From feb20aac304b39e18c70f88cae2f7cf7d5c82db2 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 24 Mar 2021 17:39:37 -0700 Subject: Formats the source and updates the gcc warning pragmas --- c++/examples/chunks.cpp | 84 +- c++/examples/compound.cpp | 323 +- c++/examples/create.cpp | 194 +- c++/examples/extend_ds.cpp | 386 +- c++/examples/h5group.cpp | 86 +- c++/examples/h5tutr_cmprss.cpp | 84 +- c++/examples/h5tutr_crtatt.cpp | 65 +- c++/examples/h5tutr_crtdat.cpp | 32 +- c++/examples/h5tutr_crtgrp.cpp | 12 +- c++/examples/h5tutr_crtgrpar.cpp | 18 +- c++/examples/h5tutr_crtgrpd.cpp | 66 +- c++/examples/h5tutr_extend.cpp | 87 +- c++/examples/h5tutr_rdwt.cpp | 30 +- c++/examples/h5tutr_subset.cpp | 67 +- c++/examples/readdata.cpp | 348 +- c++/examples/writedata.cpp | 190 +- c++/src/H5AbstractDs.cpp | 99 +- c++/src/H5AbstractDs.h | 86 +- c++/src/H5ArrayType.cpp | 52 +- c++/src/H5ArrayType.h | 60 +- c++/src/H5AtomType.cpp | 95 +- c++/src/H5AtomType.h | 68 +- c++/src/H5Attribute.cpp | 227 +- c++/src/H5Attribute.h | 105 +- c++/src/H5Classes.h | 54 +- c++/src/H5CommonFG.cpp | 98 +- c++/src/H5CommonFG.h | 73 +- c++/src/H5CompType.cpp | 179 +- c++/src/H5CompType.h | 140 +- c++/src/H5Cpp.h | 4 +- c++/src/H5DaccProp.cpp | 50 +- c++/src/H5DaccProp.h | 52 +- c++/src/H5DataSet.cpp | 296 +- c++/src/H5DataSet.h | 214 +- c++/src/H5DataSpace.cpp | 251 +- c++/src/H5DataSpace.h | 163 +- c++/src/H5DataType.cpp | 278 +- c++/src/H5DataType.h | 211 +- c++/src/H5DcreatProp.cpp | 307 +- c++/src/H5DcreatProp.h | 167 +- c++/src/H5DxferProp.cpp | 250 +- c++/src/H5DxferProp.h | 141 +- c++/src/H5EnumType.cpp | 109 +- c++/src/H5EnumType.h | 84 +- c++/src/H5Exception.cpp | 259 +- c++/src/H5Exception.h | 218 +- c++/src/H5FaccProp.cpp | 258 +- c++/src/H5FaccProp.h | 186 +- c++/src/H5FcreatProp.cpp | 165 +- c++/src/H5FcreatProp.h | 106 +- c++/src/H5File.cpp | 196 +- c++/src/H5File.h | 150 +- c++/src/H5FloatType.cpp | 90 +- c++/src/H5FloatType.h | 78 +- c++/src/H5Group.cpp | 70 +- c++/src/H5Group.h | 76 +- c++/src/H5IdComponent.cpp | 105 +- c++/src/H5IdComponent.h | 109 +- c++/src/H5Include.h | 9 +- c++/src/H5IntType.cpp | 52 +- c++/src/H5IntType.h | 54 +- c++/src/H5LaccProp.cpp | 54 +- c++/src/H5LaccProp.h | 54 +- c++/src/H5LcreatProp.cpp | 70 +- c++/src/H5LcreatProp.h | 64 +- c++/src/H5Library.cpp | 91 +- c++/src/H5Library.h | 57 +- c++/src/H5Location.cpp | 770 +- c++/src/H5Location.h | 575 +- c++/src/H5Object.cpp | 214 +- c++/src/H5Object.h | 118 +- c++/src/H5OcreatProp.cpp | 68 +- c++/src/H5OcreatProp.h | 61 +- c++/src/H5PredType.cpp | 686 +- c++/src/H5PredType.h | 642 +- c++/src/H5PropList.cpp | 266 +- c++/src/H5PropList.h | 166 +- c++/src/H5StrType.cpp | 69 +- c++/src/H5StrType.h | 70 +- c++/src/H5VarLenType.cpp | 43 +- c++/src/H5VarLenType.h | 48 +- c++/test/dsets.cpp | 728 +- c++/test/h5cpputil.cpp | 120 +- c++/test/h5cpputil.h | 106 +- c++/test/tarray.cpp | 212 +- c++/test/tattr.cpp | 856 +- c++/test/tcompound.cpp | 470 +- c++/test/tdspl.cpp | 68 +- c++/test/testhdf5.cpp | 65 +- c++/test/tfile.cpp | 550 +- c++/test/tfilter.cpp | 102 +- c++/test/th5s.cpp | 268 +- c++/test/titerate.cpp | 246 +- c++/test/tlinks.cpp | 327 +- c++/test/tobject.cpp | 186 +- c++/test/trefer.cpp | 385 +- c++/test/ttypes.cpp | 339 +- c++/test/tvlstr.cpp | 265 +- examples/credel.c | 637 +- examples/gaussians.c | 1049 +- examples/h5_attribute.c | 372 +- examples/h5_chunk_read.c | 103 +- examples/h5_cmprss.c | 121 +- examples/h5_compound.c | 56 +- examples/h5_crtatt.c | 57 +- examples/h5_crtdat.c | 41 +- examples/h5_crtgrp.c | 24 +- examples/h5_crtgrpar.c | 36 +- examples/h5_crtgrpd.c | 99 +- examples/h5_debug_trace.c | 84 +- examples/h5_drivers.c | 19 +- examples/h5_dtransform.c | 120 +- examples/h5_elink_unix2win.c | 126 +- examples/h5_extend.c | 135 +- examples/h5_extend_write.c | 102 +- examples/h5_extlink.c | 255 +- examples/h5_group.c | 105 +- examples/h5_interm_group.c | 74 +- examples/h5_mount.c | 198 +- examples/h5_rdwt.c | 42 +- examples/h5_read.c | 104 +- examples/h5_ref2reg_deprec.c | 93 +- examples/h5_ref_compat.c | 45 +- examples/h5_ref_extern.c | 48 +- examples/h5_reference_deprec.c | 239 +- examples/h5_select.c | 232 +- examples/h5_shared_mesg.c | 203 +- examples/h5_subset.c | 131 +- examples/h5_vds-eiger.c | 221 +- examples/h5_vds-exc.c | 296 +- examples/h5_vds-exclim.c | 287 +- examples/h5_vds-percival-unlim-maxmin.c | 376 +- examples/h5_vds-percival-unlim.c | 426 +- examples/h5_vds-percival.c | 280 +- examples/h5_vds-simpleIO.c | 167 +- examples/h5_vds.c | 217 +- examples/h5_write.c | 38 +- examples/nbcompat.c | 2 +- examples/nbcompat.h | 40 +- examples/ph5example.c | 866 +- fortran/src/H5Af.c | 694 +- fortran/src/H5Df.c | 1307 +- fortran/src/H5Ef.c | 98 +- fortran/src/H5Ff.c | 576 +- fortran/src/H5Gf.c | 516 +- fortran/src/H5If.c | 189 +- fortran/src/H5Lf.c | 516 +- fortran/src/H5Of.c | 911 +- fortran/src/H5Pf.c | 4029 ++- fortran/src/H5Rf.c | 270 +- fortran/src/H5Sf.c | 987 +- fortran/src/H5Tf.c | 1610 +- fortran/src/H5Zf.c | 68 +- fortran/src/H5_f.c | 729 +- fortran/src/H5f90.h | 6 +- fortran/src/H5f90i.h | 5 +- fortran/src/H5f90kit.c | 25 +- fortran/src/H5f90proto.h | 734 +- fortran/src/H5match_types.c | 578 +- fortran/test/t.c | 110 +- fortran/test/t.h | 22 +- hl/c++/examples/ptExampleFL.cpp | 51 +- hl/c++/src/H5PacketTable.cpp | 525 +- hl/c++/src/H5PacketTable.h | 55 +- hl/c++/test/ptableTest.cpp | 553 +- hl/examples/ex_ds1.c | 176 +- hl/examples/ex_image1.c | 85 +- hl/examples/ex_image2.c | 274 +- hl/examples/ex_lite1.c | 27 +- hl/examples/ex_lite2.c | 50 +- hl/examples/ex_lite3.c | 70 +- hl/examples/ex_table_01.c | 189 +- hl/examples/ex_table_02.c | 180 +- hl/examples/ex_table_03.c | 187 +- hl/examples/ex_table_04.c | 246 +- hl/examples/ex_table_05.c | 242 +- hl/examples/ex_table_06.c | 123 +- hl/examples/ex_table_07.c | 155 +- hl/examples/ex_table_08.c | 205 +- hl/examples/ex_table_09.c | 210 +- hl/examples/ex_table_10.c | 196 +- hl/examples/ex_table_11.c | 164 +- hl/examples/ex_table_12.c | 148 +- hl/examples/pal_rgb.h | 302 +- hl/examples/ptExampleFL.c | 88 +- hl/fortran/src/H5DSfc.c | 510 +- hl/fortran/src/H5IMcc.c | 565 +- hl/fortran/src/H5IMcc.h | 34 +- hl/fortran/src/H5IMfc.c | 809 +- hl/fortran/src/H5LTf90proto.h | 494 +- hl/fortran/src/H5LTfc.c | 1004 +- hl/fortran/src/H5TBfc.c | 719 +- hl/src/H5DO.c | 147 +- hl/src/H5DOpublic.h | 13 +- hl/src/H5DS.c | 1839 +- hl/src/H5DSprivate.h | 10 +- hl/src/H5DSpublic.h | 48 +- hl/src/H5HLprivate2.h | 1 - hl/src/H5IM.c | 1297 +- hl/src/H5IMprivate.h | 10 +- hl/src/H5IMpublic.h | 85 +- hl/src/H5LD.c | 527 +- hl/src/H5LDprivate.h | 5 +- hl/src/H5LDpublic.h | 5 +- hl/src/H5LT.c | 4479 ++- hl/src/H5LTprivate.h | 23 +- hl/src/H5LTpublic.h | 349 +- hl/src/H5PT.c | 885 +- hl/src/H5PTprivate.h | 1 - hl/src/H5PTpublic.h | 28 +- hl/src/H5TB.c | 3247 +- hl/src/H5TBprivate.h | 27 +- hl/src/H5TBpublic.h | 195 +- hl/src/hdf5_hl.h | 1 - hl/test/gen_test_ds.c | 393 +- hl/test/gen_test_ld.c | 430 +- hl/test/h5hltest.h | 19 +- hl/test/pal_rgb.h | 296 +- hl/test/test_ds.c | 3980 +- hl/test/test_dset_append.c | 869 +- hl/test/test_file_image.c | 181 +- hl/test/test_h5do_compat.c | 90 +- hl/test/test_image.c | 749 +- hl/test/test_ld.c | 1280 +- hl/test/test_lite.c | 2044 +- hl/test/test_packet.c | 776 +- hl/test/test_packet_vlen.c | 1068 +- hl/test/test_table.c | 1815 +- hl/tools/gif2h5/decompress.c | 176 +- hl/tools/gif2h5/gif.h | 81 +- hl/tools/gif2h5/gif2hdf.c | 46 +- hl/tools/gif2h5/gif2mem.c | 181 +- hl/tools/gif2h5/gifread.c | 306 +- hl/tools/gif2h5/h52gifgentst.c | 66 +- hl/tools/gif2h5/hdf2gif.c | 229 +- hl/tools/gif2h5/hdfgifwr.c | 217 +- hl/tools/gif2h5/writehdf.c | 57 +- hl/tools/h5watch/extend_dset.c | 292 +- hl/tools/h5watch/h5watch.c | 553 +- hl/tools/h5watch/h5watchgentest.c | 275 +- hl/tools/h5watch/swmr_check_compat_vfd.c | 8 +- java/src/jni/exceptionImp.c | 135 +- java/src/jni/exceptionImp.h | 25 +- java/src/jni/h5Constants.c | 3288 +- java/src/jni/h5Imp.c | 44 +- java/src/jni/h5Imp.h | 33 +- java/src/jni/h5aImp.c | 594 +- java/src/jni/h5aImp.h | 220 +- java/src/jni/h5dImp.c | 662 +- java/src/jni/h5dImp.h | 182 +- java/src/jni/h5eImp.c | 112 +- java/src/jni/h5eImp.h | 70 +- java/src/jni/h5fImp.c | 165 +- java/src/jni/h5fImp.h | 122 +- java/src/jni/h5gImp.c | 68 +- java/src/jni/h5gImp.h | 44 +- java/src/jni/h5iImp.c | 65 +- java/src/jni/h5iImp.h | 60 +- java/src/jni/h5jni.h | 498 +- java/src/jni/h5lImp.c | 283 +- java/src/jni/h5lImp.h | 90 +- java/src/jni/h5oImp.c | 324 +- java/src/jni/h5oImp.h | 116 +- java/src/jni/h5pDAPLImp.c | 93 +- java/src/jni/h5pDAPLImp.h | 39 +- java/src/jni/h5pDCPLImp.c | 470 +- java/src/jni/h5pDCPLImp.h | 174 +- java/src/jni/h5pDXPLImp.c | 110 +- java/src/jni/h5pDXPLImp.h | 60 +- java/src/jni/h5pFAPLImp.c | 489 +- java/src/jni/h5pFAPLImp.h | 193 +- java/src/jni/h5pFCPLImp.c | 174 +- java/src/jni/h5pFCPLImp.h | 87 +- java/src/jni/h5pGCPLImp.c | 54 +- java/src/jni/h5pGCPLImp.h | 32 +- java/src/jni/h5pImp.c | 371 +- java/src/jni/h5pImp.h | 111 +- java/src/jni/h5pLAPLImp.c | 45 +- java/src/jni/h5pLAPLImp.h | 32 +- java/src/jni/h5pOCPLImp.c | 38 +- java/src/jni/h5pOCPLImp.h | 33 +- java/src/jni/h5pOCpyPLImp.c | 6 +- java/src/jni/h5pOCpyPLImp.h | 8 +- java/src/jni/h5pStrCPLImp.c | 6 +- java/src/jni/h5pStrCPLImp.h | 8 +- java/src/jni/h5plImp.c | 53 +- java/src/jni/h5plImp.h | 36 +- java/src/jni/h5rImp.c | 274 +- java/src/jni/h5rImp.h | 86 +- java/src/jni/h5sImp.c | 458 +- java/src/jni/h5sImp.h | 133 +- java/src/jni/h5tImp.c | 423 +- java/src/jni/h5tImp.h | 277 +- java/src/jni/h5util.c | 1355 +- java/src/jni/h5util.h | 78 +- java/src/jni/h5vlImp.c | 59 +- java/src/jni/h5vlImp.h | 43 +- java/src/jni/h5zImp.c | 12 +- java/src/jni/h5zImp.h | 12 +- java/src/jni/nativeData.c | 486 +- java/src/jni/nativeData.h | 95 +- src/H5.c | 520 +- src/H5A.c | 673 +- src/H5AC.c | 1059 +- src/H5ACdbg.c | 63 +- src/H5ACmodule.h | 7 +- src/H5ACmpio.c | 763 +- src/H5ACpkg.h | 87 +- src/H5ACprivate.h | 461 +- src/H5ACproxy_entry.c | 224 +- src/H5ACpublic.h | 86 +- src/H5Abtree2.c | 185 +- src/H5Adense.c | 1061 +- src/H5Adeprec.c | 158 +- src/H5Aint.c | 1115 +- src/H5Amodule.h | 7 +- src/H5Apkg.h | 202 +- src/H5Aprivate.h | 39 +- src/H5Apublic.h | 93 +- src/H5Atest.c | 51 +- src/H5B.c | 1227 +- src/H5B2.c | 759 +- src/H5B2cache.c | 543 +- src/H5B2dbg.c | 193 +- src/H5B2hdr.c | 284 +- src/H5B2int.c | 1298 +- src/H5B2internal.c | 837 +- src/H5B2leaf.c | 504 +- src/H5B2module.h | 8 +- src/H5B2pkg.h | 451 +- src/H5B2private.h | 122 +- src/H5B2stat.c | 33 +- src/H5B2test.c | 201 +- src/H5Bcache.c | 147 +- src/H5Bdbg.c | 153 +- src/H5Bmodule.h | 7 +- src/H5Bpkg.h | 36 +- src/H5Bprivate.h | 127 +- src/H5C.c | 11472 +++--- src/H5CS.c | 84 +- src/H5CSprivate.h | 9 +- src/H5CX.c | 1265 +- src/H5CXmodule.h | 7 +- src/H5CXprivate.h | 71 +- src/H5Cdbg.c | 1107 +- src/H5Cepoch.c | 110 +- src/H5Cimage.c | 1882 +- src/H5Clog.c | 276 +- src/H5Clog.h | 99 +- src/H5Clog_json.c | 506 +- src/H5Clog_trace.c | 390 +- src/H5Cmodule.h | 7 +- src/H5Cmpio.c | 749 +- src/H5Cpkg.h | 5066 ++- src/H5Cprefetched.c | 141 +- src/H5Cprivate.h | 838 +- src/H5Cpublic.h | 15 +- src/H5Cquery.c | 180 +- src/H5Ctag.c | 273 +- src/H5Ctest.c | 74 +- src/H5D.c | 399 +- src/H5Dbtree.c | 618 +- src/H5Dbtree2.c | 643 +- src/H5Dchunk.c | 4037 ++- src/H5Dcompact.c | 276 +- src/H5Dcontig.c | 813 +- src/H5Ddbg.c | 34 +- src/H5Ddeprec.c | 139 +- src/H5Dearray.c | 685 +- src/H5Defl.c | 265 +- src/H5Dfarray.c | 613 +- src/H5Dfill.c | 305 +- src/H5Dint.c | 1887 +- src/H5Dio.c | 669 +- src/H5Dlayout.c | 303 +- src/H5Dmodule.h | 7 +- src/H5Dmpio.c | 1826 +- src/H5Dnone.c | 160 +- src/H5Doh.c | 198 +- src/H5Dpkg.h | 797 +- src/H5Dprivate.h | 166 +- src/H5Dpublic.h | 176 +- src/H5Dscatgath.c | 620 +- src/H5Dselect.c | 179 +- src/H5Dsingle.c | 196 +- src/H5Dtest.c | 84 +- src/H5Dvirtual.c | 1847 +- src/H5E.c | 564 +- src/H5EA.c | 586 +- src/H5EAcache.c | 1162 +- src/H5EAdbg.c | 298 +- src/H5EAdblkpage.c | 158 +- src/H5EAdblock.c | 229 +- src/H5EAhdr.c | 409 +- src/H5EAiblock.c | 263 +- src/H5EAint.c | 43 +- src/H5EAmodule.h | 7 +- src/H5EApkg.h | 467 +- src/H5EAprivate.h | 97 +- src/H5EAsblock.c | 215 +- src/H5EAstat.c | 32 +- src/H5EAtest.c | 197 +- src/H5ESpublic.h | 12 +- src/H5Edeprec.c | 130 +- src/H5Eint.c | 406 +- src/H5Emodule.h | 8 +- src/H5Epkg.h | 80 +- src/H5Eprivate.h | 132 +- src/H5Epublic.h | 195 +- src/H5F.c | 760 +- src/H5FA.c | 420 +- src/H5FAcache.c | 625 +- src/H5FAdbg.c | 179 +- src/H5FAdblkpage.c | 154 +- src/H5FAdblock.c | 193 +- src/H5FAhdr.c | 265 +- src/H5FAint.c | 43 +- src/H5FAmodule.h | 7 +- src/H5FApkg.h | 268 +- src/H5FAprivate.h | 82 +- src/H5FAstat.c | 32 +- src/H5FAtest.c | 152 +- src/H5FD.c | 570 +- src/H5FDcore.c | 861 +- src/H5FDcore.h | 11 +- src/H5FDdirect.c | 993 +- src/H5FDdirect.h | 20 +- src/H5FDdrvr_module.h | 7 +- src/H5FDfamily.c | 716 +- src/H5FDfamily.h | 11 +- src/H5FDhdfs.c | 687 +- src/H5FDhdfs.h | 8 +- src/H5FDint.c | 147 +- src/H5FDlog.c | 988 +- src/H5FDlog.h | 53 +- src/H5FDmirror.c | 687 +- src/H5FDmirror.h | 46 +- src/H5FDmodule.h | 7 +- src/H5FDmpi.c | 98 +- src/H5FDmpi.h | 9 +- src/H5FDmpio.c | 796 +- src/H5FDmpio.h | 12 +- src/H5FDmulti.c | 1409 +- src/H5FDmulti.h | 20 +- src/H5FDpkg.h | 14 +- src/H5FDprivate.h | 275 +- src/H5FDpublic.h | 445 +- src/H5FDros3.c | 484 +- src/H5FDros3.h | 17 +- src/H5FDs3comms.c | 1532 +- src/H5FDs3comms.h | 148 +- src/H5FDsec2.c | 508 +- src/H5FDsec2.h | 5 +- src/H5FDspace.c | 153 +- src/H5FDsplitter.c | 402 +- src/H5FDsplitter.h | 15 +- src/H5FDstdio.c | 601 +- src/H5FDstdio.h | 4 +- src/H5FDtest.c | 60 +- src/H5FDvfd_swmr.c | 703 +- src/H5FDvfd_swmr.h | 4 +- src/H5FDvfd_swmr_instr.c | 7 +- src/H5FDvfd_swmr_private.h | 31 +- src/H5FDwindows.c | 28 +- src/H5FDwindows.h | 3 +- src/H5FL.c | 871 +- src/H5FLmodule.h | 7 +- src/H5FLprivate.h | 301 +- src/H5FO.c | 138 +- src/H5FOprivate.h | 29 +- src/H5FS.c | 576 +- src/H5FScache.c | 528 +- src/H5FSdbg.c | 135 +- src/H5FSint.c | 35 +- src/H5FSmodule.h | 7 +- src/H5FSpkg.h | 197 +- src/H5FSprivate.h | 244 +- src/H5FSsection.c | 1229 +- src/H5FSstat.c | 35 +- src/H5FStest.c | 50 +- src/H5Faccum.c | 534 +- src/H5Fcwfs.c | 132 +- src/H5Fdbg.c | 90 +- src/H5Fdeprec.c | 72 +- src/H5Fefc.c | 343 +- src/H5Ffake.c | 32 +- src/H5Fint.c | 1634 +- src/H5Fio.c | 108 +- src/H5Fmodule.h | 7 +- src/H5Fmount.c | 351 +- src/H5Fmpi.c | 88 +- src/H5Fpkg.h | 658 +- src/H5Fprivate.h | 1218 +- src/H5Fpublic.h | 367 +- src/H5Fquery.c | 110 +- src/H5Fsfile.c | 49 +- src/H5Fspace.c | 51 +- src/H5Fsuper.c | 841 +- src/H5Fsuper_cache.c | 772 +- src/H5Ftest.c | 289 +- src/H5Fvfd_swmr.c | 938 +- src/H5G.c | 295 +- src/H5Gbtree2.c | 188 +- src/H5Gcache.c | 113 +- src/H5Gcompact.c | 205 +- src/H5Gdense.c | 819 +- src/H5Gdeprec.c | 541 +- src/H5Gent.c | 197 +- src/H5Gint.c | 558 +- src/H5Glink.c | 187 +- src/H5Gloc.c | 431 +- src/H5Gmodule.h | 7 +- src/H5Gname.c | 585 +- src/H5Gnode.c | 662 +- src/H5Gobj.c | 570 +- src/H5Goh.c | 176 +- src/H5Gpkg.h | 381 +- src/H5Gprivate.h | 257 +- src/H5Gpublic.h | 135 +- src/H5Groot.c | 200 +- src/H5Gstab.c | 439 +- src/H5Gtest.c | 383 +- src/H5Gtraverse.c | 446 +- src/H5HF.c | 301 +- src/H5HFbtree2.c | 269 +- src/H5HFcache.c | 1383 +- src/H5HFdbg.c | 482 +- src/H5HFdblock.c | 334 +- src/H5HFdtable.c | 132 +- src/H5HFhdr.c | 625 +- src/H5HFhuge.c | 460 +- src/H5HFiblock.c | 911 +- src/H5HFiter.c | 232 +- src/H5HFman.c | 262 +- src/H5HFmodule.h | 7 +- src/H5HFpkg.h | 893 +- src/H5HFprivate.h | 90 +- src/H5HFsection.c | 1900 +- src/H5HFspace.c | 181 +- src/H5HFstat.c | 74 +- src/H5HFtest.c | 140 +- src/H5HFtiny.c | 104 +- src/H5HG.c | 332 +- src/H5HGcache.c | 156 +- src/H5HGdbg.c | 125 +- src/H5HGmodule.h | 7 +- src/H5HGpkg.h | 71 +- src/H5HGprivate.h | 38 +- src/H5HGquery.c | 21 +- src/H5HGtrap.c | 10 +- src/H5HL.c | 437 +- src/H5HLcache.c | 317 +- src/H5HLdbg.c | 71 +- src/H5HLdblk.c | 95 +- src/H5HLint.c | 70 +- src/H5HLmodule.h | 7 +- src/H5HLpkg.h | 96 +- src/H5HLprfx.c | 46 +- src/H5HLprivate.h | 28 +- src/H5HP.c | 395 +- src/H5HPprivate.h | 23 +- src/H5I.c | 764 +- src/H5Imodule.h | 7 +- src/H5Ipkg.h | 14 +- src/H5Iprivate.h | 63 +- src/H5Ipublic.h | 77 +- src/H5Itest.c | 51 +- src/H5L.c | 1603 +- src/H5Ldeprec.c | 303 +- src/H5Lexternal.c | 303 +- src/H5Lmodule.h | 8 +- src/H5Lpkg.h | 14 +- src/H5Lprivate.h | 123 +- src/H5Lpublic.h | 239 +- src/H5M.c | 352 +- src/H5MF.c | 1601 +- src/H5MFaggr.c | 1367 +- src/H5MFdbg.c | 153 +- src/H5MFmodule.h | 7 +- src/H5MFpkg.h | 143 +- src/H5MFprivate.h | 20 +- src/H5MFsection.c | 462 +- src/H5MM.c | 204 +- src/H5MMprivate.h | 27 +- src/H5MMpublic.h | 1 - src/H5MP.c | 196 +- src/H5MPmodule.h | 7 +- src/H5MPpkg.h | 45 +- src/H5MPprivate.h | 15 +- src/H5MPtest.c | 48 +- src/H5MV.c | 263 +- src/H5MVmodule.h | 7 +- src/H5MVpkg.h | 21 +- src/H5MVprivate.h | 12 +- src/H5MVsection.c | 155 +- src/H5Mmodule.h | 8 +- src/H5Mpkg.h | 4 - src/H5Mprivate.h | 33 +- src/H5Mpublic.h | 75 +- src/H5O.c | 610 +- src/H5Oainfo.c | 221 +- src/H5Oalloc.c | 1457 +- src/H5Oattr.c | 419 +- src/H5Oattribute.c | 916 +- src/H5Obogus.c | 134 +- src/H5Obtreek.c | 120 +- src/H5Ocache.c | 675 +- src/H5Ocache_image.c | 152 +- src/H5Ochunk.c | 131 +- src/H5Ocont.c | 109 +- src/H5Ocopy.c | 856 +- src/H5Ocopy_ref.c | 291 +- src/H5Odbg.c | 320 +- src/H5Odeprec.c | 531 +- src/H5Odrvinfo.c | 133 +- src/H5Odtype.c | 1321 +- src/H5Oefl.c | 318 +- src/H5Ofill.c | 537 +- src/H5Oflush.c | 243 +- src/H5Ofsinfo.c | 226 +- src/H5Oginfo.c | 171 +- src/H5Oint.c | 1099 +- src/H5Olayout.c | 615 +- src/H5Olinfo.c | 272 +- src/H5Olink.c | 421 +- src/H5Omessage.c | 737 +- src/H5Omodule.h | 7 +- src/H5Omtime.c | 217 +- src/H5Oname.c | 124 +- src/H5Onull.c | 49 +- src/H5Opkg.h | 550 +- src/H5Opline.c | 448 +- src/H5Oprivate.h | 885 +- src/H5Opublic.h | 284 +- src/H5Orefcount.c | 125 +- src/H5Osdspace.c | 325 +- src/H5Oshared.c | 279 +- src/H5Oshared.h | 135 +- src/H5Oshmesg.c | 100 +- src/H5Ostab.c | 186 +- src/H5Otest.c | 376 +- src/H5Ounknown.c | 54 +- src/H5P.c | 519 +- src/H5PB.c | 2816 +- src/H5PBmodule.h | 6 +- src/H5PBpkg.h | 2518 +- src/H5PBprivate.h | 433 +- src/H5PL.c | 66 +- src/H5PLextern.h | 11 +- src/H5PLint.c | 108 +- src/H5PLmodule.h | 8 +- src/H5PLpath.c | 164 +- src/H5PLpkg.h | 106 +- src/H5PLplugin_cache.c | 93 +- src/H5PLprivate.h | 15 +- src/H5PLpublic.h | 35 +- src/H5Pacpl.c | 32 +- src/H5Pdapl.c | 649 +- src/H5Pdcpl.c | 2032 +- src/H5Pdeprec.c | 176 +- src/H5Pdxpl.c | 900 +- src/H5Pencdec.c | 228 +- src/H5Pfapl.c | 2631 +- src/H5Pfcpl.c | 692 +- src/H5Pfmpl.c | 65 +- src/H5Pgcpl.c | 252 +- src/H5Pint.c | 2377 +- src/H5Plapl.c | 529 +- src/H5Plcpl.c | 92 +- src/H5Pmapl.c | 120 +- src/H5Pmcpl.c | 55 +- src/H5Pmodule.h | 7 +- src/H5Pocpl.c | 736 +- src/H5Pocpypl.c | 364 +- src/H5Ppkg.h | 163 +- src/H5Pprivate.h | 170 +- src/H5Ppublic.h | 562 +- src/H5Pstrcpl.c | 104 +- src/H5Ptest.c | 36 +- src/H5R.c | 501 +- src/H5RS.c | 70 +- src/H5RSprivate.h | 13 +- src/H5Rdeprec.c | 344 +- src/H5Rint.c | 702 +- src/H5Rmodule.h | 7 +- src/H5Rpkg.h | 107 +- src/H5Rprivate.h | 8 +- src/H5Rpublic.h | 61 +- src/H5S.c | 647 +- src/H5SL.c | 1239 +- src/H5SLmodule.h | 7 +- src/H5SLprivate.h | 40 +- src/H5SM.c | 1304 +- src/H5SMbtree2.c | 84 +- src/H5SMcache.c | 265 +- src/H5SMmessage.c | 111 +- src/H5SMmodule.h | 7 +- src/H5SMpkg.h | 179 +- src/H5SMprivate.h | 36 +- src/H5SMtest.c | 45 +- src/H5ST.c | 186 +- src/H5STprivate.h | 35 +- src/H5Sall.c | 187 +- src/H5Sdbg.c | 36 +- src/H5Sdeprec.c | 34 +- src/H5Shyper.c | 5547 +-- src/H5Smodule.h | 7 +- src/H5Smpio.c | 915 +- src/H5Snone.c | 170 +- src/H5Spkg.h | 265 +- src/H5Spoint.c | 781 +- src/H5Sprivate.h | 344 +- src/H5Spublic.h | 247 +- src/H5Sselect.c | 1011 +- src/H5Stest.c | 136 +- src/H5T.c | 3731 +- src/H5TS.c | 98 +- src/H5TSprivate.h | 110 +- src/H5Tarray.c | 146 +- src/H5Tbit.c | 138 +- src/H5Tcommit.c | 512 +- src/H5Tcompound.c | 235 +- src/H5Tconv.c | 6351 ++-- src/H5Tcset.c | 49 +- src/H5Tdbg.c | 106 +- src/H5Tdeprec.c | 85 +- src/H5Tenum.c | 305 +- src/H5Tfields.c | 350 +- src/H5Tfixed.c | 42 +- src/H5Tfloat.c | 202 +- src/H5Tmodule.h | 7 +- src/H5Tnative.c | 1057 +- src/H5Toffset.c | 89 +- src/H5Toh.c | 88 +- src/H5Topaque.c | 35 +- src/H5Torder.c | 117 +- src/H5Tpad.c | 33 +- src/H5Tpkg.h | 1471 +- src/H5Tprecis.c | 111 +- src/H5Tprivate.h | 119 +- src/H5Tpublic.h | 586 +- src/H5Tref.c | 587 +- src/H5Tstrpad.c | 37 +- src/H5Tvisit.c | 60 +- src/H5Tvlen.c | 348 +- src/H5UC.c | 26 +- src/H5UCprivate.h | 14 +- src/H5VL.c | 236 +- src/H5VLcallback.c | 3104 +- src/H5VLconnector.h | 382 +- src/H5VLconnector_passthru.h | 193 +- src/H5VLint.c | 828 +- src/H5VLmodule.h | 7 +- src/H5VLnative.c | 322 +- src/H5VLnative.h | 118 +- src/H5VLnative_attr.c | 626 +- src/H5VLnative_blob.c | 171 +- src/H5VLnative_dataset.c | 708 +- src/H5VLnative_datatype.c | 154 +- src/H5VLnative_file.c | 1104 +- src/H5VLnative_group.c | 296 +- src/H5VLnative_introspect.c | 10 +- src/H5VLnative_link.c | 479 +- src/H5VLnative_object.c | 790 +- src/H5VLnative_private.h | 148 +- src/H5VLnative_token.c | 34 +- src/H5VLpassthru.c | 1277 +- src/H5VLpassthru.h | 16 +- src/H5VLpkg.h | 35 +- src/H5VLprivate.h | 212 +- src/H5VLpublic.h | 70 +- src/H5VM.c | 701 +- src/H5VMprivate.h | 324 +- src/H5WB.c | 63 +- src/H5WBprivate.h | 10 +- src/H5Z.c | 539 +- src/H5Zdeflate.c | 169 +- src/H5Zfletcher32.c | 93 +- src/H5Zmodule.h | 7 +- src/H5Znbit.c | 1301 +- src/H5Zpkg.h | 3 +- src/H5Zprivate.h | 76 +- src/H5Zpublic.h | 132 +- src/H5Zscaleoffset.c | 2204 +- src/H5Zshuffle.c | 308 +- src/H5Zszip.c | 215 +- src/H5Ztrans.c | 1373 +- src/H5api_adpt.h | 325 +- src/H5checksum.c | 207 +- src/H5dbg.c | 85 +- src/H5detect.c | 1177 +- src/H5make_libsettings.c | 96 +- src/H5mpi.c | 137 +- src/H5private.h | 2731 +- src/H5public.h | 356 +- src/H5queue.h | 984 +- src/H5retry_private.h | 29 +- src/H5system.c | 790 +- src/H5timer.c | 148 +- src/H5trace.c | 1379 +- src/H5win32defs.h | 158 +- src/hdf5.h | 70 +- test/H5srcdir.h | 1 - test/accum.c | 342 +- test/accum_swmr_reader.c | 72 +- test/app_ref.c | 122 +- test/atomic_reader.c | 121 +- test/atomic_writer.c | 63 +- test/big.c | 521 +- test/bittests.c | 1205 +- test/btree2.c | 6083 ++-- test/cache.c | 43844 +++++++++++++---------- test/cache_api.c | 1848 +- test/cache_common.c | 3806 +- test/cache_common.h | 1142 +- test/cache_image.c | 4154 +-- test/cache_logging.c | 101 +- test/cache_tagging.c | 3002 +- test/chunk_info.c | 1313 +- test/cmpd_dset.c | 1952 +- test/cork.c | 1480 +- test/cross_read.c | 192 +- test/dangle.c | 393 +- test/del_many_dense_attrs.c | 96 +- test/direct_chunk.c | 1587 +- test/dsets.c | 12382 ++++--- test/dt_arith.c | 5673 +-- test/dtransform.c | 961 +- test/dtypes.c | 6425 ++-- test/earray.c | 1542 +- test/efc.c | 2719 +- test/enc_dec_plist.c | 453 +- test/enc_dec_plist_cross_platform.c | 97 +- test/enum.c | 734 +- test/err_compat.c | 241 +- test/error_test.c | 224 +- test/evict_on_close.c | 519 +- test/extend.c | 261 +- test/external.c | 953 +- test/external_common.c | 49 +- test/external_common.h | 9 +- test/external_env.c | 121 +- test/external_fname.h | 12 +- test/farray.c | 789 +- test/fheap.c | 10137 +++--- test/file_image.c | 644 +- test/filenotclosed.c | 65 +- test/fillval.c | 2434 +- test/filter_fail.c | 283 +- test/filter_plugin.c | 334 +- test/filter_plugin1_dsets.c | 47 +- test/filter_plugin2_dsets.c | 46 +- test/filter_plugin3_dsets.c | 55 +- test/filter_plugin4_groups.c | 56 +- test/flush1.c | 184 +- test/flush2.c | 209 +- test/flushrefresh.c | 1067 +- test/freespace.c | 1939 +- test/gen_bad_compound.c | 22 +- test/gen_bad_offset.c | 69 +- test/gen_bad_ohdr.c | 66 +- test/gen_bogus.c | 107 +- test/gen_bounds.c | 764 +- test/gen_cross.c | 672 +- test/gen_deflate.c | 61 +- test/gen_file_image.c | 44 +- test/gen_filespace.c | 79 +- test/gen_filters.c | 180 +- test/gen_mergemsg.c | 50 +- test/gen_new_array.c | 68 +- test/gen_new_fill.c | 87 +- test/gen_new_group.c | 76 +- test/gen_new_mtime.c | 13 +- test/gen_new_super.c | 16 +- test/gen_noencoder.c | 29 +- test/gen_nullspace.c | 20 +- test/gen_old_array.c | 71 +- test/gen_old_group.c | 26 +- test/gen_old_layout.c | 30 +- test/gen_old_mtime.c | 14 +- test/gen_plist.c | 383 +- test/gen_sizes_lheap.c | 15 +- test/gen_specmetaread.c | 26 +- test/gen_udlinks.c | 104 +- test/genall5.c | 888 +- test/genall5.h | 24 +- test/getname.c | 3372 +- test/gheap.c | 323 +- test/h5test.c | 791 +- test/h5test.h | 273 +- test/hdfs.c | 744 +- test/hyperslab.c | 856 +- test/istore.c | 512 +- test/lheap.c | 104 +- test/links.c | 18373 ++++++---- test/links_env.c | 109 +- test/mf.c | 4654 +-- test/mirror_vfd.c | 1205 +- test/mount.c | 3287 +- test/mtime.c | 117 +- test/ntypes.c | 2241 +- test/null_vol_connector.c | 210 +- test/null_vol_connector.h | 5 +- test/objcopy.c | 13511 ++++--- test/objcopy_ref.c | 1586 +- test/ohdr.c | 1546 +- test/page_buffer.c | 2523 +- test/pool.c | 372 +- test/reserved.c | 365 +- test/ros3.c | 916 +- test/s3comms.c | 1675 +- test/set_extent.c | 1885 +- test/space_overflow.c | 15 +- test/stab.c | 1096 +- test/stubs.c | 1 - test/swmr.c | 4303 +-- test/swmr_addrem_writer.c | 184 +- test/swmr_check_compat_vfd.c | 7 +- test/swmr_common.c | 92 +- test/swmr_common.h | 32 +- test/swmr_generator.c | 175 +- test/swmr_reader.c | 240 +- test/swmr_remove_reader.c | 227 +- test/swmr_remove_writer.c | 154 +- test/swmr_sparse_reader.c | 190 +- test/swmr_sparse_writer.c | 198 +- test/swmr_start_write.c | 257 +- test/swmr_writer.c | 188 +- test/tarray.c | 1170 +- test/tattr.c | 3776 +- test/tcheck_version.c | 84 +- test/tchecksum.c | 44 +- test/tconfig.c | 47 +- test/tcoords.c | 392 +- test/testframe.c | 331 +- test/testhdf5.c | 45 +- test/testhdf5.h | 274 +- test/testmeta.c | 108 +- test/tfile.c | 2676 +- test/tgenprop.c | 783 +- test/th5o.c | 433 +- test/th5s.c | 1320 +- test/theap.c | 516 +- test/thread_id.c | 56 +- test/tid.c | 365 +- test/timer.c | 151 +- test/titerate.c | 565 +- test/tmeta.c | 106 +- test/tmisc.c | 2220 +- test/trefer.c | 892 +- test/trefer_deprec.c | 636 +- test/trefer_shutdown.c | 2 +- test/trefstr.c | 167 +- test/tselect.c | 11997 ++++--- test/tskiplist.c | 1007 +- test/tsohm.c | 1459 +- test/ttime.c | 96 +- test/ttsafe.c | 42 +- test/ttsafe.h | 26 +- test/ttsafe_acreate.c | 72 +- test/ttsafe_attr_vlen.c | 55 +- test/ttsafe_cancel.c | 117 +- test/ttsafe_dcreate.c | 82 +- test/ttsafe_error.c | 68 +- test/ttst.c | 220 +- test/tunicode.c | 1128 +- test/tvlstr.c | 383 +- test/tvltypes.c | 1802 +- test/twriteorder.c | 237 +- test/unlink.c | 2420 +- test/unregister.c | 184 +- test/use.h | 66 +- test/use_append_chunk.c | 51 +- test/use_append_chunk_mirror.c | 74 +- test/use_append_mchunks.c | 57 +- test/use_common.c | 306 +- test/use_disable_mdc_flushes.c | 483 +- test/vds.c | 8417 ++--- test/vds_env.c | 234 +- test/vds_swmr.h | 20 +- test/vds_swmr_gen.c | 157 +- test/vds_swmr_reader.c | 98 +- test/vds_swmr_writer.c | 98 +- test/vfd.c | 1735 +- test/vfd_swmr.c | 2125 +- test/vfd_swmr_addrem_writer.c | 221 +- test/vfd_swmr_bigset_writer.c | 753 +- test/vfd_swmr_common.c | 64 +- test/vfd_swmr_common.h | 29 +- test/vfd_swmr_generator.c | 185 +- test/vfd_swmr_group_writer.c | 216 +- test/vfd_swmr_reader.c | 315 +- test/vfd_swmr_remove_reader.c | 277 +- test/vfd_swmr_remove_writer.c | 187 +- test/vfd_swmr_sparse_reader.c | 254 +- test/vfd_swmr_sparse_writer.c | 221 +- test/vfd_swmr_vlstr_reader.c | 134 +- test/vfd_swmr_vlstr_writer.c | 206 +- test/vfd_swmr_writer.c | 224 +- test/vfd_swmr_zoo_writer.c | 240 +- test/vol.c | 487 +- test/vol_plugin.c | 169 +- testpar/t_2Gio.c | 2762 +- testpar/t_bigio.c | 1793 +- testpar/t_cache.c | 5137 ++- testpar/t_cache_image.c | 2454 +- testpar/t_chunk_alloc.c | 243 +- testpar/t_coll_chunk.c | 1191 +- testpar/t_coll_md_read.c | 211 +- testpar/t_dset.c | 2481 +- testpar/t_file.c | 475 +- testpar/t_file_image.c | 285 +- testpar/t_filter_read.c | 406 +- testpar/t_filters_parallel.c | 3503 +- testpar/t_filters_parallel.h | 301 +- testpar/t_init_term.c | 31 +- testpar/t_mdset.c | 1675 +- testpar/t_mpi.c | 618 +- testpar/t_pflush1.c | 105 +- testpar/t_pflush2.c | 115 +- testpar/t_ph5basic.c | 28 +- testpar/t_pread.c | 1105 +- testpar/t_prestart.c | 89 +- testpar/t_prop.c | 179 +- testpar/t_pshutdown.c | 76 +- testpar/t_shapesame.c | 3321 +- testpar/t_span_tree.c | 2661 +- testpar/testpar.h | 97 +- testpar/testphdf5.c | 514 +- testpar/testphdf5.h | 300 +- tools/lib/h5diff.c | 1223 +- tools/lib/h5diff.h | 155 +- tools/lib/h5diff_array.c | 2366 +- tools/lib/h5diff_attr.c | 334 +- tools/lib/h5diff_dset.c | 608 +- tools/lib/h5diff_util.c | 329 +- tools/lib/h5tools.c | 868 +- tools/lib/h5tools.h | 416 +- tools/lib/h5tools_dump.c | 3116 +- tools/lib/h5tools_dump.h | 100 +- tools/lib/h5tools_error.h | 262 +- tools/lib/h5tools_filters.c | 182 +- tools/lib/h5tools_ref.c | 99 +- tools/lib/h5tools_ref.h | 1 - tools/lib/h5tools_str.c | 1026 +- tools/lib/h5tools_str.h | 45 +- tools/lib/h5tools_type.c | 10 +- tools/lib/h5tools_utils.c | 411 +- tools/lib/h5tools_utils.h | 96 +- tools/lib/h5trav.c | 542 +- tools/lib/h5trav.h | 94 +- tools/lib/io_timer.c | 116 +- tools/lib/io_timer.h | 46 +- tools/lib/ph5diff.h | 33 +- tools/libtest/h5tools_test_utils.c | 771 +- tools/src/h5copy/h5copy.c | 338 +- tools/src/h5diff/h5diff_common.c | 913 +- tools/src/h5diff/h5diff_common.h | 5 +- tools/src/h5diff/h5diff_main.c | 54 +- tools/src/h5diff/ph5diff_main.c | 120 +- tools/src/h5dump/h5dump.c | 1416 +- tools/src/h5dump/h5dump.h | 102 +- tools/src/h5dump/h5dump_ddl.c | 1500 +- tools/src/h5dump/h5dump_ddl.h | 29 +- tools/src/h5dump/h5dump_defines.h | 57 +- tools/src/h5dump/h5dump_extern.h | 97 +- tools/src/h5dump/h5dump_xml.c | 3038 +- tools/src/h5dump/h5dump_xml.h | 18 +- tools/src/h5format_convert/h5format_convert.c | 259 +- tools/src/h5import/h5import.c | 4984 ++- tools/src/h5import/h5import.h | 196 +- tools/src/h5jam/h5jam.c | 313 +- tools/src/h5jam/h5unjam.c | 201 +- tools/src/h5ls/h5ls.c | 1260 +- tools/src/h5repack/h5repack.c | 225 +- tools/src/h5repack/h5repack.h | 195 +- tools/src/h5repack/h5repack_copy.c | 1408 +- tools/src/h5repack/h5repack_filters.c | 311 +- tools/src/h5repack/h5repack_main.c | 397 +- tools/src/h5repack/h5repack_opttable.c | 106 +- tools/src/h5repack/h5repack_parse.c | 314 +- tools/src/h5repack/h5repack_refs.c | 547 +- tools/src/h5repack/h5repack_verify.c | 366 +- tools/src/h5stat/h5stat.c | 1111 +- tools/src/misc/h5clear.c | 196 +- tools/src/misc/h5debug.c | 487 +- tools/src/misc/h5mkgrp.c | 126 +- tools/src/misc/h5repart.c | 335 +- tools/test/h5copy/dynlib_copy.c | 54 +- tools/test/h5copy/h5copygentest.c | 465 +- tools/test/h5diff/dynlib_diff.c | 54 +- tools/test/h5diff/h5diffgentest.c | 3665 +- tools/test/h5dump/binread.c | 21 +- tools/test/h5dump/dynlib_dump.c | 54 +- tools/test/h5dump/h5dumpgentest.c | 6452 ++-- tools/test/h5format_convert/h5fc_chk_idx.c | 53 +- tools/test/h5format_convert/h5fc_gentest.c | 587 +- tools/test/h5import/h5importtest.c | 505 +- tools/test/h5jam/getub.c | 73 +- tools/test/h5jam/h5jamgentest.c | 395 +- tools/test/h5jam/tellub.c | 62 +- tools/test/h5ls/dynlib_ls.c | 54 +- tools/test/h5repack/dynlib_rpk.c | 58 +- tools/test/h5repack/dynlib_vrpk.c | 73 +- tools/test/h5repack/h5repackgentest.c | 183 +- tools/test/h5repack/h5repacktst.c | 3903 +- tools/test/h5repack/testh5repack_detect_szip.c | 9 +- tools/test/h5stat/h5stat_gentest.c | 337 +- tools/test/misc/clear_open_chk.c | 10 +- tools/test/misc/h5clear_gentest.c | 312 +- tools/test/misc/h5perf_gentest.c | 654 +- tools/test/misc/h5repart_gentest.c | 50 +- tools/test/misc/repart_test.c | 51 +- tools/test/misc/talign.c | 115 +- tools/test/misc/vds/UC_1.h | 55 +- tools/test/misc/vds/UC_1_one_dim_gen.c | 177 +- tools/test/misc/vds/UC_2.h | 72 +- tools/test/misc/vds/UC_2_two_dims_gen.c | 192 +- tools/test/misc/vds/UC_3.h | 42 +- tools/test/misc/vds/UC_3_gaps_gen.c | 146 +- tools/test/misc/vds/UC_4.h | 38 +- tools/test/misc/vds/UC_4_printf_gen.c | 138 +- tools/test/misc/vds/UC_5.h | 31 +- tools/test/misc/vds/UC_5_stride_gen.c | 153 +- tools/test/misc/vds/UC_common.h | 19 +- tools/test/perform/chunk.c | 578 +- tools/test/perform/chunk_cache.c | 313 +- tools/test/perform/direct_write_perf.c | 430 +- tools/test/perform/iopipe.c | 188 +- tools/test/perform/overhead.c | 306 +- tools/test/perform/perf.c | 390 +- tools/test/perform/perf_meta.c | 618 +- tools/test/perform/pio_engine.c | 3628 +- tools/test/perform/pio_perf.c | 1079 +- tools/test/perform/pio_perf.h | 86 +- tools/test/perform/pio_standalone.c | 114 +- tools/test/perform/pio_standalone.h | 676 +- tools/test/perform/sio_engine.c | 1170 +- tools/test/perform/sio_perf.c | 1038 +- tools/test/perform/sio_perf.h | 74 +- tools/test/perform/sio_standalone.c | 63 +- tools/test/perform/sio_standalone.h | 696 +- tools/test/perform/zip_perf.c | 342 +- utils/mirror_vfd/mirror_remote.c | 82 +- utils/mirror_vfd/mirror_remote.h | 21 +- utils/mirror_vfd/mirror_server.c | 197 +- utils/mirror_vfd/mirror_server_stop.c | 66 +- utils/mirror_vfd/mirror_writer.c | 315 +- 1148 files changed, 335117 insertions(+), 326667 deletions(-) diff --git a/c++/examples/chunks.cpp b/c++/examples/chunks.cpp index 03e2855..fdcb6d3 100644 --- a/c++/examples/chunks.cpp +++ b/c++/examples/chunks.cpp @@ -28,20 +28,20 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDSextendible.h5" ); -const H5std_string DATASET_NAME( "ExtendibleArray" ); -const int NX = 10; -const int NY = 5; -const int RANK = 2; -const int RANKC = 1; - -int main (void) +const H5std_string FILE_NAME("SDSextendible.h5"); +const H5std_string DATASET_NAME("ExtendibleArray"); +const int NX = 10; +const int NY = 5; +const int RANK = 2; +const int RANKC = 1; + +int +main(void) { - hsize_t i, j; + hsize_t i, j; // Try block to detect exceptions raised by any of the calls inside it - try - { + try { /* * Turn off the auto-printing when failure occurs so that we can * handle the errors appropriately @@ -51,8 +51,8 @@ int main (void) /* * Open the file and the dataset. */ - H5File file( FILE_NAME, H5F_ACC_RDONLY ); - DataSet dataset = file.openDataSet( DATASET_NAME ); + H5File file(FILE_NAME, H5F_ACC_RDONLY); + DataSet dataset = file.openDataSet(DATASET_NAME); /* * Get filespace for rank and dimension @@ -67,10 +67,9 @@ int main (void) /* * Get and print the dimension sizes of the file dataspace */ - hsize_t dims[2]; // dataset dimensions - rank = filespace.getSimpleExtentDims( dims ); - cout << "dataset rank = " << rank << ", dimensions " - << (unsigned long)(dims[0]) << " x " + hsize_t dims[2]; // dataset dimensions + rank = filespace.getSimpleExtentDims(dims); + cout << "dataset rank = " << rank << ", dimensions " << (unsigned long)(dims[0]) << " x " << (unsigned long)(dims[1]) << endl; /* @@ -81,13 +80,12 @@ int main (void) /* * Read dataset back and display. */ - int data_out[NX][NY]; // buffer for dataset to be read - dataset.read( data_out, PredType::NATIVE_INT, mspace1, filespace ); + int data_out[NX][NY]; // buffer for dataset to be read + dataset.read(data_out, PredType::NATIVE_INT, mspace1, filespace); cout << "\n"; cout << "Dataset: \n"; - for (j = 0; j < dims[0]; j++) - { + for (j = 0; j < dims[0]; j++) { for (i = 0; i < dims[1]; i++) cout << data_out[j][i] << " "; cout << endl; @@ -117,20 +115,20 @@ int main (void) */ hsize_t col_dims[1]; col_dims[0] = 10; - DataSpace mspace2( RANKC, col_dims ); + DataSpace mspace2(RANKC, col_dims); /* * Define the column (hyperslab) to read. */ - hsize_t offset[2] = { 0, 2 }; - hsize_t count[2] = { 10, 1 }; - int column[10]; // buffer for column to be read + hsize_t offset[2] = {0, 2}; + hsize_t count[2] = {10, 1}; + int column[10]; // buffer for column to be read /* * Define hyperslab and read. */ - filespace.selectHyperslab( H5S_SELECT_SET, count, offset ); - dataset.read( column, PredType::NATIVE_INT, mspace2, filespace ); + filespace.selectHyperslab(H5S_SELECT_SET, count, offset); + dataset.read(column, PredType::NATIVE_INT, mspace2, filespace); cout << endl; cout << "Third column: " << endl; @@ -161,20 +159,18 @@ int main (void) */ hsize_t chunk_dims[2]; int rank_chunk; - if( H5D_CHUNKED == cparms.getLayout() ) - { + if (H5D_CHUNKED == cparms.getLayout()) { /* * Get chunking information: rank and dimensions */ - rank_chunk = cparms.getChunk( 2, chunk_dims); - cout << "chunk rank " << rank_chunk << "dimensions " - << (unsigned long)(chunk_dims[0]) << " x " - << (unsigned long)(chunk_dims[1]) << endl; + rank_chunk = cparms.getChunk(2, chunk_dims); + cout << "chunk rank " << rank_chunk << "dimensions " << (unsigned long)(chunk_dims[0]) << " x " + << (unsigned long)(chunk_dims[1]) << endl; /* * Define the memory space to read a chunk. */ - DataSpace mspace3( rank_chunk, chunk_dims ); + DataSpace mspace3(rank_chunk, chunk_dims); /* * Define chunk in the file (hyperslab) to read. @@ -183,17 +179,16 @@ int main (void) offset[1] = 0; count[0] = chunk_dims[0]; count[1] = chunk_dims[1]; - filespace.selectHyperslab( H5S_SELECT_SET, count, offset ); + filespace.selectHyperslab(H5S_SELECT_SET, count, offset); /* * Read chunk back and display. */ - int chunk_out[2][5]; // buffer for chunk to be read - dataset.read( chunk_out, PredType::NATIVE_INT, mspace3, filespace ); + int chunk_out[2][5]; // buffer for chunk to be read + dataset.read(chunk_out, PredType::NATIVE_INT, mspace3, filespace); cout << endl; cout << "Chunk:" << endl; - for (j = 0; j < chunk_dims[0]; j++) - { + for (j = 0; j < chunk_dims[0]; j++) { for (i = 0; i < chunk_dims[1]; i++) cout << chunk_out[j][i] << " "; cout << endl; @@ -204,25 +199,22 @@ int main (void) * 2 0 0 0 0 */ } - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch( FileIException error ) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } diff --git a/c++/examples/compound.cpp b/c++/examples/compound.cpp index 4b116e0..45b001e 100644 --- a/c++/examples/compound.cpp +++ b/c++/examples/compound.cpp @@ -29,175 +29,170 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDScompound.h5" ); -const H5std_string DATASET_NAME( "ArrayOfStructures" ); -const H5std_string MEMBER1( "a_name" ); -const H5std_string MEMBER2( "b_name" ); -const H5std_string MEMBER3( "c_name" ); -const int LENGTH = 10; -const int RANK = 1; - -int main(void) +const H5std_string FILE_NAME("SDScompound.h5"); +const H5std_string DATASET_NAME("ArrayOfStructures"); +const H5std_string MEMBER1("a_name"); +const H5std_string MEMBER2("b_name"); +const H5std_string MEMBER3("c_name"); +const int LENGTH = 10; +const int RANK = 1; + +int +main(void) { - /* First structure and dataset*/ - typedef struct s1_t { + /* First structure and dataset*/ + typedef struct s1_t { int a; float b; double c; - } s1_t; + } s1_t; - /* Second structure (subset of s1_t) and dataset*/ - typedef struct s2_t { + /* Second structure (subset of s1_t) and dataset*/ + typedef struct s2_t { double c; int a; - } s2_t; - - // Try block to detect exceptions raised by any of the calls inside it - try - { - /* - * Initialize the data - */ - int i; - s1_t s1[LENGTH]; - for (i = 0; i< LENGTH; i++) - { - s1[i].a = i; - s1[i].b = i*i; - s1[i].c = 1./(i+1); - } - - /* - * Turn off the auto-printing when failure occurs so that we can - * handle the errors appropriately - */ - Exception::dontPrint(); - - /* - * Create the data space. - */ - hsize_t dim[] = {LENGTH}; /* Dataspace dimensions */ - DataSpace space( RANK, dim ); - - /* - * Create the file. - */ - H5File* file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); - - /* - * Create the memory datatype. - */ - CompType mtype1( sizeof(s1_t) ); - mtype1.insertMember( MEMBER1, HOFFSET(s1_t, a), PredType::NATIVE_INT); - mtype1.insertMember( MEMBER3, HOFFSET(s1_t, c), PredType::NATIVE_DOUBLE); - mtype1.insertMember( MEMBER2, HOFFSET(s1_t, b), PredType::NATIVE_FLOAT); - - /* - * Create the dataset. - */ - DataSet* dataset; - dataset = new DataSet(file->createDataSet(DATASET_NAME, mtype1, space)); - - /* - * Write data to the dataset; - */ - dataset->write( s1, mtype1 ); - - /* - * Release resources - */ - delete dataset; - delete file; - - /* - * Open the file and the dataset. - */ - file = new H5File( FILE_NAME, H5F_ACC_RDONLY ); - dataset = new DataSet (file->openDataSet( DATASET_NAME )); - - /* - * Create a datatype for s2 - */ - CompType mtype2( sizeof(s2_t) ); - - mtype2.insertMember( MEMBER3, HOFFSET(s2_t, c), PredType::NATIVE_DOUBLE); - mtype2.insertMember( MEMBER1, HOFFSET(s2_t, a), PredType::NATIVE_INT); - - /* - * Read two fields c and a from s1 dataset. Fields in the file - * are found by their names "c_name" and "a_name". - */ - s2_t s2[LENGTH]; - dataset->read( s2, mtype2 ); - - /* - * Display the fields - */ - cout << endl << "Field c : " << endl; - for( i = 0; i < LENGTH; i++) - cout << s2[i].c << " "; - cout << endl; - - cout << endl << "Field a : " << endl; - for( i = 0; i < LENGTH; i++) - cout << s2[i].a << " "; - cout << endl; - - /* - * Create a datatype for s3. - */ - CompType mtype3( sizeof(float) ); - - mtype3.insertMember( MEMBER2, 0, PredType::NATIVE_FLOAT); - - /* - * Read field b from s1 dataset. Field in the file is found by its name. - */ - float s3[LENGTH]; // Third "structure" - used to read float field of s1 - dataset->read( s3, mtype3 ); - - /* - * Display the field - */ - cout << endl << "Field b : " << endl; - for( i = 0; i < LENGTH; i++) - cout << s3[i] << " "; - cout << endl; - - /* - * Release resources - */ - delete dataset; - delete file; - } // end of try block - - // catch failure caused by the H5File operations - catch( FileIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataTypeIException error ) - { - error.printErrorStack(); - return -1; - } - - return 0; + } s2_t; + + // Try block to detect exceptions raised by any of the calls inside it + try { + /* + * Initialize the data + */ + int i; + s1_t s1[LENGTH]; + for (i = 0; i < LENGTH; i++) { + s1[i].a = i; + s1[i].b = i * i; + s1[i].c = 1. / (i + 1); + } + + /* + * Turn off the auto-printing when failure occurs so that we can + * handle the errors appropriately + */ + Exception::dontPrint(); + + /* + * Create the data space. + */ + hsize_t dim[] = {LENGTH}; /* Dataspace dimensions */ + DataSpace space(RANK, dim); + + /* + * Create the file. + */ + H5File *file = new H5File(FILE_NAME, H5F_ACC_TRUNC); + + /* + * Create the memory datatype. + */ + CompType mtype1(sizeof(s1_t)); + mtype1.insertMember(MEMBER1, HOFFSET(s1_t, a), PredType::NATIVE_INT); + mtype1.insertMember(MEMBER3, HOFFSET(s1_t, c), PredType::NATIVE_DOUBLE); + mtype1.insertMember(MEMBER2, HOFFSET(s1_t, b), PredType::NATIVE_FLOAT); + + /* + * Create the dataset. + */ + DataSet *dataset; + dataset = new DataSet(file->createDataSet(DATASET_NAME, mtype1, space)); + + /* + * Write data to the dataset; + */ + dataset->write(s1, mtype1); + + /* + * Release resources + */ + delete dataset; + delete file; + + /* + * Open the file and the dataset. + */ + file = new H5File(FILE_NAME, H5F_ACC_RDONLY); + dataset = new DataSet(file->openDataSet(DATASET_NAME)); + + /* + * Create a datatype for s2 + */ + CompType mtype2(sizeof(s2_t)); + + mtype2.insertMember(MEMBER3, HOFFSET(s2_t, c), PredType::NATIVE_DOUBLE); + mtype2.insertMember(MEMBER1, HOFFSET(s2_t, a), PredType::NATIVE_INT); + + /* + * Read two fields c and a from s1 dataset. Fields in the file + * are found by their names "c_name" and "a_name". + */ + s2_t s2[LENGTH]; + dataset->read(s2, mtype2); + + /* + * Display the fields + */ + cout << endl << "Field c : " << endl; + for (i = 0; i < LENGTH; i++) + cout << s2[i].c << " "; + cout << endl; + + cout << endl << "Field a : " << endl; + for (i = 0; i < LENGTH; i++) + cout << s2[i].a << " "; + cout << endl; + + /* + * Create a datatype for s3. + */ + CompType mtype3(sizeof(float)); + + mtype3.insertMember(MEMBER2, 0, PredType::NATIVE_FLOAT); + + /* + * Read field b from s1 dataset. Field in the file is found by its name. + */ + float s3[LENGTH]; // Third "structure" - used to read float field of s1 + dataset->read(s3, mtype3); + + /* + * Display the field + */ + cout << endl << "Field b : " << endl; + for (i = 0; i < LENGTH; i++) + cout << s3[i] << " "; + cout << endl; + + /* + * Release resources + */ + delete dataset; + delete file; + } // end of try block + + // catch failure caused by the H5File operations + catch (FileIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSet operations + catch (DataSetIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataTypeIException error) { + error.printErrorStack(); + return -1; + } + + return 0; } diff --git a/c++/examples/create.cpp b/c++/examples/create.cpp index 06b981b..968c897 100644 --- a/c++/examples/create.cpp +++ b/c++/examples/create.cpp @@ -25,105 +25,99 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDS.h5" ); -const H5std_string DATASET_NAME( "IntArray" ); -const int NX = 5; // dataset dimensions -const int NY = 6; -const int RANK = 2; - -int main (void) +const H5std_string FILE_NAME("SDS.h5"); +const H5std_string DATASET_NAME("IntArray"); +const int NX = 5; // dataset dimensions +const int NY = 6; +const int RANK = 2; + +int +main(void) { - /* - * Data initialization. - */ - int i, j; - int data[NX][NY]; // buffer for data to write - for (j = 0; j < NX; j++) - { - for (i = 0; i < NY; i++) - data[j][i] = i + j; - } - /* - * 0 1 2 3 4 5 - * 1 2 3 4 5 6 - * 2 3 4 5 6 7 - * 3 4 5 6 7 8 - * 4 5 6 7 8 9 - */ - - // Try block to detect exceptions raised by any of the calls inside it - try - { - /* - * Turn off the auto-printing when failure occurs so that we can - * handle the errors appropriately - */ - Exception::dontPrint(); - - /* - * Create a new file using H5F_ACC_TRUNC access, - * default file creation properties, and default file - * access properties. - */ - H5File file( FILE_NAME, H5F_ACC_TRUNC ); - - /* - * Define the size of the array and create the data space for fixed - * size dataset. - */ - hsize_t dimsf[2]; // dataset dimensions - dimsf[0] = NX; - dimsf[1] = NY; - DataSpace dataspace( RANK, dimsf ); - - /* - * Define datatype for the data in the file. - * We will store little endian INT numbers. - */ - IntType datatype( PredType::NATIVE_INT ); - datatype.setOrder( H5T_ORDER_LE ); - - /* - * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. - */ - DataSet dataset = file.createDataSet( DATASET_NAME, datatype, dataspace ); - - /* - * Write the data to the dataset using default memory space, file - * space, and transfer properties. - */ - dataset.write( data, PredType::NATIVE_INT ); - } // end of try block - - // catch failure caused by the H5File operations - catch( FileIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataTypeIException error ) - { - error.printErrorStack(); - return -1; - } - - return 0; // successfully terminated + /* + * Data initialization. + */ + int i, j; + int data[NX][NY]; // buffer for data to write + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + data[j][i] = i + j; + } + /* + * 0 1 2 3 4 5 + * 1 2 3 4 5 6 + * 2 3 4 5 6 7 + * 3 4 5 6 7 8 + * 4 5 6 7 8 9 + */ + + // Try block to detect exceptions raised by any of the calls inside it + try { + /* + * Turn off the auto-printing when failure occurs so that we can + * handle the errors appropriately + */ + Exception::dontPrint(); + + /* + * Create a new file using H5F_ACC_TRUNC access, + * default file creation properties, and default file + * access properties. + */ + H5File file(FILE_NAME, H5F_ACC_TRUNC); + + /* + * Define the size of the array and create the data space for fixed + * size dataset. + */ + hsize_t dimsf[2]; // dataset dimensions + dimsf[0] = NX; + dimsf[1] = NY; + DataSpace dataspace(RANK, dimsf); + + /* + * Define datatype for the data in the file. + * We will store little endian INT numbers. + */ + IntType datatype(PredType::NATIVE_INT); + datatype.setOrder(H5T_ORDER_LE); + + /* + * Create a new dataset within the file using defined dataspace and + * datatype and default dataset creation properties. + */ + DataSet dataset = file.createDataSet(DATASET_NAME, datatype, dataspace); + + /* + * Write the data to the dataset using default memory space, file + * space, and transfer properties. + */ + dataset.write(data, PredType::NATIVE_INT); + } // end of try block + + // catch failure caused by the H5File operations + catch (FileIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSet operations + catch (DataSetIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataTypeIException error) { + error.printErrorStack(); + return -1; + } + + return 0; // successfully terminated } - diff --git a/c++/examples/extend_ds.cpp b/c++/examples/extend_ds.cpp index 9e005c6..9145088 100644 --- a/c++/examples/extend_ds.cpp +++ b/c++/examples/extend_ds.cpp @@ -32,201 +32,195 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDSextendible.h5" ); -const H5std_string DATASET_NAME( "ExtendibleArray" ); -const int NX = 10; -const int NY = 5; -const int RANK = 2; - -int main (void) +const H5std_string FILE_NAME("SDSextendible.h5"); +const H5std_string DATASET_NAME("ExtendibleArray"); +const int NX = 10; +const int NY = 5; +const int RANK = 2; + +int +main(void) { - /* - * Try block to detect exceptions raised by any of the calls inside it - */ - try - { - /* - * Turn off the auto-printing when failure occurs so that we can - * handle the errors appropriately - */ - Exception::dontPrint(); - - /* - * Create the data space with unlimited dimensions. - */ - hsize_t dims[2] = { 3, 3}; // dataset dimensions at creation - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - DataSpace mspace1( RANK, dims, maxdims); - - /* - * Create a new file. If file exists its contents will be overwritten. - */ - H5File file( FILE_NAME, H5F_ACC_TRUNC ); - - /* - * Modify dataset creation properties, i.e. enable chunking. - */ - DSetCreatPropList cparms; - - hsize_t chunk_dims[2] ={2, 5}; - cparms.setChunk( RANK, chunk_dims ); - - /* - * Set fill value for the dataset - */ - int fill_val = 0; - cparms.setFillValue( PredType::NATIVE_INT, &fill_val); - - /* - * Create a new dataset within the file using cparms - * creation properties. - */ - DataSet dataset = file.createDataSet( DATASET_NAME, PredType::NATIVE_INT, mspace1, cparms); - - /* - * Extend the dataset. This call assures that dataset is at least 3 x 3. - */ - hsize_t size[2]; - size[0] = 3; - size[1] = 3; - dataset.extend( size ); - - /* - * Select a hyperslab. - */ - DataSpace fspace1 = dataset.getSpace (); - hsize_t offset[2]; - offset[0] = 0; - offset[1] = 0; - hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */ - fspace1.selectHyperslab( H5S_SELECT_SET, dims1, offset ); - - /* - * Write the data to the hyperslab. - */ - int data1[3][3] = { {1, 1, 1}, /* data to write */ - {1, 1, 1}, - {1, 1, 1} }; - dataset.write( data1, PredType::NATIVE_INT, mspace1, fspace1 ); - - /* - * Extend the dataset. Dataset becomes 10 x 3. - */ - hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */ - dims[0] = dims1[0] + dims2[0]; - size[0] = dims[0]; - size[1] = dims[1]; - dataset.extend( size ); - - /* - * Select a hyperslab. - */ - DataSpace fspace2 = dataset.getSpace (); - offset[0] = 3; - offset[1] = 0; - fspace2.selectHyperslab( H5S_SELECT_SET, dims2, offset ); - - /* - * Define memory space - */ - DataSpace mspace2( RANK, dims2 ); - - /* - * Write the data to the hyperslab. - */ - int data2[7] = { 2, 2, 2, 2, 2, 2, 2}; - dataset.write( data2, PredType::NATIVE_INT, mspace2, fspace2 ); - - /* - * Extend the dataset. Dataset becomes 10 x 5. - */ - hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */ - dims[1] = dims1[1] + dims3[1]; - size[0] = dims[0]; - size[1] = dims[1]; - dataset.extend( size ); - - /* - * Select a hyperslab - */ - DataSpace fspace3 = dataset.getSpace (); - offset[0] = 0; - offset[1] = 3; - fspace3.selectHyperslab( H5S_SELECT_SET, dims3, offset ); - - /* - * Define memory space. - */ - DataSpace mspace3( RANK, dims3 ); - - /* - * Write the data to the hyperslab. - */ - int data3[2][2] = { {3, 3}, {3, 3} }; - dataset.write( data3, PredType::NATIVE_INT, mspace3, fspace3 ); - - /* - * Read the data from this dataset and display it. - */ - int i, j; - int data_out[NX][NY]; - for (i = 0; i < NX; i++) - { - for (j = 0; j < NY; j++) - data_out[i][j] = 0; - } - dataset.read( data_out, PredType::NATIVE_INT ); - /* - * Resulting dataset - * - * 1 1 1 3 3 - * 1 1 1 3 3 - * 1 1 1 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - */ - /* - * Display the result. - */ - for (i=0; i < NX; i++) - { - for(j=0; j < NY; j++) - cout << data_out[i][j] << " "; - cout << endl; - } - } // end of try block - - // catch failure caused by the H5File operations - catch( FileIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataTypeIException error ) - { - error.printErrorStack(); - return -1; - } - return 0; + /* + * Try block to detect exceptions raised by any of the calls inside it + */ + try { + /* + * Turn off the auto-printing when failure occurs so that we can + * handle the errors appropriately + */ + Exception::dontPrint(); + + /* + * Create the data space with unlimited dimensions. + */ + hsize_t dims[2] = {3, 3}; // dataset dimensions at creation + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + DataSpace mspace1(RANK, dims, maxdims); + + /* + * Create a new file. If file exists its contents will be overwritten. + */ + H5File file(FILE_NAME, H5F_ACC_TRUNC); + + /* + * Modify dataset creation properties, i.e. enable chunking. + */ + DSetCreatPropList cparms; + + hsize_t chunk_dims[2] = {2, 5}; + cparms.setChunk(RANK, chunk_dims); + + /* + * Set fill value for the dataset + */ + int fill_val = 0; + cparms.setFillValue(PredType::NATIVE_INT, &fill_val); + + /* + * Create a new dataset within the file using cparms + * creation properties. + */ + DataSet dataset = file.createDataSet(DATASET_NAME, PredType::NATIVE_INT, mspace1, cparms); + + /* + * Extend the dataset. This call assures that dataset is at least 3 x 3. + */ + hsize_t size[2]; + size[0] = 3; + size[1] = 3; + dataset.extend(size); + + /* + * Select a hyperslab. + */ + DataSpace fspace1 = dataset.getSpace(); + hsize_t offset[2]; + offset[0] = 0; + offset[1] = 0; + hsize_t dims1[2] = {3, 3}; /* data1 dimensions */ + fspace1.selectHyperslab(H5S_SELECT_SET, dims1, offset); + + /* + * Write the data to the hyperslab. + */ + int data1[3][3] = {{1, 1, 1}, /* data to write */ + {1, 1, 1}, + {1, 1, 1}}; + dataset.write(data1, PredType::NATIVE_INT, mspace1, fspace1); + + /* + * Extend the dataset. Dataset becomes 10 x 3. + */ + hsize_t dims2[2] = {7, 1}; /* data2 dimensions */ + dims[0] = dims1[0] + dims2[0]; + size[0] = dims[0]; + size[1] = dims[1]; + dataset.extend(size); + + /* + * Select a hyperslab. + */ + DataSpace fspace2 = dataset.getSpace(); + offset[0] = 3; + offset[1] = 0; + fspace2.selectHyperslab(H5S_SELECT_SET, dims2, offset); + + /* + * Define memory space + */ + DataSpace mspace2(RANK, dims2); + + /* + * Write the data to the hyperslab. + */ + int data2[7] = {2, 2, 2, 2, 2, 2, 2}; + dataset.write(data2, PredType::NATIVE_INT, mspace2, fspace2); + + /* + * Extend the dataset. Dataset becomes 10 x 5. + */ + hsize_t dims3[2] = {2, 2}; /* data3 dimensions */ + dims[1] = dims1[1] + dims3[1]; + size[0] = dims[0]; + size[1] = dims[1]; + dataset.extend(size); + + /* + * Select a hyperslab + */ + DataSpace fspace3 = dataset.getSpace(); + offset[0] = 0; + offset[1] = 3; + fspace3.selectHyperslab(H5S_SELECT_SET, dims3, offset); + + /* + * Define memory space. + */ + DataSpace mspace3(RANK, dims3); + + /* + * Write the data to the hyperslab. + */ + int data3[2][2] = {{3, 3}, {3, 3}}; + dataset.write(data3, PredType::NATIVE_INT, mspace3, fspace3); + + /* + * Read the data from this dataset and display it. + */ + int i, j; + int data_out[NX][NY]; + for (i = 0; i < NX; i++) { + for (j = 0; j < NY; j++) + data_out[i][j] = 0; + } + dataset.read(data_out, PredType::NATIVE_INT); + /* + * Resulting dataset + * + * 1 1 1 3 3 + * 1 1 1 3 3 + * 1 1 1 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + */ + /* + * Display the result. + */ + for (i = 0; i < NX; i++) { + for (j = 0; j < NY; j++) + cout << data_out[i][j] << " "; + cout << endl; + } + } // end of try block + + // catch failure caused by the H5File operations + catch (FileIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSet operations + catch (DataSetIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataTypeIException error) { + error.printErrorStack(); + return -1; + } + return 0; } diff --git a/c++/examples/h5group.cpp b/c++/examples/h5group.cpp index 271c538..3d2c6d9 100644 --- a/c++/examples/h5group.cpp +++ b/c++/examples/h5group.cpp @@ -32,22 +32,21 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "Group.h5" ); +const H5std_string FILE_NAME("Group.h5"); const int RANK = 2; // Operator function -extern "C" herr_t file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, - void *opdata); +extern "C" herr_t file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata); -int main(void) +int +main(void) { - hsize_t dims[2]; - hsize_t cdims[2]; + hsize_t dims[2]; + hsize_t cdims[2]; // Try block to detect exceptions raised by any of the calls inside it - try - { + try { /* * Turn off the auto-printing when failure occurs so that we can * handle the errors appropriately @@ -58,12 +57,12 @@ int main(void) * Create the named file, truncating the existing one if any, * using default create and access property lists. */ - H5File *file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); + H5File *file = new H5File(FILE_NAME, H5F_ACC_TRUNC); /* * Create a group in the file */ - Group* group = new Group( file->createGroup( "/Data" )); + Group *group = new Group(file->createGroup("/Data")); /* * Create dataset "Compressed Data" in the group using absolute @@ -71,21 +70,20 @@ int main(void) * GZIP compression with the compression effort set to 6. * Note that compression can be used only when dataset is chunked. */ - dims[0] = 1000; - dims[1] = 20; - cdims[0] = 20; - cdims[1] = 20; - DataSpace *dataspace = new DataSpace(RANK, dims); // create new dspace - DSetCreatPropList ds_creatplist; // create dataset creation prop list - ds_creatplist.setChunk( 2, cdims ); // then modify it for compression - ds_creatplist.setDeflate( 6 ); + dims[0] = 1000; + dims[1] = 20; + cdims[0] = 20; + cdims[1] = 20; + DataSpace * dataspace = new DataSpace(RANK, dims); // create new dspace + DSetCreatPropList ds_creatplist; // create dataset creation prop list + ds_creatplist.setChunk(2, cdims); // then modify it for compression + ds_creatplist.setDeflate(6); /* * Create the first dataset. */ - DataSet* dataset = new DataSet(file->createDataSet( - "/Data/Compressed_Data", PredType::NATIVE_INT, - *dataspace, ds_creatplist )); + DataSet *dataset = new DataSet( + file->createDataSet("/Data/Compressed_Data", PredType::NATIVE_INT, *dataspace, ds_creatplist)); /* * Close the first dataset. @@ -96,11 +94,10 @@ int main(void) /* * Create the second dataset. */ - dims[0] = 500; - dims[1] = 20; + dims[0] = 500; + dims[1] = 20; dataspace = new DataSpace(RANK, dims); // create second dspace - dataset = new DataSet(file->createDataSet("/Data/Float_Data", - PredType::NATIVE_FLOAT, *dataspace)); + dataset = new DataSet(file->createDataSet("/Data/Float_Data", PredType::NATIVE_FLOAT, *dataspace)); delete dataset; delete dataspace; @@ -110,16 +107,16 @@ int main(void) /* * Now reopen the file and group in the file. */ - file = new H5File(FILE_NAME, H5F_ACC_RDWR); + file = new H5File(FILE_NAME, H5F_ACC_RDWR); group = new Group(file->openGroup("Data")); /* * Access "Compressed_Data" dataset in the group. */ - try { // to determine if the dataset exists in the group - dataset = new DataSet( group->openDataSet( "Compressed_Data" )); + try { // to determine if the dataset exists in the group + dataset = new DataSet(group->openDataSet("Compressed_Data")); } - catch( GroupIException not_found_error ) { + catch (GroupIException not_found_error) { cout << " Dataset is not found." << endl; } cout << "dataset \"/Data/Compressed_Data\" is open" << endl; @@ -132,17 +129,16 @@ int main(void) /* * Create hard link to the Data group. */ - file->link( H5L_TYPE_HARD, "Data", "Data_new" ); + file->link(H5L_TYPE_HARD, "Data", "Data_new"); /* * We can access "Compressed_Data" dataset using created * hard link "Data_new". */ - try { // to determine if the dataset exists in the file - dataset = new DataSet(file->openDataSet( "/Data_new/Compressed_Data" )); + try { // to determine if the dataset exists in the file + dataset = new DataSet(file->openDataSet("/Data_new/Compressed_Data")); } - catch( FileIException not_found_error ) - { + catch (FileIException not_found_error) { cout << " Dataset is not found." << endl; } cout << "dataset \"/Data_new/Compressed_Data\" is open" << endl; @@ -165,11 +161,10 @@ int main(void) * of the objects in the file root direvtory. */ cout << "Unlinking..." << endl; - try { // attempt to unlink the dataset - file->unlink( "Data" ); + try { // attempt to unlink the dataset + file->unlink("Data"); } - catch( FileIException unlink_error ) - { + catch (FileIException unlink_error) { cout << " unlink failed." << endl; } cout << "\"Data\" is unlinked" << endl; @@ -183,32 +178,28 @@ int main(void) */ delete group; delete file; - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch( FileIException error ) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } // catch failure caused by the Attribute operations - catch( AttributeIException error ) - { + catch (AttributeIException error) { error.printErrorStack(); return -1; } @@ -236,4 +227,3 @@ file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata H5Gclose(group); return 0; } - diff --git a/c++/examples/h5tutr_cmprss.cpp b/c++/examples/h5tutr_cmprss.cpp index e3cf978..23a7aba 100644 --- a/c++/examples/h5tutr_cmprss.cpp +++ b/c++/examples/h5tutr_cmprss.cpp @@ -24,20 +24,20 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_cmprss.h5"); -const H5std_string DATASET_NAME("Compressed_Data"); -const int DIM0 = 100; -const int DIM1 = 20; +const H5std_string FILE_NAME("h5tutr_cmprss.h5"); +const H5std_string DATASET_NAME("Compressed_Data"); +const int DIM0 = 100; +const int DIM1 = 20; -int main (void) +int +main(void) { - hsize_t dims[2] = { DIM0, DIM1 }; // dataset dimensions - hsize_t chunk_dims[2] = { 20, 20 }; // chunk dimensions - int i,j, buf[DIM0][DIM1]; + hsize_t dims[2] = {DIM0, DIM1}; // dataset dimensions + hsize_t chunk_dims[2] = {20, 20}; // chunk dimensions + int i, j, buf[DIM0][DIM1]; // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -49,7 +49,7 @@ int main (void) DataSpace *dataspace = new DataSpace(2, dims); // Modify dataset creation property to enable chunking - DSetCreatPropList *plist = new DSetCreatPropList; + DSetCreatPropList *plist = new DSetCreatPropList; plist->setChunk(2, chunk_dims); // Set ZLIB (DEFLATE) Compression using level 6. @@ -62,12 +62,12 @@ int main (void) // plist->setSzip(szip_options_mask, szip_pixels_per_block); // Create the dataset. - DataSet *dataset = new DataSet(file.createDataSet( DATASET_NAME, - PredType::STD_I32BE, *dataspace, *plist) ); + DataSet *dataset = + new DataSet(file.createDataSet(DATASET_NAME, PredType::STD_I32BE, *dataspace, *plist)); - for (i = 0; i< DIM0; i++) - for (j=0; jwrite(buf, PredType::NATIVE_INT); @@ -83,41 +83,41 @@ int main (void) // information for dataset and read the data back. // ----------------------------------------------- - int rbuf[DIM0][DIM1]; - int numfilt; - size_t nelmts={1}, namelen={1}; - unsigned flags, filter_info, cd_values[1], idx; - char name[1]; + int rbuf[DIM0][DIM1]; + int numfilt; + size_t nelmts = {1}, namelen = {1}; + unsigned flags, filter_info, cd_values[1], idx; + char name[1]; H5Z_filter_t filter_type; // Open the file and the dataset in the file. file.openFile(FILE_NAME, H5F_ACC_RDONLY); - dataset = new DataSet(file.openDataSet( DATASET_NAME)); + dataset = new DataSet(file.openDataSet(DATASET_NAME)); // Get the create property list of the dataset. - plist = new DSetCreatPropList(dataset->getCreatePlist ()); + plist = new DSetCreatPropList(dataset->getCreatePlist()); // Get the number of filters associated with the dataset. numfilt = plist->getNfilters(); cout << "Number of filters associated with dataset: " << numfilt << endl; - for (idx=0; idx < numfilt; idx++) { + for (idx = 0; idx < numfilt; idx++) { nelmts = 0; - filter_type = plist->getFilter(idx, flags, nelmts, cd_values, namelen, name , filter_info); + filter_type = plist->getFilter(idx, flags, nelmts, cd_values, namelen, name, filter_info); cout << "Filter Type: "; switch (filter_type) { - case H5Z_FILTER_DEFLATE: - cout << "H5Z_FILTER_DEFLATE" << endl; - break; - case H5Z_FILTER_SZIP: - cout << "H5Z_FILTER_SZIP" << endl; - break; - default: - cout << "Other filter type included." << endl; - } + case H5Z_FILTER_DEFLATE: + cout << "H5Z_FILTER_DEFLATE" << endl; + break; + case H5Z_FILTER_SZIP: + cout << "H5Z_FILTER_SZIP" << endl; + break; + default: + cout << "Other filter type included." << endl; + } } // Read data. @@ -125,31 +125,27 @@ int main (void) delete plist; delete dataset; - file.close(); // can be skipped + file.close(); // can be skipped - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_crtatt.cpp b/c++/examples/h5tutr_crtatt.cpp index 409bd62..fdedadf 100644 --- a/c++/examples/h5tutr_crtatt.cpp +++ b/c++/examples/h5tutr_crtatt.cpp @@ -21,69 +21,62 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "h5tutr_dset.h5" ); -const H5std_string DATASET_NAME( "dset" ); -const H5std_string ATTR_NAME( "Units" ); +const H5std_string FILE_NAME("h5tutr_dset.h5"); +const H5std_string DATASET_NAME("dset"); +const H5std_string ATTR_NAME("Units"); -const int DIM1 = 2; +const int DIM1 = 2; -int main (void) +int +main(void) { - int attr_data[2] = { 100, 200}; - hsize_t dims[1] = { DIM1 }; + int attr_data[2] = {100, 200}; + hsize_t dims[1] = {DIM1}; - - // Try block to detect exceptions raised by any of the calls inside it - try - { + // Try block to detect exceptions raised by any of the calls inside it + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); // Open an existing file and dataset. - H5File file( FILE_NAME, H5F_ACC_RDWR ); - DataSet dataset = file.openDataSet( DATASET_NAME ); + H5File file(FILE_NAME, H5F_ACC_RDWR); + DataSet dataset = file.openDataSet(DATASET_NAME); // Create the data space for the attribute. - DataSpace attr_dataspace = DataSpace (1, dims ); + DataSpace attr_dataspace = DataSpace(1, dims); // Create a dataset attribute. - Attribute attribute = dataset.createAttribute( ATTR_NAME, PredType::STD_I32BE, - attr_dataspace); + Attribute attribute = dataset.createAttribute(ATTR_NAME, PredType::STD_I32BE, attr_dataspace); // Write the attribute data. - attribute.write( PredType::NATIVE_INT, attr_data); + attribute.write(PredType::NATIVE_INT, attr_data); - } // end of try block + } // end of try block - // catch failure caused by the H5File operations - catch( DataSpaceIException error ) - { + // catch failure caused by the H5File operations + catch (DataSpaceIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the H5File operations - catch( AttributeIException error ) - { + // catch failure caused by the H5File operations + catch (AttributeIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the H5File operations - catch( FileIException error ) - { + // catch failure caused by the H5File operations + catch (FileIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { + // catch failure caused by the DataSet operations + catch (DataSetIException error) { error.printErrorStack(); return -1; - } + } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_crtdat.cpp b/c++/examples/h5tutr_crtdat.cpp index 3257223..aef78d9 100644 --- a/c++/examples/h5tutr_crtdat.cpp +++ b/c++/examples/h5tutr_crtdat.cpp @@ -22,17 +22,17 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_dset.h5"); -const H5std_string DATASET_NAME("dset"); -const int NX = 4; // dataset dimensions -const int NY = 6; -const int RANK = 2; +const H5std_string FILE_NAME("h5tutr_dset.h5"); +const H5std_string DATASET_NAME("dset"); +const int NX = 4; // dataset dimensions +const int NY = 6; +const int RANK = 2; -int main (void) +int +main(void) { // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -41,7 +41,7 @@ int main (void) H5File file(FILE_NAME, H5F_ACC_TRUNC); // Create the data space for the dataset. - hsize_t dims[2]; // dataset dimensions + hsize_t dims[2]; // dataset dimensions dims[0] = NX; dims[1] = NY; DataSpace dataspace(RANK, dims); @@ -49,29 +49,25 @@ int main (void) // Create the dataset. DataSet dataset = file.createDataSet(DATASET_NAME, PredType::STD_I32BE, dataspace); - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_crtgrp.cpp b/c++/examples/h5tutr_crtgrp.cpp index 43af08a..8e48eec 100644 --- a/c++/examples/h5tutr_crtgrp.cpp +++ b/c++/examples/h5tutr_crtgrp.cpp @@ -26,11 +26,11 @@ using namespace H5; const H5std_string FILE_NAME("h5tutr_group.h5"); -int main(void) +int +main(void) { // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -46,14 +46,12 @@ int main(void) } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the Group operations - catch(GroupIException error) - { + catch (GroupIException error) { error.printErrorStack(); return -1; } diff --git a/c++/examples/h5tutr_crtgrpar.cpp b/c++/examples/h5tutr_crtgrpar.cpp index 15cf1df..3414cee 100644 --- a/c++/examples/h5tutr_crtgrpar.cpp +++ b/c++/examples/h5tutr_crtgrpar.cpp @@ -26,12 +26,12 @@ using namespace H5; const H5std_string FILE_NAME("h5tutr_groups.h5"); -int main(void) +int +main(void) { // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately. @@ -44,7 +44,7 @@ int main(void) // Create group "MyGroup" in the root group using an absolute name. - Group group1(file.createGroup( "/MyGroup")); + Group group1(file.createGroup("/MyGroup")); // Create group "Group_A" in group "MyGroup" using an // absolute name. @@ -54,7 +54,7 @@ int main(void) // Create group "Group_B" in group "MyGroup" using a // relative name. - Group group3(group1.createGroup ("Group_B")); + Group group3(group1.createGroup("Group_B")); // Close the groups and file. @@ -66,20 +66,16 @@ int main(void) } // end of try block // catch failure caused by the File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the Group operations - catch(GroupIException error) - { + catch (GroupIException error) { error.printErrorStack(); return -1; } return 0; } - - diff --git a/c++/examples/h5tutr_crtgrpd.cpp b/c++/examples/h5tutr_crtgrpd.cpp index c28b666..8ada706 100644 --- a/c++/examples/h5tutr_crtgrpd.cpp +++ b/c++/examples/h5tutr_crtgrpd.cpp @@ -27,20 +27,20 @@ using namespace H5; const H5std_string FILE_NAME("h5tutr_groups.h5"); const H5std_string DATASET_NAME1("/MyGroup/dset1"); const H5std_string DATASET_NAME2("dset2"); -const int RANK = 2; -const int D1DIM1 = 3; -const int D1DIM2 = 3; -const int D2DIM1 = 2; -const int D2DIM2 = 10; - -int main(void) +const int RANK = 2; +const int D1DIM1 = 3; +const int D1DIM2 = 3; +const int D2DIM1 = 2; +const int D2DIM2 = 10; + +int +main(void) { int dset1_data[D1DIM1][D1DIM2], dset2_data[D2DIM1][D2DIM2]; // data buffers int i, j; // Try block to catch exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -48,12 +48,12 @@ int main(void) // Initialize the first dataset. for (i = 0; i < D1DIM1; i++) for (j = 0; j < D1DIM2; j++) - dset1_data[i][j] = j + 1; + dset1_data[i][j] = j + 1; // Initialize the second dataset. for (i = 0; i < D2DIM1; i++) - for (j = 0; j < D2DIM2; j++) - dset2_data[i][j] = j + 1; + for (j = 0; j < D2DIM2; j++) + dset2_data[i][j] = j + 1; // Open an existing file and dataset. H5File file(FILE_NAME, H5F_ACC_RDWR); @@ -62,15 +62,14 @@ int main(void) // pointer for the instance 'dataspace'. It can be deleted and // used again later for another data space. An HDF5 identifier is // closed by the destructor or the method 'close()'. - hsize_t dims[RANK]; // dataset dimensions - dims[0] = D1DIM1; - dims[1] = D1DIM2; - DataSpace *dataspace = new DataSpace (RANK, dims); + hsize_t dims[RANK]; // dataset dimensions + dims[0] = D1DIM1; + dims[1] = D1DIM2; + DataSpace *dataspace = new DataSpace(RANK, dims); // Create the dataset in group "MyGroup". Same note as for the // dataspace above. - DataSet *dataset = new DataSet (file.createDataSet(DATASET_NAME1, - PredType::STD_I32BE, *dataspace)); + DataSet *dataset = new DataSet(file.createDataSet(DATASET_NAME1, PredType::STD_I32BE, *dataspace)); // Write the data to the dataset using default memory space, file // space, and transfer properties. @@ -81,16 +80,15 @@ int main(void) delete dataspace; // Create the data space for the second dataset. - dims[0] = D2DIM1; - dims[1] = D2DIM2; - dataspace = new DataSpace (RANK, dims); + dims[0] = D2DIM1; + dims[1] = D2DIM2; + dataspace = new DataSpace(RANK, dims); // Create group "Group_A" in group "MyGroup". Group group(file.openGroup("/MyGroup/Group_A")); // Create the second dataset in group "Group_A". - dataset = new DataSet (group.createDataSet(DATASET_NAME2, - PredType::STD_I32BE, *dataspace)); + dataset = new DataSet(group.createDataSet(DATASET_NAME2, PredType::STD_I32BE, *dataspace)); // Write the data to the dataset using default memory space, file // space, and transfer properties. @@ -104,31 +102,27 @@ int main(void) } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { - error.printErrorStack(); - return -1; + catch (FileIException error) { + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { - error.printErrorStack(); - return -1; + catch (DataSetIException error) { + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } // catch failure caused by the Group operations - catch(GroupIException error) - { + catch (GroupIException error) { error.printErrorStack(); return -1; } - return 0; + return 0; } diff --git a/c++/examples/h5tutr_extend.cpp b/c++/examples/h5tutr_extend.cpp index 94e9acf..71a8ffb 100644 --- a/c++/examples/h5tutr_extend.cpp +++ b/c++/examples/h5tutr_extend.cpp @@ -24,34 +24,28 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_extend.h5"); -const H5std_string DATASETNAME("ExtendibleArray"); +const H5std_string FILE_NAME("h5tutr_extend.h5"); +const H5std_string DATASETNAME("ExtendibleArray"); -int main (void) +int +main(void) { - hsize_t dims[2] = {3,3}; // dataset dimensions at creation - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims[2] ={2, 5}; - int data[3][3] = { {1, 1, 1}, // data to write - {1, 1, 1}, - {1, 1, 1} }; - - // Variables used in extending and writing to the extended portion of dataset - - hsize_t size[2]; - hsize_t offset[2]; - hsize_t dimsext[2] = {7, 3}; // extend dimensions - int dataext[7][3] = { {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4} }; + hsize_t dims[2] = {3, 3}; // dataset dimensions at creation + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims[2] = {2, 5}; + int data[3][3] = {{1, 1, 1}, // data to write + {1, 1, 1}, + {1, 1, 1}}; + + // Variables used in extending and writing to the extended portion of dataset + + hsize_t size[2]; + hsize_t offset[2]; + hsize_t dimsext[2] = {7, 3}; // extend dimensions + int dataext[7][3] = {{2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}}; // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -63,15 +57,15 @@ int main (void) // for the instance 'dataspace'. It can be deleted and used again // later for another dataspace. An HDF5 identifier can be closed // by the destructor or the method 'close()'. - DataSpace *dataspace = new DataSpace (2, dims, maxdims); + DataSpace *dataspace = new DataSpace(2, dims, maxdims); // Modify dataset creation property to enable chunking DSetCreatPropList prop; prop.setChunk(2, chunk_dims); // Create the chunked dataset. Note the use of pointer. - DataSet *dataset = new DataSet(file.createDataSet( DATASETNAME, - PredType::STD_I32BE, *dataspace, prop) ); + DataSet *dataset = + new DataSet(file.createDataSet(DATASETNAME, PredType::STD_I32BE, *dataspace, prop)); // Write data to dataset. dataset->write(data, PredType::NATIVE_INT); @@ -82,9 +76,9 @@ int main (void) dataset->extend(size); // Select a hyperslab in extended portion of the dataset. - DataSpace *filespace = new DataSpace(dataset->getSpace ()); - offset[0] = 3; - offset[1] = 0; + DataSpace *filespace = new DataSpace(dataset->getSpace()); + offset[0] = 3; + offset[1] = 0; filespace->selectHyperslab(H5S_SELECT_SET, dimsext, offset); // Define memory space. @@ -105,25 +99,26 @@ int main (void) // Re-open the file and read the data back // --------------------------------------- - int rdata[10][3]; - int i,j, rank, rank_chunk; - hsize_t chunk_dimsr[2], dimsr[2]; + int rdata[10][3]; + int i, j, rank, rank_chunk; + hsize_t chunk_dimsr[2], dimsr[2]; // Open the file and dataset. file.openFile(FILE_NAME, H5F_ACC_RDONLY); - dataset = new DataSet(file.openDataSet( DATASETNAME)); + dataset = new DataSet(file.openDataSet(DATASETNAME)); // Get the dataset's dataspace and creation property list. filespace = new DataSpace(dataset->getSpace()); - prop = dataset->getCreatePlist(); + prop = dataset->getCreatePlist(); // Get information to obtain memory dataspace. - rank = filespace->getSimpleExtentNdims(); + rank = filespace->getSimpleExtentNdims(); herr_t status_n = filespace->getSimpleExtentDims(dimsr); if (H5D_CHUNKED == prop.getLayout()) - rank_chunk = prop.getChunk(rank, chunk_dimsr); - cout << "rank chunk = " << rank_chunk << endl;; + rank_chunk = prop.getChunk(rank, chunk_dimsr); + cout << "rank chunk = " << rank_chunk << endl; + ; memspace = new DataSpace(rank, dimsr, NULL); dataset->read(rdata, PredType::NATIVE_INT, *memspace, *filespace); @@ -131,7 +126,7 @@ int main (void) cout << endl; for (j = 0; j < dimsr[0]; j++) { for (i = 0; i < dimsr[1]; i++) - cout << " " << rdata[j][i]; + cout << " " << rdata[j][i]; cout << endl; } @@ -142,29 +137,25 @@ int main (void) delete dataset; file.close(); - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_rdwt.cpp b/c++/examples/h5tutr_rdwt.cpp index e9b76ad..4d265cd 100644 --- a/c++/examples/h5tutr_rdwt.cpp +++ b/c++/examples/h5tutr_rdwt.cpp @@ -21,53 +21,51 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_dset.h5"); -const H5std_string DATASET_NAME("dset"); -const int DIM0 = 4; // dataset dimensions -const int DIM1 = 6; +const H5std_string FILE_NAME("h5tutr_dset.h5"); +const H5std_string DATASET_NAME("dset"); +const int DIM0 = 4; // dataset dimensions +const int DIM1 = 6; -int main (void) +int +main(void) { // Data initialization. int i, j; - int data[DIM0][DIM1]; // buffer for data to write + int data[DIM0][DIM1]; // buffer for data to write for (j = 0; j < DIM0; j++) for (i = 0; i < DIM1; i++) - data[j][i] = i * 6 + j + 1; + data[j][i] = i * 6 + j + 1; // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); // Open an existing file and dataset. - H5File file(FILE_NAME, H5F_ACC_RDWR); + H5File file(FILE_NAME, H5F_ACC_RDWR); DataSet dataset = file.openDataSet(DATASET_NAME); // Write the data to the dataset using default memory space, file // space, and transfer properties. dataset.write(data, PredType::NATIVE_INT); - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } diff --git a/c++/examples/h5tutr_subset.cpp b/c++/examples/h5tutr_subset.cpp index f7d0513..d4b77c3 100644 --- a/c++/examples/h5tutr_subset.cpp +++ b/c++/examples/h5tutr_subset.cpp @@ -24,23 +24,23 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_subset.h5"); -const H5std_string DATASET_NAME("IntArray"); +const H5std_string FILE_NAME("h5tutr_subset.h5"); +const H5std_string DATASET_NAME("IntArray"); -const int RANK = 2; -const int DIM0_SUB = 3; // subset dimensions -const int DIM1_SUB = 4; -const int DIM0 = 8; // size of dataset -const int DIM1 = 10; +const int RANK = 2; +const int DIM0_SUB = 3; // subset dimensions +const int DIM1_SUB = 4; +const int DIM0 = 8; // size of dataset +const int DIM1 = 10; -int main (void) +int +main(void) { - int i,j; - int data[DIM0][DIM1], sdata[DIM0_SUB][DIM1_SUB], rdata[DIM0][DIM1]; + int i, j; + int data[DIM0][DIM1], sdata[DIM0_SUB][DIM1_SUB], rdata[DIM0][DIM1]; // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -54,28 +54,26 @@ int main (void) H5File file(FILE_NAME, H5F_ACC_TRUNC); hsize_t dims[2]; - dims[0] = DIM0; - dims[1] = DIM1; - DataSpace dataspace = DataSpace (RANK, dims); - - DataSet dataset(file.createDataSet( DATASET_NAME, - PredType::STD_I32BE, dataspace) ); + dims[0] = DIM0; + dims[1] = DIM1; + DataSpace dataspace = DataSpace(RANK, dims); + DataSet dataset(file.createDataSet(DATASET_NAME, PredType::STD_I32BE, dataspace)); for (j = 0; j < DIM0; j++) { - for (i = 0; i < DIM1; i++) - if (i< (DIM1/2)) + for (i = 0; i < DIM1; i++) + if (i < (DIM1 / 2)) data[j][i] = 1; - else + else data[j][i] = 2; - } + } dataset.write(data, PredType::NATIVE_INT); cout << endl << "Data Written to File:" << endl; for (j = 0; j < DIM0; j++) { for (i = 0; i < DIM1; i++) - cout << " " << data[j][i]; + cout << " " << data[j][i]; cout << endl; } @@ -99,8 +97,8 @@ int main (void) offset[0] = 1; offset[1] = 2; - count[0] = DIM0_SUB; - count[1] = DIM1_SUB; + count[0] = DIM0_SUB; + count[1] = DIM1_SUB; stride[0] = 1; stride[1] = 1; @@ -126,17 +124,16 @@ int main (void) cout << " offset=1x2 stride=1x1 count=3x4 block=1x1" << endl; for (j = 0; j < DIM0_SUB; j++) { for (i = 0; i < DIM1_SUB; i++) - sdata[j][i] = 5; + sdata[j][i] = 5; } dataset.write(sdata, PredType::NATIVE_INT, memspace, dataspace); dataset.read(rdata, PredType::NATIVE_INT); - cout << endl << "Data in File after Subset is Written:" << endl; for (i = 0; i < DIM0; i++) { for (j = 0; j < DIM1; j++) - cout << " " << rdata[i][j]; + cout << " " << rdata[i][j]; cout << endl; } cout << endl; @@ -148,29 +145,25 @@ int main (void) dataset.close(); file.close(); - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/readdata.cpp b/c++/examples/readdata.cpp index 3df8191..e088cce 100644 --- a/c++/examples/readdata.cpp +++ b/c++/examples/readdata.cpp @@ -29,184 +29,174 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDS.h5" ); -const H5std_string DATASET_NAME( "IntArray" ); -const int NX_SUB = 3; // hyperslab dimensions -const int NY_SUB = 4; -const int NX = 7; // output buffer dimensions -const int NY = 7; -const int NZ = 3; -const int RANK_OUT = 3; - -int main (void) +const H5std_string FILE_NAME("SDS.h5"); +const H5std_string DATASET_NAME("IntArray"); +const int NX_SUB = 3; // hyperslab dimensions +const int NY_SUB = 4; +const int NX = 7; // output buffer dimensions +const int NY = 7; +const int NZ = 3; +const int RANK_OUT = 3; + +int +main(void) { - /* - * Output buffer initialization. - */ - int i, j, k; - int data_out[NX][NY][NZ ]; /* output buffer */ - for (j = 0; j < NX; j++) - { - for (i = 0; i < NY; i++) - { - for (k = 0; k < NZ ; k++) - data_out[j][i][k] = 0; - } - } - - /* - * Try block to detect exceptions raised by any of the calls inside it - */ - try - { - /* - * Turn off the auto-printing when failure occurs so that we can - * handle the errors appropriately - */ - Exception::dontPrint(); - - /* - * Open the specified file and the specified dataset in the file. - */ - H5File file( FILE_NAME, H5F_ACC_RDONLY ); - DataSet dataset = file.openDataSet( DATASET_NAME ); - - /* - * Get the class of the datatype that is used by the dataset. - */ - H5T_class_t type_class = dataset.getTypeClass(); - - /* - * Get class of datatype and print message if it's an integer. - */ - if( type_class == H5T_INTEGER ) - { - cout << "Data set has INTEGER type" << endl; - - /* - * Get the integer datatype - */ - IntType intype = dataset.getIntType(); - - /* - * Get order of datatype and print message if it's a little endian. - */ - H5std_string order_string; - H5T_order_t order = intype.getOrder( order_string ); - cout << order_string << endl; - - /* - * Get size of the data element stored in file and print it. - */ - size_t size = intype.getSize(); - cout << "Data size is " << size << endl; - } - - /* - * Get dataspace of the dataset. - */ - DataSpace dataspace = dataset.getSpace(); - - /* - * Get the number of dimensions in the dataspace. - */ - int rank = dataspace.getSimpleExtentNdims(); - - /* - * Get the dimension size of each dimension in the dataspace and - * display them. - */ - hsize_t dims_out[2]; - int ndims = dataspace.getSimpleExtentDims( dims_out, NULL); - cout << "rank " << rank << ", dimensions " << - (unsigned long)(dims_out[0]) << " x " << - (unsigned long)(dims_out[1]) << endl; - - /* - * Define hyperslab in the dataset; implicitly giving strike and - * block NULL. - */ - hsize_t offset[2]; // hyperslab offset in the file - hsize_t count[2]; // size of the hyperslab in the file - offset[0] = 1; - offset[1] = 2; - count[0] = NX_SUB; - count[1] = NY_SUB; - dataspace.selectHyperslab( H5S_SELECT_SET, count, offset ); - - /* - * Define the memory dataspace. - */ - hsize_t dimsm[3]; /* memory space dimensions */ - dimsm[0] = NX; - dimsm[1] = NY; - dimsm[2] = NZ ; - DataSpace memspace( RANK_OUT, dimsm ); - - /* - * Define memory hyperslab. - */ - hsize_t offset_out[3]; // hyperslab offset in memory - hsize_t count_out[3]; // size of the hyperslab in memory - offset_out[0] = 3; - offset_out[1] = 0; - offset_out[2] = 0; - count_out[0] = NX_SUB; - count_out[1] = NY_SUB; - count_out[2] = 1; - memspace.selectHyperslab( H5S_SELECT_SET, count_out, offset_out ); - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display the data. - */ - dataset.read( data_out, PredType::NATIVE_INT, memspace, dataspace ); - - for (j = 0; j < NX; j++) - { - for (i = 0; i < NY; i++) - cout << data_out[j][i][0] << " "; - cout << endl; - } - /* - * 0 0 0 0 0 0 0 - * 0 0 0 0 0 0 0 - * 0 0 0 0 0 0 0 - * 3 4 5 6 0 0 0 - * 4 5 6 7 0 0 0 - * 5 6 7 8 0 0 0 - * 0 0 0 0 0 0 0 - */ - } // end of try block - - // catch failure caused by the H5File operations - catch( FileIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataTypeIException error ) - { - error.printErrorStack(); - return -1; - } - - return 0; // successfully terminated + /* + * Output buffer initialization. + */ + int i, j, k; + int data_out[NX][NY][NZ]; /* output buffer */ + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) { + for (k = 0; k < NZ; k++) + data_out[j][i][k] = 0; + } + } + + /* + * Try block to detect exceptions raised by any of the calls inside it + */ + try { + /* + * Turn off the auto-printing when failure occurs so that we can + * handle the errors appropriately + */ + Exception::dontPrint(); + + /* + * Open the specified file and the specified dataset in the file. + */ + H5File file(FILE_NAME, H5F_ACC_RDONLY); + DataSet dataset = file.openDataSet(DATASET_NAME); + + /* + * Get the class of the datatype that is used by the dataset. + */ + H5T_class_t type_class = dataset.getTypeClass(); + + /* + * Get class of datatype and print message if it's an integer. + */ + if (type_class == H5T_INTEGER) { + cout << "Data set has INTEGER type" << endl; + + /* + * Get the integer datatype + */ + IntType intype = dataset.getIntType(); + + /* + * Get order of datatype and print message if it's a little endian. + */ + H5std_string order_string; + H5T_order_t order = intype.getOrder(order_string); + cout << order_string << endl; + + /* + * Get size of the data element stored in file and print it. + */ + size_t size = intype.getSize(); + cout << "Data size is " << size << endl; + } + + /* + * Get dataspace of the dataset. + */ + DataSpace dataspace = dataset.getSpace(); + + /* + * Get the number of dimensions in the dataspace. + */ + int rank = dataspace.getSimpleExtentNdims(); + + /* + * Get the dimension size of each dimension in the dataspace and + * display them. + */ + hsize_t dims_out[2]; + int ndims = dataspace.getSimpleExtentDims(dims_out, NULL); + cout << "rank " << rank << ", dimensions " << (unsigned long)(dims_out[0]) << " x " + << (unsigned long)(dims_out[1]) << endl; + + /* + * Define hyperslab in the dataset; implicitly giving strike and + * block NULL. + */ + hsize_t offset[2]; // hyperslab offset in the file + hsize_t count[2]; // size of the hyperslab in the file + offset[0] = 1; + offset[1] = 2; + count[0] = NX_SUB; + count[1] = NY_SUB; + dataspace.selectHyperslab(H5S_SELECT_SET, count, offset); + + /* + * Define the memory dataspace. + */ + hsize_t dimsm[3]; /* memory space dimensions */ + dimsm[0] = NX; + dimsm[1] = NY; + dimsm[2] = NZ; + DataSpace memspace(RANK_OUT, dimsm); + + /* + * Define memory hyperslab. + */ + hsize_t offset_out[3]; // hyperslab offset in memory + hsize_t count_out[3]; // size of the hyperslab in memory + offset_out[0] = 3; + offset_out[1] = 0; + offset_out[2] = 0; + count_out[0] = NX_SUB; + count_out[1] = NY_SUB; + count_out[2] = 1; + memspace.selectHyperslab(H5S_SELECT_SET, count_out, offset_out); + + /* + * Read data from hyperslab in the file into the hyperslab in + * memory and display the data. + */ + dataset.read(data_out, PredType::NATIVE_INT, memspace, dataspace); + + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + cout << data_out[j][i][0] << " "; + cout << endl; + } + /* + * 0 0 0 0 0 0 0 + * 0 0 0 0 0 0 0 + * 0 0 0 0 0 0 0 + * 3 4 5 6 0 0 0 + * 4 5 6 7 0 0 0 + * 5 6 7 8 0 0 0 + * 0 0 0 0 0 0 0 + */ + } // end of try block + + // catch failure caused by the H5File operations + catch (FileIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSet operations + catch (DataSetIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataTypeIException error) { + error.printErrorStack(); + return -1; + } + + return 0; // successfully terminated } - diff --git a/c++/examples/writedata.cpp b/c++/examples/writedata.cpp index eada2ed..61cd43a 100644 --- a/c++/examples/writedata.cpp +++ b/c++/examples/writedata.cpp @@ -32,31 +32,31 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "Select.h5" ); -const H5std_string DATASET_NAME( "Matrix in file" ); -const int MSPACE1_RANK = 1; // Rank of the first dataset in memory -const int MSPACE1_DIM = 50; // Dataset size in memory -const int MSPACE2_RANK = 1; // Rank of the second dataset in memory -const int MSPACE2_DIM = 4; // Dataset size in memory -const int FSPACE_RANK = 2; // Dataset rank as it is stored in the file -const int FSPACE_DIM1 = 8; // Dimension sizes of the dataset as it is -const int FSPACE_DIM2 = 12; // stored in the file -const int MSPACE_RANK = 2; // Rank of the first dataset in memory -const int MSPACE_DIM1 = 8; // We will read dataset back from the file -const int MSPACE_DIM2 = 9; // to the dataset in memory with these - // dataspace parameters -const int NPOINTS = 4; // Number of points that will be selected - // and overwritten - -int main (void) +const H5std_string FILE_NAME("Select.h5"); +const H5std_string DATASET_NAME("Matrix in file"); +const int MSPACE1_RANK = 1; // Rank of the first dataset in memory +const int MSPACE1_DIM = 50; // Dataset size in memory +const int MSPACE2_RANK = 1; // Rank of the second dataset in memory +const int MSPACE2_DIM = 4; // Dataset size in memory +const int FSPACE_RANK = 2; // Dataset rank as it is stored in the file +const int FSPACE_DIM1 = 8; // Dimension sizes of the dataset as it is +const int FSPACE_DIM2 = 12; // stored in the file +const int MSPACE_RANK = 2; // Rank of the first dataset in memory +const int MSPACE_DIM1 = 8; // We will read dataset back from the file +const int MSPACE_DIM2 = 9; // to the dataset in memory with these + // dataspace parameters +const int NPOINTS = 4; // Number of points that will be selected + // and overwritten + +int +main(void) { - int i,j; // loop indices */ + int i, j; // loop indices */ /* * Try block to detect exceptions raised by any of the calls inside it */ - try - { + try { /* * Turn off the auto-printing when failure occurs so that we can * handle the errors appropriately @@ -66,47 +66,51 @@ int main (void) /* * Create a file. */ - H5File* file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); + H5File *file = new H5File(FILE_NAME, H5F_ACC_TRUNC); /* - * Create property list for a dataset and set up fill values. - */ - int fillvalue = 0; /* Fill value for the dataset */ + * Create property list for a dataset and set up fill values. + */ + int fillvalue = 0; /* Fill value for the dataset */ DSetCreatPropList plist; plist.setFillValue(PredType::NATIVE_INT, &fillvalue); /* * Create dataspace for the dataset in the file. */ - hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; // dim sizes of ds (on disk) - DataSpace fspace( FSPACE_RANK, fdim ); + hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; // dim sizes of ds (on disk) + DataSpace fspace(FSPACE_RANK, fdim); /* * Create dataset and write it into the file. */ - DataSet* dataset = new DataSet(file->createDataSet( - DATASET_NAME, PredType::NATIVE_INT, fspace, plist)); + DataSet *dataset = + new DataSet(file->createDataSet(DATASET_NAME, PredType::NATIVE_INT, fspace, plist)); /* * Select hyperslab for the dataset in the file, using 3x2 blocks, * (4,3) stride and (2,4) count starting at the position (0,1). */ - hsize_t start[2]; // Start of hyperslab + hsize_t start[2]; // Start of hyperslab hsize_t stride[2]; // Stride of hyperslab hsize_t count[2]; // Block count hsize_t block[2]; // Block sizes - start[0] = 0; start[1] = 1; - stride[0] = 4; stride[1] = 3; - count[0] = 2; count[1] = 4; - block[0] = 3; block[1] = 2; - fspace.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); + start[0] = 0; + start[1] = 1; + stride[0] = 4; + stride[1] = 3; + count[0] = 2; + count[1] = 4; + block[0] = 3; + block[1] = 2; + fspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); /* * Create dataspace for the first dataset. */ - hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset - (in memory) */ - DataSpace mspace1( MSPACE1_RANK, dim1 ); + hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset + (in memory) */ + DataSpace mspace1(MSPACE1_RANK, dim1); /* * Select hyperslab. @@ -117,7 +121,7 @@ int main (void) stride[0] = 1; count[0] = 48; block[0] = 1; - mspace1.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); + mspace1.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); /* * Write selection from the vector buffer to the dataset in the file. @@ -132,7 +136,7 @@ int main (void) * 0 41 42 0 43 44 0 45 46 0 47 48 * 0 0 0 0 0 0 0 0 0 0 0 0 */ - int vector[MSPACE1_DIM]; // vector buffer for dset + int vector[MSPACE1_DIM]; // vector buffer for dset /* * Buffer initialization. @@ -141,7 +145,7 @@ int main (void) for (i = 1; i < MSPACE1_DIM - 1; i++) vector[i] = i; - dataset->write( vector, PredType::NATIVE_INT, mspace1, fspace ); + dataset->write(vector, PredType::NATIVE_INT, mspace1, fspace); /* * Reset the selection for the file dataspace fid. @@ -151,27 +155,31 @@ int main (void) /* * Create dataspace for the second dataset. */ - hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset - (in memory */ - DataSpace mspace2( MSPACE2_RANK, dim2 ); + hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset + (in memory */ + DataSpace mspace2(MSPACE2_RANK, dim2); /* * Select sequence of NPOINTS points in the file dataspace. */ hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points from the file dataspace */ - coord[0][0] = 0; coord[0][1] = 0; - coord[1][0] = 3; coord[1][1] = 3; - coord[2][0] = 3; coord[2][1] = 5; - coord[3][0] = 5; coord[3][1] = 6; + coord[0][0] = 0; + coord[0][1] = 0; + coord[1][0] = 3; + coord[1][1] = 3; + coord[2][0] = 3; + coord[2][1] = 5; + coord[3][0] = 5; + coord[3][1] = 6; - fspace.selectElements( H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord); + fspace.selectElements(H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord); /* * Write new selection of points to the dataset. */ - int values[] = {53, 59, 61, 67}; /* New values to be written */ - dataset->write( values, PredType::NATIVE_INT, mspace2, fspace ); + int values[] = {53, 59, 61, 67}; /* New values to be written */ + dataset->write(values, PredType::NATIVE_INT, mspace2, fspace); /* * File dataset should look like this: @@ -195,12 +203,12 @@ int main (void) /* * Open the file. */ - file = new H5File( FILE_NAME, H5F_ACC_RDONLY ); + file = new H5File(FILE_NAME, H5F_ACC_RDONLY); /* * Open the dataset. */ - dataset = new DataSet( file->openDataSet( DATASET_NAME )); + dataset = new DataSet(file->openDataSet(DATASET_NAME)); /* * Get dataspace of the dataset. @@ -215,10 +223,14 @@ int main (void) * 0 59 0 61 * */ - start[0] = 1; start[1] = 2; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 3; count[1] = 4; + start[0] = 1; + start[1] = 2; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 3; + count[1] = 4; fspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); /* @@ -234,10 +246,14 @@ int main (void) * 19 20 * 0 61 */ - start[0] = 2; start[1] = 4; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 5; + start[0] = 2; + start[1] = 4; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 5; fspace.selectHyperslab(H5S_SELECT_OR, count, start, stride, block); /* @@ -253,15 +269,23 @@ int main (void) * Select two hyperslabs in memory. Hyperslabs has the same * size and shape as the selected hyperslabs for the file dataspace. */ - start[0] = 0; start[1] = 0; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 3; count[1] = 4; + start[0] = 0; + start[1] = 0; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 3; + count[1] = 4; mspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); - start[0] = 1; start[1] = 2; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 5; + start[0] = 1; + start[1] = 2; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 5; mspace.selectHyperslab(H5S_SELECT_OR, count, start, stride, block); /* @@ -289,9 +313,8 @@ int main (void) * 0 0 0 0 0 0 0 0 0 * 0 0 0 0 0 0 0 0 0 */ - for (i=0; i < MSPACE_DIM1; i++) - { - for(j=0; j < MSPACE_DIM2; j++) + for (i = 0; i < MSPACE_DIM1; i++) { + for (j = 0; j < MSPACE_DIM2; j++) cout << matrix_out[i][j] << " "; cout << endl; } @@ -301,28 +324,25 @@ int main (void) */ delete dataset; delete file; - } // end of try block + } // end of try block - // catch failure caused by the H5File operations - catch( FileIException error ) - { + // catch failure caused by the H5File operations + catch (FileIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { + // catch failure caused by the DataSet operations + catch (DataSetIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { error.printErrorStack(); return -1; - } + } - return 0; + return 0; } diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index d59a3cb..77d9248 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -38,7 +38,9 @@ namespace H5 { ///\brief Default constructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AbstractDs::AbstractDs(){} +AbstractDs::AbstractDs() +{ +} //-------------------------------------------------------------------------- // Function: AbstractDs default constructor @@ -61,19 +63,20 @@ AbstractDs::AbstractDs(){} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_class_t AbstractDs::getTypeClass() const +H5T_class_t +AbstractDs::getTypeClass() const { // Gets the datatype used by this dataset or attribute. // p_get_type calls either H5Dget_type or H5Aget_type depending on // which object invokes getTypeClass hid_t datatype_id; try { - datatype_id = p_get_type(); // returned value is already validated + datatype_id = p_get_type(); // returned value is already validated } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getTypeClass", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getTypeClass", E.getDetailMsg()); } @@ -82,8 +85,7 @@ H5T_class_t AbstractDs::getTypeClass() const // Close temporary datatype_id herr_t ret_value = H5Tclose(datatype_id); - if (ret_value < 0) - { + if (ret_value < 0) { if (fromClass() == "DataSet") throw DataTypeIException("DataSet::getTypeClass", "H5Tclose failed"); else if (fromClass() == "Attribute") @@ -91,14 +93,13 @@ H5T_class_t AbstractDs::getTypeClass() const } // Check on the returned type_class - if (type_class == H5T_NO_CLASS) - { + if (type_class == H5T_NO_CLASS) { if (fromClass() == "DataSet") throw DataTypeIException("DataSet::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); else if (fromClass() == "Attribute") throw DataTypeIException("Attribute::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); } - return(type_class); + return (type_class); } //-------------------------------------------------------------------------- @@ -109,7 +110,8 @@ H5T_class_t AbstractDs::getTypeClass() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType AbstractDs::getDataType() const +DataType +AbstractDs::getDataType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -118,12 +120,12 @@ DataType AbstractDs::getDataType() const try { DataType datatype; f_DataType_setId(&datatype, p_get_type()); - return(datatype); + return (datatype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getDataType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getDataType", E.getDetailMsg()); } } @@ -136,7 +138,8 @@ DataType AbstractDs::getDataType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType AbstractDs::getArrayType() const +ArrayType +AbstractDs::getArrayType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -147,12 +150,12 @@ ArrayType AbstractDs::getArrayType() const // problem described in the JIRA issue HDFFV-7947 ArrayType arraytype; f_DataType_setId(&arraytype, p_get_type()); - return(arraytype); + return (arraytype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getArrayType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getArrayType", E.getDetailMsg()); } } @@ -165,7 +168,8 @@ ArrayType AbstractDs::getArrayType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType AbstractDs::getCompType() const +CompType +AbstractDs::getCompType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -174,12 +178,12 @@ CompType AbstractDs::getCompType() const try { CompType comptype; f_DataType_setId(&comptype, p_get_type()); - return(comptype); + return (comptype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getCompType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getCompType", E.getDetailMsg()); } } @@ -192,7 +196,8 @@ CompType AbstractDs::getCompType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType AbstractDs::getEnumType() const +EnumType +AbstractDs::getEnumType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -201,12 +206,12 @@ EnumType AbstractDs::getEnumType() const try { EnumType enumtype; f_DataType_setId(&enumtype, p_get_type()); - return(enumtype); + return (enumtype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getEnumType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getEnumType", E.getDetailMsg()); } } @@ -219,7 +224,8 @@ EnumType AbstractDs::getEnumType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType AbstractDs::getIntType() const +IntType +AbstractDs::getIntType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -228,12 +234,12 @@ IntType AbstractDs::getIntType() const try { IntType inttype; f_DataType_setId(&inttype, p_get_type()); - return(inttype); + return (inttype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getIntType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getIntType", E.getDetailMsg()); } } @@ -246,7 +252,8 @@ IntType AbstractDs::getIntType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType AbstractDs::getFloatType() const +FloatType +AbstractDs::getFloatType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -255,12 +262,12 @@ FloatType AbstractDs::getFloatType() const try { FloatType floatype; f_DataType_setId(&floatype, p_get_type()); - return(floatype); + return (floatype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getFloatType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getFloatType", E.getDetailMsg()); } } @@ -273,7 +280,8 @@ FloatType AbstractDs::getFloatType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType AbstractDs::getStrType() const +StrType +AbstractDs::getStrType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -282,12 +290,12 @@ StrType AbstractDs::getStrType() const try { StrType strtype; f_DataType_setId(&strtype, p_get_type()); - return(strtype); + return (strtype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getStrType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getStrType", E.getDetailMsg()); } } @@ -300,7 +308,8 @@ StrType AbstractDs::getStrType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType AbstractDs::getVarLenType() const +VarLenType +AbstractDs::getVarLenType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -309,12 +318,12 @@ VarLenType AbstractDs::getVarLenType() const try { VarLenType varlentype; f_DataType_setId(&varlentype, p_get_type()); - return(varlentype); + return (varlentype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getVarLenType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getVarLenType", E.getDetailMsg()); } } @@ -324,6 +333,8 @@ VarLenType AbstractDs::getVarLenType() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AbstractDs::~AbstractDs() {} +AbstractDs::~AbstractDs() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 399e033..0c66845 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -34,49 +34,49 @@ class DataSpace; and DataSet. */ class H5_DLLCPP AbstractDs { - public: - // Gets a copy the datatype of that this abstract dataset uses. - // Note that this datatype is a generic one and can only be accessed - // via generic member functions, i.e., member functions belong - // to DataType. To get specific datatype, i.e. EnumType, FloatType, - // etc..., use the specific functions, that follow, instead. - DataType getDataType() const; - - // Gets a copy of the specific datatype of this abstract dataset. - ArrayType getArrayType() const; - CompType getCompType() const; - EnumType getEnumType() const; - IntType getIntType() const; - FloatType getFloatType() const; - StrType getStrType() const; - VarLenType getVarLenType() const; - - ///\brief Gets the size in memory of this abstract dataset. - virtual size_t getInMemDataSize() const = 0; - - ///\brief Gets the dataspace of this abstract dataset - pure virtual. - virtual DataSpace getSpace() const = 0; - - // Gets the class of the datatype that is used by this abstract - // dataset. - H5T_class_t getTypeClass() const; - - ///\brief Returns the amount of storage size required - pure virtual. - virtual hsize_t getStorageSize() const = 0; - - // Returns this class name - pure virtual. - virtual H5std_string fromClass() const = 0; - - // Destructor - virtual ~AbstractDs(); - - protected: - // Default constructor - AbstractDs(); - - private: - // This member function is implemented by DataSet and Attribute - pure virtual. - virtual hid_t p_get_type() const = 0; + public: + // Gets a copy the datatype of that this abstract dataset uses. + // Note that this datatype is a generic one and can only be accessed + // via generic member functions, i.e., member functions belong + // to DataType. To get specific datatype, i.e. EnumType, FloatType, + // etc..., use the specific functions, that follow, instead. + DataType getDataType() const; + + // Gets a copy of the specific datatype of this abstract dataset. + ArrayType getArrayType() const; + CompType getCompType() const; + EnumType getEnumType() const; + IntType getIntType() const; + FloatType getFloatType() const; + StrType getStrType() const; + VarLenType getVarLenType() const; + + ///\brief Gets the size in memory of this abstract dataset. + virtual size_t getInMemDataSize() const = 0; + + ///\brief Gets the dataspace of this abstract dataset - pure virtual. + virtual DataSpace getSpace() const = 0; + + // Gets the class of the datatype that is used by this abstract + // dataset. + H5T_class_t getTypeClass() const; + + ///\brief Returns the amount of storage size required - pure virtual. + virtual hsize_t getStorageSize() const = 0; + + // Returns this class name - pure virtual. + virtual H5std_string fromClass() const = 0; + + // Destructor + virtual ~AbstractDs(); + + protected: + // Default constructor + AbstractDs(); + + private: + // This member function is implemented by DataSet and Attribute - pure virtual. + virtual hid_t p_get_type() const = 0; }; // end of AbstractDs } // namespace H5 diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 0dab8ef..a567f8b 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -34,7 +34,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub ArrayType // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType() : DataType() {} +ArrayType::ArrayType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: ArrayType overloaded constructor @@ -43,14 +45,18 @@ ArrayType::ArrayType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const hid_t existing_id) : DataType(existing_id) {} +ArrayType::ArrayType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: ArrayType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const ArrayType& original) : DataType(original) {} +ArrayType::ArrayType(const ArrayType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: ArrayType overloaded constructor @@ -62,7 +68,7 @@ ArrayType::ArrayType(const ArrayType& original) : DataType(original) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) : DataType() +ArrayType::ArrayType(const DataType &base_type, int ndims, const hsize_t *dims) : DataType() { // Call C API to create an array data type hid_t new_type_id = H5Tarray_create2(base_type.getId(), ndims, dims); @@ -87,7 +93,7 @@ ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const H5Location& loc, const char *dtype_name) : DataType() +ArrayType::ArrayType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -106,7 +112,7 @@ ArrayType::ArrayType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +ArrayType::ArrayType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -122,21 +128,21 @@ ArrayType::ArrayType(const H5Location& loc, const H5std_string& dtype_name) : Da // each data member from the rhs object. (Issue HDFFV-9562) // Programmer Binh-Minh Ribler - Mar 2016 //-------------------------------------------------------------------------- -ArrayType& ArrayType::operator=(const ArrayType& rhs) +ArrayType & +ArrayType::operator=(const ArrayType &rhs) { - if (this != &rhs) - { + if (this != &rhs) { // handling references to this id try { setId(rhs.id); // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("operator="), close_error.getDetailMsg()); } } - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -147,7 +153,8 @@ ArrayType& ArrayType::operator=(const ArrayType& rhs) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* ArrayType::decode() const +DataType * +ArrayType::decode() const { hid_t encoded_arrtype_id = H5I_INVALID_HID; try { @@ -158,7 +165,7 @@ DataType* ArrayType::decode() const } ArrayType *encoded_arrtype = new ArrayType; encoded_arrtype->p_setId(encoded_arrtype_id); - return(encoded_arrtype); + return (encoded_arrtype); } //-------------------------------------------------------------------------- @@ -168,16 +175,16 @@ DataType* ArrayType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -int ArrayType::getArrayNDims() const +int +ArrayType::getArrayNDims() const { // Get the rank of the array type specified by id from the C API int ndims = H5Tget_array_ndims(id); - if (ndims < 0) - { + if (ndims < 0) { throw DataTypeIException("ArrayType::getArrayNDims", "H5Tget_array_ndims failed"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -188,7 +195,8 @@ int ArrayType::getArrayNDims() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -int ArrayType::getArrayDims(hsize_t* dims) const +int +ArrayType::getArrayDims(hsize_t *dims) const { // Get the dimensions int ndims = H5Tget_array_dims2(id, dims); @@ -196,7 +204,7 @@ int ArrayType::getArrayDims(hsize_t* dims) const throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); // Return the number of dimensions - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -204,6 +212,8 @@ int ArrayType::getArrayDims(hsize_t* dims) const ///\brief Properly terminates access to this array datatype. // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::~ArrayType() {} +ArrayType::~ArrayType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index d99b936..09f1592 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -23,44 +23,48 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP ArrayType : public DataType { - public: - // Constructor that creates a new array data type based on the - // specified base type. - ArrayType(const DataType& base_type, int ndims, const hsize_t* dims); + public: + // Constructor that creates a new array data type based on the + // specified base type. + ArrayType(const DataType &base_type, int ndims, const hsize_t *dims); - // Assignment operator - ArrayType& operator=(const ArrayType& rhs); + // Assignment operator + ArrayType &operator=(const ArrayType &rhs); - // Constructors that open an array datatype, given a location. - ArrayType(const H5Location& loc, const char* name); - ArrayType(const H5Location& loc, const H5std_string& name); + // Constructors that open an array datatype, given a location. + ArrayType(const H5Location &loc, const char *name); + ArrayType(const H5Location &loc, const H5std_string &name); - // Returns an ArrayType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an ArrayType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Returns the number of dimensions of this array datatype. - int getArrayNDims() const; - //int getArrayNDims(); // removed 1.8.18 and 1.10.1 + // Returns the number of dimensions of this array datatype. + int getArrayNDims() const; + // int getArrayNDims(); // removed 1.8.18 and 1.10.1 - // Returns the sizes of dimensions of this array datatype. - int getArrayDims(hsize_t* dims) const; - //int getArrayDims(hsize_t* dims); // removed 1.8.18 and 1.10.1 + // Returns the sizes of dimensions of this array datatype. + int getArrayDims(hsize_t *dims) const; + // int getArrayDims(hsize_t* dims); // removed 1.8.18 and 1.10.1 - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("ArrayType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("ArrayType"); + } - // Copy constructor: same as the original ArrayType. - ArrayType(const ArrayType& original); + // Copy constructor: same as the original ArrayType. + ArrayType(const ArrayType &original); - // Constructor that takes an existing id - ArrayType(const hid_t existing_id); + // Constructor that takes an existing id + ArrayType(const hid_t existing_id); - // Noop destructor - virtual ~ArrayType(); + // Noop destructor + virtual ~ArrayType(); - // Default constructor - ArrayType(); + // Default constructor + ArrayType(); }; // end of ArrayType } // namespace H5 diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 9408452..167b3d1 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -35,7 +35,9 @@ namespace H5 { // Purpose Default constructor: creates a stub atomic datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType() : DataType() {} +AtomType::AtomType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: AtomType overloaded constructor [protected] @@ -44,14 +46,18 @@ AtomType::AtomType() : DataType() {} // Exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType(const hid_t existing_id) : DataType(existing_id) {} +AtomType::AtomType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: AtomType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType(const AtomType& original) : DataType(original) {} +AtomType::AtomType(const AtomType &original) : DataType(original) +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- @@ -61,12 +67,12 @@ AtomType::AtomType(const AtomType& original) : DataType(original) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setSize(size_t size) const +void +AtomType::setSize(size_t size) const { // Call C routine H5Tset_size to set the total size herr_t ret_value = H5Tset_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setSize"), "H5Tset_size failed"); } } @@ -81,18 +87,17 @@ void AtomType::setSize(size_t size) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -H5T_order_t AtomType::getOrder() const +H5T_order_t +AtomType::getOrder() const { // Call C routine to get the byte ordering H5T_order_t type_order = H5Tget_order(id); // return a byte order constant if successful - if (type_order == H5T_ORDER_ERROR) - { - throw DataTypeIException(inMemFunc("getOrder"), - "H5Tget_order returns H5T_ORDER_ERROR"); + if (type_order == H5T_ORDER_ERROR) { + throw DataTypeIException(inMemFunc("getOrder"), "H5Tget_order returns H5T_ORDER_ERROR"); } - return(type_order); + return (type_order); } //-------------------------------------------------------------------------- @@ -112,7 +117,8 @@ H5T_order_t AtomType::getOrder() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_order_t AtomType::getOrder(H5std_string& order_string) const +H5T_order_t +AtomType::getOrder(H5std_string &order_string) const { // Call the overloaded to get the type order without text H5T_order_t type_order = getOrder(); @@ -124,7 +130,7 @@ H5T_order_t AtomType::getOrder(H5std_string& order_string) const order_string = "Big endian byte ordering (1)"; else if (type_order == H5T_ORDER_VAX) order_string = "VAX mixed byte ordering (2)"; - return(type_order); + return (type_order); } //-------------------------------------------------------------------------- @@ -137,12 +143,12 @@ H5T_order_t AtomType::getOrder(H5std_string& order_string) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setOrder(H5T_order_t order) const +void +AtomType::setOrder(H5T_order_t order) const { // Call C routine to set the byte ordering herr_t ret_value = H5Tset_order(id, order); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setOrder"), "H5Tset_order failed"); } } @@ -158,17 +164,17 @@ void AtomType::setOrder(H5T_order_t order) const /// value returned by \c DataType::getSize(). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t AtomType::getPrecision() const +size_t +AtomType::getPrecision() const { - size_t num_signi_bits = H5Tget_precision(id); // C routine + size_t num_signi_bits = H5Tget_precision(id); // C routine // returns number of significant bits if successful - if (num_signi_bits == 0) - { + if (num_signi_bits == 0) { throw DataTypeIException(inMemFunc("getPrecision"), - "H5Tget_precision returns invalid number of significant bits"); + "H5Tget_precision returns invalid number of significant bits"); } - return(num_signi_bits); + return (num_signi_bits); } //-------------------------------------------------------------------------- @@ -181,12 +187,12 @@ size_t AtomType::getPrecision() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setPrecision(size_t precision) const +void +AtomType::setPrecision(size_t precision) const { // Call C routine to set the datatype precision herr_t ret_value = H5Tset_precision(id, precision); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setPrecision"), "H5Tset_precision failed"); } } @@ -205,17 +211,16 @@ void AtomType::setPrecision(size_t precision) const // - return type changed from size_t to int // - offset = -1 when failure occurs vs. 0 //-------------------------------------------------------------------------- -int AtomType::getOffset() const +int +AtomType::getOffset() const { - int offset = H5Tget_offset(id); // C routine + int offset = H5Tget_offset(id); // C routine // returns a non-negative offset value if successful - if (offset == -1) - { - throw DataTypeIException(inMemFunc("getOffset"), - "H5Tget_offset returns a negative offset value"); + if (offset == -1) { + throw DataTypeIException(inMemFunc("getOffset"), "H5Tget_offset returns a negative offset value"); } - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -228,12 +233,12 @@ int AtomType::getOffset() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setOffset(size_t offset) const +void +AtomType::setOffset(size_t offset) const { // Call C routine to set the bit offset herr_t ret_value = H5Tset_offset(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setOffset"), "H5Tset_offset failed"); } } @@ -252,12 +257,12 @@ void AtomType::setOffset(size_t offset) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const +void +AtomType::getPad(H5T_pad_t &lsb, H5T_pad_t &msb) const { // Call C routine to get the padding type herr_t ret_value = H5Tget_pad(id, &lsb, &msb); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("getPad"), "H5Tget_pad failed"); } } @@ -275,12 +280,12 @@ void AtomType::getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const +void +AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const { // Call C routine to set the padding type herr_t ret_value = H5Tset_pad(id, lsb, msb); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setPad"), "H5Tset_pad failed"); } } @@ -291,7 +296,9 @@ void AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::~AtomType() {} +AtomType::~AtomType() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index 80271ac..337aca6 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -26,54 +26,58 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP AtomType : public DataType { - public: - // Returns the byte order of an atomic datatype. - H5T_order_t getOrder() const; - H5T_order_t getOrder(H5std_string& order_string) const; + public: + // Returns the byte order of an atomic datatype. + H5T_order_t getOrder() const; + H5T_order_t getOrder(H5std_string &order_string) const; - // Sets the byte ordering of an atomic datatype. - void setOrder(H5T_order_t order) const; + // Sets the byte ordering of an atomic datatype. + void setOrder(H5T_order_t order) const; - // Retrieves the bit offset of the first significant bit. - // 12/05/00 - changed return type to int from size_t - C API - int getOffset() const; + // Retrieves the bit offset of the first significant bit. + // 12/05/00 - changed return type to int from size_t - C API + int getOffset() const; - // Sets the bit offset of the first significant bit. - void setOffset(size_t offset) const; + // Sets the bit offset of the first significant bit. + void setOffset(size_t offset) const; - // Retrieves the padding type of the least and most-significant bit padding. - void getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const; + // Retrieves the padding type of the least and most-significant bit padding. + void getPad(H5T_pad_t &lsb, H5T_pad_t &msb) const; - // Sets the least and most-significant bits padding types - void setPad(H5T_pad_t lsb, H5T_pad_t msb) const; + // Sets the least and most-significant bits padding types + void setPad(H5T_pad_t lsb, H5T_pad_t msb) const; - // Returns the precision of an atomic datatype. - size_t getPrecision() const; + // Returns the precision of an atomic datatype. + size_t getPrecision() const; - // Sets the precision of an atomic datatype. - void setPrecision(size_t precision) const; + // Sets the precision of an atomic datatype. + void setPrecision(size_t precision) const; - // Sets the total size for an atomic datatype. - void setSize(size_t size) const; + // Sets the total size for an atomic datatype. + void setSize(size_t size) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("AtomType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("AtomType"); + } #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Copy constructor: same as the original AtomType. - AtomType(const AtomType& original); + // Copy constructor: same as the original AtomType. + AtomType(const AtomType &original); - // Noop destructor - virtual ~AtomType(); + // Noop destructor + virtual ~AtomType(); #endif // DOXYGEN_SHOULD_SKIP_THIS - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Default constructor - AtomType(); + // Default constructor + AtomType(); - // Constructor that takes an existing id - AtomType(const hid_t existing_id); + // Constructor that takes an existing id + AtomType(const hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of AtomType diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 33f992a..1137eb8 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -18,7 +18,7 @@ #endif #include -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -41,14 +41,16 @@ namespace H5 { using std::cerr; using std::endl; -class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate +class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate //-------------------------------------------------------------------------- // Function: Attribute default constructor ///\brief Default constructor: Creates a stub attribute // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) {} +Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: Attribute copy constructor @@ -56,7 +58,7 @@ Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) {} ///\param original - IN: Original Attribute object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute::Attribute(const Attribute& original) : AbstractDs(), H5Location(), id(original.id) +Attribute::Attribute(const Attribute &original) : AbstractDs(), H5Location(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -82,11 +84,11 @@ Attribute::Attribute(const hid_t existing_id) : AbstractDs(), H5Location(), id(e ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::write(const DataType& mem_type, const void *buf) const +void +Attribute::write(const DataType &mem_type, const void *buf) const { - herr_t ret_value = H5Awrite(id, mem_type.getId(), buf); - if (ret_value < 0) - { + herr_t ret_value = H5Awrite(id, mem_type.getId(), buf); + if (ret_value < 0) { throw AttributeIException("Attribute::write", "H5Awrite failed"); } } @@ -100,32 +102,29 @@ void Attribute::write(const DataType& mem_type, const void *buf) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Apr, 2003 //-------------------------------------------------------------------------- -void Attribute::write(const DataType& mem_type, const H5std_string& strg) const +void +Attribute::write(const DataType &mem_type, const H5std_string &strg) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw AttributeIException("Attribute::write", "H5Tis_variable_str failed"); } // Convert string to C-string - const char* strg_C; - strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str + const char *strg_C; + strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str herr_t ret_value = 0; // Pass string in differently depends on variable or fixed length - if (!is_variable_len) - { + if (!is_variable_len) { ret_value = H5Awrite(id, mem_type.getId(), strg_C); } - else - { + else { // passing third argument by address ret_value = H5Awrite(id, mem_type.getId(), &strg_C); } - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::write", "H5Awrite failed"); } } @@ -138,11 +137,11 @@ void Attribute::write(const DataType& mem_type, const H5std_string& strg) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::read(const DataType& mem_type, void *buf) const +void +Attribute::read(const DataType &mem_type, void *buf) const { - herr_t ret_value = H5Aread(id, mem_type.getId(), buf); - if (ret_value < 0) - { + herr_t ret_value = H5Aread(id, mem_type.getId(), buf); + if (ret_value < 0) { throw AttributeIException("Attribute::read", "H5Aread failed"); } } @@ -167,22 +166,21 @@ void Attribute::read(const DataType& mem_type, void *buf) const // variable-len string data: p_read_fixed_len and // p_read_variable_len. This should improve readability. -BMR //-------------------------------------------------------------------------- -void Attribute::read(const DataType& mem_type, H5std_string& strg) const +void +Attribute::read(const DataType &mem_type, H5std_string &strg) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw AttributeIException("Attribute::read", "H5Tis_variable_str failed"); } - if (!is_variable_len) // only allocate for fixed-len string + if (!is_variable_len) // only allocate for fixed-len string { p_read_fixed_len(mem_type, strg); } - else - { + else { p_read_variable_len(mem_type, strg); } } @@ -194,62 +192,55 @@ void Attribute::read(const DataType& mem_type, H5std_string& strg) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Apr 2009 //-------------------------------------------------------------------------- -size_t Attribute::getInMemDataSize() const +size_t +Attribute::getInMemDataSize() const { const char *func = "Attribute::getInMemDataSize"; // Get the data type of this attribute hid_t mem_type_id = H5Aget_type(id); - if (mem_type_id < 0) - { + if (mem_type_id < 0) { throw AttributeIException(func, "H5Aget_type failed"); } // Get the data type's size by first getting its native type then getting // the native type's size. hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); - if (native_type < 0) - { + if (native_type < 0) { throw AttributeIException(func, "H5Tget_native_type failed"); } size_t type_size = H5Tget_size(native_type); - if (type_size == 0) - { + if (type_size == 0) { throw AttributeIException(func, "H5Tget_size failed"); } // Close the native type and the datatype of this attribute. - if (H5Tclose(native_type) < 0) - { + if (H5Tclose(native_type) < 0) { throw DataSetIException(func, "H5Tclose(native_type) failed"); } - if (H5Tclose(mem_type_id) < 0) - { + if (H5Tclose(mem_type_id) < 0) { throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); } // Get number of elements of the attribute by first getting its dataspace // then getting the number of elements in the dataspace hid_t space_id = H5Aget_space(id); - if (space_id < 0) - { + if (space_id < 0) { throw AttributeIException(func, "H5Aget_space failed"); } hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); - if (num_elements < 0) - { + if (num_elements < 0) { throw AttributeIException(func, "H5Sget_simple_extent_npoints failed"); } // Close the dataspace - if (H5Sclose(space_id) < 0) - { + if (H5Sclose(space_id) < 0) { throw DataSetIException(func, "H5Sclose failed"); } // Calculate and return the size of the data size_t data_size = type_size * num_elements; - return(data_size); + return (data_size); } //-------------------------------------------------------------------------- @@ -259,20 +250,19 @@ size_t Attribute::getInMemDataSize() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace Attribute::getSpace() const +DataSpace +Attribute::getSpace() const { - // Calls C function H5Aget_space to get the id of the dataspace - hid_t dataspace_id = H5Aget_space(id); + // Calls C function H5Aget_space to get the id of the dataspace + hid_t dataspace_id = H5Aget_space(id); - // If the dataspace id is valid, create and return the DataSpace object - if (dataspace_id > 0) - { + // If the dataspace id is valid, create and return the DataSpace object + if (dataspace_id > 0) { DataSpace dataspace; f_DataSpace_setId(&dataspace, dataspace_id); - return(dataspace); + return (dataspace); } - else - { + else { throw AttributeIException("Attribute::getSpace", "H5Aget_space failed"); } } @@ -294,22 +284,21 @@ DataSpace Attribute::getSpace() const /// first argument and ignore the second argument. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t Attribute::getName(char* attr_name, size_t buf_size) const +ssize_t +Attribute::getName(char *attr_name, size_t buf_size) const { // H5Aget_name will get buf_size-1 chars of the name to null terminate it ssize_t name_size = H5Aget_name(id, buf_size, attr_name); // If H5Aget_name returns a negative value, raise an exception - if (name_size < 0) - { + if (name_size < 0) { throw AttributeIException("Attribute::getName", "H5Aget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); } // Return length of the name - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -322,7 +311,8 @@ ssize_t Attribute::getName(char* attr_name, size_t buf_size) const // Mar 2014 - BMR // Revised to use the modified getName() above //-------------------------------------------------------------------------- -H5std_string Attribute::getName() const +H5std_string +Attribute::getName() const { H5std_string attr_name(""); // attribute name to return @@ -330,32 +320,28 @@ H5std_string Attribute::getName() const ssize_t name_size = H5Aget_name(id, static_cast(0), NULL); // If H5Aget_name failed, throw exception - if (name_size < 0) - { + if (name_size < 0) { throw AttributeIException("Attribute::getName", "H5Aget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); } // Attribute's name exists, retrieve it - else if (name_size > 0) - { - char* name_C = new char[name_size+1]; // temporary C-string - HDmemset(name_C, 0, name_size+1); // clear buffer + else if (name_size > 0) { + char *name_C = new char[name_size + 1]; // temporary C-string + HDmemset(name_C, 0, name_size + 1); // clear buffer // Use overloaded function - name_size = getName(name_C, name_size+1); + name_size = getName(name_C, name_size + 1); // Convert the C attribute name to return attr_name = name_C; // Clean up resource - delete []name_C; - + delete[] name_C; } // Return attribute's name - return(attr_name); + return (attr_name); } //-------------------------------------------------------------------------- @@ -371,14 +357,15 @@ H5std_string Attribute::getName() const // Mar 2014 - BMR // Revised to use the new getName() below //-------------------------------------------------------------------------- -H5std_string Attribute::getName(size_t len) const +H5std_string +Attribute::getName(size_t len) const { H5std_string attr_name; - ssize_t name_size = getName(attr_name, len); + ssize_t name_size = getName(attr_name, len); if (name_size < 0) - return(""); + return (""); else - return(attr_name); + return (attr_name); } //-------------------------------------------------------------------------- @@ -398,35 +385,34 @@ H5std_string Attribute::getName(size_t len) const // Added to replace getName(size_t, H5std_string&) so that it'll // allow the argument "len" to be skipped. //-------------------------------------------------------------------------- -ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const +ssize_t +Attribute::getName(H5std_string &attr_name, size_t len) const { ssize_t name_size = 0; // If no length is provided, get the entire attribute name - if (len == 0) - { + if (len == 0) { attr_name = getName(); name_size = attr_name.length(); } // If length is provided, get that number of characters in name - else - { - char* name_C = new char[len+1]; // temporary C-string - HDmemset(name_C, 0, len+1); // clear buffer + else { + char *name_C = new char[len + 1]; // temporary C-string + HDmemset(name_C, 0, len + 1); // clear buffer // Use overloaded function - name_size = getName(name_C, len+1); + name_size = getName(name_C, len + 1); // Convert the C attribute name to return attr_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Otherwise, keep attr_name intact // Return name size - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -444,7 +430,7 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//ssize_t Attribute::getName(size_t len, H5std_string& attr_name) const +// ssize_t Attribute::getName(size_t len, H5std_string& attr_name) const //{ // return (getName(attr_name, len)); //} @@ -458,10 +444,11 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const // function should have no failure. (from SLU) // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -hsize_t Attribute::getStorageSize() const +hsize_t +Attribute::getStorageSize() const { - hsize_t storage_size = H5Aget_storage_size(id); - return (storage_size); + hsize_t storage_size = H5Aget_storage_size(id); + return (storage_size); } //-------------------------------------------------------------------------- @@ -480,9 +467,10 @@ hsize_t Attribute::getStorageSize() const // an attribute id can be used to specify a location in HDF5 // library. //-------------------------------------------------------------------------- -hid_t Attribute::getId() const +hid_t +Attribute::getId() const { - return(id); + return (id); } //-------------------------------------------------------------------------- @@ -494,13 +482,13 @@ hid_t Attribute::getId() const // This private function is used in AbstractDs. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hid_t Attribute::p_get_type() const +hid_t +Attribute::p_get_type() const { hid_t type_id = H5Aget_type(id); if (type_id > 0) - return(type_id); - else - { + return (type_id); + else { throw AttributeIException("", "H5Aget_type failed"); } } @@ -517,7 +505,8 @@ hid_t Attribute::p_get_type() const // Separated the fixed length case from the original // Attribute::read //-------------------------------------------------------------------------- -void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const +void +Attribute::p_read_fixed_len(const DataType &mem_type, H5std_string &strg) const { // Only allocate for fixed-len string. @@ -525,19 +514,17 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c size_t attr_size = getInMemDataSize(); // If there is data, allocate buffer and read it. - if (attr_size > 0) - { - char *strg_C = new char[attr_size+1]; + if (attr_size > 0) { + char * strg_C = new char[attr_size + 1]; herr_t ret_value = H5Aread(id, mem_type.getId(), strg_C); - if (ret_value < 0) - { - delete []strg_C; // de-allocate for fixed-len string + if (ret_value < 0) { + delete[] strg_C; // de-allocate for fixed-len string throw AttributeIException("Attribute::read", "H5Aread failed"); } // Get string from the C char* and release resource allocated locally strg_C[attr_size] = '\0'; - strg = strg_C; - delete []strg_C; + strg = strg_C; + delete[] strg_C; } } @@ -553,7 +540,8 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c // Separated the variable length case from the original // Attribute::read. -BMR //-------------------------------------------------------------------------- -void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg) const +void +Attribute::p_read_variable_len(const DataType &mem_type, H5std_string &strg) const { // Prepare and call C API to read attribute. char *strg_C; @@ -561,8 +549,7 @@ void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg // Read attribute, no allocation for variable-len string; C library will herr_t ret_value = H5Aread(id, mem_type.getId(), &strg_C); - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::read", "H5Aread failed"); } @@ -584,13 +571,14 @@ void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::p_setId(const hid_t new_id) +void +Attribute::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -605,13 +593,12 @@ void Attribute::p_setId(const hid_t new_id) ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void Attribute::close() +void +Attribute::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Aclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::close", "H5Aclose failed"); } // reset the id @@ -634,9 +621,9 @@ Attribute::~Attribute() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "Attribute::~Attribute - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index c6fdaec..8783c00 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -27,76 +27,79 @@ namespace H5 { */ // Inheritance: multiple H5Location/AbstractDs -> IdComponent class H5_DLLCPP Attribute : public AbstractDs, public H5Location { - public: + public: + // Copy constructor: same as the original Attribute. + Attribute(const Attribute &original); - // Copy constructor: same as the original Attribute. - Attribute(const Attribute& original); + // Default constructor + Attribute(); - // Default constructor - Attribute(); + // Creates a copy of an existing attribute using the attribute id + Attribute(const hid_t attr_id); - // Creates a copy of an existing attribute using the attribute id - Attribute(const hid_t attr_id); + // Closes this attribute. + virtual void close(); - // Closes this attribute. - virtual void close(); + // Gets the name of this attribute. + ssize_t getName(char *attr_name, size_t buf_size = 0) const; + H5std_string getName(size_t len) const; + H5std_string getName() const; + ssize_t getName(H5std_string &attr_name, size_t len = 0) const; + // The overloaded function below is replaced by the one above and it + // is kept for backward compatibility purpose. + ssize_t getName(size_t buf_size, H5std_string &attr_name) const; - // Gets the name of this attribute. - ssize_t getName(char* attr_name, size_t buf_size = 0) const; - H5std_string getName(size_t len) const; - H5std_string getName() const; - ssize_t getName(H5std_string& attr_name, size_t len = 0) const; - // The overloaded function below is replaced by the one above and it - // is kept for backward compatibility purpose. - ssize_t getName(size_t buf_size, H5std_string& attr_name) const; + // Gets a copy of the dataspace for this attribute. + virtual DataSpace getSpace() const; - // Gets a copy of the dataspace for this attribute. - virtual DataSpace getSpace() const; + // Returns the amount of storage size required for this attribute. + virtual hsize_t getStorageSize() const; - // Returns the amount of storage size required for this attribute. - virtual hsize_t getStorageSize() const; + // Returns the in memory size of this attribute's data. + virtual size_t getInMemDataSize() const; - // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; + // Reads data from this attribute. + void read(const DataType &mem_type, void *buf) const; + void read(const DataType &mem_type, H5std_string &strg) const; - // Reads data from this attribute. - void read(const DataType& mem_type, void *buf) const; - void read(const DataType& mem_type, H5std_string& strg) const; + // Writes data to this attribute. + void write(const DataType &mem_type, const void *buf) const; + void write(const DataType &mem_type, const H5std_string &strg) const; - // Writes data to this attribute. - void write(const DataType& mem_type, const void *buf) const; - void write(const DataType& mem_type, const H5std_string& strg) const; + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("Attribute"); + } - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Attribute"); } + // Gets the attribute id. + virtual hid_t getId() const; - // Gets the attribute id. - virtual hid_t getId() const; - - // Destructor: properly terminates access to this attribute. - virtual ~Attribute(); + // Destructor: properly terminates access to this attribute. + virtual ~Attribute(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Sets the attribute id. - virtual void p_setId(const hid_t new_id); + protected: + // Sets the attribute id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 attribute id + private: + hid_t id; // HDF5 attribute id - // This function contains the common code that is used by - // getTypeClass and various API functions getXxxType - // defined in AbstractDs for generic datatype and specific - // sub-types - virtual hid_t p_get_type() const; + // This function contains the common code that is used by + // getTypeClass and various API functions getXxxType + // defined in AbstractDs for generic datatype and specific + // sub-types + virtual hid_t p_get_type() const; - // Reads variable or fixed len strings from this attribute. - void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const; - void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const; + // Reads variable or fixed len strings from this attribute. + void p_read_variable_len(const DataType &mem_type, H5std_string &strg) const; + void p_read_fixed_len(const DataType &mem_type, H5std_string &strg) const; - // Friend function to set Attribute id. For library use only. - friend void f_Attribute_setId(Attribute* attr, hid_t new_id); + // Friend function to set Attribute id. For library use only. + friend void f_Attribute_setId(Attribute *attr, hid_t new_id); }; // end of Attribute } // namespace H5 diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h index 8b1e6ed..618b46c 100644 --- a/c++/src/H5Classes.h +++ b/c++/src/H5Classes.h @@ -16,31 +16,31 @@ #define __H5Classes_H namespace H5 { - class Exception; - class IdComponent; - class H5Location; - class H5Object; - class PropList; - class FileCreatPropList; - class FileAccPropList; - class LinkAccPropList; - class DSetCreatPropList; - class DSetMemXferPropList; - class DTypePropList; - class DataType; - class DataSpace; - class AtomType; - class PredType; - class IntType; - class FloatType; - class StrType; - class EnumType; - class CompType; - class AbstractDs; - class DataSet; - class Group; - class H5File; - class Attribute; - class H5Library; -} +class Exception; +class IdComponent; +class H5Location; +class H5Object; +class PropList; +class FileCreatPropList; +class FileAccPropList; +class LinkAccPropList; +class DSetCreatPropList; +class DSetMemXferPropList; +class DTypePropList; +class DataType; +class DataSpace; +class AtomType; +class PredType; +class IntType; +class FloatType; +class StrType; +class EnumType; +class CompType; +class AbstractDs; +class DataSet; +class Group; +class H5File; +class Attribute; +class H5Library; +} // namespace H5 #endif // __H5Classes_H diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 6c5fdca..52f9175 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -13,7 +13,7 @@ #include -#include "H5private.h" // for HDstrcpy +#include "H5private.h" // for HDstrcpy #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -55,7 +55,8 @@ namespace H5 { ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CommonFG::openDataType(const char* name) const +DataType +CommonFG::openDataType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -68,7 +69,7 @@ DataType CommonFG::openDataType(const char* name) const // No failure, create and return the DataType object DataType data_type; f_DataType_setId(&data_type, type_id); - return(data_type); + return (data_type); } //-------------------------------------------------------------------------- @@ -78,9 +79,10 @@ DataType CommonFG::openDataType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CommonFG::openDataType(const H5std_string& name) const +DataType +CommonFG::openDataType(const H5std_string &name) const { - return(openDataType(name.c_str())); + return (openDataType(name.c_str())); } //-------------------------------------------------------------------------- @@ -91,7 +93,8 @@ DataType CommonFG::openDataType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CommonFG::openArrayType(const char* name) const +ArrayType +CommonFG::openArrayType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -104,7 +107,7 @@ ArrayType CommonFG::openArrayType(const char* name) const // No failure, create and return the ArrayType object ArrayType array_type; f_DataType_setId(&array_type, type_id); - return(array_type); + return (array_type); } //-------------------------------------------------------------------------- @@ -114,9 +117,10 @@ ArrayType CommonFG::openArrayType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CommonFG::openArrayType(const H5std_string& name) const +ArrayType +CommonFG::openArrayType(const H5std_string &name) const { - return(openArrayType(name.c_str())); + return (openArrayType(name.c_str())); } //-------------------------------------------------------------------------- @@ -127,7 +131,8 @@ ArrayType CommonFG::openArrayType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CommonFG::openCompType(const char* name) const +CompType +CommonFG::openCompType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -140,7 +145,7 @@ CompType CommonFG::openCompType(const char* name) const // No failure, create and return the CompType object CompType comp_type; f_DataType_setId(&comp_type, type_id); - return(comp_type); + return (comp_type); } //-------------------------------------------------------------------------- @@ -150,9 +155,10 @@ CompType CommonFG::openCompType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CommonFG::openCompType(const H5std_string& name) const +CompType +CommonFG::openCompType(const H5std_string &name) const { - return(openCompType(name.c_str())); + return (openCompType(name.c_str())); } //-------------------------------------------------------------------------- @@ -163,7 +169,8 @@ CompType CommonFG::openCompType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType(const char* name) const +EnumType +CommonFG::openEnumType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -176,7 +183,7 @@ EnumType CommonFG::openEnumType(const char* name) const // No failure, create and return the EnumType object EnumType enum_type; f_DataType_setId(&enum_type, type_id); - return(enum_type); + return (enum_type); } //-------------------------------------------------------------------------- @@ -186,9 +193,10 @@ EnumType CommonFG::openEnumType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType(const H5std_string& name) const +EnumType +CommonFG::openEnumType(const H5std_string &name) const { - return(openEnumType(name.c_str())); + return (openEnumType(name.c_str())); } //-------------------------------------------------------------------------- @@ -199,7 +207,8 @@ EnumType CommonFG::openEnumType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CommonFG::openIntType(const char* name) const +IntType +CommonFG::openIntType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -212,7 +221,7 @@ IntType CommonFG::openIntType(const char* name) const // No failure, create and return the IntType object IntType int_type; f_DataType_setId(&int_type, type_id); - return(int_type); + return (int_type); } //-------------------------------------------------------------------------- @@ -222,9 +231,10 @@ IntType CommonFG::openIntType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CommonFG::openIntType(const H5std_string& name) const +IntType +CommonFG::openIntType(const H5std_string &name) const { - return(openIntType(name.c_str())); + return (openIntType(name.c_str())); } //-------------------------------------------------------------------------- @@ -235,7 +245,8 @@ IntType CommonFG::openIntType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CommonFG::openFloatType(const char* name) const +FloatType +CommonFG::openFloatType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -248,7 +259,7 @@ FloatType CommonFG::openFloatType(const char* name) const // No failure, create and return the FloatType object FloatType float_type; f_DataType_setId(&float_type, type_id); - return(float_type); + return (float_type); } //-------------------------------------------------------------------------- @@ -258,9 +269,10 @@ FloatType CommonFG::openFloatType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CommonFG::openFloatType(const H5std_string& name) const +FloatType +CommonFG::openFloatType(const H5std_string &name) const { - return(openFloatType(name.c_str())); + return (openFloatType(name.c_str())); } //-------------------------------------------------------------------------- @@ -271,7 +283,8 @@ FloatType CommonFG::openFloatType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CommonFG::openStrType(const char* name) const +StrType +CommonFG::openStrType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -284,7 +297,7 @@ StrType CommonFG::openStrType(const char* name) const // No failure, create and return the StrType object StrType str_type; f_DataType_setId(&str_type, type_id); - return(str_type); + return (str_type); } //-------------------------------------------------------------------------- @@ -294,9 +307,10 @@ StrType CommonFG::openStrType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CommonFG::openStrType(const H5std_string& name) const +StrType +CommonFG::openStrType(const H5std_string &name) const { - return(openStrType(name.c_str())); + return (openStrType(name.c_str())); } //-------------------------------------------------------------------------- @@ -307,7 +321,8 @@ StrType CommonFG::openStrType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CommonFG::openVarLenType(const char* name) const +VarLenType +CommonFG::openVarLenType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -320,7 +335,7 @@ VarLenType CommonFG::openVarLenType(const char* name) const // No failure, create and return the VarLenType object VarLenType varlen_type; f_DataType_setId(&varlen_type, type_id); - return(varlen_type); + return (varlen_type); } //-------------------------------------------------------------------------- @@ -330,9 +345,10 @@ VarLenType CommonFG::openVarLenType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CommonFG::openVarLenType(const H5std_string& name) const +VarLenType +CommonFG::openVarLenType(const H5std_string &name) const { - return(openVarLenType(name.c_str())); + return (openVarLenType(name.c_str())); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -341,14 +357,18 @@ VarLenType CommonFG::openVarLenType(const H5std_string& name) const ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CommonFG::CommonFG() {} +CommonFG::CommonFG() +{ +} //-------------------------------------------------------------------------- // Function: CommonFG destructor ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CommonFG::~CommonFG() {} +CommonFG::~CommonFG() +{ +} //-------------------------------------------------------------------------- // Function: f_DataType_setId - friend @@ -360,7 +380,8 @@ CommonFG::~CommonFG() {} // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataType_setId(DataType* dtype, hid_t new_id) +void +f_DataType_setId(DataType *dtype, hid_t new_id) { dtype->p_setId(new_id); } @@ -375,11 +396,12 @@ void f_DataType_setId(DataType* dtype, hid_t new_id) // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataSet_setId(DataSet* dset, hid_t new_id) +void +f_DataSet_setId(DataSet *dset, hid_t new_id) { dset->p_setId(new_id); } #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 68e3f19..c3aef41 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -28,56 +28,55 @@ class VarLenType; */ /* Note: This class is being deprecated gradually. */ class H5_DLLCPP CommonFG { - public: - // Opens a generic named datatype in this location. - DataType openDataType(const char* name) const; - DataType openDataType(const H5std_string& name) const; + public: + // Opens a generic named datatype in this location. + DataType openDataType(const char *name) const; + DataType openDataType(const H5std_string &name) const; - // Opens a named array datatype in this location. - ArrayType openArrayType(const char* name) const; - ArrayType openArrayType(const H5std_string& name) const; + // Opens a named array datatype in this location. + ArrayType openArrayType(const char *name) const; + ArrayType openArrayType(const H5std_string &name) const; - // Opens a named compound datatype in this location. - CompType openCompType(const char* name) const; - CompType openCompType(const H5std_string& name) const; + // Opens a named compound datatype in this location. + CompType openCompType(const char *name) const; + CompType openCompType(const H5std_string &name) const; - // Opens a named enumeration datatype in this location. - EnumType openEnumType(const char* name) const; - EnumType openEnumType(const H5std_string& name) const; + // Opens a named enumeration datatype in this location. + EnumType openEnumType(const char *name) const; + EnumType openEnumType(const H5std_string &name) const; - // Opens a named integer datatype in this location. - IntType openIntType(const char* name) const; - IntType openIntType(const H5std_string& name) const; + // Opens a named integer datatype in this location. + IntType openIntType(const char *name) const; + IntType openIntType(const H5std_string &name) const; - // Opens a named floating-point datatype in this location. - FloatType openFloatType(const char* name) const; - FloatType openFloatType(const H5std_string& name) const; + // Opens a named floating-point datatype in this location. + FloatType openFloatType(const char *name) const; + FloatType openFloatType(const H5std_string &name) const; - // Opens a named string datatype in this location. - StrType openStrType(const char* name) const; - StrType openStrType(const H5std_string& name) const; + // Opens a named string datatype in this location. + StrType openStrType(const char *name) const; + StrType openStrType(const H5std_string &name) const; - // Opens a named variable length datatype in this location. - VarLenType openVarLenType(const char* name) const; - VarLenType openVarLenType(const H5std_string& name) const; + // Opens a named variable length datatype in this location. + VarLenType openVarLenType(const char *name) const; + VarLenType openVarLenType(const H5std_string &name) const; #ifndef DOXYGEN_SHOULD_SKIP_THIS - /// For subclasses, H5File and Group, to return the correct - /// object id, i.e. file or group id. - virtual hid_t getLocId() const = 0; + /// For subclasses, H5File and Group, to return the correct + /// object id, i.e. file or group id. + virtual hid_t getLocId() const = 0; + /// For subclasses, H5File and Group, to throw appropriate exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const = 0; - /// For subclasses, H5File and Group, to throw appropriate exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const = 0; + // Default constructor. + CommonFG(); - // Default constructor. - CommonFG(); + // Noop destructor. + virtual ~CommonFG(); - // Noop destructor. - virtual ~CommonFG(); - - protected: - virtual void p_setId(const hid_t new_id) = 0; + protected: + virtual void p_setId(const hid_t new_id) = 0; #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index fe96bb0..5eb030c 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -37,7 +37,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub compound datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType() : DataType() {} +CompType::CompType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: CompType copy constructor @@ -45,7 +47,9 @@ CompType::CompType() : DataType() {} ///\param original - IN: Original CompType instance // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const CompType& original) : DataType(original) {} +CompType::CompType(const CompType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -53,7 +57,9 @@ CompType::CompType(const CompType& original) : DataType(original) {} ///\param existing_id - IN: Id of an existing compound datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const hid_t existing_id) : DataType(existing_id) {} +CompType::CompType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -65,7 +71,9 @@ CompType::CompType(const hid_t existing_id) : DataType(existing_id) {} // the compound datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) {} +CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -75,14 +83,13 @@ CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const DataSet& dataset) : DataType() +CompType::CompType(const DataSet &dataset) : DataType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); // If the datatype id is invalid, throw exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("CompType constructor", "H5Dget_type failed"); } } @@ -101,7 +108,7 @@ CompType::CompType(const DataSet& dataset) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -CompType::CompType(const H5Location& loc, const char *dtype_name) : DataType() +CompType::CompType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -120,7 +127,7 @@ CompType::CompType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -CompType::CompType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +CompType::CompType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -133,7 +140,8 @@ CompType::CompType(const H5Location& loc, const H5std_string& dtype_name) : Data ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* CompType::decode() const +DataType * +CompType::decode() const { hid_t encoded_cmptype_id = H5I_INVALID_HID; try { @@ -144,7 +152,7 @@ DataType* CompType::decode() const } CompType *encoded_cmptype = new CompType; encoded_cmptype->p_setId(encoded_cmptype_id); - return(encoded_cmptype); + return (encoded_cmptype); } //-------------------------------------------------------------------------- @@ -154,15 +162,15 @@ DataType* CompType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int CompType::getNmembers() const +int +CompType::getNmembers() const { int num_members = H5Tget_nmembers(id); - if (num_members < 0) - { + if (num_members < 0) { throw DataTypeIException("CompType::getNmembers", - "H5Tget_nmembers returns negative number of members"); + "H5Tget_nmembers returns negative number of members"); } - return(num_members); + return (num_members); } //-------------------------------------------------------------------------- @@ -173,17 +181,18 @@ int CompType::getNmembers() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string CompType::getMemberName(unsigned member_num) const +H5std_string +CompType::getMemberName(unsigned member_num) const { - char* member_name_C = H5Tget_member_name(id, member_num); - if (member_name_C == NULL) // NULL means failure + char *member_name_C = H5Tget_member_name(id, member_num); + if (member_name_C == NULL) // NULL means failure { throw DataTypeIException("CompType::getMemberName", - "H5Tget_member_name returns NULL for member name"); + "H5Tget_member_name returns NULL for member name"); } H5std_string member_name = H5std_string(member_name_C); // convert C string to string - H5free_memory(member_name_C); // free the C string - return(member_name); // return the member name string + H5free_memory(member_name_C); // free the C string + return (member_name); // return the member name string } //-------------------------------------------------------------------------- @@ -198,19 +207,19 @@ H5std_string CompType::getMemberName(unsigned member_num) const /// function \c CompType::getNmembers. // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int CompType::getMemberIndex(const char* name) const +int +CompType::getMemberIndex(const char *name) const { int member_index = H5Tget_member_index(id, name); - if (member_index < 0) - { - throw DataTypeIException("CompType::getMemberIndex", - "H5Tget_member_index returns negative value"); + if (member_index < 0) { + throw DataTypeIException("CompType::getMemberIndex", "H5Tget_member_index returns negative value"); } - return(member_index); + return (member_index); } -int CompType::getMemberIndex(const H5std_string& name) const +int +CompType::getMemberIndex(const H5std_string &name) const { - return(getMemberIndex(name.c_str())); + return (getMemberIndex(name.c_str())); } //-------------------------------------------------------------------------- @@ -228,10 +237,11 @@ int CompType::getMemberIndex(const H5std_string& name) const // Note that byte offset being returned as 0 doesn't indicate // a failure. (According to Quincey) //-------------------------------------------------------------------------- -size_t CompType::getMemberOffset(unsigned member_num) const +size_t +CompType::getMemberOffset(unsigned member_num) const { size_t offset = H5Tget_member_offset(id, member_num); - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -244,29 +254,28 @@ size_t CompType::getMemberOffset(unsigned member_num) const // Modification // Modified to use H5Tget_member_class instead. - Jul, 2005 //-------------------------------------------------------------------------- -H5T_class_t CompType::getMemberClass(unsigned member_num) const +H5T_class_t +CompType::getMemberClass(unsigned member_num) const { H5T_class_t member_class = H5Tget_member_class(id, member_num); - if (member_class == H5T_NO_CLASS) - { - throw DataTypeIException("CompType::getMemberClass", - "H5Tget_member_class returns H5T_NO_CLASS"); + if (member_class == H5T_NO_CLASS) { + throw DataTypeIException("CompType::getMemberClass", "H5Tget_member_class returns H5T_NO_CLASS"); } - return(member_class); + return (member_class); } // This private member function calls the C API to get the identifier // of the specified member. It provides the id to construct appropriate // sub-types in the functions getMemberXxxType below, where Xxx indicates // the sub-types. -hid_t CompType::p_get_member_type(unsigned member_num) const +hid_t +CompType::p_get_member_type(unsigned member_num) const { // get the id of the specified member first hid_t member_type_id = H5Tget_member_type(id, member_num); if (member_type_id > 0) - return(member_type_id); - else - { + return (member_type_id); + else { // p_get_member_type is private, caller will catch this exception // then throw another with appropriate API name throw DataTypeIException("", "H5Tget_member_type failed"); @@ -282,14 +291,15 @@ hid_t CompType::p_get_member_type(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CompType::getMemberDataType(unsigned member_num) const +DataType +CompType::getMemberDataType(unsigned member_num) const { try { DataType datatype; f_DataType_setId(&datatype, p_get_member_type(member_num)); - return(datatype); + return (datatype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); } } @@ -303,14 +313,15 @@ DataType CompType::getMemberDataType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CompType::getMemberArrayType(unsigned member_num) const +ArrayType +CompType::getMemberArrayType(unsigned member_num) const { try { ArrayType arraytype; f_DataType_setId(&arraytype, p_get_member_type(member_num)); - return(arraytype); + return (arraytype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberArrayType", E.getDetailMsg()); } } @@ -324,14 +335,15 @@ ArrayType CompType::getMemberArrayType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CompType::getMemberCompType(unsigned member_num) const +CompType +CompType::getMemberCompType(unsigned member_num) const { try { CompType comptype; f_DataType_setId(&comptype, p_get_member_type(member_num)); - return(comptype); + return (comptype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberCompType", E.getDetailMsg()); } } @@ -345,14 +357,15 @@ CompType CompType::getMemberCompType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CompType::getMemberEnumType(unsigned member_num) const +EnumType +CompType::getMemberEnumType(unsigned member_num) const { try { EnumType enumtype; f_DataType_setId(&enumtype, p_get_member_type(member_num)); - return(enumtype); + return (enumtype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberEnumType", E.getDetailMsg()); } } @@ -366,14 +379,15 @@ EnumType CompType::getMemberEnumType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CompType::getMemberIntType(unsigned member_num) const +IntType +CompType::getMemberIntType(unsigned member_num) const { try { IntType inttype; f_DataType_setId(&inttype, p_get_member_type(member_num)); - return(inttype); + return (inttype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg()); } } @@ -387,14 +401,15 @@ IntType CompType::getMemberIntType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CompType::getMemberFloatType(unsigned member_num) const +FloatType +CompType::getMemberFloatType(unsigned member_num) const { try { FloatType floatype; f_DataType_setId(&floatype, p_get_member_type(member_num)); - return(floatype); + return (floatype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberFloatType", E.getDetailMsg()); } } @@ -408,14 +423,15 @@ FloatType CompType::getMemberFloatType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CompType::getMemberStrType(unsigned member_num) const +StrType +CompType::getMemberStrType(unsigned member_num) const { try { StrType strtype; f_DataType_setId(&strtype, p_get_member_type(member_num)); - return(strtype); + return (strtype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg()); } } @@ -429,14 +445,15 @@ StrType CompType::getMemberStrType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CompType::getMemberVarLenType(unsigned member_num) const +VarLenType +CompType::getMemberVarLenType(unsigned member_num) const { try { VarLenType varlentype; f_DataType_setId(&varlentype, p_get_member_type(member_num)); - return(varlentype); + return (varlentype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberVarLenType", E.getDetailMsg()); } } @@ -483,18 +500,18 @@ void CompType::getMemberType(unsigned member_num, StrType& strtype) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void CompType::insertMember(const H5std_string& name, size_t offset, const DataType& new_member) const +void +CompType::insertMember(const H5std_string &name, size_t offset, const DataType &new_member) const { // Convert string to C-string - const char* name_C; - name_C = name.c_str(); // name_C refers to the contents of name as a C-str + const char *name_C; + name_C = name.c_str(); // name_C refers to the contents of name as a C-str - hid_t new_member_id = new_member.getId(); // get new_member id for C API + hid_t new_member_id = new_member.getId(); // get new_member id for C API // Call C routine H5Tinsert to add the new member herr_t ret_value = H5Tinsert(id, name_C, offset, new_member_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::insertMember", "H5Tinsert failed"); } } @@ -506,12 +523,12 @@ void CompType::insertMember(const H5std_string& name, size_t offset, const DataT ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void CompType::pack() const +void +CompType::pack() const { // Calls C routine H5Tpack to remove padding herr_t ret_value = H5Tpack(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::pack", "H5Tpack failed"); } } @@ -525,12 +542,12 @@ void CompType::pack() const // H5Tset_size works on atom datatypes and compound datatypes only // Programmer Binh-Minh Ribler - 2014 //-------------------------------------------------------------------------- -void CompType::setSize(size_t size) const +void +CompType::setSize(size_t size) const { // Call C routine H5Tset_size to set the total size herr_t ret_value = H5Tset_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::setSize", "H5Tset_size failed"); } } @@ -540,6 +557,8 @@ void CompType::setSize(size_t size) const ///\brief Properly terminates access to this compound datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::~CompType() {} +CompType::~CompType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index d85e2ed..66392d9 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -23,99 +23,103 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP CompType : public DataType { - public: - // Default constructor - CompType(); + public: + // Default constructor + CompType(); - // Creates a compound datatype using an existing id - CompType(const hid_t existing_id); + // Creates a compound datatype using an existing id + CompType(const hid_t existing_id); - // Creates a new compound datatype, given the type's size - CompType(size_t size); // H5Tcreate + // Creates a new compound datatype, given the type's size + CompType(size_t size); // H5Tcreate - // Gets the compound datatype of the specified dataset - CompType(const DataSet& dataset); // H5Dget_type + // Gets the compound datatype of the specified dataset + CompType(const DataSet &dataset); // H5Dget_type - // Copy constructor - same as the original CompType. - CompType(const CompType& original); + // Copy constructor - same as the original CompType. + CompType(const CompType &original); - // Constructors that open a compound datatype, given a location. - CompType(const H5Location& loc, const char* name); - CompType(const H5Location& loc, const H5std_string& name); + // Constructors that open a compound datatype, given a location. + CompType(const H5Location &loc, const char *name); + CompType(const H5Location &loc, const H5std_string &name); - // Returns a CompType object via DataType* by decoding the binary - // object description of this type. - virtual DataType* decode() const; + // Returns a CompType object via DataType* by decoding the binary + // object description of this type. + virtual DataType *decode() const; - // Returns the type class of the specified member of this compound - // datatype. It provides to the user a way of knowing what type - // to create another datatype of the same class - H5T_class_t getMemberClass(unsigned member_num) const; + // Returns the type class of the specified member of this compound + // datatype. It provides to the user a way of knowing what type + // to create another datatype of the same class + H5T_class_t getMemberClass(unsigned member_num) const; - // Returns the index of a member in this compound data type. - int getMemberIndex(const char* name) const; - int getMemberIndex(const H5std_string& name) const; + // Returns the index of a member in this compound data type. + int getMemberIndex(const char *name) const; + int getMemberIndex(const H5std_string &name) const; - // Returns the offset of a member of this compound datatype. - size_t getMemberOffset(unsigned memb_no) const; + // Returns the offset of a member of this compound datatype. + size_t getMemberOffset(unsigned memb_no) const; - // Returns the name of a member of this compound datatype. - H5std_string getMemberName(unsigned member_num) const; + // Returns the name of a member of this compound datatype. + H5std_string getMemberName(unsigned member_num) const; - // Returns the generic datatype of the specified member in - // this compound datatype. - DataType getMemberDataType(unsigned member_num) const; + // Returns the generic datatype of the specified member in + // this compound datatype. + DataType getMemberDataType(unsigned member_num) const; - // Returns the array datatype of the specified member in - // this compound datatype. - ArrayType getMemberArrayType(unsigned member_num) const; + // Returns the array datatype of the specified member in + // this compound datatype. + ArrayType getMemberArrayType(unsigned member_num) const; - // Returns the compound datatype of the specified member in - // this compound datatype. - CompType getMemberCompType(unsigned member_num) const; + // Returns the compound datatype of the specified member in + // this compound datatype. + CompType getMemberCompType(unsigned member_num) const; - // Returns the enumeration datatype of the specified member in - // this compound datatype. - EnumType getMemberEnumType(unsigned member_num) const; + // Returns the enumeration datatype of the specified member in + // this compound datatype. + EnumType getMemberEnumType(unsigned member_num) const; - // Returns the integer datatype of the specified member in - // this compound datatype. - IntType getMemberIntType(unsigned member_num) const; + // Returns the integer datatype of the specified member in + // this compound datatype. + IntType getMemberIntType(unsigned member_num) const; - // Returns the floating-point datatype of the specified member in - // this compound datatype. - FloatType getMemberFloatType(unsigned member_num) const; + // Returns the floating-point datatype of the specified member in + // this compound datatype. + FloatType getMemberFloatType(unsigned member_num) const; - // Returns the string datatype of the specified member in - // this compound datatype. - StrType getMemberStrType(unsigned member_num) const; + // Returns the string datatype of the specified member in + // this compound datatype. + StrType getMemberStrType(unsigned member_num) const; - // Returns the variable length datatype of the specified member in - // this compound datatype. - VarLenType getMemberVarLenType(unsigned member_num) const; + // Returns the variable length datatype of the specified member in + // this compound datatype. + VarLenType getMemberVarLenType(unsigned member_num) const; - // Returns the number of members in this compound datatype. - int getNmembers() const; + // Returns the number of members in this compound datatype. + int getNmembers() const; - // Adds a new member to this compound datatype. - void insertMember(const H5std_string& name, size_t offset, const DataType& new_member) const; + // Adds a new member to this compound datatype. + void insertMember(const H5std_string &name, size_t offset, const DataType &new_member) const; - // Recursively removes padding from within this compound datatype. - void pack() const; + // Recursively removes padding from within this compound datatype. + void pack() const; - // Sets the total size for this compound datatype. - void setSize(size_t size) const; + // Sets the total size for this compound datatype. + void setSize(size_t size) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("CompType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("CompType"); + } - // Noop destructor. - virtual ~CompType(); + // Noop destructor. + virtual ~CompType(); - private: - // Contains common code that is used by the member functions - // getMemberXxxType - hid_t p_get_member_type(unsigned member_num) const; + private: + // Contains common code that is used by the member functions + // getMemberXxxType + hid_t p_get_member_type(unsigned member_num) const; }; // end of CompType } // namespace H5 diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 01fae45..e614d69 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -53,9 +53,9 @@ */ #ifndef H5_CXX_HAVE_OFFSETOF #ifdef HOFFSET - #undef HOFFSET +#undef HOFFSET #endif -#define HOFFSET(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#define HOFFSET(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) #endif #endif // __H5Cpp_H diff --git a/c++/src/H5DaccProp.cpp b/c++/src/H5DaccProp.cpp index c6ff705..0a203d2 100644 --- a/c++/src/H5DaccProp.cpp +++ b/c++/src/H5DaccProp.cpp @@ -29,7 +29,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetAccPropList* DSetAccPropList::DEFAULT_ = 0; +DSetAccPropList *DSetAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetAccPropList::getConstant @@ -43,13 +43,13 @@ DSetAccPropList* DSetAccPropList::DEFAULT_ = 0; // not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetAccPropList* DSetAccPropList::getConstant() +DSetAccPropList * +DSetAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -58,8 +58,9 @@ DSetAccPropList* DSetAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetAccPropList(H5P_DATASET_ACCESS); else - throw PropListIException("DSetAccPropList::getConstant", "DSetAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("DSetAccPropList::getConstant", + "DSetAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -68,7 +69,8 @@ DSetAccPropList* DSetAccPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetAccPropList::deleteConstants() +void +DSetAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -77,7 +79,7 @@ void DSetAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for dataset creation default property //-------------------------------------------------------------------------- -const DSetAccPropList& DSetAccPropList::DEFAULT = *getConstant(); +const DSetAccPropList &DSetAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -86,7 +88,9 @@ const DSetAccPropList& DSetAccPropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub dataset creation property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) {} +DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList copy constructor @@ -94,7 +98,9 @@ DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) {} /// DSetAccPropList object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList(const DSetAccPropList& orig) : LinkAccPropList(orig) {} +DSetAccPropList::DSetAccPropList(const DSetAccPropList &orig) : LinkAccPropList(orig) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList overloaded constructor @@ -102,7 +108,9 @@ DSetAccPropList::DSetAccPropList(const DSetAccPropList& orig) : LinkAccPropList( /// existing dataset creation property list. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_id) {} +DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList::setChunkCache @@ -122,11 +130,11 @@ DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_i /// the HDF5 C Reference Manual. // July 2018 //-------------------------------------------------------------------------- -void DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const +void +DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const { herr_t ret_value = H5Pset_chunk_cache(id, rdcc_nslots, rdcc_nbytes, rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetAccPropList::setChunkCache", "H5Pset_chunk_cache failed"); } } @@ -143,11 +151,11 @@ void DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, doub /// the HDF5 C Reference Manual. // July 2018 //-------------------------------------------------------------------------- -void DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const +void +DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const { herr_t ret_value = H5Pget_chunk_cache(id, &rdcc_nslots, &rdcc_nbytes, &rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetAccPropList::getChunkCache", "H5Pget_chunk_cache failed"); } } @@ -157,6 +165,8 @@ void DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, d ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::~DSetAccPropList() {} +DSetAccPropList::~DSetAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DaccProp.h b/c++/src/H5DaccProp.h index 111b4f5..a467fac 100644 --- a/c++/src/H5DaccProp.h +++ b/c++/src/H5DaccProp.h @@ -23,42 +23,46 @@ namespace H5 { */ // Inheritance: LinkAccPropList -> PropList -> IdComponent class H5_DLLCPP DSetAccPropList : public LinkAccPropList { - public: - ///\brief Default dataset creation property list. - static const DSetAccPropList& DEFAULT; + public: + ///\brief Default dataset creation property list. + static const DSetAccPropList &DEFAULT; - // Creates a dataset creation property list. - DSetAccPropList(); + // Creates a dataset creation property list. + DSetAccPropList(); - // Sets the raw data chunk cache parameters. - void setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const; + // Sets the raw data chunk cache parameters. + void setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const; - // Retrieves the raw data chunk cache parameters. - void getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const; + // Retrieves the raw data chunk cache parameters. + void getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetAccPropList"); + } - // Copy constructor - same as the original DSetAccPropList. - DSetAccPropList(const DSetAccPropList& orig); + // Copy constructor - same as the original DSetAccPropList. + DSetAccPropList(const DSetAccPropList &orig); - // Creates a copy of an existing dataset creation property list - // using the property list id. - DSetAccPropList(const hid_t plist_id); + // Creates a copy of an existing dataset creation property list + // using the property list id. + DSetAccPropList(const hid_t plist_id); - // Noop destructor. - virtual ~DSetAccPropList(); + // Noop destructor. + virtual ~DSetAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetAccPropList* DEFAULT_; + private: + static DSetAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index a071289..607f88b 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -18,7 +18,7 @@ #endif #include -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -48,7 +48,9 @@ using std::endl; ///\brief Default constructor: creates a stub DataSet. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) {} +DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: DataSet overloaded constructor @@ -73,7 +75,7 @@ DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs(), id(existin ///\param original - IN: DataSet instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(original.id) +DataSet::DataSet(const DataSet &original) : H5Object(), AbstractDs(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -93,7 +95,8 @@ DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(origina /// is a datatype that has been named by DataType::commit. // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +DataSet::DataSet(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), AbstractDs(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereferenced"); } @@ -109,7 +112,8 @@ DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, co ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +DataSet::DataSet(const Attribute &attr, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), AbstractDs(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -121,32 +125,32 @@ DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, co ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace DataSet::getSpace() const +DataSpace +DataSet::getSpace() const { // Calls C function H5Dget_space to get the id of the dataspace hid_t dataspace_id = H5Dget_space(id); // If the dataspace id is invalid, throw an exception - if (dataspace_id < 0) - { + if (dataspace_id < 0) { throw DataSetIException("DataSet::getSpace", "H5Dget_space failed"); } - //create dataspace object using the existing id then return the object + // create dataspace object using the existing id then return the object DataSpace data_space; f_DataSpace_setId(&data_space, dataspace_id); - return(data_space); + return (data_space); } // This private member function calls the C API to get the identifier // of the datatype that is used by this dataset. It is used // by the various AbstractDs functions to get the specific datatype. -hid_t DataSet::p_get_type() const +hid_t +DataSet::p_get_type() const { hid_t type_id = H5Dget_type(id); if (type_id > 0) - return(type_id); - else - { + return (type_id); + else { throw DataSetIException("", "H5Dget_type failed"); } } @@ -158,18 +162,18 @@ hid_t DataSet::p_get_type() const ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList DataSet::getCreatePlist() const +DSetCreatPropList +DataSet::getCreatePlist() const { hid_t create_plist_id = H5Dget_create_plist(id); - if (create_plist_id < 0) - { + if (create_plist_id < 0) { throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed"); } // create and return the DSetCreatPropList object DSetCreatPropList create_plist; f_PropList_setId(&create_plist, create_plist_id); - return(create_plist); + return (create_plist); } //-------------------------------------------------------------------------- @@ -179,18 +183,18 @@ DSetCreatPropList DataSet::getCreatePlist() const ///\exception H5::DataSetIException // July 2018 //-------------------------------------------------------------------------- -DSetAccPropList DataSet::getAccessPlist() const +DSetAccPropList +DataSet::getAccessPlist() const { hid_t access_plist_id = H5Dget_access_plist(id); - if (access_plist_id < 0) - { + if (access_plist_id < 0) { throw DataSetIException("DataSet::getAccessPlist", "H5Dget_access_plist failed"); } // create and return the DSetCreatPropList object DSetAccPropList access_plist; f_PropList_setId(&access_plist, access_plist_id); - return(access_plist); + return (access_plist); } //-------------------------------------------------------------------------- @@ -202,10 +206,11 @@ DSetAccPropList DataSet::getAccessPlist() const // function should have no failure. (from SLU) // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -hsize_t DataSet::getStorageSize() const +hsize_t +DataSet::getStorageSize() const { hsize_t storage_size = H5Dget_storage_size(id); - return(storage_size); + return (storage_size); } //-------------------------------------------------------------------------- @@ -215,62 +220,55 @@ hsize_t DataSet::getStorageSize() const ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - Apr 2009 //-------------------------------------------------------------------------- -size_t DataSet::getInMemDataSize() const +size_t +DataSet::getInMemDataSize() const { const char *func = "DataSet::getInMemDataSize"; // Get the data type of this dataset hid_t mem_type_id = H5Dget_type(id); - if (mem_type_id < 0) - { + if (mem_type_id < 0) { throw DataSetIException(func, "H5Dget_type failed"); } // Get the data type's size by first getting its native type then getting // the native type's size. hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); - if (native_type < 0) - { + if (native_type < 0) { throw DataSetIException(func, "H5Tget_native_type failed"); } size_t type_size = H5Tget_size(native_type); - if (type_size == 0) - { + if (type_size == 0) { throw DataSetIException(func, "H5Tget_size failed"); } // Close the native type and the datatype of this dataset. - if (H5Tclose(native_type) < 0) - { + if (H5Tclose(native_type) < 0) { throw DataSetIException(func, "H5Tclose(native_type) failed"); } - if (H5Tclose(mem_type_id) < 0) - { + if (H5Tclose(mem_type_id) < 0) { throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); } // Get number of elements of the dataset by first getting its dataspace, // then getting the number of elements in the dataspace hid_t space_id = H5Dget_space(id); - if (space_id < 0) - { + if (space_id < 0) { throw DataSetIException(func, "H5Dget_space failed"); } hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); - if (num_elements < 0) - { + if (num_elements < 0) { throw DataSetIException(func, "H5Sget_simple_extent_npoints failed"); } // Close the dataspace - if (H5Sclose(space_id) < 0) - { + if (H5Sclose(space_id) < 0) { throw DataSetIException(func, "H5Sclose failed"); } // Calculate and return the size of the data size_t data_size = type_size * num_elements; - return(data_size); + return (data_size); } //-------------------------------------------------------------------------- @@ -280,16 +278,16 @@ size_t DataSet::getInMemDataSize() const ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -haddr_t DataSet::getOffset() const +haddr_t +DataSet::getOffset() const { haddr_t ds_addr; // for address of dataset ds_addr = H5Dget_offset(id); - if (ds_addr == HADDR_UNDEF) - { + if (ds_addr == HADDR_UNDEF) { throw DataSetIException("DataSet::getOffset", "H5Dget_offset returned HADDR_UNDEF"); } - return(ds_addr); + return (ds_addr); } //-------------------------------------------------------------------------- @@ -299,11 +297,11 @@ haddr_t DataSet::getOffset() const ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::getSpaceStatus(H5D_space_status_t& status) const +void +DataSet::getSpaceStatus(H5D_space_status_t &status) const { herr_t ret_value = H5Dget_space_status(id, &status); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::getSpaceStatus", "H5Dget_space_status failed"); } } @@ -317,20 +315,20 @@ void DataSet::getSpaceStatus(H5D_space_status_t& status) const ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) const +hsize_t +DataSet::getVlenBufSize(const DataType &type, const DataSpace &space) const { // Obtain identifiers for C API - hid_t type_id = type.getId(); + hid_t type_id = type.getId(); hid_t space_id = space.getId(); hsize_t size; // for amount of storage herr_t ret_value = H5Dvlen_get_buf_size(id, type_id, space_id, &size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::getVlenBufSize", "H5Dvlen_get_buf_size failed"); } - return(size); + return (size); } //-------------------------------------------------------------------------- @@ -346,7 +344,7 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) co // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//hsize_t DataSet::getVlenBufSize(DataType& type, DataSpace& space) const +// hsize_t DataSet::getVlenBufSize(DataType& type, DataSpace& space) const //{ // return(getVlenBufSize(type, space)); //} @@ -362,16 +360,17 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) co ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf) +void +DataSet::vlenReclaim(const DataType &type, const DataSpace &space, const DSetMemXferPropList &xfer_plist, + void *buf) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Treclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::vlenReclaim", "H5Treclaim failed"); } } @@ -390,16 +389,17 @@ void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DS // This function has better prototype for the users than the // other, which might be removed at some point. BMR - 2006/12/20 //-------------------------------------------------------------------------- -void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist) +void +DataSet::vlenReclaim(void *buf, const DataType &type, const DataSpace &space, + const DSetMemXferPropList &xfer_plist) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Treclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::vlenReclaim", "H5Treclaim failed"); } } @@ -419,17 +419,18 @@ void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& spac /// to memory datatype \a mem_type and dataspace \a mem_space. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::read(void *buf, const DataType &mem_type, const DataSpace &mem_space, const DataSpace &file_space, + const DSetMemXferPropList &xfer_plist) const { // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::read", "H5Dread failed"); } } @@ -453,28 +454,28 @@ void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_spa // DataSet::p_read_fixed_len and // DataSet::p_read_variable_len //-------------------------------------------------------------------------- -void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::read(H5std_string &strg, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Check if this dataset has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw DataSetIException("DataSet::read", "H5Tis_variable_str failed"); } // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); - if (!is_variable_len) // only allocate for fixed-len string + if (!is_variable_len) // only allocate for fixed-len string { p_read_fixed_len(mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg); } - else - { + else { p_read_variable_len(mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg); } } @@ -495,17 +496,18 @@ void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace /// and dataspace. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::write(const void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::write(const void *buf, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::write", "H5Dwrite failed"); } } @@ -520,39 +522,37 @@ void DataSet::write(const void* buf, const DataType& mem_type, const DataSpace& // Modified to pass the buffer into H5Dwrite properly depending // whether the dataset has variable- or fixed-length string. //-------------------------------------------------------------------------- -void DataSet::write(const H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::write(const H5std_string &strg, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw DataSetIException("DataSet::write", "H5Tis_variable_str failed"); } // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); // Convert string to C-string - const char* strg_C; - strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str + const char *strg_C; + strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str herr_t ret_value = 0; // Pass string in differently depends on variable or fixed length - if (!is_variable_len) - { + if (!is_variable_len) { ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); } - else - { + else { // passing string argument by address ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C); } - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::write", "H5Dwrite failed"); } } @@ -574,15 +574,17 @@ void DataSet::write(const H5std_string& strg, const DataType& mem_type, const Da /// under development. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSet::iterateElems(void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data) +int +DataSet::iterateElems(void *buf, const DataType &type, const DataSpace &space, H5D_operator_t op, + void *op_data) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); herr_t ret_value = H5Diterate(buf, type_id, space_id, op, op_data); if (ret_value >= 0) - return(ret_value); - else // raise exception when H5Diterate returns a negative value + return (ret_value); + else // raise exception when H5Diterate returns a negative value { throw DataSetIException("DataSet::iterateElems", "H5Diterate failed"); } @@ -598,10 +600,11 @@ int DataSet::iterateElems(void* buf, const DataType& type, const DataSpace& spac /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::extend(const hsize_t* size) const +void +DataSet::extend(const hsize_t *size) const { herr_t ret_value = H5Dset_extent(id, size); - if (ret_value < 0) // raise exception when H5Dset_extent returns a neg value + if (ret_value < 0) // raise exception when H5Dset_extent returns a neg value throw DataSetIException("DataSet::extend", "H5Dset_extent failed"); } @@ -616,14 +619,15 @@ void DataSet::extend(const hsize_t* size) const ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2014 //-------------------------------------------------------------------------- -void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const +void +DataSet::fillMemBuf(const void *fill, const DataType &fill_type, void *buf, const DataType &buf_type, + const DataSpace &space) const { - hid_t fill_type_id = fill_type.getId(); - hid_t buf_type_id = buf_type.getId(); - hid_t space_id = space.getId(); - herr_t ret_value = H5Dfill(fill, fill_type_id, buf, buf_type_id, space_id); - if (ret_value < 0) - { + hid_t fill_type_id = fill_type.getId(); + hid_t buf_type_id = buf_type.getId(); + hid_t space_id = space.getId(); + herr_t ret_value = H5Dfill(fill, fill_type_id, buf, buf_type_id, space_id); + if (ret_value < 0) { throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); } } @@ -645,7 +649,8 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSet::fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space) +// void DataSet::fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& +// space) //{ // fillMemBuf(fill, (const DataType)fill_type, buf, (const DataType)buf_type, (const DataSpace)space); //} @@ -659,13 +664,13 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const +void +DataSet::fillMemBuf(void *buf, const DataType &buf_type, const DataSpace &space) const { - hid_t buf_type_id = buf_type.getId(); - hid_t space_id = space.getId(); - herr_t ret_value = H5Dfill(NULL, buf_type_id, buf, buf_type_id, space_id); - if (ret_value < 0) - { + hid_t buf_type_id = buf_type.getId(); + hid_t space_id = space.getId(); + herr_t ret_value = H5Dfill(NULL, buf_type_id, buf, buf_type_id, space_id); + if (ret_value < 0) { throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); } } @@ -685,7 +690,7 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) +// void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) //{ // fillMemBuf(buf, (const DataType)buf_type, (const DataSpace)space); //} @@ -701,9 +706,10 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataSet::getId() const +hid_t +DataSet::getId() const { - return(id); + return (id); } //-------------------------------------------------------------------------- @@ -717,7 +723,9 @@ hid_t DataSet::getId() const // Jul 2009 // Added in follow to the change in Attribute::read //-------------------------------------------------------------------------- -void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const +void +DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, + const hid_t xfer_plist_id, H5std_string &strg) const { // Only allocate for fixed-len string. @@ -725,22 +733,20 @@ void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id size_t data_size = getInMemDataSize(); // If there is data, allocate buffer and read it. - if (data_size > 0) - { - char *strg_C = new char [data_size+1]; - HDmemset(strg_C, 0, data_size+1); // clear buffer + if (data_size > 0) { + char *strg_C = new char[data_size + 1]; + HDmemset(strg_C, 0, data_size + 1); // clear buffer herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); - if (ret_value < 0) - { - delete []strg_C; // de-allocate for fixed-len string + if (ret_value < 0) { + delete[] strg_C; // de-allocate for fixed-len string throw DataSetIException("DataSet::read", "H5Dread failed for fixed length string"); } // Get string from the C char* and release resource allocated locally strg = strg_C; - delete []strg_C; + delete[] strg_C; } } @@ -755,7 +761,9 @@ void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id // Jul 2009 // Added in follow to the change in Attribute::read //-------------------------------------------------------------------------- -void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const +void +DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, + const hid_t xfer_plist_id, H5std_string &strg) const { // Prepare and call C API to read dataset. char *strg_C; @@ -763,8 +771,7 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space // Read dataset, no allocation for variable-len string; C library will herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::read", "H5Dread failed for variable length string"); } @@ -786,17 +793,18 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::p_setId(const hid_t new_id) +void +DataSet::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataSetIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } //-------------------------------------------------------------------------- @@ -809,7 +817,8 @@ void DataSet::p_setId(const hid_t new_id) // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_PropList_setId(PropList* plist, hid_t new_id) +void +f_PropList_setId(PropList *plist, hid_t new_id) { plist->p_setId(new_id); } @@ -823,13 +832,12 @@ void f_PropList_setId(PropList* plist, hid_t new_id) ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataSet::close() +void +DataSet::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Dclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::close", "H5Dclose failed"); } // reset the id @@ -852,9 +860,9 @@ DataSet::~DataSet() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "DataSet::~DataSet - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index a0a962e..0bf7589 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -26,109 +26,129 @@ namespace H5 { */ // Inheritance: multiple H5Object/AbstractDs -> H5Location -> IdComponent class H5_DLLCPP DataSet : public H5Object, public AbstractDs { - public: - - // Close this dataset. - virtual void close(); - - // Extends the dataset with unlimited dimension. - void extend(const hsize_t* size) const; - - // Fills a selection in memory with a value - void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const; - //void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 - - // Fills a selection in memory with zero - void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const; - //void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 - - // Gets the creation property list of this dataset. - DSetCreatPropList getCreatePlist() const; - - // Gets the access property list of this dataset. - DSetAccPropList getAccessPlist() const; - - // Returns the address of this dataset in the file. - haddr_t getOffset() const; - - // Gets the dataspace of this dataset. - virtual DataSpace getSpace() const; - - // Determines whether space has been allocated for a dataset. - void getSpaceStatus(H5D_space_status_t& status) const; - - // Returns the amount of storage size required for this dataset. - virtual hsize_t getStorageSize() const; - - // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; - - // Returns the number of bytes required to store VL data. - hsize_t getVlenBufSize(const DataType& type, const DataSpace& space) const; - //hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1 - - // Reclaims VL datatype memory buffers. - static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf); - static void vlenReclaim(void *buf, const DataType& type, const DataSpace& space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT); - - // Reads the data of this dataset and stores it in the provided buffer. - // The memory and file dataspaces and the transferring property list - // can be defaults. - void read(void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - void read(H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - - // Writes the buffered data to this dataset. - // The memory and file dataspaces and the transferring property list - // can be defaults. - void write(const void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - void write(const H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - - // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet - int iterateElems(void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL); - - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataSet"); } - - // Creates a dataset by way of dereference. - DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - - // Default constructor. - DataSet(); - - // Copy constructor - same as the original DataSet. - DataSet(const DataSet& original); - - // Creates a copy of an existing DataSet using its id. - DataSet(const hid_t existing_id); - - // Gets the dataset id. - virtual hid_t getId() const; - - // Destructor: properly terminates access to this dataset. - virtual ~DataSet(); - - protected: + public: + // Close this dataset. + virtual void close(); + + // Extends the dataset with unlimited dimension. + void extend(const hsize_t *size) const; + + // Fills a selection in memory with a value + void fillMemBuf(const void *fill, const DataType &fill_type, void *buf, const DataType &buf_type, + const DataSpace &space) const; + // void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& + // space); // removed from 1.8.18 and 1.10.1 + + // Fills a selection in memory with zero + void fillMemBuf(void *buf, const DataType &buf_type, const DataSpace &space) const; + // void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 + + // Gets the creation property list of this dataset. + DSetCreatPropList getCreatePlist() const; + + // Gets the access property list of this dataset. + DSetAccPropList getAccessPlist() const; + + // Returns the address of this dataset in the file. + haddr_t getOffset() const; + + // Gets the dataspace of this dataset. + virtual DataSpace getSpace() const; + + // Determines whether space has been allocated for a dataset. + void getSpaceStatus(H5D_space_status_t &status) const; + + // Returns the amount of storage size required for this dataset. + virtual hsize_t getStorageSize() const; + + // Returns the in memory size of this attribute's data. + virtual size_t getInMemDataSize() const; + + // Returns the number of bytes required to store VL data. + hsize_t getVlenBufSize(const DataType &type, const DataSpace &space) const; + // hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1 + + // Reclaims VL datatype memory buffers. + static void vlenReclaim(const DataType &type, const DataSpace &space, + const DSetMemXferPropList &xfer_plist, void *buf); + static void vlenReclaim(void *buf, const DataType &type, const DataSpace &space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT); + + // Reads the data of this dataset and stores it in the provided buffer. + // The memory and file dataspaces and the transferring property list + // can be defaults. + void read(void *buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, + const DataSpace & file_space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + void read(H5std_string &buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, + const DataSpace & file_space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + + // Writes the buffered data to this dataset. + // The memory and file dataspaces and the transferring property list + // can be defaults. + void write(const void *buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, + const DataSpace & file_space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + void write(const H5std_string &buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, + const DataSpace & file_space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + + // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet + int iterateElems(void *buf, const DataType &type, const DataSpace &space, H5D_operator_t op, + void *op_data = NULL); + + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DataSet"); + } + + // Creates a dataset by way of dereference. + DataSet(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + DataSet(const Attribute &attr, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + + // Default constructor. + DataSet(); + + // Copy constructor - same as the original DataSet. + DataSet(const DataSet &original); + + // Creates a copy of an existing DataSet using its id. + DataSet(const hid_t existing_id); + + // Gets the dataset id. + virtual hid_t getId() const; + + // Destructor: properly terminates access to this dataset. + virtual ~DataSet(); + + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the dataset id. - virtual void p_setId(const hid_t new_id); + // Sets the dataset id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 dataset id + private: + hid_t id; // HDF5 dataset id - // This function contains the common code that is used by - // getTypeClass and various API functions getXxxType - // defined in AbstractDs for generic datatype and specific - // sub-types - virtual hid_t p_get_type() const; + // This function contains the common code that is used by + // getTypeClass and various API functions getXxxType + // defined in AbstractDs for generic datatype and specific + // sub-types + virtual hid_t p_get_type() const; - // Reads variable or fixed len strings from this dataset. - void p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const; - void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const; + // Reads variable or fixed len strings from this dataset. + void p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, + const hid_t xfer_plist_id, H5std_string &strg) const; + void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, + const hid_t xfer_plist_id, H5std_string &strg) const; - // Friend function to set DataSet id. For library use only. - friend void f_DataSet_setId(DataSet* dset, hid_t new_id); + // Friend function to set DataSet id. For library use only. + friend void f_DataSet_setId(DataSet *dset, hid_t new_id); }; // end of DataSet } // namespace H5 diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index e8e5712..47fdbbc 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -33,7 +33,7 @@ using std::endl; // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DataSpace* DataSpace::ALL_ = 0; +DataSpace *DataSpace::ALL_ = 0; //-------------------------------------------------------------------------- // Function: DataSpace::getConstant @@ -45,13 +45,13 @@ DataSpace* DataSpace::ALL_ = 0; // a DataSpaceIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DataSpace* DataSpace::getConstant() +DataSpace * +DataSpace::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -60,8 +60,9 @@ DataSpace* DataSpace::getConstant() if (ALL_ == 0) ALL_ = new DataSpace(H5S_ALL); else - throw DataSpaceIException("DataSpace::getConstant", "DataSpace::getConstant is being invoked on an allocated ALL_"); - return(ALL_); + throw DataSpaceIException("DataSpace::getConstant", + "DataSpace::getConstant is being invoked on an allocated ALL_"); + return (ALL_); } //-------------------------------------------------------------------------- @@ -69,7 +70,8 @@ DataSpace* DataSpace::getConstant() // Purpose: Deletes the constant object that DataSpace::ALL_ points to // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DataSpace::deleteConstants() +void +DataSpace::deleteConstants() { if (ALL_ != 0) delete ALL_; @@ -78,7 +80,7 @@ void DataSpace::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default dataspace. //-------------------------------------------------------------------------- -const DataSpace& DataSpace::ALL = *getConstant(); +const DataSpace &DataSpace::ALL = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -94,8 +96,7 @@ const DataSpace& DataSpace::ALL = *getConstant(); DataSpace::DataSpace(H5S_class_t type) : IdComponent() { id = H5Screate(type); - if (id < 0) - { + if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate failed"); } } @@ -109,11 +110,10 @@ DataSpace::DataSpace(H5S_class_t type) : IdComponent() ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims) : IdComponent() +DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) : IdComponent() { id = H5Screate_simple(rank, dims, maxdims); - if (id < 0) - { + if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed"); } } @@ -137,7 +137,7 @@ DataSpace::DataSpace(const hid_t existing_id) : IdComponent(), id(existing_id) ///\param original - IN: DataSpace object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id) +DataSpace::DataSpace(const DataSpace &original) : IdComponent(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -154,17 +154,18 @@ DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id) // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void DataSpace::copy(const DataSpace& like_space) +void +DataSpace::copy(const DataSpace &like_space) { // If this object has an hdf5 valid id, close it if (id != H5S_ALL) { try { close(); } - catch (Exception& close_error) { - throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); + catch (Exception &close_error) { + throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); } - } // end if + } // end if // call C routine to copy the dataspace id = H5Scopy(like_space.getId()); @@ -184,11 +185,12 @@ void DataSpace::copy(const DataSpace& like_space) // the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace& DataSpace::operator=(const DataSpace& rhs) +DataSpace & +DataSpace::operator=(const DataSpace &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -199,17 +201,16 @@ DataSpace& DataSpace::operator=(const DataSpace& rhs) ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataSpace::isSimple () const +bool +DataSpace::isSimple() const { htri_t simple = H5Sis_simple(id); if (simple > 0) return true; else if (simple == 0) return false; - else - { - throw DataSpaceIException("DataSpace::isSimple", - "H5Sis_simple returns negative value"); + else { + throw DataSpaceIException("DataSpace::isSimple", "H5Sis_simple returns negative value"); } } @@ -225,11 +226,11 @@ bool DataSpace::isSimple () const /// it to be re-defined. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::offsetSimple (const hssize_t* offset) const +void +DataSpace::offsetSimple(const hssize_t *offset) const { herr_t ret_value = H5Soffset_simple(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::offsetSimple", "H5Soffset_simple failed"); } } @@ -244,15 +245,15 @@ void DataSpace::offsetSimple (const hssize_t* offset) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSpace::getSimpleExtentDims (hsize_t *dims, hsize_t *maxdims) const +int +DataSpace::getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims) const { int ndims = H5Sget_simple_extent_dims(id, dims, maxdims); - if (ndims < 0) - { + if (ndims < 0) { throw DataSpaceIException("DataSpace::getSimpleExtentDims", - "H5Sget_simple_extent_dims returns negative number of dimensions"); + "H5Sget_simple_extent_dims returns negative number of dimensions"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -262,15 +263,16 @@ int DataSpace::getSimpleExtentDims (hsize_t *dims, hsize_t *maxdims) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSpace::getSimpleExtentNdims () const +int +DataSpace::getSimpleExtentNdims() const { int ndims = H5Sget_simple_extent_ndims(id); - if (ndims < 0) - { - throw DataSpaceIException("DataSpace::getSimpleExtentNdims", + if (ndims < 0) { + throw DataSpaceIException( + "DataSpace::getSimpleExtentNdims", "H5Sget_simple_extent_ndims returns negative value for dimensionality of the dataspace"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -284,15 +286,16 @@ int DataSpace::getSimpleExtentNdims () const // num_elements = -1 when failure occurs vs. 0 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSimpleExtentNpoints () const +hssize_t +DataSpace::getSimpleExtentNpoints() const { hssize_t num_elements = H5Sget_simple_extent_npoints(id); if (num_elements > -1) - return(num_elements); - else - { + return (num_elements); + else { throw DataSpaceIException("DataSpace::getSimpleExtentNpoints", - "H5Sget_simple_extent_npoints returns negative value for the number of elements in the dataspace"); + "H5Sget_simple_extent_npoints returns negative value for the number of " + "elements in the dataspace"); } } @@ -303,15 +306,15 @@ hssize_t DataSpace::getSimpleExtentNpoints () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5S_class_t DataSpace::getSimpleExtentType () const +H5S_class_t +DataSpace::getSimpleExtentType() const { H5S_class_t class_name = H5Sget_simple_extent_type(id); - if (class_name == H5S_NO_CLASS) - { + if (class_name == H5S_NO_CLASS) { throw DataSpaceIException("DataSpace::getSimpleExtentType", - "H5Sget_simple_extent_type returns H5S_NO_CLASS"); + "H5Sget_simple_extent_type returns H5S_NO_CLASS"); } - return(class_name); + return (class_name); } //-------------------------------------------------------------------------- @@ -321,12 +324,12 @@ H5S_class_t DataSpace::getSimpleExtentType () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::extentCopy (const DataSpace& dest_space) const +void +DataSpace::extentCopy(const DataSpace &dest_space) const { - hid_t dest_space_id = dest_space.getId(); - herr_t ret_value = H5Sextent_copy(dest_space_id, id); - if (ret_value < 0) - { + hid_t dest_space_id = dest_space.getId(); + herr_t ret_value = H5Sextent_copy(dest_space_id, id); + if (ret_value < 0) { throw DataSpaceIException("DataSpace::extentCopy", "H5Sextent_copy failed"); } } @@ -344,7 +347,7 @@ void DataSpace::extentCopy (const DataSpace& dest_space) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSpace::extentCopy(DataSpace& dest_space) const +// void DataSpace::extentCopy(DataSpace& dest_space) const //{ // extentCopy(dest_space); //} @@ -358,12 +361,12 @@ void DataSpace::extentCopy (const DataSpace& dest_space) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size) const +void +DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size) const { herr_t ret_value; ret_value = H5Sset_extent_simple(id, rank, current_size, maximum_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::setExtentSimple", "H5Sset_extent_simple failed"); } } @@ -375,11 +378,11 @@ void DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsi ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::setExtentNone () const +void +DataSpace::setExtentNone() const { herr_t ret_value = H5Sset_extent_none(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::setExtentNone", "H5Sset_extent_none failed"); } } @@ -391,15 +394,16 @@ void DataSpace::setExtentNone () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectNpoints () const +hssize_t +DataSpace::getSelectNpoints() const { hssize_t num_elements = H5Sget_select_npoints(id); - if (num_elements < 0) - { - throw DataSpaceIException("DataSpace::getSelectNpoints", + if (num_elements < 0) { + throw DataSpaceIException( + "DataSpace::getSelectNpoints", "H5Sget_select_npoints returns negative value for number of elements in the dataspace selection"); } - return(num_elements); + return (num_elements); } //-------------------------------------------------------------------------- @@ -409,15 +413,16 @@ hssize_t DataSpace::getSelectNpoints () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectHyperNblocks () const +hssize_t +DataSpace::getSelectHyperNblocks() const { hssize_t num_blocks = H5Sget_select_hyper_nblocks(id); - if (num_blocks < 0) - { - throw DataSpaceIException("DataSpace::getSelectHyperNblocks", + if (num_blocks < 0) { + throw DataSpaceIException( + "DataSpace::getSelectHyperNblocks", "H5Sget_select_hyper_nblocks returns negative value for the number of hyperslab blocks"); } - return(num_blocks); + return (num_blocks); } //-------------------------------------------------------------------------- @@ -429,14 +434,14 @@ hssize_t DataSpace::getSelectHyperNblocks () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const +void +DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const { herr_t ret_value; ret_value = H5Sget_select_hyper_blocklist(id, startblock, numblocks, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::getSelectHyperBlocklist", - "H5Sget_select_hyper_blocklist failed"); + "H5Sget_select_hyper_blocklist failed"); } } @@ -447,15 +452,14 @@ void DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, h ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectElemNpoints () const +hssize_t +DataSpace::getSelectElemNpoints() const { hssize_t num_points = H5Sget_select_elem_npoints(id); - if (num_points < 0) - { - throw DataSpaceIException("DataSpace::getSelectElemNpoints", - "H5Sget_select_elem_npoints failed"); + if (num_points < 0) { + throw DataSpaceIException("DataSpace::getSelectElemNpoints", "H5Sget_select_elem_npoints failed"); } - return(num_points); + return (num_points); } //-------------------------------------------------------------------------- @@ -470,14 +474,13 @@ hssize_t DataSpace::getSelectElemNpoints () const /// H5Sget_select_elem_pointlist in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectElemPointlist (hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const +void +DataSpace::getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const { herr_t ret_value; ret_value = H5Sget_select_elem_pointlist(id, startpoint, numpoints, buf); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::getSelectElemPointlist", - "H5Sget_select_elem_pointlist failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::getSelectElemPointlist", "H5Sget_select_elem_pointlist failed"); } } @@ -493,13 +496,12 @@ void DataSpace::getSelectElemPointlist (hsize_t startpoint, hsize_t numpoints, h /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectBounds (hsize_t* start, hsize_t* end) const +void +DataSpace::getSelectBounds(hsize_t *start, hsize_t *end) const { herr_t ret_value = H5Sget_select_bounds(id, start, end); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::getSelectBounds", - "H5Sget_select_bounds failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::getSelectBounds", "H5Sget_select_bounds failed"); } } @@ -518,14 +520,13 @@ void DataSpace::getSelectBounds (hsize_t* start, hsize_t* end) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectElements (H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const +void +DataSpace::selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const { herr_t ret_value; ret_value = H5Sselect_elements(id, op, num_elements, coord); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectElements", - "H5Sselect_elements failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectElements", "H5Sselect_elements failed"); } } @@ -536,11 +537,11 @@ void DataSpace::selectElements (H5S_seloper_t op, const size_t num_elements, con ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectAll () const +void +DataSpace::selectAll() const { herr_t ret_value = H5Sselect_all(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::selectAll", "H5Sselect_all failed"); } } @@ -552,13 +553,12 @@ void DataSpace::selectAll () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectNone () const +void +DataSpace::selectNone() const { herr_t ret_value = H5Sselect_none(id); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectNone", - "H5Sselect_none failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectNone", "H5Sselect_none failed"); } } @@ -571,17 +571,16 @@ void DataSpace::selectNone () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataSpace::selectValid () const +bool +DataSpace::selectValid() const { htri_t ret_value = H5Sselect_valid(id); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataSpaceIException("DataSpace::selectValid", - "H5Sselect_valid returns negative value"); + else { + throw DataSpaceIException("DataSpace::selectValid", "H5Sselect_valid returns negative value"); } } @@ -599,14 +598,14 @@ bool DataSpace::selectValid () const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride, const hsize_t *block) const +void +DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, + const hsize_t *stride, const hsize_t *block) const { herr_t ret_value; ret_value = H5Sselect_hyperslab(id, op, start, stride, count, block); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectHyperslab", - "H5Sselect_hyperslab failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectHyperslab", "H5Sselect_hyperslab failed"); } } @@ -622,9 +621,10 @@ void DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hs // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataSpace::getId() const +hid_t +DataSpace::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -640,13 +640,14 @@ hid_t DataSpace::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::p_setId(const hid_t new_id) +void +DataSpace::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataSpaceIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -661,14 +662,13 @@ void DataSpace::p_setId(const hid_t new_id) ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataSpace::close() +void +DataSpace::close() { // check if id is a valid hdf5 object id before trying to close it - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Sclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::close", "H5Sclose failed"); } // reset the id @@ -690,9 +690,10 @@ DataSpace::~DataSpace() { try { close(); - } catch (Exception& close_error) { + } + catch (Exception &close_error) { cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index 54c68ac..b5e92bc 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -23,127 +23,132 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP DataSpace : public IdComponent { - public: - ///\brief Default DataSpace objects - static const DataSpace& ALL; + public: + ///\brief Default DataSpace objects + static const DataSpace &ALL; - // Creates a dataspace object given the space type - DataSpace(H5S_class_t type = H5S_SCALAR); + // Creates a dataspace object given the space type + DataSpace(H5S_class_t type = H5S_SCALAR); - // Creates a simple dataspace - DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims = NULL); + // Creates a simple dataspace + DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims = NULL); - // Creates a DataSpace object using an existing dataspace id. - DataSpace(const hid_t space_id); + // Creates a DataSpace object using an existing dataspace id. + DataSpace(const hid_t space_id); - // Copy constructor - same as the original DataSpace. - DataSpace(const DataSpace& original); + // Copy constructor - same as the original DataSpace. + DataSpace(const DataSpace &original); - // Assignment operator - DataSpace& operator=(const DataSpace& rhs); + // Assignment operator + DataSpace &operator=(const DataSpace &rhs); - // Closes this dataspace. - virtual void close(); + // Closes this dataspace. + virtual void close(); - // Makes copy of an existing dataspace. - void copy(const DataSpace& like_space); + // Makes copy of an existing dataspace. + void copy(const DataSpace &like_space); - // Copies the extent of this dataspace. - void extentCopy(const DataSpace& dest_space) const; - // removed from 1.8.18 and 1.10.1 - //void extentCopy(DataSpace& dest_space) const; + // Copies the extent of this dataspace. + void extentCopy(const DataSpace &dest_space) const; + // removed from 1.8.18 and 1.10.1 + // void extentCopy(DataSpace& dest_space) const; - // Gets the bounding box containing the current selection. - void getSelectBounds(hsize_t* start, hsize_t* end) const; + // Gets the bounding box containing the current selection. + void getSelectBounds(hsize_t *start, hsize_t *end) const; - // Gets the number of element points in the current selection. - hssize_t getSelectElemNpoints() const; + // Gets the number of element points in the current selection. + hssize_t getSelectElemNpoints() const; - // Retrieves the list of element points currently selected. - void getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const; + // Retrieves the list of element points currently selected. + void getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const; - // Gets the list of hyperslab blocks currently selected. - void getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const; + // Gets the list of hyperslab blocks currently selected. + void getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const; - // Get number of hyperslab blocks. - hssize_t getSelectHyperNblocks() const; + // Get number of hyperslab blocks. + hssize_t getSelectHyperNblocks() const; - // Gets the number of elements in this dataspace selection. - hssize_t getSelectNpoints() const; + // Gets the number of elements in this dataspace selection. + hssize_t getSelectNpoints() const; - // Retrieves dataspace dimension size and maximum size. - int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims = NULL) const; + // Retrieves dataspace dimension size and maximum size. + int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims = NULL) const; - // Gets the dimensionality of this dataspace. - int getSimpleExtentNdims() const; + // Gets the dimensionality of this dataspace. + int getSimpleExtentNdims() const; - // Gets the number of elements in this dataspace. - // 12/05/00 - changed return type to hssize_t from hsize_t - C API - hssize_t getSimpleExtentNpoints() const; + // Gets the number of elements in this dataspace. + // 12/05/00 - changed return type to hssize_t from hsize_t - C API + hssize_t getSimpleExtentNpoints() const; - // Gets the current class of this dataspace. - H5S_class_t getSimpleExtentType() const; + // Gets the current class of this dataspace. + H5S_class_t getSimpleExtentType() const; - // Determines if this dataspace is a simple one. - bool isSimple() const; + // Determines if this dataspace is a simple one. + bool isSimple() const; - // Sets the offset of this simple dataspace. - void offsetSimple(const hssize_t* offset) const; + // Sets the offset of this simple dataspace. + void offsetSimple(const hssize_t *offset) const; - // Selects the entire dataspace. - void selectAll() const; + // Selects the entire dataspace. + void selectAll() const; - // Selects array elements to be included in the selection for - // this dataspace. - void selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const; + // Selects array elements to be included in the selection for + // this dataspace. + void selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const; - // Selects a hyperslab region to add to the current selected region. - void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride = NULL, const hsize_t *block = NULL) const; + // Selects a hyperslab region to add to the current selected region. + void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, + const hsize_t *stride = NULL, const hsize_t *block = NULL) const; - // Resets the selection region to include no elements. - void selectNone() const; + // Resets the selection region to include no elements. + void selectNone() const; - // Verifies that the selection is within the extent of the dataspace. - bool selectValid() const; + // Verifies that the selection is within the extent of the dataspace. + bool selectValid() const; - // Removes the extent from this dataspace. - void setExtentNone() const; + // Removes the extent from this dataspace. + void setExtentNone() const; - // Sets or resets the size of this dataspace. - void setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL) const; + // Sets or resets the size of this dataspace. + void setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataSpace"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DataSpace"); + } - // Gets the dataspace id. - virtual hid_t getId() const; + // Gets the dataspace id. + virtual hid_t getId() const; - // Deletes the global constant - static void deleteConstants(); + // Deletes the global constant + static void deleteConstants(); - // Destructor: properly terminates access to this dataspace. - virtual ~DataSpace(); + // Destructor: properly terminates access to this dataspace. + virtual ~DataSpace(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Sets the dataspace id. - virtual void p_setId(const hid_t new_id); + protected: + // Sets the dataspace id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 dataspace id + private: + hid_t id; // HDF5 dataspace id #ifndef DOXYGEN_SHOULD_SKIP_THIS - static DataSpace* ALL_; + static DataSpace *ALL_; - // Creates the global constant - static DataSpace* getConstant(); + // Creates the global constant + static DataSpace *getConstant(); - // Friend function to set DataSpace id. For library use only. - friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); + // Friend function to set DataSpace id. For library use only. + friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 0472975..eecce00 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -50,7 +50,9 @@ using std::endl; ///\brief Default constructor: Creates a stub datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType() : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) {} +DataType::DataType() : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) +{ +} //-------------------------------------------------------------------------- // Function: DataType overloaded constructor @@ -82,8 +84,7 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco { // Call C routine to create the new datatype id = H5Tcreate(type_class, size); - if (id < 0) - { + if (id < 0) { throw DataTypeIException("DataType constructor", "H5Tcreate failed"); } } @@ -99,7 +100,8 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), encoded_buf(NULL), buf_size(0) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -118,18 +120,19 @@ DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- - /* DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) +/* DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : +H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) { - id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); + id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } - */ +*/ //-------------------------------------------------------------------------- // Function: DataType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType(const DataType& original) : H5Object(), id(original.id), encoded_buf(NULL), buf_size(0) +DataType::DataType(const DataType &original) : H5Object(), id(original.id), encoded_buf(NULL), buf_size(0) { incRefCount(); // increment number of references to this id } @@ -147,7 +150,7 @@ DataType::DataType(const DataType& original) : H5Object(), id(original.id), enco // unnecessarily and will produce undefined behavior. // -BMR, Apr 2015 //-------------------------------------------------------------------------- -DataType::DataType(const PredType& pred_type) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), buf_size(0) { // Call C routine to copy the datatype id = H5Tcopy(pred_type.getId()); @@ -169,7 +172,7 @@ DataType::DataType(const PredType& pred_type) : H5Object(), encoded_buf(NULL), b // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) { id = p_opentype(loc, dtype_name); } @@ -188,7 +191,8 @@ DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object(), // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const H5std_string &dtype_name) + : H5Object(), encoded_buf(NULL), buf_size(0) { id = p_opentype(loc, dtype_name.c_str()); } @@ -205,13 +209,14 @@ DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Ob // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void DataType::copy(const DataType& like_type) +void +DataType::copy(const DataType &like_type) { // close the current data type before copying like_type to this object try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -230,13 +235,14 @@ void DataType::copy(const DataType& like_type) ///\par Description /// The resulted dataset will be transient and modifiable. //-------------------------------------------------------------------------- -void DataType::copy(const DataSet& dset) +void +DataType::copy(const DataSet &dset) { // close the current data type before copying dset's datatype to this object try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -254,11 +260,11 @@ void DataType::copy(const DataSet& dset) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -hid_t DataType::p_decode() const +hid_t +DataType::p_decode() const { // Make sure that the buffer can be decoded - if (encoded_buf == NULL) - { + if (encoded_buf == NULL) { throw DataTypeIException("DataType::p_decode", "No encoded buffer"); } @@ -266,13 +272,11 @@ hid_t DataType::p_decode() const hid_t encoded_dtype_id = H5Tdecode(encoded_buf); // If H5Tdecode fails, raise exception - if (encoded_dtype_id < 0) - { + if (encoded_dtype_id < 0) { throw DataTypeIException("DataType::p_decode", "H5Tdecode failed"); } - else - { - return(encoded_dtype_id); + else { + return (encoded_dtype_id); } } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -285,7 +289,8 @@ hid_t DataType::p_decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* DataType::decode() const +DataType * +DataType::decode() const { hid_t encoded_dtype_id = H5I_INVALID_HID; try { @@ -296,7 +301,7 @@ DataType* DataType::decode() const } DataType *encoded_dtype = new DataType; encoded_dtype->p_setId(encoded_dtype_id); - return(encoded_dtype); + return (encoded_dtype); } //-------------------------------------------------------------------------- @@ -306,27 +311,24 @@ DataType* DataType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -void DataType::encode() +void +DataType::encode() { // Call H5Tencode passing in null to determine the size of the buffer herr_t ret_value = H5Tencode(id, NULL, &buf_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("DataType::encode", "Failed to get buf_size"); } // Allocate buffer and call C function again to encode - if (buf_size > 0) - { + if (buf_size > 0) { encoded_buf = (unsigned char *)HDcalloc((size_t)1, buf_size); - ret_value = H5Tencode(id, encoded_buf, &buf_size); - if (ret_value < 0) - { + ret_value = H5Tencode(id, encoded_buf, &buf_size); + if (ret_value < 0) { throw DataTypeIException("DataType::encode", "H5Tencode failed"); } } - else - { + else { throw DataTypeIException("DataType::encode", "Failed to allocate buffer for encoding"); } } @@ -339,7 +341,8 @@ void DataType::encode() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -bool DataType::hasBinaryDesc() const +bool +DataType::hasBinaryDesc() const { if (encoded_buf != NULL) return true; @@ -366,13 +369,13 @@ bool DataType::hasBinaryDesc() const // transient datatype. // BMR - Mar, 2015 //-------------------------------------------------------------------------- -DataType& DataType::operator=(const DataType& rhs) +DataType & +DataType::operator=(const DataType &rhs) { - if (this != &rhs) - { + if (this != &rhs) { setId(rhs.id); } - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -384,7 +387,8 @@ DataType& DataType::operator=(const DataType& rhs) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataType::operator==(const DataType& compared_type) const +bool +DataType::operator==(const DataType &compared_type) const { // Call C routine H5Tequal to determines whether two datatype // identifiers refer to the same datatype @@ -393,8 +397,7 @@ bool DataType::operator==(const DataType& compared_type) const return true; else if (ret_value == 0) return false; - else - { + else { throw DataTypeIException(inMemFunc("operator=="), "H5Tequal returns negative value"); } } @@ -408,7 +411,8 @@ bool DataType::operator==(const DataType& compared_type) const ///\exception H5::DataTypeIException // July, 2018 //-------------------------------------------------------------------------- -bool DataType::operator!=(const DataType& compared_type) const +bool +DataType::operator!=(const DataType &compared_type) const { return !operator==(compared_type); } @@ -427,7 +431,8 @@ bool DataType::operator!=(const DataType& compared_type) const // to be commonly used by several overloads of DataType::commit. // BMR - Jan, 2007 //-------------------------------------------------------------------------- -void DataType::p_commit(hid_t loc_id, const char* name) +void +DataType::p_commit(hid_t loc_id, const char *name) { // Call C routine to commit the transient datatype herr_t ret_value = H5Tcommit2(loc_id, name, id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -444,7 +449,8 @@ void DataType::p_commit(hid_t loc_id, const char* name) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jan, 2007 //-------------------------------------------------------------------------- -void DataType::commit(const H5Location& loc, const char* name) +void +DataType::commit(const H5Location &loc, const char *name) { p_commit(loc.getId(), name); } @@ -463,7 +469,7 @@ void DataType::commit(const H5Location& loc, const char* name) // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataType::commit(H5Location& loc, const char* name) +// void DataType::commit(H5Location& loc, const char* name) //{ // p_commit(loc.getId(), name); //} @@ -475,7 +481,8 @@ void DataType::commit(const H5Location& loc, const char* name) /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::commit(const H5Location& loc, const H5std_string& name) +void +DataType::commit(const H5Location &loc, const H5std_string &name) { p_commit(loc.getId(), name.c_str()); } @@ -494,7 +501,7 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataType::commit(H5Location& loc, const H5std_string& name) +// void DataType::commit(H5Location& loc, const H5std_string& name) //{ // p_commit(loc.getId(), name.c_str()); //} @@ -508,7 +515,8 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataType::committed() const +bool +DataType::committed() const { // Call C function to determine if a datatype is a named one htri_t is_committed = H5Tcommitted(id); @@ -516,8 +524,7 @@ bool DataType::committed() const return true; else if (is_committed == 0) return false; - else - { + else { throw DataTypeIException(inMemFunc("committed"), "H5Tcommitted return negative value"); } } @@ -532,15 +539,15 @@ bool DataType::committed() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const +H5T_conv_t +DataType::find(const DataType &dest, H5T_cdata_t **pcdata) const { // Call C routine to find the conversion function H5T_conv_t func = H5Tfind(id, dest.getId(), pcdata); - if (func == NULL) - { + if (func == NULL) { throw DataTypeIException(inMemFunc("find"), "H5Tfind returns a NULL function"); } - return(func); + return (func); } //-------------------------------------------------------------------------- @@ -556,17 +563,18 @@ H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist) const +void +DataType::convert(const DataType &dest, size_t nelmts, void *buf, void *background, + const PropList &plist) const { // Get identifiers for C API - hid_t dest_id = dest.getId(); + hid_t dest_id = dest.getId(); hid_t plist_id = plist.getId(); // Call C routine H5Tconvert to convert the data herr_t ret_value; ret_value = H5Tconvert(id, dest_id, nelmts, buf, background, plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed"); } } @@ -585,12 +593,12 @@ void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *bac /// the entire library is closed. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::lock() const +void +DataType::lock() const { // Call C routine to lock the datatype herr_t ret_value = H5Tlock(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("lock"), "H5Tlock failed"); } } @@ -602,16 +610,16 @@ void DataType::lock() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_class_t DataType::getClass() const +H5T_class_t +DataType::getClass() const { H5T_class_t type_class = H5Tget_class(id); // Return datatype class identifier if successful - if (type_class == H5T_NO_CLASS) - { + if (type_class == H5T_NO_CLASS) { throw DataTypeIException(inMemFunc("getClass"), "H5Tget_class returns H5T_NO_CLASS"); } - return(type_class); + return (type_class); } //-------------------------------------------------------------------------- @@ -621,15 +629,16 @@ H5T_class_t DataType::getClass() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t DataType::getSize() const +size_t +DataType::getSize() const { // Call C routine to get the datatype size size_t type_size = H5Tget_size(id); - if (type_size <= 0) // valid data types are never zero size + if (type_size <= 0) // valid data types are never zero size { throw DataTypeIException(inMemFunc("getSize"), "H5Tget_size returns invalid datatype size"); } - return(type_size); + return (type_size); } //-------------------------------------------------------------------------- @@ -639,7 +648,8 @@ size_t DataType::getSize() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType DataType::getSuper() const +DataType +DataType::getSuper() const { // Call C routine to get the base datatype from which the specified // datatype is derived. @@ -647,14 +657,12 @@ DataType DataType::getSuper() const // If H5Tget_super returns a valid datatype id, create and return // the base type, otherwise, raise exception - if (base_type_id > 0) - { + if (base_type_id > 0) { DataType base_type; base_type.p_setId(base_type_id); - return(base_type); + return (base_type); } - else - { + else { throw DataTypeIException(inMemFunc("getSuper"), "H5Tget_super failed"); } } @@ -675,14 +683,14 @@ DataType DataType::getSuper() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const +void +DataType::registerFunc(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the destination datatype + hid_t dest_id = dest.getId(); // get id of the destination datatype // Call C routine H5Tregister to register the conversion function herr_t ret_value = H5Tregister(pers, name, id, dest_id, func); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("registerFunc"), "H5Tregister failed"); } } @@ -694,7 +702,8 @@ void DataType::registerFunc(H5T_pers_t pers, const char* name, const DataType& d /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const +void +DataType::registerFunc(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const { registerFunc(pers, name.c_str(), dest, func); } @@ -712,14 +721,14 @@ void DataType::registerFunc(H5T_pers_t pers, const H5std_string& name, const Dat ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const +void +DataType::unregister(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the dest datatype for C API + hid_t dest_id = dest.getId(); // get id of the dest datatype for C API // Call C routine H5Tunregister to remove the conversion function herr_t ret_value = H5Tunregister(pers, name, id, dest_id, func); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("unregister"), "H5Tunregister failed"); } } @@ -731,7 +740,8 @@ void DataType::unregister(H5T_pers_t pers, const char* name, const DataType& des /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const +void +DataType::unregister(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const { unregister(pers, name.c_str(), dest, func); } @@ -744,12 +754,12 @@ void DataType::unregister(H5T_pers_t pers, const H5std_string& name, const DataT ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag(const char* tag) const +void +DataType::setTag(const char *tag) const { // Call C routine H5Tset_tag to tag an opaque datatype. herr_t ret_value = H5Tset_tag(id, tag); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setTag"), "H5Tset_tag failed"); } } @@ -761,7 +771,8 @@ void DataType::setTag(const char* tag) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag(const H5std_string& tag) const +void +DataType::setTag(const H5std_string &tag) const { setTag(tag.c_str()); } @@ -773,20 +784,19 @@ void DataType::setTag(const H5std_string& tag) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string DataType::getTag() const +H5std_string +DataType::getTag() const { - char* tag_Cstr = H5Tget_tag(id); + char *tag_Cstr = H5Tget_tag(id); // if the tag C-string returned is not NULL, convert it to C++ string // and return it, otherwise, raise an exception - if (tag_Cstr != NULL) - { + if (tag_Cstr != NULL) { H5std_string tag = H5std_string(tag_Cstr); // C string to string object - H5free_memory(tag_Cstr); // free the C string - return (tag); // return the tag + H5free_memory(tag_Cstr); // free the C string + return (tag); // return the tag } - else - { + else { throw DataTypeIException(inMemFunc("getTag"), "H5Tget_tag returns NULL for tag"); } } @@ -800,17 +810,16 @@ H5std_string DataType::getTag() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -bool DataType::detectClass(H5T_class_t cls) const +bool +DataType::detectClass(H5T_class_t cls) const { htri_t ret_value = H5Tdetect_class(id, cls); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataTypeIException(inMemFunc("detectClass"), - "H5Tdetect_class returns negative value"); + else { + throw DataTypeIException(inMemFunc("detectClass"), "H5Tdetect_class returns negative value"); } } @@ -822,17 +831,16 @@ bool DataType::detectClass(H5T_class_t cls) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - August, 2017 //-------------------------------------------------------------------------- -bool DataType::detectClass(const PredType& pred_type, H5T_class_t cls) +bool +DataType::detectClass(const PredType &pred_type, H5T_class_t cls) { htri_t ret_value = H5Tdetect_class(pred_type.getId(), cls); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataTypeIException("detectClass on PredType", - "H5Tdetect_class returns negative value"); + else { + throw DataTypeIException("detectClass on PredType", "H5Tdetect_class returns negative value"); } } @@ -844,17 +852,16 @@ bool DataType::detectClass(const PredType& pred_type, H5T_class_t cls) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -bool DataType::isVariableStr() const +bool +DataType::isVariableStr() const { htri_t is_varlen_str = H5Tis_variable_str(id); if (is_varlen_str == 1) return true; else if (is_varlen_str == 0) return false; - else - { - throw DataTypeIException(inMemFunc("isVariableStr"), - "H5Tis_variable_str returns negative value"); + else { + throw DataTypeIException(inMemFunc("isVariableStr"), "H5Tis_variable_str returns negative value"); } } @@ -869,18 +876,17 @@ bool DataType::isVariableStr() const // Currently, there is no datatype creation property list class // in the C++ API because there is no associated functionality. //-------------------------------------------------------------------------- -PropList DataType::getCreatePlist() const +PropList +DataType::getCreatePlist() const { hid_t create_plist_id = H5Tget_create_plist(id); - if (create_plist_id < 0) - { - throw DataTypeIException(inMemFunc("getCreatePlist"), - "H5Tget_create_plist returns negative value"); + if (create_plist_id < 0) { + throw DataTypeIException(inMemFunc("getCreatePlist"), "H5Tget_create_plist returns negative value"); } // create and return the DSetCreatPropList object PropList create_plist; f_PropList_setId(&create_plist, create_plist_id); - return(create_plist); + return (create_plist); } //-------------------------------------------------------------------------- @@ -895,9 +901,10 @@ PropList DataType::getCreatePlist() const // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataType::getId() const +hid_t +DataType::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -912,13 +919,14 @@ hid_t DataType::getId() const // This function was introduced in 1.10.1 to be used by the new // XxxType constructors that open a datatype. -BMR, Dec 2016 //-------------------------------------------------------------------------- -hid_t DataType::p_opentype(const H5Location& loc, const char *dtype_name) const +hid_t +DataType::p_opentype(const H5Location &loc, const char *dtype_name) const { // Call C function to open the named datatype at this location hid_t ret_value = H5Topen2(loc.getId(), dtype_name, H5P_DEFAULT); if (ret_value < 0) throw DataTypeIException(inMemFunc("constructor"), "H5Topen2 failed"); - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -933,13 +941,14 @@ hid_t DataType::p_opentype(const H5Location& loc, const char *dtype_name) const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::p_setId(const hid_t new_id) +void +DataType::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -954,21 +963,19 @@ void DataType::p_setId(const hid_t new_id) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataType::close() +void +DataType::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Tclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("close"), "H5Tclose failed"); } // Reset the id id = H5I_INVALID_HID; // Free and reset buffer of encoded object description if it's been used - if (encoded_buf != NULL) - { + if (encoded_buf != NULL) { HDfree(encoded_buf); buf_size = 0; } @@ -995,13 +1002,12 @@ void DataType::close() //-------------------------------------------------------------------------- DataType::~DataType() { - try - { + try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index e4d9e4b..32badfe 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -26,152 +26,159 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP DataType : public H5Object { - public: - // Creates a datatype given its class and size - DataType(const H5T_class_t type_class, size_t size); + public: + // Creates a datatype given its class and size + DataType(const H5T_class_t type_class, size_t size); - // Copy constructor - same as the original DataType. - DataType(const DataType& original); + // Copy constructor - same as the original DataType. + DataType(const DataType &original); - // Creates a copy of a predefined type - DataType(const PredType& pred_type); + // Creates a copy of a predefined type + DataType(const PredType &pred_type); - // Constructors to open a generic named datatype at a given location. - DataType(const H5Location& loc, const char* name); - DataType(const H5Location& loc, const H5std_string& name); + // Constructors to open a generic named datatype at a given location. + DataType(const H5Location &loc, const char *name); + DataType(const H5Location &loc, const H5std_string &name); - // Creates a datatype by way of dereference. - DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); -// DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Creates a datatype by way of dereference. + DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + // DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const + // PropList& plist = PropList::DEFAULT); - // Closes this datatype. - virtual void close(); + // Closes this datatype. + virtual void close(); - // Copies an existing datatype to this datatype object. - void copy(const DataType& like_type); + // Copies an existing datatype to this datatype object. + void copy(const DataType &like_type); - // Copies the datatype of dset to this datatype object. - void copy(const DataSet& dset); + // Copies the datatype of dset to this datatype object. + void copy(const DataSet &dset); - // Returns a DataType instance by decoding the binary object - // description of this datatype. - virtual DataType* decode() const; + // Returns a DataType instance by decoding the binary object + // description of this datatype. + virtual DataType *decode() const; - // Creates a binary object description of this datatype. - void encode(); + // Creates a binary object description of this datatype. + void encode(); - // Returns the datatype class identifier. - H5T_class_t getClass() const; + // Returns the datatype class identifier. + H5T_class_t getClass() const; - // Commits a transient datatype to a file; this datatype becomes - // a named datatype which can be accessed from the location. - void commit(const H5Location& loc, const char* name); - void commit(const H5Location& loc, const H5std_string& name); + // Commits a transient datatype to a file; this datatype becomes + // a named datatype which can be accessed from the location. + void commit(const H5Location &loc, const char *name); + void commit(const H5Location &loc, const H5std_string &name); - // These two overloaded functions are kept for backward compatibility - // only; they missed the const - removed from 1.8.18 and 1.10.1 - //void commit(H5Location& loc, const char* name); - //void commit(H5Location& loc, const H5std_string& name); + // These two overloaded functions are kept for backward compatibility + // only; they missed the const - removed from 1.8.18 and 1.10.1 + // void commit(H5Location& loc, const char* name); + // void commit(H5Location& loc, const H5std_string& name); - // Determines whether this datatype is a named datatype or - // a transient datatype. - bool committed() const; + // Determines whether this datatype is a named datatype or + // a transient datatype. + bool committed() const; - // Finds a conversion function that can handle the conversion - // this datatype to the given datatype, dest. - H5T_conv_t find(const DataType& dest, H5T_cdata_t **pcdata) const; + // Finds a conversion function that can handle the conversion + // this datatype to the given datatype, dest. + H5T_conv_t find(const DataType &dest, H5T_cdata_t **pcdata) const; - // Converts data from between specified datatypes. - void convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const; + // Converts data from between specified datatypes. + void convert(const DataType &dest, size_t nelmts, void *buf, void *background, + const PropList &plist = PropList::DEFAULT) const; - // Assignment operator - DataType& operator=(const DataType& rhs); + // Assignment operator + DataType &operator=(const DataType &rhs); - // Determines whether two datatypes are the same. - bool operator==(const DataType& compared_type) const; + // Determines whether two datatypes are the same. + bool operator==(const DataType &compared_type) const; - // Determines whether two datatypes are not the same. - bool operator!=(const DataType& compared_type) const; + // Determines whether two datatypes are not the same. + bool operator!=(const DataType &compared_type) const; - // Locks a datatype. - void lock() const; + // Locks a datatype. + void lock() const; - // Returns the size of a datatype. - size_t getSize() const; + // Returns the size of a datatype. + size_t getSize() const; - // Returns the base datatype from which a datatype is derived. - // Note: not quite right for specific types yet??? - DataType getSuper() const; + // Returns the base datatype from which a datatype is derived. + // Note: not quite right for specific types yet??? + DataType getSuper() const; - // Registers a conversion function. - void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const; - void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const; + // Registers a conversion function. + void registerFunc(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const; + void registerFunc(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const; - // Removes a conversion function from all conversion paths. - void unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const; - void unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const; + // Removes a conversion function from all conversion paths. + void unregister(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const; + void unregister(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const; - // Tags an opaque datatype. - void setTag(const char* tag) const; - void setTag(const H5std_string& tag) const; + // Tags an opaque datatype. + void setTag(const char *tag) const; + void setTag(const H5std_string &tag) const; - // Gets the tag associated with an opaque datatype. - H5std_string getTag() const; + // Gets the tag associated with an opaque datatype. + H5std_string getTag() const; - // Checks whether this datatype contains (or is) a certain type class. - bool detectClass(H5T_class_t cls) const; - static bool detectClass(const PredType& pred_type, H5T_class_t cls); + // Checks whether this datatype contains (or is) a certain type class. + bool detectClass(H5T_class_t cls) const; + static bool detectClass(const PredType &pred_type, H5T_class_t cls); - // Checks whether this datatype is a variable-length string. - bool isVariableStr() const; + // Checks whether this datatype is a variable-length string. + bool isVariableStr() const; - // Returns a copy of the creation property list of a datatype. - PropList getCreatePlist() const; + // Returns a copy of the creation property list of a datatype. + PropList getCreatePlist() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DataType"); + } - // Creates a copy of an existing DataType using its id - DataType(const hid_t type_id); + // Creates a copy of an existing DataType using its id + DataType(const hid_t type_id); - // Default constructor - DataType(); + // Default constructor + DataType(); - // Determines whether this datatype has a binary object description. - bool hasBinaryDesc() const; + // Determines whether this datatype has a binary object description. + bool hasBinaryDesc() const; - // Gets the datatype id. - virtual hid_t getId() const; + // Gets the datatype id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this datatype. - virtual ~DataType(); + // Destructor: properly terminates access to this datatype. + virtual ~DataType(); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - hid_t id; // HDF5 datatype id + hid_t id; // HDF5 datatype id - // Returns an id of a type by decoding the binary object - // description of this datatype. - hid_t p_decode() const; + // Returns an id of a type by decoding the binary object + // description of this datatype. + hid_t p_decode() const; - // Sets the datatype id. - virtual void p_setId(const hid_t new_id); + // Sets the datatype id. + virtual void p_setId(const hid_t new_id); - // Opens a datatype and returns the id. - hid_t p_opentype(const H5Location& loc, const char* dtype_name) const; + // Opens a datatype and returns the id. + hid_t p_opentype(const H5Location &loc, const char *dtype_name) const; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - // Buffer for binary object description of this datatype, allocated - // in DataType::encode and used in DataType::decode - unsigned char *encoded_buf; - size_t buf_size; + private: + // Buffer for binary object description of this datatype, allocated + // in DataType::encode and used in DataType::decode + unsigned char *encoded_buf; + size_t buf_size; - // Friend function to set DataType id. For library use only. - friend void f_DataType_setId(DataType* dtype, hid_t new_id); + // Friend function to set DataType id. For library use only. + friend void f_DataType_setId(DataType *dtype, hid_t new_id); - void p_commit(hid_t loc_id, const char* name); + void p_commit(hid_t loc_id, const char *name); }; // end of DataType } // namespace H5 diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 79ff100..6cca01a 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -35,7 +35,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetCreatPropList* DSetCreatPropList::DEFAULT_ = 0; +DSetCreatPropList *DSetCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetCreatPropList::getConstant @@ -49,13 +49,13 @@ DSetCreatPropList* DSetCreatPropList::DEFAULT_ = 0; // not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetCreatPropList* DSetCreatPropList::getConstant() +DSetCreatPropList * +DSetCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -64,8 +64,9 @@ DSetCreatPropList* DSetCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetCreatPropList(H5P_DATASET_CREATE); else - throw PropListIException("DSetCreatPropList::getConstant", "DSetCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("DSetCreatPropList::getConstant", + "DSetCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -74,7 +75,8 @@ DSetCreatPropList* DSetCreatPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetCreatPropList::deleteConstants() +void +DSetCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -83,7 +85,7 @@ void DSetCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for dataset creation default property //-------------------------------------------------------------------------- -const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant(); +const DSetCreatPropList &DSetCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -92,7 +94,9 @@ const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub dataset creation property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) {} +DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList copy constructor @@ -100,7 +104,9 @@ DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) {} /// DSetCreatPropList object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList& orig) : ObjCreatPropList(orig) {} +DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList &orig) : ObjCreatPropList(orig) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList overloaded constructor @@ -108,7 +114,9 @@ DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList& orig) : ObjCreatPr /// existing dataset creation property list. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(plist_id) {} +DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList::setChunk @@ -125,11 +133,11 @@ DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(pl /// changed to \c H5D_CHUNKED, if it is not so already. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setChunk(int ndims, const hsize_t* dim) const +void +DSetCreatPropList::setChunk(int ndims, const hsize_t *dim) const { herr_t ret_value = H5Pset_chunk(id, ndims, dim); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetCreatPropList::setChunk", "H5Pset_chunk failed"); } } @@ -143,15 +151,14 @@ void DSetCreatPropList::setChunk(int ndims, const hsize_t* dim) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getChunk(int max_ndims, hsize_t* dim) const +int +DSetCreatPropList::getChunk(int max_ndims, hsize_t *dim) const { int chunk_size = H5Pget_chunk(id, max_ndims, dim); - if (chunk_size < 0) - { - throw PropListIException("DSetCreatPropList::getChunk", - "H5Pget_chunk returns negative chunk size"); + if (chunk_size < 0) { + throw PropListIException("DSetCreatPropList::getChunk", "H5Pget_chunk returns negative chunk size"); } - return(chunk_size); + return (chunk_size); } //-------------------------------------------------------------------------- @@ -164,13 +171,12 @@ int DSetCreatPropList::getChunk(int max_ndims, hsize_t* dim) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setLayout(H5D_layout_t layout) const +void +DSetCreatPropList::setLayout(H5D_layout_t layout) const { herr_t ret_value = H5Pset_layout(id, layout); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setLayout", - "H5Pset_layout failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setLayout", "H5Pset_layout failed"); } } @@ -190,15 +196,14 @@ void DSetCreatPropList::setLayout(H5D_layout_t layout) const ///\par Description // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_layout_t DSetCreatPropList::getLayout() const +H5D_layout_t +DSetCreatPropList::getLayout() const { H5D_layout_t layout = H5Pget_layout(id); - if (layout == H5D_LAYOUT_ERROR) - { - throw PropListIException("DSetCreatPropList::getLayout", - "H5Pget_layout returns H5D_LAYOUT_ERROR"); + if (layout == H5D_LAYOUT_ERROR) { + throw PropListIException("DSetCreatPropList::getLayout", "H5Pget_layout returns H5D_LAYOUT_ERROR"); } - return(layout); + return (layout); } //-------------------------------------------------------------------------- @@ -213,13 +218,12 @@ H5D_layout_t DSetCreatPropList::getLayout() const /// less compression. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setDeflate(int level) const +void +DSetCreatPropList::setDeflate(int level) const { herr_t ret_value = H5Pset_deflate(id, level); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setDeflate", - "H5Pset_deflate failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setDeflate", "H5Pset_deflate failed"); } } @@ -239,13 +243,12 @@ void DSetCreatPropList::setDeflate(int level) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Jan, 2007 //-------------------------------------------------------------------------- -void DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_per_block) const +void +DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_per_block) const { herr_t ret_value = H5Pset_szip(id, options_mask, pixels_per_block); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setSzip", - "H5Pset_szip failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setSzip", "H5Pset_szip failed"); } } @@ -261,13 +264,12 @@ void DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_p /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Apr, 2016 //-------------------------------------------------------------------------- -void DSetCreatPropList::setNbit() const +void +DSetCreatPropList::setNbit() const { herr_t ret_value = H5Pset_nbit(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setNbit", - "H5Pset_nbit failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setNbit", "H5Pset_nbit failed"); } } @@ -288,13 +290,12 @@ void DSetCreatPropList::setNbit() const /// H5Pset_fill_value API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFillValue(const DataType& fvalue_type, const void* value) const +void +DSetCreatPropList::setFillValue(const DataType &fvalue_type, const void *value) const { herr_t ret_value = H5Pset_fill_value(id, fvalue_type.getId(), value); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFillValue", - "H5Pset_fill_value failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFillValue", "H5Pset_fill_value failed"); } } @@ -311,13 +312,12 @@ void DSetCreatPropList::setFillValue(const DataType& fvalue_type, const void* va /// specified by \a fvalue_type. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getFillValue(const DataType& fvalue_type, void* value) const +void +DSetCreatPropList::getFillValue(const DataType &fvalue_type, void *value) const { herr_t ret_value = H5Pget_fill_value(id, fvalue_type.getId(), value); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getFillValue", - "H5Pget_fill_value failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getFillValue", "H5Pget_fill_value failed"); } } @@ -331,14 +331,14 @@ void DSetCreatPropList::getFillValue(const DataType& fvalue_type, void* value) c ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_fill_value_t DSetCreatPropList::isFillValueDefined() const +H5D_fill_value_t +DSetCreatPropList::isFillValueDefined() const { H5D_fill_value_t status; - herr_t ret_value = H5Pfill_value_defined(id, &status); - if (ret_value < 0) - { + herr_t ret_value = H5Pfill_value_defined(id, &status); + if (ret_value < 0) { throw PropListIException("DSetCreatPropList::isFillValueDefined", - "H5Pfill_value_defined returned H5D_FILL_VALUE_ERROR (-1)"); + "H5Pfill_value_defined returned H5D_FILL_VALUE_ERROR (-1)"); } else return (status); @@ -364,14 +364,13 @@ H5D_fill_value_t DSetCreatPropList::isFillValueDefined() const /// and the filter fails then the entire I/O operation fails. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[]) const +void +DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const { herr_t ret_value = H5Pset_filter(id, filter_id, flags, cd_nelmts, cd_values); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFilter", - "H5Pset_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFilter", "H5Pset_filter failed"); } } @@ -385,13 +384,12 @@ void DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, /// deletes all filters if \a filter_id is \c H5Z_FILTER_NONE. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const +void +DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const { herr_t ret_value = H5Premove_filter(id, filter_id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::removeFilter", - "H5Premove_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::removeFilter", "H5Premove_filter failed"); } } @@ -402,16 +400,16 @@ void DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getNfilters() const +int +DSetCreatPropList::getNfilters() const { int num_filters = H5Pget_nfilters(id); - if (num_filters < 0) - { + if (num_filters < 0) { throw PropListIException("DSetCreatPropList::getNfilters", - "H5Pget_nfilters returned negative number of filters"); + "H5Pget_nfilters returned negative number of filters"); } else - return(num_filters); + return (num_filters); } //-------------------------------------------------------------------------- @@ -434,18 +432,18 @@ int DSetCreatPropList::getNfilters() const // of unsigned int, but for backward compatibility, it cannot be // changed. -BMR (2014/04/15) //-------------------------------------------------------------------------- -H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, - unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, - size_t namelen, char name[], unsigned int& filter_config) const +H5Z_filter_t +DSetCreatPropList::getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const { H5Z_filter_t filter_id; - filter_id = H5Pget_filter2(id, filter_number, &flags, &cd_nelmts, - cd_values, namelen, name, &filter_config); + filter_id = + H5Pget_filter2(id, filter_number, &flags, &cd_nelmts, cd_values, namelen, name, &filter_config); if (filter_id == H5Z_FILTER_ERROR) - throw PropListIException("DSetCreatPropList::getFilter", - "H5Pget_filter2 returned H5Z_FILTER_ERROR"); + throw PropListIException("DSetCreatPropList::getFilter", "H5Pget_filter2 returned H5Z_FILTER_ERROR"); else - return(filter_id); + return (filter_id); } //-------------------------------------------------------------------------- @@ -463,15 +461,15 @@ H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, - unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, - size_t namelen, char name[], unsigned int &filter_config) const +void +DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const { - herr_t ret_value = H5Pget_filter_by_id2(id, filter_id, &flags, &cd_nelmts, - cd_values, namelen, name, &filter_config); + herr_t ret_value = + H5Pget_filter_by_id2(id, filter_id, &flags, &cd_nelmts, cd_values, namelen, name, &filter_config); if (ret_value < 0) - throw PropListIException("DSetCreatPropList::getFilterById", - "H5Pget_filter_by_id2 failed"); + throw PropListIException("DSetCreatPropList::getFilterById", "H5Pget_filter_by_id2 failed"); } //-------------------------------------------------------------------------- @@ -495,14 +493,13 @@ void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, /// and the filter fails then the entire I/O operation fails. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int - flags, size_t cd_nelmts, const unsigned int cd_values[]) const +void +DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const { herr_t ret_value = H5Pmodify_filter(id, filter_id, flags, cd_nelmts, cd_values); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::modifyFilter", - "H5Pmodify_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::modifyFilter", "H5Pmodify_filter failed"); } } @@ -515,7 +512,8 @@ void DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DSetCreatPropList::allFiltersAvail() const +bool +DSetCreatPropList::allFiltersAvail() const { htri_t ret_value = H5Pall_filters_avail(id); if (ret_value > 0) @@ -524,7 +522,8 @@ bool DSetCreatPropList::allFiltersAvail() const return false; else // Raise exception when H5Pall_filters_avail returns a negative value { - throw PropListIException("DSetCreatPropList::allFiltersAvail", "H5Pall_filters_avail returned negative value"); + throw PropListIException("DSetCreatPropList::allFiltersAvail", + "H5Pall_filters_avail returned negative value"); } } @@ -538,13 +537,12 @@ bool DSetCreatPropList::allFiltersAvail() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setShuffle() const +void +DSetCreatPropList::setShuffle() const { herr_t ret_value = H5Pset_shuffle(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setShuffle", - "H5Pset_shuffle failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setShuffle", "H5Pset_shuffle failed"); } } @@ -562,14 +560,13 @@ void DSetCreatPropList::setShuffle() const /// \li \c H5D_ALLOC_TIME_INCR // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_alloc_time_t DSetCreatPropList::getAllocTime() const +H5D_alloc_time_t +DSetCreatPropList::getAllocTime() const { H5D_alloc_time_t alloc_time; - herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getAllocTime", - "H5Pget_alloc_time failed"); + herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getAllocTime", "H5Pget_alloc_time failed"); } else return (alloc_time); @@ -586,14 +583,13 @@ H5D_alloc_time_t DSetCreatPropList::getAllocTime() const /// \li \c H5D_FILL_TIME_ALLOC. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_fill_time_t DSetCreatPropList::getFillTime() const +H5D_fill_time_t +DSetCreatPropList::getFillTime() const { H5D_fill_time_t fill_time; - herr_t ret_value = H5Pget_fill_time(id, &fill_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getFillTime", - "H5Pget_fill_time failed"); + herr_t ret_value = H5Pget_fill_time(id, &fill_time); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getFillTime", "H5Pget_fill_time failed"); } else return (fill_time); @@ -612,13 +608,12 @@ H5D_fill_time_t DSetCreatPropList::getFillTime() const /// \li \c H5D_ALLOC_TIME_INCR // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const +void +DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const { herr_t ret_value = H5Pset_alloc_time(id, alloc_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setAllocTime", - "H5Pset_alloc_time failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setAllocTime", "H5Pset_alloc_time failed"); } } @@ -633,13 +628,12 @@ void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const /// \li \c H5D_FILL_TIME_ALLOC. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const +void +DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const { herr_t ret_value = H5Pset_fill_time(id, fill_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFillTime", - "H5Pset_fill_time failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFillTime", "H5Pset_fill_time failed"); } } @@ -650,13 +644,12 @@ void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFletcher32() const +void +DSetCreatPropList::setFletcher32() const { herr_t ret_value = H5Pset_fletcher32(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFletcher32", - "H5Pset_fletcher32 failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFletcher32", "H5Pset_fletcher32 failed"); } } @@ -676,13 +669,12 @@ void DSetCreatPropList::setFletcher32() const /// the extending). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setExternal(const char* name, off_t offset, hsize_t size) const +void +DSetCreatPropList::setExternal(const char *name, off_t offset, hsize_t size) const { herr_t ret_value = H5Pset_external(id, name, offset, size); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setExternal", - "H5Pset_external failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setExternal", "H5Pset_external failed"); } } @@ -693,16 +685,16 @@ void DSetCreatPropList::setExternal(const char* name, off_t offset, hsize_t size ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getExternalCount() const +int +DSetCreatPropList::getExternalCount() const { int num_ext_files = H5Pget_external_count(id); - if (num_ext_files < 0) - { + if (num_ext_files < 0) { throw PropListIException("DSetCreatPropList::getExternalCount", - "H5Pget_external_count returns negative number of external files"); + "H5Pget_external_count returns negative number of external files"); } else - return(num_ext_files); + return (num_ext_files); } //-------------------------------------------------------------------------- @@ -727,13 +719,12 @@ int DSetCreatPropList::getExternalCount() const /// will not be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size) const +void +DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char *name, off_t &offset, hsize_t &size) const { herr_t ret_value = H5Pget_external(id, idx, name_size, name, &offset, &size); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getExternal", - "H5Pget_external failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getExternal", "H5Pget_external failed"); } } @@ -755,13 +746,13 @@ void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char* name, /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Mar, 2017 //-------------------------------------------------------------------------- -void DSetCreatPropList::setVirtual(const DataSpace& vspace, const char *src_fname, const char *src_dsname, const DataSpace& sspace) const +void +DSetCreatPropList::setVirtual(const DataSpace &vspace, const char *src_fname, const char *src_dsname, + const DataSpace &sspace) const { herr_t ret_value = H5Pset_virtual(id, vspace.getId(), src_fname, src_dsname, sspace.getId()); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setVirtual", - "H5Pset_virtual failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setVirtual", "H5Pset_virtual failed"); } } @@ -783,7 +774,9 @@ void DSetCreatPropList::setVirtual(const DataSpace& vspace, const char *src_fnam /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Mar, 2017 //-------------------------------------------------------------------------- -void DSetCreatPropList::setVirtual(const DataSpace& vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace& sspace) const +void +DSetCreatPropList::setVirtual(const DataSpace &vspace, const H5std_string src_fname, + const H5std_string src_dsname, const DataSpace &sspace) const { setVirtual(vspace, src_fname.c_str(), src_dsname.c_str(), sspace); } @@ -793,6 +786,8 @@ void DSetCreatPropList::setVirtual(const DataSpace& vspace, const H5std_string s ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::~DSetCreatPropList() {} +DSetCreatPropList::~DSetCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 9f54e8d..e73ec32 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -27,121 +27,132 @@ class DataSpace; */ // Inheritance: ObjCreatPropList -> PropList -> IdComponent class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { - public: - ///\brief Default dataset creation property list. - static const DSetCreatPropList& DEFAULT; + public: + ///\brief Default dataset creation property list. + static const DSetCreatPropList &DEFAULT; - // Creates a dataset creation property list. - DSetCreatPropList(); + // Creates a dataset creation property list. + DSetCreatPropList(); - // Queries whether all the filters set in this property list are - // available currently. - bool allFiltersAvail() const; + // Queries whether all the filters set in this property list are + // available currently. + bool allFiltersAvail() const; - // Get space allocation time for this property. - H5D_alloc_time_t getAllocTime() const; + // Get space allocation time for this property. + H5D_alloc_time_t getAllocTime() const; - // Set space allocation time for dataset during creation. - void setAllocTime(H5D_alloc_time_t alloc_time) const; + // Set space allocation time for dataset during creation. + void setAllocTime(H5D_alloc_time_t alloc_time) const; - // Retrieves the size of the chunks used to store a chunked layout dataset. - int getChunk(int max_ndims, hsize_t* dim) const; + // Retrieves the size of the chunks used to store a chunked layout dataset. + int getChunk(int max_ndims, hsize_t *dim) const; - // Sets the size of the chunks used to store a chunked layout dataset. - void setChunk(int ndims, const hsize_t* dim) const; + // Sets the size of the chunks used to store a chunked layout dataset. + void setChunk(int ndims, const hsize_t *dim) const; - // Returns information about an external file. - void getExternal(unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size) const; + // Returns information about an external file. + void getExternal(unsigned idx, size_t name_size, char *name, off_t &offset, hsize_t &size) const; - // Returns the number of external files for a dataset. - int getExternalCount() const; + // Returns the number of external files for a dataset. + int getExternalCount() const; - // Gets fill value writing time. - H5D_fill_time_t getFillTime() const; + // Gets fill value writing time. + H5D_fill_time_t getFillTime() const; - // Sets fill value writing time for dataset. - void setFillTime(H5D_fill_time_t fill_time) const; + // Sets fill value writing time for dataset. + void setFillTime(H5D_fill_time_t fill_time) const; - // Retrieves a dataset fill value. - void getFillValue(const DataType& fvalue_type, void* value) const; + // Retrieves a dataset fill value. + void getFillValue(const DataType &fvalue_type, void *value) const; - // Sets a dataset fill value. - void setFillValue(const DataType& fvalue_type, const void* value) const; + // Sets a dataset fill value. + void setFillValue(const DataType &fvalue_type, const void *value) const; - // Returns information about a filter in a pipeline. - H5Z_filter_t getFilter(int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + // Returns information about a filter in a pipeline. + H5Z_filter_t getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, unsigned int *cd_values, + size_t namelen, char name[], unsigned int &filter_config) const; - // Returns information about a filter in a pipeline given the filter id. - void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + // Returns information about a filter in a pipeline given the filter id. + void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const; - // Gets the layout of the raw data storage of the data that uses this - // property list. - H5D_layout_t getLayout() const; + // Gets the layout of the raw data storage of the data that uses this + // property list. + H5D_layout_t getLayout() const; - // Sets the type of storage used to store the raw data for the - // dataset that uses this property list. - void setLayout(H5D_layout_t layout) const; + // Sets the type of storage used to store the raw data for the + // dataset that uses this property list. + void setLayout(H5D_layout_t layout) const; - // Returns the number of filters in the pipeline. - int getNfilters() const; + // Returns the number of filters in the pipeline. + int getNfilters() const; - // Checks if fill value has been defined for this property. - H5D_fill_value_t isFillValueDefined() const; + // Checks if fill value has been defined for this property. + H5D_fill_value_t isFillValueDefined() const; - // Modifies the specified filter. - void modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[]) const; + // Modifies the specified filter. + void modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const; - // Remove one or all filters from the filter pipeline. - void removeFilter(H5Z_filter_t filter_id) const; + // Remove one or all filters from the filter pipeline. + void removeFilter(H5Z_filter_t filter_id) const; - // Sets compression method and compression level. - void setDeflate(int level) const; + // Sets compression method and compression level. + void setDeflate(int level) const; - // Adds an external file to the list of external files. - void setExternal(const char* name, off_t offset, hsize_t size) const; + // Adds an external file to the list of external files. + void setExternal(const char *name, off_t offset, hsize_t size) const; - // Adds a filter to the filter pipeline. - void setFilter(H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0, const unsigned int cd_values[] = NULL) const; + // Adds a filter to the filter pipeline. + void setFilter(H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0, + const unsigned int cd_values[] = NULL) const; - // Sets Fletcher32 checksum of EDC for this property list. - void setFletcher32() const; + // Sets Fletcher32 checksum of EDC for this property list. + void setFletcher32() const; - // Sets method of the shuffle filter. - void setShuffle() const; + // Sets method of the shuffle filter. + void setShuffle() const; - // Sets SZIP compression method. - void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; + // Sets SZIP compression method. + void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; - // Sets N-bit compression method. - void setNbit() const; + // Sets N-bit compression method. + void setNbit() const; - // Maps elements of a virtual dataset to elements of the source dataset. - void setVirtual(const DataSpace& vspace, const char *src_fname, const char *src_dsname, const DataSpace& sspace) const; - void setVirtual(const DataSpace& vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace& sspace) const; + // Maps elements of a virtual dataset to elements of the source dataset. + void setVirtual(const DataSpace &vspace, const char *src_fname, const char *src_dsname, + const DataSpace &sspace) const; + void setVirtual(const DataSpace &vspace, const H5std_string src_fname, const H5std_string src_dsname, + const DataSpace &sspace) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetCreatPropList"); + } - // Copy constructor - same as the original DSetCreatPropList. - DSetCreatPropList(const DSetCreatPropList& orig); + // Copy constructor - same as the original DSetCreatPropList. + DSetCreatPropList(const DSetCreatPropList &orig); - // Creates a copy of an existing dataset creation property list - // using the property list id. - DSetCreatPropList(const hid_t plist_id); + // Creates a copy of an existing dataset creation property list + // using the property list id. + DSetCreatPropList(const hid_t plist_id); - // Noop destructor. - virtual ~DSetCreatPropList(); + // Noop destructor. + virtual ~DSetCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetCreatPropList* DEFAULT_; + private: + static DSetCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 9cc6961..ed7df9a 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -13,7 +13,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -28,7 +28,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetMemXferPropList* DSetMemXferPropList::DEFAULT_ = 0; +DSetMemXferPropList *DSetMemXferPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetMemXferPropList::getConstant @@ -42,13 +42,13 @@ DSetMemXferPropList* DSetMemXferPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetMemXferPropList* DSetMemXferPropList::getConstant() +DSetMemXferPropList * +DSetMemXferPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -57,8 +57,10 @@ DSetMemXferPropList* DSetMemXferPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetMemXferPropList(H5P_DATASET_XFER); else - throw PropListIException("DSetMemXferPropList::getConstant", "DSetMemXferPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException( + "DSetMemXferPropList::getConstant", + "DSetMemXferPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -67,7 +69,8 @@ DSetMemXferPropList* DSetMemXferPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetMemXferPropList::deleteConstants() +void +DSetMemXferPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -76,7 +79,7 @@ void DSetMemXferPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default dataset memory and transfer property list. //-------------------------------------------------------------------------- -const DSetMemXferPropList& DSetMemXferPropList::DEFAULT = *getConstant(); +const DSetMemXferPropList &DSetMemXferPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -86,7 +89,9 @@ const DSetMemXferPropList& DSetMemXferPropList::DEFAULT = *getConstant(); /// transfer property list object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) {} +DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) +{ +} //-------------------------------------------------------------------------- // Function DSetMemXferPropList constructor @@ -94,7 +99,7 @@ DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) {} /// expression. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const char* exp) : PropList(H5P_DATASET_XFER) +DSetMemXferPropList::DSetMemXferPropList(const char *exp) : PropList(H5P_DATASET_XFER) { setDataTransform(exp); } @@ -107,7 +112,9 @@ DSetMemXferPropList::DSetMemXferPropList(const char* exp) : PropList(H5P_DATASET /// list object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList& original) : PropList(original ) {} +DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function DSetMemXferPropList overloaded constructor @@ -117,7 +124,9 @@ DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList& original) : /// property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_id) {} +DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetMemXferPropList::setBuffer @@ -128,13 +137,12 @@ DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setBuffer(size_t size, void* tconv, void* bkg) const +void +DSetMemXferPropList::setBuffer(size_t size, void *tconv, void *bkg) const { herr_t ret_value = H5Pset_buffer(id, size, tconv, bkg); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setBuffer", - "H5Pset_buffer failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setBuffer", "H5Pset_buffer failed"); } } @@ -147,15 +155,15 @@ void DSetMemXferPropList::setBuffer(size_t size, void* tconv, void* bkg) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t DSetMemXferPropList::getBuffer(void** tconv, void** bkg) const +size_t +DSetMemXferPropList::getBuffer(void **tconv, void **bkg) const { size_t buffer_size = H5Pget_buffer(id, tconv, bkg); - if(buffer_size == 0) - { + if (buffer_size == 0) { throw PropListIException("DSetMemXferPropList::getBuffer", - "H5Pget_buffer returned 0 for buffer size - failure"); + "H5Pget_buffer returned 0 for buffer size - failure"); } - return(buffer_size); + return (buffer_size); } //-------------------------------------------------------------------------- @@ -165,13 +173,12 @@ size_t DSetMemXferPropList::getBuffer(void** tconv, void** bkg) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setPreserve(bool status) const +void +DSetMemXferPropList::setPreserve(bool status) const { - herr_t ret_value = H5Pset_preserve(id, (hbool_t) status); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setPreserve", - "H5Pset_preserve failed"); + herr_t ret_value = H5Pset_preserve(id, (hbool_t)status); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setPreserve", "H5Pset_preserve failed"); } } @@ -182,17 +189,17 @@ void DSetMemXferPropList::setPreserve(bool status) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DSetMemXferPropList::getPreserve() const +bool +DSetMemXferPropList::getPreserve() const { int ret_value = H5Pget_preserve(id); - if(ret_value > 0) + if (ret_value > 0) return true; - else if(ret_value == 0) + else if (ret_value == 0) return false; - else - { + else { throw PropListIException("DSetMemXferPropList::getPreserve", - "H5Pget_preserve returned negative value for status"); + "H5Pget_preserve returned negative value for status"); } } @@ -205,13 +212,12 @@ bool DSetMemXferPropList::getPreserve() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setBtreeRatios(double left, double middle, double right) const +void +DSetMemXferPropList::setBtreeRatios(double left, double middle, double right) const { herr_t ret_value = H5Pset_btree_ratios(id, left, middle, right); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setBtreeRatios", - "H5Pset_btree_ratios failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setBtreeRatios", "H5Pset_btree_ratios failed"); } } @@ -224,13 +230,12 @@ void DSetMemXferPropList::setBtreeRatios(double left, double middle, double righ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getBtreeRatios(double& left, double& middle, double& right) const +void +DSetMemXferPropList::getBtreeRatios(double &left, double &middle, double &right) const { herr_t ret_value = H5Pget_btree_ratios(id, &left, &middle, &right); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getBtreeRatios", - "H5Pget_btree_ratios failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getBtreeRatios", "H5Pget_btree_ratios failed"); } } @@ -241,13 +246,12 @@ void DSetMemXferPropList::getBtreeRatios(double& left, double& middle, double& r ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setDataTransform(const char* expression) const +void +DSetMemXferPropList::setDataTransform(const char *expression) const { herr_t ret_value = H5Pset_data_transform(id, expression); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setDataTransform", - "H5Pset_data_transform failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setDataTransform", "H5Pset_data_transform failed"); } } @@ -259,7 +263,8 @@ void DSetMemXferPropList::setDataTransform(const char* expression) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setDataTransform(const H5std_string& expression) const +void +DSetMemXferPropList::setDataTransform(const H5std_string &expression) const { setDataTransform(expression.c_str()); } @@ -273,7 +278,8 @@ void DSetMemXferPropList::setDataTransform(const H5std_string& expression) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const +ssize_t +DSetMemXferPropList::getDataTransform(char *exp, size_t buf_size) const { // H5Pget_data_transform will get buf_size characters of the expression // including the null terminator @@ -281,10 +287,8 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const exp_len = H5Pget_data_transform(id, exp, buf_size); // H5Pget_data_transform returns a negative value, raise an exception - if (exp_len < 0) - { - throw PropListIException("DSetMemXferPropList::getDataTransform", - "H5Pget_data_transform failed"); + if (exp_len < 0) { + throw PropListIException("DSetMemXferPropList::getDataTransform", "H5Pget_data_transform failed"); } // H5Pget_data_transform will put a null terminator at the end of the @@ -292,7 +296,7 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const // of the buffer. // Return the expression length, which might be different from buf_size - return(exp_len); + return (exp_len); } //-------------------------------------------------------------------------- @@ -303,7 +307,8 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5std_string DSetMemXferPropList::getDataTransform() const +H5std_string +DSetMemXferPropList::getDataTransform() const { // Initialize string to "", so that if there is no expression, the returned // string will be empty @@ -313,29 +318,27 @@ H5std_string DSetMemXferPropList::getDataTransform() const ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0); // If H5Pget_data_transform returns a negative value, raise an exception - if (exp_len < 0) - { + if (exp_len < 0) { throw PropListIException("DSetMemXferPropList::getDataTransform", "H5Pget_data_transform failed"); } // If expression exists, calls C routine again to get it - else if (exp_len > 0) - { + else if (exp_len > 0) { // Temporary buffer for char* expression - char* exp_C = new char[exp_len+1]; - HDmemset(exp_C, 0, exp_len+1); // clear buffer + char *exp_C = new char[exp_len + 1]; + HDmemset(exp_C, 0, exp_len + 1); // clear buffer // Used overloaded function - exp_len = getDataTransform(exp_C, exp_len+1); + exp_len = getDataTransform(exp_C, exp_len + 1); // Convert the C expression to return expression = exp_C; // Clean up resource - delete []exp_C; + delete[] exp_C; } // Return the string expression - return(expression); + return (expression); } //-------------------------------------------------------------------------- @@ -347,13 +350,12 @@ H5std_string DSetMemXferPropList::getDataTransform() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const +void +DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const { herr_t ret_value = H5Pset_type_conv_cb(id, op, user_data); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setTypeConvCB", - "H5Pset_type_conv_cb failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setTypeConvCB", "H5Pset_type_conv_cb failed"); } } @@ -365,13 +367,12 @@ void DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_da ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const +void +DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const { herr_t ret_value = H5Pget_type_conv_cb(id, op, user_data); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getTypeConvCB", - "H5Pget_type_conv_cb failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getTypeConvCB", "H5Pget_type_conv_cb failed"); } } @@ -385,14 +386,13 @@ void DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void* alloc_info, H5MM_free_t free_func, void* free_info) const +void +DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, + void *free_info) const { - herr_t ret_value = H5Pset_vlen_mem_manager(id, alloc_func, alloc_info, - free_func, free_info); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setVlenMemManager", - "H5Pset_vlen_mem_manager failed"); + herr_t ret_value = H5Pset_vlen_mem_manager(id, alloc_func, alloc_info, free_func, free_info); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setVlenMemManager", "H5Pset_vlen_mem_manager failed"); } } @@ -404,9 +404,10 @@ void DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void* al ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setVlenMemManager() const +void +DSetMemXferPropList::setVlenMemManager() const { - setVlenMemManager(NULL, NULL, NULL, NULL); + setVlenMemManager(NULL, NULL, NULL, NULL); } //-------------------------------------------------------------------------- @@ -419,13 +420,13 @@ void DSetMemXferPropList::setVlenMemManager() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t& alloc_func, void** alloc_info, H5MM_free_t& free_func, void** free_info) const +void +DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t &alloc_func, void **alloc_info, H5MM_free_t &free_func, + void **free_info) const { herr_t ret_value = H5Pget_vlen_mem_manager(id, &alloc_func, alloc_info, &free_func, free_info); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getVlenMemManager", - "H5Pget_vlen_mem_manager failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getVlenMemManager", "H5Pget_vlen_mem_manager failed"); } } @@ -439,13 +440,13 @@ void DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t& alloc_func, void** /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const +void +DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const { herr_t ret_value = H5Pset_small_data_block_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setSmallDataBlockSize", - "H5Pset_small_data_block_size failed"); + "H5Pset_small_data_block_size failed"); } } @@ -456,16 +457,16 @@ void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t DSetMemXferPropList::getSmallDataBlockSize() const +hsize_t +DSetMemXferPropList::getSmallDataBlockSize() const { hsize_t size; - herr_t ret_value = H5Pget_small_data_block_size(id, &size); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_small_data_block_size(id, &size); + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::getSmallDataBlockSize", - "H5Pget_small_data_block_size failed"); + "H5Pget_small_data_block_size failed"); } - return(size); + return (size); } //-------------------------------------------------------------------------- @@ -478,13 +479,13 @@ hsize_t DSetMemXferPropList::getSmallDataBlockSize() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const +void +DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const { herr_t ret_value = H5Pset_hyper_vector_size(id, vector_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setHyperVectorSize", - "H5Pset_hyper_vector_size failed"); + "H5Pset_hyper_vector_size failed"); } } @@ -496,16 +497,16 @@ void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t DSetMemXferPropList::getHyperVectorSize() const +size_t +DSetMemXferPropList::getHyperVectorSize() const { size_t vector_size; herr_t ret_value = H5Pget_hyper_vector_size(id, &vector_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::getHyperVectorSize", - "H5Pget_hyper_vector_size failed"); + "H5Pget_hyper_vector_size failed"); } - return(vector_size); + return (vector_size); } //-------------------------------------------------------------------------- @@ -526,13 +527,12 @@ size_t DSetMemXferPropList::getHyperVectorSize() const /// \li \c H5Z_DISABLE_EDC // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const +void +DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const { herr_t ret_value = H5Pset_edc_check(id, check); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setEDCCheck", - "H5Pset_edc_check failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setEDCCheck", "H5Pset_edc_check failed"); } } @@ -543,15 +543,14 @@ void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const +H5Z_EDC_t +DSetMemXferPropList::getEDCCheck() const { H5Z_EDC_t check = H5Pget_edc_check(id); - if (check < 0) - { - throw PropListIException("DSetMemXferPropList::getEDCCheck", - "H5Pget_edc_check failed"); + if (check < 0) { + throw PropListIException("DSetMemXferPropList::getEDCCheck", "H5Pget_edc_check failed"); } - return(check); + return (check); } //-------------------------------------------------------------------------- @@ -559,7 +558,8 @@ H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::~DSetMemXferPropList() {} - -} // end namespace +DSetMemXferPropList::~DSetMemXferPropList() +{ +} +} // namespace H5 diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index e53a03b..59ece6f 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -23,105 +23,108 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP DSetMemXferPropList : public PropList { - public: - ///\brief Default dataset memory and transfer property list. - static const DSetMemXferPropList& DEFAULT; + public: + ///\brief Default dataset memory and transfer property list. + static const DSetMemXferPropList &DEFAULT; - // Creates a dataset memory and transfer property list. - DSetMemXferPropList(); + // Creates a dataset memory and transfer property list. + DSetMemXferPropList(); - // Creates a dataset transform property list. - DSetMemXferPropList(const char* expression); + // Creates a dataset transform property list. + DSetMemXferPropList(const char *expression); - // Sets type conversion and background buffers. - void setBuffer(size_t size, void* tconv, void* bkg) const; + // Sets type conversion and background buffers. + void setBuffer(size_t size, void *tconv, void *bkg) const; - // Reads buffer settings. - size_t getBuffer(void** tconv, void** bkg) const; + // Reads buffer settings. + size_t getBuffer(void **tconv, void **bkg) const; - // Sets B-tree split ratios for a dataset transfer property list. - void setBtreeRatios(double left, double middle, double right) const; + // Sets B-tree split ratios for a dataset transfer property list. + void setBtreeRatios(double left, double middle, double right) const; - // Gets B-tree split ratios for a dataset transfer property list. - void getBtreeRatios(double& left, double& middle, double& right) const; + // Gets B-tree split ratios for a dataset transfer property list. + void getBtreeRatios(double &left, double &middle, double &right) const; - // Sets data transform expression. - void setDataTransform(const char* expression) const; - void setDataTransform(const H5std_string& expression) const; + // Sets data transform expression. + void setDataTransform(const char *expression) const; + void setDataTransform(const H5std_string &expression) const; - // Gets data transform expression. - ssize_t getDataTransform(char* exp, size_t buf_size=0) const; - H5std_string getDataTransform() const; + // Gets data transform expression. + ssize_t getDataTransform(char *exp, size_t buf_size = 0) const; + H5std_string getDataTransform() const; - // Sets the dataset transfer property list status to TRUE or FALSE. - void setPreserve(bool status) const; + // Sets the dataset transfer property list status to TRUE or FALSE. + void setPreserve(bool status) const; - // Checks status of the dataset transfer property list. - bool getPreserve() const; + // Checks status of the dataset transfer property list. + bool getPreserve() const; - // Sets an exception handling callback for datatype conversion. - void setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const; + // Sets an exception handling callback for datatype conversion. + void setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const; - // Gets the exception handling callback for datatype conversion. - void getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const; + // Gets the exception handling callback for datatype conversion. + void getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const; - // Sets the memory manager for variable-length datatype - // allocation in H5Dread and H5Treclaim. - void setVlenMemManager(H5MM_allocate_t alloc, void* alloc_info, - H5MM_free_t free, void* free_info) const; + // Sets the memory manager for variable-length datatype + // allocation in H5Dread and H5Treclaim. + void setVlenMemManager(H5MM_allocate_t alloc, void *alloc_info, H5MM_free_t free, void *free_info) const; - // alloc and free are set to NULL, indicating that system - // malloc and free are to be used. - void setVlenMemManager() const; + // alloc and free are set to NULL, indicating that system + // malloc and free are to be used. + void setVlenMemManager() const; - // Gets the memory manager for variable-length datatype - // allocation in H5Dread and H5Treclaim. - void getVlenMemManager(H5MM_allocate_t& alloc, void** alloc_info, - H5MM_free_t& free, void** free_info) const; + // Gets the memory manager for variable-length datatype + // allocation in H5Dread and H5Treclaim. + void getVlenMemManager(H5MM_allocate_t &alloc, void **alloc_info, H5MM_free_t &free, + void **free_info) const; - // Sets the size of a contiguous block reserved for small data. - void setSmallDataBlockSize(hsize_t size) const; + // Sets the size of a contiguous block reserved for small data. + void setSmallDataBlockSize(hsize_t size) const; - // Returns the current small data block size setting. - hsize_t getSmallDataBlockSize() const; + // Returns the current small data block size setting. + hsize_t getSmallDataBlockSize() const; - // Sets number of I/O vectors to be read/written in hyperslab I/O. - void setHyperVectorSize(size_t vector_size) const; + // Sets number of I/O vectors to be read/written in hyperslab I/O. + void setHyperVectorSize(size_t vector_size) const; - // Returns the number of I/O vectors to be read/written in - // hyperslab I/O. - size_t getHyperVectorSize() const; + // Returns the number of I/O vectors to be read/written in + // hyperslab I/O. + size_t getHyperVectorSize() const; - // Enables or disables error-detecting for a dataset reading - // process. - void setEDCCheck(H5Z_EDC_t check) const; + // Enables or disables error-detecting for a dataset reading + // process. + void setEDCCheck(H5Z_EDC_t check) const; - // Determines whether error-detection is enabled for dataset reads. - H5Z_EDC_t getEDCCheck() const; + // Determines whether error-detection is enabled for dataset reads. + H5Z_EDC_t getEDCCheck() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetMemXferPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetMemXferPropList"); + } - // Copy constructor - same as the original DSetMemXferPropList. - DSetMemXferPropList(const DSetMemXferPropList& orig); + // Copy constructor - same as the original DSetMemXferPropList. + DSetMemXferPropList(const DSetMemXferPropList &orig); - // Creates a copy of an existing dataset memory and transfer - // property list using the property list id. - DSetMemXferPropList(const hid_t plist_id); + // Creates a copy of an existing dataset memory and transfer + // property list using the property list id. + DSetMemXferPropList(const hid_t plist_id); - // Noop destructor - virtual ~DSetMemXferPropList(); + // Noop destructor + virtual ~DSetMemXferPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetMemXferPropList* DEFAULT_; + private: + static DSetMemXferPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetMemXferPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetMemXferPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index f9adc47..a034a24 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -13,7 +13,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -41,7 +41,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType() : DataType() {} +EnumType::EnumType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -50,14 +52,18 @@ EnumType::EnumType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const hid_t existing_id) : DataType( existing_id ) {} +EnumType::EnumType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: EnumType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const EnumType& original) : DataType( original ) {} +EnumType::EnumType(const EnumType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -69,7 +75,9 @@ EnumType::EnumType(const EnumType& original) : DataType( original ) {} // the enum datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(size_t size) : DataType( H5T_ENUM, size ) {} +EnumType::EnumType(size_t size) : DataType(H5T_ENUM, size) +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -78,14 +86,13 @@ EnumType::EnumType(size_t size) : DataType( H5T_ENUM, size ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const DataSet& dataset) : DataType() +EnumType::EnumType(const DataSet &dataset) : DataType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); // If the datatype id is not valid, throw an exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("EnumType constructor", "H5Dget_type failed"); } } @@ -97,14 +104,13 @@ EnumType::EnumType(const DataSet& dataset) : DataType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const IntType& data_type) : DataType() +EnumType::EnumType(const IntType &data_type) : DataType() { // Calls C function H5Tenum_create to get the id of the datatype id = H5Tenum_create(data_type.getId()); // If the datatype id is not valid, throw an exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("EnumType constructor", "H5Tenum_create failed"); } } @@ -123,7 +129,7 @@ EnumType::EnumType(const IntType& data_type) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -EnumType::EnumType(const H5Location& loc, const char *dtype_name) : DataType() +EnumType::EnumType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -142,7 +148,7 @@ EnumType::EnumType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -EnumType::EnumType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +EnumType::EnumType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -155,7 +161,8 @@ EnumType::EnumType(const H5Location& loc, const H5std_string& dtype_name) : Data ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* EnumType::decode() const +DataType * +EnumType::decode() const { hid_t encoded_enumtype_id = H5I_INVALID_HID; try { @@ -166,7 +173,7 @@ DataType* EnumType::decode() const } EnumType *encoded_enumtype = new EnumType; encoded_enumtype->p_setId(encoded_enumtype_id); - return(encoded_enumtype); + return (encoded_enumtype); } //-------------------------------------------------------------------------- @@ -177,12 +184,12 @@ DataType* EnumType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::insert(const char* name, void *value) const +void +EnumType::insert(const char *name, void *value) const { // Calls C routine H5Tenum_insert to insert the new enum datatype member. herr_t ret_value = H5Tenum_insert(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::insert", "H5Tenum_insert failed"); } } @@ -194,7 +201,8 @@ void EnumType::insert(const char* name, void *value) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::insert(const H5std_string& name, void *value) const +void +EnumType::insert(const H5std_string &name, void *value) const { insert(name.c_str(), value); } @@ -208,24 +216,24 @@ void EnumType::insert(const H5std_string& name, void *value) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string EnumType::nameOf(void *value, size_t size) const +H5std_string +EnumType::nameOf(void *value, size_t size) const { - char* name_C = new char[size+1]; // temporary C-string for C API - HDmemset(name_C, 0, size+1); // clear buffer + char *name_C = new char[size + 1]; // temporary C-string for C API + HDmemset(name_C, 0, size + 1); // clear buffer // Calls C routine H5Tenum_nameof to get the name of the specified enum type herr_t ret_value = H5Tenum_nameof(id, value, name_C, size); // If H5Tenum_nameof returns a negative value, raise an exception, - if (ret_value < 0) - { - delete []name_C; + if (ret_value < 0) { + delete[] name_C; throw DataTypeIException("EnumType::nameOf", "H5Tenum_nameof failed"); } // otherwise, create the string to hold the datatype name and return it H5std_string name(name_C); - delete []name_C; - return(name); + delete[] name_C; + return (name); } //-------------------------------------------------------------------------- @@ -237,12 +245,12 @@ H5std_string EnumType::nameOf(void *value, size_t size) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::valueOf(const char* name, void *value) const +void +EnumType::valueOf(const char *name, void *value) const { // Calls C routine H5Tenum_valueof to get the enum datatype value herr_t ret_value = H5Tenum_valueof(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::valueOf", "H5Tenum_valueof failed"); } } @@ -254,7 +262,8 @@ void EnumType::valueOf(const char* name, void *value) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::valueOf(const H5std_string& name, void *value) const +void +EnumType::valueOf(const H5std_string &name, void *value) const { valueOf(name.c_str(), value); } @@ -269,15 +278,14 @@ void EnumType::valueOf(const H5std_string& name, void *value) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int EnumType::getMemberIndex(const char *name) const +int +EnumType::getMemberIndex(const char *name) const { int member_index = H5Tget_member_index(id, name); - if (member_index < 0) - { - throw DataTypeIException("EnumType::getMemberIndex", - "H5Tget_member_index returns negative value"); + if (member_index < 0) { + throw DataTypeIException("EnumType::getMemberIndex", "H5Tget_member_index returns negative value"); } - return(member_index); + return (member_index); } //-------------------------------------------------------------------------- @@ -287,9 +295,10 @@ int EnumType::getMemberIndex(const char *name) const /// argument \a name. // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int EnumType::getMemberIndex(const H5std_string& name) const +int +EnumType::getMemberIndex(const H5std_string &name) const { - return(EnumType::getMemberIndex(name.c_str())); + return (EnumType::getMemberIndex(name.c_str())); } //-------------------------------------------------------------------------- @@ -299,15 +308,15 @@ int EnumType::getMemberIndex(const H5std_string& name) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -int EnumType::getNmembers() const +int +EnumType::getNmembers() const { int num_members = H5Tget_nmembers(id); - if (num_members < 0) - { + if (num_members < 0) { throw DataTypeIException("EnumType::getNmembers", - "H5Tget_nmembers returns negative number of members"); + "H5Tget_nmembers returns negative number of members"); } - return(num_members); + return (num_members); } //-------------------------------------------------------------------------- @@ -319,12 +328,12 @@ int EnumType::getNmembers() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::getMemberValue(unsigned memb_no, void *value) const +void +EnumType::getMemberValue(unsigned memb_no, void *value) const { // Call C routine H5Tget_member_value to get the datatype member's value hid_t ret_value = H5Tget_member_value(id, memb_no, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::getMemberValue", "H5Tget_member_value failed"); } } @@ -334,6 +343,8 @@ void EnumType::getMemberValue(unsigned memb_no, void *value) const ///\brief Properly terminates access to this enum datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::~EnumType() {} +EnumType::~EnumType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index 4797ee7..e3d9a50 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -24,61 +24,65 @@ namespace H5 { // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP EnumType : public DataType { - public: - // Creates an empty enumeration datatype based on a native signed - // integer type, whose size is given by size. - EnumType(size_t size); + public: + // Creates an empty enumeration datatype based on a native signed + // integer type, whose size is given by size. + EnumType(size_t size); - // Gets the enum datatype of the specified dataset - EnumType(const DataSet& dataset); // H5Dget_type + // Gets the enum datatype of the specified dataset + EnumType(const DataSet &dataset); // H5Dget_type - // Creates a new enum datatype based on an integer datatype - EnumType(const IntType& data_type); // H5Tenum_create + // Creates a new enum datatype based on an integer datatype + EnumType(const IntType &data_type); // H5Tenum_create - // Constructors that open an enum datatype, given a location. - EnumType(const H5Location& loc, const char* name); - EnumType(const H5Location& loc, const H5std_string& name); + // Constructors that open an enum datatype, given a location. + EnumType(const H5Location &loc, const char *name); + EnumType(const H5Location &loc, const H5std_string &name); - // Returns an EnumType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an EnumType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Returns the number of members in this enumeration datatype. - int getNmembers () const; + // Returns the number of members in this enumeration datatype. + int getNmembers() const; - // Returns the index of a member in this enumeration data type. - int getMemberIndex(const char* name) const; - int getMemberIndex(const H5std_string& name) const; + // Returns the index of a member in this enumeration data type. + int getMemberIndex(const char *name) const; + int getMemberIndex(const H5std_string &name) const; - // Returns the value of an enumeration datatype member - void getMemberValue(unsigned memb_no, void *value) const; + // Returns the value of an enumeration datatype member + void getMemberValue(unsigned memb_no, void *value) const; - // Inserts a new member to this enumeration type. - void insert(const char* name, void *value) const; - void insert(const H5std_string& name, void *value) const; + // Inserts a new member to this enumeration type. + void insert(const char *name, void *value) const; + void insert(const H5std_string &name, void *value) const; - // Returns the symbol name corresponding to a specified member - // of this enumeration datatype. - H5std_string nameOf(void *value, size_t size) const; + // Returns the symbol name corresponding to a specified member + // of this enumeration datatype. + H5std_string nameOf(void *value, size_t size) const; - // Returns the value corresponding to a specified member of this - // enumeration datatype. - void valueOf(const char* name, void *value) const; - void valueOf(const H5std_string& name, void *value) const; + // Returns the value corresponding to a specified member of this + // enumeration datatype. + void valueOf(const char *name, void *value) const; + void valueOf(const H5std_string &name, void *value) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("EnumType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("EnumType"); + } - // Default constructor - EnumType(); + // Default constructor + EnumType(); - // Creates an enumeration datatype using an existing id - EnumType(const hid_t existing_id); + // Creates an enumeration datatype using an existing id + EnumType(const hid_t existing_id); - // Copy constructor: same as the original EnumType. - EnumType(const EnumType& original); + // Copy constructor: same as the original EnumType. + EnumType(const EnumType &original); - virtual ~EnumType(); + virtual ~EnumType(); }; // end of EnumType } // namespace H5 diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 7431e6c..934b179 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -25,7 +25,9 @@ const char Exception::DEFAULT_MSG[] = "No detailed information provided"; ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception() : detail_message(""), func_name("") {} +Exception::Exception() : detail_message(""), func_name("") +{ +} //-------------------------------------------------------------------------- // Function: Exception overloaded constructor @@ -35,7 +37,10 @@ Exception::Exception() : detail_message(""), func_name("") {} ///\param message - IN: Message on the failure // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception(const H5std_string& func, const H5std_string& message) : detail_message(message), func_name(func) {} +Exception::Exception(const H5std_string &func, const H5std_string &message) + : detail_message(message), func_name(func) +{ +} //-------------------------------------------------------------------------- // Function: Exception copy constructor @@ -43,7 +48,9 @@ Exception::Exception(const H5std_string& func, const H5std_string& message) : de ///\param orig - IN: Exception instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception(const Exception& orig) : detail_message(orig.detail_message), func_name(orig.func_name) {} +Exception::Exception(const Exception &orig) : detail_message(orig.detail_message), func_name(orig.func_name) +{ +} //-------------------------------------------------------------------------- // Function: Exception::getMajorString @@ -56,32 +63,30 @@ Exception::Exception(const Exception& orig) : detail_message(orig.detail_message /// will be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getMajorString(hid_t err_major) const +H5std_string +Exception::getMajorString(hid_t err_major) const { // Preliminary call to H5Eget_msg() to get the length of the message ssize_t mesg_size = H5Eget_msg(err_major, NULL, NULL, 0); // If H5Eget_msg() returns a negative value, raise an exception, if (mesg_size < 0) - throw IdComponentException("Exception::getMajorString", - "H5Eget_msg failed"); + throw IdComponentException("Exception::getMajorString", "H5Eget_msg failed"); // Call H5Eget_msg again to get the actual message - char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API - mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size+1); + char *mesg_C = new char[mesg_size + 1]; // temporary C-string for C API + mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size + 1); // Check for failure again - if (mesg_size < 0) - { - delete []mesg_C; - throw IdComponentException("Exception::getMajorString", - "H5Eget_msg failed"); + if (mesg_size < 0) { + delete[] mesg_C; + throw IdComponentException("Exception::getMajorString", "H5Eget_msg failed"); } // Convert the C error description and return H5std_string major_str(mesg_C); - delete []mesg_C; - return(major_str); + delete[] mesg_C; + return (major_str); } //-------------------------------------------------------------------------- @@ -95,32 +100,30 @@ H5std_string Exception::getMajorString(hid_t err_major) const /// will be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getMinorString(hid_t err_minor) const +H5std_string +Exception::getMinorString(hid_t err_minor) const { // Preliminary call to H5Eget_msg() to get the length of the message ssize_t mesg_size = H5Eget_msg(err_minor, NULL, NULL, 0); // If H5Eget_msg() returns a negative value, raise an exception, if (mesg_size < 0) - throw IdComponentException("Exception::getMinorString", - "H5Eget_msg failed"); + throw IdComponentException("Exception::getMinorString", "H5Eget_msg failed"); // Call H5Eget_msg again to get the actual message - char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API - mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size+1); + char *mesg_C = new char[mesg_size + 1]; // temporary C-string for C API + mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size + 1); // Check for failure again - if (mesg_size < 0) - { - delete []mesg_C; - throw IdComponentException("Exception::getMinorString", - "H5Eget_msg failed"); + if (mesg_size < 0) { + delete[] mesg_C; + throw IdComponentException("Exception::getMinorString", "H5Eget_msg failed"); } // Convert the C error description and return H5std_string minor_str(mesg_C); - delete []mesg_C; - return(minor_str); + delete[] mesg_C; + return (minor_str); } //-------------------------------------------------------------------------- @@ -139,7 +142,8 @@ H5std_string Exception::getMinorString(hid_t err_minor) const /// handlers // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::setAutoPrint(H5E_auto2_t& func, void* client_data) +void +Exception::setAutoPrint(H5E_auto2_t &func, void *client_data) { // calls the C API routine H5Eset_auto to set the auto printing to // the specified function. @@ -153,7 +157,8 @@ void Exception::setAutoPrint(H5E_auto2_t& func, void* client_data) ///\brief Turns off the automatic error printing from the C library. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::dontPrint() +void +Exception::dontPrint() { // calls the C API routine H5Eset_auto with NULL parameters to turn // off the automatic error printing. @@ -172,7 +177,8 @@ void Exception::dontPrint() /// the error function // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::getAutoPrint(H5E_auto2_t& func, void** client_data) +void +Exception::getAutoPrint(H5E_auto2_t &func, void **client_data) { // calls the C API routine H5Eget_auto to get the current setting of // the automatic error printing @@ -189,7 +195,8 @@ void Exception::getAutoPrint(H5E_auto2_t& func, void** client_data) /// called, with certain exceptions (for instance, \c H5Eprint). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::clearErrorStack() +void +Exception::clearErrorStack() { // calls the C API routine H5Eclear to clear the error stack herr_t ret_value = H5Eclear2(H5E_DEFAULT); @@ -238,7 +245,8 @@ void Exception::clearErrorStack() ///\endcode // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void* client_data) +void +Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void *client_data) { // calls the C API routine H5Ewalk to walk the error stack herr_t ret_value = H5Ewalk2(H5E_DEFAULT, direction, func, client_data); @@ -253,9 +261,10 @@ void Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void ///\return Text message - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getDetailMsg() const +H5std_string +Exception::getDetailMsg() const { - return(detail_message); + return (detail_message); } //-------------------------------------------------------------------------- @@ -265,9 +274,10 @@ H5std_string Exception::getDetailMsg() const ///\return Text message - \c char pointer // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -const char* Exception::getCDetailMsg() const +const char * +Exception::getCDetailMsg() const { - return(detail_message.c_str()); + return (detail_message.c_str()); } //-------------------------------------------------------------------------- @@ -276,9 +286,10 @@ const char* Exception::getCDetailMsg() const ///\return Text message - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getFuncName() const +H5std_string +Exception::getFuncName() const { - return(func_name); + return (func_name); } //-------------------------------------------------------------------------- @@ -287,9 +298,10 @@ H5std_string Exception::getFuncName() const ///\return Text message - \c char pointer // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -const char* Exception::getCFuncName() const +const char * +Exception::getCFuncName() const { - return(func_name.c_str()); + return (func_name.c_str()); } //-------------------------------------------------------------------------- @@ -299,7 +311,8 @@ const char* Exception::getCFuncName() const ///\param err_stack - IN: Error stack ID, default to H5E_DEFAULT(0) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::printErrorStack(FILE* stream, hid_t err_stack) +void +Exception::printErrorStack(FILE *stream, hid_t err_stack) { herr_t ret_value = H5Eprint2(err_stack, stream); if (ret_value < 0) @@ -319,7 +332,7 @@ void Exception::printErrorStack(FILE* stream, hid_t err_stack) // Removed from documentation. -BMR, 2016/03/23 // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 //-------------------------------------------------------------------------- -//void Exception::printError(FILE* stream) const +// void Exception::printError(FILE* stream) const //{ // Exception::printErrorStack(stream, H5E_DEFAULT); //} @@ -329,7 +342,9 @@ void Exception::printErrorStack(FILE* stream, hid_t err_stack) ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::~Exception() throw() {} +Exception::~Exception() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: FileIException @@ -339,7 +354,9 @@ Exception::~Exception() throw() {} // Function: FileIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -FileIException::FileIException():Exception(){} +FileIException::FileIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: FileIException overloaded constructor ///\brief Creates a FileIException with the name of the function, @@ -347,12 +364,17 @@ FileIException::FileIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -FileIException::FileIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +FileIException::FileIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: FileIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -FileIException::~FileIException() throw() {} +FileIException::~FileIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: GroupIException @@ -362,7 +384,9 @@ FileIException::~FileIException() throw() {} // Function: GroupIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -GroupIException::GroupIException():Exception(){} +GroupIException::GroupIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: GroupIException overloaded constructor ///\brief Creates a GroupIException with the name of the function, @@ -370,12 +394,17 @@ GroupIException::GroupIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -GroupIException::GroupIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +GroupIException::GroupIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: GroupIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -GroupIException::~GroupIException() throw() {} +GroupIException::~GroupIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataSpaceIException @@ -385,7 +414,9 @@ GroupIException::~GroupIException() throw() {} // Function: DataSpaceIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataSpaceIException::DataSpaceIException():Exception(){} +DataSpaceIException::DataSpaceIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataSpaceIException overloaded constructor ///\brief Creates a DataSpaceIException with the name of the function, @@ -393,12 +424,17 @@ DataSpaceIException::DataSpaceIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataSpaceIException::DataSpaceIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataSpaceIException::DataSpaceIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataSpaceIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataSpaceIException::~DataSpaceIException() throw() {} +DataSpaceIException::~DataSpaceIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataTypeIException @@ -408,7 +444,9 @@ DataSpaceIException::~DataSpaceIException() throw() {} // Function: DataTypeIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataTypeIException::DataTypeIException():Exception(){} +DataTypeIException::DataTypeIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataTypeIException overloaded constructor ///\brief Creates a DataTypeIException with the name of the function, @@ -416,12 +454,17 @@ DataTypeIException::DataTypeIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataTypeIException::DataTypeIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataTypeIException::DataTypeIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataTypeIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataTypeIException::~DataTypeIException() throw() {} +DataTypeIException::~DataTypeIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: ObjHeaderIException @@ -431,7 +474,9 @@ DataTypeIException::~DataTypeIException() throw() {} // Function: ObjHeaderIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -ObjHeaderIException::ObjHeaderIException():Exception(){} +ObjHeaderIException::ObjHeaderIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: ObjHeaderIException overloaded constructor ///\brief Creates an ObjHeaderIException with the name of the function, @@ -439,12 +484,17 @@ ObjHeaderIException::ObjHeaderIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -ObjHeaderIException::ObjHeaderIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +ObjHeaderIException::ObjHeaderIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: ObjHeaderIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -ObjHeaderIException::~ObjHeaderIException() throw() {} +ObjHeaderIException::~ObjHeaderIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: PropListIException @@ -454,7 +504,9 @@ ObjHeaderIException::~ObjHeaderIException() throw() {} // Function: PropListIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -PropListIException::PropListIException():Exception(){} +PropListIException::PropListIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: PropListIException overloaded constructor ///\brief Creates a PropListIException with the name of the function, @@ -462,12 +514,17 @@ PropListIException::PropListIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -PropListIException::PropListIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +PropListIException::PropListIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: PropListIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -PropListIException::~PropListIException() throw() {} +PropListIException::~PropListIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataSetIException @@ -477,7 +534,9 @@ PropListIException::~PropListIException() throw() {} // Function: DataSetIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataSetIException::DataSetIException():Exception(){} +DataSetIException::DataSetIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataSetIException overloaded constructor ///\brief Creates a DataSetIException with the name of the function, @@ -485,12 +544,17 @@ DataSetIException::DataSetIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataSetIException::DataSetIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataSetIException::DataSetIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataSetIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataSetIException::~DataSetIException() throw() {} +DataSetIException::~DataSetIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: AttributeIException @@ -500,7 +564,9 @@ DataSetIException::~DataSetIException() throw() {} // Function: AttributeIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -AttributeIException::AttributeIException():Exception(){} +AttributeIException::AttributeIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: AttributeIException overloaded constructor ///\brief Creates an AttributeIException with the name of the function, @@ -508,12 +574,17 @@ AttributeIException::AttributeIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -AttributeIException::AttributeIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +AttributeIException::AttributeIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: AttributeIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -AttributeIException::~AttributeIException() throw() {} +AttributeIException::~AttributeIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: ReferenceException @@ -523,7 +594,9 @@ AttributeIException::~AttributeIException() throw() {} // Function: ReferenceException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -ReferenceException::ReferenceException():Exception(){} +ReferenceException::ReferenceException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: ReferenceException overloaded constructor ///\brief Creates a ReferenceException with the name of the function, @@ -531,12 +604,17 @@ ReferenceException::ReferenceException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -ReferenceException::ReferenceException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +ReferenceException::ReferenceException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: ReferenceException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -ReferenceException::~ReferenceException() throw() {} +ReferenceException::~ReferenceException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: LibraryIException @@ -546,7 +624,9 @@ ReferenceException::~ReferenceException() throw() {} // Function: LibraryIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -LibraryIException::LibraryIException():Exception(){} +LibraryIException::LibraryIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: LibraryIException overloaded constructor ///\brief Creates a LibraryIException with the name of the function, @@ -554,12 +634,17 @@ LibraryIException::LibraryIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -LibraryIException::LibraryIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +LibraryIException::LibraryIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: LibraryIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -LibraryIException::~LibraryIException() throw() {} +LibraryIException::~LibraryIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: LocationException @@ -569,7 +654,9 @@ LibraryIException::~LibraryIException() throw() {} // Function: LocationException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -LocationException::LocationException():Exception(){} +LocationException::LocationException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: LocationException overloaded constructor ///\brief Creates a LocationException with the name of the function, @@ -577,12 +664,17 @@ LocationException::LocationException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -LocationException::LocationException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +LocationException::LocationException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: LocationException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -LocationException::~LocationException() throw() {} +LocationException::~LocationException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: IdComponentException @@ -592,7 +684,9 @@ LocationException::~LocationException() throw() {} // Function: IdComponentException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -IdComponentException::IdComponentException(): Exception() {} +IdComponentException::IdComponentException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: IdComponentException overloaded constructor ///\brief Creates a IdComponentException with the name of the function, @@ -600,11 +694,16 @@ IdComponentException::IdComponentException(): Exception() {} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -IdComponentException::IdComponentException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +IdComponentException::IdComponentException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: IdComponentException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -IdComponentException::~IdComponentException() throw() {} +IdComponentException::~IdComponentException() throw() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index cb14a4c..44edac2 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -19,9 +19,9 @@ namespace H5 { #ifdef H5_NO_STD - #define H5std_string ::string +#define H5std_string ::string #else - #define H5std_string std::string +#define H5std_string std::string #endif /*! \class Exception @@ -30,150 +30,148 @@ namespace H5 { Many classes are derived from Exception for specific HDF5 C interfaces. */ class H5_DLLCPP Exception { - public: - // Creates an exception with a function name where the failure occurs - // and an optional detailed message - Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - - // Returns a character string that describes the error specified by - // a major error number. - H5std_string getMajorString(hid_t err_major_id) const; - - // Returns a character string that describes the error specified by - // a minor error number. - H5std_string getMinorString(hid_t err_minor_id) const; - - // Returns the detailed message set at the time the exception is thrown - H5std_string getDetailMsg() const; - const char* getCDetailMsg() const; // C string of detailed message - H5std_string getFuncName() const; // function name as a string object - const char* getCFuncName() const; // function name as a char string - - // Turns on the automatic error printing. - static void setAutoPrint(H5E_auto2_t& func, void* client_data); - - // Turns off the automatic error printing. - static void dontPrint(); - - // Retrieves the current settings for the automatic error stack - // traversal function and its data. - static void getAutoPrint(H5E_auto2_t& func, void** client_data); - - // Clears the error stack for the current thread. - static void clearErrorStack(); - - // Walks the error stack for the current thread, calling the - // specified function. - static void walkErrorStack(H5E_direction_t direction, - H5E_walk2_t func, void* client_data); - - // Prints the error stack in a default manner. - static void printErrorStack(FILE* stream = stderr, - hid_t err_stack = H5E_DEFAULT); - // Deprecated in favor of printErrorStack. - // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 - // virtual void printError(FILE* stream = NULL) const; - - // Default constructor - Exception(); - - // copy constructor - Exception(const Exception& orig); - - // virtual Destructor - virtual ~Exception() throw(); - - protected: - // Default value for detail_message - static const char DEFAULT_MSG[]; - - private: - H5std_string detail_message; - H5std_string func_name; + public: + // Creates an exception with a function name where the failure occurs + // and an optional detailed message + Exception(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + + // Returns a character string that describes the error specified by + // a major error number. + H5std_string getMajorString(hid_t err_major_id) const; + + // Returns a character string that describes the error specified by + // a minor error number. + H5std_string getMinorString(hid_t err_minor_id) const; + + // Returns the detailed message set at the time the exception is thrown + H5std_string getDetailMsg() const; + const char * getCDetailMsg() const; // C string of detailed message + H5std_string getFuncName() const; // function name as a string object + const char * getCFuncName() const; // function name as a char string + + // Turns on the automatic error printing. + static void setAutoPrint(H5E_auto2_t &func, void *client_data); + + // Turns off the automatic error printing. + static void dontPrint(); + + // Retrieves the current settings for the automatic error stack + // traversal function and its data. + static void getAutoPrint(H5E_auto2_t &func, void **client_data); + + // Clears the error stack for the current thread. + static void clearErrorStack(); + + // Walks the error stack for the current thread, calling the + // specified function. + static void walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void *client_data); + + // Prints the error stack in a default manner. + static void printErrorStack(FILE *stream = stderr, hid_t err_stack = H5E_DEFAULT); + // Deprecated in favor of printErrorStack. + // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 + // virtual void printError(FILE* stream = NULL) const; + + // Default constructor + Exception(); + + // copy constructor + Exception(const Exception &orig); + + // virtual Destructor + virtual ~Exception() throw(); + + protected: + // Default value for detail_message + static const char DEFAULT_MSG[]; + + private: + H5std_string detail_message; + H5std_string func_name; }; class H5_DLLCPP FileIException : public Exception { - public: - FileIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - FileIException(); - virtual ~FileIException() throw(); + public: + FileIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + FileIException(); + virtual ~FileIException() throw(); }; class H5_DLLCPP GroupIException : public Exception { - public: - GroupIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - GroupIException(); - virtual ~GroupIException() throw(); + public: + GroupIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + GroupIException(); + virtual ~GroupIException() throw(); }; class H5_DLLCPP DataSpaceIException : public Exception { - public: - DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataSpaceIException(); - virtual ~DataSpaceIException() throw(); + public: + DataSpaceIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataSpaceIException(); + virtual ~DataSpaceIException() throw(); }; class H5_DLLCPP DataTypeIException : public Exception { - public: - DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataTypeIException(); - virtual ~DataTypeIException() throw(); + public: + DataTypeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataTypeIException(); + virtual ~DataTypeIException() throw(); }; class H5_DLLCPP ObjHeaderIException : public Exception { - public: - ObjHeaderIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - ObjHeaderIException(); - virtual ~ObjHeaderIException() throw(); + public: + ObjHeaderIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + ObjHeaderIException(); + virtual ~ObjHeaderIException() throw(); }; class H5_DLLCPP PropListIException : public Exception { - public: - PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - PropListIException(); - virtual ~PropListIException() throw(); + public: + PropListIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + PropListIException(); + virtual ~PropListIException() throw(); }; class H5_DLLCPP DataSetIException : public Exception { - public: - DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataSetIException(); - virtual ~DataSetIException() throw(); + public: + DataSetIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataSetIException(); + virtual ~DataSetIException() throw(); }; class H5_DLLCPP AttributeIException : public Exception { - public: - AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - AttributeIException(); - virtual ~AttributeIException() throw(); + public: + AttributeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + AttributeIException(); + virtual ~AttributeIException() throw(); }; class H5_DLLCPP ReferenceException : public Exception { - public: - ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - ReferenceException(); - virtual ~ReferenceException() throw(); + public: + ReferenceException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + ReferenceException(); + virtual ~ReferenceException() throw(); }; class H5_DLLCPP LibraryIException : public Exception { - public: - LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - LibraryIException(); - virtual ~LibraryIException() throw(); + public: + LibraryIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + LibraryIException(); + virtual ~LibraryIException() throw(); }; class H5_DLLCPP LocationException : public Exception { - public: - LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - LocationException(); - virtual ~LocationException() throw(); + public: + LocationException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + LocationException(); + virtual ~LocationException() throw(); }; class H5_DLLCPP IdComponentException : public Exception { - public: - IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - IdComponentException(); - virtual ~IdComponentException() throw(); + public: + IdComponentException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + IdComponentException(); + virtual ~IdComponentException() throw(); }; // end of IdComponentException } // namespace H5 diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index 5a478e7..3b9ccd5 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -37,7 +37,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -FileAccPropList* FileAccPropList::DEFAULT_ = 0; +FileAccPropList *FileAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: FileAccPropList::getConstant @@ -50,13 +50,13 @@ FileAccPropList* FileAccPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -FileAccPropList* FileAccPropList::getConstant() +FileAccPropList * +FileAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -65,8 +65,9 @@ FileAccPropList* FileAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new FileAccPropList(H5P_FILE_ACCESS); else - throw PropListIException("FileAccPropList::getConstant", "FileAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("FileAccPropList::getConstant", + "FileAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -76,7 +77,8 @@ FileAccPropList* FileAccPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void FileAccPropList::deleteConstants() +void +FileAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -85,7 +87,7 @@ void FileAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property //-------------------------------------------------------------------------- -const FileAccPropList& FileAccPropList::DEFAULT = *getConstant(); +const FileAccPropList &FileAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -94,7 +96,9 @@ const FileAccPropList& FileAccPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) {} +FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList copy constructor @@ -102,7 +106,9 @@ FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) {} ///\param original - IN: FileAccPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList(const FileAccPropList& original) : PropList(original) {} +FileAccPropList::FileAccPropList(const FileAccPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList overloaded constructor @@ -110,7 +116,9 @@ FileAccPropList::FileAccPropList(const FileAccPropList& original) : PropList(ori /// existing one. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) {} +FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList::setStdio @@ -119,11 +127,11 @@ FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) {} ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setStdio() const +void +FileAccPropList::setStdio() const { herr_t ret_value = H5Pset_fapl_stdio(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setStdio", "H5Pset_fapl_stdio failed"); } } @@ -139,14 +147,14 @@ void FileAccPropList::setStdio() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hid_t FileAccPropList::getDriver() const +hid_t +FileAccPropList::getDriver() const { hid_t driver = H5Pget_driver(id); - if (driver < 0) - { + if (driver < 0) { throw PropListIException("FileAccPropList::getDriver", "H5Pget_driver failed"); } - return(driver); + return (driver); } //-------------------------------------------------------------------------- @@ -160,11 +168,11 @@ hid_t FileAccPropList::getDriver() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info) const +void +FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info) const { herr_t ret_value = H5Pset_driver(id, new_driver_id, new_driver_info); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setDriver", "H5Pset_driver failed"); } } @@ -176,11 +184,11 @@ void FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFamilyOffset(hsize_t offset) const +void +FileAccPropList::setFamilyOffset(hsize_t offset) const { herr_t ret_value = H5Pset_family_offset(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFamilyOffset", "H5Pset_family_offset failed"); } } @@ -192,15 +200,15 @@ void FileAccPropList::setFamilyOffset(hsize_t offset) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t FileAccPropList::getFamilyOffset() const +hsize_t +FileAccPropList::getFamilyOffset() const { hsize_t offset; - herr_t ret_value = H5Pget_family_offset(id, &offset); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_family_offset(id, &offset); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamilyOffset", "H5Pget_family_offset failed"); } - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -217,12 +225,12 @@ hsize_t FileAccPropList::getFamilyOffset() const /// refer to the H5Pset_fapl_core API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setCore (size_t increment, hbool_t backing_store) const +void +FileAccPropList::setCore(size_t increment, hbool_t backing_store) const { - herr_t ret_value = H5Pset_fapl_core (id, increment, backing_store); - if (ret_value < 0) - { - throw PropListIException ("FileAccPropList::setCore", "H5Pset_fapl_core failed"); + herr_t ret_value = H5Pset_fapl_core(id, increment, backing_store); + if (ret_value < 0) { + throw PropListIException("FileAccPropList::setCore", "H5Pset_fapl_core failed"); } } @@ -235,11 +243,11 @@ void FileAccPropList::setCore (size_t increment, hbool_t backing_store) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::getCore (size_t& increment, hbool_t& backing_store) const +void +FileAccPropList::getCore(size_t &increment, hbool_t &backing_store) const { herr_t ret_value = H5Pget_fapl_core(id, &increment, &backing_store); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getCore", "H5Pget_fapl_core failed"); } } @@ -255,11 +263,11 @@ void FileAccPropList::getCore (size_t& increment, hbool_t& backing_store) const /// Note that \a memb_size is used only when creating a new file. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList& memb_plist) const +void +FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList &memb_plist) const { - herr_t ret_value = H5Pset_fapl_family (id, memb_size, memb_plist.getId()); - if (ret_value < 0) - { + herr_t ret_value = H5Pset_fapl_family(id, memb_size, memb_plist.getId()); + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFamily", "H5Pset_fapl_family failed"); } } @@ -274,12 +282,12 @@ void FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList& memb_p ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const +void +FileAccPropList::getFamily(hsize_t &memb_size, FileAccPropList &memb_plist) const { - hid_t memb_plist_id; + hid_t memb_plist_id; herr_t ret_value = H5Pget_fapl_family(id, &memb_size, &memb_plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); } memb_plist.p_setId(memb_plist_id); @@ -295,16 +303,16 @@ void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -FileAccPropList FileAccPropList::getFamily(hsize_t& memb_size) const +FileAccPropList +FileAccPropList::getFamily(hsize_t &memb_size) const { - hid_t memb_plist_id; + hid_t memb_plist_id; herr_t ret_value = H5Pget_fapl_family(id, &memb_size, &memb_plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); } FileAccPropList memb_plist(memb_plist_id); - return(memb_plist); + return (memb_plist); } //-------------------------------------------------------------------------- @@ -321,13 +329,14 @@ FileAccPropList FileAccPropList::getFamily(hsize_t& memb_size) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext) const +void +FileAccPropList::setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const char *meta_ext, const char *raw_ext) const { - hid_t meta_pid = meta_plist.getId(); - hid_t raw_pid = raw_plist.getId(); + hid_t meta_pid = meta_plist.getId(); + hid_t raw_pid = raw_plist.getId(); herr_t ret_value = H5Pset_fapl_split(id, meta_ext, meta_pid, raw_ext, raw_pid); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setSplit", "H5Pset_fapl_split failed"); } } @@ -343,7 +352,9 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const H5std_string& meta_ext, const H5std_string& raw_ext) const +void +FileAccPropList::setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const H5std_string &meta_ext, const H5std_string &raw_ext) const { setSplit(meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str()); } @@ -360,15 +371,15 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t FileAccPropList::getSieveBufSize() const +size_t +FileAccPropList::getSieveBufSize() const { size_t bufsize; herr_t ret_value = H5Pget_sieve_buf_size(id, &bufsize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); } - return(bufsize); + return (bufsize); } //-------------------------------------------------------------------------- @@ -381,11 +392,11 @@ size_t FileAccPropList::getSieveBufSize() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSieveBufSize(size_t bufsize) const +void +FileAccPropList::setSieveBufSize(size_t bufsize) const { herr_t ret_value = H5Pset_sieve_buf_size(id, bufsize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); } } @@ -401,11 +412,11 @@ void FileAccPropList::setSieveBufSize(size_t bufsize) const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setMetaBlockSize(hsize_t &block_size) const +void +FileAccPropList::setMetaBlockSize(hsize_t &block_size) const { herr_t ret_value = H5Pset_meta_block_size(id, block_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setMetaBlockSize", "H5Pset_meta_block_size failed"); } } @@ -417,15 +428,15 @@ void FileAccPropList::setMetaBlockSize(hsize_t &block_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t FileAccPropList::getMetaBlockSize() const +hsize_t +FileAccPropList::getMetaBlockSize() const { hsize_t block_size; - herr_t ret_value = H5Pget_meta_block_size(id, &block_size); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_meta_block_size(id, &block_size); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getMetaBlockSize", "H5Pget_meta_block_size failed"); } - return(block_size); + return (block_size); } //-------------------------------------------------------------------------- @@ -441,11 +452,11 @@ hsize_t FileAccPropList::getMetaBlockSize() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_size) const +void +FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_size) const { herr_t ret_value = H5Pset_fapl_log(id, logfile, flags, buf_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setLog", "H5Pset_fapl_log failed"); } } @@ -460,7 +471,8 @@ void FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_siz ///\param buf_size - IN: Size of the logging buffer // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const +void +FileAccPropList::setLog(const H5std_string &logfile, unsigned flags, size_t buf_size) const { setLog(logfile.c_str(), flags, buf_size); } @@ -473,11 +485,11 @@ void FileAccPropList::setLog(const H5std_string& logfile, unsigned flags, size_t ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSec2() const +void +FileAccPropList::setSec2() const { herr_t ret_value = H5Pset_fapl_sec2(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setSec2", "H5Pset_fapl_sec2 failed"); } } @@ -498,11 +510,11 @@ void FileAccPropList::setSec2() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const +void +FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const { herr_t ret_value = H5Pset_alignment(id, threshold, alignment); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setAlignment", "H5Pset_alignment failed"); } } @@ -516,11 +528,11 @@ void FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const +void +FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const { herr_t ret_value = H5Pget_alignment(id, &threshold, &alignment); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getAlignment", "H5Pget_alignment failed"); } } @@ -535,11 +547,11 @@ void FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setMultiType(H5FD_mem_t dtype) const +void +FileAccPropList::setMultiType(H5FD_mem_t dtype) const { herr_t ret_value = H5Pset_multi_type(id, dtype); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setMultiType", "H5Pset_multi_type failed"); } } @@ -554,15 +566,15 @@ void FileAccPropList::setMultiType(H5FD_mem_t dtype) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5FD_mem_t FileAccPropList::getMultiType() const +H5FD_mem_t +FileAccPropList::getMultiType() const { H5FD_mem_t dtype; - herr_t ret_value = H5Pget_multi_type(id, &dtype); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_multi_type(id, &dtype); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getMultiType", "H5Pget_multi_type failed"); } - return(dtype); + return (dtype); } //-------------------------------------------------------------------------- @@ -582,11 +594,11 @@ H5FD_mem_t FileAccPropList::getMultiType() const /// means fully read chunks are always preempted before other chunks. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const +void +FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const { herr_t ret_value = H5Pset_cache(id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setCache", "H5Pset_cache failed"); } } @@ -601,11 +613,11 @@ void FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_n ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0) const +void +FileAccPropList::getCache(int &mdc_nelmts, size_t &rdcc_nelmts, size_t &rdcc_nbytes, double &rdcc_w0) const { herr_t ret_value = H5Pget_cache(id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getCache", "H5Pget_cache failed"); } } @@ -617,11 +629,11 @@ void FileAccPropList::getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdc ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const +void +FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const { herr_t ret_value = H5Pset_fclose_degree(id, degree); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFcloseDegree", "H5Pset_fclose_degree failed"); } } @@ -633,15 +645,15 @@ void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5F_close_degree_t FileAccPropList::getFcloseDegree() const +H5F_close_degree_t +FileAccPropList::getFcloseDegree() const { H5F_close_degree_t degree; - herr_t ret_value = H5Pget_fclose_degree(id, °ree); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_fclose_degree(id, °ree); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFcloseDegree", "H5Pget_fclose_degree failed"); } - return(degree); + return (degree); } //-------------------------------------------------------------------------- @@ -655,11 +667,11 @@ H5F_close_degree_t FileAccPropList::getFcloseDegree() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setGcReferences(unsigned gc_ref) const +void +FileAccPropList::setGcReferences(unsigned gc_ref) const { herr_t ret_value = H5Pset_gc_references(id, gc_ref); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setGcReferences", "H5Pset_gc_references failed"); } } @@ -671,17 +683,17 @@ void FileAccPropList::setGcReferences(unsigned gc_ref) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -unsigned FileAccPropList::getGcReferences() const +unsigned +FileAccPropList::getGcReferences() const { unsigned gc_ref; // the name of this routine will be changed to H5Pget_gc_references??? herr_t ret_value = H5Pget_gc_references(id, &gc_ref); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getGcReferences", "H5Pget_gc_references failed"); } - return(gc_ref); + return (gc_ref); } //-------------------------------------------------------------------------- @@ -712,11 +724,11 @@ unsigned FileAccPropList::getGcReferences() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- -void FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const +void +FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const { herr_t ret_value = H5Pset_libver_bounds(id, libver_low, libver_high); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setLibverBounds", "H5Pset_libver_bounds failed"); } } @@ -748,11 +760,11 @@ void FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libv /// \li \c H5F_LIBVER_LATEST // Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- -void FileAccPropList::getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const +void +FileAccPropList::getLibverBounds(H5F_libver_t &libver_low, H5F_libver_t &libver_high) const { herr_t ret_value = H5Pget_libver_bounds(id, &libver_low, &libver_high); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getLibverBounds", "H5Pget_libver_bounds failed"); } } @@ -762,6 +774,8 @@ void FileAccPropList::getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& li ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::~FileAccPropList() {} +FileAccPropList::~FileAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index 58f049e..d1a5051 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -23,139 +23,139 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP FileAccPropList : public PropList { - public: - ///\brief Default file access property list. - static const FileAccPropList& DEFAULT; + public: + ///\brief Default file access property list. + static const FileAccPropList &DEFAULT; - // Creates a file access property list. - FileAccPropList(); + // Creates a file access property list. + FileAccPropList(); - // Modifies this property list to use the H5FD_STDIO driver - void setStdio() const; + // Modifies this property list to use the H5FD_STDIO driver + void setStdio() const; - // Set file driver for this property list - void setDriver(hid_t new_driver_id, const void *new_driver_info) const; + // Set file driver for this property list + void setDriver(hid_t new_driver_id, const void *new_driver_info) const; - // Returns a low-level file driver identifier. - hid_t getDriver() const; + // Returns a low-level file driver identifier. + hid_t getDriver() const; - // Sets offset for family driver. - void setFamilyOffset(hsize_t offset) const; + // Sets offset for family driver. + void setFamilyOffset(hsize_t offset) const; - // Gets offset for family driver. - hsize_t getFamilyOffset() const; + // Gets offset for family driver. + hsize_t getFamilyOffset() const; - // Modifies this file access property list to use the sec2 driver. - void setSec2() const; + // Modifies this file access property list to use the sec2 driver. + void setSec2() const; - // Modifies this file access property list to use the H5FD_CORE - // driver. - void setCore (size_t increment, hbool_t backing_store) const; + // Modifies this file access property list to use the H5FD_CORE + // driver. + void setCore(size_t increment, hbool_t backing_store) const; - // Queries H5FD_CORE driver properties. - void getCore (size_t& increment, hbool_t& backing_store) const; + // Queries H5FD_CORE driver properties. + void getCore(size_t &increment, hbool_t &backing_store) const; - // Sets this file access properties list to the family driver. - void setFamily(hsize_t memb_size, const FileAccPropList& memb_plist) const; + // Sets this file access properties list to the family driver. + void setFamily(hsize_t memb_size, const FileAccPropList &memb_plist) const; - // Returns information about the family file access property list. - void getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const; - FileAccPropList getFamily(hsize_t& memb_size) const; + // Returns information about the family file access property list. + void getFamily(hsize_t &memb_size, FileAccPropList &memb_plist) const; + FileAccPropList getFamily(hsize_t &memb_size) const; - // Emulates the old split file driver, - void setSplit(const FileAccPropList& meta_plist, - const FileAccPropList& raw_plist, - const char* meta_ext = ".meta", - const char* raw_ext = ".raw") const; - void setSplit(const FileAccPropList& meta_plist, - const FileAccPropList& raw_plist, - const H5std_string& meta_ext = ".meta", - const H5std_string& raw_ext = ".raw") const; + // Emulates the old split file driver, + void setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const char *meta_ext = ".meta", const char *raw_ext = ".raw") const; + void setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const H5std_string &meta_ext = ".meta", const H5std_string &raw_ext = ".raw") const; - // Sets the maximum size of the data sieve buffer. - void setSieveBufSize(size_t bufsize) const; + // Sets the maximum size of the data sieve buffer. + void setSieveBufSize(size_t bufsize) const; - // Returns the current settings for the data sieve buffer size - // property - size_t getSieveBufSize() const; + // Returns the current settings for the data sieve buffer size + // property + size_t getSieveBufSize() const; - // Sets the minimum size of metadata block allocations. - void setMetaBlockSize(hsize_t &block_size) const; + // Sets the minimum size of metadata block allocations. + void setMetaBlockSize(hsize_t &block_size) const; - // Returns the current metadata block size setting. - hsize_t getMetaBlockSize() const; + // Returns the current metadata block size setting. + hsize_t getMetaBlockSize() const; - // Modifies this file access property list to use the logging driver. - void setLog(const char *logfile, unsigned flags, size_t buf_size) const; - void setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const; + // Modifies this file access property list to use the logging driver. + void setLog(const char *logfile, unsigned flags, size_t buf_size) const; + void setLog(const H5std_string &logfile, unsigned flags, size_t buf_size) const; - // Sets alignment properties of this file access property list - void setAlignment(hsize_t threshold = 1, hsize_t alignment = 1) const; + // Sets alignment properties of this file access property list + void setAlignment(hsize_t threshold = 1, hsize_t alignment = 1) const; - // Retrieves the current settings for alignment properties from - // this property list. - void getAlignment(hsize_t& threshold, hsize_t& alignment) const; + // Retrieves the current settings for alignment properties from + // this property list. + void getAlignment(hsize_t &threshold, hsize_t &alignment) const; - // Sets data type for multi driver. - void setMultiType(H5FD_mem_t dtype) const; + // Sets data type for multi driver. + void setMultiType(H5FD_mem_t dtype) const; - // Returns the data type property for MULTI driver. - H5FD_mem_t getMultiType() const; + // Returns the data type property for MULTI driver. + H5FD_mem_t getMultiType() const; - // Sets the meta data cache and raw data chunk cache parameters. - void setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const; + // Sets the meta data cache and raw data chunk cache parameters. + void setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const; - // Queries the meta data cache and raw data chunk cache parameters. - void getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0) const; + // Queries the meta data cache and raw data chunk cache parameters. + void getCache(int &mdc_nelmts, size_t &rdcc_nelmts, size_t &rdcc_nbytes, double &rdcc_w0) const; - // Sets the degree for the file close behavior. - void setFcloseDegree(H5F_close_degree_t degree) const; + // Sets the degree for the file close behavior. + void setFcloseDegree(H5F_close_degree_t degree) const; - // Returns the degree for the file close behavior. - H5F_close_degree_t getFcloseDegree() const; + // Returns the degree for the file close behavior. + H5F_close_degree_t getFcloseDegree() const; - // Sets file access property list to use the H5FD_DIRECT driver. - void setFileAccDirect(size_t boundary, size_t block_size, size_t cbuf_size) const; + // Sets file access property list to use the H5FD_DIRECT driver. + void setFileAccDirect(size_t boundary, size_t block_size, size_t cbuf_size) const; - // Retrieves information about the direct file access property list. - void getFileAccDirect(size_t &boundary, size_t &block_size, size_t &cbuf_size) const; + // Retrieves information about the direct file access property list. + void getFileAccDirect(size_t &boundary, size_t &block_size, size_t &cbuf_size) const; - // Sets garbage collecting references flag. - void setGcReferences(unsigned gc_ref = 0) const; + // Sets garbage collecting references flag. + void setGcReferences(unsigned gc_ref = 0) const; - // Returns garbage collecting references setting. - unsigned getGcReferences() const; + // Returns garbage collecting references setting. + unsigned getGcReferences() const; - // Sets bounds on versions of library format to be used when creating - // or writing objects. - void setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const; + // Sets bounds on versions of library format to be used when creating + // or writing objects. + void setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const; - // Gets the current settings for the library version format bounds. - void getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const; + // Gets the current settings for the library version format bounds. + void getLibverBounds(H5F_libver_t &libver_low, H5F_libver_t &libver_high) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FileAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FileAccPropList"); + } - // Copy constructor: same as the original FileAccPropList. - FileAccPropList(const FileAccPropList& original); + // Copy constructor: same as the original FileAccPropList. + FileAccPropList(const FileAccPropList &original); - // Creates a copy of an existing file access property list - // using the property list id. - FileAccPropList (const hid_t plist_id); + // Creates a copy of an existing file access property list + // using the property list id. + FileAccPropList(const hid_t plist_id); - // Noop destructor - virtual ~FileAccPropList(); + // Noop destructor + virtual ~FileAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static FileAccPropList* DEFAULT_; + private: + static FileAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static FileAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static FileAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index 9b0fecc..ccc9251 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -FileCreatPropList* FileCreatPropList::DEFAULT_ = 0; +FileCreatPropList *FileCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: FileCreatPropList::getConstant @@ -39,13 +39,13 @@ FileCreatPropList* FileCreatPropList::DEFAULT_ = 0; // object, throw a PropListIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -FileCreatPropList* FileCreatPropList::getConstant() +FileCreatPropList * +FileCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -54,8 +54,9 @@ FileCreatPropList* FileCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new FileCreatPropList(H5P_FILE_CREATE); else - throw PropListIException("FileCreatPropList::getConstant", "FileCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("FileCreatPropList::getConstant", + "FileCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -64,7 +65,8 @@ FileCreatPropList* FileCreatPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void FileCreatPropList::deleteConstants() +void +FileCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -73,7 +75,7 @@ void FileCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property //-------------------------------------------------------------------------- -const FileCreatPropList& FileCreatPropList::DEFAULT = *getConstant(); +const FileCreatPropList &FileCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -82,7 +84,9 @@ const FileCreatPropList& FileCreatPropList::DEFAULT = *getConstant(); ///\brief Default constructor: Creates a file create property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) {} +FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: FileCreatPropList copy constructor @@ -91,7 +95,9 @@ FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) {} ///\param original - IN: FileCreatPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList(const FileCreatPropList& original) : PropList( original ) {} +FileCreatPropList::FileCreatPropList(const FileCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: FileCreatPropList overloaded constructor @@ -100,7 +106,9 @@ FileCreatPropList::FileCreatPropList(const FileCreatPropList& original) : PropLi ///\param plist_id - IN: FileCreatPropList id to use // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- @@ -115,13 +123,12 @@ FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) /// Any (or even all) of the output arguments can be null pointers. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getVersion(unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr) const +void +FileCreatPropList::getVersion(unsigned &super, unsigned &freelist, unsigned &stab, unsigned &shhdr) const { herr_t ret_value = H5Pget_version(id, &super, &freelist, &stab, &shhdr); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getVersion", - "H5Pget_version failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getVersion", "H5Pget_version failed"); } } #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -136,13 +143,12 @@ void FileCreatPropList::getVersion(unsigned& super, unsigned& freelist, unsigned /// of 2 equal to 512 or greater (512, 1024, 2048, etc.) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setUserblock(hsize_t size) const +void +FileCreatPropList::setUserblock(hsize_t size) const { herr_t ret_value = H5Pset_userblock(id, size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setUserblock", - "H5Pset_userblock failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setUserblock", "H5Pset_userblock failed"); } } @@ -153,16 +159,15 @@ void FileCreatPropList::setUserblock(hsize_t size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hsize_t FileCreatPropList::getUserblock() const +hsize_t +FileCreatPropList::getUserblock() const { hsize_t userblock_size; - herr_t ret_value = H5Pget_userblock(id, &userblock_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getUserblock", - "H5Pget_userblock failed"); + herr_t ret_value = H5Pget_userblock(id, &userblock_size); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getUserblock", "H5Pget_userblock failed"); } - return(userblock_size); + return (userblock_size); } //-------------------------------------------------------------------------- @@ -177,13 +182,12 @@ hsize_t FileCreatPropList::getUserblock() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const +void +FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const { herr_t ret_value = H5Pset_sizes(id, sizeof_addr, sizeof_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setSizes", - "H5Pset_sizes failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setSizes", "H5Pset_sizes failed"); } } @@ -195,13 +199,12 @@ void FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getSizes(size_t& sizeof_addr, size_t& sizeof_size) const +void +FileCreatPropList::getSizes(size_t &sizeof_addr, size_t &sizeof_size) const { herr_t ret_value = H5Pget_sizes(id, &sizeof_addr, &sizeof_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getSizes", - "H5Pget_sizes failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getSizes", "H5Pget_sizes failed"); } } @@ -217,13 +220,12 @@ void FileCreatPropList::getSizes(size_t& sizeof_addr, size_t& sizeof_size) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setSymk(unsigned ik, unsigned lk) const +void +FileCreatPropList::setSymk(unsigned ik, unsigned lk) const { herr_t ret_value = H5Pset_sym_k(id, ik, lk); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setSymk", - "H5Pset_sym_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setSymk", "H5Pset_sym_k failed"); } } @@ -238,13 +240,12 @@ void FileCreatPropList::setSymk(unsigned ik, unsigned lk) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getSymk(unsigned& ik, unsigned& lk) const +void +FileCreatPropList::getSymk(unsigned &ik, unsigned &lk) const { herr_t ret_value = H5Pget_sym_k(id, &ik, &lk); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getSymk", - "H5Pget_sym_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getSymk", "H5Pget_sym_k failed"); } } @@ -259,13 +260,12 @@ void FileCreatPropList::getSymk(unsigned& ik, unsigned& lk) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setIstorek(unsigned ik) const +void +FileCreatPropList::setIstorek(unsigned ik) const { herr_t ret_value = H5Pset_istore_k(id, ik); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setIstorek", - "H5Pset_istore_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setIstorek", "H5Pset_istore_k failed"); } } @@ -279,16 +279,15 @@ void FileCreatPropList::setIstorek(unsigned ik) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -unsigned FileCreatPropList::getIstorek() const +unsigned +FileCreatPropList::getIstorek() const { unsigned ik; - herr_t ret_value = H5Pget_istore_k(id, &ik); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getIstorek", - "H5Pget_istore_k failed"); + herr_t ret_value = H5Pget_istore_k(id, &ik); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getIstorek", "H5Pget_istore_k failed"); } - return(ik); + return (ik); } //-------------------------------------------------------------------------- @@ -309,13 +308,14 @@ unsigned FileCreatPropList::getIstorek() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const +void +FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, + hsize_t threshold) const { herr_t ret_value = H5Pset_file_space_strategy(id, strategy, persist, threshold); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::setFileSpaceStrategy", - "H5Pset_file_space_strategy failed"); + "H5Pset_file_space_strategy failed"); } } @@ -329,13 +329,14 @@ void FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbo ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const +void +FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t &strategy, hbool_t &persist, + hsize_t &threshold) const { herr_t ret_value = H5Pget_file_space_strategy(id, &strategy, &persist, &threshold); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::getFileSpaceStrategy", - "H5Pget_file_space_strategy failed"); + "H5Pget_file_space_strategy failed"); } } @@ -346,13 +347,13 @@ void FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hb ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const +void +FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const { herr_t ret_value = H5Pset_file_space_page_size(id, fsp_psize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::setFileSpacePagesize", - "H5Pset_file_space_page_size failed"); + "H5Pset_file_space_page_size failed"); } } @@ -364,16 +365,16 @@ void FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -hsize_t FileCreatPropList::getFileSpacePagesize() const +hsize_t +FileCreatPropList::getFileSpacePagesize() const { hsize_t fsp_psize = 0; - herr_t ret_value = H5Pget_file_space_page_size(id, &fsp_psize); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_file_space_page_size(id, &fsp_psize); + if (ret_value < 0) { throw PropListIException("FileCreatPropList::getFileSpacePagesize", - "H5Pget_file_space_page_size failed"); + "H5Pget_file_space_page_size failed"); } - return(fsp_psize); + return (fsp_psize); } //-------------------------------------------------------------------------- @@ -381,6 +382,8 @@ hsize_t FileCreatPropList::getFileSpacePagesize() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::~FileCreatPropList() {} +FileCreatPropList::~FileCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index cc28920..d19b60d 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -23,82 +23,86 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP FileCreatPropList : public PropList { - public: - ///\brief Default file creation property list. - static const FileCreatPropList& DEFAULT; + public: + ///\brief Default file creation property list. + static const FileCreatPropList &DEFAULT; - // Creates a file create property list. - FileCreatPropList(); + // Creates a file create property list. + FileCreatPropList(); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves version information for various parts of a file. - void getVersion(unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr) const; + // Retrieves version information for various parts of a file. + void getVersion(unsigned &super, unsigned &freelist, unsigned &stab, unsigned &shhdr) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Sets the userblock size field of a file creation property list. - void setUserblock(hsize_t size) const; + // Sets the userblock size field of a file creation property list. + void setUserblock(hsize_t size) const; - // Gets the size of a user block in this file creation property list. - hsize_t getUserblock() const; + // Gets the size of a user block in this file creation property list. + hsize_t getUserblock() const; - // Retrieves the size-of address and size quantities stored in a - // file according to this file creation property list. - void getSizes(size_t& sizeof_addr, size_t& sizeof_size) const; + // Retrieves the size-of address and size quantities stored in a + // file according to this file creation property list. + void getSizes(size_t &sizeof_addr, size_t &sizeof_size) const; - // Sets file size-of addresses and sizes. - void setSizes(size_t sizeof_addr = 4, size_t sizeof_size = 4) const; + // Sets file size-of addresses and sizes. + void setSizes(size_t sizeof_addr = 4, size_t sizeof_size = 4) const; - // Retrieves the size of the symbol table B-tree 1/2 rank and the - // symbol table leaf node 1/2 size. - void getSymk(unsigned& int_nodes_k, unsigned& leaf_nodes_k) const; + // Retrieves the size of the symbol table B-tree 1/2 rank and the + // symbol table leaf node 1/2 size. + void getSymk(unsigned &int_nodes_k, unsigned &leaf_nodes_k) const; - // Sets the size of parameters used to control the symbol table nodes. - void setSymk(unsigned int_nodes_k, unsigned leaf_nodes_k) const; + // Sets the size of parameters used to control the symbol table nodes. + void setSymk(unsigned int_nodes_k, unsigned leaf_nodes_k) const; - // Returns the 1/2 rank of an indexed storage B-tree. - unsigned getIstorek() const; + // Returns the 1/2 rank of an indexed storage B-tree. + unsigned getIstorek() const; - // Sets the size of parameter used to control the B-trees for - // indexing chunked datasets. - void setIstorek(unsigned ik) const; + // Sets the size of parameter used to control the B-trees for + // indexing chunked datasets. + void setIstorek(unsigned ik) const; - // Sets the strategy and the threshold value that the library will - // will employ in managing file space. - void setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const; + // Sets the strategy and the threshold value that the library will + // will employ in managing file space. + void setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const; - // Returns the strategy that the library uses in managing file space. - void getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const; + // Returns the strategy that the library uses in managing file space. + void getFileSpaceStrategy(H5F_fspace_strategy_t &strategy, hbool_t &persist, hsize_t &threshold) const; - // Sets the file space page size for paged aggregation. - void setFileSpacePagesize(hsize_t fsp_psize) const; + // Sets the file space page size for paged aggregation. + void setFileSpacePagesize(hsize_t fsp_psize) const; - // Returns the threshold value that the library uses in tracking free - // space sections. - hsize_t getFileSpacePagesize() const; + // Returns the threshold value that the library uses in tracking free + // space sections. + hsize_t getFileSpacePagesize() const; - ///\brief Returns this class name. - virtual H5std_string fromClass() const { return("FileCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FileCreatPropList"); + } - // Copy constructor: same as the original FileCreatPropList. - FileCreatPropList(const FileCreatPropList& orig); + // Copy constructor: same as the original FileCreatPropList. + FileCreatPropList(const FileCreatPropList &orig); - // Creates a copy of an existing file create property list - // using the property list id. - FileCreatPropList(const hid_t plist_id); + // Creates a copy of an existing file create property list + // using the property list id. + FileCreatPropList(const hid_t plist_id); - // Noop destructor - virtual ~FileCreatPropList(); + // Noop destructor + virtual ~FileCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static FileCreatPropList* DEFAULT_; + private: + static FileCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static FileCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static FileCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index b9ecded..677c3e6 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -41,15 +41,17 @@ #include "H5Alltypes.h" namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; //-------------------------------------------------------------------------- // Function H5File default constructor ///\brief Default constructor: creates a stub H5File object. // December 2000 //-------------------------------------------------------------------------- -H5File::H5File() : Group(), id(H5I_INVALID_HID) {} +H5File::H5File() : Group(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: H5File overloaded constructor @@ -81,11 +83,14 @@ H5File::H5File() : Group(), id(H5I_INVALID_HID) {} // block here to catch then re-throw it. -BMR 2013/03/21 // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) +H5File::H5File(const char *name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) + : Group(), id(H5I_INVALID_HID) { try { p_get_file(name, flags, create_plist, access_plist); - } catch (FileIException& open_file) { + } + catch (FileIException &open_file) { throw open_file; } } @@ -106,11 +111,14 @@ H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& cr // block here to catch then re-throw it. -BMR 2013/03/21 // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) +H5File::H5File(const H5std_string &name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) + : Group(), id(H5I_INVALID_HID) { try { p_get_file(name.c_str(), flags, create_plist, access_plist); - } catch (FileIException& open_file) { + } + catch (FileIException &open_file) { throw open_file; } } @@ -123,26 +131,26 @@ H5File::H5File(const H5std_string& name, unsigned int flags, const FileCreatProp // - removed H5F_ACC_CREAT because H5Fcreate will fail with // H5F_ACC_CREAT. - BMR, Sep 17, 2014 //-------------------------------------------------------------------------- -void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) +void +H5File::p_get_file(const char *name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) { // These bits only set for creation, so if any of them are set, // create the file. - if (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)) - { + if (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC)) { hid_t create_plist_id = create_plist.getId(); hid_t access_plist_id = access_plist.getId(); - id = H5Fcreate(name, flags, create_plist_id, access_plist_id); - if (id < 0) // throw an exception when open/create fail + id = H5Fcreate(name, flags, create_plist_id, access_plist_id); + if (id < 0) // throw an exception when open/create fail { throw FileIException("H5File constructor", "H5Fcreate failed"); } } // Open the file if none of the bits above are set. - else - { + else { hid_t access_plist_id = access_plist.getId(); - id = H5Fopen(name, flags, access_plist_id); - if (id < 0) // throw an exception when open/create fail + id = H5Fopen(name, flags, access_plist_id); + if (id < 0) // throw an exception when open/create fail { throw FileIException("H5File constructor", "H5Fopen failed"); } @@ -176,7 +184,7 @@ H5File::H5File(hid_t existing_id) : Group() ///\param original - IN: H5File instance to copy // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const H5File& original) : Group() +H5File::H5File(const H5File &original) : Group() { id = original.getId(); incRefCount(); // increment number of references to this id @@ -190,7 +198,8 @@ H5File::H5File(const H5File& original) : Group() ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const char* name) +bool +H5File::isHdf5(const char *name) { // Calls C routine H5Fis_accessible to determine whether the file is in // HDF5 format. It returns positive value, 0, or negative value @@ -213,9 +222,10 @@ bool H5File::isHdf5(const char* name) ///\param name - IN: Name of the file - \c H5std_string // December 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const H5std_string& name) +bool +H5File::isHdf5(const H5std_string &name) { - return(isHdf5( name.c_str())); + return (isHdf5(name.c_str())); } //-------------------------------------------------------------------------- @@ -228,12 +238,13 @@ bool H5File::isHdf5(const H5std_string& name) ///\exception H5::FileIException // September 2018 //-------------------------------------------------------------------------- -bool H5File::isAccessible(const char* name, const FileAccPropList& access_plist) +bool +H5File::isAccessible(const char *name, const FileAccPropList &access_plist) { // Calls C routine H5Fis_accessible to determine whether the file is in // HDF5 format. It returns positive value, 0, or negative value - hid_t access_plist_id = access_plist.getId(); - htri_t ret_value = H5Fis_accessible(name, access_plist_id); + hid_t access_plist_id = access_plist.getId(); + htri_t ret_value = H5Fis_accessible(name, access_plist_id); if (ret_value > 0) return true; else if (ret_value == 0) @@ -253,9 +264,10 @@ bool H5File::isAccessible(const char* name, const FileAccPropList& access_plist) /// FileAccPropList::DEFAULT // September 2018 //-------------------------------------------------------------------------- -bool H5File::isAccessible(const H5std_string& name, const FileAccPropList& access_plist) +bool +H5File::isAccessible(const H5std_string &name, const FileAccPropList &access_plist) { - return(isAccessible(name.c_str(), access_plist)); + return (isAccessible(name.c_str(), access_plist)); } //-------------------------------------------------------------------------- @@ -276,18 +288,19 @@ bool H5File::isAccessible(const H5std_string& name, const FileAccPropList& acces /// // October 2005 //-------------------------------------------------------------------------- -void H5File::openFile(const char* name, unsigned int flags, const FileAccPropList& access_plist) +void +H5File::openFile(const char *name, unsigned int flags, const FileAccPropList &access_plist) { try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException("H5File::openFile", close_error.getDetailMsg()); } hid_t access_plist_id = access_plist.getId(); - id = H5Fopen (name, flags, access_plist_id); - if (id < 0) // throw an exception when open fails + id = H5Fopen(name, flags, access_plist_id); + if (id < 0) // throw an exception when open fails { throw FileIException("H5File::openFile", "H5Fopen failed"); } @@ -303,7 +316,8 @@ void H5File::openFile(const char* name, unsigned int flags, const FileAccPropLis /// FileAccPropList::DEFAULT // December 2000 //-------------------------------------------------------------------------- -void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAccPropList& access_plist) +void +H5File::openFile(const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist) { openFile(name.c_str(), flags, access_plist); } @@ -324,12 +338,13 @@ void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAc // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void H5File::reOpen() +void +H5File::reOpen() { try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException("H5File::reOpen", close_error.getDetailMsg()); } @@ -347,19 +362,18 @@ void H5File::reOpen() ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -FileCreatPropList H5File::getCreatePlist() const +FileCreatPropList +H5File::getCreatePlist() const { hid_t create_plist_id = H5Fget_create_plist(id); // if H5Fget_create_plist returns a valid id, create and return // the FileCreatPropList object for this property list - if (create_plist_id > 0) - { - FileCreatPropList create_plist(create_plist_id); - return(create_plist); + if (create_plist_id > 0) { + FileCreatPropList create_plist(create_plist_id); + return (create_plist); } - else - { + else { throw FileIException("H5File::getCreatePlist", "H5Fget_create_plist failed"); } } @@ -371,16 +385,16 @@ FileCreatPropList H5File::getCreatePlist() const ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -FileAccPropList H5File::getAccessPlist() const +FileAccPropList +H5File::getAccessPlist() const { hid_t access_plist_id = H5Fget_access_plist(id); // if H5Fget_access_plist returns a valid id, create and return // the FileAccPropList object for this property list - if (access_plist_id > 0) - { - FileAccPropList access_plist(access_plist_id); - return access_plist; + if (access_plist_id > 0) { + FileAccPropList access_plist(access_plist_id); + return access_plist; } else // Raise an exception { @@ -398,11 +412,11 @@ FileAccPropList H5File::getAccessPlist() const /// superblock extension, free space management, and shared object // February 2017 //-------------------------------------------------------------------------- -void H5File::getFileInfo(H5F_info2_t& file_info) const +void +H5File::getFileInfo(H5F_info2_t &file_info) const { herr_t ret_value = H5Fget_info2(id, &file_info); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getFileInfo", "H5Fget_info2 failed"); } } @@ -414,17 +428,16 @@ void H5File::getFileInfo(H5F_info2_t& file_info) const ///\exception H5::FileIException // May 2004 //-------------------------------------------------------------------------- -hssize_t H5File::getFreeSpace() const +hssize_t +H5File::getFreeSpace() const { hssize_t free_space = H5Fget_freespace(id); - if (free_space < 0) - { + if (free_space < 0) { throw FileIException("H5File::getFreeSpace", "H5Fget_freespace failed"); } return (free_space); } - //-------------------------------------------------------------------------- // Function: H5File::getObjCount ///\brief Returns the number of opened object IDs (files, datasets, @@ -446,11 +459,11 @@ hssize_t H5File::getFreeSpace() const /// Multiple object types can be combined with the logical OR operator (|). // May 2004 //-------------------------------------------------------------------------- -ssize_t H5File::getObjCount(unsigned types) const +ssize_t +H5File::getObjCount(unsigned types) const { ssize_t num_objs = H5Fget_obj_count(id, types); - if (num_objs < 0) - { + if (num_objs < 0) { throw FileIException("H5File::getObjCount", "H5Fget_obj_count failed"); } return (num_objs); @@ -481,11 +494,11 @@ ssize_t H5File::getObjCount(unsigned types) const // Notes: will do the overload for this one after hearing from Quincey??? // May 2004 //-------------------------------------------------------------------------- -void H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const +void +H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const { ssize_t ret_value = H5Fget_obj_ids(id, types, max_objs, oid_list); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getObjIDs", "H5Fget_obj_ids failed"); } } @@ -509,12 +522,12 @@ void H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const /// closed and reopened or opened during a subsequent session. // May 2004 //-------------------------------------------------------------------------- -void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const +void +H5File::getVFDHandle(const FileAccPropList &fapl, void **file_handle) const { - hid_t fapl_id = fapl.getId(); + hid_t fapl_id = fapl.getId(); herr_t ret_value = H5Fget_vfd_handle(id, fapl_id, file_handle); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); } } @@ -534,7 +547,7 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) const +// void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) const //{ // getVFDHandle((const FileAccPropList)fapl, file_handle); //} @@ -549,11 +562,11 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const ///\exception H5::FileIException // May 2004 //-------------------------------------------------------------------------- -void H5File::getVFDHandle(void **file_handle) const +void +H5File::getVFDHandle(void **file_handle) const { herr_t ret_value = H5Fget_vfd_handle(id, H5P_DEFAULT, file_handle); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); } } @@ -568,12 +581,12 @@ void H5File::getVFDHandle(void **file_handle) const /// order to learn the true size of the underlying file. // Programmer Raymond Lu - June 24, 2004 //-------------------------------------------------------------------------- -hsize_t H5File::getFileSize() const +hsize_t +H5File::getFileSize() const { hsize_t file_size; - herr_t ret_value = H5Fget_filesize(id, &file_size); - if (ret_value < 0) - { + herr_t ret_value = H5Fget_filesize(id, &file_size); + if (ret_value < 0) { throw FileIException("H5File::getFileSize", "H5Fget_filesize failed"); } return (file_size); @@ -589,12 +602,12 @@ hsize_t H5File::getFileSize() const /// order to retrieve the unique 'file number' for the file. // Programmer Quincey Koziol - April 13, 2019 //-------------------------------------------------------------------------- -unsigned long H5File::getFileNum() const +unsigned long +H5File::getFileNum() const { - unsigned long fileno = 0; - herr_t ret_value = H5Fget_fileno(id, &fileno); - if (ret_value < 0) - { + unsigned long fileno = 0; + herr_t ret_value = H5Fget_fileno(id, &fileno); + if (ret_value < 0) { throw FileIException("H5File::getFileNum", "H5Fget_fileno failed"); } return (fileno); @@ -612,9 +625,10 @@ unsigned long H5File::getFileNum() const // IdComponent::getId now becomes pure virtual function. // May, 2008 //-------------------------------------------------------------------------- -hid_t H5File::getId() const +hid_t +H5File::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -626,7 +640,8 @@ hid_t H5File::getId() const // This function is replaced by the above function reOpen. // December 2000 //-------------------------------------------------------------------------- -void H5File::reopen() +void +H5File::reopen() { H5File::reOpen(); } @@ -643,9 +658,10 @@ void H5File::reopen() // After HDFFV-9920, the Group's methods can use getId() and // getLocId() is kept for backward compatibility. //-------------------------------------------------------------------------- -hid_t H5File::getLocId() const +hid_t +H5File::getLocId() const { - return(getId()); + return (getId()); } //-------------------------------------------------------------------------- @@ -660,13 +676,14 @@ hid_t H5File::getLocId() const // Then the object's id is reset to the new id. // December 2000 //-------------------------------------------------------------------------- -void H5File::p_setId(const hid_t new_id) +void +H5File::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& E) { + catch (Exception &E) { throw FileIException("H5File::p_setId", E.getDetailMsg()); } // reset object's id to the given id @@ -681,13 +698,12 @@ void H5File::p_setId(const hid_t new_id) ///\exception H5::FileIException // March 2005 //-------------------------------------------------------------------------- -void H5File::close() +void +H5File::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Fclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::close", "H5Fclose failed"); } // reset the id @@ -708,7 +724,8 @@ void H5File::close() // an implementation of H5File. // December 2000 //-------------------------------------------------------------------------- -void H5File::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +H5File::throwException(const H5std_string &func_name, const H5std_string &msg) const { H5std_string full_name = func_name; full_name.insert(0, "H5File::"); @@ -729,9 +746,10 @@ H5File::~H5File() { try { close(); - } catch (Exception& close_error) { + } + catch (Exception &close_error) { cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 1b1227f..9231d5f 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -23,111 +23,117 @@ namespace H5 { */ // Inheritance: Group -> CommonFG/H5Object -> H5Location -> IdComponent class H5_DLLCPP H5File : public Group { - public: - // Creates or opens an HDF5 file. - H5File(const char* name, unsigned int flags, - const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - H5File(const H5std_string& name, unsigned int flags, - const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + public: + // Creates or opens an HDF5 file. + H5File(const char *name, unsigned int flags, + const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT, + const FileAccPropList & access_plist = FileAccPropList::DEFAULT); + H5File(const H5std_string &name, unsigned int flags, + const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT, + const FileAccPropList & access_plist = FileAccPropList::DEFAULT); - // Open the file - void openFile(const H5std_string& name, unsigned int flags, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - void openFile(const char* name, unsigned int flags, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + // Open the file + void openFile(const H5std_string &name, unsigned int flags, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); + void openFile(const char *name, unsigned int flags, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); - // Close this file. - virtual void close(); + // Close this file. + virtual void close(); - // Gets a copy of the access property list of this file. - FileAccPropList getAccessPlist() const; + // Gets a copy of the access property list of this file. + FileAccPropList getAccessPlist() const; - // Gets a copy of the creation property list of this file. - FileCreatPropList getCreatePlist() const; + // Gets a copy of the creation property list of this file. + FileCreatPropList getCreatePlist() const; - // Gets general information about this file. - void getFileInfo(H5F_info2_t& file_info) const; + // Gets general information about this file. + void getFileInfo(H5F_info2_t &file_info) const; - // Returns the amount of free space in the file. - hssize_t getFreeSpace() const; + // Returns the amount of free space in the file. + hssize_t getFreeSpace() const; - // Returns the number of opened object IDs (files, datasets, groups - // and datatypes) in the same file. - ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const; + // Returns the number of opened object IDs (files, datasets, groups + // and datatypes) in the same file. + ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const; - // Retrieves a list of opened object IDs (files, datasets, groups - // and datatypes) in the same file. - void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; + // Retrieves a list of opened object IDs (files, datasets, groups + // and datatypes) in the same file. + void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; - // Returns the pointer to the file handle of the low-level file driver. - void getVFDHandle(void **file_handle) const; - void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const; - //void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1 + // Returns the pointer to the file handle of the low-level file driver. + void getVFDHandle(void **file_handle) const; + void getVFDHandle(const FileAccPropList &fapl, void **file_handle) const; + // void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1 - // Returns the file size of the HDF5 file. - hsize_t getFileSize() const; + // Returns the file size of the HDF5 file. + hsize_t getFileSize() const; - // Returns the 'file number' of the HDF5 file. - unsigned long getFileNum() const; + // Returns the 'file number' of the HDF5 file. + unsigned long getFileNum() const; - // Determines if a file, specified by its name, is in HDF5 format - static bool isHdf5(const char* name); - static bool isHdf5(const H5std_string& name); + // Determines if a file, specified by its name, is in HDF5 format + static bool isHdf5(const char *name); + static bool isHdf5(const H5std_string &name); - // Determines if a file, specified by its name, can be accessed as HDF5 - static bool isAccessible(const char* name, const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - static bool isAccessible(const H5std_string& name, const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + // Determines if a file, specified by its name, can be accessed as HDF5 + static bool isAccessible(const char * name, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); + static bool isAccessible(const H5std_string & name, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); - // Reopens this file. - void reOpen(); // added for better name + // Reopens this file. + void reOpen(); // added for better name #ifndef DOXYGEN_SHOULD_SKIP_THIS - void reopen(); // obsolete in favor of reOpen() + void reopen(); // obsolete in favor of reOpen() - // Creates an H5File using an existing file id. Not recommended - // in applications. - H5File(hid_t existing_id); + // Creates an H5File using an existing file id. Not recommended + // in applications. + H5File(hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("H5File"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("H5File"); + } - // Throw file exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + // Throw file exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const; - // For CommonFG to get the file id. - virtual hid_t getLocId() const; + // For CommonFG to get the file id. + virtual hid_t getLocId() const; - // Default constructor - H5File(); + // Default constructor + H5File(); - // Copy constructor: same as the original H5File. - H5File(const H5File& original); + // Copy constructor: same as the original H5File. + H5File(const H5File &original); - // Gets the HDF5 file id. - virtual hid_t getId() const; + // Gets the HDF5 file id. + virtual hid_t getId() const; - // H5File destructor. - virtual ~H5File(); + // H5File destructor. + virtual ~H5File(); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the HDF5 file id. - virtual void p_setId(const hid_t new_id); + // Sets the HDF5 file id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 file id + private: + hid_t id; // HDF5 file id - // This function is private and contains common code between the - // constructors taking a string or a char* - void p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist); + // This function is private and contains common code between the + // constructors taking a string or a char* + void p_get_file(const char *name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist); }; // end of H5File } // namespace H5 #endif // __H5File_H - diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index aba826e..3941f60 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -40,7 +40,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub floating-point datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType() {} +FloatType::FloatType() +{ +} //-------------------------------------------------------------------------- // Function: FloatType overloaded constructor @@ -49,7 +51,7 @@ FloatType::FloatType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const PredType& pred_type) : AtomType() +FloatType::FloatType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -63,14 +65,18 @@ FloatType::FloatType(const PredType& pred_type) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const hid_t existing_id) : AtomType( existing_id ) {} +FloatType::FloatType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: FloatType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const FloatType& original) : AtomType( original ){} +FloatType::FloatType(const FloatType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: FloatType overloaded constructor @@ -80,13 +86,12 @@ FloatType::FloatType(const FloatType& original) : AtomType( original ){} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const DataSet& dataset) : AtomType() +FloatType::FloatType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("FloatType constructor", "H5Dget_type failed"); } } @@ -105,7 +110,7 @@ FloatType::FloatType(const DataSet& dataset) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -FloatType::FloatType(const H5Location& loc, const char *dtype_name) : AtomType() +FloatType::FloatType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -124,7 +129,7 @@ FloatType::FloatType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -FloatType::FloatType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +FloatType::FloatType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -137,7 +142,8 @@ FloatType::FloatType(const H5Location& loc, const H5std_string& dtype_name) : At ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* FloatType::decode() const +DataType * +FloatType::decode() const { hid_t encoded_flttype_id = H5I_INVALID_HID; try { @@ -148,7 +154,7 @@ DataType* FloatType::decode() const } FloatType *encoded_flttype = new FloatType; encoded_flttype->p_setId(encoded_flttype_id); - return(encoded_flttype); + return (encoded_flttype); } //-------------------------------------------------------------------------- @@ -162,11 +168,11 @@ DataType* FloatType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize) const +void +FloatType::getFields(size_t &spos, size_t &epos, size_t &esize, size_t &mpos, size_t &msize) const { herr_t ret_value = H5Tget_fields(id, &spos, &epos, &esize, &mpos, &msize); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::getFields", "H5Tget_fields failed"); } } @@ -183,11 +189,11 @@ void FloatType::getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpo ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const +void +FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const { herr_t ret_value = H5Tset_fields(id, spos, epos, esize, mpos, msize); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setFields", "H5Tset_fields failed"); } } @@ -199,15 +205,15 @@ void FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, s ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t FloatType::getEbias() const +size_t +FloatType::getEbias() const { size_t ebias = H5Tget_ebias(id); // Returns the bias if successful - if (ebias == 0) - { + if (ebias == 0) { throw DataTypeIException("FloatType::getEbias", "H5Tget_ebias failed - returned exponent bias as 0"); } - return(ebias); + return (ebias); } //-------------------------------------------------------------------------- @@ -217,11 +223,11 @@ size_t FloatType::getEbias() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setEbias(size_t ebias) const +void +FloatType::setEbias(size_t ebias) const { herr_t ret_value = H5Tset_ebias(id, ebias); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setEbias", "H5Tset_ebias failed"); } } @@ -241,12 +247,12 @@ void FloatType::setEbias(size_t ebias) const /// \a norm_string. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const +H5T_norm_t +FloatType::getNorm(H5std_string &norm_string) const { - H5T_norm_t norm = H5Tget_norm(id); // C routine + H5T_norm_t norm = H5Tget_norm(id); // C routine // Returns a valid normalization type if successful - if (norm == H5T_NORM_ERROR) - { + if (norm == H5T_NORM_ERROR) { throw DataTypeIException("FloatType::getNorm", "H5Tget_norm failed - returned H5T_NORM_ERROR"); } if (norm == H5T_NORM_IMPLIED) @@ -255,7 +261,7 @@ H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const norm_string = "H5T_NORM_MSBSET (1)"; else if (norm == H5T_NORM_NONE) norm_string = "H5T_NORM_NONE (2)"; - return(norm); + return (norm); } //-------------------------------------------------------------------------- @@ -270,11 +276,11 @@ H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const /// \li \c H5T_NORM_NONE (2) - Mantissa is not normalized // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setNorm(H5T_norm_t norm) const +void +FloatType::setNorm(H5T_norm_t norm) const { herr_t ret_value = H5Tset_norm(id, norm); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setNorm", "H5Tset_norm failed"); } } @@ -294,12 +300,12 @@ void FloatType::setNorm(H5T_norm_t norm) const /// \a pad_string. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const +H5T_pad_t +FloatType::getInpad(H5std_string &pad_string) const { H5T_pad_t pad_type = H5Tget_inpad(id); // Returns a valid padding type if successful - if (pad_type == H5T_PAD_ERROR) - { + if (pad_type == H5T_PAD_ERROR) { throw DataTypeIException("FloatType::getInpad", "H5Tget_inpad failed - returned H5T_PAD_ERROR"); } if (pad_type == H5T_PAD_ZERO) @@ -308,7 +314,7 @@ H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const pad_string = "H5T_PAD_ONE (1)"; else if (pad_type == H5T_PAD_BACKGROUND) pad_string = "H5T_PAD_BACKGROUD (2)"; - return(pad_type); + return (pad_type); } //-------------------------------------------------------------------------- @@ -328,11 +334,11 @@ H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setInpad(H5T_pad_t inpad) const +void +FloatType::setInpad(H5T_pad_t inpad) const { herr_t ret_value = H5Tset_inpad(id, inpad); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setInpad", "H5Tset_inpad failed"); } } @@ -342,6 +348,8 @@ void FloatType::setInpad(H5T_pad_t inpad) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::~FloatType() {} +FloatType::~FloatType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index f74a9ae..2368113 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -23,59 +23,63 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP FloatType : public AtomType { - public: - // Creates a floating-point type using a predefined type. - FloatType(const PredType& pred_type); + public: + // Creates a floating-point type using a predefined type. + FloatType(const PredType &pred_type); - // Gets the floating-point datatype of the specified dataset. - FloatType(const DataSet& dataset); + // Gets the floating-point datatype of the specified dataset. + FloatType(const DataSet &dataset); - // Constructors that open an HDF5 float datatype, given a location. - FloatType(const H5Location& loc, const char* name); - FloatType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 float datatype, given a location. + FloatType(const H5Location &loc, const char *name); + FloatType(const H5Location &loc, const H5std_string &name); - // Returns an FloatType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an FloatType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the exponent bias of a floating-point type. - size_t getEbias() const; + // Retrieves the exponent bias of a floating-point type. + size_t getEbias() const; - // Sets the exponent bias of a floating-point type. - void setEbias(size_t ebias) const; + // Sets the exponent bias of a floating-point type. + void setEbias(size_t ebias) const; - // Retrieves floating point datatype bit field information. - void getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize) const; + // Retrieves floating point datatype bit field information. + void getFields(size_t &spos, size_t &epos, size_t &esize, size_t &mpos, size_t &msize) const; - // Sets locations and sizes of floating point bit fields. - void setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const; + // Sets locations and sizes of floating point bit fields. + void setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const; - // Retrieves the internal padding type for unused bits in floating-point datatypes. - H5T_pad_t getInpad(H5std_string& pad_string) const; + // Retrieves the internal padding type for unused bits in floating-point datatypes. + H5T_pad_t getInpad(H5std_string &pad_string) const; - // Fills unused internal floating point bits. - void setInpad(H5T_pad_t inpad) const; + // Fills unused internal floating point bits. + void setInpad(H5T_pad_t inpad) const; - // Retrieves mantissa normalization of a floating-point datatype. - H5T_norm_t getNorm(H5std_string& norm_string) const; + // Retrieves mantissa normalization of a floating-point datatype. + H5T_norm_t getNorm(H5std_string &norm_string) const; - // Sets the mantissa normalization of a floating-point datatype. - void setNorm(H5T_norm_t norm) const; + // Sets the mantissa normalization of a floating-point datatype. + void setNorm(H5T_norm_t norm) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FloatType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FloatType"); + } - // Default constructor - FloatType(); + // Default constructor + FloatType(); - // Creates a floating-point datatype using an existing id. - FloatType(const hid_t existing_id); + // Creates a floating-point datatype using an existing id. + FloatType(const hid_t existing_id); - // Copy constructor: same as the original FloatType. - FloatType(const FloatType& original); + // Copy constructor: same as the original FloatType. + FloatType(const FloatType &original); - // Noop destructor. - virtual ~FloatType(); + // Noop destructor. + virtual ~FloatType(); }; // end of FloatType } // namespace H5 diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 7132bdf..f30f03b 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -42,15 +42,17 @@ #include "H5Alltypes.h" namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; //-------------------------------------------------------------------------- // Function: Group default constructor ///\brief Default constructor: creates a stub Group. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {} +Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: Group copy constructor @@ -58,7 +60,7 @@ Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {} ///\param original - IN: Original group to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) +Group::Group(const Group &original) : H5Object(), CommonFG(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -70,11 +72,11 @@ Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -void Group::closeObjId(hid_t obj_id) const +void +Group::closeObjId(hid_t obj_id) const { herr_t ret_value = H5Oclose(obj_id); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::closeObjId", "H5Oclose failed"); } } @@ -91,9 +93,10 @@ void Group::closeObjId(hid_t obj_id) const // After HDFFV-9920, the Group's methods can use getId() and // getLocId() is kept for backward compatibility. //-------------------------------------------------------------------------- -hid_t Group::getLocId() const +hid_t +Group::getLocId() const { - return(getId()); + return (getId()); } //-------------------------------------------------------------------------- @@ -120,7 +123,8 @@ Group::Group(const hid_t existing_id) : H5Object(), CommonFG(), id(existing_id) /// is a datatype that has been named by DataType::commit. // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), CommonFG(), id(H5I_INVALID_HID) +Group::Group(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), CommonFG(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -132,12 +136,13 @@ Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -hsize_t Group::getNumObjs() const +hsize_t +Group::getNumObjs() const { - H5G_info_t ginfo; // Group information + H5G_info_t ginfo; // Group information herr_t ret_value = H5Gget_info(getId(), &ginfo); - if(ret_value < 0) + if (ret_value < 0) throwException("getNumObjs", "H5Gget_info failed"); return (ginfo.nlinks); } @@ -155,14 +160,14 @@ hsize_t Group::getNumObjs() const /// the object's type. // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -hid_t Group::getObjId(const char* obj_name, const PropList& plist) const +hid_t +Group::getObjId(const char *obj_name, const PropList &plist) const { hid_t ret_value = H5Oopen(getId(), obj_name, plist.getId()); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::getObjId", "H5Oopen failed"); } - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -175,9 +180,10 @@ hid_t Group::getObjId(const char* obj_name, const PropList& plist) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const +hid_t +Group::getObjId(const H5std_string &obj_name, const PropList &plist) const { - return(getObjId(obj_name.c_str(), plist)); + return (getObjId(obj_name.c_str(), plist)); } //-------------------------------------------------------------------------- @@ -192,9 +198,10 @@ hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t Group::getId() const +hid_t +Group::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -210,13 +217,14 @@ hid_t Group::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Group::p_setId(const hid_t new_id) +void +Group::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throwException("Group::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -231,13 +239,12 @@ void Group::p_setId(const hid_t new_id) ///\exception H5::GroupIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void Group::close() +void +Group::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Gclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::close", "H5Gclose failed"); } // reset the id @@ -258,7 +265,8 @@ void Group::close() // an implementation of Group. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Group::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +Group::throwException(const H5std_string &func_name, const H5std_string &msg) const { H5std_string full_name = func_name; full_name.insert(0, "Group::"); @@ -280,9 +288,9 @@ Group::~Group() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "Group::~Group - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 70b6bff..7b9dc54 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -22,57 +22,63 @@ namespace H5 { */ // Inheritance: CommonFG/H5Object -> H5Location -> IdComponent class H5_DLLCPP Group : public H5Object, public CommonFG { - public: - // Close this group. - virtual void close(); + public: + // Close this group. + virtual void close(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Group"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("Group"); + } - // Throw group exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + // Throw group exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const; - // for CommonFG to get the file id. - virtual hid_t getLocId() const; + // for CommonFG to get the file id. + virtual hid_t getLocId() const; - // Creates a group by way of dereference. - Group(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // Removed in 1.10.1, because H5Location is baseclass -// Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Creates a group by way of dereference. + Group(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + // Removed in 1.10.1, because H5Location is baseclass + // Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& + // plist = PropList::DEFAULT); - // Returns the number of objects in this group. - hsize_t getNumObjs() const; + // Returns the number of objects in this group. + hsize_t getNumObjs() const; - // Opens an object within a group or a file, i.e., root group. - hid_t getObjId(const char* name, const PropList& plist = PropList::DEFAULT) const; - hid_t getObjId(const H5std_string& name, const PropList& plist = PropList::DEFAULT) const; + // Opens an object within a group or a file, i.e., root group. + hid_t getObjId(const char *name, const PropList &plist = PropList::DEFAULT) const; + hid_t getObjId(const H5std_string &name, const PropList &plist = PropList::DEFAULT) const; - // Closes an object opened by getObjId(). - void closeObjId(hid_t obj_id) const; + // Closes an object opened by getObjId(). + void closeObjId(hid_t obj_id) const; - // default constructor - Group(); + // default constructor + Group(); - // Copy constructor: same as the original Group. - Group(const Group& original); + // Copy constructor: same as the original Group. + Group(const Group &original); - // Gets the group id. - virtual hid_t getId() const; + // Gets the group id. + virtual hid_t getId() const; - // Destructor - virtual ~Group(); + // Destructor + virtual ~Group(); - // Creates a copy of an existing group using its id. - Group(const hid_t group_id); + // Creates a copy of an existing group using its id. + Group(const hid_t group_id); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the group id. - virtual void p_setId(const hid_t new_id); + // Sets the group id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 group id + private: + hid_t id; // HDF5 group id }; // end of Group } // namespace H5 diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 40520aa..485b860 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -13,7 +13,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5Library.h" @@ -38,7 +38,8 @@ bool IdComponent::H5dontAtexit_called = false; ///\brief Increment reference counter for a given id. // Programmer Binh-Minh Ribler - May 2005 //-------------------------------------------------------------------------- -void IdComponent::incRefCount(const hid_t obj_id) const +void +IdComponent::incRefCount(const hid_t obj_id) const { if (p_valid_id(obj_id)) if (H5Iinc_ref(obj_id) < 0) @@ -50,7 +51,8 @@ void IdComponent::incRefCount(const hid_t obj_id) const ///\brief Increment reference counter for the id of this object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IdComponent::incRefCount() const +void +IdComponent::incRefCount() const { incRefCount(getId()); } @@ -63,17 +65,15 @@ void IdComponent::incRefCount() const // Added the check for ref counter to give a little more info // on why H5Idec_ref fails in some cases - BMR 5/19/2005 //-------------------------------------------------------------------------- -void IdComponent::decRefCount(const hid_t obj_id) const +void +IdComponent::decRefCount(const hid_t obj_id) const { if (p_valid_id(obj_id)) - if (H5Idec_ref(obj_id) < 0) - { + if (H5Idec_ref(obj_id) < 0) { if (H5Iget_ref(obj_id) <= 0) - throw IdComponentException(inMemFunc("decRefCount"), - "object ref count is 0 or negative"); + throw IdComponentException(inMemFunc("decRefCount"), "object ref count is 0 or negative"); else - throw IdComponentException(inMemFunc("decRefCount"), - "decrementing object ref count failed"); + throw IdComponentException(inMemFunc("decRefCount"), "decrementing object ref count failed"); } } @@ -82,7 +82,8 @@ void IdComponent::decRefCount(const hid_t obj_id) const ///\brief Decrement reference counter for the id of this object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IdComponent::decRefCount() const +void +IdComponent::decRefCount() const { decRefCount(getId()); } @@ -93,14 +94,15 @@ void IdComponent::decRefCount() const ///\return Reference count // Programmer Binh-Minh Ribler - May 2005 //-------------------------------------------------------------------------- -int IdComponent::getCounter(const hid_t obj_id) const +int +IdComponent::getCounter(const hid_t obj_id) const { int counter = 0; - if (p_valid_id(obj_id)) - { + if (p_valid_id(obj_id)) { counter = H5Iget_ref(obj_id); if (counter < 0) - throw IdComponentException(inMemFunc("incRefCount"), "getting object ref count failed - negative"); + throw IdComponentException(inMemFunc("incRefCount"), + "getting object ref count failed - negative"); } return (counter); } @@ -111,7 +113,8 @@ int IdComponent::getCounter(const hid_t obj_id) const ///\return Reference count // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int IdComponent::getCounter() const +int +IdComponent::getCounter() const { return (getCounter(getId())); } @@ -130,7 +133,8 @@ int IdComponent::getCounter() const /// input object id is invalid. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) +H5I_type_t +IdComponent::getHDFObjType(const hid_t obj_id) { if (obj_id <= 0) return H5I_BADID; // invalid @@ -156,9 +160,10 @@ H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) /// input object id is invalid. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5I_type_t IdComponent::getHDFObjType() const +H5I_type_t +IdComponent::getHDFObjType() const { - return(getHDFObjType(getId())); + return (getHDFObjType(getId())); } //-------------------------------------------------------------------------- @@ -183,14 +188,15 @@ H5I_type_t IdComponent::getHDFObjType() const /// \li \c H5I_ERROR_STACK // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -hsize_t IdComponent::getNumMembers(H5I_type_t type) +hsize_t +IdComponent::getNumMembers(H5I_type_t type) { - hsize_t nmembers = 0; - herr_t ret_value = H5Inmembers(type, &nmembers); + hsize_t nmembers = 0; + herr_t ret_value = H5Inmembers(type, &nmembers); if (ret_value < 0) throw IdComponentException("getNumMembers", "H5Inmembers failed"); else - return(nmembers); + return (nmembers); } //-------------------------------------------------------------------------- @@ -202,7 +208,8 @@ hsize_t IdComponent::getNumMembers(H5I_type_t type) /// reference count of at least 1. // Programmer Binh-Minh Ribler - Mar 1, 2017 //-------------------------------------------------------------------------- -bool IdComponent::isValid(hid_t an_id) +bool +IdComponent::isValid(hid_t an_id) { // Call C function htri_t ret_value = H5Iis_valid(an_id); @@ -236,7 +243,8 @@ bool IdComponent::isValid(hid_t an_id) /// \li \c H5I_ERROR_STACK // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -bool IdComponent::typeExists(H5I_type_t type) +bool +IdComponent::typeExists(H5I_type_t type) { // Call C function htri_t ret_value = H5Itype_exists(type); @@ -266,17 +274,17 @@ bool IdComponent::typeExists(H5I_type_t type) // care of close() and setId takes care incRefCount(). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IdComponent& IdComponent::operator=(const IdComponent& rhs) +IdComponent & +IdComponent::operator=(const IdComponent &rhs) { - if (this != &rhs) - { + if (this != &rhs) { // handling references to this id try { setId(rhs.getId()); // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException(inMemFunc("operator="), close_error.getDetailMsg()); } } @@ -304,7 +312,8 @@ IdComponent& IdComponent::operator=(const IdComponent& rhs) // the id passed to setId is that of another C++ API object, so // setId must call incRefCount. //-------------------------------------------------------------------------- -void IdComponent::setId(const hid_t new_id) +void +IdComponent::setId(const hid_t new_id) { // set to new_id p_setId(new_id); @@ -318,7 +327,9 @@ void IdComponent::setId(const hid_t new_id) ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IdComponent::~IdComponent() {} +IdComponent::~IdComponent() +{ +} // // Implementation of protected functions for HDF5 Reference Interface @@ -338,7 +349,8 @@ IdComponent::~IdComponent() {} /// an exception is thrown. // Programmer Binh-Minh Ribler - Aug 6, 2005 //-------------------------------------------------------------------------- -H5std_string IdComponent::inMemFunc(const char* func_name) const +H5std_string +IdComponent::inMemFunc(const char *func_name) const { H5std_string full_name = func_name; full_name.insert(0, "::"); @@ -355,8 +367,7 @@ IdComponent::IdComponent() { // initH5cpp will register the terminating functions with atexit(). // This should only be done once. - if (!H5cppinit) - { + if (!H5cppinit) { H5Library::initH5cpp(); H5cppinit = true; } @@ -374,7 +385,8 @@ IdComponent::IdComponent() // inherits from H5Location. // Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- -H5std_string IdComponent::p_get_file_name() const +H5std_string +IdComponent::p_get_file_name() const { hid_t temp_id = getId(); @@ -382,28 +394,26 @@ H5std_string IdComponent::p_get_file_name() const ssize_t name_size = H5Fget_name(temp_id, NULL, 0); // If H5Aget_name returns a negative value, raise an exception, - if (name_size < 0) - { + if (name_size < 0) { throw IdComponentException("", "H5Fget_name failed"); } // Call H5Fget_name again to get the actual file name - char* name_C = new char[name_size+1]; // temporary C-string for C API - HDmemset(name_C, 0, name_size+1); // clear buffer + char *name_C = new char[name_size + 1]; // temporary C-string for C API + HDmemset(name_C, 0, name_size + 1); // clear buffer - name_size = H5Fget_name(temp_id, name_C, name_size+1); + name_size = H5Fget_name(temp_id, name_C, name_size + 1); // Check for failure again - if (name_size < 0) - { - delete []name_C; + if (name_size < 0) { + delete[] name_C; throw IdComponentException("", "H5Fget_name failed"); } // Convert the C file name and return H5std_string file_name(name_C); - delete []name_C; - return(file_name); + delete[] name_C; + return (file_name); } // @@ -417,7 +427,8 @@ H5std_string IdComponent::p_get_file_name() const // Return true if id is valid, false, otherwise // Programmer Binh-Minh Ribler - May, 2005 //-------------------------------------------------------------------------- -bool IdComponent::p_valid_id(const hid_t obj_id) +bool +IdComponent::p_valid_id(const hid_t obj_id) { if (obj_id <= 0) return false; @@ -439,4 +450,4 @@ bool IdComponent::p_valid_id(const hid_t obj_id) #endif // DOXYGEN_SHOULD_SKIP_THIS -} +} // namespace H5 diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index b4070b0..8db1af2 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -25,85 +25,88 @@ namespace H5 { rarely needs them. */ class H5_DLLCPP IdComponent { - public: + public: + // Increment reference counter. + void incRefCount(const hid_t obj_id) const; + void incRefCount() const; - // Increment reference counter. - void incRefCount(const hid_t obj_id) const; - void incRefCount() const; + // Decrement reference counter. + void decRefCount(const hid_t obj_id) const; + void decRefCount() const; - // Decrement reference counter. - void decRefCount(const hid_t obj_id) const; - void decRefCount() const; + // Get the reference counter to this identifier. + int getCounter(const hid_t obj_id) const; + int getCounter() const; - // Get the reference counter to this identifier. - int getCounter(const hid_t obj_id) const; - int getCounter() const; + // Returns an HDF5 object type, given the object id. + static H5I_type_t getHDFObjType(const hid_t obj_id); - // Returns an HDF5 object type, given the object id. - static H5I_type_t getHDFObjType(const hid_t obj_id); + // Returns an HDF5 object type of this object. + H5I_type_t getHDFObjType() const; - // Returns an HDF5 object type of this object. - H5I_type_t getHDFObjType() const; + // Returns the number of members in a type. + static hsize_t getNumMembers(H5I_type_t type); - // Returns the number of members in a type. - static hsize_t getNumMembers(H5I_type_t type); + // Checks if the given ID is valid. + static bool isValid(hid_t an_id); - // Checks if the given ID is valid. - static bool isValid(hid_t an_id); + // Determines if an type exists. + static bool typeExists(H5I_type_t type); - // Determines if an type exists. - static bool typeExists(H5I_type_t type); + // Assignment operator. + IdComponent &operator=(const IdComponent &rhs); - // Assignment operator. - IdComponent& operator=(const IdComponent& rhs); - - // Sets the identifier of this object to a new value. - void setId(const hid_t new_id); + // Sets the identifier of this object to a new value. + void setId(const hid_t new_id); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Gets the identifier of this object. - virtual hid_t getId () const = 0; + // Gets the identifier of this object. + virtual hid_t getId() const = 0; - // Pure virtual function for there are various H5*close for the - // subclasses. - virtual void close() = 0; + // Pure virtual function for there are various H5*close for the + // subclasses. + virtual void close() = 0; - // Makes and returns the string "::"; - // is returned by fromClass(). - H5std_string inMemFunc(const char* func_name) const; + // Makes and returns the string "::"; + // is returned by fromClass(). + H5std_string inMemFunc(const char *func_name) const; - ///\brief Returns this class name. - virtual H5std_string fromClass() const { return("IdComponent");} + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("IdComponent"); + } #endif // DOXYGEN_SHOULD_SKIP_THIS - // Destructor - virtual ~IdComponent(); + // Destructor + virtual ~IdComponent(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Default constructor. - IdComponent(); + protected: + // Default constructor. + IdComponent(); - // Gets the name of the file, in which an HDF5 object belongs. - H5std_string p_get_file_name() const; + // Gets the name of the file, in which an HDF5 object belongs. + H5std_string p_get_file_name() const; - // Verifies that the given id is valid. - static bool p_valid_id(const hid_t obj_id); + // Verifies that the given id is valid. + static bool p_valid_id(const hid_t obj_id); - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - virtual void p_setId(const hid_t new_id) = 0; + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + virtual void p_setId(const hid_t new_id) = 0; - // This flag is used to decide whether H5dont_atexit should be called - static bool H5dontAtexit_called; + // This flag is used to decide whether H5dont_atexit should be called + static bool H5dontAtexit_called; - private: - // This flag indicates whether H5Library::initH5cpp has been called - // to register various terminating functions with atexit() - static bool H5cppinit; + private: + // This flag indicates whether H5Library::initH5cpp has been called + // to register various terminating functions with atexit() + static bool H5cppinit; #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Include.h b/c++/src/H5Include.h index a180430..c26ba33 100644 --- a/c++/src/H5Include.h +++ b/c++/src/H5Include.h @@ -23,18 +23,17 @@ #undef true #endif typedef int bool; -const bool false = 0; -const bool true = 1; +const bool false = 0; +const bool true = 1; #endif // These are defined in H5Opkg.h, which should not be included in the C++ API, // so re-define them here for now. /* Initial version of the object header format */ -#define H5O_VERSION_1 1 +#define H5O_VERSION_1 1 /* Revised version - leaves out reserved bytes and alignment padding, and adds * magic number as prefix and checksum as suffix for all chunks. */ -#define H5O_VERSION_2 2 - +#define H5O_VERSION_2 2 diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index 01c20e9..00eea5e 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -40,14 +40,18 @@ namespace H5 { ///\brief Default constructor: Creates a stub integer datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType() {} +IntType::IntType() +{ +} //-------------------------------------------------------------------------- // Function: IntType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const IntType& original) : AtomType( original ) {} +IntType::IntType(const IntType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: IntType overloaded constructor @@ -56,7 +60,7 @@ IntType::IntType(const IntType& original) : AtomType( original ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const PredType& pred_type) : AtomType() +IntType::IntType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -70,7 +74,9 @@ IntType::IntType(const PredType& pred_type) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const hid_t existing_id) : AtomType( existing_id ) {} +IntType::IntType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: IntType overloaded constructor @@ -79,13 +85,12 @@ IntType::IntType(const hid_t existing_id) : AtomType( existing_id ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const DataSet& dataset) : AtomType() +IntType::IntType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("IntType constructor", "H5Dget_type failed"); } } @@ -104,7 +109,7 @@ IntType::IntType(const DataSet& dataset) : AtomType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -IntType::IntType(const H5Location& loc, const char *dtype_name) : AtomType() +IntType::IntType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -123,7 +128,7 @@ IntType::IntType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -IntType::IntType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +IntType::IntType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -136,7 +141,8 @@ IntType::IntType(const H5Location& loc, const H5std_string& dtype_name) : AtomTy ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* IntType::decode() const +DataType * +IntType::decode() const { hid_t encoded_inttype_id = H5I_INVALID_HID; try { @@ -147,7 +153,7 @@ DataType* IntType::decode() const } IntType *encoded_inttype = new IntType; encoded_inttype->p_setId(encoded_inttype_id); - return(encoded_inttype); + return (encoded_inttype); } //-------------------------------------------------------------------------- @@ -157,17 +163,17 @@ DataType* IntType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_sign_t IntType::getSign() const +H5T_sign_t +IntType::getSign() const { - H5T_sign_t type_sign = H5Tget_sign(id); // C routine + H5T_sign_t type_sign = H5Tget_sign(id); // C routine // Returns a valid sign type if no errors - if (type_sign == H5T_SGN_ERROR) - { + if (type_sign == H5T_SGN_ERROR) { throw DataTypeIException("IntType::getSign", - "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type"); + "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type"); } - return(type_sign); + return (type_sign); } //-------------------------------------------------------------------------- @@ -177,12 +183,12 @@ H5T_sign_t IntType::getSign() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IntType::setSign(H5T_sign_t sign) const +void +IntType::setSign(H5T_sign_t sign) const { // Call C routine to set the sign property herr_t ret_value = H5Tset_sign(id, sign); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("IntType::setSign", "H5Tset_sign failed"); } } @@ -192,6 +198,8 @@ void IntType::setSign(H5T_sign_t sign) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::~IntType() {} +IntType::~IntType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index 496872b..e8bccca 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -23,41 +23,45 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP IntType : public AtomType { - public: - // Creates an integer type using a predefined type - IntType(const PredType& pred_type); + public: + // Creates an integer type using a predefined type + IntType(const PredType &pred_type); - // Gets the integer datatype of the specified dataset - IntType(const DataSet& dataset); + // Gets the integer datatype of the specified dataset + IntType(const DataSet &dataset); - // Constructors that open an HDF5 integer datatype, given a location. - IntType(const H5Location& loc, const char* name); - IntType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 integer datatype, given a location. + IntType(const H5Location &loc, const char *name); + IntType(const H5Location &loc, const H5std_string &name); - // Returns an IntType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an IntType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the sign type for an integer type - H5T_sign_t getSign() const; + // Retrieves the sign type for an integer type + H5T_sign_t getSign() const; - // Sets the sign proprety for an integer type. - void setSign(H5T_sign_t sign) const; + // Sets the sign proprety for an integer type. + void setSign(H5T_sign_t sign) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("IntType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("IntType"); + } - // Default constructor - IntType(); + // Default constructor + IntType(); - // Creates a integer datatype using an existing id - IntType(const hid_t existing_id); + // Creates a integer datatype using an existing id + IntType(const hid_t existing_id); - // Copy constructor: same as the original IntType. - IntType(const IntType& original); + // Copy constructor: same as the original IntType. + IntType(const IntType &original); - // Noop destructor. - virtual ~IntType(); + // Noop destructor. + virtual ~IntType(); }; // end of IntType } // namespace H5 diff --git a/c++/src/H5LaccProp.cpp b/c++/src/H5LaccProp.cpp index 1905cce..bd6c26b 100644 --- a/c++/src/H5LaccProp.cpp +++ b/c++/src/H5LaccProp.cpp @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -LinkAccPropList* LinkAccPropList::DEFAULT_ = 0; +LinkAccPropList *LinkAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: LinkAccPropList::getConstant @@ -40,13 +40,13 @@ LinkAccPropList* LinkAccPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList* LinkAccPropList::getConstant() +LinkAccPropList * +LinkAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ LinkAccPropList* LinkAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new LinkAccPropList(H5P_LINK_ACCESS); else - throw PropListIException("LinkAccPropList::getConstant", "LinkAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("LinkAccPropList::getConstant", + "LinkAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ LinkAccPropList* LinkAccPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -void LinkAccPropList::deleteConstants() +void +LinkAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void LinkAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant(); +const LinkAccPropList &LinkAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} +LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList copy constructor @@ -92,7 +96,9 @@ LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} ///\param original - IN: LinkAccPropList instance to copy // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(original) {} +LinkAccPropList::LinkAccPropList(const LinkAccPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList overloaded constructor @@ -100,7 +106,9 @@ LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(ori /// existing one. // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {} +LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList::setNumLinks @@ -111,12 +119,12 @@ LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {} ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - March 1, 2017 //-------------------------------------------------------------------------- -void LinkAccPropList::setNumLinks(size_t nlinks) const +void +LinkAccPropList::setNumLinks(size_t nlinks) const { herr_t ret_value = H5Pset_nlinks(id, nlinks); // Throw exception if H5Pset_nlinks returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setNumLinks", "H5Pset_nlinks failed"); } } @@ -129,16 +137,16 @@ void LinkAccPropList::setNumLinks(size_t nlinks) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - March 1, 2017 //-------------------------------------------------------------------------- -size_t LinkAccPropList::getNumLinks() const +size_t +LinkAccPropList::getNumLinks() const { - size_t nlinks = 0; + size_t nlinks = 0; herr_t ret_value = H5Pget_nlinks(id, &nlinks); // Throw exception if H5Pget_nlinks returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getNumLinks", "H5Pget_nlinks failed"); } - return(nlinks); + return (nlinks); } //-------------------------------------------------------------------------- @@ -146,6 +154,8 @@ size_t LinkAccPropList::getNumLinks() const ///\brief Noop destructor // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::~LinkAccPropList() {} +LinkAccPropList::~LinkAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5LaccProp.h b/c++/src/H5LaccProp.h index ec5e54f..337f0b7 100644 --- a/c++/src/H5LaccProp.h +++ b/c++/src/H5LaccProp.h @@ -23,43 +23,47 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP LinkAccPropList : public PropList { - public: - ///\brief Default link access property list. - static const LinkAccPropList& DEFAULT; + public: + ///\brief Default link access property list. + static const LinkAccPropList &DEFAULT; - // Creates a link access property list. - LinkAccPropList(); + // Creates a link access property list. + LinkAccPropList(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("LinkAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("LinkAccPropList"); + } - // Copy constructor: same as the original LinkAccPropList. - LinkAccPropList(const LinkAccPropList& original); + // Copy constructor: same as the original LinkAccPropList. + LinkAccPropList(const LinkAccPropList &original); - // Creates a copy of an existing link access property list - // using the property list id. - LinkAccPropList (const hid_t plist_id); + // Creates a copy of an existing link access property list + // using the property list id. + LinkAccPropList(const hid_t plist_id); - // Sets the number of soft or user-defined links that can be - // traversed before a failure occurs. - void setNumLinks(size_t nlinks) const; + // Sets the number of soft or user-defined links that can be + // traversed before a failure occurs. + void setNumLinks(size_t nlinks) const; - // Gets the number of soft or user-defined link traversals allowed - size_t getNumLinks() const; + // Gets the number of soft or user-defined link traversals allowed + size_t getNumLinks() const; - // Noop destructor - virtual ~LinkAccPropList(); + // Noop destructor + virtual ~LinkAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static LinkAccPropList* DEFAULT_; + private: + static LinkAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static LinkAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static LinkAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5LcreatProp.cpp b/c++/src/H5LcreatProp.cpp index bde9339..7bcdd2b 100644 --- a/c++/src/H5LcreatProp.cpp +++ b/c++/src/H5LcreatProp.cpp @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -LinkCreatPropList* LinkCreatPropList::DEFAULT_ = 0; +LinkCreatPropList *LinkCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: LinkCreatPropList::getConstant @@ -40,13 +40,13 @@ LinkCreatPropList* LinkCreatPropList::DEFAULT_ = 0; // happen. // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList* LinkCreatPropList::getConstant() +LinkCreatPropList * +LinkCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ LinkCreatPropList* LinkCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new LinkCreatPropList(H5P_LINK_CREATE); else - throw PropListIException("LinkCreatPropList::getConstant", "LinkCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("LinkCreatPropList::getConstant", + "LinkCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ LinkCreatPropList* LinkCreatPropList::getConstant() // exception H5::PropListIException // December, 2016 //-------------------------------------------------------------------------- -void LinkCreatPropList::deleteConstants() +void +LinkCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void LinkCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const LinkCreatPropList& LinkCreatPropList::DEFAULT = *getConstant(); +const LinkCreatPropList &LinkCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const LinkCreatPropList& LinkCreatPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) {} +LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList copy constructor @@ -92,7 +96,9 @@ LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) {} ///\param original - IN: LinkCreatPropList instance to copy // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList& original) : PropList(original) {} +LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList overloaded constructor @@ -100,7 +106,9 @@ LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList& original) : PropLi /// existing one. // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList::setCreateIntermediateGroup @@ -111,12 +119,12 @@ LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) ///\exception H5::PropListIException // April, 2019 //-------------------------------------------------------------------------- -void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const +void +LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const { herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group); // Throw exception if H5Pset_create_intermediate_group returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed"); } } @@ -129,17 +137,17 @@ void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const ///\exception H5::PropListIException // April, 2019 //-------------------------------------------------------------------------- -bool LinkCreatPropList::getCreateIntermediateGroup() const +bool +LinkCreatPropList::getCreateIntermediateGroup() const { unsigned crt_intmd_group; - herr_t ret_value = H5Pget_create_intermediate_group(id, &crt_intmd_group); + herr_t ret_value = H5Pget_create_intermediate_group(id, &crt_intmd_group); // Throw exception if H5Pget_create_intermediate_group returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed"); } - return((bool)crt_intmd_group); + return ((bool)crt_intmd_group); } //-------------------------------------------------------------------------- @@ -149,12 +157,12 @@ bool LinkCreatPropList::getCreateIntermediateGroup() const ///\exception H5::PropListIException // March, 2018 //-------------------------------------------------------------------------- -void LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const +void +LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const { herr_t ret_value = H5Pset_char_encoding(id, encoding); // Throw exception if H5Pset_char_encoding returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setCharEncoding", "H5Pset_char_encoding failed"); } } @@ -166,16 +174,16 @@ void LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const ///\exception H5::PropListIException // March, 2018 //-------------------------------------------------------------------------- -H5T_cset_t LinkCreatPropList::getCharEncoding() const +H5T_cset_t +LinkCreatPropList::getCharEncoding() const { H5T_cset_t encoding; - herr_t ret_value = H5Pget_char_encoding(id, &encoding); + herr_t ret_value = H5Pget_char_encoding(id, &encoding); // Throw exception if H5Pget_char_encoding returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getCharEncoding", "H5Pget_char_encoding failed"); } - return(encoding); + return (encoding); } //-------------------------------------------------------------------------- @@ -183,6 +191,8 @@ H5T_cset_t LinkCreatPropList::getCharEncoding() const ///\brief Noop destructor // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::~LinkCreatPropList() {} +LinkCreatPropList::~LinkCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5LcreatProp.h b/c++/src/H5LcreatProp.h index 908ef63..7194bdc 100644 --- a/c++/src/H5LcreatProp.h +++ b/c++/src/H5LcreatProp.h @@ -23,50 +23,54 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP LinkCreatPropList : public PropList { - public: - ///\brief Default link creation property list. - static const LinkCreatPropList& DEFAULT; + public: + ///\brief Default link creation property list. + static const LinkCreatPropList &DEFAULT; - // Creates a link creation property list. - LinkCreatPropList(); + // Creates a link creation property list. + LinkCreatPropList(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("LinkCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("LinkCreatPropList"); + } - // Copy constructor: same as the original LinkCreatPropList. - LinkCreatPropList(const LinkCreatPropList& original); + // Copy constructor: same as the original LinkCreatPropList. + LinkCreatPropList(const LinkCreatPropList &original); - // Creates a copy of an existing link creation property list - // using the property list id. - LinkCreatPropList (const hid_t plist_id); + // Creates a copy of an existing link creation property list + // using the property list id. + LinkCreatPropList(const hid_t plist_id); - // Specifies in property list whether to create missing - // intermediate groups - void setCreateIntermediateGroup(bool crt_intmd_group) const; + // Specifies in property list whether to create missing + // intermediate groups + void setCreateIntermediateGroup(bool crt_intmd_group) const; - // Determines whether property is set to enable creating missing - // intermediate groups - bool getCreateIntermediateGroup() const; + // Determines whether property is set to enable creating missing + // intermediate groups + bool getCreateIntermediateGroup() const; - // Sets the character encoding of the string. - void setCharEncoding(H5T_cset_t encoding) const; + // Sets the character encoding of the string. + void setCharEncoding(H5T_cset_t encoding) const; - // Gets the character encoding of the string. - H5T_cset_t getCharEncoding() const; + // Gets the character encoding of the string. + H5T_cset_t getCharEncoding() const; - // Noop destructor - virtual ~LinkCreatPropList(); + // Noop destructor + virtual ~LinkCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static LinkCreatPropList* DEFAULT_; + private: + static LinkCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static LinkCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static LinkCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index fde5599..f64bce4 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -14,7 +14,7 @@ #include #include -#include "H5CppDoc.h" // included only for Doxygen to generate part of RM +#include "H5CppDoc.h" // included only for Doxygen to generate part of RM #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -44,11 +44,11 @@ namespace H5 { ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::open() +void +H5Library::open() { herr_t ret_value = H5open(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::open", "H5open failed"); } } @@ -60,11 +60,11 @@ void H5Library::open() ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::close() +void +H5Library::close() { herr_t ret_value = H5close(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::close", "H5close failed"); } } @@ -79,9 +79,10 @@ void H5Library::close() // Removed the check for failure returned from H5dont_atexit. // will be fixed to not fail (HDFFV-9540) //-------------------------------------------------------------------------- -void H5Library::dontAtExit() +void +H5Library::dontAtExit() { - (void)H5dont_atexit(); + (void)H5dont_atexit(); } //-------------------------------------------------------------------------- @@ -93,11 +94,11 @@ void H5Library::dontAtExit() ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& relnum) +void +H5Library::getLibVersion(unsigned &majnum, unsigned &minnum, unsigned &relnum) { herr_t ret_value = H5get_libversion(&majnum, &minnum, &relnum); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::getLibVersion", "H5get_libversion failed"); } } @@ -115,11 +116,11 @@ void H5Library::getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& reln /// the H5check_version API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) +void +H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) { herr_t ret_value = H5check_version(majnum, minnum, relnum); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::checkVersion", "H5check_version failed"); } } @@ -144,11 +145,11 @@ void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) /// lists when the application ends. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Library::garbageCollect() +void +H5Library::garbageCollect() { herr_t ret_value = H5garbage_collect(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::garbageCollect", "H5garbage_collect failed"); } } @@ -168,12 +169,13 @@ void H5Library::garbageCollect() // // Programmer Binh-Minh Ribler - September, 2015 //-------------------------------------------------------------------------- -void H5Library::initH5cpp() +void +H5Library::initH5cpp() { // Register terminating functions with atexit(); they will be invoked in // the reversed order int ret_value = 0; - ret_value = std::atexit(termH5cpp); + ret_value = std::atexit(termH5cpp); if (ret_value != 0) throw LibraryIException("H5Library::initH5cpp", "Registering termH5cpp failed"); @@ -187,35 +189,43 @@ void H5Library::initH5cpp() ret_value = std::atexit(DSetAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetAccPropList::deleteConstants failed"); ret_value = std::atexit(LinkAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering LinkAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering LinkAccPropList::deleteConstants failed"); ret_value = std::atexit(LinkCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering LinkCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering LinkCreatPropList::deleteConstants failed"); ret_value = std::atexit(FileAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering FileAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering FileAccPropList::deleteConstants failed"); ret_value = std::atexit(FileCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering FileCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering FileCreatPropList::deleteConstants failed"); ret_value = std::atexit(DSetMemXferPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetMemXferPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetMemXferPropList::deleteConstants failed"); ret_value = std::atexit(DSetCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetCreatPropList::deleteConstants failed"); ret_value = std::atexit(ObjCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering ObjCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering ObjCreatPropList::deleteConstants failed"); ret_value = std::atexit(DataSpace::deleteConstants); if (ret_value != 0) @@ -229,7 +239,8 @@ void H5Library::initH5cpp() /// If the C library fails to terminate, exit with a failure. // Programmer Binh-Minh Ribler - September, 2015 //-------------------------------------------------------------------------- -void H5Library::termH5cpp() +void +H5Library::termH5cpp() { // Close the C library herr_t ret_value = H5close(); @@ -253,13 +264,13 @@ void H5Library::termH5cpp() /// the H5set_free_list_limits API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, - int blk_list_lim) +void +H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim) { - herr_t ret_value = H5set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim); - if (ret_value < 0) - { + herr_t ret_value = H5set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, + blk_global_lim, blk_list_lim); + if (ret_value < 0) { throw LibraryIException("H5Library::setFreeListLimits", "H5set_free_list_limits failed"); } } @@ -270,14 +281,18 @@ void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, ///\brief Default constructor: Creates a stub H5Library object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Library::H5Library(){} +H5Library::H5Library() +{ +} //-------------------------------------------------------------------------- // Function: H5Library destructor ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Library::~H5Library(){} +H5Library::~H5Library() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index b9be3d0..d3f2831 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -24,47 +24,46 @@ namespace H5 { methods. */ class H5_DLLCPP H5Library { - public: - // Initializes the HDF5 library. - static void open(); + public: + // Initializes the HDF5 library. + static void open(); - // Flushes all data to disk, closes files, and cleans up memory. - static void close(); + // Flushes all data to disk, closes files, and cleans up memory. + static void close(); - // Instructs library not to install atexit cleanup routine - static void dontAtExit(); + // Instructs library not to install atexit cleanup routine + static void dontAtExit(); - // Returns the HDF library release number. - static void getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& relnum); + // Returns the HDF library release number. + static void getLibVersion(unsigned &majnum, unsigned &minnum, unsigned &relnum); - // Verifies that the arguments match the version numbers compiled - // into the library - static void checkVersion(unsigned majnum, unsigned minnum, unsigned relnum); + // Verifies that the arguments match the version numbers compiled + // into the library + static void checkVersion(unsigned majnum, unsigned minnum, unsigned relnum); - // Walks through all the garbage collection routines for the library, - // which are supposed to free any unused memory they have allocated. - static void garbageCollect(); + // Walks through all the garbage collection routines for the library, + // which are supposed to free any unused memory they have allocated. + static void garbageCollect(); - // Sets limits on the different kinds of free lists. - static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int - arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); + // Sets limits on the different kinds of free lists. + static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim); - // Initializes C++ library and registers terminating functions at exit. - // Only for the library functions, not for user-defined functions. - static void initH5cpp(void); + // Initializes C++ library and registers terminating functions at exit. + // Only for the library functions, not for user-defined functions. + static void initH5cpp(void); - // Sends request for terminating the HDF5 library. - static void termH5cpp(void); + // Sends request for terminating the HDF5 library. + static void termH5cpp(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS - private: + private: + // Default constructor - no instance ever created from outsiders + H5Library(); - // Default constructor - no instance ever created from outsiders - H5Library(); - - // Destructor - ~H5Library(); + // Destructor + ~H5Library(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of H5Library diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 89a7890..ba498d9 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -15,7 +15,7 @@ #include using namespace std; -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -45,7 +45,9 @@ namespace H5 { // Function: H5Location default constructor (protected) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Location::H5Location() : IdComponent() {} +H5Location::H5Location() : IdComponent() +{ +} //-------------------------------------------------------------------------- // Function: H5Location overloaded constructor (protected) @@ -88,7 +90,8 @@ H5Location::H5Location() : IdComponent() {} // Modification // Renamed from exists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const +bool +H5Location::nameExists(const char *name, const LinkAccPropList &lapl) const { htri_t ret_value = H5Lexists(getId(), name, lapl.getId()); if (ret_value > 0) @@ -110,9 +113,10 @@ bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const // Modification // Renamed from exists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::nameExists(const H5std_string& name, const LinkAccPropList& lapl) const +bool +H5Location::nameExists(const H5std_string &name, const LinkAccPropList &lapl) const { - return(nameExists(name.c_str(), lapl)); + return (nameExists(name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -126,9 +130,10 @@ bool H5Location::nameExists(const H5std_string& name, const LinkAccPropList& lap // Modification // Renamed to nameExists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const +bool +H5Location::exists(const char *name, const LinkAccPropList &lapl) const { - return(nameExists(name, lapl)); + return (nameExists(name, lapl)); } //-------------------------------------------------------------------------- @@ -142,9 +147,10 @@ bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const // Modification // Renamed to nameExists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) const +bool +H5Location::exists(const H5std_string &name, const LinkAccPropList &lapl) const { - return(nameExists(name.c_str(), lapl)); + return (nameExists(name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -162,11 +168,11 @@ bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) c // Sep 2012 - BMR // Moved from H5File/H5Object //-------------------------------------------------------------------------- -void H5Location::flush(H5F_scope_t scope) const +void +H5Location::flush(H5F_scope_t scope) const { herr_t ret_value = H5Fflush(getId(), scope); - if (ret_value < 0) - { + if (ret_value < 0) { throw LocationException(inMemFunc("flush"), "H5Fflush failed"); } } @@ -179,12 +185,13 @@ void H5Location::flush(H5F_scope_t scope) const ///\exception H5::LocationException // Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- -H5std_string H5Location::getFileName() const +H5std_string +H5Location::getFileName() const { try { - return(p_get_file_name()); + return (p_get_file_name()); } - catch (IdComponentException& E) { + catch (IdComponentException &E) { throw LocationException(inMemFunc("getFileName"), E.getDetailMsg()); } } @@ -209,7 +216,8 @@ H5std_string H5Location::getFileName() const // to another class to accommodate attribute, dataset, and named // datatype. - BMR //-------------------------------------------------------------------------- -void H5Location::setComment(const char* name, const char* comment) const +void +H5Location::setComment(const char *name, const char *comment) const { herr_t ret_value = H5Oset_comment_by_name(getId(), name, comment, H5P_DEFAULT); if (ret_value < 0) @@ -223,7 +231,8 @@ void H5Location::setComment(const char* name, const char* comment) const /// \c H5std_string for \a name and \a comment. // Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -void H5Location::setComment(const H5std_string& name, const H5std_string& comment) const +void +H5Location::setComment(const H5std_string &name, const H5std_string &comment) const { setComment(name.c_str(), comment.c_str()); } @@ -235,7 +244,8 @@ void H5Location::setComment(const H5std_string& name, const H5std_string& commen /// an object name. // Programmer Binh-Minh Ribler - Sep 2013 //-------------------------------------------------------------------------- -void H5Location::setComment(const char* comment) const +void +H5Location::setComment(const char *comment) const { herr_t ret_value = H5Oset_comment_by_name(getId(), ".", comment, H5P_DEFAULT); if (ret_value < 0) @@ -249,7 +259,8 @@ void H5Location::setComment(const char* comment) const /// \c H5std_string for \a comment. // Programmer Binh-Minh Ribler - Sep 2013 //-------------------------------------------------------------------------- -void H5Location::setComment(const H5std_string& comment) const +void +H5Location::setComment(const H5std_string &comment) const { setComment(comment.c_str()); } @@ -265,7 +276,8 @@ void H5Location::setComment(const H5std_string& comment) const // to another class to accommodate attribute, dataset, and named // datatype. - BMR //-------------------------------------------------------------------------- -void H5Location::removeComment(const char* name) const +void +H5Location::removeComment(const char *name) const { herr_t ret_value = H5Oset_comment_by_name(getId(), name, NULL, H5P_DEFAULT); if (ret_value < 0) @@ -279,9 +291,10 @@ void H5Location::removeComment(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -void H5Location::removeComment(const H5std_string& name) const +void +H5Location::removeComment(const H5std_string &name) const { - removeComment (name.c_str()); + removeComment(name.c_str()); } //-------------------------------------------------------------------------- @@ -299,7 +312,8 @@ void H5Location::removeComment(const H5std_string& name) const /// will be truncated to accommodate the null terminator. // Programmer Binh-Minh Ribler - Mar 2014 //-------------------------------------------------------------------------- -ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) const +ssize_t +H5Location::getComment(const char *name, size_t buf_size, char *comment) const { // H5Oget_comment_by_name will get buf_size chars of the comment including // the null terminator @@ -307,17 +321,16 @@ ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) comment_len = H5Oget_comment_by_name(getId(), name, comment, buf_size, H5P_DEFAULT); // If H5Oget_comment_by_name returns a negative value, raise an exception - if (comment_len < 0) - { + if (comment_len < 0) { throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } // If the comment is longer than the provided buffer size, the C library // will not null terminate it if (static_cast(comment_len) >= buf_size) - comment[buf_size-1] = '\0'; + comment[buf_size - 1] = '\0'; // Return the actual comment length, which might be different from buf_size - return(comment_len); + return (comment_len); } //-------------------------------------------------------------------------- @@ -330,7 +343,8 @@ ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) ///\exception H5::LocationException // Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -H5std_string H5Location::getComment(const char* name, size_t buf_size) const +H5std_string +H5Location::getComment(const char *name, size_t buf_size) const { // Initialize string to "", so that if there is no comment, the returned // string will be empty @@ -340,14 +354,12 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, (size_t)0, H5P_DEFAULT); // If H5Oget_comment_by_name returns a negative value, raise an exception - if (comment_len < 0) - { + if (comment_len < 0) { throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } // If comment exists, calls C routine again to get it - else if (comment_len > 0) - { + else if (comment_len > 0) { size_t tmp_len = buf_size; // If buffer size is not provided, use comment length @@ -355,14 +367,13 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const tmp_len = comment_len; // Temporary buffer for char* comment - char* comment_C = new char[tmp_len+1]; - HDmemset(comment_C, 0, tmp_len+1); // clear buffer + char *comment_C = new char[tmp_len + 1]; + HDmemset(comment_C, 0, tmp_len + 1); // clear buffer // Used overloaded function - ssize_t temp_len = getComment(name, tmp_len+1, comment_C); - if (temp_len < 0) - { - delete []comment_C; + ssize_t temp_len = getComment(name, tmp_len + 1, comment_C); + if (temp_len < 0) { + delete[] comment_C; throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } @@ -370,11 +381,11 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const comment = comment_C; // Clean up resource - delete []comment_C; + delete[] comment_C; } // Return the string comment - return(comment); + return (comment); } //-------------------------------------------------------------------------- @@ -384,9 +395,10 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -H5std_string H5Location::getComment(const H5std_string& name, size_t buf_size) const +H5std_string +H5Location::getComment(const H5std_string &name, size_t buf_size) const { - return(getComment(name.c_str(), buf_size)); + return (getComment(name.c_str(), buf_size)); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -400,11 +412,11 @@ H5std_string H5Location::getComment(const H5std_string& name, size_t buf_size) c // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const +void +H5Location::p_reference(void *ref, const char *name, hid_t space_id, H5R_type_t ref_type) const { herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw ReferenceException(inMemFunc("reference"), "H5Rcreate failed"); } } @@ -425,12 +437,13 @@ void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_ty ///\note This method is more suitable for a dataset region reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const char *name, const DataSpace &dataspace, H5R_type_t ref_type) const { try { p_reference(ref, name, dataspace.getId(), ref_type); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -451,12 +464,14 @@ void H5Location::reference(void* ref, const char* name, const DataSpace& dataspa ///\note This method is more suitable for a dataset region reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& dataspace, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const H5std_string &name, const DataSpace &dataspace, + H5R_type_t ref_type) const { try { p_reference(ref, name.c_str(), dataspace.getId(), ref_type); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -475,12 +490,13 @@ void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& ///\note This method is more suitable for an object reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const char *name, H5R_type_t ref_type) const { try { p_reference(ref, name, -1, ref_type); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -498,9 +514,10 @@ void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) con ///\note This method is more suitable for an object reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const H5std_string &name, H5R_type_t ref_type) const { - reference(ref, name.c_str(), ref_type); + reference(ref, name.c_str(), ref_type); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -517,7 +534,9 @@ void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_t // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func) +hid_t +H5Location::p_dereference(hid_t loc_id, const void *ref, H5R_type_t ref_type, const PropList &plist, + const char *from_func) { hid_t plist_id; if (p_valid_id(plist.getId())) @@ -526,12 +545,11 @@ hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_ty plist_id = H5P_DEFAULT; hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref); - if (temp_id < 0) - { + if (temp_id < 0) { throw ReferenceException(inMemFunc(from_func), "H5Rdereference2 failed"); } - return(temp_id); + return (temp_id); } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -545,7 +563,8 @@ hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_ty ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) +void +H5Location::dereference(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) { p_setId(p_dereference(loc.getId(), ref, ref_type, plist, "dereference")); } @@ -564,11 +583,12 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t // Removed in 1.10.1 because H5Location is Attribute's baseclass // now. -BMR //-------------------------------------------------------------------------- - /* void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) +/* void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& +plist) { - p_setId(p_dereference(attr.getId(), ref, ref_type, plist, "dereference")); + p_setId(p_dereference(attr.getId(), ref, ref_type, plist, "dereference")); } - */ +*/ #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- @@ -590,12 +610,13 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t // Modification // Sep 2012: Moved up from H5File, Group, DataSet, and DataType //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const +H5G_obj_t +H5Location::getObjType(void *ref, H5R_type_t ref_type) const { try { - return(p_get_obj_type(ref, ref_type)); + return (p_get_obj_type(ref, ref_type)); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("getObjType"), E.getDetailMsg()); } } @@ -617,14 +638,14 @@ H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const +H5G_obj_t +H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const { - H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref); - if (obj_type == H5G_UNKNOWN) - { + H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref); + if (obj_type == H5G_UNKNOWN) { throw ReferenceException(inMemFunc("getObjType"), "H5Rget_obj_type1 failed"); } - return(obj_type); + return (obj_type); } #endif // DOXYGEN_SHOULD_SKIP_THIS #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -645,12 +666,13 @@ H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const +H5O_type_t +H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const { try { - return(p_get_ref_obj_type(ref, ref_type)); + return (p_get_ref_obj_type(ref, ref_type)); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg()); } } @@ -671,22 +693,20 @@ H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const +H5O_type_t +H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const { - H5O_type_t obj_type = H5O_TYPE_UNKNOWN; - herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); - if (ret_value < 0) - { + H5O_type_t obj_type = H5O_TYPE_UNKNOWN; + herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); + if (ret_value < 0) { throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 failed"); } - if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) - { + if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) { throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 returned invalid type"); } - return(obj_type); + return (obj_type); } - //-------------------------------------------------------------------------- // Function: H5Location::getRegion ///\brief Retrieves a dataspace with the region pointed to selected. @@ -703,24 +723,23 @@ H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const // ref count, as a work-around for a problem described in the JIRA // issue HDFFV-7947. -BMR //-------------------------------------------------------------------------- -DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const +DataSpace +H5Location::getRegion(void *ref, H5R_type_t ref_type) const { hid_t space_id = H5Rget_region(getId(), ref_type, ref); - if (space_id < 0) - { + if (space_id < 0) { throw ReferenceException(inMemFunc("getRegion"), "H5Rget_region failed"); } try { DataSpace dataspace; f_DataSpace_setId(&dataspace, space_id); - return(dataspace); + return (dataspace); } - catch (DataSpaceIException& E) { + catch (DataSpaceIException &E) { throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); } } - // From H5CommonFG.cpp // Notes with "***Updated" are new and for Group.cpp // Original notes are from December 2000 @@ -768,7 +787,8 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const /// then a default size is chosen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) const +Group +H5Location::createGroup(const char *name, const LinkCreatPropList &lcpl) const { // Call C routine H5Gcreate2 to create the named group, giving the // location id which can be a file id or a group id @@ -779,10 +799,10 @@ Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) c throwException("createGroup", "H5Gcreate2 failed"); // No failure, create and return the Group object - Group group; + Group group; H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -792,9 +812,10 @@ Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) c /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const H5std_string& name, const LinkCreatPropList& lcpl) const +Group +H5Location::createGroup(const H5std_string &name, const LinkCreatPropList &lcpl) const { - return(createGroup( name.c_str(), lcpl)); + return (createGroup(name.c_str(), lcpl)); } //-------------------------------------------------------------------------- @@ -813,22 +834,22 @@ Group H5Location::createGroup(const H5std_string& name, const LinkCreatPropList& /// then a default size is chosen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const char* name, size_t size_hint) const +Group +H5Location::createGroup(const char *name, size_t size_hint) const { // Group creation property list for size hint hid_t gcpl_id = 0; // Set the local heap size hint - if (size_hint > 0) - { - // If the creation of the property list failed, throw an exception - if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) - throwException("createGroup", "H5Pcreate failed"); - - if (H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) { - H5Pclose(gcpl_id); - throwException("createGroup", "H5Pset_local_heap_size_hint failed"); - } + if (size_hint > 0) { + // If the creation of the property list failed, throw an exception + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + throwException("createGroup", "H5Pcreate failed"); + + if (H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) { + H5Pclose(gcpl_id); + throwException("createGroup", "H5Pset_local_heap_size_hint failed"); + } } // Call C routine H5Gcreate2 to create the named group, giving the @@ -836,18 +857,18 @@ Group H5Location::createGroup(const char* name, size_t size_hint) const hid_t group_id = H5Gcreate2(getId(), name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT); // Close the group creation property list, if necessary - if(gcpl_id > 0) - H5Pclose(gcpl_id); + if (gcpl_id > 0) + H5Pclose(gcpl_id); // If the creation of the group failed, throw an exception if (group_id < 0) throwException("createGroup", "H5Gcreate2 failed"); // No failure, create and return the Group object - Group group; + Group group; H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -857,9 +878,10 @@ Group H5Location::createGroup(const char* name, size_t size_hint) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const H5std_string& name, size_t size_hint) const +Group +H5Location::createGroup(const H5std_string &name, size_t size_hint) const { - return(createGroup( name.c_str(), size_hint)); + return (createGroup(name.c_str(), size_hint)); } //-------------------------------------------------------------------------- @@ -871,7 +893,8 @@ Group H5Location::createGroup(const H5std_string& name, size_t size_hint) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::openGroup(const char* name) const +Group +H5Location::openGroup(const char *name) const { // Call C routine H5Gopen2 to open the named group, giving the // location id which can be a file id or a group id @@ -883,10 +906,10 @@ Group H5Location::openGroup(const char* name) const // No failure, create and return the Group object Group group; - //group.p_setId(group_id); + // group.p_setId(group_id); H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -896,9 +919,10 @@ Group H5Location::openGroup(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::openGroup(const H5std_string& name) const +Group +H5Location::openGroup(const H5std_string &name) const { - return(openGroup( name.c_str())); + return (openGroup(name.c_str())); } //-------------------------------------------------------------------------- @@ -919,14 +943,17 @@ Group H5Location::openGroup(const H5std_string& name) const // follow the order in the C function: lcpl, dcpl, dapl, to // accommodate the existing createDataSet calls. //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& dcpl, const DSetAccPropList& dapl, const LinkCreatPropList& lcpl) const +DataSet +H5Location::createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &dcpl, const DSetAccPropList &dapl, + const LinkCreatPropList &lcpl) const { - // Obtain identifiers for C API - hid_t type_id = data_type.getId(); + // Obtain identifiers for C API + hid_t type_id = data_type.getId(); hid_t space_id = data_space.getId(); - hid_t dcpl_id = dcpl.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t dapl_id = dapl.getId(); + hid_t dcpl_id = dcpl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t dapl_id = dapl.getId(); // Call C routine H5Dcreate2 to create the named dataset hid_t dataset_id = H5Dcreate2(getId(), name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); @@ -938,7 +965,7 @@ DataSet H5Location::createDataSet(const char* name, const DataType& data_type, c // No failure, create and return the DataSet object DataSet dataset; f_DataSet_setId(&dataset, dataset_id); - return(dataset); + return (dataset); } //-------------------------------------------------------------------------- @@ -953,9 +980,12 @@ DataSet H5Location::createDataSet(const char* name, const DataType& data_type, c // follow the order in the C function: lcpl, dcpl, dapl, to // accommodate the existing createDataSet calls. //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& dcpl, const DSetAccPropList& dapl, const LinkCreatPropList& lcpl) const +DataSet +H5Location::createDataSet(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &dcpl, const DSetAccPropList &dapl, + const LinkCreatPropList &lcpl) const { - return(createDataSet(name.c_str(), data_type, data_space, dcpl, dapl, lcpl)); + return (createDataSet(name.c_str(), data_type, data_space, dcpl, dapl, lcpl)); } //-------------------------------------------------------------------------- @@ -969,21 +999,22 @@ DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data // Jul 2018 // Added DSetAccPropList argument //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet(const char* name, const DSetAccPropList& dapl) const +DataSet +H5Location::openDataSet(const char *name, const DSetAccPropList &dapl) const { // Call C function H5Dopen2 to open the specified dataset, giving // the location id and the dataset's name - hid_t dapl_id = dapl.getId(); + hid_t dapl_id = dapl.getId(); hid_t dataset_id = H5Dopen2(getId(), name, dapl_id); // If the dataset's opening failed, throw an exception - if(dataset_id < 0) + if (dataset_id < 0) throwException("openDataSet", "H5Dopen2 failed"); // No failure, create and return the DataSet object DataSet dataset; f_DataSet_setId(&dataset, dataset_id); - return(dataset); + return (dataset); } //-------------------------------------------------------------------------- @@ -996,9 +1027,10 @@ DataSet H5Location::openDataSet(const char* name, const DSetAccPropList& dapl) c // Jul 2018 // Added DSetAccPropList argument //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet(const H5std_string& name, const DSetAccPropList& dapl) const +DataSet +H5Location::openDataSet(const H5std_string &name, const DSetAccPropList &dapl) const { - return(openDataSet(name.c_str(), dapl)); + return (openDataSet(name.c_str(), dapl)); } //-------------------------------------------------------------------------- @@ -1016,12 +1048,13 @@ DataSet H5Location::openDataSet(const H5std_string& name, const DSetAccPropList& /// H5Lcreate_soft APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *target_name, const char *link_name, - const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *target_name, const char *link_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value = -1; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_soft(target_name, getId(), link_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1036,8 +1069,9 @@ void H5Location::link(const char *target_name, const char *link_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& target_name, const H5std_string& - link_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &target_name, const H5std_string &link_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(target_name.c_str(), link_name.c_str(), lcpl, lapl); } @@ -1058,16 +1092,17 @@ void H5Location::link(const H5std_string& target_name, const H5std_string& /// H5Lcreate_hard APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *curr_name, const Group& new_loc, - const char *new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *curr_name, const Group &new_loc, const char *new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { - herr_t ret_value = -1; - hid_t new_loc_id = new_loc.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + herr_t ret_value = -1; + hid_t new_loc_id = new_loc.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_hard(getId(), curr_name, new_loc_id, new_name, lcpl_id, lapl_id); - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1079,8 +1114,9 @@ void H5Location::link(const char *curr_name, const Group& new_loc, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& curr_name, const Group& new_loc, - const H5std_string& new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(curr_name.c_str(), new_loc, new_name.c_str(), lcpl, lapl); } @@ -1102,15 +1138,17 @@ void H5Location::link(const H5std_string& curr_name, const Group& new_loc, /// H5Lcreate_hard APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *curr_name, const hid_t same_loc, const char *new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *curr_name, const hid_t same_loc, const char *new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value = -1; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_hard(getId(), curr_name, same_loc, new_name, lcpl_id, lapl_id); - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1122,8 +1160,9 @@ void H5Location::link(const char *curr_name, const hid_t same_loc, const char *n ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& curr_name, const hid_t same_loc, - const H5std_string& new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(curr_name.c_str(), same_loc, new_name.c_str(), lcpl, lapl); } @@ -1152,17 +1191,18 @@ void H5Location::link(const H5std_string& curr_name, const hid_t same_loc, // H5L_SAME_LOC. This function will be retired in favor of // its replacement. - BMR //-------------------------------------------------------------------------- -void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* new_name) const +void +H5Location::link(H5L_type_t link_type, const char *curr_name, const char *new_name) const { herr_t ret_value = -1; - switch(link_type) { + switch (link_type) { case H5L_TYPE_HARD: ret_value = H5Lcreate_hard(getId(), curr_name, H5L_SAME_LOC, new_name, H5P_DEFAULT, H5P_DEFAULT); break; case H5L_TYPE_SOFT: - ret_value = H5Lcreate_soft(curr_name,getId(), new_name, H5P_DEFAULT, H5P_DEFAULT); + ret_value = H5Lcreate_soft(curr_name, getId(), new_name, H5P_DEFAULT, H5P_DEFAULT); break; case H5L_TYPE_ERROR: @@ -1173,7 +1213,7 @@ void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* n break; } /* end switch */ - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1184,7 +1224,8 @@ void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* n /// \c H5std_string for \a curr_name and \a new_name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const +void +H5Location::link(H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const { link(link_type, curr_name.c_str(), new_name.c_str()); } @@ -1200,17 +1241,17 @@ void H5Location::link(H5L_type_t link_type, const H5std_string& curr_name, const ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const char *src_name, - const Group& dst, const char *dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t dst_id = dst.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t dst_id = dst.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcopy(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id); - if(ret_value < 0) + if (ret_value < 0) throwException("copyLink", "H5Lcopy failed"); } @@ -1222,9 +1263,9 @@ void H5Location::copyLink(const char *src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const H5std_string& src_name, - const Group& dst, const H5std_string& dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { copyLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl); } @@ -1239,16 +1280,16 @@ void H5Location::copyLink(const H5std_string& src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const char *src_name, - const char *dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcopy(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id); - if(ret_value < 0) + if (ret_value < 0) throwException("copyLink", "H5Lcopy H5L_SAME_LOC failed"); } @@ -1260,9 +1301,9 @@ void H5Location::copyLink(const char *src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const H5std_string& src_name, - const H5std_string& dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { copyLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl); } @@ -1282,12 +1323,14 @@ void H5Location::copyLink(const H5std_string& src_name, /// to the Group Interface in the HDF5 User's Guide for details. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const char* src_name, const Group& dst, const char* dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t dst_id = dst.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t dst_id = dst.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lmove(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1302,7 +1345,9 @@ void H5Location::moveLink(const char* src_name, const Group& dst, const char* ds ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const H5std_string& src_name, const Group& dst, const H5std_string& dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { moveLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl); } @@ -1321,11 +1366,13 @@ void H5Location::moveLink(const H5std_string& src_name, const Group& dst, const /// to the Group Interface in the HDF5 User's Guide for details. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const char* src_name, const char* dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lmove(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1340,7 +1387,9 @@ void H5Location::moveLink(const char* src_name, const char* dst_name, const Link ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const H5std_string& src_name, const H5std_string& dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { moveLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl); } @@ -1359,7 +1408,8 @@ void H5Location::moveLink(const H5std_string& src_name, const H5std_string& dst_ // 2007: QAK modified to use H5L APIs - BMR // 2018: Will be replaced by H5Location::moveLink() -BMR //-------------------------------------------------------------------------- -void H5Location::move(const char* src, const char* dst) const +void +H5Location::move(const char *src, const char *dst) const { moveLink(src, dst, LinkCreatPropList::DEFAULT, LinkAccPropList::DEFAULT); } @@ -1372,7 +1422,8 @@ void H5Location::move(const char* src, const char* dst) const // Modification // 2018: Will be replaced by H5Location::moveLink() -BMR //-------------------------------------------------------------------------- -void H5Location::move(const H5std_string& src, const H5std_string& dst) const +void +H5Location::move(const H5std_string &src, const H5std_string &dst) const { moveLink(src.c_str(), dst.c_str(), LinkCreatPropList::DEFAULT, LinkAccPropList::DEFAULT); } @@ -1384,7 +1435,8 @@ void H5Location::move(const H5std_string& src, const H5std_string& dst) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::unlink(const char* name, const LinkAccPropList& lapl) const +void +H5Location::unlink(const char *name, const LinkAccPropList &lapl) const { herr_t ret_value = H5Ldelete(getId(), name, lapl.getId()); if (ret_value < 0) @@ -1398,7 +1450,8 @@ void H5Location::unlink(const char* name, const LinkAccPropList& lapl) const /// \c H5std_string for \a name. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::unlink(const H5std_string& name, const LinkAccPropList& lapl) const +void +H5Location::unlink(const H5std_string &name, const LinkAccPropList &lapl) const { unlink(name.c_str(), lapl); } @@ -1415,7 +1468,8 @@ void H5Location::unlink(const H5std_string& name, const LinkAccPropList& lapl) c /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(H5O_native_info_t& objinfo, unsigned fields) const +void +H5Location::getNativeObjinfo(H5O_native_info_t &objinfo, unsigned fields) const { // Use C API to get information of the object @@ -1441,7 +1495,9 @@ void H5Location::getNativeObjinfo(H5O_native_info_t& objinfo, unsigned fields) c /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(const char* name, H5O_native_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getNativeObjinfo(const char *name, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { // Use C API to get information of the object herr_t ret_value = H5Oget_native_info_by_name(getId(), name, &objinfo, fields, lapl.getId()); @@ -1463,7 +1519,9 @@ void H5Location::getNativeObjinfo(const char* name, H5O_native_info_t& objinfo, ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(const H5std_string& name, H5O_native_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getNativeObjinfo(const H5std_string &name, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { getNativeObjinfo(name.c_str(), objinfo, fields, lapl); } @@ -1486,13 +1544,13 @@ void H5Location::getNativeObjinfo(const H5std_string& name, H5O_native_info_t& o /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getNativeObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_native_info_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { // Use C API to get information of the object - herr_t ret_value = H5Oget_native_info_by_idx(getId(), grp_name, idx_type, order, - idx, &objinfo, fields, lapl.getId()); + herr_t ret_value = + H5Oget_native_info_by_idx(getId(), grp_name, idx_type, order, idx, &objinfo, fields, lapl.getId()); // Throw exception if C API returns failure if (ret_value < 0) @@ -1511,9 +1569,10 @@ void H5Location::getNativeObjinfo(const char* grp_name, H5_index_t idx_type, ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getNativeObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t idx, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { getNativeObjinfo(grp_name.c_str(), idx_type, order, idx, objinfo, fields, lapl); } @@ -1533,7 +1592,8 @@ void H5Location::getNativeObjinfo(const H5std_string& grp_name, H5_index_t idx_t /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(H5O_info2_t& objinfo, unsigned fields) const +void +H5Location::getObjinfo(H5O_info2_t &objinfo, unsigned fields) const { // Use C API to get information of the object @@ -1562,7 +1622,9 @@ void H5Location::getObjinfo(H5O_info2_t& objinfo, unsigned fields) const /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, H5O_info2_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const char *name, H5O_info2_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { // Use C API to get information of the object herr_t ret_value = H5Oget_info_by_name3(getId(), name, &objinfo, fields, lapl.getId()); @@ -1584,7 +1646,9 @@ void H5Location::getObjinfo(const char* name, H5O_info2_t& objinfo, unsigned fie ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, H5O_info2_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const H5std_string &name, H5O_info2_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { getObjinfo(name.c_str(), objinfo, fields, lapl); } @@ -1610,13 +1674,13 @@ void H5Location::getObjinfo(const H5std_string& name, H5O_info2_t& objinfo, unsi /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info2_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info2_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { // Use C API to get information of the object - herr_t ret_value = H5Oget_info_by_idx3(getId(), grp_name, idx_type, order, - idx, &objinfo, fields, lapl.getId()); + herr_t ret_value = + H5Oget_info_by_idx3(getId(), grp_name, idx_type, order, idx, &objinfo, fields, lapl.getId()); // Throw exception if C API returns failure if (ret_value < 0) @@ -1635,9 +1699,9 @@ void H5Location::getObjinfo(const char* grp_name, H5_index_t idx_type, ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info2_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info2_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { getObjinfo(grp_name.c_str(), idx_type, order, idx, objinfo, fields, lapl); } @@ -1655,7 +1719,8 @@ void H5Location::getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, /// the HDF5 C Reference Manual. // 2000 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const char *name, hbool_t follow_link, H5G_stat_t &statbuf) const { herr_t ret_value = H5Gget_objinfo(getId(), name, follow_link, &statbuf); if (ret_value < 0) @@ -1669,7 +1734,8 @@ void H5Location::getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& s /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t &statbuf) const { getObjinfo(name.c_str(), follow_link, statbuf); } @@ -1681,7 +1747,8 @@ void H5Location::getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_s /// the paramemter \a follow_link. // Nov, 2005 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const char *name, H5G_stat_t &statbuf) const { herr_t ret_value = H5Gget_objinfo(getId(), name, 0, &statbuf); if (ret_value < 0) @@ -1695,7 +1762,8 @@ void H5Location::getObjinfo(const char* name, H5G_stat_t& statbuf) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Nov, 2005 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const H5std_string &name, H5G_stat_t &statbuf) const { getObjinfo(name.c_str(), statbuf); } @@ -1711,7 +1779,8 @@ void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // 2000 //-------------------------------------------------------------------------- -H5L_info2_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList& lapl) const +H5L_info2_t +H5Location::getLinkInfo(const char *link_name, const LinkAccPropList &lapl) const { H5L_info2_t linkinfo; // link info structure @@ -1719,7 +1788,7 @@ H5L_info2_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList if (ret_value < 0) throwException("getLinkInfo", "H5Lget_info to find buffer size failed"); - return(linkinfo); + return (linkinfo); } //-------------------------------------------------------------------------- @@ -1728,9 +1797,10 @@ H5L_info2_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList /// It differs from the above function in that it takes an /// \c H5std_string for \a link_name. //-------------------------------------------------------------------------- -H5L_info2_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl) const +H5L_info2_t +H5Location::getLinkInfo(const H5std_string &link_name, const LinkAccPropList &lapl) const { - return(getLinkInfo(link_name.c_str(), lapl)); + return (getLinkInfo(link_name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -1742,17 +1812,17 @@ H5L_info2_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAcc ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // 2000 //-------------------------------------------------------------------------- -H5std_string H5Location::getLinkval(const char* name, size_t size) const +H5std_string +H5Location::getLinkval(const char *name, size_t size) const { - H5L_info2_t linkinfo; - char *value_C; // value in C string - size_t val_size = size; - H5std_string value = ""; - herr_t ret_value; + H5L_info2_t linkinfo; + char * value_C; // value in C string + size_t val_size = size; + H5std_string value = ""; + herr_t ret_value; // if user doesn't provide buffer size, determine it - if (size == 0) - { + if (size == 0) { ret_value = H5Lget_info2(getId(), name, &linkinfo, H5P_DEFAULT); if (ret_value < 0) throwException("getLinkval", "H5Lget_info to find buffer size failed"); @@ -1761,22 +1831,20 @@ H5std_string H5Location::getLinkval(const char* name, size_t size) const } // if link has value, retrieve the value, otherwise, return null string - if (val_size > 0) - { - value_C = new char[val_size+1]; // temporary C-string for C API - HDmemset(value_C, 0, val_size+1); // clear buffer + if (val_size > 0) { + value_C = new char[val_size + 1]; // temporary C-string for C API + HDmemset(value_C, 0, val_size + 1); // clear buffer ret_value = H5Lget_val(getId(), name, value_C, val_size, H5P_DEFAULT); - if (ret_value < 0) - { - delete []value_C; + if (ret_value < 0) { + delete[] value_C; throwException("getLinkval", "H5Lget_val failed"); } value = H5std_string(value_C); - delete []value_C; + delete[] value_C; } - return(value); + return (value); } //-------------------------------------------------------------------------- @@ -1786,9 +1854,10 @@ H5std_string H5Location::getLinkval(const char* name, size_t size) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string H5Location::getLinkval(const H5std_string& name, size_t size) const +H5std_string +H5Location::getLinkval(const H5std_string &name, size_t size) const { - return(getLinkval( name.c_str(), size)); + return (getLinkval(name.c_str(), size)); } //-------------------------------------------------------------------------- @@ -1800,7 +1869,8 @@ H5std_string H5Location::getLinkval(const H5std_string& name, size_t size) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2014 (original 2000) //-------------------------------------------------------------------------- -void H5Location::mount(const char* name, const H5File& child, const PropList& plist) const +void +H5Location::mount(const char *name, const H5File &child, const PropList &plist) const { // Obtain identifiers for C API hid_t plist_id = plist.getId(); @@ -1829,7 +1899,7 @@ void H5Location::mount(const char* name, const H5File& child, const PropList& pl // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5Location::mount(const char* name, H5File& child, PropList& plist) const +// void H5Location::mount(const char* name, H5File& child, PropList& plist) const //{ // mount(name, child, plist); //} @@ -1840,7 +1910,8 @@ void H5Location::mount(const char* name, const H5File& child, const PropList& pl /// It takes an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::mount(const H5std_string& name, const H5File& child, const PropList& plist) const +void +H5Location::mount(const H5std_string &name, const H5File &child, const PropList &plist) const { mount(name.c_str(), child, plist); } @@ -1856,7 +1927,7 @@ void H5Location::mount(const H5std_string& name, const H5File& child, const Prop // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5Location::mount(const H5std_string& name, H5File& child, PropList& plist) const +// void H5Location::mount(const H5std_string& name, H5File& child, PropList& plist) const //{ // mount(name.c_str(), child, plist); //} @@ -1868,7 +1939,8 @@ void H5Location::mount(const H5std_string& name, const H5File& child, const Prop ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unmount(const char* name) const +void +H5Location::unmount(const char *name) const { // Call C routine H5Fmount to do the mouting herr_t ret_value = H5Funmount(getId(), name); @@ -1885,7 +1957,8 @@ void H5Location::unmount(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unmount(const H5std_string& name) const +void +H5Location::unmount(const H5std_string &name) const { unmount(name.c_str()); } @@ -1904,14 +1977,14 @@ void H5Location::unmount(const H5std_string& name) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Location::iterateElems(const char* name, int *idx, H5G_iterate_t op , void* op_data) +int +H5Location::iterateElems(const char *name, int *idx, H5G_iterate_t op, void *op_data) { int ret_value = H5Giterate(getId(), name, idx, op, op_data); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("iterateElems", "H5Giterate failed"); } - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -1921,9 +1994,10 @@ int H5Location::iterateElems(const char* name, int *idx, H5G_iterate_t op , void /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op , void* op_data) +int +H5Location::iterateElems(const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data) { - return(iterateElems( name.c_str(), idx, op, op_data)); + return (iterateElems(name.c_str(), idx, op, op_data)); } #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1934,12 +2008,13 @@ int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t o ///\exception Deprecated // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -hsize_t H5Location::getNumObjs() const +hsize_t +H5Location::getNumObjs() const { - H5G_info_t ginfo; // Group information + H5G_info_t ginfo; // Group information herr_t ret_value = H5Gget_info(getId(), &ginfo); - if(ret_value < 0) + if (ret_value < 0) throwException("getNumObjs", "H5Gget_info failed"); return (ginfo.nlinks); } @@ -1959,28 +2034,30 @@ hsize_t H5Location::getNumObjs() const /// each time the group is opened. // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -H5std_string H5Location::getObjnameByIdx(hsize_t idx) const +H5std_string +H5Location::getObjnameByIdx(hsize_t idx) const { // call H5Lget_name_by_idx with name as NULL to get its length - ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, NULL, 0, H5P_DEFAULT); - if(name_len < 0) + ssize_t name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, NULL, 0, H5P_DEFAULT); + if (name_len < 0) throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); // now, allocate C buffer to get the name - char* name_C = new char[name_len+1]; - HDmemset(name_C, 0, name_len+1); // clear buffer + char *name_C = new char[name_len + 1]; + HDmemset(name_C, 0, name_len + 1); // clear buffer - name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len+1, H5P_DEFAULT); + name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len + 1, H5P_DEFAULT); - if (name_len < 0) - { - delete []name_C; + if (name_len < 0) { + delete[] name_C; throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); } // clean up and return the string H5std_string name = H5std_string(name_C); - delete []name_C; + delete[] name_C; return (name); } @@ -2001,10 +2078,12 @@ H5std_string H5Location::getObjnameByIdx(hsize_t idx) const /// each time the group is opened. // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -ssize_t H5Location::getObjnameByIdx(hsize_t idx, char* name, size_t size) const +ssize_t +H5Location::getObjnameByIdx(hsize_t idx, char *name, size_t size) const { - ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); - if(name_len < 0) + ssize_t name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); + if (name_len < 0) throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); return (name_len); @@ -2017,22 +2096,22 @@ ssize_t H5Location::getObjnameByIdx(hsize_t idx, char* name, size_t size) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const +ssize_t +H5Location::getObjnameByIdx(hsize_t idx, H5std_string &name, size_t size) const { - char* name_C = new char[size+1]; // temporary C-string for object name - HDmemset(name_C, 0, size+1); // clear buffer + char *name_C = new char[size + 1]; // temporary C-string for object name + HDmemset(name_C, 0, size + 1); // clear buffer // call overloaded function to get the name - ssize_t name_len = getObjnameByIdx(idx, name_C, size+1); - if(name_len < 0) - { - delete []name_C; + ssize_t name_len = getObjnameByIdx(idx, name_C, size + 1); + if (name_len < 0) { + delete[] name_C; throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); } // clean up and return the string name = H5std_string(name_C); - delete []name_C; + delete[] name_C; return (name_len); } @@ -2054,10 +2133,11 @@ ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size /// - object type is not one of the valid values above // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(const char* objname) const +H5O_type_t +H5Location::childObjType(const char *objname) const { H5O_info2_t objinfo; - H5O_type_t objtype = H5O_TYPE_UNKNOWN; + H5O_type_t objtype = H5O_TYPE_UNKNOWN; // Use C API to get information of the object herr_t ret_value = H5Oget_info_by_name3(getId(), objname, &objinfo, H5O_INFO_BASIC, H5P_DEFAULT); @@ -2067,19 +2147,18 @@ H5O_type_t H5Location::childObjType(const char* objname) const throwException("childObjType", "H5Oget_info_by_name failed"); // Return a valid type or throw an exception for unknown type else - switch (objinfo.type) - { - case H5O_TYPE_GROUP: - case H5O_TYPE_DATASET: - case H5O_TYPE_NAMED_DATATYPE: - objtype = objinfo.type; - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - throwException("childObjType", "Unknown type of object"); + switch (objinfo.type) { + case H5O_TYPE_GROUP: + case H5O_TYPE_DATASET: + case H5O_TYPE_NAMED_DATATYPE: + objtype = objinfo.type; + break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + throwException("childObjType", "Unknown type of object"); } - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -2092,11 +2171,12 @@ H5O_type_t H5Location::childObjType(const char* objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(const H5std_string& objname) const +H5O_type_t +H5Location::childObjType(const H5std_string &objname) const { // Use overloaded function H5O_type_t objtype = childObjType(objname.c_str()); - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -2128,33 +2208,35 @@ H5O_type_t H5Location::childObjType(const H5std_string& objname) const // can be added later when needed. // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_iter_order_t order, const char* objname) const +H5O_type_t +H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_iter_order_t order, + const char *objname) const { - herr_t ret_value; + herr_t ret_value; H5O_info2_t objinfo; - H5O_type_t objtype = H5O_TYPE_UNKNOWN; + H5O_type_t objtype = H5O_TYPE_UNKNOWN; // Use C API to get information of the object - ret_value = H5Oget_info_by_idx3(getId(), objname, index_type, order, index, &objinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret_value = H5Oget_info_by_idx3(getId(), objname, index_type, order, index, &objinfo, H5O_INFO_BASIC, + H5P_DEFAULT); // Throw exception if C API returns failure if (ret_value < 0) throwException("childObjType", "H5Oget_info_by_idx failed"); // Return a valid type or throw an exception for unknown type else - switch (objinfo.type) - { - case H5O_TYPE_GROUP: - case H5O_TYPE_DATASET: - case H5O_TYPE_NAMED_DATATYPE: - objtype = objinfo.type; - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - throwException("childObjType", "Unknown type of object"); + switch (objinfo.type) { + case H5O_TYPE_GROUP: + case H5O_TYPE_DATASET: + case H5O_TYPE_NAMED_DATATYPE: + objtype = objinfo.type; + break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + throwException("childObjType", "Unknown type of object"); } - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -2171,25 +2253,26 @@ H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_ite /// - version number is not one of the valid values above // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -unsigned H5Location::childObjVersion(const char* objname) const +unsigned +H5Location::childObjVersion(const char *objname) const { H5O_native_info_t objinfo; - unsigned version = 0; + unsigned version = 0; // Use C API to get information of the object - herr_t ret_value = H5Oget_native_info_by_name(getId(), objname, &objinfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); + herr_t ret_value = + H5Oget_native_info_by_name(getId(), objname, &objinfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); // Throw exception if C API returns failure if (ret_value < 0) throwException("childObjVersion", "H5Oget_info_by_name failed"); // Return a valid version or throw an exception for invalid value - else - { + else { version = objinfo.hdr.version; if (version != H5O_VERSION_1 && version != H5O_VERSION_2) throwException("childObjVersion", "Invalid version for object"); } - return(version); + return (version); } //-------------------------------------------------------------------------- @@ -2202,11 +2285,12 @@ unsigned H5Location::childObjVersion(const char* objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -unsigned H5Location::childObjVersion(const H5std_string& objname) const +unsigned +H5Location::childObjVersion(const H5std_string &objname) const { // Use overloaded function unsigned version = childObjVersion(objname.c_str()); - return(version); + return (version); } #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -2220,13 +2304,14 @@ unsigned H5Location::childObjVersion(const H5std_string& objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx) const { - H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); - if (obj_type == H5G_UNKNOWN) + H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); + if (obj_type == H5G_UNKNOWN) throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); - return (obj_type); + return (obj_type); } //-------------------------------------------------------------------------- @@ -2242,10 +2327,11 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const // Modification // Modified to use the other function. -BMR, 2016/03/07 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx, char *type_name) const { H5std_string stype_name(type_name); - return(getObjTypeByIdx(idx, stype_name)); + return (getObjTypeByIdx(idx, stype_name)); } //-------------------------------------------------------------------------- // Function: H5Location::getObjTypeByIdx @@ -2258,22 +2344,30 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const { H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); - switch (obj_type) - { - case H5G_LINK: type_name = H5std_string("symbolic link"); break; - case H5G_GROUP: type_name = H5std_string("group"); break; - case H5G_DATASET: type_name = H5std_string("dataset"); break; - case H5G_TYPE: type_name = H5std_string("datatype"); break; - case H5G_UNKNOWN: - case H5G_UDLINK: - case H5G_RESERVED_5: - case H5G_RESERVED_6: - case H5G_RESERVED_7: - default: - throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); + switch (obj_type) { + case H5G_LINK: + type_name = H5std_string("symbolic link"); + break; + case H5G_GROUP: + type_name = H5std_string("group"); + break; + case H5G_DATASET: + type_name = H5std_string("dataset"); + break; + case H5G_TYPE: + type_name = H5std_string("datatype"); + break; + case H5G_UNKNOWN: + case H5G_UDLINK: + case H5G_RESERVED_5: + case H5G_RESERVED_6: + case H5G_RESERVED_7: + default: + throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); } return (obj_type); } @@ -2294,7 +2388,8 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) cons // maintain backward compatibility. For other subclasses, throw // LocationException. //-------------------------------------------------------------------------- -void H5Location::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +H5Location::throwException(const H5std_string &func_name, const H5std_string &msg) const { throw LocationException(inMemFunc(func_name.c_str()), msg); } @@ -2325,7 +2420,8 @@ void H5Location::throwException(const H5std_string& func_name, const H5std_strin // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataSpace_setId(DataSpace* dspace, hid_t new_id) +void +f_DataSpace_setId(DataSpace *dspace, hid_t new_id) { dspace->p_setId(new_id); } @@ -2335,8 +2431,10 @@ void f_DataSpace_setId(DataSpace* dspace, hid_t new_id) ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Location::~H5Location() {} +H5Location::~H5Location() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 3c30715..3ea58cd 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -15,7 +15,7 @@ #ifndef __H5Location_H #define __H5Location_H -#include "H5Classes.h" // constains forward class declarations +#include "H5Classes.h" // constains forward class declarations namespace H5 { @@ -29,319 +29,312 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP H5Location : public IdComponent { - public: - // Checks if a link of a given name exists in a location - bool nameExists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - bool nameExists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + public: + // Checks if a link of a given name exists in a location + bool nameExists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + bool nameExists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; - // Checks if a link of a given name exists in a location - // Deprecated in favor of nameExists for better name. - bool exists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - bool exists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Checks if a link of a given name exists in a location + // Deprecated in favor of nameExists for better name. + bool exists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + bool exists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; - // Flushes all buffers associated with this location to disk. - void flush(H5F_scope_t scope) const; + // Flushes all buffers associated with this location to disk. + void flush(H5F_scope_t scope) const; - // Gets the name of the file, specified by this location. - H5std_string getFileName() const; + // Gets the name of the file, specified by this location. + H5std_string getFileName() const; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves the type of object that an object reference points to. - H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Retrieves the type of object that an object reference points to. - H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; - // Note: getRefObjType deprecates getObjType, but getObjType's name is - // misleading, so getRefObjType is used in the new function instead. - - // Sets the comment for an HDF5 object specified by its name. - void setComment(const char* name, const char* comment) const; - void setComment(const H5std_string& name, const H5std_string& comment) const; - void setComment(const char* comment) const; - void setComment(const H5std_string& comment) const; - - // Retrieves comment for the HDF5 object specified by its name. - ssize_t getComment(const char* name, size_t buf_size, char* comment) const; - H5std_string getComment(const char* name, size_t buf_size=0) const; - H5std_string getComment(const H5std_string& name, size_t buf_size=0) const; - - // Removes the comment for the HDF5 object specified by its name. - void removeComment(const char* name) const; - void removeComment(const H5std_string& name) const; - - // Creates a reference to a named object or to a dataset region - // in this object. - void reference(void* ref, const char* name, - H5R_type_t ref_type = H5R_OBJECT) const; - void reference(void* ref, const H5std_string& name, - H5R_type_t ref_type = H5R_OBJECT) const; - void reference(void* ref, const char* name, const DataSpace& dataspace, - H5R_type_t ref_type = H5R_DATASET_REGION) const; - void reference(void* ref, const H5std_string& name, const DataSpace& dataspace, - H5R_type_t ref_type = H5R_DATASET_REGION) const; - - // Open a referenced object whose location is specified by either - // a file, an HDF5 object, or an attribute. - void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // Removed in 1.10.1, because H5Location is baseclass - //void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - - // Retrieves a dataspace with the region pointed to selected. - DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; - - // Create a new group with using link create property list. - Group createGroup(const char* name, const LinkCreatPropList& lcpl) const; - Group createGroup(const H5std_string& name, const LinkCreatPropList& lcpl) const; - -// From CommonFG - // Creates a new group at this location which can be a file - // or another group. - Group createGroup(const char* name, size_t size_hint = 0) const; - Group createGroup(const H5std_string& name, size_t size_hint = 0) const; - - // Opens an existing group in a location which can be a file - // or another group. - Group openGroup(const char* name) const; - Group openGroup(const H5std_string& name) const; - - // Creates a new dataset in this location. - DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const; - DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const; - - // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3 - // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - // DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - - // Opens an existing dataset at this location. - // DSetAccPropList is added - 1.10.3 - DataSet openDataSet(const char* name, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const; - DataSet openDataSet(const H5std_string& name, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const; - - H5L_info2_t getLinkInfo(const char* link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - H5L_info2_t getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Returns the value of a symbolic link. - H5std_string getLinkval(const char* link_name, size_t size=0) const; - H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; - - // Returns the number of objects in this group. - // Deprecated - moved to H5::Group in 1.10.2. - hsize_t getNumObjs() const; - - // Retrieves the name of an object in this group, given the - // object's index. - H5std_string getObjnameByIdx(hsize_t idx) const; - ssize_t getObjnameByIdx(hsize_t idx, char* name, size_t size) const; - ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const; - - // Retrieves the type of an object in this file or group, given the - // object's name - H5O_type_t childObjType(const H5std_string& objname) const; - H5O_type_t childObjType(const char* objname) const; - H5O_type_t childObjType(hsize_t index, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_INC, const char* objname=".") const; - - // Returns the object header version of an object in this file or group, - // given the object's name. - unsigned childObjVersion(const char* objname) const; - unsigned childObjVersion(const H5std_string& objname) const; - - // Retrieves information about an HDF5 object. - void getObjinfo(H5O_info2_t& objinfo, unsigned fields = H5O_INFO_BASIC) const; - - // Retrieves information about an HDF5 object, given its name. - void getObjinfo(const char* name, H5O_info2_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getObjinfo(const H5std_string& name, H5O_info2_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Retrieves information about an HDF5 object, given its index. - void getObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info2_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info2_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Retrieves native native information about an HDF5 object. - void getNativeObjinfo(H5O_native_info_t& objinfo, unsigned fields = H5O_NATIVE_INFO_HDR) const; - - // Retrieves native information about an HDF5 object, given its name. - void getNativeObjinfo(const char* name, H5O_native_info_t& objinfo, - unsigned fields = H5O_NATIVE_INFO_HDR, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getNativeObjinfo(const H5std_string& name, H5O_native_info_t& objinfo, - unsigned fields = H5O_NATIVE_INFO_HDR, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Retrieves native information about an HDF5 object, given its index. - void getNativeObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo, - unsigned fields = H5O_NATIVE_INFO_HDR, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getNativeObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo, - unsigned fields = H5O_NATIVE_INFO_HDR, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Retrieves the type of object that an object reference points to. + H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; + // Note: getRefObjType deprecates getObjType, but getObjType's name is + // misleading, so getRefObjType is used in the new function instead. + + // Sets the comment for an HDF5 object specified by its name. + void setComment(const char *name, const char *comment) const; + void setComment(const H5std_string &name, const H5std_string &comment) const; + void setComment(const char *comment) const; + void setComment(const H5std_string &comment) const; + + // Retrieves comment for the HDF5 object specified by its name. + ssize_t getComment(const char *name, size_t buf_size, char *comment) const; + H5std_string getComment(const char *name, size_t buf_size = 0) const; + H5std_string getComment(const H5std_string &name, size_t buf_size = 0) const; + + // Removes the comment for the HDF5 object specified by its name. + void removeComment(const char *name) const; + void removeComment(const H5std_string &name) const; + + // Creates a reference to a named object or to a dataset region + // in this object. + void reference(void *ref, const char *name, H5R_type_t ref_type = H5R_OBJECT) const; + void reference(void *ref, const H5std_string &name, H5R_type_t ref_type = H5R_OBJECT) const; + void reference(void *ref, const char *name, const DataSpace &dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + void reference(void *ref, const H5std_string &name, const DataSpace &dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + + // Open a referenced object whose location is specified by either + // a file, an HDF5 object, or an attribute. + void dereference(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + // Removed in 1.10.1, because H5Location is baseclass + // void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const + // PropList& plist = PropList::DEFAULT); + + // Retrieves a dataspace with the region pointed to selected. + DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; + + // Create a new group with using link create property list. + Group createGroup(const char *name, const LinkCreatPropList &lcpl) const; + Group createGroup(const H5std_string &name, const LinkCreatPropList &lcpl) const; + + // From CommonFG + // Creates a new group at this location which can be a file + // or another group. + Group createGroup(const char *name, size_t size_hint = 0) const; + Group createGroup(const H5std_string &name, size_t size_hint = 0) const; + + // Opens an existing group in a location which can be a file + // or another group. + Group openGroup(const char *name) const; + Group openGroup(const H5std_string &name) const; + + // Creates a new dataset in this location. + DataSet createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT, + const DSetAccPropList & dapl = DSetAccPropList::DEFAULT, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const; + DataSet createDataSet(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT, + const DSetAccPropList & dapl = DSetAccPropList::DEFAULT, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const; + + // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3 + // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const + // DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; DataSet createDataSet(const + // H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& + // create_plist = DSetCreatPropList::DEFAULT) const; + + // Opens an existing dataset at this location. + // DSetAccPropList is added - 1.10.3 + DataSet openDataSet(const char *name, const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const; + DataSet openDataSet(const H5std_string & name, + const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const; + + H5L_info2_t getLinkInfo(const char * link_name, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + H5L_info2_t getLinkInfo(const H5std_string & link_name, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Returns the value of a symbolic link. + H5std_string getLinkval(const char *link_name, size_t size = 0) const; + H5std_string getLinkval(const H5std_string &link_name, size_t size = 0) const; + + // Returns the number of objects in this group. + // Deprecated - moved to H5::Group in 1.10.2. + hsize_t getNumObjs() const; + + // Retrieves the name of an object in this group, given the + // object's index. + H5std_string getObjnameByIdx(hsize_t idx) const; + ssize_t getObjnameByIdx(hsize_t idx, char *name, size_t size) const; + ssize_t getObjnameByIdx(hsize_t idx, H5std_string &name, size_t size) const; + + // Retrieves the type of an object in this file or group, given the + // object's name + H5O_type_t childObjType(const H5std_string &objname) const; + H5O_type_t childObjType(const char *objname) const; + H5O_type_t childObjType(hsize_t index, H5_index_t index_type = H5_INDEX_NAME, + H5_iter_order_t order = H5_ITER_INC, const char *objname = ".") const; + + // Returns the object header version of an object in this file or group, + // given the object's name. + unsigned childObjVersion(const char *objname) const; + unsigned childObjVersion(const H5std_string &objname) const; + + // Retrieves information about an HDF5 object. + void getObjinfo(H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC) const; + + // Retrieves information about an HDF5 object, given its name. + void getObjinfo(const char *name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getObjinfo(const H5std_string &name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves information about an HDF5 object, given its index. + void getObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves native native information about an HDF5 object. + void getNativeObjinfo(H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR) const; + + // Retrieves native information about an HDF5 object, given its name. + void getNativeObjinfo(const char *name, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getNativeObjinfo(const H5std_string &name, H5O_native_info_t &objinfo, + unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves native information about an HDF5 object, given its index. + void getNativeObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getNativeObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t idx, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Returns the type of an object in this group, given the - // object's index. - H5G_obj_t getObjTypeByIdx(hsize_t idx) const; - H5G_obj_t getObjTypeByIdx(hsize_t idx, char* type_name) const; - H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const; - - // Returns information about an HDF5 object, given by its name, - // at this location. - Deprecated - void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const char* name, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const; - - // Iterates over the elements of this group - not implemented in - // C++ style yet. - int iterateElems(const char* name, int *idx, H5G_iterate_t op, void *op_data); - int iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op, void *op_data); + // Returns the type of an object in this group, given the + // object's index. + H5G_obj_t getObjTypeByIdx(hsize_t idx) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, char *type_name) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const; + + // Returns information about an HDF5 object, given by its name, + // at this location. - Deprecated + void getObjinfo(const char *name, hbool_t follow_link, H5G_stat_t &statbuf) const; + void getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t &statbuf) const; + void getObjinfo(const char *name, H5G_stat_t &statbuf) const; + void getObjinfo(const H5std_string &name, H5G_stat_t &statbuf) const; + + // Iterates over the elements of this group - not implemented in + // C++ style yet. + int iterateElems(const char *name, int *idx, H5G_iterate_t op, void *op_data); + int iterateElems(const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Creates a soft link from link_name to target_name. - void link(const char *target_name, const char *link_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void link(const H5std_string& target_name, - const H5std_string& link_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Creates a hard link from new_name to curr_name. - void link(const char *curr_name, - const Group& new_loc, const char *new_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void link(const H5std_string& curr_name, - const Group& new_loc, const H5std_string& new_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Creates a hard link from new_name to curr_name in same location. - void link(const char *curr_name, - const hid_t same_loc, const char *new_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void link(const H5std_string& curr_name, - const hid_t same_loc, const H5std_string& new_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Creates a link of the specified type from new_name to current_name; - // both names are interpreted relative to the specified location id. - // Deprecated due to inadequate functionality. - void link(H5L_type_t link_type, const char* curr_name, const char* new_name) const; - void link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const; - - // Removes the specified link from this location. - void unlink(const char *link_name, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void unlink(const H5std_string& link_name, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Mounts the file 'child' onto this location. - void mount(const char* name, const H5File& child, const PropList& plist) const; - void mount(const H5std_string& name, const H5File& child, const PropList& plist) const; - - // Unmounts the file named 'name' from this parent location. - void unmount(const char* name) const; - void unmount(const H5std_string& name) const; - - // Copies a link from a group to another. - void copyLink(const char *src_name, - const Group& dst, const char *dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void copyLink(const H5std_string& src_name, - const Group& dst, const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Makes a copy of a link in the same group. - void copyLink(const char *src_name, const char *dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void copyLink(const H5std_string& src_name, - const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Renames a link in this group and moves to a new location. - void moveLink(const char* src_name, - const Group& dst, const char* dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void moveLink(const H5std_string& src_name, - const Group& dst, const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Renames a link in this group. - void moveLink(const char* src_name, const char* dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void moveLink(const H5std_string& src_name, - const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Renames an object at this location. - // Deprecated due to inadequate functionality. - void move(const char* src, const char* dst) const; - void move(const H5std_string& src, const H5std_string& dst) const; - -// end From CommonFG - - /// For subclasses, H5File and Group, to throw appropriate exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; - - // Default constructor - H5Location(); - - protected: + // Creates a soft link from link_name to target_name. + void link(const char *target_name, const char *link_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string &target_name, const H5std_string &link_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Creates a hard link from new_name to curr_name. + void link(const char *curr_name, const Group &new_loc, const char *new_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Creates a hard link from new_name to curr_name in same location. + void link(const char *curr_name, const hid_t same_loc, const char *new_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Creates a link of the specified type from new_name to current_name; + // both names are interpreted relative to the specified location id. + // Deprecated due to inadequate functionality. + void link(H5L_type_t link_type, const char *curr_name, const char *new_name) const; + void link(H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const; + + // Removes the specified link from this location. + void unlink(const char *link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void unlink(const H5std_string &link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Mounts the file 'child' onto this location. + void mount(const char *name, const H5File &child, const PropList &plist) const; + void mount(const H5std_string &name, const H5File &child, const PropList &plist) const; + + // Unmounts the file named 'name' from this parent location. + void unmount(const char *name) const; + void unmount(const H5std_string &name) const; + + // Copies a link from a group to another. + void copyLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void copyLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Makes a copy of a link in the same group. + void copyLink(const char *src_name, const char *dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void copyLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Renames a link in this group and moves to a new location. + void moveLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void moveLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Renames a link in this group. + void moveLink(const char *src_name, const char *dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void moveLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Renames an object at this location. + // Deprecated due to inadequate functionality. + void move(const char *src, const char *dst) const; + void move(const H5std_string &src, const H5std_string &dst) const; + + // end From CommonFG + + /// For subclasses, H5File and Group, to throw appropriate exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const; + + // Default constructor + H5Location(); + + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // *** Deprecation warning *** - // The following two constructors are no longer appropriate after the - // data member "id" had been moved to the sub-classes. - // The copy constructor is a noop and is removed in 1.8.15 and the - // other will be removed from 1.10 release, and then from 1.8 if its - // removal does not raise any problems in two 1.10 releases. + // *** Deprecation warning *** + // The following two constructors are no longer appropriate after the + // data member "id" had been moved to the sub-classes. + // The copy constructor is a noop and is removed in 1.8.15 and the + // other will be removed from 1.10 release, and then from 1.8 if its + // removal does not raise any problems in two 1.10 releases. - // Creates a copy of an existing object giving the location id. - // H5Location(const hid_t loc_id); + // Creates a copy of an existing object giving the location id. + // H5Location(const hid_t loc_id); - // Creates a reference to an HDF5 object or a dataset region. - void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const; + // Creates a reference to an HDF5 object or a dataset region. + void p_reference(void *ref, const char *name, hid_t space_id, H5R_type_t ref_type) const; - // Dereferences a ref into an HDF5 id. - hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func); + // Dereferences a ref into an HDF5 id. + hid_t p_dereference(hid_t loc_id, const void *ref, H5R_type_t ref_type, const PropList &plist, + const char *from_func); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves the type of object that an object reference points to. - H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Retrieves the type of object that an object reference points to. - H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const; + // Retrieves the type of object that an object reference points to. + H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const; - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - //virtual void p_setId(const hid_t new_id); + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + // virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - // Noop destructor. - virtual ~H5Location(); + // Noop destructor. + virtual ~H5Location(); }; // end of H5Location } // namespace H5 diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 081cab7..9fd750a 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -13,7 +13,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -42,23 +42,23 @@ namespace H5 { #ifndef DOXYGEN_SHOULD_SKIP_THIS // userAttrOpWrpr interfaces between the user's function and the // C library function H5Aiterate2 -extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name, - const H5A_info_t *ainfo, void *op_data) +extern "C" herr_t +userAttrOpWrpr(hid_t loc_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data) { - H5std_string s_attr_name = H5std_string(attr_name); - UserData4Aiterate* myData = reinterpret_cast (op_data); + H5std_string s_attr_name = H5std_string(attr_name); + UserData4Aiterate *myData = reinterpret_cast(op_data); myData->op(*myData->location, s_attr_name, myData->opData); return 0; } // userVisitOpWrpr interfaces between the user's function and the // C library function H5Ovisit3 -extern "C" herr_t userVisitOpWrpr(hid_t obj_id, const char *attr_name, - const H5O_info2_t *obj_info, void *op_data) +extern "C" herr_t +userVisitOpWrpr(hid_t obj_id, const char *attr_name, const H5O_info2_t *obj_info, void *op_data) { - H5std_string s_attr_name = H5std_string(attr_name); - UserData4Visit* myData = reinterpret_cast (op_data); - int status = myData->op(*myData->obj, s_attr_name, obj_info, myData->opData); + H5std_string s_attr_name = H5std_string(attr_name); + UserData4Visit *myData = reinterpret_cast(op_data); + int status = myData->op(*myData->obj, s_attr_name, obj_info, myData->opData); return status; } @@ -66,7 +66,9 @@ extern "C" herr_t userVisitOpWrpr(hid_t obj_id, const char *attr_name, // Function: H5Object default constructor (protected) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Object::H5Object() : H5Location() {} +H5Object::H5Object() : H5Location() +{ +} //-------------------------------------------------------------------------- // Function: f_Attribute_setId - friend @@ -78,7 +80,8 @@ H5Object::H5Object() : H5Location() {} // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_Attribute_setId(Attribute* attr, hid_t new_id) +void +f_Attribute_setId(Attribute *attr, hid_t new_id) { attr->p_setId(new_id); } @@ -105,19 +108,20 @@ void f_Attribute_setId(Attribute* attr, hid_t new_id) /// recreate it with this function. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::createAttribute(const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const +Attribute +H5Object::createAttribute(const char *name, const DataType &data_type, const DataSpace &data_space, + const PropList &create_plist) const { - hid_t type_id = data_type.getId(); + hid_t type_id = data_type.getId(); hid_t space_id = data_space.getId(); hid_t plist_id = create_plist.getId(); - hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT); + hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT); // If the attribute id is valid, create and return the Attribute object - if (attr_id > 0) - { + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } else throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed"); @@ -130,9 +134,11 @@ Attribute H5Object::createAttribute(const char* name, const DataType& data_type, /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::createAttribute(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const +Attribute +H5Object::createAttribute(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, + const PropList &create_plist) const { - return(createAttribute(name.c_str(), data_type, data_space, create_plist)); + return (createAttribute(name.c_str(), data_type, data_space, create_plist)); } //-------------------------------------------------------------------------- @@ -143,17 +149,16 @@ Attribute H5Object::createAttribute(const H5std_string& name, const DataType& da ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const char* name) const +Attribute +H5Object::openAttribute(const char *name) const { hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT); - if (attr_id > 0) - { + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } - else - { + else { throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed"); } } @@ -165,9 +170,10 @@ Attribute H5Object::openAttribute(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const H5std_string& name) const +Attribute +H5Object::openAttribute(const H5std_string &name) const { - return(openAttribute(name.c_str())); + return (openAttribute(name.c_str())); } //-------------------------------------------------------------------------- @@ -178,18 +184,17 @@ Attribute H5Object::openAttribute(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const unsigned int idx) const +Attribute +H5Object::openAttribute(const unsigned int idx) const { - hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, - H5_ITER_INC, static_cast(idx), H5P_DEFAULT, H5P_DEFAULT); - if (attr_id > 0) - { + hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, static_cast(idx), + H5P_DEFAULT, H5P_DEFAULT); + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } - else - { + else { throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_by_idx failed"); } } @@ -209,18 +214,19 @@ Attribute H5Object::openAttribute(const unsigned int idx) const /// void (*)(H5::H5Location&, H5std_string, void*). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_data) +int +H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_data) { // store the user's function and data - UserData4Aiterate* userData = new UserData4Aiterate; - userData->opData = op_data; - userData->op = user_op; - userData->location = this; + UserData4Aiterate *userData = new UserData4Aiterate; + userData->opData = op_data; + userData->op = user_op; + userData->location = this; // call the C library routine H5Aiterate2 to iterate the attributes hsize_t idx = _idx ? static_cast(*_idx) : 0; - int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, - userAttrOpWrpr, static_cast(userData)); + int ret_value = + H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, static_cast(userData)); // release memory delete userData; @@ -229,9 +235,9 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat /* Pass back update index value to calling code */ if (_idx) *_idx = static_cast(idx); - return(ret_value); + return (ret_value); } - else // raise exception when H5Aiterate returns a negative value + else // raise exception when H5Aiterate returns a negative value throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate2 failed"); } @@ -268,16 +274,19 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat /// C Reference Manual. // Programmer Binh-Minh Ribler - Feb, 2019 //-------------------------------------------------------------------------- -void H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields) +void +H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, + unsigned int fields) { // Store the user's function and data - UserData4Visit* userData = new UserData4Visit; - userData->opData = op_data; - userData->op = user_op; - userData->obj = this; + UserData4Visit *userData = new UserData4Visit; + userData->opData = op_data; + userData->op = user_op; + userData->obj = this; // Call the C API passing in op wrapper and info - herr_t ret_value = H5Ovisit3(getId(), idx_type, order, userVisitOpWrpr, static_cast(userData), fields); + herr_t ret_value = + H5Ovisit3(getId(), idx_type, order, userVisitOpWrpr, static_cast(userData), fields); // Release memory delete userData; @@ -300,10 +309,11 @@ void H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_ /// - version number is not one of the valid values above // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -unsigned H5Object::objVersion() const +unsigned +H5Object::objVersion() const { H5O_native_info_t objinfo; - unsigned version = 0; + unsigned version = 0; // Use C API to get information of the object herr_t ret_value = H5Oget_native_info(getId(), &objinfo, H5O_NATIVE_INFO_HDR); @@ -312,13 +322,12 @@ unsigned H5Object::objVersion() const if (ret_value < 0) throw Exception(inMemFunc("objVersion"), "H5Oget_native_info failed"); // Return a valid version or throw an exception for invalid value - else - { + else { version = objinfo.hdr.version; if (version != H5O_VERSION_1 && version != H5O_VERSION_2) throw ObjHeaderIException("objVersion", "Invalid version for object"); } - return(version); + return (version); } //-------------------------------------------------------------------------- @@ -328,14 +337,15 @@ unsigned H5Object::objVersion() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Object::getNumAttrs() const +int +H5Object::getNumAttrs() const { - H5O_info2_t oinfo; /* Object info */ + H5O_info2_t oinfo; /* Object info */ - if(H5Oget_info3(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0) + if (H5Oget_info3(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0) throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed"); else - return(static_cast(oinfo.num_attrs)); + return (static_cast(oinfo.num_attrs)); } //-------------------------------------------------------------------------- @@ -345,7 +355,8 @@ int H5Object::getNumAttrs() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2013 //-------------------------------------------------------------------------- -bool H5Object::attrExists(const char* name) const +bool +H5Object::attrExists(const char *name) const { // Call C routine H5Aexists to determine whether an attribute exists // at this location, which could be specified by a file, group, dataset, @@ -353,7 +364,7 @@ bool H5Object::attrExists(const char* name) const herr_t ret_value = H5Aexists(getId(), name); if (ret_value > 0) return true; - else if(ret_value == 0) + else if (ret_value == 0) return false; else // Raise exception when H5Aexists returns a negative value throw AttributeIException(inMemFunc("attrExists"), "H5Aexists failed"); @@ -366,9 +377,10 @@ bool H5Object::attrExists(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool H5Object::attrExists(const H5std_string& name) const +bool +H5Object::attrExists(const H5std_string &name) const { - return(attrExists(name.c_str())); + return (attrExists(name.c_str())); } //-------------------------------------------------------------------------- @@ -378,7 +390,8 @@ bool H5Object::attrExists(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Object::removeAttr(const char* name) const +void +H5Object::removeAttr(const char *name) const { herr_t ret_value = H5Adelete(getId(), name); if (ret_value < 0) @@ -392,7 +405,8 @@ void H5Object::removeAttr(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Object::removeAttr(const H5std_string& name) const +void +H5Object::removeAttr(const H5std_string &name) const { removeAttr(name.c_str()); } @@ -405,7 +419,8 @@ void H5Object::removeAttr(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -void H5Object::renameAttr(const char* oldname, const char* newname) const +void +H5Object::renameAttr(const char *oldname, const char *newname) const { herr_t ret_value = H5Arename(getId(), oldname, newname); if (ret_value < 0) @@ -419,9 +434,10 @@ void H5Object::renameAttr(const char* oldname, const char* newname) const /// a reference to an \c H5std_string for the names. // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newname) const +void +H5Object::renameAttr(const H5std_string &oldname, const H5std_string &newname) const { - renameAttr (oldname.c_str(), newname.c_str()); + renameAttr(oldname.c_str(), newname.c_str()); } //-------------------------------------------------------------------------- @@ -430,22 +446,21 @@ void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newna ///\return The name of the object // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t H5Object::getObjName(char *obj_name, size_t buf_size) const +ssize_t +H5Object::getObjName(char *obj_name, size_t buf_size) const { // H5Iget_name will get buf_size-1 chars of the name to null terminate it ssize_t name_size = H5Iget_name(getId(), obj_name, buf_size); // If H5Iget_name returns a negative value, raise an exception - if (name_size < 0) - { + if (name_size < 0) { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // Return length of the name - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -455,7 +470,8 @@ ssize_t H5Object::getObjName(char *obj_name, size_t buf_size) const ///\exception H5::Exception // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5std_string H5Object::getObjName() const +H5std_string +H5Object::getObjName() const { H5std_string obj_name(""); // object name to return @@ -463,31 +479,28 @@ H5std_string H5Object::getObjName() const ssize_t name_size = H5Iget_name(getId(), NULL, static_cast(0)); // If H5Iget_name failed, throw exception - if (name_size < 0) - { + if (name_size < 0) { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // Object's name exists, retrieve it - else if (name_size > 0) - { - char* name_C = new char[name_size+1]; // temporary C-string - HDmemset(name_C, 0, name_size+1); // clear buffer + else if (name_size > 0) { + char *name_C = new char[name_size + 1]; // temporary C-string + HDmemset(name_C, 0, name_size + 1); // clear buffer // Use overloaded function - name_size = getObjName(name_C, name_size+1); + name_size = getObjName(name_C, name_size + 1); // Convert the C object name to return obj_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Return object's name - return(obj_name); + return (obj_name); } //-------------------------------------------------------------------------- @@ -503,35 +516,34 @@ H5std_string H5Object::getObjName() const /// which case the entire name will be retrieved. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const +ssize_t +H5Object::getObjName(H5std_string &obj_name, size_t len) const { ssize_t name_size = 0; // If no length is provided, get the entire object name - if (len == 0) - { - obj_name = getObjName(); + if (len == 0) { + obj_name = getObjName(); name_size = obj_name.length(); } // If length is provided, get that number of characters in name - else - { - char* name_C = new char[len+1]; // temporary C-string - HDmemset(name_C, 0, len+1); // clear buffer + else { + char *name_C = new char[len + 1]; // temporary C-string + HDmemset(name_C, 0, len + 1); // clear buffer // Use overloaded function - name_size = getObjName(name_C, len+1); + name_size = getObjName(name_C, len + 1); // Convert the C object name to return obj_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Otherwise, keep obj_name intact // Return name size - return(name_size); + return (name_size); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -540,7 +552,9 @@ ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Object::~H5Object() {} +H5Object::~H5Object() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index a63229c..104e2a5 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -40,94 +40,92 @@ namespace H5 { // Inheritance: H5Location -> IdComponent // Define the operator function pointer for H5Aiterate(). -typedef void (*attr_operator_t)(H5Object& loc, - const H5std_string attr_name, - void *operator_data); +typedef void (*attr_operator_t)(H5Object &loc, const H5std_string attr_name, void *operator_data); // Define the operator function pointer for H5Ovisit3(). -typedef int (*visit_operator_t)(H5Object& obj, - const H5std_string attr_name, - const H5O_info2_t *oinfo, - void *operator_data); +typedef int (*visit_operator_t)(H5Object &obj, const H5std_string attr_name, const H5O_info2_t *oinfo, + void *operator_data); // User data for attribute iteration class UserData4Aiterate { - public: - attr_operator_t op; - void* opData; - H5Object* location; // Consider changing to H5Location + public: + attr_operator_t op; + void * opData; + H5Object * location; // Consider changing to H5Location }; // User data for visit iteration class UserData4Visit { - public: - visit_operator_t op; - void* opData; - H5Object* obj; + public: + visit_operator_t op; + void * opData; + H5Object * obj; }; class H5_DLLCPP H5Object : public H5Location { - public: - // Creates an attribute for the specified object - // PropList is currently not used, so always be default. - Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; - Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; + public: + // Creates an attribute for the specified object + // PropList is currently not used, so always be default. + Attribute createAttribute(const char *name, const DataType &type, const DataSpace &space, + const PropList &create_plist = PropList::DEFAULT) const; + Attribute createAttribute(const H5std_string &name, const DataType &type, const DataSpace &space, + const PropList &create_plist = PropList::DEFAULT) const; - // Given its name, opens the attribute that belongs to an object at - // this location. - Attribute openAttribute(const char* name) const; - Attribute openAttribute(const H5std_string& name) const; + // Given its name, opens the attribute that belongs to an object at + // this location. + Attribute openAttribute(const char *name) const; + Attribute openAttribute(const H5std_string &name) const; - // Given its index, opens the attribute that belongs to an object at - // this location. - Attribute openAttribute(const unsigned int idx) const; + // Given its index, opens the attribute that belongs to an object at + // this location. + Attribute openAttribute(const unsigned int idx) const; - // Iterate user's function over the attributes of this object. - int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL); + // Iterate user's function over the attributes of this object. + int iterateAttrs(attr_operator_t user_op, unsigned *idx = NULL, void *op_data = NULL); - // Recursively visit elements reachable from this object. - void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields); + // Recursively visit elements reachable from this object. + void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, + unsigned int fields); - // Returns the object header version of an object - unsigned objVersion() const; + // Returns the object header version of an object + unsigned objVersion() const; - // Determines the number of attributes belong to this object. - int getNumAttrs() const; + // Determines the number of attributes belong to this object. + int getNumAttrs() const; - // Checks whether the named attribute exists for this object. - bool attrExists(const char* name) const; - bool attrExists(const H5std_string& name) const; + // Checks whether the named attribute exists for this object. + bool attrExists(const char *name) const; + bool attrExists(const H5std_string &name) const; - // Renames the named attribute to a new name. - void renameAttr(const char* oldname, const char* newname) const; - void renameAttr(const H5std_string& oldname, const H5std_string& newname) const; + // Renames the named attribute to a new name. + void renameAttr(const char *oldname, const char *newname) const; + void renameAttr(const H5std_string &oldname, const H5std_string &newname) const; - // Removes the named attribute from this object. - void removeAttr(const char* name) const; - void removeAttr(const H5std_string& name) const; + // Removes the named attribute from this object. + void removeAttr(const char *name) const; + void removeAttr(const H5std_string &name) const; - // Returns an identifier. - virtual hid_t getId() const = 0; - - // Gets the name of this HDF5 object, i.e., Group, DataSet, or - // DataType. - ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; - ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const; - H5std_string getObjName() const; + // Returns an identifier. + virtual hid_t getId() const = 0; + // Gets the name of this HDF5 object, i.e., Group, DataSet, or + // DataType. + ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; + ssize_t getObjName(H5std_string &obj_name, size_t len = 0) const; + H5std_string getObjName() const; #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Default constructor - H5Object(); + protected: + // Default constructor + H5Object(); - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - virtual void p_setId(const hid_t new_id) = 0; + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + virtual void p_setId(const hid_t new_id) = 0; - // Noop destructor. - virtual ~H5Object(); + // Noop destructor. + virtual ~H5Object(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5OcreatProp.cpp b/c++/src/H5OcreatProp.cpp index 0542d5e..20e781a 100644 --- a/c++/src/H5OcreatProp.cpp +++ b/c++/src/H5OcreatProp.cpp @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -ObjCreatPropList* ObjCreatPropList::DEFAULT_ = 0; +ObjCreatPropList *ObjCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: ObjCreatPropList::getConstant @@ -40,13 +40,13 @@ ObjCreatPropList* ObjCreatPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -ObjCreatPropList* ObjCreatPropList::getConstant() +ObjCreatPropList * +ObjCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ ObjCreatPropList* ObjCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new ObjCreatPropList(H5P_OBJECT_CREATE); else - throw PropListIException("ObjCreatPropList::getConstant", "ObjCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("ObjCreatPropList::getConstant", + "ObjCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ ObjCreatPropList* ObjCreatPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::deleteConstants() +void +ObjCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void ObjCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant(); +const ObjCreatPropList &ObjCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {} +ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList copy constructor @@ -92,7 +96,9 @@ ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {} ///\param original - IN: ObjCreatPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList(original) {} +ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList overloaded constructor @@ -100,7 +106,9 @@ ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList( /// existing one. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList::setAttrPhaseChange @@ -116,11 +124,11 @@ ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {} /// H5Pset_attr_phase_change API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const +void +ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const { herr_t ret_value = H5Pset_attr_phase_change(id, max_compact, min_dense); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::setAttrPhaseChange", "H5Pset_attr_phase_change failed"); } } @@ -139,12 +147,12 @@ void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_den /// H5Pget_attr_phase_change API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const +void +ObjCreatPropList::getAttrPhaseChange(unsigned &max_compact, unsigned &min_dense) const { herr_t ret_value; ret_value = H5Pget_attr_phase_change(id, &max_compact, &min_dense); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::getAttrPhaseChange", "H5Pget_attr_phase_change failed"); } } @@ -168,11 +176,11 @@ void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_d /// in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const +void +ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const { herr_t ret_value = H5Pset_attr_creation_order(id, crt_order_flags); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::setAttrCrtOrder", "H5Pset_attr_creation_order failed"); } } @@ -190,16 +198,16 @@ void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const /// in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -unsigned ObjCreatPropList::getAttrCrtOrder() const +unsigned +ObjCreatPropList::getAttrCrtOrder() const { - herr_t ret_value; + herr_t ret_value; unsigned crt_order_flags = 0; - ret_value = H5Pget_attr_creation_order(id, &crt_order_flags); - if (ret_value < 0) - { + ret_value = H5Pget_attr_creation_order(id, &crt_order_flags); + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::getAttrCrtOrder", "H5Pget_attr_creation_order failed"); } - return(crt_order_flags); + return (crt_order_flags); } //-------------------------------------------------------------------------- @@ -207,6 +215,8 @@ unsigned ObjCreatPropList::getAttrCrtOrder() const ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::~ObjCreatPropList() {} +ObjCreatPropList::~ObjCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5OcreatProp.h b/c++/src/H5OcreatProp.h index 1d5dd55..ffafd44 100644 --- a/c++/src/H5OcreatProp.h +++ b/c++/src/H5OcreatProp.h @@ -23,49 +23,52 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP ObjCreatPropList : public PropList { - public: - ///\brief Default object creation property list. - static const ObjCreatPropList& DEFAULT; + public: + ///\brief Default object creation property list. + static const ObjCreatPropList &DEFAULT; - // Creates a object creation property list. - ObjCreatPropList(); + // Creates a object creation property list. + ObjCreatPropList(); - // Sets attribute storage phase change thresholds. - void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; + // Sets attribute storage phase change thresholds. + void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; - // Gets attribute storage phase change thresholds. - void getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const; + // Gets attribute storage phase change thresholds. + void getAttrPhaseChange(unsigned &max_compact, unsigned &min_dense) const; - // Sets tracking and indexing of attribute creation order. - void setAttrCrtOrder(unsigned crt_order_flags) const; + // Sets tracking and indexing of attribute creation order. + void setAttrCrtOrder(unsigned crt_order_flags) const; - // Gets tracking and indexing settings for attribute creation order. - unsigned getAttrCrtOrder() const; + // Gets tracking and indexing settings for attribute creation order. + unsigned getAttrCrtOrder() const; + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("ObjCreatPropList"); + } - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("ObjCreatPropList"); } + // Copy constructor: same as the original ObjCreatPropList. + ObjCreatPropList(const ObjCreatPropList &original); - // Copy constructor: same as the original ObjCreatPropList. - ObjCreatPropList(const ObjCreatPropList& original); + // Creates a copy of an existing object creation property list + // using the property list id. + ObjCreatPropList(const hid_t plist_id); - // Creates a copy of an existing object creation property list - // using the property list id. - ObjCreatPropList (const hid_t plist_id); - - // Noop destructor - virtual ~ObjCreatPropList(); + // Noop destructor + virtual ~ObjCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static ObjCreatPropList* DEFAULT_; + private: + static ObjCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static ObjCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static ObjCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 57ba5e5..5943a1b 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -51,7 +51,9 @@ PredType::PredType(const hid_t predtype_id) : AtomType(predtype_id) ///\brief Default constructor: Creates a stub predefined datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::PredType() : AtomType() {} +PredType::PredType() : AtomType() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- @@ -60,7 +62,9 @@ PredType::PredType() : AtomType() {} ///\param original - IN: PredType instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::PredType(const PredType& original) : AtomType(original) {} +PredType::PredType(const PredType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: PredType::operator= @@ -73,29 +77,35 @@ PredType::PredType(const PredType& original) : AtomType(original) {} // the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType& PredType::operator=(const PredType& rhs) +PredType & +PredType::operator=(const PredType &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } #ifndef DOXYGEN_SHOULD_SKIP_THIS // These dummy functions do not inherit from DataType - they'll // throw an DataTypeIException if invoked. -void PredType::commit(H5Location& loc, const char* name) +void +PredType::commit(H5Location &loc, const char *name) { - throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!"); + throw DataTypeIException("PredType::commit", + "Error: Attempted to commit a predefined datatype. Invalid operation!"); } -void PredType::commit(H5Location& loc, const H5std_string& name) +void +PredType::commit(H5Location &loc, const H5std_string &name) { commit(loc, name.c_str()); } -bool PredType::committed() +bool +PredType::committed() { - throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype."); + throw DataTypeIException("PredType::committed", + "Error: Attempting to check for commit status on a predefined datatype."); } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -105,7 +115,9 @@ bool PredType::committed() ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::~PredType() {} +PredType::~PredType() +{ +} /***************************************************************************** The following section is regarding the global constants PredType, @@ -115,180 +127,180 @@ PredType::~PredType() {} #ifndef DOXYGEN_SHOULD_SKIP_THIS // Definition pointers for the constants -PredType* PredType::PREDTYPE_CONST_ = 0; //dummy -PredType* PredType::STD_I8BE_; -PredType* PredType::STD_I8LE_; -PredType* PredType::STD_I16BE_; -PredType* PredType::STD_I16LE_; -PredType* PredType::STD_I32BE_; -PredType* PredType::STD_I32LE_; -PredType* PredType::STD_I64BE_; -PredType* PredType::STD_I64LE_; -PredType* PredType::STD_U8BE_; -PredType* PredType::STD_U8LE_; -PredType* PredType::STD_U16BE_; -PredType* PredType::STD_U16LE_; -PredType* PredType::STD_U32BE_; -PredType* PredType::STD_U32LE_; -PredType* PredType::STD_U64BE_; -PredType* PredType::STD_U64LE_; -PredType* PredType::STD_B8BE_; -PredType* PredType::STD_B8LE_; -PredType* PredType::STD_B16BE_; -PredType* PredType::STD_B16LE_; -PredType* PredType::STD_B32BE_; -PredType* PredType::STD_B32LE_; -PredType* PredType::STD_B64BE_; -PredType* PredType::STD_B64LE_; -PredType* PredType::STD_REF_OBJ_; -PredType* PredType::STD_REF_DSETREG_; - -PredType* PredType::C_S1_; -PredType* PredType::FORTRAN_S1_; - -PredType* PredType::IEEE_F32BE_; -PredType* PredType::IEEE_F32LE_; -PredType* PredType::IEEE_F64BE_; -PredType* PredType::IEEE_F64LE_; - -PredType* PredType::UNIX_D32BE_; -PredType* PredType::UNIX_D32LE_; -PredType* PredType::UNIX_D64BE_; -PredType* PredType::UNIX_D64LE_; - -PredType* PredType::INTEL_I8_; -PredType* PredType::INTEL_I16_; -PredType* PredType::INTEL_I32_; -PredType* PredType::INTEL_I64_; -PredType* PredType::INTEL_U8_; -PredType* PredType::INTEL_U16_; -PredType* PredType::INTEL_U32_; -PredType* PredType::INTEL_U64_; -PredType* PredType::INTEL_B8_; -PredType* PredType::INTEL_B16_; -PredType* PredType::INTEL_B32_; -PredType* PredType::INTEL_B64_; -PredType* PredType::INTEL_F32_; -PredType* PredType::INTEL_F64_; - -PredType* PredType::ALPHA_I8_; -PredType* PredType::ALPHA_I16_; -PredType* PredType::ALPHA_I32_; -PredType* PredType::ALPHA_I64_; -PredType* PredType::ALPHA_U8_; -PredType* PredType::ALPHA_U16_; -PredType* PredType::ALPHA_U32_; -PredType* PredType::ALPHA_U64_; -PredType* PredType::ALPHA_B8_; -PredType* PredType::ALPHA_B16_; -PredType* PredType::ALPHA_B32_; -PredType* PredType::ALPHA_B64_; -PredType* PredType::ALPHA_F32_; -PredType* PredType::ALPHA_F64_; - -PredType* PredType::MIPS_I8_; -PredType* PredType::MIPS_I16_; -PredType* PredType::MIPS_I32_; -PredType* PredType::MIPS_I64_; -PredType* PredType::MIPS_U8_; -PredType* PredType::MIPS_U16_; -PredType* PredType::MIPS_U32_; -PredType* PredType::MIPS_U64_; -PredType* PredType::MIPS_B8_; -PredType* PredType::MIPS_B16_; -PredType* PredType::MIPS_B32_; -PredType* PredType::MIPS_B64_; -PredType* PredType::MIPS_F32_; -PredType* PredType::MIPS_F64_; - -PredType* PredType::NATIVE_CHAR_; -PredType* PredType::NATIVE_SCHAR_; -PredType* PredType::NATIVE_UCHAR_; -PredType* PredType::NATIVE_SHORT_; -PredType* PredType::NATIVE_USHORT_; -PredType* PredType::NATIVE_INT_; -PredType* PredType::NATIVE_UINT_; -PredType* PredType::NATIVE_LONG_; -PredType* PredType::NATIVE_ULONG_; -PredType* PredType::NATIVE_LLONG_; -PredType* PredType::NATIVE_ULLONG_; -PredType* PredType::NATIVE_FLOAT_; -PredType* PredType::NATIVE_DOUBLE_; -PredType* PredType::NATIVE_LDOUBLE_; -PredType* PredType::NATIVE_B8_; -PredType* PredType::NATIVE_B16_; -PredType* PredType::NATIVE_B32_; -PredType* PredType::NATIVE_B64_; -PredType* PredType::NATIVE_OPAQUE_; -PredType* PredType::NATIVE_HSIZE_; -PredType* PredType::NATIVE_HSSIZE_; -PredType* PredType::NATIVE_HERR_; -PredType* PredType::NATIVE_HBOOL_; - -PredType* PredType::NATIVE_INT8_; -PredType* PredType::NATIVE_UINT8_; -PredType* PredType::NATIVE_INT16_; -PredType* PredType::NATIVE_UINT16_; -PredType* PredType::NATIVE_INT32_; -PredType* PredType::NATIVE_UINT32_; -PredType* PredType::NATIVE_INT64_; -PredType* PredType::NATIVE_UINT64_; +PredType *PredType::PREDTYPE_CONST_ = 0; // dummy +PredType *PredType::STD_I8BE_; +PredType *PredType::STD_I8LE_; +PredType *PredType::STD_I16BE_; +PredType *PredType::STD_I16LE_; +PredType *PredType::STD_I32BE_; +PredType *PredType::STD_I32LE_; +PredType *PredType::STD_I64BE_; +PredType *PredType::STD_I64LE_; +PredType *PredType::STD_U8BE_; +PredType *PredType::STD_U8LE_; +PredType *PredType::STD_U16BE_; +PredType *PredType::STD_U16LE_; +PredType *PredType::STD_U32BE_; +PredType *PredType::STD_U32LE_; +PredType *PredType::STD_U64BE_; +PredType *PredType::STD_U64LE_; +PredType *PredType::STD_B8BE_; +PredType *PredType::STD_B8LE_; +PredType *PredType::STD_B16BE_; +PredType *PredType::STD_B16LE_; +PredType *PredType::STD_B32BE_; +PredType *PredType::STD_B32LE_; +PredType *PredType::STD_B64BE_; +PredType *PredType::STD_B64LE_; +PredType *PredType::STD_REF_OBJ_; +PredType *PredType::STD_REF_DSETREG_; + +PredType *PredType::C_S1_; +PredType *PredType::FORTRAN_S1_; + +PredType *PredType::IEEE_F32BE_; +PredType *PredType::IEEE_F32LE_; +PredType *PredType::IEEE_F64BE_; +PredType *PredType::IEEE_F64LE_; + +PredType *PredType::UNIX_D32BE_; +PredType *PredType::UNIX_D32LE_; +PredType *PredType::UNIX_D64BE_; +PredType *PredType::UNIX_D64LE_; + +PredType *PredType::INTEL_I8_; +PredType *PredType::INTEL_I16_; +PredType *PredType::INTEL_I32_; +PredType *PredType::INTEL_I64_; +PredType *PredType::INTEL_U8_; +PredType *PredType::INTEL_U16_; +PredType *PredType::INTEL_U32_; +PredType *PredType::INTEL_U64_; +PredType *PredType::INTEL_B8_; +PredType *PredType::INTEL_B16_; +PredType *PredType::INTEL_B32_; +PredType *PredType::INTEL_B64_; +PredType *PredType::INTEL_F32_; +PredType *PredType::INTEL_F64_; + +PredType *PredType::ALPHA_I8_; +PredType *PredType::ALPHA_I16_; +PredType *PredType::ALPHA_I32_; +PredType *PredType::ALPHA_I64_; +PredType *PredType::ALPHA_U8_; +PredType *PredType::ALPHA_U16_; +PredType *PredType::ALPHA_U32_; +PredType *PredType::ALPHA_U64_; +PredType *PredType::ALPHA_B8_; +PredType *PredType::ALPHA_B16_; +PredType *PredType::ALPHA_B32_; +PredType *PredType::ALPHA_B64_; +PredType *PredType::ALPHA_F32_; +PredType *PredType::ALPHA_F64_; + +PredType *PredType::MIPS_I8_; +PredType *PredType::MIPS_I16_; +PredType *PredType::MIPS_I32_; +PredType *PredType::MIPS_I64_; +PredType *PredType::MIPS_U8_; +PredType *PredType::MIPS_U16_; +PredType *PredType::MIPS_U32_; +PredType *PredType::MIPS_U64_; +PredType *PredType::MIPS_B8_; +PredType *PredType::MIPS_B16_; +PredType *PredType::MIPS_B32_; +PredType *PredType::MIPS_B64_; +PredType *PredType::MIPS_F32_; +PredType *PredType::MIPS_F64_; + +PredType *PredType::NATIVE_CHAR_; +PredType *PredType::NATIVE_SCHAR_; +PredType *PredType::NATIVE_UCHAR_; +PredType *PredType::NATIVE_SHORT_; +PredType *PredType::NATIVE_USHORT_; +PredType *PredType::NATIVE_INT_; +PredType *PredType::NATIVE_UINT_; +PredType *PredType::NATIVE_LONG_; +PredType *PredType::NATIVE_ULONG_; +PredType *PredType::NATIVE_LLONG_; +PredType *PredType::NATIVE_ULLONG_; +PredType *PredType::NATIVE_FLOAT_; +PredType *PredType::NATIVE_DOUBLE_; +PredType *PredType::NATIVE_LDOUBLE_; +PredType *PredType::NATIVE_B8_; +PredType *PredType::NATIVE_B16_; +PredType *PredType::NATIVE_B32_; +PredType *PredType::NATIVE_B64_; +PredType *PredType::NATIVE_OPAQUE_; +PredType *PredType::NATIVE_HSIZE_; +PredType *PredType::NATIVE_HSSIZE_; +PredType *PredType::NATIVE_HERR_; +PredType *PredType::NATIVE_HBOOL_; + +PredType *PredType::NATIVE_INT8_; +PredType *PredType::NATIVE_UINT8_; +PredType *PredType::NATIVE_INT16_; +PredType *PredType::NATIVE_UINT16_; +PredType *PredType::NATIVE_INT32_; +PredType *PredType::NATIVE_UINT32_; +PredType *PredType::NATIVE_INT64_; +PredType *PredType::NATIVE_UINT64_; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 -PredType* PredType::NATIVE_INT_LEAST8_; +PredType *PredType::NATIVE_INT_LEAST8_; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 -PredType* PredType::NATIVE_UINT_LEAST8_; +PredType *PredType::NATIVE_UINT_LEAST8_; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 -PredType* PredType::NATIVE_INT_LEAST16_; +PredType *PredType::NATIVE_INT_LEAST16_; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 -PredType* PredType::NATIVE_UINT_LEAST16_; +PredType *PredType::NATIVE_UINT_LEAST16_; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 -PredType* PredType::NATIVE_INT_LEAST32_; +PredType *PredType::NATIVE_INT_LEAST32_; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 -PredType* PredType::NATIVE_UINT_LEAST32_; +PredType *PredType::NATIVE_UINT_LEAST32_; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 -PredType* PredType::NATIVE_INT_LEAST64_; +PredType *PredType::NATIVE_INT_LEAST64_; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 -PredType* PredType::NATIVE_UINT_LEAST64_; +PredType *PredType::NATIVE_UINT_LEAST64_; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 -PredType* PredType::NATIVE_INT_FAST8_; +PredType *PredType::NATIVE_INT_FAST8_; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 -PredType* PredType::NATIVE_UINT_FAST8_; +PredType *PredType::NATIVE_UINT_FAST8_; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 -PredType* PredType::NATIVE_INT_FAST16_; +PredType *PredType::NATIVE_INT_FAST16_; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 -PredType* PredType::NATIVE_UINT_FAST16_; +PredType *PredType::NATIVE_UINT_FAST16_; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 -PredType* PredType::NATIVE_INT_FAST32_; +PredType *PredType::NATIVE_INT_FAST32_; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 -PredType* PredType::NATIVE_UINT_FAST32_; +PredType *PredType::NATIVE_UINT_FAST32_; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 -PredType* PredType::NATIVE_INT_FAST64_; +PredType *PredType::NATIVE_INT_FAST64_; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 -PredType* PredType::NATIVE_UINT_FAST64_; +PredType *PredType::NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ //-------------------------------------------------------------------------- @@ -305,13 +317,13 @@ PredType* PredType::NATIVE_UINT_FAST64_; // // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -PredType* PredType::getPredTypes() +PredType * +PredType::getPredTypes() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -320,7 +332,9 @@ PredType* PredType::getPredTypes() if (PREDTYPE_CONST_ == 0) makePredTypes(); else - throw H5::DataTypeIException("PredType::getPredTypes", "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_"); + throw H5::DataTypeIException( + "PredType::getPredTypes", + "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_"); return PREDTYPE_CONST_; } @@ -329,38 +343,39 @@ PredType* PredType::getPredTypes() // Purpose Allocate all PredType constants. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void PredType::makePredTypes() +void +PredType::makePredTypes() { PREDTYPE_CONST_ = new PredType; - C_S1_ = new PredType(H5T_C_S1); - FORTRAN_S1_ = new PredType(H5T_FORTRAN_S1); + C_S1_ = new PredType(H5T_C_S1); + FORTRAN_S1_ = new PredType(H5T_FORTRAN_S1); - STD_I8BE_ = new PredType(H5T_STD_I8BE); - STD_I8LE_ = new PredType(H5T_STD_I8LE); + STD_I8BE_ = new PredType(H5T_STD_I8BE); + STD_I8LE_ = new PredType(H5T_STD_I8LE); STD_I16BE_ = new PredType(H5T_STD_I16BE); STD_I16LE_ = new PredType(H5T_STD_I16LE); STD_I32BE_ = new PredType(H5T_STD_I32BE); STD_I32LE_ = new PredType(H5T_STD_I32LE); STD_I64BE_ = new PredType(H5T_STD_I64BE); STD_I64LE_ = new PredType(H5T_STD_I64LE); - STD_U8BE_ = new PredType(H5T_STD_U8BE); - STD_U8LE_ = new PredType(H5T_STD_U8LE); + STD_U8BE_ = new PredType(H5T_STD_U8BE); + STD_U8LE_ = new PredType(H5T_STD_U8LE); STD_U16BE_ = new PredType(H5T_STD_U16BE); STD_U16LE_ = new PredType(H5T_STD_U16LE); STD_U32BE_ = new PredType(H5T_STD_U32BE); STD_U32LE_ = new PredType(H5T_STD_U32LE); STD_U64BE_ = new PredType(H5T_STD_U64BE); STD_U64LE_ = new PredType(H5T_STD_U64LE); - STD_B8BE_ = new PredType(H5T_STD_B8BE); - STD_B8LE_ = new PredType(H5T_STD_B8LE); - - STD_B16BE_ = new PredType(H5T_STD_B16BE); - STD_B16LE_ = new PredType(H5T_STD_B16LE); - STD_B32BE_ = new PredType(H5T_STD_B32BE); - STD_B32LE_ = new PredType(H5T_STD_B32LE); - STD_B64BE_ = new PredType(H5T_STD_B64BE); - STD_B64LE_ = new PredType(H5T_STD_B64LE); - STD_REF_OBJ_ = new PredType(H5T_STD_REF_OBJ); + STD_B8BE_ = new PredType(H5T_STD_B8BE); + STD_B8LE_ = new PredType(H5T_STD_B8LE); + + STD_B16BE_ = new PredType(H5T_STD_B16BE); + STD_B16LE_ = new PredType(H5T_STD_B16LE); + STD_B32BE_ = new PredType(H5T_STD_B32BE); + STD_B32LE_ = new PredType(H5T_STD_B32LE); + STD_B64BE_ = new PredType(H5T_STD_B64BE); + STD_B64LE_ = new PredType(H5T_STD_B64LE); + STD_REF_OBJ_ = new PredType(H5T_STD_REF_OBJ); STD_REF_DSETREG_ = new PredType(H5T_STD_REF_DSETREG); IEEE_F32BE_ = new PredType(H5T_IEEE_F32BE); @@ -373,84 +388,84 @@ void PredType::makePredTypes() UNIX_D64BE_ = new PredType(H5T_UNIX_D64BE); UNIX_D64LE_ = new PredType(H5T_UNIX_D64LE); - INTEL_I8_ = new PredType(H5T_INTEL_I8); + INTEL_I8_ = new PredType(H5T_INTEL_I8); INTEL_I16_ = new PredType(H5T_INTEL_I16); INTEL_I32_ = new PredType(H5T_INTEL_I32); INTEL_I64_ = new PredType(H5T_INTEL_I64); - INTEL_U8_ = new PredType(H5T_INTEL_U8); + INTEL_U8_ = new PredType(H5T_INTEL_U8); INTEL_U16_ = new PredType(H5T_INTEL_U16); INTEL_U32_ = new PredType(H5T_INTEL_U32); INTEL_U64_ = new PredType(H5T_INTEL_U64); - INTEL_B8_ = new PredType(H5T_INTEL_B8); + INTEL_B8_ = new PredType(H5T_INTEL_B8); INTEL_B16_ = new PredType(H5T_INTEL_B16); INTEL_B32_ = new PredType(H5T_INTEL_B32); INTEL_B64_ = new PredType(H5T_INTEL_B64); INTEL_F32_ = new PredType(H5T_INTEL_F32); INTEL_F64_ = new PredType(H5T_INTEL_F64); - ALPHA_I8_ = new PredType(H5T_ALPHA_I8); + ALPHA_I8_ = new PredType(H5T_ALPHA_I8); ALPHA_I16_ = new PredType(H5T_ALPHA_I16); ALPHA_I32_ = new PredType(H5T_ALPHA_I32); ALPHA_I64_ = new PredType(H5T_ALPHA_I64); - ALPHA_U8_ = new PredType(H5T_ALPHA_U8); + ALPHA_U8_ = new PredType(H5T_ALPHA_U8); ALPHA_U16_ = new PredType(H5T_ALPHA_U16); ALPHA_U32_ = new PredType(H5T_ALPHA_U32); ALPHA_U64_ = new PredType(H5T_ALPHA_U64); - ALPHA_B8_ = new PredType(H5T_ALPHA_B8); + ALPHA_B8_ = new PredType(H5T_ALPHA_B8); ALPHA_B16_ = new PredType(H5T_ALPHA_B16); ALPHA_B32_ = new PredType(H5T_ALPHA_B32); ALPHA_B64_ = new PredType(H5T_ALPHA_B64); ALPHA_F32_ = new PredType(H5T_ALPHA_F32); ALPHA_F64_ = new PredType(H5T_ALPHA_F64); - MIPS_I8_ = new PredType(H5T_MIPS_I8); + MIPS_I8_ = new PredType(H5T_MIPS_I8); MIPS_I16_ = new PredType(H5T_MIPS_I16); MIPS_I32_ = new PredType(H5T_MIPS_I32); MIPS_I64_ = new PredType(H5T_MIPS_I64); - MIPS_U8_ = new PredType(H5T_MIPS_U8); + MIPS_U8_ = new PredType(H5T_MIPS_U8); MIPS_U16_ = new PredType(H5T_MIPS_U16); MIPS_U32_ = new PredType(H5T_MIPS_U32); MIPS_U64_ = new PredType(H5T_MIPS_U64); - MIPS_B8_ = new PredType(H5T_MIPS_B8); + MIPS_B8_ = new PredType(H5T_MIPS_B8); MIPS_B16_ = new PredType(H5T_MIPS_B16); MIPS_B32_ = new PredType(H5T_MIPS_B32); MIPS_B64_ = new PredType(H5T_MIPS_B64); MIPS_F32_ = new PredType(H5T_MIPS_F32); MIPS_F64_ = new PredType(H5T_MIPS_F64); - NATIVE_CHAR_ = new PredType(H5T_NATIVE_CHAR); - NATIVE_INT_ = new PredType(H5T_NATIVE_INT); - NATIVE_FLOAT_ = new PredType(H5T_NATIVE_FLOAT); - NATIVE_SCHAR_ = new PredType(H5T_NATIVE_SCHAR); - NATIVE_UCHAR_ = new PredType(H5T_NATIVE_UCHAR); - NATIVE_SHORT_ = new PredType(H5T_NATIVE_SHORT); + NATIVE_CHAR_ = new PredType(H5T_NATIVE_CHAR); + NATIVE_INT_ = new PredType(H5T_NATIVE_INT); + NATIVE_FLOAT_ = new PredType(H5T_NATIVE_FLOAT); + NATIVE_SCHAR_ = new PredType(H5T_NATIVE_SCHAR); + NATIVE_UCHAR_ = new PredType(H5T_NATIVE_UCHAR); + NATIVE_SHORT_ = new PredType(H5T_NATIVE_SHORT); NATIVE_USHORT_ = new PredType(H5T_NATIVE_USHORT); - NATIVE_UINT_ = new PredType(H5T_NATIVE_UINT); - NATIVE_LONG_ = new PredType(H5T_NATIVE_LONG); - NATIVE_ULONG_ = new PredType(H5T_NATIVE_ULONG); - NATIVE_LLONG_ = new PredType(H5T_NATIVE_LLONG); + NATIVE_UINT_ = new PredType(H5T_NATIVE_UINT); + NATIVE_LONG_ = new PredType(H5T_NATIVE_LONG); + NATIVE_ULONG_ = new PredType(H5T_NATIVE_ULONG); + NATIVE_LLONG_ = new PredType(H5T_NATIVE_LLONG); NATIVE_ULLONG_ = new PredType(H5T_NATIVE_ULLONG); NATIVE_DOUBLE_ = new PredType(H5T_NATIVE_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 NATIVE_LDOUBLE_ = new PredType(H5T_NATIVE_LDOUBLE); #endif - NATIVE_B8_ = new PredType(H5T_NATIVE_B8); - NATIVE_B16_ = new PredType(H5T_NATIVE_B16); - NATIVE_B32_ = new PredType(H5T_NATIVE_B32); - NATIVE_B64_ = new PredType(H5T_NATIVE_B64); + NATIVE_B8_ = new PredType(H5T_NATIVE_B8); + NATIVE_B16_ = new PredType(H5T_NATIVE_B16); + NATIVE_B32_ = new PredType(H5T_NATIVE_B32); + NATIVE_B64_ = new PredType(H5T_NATIVE_B64); NATIVE_OPAQUE_ = new PredType(H5T_NATIVE_OPAQUE); - NATIVE_HSIZE_ = new PredType(H5T_NATIVE_HSIZE); + NATIVE_HSIZE_ = new PredType(H5T_NATIVE_HSIZE); NATIVE_HSSIZE_ = new PredType(H5T_NATIVE_HSSIZE); - NATIVE_HERR_ = new PredType(H5T_NATIVE_HERR); - NATIVE_HBOOL_ = new PredType(H5T_NATIVE_HBOOL); + NATIVE_HERR_ = new PredType(H5T_NATIVE_HERR); + NATIVE_HBOOL_ = new PredType(H5T_NATIVE_HBOOL); - NATIVE_INT8_ = new PredType(H5T_NATIVE_INT8); - NATIVE_UINT8_ = new PredType(H5T_NATIVE_UINT8); - NATIVE_INT16_ = new PredType(H5T_NATIVE_INT16); + NATIVE_INT8_ = new PredType(H5T_NATIVE_INT8); + NATIVE_UINT8_ = new PredType(H5T_NATIVE_UINT8); + NATIVE_INT16_ = new PredType(H5T_NATIVE_INT16); NATIVE_UINT16_ = new PredType(H5T_NATIVE_UINT16); - NATIVE_INT32_ = new PredType(H5T_NATIVE_INT32); + NATIVE_INT32_ = new PredType(H5T_NATIVE_INT32); NATIVE_UINT32_ = new PredType(H5T_NATIVE_UINT32); - NATIVE_INT64_ = new PredType(H5T_NATIVE_INT64); + NATIVE_INT64_ = new PredType(H5T_NATIVE_INT64); NATIVE_UINT64_ = new PredType(H5T_NATIVE_UINT64); // LEAST types @@ -513,13 +528,13 @@ void PredType::makePredTypes() } // makePredTypes - //-------------------------------------------------------------------------- // Function: PredType::deleteConstants // Purpose Deletes all PredType constant pointers. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void PredType::deleteConstants() +void +PredType::deleteConstants() { delete STD_I8BE_; delete STD_I8LE_; @@ -709,186 +724,186 @@ void PredType::deleteConstants() // PredType constants. Note that, there is a similar function to getPredTypes() // in other classes, that have global constants, is called getConstant(). -const PredType& PredType::PREDTYPE_CONST = *PredType::getPredTypes(); -const PredType& PredType::STD_I8BE = *STD_I8BE_; -const PredType& PredType::STD_I8LE = *STD_I8LE_; -const PredType& PredType::STD_I16BE = *STD_I16BE_; -const PredType& PredType::STD_I16LE = *STD_I16LE_; -const PredType& PredType::STD_I32BE = *STD_I32BE_; -const PredType& PredType::STD_I32LE = *STD_I32LE_; -const PredType& PredType::STD_I64BE = *STD_I64BE_; -const PredType& PredType::STD_I64LE = *STD_I64LE_; -const PredType& PredType::STD_U8BE = *STD_U8BE_; -const PredType& PredType::STD_U8LE = *STD_U8LE_; -const PredType& PredType::STD_U16BE = *STD_U16BE_; -const PredType& PredType::STD_U16LE = *STD_U16LE_; -const PredType& PredType::STD_U32BE = *STD_U32BE_; -const PredType& PredType::STD_U32LE = *STD_U32LE_; -const PredType& PredType::STD_U64BE = *STD_U64BE_; -const PredType& PredType::STD_U64LE = *STD_U64LE_; -const PredType& PredType::STD_B8BE = *STD_B8BE_; -const PredType& PredType::STD_B8LE = *STD_B8LE_; -const PredType& PredType::STD_B16BE = *STD_B16BE_; -const PredType& PredType::STD_B16LE = *STD_B16LE_; -const PredType& PredType::STD_B32BE = *STD_B32BE_; -const PredType& PredType::STD_B32LE = *STD_B32LE_; -const PredType& PredType::STD_B64BE = *STD_B64BE_; -const PredType& PredType::STD_B64LE = *STD_B64LE_; -const PredType& PredType::STD_REF_OBJ = *STD_REF_OBJ_; -const PredType& PredType::STD_REF_DSETREG = *STD_REF_DSETREG_; - -const PredType& PredType::C_S1 = *C_S1_; -const PredType& PredType::FORTRAN_S1 = *FORTRAN_S1_; - -const PredType& PredType::IEEE_F32BE = *IEEE_F32BE_; -const PredType& PredType::IEEE_F32LE = *IEEE_F32LE_; -const PredType& PredType::IEEE_F64BE = *IEEE_F64BE_; -const PredType& PredType::IEEE_F64LE = *IEEE_F64LE_; - -const PredType& PredType::UNIX_D32BE = *UNIX_D32BE_; -const PredType& PredType::UNIX_D32LE = *UNIX_D32LE_; -const PredType& PredType::UNIX_D64BE = *UNIX_D64BE_; -const PredType& PredType::UNIX_D64LE = *UNIX_D64LE_; - -const PredType& PredType::INTEL_I8 = *INTEL_I8_; -const PredType& PredType::INTEL_I16 = *INTEL_I16_; -const PredType& PredType::INTEL_I32 = *INTEL_I32_; -const PredType& PredType::INTEL_I64 = *INTEL_I64_; -const PredType& PredType::INTEL_U8 = *INTEL_U8_; -const PredType& PredType::INTEL_U16 = *INTEL_U16_; -const PredType& PredType::INTEL_U32 = *INTEL_U32_; -const PredType& PredType::INTEL_U64 = *INTEL_U64_; -const PredType& PredType::INTEL_B8 = *INTEL_B8_; -const PredType& PredType::INTEL_B16 = *INTEL_B16_; -const PredType& PredType::INTEL_B32 = *INTEL_B32_; -const PredType& PredType::INTEL_B64 = *INTEL_B64_; -const PredType& PredType::INTEL_F32 = *INTEL_F32_; -const PredType& PredType::INTEL_F64 = *INTEL_F64_; - -const PredType& PredType::ALPHA_I8 = *ALPHA_I8_; -const PredType& PredType::ALPHA_I16 = *ALPHA_I16_; -const PredType& PredType::ALPHA_I32 = *ALPHA_I32_; -const PredType& PredType::ALPHA_I64 = *ALPHA_I64_; -const PredType& PredType::ALPHA_U8 = *ALPHA_U8_; -const PredType& PredType::ALPHA_U16 = *ALPHA_U16_; -const PredType& PredType::ALPHA_U32 = *ALPHA_U32_; -const PredType& PredType::ALPHA_U64 = *ALPHA_U64_; -const PredType& PredType::ALPHA_B8 = *ALPHA_B8_; -const PredType& PredType::ALPHA_B16 = *ALPHA_B16_; -const PredType& PredType::ALPHA_B32 = *ALPHA_B32_; -const PredType& PredType::ALPHA_B64 = *ALPHA_B64_; -const PredType& PredType::ALPHA_F32 = *ALPHA_F32_; -const PredType& PredType::ALPHA_F64 = *ALPHA_F64_; - -const PredType& PredType::MIPS_I8 = *MIPS_I8_; -const PredType& PredType::MIPS_I16 = *MIPS_I16_; -const PredType& PredType::MIPS_I32 = *MIPS_I32_; -const PredType& PredType::MIPS_I64 = *MIPS_I64_; -const PredType& PredType::MIPS_U8 = *MIPS_U8_; -const PredType& PredType::MIPS_U16 = *MIPS_U16_; -const PredType& PredType::MIPS_U32 = *MIPS_U32_; -const PredType& PredType::MIPS_U64 = *MIPS_U64_; -const PredType& PredType::MIPS_B8 = *MIPS_B8_; -const PredType& PredType::MIPS_B16 = *MIPS_B16_; -const PredType& PredType::MIPS_B32 = *MIPS_B32_; -const PredType& PredType::MIPS_B64 = *MIPS_B64_; -const PredType& PredType::MIPS_F32 = *MIPS_F32_; -const PredType& PredType::MIPS_F64 = *MIPS_F64_; - -const PredType& PredType::NATIVE_CHAR = *NATIVE_CHAR_; -const PredType& PredType::NATIVE_SCHAR = *NATIVE_SCHAR_; -const PredType& PredType::NATIVE_UCHAR = *NATIVE_UCHAR_; -const PredType& PredType::NATIVE_SHORT = *NATIVE_SHORT_; -const PredType& PredType::NATIVE_USHORT = *NATIVE_USHORT_; -const PredType& PredType::NATIVE_INT = *NATIVE_INT_; -const PredType& PredType::NATIVE_UINT = *NATIVE_UINT_; -const PredType& PredType::NATIVE_LONG = *NATIVE_LONG_; -const PredType& PredType::NATIVE_ULONG = *NATIVE_ULONG_; -const PredType& PredType::NATIVE_LLONG = *NATIVE_LLONG_; -const PredType& PredType::NATIVE_ULLONG = *NATIVE_ULLONG_; -const PredType& PredType::NATIVE_FLOAT = *NATIVE_FLOAT_; -const PredType& PredType::NATIVE_DOUBLE = *NATIVE_DOUBLE_; -const PredType& PredType::NATIVE_LDOUBLE = *NATIVE_LDOUBLE_; -const PredType& PredType::NATIVE_B8 = *NATIVE_B8_; -const PredType& PredType::NATIVE_B16 = *NATIVE_B16_; -const PredType& PredType::NATIVE_B32 = *NATIVE_B32_; -const PredType& PredType::NATIVE_B64 = *NATIVE_B64_; -const PredType& PredType::NATIVE_OPAQUE = *NATIVE_OPAQUE_; -const PredType& PredType::NATIVE_HSIZE = *NATIVE_HSIZE_; -const PredType& PredType::NATIVE_HSSIZE = *NATIVE_HSSIZE_; -const PredType& PredType::NATIVE_HERR = *NATIVE_HERR_; -const PredType& PredType::NATIVE_HBOOL = *NATIVE_HBOOL_; - -const PredType& PredType::NATIVE_INT8 = *NATIVE_INT8_; -const PredType& PredType::NATIVE_UINT8 = *NATIVE_UINT8_; -const PredType& PredType::NATIVE_INT16 = *NATIVE_INT16_; -const PredType& PredType::NATIVE_UINT16 = *NATIVE_UINT16_; -const PredType& PredType::NATIVE_INT32 = *NATIVE_INT32_; -const PredType& PredType::NATIVE_UINT32 = *NATIVE_UINT32_; -const PredType& PredType::NATIVE_INT64 = *NATIVE_INT64_; -const PredType& PredType::NATIVE_UINT64 = *NATIVE_UINT64_; +const PredType &PredType::PREDTYPE_CONST = *PredType::getPredTypes(); +const PredType &PredType::STD_I8BE = *STD_I8BE_; +const PredType &PredType::STD_I8LE = *STD_I8LE_; +const PredType &PredType::STD_I16BE = *STD_I16BE_; +const PredType &PredType::STD_I16LE = *STD_I16LE_; +const PredType &PredType::STD_I32BE = *STD_I32BE_; +const PredType &PredType::STD_I32LE = *STD_I32LE_; +const PredType &PredType::STD_I64BE = *STD_I64BE_; +const PredType &PredType::STD_I64LE = *STD_I64LE_; +const PredType &PredType::STD_U8BE = *STD_U8BE_; +const PredType &PredType::STD_U8LE = *STD_U8LE_; +const PredType &PredType::STD_U16BE = *STD_U16BE_; +const PredType &PredType::STD_U16LE = *STD_U16LE_; +const PredType &PredType::STD_U32BE = *STD_U32BE_; +const PredType &PredType::STD_U32LE = *STD_U32LE_; +const PredType &PredType::STD_U64BE = *STD_U64BE_; +const PredType &PredType::STD_U64LE = *STD_U64LE_; +const PredType &PredType::STD_B8BE = *STD_B8BE_; +const PredType &PredType::STD_B8LE = *STD_B8LE_; +const PredType &PredType::STD_B16BE = *STD_B16BE_; +const PredType &PredType::STD_B16LE = *STD_B16LE_; +const PredType &PredType::STD_B32BE = *STD_B32BE_; +const PredType &PredType::STD_B32LE = *STD_B32LE_; +const PredType &PredType::STD_B64BE = *STD_B64BE_; +const PredType &PredType::STD_B64LE = *STD_B64LE_; +const PredType &PredType::STD_REF_OBJ = *STD_REF_OBJ_; +const PredType &PredType::STD_REF_DSETREG = *STD_REF_DSETREG_; + +const PredType &PredType::C_S1 = *C_S1_; +const PredType &PredType::FORTRAN_S1 = *FORTRAN_S1_; + +const PredType &PredType::IEEE_F32BE = *IEEE_F32BE_; +const PredType &PredType::IEEE_F32LE = *IEEE_F32LE_; +const PredType &PredType::IEEE_F64BE = *IEEE_F64BE_; +const PredType &PredType::IEEE_F64LE = *IEEE_F64LE_; + +const PredType &PredType::UNIX_D32BE = *UNIX_D32BE_; +const PredType &PredType::UNIX_D32LE = *UNIX_D32LE_; +const PredType &PredType::UNIX_D64BE = *UNIX_D64BE_; +const PredType &PredType::UNIX_D64LE = *UNIX_D64LE_; + +const PredType &PredType::INTEL_I8 = *INTEL_I8_; +const PredType &PredType::INTEL_I16 = *INTEL_I16_; +const PredType &PredType::INTEL_I32 = *INTEL_I32_; +const PredType &PredType::INTEL_I64 = *INTEL_I64_; +const PredType &PredType::INTEL_U8 = *INTEL_U8_; +const PredType &PredType::INTEL_U16 = *INTEL_U16_; +const PredType &PredType::INTEL_U32 = *INTEL_U32_; +const PredType &PredType::INTEL_U64 = *INTEL_U64_; +const PredType &PredType::INTEL_B8 = *INTEL_B8_; +const PredType &PredType::INTEL_B16 = *INTEL_B16_; +const PredType &PredType::INTEL_B32 = *INTEL_B32_; +const PredType &PredType::INTEL_B64 = *INTEL_B64_; +const PredType &PredType::INTEL_F32 = *INTEL_F32_; +const PredType &PredType::INTEL_F64 = *INTEL_F64_; + +const PredType &PredType::ALPHA_I8 = *ALPHA_I8_; +const PredType &PredType::ALPHA_I16 = *ALPHA_I16_; +const PredType &PredType::ALPHA_I32 = *ALPHA_I32_; +const PredType &PredType::ALPHA_I64 = *ALPHA_I64_; +const PredType &PredType::ALPHA_U8 = *ALPHA_U8_; +const PredType &PredType::ALPHA_U16 = *ALPHA_U16_; +const PredType &PredType::ALPHA_U32 = *ALPHA_U32_; +const PredType &PredType::ALPHA_U64 = *ALPHA_U64_; +const PredType &PredType::ALPHA_B8 = *ALPHA_B8_; +const PredType &PredType::ALPHA_B16 = *ALPHA_B16_; +const PredType &PredType::ALPHA_B32 = *ALPHA_B32_; +const PredType &PredType::ALPHA_B64 = *ALPHA_B64_; +const PredType &PredType::ALPHA_F32 = *ALPHA_F32_; +const PredType &PredType::ALPHA_F64 = *ALPHA_F64_; + +const PredType &PredType::MIPS_I8 = *MIPS_I8_; +const PredType &PredType::MIPS_I16 = *MIPS_I16_; +const PredType &PredType::MIPS_I32 = *MIPS_I32_; +const PredType &PredType::MIPS_I64 = *MIPS_I64_; +const PredType &PredType::MIPS_U8 = *MIPS_U8_; +const PredType &PredType::MIPS_U16 = *MIPS_U16_; +const PredType &PredType::MIPS_U32 = *MIPS_U32_; +const PredType &PredType::MIPS_U64 = *MIPS_U64_; +const PredType &PredType::MIPS_B8 = *MIPS_B8_; +const PredType &PredType::MIPS_B16 = *MIPS_B16_; +const PredType &PredType::MIPS_B32 = *MIPS_B32_; +const PredType &PredType::MIPS_B64 = *MIPS_B64_; +const PredType &PredType::MIPS_F32 = *MIPS_F32_; +const PredType &PredType::MIPS_F64 = *MIPS_F64_; + +const PredType &PredType::NATIVE_CHAR = *NATIVE_CHAR_; +const PredType &PredType::NATIVE_SCHAR = *NATIVE_SCHAR_; +const PredType &PredType::NATIVE_UCHAR = *NATIVE_UCHAR_; +const PredType &PredType::NATIVE_SHORT = *NATIVE_SHORT_; +const PredType &PredType::NATIVE_USHORT = *NATIVE_USHORT_; +const PredType &PredType::NATIVE_INT = *NATIVE_INT_; +const PredType &PredType::NATIVE_UINT = *NATIVE_UINT_; +const PredType &PredType::NATIVE_LONG = *NATIVE_LONG_; +const PredType &PredType::NATIVE_ULONG = *NATIVE_ULONG_; +const PredType &PredType::NATIVE_LLONG = *NATIVE_LLONG_; +const PredType &PredType::NATIVE_ULLONG = *NATIVE_ULLONG_; +const PredType &PredType::NATIVE_FLOAT = *NATIVE_FLOAT_; +const PredType &PredType::NATIVE_DOUBLE = *NATIVE_DOUBLE_; +const PredType &PredType::NATIVE_LDOUBLE = *NATIVE_LDOUBLE_; +const PredType &PredType::NATIVE_B8 = *NATIVE_B8_; +const PredType &PredType::NATIVE_B16 = *NATIVE_B16_; +const PredType &PredType::NATIVE_B32 = *NATIVE_B32_; +const PredType &PredType::NATIVE_B64 = *NATIVE_B64_; +const PredType &PredType::NATIVE_OPAQUE = *NATIVE_OPAQUE_; +const PredType &PredType::NATIVE_HSIZE = *NATIVE_HSIZE_; +const PredType &PredType::NATIVE_HSSIZE = *NATIVE_HSSIZE_; +const PredType &PredType::NATIVE_HERR = *NATIVE_HERR_; +const PredType &PredType::NATIVE_HBOOL = *NATIVE_HBOOL_; + +const PredType &PredType::NATIVE_INT8 = *NATIVE_INT8_; +const PredType &PredType::NATIVE_UINT8 = *NATIVE_UINT8_; +const PredType &PredType::NATIVE_INT16 = *NATIVE_INT16_; +const PredType &PredType::NATIVE_UINT16 = *NATIVE_UINT16_; +const PredType &PredType::NATIVE_INT32 = *NATIVE_INT32_; +const PredType &PredType::NATIVE_UINT32 = *NATIVE_UINT32_; +const PredType &PredType::NATIVE_INT64 = *NATIVE_INT64_; +const PredType &PredType::NATIVE_UINT64 = *NATIVE_UINT64_; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 -const PredType& PredType::NATIVE_INT_LEAST8 = *NATIVE_INT_LEAST8_; +const PredType &PredType::NATIVE_INT_LEAST8 = *NATIVE_INT_LEAST8_; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 -const PredType& PredType::NATIVE_UINT_LEAST8 = *NATIVE_UINT_LEAST8_; +const PredType &PredType::NATIVE_UINT_LEAST8 = *NATIVE_UINT_LEAST8_; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 -const PredType& PredType::NATIVE_INT_LEAST16 = *NATIVE_INT_LEAST16_; +const PredType &PredType::NATIVE_INT_LEAST16 = *NATIVE_INT_LEAST16_; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 -const PredType& PredType::NATIVE_UINT_LEAST16 = *NATIVE_UINT_LEAST16_; +const PredType &PredType::NATIVE_UINT_LEAST16 = *NATIVE_UINT_LEAST16_; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 -const PredType& PredType::NATIVE_INT_LEAST32 = *NATIVE_INT_LEAST32_; +const PredType &PredType::NATIVE_INT_LEAST32 = *NATIVE_INT_LEAST32_; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 -const PredType& PredType::NATIVE_UINT_LEAST32 = *NATIVE_UINT_LEAST32_; +const PredType &PredType::NATIVE_UINT_LEAST32 = *NATIVE_UINT_LEAST32_; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 -const PredType& PredType::NATIVE_INT_LEAST64 = *NATIVE_INT_LEAST64_; +const PredType &PredType::NATIVE_INT_LEAST64 = *NATIVE_INT_LEAST64_; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 -const PredType& PredType::NATIVE_UINT_LEAST64 = *NATIVE_UINT_LEAST64_; +const PredType &PredType::NATIVE_UINT_LEAST64 = *NATIVE_UINT_LEAST64_; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 -const PredType& PredType::NATIVE_INT_FAST8 = *NATIVE_INT_FAST8_; +const PredType &PredType::NATIVE_INT_FAST8 = *NATIVE_INT_FAST8_; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 -const PredType& PredType::NATIVE_UINT_FAST8 = *NATIVE_UINT_FAST8_; +const PredType &PredType::NATIVE_UINT_FAST8 = *NATIVE_UINT_FAST8_; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 -const PredType& PredType::NATIVE_INT_FAST16 = *NATIVE_INT_FAST16_; +const PredType &PredType::NATIVE_INT_FAST16 = *NATIVE_INT_FAST16_; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 -const PredType& PredType::NATIVE_UINT_FAST16 = *NATIVE_UINT_FAST16_; +const PredType &PredType::NATIVE_UINT_FAST16 = *NATIVE_UINT_FAST16_; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 -const PredType& PredType::NATIVE_INT_FAST32 = *NATIVE_INT_FAST32_; +const PredType &PredType::NATIVE_INT_FAST32 = *NATIVE_INT_FAST32_; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 -const PredType& PredType::NATIVE_UINT_FAST32 = *NATIVE_UINT_FAST32_; +const PredType &PredType::NATIVE_UINT_FAST32 = *NATIVE_UINT_FAST32_; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 -const PredType& PredType::NATIVE_INT_FAST64 = *NATIVE_INT_FAST64_; +const PredType &PredType::NATIVE_INT_FAST64 = *NATIVE_INT_FAST64_; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 -const PredType& PredType::NATIVE_UINT_FAST64 = *NATIVE_UINT_FAST64_; +const PredType &PredType::NATIVE_UINT_FAST64 = *NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 /*************************************************************************** Design Note @@ -1102,4 +1117,3 @@ September 2015: using PropList's because of the class types and in favor of clarity. ****************************************************************************/ - diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index 0978384..2d1185b 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -26,412 +26,416 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP PredType : public AtomType { - public: - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("PredType"); } - - // Makes a copy of the predefined type and stores the new - // id in the left hand side object. - PredType& operator=(const PredType& rhs); - - // Copy constructor: same as the original PredType. - PredType(const PredType& original); - - // Noop destructor - virtual ~PredType(); - - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(H5Location& loc, const H5std_string& name); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(H5Location& loc, const char* name); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - bool committed(); - - ///\brief PredType constants - static const PredType& STD_I8BE; - static const PredType& STD_I8LE; - static const PredType& STD_I16BE; - static const PredType& STD_I16LE; - static const PredType& STD_I32BE; - static const PredType& STD_I32LE; - static const PredType& STD_I64BE; - static const PredType& STD_I64LE; - static const PredType& STD_U8BE; - static const PredType& STD_U8LE; - static const PredType& STD_U16BE; - static const PredType& STD_U16LE; - static const PredType& STD_U32BE; - static const PredType& STD_U32LE; - static const PredType& STD_U64BE; - static const PredType& STD_U64LE; - static const PredType& STD_B8BE; - static const PredType& STD_B8LE; - static const PredType& STD_B16BE; - static const PredType& STD_B16LE; - static const PredType& STD_B32BE; - static const PredType& STD_B32LE; - static const PredType& STD_B64BE; - static const PredType& STD_B64LE; - static const PredType& STD_REF_OBJ; - static const PredType& STD_REF_DSETREG; - - static const PredType& C_S1; - static const PredType& FORTRAN_S1; - - static const PredType& IEEE_F32BE; - static const PredType& IEEE_F32LE; - static const PredType& IEEE_F64BE; - static const PredType& IEEE_F64LE; - - static const PredType& UNIX_D32BE; - static const PredType& UNIX_D32LE; - static const PredType& UNIX_D64BE; - static const PredType& UNIX_D64LE; - - static const PredType& INTEL_I8; - static const PredType& INTEL_I16; - static const PredType& INTEL_I32; - static const PredType& INTEL_I64; - static const PredType& INTEL_U8; - static const PredType& INTEL_U16; - static const PredType& INTEL_U32; - static const PredType& INTEL_U64; - static const PredType& INTEL_B8; - static const PredType& INTEL_B16; - static const PredType& INTEL_B32; - static const PredType& INTEL_B64; - static const PredType& INTEL_F32; - static const PredType& INTEL_F64; - - static const PredType& ALPHA_I8; - static const PredType& ALPHA_I16; - static const PredType& ALPHA_I32; - static const PredType& ALPHA_I64; - static const PredType& ALPHA_U8; - static const PredType& ALPHA_U16; - static const PredType& ALPHA_U32; - static const PredType& ALPHA_U64; - static const PredType& ALPHA_B8; - static const PredType& ALPHA_B16; - static const PredType& ALPHA_B32; - static const PredType& ALPHA_B64; - static const PredType& ALPHA_F32; - static const PredType& ALPHA_F64; - - static const PredType& MIPS_I8; - static const PredType& MIPS_I16; - static const PredType& MIPS_I32; - static const PredType& MIPS_I64; - static const PredType& MIPS_U8; - static const PredType& MIPS_U16; - static const PredType& MIPS_U32; - static const PredType& MIPS_U64; - static const PredType& MIPS_B8; - static const PredType& MIPS_B16; - static const PredType& MIPS_B32; - static const PredType& MIPS_B64; - static const PredType& MIPS_F32; - static const PredType& MIPS_F64; - - static const PredType& NATIVE_CHAR; - static const PredType& NATIVE_SCHAR; - static const PredType& NATIVE_UCHAR; - static const PredType& NATIVE_SHORT; - static const PredType& NATIVE_USHORT; - static const PredType& NATIVE_INT; - static const PredType& NATIVE_UINT; - static const PredType& NATIVE_LONG; - static const PredType& NATIVE_ULONG; - static const PredType& NATIVE_LLONG; - static const PredType& NATIVE_ULLONG; - static const PredType& NATIVE_FLOAT; - static const PredType& NATIVE_DOUBLE; - static const PredType& NATIVE_LDOUBLE; - static const PredType& NATIVE_B8; - static const PredType& NATIVE_B16; - static const PredType& NATIVE_B32; - static const PredType& NATIVE_B64; - static const PredType& NATIVE_OPAQUE; - static const PredType& NATIVE_HSIZE; - static const PredType& NATIVE_HSSIZE; - static const PredType& NATIVE_HERR; - static const PredType& NATIVE_HBOOL; - - static const PredType& NATIVE_INT8; - static const PredType& NATIVE_UINT8; - static const PredType& NATIVE_INT16; - static const PredType& NATIVE_UINT16; - static const PredType& NATIVE_INT32; - static const PredType& NATIVE_UINT32; - static const PredType& NATIVE_INT64; - static const PredType& NATIVE_UINT64; + public: + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("PredType"); + } + + // Makes a copy of the predefined type and stores the new + // id in the left hand side object. + PredType &operator=(const PredType &rhs); + + // Copy constructor: same as the original PredType. + PredType(const PredType &original); + + // Noop destructor + virtual ~PredType(); + + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location &loc, const H5std_string &name); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location &loc, const char *name); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + bool committed(); + + ///\brief PredType constants + static const PredType &STD_I8BE; + static const PredType &STD_I8LE; + static const PredType &STD_I16BE; + static const PredType &STD_I16LE; + static const PredType &STD_I32BE; + static const PredType &STD_I32LE; + static const PredType &STD_I64BE; + static const PredType &STD_I64LE; + static const PredType &STD_U8BE; + static const PredType &STD_U8LE; + static const PredType &STD_U16BE; + static const PredType &STD_U16LE; + static const PredType &STD_U32BE; + static const PredType &STD_U32LE; + static const PredType &STD_U64BE; + static const PredType &STD_U64LE; + static const PredType &STD_B8BE; + static const PredType &STD_B8LE; + static const PredType &STD_B16BE; + static const PredType &STD_B16LE; + static const PredType &STD_B32BE; + static const PredType &STD_B32LE; + static const PredType &STD_B64BE; + static const PredType &STD_B64LE; + static const PredType &STD_REF_OBJ; + static const PredType &STD_REF_DSETREG; + + static const PredType &C_S1; + static const PredType &FORTRAN_S1; + + static const PredType &IEEE_F32BE; + static const PredType &IEEE_F32LE; + static const PredType &IEEE_F64BE; + static const PredType &IEEE_F64LE; + + static const PredType &UNIX_D32BE; + static const PredType &UNIX_D32LE; + static const PredType &UNIX_D64BE; + static const PredType &UNIX_D64LE; + + static const PredType &INTEL_I8; + static const PredType &INTEL_I16; + static const PredType &INTEL_I32; + static const PredType &INTEL_I64; + static const PredType &INTEL_U8; + static const PredType &INTEL_U16; + static const PredType &INTEL_U32; + static const PredType &INTEL_U64; + static const PredType &INTEL_B8; + static const PredType &INTEL_B16; + static const PredType &INTEL_B32; + static const PredType &INTEL_B64; + static const PredType &INTEL_F32; + static const PredType &INTEL_F64; + + static const PredType &ALPHA_I8; + static const PredType &ALPHA_I16; + static const PredType &ALPHA_I32; + static const PredType &ALPHA_I64; + static const PredType &ALPHA_U8; + static const PredType &ALPHA_U16; + static const PredType &ALPHA_U32; + static const PredType &ALPHA_U64; + static const PredType &ALPHA_B8; + static const PredType &ALPHA_B16; + static const PredType &ALPHA_B32; + static const PredType &ALPHA_B64; + static const PredType &ALPHA_F32; + static const PredType &ALPHA_F64; + + static const PredType &MIPS_I8; + static const PredType &MIPS_I16; + static const PredType &MIPS_I32; + static const PredType &MIPS_I64; + static const PredType &MIPS_U8; + static const PredType &MIPS_U16; + static const PredType &MIPS_U32; + static const PredType &MIPS_U64; + static const PredType &MIPS_B8; + static const PredType &MIPS_B16; + static const PredType &MIPS_B32; + static const PredType &MIPS_B64; + static const PredType &MIPS_F32; + static const PredType &MIPS_F64; + + static const PredType &NATIVE_CHAR; + static const PredType &NATIVE_SCHAR; + static const PredType &NATIVE_UCHAR; + static const PredType &NATIVE_SHORT; + static const PredType &NATIVE_USHORT; + static const PredType &NATIVE_INT; + static const PredType &NATIVE_UINT; + static const PredType &NATIVE_LONG; + static const PredType &NATIVE_ULONG; + static const PredType &NATIVE_LLONG; + static const PredType &NATIVE_ULLONG; + static const PredType &NATIVE_FLOAT; + static const PredType &NATIVE_DOUBLE; + static const PredType &NATIVE_LDOUBLE; + static const PredType &NATIVE_B8; + static const PredType &NATIVE_B16; + static const PredType &NATIVE_B32; + static const PredType &NATIVE_B64; + static const PredType &NATIVE_OPAQUE; + static const PredType &NATIVE_HSIZE; + static const PredType &NATIVE_HSSIZE; + static const PredType &NATIVE_HERR; + static const PredType &NATIVE_HBOOL; + + static const PredType &NATIVE_INT8; + static const PredType &NATIVE_UINT8; + static const PredType &NATIVE_INT16; + static const PredType &NATIVE_UINT16; + static const PredType &NATIVE_INT32; + static const PredType &NATIVE_UINT32; + static const PredType &NATIVE_INT64; + static const PredType &NATIVE_UINT64; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 - static const PredType& NATIVE_INT_LEAST8; + static const PredType &NATIVE_INT_LEAST8; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 - static const PredType& NATIVE_UINT_LEAST8; + static const PredType &NATIVE_UINT_LEAST8; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 - static const PredType& NATIVE_INT_LEAST16; + static const PredType &NATIVE_INT_LEAST16; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 - static const PredType& NATIVE_UINT_LEAST16; + static const PredType &NATIVE_UINT_LEAST16; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 - static const PredType& NATIVE_INT_LEAST32; + static const PredType &NATIVE_INT_LEAST32; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 - static const PredType& NATIVE_UINT_LEAST32; + static const PredType &NATIVE_UINT_LEAST32; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 - static const PredType& NATIVE_INT_LEAST64; + static const PredType &NATIVE_INT_LEAST64; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 - static const PredType& NATIVE_UINT_LEAST64; + static const PredType &NATIVE_UINT_LEAST64; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 - static const PredType& NATIVE_INT_FAST8; + static const PredType &NATIVE_INT_FAST8; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 - static const PredType& NATIVE_UINT_FAST8; + static const PredType &NATIVE_UINT_FAST8; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 - static const PredType& NATIVE_INT_FAST16; + static const PredType &NATIVE_INT_FAST16; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 - static const PredType& NATIVE_UINT_FAST16; + static const PredType &NATIVE_UINT_FAST16; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 - static const PredType& NATIVE_INT_FAST32; + static const PredType &NATIVE_INT_FAST32; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 - static const PredType& NATIVE_UINT_FAST32; + static const PredType &NATIVE_UINT_FAST32; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 - static const PredType& NATIVE_INT_FAST64; + static const PredType &NATIVE_INT_FAST64; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 - static const PredType& NATIVE_UINT_FAST64; + static const PredType &NATIVE_UINT_FAST64; #endif /* H5_SIZEOF_UINT_FAST64_T */ #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the PredType global constants - static void deleteConstants(); - - // Dummy constant - static const PredType& PREDTYPE_CONST; // dummy constant - - protected: - // Default constructor - PredType(); - - // Creates a pre-defined type using an HDF5 pre-defined constant - PredType(const hid_t predtype_id); // used by the library only - - private: - // Activates the creation of the PredType global constants - static PredType* getPredTypes(); - - // Dynamically allocates PredType global constants - static void makePredTypes(); - - // Dummy constant - static PredType* PREDTYPE_CONST_; - - // Declaration of pointers to constants - static PredType* STD_I8BE_; - static PredType* STD_I8LE_; - static PredType* STD_I16BE_; - static PredType* STD_I16LE_; - static PredType* STD_I32BE_; - static PredType* STD_I32LE_; - static PredType* STD_I64BE_; - static PredType* STD_I64LE_; - static PredType* STD_U8BE_; - static PredType* STD_U8LE_; - static PredType* STD_U16BE_; - static PredType* STD_U16LE_; - static PredType* STD_U32BE_; - static PredType* STD_U32LE_; - static PredType* STD_U64BE_; - static PredType* STD_U64LE_; - static PredType* STD_B8BE_; - static PredType* STD_B8LE_; - static PredType* STD_B16BE_; - static PredType* STD_B16LE_; - static PredType* STD_B32BE_; - static PredType* STD_B32LE_; - static PredType* STD_B64BE_; - static PredType* STD_B64LE_; - static PredType* STD_REF_OBJ_; - static PredType* STD_REF_DSETREG_; - - static PredType* C_S1_; - static PredType* FORTRAN_S1_; - - static PredType* IEEE_F32BE_; - static PredType* IEEE_F32LE_; - static PredType* IEEE_F64BE_; - static PredType* IEEE_F64LE_; - - static PredType* UNIX_D32BE_; - static PredType* UNIX_D32LE_; - static PredType* UNIX_D64BE_; - static PredType* UNIX_D64LE_; - - static PredType* INTEL_I8_; - static PredType* INTEL_I16_; - static PredType* INTEL_I32_; - static PredType* INTEL_I64_; - static PredType* INTEL_U8_; - static PredType* INTEL_U16_; - static PredType* INTEL_U32_; - static PredType* INTEL_U64_; - static PredType* INTEL_B8_; - static PredType* INTEL_B16_; - static PredType* INTEL_B32_; - static PredType* INTEL_B64_; - static PredType* INTEL_F32_; - static PredType* INTEL_F64_; - - static PredType* ALPHA_I8_; - static PredType* ALPHA_I16_; - static PredType* ALPHA_I32_; - static PredType* ALPHA_I64_; - static PredType* ALPHA_U8_; - static PredType* ALPHA_U16_; - static PredType* ALPHA_U32_; - static PredType* ALPHA_U64_; - static PredType* ALPHA_B8_; - static PredType* ALPHA_B16_; - static PredType* ALPHA_B32_; - static PredType* ALPHA_B64_; - static PredType* ALPHA_F32_; - static PredType* ALPHA_F64_; - - static PredType* MIPS_I8_; - static PredType* MIPS_I16_; - static PredType* MIPS_I32_; - static PredType* MIPS_I64_; - static PredType* MIPS_U8_; - static PredType* MIPS_U16_; - static PredType* MIPS_U32_; - static PredType* MIPS_U64_; - static PredType* MIPS_B8_; - static PredType* MIPS_B16_; - static PredType* MIPS_B32_; - static PredType* MIPS_B64_; - static PredType* MIPS_F32_; - static PredType* MIPS_F64_; - - static PredType* NATIVE_CHAR_; - static PredType* NATIVE_SCHAR_; - static PredType* NATIVE_UCHAR_; - static PredType* NATIVE_SHORT_; - static PredType* NATIVE_USHORT_; - static PredType* NATIVE_INT_; - static PredType* NATIVE_UINT_; - static PredType* NATIVE_LONG_; - static PredType* NATIVE_ULONG_; - static PredType* NATIVE_LLONG_; - static PredType* NATIVE_ULLONG_; - static PredType* NATIVE_FLOAT_; - static PredType* NATIVE_DOUBLE_; - static PredType* NATIVE_LDOUBLE_; - static PredType* NATIVE_B8_; - static PredType* NATIVE_B16_; - static PredType* NATIVE_B32_; - static PredType* NATIVE_B64_; - static PredType* NATIVE_OPAQUE_; - static PredType* NATIVE_HSIZE_; - static PredType* NATIVE_HSSIZE_; - static PredType* NATIVE_HERR_; - static PredType* NATIVE_HBOOL_; - - static PredType* NATIVE_INT8_; - static PredType* NATIVE_UINT8_; - static PredType* NATIVE_INT16_; - static PredType* NATIVE_UINT16_; - static PredType* NATIVE_INT32_; - static PredType* NATIVE_UINT32_; - static PredType* NATIVE_INT64_; - static PredType* NATIVE_UINT64_; + // Deletes the PredType global constants + static void deleteConstants(); + + // Dummy constant + static const PredType &PREDTYPE_CONST; // dummy constant + + protected: + // Default constructor + PredType(); + + // Creates a pre-defined type using an HDF5 pre-defined constant + PredType(const hid_t predtype_id); // used by the library only + + private: + // Activates the creation of the PredType global constants + static PredType *getPredTypes(); + + // Dynamically allocates PredType global constants + static void makePredTypes(); + + // Dummy constant + static PredType *PREDTYPE_CONST_; + + // Declaration of pointers to constants + static PredType *STD_I8BE_; + static PredType *STD_I8LE_; + static PredType *STD_I16BE_; + static PredType *STD_I16LE_; + static PredType *STD_I32BE_; + static PredType *STD_I32LE_; + static PredType *STD_I64BE_; + static PredType *STD_I64LE_; + static PredType *STD_U8BE_; + static PredType *STD_U8LE_; + static PredType *STD_U16BE_; + static PredType *STD_U16LE_; + static PredType *STD_U32BE_; + static PredType *STD_U32LE_; + static PredType *STD_U64BE_; + static PredType *STD_U64LE_; + static PredType *STD_B8BE_; + static PredType *STD_B8LE_; + static PredType *STD_B16BE_; + static PredType *STD_B16LE_; + static PredType *STD_B32BE_; + static PredType *STD_B32LE_; + static PredType *STD_B64BE_; + static PredType *STD_B64LE_; + static PredType *STD_REF_OBJ_; + static PredType *STD_REF_DSETREG_; + + static PredType *C_S1_; + static PredType *FORTRAN_S1_; + + static PredType *IEEE_F32BE_; + static PredType *IEEE_F32LE_; + static PredType *IEEE_F64BE_; + static PredType *IEEE_F64LE_; + + static PredType *UNIX_D32BE_; + static PredType *UNIX_D32LE_; + static PredType *UNIX_D64BE_; + static PredType *UNIX_D64LE_; + + static PredType *INTEL_I8_; + static PredType *INTEL_I16_; + static PredType *INTEL_I32_; + static PredType *INTEL_I64_; + static PredType *INTEL_U8_; + static PredType *INTEL_U16_; + static PredType *INTEL_U32_; + static PredType *INTEL_U64_; + static PredType *INTEL_B8_; + static PredType *INTEL_B16_; + static PredType *INTEL_B32_; + static PredType *INTEL_B64_; + static PredType *INTEL_F32_; + static PredType *INTEL_F64_; + + static PredType *ALPHA_I8_; + static PredType *ALPHA_I16_; + static PredType *ALPHA_I32_; + static PredType *ALPHA_I64_; + static PredType *ALPHA_U8_; + static PredType *ALPHA_U16_; + static PredType *ALPHA_U32_; + static PredType *ALPHA_U64_; + static PredType *ALPHA_B8_; + static PredType *ALPHA_B16_; + static PredType *ALPHA_B32_; + static PredType *ALPHA_B64_; + static PredType *ALPHA_F32_; + static PredType *ALPHA_F64_; + + static PredType *MIPS_I8_; + static PredType *MIPS_I16_; + static PredType *MIPS_I32_; + static PredType *MIPS_I64_; + static PredType *MIPS_U8_; + static PredType *MIPS_U16_; + static PredType *MIPS_U32_; + static PredType *MIPS_U64_; + static PredType *MIPS_B8_; + static PredType *MIPS_B16_; + static PredType *MIPS_B32_; + static PredType *MIPS_B64_; + static PredType *MIPS_F32_; + static PredType *MIPS_F64_; + + static PredType *NATIVE_CHAR_; + static PredType *NATIVE_SCHAR_; + static PredType *NATIVE_UCHAR_; + static PredType *NATIVE_SHORT_; + static PredType *NATIVE_USHORT_; + static PredType *NATIVE_INT_; + static PredType *NATIVE_UINT_; + static PredType *NATIVE_LONG_; + static PredType *NATIVE_ULONG_; + static PredType *NATIVE_LLONG_; + static PredType *NATIVE_ULLONG_; + static PredType *NATIVE_FLOAT_; + static PredType *NATIVE_DOUBLE_; + static PredType *NATIVE_LDOUBLE_; + static PredType *NATIVE_B8_; + static PredType *NATIVE_B16_; + static PredType *NATIVE_B32_; + static PredType *NATIVE_B64_; + static PredType *NATIVE_OPAQUE_; + static PredType *NATIVE_HSIZE_; + static PredType *NATIVE_HSSIZE_; + static PredType *NATIVE_HERR_; + static PredType *NATIVE_HBOOL_; + + static PredType *NATIVE_INT8_; + static PredType *NATIVE_UINT8_; + static PredType *NATIVE_INT16_; + static PredType *NATIVE_UINT16_; + static PredType *NATIVE_INT32_; + static PredType *NATIVE_UINT32_; + static PredType *NATIVE_INT64_; + static PredType *NATIVE_UINT64_; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 - static PredType* NATIVE_INT_LEAST8_; + static PredType *NATIVE_INT_LEAST8_; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 - static PredType* NATIVE_UINT_LEAST8_; + static PredType *NATIVE_UINT_LEAST8_; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 - static PredType* NATIVE_INT_LEAST16_; + static PredType *NATIVE_INT_LEAST16_; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 - static PredType* NATIVE_UINT_LEAST16_; + static PredType *NATIVE_UINT_LEAST16_; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 - static PredType* NATIVE_INT_LEAST32_; + static PredType *NATIVE_INT_LEAST32_; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 - static PredType* NATIVE_UINT_LEAST32_; + static PredType *NATIVE_UINT_LEAST32_; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 - static PredType* NATIVE_INT_LEAST64_; + static PredType *NATIVE_INT_LEAST64_; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 - static PredType* NATIVE_UINT_LEAST64_; + static PredType *NATIVE_UINT_LEAST64_; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 - static PredType* NATIVE_INT_FAST8_; + static PredType *NATIVE_INT_FAST8_; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 - static PredType* NATIVE_UINT_FAST8_; + static PredType *NATIVE_UINT_FAST8_; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 - static PredType* NATIVE_INT_FAST16_; + static PredType *NATIVE_INT_FAST16_; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 - static PredType* NATIVE_UINT_FAST16_; + static PredType *NATIVE_UINT_FAST16_; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 - static PredType* NATIVE_INT_FAST32_; + static PredType *NATIVE_INT_FAST32_; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 - static PredType* NATIVE_UINT_FAST32_; + static PredType *NATIVE_UINT_FAST32_; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 - static PredType* NATIVE_INT_FAST64_; + static PredType *NATIVE_INT_FAST64_; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 - static PredType* NATIVE_UINT_FAST64_; + static PredType *NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ - // End of Declaration of pointers + // End of Declaration of pointers #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index a01878c..7d6447b 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -19,16 +19,15 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" - namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; #ifndef DOXYGEN_SHOULD_SKIP_THIS // This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control @@ -36,7 +35,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -PropList* PropList::DEFAULT_ = 0; +PropList *PropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: PropList::getConstant @@ -48,13 +47,13 @@ PropList* PropList::DEFAULT_ = 0; // throw a PropListIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -PropList* PropList::getConstant() +PropList * +PropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -63,8 +62,9 @@ PropList* PropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new PropList(H5P_DEFAULT); else - throw PropListIException("PropList::getConstant", "PropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("PropList::getConstant", + "PropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -72,7 +72,8 @@ PropList* PropList::getConstant() // Purpose Deletes the constant object that PropList::DEFAULT_ points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void PropList::deleteConstants() +void +PropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -81,7 +82,7 @@ void PropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property. //-------------------------------------------------------------------------- -const PropList& PropList::DEFAULT = *getConstant(); +const PropList &PropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -90,7 +91,9 @@ const PropList& PropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub property list object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {} +PropList::PropList() : IdComponent(), id(H5P_DEFAULT) +{ +} //-------------------------------------------------------------------------- // Function: PropList copy constructor @@ -98,7 +101,7 @@ PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {} ///\param original - IN: The original property list to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList(const PropList& original) : IdComponent(), id(original.id) +PropList::PropList(const PropList &original) : IdComponent(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -123,21 +126,19 @@ PropList::PropList(const hid_t plist_id) : IdComponent() H5I_type_t id_type = H5Iget_type(plist_id); switch (id_type) { case H5I_GENPROP_CLS: - // call C routine to create a new property from the given prop class - id = H5Pcreate(plist_id); - if (id < 0) - { - throw PropListIException("PropList constructor", "H5Pcreate failed"); - } - break; + // call C routine to create a new property from the given prop class + id = H5Pcreate(plist_id); + if (id < 0) { + throw PropListIException("PropList constructor", "H5Pcreate failed"); + } + break; case H5I_GENPROP_LST: - // call C routine to make a copy of the given property list - id = H5Pcopy(plist_id); - if (id < 0) - { - throw PropListIException("PropList constructor", "H5Pcopy failed"); - } - break; + // call C routine to make a copy of the given property list + id = H5Pcopy(plist_id); + if (id < 0) { + throw PropListIException("PropList constructor", "H5Pcopy failed"); + } + break; /* These should really be error cases, but changing that breaks * the stated behavior and causes test failures. * (DER, July 2017) @@ -157,8 +158,8 @@ PropList::PropList(const hid_t plist_id) : IdComponent() case H5I_NTYPES: case H5I_UNINIT: default: - id = H5P_DEFAULT; - break; + id = H5P_DEFAULT; + break; } } @@ -174,14 +175,15 @@ PropList::PropList(const hid_t plist_id) : IdComponent() // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void PropList::copy(const PropList& like_plist) +void +PropList::copy(const PropList &like_plist) { // If this object is representing an hdf5 object, close it before // copying like_plist to it try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -202,11 +204,12 @@ void PropList::copy(const PropList& like_plist) // and stores the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList& PropList::operator=(const PropList& rhs) +PropList & +PropList::operator=(const PropList &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -217,12 +220,12 @@ PropList& PropList::operator=(const PropList& rhs) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, const char *name) const +void +PropList::copyProp(PropList &dest, const char *name) const { - hid_t dst_id = dest.getId(); + hid_t dst_id = dest.getId(); herr_t ret_value = H5Pcopy_prop(dst_id, id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); } } @@ -236,7 +239,8 @@ void PropList::copyProp(PropList& dest, const char *name) const ///\param name - IN: Name of the property to copy - \c H5std_string // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, const H5std_string& name) const +void +PropList::copyProp(PropList &dest, const H5std_string &name) const { copyProp(dest, name.c_str()); } @@ -251,16 +255,15 @@ void PropList::copyProp(PropList& dest, const H5std_string& name) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, PropList& src, const char *name) const +void +PropList::copyProp(PropList &dest, PropList &src, const char *name) const { - hid_t dst_id = dest.getId(); - hid_t src_id = src.getId(); + hid_t dst_id = dest.getId(); + hid_t src_id = src.getId(); herr_t ret_value = H5Pcopy_prop(dst_id, src_id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); } - } //-------------------------------------------------------------------------- @@ -273,7 +276,8 @@ void PropList::copyProp(PropList& dest, PropList& src, const char *name) const ///\param name - IN: Name of the property to copy - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name) const +void +PropList::copyProp(PropList &dest, PropList &src, const H5std_string &name) const { copyProp(dest, src, name.c_str()); } @@ -289,9 +293,10 @@ void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name) // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t PropList::getId() const +hid_t +PropList::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -307,17 +312,18 @@ hid_t PropList::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::p_setId(const hid_t new_id) +void +PropList::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw PropListIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -329,13 +335,12 @@ void PropList::p_setId(const hid_t new_id) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void PropList::close() +void +PropList::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Pclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("close"), "H5Pclose failed"); } // reset the id @@ -350,15 +355,14 @@ void PropList::close() ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hid_t PropList::getClass() const +hid_t +PropList::getClass() const { hid_t plist_class = H5Pget_class(id); - if (plist_class == H5P_ROOT) - { - throw PropListIException(inMemFunc("getClass"), - "H5Pget_class failed - returned H5P_ROOT"); + if (plist_class == H5P_ROOT) { + throw PropListIException(inMemFunc("getClass"), "H5Pget_class failed - returned H5P_ROOT"); } - return(plist_class); + return (plist_class); } //-------------------------------------------------------------------------- @@ -373,7 +377,8 @@ hid_t PropList::getClass() const /// list or class. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::propExist(const char* name) const +bool +PropList::propExist(const char *name) const { // Calls C routine H5Pexist to determine whether a property exists // within a property list or class. It returns a positive value, 0, @@ -396,9 +401,10 @@ bool PropList::propExist(const char* name) const ///\param name - IN: Name of property to check for - \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::propExist(const H5std_string& name) const +bool +PropList::propExist(const H5std_string &name) const { - return(propExist( name.c_str())); + return (propExist(name.c_str())); } //-------------------------------------------------------------------------- @@ -411,11 +417,11 @@ bool PropList::propExist(const H5std_string& name) const /// list class hierarchy. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::closeClass() const +void +PropList::closeClass() const { herr_t ret_value = H5Pclose_class(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("closeClass"), "H5Pclose_class failed"); } } @@ -432,11 +438,11 @@ void PropList::closeClass() const /// throw an exception. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::getProperty(const char* name, void* value) const +void +PropList::getProperty(const char *name, void *value) const { herr_t ret_value = H5Pget(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } } @@ -450,27 +456,27 @@ void PropList::getProperty(const char* name, void* value) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getProperty(const char* name) const +H5std_string +PropList::getProperty(const char *name) const { // Get property size first size_t size = getPropSize(name); // Allocate buffer then get the property - char* prop_strg_C = new char[size+1]; // temporary C-string for C API - HDmemset(prop_strg_C, 0, size+1); // clear buffer + char *prop_strg_C = new char[size + 1]; // temporary C-string for C API + HDmemset(prop_strg_C, 0, size + 1); // clear buffer herr_t ret_value = H5Pget(id, name, prop_strg_C); // call C API // Throw exception if H5Pget returns failure - if (ret_value < 0) - { - delete []prop_strg_C; + if (ret_value < 0) { + delete[] prop_strg_C; throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } // Return property value as a string after deleting temp C-string H5std_string prop_strg(prop_strg_C); - delete []prop_strg_C; + delete[] prop_strg_C; return (prop_strg); } //-------------------------------------------------------------------------- @@ -482,7 +488,8 @@ H5std_string PropList::getProperty(const char* name) const ///\param value - OUT: Pointer to the buffer for the property value // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::getProperty(const H5std_string& name, void* value) const +void +PropList::getProperty(const H5std_string &name, void *value) const { getProperty(name.c_str(), value); } @@ -495,7 +502,8 @@ void PropList::getProperty(const H5std_string& name, void* value) const ///\return The property that is a \c H5std_string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getProperty(const H5std_string& name) const +H5std_string +PropList::getProperty(const H5std_string &name) const { return (getProperty(name.c_str())); } @@ -513,15 +521,15 @@ H5std_string PropList::getProperty(const H5std_string& name) const /// lists and classes. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getPropSize(const char *name) const +size_t +PropList::getPropSize(const char *name) const { size_t prop_size; herr_t ret_value = H5Pget_size(id, name, &prop_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("getPropSize"), "H5Pget_size failed"); } - return(prop_size); + return (prop_size); } //-------------------------------------------------------------------------- // Function: PropList::getPropSize @@ -532,7 +540,8 @@ size_t PropList::getPropSize(const char *name) const /// // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getPropSize(const H5std_string& name) const +size_t +PropList::getPropSize(const H5std_string &name) const { return (getPropSize(name.c_str())); } @@ -544,15 +553,15 @@ size_t PropList::getPropSize(const H5std_string& name) const /// a NULL string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getClassName() const +H5std_string +PropList::getClassName() const { - char* temp_str; + char *temp_str; temp_str = H5Pget_class_name(id); - if (temp_str != NULL) - { + if (temp_str != NULL) { H5std_string class_name(temp_str); H5free_memory(temp_str); - return(class_name); + return (class_name); } else return 0; @@ -564,12 +573,12 @@ H5std_string PropList::getClassName() const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getNumProps() const +size_t +PropList::getNumProps() const { size_t nprops; - herr_t ret_value = H5Pget_nprops (id, &nprops); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_nprops(id, &nprops); + if (ret_value < 0) { throw PropListIException(inMemFunc("getNumProps"), "H5Pget_nprops failed"); } return (nprops); @@ -586,11 +595,11 @@ size_t PropList::getNumProps() const // the non-const setProperty. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const void* value) const +void +PropList::setProperty(const char *name, const void *value) const { herr_t ret_value = H5Pset(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -602,11 +611,11 @@ void PropList::setProperty(const char* name, const void* value) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, void* value) const +void +PropList::setProperty(const char *name, void *value) const { herr_t ret_value = H5Pset(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -623,11 +632,11 @@ void PropList::setProperty(const char* name, void* value) const // the non-const setProperty. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const char* charptr) const +void +PropList::setProperty(const char *name, const char *charptr) const { - herr_t ret_value = H5Pset(id, name, (const void*)charptr); - if (ret_value < 0) - { + herr_t ret_value = H5Pset(id, name, (const void *)charptr); + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -640,7 +649,8 @@ void PropList::setProperty(const char* name, const char* charptr) const ///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const H5std_string& strg) const +void +PropList::setProperty(const char *name, const H5std_string &strg) const { setProperty(name, strg.c_str()); } @@ -652,7 +662,8 @@ void PropList::setProperty(const char* name, const H5std_string& strg) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, H5std_string& strg) const +void +PropList::setProperty(const char *name, H5std_string &strg) const { setProperty(name, strg.c_str()); } @@ -666,7 +677,8 @@ void PropList::setProperty(const char* name, H5std_string& strg) const ///\param value - IN: Void pointer to the value for the property // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, const void* value) const +void +PropList::setProperty(const H5std_string &name, const void *value) const { setProperty(name.c_str(), value); } @@ -678,7 +690,8 @@ void PropList::setProperty(const H5std_string& name, const void* value) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, void* value) const +void +PropList::setProperty(const H5std_string &name, void *value) const { setProperty(name.c_str(), value); } @@ -692,7 +705,8 @@ void PropList::setProperty(const H5std_string& name, void* value) const ///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, const H5std_string& strg) const +void +PropList::setProperty(const H5std_string &name, const H5std_string &strg) const { setProperty(name.c_str(), strg.c_str()); } @@ -704,7 +718,8 @@ void PropList::setProperty(const H5std_string& name, const H5std_string& strg) c // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, H5std_string& strg) const +void +PropList::setProperty(const H5std_string &name, H5std_string &strg) const { setProperty(name.c_str(), strg.c_str()); } @@ -718,7 +733,8 @@ void PropList::setProperty(const H5std_string& name, H5std_string& strg) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::isAClass(const PropList& prop_class) const +bool +PropList::isAClass(const PropList &prop_class) const { htri_t ret_value = H5Pisa_class(id, prop_class.getId()); if (ret_value > 0) @@ -738,11 +754,11 @@ bool PropList::isAClass(const PropList& prop_class) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::removeProp(const char *name) const +void +PropList::removeProp(const char *name) const { herr_t ret_value = H5Premove(id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("removeProp"), "H5Premove failed"); } } @@ -755,7 +771,8 @@ void PropList::removeProp(const char *name) const ///\param name - IN: Name of property to remove - \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::removeProp(const H5std_string& name) const +void +PropList::removeProp(const H5std_string &name) const { removeProp(name.c_str()); } @@ -769,7 +786,8 @@ void PropList::removeProp(const H5std_string& name) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::operator==(const PropList& rhs) const +bool +PropList::operator==(const PropList &rhs) const { htri_t ret_value = H5Pequal(id, rhs.getId()); if (ret_value > 0) @@ -789,15 +807,15 @@ bool PropList::operator==(const PropList& rhs) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -PropList PropList::getClassParent() const +PropList +PropList::getClassParent() const { hid_t class_id = H5Pget_class_parent(id); - if (class_id < 0) - { + if (class_id < 0) { throw PropListIException(inMemFunc("getClassParent"), "H5Pget_class_parent failed"); } PropList pclass(class_id); - return(pclass); + return (pclass); } //-------------------------------------------------------------------------- @@ -815,9 +833,9 @@ PropList::~PropList() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index d704775..805f6da 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -23,121 +23,125 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP PropList : public IdComponent { - public: - ///\brief Default property list - static const PropList& DEFAULT; + public: + ///\brief Default property list + static const PropList &DEFAULT; - // Creates a property list of a given type or creates a copy of an - // existing property list giving the property list id. - PropList(const hid_t plist_id); + // Creates a property list of a given type or creates a copy of an + // existing property list giving the property list id. + PropList(const hid_t plist_id); - // Make a copy of the given property list using assignment statement - PropList& operator=(const PropList& rhs); + // Make a copy of the given property list using assignment statement + PropList &operator=(const PropList &rhs); - // Compares this property list or class against the given list or class. - bool operator==(const PropList& rhs) const; + // Compares this property list or class against the given list or class. + bool operator==(const PropList &rhs) const; - // Close this property list. - virtual void close(); + // Close this property list. + virtual void close(); - // Close a property list class. - void closeClass() const; + // Close a property list class. + void closeClass() const; - // Makes a copy of the given property list. - void copy(const PropList& like_plist); + // Makes a copy of the given property list. + void copy(const PropList &like_plist); - // Copies a property from this property list or class to another - void copyProp(PropList& dest, const char* name) const; - void copyProp(PropList& dest, const H5std_string& name) const; + // Copies a property from this property list or class to another + void copyProp(PropList &dest, const char *name) const; + void copyProp(PropList &dest, const H5std_string &name) const; - // Copies a property from one property list or property class to another - void copyProp(PropList& dest, PropList& src, const char* name) const; - void copyProp(PropList& dest, PropList& src, const H5std_string& name) const; + // Copies a property from one property list or property class to another + void copyProp(PropList &dest, PropList &src, const char *name) const; + void copyProp(PropList &dest, PropList &src, const H5std_string &name) const; - // Gets the class of this property list, i.e. H5P_FILE_CREATE, - // H5P_FILE_ACCESS, ... - hid_t getClass() const; + // Gets the class of this property list, i.e. H5P_FILE_CREATE, + // H5P_FILE_ACCESS, ... + hid_t getClass() const; - // Return the name of a generic property list class. - H5std_string getClassName() const; + // Return the name of a generic property list class. + H5std_string getClassName() const; - // Returns the parent class of a generic property class. - PropList getClassParent() const; + // Returns the parent class of a generic property class. + PropList getClassParent() const; - // Returns the number of properties in this property list or class. - size_t getNumProps() const; + // Returns the number of properties in this property list or class. + size_t getNumProps() const; - // Query the value of a property in a property list. - void getProperty(const char* name, void* value) const; - void getProperty(const H5std_string& name, void* value) const; - H5std_string getProperty(const char* name) const; - H5std_string getProperty(const H5std_string& name) const; + // Query the value of a property in a property list. + void getProperty(const char *name, void *value) const; + void getProperty(const H5std_string &name, void *value) const; + H5std_string getProperty(const char *name) const; + H5std_string getProperty(const H5std_string &name) const; - // Set a property's value in a property list. - void setProperty(const char* name, const char* charptr) const; - void setProperty(const char* name, const void* value) const; - void setProperty(const char* name, const H5std_string& strg) const; - void setProperty(const H5std_string& name, const void* value) const; - void setProperty(const H5std_string& name, const H5std_string& strg) const; - // Deprecated after 1.10.1, missing const - void setProperty(const char* name, void* value) const; - void setProperty(const char* name, H5std_string& strg) const; - void setProperty(const H5std_string& name, void* value) const; - void setProperty(const H5std_string& name, H5std_string& strg) const; + // Set a property's value in a property list. + void setProperty(const char *name, const char *charptr) const; + void setProperty(const char *name, const void *value) const; + void setProperty(const char *name, const H5std_string &strg) const; + void setProperty(const H5std_string &name, const void *value) const; + void setProperty(const H5std_string &name, const H5std_string &strg) const; + // Deprecated after 1.10.1, missing const + void setProperty(const char *name, void *value) const; + void setProperty(const char *name, H5std_string &strg) const; + void setProperty(const H5std_string &name, void *value) const; + void setProperty(const H5std_string &name, H5std_string &strg) const; - // Query the size of a property in a property list or class. - size_t getPropSize(const char *name) const; - size_t getPropSize(const H5std_string& name) const; + // Query the size of a property in a property list or class. + size_t getPropSize(const char *name) const; + size_t getPropSize(const H5std_string &name) const; - // Determines whether a property list is a certain class. - bool isAClass(const PropList& prop_class) const; + // Determines whether a property list is a certain class. + bool isAClass(const PropList &prop_class) const; - /// Query the existence of a property in a property object. - bool propExist(const char* name) const; - bool propExist(const H5std_string& name) const; + /// Query the existence of a property in a property object. + bool propExist(const char *name) const; + bool propExist(const H5std_string &name) const; - // Removes a property from a property list. - void removeProp(const char *name) const; - void removeProp(const H5std_string& name) const; + // Removes a property from a property list. + void removeProp(const char *name) const; + void removeProp(const H5std_string &name) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("PropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("PropList"); + } - // Default constructor: creates a stub PropList object. - PropList(); + // Default constructor: creates a stub PropList object. + PropList(); - // Copy constructor: same as the original PropList. - PropList(const PropList& original); + // Copy constructor: same as the original PropList. + PropList(const PropList &original); - // Gets the property list id. - virtual hid_t getId() const; + // Gets the property list id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this property list. - virtual ~PropList(); + // Destructor: properly terminates access to this property list. + virtual ~PropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the PropList global constant - static void deleteConstants(); + // Deletes the PropList global constant + static void deleteConstants(); - protected: - hid_t id; // HDF5 property list id + protected: + hid_t id; // HDF5 property list id - // Sets the property list id. - virtual void p_setId(const hid_t new_id); + // Sets the property list id. + virtual void p_setId(const hid_t new_id); - private: - static PropList* DEFAULT_; + private: + static PropList *DEFAULT_; - // Dynamically allocates the PropList global constant - static PropList* getConstant(); + // Dynamically allocates the PropList global constant + static PropList *getConstant(); - // Friend function to set PropList id. For library use only. - friend void f_PropList_setId(PropList* plist, hid_t new_id); + // Friend function to set PropList id. For library use only. + friend void f_PropList_setId(PropList *plist, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of PropList } // namespace H5 -#endif // __H5PropList_H +#endif // __H5PropList_H diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index f5b65e4..5dcf4a6 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -40,7 +40,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub string datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType() : AtomType() {} +StrType::StrType() : AtomType() +{ +} //-------------------------------------------------------------------------- // Function: StrType overloaded constructor @@ -49,7 +51,7 @@ StrType::StrType() : AtomType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const PredType& pred_type) : AtomType() +StrType::StrType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -78,7 +80,7 @@ StrType::StrType(const PredType& pred_type) : AtomType() // Planned for removal. -BMR, 2005/12/02 // Removed from documentation. -BMR, 2016/03/07 //-------------------------------------------------------------------------- -StrType::StrType(const PredType& pred_type, const size_t& size) : AtomType() +StrType::StrType(const PredType &pred_type, const size_t &size) : AtomType() { // use DataType::copy to make a copy of the string predefined type // then set its length @@ -102,7 +104,7 @@ StrType::StrType(const PredType& pred_type, const size_t& size) : AtomType() // This constructor replaced the previous one. // Programmer Binh-Minh Ribler - Nov 28, 2005 //-------------------------------------------------------------------------- -StrType::StrType(const int dummy, const size_t& size) : AtomType() +StrType::StrType(const int dummy, const size_t &size) : AtomType() { // use DataType::copy to make a copy of the string predefined type // then set its length @@ -117,14 +119,18 @@ StrType::StrType(const int dummy, const size_t& size) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const hid_t existing_id) : AtomType( existing_id ) {} +StrType::StrType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: StrType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const StrType& original) : AtomType ( original ) {} +StrType::StrType(const StrType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: StrType overloaded constructor @@ -133,13 +139,12 @@ StrType::StrType(const StrType& original) : AtomType ( original ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const DataSet& dataset) : AtomType () +StrType::StrType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("StrType constructor", "H5Dget_type failed"); } } @@ -158,7 +163,7 @@ StrType::StrType(const DataSet& dataset) : AtomType () // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -StrType::StrType(const H5Location& loc, const char *dtype_name) : AtomType() +StrType::StrType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -177,7 +182,7 @@ StrType::StrType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -StrType::StrType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +StrType::StrType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -190,7 +195,8 @@ StrType::StrType(const H5Location& loc, const H5std_string& dtype_name) : AtomTy ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* StrType::decode() const +DataType * +StrType::decode() const { hid_t encoded_strtype_id = H5I_INVALID_HID; try { @@ -201,7 +207,7 @@ DataType* StrType::decode() const } StrType *encoded_strtype = new StrType; encoded_strtype->p_setId(encoded_strtype_id); - return(encoded_strtype); + return (encoded_strtype); } //-------------------------------------------------------------------------- @@ -219,16 +225,16 @@ DataType* StrType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_cset_t StrType::getCset() const +H5T_cset_t +StrType::getCset() const { H5T_cset_t cset = H5Tget_cset(id); // Returns a valid character set type if successful - if (cset == H5T_CSET_ERROR) - { + if (cset == H5T_CSET_ERROR) { throw DataTypeIException("StrType::getCset", "H5Tget_cset failed"); } - return(cset); + return (cset); } //-------------------------------------------------------------------------- @@ -246,11 +252,11 @@ H5T_cset_t StrType::getCset() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void StrType::setCset(H5T_cset_t cset) const +void +StrType::setCset(H5T_cset_t cset) const { herr_t ret_value = H5Tset_cset(id, cset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("StrType::setCset", "H5Tset_cset failed"); } } @@ -265,17 +271,16 @@ void StrType::setCset(H5T_cset_t cset) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_str_t StrType::getStrpad() const +H5T_str_t +StrType::getStrpad() const { H5T_str_t strpad = H5Tget_strpad(id); // Returns a valid string padding type if successful - if (strpad == H5T_STR_ERROR) - { - throw DataTypeIException("StrType::getStrpad", - "H5Tget_strpad failed - returned H5T_STR_ERROR"); + if (strpad == H5T_STR_ERROR) { + throw DataTypeIException("StrType::getStrpad", "H5Tget_strpad failed - returned H5T_STR_ERROR"); } - return(strpad); + return (strpad); } //-------------------------------------------------------------------------- @@ -288,11 +293,11 @@ H5T_str_t StrType::getStrpad() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void StrType::setStrpad(H5T_str_t strpad) const +void +StrType::setStrpad(H5T_str_t strpad) const { herr_t ret_value = H5Tset_strpad(id, strpad); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("StrType::setStrpad", "H5Tset_strpad failed"); } } @@ -302,6 +307,8 @@ void StrType::setStrpad(H5T_str_t strpad) const ///\brief Properly terminates access to this string datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::~StrType() {} +StrType::~StrType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h index 38974da..d442bc4 100644 --- a/c++/src/H5StrType.h +++ b/c++/src/H5StrType.h @@ -23,53 +23,57 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP StrType : public AtomType { - public: - // Creates a string type using a predefined type - StrType(const PredType& pred_type); + public: + // Creates a string type using a predefined type + StrType(const PredType &pred_type); - // Creates a string type with specified length - may be obsolete - StrType(const PredType& pred_type, const size_t& size); + // Creates a string type with specified length - may be obsolete + StrType(const PredType &pred_type, const size_t &size); - // Creates a string type with specified length - StrType(const int dummy, const size_t& size); + // Creates a string type with specified length + StrType(const int dummy, const size_t &size); - // Gets the string datatype of the specified dataset - StrType(const DataSet& dataset); + // Gets the string datatype of the specified dataset + StrType(const DataSet &dataset); - // Constructors that open an HDF5 string datatype, given a location. - StrType(const H5Location& loc, const char* name); - StrType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 string datatype, given a location. + StrType(const H5Location &loc, const char *name); + StrType(const H5Location &loc, const H5std_string &name); - // Returns an StrType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an StrType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the character set type of this string datatype. - H5T_cset_t getCset() const; + // Retrieves the character set type of this string datatype. + H5T_cset_t getCset() const; - // Sets character set to be used. - void setCset(H5T_cset_t cset) const; + // Sets character set to be used. + void setCset(H5T_cset_t cset) const; - // Retrieves the string padding method for this string datatype. - H5T_str_t getStrpad() const; + // Retrieves the string padding method for this string datatype. + H5T_str_t getStrpad() const; - // Defines the storage mechanism for character strings. - void setStrpad(H5T_str_t strpad) const; + // Defines the storage mechanism for character strings. + void setStrpad(H5T_str_t strpad) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("StrType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("StrType"); + } - // default constructor - StrType(); + // default constructor + StrType(); - // Creates a string datatype using an existing id - StrType(const hid_t existing_id); + // Creates a string datatype using an existing id + StrType(const hid_t existing_id); - // Copy constructor: same as the original StrType. - StrType(const StrType& original); + // Copy constructor: same as the original StrType. + StrType(const StrType &original); - // Noop destructor. - virtual ~StrType(); + // Noop destructor. + virtual ~StrType(); }; // end of StrType } // namespace H5 diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp index 094af61..13d1a5f 100644 --- a/c++/src/H5VarLenType.cpp +++ b/c++/src/H5VarLenType.cpp @@ -33,7 +33,9 @@ namespace H5 { // Function: VarLenType default constructor ///\brief Default constructor: Creates a stub variable-length datatype. //-------------------------------------------------------------------------- -VarLenType::VarLenType() : DataType() {} +VarLenType::VarLenType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: VarLenType overloaded constructor @@ -42,14 +44,18 @@ VarLenType::VarLenType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const hid_t existing_id) : DataType(existing_id) {} +VarLenType::VarLenType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: VarLenType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const VarLenType& original) : DataType(original) {} +VarLenType::VarLenType(const VarLenType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: VarLenType overloaded constructor @@ -63,13 +69,11 @@ VarLenType::VarLenType(const VarLenType& original) : DataType(original) {} // -BMR, Sep, 2017 // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const DataType* base_type) : DataType() +VarLenType::VarLenType(const DataType *base_type) : DataType() { id = H5Tvlen_create(base_type->getId()); - if (id < 0) - { - throw DataTypeIException("VarLenType constructor", - "H5Tvlen_create returns negative value"); + if (id < 0) { + throw DataTypeIException("VarLenType constructor", "H5Tvlen_create returns negative value"); } } @@ -81,13 +85,11 @@ VarLenType::VarLenType(const DataType* base_type) : DataType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const DataType& base_type) : DataType() +VarLenType::VarLenType(const DataType &base_type) : DataType() { id = H5Tvlen_create(base_type.getId()); - if (id < 0) - { - throw DataTypeIException("VarLenType constructor", - "H5Tvlen_create returns negative value"); + if (id < 0) { + throw DataTypeIException("VarLenType constructor", "H5Tvlen_create returns negative value"); } } @@ -105,7 +107,7 @@ VarLenType::VarLenType(const DataType& base_type) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const H5Location& loc, const char *dtype_name) : DataType() +VarLenType::VarLenType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -124,7 +126,7 @@ VarLenType::VarLenType(const H5Location& loc, const char *dtype_name) : DataType // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +VarLenType::VarLenType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -137,7 +139,8 @@ VarLenType::VarLenType(const H5Location& loc, const H5std_string& dtype_name) : ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* VarLenType::decode() const +DataType * +VarLenType::decode() const { hid_t encoded_vltype_id = H5I_INVALID_HID; try { @@ -148,7 +151,7 @@ DataType* VarLenType::decode() const } VarLenType *encoded_vltype = new VarLenType; encoded_vltype->p_setId(encoded_vltype_id); - return(encoded_vltype); + return (encoded_vltype); } //-------------------------------------------------------------------------- @@ -156,6 +159,8 @@ DataType* VarLenType::decode() const ///\brief Properly terminates access to this datatype. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::~VarLenType() {} +VarLenType::~VarLenType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index ab3c14c..56c699b 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -23,36 +23,40 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP VarLenType : public DataType { - public: - // Constructor that creates a variable-length datatype based - // on the specified base type. - VarLenType(const DataType& base_type); + public: + // Constructor that creates a variable-length datatype based + // on the specified base type. + VarLenType(const DataType &base_type); - // Deprecated - will be removed after 1.10.2 - VarLenType(const DataType* base_type); + // Deprecated - will be removed after 1.10.2 + VarLenType(const DataType *base_type); - // Returns an VarLenType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an VarLenType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("VarLenType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("VarLenType"); + } - // Copy constructor: same as the original VarLenType. - VarLenType(const VarLenType& original); + // Copy constructor: same as the original VarLenType. + VarLenType(const VarLenType &original); - // Constructor that takes an existing id - VarLenType(const hid_t existing_id); + // Constructor that takes an existing id + VarLenType(const hid_t existing_id); - // Constructors that open a variable-length datatype, given a location. - VarLenType(const H5Location& loc, const char* name); - VarLenType(const H5Location& loc, const H5std_string& name); + // Constructors that open a variable-length datatype, given a location. + VarLenType(const H5Location &loc, const char *name); + VarLenType(const H5Location &loc, const H5std_string &name); - // Noop destructor - virtual ~VarLenType(); + // Noop destructor + virtual ~VarLenType(); - // Default constructor - VarLenType(); + // Default constructor + VarLenType(); }; // end of VarLenType } // namespace H5 diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 76e4424..0116d6c 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -32,29 +32,28 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILE1("dataset.h5"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_DEFAULT_NAME_PATH("/default"); -const H5std_string DSET_CHUNKED_NAME("chunked"); -const H5std_string DSET_SIMPLE_IO_NAME("simple_io"); -const H5std_string DSET_TCONV_NAME("tconv"); -const H5std_string DSET_COMPRESS_NAME("compressed"); -const H5std_string DSET_BOGUS_NAME("bogus"); +const H5std_string FILE1("dataset.h5"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_DEFAULT_NAME_PATH("/default"); +const H5std_string DSET_CHUNKED_NAME("chunked"); +const H5std_string DSET_SIMPLE_IO_NAME("simple_io"); +const H5std_string DSET_TCONV_NAME("tconv"); +const H5std_string DSET_COMPRESS_NAME("compressed"); +const H5std_string DSET_BOGUS_NAME("bogus"); /* Temporary filter IDs used for testing */ const int H5Z_FILTER_BOGUS = 305; -static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); // H5_ATTR_UNUSED variables caused warning, but taking them out caused failure. - /*------------------------------------------------------------------------- * Function: test_create * @@ -68,7 +67,8 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, * Friday, January 5, 2001 *------------------------------------------------------------------------- */ -static herr_t test_create( H5File& file) +static herr_t +test_create(H5File &file) { SUBTEST("Create, open, close"); @@ -76,19 +76,17 @@ static herr_t test_create( H5File& file) DataSet *dataset = NULL; try { // Create a data space - hsize_t dims[2]; + hsize_t dims[2]; dims[0] = 256; dims[1] = 512; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a dataset using the default dataset creation properties. // We're not sure what they are, so we won't check. - dataset = new DataSet (file.createDataSet - (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); - + dataset = new DataSet(file.createDataSet(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); // Add a comment to the dataset - file.setComment (DSET_DEFAULT_NAME, "This is a dataset"); + file.setComment(DSET_DEFAULT_NAME, "This is a dataset"); // Close the dataset delete dataset; @@ -98,18 +96,19 @@ static herr_t test_create( H5File& file) // dataset can only be created once. If an exception is not thrown for // this action by createDataSet, then throw an invalid action exception. try { - dataset = new DataSet (file.createDataSet - (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); + dataset = new DataSet(file.createDataSet(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("H5File::createDataSet", + "Library allowed overwrite of existing dataset"); } - catch (FileIException& E) // catching invalid creating dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching invalid creating dataset + { + } // do nothing, exception expected // Open the dataset we created above and then close it. This is one // way to open an existing dataset for accessing. - dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME)); + dataset = new DataSet(file.openDataSet(DSET_DEFAULT_NAME)); // Get and verify the name of this dataset, using // H5std_string getObjName() @@ -125,30 +124,31 @@ static herr_t test_create( H5File& file) delete dataset; // This is another way to open an existing dataset for accessing. - DataSet another_dataset(file.openDataSet (DSET_DEFAULT_NAME)); + DataSet another_dataset(file.openDataSet(DSET_DEFAULT_NAME)); // Try opening a non-existent dataset. This should fail so if an // exception is not thrown for this action by openDataSet, then // display failure information and throw an exception. try { - dataset = new DataSet (file.openDataSet( "does_not_exist" )); + dataset = new DataSet(file.openDataSet("does_not_exist")); // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset"); } - catch (FileIException& E ) // catching creating non-existent dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching creating non-existent dataset + { + } // do nothing, exception expected // Create a new dataset that uses chunked storage instead of the default // layout. DSetCreatPropList create_parms; - hsize_t csize[2]; + hsize_t csize[2]; csize[0] = 5; csize[1] = 100; - create_parms.setChunk( 2, csize ); + create_parms.setChunk(2, csize); - dataset = new DataSet (file.createDataSet(DSET_CHUNKED_NAME, - PredType::NATIVE_DOUBLE, space, create_parms)); + dataset = + new DataSet(file.createDataSet(DSET_CHUNKED_NAME, PredType::NATIVE_DOUBLE, space, create_parms)); // Note: this one has no error message in C when failure occurs? // clean up and return with success @@ -156,10 +156,9 @@ static herr_t test_create( H5File& file) PASSED(); return 0; - } // outer most try block + } // outer most try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -169,8 +168,7 @@ static herr_t test_create( H5File& file) return -1; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_create", __LINE__, __FILE__); // clean up and return with failure @@ -178,9 +176,8 @@ static herr_t test_create( H5File& file) delete dataset; return -1; } -} // test_create +} // test_create - /*------------------------------------------------------------------------- * Function: test_simple_io * @@ -196,75 +193,72 @@ static herr_t test_create( H5File& file) * Friday, January 5, 2001 *------------------------------------------------------------------------- */ -static herr_t test_simple_io( H5File& file) +static herr_t +test_simple_io(H5File &file) { SUBTEST("Simple I/O"); - int points[100][200]; - int check[100][200]; + int points[100][200]; + int check[100][200]; int i, j, n; // Initialize the dataset - for (i = n = 0; i < 100; i++) - { + for (i = n = 0; i < 100; i++) { for (j = 0; j < 200; j++) { points[i][j] = n++; } } - char* tconv_buf = new char [1000]; - try - { + char *tconv_buf = new char[1000]; + try { // Create the data space hsize_t dims[2]; dims[0] = 100; dims[1] = 200; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a small conversion buffer to test strip mining DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Create the dataset - DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); + DataSet dataset(file.createDataSet(DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); // Write the data to the dataset - dataset.write(static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.write(static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); // Read the dataset back - dataset.read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.read(static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < 100; i++) - for (j = 0; j < 200; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < 200; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("DataSet::read"); } // clean up and return with success - delete [] tconv_buf; + delete[] tconv_buf; PASSED(); return 0; - } // end try + } // end try // catch all dataset, space, plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; // clean up and return with failure if (tconv_buf) - delete [] tconv_buf; + delete[] tconv_buf; return -1; } -} // test_simple_io +} // test_simple_io - /*------------------------------------------------------------------------- * Function: test_datasize * @@ -278,25 +272,24 @@ static herr_t test_simple_io( H5File& file) * Thursday, March 22, 2012 *------------------------------------------------------------------------- */ -static herr_t test_datasize(FileAccPropList &fapl) +static herr_t +test_datasize(FileAccPropList &fapl) { SUBTEST("DataSet::getInMemDataSize()"); - try - { + try { // Open FILE1. H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); // Open dataset DSET_SIMPLE_IO_NAME. - DataSet dset = file.openDataSet (DSET_SIMPLE_IO_NAME); + DataSet dset = file.openDataSet(DSET_SIMPLE_IO_NAME); // Get the dataset's dataspace to calculate the size for verification. DataSpace space(dset.getSpace()); // Get the dimension sizes. hsize_t dims[2]; - int n_dims = space.getSimpleExtentDims(dims); - if (n_dims < 0) - { + int n_dims = space.getSimpleExtentDims(dims); + if (n_dims < 0) { throw Exception("test_compression", "DataSpace::getSimpleExtentDims() failed"); } @@ -308,8 +301,7 @@ static herr_t test_datasize(FileAccPropList &fapl) size_t ds_size = dset.getInMemDataSize(); // Verify the data size. - if (ds_size != expected_size) - { + if (ds_size != expected_size) { H5_FAILED(); cerr << " Expected data size = " << expected_size; cerr << " but dset.getInMemDataSize() returned " << ds_size << endl; @@ -318,19 +310,17 @@ static herr_t test_datasize(FileAccPropList &fapl) PASSED(); return 0; - } // end try + } // end try // catch all dataset, space, plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; return -1; } -} // test_datasize +} // test_datasize - /*------------------------------------------------------------------------- * Function: test_tconv * @@ -344,84 +334,79 @@ static herr_t test_datasize(FileAccPropList &fapl) * Friday, January 5, 2001 *------------------------------------------------------------------------- */ -static herr_t test_tconv(H5File& file) +static herr_t +test_tconv(H5File &file) { // Prepare buffers for input/output - char *out=NULL, *in=NULL; - out = new char [4*1000000]; + char *out = NULL, *in = NULL; + out = new char[4 * 1000000]; // assert (out); - should use exception handler for new - BMR - in = new char [4*1000000]; - //assert (in); + in = new char[4 * 1000000]; + // assert (in); SUBTEST("Data type conversion"); // Initialize the dataset for (int i = 0; i < 1000000; i++) { - out[i*4+0] = 0x11; - out[i*4+1] = 0x22; - out[i*4+2] = 0x33; - out[i*4+3] = 0x44; + out[i * 4 + 0] = 0x11; + out[i * 4 + 1] = 0x22; + out[i * 4 + 2] = 0x33; + out[i * 4 + 3] = 0x44; } - try - { + try { // Create the data space hsize_t dims[1]; dims[0] = 1000000; - DataSpace space (1, dims, NULL); + DataSpace space(1, dims, NULL); // Create the data set - DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space)); + DataSet dataset(file.createDataSet(DSET_TCONV_NAME, PredType::STD_I32LE, space)); // Write the data to the dataset - dataset.write (static_cast(out), PredType::STD_I32LE); + dataset.write(static_cast(out), PredType::STD_I32LE); // Read data with byte order conversion - dataset.read (static_cast(in), PredType::STD_I32BE); + dataset.read(static_cast(in), PredType::STD_I32BE); // Check for (int i = 0; i < 1000000; i++) { - if (in[4*i+0]!=out[4*i+3] || - in[4*i+1]!=out[4*i+2] || - in[4*i+2]!=out[4*i+1] || - in[4*i+3]!=out[4*i+0]) - { + if (in[4 * i + 0] != out[4 * i + 3] || in[4 * i + 1] != out[4 * i + 2] || + in[4 * i + 2] != out[4 * i + 1] || in[4 * i + 3] != out[4 * i + 0]) { throw Exception("DataSet::read", "Read with byte order conversion failed"); } } // clean up and return with success - delete [] out; - delete [] in; + delete[] out; + delete[] in; PASSED(); return 0; - } // end try + } // end try // catch all dataset and space exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; // clean up and return with failure - delete [] out; - delete [] in; + delete[] out; + delete[] in; return -1; } -} // test_tconv +} // test_tconv /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encode and decode enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)filter_bogus, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encode and decode enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)filter_bogus, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: bogus * @@ -435,15 +420,14 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ * Tuesday, April 21, 1998 *------------------------------------------------------------------------- */ -static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int cd_values[], size_t nbytes, - size_t *buf_size, void **buf) +static size_t +filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], size_t nbytes, + size_t *buf_size, void **buf) // H5_ATTR_UNUSED variables caused warning, but taking them out caused failure. { return nbytes; } - /*------------------------------------------------------------------------- * Function: test_compression * @@ -460,28 +444,27 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, * Friday, January 5, 2001 *------------------------------------------------------------------------- */ -static herr_t test_compression(H5File& file) +static herr_t +test_compression(H5File &file) { #ifndef H5_HAVE_FILTER_DEFLATE const char *not_supported; not_supported = " Deflate compression is not enabled."; #endif /* H5_HAVE_FILTER_DEFLATE */ - int points[100][200]; - int check[100][200]; - hsize_t i, j, n; + int points[100][200]; + int check[100][200]; + hsize_t i, j, n; // Initialize the dataset - for (i = n = 0; i < 100; i++) - { + for (i = n = 0; i < 100; i++) { for (j = 0; j < 200; j++) { points[i][j] = static_cast(n++); } } - char* tconv_buf = new char [1000]; - DataSet* dataset = NULL; - try - { + char * tconv_buf = new char[1000]; + DataSet *dataset = NULL; + try { const hsize_t size[2] = {100, 200}; // Create the data space DataSpace space1(2, size, NULL); @@ -489,39 +472,39 @@ static herr_t test_compression(H5File& file) // Create a small conversion buffer to test strip mining DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Use chunked storage with compression DSetCreatPropList dscreatplist; const hsize_t chunk_size[2] = {2, 25}; - dscreatplist.setChunk (2, chunk_size); - dscreatplist.setDeflate (6); + dscreatplist.setChunk(2, chunk_size); + dscreatplist.setDeflate(6); #ifdef H5_HAVE_FILTER_DEFLATE SUBTEST("Compression (setup)"); // Create the dataset - dataset = new DataSet (file.createDataSet - (DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist)); + dataset = + new DataSet(file.createDataSet(DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist)); PASSED(); /*---------------------------------------------------------------------- - * STEP 1: Read uninitialized data. It should be zero. - *---------------------------------------------------------------------- - */ + * STEP 1: Read uninitialized data. It should be zero. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (uninitialized read)"); - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - for (i=0; i(i) - << "," << static_cast(j) << endl; + cerr << " At index " << static_cast(i) << "," + << static_cast(j) << endl; throw Exception("test_compression", "Failed in uninitialized read"); } } @@ -529,38 +512,36 @@ static herr_t test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 2: Test compression by setting up a chunked dataset and writing - * to it. - *---------------------------------------------------------------------- - */ + * STEP 2: Test compression by setting up a chunked dataset and writing + * to it. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (write)"); - for (i=n=0; i(n++); } } - dataset->write (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); PASSED(); /*---------------------------------------------------------------------- - * STEP 3: Try to read the data we just wrote. - *---------------------------------------------------------------------- - */ + * STEP 3: Try to read the data we just wrote. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (read)"); // Read the dataset back - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in read"); } @@ -568,31 +549,29 @@ static herr_t test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 4: Write new data over the top of the old data. The new data is - * random thus not very compressible, and will cause the chunks to move - * around as they grow. We only change values for the left half of the - * dataset although we rewrite the whole thing. - *---------------------------------------------------------------------- - */ + * STEP 4: Write new data over the top of the old data. The new data is + * random thus not very compressible, and will cause the chunks to move + * around as they grow. We only change values for the left half of the + * dataset although we rewrite the whole thing. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (modify)"); - for (i=0; iwrite (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); // Read the dataset back and check it - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in modify"); } @@ -600,66 +579,65 @@ static herr_t test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 5: Close the dataset and then open it and read it again. This - * insures that the compression message is picked up properly from the - * object header. - *---------------------------------------------------------------------- - */ + * STEP 5: Close the dataset and then open it and read it again. This + * insures that the compression message is picked up properly from the + * object header. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (re-open)"); // close this dataset to reuse the var delete dataset; - dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME)); - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset = new DataSet(file.openDataSet(DSET_COMPRESS_NAME)); + dataset->read(static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in re-open"); } PASSED(); - /*---------------------------------------------------------------------- - * STEP 6: Test partial I/O by writing to and then reading from a - * hyperslab of the dataset. The hyperslab does not line up on chunk - * boundaries (we know that case already works from above tests). - *---------------------------------------------------------------------- - */ + * STEP 6: Test partial I/O by writing to and then reading from a + * hyperslab of the dataset. The hyperslab does not line up on chunk + * boundaries (we know that case already works from above tests). + *---------------------------------------------------------------------- + */ SUBTEST("Compression (partial I/O)"); - const hsize_t hs_size[2] = {4, 50}; + const hsize_t hs_size[2] = {4, 50}; const hsize_t hs_offset[2] = {7, 30}; for (i = 0; i < hs_size[0]; i++) { for (j = 0; j < hs_size[1]; j++) { - points[hs_offset[0]+i][hs_offset[1]+j] = rand (); + points[hs_offset[0] + i][hs_offset[1] + j] = rand(); } } - space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset ); - dataset->write (static_cast(points), PredType::NATIVE_INT, space1, space1, xfer); - dataset->read (static_cast(check), PredType::NATIVE_INT, space1, space1, xfer); + space1.selectHyperslab(H5S_SELECT_SET, hs_size, hs_offset); + dataset->write(static_cast(points), PredType::NATIVE_INT, space1, space1, xfer); + dataset->read(static_cast(check), PredType::NATIVE_INT, space1, space1, xfer); // Check that the values read are the same as the values written - for (i=0; i((hs_offset[0]+i)) << - "," << static_cast((hs_offset[1]+j)) << endl; - - cerr << " At original: " << static_cast(points[hs_offset[0]+i][hs_offset[1]+j]) << endl; - cerr << " At returned: " << static_cast(check[hs_offset[0]+i][hs_offset[1]+j]) << endl; - throw Exception("test_compression", "Failed in partial I/O"); - } - } // for j - } // for i + for (i = 0; i < hs_size[0]; i++) { + for (j = 0; j < hs_size[1]; j++) { + if (points[hs_offset[0] + i][hs_offset[1] + j] != check[hs_offset[0] + i][hs_offset[1] + j]) { + H5_FAILED(); + cerr << " Read different values than written.\n" << endl; + cerr << " At index " << static_cast((hs_offset[0] + i)) << "," + << static_cast((hs_offset[1] + j)) << endl; + + cerr << " At original: " + << static_cast(points[hs_offset[0] + i][hs_offset[1] + j]) << endl; + cerr << " At returned: " << static_cast(check[hs_offset[0] + i][hs_offset[1] + j]) + << endl; + throw Exception("test_compression", "Failed in partial I/O"); + } + } // for j + } // for i delete dataset; dataset = NULL; @@ -673,29 +651,30 @@ static herr_t test_compression(H5File& file) #endif /*---------------------------------------------------------------------- - * STEP 7: Register an application-defined compression method and use it - * to write and then read the dataset. - *---------------------------------------------------------------------- - */ + * STEP 7: Register an application-defined compression method and use it + * to write and then read the dataset. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (app-defined method)"); - if (H5Zregister (H5Z_BOGUS)<0) - throw Exception("test_compression", "Failed in app-defined method"); - if (H5Pset_filter (dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL)<0) + if (H5Zregister(H5Z_BOGUS) < 0) + throw Exception("test_compression", "Failed in app-defined method"); + if (H5Pset_filter(dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL) < 0) throw Exception("test_compression", "Failed in app-defined method"); - dscreatplist.setFilter (H5Z_FILTER_BOGUS, 0, 0, NULL); + dscreatplist.setFilter(H5Z_FILTER_BOGUS, 0, 0, NULL); - DataSpace space2 (2, size, NULL); - dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); + DataSpace space2(2, size, NULL); + dataset = + new DataSet(file.createDataSet(DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); - dataset->write (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); + dataset->read(static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in app-defined method"); } @@ -703,17 +682,16 @@ static herr_t test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * Cleanup - *---------------------------------------------------------------------- - */ + * Cleanup + *---------------------------------------------------------------------- + */ delete dataset; - delete [] tconv_buf; + delete[] tconv_buf; return 0; } // end try // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -721,12 +699,11 @@ static herr_t test_compression(H5File& file) if (dataset != NULL) delete dataset; if (tconv_buf) - delete [] tconv_buf; + delete[] tconv_buf; return -1; } -} // test_compression +} // test_compression - /*------------------------------------------------------------------------- * Function: test_nbit_methods * @@ -742,18 +719,19 @@ static herr_t test_compression(H5File& file) *------------------------------------------------------------------------- */ const H5std_string DSET_NBIT_NAME("nbit_dataset"); -const hsize_t DIM1 = 2; -const hsize_t DIM2 = 5; +const hsize_t DIM1 = 2; +const hsize_t DIM2 = 5; -static herr_t test_nbit_compression(H5File& file) +static herr_t +test_nbit_compression(H5File &file) { typedef struct { - int i; - char c; + int i; + char c; short s; } s1_t; - const hsize_t size[2] = {DIM1, DIM2}; + const hsize_t size[2] = {DIM1, DIM2}; const hsize_t chunk_size[2] = {DIM1, DIM2}; s1_t orig_data[DIM1][DIM2]; s1_t new_data[DIM1][DIM2]; @@ -761,8 +739,7 @@ static herr_t test_nbit_compression(H5File& file) SUBTEST("N-bit compression (setup)"); - try - { + try { // Define datatypes of members of compound datatype IntType i_type(PredType::NATIVE_INT); IntType c_type(PredType::NATIVE_CHAR); @@ -781,7 +758,7 @@ static herr_t test_nbit_compression(H5File& file) mem_cmpd.insertMember("s", HOFFSET(s1_t, s), s_type); // Set order of dataset compound datatype - //cmpd.setOrder(H5T_ORDER_BE); only for atomic type? + // cmpd.setOrder(H5T_ORDER_BE); only for atomic type? // Create the data space DataSpace space(2, size); @@ -796,36 +773,33 @@ static herr_t test_nbit_compression(H5File& file) // Initialize data, assuming size of long long >= size of member datatypes for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { + for (j = 0; j < size[1]; j++) { orig_data[i][j].i = static_cast(i * j); orig_data[i][j].c = static_cast('a' + i); orig_data[i][j].s = static_cast(i + j); // Some even-numbered integer values are negative - if ((i*size[1]+j+1)%2 == 0) { + if ((i * size[1] + j + 1) % 2 == 0) { orig_data[i][j].i = -orig_data[i][j].i; orig_data[i][j].s = static_cast(-orig_data[i][j].s); } } // Write to the dataset - dataset.write(static_cast(orig_data), mem_cmpd); + dataset.write(static_cast(orig_data), mem_cmpd); // Read the dataset back */ - dataset.read(static_cast(new_data), mem_cmpd); + dataset.read(static_cast(new_data), mem_cmpd); // Check that the values read are the same as the values written. for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - if((new_data[i][j].i != orig_data[i][j].i) || - (new_data[i][j].c != orig_data[i][j].c) || - (new_data[i][j].s != orig_data[i][j].s)) - { + for (j = 0; j < size[1]; j++) { + if ((new_data[i][j].i != orig_data[i][j].i) || (new_data[i][j].c != orig_data[i][j].c) || + (new_data[i][j].s != orig_data[i][j].s)) { H5_FAILED(); printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", static_cast(i), static_cast(j)); + printf(" At index %lu,%lu\n", static_cast(i), + static_cast(j)); } } @@ -834,8 +808,7 @@ static herr_t test_nbit_compression(H5File& file) } // end try block // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -843,7 +816,6 @@ static herr_t test_nbit_compression(H5File& file) } } // test_nbit_compression - /*------------------------------------------------------------------------- * Function: test_multiopen * @@ -860,12 +832,13 @@ static herr_t test_nbit_compression(H5File& file) * Saturday, February 17, 2001 *------------------------------------------------------------------------- */ -static herr_t test_multiopen (H5File& file) +static herr_t +test_multiopen(H5File &file) { SUBTEST("Multi-open with extending"); - DataSpace* space = NULL; + DataSpace *space = NULL; try { // Create a dataset creation property list @@ -873,17 +846,17 @@ static herr_t test_multiopen (H5File& file) // Set chunk size to given size hsize_t cur_size[1] = {10}; - dcpl.setChunk (1, cur_size); + dcpl.setChunk(1, cur_size); // Create a simple data space with unlimited size hsize_t max_size[1] = {H5S_UNLIMITED}; - space = new DataSpace (1, cur_size, max_size); + space = new DataSpace(1, cur_size, max_size); // Create first dataset - DataSet dset1 = file.createDataSet ("multiopen", PredType::NATIVE_INT, *space, dcpl); + DataSet dset1 = file.createDataSet("multiopen", PredType::NATIVE_INT, *space, dcpl); // Open again the first dataset from the file to another DataSet object. - DataSet dset2 = file.openDataSet ("multiopen"); + DataSet dset2 = file.openDataSet("multiopen"); // Relieve the dataspace delete space; @@ -891,18 +864,16 @@ static herr_t test_multiopen (H5File& file) // Extend the dimensionality of the first dataset cur_size[0] = 20; - dset1.extend (cur_size); + dset1.extend(cur_size); // Get the size from the second handle - space = new DataSpace (dset2.getSpace()); + space = new DataSpace(dset2.getSpace()); hsize_t tmp_size[1]; - space->getSimpleExtentDims (tmp_size); - if (cur_size[0]!=tmp_size[0]) - { - cerr << " Got " << static_cast(tmp_size[0]) - << " instead of " << static_cast(cur_size[0]) - << "!" << endl; + space->getSimpleExtentDims(tmp_size); + if (cur_size[0] != tmp_size[0]) { + cerr << " Got " << static_cast(tmp_size[0]) << " instead of " + << static_cast(cur_size[0]) << "!" << endl; throw Exception("test_multiopen", "Failed in multi-open with extending"); } @@ -913,8 +884,7 @@ static herr_t test_multiopen (H5File& file) } // end try block // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -923,9 +893,8 @@ static herr_t test_multiopen (H5File& file) delete space; return -1; } -} // test_multiopen +} // test_multiopen - /*------------------------------------------------------------------------- * Function: test_types * @@ -939,24 +908,25 @@ static herr_t test_multiopen (H5File& file) * February 17, 2001 *------------------------------------------------------------------------- */ -static herr_t test_types(H5File& file) +static herr_t +test_types(H5File &file) { SUBTEST("Various datatypes"); - size_t i; - DataSet* dset = NULL; + size_t i; + DataSet *dset = NULL; try { // Create a group in the file that was passed in from the caller - Group grp = file.createGroup ("typetests"); + Group grp = file.createGroup("typetests"); /* bitfield_1 */ unsigned char buf[32]; - hsize_t nelmts = sizeof(buf); - DataType type; + hsize_t nelmts = sizeof(buf); + DataType type; try { // block of bitfield_1 // test copying a predefined type - type.copy (PredType::STD_B8LE); + type.copy(PredType::STD_B8LE); // Test copying a user-defined type using DataType::copy DataType copied_type; @@ -967,7 +937,7 @@ static herr_t test_types(H5File& file) another_copied_type = type; // Test copying a user-defined int type using DataType::operator= - IntType orig_int(PredType::STD_B8LE); + IntType orig_int(PredType::STD_B8LE); DataType generic_type; generic_type = orig_int; @@ -978,45 +948,45 @@ static herr_t test_types(H5File& file) IntType another_int_type; another_int_type = new_int_type; - DataSpace space (1, &nelmts); + DataSpace space(1, &nelmts); dset = new DataSet(grp.createDataSet("bitfield_1", type, space)); // Fill buffer - for (i=0; i(0xff) ^ static_cast(i); + for (i = 0; i < sizeof buf; i++) + buf[i] = static_cast(0xff) ^ static_cast(i); // Write data from buf using all default dataspaces and property list - dset->write (buf, type); + dset->write(buf, type); // no failure in bitfield_1, close this dataset delete dset; } // end try block of bitfield_1 // catch exceptions thrown in try block of bitfield_1 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "bitfield_1: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "bitfield_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; return -1; } /* bitfield_2 */ - nelmts = sizeof(buf)/2; + nelmts = sizeof(buf) / 2; try { // bitfield_2 block - type.copy (PredType::STD_B16LE); - DataSpace space (1, &nelmts); + type.copy(PredType::STD_B16LE); + DataSpace space(1, &nelmts); dset = new DataSet(grp.createDataSet("bitfield_2", type, space)); // Fill buffer - for (i=0; i(0xff) ^ static_cast(i); // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, type); + dset->write(buf, type); // no failure in bitfield_2, close this dataset and reset for // variable reuse @@ -1025,44 +995,46 @@ static herr_t test_types(H5File& file) } // end try block of bitfield_2 // catch exceptions thrown in try block of bitfield_2 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "bitfield_2: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "bitfield_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; throw E; // propagate the exception } /* opaque_1 */ - DataType* optype = NULL; + DataType *optype = NULL; try { // opaque_1 block optype = new DataType(H5T_OPAQUE, 1); nelmts = sizeof(buf); - DataSpace space (1, &nelmts); - optype->setTag ("testing 1-byte opaque type"); + DataSpace space(1, &nelmts); + optype->setTag("testing 1-byte opaque type"); dset = new DataSet(grp.createDataSet("opaque_1", *optype, space)); // Fill buffer - for (i=0; i(0xff) ^ static_cast(i); // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, *optype); + dset->write(buf, *optype); // no failure in opaque_1 - delete dset; dset = NULL; - delete optype; optype = NULL; + delete dset; + dset = NULL; + delete optype; + optype = NULL; } // end try block of opaque_1 // catch exceptions thrown in try block of opaque_1 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "opaque_1: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "opaque_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; if (optype != NULL) @@ -1072,31 +1044,33 @@ static herr_t test_types(H5File& file) /* opaque_2 */ try { // block opaque_2 - nelmts = sizeof(buf)/4; - DataSpace space (1, &nelmts); + nelmts = sizeof(buf) / 4; + DataSpace space(1, &nelmts); optype = new DataType(H5T_OPAQUE, 4); - optype->setTag ("testing 4-byte opaque type"); + optype->setTag("testing 4-byte opaque type"); dset = new DataSet(grp.createDataSet("opaque_2", *optype, space)); // Fill buffer - for (i=0; i(0xff) ^ static_cast(i); // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, *optype); + dset->write(buf, *optype); // no failure in opaque_1 - delete dset; dset = NULL; - delete optype; optype = NULL; - } //end try block of opaque_2 + delete dset; + dset = NULL; + delete optype; + optype = NULL; + } // end try block of opaque_2 // catch exceptions thrown in try block of opaque_2 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "opaque_2: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "opaque_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; if (optype != NULL) @@ -1108,13 +1082,11 @@ static herr_t test_types(H5File& file) return 0; } // end top try block - catch (Exception& E) - { + catch (Exception &E) { return -1; } -} // test_types +} // test_types - /*------------------------------------------------------------------------- * Function: test_getNativeObjinfo * @@ -1126,16 +1098,17 @@ static herr_t test_types(H5File& file) * July, 2018 *------------------------------------------------------------------------- */ -static herr_t test_getnativeinfo(H5File& file) +static herr_t +test_getnativeinfo(H5File &file) { SUBTEST("Getting object information"); try { // Create a data space - hsize_t dims[2]; + hsize_t dims[2]; dims[0] = 256; dims[1] = 512; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a dataset using the default dataset creation properties. // We're not sure what they are, so we won't check. @@ -1158,23 +1131,20 @@ static herr_t test_getnativeinfo(H5File& file) PASSED(); return 0; - } // outer most try block + } // outer most try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; return -1; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_getnativeinfo", __LINE__, __FILE__); return -1; } -} // test_getnativeinfo +} // test_getnativeinfo - /*------------------------------------------------------------------------- * Function: test_chunk_cache * @@ -1187,10 +1157,11 @@ static herr_t test_getnativeinfo(H5File& file) * July 2018 *------------------------------------------------------------------------- */ -const int RANK1 = 1; +const int RANK1 = 1; const H5std_string FILE_ACCPLIST("test_accplist.h5"); -static herr_t test_chunk_cache(FileAccPropList fapl) +static herr_t +test_chunk_cache(FileAccPropList fapl) { SUBTEST("DSetAccPropList::set/getChunkCache"); @@ -1200,14 +1171,14 @@ static herr_t test_chunk_cache(FileAccPropList fapl) DSetAccPropList dapl; // Verify that chunk cache parameters are the same - int mdc_nelmts = 0; + int mdc_nelmts = 0; size_t nslots_1 = 0, nslots_4 = 0, nbytes_1 = 0, nbytes_4 = 0; double w0_1 = 0.0F, w0_4 = 0.0F; fapl_def.getCache(mdc_nelmts, nslots_1, nbytes_1, w0_1); dapl.getChunkCache(nslots_4, nbytes_4, w0_4); - verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); - verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); - verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); // Set a link access property on dapl to verify property list inheritance dapl.setNumLinks((size_t)134); @@ -1220,7 +1191,7 @@ static herr_t test_chunk_cache(FileAccPropList fapl) // Set new rdcc settings on fapl local size_t nslots_2 = nslots_1 * 2; size_t nbytes_2 = nbytes_1 * 2; - double w0_2 = w0_1 / (double)2.0F; + double w0_2 = w0_1 / (double)2.0F; fapl_local.getCache(mdc_nelmts, nslots_2, nbytes_2, w0_2); // Create a new file using default fcpl and the passed-in fapl @@ -1247,17 +1218,16 @@ static herr_t test_chunk_cache(FileAccPropList fapl) // Retrieve and verify the raw data chunk cache parameters nslots_4 = nbytes_4 = 0; - w0_4 = 0.0F; + w0_4 = 0.0F; dapl2.getChunkCache(nslots_4, nbytes_4, w0_4); verify_val(nslots_2, nslots_4, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); verify_val(nbytes_2, nbytes_4, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); verify_val(H5_DBL_ABS_EQUAL(w0_2, w0_4), 1, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); - // Set new values on original dapl size_t nslots_3 = nslots_1 * 2; size_t nbytes_3 = H5D_CHUNK_CACHE_NBYTES_DEFAULT; - double w0_3 = w0_2 / 2; + double w0_3 = w0_2 / 2; dapl.getChunkCache(nslots_3, nbytes_3, w0_3); // Close dataset @@ -1275,18 +1245,15 @@ static herr_t test_chunk_cache(FileAccPropList fapl) verify_val(nbytes_3, nbytes_4, "DSetCreatPropList::getLayout", __LINE__, __FILE__); verify_val(H5_DBL_ABS_EQUAL(w0_3, w0_4), 1, "DSetCreatPropList::getLayout", __LINE__, __FILE__); - PASSED(); return 0; } // end top try block - catch (Exception& E) - { + catch (Exception &E) { return -1; } } // test_chunk_cache - /*------------------------------------------------------------------------- * Function: test_virtual * @@ -1303,7 +1270,8 @@ static herr_t test_chunk_cache(FileAccPropList fapl) */ const int RANK = 2; -static herr_t test_virtual() +static herr_t +test_virtual() { SUBTEST("DSetCreatPropList::setVirtual"); @@ -1338,8 +1306,8 @@ static herr_t test_virtual() dims[1] = 6; DataSpace vspace(RANK, dims, mdims); - hsize_t start[RANK]; // Hyperslab start - hsize_t count[RANK]; // Hyperslab count + hsize_t start[RANK]; // Hyperslab start + hsize_t count[RANK]; // Hyperslab count start[0] = start[1] = 3; count[0] = count[1] = 3; vspace.selectHyperslab(H5S_SELECT_SET, count, start); @@ -1358,13 +1326,11 @@ static herr_t test_virtual() return 0; } // end top try block - catch (Exception& E) - { + catch (Exception &E) { return -1; } } // test_virtual - /*------------------------------------------------------------------------- * Function: test_dset * @@ -1387,15 +1353,14 @@ static herr_t test_virtual() * *------------------------------------------------------------------------- */ -extern "C" -void test_dset() +extern "C" void +test_dset() { hid_t fapl_id; - fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template - int nerrors=0; // keep track of number of failures occur + fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template + int nerrors = 0; // keep track of number of failures occur - try - { + try { // Use the file access template id to create a file access prop. // list object to pass in H5File::H5File FileAccPropList fapl(fapl_id); @@ -1403,19 +1368,19 @@ void test_dset() H5File file(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Cause the library to emit initial messages - Group grp = file.createGroup( "emit diagnostics", 0); + Group grp = file.createGroup("emit diagnostics", 0); grp.setComment("Causes diagnostic messages to be emitted"); - nerrors += test_create(file) < 0 ? 1:0; - nerrors += test_simple_io(file) < 0 ? 1:0; - nerrors += test_getnativeinfo(file) < 0 ? 1:0; - nerrors += test_tconv(file) < 0 ? 1:0; - nerrors += test_compression(file) < 0 ? 1:0; - nerrors += test_nbit_compression(file) < 0 ? 1:0; - nerrors += test_multiopen (file) < 0 ? 1:0; - nerrors += test_types(file) < 0 ? 1:0; - nerrors += test_virtual() < 0 ? 1:0; - nerrors += test_chunk_cache(fapl) < 0 ? 1:0; + nerrors += test_create(file) < 0 ? 1 : 0; + nerrors += test_simple_io(file) < 0 ? 1 : 0; + nerrors += test_getnativeinfo(file) < 0 ? 1 : 0; + nerrors += test_tconv(file) < 0 ? 1 : 0; + nerrors += test_compression(file) < 0 ? 1 : 0; + nerrors += test_nbit_compression(file) < 0 ? 1 : 0; + nerrors += test_multiopen(file) < 0 ? 1 : 0; + nerrors += test_types(file) < 0 ? 1 : 0; + nerrors += test_virtual() < 0 ? 1 : 0; + nerrors += test_chunk_cache(fapl) < 0 ? 1 : 0; // Close group "emit diagnostics". grp.close(); @@ -1423,18 +1388,16 @@ void test_dset() // Close the file before testing data size. file.close(); - nerrors += test_datasize(fapl) <0 ? 1:0; + nerrors += test_datasize(fapl) < 0 ? 1 : 0; } - catch (Exception& E) - { + catch (Exception &E) { test_report(nerrors, H5std_string(" Dataset")); } // Clean up data file cleanup_dsets(); -} // test_dset +} // test_dset - /*------------------------------------------------------------------------- * Function: cleanup_dsets * @@ -1445,9 +1408,8 @@ void test_dset() * Programmer (use C version) *------------------------------------------------------------------------- */ -extern "C" -void cleanup_dsets() +extern "C" void +cleanup_dsets() { HDremove(FILE1.c_str()); } // cleanup_dsets - diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp index f271eed..960e9c9 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -28,11 +28,11 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file /*------------------------------------------------------------------------- * Function: test_report @@ -49,24 +49,21 @@ using namespace H5; * Friday, February 6, 2001 *------------------------------------------------------------------------- */ -int test_report( int nerrors, const H5std_string& testname ) +int +test_report(int nerrors, const H5std_string &testname) { - if (nerrors) - { - nerrors = MAX(1, nerrors); + if (nerrors) { + nerrors = MAX(1, nerrors); if (1 == nerrors) - cerr << "***** " << nerrors << testname - << " TEST FAILED! *****" << endl; + cerr << "***** " << nerrors << testname << " TEST FAILED! *****" << endl; else - cerr << "***** " << nerrors << testname - << " TESTS FAILED! *****" << endl; - return 1; - } - else - { - cerr << "All" << testname << " tests passed." << endl; - return 0; - } + cerr << "***** " << nerrors << testname << " TESTS FAILED! *****" << endl; + return 1; + } + else { + cerr << "All" << testname << " tests passed." << endl; + return 0; + } } /*------------------------------------------------------------------------- @@ -81,14 +78,14 @@ int test_report( int nerrors, const H5std_string& testname ) * *------------------------------------------------------------------------- */ -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* message) +void +issue_fail_msg(const char *where, int line, const char *file_name, const char *message) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << ">>> FAILED in " << where << " at line " << line - << " in " << file_name << " - " << message << endl << endl; + cerr << ">>> FAILED in " << where << " at line " << line << " in " << file_name << " - " << message + << endl + << endl; } } @@ -104,15 +101,15 @@ void issue_fail_msg(const char* where, int line, const char* file_name, * *------------------------------------------------------------------------- */ -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* func_name, const char* message) +void +issue_fail_msg(const char *where, int line, const char *file_name, const char *func_name, const char *message) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << ">>> FAILED in " << where << ": " << func_name << endl << - " at line " << line << " in " << file_name << endl << - " C library detail: " << message << endl << endl; + cerr << ">>> FAILED in " << where << ": " << func_name << endl + << " at line " << line << " in " << file_name << endl + << " C library detail: " << message << endl + << endl; } } @@ -134,13 +131,13 @@ void issue_fail_msg(const char* where, int line, const char* file_name, * Friday, February 6, 2001 *------------------------------------------------------------------------- */ -int check_values (hsize_t i, hsize_t j, int apoint, int acheck) +int +check_values(hsize_t i, hsize_t j, int apoint, int acheck) { - if (apoint != acheck) - { + if (apoint != acheck) { cerr << " Read different values than written.\n" << endl; - cerr << " At index " << static_cast(i) << "," << - static_cast(j) << endl; + cerr << " At index " << static_cast(i) << "," << static_cast(j) + << endl; return -1; } return 0; @@ -161,10 +158,10 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck) * *------------------------------------------------------------------------- */ -void check_values(const char *value, const char* msg, int line, const char* file_name) +void +check_values(const char *value, const char *msg, int line, const char *file_name) { - if (value == NULL) - { + if (value == NULL) { cerr << endl; cerr << "*** ERROR: " << msg << ", at line " << line << endl; IncTestNumErrs(); @@ -187,21 +184,19 @@ void check_values(const char *value, const char* msg, int line, const char* file * May 2, 2010 *------------------------------------------------------------------------- */ -void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name) +void +verify_val(const char *x, const char *value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (strcmp(x, value) != 0) - { + if (strcmp(x, value) != 0) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should be " - << value << ", but is " << x << " at line " << line - << " in " << file_name << endl; - //IncTestNumErrs(); + cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x + << " at line " << line << " in " << file_name << endl; + // IncTestNumErrs(); throw TestFailedException(where, ""); } } @@ -209,7 +204,9 @@ void verify_val(const char* x, const char* value, const char* where, int line, c //-------------------------------------------------------------------------- // Function: InvalidActionException default constructor //-------------------------------------------------------------------------- -InvalidActionException::InvalidActionException():Exception(){} +InvalidActionException::InvalidActionException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: InvalidActionException overloaded constructor @@ -221,17 +218,24 @@ InvalidActionException::InvalidActionException():Exception(){} // func - IN: Name of the function where failure should occur // message - IN: Message //-------------------------------------------------------------------------- -InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) : Exception(func, message) {} +InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: InvalidActionException destructor //-------------------------------------------------------------------------- -InvalidActionException::~InvalidActionException() throw() {} +InvalidActionException::~InvalidActionException() throw() +{ +} //-------------------------------------------------------------------------- // Function: TestFailedException default constructor //-------------------------------------------------------------------------- -TestFailedException::TestFailedException():Exception(){} +TestFailedException::TestFailedException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: TestFailedException overloaded constructor @@ -243,10 +247,14 @@ TestFailedException::TestFailedException():Exception(){} // func - IN: Name of the function where failure should occur // message - IN: Message //-------------------------------------------------------------------------- -TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) : Exception(func, message) {} +TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: TestFailedException destructor //-------------------------------------------------------------------------- -TestFailedException::~TestFailedException() throw() {} - +TestFailedException::~TestFailedException() throw() +{ +} diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h index 6664d0c..97ed00b 100644 --- a/c++/test/h5cpputil.h +++ b/c++/test/h5cpputil.h @@ -28,94 +28,97 @@ using namespace H5; using std::cerr; using std::endl; -#define MESSAGE(V,A) {if (HDGetTestVerbosity()>(V)) print_func A;} -#define SUBTEST(TEST) {printf(" Subtest: %-52s",TEST); fflush(stdout);} +#define MESSAGE(V, A) \ + { \ + if (HDGetTestVerbosity() > (V)) \ + print_func A; \ + } +#define SUBTEST(TEST) \ + { \ + printf(" Subtest: %-52s", TEST); \ + fflush(stdout); \ + } -int check_values (hsize_t i, hsize_t j, int apoint, int acheck); -void check_values(const char *value, const char* msg, int line, const char* file_name); -int test_report (int, const H5std_string&); -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* message=""); -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* func_name, const char* message); +int check_values(hsize_t i, hsize_t j, int apoint, int acheck); +void check_values(const char *value, const char *msg, int line, const char *file_name); +int test_report(int, const H5std_string &); +void issue_fail_msg(const char *where, int line, const char *file_name, const char *message = ""); +void issue_fail_msg(const char *where, int line, const char *file_name, const char *func_name, + const char *message); class InvalidActionException : public Exception { - public: - InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); - InvalidActionException(); - virtual ~InvalidActionException() throw(); + public: + InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); + InvalidActionException(); + virtual ~InvalidActionException() throw(); }; class TestFailedException : public Exception { - public: - TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); - TestFailedException(); - virtual ~TestFailedException() throw(); + public: + TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); + TestFailedException(); + virtual ~TestFailedException() throw(); }; // Overloaded/Template functions to verify values and display proper info // Verifies -void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name); +void verify_val(const char *x, const char *value, const char *where, int line, const char *file_name); template - void verify_val(Type1 x, Type2 value, const char* where, int line, const char* file_name) +void +verify_val(Type1 x, Type2 value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (x != value) - { + if (x != value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should be " - << value << ", but is " << x << " at line " << line - << " in " << file_name << endl; + cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x + << " at line " << line << " in " << file_name << endl; IncTestNumErrs(); throw TestFailedException(where, ""); } } template - void verify_val(Type1 x, Type2 value, const char* msg, const char* file_name, int line) +void +verify_val(Type1 x, Type2 value, const char *msg, const char *file_name, int line) { - if (x != value) - { + if (x != value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line - << ": " << msg << " different: " << x << ", should be " << value - << endl; + cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line << ": " << msg + << " different: " << x << ", should be " << value << endl; IncTestNumErrs(); throw TestFailedException(file_name, msg); } } template - void verify_val_noteq(Type1 x, Type2 value, const char* where, int line, const char* file_name) +void +verify_val_noteq(Type1 x, Type2 value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (x == value) - { + if (x == value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should not be " - << value << " at line " << line << " in " << file_name << endl; + cerr << "*** UNEXPECTED VALUE from " << where << " should not be " << value << " at line " << line + << " in " << file_name << endl; IncTestNumErrs(); throw TestFailedException(where, ""); } } template - void CHECK(Type1 x, Type2 value, const char* msg, int line, const char* file_name) +void +CHECK(Type1 x, Type2 value, const char *msg, int line, const char *file_name) { - if (x == value) - { + if (x == value) { cerr << endl; cerr << "*** Function " << msg << " FAILED at line " << line << endl; IncTestNumErrs(); @@ -124,14 +127,13 @@ template } template - void verify_val(Type1 x, Type2 value, float epsilon, const char* msg, int line, const char* file_name) +void +verify_val(Type1 x, Type2 value, float epsilon, const char *msg, int line, const char *file_name) { - if (x == value) - { + if (x == value) { cerr << endl; - cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line - << ": " << msg << " different: " << x << ", should be " << value - << " (epsilon=" << epsilon << ")" << endl; + cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line << ": " << msg + << " different: " << x << ", should be " << value << " (epsilon=" << epsilon << ")" << endl; IncTestNumErrs(); throw TestFailedException(file_name, msg); } diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index d80de16..dc7ea71 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -25,29 +25,35 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILENAME("tarray.h5"); -const H5std_string ARRAYTYPE_NAME("/Array type 1"); -const int SPACE1_RANK = 1; -const hsize_t SPACE1_DIM1 = 4; -const int ARRAY1_RANK = 1; -const hsize_t ARRAY1_DIM1 = 4; +const H5std_string FILENAME("tarray.h5"); +const H5std_string ARRAYTYPE_NAME("/Array type 1"); +const int SPACE1_RANK = 1; +const hsize_t SPACE1_DIM1 = 4; +const int ARRAY1_RANK = 1; +const hsize_t ARRAY1_DIM1 = 4; -typedef enum flt_t { - FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER -} flt_t; +typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t; typedef enum int_t { - INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, - INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER + INT_CHAR, + INT_UCHAR, + INT_SHORT, + INT_USHORT, + INT_INT, + INT_UINT, + INT_LONG, + INT_ULONG, + INT_LLONG, + INT_ULLONG, + INT_OTHER } int_t; - /*------------------------------------------------------------------------- * Function: test_array_compound_array * @@ -59,29 +65,29 @@ typedef enum int_t { * January, 2016 *------------------------------------------------------------------------- */ -static void test_array_compound_array() +static void +test_array_compound_array() { SUBTEST("ArrayType::getArrayNDims & ArrayType::getArrayDims"); - typedef struct { // Typedef for compound datatype */ - int i; + typedef struct { // Typedef for compound datatype */ + int i; float f[ARRAY1_DIM1]; } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write - s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int nmemb; // Number of compound members - int ii; // counting variables - hsize_t idxi, idxj, idxk; // dimension indicing variables - H5T_class_t mclass; // Datatype class for field + s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write + s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int nmemb; // Number of compound members + int ii; // counting variables + hsize_t idxi, idxj, idxk; // dimension indicing variables + H5T_class_t mclass; // Datatype class for field // Initialize array data to write - for (idxi =0; idxi < SPACE1_DIM1; idxi++) + for (idxi = 0; idxi < SPACE1_DIM1; idxi++) for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { wdata[idxi][idxj].i = idxi * 10 + idxj; - for(idxk = 0; idxk < ARRAY1_DIM1; idxk++) - { - float temp = idxi * 10.0 + idxj * 2.5 + idxk; + for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) { + float temp = idxi * 10.0 + idxj * 2.5 + idxk; wdata[idxi][idxj].f[idxk] = temp; } } // end for @@ -157,8 +163,8 @@ static void test_array_compound_array() // Verify that it is an array of compounds DataType dstype = dataset.getDataType(); - mclass = dstype.getClass(); - verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); + mclass = dstype.getClass(); + verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); dstype.close(); @@ -174,11 +180,12 @@ static void test_array_compound_array() atype_check.getArrayDims(rdims1); // Check the array dimensions - for (ii =0; ii -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file const H5std_string FILE_BASIC("tattr_basic.h5"); const H5std_string FILE_COMPOUND("tattr_compound.h5"); @@ -39,10 +39,10 @@ const H5std_string FILE_MULTI("tattr_multi.h5"); const H5std_string FILE_DTYPE("tattr_dtype.h5"); const H5std_string ATTR_TMP_NAME("temp_attr_name"); const H5std_string FATTR_TMP_NAME("temp_fattr_name"); -const size_t ATTR_MAX_DIMS = 7; +const size_t ATTR_MAX_DIMS = 7; /* 3-D dataset with fixed dimensions */ -const int SPACE1_RANK = 3; +const int SPACE1_RANK = 3; const hsize_t SPACE1_DIM1 = 3; const hsize_t SPACE1_DIM2 = 15; const hsize_t SPACE1_DIM3 = 13; @@ -54,54 +54,55 @@ const H5std_string TYPE1_NAME("/Type"); /* Attribute Rank & Dimensions */ const H5std_string ATTR1_NAME("Attr1"); -const int ATTR1_RANK = 1; -const hsize_t ATTR1_DIM1 = 3; -int attr_data1[ATTR1_DIM1]={512,-234,98123}; /* Test data for 1st attribute */ +const int ATTR1_RANK = 1; +const hsize_t ATTR1_DIM1 = 3; +int attr_data1[ATTR1_DIM1] = {512, -234, 98123}; /* Test data for 1st attribute */ // File attribute, using the same rank and dimensions as ATTR1_NAME's const H5std_string FATTR1_NAME("File Attr1"); const H5std_string FATTR2_NAME("File Attr2"); const H5std_string ATTR2_NAME("Attr2"); -const int ATTR2_RANK = 2; -const hsize_t ATTR2_DIM1 = 2; -const hsize_t ATTR2_DIM2 = 2; -int attr_data2[ATTR2_DIM1][ATTR2_DIM2]={{7614,-416},{197814,-3}}; /* Test data for 2nd attribute */ +const int ATTR2_RANK = 2; +const hsize_t ATTR2_DIM1 = 2; +const hsize_t ATTR2_DIM2 = 2; +int attr_data2[ATTR2_DIM1][ATTR2_DIM2] = {{7614, -416}, {197814, -3}}; /* Test data for 2nd attribute */ const H5std_string ATTR3_NAME("Attr3"); -const int ATTR3_RANK = 3; -const hsize_t ATTR3_DIM1 = 2; -const hsize_t ATTR3_DIM2 = 2; -const hsize_t ATTR3_DIM3 = 2; -double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{2.3,-26.1},{0.123,-10.0}},{{981724.2,-0.91827},{2.0,23.0}}}; /* Test data for 3rd attribute */ +const int ATTR3_RANK = 3; +const hsize_t ATTR3_DIM1 = 2; +const hsize_t ATTR3_DIM2 = 2; +const hsize_t ATTR3_DIM3 = 2; +double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = { + {{2.3, -26.1}, {0.123, -10.0}}, {{981724.2, -0.91827}, {2.0, 23.0}}}; /* Test data for 3rd attribute */ const H5std_string ATTR4_NAME("Attr4"); -const int ATTR4_RANK = 2; -const hsize_t ATTR4_DIM1 = 2; -const hsize_t ATTR4_DIM2 = 2; +const int ATTR4_RANK = 2; +const hsize_t ATTR4_DIM1 = 2; +const hsize_t ATTR4_DIM2 = 2; const H5std_string ATTR4_FIELDNAME1("i"); const H5std_string ATTR4_FIELDNAME2("d"); const H5std_string ATTR4_FIELDNAME3("c"); -size_t attr4_field1_off=0; -size_t attr4_field2_off=0; -size_t attr4_field3_off=0; +size_t attr4_field1_off = 0; +size_t attr4_field2_off = 0; +size_t attr4_field3_off = 0; struct attr4_struct { - int i; + int i; double d; - char c; - } attr_data4[ATTR4_DIM1][ATTR4_DIM2]={{{3,-26.1,'d'},{-100000, 0.123,'3'}}, - {{-23,981724.2,'Q'},{0,2.0,'\n'}}}; // Test data for 4th attribute + char c; +} attr_data4[ATTR4_DIM1][ATTR4_DIM2] = { + {{3, -26.1, 'd'}, {-100000, 0.123, '3'}}, + {{-23, 981724.2, 'Q'}, {0, 2.0, '\n'}}}; // Test data for 4th attribute const H5std_string ATTR5_NAME("Attr5"); -const int ATTR5_RANK = 0; -float attr_data5 = (float)-5.123; // Test data for 5th attribute +const int ATTR5_RANK = 0; +float attr_data5 = (float)-5.123; // Test data for 5th attribute /* Info for another attribute */ const H5std_string ATTR1A_NAME("Attr1_a"); -int attr_data1a[ATTR1_DIM1]={256,11945,-22107}; +int attr_data1a[ATTR1_DIM1] = {256, 11945, -22107}; - /*------------------------------------------------------------------------- * Function: test_attr_basic_write * @@ -110,12 +111,13 @@ int attr_data1a[ATTR1_DIM1]={256,11945,-22107}; * Return None *------------------------------------------------------------------------- */ -static void test_attr_basic_write() +static void +test_attr_basic_write() { - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2}; + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute hsize_t i; // Output message about test being performed @@ -123,10 +125,10 @@ static void test_attr_basic_write() try { // Create file - H5File fid1 (FILE_BASIC, H5F_ACC_TRUNC); + H5File fid1(FILE_BASIC, H5F_ACC_TRUNC); // Create dataspace for dataset - DataSpace ds_space (SPACE1_RANK, dims1); + DataSpace ds_space(SPACE1_RANK, dims1); /* * Test attribute with dataset @@ -136,55 +138,59 @@ static void test_attr_basic_write() DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); // Create dataspace for attribute - DataSpace att_space (ATTR1_RANK, dims2); + DataSpace att_space(ATTR1_RANK, dims2); // Create a file attribute - Attribute file_attr2 = fid1.createAttribute (FATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute file_attr2 = fid1.createAttribute(FATTR1_NAME, PredType::NATIVE_INT, att_space); // Create a file attribute - Attribute file_attr1 = fid1.createAttribute (FATTR2_NAME, PredType::NATIVE_INT, att_space); + Attribute file_attr1 = fid1.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, att_space); // Create an attribute for the dataset - Attribute ds_attr1 = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr1 = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // Try creating an attribute that already exists. This should fail // since two attributes cannot have the same name. If an exception // is not thrown for this action by createAttribute, then throw an // invalid action exception. try { - Attribute invalid_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute invalid_attr = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("H5File::createDataSet", + "Library allowed overwrite of existing dataset"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write attribute information - ds_attr1.write (PredType::NATIVE_INT, attr_data1); + ds_attr1.write(PredType::NATIVE_INT, attr_data1); // Read attribute information immediately, without closing attribute - ds_attr1.read (PredType::NATIVE_INT, read_data1); + ds_attr1.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i FP_EPSILON) verify_val(read_data2, attr_data5, FP_EPSILON, "Attribute::read", __LINE__, __FILE__); @@ -907,13 +919,11 @@ static void test_attr_scalar_read() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_scalar_read() +} // test_attr_scalar_read() - /*------------------------------------------------------------------------- * Function: test_attr_mult_write * @@ -922,75 +932,76 @@ static void test_attr_scalar_read() * Return None *------------------------------------------------------------------------- */ -static void test_attr_mult_write() +static void +test_attr_mult_write() { // Output message about test being performed SUBTEST("Multiple Attribute Writing Functions"); try { // Create file - H5File fid1 (FILE_MULTI, H5F_ACC_TRUNC); + H5File fid1(FILE_MULTI, H5F_ACC_TRUNC); // Create dataspace for dataset - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - DataSpace ds_space (SPACE1_RANK, dims1); + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + DataSpace ds_space(SPACE1_RANK, dims1); // Create a dataset DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); // Create dataspace for 1st attribute - hsize_t dims2[] = {ATTR1_DIM1}; - DataSpace att_space (ATTR1_RANK, dims2); + hsize_t dims2[] = {ATTR1_DIM1}; + DataSpace att_space(ATTR1_RANK, dims2); // Create 1st attribute for the dataset - Attribute ds_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // Write attribute information - ds_attr.write (PredType::NATIVE_INT, attr_data1); + ds_attr.write(PredType::NATIVE_INT, attr_data1); // Create dataspace for 2nd attribute - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - DataSpace att2_space (ATTR2_RANK, dims3); + hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2}; + DataSpace att2_space(ATTR2_RANK, dims3); // Create 2nd attribute for the dataset - Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att2_space); + Attribute ds_attr2 = dataset.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, att2_space); // Write 2nd attribute information - ds_attr2.write (PredType::NATIVE_INT, attr_data2); + ds_attr2.write(PredType::NATIVE_INT, attr_data2); // Create dataspace for 3rd attribute - hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; - DataSpace att3_space (ATTR3_RANK, dims4); + hsize_t dims4[] = {ATTR3_DIM1, ATTR3_DIM2, ATTR3_DIM3}; + DataSpace att3_space(ATTR3_RANK, dims4); // Create 3rd attribute for the dataset - Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); + Attribute ds_attr3 = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); // Try creating an attribute that already exists. This should fail // since two attributes cannot have the same name. If an exception // is not thrown for this action by createAttribute, then throw an // invalid action exception. try { - Attribute invalid_attr = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); + Attribute invalid_attr = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::createAttribute", "Attempting to create a duplicate attribute"); + throw InvalidActionException("DataSet::createAttribute", + "Attempting to create a duplicate attribute"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write 3rd attribute information - ds_attr3.write (PredType::NATIVE_DOUBLE, attr_data3); + ds_attr3.write(PredType::NATIVE_DOUBLE, attr_data3); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_mult_write() +} // test_attr_mult_write() - /*------------------------------------------------------------------------- * Function: test_attr_mult_read * @@ -999,14 +1010,15 @@ static void test_attr_mult_write() * Return None *------------------------------------------------------------------------- */ -static void test_attr_mult_read() +static void +test_attr_mult_read() { - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute - int read_data2[ATTR2_DIM1][ATTR2_DIM2]={{0}}; // Buffer for reading 2nd attribute - double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{0}}}; // Buffer for reading 3rd attribute - hsize_t i,j,k; + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute + int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; // Buffer for reading 2nd attribute + double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {{{0}}}; // Buffer for reading 3rd attribute + hsize_t i, j, k; - // Output message about test being performed + // Output message about test being performed SUBTEST("Multiple Attribute Reading Functions"); try { @@ -1033,10 +1045,11 @@ static void test_attr_mult_read() verify_val(rank, ATTR1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Get the dims of the dataspace and verify them - hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions - int ndims = space.getSimpleExtentDims(dims); + hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions + int ndims = space.getSimpleExtentDims(dims); if ((long)dims[0] != (long)ATTR1_DIM1) - TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n",__LINE__,(int)dims[0],ATTR1_DIM1); + TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n", __LINE__, + (int)dims[0], ATTR1_DIM1); /* Verify Datatype */ @@ -1046,7 +1059,7 @@ static void test_attr_mult_read() // Verify that the type is of integer datatype verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__); - // Get the integer datatype + // Get the integer datatype IntType i_type1 = attr.getIntType(); // Get and verify the order of this type @@ -1061,9 +1074,10 @@ static void test_attr_mult_read() attr.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; iopenAttribute(ATTR1_NAME)); + // Open attribute + Attribute *attr2 = new Attribute(dset2->openAttribute(ATTR1_NAME)); - // Read data from the attribute - attr2->read(PredType::NATIVE_INT, &rdata); - verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__); + // Read data from the attribute + attr2->read(PredType::NATIVE_INT, &rdata); + verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__); - // Close attribute and dataset - delete attr2; - delete dset2; + // Close attribute and dataset + delete attr2; + delete dset2; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); #endif } // end of second enclosing @@ -1458,15 +1477,13 @@ static void test_attr_dtype_shared() verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__); PASSED(); - } // end try block + } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_dtype_shared() +} // test_attr_dtype_shared() - /*------------------------------------------------------------------------- * Function: test_string_attr * @@ -1480,9 +1497,10 @@ const H5std_string ATTR1_FL_STR_NAME("String_attr 1"); const H5std_string ATTR2_FL_STR_NAME("String_attr 2"); const H5std_string ATTR_VL_STR_NAME("String_attr"); const H5std_string ATTRSTR_DATA("String Attribute"); -const int ATTR_LEN = 17; +const int ATTR_LEN = 17; -static void test_string_attr() +static void +test_string_attr() { // Output message about test being performed SUBTEST("I/O on FL and VL String Attributes"); @@ -1501,7 +1519,7 @@ static void test_string_attr() Group root = fid1.openGroup("/"); // Create dataspace for the attribute. - DataSpace att_space (H5S_SCALAR); + DataSpace att_space(H5S_SCALAR); /* Test Attribute::write(...,const void *buf) with Fixed len string */ @@ -1524,18 +1542,20 @@ static void test_string_attr() // Read and verify the attribute string as a string of chars. char flstring_att_check[ATTR_LEN]; gr_flattr1.read(fls_type, flstring_att_check); - if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + if (HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); // Read and verify the attribute string as a string of chars; buffer // is dynamically allocated. size_t attr_size = gr_flattr1.getInMemDataSize(); - char *fl_dyn_string_att_check; - fl_dyn_string_att_check = new char[attr_size+1]; + char * fl_dyn_string_att_check; + fl_dyn_string_att_check = new char[attr_size + 1]; gr_flattr1.read(fls_type, fl_dyn_string_att_check); - if(HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); - delete []fl_dyn_string_att_check; + if (HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); + delete[] fl_dyn_string_att_check; /* Test Attribute::read(...,H5std_string& strg) with FL string */ @@ -1543,13 +1563,15 @@ static void test_string_attr() H5std_string read_flstr1; gr_flattr1.read(fls_type, read_flstr1); if (read_flstr1 != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr1.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_flstr1.c_str()); // Read and verify the attribute string as a string of chars. HDstrcpy(flstring_att_check, ""); gr_flattr2.read(fls_type, flstring_att_check); - if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + if (HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); /* Test Attribute::read(...,H5std_string& strg) with FL string */ @@ -1557,7 +1579,8 @@ static void test_string_attr() H5std_string read_flstr2; gr_flattr2.read(fls_type, read_flstr2); if (read_flstr2 != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr2.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_flstr2.c_str()); // // Variable-lenth string attributes @@ -1575,8 +1598,9 @@ static void test_string_attr() // Read and verify the attribute string as a string of chars. char *string_att_check; gr_vlattr.read(vls_type, &string_att_check); - if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check); + if (HDstrcmp(string_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), string_att_check); HDfree(string_att_check); /* Test Attribute::read(...,H5std_string& strg) with VL string */ @@ -1584,17 +1608,16 @@ static void test_string_attr() H5std_string read_str; gr_vlattr.read(vls_type, read_str); if (read_str != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_str.c_str()); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_string_attr() +} // test_string_attr() - /*------------------------------------------------------------------------- * Function: test_attr_exists * @@ -1606,7 +1629,8 @@ static void test_string_attr() * Additional attrExists tests are in test_attr_rename(). *------------------------------------------------------------------------- */ -static void test_attr_exists() +static void +test_attr_exists() { // Output message about test being performed SUBTEST("Check Attribute Existence"); @@ -1621,12 +1645,14 @@ static void test_attr_exists() // Check for existence of attribute bool attr_exists = fid1.attrExists(ATTR1_FL_STR_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not"); // Check for existence of attribute attr_exists = fid1.attrExists(FATTR1_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "fid1,FATTR2_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "fid1,FATTR2_NAMEAttribute should exist but does not"); // Open a group. Group group = fid1.openGroup(GROUP1_NAME); @@ -1634,22 +1660,20 @@ static void test_attr_exists() // Check for existence of attribute attr_exists = group.attrExists(ATTR2_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "group, ATTR2_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "group, ATTR2_NAMEAttribute should exist but does not"); PASSED(); } // end try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_exists() +} // test_attr_exists() - /*------------------------------------------------------------------------- * Function: test_attr_dense_create * @@ -1659,25 +1683,25 @@ static void test_attr_exists() *------------------------------------------------------------------------- */ const H5std_string FILE_CRTPROPS("tattr_crt_properties.h5"); -const int NAME_BUF_SIZE = 1024; -const unsigned MAX_COMPACT_DEF = 8; -const unsigned MIN_DENSE_DEF = 6; +const int NAME_BUF_SIZE = 1024; +const unsigned MAX_COMPACT_DEF = 8; +const unsigned MIN_DENSE_DEF = 6; -static void test_attr_dense_create(FileCreatPropList& fcpl, - FileAccPropList& fapl) +static void +test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl) { // Output message about test being performed SUBTEST("Dense Attribute Storage Creation"); try { // Create file - H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + H5File fid1(FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); // Close file fid1.close(); // Get size of file - h5_stat_size_t empty_filesize; // Size of empty file + h5_stat_size_t empty_filesize; // Size of empty file empty_filesize = h5_get_file_size(FILE_CRTPROPS.c_str(), fapl.getId()); if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); @@ -1698,16 +1722,18 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // Retrieve limits for compact/dense attribute storage dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange", __LINE__, __FILE__); + verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange", __LINE__, __FILE__); // Set new compact/dense attribute storage limits to some random numbers dcpl.setAttrPhaseChange(7, 5); // Retrieve limits for compact/dense attribute storage and verify them dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, static_cast(7), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, static_cast(5), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(max_compact, static_cast(7), "DSetCreatPropList::getAttrPhaseChange", __LINE__, + __FILE__); + verify_val(min_dense, static_cast(5), "DSetCreatPropList::getAttrPhaseChange", __LINE__, + __FILE__); // Close property list dcpl.close(); @@ -1715,10 +1741,9 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // H5O__is_attr_dense_test - un-usable // Add attributes, until just before converting to dense storage - char attr_name[NAME_BUF_SIZE]; + char attr_name[NAME_BUF_SIZE]; unsigned attr_num; - for (attr_num = 0; attr_num < max_compact; attr_num++) - { + for (attr_num = 0; attr_num < max_compact; attr_num++) { // Create attribute sprintf(attr_name, "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); @@ -1740,28 +1765,27 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, } // Attempt to add attribute again, which should fail - try - { + try { // Create another attribute sprintf(attr_name, "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached"); + throw InvalidActionException("DataSet::createAttribute", + "Maximum number of attributes has been reached"); } - catch (AttributeIException& E) // catching invalid action - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid action + { + } // do nothing, exception expected PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_dense_create() +} // test_attr_dense_create() - /*------------------------------------------------------------------------- * Function: test_attr_corder_create_basic * @@ -1770,23 +1794,23 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, * Return None *------------------------------------------------------------------------- */ -static void test_attr_corder_create_basic(FileCreatPropList& fcpl, - FileAccPropList& fapl) +static void +test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl) { // Output message about test being performed SUBTEST("Basic Code for Attributes with Creation Order Info"); try { // Create file - H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + H5File fid1(FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); // Create dataset creation property list. DSetCreatPropList dcpl; // Get creation order indexing on object unsigned crt_order_flags = 0; - crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); // Setting invalid combination of a attribute order creation order // indexing on should fail @@ -1794,16 +1818,19 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, dcpl.setAttrCrtOrder(H5P_CRT_ORDER_INDEXED); // continuation here, that means no exception has been thrown - throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required"); + throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", + "Indexing cannot be set alone, order tracking is required"); } - catch (PropListIException& E) // catching invalid action - {} // do nothing, exception expected + catch (PropListIException &E) // catching invalid action + { + } // do nothing, exception expected // Set attribute creation order tracking & indexing for object then // verify them dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), + "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); // Create dataspace for dataset DataSpace ds_space(H5S_SCALAR); @@ -1838,18 +1865,17 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, // Query the attribute creation properties crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), + "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_corder_create_basic() +} // test_attr_corder_create_basic() - /*------------------------------------------------------------------------- * Function: test_attr * @@ -1858,14 +1884,13 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, * Return None *------------------------------------------------------------------------- */ -extern "C" -void test_attr() +extern "C" void +test_attr() { // Output message about test being performed MESSAGE(5, ("Testing Attributes\n")); - try - { + try { // Create a default file access property list FileAccPropList fapl; @@ -1887,45 +1912,41 @@ void test_attr() // Loop over using new group format unsigned new_format; - for (new_format = FALSE; new_format <= TRUE; new_format++) - { + for (new_format = FALSE; new_format <= TRUE; new_format++) { FileAccPropList curr_fapl; // Set the file access proplist for the type of format - if (new_format) - { + if (new_format) { MESSAGE(7, ("testing with new file format\n")); curr_fapl = fapl_new; } - else - { + else { MESSAGE(7, ("testing with old file format\n")); curr_fapl = fapl; } - test_attr_basic_write(); // Test basic H5A writing code - test_attr_getname(); // Test overloads of Attribute::getName - test_attr_rename(); // Test renaming attribute - test_attr_basic_read(); // Test basic H5A reading code + test_attr_basic_write(); // Test basic H5A writing code + test_attr_getname(); // Test overloads of Attribute::getName + test_attr_rename(); // Test renaming attribute + test_attr_basic_read(); // Test basic H5A reading code test_attr_compound_write(); // Test complex datatype H5A writing code test_attr_compound_read(); // Test complex datatype H5A reading code - test_attr_scalar_write(); // Test scalar dataspace H5A writing code - test_attr_scalar_read(); // Test scalar dataspace H5A reading code + test_attr_scalar_write(); // Test scalar dataspace H5A writing code + test_attr_scalar_read(); // Test scalar dataspace H5A reading code - test_attr_mult_write(); // Test writing multiple attributes - test_attr_mult_read(); // Test reading multiple attributes - test_attr_delete(); // Test deleting attributes + test_attr_mult_write(); // Test writing multiple attributes + test_attr_mult_read(); // Test reading multiple attributes + test_attr_delete(); // Test deleting attributes - test_attr_dtype_shared(); // Test using shared datatypes in attributes + test_attr_dtype_shared(); // Test using shared datatypes in attributes - test_string_attr(); // Test read/write string attribute - test_attr_exists(); // Test H5Location::attrExists + test_string_attr(); // Test read/write string attribute + test_attr_exists(); // Test H5Location::attrExists // Test with new format - if (new_format) - { + if (new_format) { // Test dense attribute storage creation test_attr_dense_create(fcpl, curr_fapl); @@ -1933,15 +1954,13 @@ void test_attr() test_attr_corder_create_basic(fcpl, curr_fapl); } } // end for - } // end try block + } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr() +} // test_attr() - /*------------------------------------------------------------------------- * Function: cleanup_attr * @@ -1950,8 +1969,8 @@ void test_attr() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_attr() +extern "C" void +cleanup_attr() { HDremove(FILE_BASIC.c_str()); HDremove(FILE_COMPOUND.c_str()); @@ -1960,4 +1979,3 @@ void cleanup_attr() HDremove(FILE_DTYPE.c_str()); HDremove(FILE_CRTPROPS.c_str()); } - diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index ec8adf0..7b48a78 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -25,21 +25,20 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file /* Number of elements in each test */ #define NTESTELEM 100000 typedef struct complex_t { - double re; - double im; + double re; + double im; } complex_t; - /*------------------------------------------------------------------------- * Function: test_compound_1 * @@ -51,7 +50,8 @@ typedef struct complex_t { * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_1() +static void +test_compound_1() { // Output message about test being performed SUBTEST("Compound Data Types"); @@ -63,15 +63,13 @@ static void test_compound_1() complex_type.insertMember("real", HOFFSET(complex_t, re), PredType::NATIVE_DOUBLE); complex_type.insertMember("imaginary", HOFFSET(complex_t, im), PredType::NATIVE_DOUBLE); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_1() +} // test_compound_1() - /*------------------------------------------------------------------------- * Function: test_compound_2 * @@ -85,7 +83,8 @@ static void test_compound_1() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_2() +static void +test_compound_2() { typedef struct { int a, b, c[4], d, e; @@ -94,33 +93,33 @@ static void test_compound_2() int e, d, c[4], b, a; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - const int nelmts = NTESTELEM; - const hsize_t four = 4; - int i; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + const int nelmts = NTESTELEM; + const hsize_t four = 4; + int i; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType *array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Reordering"); try { // Sizes should be the same, but be careful just in case - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; ia = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); // Build hdf5 datatypes array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -150,29 +149,22 @@ static void test_compound_2() st.convert(dt, (size_t)nelmts, buf, bkg); // Compare results - for (i=0; ia != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - } + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; } + } // Release resources HDfree(buf); HDfree(bkg); @@ -182,18 +174,16 @@ static void test_compound_2() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_2() +} // test_compound_2() - /*------------------------------------------------------------------------- * Function: test_compound_3 * @@ -207,42 +197,43 @@ static void test_compound_2() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_3() +static void +test_compound_3() { typedef struct { int a, b, c[4], d, e; } src_typ_t; typedef struct { - int a, c[4], e; + int a, c[4], e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - const hsize_t four = 4; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType* array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Datatype Subset Conversions"); try { /* Initialize */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; ia = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -270,27 +261,20 @@ static void test_compound_3() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; ia != d_ptr->a || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->e != d_ptr->e) { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] || + s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << ", c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << d_ptr->a - << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," - << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" - << d_ptr->e << "}" << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << ", c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << d_ptr->a << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," + << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" << d_ptr->e << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -301,18 +285,16 @@ static void test_compound_3() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_3() +} // test_compound_3() - /*------------------------------------------------------------------------- * Function: test_compound_4 * @@ -326,7 +308,8 @@ static void test_compound_3() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_4() +static void +test_compound_4() { typedef struct { @@ -335,38 +318,38 @@ static void test_compound_4() typedef struct { short b; - int a, c[4]; + int a, c[4]; short d; - int e; + int e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - const hsize_t four = 4; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType* array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Shrinking & Reordering"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; ia = i*8+0; - s_ptr->b = (i*8+1) & 0x7fff; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = (i*8+6) & 0x7fff; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = (i * 8 + 1) & 0x7fff; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = (i * 8 + 6) & 0x7fff; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -396,30 +379,22 @@ static void test_compound_4() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; ia != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) - { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b - << "c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," - << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" - << d_ptr->d << ", e=" << d_ptr->e << "}" << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b << "c=[" << d_ptr->c[0] << "," + << d_ptr->c[1] << "," << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" << d_ptr->d + << ", e=" << d_ptr->e << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -430,18 +405,16 @@ static void test_compound_4() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_4() +} // test_compound_4() - /*------------------------------------------------------------------------- * Function: test_compound_5 * @@ -456,27 +429,27 @@ static void test_compound_4() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_5() +static void +test_compound_5() { typedef struct { - char name[16]; - short tdim; - short coll_ids[4]; + char name[16]; + short tdim; + short coll_ids[4]; } src_typ_t; typedef struct { - char name[16]; - short tdim; - int coll_ids[4]; + char name[16]; + short tdim; + int coll_ids[4]; } dst_typ_t; - hsize_t dims[1] = {4}; - src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, - {"two", 202, {204, 205, 206, 207}}}; - dst_typ_t *dst; - void *buf = HDcalloc(2, sizeof(dst_typ_t)); - void *bkg = HDcalloc(2, sizeof(dst_typ_t)); - ArrayType* array_dt = NULL; + hsize_t dims[1] = {4}; + src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, {"two", 202, {204, 205, 206, 207}}}; + dst_typ_t *dst; + void * buf = HDcalloc(2, sizeof(dst_typ_t)); + void * bkg = HDcalloc(2, sizeof(dst_typ_t)); + ArrayType *array_dt = NULL; // Output message about test being performed SUBTEST("Optimized Struct Converter"); @@ -484,17 +457,17 @@ static void test_compound_5() /* Build datatypes */ array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); - CompType short_array(4*sizeof(short)); + CompType short_array(4 * sizeof(short)); short_array.insertMember("_", 0, *array_dt); array_dt->close(); delete array_dt; - CompType int_array(4*sizeof(int)); + CompType int_array(4 * sizeof(int)); array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims); int_array.insertMember("_", 0, *array_dt); array_dt->close(); - StrType strg(PredType::C_S1, 16); + StrType strg(PredType::C_S1, 16); CompType src_type(sizeof(src_typ_t)); src_type.insertMember("name", HOFFSET(src_typ_t, name), strg); src_type.insertMember("tdim", HOFFSET(src_typ_t, tdim), PredType::NATIVE_SHORT); @@ -508,7 +481,7 @@ static void test_compound_5() /* Convert data */ memcpy(buf, src, sizeof(src)); src_type.convert(dst_type, (size_t)2, buf, bkg); - dst = (dst_typ_t*)buf; + dst = (dst_typ_t *)buf; /* Cleanup */ src_type.close(); @@ -518,31 +491,27 @@ static void test_compound_5() int_array.close(); /* Check results */ - if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || - src[1].tdim!=dst[1].tdim || - src[1].coll_ids[0]!=dst[1].coll_ids[0] || - src[1].coll_ids[1]!=dst[1].coll_ids[1] || - src[1].coll_ids[2]!=dst[1].coll_ids[2] || - src[1].coll_ids[3]!=dst[1].coll_ids[3]) - { H5_FAILED(); } + if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || src[1].tdim != dst[1].tdim || + src[1].coll_ids[0] != dst[1].coll_ids[0] || src[1].coll_ids[1] != dst[1].coll_ids[1] || + src[1].coll_ids[2] != dst[1].coll_ids[2] || src[1].coll_ids[3] != dst[1].coll_ids[3]) { + H5_FAILED(); + } /* Free memory buffers */ HDfree(buf); HDfree(bkg); dst = NULL; PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_5() +} // test_compound_5() - /*------------------------------------------------------------------------- * Function: test_compound_6 * @@ -556,7 +525,8 @@ static void test_compound_5() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_6() +static void +test_compound_6() { typedef struct { short b; @@ -568,25 +538,25 @@ static void test_compound_6() long d; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; // Output message about test being performed SUBTEST("Compound Element Growing"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; ib = (i*8+1) & 0x7fff; - s_ptr->d = (i*8+6) & 0x7fff; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->b = (i * 8 + 1) & 0x7fff; + s_ptr->d = (i * 8 + 6) & 0x7fff; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ CompType st(sizeof(src_typ_t)); @@ -601,20 +571,16 @@ static void test_compound_6() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; ib != d_ptr->b || - s_ptr->d != d_ptr->d) - { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->b != d_ptr->b || s_ptr->d != d_ptr->d) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d - << "}" << endl; - cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d - << "}" << endl; + cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d << "}" << endl; + cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -625,15 +591,13 @@ static void test_compound_6() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_6() +} // test_compound_6() - /*------------------------------------------------------------------------- * Function: test_compound_7 * @@ -646,18 +610,19 @@ static void test_compound_6() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_7() +static void +test_compound_7() { typedef struct { - int a; + int a; float b; - long c; + long c; } s1_typ_t; typedef struct { - int a; - float b; - long c; + int a; + float b; + long c; double d; } s2_typ_t; @@ -666,9 +631,9 @@ static void test_compound_7() try { CompType tid1(sizeof(s1_typ_t)); - tid1.insertMember("a", HOFFSET(s1_typ_t,a),PredType::NATIVE_INT); - tid1.insertMember("b", HOFFSET(s1_typ_t,b),PredType::NATIVE_FLOAT); - tid1.insertMember("c", HOFFSET(s1_typ_t,c),PredType::NATIVE_LONG); + tid1.insertMember("a", HOFFSET(s1_typ_t, a), PredType::NATIVE_INT); + tid1.insertMember("b", HOFFSET(s1_typ_t, b), PredType::NATIVE_FLOAT); + tid1.insertMember("c", HOFFSET(s1_typ_t, c), PredType::NATIVE_LONG); size_t type_size = tid1.getSize(); verify_val(type_size, sizeof(s1_typ_t), "DataType::getSize", __LINE__, __FILE__); @@ -683,22 +648,23 @@ static void test_compound_7() try { tid2.insertMember("d", HOFFSET(s2_typ_t, d), PredType::NATIVE_DOUBLE); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("CompType::insertMember", "Attempted to insert field past end of compound data type."); - } catch (DataTypeIException& err) {} + throw InvalidActionException("CompType::insertMember", + "Attempted to insert field past end of compound data type."); + } + catch (DataTypeIException &err) { + } /* Release resources */ tid1.close(); tid2.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_7() +} // test_compound_7() - /*------------------------------------------------------------------------- * Function: test_compound_set_size * @@ -712,7 +678,8 @@ static void test_compound_7() */ const H5std_string COMPFILE("tcompound_types.h5"); -static void test_compound_set_size() +static void +test_compound_set_size() { typedef struct { int a, b, c[4], d, e; @@ -779,15 +746,13 @@ static void test_compound_set_size() file.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_set_size() +} // test_compound_set_size() - /*------------------------------------------------------------------------- * Function: test_compound * @@ -799,23 +764,22 @@ static void test_compound_set_size() * January 2007 *------------------------------------------------------------------------- */ -extern "C" -void test_compound() +extern "C" void +test_compound() { // Output message about test being performed MESSAGE(5, ("Testing Compound Data Type operations\n")); - test_compound_1(); // various things about compound data types - test_compound_2(); // compound element reordering - test_compound_3(); // compound datatype subset conversions - test_compound_4(); // compound element shrinking & reordering - test_compound_5(); // optimized struct converter - test_compound_6(); // compound element growing - test_compound_7(); // compound element insertion - test_compound_set_size(); // set size on compound data types -} // test_compound() - - + test_compound_1(); // various things about compound data types + test_compound_2(); // compound element reordering + test_compound_3(); // compound datatype subset conversions + test_compound_4(); // compound element shrinking & reordering + test_compound_5(); // optimized struct converter + test_compound_6(); // compound element growing + test_compound_7(); // compound element insertion + test_compound_set_size(); // set size on compound data types +} // test_compound() + /*------------------------------------------------------------------------- * Function: cleanup_compound * @@ -824,8 +788,8 @@ void test_compound() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_compound() +extern "C" void +cleanup_compound() { HDremove(COMPFILE.c_str()); -} // cleanup_file +} // cleanup_file diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp index 438f385..4cdf408 100644 --- a/c++/test/tdspl.cpp +++ b/c++/test/tdspl.cpp @@ -26,20 +26,21 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file const H5std_string FILENAME("tdatatransform.h5"); -static void test_transfplist() +static void +test_transfplist() { - const char* c_to_f = "(9/5.0)*x + 32"; - const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ + const char *c_to_f = "(9/5.0)*x + 32"; + const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ /* inverses the utrans transform in init_test to get back original array */ - const char* utrans_inv = "(x/3)*4 - 100"; + const char *utrans_inv = "(x/3)*4 - 100"; SUBTEST("DSetMemXferPropList::set/getDataTransform()"); try { @@ -63,12 +64,12 @@ static void test_transfplist() // Find out the length of the transform expression, allocate the buffer // for it, then read and verify the expression from the copied plist - ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); - char *c_to_f_read = (char *)HDmalloc(tran_len+1); - HDmemset(c_to_f_read, 0, tran_len+1); - dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len+1); - verify_val((const char*)c_to_f_read, (const char*)c_to_f, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); + char * c_to_f_read = (char *)HDmalloc(tran_len + 1); + HDmemset(c_to_f_read, 0, tran_len + 1); + dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len + 1); + verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform", + __LINE__, __FILE__); HDfree(c_to_f_read); // @@ -78,39 +79,37 @@ static void test_transfplist() // Get and verify the expression with: // ssize_t getDataTransform(char* exp, const size_t buf_size [default=0]) - tran_len = dxpl_c_to_f.getDataTransform(NULL); - c_to_f_read = (char *)HDmalloc(tran_len+1); - HDmemset(c_to_f_read, 0, tran_len+1); - dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len+1); - verify_val((const char*)c_to_f_read, (const char*)c_to_f, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + tran_len = dxpl_c_to_f.getDataTransform(NULL); + c_to_f_read = (char *)HDmalloc(tran_len + 1); + HDmemset(c_to_f_read, 0, tran_len + 1); + dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len + 1); + verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform", + __LINE__, __FILE__); HDfree(c_to_f_read); // Get and verify the expression with: // H5std_string DSetMemXferPropList::getDataTransform() H5std_string simple_read = dxpl_simple.getDataTransform(); - verify_val((const char*)simple_read.c_str(), (const char*)simple, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + verify_val((const char *)simple_read.c_str(), (const char *)simple, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); // Get and verify the expression with: // ssize_t getDataTransform(char* exp, const size_t buf_size) - tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); - char *utrans_inv_read = (char *)HDmalloc(tran_len+1); - HDmemset(utrans_inv_read, 0, tran_len+1); - dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len+1); - verify_val((const char*)utrans_inv_read, (const char*)utrans_inv, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); + char *utrans_inv_read = (char *)HDmalloc(tran_len + 1); + HDmemset(utrans_inv_read, 0, tran_len + 1); + dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len + 1); + verify_val((const char *)utrans_inv_read, (const char *)utrans_inv, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); HDfree(utrans_inv_read); PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_dsproplist * @@ -119,17 +118,16 @@ static void test_transfplist() * Return None *------------------------------------------------------------------------- */ -extern "C" -void test_dsproplist() +extern "C" void +test_dsproplist() { // Output message about test being performed MESSAGE(5, ("Testing Generic Dataset Property Lists\n")); test_transfplist(); // test set/getDataTransform() -} // test_dsproplist() +} // test_dsproplist() - /*------------------------------------------------------------------------- * Function: cleanup_dsproplist * @@ -138,8 +136,8 @@ void test_dsproplist() * Return none *------------------------------------------------------------------------- */ -extern "C" -void cleanup_dsproplist() +extern "C" void +cleanup_dsproplist() { HDremove(FILENAME.c_str()); } diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index a2a0867..a38d36d 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -47,17 +47,16 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file int main(int argc, char *argv[]) { - try - { + try { // Turn of the auto-printing when failure occurs so that we can // handle the errors appropriately since sometime failures are // caused deliberately and expected. @@ -70,39 +69,38 @@ main(int argc, char *argv[]) // testing dataset functionalities in dset.cpp AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL); // testing dataspace functionalities in th5s.cpp - AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); + AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); // testing attribute functionalities in tattr.cpp - AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL); + AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL); // testing object functionalities in tobject.cpp - AddTest("tobject", test_object, cleanup_object, "Objects", NULL); + AddTest("tobject", test_object, cleanup_object, "Objects", NULL); // testing reference functionalities in trefer.cpp - AddTest("trefer", test_reference, cleanup_reference, "References", NULL); + AddTest("trefer", test_reference, cleanup_reference, "References", NULL); // testing variable-length strings in tvlstr.cpp - AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); - AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); - AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL); - AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); - AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); - AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); - AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); -/* Comment out tests that are not done yet. - BMR, Feb 2001 - AddTest("select", test_select, cleanup_select, "Selections", NULL); - AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); - AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); -*/ - AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); -/* - AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); - AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); - -Comment out tests that are not done yet */ - -/* Tentative - BMR 2007/1/12 - AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); -*/ + AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); + AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); + AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL); + AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); + AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); + AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); + AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); + /* Comment out tests that are not done yet. - BMR, Feb 2001 + AddTest("select", test_select, cleanup_select, "Selections", NULL); + AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); + AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); + */ + AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); + /* + AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); + AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); + + Comment out tests that are not done yet */ + + /* Tentative - BMR 2007/1/12 + AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); + */ } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -110,7 +108,7 @@ Comment out tests that are not done yet */ TestInfo(argv[0]); /* Parse command line arguments */ - TestParseCmdLine(argc,argv); + TestParseCmdLine(argc, argv); /* Perform requested testing */ PerformTests(); @@ -128,4 +126,3 @@ Comment out tests that are not done yet */ return (GetTestNumErrs()); } - diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index f5625a3..b4e5da5 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -29,38 +29,37 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file - -const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; -const size_t F1_OFFSET_SIZE = sizeof(haddr_t); -const size_t F1_LENGTH_SIZE = sizeof(hsize_t); -const unsigned F1_SYM_LEAF_K = 4; -const unsigned F1_SYM_INTERN_K = 16; -const H5std_string FILE1("tfile1.h5"); - -const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; -const size_t F2_OFFSET_SIZE = 8; -const size_t F2_LENGTH_SIZE = 8; -const unsigned F2_SYM_LEAF_K = 8; -const unsigned F2_SYM_INTERN_K = 32; -const unsigned F2_ISTORE = 64; -const H5std_string FILE2("tfile2.h5"); - -const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; -const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; -const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; -const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; -const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K; -const H5std_string FILE3("tfile3.h5"); - -const int KB = 1024; -const H5std_string FILE4("tfile4.h5"); - - +#include "h5cpputil.h" // C++ utilility header file + +const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; +const size_t F1_OFFSET_SIZE = sizeof(haddr_t); +const size_t F1_LENGTH_SIZE = sizeof(hsize_t); +const unsigned F1_SYM_LEAF_K = 4; +const unsigned F1_SYM_INTERN_K = 16; +const H5std_string FILE1("tfile1.h5"); + +const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; +const size_t F2_OFFSET_SIZE = 8; +const size_t F2_LENGTH_SIZE = 8; +const unsigned F2_SYM_LEAF_K = 8; +const unsigned F2_SYM_INTERN_K = 32; +const unsigned F2_ISTORE = 64; +const H5std_string FILE2("tfile2.h5"); + +const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; +const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; +const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; +const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; +const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K; +const H5std_string FILE3("tfile3.h5"); + +const int KB = 1024; +const H5std_string FILE4("tfile4.h5"); + /*------------------------------------------------------------------------- * Function: test_file_create * @@ -80,7 +79,8 @@ const H5std_string FILE4("tfile4.h5"); * with a special routine. *------------------------------------------------------------------------- */ -static void test_file_create() +static void +test_file_create() { // Output message about test being performed SUBTEST("File Creation I/O"); @@ -93,21 +93,22 @@ static void test_file_create() remove(FILE1.c_str()); // Setting this to NULL for cleaning up in failure situations - H5File* file1 = NULL; + H5File *file1 = NULL; try { // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_EXCL); + file1 = new H5File(FILE1, H5F_ACC_EXCL); // Try to create the same file with H5F_ACC_TRUNC. This should fail // because file1 is the same file and is currently open. try { - H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + H5File file2(FILE1, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempted to create an existing file."); } - catch (FileIException& E) // catch truncating existing file - {} // do nothing, FAIL expected + catch (FileIException &E) // catch truncating existing file + { + } // do nothing, FAIL expected // Close file1 delete file1; @@ -116,52 +117,56 @@ static void test_file_create() // Try again with H5F_ACC_EXCL. This should fail because the file // already exists from the previous steps. try { - H5File file2(FILE1, H5F_ACC_EXCL); // should throw E + H5File file2(FILE1, H5F_ACC_EXCL); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "File already exists."); } - catch (FileIException& E) // catching creating existing file - {} // do nothing, FAIL expected + catch (FileIException &E) // catching creating existing file + { + } // do nothing, FAIL expected - // Test create with H5F_ACC_TRUNC. This will truncate the existing file. - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + // Test create with H5F_ACC_TRUNC. This will truncate the existing file. + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Try to create first file again. This should fail because file1 // is the same file and is currently open. - try { - H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + try { + H5File file2(FILE1, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_TRUNC attempt on an opened file."); } - catch (FileIException& E) // catching truncating opened file - {} // do nothing, FAIL expected + catch (FileIException &E) // catching truncating opened file + { + } // do nothing, FAIL expected - // Try with H5F_ACC_EXCL. This should fail too because the file already - // exists. - try { - H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E + // Try with H5F_ACC_EXCL. This should fail too because the file already + // exists. + try { + H5File file3(FILE1, H5F_ACC_EXCL); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file."); - } - catch (FileIException& E) // catching H5F_ACC_EXCL on existing file - {} // do nothing, FAIL expected + } + catch (FileIException &E) // catching H5F_ACC_EXCL on existing file + { + } // do nothing, FAIL expected - // Get the file-creation template + // Get the file-creation template FileCreatPropList tmpl1 = file1->getCreatePlist(); hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1.getSizes( parm1, parm2); + size_t parm1, parm2; // file-creation parameters + tmpl1.getSizes(parm1, parm2); verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1.getSymk( iparm1, iparm2); + unsigned iparm1, iparm2; // file-creation parameters + tmpl1.getSymk(iparm1, iparm2); verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -171,85 +176,84 @@ static void test_file_create() // Close first file delete file1; } - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " *FAILED*" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; if (file1 != NULL) // clean up delete file1; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); if (file1 != NULL) // clean up delete file1; } // Setting this to NULL for cleaning up in failure situations - FileCreatPropList* tmpl1 = NULL; - try - { - // Create a new file with a non-standard file-creation template + FileCreatPropList *tmpl1 = NULL; + try { + // Create a new file with a non-standard file-creation template tmpl1 = new FileCreatPropList; - // Set the new file-creation parameters - tmpl1->setUserblock (F2_USERBLOCK_SIZE); - tmpl1->setSizes( F2_OFFSET_SIZE, F2_LENGTH_SIZE ); - tmpl1->setSymk( F2_SYM_INTERN_K, F2_SYM_LEAF_K ); + // Set the new file-creation parameters + tmpl1->setUserblock(F2_USERBLOCK_SIZE); + tmpl1->setSizes(F2_OFFSET_SIZE, F2_LENGTH_SIZE); + tmpl1->setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); - // Try to create second file, with non-standard file-creation template - // params. - H5File file2( FILE2, H5F_ACC_TRUNC, *tmpl1 ); + // Try to create second file, with non-standard file-creation template + // params. + H5File file2(FILE2, H5F_ACC_TRUNC, *tmpl1); - // Release file-creation template + // Release file-creation template delete tmpl1; tmpl1 = NULL; // Get the file-creation template - tmpl1 = new FileCreatPropList (file2.getCreatePlist()); + tmpl1 = new FileCreatPropList(file2.getCreatePlist()); // Get the file-creation parameters hsize_t ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); size_t parm1, parm2; // file-creation parameters - tmpl1->getSizes( parm1, parm2); + tmpl1->getSizes(parm1, parm2); verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1->getSymk( iparm1, iparm2); + unsigned iparm1, iparm2; // file-creation parameters + tmpl1->getSymk(iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); // Clone the file-creation template FileCreatPropList tmpl2; - tmpl2.copy (*tmpl1); + tmpl2.copy(*tmpl1); // Release file-creation template delete tmpl1; tmpl1 = NULL; // Set the new file-creation parameter - tmpl2.setUserblock( F3_USERBLOCK_SIZE ); + tmpl2.setUserblock(F3_USERBLOCK_SIZE); // Try to create second file, with non-standard file-creation template // params - H5File file3( FILE3, H5F_ACC_TRUNC, tmpl2 ); + H5File file3(FILE3, H5F_ACC_TRUNC, tmpl2); // Get the file-creation template - tmpl1 = new FileCreatPropList (file3.getCreatePlist()); + tmpl1 = new FileCreatPropList(file3.getCreatePlist()); // Get the file-creation parameters ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - tmpl1->getSizes( parm1, parm2); + tmpl1->getSizes(parm1, parm2); verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - tmpl1->getSymk( iparm1, iparm2); + tmpl1->getSymk(iparm1, iparm2); verify_val(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -258,15 +262,13 @@ static void test_file_create() PASSED(); } // catch all exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); - if (tmpl1 != NULL) // clean up + if (tmpl1 != NULL) // clean up delete tmpl1; } -} // test_file_create() +} // test_file_create() - /*------------------------------------------------------------------------- * Function: test_file_open * @@ -286,7 +288,8 @@ static void test_file_create() * with a special routine. *------------------------------------------------------------------------- */ -static void test_file_open() +static void +test_file_open() { // Output message about test being performed SUBTEST("File Opening I/O"); @@ -294,22 +297,23 @@ static void test_file_open() try { // Open first file - H5File file1 (FILE2, H5F_ACC_RDWR ); + H5File file1(FILE2, H5F_ACC_RDWR); // Get the file-creation template FileCreatPropList tmpl1 = file1.getCreatePlist(); // Get the file-creation parameters hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1.getSizes( parm1, parm2); + size_t parm1, parm2; // file-creation parameters + tmpl1.getSizes(parm1, parm2); verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1.getSymk( iparm1, iparm2); + unsigned iparm1, iparm2; // file-creation parameters + tmpl1.getSymk(iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -319,14 +323,15 @@ static void test_file_open() // Try truncating the file, and it should fail because the file is // still opened with file2. - try { - H5File file3 (FILE2, H5F_ACC_TRUNC); // should throw E + try { + H5File file3(FILE2, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempt truncating an opened file."); - } - catch (FileIException& E) // catching H5F_ACC_TRUNC on opened file - {} // do nothing, FAIL expected + } + catch (FileIException &E) // catching H5F_ACC_TRUNC on opened file + { + } // do nothing, FAIL expected // Now, really close the file. file2.close(); @@ -340,15 +345,13 @@ static void test_file_open() H5File file4(FILE2, H5F_ACC_TRUNC); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_open()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_open() +} // test_file_open() - /*------------------------------------------------------------------------- * Function: test_file_size * @@ -360,12 +363,13 @@ static void test_file_open() * June, 2004 *------------------------------------------------------------------------- */ -static void test_file_size() +static void +test_file_size() { // Output message about test being performed SUBTEST("File Size"); - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template try { @@ -373,33 +377,34 @@ static void test_file_size() // list object to pass in H5File::H5File FileAccPropList fapl(fapl_id); - // Set to sec2 driver. Do we want to test other file drivers? + // Set to sec2 driver. Do we want to test other file drivers? // They're not tested in C++. // File drivers seem not implemented. // fapl.setSec2(); // Create a file - H5File file4( FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + H5File file4(FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Get file size hsize_t file_size = file4.getFileSize(); // Check if file size is reasonable. It's supposed to be 2KB now. - if (file_size < 1*KB || file_size > 4*KB) - issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFileSize() returned unreasonable value"); + if (file_size < 1 * KB || file_size > 4 * KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, + "getFileSize() returned unreasonable value"); // Get the amount of free space in the file hssize_t free_space = file4.getFreeSpace(); // Check if it's reasonable. It's 0 now. - if (free_space < 0 || free_space > 4*KB) - issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFreeSpace returned unreasonable value"); + if (free_space < 0 || free_space > 4 * KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, + "getFreeSpace returned unreasonable value"); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_size()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -408,9 +413,8 @@ static void test_file_size() if (ret < 0) issue_fail_msg("test_file_size()", __LINE__, __FILE__, "H5Pclose failed"); -} // test_file_size() +} // test_file_size() - /*------------------------------------------------------------------------- * Function: test_file_num * @@ -422,12 +426,13 @@ static void test_file_size() * April, 2019 *------------------------------------------------------------------------- */ -static void test_file_num() +static void +test_file_num() { // Output message about test being performed SUBTEST("File Number"); - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template try { @@ -454,10 +459,9 @@ static void test_file_num() issue_fail_msg("test_file_num()", __LINE__, __FILE__, "getFileNum() returned wrong value"); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_num()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -466,9 +470,8 @@ static void test_file_num() if (ret < 0) issue_fail_msg("test_file_num()", __LINE__, __FILE__, "H5Pclose failed"); -} // test_file_num() +} // test_file_num() - /*------------------------------------------------------------------------- * Function: test_file_name * @@ -480,14 +483,14 @@ static void test_file_num() * July, 2004 *------------------------------------------------------------------------- */ -const int RANK = 2; -const int NX = 4; -const int NY = 5; -const H5std_string GROUPNAME ("group"); -const H5std_string DSETNAME ("dataset"); -const H5std_string DATTRNAME ("dataset attribute"); -const H5std_string FATTRNAME ("file attribute"); -const H5std_string DTYPENAME ("compound"); +const int RANK = 2; +const int NX = 4; +const int NY = 5; +const H5std_string GROUPNAME("group"); +const H5std_string DSETNAME("dataset"); +const H5std_string DATTRNAME("dataset attribute"); +const H5std_string FATTRNAME("file attribute"); +const H5std_string DTYPENAME("compound"); // Compound datatype typedef struct s1_t { @@ -495,7 +498,8 @@ typedef struct s1_t { float b; } s1_t; -static void test_file_name() +static void +test_file_name() { // Output message about test being performed. SUBTEST("File Name"); @@ -517,11 +521,11 @@ static void test_file_name() verify_val(file_name, FILE4, "Group::getFileName", __LINE__, __FILE__); // Create the data space. - hsize_t dims[RANK] = {NX, NY}; + hsize_t dims[RANK] = {NX, NY}; DataSpace space(RANK, dims); // Create a new dataset. - DataSet dataset(file4.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(file4.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Get and verify file name via a dataset. file_name = dataset.getFileName(); @@ -535,7 +539,7 @@ static void test_file_name() verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); // Create a compound datatype. - CompType comp_type (sizeof(s1_t)); + CompType comp_type(sizeof(s1_t)); // Insert fields. comp_type.insertMember("a", HOFFSET(s1_t, a), PredType::NATIVE_INT); @@ -548,15 +552,13 @@ static void test_file_name() comp_type.getFileName(); verify_val(file_name, FILE4, "CompType::getFileName", __LINE__, __FILE__); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_name() +} // test_file_name() - /*------------------------------------------------------------------------- * * Function: test_file_attribute @@ -566,15 +568,16 @@ static void test_file_name() * Return None *------------------------------------------------------------------------- */ -const int RANK1 = 1; -const int ATTR1_DIM1 = 3; -const H5std_string FILE5("tfattrs.h5"); -const H5std_string FATTR1_NAME ("file attribute 1"); -const H5std_string FATTR2_NAME ("file attribute 2"); -int fattr_data[ATTR1_DIM1]={512,-234,98123}; // Test data for file attribute -int dattr_data[ATTR1_DIM1]={256,-123,1000}; // Test data for dataset attribute - -static void test_file_attribute() +const int RANK1 = 1; +const int ATTR1_DIM1 = 3; +const H5std_string FILE5("tfattrs.h5"); +const H5std_string FATTR1_NAME("file attribute 1"); +const H5std_string FATTR2_NAME("file attribute 2"); +int fattr_data[ATTR1_DIM1] = {512, -234, 98123}; // Test data for file attribute +int dattr_data[ATTR1_DIM1] = {256, -123, 1000}; // Test data for dataset attribute + +static void +test_file_attribute() { int rdata[ATTR1_DIM1]; int i; @@ -588,7 +591,7 @@ static void test_file_attribute() H5File file5(FILE5, H5F_ACC_TRUNC); // Create the data space - hsize_t dims[RANK1] = {ATTR1_DIM1}; + hsize_t dims[RANK1] = {ATTR1_DIM1}; DataSpace space(RANK1, dims); // Create two attributes for the file @@ -601,13 +604,15 @@ static void test_file_attribute() // Try to create the same attribute again (should fail) Attribute fattr_dup(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space)); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute."); + throw InvalidActionException("H5File createAttribute", + "Attempted to create an existing attribute."); } - catch (AttributeIException& E) // catch creating existing attribute - {} // do nothing, FAIL expected + catch (AttributeIException &E) // catch creating existing attribute + { + } // do nothing, FAIL expected // Create a new dataset - DataSet dataset(file5.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(file5.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Create an attribute for the dataset Attribute dattr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); @@ -663,20 +668,18 @@ static void test_file_attribute() if (rdata[i] != dattr_data[i]) { H5_FAILED(); cerr << endl; - cerr << "element [" << i << "] is " << rdata[i] << - "but should have been " << dattr_data[i] << endl; - } + cerr << "element [" << i << "] is " << rdata[i] << "but should have been " << dattr_data[i] + << endl; } + } PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_attribute() +} // test_file_attribute() - /*------------------------------------------------------------------------- * Function: test_libver_bounds_real * @@ -690,94 +693,92 @@ static void test_file_attribute() * March, 2015 *------------------------------------------------------------------------- */ -const H5std_string FILE6("tfile5.h5"); -const H5std_string ROOTGROUP("/"); -const H5std_string GROUP1("/G1"); -const H5std_string SUBGROUP3("/G1/G3"); - -static void test_libver_bounds_real( - H5F_libver_t libver_create, unsigned oh_vers_create, - H5F_libver_t libver_mod, unsigned oh_vers_mod) +const H5std_string FILE6("tfile5.h5"); +const H5std_string ROOTGROUP("/"); +const H5std_string GROUP1("/G1"); +const H5std_string SUBGROUP3("/G1/G3"); + +static void +test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, H5F_libver_t libver_mod, + unsigned oh_vers_mod) { try { - /* - * Create a new file using the default creation property and access property - * with latest library version. - */ - FileAccPropList fapl; - fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST); - H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + /* + * Create a new file using the default creation property and access property + * with latest library version. + */ + FileAccPropList fapl; + fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST); + H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); - /* - * Make sure the root group has the correct object header version - */ - unsigned obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - - // Verify object header version another way - H5O_native_info_t ninfo; - HDmemset(&ninfo, 0, sizeof(ninfo)); - file.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR); - verify_val(ninfo.hdr.version, oh_vers_create, "H5File::getNativeObjinfo", __LINE__, __FILE__); - - /* - * Reopen the file and make sure the root group still has the correct - * version - */ - file.close(); + /* + * Make sure the root group has the correct object header version + */ + unsigned obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST); + // Verify object header version another way + H5O_native_info_t ninfo; + HDmemset(&ninfo, 0, sizeof(ninfo)); + file.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR); + verify_val(ninfo.hdr.version, oh_vers_create, "H5File::getNativeObjinfo", __LINE__, __FILE__); - file.openFile(FILE6, H5F_ACC_RDWR, fapl); + /* + * Reopen the file and make sure the root group still has the correct + * version + */ + file.close(); - obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST); - /* - * Create a group named "/G1" in the file, and make sure it has the correct - * object header version - */ - Group group = file.createGroup(GROUP1); + file.openFile(FILE6, H5F_ACC_RDWR, fapl); - obj_version = group.objVersion(); - verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); + obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - // Verify object header version another way - HDmemset(&ninfo, 0, sizeof(ninfo)); - group.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR); - verify_val(ninfo.hdr.version, oh_vers_mod, "Group::getNativeObjinfo", __LINE__, __FILE__); + /* + * Create a group named "/G1" in the file, and make sure it has the correct + * object header version + */ + Group group = file.createGroup(GROUP1); - group.close(); // close "/G1" + obj_version = group.objVersion(); + verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); - /* - * Create a group named "/G1/G3" in the file, and make sure it has the - * correct object header version - */ - group = file.createGroup(SUBGROUP3); + // Verify object header version another way + HDmemset(&ninfo, 0, sizeof(ninfo)); + group.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR); + verify_val(ninfo.hdr.version, oh_vers_mod, "Group::getNativeObjinfo", __LINE__, __FILE__); - obj_version = group.objVersion(); - verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); + group.close(); // close "/G1" - group.close(); // close "/G1/G3" + /* + * Create a group named "/G1/G3" in the file, and make sure it has the + * correct object header version + */ + group = file.createGroup(SUBGROUP3); - /* - * Make sure the root group still has the correct object header version - */ - obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + obj_version = group.objVersion(); + verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); - // Everything should be closed as they go out of scope - } // end of try block + group.close(); // close "/G1/G3" - catch (Exception& E) - { + /* + * Make sure the root group still has the correct object header version + */ + obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + + // Everything should be closed as they go out of scope + } // end of try block + + catch (Exception &E) { issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg()); } } /* end test_libver_bounds_real() */ - /*------------------------------------------------------------------------- * * Function: test_libver_bounds @@ -791,7 +792,8 @@ static void test_libver_bounds_real( * March 2015 *------------------------------------------------------------------------- */ -static void test_libver_bounds() +static void +test_libver_bounds() { // Output message about test being performed SUBTEST("Setting library version bounds"); @@ -802,7 +804,6 @@ static void test_libver_bounds() PASSED(); } /* end test_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: test_commonfg * @@ -814,7 +815,8 @@ static void test_libver_bounds() * March, 2015 *------------------------------------------------------------------------- */ -static void test_commonfg() +static void +test_commonfg() { // Output message about test being performed SUBTEST("Root group"); @@ -830,11 +832,11 @@ static void test_commonfg() Group group(rootgroup.createGroup(GROUPNAME, 0)); // Create the data space. - hsize_t dims[RANK] = {NX, NY}; + hsize_t dims[RANK] = {NX, NY}; DataSpace space(RANK, dims); // Create a new dataset. - DataSet dataset(group.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(group.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Get and verify file name via a dataset. H5std_string file_name = dataset.getFileName(); @@ -855,16 +857,14 @@ static void test_commonfg() verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_commonfg()", __LINE__, __FILE__, E.getCDetailMsg()); } } /* end test_commonfg() */ - /*------------------------------------------------------------------------- * Function: test_file_info * @@ -879,16 +879,17 @@ static void test_commonfg() *------------------------------------------------------------------------- */ const H5std_string FILE7("tfile7.h5"); -const hsize_t FSP_SIZE_DEF = 4096; -const hsize_t FSP_SIZE512 = 512; +const hsize_t FSP_SIZE_DEF = 4096; +const hsize_t FSP_SIZE512 = 512; -static void test_file_info() +static void +test_file_info() { // Output message about test being performed SUBTEST("File general information"); - hsize_t out_threshold = 0; // Free space section threshold to get - hbool_t out_persist = FALSE;// Persist free-space read + hsize_t out_threshold = 0; // Free space section threshold to get + hbool_t out_persist = FALSE; // Persist free-space read // File space handling strategy H5F_fspace_strategy_t out_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; @@ -919,7 +920,8 @@ static void test_file_info() /* Retrieve file space page size */ hsize_t out_fsp_psize = fcpl.getFileSpacePagesize(); - verify_val(out_fsp_psize, FSP_SIZE_DEF, "FileCreatPropList::getFileSpacePagesize", __LINE__, __FILE__); + verify_val(out_fsp_psize, FSP_SIZE_DEF, "FileCreatPropList::getFileSpacePagesize", __LINE__, + __FILE__); // Set various file information. fcpl.setUserblock(F2_USERBLOCK_SIZE); @@ -927,9 +929,9 @@ static void test_file_info() fcpl.setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); fcpl.setIstorek(F2_ISTORE); - hsize_t threshold = 5; // Free space section threshold to set - hbool_t persist = TRUE; // Persist free-space to set - H5F_fspace_strategy_t strategy = H5F_FSPACE_STRATEGY_PAGE; + hsize_t threshold = 5; // Free space section threshold to set + hbool_t persist = TRUE; // Persist free-space to set + H5F_fspace_strategy_t strategy = H5F_FSPACE_STRATEGY_PAGE; fcpl.setFileSpaceStrategy(strategy, persist, threshold); fcpl.setFileSpacePagesize(FSP_SIZE512); @@ -981,10 +983,10 @@ static void test_file_info() unsigned istore_ik = fcpl2.getIstorek(); verify_val(istore_ik, F2_ISTORE, "FileCreatPropList::getIstorek", __LINE__, __FILE__); - /* ret=H5Pget_shared_mesg_nindexes(fcpl2,&nindexes); - CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes"); - VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); - */ + /* ret=H5Pget_shared_mesg_nindexes(fcpl2,&nindexes); + CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes"); + VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); + */ // Get and verify the file space info from the creation property list */ fcpl2.getFileSpaceStrategy(out_strategy, out_persist, out_threshold); @@ -996,14 +998,12 @@ static void test_file_info() verify_val(out_fsp_psize, FSP_SIZE512, "FileCreatPropList::getFileSpacePagesize", __LINE__, __FILE__); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_filespace_info()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_file_info() */ +} /* test_file_info() */ - /*------------------------------------------------------------------------- * Function: test_file * @@ -1015,24 +1015,23 @@ static void test_file_info() * January 2001 *------------------------------------------------------------------------- */ -extern "C" -void test_file() +extern "C" void +test_file() { // Output message about test being performed MESSAGE(5, ("Testing File I/O Operations\n")); - test_file_create(); // Test file creation (also creation templates) - test_file_open(); // Test file opening - test_file_size(); // Test file size - test_file_num(); // Test file number - test_file_name(); // Test getting file's name - test_file_attribute(); // Test file attribute feature - test_libver_bounds(); // Test format version - test_commonfg(); // Test H5File as a root group - test_file_info(); // Test various file info -} // test_file() - - + test_file_create(); // Test file creation (also creation templates) + test_file_open(); // Test file opening + test_file_size(); // Test file size + test_file_num(); // Test file number + test_file_name(); // Test getting file's name + test_file_attribute(); // Test file attribute feature + test_libver_bounds(); // Test format version + test_commonfg(); // Test H5File as a root group + test_file_info(); // Test various file info +} // test_file() + /*------------------------------------------------------------------------- * Function: cleanup_file * @@ -1044,7 +1043,8 @@ void test_file() #ifdef __cplusplus extern "C" #endif -void cleanup_file() + void + cleanup_file() { HDremove(FILE1.c_str()); HDremove(FILE2.c_str()); @@ -1053,4 +1053,4 @@ void cleanup_file() HDremove(FILE5.c_str()); HDremove(FILE6.c_str()); HDremove(FILE7.c_str()); -} // cleanup_file +} // cleanup_file diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index 5a493ac..e7788e5 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -25,14 +25,14 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -#define DSET_DIM1 100 -#define DSET_DIM2 200 +#define DSET_DIM1 100 +#define DSET_DIM2 200 #define FILTER_CHUNK_DIM1 2 #define FILTER_CHUNK_DIM2 25 @@ -56,16 +56,15 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, static size_t filter_bogus(size_t nbytes); /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)filter_bogus, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)filter_bogus, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: filter_bogus * @@ -90,7 +89,6 @@ filter_bogus(size_t nbytes) return nbytes; } - /*------------------------------------------------------------------------- * Function: test_null_filter * @@ -107,25 +105,26 @@ filter_bogus(size_t nbytes) */ const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; -static void test_null_filter() +static void +test_null_filter() { // Output message about test being performed SUBTEST("'Null' filter"); try { - //hsize_t null_size; // Size of dataset with null filter + // hsize_t null_size; // Size of dataset with null filter // Prepare dataset create property list DSetCreatPropList dsplist; dsplist.setChunk(2, chunk_size); - if (H5Zregister (H5Z_BOGUS)<0) + if (H5Zregister(H5Z_BOGUS) < 0) throw Exception("test_null_filter", "H5Zregister failed"); // Set some pretent filter dsplist.setFilter(H5Z_FILTER_BOGUS); // this function is just a stub right now; will work on it later - BMR - //if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0) + // if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0) // throw Exception("test_null_filter", "test_filter_internal failed"); // Close objects. @@ -134,13 +133,11 @@ static void test_null_filter() } // end of try // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_null_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_null_filter +} // test_null_filter - /*------------------------------------------------------------------------- * Function: test_szip_filter * @@ -157,28 +154,29 @@ static void test_null_filter() */ const H5std_string DSET_SZIP_NAME("szipped dataset"); -static void test_szip_filter(H5File& file1) +static void +test_szip_filter(H5File &file1) { #ifdef H5_HAVE_FILTER_SZIP int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2]; - unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block=4; + unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block = 4; // Output message about test being performed SUBTEST("szip filter (with encoder)"); - if ( h5_szip_can_encode() == 1) { - char* tconv_buf = new char [1000]; + if (h5_szip_can_encode() == 1) { + char *tconv_buf = new char[1000]; try { - const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; + const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; // Create the data space DataSpace space1(2, size, NULL); // Create a small conversion buffer to test strip mining (?) DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Prepare dataset create property list DSetCreatPropList dsplist; @@ -188,27 +186,24 @@ static void test_szip_filter(H5File& file1) dsplist.setSzip(szip_options_mask, szip_pixels_per_block); // Create a dataset with szip compression - DataSpace space2 (2, size, NULL); - DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist)); + DataSpace space2(2, size, NULL); + DataSet dataset(file1.createDataSet(DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist)); hsize_t i, j, n; - for (i=n=0; i -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file -#include "H5srcdir.h" // srcdir querying header file +#include "h5cpputil.h" // C++ utilility header file +#include "H5srcdir.h" // srcdir querying header file -const H5std_string TESTFILE("th5s.h5"); -const H5std_string DATAFILE("th5s1.h5"); +const H5std_string TESTFILE("th5s.h5"); +const H5std_string DATAFILE("th5s1.h5"); /* 3-D dataset with fixed dimensions */ const H5std_string SPACE1_NAME("Space1"); -const int SPACE1_RANK = 3; -const int SPACE1_DIM1 = 3; -const int SPACE1_DIM2 = 15; -const int SPACE1_DIM3 = 13; +const int SPACE1_RANK = 3; +const int SPACE1_DIM1 = 3; +const int SPACE1_DIM2 = 15; +const int SPACE1_DIM3 = 13; /* 4-D dataset with one unlimited dimension */ const H5std_string SPACE2_NAME("Space2"); -const int SPACE2_RANK = 4; -const int SPACE2_DIM1 = 0; -const int SPACE2_DIM2 = 15; -const int SPACE2_DIM3 = 13; -const int SPACE2_DIM4 = 23; -const hsize_t SPACE2_MAX1 = H5S_UNLIMITED; -const hsize_t SPACE2_MAX2 = 15; -const hsize_t SPACE2_MAX3 = 13; -const hsize_t SPACE2_MAX4 = 23; +const int SPACE2_RANK = 4; +const int SPACE2_DIM1 = 0; +const int SPACE2_DIM2 = 15; +const int SPACE2_DIM3 = 13; +const int SPACE2_DIM4 = 23; +const hsize_t SPACE2_MAX1 = H5S_UNLIMITED; +const hsize_t SPACE2_MAX2 = 15; +const hsize_t SPACE2_MAX3 = 13; +const hsize_t SPACE2_MAX4 = 23; /* Scalar dataset with simple datatype */ const H5std_string SPACE3_NAME("Scalar1"); -const int SPACE3_RANK = 0; -unsigned space3_data=65; +const int SPACE3_RANK = 0; +unsigned space3_data = 65; /* Scalar dataset with compound datatype */ const H5std_string SPACE4_NAME("Scalar2"); @@ -68,21 +68,20 @@ const H5std_string SPACE4_FIELDNAME1("c1"); const H5std_string SPACE4_FIELDNAME2("u"); const H5std_string SPACE4_FIELDNAME3("f"); const H5std_string SPACE4_FIELDNAME4("c2"); -size_t space4_field1_off=0; -size_t space4_field2_off=0; -size_t space4_field3_off=0; -size_t space4_field4_off=0; +size_t space4_field1_off = 0; +size_t space4_field2_off = 0; +size_t space4_field3_off = 0; +size_t space4_field4_off = 0; struct space4_struct { - char c1; + char c1; unsigned u; - float f; - char c2; - } space4_data={'v',987123,(float)-3.14,'g'}; /* Test data for 4th dataspace */ + float f; + char c2; +} space4_data = {'v', 987123, (float)-3.14, 'g'}; /* Test data for 4th dataspace */ /* Null dataspace */ int space5_data = 7; - /*------------------------------------------------------------------------- * Function: test_h5s_basic * @@ -105,11 +104,12 @@ int space5_data = 7; * size to be zero. So I took out the test against it. *------------------------------------------------------------------------- */ -static void test_h5s_basic() +static void +test_h5s_basic() { hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}; - hsize_t dims3[H5S_MAX_RANK+1]; + hsize_t dims3[H5S_MAX_RANK + 1]; hsize_t tmax[4]; // Output message about test being performed @@ -117,13 +117,13 @@ static void test_h5s_basic() try { // Create simple dataspace sid1 - DataSpace sid1 (SPACE1_RANK, dims1 ); + DataSpace sid1(SPACE1_RANK, dims1); // Get simple extent npoints of the dataspace sid1 and verify it hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3), - "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of dataspace sid1 and verify it int rank; // Logical rank of dataspace @@ -131,21 +131,21 @@ static void test_h5s_basic() verify_val(rank, SPACE1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Retrieves dimension size of dataspace sid1 and verify it - int ndims; // Number of dimensions + int ndims; // Number of dimensions hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims( tdims ); + ndims = sid1.getSimpleExtentDims(tdims); verify_val(ndims, SPACE1_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Create simple dataspace sid2 - hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; - DataSpace sid2 (SPACE2_RANK, dims2, max2); + hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; + DataSpace sid2(SPACE2_RANK, dims2, max2); // Get simple extent npoints of dataspace sid2 and verify it n = sid2.getSimpleExtentNpoints(); verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4), - "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of dataspace sid2 and verify it rank = sid2.getSimpleExtentNdims(); @@ -153,34 +153,36 @@ static void test_h5s_basic() // Retrieves dimension size and max size of dataspace sid2 and // verify them - ndims = sid2.getSimpleExtentDims( tdims, tmax ); + ndims = sid2.getSimpleExtentDims(tdims, tmax); verify_val(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, "DataSpace::getSimpleExtentDims", + __LINE__, __FILE__); // Check to be sure we can't create a simple data space that has too // many dimensions. try { - DataSpace manydims_ds(H5S_MAX_RANK+1, dims3, NULL); + DataSpace manydims_ds(H5S_MAX_RANK + 1, dims3, NULL); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("DataSpace constructor", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("DataSpace constructor", + "Library allowed overwrite of existing dataset"); } - catch (DataSpaceIException& E) // Simple data space with too many dims - {} // do nothing, exception expected - - /* - * Try reading a file that has been prepared that has a dataset with a - * higher dimensionality than what the library can handle. - * - * If this test fails and the H5S_MAX_RANK variable has changed, follow - * the instructions in space_overflow.c for regenating the th5s.h5 file. - */ - char *tmp_str = new char[TESTFILE.length()+1]; + catch (DataSpaceIException &E) // Simple data space with too many dims + { + } // do nothing, exception expected + + /* + * Try reading a file that has been prepared that has a dataset with a + * higher dimensionality than what the library can handle. + * + * If this test fails and the H5S_MAX_RANK variable has changed, follow + * the instructions in space_overflow.c for regenating the th5s.h5 file. + */ + char *tmp_str = new char[TESTFILE.length() + 1]; strcpy(tmp_str, TESTFILE.c_str()); const char *testfile = H5_get_srcdir_filename(tmp_str); - delete []tmp_str; + delete[] tmp_str; // Create file H5File fid1(testfile, H5F_ACC_RDONLY); @@ -188,33 +190,33 @@ static void test_h5s_basic() // Try to open the dataset that has higher dimensionality than // what the library can handle and this operation should fail. try { - DataSet dset1 = fid1.openDataSet( "dset" ); + DataSet dset1 = fid1.openDataSet("dset"); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File::openDataSet", "Opening a dataset with higher dimensionality than what the library can handle"); + throw InvalidActionException( + "H5File::openDataSet", + "Opening a dataset with higher dimensionality than what the library can handle"); } - catch (FileIException& E) // catching higher dimensionality dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching higher dimensionality dataset + { + } // do nothing, exception expected - // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure - // in the p_close see how this will handle it. - BMR + // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure + // in the p_close see how this will handle it. - BMR PASSED(); - } // end of try block + } // end of try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_basic() +} // test_h5s_basic() - /*------------------------------------------------------------------------- * Function: test_h5s_scalar_write * @@ -234,7 +236,8 @@ static void test_h5s_basic() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_scalar_write() +static void +test_h5s_scalar_write() { // Output message about test being performed SUBTEST("Scalar Dataspace Writing"); @@ -246,7 +249,7 @@ static void test_h5s_scalar_write() // Create scalar dataspace DataSpace sid1(SPACE3_RANK, NULL); - //n = H5Sget_simple_extent_npoints(sid1); + // n = H5Sget_simple_extent_npoints(sid1); hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); @@ -256,9 +259,9 @@ static void test_h5s_scalar_write() verify_val(rank, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Retrieves dimension size of dataspace sid1 and verify it - int ndims; // Number of dimensions + int ndims; // Number of dimensions hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims( tdims ); + ndims = sid1.getSimpleExtentDims(tdims); verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Verify extent type @@ -267,18 +270,16 @@ static void test_h5s_scalar_write() verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); // Create and write a dataset - DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); + DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1); dataset.write(&space3_data, PredType::NATIVE_UINT); PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_scalar_write() +} // test_h5s_scalar_write() - /*------------------------------------------------------------------------- * Function: test_h5s_scalar_read * @@ -298,7 +299,8 @@ static void test_h5s_scalar_write() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_scalar_read() +static void +test_h5s_scalar_read() { hsize_t tdims[4]; // Dimension array to test with @@ -331,16 +333,14 @@ static void test_h5s_scalar_read() verify_val(rdata, space3_data, "DataSet::read", __LINE__, __FILE__); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_scalar_read() +} // test_h5s_scalar_read() - /*------------------------------------------------------------------------- * Function: test_h5s_null * @@ -360,7 +360,8 @@ static void test_h5s_scalar_read() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_null() +static void +test_h5s_null() { // Output message about test being performed SUBTEST("Null Dataspace Writing"); @@ -377,7 +378,7 @@ static void test_h5s_null() verify_val((long)n, 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Create a dataset - DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); + DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1); // Try to write nothing to the dataset dataset.write(&space5_data, PredType::NATIVE_INT); @@ -388,13 +389,11 @@ static void test_h5s_null() PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_null()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_null() +} // test_h5s_null() - /*------------------------------------------------------------------------- * Function: test_h5s_compound_scalar_write * @@ -415,7 +414,8 @@ static void test_h5s_null() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_compound_scalar_write() +static void +test_h5s_compound_scalar_write() { // Output message about test being performed SUBTEST("Compound Dataspace Writing"); @@ -426,18 +426,14 @@ static void test_h5s_compound_scalar_write() // Create the compound datatype. CompType tid1(sizeof(struct space4_struct)); - space4_field1_off=HOFFSET(struct space4_struct, c1); - tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, - PredType::NATIVE_SCHAR); - space4_field2_off=HOFFSET(struct space4_struct, u); - tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, - PredType::NATIVE_UINT); - space4_field3_off=HOFFSET(struct space4_struct, f); - tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, - PredType::NATIVE_FLOAT); - space4_field4_off=HOFFSET(struct space4_struct, c2); - tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, - PredType::NATIVE_SCHAR); + space4_field1_off = HOFFSET(struct space4_struct, c1); + tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, PredType::NATIVE_SCHAR); + space4_field2_off = HOFFSET(struct space4_struct, u); + tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, PredType::NATIVE_UINT); + space4_field3_off = HOFFSET(struct space4_struct, f); + tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, PredType::NATIVE_FLOAT); + space4_field4_off = HOFFSET(struct space4_struct, c2); + tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, PredType::NATIVE_SCHAR); // Create scalar dataspace DataSpace sid1(SPACE3_RANK, NULL); @@ -459,15 +455,13 @@ static void test_h5s_compound_scalar_write() dataset.write(&space4_data, tid1); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_compound_scalar_write() +} // test_h5s_compound_scalar_write() - /*------------------------------------------------------------------------- * Function: test_h5s_compound_scalar_read * @@ -488,7 +482,8 @@ static void test_h5s_compound_scalar_write() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_compound_scalar_read() +static void +test_h5s_compound_scalar_read() { hsize_t tdims[4]; // Dimension array to test with @@ -521,27 +516,24 @@ static void test_h5s_compound_scalar_read() dataset.read(&rdata, type); // Verify read data - if(HDmemcmp(&space4_data,&rdata,sizeof(struct space4_struct))) - { - cerr << "scalar data different: space4_data.c1=" - << space4_data.c1 << ", read_data4.c1=" << rdata.c1 << endl; - cerr << "scalar data different: space4_data.u=" - << space4_data.u << ", read_data4.u=" << rdata.u << endl; - cerr << "scalar data different: space4_data.f=" - << space4_data.f << ", read_data4.f=" << rdata.f << endl; - TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", - space4_data.c1, rdata.c2); + if (HDmemcmp(&space4_data, &rdata, sizeof(struct space4_struct))) { + cerr << "scalar data different: space4_data.c1=" << space4_data.c1 + << ", read_data4.c1=" << rdata.c1 << endl; + cerr << "scalar data different: space4_data.u=" << space4_data.u << ", read_data4.u=" << rdata.u + << endl; + cerr << "scalar data different: space4_data.f=" << space4_data.f << ", read_data4.f=" << rdata.f + << endl; + TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", space4_data.c1, + rdata.c2); } // end if PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_compound_scalar_read() +} // test_h5s_compound_scalar_read() - /*------------------------------------------------------------------------- * Function: test_h5s * @@ -553,21 +545,20 @@ static void test_h5s_compound_scalar_read() * Mar 2001 *------------------------------------------------------------------------- */ -extern "C" -void test_h5s() +extern "C" void +test_h5s() { // Output message about test being performed MESSAGE(5, ("Testing Dataspaces\n")); - test_h5s_basic(); // Test basic H5S code - test_h5s_scalar_write(); // Test scalar H5S writing code - test_h5s_scalar_read(); // Test scalar H5S reading code - test_h5s_null(); // Test null H5S code - test_h5s_compound_scalar_write(); // Test compound datatype scalar H5S writing code - test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code -} // test_h5s() + test_h5s_basic(); // Test basic H5S code + test_h5s_scalar_write(); // Test scalar H5S writing code + test_h5s_scalar_read(); // Test scalar H5S reading code + test_h5s_null(); // Test null H5S code + test_h5s_compound_scalar_write(); // Test compound datatype scalar H5S writing code + test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code +} // test_h5s() - /*------------------------------------------------------------------------- * Function: cleanup_h5s * @@ -576,9 +567,8 @@ void test_h5s() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_h5s() +extern "C" void +cleanup_h5s() { HDremove(DATAFILE.c_str()); -} // cleanup_h5s - +} // cleanup_h5s diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp index d69e8d2..83229b9 100644 --- a/c++/test/titerate.cpp +++ b/c++/test/titerate.cpp @@ -25,11 +25,11 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file /* Number of datasets for group iteration test */ #define NDATASETS 50 @@ -41,53 +41,48 @@ using namespace H5; //#define ITER_NGROUPS 150 /* General maximum length of names used */ -#define NAMELEN 80 +#define NAMELEN 80 /* 1-D dataset with fixed dimensions */ //#define SPACE1_RANK 1 //#define SPACE1_DIM1 4 -const H5std_string FILE_ITERATE("titerate.h5"); -const H5std_string GROUP1("Top Group"); -const H5std_string GROUP1_PATH("/Top Group"); -const H5std_string GROUP1_1("Sub-Group 1.1"); -const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); -const H5std_string GROUP1_2("Sub-Group 1.2"); -const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_IN_FILE("Dataset in File"); -const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); -const H5std_string DSET_IN_GRP1("Dataset in Group 1"); -const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1"); -const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2"); -const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2"); - -typedef enum { - RET_ZERO, - RET_TWO, - RET_CHANGE, - RET_CHANGE2 -} iter_enum; +const H5std_string FILE_ITERATE("titerate.h5"); +const H5std_string GROUP1("Top Group"); +const H5std_string GROUP1_PATH("/Top Group"); +const H5std_string GROUP1_1("Sub-Group 1.1"); +const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); +const H5std_string GROUP1_2("Sub-Group 1.2"); +const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_IN_FILE("Dataset in File"); +const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); +const H5std_string DSET_IN_GRP1("Dataset in Group 1"); +const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1"); +const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2"); +const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2"); + +typedef enum { RET_ZERO, RET_TWO, RET_CHANGE, RET_CHANGE2 } iter_enum; /* Custom group iteration callback data */ typedef struct { - char name[NAMELEN]; /* The name of the object */ - H5O_type_t type; /* The type of the object */ - iter_enum command; /* The type of return value */ + char name[NAMELEN]; /* The name of the object */ + H5O_type_t type; /* The type of the object */ + iter_enum command; /* The type of return value */ } iter_info; int iter_strcmp(const void *s1, const void *s2); - /*------------------------------------------------------------------------- * Function: iter_strcmp * * Purpose String comparison routine for qsort *------------------------------------------------------------------------- */ -int iter_strcmp(const void *s1, const void *s2) +int +iter_strcmp(const void *s1, const void *s2) { - return(HDstrcmp(*(const char * const *)s1,*(const char * const *)s2)); + return (HDstrcmp(*(const char *const *)s1, *(const char *const *)s2)); } /*------------------------------------------------------------------------- @@ -96,36 +91,37 @@ int iter_strcmp(const void *s1, const void *s2) * Purpose Custom link iteration callback routine *------------------------------------------------------------------------- */ -static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, void *op_data) +static herr_t +liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, + void *op_data) { - iter_info *info = (iter_info *)op_data; - static int count = 0; + iter_info *info = (iter_info *)op_data; + static int count = 0; static int count2 = 0; HDstrcpy(info->name, name); - switch(info->command) { + switch (info->command) { case RET_ZERO: - return(0); + return (0); case RET_TWO: - return(2); + return (2); case RET_CHANGE: count++; - return(count > 10 ? 1 : 0); + return (count > 10 ? 1 : 0); case RET_CHANGE2: count2++; - return(count2 > 10 ? 1 : 0); + return (count2 > 10 ? 1 : 0); default: printf("invalid iteration command"); - return(-1); + return (-1); } /* end switch */ } /* end liter_cb() */ - /*------------------------------------------------------------------------- * Function: test_iter_group * @@ -138,14 +134,15 @@ static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_i * Friday, September 9, 2016 *------------------------------------------------------------------------- */ -static void test_iter_group(FileAccPropList& fapl) +static void +test_iter_group(FileAccPropList &fapl) { - int i; /* counting variable */ - hsize_t idx; /* Index in the group */ - char name[NAMELEN]; /* temporary name buffer */ - char *lnames[NDATASETS + 2];/* Names of the links created */ - iter_info info; /* Custom iteration information */ - herr_t ret; /* Generic return value */ + int i; /* counting variable */ + hsize_t idx; /* Index in the group */ + char name[NAMELEN]; /* temporary name buffer */ + char * lnames[NDATASETS + 2]; /* Names of the links created */ + iter_info info; /* Custom iteration information */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ SUBTEST("Group Iteration"); @@ -157,8 +154,8 @@ static void test_iter_group(FileAccPropList& fapl) /* Test iterating over empty group */ info.command = RET_ZERO; - idx = 0; - ret = H5Literate2(file.getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); + idx = 0; + ret = H5Literate2(file.getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); verify_val(ret, SUCCEED, "H5Literate", __LINE__, __FILE__); DataType datatype(PredType::NATIVE_INT); @@ -166,16 +163,15 @@ static void test_iter_group(FileAccPropList& fapl) // Create a scalar file space DataSpace filespace; - for (i=0; i< NDATASETS; i++) - { - sprintf(name, "Dataset %d", i); + for (i = 0; i < NDATASETS; i++) { + sprintf(name, "Dataset %d", i); - // Create a dataset in the file - DataSet dataset = file.createDataSet(name, datatype, filespace); + // Create a dataset in the file + DataSet dataset = file.createDataSet(name, datatype, filespace); - /* Keep a copy of the dataset names */ - lnames[i] = HDstrdup(name); - check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__); + /* Keep a copy of the dataset names */ + lnames[i] = HDstrdup(name); + check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__); } /* end for */ @@ -191,7 +187,6 @@ static void test_iter_group(FileAccPropList& fapl) /* Sort the dataset names */ HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp); - /* Iterate through the datasets in the root group in various ways */ // Open data file to read @@ -205,15 +200,16 @@ static void test_iter_group(FileAccPropList& fapl) verify_val(nobjs, (hsize_t)(NDATASETS + 2), "H5Gget_info", __LINE__, __FILE__); H5std_string obj_name; - for (i = 0; i < nobjs; i++) - { - //H5O_info2_t oinfo; /* Object info */ + for (i = 0; i < nobjs; i++) { + // H5O_info2_t oinfo; /* Object info */ obj_name = root_group.getObjnameByIdx(i); - //ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT); + // ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, + // dataset_name, (size_t)NAMELEN, H5P_DEFAULT); - //oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); - //ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT); + // oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); + // ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, + // H5P_DEFAULT); } /* end for */ // Attempted to iterate with invalid index, should fail @@ -223,63 +219,69 @@ static void test_iter_group(FileAccPropList& fapl) // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with invalid index"); } - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected + catch (GroupIException &invalid_action) // invalid index + { + } // do nothing, exception expected // Attempted to iterate with negative index, should fail try { info.command = RET_ZERO; - idx = (hsize_t)-1; - obj_name = root_group.getObjnameByIdx(idx); + idx = (hsize_t)-1; + obj_name = root_group.getObjnameByIdx(idx); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected + catch (FileIException &invalid_action) // invalid index + { + } // do nothing, exception expected + catch (GroupIException &invalid_action) // invalid index + { + } // do nothing, exception expected /* Test skipping exactly as many entries as in the group */ try { info.command = RET_ZERO; - idx = NDATASETS + 2; - obj_name = root_group.getObjnameByIdx(idx); + idx = NDATASETS + 2; + obj_name = root_group.getObjnameByIdx(idx); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected + catch (FileIException &invalid_action) // invalid index + { + } // do nothing, exception expected + catch (GroupIException &invalid_action) // invalid index + { + } // do nothing, exception expected /* Test skipping more entries than are in the group */ try { info.command = RET_ZERO; - idx = NDATASETS + 3; - obj_name = root_group.getObjnameByIdx(idx); + idx = NDATASETS + 3; + obj_name = root_group.getObjnameByIdx(idx); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected + catch (FileIException &invalid_action) // invalid index + { + } // do nothing, exception expected + catch (GroupIException &invalid_action) // invalid index + { + } // do nothing, exception expected /* Free the dataset names */ - for(i = 0; i< (NDATASETS + 2); i++) + for (i = 0; i < (NDATASETS + 2); i++) HDfree(lnames[i]); // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_iter_group", __LINE__, __FILE__); } @@ -348,7 +350,6 @@ static void test_iter_group(FileAccPropList& fapl) #endif } /* test_iter_group() */ - /*------------------------------------------------------------------------- * Function: printelems * @@ -362,31 +363,29 @@ const H5std_string GDATASET_NAME("group dset"); const H5std_string ATTR_NAME("Units"); const H5std_string FATTR_NAME("F attr"); const H5std_string GATTR_NAME("G attr"); -const int DIM1 = 2; -void printelems(const Group& group, const H5std_string& dsname, const H5std_string& atname) +const int DIM1 = 2; +void +printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname) { - try - { - DataSet d1(group.openDataSet(dsname)); + try { + DataSet d1(group.openDataSet(dsname)); DataSpace s1 = d1.getSpace(); s1.close(); d1.close(); - unsigned idx = 0; - Attribute a1(group.openAttribute(idx)); + unsigned idx = 0; + Attribute a1(group.openAttribute(idx)); H5std_string aname = a1.getName(); verify_val(aname, atname, "printelems", __LINE__, __FILE__); a1.close(); - } + } // Catch all exceptions and rethrow so caller can handle - catch (Exception& E) - { + catch (Exception &E) { throw; } } - /*------------------------------------------------------------------------- * Function: test_HDFFV_9920 * @@ -396,33 +395,31 @@ void printelems(const Group& group, const H5std_string& dsname, const H5std_stri * Friday, September 9, 2016 *------------------------------------------------------------------------- */ -static void test_HDFFV_9920() +static void +test_HDFFV_9920() { - int attr_data[2] = { 100, 200}; - hsize_t dims[1] = { DIM1 }; + int attr_data[2] = {100, 200}; + hsize_t dims[1] = {DIM1}; - try - { + try { // Create a new file and a group in it - H5File file( FILE_NAME, H5F_ACC_TRUNC ); + H5File file(FILE_NAME, H5F_ACC_TRUNC); Group gr1(file.createGroup(GRP_NAME)); // Create the data space for the attribute. - DataSpace dspace = DataSpace (1, dims ); + DataSpace dspace = DataSpace(1, dims); DataSet fds = file.createDataSet(FDATASET_NAME, PredType::STD_I32BE, dspace); DataSet gds = gr1.createDataSet(GDATASET_NAME, PredType::STD_I32BE, dspace); // Create a file attribute and a group attribute. - Attribute fa1 = file.createAttribute(FATTR_NAME, PredType::STD_I32BE, - dspace); - Attribute ga1 = gr1.createAttribute(GATTR_NAME, PredType::STD_I32BE, - dspace); + Attribute fa1 = file.createAttribute(FATTR_NAME, PredType::STD_I32BE, dspace); + Attribute ga1 = gr1.createAttribute(GATTR_NAME, PredType::STD_I32BE, dspace); // Write the attribute data. - fa1.write( PredType::NATIVE_INT, attr_data); - ga1.write( PredType::NATIVE_INT, attr_data); + fa1.write(PredType::NATIVE_INT, attr_data); + ga1.write(PredType::NATIVE_INT, attr_data); fa1.close(); ga1.close(); @@ -433,16 +430,14 @@ static void test_HDFFV_9920() printelems(file, FDATASET_NAME, FATTR_NAME); printelems(gr1, GDATASET_NAME, GATTR_NAME); - } // end of try block + } // end of try block // Catch all failures for handling in the same way - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_HDFFV_9920()", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_iterate * @@ -455,8 +450,8 @@ static void test_HDFFV_9920() * Tuesday, September 6, 2016 *------------------------------------------------------------------------- */ -extern "C" -void test_iterate() +extern "C" void +test_iterate() { // Output message about test being performed MESSAGE(5, ("Testing Iterate Feature\n")); @@ -465,13 +460,12 @@ void test_iterate() FileAccPropList fapl; fapl.setLibverBounds(H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - test_iter_group(fapl); // Test iterating groups - test_HDFFV_9920(); // Test the fix of HDFFV-9920 - //test_iter_attr(fapl); // Test iterating attributes + test_iter_group(fapl); // Test iterating groups + test_HDFFV_9920(); // Test the fix of HDFFV-9920 + // test_iter_attr(fapl); // Test iterating attributes -} // test_iterate +} // test_iterate - /*------------------------------------------------------------------------- * Function: cleanup_iterate * @@ -480,8 +474,8 @@ void test_iterate() * Return none *------------------------------------------------------------------------- */ -extern "C" -void cleanup_iterate() +extern "C" void +cleanup_iterate() { HDremove(FILE_ITERATE.c_str()); } // cleanup_iterate diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index 1bdd442..8690ac2 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -25,37 +25,30 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -#define NAME_BUF_SIZE 1024 -#define H5L_DIM1 100 -#define H5L_DIM2 100 +#define NAME_BUF_SIZE 1024 +#define H5L_DIM1 100 +#define H5L_DIM2 100 // Object visit structs typedef struct { - const char *path; /* Path to object */ - H5O_type_t type; /* Type of object */ + const char *path; /* Path to object */ + H5O_type_t type; /* Type of object */ } obj_visit_t; // User data for callback function typedef struct { - unsigned idx; /* Index in object visit structure */ - const obj_visit_t *info; /* Pointer to the object visit structure to use */ + unsigned idx; /* Index in object visit structure */ + const obj_visit_t *info; /* Pointer to the object visit structure to use */ } ovisit_ud_t; -static const char *FILENAME[] = { - "link0", - "link1.h5", - "link2.h5", - "visit", - NULL -}; +static const char *FILENAME[] = {"link0", "link1.h5", "link2.h5", "visit", NULL}; - /*------------------------------------------------------------------------- * Function: test_basic_links * @@ -67,17 +60,17 @@ static const char *FILENAME[] = { * October 16, 2009 *------------------------------------------------------------------------- */ -static void test_basic_links(hid_t fapl_id, hbool_t new_format) +static void +test_basic_links(hid_t fapl_id, hbool_t new_format) { hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); - try - { - if(new_format) + try { + if (new_format) SUBTEST("Link creation (w/new group format)") else SUBTEST("Link creation") @@ -86,7 +79,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Create simple dataspace - DataSpace scalar (1, size, size); + DataSpace scalar(1, size, size); // Create a group then close it by letting the object go out of scope { @@ -103,25 +96,19 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) // Because these are not implemented in the C++ API yet, they are // used so CommonFG::getLinkval can be tested. // Create a hard link - if(H5Lcreate_hard( - file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", - H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_hard failed"); // Create a symbolic link - if(H5Lcreate_soft( - "/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Create a symbolic link to something that doesn't exist - if(H5Lcreate_soft( - "foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Create a recursive symbolic link - if(H5Lcreate_soft( - "/grp1/recursive", file_id, "/grp1/recursive", - H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/grp1/recursive", file_id, "/grp1/recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Verify link values before closing the file @@ -136,26 +123,24 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } // Open the file and check on the links in it - try - { + try { // Open the file above H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); // Verify link existence - if(file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE) + if (file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::nameExists", "dset1 doesn't exist"); - if(file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) + if (file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::nameExists", "grp1/soft doesn't exist"); // Deprecated - if(file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE) + if (file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::exists", "dset1 doesn't exist"); - if(file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) + if (file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist"); // Verify link values @@ -167,13 +152,11 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_basic_links - /*------------------------------------------------------------------------- * Function: test_lcpl * @@ -191,16 +174,15 @@ static void test_lcpl(hid_t fapl_id, hbool_t new_format) { H5L_info2_t linfo; - char filename[1024]; - hsize_t dims[2]; + char filename[1024]; + hsize_t dims[2]; - if(new_format) + if (new_format) SUBTEST("Link creation property lists (w/new group format)") else SUBTEST("Link creation property lists") - try - { + try { FileAccPropList fapl(fapl_id); // Create a new file. @@ -213,7 +195,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Check that its character encoding is the default. linfo = file.getLinkInfo(GROUP1NAME); - if(linfo.cset != H5T_CSET_ASCII) + if (linfo.cset != H5T_CSET_ASCII) throw InvalidActionException("H5Lget_info", "Character encoding is not default"); // Create and commit a datatype with the default LCPL. @@ -228,7 +210,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Create a simple dataspace. dims[0] = H5L_DIM1; dims[1] = H5L_DIM2; - DataSpace dspace(2 ,dims); + DataSpace dspace(2, dims); // Create a dataset using the default LCPL. DataSet dset(file.createDataSet("/dataset", PredType::NATIVE_INT, dspace)); @@ -252,13 +234,11 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_lcpl()", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_lcpl() - /*------------------------------------------------------------------------- * Function: test_move * @@ -272,15 +252,14 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) static void test_move(hid_t fapl_id, hbool_t new_format) { - char filename[1024]; + char filename[1024]; - if(new_format) + if (new_format) SUBTEST("Group::moveLink (w/new group format)") else SUBTEST("Group::moveLink") - try - { + try { FileAccPropList fapl(fapl_id); // Create two new files @@ -303,15 +282,16 @@ test_move(hid_t fapl_id, hbool_t new_format) grp_1.moveLink("group_move", file_b, "group_new_name"); // Should throw an exception but didn't - H5_FAILED(); - cerr << " Group group_move should not be moved across files" << endl; - } catch (Exception& E) { + H5_FAILED(); + cerr << " Group group_move should not be moved across files" << endl; + } + catch (Exception &E) { // expected } // Move a soft link across files, should succeed grp_2.moveLink("soft", file_b, "soft_new_name"); - if(file_b.exists("soft_new_name") != TRUE) + if (file_b.exists("soft_new_name") != TRUE) throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist"); // Move a group across groups in the same file while renaming it @@ -326,9 +306,10 @@ test_move(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_move"); // Should throw an exception but didn't - H5_FAILED(); - cerr << " Group group_move should not be in original location" << endl; - } catch (Exception& E) { + H5_FAILED(); + cerr << " Group group_move should not be in original location" << endl; + } + catch (Exception &E) { // expected } @@ -360,46 +341,49 @@ test_move(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_2.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_2.openGroup("group_new_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_new_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_new_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_1.openGroup("group_copy"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_copy should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_copy should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_move()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_move - + /*------------------------------------------------------------------------- * Function: test_copy * @@ -410,17 +394,17 @@ test_move(hid_t fapl_id, hbool_t new_format) * March, 2018 *------------------------------------------------------------------------- */ -static void test_copy(hid_t fapl_id, hbool_t new_format) +static void +test_copy(hid_t fapl_id, hbool_t new_format) { char filename[1024]; - if(new_format) + if (new_format) SUBTEST("Group::copyLink (w/new group format)") else SUBTEST("Group::copyLink") - try - { + try { // Create two new files h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); H5File file_a(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl_id); @@ -439,7 +423,8 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) // Copy a group across files, should fail try { grp_1.copyLink("group_copy", file_b, "group_new_name"); - } catch (Exception& E) { + } + catch (Exception &E) { // expected } @@ -509,9 +494,10 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) moved_grp = grp_2.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } @@ -521,21 +507,20 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_copy"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_copy should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_copy should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_copy()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_copy - /*------------------------------------------------------------------------- * Function: test_num_links * @@ -547,17 +532,17 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) * October 16, 2009 *------------------------------------------------------------------------- */ -static void test_num_links(hid_t fapl_id, hbool_t new_format) +static void +test_num_links(hid_t fapl_id, hbool_t new_format) { char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) SUBTEST("Setting number of links (w/new group format)") else SUBTEST("Setting number of links") - try - { + try { // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); @@ -565,7 +550,7 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); LinkAccPropList lapl; - size_t nlinks = 5; + size_t nlinks = 5; lapl.setNumLinks(nlinks); // Read it back and verify @@ -574,13 +559,11 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_num_links - // Data for visit on the file static const obj_visit_t file_visit[] = { {".", H5O_TYPE_GROUP}, @@ -600,22 +583,25 @@ const H5std_string FILE_NAME("tvisit.h5"); const H5std_string GROUP_NAME("/Data"); const H5std_string DSET1_NAME("/Data/Compressed_Data"); const H5std_string DSET2_NAME("/Data/Float_Data"); -const int RANK = 2; -const int DIM1 = 2; +const int RANK = 2; +const int DIM1 = 2; // Operator function -static int visit_obj_cb(H5Object& obj, const H5std_string name, const H5O_info2_t *oinfo, void *_op_data) +static int +visit_obj_cb(H5Object &obj, const H5std_string name, const H5O_info2_t *oinfo, void *_op_data) { - ovisit_ud_t *op_data = static_cast (_op_data); + ovisit_ud_t *op_data = static_cast(_op_data); // Check for correct object information - if(strcmp(op_data->info[op_data->idx].path, name.c_str())) return(H5_ITER_ERROR); - if(op_data->info[op_data->idx].type != oinfo->type) return(H5_ITER_ERROR); + if (strcmp(op_data->info[op_data->idx].path, name.c_str())) + return (H5_ITER_ERROR); + if (op_data->info[op_data->idx].type != oinfo->type) + return (H5_ITER_ERROR); // Advance to next location op_data->idx++; - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /*------------------------------------------------------------------------- @@ -628,93 +614,90 @@ static int visit_obj_cb(H5Object& obj, const H5std_string name, const H5O_info2_ * February 8, 2019 *------------------------------------------------------------------------- */ -static void test_visit(hid_t fapl_id, hbool_t new_format) +static void +test_visit(hid_t fapl_id, hbool_t new_format) { - hsize_t dims[2]; - hsize_t cdims[2]; - char filename[NAME_BUF_SIZE]; + hsize_t dims[2]; + hsize_t cdims[2]; + char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) SUBTEST("H5Object::visit (w/new group format)") else SUBTEST("H5Object::visit") - try - { + try { // Use the file access template id to create a file access prop. list FileAccPropList fapl(fapl_id); // Build the hdf5 file name and create the file h5_fixname(FILENAME[3], fapl_id, filename, sizeof filename); - H5File *file = new H5File(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + H5File *file = new H5File(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Create a group - Group* group = new Group(file->createGroup(GROUP_NAME)); + Group *group = new Group(file->createGroup(GROUP_NAME)); // Create a chunked/compressed dataset within this group specified by path - dims[0] = 20; - dims[1] = 2; - cdims[0] = 2; - cdims[1] = 2; - DataSpace *dataspace = new DataSpace(RANK, dims); // create new dspace - DSetCreatPropList ds_creatplist; // create dataset creation prop list - ds_creatplist.setChunk(2, cdims); // then modify it for compression - ds_creatplist.setDeflate(6); - - DataSet* dataset = new DataSet(file->createDataSet(DSET1_NAME, - PredType::NATIVE_INT, *dataspace, ds_creatplist)); - - delete dataset; - delete dataspace; - - // Create another dataset - dims[0] = 5; - dims[1] = 2; - dataspace = new DataSpace(RANK, dims); // create second dspace - dataset = new DataSet(file->createDataSet(DSET2_NAME, - PredType::NATIVE_FLOAT, *dataspace)); + dims[0] = 20; + dims[1] = 2; + cdims[0] = 2; + cdims[1] = 2; + DataSpace * dataspace = new DataSpace(RANK, dims); // create new dspace + DSetCreatPropList ds_creatplist; // create dataset creation prop list + ds_creatplist.setChunk(2, cdims); // then modify it for compression + ds_creatplist.setDeflate(6); + + DataSet *dataset = + new DataSet(file->createDataSet(DSET1_NAME, PredType::NATIVE_INT, *dataspace, ds_creatplist)); + + delete dataset; + delete dataspace; + + // Create another dataset + dims[0] = 5; + dims[1] = 2; + dataspace = new DataSpace(RANK, dims); // create second dspace + dataset = new DataSet(file->createDataSet(DSET2_NAME, PredType::NATIVE_FLOAT, *dataspace)); // Close everything - delete dataset; - delete dataspace; - delete group; - delete file; + delete dataset; + delete dataspace; + delete group; + delete file; - // Reopen the file and group in the file. - file = new H5File(filename, H5F_ACC_RDWR); - group = new Group(file->openGroup("Data")); + // Reopen the file and group in the file. + file = new H5File(filename, H5F_ACC_RDWR); + group = new Group(file->openGroup("Data")); // Open the group - dataset = new DataSet(group->openDataSet(DSET2_NAME)); + dataset = new DataSet(group->openDataSet(DSET2_NAME)); delete dataset; // Visit objects in the file - ovisit_ud_t udata; /* User-data for visiting */ - udata.idx = 0; + ovisit_ud_t udata; /* User-data for visiting */ + udata.idx = 0; udata.info = file_visit; file->visit(H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC); // Visit objects in the group - udata.idx = 0; + udata.idx = 0; udata.info = group_visit; group->visit(H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC); - // Close the group and file. - delete group; - delete file; + // Close the group and file. + delete group; + delete file; PASSED(); } // end of try block - catch (Exception& E) - { - cerr << "in catch" << endl; + catch (Exception &E) { + cerr << "in catch" << endl; issue_fail_msg("test_visit()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_visit() - /*------------------------------------------------------------------------- * Function: test_links * @@ -725,35 +708,33 @@ static void test_visit(hid_t fapl_id, hbool_t new_format) * October 16, 2009 *------------------------------------------------------------------------- */ -extern "C" -void test_links() +extern "C" void +test_links() { - hid_t fapl_id, fapl2_id; /* File access property lists */ - unsigned new_format; /* Whether to use the new format or not */ + hid_t fapl_id, fapl2_id; /* File access property lists */ + unsigned new_format; /* Whether to use the new format or not */ - if((fapl_id = h5_fileaccess()) < 0) + if ((fapl_id = h5_fileaccess()) < 0) throw Exception("test_links", "Unable to get file access property list"); // Output message about test being performed MESSAGE(5, ("Testing Various Links\n")); - try - { + try { /* Copy the file access property list */ - if((fapl2_id = H5Pcopy(fapl_id)) < 0) + if ((fapl2_id = H5Pcopy(fapl_id)) < 0) throw Exception("test_links", "H5Pcopy failed"); /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) throw Exception("test_links", "H5Pset_libver_bounds failed"); /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) - { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl_id; /* Check for FAPL to use */ - if(new_format) + if (new_format) my_fapl_id = fapl2_id; else my_fapl_id = fapl_id; @@ -773,13 +754,11 @@ void test_links() h5_clean_files(FILENAME, fapl_id); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: cleanup_links * @@ -788,8 +767,8 @@ void test_links() * Return none *------------------------------------------------------------------------- */ -extern "C" -void cleanup_links() +extern "C" void +cleanup_links() { HDremove(FILENAME[0]); HDremove(FILENAME[1]); diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 9b5dd68..991df3f 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -23,29 +23,28 @@ #endif #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file - -const H5std_string FILE_OBJECTS("tobjects.h5"); -const H5std_string FILE_OBJHDR("tobject_header.h5"); -const H5std_string GROUP1("Top Group"); -const H5std_string GROUP1_PATH("/Top Group"); -const H5std_string GROUP1_1("Sub-Group 1.1"); -const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); -const H5std_string GROUP1_2("Sub-Group 1.2"); -const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_IN_FILE("Dataset in File"); -const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); -const H5std_string DSET_IN_GRP1("Dataset_in_Group_1"); -const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1"); -const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2"); -const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2"); - - +#include "h5cpputil.h" // C++ utilility header file + +const H5std_string FILE_OBJECTS("tobjects.h5"); +const H5std_string FILE_OBJHDR("tobject_header.h5"); +const H5std_string GROUP1("Top Group"); +const H5std_string GROUP1_PATH("/Top Group"); +const H5std_string GROUP1_1("Sub-Group 1.1"); +const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); +const H5std_string GROUP1_2("Sub-Group 1.2"); +const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_IN_FILE("Dataset in File"); +const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); +const H5std_string DSET_IN_GRP1("Dataset_in_Group_1"); +const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1"); +const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2"); +const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2"); + /*------------------------------------------------------------------------- * Function: test_get_objname * @@ -68,7 +67,8 @@ const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_ * Friday, March 4, 2014 *------------------------------------------------------------------------- */ -static void test_get_objname() +static void +test_get_objname() { SUBTEST("H5Object::getObjName on Groups and Datasets"); @@ -77,7 +77,7 @@ static void test_get_objname() H5File file(FILE_OBJECTS, H5F_ACC_TRUNC); // Create a top group and 2 subgroups - Group grp1 = file.createGroup(GROUP1, 0); + Group grp1 = file.createGroup(GROUP1, 0); Group grp1_1 = grp1.createGroup(GROUP1_1, 0); Group grp1_2 = grp1.createGroup(GROUP1_2, 0); @@ -88,27 +88,24 @@ static void test_get_objname() ssize_t name_len = grp1.getObjName(NULL); // Random length is 4 - if (name_len > 4) - { - char* grp1_name = new char[5]; - name_len = grp1.getObjName(grp1_name, 5); - verify_val((const char*)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); - delete []grp1_name; + if (name_len > 4) { + char *grp1_name = new char[5]; + name_len = grp1.getObjName(grp1_name, 5); + verify_val((const char *)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); + delete[] grp1_name; } // Create a data space - hsize_t dims[2]; + hsize_t dims[2]; dims[0] = 2; dims[1] = 5; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a dataset in the file - DataSet dsinfile = file.createDataSet(DSET_IN_FILE, - PredType::NATIVE_DOUBLE, space); + DataSet dsinfile = file.createDataSet(DSET_IN_FILE, PredType::NATIVE_DOUBLE, space); // Create a dataset in the group - DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, - PredType::NATIVE_INT, space); + DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, PredType::NATIVE_INT, space); // Get and verify the name of each dataset, using // H5std_string getObjName() and @@ -135,23 +132,21 @@ static void test_get_objname() // Reopen that same dataset then check the name again with another // overload: ssize_t getObjName(H5std_string& obj_name, size_t len = 0) - dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2); + dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2); name_len = dsingrp.getObjName(ds_name); verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__); // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objname", __LINE__, __FILE__); } -} // test_get_objname +} // test_get_objname - /*------------------------------------------------------------------------- * Function: test_existance * @@ -174,7 +169,8 @@ static void test_get_objname() * Friday, March 4, 2014 *------------------------------------------------------------------------- */ -static void test_existance() +static void +test_existance() { SUBTEST("H5File::exists and Group::exists"); @@ -222,7 +218,7 @@ static void test_existance() // Check if a dataset exists given dataset as location with full path name DataSet dset1 = file.openDataSet(DSET_IN_FILE); - exists = dset1.nameExists("/Top Group/Dataset_in_Group_1"); + exists = dset1.nameExists("/Top Group/Dataset_in_Group_1"); verify_val(exists, TRUE, "Group::nameExists given dataset with full path name", __LINE__, __FILE__); exists = grp1_2.nameExists(DSET_IN_GRP1); @@ -236,16 +232,14 @@ static void test_existance() // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_existance", __LINE__, __FILE__); } -} // test_existance +} // test_existance - /*------------------------------------------------------------------------- * Function: test_get_objname_ontypes * @@ -258,7 +252,8 @@ static void test_existance() * March 4, 2014 *------------------------------------------------------------------------- */ -static void test_get_objname_ontypes() +static void +test_get_objname_ontypes() { SUBTEST("H5Object::getObjName on Committed Datatypes"); @@ -267,7 +262,7 @@ static void test_get_objname_ontypes() H5File file(FILE_OBJECTS, H5F_ACC_RDWR); // Create a group - Group grp = file.createGroup ("typetests"); + Group grp = file.createGroup("typetests"); // Create a datatype and save it IntType inttype(PredType::STD_B8LE); @@ -326,7 +321,8 @@ static void test_get_objname_ontypes() // Name this datatype new_int_type.commit(grp, "IntType NATIVE_INT"); ssize_t name_len = new_int_type.getObjName(type_name); // default len - verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", __LINE__, __FILE__); + verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", + __LINE__, __FILE__); verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__); // Close everything or they can be closed when objects go out of scope @@ -338,13 +334,11 @@ static void test_get_objname_ontypes() PASSED(); } // end top try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__); } -} // test_get_objname_ontypes +} // test_get_objname_ontypes - /*------------------------------------------------------------------------- * Function: test_get_objtype * @@ -357,7 +351,8 @@ static void test_get_objname_ontypes() * Friday, March 4, 2014 *------------------------------------------------------------------------- */ -static void test_get_objtype() +static void +test_get_objtype() { SUBTEST("H5File::childObjType and H5Group::childObjType"); @@ -398,16 +393,14 @@ static void test_get_objtype() // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objtype", __LINE__, __FILE__); } -} // test_get_objtype +} // test_get_objtype - /*------------------------------------------------------------------------- * Function: test_open_object_header * @@ -427,9 +420,10 @@ const H5std_string DSETNAME("dataset"); #define DIM0 5 #define DIM1 10 -static void test_open_object_header() +static void +test_open_object_header() { - hsize_t dims[2]; + hsize_t dims[2]; // Output message about test being performed SUBTEST("Group::getObjId"); @@ -452,16 +446,16 @@ static void test_open_object_header() dims[0] = DIM0; dims[1] = DIM1; DataSpace dspace(RANK, dims); - DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace)); + DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace)); // Close dataset and dataspace dset.close(); dspace.close(); // Now make sure that getObjId can open all three types of objects - hid_t obj_grp = file1.getObjId(GROUPNAME); + hid_t obj_grp = file1.getObjId(GROUPNAME); hid_t obj_dtype = file1.getObjId(DTYPENAME); - hid_t obj_dset = file1.getObjId(DSETNAME); + hid_t obj_dset = file1.getObjId(DSETNAME); // Make sure that each is the right kind of ID H5I_type_t id_type = IdComponent::getHDFObjType(obj_grp); @@ -473,7 +467,7 @@ static void test_open_object_header() /* Do something more complex with each of the IDs to make sure */ - Group grp2(obj_grp); + Group grp2(obj_grp); hsize_t num_objs = grp2.getNumObjs(); verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__); // There should be one object, the datatype @@ -482,7 +476,7 @@ static void test_open_object_header() file1.closeObjId(obj_dtype); dset.setId(obj_dset); - dspace = dset.getSpace(); + dspace = dset.getSpace(); bool is_simple = dspace.isSimple(); verify_val(is_simple, true, "isSimple", __LINE__, __FILE__); dspace.close(); @@ -509,23 +503,20 @@ static void test_open_object_header() grp2.close(); PASSED(); - } // end of try block + } // end of try block // catch invalid action exception - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " in InvalidActionException" << endl; cerr << " *FAILED*" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " in Exception" << endl; issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_open_object_header +} // test_open_object_header - /*------------------------------------------------------------------------- * Function: test_getobjectinfo_same_file * @@ -540,9 +531,10 @@ static void test_open_object_header() const H5std_string FILE_OBJINFO("tobject_getinfo.h5"); const H5std_string GROUP1NAME("group1"); const H5std_string GROUP2NAME("group2"); -static void test_getobjectinfo_same_file() +static void +test_getobjectinfo_same_file() { - H5O_info2_t oinfo1, oinfo2; /* Object info structs */ + H5O_info2_t oinfo1, oinfo2; /* Object info structs */ // Output message about test being performed SUBTEST("Group::getObjinfo"); @@ -588,7 +580,6 @@ static void test_getobjectinfo_same_file() grp2.getObjinfo(oinfo2); verify_val(oinfo1.fileno, oinfo2.fileno, "file number from getObjinfo", __LINE__, __FILE__); - // Reset object info HDmemset(&oinfo1, 0, sizeof(oinfo1)); HDmemset(&oinfo2, 0, sizeof(oinfo2)); @@ -604,16 +595,15 @@ static void test_getobjectinfo_same_file() file2.close(); PASSED(); - } // end of try block + } // end of try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " in Exception " << E.getCFuncName() << "detail: " << E.getCDetailMsg() << endl; issue_fail_msg("test_getobjectinfo_same_file()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_getobjectinfo_same_file - +} // test_getobjectinfo_same_file + /*------------------------------------------------------------------------- * Function: test_intermediate_groups * @@ -636,7 +626,8 @@ const H5std_string GROUP20NAME("/group20"); const H5std_string GROUP21NAME("/group20/group21"); const H5std_string GROUP22NAME("group21/group22"); const H5std_string GROUP22FULLNAME("/group20/group21/group22"); -static void test_intermediate_groups() +static void +test_intermediate_groups() { // Output message about test being performed SUBTEST("Group::set/getCreateIntermediateGroup"); @@ -663,7 +654,9 @@ static void test_intermediate_groups() // fail because group GROUP13NAME is missing try { Group grp14_nopl(file.createGroup(GROUP14NAME)); - } catch (FileIException& expected1) {} // Failure is ignored + } + catch (FileIException &expected1) { + } // Failure is ignored // Create GROUP14NAME with the flag to create missing groups set // to FALSE, should fail because group GROUP13NAME is missing @@ -677,14 +670,15 @@ static void test_intermediate_groups() try { Group grp14_false(file.createGroup(GROUP14NAME, lcpl)); - } catch (FileIException& expected2) {} // Failure is ignored + } + catch (FileIException &expected2) { + } // Failure is ignored // Set the flag to create missing groups set to TRUE lcpl.setCreateIntermediateGroup(true); crt_int_grps = lcpl.getCreateIntermediateGroup(); verify_val(crt_int_grps, true, "LinkCreatPropList::getCreateIntermediateGroup", __LINE__, __FILE__); - // Create GROUP14NAME with the use of link create plist Group grp14(file.createGroup(GROUP14NAME, lcpl)); @@ -715,16 +709,15 @@ static void test_intermediate_groups() Group grp22fromfile(file.openGroup(GROUP22FULLNAME)); PASSED(); - } // end of try block + } // end of try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " in Exception " << E.getCFuncName() << "detail: " << E.getCDetailMsg() << endl; issue_fail_msg("test_intermediate_groups()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_intermediate_groups - +} // test_intermediate_groups + /*------------------------------------------------------------------------- * Function: test_object * @@ -736,8 +729,8 @@ static void test_intermediate_groups() * March 4, 2014 *------------------------------------------------------------------------- */ -extern "C" -void test_object() +extern "C" void +test_object() { // Output message about test being performed MESSAGE(5, ("Testing Object Functions\n")); @@ -750,9 +743,8 @@ void test_object() test_getobjectinfo_same_file(); // Test object info in same file test_intermediate_groups(); // Test intermediate group property -} // test_object +} // test_object - /*------------------------------------------------------------------------- * Function: cleanup_objects * @@ -761,8 +753,8 @@ void test_object() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_object() +extern "C" void +cleanup_object() { HDremove(FILE_OBJECTS.c_str()); } // cleanup_objects diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index b46ae29..beba36a 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -26,22 +26,22 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILE1("trefer1.h5"); -const H5std_string FILE2("trefer2.h5"); +const H5std_string FILE1("trefer1.h5"); +const H5std_string FILE2("trefer2.h5"); // Dataset 1 -const H5std_string DSET1_NAME("Dataset1"); -const H5std_string DSET2_NAME("Dataset2"); +const H5std_string DSET1_NAME("Dataset1"); +const H5std_string DSET2_NAME("Dataset2"); -const H5std_string MEMBER1( "a_name" ); -const H5std_string MEMBER2( "b_name" ); -const H5std_string MEMBER3( "c_name" ); +const H5std_string MEMBER1("a_name"); +const H5std_string MEMBER2("b_name"); +const H5std_string MEMBER3("c_name"); // 1-D dataset with fixed dimensions const int SPACE1_RANK = 1; @@ -58,10 +58,9 @@ const int POINT1_NPOINTS = 10; typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; - /*------------------------------------------------------------------------- * Function: test_reference_params * @@ -70,30 +69,31 @@ typedef struct s1_t { * Return None *------------------------------------------------------------------------- */ -static void test_reference_params() +static void +test_reference_params() { const char *write_comment = "Foo!"; /* Comments for group */ // Output message about test being performed SUBTEST("Object Reference Parameters"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + hobj_ref_t *wbuf, // buffer to write to disk + *rbuf, // buffer read from disk + *tbuf; // temp. buffer read from disk // Allocate write & read buffers - int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); - wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t)); + wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a group @@ -105,10 +105,10 @@ static void test_reference_params() // Create a dataset (inside /Group1) DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - unsigned *tu32; // Temporary pointer to uint32 data - int i; - for (tu32=(unsigned *)wbuf, i=0; ireference(NULL, "/Group1/Dataset1"); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], NULL); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], ""); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail // Close resources dataset.close(); @@ -169,17 +179,14 @@ static void test_reference_params() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_param()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_param()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} /* test_reference_param() */ +} /* test_reference_param() */ - /*------------------------------------------------------------------------- * Function: test_reference_obj * @@ -189,31 +196,32 @@ static void test_reference_params() * Return None *------------------------------------------------------------------------- */ -static void test_reference_obj() +static void +test_reference_obj() { - int i; // counting variables - const H5std_string write_comment="Foo!"; // Comments for group + int i; // counting variables + const H5std_string write_comment = "Foo!"; // Comments for group // Output message about test being performed SUBTEST("Object Reference Functions"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + hobj_ref_t *wbuf, // buffer to write to disk + *rbuf, // buffer read from disk + *tbuf; // temp. buffer read from disk // Allocate write & read buffers - int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); - wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t)); + wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create dataset access property list @@ -228,9 +236,9 @@ static void test_reference_obj() // Create a dataset (inside /Group1) DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - unsigned *tu32; // Temporary pointer to uint32 data + unsigned *tu32; // Temporary pointer to uint32 data for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++=i*3; // from C test + *tu32++ = i * 3; // from C test // Write selection to disk dataset.write(wbuf, PredType::NATIVE_UINT); @@ -265,22 +273,22 @@ static void test_reference_obj() // Create reference to dataset and test getRefObjType file1->reference(&wbuf[0], "/Group1/Dataset1"); H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to dataset and test getRefObjType file1->reference(&wbuf[1], "/Group1/Dataset2"); refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to group file1->reference(&wbuf[2], "/Group1"); refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to named datatype file1->reference(&wbuf[3], "/Group1/Datatype1"); refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType", __LINE__, __FILE__); // Write selection to disk dataset.write(wbuf, PredType::STD_REF_OBJ); @@ -304,15 +312,15 @@ static void test_reference_obj() DataSet dset2(dataset, &rbuf[0], H5R_OBJECT, dapl); // Check information in the referenced dataset - sid1 = dset2.getSpace(); + sid1 = dset2.getSpace(); hssize_t n_elements = sid1.getSimpleExtentNpoints(); - verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Read from disk dset2.read(tbuf, PredType::NATIVE_UINT); - for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - verify_val(*tu32, (uint32_t)(i*3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + for (tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) + verify_val(*tu32, (uint32_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Close dereferenced dataset dset2.close(); @@ -323,18 +331,19 @@ static void test_reference_obj() // Get group's comment using // H5std_string getComment(const char* name, ) H5std_string read_comment1 = group.getComment(".", 10); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__); // Test with the old default value read_comment1 = group.getComment(".", 256); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__); // Test that getComment handles failures gracefully, using // H5std_string getComment(const char* name, ) try { H5std_string read_comment_tmp = group.getComment(NULL); } - catch (Exception& E) {} // We expect this to fail + catch (Exception &E) { + } // We expect this to fail // Close group group.close(); @@ -349,9 +358,9 @@ static void test_reference_obj() H5T_class_t tclass; tclass = dtype1.getClass(); - verify_val(tclass, H5T_COMPOUND, "DataType::getClass",__LINE__,__FILE__); + verify_val(tclass, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__); int n_members = dtype1.getNmembers(); - verify_val(n_members, 3, "CompType::getNmembers",__LINE__,__FILE__); + verify_val(n_members, 3, "CompType::getNmembers", __LINE__, __FILE__); // Close all objects and file dtype1.close(); @@ -365,17 +374,14 @@ static void test_reference_obj() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} // test_reference_obj() +} // test_reference_obj() - /*------------------------------------------------------------------------- * Function: test_reference_group * @@ -384,23 +390,24 @@ static void test_reference_obj() * Return None *------------------------------------------------------------------------- */ -#define GROUPNAME "/group" -#define GROUPNAME2 "group2" -#define GROUPNAME3 "group3" -#define DSETNAME "/dset" -#define DSETNAME2 "dset2" -#define NAME_SIZE 16 - -static void test_reference_group() +#define GROUPNAME "/group" +#define GROUPNAME2 "group2" +#define GROUPNAME3 "group3" +#define DSETNAME "/dset" +#define DSETNAME2 "dset2" +#define NAME_SIZE 16 + +static void +test_reference_group() { - hobj_ref_t wref; /* Reference to write */ - hobj_ref_t rref; /* Reference to read */ - const H5std_string write_comment="Foo!"; // Comments for group + hobj_ref_t wref; /* Reference to write */ + hobj_ref_t rref; /* Reference to read */ + const H5std_string write_comment = "Foo!"; // Comments for group // Output message about test being performed SUBTEST("Object Reference to Group"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { /* * Create file with a group and a dataset containing an object @@ -408,7 +415,7 @@ static void test_reference_group() */ // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create scalar dataspace DataSpace sid1; @@ -467,25 +474,25 @@ static void test_reference_group() // Check number of objects in the group dereferenced by constructor hsize_t nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check number of objects in the group dereferenced by ::reference nobjs = group.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check getting file name given the group dereferenced via constructor H5std_string fname = refgroup.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); + verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__); // Check getting file name given the group dereferenced by ::reference fname = group.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); + verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__); // Check object type using Group::getObjinfo() H5O_info2_t oinfo; HDmemset(&oinfo, 0, sizeof(oinfo)); group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, oinfo); - verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo",__LINE__,__FILE__); + verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo", __LINE__, __FILE__); // Check for out of bound query by index try { @@ -494,12 +501,14 @@ static void test_reference_group() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjinfo", "Out of bound index."); - } catch (Exception& err) {} // do nothing, failure expected + } + catch (Exception &err) { + } // do nothing, failure expected // Unlink one of the objects in the dereferenced group, and re-check refgroup.unlink(GROUPNAME2); nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs", __LINE__, __FILE__); // Close resources group.close(); @@ -509,17 +518,14 @@ static void test_reference_group() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_group()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_group()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} /* test_reference_group() */ +} /* test_reference_group() */ - /*------------------------------------------------------------------------- * Function: test_reference_region_1D * @@ -528,30 +534,31 @@ static void test_reference_group() * Return None *------------------------------------------------------------------------- */ -static void test_reference_region_1D() +static void +test_reference_region_1D() { - hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ - hsize_t * coords; /* Coordinate buffer */ - hsize_t low[SPACE3_RANK]; /* Selection bounds */ - hsize_t high[SPACE3_RANK]; /* Selection bounds */ - int i; /* counting variables */ + hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ + hsize_t *coords; /* Coordinate buffer */ + hsize_t low[SPACE3_RANK]; /* Selection bounds */ + hsize_t high[SPACE3_RANK]; /* Selection bounds */ + int i; /* counting variables */ // Output message about test being performed SUBTEST("1-D Dataset Region Reference Functions"); try { - hdset_reg_ref_t *wbuf, // buffer to write to disk - *rbuf; // buffer read from disk - uint8_t *dwbuf, // Buffer for writing numeric data to disk - *drbuf; // Buffer for reading numeric data from disk + hdset_reg_ref_t *wbuf, // buffer to write to disk + *rbuf; // buffer read from disk + uint8_t *dwbuf, // Buffer for writing numeric data to disk + *drbuf; // Buffer for reading numeric data from disk // Allocate write & read buffers - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); @@ -559,7 +566,7 @@ static void test_reference_region_1D() H5File file1(FILE2, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims3[] = {SPACE3_DIM1}; + hsize_t dims3[] = {SPACE3_DIM1}; DataSpace sid3(SPACE3_RANK, dims3); // Create dataset access property list @@ -568,7 +575,7 @@ static void test_reference_region_1D() // Create a dataset DataSet dset3 = file1.createDataSet(DSET2_NAME, PredType::STD_U8LE, sid3); - uint8_t *tu8; // Temporary pointer to uint8 data + uint8_t *tu8; // Temporary pointer to uint8 data for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) *tu8++ = i * 3; // from C test @@ -579,7 +586,7 @@ static void test_reference_region_1D() dset3.close(); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset @@ -590,24 +597,24 @@ static void test_reference_region_1D() */ /* Select 15 2x1 hyperslabs for first reference */ - start[0] = 2; + start[0] = 2; stride[0] = 5; - count[0] = 15; - block[0] = 2; + count[0] = 15; + block[0] = 2; // Select a hyperslab region to add to the current selected region sid3.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); // Get and verify the number of elements in a dataspace selection hssize_t nelms = sid3.getSelectNpoints(); - verify_val(nelms, 30, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(nelms, 30, "DataSet::getRefObjType", __LINE__, __FILE__); // Store first dataset region file1.reference(&wbuf[0], "/Dataset2", sid3); // Get and verify object type H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); /* Select sequence of ten points for second reference */ coord1[0][0] = 16; @@ -626,7 +633,7 @@ static void test_reference_region_1D() // Get and verify the number of elements in a dataspace selection nelms = sid3.getSelectNpoints(); - verify_val(nelms, 10, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(nelms, 10, "DataSet::getRefObjType", __LINE__, __FILE__); // Store first dataset region file1.reference(&wbuf[1], "/Dataset2", sid3); @@ -658,12 +665,12 @@ static void test_reference_region_1D() // Get and verify object type obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Get dataspace of dset3 the verify number of elements - sid1 = dset3.getSpace(); + sid1 = dset3.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); } // End of test DataSet::dereference { // Test DataSet constructor -by dereference @@ -672,9 +679,9 @@ static void test_reference_region_1D() DataSet newds(dset1, &rbuf[0], H5R_DATASET_REGION, dapl); // Get dataspace of newds then verify number of elements - sid1 = newds.getSpace(); + sid1 = newds.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Close objects for this mini test newds.close(); @@ -684,8 +691,8 @@ static void test_reference_region_1D() // Read from disk dset3.read(drbuf, PredType::STD_U8LE); - for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) - verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + for (tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) + verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); /* * Test getting the referenced region @@ -696,11 +703,11 @@ static void test_reference_region_1D() // Get and verify number of elements in a dataspace selection nelms = reg_sp.getSelectNpoints(); - verify_val((long)nelms, 30, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 30, "DataSpace::getSelectNpoints", __LINE__, __FILE__); // Get and verify number of hyperslab blocks nelms = reg_sp.getSelectHyperNblocks(); - verify_val((long)nelms, 15, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 15, "DataSpace::getSelectNpoints", __LINE__, __FILE__); /* Allocate space for the hyperslab blocks */ coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2); @@ -709,43 +716,43 @@ static void test_reference_region_1D() reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords); // Verify values in the list - verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[4],(hsize_t)12, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[5],(hsize_t)13, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[6],(hsize_t)17, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[7],(hsize_t)18, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[8],(hsize_t)22, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[9],(hsize_t)23, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[10],(hsize_t)27, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[11],(hsize_t)28, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[12],(hsize_t)32, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[13],(hsize_t)33, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[14],(hsize_t)37, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[15],(hsize_t)38, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[16],(hsize_t)42, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[17],(hsize_t)43, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[18],(hsize_t)47, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[19],(hsize_t)48, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[20],(hsize_t)52, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[21],(hsize_t)53, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[22],(hsize_t)57, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[23],(hsize_t)58, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[24],(hsize_t)62, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[25],(hsize_t)63, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[26],(hsize_t)67, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[27],(hsize_t)68, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[28],(hsize_t)72, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[29],(hsize_t)73, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[4], (hsize_t)12, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[5], (hsize_t)13, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[6], (hsize_t)17, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[7], (hsize_t)18, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[8], (hsize_t)22, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[9], (hsize_t)23, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[10], (hsize_t)27, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[11], (hsize_t)28, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[12], (hsize_t)32, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[13], (hsize_t)33, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[14], (hsize_t)37, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[15], (hsize_t)38, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[16], (hsize_t)42, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[17], (hsize_t)43, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[18], (hsize_t)47, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[19], (hsize_t)48, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[20], (hsize_t)52, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[21], (hsize_t)53, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[22], (hsize_t)57, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[23], (hsize_t)58, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[24], (hsize_t)62, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[25], (hsize_t)63, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[26], (hsize_t)67, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[27], (hsize_t)68, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[28], (hsize_t)72, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[29], (hsize_t)73, "Hyperslab Coordinates", __LINE__, __FILE__); HDfree(coords); // Check boundaries reg_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)2, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)73, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0], (hsize_t)2, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(high[0], (hsize_t)73, "DataSpace::getSelectBounds", __LINE__, __FILE__); /* Close region space */ reg_sp.close(); @@ -759,7 +766,7 @@ static void test_reference_region_1D() // Get and verify number of element points in the current selection hssize_t nelmspts = elm_sp.getSelectElemNpoints(); - verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints", __LINE__, __FILE__); /* Allocate space for the hyperslab blocks */ coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t)); @@ -768,23 +775,23 @@ static void test_reference_region_1D() elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords); // Verify points - verify_val(coords[0], coord1[0][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[1], coord1[1][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[2], coord1[2][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[3], coord1[3][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[4], coord1[4][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[5], coord1[5][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[6], coord1[6][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[7], coord1[7][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[8], coord1[8][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[9], coord1[9][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[0], coord1[0][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[1], coord1[1][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[2], coord1[2][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[3], coord1[3][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[4], coord1[4][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[5], coord1[5][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[6], coord1[6][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[7], coord1[7][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[8], coord1[8][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[9], coord1[9][0], "Element Coordinates", __LINE__, __FILE__); HDfree(coords); // Check boundaries elm_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)3, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)97, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0], (hsize_t)3, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(high[0], (hsize_t)97, "DataSpace::getSelectBounds", __LINE__, __FILE__); // Close element space elm_sp.close(); @@ -803,12 +810,10 @@ static void test_reference_region_1D() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_region_1D()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } -} /* test_reference_region_1D() */ +} /* test_reference_region_1D() */ /*------------------------------------------------------------------------- * @@ -816,8 +821,8 @@ static void test_reference_region_1D() * *------------------------------------------------------------------------- */ -extern "C" -void test_reference() +extern "C" void +test_reference() { // Output message about test being performed MESSAGE(5, ("Testing References\n")); @@ -827,9 +832,8 @@ void test_reference() test_reference_group(); // Test group reference functionality test_reference_region_1D(); // Test 1-D reference functionality -} // test_reference() +} // test_reference() - /*------------------------------------------------------------------------- * Function: cleanup_reference * @@ -838,10 +842,9 @@ void test_reference() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_reference() +extern "C" void +cleanup_reference() { HDremove(FILE1.c_str()); HDremove(FILE2.c_str()); } - diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index b8846f4..7411e37 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -25,17 +25,17 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file /* * Offset from alinged memory returned by malloc(). This can be used to test * that type conversions handle non-aligned buffers correctly. */ -#define ALIGNMENT 1 +#define ALIGNMENT 1 /* * Define if you want to test alignment code on a machine that doesn't @@ -50,35 +50,34 @@ using namespace H5; #define H5T_FRIEND #include "H5Tpkg.h" #endif -#define SET_ALIGNMENT(TYPE,VAL) \ - H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) +#define SET_ALIGNMENT(TYPE, VAL) H5T_NATIVE_##TYPE##_ALIGN_g = MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) #endif - /* #include "H5Tpkg.h" +/* #include "H5Tpkg.h" */ -const char *FILENAME[] = { - "dtypes1.h5", - "dtypes2.h5", - "dtypes3.h5", - "dtypes4.h5", - NULL -}; +const char *FILENAME[] = {"dtypes1.h5", "dtypes2.h5", "dtypes3.h5", "dtypes4.h5", NULL}; /* * Count up or down depending on whether the machine is big endian or little * endian. If local variable `endian' is H5T_ORDER_BE then the result will * be I, otherwise the result will be Z-(I+1). */ -#define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1)) +#define ENDIAN(Z, I) (H5T_ORDER_BE == endian ? (I) : (Z) - ((I) + 1)) - -typedef enum flt_t { - FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER -} flt_t; +typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t; typedef enum int_t { - INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, - INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER + INT_CHAR, + INT_UCHAR, + INT_SHORT, + INT_USHORT, + INT_INT, + INT_UINT, + INT_LONG, + INT_ULONG, + INT_LLONG, + INT_ULLONG, + INT_OTHER } int_t; typedef struct { @@ -88,7 +87,6 @@ typedef struct { double d; } src_typ_t; - /*------------------------------------------------------------------------- * Function: test_classes * @@ -100,7 +98,8 @@ typedef struct { * January, 2007 *------------------------------------------------------------------------- */ -static void test_classes() +static void +test_classes() { SUBTEST("PredType::getClass()"); try { @@ -108,24 +107,23 @@ static void test_classes() // PredType::NATIVE_INT should be in H5T_INTEGER class H5T_class_t tcls = PredType::NATIVE_INT.getClass(); - if (H5T_INTEGER!=tcls) { + if (H5T_INTEGER != tcls) { puts(" Invalid type class for H5T_NATIVE_INT"); } // PredType::NATIVE_DOUBLE should be in H5T_FLOAT class tcls = PredType::NATIVE_DOUBLE.getClass(); - if (H5T_FLOAT!=tcls) { - verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__); + if (H5T_FLOAT != tcls) { + verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, + __FILE__); } PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_copy * @@ -137,7 +135,8 @@ static void test_classes() * January, 2007 *------------------------------------------------------------------------- */ -static void test_copy() +static void +test_copy() { SUBTEST("DataType::copy() and DataType::operator="); @@ -148,7 +147,7 @@ static void test_copy() // Test copying a predefined type using DataType::copy DataType copied_type; - copied_type.copy (PredType::STD_B8LE); + copied_type.copy(PredType::STD_B8LE); // Test copying a user-defined type using DataType::operator= DataType assigned_usertype; @@ -159,7 +158,7 @@ static void test_copy() copied_usertype.copy(copied_type); // Test copying a user-defined int type using DataType::operator= - IntType orig_int(PredType::STD_B8LE); + IntType orig_int(PredType::STD_B8LE); DataType generic_type; generic_type = orig_int; @@ -172,13 +171,11 @@ static void test_copy() PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_detect_type_class * @@ -190,29 +187,30 @@ static void test_copy() * August, 2017 *------------------------------------------------------------------------- */ -typedef struct { /* Struct with atomic fields */ - int i; - float f; - char c; - double d; - short s; +typedef struct { /* Struct with atomic fields */ + int i; + float f; + char c; + double d; + short s; } atomic_typ_t; -typedef struct { /* Struct with complex fields */ - hobj_ref_t arr_r[3][3]; - int i; - hvl_t vl_f; - hvl_t vl_s; - char c; - short s; +typedef struct { /* Struct with complex fields */ + hobj_ref_t arr_r[3][3]; + int i; + hvl_t vl_f; + hvl_t vl_s; + char c; + short s; } complex_typ_t; -static void test_detect_type_class() +static void +test_detect_type_class() { SUBTEST("DataType::detectClass()"); try { - bool in_class = false; // indicates whether a datatype is in a class + bool in_class = false; // indicates whether a datatype is in a class /* * Test class of some atomic types. @@ -260,8 +258,8 @@ static void test_detect_type_class() */ // Create an array datatype with an atomic base type - unsigned rank = 2; // Rank for array datatype - hsize_t dims[2] = {3,3}; // Dimensions for array datatype + unsigned rank = 2; // Rank for array datatype + hsize_t dims[2] = {3, 3}; // Dimensions for array datatype ArrayType atom_arr(PredType::STD_REF_OBJ, rank, dims); // Make certain that the correct classes can be detected @@ -367,13 +365,11 @@ static void test_detect_type_class() PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_detect_type_class", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_vltype * @@ -385,12 +381,12 @@ static void test_detect_type_class() * August, 2017 *------------------------------------------------------------------------- */ -static void test_vltype() +static void +test_vltype() { // Output message about test being performed SUBTEST("VarLenType functions"); - try - { + try { VarLenType vltype(PredType::NATIVE_INT); bool in_class = vltype.detectClass(H5T_VLEN); @@ -408,9 +404,11 @@ static void test_vltype() in_class = vltype2.detectClass(H5T_VLEN); verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__); in_class = vltype2.detectClass(H5T_INTEGER); - verify_val(in_class, true, "VarLenType::detectClass() with H5T_INTEGER for vltype2", __LINE__, __FILE__); + verify_val(in_class, true, "VarLenType::detectClass() with H5T_INTEGER for vltype2", __LINE__, + __FILE__); in_class = vltype2.detectClass(H5T_FLOAT); - verify_val(in_class, false, "VarLenType::detectClass() with H5T_FLOAT for vltype2", __LINE__, __FILE__); + verify_val(in_class, false, "VarLenType::detectClass() with H5T_FLOAT for vltype2", __LINE__, + __FILE__); // Create a new file to use in this test H5File file(FILENAME[3], H5F_ACC_TRUNC); @@ -435,17 +433,16 @@ static void test_vltype() in_class = vltype2.detectClass(H5T_VLEN); verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__); in_class = first_vlt_again.detectClass(H5T_FLOAT); - verify_val(in_class, true, "VarLenType::detectClass() with H5T_FLOAT for first_vlt_again", __LINE__, __FILE__); + verify_val(in_class, true, "VarLenType::detectClass() with H5T_FLOAT for first_vlt_again", __LINE__, + __FILE__); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_vltype", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_vltype +} // test_vltype - /*------------------------------------------------------------------------- * Function: test_query * @@ -460,14 +457,14 @@ static void test_vltype() const H5std_string CompT_NAME("Compound_type"); const H5std_string EnumT_NAME("Enum_type"); -static void test_query() +static void +test_query() { - short enum_val; + short enum_val; // Output message about test being performed SUBTEST("Query functions of compound and enumeration types"); - try - { + try { // Create File H5File file(FILENAME[2], H5F_ACC_TRUNC); @@ -482,11 +479,11 @@ static void test_query() // Create a enumerate datatype EnumType tid2(sizeof(short)); - tid2.insert("RED", (enum_val=0,&enum_val)); - tid2.insert("GREEN", (enum_val=1,&enum_val)); - tid2.insert("BLUE", (enum_val=2,&enum_val)); - tid2.insert("ORANGE", (enum_val=3,&enum_val)); - tid2.insert("YELLOW", (enum_val=4,&enum_val)); + tid2.insert("RED", (enum_val = 0, &enum_val)); + tid2.insert("GREEN", (enum_val = 1, &enum_val)); + tid2.insert("BLUE", (enum_val = 2, &enum_val)); + tid2.insert("ORANGE", (enum_val = 3, &enum_val)); + tid2.insert("YELLOW", (enum_val = 4, &enum_val)); // Query member number and member index by name, for compound type int nmembs = tid1.getNmembers(); @@ -506,10 +503,10 @@ static void test_query() // prop list, then close it tid1.commit(file, CompT_NAME); PropList tcpl = tid1.getCreatePlist(); - if (!IdComponent::isValid(tcpl.getId())) - { + if (!IdComponent::isValid(tcpl.getId())) { // Throw an invalid action exception - throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid"); + throw InvalidActionException("H5Object::createAttribute", + "Datatype creation property list is not valid"); } tcpl.close(); tid1.close(); @@ -518,10 +515,10 @@ static void test_query() // prop list, then close it tid2.commit(file, EnumT_NAME); tcpl = tid2.getCreatePlist(); - if (!IdComponent::isValid(tcpl.getId())) - { + if (!IdComponent::isValid(tcpl.getId())) { // Throw an invalid action exception - throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid"); + throw InvalidActionException("H5Object::createAttribute", + "Datatype creation property list is not valid"); } tcpl.close(); tid2.close(); @@ -560,14 +557,12 @@ static void test_query() H5File file1(FILENAME[2], H5F_ACC_TRUNC); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_query +} // test_query - /*------------------------------------------------------------------------- * Function: test_transient * @@ -579,17 +574,18 @@ static void test_query() * January, 2007 *------------------------------------------------------------------------- */ -const char* filename1 = "dtypes1.h5"; +const char *filename1 = "dtypes1.h5"; -static void test_transient () +static void +test_transient() { - static hsize_t ds_size[2] = {10, 20}; + static hsize_t ds_size[2] = {10, 20}; SUBTEST("Transient datatypes"); try { // Create the file and the dataspace. - H5File file(filename1, H5F_ACC_TRUNC); + H5File file(filename1, H5F_ACC_TRUNC); DataSpace space(2, ds_size, ds_size); // Copying a predefined type results in a modifiable copy @@ -600,8 +596,11 @@ static void test_transient () try { Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space)); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype."); - } catch (AttributeIException& err) {} // do nothing, failure expected + throw InvalidActionException("H5Object::createAttribute", + "Attempted to commit a predefined datatype."); + } + catch (AttributeIException &err) { + } // do nothing, failure expected // Create a dataset from a transient datatype // type.close(); - put trace in H5Tclose to make sure it's closed @@ -614,8 +613,11 @@ static void test_transient () itype.setPrecision(256); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!"); - } catch (DataTypeIException& err) {} + throw InvalidActionException("PredType::setPrecision", + "Dataset datatypes should not be modifiable!"); + } + catch (DataTypeIException &err) { + } itype.close(); // Get a copy of the dataset's datatype by applying DataType::copy() @@ -635,14 +637,12 @@ static void test_transient () type.close(); space.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_transient", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_transient +} // test_transient - /*------------------------------------------------------------------------- * Function: test_named * @@ -656,12 +656,13 @@ static void test_transient () */ const H5std_string filename2("dtypes2.h5"); -static void test_named () +static void +test_named() { static hsize_t ds_size[2] = {10, 20}; - hsize_t i; - unsigned attr_data[10][20]; - DataType *ds_type = NULL; + hsize_t i; + unsigned attr_data[10][20]; + DataType * ds_type = NULL; SUBTEST("Named datatypes"); try { @@ -678,15 +679,16 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype."); - } catch (DataTypeIException& err) {} + } + catch (DataTypeIException &err) { + } // Copy a predefined datatype and commit the copy. IntType itype(PredType::NATIVE_INT); itype.commit(file, "native-int"); // Test commit passing in const H5File& for prototype with const - try - { + try { // Create random char type IntType atype(PredType::NATIVE_UCHAR); @@ -696,9 +698,8 @@ static void test_named () // Commit type passing in const group; compilation would fail if // no matching prototype atype.commit(const_grp, "random uchar"); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group"); } @@ -708,11 +709,14 @@ static void test_named () // We should not be able to modify a type after it has been committed. try { - itype.setPrecision(256); // attempt an invalid action... + itype.setPrecision(256); // attempt an invalid action... // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype."); - } catch (DataTypeIException& err) {} + throw InvalidActionException("IntType::setPrecision", + "Attempted to modify a committed datatype."); + } + catch (DataTypeIException &err) { + } // We should not be able to re-commit a committed type try { @@ -720,12 +724,14 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype."); - } catch (DataTypeIException& err) {} // do nothing, failure expected + } + catch (DataTypeIException &err) { + } // do nothing, failure expected // It should be possible to define an attribute for the named type Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); - for (i=0; icommitted(); + ds_type = new DataType(dset.getDataType()); + iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); dset.close(); @@ -758,8 +766,8 @@ static void test_named () // Reopen the dataset and its type, then make sure the type is // a named type. - dset = file.openDataSet("dset1"); - ds_type = new DataType(dset.getDataType()); + dset = file.openDataSet("dset1"); + ds_type = new DataType(dset.getDataType()); iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); @@ -773,8 +781,8 @@ static void test_named () delete ds_type; // Reopen the second dataset and make sure the type is shared - dset = file.openDataSet("dset2"); - ds_type = new DataType(dset.getDataType()); + dset = file.openDataSet("dset2"); + ds_type = new DataType(dset.getDataType()); iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("DataType::iscommitted()", "Dataset type should be named type!"); @@ -793,17 +801,15 @@ static void test_named () space.close(); file.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg()); } - if(ds_type) + if (ds_type) delete ds_type; -} // test_named +} // test_named - /*------------------------------------------------------------------------- * Function: test_encode_decode * @@ -816,12 +822,13 @@ static void test_named () *------------------------------------------------------------------------- */ const H5std_string filename3("encode_decode.h5"); -const int ARRAY1_RANK = 1; -const int ARRAY1_DIM = 10; +const int ARRAY1_RANK = 1; +const int ARRAY1_DIM = 10; -static void test_encode_decode() +static void +test_encode_decode() { - short enum_val; + short enum_val; SUBTEST("DataType::encode() and DataType::decode()"); try { @@ -847,7 +854,7 @@ static void test_encode_decode() verify_val(cmptyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode compound type's buffer to a new CompType - CompType* decoded_cmp_ptr(static_cast(cmptyp.decode())); + CompType *decoded_cmp_ptr(static_cast(cmptyp.decode())); // Verify that the datatype was copied exactly via encoding/decoding verify_val(cmptyp == *decoded_cmp_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -871,11 +878,11 @@ static void test_encode_decode() // Create a enumerate datatype EnumType enumtyp(sizeof(short)); - enumtyp.insert("RED", (enum_val=0,&enum_val)); - enumtyp.insert("GREEN", (enum_val=1,&enum_val)); - enumtyp.insert("BLUE", (enum_val=2,&enum_val)); - enumtyp.insert("ORANGE", (enum_val=3,&enum_val)); - enumtyp.insert("YELLOW", (enum_val=4,&enum_val)); + enumtyp.insert("RED", (enum_val = 0, &enum_val)); + enumtyp.insert("GREEN", (enum_val = 1, &enum_val)); + enumtyp.insert("BLUE", (enum_val = 2, &enum_val)); + enumtyp.insert("ORANGE", (enum_val = 3, &enum_val)); + enumtyp.insert("YELLOW", (enum_val = 4, &enum_val)); // Encode compound type in a buffer enumtyp.encode(); @@ -884,7 +891,7 @@ static void test_encode_decode() verify_val(enumtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode enumeration type's buffer to a new EnumType - EnumType* decoded_enum_ptr(static_cast(enumtyp.decode())); + EnumType *decoded_enum_ptr(static_cast(enumtyp.decode())); // Verify that the datatype was copied exactly via encoding/decoding verify_val(enumtyp == *decoded_enum_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -916,7 +923,7 @@ static void test_encode_decode() verify_val(vlsttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode the variable-length type's buffer to a new StrType - StrType* decoded_str_ptr(static_cast(vlsttyp.decode())); + StrType *decoded_str_ptr(static_cast(vlsttyp.decode())); verify_val(vlsttyp == *decoded_str_ptr, true, "DataType::decode", __LINE__, __FILE__); verify_val(decoded_str_ptr->isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); @@ -926,7 +933,7 @@ static void test_encode_decode() // Test decoding the type by way of DataType* // Decode variable-length string type to a new DataType - DataType* decoded_vlstr_ptr(vlsttyp.decode()); + DataType *decoded_vlstr_ptr(vlsttyp.decode()); // Create a StrType instance from the DataType object and verify it StrType decoded_vlsttyp(decoded_vlstr_ptr->getId()); @@ -951,7 +958,7 @@ static void test_encode_decode() verify_val(arrtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Create an ArrayType instance from the decoded pointer and verify it - ArrayType* decoded_arr_ptr(static_cast(arrtyp.decode())); + ArrayType *decoded_arr_ptr(static_cast(arrtyp.decode())); verify_val(arrtyp == *decoded_arr_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -983,7 +990,7 @@ static void test_encode_decode() verify_val(inttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Create an IntType instance from the decoded pointer and verify it - IntType* decoded_int_ptr(static_cast(inttyp.decode())); + IntType * decoded_int_ptr(static_cast(inttyp.decode())); H5T_sign_t int_sign = decoded_int_ptr->getSign(); verify_val(int_sign, H5T_SGN_NONE, "DataType::decode", __LINE__, __FILE__); verify_val(inttyp == *decoded_int_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -1004,27 +1011,25 @@ static void test_encode_decode() verify_val(flttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode the array type's buffer - DataType* decoded_flt_ptr(flttyp.decode()); + DataType *decoded_flt_ptr(flttyp.decode()); // Create a IntType instance from the decoded pointer and verify it FloatType decoded_flttyp(decoded_flt_ptr->getId()); verify_val(flttyp == decoded_flttyp, true, "DataType::decode", __LINE__, __FILE__); - //H5std_string norm_string; - //H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string); - //verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); + // H5std_string norm_string; + // H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string); + // verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); delete decoded_flt_ptr; PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_encode_decode", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_operators * @@ -1038,9 +1043,10 @@ static void test_encode_decode() */ const H5std_string filename4("h5_type_operators.h5"); -static void test_operators() +static void +test_operators() { - short enum_val; + short enum_val; SUBTEST("DataType::operator== and DataType::operator!="); try { @@ -1073,9 +1079,9 @@ static void test_operators() // Create an enumerate datatype EnumType enumtyp(sizeof(short)); - enumtyp.insert("RED", (enum_val=0,&enum_val)); - enumtyp.insert("GREEN", (enum_val=1,&enum_val)); - enumtyp.insert("BLUE", (enum_val=2,&enum_val)); + enumtyp.insert("RED", (enum_val = 0, &enum_val)); + enumtyp.insert("GREEN", (enum_val = 1, &enum_val)); + enumtyp.insert("BLUE", (enum_val = 2, &enum_val)); // Verify that operator== and operator!= work properly verify_val(cmptyp == enumtyp, false, "DataType::operator==", __LINE__, __FILE__); @@ -1086,7 +1092,7 @@ static void test_operators() // // Create random atomic datatypes - IntType inttyp(PredType::NATIVE_INT); + IntType inttyp(PredType::NATIVE_INT); FloatType flttyp(PredType::NATIVE_FLOAT); // Get the NATIVE_INT member from the compound datatype above @@ -1106,13 +1112,11 @@ static void test_operators() PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_operators", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_operators +} // test_operators - /*------------------------------------------------------------------------- * Function: test_types * @@ -1121,8 +1125,8 @@ static void test_operators() * Return None *------------------------------------------------------------------------- */ -extern "C" -void test_types() +extern "C" void +test_types() { // Output message about test being performed MESSAGE(5, ("Testing Generic Data Types\n")); @@ -1138,9 +1142,8 @@ void test_types() test_encode_decode(); test_operators(); -} // test_types() +} // test_types() - /*------------------------------------------------------------------------- * Function: cleanup_types * @@ -1149,9 +1152,9 @@ void test_types() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_types() +extern "C" void +cleanup_types() { for (int i = 0; i < 3; i++) HDremove(FILENAME[i]); -} // cleanup_types +} // cleanup_types diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 2421a87..8f0c0ab 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -27,17 +27,17 @@ using std::cerr; using std::endl; #include -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file // Data file used in most test functions const H5std_string FILENAME("tvlstr.h5"); // 1-D dataset with fixed dimensions -const int SPACE1_RANK = 1; +const int SPACE1_RANK = 1; const hsize_t SPACE1_DIM1 = 4; /*------------------------------------------------------------------------- @@ -137,10 +137,11 @@ static void test_vlstr_free_custom(void *_mem, void *info) const H5std_string DSET1_NAME("String_ds"); const H5std_string DSET1_DATA("String Dataset"); -static void test_vlstring_dataset() +static void +test_vlstring_dataset() { char *dynstring_ds_write = NULL; - char *string_ds_check = NULL; + char *string_ds_check = NULL; // Output message about test being performed SUBTEST("VL String on Datasets"); @@ -156,7 +157,7 @@ static void test_vlstring_dataset() Group root = file1.openGroup("/"); // Create dataspace for the dataset. - DataSpace ds_space (H5S_SCALAR); + DataSpace ds_space(H5S_SCALAR); // Create an dataset in the root group. DataSet dset1 = root.createDataSet(DSET1_NAME, vlst, ds_space); @@ -166,17 +167,19 @@ static void test_vlstring_dataset() // Read and verify the dataset string as a string of chars. dset1.read(&string_ds_check, vlst); - if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check); + if (HDstrcmp(string_ds_check, DSET1_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n", __LINE__, + DSET1_DATA.c_str(), string_ds_check); - HDfree(string_ds_check); // note: no need for std::string test + HDfree(string_ds_check); // note: no need for std::string test string_ds_check = NULL; // Read and verify the dataset string as an std::string. H5std_string read_str; dset1.read(read_str, vlst); if (read_str != DSET1_DATA) - TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n",__LINE__, DSET1_DATA.c_str(), read_str.c_str()); + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n", __LINE__, + DSET1_DATA.c_str(), read_str.c_str()); // Close the dataset. dset1.close(); @@ -184,7 +187,7 @@ static void test_vlstring_dataset() // Test scalar type dataset with 1 value. dset1 = root.createDataSet("test_scalar_small", vlst, ds_space); - dynstring_ds_write = (char*)HDcalloc(1, sizeof(char)); + dynstring_ds_write = (char *)HDcalloc(1, sizeof(char)); HDmemset(dynstring_ds_write, 'A', 1); // Write data to the dataset, then read it back. @@ -192,8 +195,9 @@ static void test_vlstring_dataset() dset1.read(&string_ds_check, vlst); // Verify data read. - if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0) - TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check); + if (HDstrcmp(string_ds_check, dynstring_ds_write) != 0) + TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n", + dynstring_ds_write, string_ds_check); HDfree(string_ds_check); string_ds_check = NULL; dset1.close(); @@ -209,16 +213,15 @@ static void test_vlstring_dataset() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } - if(dynstring_ds_write) + if (dynstring_ds_write) HDfree(dynstring_ds_write); - if(string_ds_check) + if (string_ds_check) HDfree(string_ds_check); -} // test_vlstring_dataset() +} // test_vlstring_dataset() /*------------------------------------------------------------------------- * Function: test_vlstring_array_dataset @@ -234,22 +237,22 @@ static void test_vlstring_dataset() */ const H5std_string DSSTRARR_NAME("StringArray_dset"); -static void test_vlstring_array_dataset() +static void +test_vlstring_array_dataset() { - const char *string_ds_array[SPACE1_DIM1]= { - "Line 1", "Line 2", "Line 3", "Line 4" - }; // Information to write + const char *string_ds_array[SPACE1_DIM1] = {"Line 1", "Line 2", "Line 3", + "Line 4"}; // Information to write // Output message about test being performed SUBTEST("VL String Array on Datasets"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { // Create file. file1 = new H5File(FILENAME, H5F_ACC_RDWR); // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace ds_space(SPACE1_RANK, dims1); // Create a datatype to refer to. @@ -265,10 +268,10 @@ static void test_vlstring_array_dataset() dataset.read(string_ds_check, vlst); hsize_t ii; - for (ii = 0; ii < SPACE1_DIM1; ii++) - { - if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) { + if (HDstrcmp(string_ds_check[ii], string_ds_array[ii]) != 0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__, + string_ds_array[ii], string_ds_check[ii]); HDfree(string_ds_check[ii]); } @@ -286,14 +289,14 @@ static void test_vlstring_array_dataset() // Create and write another dataset. DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space)); - char *wdata2 = (char*)HDcalloc(65534, sizeof(char)); + char * wdata2 = (char *)HDcalloc(65534, sizeof(char)); HDmemset(wdata2, 'A', 65533); dataset2.write(&wdata2, vlst); char *rdata2; dataset2.read(&rdata2, vlst); - if (HDstrcmp(wdata2, rdata2)!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2); + if (HDstrcmp(wdata2, rdata2) != 0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__, wdata2, rdata2); // Release resources from second dataset operation. scalar_space.close(); @@ -310,12 +313,11 @@ static void test_vlstring_array_dataset() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; } // end test_vlstring_array_dataset() @@ -332,11 +334,12 @@ static void test_vlstring_array_dataset() * *------------------------------------------------------------------------- */ -static void test_vlstrings_special() +static void +test_vlstrings_special() { - const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"}; + const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"}; const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL}; - char *rdata[SPACE1_DIM1]; // Information read in + char * rdata[SPACE1_DIM1]; // Information read in // Output message about test being performed. SUBTEST("Special VL Strings"); @@ -346,7 +349,7 @@ static void test_vlstrings_special() H5File file1(FILENAME, H5F_ACC_TRUNC); // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a datatype to refer to. @@ -360,30 +363,29 @@ static void test_vlstrings_special() // Check data read in. hsize_t ii; // counting variable - for (ii=0; iidataset); - hid_t ds; - int32_t data[DATAROWS][DATACOLS]; - herr_t status; - unsigned int i, j; - - for (i = 0; i < __arraycount(data); i++) { - for (j = 0; j < __arraycount(data[i]); j++) { - int k = (didx + j + i) % __arraycount(data[i]); - data[i][j] = (0 <= k && k < 3) ? 1 : 0; - if (s->verbose > 1) - fprintf(stderr, " %" PRId32, data[i][j]); - } - if (s->verbose > 1) - fprintf(stderr, "\n"); - } - - ds = s->dataset[didx % ndatasets]; - status = H5Dwrite(ds, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data); - - if (status < 0) - errx(EXIT_FAILURE, "H5Dwrite failed"); - - if (H5Dflush(ds) < 0) - errx(EXIT_FAILURE, "H5Dflush failed"); + const int ndatasets = __arraycount(s->dataset); + hid_t ds; + int32_t data[DATAROWS][DATACOLS]; + herr_t status; + unsigned int i, j; + + for (i = 0; i < __arraycount(data); i++) { + for (j = 0; j < __arraycount(data[i]); j++) { + int k = (didx + j + i) % __arraycount(data[i]); + data[i][j] = (0 <= k && k < 3) ? 1 : 0; + if (s->verbose > 1) + fprintf(stderr, " %" PRId32, data[i][j]); + } + if (s->verbose > 1) + fprintf(stderr, "\n"); + } + + ds = s->dataset[didx % ndatasets]; + status = H5Dwrite(ds, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + + if (status < 0) + errx(EXIT_FAILURE, "H5Dwrite failed"); + + if (H5Dflush(ds) < 0) + errx(EXIT_FAILURE, "H5Dflush failed"); } static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-u milliseconds]\n" - "\n" - "-o: oneshot mode, perform one iteration, wait for a signal, " - "then quit.\n" - "-s: print statistics at end\n" - "-S: disable VFD SWMR mode\n" - "-u ms: milliseconds interval between updates to %s.h5\n" - "-v: verbose mode, mention creation/deletion; -vv: print data\n" - "\n", - progname, progname); - exit(EXIT_FAILURE); + fprintf(stderr, + "usage: %s [-u milliseconds]\n" + "\n" + "-o: oneshot mode, perform one iteration, wait for a signal, " + "then quit.\n" + "-s: print statistics at end\n" + "-S: disable VFD SWMR mode\n" + "-u ms: milliseconds interval between updates to %s.h5\n" + "-v: verbose mode, mention creation/deletion; -vv: print data\n" + "\n", + progname, progname); + exit(EXIT_FAILURE); } static void print_stats(stats_t *s) { - printf("%10" PRIu64 " groups created\n", s->groups.created); - printf("%10" PRIu64 " groups deleted\n", s->groups.deleted); - printf("%10" PRIu64 " datasets created\n", s->datasets.created); - printf("%10" PRIu64 " datasets deleted\n", s->datasets.deleted); - printf("%10" PRIu64 " iterations\n", s->iterations); + printf("%10" PRIu64 " groups created\n", s->groups.created); + printf("%10" PRIu64 " groups deleted\n", s->groups.deleted); + printf("%10" PRIu64 " datasets created\n", s->datasets.created); + printf("%10" PRIu64 " datasets deleted\n", s->datasets.deleted); + printf("%10" PRIu64 " iterations\n", s->iterations); } static void state_init(state_t *s, int argc, char **argv) { - int ch, i, rc; - char tfile[PATH_MAX]; - char *end; - unsigned long millis; - uintmax_t niters; - - *s = ALL_HID_INITIALIZER; - strlcpy(tfile, argv[0], sizeof(tfile)); - strlcpy(s->progname, basename(tfile), sizeof(s->progname)); - while ((ch = getopt(argc, argv, "n:ou:sSv")) != -1) { - switch (ch) { - case 'n': - niters = strtoumax(optarg, &end, 0); - if (niters == UINTMAX_MAX && errno == ERANGE) { - err(EXIT_FAILURE, "option -%c argument \"%s\"", - ch, optarg); - } else if (*end != '\0') { - errx(EXIT_FAILURE, - "garbage after -%c argument \"%s\"", ch, - optarg); - } - s->iterations_limit = niters; - break; - case 'o': - s->oneshot = true; - break; - case 's': - s->print_stats = true; - break; - case 'S': - s->use_vfd_swmr = false; - break; - case 'u': - errno = 0; - millis = strtoul(optarg, &end, 0); - if (millis == ULONG_MAX && errno == ERANGE) { - err(EXIT_FAILURE, "option -%c argument \"%s\"", - ch, optarg); - } else if (*end != '\0') { - errx(EXIT_FAILURE, - "garbage after -%c argument \"%s\"", ch, - optarg); - } - s->update_interval.tv_sec = millis / 1000UL; - s->update_interval.tv_nsec = (millis * 1000000UL) % 1000000000UL; - warnx("%lu milliseconds between updates", millis); - break; - case 'v': - s->verbose++; - break; - case '?': - default: - usage(s->progname); - } - } - argc -= optind; - argv += optind; - - for (i = 0; i < __arraycount(s->dataset); i++) - s->dataset[i] = H5I_INVALID_HID; - - for (i = 0; i < __arraycount(s->group); i++) - s->group[i] = H5I_INVALID_HID; - - rc = snprintf(s->output_file, sizeof(s->output_file), "%s.h5", s->progname); - if (rc == -1 || rc >= sizeof(s->output_file)) - errx(EXIT_FAILURE, "output filename was truncated"); + int ch, i, rc; + char tfile[PATH_MAX]; + char * end; + unsigned long millis; + uintmax_t niters; + + *s = ALL_HID_INITIALIZER; + strlcpy(tfile, argv[0], sizeof(tfile)); + strlcpy(s->progname, basename(tfile), sizeof(s->progname)); + while ((ch = getopt(argc, argv, "n:ou:sSv")) != -1) { + switch (ch) { + case 'n': + niters = strtoumax(optarg, &end, 0); + if (niters == UINTMAX_MAX && errno == ERANGE) { + err(EXIT_FAILURE, "option -%c argument \"%s\"", ch, optarg); + } + else if (*end != '\0') { + errx(EXIT_FAILURE, "garbage after -%c argument \"%s\"", ch, optarg); + } + s->iterations_limit = niters; + break; + case 'o': + s->oneshot = true; + break; + case 's': + s->print_stats = true; + break; + case 'S': + s->use_vfd_swmr = false; + break; + case 'u': + errno = 0; + millis = strtoul(optarg, &end, 0); + if (millis == ULONG_MAX && errno == ERANGE) { + err(EXIT_FAILURE, "option -%c argument \"%s\"", ch, optarg); + } + else if (*end != '\0') { + errx(EXIT_FAILURE, "garbage after -%c argument \"%s\"", ch, optarg); + } + s->update_interval.tv_sec = millis / 1000UL; + s->update_interval.tv_nsec = (millis * 1000000UL) % 1000000000UL; + warnx("%lu milliseconds between updates", millis); + break; + case 'v': + s->verbose++; + break; + case '?': + default: + usage(s->progname); + } + } + argc -= optind; + argv += optind; + + for (i = 0; i < __arraycount(s->dataset); i++) + s->dataset[i] = H5I_INVALID_HID; + + for (i = 0; i < __arraycount(s->group); i++) + s->group[i] = H5I_INVALID_HID; + + rc = snprintf(s->output_file, sizeof(s->output_file), "%s.h5", s->progname); + if (rc == -1 || rc >= sizeof(s->output_file)) + errx(EXIT_FAILURE, "output filename was truncated"); } static void delete_group(state_t *s, const int64_t gidx) { - hid_t g; - const int ngroups = __arraycount(s->group); - char gname[32]; + hid_t g; + const int ngroups = __arraycount(s->group); + char gname[32]; - assert(0 <= gidx); + assert(0 <= gidx); - snprintf(gname, sizeof(gname), "/group-%" PRId64, gidx); - g = s->group[gidx % ngroups]; + snprintf(gname, sizeof(gname), "/group-%" PRId64, gidx); + g = s->group[gidx % ngroups]; - if (H5Ldelete(s->file, gname, H5P_DEFAULT) < 0) { - errx(EXIT_FAILURE, "%s: H5Ldelete(, \"%s\", ) failed", - __func__, gname); - } + if (H5Ldelete(s->file, gname, H5P_DEFAULT) < 0) { + errx(EXIT_FAILURE, "%s: H5Ldelete(, \"%s\", ) failed", __func__, gname); + } - if (H5Gclose(g) < 0) - errx(EXIT_FAILURE, "H5Gclose failed"); + if (H5Gclose(g) < 0) + errx(EXIT_FAILURE, "H5Gclose failed"); - if (s->verbose > 0) - fprintf(stderr, "Deleted group %s\n", gname); + if (s->verbose > 0) + fprintf(stderr, "Deleted group %s\n", gname); - s->group[gidx % ngroups] = H5I_INVALID_HID; - s->stats.groups.deleted++; + s->group[gidx % ngroups] = H5I_INVALID_HID; + s->stats.groups.deleted++; } static void create_group(state_t *s, const int64_t gidx) { - const int ngroups = __arraycount(s->group); - hid_t g; - char gname[32]; + const int ngroups = __arraycount(s->group); + hid_t g; + char gname[32]; - assert(0 <= gidx); - assert(s->group[gidx % ngroups] == H5I_INVALID_HID); + assert(0 <= gidx); + assert(s->group[gidx % ngroups] == H5I_INVALID_HID); - snprintf(gname, sizeof(gname), "/group-%" PRId64, gidx); - g = H5Gcreate(s->file, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + snprintf(gname, sizeof(gname), "/group-%" PRId64, gidx); + g = H5Gcreate(s->file, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (g < 0) - errx(EXIT_FAILURE, "H5Gcreate failed"); + if (g < 0) + errx(EXIT_FAILURE, "H5Gcreate failed"); - if (s->verbose > 0) - fprintf(stderr, "Created group %s\n", gname); - s->group[gidx % ngroups] = g; - s->stats.groups.created++; + if (s->verbose > 0) + fprintf(stderr, "Created group %s\n", gname); + s->group[gidx % ngroups] = g; + s->stats.groups.created++; } static void delete_dataset(state_t *s, const int64_t didx) { - const int ndatasets = __arraycount(s->dataset); - char dname[32]; - const int64_t gidx = didx / 2; + const int ndatasets = __arraycount(s->dataset); + char dname[32]; + const int64_t gidx = didx / 2; - assert(0 <= gidx && 0 <= didx); + assert(0 <= gidx && 0 <= didx); - snprintf(dname, sizeof(dname), "/group-%" PRId64 "/dataset-%" PRId64, - gidx, didx); - if (H5Ldelete(s->file, dname, H5P_DEFAULT) < 0) { - errx(EXIT_FAILURE, "%s: H5Ldelete(, \"%s\", ) failed", - __func__, dname); - } + snprintf(dname, sizeof(dname), "/group-%" PRId64 "/dataset-%" PRId64, gidx, didx); + if (H5Ldelete(s->file, dname, H5P_DEFAULT) < 0) { + errx(EXIT_FAILURE, "%s: H5Ldelete(, \"%s\", ) failed", __func__, dname); + } - if (s->verbose > 0) - fprintf(stderr, "Deleted dataset %s\n", dname); + if (s->verbose > 0) + fprintf(stderr, "Deleted dataset %s\n", dname); #if 1 - const hid_t ds = s->dataset[didx % ndatasets]; - if (H5Dclose(ds) < 0) - errx(EXIT_FAILURE, "H5Dclose failed"); + const hid_t ds = s->dataset[didx % ndatasets]; + if (H5Dclose(ds) < 0) + errx(EXIT_FAILURE, "H5Dclose failed"); #endif - s->dataset[didx % ndatasets] = H5I_INVALID_HID; - s->stats.datasets.deleted++; + s->dataset[didx % ndatasets] = H5I_INVALID_HID; + s->stats.datasets.deleted++; } static void create_dataset(state_t *s, const int64_t didx) { - const int ndatasets = __arraycount(s->dataset); - char dname[32]; - const int64_t gidx = didx / 2; - hid_t ds; + const int ndatasets = __arraycount(s->dataset); + char dname[32]; + const int64_t gidx = didx / 2; + hid_t ds; - assert(0 <= gidx && 0 <= didx); - assert(s->dataset[didx % ndatasets] == H5I_INVALID_HID); + assert(0 <= gidx && 0 <= didx); + assert(s->dataset[didx % ndatasets] == H5I_INVALID_HID); - s->dataspace = H5Screate_simple(__arraycount(dims), dims, NULL); + s->dataspace = H5Screate_simple(__arraycount(dims), dims, NULL); - if (s->dataspace < 0) - errx(EXIT_FAILURE, "H5Screate_simple failed"); + if (s->dataspace < 0) + errx(EXIT_FAILURE, "H5Screate_simple failed"); - snprintf(dname, sizeof(dname), "/group-%" PRId64 "/dataset-%" PRId64, - gidx, didx); - ds = H5Dcreate2(s->file, dname, - H5T_STD_I32BE, s->dataspace, - H5P_DEFAULT, s->dcpl, s->dapl); + snprintf(dname, sizeof(dname), "/group-%" PRId64 "/dataset-%" PRId64, gidx, didx); + ds = H5Dcreate2(s->file, dname, H5T_STD_I32BE, s->dataspace, H5P_DEFAULT, s->dcpl, s->dapl); - if (H5Sclose(s->dataspace) < 0) - errx(EXIT_FAILURE, "H5Sclose failed"); + if (H5Sclose(s->dataspace) < 0) + errx(EXIT_FAILURE, "H5Sclose failed"); - s->dataspace = H5I_INVALID_HID; + s->dataspace = H5I_INVALID_HID; - if (ds < 0) - errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", dname); + if (ds < 0) + errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", dname); - if (s->verbose > 0) - fprintf(stderr, "Created dataset %s\n", dname); - s->dataset[didx % ndatasets] = ds; - s->stats.datasets.created++; + if (s->verbose > 0) + fprintf(stderr, "Created dataset %s\n", dname); + s->dataset[didx % ndatasets] = ds; + s->stats.datasets.created++; } static void @@ -309,8 +297,8 @@ create_and_write_dataset(state_t *s, const int64_t didx) err(EXIT_FAILURE, "H5Odisable_mdc_flushes failed"); #endif - create_dataset(s, didx); - write_dataset(s, didx); + create_dataset(s, didx); + write_dataset(s, didx); #if 0 if (H5Oenable_mdc_flushes(g) < 0) @@ -321,133 +309,126 @@ create_and_write_dataset(state_t *s, const int64_t didx) static void handle_signal(int signo) { - char msg[] = "Handling signal\n"; - write(STDERR_FILENO, msg, sizeof(msg) - 1); - unbroken = 0; + char msg[] = "Handling signal\n"; + write(STDERR_FILENO, msg, sizeof(msg) - 1); + unbroken = 0; } static void disestablish_handler(const struct sigaction *osa) { - if (sigaction(SIGINT, osa, NULL) == -1) - err(EXIT_FAILURE, "%s: sigaction", __func__); + if (sigaction(SIGINT, osa, NULL) == -1) + err(EXIT_FAILURE, "%s: sigaction", __func__); } static void establish_handler(struct sigaction *osa) { - struct sigaction sa; + struct sigaction sa; - memset(&sa, '\0', sizeof(sa)); - sa.sa_handler = handle_signal; - sigemptyset(&sa.sa_mask); - if (sigaction(SIGINT, &sa, osa) == -1) - err(EXIT_FAILURE, "%s: sigaction", __func__); + memset(&sa, '\0', sizeof(sa)); + sa.sa_handler = handle_signal; + sigemptyset(&sa.sa_mask); + if (sigaction(SIGINT, &sa, osa) == -1) + err(EXIT_FAILURE, "%s: sigaction", __func__); } int main(int argc, char **argv) { - hid_t fapl, fcpl; - struct sigaction osa; - state_t storage; - state_t *s = &storage; - int64_t i; - H5F_vfd_swmr_config_t config; - - memset(&config, '\0', sizeof(config)); - - state_init(s, argc, argv); - - fapl = H5Pcreate(H5P_FILE_ACCESS); - if (fapl < 0) { - errx(EXIT_FAILURE, "%s.%d H5Pcreate failed", - __func__, __LINE__); - } - - fcpl = H5Pcreate(H5P_FILE_CREATE); - if (fcpl < 0) { - errx(EXIT_FAILURE, "%s.%d H5Pcreate failed", - __func__, __LINE__); - } - - config.version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; - config.tick_len = 4; - config.max_lag = 5; -#if 0 /* raw-data flushing is not implemented */ + hid_t fapl, fcpl; + struct sigaction osa; + state_t storage; + state_t * s = &storage; + int64_t i; + H5F_vfd_swmr_config_t config; + + memset(&config, '\0', sizeof(config)); + + state_init(s, argc, argv); + + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (fapl < 0) { + errx(EXIT_FAILURE, "%s.%d H5Pcreate failed", __func__, __LINE__); + } + + fcpl = H5Pcreate(H5P_FILE_CREATE); + if (fcpl < 0) { + errx(EXIT_FAILURE, "%s.%d H5Pcreate failed", __func__, __LINE__); + } + + config.version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; + config.tick_len = 4; + config.max_lag = 5; +#if 0 /* raw-data flushing is not implemented */ config.flush_raw_data = true; #endif - config.writer = true; - config.md_pages_reserved = 128; - strlcpy(config.md_file_path, "./my_md_file", - sizeof(config.md_file_path)); - - /* Enable page buffering */ - if (H5Pset_page_buffer_size(fapl, 4096, 100, 0) < 0) - errx(EXIT_FAILURE, "H5Pset_page_buffer_size failed"); - - /* Enable VFD SWMR configuration */ - if (s->use_vfd_swmr && H5Pset_vfd_swmr_config(fapl, &config) < 0) - errx(EXIT_FAILURE, "H5Pset_vfd_swmr_config failed"); - - /* Set file space strategy to paged aggregation in fcpl. - * Page buffering *requires* this strategy. - * - * I set the free-space threshold to 1GB so that deleted - * datasets are not recycled. - */ - if (H5Pset_file_space_strategy(fcpl, - H5F_FSPACE_STRATEGY_PAGE, false, 1024 * 1024 * 1024) < 0) - errx(EXIT_FAILURE, "H5Pset_file_space_strategy failed"); - - s->file = H5Fcreate(s->output_file, H5F_ACC_TRUNC, fcpl, fapl); - - H5Pclose(fapl); - - if (s->file < 0) - errx(EXIT_FAILURE, "H5Fcreate failed"); - - if ((s->dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", - __func__, __LINE__); - } - if ((s->dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", - __func__, __LINE__); - } - if (H5Pset_chunk(s->dcpl, 2, chunk_dims) < 0) - errx(EXIT_FAILURE, "H5Pset_chunk failed"); - if (H5Pset_chunk_cache(s->dapl, H5D_CHUNK_CACHE_NSLOTS_DEFAULT, 0, - H5D_CHUNK_CACHE_W0_DEFAULT) < 0) - errx(EXIT_FAILURE, "H5Pset_chunk_cache failed"); - - establish_handler(&osa); - - for (i = 0; i < 4; i++) { - s->stats.iterations++; - if (i % 2 == 0) - create_group(s, i / 2); - create_and_write_dataset(s, i); - } - - for (i = 5; unbroken; i += 2) { - delete_dataset(s, i - 5); - delete_dataset(s, i - 4); - delete_group(s, (i - 4) / 2); - create_group(s, i / 2); - create_and_write_dataset(s, i - 1); - create_and_write_dataset(s, i); - if (s->oneshot || ++s->stats.iterations >= s->iterations_limit) - break; - nanosleep(&s->update_interval, NULL); - } - - if (s->oneshot) { - sigset_t mask; - sigemptyset(&mask); - H5Fvfd_swmr_end_tick(s->file); - (void)sigsuspend(&mask); - } + config.writer = true; + config.md_pages_reserved = 128; + strlcpy(config.md_file_path, "./my_md_file", sizeof(config.md_file_path)); + + /* Enable page buffering */ + if (H5Pset_page_buffer_size(fapl, 4096, 100, 0) < 0) + errx(EXIT_FAILURE, "H5Pset_page_buffer_size failed"); + + /* Enable VFD SWMR configuration */ + if (s->use_vfd_swmr && H5Pset_vfd_swmr_config(fapl, &config) < 0) + errx(EXIT_FAILURE, "H5Pset_vfd_swmr_config failed"); + + /* Set file space strategy to paged aggregation in fcpl. + * Page buffering *requires* this strategy. + * + * I set the free-space threshold to 1GB so that deleted + * datasets are not recycled. + */ + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1024 * 1024 * 1024) < 0) + errx(EXIT_FAILURE, "H5Pset_file_space_strategy failed"); + + s->file = H5Fcreate(s->output_file, H5F_ACC_TRUNC, fcpl, fapl); + + H5Pclose(fapl); + + if (s->file < 0) + errx(EXIT_FAILURE, "H5Fcreate failed"); + + if ((s->dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", __func__, __LINE__); + } + if ((s->dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { + errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", __func__, __LINE__); + } + if (H5Pset_chunk(s->dcpl, 2, chunk_dims) < 0) + errx(EXIT_FAILURE, "H5Pset_chunk failed"); + if (H5Pset_chunk_cache(s->dapl, H5D_CHUNK_CACHE_NSLOTS_DEFAULT, 0, H5D_CHUNK_CACHE_W0_DEFAULT) < 0) + errx(EXIT_FAILURE, "H5Pset_chunk_cache failed"); + + establish_handler(&osa); + + for (i = 0; i < 4; i++) { + s->stats.iterations++; + if (i % 2 == 0) + create_group(s, i / 2); + create_and_write_dataset(s, i); + } + + for (i = 5; unbroken; i += 2) { + delete_dataset(s, i - 5); + delete_dataset(s, i - 4); + delete_group(s, (i - 4) / 2); + create_group(s, i / 2); + create_and_write_dataset(s, i - 1); + create_and_write_dataset(s, i); + if (s->oneshot || ++s->stats.iterations >= s->iterations_limit) + break; + nanosleep(&s->update_interval, NULL); + } + + if (s->oneshot) { + sigset_t mask; + sigemptyset(&mask); + H5Fvfd_swmr_end_tick(s->file); + (void)sigsuspend(&mask); + } #if 0 fprintf(stderr, "Interrupted. Cleaning up.\n"); @@ -466,19 +447,19 @@ main(int argc, char **argv) } #endif - if (s->print_stats) - print_stats(&s->stats); + if (s->print_stats) + print_stats(&s->stats); - if (H5Fclose(s->file) < 0) - errx(EXIT_FAILURE, "H5Fclose failed"); + if (H5Fclose(s->file) < 0) + errx(EXIT_FAILURE, "H5Fclose failed"); - if (H5Pclose(s->dapl) < 0) - errx(EXIT_FAILURE, "H5Pclose failed"); + if (H5Pclose(s->dapl) < 0) + errx(EXIT_FAILURE, "H5Pclose failed"); - if (H5Pclose(s->dcpl) < 0) - errx(EXIT_FAILURE, "H5Pclose failed"); + if (H5Pclose(s->dcpl) < 0) + errx(EXIT_FAILURE, "H5Pclose failed"); - disestablish_handler(&osa); + disestablish_handler(&osa); - return EXIT_SUCCESS; + return EXIT_SUCCESS; } diff --git a/examples/gaussians.c b/examples/gaussians.c index 0ceeb8b..413bc03 100644 --- a/examples/gaussians.c +++ b/examples/gaussians.c @@ -14,194 +14,181 @@ */ #include /* getopt, PATH_MAX, ... */ -#include /* for MIN(a, b) */ +#include /* for MIN(a, b) */ #include "hdf5.h" #include "nbcompat.h" -#define SWMR_TICK_LEN 4 /* in 100 ms */ +#define SWMR_TICK_LEN 4 /* in 100 ms */ -typedef enum { - STANDALONE = 0 - , READ = 1 - , WRITE = 2 -} personality_t; +typedef enum { STANDALONE = 0, READ = 1, WRITE = 2 } personality_t; -typedef enum { - TOP = 0 - , BOTTOM - , LEFT - , RIGHT - , NSIDES -} side_t; +typedef enum { TOP = 0, BOTTOM, LEFT, RIGHT, NSIDES } side_t; typedef struct { - bool side[NSIDES]; + bool side[NSIDES]; } inside_t; typedef struct { - float x, y; + float x, y; } vec_t; #define RANK 3 #define ROWS 20 #define COLS 40 -static const hsize_t original_dims[RANK] = {0, ROWS, COLS}; -static const hsize_t max_dims[RANK] = {H5S_UNLIMITED, ROWS, COLS}; -static const hsize_t frame_dims[RANK] = {1, ROWS, COLS}; -static const hsize_t *chunk_dims = frame_dims; -static volatile sig_atomic_t unbroken = 1; +static const hsize_t original_dims[RANK] = {0, ROWS, COLS}; +static const hsize_t max_dims[RANK] = {H5S_UNLIMITED, ROWS, COLS}; +static const hsize_t frame_dims[RANK] = {1, ROWS, COLS}; +static const hsize_t * chunk_dims = frame_dims; +static volatile sig_atomic_t unbroken = 1; typedef struct { - /* main-loop statistics */ - uint64_t max_elapsed_ns, min_elapsed_ns, total_elapsed_ns; - uint64_t total_loops; - hid_t dataset, memspace, dcpl, file, group; - char output_file[PATH_MAX]; - char progname[PATH_MAX]; - struct timespec update_interval; - bool fuzz; - bool constantrate; - unsigned int partstep; + /* main-loop statistics */ + uint64_t max_elapsed_ns, min_elapsed_ns, total_elapsed_ns; + uint64_t total_loops; + hid_t dataset, memspace, dcpl, file, group; + char output_file[PATH_MAX]; + char progname[PATH_MAX]; + struct timespec update_interval; + bool fuzz; + bool constantrate; + unsigned int partstep; } state_t; -#define ALL_HID_INITIALIZER (state_t){ \ - .total_elapsed_ns = 0 \ - , .total_loops = 0 \ - , .min_elapsed_ns = UINT64_MAX \ - , .max_elapsed_ns = 0 \ - , .memspace = H5I_INVALID_HID \ - , .file = H5I_INVALID_HID \ - , .constantrate = false \ - , .partstep = 0 \ - , .output_file = "" \ - , .update_interval = (struct timespec){ \ - .tv_sec = 0 \ - , .tv_nsec = 1000000000UL / 30 /* 1/30 second */}} +#define ALL_HID_INITIALIZER \ + (state_t) \ + { \ + .total_elapsed_ns = 0, .total_loops = 0, .min_elapsed_ns = UINT64_MAX, .max_elapsed_ns = 0, \ + .memspace = H5I_INVALID_HID, .file = H5I_INVALID_HID, .constantrate = false, .partstep = 0, \ + .output_file = "", .update_interval = (struct timespec) \ + { \ + .tv_sec = 0, .tv_nsec = 1000000000UL / 30 /* 1/30 second */ \ + } \ + } static void state_init(state_t *, int, char **); static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-u milliseconds]\n" - "\n" - "-c: increase the frame number continously (reader mode)\n" - "-f: add \"fuzz\" (linear noise) to the data (writer mode)\n" - "-u ms: milliseconds interval between updates to %s.h5\n" - "\n", - progname, progname); - exit(EXIT_FAILURE); + fprintf(stderr, + "usage: %s [-u milliseconds]\n" + "\n" + "-c: increase the frame number continously (reader mode)\n" + "-f: add \"fuzz\" (linear noise) to the data (writer mode)\n" + "-u ms: milliseconds interval between updates to %s.h5\n" + "\n", + progname, progname); + exit(EXIT_FAILURE); } static void state_init(state_t *s, int argc, char **argv) { - int ch; - char tfile[PATH_MAX]; - char *end; - unsigned long millis; - - *s = ALL_HID_INITIALIZER; - strlcpy(tfile, argv[0], sizeof(tfile)); - strlcpy(s->progname, basename(tfile), sizeof(s->progname)); - - while ((ch = getopt(argc, argv, "cfu:")) != -1) { - switch (ch) { - case 'c': - s->constantrate = true; - break; - case 'f': - s->fuzz = true; - break; - case 'u': - errno = 0; - millis = strtoul(optarg, &end, 0); - if (millis == ULONG_MAX && errno == ERANGE) { - err(EXIT_FAILURE, - "option -p argument \"%s\"", optarg); - } else if (*end != '\0') { - errx(EXIT_FAILURE, - "garbage after -p argument \"%s\"", optarg); - } - s->update_interval.tv_sec = millis / 1000UL; - s->update_interval.tv_nsec = - (millis * 1000000UL) % 1000000000UL; - warnx("%lu milliseconds between updates", millis); - break; - case '?': - default: - usage(s->progname); - } - } - argc -= optind; - argv += optind; - - s->dataset = H5I_INVALID_HID; - s->group = H5I_INVALID_HID; - - s->memspace = H5Screate_simple(RANK, frame_dims, NULL); - - if (s->memspace < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); - } - - const int nprinted = snprintf(s->output_file, sizeof(s->output_file), - "%s.h5", s->progname); - if (nprinted < 0 || nprinted >= sizeof(s->output_file)) { - errx(EXIT_FAILURE, "%s.%d: output filename truncated.", - __func__, __LINE__); - } + int ch; + char tfile[PATH_MAX]; + char * end; + unsigned long millis; + + *s = ALL_HID_INITIALIZER; + strlcpy(tfile, argv[0], sizeof(tfile)); + strlcpy(s->progname, basename(tfile), sizeof(s->progname)); + + while ((ch = getopt(argc, argv, "cfu:")) != -1) { + switch (ch) { + case 'c': + s->constantrate = true; + break; + case 'f': + s->fuzz = true; + break; + case 'u': + errno = 0; + millis = strtoul(optarg, &end, 0); + if (millis == ULONG_MAX && errno == ERANGE) { + err(EXIT_FAILURE, "option -p argument \"%s\"", optarg); + } + else if (*end != '\0') { + errx(EXIT_FAILURE, "garbage after -p argument \"%s\"", optarg); + } + s->update_interval.tv_sec = millis / 1000UL; + s->update_interval.tv_nsec = (millis * 1000000UL) % 1000000000UL; + warnx("%lu milliseconds between updates", millis); + break; + case '?': + default: + usage(s->progname); + } + } + argc -= optind; + argv += optind; + + s->dataset = H5I_INVALID_HID; + s->group = H5I_INVALID_HID; + + s->memspace = H5Screate_simple(RANK, frame_dims, NULL); + + if (s->memspace < 0) { + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); + } + + const int nprinted = snprintf(s->output_file, sizeof(s->output_file), "%s.h5", s->progname); + if (nprinted < 0 || nprinted >= sizeof(s->output_file)) { + errx(EXIT_FAILURE, "%s.%d: output filename truncated.", __func__, __LINE__); + } } static void matrix_read(state_t *s, int *framenop, float mat[ROWS][COLS]) { - hid_t ds, filespace; - herr_t status; - hsize_t dims[RANK]; - - ds = s->dataset; - - if (H5Drefresh(ds) < 0) - errx(EXIT_FAILURE, "H5Drefresh failed"); - - filespace = H5Dget_space(ds); - - if (H5Sget_simple_extent_dims(filespace, dims, NULL) < 0) - errx(EXIT_FAILURE, "H5Sget_simple_extent_dims failed"); - - if (dims[1] != original_dims[1] || dims[2] != original_dims[2]) { - errx(EXIT_FAILURE, "Unexpected dimensions N x %ju x %ju", - (uintmax_t)dims[1], (uintmax_t)dims[2]); - } - - const uint64_t update_ms = timespec2ns(&s->update_interval) / 1000000; - const uint32_t tick_ms = SWMR_TICK_LEN * 100; - const uint64_t updates_per_tick = (tick_ms + update_ms - 1) / update_ms; - const hssize_t hang_back = 2 * updates_per_tick; - const int frameno = *framenop; - - const int lead = frameno + hang_back - dims[0]; - if (s->constantrate) { - *framenop = frameno + 1; - } else if (lead > hang_back * 2) { - if (++s->partstep % 3 == 0) - *framenop = frameno + 1; - } else if (lead > 0) { - if (++s->partstep % 2 == 0) - *framenop = frameno + 1; - } else if (lead == 0) { - *framenop = frameno + 1; - } else if (lead < -hang_back * 2) { - /* We're way behind, so jump close to the front. */ - *framenop = dims[0] - hang_back; - } else /* lead < 0 */ { - *framenop = frameno + 1; - if (++s->partstep % 2 == 0) - *framenop = frameno + 2; - } + hid_t ds, filespace; + herr_t status; + hsize_t dims[RANK]; + + ds = s->dataset; + + if (H5Drefresh(ds) < 0) + errx(EXIT_FAILURE, "H5Drefresh failed"); + + filespace = H5Dget_space(ds); + + if (H5Sget_simple_extent_dims(filespace, dims, NULL) < 0) + errx(EXIT_FAILURE, "H5Sget_simple_extent_dims failed"); + + if (dims[1] != original_dims[1] || dims[2] != original_dims[2]) { + errx(EXIT_FAILURE, "Unexpected dimensions N x %ju x %ju", (uintmax_t)dims[1], (uintmax_t)dims[2]); + } + + const uint64_t update_ms = timespec2ns(&s->update_interval) / 1000000; + const uint32_t tick_ms = SWMR_TICK_LEN * 100; + const uint64_t updates_per_tick = (tick_ms + update_ms - 1) / update_ms; + const hssize_t hang_back = 2 * updates_per_tick; + const int frameno = *framenop; + + const int lead = frameno + hang_back - dims[0]; + if (s->constantrate) { + *framenop = frameno + 1; + } + else if (lead > hang_back * 2) { + if (++s->partstep % 3 == 0) + *framenop = frameno + 1; + } + else if (lead > 0) { + if (++s->partstep % 2 == 0) + *framenop = frameno + 1; + } + else if (lead == 0) { + *framenop = frameno + 1; + } + else if (lead < -hang_back * 2) { + /* We're way behind, so jump close to the front. */ + *framenop = dims[0] - hang_back; + } + else /* lead < 0 */ { + *framenop = frameno + 1; + if (++s->partstep % 2 == 0) + *framenop = frameno + 2; + } #if 0 if (!s->constantrate && (lead < -2 || 2 < lead)) { @@ -222,538 +209,520 @@ matrix_read(state_t *s, int *framenop, float mat[ROWS][COLS]) } #endif - if (frameno >= dims[0]) { - int i, j; - for (i = 0; i < ROWS; i++) { - for (j = 0; j < COLS; j++) - mat[i][j] = ((i + j) % 2 == 0) ? 0. : 1.; - } - return; - } + if (frameno >= dims[0]) { + int i, j; + for (i = 0; i < ROWS; i++) { + for (j = 0; j < COLS; j++) + mat[i][j] = ((i + j) % 2 == 0) ? 0. : 1.; + } + return; + } - hsize_t offset[RANK] = {frameno, 0, 0}; + hsize_t offset[RANK] = {frameno, 0, 0}; - if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - frame_dims, NULL) < 0) - errx(EXIT_FAILURE, "H5Sselect_hyperslab failed"); + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, frame_dims, NULL) < 0) + errx(EXIT_FAILURE, "H5Sselect_hyperslab failed"); - status = H5Dread(ds, H5T_NATIVE_FLOAT, s->memspace, filespace, - H5P_DEFAULT, mat); + status = H5Dread(ds, H5T_NATIVE_FLOAT, s->memspace, filespace, H5P_DEFAULT, mat); - if (status < 0) - errx(EXIT_FAILURE, "H5Dread failed"); + if (status < 0) + errx(EXIT_FAILURE, "H5Dread failed"); - if (H5Sclose(filespace) < 0) - errx(EXIT_FAILURE, "H5Sclose failed"); + if (H5Sclose(filespace) < 0) + errx(EXIT_FAILURE, "H5Sclose failed"); } static void matrix_write(state_t *s, int frameno, float mat[ROWS][COLS]) { - hid_t ds, filespace; - herr_t status; - hsize_t size[RANK] = {frameno + 1, ROWS, COLS}; - hsize_t offset[RANK] = {frameno, 0, 0}; + hid_t ds, filespace; + herr_t status; + hsize_t size[RANK] = {frameno + 1, ROWS, COLS}; + hsize_t offset[RANK] = {frameno, 0, 0}; - ds = s->dataset; + ds = s->dataset; - if (H5Dset_extent(ds, size) < 0) - errx(EXIT_FAILURE, "H5Dset_extent failed"); + if (H5Dset_extent(ds, size) < 0) + errx(EXIT_FAILURE, "H5Dset_extent failed"); - filespace = H5Dget_space(ds); + filespace = H5Dget_space(ds); - if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - frame_dims, NULL) < 0) - errx(EXIT_FAILURE, "H5Sselect_hyperslab failed"); + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, frame_dims, NULL) < 0) + errx(EXIT_FAILURE, "H5Sselect_hyperslab failed"); - status = H5Dwrite(ds, H5T_NATIVE_FLOAT, s->memspace, filespace, - H5P_DEFAULT, mat); + status = H5Dwrite(ds, H5T_NATIVE_FLOAT, s->memspace, filespace, H5P_DEFAULT, mat); - if (status < 0) - errx(EXIT_FAILURE, "H5Dwrite failed"); + if (status < 0) + errx(EXIT_FAILURE, "H5Dwrite failed"); - if (H5Sclose(filespace) < 0) - errx(EXIT_FAILURE, "H5Sclose failed"); + if (H5Sclose(filespace) < 0) + errx(EXIT_FAILURE, "H5Sclose failed"); - if (H5Dflush(ds) < 0) - errx(EXIT_FAILURE, "H5Dflush failed"); + if (H5Dflush(ds) < 0) + errx(EXIT_FAILURE, "H5Dflush failed"); } static void open_group(state_t *s) { - hid_t g; - const char *gname = "/group-0"; + hid_t g; + const char *gname = "/group-0"; - assert(s->group == H5I_INVALID_HID); + assert(s->group == H5I_INVALID_HID); - g = H5Gopen(s->file, gname, H5P_DEFAULT); + g = H5Gopen(s->file, gname, H5P_DEFAULT); - if (g < 0) - errx(EXIT_FAILURE, "H5Gcreate failed"); + if (g < 0) + errx(EXIT_FAILURE, "H5Gcreate failed"); - fprintf(stderr, "Opened group %s\n", gname); - s->group = g; + fprintf(stderr, "Opened group %s\n", gname); + s->group = g; } static void create_group(state_t *s) { - hid_t g; - const char *gname = "/group-0"; + hid_t g; + const char *gname = "/group-0"; - assert(s->group == H5I_INVALID_HID); + assert(s->group == H5I_INVALID_HID); - g = H5Gcreate(s->file, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + g = H5Gcreate(s->file, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (g < 0) - errx(EXIT_FAILURE, "H5Gcreate failed"); + if (g < 0) + errx(EXIT_FAILURE, "H5Gcreate failed"); - s->group = g; + s->group = g; } static void open_dataset(state_t *s) { - const char *dname = "/group-0/dataset-0"; - hid_t ds; - hid_t filespace; - hid_t ty; - hsize_t dims[RANK], maxdims[RANK]; + const char *dname = "/group-0/dataset-0"; + hid_t ds; + hid_t filespace; + hid_t ty; + hsize_t dims[RANK], maxdims[RANK]; - assert(s->dataset == H5I_INVALID_HID); + assert(s->dataset == H5I_INVALID_HID); - ds = H5Dopen(s->file, dname, H5P_DEFAULT); + ds = H5Dopen(s->file, dname, H5P_DEFAULT); - if (ds < 0) - errx(EXIT_FAILURE, "H5Dopen(, \"%s\", ) failed", dname); + if (ds < 0) + errx(EXIT_FAILURE, "H5Dopen(, \"%s\", ) failed", dname); - if ((ty = H5Dget_type(ds)) < 0) - errx(EXIT_FAILURE, "H5Dget_type failed"); + if ((ty = H5Dget_type(ds)) < 0) + errx(EXIT_FAILURE, "H5Dget_type failed"); - if (H5Tequal(ty, H5T_IEEE_F32BE) <= 0) - errx(EXIT_FAILURE, "Unexpected data type"); + if (H5Tequal(ty, H5T_IEEE_F32BE) <= 0) + errx(EXIT_FAILURE, "Unexpected data type"); - if ((filespace = H5Dget_space(ds)) < 0) - errx(EXIT_FAILURE, "H5Dget_space failed"); + if ((filespace = H5Dget_space(ds)) < 0) + errx(EXIT_FAILURE, "H5Dget_space failed"); - if (H5Sget_simple_extent_ndims(filespace) != RANK) - errx(EXIT_FAILURE, "Unexpected rank"); + if (H5Sget_simple_extent_ndims(filespace) != RANK) + errx(EXIT_FAILURE, "Unexpected rank"); - if (H5Sget_simple_extent_dims(filespace, dims, maxdims) < 0) - errx(EXIT_FAILURE, "H5Sget_simple_extent_dims failed"); + if (H5Sget_simple_extent_dims(filespace, dims, maxdims) < 0) + errx(EXIT_FAILURE, "H5Sget_simple_extent_dims failed"); - if (dims[1] != original_dims[1] || dims[2] != original_dims[2]) { - errx(EXIT_FAILURE, "Unexpected dimensions ? x %ju x %ju", - (uintmax_t)dims[1], (uintmax_t)dims[2]); - } + if (dims[1] != original_dims[1] || dims[2] != original_dims[2]) { + errx(EXIT_FAILURE, "Unexpected dimensions ? x %ju x %ju", (uintmax_t)dims[1], (uintmax_t)dims[2]); + } - if (maxdims[1] != original_dims[1] || maxdims[2] != original_dims[2]) { - errx(EXIT_FAILURE, - "Unexpected maximum dimensions ? x %ju x %ju", - (uintmax_t)dims[1], (uintmax_t)dims[2]); - } + if (maxdims[1] != original_dims[1] || maxdims[2] != original_dims[2]) { + errx(EXIT_FAILURE, "Unexpected maximum dimensions ? x %ju x %ju", (uintmax_t)dims[1], + (uintmax_t)dims[2]); + } - fprintf(stderr, "Opened dataset %s\n", dname); - s->dataset = ds; + fprintf(stderr, "Opened dataset %s\n", dname); + s->dataset = ds; } static void create_dataset(state_t *s) { - const char *dname = "/group-0/dataset-0"; - hid_t ds; - hid_t filespace; + const char *dname = "/group-0/dataset-0"; + hid_t ds; + hid_t filespace; - assert(s->dataset == H5I_INVALID_HID); + assert(s->dataset == H5I_INVALID_HID); - filespace = H5Screate_simple(__arraycount(original_dims), original_dims, - max_dims); + filespace = H5Screate_simple(__arraycount(original_dims), original_dims, max_dims); - if (filespace < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); - } + if (filespace < 0) { + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); + } - if ((s->dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", - __func__, __LINE__); - } + if ((s->dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", __func__, __LINE__); + } - if (H5Pset_chunk(s->dcpl, RANK, chunk_dims) < 0) - errx(EXIT_FAILURE, "H5Pset_chunk failed"); + if (H5Pset_chunk(s->dcpl, RANK, chunk_dims) < 0) + errx(EXIT_FAILURE, "H5Pset_chunk failed"); - ds = H5Dcreate2(s->file, dname, H5T_IEEE_F32BE, filespace, - H5P_DEFAULT, s->dcpl, H5P_DEFAULT); + ds = H5Dcreate2(s->file, dname, H5T_IEEE_F32BE, filespace, H5P_DEFAULT, s->dcpl, H5P_DEFAULT); - if (H5Sclose(filespace) < 0) - errx(EXIT_FAILURE, "H5Sclose failed"); + if (H5Sclose(filespace) < 0) + errx(EXIT_FAILURE, "H5Sclose failed"); - filespace = H5I_INVALID_HID; + filespace = H5I_INVALID_HID; - if (ds < 0) - errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", dname); + if (ds < 0) + errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", dname); - s->dataset = ds; + s->dataset = ds; } static void handle_signal(int signo) { - unbroken = 0; + unbroken = 0; } static void disestablish_handler(const struct sigaction *osa) { - if (sigaction(SIGINT, osa, NULL) == -1) - err(EXIT_FAILURE, "%s: sigaction", __func__); + if (sigaction(SIGINT, osa, NULL) == -1) + err(EXIT_FAILURE, "%s: sigaction", __func__); } static void establish_handler(struct sigaction *osa) { - struct sigaction sa; + struct sigaction sa; - memset(&sa, '\0', sizeof(sa)); - sa.sa_handler = handle_signal; - sigemptyset(&sa.sa_mask); - if (sigaction(SIGINT, &sa, osa) == -1) - err(EXIT_FAILURE, "%s: sigaction", __func__); + memset(&sa, '\0', sizeof(sa)); + sa.sa_handler = handle_signal; + sigemptyset(&sa.sa_mask); + if (sigaction(SIGINT, &sa, osa) == -1) + err(EXIT_FAILURE, "%s: sigaction", __func__); } static void step(vec_t *center, vec_t *direction, float steplen, bool *recursed) { - static const float top = 0., bottom = (float)COLS, - left = 0., right = (float)ROWS; - struct { - bool top, bottom, left, right; - } bounce = {false, false, false, false}; - float xback, yback; - vec_t before = *center; - vec_t after = (vec_t){.x = before.x + direction->x * steplen, - .y = before.y + direction->y * steplen}; - - if (before.x < right && after.x >= right) { - xback = (right - before.x) / (after.x - before.x); - bounce.right = true; - } else if (before.x > left && after.x <= left) { - xback = (before.x - left) / (before.x - after.x); - bounce.left = true; - } else - xback = 0.; - - if (before.y < bottom && after.y >= bottom) { - yback = (bottom - before.y) / (after.y - before.y); - bounce.bottom = true; - } else if (before.y > top && after.y <= top) { - yback = (before.y - top) / (before.y - after.y); - bounce.top = true; - } else - yback = 0.; - - /* I shorten the step length until a corner crossing becomes - * a side crossing. - */ - if ((bounce.top && bounce.right) || - (bounce.right && bounce.bottom) || - (bounce.bottom && bounce.left) || - (bounce.left && bounce.top)) { - - float newsteplen = steplen * 2 / 3; - if (recursed != NULL) - *recursed = true; - step(center, direction, newsteplen, NULL); - step(center, direction, steplen - newsteplen, NULL); - } - if (bounce.right || bounce.left) { - after.x = before.x + direction->x * (2 * xback - 1) * steplen; - direction->x = -direction->x; - } - if (bounce.top || bounce.bottom) { - after.y = before.y + direction->y * (2 * yback - 1) * steplen; - direction->y = -direction->y; - } - *center = after; + static const float top = 0., bottom = (float)COLS, left = 0., right = (float)ROWS; + struct { + bool top, bottom, left, right; + } bounce = {false, false, false, false}; + float xback, yback; + vec_t before = *center; + vec_t after = (vec_t){.x = before.x + direction->x * steplen, .y = before.y + direction->y * steplen}; + + if (before.x < right && after.x >= right) { + xback = (right - before.x) / (after.x - before.x); + bounce.right = true; + } + else if (before.x > left && after.x <= left) { + xback = (before.x - left) / (before.x - after.x); + bounce.left = true; + } + else + xback = 0.; + + if (before.y < bottom && after.y >= bottom) { + yback = (bottom - before.y) / (after.y - before.y); + bounce.bottom = true; + } + else if (before.y > top && after.y <= top) { + yback = (before.y - top) / (before.y - after.y); + bounce.top = true; + } + else + yback = 0.; + + /* I shorten the step length until a corner crossing becomes + * a side crossing. + */ + if ((bounce.top && bounce.right) || (bounce.right && bounce.bottom) || (bounce.bottom && bounce.left) || + (bounce.left && bounce.top)) { + + float newsteplen = steplen * 2 / 3; + if (recursed != NULL) + *recursed = true; + step(center, direction, newsteplen, NULL); + step(center, direction, steplen - newsteplen, NULL); + } + if (bounce.right || bounce.left) { + after.x = before.x + direction->x * (2 * xback - 1) * steplen; + direction->x = -direction->x; + } + if (bounce.top || bounce.bottom) { + after.y = before.y + direction->y * (2 * yback - 1) * steplen; + direction->y = -direction->y; + } + *center = after; } static float gaussian(float x, float y, float r) { - return expf(-(x * x + y * y) / (r * r)); + return expf(-(x * x + y * y) / (r * r)); } int stepno(float v) { - if (v < 1. / 8.) - return 0; - if (v < 3. / 8.) - return 1; - if (v < 7 / 8.) - return 2; - - return 3; + if (v < 1. / 8.) + return 0; + if (v < 3. / 8.) + return 1; + if (v < 7 / 8.) + return 2; + + return 3; } static void draw_border(WINDOW *w) { - wborder(w, 0, 0, 0, 0, 0, 0, 0, 0); + wborder(w, 0, 0, 0, 0, 0, 0, 0, 0); } static void matrix_draw(WINDOW *w, float mat[ROWS][COLS]) { - int ch, i, j; - static char steps[] = " .oO"; - - wclear(w); - draw_border(w); - for (i = 0; i < ROWS; i++) { - wmove(w, 1 + i, 1); - for (j = 0; j < COLS; j++) { - ch = steps[stepno(mat[i][j])]; - waddch(w, ch); - } - } - - wnoutrefresh(w); + int ch, i, j; + static char steps[] = " .oO"; + + wclear(w); + draw_border(w); + for (i = 0; i < ROWS; i++) { + wmove(w, 1 + i, 1); + for (j = 0; j < COLS; j++) { + ch = steps[stepno(mat[i][j])]; + waddch(w, ch); + } + } + + wnoutrefresh(w); } static void matrix_compute(vec_t *center, size_t ncenters, float mat[ROWS][COLS]) { - int i, j, k; - float radius = 4; - - for (i = 0; i < ROWS; i++) { - for (j = 0; j < COLS; j++) { - mat[i][j] = 0.; - for (k = 0; k < ncenters; k++) { - mat[i][j] += gaussian(i - center[k].x, - j - center[k].y, radius); - } - } - } + int i, j, k; + float radius = 4; + + for (i = 0; i < ROWS; i++) { + for (j = 0; j < COLS; j++) { + mat[i][j] = 0.; + for (k = 0; k < ncenters; k++) { + mat[i][j] += gaussian(i - center[k].x, j - center[k].y, radius); + } + } + } } static void move_centers(vec_t *center, vec_t *direction, size_t ncenters) { - const float steplen = .01; - int k; - bool recursed[2] = {false, false}; - - for (k = 0; k < ncenters; k++) { - recursed[k] = false; - step(¢er[k], &direction[k], steplen, &recursed[k]); - } + const float steplen = .01; + int k; + bool recursed[2] = {false, false}; + + for (k = 0; k < ncenters; k++) { + recursed[k] = false; + step(¢er[k], &direction[k], steplen, &recursed[k]); + } } static void matrix_open(state_t *s, bool rw) { - const char *func; - hid_t fapl, fcpl; - H5F_vfd_swmr_config_t config; - - fapl = H5Pcreate(H5P_FILE_ACCESS); - if (fapl < 0) { - errx(EXIT_FAILURE, "%s.%d H5Pcreate failed", - __func__, __LINE__); - } + const char * func; + hid_t fapl, fcpl; + H5F_vfd_swmr_config_t config; - fcpl = H5Pcreate(H5P_FILE_CREATE); - if (fcpl < 0) { - errx(EXIT_FAILURE, "%s.%d H5Pcreate failed", - __func__, __LINE__); - } + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (fapl < 0) { + errx(EXIT_FAILURE, "%s.%d H5Pcreate failed", __func__, __LINE__); + } - memset(&config, '\0', sizeof(config)); + fcpl = H5Pcreate(H5P_FILE_CREATE); + if (fcpl < 0) { + errx(EXIT_FAILURE, "%s.%d H5Pcreate failed", __func__, __LINE__); + } - config.version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; - config.tick_len = SWMR_TICK_LEN; - config.max_lag = 5; - config.writer = rw; - config.md_pages_reserved = 128; + memset(&config, '\0', sizeof(config)); -#if 0 /* raw-data flushing is not implemented; default open-tries is ok */ + config.version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; + config.tick_len = SWMR_TICK_LEN; + config.max_lag = 5; + config.writer = rw; + config.md_pages_reserved = 128; + +#if 0 /* raw-data flushing is not implemented; default open-tries is ok */ config.flush_raw_data = true; config.md_open_tries = 1; #endif - strlcpy(config.md_file_path, "./my_md_file", sizeof(config.md_file_path)); - - /* Enable page buffering */ - if (H5Pset_page_buffer_size(fapl, 4096, 100, 0) < 0) - errx(EXIT_FAILURE, "H5Pset_page_buffer_size failed"); - - /* Enable VFD SWMR configuration */ - if (H5Pset_vfd_swmr_config(fapl, &config) < 0) - errx(EXIT_FAILURE, "H5Pset_vfd_swmr_config failed"); - - /* Set file space strategy to paged aggregation in fcpl. - * Page buffering *requires* this strategy. - * - * I set the free-space threshold to 1GB so that deleted - * datasets are not recycled. - */ - if (H5Pset_file_space_strategy(fcpl, - H5F_FSPACE_STRATEGY_PAGE, false, 1024 * 1024 * 1024) < 0) - errx(EXIT_FAILURE, "H5Pset_file_space_strategy failed"); - - if (rw) { - s->file = H5Fcreate("gaussians.h5", H5F_ACC_TRUNC, fcpl, fapl); - func = "H5Fcreate"; - } else { - s->file = H5Fopen("gaussians.h5", H5F_ACC_RDONLY, fapl); - func = "H5Fopen"; - } - - H5Pclose(fapl); - - if (s->file < 0) - errx(EXIT_FAILURE, "%s failed", func); + strlcpy(config.md_file_path, "./my_md_file", sizeof(config.md_file_path)); + + /* Enable page buffering */ + if (H5Pset_page_buffer_size(fapl, 4096, 100, 0) < 0) + errx(EXIT_FAILURE, "H5Pset_page_buffer_size failed"); + + /* Enable VFD SWMR configuration */ + if (H5Pset_vfd_swmr_config(fapl, &config) < 0) + errx(EXIT_FAILURE, "H5Pset_vfd_swmr_config failed"); + + /* Set file space strategy to paged aggregation in fcpl. + * Page buffering *requires* this strategy. + * + * I set the free-space threshold to 1GB so that deleted + * datasets are not recycled. + */ + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, false, 1024 * 1024 * 1024) < 0) + errx(EXIT_FAILURE, "H5Pset_file_space_strategy failed"); + + if (rw) { + s->file = H5Fcreate("gaussians.h5", H5F_ACC_TRUNC, fcpl, fapl); + func = "H5Fcreate"; + } + else { + s->file = H5Fopen("gaussians.h5", H5F_ACC_RDONLY, fapl); + func = "H5Fopen"; + } + + H5Pclose(fapl); + + if (s->file < 0) + errx(EXIT_FAILURE, "%s failed", func); } static void fuzz(float mat[ROWS][COLS]) { - int i, j; + int i, j; - for (i = 0; i < ROWS; i++) { - for (j = 0; j < COLS; j++) { - mat[i][j] += (float)random() / RAND_MAX * (9. / 64.); - } - } + for (i = 0; i < ROWS; i++) { + for (j = 0; j < COLS; j++) { + mat[i][j] += (float)random() / RAND_MAX * (9. / 64.); + } + } } int main(int argc, char **argv) { - char buf[32]; - float mat[ROWS][COLS]; - int frameno; - vec_t center[2] = {{.x = .5, .y = .5}, - {.x = ROWS - .5, .y = COLS - .5}}; - vec_t direction[2] = {{.x = 3, .y = 7}, {.x = 43, .y = 41}}; - struct sigaction osa; - WINDOW *topw = NULL, *w = NULL; - personality_t personality; - state_t s; - - srandom((unsigned int)time(NULL)); - - setlocale(LC_ALL, ""); - - state_init(&s, argc, argv); - - switch (s.progname[0]) { - case 'r': - personality = READ; - break; - case 'w': - personality = WRITE; - break; - default: - personality = STANDALONE; - break; - } - establish_handler(&osa); - - switch (personality) { - case WRITE: - matrix_open(&s, true); - create_group(&s); - create_dataset(&s); - break; - case READ: - matrix_open(&s, false); - open_group(&s); - open_dataset(&s); - break; - default: - break; - } - - if ((topw = initscr()) == NULL) - errx(EXIT_FAILURE, "initscr failed"); - else if ((w = subwin(topw, ROWS + 2, COLS + 2, 0, 0)) == NULL) - errx(EXIT_FAILURE, "subwin failed"); - - for (frameno = 0; unbroken; ) { - struct timespec elapsed, start, stop; - uint64_t elapsed_ns; - clock_gettime(CLOCK_MONOTONIC, &start); - - switch (personality) { - case READ: - matrix_read(&s, &frameno, mat); - break; - case WRITE: - case STANDALONE: - matrix_compute(center, __arraycount(center), mat); - if (s.fuzz) - fuzz(mat); - break; - } - switch (personality) { - case READ: - case STANDALONE: - matrix_draw(w, mat); + char buf[32]; + float mat[ROWS][COLS]; + int frameno; + vec_t center[2] = {{.x = .5, .y = .5}, {.x = ROWS - .5, .y = COLS - .5}}; + vec_t direction[2] = {{.x = 3, .y = 7}, {.x = 43, .y = 41}}; + struct sigaction osa; + WINDOW * topw = NULL, *w = NULL; + personality_t personality; + state_t s; + + srandom((unsigned int)time(NULL)); + + setlocale(LC_ALL, ""); + + state_init(&s, argc, argv); + + switch (s.progname[0]) { + case 'r': + personality = READ; + break; + case 'w': + personality = WRITE; + break; + default: + personality = STANDALONE; + break; + } + establish_handler(&osa); + + switch (personality) { + case WRITE: + matrix_open(&s, true); + create_group(&s); + create_dataset(&s); + break; + case READ: + matrix_open(&s, false); + open_group(&s); + open_dataset(&s); + break; + default: + break; + } + + if ((topw = initscr()) == NULL) + errx(EXIT_FAILURE, "initscr failed"); + else if ((w = subwin(topw, ROWS + 2, COLS + 2, 0, 0)) == NULL) + errx(EXIT_FAILURE, "subwin failed"); + + for (frameno = 0; unbroken;) { + struct timespec elapsed, start, stop; + uint64_t elapsed_ns; + clock_gettime(CLOCK_MONOTONIC, &start); + + switch (personality) { + case READ: + matrix_read(&s, &frameno, mat); + break; + case WRITE: + case STANDALONE: + matrix_compute(center, __arraycount(center), mat); + if (s.fuzz) + fuzz(mat); + break; + } + switch (personality) { + case READ: + case STANDALONE: + matrix_draw(w, mat); #if 0 wmove(topw, ROWS + 3, 0); waddstr(topw, "\"Don't cross the streams.\""); #endif - break; - case WRITE: - matrix_write(&s, frameno, mat); - break; - } - - snprintf(buf, sizeof(buf), "Frame %d.", frameno); - wmove(topw, ROWS + 2, 0); - waddstr(topw, buf); - snprintf(buf, sizeof(buf), "Rate %lld/s.", - 1000000000ULL / timespec2ns(&s.update_interval)); - wmove(topw, ROWS + 2, COLS + 2 - strlen(buf)); - waddstr(topw, buf); - wnoutrefresh(topw); - doupdate(); - - nanosleep(&s.update_interval, NULL); - - switch (personality) { - case STANDALONE: - case WRITE: - move_centers(center, direction, __arraycount(center)); - frameno++; - break; - case READ: - break; - } - clock_gettime(CLOCK_MONOTONIC, &stop); - - timespecsub(&stop, &start, &elapsed); - elapsed_ns = timespec2ns(&elapsed); - - if (elapsed_ns < s.min_elapsed_ns) - s.min_elapsed_ns = elapsed_ns; - if (elapsed_ns > s.max_elapsed_ns) - s.max_elapsed_ns = elapsed_ns; - s.total_elapsed_ns += elapsed_ns; - s.total_loops++; - } - endwin(); - fprintf(stderr, "Iteration stats:\n"); - fprintf(stderr, "min. elapsed %" PRIu64 " ms\n", - s.min_elapsed_ns / 1000000); - fprintf(stderr, "max. elapsed %" PRIu64 " ms\n", - s.max_elapsed_ns / 1000000); - fprintf(stderr, "avg. elapsed %.3f ms\n", - (double)s.total_elapsed_ns / s.total_loops / 1000000); - disestablish_handler(&osa); - return EXIT_SUCCESS; + break; + case WRITE: + matrix_write(&s, frameno, mat); + break; + } + + snprintf(buf, sizeof(buf), "Frame %d.", frameno); + wmove(topw, ROWS + 2, 0); + waddstr(topw, buf); + snprintf(buf, sizeof(buf), "Rate %lld/s.", 1000000000ULL / timespec2ns(&s.update_interval)); + wmove(topw, ROWS + 2, COLS + 2 - strlen(buf)); + waddstr(topw, buf); + wnoutrefresh(topw); + doupdate(); + + nanosleep(&s.update_interval, NULL); + + switch (personality) { + case STANDALONE: + case WRITE: + move_centers(center, direction, __arraycount(center)); + frameno++; + break; + case READ: + break; + } + clock_gettime(CLOCK_MONOTONIC, &stop); + + timespecsub(&stop, &start, &elapsed); + elapsed_ns = timespec2ns(&elapsed); + + if (elapsed_ns < s.min_elapsed_ns) + s.min_elapsed_ns = elapsed_ns; + if (elapsed_ns > s.max_elapsed_ns) + s.max_elapsed_ns = elapsed_ns; + s.total_elapsed_ns += elapsed_ns; + s.total_loops++; + } + endwin(); + fprintf(stderr, "Iteration stats:\n"); + fprintf(stderr, "min. elapsed %" PRIu64 " ms\n", s.min_elapsed_ns / 1000000); + fprintf(stderr, "max. elapsed %" PRIu64 " ms\n", s.max_elapsed_ns / 1000000); + fprintf(stderr, "avg. elapsed %.3f ms\n", (double)s.total_elapsed_ns / s.total_loops / 1000000); + disestablish_handler(&osa); + return EXIT_SUCCESS; } diff --git a/examples/h5_attribute.c b/examples/h5_attribute.c index 0e275c7..7a619f9 100644 --- a/examples/h5_attribute.c +++ b/examples/h5_attribute.c @@ -29,193 +29,192 @@ #define H5FILE_NAME "Attributes.h5" -#define RANK 1 /* Rank and size of the dataset */ -#define SIZE 7 +#define RANK 1 /* Rank and size of the dataset */ +#define SIZE 7 -#define ARANK 2 /* Rank and dimension sizes of the first dataset attribute */ +#define ARANK 2 /* Rank and dimension sizes of the first dataset attribute */ #define ADIM1 2 #define ADIM2 3 -#define ANAME "Float attribute" /* Name of the array attribute */ +#define ANAME "Float attribute" /* Name of the array attribute */ #define ANAMES "Character attribute" /* Name of the string attribute */ static herr_t attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata); - /* Operator function */ +/* Operator function */ int -main (void) +main(void) { - hid_t file, dataset; /* File and dataset identifiers */ - - hid_t fid; /* Dataspace identifier */ - hid_t attr1, attr2, attr3; /* Attribute identifiers */ - hid_t attr; - hid_t aid1, aid2, aid3; /* Attribute dataspace identifiers */ - hid_t atype, atype_mem; /* Attribute type */ - H5T_class_t type_class; - - hsize_t fdim[] = {SIZE}; - hsize_t adim[] = {ADIM1, ADIM2}; /* Dimensions of the first attribute */ - - float matrix[ADIM1][ADIM2]; /* Attribute data */ - - herr_t ret; /* Return value */ - H5O_info2_t oinfo; /* Object info */ - unsigned i, j; /* Counters */ - char string_out[80]; /* Buffer to read string attribute back */ - int point_out; /* Buffer to read scalar attribute back */ - - /* - * Data initialization. - */ - int vector[] = {1, 2, 3, 4, 5, 6, 7}; /* Dataset data */ - int point = 1; /* Value of the scalar attribute */ - char string[] = "ABCD"; /* Value of the string attribute */ - - - for (i=0; i < ADIM1; i++) { /* Values of the array attribute */ - for (j=0; j < ADIM2; j++) - matrix[i][j] = -1.; - } - - /* - * Create a file. - */ - file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create the dataspace for the dataset in the file. - */ - fid = H5Screate(H5S_SIMPLE); - ret = H5Sset_extent_simple(fid, RANK, fdim, NULL); - - /* - * Create the dataset in the file. - */ - dataset = H5Dcreate2(file, "Dataset", H5T_NATIVE_INT, fid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Write data to the dataset. - */ - ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT, vector); - - /* - * Create dataspace for the first attribute. - */ - aid1 = H5Screate(H5S_SIMPLE); - ret = H5Sset_extent_simple(aid1, ARANK, adim, NULL); - - /* - * Create array attribute. - */ - attr1 = H5Acreate2(dataset, ANAME, H5T_NATIVE_FLOAT, aid1, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Write array attribute. - */ - ret = H5Awrite(attr1, H5T_NATIVE_FLOAT, matrix); - - /* - * Create scalar attribute. - */ - aid2 = H5Screate(H5S_SCALAR); - attr2 = H5Acreate2(dataset, "Integer attribute", H5T_NATIVE_INT, aid2, - H5P_DEFAULT, H5P_DEFAULT); - - /* - * Write scalar attribute. - */ - ret = H5Awrite(attr2, H5T_NATIVE_INT, &point); - - /* - * Create string attribute. - */ - aid3 = H5Screate(H5S_SCALAR); - atype = H5Tcopy(H5T_C_S1); - H5Tset_size(atype, 5); - H5Tset_strpad(atype,H5T_STR_NULLTERM); - attr3 = H5Acreate2(dataset, ANAMES, atype, aid3, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Write string attribute. - */ - ret = H5Awrite(attr3, atype, string); - - /* - * Close attribute and file dataspaces, and datatype. - */ - ret = H5Sclose(aid1); - ret = H5Sclose(aid2); - ret = H5Sclose(aid3); - ret = H5Sclose(fid); - ret = H5Tclose(atype); - - /* - * Close the attributes. - */ - ret = H5Aclose(attr1); - ret = H5Aclose(attr2); - ret = H5Aclose(attr3); - - /* - * Close the dataset. - */ - ret = H5Dclose(dataset); - - /* - * Close the file. - */ - ret = H5Fclose(file); - - /* - * Reopen the file. - */ - file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT); - - /* - * Open the dataset. - */ - dataset = H5Dopen2(file, "Dataset", H5P_DEFAULT); - - /* - * Attach to the scalar attribute using attribute name, then read and - * display its value. - */ - attr = H5Aopen(dataset, "Integer attribute", H5P_DEFAULT); - ret = H5Aread(attr, H5T_NATIVE_INT, &point_out); - printf("The value of the attribute \"Integer attribute\" is %d \n", point_out); - ret = H5Aclose(attr); - - /* - * Find string attribute by iterating through all attributes - */ - ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS); - for(i = 0; i < (unsigned)oinfo.num_attrs; i++) { - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, H5P_DEFAULT); - atype = H5Aget_type(attr); - type_class = H5Tget_class(atype); - if (type_class == H5T_STRING) { - atype_mem = H5Tget_native_type(atype, H5T_DIR_ASCEND); - ret = H5Aread(attr, atype_mem, string_out); - printf("Found string attribute; its index is %d , value = %s \n", i, string_out); - ret = H5Tclose(atype_mem); - } - ret = H5Aclose(attr); - ret = H5Tclose(atype); + hid_t file, dataset; /* File and dataset identifiers */ + + hid_t fid; /* Dataspace identifier */ + hid_t attr1, attr2, attr3; /* Attribute identifiers */ + hid_t attr; + hid_t aid1, aid2, aid3; /* Attribute dataspace identifiers */ + hid_t atype, atype_mem; /* Attribute type */ + H5T_class_t type_class; + + hsize_t fdim[] = {SIZE}; + hsize_t adim[] = {ADIM1, ADIM2}; /* Dimensions of the first attribute */ + + float matrix[ADIM1][ADIM2]; /* Attribute data */ + + herr_t ret; /* Return value */ + H5O_info2_t oinfo; /* Object info */ + unsigned i, j; /* Counters */ + char string_out[80]; /* Buffer to read string attribute back */ + int point_out; /* Buffer to read scalar attribute back */ + + /* + * Data initialization. + */ + int vector[] = {1, 2, 3, 4, 5, 6, 7}; /* Dataset data */ + int point = 1; /* Value of the scalar attribute */ + char string[] = "ABCD"; /* Value of the string attribute */ + + for (i = 0; i < ADIM1; i++) { /* Values of the array attribute */ + for (j = 0; j < ADIM2; j++) + matrix[i][j] = -1.; + } + + /* + * Create a file. + */ + file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Create the dataspace for the dataset in the file. + */ + fid = H5Screate(H5S_SIMPLE); + ret = H5Sset_extent_simple(fid, RANK, fdim, NULL); + + /* + * Create the dataset in the file. + */ + dataset = H5Dcreate2(file, "Dataset", H5T_NATIVE_INT, fid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Write data to the dataset. + */ + ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, vector); + + /* + * Create dataspace for the first attribute. + */ + aid1 = H5Screate(H5S_SIMPLE); + ret = H5Sset_extent_simple(aid1, ARANK, adim, NULL); + + /* + * Create array attribute. + */ + attr1 = H5Acreate2(dataset, ANAME, H5T_NATIVE_FLOAT, aid1, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Write array attribute. + */ + ret = H5Awrite(attr1, H5T_NATIVE_FLOAT, matrix); + + /* + * Create scalar attribute. + */ + aid2 = H5Screate(H5S_SCALAR); + attr2 = H5Acreate2(dataset, "Integer attribute", H5T_NATIVE_INT, aid2, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Write scalar attribute. + */ + ret = H5Awrite(attr2, H5T_NATIVE_INT, &point); + + /* + * Create string attribute. + */ + aid3 = H5Screate(H5S_SCALAR); + atype = H5Tcopy(H5T_C_S1); + H5Tset_size(atype, 5); + H5Tset_strpad(atype, H5T_STR_NULLTERM); + attr3 = H5Acreate2(dataset, ANAMES, atype, aid3, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Write string attribute. + */ + ret = H5Awrite(attr3, atype, string); + + /* + * Close attribute and file dataspaces, and datatype. + */ + ret = H5Sclose(aid1); + ret = H5Sclose(aid2); + ret = H5Sclose(aid3); + ret = H5Sclose(fid); + ret = H5Tclose(atype); + + /* + * Close the attributes. + */ + ret = H5Aclose(attr1); + ret = H5Aclose(attr2); + ret = H5Aclose(attr3); + + /* + * Close the dataset. + */ + ret = H5Dclose(dataset); + + /* + * Close the file. + */ + ret = H5Fclose(file); + + /* + * Reopen the file. + */ + file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT); + + /* + * Open the dataset. + */ + dataset = H5Dopen2(file, "Dataset", H5P_DEFAULT); + + /* + * Attach to the scalar attribute using attribute name, then read and + * display its value. + */ + attr = H5Aopen(dataset, "Integer attribute", H5P_DEFAULT); + ret = H5Aread(attr, H5T_NATIVE_INT, &point_out); + printf("The value of the attribute \"Integer attribute\" is %d \n", point_out); + ret = H5Aclose(attr); + + /* + * Find string attribute by iterating through all attributes + */ + ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS); + for (i = 0; i < (unsigned)oinfo.num_attrs; i++) { + attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, + H5P_DEFAULT); + atype = H5Aget_type(attr); + type_class = H5Tget_class(atype); + if (type_class == H5T_STRING) { + atype_mem = H5Tget_native_type(atype, H5T_DIR_ASCEND); + ret = H5Aread(attr, atype_mem, string_out); + printf("Found string attribute; its index is %d , value = %s \n", i, string_out); + ret = H5Tclose(atype_mem); + } + ret = H5Aclose(attr); + ret = H5Tclose(atype); } - /* - * Get attribute info using iteration function. - */ + /* + * Get attribute info using iteration function. + */ ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_info, NULL); - /* - * Close the dataset and the file. - */ - H5Dclose(dataset); - H5Fclose(file); + /* + * Close the dataset and the file. + */ + H5Dclose(dataset); + H5Fclose(file); - return 0; + return 0; } /* @@ -224,13 +223,13 @@ main (void) static herr_t attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata) { - hid_t attr, atype, aspace; /* Attribute, datatype and dataspace identifiers */ - int rank; + hid_t attr, atype, aspace; /* Attribute, datatype and dataspace identifiers */ + int rank; hsize_t sdim[64]; - herr_t ret; - int i; - size_t npoints; /* Number of elements in the array attribute. */ - float *float_array; /* Pointer to the array attribute. */ + herr_t ret; + int i; + size_t npoints; /* Number of elements in the array attribute. */ + float * float_array; /* Pointer to the array attribute. */ /* avoid warnings */ opdata = opdata; @@ -250,17 +249,17 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata) */ atype = H5Aget_type(attr); aspace = H5Aget_space(attr); - rank = H5Sget_simple_extent_ndims(aspace); - ret = H5Sget_simple_extent_dims(aspace, sdim, NULL); + rank = H5Sget_simple_extent_ndims(aspace); + ret = H5Sget_simple_extent_dims(aspace, sdim, NULL); /* * Display rank and dimension sizes for the array attribute. */ - if(rank > 0) { + if (rank > 0) { printf("Rank : %d \n", rank); printf("Dimension sizes : "); - for (i=0; i< rank; i++) + for (i = 0; i < rank; i++) printf("%d ", (int)sdim[i]); printf("\n"); } @@ -271,11 +270,11 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata) if (H5T_FLOAT == H5Tget_class(atype)) { printf("Type : FLOAT \n"); - npoints = H5Sget_simple_extent_npoints(aspace); - float_array = (float *)malloc(sizeof(float)*(int)npoints); - ret = H5Aread(attr, atype, float_array); + npoints = H5Sget_simple_extent_npoints(aspace); + float_array = (float *)malloc(sizeof(float) * (int)npoints); + ret = H5Aread(attr, atype, float_array); printf("Values : "); - for( i = 0; i < (int)npoints; i++) + for (i = 0; i < (int)npoints; i++) printf("%f ", float_array[i]); printf("\n"); free(float_array); @@ -290,4 +289,3 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata) return 0; } - diff --git a/examples/h5_chunk_read.c b/examples/h5_chunk_read.c index c3455f4..01e8c5d 100644 --- a/examples/h5_chunk_read.c +++ b/examples/h5_chunk_read.c @@ -18,68 +18,66 @@ #include "hdf5.h" -#define H5FILE_NAME "SDSextendible.h5" +#define H5FILE_NAME "SDSextendible.h5" #define DATASETNAME "ExtendibleArray" -#define RANK 2 -#define RANKC 1 -#define NX 10 -#define NY 5 +#define RANK 2 +#define RANKC 1 +#define NX 10 +#define NY 5 int -main (void) +main(void) { - hid_t file; /* handles */ - hid_t dataset; - hid_t filespace; - hid_t memspace; - hid_t cparms; - hsize_t dims[2]; /* dataset and chunk dimensions*/ - hsize_t chunk_dims[2]; - hsize_t col_dims[1]; - hsize_t count[2]; - hsize_t offset[2]; - - herr_t status, status_n; - - int data_out[NX][NY]; /* buffer for dataset to be read */ - int chunk_out[2][5]; /* buffer for chunk to be read */ - int column[10]; /* buffer for column to be read */ - int rank, rank_chunk; - int i, j; - - + hid_t file; /* handles */ + hid_t dataset; + hid_t filespace; + hid_t memspace; + hid_t cparms; + hsize_t dims[2]; /* dataset and chunk dimensions*/ + hsize_t chunk_dims[2]; + hsize_t col_dims[1]; + hsize_t count[2]; + hsize_t offset[2]; + + herr_t status, status_n; + + int data_out[NX][NY]; /* buffer for dataset to be read */ + int chunk_out[2][5]; /* buffer for chunk to be read */ + int column[10]; /* buffer for column to be read */ + int rank, rank_chunk; + int i, j; /* * Open the file and the dataset. */ - file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT); + file = H5Fopen(H5FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT); dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT); /* * Get dataset rank and dimension. */ - filespace = H5Dget_space(dataset); /* Get filespace handle first. */ + filespace = H5Dget_space(dataset); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(filespace); status_n = H5Sget_simple_extent_dims(filespace, dims, NULL); - printf("dataset rank %d, dimensions %lu x %lu\n", - rank, (unsigned long)(dims[0]), (unsigned long)(dims[1])); + printf("dataset rank %d, dimensions %lu x %lu\n", rank, (unsigned long)(dims[0]), + (unsigned long)(dims[1])); /* * Define the memory space to read dataset. */ - memspace = H5Screate_simple(RANK,dims,NULL); + memspace = H5Screate_simple(RANK, dims, NULL); /* * Read dataset back and display. */ - status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, data_out); + status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, data_out); printf("\n"); printf("Dataset: \n"); for (j = 0; j < dims[0]; j++) { - for (i = 0; i < dims[1]; i++) printf("%d ", data_out[j][i]); - printf("\n"); + for (i = 0; i < dims[1]; i++) + printf("%d ", data_out[j][i]); + printf("\n"); } /* @@ -110,7 +108,7 @@ main (void) * and read it into column array. */ col_dims[0] = 10; - memspace = H5Screate_simple(RANKC, col_dims, NULL); + memspace = H5Screate_simple(RANKC, col_dims, NULL); /* * Define the column (hyperslab) to read. @@ -119,14 +117,12 @@ main (void) offset[1] = 2; count[0] = 10; count[1] = 1; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - count, NULL); - status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, column); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, count, NULL); + status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, column); printf("\n"); printf("Third column: \n"); for (i = 0; i < 10; i++) { - printf("%d \n", column[i]); + printf("%d \n", column[i]); } /* @@ -153,19 +149,19 @@ main (void) */ cparms = H5Dget_create_plist(dataset); /* Get properties handle first. */ - if (H5D_CHUNKED == H5Pget_layout(cparms)) { + if (H5D_CHUNKED == H5Pget_layout(cparms)) { - /* - * Get chunking information: rank and dimensions - */ - rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims); - printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, - (unsigned long)(chunk_dims[0]), (unsigned long)(chunk_dims[1])); + /* + * Get chunking information: rank and dimensions + */ + rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims); + printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, (unsigned long)(chunk_dims[0]), + (unsigned long)(chunk_dims[1])); /* * Define the memory space to read a chunk. */ - memspace = H5Screate_simple(rank_chunk,chunk_dims,NULL); + memspace = H5Screate_simple(rank_chunk, chunk_dims, NULL); /* * Define chunk in the file (hyperslab) to read. @@ -174,18 +170,17 @@ main (void) offset[1] = 0; count[0] = chunk_dims[0]; count[1] = chunk_dims[1]; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - count, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, count, NULL); /* * Read chunk back and display. */ - status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, chunk_out); + status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, chunk_out); printf("\n"); printf("Chunk: \n"); for (j = 0; j < chunk_dims[0]; j++) { - for (i = 0; i < chunk_dims[1]; i++) printf("%d ", chunk_out[j][i]); + for (i = 0; i < chunk_dims[1]; i++) + printf("%d ", chunk_out[j][i]); printf("\n"); } /* diff --git a/examples/h5_cmprss.c b/examples/h5_cmprss.c index 5feadd3..7557cf5 100644 --- a/examples/h5_cmprss.c +++ b/examples/h5_cmprss.c @@ -18,27 +18,29 @@ #include "hdf5.h" -#define FILE "cmprss.h5" -#define RANK 2 -#define DIM0 100 -#define DIM1 20 +#define FILE "cmprss.h5" +#define RANK 2 +#define DIM0 100 +#define DIM1 20 -int main () { +int +main() +{ - hid_t file_id, dataset_id, dataspace_id; /* identifiers */ - hid_t plist_id; + hid_t file_id, dataset_id, dataspace_id; /* identifiers */ + hid_t plist_id; - size_t nelmts; - unsigned flags, filter_info; + size_t nelmts; + unsigned flags, filter_info; H5Z_filter_t filter_type; - herr_t status; - hsize_t dims[2]; - hsize_t cdims[2]; + herr_t status; + hsize_t dims[2]; + hsize_t cdims[2]; - int i,j, numfilt; - int buf[DIM0][DIM1]; - int rbuf [DIM0][DIM1]; + int i, j, numfilt; + int buf[DIM0][DIM1]; + int rbuf[DIM0][DIM1]; /* Uncomment these variables to use SZIP compression unsigned szip_options_mask; @@ -46,25 +48,24 @@ int main () { */ /* Create a file. */ - file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - + file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create dataset "Compressed Data" in the group using absolute name. */ - dims[0] = DIM0; - dims[1] = DIM1; - dataspace_id = H5Screate_simple (RANK, dims, NULL); + dims[0] = DIM0; + dims[1] = DIM1; + dataspace_id = H5Screate_simple(RANK, dims, NULL); - plist_id = H5Pcreate (H5P_DATASET_CREATE); + plist_id = H5Pcreate(H5P_DATASET_CREATE); /* Dataset must be chunked for compression */ cdims[0] = 20; cdims[1] = 20; - status = H5Pset_chunk (plist_id, 2, cdims); + status = H5Pset_chunk(plist_id, 2, cdims); /* Set ZLIB / DEFLATE Compression using compression level 6. * To use SZIP Compression comment out these lines. - */ - status = H5Pset_deflate (plist_id, 6); + */ + status = H5Pset_deflate(plist_id, 6); /* Uncomment these lines to set SZIP Compression szip_options_mask = H5_SZIP_NN_OPTION_MASK; @@ -72,51 +73,49 @@ int main () { status = H5Pset_szip (plist_id, szip_options_mask, szip_pixels_per_block); */ - dataset_id = H5Dcreate2 (file_id, "Compressed_Data", H5T_STD_I32BE, - dataspace_id, H5P_DEFAULT, plist_id, H5P_DEFAULT); + dataset_id = H5Dcreate2(file_id, "Compressed_Data", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, plist_id, + H5P_DEFAULT); - for (i = 0; i< DIM0; i++) - for (j=0; j #include - + #include "hdf5.h" - -#define BUF_SIZE 1048576 -#define N_LOOPS 64 - + +#define BUF_SIZE 1048576 +#define N_LOOPS 64 + #define TESTFILE "h5_debug_trace_out.h5" - + int main(int argc, char **argv) { - int i, j; + int i, j; int *data; - - hid_t fid; - hid_t pid; - hid_t did; - hid_t sid; - - hsize_t dims[1] = { BUF_SIZE }; - hsize_t chunk_sizes[1] = { 1024 }; - + + hid_t fid; + hid_t pid; + hid_t did; + hid_t sid; + + hsize_t dims[1] = {BUF_SIZE}; + hsize_t chunk_sizes[1] = {1024}; + herr_t err; - + /*************************************************************************/ /* Warn the user about trace deluge to come */ @@ -82,55 +82,52 @@ main(int argc, char **argv) fflush(stdout); /* This will emit H5Tconvert() performance information */ - - for(i = 0; i < N_LOOPS; i++) { - + + for (i = 0; i < N_LOOPS; i++) { + /* The buffer has to be large enough to hold the conversion output */ data = (int *)malloc(BUF_SIZE * sizeof(double)); - - for(j = 0; j < BUF_SIZE; j++) { + + for (j = 0; j < BUF_SIZE; j++) { data[j] = j; } - - err = H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_DOUBLE, BUF_SIZE, data, - NULL, H5P_DEFAULT); - - if(err < 0) { + + err = H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_DOUBLE, BUF_SIZE, data, NULL, H5P_DEFAULT); + + if (err < 0) { fprintf(stderr, "ERROR: Conversion failed\n"); free(data); return err; } - + free(data); - } - - + /* This will emit H5Z performance information */ - + data = (int *)malloc(BUF_SIZE * sizeof(int)); - - for(i = 0; i < BUF_SIZE; i++) { + + for (i = 0; i < BUF_SIZE; i++) { data[i] = i; } - + fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - + pid = H5Pcreate(H5P_DATASET_CREATE); err = H5Pset_chunk(pid, 1, chunk_sizes); err = H5Pset_shuffle(pid); - + sid = H5Screate_simple(1, dims, dims); did = H5Dcreate2(fid, "somedata", H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT); err = H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data); - + H5Sclose(sid); H5Dclose(did); H5Pclose(pid); H5Fclose(fid); - + free(data); - + /* Finished */ fflush(stdout); printf("\n"); @@ -138,7 +135,6 @@ main(int argc, char **argv) printf("\n"); remove(TESTFILE); - + return 0; } - diff --git a/examples/h5_drivers.c b/examples/h5_drivers.c index 43c1fc7..486cf3b 100644 --- a/examples/h5_drivers.c +++ b/examples/h5_drivers.c @@ -22,13 +22,12 @@ #include "stdlib.h" /* global variables */ -int cleanup_g = -1; /* whether to clean. Init to not set. */ +int cleanup_g = -1; /* whether to clean. Init to not set. */ /* prototypes */ void cleanup(const char *); void split_file(void); - /* * Cleanup a file unless $HDF5_NOCLEANUP is set. */ @@ -36,12 +35,11 @@ void cleanup(const char *filename) { if (cleanup_g == -1) - cleanup_g = getenv("HDF5_NOCLEANUP") ? 0 : 1; + cleanup_g = getenv("HDF5_NOCLEANUP") ? 0 : 1; if (cleanup_g) - remove(filename); + remove(filename); } - /* * This shows how to use the split file driver. */ @@ -55,7 +53,7 @@ split_file(void) /* the metadata and rawdata files. */ fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); - fid=H5Fcreate("Station1",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); + fid = H5Fcreate("Station1", H5F_ACC_TRUNC, H5P_DEFAULT, fapl); /* using the file ... */ H5Fclose(fid); H5Pclose(fapl); @@ -68,7 +66,7 @@ split_file(void) /* the metadata and rawdata files. */ fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "/tmp/%s-r.h5", H5P_DEFAULT); - fid=H5Fcreate("PointA",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); + fid = H5Fcreate("PointA", H5F_ACC_TRUNC, H5P_DEFAULT, fapl); /* using the file ... */ H5Fclose(fid); H5Pclose(fapl); @@ -81,7 +79,7 @@ split_file(void) /* the metadata and rawdata files. */ fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_split(fapl, NULL, H5P_DEFAULT, NULL, H5P_DEFAULT); - fid=H5Fcreate("Measure",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); + fid = H5Fcreate("Measure", H5F_ACC_TRUNC, H5P_DEFAULT, fapl); /* using the file ... */ H5Fclose(fid); H5Pclose(fapl); @@ -90,13 +88,12 @@ split_file(void) cleanup("Measure.raw"); } - /* Main Body */ int -main (void) +main(void) { split_file(); - return(0); + return (0); } diff --git a/examples/h5_dtransform.c b/examples/h5_dtransform.c index 0b718ad..88eef3c 100644 --- a/examples/h5_dtransform.c +++ b/examples/h5_dtransform.c @@ -33,50 +33,56 @@ #include "hdf5.h" -#define ROWS 12 -#define COLS 18 - -const float windchillF[ROWS][COLS] = - { {36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0 }, - {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0 } , - {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0 }, - {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0 }, - {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0 }, - {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0 }, - {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0 }, - {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0 }, - {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0 }, - {26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0}, - {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0}, - {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0} - }; - -#define PRINT(array) \ -{ \ - for(i=0; i #include - /* "Windows to Unix" traversal function for external links * * Translates a filename stored in Unix format to Windows format by replacing @@ -37,45 +36,44 @@ * Note that this may not be necessary on your system; many Windows systems can * understand Unix paths. */ -static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id) +static hid_t +elink_unix2win_trav(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t lapl_id, hid_t dxpl_id) { - hid_t fid; - const char *file_name; - const char *obj_name; - char *new_fname = NULL; /* Buffer allocated to hold Unix file path */ - ssize_t prefix_len; /* External link prefix length */ - size_t fname_len; - size_t start_pos; /* Initial position in new_fname buffer */ - size_t x; /* Counter variable */ - hid_t ret_value = -1; + hid_t fid; + const char *file_name; + const char *obj_name; + char * new_fname = NULL; /* Buffer allocated to hold Unix file path */ + ssize_t prefix_len; /* External link prefix length */ + size_t fname_len; + size_t start_pos; /* Initial position in new_fname buffer */ + size_t x; /* Counter variable */ + hid_t ret_value = -1; printf("Converting Unix path to Windows path.\n"); - if(H5Lunpack_elink_val(udata, udata_size, NULL, &file_name, &obj_name) < 0) + if (H5Lunpack_elink_val(udata, udata_size, NULL, &file_name, &obj_name) < 0) goto error; fname_len = strlen(file_name); /* See if the external link prefix property is set */ - if((prefix_len = H5Pget_elink_prefix(lapl_id, NULL, 0)) < 0) + if ((prefix_len = H5Pget_elink_prefix(lapl_id, NULL, 0)) < 0) goto error; /* If so, prepend it to the filename. We assume that the prefix * is in the correct format for the current file system. */ - if(prefix_len > 0) - { + if (prefix_len > 0) { /* Allocate a buffer to hold the filename plus prefix */ new_fname = malloc(prefix_len + fname_len + 1); /* Copy the prefix into the buffer */ - if(H5Pget_elink_prefix(lapl_id, new_fname, (size_t)(prefix_len + 1)) < 0) + if (H5Pget_elink_prefix(lapl_id, new_fname, (size_t)(prefix_len + 1)) < 0) goto error; start_pos = prefix_len; } - else - { + else { /* Allocate a buffer to hold just the filename */ new_fname = malloc(fname_len + 1); start_pos = 0; @@ -84,9 +82,8 @@ static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group, /* We should now copy file_name into new_fname starting at position pos. * We'll convert '/' characters into '\' characters as we go. */ - for(x=0; file_name[x] != '\0'; x++) - { - if(file_name[x] == '/') + for (x = 0; file_name[x] != '\0'; x++) { + if (file_name[x] == '/') new_fname[x + start_pos] = '\\'; else new_fname[x + start_pos] = file_name[x]; @@ -94,38 +91,37 @@ static hid_t elink_unix2win_trav(const char *link_name, hid_t cur_group, new_fname[x + start_pos] = '\0'; /* Now open the file and object within it */ - if((fid = H5Fopen(new_fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(new_fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto error; ret_value = H5Oopen(fid, obj_name, lapl_id); /* If this fails, our return value will be negative. */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* Free file name if it's been allocated */ - if(new_fname) + if (new_fname) free(new_fname); return ret_value; error: /* Free file name if it's been allocated */ - if(new_fname) + if (new_fname) free(new_fname); return -1; } const H5L_class_t elink_unix2win_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - H5L_TYPE_EXTERNAL, /* Link type id number */ - "unix2win external link", /* Link class name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move callback */ - NULL, /* Copy callback */ - elink_unix2win_trav, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + H5L_TYPE_EXTERNAL, /* Link type id number */ + "unix2win external link", /* Link class name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move callback */ + NULL, /* Copy callback */ + elink_unix2win_trav, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; - /* The example function. * Creates a file named "unix2win.h5" with an external link pointing to * the file "u2w/u2w_target.h5". @@ -136,55 +132,65 @@ const H5L_class_t elink_unix2win_class[1] = {{ static int unix2win_example(void) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ /* Create the target file. */ #ifdef H5_HAVE_WIN32_API - if((fid=H5Fcreate("u2w\\u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) goto error; + if ((fid = H5Fcreate("u2w\\u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; #else - if((fid=H5Fcreate("u2w/u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) goto error; + if ((fid = H5Fcreate("u2w/u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; #endif - if(H5Fclose(fid) < 0) goto error; + if (H5Fclose(fid) < 0) + goto error; /* Create the source file with an external link in Windows format */ - if((fid=H5Fcreate("unix2win.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) goto error; + if ((fid = H5Fcreate("unix2win.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* Create the external link */ - if(H5Lcreate_external("u2w/../u2w/u2w_target.h5", "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; + if (H5Lcreate_external("u2w/../u2w/u2w_target.h5", "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto error; - /* If we are not on Windows, assume we are on a Unix-y filesystem and - * follow the external link normally. - * If we are on Windows, register the unix2win traversal function so - * that external links can be traversed. - */ + /* If we are not on Windows, assume we are on a Unix-y filesystem and + * follow the external link normally. + * If we are on Windows, register the unix2win traversal function so + * that external links can be traversed. + */ #ifdef H5_HAVE_WIN32_API /* Register the elink_unix2win class defined above to replace default * external links */ - if(H5Lregister(elink_unix2win_class) < 0) goto error; + if (H5Lregister(elink_unix2win_class) < 0) + goto error; #endif /* Now follow the link */ - if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) goto error; + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) + goto error; printf("Successfully followed external link.\n"); /* Close the group and the file */ - if(H5Gclose(gid) <0) goto error; - if(H5Fclose(fid) <0) goto error; + if (H5Gclose(gid) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; return 0; - error: +error: printf("Error!\n"); - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return -1; } - /* Main function * @@ -193,12 +199,10 @@ unix2win_example(void) int main(void) { - int ret; + int ret; printf("Testing unix2win external links.\n"); ret = unix2win_example(); return ret; } - - diff --git a/examples/h5_extend.c b/examples/h5_extend.c index 6018e65..749a73a 100644 --- a/examples/h5_extend.c +++ b/examples/h5_extend.c @@ -18,127 +18,114 @@ * It is used in the HDF5 Tutorial. */ - #include "hdf5.h" #define FILENAME "extend.h5" #define DATASETNAME "ExtendibleArray" -#define RANK 2 +#define RANK 2 int -main (void) +main(void) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t filespace, memspace; - hid_t prop; - - hsize_t dims[2] = {3, 3}; /* dataset dimensions at creation time */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - herr_t status; - hsize_t chunk_dims[2] = {2, 5}; - int data[3][3] = { {1, 1, 1}, /* data to write */ - {1, 1, 1}, - {1, 1, 1} }; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t filespace, memspace; + hid_t prop; + + hsize_t dims[2] = {3, 3}; /* dataset dimensions at creation time */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + herr_t status; + hsize_t chunk_dims[2] = {2, 5}; + int data[3][3] = {{1, 1, 1}, /* data to write */ + {1, 1, 1}, + {1, 1, 1}}; /* Variables used in extending and writing to the extended portion of dataset */ - hsize_t size[2]; - hsize_t offset[2]; - hsize_t dimsext[2] = {7, 3}; /* extend dimensions */ - int dataext[7][3] = { {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4}, - {2, 3, 4} }; + hsize_t size[2]; + hsize_t offset[2]; + hsize_t dimsext[2] = {7, 3}; /* extend dimensions */ + int dataext[7][3] = {{2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}, {2, 3, 4}}; /* Variables used in reading data back */ - hsize_t chunk_dimsr[2]; - hsize_t dimsr[2]; - hsize_t i, j; - int rdata[10][3]; - herr_t status_n; - int rank, rank_chunk; + hsize_t chunk_dimsr[2]; + hsize_t dimsr[2]; + hsize_t i, j; + int rdata[10][3]; + herr_t status_n; + int rank, rank_chunk; /* Create the data space with unlimited dimensions. */ - dataspace = H5Screate_simple (RANK, dims, maxdims); + dataspace = H5Screate_simple(RANK, dims, maxdims); /* Create a new file. If file exists its contents will be overwritten. */ - file = H5Fcreate (FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Modify dataset creation properties, i.e. enable chunking */ - prop = H5Pcreate (H5P_DATASET_CREATE); - status = H5Pset_chunk (prop, RANK, chunk_dims); + prop = H5Pcreate(H5P_DATASET_CREATE); + status = H5Pset_chunk(prop, RANK, chunk_dims); /* Create a new dataset within the file using chunk creation properties. */ - dataset = H5Dcreate2 (file, DATASETNAME, H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, prop, H5P_DEFAULT); + dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, prop, H5P_DEFAULT); /* Write data to dataset */ - status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data); + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); /* Extend the dataset. Dataset becomes 10 x 3 */ - size[0] = dims[0]+ dimsext[0]; + size[0] = dims[0] + dimsext[0]; size[1] = dims[1]; - status = H5Dset_extent (dataset, size); + status = H5Dset_extent(dataset, size); /* Select a hyperslab in extended portion of dataset */ - filespace = H5Dget_space (dataset); + filespace = H5Dget_space(dataset); offset[0] = 3; offset[1] = 0; - status = H5Sselect_hyperslab (filespace, H5S_SELECT_SET, offset, NULL, - dimsext, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dimsext, NULL); /* Define memory space */ - memspace = H5Screate_simple (RANK, dimsext, NULL); + memspace = H5Screate_simple(RANK, dimsext, NULL); /* Write the data to the extended portion of dataset */ - status = H5Dwrite (dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, dataext); + status = H5Dwrite(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, dataext); /* Close resources */ - status = H5Dclose (dataset); - status = H5Pclose (prop); - status = H5Sclose (dataspace); - status = H5Sclose (memspace); - status = H5Sclose (filespace); - status = H5Fclose (file); + status = H5Dclose(dataset); + status = H5Pclose(prop); + status = H5Sclose(dataspace); + status = H5Sclose(memspace); + status = H5Sclose(filespace); + status = H5Fclose(file); /******************************************** * Re-open the file and read the data back. * ********************************************/ - file = H5Fopen (FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); - dataset = H5Dopen2 (file, DATASETNAME, H5P_DEFAULT); + file = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); + dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT); - filespace = H5Dget_space (dataset); - rank = H5Sget_simple_extent_ndims (filespace); - status_n = H5Sget_simple_extent_dims (filespace, dimsr, NULL); + filespace = H5Dget_space(dataset); + rank = H5Sget_simple_extent_ndims(filespace); + status_n = H5Sget_simple_extent_dims(filespace, dimsr, NULL); - prop = H5Dget_create_plist (dataset); + prop = H5Dget_create_plist(dataset); - if (H5D_CHUNKED == H5Pget_layout (prop)) - rank_chunk = H5Pget_chunk (prop, rank, chunk_dimsr); + if (H5D_CHUNKED == H5Pget_layout(prop)) + rank_chunk = H5Pget_chunk(prop, rank, chunk_dimsr); - memspace = H5Screate_simple (rank, dimsr, NULL); - status = H5Dread (dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, rdata); + memspace = H5Screate_simple(rank, dimsr, NULL); + status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rdata); printf("\n"); printf("Dataset: \n"); - for (j = 0; j < dimsr[0]; j++) - { - for (i = 0; i < dimsr[1]; i++) - printf("%d ", rdata[j][i]); - printf("\n"); + for (j = 0; j < dimsr[0]; j++) { + for (i = 0; i < dimsr[1]; i++) + printf("%d ", rdata[j][i]); + printf("\n"); } - status = H5Pclose (prop); - status = H5Dclose (dataset); - status = H5Sclose (filespace); - status = H5Sclose (memspace); - status = H5Fclose (file); + status = H5Pclose(prop); + status = H5Dclose(dataset); + status = H5Sclose(filespace); + status = H5Sclose(memspace); + status = H5Fclose(file); } diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c index 4abda30..ad7ef50 100644 --- a/examples/h5_extend_write.c +++ b/examples/h5_extend_write.c @@ -20,43 +20,42 @@ #include "hdf5.h" -#define H5FILE_NAME "SDSextendible.h5" +#define H5FILE_NAME "SDSextendible.h5" #define DATASETNAME "ExtendibleArray" -#define RANK 2 -#define NX 10 -#define NY 5 +#define RANK 2 +#define NX 10 +#define NY 5 int -main (void) +main(void) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t filespace; - hid_t cparms; - hsize_t dims[2] = { 3, 3}; /* - * dataset dimensions - * at the creation time - */ - hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */ - hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */ - hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */ + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t filespace; + hid_t cparms; + hsize_t dims[2] = {3, 3}; /* + * dataset dimensions + * at the creation time + */ + hsize_t dims1[2] = {3, 3}; /* data1 dimensions */ + hsize_t dims2[2] = {7, 1}; /* data2 dimensions */ + hsize_t dims3[2] = {2, 2}; /* data3 dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims[2] ={2, 5}; - hsize_t size[2]; - hsize_t offset[2]; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims[2] = {2, 5}; + hsize_t size[2]; + hsize_t offset[2]; - herr_t status; + herr_t status; - int data1[3][3] = { {1, 1, 1}, /* data to write */ - {1, 1, 1}, - {1, 1, 1} }; + int data1[3][3] = {{1, 1, 1}, /* data to write */ + {1, 1, 1}, + {1, 1, 1}}; - int data2[7] = { 2, 2, 2, 2, 2, 2, 2}; + int data2[7] = {2, 2, 2, 2, 2, 2, 2}; - int data3[2][2] = { {3, 3}, - {3, 3} }; - int fillvalue = 0; + int data3[2][2] = {{3, 3}, {3, 3}}; + int fillvalue = 0; /* * Create the data space with unlimited dimensions. @@ -72,22 +71,21 @@ main (void) * Modify dataset creation properties, i.e. enable chunking. */ cparms = H5Pcreate(H5P_DATASET_CREATE); - status = H5Pset_chunk( cparms, RANK, chunk_dims); - status = H5Pset_fill_value (cparms, H5T_NATIVE_INT, &fillvalue ); + status = H5Pset_chunk(cparms, RANK, chunk_dims); + status = H5Pset_fill_value(cparms, H5T_NATIVE_INT, &fillvalue); /* * Create a new dataset within the file using cparms * creation properties. */ - dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT); + dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT); /* * Extend the dataset. This call assures that dataset is at least 3 x 3. */ - size[0] = 3; - size[1] = 3; - status = H5Dset_extent(dataset, size); + size[0] = 3; + size[1] = 3; + status = H5Dset_extent(dataset, size); /* * Select a hyperslab. @@ -95,22 +93,20 @@ main (void) filespace = H5Dget_space(dataset); offset[0] = 0; offset[1] = 0; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - dims1, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims1, NULL); /* * Write the data to the hyperslab. */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5P_DEFAULT, data1); + status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data1); /* * Extend the dataset. Dataset becomes 10 x 3. */ - dims[0] = dims1[0] + dims2[0]; - size[0] = dims[0]; - size[1] = dims[1]; - status = H5Dset_extent(dataset, size); + dims[0] = dims1[0] + dims2[0]; + size[0] = dims[0]; + size[1] = dims[1]; + status = H5Dset_extent(dataset, size); /* * Select a hyperslab. @@ -118,8 +114,7 @@ main (void) filespace = H5Dget_space(dataset); offset[0] = 3; offset[1] = 0; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - dims2, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims2, NULL); /* * Define memory space @@ -129,16 +124,15 @@ main (void) /* * Write the data to the hyperslab. */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5P_DEFAULT, data2); + status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data2); /* * Extend the dataset. Dataset becomes 10 x 5. */ - dims[1] = dims1[1] + dims3[1]; - size[0] = dims[0]; - size[1] = dims[1]; - status = H5Dset_extent(dataset, size); + dims[1] = dims1[1] + dims3[1]; + size[0] = dims[0]; + size[1] = dims[1]; + status = H5Dset_extent(dataset, size); /* * Select a hyperslab @@ -146,8 +140,7 @@ main (void) filespace = H5Dget_space(dataset); offset[0] = 0; offset[1] = 3; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, - dims3, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims3, NULL); /* * Define memory space. @@ -157,8 +150,7 @@ main (void) /* * Write the data to the hyperslab. */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5P_DEFAULT, data3); + status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, H5P_DEFAULT, data3); /* * Resulting dataset diff --git a/examples/h5_extlink.c b/examples/h5_extlink.c index fea1fa2..15f76fb 100644 --- a/examples/h5_extlink.c +++ b/examples/h5_extlink.c @@ -26,37 +26,36 @@ #define PREFIX_SOURCE_FILE "extlink_prefix_source.h5" -#define SOFT_LINK_FILE "soft_link.h5" -#define SOFT_LINK_NAME "soft_link_to_group" +#define SOFT_LINK_FILE "soft_link.h5" +#define SOFT_LINK_NAME "soft_link_to_group" #define UD_SOFT_LINK_NAME "ud_soft_link" -#define TARGET_GROUP "target_group" +#define TARGET_GROUP "target_group" #define UD_SOFT_CLASS 65 -#define HARD_LINK_FILE "hard_link.h5" -#define HARD_LINK_NAME "hard_link_to_group" +#define HARD_LINK_FILE "hard_link.h5" +#define HARD_LINK_NAME "hard_link_to_group" #define UD_HARD_LINK_NAME "ud_hard_link" #define UD_HARD_CLASS 66 #define PLIST_LINK_PROP "plist_link_prop" -#define UD_PLIST_CLASS 66 +#define UD_PLIST_CLASS 66 - - /* Basic external link example * * Creates two files and uses an external link to access an object in the * second file from the first file. */ -static void extlink_example(void) +static void +extlink_example(void) { hid_t source_file_id, targ_file_id; hid_t group_id, group2_id; /* Create two files, a source and a target */ source_file_id = H5Fcreate(SOURCE_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - targ_file_id = H5Fcreate(TARGET_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + targ_file_id = H5Fcreate(TARGET_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create a group in the target file for the external link to point to. */ group_id = H5Gcreate2(targ_file_id, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -96,7 +95,6 @@ static void extlink_example(void) */ } - /* External link prefix example * * Uses a group access property list to set a "prefix" for the filenames @@ -109,7 +107,8 @@ static void extlink_example(void) * where it is run (so to run this example on Unix, first mkdir red and mkdir * blue). */ -static void extlink_prefix_example(void) +static void +extlink_prefix_example(void) { hid_t source_file_id, red_file_id, blue_file_id; hid_t group_id, group2_id; @@ -119,14 +118,15 @@ static void extlink_prefix_example(void) * the same name, but one will be located in the red directory and one will * be located in the blue directory */ source_file_id = H5Fcreate(PREFIX_SOURCE_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - red_file_id = H5Fcreate("red/prefix_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - blue_file_id = H5Fcreate("blue/prefix_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + red_file_id = H5Fcreate("red/prefix_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + blue_file_id = H5Fcreate("blue/prefix_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* This test needs a red and a blue directory in the filesystem. If they're not present, * trying to create the files above will fail. */ - if(red_file_id < 0 || blue_file_id < 0) - printf("This test requires directories named 'red' and 'blue' to exist. Did you forget to create them?\n"); + if (red_file_id < 0 || blue_file_id < 0) + printf("This test requires directories named 'red' and 'blue' to exist. Did you forget to create " + "them?\n"); /* Create an external link in the source file pointing to the root group of * a file named prefix_target.h5. This file doesn't exist in the current @@ -163,7 +163,7 @@ static void extlink_prefix_example(void) * directory. */ H5Pset_elink_prefix(gapl_id, "blue/"); - group_id = H5Gopen2(source_file_id, "ext_link", gapl_id); + group_id = H5Gopen2(source_file_id, "ext_link", gapl_id); group2_id = H5Gcreate2(group_id, "sky blue", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Close both groups. */ @@ -171,7 +171,7 @@ static void extlink_prefix_example(void) H5Gclose(group_id); /* Each file has had a group created inside it using the same external link. */ - group_id = H5Gopen2(red_file_id, "pink", H5P_DEFAULT); + group_id = H5Gopen2(red_file_id, "pink", H5P_DEFAULT); group2_id = H5Gopen2(blue_file_id, "sky blue", H5P_DEFAULT); /* Clean up our open IDs */ @@ -189,7 +189,6 @@ static void extlink_prefix_example(void) */ } - /* Soft Link example * * Create a new class of user-defined links that behave like HDF5's built-in @@ -207,10 +206,11 @@ static void extlink_prefix_example(void) * We might also have wanted to supply a creation callback that checks * that a path was supplied in the udata. */ -static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id); +static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t lapl_id, hid_t dxpl_id); -static void soft_link_example(void) +static void +soft_link_example(void) { hid_t file_id; hid_t group_id; @@ -220,27 +220,26 @@ static void soft_link_example(void) * callback. */ const H5L_class_t UD_soft_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* Version number for this struct. - * This field is always H5L_LINK_CLASS_T_VERS */ - (H5L_type_t)UD_SOFT_CLASS, /* Link class id number. This can be any - * value between H5L_TYPE_UD_MIN (64) and - * H5L_TYPE_MAX (255). It should be a - * value that isn't already being used by - * another kind of link. We'll use 65. */ - "UD_soft_link", /* Link class name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move callback */ - NULL, /* Copy callback */ - UD_soft_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* Version number for this struct. + * This field is always H5L_LINK_CLASS_T_VERS */ + (H5L_type_t)UD_SOFT_CLASS, /* Link class id number. This can be any + * value between H5L_TYPE_UD_MIN (64) and + * H5L_TYPE_MAX (255). It should be a + * value that isn't already being used by + * another kind of link. We'll use 65. */ + "UD_soft_link", /* Link class name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move callback */ + NULL, /* Copy callback */ + UD_soft_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; - /* First, create a file and an object within the file for the link to * point to. */ - file_id = H5Fcreate(SOFT_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(SOFT_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); group_id = H5Gcreate2(file_id, TARGET_GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(group_id); @@ -275,12 +274,13 @@ static void soft_link_example(void) * The actual traversal function simply needs to open the correct object by * name and return its ID. */ - -static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id) + +static hid_t +UD_soft_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, hid_t lapl_id, + hid_t dxpl_id) { - const char *target = (const char *) udata; - hid_t ret_value; + const char *target = (const char *)udata; + hid_t ret_value; /* Pass the udata straight through to HDF5. If it's invalid, let HDF5 * return an error. @@ -289,7 +289,6 @@ static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group, return ret_value; } - /* Hard Link example * * Create a new class of user-defined links that behave like HDF5's built-in @@ -305,17 +304,17 @@ static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group, * To keep the example simple, these links don't have a query callback. * Generally, real link classes should always be query-able. */ -static herr_t UD_hard_create(const char *link_name, hid_t loc_group, - const void *udata, size_t udata_size, hid_t lcpl_id); -static herr_t UD_hard_delete(const char *link_name, hid_t loc_group, - const void *udata, size_t udata_size); -static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id); - -static void hard_link_example(void) +static herr_t UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size, + hid_t lcpl_id); +static herr_t UD_hard_delete(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size); +static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t lapl_id, hid_t dxpl_id); + +static void +hard_link_example(void) { - hid_t file_id; - hid_t group_id; + hid_t file_id; + hid_t group_id; H5L_info2_t li; /* Define the link class that we'll use to register "user-defined hard * links" using the callbacks we defined above. @@ -323,27 +322,26 @@ static void hard_link_example(void) * callback. */ const H5L_class_t UD_hard_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* Version number for this struct. - * This field is always H5L_LINK_CLASS_T_VERS */ - (H5L_type_t)UD_HARD_CLASS, /* Link class id number. This can be any - * value between H5L_TYPE_UD_MIN (64) and - * H5L_TYPE_MAX (255). It should be a - * value that isn't already being used by - * another kind of link. We'll use 66. */ - "UD_hard_link", /* Link class name for debugging */ - UD_hard_create, /* Creation callback */ - NULL, /* Move callback */ - NULL, /* Copy callback */ - UD_hard_traverse, /* The actual traversal function */ - UD_hard_delete, /* Deletion callback */ - NULL /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* Version number for this struct. + * This field is always H5L_LINK_CLASS_T_VERS */ + (H5L_type_t)UD_HARD_CLASS, /* Link class id number. This can be any + * value between H5L_TYPE_UD_MIN (64) and + * H5L_TYPE_MAX (255). It should be a + * value that isn't already being used by + * another kind of link. We'll use 66. */ + "UD_hard_link", /* Link class name for debugging */ + UD_hard_create, /* Creation callback */ + NULL, /* Move callback */ + NULL, /* Copy callback */ + UD_hard_traverse, /* The actual traversal function */ + UD_hard_delete, /* Deletion callback */ + NULL /* Query callback */ }}; - /* First, create a file and an object within the file for the link to * point to. */ - file_id = H5Fcreate(HARD_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(HARD_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); group_id = H5Gcreate2(file_id, TARGET_GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(group_id); @@ -366,8 +364,8 @@ static void hard_link_example(void) /* Now create a user-defined link. We give it the group's address * as its udata. */ - H5Lcreate_ud(file_id, UD_HARD_LINK_NAME, (H5L_type_t)UD_HARD_CLASS, &(li.u.token), - sizeof(H5O_token_t), H5P_DEFAULT, H5P_DEFAULT); + H5Lcreate_ud(file_id, UD_HARD_LINK_NAME, (H5L_type_t)UD_HARD_CLASS, &(li.u.token), sizeof(H5O_token_t), + H5P_DEFAULT, H5P_DEFAULT); /* The UD hard link has now incremented the group's reference count * like a normal hard link would. This means that we can unlink the @@ -401,42 +399,39 @@ static void hard_link_example(void) * If this function returns a negative value, the call to H5Lcreate_ud() * will also return failure and the link will not be created. */ -static herr_t UD_hard_create(const char *link_name, hid_t loc_group, - const void *udata, size_t udata_size, hid_t lcpl_id) +static herr_t +UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size, hid_t lcpl_id) { H5O_token_t token; - hid_t target_obj = H5I_INVALID_HID; - herr_t ret_value = 0; + hid_t target_obj = H5I_INVALID_HID; + herr_t ret_value = 0; /* Make sure that the address passed in looks valid */ - if(udata_size != sizeof(H5O_token_t)) - { - ret_value = -1; - goto done; + if (udata_size != sizeof(H5O_token_t)) { + ret_value = -1; + goto done; } - token = *((H5O_token_t *) udata); + token = *((H5O_token_t *)udata); /* Open the object this link points to so that we can increment * its reference count. This also ensures that the token passed * in points to a real object (although this check is not perfect!) */ target_obj = H5Oopen_by_token(loc_group, token); - if(target_obj < 0) - { - ret_value = -1; - goto done; + if (target_obj < 0) { + ret_value = -1; + goto done; } /* Increment the reference count of the target object */ - if(H5Oincr_refcount(target_obj) < 0) - { - ret_value = -1; - goto done; + if (H5Oincr_refcount(target_obj) < 0) { + ret_value = -1; + goto done; } done: /* Close the target object if we opened it */ - if(target_obj >= 0) + if (target_obj >= 0) H5Oclose(target_obj); return ret_value; } @@ -445,42 +440,39 @@ done: * Since the creation function increments the object's reference count, it's * important to decrement it again when the link is deleted. */ -static herr_t UD_hard_delete(const char *link_name, hid_t loc_group, - const void *udata, size_t udata_size) +static herr_t +UD_hard_delete(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size) { H5O_token_t token; - hid_t target_obj = H5I_INVALID_HID; - herr_t ret_value = 0; + hid_t target_obj = H5I_INVALID_HID; + herr_t ret_value = 0; /* Sanity check; we have already verified the udata's size in the creation * callback. */ - if(udata_size != sizeof(H5O_token_t)) - { - ret_value = -1; - goto done; + if (udata_size != sizeof(H5O_token_t)) { + ret_value = -1; + goto done; } - token = *((H5O_token_t *) udata); + token = *((H5O_token_t *)udata); /* Open the object this link points to */ target_obj = H5Oopen_by_token(loc_group, token); - if(target_obj < 0) - { - ret_value = -1; - goto done; + if (target_obj < 0) { + ret_value = -1; + goto done; } /* Decrement the reference count of the target object */ - if(H5Odecr_refcount(target_obj) < 0) - { - ret_value = -1; - goto done; + if (H5Odecr_refcount(target_obj) < 0) { + ret_value = -1; + goto done; } done: /* Close the target object if we opened it */ - if(target_obj >= 0) + if (target_obj >= 0) H5Oclose(target_obj); return ret_value; } @@ -489,19 +481,20 @@ done: * The actual traversal function simply needs to open the correct object and * return its ID. */ -static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id) +static hid_t +UD_hard_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, hid_t lapl_id, + hid_t dxpl_id) { H5O_token_t token; - hid_t ret_value = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; /* Sanity check; we have already verified the udata's size in the creation * callback. */ - if(udata_size != sizeof(H5O_token_t)) - return H5I_INVALID_HID; + if (udata_size != sizeof(H5O_token_t)) + return H5I_INVALID_HID; - token = *((H5O_token_t *) udata); + token = *((H5O_token_t *)udata); /* Open the object by token. If H5Oopen_by_token fails, ret_value will * be negative to indicate that the traversal function failed. @@ -511,8 +504,6 @@ static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group, return ret_value; } - - /* Plist example * * Create a new class of user-defined links that open objects within a file @@ -526,10 +517,11 @@ static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group, * These are defined after the example below. * These links have no udata, so they don't need a query function. */ -static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id); +static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t lapl_id, hid_t dxpl_id); -static void plist_link_example(void) +static void +plist_link_example(void) { hid_t file_id; hid_t group_id, group2_id; @@ -558,11 +550,10 @@ static void plist_link_example(void) NULL /* Query callback */ }}; - /* First, create a file and two objects within the file for the link to * point to. */ - file_id = H5Fcreate(HARD_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file_id = H5Fcreate(HARD_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); group_id = H5Gcreate2(file_id, "group_1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(group_id); group_id = H5Gcreate2(file_id, "group_1/group_2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -570,8 +561,7 @@ static void plist_link_example(void) /* Register "plist links" and create one. It has no udata at all. */ H5Lregister(UD_plist_class); - H5Lcreate_ud(file_id, "plist_link", (H5L_type_t)UD_PLIST_CLASS, NULL, 0, - H5P_DEFAULT, H5P_DEFAULT); + H5Lcreate_ud(file_id, "plist_link", (H5L_type_t)UD_PLIST_CLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT); /* Create a group access property list to pass in the target for the * plist link. @@ -617,17 +607,18 @@ static void plist_link_example(void) /* UD_plist_traverse * Open a path passed in through the property list. */ -static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id) +static hid_t +UD_plist_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, hid_t lapl_id, + hid_t dxpl_id) { - char * path; - hid_t ret_value = H5I_INVALID_HID; + char *path; + hid_t ret_value = H5I_INVALID_HID; /* If the link property isn't set or can't be found, traversal fails. */ - if(H5Pexist(lapl_id, PLIST_LINK_PROP) < 0) + if (H5Pexist(lapl_id, PLIST_LINK_PROP) < 0) goto error; - if(H5Pget(lapl_id, PLIST_LINK_PROP, &path) < 0) + if (H5Pget(lapl_id, PLIST_LINK_PROP, &path) < 0) goto error; /* Open the object by address. If H5Oopen_by_addr fails, ret_value will @@ -641,13 +632,11 @@ error: return H5I_INVALID_HID; } - - /* Main function * * Invokes the example functions. */ - int +int main(void) { printf("Testing basic external links.\n"); @@ -667,5 +656,3 @@ main(void) return 0; } - - diff --git a/examples/h5_group.c b/examples/h5_group.c index 75bed91..fe6405c 100644 --- a/examples/h5_group.c +++ b/examples/h5_group.c @@ -19,31 +19,29 @@ * in the root group and in the created group. */ - #include "hdf5.h" - -#define H5FILE_NAME "group.h5" -#define RANK 2 +#define H5FILE_NAME "group.h5" +#define RANK 2 static herr_t file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, - void *opdata); /* Link iteration operator function */ + void *opdata); /* Link iteration operator function */ static herr_t group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, - void *opdata); /* Link iteration operator function */ + void *opdata); /* Link iteration operator function */ int main(void) { - hid_t file; - hid_t grp; - hid_t dataset, dataspace; - hid_t plist; + hid_t file; + hid_t grp; + hid_t dataset, dataspace; + hid_t plist; - herr_t status; - hsize_t dims[2]; - hsize_t cdims[2]; + herr_t status; + hsize_t dims[2]; + hsize_t cdims[2]; - int idx_f, idx_g; + int idx_f, idx_g; /* * Create a file. @@ -61,16 +59,16 @@ main(void) * GZIP compression with the compression effort set to 6. * Note that compression can be used only when dataset is chunked. */ - dims[0] = 1000; - dims[1] = 20; - cdims[0] = 20; - cdims[1] = 20; + dims[0] = 1000; + dims[1] = 20; + cdims[0] = 20; + cdims[1] = 20; dataspace = H5Screate_simple(RANK, dims, NULL); plist = H5Pcreate(H5P_DATASET_CREATE); - H5Pset_chunk(plist, 2, cdims); - H5Pset_deflate( plist, 6); - dataset = H5Dcreate2(file, "/Data/Compressed_Data", H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, plist, H5P_DEFAULT); + H5Pset_chunk(plist, 2, cdims); + H5Pset_deflate(plist, 6); + dataset = + H5Dcreate2(file, "/Data/Compressed_Data", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, plist, H5P_DEFAULT); /* * Close the first dataset . */ @@ -80,11 +78,11 @@ main(void) /* * Create the second dataset. */ - dims[0] = 500; - dims[1] = 20; + dims[0] = 500; + dims[1] = 20; dataspace = H5Screate_simple(RANK, dims, NULL); - dataset = H5Dcreate2(file, "/Data/Float_Data", H5T_NATIVE_FLOAT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(file, "/Data/Float_Data", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); /* *Close the second dataset and file. @@ -105,7 +103,8 @@ main(void) * Access "Compressed_Data" dataset in the group. */ dataset = H5Dopen2(grp, "Compressed_Data", H5P_DEFAULT); - if( dataset < 0) printf(" Dataset 'Compressed-Data' is not found. \n"); + if (dataset < 0) + printf(" Dataset 'Compressed-Data' is not found. \n"); printf("\"/Data/Compressed_Data\" dataset is open \n"); /* @@ -123,7 +122,8 @@ main(void) * hard link "Data_new". */ dataset = H5Dopen2(file, "/Data_new/Compressed_Data", H5P_DEFAULT); - if( dataset < 0) printf(" Dataset is not found. \n"); + if (dataset < 0) + printf(" Dataset is not found. \n"); printf("\"/Data_new/Compressed_Data\" dataset is open \n"); /* @@ -131,7 +131,6 @@ main(void) */ status = H5Dclose(dataset); - /* * Use iterator to see the names of the objects in the root group. */ @@ -141,10 +140,10 @@ main(void) * Unlink name "Data" and use iterator to see the names * of the objects in the file root direvtory. */ - if(H5Ldelete(file, "Data", H5P_DEFAULT) < 0) - printf(" H5Ldelete failed \n"); + if (H5Ldelete(file, "Data", H5P_DEFAULT) < 0) + printf(" H5Ldelete failed \n"); else - printf("\"Data\" is unlinked \n"); + printf("\"Data\" is unlinked \n"); idx_f = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, NULL, file_info, NULL); @@ -152,7 +151,8 @@ main(void) * Use iterator to see the names of the objects in the group * /Data_new. */ - idx_g = H5Literate_by_name2(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL, H5P_DEFAULT); + idx_g = H5Literate_by_name2(grp, "/Data_new", H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, NULL, + H5P_DEFAULT); /* * Close the file. @@ -173,7 +173,7 @@ file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata /* avoid compiler warnings */ loc_id = loc_id; opdata = opdata; - linfo = linfo; + linfo = linfo; /* * Display group name. The name is passed to the function by @@ -184,23 +184,22 @@ file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata return 0; } - /* * Operator function. */ static herr_t group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata) { - hid_t did; /* dataset identifier */ - hid_t tid; /* datatype identifier */ + hid_t did; /* dataset identifier */ + hid_t tid; /* datatype identifier */ H5T_class_t t_class; - hid_t pid; /* data_property identifier */ - hsize_t chunk_dims_out[2]; - int rank_chunk; + hid_t pid; /* data_property identifier */ + hsize_t chunk_dims_out[2]; + int rank_chunk; /* avoid warnings */ opdata = opdata; - linfo = linfo; + linfo = linfo; /* * Open the datasets using their names. @@ -215,38 +214,37 @@ group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdat /* * Display dataset information. */ - tid = H5Dget_type(did); /* get datatype*/ + tid = H5Dget_type(did); /* get datatype*/ pid = H5Dget_create_plist(did); /* get creation property list */ /* * Check if dataset is chunked. */ - if(H5D_CHUNKED == H5Pget_layout(pid)) { + if (H5D_CHUNKED == H5Pget_layout(pid)) { /* * get chunking information: rank and dimensions. */ rank_chunk = H5Pget_chunk(pid, 2, chunk_dims_out); - printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, - (unsigned long)(chunk_dims_out[0]), - (unsigned long)(chunk_dims_out[1])); + printf("chunk rank %d, dimensions %lu x %lu\n", rank_chunk, (unsigned long)(chunk_dims_out[0]), + (unsigned long)(chunk_dims_out[1])); } else { t_class = H5Tget_class(tid); - if(t_class < 0) { + if (t_class < 0) { puts(" Invalid datatype.\n"); } else { - if(t_class == H5T_INTEGER) + if (t_class == H5T_INTEGER) puts(" Datatype is 'H5T_NATIVE_INTEGER'.\n"); - if(t_class == H5T_FLOAT) + if (t_class == H5T_FLOAT) puts(" Datatype is 'H5T_NATIVE_FLOAT'.\n"); - if(t_class == H5T_STRING) + if (t_class == H5T_STRING) puts(" Datatype is 'H5T_NATIVE_STRING'.\n"); - if(t_class == H5T_BITFIELD) + if (t_class == H5T_BITFIELD) puts(" Datatype is 'H5T_NATIVE_BITFIELD'.\n"); - if(t_class == H5T_OPAQUE) + if (t_class == H5T_OPAQUE) puts(" Datatype is 'H5T_NATIVE_OPAQUE'.\n"); - if(t_class == H5T_COMPOUND) + if (t_class == H5T_COMPOUND) puts(" Datatype is 'H5T_NATIVE_COMPOUND'.\n"); } } @@ -256,4 +254,3 @@ group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdat H5Tclose(tid); return 0; } - diff --git a/examples/h5_interm_group.c b/examples/h5_interm_group.c index 6507fd1..a103ea1 100644 --- a/examples/h5_interm_group.c +++ b/examples/h5_interm_group.c @@ -16,27 +16,24 @@ * all intermediate groups. */ - #include "hdf5.h" - -#define H5FILE_NAME "interm_group.h5" -#define TRUE 1 -#define FALSE 0 +#define H5FILE_NAME "interm_group.h5" +#define TRUE 1 +#define FALSE 0 int main(void) { - hid_t file; - hid_t g1_id, g2_id, g3_id; - hid_t grp_crt_plist; + hid_t file; + hid_t g1_id, g2_id, g3_id; + hid_t grp_crt_plist; H5G_info_t g2_info; - char name[3]; - - herr_t status; - int i; + char name[3]; + herr_t status; + int i; /* * Create a file using the default properties. @@ -59,53 +56,44 @@ main(void) /* * Check if group /G1 exists in the file. */ - if(H5Lexists(file, "/G1", H5P_DEFAULT) !=FALSE) - printf("Group /G1 exists in the file\n"); + if (H5Lexists(file, "/G1", H5P_DEFAULT) != FALSE) + printf("Group /G1 exists in the file\n"); /* * Check that group G2/G3 exists in /G1 and if not create it using * intermediate group creation property. */ g1_id = H5Gopen2(file, "/G1", H5P_DEFAULT); -/* Next commented call causes error stack to be printed out; the next one - * works fine; is it a bug or a feature? EIP 04-25-07 -*/ -/* if (H5Lexists(g1_id, "G2/G3", H5P_DEFAULT) !=TRUE) { */ - if (H5Lexists(g1_id, "G2", H5P_DEFAULT) !=TRUE) { - - grp_crt_plist = H5Pcreate(H5P_LINK_CREATE); - - /* Set flag for intermediate group creation */ - status = H5Pset_create_intermediate_group(grp_crt_plist, TRUE); - g3_id = H5Gcreate2(g1_id, "G2/G3", grp_crt_plist, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(g3_id); + /* Next commented call causes error stack to be printed out; the next one + * works fine; is it a bug or a feature? EIP 04-25-07 + */ + /* if (H5Lexists(g1_id, "G2/G3", H5P_DEFAULT) !=TRUE) { */ + if (H5Lexists(g1_id, "G2", H5P_DEFAULT) != TRUE) { + + grp_crt_plist = H5Pcreate(H5P_LINK_CREATE); + + /* Set flag for intermediate group creation */ + status = H5Pset_create_intermediate_group(grp_crt_plist, TRUE); + g3_id = H5Gcreate2(g1_id, "G2/G3", grp_crt_plist, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(g3_id); } H5Gclose(g1_id); - /* Now check if group /G1/G2 exists in the file, then open it and print * its members names */ if (H5Lexists(file, "/G1/G2", H5P_DEFAULT)) { - g2_id = H5Gopen2(file, "/G1/G2", H5P_DEFAULT); - status = H5Gget_info(g2_id, &g2_info); - printf("Group /G1/G2 has %d member(s)\n", (int)g2_info.nlinks); + g2_id = H5Gopen2(file, "/G1/G2", H5P_DEFAULT); + status = H5Gget_info(g2_id, &g2_info); + printf("Group /G1/G2 has %d member(s)\n", (int)g2_info.nlinks); - for (i=0; i < (int)g2_info.nlinks; i++) { - H5Lget_name_by_idx(g2_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)i, - name, 3, H5P_DEFAULT); - printf("Object's name is %s\n", name); - - } - H5Gclose(g2_id); + for (i = 0; i < (int)g2_info.nlinks; i++) { + H5Lget_name_by_idx(g2_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)i, name, 3, H5P_DEFAULT); + printf("Object's name is %s\n", name); + } + H5Gclose(g2_id); } H5Fclose(file); return 0; } - - - - - - diff --git a/examples/h5_mount.c b/examples/h5_mount.c index a2e16c5..c1b63cf 100644 --- a/examples/h5_mount.c +++ b/examples/h5_mount.c @@ -25,107 +25,105 @@ #define FILE2 "mount2.h5" #define RANK 2 -#define NX 4 -#define NY 5 +#define NX 4 +#define NY 5 -int main(void) +int +main(void) { - hid_t fid1, fid2, gid; /* Files and group identifiers */ - hid_t did, tid, sid; /* Dataset and datatype identifiers */ - - herr_t status; - hsize_t dims[] = {NX,NY}; /* Dataset dimensions */ - - int i, j; - int bm[NX][NY], bm_out[NX][NY]; /* Data buffers */ - - /* - * Initialization of buffer matrix "bm" - */ - for(i =0; i < NX; i++) - for(j = 0; j < NY; j++) - bm[i][j] = i + j; - - /* - * Create first file and a group in it. - */ - fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - gid = H5Gcreate2(fid1, "/G", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Close group and file - */ - H5Gclose(gid); - H5Fclose(fid1); - - /* - * Create second file and dataset "D" in it. - */ - fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - dims[0] = NX; - dims[1] = NY; - sid = H5Screate_simple(RANK, dims, NULL); - did = H5Dcreate2(fid2, "D", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Write data to the dataset. - */ - status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm); - - /* - * Close all identifiers. - */ - H5Sclose(sid); - H5Dclose(did); - H5Fclose(fid2); - - /* - * Reopen both files - */ - fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); - fid2 = H5Fopen(FILE2, H5F_ACC_RDONLY, H5P_DEFAULT); - - /* - * Mount second file under G in the first file. - */ - H5Fmount(fid1, "/G", fid2, H5P_DEFAULT); - - /* - * Access dataset D in the first file under /G/D name. - */ - did = H5Dopen2(fid1, "/G/D", H5P_DEFAULT); - tid = H5Dget_type(did); - status = H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm_out); - - /* - * Print out the data. - */ - for(i=0; i @@ -24,22 +24,23 @@ #define H5FILE_NAME "refer_deprec.h5" -#define NDIMS 1 /* Number of dimensions */ -#define BUF_SIZE 4 /* Size of example buffer */ -#define NREFS 1 /* Number of references */ +#define NDIMS 1 /* Number of dimensions */ +#define BUF_SIZE 4 /* Size of example buffer */ +#define NREFS 1 /* Number of references */ int -main(void) { - hid_t file1, dset1, space1; - hsize_t dset1_dims[NDIMS] = { BUF_SIZE }; - int dset_buf[BUF_SIZE]; - - hid_t dset2, space2; - hsize_t dset2_dims[NDIMS] = { NREFS }; - hobj_ref_t ref_buf[NREFS] = { 0 }; - H5R_ref_t new_ref_buf[NREFS] = { 0 }; +main(void) +{ + hid_t file1, dset1, space1; + hsize_t dset1_dims[NDIMS] = {BUF_SIZE}; + int dset_buf[BUF_SIZE]; + + hid_t dset2, space2; + hsize_t dset2_dims[NDIMS] = {NREFS}; + hobj_ref_t ref_buf[NREFS] = {0}; + H5R_ref_t new_ref_buf[NREFS] = {0}; H5O_type_t obj_type; - int i; + int i; for (i = 0; i < BUF_SIZE; i++) dset_buf[i] = i; @@ -48,8 +49,7 @@ main(void) { file1 = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); space1 = H5Screate_simple(NDIMS, dset1_dims, NULL); - dset1 = H5Dcreate2(file1, "dataset1", H5T_NATIVE_INT, space1, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dset1 = H5Dcreate2(file1, "dataset1", H5T_NATIVE_INT, space1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf); H5Dclose(dset1); H5Sclose(space1); @@ -62,7 +62,7 @@ main(void) { /* Store reference in separate dataset using deprecated reference type */ space2 = H5Screate_simple(NDIMS, dset2_dims, NULL); - dset2 = H5Dcreate2(file1, "references", H5T_STD_REF_OBJ, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset2 = H5Dcreate2(file1, "references", H5T_STD_REF_OBJ, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dset2, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf); H5Dclose(dset2); H5Sclose(space2); @@ -87,4 +87,3 @@ main(void) { assert(dset_buf[i] == i); return 0; } - diff --git a/examples/h5_ref_extern.c b/examples/h5_ref_extern.c index 5403814..283af95 100644 --- a/examples/h5_ref_extern.c +++ b/examples/h5_ref_extern.c @@ -10,12 +10,12 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* - * The example below illustrates the use of the new API with files that are - * opened read-only. Created references to the objects in that file are - * stored into a separate file, and accessed from that file, without the user - * explicitly opening the original file that was referenced. - */ +/* + * The example below illustrates the use of the new API with files that are + * opened read-only. Created references to the objects in that file are + * stored into a separate file, and accessed from that file, without the user + * explicitly opening the original file that was referenced. + */ #include @@ -25,30 +25,30 @@ #define H5FILE_NAME1 "refer_extern1.h5" #define H5FILE_NAME2 "refer_extern2.h5" -#define NDIMS 1 /* Number of dimensions */ -#define BUF_SIZE 4 /* Size of example buffer */ -#define NREFS 1 /* Number of references */ +#define NDIMS 1 /* Number of dimensions */ +#define BUF_SIZE 4 /* Size of example buffer */ +#define NREFS 1 /* Number of references */ int -main(void) { - hid_t file1, dset1, space1; - hsize_t dset1_dims[NDIMS] = { BUF_SIZE }; - int dset_buf[BUF_SIZE]; - - hid_t file2, dset2, space2; - hsize_t dset2_dims[NDIMS] = { NREFS }; - H5R_ref_t ref_buf[NREFS] = { 0 }; +main(void) +{ + hid_t file1, dset1, space1; + hsize_t dset1_dims[NDIMS] = {BUF_SIZE}; + int dset_buf[BUF_SIZE]; + + hid_t file2, dset2, space2; + hsize_t dset2_dims[NDIMS] = {NREFS}; + H5R_ref_t ref_buf[NREFS] = {0}; H5O_type_t obj_type; - int i; + int i; for (i = 0; i < BUF_SIZE; i++) dset_buf[i] = i; /* Create file with one dataset and close it */ - file1 = H5Fcreate(H5FILE_NAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file1 = H5Fcreate(H5FILE_NAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); space1 = H5Screate_simple(NDIMS, dset1_dims, NULL); - dset1 = H5Dcreate2(file1, "dataset1", H5T_NATIVE_INT, space1, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dset1 = H5Dcreate2(file1, "dataset1", H5T_NATIVE_INT, space1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_buf); H5Dclose(dset1); H5Sclose(space1); @@ -60,10 +60,9 @@ main(void) { H5Fclose(file1); /* Store reference in dataset in separate file "refer_extern2.h5" */ - file2 = H5Fcreate(H5FILE_NAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file2 = H5Fcreate(H5FILE_NAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); space2 = H5Screate_simple(NDIMS, dset2_dims, NULL); - dset2 = H5Dcreate2(file2, "references", H5T_STD_REF, space2, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dset2 = H5Dcreate2(file2, "references", H5T_STD_REF, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dset2, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf); H5Dclose(dset2); H5Sclose(space2); @@ -91,4 +90,3 @@ main(void) { return 0; } - diff --git a/examples/h5_reference_deprec.c b/examples/h5_reference_deprec.c index 32a5f59..457956b 100644 --- a/examples/h5_reference_deprec.c +++ b/examples/h5_reference_deprec.c @@ -11,15 +11,15 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* - * This program illustrates how references to objects can be used. - * Program creates a dataset and a group in a file. It also creates - * second dataset, and references to the first dataset and the group - * are stored in it. - * Program reopens the file and reads dataset with the references. - * References are used to open the objects. Information about the - * objects is displayed. - */ +/* + * This program illustrates how references to objects can be used. + * Program creates a dataset and a group in a file. It also creates + * second dataset, and references to the first dataset and the group + * are stored in it. + * Program reopens the file and reads dataset with the references. + * References are used to open the objects. Information about the + * objects is displayed. + */ #include @@ -28,120 +28,119 @@ #define H5FILE_NAME "refere.h5" int -main(void) { - hid_t fid; /* File, group, datasets, datatypes */ - hid_t gid_a; /* and dataspaces identifiers */ - hid_t did_b, sid_b, tid_b; - hid_t did_r, tid_r, sid_r; - H5O_type_t obj_type; - herr_t status; - - hobj_ref_t *wbuf; /* buffer to write to disk */ - hobj_ref_t *rbuf; /* buffer to read from disk */ - - - hsize_t dim_r[1]; - hsize_t dim_b[2]; - - /* - * Create a file using default properties. - */ - fid = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create group "A" in the file. - */ - gid_a = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create dataset "B" in the file. - */ - dim_b[0] = 2; - dim_b[1] = 6; - sid_b = H5Screate_simple(2, dim_b, NULL); - did_b = H5Dcreate2(fid, "B", H5T_NATIVE_FLOAT, sid_b, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create dataset "R" to store references to the objects "A" and "B". - */ - dim_r[0] = 2; - sid_r = H5Screate_simple(1, dim_r, NULL); - tid_r = H5Tcopy(H5T_STD_REF_OBJ); - did_r = H5Dcreate2(fid, "R", tid_r, sid_r, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Allocate write and read buffers. - */ - wbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2); - rbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2); - - /* - * Create references to the group "A" and dataset "B" - * and store them in the wbuf. - */ - H5Rcreate(&wbuf[0], fid, "A", H5R_OBJECT, (hid_t)-1); - H5Rcreate(&wbuf[1], fid, "B", H5R_OBJECT, (hid_t)-1); - - /* - * Write dataset R using default transfer properties. - */ - status = H5Dwrite(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - - /* - * Close all objects. - */ - H5Gclose(gid_a); - - H5Sclose(sid_b); - H5Dclose(did_b); - - H5Tclose(tid_r); - H5Sclose(sid_r); - H5Dclose(did_r); - - H5Fclose(fid); - - /* - * Reopen the file. - */ - fid = H5Fopen(H5FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); - - /* - * Open and read dataset "R". - */ - did_r = H5Dopen2(fid, "R", H5P_DEFAULT); - status = H5Dread(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); - - /* - * Find the type of referenced objects. - */ +main(void) +{ + hid_t fid; /* File, group, datasets, datatypes */ + hid_t gid_a; /* and dataspaces identifiers */ + hid_t did_b, sid_b, tid_b; + hid_t did_r, tid_r, sid_r; + H5O_type_t obj_type; + herr_t status; + + hobj_ref_t *wbuf; /* buffer to write to disk */ + hobj_ref_t *rbuf; /* buffer to read from disk */ + + hsize_t dim_r[1]; + hsize_t dim_b[2]; + + /* + * Create a file using default properties. + */ + fid = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Create group "A" in the file. + */ + gid_a = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Create dataset "B" in the file. + */ + dim_b[0] = 2; + dim_b[1] = 6; + sid_b = H5Screate_simple(2, dim_b, NULL); + did_b = H5Dcreate2(fid, "B", H5T_NATIVE_FLOAT, sid_b, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Create dataset "R" to store references to the objects "A" and "B". + */ + dim_r[0] = 2; + sid_r = H5Screate_simple(1, dim_r, NULL); + tid_r = H5Tcopy(H5T_STD_REF_OBJ); + did_r = H5Dcreate2(fid, "R", tid_r, sid_r, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Allocate write and read buffers. + */ + wbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2); + rbuf = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * 2); + + /* + * Create references to the group "A" and dataset "B" + * and store them in the wbuf. + */ + H5Rcreate(&wbuf[0], fid, "A", H5R_OBJECT, (hid_t)-1); + H5Rcreate(&wbuf[1], fid, "B", H5R_OBJECT, (hid_t)-1); + + /* + * Write dataset R using default transfer properties. + */ + status = H5Dwrite(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + + /* + * Close all objects. + */ + H5Gclose(gid_a); + + H5Sclose(sid_b); + H5Dclose(did_b); + + H5Tclose(tid_r); + H5Sclose(sid_r); + H5Dclose(did_r); + + H5Fclose(fid); + + /* + * Reopen the file. + */ + fid = H5Fopen(H5FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); + + /* + * Open and read dataset "R". + */ + did_r = H5Dopen2(fid, "R", H5P_DEFAULT); + status = H5Dread(did_r, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); + + /* + * Find the type of referenced objects. + */ status = H5Rget_obj_type2(did_r, H5R_OBJECT, &rbuf[0], &obj_type); - if(obj_type == H5O_TYPE_GROUP) + if (obj_type == H5O_TYPE_GROUP) printf("First dereferenced object is a group. \n"); status = H5Rget_obj_type2(did_r, H5R_OBJECT, &rbuf[1], &obj_type); - if(obj_type == H5O_TYPE_DATASET) + if (obj_type == H5O_TYPE_DATASET) printf("Second dereferenced object is a dataset. \n"); - /* - * Get datatype of the dataset "B" - */ - did_b = H5Rdereference2(did_r, H5P_DEFAULT, H5R_OBJECT, &rbuf[1]); - tid_b = H5Dget_type(did_b); - if(H5Tequal(tid_b, H5T_NATIVE_FLOAT)) - printf("Datatype of the dataset is H5T_NATIVE_FLOAT.\n"); - printf("\n"); - - /* - * Close all objects and free memory buffers. - */ - H5Dclose(did_r); - H5Dclose(did_b); - H5Tclose(tid_b); - H5Fclose(fid); - free(rbuf); - free(wbuf); - - return 0; - } - + /* + * Get datatype of the dataset "B" + */ + did_b = H5Rdereference2(did_r, H5P_DEFAULT, H5R_OBJECT, &rbuf[1]); + tid_b = H5Dget_type(did_b); + if (H5Tequal(tid_b, H5T_NATIVE_FLOAT)) + printf("Datatype of the dataset is H5T_NATIVE_FLOAT.\n"); + printf("\n"); + + /* + * Close all objects and free memory buffers. + */ + H5Dclose(did_r); + H5Dclose(did_b); + H5Tclose(tid_b); + H5Fclose(fid); + free(rbuf); + free(wbuf); + + return 0; +} diff --git a/examples/h5_select.c b/examples/h5_select.c index bbc877c..b4aa679 100644 --- a/examples/h5_select.c +++ b/examples/h5_select.c @@ -26,78 +26,80 @@ #define H5FILE_NAME "Select.h5" -#define MSPACE1_RANK 1 /* Rank of the first dataset in memory */ -#define MSPACE1_DIM 50 /* Dataset size in memory */ - -#define MSPACE2_RANK 1 /* Rank of the second dataset in memory */ -#define MSPACE2_DIM 4 /* Dataset size in memory */ - -#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */ -#define FSPACE_DIM1 8 /* Dimension sizes of the dataset as it is - stored in the file */ -#define FSPACE_DIM2 12 - - /* We will read dataset back from the file - to the dataset in memory with these - dataspace parameters. */ -#define MSPACE_RANK 2 -#define MSPACE_DIM1 8 -#define MSPACE_DIM2 9 - -#define NPOINTS 4 /* Number of points that will be selected - and overwritten */ +#define MSPACE1_RANK 1 /* Rank of the first dataset in memory */ +#define MSPACE1_DIM 50 /* Dataset size in memory */ + +#define MSPACE2_RANK 1 /* Rank of the second dataset in memory */ +#define MSPACE2_DIM 4 /* Dataset size in memory */ + +#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */ +#define FSPACE_DIM1 \ + 8 /* Dimension sizes of the dataset as it is \ + stored in the file */ +#define FSPACE_DIM2 12 + +/* We will read dataset back from the file + to the dataset in memory with these + dataspace parameters. */ +#define MSPACE_RANK 2 +#define MSPACE_DIM1 8 +#define MSPACE_DIM2 9 + +#define NPOINTS \ + 4 /* Number of points that will be selected \ + and overwritten */ int -main (void) +main(void) { - hid_t file, dataset; /* File and dataset identifiers */ - hid_t mid1, mid2, mid, fid; /* Dataspace identifiers */ - hid_t plist; /* Dataset property list identifier */ + hid_t file, dataset; /* File and dataset identifiers */ + hid_t mid1, mid2, mid, fid; /* Dataspace identifiers */ + hid_t plist; /* Dataset property list identifier */ - hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset + hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset (in memory) */ - hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset + hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset (in memory */ - hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; - /* Dimension sizes of the dataset (on disk) */ - hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the - dataset in memory when we - read selection from the - dataset on the disk */ - - hsize_t start[2]; /* Start of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Block count */ - hsize_t block[2]; /* Block sizes */ - - hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points - from the file dataspace */ - herr_t ret; - unsigned i,j; - int fillvalue = 0; /* Fill value for the dataset */ - - int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the - dataset */ - int vector[MSPACE1_DIM]; - int values[] = {53, 59, 61, 67}; /* New values to be written */ - - /* - * Buffers' initialization. - */ - vector[0] = vector[MSPACE1_DIM - 1] = -1; - for(i = 1; i < MSPACE1_DIM - 1; i++) - vector[i] = i; - - /* - * Create a file. - */ - file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create property list for a dataset and set up fill values. - */ - plist = H5Pcreate(H5P_DATASET_CREATE); - ret = H5Pset_fill_value(plist, H5T_NATIVE_INT, &fillvalue); + hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; + /* Dimension sizes of the dataset (on disk) */ + hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the + dataset in memory when we + read selection from the + dataset on the disk */ + + hsize_t start[2]; /* Start of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Block count */ + hsize_t block[2]; /* Block sizes */ + + hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points + from the file dataspace */ + herr_t ret; + unsigned i, j; + int fillvalue = 0; /* Fill value for the dataset */ + + int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the + dataset */ + int vector[MSPACE1_DIM]; + int values[] = {53, 59, 61, 67}; /* New values to be written */ + + /* + * Buffers' initialization. + */ + vector[0] = vector[MSPACE1_DIM - 1] = -1; + for (i = 1; i < MSPACE1_DIM - 1; i++) + vector[i] = i; + + /* + * Create a file. + */ + file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Create property list for a dataset and set up fill values. + */ + plist = H5Pcreate(H5P_DATASET_CREATE); + ret = H5Pset_fill_value(plist, H5T_NATIVE_INT, &fillvalue); /* * Create dataspace for the dataset in the file. @@ -114,11 +116,15 @@ main (void) * Select hyperslab for the dataset in the file, using 3x2 blocks, * (4,3) stride and (2,4) count starting at the position (0,1). */ - start[0] = 0; start[1] = 1; - stride[0] = 4; stride[1] = 3; - count[0] = 2; count[1] = 4; - block[0] = 3; block[1] = 2; - ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 0; + start[1] = 1; + stride[0] = 4; + stride[1] = 3; + count[0] = 2; + count[1] = 4; + block[0] = 3; + block[1] = 2; + ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block); /* * Create dataspace for the first dataset. @@ -134,7 +140,7 @@ main (void) stride[0] = 1; count[0] = 48; block[0] = 1; - ret = H5Sselect_hyperslab(mid1, H5S_SELECT_SET, start, stride, count, block); + ret = H5Sselect_hyperslab(mid1, H5S_SELECT_SET, start, stride, count, block); /* * Write selection from the vector buffer to the dataset in the file. @@ -149,7 +155,7 @@ main (void) * 0 41 42 0 43 44 0 45 46 0 47 48 * 0 0 0 0 0 0 0 0 0 0 0 0 */ - ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid1, fid, H5P_DEFAULT, vector); + ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid1, fid, H5P_DEFAULT, vector); /* * Reset the selection for the file dataspace fid. @@ -164,10 +170,14 @@ main (void) /* * Select sequence of NPOINTS points in the file dataspace. */ - coord[0][0] = 0; coord[0][1] = 0; - coord[1][0] = 3; coord[1][1] = 3; - coord[2][0] = 3; coord[2][1] = 5; - coord[3][0] = 5; coord[3][1] = 6; + coord[0][0] = 0; + coord[0][1] = 0; + coord[1][0] = 3; + coord[1][1] = 3; + coord[2][0] = 3; + coord[2][1] = 5; + coord[3][0] = 5; + coord[3][1] = 6; ret = H5Sselect_elements(fid, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord); @@ -229,11 +239,15 @@ main (void) * 0 59 0 61 * */ - start[0] = 1; start[1] = 2; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 3; count[1] = 4; - ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 1; + start[1] = 2; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 3; + count[1] = 4; + ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block); /* * Add second selected hyperslab to the selection. @@ -248,11 +262,15 @@ main (void) * 19 20 * 0 61 */ - start[0] = 2; start[1] = 4; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 5; - ret = H5Sselect_hyperslab(fid, H5S_SELECT_OR, start, stride, count, block); + start[0] = 2; + start[1] = 4; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 5; + ret = H5Sselect_hyperslab(fid, H5S_SELECT_OR, start, stride, count, block); /* * Create memory dataspace. @@ -263,30 +281,37 @@ main (void) * Select two hyperslabs in memory. Hyperslabs has the same * size and shape as the selected hyperslabs for the file dataspace. */ - start[0] = 0; start[1] = 0; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 3; count[1] = 4; - ret = H5Sselect_hyperslab(mid, H5S_SELECT_SET, start, stride, count, block); - - start[0] = 1; start[1] = 2; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 5; - ret = H5Sselect_hyperslab(mid, H5S_SELECT_OR, start, stride, count, block); + start[0] = 0; + start[1] = 0; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 3; + count[1] = 4; + ret = H5Sselect_hyperslab(mid, H5S_SELECT_SET, start, stride, count, block); + + start[0] = 1; + start[1] = 2; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 5; + ret = H5Sselect_hyperslab(mid, H5S_SELECT_OR, start, stride, count, block); /* * Initialize data buffer. */ for (i = 0; i < MSPACE_DIM1; i++) { - for (j = 0; j < MSPACE_DIM2; j++) + for (j = 0; j < MSPACE_DIM2; j++) matrix_out[i][j] = 0; } /* * Read data back to the buffer matrix_out. */ - ret = H5Dread(dataset, H5T_NATIVE_INT, mid, fid, - H5P_DEFAULT, matrix_out); + ret = H5Dread(dataset, H5T_NATIVE_INT, mid, fid, H5P_DEFAULT, matrix_out); /* * Display the result. Memory dataset is: @@ -300,8 +325,8 @@ main (void) * 0 0 0 0 0 0 0 0 0 * 0 0 0 0 0 0 0 0 0 */ - for(i = 0; i < MSPACE_DIM1; i++) { - for(j = 0; j < MSPACE_DIM2; j++) + for (i = 0; i < MSPACE_DIM1; i++) { + for (j = 0; j < MSPACE_DIM2; j++) printf("%3d ", matrix_out[i][j]); printf("\n"); } @@ -329,4 +354,3 @@ main (void) return 0; } - diff --git a/examples/h5_shared_mesg.c b/examples/h5_shared_mesg.c index 4e1f92a..cf2deb6 100644 --- a/examples/h5_shared_mesg.c +++ b/examples/h5_shared_mesg.c @@ -27,29 +27,13 @@ #include "hdf5.h" #define NUM_DATASETS 40 -const char* DSETNAME[] = { - "dataset0", "dataset1", - "dataset2", "dataset3", - "dataset4", "dataset5", - "dataset6", "dataset7", - "dataset8", "dataset9", - "dataset10", "dataset11", - "dataset12", "dataset13", - "dataset14", "dataset15", - "dataset16", "dataset17", - "dataset18", "dataset19", - "dataset20", "dataset21", - "dataset22", "dataset23", - "dataset24", "dataset25", - "dataset26", "dataset27", - "dataset28", "dataset29", - "dataset30", "dataset31", - "dataset32", "dataset33", - "dataset34", "dataset35", - "dataset36", "dataset37", - "dataset38", "dataset39", - NULL -}; +const char *DSETNAME[] = {"dataset0", "dataset1", "dataset2", "dataset3", "dataset4", "dataset5", + "dataset6", "dataset7", "dataset8", "dataset9", "dataset10", "dataset11", + "dataset12", "dataset13", "dataset14", "dataset15", "dataset16", "dataset17", + "dataset18", "dataset19", "dataset20", "dataset21", "dataset22", "dataset23", + "dataset24", "dataset25", "dataset26", "dataset27", "dataset28", "dataset29", + "dataset30", "dataset31", "dataset32", "dataset33", "dataset34", "dataset35", + "dataset36", "dataset37", "dataset38", "dataset39", NULL}; herr_t create_standard_file(const char *filename, hid_t fcpl); @@ -61,21 +45,24 @@ herr_t create_standard_file(const char *filename, hid_t fcpl); * *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { - hid_t fcpl_id; + hid_t fcpl_id; herr_t ret; /* Create a file creation property list */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); - if(fcpl_id < 0) goto error; + if (fcpl_id < 0) + goto error; /* The file creation property list is the default list right now. * Create a file using it (this is the same as creating a file with * H5P_DEFAULT). Implicit shared messages will be disabled. */ ret = create_standard_file("default_file.h5", fcpl_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; /* There are five kinds of messages that can be shared: datatypes, * dataspaces, attributes, fill values, and filter pipelines. @@ -86,7 +73,8 @@ int main(void) */ /* To begin with, use only one index. */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); - if(ret < 0) goto error; + if (ret < 0) + goto error; /* Each index has a "minimum message size" for a message of that * type to be shared. Since sharing a message creates some overhead, @@ -111,7 +99,8 @@ int main(void) * shared in this single index. */ ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 40); - if(ret < 0) goto error; + if (ret < 0) + goto error; /* The other property that can be set for shared messages is the * list/B-tree cutoff for the indexes. @@ -128,7 +117,8 @@ int main(void) * second the minimum B-tree size. */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 30, 20); - if(ret < 0) goto error; + if (ret < 0) + goto error; /* Now create a file with this property list. After the FCPL is used, * everything is automatic; messages will be shared and this will be @@ -137,7 +127,8 @@ int main(void) * written later. */ ret = create_standard_file("one_index_file.h5", fcpl_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; /* Now try some variations on this. The FCPL hasn't been closed, so * we don't need to re-create it. @@ -147,36 +138,42 @@ int main(void) * overhead). */ ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 1000); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = create_standard_file("only_huge_mesgs_file.h5", fcpl_id); - if(ret < 0) goto error; - + if (ret < 0) + goto error; /* Or, suppose we only wanted to shared dataspaces and * attributes (which might make sense if we were going to use committed * datatypes). We could change the flags on the index: */ ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_ATTR_FLAG, 40); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = create_standard_file("only_dspaces_and_attrs_file.h5", fcpl_id); - if(ret < 0) goto error; - + if (ret < 0) + goto error; /* We could create a second index and put attributes in it to separate them * from datatypes and dataspaces (and then run some performance metrics to * see whether this improved caching performance). */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_SDSPACE_FLAG, 40); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_ATTR_FLAG, 40); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = create_standard_file("separate_indexes_file.h5", fcpl_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; /* We can try twiddling the "phase change" values and see what it does to * the file size. Since there's only a few different messages (two @@ -184,25 +181,30 @@ int main(void) * save some space. */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 40); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = H5Pset_shared_mesg_phase_change(fcpl_id, 5, 0); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = create_standard_file("small_lists_file.h5", fcpl_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; /* Or we could create indexes that are never lists, but are created as * B-trees. We do this by setting the "maximum list size" to zero. */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = create_standard_file("btrees_file.h5", fcpl_id); - if(ret < 0) goto error; - + if (ret < 0) + goto error; /* Obviously there are a lot more permutations of these options possible. * Performance will often be a tradeoff of speed for space, but will @@ -212,10 +214,10 @@ int main(void) * Please let The HDF Group (help@hdfgroup.org) know what you find! */ - /* Close the property list */ ret = H5Pclose(fcpl_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; return 0; error: @@ -238,21 +240,22 @@ error: herr_t create_standard_file(const char *filename, hid_t fcpl_id) { - hid_t file_id=-1; - hid_t type_id=-1, temp_type_id=-1; - hsize_t dims[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; - hid_t space_id=-1; - hid_t attr_type_id = -1; - hid_t attr_space_id = -1; - int attr_data[] = {1,2,3,4,5,6,7,8,9,0}; - hid_t dset_id=-1; - hid_t attr_id=-1; - int x; - herr_t ret; + hid_t file_id = -1; + hid_t type_id = -1, temp_type_id = -1; + hsize_t dims[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; + hid_t space_id = -1; + hid_t attr_type_id = -1; + hid_t attr_space_id = -1; + int attr_data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; + hid_t dset_id = -1; + hid_t attr_id = -1; + int x; + herr_t ret; /* Create the file */ file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); - if(file_id < 0) goto error; + if (file_id < 0) + goto error; /* Create the datatype we'll be using. Generally, sharing messages * is most useful when the message is complex and takes more space on @@ -260,66 +263,80 @@ create_standard_file(const char *filename, hid_t fcpl_id) * However, any type can be shared. */ temp_type_id = H5Tarray_create2(H5T_NATIVE_INT, 2, dims); - if(temp_type_id < 0) goto error; - type_id = H5Tarray_create2(temp_type_id, 2, dims); - if(type_id < 0) goto error; + if (temp_type_id < 0) + goto error; + type_id = H5Tarray_create2(temp_type_id, 2, dims); + if (type_id < 0) + goto error; ret = H5Tclose(temp_type_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; /* Create the dataspace we'll be using. * Again, create a more complex dataspace so that more space will * be saved when we share it. */ space_id = H5Screate_simple(10, dims, dims); - if(space_id < 0) goto error; + if (space_id < 0) + goto error; /* Create a datatype and dataspace for the attributes we'll be creating. * The datatype will be a single integer, and each attribute will hold * 10 integers. */ attr_type_id = H5Tcopy(H5T_NATIVE_INT); - if(attr_type_id < 0) goto error; + if (attr_type_id < 0) + goto error; attr_space_id = H5Screate_simple(1, dims, dims); - if(attr_space_id < 0) goto error; - + if (attr_space_id < 0) + goto error; /* Begin using the messages many times. Do this by creating datasets * that use this datatype, dataspace, and have this attribute. */ - for(x = 0; x < NUM_DATASETS; ++x) { - /* Create a dataset */ - dset_id = H5Dcreate2(file_id, DSETNAME[x], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset_id < 0) goto error; - - /* Create an attribute on the dataset */ - attr_id = H5Acreate2(dset_id, "attr_name", attr_type_id, attr_space_id, H5P_DEFAULT, H5P_DEFAULT); - if(attr_id < 0) goto error; - - /* Write data to the attribute */ - ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data); - if(ret < 0) goto error; - - ret = H5Aclose(attr_id); - if(ret < 0) goto error; - ret = H5Dclose(dset_id); - if(ret < 0) goto error; + for (x = 0; x < NUM_DATASETS; ++x) { + /* Create a dataset */ + dset_id = H5Dcreate2(file_id, DSETNAME[x], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset_id < 0) + goto error; + + /* Create an attribute on the dataset */ + attr_id = H5Acreate2(dset_id, "attr_name", attr_type_id, attr_space_id, H5P_DEFAULT, H5P_DEFAULT); + if (attr_id < 0) + goto error; + + /* Write data to the attribute */ + ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data); + if (ret < 0) + goto error; + + ret = H5Aclose(attr_id); + if (ret < 0) + goto error; + ret = H5Dclose(dset_id); + if (ret < 0) + goto error; } /* Close all open IDs */ ret = H5Tclose(attr_type_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = H5Sclose(attr_space_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = H5Tclose(type_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = H5Sclose(space_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; ret = H5Fclose(file_id); - if(ret < 0) goto error; + if (ret < 0) + goto error; return 0; error: return -1; } - diff --git a/examples/h5_subset.c b/examples/h5_subset.c index ad2eaba..bd680c7 100644 --- a/examples/h5_subset.c +++ b/examples/h5_subset.c @@ -20,34 +20,32 @@ #define FILE "subset.h5" #define DATASETNAME "IntArray" -#define RANK 2 +#define RANK 2 -#define DIM0_SUB 3 /* subset dimensions */ -#define DIM1_SUB 4 +#define DIM0_SUB 3 /* subset dimensions */ +#define DIM1_SUB 4 - -#define DIM0 8 /* size of dataset */ -#define DIM1 10 +#define DIM0 8 /* size of dataset */ +#define DIM1 10 int -main (void) +main(void) { - hsize_t dims[2], dimsm[2]; - int data[DIM0][DIM1]; /* data to write */ - int sdata[DIM0_SUB][DIM1_SUB]; /* subset to write */ - int rdata[DIM0][DIM1]; /* buffer for read */ - - hid_t file_id, dataset_id; /* handles */ - hid_t dataspace_id, memspace_id; + hsize_t dims[2], dimsm[2]; + int data[DIM0][DIM1]; /* data to write */ + int sdata[DIM0_SUB][DIM1_SUB]; /* subset to write */ + int rdata[DIM0][DIM1]; /* buffer for read */ - herr_t status; + hid_t file_id, dataset_id; /* handles */ + hid_t dataspace_id, memspace_id; - hsize_t count[2]; /* size of subset in the file */ - hsize_t offset[2]; /* subset offset in the file */ - hsize_t stride[2]; - hsize_t block[2]; - int i, j; + herr_t status; + hsize_t count[2]; /* size of subset in the file */ + hsize_t offset[2]; /* subset offset in the file */ + hsize_t stride[2]; + hsize_t block[2]; + int i, j; /***************************************************************** * Create a new file with default creation and access properties.* @@ -55,53 +53,50 @@ main (void) * and dataset. * *****************************************************************/ - file_id = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - dims[0] = DIM0; - dims[1] = DIM1; - dataspace_id = H5Screate_simple (RANK, dims, NULL); + file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - dataset_id = H5Dcreate2 (file_id, DATASETNAME, H5T_STD_I32BE, dataspace_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = DIM0; + dims[1] = DIM1; + dataspace_id = H5Screate_simple(RANK, dims, NULL); + dataset_id = + H5Dcreate2(file_id, DATASETNAME, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); for (j = 0; j < DIM0; j++) { - for (i = 0; i < DIM1; i++) - if (i< (DIM1/2)) - data[j][i] = 1; + for (i = 0; i < DIM1; i++) + if (i < (DIM1 / 2)) + data[j][i] = 1; else - data[j][i] = 2; + data[j][i] = 2; } - status = H5Dwrite (dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data); + status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - printf ("\nData Written to File:\n"); - for (i = 0; i #include -#define FILE "vds-eiger.h5" -#define DATASET "VDS-Eiger" -#define VDSDIM0 5 -#define VDSDIM1 10 -#define VDSDIM2 10 -#define DIM0 5 -#define DIM1 10 -#define DIM2 10 -#define RANK 3 +#define FILE "vds-eiger.h5" +#define DATASET "VDS-Eiger" +#define VDSDIM0 5 +#define VDSDIM1 10 +#define VDSDIM2 10 +#define DIM0 5 +#define DIM1 10 +#define DIM2 10 +#define RANK 3 int -main (void) +main(void) { - hid_t file, src_space, vspace, - dset; /* Handles */ - hid_t dcpl; - herr_t status; - hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, - vdsdims_max[3] = {H5S_UNLIMITED, VDSDIM1, VDSDIM1}, - dims[3] = {DIM0, DIM1, DIM2}, - start[3], /* Hyperslab parameters */ - stride[3], - count[3], - block[3]; - hsize_t start_out[3], /* Hyperslab parameter out */ - stride_out[3], - count_out[3], - block_out[3]; + hid_t file, src_space, vspace, dset; /* Handles */ + hid_t dcpl; + herr_t status; + hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, vdsdims_max[3] = {H5S_UNLIMITED, VDSDIM1, VDSDIM1}, + dims[3] = {DIM0, DIM1, DIM2}, start[3], /* Hyperslab parameters */ + stride[3], count[3], block[3]; + hsize_t start_out[3], /* Hyperslab parameter out */ + stride_out[3], count_out[3], block_out[3]; int i; - H5D_layout_t layout; /* Storage layout */ - size_t num_map; /* Number of mappings */ - ssize_t len; /* Length of the string; also a return value */ - char *filename; - char *dsetname; + H5D_layout_t layout; /* Storage layout */ + size_t num_map; /* Number of mappings */ + ssize_t len; /* Length of the string; also a return value */ + char * filename; + char * dsetname; - - file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ - vspace = H5Screate_simple (RANK, vdsdims, vdsdims_max); + vspace = H5Screate_simple(RANK, vdsdims, vdsdims_max); /* Create dataspaces for the source dataset. */ - src_space = H5Screate_simple (RANK, dims, NULL); + src_space = H5Screate_simple(RANK, dims, NULL); /* Create VDS creation property */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Initialize hyperslab values */ - start[0] = 0; - start[1] = 0; - start[2] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; stride[0] = DIM0; stride[1] = 1; stride[2] = 1; - count[0] = H5S_UNLIMITED; - count[1] = 1; - count[2] = 1; - block[0] = DIM0; - block[1] = DIM1; - block[2] = DIM2; - - /* - * Build the mappings - * - */ - status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block); - status = H5Pset_virtual (dcpl, vspace, "f-%b.h5", "/A", src_space); - + count[0] = H5S_UNLIMITED; + count[1] = 1; + count[2] = 1; + block[0] = DIM0; + block[1] = DIM1; + block[2] = DIM2; + /* + * Build the mappings + * + */ + status = H5Sselect_hyperslab(vspace, H5S_SELECT_SET, start, stride, count, block); + status = H5Pset_virtual(dcpl, vspace, "f-%b.h5", "/A", src_space); - /* Create a virtual dataset */ - dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Sclose (vspace); - status = H5Sclose (src_space); - status = H5Dclose (dset); - status = H5Fclose (file); - + /* Create a virtual dataset */ + dset = H5Dcreate2(file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Sclose(vspace); + status = H5Sclose(src_space); + status = H5Dclose(dset); + status = H5Fclose(file); /* * Now we begin the read section of this example. @@ -110,79 +98,82 @@ main (void) /* * Open file and dataset using the default properties. */ - file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); - dset = H5Dopen2 (file, DATASET, H5P_DEFAULT); + file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + dset = H5Dopen2(file, DATASET, H5P_DEFAULT); /* * Get creation property list and mapping properties. */ - dcpl = H5Dget_create_plist (dset); + dcpl = H5Dget_create_plist(dset); /* * Get storage layout. */ - layout = H5Pget_layout (dcpl); + layout = H5Pget_layout(dcpl); if (H5D_VIRTUAL == layout) printf(" Dataset has a virtual layout \n"); else printf(" Wrong layout found \n"); - /* - * Find number of mappings. - */ - status = H5Pget_virtual_count (dcpl, &num_map); - printf(" Number of mappings is %d\n", (int)num_map); - - /* - * Get mapping parameters for each mapping. - */ - for (i = 0; i < (int)num_map; i++) { - printf(" Mapping %d \n", i); - printf(" Selection in the virtual dataset \n"); - /* Get selection in the virttual dataset */ - vspace = H5Pget_virtual_vspace (dcpl, (size_t)i); - if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { - if (H5Sis_regular_hyperslab(vspace)) { - status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out); - printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]); - printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); - printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]); - printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]); - } - } - /* Get source file name */ - len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0); - filename = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1); - printf(" Source filename %s\n", filename); - - /* Get source dataset name */ - len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0); - dsetname = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1); - printf(" Source dataset name %s\n", dsetname); - - /* Get selection in the source dataset */ - printf(" Selection in the source dataset "); - src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i); - if(H5Sget_select_type(src_space) == H5S_SEL_ALL) { - printf("H5S_ALL \n"); - } -/* EIP read data back */ - H5Sclose(vspace); - H5Sclose(src_space); - free(filename); - free(dsetname); - } + /* + * Find number of mappings. + */ + status = H5Pget_virtual_count(dcpl, &num_map); + printf(" Number of mappings is %d\n", (int)num_map); + + /* + * Get mapping parameters for each mapping. + */ + for (i = 0; i < (int)num_map; i++) { + printf(" Mapping %d \n", i); + printf(" Selection in the virtual dataset \n"); + /* Get selection in the virttual dataset */ + vspace = H5Pget_virtual_vspace(dcpl, (size_t)i); + if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { + if (H5Sis_regular_hyperslab(vspace)) { + status = H5Sget_regular_hyperslab(vspace, start_out, stride_out, count_out, block_out); + printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], + (unsigned long long)start_out[1], (unsigned long long)start_out[2]); + printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], + (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); + printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], + (unsigned long long)count_out[1], (unsigned long long)count_out[2]); + printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], + (unsigned long long)block_out[1], (unsigned long long)block_out[2]); + } + } + /* Get source file name */ + len = H5Pget_virtual_filename(dcpl, (size_t)i, NULL, 0); + filename = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_filename(dcpl, (size_t)i, filename, len + 1); + printf(" Source filename %s\n", filename); + + /* Get source dataset name */ + len = H5Pget_virtual_dsetname(dcpl, (size_t)i, NULL, 0); + dsetname = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_dsetname(dcpl, (size_t)i, dsetname, len + 1); + printf(" Source dataset name %s\n", dsetname); + + /* Get selection in the source dataset */ + printf(" Selection in the source dataset "); + src_space = H5Pget_virtual_srcspace(dcpl, (size_t)i); + if (H5Sget_select_type(src_space) == H5S_SEL_ALL) { + printf("H5S_ALL \n"); + } + /* EIP read data back */ + H5Sclose(vspace); + H5Sclose(src_space); + free(filename); + free(dsetname); + } /* * Close and release resources. */ - status = H5Pclose (dcpl); - status = H5Dclose (dset); - status = H5Fclose (file); + status = H5Pclose(dcpl); + status = H5Dclose(dset); + status = H5Fclose(file); return 0; } - diff --git a/examples/h5_vds-exc.c b/examples/h5_vds-exc.c index b113c36..a9ef57e 100644 --- a/examples/h5_vds-exc.c +++ b/examples/h5_vds-exc.c @@ -22,80 +22,55 @@ #include #include -#define FILE "vds-exc.h5" -#define DATASET "VDS-Excalibur" -#define VDSDIM0 0 -#define VDSDIM1 15 -#define VDSDIM2 6 -#define KDIM0 0 -#define KDIM1 2 -#define KDIM2 6 -#define NDIM0 0 -#define NDIM1 3 -#define NDIM2 6 -#define RANK 3 - -const char *SRC_FILE[] = { - "a.h5", - "b.h5", - "c.h5", - "d.h5", - "e.h5", - "f.h5" -}; - -const char *SRC_DATASET[] = { - "A", - "B", - "C", - "D", - "E", - "F" -}; +#define FILE "vds-exc.h5" +#define DATASET "VDS-Excalibur" +#define VDSDIM0 0 +#define VDSDIM1 15 +#define VDSDIM2 6 +#define KDIM0 0 +#define KDIM1 2 +#define KDIM2 6 +#define NDIM0 0 +#define NDIM1 3 +#define NDIM2 6 +#define RANK 3 + +const char *SRC_FILE[] = {"a.h5", "b.h5", "c.h5", "d.h5", "e.h5", "f.h5"}; + +const char *SRC_DATASET[] = {"A", "B", "C", "D", "E", "F"}; int -main (void) +main(void) { - hid_t file, space, ksrc_space, nsrc_space, vspace, - src_space, - dset; /* Handles */ - hid_t dcpl; - herr_t status; - hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, - vdsdims_max[3] = {H5S_UNLIMITED,VDSDIM1, VDSDIM2}, - kdims[3] = {KDIM0, KDIM1, KDIM2}, - kdims_max[3] = {H5S_UNLIMITED, KDIM1, KDIM2}, - ndims[3] = {NDIM0, NDIM1, NDIM2}, - ndims_max[3] = {H5S_UNLIMITED, NDIM1, NDIM2}, - start[3], /* Hyperslab parameters */ - stride[3], - count[3], - block[3]; - hsize_t start_out[3], - stride_out[3], - count_out[3], - block_out[3]; + hid_t file, space, ksrc_space, nsrc_space, vspace, src_space, dset; /* Handles */ + hid_t dcpl; + herr_t status; + hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, vdsdims_max[3] = {H5S_UNLIMITED, VDSDIM1, VDSDIM2}, + kdims[3] = {KDIM0, KDIM1, KDIM2}, kdims_max[3] = {H5S_UNLIMITED, KDIM1, KDIM2}, + ndims[3] = {NDIM0, NDIM1, NDIM2}, ndims_max[3] = {H5S_UNLIMITED, NDIM1, NDIM2}, + start[3], /* Hyperslab parameters */ + stride[3], count[3], block[3]; + hsize_t start_out[3], stride_out[3], count_out[3], block_out[3]; int k = 2; int n = 3; int i; - H5D_layout_t layout; /* Storage layout */ - size_t num_map; /* Number of mappings */ - ssize_t len; /* Length of the string; also a return value */ - char *filename; - char *dsetname; + H5D_layout_t layout; /* Storage layout */ + size_t num_map; /* Number of mappings */ + ssize_t len; /* Length of the string; also a return value */ + char * filename; + char * dsetname; - - file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ - space = H5Screate_simple (RANK, vdsdims, vdsdims_max); + space = H5Screate_simple(RANK, vdsdims, vdsdims_max); /* Create dataspaces for A, C, and E datasets. */ - ksrc_space = H5Screate_simple (RANK, kdims, kdims_max); + ksrc_space = H5Screate_simple(RANK, kdims, kdims_max); /* Create dataspaces for B, D, and F datasets. */ - nsrc_space = H5Screate_simple (RANK, ndims, ndims_max); + nsrc_space = H5Screate_simple(RANK, ndims, ndims_max); /* Create VDS creation property */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Initialize hyperslab values */ @@ -109,42 +84,40 @@ main (void) block[1] = k; block[2] = VDSDIM2; - /* - * Build the mappings for A, C and E source datasets. - * Unlimited hyperslab selection is the same in the source datasets. - * Unlimited hyperslab selections in the virtual dataset have different offsets. - */ - status = H5Sselect_hyperslab (ksrc_space, H5S_SELECT_SET, start, NULL, count, block); - for (i = 0; i < 3; i++) { - start[1] = (hsize_t)((k+n)*i); - status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block); - status = H5Pset_virtual (dcpl, space, SRC_FILE[2*i], SRC_DATASET[2*i], ksrc_space); - } - - /* Reinitialize start[1] and block[1] to build the second set of mappings. */ - start[1] = 0; - block[1] = n; - /* - * Build the mappings for B, D and F source datasets. - * Unlimited hyperslab selection is the same in the source datasets. - * Unlimited hyperslab selections in the virtual dataset have different offsets. - */ - status = H5Sselect_hyperslab (nsrc_space, H5S_SELECT_SET, start, NULL, count, block); - for (i = 0; i < 3; i++) { - start[1] = (hsize_t)(k+(k+n)*i); - status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block); - status = H5Pset_virtual (dcpl, space, SRC_FILE[2*i+1], SRC_DATASET[2*i+1], nsrc_space); - } - - /* Create a virtual dataset */ - dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Sclose (space); - status = H5Sclose (nsrc_space); - status = H5Sclose (ksrc_space); - status = H5Dclose (dset); - status = H5Fclose (file); - + /* + * Build the mappings for A, C and E source datasets. + * Unlimited hyperslab selection is the same in the source datasets. + * Unlimited hyperslab selections in the virtual dataset have different offsets. + */ + status = H5Sselect_hyperslab(ksrc_space, H5S_SELECT_SET, start, NULL, count, block); + for (i = 0; i < 3; i++) { + start[1] = (hsize_t)((k + n) * i); + status = H5Sselect_hyperslab(space, H5S_SELECT_SET, start, NULL, count, block); + status = H5Pset_virtual(dcpl, space, SRC_FILE[2 * i], SRC_DATASET[2 * i], ksrc_space); + } + + /* Reinitialize start[1] and block[1] to build the second set of mappings. */ + start[1] = 0; + block[1] = n; + /* + * Build the mappings for B, D and F source datasets. + * Unlimited hyperslab selection is the same in the source datasets. + * Unlimited hyperslab selections in the virtual dataset have different offsets. + */ + status = H5Sselect_hyperslab(nsrc_space, H5S_SELECT_SET, start, NULL, count, block); + for (i = 0; i < 3; i++) { + start[1] = (hsize_t)(k + (k + n) * i); + status = H5Sselect_hyperslab(space, H5S_SELECT_SET, start, NULL, count, block); + status = H5Pset_virtual(dcpl, space, SRC_FILE[2 * i + 1], SRC_DATASET[2 * i + 1], nsrc_space); + } + + /* Create a virtual dataset */ + dset = H5Dcreate2(file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Sclose(space); + status = H5Sclose(nsrc_space); + status = H5Sclose(ksrc_space); + status = H5Dclose(dset); + status = H5Fclose(file); /* * Now we begin the read section of this example. @@ -153,85 +126,92 @@ main (void) /* * Open file and dataset using the default properties. */ - file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); - dset = H5Dopen2 (file, DATASET, H5P_DEFAULT); + file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + dset = H5Dopen2(file, DATASET, H5P_DEFAULT); /* * Get creation property list and mapping properties. */ - dcpl = H5Dget_create_plist (dset); + dcpl = H5Dget_create_plist(dset); /* * Get storage layout. */ - layout = H5Pget_layout (dcpl); + layout = H5Pget_layout(dcpl); if (H5D_VIRTUAL == layout) printf(" Dataset has a virtual layout \n"); else printf("Wrong layout found \n"); - /* - * Find number of mappings. - */ - status = H5Pget_virtual_count (dcpl, &num_map); - printf(" Number of mappings is %lu\n", (unsigned long)num_map); - - /* - * Get mapping parameters for each mapping. - */ - for (i = 0; i < (int)num_map; i++) { - printf(" Mapping %d \n", i); - printf(" Selection in the virtual dataset \n"); - /* Get selection in the virttual dataset */ - vspace = H5Pget_virtual_vspace (dcpl, (size_t)i); - if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { - if (H5Sis_regular_hyperslab(vspace)) { - status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out); - printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]); - printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); - printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]); - printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]); - } - } - /* Get source file name */ - len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0); - filename = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1); - printf(" Source filename %s\n", filename); - - /* Get source dataset name */ - len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0); - dsetname = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1); - printf(" Source dataset name %s\n", dsetname); - - /* Get selection in the source dataset */ - printf(" Selection in the source dataset \n"); - src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i); - if (H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) { - if (H5Sis_regular_hyperslab(vspace)) { - status = H5Sget_regular_hyperslab (src_space, start_out, stride_out, count_out, block_out); - printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]); - printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); - printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]); - printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]); - } - } - H5Sclose(vspace); - H5Sclose(src_space); - free(filename); - free(dsetname); - } -/* EIP read data back */ + /* + * Find number of mappings. + */ + status = H5Pget_virtual_count(dcpl, &num_map); + printf(" Number of mappings is %lu\n", (unsigned long)num_map); + + /* + * Get mapping parameters for each mapping. + */ + for (i = 0; i < (int)num_map; i++) { + printf(" Mapping %d \n", i); + printf(" Selection in the virtual dataset \n"); + /* Get selection in the virttual dataset */ + vspace = H5Pget_virtual_vspace(dcpl, (size_t)i); + if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { + if (H5Sis_regular_hyperslab(vspace)) { + status = H5Sget_regular_hyperslab(vspace, start_out, stride_out, count_out, block_out); + printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], + (unsigned long long)start_out[1], (unsigned long long)start_out[2]); + printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], + (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); + printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], + (unsigned long long)count_out[1], (unsigned long long)count_out[2]); + printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], + (unsigned long long)block_out[1], (unsigned long long)block_out[2]); + } + } + /* Get source file name */ + len = H5Pget_virtual_filename(dcpl, (size_t)i, NULL, 0); + filename = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_filename(dcpl, (size_t)i, filename, len + 1); + printf(" Source filename %s\n", filename); + + /* Get source dataset name */ + len = H5Pget_virtual_dsetname(dcpl, (size_t)i, NULL, 0); + dsetname = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_dsetname(dcpl, (size_t)i, dsetname, len + 1); + printf(" Source dataset name %s\n", dsetname); + + /* Get selection in the source dataset */ + printf(" Selection in the source dataset \n"); + src_space = H5Pget_virtual_srcspace(dcpl, (size_t)i); + if (H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) { + if (H5Sis_regular_hyperslab(vspace)) { + status = H5Sget_regular_hyperslab(src_space, start_out, stride_out, count_out, block_out); + printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], + (unsigned long long)start_out[1], (unsigned long long)start_out[2]); + printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], + (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); + printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], + (unsigned long long)count_out[1], (unsigned long long)count_out[2]); + printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], + (unsigned long long)block_out[1], (unsigned long long)block_out[2]); + } + } + H5Sclose(vspace); + H5Sclose(src_space); + free(filename); + free(dsetname); + } + /* EIP read data back */ /* * Close and release resources. */ - status = H5Pclose (dcpl); - status = H5Dclose (dset); - status = H5Fclose (file); + status = H5Pclose(dcpl); + status = H5Dclose(dset); + status = H5Fclose(file); return 0; } - diff --git a/examples/h5_vds-exclim.c b/examples/h5_vds-exclim.c index 152731c..559799b 100644 --- a/examples/h5_vds-exclim.c +++ b/examples/h5_vds-exclim.c @@ -23,77 +23,53 @@ #include #include -#define FILE "vds-exclim.h5" -#define DATASET "VDS-Excaliburlim" -#define VDSDIM0 3 -#define VDSDIM1 15 -#define VDSDIM2 6 -#define KDIM0 3 -#define KDIM1 2 -#define KDIM2 6 -#define NDIM0 3 -#define NDIM1 3 -#define NDIM2 6 -#define RANK 3 - -const char *SRC_FILE[] = { - "a.h5", - "b.h5", - "c.h5", - "d.h5", - "e.h5", - "f.h5" -}; - -const char *SRC_DATASET[] = { - "A", - "B", - "C", - "D", - "E", - "F" -}; +#define FILE "vds-exclim.h5" +#define DATASET "VDS-Excaliburlim" +#define VDSDIM0 3 +#define VDSDIM1 15 +#define VDSDIM2 6 +#define KDIM0 3 +#define KDIM1 2 +#define KDIM2 6 +#define NDIM0 3 +#define NDIM1 3 +#define NDIM2 6 +#define RANK 3 + +const char *SRC_FILE[] = {"a.h5", "b.h5", "c.h5", "d.h5", "e.h5", "f.h5"}; + +const char *SRC_DATASET[] = {"A", "B", "C", "D", "E", "F"}; int -main (void) +main(void) { - hid_t file, space, ksrc_space, nsrc_space, vspace, - src_space, - dset; /* Handles */ - hid_t dcpl; - herr_t status; - hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, - kdims[3] = {KDIM0, KDIM1, KDIM2}, - ndims[3] = {NDIM0, NDIM1, NDIM2}, - start[3], /* Hyperslab parameters */ - stride[3], - count[3], - block[3]; - hsize_t start_out[3], - stride_out[3], - count_out[3], - block_out[3]; + hid_t file, space, ksrc_space, nsrc_space, vspace, src_space, dset; /* Handles */ + hid_t dcpl; + herr_t status; + hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, kdims[3] = {KDIM0, KDIM1, KDIM2}, + ndims[3] = {NDIM0, NDIM1, NDIM2}, start[3], /* Hyperslab parameters */ + stride[3], count[3], block[3]; + hsize_t start_out[3], stride_out[3], count_out[3], block_out[3]; int k = 2; int n = 3; int i; - H5D_layout_t layout; /* Storage layout */ - size_t num_map; /* Number of mappings */ - ssize_t len; /* Length of the string; also a return value */ - char *filename; - char *dsetname; + H5D_layout_t layout; /* Storage layout */ + size_t num_map; /* Number of mappings */ + ssize_t len; /* Length of the string; also a return value */ + char * filename; + char * dsetname; - - file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ - space = H5Screate_simple (RANK, vdsdims, NULL); + space = H5Screate_simple(RANK, vdsdims, NULL); /* Create dataspaces for A, C, and E datasets. */ - ksrc_space = H5Screate_simple (RANK, kdims, NULL); + ksrc_space = H5Screate_simple(RANK, kdims, NULL); /* Create dataspaces for B, D, and F datasets. */ - nsrc_space = H5Screate_simple (RANK, ndims, NULL); + nsrc_space = H5Screate_simple(RANK, ndims, NULL); /* Create VDS creation property */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Initialize hyperslab values */ @@ -107,40 +83,38 @@ main (void) block[1] = k; block[2] = VDSDIM2; - /* - * Build the mappings for A, C and E source datasets. - * - */ - status = H5Sselect_hyperslab (ksrc_space, H5S_SELECT_SET, start, NULL, count, block); - for (i = 0; i < 3; i++) { - start[1] = (hsize_t)((k+n)*i); - status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block); - status = H5Pset_virtual (dcpl, space, SRC_FILE[2*i], SRC_DATASET[2*i], ksrc_space); - } - - /* Reinitialize start[0] and block[1] */ - start[0] = 0; - block[1] = n; - /* - * Build the mappings for B, D and F source datasets. - * - */ - status = H5Sselect_hyperslab (nsrc_space, H5S_SELECT_SET, start, NULL, count, block); - for (i = 0; i < 3; i++) { - start[1] = (hsize_t)(k+(k+n)*i); - status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block); - status = H5Pset_virtual (dcpl, space, SRC_FILE[2*i+1], SRC_DATASET[2*i+1], nsrc_space); - } - - /* Create a virtual dataset */ - dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Sclose (space); - status = H5Sclose (nsrc_space); - status = H5Sclose (ksrc_space); - status = H5Dclose (dset); - status = H5Fclose (file); - + /* + * Build the mappings for A, C and E source datasets. + * + */ + status = H5Sselect_hyperslab(ksrc_space, H5S_SELECT_SET, start, NULL, count, block); + for (i = 0; i < 3; i++) { + start[1] = (hsize_t)((k + n) * i); + status = H5Sselect_hyperslab(space, H5S_SELECT_SET, start, NULL, count, block); + status = H5Pset_virtual(dcpl, space, SRC_FILE[2 * i], SRC_DATASET[2 * i], ksrc_space); + } + + /* Reinitialize start[0] and block[1] */ + start[0] = 0; + block[1] = n; + /* + * Build the mappings for B, D and F source datasets. + * + */ + status = H5Sselect_hyperslab(nsrc_space, H5S_SELECT_SET, start, NULL, count, block); + for (i = 0; i < 3; i++) { + start[1] = (hsize_t)(k + (k + n) * i); + status = H5Sselect_hyperslab(space, H5S_SELECT_SET, start, NULL, count, block); + status = H5Pset_virtual(dcpl, space, SRC_FILE[2 * i + 1], SRC_DATASET[2 * i + 1], nsrc_space); + } + + /* Create a virtual dataset */ + dset = H5Dcreate2(file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Sclose(space); + status = H5Sclose(nsrc_space); + status = H5Sclose(ksrc_space); + status = H5Dclose(dset); + status = H5Fclose(file); /* * Now we begin the read section of this example. @@ -149,85 +123,92 @@ main (void) /* * Open file and dataset using the default properties. */ - file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); - dset = H5Dopen2 (file, DATASET, H5P_DEFAULT); + file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + dset = H5Dopen2(file, DATASET, H5P_DEFAULT); /* * Get creation property list and mapping properties. */ - dcpl = H5Dget_create_plist (dset); + dcpl = H5Dget_create_plist(dset); /* * Get storage layout. */ - layout = H5Pget_layout (dcpl); + layout = H5Pget_layout(dcpl); if (H5D_VIRTUAL == layout) printf(" Dataset has a virtual layout \n"); else printf("Wrong layout found \n"); - /* - * Find number of mappings. - */ - status = H5Pget_virtual_count (dcpl, &num_map); - printf(" Number of mappings is %lu\n", (unsigned long)num_map); - - /* - * Get mapping parameters for each mapping. - */ - for (i = 0; i < (int)num_map; i++) { - printf(" Mapping %d \n", i); - printf(" Selection in the virtual dataset \n"); - /* Get selection in the virttual dataset */ - vspace = H5Pget_virtual_vspace (dcpl, (size_t)i); - if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { - if (H5Sis_regular_hyperslab(vspace)) { - status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out); - printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]); - printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); - printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]); - printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]); - } - } - /* Get source file name */ - len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0); - filename = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1); - printf(" Source filename %s\n", filename); - - /* Get source dataset name */ - len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0); - dsetname = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1); - printf(" Source dataset name %s\n", dsetname); - - /* Get selection in the source dataset */ - printf(" Selection in the source dataset \n"); - src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i); - if(H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) { - if (H5Sis_regular_hyperslab(vspace)) { - status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out); - printf(" start = [%d, %d, %d] \n", (int)start_out[0], (int)start_out[1], (int)start_out[2]); - printf(" stride = [%d, %d, %d] \n", (int)stride_out[0], (int)stride_out[1], (int)stride_out[2]); - printf(" count = [%d, %d, %d] \n", (int)count_out[0], (int)count_out[1], (int)count_out[2]); - printf(" block = [%d, %d, %d] \n", (int)block_out[0], (int)block_out[1], (int)block_out[2]); - } - } - H5Sclose(vspace); - H5Sclose(src_space); - free(filename); - free(dsetname); - } -/* EIP read data back */ + /* + * Find number of mappings. + */ + status = H5Pget_virtual_count(dcpl, &num_map); + printf(" Number of mappings is %lu\n", (unsigned long)num_map); + + /* + * Get mapping parameters for each mapping. + */ + for (i = 0; i < (int)num_map; i++) { + printf(" Mapping %d \n", i); + printf(" Selection in the virtual dataset \n"); + /* Get selection in the virttual dataset */ + vspace = H5Pget_virtual_vspace(dcpl, (size_t)i); + if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { + if (H5Sis_regular_hyperslab(vspace)) { + status = H5Sget_regular_hyperslab(vspace, start_out, stride_out, count_out, block_out); + printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], + (unsigned long long)start_out[1], (unsigned long long)start_out[2]); + printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], + (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); + printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], + (unsigned long long)count_out[1], (unsigned long long)count_out[2]); + printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], + (unsigned long long)block_out[1], (unsigned long long)block_out[2]); + } + } + /* Get source file name */ + len = H5Pget_virtual_filename(dcpl, (size_t)i, NULL, 0); + filename = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_filename(dcpl, (size_t)i, filename, len + 1); + printf(" Source filename %s\n", filename); + + /* Get source dataset name */ + len = H5Pget_virtual_dsetname(dcpl, (size_t)i, NULL, 0); + dsetname = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_dsetname(dcpl, (size_t)i, dsetname, len + 1); + printf(" Source dataset name %s\n", dsetname); + + /* Get selection in the source dataset */ + printf(" Selection in the source dataset \n"); + src_space = H5Pget_virtual_srcspace(dcpl, (size_t)i); + if (H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) { + if (H5Sis_regular_hyperslab(vspace)) { + status = H5Sget_regular_hyperslab(vspace, start_out, stride_out, count_out, block_out); + printf(" start = [%d, %d, %d] \n", (int)start_out[0], (int)start_out[1], + (int)start_out[2]); + printf(" stride = [%d, %d, %d] \n", (int)stride_out[0], (int)stride_out[1], + (int)stride_out[2]); + printf(" count = [%d, %d, %d] \n", (int)count_out[0], (int)count_out[1], + (int)count_out[2]); + printf(" block = [%d, %d, %d] \n", (int)block_out[0], (int)block_out[1], + (int)block_out[2]); + } + } + H5Sclose(vspace); + H5Sclose(src_space); + free(filename); + free(dsetname); + } + /* EIP read data back */ /* * Close and release resources. */ - status = H5Pclose (dcpl); - status = H5Dclose (dset); - status = H5Fclose (file); + status = H5Pclose(dcpl); + status = H5Dclose(dset); + status = H5Fclose(file); return 0; } - diff --git a/examples/h5_vds-percival-unlim-maxmin.c b/examples/h5_vds-percival-unlim-maxmin.c index 7b0d532..01e41ef 100644 --- a/examples/h5_vds-percival-unlim-maxmin.c +++ b/examples/h5_vds-percival-unlim-maxmin.c @@ -26,185 +26,162 @@ #include #include -#define VFILE "vds-percival-unlim-maxmin.h5" -#define DATASET "VDS-Percival-unlim-maxmin" -#define VDSDIM0 H5S_UNLIMITED -#define VDSDIM1 10 -#define VDSDIM2 10 - -#define DIM0 H5S_UNLIMITED -#define DIM0_1 4 /* Initial size of the source datasets */ -#define DIM1 10 -#define DIM2 10 -#define RANK 3 -#define PLANE_STRIDE 4 - -const char *SRC_FILE[] = { - "a.h5", - "b.h5", - "c.h5", - "d.h5" -}; - -const char *SRC_DATASET[] = { - "A", - "B", - "C", - "D" -}; +#define VFILE "vds-percival-unlim-maxmin.h5" +#define DATASET "VDS-Percival-unlim-maxmin" +#define VDSDIM0 H5S_UNLIMITED +#define VDSDIM1 10 +#define VDSDIM2 10 + +#define DIM0 H5S_UNLIMITED +#define DIM0_1 4 /* Initial size of the source datasets */ +#define DIM1 10 +#define DIM2 10 +#define RANK 3 +#define PLANE_STRIDE 4 + +const char *SRC_FILE[] = {"a.h5", "b.h5", "c.h5", "d.h5"}; + +const char *SRC_DATASET[] = {"A", "B", "C", "D"}; int -main (void) +main(void) { - hid_t vfile, file, src_space, mem_space, vspace, - vdset, dset; /* Handles */ - hid_t dcpl, dapl; - herr_t status; - hsize_t vdsdims[3] = {4*DIM0_1, VDSDIM1, VDSDIM2}, - vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, - dims[3] = {DIM0_1, DIM1, DIM2}, - memdims[3] = {DIM0_1, DIM1, DIM2}, - extdims[3] = {0, DIM1, DIM2}, /* Dimensions of the extended source datasets */ - chunk_dims[3] = {DIM0_1, DIM1, DIM2}, - dims_max[3] = {DIM0, DIM1, DIM2}, - vdsdims_out[3], - vdsdims_max_out[3], - start[3], /* Hyperslab parameters */ - stride[3], - count[3], - src_count[3], - block[3]; - hsize_t start_out[3], /* Hyperslab parameter out */ - stride_out[3], - count_out[3], - block_out[3]; + hid_t vfile, file, src_space, mem_space, vspace, vdset, dset; /* Handles */ + hid_t dcpl, dapl; + herr_t status; + hsize_t vdsdims[3] = {4 * DIM0_1, VDSDIM1, VDSDIM2}, vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, + dims[3] = {DIM0_1, DIM1, DIM2}, memdims[3] = {DIM0_1, DIM1, DIM2}, + extdims[3] = {0, DIM1, DIM2}, /* Dimensions of the extended source datasets */ + chunk_dims[3] = {DIM0_1, DIM1, DIM2}, dims_max[3] = {DIM0, DIM1, DIM2}, vdsdims_out[3], + vdsdims_max_out[3], start[3], /* Hyperslab parameters */ + stride[3], count[3], src_count[3], block[3]; + hsize_t start_out[3], /* Hyperslab parameter out */ + stride_out[3], count_out[3], block_out[3]; int i, j; - H5D_layout_t layout; /* Storage layout */ - size_t num_map; /* Number of mappings */ - ssize_t len; /* Length of the string; also a return value */ - char *filename; - char *dsetname; - int wdata[DIM0_1*DIM1*DIM2]; + H5D_layout_t layout; /* Storage layout */ + size_t num_map; /* Number of mappings */ + ssize_t len; /* Length of the string; also a return value */ + char * filename; + char * dsetname; + int wdata[DIM0_1 * DIM1 * DIM2]; /* * Create source files and datasets. This step is optional. */ - for (i=0; i < PLANE_STRIDE; i++) { + for (i = 0; i < PLANE_STRIDE; i++) { /* * Initialize data for i-th source dataset. */ - for (j = 0; j < DIM0_1*DIM1*DIM2; j++) wdata[j] = i+1; + for (j = 0; j < DIM0_1 * DIM1 * DIM2; j++) + wdata[j] = i + 1; /* * Create the source files and datasets. Write data to each dataset and * close all resources. */ - file = H5Fcreate (SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - src_space = H5Screate_simple (RANK, dims, dims_max); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - status = H5Pset_chunk (dcpl, RANK, chunk_dims); - dset = H5Dcreate2 (file, SRC_DATASET[i], H5T_NATIVE_INT, src_space, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - wdata); - status = H5Sclose (src_space); - status = H5Pclose (dcpl); - status = H5Dclose (dset); - status = H5Fclose (file); + file = H5Fcreate(SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + src_space = H5Screate_simple(RANK, dims, dims_max); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + status = H5Pset_chunk(dcpl, RANK, chunk_dims); + dset = H5Dcreate2(file, SRC_DATASET[i], H5T_NATIVE_INT, src_space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + status = H5Sclose(src_space); + status = H5Pclose(dcpl); + status = H5Dclose(dset); + status = H5Fclose(file); } - vfile = H5Fcreate (VFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + vfile = H5Fcreate(VFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ - vspace = H5Screate_simple (RANK, vdsdims, vdsdims_max); + vspace = H5Screate_simple(RANK, vdsdims, vdsdims_max); /* Create dataspaces for the source dataset. */ - src_space = H5Screate_simple (RANK, dims, dims_max); + src_space = H5Screate_simple(RANK, dims, dims_max); /* Create VDS creation property */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Initialize hyperslab values */ - start[0] = 0; - start[1] = 0; - start[2] = 0; - stride[0] = PLANE_STRIDE; /* we will select every fifth plane in VDS */ - stride[1] = 1; - stride[2] = 1; - count[0] = H5S_UNLIMITED; - count[1] = 1; - count[2] = 1; + start[0] = 0; + start[1] = 0; + start[2] = 0; + stride[0] = PLANE_STRIDE; /* we will select every fifth plane in VDS */ + stride[1] = 1; + stride[2] = 1; + count[0] = H5S_UNLIMITED; + count[1] = 1; + count[2] = 1; src_count[0] = H5S_UNLIMITED; src_count[1] = 1; src_count[2] = 1; - block[0] = 1; - block[1] = DIM1; - block[2] = DIM2; + block[0] = 1; + block[1] = DIM1; + block[2] = DIM2; /* * Build the mappings * */ - status = H5Sselect_hyperslab (src_space, H5S_SELECT_SET, start, NULL, src_count, block); - for (i=0; i < PLANE_STRIDE; i++) { - status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block); - status = H5Pset_virtual (dcpl, vspace, SRC_FILE[i], SRC_DATASET[i], src_space); + status = H5Sselect_hyperslab(src_space, H5S_SELECT_SET, start, NULL, src_count, block); + for (i = 0; i < PLANE_STRIDE; i++) { + status = H5Sselect_hyperslab(vspace, H5S_SELECT_SET, start, stride, count, block); + status = H5Pset_virtual(dcpl, vspace, SRC_FILE[i], SRC_DATASET[i], src_space); start[0]++; } H5Sselect_none(vspace); /* Create a virtual dataset */ - vdset = H5Dcreate2 (vfile, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Sclose (vspace); - status = H5Sclose (src_space); - status = H5Pclose (dcpl); + vdset = H5Dcreate2(vfile, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Sclose(vspace); + status = H5Sclose(src_space); + status = H5Pclose(dcpl); /* Let's add data to the source datasets and check new dimensions for VDS */ /* We will add only one plane to the first source dataset, two planes to the second one, three to the third, and four to the forth. */ - for (i=0; i < PLANE_STRIDE; i++) { + for (i = 0; i < PLANE_STRIDE; i++) { /* * Initialize data for i-th source dataset. */ - for (j = 0; j < (i+1)*DIM1*DIM2; j++) wdata[j] = 10*(i+1); + for (j = 0; j < (i + 1) * DIM1 * DIM2; j++) + wdata[j] = 10 * (i + 1); /* * Open the source files and datasets. Appen data to each dataset and * close all resources. */ - file = H5Fopen (SRC_FILE[i], H5F_ACC_RDWR, H5P_DEFAULT); - dset = H5Dopen2 (file, SRC_DATASET[i], H5P_DEFAULT); - extdims[0] = DIM0_1+i+1; - status = H5Dset_extent (dset, extdims); - src_space = H5Dget_space (dset); - start[0] = DIM0_1; - start[1] = 0; - start[2] = 0; - count[0] = 1; - count[1] = 1; - count[2] = 1; - block[0] = i+1; - block[1] = DIM1; - block[2] = DIM2; - - memdims[0] = i+1; - mem_space = H5Screate_simple(RANK, memdims, NULL); - status = H5Sselect_hyperslab (src_space, H5S_SELECT_SET, start, NULL, count, block); - status = H5Dwrite (dset, H5T_NATIVE_INT, mem_space, src_space, H5P_DEFAULT, - wdata); - status = H5Sclose (src_space); - status = H5Dclose (dset); - status = H5Fclose (file); - } - - status = H5Dclose (vdset); - status = H5Fclose (vfile); + file = H5Fopen(SRC_FILE[i], H5F_ACC_RDWR, H5P_DEFAULT); + dset = H5Dopen2(file, SRC_DATASET[i], H5P_DEFAULT); + extdims[0] = DIM0_1 + i + 1; + status = H5Dset_extent(dset, extdims); + src_space = H5Dget_space(dset); + start[0] = DIM0_1; + start[1] = 0; + start[2] = 0; + count[0] = 1; + count[1] = 1; + count[2] = 1; + block[0] = i + 1; + block[1] = DIM1; + block[2] = DIM2; + + memdims[0] = i + 1; + mem_space = H5Screate_simple(RANK, memdims, NULL); + status = H5Sselect_hyperslab(src_space, H5S_SELECT_SET, start, NULL, count, block); + status = H5Dwrite(dset, H5T_NATIVE_INT, mem_space, src_space, H5P_DEFAULT, wdata); + status = H5Sclose(src_space); + status = H5Dclose(dset); + status = H5Fclose(file); + } + + status = H5Dclose(vdset); + status = H5Fclose(vfile); /* * Now we begin the read section of this example. @@ -213,108 +190,115 @@ main (void) /* * Open file and dataset using the default properties. */ - vfile = H5Fopen (VFILE, H5F_ACC_RDONLY, H5P_DEFAULT); + vfile = H5Fopen(VFILE, H5F_ACC_RDONLY, H5P_DEFAULT); /* * Open VDS using different access properties to use max or * min extents depending on the sizes of the underlying datasets */ - dapl = H5Pcreate (H5P_DATASET_ACCESS); + dapl = H5Pcreate(H5P_DATASET_ACCESS); - for(i = 0; i < 2; i++) { - status = H5Pset_virtual_view (dapl, i ? H5D_VDS_LAST_AVAILABLE : H5D_VDS_FIRST_MISSING); - vdset = H5Dopen2 (vfile, DATASET, dapl); + for (i = 0; i < 2; i++) { + status = H5Pset_virtual_view(dapl, i ? H5D_VDS_LAST_AVAILABLE : H5D_VDS_FIRST_MISSING); + vdset = H5Dopen2(vfile, DATASET, dapl); /* Let's get space of the VDS and its dimension; we should get 32(or 20)x10x10 */ - vspace = H5Dget_space (vdset); - H5Sget_simple_extent_dims (vspace, vdsdims_out, vdsdims_max_out); - printf ("VDS dimensions, bounds = H5D_VDS_%s: ", i ? "LAST_AVAILABLE" : "FIRST_MISSING"); - for (j=0; j #include -#define VFILE "vds-percival-unlim.h5" -#define DATASET "VDS-Percival-unlim" -#define VDSDIM0 H5S_UNLIMITED -#define VDSDIM1 10 -#define VDSDIM2 10 - -#define DIM0 H5S_UNLIMITED -#define DIM0_1 10 /* Initial size of the datasets */ -#define DIM1 10 -#define DIM2 10 -#define RANK 3 -#define PLANE_STRIDE 4 - -const char *SRC_FILE[] = { - "a.h5", - "b.h5", - "c.h5", - "d.h5" -}; - -const char *SRC_DATASET[] = { - "A", - "B", - "C", - "D" -}; +#define VFILE "vds-percival-unlim.h5" +#define DATASET "VDS-Percival-unlim" +#define VDSDIM0 H5S_UNLIMITED +#define VDSDIM1 10 +#define VDSDIM2 10 + +#define DIM0 H5S_UNLIMITED +#define DIM0_1 10 /* Initial size of the datasets */ +#define DIM1 10 +#define DIM2 10 +#define RANK 3 +#define PLANE_STRIDE 4 + +const char *SRC_FILE[] = {"a.h5", "b.h5", "c.h5", "d.h5"}; + +const char *SRC_DATASET[] = {"A", "B", "C", "D"}; int -main (void) +main(void) { - hid_t vfile, file, src_space, mem_space, vspace, - vdset, dset; /* Handles */ - hid_t dcpl; - herr_t status; - hsize_t vdsdims[3] = {4*DIM0_1, VDSDIM1, VDSDIM2}, - vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, - dims[3] = {DIM0_1, DIM1, DIM2}, - extdims[3] = {2*DIM0_1, DIM1, DIM2}, - chunk_dims[3] = {DIM0_1, DIM1, DIM2}, - dims_max[3] = {DIM0, DIM1, DIM2}, - vdsdims_out[3], - vdsdims_max_out[3], - start[3], /* Hyperslab parameters */ - stride[3], - count[3], - src_count[3], - block[3]; - hsize_t start_out[3], /* Hyperslab parameter out */ - stride_out[3], - count_out[3], - block_out[3]; + hid_t vfile, file, src_space, mem_space, vspace, vdset, dset; /* Handles */ + hid_t dcpl; + herr_t status; + hsize_t vdsdims[3] = {4 * DIM0_1, VDSDIM1, VDSDIM2}, vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, + dims[3] = {DIM0_1, DIM1, DIM2}, extdims[3] = {2 * DIM0_1, DIM1, DIM2}, + chunk_dims[3] = {DIM0_1, DIM1, DIM2}, dims_max[3] = {DIM0, DIM1, DIM2}, vdsdims_out[3], + vdsdims_max_out[3], start[3], /* Hyperslab parameters */ + stride[3], count[3], src_count[3], block[3]; + hsize_t start_out[3], /* Hyperslab parameter out */ + stride_out[3], count_out[3], block_out[3]; int i, j, k; - H5D_layout_t layout; /* Storage layout */ - size_t num_map; /* Number of mappings */ - ssize_t len; /* Length of the string; also a return value */ - char *filename; - char *dsetname; - int wdata[DIM0_1*DIM1*DIM2]; + H5D_layout_t layout; /* Storage layout */ + size_t num_map; /* Number of mappings */ + ssize_t len; /* Length of the string; also a return value */ + char * filename; + char * dsetname; + int wdata[DIM0_1 * DIM1 * DIM2]; int rdata[80][10][10]; int a_rdata[20][10][10]; /* * Create source files and datasets. This step is optional. */ - for (i=0; i < PLANE_STRIDE; i++) { + for (i = 0; i < PLANE_STRIDE; i++) { /* * Initialize data for i-th source dataset. */ - for (j = 0; j < DIM0_1*DIM1*DIM2; j++) wdata[j] = i+1; + for (j = 0; j < DIM0_1 * DIM1 * DIM2; j++) + wdata[j] = i + 1; /* * Create the source files and datasets. Write data to each dataset and * close all resources. */ - file = H5Fcreate (SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - src_space = H5Screate_simple (RANK, dims, dims_max); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - status = H5Pset_chunk (dcpl, RANK, chunk_dims); - dset = H5Dcreate2 (file, SRC_DATASET[i], H5T_NATIVE_INT, src_space, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - wdata); - status = H5Sclose (src_space); - status = H5Pclose (dcpl); - status = H5Dclose (dset); - status = H5Fclose (file); + file = H5Fcreate(SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + src_space = H5Screate_simple(RANK, dims, dims_max); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + status = H5Pset_chunk(dcpl, RANK, chunk_dims); + dset = H5Dcreate2(file, SRC_DATASET[i], H5T_NATIVE_INT, src_space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + status = H5Sclose(src_space); + status = H5Pclose(dcpl); + status = H5Dclose(dset); + status = H5Fclose(file); } - vfile = H5Fcreate (VFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + vfile = H5Fcreate(VFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ - vspace = H5Screate_simple (RANK, vdsdims, vdsdims_max); + vspace = H5Screate_simple(RANK, vdsdims, vdsdims_max); /* Create dataspaces for the source dataset. */ - src_space = H5Screate_simple (RANK, dims, dims_max); + src_space = H5Screate_simple(RANK, dims, dims_max); /* Create VDS creation property */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Initialize hyperslab values */ - start[0] = 0; - start[1] = 0; - start[2] = 0; - stride[0] = PLANE_STRIDE; /* we will select every fifth plane in VDS */ - stride[1] = 1; - stride[2] = 1; - count[0] = H5S_UNLIMITED; - count[1] = 1; - count[2] = 1; + start[0] = 0; + start[1] = 0; + start[2] = 0; + stride[0] = PLANE_STRIDE; /* we will select every fifth plane in VDS */ + stride[1] = 1; + stride[2] = 1; + count[0] = H5S_UNLIMITED; + count[1] = 1; + count[2] = 1; src_count[0] = H5S_UNLIMITED; src_count[1] = 1; src_count[2] = 1; - block[0] = 1; - block[1] = DIM1; - block[2] = DIM2; + block[0] = 1; + block[1] = DIM1; + block[2] = DIM2; /* * Build the mappings * */ - status = H5Sselect_hyperslab (src_space, H5S_SELECT_SET, start, NULL, src_count, block); - for (i=0; i < PLANE_STRIDE; i++) { - status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block); - status = H5Pset_virtual (dcpl, vspace, SRC_FILE[i], SRC_DATASET[i], src_space); + status = H5Sselect_hyperslab(src_space, H5S_SELECT_SET, start, NULL, src_count, block); + for (i = 0; i < PLANE_STRIDE; i++) { + status = H5Sselect_hyperslab(vspace, H5S_SELECT_SET, start, stride, count, block); + status = H5Pset_virtual(dcpl, vspace, SRC_FILE[i], SRC_DATASET[i], src_space); start[0]++; } H5Sselect_none(vspace); /* Create a virtual dataset */ - vdset = H5Dcreate2 (vfile, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Sclose (vspace); - status = H5Sclose (src_space); - status = H5Pclose (dcpl); + vdset = H5Dcreate2(vfile, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Sclose(vspace); + status = H5Sclose(src_space); + status = H5Pclose(dcpl); /* Let's get space of the VDS and its dimension; we should get 40x10x10 */ - vspace = H5Dget_space (vdset); - H5Sget_simple_extent_dims (vspace, vdsdims_out, vdsdims_max_out); - printf ("VDS dimensions first time \n"); - printf (" Current: "); - for (i=0; i #include -#define FILE "vds-percival.h5" -#define DATASET "VDS-Percival" +#define FILE "vds-percival.h5" +#define DATASET "VDS-Percival" /* later #define VDSDIM0 H5S_UNLIMITED */ -#define VDSDIM0 40 -#define VDSDIM1 10 -#define VDSDIM2 10 +#define VDSDIM0 40 +#define VDSDIM1 10 +#define VDSDIM2 10 /* later #define DIM0 H5S_UNLIMITED */ -#define DIM0 10 -#define DIM1 10 -#define DIM2 10 -#define RANK 3 -#define PLANE_STRIDE 4 - -const char *SRC_FILE[] = { - "a.h5", - "b.h5", - "c.h5", - "d.h5" -}; - -const char *SRC_DATASET[] = { - "A", - "B", - "C", - "D" -}; +#define DIM0 10 +#define DIM1 10 +#define DIM2 10 +#define RANK 3 +#define PLANE_STRIDE 4 + +const char *SRC_FILE[] = {"a.h5", "b.h5", "c.h5", "d.h5"}; + +const char *SRC_DATASET[] = {"A", "B", "C", "D"}; int -main (void) +main(void) { - hid_t file, src_space, vspace, - dset; /* Handles */ - hid_t dcpl; - herr_t status; - hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, - vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, - dims[3] = {DIM0, DIM1, DIM2}, - dims_max[3] = {DIM0, DIM1, DIM2}, - start[3], /* Hyperslab start parameter for VDS */ - stride[3], - count[3], - src_count[3], - block[3]; - hsize_t start_out[3], /* Hyperslab parameter out */ - stride_out[3], - count_out[3], - block_out[3]; + hid_t file, src_space, vspace, dset; /* Handles */ + hid_t dcpl; + herr_t status; + hsize_t vdsdims[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, + dims[3] = {DIM0, DIM1, DIM2}, dims_max[3] = {DIM0, DIM1, DIM2}, + start[3], /* Hyperslab start parameter for VDS */ + stride[3], count[3], src_count[3], block[3]; + hsize_t start_out[3], /* Hyperslab parameter out */ + stride_out[3], count_out[3], block_out[3]; int i, j; - H5D_layout_t layout; /* Storage layout */ - size_t num_map; /* Number of mappings */ - ssize_t len; /* Length of the string; also a return value */ - char *filename; - char *dsetname; - int wdata[DIM0*DIM1*DIM2]; + H5D_layout_t layout; /* Storage layout */ + size_t num_map; /* Number of mappings */ + ssize_t len; /* Length of the string; also a return value */ + char * filename; + char * dsetname; + int wdata[DIM0 * DIM1 * DIM2]; /* * Create source files and datasets. This step is optional. */ - for (i=0; i < PLANE_STRIDE; i++) { + for (i = 0; i < PLANE_STRIDE; i++) { /* * Initialize data for i-th source dataset. */ - for (j = 0; j < DIM0*DIM1*DIM2; j++) wdata[j] = i+1; + for (j = 0; j < DIM0 * DIM1 * DIM2; j++) + wdata[j] = i + 1; /* * Create the source files and datasets. Write data to each dataset and * close all resources. */ - file = H5Fcreate (SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - src_space = H5Screate_simple (RANK, dims, NULL); - dset = H5Dcreate2 (file, SRC_DATASET[i], H5T_NATIVE_INT, src_space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - wdata); - status = H5Sclose (src_space); - status = H5Dclose (dset); - status = H5Fclose (file); + file = H5Fcreate(SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + src_space = H5Screate_simple(RANK, dims, NULL); + dset = H5Dcreate2(file, SRC_DATASET[i], H5T_NATIVE_INT, src_space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); + status = H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + status = H5Sclose(src_space); + status = H5Dclose(dset); + status = H5Fclose(file); } - file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ - vspace = H5Screate_simple (RANK, vdsdims, vdsdims_max); + vspace = H5Screate_simple(RANK, vdsdims, vdsdims_max); /* Create dataspaces for the source dataset. */ - src_space = H5Screate_simple (RANK, dims, dims_max); + src_space = H5Screate_simple(RANK, dims, dims_max); /* Create VDS creation property */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Initialize hyperslab values */ - start[0] = 0; - start[1] = 0; - start[2] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; stride[0] = PLANE_STRIDE; /* we will select every fifth plane in VDS */ stride[1] = 1; stride[2] = 1; -/* later - count[0] = H5S_UNLIMITED; -*/ - count[0] = VDSDIM0/4; + /* later + count[0] = H5S_UNLIMITED; + */ + count[0] = VDSDIM0 / 4; count[1] = 1; count[2] = 1; -/* later - src_count[0] = H5S_UNLIMITED; -*/ + /* later + src_count[0] = H5S_UNLIMITED; + */ src_count[0] = DIM0; src_count[1] = 1; src_count[2] = 1; - block[0] = 1; - block[1] = DIM1; - block[2] = DIM2; + block[0] = 1; + block[1] = DIM1; + block[2] = DIM2; /* * Build the mappings * */ - status = H5Sselect_hyperslab (src_space, H5S_SELECT_SET, start, NULL, src_count, block); - for (i=0; i < PLANE_STRIDE; i++) { - status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block); - status = H5Pset_virtual (dcpl, vspace, SRC_FILE[i], SRC_DATASET[i], src_space); + status = H5Sselect_hyperslab(src_space, H5S_SELECT_SET, start, NULL, src_count, block); + for (i = 0; i < PLANE_STRIDE; i++) { + status = H5Sselect_hyperslab(vspace, H5S_SELECT_SET, start, stride, count, block); + status = H5Pset_virtual(dcpl, vspace, SRC_FILE[i], SRC_DATASET[i], src_space); start[0]++; } H5Sselect_none(vspace); /* Create a virtual dataset */ - dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Sclose (vspace); - status = H5Sclose (src_space); - status = H5Dclose (dset); - status = H5Fclose (file); + dset = H5Dcreate2(file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Sclose(vspace); + status = H5Sclose(src_space); + status = H5Dclose(dset); + status = H5Fclose(file); /* * Now we begin the read section of this example. @@ -172,82 +153,89 @@ main (void) /* * Open file and dataset using the default properties. */ - file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); - dset = H5Dopen2 (file, DATASET, H5P_DEFAULT); + file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + dset = H5Dopen2(file, DATASET, H5P_DEFAULT); /* * Get creation property list and mapping properties. */ - dcpl = H5Dget_create_plist (dset); + dcpl = H5Dget_create_plist(dset); /* * Get storage layout. */ - layout = H5Pget_layout (dcpl); + layout = H5Pget_layout(dcpl); if (H5D_VIRTUAL == layout) printf(" Dataset has a virtual layout \n"); else printf(" Wrong layout found \n"); - /* - * Find number of mappings. - */ - status = H5Pget_virtual_count (dcpl, &num_map); - printf(" Number of mappings is %lu\n", (unsigned long)num_map); - - /* - * Get mapping parameters for each mapping. - */ - for (i = 0; i < (int)num_map; i++) { - printf(" Mapping %d \n", i); - printf(" Selection in the virtual dataset \n"); - /* Get selection in the virttual dataset */ - vspace = H5Pget_virtual_vspace (dcpl, (size_t)i); - if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { - if (H5Sis_regular_hyperslab(vspace)) { - status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out); - printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]); - printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); - printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]); - printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]); - } - } - /* Get source file name */ - len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0); - filename = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1); - printf(" Source filename %s\n", filename); - - /* Get source dataset name */ - len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0); - dsetname = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1); - printf(" Source dataset name %s\n", dsetname); - - /* Get selection in the source dataset */ - printf(" Selection in the source dataset \n"); - src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i); - if (H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) { - if (H5Sis_regular_hyperslab(src_space)) { - status = H5Sget_regular_hyperslab (src_space, start_out, stride_out, count_out, block_out); - printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]); - printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); - printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]); - printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]); - } - } - H5Sclose(vspace); - H5Sclose(src_space); - free(filename); - free(dsetname); - } + /* + * Find number of mappings. + */ + status = H5Pget_virtual_count(dcpl, &num_map); + printf(" Number of mappings is %lu\n", (unsigned long)num_map); + + /* + * Get mapping parameters for each mapping. + */ + for (i = 0; i < (int)num_map; i++) { + printf(" Mapping %d \n", i); + printf(" Selection in the virtual dataset \n"); + /* Get selection in the virttual dataset */ + vspace = H5Pget_virtual_vspace(dcpl, (size_t)i); + if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { + if (H5Sis_regular_hyperslab(vspace)) { + status = H5Sget_regular_hyperslab(vspace, start_out, stride_out, count_out, block_out); + printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], + (unsigned long long)start_out[1], (unsigned long long)start_out[2]); + printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], + (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); + printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], + (unsigned long long)count_out[1], (unsigned long long)count_out[2]); + printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], + (unsigned long long)block_out[1], (unsigned long long)block_out[2]); + } + } + /* Get source file name */ + len = H5Pget_virtual_filename(dcpl, (size_t)i, NULL, 0); + filename = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_filename(dcpl, (size_t)i, filename, len + 1); + printf(" Source filename %s\n", filename); + + /* Get source dataset name */ + len = H5Pget_virtual_dsetname(dcpl, (size_t)i, NULL, 0); + dsetname = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_dsetname(dcpl, (size_t)i, dsetname, len + 1); + printf(" Source dataset name %s\n", dsetname); + + /* Get selection in the source dataset */ + printf(" Selection in the source dataset \n"); + src_space = H5Pget_virtual_srcspace(dcpl, (size_t)i); + if (H5Sget_select_type(src_space) == H5S_SEL_HYPERSLABS) { + if (H5Sis_regular_hyperslab(src_space)) { + status = H5Sget_regular_hyperslab(src_space, start_out, stride_out, count_out, block_out); + printf(" start = [%llu, %llu, %llu] \n", (unsigned long long)start_out[0], + (unsigned long long)start_out[1], (unsigned long long)start_out[2]); + printf(" stride = [%llu, %llu, %llu] \n", (unsigned long long)stride_out[0], + (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); + printf(" count = [%llu, %llu, %llu] \n", (unsigned long long)count_out[0], + (unsigned long long)count_out[1], (unsigned long long)count_out[2]); + printf(" block = [%llu, %llu, %llu] \n", (unsigned long long)block_out[0], + (unsigned long long)block_out[1], (unsigned long long)block_out[2]); + } + } + H5Sclose(vspace); + H5Sclose(src_space); + free(filename); + free(dsetname); + } /* * Close and release resources. */ - status = H5Pclose (dcpl); - status = H5Dclose (dset); - status = H5Fclose (file); + status = H5Pclose(dcpl); + status = H5Dclose(dset); + status = H5Fclose(file); return 0; } - diff --git a/examples/h5_vds-simpleIO.c b/examples/h5_vds-simpleIO.c index 5fd5c52..f5d8901 100644 --- a/examples/h5_vds-simpleIO.c +++ b/examples/h5_vds-simpleIO.c @@ -27,61 +27,59 @@ #include #include -#define FILE "vds-simpleIO.h5" -#define DATASET "VDS" -#define DIM1 6 -#define DIM0 4 -#define RANK 2 - -#define SRC_FILE "a.h5" -#define SRC_DATASET "/A" +#define FILE "vds-simpleIO.h5" +#define DATASET "VDS" +#define DIM1 6 +#define DIM0 4 +#define RANK 2 +#define SRC_FILE "a.h5" +#define SRC_DATASET "/A" int -main (void) +main(void) { - hid_t file, space, src_space, vspace, dset; /* Handles */ - hid_t dcpl; - herr_t status; - hsize_t vdsdims[2] = {DIM0, DIM1}, /* Virtual dataset dimension */ - dims[2] = {DIM0, DIM1}; /* Source dataset dimensions */ - int wdata[DIM0][DIM1], /* Write buffer for source dataset */ - rdata[DIM0][DIM1], /* Read buffer for virtual dataset */ - i, j; - H5D_layout_t layout; /* Storage layout */ - size_t num_map; /* Number of mappings */ - ssize_t len; /* Length of the string; also a return value */ - char *filename; - char *dsetname; + hid_t file, space, src_space, vspace, dset; /* Handles */ + hid_t dcpl; + herr_t status; + hsize_t vdsdims[2] = {DIM0, DIM1}, /* Virtual dataset dimension */ + dims[2] = {DIM0, DIM1}; /* Source dataset dimensions */ + int wdata[DIM0][DIM1], /* Write buffer for source dataset */ + rdata[DIM0][DIM1], /* Read buffer for virtual dataset */ + i, j; + H5D_layout_t layout; /* Storage layout */ + size_t num_map; /* Number of mappings */ + ssize_t len; /* Length of the string; also a return value */ + char * filename; + char * dsetname; /* * Initialize data. */ - for (i = 0; i < DIM0; i++) - for (j = 0; j < DIM1; j++) wdata[i][j] = i+1; - - /* - * Create the source file and the dataset. Write data to the source dataset - * and close all resources. - */ - - file = H5Fcreate (SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - space = H5Screate_simple (RANK, dims, NULL); - dset = H5Dcreate2 (file, SRC_DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - wdata[0]); - status = H5Sclose (space); - status = H5Dclose (dset); - status = H5Fclose (file); + for (i = 0; i < DIM0; i++) + for (j = 0; j < DIM1; j++) + wdata[i][j] = i + 1; + + /* + * Create the source file and the dataset. Write data to the source dataset + * and close all resources. + */ + + file = H5Fcreate(SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(RANK, dims, NULL); + dset = H5Dcreate2(file, SRC_DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + status = H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata[0]); + status = H5Sclose(space); + status = H5Dclose(dset); + status = H5Fclose(file); /* Create file in which virtual dataset will be stored. */ - file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ - vspace = H5Screate_simple (RANK, vdsdims, NULL); + vspace = H5Screate_simple(RANK, vdsdims, NULL); /* Set VDS creation property. */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); /* * Build the mappings. @@ -89,16 +87,15 @@ main (void) * In the virtual dataset we select the first, the second and the third rows * and map each row to the data in the corresponding source dataset. */ - src_space = H5Screate_simple (RANK, dims, NULL); - status = H5Pset_virtual (dcpl, vspace, SRC_FILE, SRC_DATASET, src_space); + src_space = H5Screate_simple(RANK, dims, NULL); + status = H5Pset_virtual(dcpl, vspace, SRC_FILE, SRC_DATASET, src_space); /* Create a virtual dataset. */ - dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Sclose (vspace); - status = H5Sclose (src_space); - status = H5Dclose (dset); - status = H5Fclose (file); + dset = H5Dcreate2(file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Sclose(vspace); + status = H5Sclose(src_space); + status = H5Dclose(dset); + status = H5Fclose(file); /* * Now we begin the read section of this example. @@ -107,60 +104,60 @@ main (void) /* * Open the file and virtual dataset. */ - file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); - dset = H5Dopen2 (file, DATASET, H5P_DEFAULT); + file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + dset = H5Dopen2(file, DATASET, H5P_DEFAULT); /* * Get creation property list and mapping properties. */ - dcpl = H5Dget_create_plist (dset); + dcpl = H5Dget_create_plist(dset); /* * Get storage layout. */ - layout = H5Pget_layout (dcpl); + layout = H5Pget_layout(dcpl); if (H5D_VIRTUAL == layout) printf(" Dataset has a virtual layout \n"); else printf(" Wrong layout found \n"); - /* - * Find the number of mappings. - */ - status = H5Pget_virtual_count (dcpl, &num_map); - printf(" Number of mappings is %lu\n", (unsigned long)num_map); + /* + * Find the number of mappings. + */ + status = H5Pget_virtual_count(dcpl, &num_map); + printf(" Number of mappings is %lu\n", (unsigned long)num_map); - /* - * Get mapping parameters for each mapping. - */ + /* + * Get mapping parameters for each mapping. + */ for (i = 0; i < (int)num_map; i++) { printf(" Mapping %d \n", i); printf(" Selection in the virtual dataset "); /* Get selection in the virttual dataset */ - vspace = H5Pget_virtual_vspace (dcpl, (size_t)i); + vspace = H5Pget_virtual_vspace(dcpl, (size_t)i); /* Make sure it is ALL selection and then print selection. */ - if(H5Sget_select_type(vspace) == H5S_SEL_ALL) { - printf("Selection is H5S_ALL \n"); + if (H5Sget_select_type(vspace) == H5S_SEL_ALL) { + printf("Selection is H5S_ALL \n"); } /* Get source file name. */ - len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0); - filename = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1); + len = H5Pget_virtual_filename(dcpl, (size_t)i, NULL, 0); + filename = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_filename(dcpl, (size_t)i, filename, len + 1); printf(" Source filename %s\n", filename); /* Get source dataset name. */ - len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0); - dsetname = (char *)malloc((size_t)len*sizeof(char)+1); - H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1); + len = H5Pget_virtual_dsetname(dcpl, (size_t)i, NULL, 0); + dsetname = (char *)malloc((size_t)len * sizeof(char) + 1); + H5Pget_virtual_dsetname(dcpl, (size_t)i, dsetname, len + 1); printf(" Source dataset name %s\n", dsetname); /* Get selection in the source dataset. */ printf(" Selection in the source dataset "); - src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i); + src_space = H5Pget_virtual_srcspace(dcpl, (size_t)i); /* Make sure it is ALL selection and then print selection. */ - if(H5Sget_select_type(src_space) == H5S_SEL_ALL) { - printf("Selection is H5S_ALL \n"); + if (H5Sget_select_type(src_space) == H5S_SEL_ALL) { + printf("Selection is H5S_ALL \n"); } H5Sclose(vspace); H5Sclose(src_space); @@ -170,26 +167,24 @@ main (void) /* * Read the data using the default properties. */ - status = H5Dread (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - rdata[0]); + status = H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata[0]); /* * Output the data to the screen. */ - printf (" VDS Data:\n"); - for (i=0; i #include -#define FILE "vds.h5" -#define DATASET "VDS" -#define VDSDIM1 6 -#define VDSDIM0 4 -#define DIM0 6 -#define RANK1 1 -#define RANK2 2 - -const char *SRC_FILE[] = { - "a.h5", - "b.h5", - "c.h5" -}; - -const char *SRC_DATASET[] = { - "A", - "B", - "C" -}; +#define FILE "vds.h5" +#define DATASET "VDS" +#define VDSDIM1 6 +#define VDSDIM0 4 +#define DIM0 6 +#define RANK1 1 +#define RANK2 2 + +const char *SRC_FILE[] = {"a.h5", "b.h5", "c.h5"}; + +const char *SRC_DATASET[] = {"A", "B", "C"}; int -main (void) +main(void) { - hid_t file, space, src_space, vspace, dset; /* Handles */ - hid_t dcpl; - herr_t status; - hsize_t vdsdims[2] = {VDSDIM0, VDSDIM1}, /* Virtual datasets dimension */ - dims[1] = {DIM0}, /* Source datasets dimensions */ - start[2], /* Hyperslab parameters */ - stride[2], - count[2], - block[2]; - hsize_t start_out[2], - stride_out[2], - count_out[2], - block_out[2]; - int wdata[DIM0], /* Write buffer for source dataset */ - rdata[VDSDIM0][VDSDIM1], /* Read buffer for virtual dataset */ - i, j, k, l; - int fill_value = -1; /* Fill value for VDS */ - H5D_layout_t layout; /* Storage layout */ - size_t num_map; /* Number of mappings */ - ssize_t len; /* Length of the string; also a return value */ - char *filename; - char *dsetname; + hid_t file, space, src_space, vspace, dset; /* Handles */ + hid_t dcpl; + herr_t status; + hsize_t vdsdims[2] = {VDSDIM0, VDSDIM1}, /* Virtual datasets dimension */ + dims[1] = {DIM0}, /* Source datasets dimensions */ + start[2], /* Hyperslab parameters */ + stride[2], count[2], block[2]; + hsize_t start_out[2], stride_out[2], count_out[2], block_out[2]; + int wdata[DIM0], /* Write buffer for source dataset */ + rdata[VDSDIM0][VDSDIM1], /* Read buffer for virtual dataset */ + i, j, k, l; + int fill_value = -1; /* Fill value for VDS */ + H5D_layout_t layout; /* Storage layout */ + size_t num_map; /* Number of mappings */ + ssize_t len; /* Length of the string; also a return value */ + char * filename; + char * dsetname; hsize_t nblocks; - hsize_t *buf; /* Buffer to hold hyperslab coordinates */ + hsize_t * buf; /* Buffer to hold hyperslab coordinates */ /* * Create source files and datasets. This step is optional. */ - for (i=0; i < 3; i++) { + for (i = 0; i < 3; i++) { /* * Initialize data for i-th source dataset. */ - for (j = 0; j < DIM0; j++) wdata[j] = i+1; + for (j = 0; j < DIM0; j++) + wdata[j] = i + 1; /* * Create the source files and datasets. Write data to each dataset and * close all resources. */ - file = H5Fcreate (SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - space = H5Screate_simple (RANK1, dims, NULL); - dset = H5Dcreate2 (file, SRC_DATASET[i], H5T_NATIVE_INT, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - wdata); - status = H5Sclose (space); - status = H5Dclose (dset); - status = H5Fclose (file); + file = H5Fcreate(SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(RANK1, dims, NULL); + dset = H5Dcreate2(file, SRC_DATASET[i], H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + status = H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + status = H5Sclose(space); + status = H5Dclose(dset); + status = H5Fclose(file); } /* Create file in which virtual dataset will be stored. */ - file = H5Fcreate (FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ - space = H5Screate_simple (RANK2, vdsdims, NULL); + space = H5Screate_simple(RANK2, vdsdims, NULL); /* Set VDS creation property. */ - dcpl = H5Pcreate (H5P_DATASET_CREATE); - status = H5Pset_fill_value (dcpl, H5T_NATIVE_INT, &fill_value); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + status = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill_value); /* Initialize hyperslab values. */ start[0] = 0; @@ -132,21 +118,20 @@ main (void) * In the virtual dataset we select the first, the second and the third rows * and map each row to the data in the corresponding source dataset. */ - src_space = H5Screate_simple (RANK1, dims, NULL); + src_space = H5Screate_simple(RANK1, dims, NULL); for (i = 0; i < 3; i++) { start[0] = (hsize_t)i; /* Select i-th row in the virtual dataset; selection in the source datasets is the same. */ - status = H5Sselect_hyperslab (space, H5S_SELECT_SET, start, NULL, count, block); - status = H5Pset_virtual (dcpl, space, SRC_FILE[i], SRC_DATASET[i], src_space); + status = H5Sselect_hyperslab(space, H5S_SELECT_SET, start, NULL, count, block); + status = H5Pset_virtual(dcpl, space, SRC_FILE[i], SRC_DATASET[i], src_space); } /* Create a virtual dataset. */ - dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, - dcpl, H5P_DEFAULT); - status = H5Sclose (space); - status = H5Sclose (src_space); - status = H5Dclose (dset); - status = H5Fclose (file); + dset = H5Dcreate2(file, DATASET, H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + status = H5Sclose(space); + status = H5Sclose(src_space); + status = H5Dclose(dset); + status = H5Fclose(file); /* * Now we begin the read section of this example. @@ -155,80 +140,84 @@ main (void) /* * Open the file and virtual dataset. */ - file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); - dset = H5Dopen2 (file, DATASET, H5P_DEFAULT); + file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + dset = H5Dopen2(file, DATASET, H5P_DEFAULT); /* * Get creation property list and mapping properties. */ - dcpl = H5Dget_create_plist (dset); + dcpl = H5Dget_create_plist(dset); /* * Get storage layout. */ - layout = H5Pget_layout (dcpl); + layout = H5Pget_layout(dcpl); if (H5D_VIRTUAL == layout) printf(" Dataset has a virtual layout \n"); else printf(" Wrong layout found \n"); - /* - * Find the number of mappings. - */ - status = H5Pget_virtual_count (dcpl, &num_map); - printf(" Number of mappings is %lu\n", (unsigned long)num_map); + /* + * Find the number of mappings. + */ + status = H5Pget_virtual_count(dcpl, &num_map); + printf(" Number of mappings is %lu\n", (unsigned long)num_map); - /* - * Get mapping parameters for each mapping. - */ + /* + * Get mapping parameters for each mapping. + */ for (i = 0; i < (int)num_map; i++) { printf(" Mapping %d \n", i); printf(" Selection in the virtual dataset "); /* Get selection in the virttual dataset */ - vspace = H5Pget_virtual_vspace (dcpl, (size_t)i); + vspace = H5Pget_virtual_vspace(dcpl, (size_t)i); /* Make sure that this is a hyperslab selection and then print information. */ if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { - nblocks = H5Sget_select_hyper_nblocks (vspace); - buf = (hsize_t *)malloc(sizeof(hsize_t)*2*RANK2*nblocks); - status = H5Sget_select_hyper_blocklist (vspace, (hsize_t)0, nblocks, buf); - for (l=0; ltv_sec == (usp)->tv_sec) ? \ - ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ - ((tsp)->tv_sec cmp (usp)->tv_sec)) -#define timespecadd(tsp, usp, vsp) \ - do { \ - (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ - (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ - if ((vsp)->tv_nsec >= 1000000000L) { \ - (vsp)->tv_sec++; \ - (vsp)->tv_nsec -= 1000000000L; \ - } \ - } while (/* CONSTCOND */ 0) -#define timespecsub(tsp, usp, vsp) \ - do { \ - (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ - (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ - if ((vsp)->tv_nsec < 0) { \ - (vsp)->tv_sec--; \ - (vsp)->tv_nsec += 1000000000L; \ - } \ +#define timespeccmp(tsp, usp, cmp) \ + (((tsp)->tv_sec == (usp)->tv_sec) ? ((tsp)->tv_nsec cmp(usp)->tv_nsec) : ((tsp)->tv_sec cmp(usp)->tv_sec)) +#define timespecadd(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ + if ((vsp)->tv_nsec >= 1000000000L) { \ + (vsp)->tv_sec++; \ + (vsp)->tv_nsec -= 1000000000L; \ + } \ + } while (/* CONSTCOND */ 0) +#define timespecsub(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ + if ((vsp)->tv_nsec < 0) { \ + (vsp)->tv_sec--; \ + (vsp)->tv_nsec += 1000000000L; \ + } \ } while (/* CONSTCOND */ 0) #define timespec2ns(x) (((uint64_t)(x)->tv_sec) * 1000000000L + (x)->tv_nsec) diff --git a/examples/ph5example.c b/examples/ph5example.c index d718479..06c8919 100644 --- a/examples/ph5example.c +++ b/examples/ph5example.c @@ -46,69 +46,73 @@ /* Define some handy debugging shorthands, routines, ... */ /* debugging tools */ -#define MESG(x)\ - if (verbose) printf("%s\n", x);\ - -#define MPI_BANNER(mesg)\ - {printf("--------------------------------\n");\ - printf("Proc %d: ", mpi_rank); \ - printf("*** %s\n", mesg);\ - printf("--------------------------------\n");} +#define MESG(x) \ + if (verbose) \ + printf("%s\n", x); + +#define MPI_BANNER(mesg) \ + { \ + printf("--------------------------------\n"); \ + printf("Proc %d: ", mpi_rank); \ + printf("*** %s\n", mesg); \ + printf("--------------------------------\n"); \ + } -#define SYNC(comm)\ - {MPI_BANNER("doing a SYNC"); MPI_Barrier(comm); MPI_BANNER("SYNC DONE");} +#define SYNC(comm) \ + { \ + MPI_BANNER("doing a SYNC"); \ + MPI_Barrier(comm); \ + MPI_BANNER("SYNC DONE"); \ + } /* End of Define some handy debugging shorthands, routines, ... */ /* Constants definitions */ /* 24 is a multiple of 2, 3, 4, 6, 8, 12. Neat for parallel tests. */ -#define SPACE1_DIM1 24 -#define SPACE1_DIM2 24 -#define SPACE1_RANK 2 -#define DATASETNAME1 "Data1" -#define DATASETNAME2 "Data2" -#define DATASETNAME3 "Data3" +#define SPACE1_DIM1 24 +#define SPACE1_DIM2 24 +#define SPACE1_RANK 2 +#define DATASETNAME1 "Data1" +#define DATASETNAME2 "Data2" +#define DATASETNAME3 "Data3" /* hyperslab layout styles */ -#define BYROW 1 /* divide into slabs of rows */ -#define BYCOL 2 /* divide into blocks of columns */ - -#define PARAPREFIX "HDF5_PARAPREFIX" /* file prefix environment variable name */ +#define BYROW 1 /* divide into slabs of rows */ +#define BYCOL 2 /* divide into blocks of columns */ +#define PARAPREFIX "HDF5_PARAPREFIX" /* file prefix environment variable name */ /* dataset data type. Int's can be easily octo dumped. */ typedef int DATATYPE; /* global variables */ -int nerrors = 0; /* errors count */ +int nerrors = 0; /* errors count */ #ifndef PATH_MAX -#define PATH_MAX 512 -#endif /* !PATH_MAX */ -char testfiles[2][PATH_MAX]; +#define PATH_MAX 512 +#endif /* !PATH_MAX */ +char testfiles[2][PATH_MAX]; - -int mpi_size, mpi_rank; /* mpi variables */ +int mpi_size, mpi_rank; /* mpi variables */ /* option flags */ -int verbose = 0; /* verbose, default as no. */ -int doread=1; /* read test */ -int dowrite=1; /* write test */ -int docleanup=1; /* cleanup */ +int verbose = 0; /* verbose, default as no. */ +int doread = 1; /* read test */ +int dowrite = 1; /* write test */ +int docleanup = 1; /* cleanup */ /* Prototypes */ void slab_set(hsize_t start[], hsize_t count[], hsize_t stride[], int mode); -void dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset); -void dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset); -int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original); +void dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset); +void dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset); +int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original); void phdf5writeInd(char *filename); void phdf5readInd(char *filename); void phdf5writeAll(char *filename); void phdf5readAll(char *filename); void test_split_comm_access(char filenames[][PATH_MAX]); -int parse_options(int argc, char **argv); +int parse_options(int argc, char **argv); void usage(void); -int mkfilenames(char *prefix); +int mkfilenames(char *prefix); void cleanup(void); - /* * Setup the dimensions of the hyperslab. * Two modes--by rows or by columns. @@ -117,113 +121,110 @@ void cleanup(void); void slab_set(hsize_t start[], hsize_t count[], hsize_t stride[], int mode) { - switch (mode){ - case BYROW: - /* Each process takes a slabs of rows. */ - stride[0] = 1; - stride[1] = 1; - count[0] = SPACE1_DIM1/mpi_size; - count[1] = SPACE1_DIM2; - start[0] = mpi_rank*count[0]; - start[1] = 0; - break; - case BYCOL: - /* Each process takes a block of columns. */ - stride[0] = 1; - stride[1] = 1; - count[0] = SPACE1_DIM1; - count[1] = SPACE1_DIM2/mpi_size; - start[0] = 0; - start[1] = mpi_rank*count[1]; - break; - default: - /* Unknown mode. Set it to cover the whole dataset. */ - printf("unknown slab_set mode (%d)\n", mode); - stride[0] = 1; - stride[1] = 1; - count[0] = SPACE1_DIM1; - count[1] = SPACE1_DIM2; - start[0] = 0; - start[1] = 0; - break; + switch (mode) { + case BYROW: + /* Each process takes a slabs of rows. */ + stride[0] = 1; + stride[1] = 1; + count[0] = SPACE1_DIM1 / mpi_size; + count[1] = SPACE1_DIM2; + start[0] = mpi_rank * count[0]; + start[1] = 0; + break; + case BYCOL: + /* Each process takes a block of columns. */ + stride[0] = 1; + stride[1] = 1; + count[0] = SPACE1_DIM1; + count[1] = SPACE1_DIM2 / mpi_size; + start[0] = 0; + start[1] = mpi_rank * count[1]; + break; + default: + /* Unknown mode. Set it to cover the whole dataset. */ + printf("unknown slab_set mode (%d)\n", mode); + stride[0] = 1; + stride[1] = 1; + count[0] = SPACE1_DIM1; + count[1] = SPACE1_DIM2; + start[0] = 0; + start[1] = 0; + break; } } - /* * Fill the dataset with trivial data for testing. * Assume dimension rank is 2 and data is stored contiguous. */ void -dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset) +dataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset) { DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* put some trivial data in the data_array */ - for (i=0; i < count[0]; i++){ - for (j=0; j < count[1]; j++){ - *dataptr++ = (i*stride[0]+start[0])*100 + (j*stride[1]+start[1]+1); - } + for (i = 0; i < count[0]; i++) { + for (j = 0; j < count[1]; j++) { + *dataptr++ = (i * stride[0] + start[0]) * 100 + (j * stride[1] + start[1] + 1); + } } } - /* * Print the content of the dataset. */ -void dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE * dataset) +void +dataset_print(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset) { DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* print the slab read */ - for (i=0; i < count[0]; i++){ - printf("Row %lu: ", (unsigned long)(i*stride[0]+start[0])); - for (j=0; j < count[1]; j++){ - printf("%03d ", *dataptr++); - } - printf("\n"); + for (i = 0; i < count[0]; i++) { + printf("Row %lu: ", (unsigned long)(i * stride[0] + start[0])); + for (j = 0; j < count[1]; j++) { + printf("%03d ", *dataptr++); + } + printf("\n"); } } - /* * Print the content of the dataset. */ -int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original) +int +dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *dataset, DATATYPE *original) { -#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */ +#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */ hsize_t i, j; - int nerr; + int nerr; /* print it if verbose */ if (verbose) - dataset_print(start, count, stride, dataset); + dataset_print(start, count, stride, dataset); nerr = 0; - for (i=0; i < count[0]; i++){ - for (j=0; j < count[1]; j++){ - if (*dataset++ != *original++){ - nerr++; - if (nerr <= MAX_ERR_REPORT){ - printf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n", - (unsigned long)i, (unsigned long)j, - (unsigned long)(i*stride[0]+start[0]), (unsigned long)(j*stride[1]+start[1]), - *(dataset-1), *(original-1)); - } - } - } + for (i = 0; i < count[0]; i++) { + for (j = 0; j < count[1]; j++) { + if (*dataset++ != *original++) { + nerr++; + if (nerr <= MAX_ERR_REPORT) { + printf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n", + (unsigned long)i, (unsigned long)j, (unsigned long)(i * stride[0] + start[0]), + (unsigned long)(j * stride[1] + start[1]), *(dataset - 1), *(original - 1)); + } + } + } } if (nerr > MAX_ERR_REPORT) - printf("[more errors ...]\n"); + printf("[more errors ...]\n"); if (nerr) - printf("%d errors found in dataset_vrfy\n", nerr); - return(nerr); + printf("%d errors found in dataset_vrfy\n", nerr); + return (nerr); } - /* * Example of using the parallel HDF5 library to create two datasets * in one HDF5 files with parallel MPIO access support. @@ -235,32 +236,31 @@ int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], DATATYPE *d void phdf5writeInd(char *filename) { - hid_t fid1; /* HDF5 file IDs */ - hid_t acc_tpl1; /* File access templates */ - hid_t sid1; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - hsize_t dims1[SPACE1_RANK] = - {SPACE1_DIM1,SPACE1_DIM2}; /* dataspace dim sizes */ - DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ + hid_t fid1; /* HDF5 file IDs */ + hid_t acc_tpl1; /* File access templates */ + hid_t sid1; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + hsize_t dims1[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; /* dataspace dim sizes */ + DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ - hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ - hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ + hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ + hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; if (verbose) - printf("Independent write test on file %s\n", filename); + printf("Independent write test on file %s\n", filename); /* ------------------- * START AN HDF5 FILE * -------------------*/ /* setup file access template with parallel IO access. */ - acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS); + acc_tpl1 = H5Pcreate(H5P_FILE_ACCESS); assert(acc_tpl1 != FAIL); MESG("H5Pcreate access succeed"); /* set Parallel access with communicator */ @@ -277,70 +277,60 @@ phdf5writeInd(char *filename) ret = H5Pclose(acc_tpl1); assert(ret != FAIL); - /* -------------------------- * Define the dimensions of the overall datasets * and the slabs local to the MPI process. * ------------------------- */ /* setup dimensionality object */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - assert (sid1 != FAIL); + assert(sid1 != FAIL); MESG("H5Screate_simple succeed"); - /* create a dataset collectively */ - dataset1 = H5Dcreate2(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset1 = H5Dcreate2(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); assert(dataset1 != FAIL); MESG("H5Dcreate2 succeed"); /* create another dataset collectively */ - dataset2 = H5Dcreate2(fid1, DATASETNAME2, H5T_NATIVE_INT, sid1, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset2 = H5Dcreate2(fid1, DATASETNAME2, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); assert(dataset2 != FAIL); MESG("H5Dcreate2 succeed"); - - /* set up dimensions of the slab this process accesses */ - start[0] = mpi_rank*SPACE1_DIM1/mpi_size; - start[1] = 0; - count[0] = SPACE1_DIM1/mpi_size; - count[1] = SPACE1_DIM2; + start[0] = mpi_rank * SPACE1_DIM1 / mpi_size; + start[1] = 0; + count[0] = SPACE1_DIM1 / mpi_size; + count[1] = SPACE1_DIM2; stride[0] = 1; - stride[1] =1; -if (verbose) - printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], - (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)(count[0]*count[1])); + stride[1] = 1; + if (verbose) + printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0], + (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], + (unsigned long)(count[0] * count[1])); /* put some trivial data in the data_array */ dataset_fill(start, count, stride, &data_array1[0][0]); MESG("data_array initialized"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); assert(file_dataspace != FAIL); MESG("H5Dget_space succeed"); - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, - count, NULL); + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL); assert(ret != FAIL); MESG("H5Sset_hyperslab succeed"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL); - assert (mem_dataspace != FAIL); + mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL); + assert(mem_dataspace != FAIL); /* write data independently */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); assert(ret != FAIL); MESG("H5Dwrite succeed"); /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); assert(ret != FAIL); MESG("H5Dwrite succeed"); @@ -348,10 +338,10 @@ if (verbose) H5Sclose(file_dataspace); /* close dataset collectively */ - ret=H5Dclose(dataset1); + ret = H5Dclose(dataset1); assert(ret != FAIL); MESG("H5Dclose1 succeed"); - ret=H5Dclose(dataset2); + ret = H5Dclose(dataset2); assert(ret != FAIL); MESG("H5Dclose2 succeed"); @@ -366,39 +356,38 @@ if (verbose) void phdf5readInd(char *filename) { - hid_t fid1; /* HDF5 file IDs */ - hid_t acc_tpl1; /* File access templates */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ - DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */ + hid_t fid1; /* HDF5 file IDs */ + hid_t acc_tpl1; /* File access templates */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ + DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */ - hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ - hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ + hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ + hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; if (verbose) - printf("Independent read test on file %s\n", filename); + printf("Independent read test on file %s\n", filename); /* setup file access template */ - acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS); + acc_tpl1 = H5Pcreate(H5P_FILE_ACCESS); assert(acc_tpl1 != FAIL); /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(acc_tpl1, comm, info); assert(ret != FAIL); - /* open the file collectively */ - fid1=H5Fopen(filename,H5F_ACC_RDWR,acc_tpl1); + fid1 = H5Fopen(filename, H5F_ACC_RDWR, acc_tpl1); assert(fid1 != FAIL); /* Release file-access template */ - ret=H5Pclose(acc_tpl1); + ret = H5Pclose(acc_tpl1); assert(ret != FAIL); /* open the dataset1 collectively */ @@ -409,37 +398,33 @@ phdf5readInd(char *filename) dataset2 = H5Dopen2(fid1, DATASETNAME1, H5P_DEFAULT); assert(dataset2 != FAIL); - /* set up dimensions of the slab this process accesses */ - start[0] = mpi_rank*SPACE1_DIM1/mpi_size; - start[1] = 0; - count[0] = SPACE1_DIM1/mpi_size; - count[1] = SPACE1_DIM2; + start[0] = mpi_rank * SPACE1_DIM1 / mpi_size; + start[1] = 0; + count[0] = SPACE1_DIM1 / mpi_size; + count[1] = SPACE1_DIM2; stride[0] = 1; - stride[1] =1; -if (verbose) - printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], - (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)(count[0]*count[1])); + stride[1] = 1; + if (verbose) + printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0], + (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], + (unsigned long)(count[0] * count[1])); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); assert(file_dataspace != FAIL); - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, - count, NULL); + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL); assert(ret != FAIL); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL); - assert (mem_dataspace != FAIL); + mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL); + assert(mem_dataspace != FAIL); /* fill dataset with test data */ dataset_fill(start, count, stride, &data_origin1[0][0]); /* read data independently */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); assert(ret != FAIL); /* verify the read data with original expected data */ @@ -447,8 +432,7 @@ if (verbose) assert(ret != FAIL); /* read data independently */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); assert(ret != FAIL); /* verify the read data with original expected data */ @@ -456,9 +440,9 @@ if (verbose) assert(ret == 0); /* close dataset collectively */ - ret=H5Dclose(dataset1); + ret = H5Dclose(dataset1); assert(ret != FAIL); - ret=H5Dclose(dataset2); + ret = H5Dclose(dataset2); assert(ret != FAIL); /* release all IDs created */ @@ -468,7 +452,6 @@ if (verbose) H5Fclose(fid1); } - /* * Example of using the parallel HDF5 library to create two datasets * in one HDF5 file with collective parallel access support. @@ -481,33 +464,32 @@ if (verbose) void phdf5writeAll(char *filename) { - hid_t fid1; /* HDF5 file IDs */ - hid_t acc_tpl1; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t sid1; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - hsize_t dims1[SPACE1_RANK] = - {SPACE1_DIM1,SPACE1_DIM2}; /* dataspace dim sizes */ - DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ - - hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ - hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ - - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 file IDs */ + hid_t acc_tpl1; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t sid1; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + hsize_t dims1[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; /* dataspace dim sizes */ + DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ + + hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ + hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ + + herr_t ret; /* Generic return value */ MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; if (verbose) - printf("Collective write test on file %s\n", filename); + printf("Collective write test on file %s\n", filename); /* ------------------- * START AN HDF5 FILE * -------------------*/ /* setup file access template with parallel IO access. */ - acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS); + acc_tpl1 = H5Pcreate(H5P_FILE_ACCESS); assert(acc_tpl1 != FAIL); MESG("H5Pcreate access succeed"); /* set Parallel access with communicator */ @@ -516,25 +498,23 @@ phdf5writeAll(char *filename) MESG("H5Pset_fapl_mpio succeed"); /* create the file collectively */ - fid1=H5Fcreate(filename,H5F_ACC_TRUNC,H5P_DEFAULT,acc_tpl1); + fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl1); assert(fid1 != FAIL); MESG("H5Fcreate succeed"); /* Release file-access template */ - ret=H5Pclose(acc_tpl1); + ret = H5Pclose(acc_tpl1); assert(ret != FAIL); - /* -------------------------- * Define the dimensions of the overall datasets * and create the dataset * ------------------------- */ /* setup dimensionality object */ - sid1 = H5Screate_simple (SPACE1_RANK, dims1, NULL); - assert (sid1 != FAIL); + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + assert(sid1 != FAIL); MESG("H5Screate_simple succeed"); - /* create a dataset collectively */ dataset1 = H5Dcreate2(fid1, DATASETNAME1, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); assert(dataset1 != FAIL); @@ -551,43 +531,40 @@ phdf5writeAll(char *filename) /* Dataset1: each process takes a block of rows. */ slab_set(start, count, stride, BYROW); -if (verbose) - printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], - (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)(count[0]*count[1])); + if (verbose) + printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0], + (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], + (unsigned long)(count[0] * count[1])); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); assert(file_dataspace != FAIL); MESG("H5Dget_space succeed"); - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, - count, NULL); + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL); assert(ret != FAIL); MESG("H5Sset_hyperslab succeed"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL); - assert (mem_dataspace != FAIL); + mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL); + assert(mem_dataspace != FAIL); /* fill the local slab with some trivial data */ dataset_fill(start, count, stride, &data_array1[0][0]); MESG("data_array initialized"); - if (verbose){ - MESG("data_array created"); - dataset_print(start, count, stride, &data_array1[0][0]); + if (verbose) { + MESG("data_array created"); + dataset_print(start, count, stride, &data_array1[0][0]); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); assert(xfer_plist != FAIL); - ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); assert(ret != FAIL); MESG("H5Pcreate xfer succeed"); /* write data collectively */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); assert(ret != FAIL); MESG("H5Dwrite succeed"); @@ -600,51 +577,48 @@ if (verbose) /* Dataset2: each process takes a block of columns. */ slab_set(start, count, stride, BYCOL); -if (verbose) - printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], - (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)(count[0]*count[1])); + if (verbose) + printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0], + (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], + (unsigned long)(count[0] * count[1])); /* put some trivial data in the data_array */ dataset_fill(start, count, stride, &data_array1[0][0]); MESG("data_array initialized"); - if (verbose){ - MESG("data_array created"); - dataset_print(start, count, stride, &data_array1[0][0]); + if (verbose) { + MESG("data_array created"); + dataset_print(start, count, stride, &data_array1[0][0]); } /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); assert(file_dataspace != FAIL); MESG("H5Dget_space succeed"); - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, - count, NULL); + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL); assert(ret != FAIL); MESG("H5Sset_hyperslab succeed"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL); - assert (mem_dataspace != FAIL); + mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL); + assert(mem_dataspace != FAIL); /* fill the local slab with some trivial data */ dataset_fill(start, count, stride, &data_array1[0][0]); MESG("data_array initialized"); - if (verbose){ - MESG("data_array created"); - dataset_print(start, count, stride, &data_array1[0][0]); + if (verbose) { + MESG("data_array created"); + dataset_print(start, count, stride, &data_array1[0][0]); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); assert(xfer_plist != FAIL); - ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); assert(ret != FAIL); MESG("H5Pcreate xfer succeed"); /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); assert(ret != FAIL); MESG("H5Dwrite succeed"); @@ -653,14 +627,13 @@ if (verbose) H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - /* * All writes completed. Close datasets collectively */ - ret=H5Dclose(dataset1); + ret = H5Dclose(dataset1); assert(ret != FAIL); MESG("H5Dclose1 succeed"); - ret=H5Dclose(dataset2); + ret = H5Dclose(dataset2); assert(ret != FAIL); MESG("H5Dclose2 succeed"); @@ -683,31 +656,31 @@ if (verbose) void phdf5readAll(char *filename) { - hid_t fid1; /* HDF5 file IDs */ - hid_t acc_tpl1; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ - DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */ + hid_t fid1; /* HDF5 file IDs */ + hid_t acc_tpl1; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + DATATYPE data_array1[SPACE1_DIM1][SPACE1_DIM2]; /* data buffer */ + DATATYPE data_origin1[SPACE1_DIM1][SPACE1_DIM2]; /* expected data buffer */ - hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ - hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ + hsize_t start[SPACE1_RANK]; /* for hyperslab setting */ + hsize_t count[SPACE1_RANK], stride[SPACE1_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; if (verbose) - printf("Collective read test on file %s\n", filename); + printf("Collective read test on file %s\n", filename); /* ------------------- * OPEN AN HDF5 FILE * -------------------*/ /* setup file access template with parallel IO access. */ - acc_tpl1 = H5Pcreate (H5P_FILE_ACCESS); + acc_tpl1 = H5Pcreate(H5P_FILE_ACCESS); assert(acc_tpl1 != FAIL); MESG("H5Pcreate access succeed"); /* set Parallel access with communicator */ @@ -716,15 +689,14 @@ phdf5readAll(char *filename) MESG("H5Pset_fapl_mpio succeed"); /* open the file collectively */ - fid1=H5Fopen(filename,H5F_ACC_RDWR,acc_tpl1); + fid1 = H5Fopen(filename, H5F_ACC_RDWR, acc_tpl1); assert(fid1 != FAIL); MESG("H5Fopen succeed"); /* Release file-access template */ - ret=H5Pclose(acc_tpl1); + ret = H5Pclose(acc_tpl1); assert(ret != FAIL); - /* -------------------------- * Open the datasets in it * ------------------------- */ @@ -744,43 +716,40 @@ phdf5readAll(char *filename) /* Dataset1: each process takes a block of columns. */ slab_set(start, count, stride, BYCOL); -if (verbose) - printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], - (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)(count[0]*count[1])); + if (verbose) + printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0], + (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], + (unsigned long)(count[0] * count[1])); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); assert(file_dataspace != FAIL); MESG("H5Dget_space succeed"); - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, - count, NULL); + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL); assert(ret != FAIL); MESG("H5Sset_hyperslab succeed"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL); - assert (mem_dataspace != FAIL); + mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL); + assert(mem_dataspace != FAIL); /* fill dataset with test data */ dataset_fill(start, count, stride, &data_origin1[0][0]); MESG("data_array initialized"); - if (verbose){ - MESG("data_array created"); - dataset_print(start, count, stride, &data_array1[0][0]); + if (verbose) { + MESG("data_array created"); + dataset_print(start, count, stride, &data_array1[0][0]); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); assert(xfer_plist != FAIL); - ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); assert(ret != FAIL); MESG("H5Pcreate xfer succeed"); /* read data collectively */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); assert(ret != FAIL); MESG("H5Dread succeed"); @@ -797,43 +766,40 @@ if (verbose) /* Dataset2: each process takes a block of rows. */ slab_set(start, count, stride, BYROW); -if (verbose) - printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], - (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)(count[0]*count[1])); + if (verbose) + printf("start[]=(%lu,%lu), count[]=(%lu,%lu), total datapoints=%lu\n", (unsigned long)start[0], + (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], + (unsigned long)(count[0] * count[1])); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); assert(file_dataspace != FAIL); MESG("H5Dget_space succeed"); - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, - count, NULL); + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, NULL); assert(ret != FAIL); MESG("H5Sset_hyperslab succeed"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (SPACE1_RANK, count, NULL); - assert (mem_dataspace != FAIL); + mem_dataspace = H5Screate_simple(SPACE1_RANK, count, NULL); + assert(mem_dataspace != FAIL); /* fill dataset with test data */ dataset_fill(start, count, stride, &data_origin1[0][0]); MESG("data_array initialized"); - if (verbose){ - MESG("data_array created"); - dataset_print(start, count, stride, &data_array1[0][0]); + if (verbose) { + MESG("data_array created"); + dataset_print(start, count, stride, &data_array1[0][0]); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); assert(xfer_plist != FAIL); - ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); assert(ret != FAIL); MESG("H5Pcreate xfer succeed"); /* read data independently */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); assert(ret != FAIL); MESG("H5Dread succeed"); @@ -846,14 +812,13 @@ if (verbose) H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - /* * All reads completed. Close datasets collectively */ - ret=H5Dclose(dataset1); + ret = H5Dclose(dataset1); assert(ret != FAIL); MESG("H5Dclose1 succeed"); - ret=H5Dclose(dataset2); + ret = H5Dclose(dataset2); assert(ret != FAIL); MESG("H5Dclose2 succeed"); @@ -877,51 +842,51 @@ test_split_comm_access(char filenames[][PATH_MAX]) { MPI_Comm comm; MPI_Info info = MPI_INFO_NULL; - int color, mrc; - int newrank, newprocs; - hid_t fid; /* file IDs */ - hid_t acc_tpl; /* File access properties */ - herr_t ret; /* generic return value */ + int color, mrc; + int newrank, newprocs; + hid_t fid; /* file IDs */ + hid_t acc_tpl; /* File access properties */ + herr_t ret; /* generic return value */ if (verbose) - printf("Independent write test on file %s %s\n", - filenames[0], filenames[1]); - - color = mpi_rank%2; - mrc = MPI_Comm_split (MPI_COMM_WORLD, color, mpi_rank, &comm); - assert(mrc==MPI_SUCCESS); - MPI_Comm_size(comm,&newprocs); - MPI_Comm_rank(comm,&newrank); - - if (color){ - /* odd-rank processes */ - mrc = MPI_Barrier(comm); - assert(mrc==MPI_SUCCESS); - }else{ - /* even-rank processes */ - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - assert(acc_tpl != FAIL); - - /* set Parallel access with communicator */ - ret = H5Pset_fapl_mpio(acc_tpl, comm, info); - assert(ret != FAIL); - - /* create the file collectively */ - fid=H5Fcreate(filenames[color],H5F_ACC_TRUNC,H5P_DEFAULT,acc_tpl); - assert(fid != FAIL); - MESG("H5Fcreate succeed"); - - /* Release file-access template */ - ret=H5Pclose(acc_tpl); - assert(ret != FAIL); - - ret=H5Fclose(fid); - assert(ret != FAIL); + printf("Independent write test on file %s %s\n", filenames[0], filenames[1]); + + color = mpi_rank % 2; + mrc = MPI_Comm_split(MPI_COMM_WORLD, color, mpi_rank, &comm); + assert(mrc == MPI_SUCCESS); + MPI_Comm_size(comm, &newprocs); + MPI_Comm_rank(comm, &newrank); + + if (color) { + /* odd-rank processes */ + mrc = MPI_Barrier(comm); + assert(mrc == MPI_SUCCESS); } - if (mpi_rank == 0){ - mrc = MPI_File_delete(filenames[color], info); - assert(mrc==MPI_SUCCESS); + else { + /* even-rank processes */ + /* setup file access template */ + acc_tpl = H5Pcreate(H5P_FILE_ACCESS); + assert(acc_tpl != FAIL); + + /* set Parallel access with communicator */ + ret = H5Pset_fapl_mpio(acc_tpl, comm, info); + assert(ret != FAIL); + + /* create the file collectively */ + fid = H5Fcreate(filenames[color], H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); + assert(fid != FAIL); + MESG("H5Fcreate succeed"); + + /* Release file-access template */ + ret = H5Pclose(acc_tpl); + assert(ret != FAIL); + + ret = H5Fclose(fid); + assert(ret != FAIL); + } + if (mpi_rank == 0) { + mrc = MPI_File_delete(filenames[color], info); + assert(mrc == MPI_SUCCESS); } } @@ -944,7 +909,6 @@ usage(void) printf("\n"); } - /* * compose the test filename with the prefix supplied. * return code: 0 if no error @@ -953,88 +917,93 @@ usage(void) int mkfilenames(char *prefix) { - int i, n; + int i, n; size_t strsize; /* filename will be prefix/ParaEgN.h5 where N is 0 to 9. */ /* So, string must be big enough to hold the prefix, / and 10 more chars */ /* and the terminating null. */ strsize = strlen(prefix) + 12; - if (strsize > PATH_MAX){ - printf("File prefix too long; Use a short path name.\n"); - return(1); + if (strsize > PATH_MAX) { + printf("File prefix too long; Use a short path name.\n"); + return (1); } - n = sizeof(testfiles)/sizeof(testfiles[0]); - if (n > 9){ - printf("Warning: Too many entries in testfiles. " - "Need to adjust the code to accommodate the large size.\n"); + n = sizeof(testfiles) / sizeof(testfiles[0]); + if (n > 9) { + printf("Warning: Too many entries in testfiles. " + "Need to adjust the code to accommodate the large size.\n"); } - for (i=0; i 0) *corder_valid = 1; + if (ainfo.corder_valid > 0) + *corder_valid = 1; - *corder = (int_f)ainfo.corder; - *cset = (int_f)ainfo.cset; + *corder = (int_f)ainfo.corder; + *cset = (int_f)ainfo.cset; *data_size = (hsize_t_f)ainfo.data_size; done: @@ -659,41 +661,40 @@ done: * HISTORY * N/A * SOURCE -*/ + */ int_f -h5aget_info_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, - int_f *idx_type, int_f *order, hsize_t_f *n, hid_t_f *lapl_id, - int_f *corder_valid, int_f *corder, - int_f *cset, hsize_t_f *data_size ) +h5aget_info_by_idx_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, int_f *idx_type, int_f *order, + hsize_t_f *n, hid_t_f *lapl_id, int_f *corder_valid, int_f *corder, int_f *cset, + hsize_t_f *data_size) /******/ { - char *c_obj_name = NULL; /* Buffer to hold C string */ + char * c_obj_name = NULL; /* Buffer to hold C string */ H5A_info_t ainfo; - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ /* * Convert FORTRAN name to C name */ - if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen))) + if (NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen))) HGOTO_DONE(FAIL) - /* - * Call H5Ainfo_by_idx function. - */ - if(H5Aget_info_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n, - &ainfo, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL) + /* + * Call H5Ainfo_by_idx function. + */ + if (H5Aget_info_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, + (hsize_t)*n, &ainfo, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL) /* Unpack the structure */ *corder_valid = 0; - if(ainfo.corder_valid > 0) + if (ainfo.corder_valid > 0) *corder_valid = 1; - *corder = (int_f)ainfo.corder; - *cset = (int_f)ainfo.cset; + *corder = (int_f)ainfo.corder; + *cset = (int_f)ainfo.cset; *data_size = (hsize_t_f)ainfo.data_size; done: - if(c_obj_name) + if (c_obj_name) HDfree(c_obj_name); return ret_value; @@ -726,45 +727,44 @@ done: * HISTORY * N/A * SOURCE -*/ + */ int_f -h5aget_info_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, - _fcd attr_name, size_t_f *attr_namelen, hid_t_f *lapl_id, - int_f *corder_valid, int_f *corder, - int_f *cset, hsize_t_f *data_size ) +h5aget_info_by_name_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, + size_t_f *attr_namelen, hid_t_f *lapl_id, int_f *corder_valid, int_f *corder, + int_f *cset, hsize_t_f *data_size) /******/ { - char *c_obj_name = NULL; /* Buffer to hold C string */ - char *c_attr_name = NULL; /* Buffer to hold C string */ + char * c_obj_name = NULL; /* Buffer to hold C string */ + char * c_attr_name = NULL; /* Buffer to hold C string */ H5A_info_t ainfo; - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ /* * Convert FORTRAN name to C name */ - if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen))) + if (NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen))) + if (NULL == (c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen))) HGOTO_DONE(FAIL) - /* - * Call H5Ainfo_by_name function. - */ - if(H5Aget_info_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, &ainfo, (hid_t)*lapl_id) < 0) + /* + * Call H5Ainfo_by_name function. + */ + if (H5Aget_info_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, &ainfo, (hid_t)*lapl_id) < 0) HGOTO_DONE(FAIL) /* Unpack the structure */ *corder_valid = 0; - if(ainfo.corder_valid > 0) + if (ainfo.corder_valid > 0) *corder_valid = 1; - *corder = (int_f)ainfo.corder; - *cset = (int_f)ainfo.cset; + *corder = (int_f)ainfo.corder; + *cset = (int_f)ainfo.cset; *data_size = (hsize_t_f)ainfo.data_size; done: - if(c_obj_name) + if (c_obj_name) HDfree(c_obj_name); - if(c_attr_name) + if (c_attr_name) HDfree(c_attr_name); return ret_value; @@ -803,37 +803,37 @@ done: * SOURCE */ int_f -h5acreate_by_name_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, - _fcd attr_name, size_t_f *attr_namelen, hid_t_f *type_id, - hid_t_f *space_id, hid_t_f *acpl_id, hid_t_f *aapl_id, - hid_t_f *lapl_id, hid_t_f *attr_id ) +h5acreate_by_name_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, + size_t_f *attr_namelen, hid_t_f *type_id, hid_t_f *space_id, hid_t_f *acpl_id, + hid_t_f *aapl_id, hid_t_f *lapl_id, hid_t_f *attr_id) /******/ { - char *c_obj_name = NULL; /* Buffer to hold C string */ - char *c_attr_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN name to C name - */ - if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) - HGOTO_DONE(FAIL); - if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Acreate_by_name function. - */ - if((*attr_id = (hid_t_f)H5Acreate_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, - (hid_t)*type_id, (hid_t)*space_id,(hid_t)*acpl_id,(hid_t)*aapl_id,(hid_t)*lapl_id )) < 0) - HGOTO_DONE(FAIL); + char *c_obj_name = NULL; /* Buffer to hold C string */ + char *c_attr_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN name to C name + */ + if ((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) + HGOTO_DONE(FAIL); + if ((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Acreate_by_name function. + */ + if ((*attr_id = (hid_t_f)H5Acreate_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, (hid_t)*type_id, + (hid_t)*space_id, (hid_t)*acpl_id, (hid_t)*aapl_id, + (hid_t)*lapl_id)) < 0) + HGOTO_DONE(FAIL); done: - if(c_obj_name) - HDfree(c_obj_name); - if(c_attr_name) - HDfree(c_attr_name); - return ret_value; + if (c_obj_name) + HDfree(c_obj_name); + if (c_attr_name) + HDfree(c_attr_name); + return ret_value; } /****if* H5Af/h5aexists_c @@ -856,28 +856,28 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5aexists_c (hid_t_f *obj_id, _fcd name, size_t_f *namelen, hid_t_f *attr_exists) +h5aexists_c(hid_t_f *obj_id, _fcd name, size_t_f *namelen, hid_t_f *attr_exists) /******/ { - char *c_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ + char *c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ - /* - * Convert FORTRAN name to C name - */ - if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); + /* + * Convert FORTRAN name to C name + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); - /* - * Call H5Aexists function. - */ - if((*attr_exists = (hid_t_f)H5Aexists((hid_t)*obj_id, c_name)) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Aexists function. + */ + if ((*attr_exists = (hid_t_f)H5Aexists((hid_t)*obj_id, c_name)) < 0) + HGOTO_DONE(FAIL); done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -904,34 +904,35 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5aexists_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, size_t_f *attr_namelen, - hid_t_f *lapl_id, int_f *attr_exists) +h5aexists_by_name_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, + size_t_f *attr_namelen, hid_t_f *lapl_id, int_f *attr_exists) /******/ { - char *c_obj_name = NULL; /* Buffer to hold object name C string */ - char *c_attr_name = NULL; /* Buffer to hold attribute name C string */ - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN name to C name - */ - if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) - HGOTO_DONE(FAIL); - if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Aexists_by_name function. - */ - if((*attr_exists = (int_f)H5Aexists_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, (hid_t)*lapl_id)) < 0) - HGOTO_DONE(FAIL); + char *c_obj_name = NULL; /* Buffer to hold object name C string */ + char *c_attr_name = NULL; /* Buffer to hold attribute name C string */ + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN name to C name + */ + if ((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) + HGOTO_DONE(FAIL); + if ((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Aexists_by_name function. + */ + if ((*attr_exists = (int_f)H5Aexists_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, (hid_t)*lapl_id)) < + 0) + HGOTO_DONE(FAIL); done: - if(c_obj_name) + if (c_obj_name) HDfree(c_obj_name); - if(c_attr_name) + if (c_attr_name) HDfree(c_attr_name); return ret_value; } @@ -959,36 +960,37 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5aopen_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, size_t_f *attr_namelen, - hid_t_f *aapl_id, hid_t_f *lapl_id, hid_t_f *attr_id) +h5aopen_by_name_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, + size_t_f *attr_namelen, hid_t_f *aapl_id, hid_t_f *lapl_id, hid_t_f *attr_id) /******/ { - char *c_obj_name = NULL; /* Buffer to hold object name C string */ - char *c_attr_name = NULL; /* Buffer to hold attribute name C string */ - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN name to C name - */ - if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) - HGOTO_DONE(FAIL); - if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Aopen function. - */ - if((*attr_id = (hid_t_f)H5Aopen_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, (hid_t)*aapl_id, (hid_t)*lapl_id)) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_obj_name) - HDfree(c_obj_name); - if(c_attr_name) - HDfree(c_attr_name); - return ret_value; + char *c_obj_name = NULL; /* Buffer to hold object name C string */ + char *c_attr_name = NULL; /* Buffer to hold attribute name C string */ + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN name to C name + */ + if ((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) + HGOTO_DONE(FAIL); + if ((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Aopen function. + */ + if ((*attr_id = (hid_t_f)H5Aopen_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, (hid_t)*aapl_id, + (hid_t)*lapl_id)) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_obj_name) + HDfree(c_obj_name); + if (c_attr_name) + HDfree(c_attr_name); + return ret_value; } /****if* H5Af/h5arename_c @@ -1012,33 +1014,32 @@ h5aopen_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd a * HISTORY * N/A * SOURCE -*/ + */ int_f -h5arename_c( hid_t_f *loc_id, - _fcd old_attr_name, size_t_f *old_attr_namelen, - _fcd new_attr_name, size_t_f *new_attr_namelen) +h5arename_c(hid_t_f *loc_id, _fcd old_attr_name, size_t_f *old_attr_namelen, _fcd new_attr_name, + size_t_f *new_attr_namelen) /******/ { - char *c_old_attr_name = NULL; /* Buffer to hold C string */ - char *c_new_attr_name = NULL; /* Buffer to hold C string */ - int_f ret_value=0; /* Return value */ - /* - * Convert FORTRAN name to C name - */ - if((c_old_attr_name = HD5f2cstring(old_attr_name, (size_t)*old_attr_namelen)) == NULL) - HGOTO_DONE(FAIL); - if((c_new_attr_name = HD5f2cstring(new_attr_name, (size_t)*new_attr_namelen)) == NULL) - HGOTO_DONE(FAIL); - - if(H5Arename((hid_t)*loc_id,c_old_attr_name,c_new_attr_name) < 0) + char *c_old_attr_name = NULL; /* Buffer to hold C string */ + char *c_new_attr_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + /* + * Convert FORTRAN name to C name + */ + if ((c_old_attr_name = HD5f2cstring(old_attr_name, (size_t)*old_attr_namelen)) == NULL) + HGOTO_DONE(FAIL); + if ((c_new_attr_name = HD5f2cstring(new_attr_name, (size_t)*new_attr_namelen)) == NULL) + HGOTO_DONE(FAIL); + + if (H5Arename((hid_t)*loc_id, c_old_attr_name, c_new_attr_name) < 0) HGOTO_DONE(FAIL); done: - if(c_old_attr_name) - HDfree(c_old_attr_name); - if(c_new_attr_name) - HDfree(c_new_attr_name); + if (c_old_attr_name) + HDfree(c_old_attr_name); + if (c_new_attr_name) + HDfree(c_new_attr_name); return ret_value; } /****if* H5Af/h5awrite_f_c @@ -1059,19 +1060,20 @@ done: * * * SOURCE -*/ + */ int_f -h5awrite_f_c (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf) +h5awrite_f_c(hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf) /******/ { - int ret_value = -1; - herr_t ret; + int ret_value = -1; + herr_t ret; - ret = H5Awrite( (hid_t)*attr_id, (hid_t)*mem_type_id, buf); + ret = H5Awrite((hid_t)*attr_id, (hid_t)*mem_type_id, buf); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Af/h5aread_f_c @@ -1092,18 +1094,18 @@ h5awrite_f_c (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf) * * * SOURCE -*/ + */ int_f -h5aread_f_c (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf) +h5aread_f_c(hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf) /******/ { - int ret_value = -1; - herr_t ret; + int ret_value = -1; + herr_t ret; - ret = H5Aread( (hid_t)*attr_id, (hid_t)*mem_type_id, buf); + ret = H5Aread((hid_t)*attr_id, (hid_t)*mem_type_id, buf); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } - diff --git a/fortran/src/H5Df.c b/fortran/src/H5Df.c index 8ef7936..7d1ea9e 100644 --- a/fortran/src/H5Df.c +++ b/fortran/src/H5Df.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" @@ -44,34 +44,34 @@ * - Added optional parameters introduced in version 1.8 * February, 2008 * SOURCE -*/ + */ int_f -h5dcreate_c (hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_t_f *space_id, - hid_t_f *lcpl_id, hid_t_f *dcpl_id, hid_t_f *dapl_id, hid_t_f *dset_id) +h5dcreate_c(hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_t_f *space_id, hid_t_f *lcpl_id, + hid_t_f *dcpl_id, hid_t_f *dapl_id, hid_t_f *dset_id) /******/ { - char *c_name = NULL; - hid_t c_dset_id; - int ret_value = -1; - - /* - * Convert FORTRAN name to C name - */ - if(NULL == ( c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) - goto DONE; - - /* - * Call H5Dcreate2 function. - */ - if((c_dset_id = H5Dcreate2((hid_t)*loc_id, c_name, (hid_t)*type_id, (hid_t)*space_id, - (hid_t)*lcpl_id, (hid_t)*dcpl_id, (hid_t)*dapl_id)) < 0) - goto DONE; - *dset_id = (hid_t_f)c_dset_id; - - ret_value = 0; + char *c_name = NULL; + hid_t c_dset_id; + int ret_value = -1; + + /* + * Convert FORTRAN name to C name + */ + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + goto DONE; + + /* + * Call H5Dcreate2 function. + */ + if ((c_dset_id = H5Dcreate2((hid_t)*loc_id, c_name, (hid_t)*type_id, (hid_t)*space_id, (hid_t)*lcpl_id, + (hid_t)*dcpl_id, (hid_t)*dapl_id)) < 0) + goto DONE; + *dset_id = (hid_t_f)c_dset_id; + + ret_value = 0; DONE: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -96,34 +96,34 @@ DONE: * HISTORY * Added 1.8 parameter: dapl_id * SOURCE -*/ + */ int_f h5dopen_c(hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *dapl_id, hid_t_f *dset_id) /******/ { - char *c_name = NULL; - hid_t c_dset_id; - int ret_value = -1; + char *c_name = NULL; + hid_t c_dset_id; + int ret_value = -1; - /* - * Convert FORTRAN name to C name - */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) - goto DONE; + /* + * Convert FORTRAN name to C name + */ + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + goto DONE; - /* - * Call H5Dopen2 function. - */ - if((c_dset_id = H5Dopen2((hid_t)*loc_id, c_name, (hid_t)*dapl_id)) < 0) - goto DONE; + /* + * Call H5Dopen2 function. + */ + if ((c_dset_id = H5Dopen2((hid_t)*loc_id, c_name, (hid_t)*dapl_id)) < 0) + goto DONE; - *dset_id = (hid_t_f)c_dset_id; - ret_value = 0; + *dset_id = (hid_t_f)c_dset_id; + ret_value = 0; DONE: - if(c_name) - HDfree(c_name); - return ret_value; + if (c_name) + HDfree(c_name); + return ret_value; } /****if* H5Df/h5dwrite_ref_reg_c @@ -148,52 +148,54 @@ DONE: * This function was added to accomodate h5dwrite_f with the * dims argument being of INTEGER(HSIZE_T) type * SOURCE -*/ + */ int_f -h5dwrite_ref_reg_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims) +h5dwrite_ref_reg_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, + hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims) /******/ { - int ret_value = -1; - herr_t ret; - hid_t c_dset_id; - hid_t c_mem_type_id; - hid_t c_mem_space_id; - hid_t c_file_space_id; - hid_t c_xfer_prp; - hdset_reg_ref_t *buf_c = NULL; - unsigned int i, n; - - n = (unsigned int)*dims; - /* - * Define transfer property - */ - c_xfer_prp = (hid_t)*xfer_prp; - - /* - * Allocate temporary buffer and copy references from Fortran. - */ - buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t)*n); - if ( buf_c != NULL ) { - for (i = 0; i < n; i++) { - HDmemcpy(&buf_c[i], buf, H5R_DSET_REG_REF_BUF_SIZE); - buf = buf + REF_REG_BUF_LEN_F; - } - } - else return ret_value; - - - /* - * Call H5Dwrite function. - */ - c_dset_id = (hid_t)*dset_id; - c_mem_type_id = (hid_t)*mem_type_id; - c_mem_space_id = (hid_t)*mem_space_id; - c_file_space_id = (hid_t)*file_space_id; - ret = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); - HDfree(buf_c); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + herr_t ret; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + hdset_reg_ref_t *buf_c = NULL; + unsigned int i, n; + + n = (unsigned int)*dims; + /* + * Define transfer property + */ + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Allocate temporary buffer and copy references from Fortran. + */ + buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * n); + if (buf_c != NULL) { + for (i = 0; i < n; i++) { + HDmemcpy(&buf_c[i], buf, H5R_DSET_REG_REF_BUF_SIZE); + buf = buf + REF_REG_BUF_LEN_F; + } + } + else + return ret_value; + + /* + * Call H5Dwrite function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); + HDfree(buf_c); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Df/h5dread_ref_reg_c @@ -218,54 +220,55 @@ h5dwrite_ref_reg_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_i * This function was added to accomodate h5dread_f subroutine * with the dims parameter being of INTEGER(HSIZE_T_F) size. * SOURCE -*/ + */ int_f -h5dread_ref_reg_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, int_f * buf, hsize_t_f *dims) +h5dread_ref_reg_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, + hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims) /******/ { - int ret_value = -1; - herr_t ret = -1; - hid_t c_dset_id; - hid_t c_mem_type_id; - hid_t c_mem_space_id; - hid_t c_file_space_id; - hid_t c_xfer_prp; - hdset_reg_ref_t *buf_c = NULL; - hsize_t i, n; - n = (hsize_t)*dims; - /* - * Define transfer property - */ - c_xfer_prp = (hid_t)*xfer_prp; - - /* - * Allocate temporary buffer. - */ - buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t)*(size_t)n); - if ( buf_c != NULL ) { - /* - * Call H5Dread function. - */ - c_dset_id = (hid_t)*dset_id; - c_mem_type_id = (hid_t)*mem_type_id; - c_mem_space_id = (hid_t)*mem_space_id; - c_file_space_id = (hid_t)*file_space_id; - ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); - if (ret >=0) { + int ret_value = -1; + herr_t ret = -1; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + hdset_reg_ref_t *buf_c = NULL; + hsize_t i, n; + n = (hsize_t)*dims; + /* + * Define transfer property + */ + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Allocate temporary buffer. + */ + buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * (size_t)n); + if (buf_c != NULL) { + /* + * Call H5Dread function. + */ + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c); + if (ret >= 0) { for (i = 0; i < n; i++) { - HDmemcpy(buf, &buf_c[i], H5R_DSET_REG_REF_BUF_SIZE); - buf = buf + REF_REG_BUF_LEN_F; + HDmemcpy(buf, &buf_c[i], H5R_DSET_REG_REF_BUF_SIZE); + buf = buf + REF_REG_BUF_LEN_F; } - } - if ( buf_c != NULL ) HDfree(buf_c); - } - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + } + if (buf_c != NULL) + HDfree(buf_c); + } + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } - - /****if* H5Df/h5dclose_c * NAME * h5dclose_c @@ -281,17 +284,18 @@ h5dread_ref_reg_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id * HISTORY * * SOURCE -*/ + */ int_f -h5dclose_c ( hid_t_f *dset_id ) +h5dclose_c(hid_t_f *dset_id) /******/ { - int ret_value = 0; - hid_t c_dset_id; - c_dset_id = (hid_t)*dset_id; - if ( H5Dclose(c_dset_id) < 0 ) ret_value = -1; - return ret_value; + int ret_value = 0; + hid_t c_dset_id; + c_dset_id = (hid_t)*dset_id; + if (H5Dclose(c_dset_id) < 0) + ret_value = -1; + return ret_value; } /****if* H5Df/h5dget_space_c @@ -311,22 +315,23 @@ h5dclose_c ( hid_t_f *dset_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5dget_space_c ( hid_t_f *dset_id , hid_t_f *space_id) +h5dget_space_c(hid_t_f *dset_id, hid_t_f *space_id) /******/ { - int ret_value = -1; - hid_t c_dset_id; - hid_t c_space_id; - - c_dset_id = (hid_t)*dset_id; - c_space_id = H5Dget_space(c_dset_id); - if(c_space_id < 0 ) return ret_value; - ret_value = 0; - *space_id = (hid_t_f)c_space_id; - return ret_value; + int ret_value = -1; + hid_t c_dset_id; + hid_t c_space_id; + + c_dset_id = (hid_t)*dset_id; + c_space_id = H5Dget_space(c_dset_id); + if (c_space_id < 0) + return ret_value; + ret_value = 0; + *space_id = (hid_t_f)c_space_id; + return ret_value; } /****if* H5Df/h5dget_type_c @@ -346,24 +351,25 @@ h5dget_space_c ( hid_t_f *dset_id , hid_t_f *space_id) * HISTORY * * SOURCE -*/ + */ int_f -h5dget_type_c ( hid_t_f *dset_id , hid_t_f *type_id) +h5dget_type_c(hid_t_f *dset_id, hid_t_f *type_id) /******/ { - int ret_value = -1; - hid_t c_dset_id; - hid_t c_type_id; + int ret_value = -1; + hid_t c_dset_id; + hid_t c_type_id; - c_dset_id = (hid_t)*dset_id; - c_type_id = H5Dget_type(c_dset_id); + c_dset_id = (hid_t)*dset_id; + c_type_id = H5Dget_type(c_dset_id); - if(c_type_id < 0 ) return ret_value; + if (c_type_id < 0) + return ret_value; - *type_id = (hid_t_f)c_type_id; - ret_value = 0; - return ret_value; + *type_id = (hid_t_f)c_type_id; + ret_value = 0; + return ret_value; } /****if* H5Df/h5dget_create_plist_c @@ -384,27 +390,27 @@ h5dget_type_c ( hid_t_f *dset_id , hid_t_f *type_id) * HISTORY * * SOURCE -*/ + */ int_f -h5dget_create_plist_c ( hid_t_f *dset_id , hid_t_f *plist_id) +h5dget_create_plist_c(hid_t_f *dset_id, hid_t_f *plist_id) /******/ { - int ret_value = -1; - hid_t c_dset_id; - hid_t c_plist_id; + int ret_value = -1; + hid_t c_dset_id; + hid_t c_plist_id; - c_dset_id = (hid_t)*dset_id; - c_plist_id = H5Dget_create_plist(c_dset_id); + c_dset_id = (hid_t)*dset_id; + c_plist_id = H5Dget_create_plist(c_dset_id); - if(c_plist_id < 0 ) return ret_value; + if (c_plist_id < 0) + return ret_value; - ret_value = 0; - *plist_id = (hid_t_f)c_plist_id; - return ret_value; + ret_value = 0; + *plist_id = (hid_t_f)c_plist_id; + return ret_value; } - /****if* H5Df/h5dset_extent_c * NAME * h5dset_extent_c @@ -425,37 +431,38 @@ h5dget_create_plist_c ( hid_t_f *dset_id , hid_t_f *plist_id) * to h5dset_extent in order to match new fortran interface. * -MSB- March 14, 2008 * SOURCE -*/ + */ int_f -h5dset_extent_c ( hid_t_f *dset_id , hsize_t_f *dims) +h5dset_extent_c(hid_t_f *dset_id, hsize_t_f *dims) /******/ { - hid_t c_space_id; - hsize_t c_dims[H5S_MAX_RANK]; - int rank; - int i; - int status; - int ret_value = -1; - - if((c_space_id = H5Dget_space((hid_t)*dset_id)) < 0) return ret_value; - - rank = H5Sget_simple_extent_ndims(c_space_id); - H5Sclose(c_space_id); - if(rank < 0 ) return ret_value; - - - /* - * Reverse dimensions due to C-FORTRAN storage order. - */ - for(i = 0; i < rank; i++) - c_dims[i] = (hsize_t)dims[rank - i - 1]; - - status = H5Dset_extent((hid_t)*dset_id, c_dims); - - if(status >= 0) - ret_value = 0; - return ret_value; + hid_t c_space_id; + hsize_t c_dims[H5S_MAX_RANK]; + int rank; + int i; + int status; + int ret_value = -1; + + if ((c_space_id = H5Dget_space((hid_t)*dset_id)) < 0) + return ret_value; + + rank = H5Sget_simple_extent_ndims(c_space_id); + H5Sclose(c_space_id); + if (rank < 0) + return ret_value; + + /* + * Reverse dimensions due to C-FORTRAN storage order. + */ + for (i = 0; i < rank; i++) + c_dims[i] = (hsize_t)dims[rank - i - 1]; + + status = H5Dset_extent((hid_t)*dset_id, c_dims); + + if (status >= 0) + ret_value = 0; + return ret_value; } /****if* H5Df/h5dget_storage_size_c @@ -476,22 +483,23 @@ h5dset_extent_c ( hid_t_f *dset_id , hsize_t_f *dims) * HISTORY * * SOURCE -*/ + */ int_f -h5dget_storage_size_c ( hid_t_f *dset_id , hsize_t_f *size) +h5dget_storage_size_c(hid_t_f *dset_id, hsize_t_f *size) /******/ { - int ret_value = -1; - hsize_t c_size; - hid_t c_dset_id; - - c_dset_id = (hid_t)*dset_id; - c_size = H5Dget_storage_size(c_dset_id); - if (c_size == 0) return ret_value; - *size = (hsize_t_f)c_size; - ret_value = 0; - return ret_value; + int ret_value = -1; + hsize_t c_size; + hid_t c_dset_id; + + c_dset_id = (hid_t)*dset_id; + c_size = H5Dget_storage_size(c_dset_id); + if (c_size == 0) + return ret_value; + *size = (hsize_t_f)c_size; + ret_value = 0; + return ret_value; } /****if* H5Df/h5dvlen_get_max_len_c @@ -513,44 +521,48 @@ h5dget_storage_size_c ( hid_t_f *dset_id , hsize_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5dvlen_get_max_len_c ( hid_t_f *dset_id , hid_t_f *type_id, hid_t_f *space_id, size_t_f *len) +h5dvlen_get_max_len_c(hid_t_f *dset_id, hid_t_f *type_id, hid_t_f *space_id, size_t_f *len) /******/ { - int ret_value = -1; - size_t c_len; - hid_t c_dset_id; - hid_t c_type_id; - hid_t c_space_id; - hvl_t *c_buf; - int i; - hssize_t num_elem; - herr_t status; - - c_dset_id = (hid_t)*dset_id; - c_type_id = (hid_t)*type_id; - c_space_id = (hid_t)*space_id; - - num_elem = H5Sget_select_npoints(c_space_id); - if( num_elem < 0) return ret_value; - - c_buf = (hvl_t *)HDmalloc(sizeof(hvl_t)*(size_t)num_elem); - if (c_buf == NULL) return ret_value; - status = H5Dread(c_dset_id, c_type_id, H5S_ALL, c_space_id, H5P_DEFAULT, c_buf); - if(status < 0) goto DONE; - - c_len = 0; - for (i=0; i < num_elem; i++) c_len = H5_MAX(c_len, c_buf[i].len); - *len = (size_t_f)c_len; - H5Treclaim(c_type_id, c_space_id, H5P_DEFAULT, c_buf); - ret_value = 0; + int ret_value = -1; + size_t c_len; + hid_t c_dset_id; + hid_t c_type_id; + hid_t c_space_id; + hvl_t * c_buf; + int i; + hssize_t num_elem; + herr_t status; + + c_dset_id = (hid_t)*dset_id; + c_type_id = (hid_t)*type_id; + c_space_id = (hid_t)*space_id; + + num_elem = H5Sget_select_npoints(c_space_id); + if (num_elem < 0) + return ret_value; + + c_buf = (hvl_t *)HDmalloc(sizeof(hvl_t) * (size_t)num_elem); + if (c_buf == NULL) + return ret_value; + status = H5Dread(c_dset_id, c_type_id, H5S_ALL, c_space_id, H5P_DEFAULT, c_buf); + if (status < 0) + goto DONE; + + c_len = 0; + for (i = 0; i < num_elem; i++) + c_len = H5_MAX(c_len, c_buf[i].len); + *len = (size_t_f)c_len; + H5Treclaim(c_type_id, c_space_id, H5P_DEFAULT, c_buf); + ret_value = 0; DONE: - HDfree(c_buf); - return ret_value; + HDfree(c_buf); + return ret_value; } /****if* H5Df/h5dwrite_vl_integer_c * NAME @@ -576,53 +588,56 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5dwrite_vl_integer_c ( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims, size_t_f *len) +h5dwrite_vl_integer_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, + hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims, size_t_f *len) /******/ { - int ret_value = -1; - hid_t c_dset_id; - hid_t c_mem_type_id; - hid_t c_mem_space_id; - hid_t c_file_space_id; - hid_t c_xfer_prp; - herr_t status; - int_f *tmp; - size_t max_len; - - hvl_t *c_buf; - hsize_t i; - hsize_t num_elem; - - max_len = (size_t)dims[0]; - num_elem = (hsize_t)dims[1]; - - c_dset_id = (hid_t)*dset_id; - c_mem_type_id = (hid_t)*mem_type_id; - c_mem_space_id = (hid_t)*mem_space_id; - c_file_space_id = (hid_t)*file_space_id; - c_xfer_prp = (hid_t)*xfer_prp; - - c_buf = (hvl_t *)HDmalloc((size_t)num_elem * sizeof(hvl_t)); - if (c_buf == NULL) return ret_value; - tmp = (int_f *)buf; - for (i=0; i < num_elem; i++) { - c_buf[i].len = (size_t)len[i]; - c_buf[i].p = tmp; - tmp = tmp + max_len; - } - /* - * Call H5Dwrite function. - */ - status = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf); - - if( status < 0) goto DONE; - ret_value = 0; + int ret_value = -1; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + herr_t status; + int_f *tmp; + size_t max_len; + + hvl_t * c_buf; + hsize_t i; + hsize_t num_elem; + + max_len = (size_t)dims[0]; + num_elem = (hsize_t)dims[1]; + + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + c_xfer_prp = (hid_t)*xfer_prp; + + c_buf = (hvl_t *)HDmalloc((size_t)num_elem * sizeof(hvl_t)); + if (c_buf == NULL) + return ret_value; + tmp = (int_f *)buf; + for (i = 0; i < num_elem; i++) { + c_buf[i].len = (size_t)len[i]; + c_buf[i].p = tmp; + tmp = tmp + max_len; + } + /* + * Call H5Dwrite function. + */ + status = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf); + + if (status < 0) + goto DONE; + ret_value = 0; DONE: - HDfree(c_buf); - return ret_value; + HDfree(c_buf); + return ret_value; } /****if* H5Df/h5dread_vl_integer_c @@ -650,51 +665,55 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5dread_vl_integer_c ( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims, size_t_f *len) +h5dread_vl_integer_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, + hid_t_f *xfer_prp, int_f *buf, hsize_t_f *dims, size_t_f *len) /******/ { - int ret_value = -1; - hid_t c_dset_id; - hid_t c_mem_type_id; - hid_t c_mem_space_id; - hid_t c_file_space_id; - hid_t c_xfer_prp; - herr_t status; - size_t max_len; - - hvl_t *c_buf; - hsize_t i; - hssize_t num_elem; - - c_dset_id = (hid_t)*dset_id; - c_mem_type_id = (hid_t)*mem_type_id; - c_mem_space_id = (hid_t)*mem_space_id; - c_file_space_id = (hid_t)*file_space_id; - c_xfer_prp = (hid_t)*xfer_prp; - - max_len = (size_t)dims[0]; - num_elem = H5Sget_select_npoints(c_mem_space_id); - if(num_elem != (hssize_t)dims[1]) return ret_value; - - c_buf = (hvl_t *)HDmalloc((size_t)num_elem * sizeof(hvl_t)); - if (c_buf == NULL) return ret_value; - /* - * Call H5Dread function. - */ - status = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf); - if ( status < 0 ) goto DONE; - for (i=0; i < (hsize_t)num_elem; i++) { - len[i] = (size_t_f)c_buf[i].len; - memcpy(&buf[i*max_len], c_buf[i].p, c_buf[i].len*sizeof(int_f)); - } - H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf); - ret_value = 0; + int ret_value = -1; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + herr_t status; + size_t max_len; + + hvl_t * c_buf; + hsize_t i; + hssize_t num_elem; + + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + c_xfer_prp = (hid_t)*xfer_prp; + + max_len = (size_t)dims[0]; + num_elem = H5Sget_select_npoints(c_mem_space_id); + if (num_elem != (hssize_t)dims[1]) + return ret_value; + + c_buf = (hvl_t *)HDmalloc((size_t)num_elem * sizeof(hvl_t)); + if (c_buf == NULL) + return ret_value; + /* + * Call H5Dread function. + */ + status = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf); + if (status < 0) + goto DONE; + for (i = 0; i < (hsize_t)num_elem; i++) { + len[i] = (size_t_f)c_buf[i].len; + memcpy(&buf[i * max_len], c_buf[i].p, c_buf[i].len * sizeof(int_f)); + } + H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf); + ret_value = 0; DONE: - HDfree(c_buf); - return ret_value; + HDfree(c_buf); + return ret_value; } /****if* H5Df/h5dwrite_vl_string_c @@ -720,69 +739,73 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5dwrite_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims, size_t_f *len) +h5dwrite_vl_string_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, + hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims, size_t_f *len) /******/ { - int ret_value = -1; - hid_t c_dset_id; - hid_t c_mem_type_id; - hid_t c_mem_space_id; - hid_t c_file_space_id; - hid_t c_xfer_prp; - herr_t status; - char *tmp, *tmp_p; - size_t max_len; - - char **c_buf; - hsize_t i; - hsize_t num_elem; - - max_len = (size_t)dims[0]; - num_elem = (hsize_t)dims[1]; - - c_dset_id = (hid_t)*dset_id; - c_mem_type_id = (hid_t)*mem_type_id; - c_mem_space_id = (hid_t)*mem_space_id; - c_file_space_id = (hid_t)*file_space_id; - c_xfer_prp = (hid_t)*xfer_prp; - - /* - * Allocate arra of character pointers - */ - c_buf = (char **)HDmalloc((size_t)num_elem * sizeof(char *)); - if (c_buf == NULL) return ret_value; - - /* Copy data to long C string */ - tmp = (char *)HD5f2cstring(buf, (size_t)(max_len*num_elem)); - if (tmp == NULL) { HDfree(c_buf); - return ret_value; - } - /* - * Move data from temorary buffer - */ - tmp_p = tmp; - for (i=0; i < num_elem; i++) { - c_buf[i] = (char *) HDmalloc((size_t)len[i]+1); + int ret_value = -1; + hid_t c_dset_id; + hid_t c_mem_type_id; + hid_t c_mem_space_id; + hid_t c_file_space_id; + hid_t c_xfer_prp; + herr_t status; + char * tmp, *tmp_p; + size_t max_len; + + char ** c_buf; + hsize_t i; + hsize_t num_elem; + + max_len = (size_t)dims[0]; + num_elem = (hsize_t)dims[1]; + + c_dset_id = (hid_t)*dset_id; + c_mem_type_id = (hid_t)*mem_type_id; + c_mem_space_id = (hid_t)*mem_space_id; + c_file_space_id = (hid_t)*file_space_id; + c_xfer_prp = (hid_t)*xfer_prp; + + /* + * Allocate arra of character pointers + */ + c_buf = (char **)HDmalloc((size_t)num_elem * sizeof(char *)); + if (c_buf == NULL) + return ret_value; + + /* Copy data to long C string */ + tmp = (char *)HD5f2cstring(buf, (size_t)(max_len * num_elem)); + if (tmp == NULL) { + HDfree(c_buf); + return ret_value; + } + /* + * Move data from temorary buffer + */ + tmp_p = tmp; + for (i = 0; i < num_elem; i++) { + c_buf[i] = (char *)HDmalloc((size_t)len[i] + 1); memcpy(c_buf[i], tmp_p, (size_t)len[i]); c_buf[i][len[i]] = '\0'; - tmp_p = tmp_p + max_len; - } + tmp_p = tmp_p + max_len; + } - /* - * Call H5Dwrite function. - */ - status = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf); + /* + * Call H5Dwrite function. + */ + status = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf); - if( status < 0) goto DONE; - ret_value = 0; + if (status < 0) + goto DONE; + ret_value = 0; DONE: - H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf); - HDfree(c_buf); - HDfree(tmp); - return ret_value; + H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf); + HDfree(c_buf); + HDfree(tmp); + return ret_value; } /****if* H5Df/h5dread_vl_string_c * NAME @@ -807,64 +830,68 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5dread_vl_string_c( hid_t_f *dset_id , hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims, size_t_f *len) +h5dread_vl_string_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, + hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims, size_t_f *len) /******/ { - int ret_value = -1; - hid_t c_dset_id; - hid_t c_mem_type_id; - hid_t c_mem_space_id; - hid_t c_file_space_id; - hid_t c_xfer_prp; - herr_t status; - char *tmp, *tmp_p; - size_t max_len; - - char **c_buf; - hsize_t i; - hsize_t num_elem; - - max_len = (size_t)dims[0]; - num_elem = (hsize_t)dims[1]; - - c_dset_id = (hid_t)*dset_id; - c_mem_type_id = (hid_t)*mem_type_id; - c_mem_space_id = (hid_t)*mem_space_id; - c_file_space_id = (hid_t)*file_space_id; - c_xfer_prp = (hid_t)*xfer_prp; - - /* - * Allocate array of character pointers - */ - c_buf = (char **)HDmalloc((size_t)num_elem * sizeof(char *)); - if (c_buf == NULL) return ret_value; - - /* - * Call H5Dread function. - */ - status = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf); - if (status < 0) { HDfree(c_buf); - return ret_value; - } - /* Copy data to long C string */ - tmp = (char *)HDmalloc((size_t)(max_len*num_elem) +1); - tmp_p = tmp; - for (i=0; i 0) + if (c_namelen > 0) c_name = (char *)HDmalloc(c_namelen + 1); - if(!c_name) + if (!c_name) HGOTO_DONE(FAIL) /* * Call H5Eget_msg function. */ H5Eget_msg((hid_t)*error_no, NULL, c_name, c_namelen); - HD5packFstring((char*)c_name, _fcdtocp(name), c_namelen); - if(!HDstrcmp(c_name, "Invalid major error number")) + HD5packFstring((char *)c_name, _fcdtocp(name), c_namelen); + if (!HDstrcmp(c_name, "Invalid major error number")) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; @@ -203,19 +203,19 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5eget_minor_c(int_f* error_no, _fcd name, size_t_f* namelen) +h5eget_minor_c(int_f *error_no, _fcd name, size_t_f *namelen) /******/ { - char *c_name = NULL; + char * c_name = NULL; size_t c_namelen = (size_t)*namelen; - int_f ret_value = 0; + int_f ret_value = 0; - if(c_namelen > 0) + if (c_namelen > 0) c_name = (char *)HDmalloc(c_namelen + 1); - if(!c_name) + if (!c_name) HGOTO_DONE(FAIL) /* @@ -223,11 +223,11 @@ h5eget_minor_c(int_f* error_no, _fcd name, size_t_f* namelen) */ H5Eget_msg((hid_t)*error_no, NULL, c_name, c_namelen); HD5packFstring((char *)c_name, _fcdtocp(name), c_namelen); - if(!HDstrcmp(c_name, "Invalid minor error number")) + if (!HDstrcmp(c_name, "Invalid minor error number")) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; @@ -249,7 +249,7 @@ done: * M. Scot Breitenfeld * July 22, 2009 * SOURCE -*/ + */ /* int_f */ /* h5eset_auto2_c(hid_t_f *estack_id, H5E_auto2_t *func, void *client_data) */ /* /\******\/ */ @@ -266,17 +266,17 @@ int_f h5eset_auto2_c(int_f *printflag, hid_t_f *estack_id, H5E_auto2_t func, void *client_data) /******/ { - int ret_val = -1; - herr_t status = -1; + int ret_val = -1; + herr_t status = -1; - if (*printflag == 1 && *estack_id == -1) - status = H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)H5Eprint2, stderr); - else if (*printflag == 1) - status = H5Eset_auto2((hid_t)*estack_id, func, client_data); - else if (*printflag == 0) - status = H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - if (status >= 0) ret_val = 0; + if (*printflag == 1 && *estack_id == -1) + status = H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)H5Eprint2, stderr); + else if (*printflag == 1) + status = H5Eset_auto2((hid_t)*estack_id, func, client_data); + else if (*printflag == 0) + status = H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + if (status >= 0) + ret_val = 0; - return ret_val; + return ret_val; } - diff --git a/fortran/src/H5Ff.c b/fortran/src/H5Ff.c index 7123f1d..1f1fc7b 100644 --- a/fortran/src/H5Ff.c +++ b/fortran/src/H5Ff.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5Eprivate.h" @@ -41,54 +41,55 @@ * Elena Pourmal * Monday, July 26, 1999 * SOURCE -*/ + */ int_f -h5fcreate_c(_fcd name, int_f *namelen, int_f *access_flags, hid_t_f* crt_prp, hid_t_f *acc_prp, hid_t_f *file_id) +h5fcreate_c(_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *crt_prp, hid_t_f *acc_prp, + hid_t_f *file_id) /******/ { - int ret_value = -1; - char *c_name; - int_f c_namelen; - hid_t c_file_id; - unsigned c_access_flags; - hid_t c_crt_prp; - hid_t c_acc_prp; - - /* - * Define access flags - */ - c_access_flags = (unsigned) *access_flags; - - /* - * Define creation property - */ - c_crt_prp = *crt_prp; - - /* - * Define access property - */ - c_acc_prp = *acc_prp; - - /* - * Convert FORTRAN name to C name - */ - c_namelen = *namelen; - c_name = (char *)HD5f2cstring(name, (size_t)c_namelen); - if(c_name == NULL) - return ret_value; - - /* - * Call H5Fcreate function. - */ - c_file_id = H5Fcreate(c_name, c_access_flags, c_crt_prp, c_acc_prp); - - if (c_file_id >= 0) { - ret_value = 0; - *file_id = c_file_id; - } - - HDfree(c_name); - return ret_value; + int ret_value = -1; + char * c_name; + int_f c_namelen; + hid_t c_file_id; + unsigned c_access_flags; + hid_t c_crt_prp; + hid_t c_acc_prp; + + /* + * Define access flags + */ + c_access_flags = (unsigned)*access_flags; + + /* + * Define creation property + */ + c_crt_prp = *crt_prp; + + /* + * Define access property + */ + c_acc_prp = *acc_prp; + + /* + * Convert FORTRAN name to C name + */ + c_namelen = *namelen; + c_name = (char *)HD5f2cstring(name, (size_t)c_namelen); + if (c_name == NULL) + return ret_value; + + /* + * Call H5Fcreate function. + */ + c_file_id = H5Fcreate(c_name, c_access_flags, c_crt_prp, c_acc_prp); + + if (c_file_id >= 0) { + ret_value = 0; + *file_id = c_file_id; + } + + HDfree(c_name); + return ret_value; } /****if* H5Ff/h5fflush_c @@ -107,31 +108,31 @@ h5fcreate_c(_fcd name, int_f *namelen, int_f *access_flags, hid_t_f* crt_prp, hi * Xiangyang Su * Friday, November 5, 1999 * SOURCE -*/ + */ int_f -h5fflush_c (hid_t_f *object_id, int_f *scope) +h5fflush_c(hid_t_f *object_id, int_f *scope) /******/ { - int ret_value = -1; - hid_t c_file_id; - H5F_scope_t c_scope; - htri_t status; - c_scope = (H5F_scope_t)*scope; + int ret_value = -1; + hid_t c_file_id; + H5F_scope_t c_scope; + htri_t status; + c_scope = (H5F_scope_t)*scope; - /* - * Call H5Fflush function. - */ + /* + * Call H5Fflush function. + */ - c_file_id = *object_id; + c_file_id = *object_id; - status = H5Fflush(c_file_id, c_scope); + status = H5Fflush(c_file_id, c_scope); - if (status >= 0) ret_value = 0; + if (status >= 0) + ret_value = 0; - return ret_value; + return ret_value; } - /****if* H5Ff/h5fmount_c * NAME * h5fmount_c @@ -149,45 +150,47 @@ h5fflush_c (hid_t_f *object_id, int_f *scope) * Xiangyang Su * Monday, October 25, 1999 * HISTORY -*/ + */ int_f -h5fmount_c (hid_t_f *loc_id, _fcd dsetname, int_f *namelen, hid_t_f *file_id, hid_t_f *acc_prp) +h5fmount_c(hid_t_f *loc_id, _fcd dsetname, int_f *namelen, hid_t_f *file_id, hid_t_f *acc_prp) /******/ { - int ret_value = -1; - char *c_name; - int_f c_namelen; - hid_t c_loc_id; - hid_t c_file_id; - hid_t c_acc_prp; - htri_t status; - - /* - * Define access property - */ - c_acc_prp = *acc_prp; -/* - if ( H5P_DEFAULT_F == c_acc_prp ) c_acc_prp = H5P_DEFAULT; -*/ - - c_loc_id = *loc_id; - c_file_id = *file_id; - /* - * Convert FORTRAN name to C name - */ - c_namelen = *namelen; - c_name = (char *)HD5f2cstring(dsetname, (size_t)c_namelen); - if (c_name == NULL) return ret_value; - - /* - * Call H5Fmount function. - */ - status = H5Fmount(c_loc_id, c_name, c_file_id, c_acc_prp); - - if (status >= 0) ret_value = 0; - - HDfree(c_name); - return ret_value; + int ret_value = -1; + char * c_name; + int_f c_namelen; + hid_t c_loc_id; + hid_t c_file_id; + hid_t c_acc_prp; + htri_t status; + + /* + * Define access property + */ + c_acc_prp = *acc_prp; + /* + if ( H5P_DEFAULT_F == c_acc_prp ) c_acc_prp = H5P_DEFAULT; + */ + + c_loc_id = *loc_id; + c_file_id = *file_id; + /* + * Convert FORTRAN name to C name + */ + c_namelen = *namelen; + c_name = (char *)HD5f2cstring(dsetname, (size_t)c_namelen); + if (c_name == NULL) + return ret_value; + + /* + * Call H5Fmount function. + */ + status = H5Fmount(c_loc_id, c_name, c_file_id, c_acc_prp); + + if (status >= 0) + ret_value = 0; + + HDfree(c_name); + return ret_value; } /****if* H5Ff/h5funmount_c @@ -205,38 +208,38 @@ h5fmount_c (hid_t_f *loc_id, _fcd dsetname, int_f *namelen, hid_t_f *file_id, hi * Xiangyang Su * Monday, October 25, 1999 * SOURCE -*/ + */ int_f -h5funmount_c (hid_t_f *loc_id, _fcd dsetname, int_f *namelen) +h5funmount_c(hid_t_f *loc_id, _fcd dsetname, int_f *namelen) /******/ { - int ret_value = -1; - char *c_name; - int_f c_namelen; - hid_t c_loc_id; - htri_t status; - - c_loc_id = *loc_id; - - /* - * Convert FORTRAN name to C name - */ - c_namelen = *namelen; - c_name = (char *)HD5f2cstring(dsetname, (size_t)c_namelen); - if (c_name == NULL) return ret_value; - - /* - * Call H5Fmount function. - */ - status = H5Funmount(c_loc_id, c_name); - - if (status >= 0) ret_value = 0; - - HDfree(c_name); - return ret_value; -} + int ret_value = -1; + char * c_name; + int_f c_namelen; + hid_t c_loc_id; + htri_t status; + c_loc_id = *loc_id; + /* + * Convert FORTRAN name to C name + */ + c_namelen = *namelen; + c_name = (char *)HD5f2cstring(dsetname, (size_t)c_namelen); + if (c_name == NULL) + return ret_value; + + /* + * Call H5Fmount function. + */ + status = H5Funmount(c_loc_id, c_name); + + if (status >= 0) + ret_value = 0; + + HDfree(c_name); + return ret_value; +} /****if* H5Ff/h5fopen_c * NAME @@ -256,49 +259,49 @@ h5funmount_c (hid_t_f *loc_id, _fcd dsetname, int_f *namelen) * Elena Pourmal * Tuesday, August 3, 1999 * SOURCE -*/ + */ int_f -h5fopen_c (_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *acc_prp, hid_t_f *file_id) +h5fopen_c(_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *acc_prp, hid_t_f *file_id) /******/ { - int ret_value = -1; - char *c_name; - int_f c_namelen; - hid_t c_file_id; - unsigned c_access_flags; - hid_t c_acc_prp; - c_acc_prp = (hid_t)*acc_prp; - - /* - * Define access flags - */ - c_access_flags = (unsigned) *access_flags; - - /* - * Define access property - */ - c_acc_prp = *acc_prp; - - /* - * Convert FORTRAN name to C name - */ - c_namelen = *namelen; - c_name = (char *)HD5f2cstring(name, (size_t)c_namelen); - if(c_name == NULL) - return ret_value; - - /* - * Call H5Fopen function. - */ - c_file_id = H5Fopen(c_name, c_access_flags, c_acc_prp); - - if(c_file_id >= 0) { - ret_value = 0; - *file_id = (hid_t_f)c_file_id; - } /* end if */ - - HDfree(c_name); - return ret_value; + int ret_value = -1; + char * c_name; + int_f c_namelen; + hid_t c_file_id; + unsigned c_access_flags; + hid_t c_acc_prp; + c_acc_prp = (hid_t)*acc_prp; + + /* + * Define access flags + */ + c_access_flags = (unsigned)*access_flags; + + /* + * Define access property + */ + c_acc_prp = *acc_prp; + + /* + * Convert FORTRAN name to C name + */ + c_namelen = *namelen; + c_name = (char *)HD5f2cstring(name, (size_t)c_namelen); + if (c_name == NULL) + return ret_value; + + /* + * Call H5Fopen function. + */ + c_file_id = H5Fopen(c_name, c_access_flags, c_acc_prp); + + if (c_file_id >= 0) { + ret_value = 0; + *file_id = (hid_t_f)c_file_id; + } /* end if */ + + HDfree(c_name); + return ret_value; } /****if* H5Ff/h5freopen_c @@ -316,22 +319,23 @@ h5fopen_c (_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *acc_prp, hid * Xiangyang Su * Wednesday, November 3, 1999 * SOURCE -*/ + */ int_f -h5freopen_c (hid_t_f *file_id1, hid_t_f *file_id2) +h5freopen_c(hid_t_f *file_id1, hid_t_f *file_id2) /******/ { - int ret_value = -1; - hid_t c_file_id1, c_file_id2; + int ret_value = -1; + hid_t c_file_id1, c_file_id2; - c_file_id1 = *file_id1; - c_file_id2 = H5Freopen(c_file_id1); + c_file_id1 = *file_id1; + c_file_id2 = H5Freopen(c_file_id1); - if (c_file_id2 < 0) return ret_value; - *file_id2 = (hid_t_f)c_file_id2; + if (c_file_id2 < 0) + return ret_value; + *file_id2 = (hid_t_f)c_file_id2; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Ff/h5fget_create_plist_c @@ -349,22 +353,23 @@ h5freopen_c (hid_t_f *file_id1, hid_t_f *file_id2) * Elena Pourmal, Xiangyang Su * Wednesday, November 3, 1999 * SOURCE -*/ + */ int_f -h5fget_create_plist_c (hid_t_f *file_id, hid_t_f *prop_id) +h5fget_create_plist_c(hid_t_f *file_id, hid_t_f *prop_id) /******/ { - int ret_value = -1; - hid_t c_file_id, c_prop_id; + int ret_value = -1; + hid_t c_file_id, c_prop_id; - c_file_id = (hid_t)*file_id; - c_prop_id = H5Fget_create_plist(c_file_id); + c_file_id = (hid_t)*file_id; + c_prop_id = H5Fget_create_plist(c_file_id); - if (c_prop_id < 0) return ret_value; - *prop_id = (hid_t_f)c_prop_id; + if (c_prop_id < 0) + return ret_value; + *prop_id = (hid_t_f)c_prop_id; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Ff/h5fget_access_plist_c @@ -384,22 +389,23 @@ h5fget_create_plist_c (hid_t_f *file_id, hid_t_f *prop_id) * HISTORY * * SOURCE -*/ + */ int_f -h5fget_access_plist_c (hid_t_f *file_id, hid_t_f *access_id) +h5fget_access_plist_c(hid_t_f *file_id, hid_t_f *access_id) /******/ { - int ret_value = -1; - hid_t c_file_id, c_access_id; + int ret_value = -1; + hid_t c_file_id, c_access_id; - c_file_id = (hid_t)*file_id; - c_access_id = H5Fget_access_plist(c_file_id); + c_file_id = (hid_t)*file_id; + c_access_id = H5Fget_access_plist(c_file_id); - if (c_access_id < 0) return ret_value; - *access_id = (hid_t_f)c_access_id; + if (c_access_id < 0) + return ret_value; + *access_id = (hid_t_f)c_access_id; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Ff/h5fclose_c @@ -417,18 +423,19 @@ h5fget_access_plist_c (hid_t_f *file_id, hid_t_f *access_id) * HISTORY * * SOURCE -*/ + */ int_f -h5fclose_c ( hid_t_f *file_id ) +h5fclose_c(hid_t_f *file_id) /******/ { - int ret_value = 0; - hid_t c_file_id; + int ret_value = 0; + hid_t c_file_id; - c_file_id = (hid_t)*file_id; - if ( H5Fclose(c_file_id) < 0 ) ret_value = -1; - return ret_value; + c_file_id = (hid_t)*file_id; + if (H5Fclose(c_file_id) < 0) + ret_value = -1; + return ret_value; } /****if* H5Ff/h5fget_obj_count_c * NAME @@ -449,23 +456,23 @@ h5fclose_c ( hid_t_f *file_id ) * Changed type of obj_count to size_t_f * Thursday, September 25, 2008 * SOURCE -*/ + */ int_f -h5fget_obj_count_c ( hid_t_f *file_id , int_f *obj_type, size_t_f * obj_count) +h5fget_obj_count_c(hid_t_f *file_id, int_f *obj_type, size_t_f *obj_count) /******/ { - int ret_value = 0; - hid_t c_file_id; - unsigned c_obj_type; - ssize_t c_obj_count; - + int ret_value = 0; + hid_t c_file_id; + unsigned c_obj_type; + ssize_t c_obj_count; - c_file_id = (hid_t)*file_id; - c_obj_type = (unsigned) *obj_type; - if ( (c_obj_count=H5Fget_obj_count(c_file_id, c_obj_type)) < 0 ) ret_value = -1; - *obj_count = (size_t_f)c_obj_count; - return ret_value; + c_file_id = (hid_t)*file_id; + c_obj_type = (unsigned)*obj_type; + if ((c_obj_count = H5Fget_obj_count(c_file_id, c_obj_type)) < 0) + ret_value = -1; + *obj_count = (size_t_f)c_obj_count; + return ret_value; } /****if* H5Ff/h5fget_obj_ids_c * NAME @@ -488,29 +495,28 @@ h5fget_obj_count_c ( hid_t_f *file_id , int_f *obj_type, size_t_f * obj_count) * Thursday, September 25, 2008 EIP * * SOURCE -*/ + */ int_f -h5fget_obj_ids_c ( hid_t_f *file_id , int_f *obj_type, size_t_f *max_objs, - hid_t_f *obj_ids, size_t_f *num_objs) +h5fget_obj_ids_c(hid_t_f *file_id, int_f *obj_type, size_t_f *max_objs, hid_t_f *obj_ids, size_t_f *num_objs) /******/ { - int ret_value = 0; - hid_t c_file_id; + int ret_value = 0; + hid_t c_file_id; unsigned c_obj_type; - size_t u; - size_t c_max_objs; - ssize_t c_num_objs; - hid_t *c_obj_ids; + size_t u; + size_t c_max_objs; + ssize_t c_num_objs; + hid_t * c_obj_ids; - c_file_id = (hid_t)*file_id; - c_obj_type = (unsigned) *obj_type; + c_file_id = (hid_t)*file_id; + c_obj_type = (unsigned)*obj_type; c_max_objs = (size_t)*max_objs; - c_obj_ids = (hid_t *)HDmalloc(sizeof(hid_t)*c_max_objs); + c_obj_ids = (hid_t *)HDmalloc(sizeof(hid_t) * c_max_objs); c_num_objs = H5Fget_obj_ids(c_file_id, c_obj_type, c_max_objs, c_obj_ids); - if(c_num_objs < 0) + if (c_num_objs < 0) ret_value = -1; - for(u = 0; u < c_max_objs; u++) + for (u = 0; u < c_max_objs; u++) obj_ids[u] = (hid_t_f)c_obj_ids[u]; HDfree(c_obj_ids); @@ -533,20 +539,21 @@ h5fget_obj_ids_c ( hid_t_f *file_id , int_f *obj_type, size_t_f *max_objs, * Quincey Koziol * Tuesday, October 7, 2003 * SOURCE -*/ + */ int_f -h5fget_freespace_c ( hid_t_f *file_id , hssize_t_f *free_space) +h5fget_freespace_c(hid_t_f *file_id, hssize_t_f *free_space) /******/ { - int ret_value = 0; - hid_t c_file_id; - hssize_t c_free_space; - - c_file_id = (hid_t)*file_id; - if ( (c_free_space=H5Fget_freespace(c_file_id)) < 0 ) ret_value = -1; - *free_space=(hssize_t_f)c_free_space; - return ret_value; + int ret_value = 0; + hid_t c_file_id; + hssize_t c_free_space; + + c_file_id = (hid_t)*file_id; + if ((c_free_space = H5Fget_freespace(c_file_id)) < 0) + ret_value = -1; + *free_space = (hssize_t_f)c_free_space; + return ret_value; } /****if* H5Ff/h5fget_name_c @@ -566,36 +573,37 @@ h5fget_freespace_c ( hid_t_f *file_id , hssize_t_f *free_space) * Elena Pourmal * Tuesday, July 6, 2004 * SOURCE -*/ + */ int_f h5fget_name_c(hid_t_f *obj_id, size_t_f *size, _fcd buf, size_t_f *buflen) /******/ { - char *c_buf = NULL; /* Buffer to hold C string */ - ssize_t size_c = -1; - int_f ret_value = 0; /* Return value */ - - /* - * Allocate buffer to hold name of an attribute - */ - if(NULL == (c_buf = (char *)HDmalloc((size_t)*buflen + 1))) - HGOTO_DONE(FAIL); - - /* - * Call H5Fget_name function - */ - if ((size_c = H5Fget_name((hid_t)*obj_id, c_buf, (size_t)*buflen)) < 0) - HGOTO_DONE(FAIL); - - /* - * Convert C name to FORTRAN and place it in the given buffer - */ - HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*buflen); + char * c_buf = NULL; /* Buffer to hold C string */ + ssize_t size_c = -1; + int_f ret_value = 0; /* Return value */ + + /* + * Allocate buffer to hold name of an attribute + */ + if (NULL == (c_buf = (char *)HDmalloc((size_t)*buflen + 1))) + HGOTO_DONE(FAIL); + + /* + * Call H5Fget_name function + */ + if ((size_c = H5Fget_name((hid_t)*obj_id, c_buf, (size_t)*buflen)) < 0) + HGOTO_DONE(FAIL); + + /* + * Convert C name to FORTRAN and place it in the given buffer + */ + HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*buflen); done: - *size = (size_t_f)size_c; - if(c_buf) HDfree(c_buf); - return ret_value; + *size = (size_t_f)size_c; + if (c_buf) + HDfree(c_buf); + return ret_value; } /****if* H5Ff/h5fget_filesize_c @@ -613,23 +621,23 @@ done: * Elena Pourmal * Wednesday, July 7, 2004 * SOURCE -*/ + */ int_f h5fget_filesize_c(hid_t_f *file_id, hsize_t_f *size) /******/ { hsize_t size_c; - herr_t ret_value=0; /* Return value */ + herr_t ret_value = 0; /* Return value */ - /* - * Call H5Fget_filesize function - */ - if ((ret_value = H5Fget_filesize((hid_t)*file_id, &size_c)) < 0) - HGOTO_DONE(FAIL); - *size = (hsize_t_f)size_c; + /* + * Call H5Fget_filesize function + */ + if ((ret_value = H5Fget_filesize((hid_t)*file_id, &size_c)) < 0) + HGOTO_DONE(FAIL); + *size = (hsize_t_f)size_c; done: - return ret_value; + return ret_value; } /****if* H5Ff/h5fget_fileno_c @@ -647,23 +655,23 @@ done: * Quincey Koziol * Saturday, April 13, 2019 * SOURCE -*/ + */ int_f h5fget_fileno_c(hid_t_f *file_id, int_f *fileno) /******/ { unsigned long fileno_c; - herr_t ret_value=0; /* Return value */ + herr_t ret_value = 0; /* Return value */ - /* - * Call H5Fget_filesize function - */ - if ((ret_value = H5Fget_fileno((hid_t)*file_id, &fileno_c)) < 0) - HGOTO_DONE(FAIL); - *fileno = (hsize_t_f)fileno_c; + /* + * Call H5Fget_filesize function + */ + if ((ret_value = H5Fget_fileno((hid_t)*file_id, &fileno_c)) < 0) + HGOTO_DONE(FAIL); + *fileno = (hsize_t_f)fileno_c; done: - return ret_value; + return ret_value; } /****if* H5Ff/h5fget_file_image_c @@ -683,22 +691,22 @@ done: * M. Scot Breitenfeld * November 26, 2012 * SOURCE -*/ + */ int_f h5fget_file_image_c(hid_t_f *file_id, void *buf_ptr, size_t_f *buf_len, size_t_f *buf_req) /******/ { - herr_t ret_value=0; /* Return value */ + herr_t ret_value = 0; /* Return value */ ssize_t c_buf_req; /* * Call h5fget_file_image function */ - if ( (c_buf_req = H5Fget_file_image((hid_t)*file_id, buf_ptr, (size_t)*buf_len)) < 0) - HGOTO_DONE(FAIL); + if ((c_buf_req = H5Fget_file_image((hid_t)*file_id, buf_ptr, (size_t)*buf_len)) < 0) + HGOTO_DONE(FAIL); *buf_req = (size_t_f)c_buf_req; done: - return ret_value; + return ret_value; } diff --git a/fortran/src/H5Gf.c b/fortran/src/H5Gf.c index 770752d..1e266e7 100644 --- a/fortran/src/H5Gf.c +++ b/fortran/src/H5Gf.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5Eprivate.h" @@ -44,51 +44,52 @@ * H5Gcreate1 can be compiled out of the library * QAK - 2007/08/23 * SOURCE -*/ + */ int_f -h5gcreate_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *size_hint, - hid_t_f *grp_id, hid_t_f *lcpl_id, hid_t_f *gcpl_id, hid_t_f *gapl_id ) +h5gcreate_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *size_hint, hid_t_f *grp_id, + hid_t_f *lcpl_id, hid_t_f *gcpl_id, hid_t_f *gapl_id) /******/ { - hid_t c_gcpl_id = -1; /* Group creation property list */ - char *c_name = NULL; + hid_t c_gcpl_id = -1; /* Group creation property list */ + char *c_name = NULL; hid_t c_grp_id; int_f ret_value = -1; /* * Convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto DONE; /* * Call H5Gcreate function. */ - if(*size_hint == (size_t_f)OBJECT_NAMELEN_DEFAULT_F ){ - c_grp_id = H5Gcreate2((hid_t)*loc_id, c_name,(hid_t)*lcpl_id,(hid_t)*gcpl_id,(hid_t)*gapl_id);} + if (*size_hint == (size_t_f)OBJECT_NAMELEN_DEFAULT_F) { + c_grp_id = H5Gcreate2((hid_t)*loc_id, c_name, (hid_t)*lcpl_id, (hid_t)*gcpl_id, (hid_t)*gapl_id); + } else { - /* Create the group creation property list */ - if((c_gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) - goto DONE; + /* Create the group creation property list */ + if ((c_gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + goto DONE; - /* Set the local heap size hint */ - if(H5Pset_local_heap_size_hint(c_gcpl_id, (size_t)*size_hint) < 0) - goto DONE; + /* Set the local heap size hint */ + if (H5Pset_local_heap_size_hint(c_gcpl_id, (size_t)*size_hint) < 0) + goto DONE; - /* Create the group */ - c_grp_id = H5Gcreate2((hid_t)*loc_id, c_name, H5P_DEFAULT, c_gcpl_id, H5P_DEFAULT); + /* Create the group */ + c_grp_id = H5Gcreate2((hid_t)*loc_id, c_name, H5P_DEFAULT, c_gcpl_id, H5P_DEFAULT); } - if(c_grp_id < 0) + if (c_grp_id < 0) goto DONE; /* Everything OK, set values to return */ - *grp_id = (hid_t_f)c_grp_id; + *grp_id = (hid_t_f)c_grp_id; ret_value = 0; DONE: - if(c_gcpl_id > 0) + if (c_gcpl_id > 0) H5Pclose(c_gcpl_id); - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -112,35 +113,35 @@ DONE: * Wednesday, August 5, 1999 * * SOURCE -*/ + */ int_f h5gopen_c(hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *gapl_id, hid_t_f *grp_id) /******/ { - char *c_name = NULL; - hid_t c_grp_id; - int ret_value = -1; - - /* - * Convert FORTRAN name to C name - */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + char *c_name = NULL; + hid_t c_grp_id; + int ret_value = -1; + + /* + * Convert FORTRAN name to C name + */ + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto DONE; - /* - * Call H5Gopen function. - */ - if((c_grp_id = H5Gopen2((hid_t)*loc_id, c_name, (hid_t)*gapl_id)) < 0) + /* + * Call H5Gopen function. + */ + if ((c_grp_id = H5Gopen2((hid_t)*loc_id, c_name, (hid_t)*gapl_id)) < 0) goto DONE; /* Everything OK, set values to return */ - *grp_id = (hid_t_f)c_grp_id; + *grp_id = (hid_t_f)c_grp_id; ret_value = 0; DONE: - if(c_name) - HDfree(c_name); - return ret_value; + if (c_name) + HDfree(c_name); + return ret_value; } /****if* H5Gf/h5gget_obj_info_idx_c @@ -164,48 +165,50 @@ DONE: * Elena Pourmal * Wednesday, August 5, 1999 * SOURCE -*/ + */ int_f -h5gget_obj_info_idx_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *idx, - _fcd obj_name, int_f *obj_namelen, int_f *obj_type) +h5gget_obj_info_idx_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *idx, _fcd obj_name, + int_f *obj_namelen, int_f *obj_type) /******/ { H5O_info2_t oinfo; - hid_t c_loc_id = (hid_t)*loc_id; - char *c_name = NULL; - size_t c_obj_namelen; - char *c_obj_name = NULL; - hsize_t c_idx = (hsize_t)*idx; - hid_t gid = (-1); /* Temporary group ID */ - int ret_value = -1; + hid_t c_loc_id = (hid_t)*loc_id; + char * c_name = NULL; + size_t c_obj_namelen; + char * c_obj_name = NULL; + hsize_t c_idx = (hsize_t)*idx; + hid_t gid = (-1); /* Temporary group ID */ + int ret_value = -1; /* * Convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto DONE; /* * Allocate buffer to hold name of the object */ c_obj_namelen = (size_t)*obj_namelen; - if(c_obj_namelen) - if(NULL == (c_obj_name = (char *)HDmalloc(c_obj_namelen + 1))) - goto DONE; + if (c_obj_namelen) + if (NULL == (c_obj_name = (char *)HDmalloc(c_obj_namelen + 1))) + goto DONE; /* Get a temporary group ID for the group to query */ - if((gid = H5Gopen2(c_loc_id, c_name, H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(c_loc_id, c_name, H5P_DEFAULT)) < 0) goto DONE; /* Query the object's information */ - if(H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, c_idx, c_obj_name, c_obj_namelen, H5P_DEFAULT) < 0) + if (H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, c_idx, c_obj_name, c_obj_namelen, + H5P_DEFAULT) < 0) goto DONE; - if(H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, c_idx, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + if (H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, c_idx, &oinfo, H5O_INFO_BASIC, + H5P_DEFAULT) < 0) goto DONE; -/* XXX: Switch from using H5Gget_objtype_by_idx() means that this routine won't - * work on non-hard links - QAK - */ + /* XXX: Switch from using H5Gget_objtype_by_idx() means that this routine won't + * work on non-hard links - QAK + */ *obj_type = oinfo.type; /* @@ -216,12 +219,12 @@ h5gget_obj_info_idx_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *idx, DONE: /* Close the temporary group, if it was opened */ - if(gid > 0) + if (gid > 0) H5Gclose(gid); - if(c_obj_name) + if (c_obj_name) HDfree(c_obj_name); - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -243,30 +246,30 @@ DONE: * Elena Pourmal * Wednesday, August 5, 1999 * SOURCE -*/ + */ int_f h5gn_members_c(hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *nmembers) /******/ { - char *c_name = NULL; + char * c_name = NULL; H5G_info_t ginfo; - int ret_value = -1; + int ret_value = -1; /* * Convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto DONE; /* Call H5Gget_info_by_name() for the number of objects in the group */ - if(H5Gget_info_by_name((hid_t)*loc_id, c_name, &ginfo, H5P_DEFAULT) < 0) + if (H5Gget_info_by_name((hid_t)*loc_id, c_name, &ginfo, H5P_DEFAULT) < 0) goto DONE; *nmembers = (int_f)ginfo.nlinks; ret_value = 0; DONE: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -284,7 +287,7 @@ DONE: * Elena Pourmal * Wednesday, August 5, 1999 * SOURCE -*/ + */ int_f h5gclose_c(hid_t_f *grp_id) @@ -292,12 +295,11 @@ h5gclose_c(hid_t_f *grp_id) { int ret_value = 0; - if(H5Gclose((hid_t)*grp_id) < 0) + if (H5Gclose((hid_t)*grp_id) < 0) ret_value = -1; return ret_value; } - /****if* H5Gf/h5glink_c * NAME * h5glink_c @@ -317,67 +319,68 @@ h5gclose_c(hid_t_f *grp_id) * Mingshi Chen * Friday, August 6, 1999 * SOURCE -*/ + */ int_f -h5glink_c(hid_t_f *loc_id, int_f *link_type, _fcd current_name, - int_f *current_namelen, _fcd new_name, int_f *new_namelen) +h5glink_c(hid_t_f *loc_id, int_f *link_type, _fcd current_name, int_f *current_namelen, _fcd new_name, + int_f *new_namelen) /******/ { char *c_current_name = NULL, *c_new_name = NULL; - int ret_value = -1; + int ret_value = -1; /* - * Convert Fortran name to C name - */ - if(NULL == (c_current_name = (char *)HD5f2cstring(current_name, (size_t)*current_namelen))) + * Convert Fortran name to C name + */ + if (NULL == (c_current_name = (char *)HD5f2cstring(current_name, (size_t)*current_namelen))) goto DONE; - if(NULL == (c_new_name = (char *)HD5f2cstring(new_name, (size_t)*new_namelen))) + if (NULL == (c_new_name = (char *)HD5f2cstring(new_name, (size_t)*new_namelen))) goto DONE; /* - * Call appropriate link creation function - */ - switch((H5L_type_t)*link_type) { + * Call appropriate link creation function + */ + switch ((H5L_type_t)*link_type) { case H5L_TYPE_HARD: - if(H5Lcreate_hard((hid_t)*loc_id, c_current_name, H5L_SAME_LOC, c_new_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard((hid_t)*loc_id, c_current_name, H5L_SAME_LOC, c_new_name, H5P_DEFAULT, + H5P_DEFAULT) < 0) goto DONE; break; case H5L_TYPE_SOFT: - if(H5Lcreate_soft(c_current_name, (hid_t)*loc_id, c_new_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft(c_current_name, (hid_t)*loc_id, c_new_name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto DONE; break; - /* Cases below were added to remove the warnings in gcc 4.9.2 and probably other */ + /* Cases below were added to remove the warnings in gcc 4.9.2 and probably other */ case H5L_TYPE_EXTERNAL: ret_value = -1; - goto DONE; + goto DONE; break; case H5L_TYPE_MAX: ret_value = -1; - goto DONE; + goto DONE; break; case H5L_TYPE_ERROR: ret_value = -1; - goto DONE; + goto DONE; break; - /* End of the warnings fix */ + /* End of the warnings fix */ - default: /* Unknown/unhandled link type */ + default: /* Unknown/unhandled link type */ goto DONE; } /* end switch */ ret_value = 0; DONE: - if(c_current_name) + if (c_current_name) HDfree(c_current_name); - if(c_new_name) + if (c_new_name) HDfree(c_new_name); - return ret_value ; + return ret_value; } /****if* H5Gf/h5glink2_c @@ -404,65 +407,66 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5glink2_c(hid_t_f *cur_loc_id, _fcd cur_name, int_f *cur_namelen, - int_f *link_type, hid_t_f *new_loc_id, _fcd new_name, int_f *new_namelen) +h5glink2_c(hid_t_f *cur_loc_id, _fcd cur_name, int_f *cur_namelen, int_f *link_type, hid_t_f *new_loc_id, + _fcd new_name, int_f *new_namelen) /******/ { char *c_cur_name = NULL, *c_new_name = NULL; - int ret_value = -1; + int ret_value = -1; /* * Convert Fortran name to C name */ - if(NULL == (c_cur_name = (char *)HD5f2cstring(cur_name, (size_t)*cur_namelen))) + if (NULL == (c_cur_name = (char *)HD5f2cstring(cur_name, (size_t)*cur_namelen))) goto DONE; - if(NULL == (c_new_name = (char *)HD5f2cstring(new_name, (size_t)*new_namelen))) + if (NULL == (c_new_name = (char *)HD5f2cstring(new_name, (size_t)*new_namelen))) goto DONE; /* - * Call appropriate link creation function - */ - switch((H5L_type_t)*link_type) { + * Call appropriate link creation function + */ + switch ((H5L_type_t)*link_type) { case H5L_TYPE_HARD: - if(H5Lcreate_hard((hid_t)*cur_loc_id, c_cur_name, (hid_t)*new_loc_id, c_new_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard((hid_t)*cur_loc_id, c_cur_name, (hid_t)*new_loc_id, c_new_name, H5P_DEFAULT, + H5P_DEFAULT) < 0) goto DONE; break; case H5L_TYPE_SOFT: - if(H5Lcreate_soft(c_cur_name, (hid_t)*new_loc_id, c_new_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft(c_cur_name, (hid_t)*new_loc_id, c_new_name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto DONE; break; - /* Cases below were added to remove the warnings in gcc 4.9.2 and probably other */ + /* Cases below were added to remove the warnings in gcc 4.9.2 and probably other */ case H5L_TYPE_EXTERNAL: ret_value = -1; - goto DONE; + goto DONE; break; case H5L_TYPE_MAX: ret_value = -1; - goto DONE; + goto DONE; break; case H5L_TYPE_ERROR: ret_value = -1; - goto DONE; + goto DONE; break; - /* End of the warnings fix */ + /* End of the warnings fix */ - default: /* Unknown/unhandled link type */ + default: /* Unknown/unhandled link type */ goto DONE; } /* end switch */ ret_value = 0; DONE: - if(c_cur_name) + if (c_cur_name) HDfree(c_cur_name); - if(c_new_name) + if (c_new_name) HDfree(c_new_name); - return ret_value ; + return ret_value; } /****if* H5Gf/h5gunlink_c @@ -479,30 +483,30 @@ DONE: * Mingshi Chen * Friday, August 6, 1999 * SOURCE -*/ + */ int_f h5gunlink_c(hid_t_f *loc_id, _fcd name, int_f *namelen) /******/ { - char *c_name = NULL; - int ret_value = -1; + char *c_name = NULL; + int ret_value = -1; /* * Convert Fortran name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto DONE; /* * Call H5Gunlink function */ - if(H5Ldelete((hid_t)*loc_id, c_name, H5P_DEFAULT) < 0) + if (H5Ldelete((hid_t)*loc_id, c_name, H5P_DEFAULT) < 0) goto DONE; ret_value = 0; DONE: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -524,35 +528,35 @@ DONE: * Mingshi Chen * Friday, August 6, 1999 * SOURCE -*/ + */ int_f -h5gmove_c(hid_t_f *loc_id, _fcd src_name, int_f *src_namelen, _fcd dst_name, int_f*dst_namelen) +h5gmove_c(hid_t_f *loc_id, _fcd src_name, int_f *src_namelen, _fcd dst_name, int_f *dst_namelen) /******/ { char *c_src_name = NULL, *c_dst_name = NULL; - int ret_value = -1; + int ret_value = -1; /* * Convert Fortran name to C name */ - if(NULL == (c_src_name = (char *)HD5f2cstring(src_name, (size_t)*src_namelen))) + if (NULL == (c_src_name = (char *)HD5f2cstring(src_name, (size_t)*src_namelen))) goto DONE; - if(NULL == (c_dst_name = (char *)HD5f2cstring(dst_name, (size_t)*dst_namelen))) + if (NULL == (c_dst_name = (char *)HD5f2cstring(dst_name, (size_t)*dst_namelen))) goto DONE; /* * Call H5Gmove function */ - if(H5Lmove((hid_t)*loc_id, c_src_name, H5L_SAME_LOC, c_dst_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lmove((hid_t)*loc_id, c_src_name, H5L_SAME_LOC, c_dst_name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto DONE; ret_value = 0; DONE: - if(c_src_name) + if (c_src_name) HDfree(c_src_name); - if(c_dst_name) + if (c_dst_name) HDfree(c_dst_name); return ret_value; } @@ -576,35 +580,36 @@ DONE: * Wednesday, September 25, 2002 * * SOURCE -*/ + */ int_f -h5gmove2_c(hid_t_f *src_loc_id, _fcd src_name, int_f *src_namelen, hid_t_f *dst_loc_id, _fcd dst_name, int_f*dst_namelen) +h5gmove2_c(hid_t_f *src_loc_id, _fcd src_name, int_f *src_namelen, hid_t_f *dst_loc_id, _fcd dst_name, + int_f *dst_namelen) /******/ { char *c_src_name = NULL, *c_dst_name = NULL; - int ret_value = -1; + int ret_value = -1; /* * Convert Fortran name to C name */ - if(NULL == (c_src_name = (char *)HD5f2cstring(src_name, (size_t)*src_namelen))) + if (NULL == (c_src_name = (char *)HD5f2cstring(src_name, (size_t)*src_namelen))) goto DONE; - if(NULL == (c_dst_name = (char *)HD5f2cstring(dst_name, (size_t)*dst_namelen))) + if (NULL == (c_dst_name = (char *)HD5f2cstring(dst_name, (size_t)*dst_namelen))) goto DONE; /* * Call H5Gmove2 function */ - if(H5Lmove((hid_t)*src_loc_id, c_src_name, (hid_t)*dst_loc_id, c_dst_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lmove((hid_t)*src_loc_id, c_src_name, (hid_t)*dst_loc_id, c_dst_name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto DONE; ret_value = 0; DONE: - if(c_src_name) + if (c_src_name) HDfree(c_src_name); - if(c_dst_name) + if (c_dst_name) HDfree(c_dst_name); return ret_value; } @@ -627,37 +632,37 @@ DONE: * Mingshi Chen * Friday, August 6, 1999 * SOURCE -*/ + */ int_f -h5gget_linkval_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *size, - _fcd value) +h5gget_linkval_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *size, _fcd value) /******/ { - char *c_name = NULL; - char *c_value = NULL; - int ret_value = -1; + char *c_name = NULL; + char *c_value = NULL; + int ret_value = -1; /* * Convert Fortran name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto DONE; /* * Allocate buffer to hold name of the value */ - if(*size) c_value = (char *)HDmalloc((size_t)*size); - if(c_value == NULL) { - HDfree(c_name); - return ret_value; - } + if (*size) + c_value = (char *)HDmalloc((size_t)*size); + if (c_value == NULL) { + HDfree(c_name); + return ret_value; + } /* * Call H5Lget_val function */ - if(H5Lget_val((hid_t)*loc_id, c_name, c_value, (size_t)*size, H5P_DEFAULT) < 0) - goto DONE; + if (H5Lget_val((hid_t)*loc_id, c_name, c_value, (size_t)*size, H5P_DEFAULT) < 0) + goto DONE; /* * Convert C name to FORTRAN and place it in the given buffer @@ -666,9 +671,9 @@ h5gget_linkval_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *size, ret_value = 0; DONE: - if(c_value) + if (c_value) HDfree(c_value); - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -692,34 +697,33 @@ DONE: * HISTORY * Elena Pourmal * SOURCE -*/ + */ int_f -h5gset_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, _fcd comment, - int_f *commentlen) +h5gset_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, _fcd comment, int_f *commentlen) /******/ { char *c_name = NULL, *c_comment = NULL; - int ret_value = -1; + int ret_value = -1; /* * Convert Fortran name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto DONE; - if(NULL == (c_comment = (char *)HD5f2cstring(comment, (size_t)*commentlen))) + if (NULL == (c_comment = (char *)HD5f2cstring(comment, (size_t)*commentlen))) goto DONE; /* * Call H5Oset_comment_by_name function */ - if(H5Oset_comment_by_name((hid_t)*loc_id, c_name, c_comment, H5P_DEFAULT) < 0) + if (H5Oset_comment_by_name((hid_t)*loc_id, c_name, c_comment, H5P_DEFAULT) < 0) goto DONE; ret_value = 0; DONE: - if(c_name) + if (c_name) HDfree(c_name); - if(c_comment) + if (c_comment) HDfree(c_comment); return ret_value; } @@ -741,47 +745,46 @@ DONE: * Mingshi Chen * Friday, August 6, 1999 * SOURCE -*/ + */ int_f -h5gget_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *bufsize, - _fcd comment) +h5gget_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *bufsize, _fcd comment) /******/ { - char *c_name = NULL, *c_comment = NULL; + char * c_name = NULL, *c_comment = NULL; size_t c_bufsize; - int ret_value = -1; + int ret_value = -1; /* * Convert Fortran name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto DONE; /* * Allocate buffer to hold the comment */ c_bufsize = (size_t)*bufsize; - if(c_bufsize) { - if(NULL == (c_comment = (char *)HDmalloc(c_bufsize + 1))) + if (c_bufsize) { + if (NULL == (c_comment = (char *)HDmalloc(c_bufsize + 1))) goto DONE; } /* end if */ /* * Call H5Oget_comment_by_name function */ - if(H5Oget_comment_by_name((hid_t)*loc_id, c_name, c_comment, c_bufsize, H5P_DEFAULT) < 0) + if (H5Oget_comment_by_name((hid_t)*loc_id, c_name, c_comment, c_bufsize, H5P_DEFAULT) < 0) goto DONE; /* - * Convert C name to FORTRAN and place it in the given buffer - */ + * Convert C name to FORTRAN and place it in the given buffer + */ HD5packFstring(c_comment, _fcdtocp(comment), c_bufsize); ret_value = 0; DONE: - if(c_name) + if (c_name) HDfree(c_name); - if(c_comment) + if (c_comment) HDfree(c_comment); return ret_value; } @@ -805,16 +808,16 @@ DONE: * M. Scot Breitenfeld * February 15, 2008 * SOURCE -*/ + */ int_f h5gcreate_anon_c(hid_t_f *loc_id, hid_t_f *gcpl_id, hid_t_f *gapl_id, hid_t_f *grp_id) /******/ { - int_f ret_value=0; /* Return value */ + int_f ret_value = 0; /* Return value */ - if ((*grp_id = (hid_t_f)H5Gcreate_anon((hid_t)*loc_id,(hid_t)*gcpl_id,(hid_t)*gapl_id)) < 0) - HGOTO_DONE(FAIL); + if ((*grp_id = (hid_t_f)H5Gcreate_anon((hid_t)*loc_id, (hid_t)*gcpl_id, (hid_t)*gapl_id)) < 0) + HGOTO_DONE(FAIL); done: return ret_value; @@ -837,21 +840,20 @@ done: * M. Scot Breitenfeld * February 15, 2008 * SOURCE -*/ + */ int_f -h5gget_create_plist_c(hid_t_f *grp_id, hid_t_f *gcpl_id ) +h5gget_create_plist_c(hid_t_f *grp_id, hid_t_f *gcpl_id) /******/ { - int_f ret_value=0; /* Return value */ + int_f ret_value = 0; /* Return value */ - if ((*gcpl_id = (hid_t_f)H5Gget_create_plist((hid_t)*grp_id)) < 0) - HGOTO_DONE(FAIL); + if ((*gcpl_id = (hid_t_f)H5Gget_create_plist((hid_t)*grp_id)) < 0) + HGOTO_DONE(FAIL); done: return ret_value; } - /****if* H5Gf/h5gget_info_c * NAME * h5gget_info_c @@ -881,34 +883,34 @@ done: * M. Scot Breitenfeld * July 16, 2008 * SOURCE -*/ + */ int_f -h5gget_info_c (hid_t_f *group_id, int_f *storage_type, int_f *nlinks, int_f *max_corder, int_f *mounted ) +h5gget_info_c(hid_t_f *group_id, int_f *storage_type, int_f *nlinks, int_f *max_corder, int_f *mounted) /******/ { - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ H5G_info_t ginfo; - /* - * Call H5Gget_info function. - */ - if(H5Gget_info((hid_t)*group_id,&ginfo) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Gget_info function. + */ + if (H5Gget_info((hid_t)*group_id, &ginfo) < 0) + HGOTO_DONE(FAIL); /* Unpack the structure */ *storage_type = (int_f)ginfo.storage_type; - *nlinks = (int_f)ginfo.nlinks; - *max_corder = (int_f)ginfo.max_corder; - *mounted = 0; - if(ginfo.mounted) *mounted = 1; + *nlinks = (int_f)ginfo.nlinks; + *max_corder = (int_f)ginfo.max_corder; + *mounted = 0; + if (ginfo.mounted) + *mounted = 1; done: return ret_value; } - /****if* H5Gf/h5gget_info_by_idx_c * NAME * h5gget_info_by_idx_c @@ -945,41 +947,42 @@ done: * M. Scot Breitenfeld * July 16, 2008 * SOURCE -*/ + */ int_f -h5gget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, - int_f *index_type, int_f *order, hsize_t_f *n, hid_t_f *lapl_id, - int_f *storage_type, int_f *nlinks, int_f *max_corder, int_f *mounted ) +h5gget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, int_f *index_type, + int_f *order, hsize_t_f *n, hid_t_f *lapl_id, int_f *storage_type, int_f *nlinks, + int_f *max_corder, int_f *mounted) /******/ { - char *c_group_name = NULL; /* Buffer to hold group name C string */ - int_f ret_value = 0; /* Return value */ - H5G_info_t ginfo; - /* - * Convert FORTRAN name to C name - */ - if((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Gget_info_by_idx function. - */ - if(H5Gget_info_by_idx((hid_t)*loc_id,c_group_name, (H5_index_t)*index_type,(H5_iter_order_t)*order,(hsize_t)*n, - &ginfo, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); - - /* Unpack the structure */ - - *storage_type = (int_f)ginfo.storage_type; - *nlinks = (int_f)ginfo.nlinks; - *max_corder = (int_f)ginfo.max_corder; - *mounted = 0; - if(ginfo.mounted) *mounted = 1; - - done: - if(c_group_name) - HDfree(c_group_name); - return ret_value; + char * c_group_name = NULL; /* Buffer to hold group name C string */ + int_f ret_value = 0; /* Return value */ + H5G_info_t ginfo; + /* + * Convert FORTRAN name to C name + */ + if ((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Gget_info_by_idx function. + */ + if (H5Gget_info_by_idx((hid_t)*loc_id, c_group_name, (H5_index_t)*index_type, (H5_iter_order_t)*order, + (hsize_t)*n, &ginfo, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); + + /* Unpack the structure */ + + *storage_type = (int_f)ginfo.storage_type; + *nlinks = (int_f)ginfo.nlinks; + *max_corder = (int_f)ginfo.max_corder; + *mounted = 0; + if (ginfo.mounted) + *mounted = 1; + +done: + if (c_group_name) + HDfree(c_group_name); + return ret_value; } /****if* H5Gf/h5gget_info_by_name_c @@ -1015,37 +1018,38 @@ h5gget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, * M. Scot Breitenfeld * July 16, 2008 * SOURCE -*/ + */ int_f h5gget_info_by_name_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, hid_t_f *lapl_id, - int_f *storage_type, int_f *nlinks, int_f *max_corder, int_f *mounted) + int_f *storage_type, int_f *nlinks, int_f *max_corder, int_f *mounted) /******/ { - char *c_group_name = NULL; /* Buffer to hold group name C string */ - int_f ret_value = 0; /* Return value */ - H5G_info_t ginfo; - /* - * Convert FORTRAN name to C name - */ - if((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Gget_info_by_name function. - */ - if(H5Gget_info_by_name((hid_t)*loc_id, c_group_name, &ginfo, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); - - /* Unpack the structure */ - - *storage_type = (int_f)ginfo.storage_type; - *nlinks = (int_f)ginfo.nlinks; - *max_corder = (int_f)ginfo.max_corder; - *mounted = 0; - if(ginfo.mounted) *mounted = 1; - - done: - if(c_group_name) - HDfree(c_group_name); - return ret_value; + char * c_group_name = NULL; /* Buffer to hold group name C string */ + int_f ret_value = 0; /* Return value */ + H5G_info_t ginfo; + /* + * Convert FORTRAN name to C name + */ + if ((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Gget_info_by_name function. + */ + if (H5Gget_info_by_name((hid_t)*loc_id, c_group_name, &ginfo, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); + + /* Unpack the structure */ + + *storage_type = (int_f)ginfo.storage_type; + *nlinks = (int_f)ginfo.nlinks; + *max_corder = (int_f)ginfo.max_corder; + *mounted = 0; + if (ginfo.mounted) + *mounted = 1; + +done: + if (c_group_name) + HDfree(c_group_name); + return ret_value; } diff --git a/fortran/src/H5If.c b/fortran/src/H5If.c index 8222817..1b44924 100644 --- a/fortran/src/H5If.c +++ b/fortran/src/H5If.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5Eprivate.h" @@ -38,24 +38,25 @@ * HISTORY * * SOURCE -*/ + */ int_f -h5iget_type_c (hid_t_f *obj_id, int_f *type) +h5iget_type_c(hid_t_f *obj_id, int_f *type) /******/ { - int ret_value = -1; - hid_t c_obj_id; - H5I_type_t c_type; + int ret_value = -1; + hid_t c_obj_id; + H5I_type_t c_type; - /* - * Call H5Iget_type function. - */ - c_obj_id = *obj_id; - c_type = H5Iget_type(c_obj_id); - if (c_type == H5I_BADID) return ret_value; - *type = (int_f)c_type; - ret_value = 0; - return ret_value; + /* + * Call H5Iget_type function. + */ + c_obj_id = *obj_id; + c_type = H5Iget_type(c_obj_id); + if (c_type == H5I_BADID) + return ret_value; + *type = (int_f)c_type; + ret_value = 0; + return ret_value; } /****if* H5If/h5iget_name_c * NAME @@ -79,41 +80,43 @@ h5iget_type_c (hid_t_f *obj_id, int_f *type) * exact size of the string (buf_size) is passed in. * M. Scot Breitenfeld, April 21, 2008 * SOURCE -*/ + */ int_f h5iget_name_c(hid_t_f *obj_id, _fcd buf, size_t_f *buf_size, size_t_f *name_size) /******/ { - int ret_value = -1; - hid_t c_obj_id; - ssize_t c_size; - size_t c_buf_size; - char *c_buf =NULL; + int ret_value = -1; + hid_t c_obj_id; + ssize_t c_size; + size_t c_buf_size; + char * c_buf = NULL; - /* - * Allocate buffer to hold name of an object - */ - c_buf_size = (size_t)*buf_size +1; - c_buf = (char *)HDmalloc(c_buf_size); - if (c_buf == NULL) return ret_value; + /* + * Allocate buffer to hold name of an object + */ + c_buf_size = (size_t)*buf_size + 1; + c_buf = (char *)HDmalloc(c_buf_size); + if (c_buf == NULL) + return ret_value; - /* - * Call H5IAget_name function - */ - c_obj_id = (hid_t)*obj_id; - c_size = H5Iget_name(c_obj_id, c_buf, c_buf_size); - if (c_size < 0) goto DONE; + /* + * Call H5IAget_name function + */ + c_obj_id = (hid_t)*obj_id; + c_size = H5Iget_name(c_obj_id, c_buf, c_buf_size); + if (c_size < 0) + goto DONE; - /* - * Convert C name to FORTRAN and place it in the given buffer - */ - HD5packFstring(c_buf, _fcdtocp(buf), c_buf_size-1); - *name_size = (size_t_f)c_size; - ret_value = 0; + /* + * Convert C name to FORTRAN and place it in the given buffer + */ + HD5packFstring(c_buf, _fcdtocp(buf), c_buf_size - 1); + *name_size = (size_t_f)c_size; + ret_value = 0; DONE: - HDfree(c_buf); - return ret_value; + HDfree(c_buf); + return ret_value; } /****if* H5If/h5iinc_ref_c @@ -131,25 +134,25 @@ DONE: * Quincey Koziol * Tuesday, December 9, 2003 * SOURCE -*/ + */ int_f h5iinc_ref_c(hid_t_f *obj_id, int_f *ref_count) /******/ { - int ret_value; + int ret_value; - /* - * Call H5Iinc_ref function - */ - if ((ret_value = H5Iinc_ref(*obj_id)) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Iinc_ref function + */ + if ((ret_value = H5Iinc_ref(*obj_id)) < 0) + HGOTO_DONE(FAIL); /* Set output & return values */ - *ref_count=ret_value; - ret_value=0; + *ref_count = ret_value; + ret_value = 0; done: - return ret_value; + return ret_value; } /****if* H5If/h5idec_ref_c @@ -167,25 +170,25 @@ done: * Quincey Koziol * Tuesday, December 9, 2003 * SOURCE -*/ + */ int_f h5idec_ref_c(hid_t_f *obj_id, int_f *ref_count) /******/ { - int ret_value; + int ret_value; - /* - * Call H5Idec_ref function - */ - if ((ret_value = H5Idec_ref(*obj_id)) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Idec_ref function + */ + if ((ret_value = H5Idec_ref(*obj_id)) < 0) + HGOTO_DONE(FAIL); /* Set output & return values */ - *ref_count=ret_value; - ret_value=0; + *ref_count = ret_value; + ret_value = 0; done: - return ret_value; + return ret_value; } /****if* H5If/h5iget_ref_c @@ -204,25 +207,25 @@ done: * Tuesday, December 9, 2003 * * SOURCE -*/ + */ int_f h5iget_ref_c(hid_t_f *obj_id, int_f *ref_count) /******/ { - int ret_value; + int ret_value; - /* - * Call H5Iget_ref function - */ - if ((ret_value = H5Iget_ref(*obj_id)) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Iget_ref function + */ + if ((ret_value = H5Iget_ref(*obj_id)) < 0) + HGOTO_DONE(FAIL); /* Set output & return values */ - *ref_count=ret_value; - ret_value=0; + *ref_count = ret_value; + ret_value = 0; done: - return ret_value; + return ret_value; } /****if* H5If/h5iget_file_id_c @@ -241,26 +244,26 @@ done: * Tuesday, August 24, 2004 * * SOURCE -*/ + */ int_f h5iget_file_id_c(hid_t_f *obj_id, hid_t_f *file_id) /******/ { - int ret_value; - hid_t c_file_id; + int ret_value; + hid_t c_file_id; - /* - * Call H5Iget_file_id - */ - if ((c_file_id = H5Iget_file_id(*obj_id)) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Iget_file_id + */ + if ((c_file_id = H5Iget_file_id(*obj_id)) < 0) + HGOTO_DONE(FAIL); /* Set output & return values */ - *file_id=(hid_t_f)c_file_id; - ret_value=0; + *file_id = (hid_t_f)c_file_id; + ret_value = 0; done: - return ret_value; + return ret_value; } /*---------------------------------------------------------------------------- @@ -276,19 +279,19 @@ done: int_f h5iis_valid_c(hid_t_f *obj_id, int_f *c_valid) { - int ret_value; - htri_t c_ret_value; + int ret_value; + htri_t c_ret_value; - /* - * Call H5Iis_valid - */ - if ((c_ret_value = H5Iis_valid(*obj_id)) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Iis_valid + */ + if ((c_ret_value = H5Iis_valid(*obj_id)) < 0) + HGOTO_DONE(FAIL); - /* Set output & return values */ - *c_valid = (int_f)c_ret_value; - ret_value=0; + /* Set output & return values */ + *c_valid = (int_f)c_ret_value; + ret_value = 0; done: - return ret_value; + return ret_value; } diff --git a/fortran/src/H5Lf.c b/fortran/src/H5Lf.c index 1fee5e8..2614c10 100644 --- a/fortran/src/H5Lf.c +++ b/fortran/src/H5Lf.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5Eprivate.h" @@ -48,40 +48,39 @@ * HISTORY * * SOURCE -*/ + */ int_f -h5lcopy_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *dest_loc_id, - _fcd dest_name, size_t_f *dest_namelen, - hid_t_f *lcpl_id, hid_t_f *lapl_id) +h5lcopy_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *dest_loc_id, _fcd dest_name, + size_t_f *dest_namelen, hid_t_f *lcpl_id, hid_t_f *lapl_id) /******/ { - char *c_src_name = NULL; + char *c_src_name = NULL; char *c_dest_name = NULL; - int_f ret_value = 0; + int_f ret_value = 0; /* * Convert FORTRAN name to C name */ - if(NULL == (c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen))) + if (NULL == (c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen))) + if (NULL == (c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen))) HGOTO_DONE(FAIL) /* * Call H5Lcopy function. */ - if(H5Lcopy((hid_t)*src_loc_id, c_src_name, (hid_t) *dest_loc_id, - c_dest_name, (hid_t)*lcpl_id, (hid_t)*lapl_id ) < 0) + if (H5Lcopy((hid_t)*src_loc_id, c_src_name, (hid_t)*dest_loc_id, c_dest_name, (hid_t)*lcpl_id, + (hid_t)*lapl_id) < 0) HGOTO_DONE(FAIL) done: - if(c_src_name) + if (c_src_name) HDfree(c_src_name); - if(c_dest_name) + if (c_dest_name) HDfree(c_dest_name); - return ret_value; + return ret_value; } /****if* H5Lf/h5lcreate_external_c @@ -105,45 +104,45 @@ done: * M. Scot Breitenfeld * February 29, 2008 * SOURCE -*/ + */ int_f h5lcreate_external_c(_fcd file_name, size_t_f *file_namelen, _fcd obj_name, size_t_f *obj_namelen, - hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, - hid_t_f *lcpl_id, hid_t_f *lapl_id) + hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, hid_t_f *lcpl_id, + hid_t_f *lapl_id) /******/ { - char *c_file_name = NULL; - char *c_obj_name = NULL; - char *c_link_name = NULL; - int_f ret_value = 0; - - /* - * Convert FORTRAN name to C name - */ - if((c_file_name = HD5f2cstring(file_name, (size_t)*file_namelen)) == NULL) - HGOTO_DONE(FAIL); - if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) - HGOTO_DONE(FAIL); - if((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Lcopy function. - */ - if( H5Lcreate_external( c_file_name, c_obj_name, (hid_t) *link_loc_id, c_link_name, - (hid_t) *lcpl_id, (hid_t) *lapl_id) < 0) - HGOTO_DONE(FAIL); + char *c_file_name = NULL; + char *c_obj_name = NULL; + char *c_link_name = NULL; + int_f ret_value = 0; + + /* + * Convert FORTRAN name to C name + */ + if ((c_file_name = HD5f2cstring(file_name, (size_t)*file_namelen)) == NULL) + HGOTO_DONE(FAIL); + if ((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) + HGOTO_DONE(FAIL); + if ((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Lcopy function. + */ + if (H5Lcreate_external(c_file_name, c_obj_name, (hid_t)*link_loc_id, c_link_name, (hid_t)*lcpl_id, + (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); done: - if(c_file_name) - HDfree(c_file_name); - if(c_obj_name) - HDfree(c_obj_name); - if(c_link_name) - HDfree(c_link_name); - - return ret_value; + if (c_file_name) + HDfree(c_file_name); + if (c_obj_name) + HDfree(c_obj_name); + if (c_link_name) + HDfree(c_link_name); + + return ret_value; } /****if* H5Lf/h5ldelete_c @@ -165,29 +164,29 @@ done: * M. Scot Breitenfeld * January, 2008 * SOURCE -*/ + */ int_f -h5ldelete_c ( hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id ) +h5ldelete_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id) /******/ { - char *c_name = NULL; - int_f ret_value = 0; + char *c_name = NULL; + int_f ret_value = 0; - /* - * Convert FORTRAN name to C name - */ - if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); + /* + * Convert FORTRAN name to C name + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); - /* - * Call H5Ldelete function. - */ - if( H5Ldelete( (hid_t)*loc_id, c_name, (hid_t)*lapl_id ) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Ldelete function. + */ + if (H5Ldelete((hid_t)*loc_id, c_name, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; @@ -213,37 +212,35 @@ done: * M. Scot Breitenfeld * February 20, 2008 * SOURCE -*/ + */ int_f -h5lcreate_soft_c(_fcd target_path, size_t_f *target_path_len, - hid_t_f *link_loc_id, - _fcd link_name, size_t_f *link_name_len, - hid_t_f *lcpl_id, hid_t_f *lapl_id ) +h5lcreate_soft_c(_fcd target_path, size_t_f *target_path_len, hid_t_f *link_loc_id, _fcd link_name, + size_t_f *link_name_len, hid_t_f *lcpl_id, hid_t_f *lapl_id) /******/ { - char *c_target_path = NULL; - char *c_link_name = NULL; - int_f ret_value = 0; - - /* - * Convert FORTRAN name to C name - */ - if((c_target_path = HD5f2cstring(target_path, (size_t)*target_path_len)) == NULL) - HGOTO_DONE(FAIL); - if((c_link_name = HD5f2cstring(link_name, (size_t)*link_name_len)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Adelete function. - */ - if ( H5Lcreate_soft(c_target_path,(hid_t)*link_loc_id, c_link_name, (hid_t)*lcpl_id, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_target_path) + char *c_target_path = NULL; + char *c_link_name = NULL; + int_f ret_value = 0; + + /* + * Convert FORTRAN name to C name + */ + if ((c_target_path = HD5f2cstring(target_path, (size_t)*target_path_len)) == NULL) + HGOTO_DONE(FAIL); + if ((c_link_name = HD5f2cstring(link_name, (size_t)*link_name_len)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Adelete function. + */ + if (H5Lcreate_soft(c_target_path, (hid_t)*link_loc_id, c_link_name, (hid_t)*lcpl_id, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_target_path) HDfree(c_target_path); - if(c_link_name) + if (c_link_name) HDfree(c_link_name); return ret_value; @@ -271,36 +268,35 @@ h5lcreate_soft_c(_fcd target_path, size_t_f *target_path_len, * M. Scot Breitenfeld * February 27, 2008 * SOURCE -*/ + */ int_f -h5lcreate_hard_c(hid_t_f *obj_loc_id, _fcd obj_name, size_t_f *obj_namelen, - hid_t_f *link_loc_id, - _fcd link_name, size_t_f *link_namelen, - hid_t_f *lcpl_id, hid_t_f *lapl_id ) +h5lcreate_hard_c(hid_t_f *obj_loc_id, _fcd obj_name, size_t_f *obj_namelen, hid_t_f *link_loc_id, + _fcd link_name, size_t_f *link_namelen, hid_t_f *lcpl_id, hid_t_f *lapl_id) /******/ { - char *c_obj_name = NULL; - char *c_link_name = NULL; - int_f ret_value = 0; - - /* - * Convert FORTRAN name to C name - */ - if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) - HGOTO_DONE(FAIL); - if((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Lcreate_hard function. - */ - if ( H5Lcreate_hard((hid_t)*obj_loc_id, c_obj_name, (hid_t)*link_loc_id, c_link_name, (hid_t)*lcpl_id, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_obj_name) + char *c_obj_name = NULL; + char *c_link_name = NULL; + int_f ret_value = 0; + + /* + * Convert FORTRAN name to C name + */ + if ((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL) + HGOTO_DONE(FAIL); + if ((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Lcreate_hard function. + */ + if (H5Lcreate_hard((hid_t)*obj_loc_id, c_obj_name, (hid_t)*link_loc_id, c_link_name, (hid_t)*lcpl_id, + (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_obj_name) HDfree(c_obj_name); - if(c_link_name) + if (c_link_name) HDfree(c_link_name); return ret_value; @@ -340,34 +336,35 @@ h5lcreate_hard_c(hid_t_f *obj_loc_id, _fcd obj_name, size_t_f *obj_namelen, * HISTORY * N/A * SOURCE -*/ + */ int_f -h5ldelete_by_idx_c (hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, - int_f *index_field, int_f *order, hsize_t_f *n, hid_t_f *lapl_id) +h5ldelete_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, int_f *index_field, + int_f *order, hsize_t_f *n, hid_t_f *lapl_id) /******/ { - char *c_group_name = NULL; /* Buffer to hold C string */ - H5_index_t c_index_field; + char * c_group_name = NULL; /* Buffer to hold C string */ + H5_index_t c_index_field; H5_iter_order_t c_order; - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ - /* - * Convert FORTRAN name to C name - */ - if((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) - HGOTO_DONE(FAIL); + /* + * Convert FORTRAN name to C name + */ + if ((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) + HGOTO_DONE(FAIL); c_index_field = (H5_index_t)*index_field; - c_order = (H5_iter_order_t)*order; + c_order = (H5_iter_order_t)*order; - /* - * Call H5Ldelete_by_name function. - */ - if(H5Ldelete_by_idx((hid_t)*loc_id, c_group_name, c_index_field, c_order, (hsize_t)*n, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Ldelete_by_name function. + */ + if (H5Ldelete_by_idx((hid_t)*loc_id, c_group_name, c_index_field, c_order, (hsize_t)*n, (hid_t)*lapl_id) < + 0) + HGOTO_DONE(FAIL); done: - if(c_group_name) + if (c_group_name) HDfree(c_group_name); return ret_value; } @@ -393,28 +390,28 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5lexists_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, int_f *link_exists) +h5lexists_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, int_f *link_exists) /******/ { - char *c_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ + char *c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ - /* - * Convert FORTRAN name to C name - */ - if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); + /* + * Convert FORTRAN name to C name + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); - /* - * Call H5Lexists function. - */ - if((*link_exists = (int_f)H5Lexists((hid_t)*loc_id, c_name, (hid_t)*lapl_id)) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Lexists function. + */ + if ((*link_exists = (int_f)H5Lexists((hid_t)*loc_id, c_name, (hid_t)*lapl_id)) < 0) + HGOTO_DONE(FAIL); done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -452,40 +449,40 @@ done: * HISTORY * N/A * SOURCE -*/ + */ int_f -h5lget_info_c(hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, - int_f *cset, int_f *corder, int_f *corder_valid, int_f *link_type, - H5O_token_t *token, size_t_f *val_size, hid_t_f *lapl_id) +h5lget_info_c(hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, int_f *cset, int_f *corder, + int_f *corder_valid, int_f *link_type, H5O_token_t *token, size_t_f *val_size, hid_t_f *lapl_id) /******/ { - char *c_link_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ + char * c_link_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ H5L_info2_t link_buff; /* * Convert FORTRAN name to C name */ - if(NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen))) + if (NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen))) HGOTO_DONE(FAIL); /* * Call H5Linfo function. */ - if(H5Lget_info2((hid_t)*link_loc_id, c_link_name, &link_buff, (hid_t)*lapl_id) < 0) + if (H5Lget_info2((hid_t)*link_loc_id, c_link_name, &link_buff, (hid_t)*lapl_id) < 0) HGOTO_DONE(FAIL); /* Unpack the structure */ - *cset = (int_f)link_buff.cset; - *corder = (int_f)link_buff.corder; + *cset = (int_f)link_buff.cset; + *corder = (int_f)link_buff.corder; *corder_valid = 0; - if(link_buff.corder_valid > 0) *corder_valid = 1; + if (link_buff.corder_valid > 0) + *corder_valid = 1; *link_type = (int_f)link_buff.type; - *token = link_buff.u.token; - *val_size = (size_t_f)link_buff.u.val_size; + *token = link_buff.u.token; + *val_size = (size_t_f)link_buff.u.val_size; done: - if(c_link_name) + if (c_link_name) HDfree(c_link_name); return ret_value; @@ -520,45 +517,45 @@ done: * HISTORY * N/A * SOURCE -*/ + */ int_f -h5lget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, - int_f *index_field, int_f *order, hsize_t_f *n, - int_f *link_type, int_f *corder_valid, int_f *corder, - int_f *cset, H5O_token_t *token, size_t_f *val_size, hid_t_f *lapl_id) +h5lget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, int_f *index_field, + int_f *order, hsize_t_f *n, int_f *link_type, int_f *corder_valid, int_f *corder, + int_f *cset, H5O_token_t *token, size_t_f *val_size, hid_t_f *lapl_id) /******/ { - char *c_group_name = NULL; /* Buffer to hold C string */ - H5_index_t c_index_field; + char * c_group_name = NULL; /* Buffer to hold C string */ + H5_index_t c_index_field; H5_iter_order_t c_order; - int_f ret_value = 0; /* Return value */ - H5L_info2_t link_buff; + int_f ret_value = 0; /* Return value */ + H5L_info2_t link_buff; /* * Convert FORTRAN name to C name */ - if((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) - HGOTO_DONE(FAIL); + if ((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) + HGOTO_DONE(FAIL); c_index_field = (H5_index_t)*index_field; - c_order = (H5_iter_order_t)*order; - /* - * Call H5Linfo_by_idx function. - */ - if(H5Lget_info_by_idx2((hid_t)*loc_id, c_group_name, c_index_field, c_order, (hsize_t)*n, - &link_buff, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); + c_order = (H5_iter_order_t)*order; + /* + * Call H5Linfo_by_idx function. + */ + if (H5Lget_info_by_idx2((hid_t)*loc_id, c_group_name, c_index_field, c_order, (hsize_t)*n, &link_buff, + (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); /* Unpack the structure */ *corder_valid = 0; - if(link_buff.corder_valid > 0) *corder_valid = 1; + if (link_buff.corder_valid > 0) + *corder_valid = 1; - *corder = (int_f)link_buff.corder; - *cset = (int_f)link_buff.cset; + *corder = (int_f)link_buff.corder; + *cset = (int_f)link_buff.cset; *link_type = (int_f)link_buff.type; - *token = link_buff.u.token; - *val_size = (size_t_f)link_buff.u.val_size; + *token = link_buff.u.token; + *val_size = (size_t_f)link_buff.u.val_size; done: return ret_value; @@ -584,12 +581,12 @@ done: * HISTORY * N/A * SOURCE -*/ + */ int_f h5lis_registered_c(int_f *link_cls_id) /******/ { - int_f ret_value; /* Return value */ + int_f ret_value; /* Return value */ /* * Call H5Lis_registered @@ -604,7 +601,6 @@ h5lis_registered_c(int_f *link_cls_id) /* H5L_type_t c_link_cls_id; /\* User-defined link class identifier *\/ */ /* htri_t registered; /\* registration status *\/ */ - /* c_link_cls_id = (H5L_type_t)*link_cls_id; */ /* /\* */ /* * Call H5Lis_registered */ @@ -616,7 +612,6 @@ h5lis_registered_c(int_f *link_cls_id) /* return ret_value; */ /* } */ - /****if* H5Lf/h5lmove_c * NAME * h5lmove_c @@ -639,35 +634,35 @@ h5lis_registered_c(int_f *link_cls_id) * M. Scot Breitenfeld * March 3, 2008 * SOURCE -*/ + */ int_f -h5lmove_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *dest_loc_id, - _fcd dest_name, size_t_f *dest_namelen, hid_t_f *lcpl_id, hid_t_f *lapl_id) +h5lmove_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *dest_loc_id, _fcd dest_name, + size_t_f *dest_namelen, hid_t_f *lcpl_id, hid_t_f *lapl_id) /******/ { - char *c_src_name = NULL; /* Buffer to hold C string */ + char *c_src_name = NULL; /* Buffer to hold C string */ char *c_dest_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ /* * Convert FORTRAN name to C name */ - if(NULL == (c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen))) + if (NULL == (c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen))) + if (NULL == (c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen))) HGOTO_DONE(FAIL) - /* - * Call H5Lmove function. - */ - if(H5Lmove((hid_t)*src_loc_id, c_src_name, (hid_t)*dest_loc_id, - c_dest_name, (hid_t)*lcpl_id, (hid_t)*lapl_id) < 0) + /* + * Call H5Lmove function. + */ + if (H5Lmove((hid_t)*src_loc_id, c_src_name, (hid_t)*dest_loc_id, c_dest_name, (hid_t)*lcpl_id, + (hid_t)*lapl_id) < 0) HGOTO_DONE(FAIL) done: - if(c_src_name) + if (c_src_name) HDfree(c_src_name); - if(c_dest_name) + if (c_dest_name) HDfree(c_dest_name); return ret_value; @@ -697,23 +692,22 @@ done: * M. Scot Breitenfeld * March 10, 2008 * SOURCE -*/ + */ int_f -h5lget_name_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, - int_f *index_field, int_f *order, hsize_t_f *n, - size_t_f *size, _fcd name, hid_t_f *lapl_id) +h5lget_name_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, int_f *index_field, + int_f *order, hsize_t_f *n, size_t_f *size, _fcd name, hid_t_f *lapl_id) /******/ { - char *c_group_name = NULL; /* Buffer to hold C string */ - char *c_name = NULL; /* Buffer to hold C string */ - size_t c_size; + char * c_group_name = NULL; /* Buffer to hold C string */ + char * c_name = NULL; /* Buffer to hold C string */ + size_t c_size; ssize_t c_size_link; - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ /* * Convert FORTRAN name to C name */ - if(NULL == (c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen))) + if (NULL == (c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen))) HGOTO_DONE(FAIL) c_size = (size_t)*size + 1; @@ -721,11 +715,12 @@ h5lget_name_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, /* * Allocate buffer to hold name of an attribute */ - if(NULL == (c_name = (char *)HDmalloc(c_size))) + if (NULL == (c_name = (char *)HDmalloc(c_size))) HGOTO_DONE(FAIL) - if((c_size_link = H5Lget_name_by_idx((hid_t)*loc_id, c_group_name, (H5_index_t)*index_field, - (H5_iter_order_t)*order, (hsize_t)*n,c_name, c_size, (hid_t)*lapl_id)) < 0) + if ((c_size_link = + H5Lget_name_by_idx((hid_t)*loc_id, c_group_name, (H5_index_t)*index_field, + (H5_iter_order_t)*order, (hsize_t)*n, c_name, c_size, (hid_t)*lapl_id)) < 0) HGOTO_DONE(FAIL) *size = (size_t_f)c_size_link; @@ -733,19 +728,18 @@ h5lget_name_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, /* * Convert C name to FORTRAN and place it in the given buffer */ - if(c_name) + if (c_name) HD5packFstring(c_name, _fcdtocp(name), c_size - 1); done: - if(c_group_name) + if (c_group_name) HDfree(c_group_name); - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } - /* /\****if* H5Lf/h5lget_val_c */ /* * NAME */ /* * h5lget_val_c */ @@ -795,12 +789,10 @@ done: /* *\/ */ /* HD5packFstring(c_buf, _fcdtocp(buf), c_bufsize-1); */ - /* done: */ /* return ret_value; */ /* } */ - /* /\****if* H5Lf/ */ /* * NAME */ /* * H5Lregistered_c */ @@ -934,29 +926,29 @@ done: * M. Scot Breitenfeld * April 11, 2008 * SOURCE -*/ + */ int_f -h5lget_val_c(hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, size_t_f *size, - void *linkval_buff, hid_t_f *lapl_id) +h5lget_val_c(hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, size_t_f *size, void *linkval_buff, + hid_t_f *lapl_id) /******/ { char *c_link_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ /* * Convert FORTRAN name to C name */ - if(NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen))) + if (NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen))) HGOTO_DONE(FAIL) /* * Call H5Lget_val */ - if(H5Lget_val((hid_t)*link_loc_id, c_link_name, &linkval_buff, (size_t)*size, (hid_t)*lapl_id )< 0) + if (H5Lget_val((hid_t)*link_loc_id, c_link_name, &linkval_buff, (size_t)*size, (hid_t)*lapl_id) < 0) HGOTO_DONE(FAIL) done: - if(c_link_name) + if (c_link_name) HDfree(c_link_name); return ret_value; @@ -986,27 +978,29 @@ done: * M. Scot Breitenfeld * July 8, 2008 * SOURCE -*/ + */ int_f -h5literate_c(hid_t_f *group_id, int_f *index_type, int_f *order, hsize_t_f *idx, H5L_iterate2_t op, void *op_data ) +h5literate_c(hid_t_f *group_id, int_f *index_type, int_f *order, hsize_t_f *idx, H5L_iterate2_t op, + void *op_data) /******/ { - int_f ret_value = -1; /* Return value */ - herr_t func_ret_value; /* H5Linterate return value */ - hsize_t idx_c = 0; + int_f ret_value = -1; /* Return value */ + herr_t func_ret_value; /* H5Linterate return value */ + hsize_t idx_c = 0; - idx_c = (hsize_t)*idx; + idx_c = (hsize_t)*idx; - /* - * Call H5Linterate - */ + /* + * Call H5Linterate + */ - func_ret_value = H5Literate2( (hid_t)*group_id, (H5_index_t)*index_type, (H5_iter_order_t)*order, &idx_c, op, op_data); + func_ret_value = + H5Literate2((hid_t)*group_id, (H5_index_t)*index_type, (H5_iter_order_t)*order, &idx_c, op, op_data); - ret_value = (int_f)func_ret_value; - *idx = (hsize_t_f)idx_c; + ret_value = (int_f)func_ret_value; + *idx = (hsize_t_f)idx_c; - return ret_value; + return ret_value; } /****if* H5Lf/h5literate_by_name_c @@ -1036,35 +1030,37 @@ h5literate_c(hid_t_f *group_id, int_f *index_type, int_f *order, hsize_t_f *idx, * M. Scot Breitenfeld * August 18, 2008 * SOURCE -*/ + */ int_f -h5literate_by_name_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, int_f *index_type, int_f *order, hsize_t_f *idx, H5L_iterate2_t op, void *op_data, hid_t_f *lapl_id) +h5literate_by_name_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, int_f *index_type, int_f *order, + hsize_t_f *idx, H5L_iterate2_t op, void *op_data, hid_t_f *lapl_id) /******/ { - int_f ret_value = -1; /* Return value */ - herr_t func_ret_value; /* H5Linterate return value */ - hsize_t idx_c = 0; - char *c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = -1; /* Return value */ + herr_t func_ret_value; /* H5Linterate return value */ + hsize_t idx_c = 0; + char * c_name = NULL; /* Buffer to hold C string */ - /* - * Convert FORTRAN name to C name - */ - if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - return ret_value=-1; + /* + * Convert FORTRAN name to C name + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + return ret_value = -1; - idx_c = (hsize_t)*idx; + idx_c = (hsize_t)*idx; - /* - * Call H5Linterate - */ + /* + * Call H5Linterate + */ - func_ret_value = H5Literate_by_name2((hid_t)*loc_id, c_name,(H5_index_t)*index_type,(H5_iter_order_t)*order,&idx_c,op,op_data,(hid_t)*lapl_id); + func_ret_value = H5Literate_by_name2((hid_t)*loc_id, c_name, (H5_index_t)*index_type, + (H5_iter_order_t)*order, &idx_c, op, op_data, (hid_t)*lapl_id); - ret_value = (int_f)func_ret_value; - *idx = (hsize_t_f)idx_c; + ret_value = (int_f)func_ret_value; + *idx = (hsize_t_f)idx_c; - if(c_name) HDfree(c_name); + if (c_name) + HDfree(c_name); - return ret_value; + return ret_value; } - diff --git a/fortran/src/H5Of.c b/fortran/src/H5Of.c index edbfcbe..36dbbac 100644 --- a/fortran/src/H5Of.c +++ b/fortran/src/H5Of.c @@ -17,76 +17,75 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5Eprivate.h" -int_f -fill_h5o_info_t_f(H5O_info2_t Oinfo, H5O_info_t_f *object_info); +int_f fill_h5o_info_t_f(H5O_info2_t Oinfo, H5O_info_t_f *object_info); int_f -fill_h5o_info_t_f(H5O_info2_t Oinfo, H5O_info_t_f *object_info) { - - /* This function does not used the field parameter because we want - * this function to fill the unfilled fields with C's default values. - */ - - struct tm *ts; - - object_info->fileno = Oinfo.fileno; - object_info->token = Oinfo.token; - - object_info->type = (int_f)Oinfo.type; - object_info->rc = (int_f)Oinfo.rc; - - ts = HDgmtime(&Oinfo.atime); - - object_info->atime[0] = (int_f)ts->tm_year+1900; /* year starts at 1900 */ - object_info->atime[1] = (int_f)ts->tm_mon+1; /* month starts at 0 in C */ - object_info->atime[2] = (int_f)ts->tm_mday; - object_info->atime[3] = 0; /* time is expressed as UTC (or GMT timezone) */ - object_info->atime[4] = (int_f)ts->tm_hour; - object_info->atime[5] = (int_f)ts->tm_min; - object_info->atime[6] = (int_f)ts->tm_sec; - object_info->atime[7] = -32767; /* millisecond is not available, assign it -HUGE(0) */ - - ts = HDgmtime(&Oinfo.btime); - - object_info->btime[0] = (int_f)ts->tm_year+1900; /* year starts at 1900 */ - object_info->btime[1] = (int_f)ts->tm_mon+1; /* month starts at 0 in C */ - object_info->btime[2] = (int_f)ts->tm_mday; - object_info->btime[3] = 0; /* time is expressed as UTC (or GMT timezone) */ - object_info->btime[4] = (int_f)ts->tm_hour; - object_info->btime[5] = (int_f)ts->tm_min; - object_info->btime[6] = (int_f)ts->tm_sec; - object_info->btime[7] = -32767; /* millisecond is not available, assign it -HUGE(0) */ - - ts = HDgmtime(&Oinfo.ctime); - - object_info->ctime[0] = (int_f)ts->tm_year+1900; /* year starts at 1900 */ - object_info->ctime[1] = (int_f)ts->tm_mon+1; /* month starts at 0 in C */ - object_info->ctime[2] = (int_f)ts->tm_mday; - object_info->ctime[3] = 0; /* time is expressed as UTC (or GMT timezone) */ - object_info->ctime[4] = (int_f)ts->tm_hour; - object_info->ctime[5] = (int_f)ts->tm_min; - object_info->ctime[6] = (int_f)ts->tm_sec; - object_info->ctime[7] = -32767; /* millisecond is not available, assign it -HUGE(0) */ - - ts = HDgmtime(&Oinfo.mtime); - - object_info->mtime[0] = (int_f)ts->tm_year+1900; /* year starts at 1900 */ - object_info->mtime[1] = (int_f)ts->tm_mon+1; /* month starts at 0 in C */ - object_info->mtime[2] = (int_f)ts->tm_mday; - object_info->mtime[3] = 0; /* time is expressed as UTC (or GMT timezone) */ - object_info->mtime[4] = (int_f)ts->tm_hour; - object_info->mtime[5] = (int_f)ts->tm_min; - object_info->mtime[6] = (int_f)ts->tm_sec; - object_info->mtime[7] = -32767; /* millisecond is not available, assign it -HUGE(0) */ - - object_info->num_attrs = (hsize_t_f)Oinfo.num_attrs; - - return 0; +fill_h5o_info_t_f(H5O_info2_t Oinfo, H5O_info_t_f *object_info) +{ + /* This function does not used the field parameter because we want + * this function to fill the unfilled fields with C's default values. + */ + + struct tm *ts; + + object_info->fileno = Oinfo.fileno; + object_info->token = Oinfo.token; + + object_info->type = (int_f)Oinfo.type; + object_info->rc = (int_f)Oinfo.rc; + + ts = HDgmtime(&Oinfo.atime); + + object_info->atime[0] = (int_f)ts->tm_year + 1900; /* year starts at 1900 */ + object_info->atime[1] = (int_f)ts->tm_mon + 1; /* month starts at 0 in C */ + object_info->atime[2] = (int_f)ts->tm_mday; + object_info->atime[3] = 0; /* time is expressed as UTC (or GMT timezone) */ + object_info->atime[4] = (int_f)ts->tm_hour; + object_info->atime[5] = (int_f)ts->tm_min; + object_info->atime[6] = (int_f)ts->tm_sec; + object_info->atime[7] = -32767; /* millisecond is not available, assign it -HUGE(0) */ + + ts = HDgmtime(&Oinfo.btime); + + object_info->btime[0] = (int_f)ts->tm_year + 1900; /* year starts at 1900 */ + object_info->btime[1] = (int_f)ts->tm_mon + 1; /* month starts at 0 in C */ + object_info->btime[2] = (int_f)ts->tm_mday; + object_info->btime[3] = 0; /* time is expressed as UTC (or GMT timezone) */ + object_info->btime[4] = (int_f)ts->tm_hour; + object_info->btime[5] = (int_f)ts->tm_min; + object_info->btime[6] = (int_f)ts->tm_sec; + object_info->btime[7] = -32767; /* millisecond is not available, assign it -HUGE(0) */ + + ts = HDgmtime(&Oinfo.ctime); + + object_info->ctime[0] = (int_f)ts->tm_year + 1900; /* year starts at 1900 */ + object_info->ctime[1] = (int_f)ts->tm_mon + 1; /* month starts at 0 in C */ + object_info->ctime[2] = (int_f)ts->tm_mday; + object_info->ctime[3] = 0; /* time is expressed as UTC (or GMT timezone) */ + object_info->ctime[4] = (int_f)ts->tm_hour; + object_info->ctime[5] = (int_f)ts->tm_min; + object_info->ctime[6] = (int_f)ts->tm_sec; + object_info->ctime[7] = -32767; /* millisecond is not available, assign it -HUGE(0) */ + + ts = HDgmtime(&Oinfo.mtime); + + object_info->mtime[0] = (int_f)ts->tm_year + 1900; /* year starts at 1900 */ + object_info->mtime[1] = (int_f)ts->tm_mon + 1; /* month starts at 0 in C */ + object_info->mtime[2] = (int_f)ts->tm_mday; + object_info->mtime[3] = 0; /* time is expressed as UTC (or GMT timezone) */ + object_info->mtime[4] = (int_f)ts->tm_hour; + object_info->mtime[5] = (int_f)ts->tm_min; + object_info->mtime[6] = (int_f)ts->tm_sec; + object_info->mtime[7] = -32767; /* millisecond is not available, assign it -HUGE(0) */ + + object_info->num_attrs = (hsize_t_f)Oinfo.num_attrs; + + return 0; } /****if* H5Of/h5olink_c @@ -107,32 +106,31 @@ fill_h5o_info_t_f(H5O_info2_t Oinfo, H5O_info_t_f *object_info) { * M. Scot Breitenfeld * April 21, 2008 * SOURCE -*/ + */ int_f -h5olink_c (hid_t_f *object_id, hid_t_f *new_loc_id, _fcd name, size_t_f *namelen, - hid_t_f *lcpl_id, hid_t_f *lapl_id) +h5olink_c(hid_t_f *object_id, hid_t_f *new_loc_id, _fcd name, size_t_f *namelen, hid_t_f *lcpl_id, + hid_t_f *lapl_id) /******/ { - char *c_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN name to C name - */ - if( (c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Olink function. - */ - if((hid_t_f)H5Olink((hid_t)*object_id, (hid_t)*new_loc_id, c_name, - (hid_t)*lcpl_id, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_name) - HDfree(c_name); - return ret_value; + char *c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN name to C name + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Olink function. + */ + if ((hid_t_f)H5Olink((hid_t)*object_id, (hid_t)*new_loc_id, c_name, (hid_t)*lcpl_id, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_name) + HDfree(c_name); + return ret_value; } /****if* H5Of/h5oopen_c @@ -153,30 +151,30 @@ h5olink_c (hid_t_f *object_id, hid_t_f *new_loc_id, _fcd name, size_t_f *namelen * M. Scot Breitenfeld * April 18, 2008 * SOURCE -*/ + */ int_f -h5oopen_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, hid_t_f *obj_id) +h5oopen_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, hid_t_f *obj_id) /******/ { - char *c_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN name to C name - */ - if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Oopen function. - */ - if((*obj_id = (hid_t_f)H5Oopen((hid_t)*loc_id, c_name, (hid_t)*lapl_id)) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_name) - HDfree(c_name); - return ret_value; + char *c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN name to C name + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Oopen function. + */ + if ((*obj_id = (hid_t_f)H5Oopen((hid_t)*loc_id, c_name, (hid_t)*lapl_id)) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_name) + HDfree(c_name); + return ret_value; } /****if* H5Of/h5oclose_c * NAME @@ -191,18 +189,18 @@ h5oopen_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, hid_ * M. Scot Breitenfeld * December 17, 2008 * SOURCE -*/ + */ int_f -h5oclose_c ( hid_t_f *object_id ) +h5oclose_c(hid_t_f *object_id) /******/ { - int_f ret_value=0; /* Return value */ + int_f ret_value = 0; /* Return value */ - if (H5Oclose((hid_t)*object_id) < 0) - HGOTO_DONE(FAIL); + if (H5Oclose((hid_t)*object_id) < 0) + HGOTO_DONE(FAIL); - done: - return ret_value; +done: + return ret_value; } /****if* H5Of/h5ovisit_c @@ -228,24 +226,25 @@ h5oclose_c ( hid_t_f *object_id ) * M. Scot Breitenfeld * November 19, 2008 * SOURCE -*/ + */ int_f -h5ovisit_c(hid_t_f *group_id, int_f *index_type, int_f *order, H5O_iterate2_t op, - void *op_data, int_f *fields ) +h5ovisit_c(hid_t_f *group_id, int_f *index_type, int_f *order, H5O_iterate2_t op, void *op_data, + int_f *fields) /******/ { - int_f ret_value = -1; /* Return value */ - herr_t func_ret_value; /* H5Linterate return value */ + int_f ret_value = -1; /* Return value */ + herr_t func_ret_value; /* H5Linterate return value */ - /* - * Call H5Ovisit - */ + /* + * Call H5Ovisit + */ - func_ret_value = H5Ovisit3( (hid_t)*group_id, (H5_index_t)*index_type, (H5_iter_order_t)*order, op, op_data, (unsigned)*fields); + func_ret_value = H5Ovisit3((hid_t)*group_id, (H5_index_t)*index_type, (H5_iter_order_t)*order, op, + op_data, (unsigned)*fields); - ret_value = (int_f)func_ret_value; + ret_value = (int_f)func_ret_value; - return ret_value; + return ret_value; } /****if* H5Of/h5oopen_by_token_c @@ -266,21 +265,21 @@ h5ovisit_c(hid_t_f *group_id, int_f *index_type, int_f *order, H5O_iterate2_t op * M. Scot Breitenfeld * September 14, 2009 * SOURCE -*/ + */ int_f h5oopen_by_token_c(hid_t_f *loc_id, H5O_token_t *token, hid_t_f *obj_id) /******/ { - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ - /* - * Call H5Oopen_by_token function. - */ - if((*obj_id = (hid_t_f)H5Oopen_by_token((hid_t)*loc_id, *token)) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Oopen_by_token function. + */ + if ((*obj_id = (hid_t_f)H5Oopen_by_token((hid_t)*loc_id, *token)) < 0) + HGOTO_DONE(FAIL); - done: - return ret_value; +done: + return ret_value; } /****if* H5Of/H5Oget_info_by_name_c @@ -303,35 +302,34 @@ h5oopen_by_token_c(hid_t_f *loc_id, H5O_token_t *token, hid_t_f *obj_id) * M. Scot Breitenfeld * December 1, 2008 * SOURCE -*/ + */ int_f -h5oget_info_by_name_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, - H5O_info_t_f *object_info, int_f *fields) +h5oget_info_by_name_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, + H5O_info_t_f *object_info, int_f *fields) /******/ { - char *c_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - H5O_info2_t Oinfo; - - /* - * Convert FORTRAN name to C name - */ - if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Oinfo_by_name function. - */ - if(H5Oget_info_by_name3((hid_t)*loc_id, c_name, - &Oinfo, (unsigned)*fields, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); - - ret_value = fill_h5o_info_t_f(Oinfo, object_info); - - done: - if(c_name) - HDfree(c_name); - return ret_value; + char * c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + H5O_info2_t Oinfo; + + /* + * Convert FORTRAN name to C name + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Oinfo_by_name function. + */ + if (H5Oget_info_by_name3((hid_t)*loc_id, c_name, &Oinfo, (unsigned)*fields, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); + + ret_value = fill_h5o_info_t_f(Oinfo, object_info); + +done: + if (c_name) + HDfree(c_name); + return ret_value; } /****if* H5Of/H5Oget_info_by_idx_c @@ -354,40 +352,40 @@ h5oget_info_by_name_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *l * M. Scot Breitenfeld * December 1, 2008 * SOURCE -*/ + */ int_f -h5oget_info_by_idx_c (hid_t_f *loc_id, _fcd group_name, size_t_f *namelen, - int_f *index_field, int_f *order, hsize_t_f *n, hid_t_f *lapl_id, H5O_info_t_f *object_info, int_f *fields) +h5oget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *namelen, int_f *index_field, int_f *order, + hsize_t_f *n, hid_t_f *lapl_id, H5O_info_t_f *object_info, int_f *fields) /******/ { - char *c_group_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - H5O_info2_t Oinfo; - H5_index_t c_index_field; - H5_iter_order_t c_order; - - /* - * Convert FORTRAN name to C name - */ - if((c_group_name = HD5f2cstring( group_name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); - - c_index_field = (H5_index_t)*index_field; - c_order = (H5_iter_order_t)*order; - - /* - * Call H5Oinfo_by_idx function. - */ - if(H5Oget_info_by_idx3((hid_t)*loc_id, c_group_name, c_index_field, c_order, (hsize_t)*n, - &Oinfo, (unsigned)*fields, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); - - ret_value = fill_h5o_info_t_f(Oinfo,object_info); - - done: - if(c_group_name) - HDfree(c_group_name); - return ret_value; + char * c_group_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + H5O_info2_t Oinfo; + H5_index_t c_index_field; + H5_iter_order_t c_order; + + /* + * Convert FORTRAN name to C name + */ + if ((c_group_name = HD5f2cstring(group_name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); + + c_index_field = (H5_index_t)*index_field; + c_order = (H5_iter_order_t)*order; + + /* + * Call H5Oinfo_by_idx function. + */ + if (H5Oget_info_by_idx3((hid_t)*loc_id, c_group_name, c_index_field, c_order, (hsize_t)*n, &Oinfo, + (unsigned)*fields, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); + + ret_value = fill_h5o_info_t_f(Oinfo, object_info); + +done: + if (c_group_name) + HDfree(c_group_name); + return ret_value; } /****if* H5Of/H5Oget_info_c @@ -407,24 +405,24 @@ h5oget_info_by_idx_c (hid_t_f *loc_id, _fcd group_name, size_t_f *namelen, * M. Scot Breitenfeld * May 16, 2012 * SOURCE -*/ + */ int_f -h5oget_info_c (hid_t_f *object_id, H5O_info_t_f *object_info, int_f *fields) +h5oget_info_c(hid_t_f *object_id, H5O_info_t_f *object_info, int_f *fields) /******/ { - int_f ret_value = 0; /* Return value */ - H5O_info2_t Oinfo; + int_f ret_value = 0; /* Return value */ + H5O_info2_t Oinfo; - /* - * Call H5Oinfo_by_name function. - */ - if(H5Oget_info3((hid_t)*object_id, &Oinfo, (unsigned)*fields) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Oinfo_by_name function. + */ + if (H5Oget_info3((hid_t)*object_id, &Oinfo, (unsigned)*fields) < 0) + HGOTO_DONE(FAIL); - ret_value = fill_h5o_info_t_f(Oinfo,object_info); + ret_value = fill_h5o_info_t_f(Oinfo, object_info); - done: - return ret_value; +done: + return ret_value; } /* ***if* H5Of/H5Ocopy_c @@ -448,41 +446,39 @@ h5oget_info_c (hid_t_f *object_id, H5O_info_t_f *object_info, int_f *fields) * M. Scot Breitenfeld * March 14, 2012 * SOURCE -*/ + */ int_f -h5ocopy_c (hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_name_len, - hid_t_f *dst_loc_id, _fcd dst_name, size_t_f *dst_name_len, - hid_t_f *ocpypl_id, hid_t_f *lcpl_id ) +h5ocopy_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_name_len, hid_t_f *dst_loc_id, _fcd dst_name, + size_t_f *dst_name_len, hid_t_f *ocpypl_id, hid_t_f *lcpl_id) /******/ { - char *c_src_name = NULL; /* Buffer to hold C string */ - char *c_dst_name = NULL; /* Buffer to hold C string */ - - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN name to C name - */ - if((c_src_name = HD5f2cstring(src_name, (size_t)*src_name_len)) == NULL) - HGOTO_DONE(FAIL); - if((c_dst_name = HD5f2cstring(dst_name, (size_t)*dst_name_len)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Ocopy function. - */ - if(H5Ocopy( (hid_t)*src_loc_id, c_src_name, (hid_t)*dst_loc_id, c_dst_name, - (hid_t)*ocpypl_id, (hid_t)*lcpl_id) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_src_name) - HDfree(c_src_name); - if(c_dst_name) - HDfree(c_dst_name); - - return ret_value; + char *c_src_name = NULL; /* Buffer to hold C string */ + char *c_dst_name = NULL; /* Buffer to hold C string */ + + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN name to C name + */ + if ((c_src_name = HD5f2cstring(src_name, (size_t)*src_name_len)) == NULL) + HGOTO_DONE(FAIL); + if ((c_dst_name = HD5f2cstring(dst_name, (size_t)*dst_name_len)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Ocopy function. + */ + if (H5Ocopy((hid_t)*src_loc_id, c_src_name, (hid_t)*dst_loc_id, c_dst_name, (hid_t)*ocpypl_id, + (hid_t)*lcpl_id) < 0) + HGOTO_DONE(FAIL); +done: + if (c_src_name) + HDfree(c_src_name); + if (c_dst_name) + HDfree(c_dst_name); + + return ret_value; } /****if* H5Of/h5ovisit_by_name_c @@ -508,34 +504,34 @@ h5ocopy_c (hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_name_len, * M. Scot Breitenfeld * May 16, 2012 * SOURCE -*/ + */ int_f -h5ovisit_by_name_c(hid_t_f *loc_id, _fcd object_name, size_t_f *namelen, int_f *index_type, int_f *order, - H5O_iterate2_t op, void *op_data, hid_t_f *lapl_id, int_f *fields ) +h5ovisit_by_name_c(hid_t_f *loc_id, _fcd object_name, size_t_f *namelen, int_f *index_type, int_f *order, + H5O_iterate2_t op, void *op_data, hid_t_f *lapl_id, int_f *fields) /******/ { - int_f ret_value = -1; /* Return value */ - herr_t func_ret_value; /* H5Linterate return value */ - char *c_object_name = NULL; /* Buffer to hold C string */ - - /* - * Convert FORTRAN name to C name - */ - if( (c_object_name = HD5f2cstring(object_name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Ovisit_by_name - */ - func_ret_value = H5Ovisit_by_name3( (hid_t)*loc_id, c_object_name, (H5_index_t)*index_type, (H5_iter_order_t)*order, - op, op_data, (unsigned)*fields, (hid_t)*lapl_id); - ret_value = (int_f)func_ret_value; - - done: - if(c_object_name) - HDfree(c_object_name); - return ret_value; + int_f ret_value = -1; /* Return value */ + herr_t func_ret_value; /* H5Linterate return value */ + char * c_object_name = NULL; /* Buffer to hold C string */ + + /* + * Convert FORTRAN name to C name + */ + if ((c_object_name = HD5f2cstring(object_name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Ovisit_by_name + */ + func_ret_value = + H5Ovisit_by_name3((hid_t)*loc_id, c_object_name, (H5_index_t)*index_type, (H5_iter_order_t)*order, op, + op_data, (unsigned)*fields, (hid_t)*lapl_id); + ret_value = (int_f)func_ret_value; +done: + if (c_object_name) + HDfree(c_object_name); + return ret_value; } /****if* H5Of/h5odecr_refcount_c @@ -551,21 +547,21 @@ h5ovisit_by_name_c(hid_t_f *loc_id, _fcd object_name, size_t_f *namelen, int_f * M. Scot Breitenfeld * May 16, 2012 * SOURCE -*/ + */ int_f -h5odecr_refcount_c (hid_t_f *object_id) +h5odecr_refcount_c(hid_t_f *object_id) /******/ { - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ - /* - * Call H5Odecr_refcount function. - */ - if((hid_t_f)H5Odecr_refcount((hid_t)*object_id) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Odecr_refcount function. + */ + if ((hid_t_f)H5Odecr_refcount((hid_t)*object_id) < 0) + HGOTO_DONE(FAIL); - done: - return ret_value; +done: + return ret_value; } /****if* H5Of/h5oexists_by_name_c @@ -585,30 +581,30 @@ h5odecr_refcount_c (hid_t_f *object_id) * M. Scot Breitenfeld * May 17, 2012 * SOURCE -*/ + */ int_f -h5oexists_by_name_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id) +h5oexists_by_name_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id) /******/ { - char *c_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN name to C name - */ - if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Oopen function. - */ - if((ret_value = (int_f)H5Oexists_by_name((hid_t)*loc_id, c_name, (hid_t)*lapl_id)) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_name) - HDfree(c_name); - return ret_value; + char *c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN name to C name + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Oopen function. + */ + if ((ret_value = (int_f)H5Oexists_by_name((hid_t)*loc_id, c_name, (hid_t)*lapl_id)) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_name) + HDfree(c_name); + return ret_value; } /****if* H5Of/h5oincr_refcount_c @@ -624,21 +620,21 @@ h5oexists_by_name_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lap * M. Scot Breitenfeld * May 16, 2012 * SOURCE -*/ + */ int_f -h5oincr_refcount_c (hid_t_f *object_id) +h5oincr_refcount_c(hid_t_f *object_id) /******/ { - int_f ret_value = 0; /* Return value */ + int_f ret_value = 0; /* Return value */ - /* - * Call H5Oincr_refcount function. - */ - if((hid_t_f)H5Oincr_refcount((hid_t)*object_id) < 0) - HGOTO_DONE(FAIL); + /* + * Call H5Oincr_refcount function. + */ + if ((hid_t_f)H5Oincr_refcount((hid_t)*object_id) < 0) + HGOTO_DONE(FAIL); - done: - return ret_value; +done: + return ret_value; } /****if* H5Of/h5oset_comment_c @@ -656,30 +652,30 @@ h5oincr_refcount_c (hid_t_f *object_id) * M. Scot Breitenfeld * May 17, 2012 * SOURCE -*/ + */ int_f -h5oset_comment_c (hid_t_f *object_id, _fcd comment, size_t_f *commentlen) +h5oset_comment_c(hid_t_f *object_id, _fcd comment, size_t_f *commentlen) /******/ { - char *c_comment = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN string to C string - */ - if((c_comment = HD5f2cstring(comment, (size_t)*commentlen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Oset_comment function. - */ - if((hid_t_f)H5Oset_comment((hid_t)*object_id, c_comment) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_comment) - HDfree(c_comment); - return ret_value; + char *c_comment = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN string to C string + */ + if ((c_comment = HD5f2cstring(comment, (size_t)*commentlen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Oset_comment function. + */ + if ((hid_t_f)H5Oset_comment((hid_t)*object_id, c_comment) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_comment) + HDfree(c_comment); + return ret_value; } /****if* H5Of/h5oset_comment_by_name_c @@ -701,38 +697,39 @@ h5oset_comment_c (hid_t_f *object_id, _fcd comment, size_t_f *commentlen) * M. Scot Breitenfeld * May 17, 2012 * SOURCE -*/ + */ int_f -h5oset_comment_by_name_c (hid_t_f *object_id, _fcd name, size_t_f *namelen, _fcd comment, size_t_f *commentlen, hid_t_f *lapl_id) +h5oset_comment_by_name_c(hid_t_f *object_id, _fcd name, size_t_f *namelen, _fcd comment, size_t_f *commentlen, + hid_t_f *lapl_id) /******/ { - char *c_comment = NULL; /* Buffer to hold C string */ - char *c_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - - /* - * Convert FORTRAN string to C string - */ - if((c_comment = HD5f2cstring(comment, (size_t)*commentlen)) == NULL) - HGOTO_DONE(FAIL); - /* - * Convert FORTRAN string to C string - */ - if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) - HGOTO_DONE(FAIL); - - /* - * Call H5Oset_comment_by_name function. - */ - if((hid_t_f)H5Oset_comment_by_name((hid_t)*object_id, c_name, c_comment, (hid_t)*lapl_id) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_name) - HDfree(c_name); - if(c_comment) - HDfree(c_comment); - return ret_value; + char *c_comment = NULL; /* Buffer to hold C string */ + char *c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + + /* + * Convert FORTRAN string to C string + */ + if ((c_comment = HD5f2cstring(comment, (size_t)*commentlen)) == NULL) + HGOTO_DONE(FAIL); + /* + * Convert FORTRAN string to C string + */ + if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL) + HGOTO_DONE(FAIL); + + /* + * Call H5Oset_comment_by_name function. + */ + if ((hid_t_f)H5Oset_comment_by_name((hid_t)*object_id, c_name, c_comment, (hid_t)*lapl_id) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_name) + HDfree(c_name); + if (c_comment) + HDfree(c_comment); + return ret_value; } /****if* H5Of/h5oopen_by_idx_c * NAME @@ -755,36 +752,37 @@ h5oset_comment_by_name_c (hid_t_f *object_id, _fcd name, size_t_f *namelen, _fc * M. Scot Breitenfeld * May 17, 2012 * SOURCE -*/ + */ int_f -h5oopen_by_idx_c (hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, - int_f *index_type, int_f *order, hsize_t_f *n, hid_t_f *obj_id, hid_t_f *lapl_id) +h5oopen_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, int_f *index_type, int_f *order, + hsize_t_f *n, hid_t_f *obj_id, hid_t_f *lapl_id) /******/ { - char *c_group_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; - H5_index_t c_index_type; - H5_iter_order_t c_order; - - /* - * Convert FORTRAN string to C string - */ - if((c_group_name = HD5f2cstring( group_name, (size_t)*group_namelen)) == NULL) - HGOTO_DONE(FAIL); - - c_index_type = (H5_index_t)*index_type; - c_order = (H5_iter_order_t)*order; - - /* - * Call H5Oopen_by_idx function. - */ - if((*obj_id =(hid_t_f)H5Oopen_by_idx((hid_t)*loc_id, c_group_name, c_index_type, c_order, (hsize_t)*n, (hid_t)*lapl_id)) < 0) - HGOTO_DONE(FAIL); - - done: - if(c_group_name) - HDfree(c_group_name); - return ret_value; + char * c_group_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; + H5_index_t c_index_type; + H5_iter_order_t c_order; + + /* + * Convert FORTRAN string to C string + */ + if ((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL) + HGOTO_DONE(FAIL); + + c_index_type = (H5_index_t)*index_type; + c_order = (H5_iter_order_t)*order; + + /* + * Call H5Oopen_by_idx function. + */ + if ((*obj_id = (hid_t_f)H5Oopen_by_idx((hid_t)*loc_id, c_group_name, c_index_type, c_order, (hsize_t)*n, + (hid_t)*lapl_id)) < 0) + HGOTO_DONE(FAIL); + +done: + if (c_group_name) + HDfree(c_group_name); + return ret_value; } /****if* H5Of/h5oget_comment_c @@ -804,43 +802,43 @@ h5oopen_by_idx_c (hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, * M. Scot Breitenfeld * June 24, 2012 * SOURCE -*/ + */ int_f -h5oget_comment_c (hid_t_f *object_id, _fcd comment, size_t_f *commentsize, hssize_t_f *bufsize) +h5oget_comment_c(hid_t_f *object_id, _fcd comment, size_t_f *commentsize, hssize_t_f *bufsize) /******/ { - char *c_comment = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - size_t c_commentsize; + char * c_comment = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + size_t c_commentsize; - c_commentsize = (size_t)*commentsize + 1; + c_commentsize = (size_t)*commentsize + 1; - /* - * Allocate buffer to hold comment name - */ + /* + * Allocate buffer to hold comment name + */ - if(NULL == (c_comment = (char *)HDmalloc(c_commentsize))) - HGOTO_DONE(FAIL); + if (NULL == (c_comment = (char *)HDmalloc(c_commentsize))) + HGOTO_DONE(FAIL); - /* - * Call H5Oget_comment function. - */ + /* + * Call H5Oget_comment function. + */ - if((*bufsize = (hssize_t_f)H5Oget_comment((hid_t)*object_id, c_comment, (size_t)*commentsize)) < 0) - HGOTO_DONE(FAIL); + if ((*bufsize = (hssize_t_f)H5Oget_comment((hid_t)*object_id, c_comment, (size_t)*commentsize)) < 0) + HGOTO_DONE(FAIL); - /* - * Convert C name to FORTRAN and place it in the given buffer - */ - if(c_comment) - HD5packFstring(c_comment, _fcdtocp(comment), c_commentsize - 1); - return ret_value; + /* + * Convert C name to FORTRAN and place it in the given buffer + */ + if (c_comment) + HD5packFstring(c_comment, _fcdtocp(comment), c_commentsize - 1); + return ret_value; - done: - if(c_comment) - HDfree(c_comment); +done: + if (c_comment) + HDfree(c_comment); - return ret_value; + return ret_value; } /****if* H5Of/h5oget_comment_by_name_c @@ -860,62 +858,63 @@ h5oget_comment_c (hid_t_f *object_id, _fcd comment, size_t_f *commentsize, hssi * M. Scot Breitenfeld * July 6, 2012 * SOURCE -*/ + */ int_f -h5oget_comment_by_name_c (hid_t_f *loc_id, _fcd name, size_t_f *name_size, - _fcd comment, size_t_f *commentsize, size_t_f *bufsize, hid_t_f *lapl_id) +h5oget_comment_by_name_c(hid_t_f *loc_id, _fcd name, size_t_f *name_size, _fcd comment, size_t_f *commentsize, + size_t_f *bufsize, hid_t_f *lapl_id) /******/ { - char *c_comment = NULL; /* Buffer to hold C string */ - char *c_name = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ - ssize_t c_bufsize; - size_t c_commentsize; + char * c_comment = NULL; /* Buffer to hold C string */ + char * c_name = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ + ssize_t c_bufsize; + size_t c_commentsize; - /* - * Convert FORTRAN string to C string - */ - if((c_name = HD5f2cstring(name, (size_t)*name_size)) == NULL) - HGOTO_DONE(FAIL); + /* + * Convert FORTRAN string to C string + */ + if ((c_name = HD5f2cstring(name, (size_t)*name_size)) == NULL) + HGOTO_DONE(FAIL); - c_commentsize = (size_t)*commentsize + 1; + c_commentsize = (size_t)*commentsize + 1; - /* - * Allocate buffer to hold comment name - */ + /* + * Allocate buffer to hold comment name + */ - if(NULL == (c_comment = (char *)HDmalloc(c_commentsize))) - HGOTO_DONE(FAIL); + if (NULL == (c_comment = (char *)HDmalloc(c_commentsize))) + HGOTO_DONE(FAIL); - /* - * Call H5Oget_comment_by_name function. - */ + /* + * Call H5Oget_comment_by_name function. + */ - if((c_bufsize = H5Oget_comment_by_name((hid_t)*loc_id, c_name, c_comment, (size_t)*commentsize,(hid_t)*lapl_id )) < 0) - HGOTO_DONE(FAIL); + if ((c_bufsize = H5Oget_comment_by_name((hid_t)*loc_id, c_name, c_comment, (size_t)*commentsize, + (hid_t)*lapl_id)) < 0) + HGOTO_DONE(FAIL); - if(c_name) - HDfree(c_name); + if (c_name) + HDfree(c_name); - *bufsize = (size_t_f)c_bufsize; + *bufsize = (size_t_f)c_bufsize; - /* - * Convert C name to FORTRAN and place it in the given buffer - */ - if(c_comment) { - HD5packFstring(c_comment, _fcdtocp(comment), c_commentsize - 1); - HDfree(c_comment); - } + /* + * Convert C name to FORTRAN and place it in the given buffer + */ + if (c_comment) { + HD5packFstring(c_comment, _fcdtocp(comment), c_commentsize - 1); + HDfree(c_comment); + } - return ret_value; + return ret_value; - done: - if(c_comment) - HDfree(c_comment); - if(c_name) - HDfree(c_name); +done: + if (c_comment) + HDfree(c_comment); + if (c_name) + HDfree(c_name); - return ret_value; + return ret_value; } /****if* H5Of/h5otoken_cmp_c @@ -934,24 +933,22 @@ h5oget_comment_by_name_c (hid_t_f *loc_id, _fcd name, size_t_f *name_size, * Quincey Koziol * January 10, 2019 * SOURCE -*/ + */ int_f -h5otoken_cmp_c(hid_t_f *loc_id, H5O_token_t *token1, H5O_token_t *token2, - int_f *cmp_value_f) +h5otoken_cmp_c(hid_t_f *loc_id, H5O_token_t *token1, H5O_token_t *token2, int_f *cmp_value_f) /******/ { - int cmp_value; /* Token comparison result */ - int_f ret_value = 0; /* Return value */ + int cmp_value; /* Token comparison result */ + int_f ret_value = 0; /* Return value */ - /* Call H5Otoken_cmp function */ - cmp_value = 0; - if(H5Otoken_cmp((hid_t)*loc_id, token1, token2, &cmp_value) < 0) - HGOTO_DONE(FAIL); + /* Call H5Otoken_cmp function */ + cmp_value = 0; + if (H5Otoken_cmp((hid_t)*loc_id, token1, token2, &cmp_value) < 0) + HGOTO_DONE(FAIL); - /* Set the comparison value to return */ - *cmp_value_f = cmp_value; + /* Set the comparison value to return */ + *cmp_value_f = cmp_value; done: - return ret_value; + return ret_value; } - diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 7cb3db8..42e137d 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5Eprivate.h" @@ -55,17 +55,17 @@ * Wednesday, October 9, 2002 * * SOURCE -*/ + */ int_f -h5pcreate_c ( hid_t_f *cls, hid_t_f *prp_id ) +h5pcreate_c(hid_t_f *cls, hid_t_f *prp_id) /******/ { hid_t c_prp_id; int_f ret_value = 0; c_prp_id = H5Pcreate((hid_t)*cls); - if(c_prp_id < 0) + if (c_prp_id < 0) HGOTO_DONE(FAIL) *prp_id = (hid_t_f)c_prp_id; @@ -88,21 +88,20 @@ done: * Saturday, August 14, 1999 * * SOURCE -*/ + */ int_f -h5pclose_c ( hid_t_f *prp_id ) +h5pclose_c(hid_t_f *prp_id) /******/ { int_f ret_value = 0; - if(H5Pclose((hid_t)*prp_id) < 0) + if (H5Pclose((hid_t)*prp_id) < 0) ret_value = -1; return ret_value; } - /****if* H5Pf/h5pcopy_c * NAME * h5pcopy_c @@ -119,16 +118,16 @@ h5pclose_c ( hid_t_f *prp_id ) * Saturday, August 14, 1999 * * SOURCE -*/ + */ int_f -h5pcopy_c ( hid_t_f *prp_id , hid_t_f *new_prp_id) +h5pcopy_c(hid_t_f *prp_id, hid_t_f *new_prp_id) /******/ { hid_t c_new_prp_id; int_f ret_value = 0; c_new_prp_id = H5Pcopy((hid_t)*prp_id); - if(c_new_prp_id < 0) + if (c_new_prp_id < 0) HGOTO_DONE(FAIL) *new_prp_id = (hid_t_f)c_new_prp_id; @@ -154,16 +153,16 @@ done: * Monday, September 30, 2002 * * SOURCE -*/ + */ int_f -h5pequal_c ( hid_t_f *plist1_id , hid_t_f *plist2_id, int_f * c_flag) +h5pequal_c(hid_t_f *plist1_id, hid_t_f *plist2_id, int_f *c_flag) /******/ { htri_t c_c_flag; - int_f ret_value = 0; + int_f ret_value = 0; c_c_flag = H5Pequal((hid_t)*plist1_id, (hid_t)*plist2_id); - if(c_c_flag < 0) + if (c_c_flag < 0) HGOTO_DONE(FAIL) *c_flag = (int_f)c_c_flag; @@ -172,7 +171,6 @@ done: return ret_value; } - /****if* H5Pf/h5pget_class_c * NAME * h5pget_class_c @@ -188,17 +186,17 @@ done: * Elena Pourmal * Saturday, August 14, 1999 * SOURCE -*/ + */ int_f -h5pget_class_c ( hid_t_f *prp_id , hid_t_f *classtype) +h5pget_class_c(hid_t_f *prp_id, hid_t_f *classtype) /******/ { hid_t c_classtype; int_f ret_value = 0; - if( (c_classtype = H5Pget_class((hid_t)*prp_id)) < 0) - HGOTO_DONE(FAIL) + if ((c_classtype = H5Pget_class((hid_t)*prp_id)) < 0) + HGOTO_DONE(FAIL) *classtype = (hid_t_f)c_classtype; @@ -221,25 +219,26 @@ done: * Elena Pourmal * Thursday, February 17, 2000 * SOURCE -*/ + */ int_f -h5pset_preserve_c ( hid_t_f *prp_id , int_f *flag) +h5pset_preserve_c(hid_t_f *prp_id, int_f *flag) /******/ { - int ret_value = 0; - hid_t c_prp_id; - herr_t status; - hbool_t c_flag = 0; + int ret_value = 0; + hid_t c_prp_id; + herr_t status; + hbool_t c_flag = 0; - if (*flag > 0) c_flag = 1; - c_prp_id = (hid_t)*prp_id; - status = H5Pset_preserve(c_prp_id, c_flag); - if ( status < 0 ) ret_value = -1; - return ret_value; + if (*flag > 0) + c_flag = 1; + c_prp_id = (hid_t)*prp_id; + status = H5Pset_preserve(c_prp_id, c_flag); + if (status < 0) + ret_value = -1; + return ret_value; } - /****if* H5Pf/h5pget_preserve_c * NAME * h5pget_preserve_c @@ -256,21 +255,22 @@ h5pset_preserve_c ( hid_t_f *prp_id , int_f *flag) * Elena Pourmal * Thursday, February 17, 2000 * SOURCE -*/ + */ int_f -h5pget_preserve_c ( hid_t_f *prp_id , int_f *flag) +h5pget_preserve_c(hid_t_f *prp_id, int_f *flag) /******/ { - int ret_value = 0; - hid_t c_prp_id; - int c_flag; + int ret_value = 0; + hid_t c_prp_id; + int c_flag; - c_prp_id = (hid_t)*prp_id; - c_flag = H5Pget_preserve(c_prp_id); - if ( c_flag < 0 ) ret_value = -1; - *flag = (int_f)c_flag; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_flag = H5Pget_preserve(c_prp_id); + if (c_flag < 0) + ret_value = -1; + *flag = (int_f)c_flag; + return ret_value; } /****if* H5Pf/h5pset_deflate_c @@ -287,26 +287,25 @@ h5pget_preserve_c ( hid_t_f *prp_id , int_f *flag) * Elena Pourmal * Saturday, August 14, 1999 * SOURCE -*/ + */ int_f -h5pset_deflate_c ( hid_t_f *prp_id , int_f *level) +h5pset_deflate_c(hid_t_f *prp_id, int_f *level) /******/ { - int ret_value = 0; - hid_t c_prp_id; - unsigned c_level; - herr_t status; + int ret_value = 0; + hid_t c_prp_id; + unsigned c_level; + herr_t status; - c_prp_id = (hid_t)*prp_id; - c_level = (unsigned)*level; - status = H5Pset_deflate(c_prp_id, c_level); - if ( status < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_level = (unsigned)*level; + status = H5Pset_deflate(c_prp_id, c_level); + if (status < 0) + ret_value = -1; + return ret_value; } - - /****if* H5Pf/h5pset_chunk_c * NAME * h5pset_chunk_c @@ -323,34 +322,34 @@ h5pset_deflate_c ( hid_t_f *prp_id , int_f *level) * AUTHOR * Elena Pourmal * SOURCE -*/ + */ int_f -h5pset_chunk_c ( hid_t_f *prp_id, int_f *rank, hsize_t_f *dims ) +h5pset_chunk_c(hid_t_f *prp_id, int_f *rank, hsize_t_f *dims) /******/ { - int ret_value = -1; - hid_t c_prp_id = (hid_t)*prp_id; - int c_rank = (int)*rank; - hsize_t c_dims[H5S_MAX_RANK]; - herr_t status; - int i; + int ret_value = -1; + hid_t c_prp_id = (hid_t)*prp_id; + int c_rank = (int)*rank; + hsize_t c_dims[H5S_MAX_RANK]; + herr_t status; + int i; - /* - * Transpose dimension arrays because of C-FORTRAN storage order - */ - for (i = 0; i < c_rank ; i++) - c_dims[i] = (hsize_t)dims[c_rank - i - 1]; + /* + * Transpose dimension arrays because of C-FORTRAN storage order + */ + for (i = 0; i < c_rank; i++) + c_dims[i] = (hsize_t)dims[c_rank - i - 1]; - status = H5Pset_chunk(c_prp_id, c_rank, c_dims); - if (status < 0) goto DONE; - ret_value = 0; + status = H5Pset_chunk(c_prp_id, c_rank, c_dims); + if (status < 0) + goto DONE; + ret_value = 0; DONE: - return ret_value; + return ret_value; } - /****if* H5Pf/h5pget_chunk_c * NAME * h5pget_chunk_c @@ -367,29 +366,30 @@ DONE: * AUTHOR * Elena Pourmal * SOURCE -*/ + */ int_f -h5pget_chunk_c ( hid_t_f *prp_id, int_f *max_rank, hsize_t_f *dims ) +h5pget_chunk_c(hid_t_f *prp_id, int_f *max_rank, hsize_t_f *dims) /******/ { - int ret_value = -1; - hid_t c_prp_id = (hid_t)*prp_id; - hsize_t c_dims[H5S_MAX_RANK]; - int rank; - int c_max_rank = (int)*max_rank; - int i; + int ret_value = -1; + hid_t c_prp_id = (hid_t)*prp_id; + hsize_t c_dims[H5S_MAX_RANK]; + int rank; + int c_max_rank = (int)*max_rank; + int i; - rank = H5Pget_chunk(c_prp_id, c_max_rank, c_dims); + rank = H5Pget_chunk(c_prp_id, c_max_rank, c_dims); - /* - * Transpose dimension arrays because of C-FORTRAN storage order - */ - for (i = 0; i < c_max_rank ; i++) - dims[c_max_rank - i - 1] = (hsize_t_f)c_dims[i]; - if (rank < 0) return ret_value; - ret_value = (int_f)rank; - return ret_value; + /* + * Transpose dimension arrays because of C-FORTRAN storage order + */ + for (i = 0; i < c_max_rank; i++) + dims[c_max_rank - i - 1] = (hsize_t_f)c_dims[i]; + if (rank < 0) + return ret_value; + ret_value = (int_f)rank; + return ret_value; } /****if* H5Pf/h5pset_fill_value_c @@ -407,26 +407,27 @@ h5pget_chunk_c ( hid_t_f *prp_id, int_f *max_rank, hsize_t_f *dims ) * Elena Pourmal * Saturday, August 14, 1999 * SOURCE -*/ + */ int_f -h5pset_fill_value_c (hid_t_f *prp_id, hid_t_f *type_id, void *fillvalue) +h5pset_fill_value_c(hid_t_f *prp_id, hid_t_f *type_id, void *fillvalue) /******/ { - int ret_value = -1; - hid_t c_prp_id; - hid_t c_type_id; - herr_t ret; + int ret_value = -1; + hid_t c_prp_id; + hid_t c_type_id; + herr_t ret; - /* - * Call H5Pset_fill_value function. - */ - c_prp_id = (hid_t)*prp_id; - c_type_id = (hid_t)*type_id; - ret = H5Pset_fill_value(c_prp_id, c_type_id, fillvalue); + /* + * Call H5Pset_fill_value function. + */ + c_prp_id = (hid_t)*prp_id; + c_type_id = (hid_t)*type_id; + ret = H5Pset_fill_value(c_prp_id, c_type_id, fillvalue); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_fill_value_c @@ -444,26 +445,27 @@ h5pset_fill_value_c (hid_t_f *prp_id, hid_t_f *type_id, void *fillvalue) * Elena Pourmal * Saturday, August 14, 1999 * SOURCE -*/ + */ int_f -h5pget_fill_value_c (hid_t_f *prp_id, hid_t_f *type_id, void *fillvalue) +h5pget_fill_value_c(hid_t_f *prp_id, hid_t_f *type_id, void *fillvalue) /******/ { - int ret_value = -1; - hid_t c_prp_id; - hid_t c_type_id; - herr_t ret; + int ret_value = -1; + hid_t c_prp_id; + hid_t c_type_id; + herr_t ret; - /* - * Call H5Pget_fill_value function. - */ - c_prp_id = (hid_t)*prp_id; - c_type_id = (hid_t)*type_id; - ret = H5Pget_fill_value(c_prp_id, c_type_id, fillvalue); + /* + * Call H5Pget_fill_value function. + */ + c_prp_id = (hid_t)*prp_id; + c_type_id = (hid_t)*type_id; + ret = H5Pget_fill_value(c_prp_id, c_type_id, fillvalue); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_version_c @@ -487,45 +489,46 @@ h5pget_fill_value_c (hid_t_f *prp_id, hid_t_f *type_id, void *fillvalue) * HISTORY * Removed extra length parameters EP 7/6/00 * SOURCE -*/ + */ #ifdef H5_NO_DEPRECATED_SYMBOLS int_f -h5pget_version_c (hid_t_f H5_ATTR_UNUSED *prp_id, int_f * boot,int_f * freelist, int_f * stab, int_f *shhdr) +h5pget_version_c(hid_t_f H5_ATTR_UNUSED *prp_id, int_f *boot, int_f *freelist, int_f *stab, int_f *shhdr) /******/ { - /* - * Fill in fake values [since we need a file ID to call H5Fget_info :-( -QAK ] - */ - *boot = (int_f)0; - *freelist = (int_f)0; - *stab = (int_f)0; - *shhdr = (int_f)0; + /* + * Fill in fake values [since we need a file ID to call H5Fget_info :-( -QAK ] + */ + *boot = (int_f)0; + *freelist = (int_f)0; + *stab = (int_f)0; + *shhdr = (int_f)0; - return 0; + return 0; } -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ int_f -h5pget_version_c (hid_t_f *prp_id, int_f * boot,int_f * freelist, int_f * stab, int_f *shhdr) +h5pget_version_c(hid_t_f *prp_id, int_f *boot, int_f *freelist, int_f *stab, int_f *shhdr) /******/ { - herr_t ret; - unsigned c_boot; - unsigned c_freelist; - unsigned c_stab; - unsigned c_shhdr; + herr_t ret; + unsigned c_boot; + unsigned c_freelist; + unsigned c_stab; + unsigned c_shhdr; - /* - * Call H5Pget_version function. - */ - ret = H5Pget_version((hid_t)*prp_id, &c_boot, &c_freelist, &c_stab, &c_shhdr); - if (ret < 0) return -1; + /* + * Call H5Pget_version function. + */ + ret = H5Pget_version((hid_t)*prp_id, &c_boot, &c_freelist, &c_stab, &c_shhdr); + if (ret < 0) + return -1; - *boot = (int_f)c_boot; - *freelist = (int_f)c_freelist; - *stab = (int_f)c_stab; - *shhdr = (int_f)c_shhdr; + *boot = (int_f)c_boot; + *freelist = (int_f)c_freelist; + *stab = (int_f)c_stab; + *shhdr = (int_f)c_shhdr; - return 0; + return 0; } #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -544,27 +547,28 @@ h5pget_version_c (hid_t_f *prp_id, int_f * boot,int_f * freelist, int_f * stab, * Xiangyang Su * Wednesday, February 23, 2000 * SOURCE -*/ + */ int_f -h5pget_userblock_c (hid_t_f *prp_id, hsize_t_f * size) +h5pget_userblock_c(hid_t_f *prp_id, hsize_t_f *size) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - hsize_t c_size; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + hsize_t c_size; - /* - * Call H5Pget_userblock function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_userblock(c_prp_id, &c_size); - if (ret < 0) return ret_value; + /* + * Call H5Pget_userblock function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_userblock(c_prp_id, &c_size); + if (ret < 0) + return ret_value; - *size = (hsize_t_f)c_size; - ret_value = 0; + *size = (hsize_t_f)c_size; + ret_value = 0; - return ret_value; + return ret_value; } /****if* H5Pf/h5pset_userblock_c @@ -582,26 +586,27 @@ h5pget_userblock_c (hid_t_f *prp_id, hsize_t_f * size) * Xiangyang Su * Wednesday, February 23, 2000 * SOURCE -*/ + */ int_f -h5pset_userblock_c (hid_t_f *prp_id, hsize_t_f * size) +h5pset_userblock_c(hid_t_f *prp_id, hsize_t_f *size) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - hsize_t c_size; - c_size = (hsize_t)*size; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + hsize_t c_size; + c_size = (hsize_t)*size; - /* - * Call H5Pset_userblock function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_userblock(c_prp_id, c_size); + /* + * Call H5Pset_userblock function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_userblock(c_prp_id, c_size); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_sizes_c @@ -622,29 +627,30 @@ h5pset_userblock_c (hid_t_f *prp_id, hsize_t_f * size) * HISTORY * Deleted extra length parameters. EP 6/7/00 * SOURCE -*/ + */ int_f -h5pget_sizes_c (hid_t_f *prp_id, size_t_f * sizeof_addr, size_t_f * sizeof_size) +h5pget_sizes_c(hid_t_f *prp_id, size_t_f *sizeof_addr, size_t_f *sizeof_size) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - size_t c_sizeof_addr; - size_t c_sizeof_size; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + size_t c_sizeof_addr; + size_t c_sizeof_size; - /* - * Call H5Pget_sizes function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_sizes(c_prp_id, &c_sizeof_addr, &c_sizeof_size); - if (ret < 0) return ret_value; + /* + * Call H5Pget_sizes function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_sizes(c_prp_id, &c_sizeof_addr, &c_sizeof_size); + if (ret < 0) + return ret_value; - *sizeof_addr = (size_t_f)c_sizeof_addr; - *sizeof_size = (size_t_f)c_sizeof_size; - ret_value = 0; + *sizeof_addr = (size_t_f)c_sizeof_addr; + *sizeof_size = (size_t_f)c_sizeof_size; + ret_value = 0; - return ret_value; + return ret_value; } /****if* H5Pf/h5pset_sizes_c @@ -664,27 +670,28 @@ h5pget_sizes_c (hid_t_f *prp_id, size_t_f * sizeof_addr, size_t_f * sizeof_size) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_sizes_c (hid_t_f *prp_id, size_t_f * sizeof_addr, size_t_f * sizeof_size) +h5pset_sizes_c(hid_t_f *prp_id, size_t_f *sizeof_addr, size_t_f *sizeof_size) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - size_t c_addr, c_size; - c_addr = (size_t)*sizeof_addr; - c_size = (size_t)*sizeof_size; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + size_t c_addr, c_size; + c_addr = (size_t)*sizeof_addr; + c_size = (size_t)*sizeof_size; - /* - * Call H5Pset_sizes function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_sizes(c_prp_id, c_addr, c_size); + /* + * Call H5Pset_sizes function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_sizes(c_prp_id, c_addr, c_size); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_sym_k_c @@ -703,28 +710,29 @@ h5pset_sizes_c (hid_t_f *prp_id, size_t_f * sizeof_addr, size_t_f * sizeof_size) * Xiangyang Su * Friday, February 25, 2000 * SOURCE -*/ + */ int_f -h5pset_sym_k_c (hid_t_f *prp_id, int_f* ik, int_f* lk) +h5pset_sym_k_c(hid_t_f *prp_id, int_f *ik, int_f *lk) /******/ { - int ret_value = -1; - hid_t c_prp_id; - unsigned c_ik; - unsigned c_lk; - herr_t ret; + int ret_value = -1; + hid_t c_prp_id; + unsigned c_ik; + unsigned c_lk; + herr_t ret; - /* - * Call H5Pset_sym_k function. - */ - c_prp_id = (hid_t)*prp_id; - c_ik = (unsigned)*ik; - c_lk = (unsigned)*lk; - ret = H5Pset_sym_k(c_prp_id, c_ik, c_lk); + /* + * Call H5Pset_sym_k function. + */ + c_prp_id = (hid_t)*prp_id; + c_ik = (unsigned)*ik; + c_lk = (unsigned)*lk; + ret = H5Pset_sym_k(c_prp_id, c_ik, c_lk); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_sym_k_c @@ -746,27 +754,28 @@ h5pset_sym_k_c (hid_t_f *prp_id, int_f* ik, int_f* lk) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_sym_k_c (hid_t_f *prp_id, int_f* ik, int_f* lk) +h5pget_sym_k_c(hid_t_f *prp_id, int_f *ik, int_f *lk) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - unsigned c_ik; - unsigned c_lk; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + unsigned c_ik; + unsigned c_lk; - /* - * Call H5Pget_sym_k function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_sym_k(c_prp_id, &c_ik, &c_lk); - *ik = (int_f)c_ik; - *lk = (int_f)c_lk; - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + /* + * Call H5Pget_sym_k function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_sym_k(c_prp_id, &c_ik, &c_lk); + *ik = (int_f)c_ik; + *lk = (int_f)c_lk; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_istore_k_c @@ -786,26 +795,27 @@ h5pget_sym_k_c (hid_t_f *prp_id, int_f* ik, int_f* lk) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_istore_k_c (hid_t_f *prp_id, int_f* ik) +h5pset_istore_k_c(hid_t_f *prp_id, int_f *ik) /******/ { - int ret_value = -1; - hid_t c_prp_id; - unsigned c_ik; - herr_t ret; + int ret_value = -1; + hid_t c_prp_id; + unsigned c_ik; + herr_t ret; - /* - * Call H5Pset_istore_k function. - */ - c_prp_id = (hid_t)*prp_id; - c_ik = (unsigned)*ik; - ret = H5Pset_istore_k(c_prp_id, c_ik); + /* + * Call H5Pset_istore_k function. + */ + c_prp_id = (hid_t)*prp_id; + c_ik = (unsigned)*ik; + ret = H5Pset_istore_k(c_prp_id, c_ik); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_istore_k_c @@ -826,25 +836,26 @@ h5pset_istore_k_c (hid_t_f *prp_id, int_f* ik) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_istore_k_c (hid_t_f *prp_id, int_f* ik) +h5pget_istore_k_c(hid_t_f *prp_id, int_f *ik) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - unsigned c_ik; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + unsigned c_ik; - /* - * Call H5Pget_istore_k function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_istore_k(c_prp_id, &c_ik); - *ik = (int_f)c_ik; - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + /* + * Call H5Pget_istore_k function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_istore_k(c_prp_id, &c_ik); + *ik = (int_f)c_ik; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_driver_c @@ -864,25 +875,26 @@ h5pget_istore_k_c (hid_t_f *prp_id, int_f* ik) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_driver_c (hid_t_f *prp_id, hid_t_f* driver) +h5pget_driver_c(hid_t_f *prp_id, hid_t_f *driver) /******/ { - int ret_value = -1; - hid_t c_driver; + int ret_value = -1; + hid_t c_driver; - /* - * Call H5Pget_driver function. - */ - c_driver = H5Pget_driver((hid_t)*prp_id); - if (c_driver < 0) goto DONE; + /* + * Call H5Pget_driver function. + */ + c_driver = H5Pget_driver((hid_t)*prp_id); + if (c_driver < 0) + goto DONE; - *driver = (hid_t_f) c_driver; - ret_value = 0; + *driver = (hid_t_f)c_driver; + ret_value = 0; DONE: - return ret_value; + return ret_value; } /****if* H5Pf/h5pset_fapl_stdio_c @@ -901,22 +913,23 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fapl_stdio_c (hid_t_f *prp_id) +h5pset_fapl_stdio_c(hid_t_f *prp_id) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - /* - * Call H5Pset_fapl_stdio function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_fapl_stdio(c_prp_id); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + /* + * Call H5Pset_fapl_stdio function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_fapl_stdio(c_prp_id); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } #ifdef NO_SUCH_F90_FUNCTION /****if* H5Pf/h5pget_fapl_stdio_c @@ -938,23 +951,24 @@ h5pset_fapl_stdio_c (hid_t_f *prp_id) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_fapl_stdio_c (hid_t_f *prp_id, int_f* io) +h5pget_fapl_stdio_c(hid_t_f *prp_id, int_f *io) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - /* - * Call H5Pget_fapl_stdio function. - */ - c_prp_id = *prp_id; - ret = H5Pget_fapl_stdio(c_prp_id); - if (ret < 0) return ret_value; - *io = (int_f)ret; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + /* + * Call H5Pget_fapl_stdio function. + */ + c_prp_id = *prp_id; + ret = H5Pget_fapl_stdio(c_prp_id); + if (ret < 0) + return ret_value; + *io = (int_f)ret; + ret_value = 0; + return ret_value; } #endif /*NO_SUCH_F90_FUNCTION*/ @@ -975,22 +989,23 @@ h5pget_fapl_stdio_c (hid_t_f *prp_id, int_f* io) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fapl_sec2_c (hid_t_f *prp_id) +h5pset_fapl_sec2_c(hid_t_f *prp_id) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - /* - * Call H5Pset_fapl_sec2 function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_fapl_sec2(c_prp_id); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + /* + * Call H5Pset_fapl_sec2 function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_fapl_sec2(c_prp_id); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } #ifdef NO_SUCH_F90_FUNCTION @@ -1013,23 +1028,24 @@ h5pset_fapl_sec2_c (hid_t_f *prp_id) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_fapl_sec2_c (hid_t_f *prp_id, int_f* sec2) +h5pget_fapl_sec2_c(hid_t_f *prp_id, int_f *sec2) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - /* - * Call H5Pget_fapl_sec2 function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_fapl_sec2(c_prp_id); - if (ret < 0) return ret_value; - *sec2 = (int_f)ret; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + /* + * Call H5Pget_fapl_sec2 function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_fapl_sec2(c_prp_id); + if (ret < 0) + return ret_value; + *sec2 = (int_f)ret; + ret_value = 0; + return ret_value; } #endif /*NO_SUCH_F90_FUNCTION*/ @@ -1051,25 +1067,26 @@ h5pget_fapl_sec2_c (hid_t_f *prp_id, int_f* sec2) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_alignment_c (hid_t_f *prp_id, hsize_t_f* threshold, hsize_t_f* alignment) +h5pset_alignment_c(hid_t_f *prp_id, hsize_t_f *threshold, hsize_t_f *alignment) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - hsize_t c_threshold, c_alignment; - c_threshold = (hsize_t)*threshold; - c_alignment = (hsize_t)* alignment; - /* - * Call H5Pset_alignment function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_alignment(c_prp_id, c_threshold, c_alignment); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + hsize_t c_threshold, c_alignment; + c_threshold = (hsize_t)*threshold; + c_alignment = (hsize_t)*alignment; + /* + * Call H5Pset_alignment function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_alignment(c_prp_id, c_threshold, c_alignment); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_alignment_c @@ -1090,26 +1107,27 @@ h5pset_alignment_c (hid_t_f *prp_id, hsize_t_f* threshold, hsize_t_f* alignment) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_alignment_c (hid_t_f *prp_id, hsize_t_f* threshold, hsize_t_f* alignment) +h5pget_alignment_c(hid_t_f *prp_id, hsize_t_f *threshold, hsize_t_f *alignment) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - hsize_t c_threshold, c_alignment; - /* - * Call H5Pget_alignment function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_alignment(c_prp_id, &c_threshold, &c_alignment); - if (ret < 0) return ret_value; - *threshold = (hsize_t_f)c_threshold; - *alignment = (hsize_t_f)c_alignment; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + hsize_t c_threshold, c_alignment; + /* + * Call H5Pget_alignment function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_alignment(c_prp_id, &c_threshold, &c_alignment); + if (ret < 0) + return ret_value; + *threshold = (hsize_t_f)c_threshold; + *alignment = (hsize_t_f)c_alignment; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_fapl_core_c @@ -1131,27 +1149,28 @@ h5pget_alignment_c (hid_t_f *prp_id, hsize_t_f* threshold, hsize_t_f* alignment) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fapl_core_c (hid_t_f *prp_id, size_t_f* increment, int_f *flag) +h5pset_fapl_core_c(hid_t_f *prp_id, size_t_f *increment, int_f *flag) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - size_t c_increment; - hbool_t c_backing_store; - c_increment = (size_t)*increment; - c_backing_store = (hbool_t)*flag; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + size_t c_increment; + hbool_t c_backing_store; + c_increment = (size_t)*increment; + c_backing_store = (hbool_t)*flag; - /* - * Call H5Pset_fapl_core function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_fapl_core(c_prp_id, c_increment, c_backing_store); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + /* + * Call H5Pset_fapl_core function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_fapl_core(c_prp_id, c_increment, c_backing_store); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_fapl_core_c @@ -1171,27 +1190,29 @@ h5pset_fapl_core_c (hid_t_f *prp_id, size_t_f* increment, int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_fapl_core_c (hid_t_f *prp_id, size_t_f* increment, int_f *flag) +h5pget_fapl_core_c(hid_t_f *prp_id, size_t_f *increment, int_f *flag) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - size_t c_increment = 0; - hbool_t c_backing_store; - *flag = 0; - /* - * Call H5Pset_fapl_core function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_fapl_core(c_prp_id, &c_increment, &c_backing_store); - if (ret < 0) return ret_value; - *increment = (size_t_f)c_increment; - if(c_backing_store > 0) *flag = 1; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + size_t c_increment = 0; + hbool_t c_backing_store; + *flag = 0; + /* + * Call H5Pset_fapl_core function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_fapl_core(c_prp_id, &c_increment, &c_backing_store); + if (ret < 0) + return ret_value; + *increment = (size_t_f)c_increment; + if (c_backing_store > 0) + *flag = 1; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_fapl_family_c @@ -1213,26 +1234,27 @@ h5pget_fapl_core_c (hid_t_f *prp_id, size_t_f* increment, int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fapl_family_c(hid_t_f *prp_id, hsize_t_f* memb_size, hid_t_f* memb_plist ) +h5pset_fapl_family_c(hid_t_f *prp_id, hsize_t_f *memb_size, hid_t_f *memb_plist) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - hsize_t c_memb_size; - hid_t c_memb_plist; - c_memb_size =(hsize_t) *memb_size; - c_memb_plist =(hid_t) *memb_plist; - /* - * Call H5Pset_fapl_family function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_fapl_family(c_prp_id, c_memb_size, c_memb_plist); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + hsize_t c_memb_size; + hid_t c_memb_plist; + c_memb_size = (hsize_t)*memb_size; + c_memb_plist = (hid_t)*memb_plist; + /* + * Call H5Pset_fapl_family function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_fapl_family(c_prp_id, c_memb_size, c_memb_plist); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_fapl_family_c @@ -1254,27 +1276,28 @@ h5pset_fapl_family_c(hid_t_f *prp_id, hsize_t_f* memb_size, hid_t_f* memb_plist * HISTORY * * SOURCE -*/ + */ int_f -h5pget_fapl_family_c(hid_t_f *prp_id, hsize_t_f* memb_size, hid_t_f* memb_plist) +h5pget_fapl_family_c(hid_t_f *prp_id, hsize_t_f *memb_size, hid_t_f *memb_plist) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - hsize_t c_memb_size = 0; - hid_t c_memb_plist = -1; - /* - * Call H5Pget_fapl_family function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_fapl_family(c_prp_id, &c_memb_size, &c_memb_plist); - if (ret < 0) return ret_value; - *memb_size = (hsize_t_f)c_memb_size; - *memb_plist = (hid_t_f)c_memb_plist; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + hsize_t c_memb_size = 0; + hid_t c_memb_plist = -1; + /* + * Call H5Pget_fapl_family function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_fapl_family(c_prp_id, &c_memb_size, &c_memb_plist); + if (ret < 0) + return ret_value; + *memb_size = (hsize_t_f)c_memb_size; + *memb_plist = (hid_t_f)c_memb_plist; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_cache_c @@ -1299,31 +1322,33 @@ h5pget_fapl_family_c(hid_t_f *prp_id, hsize_t_f* memb_size, hid_t_f* memb_plist) * Changed the type of the rdcc_w0 parameter to be real_f EP 7/7/00 * instead of double * SOURCE -*/ + */ int_f -h5pset_cache_c(hid_t_f *prp_id, int_f* mdc_nelmts, size_t_f* rdcc_nelmts, size_t_f* rdcc_nbytes , real_f* rdcc_w0 ) +h5pset_cache_c(hid_t_f *prp_id, int_f *mdc_nelmts, size_t_f *rdcc_nelmts, size_t_f *rdcc_nbytes, + real_f *rdcc_w0) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - int c_mdc_nelmts; - size_t c_rdcc_nelmts; - size_t c_rdcc_nbytes; - double c_rdcc_w0; - c_rdcc_nbytes =(size_t) *rdcc_nbytes; - c_rdcc_w0 = (double)*rdcc_w0; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + int c_mdc_nelmts; + size_t c_rdcc_nelmts; + size_t c_rdcc_nbytes; + double c_rdcc_w0; + c_rdcc_nbytes = (size_t)*rdcc_nbytes; + c_rdcc_w0 = (double)*rdcc_w0; - /* - * Call H5Pset_cache function. - */ - c_prp_id = (hid_t)*prp_id; - c_mdc_nelmts = (int)*mdc_nelmts; - c_rdcc_nelmts = (size_t)*rdcc_nelmts; - ret = H5Pset_cache(c_prp_id, c_mdc_nelmts, c_rdcc_nelmts, c_rdcc_nbytes, c_rdcc_w0 ); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + /* + * Call H5Pset_cache function. + */ + c_prp_id = (hid_t)*prp_id; + c_mdc_nelmts = (int)*mdc_nelmts; + c_rdcc_nelmts = (size_t)*rdcc_nelmts; + ret = H5Pset_cache(c_prp_id, c_mdc_nelmts, c_rdcc_nelmts, c_rdcc_nbytes, c_rdcc_w0); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_cache_c @@ -1351,31 +1376,33 @@ h5pset_cache_c(hid_t_f *prp_id, int_f* mdc_nelmts, size_t_f* rdcc_nelmts, size_ * Changed type of the rdcc_nelmts parameter to be int_f. * EIP October 10, 2003 * SOURCE -*/ + */ int_f -h5pget_cache_c(hid_t_f *prp_id, int_f* mdc_nelmts, size_t_f* rdcc_nelmts, size_t_f* rdcc_nbytes , real_f* rdcc_w0) +h5pget_cache_c(hid_t_f *prp_id, int_f *mdc_nelmts, size_t_f *rdcc_nelmts, size_t_f *rdcc_nbytes, + real_f *rdcc_w0) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - int c_mdc_nelmts; - size_t c_rdcc_nelmts; - size_t c_rdcc_nbytes; - double c_rdcc_w0; - /* - * Call H5Pget_cache function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_cache(c_prp_id, &c_mdc_nelmts, &c_rdcc_nelmts, &c_rdcc_nbytes, &c_rdcc_w0); - if (ret < 0) return ret_value; - *mdc_nelmts = (int_f)c_mdc_nelmts; - *rdcc_nelmts = (size_t_f)c_rdcc_nelmts; - *rdcc_nbytes = (size_t_f)c_rdcc_nbytes; - *rdcc_w0 = (real_f)c_rdcc_w0; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + int c_mdc_nelmts; + size_t c_rdcc_nelmts; + size_t c_rdcc_nbytes; + double c_rdcc_w0; + /* + * Call H5Pget_cache function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_cache(c_prp_id, &c_mdc_nelmts, &c_rdcc_nelmts, &c_rdcc_nbytes, &c_rdcc_w0); + if (ret < 0) + return ret_value; + *mdc_nelmts = (int_f)c_mdc_nelmts; + *rdcc_nelmts = (size_t_f)c_rdcc_nelmts; + *rdcc_nbytes = (size_t_f)c_rdcc_nbytes; + *rdcc_w0 = (real_f)c_rdcc_w0; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_fapl_split_c @@ -1400,44 +1427,47 @@ h5pget_cache_c(hid_t_f *prp_id, int_f* mdc_nelmts, size_t_f* rdcc_nelmts, size_t * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fapl_split_c(hid_t_f *prp_id, int_f* meta_len, _fcd meta_ext, hid_t_f* meta_plist, int_f* raw_len, _fcd raw_ext, hid_t_f * raw_plist) +h5pset_fapl_split_c(hid_t_f *prp_id, int_f *meta_len, _fcd meta_ext, hid_t_f *meta_plist, int_f *raw_len, + _fcd raw_ext, hid_t_f *raw_plist) /******/ { - int ret_value = -1; - hid_t c_prp_id; - hid_t c_meta_plist; - hid_t c_raw_plist; - herr_t ret = -1; - char* c_meta_ext; - char* c_raw_ext; + int ret_value = -1; + hid_t c_prp_id; + hid_t c_meta_plist; + hid_t c_raw_plist; + herr_t ret = -1; + char * c_meta_ext; + char * c_raw_ext; - c_meta_ext = (char *)HD5f2cstring(meta_ext, (size_t)*meta_len); - if (c_meta_ext == NULL) return ret_value; - c_raw_ext = (char *)HD5f2cstring(raw_ext, (size_t)*raw_len); - if (c_raw_ext == NULL) { HDfree(c_meta_ext); - return ret_value; - } + c_meta_ext = (char *)HD5f2cstring(meta_ext, (size_t)*meta_len); + if (c_meta_ext == NULL) + return ret_value; + c_raw_ext = (char *)HD5f2cstring(raw_ext, (size_t)*raw_len); + if (c_raw_ext == NULL) { + HDfree(c_meta_ext); + return ret_value; + } - /* - * Call H5Pset_fapl_split function. - */ - c_prp_id = (hid_t)*prp_id; - c_meta_plist = (hid_t)*meta_plist; - c_raw_plist = (hid_t)*raw_plist; - ret = H5Pset_fapl_split(c_prp_id, c_meta_ext, c_meta_plist, c_raw_ext, c_raw_plist ); + /* + * Call H5Pset_fapl_split function. + */ + c_prp_id = (hid_t)*prp_id; + c_meta_plist = (hid_t)*meta_plist; + c_raw_plist = (hid_t)*raw_plist; + ret = H5Pset_fapl_split(c_prp_id, c_meta_ext, c_meta_plist, c_raw_ext, c_raw_plist); - if (ret < 0) goto DONE; - ret_value = 0; + if (ret < 0) + goto DONE; + ret_value = 0; DONE: - HDfree(c_meta_ext); - HDfree(c_raw_ext); - return ret_value; + HDfree(c_meta_ext); + HDfree(c_raw_ext); + return ret_value; } - #ifdef NO_SUCH_F90_FUNCTION /****if* H5Pf/h5pget_fapl_split_c * NAME @@ -1464,41 +1494,45 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5pget_fapl_split_c(hid_t_f *prp_id, size_t_f* meta_ext_size , _fcd meta_ext, hid_t_f* meta_plist, size_t_f* raw_ext_size, _fcd raw_ext, hid_t_f * raw_plist) +h5pget_fapl_split_c(hid_t_f *prp_id, size_t_f *meta_ext_size, _fcd meta_ext, hid_t_f *meta_plist, + size_t_f *raw_ext_size, _fcd raw_ext, hid_t_f *raw_plist) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret = -1; - size_t c_meta_ext_size, c_raw_ext_size; - hid_t c_meta_plist = -1; - hid_t c_raw_plist = -1; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret = -1; + size_t c_meta_ext_size, c_raw_ext_size; + hid_t c_meta_plist = -1; + hid_t c_raw_plist = -1; - char* c_meta_ext = NULL; - char* c_raw_ext = NULL; + char *c_meta_ext = NULL; + char *c_raw_ext = NULL; - c_meta_ext_size = (size_t) *meta_ext_size; - c_raw_ext_size = (size_t) *raw_ext_size; - c_meta_ext = (char *)HDmalloc(sizeof(char) * c_meta_ext_size); - c_raw_ext = (char *)HDmalloc(sizeof(char) * c_raw_ext_size); - if(c_meta_ext == NULL || c_raw_ext == NULL) return ret_value; + c_meta_ext_size = (size_t)*meta_ext_size; + c_raw_ext_size = (size_t)*raw_ext_size; + c_meta_ext = (char *)HDmalloc(sizeof(char) * c_meta_ext_size); + c_raw_ext = (char *)HDmalloc(sizeof(char) * c_raw_ext_size); + if (c_meta_ext == NULL || c_raw_ext == NULL) + return ret_value; - /* - * Call H5Pget_fapl_split function. - */ - c_prp_id = *prp_id; - ret = H5Pget_fapl_split(c_prp_id, c_meta_ext_size, c_meta_ext,&c_meta_plist, c_raw_ext_size, c_raw_ext, &c_raw_plist ); + /* + * Call H5Pget_fapl_split function. + */ + c_prp_id = *prp_id; + ret = H5Pget_fapl_split(c_prp_id, c_meta_ext_size, c_meta_ext, &c_meta_plist, c_raw_ext_size, c_raw_ext, + &c_raw_plist); - if (ret < 0) return ret_value; - *meta_plist = c_meta_plist; - *raw_plist = c_raw_plist; - HD5packFstring(c_meta_ext, _fcdtocp(meta_ext), strlen(c_meta_ext)); - HD5packFstring(c_raw_ext, _fcdtocp(raw_ext), strlen(c_raw_ext)); + if (ret < 0) + return ret_value; + *meta_plist = c_meta_plist; + *raw_plist = c_raw_plist; + HD5packFstring(c_meta_ext, _fcdtocp(meta_ext), strlen(c_meta_ext)); + HD5packFstring(c_raw_ext, _fcdtocp(raw_ext), strlen(c_raw_ext)); - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } #endif /*NO_SUCH_F90_FUNCTION*/ @@ -1520,26 +1554,27 @@ h5pget_fapl_split_c(hid_t_f *prp_id, size_t_f* meta_ext_size , _fcd meta_ext, hi * HISTORY * * SOURCE -*/ + */ int_f -h5pset_gc_references_c (hid_t_f *prp_id, int_f* gc_references) +h5pset_gc_references_c(hid_t_f *prp_id, int_f *gc_references) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - unsigned c_gc_references; - c_gc_references = (unsigned)*gc_references; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + unsigned c_gc_references; + c_gc_references = (unsigned)*gc_references; - /* - * Call H5Pset_gc_references function. - */ - c_prp_id = *prp_id; - ret = H5Pset_gc_references(c_prp_id, c_gc_references); + /* + * Call H5Pset_gc_references function. + */ + c_prp_id = *prp_id; + ret = H5Pset_gc_references(c_prp_id, c_gc_references); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_gc_references_c @@ -1560,24 +1595,25 @@ h5pset_gc_references_c (hid_t_f *prp_id, int_f* gc_references) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_gc_references_c (hid_t_f *prp_id, int_f* gc_references) +h5pget_gc_references_c(hid_t_f *prp_id, int_f *gc_references) /******/ { - int ret_value = -1; - hid_t c_prp_id; - unsigned c_gc_references; - herr_t ret; - /* - * Call H5Pget_gc_references function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_gc_references(c_prp_id, &c_gc_references); - if (ret < 0) return ret_value; - *gc_references = (int_f)c_gc_references; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + unsigned c_gc_references; + herr_t ret; + /* + * Call H5Pget_gc_references function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_gc_references(c_prp_id, &c_gc_references); + if (ret < 0) + return ret_value; + *gc_references = (int_f)c_gc_references; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_layout_c @@ -1597,25 +1633,26 @@ h5pget_gc_references_c (hid_t_f *prp_id, int_f* gc_references) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_layout_c (hid_t_f *prp_id, int_f* layout) +h5pset_layout_c(hid_t_f *prp_id, int_f *layout) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - H5D_layout_t c_layout; - c_layout = (H5D_layout_t)*layout; - /* - * Call H5Pset_layout function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_layout(c_prp_id, c_layout); + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + H5D_layout_t c_layout; + c_layout = (H5D_layout_t)*layout; + /* + * Call H5Pset_layout function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_layout(c_prp_id, c_layout); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_layout_c @@ -1636,23 +1673,24 @@ h5pset_layout_c (hid_t_f *prp_id, int_f* layout) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_layout_c (hid_t_f *prp_id, int_f* layout) +h5pget_layout_c(hid_t_f *prp_id, int_f *layout) /******/ { - int ret_value = -1; - hid_t c_prp_id; - H5D_layout_t c_layout; - /* - * Call H5Pget_layout function. - */ - c_prp_id = (hid_t)*prp_id; - c_layout = H5Pget_layout(c_prp_id); - if (c_layout < 0) return ret_value; - *layout = (int_f)c_layout; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + H5D_layout_t c_layout; + /* + * Call H5Pget_layout function. + */ + c_prp_id = (hid_t)*prp_id; + c_layout = H5Pget_layout(c_prp_id); + if (c_layout < 0) + return ret_value; + *layout = (int_f)c_layout; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_filter_c @@ -1675,36 +1713,38 @@ h5pget_layout_c (hid_t_f *prp_id, int_f* layout) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_filter_c (hid_t_f *prp_id, int_f* filter, int_f* flags, size_t_f* cd_nelmts, int_f* cd_values ) +h5pset_filter_c(hid_t_f *prp_id, int_f *filter, int_f *flags, size_t_f *cd_nelmts, int_f *cd_values) /******/ { - int ret_value = -1; - hid_t c_prp_id = (hid_t)*prp_id; - herr_t ret; - size_t c_cd_nelmts = (size_t)*cd_nelmts; - unsigned int c_flags = (unsigned)*flags; - H5Z_filter_t c_filter = (H5Z_filter_t)*filter; - unsigned int * c_cd_values; - unsigned i; + int ret_value = -1; + hid_t c_prp_id = (hid_t)*prp_id; + herr_t ret; + size_t c_cd_nelmts = (size_t)*cd_nelmts; + unsigned int c_flags = (unsigned)*flags; + H5Z_filter_t c_filter = (H5Z_filter_t)*filter; + unsigned int *c_cd_values; + unsigned i; - c_cd_values = (unsigned int*)HDmalloc(sizeof(unsigned int) * c_cd_nelmts); - if (!c_cd_values) return ret_value; - for (i = 0; i < c_cd_nelmts; i++) - c_cd_values[i] = (unsigned int)cd_values[i]; + c_cd_values = (unsigned int *)HDmalloc(sizeof(unsigned int) * c_cd_nelmts); + if (!c_cd_values) + return ret_value; + for (i = 0; i < c_cd_nelmts; i++) + c_cd_values[i] = (unsigned int)cd_values[i]; - /* - * Call H5Pset_filter function. - */ - ret = H5Pset_filter(c_prp_id, c_filter, c_flags, c_cd_nelmts,c_cd_values ); + /* + * Call H5Pset_filter function. + */ + ret = H5Pset_filter(c_prp_id, c_filter, c_flags, c_cd_nelmts, c_cd_values); - if (ret < 0) goto DONE; - ret_value = 0; + if (ret < 0) + goto DONE; + ret_value = 0; DONE: - HDfree(c_cd_values); - return ret_value; + HDfree(c_cd_values); + return ret_value; } /****if* H5Pf/h5pget_nfilters_c @@ -1723,25 +1763,26 @@ DONE: * Xiangyang Su * Friday, February 25, 2000 * SOURCE -*/ + */ int_f -h5pget_nfilters_c (hid_t_f *prp_id, int_f* nfilters) +h5pget_nfilters_c(hid_t_f *prp_id, int_f *nfilters) /******/ { - int ret_value = -1; - hid_t c_prp_id; - int c_nfilters; - /* - * Call H5Pget_nfilters function. - */ - c_prp_id = (hid_t)*prp_id; - c_nfilters = H5Pget_nfilters(c_prp_id); - if (c_nfilters < 0) return ret_value; + int ret_value = -1; + hid_t c_prp_id; + int c_nfilters; + /* + * Call H5Pget_nfilters function. + */ + c_prp_id = (hid_t)*prp_id; + c_nfilters = H5Pget_nfilters(c_prp_id); + if (c_nfilters < 0) + return ret_value; - *nfilters = (int_f)c_nfilters; - ret_value = 0; + *nfilters = (int_f)c_nfilters; + ret_value = 0; - return ret_value; + return ret_value; } /*---------------------------------------------------------------------------- @@ -1768,45 +1809,47 @@ h5pget_nfilters_c (hid_t_f *prp_id, int_f* nfilters) * MSB January 27, 2009 *---------------------------------------------------------------------------*/ int_f -h5pget_filter_c(hid_t_f *prp_id, int_f* filter_number, int_f* flags, size_t_f* cd_nelmts, int_f* cd_values, size_t_f *namelen, _fcd name, int_f* filter_id) +h5pget_filter_c(hid_t_f *prp_id, int_f *filter_number, int_f *flags, size_t_f *cd_nelmts, int_f *cd_values, + size_t_f *namelen, _fcd name, int_f *filter_id) /******/ { unsigned int c_flags; - size_t c_cd_nelmts = 0; - H5Z_filter_t c_filter; + size_t c_cd_nelmts = 0; + H5Z_filter_t c_filter; unsigned int *c_cd_values = NULL; - char *c_name = NULL; - unsigned i; - int ret_value = -1; + char * c_name = NULL; + unsigned i; + int ret_value = -1; c_cd_nelmts = (size_t)*cd_nelmts; - if(NULL == (c_name = (char *)HDmalloc((size_t)*namelen + 1))) + if (NULL == (c_name = (char *)HDmalloc((size_t)*namelen + 1))) goto DONE; - if(NULL == (c_cd_values = (unsigned int *)HDmalloc(sizeof(unsigned int) * c_cd_nelmts))) + if (NULL == (c_cd_values = (unsigned int *)HDmalloc(sizeof(unsigned int) * c_cd_nelmts))) goto DONE; /* * Call H5Pget_filter2 function. */ - if((c_filter = H5Pget_filter2((hid_t)*prp_id, (unsigned)*filter_number, &c_flags, &c_cd_nelmts, c_cd_values, (size_t)*namelen, c_name, NULL)) < 0) + if ((c_filter = H5Pget_filter2((hid_t)*prp_id, (unsigned)*filter_number, &c_flags, &c_cd_nelmts, + c_cd_values, (size_t)*namelen, c_name, NULL)) < 0) goto DONE; *filter_id = (int_f)c_filter; *cd_nelmts = (size_t_f)c_cd_nelmts; - *flags = (int_f)c_flags; + *flags = (int_f)c_flags; HD5packFstring(c_name, _fcdtocp(name), strlen(c_name)); - for(i = 0; i < c_cd_nelmts; i++) - cd_values[i] = (int_f)c_cd_values[i]; + for (i = 0; i < c_cd_nelmts; i++) + cd_values[i] = (int_f)c_cd_values[i]; ret_value = 0; DONE: - if(c_name) + if (c_name) HDfree(c_name); - if(c_cd_values) + if (c_cd_values) HDfree(c_cd_values); return ret_value; } @@ -1833,37 +1876,38 @@ DONE: * Changed type of 'offset' from int_f to off_t_f -- MSB January 9, 2012 * * SOURCE -*/ + */ int_f -h5pset_external_c (hid_t_f *prp_id, _fcd name, int_f* namelen, off_t_f* offset, hsize_t_f*bytes) +h5pset_external_c(hid_t_f *prp_id, _fcd name, int_f *namelen, off_t_f *offset, hsize_t_f *bytes) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - hsize_t c_bytes; - char* c_name; - size_t c_namelen = (size_t)*namelen; - off_t c_offset; - c_bytes = (hsize_t) *bytes; - c_offset = (off_t) *offset; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + hsize_t c_bytes; + char * c_name; + size_t c_namelen = (size_t)*namelen; + off_t c_offset; + c_bytes = (hsize_t)*bytes; + c_offset = (off_t)*offset; + c_name = (char *)HD5f2cstring(name, c_namelen); + if (c_name == NULL) + return ret_value; - c_name = (char *)HD5f2cstring(name, c_namelen); - if (c_name == NULL) return ret_value; - - /* - * Call H5Pset_external function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_external(c_prp_id, c_name, c_offset, c_bytes); + /* + * Call H5Pset_external function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_external(c_prp_id, c_name, c_offset, c_bytes); - if (ret < 0) goto DONE; - ret_value = 0; + if (ret < 0) + goto DONE; + ret_value = 0; DONE: - HDfree(c_name); - return ret_value; + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pget_external_count_c @@ -1884,23 +1928,24 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5pget_external_count_c (hid_t_f *prp_id, int_f* count) +h5pget_external_count_c(hid_t_f *prp_id, int_f *count) /******/ { - int ret_value = -1; - hid_t c_prp_id; - int c_count; - /* - * Call H5Pget_external_count function. - */ - c_prp_id = (hid_t)*prp_id; - c_count = H5Pget_external_count(c_prp_id); - if (c_count < 0) return ret_value; - *count = (int_f)c_count; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_prp_id; + int c_count; + /* + * Call H5Pget_external_count function. + */ + c_prp_id = (hid_t)*prp_id; + c_count = H5Pget_external_count(c_prp_id); + if (c_count < 0) + return ret_value; + *count = (int_f)c_count; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_external_c @@ -1926,93 +1971,90 @@ h5pget_external_count_c (hid_t_f *prp_id, int_f* count) * Changed type of 'offset' from integer to off_t -- MSB January 9, 2012 * * SOURCE -*/ -int_f -h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f* name_size, _fcd name, off_t_f* offset, hsize_t_f*bytes) -/******/ -{ - int ret_value = -1; - hid_t c_prp_id; - unsigned c_idx; - herr_t status; - size_t c_namelen; - char* c_name = NULL; - off_t c_offset; - hsize_t size; - - c_namelen = (size_t)*name_size; - /* - * Allocate memory to store the name of the external file. - */ - if(c_namelen) c_name = (char*)HDmalloc(c_namelen + 1); - if (c_name == NULL) return ret_value; - - /* - * Call H5Pget_external function. - */ - c_prp_id = (hid_t)*prp_id; - c_idx = (unsigned)*idx; - status = H5Pget_external(c_prp_id, c_idx, c_namelen+1, c_name, &c_offset, &size ); - - if (status < 0) goto DONE; - - *offset = (off_t_f)c_offset; - *bytes = (hsize_t_f)size; - /* Note: if the size of the fortran buffer is larger then the returned string - * from the function then we need to give HD5packFstring the fortran buffer size so - * that it fills the remaining unused characters with blanks. MSB - */ - HD5packFstring(c_name, _fcdtocp(name), c_namelen); - ret_value = 0; + */ +int_f +h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f *name_size, _fcd name, off_t_f *offset, + hsize_t_f *bytes) +/******/ +{ + int ret_value = -1; + hid_t c_prp_id; + unsigned c_idx; + herr_t status; + size_t c_namelen; + char * c_name = NULL; + off_t c_offset; + hsize_t size; + + c_namelen = (size_t)*name_size; + /* + * Allocate memory to store the name of the external file. + */ + if (c_namelen) + c_name = (char *)HDmalloc(c_namelen + 1); + if (c_name == NULL) + return ret_value; + + /* + * Call H5Pget_external function. + */ + c_prp_id = (hid_t)*prp_id; + c_idx = (unsigned)*idx; + status = H5Pget_external(c_prp_id, c_idx, c_namelen + 1, c_name, &c_offset, &size); + + if (status < 0) + goto DONE; + + *offset = (off_t_f)c_offset; + *bytes = (hsize_t_f)size; + /* Note: if the size of the fortran buffer is larger then the returned string + * from the function then we need to give HD5packFstring the fortran buffer size so + * that it fills the remaining unused characters with blanks. MSB + */ + HD5packFstring(c_name, _fcdtocp(name), c_namelen); + ret_value = 0; DONE: - HDfree(c_name); - return ret_value; + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pset_btree_ratios_c * NAME * h5pset_btree_ratios_c * PURPOSE - * Call H5Pset_btree_ratios to set B-tree split ratios for B-tree split ratios for a dataset transfer property list. a - * dataset transfer property list. - * INPUTS - * prp_id - property list identifier - * left - The B-tree split ratio for left-most nodes. - * middle - The B-tree split ratio for all other nodes - * right - The B-tree split ratio for right-most nodes - * and lone nodes. - * RETURNS - * 0 on success, -1 on failure - * AUTHOR - * Xiangyang Su + * Call H5Pset_btree_ratios to set B-tree split ratios for B-tree split ratios for a dataset transfer + * property list. a dataset transfer property list. INPUTS prp_id - property list identifier left - The B-tree + * split ratio for left-most nodes. middle - The B-tree split ratio for all other nodes right - The B-tree + * split ratio for right-most nodes and lone nodes. RETURNS 0 on success, -1 on failure AUTHOR Xiangyang Su * Friday, February 25, 2000 * HISTORY * Changed the type of the last three parameters from double to real_f * SOURCE -*/ + */ int_f -h5pset_btree_ratios_c(hid_t_f *prp_id, real_f* left, real_f* middle, real_f* right) +h5pset_btree_ratios_c(hid_t_f *prp_id, real_f *left, real_f *middle, real_f *right) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - double c_left; - double c_middle; - double c_right; - c_left = (double)*left; - c_middle = (double)*middle; - c_right = (double)*right; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + double c_left; + double c_middle; + double c_right; + c_left = (double)*left; + c_middle = (double)*middle; + c_right = (double)*right; - /* - * Call H5Pset_btree_ratios function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pset_btree_ratios(c_prp_id, c_left, c_middle, c_right); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + /* + * Call H5Pset_btree_ratios function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pset_btree_ratios(c_prp_id, c_left, c_middle, c_right); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_btree_ratios_c @@ -2035,27 +2077,28 @@ h5pset_btree_ratios_c(hid_t_f *prp_id, real_f* left, real_f* middle, real_f* rig * HISTORY * Changed the type of the last three parameters from double to real_f * SOURCE -*/ + */ int_f -h5pget_btree_ratios_c(hid_t_f *prp_id, real_f* left, real_f* middle, real_f* right) +h5pget_btree_ratios_c(hid_t_f *prp_id, real_f *left, real_f *middle, real_f *right) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - double c_left, c_right, c_middle; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + double c_left, c_right, c_middle; - /* - * Call H5Pget_btree_ratios function. - */ - c_prp_id = (hid_t)*prp_id; - ret = H5Pget_btree_ratios(c_prp_id, &c_left, &c_middle, &c_right); - *left = (real_f)c_left; - *middle = (real_f)c_middle; - *right = (real_f)c_right; - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + /* + * Call H5Pget_btree_ratios function. + */ + c_prp_id = (hid_t)*prp_id; + ret = H5Pget_btree_ratios(c_prp_id, &c_left, &c_middle, &c_right); + *left = (real_f)c_left; + *middle = (real_f)c_middle; + *right = (real_f)c_right; + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_fclose_degree_c * NAME @@ -2079,22 +2122,23 @@ h5pget_btree_ratios_c(hid_t_f *prp_id, real_f* left, real_f* middle, real_f* rig * HISTORY * * SOURCE -*/ + */ int_f -h5pget_fclose_degree_c ( hid_t_f *fapl_id , int_f *degree) +h5pget_fclose_degree_c(hid_t_f *fapl_id, int_f *degree) /******/ { - int ret_value = -1; - hid_t c_fapl_id; - H5F_close_degree_t c_degree; + int ret_value = -1; + hid_t c_fapl_id; + H5F_close_degree_t c_degree; - c_fapl_id = (hid_t)*fapl_id; - if( H5Pget_fclose_degree(c_fapl_id, &c_degree) < 0) return ret_value; + c_fapl_id = (hid_t)*fapl_id; + if (H5Pget_fclose_degree(c_fapl_id, &c_degree) < 0) + return ret_value; - *degree = (int_f)c_degree; - ret_value = 0; - return ret_value; + *degree = (int_f)c_degree; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_fclose_degree_c @@ -2117,22 +2161,23 @@ h5pget_fclose_degree_c ( hid_t_f *fapl_id , int_f *degree) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fclose_degree_c ( hid_t_f *fapl_id , int_f *degree) +h5pset_fclose_degree_c(hid_t_f *fapl_id, int_f *degree) /******/ { - int ret_value = -1; - hid_t c_fapl_id; - H5F_close_degree_t c_degree; + int ret_value = -1; + hid_t c_fapl_id; + H5F_close_degree_t c_degree; - c_fapl_id = (hid_t)*fapl_id; - c_degree = (H5F_close_degree_t)*degree; - if( H5Pset_fclose_degree(c_fapl_id, c_degree) < 0) return ret_value; + c_fapl_id = (hid_t)*fapl_id; + c_degree = (H5F_close_degree_t)*degree; + if (H5Pset_fclose_degree(c_fapl_id, c_degree) < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_buffer_c @@ -2153,21 +2198,22 @@ h5pset_fclose_degree_c ( hid_t_f *fapl_id , int_f *degree) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_buffer_c ( hid_t_f *prp_id , hsize_t_f *size) +h5pset_buffer_c(hid_t_f *prp_id, hsize_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - size_t c_size; + int ret_value = 0; + hid_t c_prp_id; + size_t c_size; - c_prp_id = (hid_t)*prp_id; - c_size = (size_t)*size; - if ( H5Pset_buffer(c_prp_id, c_size, NULL, NULL) < 0 ) ret_value = -1; - return ret_value; -} + c_prp_id = (hid_t)*prp_id; + c_size = (size_t)*size; + if (H5Pset_buffer(c_prp_id, c_size, NULL, NULL) < 0) + ret_value = -1; + return ret_value; +} /****if* H5Pf/h5pget_buffer_c * NAME @@ -2186,22 +2232,23 @@ h5pset_buffer_c ( hid_t_f *prp_id , hsize_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_buffer_c ( hid_t_f *prp_id , hsize_t_f *size) +h5pget_buffer_c(hid_t_f *prp_id, hsize_t_f *size) /******/ { - int ret_value = -1; - hid_t c_prp_id; - hsize_t c_size; + int ret_value = -1; + hid_t c_prp_id; + hsize_t c_size; - c_prp_id = (hid_t)*prp_id; - c_size = H5Pget_buffer(c_prp_id, NULL, NULL); - if ( c_size == 0 ) return ret_value; - *size = (hsize_t_f)c_size; - ret_value = 0; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_size = H5Pget_buffer(c_prp_id, NULL, NULL); + if (c_size == 0) + return ret_value; + *size = (hsize_t_f)c_size; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pfill_value_defined_c * NAME @@ -2220,21 +2267,22 @@ h5pget_buffer_c ( hid_t_f *prp_id , hsize_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pfill_value_defined_c ( hid_t_f *prp_id , int_f *flag) +h5pfill_value_defined_c(hid_t_f *prp_id, int_f *flag) /******/ { - int ret_value = -1; - hid_t c_prp_id; - H5D_fill_value_t c_flag; + int ret_value = -1; + hid_t c_prp_id; + H5D_fill_value_t c_flag; - c_prp_id = (hid_t)*prp_id; - if ( H5Pfill_value_defined(c_prp_id, &c_flag) < 0 ) return ret_value; - *flag = (int_f)c_flag; - ret_value = 0; - return ret_value; + c_prp_id = (hid_t)*prp_id; + if (H5Pfill_value_defined(c_prp_id, &c_flag) < 0) + return ret_value; + *flag = (int_f)c_flag; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_alloc_time_c * NAME @@ -2254,21 +2302,22 @@ h5pfill_value_defined_c ( hid_t_f *prp_id , int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_alloc_time_c ( hid_t_f *prp_id , int_f *flag) +h5pget_alloc_time_c(hid_t_f *prp_id, int_f *flag) /******/ { - int ret_value = -1; - hid_t c_prp_id; - H5D_alloc_time_t c_flag; + int ret_value = -1; + hid_t c_prp_id; + H5D_alloc_time_t c_flag; - c_prp_id = (hid_t)*prp_id; - if ( H5Pget_alloc_time(c_prp_id, &c_flag) < 0 ) return ret_value; - *flag = (int_f)c_flag; - ret_value = 0; - return ret_value; + c_prp_id = (hid_t)*prp_id; + if (H5Pget_alloc_time(c_prp_id, &c_flag) < 0) + return ret_value; + *flag = (int_f)c_flag; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_alloc_time_c * NAME @@ -2287,21 +2336,22 @@ h5pget_alloc_time_c ( hid_t_f *prp_id , int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_alloc_time_c ( hid_t_f *prp_id , int_f *flag) +h5pset_alloc_time_c(hid_t_f *prp_id, int_f *flag) /******/ { - int ret_value = -1; - hid_t c_prp_id; - H5D_alloc_time_t c_flag; + int ret_value = -1; + hid_t c_prp_id; + H5D_alloc_time_t c_flag; - c_prp_id = (hid_t)*prp_id; - c_flag = (H5D_alloc_time_t)*flag; - if ( H5Pset_alloc_time(c_prp_id, c_flag) < 0 ) return ret_value; - ret_value = 0; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_flag = (H5D_alloc_time_t)*flag; + if (H5Pset_alloc_time(c_prp_id, c_flag) < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_fill_time_c * NAME @@ -2321,21 +2371,22 @@ h5pset_alloc_time_c ( hid_t_f *prp_id , int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_fill_time_c ( hid_t_f *prp_id , int_f *flag) +h5pget_fill_time_c(hid_t_f *prp_id, int_f *flag) /******/ { - int ret_value = -1; - hid_t c_prp_id; - H5D_fill_time_t c_flag; + int ret_value = -1; + hid_t c_prp_id; + H5D_fill_time_t c_flag; - c_prp_id = (hid_t)*prp_id; - if ( H5Pget_fill_time(c_prp_id, &c_flag) < 0 ) return ret_value; - *flag = (int_f)c_flag; - ret_value = 0; - return ret_value; + c_prp_id = (hid_t)*prp_id; + if (H5Pget_fill_time(c_prp_id, &c_flag) < 0) + return ret_value; + *flag = (int_f)c_flag; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_fill_time_c * NAME @@ -2354,21 +2405,22 @@ h5pget_fill_time_c ( hid_t_f *prp_id , int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fill_time_c ( hid_t_f *prp_id , int_f *flag) +h5pset_fill_time_c(hid_t_f *prp_id, int_f *flag) /******/ { - int ret_value = -1; - hid_t c_prp_id; - H5D_fill_time_t c_flag; + int ret_value = -1; + hid_t c_prp_id; + H5D_fill_time_t c_flag; - c_prp_id = (hid_t)*prp_id; - c_flag = (H5D_fill_time_t)*flag; - if ( H5Pset_fill_time(c_prp_id, c_flag) < 0 ) return ret_value; - ret_value = 0; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_flag = (H5D_fill_time_t)*flag; + if (H5Pset_fill_time(c_prp_id, c_flag) < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_meta_block_size_c * NAME @@ -2388,20 +2440,21 @@ h5pset_fill_time_c ( hid_t_f *prp_id , int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_meta_block_size_c ( hid_t_f *prp_id , hsize_t_f *size) +h5pset_meta_block_size_c(hid_t_f *prp_id, hsize_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - hsize_t c_size; + int ret_value = 0; + hid_t c_prp_id; + hsize_t c_size; - c_prp_id = (hid_t)*prp_id; - c_size = (hsize_t)*size; - if ( H5Pset_meta_block_size(c_prp_id, c_size) < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_size = (hsize_t)*size; + if (H5Pset_meta_block_size(c_prp_id, c_size) < 0) + ret_value = -1; + return ret_value; } /****if* H5Pf/h5pget_meta_block_size_c * NAME @@ -2421,20 +2474,21 @@ h5pset_meta_block_size_c ( hid_t_f *prp_id , hsize_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_meta_block_size_c ( hid_t_f *prp_id , hsize_t_f *size) +h5pget_meta_block_size_c(hid_t_f *prp_id, hsize_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - hsize_t c_size; + int ret_value = 0; + hid_t c_prp_id; + hsize_t c_size; - c_prp_id = (hid_t)*prp_id; - if ( H5Pget_meta_block_size(c_prp_id, &c_size) < 0 ) ret_value = -1; - *size = (hsize_t_f)c_size; - return ret_value; + c_prp_id = (hid_t)*prp_id; + if (H5Pget_meta_block_size(c_prp_id, &c_size) < 0) + ret_value = -1; + *size = (hsize_t_f)c_size; + return ret_value; } /****if* H5Pf/h5pset_sieve_buf_size_c * NAME @@ -2454,20 +2508,21 @@ h5pget_meta_block_size_c ( hid_t_f *prp_id , hsize_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_sieve_buf_size_c ( hid_t_f *prp_id , size_t_f *size) +h5pset_sieve_buf_size_c(hid_t_f *prp_id, size_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - size_t c_size; + int ret_value = 0; + hid_t c_prp_id; + size_t c_size; - c_prp_id = (hid_t)*prp_id; - c_size = (size_t)*size; - if ( H5Pset_sieve_buf_size(c_prp_id, c_size) < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_size = (size_t)*size; + if (H5Pset_sieve_buf_size(c_prp_id, c_size) < 0) + ret_value = -1; + return ret_value; } /****if* H5Pf/h5pget_sieve_buf_size_c * NAME @@ -2487,20 +2542,21 @@ h5pset_sieve_buf_size_c ( hid_t_f *prp_id , size_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_sieve_buf_size_c ( hid_t_f *prp_id , size_t_f *size) +h5pget_sieve_buf_size_c(hid_t_f *prp_id, size_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - size_t c_size; + int ret_value = 0; + hid_t c_prp_id; + size_t c_size; - c_prp_id = (hid_t)*prp_id; - if ( H5Pget_sieve_buf_size(c_prp_id, &c_size) < 0 ) ret_value = -1; - *size = (size_t_f)c_size; - return ret_value; + c_prp_id = (hid_t)*prp_id; + if (H5Pget_sieve_buf_size(c_prp_id, &c_size) < 0) + ret_value = -1; + *size = (size_t_f)c_size; + return ret_value; } /****if* H5Pf/h5pset_small_data_block_size_c * NAME @@ -2520,20 +2576,21 @@ h5pget_sieve_buf_size_c ( hid_t_f *prp_id , size_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_small_data_block_size_c ( hid_t_f *prp_id , hsize_t_f *size) +h5pset_small_data_block_size_c(hid_t_f *prp_id, hsize_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - hsize_t c_size; + int ret_value = 0; + hid_t c_prp_id; + hsize_t c_size; - c_prp_id = (hid_t)*prp_id; - c_size = (hsize_t)*size; - if ( H5Pset_small_data_block_size(c_prp_id, c_size) < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_size = (hsize_t)*size; + if (H5Pset_small_data_block_size(c_prp_id, c_size) < 0) + ret_value = -1; + return ret_value; } /****if* H5Pf/h5pget_small_data_block_size_c * NAME @@ -2553,20 +2610,21 @@ h5pset_small_data_block_size_c ( hid_t_f *prp_id , hsize_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_small_data_block_size_c ( hid_t_f *prp_id , hsize_t_f *size) +h5pget_small_data_block_size_c(hid_t_f *prp_id, hsize_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - hsize_t c_size; + int ret_value = 0; + hid_t c_prp_id; + hsize_t c_size; - c_prp_id = (hid_t)*prp_id; - if ( H5Pget_small_data_block_size(c_prp_id, &c_size) < 0 ) ret_value = -1; - *size = (hsize_t_f)c_size; - return ret_value; + c_prp_id = (hid_t)*prp_id; + if (H5Pget_small_data_block_size(c_prp_id, &c_size) < 0) + ret_value = -1; + *size = (hsize_t_f)c_size; + return ret_value; } /****if* H5Pf/h5pset_hyper_vector_size_c * NAME @@ -2586,20 +2644,21 @@ h5pget_small_data_block_size_c ( hid_t_f *prp_id , hsize_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_hyper_vector_size_c ( hid_t_f *prp_id , size_t_f *size) +h5pset_hyper_vector_size_c(hid_t_f *prp_id, size_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - size_t c_size; + int ret_value = 0; + hid_t c_prp_id; + size_t c_size; - c_prp_id = (hid_t)*prp_id; - c_size = (size_t)*size; - if ( H5Pset_hyper_vector_size(c_prp_id, c_size) < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_size = (size_t)*size; + if (H5Pset_hyper_vector_size(c_prp_id, c_size) < 0) + ret_value = -1; + return ret_value; } /****if* H5Pf/h5pget_hyper_vector_size_c * NAME @@ -2619,20 +2678,21 @@ h5pset_hyper_vector_size_c ( hid_t_f *prp_id , size_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_hyper_vector_size_c ( hid_t_f *prp_id , size_t_f *size) +h5pget_hyper_vector_size_c(hid_t_f *prp_id, size_t_f *size) /******/ { - int ret_value = 0; - hid_t c_prp_id; - size_t c_size; + int ret_value = 0; + hid_t c_prp_id; + size_t c_size; - c_prp_id = (hid_t)*prp_id; - if ( H5Pget_hyper_vector_size(c_prp_id, &c_size) < 0 ) ret_value = -1; - *size = (size_t_f)c_size; - return ret_value; + c_prp_id = (hid_t)*prp_id; + if (H5Pget_hyper_vector_size(c_prp_id, &c_size) < 0) + ret_value = -1; + *size = (size_t_f)c_size; + return ret_value; } /****if* H5Pf/h5pcreate_class_c @@ -2656,33 +2716,36 @@ h5pget_hyper_vector_size_c ( hid_t_f *prp_id , size_t_f *size) * Added the callback parameters (FORTRAN 2003 compilers only) * M. Scot Breitenfeld, July 3, 2008 * SOURCE -*/ + */ int_f -h5pcreate_class_c(hid_t_f *parent, _fcd name, int_f *name_len, hid_t_f *cls, - H5P_cls_create_func_t create, void *create_data, - H5P_cls_copy_func_t copy, void *copy_data, - H5P_cls_close_func_t close, void *close_data) +h5pcreate_class_c(hid_t_f *parent, _fcd name, int_f *name_len, hid_t_f *cls, H5P_cls_create_func_t create, + void *create_data, H5P_cls_copy_func_t copy, void *copy_data, H5P_cls_close_func_t close, + void *close_data) /******/ { - int ret_value = -1; - hid_t c_class; - char* c_name; + int ret_value = -1; + hid_t c_class; + char *c_name; - c_name = (char *)HD5f2cstring(name, (size_t)*name_len); - if (c_name == NULL) goto DONE; + c_name = (char *)HD5f2cstring(name, (size_t)*name_len); + if (c_name == NULL) + goto DONE; - /* - * Call H5Pcreate_class function. - */ - c_class = H5Pcreate_class((hid_t)*parent, c_name, create, create_data, copy, copy_data, close, close_data); + /* + * Call H5Pcreate_class function. + */ + c_class = + H5Pcreate_class((hid_t)*parent, c_name, create, create_data, copy, copy_data, close, close_data); - if (c_class < 0) goto DONE; - *cls = (hid_t_f)c_class; - ret_value = 0; + if (c_class < 0) + goto DONE; + *cls = (hid_t_f)c_class; + ret_value = 0; DONE: - if(c_name != NULL) HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pregister_c @@ -2704,28 +2767,28 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5pregister_c(hid_t_f *cls, _fcd name, int_f *name_len, size_t_f *size, void H5_ATTR_UNUSED *value) /******/ { - char* c_name = NULL; - int_f ret_value = -1; + char *c_name = NULL; + int_f ret_value = -1; - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*name_len))) - goto DONE; + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*name_len))) + goto DONE; - /* - * Call H5Pregister2 function. - */ - if(H5Pregister2((hid_t)*cls, c_name, (size_t)*size, value, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - goto DONE; - ret_value = 0; + /* + * Call H5Pregister2 function. + */ + if (H5Pregister2((hid_t)*cls, c_name, (size_t)*size, value, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + goto DONE; + ret_value = 0; DONE: - if(c_name != NULL) - HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pinsert_c @@ -2747,28 +2810,28 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5pinsert_c(hid_t_f *plist, _fcd name, int_f *name_len, size_t_f *size, void H5_ATTR_UNUSED *value) /******/ { - char* c_name = NULL; - int_f ret_value = -1; + char *c_name = NULL; + int_f ret_value = -1; - if(NULL == ( c_name = (char *)HD5f2cstring(name, (size_t)*name_len))) - goto DONE; + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*name_len))) + goto DONE; - /* - * Call H5Pinsert2 function. - */ - if(H5Pinsert2((hid_t)*plist, c_name, (size_t)*size, value, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - goto DONE; - ret_value = 0; + /* + * Call H5Pinsert2 function. + */ + if (H5Pinsert2((hid_t)*plist, c_name, (size_t)*size, value, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + goto DONE; + ret_value = 0; DONE: - if(c_name) - HDfree(c_name); - return ret_value; + if (c_name) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pexist_c @@ -2789,29 +2852,31 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5pexist_c(hid_t_f *cls, _fcd name, int_f *name_len) /******/ { - int_f ret_value = -1; - hid_t c_class; - char* c_name; - htri_t status; + int_f ret_value = -1; + hid_t c_class; + char * c_name; + htri_t status; - c_name = (char *)HD5f2cstring(name, (size_t)*name_len); - if (c_name == NULL) goto DONE; + c_name = (char *)HD5f2cstring(name, (size_t)*name_len); + if (c_name == NULL) + goto DONE; - c_class = (hid_t)*cls; - /* - * Call H5Pexist function. - */ - status = H5Pexist(c_class, c_name); - ret_value = status; + c_class = (hid_t)*cls; + /* + * Call H5Pexist function. + */ + status = H5Pexist(c_class, c_name); + ret_value = status; DONE: - if(c_name != NULL) HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pisa_class_c * NAME @@ -2830,25 +2895,25 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5pisa_class_c(hid_t_f *plist, hid_t_f *cls) /******/ { - int_f ret_value = -1; - hid_t c_class; - hid_t c_plist; - htri_t status; + int_f ret_value = -1; + hid_t c_class; + hid_t c_plist; + htri_t status; - c_class = (hid_t)*cls; - c_plist = (hid_t)*plist; + c_class = (hid_t)*cls; + c_plist = (hid_t)*plist; - /* - * Call H5Pisa_class function. - */ - status = H5Pisa_class(c_plist, c_class); - ret_value = status; - return ret_value; + /* + * Call H5Pisa_class function. + */ + status = H5Pisa_class(c_plist, c_class); + ret_value = status; + return ret_value; } /****if* H5Pf/h5pget_size_c * NAME @@ -2869,30 +2934,33 @@ h5pisa_class_c(hid_t_f *plist, hid_t_f *cls) * HISTORY * * SOURCE -*/ + */ int_f h5pget_size_c(hid_t_f *plist, _fcd name, int_f *name_len, size_t_f *size) /******/ { - int_f ret_value = -1; - hid_t c_plist; - char* c_name; - size_t c_size; + int_f ret_value = -1; + hid_t c_plist; + char * c_name; + size_t c_size; - c_name = (char *)HD5f2cstring(name, (size_t)*name_len); - if (c_name == NULL) goto DONE; + c_name = (char *)HD5f2cstring(name, (size_t)*name_len); + if (c_name == NULL) + goto DONE; - c_plist = (hid_t)*plist; - /* - * Call H5Pget_size function. - */ - if( H5Pget_size(c_plist, c_name, &c_size) < 0) goto DONE; - *size = (size_t_f)c_size; - ret_value = 0; + c_plist = (hid_t)*plist; + /* + * Call H5Pget_size function. + */ + if (H5Pget_size(c_plist, c_name, &c_size) < 0) + goto DONE; + *size = (size_t_f)c_size; + ret_value = 0; DONE: - if(c_name != NULL) HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pget_nprops_c * NAME @@ -2911,25 +2979,26 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5pget_nprops_c(hid_t_f *plist, size_t_f *nprops) /******/ { - int_f ret_value = -1; - hid_t c_plist; - size_t c_nprops; + int_f ret_value = -1; + hid_t c_plist; + size_t c_nprops; - c_plist = (hid_t)*plist; + c_plist = (hid_t)*plist; - /* - * Call H5Pget_nprops function. - */ - if( H5Pget_nprops(c_plist, &c_nprops) < 0) return ret_value; + /* + * Call H5Pget_nprops function. + */ + if (H5Pget_nprops(c_plist, &c_nprops) < 0) + return ret_value; - *nprops = (size_t_f)c_nprops; - ret_value = 0; - return ret_value; + *nprops = (size_t_f)c_nprops; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_class_parent_c * NAME @@ -2949,26 +3018,27 @@ h5pget_nprops_c(hid_t_f *plist, size_t_f *nprops) * HISTORY * * SOURCE -*/ + */ int_f h5pget_class_parent_c(hid_t_f *prp_id, hid_t_f *parent_id) /******/ { - int_f ret_value = -1; - hid_t c_prp_id; - hid_t c_parent_id; + int_f ret_value = -1; + hid_t c_prp_id; + hid_t c_parent_id; - c_prp_id = (hid_t)*prp_id; + c_prp_id = (hid_t)*prp_id; - /* - * Call H5Pget_class_parent function. - */ - c_parent_id = H5Pget_class_parent(c_prp_id); - if( c_parent_id < 0) return ret_value; + /* + * Call H5Pget_class_parent function. + */ + c_parent_id = H5Pget_class_parent(c_prp_id); + if (c_parent_id < 0) + return ret_value; - *parent_id =(hid_t_f)c_parent_id; - ret_value = 0; - return ret_value; + *parent_id = (hid_t_f)c_parent_id; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pcopy_prop_c * NAME @@ -2989,29 +3059,32 @@ h5pget_class_parent_c(hid_t_f *prp_id, hid_t_f *parent_id) * HISTORY * * SOURCE -*/ + */ int_f h5pcopy_prop_c(hid_t_f *dst_id, hid_t_f *src_id, _fcd name, int_f *name_len) /******/ { - int_f ret_value = -1; - hid_t c_dst_id, c_src_id; - char* c_name; + int_f ret_value = -1; + hid_t c_dst_id, c_src_id; + char *c_name; - c_name = (char *)HD5f2cstring(name, (size_t)*name_len); - if (c_name == NULL) goto DONE; + c_name = (char *)HD5f2cstring(name, (size_t)*name_len); + if (c_name == NULL) + goto DONE; - c_dst_id = (hid_t)*dst_id; - c_src_id = (hid_t)*src_id; - /* - * Call H5Pcopy_prop function. - */ - if( H5Pcopy_prop(c_dst_id, c_src_id, c_name) < 0) goto DONE; - ret_value = 0; + c_dst_id = (hid_t)*dst_id; + c_src_id = (hid_t)*src_id; + /* + * Call H5Pcopy_prop function. + */ + if (H5Pcopy_prop(c_dst_id, c_src_id, c_name) < 0) + goto DONE; + ret_value = 0; DONE: - if(c_name != NULL) HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5premove_c * NAME @@ -3030,28 +3103,31 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5premove_c(hid_t_f *plid, _fcd name, int_f *name_len) /******/ { - int_f ret_value = -1; - hid_t c_plid; - char* c_name; + int_f ret_value = -1; + hid_t c_plid; + char *c_name; - c_name = (char *)HD5f2cstring(name, (size_t)*name_len); - if (c_name == NULL) goto DONE; + c_name = (char *)HD5f2cstring(name, (size_t)*name_len); + if (c_name == NULL) + goto DONE; - c_plid = (hid_t)*plid; - /* - * Call H5Premove function. - */ - if( H5Premove(c_plid, c_name) < 0) goto DONE; - ret_value = 0; + c_plid = (hid_t)*plid; + /* + * Call H5Premove function. + */ + if (H5Premove(c_plid, c_name) < 0) + goto DONE; + ret_value = 0; DONE: - if(c_name != NULL) HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5punregister_c * NAME @@ -3070,28 +3146,31 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5punregister_c(hid_t_f *cls, _fcd name, int_f *name_len) /******/ { - int_f ret_value = -1; - hid_t c_class; - char* c_name; + int_f ret_value = -1; + hid_t c_class; + char *c_name; - c_name = (char *)HD5f2cstring(name, (size_t)*name_len); - if (c_name == NULL) goto DONE; + c_name = (char *)HD5f2cstring(name, (size_t)*name_len); + if (c_name == NULL) + goto DONE; - c_class = (hid_t)*cls; - /* - * Call H5Punregister function. - */ - if( H5Punregister(c_class, c_name) < 0) goto DONE; - ret_value = 0; + c_class = (hid_t)*cls; + /* + * Call H5Punregister function. + */ + if (H5Punregister(c_class, c_name) < 0) + goto DONE; + ret_value = 0; DONE: - if(c_name != NULL) HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pclose_class_c * NAME @@ -3108,21 +3187,22 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5pclose_class_c(hid_t_f *cls) /******/ { - int_f ret_value = -1; - hid_t c_class; + int_f ret_value = -1; + hid_t c_class; - c_class = (hid_t)*cls; - /* - * Call H5Pclose_class function. - */ - if( H5Pclose_class(c_class) < 0) return ret_value; - ret_value = 0; - return ret_value; + c_class = (hid_t)*cls; + /* + * Call H5Pclose_class function. + */ + if (H5Pclose_class(c_class) < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_class_name_c @@ -3142,29 +3222,29 @@ h5pclose_class_c(hid_t_f *cls) * HISTORY * * SOURCE -*/ + */ int_f h5pget_class_name_c(hid_t_f *cls, _fcd name, int_f *name_len) /******/ { - int_f ret_value = -1; + int_f ret_value = -1; - /* Buffer to return name by C function */ - char *c_name; + /* Buffer to return name by C function */ + char *c_name; - /* - * Call H5Pget_class_name function. c_name is allocated by the library, - * has to be freed by application. - */ - if(NULL == (c_name = H5Pget_class_name((hid_t)*cls))) - goto DONE; + /* + * Call H5Pget_class_name function. c_name is allocated by the library, + * has to be freed by application. + */ + if (NULL == (c_name = H5Pget_class_name((hid_t)*cls))) + goto DONE; - HD5packFstring(c_name, _fcdtocp(name), (size_t)*name_len); - ret_value = (int_f)HDstrlen(c_name); - H5free_memory(c_name); + HD5packFstring(c_name, _fcdtocp(name), (size_t)*name_len); + ret_value = (int_f)HDstrlen(c_name); + H5free_memory(c_name); DONE: - return ret_value; + return ret_value; } /****if* H5Pf/h5pset_c @@ -3185,26 +3265,29 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5pset_c(hid_t_f *plist, _fcd name, int_f *name_len, void *value) /******/ { - int_f ret_value = -1; - char* c_name; + int_f ret_value = -1; + char *c_name; - c_name = (char *)HD5f2cstring(name, (size_t)*name_len); - if (c_name == NULL) goto DONE; + c_name = (char *)HD5f2cstring(name, (size_t)*name_len); + if (c_name == NULL) + goto DONE; - /* - * Call H5Pset function. - */ - if( H5Pset((hid_t)*plist, c_name, value) <0) goto DONE; - ret_value = 0; + /* + * Call H5Pset function. + */ + if (H5Pset((hid_t)*plist, c_name, value) < 0) + goto DONE; + ret_value = 0; DONE: - if(c_name != NULL) HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pget_c @@ -3226,26 +3309,29 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f h5pget_c(hid_t_f *plist, _fcd name, int_f *name_len, void *value) /******/ { - int_f ret_value = -1; - char* c_name; + int_f ret_value = -1; + char *c_name; - c_name = (char *)HD5f2cstring(name, (size_t)*name_len); - if (c_name == NULL) goto DONE; + c_name = (char *)HD5f2cstring(name, (size_t)*name_len); + if (c_name == NULL) + goto DONE; - /* - * Call H5Pset function. - */ - if( H5Pget((hid_t)*plist, c_name, value) <0) goto DONE; - ret_value = 0; + /* + * Call H5Pset function. + */ + if (H5Pget((hid_t)*plist, c_name, value) < 0) + goto DONE; + ret_value = 0; DONE: - if(c_name != NULL) HDfree(c_name); - return ret_value; + if (c_name != NULL) + HDfree(c_name); + return ret_value; } /****if* H5Pf/h5pset_shuffle_c @@ -3264,20 +3350,21 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5pset_shuffle_c ( hid_t_f *prp_id ) +h5pset_shuffle_c(hid_t_f *prp_id) /******/ { - int_f ret_value = 0; - hid_t c_prp_id; - herr_t status; + int_f ret_value = 0; + hid_t c_prp_id; + herr_t status; - c_prp_id = (hid_t)*prp_id; - status = H5Pset_shuffle(c_prp_id); - if ( status < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + status = H5Pset_shuffle(c_prp_id); + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Pf/h5pset_fletcher32_c * NAME @@ -3294,20 +3381,21 @@ h5pset_shuffle_c ( hid_t_f *prp_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fletcher32_c ( hid_t_f *prp_id ) +h5pset_fletcher32_c(hid_t_f *prp_id) /******/ { - int_f ret_value = 0; - hid_t c_prp_id; - herr_t status; + int_f ret_value = 0; + hid_t c_prp_id; + herr_t status; - c_prp_id = (hid_t)*prp_id; - status = H5Pset_fletcher32(c_prp_id); - if ( status < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + status = H5Pset_fletcher32(c_prp_id); + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Pf/h5pset_edc_check_c @@ -3326,22 +3414,23 @@ h5pset_fletcher32_c ( hid_t_f *prp_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_edc_check_c ( hid_t_f *prp_id, int_f *flag ) +h5pset_edc_check_c(hid_t_f *prp_id, int_f *flag) /******/ { - int_f ret_value = 0; - hid_t c_prp_id; - H5Z_EDC_t c_flag; - herr_t status; + int_f ret_value = 0; + hid_t c_prp_id; + H5Z_EDC_t c_flag; + herr_t status; - c_prp_id = (hid_t)*prp_id; - c_flag = (H5Z_EDC_t)*flag; - status = H5Pset_edc_check(c_prp_id, c_flag); - if ( status < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_flag = (H5Z_EDC_t)*flag; + status = H5Pset_edc_check(c_prp_id, c_flag); + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Pf/h5pget_edc_check_c @@ -3360,21 +3449,22 @@ h5pset_edc_check_c ( hid_t_f *prp_id, int_f *flag ) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_edc_check_c ( hid_t_f *prp_id, int_f *flag ) +h5pget_edc_check_c(hid_t_f *prp_id, int_f *flag) /******/ { - int_f ret_value = 0; - hid_t c_prp_id; - H5Z_EDC_t c_flag; + int_f ret_value = 0; + hid_t c_prp_id; + H5Z_EDC_t c_flag; - c_prp_id = (hid_t)*prp_id; - c_flag = H5Pget_edc_check(c_prp_id); - if ( c_flag < 0 ) ret_value = -1; - *flag = (int_f)c_flag; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_flag = H5Pget_edc_check(c_prp_id); + if (c_flag < 0) + ret_value = -1; + *flag = (int_f)c_flag; + return ret_value; } /****if* H5Pf/h5pset_family_offset_c * NAME @@ -3392,22 +3482,23 @@ h5pget_edc_check_c ( hid_t_f *prp_id, int_f *flag ) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_family_offset_c ( hid_t_f *prp_id , hsize_t_f *offset) +h5pset_family_offset_c(hid_t_f *prp_id, hsize_t_f *offset) /******/ { - int_f ret_value = 0; - hid_t c_prp_id; - hsize_t c_offset; - herr_t status; + int_f ret_value = 0; + hid_t c_prp_id; + hsize_t c_offset; + herr_t status; - c_prp_id = (hid_t)*prp_id; - c_offset = (hsize_t)*offset; - status = H5Pset_family_offset(c_prp_id, c_offset); - if ( status < 0 ) ret_value = -1; - return ret_value; + c_prp_id = (hid_t)*prp_id; + c_offset = (hsize_t)*offset; + status = H5Pset_family_offset(c_prp_id, c_offset); + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Pf/h5pset_fapl_multi_c @@ -3431,71 +3522,79 @@ h5pset_family_offset_c ( hid_t_f *prp_id , hsize_t_f *offset) * HISTORY * * SOURCE -*/ - -int_f -/*h5pset_fapl_multi_c ( hid_t_f *prp_id , int_f *memb_map, hid_t_f *memb_fapl, _fcd memb_name, int_f *len, int_f *lenmax, haddr_t_f *memb_addr, int_f *flag) */ -h5pset_fapl_multi_c ( hid_t_f *prp_id , int_f *memb_map, hid_t_f *memb_fapl, _fcd memb_name, int_f *len, int_f *lenmax, real_f *memb_addr, int_f *flag) -/******/ -{ - int_f ret_value = -1; - hid_t c_prp_id; - H5FD_mem_t c_memb_map[H5FD_MEM_NTYPES]; - hid_t c_memb_fapl[H5FD_MEM_NTYPES]; - char *c_memb_name[H5FD_MEM_NTYPES]; - haddr_t c_memb_addr[H5FD_MEM_NTYPES]; - hbool_t relax; - herr_t status; - char *tmp, *tmp_p, *tmp_pp; - int i; - int c_lenmax; - long double tmp_max_addr; - c_lenmax = (int)*lenmax; - relax = (hbool_t)*flag; -/* - * Check that we got correct values from Fortran for memb_addr array - */ - for (i=0; i < H5FD_MEM_NTYPES; i++) { - if(memb_addr[i] >= 1.0f) return ret_value; - } -/* - * Take care of names array - */ - - tmp = (char *)HD5f2cstring(memb_name, (size_t)c_lenmax*(H5FD_MEM_NTYPES)); - if (tmp ==NULL) return ret_value; - tmp_p = tmp; - for (i=0; i < H5FD_MEM_NTYPES; i++) { - c_memb_name[i] = (char *)HDmalloc((size_t)len[i] + 1); - HDmemcpy(c_memb_name[i], tmp_p, (size_t)len[i]); - tmp_pp = c_memb_name[i]; - tmp_pp[len[i]] = '\0'; - tmp_p = tmp_p + c_lenmax; - } -/* - * Take care of othe arguments - */ - tmp_max_addr = (long double)(HADDR_MAX); - c_prp_id = (hid_t)*prp_id; - for (i=0; i < H5FD_MEM_NTYPES; i++) { - c_memb_map[i] = (H5FD_mem_t)memb_map[i]; - c_memb_fapl[i] = (hid_t)memb_fapl[i]; - if(memb_addr[i] < 0) c_memb_addr[i] = HADDR_UNDEF; - else c_memb_addr[i] = (haddr_t)(((float)memb_addr[i])*(tmp_max_addr)); - } -/* - * Call H5Pset_fapl_multi function - */ - - status = H5Pset_fapl_multi(c_prp_id, c_memb_map, c_memb_fapl, (const char * const *)c_memb_name, c_memb_addr, relax); - if ( status < 0 ) goto DONE; - ret_value = 0; + */ + +int_f +/*h5pset_fapl_multi_c ( hid_t_f *prp_id , int_f *memb_map, hid_t_f *memb_fapl, _fcd memb_name, int_f *len, + int_f *lenmax, haddr_t_f *memb_addr, int_f *flag) */ +h5pset_fapl_multi_c(hid_t_f *prp_id, int_f *memb_map, hid_t_f *memb_fapl, _fcd memb_name, int_f *len, + int_f *lenmax, real_f *memb_addr, int_f *flag) +/******/ +{ + int_f ret_value = -1; + hid_t c_prp_id; + H5FD_mem_t c_memb_map[H5FD_MEM_NTYPES]; + hid_t c_memb_fapl[H5FD_MEM_NTYPES]; + char * c_memb_name[H5FD_MEM_NTYPES]; + haddr_t c_memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + herr_t status; + char * tmp, *tmp_p, *tmp_pp; + int i; + int c_lenmax; + long double tmp_max_addr; + c_lenmax = (int)*lenmax; + relax = (hbool_t)*flag; + /* + * Check that we got correct values from Fortran for memb_addr array + */ + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + if (memb_addr[i] >= 1.0f) + return ret_value; + } + /* + * Take care of names array + */ + + tmp = (char *)HD5f2cstring(memb_name, (size_t)c_lenmax * (H5FD_MEM_NTYPES)); + if (tmp == NULL) + return ret_value; + tmp_p = tmp; + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + c_memb_name[i] = (char *)HDmalloc((size_t)len[i] + 1); + HDmemcpy(c_memb_name[i], tmp_p, (size_t)len[i]); + tmp_pp = c_memb_name[i]; + tmp_pp[len[i]] = '\0'; + tmp_p = tmp_p + c_lenmax; + } + /* + * Take care of othe arguments + */ + tmp_max_addr = (long double)(HADDR_MAX); + c_prp_id = (hid_t)*prp_id; + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + c_memb_map[i] = (H5FD_mem_t)memb_map[i]; + c_memb_fapl[i] = (hid_t)memb_fapl[i]; + if (memb_addr[i] < 0) + c_memb_addr[i] = HADDR_UNDEF; + else + c_memb_addr[i] = (haddr_t)(((float)memb_addr[i]) * (tmp_max_addr)); + } + /* + * Call H5Pset_fapl_multi function + */ + + status = H5Pset_fapl_multi(c_prp_id, c_memb_map, c_memb_fapl, (const char *const *)c_memb_name, + c_memb_addr, relax); + if (status < 0) + goto DONE; + ret_value = 0; DONE: - HDfree(tmp); - for (i=0; i < H5FD_MEM_NTYPES; i++) - HDfree(c_memb_name[i]); - return ret_value; + HDfree(tmp); + for (i = 0; i < H5FD_MEM_NTYPES; i++) + HDfree(c_memb_name[i]); + return ret_value; } /****if* H5Pf/h5pset_fapl_multi_sc @@ -3513,27 +3612,28 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fapl_multi_sc ( hid_t_f *prp_id , int_f *flag) +h5pset_fapl_multi_sc(hid_t_f *prp_id, int_f *flag) /******/ { - int_f ret_value = -1; - hid_t c_prp_id; - hbool_t relax; - herr_t status; + int_f ret_value = -1; + hid_t c_prp_id; + hbool_t relax; + herr_t status; - relax = (hbool_t)*flag; - c_prp_id = (hid_t)*prp_id; -/* - * Call H5Pset_fapl_multi function - */ + relax = (hbool_t)*flag; + c_prp_id = (hid_t)*prp_id; + /* + * Call H5Pset_fapl_multi function + */ - status = H5Pset_fapl_multi(c_prp_id, NULL, NULL, NULL, NULL, relax); - if ( status < 0 ) return ret_value; /* error occurred */ - ret_value = 0; - return ret_value; + status = H5Pset_fapl_multi(c_prp_id, NULL, NULL, NULL, NULL, relax); + if (status < 0) + return ret_value; /* error occurred */ + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_fapl_multi_c * NAME @@ -3557,66 +3657,70 @@ h5pset_fapl_multi_sc ( hid_t_f *prp_id , int_f *flag) * HISTORY * * SOURCE -*/ - -int_f -h5pget_fapl_multi_c ( hid_t_f *prp_id , int_f *memb_map, hid_t_f *memb_fapl, _fcd memb_name, int_f *len, int_f *lenmax, real_f *memb_addr, int_f *flag, int_f *maxlen_out) -/******/ -{ - int_f ret_value = -1; - hid_t c_prp_id; - H5FD_mem_t c_memb_map[H5FD_MEM_NTYPES]; - hid_t c_memb_fapl[H5FD_MEM_NTYPES]; - char *c_memb_name[H5FD_MEM_NTYPES]; - haddr_t c_memb_addr[H5FD_MEM_NTYPES]; - hbool_t relax; - herr_t status; - char *tmp, *tmp_p; - int i; - size_t c_lenmax; - size_t length = 0; - c_lenmax = (size_t)*lenmax; - - c_prp_id = (hid_t)*prp_id; -/* - * Call H5Pget_fapl_multi function - */ - - status = H5Pget_fapl_multi(c_prp_id, c_memb_map, c_memb_fapl, c_memb_name, c_memb_addr, &relax); - if ( status < 0 ) return ret_value; - -/* - * Take care of names array - */ - tmp = (char *)HDmalloc(c_lenmax*H5FD_MEM_NTYPES + 1); - tmp_p = tmp; - HDmemset(tmp,' ', c_lenmax*H5FD_MEM_NTYPES); - tmp[c_lenmax*H5FD_MEM_NTYPES] = '\0'; - for (i=0; i < H5FD_MEM_NTYPES; i++) { - memcpy(tmp_p, c_memb_name[i], strlen(c_memb_name[i])); - len[i] = (int_f)strlen(c_memb_name[i]); - length = H5_MAX(length, strlen(c_memb_name[i])); - tmp_p = tmp_p + c_lenmax; - } -HD5packFstring(tmp, _fcdtocp(memb_name), (size_t)(c_lenmax*H5FD_MEM_NTYPES)); - -/* - * Take care of other arguments - */ - - for (i=0; i < H5FD_MEM_NTYPES; i++) { - memb_map[i] = (int_f)c_memb_map[i]; - memb_fapl[i] = (hid_t_f)c_memb_fapl[i]; - if(c_memb_addr[i] == HADDR_UNDEF) memb_addr[i] = -1; - else memb_addr[i] = (real_f) (c_memb_addr[i]/HADDR_MAX); - } - *flag = (int_f)relax; - *maxlen_out = (int_f)length; - ret_value = 0; - HDfree(tmp); - for (i=0; i < H5FD_MEM_NTYPES; i++) - HDfree(c_memb_name[i]); - return ret_value; + */ + +int_f +h5pget_fapl_multi_c(hid_t_f *prp_id, int_f *memb_map, hid_t_f *memb_fapl, _fcd memb_name, int_f *len, + int_f *lenmax, real_f *memb_addr, int_f *flag, int_f *maxlen_out) +/******/ +{ + int_f ret_value = -1; + hid_t c_prp_id; + H5FD_mem_t c_memb_map[H5FD_MEM_NTYPES]; + hid_t c_memb_fapl[H5FD_MEM_NTYPES]; + char * c_memb_name[H5FD_MEM_NTYPES]; + haddr_t c_memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + herr_t status; + char * tmp, *tmp_p; + int i; + size_t c_lenmax; + size_t length = 0; + c_lenmax = (size_t)*lenmax; + + c_prp_id = (hid_t)*prp_id; + /* + * Call H5Pget_fapl_multi function + */ + + status = H5Pget_fapl_multi(c_prp_id, c_memb_map, c_memb_fapl, c_memb_name, c_memb_addr, &relax); + if (status < 0) + return ret_value; + + /* + * Take care of names array + */ + tmp = (char *)HDmalloc(c_lenmax * H5FD_MEM_NTYPES + 1); + tmp_p = tmp; + HDmemset(tmp, ' ', c_lenmax * H5FD_MEM_NTYPES); + tmp[c_lenmax * H5FD_MEM_NTYPES] = '\0'; + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + memcpy(tmp_p, c_memb_name[i], strlen(c_memb_name[i])); + len[i] = (int_f)strlen(c_memb_name[i]); + length = H5_MAX(length, strlen(c_memb_name[i])); + tmp_p = tmp_p + c_lenmax; + } + HD5packFstring(tmp, _fcdtocp(memb_name), (size_t)(c_lenmax * H5FD_MEM_NTYPES)); + + /* + * Take care of other arguments + */ + + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + memb_map[i] = (int_f)c_memb_map[i]; + memb_fapl[i] = (hid_t_f)c_memb_fapl[i]; + if (c_memb_addr[i] == HADDR_UNDEF) + memb_addr[i] = -1; + else + memb_addr[i] = (real_f)(c_memb_addr[i] / HADDR_MAX); + } + *flag = (int_f)relax; + *maxlen_out = (int_f)length; + ret_value = 0; + HDfree(tmp); + for (i = 0; i < H5FD_MEM_NTYPES; i++) + HDfree(c_memb_name[i]); + return ret_value; } /****if* H5Pf/h5pset_szip_c @@ -3636,29 +3740,30 @@ HD5packFstring(tmp, _fcdtocp(memb_name), (size_t)(c_lenmax*H5FD_MEM_NTYPES)); * HISTORY * * SOURCE -*/ + */ int_f -h5pset_szip_c ( hid_t_f *prp_id , int_f *options_mask, int_f *pixels_per_block) +h5pset_szip_c(hid_t_f *prp_id, int_f *options_mask, int_f *pixels_per_block) /******/ { - int_f ret_value = -1; - hid_t c_prp_id; - unsigned c_options_mask; - unsigned c_pixels_per_block; - herr_t status; + int_f ret_value = -1; + hid_t c_prp_id; + unsigned c_options_mask; + unsigned c_pixels_per_block; + herr_t status; - c_prp_id = (hid_t)*prp_id; - c_options_mask = (unsigned)*options_mask; - c_pixels_per_block = (unsigned)*pixels_per_block; -/* - * Call H5Pset_szip function - */ + c_prp_id = (hid_t)*prp_id; + c_options_mask = (unsigned)*options_mask; + c_pixels_per_block = (unsigned)*pixels_per_block; + /* + * Call H5Pset_szip function + */ - status = H5Pset_szip(c_prp_id, c_options_mask, c_pixels_per_block); - if ( status < 0 ) return ret_value; - ret_value = 0; - return ret_value; + status = H5Pset_szip(c_prp_id, c_options_mask, c_pixels_per_block); + if (status < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pall_filters_avail_c * NAME @@ -3677,28 +3782,29 @@ h5pset_szip_c ( hid_t_f *prp_id , int_f *options_mask, int_f *pixels_per_block) * HISTORY * * SOURCE -*/ + */ int_f -h5pall_filters_avail_c ( hid_t_f *prp_id , int_f *status) +h5pall_filters_avail_c(hid_t_f *prp_id, int_f *status) /******/ { - int_f ret_value = -1; - hid_t c_prp_id; - htri_t c_status; + int_f ret_value = -1; + hid_t c_prp_id; + htri_t c_status; + c_prp_id = (hid_t)*prp_id; + /* + * Call H5Pall_filters_avail function + */ - c_prp_id = (hid_t)*prp_id; -/* - * Call H5Pall_filters_avail function - */ - - c_status = H5Pall_filters_avail(c_prp_id); - if ( c_status < 0 ) return ret_value; - *status = 0; - if (c_status == 1) *status = 1; - ret_value = 0; - return ret_value; + c_status = H5Pall_filters_avail(c_prp_id); + if (c_status < 0) + return ret_value; + *status = 0; + if (c_status == 1) + *status = 1; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_filter_by_id_c @@ -3725,44 +3831,46 @@ h5pall_filters_avail_c ( hid_t_f *prp_id , int_f *status) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_filter_by_id_c(hid_t_f *prp_id, int_f* filter_id, int_f* flags, size_t_f* cd_nelmts, int_f* cd_values, size_t_f *namelen, _fcd name) +h5pget_filter_by_id_c(hid_t_f *prp_id, int_f *filter_id, int_f *flags, size_t_f *cd_nelmts, int_f *cd_values, + size_t_f *namelen, _fcd name) /******/ { - unsigned int c_flags; - size_t c_cd_nelmts = (size_t)*cd_nelmts; - size_t c_cd_nelmts_in = (size_t)*cd_nelmts; - unsigned int *c_cd_values = NULL; - char *c_name = NULL; - unsigned i; - int_f ret_value = -1; - - if(NULL == (c_name = (char *)HDmalloc((size_t)*namelen + 1))) - goto DONE; + unsigned int c_flags; + size_t c_cd_nelmts = (size_t)*cd_nelmts; + size_t c_cd_nelmts_in = (size_t)*cd_nelmts; + unsigned int *c_cd_values = NULL; + char * c_name = NULL; + unsigned i; + int_f ret_value = -1; + + if (NULL == (c_name = (char *)HDmalloc((size_t)*namelen + 1))) + goto DONE; - if(NULL == (c_cd_values = (unsigned int *)HDmalloc(sizeof(unsigned int) * c_cd_nelmts_in))) - goto DONE; + if (NULL == (c_cd_values = (unsigned int *)HDmalloc(sizeof(unsigned int) * c_cd_nelmts_in))) + goto DONE; - /* - * Call H5Pget_filter_by_id2 function. - */ - if(H5Pget_filter_by_id2((hid_t)*prp_id, (H5Z_filter_t)*filter_id, &c_flags, &c_cd_nelmts, c_cd_values, (size_t)*namelen, c_name, NULL) < 0) - goto DONE; + /* + * Call H5Pget_filter_by_id2 function. + */ + if (H5Pget_filter_by_id2((hid_t)*prp_id, (H5Z_filter_t)*filter_id, &c_flags, &c_cd_nelmts, c_cd_values, + (size_t)*namelen, c_name, NULL) < 0) + goto DONE; - *cd_nelmts = (size_t_f)c_cd_nelmts; - *flags = (int_f)c_flags; - HD5packFstring(c_name, _fcdtocp(name), HDstrlen(c_name)); + *cd_nelmts = (size_t_f)c_cd_nelmts; + *flags = (int_f)c_flags; + HD5packFstring(c_name, _fcdtocp(name), HDstrlen(c_name)); - for(i = 0; i < c_cd_nelmts_in; i++) - cd_values[i] = (int_f)c_cd_values[i]; + for (i = 0; i < c_cd_nelmts_in; i++) + cd_values[i] = (int_f)c_cd_values[i]; - ret_value = 0; + ret_value = 0; DONE: - if(c_name) + if (c_name) HDfree(c_name); - if(c_cd_values) + if (c_cd_values) HDfree(c_cd_values); return ret_value; @@ -3788,36 +3896,38 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5pmodify_filter_c (hid_t_f *prp_id, int_f* filter, int_f* flags, size_t_f* cd_nelmts, int_f* cd_values ) +h5pmodify_filter_c(hid_t_f *prp_id, int_f *filter, int_f *flags, size_t_f *cd_nelmts, int_f *cd_values) /******/ { - int_f ret_value = -1; - hid_t c_prp_id = (hid_t)*prp_id; - herr_t ret; - size_t c_cd_nelmts = (size_t)*cd_nelmts; - unsigned int c_flags = (unsigned)*flags; - H5Z_filter_t c_filter = (H5Z_filter_t)*filter; - unsigned int * c_cd_values; - unsigned i; + int_f ret_value = -1; + hid_t c_prp_id = (hid_t)*prp_id; + herr_t ret; + size_t c_cd_nelmts = (size_t)*cd_nelmts; + unsigned int c_flags = (unsigned)*flags; + H5Z_filter_t c_filter = (H5Z_filter_t)*filter; + unsigned int *c_cd_values; + unsigned i; - c_cd_values = (unsigned int *)HDmalloc(sizeof(unsigned int) * c_cd_nelmts); - if (!c_cd_values) return ret_value; - for (i = 0; i < c_cd_nelmts; i++) - c_cd_values[i] = (unsigned int)cd_values[i]; + c_cd_values = (unsigned int *)HDmalloc(sizeof(unsigned int) * c_cd_nelmts); + if (!c_cd_values) + return ret_value; + for (i = 0; i < c_cd_nelmts; i++) + c_cd_values[i] = (unsigned int)cd_values[i]; - /* - * Call H5Pmodify_filter function. - */ - ret = H5Pmodify_filter(c_prp_id, c_filter, c_flags, c_cd_nelmts,c_cd_values ); + /* + * Call H5Pmodify_filter function. + */ + ret = H5Pmodify_filter(c_prp_id, c_filter, c_flags, c_cd_nelmts, c_cd_values); - if (ret < 0) goto DONE; - ret_value = 0; + if (ret < 0) + goto DONE; + ret_value = 0; DONE: - HDfree(c_cd_values); - return ret_value; + HDfree(c_cd_values); + return ret_value; } /****if* H5Pf/h5premove_filter_c @@ -3836,26 +3946,27 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5premove_filter_c (hid_t_f *prp_id, int_f* filter) +h5premove_filter_c(hid_t_f *prp_id, int_f *filter) /******/ { - int_f ret_value = -1; - hid_t c_prp_id; - H5Z_filter_t c_filter; + int_f ret_value = -1; + hid_t c_prp_id; + H5Z_filter_t c_filter; - c_filter = (H5Z_filter_t)*filter; - c_prp_id = (hid_t)*prp_id; + c_filter = (H5Z_filter_t)*filter; + c_prp_id = (hid_t)*prp_id; - /* - * Call H5Premove_filter function. - */ - if(H5Premove_filter(c_prp_id, c_filter) < 0) goto DONE; - ret_value = 0; + /* + * Call H5Premove_filter function. + */ + if (H5Premove_filter(c_prp_id, c_filter) < 0) + goto DONE; + ret_value = 0; DONE: - return ret_value; + return ret_value; } /****if* H5Pf/h5pget_attr_phase_change_c @@ -3876,27 +3987,28 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5pget_attr_phase_change_c(hid_t_f *ocpl_id, int_f *max_compact, int_f *min_dense ) +h5pget_attr_phase_change_c(hid_t_f *ocpl_id, int_f *max_compact, int_f *min_dense) /******/ { - int ret_value = -1; - hid_t c_ocpl_id; - unsigned c_max_compact; - unsigned c_min_dense; - herr_t ret; - /* - * Call H5Pget_attr_phase_change function. - */ - c_ocpl_id = (hid_t)*ocpl_id; - ret = H5Pget_attr_phase_change(c_ocpl_id, &c_max_compact,&c_min_dense); - if (ret < 0) return ret_value; - - *max_compact = (int_f)c_max_compact; - *min_dense = (int_f)c_min_dense; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_ocpl_id; + unsigned c_max_compact; + unsigned c_min_dense; + herr_t ret; + /* + * Call H5Pget_attr_phase_change function. + */ + c_ocpl_id = (hid_t)*ocpl_id; + ret = H5Pget_attr_phase_change(c_ocpl_id, &c_max_compact, &c_min_dense); + if (ret < 0) + return ret_value; + + *max_compact = (int_f)c_max_compact; + *min_dense = (int_f)c_min_dense; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_attr_creation_order_c @@ -3916,24 +4028,25 @@ h5pget_attr_phase_change_c(hid_t_f *ocpl_id, int_f *max_compact, int_f *min_dens * HISTORY * * SOURCE -*/ + */ int_f -h5pset_attr_creation_order_c(hid_t_f *ocpl_id, int_f *crt_order_flags ) +h5pset_attr_creation_order_c(hid_t_f *ocpl_id, int_f *crt_order_flags) /******/ { - int ret_value = -1; - unsigned c_crt_order_flags; - herr_t ret; - /* - * Call h5pset_attr_creation_order function. - */ - c_crt_order_flags = (unsigned)*crt_order_flags; - ret = H5Pset_attr_creation_order((hid_t)*ocpl_id, c_crt_order_flags); - if (ret < 0) return ret_value; + int ret_value = -1; + unsigned c_crt_order_flags; + herr_t ret; + /* + * Call h5pset_attr_creation_order function. + */ + c_crt_order_flags = (unsigned)*crt_order_flags; + ret = H5Pset_attr_creation_order((hid_t)*ocpl_id, c_crt_order_flags); + if (ret < 0) + return ret_value; - *crt_order_flags = (int_f)c_crt_order_flags; - ret_value = 0; - return ret_value; + *crt_order_flags = (int_f)c_crt_order_flags; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_shared_mesg_nindexes_c @@ -3958,25 +4071,26 @@ h5pset_attr_creation_order_c(hid_t_f *ocpl_id, int_f *crt_order_flags ) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_shared_mesg_nindexes_c(hid_t_f *plist_id, int_f *nindexes ) +h5pset_shared_mesg_nindexes_c(hid_t_f *plist_id, int_f *nindexes) /******/ { - int ret_value = -1; - hid_t c_plist_id; - unsigned c_nindexes; - herr_t ret; - /* - * Call h5pset_shared_mesg_nindexes function. - */ - c_plist_id = (hid_t)*plist_id; - c_nindexes = (unsigned)*nindexes; - ret = H5Pset_shared_mesg_nindexes(c_plist_id, c_nindexes ); - if (ret < 0) return ret_value; + int ret_value = -1; + hid_t c_plist_id; + unsigned c_nindexes; + herr_t ret; + /* + * Call h5pset_shared_mesg_nindexes function. + */ + c_plist_id = (hid_t)*plist_id; + c_nindexes = (unsigned)*nindexes; + ret = H5Pset_shared_mesg_nindexes(c_plist_id, c_nindexes); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_shared_mesg_index_c @@ -4002,21 +4116,23 @@ h5pset_shared_mesg_nindexes_c(hid_t_f *plist_id, int_f *nindexes ) * HISTORY * * SOURCE -*/ + */ int_f h5pset_shared_mesg_index_c(hid_t_f *fcpl_id, int_f *index_num, int_f *mesg_type_flags, int_f *min_mesg_size) /******/ { - int ret_value = -1; - herr_t ret; - /* - * Call h5pset_shared_mesg_index function. - */ - ret = H5Pset_shared_mesg_index((hid_t)*fcpl_id,(unsigned)*index_num, (unsigned)*mesg_type_flags, (unsigned)*min_mesg_size); - if (ret < 0) return ret_value; + int ret_value = -1; + herr_t ret; + /* + * Call h5pset_shared_mesg_index function. + */ + ret = H5Pset_shared_mesg_index((hid_t)*fcpl_id, (unsigned)*index_num, (unsigned)*mesg_type_flags, + (unsigned)*min_mesg_size); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_attr_creation_order_c @@ -4040,26 +4156,27 @@ h5pset_shared_mesg_index_c(hid_t_f *fcpl_id, int_f *index_num, int_f *mesg_type_ * HISTORY * * SOURCE -*/ + */ int_f h5pget_attr_creation_order_c(hid_t_f *ocpl_id, int_f *crt_order_flags) /******/ { - int ret_value = -1; - herr_t ret; + int ret_value = -1; + herr_t ret; - unsigned c_crt_order_flags; - /* - * Call h5pget_attr_creation_order function. - */ + unsigned c_crt_order_flags; + /* + * Call h5pget_attr_creation_order function. + */ - ret = H5Pget_attr_creation_order((hid_t)*ocpl_id, &c_crt_order_flags); - if (ret < 0) return ret_value; + ret = H5Pget_attr_creation_order((hid_t)*ocpl_id, &c_crt_order_flags); + if (ret < 0) + return ret_value; - *crt_order_flags = (int_f)c_crt_order_flags; + *crt_order_flags = (int_f)c_crt_order_flags; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_link_creation_order_c * NAME @@ -4080,21 +4197,22 @@ h5pget_attr_creation_order_c(hid_t_f *ocpl_id, int_f *crt_order_flags) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_link_creation_order_c(hid_t_f *gcpl_id, int_f *crt_order_flags ) +h5pset_link_creation_order_c(hid_t_f *gcpl_id, int_f *crt_order_flags) /******/ { - int ret_value = -1; - herr_t ret; - /* - * Call H5Pset_link_creation_order function. - */ - ret = H5Pset_link_creation_order((hid_t)*gcpl_id, (unsigned)*crt_order_flags); - if (ret < 0) return ret_value; + int ret_value = -1; + herr_t ret; + /* + * Call H5Pset_link_creation_order function. + */ + ret = H5Pset_link_creation_order((hid_t)*gcpl_id, (unsigned)*crt_order_flags); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_link_phase_change_c @@ -4115,26 +4233,27 @@ h5pset_link_creation_order_c(hid_t_f *gcpl_id, int_f *crt_order_flags ) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_link_phase_change_c(hid_t_f *gcpl_id, int_f *max_compact, int_f *min_dense ) +h5pget_link_phase_change_c(hid_t_f *gcpl_id, int_f *max_compact, int_f *min_dense) /******/ { - int ret_value = -1; - unsigned c_max_compact; - unsigned c_min_dense; - herr_t ret; + int ret_value = -1; + unsigned c_max_compact; + unsigned c_min_dense; + herr_t ret; - /* - * Call H5Pget_link_phase_change function. - */ - ret = H5Pget_link_phase_change((hid_t)*gcpl_id, &c_max_compact,&c_min_dense); - if (ret < 0) return ret_value; + /* + * Call H5Pget_link_phase_change function. + */ + ret = H5Pget_link_phase_change((hid_t)*gcpl_id, &c_max_compact, &c_min_dense); + if (ret < 0) + return ret_value; - *max_compact = (int_f)c_max_compact; - *min_dense = (int_f)c_min_dense; - ret_value = 0; - return ret_value; + *max_compact = (int_f)c_max_compact; + *min_dense = (int_f)c_min_dense; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_obj_track_times_c @@ -4156,27 +4275,29 @@ h5pget_link_phase_change_c(hid_t_f *gcpl_id, int_f *max_compact, int_f *min_dens * HISTORY * * SOURCE -*/ + */ int_f h5pget_obj_track_times_c(hid_t_f *plist_id, int_f *flag) /******/ { - int ret_value = -1; - hbool_t c_track_times=0; - herr_t ret; + int ret_value = -1; + hbool_t c_track_times = 0; + herr_t ret; - /* - * Call H5Pget_obj_track_times function. - */ - ret = H5Pget_obj_track_times((hid_t)*plist_id, &c_track_times); + /* + * Call H5Pget_obj_track_times function. + */ + ret = H5Pget_obj_track_times((hid_t)*plist_id, &c_track_times); - if (ret < 0) return ret_value; /* error occurred */ + if (ret < 0) + return ret_value; /* error occurred */ - *flag = 0; - if(c_track_times > 0) *flag = 1; - ret_value = 0; - return ret_value; + *flag = 0; + if (c_track_times > 0) + *flag = 1; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_obj_track_times_c @@ -4196,27 +4317,27 @@ h5pget_obj_track_times_c(hid_t_f *plist_id, int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f h5pset_obj_track_times_c(hid_t_f *plist_id, int_f *flag) /******/ { - int ret_value = -1; - hbool_t c_track_times; - herr_t ret; + int ret_value = -1; + hbool_t c_track_times; + herr_t ret; + c_track_times = (hbool_t)*flag; - c_track_times = (hbool_t)*flag; - - /* - * Call H5Pset_obj_track_times function. - */ - ret = H5Pset_obj_track_times((hid_t)*plist_id, c_track_times); + /* + * Call H5Pset_obj_track_times function. + */ + ret = H5Pset_obj_track_times((hid_t)*plist_id, c_track_times); - if (ret < 0) return ret_value; /* error occurred */ - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; /* error occurred */ + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_create_inter_group_c @@ -4239,23 +4360,24 @@ h5pset_obj_track_times_c(hid_t_f *plist_id, int_f *flag) * HISTORY * * SOURCE -*/ + */ int_f h5pset_create_inter_group_c(hid_t_f *lcpl_id, int_f *crt_intermed_group) /******/ { - int ret_value = -1; - herr_t ret; + int ret_value = -1; + herr_t ret; - /* - * Call H5Pset_create_intermediate_group function. - */ - ret = H5Pset_create_intermediate_group((hid_t)*lcpl_id, (unsigned)*crt_intermed_group); + /* + * Call H5Pset_create_intermediate_group function. + */ + ret = H5Pset_create_intermediate_group((hid_t)*lcpl_id, (unsigned)*crt_intermed_group); - if (ret < 0) return ret_value; /* error occurred */ - ret_value = 0; - return ret_value; + if (ret < 0) + return ret_value; /* error occurred */ + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_link_creation_order_c @@ -4279,26 +4401,27 @@ h5pset_create_inter_group_c(hid_t_f *lcpl_id, int_f *crt_intermed_group) * HISTORY * * SOURCE -*/ + */ int_f h5pget_link_creation_order_c(hid_t_f *gcpl_id, int_f *crt_order_flags) /******/ { - int ret_value = -1; - herr_t ret; + int ret_value = -1; + herr_t ret; - unsigned c_crt_order_flags; - /* - * Call h5pget_link_creation_order function. - */ + unsigned c_crt_order_flags; + /* + * Call h5pget_link_creation_order function. + */ - ret = H5Pget_link_creation_order((hid_t)*gcpl_id, &c_crt_order_flags); - if (ret < 0) return ret_value; + ret = H5Pget_link_creation_order((hid_t)*gcpl_id, &c_crt_order_flags); + if (ret < 0) + return ret_value; - *crt_order_flags = (int_f)c_crt_order_flags; + *crt_order_flags = (int_f)c_crt_order_flags; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_char_encoding_c @@ -4324,25 +4447,25 @@ h5pget_link_creation_order_c(hid_t_f *gcpl_id, int_f *crt_order_flags) * HISTORY * * SOURCE -*/ + */ int_f h5pset_char_encoding_c(hid_t_f *plist_id, int_f *encoding) /******/ { - int ret_value = -1; - herr_t ret; + int ret_value = -1; + herr_t ret; - /* - * Call H5Pset_char_encoding function. - */ - ret = H5Pset_char_encoding((hid_t)*plist_id, (H5T_cset_t)*encoding); - if (ret < 0) return ret_value; + /* + * Call H5Pset_char_encoding function. + */ + ret = H5Pset_char_encoding((hid_t)*plist_id, (H5T_cset_t)*encoding); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } - /****if* H5Pf/h5pget_char_encoding_c * NAME * h5pget_char_encoding_c @@ -4366,24 +4489,25 @@ h5pset_char_encoding_c(hid_t_f *plist_id, int_f *encoding) * HISTORY * * SOURCE -*/ + */ int_f h5pget_char_encoding_c(hid_t_f *plist_id, int_f *encoding) /******/ { - int ret_value = -1; - H5T_cset_t c_encoding; - herr_t ret; - /* - * Call H5Pget_char_encoding function. - */ - ret = H5Pget_char_encoding((hid_t)*plist_id, &c_encoding); - if (ret < 0) return ret_value; + int ret_value = -1; + H5T_cset_t c_encoding; + herr_t ret; + /* + * Call H5Pget_char_encoding function. + */ + ret = H5Pget_char_encoding((hid_t)*plist_id, &c_encoding); + if (ret < 0) + return ret_value; - *encoding = (int_f)c_encoding; + *encoding = (int_f)c_encoding; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_copy_object_c @@ -4409,21 +4533,22 @@ h5pget_char_encoding_c(hid_t_f *plist_id, int_f *encoding) * HISTORY * * SOURCE -*/ + */ int_f h5pset_copy_object_c(hid_t_f *ocp_plist_id, int_f *copy_options) /******/ { - int ret_value = -1; - herr_t ret; - /* - * Call H5Pset_copy_object function. - */ - ret = H5Pset_copy_object((hid_t)*ocp_plist_id, (unsigned)*copy_options); - if (ret < 0) return ret_value; + int ret_value = -1; + herr_t ret; + /* + * Call H5Pset_copy_object function. + */ + ret = H5Pset_copy_object((hid_t)*ocp_plist_id, (unsigned)*copy_options); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_copy_object_c @@ -4448,24 +4573,25 @@ h5pset_copy_object_c(hid_t_f *ocp_plist_id, int_f *copy_options) * HISTORY * * SOURCE -*/ + */ int_f h5pget_copy_object_c(hid_t_f *ocp_plist_id, int_f *copy_options) /******/ { - int ret_value = -1; - unsigned c_copy_options; - herr_t ret; - /* - * Call H5Pget_copy_object function. - */ - ret = H5Pget_copy_object((hid_t)*ocp_plist_id, &c_copy_options); - if (ret < 0) return ret_value; + int ret_value = -1; + unsigned c_copy_options; + herr_t ret; + /* + * Call H5Pget_copy_object function. + */ + ret = H5Pget_copy_object((hid_t)*ocp_plist_id, &c_copy_options); + if (ret < 0) + return ret_value; - *copy_options = (int_f)c_copy_options; + *copy_options = (int_f)c_copy_options; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_data_transform_c @@ -4492,31 +4618,31 @@ h5pget_copy_object_c(hid_t_f *ocp_plist_id, int_f *copy_options) * HISTORY * * SOURCE -*/ + */ int_f h5pget_data_transform_c(hid_t_f *plist_id, _fcd expression, int_f *expression_len, size_t_f *size) /******/ { - char *c_expression = NULL; /* Buffer to hold C string */ - size_t c_expression_len = (size_t)*expression_len + 1; + char * c_expression = NULL; /* Buffer to hold C string */ + size_t c_expression_len = (size_t)*expression_len + 1; ssize_t ret; - int_f ret_value = 0; + int_f ret_value = 0; /* * Allocate memory to store the expression. */ - if(c_expression_len) { + if (c_expression_len) { c_expression = (char *)HDmalloc(c_expression_len); - if(NULL == c_expression) - HGOTO_DONE(FAIL) + if (NULL == c_expression) + HGOTO_DONE(FAIL) } /* end if */ /* * Call H5Pget_data_transform function. */ ret = H5Pget_data_transform((hid_t)*plist_id, c_expression, c_expression_len); - if(ret < 0) - HGOTO_DONE(FAIL) + if (ret < 0) + HGOTO_DONE(FAIL) /* or strlen ? */ HD5packFstring(c_expression, _fcdtocp(expression), (size_t)*expression_len); @@ -4524,7 +4650,7 @@ h5pget_data_transform_c(hid_t_f *plist_id, _fcd expression, int_f *expression_le *size = (size_t_f)ret; done: - if(c_expression) + if (c_expression) HDfree(c_expression); return ret_value; @@ -4554,31 +4680,31 @@ done: * HISTORY * * SOURCE -*/ + */ int_f h5pset_data_transform_c(hid_t_f *plist_id, _fcd expression, int_f *expression_len) /******/ { - char* c_expression = NULL; /* Buffer to hold C string */ - int_f ret_value = 0; /* Return value */ + char *c_expression = NULL; /* Buffer to hold C string */ + int_f ret_value = 0; /* Return value */ - /* - * Convert FORTRAN name to C name - */ - if(NULL == (c_expression = HD5f2cstring(expression, (size_t)*expression_len))) + /* + * Convert FORTRAN name to C name + */ + if (NULL == (c_expression = HD5f2cstring(expression, (size_t)*expression_len))) HGOTO_DONE(FAIL) - /* - * Call H5Pset_data_transform function. - */ - if(H5Pset_data_transform((hid_t)*plist_id, c_expression) < 0) + /* + * Call H5Pset_data_transform function. + */ + if (H5Pset_data_transform((hid_t)*plist_id, c_expression) < 0) HGOTO_DONE(FAIL) done: - if(c_expression) + if (c_expression) HDfree(c_expression); - return ret_value; + return ret_value; } /****if* H5Pf/h5pget_local_heap_size_hint_c @@ -4603,23 +4729,24 @@ done: * HISTORY * * SOURCE -*/ + */ int_f h5pget_local_heap_size_hint_c(hid_t_f *gcpl_id, size_t_f *size_hint) /******/ { - int_f ret_value = -1; /* Return value */ - size_t c_size_hint; - herr_t ret; - /* - * Call H5Pget_local_heap_size_hint function. - */ - ret = H5Pget_local_heap_size_hint((hid_t)*gcpl_id, &c_size_hint); - if(ret<0) return ret_value; + int_f ret_value = -1; /* Return value */ + size_t c_size_hint; + herr_t ret; + /* + * Call H5Pget_local_heap_size_hint function. + */ + ret = H5Pget_local_heap_size_hint((hid_t)*gcpl_id, &c_size_hint); + if (ret < 0) + return ret_value; - *size_hint = (size_t_f)c_size_hint; - ret_value = 0; - return ret_value; + *size_hint = (size_t_f)c_size_hint; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_est_link_info_c @@ -4645,26 +4772,27 @@ h5pget_local_heap_size_hint_c(hid_t_f *gcpl_id, size_t_f *size_hint) * HISTORY * * SOURCE -*/ + */ int_f h5pget_est_link_info_c(hid_t_f *gcpl_id, int_f *est_num_entries, int_f *est_name_len) /******/ { - int_f ret_value = -1; /* Return value */ - unsigned c_est_num_entries; - unsigned c_est_name_len; - herr_t ret; - /* - * Call h5pget_est_link_info function. - */ - ret = H5Pget_est_link_info((hid_t)*gcpl_id, &c_est_num_entries, &c_est_name_len); - if(ret<0) return ret_value; + int_f ret_value = -1; /* Return value */ + unsigned c_est_num_entries; + unsigned c_est_name_len; + herr_t ret; + /* + * Call h5pget_est_link_info function. + */ + ret = H5Pget_est_link_info((hid_t)*gcpl_id, &c_est_num_entries, &c_est_name_len); + if (ret < 0) + return ret_value; - *est_num_entries = (int_f)c_est_num_entries; - *est_name_len = (int_f)c_est_name_len; + *est_num_entries = (int_f)c_est_num_entries; + *est_name_len = (int_f)c_est_name_len; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_local_heap_size_hint_c @@ -4690,21 +4818,22 @@ h5pget_est_link_info_c(hid_t_f *gcpl_id, int_f *est_num_entries, int_f *est_name * HISTORY * * SOURCE -*/ + */ int_f h5pset_local_heap_size_hint_c(hid_t_f *gcpl_id, size_t_f *size_hint) /******/ { - int_f ret_value = -1; /* Return value */ - herr_t ret; - /* - * Call H5Pget_local_heap_size_hint function. - */ - ret = H5Pset_local_heap_size_hint((hid_t)*gcpl_id, (size_t)*size_hint); - if(ret<0) return ret_value; + int_f ret_value = -1; /* Return value */ + herr_t ret; + /* + * Call H5Pget_local_heap_size_hint function. + */ + ret = H5Pset_local_heap_size_hint((hid_t)*gcpl_id, (size_t)*size_hint); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_est_link_info_c @@ -4730,21 +4859,22 @@ h5pset_local_heap_size_hint_c(hid_t_f *gcpl_id, size_t_f *size_hint) * HISTORY * * SOURCE -*/ + */ int_f h5pset_est_link_info_c(hid_t_f *gcpl_id, int_f *est_num_entries, int_f *est_name_len) /******/ { - int_f ret_value = -1; /* Return value */ - herr_t ret; - /* - * Call h5pset_est_link_info function. - */ - ret = H5Pset_est_link_info((hid_t)*gcpl_id, (unsigned)*est_num_entries, (unsigned)*est_name_len); - if(ret<0) return ret_value; + int_f ret_value = -1; /* Return value */ + herr_t ret; + /* + * Call h5pset_est_link_info function. + */ + ret = H5Pset_est_link_info((hid_t)*gcpl_id, (unsigned)*est_num_entries, (unsigned)*est_name_len); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_link_phase_change_c @@ -4766,22 +4896,23 @@ h5pset_est_link_info_c(hid_t_f *gcpl_id, int_f *est_num_entries, int_f *est_name * HISTORY * * SOURCE -*/ + */ int_f -h5pset_link_phase_change_c(hid_t_f *gcpl_id, int_f *max_compact, int_f *min_dense ) +h5pset_link_phase_change_c(hid_t_f *gcpl_id, int_f *max_compact, int_f *min_dense) /******/ { - int ret_value = -1; - herr_t ret; + int ret_value = -1; + herr_t ret; - /* - * Call H5Pset_link_phase_change function. - */ - ret = H5Pset_link_phase_change((hid_t)*gcpl_id, (unsigned)*max_compact,(unsigned)*min_dense); - if (ret < 0) return ret_value; + /* + * Call H5Pset_link_phase_change function. + */ + ret = H5Pset_link_phase_change((hid_t)*gcpl_id, (unsigned)*max_compact, (unsigned)*min_dense); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_fapl_direct_c @@ -4805,29 +4936,31 @@ h5pset_link_phase_change_c(hid_t_f *gcpl_id, int_f *max_compact, int_f *min_dens * HISTORY * * SOURCE -*/ + */ #ifndef H5_HAVE_DIRECT /* Only gets gcc const attribute when the direct VFD is not built. */ H5_ATTR_CONST #endif int_f -h5pset_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *alignment, size_t_f H5_ATTR_UNUSED *block_size, size_t_f H5_ATTR_UNUSED *cbuf_size) +h5pset_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *alignment, + size_t_f H5_ATTR_UNUSED *block_size, size_t_f H5_ATTR_UNUSED *cbuf_size) /******/ { - int ret_value = -1; + int ret_value = -1; #ifdef H5_HAVE_DIRECT - herr_t ret; + herr_t ret; - /* - * Call H5Pset_link_phase_change function. - */ - ret = H5Pset_fapl_direct((hid_t)*fapl_id, (size_t)*alignment, (size_t)*block_size, (size_t)*cbuf_size ); - if (ret < 0) return ret_value; + /* + * Call H5Pset_link_phase_change function. + */ + ret = H5Pset_fapl_direct((hid_t)*fapl_id, (size_t)*alignment, (size_t)*block_size, (size_t)*cbuf_size); + if (ret < 0) + return ret_value; - ret_value = 0; + ret_value = 0; #endif - return ret_value; + return ret_value; } /****if* H5Pf/h5pget_fapl_direct_c @@ -4852,35 +4985,37 @@ h5pset_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *a * HISTORY * * SOURCE -*/ + */ #ifndef H5_HAVE_DIRECT /* Only gets gcc const attribute when the direct VFD is not built. */ H5_ATTR_CONST #endif int_f -h5pget_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *alignment, size_t_f H5_ATTR_UNUSED *block_size, size_t_f H5_ATTR_UNUSED *cbuf_size) +h5pget_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *alignment, + size_t_f H5_ATTR_UNUSED *block_size, size_t_f H5_ATTR_UNUSED *cbuf_size) /******/ { - int ret_value = -1; + int ret_value = -1; #ifdef H5_HAVE_DIRECT - herr_t ret; - size_t c_alignment; - size_t c_block_size; - size_t c_cbuf_size; - - /* - * Call H5Pget_link_phase_change function. - */ - ret = H5Pget_fapl_direct((hid_t)*fapl_id, &c_alignment, &c_block_size, &c_cbuf_size ); - if (ret < 0) return ret_value; - - *alignment = (size_t_f)c_alignment; - *block_size = (size_t_f)c_block_size; - *cbuf_size = (size_t_f)c_cbuf_size; - - ret_value = 0; + herr_t ret; + size_t c_alignment; + size_t c_block_size; + size_t c_cbuf_size; + + /* + * Call H5Pget_link_phase_change function. + */ + ret = H5Pget_fapl_direct((hid_t)*fapl_id, &c_alignment, &c_block_size, &c_cbuf_size); + if (ret < 0) + return ret_value; + + *alignment = (size_t_f)c_alignment; + *block_size = (size_t_f)c_block_size; + *cbuf_size = (size_t_f)c_cbuf_size; + + ret_value = 0; #endif - return ret_value; + return ret_value; } /****if* H5Pf/h5pset_attr_phase_change_c @@ -4903,21 +5038,22 @@ h5pget_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *a * HISTORY * * SOURCE -*/ + */ int_f -h5pset_attr_phase_change_c(hid_t_f *ocpl_id, int_f *max_compact, int_f *min_dense ) +h5pset_attr_phase_change_c(hid_t_f *ocpl_id, int_f *max_compact, int_f *min_dense) /******/ { - int ret_value = -1; - herr_t ret; - /* - * Call H5Pset_attr_phase_change function. - */ - ret = H5Pset_attr_phase_change((hid_t)*ocpl_id, (unsigned)*max_compact,(unsigned)*min_dense); - if (ret < 0) return ret_value; + int ret_value = -1; + herr_t ret; + /* + * Call H5Pset_attr_phase_change function. + */ + ret = H5Pset_attr_phase_change((hid_t)*ocpl_id, (unsigned)*max_compact, (unsigned)*min_dense); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_nbit_c @@ -4938,21 +5074,22 @@ h5pset_attr_phase_change_c(hid_t_f *ocpl_id, int_f *max_compact, int_f *min_dens * HISTORY * * SOURCE -*/ + */ int_f -h5pset_nbit_c(hid_t_f *plist_id ) +h5pset_nbit_c(hid_t_f *plist_id) /******/ { - int ret_value = -1; - herr_t ret; - /* - * Call H5Pset_nbit_change function. - */ - ret = H5Pset_nbit((hid_t)*plist_id); - if (ret < 0) return ret_value; + int ret_value = -1; + herr_t ret; + /* + * Call H5Pset_nbit_change function. + */ + ret = H5Pset_nbit((hid_t)*plist_id); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_scaleoffset_c * NAME @@ -4971,24 +5108,25 @@ h5pset_nbit_c(hid_t_f *plist_id ) * M. Scot Breitenfeld * March 21, 2008 * SOURCE -*/ + */ int_f -h5pset_scaleoffset_c(hid_t_f *plist_id, int_f *scale_type, int_f *scale_factor ) +h5pset_scaleoffset_c(hid_t_f *plist_id, int_f *scale_type, int_f *scale_factor) /******/ { - int ret_value = -1; - H5Z_SO_scale_type_t c_scale_type; - herr_t ret; - /* - * Call H5Pset_scaleoffset_change function. - */ - c_scale_type = (H5Z_SO_scale_type_t)*scale_type; + int ret_value = -1; + H5Z_SO_scale_type_t c_scale_type; + herr_t ret; + /* + * Call H5Pset_scaleoffset_change function. + */ + c_scale_type = (H5Z_SO_scale_type_t)*scale_type; - ret = H5Pset_scaleoffset((hid_t)*plist_id, c_scale_type, (int)*scale_factor); - if (ret < 0) return ret_value; + ret = H5Pset_scaleoffset((hid_t)*plist_id, c_scale_type, (int)*scale_factor); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_nlinks @@ -5006,21 +5144,22 @@ h5pset_scaleoffset_c(hid_t_f *plist_id, int_f *scale_type, int_f *scale_factor ) * M. Scot Breitenfeld * March 24, 2008 * SOURCE -*/ + */ int_f h5pset_nlinks_c(hid_t_f *lapl_id, size_t_f *nlinks) /******/ { - int ret_value = -1; - herr_t ret; - /* - * Call H5Pset_nlinks function. - */ - ret = H5Pset_nlinks((hid_t)*lapl_id, (size_t)*nlinks); - if (ret < 0) return ret_value; + int ret_value = -1; + herr_t ret; + /* + * Call H5Pset_nlinks function. + */ + ret = H5Pset_nlinks((hid_t)*lapl_id, (size_t)*nlinks); + if (ret < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_nlinks @@ -5045,23 +5184,24 @@ h5pset_nlinks_c(hid_t_f *lapl_id, size_t_f *nlinks) * HISTORY * * SOURCE -*/ + */ int_f h5pget_nlinks_c(hid_t_f *lapl_id, size_t_f *nlinks) /******/ { - int ret_value = -1; - herr_t ret; - size_t c_nlinks; - /* - * Call H5Pget_nlinks function. - */ - ret = H5Pget_nlinks((hid_t)*lapl_id, &c_nlinks); - if (ret < 0) return ret_value; + int ret_value = -1; + herr_t ret; + size_t c_nlinks; + /* + * Call H5Pget_nlinks function. + */ + ret = H5Pget_nlinks((hid_t)*lapl_id, &c_nlinks); + if (ret < 0) + return ret_value; - *nlinks = (size_t_f)c_nlinks; - ret_value = 0; - return ret_value; + *nlinks = (size_t_f)c_nlinks; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_create_inter_group_c @@ -5083,25 +5223,26 @@ h5pget_nlinks_c(hid_t_f *lapl_id, size_t_f *nlinks) * HISTORY * * SOURCE -*/ + */ int_f h5pget_create_inter_group_c(hid_t_f *lcpl_id, int_f *crt_intermed_group) /******/ { - int ret_value = -1; - herr_t ret; - unsigned c_crt_intermed_group; + int ret_value = -1; + herr_t ret; + unsigned c_crt_intermed_group; - /* - * Call H5Pget_create_intermediate_group function. - */ - ret = H5Pget_create_intermediate_group((hid_t)*lcpl_id, &c_crt_intermed_group); + /* + * Call H5Pget_create_intermediate_group function. + */ + ret = H5Pget_create_intermediate_group((hid_t)*lcpl_id, &c_crt_intermed_group); - if (ret < 0) return ret_value; /* error occurred */ + if (ret < 0) + return ret_value; /* error occurred */ - *crt_intermed_group = (int_f)c_crt_intermed_group; - ret_value = 0; - return ret_value; + *crt_intermed_group = (int_f)c_crt_intermed_group; + ret_value = 0; + return ret_value; } /*---------------------------------------------------------------------------- @@ -5122,16 +5263,17 @@ h5pget_create_inter_group_c(hid_t_f *lcpl_id, int_f *crt_intermed_group) int_f h5pset_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, size_t_f *rdcc_nbytes, real_f *rdcc_w0) { - int ret_value = -1; + int ret_value = -1; - /* - * Call H5Pset_chunk_cache function. - */ - if( (H5Pset_chunk_cache((hid_t)*dapl_id, (size_t)*rdcc_nslots, (size_t)*rdcc_nbytes, (double)*rdcc_w0)) <0 ) - return ret_value; /* error occurred */ + /* + * Call H5Pset_chunk_cache function. + */ + if ((H5Pset_chunk_cache((hid_t)*dapl_id, (size_t)*rdcc_nslots, (size_t)*rdcc_nbytes, (double)*rdcc_w0)) < + 0) + return ret_value; /* error occurred */ - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /*---------------------------------------------------------------------------- @@ -5153,22 +5295,22 @@ h5pset_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, size_t_f *rdcc_nby int_f h5pget_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, size_t_f *rdcc_nbytes, real_f *rdcc_w0) { - int ret_value = -1; - size_t c_rdcc_nslots; - size_t c_rdcc_nbytes; - double c_rdcc_w0; - /* - * Call H5Pget_chunk_cache function. - */ - if( (H5Pget_chunk_cache((hid_t)*dapl_id, &c_rdcc_nslots, &c_rdcc_nbytes, &c_rdcc_w0)) <0 ) - return ret_value; /* error occurred */ + int ret_value = -1; + size_t c_rdcc_nslots; + size_t c_rdcc_nbytes; + double c_rdcc_w0; + /* + * Call H5Pget_chunk_cache function. + */ + if ((H5Pget_chunk_cache((hid_t)*dapl_id, &c_rdcc_nslots, &c_rdcc_nbytes, &c_rdcc_w0)) < 0) + return ret_value; /* error occurred */ - *rdcc_nslots=(size_t_f)c_rdcc_nslots; - *rdcc_nbytes=(size_t_f)c_rdcc_nbytes; - *rdcc_w0=(real_f)c_rdcc_w0; + *rdcc_nslots = (size_t_f)c_rdcc_nslots; + *rdcc_nbytes = (size_t_f)c_rdcc_nbytes; + *rdcc_w0 = (real_f)c_rdcc_w0; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /*---------------------------------------------------------------------------- @@ -5189,15 +5331,15 @@ h5pget_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, size_t_f *rdcc_nby int_f h5pset_file_image_c(hid_t_f *fapl_id, void *buf_ptr, size_t_f *buf_len) { - int ret_value = -1; - /* - * Call H5Pset_file_image function. - */ - if( (H5Pset_file_image((hid_t)*fapl_id, buf_ptr, (size_t)*buf_len)) <0 ) - return ret_value; /* error occurred */ + int ret_value = -1; + /* + * Call H5Pset_file_image function. + */ + if ((H5Pset_file_image((hid_t)*fapl_id, buf_ptr, (size_t)*buf_len)) < 0) + return ret_value; /* error occurred */ - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /*---------------------------------------------------------------------------- @@ -5219,26 +5361,27 @@ h5pset_file_image_c(hid_t_f *fapl_id, void *buf_ptr, size_t_f *buf_len) int_f h5pget_file_image_c(hid_t_f *fapl_id, void **buf_ptr, size_t_f *buf_len_ptr) { - int ret_value = -1; - size_t c_buf_len_ptr; - void *c_buf_ptr = NULL; + int ret_value = -1; + size_t c_buf_len_ptr; + void * c_buf_ptr = NULL; - c_buf_len_ptr = (size_t)*buf_len_ptr; + c_buf_len_ptr = (size_t)*buf_len_ptr; - /* - * Call H5Pget_file_image function. - */ - if( (H5Pget_file_image((hid_t)*fapl_id, (void **)&c_buf_ptr, &c_buf_len_ptr)) <0 ) - return ret_value; /* error occurred */ + /* + * Call H5Pget_file_image function. + */ + if ((H5Pget_file_image((hid_t)*fapl_id, (void **)&c_buf_ptr, &c_buf_len_ptr)) < 0) + return ret_value; /* error occurred */ - HDmemcpy((void *)*buf_ptr, (void *)c_buf_ptr, c_buf_len_ptr); + HDmemcpy((void *)*buf_ptr, (void *)c_buf_ptr, c_buf_len_ptr); - *buf_len_ptr=(size_t_f)c_buf_len_ptr; + *buf_len_ptr = (size_t_f)c_buf_len_ptr; - ret_value = 0; - if(c_buf_ptr) H5free_memory(c_buf_ptr); + ret_value = 0; + if (c_buf_ptr) + H5free_memory(c_buf_ptr); - return ret_value; + return ret_value; } #ifdef H5_HAVE_PARALLEL @@ -5260,27 +5403,28 @@ h5pget_file_image_c(hid_t_f *fapl_id, void **buf_ptr, size_t_f *buf_len_ptr) * HISTORY * * SOURCE -*/ + */ int_f -h5pset_fapl_mpio_c(hid_t_f *prp_id, int_f* comm, int_f* info) +h5pset_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - MPI_Comm c_comm; - MPI_Info c_info; - c_comm = MPI_Comm_f2c(*comm); - c_info = MPI_Info_f2c(*info); + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + MPI_Comm c_comm; + MPI_Info c_info; + c_comm = MPI_Comm_f2c(*comm); + c_info = MPI_Info_f2c(*info); - /* - * Call H5Pset_mpi function. - */ - c_prp_id = *prp_id; - ret = H5Pset_fapl_mpio(c_prp_id, c_comm, c_info); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + /* + * Call H5Pset_mpi function. + */ + c_prp_id = *prp_id; + ret = H5Pset_fapl_mpio(c_prp_id, c_comm, c_info); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_fapl_mpio_c * NAME @@ -5299,27 +5443,28 @@ h5pset_fapl_mpio_c(hid_t_f *prp_id, int_f* comm, int_f* info) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_fapl_mpio_c(hid_t_f *prp_id, int_f* comm, int_f* info) +h5pget_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - MPI_Comm c_comm; - MPI_Info c_info; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + MPI_Comm c_comm; + MPI_Info c_info; - /* - * Call H5Pget_mpi function. - */ - c_prp_id = *prp_id; - ret = H5Pget_fapl_mpio(c_prp_id, &c_comm, &c_info); - if (ret < 0) return ret_value; - *comm = (int_f) MPI_Comm_c2f(c_comm); - *info = (int_f) MPI_Info_c2f(c_info); - ret_value = 0; - return ret_value; + /* + * Call H5Pget_mpi function. + */ + c_prp_id = *prp_id; + ret = H5Pget_fapl_mpio(c_prp_id, &c_comm, &c_info); + if (ret < 0) + return ret_value; + *comm = (int_f)MPI_Comm_c2f(c_comm); + *info = (int_f)MPI_Info_c2f(c_info); + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pset_dxpl_mpio_c * NAME @@ -5338,38 +5483,39 @@ h5pget_fapl_mpio_c(hid_t_f *prp_id, int_f* comm, int_f* info) * HISTORY * * SOURCE -*/ -int_f -h5pset_dxpl_mpio_c(hid_t_f *prp_id, int_f* data_xfer_mode) -/******/ -{ - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - H5FD_mpio_xfer_t c_data_xfer_mode; -/* - switch (*data_xfer_mode) { - - case H5FD_MPIO_INDEPENDENT_F: - c_data_xfer_mode = H5FD_MPIO_INDEPENDENT; - break; - - case H5FD_MPIO_COLLECTIVE_F: - c_data_xfer_mode = H5FD_MPIO_COLLECTIVE; - break; - default: - return ret_value; - } -*/ - c_data_xfer_mode = (H5FD_mpio_xfer_t)*data_xfer_mode; - /* - * Call H5Pset_dxpl_mpio function. - */ - c_prp_id = *prp_id; - ret = H5Pset_dxpl_mpio(c_prp_id, c_data_xfer_mode); - if (ret < 0) return ret_value; - ret_value = 0; - return ret_value; + */ +int_f +h5pset_dxpl_mpio_c(hid_t_f *prp_id, int_f *data_xfer_mode) +/******/ +{ + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + H5FD_mpio_xfer_t c_data_xfer_mode; + /* + switch (*data_xfer_mode) { + + case H5FD_MPIO_INDEPENDENT_F: + c_data_xfer_mode = H5FD_MPIO_INDEPENDENT; + break; + + case H5FD_MPIO_COLLECTIVE_F: + c_data_xfer_mode = H5FD_MPIO_COLLECTIVE; + break; + default: + return ret_value; + } + */ + c_data_xfer_mode = (H5FD_mpio_xfer_t)*data_xfer_mode; + /* + * Call H5Pset_dxpl_mpio function. + */ + c_prp_id = *prp_id; + ret = H5Pset_dxpl_mpio(c_prp_id, c_data_xfer_mode); + if (ret < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_dxpl_mpio_c @@ -5389,40 +5535,41 @@ h5pset_dxpl_mpio_c(hid_t_f *prp_id, int_f* data_xfer_mode) * HISTORY * * SOURCE -*/ + */ int_f -h5pget_dxpl_mpio_c(hid_t_f *prp_id, int_f* data_xfer_mode) +h5pget_dxpl_mpio_c(hid_t_f *prp_id, int_f *data_xfer_mode) /******/ { - int ret_value = -1; - hid_t c_prp_id; - herr_t ret; - H5FD_mpio_xfer_t c_data_xfer_mode; + int ret_value = -1; + hid_t c_prp_id; + herr_t ret; + H5FD_mpio_xfer_t c_data_xfer_mode; - /* - * Call H5Pget_xfer function. - */ - c_prp_id = *prp_id; - ret = H5Pget_dxpl_mpio(c_prp_id, &c_data_xfer_mode); - if (ret < 0) return ret_value; - *data_xfer_mode = (int_f)c_data_xfer_mode; -/* - switch (c_data_xfer_mode) { + /* + * Call H5Pget_xfer function. + */ + c_prp_id = *prp_id; + ret = H5Pget_dxpl_mpio(c_prp_id, &c_data_xfer_mode); + if (ret < 0) + return ret_value; + *data_xfer_mode = (int_f)c_data_xfer_mode; + /* + switch (c_data_xfer_mode) { - case H5FD_MPIO_INDEPENDENT: - *data_xfer_mode = H5FD_MPIO_INDEPENDENT_F; - break; + case H5FD_MPIO_INDEPENDENT: + *data_xfer_mode = H5FD_MPIO_INDEPENDENT_F; + break; - case H5FD_MPIO_COLLECTIVE: - *data_xfer_mode = H5FD_MPIO_COLLECTIVE_F; - break; + case H5FD_MPIO_COLLECTIVE: + *data_xfer_mode = H5FD_MPIO_COLLECTIVE_F; + break; - default: - return ret_value; - } -*/ - ret_value = 0; - return ret_value; + default: + return ret_value; + } + */ + ret_value = 0; + return ret_value; } /****if* H5Pf/h5pget_mpio_actual_io_mode_c @@ -5442,23 +5589,23 @@ h5pget_dxpl_mpio_c(hid_t_f *prp_id, int_f* data_xfer_mode) * M. Scot Breitenfeld * July 27, 2012 * SOURCE -*/ + */ int_f h5pget_mpio_actual_io_mode_c(hid_t_f *dxpl_id, int_f *actual_io_mode) /******/ { - int ret_value = -1; - H5D_mpio_actual_io_mode_t c_actual_io_mode; + int ret_value = -1; + H5D_mpio_actual_io_mode_t c_actual_io_mode; - /* - * Call H5Pget_mpio_actual_io_mode_f function. - */ - if( (H5Pget_mpio_actual_io_mode((hid_t)*dxpl_id, &c_actual_io_mode)) <0 ) - return ret_value; /* error occurred */ + /* + * Call H5Pget_mpio_actual_io_mode_f function. + */ + if ((H5Pget_mpio_actual_io_mode((hid_t)*dxpl_id, &c_actual_io_mode)) < 0) + return ret_value; /* error occurred */ - *actual_io_mode =(int_f)c_actual_io_mode; + *actual_io_mode = (int_f)c_actual_io_mode; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } #endif /*H5_HAVE_PARALLEL*/ diff --git a/fortran/src/H5Rf.c b/fortran/src/H5Rf.c index df2ded4..d712a8f 100644 --- a/fortran/src/H5Rf.c +++ b/fortran/src/H5Rf.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5Eprivate.h" @@ -43,34 +43,34 @@ * HISTORY * * SOURCE -*/ + */ int_f h5rcreate_region_c(int_f *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *space_id) /******/ { - char *c_name = NULL; - hdset_reg_ref_t ref_c; - int_f ret_value = 0; + char * c_name = NULL; + hdset_reg_ref_t ref_c; + int_f ret_value = 0; - /* - * Convert FORTRAN name to C name - */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) - HGOTO_DONE(FAIL) + /* + * Convert FORTRAN name to C name + */ + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + HGOTO_DONE(FAIL) - /* - * Call H5Rcreate function. - */ - if(H5Rcreate(&ref_c, (hid_t)*loc_id, c_name, H5R_DATASET_REGION, (hid_t)*space_id) < 0) - HGOTO_DONE(FAIL) + /* + * Call H5Rcreate function. + */ + if (H5Rcreate(&ref_c, (hid_t)*loc_id, c_name, H5R_DATASET_REGION, (hid_t)*space_id) < 0) + HGOTO_DONE(FAIL) - /* Copy the reference created */ - HDmemcpy(ref, &ref_c, H5R_DSET_REG_REF_BUF_SIZE); + /* Copy the reference created */ + HDmemcpy(ref, &ref_c, H5R_DSET_REG_REF_BUF_SIZE); done: - if(c_name) - HDfree(c_name); - return ret_value; + if (c_name) + HDfree(c_name); + return ret_value; } /* end h5rcreate_region_c() */ /****if* H5Rf/h5rcreate_ptr_c @@ -92,28 +92,29 @@ done: * June 20, 2008 * * SOURCE -*/ + */ int_f -h5rcreate_ptr_c (void *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *ref_type, hid_t_f *space_id) +h5rcreate_ptr_c(void *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *ref_type, hid_t_f *space_id) /******/ { - int ret_value = -1; - char *c_name; - - /* - * Convert FORTRAN name to C name - */ - c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return ret_value; - - /* - * Call H5Rcreate function. - */ - if(H5Rcreate(ref, (hid_t)*loc_id, c_name, (H5R_type_t)*ref_type, (hid_t)*space_id) >= 0) - ret_value = 0; - - HDfree(c_name); - return ret_value; + int ret_value = -1; + char *c_name; + + /* + * Convert FORTRAN name to C name + */ + c_name = (char *)HD5f2cstring(name, (size_t)*namelen); + if (c_name == NULL) + return ret_value; + + /* + * Call H5Rcreate function. + */ + if (H5Rcreate(ref, (hid_t)*loc_id, c_name, (H5R_type_t)*ref_type, (hid_t)*space_id) >= 0) + ret_value = 0; + + HDfree(c_name); + return ret_value; } /****if* H5Rf/h5rdereference_ptr_c @@ -136,22 +137,23 @@ h5rcreate_ptr_c (void *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *r * HISTORY * * SOURCE -*/ + */ int_f -h5rdereference_ptr_c (hid_t_f *obj_id, int_f *ref_type, void *ref, hid_t_f *ref_obj_id) +h5rdereference_ptr_c(hid_t_f *obj_id, int_f *ref_type, void *ref, hid_t_f *ref_obj_id) /******/ { - int ret_value = -1; - hid_t c_ref_obj_id; - - /* - * Call H5Rdereference function. - */ - c_ref_obj_id = H5Rdereference2((hid_t)*obj_id, H5P_DEFAULT, (H5R_type_t)*ref_type, ref); - if(c_ref_obj_id < 0) return ret_value; - *ref_obj_id = (hid_t_f)c_ref_obj_id; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_ref_obj_id; + + /* + * Call H5Rdereference function. + */ + c_ref_obj_id = H5Rdereference2((hid_t)*obj_id, H5P_DEFAULT, (H5R_type_t)*ref_type, ref); + if (c_ref_obj_id < 0) + return ret_value; + *ref_obj_id = (hid_t_f)c_ref_obj_id; + ret_value = 0; + return ret_value; } /****if* H5Rf/h5rget_region_region_object_c @@ -172,29 +174,29 @@ h5rdereference_ptr_c (hid_t_f *obj_id, int_f *ref_type, void *ref, hid_t_f *ref_ * HISTORY * * SOURCE -*/ + */ int_f h5rget_region_region_c(hid_t_f *dset_id, int_f *ref, hid_t_f *space_id) /******/ { - hid_t c_space_id; - hdset_reg_ref_t ref_c; - int_f ret_value = 0; + hid_t c_space_id; + hdset_reg_ref_t ref_c; + int_f ret_value = 0; - /* Copy the reference to dereference */ - HDmemcpy(&ref_c, ref, H5R_DSET_REG_REF_BUF_SIZE); + /* Copy the reference to dereference */ + HDmemcpy(&ref_c, ref, H5R_DSET_REG_REF_BUF_SIZE); - /* - * Call H5Rget_region function. - */ - if((c_space_id = H5Rget_region((hid_t)*dset_id, H5R_DATASET_REGION, &ref_c)) < 0) - HGOTO_DONE(FAIL) + /* + * Call H5Rget_region function. + */ + if ((c_space_id = H5Rget_region((hid_t)*dset_id, H5R_DATASET_REGION, &ref_c)) < 0) + HGOTO_DONE(FAIL) - /* Copy the dataspace ID */ - *space_id = (hid_t_f)c_space_id; + /* Copy the dataspace ID */ + *space_id = (hid_t_f)c_space_id; done: - return ret_value; + return ret_value; } /* end h5rget_region_region_c() */ /****if* H5Rf/h5rget_region_ptr_c @@ -215,28 +217,27 @@ done: * HISTORY * * SOURCE -*/ + */ int_f h5rget_region_ptr_c(hid_t_f *dset_id, void *ref, hid_t_f *space_id) /******/ { - hid_t c_space_id; - int_f ret_value = 0; + hid_t c_space_id; + int_f ret_value = 0; - /* - * Call H5Rget_region function. - */ - if((c_space_id = H5Rget_region((hid_t)*dset_id, H5R_DATASET_REGION, ref)) < 0) - HGOTO_DONE(FAIL) + /* + * Call H5Rget_region function. + */ + if ((c_space_id = H5Rget_region((hid_t)*dset_id, H5R_DATASET_REGION, ref)) < 0) + HGOTO_DONE(FAIL) - /* Copy the dataspace ID */ - *space_id = (hid_t_f)c_space_id; + /* Copy the dataspace ID */ + *space_id = (hid_t_f)c_space_id; done: - return ret_value; + return ret_value; } /* end h5rget_region_ptr_c() */ - /****if* H5Rf/h5rget_object_type_obj_c * NAME * h5rget_object_type_obj_c @@ -256,26 +257,26 @@ done: * HISTORY * * SOURCE -*/ + */ int_f h5rget_object_type_obj_c(hid_t_f *dset_id, haddr_t_f *ref, int_f *obj_type) /******/ { - H5O_type_t c_obj_type; - hobj_ref_t ref_c = (hobj_ref_t)*ref; - int_f ret_value = 0; + H5O_type_t c_obj_type; + hobj_ref_t ref_c = (hobj_ref_t)*ref; + int_f ret_value = 0; - /* - * Call H5Rget_object_type function. - */ - if(H5Rget_obj_type2((hid_t)*dset_id, H5R_OBJECT, &ref_c, &c_obj_type) < 0) - HGOTO_DONE(FAIL) + /* + * Call H5Rget_object_type function. + */ + if (H5Rget_obj_type2((hid_t)*dset_id, H5R_OBJECT, &ref_c, &c_obj_type) < 0) + HGOTO_DONE(FAIL) - /* Copy the object type */ - *obj_type = (int_f)c_obj_type; + /* Copy the object type */ + *obj_type = (int_f)c_obj_type; done: - return ret_value; + return ret_value; } /* end h5rget_object_type_obj_c() */ /****if* H5Rf/h5rget_name_ptr_c @@ -301,40 +302,43 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5rget_name_ptr_c (hid_t_f *loc_id, int_f *ref_type, void *ref, _fcd name, size_t_f *name_len, size_t_f *size_default) +h5rget_name_ptr_c(hid_t_f *loc_id, int_f *ref_type, void *ref, _fcd name, size_t_f *name_len, + size_t_f *size_default) /******/ { - int_f ret_value = -1; - ssize_t c_size; - size_t c_bufsize; - char *c_buf= NULL; /* Buffer to hold C string */ - - c_bufsize = (size_t)*name_len+1; - /* - * Allocate buffer to hold name of an attribute - */ - if ((c_buf = (char *)HDmalloc(c_bufsize)) == NULL) - return ret_value; - - /* - * Call H5Rget_name function. - */ - if((c_size=H5Rget_name((hid_t)*loc_id, (H5R_type_t)*ref_type, ref, c_buf, c_bufsize)) < 0){ - if(c_buf) HDfree(c_buf); - return ret_value; - } - /* - * Convert C name to FORTRAN and place it in the given buffer - */ - HD5packFstring(c_buf, _fcdtocp(name), c_bufsize-1); - - *size_default = (size_t_f)c_size; - ret_value = 0; - if(c_buf) HDfree(c_buf); - - return ret_value; + int_f ret_value = -1; + ssize_t c_size; + size_t c_bufsize; + char * c_buf = NULL; /* Buffer to hold C string */ + + c_bufsize = (size_t)*name_len + 1; + /* + * Allocate buffer to hold name of an attribute + */ + if ((c_buf = (char *)HDmalloc(c_bufsize)) == NULL) + return ret_value; + + /* + * Call H5Rget_name function. + */ + if ((c_size = H5Rget_name((hid_t)*loc_id, (H5R_type_t)*ref_type, ref, c_buf, c_bufsize)) < 0) { + if (c_buf) + HDfree(c_buf); + return ret_value; + } + /* + * Convert C name to FORTRAN and place it in the given buffer + */ + HD5packFstring(c_buf, _fcdtocp(name), c_bufsize - 1); + + *size_default = (size_t_f)c_size; + ret_value = 0; + if (c_buf) + HDfree(c_buf); + + return ret_value; } /****if* H5Rf/h5rget_obj_type_c @@ -359,22 +363,22 @@ h5rget_name_ptr_c (hid_t_f *loc_id, int_f *ref_type, void *ref, _fcd name, size_ * December 17, 2008 * * SOURCE -*/ + */ int_f -h5rget_obj_type_c (hid_t_f *loc_id, int_f *ref_type, void *ref, int_f *obj_type) +h5rget_obj_type_c(hid_t_f *loc_id, int_f *ref_type, void *ref, int_f *obj_type) /******/ { - int_f ret_value = -1; - H5O_type_t obj_type_c; + int_f ret_value = -1; + H5O_type_t obj_type_c; - /* - * Call H5Rget_obj_type function. - */ - if((H5Rget_obj_type2((hid_t)*loc_id, (H5R_type_t)*ref_type, ref, &obj_type_c)) < 0) - return ret_value; + /* + * Call H5Rget_obj_type function. + */ + if ((H5Rget_obj_type2((hid_t)*loc_id, (H5R_type_t)*ref_type, ref, &obj_type_c)) < 0) + return ret_value; - *obj_type = (int_f)obj_type_c; + *obj_type = (int_f)obj_type_c; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } diff --git a/fortran/src/H5Sf.c b/fortran/src/H5Sf.c index e3a5809..ebec0e6 100644 --- a/fortran/src/H5Sf.c +++ b/fortran/src/H5Sf.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5Eprivate.h" @@ -41,28 +41,28 @@ * HISTORY * * SOURCE -*/ + */ int_f -h5screate_simple_c ( int_f *rank, hsize_t_f *dims, hsize_t_f *maxdims, hid_t_f *space_id ) +h5screate_simple_c(int_f *rank, hsize_t_f *dims, hsize_t_f *maxdims, hid_t_f *space_id) /******/ { hsize_t c_dims[H5S_MAX_RANK]; hsize_t c_maxdims[H5S_MAX_RANK]; - hid_t c_space_id; - int i; - int_f ret_value = 0; + hid_t c_space_id; + int i; + int_f ret_value = 0; /* * Transpose dimension arrays because of C-FORTRAN storage order */ - for(i = 0; i < *rank ; i++) { - c_dims[i] = dims[*rank - i - 1]; - c_maxdims[i] = maxdims[*rank - i - 1]; + for (i = 0; i < *rank; i++) { + c_dims[i] = dims[*rank - i - 1]; + c_maxdims[i] = maxdims[*rank - i - 1]; } /* end for */ c_space_id = H5Screate_simple(*rank, c_dims, c_maxdims); - if(c_space_id < 0) + if (c_space_id < 0) HGOTO_DONE(FAIL) *space_id = (hid_t_f)c_space_id; @@ -86,18 +86,19 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5sclose_c ( hid_t_f *space_id ) +h5sclose_c(hid_t_f *space_id) /******/ { - int ret_value = 0; - hid_t c_space_id; + int ret_value = 0; + hid_t c_space_id; - c_space_id = (hid_t)*space_id; - if ( H5Sclose(c_space_id) < 0 ) ret_value = -1; - return ret_value; + c_space_id = (hid_t)*space_id; + if (H5Sclose(c_space_id) < 0) + ret_value = -1; + return ret_value; } /****if* H5Sf/h5screate_c @@ -117,21 +118,22 @@ h5sclose_c ( hid_t_f *space_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5screate_c ( int_f *classtype, hid_t_f *space_id ) +h5screate_c(int_f *classtype, hid_t_f *space_id) /******/ { - H5S_class_t c_classtype; - int ret_value = 0; - hid_t c_space_id; - c_classtype = (H5S_class_t) *classtype; - c_space_id = H5Screate(c_classtype); - - if ( c_space_id < 0 ) ret_value = -1; - *space_id = (hid_t_f) c_space_id; - return ret_value; + H5S_class_t c_classtype; + int ret_value = 0; + hid_t c_space_id; + c_classtype = (H5S_class_t)*classtype; + c_space_id = H5Screate(c_classtype); + + if (c_space_id < 0) + ret_value = -1; + *space_id = (hid_t_f)c_space_id; + return ret_value; } /****if* H5Sf/h5scopy_c @@ -151,22 +153,23 @@ h5screate_c ( int_f *classtype, hid_t_f *space_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5scopy_c( hid_t_f *space_id , hid_t_f *new_space_id) +h5scopy_c(hid_t_f *space_id, hid_t_f *new_space_id) /******/ { - int ret_value = 0; - hid_t c_new_space_id; - hid_t c_space_id; + int ret_value = 0; + hid_t c_new_space_id; + hid_t c_space_id; - c_space_id = (hid_t)*space_id; - c_new_space_id = H5Scopy(c_space_id); - if ( c_new_space_id < 0 ) ret_value = -1; + c_space_id = (hid_t)*space_id; + c_new_space_id = H5Scopy(c_space_id); + if (c_new_space_id < 0) + ret_value = -1; - *new_space_id = (hid_t_f)c_new_space_id; - return ret_value; + *new_space_id = (hid_t_f)c_new_space_id; + return ret_value; } /****if* H5Sf/h5sget_select_hyper_nblocks_c @@ -189,22 +192,23 @@ h5scopy_c( hid_t_f *space_id , hid_t_f *new_space_id) * HISTORY * * SOURCE -*/ + */ int_f -h5sget_select_hyper_nblocks_c( hid_t_f *space_id , hssize_t_f * num_blocks) +h5sget_select_hyper_nblocks_c(hid_t_f *space_id, hssize_t_f *num_blocks) /******/ { - int ret_value = 0; - hid_t c_space_id; - hssize_t c_num_blocks; + int ret_value = 0; + hid_t c_space_id; + hssize_t c_num_blocks; - c_space_id = (hid_t)*space_id; - c_num_blocks = H5Sget_select_hyper_nblocks(c_space_id); - if ( c_num_blocks < 0 ) ret_value = -1; + c_space_id = (hid_t)*space_id; + c_num_blocks = H5Sget_select_hyper_nblocks(c_space_id); + if (c_num_blocks < 0) + ret_value = -1; - *num_blocks = (hssize_t_f)c_num_blocks; - return ret_value; + *num_blocks = (hssize_t_f)c_num_blocks; + return ret_value; } /****if* H5Sf/h5sget_select_elem_npoints_c @@ -227,22 +231,23 @@ h5sget_select_hyper_nblocks_c( hid_t_f *space_id , hssize_t_f * num_blocks) * HISTORY * * SOURCE -*/ + */ int_f -h5sget_select_elem_npoints_c( hid_t_f *space_id , hssize_t_f * num_points) +h5sget_select_elem_npoints_c(hid_t_f *space_id, hssize_t_f *num_points) /******/ { - int ret_value = 0; - hid_t c_space_id; - hssize_t c_num_points; + int ret_value = 0; + hid_t c_space_id; + hssize_t c_num_points; - c_space_id = (hid_t)*space_id; - c_num_points = H5Sget_select_elem_npoints(c_space_id); - if ( c_num_points < 0 ) ret_value = -1; + c_space_id = (hid_t)*space_id; + c_num_points = H5Sget_select_elem_npoints(c_space_id); + if (c_num_points < 0) + ret_value = -1; - *num_points = (hssize_t_f)c_num_points; - return ret_value; + *num_points = (hssize_t_f)c_num_points; + return ret_value; } /****if* H5Sf/h5sget_select_hyper_blocklist_c @@ -273,54 +278,56 @@ h5sget_select_elem_npoints_c( hid_t_f *space_id , hssize_t_f * num_points) * Transpose dimension arrays because of C-FORTRAN storage order * M. Scot Breitenfeld * SOURCE -*/ + */ int_f -h5sget_select_hyper_blocklist_c( hid_t_f *space_id ,hsize_t_f *startblock, - hsize_t_f *num_blocks, hsize_t_f *buf) +h5sget_select_hyper_blocklist_c(hid_t_f *space_id, hsize_t_f *startblock, hsize_t_f *num_blocks, + hsize_t_f *buf) /******/ { - int ret_value = -1; - hid_t c_space_id; - hsize_t c_num_blocks; - - hsize_t i; - int j,k,m,n; - int rank; - hsize_t c_startblock, *c_buf; - - c_space_id = (hid_t)*space_id; - c_num_blocks = (hsize_t)*num_blocks; - - rank = H5Sget_simple_extent_ndims(c_space_id); - if (rank < 0 ) return ret_value; - c_startblock = (hsize_t)*startblock; - - c_buf = (hsize_t*)HDmalloc(sizeof(hsize_t)*(size_t)(c_num_blocks*2*(hsize_t)rank)); - if (!c_buf) return ret_value; - - ret_value = H5Sget_select_hyper_blocklist(c_space_id, c_startblock, - c_num_blocks, c_buf); - - /* - * Transpose dimension arrays because of C-FORTRAN storage order and add 1 - */ - n = 0; - m = 0; - for (i=0; i < c_num_blocks; i++) { - for (j=0; j < rank; j++) { - for (k=0; k < rank; k++) { - int t= (m + rank - k - 1); - buf[n] = (hsize_t_f)c_buf[t]+1; - n = n + 1; - } - m = m + rank; + int ret_value = -1; + hid_t c_space_id; + hsize_t c_num_blocks; + + hsize_t i; + int j, k, m, n; + int rank; + hsize_t c_startblock, *c_buf; + + c_space_id = (hid_t)*space_id; + c_num_blocks = (hsize_t)*num_blocks; + + rank = H5Sget_simple_extent_ndims(c_space_id); + if (rank < 0) + return ret_value; + c_startblock = (hsize_t)*startblock; + + c_buf = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)(c_num_blocks * 2 * (hsize_t)rank)); + if (!c_buf) + return ret_value; + + ret_value = H5Sget_select_hyper_blocklist(c_space_id, c_startblock, c_num_blocks, c_buf); + + /* + * Transpose dimension arrays because of C-FORTRAN storage order and add 1 + */ + n = 0; + m = 0; + for (i = 0; i < c_num_blocks; i++) { + for (j = 0; j < rank; j++) { + for (k = 0; k < rank; k++) { + int t = (m + rank - k - 1); + buf[n] = (hsize_t_f)c_buf[t] + 1; + n = n + 1; + } + m = m + rank; + } } - } - HDfree(c_buf); - if (ret_value >= 0 ) ret_value = 0; - return ret_value; + HDfree(c_buf); + if (ret_value >= 0) + ret_value = 0; + return ret_value; } /****if* H5Sf/h5sget_select_bounds_c @@ -346,29 +353,29 @@ h5sget_select_hyper_blocklist_c( hid_t_f *space_id ,hsize_t_f *startblock, * matrix notation. * M. Scot Breitenfeld * SOURCE -*/ + */ int_f -h5sget_select_bounds_c( hid_t_f *space_id , hsize_t_f * start, hsize_t_f * end) +h5sget_select_bounds_c(hid_t_f *space_id, hsize_t_f *start, hsize_t_f *end) /******/ { - hid_t c_space_id; + hid_t c_space_id; hsize_t c_start[H5S_MAX_RANK]; hsize_t c_end[H5S_MAX_RANK]; - int i, rank; - int_f ret_value = 0; + int i, rank; + int_f ret_value = 0; c_space_id = (hid_t)*space_id; - rank = H5Sget_simple_extent_ndims(c_space_id); - if(rank < 0 ) + rank = H5Sget_simple_extent_ndims(c_space_id); + if (rank < 0) HGOTO_DONE(FAIL) - if(H5Sget_select_bounds(c_space_id, c_start, c_end) < 0) + if (H5Sget_select_bounds(c_space_id, c_start, c_end) < 0) HGOTO_DONE(FAIL) - for(i = 0; i < rank; i++) { + for (i = 0; i < rank; i++) { start[i] = (hsize_t_f)(c_start[rank - i - 1] + 1); - end[i] = (hsize_t_f)(c_end[rank - i - 1] + 1); + end[i] = (hsize_t_f)(c_end[rank - i - 1] + 1); } /* end for */ done: @@ -401,50 +408,51 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5sget_select_elem_pointlist_c( hid_t_f *space_id ,hsize_t_f * startpoint, - hsize_t_f * numpoints, hsize_t_f * buf) +h5sget_select_elem_pointlist_c(hid_t_f *space_id, hsize_t_f *startpoint, hsize_t_f *numpoints, hsize_t_f *buf) /******/ { - int ret_value = -1; - hid_t c_space_id; - hsize_t c_num_points; - hsize_t c_startpoint,* c_buf; - hsize_t i, i1; - int rank; - int j,i2; - - c_space_id = (hid_t)*space_id; - c_num_points = (hsize_t)* numpoints; - - rank = H5Sget_simple_extent_ndims(c_space_id); - if (rank < 0 ) return ret_value; - - c_startpoint = (hsize_t)*startpoint; - c_buf = (hsize_t*)HDmalloc(sizeof(hsize_t)*(size_t)(c_num_points*(hsize_t)rank)); - if (!c_buf) return ret_value; - ret_value = H5Sget_select_elem_pointlist(c_space_id, c_startpoint, - c_num_points, c_buf); - - /* re-arrange the return buffer to account for Fortran ordering of 2D arrays */ - /* and add 1 to account for array's starting at one in Fortran */ - i2 = 0; - for( i = 0; i < c_num_points; i++) { - i1 = (hsize_t)rank*(i+1); - for(j = 0; j < rank; j++) { - buf[i2] = (hsize_t_f)(c_buf[i1-1]+1); - i2 = i2 + 1; - i1 = i1 - 1; + int ret_value = -1; + hid_t c_space_id; + hsize_t c_num_points; + hsize_t c_startpoint, *c_buf; + hsize_t i, i1; + int rank; + int j, i2; + + c_space_id = (hid_t)*space_id; + c_num_points = (hsize_t)*numpoints; + + rank = H5Sget_simple_extent_ndims(c_space_id); + if (rank < 0) + return ret_value; + + c_startpoint = (hsize_t)*startpoint; + c_buf = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)(c_num_points * (hsize_t)rank)); + if (!c_buf) + return ret_value; + ret_value = H5Sget_select_elem_pointlist(c_space_id, c_startpoint, c_num_points, c_buf); + + /* re-arrange the return buffer to account for Fortran ordering of 2D arrays */ + /* and add 1 to account for array's starting at one in Fortran */ + i2 = 0; + for (i = 0; i < c_num_points; i++) { + i1 = (hsize_t)rank * (i + 1); + for (j = 0; j < rank; j++) { + buf[i2] = (hsize_t_f)(c_buf[i1 - 1] + 1); + i2 = i2 + 1; + i1 = i1 - 1; + } } - } - if (ret_value >= 0 ) ret_value = 0; + if (ret_value >= 0) + ret_value = 0; - HDfree(c_buf); + HDfree(c_buf); - return ret_value; + return ret_value; } /****if* H5Sf/h5sselect_all_c @@ -462,18 +470,19 @@ h5sget_select_elem_pointlist_c( hid_t_f *space_id ,hsize_t_f * startpoint, * HISTORY * * SOURCE -*/ + */ int_f -h5sselect_all_c ( hid_t_f *space_id ) +h5sselect_all_c(hid_t_f *space_id) /******/ { - int ret_value = 0; - hid_t c_space_id; + int ret_value = 0; + hid_t c_space_id; - c_space_id = (hid_t)*space_id; - if ( H5Sselect_all(c_space_id) < 0 ) ret_value = -1; - return ret_value; + c_space_id = (hid_t)*space_id; + if (H5Sselect_all(c_space_id) < 0) + ret_value = -1; + return ret_value; } /****if* H5Sf/h5sselect_none_c @@ -491,18 +500,19 @@ h5sselect_all_c ( hid_t_f *space_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5sselect_none_c ( hid_t_f *space_id ) +h5sselect_none_c(hid_t_f *space_id) /******/ { - int ret_value = 0; - hid_t c_space_id; + int ret_value = 0; + hid_t c_space_id; - c_space_id = (hid_t)*space_id; - if ( H5Sselect_none(c_space_id) < 0 ) ret_value = -1; - return ret_value; + c_space_id = (hid_t)*space_id; + if (H5Sselect_none(c_space_id) < 0) + ret_value = -1; + return ret_value; } /****if* H5Sf/h5sselect_valid_c @@ -524,21 +534,22 @@ h5sselect_none_c ( hid_t_f *space_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5sselect_valid_c ( hid_t_f *space_id , int_f *flag ) +h5sselect_valid_c(hid_t_f *space_id, int_f *flag) /******/ { - int ret_value = 0; - hid_t c_space_id; - htri_t status; - - c_space_id = (hid_t)*space_id; - status = H5Sselect_valid(c_space_id); - *flag = (int_f)status; - if ( status < 0 ) ret_value = -1; - return ret_value; + int ret_value = 0; + hid_t c_space_id; + htri_t status; + + c_space_id = (hid_t)*space_id; + status = H5Sselect_valid(c_space_id); + *flag = (int_f)status; + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Sf/h5sget_simple_extent_npoints_c @@ -559,21 +570,22 @@ h5sselect_valid_c ( hid_t_f *space_id , int_f *flag ) * HISTORY * * SOURCE -*/ + */ int_f -h5sget_simple_extent_npoints_c ( hid_t_f *space_id , hsize_t_f *npoints ) +h5sget_simple_extent_npoints_c(hid_t_f *space_id, hsize_t_f *npoints) /******/ { - int ret_value = 0; - hid_t c_space_id; - hssize_t c_npoints; - - c_space_id = (hid_t)*space_id; - c_npoints = H5Sget_simple_extent_npoints(c_space_id); - if ( c_npoints == 0 ) ret_value = -1; - *npoints = (hsize_t_f)c_npoints; - return ret_value; + int ret_value = 0; + hid_t c_space_id; + hssize_t c_npoints; + + c_space_id = (hid_t)*space_id; + c_npoints = H5Sget_simple_extent_npoints(c_space_id); + if (c_npoints == 0) + ret_value = -1; + *npoints = (hsize_t_f)c_npoints; + return ret_value; } /****if* H5Sf/h5sget_select_npoints_c @@ -594,21 +606,22 @@ h5sget_simple_extent_npoints_c ( hid_t_f *space_id , hsize_t_f *npoints ) * HISTORY * * SOURCE -*/ + */ int_f -h5sget_select_npoints_c ( hid_t_f *space_id , hssize_t_f *npoints ) +h5sget_select_npoints_c(hid_t_f *space_id, hssize_t_f *npoints) /******/ { - int ret_value = 0; - hssize_t c_npoints; - hid_t c_space_id; - - c_space_id = (hid_t)*space_id; - c_npoints = H5Sget_select_npoints(c_space_id); - if ( c_npoints < 0 ) ret_value = -1; - *npoints = (hssize_t_f)c_npoints; - return ret_value; + int ret_value = 0; + hssize_t c_npoints; + hid_t c_space_id; + + c_space_id = (hid_t)*space_id; + c_npoints = H5Sget_select_npoints(c_space_id); + if (c_npoints < 0) + ret_value = -1; + *npoints = (hssize_t_f)c_npoints; + return ret_value; } /****if* H5Sf/h5sget_simple_extent_ndims_c @@ -629,21 +642,22 @@ h5sget_select_npoints_c ( hid_t_f *space_id , hssize_t_f *npoints ) * HISTORY * * SOURCE -*/ + */ int_f -h5sget_simple_extent_ndims_c ( hid_t_f *space_id , int_f *ndims ) +h5sget_simple_extent_ndims_c(hid_t_f *space_id, int_f *ndims) /******/ { - int ret_value = 0; - hid_t c_space_id; - int c_ndims; - - c_space_id = (hid_t)*space_id; - c_ndims = H5Sget_simple_extent_ndims(c_space_id); - if ( c_ndims < 0 ) ret_value = -1; - *ndims = (int_f)c_ndims; - return ret_value; + int ret_value = 0; + hid_t c_space_id; + int c_ndims; + + c_space_id = (hid_t)*space_id; + c_ndims = H5Sget_simple_extent_ndims(c_space_id); + if (c_ndims < 0) + ret_value = -1; + *ndims = (int_f)c_ndims; + return ret_value; } /****if* H5Sf/h5sget_simple_extent_type_c @@ -665,26 +679,27 @@ h5sget_simple_extent_ndims_c ( hid_t_f *space_id , int_f *ndims ) * HISTORY * * SOURCE -*/ + */ int_f -h5sget_simple_extent_type_c ( hid_t_f *space_id , int_f *classtype) +h5sget_simple_extent_type_c(hid_t_f *space_id, int_f *classtype) /******/ { - int ret_value = 0; - hid_t c_space_id; - H5S_class_t c_classtype; - - c_space_id = (hid_t)*space_id; - c_classtype = H5Sget_simple_extent_type(c_space_id); - if ( c_classtype < 0 ) ret_value = -1; - *classtype = c_classtype; -/* - if (c_classtype == H5S_SCALAR) *classtype = H5S_SCALAR_F; - if (c_classtype == H5S_SIMPLE) *classtype = H5S_SIMPLE_F; - if (c_classtype == H5S_NULL) *classtype = H5S_NULL_F; -*/ - return ret_value; + int ret_value = 0; + hid_t c_space_id; + H5S_class_t c_classtype; + + c_space_id = (hid_t)*space_id; + c_classtype = H5Sget_simple_extent_type(c_space_id); + if (c_classtype < 0) + ret_value = -1; + *classtype = c_classtype; + /* + if (c_classtype == H5S_SCALAR) *classtype = H5S_SCALAR_F; + if (c_classtype == H5S_SIMPLE) *classtype = H5S_SIMPLE_F; + if (c_classtype == H5S_NULL) *classtype = H5S_NULL_F; + */ + return ret_value; } /****if* H5Sf/h5soffset_simple_c @@ -704,30 +719,30 @@ h5sget_simple_extent_type_c ( hid_t_f *space_id , int_f *classtype) * HISTORY * * SOURCE -*/ + */ int_f -h5soffset_simple_c ( hid_t_f *space_id , hssize_t_f *offset) +h5soffset_simple_c(hid_t_f *space_id, hssize_t_f *offset) /******/ { - hid_t c_space_id; - int rank; + hid_t c_space_id; + int rank; hssize_t c_offset[H5S_MAX_RANK]; - int i; - int_f ret_value = 0; + int i; + int_f ret_value = 0; c_space_id = (hid_t)*space_id; - rank = H5Sget_simple_extent_ndims(c_space_id); - if(rank < 0) + rank = H5Sget_simple_extent_ndims(c_space_id); + if (rank < 0) HGOTO_DONE(FAIL) /* * Reverse dimensions due to C-FORTRAN storage order. */ - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) c_offset[i] = offset[rank - i - 1]; - if(H5Soffset_simple(c_space_id, c_offset) < 0) + if (H5Soffset_simple(c_space_id, c_offset) < 0) HGOTO_DONE(FAIL) done: @@ -753,33 +768,32 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5sset_extent_simple_c ( hid_t_f *space_id , int_f *rank, hsize_t_f *current_size, hsize_t_f *maximum_size) +h5sset_extent_simple_c(hid_t_f *space_id, int_f *rank, hsize_t_f *current_size, hsize_t_f *maximum_size) /******/ { hsize_t c_current_size[H5S_MAX_RANK]; hsize_t c_maximum_size[H5S_MAX_RANK]; - int i; - int_f ret_value = 0; + int i; + int_f ret_value = 0; /* * Reverse dimensions due to C-FORTRAN storage order. */ - for(i = 0; i < *rank; i++) { + for (i = 0; i < *rank; i++) { c_current_size[i] = (hsize_t)current_size[*rank - i - 1]; c_maximum_size[i] = (hsize_t)maximum_size[*rank - i - 1]; } /* end for */ - if(H5Sset_extent_simple((hid_t)*space_id, (int)*rank, c_current_size, c_maximum_size) < 0) + if (H5Sset_extent_simple((hid_t)*space_id, (int)*rank, c_current_size, c_maximum_size) < 0) HGOTO_DONE(FAIL) done: return ret_value; } - /****if* H5Sf/h5sget_simple_extent_dims_c * NAME * h5sget_simple_extent_dims_c @@ -799,32 +813,32 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5sget_simple_extent_dims_c ( hid_t_f *space_id , hsize_t_f *dims, hsize_t_f *maxdims) +h5sget_simple_extent_dims_c(hid_t_f *space_id, hsize_t_f *dims, hsize_t_f *maxdims) /******/ { - hid_t c_space_id; + hid_t c_space_id; hsize_t c_dims[H5S_MAX_RANK]; hsize_t c_maxdims[H5S_MAX_RANK]; - int rank; - int i; - int_f ret_value; + int rank; + int i; + int_f ret_value; c_space_id = (hid_t)*space_id; - rank = H5Sget_simple_extent_ndims(c_space_id); - if(rank < 0) + rank = H5Sget_simple_extent_ndims(c_space_id); + if (rank < 0) HGOTO_DONE(FAIL) - if(H5Sget_simple_extent_dims(c_space_id, c_dims, c_maxdims) < 0) + if (H5Sget_simple_extent_dims(c_space_id, c_dims, c_maxdims) < 0) HGOTO_DONE(FAIL) /* * Reverse dimensions due to C-FORTRAN storage order. */ - for(i = 0; i < rank; i++) { - dims[rank - i - 1] = (hsize_t_f)c_dims[i]; + for (i = 0; i < rank; i++) { + dims[rank - i - 1] = (hsize_t_f)c_dims[i]; maxdims[rank - i - 1] = (hsize_t_f)c_maxdims[i]; } /* end for */ @@ -853,23 +867,23 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5sis_simple_c ( hid_t_f *space_id , int_f *flag ) +h5sis_simple_c(hid_t_f *space_id, int_f *flag) /******/ { - int ret_value = 0; - hid_t c_space_id; - htri_t status; - - c_space_id = (hid_t)*space_id; - status = H5Sis_simple(c_space_id); - *flag = (int_f)status; - if ( status < 0 ) ret_value = -1; - return ret_value; -} + int ret_value = 0; + hid_t c_space_id; + htri_t status; + c_space_id = (hid_t)*space_id; + status = H5Sis_simple(c_space_id); + *flag = (int_f)status; + if (status < 0) + ret_value = -1; + return ret_value; +} /****if* H5Sf/h5sextent_copy_c * NAME @@ -887,21 +901,22 @@ h5sis_simple_c ( hid_t_f *space_id , int_f *flag ) * HISTORY * * SOURCE -*/ + */ int_f -h5sextent_copy_c ( hid_t_f *dest_space_id , hid_t_f *source_space_id) +h5sextent_copy_c(hid_t_f *dest_space_id, hid_t_f *source_space_id) /******/ { - int ret_value = 0; - hid_t c_dest_space_id, c_source_space_id; - herr_t status; - - c_dest_space_id = (hid_t)*dest_space_id; - c_source_space_id = (hid_t)*source_space_id; - status = H5Sextent_copy(c_dest_space_id, c_source_space_id); - if ( status < 0 ) ret_value = -1; - return ret_value; + int ret_value = 0; + hid_t c_dest_space_id, c_source_space_id; + herr_t status; + + c_dest_space_id = (hid_t)*dest_space_id; + c_source_space_id = (hid_t)*source_space_id; + status = H5Sextent_copy(c_dest_space_id, c_source_space_id); + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Sf/h5sset_extent_none_c @@ -919,20 +934,21 @@ h5sextent_copy_c ( hid_t_f *dest_space_id , hid_t_f *source_space_id) * HISTORY * * SOURCE -*/ + */ int_f -h5sset_extent_none_c ( hid_t_f *space_id ) +h5sset_extent_none_c(hid_t_f *space_id) /******/ { - int ret_value = 0; - hid_t c_space_id; - herr_t status; - - c_space_id = (hid_t)*space_id; - status = H5Sset_extent_none(c_space_id); - if ( status < 0 ) ret_value = -1; - return ret_value; + int ret_value = 0; + hid_t c_space_id; + herr_t status; + + c_space_id = (hid_t)*space_id; + status = H5Sset_extent_none(c_space_id); + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Sf/h5sselect_hyperslab_c @@ -957,37 +973,38 @@ h5sset_extent_none_c ( hid_t_f *space_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5sselect_hyperslab_c ( hid_t_f *space_id , int_f *op, hsize_t_f *start, hsize_t_f *count, hsize_t_f *stride, hsize_t_f *block) +h5sselect_hyperslab_c(hid_t_f *space_id, int_f *op, hsize_t_f *start, hsize_t_f *count, hsize_t_f *stride, + hsize_t_f *block) /******/ { hsize_t c_start[H5S_MAX_RANK]; hsize_t c_count[H5S_MAX_RANK]; hsize_t c_stride[H5S_MAX_RANK]; hsize_t c_block[H5S_MAX_RANK]; - int rank; - int i; - int_f ret_value = 0; + int rank; + int i; + int_f ret_value = 0; rank = H5Sget_simple_extent_ndims((hid_t)*space_id); - if(rank < 0 ) + if (rank < 0) HGOTO_DONE(FAIL) /* * Reverse dimensions due to C-FORTRAN storage order. */ - for(i = 0; i < rank; i++) { + for (i = 0; i < rank; i++) { int t = (rank - i) - 1; - c_start[i] = (hsize_t)start[t]; - c_count[i] = (hsize_t)count[t]; + c_start[i] = (hsize_t)start[t]; + c_count[i] = (hsize_t)count[t]; c_stride[i] = (hsize_t)stride[t]; - c_block[i] = (hsize_t)block[t]; + c_block[i] = (hsize_t)block[t]; } /* end for */ - if(H5Sselect_hyperslab((hid_t)*space_id, (H5S_seloper_t)*op, c_start, c_stride, c_count, c_block) < 0) + if (H5Sselect_hyperslab((hid_t)*space_id, (H5S_seloper_t)*op, c_start, c_stride, c_count, c_block) < 0) HGOTO_DONE(FAIL) done: @@ -1016,64 +1033,74 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5scombine_hyperslab_c ( hid_t_f *space_id , int_f *op, hsize_t_f *start, hsize_t_f *count, hsize_t_f *stride, hsize_t_f *block, hid_t_f *hyper_id) +h5scombine_hyperslab_c(hid_t_f *space_id, int_f *op, hsize_t_f *start, hsize_t_f *count, hsize_t_f *stride, + hsize_t_f *block, hid_t_f *hyper_id) /******/ { - int ret_value = -1; - hid_t c_space_id; - hid_t c_hyper_id; - hsize_t *c_start = NULL; - hsize_t *c_count = NULL; - hsize_t *c_stride = NULL; - hsize_t *c_block = NULL; - - H5S_seloper_t c_op; - int rank; - int i; - - rank = H5Sget_simple_extent_ndims(*space_id); - if (rank < 0 ) return ret_value; - c_start = (hsize_t *)HDmalloc(sizeof(hsize_t)*(unsigned)rank); - if (c_start == NULL) goto DONE; - - c_count = (hsize_t *)HDmalloc(sizeof(hsize_t)*(unsigned)rank); - if (c_count == NULL) goto DONE; - - c_stride = (hsize_t *)HDmalloc(sizeof(hsize_t)*(unsigned)rank); - if (c_stride == NULL) goto DONE; - - c_block = (hsize_t *)HDmalloc(sizeof(hsize_t)*(unsigned)rank); - if (c_block == NULL) goto DONE; - - - /* - * Reverse dimensions due to C-FORTRAN storage order. - */ - - for (i=0; i < rank; i++) { - int t= (rank - i) - 1; - c_start[i] = (hsize_t)start[t]; - c_count[i] = (hsize_t)count[t]; - c_stride[i] = (hsize_t)stride[t]; - c_block[i] = (hsize_t)block[t]; - } - - c_op = (H5S_seloper_t)*op; - - c_space_id = (hid_t)*space_id; - c_hyper_id = H5Scombine_hyperslab(c_space_id, c_op, c_start, c_stride, c_count, c_block); - if ( c_hyper_id < 0 ) goto DONE; - *hyper_id = (hid_t_f)c_hyper_id; - ret_value = 0; + int ret_value = -1; + hid_t c_space_id; + hid_t c_hyper_id; + hsize_t *c_start = NULL; + hsize_t *c_count = NULL; + hsize_t *c_stride = NULL; + hsize_t *c_block = NULL; + + H5S_seloper_t c_op; + int rank; + int i; + + rank = H5Sget_simple_extent_ndims(*space_id); + if (rank < 0) + return ret_value; + c_start = (hsize_t *)HDmalloc(sizeof(hsize_t) * (unsigned)rank); + if (c_start == NULL) + goto DONE; + + c_count = (hsize_t *)HDmalloc(sizeof(hsize_t) * (unsigned)rank); + if (c_count == NULL) + goto DONE; + + c_stride = (hsize_t *)HDmalloc(sizeof(hsize_t) * (unsigned)rank); + if (c_stride == NULL) + goto DONE; + + c_block = (hsize_t *)HDmalloc(sizeof(hsize_t) * (unsigned)rank); + if (c_block == NULL) + goto DONE; + + /* + * Reverse dimensions due to C-FORTRAN storage order. + */ + + for (i = 0; i < rank; i++) { + int t = (rank - i) - 1; + c_start[i] = (hsize_t)start[t]; + c_count[i] = (hsize_t)count[t]; + c_stride[i] = (hsize_t)stride[t]; + c_block[i] = (hsize_t)block[t]; + } + + c_op = (H5S_seloper_t)*op; + + c_space_id = (hid_t)*space_id; + c_hyper_id = H5Scombine_hyperslab(c_space_id, c_op, c_start, c_stride, c_count, c_block); + if (c_hyper_id < 0) + goto DONE; + *hyper_id = (hid_t_f)c_hyper_id; + ret_value = 0; DONE: - if(c_start != NULL) HDfree(c_start); - if(c_count != NULL) HDfree(c_count); - if(c_stride!= NULL) HDfree(c_stride); - if(c_block != NULL) HDfree(c_block); - return ret_value; + if (c_start != NULL) + HDfree(c_start); + if (c_count != NULL) + HDfree(c_count); + if (c_stride != NULL) + HDfree(c_stride); + if (c_block != NULL) + HDfree(c_block); + return ret_value; } /****if* H5Sf/h5scombine_select_c * NAME @@ -1094,27 +1121,28 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5scombine_select_c ( hid_t_f *space1_id , int_f *op, hid_t_f *space2_id, hid_t_f *ds_id) +h5scombine_select_c(hid_t_f *space1_id, int_f *op, hid_t_f *space2_id, hid_t_f *ds_id) /******/ { - int ret_value = -1; - hid_t c_space1_id; - hid_t c_space2_id; - hid_t c_ds_id; - H5S_seloper_t c_op; - - c_op = (H5S_seloper_t)*op; - - c_space1_id = (hid_t)*space1_id; - c_space2_id = (hid_t)*space2_id; - c_ds_id = H5Scombine_select(c_space1_id, c_op, c_space2_id); - if ( c_ds_id < 0 ) return ret_value; - *ds_id = (hid_t_f)c_ds_id; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_space1_id; + hid_t c_space2_id; + hid_t c_ds_id; + H5S_seloper_t c_op; + + c_op = (H5S_seloper_t)*op; + + c_space1_id = (hid_t)*space1_id; + c_space2_id = (hid_t)*space2_id; + c_ds_id = H5Scombine_select(c_space1_id, c_op, c_space2_id); + if (c_ds_id < 0) + return ret_value; + *ds_id = (hid_t_f)c_ds_id; + ret_value = 0; + return ret_value; } /****if* H5Sf/h5smodify_select_c * NAME @@ -1133,24 +1161,25 @@ h5scombine_select_c ( hid_t_f *space1_id , int_f *op, hid_t_f *space2_id, hid_t_ * HISTORY * * SOURCE -*/ + */ int_f -h5smodify_select_c ( hid_t_f *space1_id , int_f *op, hid_t_f *space2_id) +h5smodify_select_c(hid_t_f *space1_id, int_f *op, hid_t_f *space2_id) /******/ { - int ret_value = -1; - hid_t c_space1_id; - hid_t c_space2_id; - H5S_seloper_t c_op; - - c_op = (H5S_seloper_t)*op; - - c_space1_id = (hid_t)*space1_id; - c_space2_id = (hid_t)*space2_id; - if( H5Smodify_select(c_space1_id, c_op, c_space2_id)< 0) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_space1_id; + hid_t c_space2_id; + H5S_seloper_t c_op; + + c_op = (H5S_seloper_t)*op; + + c_space1_id = (hid_t)*space1_id; + c_space2_id = (hid_t)*space2_id; + if (H5Smodify_select(c_space1_id, c_op, c_space2_id) < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Sf/h5sget_select_type_c @@ -1170,23 +1199,23 @@ h5smodify_select_c ( hid_t_f *space1_id , int_f *op, hid_t_f *space2_id) * HISTORY * * SOURCE -*/ + */ int_f -h5sget_select_type_c ( hid_t_f *space_id , int_f *type) +h5sget_select_type_c(hid_t_f *space_id, int_f *type) /******/ { - int ret_value = -1; - hid_t c_space_id; - H5S_sel_type c_type; - - c_space_id = (hid_t)*space_id; - c_type = H5Sget_select_type(c_space_id); - if(c_type < 0) return ret_value; - *type = (int_f)c_type; - ret_value = 0; - return ret_value; -} + int ret_value = -1; + hid_t c_space_id; + H5S_sel_type c_type; + c_space_id = (hid_t)*space_id; + c_type = H5Sget_select_type(c_space_id); + if (c_type < 0) + return ret_value; + *type = (int_f)c_type; + ret_value = 0; + return ret_value; +} /****if* H5Sf/h5sselect_elements_c * NAME @@ -1208,40 +1237,42 @@ h5sget_select_type_c ( hid_t_f *space_id , int_f *type) * HISTORY * * SOURCE -*/ + */ int_f -h5sselect_elements_c ( hid_t_f *space_id , int_f *op, size_t_f *nelements, hsize_t_f *coord) +h5sselect_elements_c(hid_t_f *space_id, int_f *op, size_t_f *nelements, hsize_t_f *coord) /******/ { - int ret_value = -1; - hid_t c_space_id; - H5S_seloper_t c_op; - herr_t status; - int rank; - size_t i; - int j; - hsize_t *c_coord; - size_t c_nelements; - - c_op = (H5S_seloper_t)*op; - - c_space_id = *space_id; - rank = H5Sget_simple_extent_ndims(c_space_id); - - c_coord = (hsize_t *)HDmalloc(sizeof(hsize_t)*(size_t)rank*((size_t)*nelements)); - if(!c_coord) return ret_value; - for (i=0; i< (size_t)*nelements; i++) { - for (j = 0; j < rank; j++) { - c_coord[(size_t)j+i*(size_t)rank] = (hsize_t)coord[(size_t)j + i*(size_t)rank]; - } - } - - c_nelements = *nelements; - status = H5Sselect_elements(c_space_id, c_op, c_nelements, c_coord); - if ( status >= 0 ) ret_value = 0; - HDfree(c_coord); - return ret_value; + int ret_value = -1; + hid_t c_space_id; + H5S_seloper_t c_op; + herr_t status; + int rank; + size_t i; + int j; + hsize_t * c_coord; + size_t c_nelements; + + c_op = (H5S_seloper_t)*op; + + c_space_id = *space_id; + rank = H5Sget_simple_extent_ndims(c_space_id); + + c_coord = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)rank * ((size_t)*nelements)); + if (!c_coord) + return ret_value; + for (i = 0; i < (size_t)*nelements; i++) { + for (j = 0; j < rank; j++) { + c_coord[(size_t)j + i * (size_t)rank] = (hsize_t)coord[(size_t)j + i * (size_t)rank]; + } + } + + c_nelements = *nelements; + status = H5Sselect_elements(c_space_id, c_op, c_nelements, c_coord); + if (status >= 0) + ret_value = 0; + HDfree(c_coord); + return ret_value; } /****if* H5Sf/h5sdecode_c @@ -1261,30 +1292,30 @@ h5sselect_elements_c ( hid_t_f *space_id , int_f *op, size_t_f *nelements, hsiz * HISTORY * * SOURCE -*/ + */ int_f -h5sdecode_c ( _fcd buf, hid_t_f *obj_id ) +h5sdecode_c(_fcd buf, hid_t_f *obj_id) /******/ { - int ret_value = -1; - unsigned char *c_buf = NULL; /* Buffer to hold C string */ - hid_t c_obj_id; + int ret_value = -1; + unsigned char *c_buf = NULL; /* Buffer to hold C string */ + hid_t c_obj_id; - /* - * Call H5Sdecode function. - */ + /* + * Call H5Sdecode function. + */ - c_buf = (unsigned char*)buf; + c_buf = (unsigned char *)buf; - c_obj_id = H5Sdecode(c_buf); - if(c_obj_id < 0) - return ret_value; + c_obj_id = H5Sdecode(c_buf); + if (c_obj_id < 0) + return ret_value; - *obj_id = (hid_t_f)c_obj_id; - ret_value = 0; + *obj_id = (hid_t_f)c_obj_id; + ret_value = 0; - return ret_value; + return ret_value; } /****if* H5Sf/h5sencode_c @@ -1304,55 +1335,56 @@ h5sdecode_c ( _fcd buf, hid_t_f *obj_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc, hid_t_f *fapl_id ) +h5sencode_c(_fcd buf, hid_t_f *obj_id, size_t_f *nalloc, hid_t_f *fapl_id) /******/ { - int ret_value = -1; - unsigned char *c_buf = NULL; /* Buffer to hold C string */ - size_t c_size; + int ret_value = -1; + unsigned char *c_buf = NULL; /* Buffer to hold C string */ + size_t c_size; - /* return just the size of the allocated buffer; - * equivalent to C routine for which 'name' is set equal to NULL - */ + /* return just the size of the allocated buffer; + * equivalent to C routine for which 'name' is set equal to NULL + */ - if (*nalloc == 0) { + if (*nalloc == 0) { - if(H5Sencode2((hid_t)*obj_id, c_buf, &c_size, (hid_t)*fapl_id) < 0) - return ret_value; + if (H5Sencode2((hid_t)*obj_id, c_buf, &c_size, (hid_t)*fapl_id) < 0) + return ret_value; - *nalloc = (size_t_f)c_size; + *nalloc = (size_t_f)c_size; - ret_value = 0; - return ret_value; - } + ret_value = 0; + return ret_value; + } - c_size = (size_t)*nalloc; - /* - * Allocate buffer - */ - if(NULL == (c_buf = (unsigned char *)HDmalloc(c_size))) - return ret_value; - /* - * Call H5Sencode function. - */ - if(H5Sencode2((hid_t)*obj_id, c_buf, &c_size, (hid_t)*fapl_id) < 0){ - return ret_value; - } + c_size = (size_t)*nalloc; + /* + * Allocate buffer + */ + if (NULL == (c_buf = (unsigned char *)HDmalloc(c_size))) + return ret_value; + /* + * Call H5Sencode function. + */ + if (H5Sencode2((hid_t)*obj_id, c_buf, &c_size, (hid_t)*fapl_id) < 0) { + return ret_value; + } - /* copy the C buffer to the FORTRAN buffer. - * Can not use HD5packFstring because we don't want to - * eliminate the NUL terminator or pad remaining space - * with blanks. - */ + /* copy the C buffer to the FORTRAN buffer. + * Can not use HD5packFstring because we don't want to + * eliminate the NUL terminator or pad remaining space + * with blanks. + */ - HDmemcpy(_fcdtocp(buf),(char *)c_buf,c_size); + HDmemcpy(_fcdtocp(buf), (char *)c_buf, c_size); - ret_value = 0; - if(c_buf) HDfree(c_buf); - return ret_value; + ret_value = 0; + if (c_buf) + HDfree(c_buf); + return ret_value; } /****if* H5Sf/h5sextent_equal_c @@ -1373,18 +1405,17 @@ h5sencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc, hid_t_f *fapl_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5sextent_equal_c ( hid_t_f * space1_id, hid_t_f *space2_id, hid_t_f *c_equal) +h5sextent_equal_c(hid_t_f *space1_id, hid_t_f *space2_id, hid_t_f *c_equal) /******/ { - int ret_value = -1; + int ret_value = -1; - if( (*c_equal = (hid_t_f)H5Sextent_equal((hid_t)*space1_id, (hid_t)*space2_id)) < 0) - return ret_value; + if ((*c_equal = (hid_t_f)H5Sextent_equal((hid_t)*space1_id, (hid_t)*space2_id)) < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } - diff --git a/fortran/src/H5Tf.c b/fortran/src/H5Tf.c index c40abae..1b9cbd1 100644 --- a/fortran/src/H5Tf.c +++ b/fortran/src/H5Tf.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" @@ -41,32 +41,32 @@ * HISTORY * * SOURCE -*/ + */ int_f -h5topen_c (hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_t_f *tapl_id) +h5topen_c(hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_t_f *tapl_id) /******/ { char *c_name = NULL; hid_t c_type_id; - int ret_value = -1; + int ret_value = -1; /* * Convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto done; /* * Call H5Topen2 function. */ - if((c_type_id = H5Topen2((hid_t)*loc_id, c_name, (hid_t)*tapl_id)) < 0) + if ((c_type_id = H5Topen2((hid_t)*loc_id, c_name, (hid_t)*tapl_id)) < 0) goto done; *type_id = (hid_t_f)c_type_id; ret_value = 0; done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; @@ -95,27 +95,28 @@ done: * - Added passing optional parameters for version 1.8 * M. Scot Breitenfeld * SOURCE -*/ + */ int_f -h5tcommit_c(hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, - hid_t_f *lcpl_id, hid_t_f *tcpl_id, hid_t_f *tapl_id) +h5tcommit_c(hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_t_f *lcpl_id, hid_t_f *tcpl_id, + hid_t_f *tapl_id) /******/ { - char *c_name = NULL; - int ret_value = -1; + char *c_name = NULL; + int ret_value = -1; /* Convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) goto done; /* Call H5Tcommit2 function */ - if(H5Tcommit2((hid_t)*loc_id, c_name, (hid_t)*type_id, (hid_t)*lcpl_id, (hid_t)*tcpl_id, (hid_t)*tapl_id) < 0) + if (H5Tcommit2((hid_t)*loc_id, c_name, (hid_t)*type_id, (hid_t)*lcpl_id, (hid_t)*tcpl_id, + (hid_t)*tapl_id) < 0) goto done; ret_value = 0; done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } @@ -135,18 +136,19 @@ done: * HISTORY * * SOURCE -*/ + */ int_f -h5tclose_c ( hid_t_f *type_id ) +h5tclose_c(hid_t_f *type_id) /******/ { - int ret_value = 0; - hid_t c_type_id; + int ret_value = 0; + hid_t c_type_id; - c_type_id = *type_id; - if ( H5Tclose(c_type_id) < 0 ) ret_value = -1; - return ret_value; + c_type_id = *type_id; + if (H5Tclose(c_type_id) < 0) + ret_value = -1; + return ret_value; } /****if* H5Tf/h5tcopy_c @@ -166,21 +168,22 @@ h5tclose_c ( hid_t_f *type_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5tcopy_c ( hid_t_f *type_id , hid_t_f *new_type_id) +h5tcopy_c(hid_t_f *type_id, hid_t_f *new_type_id) /******/ { - int ret_value = 0; - hid_t c_type_id; - hid_t c_new_type_id; - - c_type_id = *type_id; - c_new_type_id = H5Tcopy(c_type_id); - if ( c_new_type_id < 0 ) ret_value = -1; - *new_type_id = (hid_t_f)c_new_type_id; - return ret_value; + int ret_value = 0; + hid_t c_type_id; + hid_t c_new_type_id; + + c_type_id = *type_id; + c_new_type_id = H5Tcopy(c_type_id); + if (c_new_type_id < 0) + ret_value = -1; + *new_type_id = (hid_t_f)c_new_type_id; + return ret_value; } /****if* H5Tf/h5tequal_c @@ -201,23 +204,24 @@ h5tcopy_c ( hid_t_f *type_id , hid_t_f *new_type_id) * HISTORY * * SOURCE -*/ + */ int_f -h5tequal_c ( hid_t_f *type1_id , hid_t_f *type2_id, int_f *c_flag) +h5tequal_c(hid_t_f *type1_id, hid_t_f *type2_id, int_f *c_flag) /******/ { - int ret_value = -1; - hid_t c_type1_id, c_type2_id; - htri_t status; - - c_type1_id = *type1_id; - c_type2_id = *type2_id; - status = H5Tequal(c_type1_id, c_type2_id); - if ( status < 0 ) return ret_value; - *c_flag = (int_f)status; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type1_id, c_type2_id; + htri_t status; + + c_type1_id = *type1_id; + c_type2_id = *type2_id; + status = H5Tequal(c_type1_id, c_type2_id); + if (status < 0) + return ret_value; + *c_flag = (int_f)status; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_class_c @@ -249,37 +253,37 @@ h5tequal_c ( hid_t_f *type1_id , hid_t_f *type2_id, int_f *c_flag) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_class_c ( hid_t_f *type_id , int_f *classtype) +h5tget_class_c(hid_t_f *type_id, int_f *classtype) /******/ { - int ret_value = 0; - hid_t c_type_id; - H5T_class_t c_classtype; - - c_type_id = *type_id; - c_classtype = H5Tget_class(c_type_id); - if (c_classtype == H5T_NO_CLASS ) { - /* *classtype = H5T_NO_CLASS_F; */ - *classtype = (int_f)H5T_NO_CLASS; - ret_value = -1; - return ret_value; - } - *classtype = c_classtype; -/* - if (c_classtype == H5T_INTEGER) *classtype = H5T_INTEGER_F; - if (c_classtype == H5T_FLOAT) *classtype = H5T_FLOAT_F; - if (c_classtype == H5T_TIME) *classtype = H5T_TIME_F; - if (c_classtype == H5T_STRING) *classtype = H5T_STRING_F; - if (c_classtype == H5T_BITFIELD) *classtype = H5T_BITFIELD_F; - if (c_classtype == H5T_OPAQUE) *classtype = H5T_OPAQUE_F; - if (c_classtype == H5T_COMPOUND) *classtype = H5T_COMPOUND_F; - if (c_classtype == H5T_REFERENCE) *classtype = H5T_REFERENCE_F; - if (c_classtype == H5T_ENUM) *classtype = H5T_ENUM_F; -*/ - return ret_value; + int ret_value = 0; + hid_t c_type_id; + H5T_class_t c_classtype; + + c_type_id = *type_id; + c_classtype = H5Tget_class(c_type_id); + if (c_classtype == H5T_NO_CLASS) { + /* *classtype = H5T_NO_CLASS_F; */ + *classtype = (int_f)H5T_NO_CLASS; + ret_value = -1; + return ret_value; + } + *classtype = c_classtype; + /* + if (c_classtype == H5T_INTEGER) *classtype = H5T_INTEGER_F; + if (c_classtype == H5T_FLOAT) *classtype = H5T_FLOAT_F; + if (c_classtype == H5T_TIME) *classtype = H5T_TIME_F; + if (c_classtype == H5T_STRING) *classtype = H5T_STRING_F; + if (c_classtype == H5T_BITFIELD) *classtype = H5T_BITFIELD_F; + if (c_classtype == H5T_OPAQUE) *classtype = H5T_OPAQUE_F; + if (c_classtype == H5T_COMPOUND) *classtype = H5T_COMPOUND_F; + if (c_classtype == H5T_REFERENCE) *classtype = H5T_REFERENCE_F; + if (c_classtype == H5T_ENUM) *classtype = H5T_ENUM_F; + */ + return ret_value; } /****if* H5Tf/h5tget_order_c @@ -302,29 +306,29 @@ h5tget_class_c ( hid_t_f *type_id , int_f *classtype) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_order_c ( hid_t_f *type_id , int_f *order) +h5tget_order_c(hid_t_f *type_id, int_f *order) /******/ { - int ret_value = -1; - hid_t c_type_id; - H5T_order_t c_order; - - c_type_id = *type_id; - c_order = H5Tget_order(c_type_id); - if ( c_order < 0 ) return ret_value; - *order = (int_f)c_order; - ret_value = 0; -/* - if ( c_order == H5T_ORDER_LE) *order = H5T_ORDER_LE_F; - if ( c_order == H5T_ORDER_BE) *order = H5T_ORDER_BE_F; - if ( c_order == H5T_ORDER_VAX) *order = H5T_ORDER_VAX_F; -*/ - return ret_value; -} + int ret_value = -1; + hid_t c_type_id; + H5T_order_t c_order; + c_type_id = *type_id; + c_order = H5Tget_order(c_type_id); + if (c_order < 0) + return ret_value; + *order = (int_f)c_order; + ret_value = 0; + /* + if ( c_order == H5T_ORDER_LE) *order = H5T_ORDER_LE_F; + if ( c_order == H5T_ORDER_BE) *order = H5T_ORDER_BE_F; + if ( c_order == H5T_ORDER_VAX) *order = H5T_ORDER_VAX_F; + */ + return ret_value; +} /****if* H5Tf/h5tset_order_c * NAME @@ -345,26 +349,27 @@ h5tget_order_c ( hid_t_f *type_id , int_f *order) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_order_c ( hid_t_f *type_id , int_f *order) +h5tset_order_c(hid_t_f *type_id, int_f *order) /******/ { - int ret_value = 0; - hid_t c_type_id; - H5T_order_t c_order; - herr_t status; - c_order = (H5T_order_t)*order; -/* - if ( *order == H5T_ORDER_LE_F) c_order = H5T_ORDER_LE; - if ( *order == H5T_ORDER_BE_F) c_order = H5T_ORDER_BE; - if ( *order == H5T_ORDER_VAX_F) c_order = H5T_ORDER_VAX; -*/ - c_type_id = *type_id; - status = H5Tset_order(c_type_id, c_order); - if ( status < 0 ) ret_value = -1; - return ret_value; + int ret_value = 0; + hid_t c_type_id; + H5T_order_t c_order; + herr_t status; + c_order = (H5T_order_t)*order; + /* + if ( *order == H5T_ORDER_LE_F) c_order = H5T_ORDER_LE; + if ( *order == H5T_ORDER_BE_F) c_order = H5T_ORDER_BE; + if ( *order == H5T_ORDER_VAX_F) c_order = H5T_ORDER_VAX; + */ + c_type_id = *type_id; + status = H5Tset_order(c_type_id, c_order); + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Tf/h5tget_size_c @@ -384,22 +389,23 @@ h5tset_order_c ( hid_t_f *type_id , int_f *order) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_size_c ( hid_t_f *type_id , size_t_f *size) +h5tget_size_c(hid_t_f *type_id, size_t_f *size) /******/ { - int ret_value = -1; - hid_t c_type_id; - size_t c_size; - - c_type_id = *type_id; - c_size = H5Tget_size(c_type_id); - if ( c_size == 0 ) return ret_value; - *size = (size_t_f)c_size ; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + size_t c_size; + + c_type_id = *type_id; + c_size = H5Tget_size(c_type_id); + if (c_size == 0) + return ret_value; + *size = (size_t_f)c_size; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_size_c @@ -419,23 +425,24 @@ h5tget_size_c ( hid_t_f *type_id , size_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_size_c ( hid_t_f *type_id , size_t_f *size) +h5tset_size_c(hid_t_f *type_id, size_t_f *size) /******/ { - int ret_value = -1; - hid_t c_type_id; - size_t c_size; - herr_t status; - - c_size = (size_t)*size; - c_type_id = *type_id; - status = H5Tset_size(c_type_id, c_size); - if ( status < 0 ) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + size_t c_size; + herr_t status; + + c_size = (size_t)*size; + c_type_id = *type_id; + status = H5Tset_size(c_type_id, c_size); + if (status < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_precision_c @@ -455,22 +462,23 @@ h5tset_size_c ( hid_t_f *type_id , size_t_f *size) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_precision_c ( hid_t_f *type_id , size_t_f *precision) +h5tget_precision_c(hid_t_f *type_id, size_t_f *precision) /******/ { - int ret_value = -1; - hid_t c_type_id; - size_t c_precision; - - c_type_id = *type_id; - c_precision = H5Tget_precision(c_type_id); - if ( c_precision == 0 ) return ret_value; - *precision = (size_t_f)c_precision ; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + size_t c_precision; + + c_type_id = *type_id; + c_precision = H5Tget_precision(c_type_id); + if (c_precision == 0) + return ret_value; + *precision = (size_t_f)c_precision; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_precision_c @@ -489,23 +497,24 @@ h5tget_precision_c ( hid_t_f *type_id , size_t_f *precision) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_precision_c ( hid_t_f *type_id , size_t_f *precision) +h5tset_precision_c(hid_t_f *type_id, size_t_f *precision) /******/ { - int ret_value = -1; - hid_t c_type_id; - size_t c_precision; - herr_t status; - - c_type_id = *type_id; - c_precision = (size_t)*precision; - status = H5Tset_precision(c_type_id, c_precision); - if ( status < 0 ) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + size_t c_precision; + herr_t status; + + c_type_id = *type_id; + c_precision = (size_t)*precision; + status = H5Tset_precision(c_type_id, c_precision); + if (status < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_offset_c @@ -526,23 +535,24 @@ h5tset_precision_c ( hid_t_f *type_id , size_t_f *precision) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_offset_c ( hid_t_f *type_id , size_t_f *offset) +h5tget_offset_c(hid_t_f *type_id, size_t_f *offset) /******/ { - int ret_value = -1; - hid_t c_type_id; - int c_offset; + int ret_value = -1; + hid_t c_type_id; + int c_offset; - c_type_id = *type_id; - c_offset = H5Tget_offset(c_type_id); - if ( c_offset < 0 ) return ret_value; + c_type_id = *type_id; + c_offset = H5Tget_offset(c_type_id); + if (c_offset < 0) + return ret_value; - *offset = (size_t_f)c_offset ; - ret_value = 0; - return ret_value; + *offset = (size_t_f)c_offset; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_offset_c @@ -562,23 +572,24 @@ h5tget_offset_c ( hid_t_f *type_id , size_t_f *offset) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_offset_c ( hid_t_f *type_id , size_t_f *offset) +h5tset_offset_c(hid_t_f *type_id, size_t_f *offset) /******/ { - int ret_value = -1; - hid_t c_type_id; - size_t c_offset; - herr_t status; - - c_offset = (size_t)*offset; - c_type_id = *type_id; - status = H5Tset_offset(c_type_id, c_offset); - if ( status < 0 ) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + size_t c_offset; + herr_t status; + + c_offset = (size_t)*offset; + c_type_id = *type_id; + status = H5Tset_offset(c_type_id, c_offset); + if (status < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_pad_c @@ -601,25 +612,26 @@ h5tset_offset_c ( hid_t_f *type_id , size_t_f *offset) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_pad_c ( hid_t_f *type_id , int_f * lsbpad, int_f * msbpad) +h5tget_pad_c(hid_t_f *type_id, int_f *lsbpad, int_f *msbpad) /******/ { - int ret_value = -1; - hid_t c_type_id; - herr_t status; - H5T_pad_t c_lsb, c_msb; - - c_type_id = *type_id; - status = H5Tget_pad(c_type_id, &c_lsb, &c_msb); - if ( status < 0 ) return ret_value; - - *lsbpad = (int_f) c_lsb; - *msbpad = (int_f) c_msb; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + herr_t status; + H5T_pad_t c_lsb, c_msb; + + c_type_id = *type_id; + status = H5Tget_pad(c_type_id, &c_lsb, &c_msb); + if (status < 0) + return ret_value; + + *lsbpad = (int_f)c_lsb; + *msbpad = (int_f)c_msb; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_pad_c @@ -643,24 +655,25 @@ h5tget_pad_c ( hid_t_f *type_id , int_f * lsbpad, int_f * msbpad) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_pad_c ( hid_t_f *type_id, int_f * lsbpad, int_f* msbpad ) +h5tset_pad_c(hid_t_f *type_id, int_f *lsbpad, int_f *msbpad) /******/ { - int ret_value = -1; - hid_t c_type_id; - herr_t status; - H5T_pad_t c_lsb, c_msb; - - c_type_id = *type_id; - c_lsb = (H5T_pad_t)*lsbpad; - c_msb = (H5T_pad_t)*msbpad; - status = H5Tset_pad(c_type_id, c_lsb, c_msb); - if ( status < 0 ) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + herr_t status; + H5T_pad_t c_lsb, c_msb; + + c_type_id = *type_id; + c_lsb = (H5T_pad_t)*lsbpad; + c_msb = (H5T_pad_t)*msbpad; + status = H5Tset_pad(c_type_id, c_lsb, c_msb); + if (status < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_sign_c @@ -680,22 +693,23 @@ h5tset_pad_c ( hid_t_f *type_id, int_f * lsbpad, int_f* msbpad ) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_sign_c ( hid_t_f *type_id , int_f *sign) +h5tget_sign_c(hid_t_f *type_id, int_f *sign) /******/ { - int ret_value = -1; - hid_t c_type_id; - H5T_sign_t c_sign; - - c_type_id = *type_id; - c_sign = H5Tget_sign(c_type_id); - if ( c_sign == -1 ) return ret_value; - *sign = (int_f)c_sign ; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + H5T_sign_t c_sign; + + c_type_id = *type_id; + c_sign = H5Tget_sign(c_type_id); + if (c_sign == -1) + return ret_value; + *sign = (int_f)c_sign; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_sign_c @@ -714,24 +728,25 @@ h5tget_sign_c ( hid_t_f *type_id , int_f *sign) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_sign_c ( hid_t_f *type_id , int_f* sign) +h5tset_sign_c(hid_t_f *type_id, int_f *sign) /******/ { - int ret_value = -1; - hid_t c_type_id; - H5T_sign_t c_sign; - herr_t status; - - c_type_id = *type_id; - c_sign = (H5T_sign_t)*sign; - status = H5Tset_sign(c_type_id, c_sign); - if ( status < 0 ) return ret_value; - - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + H5T_sign_t c_sign; + herr_t status; + + c_type_id = *type_id; + c_sign = (H5T_sign_t)*sign; + status = H5Tset_sign(c_type_id, c_sign); + if (status < 0) + return ret_value; + + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_fields_c @@ -755,27 +770,29 @@ h5tset_sign_c ( hid_t_f *type_id , int_f* sign) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_fields_c ( hid_t_f *type_id , size_t_f *spos, size_t_f *epos, size_t_f* esize, size_t_f* mpos, size_t_f* msize) +h5tget_fields_c(hid_t_f *type_id, size_t_f *spos, size_t_f *epos, size_t_f *esize, size_t_f *mpos, + size_t_f *msize) /******/ { - int ret_value = -1; - hid_t c_type_id; - herr_t status; - size_t c_spos, c_epos, c_esize, c_mpos, c_msize; - - c_type_id = *type_id; - status = H5Tget_fields(c_type_id, &c_spos, &c_epos, &c_esize, &c_mpos, &c_msize); - if ( status < 0 ) return ret_value; - *spos = (size_t_f) c_spos; - *epos = (size_t_f) c_epos; - *esize = (size_t_f) c_esize; - *mpos = (size_t_f) c_mpos; - *msize = (size_t_f) c_msize; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + herr_t status; + size_t c_spos, c_epos, c_esize, c_mpos, c_msize; + + c_type_id = *type_id; + status = H5Tget_fields(c_type_id, &c_spos, &c_epos, &c_esize, &c_mpos, &c_msize); + if (status < 0) + return ret_value; + *spos = (size_t_f)c_spos; + *epos = (size_t_f)c_epos; + *esize = (size_t_f)c_esize; + *mpos = (size_t_f)c_mpos; + *msize = (size_t_f)c_msize; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_fields_c @@ -798,28 +815,30 @@ h5tget_fields_c ( hid_t_f *type_id , size_t_f *spos, size_t_f *epos, size_t_f* e * HISTORY * * SOURCE -*/ + */ int_f -h5tset_fields_c ( hid_t_f *type_id, size_t_f *spos, size_t_f *epos, size_t_f* esize, size_t_f* mpos, size_t_f* msize) +h5tset_fields_c(hid_t_f *type_id, size_t_f *spos, size_t_f *epos, size_t_f *esize, size_t_f *mpos, + size_t_f *msize) /******/ { - int ret_value = -1; - hid_t c_type_id; - herr_t status; - size_t c_spos, c_epos, c_esize, c_mpos, c_msize; - - c_spos = (size_t)*spos; - c_epos = (size_t)*epos; - c_esize = (size_t)*esize; - c_mpos = (size_t)*mpos; - c_msize = (size_t)*msize; - c_type_id = *type_id; - status = H5Tset_fields(c_type_id, c_spos, c_epos, c_esize, c_mpos, c_msize); - if ( status < 0 ) return ret_value; - - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + herr_t status; + size_t c_spos, c_epos, c_esize, c_mpos, c_msize; + + c_spos = (size_t)*spos; + c_epos = (size_t)*epos; + c_esize = (size_t)*esize; + c_mpos = (size_t)*mpos; + c_msize = (size_t)*msize; + c_type_id = *type_id; + status = H5Tset_fields(c_type_id, c_spos, c_epos, c_esize, c_mpos, c_msize); + if (status < 0) + return ret_value; + + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_ebias_c @@ -840,23 +859,24 @@ h5tset_fields_c ( hid_t_f *type_id, size_t_f *spos, size_t_f *epos, size_t_f* es * HISTORY * * SOURCE -*/ + */ int_f -h5tget_ebias_c ( hid_t_f *type_id , size_t_f *ebias) +h5tget_ebias_c(hid_t_f *type_id, size_t_f *ebias) /******/ { - int ret_value = -1; - hid_t c_type_id; - size_t c_ebias; + int ret_value = -1; + hid_t c_type_id; + size_t c_ebias; - c_type_id = *type_id; - c_ebias = H5Tget_ebias(c_type_id); - if ( c_ebias == 0 ) return ret_value; + c_type_id = *type_id; + c_ebias = H5Tget_ebias(c_type_id); + if (c_ebias == 0) + return ret_value; - *ebias = (size_t_f)c_ebias; - ret_value = 0; - return ret_value; + *ebias = (size_t_f)c_ebias; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_ebias_c @@ -876,24 +896,25 @@ h5tget_ebias_c ( hid_t_f *type_id , size_t_f *ebias) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_ebias_c ( hid_t_f *type_id , size_t_f *ebias) +h5tset_ebias_c(hid_t_f *type_id, size_t_f *ebias) /******/ { - int ret_value = -1; - hid_t c_type_id; - size_t c_ebias; - herr_t status; - - c_type_id = *type_id; - c_ebias = (size_t)*ebias; - status = H5Tset_ebias(c_type_id, c_ebias); - if ( status < 0 ) return ret_value; - - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + size_t c_ebias; + herr_t status; + + c_type_id = *type_id; + c_ebias = (size_t)*ebias; + status = H5Tset_ebias(c_type_id, c_ebias); + if (status < 0) + return ret_value; + + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_norm_c @@ -914,23 +935,24 @@ h5tset_ebias_c ( hid_t_f *type_id , size_t_f *ebias) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_norm_c ( hid_t_f *type_id , int_f *norm) +h5tget_norm_c(hid_t_f *type_id, int_f *norm) /******/ { - int ret_value = -1; - hid_t c_type_id; - H5T_norm_t c_norm; + int ret_value = -1; + hid_t c_type_id; + H5T_norm_t c_norm; - c_type_id = *type_id; - c_norm = H5Tget_norm(c_type_id); - if ( c_norm == H5T_NORM_ERROR ) return ret_value; + c_type_id = *type_id; + c_norm = H5Tget_norm(c_type_id); + if (c_norm == H5T_NORM_ERROR) + return ret_value; - *norm = (int_f)c_norm; - ret_value = 0; - return ret_value; + *norm = (int_f)c_norm; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_norm_c @@ -950,24 +972,25 @@ h5tget_norm_c ( hid_t_f *type_id , int_f *norm) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_norm_c ( hid_t_f *type_id , int_f *norm) +h5tset_norm_c(hid_t_f *type_id, int_f *norm) /******/ { - int ret_value = -1; - hid_t c_type_id; - H5T_norm_t c_norm; - herr_t status; - - c_type_id = *type_id; - c_norm = (H5T_norm_t)*norm; - status = H5Tset_norm(c_type_id, c_norm); - if ( status < 0 ) return ret_value; - - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + H5T_norm_t c_norm; + herr_t status; + + c_type_id = *type_id; + c_norm = (H5T_norm_t)*norm; + status = H5Tset_norm(c_type_id, c_norm); + if (status < 0) + return ret_value; + + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_inpad_c @@ -990,23 +1013,24 @@ h5tset_norm_c ( hid_t_f *type_id , int_f *norm) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_inpad_c ( hid_t_f *type_id , int_f * padtype) +h5tget_inpad_c(hid_t_f *type_id, int_f *padtype) /******/ { - int ret_value = -1; - hid_t c_type_id; - H5T_pad_t c_padtype; + int ret_value = -1; + hid_t c_type_id; + H5T_pad_t c_padtype; - c_type_id = *type_id; - c_padtype = H5Tget_inpad(c_type_id); - if ( c_padtype == H5T_PAD_ERROR ) return ret_value; + c_type_id = *type_id; + c_padtype = H5Tget_inpad(c_type_id); + if (c_padtype == H5T_PAD_ERROR) + return ret_value; - *padtype = (int_f) c_padtype; - ret_value = 0; - return ret_value; + *padtype = (int_f)c_padtype; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_inpad_c @@ -1030,24 +1054,25 @@ h5tget_inpad_c ( hid_t_f *type_id , int_f * padtype) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_inpad_c ( hid_t_f *type_id, int_f * padtype) +h5tset_inpad_c(hid_t_f *type_id, int_f *padtype) /******/ { - int ret_value = -1; - hid_t c_type_id; - herr_t status; - H5T_pad_t c_padtype; - - c_type_id = *type_id; - c_padtype = (H5T_pad_t)*padtype; - status = H5Tset_inpad(c_type_id, c_padtype); - if ( status < 0 ) return ret_value; - - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + herr_t status; + H5T_pad_t c_padtype; + + c_type_id = *type_id; + c_padtype = (H5T_pad_t)*padtype; + status = H5Tset_inpad(c_type_id, c_padtype); + if (status < 0) + return ret_value; + + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_cset_c @@ -1069,23 +1094,24 @@ h5tset_inpad_c ( hid_t_f *type_id, int_f * padtype) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_cset_c ( hid_t_f *type_id , int_f * cset) +h5tget_cset_c(hid_t_f *type_id, int_f *cset) /******/ { - int ret_value = -1; - hid_t c_type_id; - H5T_cset_t c_cset; + int ret_value = -1; + hid_t c_type_id; + H5T_cset_t c_cset; - c_type_id = *type_id; - c_cset = H5Tget_cset(c_type_id); - if ( c_cset == H5T_CSET_ERROR ) return ret_value; + c_type_id = *type_id; + c_cset = H5Tget_cset(c_type_id); + if (c_cset == H5T_CSET_ERROR) + return ret_value; - *cset = (int_f) c_cset; - ret_value = 0; - return ret_value; + *cset = (int_f)c_cset; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_cset_c @@ -1108,24 +1134,25 @@ h5tget_cset_c ( hid_t_f *type_id , int_f * cset) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_cset_c ( hid_t_f *type_id, int_f * cset) +h5tset_cset_c(hid_t_f *type_id, int_f *cset) /******/ { - int ret_value = -1; - hid_t c_type_id; - herr_t status; - H5T_cset_t c_cset; - - c_type_id = *type_id; - c_cset = (H5T_cset_t)*cset; - status = H5Tset_cset(c_type_id, c_cset); - - if ( status < 0 ) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + herr_t status; + H5T_cset_t c_cset; + + c_type_id = *type_id; + c_cset = (H5T_cset_t)*cset; + status = H5Tset_cset(c_type_id, c_cset); + + if (status < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_strpad_c @@ -1146,22 +1173,23 @@ h5tset_cset_c ( hid_t_f *type_id, int_f * cset) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_strpad_c ( hid_t_f *type_id , int_f * strpad) +h5tget_strpad_c(hid_t_f *type_id, int_f *strpad) /******/ { - int ret_value = -1; - hid_t c_type_id; - H5T_str_t c_strpad; + int ret_value = -1; + hid_t c_type_id; + H5T_str_t c_strpad; - c_type_id = *type_id; - c_strpad = H5Tget_strpad(c_type_id); - if ( c_strpad == H5T_STR_ERROR ) return ret_value; + c_type_id = *type_id; + c_strpad = H5Tget_strpad(c_type_id); + if (c_strpad == H5T_STR_ERROR) + return ret_value; - *strpad = (int_f) c_strpad; - ret_value = 0; - return ret_value; + *strpad = (int_f)c_strpad; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_strpad_c @@ -1184,24 +1212,25 @@ h5tget_strpad_c ( hid_t_f *type_id , int_f * strpad) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_strpad_c ( hid_t_f *type_id, int_f * strpad) +h5tset_strpad_c(hid_t_f *type_id, int_f *strpad) /******/ { - int ret_value = -1; - hid_t c_type_id; - herr_t status; - H5T_str_t c_strpad; - - c_type_id = *type_id; - c_strpad = (H5T_str_t)*strpad; - status = H5Tset_strpad(c_type_id, c_strpad); - if ( status < 0 ) return ret_value; - - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + herr_t status; + H5T_str_t c_strpad; + + c_type_id = *type_id; + c_strpad = (H5T_str_t)*strpad; + status = H5Tset_strpad(c_type_id, c_strpad); + if (status < 0) + return ret_value; + + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_nmembers_c @@ -1222,21 +1251,22 @@ h5tset_strpad_c ( hid_t_f *type_id, int_f * strpad) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_nmembers_c ( hid_t_f *type_id , int_f * num_members) +h5tget_nmembers_c(hid_t_f *type_id, int_f *num_members) /******/ { - int ret_value = -1; - hid_t c_type_id; + int ret_value = -1; + hid_t c_type_id; - c_type_id = *type_id; - *num_members = (int_f)H5Tget_nmembers(c_type_id); - if (*num_members < 0 ) return ret_value; + c_type_id = *type_id; + *num_members = (int_f)H5Tget_nmembers(c_type_id); + if (*num_members < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_member_name_c @@ -1258,27 +1288,28 @@ h5tget_nmembers_c ( hid_t_f *type_id , int_f * num_members) * Elena Pourmal * Added namelen parameter to return length of the name to Fortran user * SOURCE -*/ + */ int_f -h5tget_member_name_c ( hid_t_f *type_id ,int_f* idx, _fcd member_name, int_f *namelen) +h5tget_member_name_c(hid_t_f *type_id, int_f *idx, _fcd member_name, int_f *namelen) /******/ { - int ret_value = -1; - hid_t c_type_id; - unsigned c_index; - char *c_name; - - c_type_id = *type_id; - c_index = (unsigned)*idx; - c_name = H5Tget_member_name(c_type_id, c_index); - if (c_name == NULL ) return ret_value; - - HD5packFstring(c_name, _fcdtocp(member_name), strlen(c_name)); - *namelen = (int_f)strlen(c_name); - H5free_memory(c_name); - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + unsigned c_index; + char * c_name; + + c_type_id = *type_id; + c_index = (unsigned)*idx; + c_name = H5Tget_member_name(c_type_id, c_index); + if (c_name == NULL) + return ret_value; + + HD5packFstring(c_name, _fcdtocp(member_name), strlen(c_name)); + *namelen = (int_f)strlen(c_name); + H5free_memory(c_name); + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_member_index_c * NAME @@ -1300,37 +1331,38 @@ h5tget_member_name_c ( hid_t_f *type_id ,int_f* idx, _fcd member_name, int_f *na * HISTORY * * SOURCE -*/ + */ int_f -h5tget_member_index_c (hid_t_f *type_id, _fcd name, int_f *namelen, int_f *idx) +h5tget_member_index_c(hid_t_f *type_id, _fcd name, int_f *namelen, int_f *idx) /******/ { - int ret_value = -1; - char *c_name; - hid_t c_type_id; - int c_index; - - /* - * Convert FORTRAN name to C name - */ - c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return ret_value; - - /* - * Call H5Tget_member_index function. - */ - c_type_id = (hid_t)*type_id; - c_index = H5Tget_member_index(c_type_id, c_name); - - if (c_index < 0) goto DONE; - *idx = (int_f)c_index; + int ret_value = -1; + char *c_name; + hid_t c_type_id; + int c_index; + + /* + * Convert FORTRAN name to C name + */ + c_name = (char *)HD5f2cstring(name, (size_t)*namelen); + if (c_name == NULL) + return ret_value; + + /* + * Call H5Tget_member_index function. + */ + c_type_id = (hid_t)*type_id; + c_index = H5Tget_member_index(c_type_id, c_name); + + if (c_index < 0) + goto DONE; + *idx = (int_f)c_index; DONE: - HDfree(c_name); - ret_value = 0; - return ret_value; + HDfree(c_name); + ret_value = 0; + return ret_value; } - /****if* H5Tf/h5tget_member_offset_c * NAME * h5tget_member_offset_c @@ -1352,19 +1384,19 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5tget_member_offset_c ( hid_t_f *type_id ,int_f* member_no, size_t_f * offset) +h5tget_member_offset_c(hid_t_f *type_id, int_f *member_no, size_t_f *offset) /******/ { - int ret_value = -1; - size_t c_offset; + int ret_value = -1; + size_t c_offset; - c_offset = H5Tget_member_offset((hid_t)*type_id, (unsigned)*member_no); - *offset = (size_t_f)c_offset; - ret_value = 0; - return ret_value; + c_offset = H5Tget_member_offset((hid_t)*type_id, (unsigned)*member_no); + *offset = (size_t_f)c_offset; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_array_dims_c @@ -1385,23 +1417,23 @@ h5tget_member_offset_c ( hid_t_f *type_id ,int_f* member_no, size_t_f * offset) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_array_dims_c ( hid_t_f *type_id , hsize_t_f * dims) +h5tget_array_dims_c(hid_t_f *type_id, hsize_t_f *dims) /******/ { hsize_t c_dims[H5S_MAX_RANK]; - int rank, i; - int ret_value = -1; + int rank, i; + int ret_value = -1; - if((rank = H5Tget_array_ndims((hid_t)*type_id)) < 0) + if ((rank = H5Tget_array_ndims((hid_t)*type_id)) < 0) goto DONE; - if(H5Tget_array_dims2((hid_t)*type_id, c_dims) < 0) + if (H5Tget_array_dims2((hid_t)*type_id, c_dims) < 0) goto DONE; - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) dims[(rank - i) - 1] = (hsize_t_f)c_dims[i]; ret_value = 0; @@ -1428,23 +1460,24 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5tget_array_ndims_c ( hid_t_f *type_id , int_f * ndims) +h5tget_array_ndims_c(hid_t_f *type_id, int_f *ndims) /******/ { - int ret_value = -1; - hid_t c_type_id; - int c_ndims; + int ret_value = -1; + hid_t c_type_id; + int c_ndims; - c_type_id = (hid_t)*type_id; - c_ndims = H5Tget_array_ndims(c_type_id); - if (c_ndims < 0) return ret_value; + c_type_id = (hid_t)*type_id; + c_ndims = H5Tget_array_ndims(c_type_id); + if (c_ndims < 0) + return ret_value; - *ndims = (int_f)c_ndims; - ret_value = 0; - return ret_value; + *ndims = (int_f)c_ndims; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_super_c @@ -1465,26 +1498,26 @@ h5tget_array_ndims_c ( hid_t_f *type_id , int_f * ndims) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_super_c ( hid_t_f *type_id , hid_t_f *base_type_id) +h5tget_super_c(hid_t_f *type_id, hid_t_f *base_type_id) /******/ { - int ret_value = -1; - hid_t c_type_id; - hid_t c_base_type_id; + int ret_value = -1; + hid_t c_type_id; + hid_t c_base_type_id; - c_type_id = (hid_t)*type_id; - c_base_type_id = H5Tget_super(c_type_id); - if (c_base_type_id < 0) return ret_value; + c_type_id = (hid_t)*type_id; + c_base_type_id = H5Tget_super(c_type_id); + if (c_base_type_id < 0) + return ret_value; - *base_type_id = (hid_t_f)c_base_type_id; - ret_value = 0; - return ret_value; + *base_type_id = (hid_t_f)c_base_type_id; + ret_value = 0; + return ret_value; } - /****if* H5Tf/h5tget_member_type_c * NAME * h5tget_member_type_c @@ -1504,22 +1537,22 @@ h5tget_super_c ( hid_t_f *type_id , hid_t_f *base_type_id) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_member_type_c ( hid_t_f *type_id ,int_f* field_idx, hid_t_f * datatype) +h5tget_member_type_c(hid_t_f *type_id, int_f *field_idx, hid_t_f *datatype) /******/ { - int ret_value = -1; + int ret_value = -1; - *datatype = (hid_t_f)H5Tget_member_type((hid_t)*type_id, (unsigned)*field_idx); - if(*datatype < 0) return ret_value; + *datatype = (hid_t_f)H5Tget_member_type((hid_t)*type_id, (unsigned)*field_idx); + if (*datatype < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } - /****if* H5Tf/h5tcreate_c * NAME * h5tcreate_c @@ -1536,24 +1569,25 @@ h5tget_member_type_c ( hid_t_f *type_id ,int_f* field_idx, hid_t_f * datatype) * HISTORY * * SOURCE -*/ + */ int_f h5tcreate_c(int_f *cls, size_t_f *size, hid_t_f *type_id) /******/ { - int ret_value = -1; - H5T_class_t c_class; - size_t c_size; + int ret_value = -1; + H5T_class_t c_class; + size_t c_size; - c_size =(size_t) *size; - c_class = (H5T_class_t) *cls; + c_size = (size_t)*size; + c_class = (H5T_class_t)*cls; - *type_id = (hid_t_f)H5Tcreate(c_class, c_size); - if(*type_id < 0) return ret_value; + *type_id = (hid_t_f)H5Tcreate(c_class, c_size); + if (*type_id < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tinsert_c @@ -1575,28 +1609,29 @@ h5tcreate_c(int_f *cls, size_t_f *size, hid_t_f *type_id) * HISTORY * * SOURCE -*/ + */ int_f -h5tinsert_c(hid_t_f *type_id, _fcd name, int_f* namelen, size_t_f *offset, hid_t_f * field_id) +h5tinsert_c(hid_t_f *type_id, _fcd name, int_f *namelen, size_t_f *offset, hid_t_f *field_id) /******/ { - int ret_value = -1; - char* c_name; - herr_t error; + int ret_value = -1; + char * c_name; + herr_t error; - c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return ret_value; + c_name = (char *)HD5f2cstring(name, (size_t)*namelen); + if (c_name == NULL) + return ret_value; - error = H5Tinsert((hid_t)*type_id, c_name, (size_t)*offset, (hid_t)*field_id); + error = H5Tinsert((hid_t)*type_id, c_name, (size_t)*offset, (hid_t)*field_id); - HDfree(c_name); - if(error < 0) return ret_value; - ret_value = 0; - return ret_value; + HDfree(c_name); + if (error < 0) + return ret_value; + ret_value = 0; + return ret_value; } - /****if* H5Tf/h5tpack_c * NAME * h5tpack_c @@ -1614,22 +1649,23 @@ h5tinsert_c(hid_t_f *type_id, _fcd name, int_f* namelen, size_t_f *offset, hid_t * HISTORY * * SOURCE -*/ + */ int_f -h5tpack_c(hid_t_f * type_id) +h5tpack_c(hid_t_f *type_id) /******/ { - int ret_value = -1; - hid_t c_type_id; - herr_t status; + int ret_value = -1; + hid_t c_type_id; + herr_t status; - c_type_id = *type_id; - status = H5Tpack(c_type_id); - if (status < 0) return ret_value; + c_type_id = *type_id; + status = H5Tpack(c_type_id); + if (status < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tarray_create_c @@ -1650,34 +1686,32 @@ h5tpack_c(hid_t_f * type_id) * HISTORY * * SOURCE -*/ + */ int_f -h5tarray_create_c(hid_t_f * base_id, int_f *rank, hsize_t_f* dims, hid_t_f* type_id) +h5tarray_create_c(hid_t_f *base_id, int_f *rank, hsize_t_f *dims, hid_t_f *type_id) /******/ { - hsize_t c_dims[H5S_MAX_RANK]; - hid_t c_type_id; - unsigned u; /* Local index variable */ - int ret_value = -1; - + hsize_t c_dims[H5S_MAX_RANK]; + hid_t c_type_id; + unsigned u; /* Local index variable */ + int ret_value = -1; /* * Transpose dimension arrays because of C-FORTRAN storage order */ - for(u = 0; u < (unsigned)*rank ; u++) - c_dims[u] = (hsize_t)dims[((unsigned)*rank - u) - 1]; + for (u = 0; u < (unsigned)*rank; u++) + c_dims[u] = (hsize_t)dims[((unsigned)*rank - u) - 1]; - if((c_type_id = H5Tarray_create2((hid_t)*base_id, (unsigned)*rank, c_dims)) < 0) + if ((c_type_id = H5Tarray_create2((hid_t)*base_id, (unsigned)*rank, c_dims)) < 0) goto DONE; - *type_id = (hid_t_f)c_type_id; + *type_id = (hid_t_f)c_type_id; ret_value = 0; DONE: return ret_value; } - /****if* H5Tf/h5tenum_create_c * NAME * h5tenum_create_c @@ -1696,20 +1730,21 @@ DONE: * HISTORY * * SOURCE -*/ + */ int_f -h5tenum_create_c ( hid_t_f *parent_id , hid_t_f *new_type_id) +h5tenum_create_c(hid_t_f *parent_id, hid_t_f *new_type_id) /******/ { - int ret_value = 0; - hid_t c_new_type_id; + int ret_value = 0; + hid_t c_new_type_id; - c_new_type_id = H5Tenum_create((hid_t)*parent_id); - if ( c_new_type_id < 0 ) ret_value = -1; + c_new_type_id = H5Tenum_create((hid_t)*parent_id); + if (c_new_type_id < 0) + ret_value = -1; - *new_type_id = (hid_t_f)c_new_type_id; - return ret_value; + *new_type_id = (hid_t_f)c_new_type_id; + return ret_value; } /****if* H5Tf/h5tenum_insert_c @@ -1732,31 +1767,32 @@ h5tenum_create_c ( hid_t_f *parent_id , hid_t_f *new_type_id) * it should not be cast to an int (which might be 4 bytes). Instead the value * is written as the size of an int_f. * SOURCE -*/ + */ int_f -h5tenum_insert_c(hid_t_f *type_id, _fcd name, int_f* namelen, int_f* value) +h5tenum_insert_c(hid_t_f *type_id, _fcd name, int_f *namelen, int_f *value) /******/ { - int ret_value = -1; - char* c_name; - herr_t error; - int_f c_value; + int ret_value = -1; + char * c_name; + herr_t error; + int_f c_value; - c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return ret_value; + c_name = (char *)HD5f2cstring(name, (size_t)*namelen); + if (c_name == NULL) + return ret_value; - c_value = *value; - error = H5Tenum_insert((hid_t)*type_id, c_name, &c_value); + c_value = *value; + error = H5Tenum_insert((hid_t)*type_id, c_name, &c_value); - HDfree(c_name); - if(error < 0) return ret_value; + HDfree(c_name); + if (error < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } - /****if* H5Tf/h5tenum_nameof_c * NAME * h5tenum_nameof_c @@ -1776,29 +1812,30 @@ h5tenum_insert_c(hid_t_f *type_id, _fcd name, int_f* namelen, int_f* value) * HISTORY * * SOURCE -*/ + */ int_f -h5tenum_nameof_c(hid_t_f *type_id, int_f* value, _fcd name, size_t_f* namelen) +h5tenum_nameof_c(hid_t_f *type_id, int_f *value, _fcd name, size_t_f *namelen) /******/ { - int ret_value = -1; - hid_t c_type_id; - char* c_name; - size_t c_namelen; - herr_t error; - int_f c_value; - c_value = *value; - c_namelen = ((size_t)*namelen) +1; - c_name = (char *)HDmalloc(sizeof(char)*c_namelen); - c_type_id = (hid_t)*type_id; - error = H5Tenum_nameof(c_type_id, &c_value, c_name, c_namelen); - HD5packFstring(c_name, _fcdtocp(name), strlen(c_name)); - HDfree(c_name); - - if(error < 0) return ret_value; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + char * c_name; + size_t c_namelen; + herr_t error; + int_f c_value; + c_value = *value; + c_namelen = ((size_t)*namelen) + 1; + c_name = (char *)HDmalloc(sizeof(char) * c_namelen); + c_type_id = (hid_t)*type_id; + error = H5Tenum_nameof(c_type_id, &c_value, c_name, c_namelen); + HD5packFstring(c_name, _fcdtocp(name), strlen(c_name)); + HDfree(c_name); + + if (error < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tenum_valueof_c @@ -1820,26 +1857,27 @@ h5tenum_nameof_c(hid_t_f *type_id, int_f* value, _fcd name, size_t_f* namelen) * HISTORY * * SOURCE -*/ + */ int_f -h5tenum_valueof_c(hid_t_f *type_id, _fcd name, int_f* namelen, int_f* value) +h5tenum_valueof_c(hid_t_f *type_id, _fcd name, int_f *namelen, int_f *value) /******/ { - int ret_value = -1; - char* c_name; - herr_t error; - c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return ret_value; - - error = H5Tenum_valueof((hid_t)*type_id, c_name, value); - HDfree(c_name); - - if(error < 0) return ret_value; - ret_value = 0; - return ret_value; -} + int ret_value = -1; + char * c_name; + herr_t error; + c_name = (char *)HD5f2cstring(name, (size_t)*namelen); + if (c_name == NULL) + return ret_value; + + error = H5Tenum_valueof((hid_t)*type_id, c_name, value); + HDfree(c_name); + if (error < 0) + return ret_value; + ret_value = 0; + return ret_value; +} /****if* H5Tf/h5tget_member_value_c * NAME @@ -1859,22 +1897,23 @@ h5tenum_valueof_c(hid_t_f *type_id, _fcd name, int_f* namelen, int_f* value) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_member_value_c(hid_t_f *type_id, int_f* member_no, int_f* value) +h5tget_member_value_c(hid_t_f *type_id, int_f *member_no, int_f *value) /******/ { - int ret_value = -1; - int c_value; - herr_t error; + int ret_value = -1; + int c_value; + herr_t error; - error = H5Tget_member_value((hid_t)*type_id, (unsigned)*member_no, &c_value); - if(error < 0) return ret_value; + error = H5Tget_member_value((hid_t)*type_id, (unsigned)*member_no, &c_value); + if (error < 0) + return ret_value; - *value = (int_f)c_value; - ret_value = 0; - return ret_value; + *value = (int_f)c_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tset_tag_c @@ -1897,23 +1936,24 @@ h5tget_member_value_c(hid_t_f *type_id, int_f* member_no, int_f* value) * HISTORY * * SOURCE -*/ + */ int_f -h5tset_tag_c(hid_t_f* type_id, _fcd tag, int_f* namelen) +h5tset_tag_c(hid_t_f *type_id, _fcd tag, int_f *namelen) /******/ { - int ret_value = -1; - herr_t status; - char* c_tag; + int ret_value = -1; + herr_t status; + char * c_tag; - c_tag = (char *)HD5f2cstring(tag, (size_t)*namelen); + c_tag = (char *)HD5f2cstring(tag, (size_t)*namelen); - status = H5Tset_tag((hid_t)*type_id, c_tag); - HDfree(c_tag); - if ( status < 0 ) return ret_value; + status = H5Tset_tag((hid_t)*type_id, c_tag); + HDfree(c_tag); + if (status < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_tag_c @@ -1935,24 +1975,25 @@ h5tset_tag_c(hid_t_f* type_id, _fcd tag, int_f* namelen) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_tag_c(hid_t_f* type_id, _fcd tag, size_t_f* tag_size, int_f* taglen) +h5tget_tag_c(hid_t_f *type_id, _fcd tag, size_t_f *tag_size, int_f *taglen) /******/ { - int ret_value = -1; - hid_t c_type_id; - char *c_tag; - - c_type_id = *type_id; - c_tag = H5Tget_tag(c_type_id); - if (c_tag == NULL ) return ret_value; - - HD5packFstring(c_tag, _fcdtocp(tag), (size_t)*tag_size); - *taglen = (int_f)HDstrlen(c_tag); - H5free_memory(c_tag); - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + char *c_tag; + + c_type_id = *type_id; + c_tag = H5Tget_tag(c_type_id); + if (c_tag == NULL) + return ret_value; + + HD5packFstring(c_tag, _fcdtocp(tag), (size_t)*tag_size); + *taglen = (int_f)HDstrlen(c_tag); + H5free_memory(c_tag); + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tvlen_create_c * NAME @@ -1971,21 +2012,22 @@ h5tget_tag_c(hid_t_f* type_id, _fcd tag, size_t_f* tag_size, int_f* taglen) * HISTORY * * SOURCE -*/ + */ int_f -h5tvlen_create_c(hid_t_f* type_id, hid_t_f *vltype_id) +h5tvlen_create_c(hid_t_f *type_id, hid_t_f *vltype_id) /******/ { - int ret_value = -1; - hid_t c_type_id; - hid_t c_vltype_id; - - c_type_id = (hid_t)*type_id; - c_vltype_id = H5Tvlen_create(c_type_id); - if (c_vltype_id < 0 ) return ret_value; - *vltype_id = (hid_t_f)c_vltype_id; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t c_type_id; + hid_t c_vltype_id; + + c_type_id = (hid_t)*type_id; + c_vltype_id = H5Tvlen_create(c_type_id); + if (c_vltype_id < 0) + return ret_value; + *vltype_id = (hid_t_f)c_vltype_id; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tis_variable_str_c * NAME @@ -2006,21 +2048,22 @@ h5tvlen_create_c(hid_t_f* type_id, hid_t_f *vltype_id) * HISTORY * * SOURCE -*/ + */ int_f -h5tis_variable_str_c ( hid_t_f *type_id , int_f *flag ) +h5tis_variable_str_c(hid_t_f *type_id, int_f *flag) /******/ { - int ret_value = 0; - hid_t c_type_id; - htri_t status; - - c_type_id = (hid_t)*type_id; - status = H5Tis_variable_str(c_type_id); - *flag = (int_f)status; - if ( status < 0 ) ret_value = -1; - return ret_value; + int ret_value = 0; + hid_t c_type_id; + htri_t status; + + c_type_id = (hid_t)*type_id; + status = H5Tis_variable_str(c_type_id); + *flag = (int_f)status; + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Tf/h5tget_member_class_c * NAME @@ -2042,24 +2085,25 @@ h5tis_variable_str_c ( hid_t_f *type_id , int_f *flag ) * HISTORY * * SOURCE -*/ + */ int_f -h5tget_member_class_c ( hid_t_f *type_id , int_f *member_no, int_f *cls ) +h5tget_member_class_c(hid_t_f *type_id, int_f *member_no, int_f *cls) /******/ { - int ret_value = 0; - hid_t c_type_id; - unsigned c_member_no; - H5T_class_t c_class; - - c_type_id = (hid_t)*type_id; - c_member_no = (unsigned)*member_no; - c_class = H5Tget_member_class(c_type_id, c_member_no); - - if ( c_class == H5T_NO_CLASS ) ret_value = -1; - *cls = (int_f)c_class; - return ret_value; + int ret_value = 0; + hid_t c_type_id; + unsigned c_member_no; + H5T_class_t c_class; + + c_type_id = (hid_t)*type_id; + c_member_no = (unsigned)*member_no; + c_class = H5Tget_member_class(c_type_id, c_member_no); + + if (c_class == H5T_NO_CLASS) + ret_value = -1; + *cls = (int_f)c_class; + return ret_value; } /****if* H5Tf/h5tcommit_anon_c @@ -2080,22 +2124,21 @@ h5tget_member_class_c ( hid_t_f *type_id , int_f *member_no, int_f *cls ) * HISTORY * * SOURCE -*/ + */ int_f -h5tcommit_anon_c(hid_t_f *loc_id, hid_t_f *dtype_id, - hid_t_f *tcpl_id, hid_t_f *tapl_id) +h5tcommit_anon_c(hid_t_f *loc_id, hid_t_f *dtype_id, hid_t_f *tcpl_id, hid_t_f *tapl_id) /******/ { - int ret_value = -1; + int ret_value = -1; - /* Call H5Tcommit_anon function */ - if(H5Tcommit_anon((hid_t)*loc_id, (hid_t)*dtype_id, (hid_t)*tcpl_id, (hid_t)*tapl_id) < 0) - goto done; + /* Call H5Tcommit_anon function */ + if (H5Tcommit_anon((hid_t)*loc_id, (hid_t)*dtype_id, (hid_t)*tcpl_id, (hid_t)*tapl_id) < 0) + goto done; - ret_value = 0; + ret_value = 0; - done: - return ret_value; +done: + return ret_value; } /****if* H5Tf/h5tcommitted_c @@ -2114,19 +2157,18 @@ h5tcommit_anon_c(hid_t_f *loc_id, hid_t_f *dtype_id, * HISTORY * * SOURCE -*/ + */ int_f h5tcommitted_c(hid_t_f *dtype_id) /******/ { - int_f ret_value; + int_f ret_value; - /* Call H5Tcommitted function */ + /* Call H5Tcommitted function */ - ret_value=(int_f)H5Tcommitted((hid_t)*dtype_id); - - return ret_value; + ret_value = (int_f)H5Tcommitted((hid_t)*dtype_id); + return ret_value; } /****if* H5Tf/h5tdecode_c @@ -2149,30 +2191,30 @@ h5tcommitted_c(hid_t_f *dtype_id) * HISTORY * * SOURCE -*/ + */ int_f -h5tdecode_c ( _fcd buf, hid_t_f *obj_id ) +h5tdecode_c(_fcd buf, hid_t_f *obj_id) /******/ { - int ret_value = -1; - unsigned char *c_buf = NULL; /* Buffer to hold C string */ - hid_t c_obj_id; + int ret_value = -1; + unsigned char *c_buf = NULL; /* Buffer to hold C string */ + hid_t c_obj_id; - /* - * Call H5Tdecode function. - */ + /* + * Call H5Tdecode function. + */ - c_buf = (unsigned char*)buf; + c_buf = (unsigned char *)buf; - c_obj_id = H5Tdecode(c_buf); - if(c_obj_id < 0) - return ret_value; + c_obj_id = H5Tdecode(c_buf); + if (c_obj_id < 0) + return ret_value; - *obj_id = (hid_t_f)c_obj_id; - ret_value = 0; + *obj_id = (hid_t_f)c_obj_id; + ret_value = 0; - return ret_value; + return ret_value; } /****if* H5Tf/h5tencode_c @@ -2193,56 +2235,56 @@ h5tdecode_c ( _fcd buf, hid_t_f *obj_id ) * HISTORY * * SOURCE -*/ + */ int_f -h5tencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc ) +h5tencode_c(_fcd buf, hid_t_f *obj_id, size_t_f *nalloc) /******/ { - int ret_value = -1; - unsigned char *c_buf = NULL; /* Buffer to hold C string */ - size_t c_size; + int ret_value = -1; + unsigned char *c_buf = NULL; /* Buffer to hold C string */ + size_t c_size; - /* return just the size of the allocated buffer; - * equivalent to C routine for which 'name' is set equal to NULL - */ + /* return just the size of the allocated buffer; + * equivalent to C routine for which 'name' is set equal to NULL + */ - if (*nalloc == 0) { + if (*nalloc == 0) { - if(H5Tencode((hid_t)*obj_id, c_buf, &c_size) < 0) - return ret_value; + if (H5Tencode((hid_t)*obj_id, c_buf, &c_size) < 0) + return ret_value; - *nalloc = (size_t_f)c_size; + *nalloc = (size_t_f)c_size; - ret_value = 0; - return ret_value; - } + ret_value = 0; + return ret_value; + } - /* - * Allocate buffer - */ - c_size = (size_t)*nalloc; - if(NULL == (c_buf = (unsigned char *)HDmalloc(c_size))) - return ret_value; + /* + * Allocate buffer + */ + c_size = (size_t)*nalloc; + if (NULL == (c_buf = (unsigned char *)HDmalloc(c_size))) + return ret_value; - /* - * Call H5Tencode function. - */ - if(H5Tencode((hid_t)*obj_id, c_buf, &c_size) < 0) - return ret_value; + /* + * Call H5Tencode function. + */ + if (H5Tencode((hid_t)*obj_id, c_buf, &c_size) < 0) + return ret_value; - /* copy the C buffer to the FORTRAN buffer. - * Can not use HD5packFstring because we don't want to - * eliminate the NUL terminator or pad remaining space - * with blanks. - */ + /* copy the C buffer to the FORTRAN buffer. + * Can not use HD5packFstring because we don't want to + * eliminate the NUL terminator or pad remaining space + * with blanks. + */ - HDmemcpy(_fcdtocp(buf),(char *)c_buf,c_size); + HDmemcpy(_fcdtocp(buf), (char *)c_buf, c_size); - ret_value = 0; - if(c_buf) - HDfree(c_buf); - return ret_value; + ret_value = 0; + if (c_buf) + HDfree(c_buf); + return ret_value; } /****if* H5Tf/h5tget_create_plist_c @@ -2262,13 +2304,13 @@ h5tencode_c (_fcd buf, hid_t_f *obj_id, size_t_f *nalloc ) * HISTORY * N/A * SOURCE -*/ + */ int_f -h5tget_create_plist_c ( hid_t_f *dtype_id, hid_t_f *dtpl_id) +h5tget_create_plist_c(hid_t_f *dtype_id, hid_t_f *dtpl_id) /******/ { - int_f ret_value=-1; /* Return value */ + int_f ret_value = -1; /* Return value */ if ((*dtpl_id = (hid_t_f)H5Tget_create_plist((hid_t)*dtype_id)) < 0) return ret_value; @@ -2296,20 +2338,21 @@ h5tget_create_plist_c ( hid_t_f *dtype_id, hid_t_f *dtpl_id) * HISTORY * * SOURCE -*/ + */ int_f -h5tcompiler_conv_c ( hid_t_f *src_id, hid_t_f *dst_id, int_f *c_flag) +h5tcompiler_conv_c(hid_t_f *src_id, hid_t_f *dst_id, int_f *c_flag) /******/ { - int ret_value = -1; - htri_t status; - - status = H5Tcompiler_conv( (hid_t)*src_id , (hid_t)*dst_id); - if ( status < 0 ) return ret_value; - *c_flag = (int_f)status; - ret_value = 0; - return ret_value; + int ret_value = -1; + htri_t status; + + status = H5Tcompiler_conv((hid_t)*src_id, (hid_t)*dst_id); + if (status < 0) + return ret_value; + *c_flag = (int_f)status; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tget_native_type_c * NAME @@ -2330,20 +2373,21 @@ h5tcompiler_conv_c ( hid_t_f *src_id, hid_t_f *dst_id, int_f *c_flag) * HISTORY * * SOURCE -*/ + */ int_f h5tget_native_type_c(hid_t_f *dtype_id, int_f *direction, hid_t_f *native_dtype_id) /******/ { - int ret_value = -1; - hid_t status; - - status = H5Tget_native_type( (hid_t)*dtype_id, (H5T_direction_t)*direction); - if ( status < 0 ) return ret_value; - *native_dtype_id = (hid_t_f)status; - ret_value = 0; - return ret_value; + int ret_value = -1; + hid_t status; + + status = H5Tget_native_type((hid_t)*dtype_id, (H5T_direction_t)*direction); + if (status < 0) + return ret_value; + *native_dtype_id = (hid_t_f)status; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tconvert_c @@ -2370,18 +2414,20 @@ h5tget_native_type_c(hid_t_f *dtype_id, int_f *direction, hid_t_f *native_dtype_ * December 8, 2008 * * SOURCE -*/ + */ int_f -h5tconvert_c(hid_t_f *src_id, hid_t_f *dst_id, size_t_f *nelmts, void *buf, void *background, hid_t_f *plist_id) +h5tconvert_c(hid_t_f *src_id, hid_t_f *dst_id, size_t_f *nelmts, void *buf, void *background, + hid_t_f *plist_id) /******/ { - int ret_value = -1; - hid_t status; + int ret_value = -1; + hid_t status; - status = H5Tconvert( (hid_t)*src_id, (hid_t)*dst_id, (size_t)*nelmts, buf, background, (hid_t)*plist_id ); - if ( status < 0 ) return ret_value; - ret_value = 0; - return ret_value; + status = H5Tconvert((hid_t)*src_id, (hid_t)*dst_id, (size_t)*nelmts, buf, background, (hid_t)*plist_id); + if (status < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Tf/h5tenum_insert_ptr_c @@ -2403,28 +2449,28 @@ h5tconvert_c(hid_t_f *src_id, hid_t_f *dst_id, size_t_f *nelmts, void *buf, void * February 6, 2015 * * SOURCE -*/ + */ int_f -h5tenum_insert_ptr_c(hid_t_f *type_id, _fcd name, int_f* namelen, void *value) +h5tenum_insert_ptr_c(hid_t_f *type_id, _fcd name, int_f *namelen, void *value) /******/ { - int ret_value = -1; - hid_t status; - char *c_name; + int ret_value = -1; + hid_t status; + char *c_name; - /* - * Convert FORTRAN name to C name - */ - c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return ret_value; + /* + * Convert FORTRAN name to C name + */ + c_name = (char *)HD5f2cstring(name, (size_t)*namelen); + if (c_name == NULL) + return ret_value; - status = H5Tenum_insert( (hid_t)*type_id, c_name, value); + status = H5Tenum_insert((hid_t)*type_id, c_name, value); - HDfree(c_name); - if ( status < 0 ) return ret_value; + HDfree(c_name); + if (status < 0) + return ret_value; - ret_value = 0; - return ret_value; + ret_value = 0; + return ret_value; } - - diff --git a/fortran/src/H5Zf.c b/fortran/src/H5Zf.c index 7afafd5..ca9e7eb 100644 --- a/fortran/src/H5Zf.c +++ b/fortran/src/H5Zf.c @@ -17,7 +17,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" @@ -36,23 +36,24 @@ * HISTORY * * SOURCE -*/ + */ int_f -h5zunregister_c (int_f *filter) +h5zunregister_c(int_f *filter) /******/ { - int ret_value = -1; - herr_t status; - H5Z_filter_t c_filter; + int ret_value = -1; + herr_t status; + H5Z_filter_t c_filter; - /* - * Call H5Zunregister function. - */ - c_filter = (H5Z_filter_t)*filter; - status = H5Zunregister(c_filter); - if (status < 0) return ret_value; - ret_value = 0; - return ret_value; + /* + * Call H5Zunregister function. + */ + c_filter = (H5Z_filter_t)*filter; + status = H5Zunregister(c_filter); + if (status < 0) + return ret_value; + ret_value = 0; + return ret_value; } /****if* H5Zf/h5zfiletr_avail_c * NAME @@ -71,21 +72,22 @@ h5zunregister_c (int_f *filter) * HISTORY * * SOURCE -*/ + */ int_f -h5zfilter_avail_c ( int_f *filter , int_f *flag ) +h5zfilter_avail_c(int_f *filter, int_f *flag) /******/ { - int ret_value = 0; - H5Z_filter_t c_filter; - htri_t status; + int ret_value = 0; + H5Z_filter_t c_filter; + htri_t status; - c_filter = (H5Z_filter_t)*filter; - status = H5Zfilter_avail(c_filter); - *flag = (int_f)status; - if ( status < 0 ) ret_value = -1; - return ret_value; + c_filter = (H5Z_filter_t)*filter; + status = H5Zfilter_avail(c_filter); + *flag = (int_f)status; + if (status < 0) + ret_value = -1; + return ret_value; } /****if* H5Zf/h5zget_filter_info_c @@ -106,19 +108,19 @@ h5zfilter_avail_c ( int_f *filter , int_f *flag ) * HISTORY * * SOURCE -*/ + */ int_f -h5zget_filter_info_c ( int_f *filter , int_f *flag ) +h5zget_filter_info_c(int_f *filter, int_f *flag) /******/ { - int ret_value = 0; - H5Z_filter_t c_filter; - unsigned int c_flag; + int ret_value = 0; + H5Z_filter_t c_filter; + unsigned int c_flag; - c_filter = (H5Z_filter_t)*filter; - ret_value = H5Zget_filter_info(c_filter, &c_flag); - *flag = (int_f)c_flag; + c_filter = (H5Z_filter_t)*filter; + ret_value = H5Zget_filter_info(c_filter, &c_flag); + *flag = (int_f)c_flag; - return ret_value; + return ret_value; } diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index 8044b78..9c71c57 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -17,14 +17,13 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "H5f90.h" #include "H5fort_type_defines.h" int IntKinds_SizeOf[] = H5_FORTRAN_INTEGER_KINDS_SIZEOF; - /****if* H5_f/h5init_types_c * NAME * h5init_types_c @@ -49,14 +48,14 @@ int IntKinds_SizeOf[] = H5_FORTRAN_INTEGER_KINDS_SIZEOF; * Elena Pourmal * Tuesday, August 3, 1999 * SOURCE -*/ + */ int_f -h5init_types_c( hid_t_f * types, hid_t_f * floatingtypes, hid_t_f * integertypes ) +h5init_types_c(hid_t_f *types, hid_t_f *floatingtypes, hid_t_f *integertypes) /******/ { - int ret_value = -1; + int ret_value = -1; hid_t c_type_id; - int i; + int i; /* Fortran INTEGER may not be the same as C; do all checking to find an appropriate size @@ -67,186 +66,258 @@ h5init_types_c( hid_t_f * types, hid_t_f * floatingtypes, hid_t_f * integertypes */ /* Initialized INTEGER KIND types to default to native integer */ - for(i=0;i<5;i++) { - if ((types[i] = (hid_t_f)H5Tcopy (H5T_NATIVE_INT)) < 0) return ret_value; + for (i = 0; i < 5; i++) { + if ((types[i] = (hid_t_f)H5Tcopy(H5T_NATIVE_INT)) < 0) + return ret_value; } - for(i=0;i= H5_PAC_FC_MAX_REAL_PRECISION) { - if ((types[13] = (hid_t_f)H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) return ret_value; - } - else { - if ((types[13] = H5Tcopy (H5T_NATIVE_FLOAT)) < 0) return ret_value; - if ( H5Tset_precision (types[13], 128) < 0) return ret_value; - } + if (H5_PAC_C_MAX_REAL_PRECISION >= H5_PAC_FC_MAX_REAL_PRECISION) { + if ((types[13] = (hid_t_f)H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) + return ret_value; + } + else { + if ((types[13] = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) + return ret_value; + if (H5Tset_precision(types[13], 128) < 0) + return ret_value; + } } -# else - if ((types[13] = H5Tcopy (H5T_NATIVE_FLOAT)) < 0) return ret_value; - if ( H5Tset_precision (types[13], 64) < 0) return ret_value; -# endif #else - if ((types[13] = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) return ret_value; + if ((types[13] = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) + return ret_value; + if (H5Tset_precision(types[13], 64) < 0) + return ret_value; +#endif +#else + if ((types[13] = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) + return ret_value; #endif /* * FIND H5T_NATIVE_B_8 */ - if ((types[14] = (hid_t_f)H5Tcopy(H5T_NATIVE_B8)) < 0) return ret_value; - if ((types[15] = (hid_t_f)H5Tcopy(H5T_NATIVE_B16)) < 0) return ret_value; - if ((types[16] = (hid_t_f)H5Tcopy(H5T_NATIVE_B32)) < 0) return ret_value; - if ((types[17] = (hid_t_f)H5Tcopy(H5T_NATIVE_B64)) < 0) return ret_value; + if ((types[14] = (hid_t_f)H5Tcopy(H5T_NATIVE_B8)) < 0) + return ret_value; + if ((types[15] = (hid_t_f)H5Tcopy(H5T_NATIVE_B16)) < 0) + return ret_value; + if ((types[16] = (hid_t_f)H5Tcopy(H5T_NATIVE_B32)) < 0) + return ret_value; + if ((types[17] = (hid_t_f)H5Tcopy(H5T_NATIVE_B64)) < 0) + return ret_value; /* * FIND H5T_NATIVE_FLOAT_128 */ - if ((types[18] = H5Tcopy (H5T_NATIVE_FLOAT)) < 0) return ret_value; - if ( H5Tset_precision (types[18], 128) < 0) return ret_value; + if ((types[18] = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) + return ret_value; + if (H5Tset_precision(types[18], 128) < 0) + return ret_value; /*--------------------------------------------------------------------------------------*/ - if ((floatingtypes[0] = (hid_t_f)H5Tcopy(H5T_IEEE_F32BE)) < 0) return ret_value; - if ((floatingtypes[1] = (hid_t_f)H5Tcopy(H5T_IEEE_F32LE)) < 0) return ret_value; - if ((floatingtypes[2] = (hid_t_f)H5Tcopy(H5T_IEEE_F64BE)) < 0) return ret_value; - if ((floatingtypes[3] = (hid_t_f)H5Tcopy(H5T_IEEE_F64LE)) < 0) return ret_value; - - if ((integertypes[0] = (hid_t_f)H5Tcopy(H5T_STD_I8BE)) < 0) return ret_value; - if ((integertypes[1] = (hid_t_f)H5Tcopy(H5T_STD_I8LE)) < 0) return ret_value; - if ((integertypes[2] = (hid_t_f)H5Tcopy(H5T_STD_I16BE)) < 0) return ret_value; - if ((integertypes[3] = (hid_t_f)H5Tcopy(H5T_STD_I16LE)) < 0) return ret_value; - if ((integertypes[4] = (hid_t_f)H5Tcopy(H5T_STD_I32BE)) < 0) return ret_value; - if ((integertypes[5] = (hid_t_f)H5Tcopy(H5T_STD_I32LE)) < 0) return ret_value; - if ((integertypes[6] = (hid_t_f)H5Tcopy(H5T_STD_I64BE)) < 0) return ret_value; - if ((integertypes[7] = (hid_t_f)H5Tcopy(H5T_STD_I64LE)) < 0) return ret_value; - if ((integertypes[8] = (hid_t_f)H5Tcopy(H5T_STD_U8BE)) < 0) return ret_value; - if ((integertypes[9] = (hid_t_f)H5Tcopy(H5T_STD_U8LE)) < 0) return ret_value; - if ((integertypes[10] = (hid_t_f)H5Tcopy(H5T_STD_U16BE)) < 0) return ret_value; - if ((integertypes[11] = (hid_t_f)H5Tcopy(H5T_STD_U16LE)) < 0) return ret_value; - if ((integertypes[12] = (hid_t_f)H5Tcopy(H5T_STD_U32BE)) < 0) return ret_value; - if ((integertypes[13] = (hid_t_f)H5Tcopy(H5T_STD_U32LE)) < 0) return ret_value; - if ((integertypes[14] = (hid_t_f)H5Tcopy(H5T_STD_U64BE)) < 0) return ret_value; - if ((integertypes[15] = (hid_t_f)H5Tcopy(H5T_STD_U64LE)) < 0) return ret_value; - if ((integertypes[17] = (hid_t_f)H5Tcopy(H5T_STD_B8BE)) < 0) return ret_value; - if ((integertypes[18] = (hid_t_f)H5Tcopy(H5T_STD_B8LE)) < 0) return ret_value; - if ((integertypes[19] = (hid_t_f)H5Tcopy(H5T_STD_B16BE)) < 0) return ret_value; - if ((integertypes[20] = (hid_t_f)H5Tcopy(H5T_STD_B16LE)) < 0) return ret_value; - if ((integertypes[21] = (hid_t_f)H5Tcopy(H5T_STD_B32BE)) < 0) return ret_value; - if ((integertypes[22] = (hid_t_f)H5Tcopy(H5T_STD_B32LE)) < 0) return ret_value; - if ((integertypes[23] = (hid_t_f)H5Tcopy(H5T_STD_B64BE)) < 0) return ret_value; - if ((integertypes[24] = (hid_t_f)H5Tcopy(H5T_STD_B64LE)) < 0) return ret_value; - if ((integertypes[25] = (hid_t_f)H5Tcopy(H5T_FORTRAN_S1)) < 0) return ret_value; - if ((integertypes[26] = (hid_t_f)H5Tcopy(H5T_C_S1)) < 0) return ret_value; - -/* - * Define Fortran H5T_STRING type to store non-fixed size strings - */ - if ((c_type_id = H5Tcopy(H5T_C_S1)) < 0) return ret_value; - if(H5Tset_size(c_type_id, H5T_VARIABLE) < 0) return ret_value; + if ((floatingtypes[0] = (hid_t_f)H5Tcopy(H5T_IEEE_F32BE)) < 0) + return ret_value; + if ((floatingtypes[1] = (hid_t_f)H5Tcopy(H5T_IEEE_F32LE)) < 0) + return ret_value; + if ((floatingtypes[2] = (hid_t_f)H5Tcopy(H5T_IEEE_F64BE)) < 0) + return ret_value; + if ((floatingtypes[3] = (hid_t_f)H5Tcopy(H5T_IEEE_F64LE)) < 0) + return ret_value; + + if ((integertypes[0] = (hid_t_f)H5Tcopy(H5T_STD_I8BE)) < 0) + return ret_value; + if ((integertypes[1] = (hid_t_f)H5Tcopy(H5T_STD_I8LE)) < 0) + return ret_value; + if ((integertypes[2] = (hid_t_f)H5Tcopy(H5T_STD_I16BE)) < 0) + return ret_value; + if ((integertypes[3] = (hid_t_f)H5Tcopy(H5T_STD_I16LE)) < 0) + return ret_value; + if ((integertypes[4] = (hid_t_f)H5Tcopy(H5T_STD_I32BE)) < 0) + return ret_value; + if ((integertypes[5] = (hid_t_f)H5Tcopy(H5T_STD_I32LE)) < 0) + return ret_value; + if ((integertypes[6] = (hid_t_f)H5Tcopy(H5T_STD_I64BE)) < 0) + return ret_value; + if ((integertypes[7] = (hid_t_f)H5Tcopy(H5T_STD_I64LE)) < 0) + return ret_value; + if ((integertypes[8] = (hid_t_f)H5Tcopy(H5T_STD_U8BE)) < 0) + return ret_value; + if ((integertypes[9] = (hid_t_f)H5Tcopy(H5T_STD_U8LE)) < 0) + return ret_value; + if ((integertypes[10] = (hid_t_f)H5Tcopy(H5T_STD_U16BE)) < 0) + return ret_value; + if ((integertypes[11] = (hid_t_f)H5Tcopy(H5T_STD_U16LE)) < 0) + return ret_value; + if ((integertypes[12] = (hid_t_f)H5Tcopy(H5T_STD_U32BE)) < 0) + return ret_value; + if ((integertypes[13] = (hid_t_f)H5Tcopy(H5T_STD_U32LE)) < 0) + return ret_value; + if ((integertypes[14] = (hid_t_f)H5Tcopy(H5T_STD_U64BE)) < 0) + return ret_value; + if ((integertypes[15] = (hid_t_f)H5Tcopy(H5T_STD_U64LE)) < 0) + return ret_value; + if ((integertypes[17] = (hid_t_f)H5Tcopy(H5T_STD_B8BE)) < 0) + return ret_value; + if ((integertypes[18] = (hid_t_f)H5Tcopy(H5T_STD_B8LE)) < 0) + return ret_value; + if ((integertypes[19] = (hid_t_f)H5Tcopy(H5T_STD_B16BE)) < 0) + return ret_value; + if ((integertypes[20] = (hid_t_f)H5Tcopy(H5T_STD_B16LE)) < 0) + return ret_value; + if ((integertypes[21] = (hid_t_f)H5Tcopy(H5T_STD_B32BE)) < 0) + return ret_value; + if ((integertypes[22] = (hid_t_f)H5Tcopy(H5T_STD_B32LE)) < 0) + return ret_value; + if ((integertypes[23] = (hid_t_f)H5Tcopy(H5T_STD_B64BE)) < 0) + return ret_value; + if ((integertypes[24] = (hid_t_f)H5Tcopy(H5T_STD_B64LE)) < 0) + return ret_value; + if ((integertypes[25] = (hid_t_f)H5Tcopy(H5T_FORTRAN_S1)) < 0) + return ret_value; + if ((integertypes[26] = (hid_t_f)H5Tcopy(H5T_C_S1)) < 0) + return ret_value; + + /* + * Define Fortran H5T_STRING type to store non-fixed size strings + */ + if ((c_type_id = H5Tcopy(H5T_C_S1)) < 0) + return ret_value; + if (H5Tset_size(c_type_id, H5T_VARIABLE) < 0) + return ret_value; integertypes[16] = c_type_id; ret_value = 0; @@ -287,26 +358,28 @@ h5init_types_c( hid_t_f * types, hid_t_f * floatingtypes, hid_t_f * integertypes * SOURCE */ int_f -h5close_types_c( hid_t_f * types, int_f *lentypes, - hid_t_f * floatingtypes, int_f* floatinglen, - hid_t_f * integertypes, int_f * integerlen ) +h5close_types_c(hid_t_f *types, int_f *lentypes, hid_t_f *floatingtypes, int_f *floatinglen, + hid_t_f *integertypes, int_f *integerlen) /******/ { - int ret_value = -1; + int ret_value = -1; hid_t c_type_id; - int i; + int i; for (i = 0; i < *lentypes; i++) { - c_type_id = types[i]; - if ( H5Tclose(c_type_id) < 0) return ret_value; + c_type_id = types[i]; + if (H5Tclose(c_type_id) < 0) + return ret_value; } for (i = 0; i < *floatinglen; i++) { - c_type_id = floatingtypes[i]; - if ( H5Tclose(c_type_id) < 0) return ret_value; + c_type_id = floatingtypes[i]; + if (H5Tclose(c_type_id) < 0) + return ret_value; } for (i = 0; i < *integerlen; i++) { - c_type_id = integertypes[i]; - if ( H5Tclose(c_type_id) < 0) return ret_value; + c_type_id = integertypes[i]; + if (H5Tclose(c_type_id) < 0) + return ret_value; } ret_value = 0; return ret_value; @@ -359,32 +432,29 @@ h5close_types_c( hid_t_f * types, int_f *lentypes, * SOURCE */ int_f -h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, - int_f *h5e_flags, hid_t_f *h5e_hid_flags, int_f *h5f_flags, - int_f *h5fd_flags, hid_t_f *h5fd_hid_flags, - int_f *h5g_flags, int_f *h5i_flags, int_f *h5l_flags, int_f *h5o_flags, - hid_t_f *h5p_flags, int_f *h5p_flags_int, int_f *h5r_flags, - int_f *h5s_flags, hid_t_f *h5s_hid_flags, hsize_t_f *h5s_hsize_flags, - int_f *h5t_flags, int_f *h5z_flags, int_f *h5_generic_flags, - haddr_t_f *h5_haddr_generic_flags) +h5init_flags_c(int_f *h5d_flags, size_t_f *h5d_size_flags, int_f *h5e_flags, hid_t_f *h5e_hid_flags, + int_f *h5f_flags, int_f *h5fd_flags, hid_t_f *h5fd_hid_flags, int_f *h5g_flags, + int_f *h5i_flags, int_f *h5l_flags, int_f *h5o_flags, hid_t_f *h5p_flags, int_f *h5p_flags_int, + int_f *h5r_flags, int_f *h5s_flags, hid_t_f *h5s_hid_flags, hsize_t_f *h5s_hsize_flags, + int_f *h5t_flags, int_f *h5z_flags, int_f *h5_generic_flags, haddr_t_f *h5_haddr_generic_flags) /******/ { -/* - * H5D flags - */ + /* + * H5D flags + */ h5d_size_flags[0] = (size_t_f)H5D_CHUNK_CACHE_NSLOTS_DEFAULT; h5d_size_flags[1] = (size_t_f)H5D_CHUNK_CACHE_NBYTES_DEFAULT; - h5d_flags[0] = (int_f)H5D_COMPACT; - h5d_flags[1] = (int_f)H5D_CONTIGUOUS; - h5d_flags[2] = (int_f)H5D_CHUNKED; - h5d_flags[3] = (int_f)H5D_ALLOC_TIME_ERROR; - h5d_flags[4] = (int_f)H5D_ALLOC_TIME_DEFAULT; - h5d_flags[5] = (int_f)H5D_ALLOC_TIME_EARLY; - h5d_flags[6] = (int_f)H5D_ALLOC_TIME_LATE; - h5d_flags[7] = (int_f)H5D_ALLOC_TIME_INCR; - h5d_flags[8] = (int_f)H5D_SPACE_STATUS_ERROR; - h5d_flags[9] = (int_f)H5D_SPACE_STATUS_NOT_ALLOCATED; + h5d_flags[0] = (int_f)H5D_COMPACT; + h5d_flags[1] = (int_f)H5D_CONTIGUOUS; + h5d_flags[2] = (int_f)H5D_CHUNKED; + h5d_flags[3] = (int_f)H5D_ALLOC_TIME_ERROR; + h5d_flags[4] = (int_f)H5D_ALLOC_TIME_DEFAULT; + h5d_flags[5] = (int_f)H5D_ALLOC_TIME_EARLY; + h5d_flags[6] = (int_f)H5D_ALLOC_TIME_LATE; + h5d_flags[7] = (int_f)H5D_ALLOC_TIME_INCR; + h5d_flags[8] = (int_f)H5D_SPACE_STATUS_ERROR; + h5d_flags[9] = (int_f)H5D_SPACE_STATUS_NOT_ALLOCATED; h5d_flags[10] = (int_f)H5D_SPACE_STATUS_PART_ALLOCATED; h5d_flags[11] = (int_f)H5D_SPACE_STATUS_ALLOCATED; h5d_flags[12] = (int_f)H5D_FILL_TIME_ERROR; @@ -405,9 +475,9 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5d_flags[27] = (int_f)H5D_VDS_LAST_AVAILABLE; h5d_flags[28] = (int_f)H5D_VIRTUAL; -/* - * H5E flags - */ + /* + * H5E flags + */ h5e_hid_flags[0] = (hid_t_f)H5E_DEFAULT; h5e_flags[0] = (int_f)H5E_MAJOR; @@ -415,12 +485,12 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5e_flags[2] = (int_f)H5E_WALK_UPWARD; h5e_flags[3] = (int_f)H5E_WALK_DOWNWARD; -/* - * H5F flags - * - * Note that H5F_ACC_DEBUG is deprecated (nonfunctional) but retained - * for backward compatibility since it's in the public API. - */ + /* + * H5F flags + * + * Note that H5F_ACC_DEBUG is deprecated (nonfunctional) but retained + * for backward compatibility since it's in the public API. + */ h5f_flags[0] = (int_f)H5F_ACC_RDWR; h5f_flags[1] = (int_f)H5F_ACC_RDONLY; h5f_flags[2] = (int_f)H5F_ACC_TRUNC; @@ -428,11 +498,11 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, #ifndef H5_NO_DEPRECATED_SYMBOLS h5f_flags[4] = (int_f)H5F_ACC_DEBUG; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - h5f_flags[5] = (int_f)H5F_SCOPE_LOCAL; - h5f_flags[6] = (int_f)H5F_SCOPE_GLOBAL; - h5f_flags[7] = (int_f)H5F_CLOSE_DEFAULT; - h5f_flags[8] = (int_f)H5F_CLOSE_WEAK; - h5f_flags[9] = (int_f)H5F_CLOSE_SEMI; + h5f_flags[5] = (int_f)H5F_SCOPE_LOCAL; + h5f_flags[6] = (int_f)H5F_SCOPE_GLOBAL; + h5f_flags[7] = (int_f)H5F_CLOSE_DEFAULT; + h5f_flags[8] = (int_f)H5F_CLOSE_WEAK; + h5f_flags[9] = (int_f)H5F_CLOSE_SEMI; h5f_flags[10] = (int_f)H5F_CLOSE_STRONG; h5f_flags[11] = (int_f)H5F_OBJ_FILE; h5f_flags[12] = (int_f)H5F_OBJ_DATASET; @@ -449,24 +519,24 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5f_flags[23] = (int_f)H5F_LIBVER_V112; h5f_flags[24] = (int_f)H5F_LIBVER_V114; -/* - * H5FD flags - */ - h5fd_flags[0] = (int_f)H5FD_MPIO_INDEPENDENT; - h5fd_flags[1] = (int_f)H5FD_MPIO_COLLECTIVE; - h5fd_flags[2] = (int_f)H5FD_MEM_NOLIST; - h5fd_flags[3] = (int_f)H5FD_MEM_DEFAULT; - h5fd_flags[4] = (int_f)H5FD_MEM_SUPER; - h5fd_flags[5] = (int_f)H5FD_MEM_BTREE; - h5fd_flags[6] = (int_f)H5FD_MEM_DRAW; - h5fd_flags[7] = (int_f)H5FD_MEM_GHEAP; - h5fd_flags[8] = (int_f)H5FD_MEM_LHEAP; - h5fd_flags[9] = (int_f)H5FD_MEM_OHDR; + /* + * H5FD flags + */ + h5fd_flags[0] = (int_f)H5FD_MPIO_INDEPENDENT; + h5fd_flags[1] = (int_f)H5FD_MPIO_COLLECTIVE; + h5fd_flags[2] = (int_f)H5FD_MEM_NOLIST; + h5fd_flags[3] = (int_f)H5FD_MEM_DEFAULT; + h5fd_flags[4] = (int_f)H5FD_MEM_SUPER; + h5fd_flags[5] = (int_f)H5FD_MEM_BTREE; + h5fd_flags[6] = (int_f)H5FD_MEM_DRAW; + h5fd_flags[7] = (int_f)H5FD_MEM_GHEAP; + h5fd_flags[8] = (int_f)H5FD_MEM_LHEAP; + h5fd_flags[9] = (int_f)H5FD_MEM_OHDR; h5fd_flags[10] = (int_f)H5FD_MEM_NTYPES; -/* - * H5FD flags of type hid_t - */ + /* + * H5FD flags of type hid_t + */ h5fd_hid_flags[0] = (hid_t_f)H5FD_CORE; h5fd_hid_flags[1] = (hid_t_f)H5FD_FAMILY; h5fd_hid_flags[2] = (hid_t_f)H5FD_LOG; @@ -475,36 +545,36 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5fd_hid_flags[5] = (hid_t_f)H5FD_SEC2; h5fd_hid_flags[6] = (hid_t_f)H5FD_STDIO; -/* - * H5G flags - */ - h5g_flags[0] = (int_f)H5O_TYPE_UNKNOWN; /* H5G_UNKNOWN is deprecated */ - h5g_flags[1] = (int_f)H5O_TYPE_GROUP; /* H5G_GROUP is deprecated */ - h5g_flags[2] = (int_f)H5O_TYPE_DATASET; /* H5G_DATASET is deprecated */ + /* + * H5G flags + */ + h5g_flags[0] = (int_f)H5O_TYPE_UNKNOWN; /* H5G_UNKNOWN is deprecated */ + h5g_flags[1] = (int_f)H5O_TYPE_GROUP; /* H5G_GROUP is deprecated */ + h5g_flags[2] = (int_f)H5O_TYPE_DATASET; /* H5G_DATASET is deprecated */ h5g_flags[3] = (int_f)H5O_TYPE_NAMED_DATATYPE; /* H5G_TYPE is deprecated */ h5g_flags[4] = (int_f)H5L_SAME_LOC; h5g_flags[5] = (int_f)H5L_TYPE_ERROR; h5g_flags[6] = (int_f)H5L_TYPE_HARD; h5g_flags[7] = (int_f)H5L_TYPE_SOFT; - h5g_flags[8] = (int_f)H5G_STORAGE_TYPE_UNKNOWN; - h5g_flags[9] = (int_f)H5G_STORAGE_TYPE_SYMBOL_TABLE; + h5g_flags[8] = (int_f)H5G_STORAGE_TYPE_UNKNOWN; + h5g_flags[9] = (int_f)H5G_STORAGE_TYPE_SYMBOL_TABLE; h5g_flags[10] = (int_f)H5G_STORAGE_TYPE_COMPACT; h5g_flags[11] = (int_f)H5G_STORAGE_TYPE_DENSE; -/* - * H5I flags - */ - h5i_flags[0] = (int_f)H5I_FILE; - h5i_flags[1] = (int_f)H5I_GROUP; - h5i_flags[2] = (int_f)H5I_DATATYPE; - h5i_flags[3] = (int_f)H5I_DATASPACE; - h5i_flags[4] = (int_f)H5I_DATASET; - h5i_flags[5] = (int_f)H5I_ATTR; - h5i_flags[6] = (int_f)H5I_BADID; - h5i_flags[7] = (int_f)H5I_UNINIT; - h5i_flags[8] = (int_f)H5I_VFL; - h5i_flags[9] = (int_f)H5I_VOL; + /* + * H5I flags + */ + h5i_flags[0] = (int_f)H5I_FILE; + h5i_flags[1] = (int_f)H5I_GROUP; + h5i_flags[2] = (int_f)H5I_DATATYPE; + h5i_flags[3] = (int_f)H5I_DATASPACE; + h5i_flags[4] = (int_f)H5I_DATASET; + h5i_flags[5] = (int_f)H5I_ATTR; + h5i_flags[6] = (int_f)H5I_BADID; + h5i_flags[7] = (int_f)H5I_UNINIT; + h5i_flags[8] = (int_f)H5I_VFL; + h5i_flags[9] = (int_f)H5I_VOL; h5i_flags[10] = (int_f)H5I_GENPROP_CLS; h5i_flags[11] = (int_f)H5I_GENPROP_LST; h5i_flags[12] = (int_f)H5I_ERROR_CLASS; @@ -512,94 +582,97 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5i_flags[14] = (int_f)H5I_ERROR_STACK; h5i_flags[15] = (int_f)H5I_NTYPES; h5i_flags[16] = (int_f)H5I_INVALID_HID; -/* - * H5L flags - */ + /* + * H5L flags + */ h5l_flags[0] = (int_f)H5L_TYPE_ERROR; h5l_flags[1] = (int_f)H5L_TYPE_HARD; h5l_flags[2] = (int_f)H5L_TYPE_SOFT; h5l_flags[3] = (int_f)H5L_TYPE_EXTERNAL; - h5l_flags[4] = (int_f)H5L_SAME_LOC; /* Macro to indicate operation occurs on same location */ + h5l_flags[4] = (int_f)H5L_SAME_LOC; /* Macro to indicate operation occurs on same location */ h5l_flags[5] = (int_f)H5L_LINK_CLASS_T_VERS; /* Current version of the H5L_class_t struct */ -/* - * H5O flags - */ + /* + * H5O flags + */ -/* Flags for object copy (H5Ocopy) */ + /* Flags for object copy (H5Ocopy) */ h5o_flags[0] = (int_f)H5O_COPY_SHALLOW_HIERARCHY_FLAG; /* Copy only immediate members */ - h5o_flags[1] = (int_f)H5O_COPY_EXPAND_SOFT_LINK_FLAG; /* Expand soft links into new objects */ - h5o_flags[2] = (int_f)H5O_COPY_EXPAND_EXT_LINK_FLAG; /* Expand external links into new objects */ - h5o_flags[3] = (int_f)H5O_COPY_EXPAND_REFERENCE_FLAG; /* Copy objects that are pointed by references */ - h5o_flags[4] = (int_f)H5O_COPY_WITHOUT_ATTR_FLAG; /* Copy object without copying attributes */ - h5o_flags[5] = (int_f)H5O_COPY_PRESERVE_NULL_FLAG; /* Copy NULL messages (empty space) */ + h5o_flags[1] = (int_f)H5O_COPY_EXPAND_SOFT_LINK_FLAG; /* Expand soft links into new objects */ + h5o_flags[2] = (int_f)H5O_COPY_EXPAND_EXT_LINK_FLAG; /* Expand external links into new objects */ + h5o_flags[3] = (int_f)H5O_COPY_EXPAND_REFERENCE_FLAG; /* Copy objects that are pointed by references */ + h5o_flags[4] = (int_f)H5O_COPY_WITHOUT_ATTR_FLAG; /* Copy object without copying attributes */ + h5o_flags[5] = (int_f)H5O_COPY_PRESERVE_NULL_FLAG; /* Copy NULL messages (empty space) */ h5o_flags[6] = (int_f)H5O_COPY_ALL; /* All object copying flags (for internal checking) */ -/* Flags for shared message indexes. - * Pass these flags in using the mesg_type_flags parameter in - * H5P_set_shared_mesg_index. - * (Developers: These flags correspond to object header message type IDs, - * but we need to assign each kind of message to a different bit so that - * one index can hold multiple types.) - */ - h5o_flags[7] = (int_f)H5O_SHMESG_NONE_FLAG; /* No shared messages */ - h5o_flags[8] = (int_f)H5O_SHMESG_SDSPACE_FLAG; /* Simple Dataspace Message. */ - h5o_flags[9] = (int_f)H5O_SHMESG_DTYPE_FLAG; /* Datatype Message. */ - h5o_flags[10] = (int_f)H5O_SHMESG_FILL_FLAG; /* Fill Value Message. */ - h5o_flags[11] = (int_f)H5O_SHMESG_PLINE_FLAG; /* Filter pipeline message. */ - h5o_flags[12] = (int_f)H5O_SHMESG_ATTR_FLAG; /* Attribute Message. */ + /* Flags for shared message indexes. + * Pass these flags in using the mesg_type_flags parameter in + * H5P_set_shared_mesg_index. + * (Developers: These flags correspond to object header message type IDs, + * but we need to assign each kind of message to a different bit so that + * one index can hold multiple types.) + */ + h5o_flags[7] = (int_f)H5O_SHMESG_NONE_FLAG; /* No shared messages */ + h5o_flags[8] = (int_f)H5O_SHMESG_SDSPACE_FLAG; /* Simple Dataspace Message. */ + h5o_flags[9] = (int_f)H5O_SHMESG_DTYPE_FLAG; /* Datatype Message. */ + h5o_flags[10] = (int_f)H5O_SHMESG_FILL_FLAG; /* Fill Value Message. */ + h5o_flags[11] = (int_f)H5O_SHMESG_PLINE_FLAG; /* Filter pipeline message. */ + h5o_flags[12] = (int_f)H5O_SHMESG_ATTR_FLAG; /* Attribute Message. */ h5o_flags[13] = (int_f)H5O_SHMESG_ALL_FLAG; -/* Object header status flag definitions */ - h5o_flags[14] = (int_f)H5O_HDR_CHUNK0_SIZE; /* 2-bit field indicating # of bytes to store the size of chunk 0's data */ + /* Object header status flag definitions */ + h5o_flags[14] = (int_f) + H5O_HDR_CHUNK0_SIZE; /* 2-bit field indicating # of bytes to store the size of chunk 0's data */ h5o_flags[15] = (int_f)H5O_HDR_ATTR_CRT_ORDER_TRACKED; /* Attribute creation order is tracked */ h5o_flags[16] = (int_f)H5O_HDR_ATTR_CRT_ORDER_INDEXED; /* Attribute creation order has index */ - h5o_flags[17] = (int_f)H5O_HDR_ATTR_STORE_PHASE_CHANGE; /* Non-default attribute storage phase change values stored */ - h5o_flags[18] = (int_f)H5O_HDR_STORE_TIMES; /* Store access, modification, change & birth times for object */ + h5o_flags[17] = + (int_f)H5O_HDR_ATTR_STORE_PHASE_CHANGE; /* Non-default attribute storage phase change values stored */ + h5o_flags[18] = + (int_f)H5O_HDR_STORE_TIMES; /* Store access, modification, change & birth times for object */ h5o_flags[19] = (int_f)H5O_HDR_ALL_FLAGS; -/* Maximum shared message values. Number of indexes is 8 to allow room to add - * new types of messages. - */ + /* Maximum shared message values. Number of indexes is 8 to allow room to add + * new types of messages. + */ h5o_flags[20] = (int_f)H5O_SHMESG_MAX_NINDEXES; h5o_flags[21] = (int_f)H5O_SHMESG_MAX_LIST_SIZE; -/* Types of objects in file */ - h5o_flags[22] = (int_f)H5O_TYPE_UNKNOWN; /* Unknown object type */ + /* Types of objects in file */ + h5o_flags[22] = (int_f)H5O_TYPE_UNKNOWN; /* Unknown object type */ h5o_flags[23] = (int_f)H5O_TYPE_GROUP; /* Object is a group */ h5o_flags[24] = (int_f)H5O_TYPE_DATASET; /* Object is a dataset */ h5o_flags[25] = (int_f)H5O_TYPE_NAMED_DATATYPE; /* Object is a named data type */ h5o_flags[26] = (int_f)H5O_TYPE_NTYPES; /* Number of different object types */ -/* Flags for H5Oget_info. - * These flags determine which fields will be filled in in the H5O_info_t - * struct. - */ - h5o_flags[27] = (int_f)H5O_INFO_ALL; /* (H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_NUM_ATTRS) */ - h5o_flags[28] = (int_f)H5O_INFO_BASIC; /* Fill in the fileno, addr, type, and rc fields */ - h5o_flags[29] = (int_f)H5O_INFO_TIME; /* Fill in the atime, mtime, ctime, and btime fields */ + /* Flags for H5Oget_info. + * These flags determine which fields will be filled in in the H5O_info_t + * struct. + */ + h5o_flags[27] = (int_f)H5O_INFO_ALL; /* (H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_NUM_ATTRS) */ + h5o_flags[28] = (int_f)H5O_INFO_BASIC; /* Fill in the fileno, addr, type, and rc fields */ + h5o_flags[29] = (int_f)H5O_INFO_TIME; /* Fill in the atime, mtime, ctime, and btime fields */ h5o_flags[30] = (int_f)H5O_INFO_NUM_ATTRS; /* Fill in the num_attrs field */ -/* Flags for H5Oget_native_info. - * These flags determine which fields will be filled in in the H5O_native_info_t - * struct. - */ + /* Flags for H5Oget_native_info. + * These flags determine which fields will be filled in in the H5O_native_info_t + * struct. + */ h5o_flags[31] = (int_f)H5O_NATIVE_INFO_ALL; /* (H5O_NATIVE_INFO_HDR|H5O_NATIVE_INFO_META_SIZE) */ h5o_flags[32] = (int_f)H5O_NATIVE_INFO_HDR; /* Fill in the hdr field */ h5o_flags[33] = (int_f)H5O_NATIVE_INFO_META_SIZE; /* Fill in the meta_size field */ -/* - * H5P flags - */ - h5p_flags[0] = (hid_t_f)H5P_FILE_CREATE; - h5p_flags[1] = (hid_t_f)H5P_FILE_ACCESS; - h5p_flags[2] = (hid_t_f)H5P_DATASET_CREATE; - h5p_flags[3] = (hid_t_f)H5P_DATASET_XFER; - h5p_flags[4] = (hid_t_f)H5P_FILE_MOUNT; - h5p_flags[5] = (hid_t_f)H5P_DEFAULT; - h5p_flags[6] = (hid_t_f)H5P_ROOT; - h5p_flags[7] = (hid_t_f)H5P_OBJECT_CREATE; - h5p_flags[8] = (hid_t_f)H5P_DATASET_ACCESS; - h5p_flags[9] = (hid_t_f)H5P_GROUP_CREATE; + /* + * H5P flags + */ + h5p_flags[0] = (hid_t_f)H5P_FILE_CREATE; + h5p_flags[1] = (hid_t_f)H5P_FILE_ACCESS; + h5p_flags[2] = (hid_t_f)H5P_DATASET_CREATE; + h5p_flags[3] = (hid_t_f)H5P_DATASET_XFER; + h5p_flags[4] = (hid_t_f)H5P_FILE_MOUNT; + h5p_flags[5] = (hid_t_f)H5P_DEFAULT; + h5p_flags[6] = (hid_t_f)H5P_ROOT; + h5p_flags[7] = (hid_t_f)H5P_OBJECT_CREATE; + h5p_flags[8] = (hid_t_f)H5P_DATASET_ACCESS; + h5p_flags[9] = (hid_t_f)H5P_GROUP_CREATE; h5p_flags[10] = (hid_t_f)H5P_GROUP_ACCESS; h5p_flags[11] = (hid_t_f)H5P_DATATYPE_CREATE; h5p_flags[12] = (hid_t_f)H5P_DATATYPE_ACCESS; @@ -609,22 +682,21 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5p_flags[16] = (hid_t_f)H5P_LINK_CREATE; h5p_flags[17] = (hid_t_f)H5P_LINK_ACCESS; - -/* - * H5P integer flags - */ + /* + * H5P integer flags + */ h5p_flags_int[0] = (int_f)H5P_CRT_ORDER_INDEXED; h5p_flags_int[1] = (int_f)H5P_CRT_ORDER_TRACKED; -/* - * H5R flags - */ + /* + * H5R flags + */ h5r_flags[0] = (int_f)H5R_OBJECT; h5r_flags[1] = (int_f)H5R_DATASET_REGION; -/* - * H5S flags - */ + /* + * H5S flags + */ h5s_hid_flags[0] = (hid_t_f)H5S_ALL; h5s_hsize_flags[0] = (hsize_t_f)H5S_UNLIMITED; @@ -651,19 +723,19 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5s_flags[16] = (int_f)H5S_SEL_HYPERSLABS; h5s_flags[17] = (int_f)H5S_SEL_ALL; -/* - * H5T flags - */ - h5t_flags[0] = (int_f)H5T_NO_CLASS; - h5t_flags[1] = (int_f)H5T_INTEGER; - h5t_flags[2] = (int_f)H5T_FLOAT; - h5t_flags[3] = (int_f)H5T_TIME; - h5t_flags[4] = (int_f)H5T_STRING; - h5t_flags[5] = (int_f)H5T_BITFIELD; - h5t_flags[6] = (int_f)H5T_OPAQUE; - h5t_flags[7] = (int_f)H5T_COMPOUND; - h5t_flags[8] = (int_f)H5T_REFERENCE; - h5t_flags[9] = (int_f)H5T_ENUM; + /* + * H5T flags + */ + h5t_flags[0] = (int_f)H5T_NO_CLASS; + h5t_flags[1] = (int_f)H5T_INTEGER; + h5t_flags[2] = (int_f)H5T_FLOAT; + h5t_flags[3] = (int_f)H5T_TIME; + h5t_flags[4] = (int_f)H5T_STRING; + h5t_flags[5] = (int_f)H5T_BITFIELD; + h5t_flags[6] = (int_f)H5T_OPAQUE; + h5t_flags[7] = (int_f)H5T_COMPOUND; + h5t_flags[8] = (int_f)H5T_REFERENCE; + h5t_flags[9] = (int_f)H5T_ENUM; h5t_flags[10] = (int_f)H5T_ORDER_LE; h5t_flags[11] = (int_f)H5T_ORDER_BE; h5t_flags[12] = (int_f)H5T_ORDER_MIXED; @@ -690,19 +762,19 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5t_flags[33] = (int_f)H5T_DIR_ASCEND; h5t_flags[34] = (int_f)H5T_DIR_DESCEND; -/* - * H5Z flags - */ - h5z_flags[0] = (int_f)H5Z_FILTER_ERROR; - h5z_flags[1] = (int_f)H5Z_FILTER_NONE; - h5z_flags[2] = (int_f)H5Z_FILTER_DEFLATE; - h5z_flags[3] = (int_f)H5Z_FILTER_SHUFFLE; - h5z_flags[4] = (int_f)H5Z_FILTER_FLETCHER32; - h5z_flags[5] = (int_f)H5Z_ERROR_EDC; - h5z_flags[6] = (int_f)H5Z_DISABLE_EDC; - h5z_flags[7] = (int_f)H5Z_ENABLE_EDC; - h5z_flags[8] = (int_f)H5Z_NO_EDC; - h5z_flags[9] = (int_f)H5Z_FILTER_SZIP; + /* + * H5Z flags + */ + h5z_flags[0] = (int_f)H5Z_FILTER_ERROR; + h5z_flags[1] = (int_f)H5Z_FILTER_NONE; + h5z_flags[2] = (int_f)H5Z_FILTER_DEFLATE; + h5z_flags[3] = (int_f)H5Z_FILTER_SHUFFLE; + h5z_flags[4] = (int_f)H5Z_FILTER_FLETCHER32; + h5z_flags[5] = (int_f)H5Z_ERROR_EDC; + h5z_flags[6] = (int_f)H5Z_DISABLE_EDC; + h5z_flags[7] = (int_f)H5Z_ENABLE_EDC; + h5z_flags[8] = (int_f)H5Z_NO_EDC; + h5z_flags[9] = (int_f)H5Z_FILTER_SZIP; h5z_flags[10] = (int_f)H5Z_FLAG_OPTIONAL; h5z_flags[11] = (int_f)H5Z_FILTER_CONFIG_ENCODE_ENABLED; h5z_flags[12] = (int_f)H5Z_FILTER_CONFIG_DECODE_ENABLED; @@ -714,9 +786,9 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5z_flags[18] = (int_f)H5Z_SO_INT; h5z_flags[19] = (int_f)H5Z_SO_INT_MINBITS_DEFAULT; -/* - * H5 Generic flags introduced in version 1.8 - */ + /* + * H5 Generic flags introduced in version 1.8 + */ /* H5_index_t enum struct */ @@ -725,14 +797,13 @@ h5init_flags_c( int_f *h5d_flags, size_t_f *h5d_size_flags, h5_generic_flags[2] = (int_f)H5_INDEX_CRT_ORDER; /* Index on creation order */ h5_generic_flags[3] = (int_f)H5_INDEX_N; /* Index on creation order */ - /* H5_iter_order_t enum struct */ - h5_generic_flags[4] = (int_f)H5_ITER_UNKNOWN; /* Unknown order */ - h5_generic_flags[5] = (int_f)H5_ITER_INC; /* Increasing order */ - h5_generic_flags[6] = (int_f)H5_ITER_DEC; /* Decreasing order */ - h5_generic_flags[7] = (int_f)H5_ITER_NATIVE; /* No particular order, whatever is fastest */ - h5_generic_flags[8] = (int_f)H5_ITER_N; /* Number of iteration orders */ + h5_generic_flags[4] = (int_f)H5_ITER_UNKNOWN; /* Unknown order */ + h5_generic_flags[5] = (int_f)H5_ITER_INC; /* Increasing order */ + h5_generic_flags[6] = (int_f)H5_ITER_DEC; /* Decreasing order */ + h5_generic_flags[7] = (int_f)H5_ITER_NATIVE; /* No particular order, whatever is fastest */ + h5_generic_flags[8] = (int_f)H5_ITER_N; /* Number of iteration orders */ h5_haddr_generic_flags[0] = (haddr_t_f)HADDR_UNDEF; /* undefined address */ @@ -743,12 +814,12 @@ int_f h5init1_flags_c(int_f *h5lib_flags) /******/ { - int ret_value = -1; - unsigned prm_1 = H5_SZIP_EC_OPTION_MASK; - unsigned prm_2 = H5_SZIP_NN_OPTION_MASK; - h5lib_flags[0] = (int_f)prm_1; - h5lib_flags[1] = (int_f)prm_2; - ret_value = 0; + int ret_value = -1; + unsigned prm_1 = H5_SZIP_EC_OPTION_MASK; + unsigned prm_2 = H5_SZIP_NN_OPTION_MASK; + h5lib_flags[0] = (int_f)prm_1; + h5lib_flags[1] = (int_f)prm_2; + ret_value = 0; return ret_value; } @@ -771,7 +842,8 @@ h5open_c(void) { int ret_value = -1; - if (H5open() < 0) return ret_value; + if (H5open() < 0) + return ret_value; ret_value = 0; return ret_value; } @@ -792,7 +864,8 @@ h5close_c(void) { int ret_value = -1; - if (H5close() < 0) return ret_value; + if (H5close() < 0) + return ret_value; ret_value = 0; return ret_value; } @@ -824,14 +897,15 @@ h5get_libversion_c(int_f *majnum, int_f *minnum, int_f *relnum) /******/ { - int ret_value = -1; + int ret_value = -1; unsigned c_majnum, c_minnum, c_relnum; - if (H5get_libversion(&c_majnum, &c_minnum, &c_relnum) < 0) return ret_value; + if (H5get_libversion(&c_majnum, &c_minnum, &c_relnum) < 0) + return ret_value; - *majnum = (int_f)c_majnum; - *minnum = (int_f)c_minnum; - *relnum = (int_f)c_relnum; + *majnum = (int_f)c_majnum; + *minnum = (int_f)c_minnum; + *relnum = (int_f)c_relnum; ret_value = 0; return ret_value; } @@ -861,12 +935,12 @@ int_f h5check_version_c(int_f *majnum, int_f *minnum, int_f *relnum) /******/ { - int ret_value = -1; + int ret_value = -1; unsigned c_majnum, c_minnum, c_relnum; - c_majnum = (unsigned) *majnum; - c_minnum = (unsigned) *minnum; - c_relnum = (unsigned) *relnum; + c_majnum = (unsigned)*majnum; + c_minnum = (unsigned)*minnum; + c_relnum = (unsigned)*relnum; H5check_version(c_majnum, c_minnum, c_relnum); @@ -892,7 +966,8 @@ h5garbage_collect_c(void) { int ret_value = -1; - if (H5garbage_collect() < 0) return ret_value; + if (H5garbage_collect() < 0) + return ret_value; ret_value = 0; return ret_value; } @@ -915,8 +990,8 @@ h5dont_atexit_c(void) { int ret_value = -1; - if (H5dont_atexit() < 0) return ret_value; + if (H5dont_atexit() < 0) + return ret_value; ret_value = 0; return ret_value; } - diff --git a/fortran/src/H5f90.h b/fortran/src/H5f90.h index 655cb9b..373f3d9 100644 --- a/fortran/src/H5f90.h +++ b/fortran/src/H5f90.h @@ -11,7 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #ifndef _H5f90_H #define _H5f90_H @@ -21,12 +20,11 @@ #include "H5f90proto.h" /* Constants used in H5Rff.F90 and H5Rf.c files */ -#define REF_REG_BUF_LEN_F 3 +#define REF_REG_BUF_LEN_F 3 /* Constants used in H5Gf.c files */ #define OBJECT_NAMELEN_DEFAULT_F -1 -#define H5_MAX(a,b) (((a)>(b)) ? (a) : (b)) +#define H5_MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif /* _H5f90_H */ - diff --git a/fortran/src/H5f90i.h b/fortran/src/H5f90i.h index 057edc5..71ce77f 100644 --- a/fortran/src/H5f90i.h +++ b/fortran/src/H5f90i.h @@ -11,7 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #ifndef _H5f90i_H #define _H5f90i_H @@ -25,7 +24,7 @@ */ #define _fcdtocp(desc) (desc) -#if (defined (UNICOS) || defined (_UNICOS)) && !defined(__crayx1) +#if (defined(UNICOS) || defined(_UNICOS)) && !defined(__crayx1) #include @@ -33,7 +32,7 @@ #else -typedef char *_fcd; +typedef char *_fcd; #endif diff --git a/fortran/src/H5f90kit.c b/fortran/src/H5f90kit.c index 6e8c793..458bcd1 100644 --- a/fortran/src/H5f90kit.c +++ b/fortran/src/H5f90kit.c @@ -20,7 +20,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include #include @@ -45,17 +45,17 @@ char * HD5f2cstring(_fcd fdesc, size_t len) /******/ { - char *cstr; /* C string to return */ - char *str; /* Pointer to FORTRAN string */ - int i; /* Local index variable */ + char *cstr; /* C string to return */ + char *str; /* Pointer to FORTRAN string */ + int i; /* Local index variable */ /* Search for the end of the string */ str = _fcdtocp(fdesc); - for(i = (int)len - 1; i >= 0 && HDisspace((int)str[i]) && str[i] == ' '; i--) + for (i = (int)len - 1; i >= 0 && HDisspace((int)str[i]) && str[i] == ' '; i--) /*EMPTY*/; /* Allocate C string */ - if(NULL == (cstr = (char *)HDmalloc((size_t)(i + 2)))) + if (NULL == (cstr = (char *)HDmalloc((size_t)(i + 2)))) return NULL; /* Copy text from FORTRAN to C string */ @@ -65,7 +65,7 @@ HD5f2cstring(_fcd fdesc, size_t len) cstr[i + 1] = '\0'; return cstr; -} /* HD5f2cstring */ +} /* HD5f2cstring */ /****if* H5f90kit/HD5packFstring * NAME @@ -91,15 +91,14 @@ void HD5packFstring(char *src, char *dest, size_t dst_len) /******/ { - size_t src_len=HDstrlen(src); + size_t src_len = HDstrlen(src); /* Copy over the string information, up to the length of the src */ /* (Don't copy the NUL terminator from the C string to the FORTRAN string */ - HDmemcpy(dest,src,MIN(src_len,dst_len)); + HDmemcpy(dest, src, MIN(src_len, dst_len)); /* Pad out any remaining space in the FORTRAN string with ' 's */ - if(src_len #include @@ -40,24 +40,24 @@ #include "H5fort_type_defines.h" /* File pointers for files */ -FILE * c_header; -FILE * fort_header; +FILE *c_header; +FILE *fort_header; #define CFILE "H5f90i_gen.h" #define FFILE "H5fortran_types.F90" /* Prototypes for the write routines */ -void writeTypedef(const char* c_typedef, const char* c_type, int size); -void writeTypedefDefault(const char* c_typedef, int size); -void writeToFiles(const char* c_typedef, const char* fortran_type, const char* c_type, int kind); -void writeToCFileOnly(const char* c_typedef, const char* fortran_type, const char* c_type, int size); -void writeToFilesChr(const char* c_typedef, const char* fortran_type, const char* c_type, int size, const char* kind); +void writeTypedef(const char *c_typedef, const char *c_type, int size); +void writeTypedefDefault(const char *c_typedef, int size); +void writeToFiles(const char *c_typedef, const char *fortran_type, const char *c_type, int kind); +void writeToCFileOnly(const char *c_typedef, const char *fortran_type, const char *c_type, int size); +void writeToFilesChr(const char *c_typedef, const char *fortran_type, const char *c_type, int size, + const char *kind); static void initCfile(void) { - fprintf(c_header, - "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\ + fprintf(c_header, "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\ * Copyright by The HDF Group. *\n\ * Copyright by the Board of Trustees of the University of Illinois. *\n\ * All rights reserved. *\n\ @@ -81,8 +81,7 @@ initCfile(void) static void initFfile(void) { - fprintf(fort_header, - "! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n\ + fprintf(fort_header, "! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n\ ! Copyright by The HDF Group. *\n\ ! Copyright by the Board of Trustees of the University of Illinois. *\n\ ! All rights reserved. *\n\ @@ -101,340 +100,359 @@ initFfile(void) !\n\ ! HDF5 integers\n\ !\n"); - } static void endCfile(void) { - fprintf(c_header, "\n#endif /* _H5f90i_gen_H */\n"); + fprintf(c_header, "\n#endif /* _H5f90i_gen_H */\n"); } static void endFfile(void) { - fprintf(fort_header, "\n INTEGER(SIZE_T), PARAMETER :: OBJECT_NAMELEN_DEFAULT_F = -1\n\n"); - fprintf(fort_header, " END MODULE H5FORTRAN_TYPES\n"); + fprintf(fort_header, "\n INTEGER(SIZE_T), PARAMETER :: OBJECT_NAMELEN_DEFAULT_F = -1\n\n"); + fprintf(fort_header, " END MODULE H5FORTRAN_TYPES\n"); } /* Define a c_int_x type in the C header */ -void writeTypedef(const char* c_typedef, const char* c_type, int size) +void +writeTypedef(const char *c_typedef, const char *c_type, int size) { - fprintf(c_header, "#define c_%s_%u %s\n", c_typedef, size, c_type); + fprintf(c_header, "#define c_%s_%u %s\n", c_typedef, size, c_type); } /* Call this function if there is no matching C type for sizes > 1 */ -void writeTypedefDefault(const char* c_typedef, int size) +void +writeTypedefDefault(const char *c_typedef, int size) { - assert(size %2 == 0); - fprintf(c_header, "typedef struct {c_%s_%u a; c_%s_%u b;} c_%s_%u;\n", c_typedef, size / 2, c_typedef, size / 2, c_typedef, size); + assert(size % 2 == 0); + fprintf(c_header, "typedef struct {c_%s_%u a; c_%s_%u b;} c_%s_%u;\n", c_typedef, size / 2, c_typedef, + size / 2, c_typedef, size); } /* Create matching Fortran and C types by writing to both files */ -void writeToFiles(const char* c_typedef, const char* fortran_type, const char* c_type, int kind) +void +writeToFiles(const char *c_typedef, const char *fortran_type, const char *c_type, int kind) { - fprintf(fort_header, " INTEGER, PARAMETER :: %s = %u\n", fortran_type, kind); - fprintf(c_header, "typedef c_%s_%d %s;\n", c_typedef, kind, c_type); + fprintf(fort_header, " INTEGER, PARAMETER :: %s = %u\n", fortran_type, kind); + fprintf(c_header, "typedef c_%s_%d %s;\n", c_typedef, kind, c_type); } -void writeToFilesChr(const char* c_typedef, const char* fortran_type, const char* c_type, int size, const char* kind) +void +writeToFilesChr(const char *c_typedef, const char *fortran_type, const char *c_type, int size, + const char *kind) { - fprintf(fort_header, " INTEGER, PARAMETER :: %s = %s\n", fortran_type, kind); - fprintf(c_header, "typedef c_%s_%d %s;\n", c_typedef, size, c_type); + fprintf(fort_header, " INTEGER, PARAMETER :: %s = %s\n", fortran_type, kind); + fprintf(c_header, "typedef c_%s_%d %s;\n", c_typedef, size, c_type); } -int main(void) +int +main(void) { - int i; - char chrA[64],chrB[64]; - - int IntKinds[] = H5_FORTRAN_INTEGER_KINDS; - int IntKinds_SizeOf[] = H5_FORTRAN_INTEGER_KINDS_SIZEOF; - int RealKinds[] = H5_FORTRAN_REAL_KINDS; - int RealKinds_SizeOf[] = H5_FORTRAN_REAL_KINDS_SIZEOF; - char Real_C_TYPES[10][32]; - - int FORTRAN_NUM_INTEGER_KINDS=H5_FORTRAN_NUM_INTEGER_KINDS; - int H5_FORTRAN_NUM_REAL_KINDS; -#if H5_FORTRAN_HAVE_C_LONG_DOUBLE!=0 - int found_long_double = 0; + int i; + char chrA[64], chrB[64]; + + int IntKinds[] = H5_FORTRAN_INTEGER_KINDS; + int IntKinds_SizeOf[] = H5_FORTRAN_INTEGER_KINDS_SIZEOF; + int RealKinds[] = H5_FORTRAN_REAL_KINDS; + int RealKinds_SizeOf[] = H5_FORTRAN_REAL_KINDS_SIZEOF; + char Real_C_TYPES[10][32]; + + int FORTRAN_NUM_INTEGER_KINDS = H5_FORTRAN_NUM_INTEGER_KINDS; + int H5_FORTRAN_NUM_REAL_KINDS; +#if H5_FORTRAN_HAVE_C_LONG_DOUBLE != 0 + int found_long_double = 0; #endif - /* Open target files */ - c_header = fopen(CFILE, "w"); - fort_header = fopen(FFILE, "w"); - - /* Write copyright, boilerplate to both files */ - initCfile(); - initFfile(); - - /* (a) define c_int_x */ - - FORTRAN_NUM_INTEGER_KINDS = (int)(sizeof(IntKinds)/sizeof(IntKinds[0])); - H5_FORTRAN_NUM_REAL_KINDS = (int)(sizeof(RealKinds)/sizeof(RealKinds[0])); - - fprintf(fort_header," INTEGER, PARAMETER :: H5_FORTRAN_NUM_INTEGER_KINDS = %d\n", FORTRAN_NUM_INTEGER_KINDS); - - - for(i=0;i< FORTRAN_NUM_INTEGER_KINDS;i++) { - if(sizeof(long long) == IntKinds_SizeOf[i]) - writeTypedef("int", "long long", IntKinds[i]); - else if(sizeof(long) == IntKinds[i]) - writeTypedef("int", "long", IntKinds[i]); - else if(sizeof(int) == IntKinds_SizeOf[i]) - writeTypedef("int", "int", IntKinds[i]); - else if(sizeof(short) == IntKinds_SizeOf[i]) - writeTypedef("int", "short", IntKinds[i]); - else - if(IntKinds_SizeOf[i] == 1) { - writeTypedef("int", "char", IntKinds[i]); - /* Actually, char is not necessarily one byte. - * But if char isn't, then nothing is, so this - * is as close as we can get. */ - } else { - writeTypedefDefault("int",IntKinds[i]); - } - if(sizeof(size_t) == IntKinds_SizeOf[i]) - writeTypedef("size_t", "size_t", IntKinds[i]); - if(sizeof(time_t) == IntKinds_SizeOf[i]) - writeTypedef("time_t", "time_t", IntKinds[i]); - if(sizeof(hsize_t) == IntKinds_SizeOf[i]) - writeTypedef("hsize_t", "hsize_t", IntKinds[i]); - } - - /* (b) Define c_float_x */ - - for(i=0;i< H5_FORTRAN_NUM_REAL_KINDS;i++) { - if (sizeof(float) == RealKinds_SizeOf[i]) { - writeTypedef("float", "float", RealKinds[i]); - strcpy(Real_C_TYPES[i], "C_FLOAT"); - } - else if(sizeof(double) == RealKinds_SizeOf[i]) { - writeTypedef("float", "double", RealKinds[i]); - strcpy(Real_C_TYPES[i], "C_DOUBLE"); + /* Open target files */ + c_header = fopen(CFILE, "w"); + fort_header = fopen(FFILE, "w"); + + /* Write copyright, boilerplate to both files */ + initCfile(); + initFfile(); + + /* (a) define c_int_x */ + + FORTRAN_NUM_INTEGER_KINDS = (int)(sizeof(IntKinds) / sizeof(IntKinds[0])); + H5_FORTRAN_NUM_REAL_KINDS = (int)(sizeof(RealKinds) / sizeof(RealKinds[0])); + + fprintf(fort_header, " INTEGER, PARAMETER :: H5_FORTRAN_NUM_INTEGER_KINDS = %d\n", + FORTRAN_NUM_INTEGER_KINDS); + + for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) { + if (sizeof(long long) == IntKinds_SizeOf[i]) + writeTypedef("int", "long long", IntKinds[i]); + else if (sizeof(long) == IntKinds[i]) + writeTypedef("int", "long", IntKinds[i]); + else if (sizeof(int) == IntKinds_SizeOf[i]) + writeTypedef("int", "int", IntKinds[i]); + else if (sizeof(short) == IntKinds_SizeOf[i]) + writeTypedef("int", "short", IntKinds[i]); + else if (IntKinds_SizeOf[i] == 1) { + writeTypedef("int", "char", IntKinds[i]); + /* Actually, char is not necessarily one byte. + * But if char isn't, then nothing is, so this + * is as close as we can get. */ + } + else { + writeTypedefDefault("int", IntKinds[i]); + } + if (sizeof(size_t) == IntKinds_SizeOf[i]) + writeTypedef("size_t", "size_t", IntKinds[i]); + if (sizeof(time_t) == IntKinds_SizeOf[i]) + writeTypedef("time_t", "time_t", IntKinds[i]); + if (sizeof(hsize_t) == IntKinds_SizeOf[i]) + writeTypedef("hsize_t", "hsize_t", IntKinds[i]); } -#if H5_FORTRAN_HAVE_C_LONG_DOUBLE!=0 - else if(sizeof(long double) == RealKinds_SizeOf[i] && found_long_double == 0) { - writeTypedef("float", "long double", RealKinds[i]); - strcpy(Real_C_TYPES[i], "C_LONG_DOUBLE"); - found_long_double = 1; - } -# ifdef H5_HAVE_FLOAT128 - /* Don't select a higher precision than Fortran can support */ - else if(sizeof(__float128) == RealKinds_SizeOf[i] && found_long_double == 1 && H5_PAC_FC_MAX_REAL_PRECISION > 28) { - writeTypedef("float", "__float128", RealKinds[i]); - strcpy(Real_C_TYPES[i], "C_FLOAT128"); - } -# else - else if(sizeof(long double) == RealKinds_SizeOf[i] && found_long_double == 1 && H5_PAC_FC_MAX_REAL_PRECISION > 28) { - writeTypedef("float", "long double", RealKinds[i]); - strcpy(Real_C_TYPES[i], "C_FLOAT128"); - } -# endif + + /* (b) Define c_float_x */ + + for (i = 0; i < H5_FORTRAN_NUM_REAL_KINDS; i++) { + if (sizeof(float) == RealKinds_SizeOf[i]) { + writeTypedef("float", "float", RealKinds[i]); + strcpy(Real_C_TYPES[i], "C_FLOAT"); + } + else if (sizeof(double) == RealKinds_SizeOf[i]) { + writeTypedef("float", "double", RealKinds[i]); + strcpy(Real_C_TYPES[i], "C_DOUBLE"); + } +#if H5_FORTRAN_HAVE_C_LONG_DOUBLE != 0 + else if (sizeof(long double) == RealKinds_SizeOf[i] && found_long_double == 0) { + writeTypedef("float", "long double", RealKinds[i]); + strcpy(Real_C_TYPES[i], "C_LONG_DOUBLE"); + found_long_double = 1; + } +#ifdef H5_HAVE_FLOAT128 + /* Don't select a higher precision than Fortran can support */ + else if (sizeof(__float128) == RealKinds_SizeOf[i] && found_long_double == 1 && + H5_PAC_FC_MAX_REAL_PRECISION > 28) { + writeTypedef("float", "__float128", RealKinds[i]); + strcpy(Real_C_TYPES[i], "C_FLOAT128"); + } +#else + else if (sizeof(long double) == RealKinds_SizeOf[i] && found_long_double == 1 && + H5_PAC_FC_MAX_REAL_PRECISION > 28) { + writeTypedef("float", "long double", RealKinds[i]); + strcpy(Real_C_TYPES[i], "C_FLOAT128"); + } +#endif #else /* There is no C_LONG_DOUBLE intrinsic */ -# ifdef H5_HAVE_FLOAT128 - /* Don't select a higher precision than Fortran can support */ - else if(sizeof(__float128) == RealKinds_SizeOf[i] ) { - writeTypedef("float", "__float128", RealKinds[i]); - strcpy(Real_C_TYPES[i], "C_FLOAT128"); - } -# else - else if(sizeof(long double) == RealKinds_SizeOf[i] ) { - writeTypedef("float", "long double", RealKinds[i]); - strcpy(Real_C_TYPES[i], "C_FLOAT128"); - } -# endif +#ifdef H5_HAVE_FLOAT128 + /* Don't select a higher precision than Fortran can support */ + else if (sizeof(__float128) == RealKinds_SizeOf[i]) { + writeTypedef("float", "__float128", RealKinds[i]); + strcpy(Real_C_TYPES[i], "C_FLOAT128"); + } +#else + else if (sizeof(long double) == RealKinds_SizeOf[i]) { + writeTypedef("float", "long double", RealKinds[i]); + strcpy(Real_C_TYPES[i], "C_FLOAT128"); + } #endif - else { - printf("\n **** HDF5 WARNING ****\n"); - printf("Fortran REAL(KIND=%d) is %d Bytes, but no corresponding C float type exists of that size\n",RealKinds[i],RealKinds_SizeOf[i]); - printf(" !!! Fortran interfaces will not be generated for REAL(KIND=%d) !!!\n\n",RealKinds[i]); - - RealKinds_SizeOf[i] = -1; - RealKinds[i] = -1; +#endif + else { + printf("\n **** HDF5 WARNING ****\n"); + printf( + "Fortran REAL(KIND=%d) is %d Bytes, but no corresponding C float type exists of that size\n", + RealKinds[i], RealKinds_SizeOf[i]); + printf(" !!! Fortran interfaces will not be generated for REAL(KIND=%d) !!!\n\n", + RealKinds[i]); + + RealKinds_SizeOf[i] = -1; + RealKinds[i] = -1; + } } - } - - /* Now begin defining fortran types. */ - fprintf(c_header, "\n"); - /* haddr_t */ - for(i=0;i< FORTRAN_NUM_INTEGER_KINDS;i++) { - if(IntKinds_SizeOf[i] == H5_SIZEOF_HADDR_T) { - writeToFiles("int","HADDR_T", "haddr_t_f", IntKinds[i]); - break; + /* Now begin defining fortran types. */ + fprintf(c_header, "\n"); + + /* haddr_t */ + for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) { + if (IntKinds_SizeOf[i] == H5_SIZEOF_HADDR_T) { + writeToFiles("int", "HADDR_T", "haddr_t_f", IntKinds[i]); + break; + } + if (i == (FORTRAN_NUM_INTEGER_KINDS - 1)) + /* Error: couldn't find a size for haddr_t */ + return -1; } - if(i == (FORTRAN_NUM_INTEGER_KINDS-1) ) - /* Error: couldn't find a size for haddr_t */ - return -1; - } - - /* hsize_t */ - for(i=0;i< FORTRAN_NUM_INTEGER_KINDS;i++) { - if(IntKinds_SizeOf[i] == H5_SIZEOF_HSIZE_T) { - writeToFiles("hsize_t","HSIZE_T", "hsize_t_f", IntKinds[i]); - break; + + /* hsize_t */ + for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) { + if (IntKinds_SizeOf[i] == H5_SIZEOF_HSIZE_T) { + writeToFiles("hsize_t", "HSIZE_T", "hsize_t_f", IntKinds[i]); + break; + } + if (i == (FORTRAN_NUM_INTEGER_KINDS - 1)) + /* Error: couldn't find a size for hsize_t */ + return -1; } - if(i == (FORTRAN_NUM_INTEGER_KINDS-1) ) - /* Error: couldn't find a size for hsize_t */ - return -1; - } - - /* hssize_t */ - for(i=0;i< FORTRAN_NUM_INTEGER_KINDS;i++) { - if(IntKinds_SizeOf[i] == H5_SIZEOF_HSSIZE_T) { - writeToFiles("int","HSSIZE_T", "hssize_t_f", IntKinds[i]); - break; + + /* hssize_t */ + for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) { + if (IntKinds_SizeOf[i] == H5_SIZEOF_HSSIZE_T) { + writeToFiles("int", "HSSIZE_T", "hssize_t_f", IntKinds[i]); + break; + } + if (i == (FORTRAN_NUM_INTEGER_KINDS - 1)) + /* Error: couldn't find a size for hssize_t */ + return -1; } - if(i == (FORTRAN_NUM_INTEGER_KINDS-1) ) - /* Error: couldn't find a size for hssize_t */ - return -1; - } - - /* off_t */ - for(i=0;i< FORTRAN_NUM_INTEGER_KINDS;i++) { - if(IntKinds_SizeOf[i] == H5_SIZEOF_OFF_T) { - writeToFiles("int","OFF_T", "off_t_f", IntKinds[i]); - break; + + /* off_t */ + for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) { + if (IntKinds_SizeOf[i] == H5_SIZEOF_OFF_T) { + writeToFiles("int", "OFF_T", "off_t_f", IntKinds[i]); + break; + } + if (i == (FORTRAN_NUM_INTEGER_KINDS - 1)) + /* Error: couldn't find a size for off_t */ + return -1; } - if(i == (FORTRAN_NUM_INTEGER_KINDS-1) ) - /* Error: couldn't find a size for off_t */ - return -1; - } - - /* size_t */ - for(i=0;i< FORTRAN_NUM_INTEGER_KINDS;i++) { - if(IntKinds_SizeOf[i] == H5_SIZEOF_SIZE_T) { - writeToFiles("size_t","SIZE_T", "size_t_f", IntKinds[i]); - break; + + /* size_t */ + for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) { + if (IntKinds_SizeOf[i] == H5_SIZEOF_SIZE_T) { + writeToFiles("size_t", "SIZE_T", "size_t_f", IntKinds[i]); + break; + } + if (i == (FORTRAN_NUM_INTEGER_KINDS - 1)) + /* Error: couldn't find a size for size_t */ + return -1; } - if(i == (FORTRAN_NUM_INTEGER_KINDS-1) ) - /* Error: couldn't find a size for size_t */ - return -1; - } - - /* time_t */ - for(i=0;i< FORTRAN_NUM_INTEGER_KINDS;i++) { - if(IntKinds_SizeOf[i] == H5_SIZEOF_TIME_T) { - writeToFiles("time_t","TIME_T", "time_t_f", IntKinds[i]); - break; + + /* time_t */ + for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) { + if (IntKinds_SizeOf[i] == H5_SIZEOF_TIME_T) { + writeToFiles("time_t", "TIME_T", "time_t_f", IntKinds[i]); + break; + } + if (i == (FORTRAN_NUM_INTEGER_KINDS - 1)) + /* Error: couldn't find a size for time_t */ + return -1; } - if(i == (FORTRAN_NUM_INTEGER_KINDS-1) ) - /* Error: couldn't find a size for time_t */ - return -1; - } - /* int */ - writeToFiles("int","Fortran_INTEGER", "int_f", H5_FORTRAN_NATIVE_INTEGER_KIND); + /* int */ + writeToFiles("int", "Fortran_INTEGER", "int_f", H5_FORTRAN_NATIVE_INTEGER_KIND); - /* int_1, int_2, int_4, int_8 */ + /* int_1, int_2, int_4, int_8 */ -/* Defined different KINDs of integers */ + /* Defined different KINDs of integers */ - fprintf(fort_header," INTEGER, DIMENSION(1:%d), PARAMETER :: Fortran_INTEGER_AVAIL_KINDS = (/", FORTRAN_NUM_INTEGER_KINDS); + fprintf(fort_header, " INTEGER, DIMENSION(1:%d), PARAMETER :: Fortran_INTEGER_AVAIL_KINDS = (/", + FORTRAN_NUM_INTEGER_KINDS); - for(i=0;i 0) { - snprintf(chrA, sizeof(chrA), "Fortran_REAL_%s", Real_C_TYPES[i]); - snprintf(chrB, sizeof(chrB), "real_%s_f", Real_C_TYPES[i]); - writeToFiles("float",chrA, chrB, RealKinds[i]); + for (i = 0; i < H5_FORTRAN_NUM_REAL_KINDS; i++) { + if (RealKinds[i] > 0) { + snprintf(chrA, sizeof(chrA), "Fortran_REAL_%s", Real_C_TYPES[i]); + snprintf(chrB, sizeof(chrB), "real_%s_f", Real_C_TYPES[i]); + writeToFiles("float", chrA, chrB, RealKinds[i]); + } } - } - /* hid_t */ - for(i=0;i< FORTRAN_NUM_INTEGER_KINDS;i++) { - if(IntKinds_SizeOf[i] == H5_SIZEOF_HID_T) { - writeToFiles("int","HID_T", "hid_t_f", IntKinds[i]); - break; + /* hid_t */ + for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) { + if (IntKinds_SizeOf[i] == H5_SIZEOF_HID_T) { + writeToFiles("int", "HID_T", "hid_t_f", IntKinds[i]); + break; + } + if (i == (FORTRAN_NUM_INTEGER_KINDS - 1)) + /* Error: couldn't find a size for hid_t */ + return -1; + } + /* real_f */ +#if H5_FORTRAN_HAVE_C_LONG_DOUBLE != 0 + if (H5_FORTRAN_NATIVE_REAL_SIZEOF == sizeof(long double)) { + writeToFilesChr("float", "Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_LONG_DOUBLE"); } - if(i == (FORTRAN_NUM_INTEGER_KINDS-1) ) - /* Error: couldn't find a size for hid_t */ - return -1; - } - /* real_f */ -#if H5_FORTRAN_HAVE_C_LONG_DOUBLE!=0 - if(H5_FORTRAN_NATIVE_REAL_SIZEOF == sizeof(long double)) { - writeToFilesChr("float","Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_LONG_DOUBLE"); - } else + else #endif - if(H5_FORTRAN_NATIVE_REAL_SIZEOF == sizeof(double)) { - writeToFilesChr("float","Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_DOUBLE"); - } else if(H5_FORTRAN_NATIVE_REAL_SIZEOF == sizeof(float)) - writeToFilesChr("float","Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_FLOAT"); - else { - /* No exact match, choose the next highest */ - if(H5_FORTRAN_NATIVE_REAL_SIZEOF > sizeof(long double)) - writeToFilesChr("float","Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_LONG_DOUBLE"); - else if(H5_FORTRAN_NATIVE_REAL_SIZEOF > sizeof(double)) - writeToFilesChr("float","Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_DOUBLE"); - else if(H5_FORTRAN_NATIVE_REAL_SIZEOF > sizeof(float)) - writeToFilesChr("float","Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_FLOAT"); + if (H5_FORTRAN_NATIVE_REAL_SIZEOF == sizeof(double)) { + writeToFilesChr("float", "Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_DOUBLE"); + } + else if (H5_FORTRAN_NATIVE_REAL_SIZEOF == sizeof(float)) + writeToFilesChr("float", "Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_FLOAT"); else { - /* Error: couldn't find a size for real_f */ - printf("Error: couldn't find a size for real_f \n"); - return -1; + /* No exact match, choose the next highest */ + if (H5_FORTRAN_NATIVE_REAL_SIZEOF > sizeof(long double)) + writeToFilesChr("float", "Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_LONG_DOUBLE"); + else if (H5_FORTRAN_NATIVE_REAL_SIZEOF > sizeof(double)) + writeToFilesChr("float", "Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_DOUBLE"); + else if (H5_FORTRAN_NATIVE_REAL_SIZEOF > sizeof(float)) + writeToFilesChr("float", "Fortran_REAL", "real_f", H5_FORTRAN_NATIVE_REAL_KIND, "C_FLOAT"); + else { + /* Error: couldn't find a size for real_f */ + printf("Error: couldn't find a size for real_f \n"); + return -1; + } } - } - /* double_f */ -#if H5_FORTRAN_HAVE_C_LONG_DOUBLE!=0 - if(H5_FORTRAN_NATIVE_DOUBLE_SIZEOF == sizeof(long double)){ - writeToFilesChr("float","Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, "C_LONG_DOUBLE"); - } else + /* double_f */ +#if H5_FORTRAN_HAVE_C_LONG_DOUBLE != 0 + if (H5_FORTRAN_NATIVE_DOUBLE_SIZEOF == sizeof(long double)) { + writeToFilesChr("float", "Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, + "C_LONG_DOUBLE"); + } + else #endif - if(H5_FORTRAN_NATIVE_DOUBLE_SIZEOF == sizeof(double)) { - writeToFilesChr("float","Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, "C_DOUBLE"); - } else if(H5_FORTRAN_NATIVE_DOUBLE_SIZEOF == sizeof(float)) - writeToFilesChr("float","Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, "C_FLOAT"); + if (H5_FORTRAN_NATIVE_DOUBLE_SIZEOF == sizeof(double)) { + writeToFilesChr("float", "Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, "C_DOUBLE"); + } + else if (H5_FORTRAN_NATIVE_DOUBLE_SIZEOF == sizeof(float)) + writeToFilesChr("float", "Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, "C_FLOAT"); #ifdef H5_HAVE_FLOAT128 /* Don't select a higher precision than Fortran can support */ - else if(sizeof(__float128) == H5_FORTRAN_NATIVE_DOUBLE_SIZEOF && H5_PAC_FC_MAX_REAL_PRECISION > 28) { - writeToFilesChr("float","Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, "Fortran_REAL_C_FLOAT128"); + else if (sizeof(__float128) == H5_FORTRAN_NATIVE_DOUBLE_SIZEOF && H5_PAC_FC_MAX_REAL_PRECISION > 28) { + writeToFilesChr("float", "Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, + "Fortran_REAL_C_FLOAT128"); } #else - else if(sizeof(long double) == H5_FORTRAN_NATIVE_DOUBLE_SIZEOF && H5_PAC_FC_MAX_REAL_PRECISION > 28) { - writeToFilesChr("float","Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, "Fortran_REAL_C_FLOAT128"); + else if (sizeof(long double) == H5_FORTRAN_NATIVE_DOUBLE_SIZEOF && H5_PAC_FC_MAX_REAL_PRECISION > 28) { + writeToFilesChr("float", "Fortran_DOUBLE", "double_f", H5_FORTRAN_NATIVE_DOUBLE_KIND, + "Fortran_REAL_C_FLOAT128"); } #endif - else { - /* Error: couldn't find a size for double_f */ - printf("Error: couldn't find a size for double_f \n"); - return -1; - } + else { + /* Error: couldn't find a size for double_f */ + printf("Error: couldn't find a size for double_f \n"); + return -1; + } - /* Need the buffer size for the fortran derived type 'hdset_reg_ref_t_f03' - * in order to be interoperable with C's structure, the C buffer size - * H5R_DSET_REG_REF_BUF_SIZE is (sizeof(haddr_t)+4) - */ + /* Need the buffer size for the fortran derived type 'hdset_reg_ref_t_f03' + * in order to be interoperable with C's structure, the C buffer size + * H5R_DSET_REG_REF_BUF_SIZE is (sizeof(haddr_t)+4) + */ - fprintf(fort_header, " INTEGER, PARAMETER :: H5R_DSET_REG_REF_BUF_SIZE_F = %u\n", H5_SIZEOF_HADDR_T + 4 ); + fprintf(fort_header, " INTEGER, PARAMETER :: H5R_DSET_REG_REF_BUF_SIZE_F = %u\n", + H5_SIZEOF_HADDR_T + 4); - /* Need the buffer size for the fortran derived type 'h5o_token_t' - * in order to be interoperable with C's structure. - */ + /* Need the buffer size for the fortran derived type 'h5o_token_t' + * in order to be interoperable with C's structure. + */ fprintf(fort_header, " INTEGER, PARAMETER :: H5O_MAX_TOKEN_SIZE_F = %u\n", H5O_MAX_TOKEN_SIZE); - /* Close files */ - endCfile(); - endFfile(); - fclose(c_header); - fclose(fort_header); + /* Close files */ + endCfile(); + endFfile(); + fclose(c_header); + fclose(fort_header); - return 0; + return 0; } - diff --git a/fortran/test/t.c b/fortran/test/t.c index 107e8d5..26cb2c0 100644 --- a/fortran/test/t.c +++ b/fortran/test/t.c @@ -21,7 +21,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ****** -*/ + */ #include "t.h" #include "H5Eprivate.h" @@ -40,34 +40,34 @@ * Modifications: *---------------------------------------------------------------------------*/ int_f -nh5_fixname_c(_fcd base_name, size_t_f *base_namelen, hid_t_f* fapl, _fcd full_name, size_t_f *full_namelen) +nh5_fixname_c(_fcd base_name, size_t_f *base_namelen, hid_t_f *fapl, _fcd full_name, size_t_f *full_namelen) { - char *c_base_name = NULL; - char *c_full_name = NULL; - int_f ret_value = 0; + char *c_base_name = NULL; + char *c_full_name = NULL; + int_f ret_value = 0; - /* - * Convert FORTRAN name to C name - */ - if(NULL == (c_base_name = (char *)HD5f2cstring(base_name, (size_t)*base_namelen))) - HGOTO_DONE(FAIL) - if(NULL == (c_full_name = (char *)HDmalloc((size_t)*full_namelen + 1))) - HGOTO_DONE(FAIL) + /* + * Convert FORTRAN name to C name + */ + if (NULL == (c_base_name = (char *)HD5f2cstring(base_name, (size_t)*base_namelen))) + HGOTO_DONE(FAIL) + if (NULL == (c_full_name = (char *)HDmalloc((size_t)*full_namelen + 1))) + HGOTO_DONE(FAIL) - /* - * Call h5_fixname function. - */ - if(NULL == h5_fixname(c_base_name, (hid_t)*fapl, c_full_name, (size_t)*full_namelen + 1)) - HGOTO_DONE(FAIL) - HD5packFstring(c_full_name, _fcdtocp(full_name), (size_t)*full_namelen); + /* + * Call h5_fixname function. + */ + if (NULL == h5_fixname(c_base_name, (hid_t)*fapl, c_full_name, (size_t)*full_namelen + 1)) + HGOTO_DONE(FAIL) + HD5packFstring(c_full_name, _fcdtocp(full_name), (size_t)*full_namelen); done: - if(c_base_name) + if (c_base_name) HDfree(c_base_name); - if(c_full_name) + if (c_full_name) HDfree(c_full_name); - return ret_value; + return ret_value; } /*---------------------------------------------------------------------------- @@ -82,40 +82,41 @@ done: * Modifications: *---------------------------------------------------------------------------*/ int_f -nh5_cleanup_c(_fcd base_name, size_t_f *base_namelen, hid_t_f* fapl) +nh5_cleanup_c(_fcd base_name, size_t_f *base_namelen, hid_t_f *fapl) { - char filename[1024]; - int ret_value = -1; - char *c_base_name[1]; - hid_t c_fapl; + char filename[1024]; + int ret_value = -1; + char *c_base_name[1]; + hid_t c_fapl; - /* - * Define ifile access property list - */ - c_fapl = (hid_t)*fapl; - /*c_fapl = H5Pcreate(H5P_FILE_ACCESS);*/ - /* - * Convert FORTRAN name to C name - */ - c_base_name[0] = (char *)HD5f2cstring(base_name, (size_t)*base_namelen); - if (c_base_name[0] == NULL) goto DONE; + /* + * Define ifile access property list + */ + c_fapl = (hid_t)*fapl; + /*c_fapl = H5Pcreate(H5P_FILE_ACCESS);*/ + /* + * Convert FORTRAN name to C name + */ + c_base_name[0] = (char *)HD5f2cstring(base_name, (size_t)*base_namelen); + if (c_base_name[0] == NULL) + goto DONE; - /* - * Call h5_cleanup function. - */ - /*if (h5_cleanup(c_base_name, c_fapl) != 0) { - ret_value = 0; - goto DONE; - } + /* + * Call h5_cleanup function. + */ + /*if (h5_cleanup(c_base_name, c_fapl) != 0) { + ret_value = 0; + goto DONE; + } */ - h5_fixname(c_base_name[0], c_fapl, filename, sizeof(filename)); - HDremove(filename); - ret_value =0; + h5_fixname(c_base_name[0], c_fapl, filename, sizeof(filename)); + HDremove(filename); + ret_value = 0; DONE: - if (NULL != c_base_name[0]) HDfree(c_base_name[0]); - return ret_value; - + if (NULL != c_base_name[0]) + HDfree(c_base_name[0]); + return ret_value; } /*---------------------------------------------------------------------------- @@ -134,7 +135,7 @@ void nh5_exit_c(int_f *status) { HDexit((int)*status); -} /* h5_exit_c */ +} /* h5_exit_c */ /*---------------------------------------------------------------------------- * Name: h5_env_nocleanup_c @@ -150,8 +151,7 @@ nh5_exit_c(int_f *status) void nh5_env_nocleanup_c(int_f *status) { - *status = (int_f)0; - if (HDgetenv("HDF5_NOCLEANUP")) - *status = (int_f)1; -} /* h5_env_nocleanup_c */ - + *status = (int_f)0; + if (HDgetenv("HDF5_NOCLEANUP")) + *status = (int_f)1; +} /* h5_env_nocleanup_c */ diff --git a/fortran/test/t.h b/fortran/test/t.h index 81d2b5d..aa28ef1 100644 --- a/fortran/test/t.h +++ b/fortran/test/t.h @@ -21,20 +21,16 @@ char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* * Functions from t.c */ -# define nh5_fixname_c H5_FC_FUNC_(h5_fixname_c, H5_FIXNAME_C) -# define nh5_cleanup_c H5_FC_FUNC_(h5_cleanup_c, H5_CLEANUP_C) -# define nh5_exit_c H5_FC_FUNC_(h5_exit_c, H5_EXIT_C) -# define nh5_env_nocleanup_c H5_FC_FUNC_(h5_env_nocleanup_c, H5_ENV_NOCLEANUP_C) +#define nh5_fixname_c H5_FC_FUNC_(h5_fixname_c, H5_FIXNAME_C) +#define nh5_cleanup_c H5_FC_FUNC_(h5_cleanup_c, H5_CLEANUP_C) +#define nh5_exit_c H5_FC_FUNC_(h5_exit_c, H5_EXIT_C) +#define nh5_env_nocleanup_c H5_FC_FUNC_(h5_env_nocleanup_c, H5_ENV_NOCLEANUP_C) -H5_FCTESTDLL int_f nh5_fixname_c -(_fcd base_name, size_t_f *base_namelen, hid_t_f *fapl, _fcd full_name, size_t_f *full_namelen); +H5_FCTESTDLL int_f nh5_fixname_c(_fcd base_name, size_t_f *base_namelen, hid_t_f *fapl, _fcd full_name, + size_t_f *full_namelen); -H5_FCTESTDLL int_f nh5_cleanup_c -(_fcd base_name, size_t_f *base_namelen, hid_t_f *fapl); +H5_FCTESTDLL int_f nh5_cleanup_c(_fcd base_name, size_t_f *base_namelen, hid_t_f *fapl); -H5_FCTESTDLL H5_ATTR_NORETURN void nh5_exit_c -(int_f *status); - -H5_FCTESTDLL void nh5_env_nocleanup_c -(int_f *status); +H5_FCTESTDLL H5_ATTR_NORETURN void nh5_exit_c(int_f *status); +H5_FCTESTDLL void nh5_env_nocleanup_c(int_f *status); diff --git a/hl/c++/examples/ptExampleFL.cpp b/hl/c++/examples/ptExampleFL.cpp index 26cbf09..d0b62da 100644 --- a/hl/c++/examples/ptExampleFL.cpp +++ b/hl/c++/examples/ptExampleFL.cpp @@ -22,56 +22,55 @@ *------------------------------------------------------------------------- */ -const char* FILE_NAME("PTcppexampleFL.h5"); -const char* PT_NAME("/examplePacketTable"); +const char *FILE_NAME("PTcppexampleFL.h5"); +const char *PT_NAME("/examplePacketTable"); -int main(void) +int +main(void) { - herr_t err; /* Return value from function calls */ - hid_t fileID; /* HDF5 identifier for file */ - hid_t plistID; /* HDF5 identifier for property list to use compression */ - hsize_t count; /* Number of records in table */ - int x; /* Temporary counter variable */ + herr_t err; /* Return value from function calls */ + hid_t fileID; /* HDF5 identifier for file */ + hid_t plistID; /* HDF5 identifier for property list to use compression */ + hsize_t count; /* Number of records in table */ + int x; /* Temporary counter variable */ /* Buffers to hold data */ int readBuffer[5]; int writeBuffer[5]; /* Initialize buffers */ - for(x=0; x<5; x++) - { - writeBuffer[x]=x; - readBuffer[x] = -1; + for (x = 0; x < 5; x++) { + writeBuffer[x] = x; + readBuffer[x] = -1; } /* Create a new HDF5 file */ fileID = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(fileID <0) + if (fileID < 0) fprintf(stderr, "Couldn't create file.\n"); /* Prepare property list to set compression, randomly use deflate with compression level 5. */ plistID = H5Pcreate(H5P_DATASET_CREATE); - err = H5Pset_deflate(plistID, 5); - if(err < 0) + err = H5Pset_deflate(plistID, 5); + if (err < 0) fprintf(stderr, "Error setting compression level."); /* Create a fixed-length packet table. */ FL_PacketTable ptable(fileID, plistID, PT_NAME, H5T_NATIVE_INT, 100); - if(! ptable.IsValid()) + if (!ptable.IsValid()) fprintf(stderr, "Unable to create packet table."); /* Append five packets to the packet table, one at a time */ - for(x=0; x<5; x++) - { - err = ptable.AppendPacket( &(writeBuffer[x]) ); - if(err<0) + for (x = 0; x < 5; x++) { + err = ptable.AppendPacket(&(writeBuffer[x])); + if (err < 0) fprintf(stderr, "Error adding record."); } /* Get the number of packets in the packet table. This should be five. */ count = ptable.GetPacketCount(err); - if(err < 0) + if (err < 0) fprintf(stderr, "Error getting packet count."); printf("Number of packets in packet table after five appends: %d\n", count); @@ -80,10 +79,9 @@ int main(void) ptable.ResetIndex(); /* Iterate through packets, read each one back */ - for(x=0; x<5; x++) - { - err = ptable.GetNextPacket( &(readBuffer[x]) ); - if(err < 0) + for (x = 0; x < 5; x++) { + err = ptable.GetNextPacket(&(readBuffer[x])); + if (err < 0) fprintf(stderr, "Error reading record."); printf("Packet %d's value is %d.\n", x, readBuffer[x]); @@ -93,9 +91,8 @@ int main(void) /* out of scope. */ err = H5Fclose(fileID); - if( err < 0 ) + if (err < 0) fprintf(stderr, "Failed to close file.\n"); return 0; } - diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp index 544df0b..55924c2 100644 --- a/hl/c++/src/H5PacketTable.cpp +++ b/hl/c++/src/H5PacketTable.cpp @@ -24,257 +24,278 @@ #include "H5PacketTable.h" - /********************************/ - /* PacketTable superclass */ - /********************************/ - - /* "Open" Constructor - * Opens an existing packet table, which can contain either fixed-length or - * variable-length packets. - */ - PacketTable::PacketTable(hid_t fileID, const char* name) - { - table_id = H5PTopen( fileID, name); - } - - /* "Open" Constructor - will be deprecated because of char* name */ - PacketTable::PacketTable(hid_t fileID, char* name) - { - table_id = H5PTopen( fileID, name); - } - - /* Destructor - * Cleans up the packet table - */ - PacketTable::~PacketTable() - { - H5PTclose( table_id); - } - - /* IsValid - * Returns true if this packet table is valid, false otherwise. - * Use this after the constructor to ensure HDF did not have - * any trouble making or opening the packet table. - */ - bool PacketTable::IsValid() - { - if (H5PTis_valid(table_id) == 0) - return true; - else - return false; - } - - /* IsVariableLength - * Return 1 if this packet table uses variable-length datatype, - * and 0, otherwise. Returns -1 if the table is invalid (not open). - */ - int PacketTable::IsVariableLength() - { - return H5PTis_varlen(table_id); - } - - /* ResetIndex - * Sets the index to point to the first packet in the packet table - */ - void PacketTable::ResetIndex() - { - H5PTcreate_index(table_id); - } - - /* SetIndex - * Sets the index to point to the packet specified by index. - * Returns 0 on success, negative on failure (if index is out of bounds) - */ - int PacketTable::SetIndex(hsize_t index) - { - return H5PTset_index(table_id, index); - } - - /* SetIndex - * Sets the index to point to the packet specified by index. - * Returns 0 on success, negative on failure (if index is out of bounds) - */ - hsize_t PacketTable::GetIndex(int &error) - { - hsize_t index; - - error = H5PTget_index(table_id, &index); - if(error < 0) - return 0; - else - return index; - } - - /* GetPacketCount - * Returns the number of packets in the packet table. Error - * is set to 0 on success. On failure, returns 0 and - * error is set to negative. - */ - hsize_t PacketTable::GetPacketCount(int& error) - { - hsize_t npackets; - - error = H5PTget_num_packets(table_id, &npackets); - return npackets; - } - - /* GetTableId - * Returns the identifier of the packet table - */ - hid_t PacketTable::GetTableId() - { - return table_id; - } - - /* GetDatatype - * Returns the datatype identifier used by the packet table, on success, - * or H5I_INVALID_HID, on failure. - * Note: it is best to avoid using this identifier in applications, unless - * the desired functionality cannot be performed via the packet table ID. - */ - hid_t PacketTable::GetDatatype() - { - return H5PTget_type(table_id); - } - - /* GetDataset - * Returns the dataset identifier associated with the packet table, on - * success, or H5I_INVALID_HID, on failure. - * Note: it is best to avoid using this identifier in applications, unless - * the desired functionality cannot be performed via the packet table ID. - */ - hid_t PacketTable::GetDataset() - { - return H5PTget_dataset(table_id); - } - - /* FreeBuff - * Frees the buffers created when variable-length packets are read. - * Takes the number of hvl_t structs to be freed and a pointer to their - * location in memory. - * Returns 0 on success, negative on error. - */ - int PacketTable::FreeBuff(size_t numStructs, hvl_t * buffer) - { - return H5PTfree_vlen_buff( table_id, numStructs, buffer); - } - - - /********************************/ - /* Fixed-Length Packet Table */ - /********************************/ - - /* Constructor - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the ID of - * the property list to specify compression, the name of the packet table, - * the ID of the datatype, and the size of a memory chunk used in chunking. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize, hid_t plistID) - { - table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); - } - - /* Constructor - deprecated - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the ID of - * the property list to specify compression, the name of the packet table, - * the ID of the datatype, and the size of a memory chunk used in chunking. - * Note: The above constructor has a better prototype, which allows default - * values to be used. This constructor was only released in 1.10.0. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plistID, const char* name, hid_t dtypeID, hsize_t chunkSize) - { - table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); - } - - /* Constructor - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the name of - * the packet table, the ID of the datatype of the set, and the size - * of a memory chunk used in chunking. - * Note: this overload will be deprecated in favor of the constructor above. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression) - { - table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression); - } - - /* "Open" Constructor - * Opens an existing fixed-length packet table. - * Fails if the packet table specified is variable-length. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name) : PacketTable(fileID, name) {} - - /* "Open" Constructor - will be deprecated because of char* name */ - FL_PacketTable::FL_PacketTable(hid_t fileID, char* name) : PacketTable(fileID, name) {} - - /* AppendPacket - * Adds a single packet to the packet table. Takes a pointer - * to the location of the data in memory. - * Returns 0 on success, negative on failure - */ - int FL_PacketTable::AppendPacket(void * data) - { - return H5PTappend(table_id, 1, data); - } - - /* AppendPackets (multiple packets) - * Adds multiple packets to the packet table. Takes the number of packets - * to be added and a pointer to their location in memory. - * Returns 0 on success, -1 on failure. - */ - int FL_PacketTable::AppendPackets(size_t numPackets, void * data) - { - return H5PTappend(table_id, numPackets, data); - } - - /* GetPacket (indexed) - * Gets a single packet from the packet table. Takes the index - * of the packet (with 0 being the first packet) and a pointer - * to memory where the data should be stored. - * Returns 0 on success, negative on failure - */ - int FL_PacketTable::GetPacket(hsize_t index, void * data) - { - return H5PTread_packets(table_id, index, 1, data); - } - - /* GetPackets (multiple packets) - * Gets multiple packets at once, all packets between - * startIndex and endIndex inclusive. Also takes a pointer to - * the memory where these packets should be stored. - * Returns 0 on success, negative on failure. - */ - int FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void * data) - { - // Make sure the range of indexes is valid - if (startIndex > endIndex) - return -1; - - return H5PTread_packets(table_id, startIndex, (size_t)(endIndex-startIndex+1), data); - } - - /* GetNextPacket (single packet) - * Gets the next packet in the packet table. Takes a pointer to - * memory where the packet should be stored. - * Returns 0 on success, negative on failure. Index - * is not advanced to the next packet on failure. - */ - int FL_PacketTable::GetNextPacket(void * data) - { - return H5PTget_next(table_id, 1, data); - } - - /* GetNextPackets (multiple packets) - * Gets the next numPackets packets in the packet table. Takes a - * pointer to memory where these packets should be stored. - * Returns 0 on success, negative on failure. Index - * is not advanced on failure. - */ - int FL_PacketTable::GetNextPackets(size_t numPackets, void * data) - { - return H5PTget_next(table_id, numPackets, data); - } +/********************************/ +/* PacketTable superclass */ +/********************************/ + +/* "Open" Constructor + * Opens an existing packet table, which can contain either fixed-length or + * variable-length packets. + */ +PacketTable::PacketTable(hid_t fileID, const char *name) +{ + table_id = H5PTopen(fileID, name); +} + +/* "Open" Constructor - will be deprecated because of char* name */ +PacketTable::PacketTable(hid_t fileID, char *name) +{ + table_id = H5PTopen(fileID, name); +} + +/* Destructor + * Cleans up the packet table + */ +PacketTable::~PacketTable() +{ + H5PTclose(table_id); +} + +/* IsValid + * Returns true if this packet table is valid, false otherwise. + * Use this after the constructor to ensure HDF did not have + * any trouble making or opening the packet table. + */ +bool +PacketTable::IsValid() +{ + if (H5PTis_valid(table_id) == 0) + return true; + else + return false; +} + +/* IsVariableLength + * Return 1 if this packet table uses variable-length datatype, + * and 0, otherwise. Returns -1 if the table is invalid (not open). + */ +int +PacketTable::IsVariableLength() +{ + return H5PTis_varlen(table_id); +} + +/* ResetIndex + * Sets the index to point to the first packet in the packet table + */ +void +PacketTable::ResetIndex() +{ + H5PTcreate_index(table_id); +} + +/* SetIndex + * Sets the index to point to the packet specified by index. + * Returns 0 on success, negative on failure (if index is out of bounds) + */ +int +PacketTable::SetIndex(hsize_t index) +{ + return H5PTset_index(table_id, index); +} + +/* SetIndex + * Sets the index to point to the packet specified by index. + * Returns 0 on success, negative on failure (if index is out of bounds) + */ +hsize_t +PacketTable::GetIndex(int &error) +{ + hsize_t index; + + error = H5PTget_index(table_id, &index); + if (error < 0) + return 0; + else + return index; +} + +/* GetPacketCount + * Returns the number of packets in the packet table. Error + * is set to 0 on success. On failure, returns 0 and + * error is set to negative. + */ +hsize_t +PacketTable::GetPacketCount(int &error) +{ + hsize_t npackets; + + error = H5PTget_num_packets(table_id, &npackets); + return npackets; +} + +/* GetTableId + * Returns the identifier of the packet table + */ +hid_t +PacketTable::GetTableId() +{ + return table_id; +} + +/* GetDatatype + * Returns the datatype identifier used by the packet table, on success, + * or H5I_INVALID_HID, on failure. + * Note: it is best to avoid using this identifier in applications, unless + * the desired functionality cannot be performed via the packet table ID. + */ +hid_t +PacketTable::GetDatatype() +{ + return H5PTget_type(table_id); +} + +/* GetDataset + * Returns the dataset identifier associated with the packet table, on + * success, or H5I_INVALID_HID, on failure. + * Note: it is best to avoid using this identifier in applications, unless + * the desired functionality cannot be performed via the packet table ID. + */ +hid_t +PacketTable::GetDataset() +{ + return H5PTget_dataset(table_id); +} + +/* FreeBuff + * Frees the buffers created when variable-length packets are read. + * Takes the number of hvl_t structs to be freed and a pointer to their + * location in memory. + * Returns 0 on success, negative on error. + */ +int +PacketTable::FreeBuff(size_t numStructs, hvl_t *buffer) +{ + return H5PTfree_vlen_buff(table_id, numStructs, buffer); +} + +/********************************/ +/* Fixed-Length Packet Table */ +/********************************/ + +/* Constructor + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the ID of + * the property list to specify compression, the name of the packet table, + * the ID of the datatype, and the size of a memory chunk used in chunking. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, const char *name, hid_t dtypeID, hsize_t chunkSize, + hid_t plistID) +{ + table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); +} + +/* Constructor - deprecated + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the ID of + * the property list to specify compression, the name of the packet table, + * the ID of the datatype, and the size of a memory chunk used in chunking. + * Note: The above constructor has a better prototype, which allows default + * values to be used. This constructor was only released in 1.10.0. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plistID, const char *name, hid_t dtypeID, + hsize_t chunkSize) +{ + table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); +} + +/* Constructor + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the name of + * the packet table, the ID of the datatype of the set, and the size + * of a memory chunk used in chunking. + * Note: this overload will be deprecated in favor of the constructor above. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, char *name, hid_t dtypeID, hsize_t chunkSize, int compression) +{ + table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression); +} + +/* "Open" Constructor + * Opens an existing fixed-length packet table. + * Fails if the packet table specified is variable-length. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, const char *name) : PacketTable(fileID, name) +{ +} + +/* "Open" Constructor - will be deprecated because of char* name */ +FL_PacketTable::FL_PacketTable(hid_t fileID, char *name) : PacketTable(fileID, name) +{ +} + +/* AppendPacket + * Adds a single packet to the packet table. Takes a pointer + * to the location of the data in memory. + * Returns 0 on success, negative on failure + */ +int +FL_PacketTable::AppendPacket(void *data) +{ + return H5PTappend(table_id, 1, data); +} + +/* AppendPackets (multiple packets) + * Adds multiple packets to the packet table. Takes the number of packets + * to be added and a pointer to their location in memory. + * Returns 0 on success, -1 on failure. + */ +int +FL_PacketTable::AppendPackets(size_t numPackets, void *data) +{ + return H5PTappend(table_id, numPackets, data); +} + +/* GetPacket (indexed) + * Gets a single packet from the packet table. Takes the index + * of the packet (with 0 being the first packet) and a pointer + * to memory where the data should be stored. + * Returns 0 on success, negative on failure + */ +int +FL_PacketTable::GetPacket(hsize_t index, void *data) +{ + return H5PTread_packets(table_id, index, 1, data); +} + +/* GetPackets (multiple packets) + * Gets multiple packets at once, all packets between + * startIndex and endIndex inclusive. Also takes a pointer to + * the memory where these packets should be stored. + * Returns 0 on success, negative on failure. + */ +int +FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void *data) +{ + // Make sure the range of indexes is valid + if (startIndex > endIndex) + return -1; + + return H5PTread_packets(table_id, startIndex, (size_t)(endIndex - startIndex + 1), data); +} + +/* GetNextPacket (single packet) + * Gets the next packet in the packet table. Takes a pointer to + * memory where the packet should be stored. + * Returns 0 on success, negative on failure. Index + * is not advanced to the next packet on failure. + */ +int +FL_PacketTable::GetNextPacket(void *data) +{ + return H5PTget_next(table_id, 1, data); +} + +/* GetNextPackets (multiple packets) + * Gets the next numPackets packets in the packet table. Takes a + * pointer to memory where these packets should be stored. + * Returns 0 on success, negative on failure. Index + * is not advanced on failure. + */ +int +FL_PacketTable::GetNextPackets(size_t numPackets, void *data) +{ + return H5PTget_next(table_id, numPackets, data); +} /* Removed "ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */ diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h index 2665984..835b9c2 100644 --- a/hl/c++/src/H5PacketTable.h +++ b/hl/c++/src/H5PacketTable.h @@ -28,22 +28,24 @@ #include "H5PTpublic.h" #include "H5api_adpt.h" -class H5_HLCPPDLL PacketTable -{ -public: +class H5_HLCPPDLL PacketTable { + public: /* Null constructor * Sets table_id to "invalid" */ - PacketTable() {table_id = H5I_BADID;} + PacketTable() + { + table_id = H5I_BADID; + } /* "Open" Constructor * Opens an existing packet table, which can contain either fixed-length or * variable-length packets. */ - PacketTable(hid_t fileID, const char* name); + PacketTable(hid_t fileID, const char *name); /* "Open" Constructor - will be deprecated because of char* name */ - PacketTable(hid_t fileID, char* name); + PacketTable(hid_t fileID, char *name); /* Destructor * Cleans up the packet table @@ -80,16 +82,17 @@ public: * Returns the position of the current packet. * On failure, returns 0 and error is set to negative. */ - hsize_t GetIndex(int& error); + hsize_t GetIndex(int &error); /* GetPacketCount * Returns the number of packets in the packet table. Error * is set to 0 on success. On failure, returns 0 and * error is set to negative. */ - hsize_t GetPacketCount(int& error); + hsize_t GetPacketCount(int &error); - hsize_t GetPacketCount() + hsize_t + GetPacketCount() { int ignoreError; return GetPacketCount(ignoreError); @@ -122,22 +125,22 @@ public: * location in memory. * Returns 0 on success, negative on error. */ - int FreeBuff(size_t numStructs, hvl_t * buffer); + int FreeBuff(size_t numStructs, hvl_t *buffer); -protected: + protected: hid_t table_id; }; -class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable -{ -public: +class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable { + public: /* Constructor * Creates a packet table to store either fixed- or variable-length packets. * Takes the ID of the file the packet table will be created in, the ID of * the property list to specify compression, the name of the packet table, * the ID of the datatype, and the size of a memory chunk used in chunking. */ - FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize = 0, hid_t plistID = H5P_DEFAULT); + FL_PacketTable(hid_t fileID, const char *name, hid_t dtypeID, hsize_t chunkSize = 0, + hid_t plistID = H5P_DEFAULT); /* Constructors - deprecated * Creates a packet table in which to store fixed length packets. @@ -148,36 +151,36 @@ public: * Note: these overloaded constructors will be deprecated in favor of the * constructor above. */ - FL_PacketTable(hid_t fileID, hid_t plist_id, const char* name, hid_t dtypeID, hsize_t chunkSize); - FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression = 0); + FL_PacketTable(hid_t fileID, hid_t plist_id, const char *name, hid_t dtypeID, hsize_t chunkSize); + FL_PacketTable(hid_t fileID, char *name, hid_t dtypeID, hsize_t chunkSize, int compression = 0); /* "Open" Constructor * Opens an existing fixed-length packet table. * Fails if the packet table specified is variable-length. */ - FL_PacketTable(hid_t fileID, const char* name); + FL_PacketTable(hid_t fileID, const char *name); /* "Open" Constructor - will be deprecated because of char* name */ - FL_PacketTable(hid_t fileID, char* name); + FL_PacketTable(hid_t fileID, char *name); /* Destructor * Cleans up the packet table */ - virtual ~FL_PacketTable() {}; + virtual ~FL_PacketTable(){}; /* AppendPacket * Adds a single packet to the packet table. Takes a pointer * to the location of the data in memory. * Returns 0 on success, negative on failure */ - int AppendPacket(void * data); + int AppendPacket(void *data); /* AppendPackets (multiple packets) * Adds multiple packets to the packet table. Takes the number of packets * to be added and a pointer to their location in memory. * Returns 0 on success, -1 on failure. */ - int AppendPackets(size_t numPackets, void * data); + int AppendPackets(size_t numPackets, void *data); /* GetPacket (indexed) * Gets a single packet from the packet table. Takes the index @@ -185,7 +188,7 @@ public: * to memory where the data should be stored. * Returns 0 on success, negative on failure */ - int GetPacket(hsize_t index, void * data); + int GetPacket(hsize_t index, void *data); /* GetPackets (multiple packets) * Gets multiple packets at once, all packets between @@ -193,7 +196,7 @@ public: * the memory where these packets should be stored. * Returns 0 on success, negative on failure. */ - int GetPackets(hsize_t startIndex, hsize_t endIndex, void * data); + int GetPackets(hsize_t startIndex, hsize_t endIndex, void *data); /* GetNextPacket (single packet) * Gets the next packet in the packet table. Takes a pointer to @@ -201,7 +204,7 @@ public: * Returns 0 on success, negative on failure. Index * is not advanced to the next packet on failure. */ - int GetNextPacket(void * data); + int GetNextPacket(void *data); /* GetNextPackets (multiple packets) * Gets the next numPackets packets in the packet table. Takes a @@ -209,7 +212,7 @@ public: * Returns 0 on success, negative on failure. Index * is not advanced on failure. */ - int GetNextPackets(size_t numPackets, void * data); + int GetNextPackets(size_t numPackets, void *data); }; /* Removed "#ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */ diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index 52f3a6b..32f7b84 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -22,41 +22,40 @@ using namespace std; #define TEST_FILE "packettest.h5" /* Main test function */ -int main(void) +int +main(void) { herr_t err; herr_t num_errors = 0; /* Create new HDF5 file */ fileID = H5Fcreate(TEST_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(fileID <0) - { + if (fileID < 0) { fprintf(stderr, "Couldn't create file.\n"); num_errors = 1; } else { - num_errors += BasicTest(); + num_errors += BasicTest(); - num_errors += TestCompoundDatatype(); + num_errors += TestCompoundDatatype(); - num_errors += TestGetPacket(); + num_errors += TestGetPacket(); - num_errors += TestGetNext(); + num_errors += TestGetNext(); - num_errors += TestCompress(); + num_errors += TestCompress(); - num_errors += TestErrors(); + num_errors += TestErrors(); - num_errors += SystemTest(); + num_errors += SystemTest(); - /* Test data corruption in packed structs */ - num_errors += TestHDFFV_9758(); + /* Test data corruption in packed structs */ + num_errors += TestHDFFV_9758(); /* Terminate access to the file. */ err = H5Fclose(fileID); - if( err < 0 ) - { + if (err < 0) { fprintf(stderr, "Failed to close file.\n"); num_errors++; } @@ -66,38 +65,39 @@ int main(void) } if (num_errors == 0) - /* ALL TESTS PASSED */ - return 0; + /* ALL TESTS PASSED */ + return 0; else - /* ERRORS */ - return -1; + /* ERRORS */ + return -1; } -const char* BASICTEST_PT("/basicTest"); -int BasicTest() +const char *BASICTEST_PT("/basicTest"); +int +BasicTest() { - herr_t err; - int myRecord; + herr_t err; + int myRecord; hsize_t count; - int error; + int error; printf("Testing %-62s", "basic functionality"); HDfflush(stdout); FL_PacketTable wrapper(fileID, H5P_DEFAULT, BASICTEST_PT, H5T_NATIVE_INT, 1); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; /* Ensure initial count is zero */ count = wrapper.GetPacketCount(error); - if(count != 0 || error != 0) - goto error; + if (count != 0 || error != 0) + goto error; myRecord = 1; /* add some records test */ err = wrapper.AppendPacket(&myRecord); - if(err < 0) + if (err < 0) goto error; myRecord = 2; @@ -106,22 +106,22 @@ int BasicTest() /* get number of records test */ count = wrapper.GetPacketCount(); - if(count != 2) - goto error; + if (count != 2) + goto error; /* get records test */ err = wrapper.GetPacket(0, &myRecord); - if(err < 0) - goto error; + if (err < 0) + goto error; - if(myRecord != 1) - goto error; + if (myRecord != 1) + goto error; err = wrapper.GetPacket(1, &myRecord); - if(err < 0) - goto error; - if(myRecord != 2) - goto error; + if (err < 0) + goto error; + if (myRecord != 2) + goto error; PASSED(); return 0; @@ -131,58 +131,58 @@ error: return 1; } -const char* CMPDTEST_PT("/compoundTest"); -int TestCompoundDatatype() +const char *CMPDTEST_PT("/compoundTest"); +int +TestCompoundDatatype() { - hid_t dtypeID; + hid_t dtypeID; hsize_t count; - int error; + int error; printf("Testing %-62s", "compound datatypes"); HDfflush(stdout); /* Create compound datatype */ - typedef struct - { + typedef struct { short a, b, c; - int e; + int e; } compoundType; - dtypeID = H5Tcreate( H5T_COMPOUND, sizeof(compoundType)); + dtypeID = H5Tcreate(H5T_COMPOUND, sizeof(compoundType)); - H5Tinsert(dtypeID, "abbey", HOFFSET( compoundType, a ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID, "bert", HOFFSET( compoundType, b ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID, "charlie", HOFFSET( compoundType, c ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID, "ebert", HOFFSET( compoundType, e ), H5T_NATIVE_INT); + H5Tinsert(dtypeID, "abbey", HOFFSET(compoundType, a), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID, "bert", HOFFSET(compoundType, b), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID, "charlie", HOFFSET(compoundType, c), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID, "ebert", HOFFSET(compoundType, e), H5T_NATIVE_INT); /* Create packet table using default property list. */ FL_PacketTable wrapper(fileID, H5P_DEFAULT, CMPDTEST_PT, dtypeID, 1); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; compoundType first; first.a = 1; first.b = first.c = 3; - first.e = 5; + first.e = 5; /* Write packet */ wrapper.AppendPacket(&first); count = wrapper.GetPacketCount(error); - if(count != 1) - goto error; + if (count != 1) + goto error; first.a = first.b = first.c = 0; - first.e = 0; + first.e = 0; /* Read packet back */ wrapper.GetPacket(0, &first); - if(first.a != 1) - goto error; - if(first.e != 5) - goto error; + if (first.a != 1) + goto error; + if (first.e != 5) + goto error; PASSED(); @@ -191,17 +191,19 @@ int TestCompoundDatatype() error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(dtypeID); - } H5E_END_TRY; - + } + H5E_END_TRY; H5_FAILED(); return 1; } -const char* GETNEXT_PT("/TestGetNext"); -int TestGetNext() +const char *GETNEXT_PT("/TestGetNext"); +int +TestGetNext() { int error; int record; @@ -214,47 +216,49 @@ int TestGetNext() /* Create a dataset */ FL_PacketTable wrapper(fileID, H5P_DEFAULT, GETNEXT_PT, H5T_NATIVE_INT, 500); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; /* Append 5 records to the dataset */ - for(record = 1; record < 6; record++) + for (record = 1; record < 6; record++) wrapper.AppendPacket(&record); /* Ensure that we can interate through the records and get the right ones */ - for(i = 1; i < 6; i++) - { + for (i = 1; i < 6; i++) { wrapper.GetNextPacket(&record); - if(record != i) - goto error; + if (record != i) + goto error; } /* Reset the index and check that it worked */ wrapper.ResetIndex(); - if(wrapper.GetIndex(error) != 0) goto error; - if(error < 0) goto error; + if (wrapper.GetIndex(error) != 0) + goto error; + if (error < 0) + goto error; /* Ensure that we can interate through the records and get the right ones */ - for(i = 1; i < 6; i++) - { + for (i = 1; i < 6; i++) { error = wrapper.GetNextPacket(&record); - if(record != i || error <0) - goto error; + if (record != i || error < 0) + goto error; } wrapper.SetIndex(1); - if(wrapper.GetIndex(error) != 1) goto error; - if(error < 0) goto error; + if (wrapper.GetIndex(error) != 1) + goto error; + if (error < 0) + goto error; /* Ensure we can get multiple records with our index pointer */ wrapper.GetNextPackets(2, records); - if(records[0] != 2 || records[1] != 3) - goto error; + if (records[0] != 2 || records[1] != 3) + goto error; /* Ensure our pointer was updated correctly */ wrapper.GetNextPacket(&record); - if(record != 4) - goto error; + if (record != 4) + goto error; PASSED(); return 0; @@ -264,28 +268,29 @@ error: return 1; } -const char* COMPRESS_PT("/compressTest"); -int TestCompress() +const char *COMPRESS_PT("/compressTest"); +int +TestCompress() { #ifdef H5_HAVE_FILTER_DEFLATE - unsigned int flags = 0; - unsigned int config = 0; - size_t cd_nelemts = 0; + unsigned int flags = 0; + unsigned int config = 0; + size_t cd_nelemts = 0; printf("Testing %-62s", "compression"); HDfflush(stdout); try { - /* Prepare property list to set compression, randomly use deflate */ - DSetCreatPropList dscreatplist; - dscreatplist.setDeflate(6); + /* Prepare property list to set compression, randomly use deflate */ + DSetCreatPropList dscreatplist; + dscreatplist.setDeflate(6); /* Create packet table with compression. */ FL_PacketTable wrapper(fileID, COMPRESS_PT, H5T_NATIVE_CHAR, 100, dscreatplist.getId()); - /* Close the property list */ - dscreatplist.close(); + /* Close the property list */ + dscreatplist.close(); - /* Verify that the deflate filter is set */ + /* Verify that the deflate filter is set */ /* Create an HDF5 C++ file object */ H5File file; @@ -297,13 +302,14 @@ int TestCompress() DSetCreatPropList dcpl = dset.getCreatePlist(); - char filter_name[8]; + char filter_name[8]; dcpl.getFilterById(H5Z_FILTER_DEFLATE, flags, cd_nelemts, NULL, 8, filter_name, config); - if (HDstrncmp(filter_name, "deflate", 7) != 0) - H5_FAILED() - } catch (Exception e) { - H5_FAILED(); - return 1; + if (HDstrncmp(filter_name, "deflate", 7) != 0) + H5_FAILED() + } + catch (Exception e) { + H5_FAILED(); + return 1; } PASSED(); #else @@ -313,8 +319,9 @@ int TestCompress() return 0; } -const char* PT_TESTGETPT = "/TestGetPacket"; -int TestGetPacket() +const char *PT_TESTGETPT = "/TestGetPacket"; +int +TestGetPacket() { int record; int theRecs[3]; @@ -326,24 +333,23 @@ int TestGetPacket() there is no compression. */ FL_PacketTable wrapper(fileID, PT_TESTGETPT, H5T_NATIVE_INT, 1); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; /* Append 5 records to the dataset */ - for(record = 1; record < 6; record++) + for (record = 1; record < 6; record++) wrapper.AppendPacket(&record); /* Ensure that the records were written properly */ wrapper.GetPacket(1, &record); - if(record != 2) - goto error; + if (record != 2) + goto error; /* Ensure that we can retrieve multiple records */ wrapper.GetPackets(1, 3, theRecs); - for(i = 0; i < 3; i++) - { - if(theRecs[i] != i+2) - goto error; + for (i = 0; i < 3; i++) { + if (theRecs[i] != i + 2) + goto error; } PASSED(); @@ -354,9 +360,10 @@ error: return 1; } -const char* PT_TESTERROR = "/TestErrors"; +const char *PT_TESTERROR = "/TestErrors"; -int TestErrors() +int +TestErrors() { printf("Testing %-62s", "error conditions"); HDfflush(stdout); @@ -364,99 +371,105 @@ int TestErrors() /* Create a dataset */ FL_PacketTable wrapper(fileID, PT_TESTERROR, H5T_NATIVE_INT, 1); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; int record; int records[3]; int error; /* Append 4 records to the dataset */ - for(record = 1; record < 5; record++) + for (record = 1; record < 5; record++) wrapper.AppendPacket(&record); /* Try to confuse functions with bad indexes */ error = wrapper.GetPacket(static_cast(-1), &record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPacket(4, &record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPacket(static_cast(-250), &record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPacket(3000, &record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPacket(1, &record); - if(error < 0) - goto error; + if (error < 0) + goto error; error = wrapper.GetPackets(static_cast(-1), 1, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(2, 4, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(static_cast(-60), static_cast(-62), records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(10, 12, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(0, 2, records); - if(error < 0) - goto error; + if (error < 0) + goto error; error = wrapper.GetPackets(2, 0, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(1, 1, records); - if(error < 0) - goto error; + if (error < 0) + goto error; error = wrapper.GetPackets(1, 3, records); - if(error < 0) - goto error; + if (error < 0) + goto error; wrapper.ResetIndex(); error = wrapper.SetIndex(static_cast(-1)); - if(error >= 0) - goto error; - if(wrapper.GetIndex(error) != 0) goto error; - if(error < 0) goto error; + if (error >= 0) + goto error; + if (wrapper.GetIndex(error) != 0) + goto error; + if (error < 0) + goto error; error = wrapper.GetNextPacket(&record); - if(error < 0) - goto error; - if(record != 1) - goto error; - if(wrapper.GetIndex(error) != 1) goto error; - if(error < 0) goto error; + if (error < 0) + goto error; + if (record != 1) + goto error; + if (wrapper.GetIndex(error) != 1) + goto error; + if (error < 0) + goto error; error = wrapper.SetIndex(20); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetNextPacket(&record); - if(error < 0) - goto error; - if(record != 2) - goto error; + if (error < 0) + goto error; + if (record != 2) + goto error; wrapper.SetIndex(3); error = wrapper.GetNextPacket(&record); - if(error < 0) - goto error; - if(record != 4) - goto error; - if(wrapper.GetIndex(error) != 4) goto error; - if(error < 0) goto error; + if (error < 0) + goto error; + if (record != 4) + goto error; + if (wrapper.GetIndex(error) != 4) + goto error; + if (error < 0) + goto error; error = wrapper.GetNextPacket(&record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; wrapper.ResetIndex(); error = wrapper.GetNextPackets(10, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetNextPackets(0, records); - if(error < 0) - goto error; + if (error < 0) + goto error; PASSED(); return 0; @@ -466,45 +479,44 @@ error: return 1; } -const char* PT_SYSTEMTST1 = "/SystemTest1"; -const char* PT_SYSTEMTST2 = "/SystemTest2"; -int SystemTest() +const char *PT_SYSTEMTST1 = "/SystemTest1"; +const char *PT_SYSTEMTST2 = "/SystemTest2"; +int +SystemTest() { printf("Testing %-62s", "multiple datatypes"); HDfflush(stdout); - hid_t dtypeID1, dtypeID2; + hid_t dtypeID1, dtypeID2; hsize_t count; - int error; + int error; /* Creating two inter-related datatypes. Create two datasets and put * one datatype in each. */ - typedef struct - { + typedef struct { short a, b, c; - int e; + int e; } compoundType; dtypeID1 = H5Tcreate(H5T_COMPOUND, sizeof(compoundType)); - H5Tinsert(dtypeID1, "abbey", HOFFSET( compoundType, a ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID1, "bert", HOFFSET( compoundType, b ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID1, "charlie", HOFFSET( compoundType, c ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID1, "ebert", HOFFSET( compoundType, e ), H5T_NATIVE_INT); + H5Tinsert(dtypeID1, "abbey", HOFFSET(compoundType, a), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID1, "bert", HOFFSET(compoundType, b), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID1, "charlie", HOFFSET(compoundType, c), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID1, "ebert", HOFFSET(compoundType, e), H5T_NATIVE_INT); - typedef struct - { - char f; + typedef struct { + char f; compoundType g; } cType2; dtypeID2 = H5Tcreate(H5T_COMPOUND, sizeof(cType2)); - H5Tinsert(dtypeID2, "f", HOFFSET( cType2, f ), H5T_NATIVE_CHAR); - H5Tinsert(dtypeID2, "g", HOFFSET( cType2, g ), dtypeID1); + H5Tinsert(dtypeID2, "f", HOFFSET(cType2, f), H5T_NATIVE_CHAR); + H5Tinsert(dtypeID2, "g", HOFFSET(cType2, g), dtypeID1); cType2 ct2[10]; - ct2[0].f = 'h'; + ct2[0].f = 'h'; ct2[0].g.a = 9; ct2[0].g.b = -13; ct2[0].g.c = 0; @@ -514,17 +526,17 @@ int SystemTest() FL_PacketTable wrapper1(fileID, PT_SYSTEMTST1, dtypeID1, 1); FL_PacketTable wrapper2(fileID, H5P_DEFAULT, PT_SYSTEMTST2, dtypeID2, 1); - if(! wrapper1.IsValid()) - goto error; - if(! wrapper2.IsValid()) - goto error; + if (!wrapper1.IsValid()) + goto error; + if (!wrapper2.IsValid()) + goto error; /* Write and read packets, ensure that nothing is unusual */ wrapper2.AppendPacket(ct2); count = wrapper1.GetPacketCount(); - if(count != 0) - goto error; + if (count != 0) + goto error; compoundType ct1[10]; ct1[0].a = 31; @@ -541,13 +553,17 @@ int SystemTest() wrapper1.ResetIndex(); wrapper1.GetNextPacket(&ct1[1]); wrapper2.GetPacket(1, &ct2[2]); - if(wrapper1.GetIndex(error) != 1) goto error; - if(error < 0) goto error; - if(wrapper2.GetIndex(error) != 0) goto error; - if(error < 0) goto error; + if (wrapper1.GetIndex(error) != 1) + goto error; + if (error < 0) + goto error; + if (wrapper2.GetIndex(error) != 0) + goto error; + if (error < 0) + goto error; - if(ct1[1].b != ct2[2].g.b) - goto error; + if (ct1[1].b != ct2[2].g.b) + goto error; H5Tclose(dtypeID1); H5Tclose(dtypeID2); @@ -556,10 +572,12 @@ int SystemTest() return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(dtypeID1); H5Tclose(dtypeID2); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return 1; @@ -580,33 +598,32 @@ error: * 2016/10/25 -BMR *------------------------------------------------------------------------- */ -#pragma pack() // default alignment -const char* ABHI_PT("/abhiTest"); -const hsize_t NUM_PACKETS = 5; -const int STRING_LENGTH = 19; // including terminating NULL -int TestHDFFV_9758() +#pragma pack() // default alignment +const char * ABHI_PT("/abhiTest"); +const hsize_t NUM_PACKETS = 5; +const int STRING_LENGTH = 19; // including terminating NULL +int +TestHDFFV_9758() { - hid_t strtype; - hid_t compound_type; + hid_t strtype; + hid_t compound_type; herr_t err; - struct s1_t - { - int a; - float b; + struct s1_t { + int a; + float b; double c; - char d[STRING_LENGTH]; // null terminated string - int e; + char d[STRING_LENGTH]; // null terminated string + int e; }; s1_t s1[NUM_PACKETS]; - for (hsize_t i = 0; i < NUM_PACKETS; i++) - { + for (hsize_t i = 0; i < NUM_PACKETS; i++) { s1[i].a = i; s1[i].b = 1.f * static_cast(i * i); s1[i].c = 1. / (i + 1); HDsprintf(s1[i].d, "string%d", (int)i); - s1[i].e = 100+i; + s1[i].e = 100 + i; } printf("Testing %-62s", "data corruption in packed structs (HDFFV-9758)"); @@ -615,73 +632,70 @@ int TestHDFFV_9758() // Build a compound datatype compound_type = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); if (compound_type < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); if (err < 0) - goto error; + goto error; - strtype = H5Tcopy (H5T_C_S1); + strtype = H5Tcopy(H5T_C_S1); if (compound_type < 0) - goto error; - err = H5Tset_size (strtype, STRING_LENGTH); /* create string */ + goto error; + err = H5Tset_size(strtype, STRING_LENGTH); /* create string */ if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "d_name", HOFFSET(s1_t, d), strtype); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "e_name", HOFFSET(s1_t, e), H5T_NATIVE_INT); if (err < 0) - goto error; + goto error; { // so ptable will go out of scope before PASSED - // Create a packet table - FL_PacketTable ptable(fileID, "/examplePacketTable", compound_type, 1); - if (!ptable.IsValid()) - goto error; - - // Add packets to the table - for (size_t i = 0; i < NUM_PACKETS; i++) - { - /* Appends one packet at the current position */ - err = ptable.AppendPacket(s1 + i); - if (err < 0) goto error; - } + // Create a packet table + FL_PacketTable ptable(fileID, "/examplePacketTable", compound_type, 1); + if (!ptable.IsValid()) + goto error; + + // Add packets to the table + for (size_t i = 0; i < NUM_PACKETS; i++) { + /* Appends one packet at the current position */ + err = ptable.AppendPacket(s1 + i); + if (err < 0) + goto error; + } - // Check packet count - const hsize_t count = ptable.GetPacketCount(err); - if (err < 0) - goto error; + // Check packet count + const hsize_t count = ptable.GetPacketCount(err); + if (err < 0) + goto error; - if (count != NUM_PACKETS) - { - std::cerr - << "Number of packets in packet table should be " << NUM_PACKETS - << " but is " << count << endl; - } - - // Read and verify the data - ptable.ResetIndex(); - for (size_t i = 0; i < NUM_PACKETS; i++) - { - s1_t s2; - HDmemset(&s2, 0, sizeof(s1_t)); - err = ptable.GetNextPacket(&s2); - if (err < 0) - goto error; + if (count != NUM_PACKETS) { + std::cerr << "Number of packets in packet table should be " << NUM_PACKETS << " but is " << count + << endl; + } - if (s2.a != s1[i].a || s2.e != s1[i].e) - goto error; - else if (HDstrcmp(s2.d, s1[i].d)) - goto error; - } + // Read and verify the data + ptable.ResetIndex(); + for (size_t i = 0; i < NUM_PACKETS; i++) { + s1_t s2; + HDmemset(&s2, 0, sizeof(s1_t)); + err = ptable.GetNextPacket(&s2); + if (err < 0) + goto error; + + if (s2.a != s1[i].a || s2.e != s1[i].e) + goto error; + else if (HDstrcmp(s2.d, s1[i].d)) + goto error; + } } // end of ptable block PASSED(); @@ -689,13 +703,14 @@ int TestHDFFV_9758() error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(strtype); H5Tclose(compound_type); H5Fclose(fileID); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return 1; } - diff --git a/hl/examples/ex_ds1.c b/hl/examples/ex_ds1.c index 1e0c592..af8b581 100644 --- a/hl/examples/ex_ds1.c +++ b/hl/examples/ex_ds1.c @@ -14,99 +14,93 @@ #include "hdf5.h" #include "hdf5_hl.h" - -#define RANK 2 -#define DIM_DATA 12 -#define DIM1_SIZE 3 -#define DIM2_SIZE 4 -#define DIM0 0 -#define DIM1 1 - -#define DSET_NAME "Mydata" -#define DS_1_NAME "Yaxis" -#define DS_2_NAME "Xaxis" - -int main(void) +#define RANK 2 +#define DIM_DATA 12 +#define DIM1_SIZE 3 +#define DIM2_SIZE 4 +#define DIM0 0 +#define DIM1 1 + +#define DSET_NAME "Mydata" +#define DS_1_NAME "Yaxis" +#define DS_2_NAME "Xaxis" + +int +main(void) { - hid_t fid; /* file ID */ - hid_t did; /* dataset ID */ - hid_t dsid; /* DS dataset ID */ - int rank = RANK; /* rank of data dataset */ - int rankds = 1; /* rank of DS dataset */ - hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ - int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12}; /* data of data dataset */ - hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */ - hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */ - float s1_wbuf[DIM1_SIZE] = {10,20,30}; /* data of DS 1 dataset */ - int s2_wbuf[DIM2_SIZE] = {10,20,50,100}; /* data of DS 2 dataset */ - - - /* create a file using default properties */ - if ((fid=H5Fcreate("ex_ds1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) - goto out; - - /* make a dataset */ - if (H5LTmake_dataset_int(fid,DSET_NAME,rank,dims,buf)<0) - goto out; - - /* make a DS dataset for the first dimension */ - if (H5LTmake_dataset_float(fid,DS_1_NAME,rankds,s1_dim,s1_wbuf)<0) - goto out; - - /* make a DS dataset for the second dimension */ - if (H5LTmake_dataset_int(fid,DS_2_NAME,rankds,s2_dim,s2_wbuf)<0) - goto out; - - -/*------------------------------------------------------------------------- - * attach the DS_1_NAME dimension scale to DSET_NAME at dimension 0 - *------------------------------------------------------------------------- - */ - - /* get the dataset id for DSET_NAME */ - if ((did = H5Dopen2(fid,DSET_NAME, H5P_DEFAULT))<0) - goto out; - - /* get the DS dataset id */ - if ((dsid = H5Dopen2(fid,DS_1_NAME, H5P_DEFAULT))<0) - goto out; - - /* attach the DS_1_NAME dimension scale to DSET_NAME at dimension index 0 */ - if (H5DSattach_scale(did,dsid,DIM0)<0) - goto out; - - /* close DS id */ - if (H5Dclose(dsid)<0) - goto out; - -/*------------------------------------------------------------------------- - * attach the DS_2_NAME dimension scale to DSET_NAME - *------------------------------------------------------------------------- - */ - - /* get the DS dataset id */ - if ((dsid = H5Dopen2(fid,DS_2_NAME, H5P_DEFAULT))<0) - goto out; - - /* attach the DS_2_NAME dimension scale to DSET_NAME as the 2nd dimension (index 1) */ - if (H5DSattach_scale(did,dsid,DIM1)<0) - goto out; - - /* close DS id */ - if (H5Dclose(dsid)<0) - goto out; - - /* close file */ - H5Fclose(fid); - - return 0; + hid_t fid; /* file ID */ + hid_t did; /* dataset ID */ + hid_t dsid; /* DS dataset ID */ + int rank = RANK; /* rank of data dataset */ + int rankds = 1; /* rank of DS dataset */ + hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */ + int buf[DIM_DATA] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; /* data of data dataset */ + hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */ + hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */ + float s1_wbuf[DIM1_SIZE] = {10, 20, 30}; /* data of DS 1 dataset */ + int s2_wbuf[DIM2_SIZE] = {10, 20, 50, 100}; /* data of DS 2 dataset */ + + /* create a file using default properties */ + if ((fid = H5Fcreate("ex_ds1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* make a dataset */ + if (H5LTmake_dataset_int(fid, DSET_NAME, rank, dims, buf) < 0) + goto out; + + /* make a DS dataset for the first dimension */ + if (H5LTmake_dataset_float(fid, DS_1_NAME, rankds, s1_dim, s1_wbuf) < 0) + goto out; + + /* make a DS dataset for the second dimension */ + if (H5LTmake_dataset_int(fid, DS_2_NAME, rankds, s2_dim, s2_wbuf) < 0) + goto out; + + /*------------------------------------------------------------------------- + * attach the DS_1_NAME dimension scale to DSET_NAME at dimension 0 + *------------------------------------------------------------------------- + */ + + /* get the dataset id for DSET_NAME */ + if ((did = H5Dopen2(fid, DSET_NAME, H5P_DEFAULT)) < 0) + goto out; + + /* get the DS dataset id */ + if ((dsid = H5Dopen2(fid, DS_1_NAME, H5P_DEFAULT)) < 0) + goto out; + + /* attach the DS_1_NAME dimension scale to DSET_NAME at dimension index 0 */ + if (H5DSattach_scale(did, dsid, DIM0) < 0) + goto out; + + /* close DS id */ + if (H5Dclose(dsid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * attach the DS_2_NAME dimension scale to DSET_NAME + *------------------------------------------------------------------------- + */ + + /* get the DS dataset id */ + if ((dsid = H5Dopen2(fid, DS_2_NAME, H5P_DEFAULT)) < 0) + goto out; + + /* attach the DS_2_NAME dimension scale to DSET_NAME as the 2nd dimension (index 1) */ + if (H5DSattach_scale(did, dsid, DIM1) < 0) + goto out; + + /* close DS id */ + if (H5Dclose(dsid) < 0) + goto out; + + /* close file */ + H5Fclose(fid); + + return 0; out: - printf("Error on return function...Exiting\n"); - return 1; - + printf("Error on return function...Exiting\n"); + return 1; } - - - diff --git a/hl/examples/ex_image1.c b/hl/examples/ex_image1.c index 56a175d..ef9410b 100644 --- a/hl/examples/ex_image1.c +++ b/hl/examples/ex_image1.c @@ -14,56 +14,55 @@ #include "hdf5.h" #include "hdf5_hl.h" -#define WIDTH 400 -#define HEIGHT 200 -#define PAL_ENTRIES 9 -unsigned char buf [ WIDTH*HEIGHT ]; +#define WIDTH 400 +#define HEIGHT 200 +#define PAL_ENTRIES 9 +unsigned char buf[WIDTH * HEIGHT]; -int main( void ) +int +main(void) { - hid_t file_id; - hsize_t pal_dims[] = {PAL_ENTRIES,3}; - size_t i, j; - int n, space; - unsigned char pal[PAL_ENTRIES*3] = { /* create a palette with 9 colors */ - 0,0,168, /* dark blue */ - 0,0,252, /* blue */ - 0,168,252, /* ocean blue */ - 84,252,252, /* light blue */ - 168,252,168, /* light green */ - 0,252,168, /* green */ - 252,252,84, /* yellow */ - 252,168,0, /* orange */ - 252,0,0}; /* red */ + hid_t file_id; + hsize_t pal_dims[] = {PAL_ENTRIES, 3}; + size_t i, j; + int n, space; + unsigned char pal[PAL_ENTRIES * 3] = { /* create a palette with 9 colors */ + 0, 0, 168, /* dark blue */ + 0, 0, 252, /* blue */ + 0, 168, 252, /* ocean blue */ + 84, 252, 252, /* light blue */ + 168, 252, 168, /* light green */ + 0, 252, 168, /* green */ + 252, 252, 84, /* yellow */ + 252, 168, 0, /* orange */ + 252, 0, 0}; /* red */ - /* create an image of 9 values divided evenly by the array */ - space = WIDTH*HEIGHT / PAL_ENTRIES; - for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ ) - { - buf[i] = n; - if ( j > space ) - { - n++; - j=0; - } - if (n>PAL_ENTRIES-1) n=0; - } + /* create an image of 9 values divided evenly by the array */ + space = WIDTH * HEIGHT / PAL_ENTRIES; + for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT; i++, j++) { + buf[i] = n; + if (j > space) { + n++; + j = 0; + } + if (n > PAL_ENTRIES - 1) + n = 0; + } - /* create a new HDF5 file using default properties. */ - file_id = H5Fcreate( "ex_image1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); + /* create a new HDF5 file using default properties. */ + file_id = H5Fcreate("ex_image1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - /* make the image */ - H5IMmake_image_8bit( file_id, "image1", (hsize_t)WIDTH, (hsize_t)HEIGHT, buf ); + /* make the image */ + H5IMmake_image_8bit(file_id, "image1", (hsize_t)WIDTH, (hsize_t)HEIGHT, buf); - /* make a palette */ - H5IMmake_palette( file_id, "pallete", pal_dims, pal ); + /* make a palette */ + H5IMmake_palette(file_id, "pallete", pal_dims, pal); - /* attach the palette to the image */ - H5IMlink_palette( file_id, "image1", "pallete" ); + /* attach the palette to the image */ + H5IMlink_palette(file_id, "image1", "pallete"); - /* close the file. */ - H5Fclose( file_id ); - - return 0; + /* close the file. */ + H5Fclose(file_id); + return 0; } diff --git a/hl/examples/ex_image2.c b/hl/examples/ex_image2.c index 5abf723..2a38430 100644 --- a/hl/examples/ex_image2.c +++ b/hl/examples/ex_image2.c @@ -16,90 +16,89 @@ #include #include -#define DATA_FILE1 "image8.txt" -#define DATA_FILE2 "image24pixel.txt" -#define IMAGE1_NAME "image8bit" -#define IMAGE2_NAME "image24bitpixel" -#define PAL_NAME "palette" -#define PAL_ENTRIES 256 - -static int read_data(const char* file_name, hsize_t *width, hsize_t *height ); -unsigned char *gbuf = NULL; /* global buffer for image data */ - -int main( void ) +#define DATA_FILE1 "image8.txt" +#define DATA_FILE2 "image24pixel.txt" +#define IMAGE1_NAME "image8bit" +#define IMAGE2_NAME "image24bitpixel" +#define PAL_NAME "palette" +#define PAL_ENTRIES 256 + +static int read_data(const char *file_name, hsize_t *width, hsize_t *height); +unsigned char *gbuf = NULL; /* global buffer for image data */ + +int +main(void) { - hid_t file_id; /* HDF5 file identifier */ - hsize_t width; /* width of image */ - hsize_t height; /* height of image */ - unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */ - hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */ - herr_t i, n; - - /* create a new HDF5 file using default properties. */ - file_id = H5Fcreate( "ex_image2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - - /* read first data file */ - if (read_data(DATA_FILE1,&width,&height)<0) - goto out; - - /* make the image */ - H5IMmake_image_8bit( file_id, IMAGE1_NAME, width, height, gbuf ); - if (gbuf) { - free(gbuf); - gbuf = NULL; - } - -/*------------------------------------------------------------------------- - * define a palette, blue to red tones - *------------------------------------------------------------------------- - */ - for ( i=0, n=0; i @@ -24,113 +23,85 @@ *------------------------------------------------------------------------- */ -#define NFIELDS (hsize_t) 5 -#define NRECORDS (hsize_t) 8 -#define NRECORDS_WRITE (hsize_t) 2 -#define TABLE_NAME "table" +#define NFIELDS (hsize_t)5 +#define NRECORDS (hsize_t)8 +#define NRECORDS_WRITE (hsize_t)2 +#define TABLE_NAME "table" -int main( void ) +int +main(void) { - typedef struct Particle - { - char name[16]; - int lati; - int longi; - float pressure; - double temperature; - } Particle; - - Particle dst_buf[NRECORDS]; - - /* Calculate the size and the offsets of our struct members in memory */ - size_t dst_size = sizeof( Particle ); - size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ), - HOFFSET( Particle, lati ), - HOFFSET( Particle, longi ), - HOFFSET( Particle, pressure ), - HOFFSET( Particle, temperature )}; - - Particle p = {"zero",0,0, 0.0f, 0.0}; - size_t dst_sizes[NFIELDS] = { sizeof( p.name), - sizeof( p.lati), - sizeof( p.longi), - sizeof( p.pressure), - sizeof( p.temperature)}; - - /* Define field information */ - const char *field_names[NFIELDS] = - { "Name","Latitude", "Longitude", "Pressure", "Temperature" }; - /* Fill value particle */ - Particle fill_data[1] = - { {"no data",-1,-1, -99.0f, -99.0} }; - hid_t field_type[NFIELDS]; - hid_t string_type; - hid_t file_id; - hsize_t chunk_size = 10; - hsize_t start; /* Record to start reading/writing */ - hsize_t nrecords; /* Number of records to read/write */ - int i; - - /* Define 2 new particles to write */ - Particle particle_in[NRECORDS_WRITE] = - { {"zero",0,0, 0.0f, 0.0}, - {"one",10,10, 1.0f, 10.0} }; - - /* Initialize the field field_type */ - string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, 16 ); - field_type[0] = string_type; - field_type[1] = H5T_NATIVE_INT; - field_type[2] = H5T_NATIVE_INT; - field_type[3] = H5T_NATIVE_FLOAT; - field_type[4] = H5T_NATIVE_DOUBLE; - -/* Create a new file using default properties. */ - file_id = H5Fcreate( "ex_table_03.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - - /* Make the table */ - H5TBmake_table( "Table Title", - file_id, - TABLE_NAME, - NFIELDS, - NRECORDS, - dst_size, - field_names, - dst_offset, - field_type, - chunk_size, - fill_data, - 0, /* no compression */ - NULL ); /* no data written */ - - - /* Overwrite 2 records starting at record 0 */ - start = 0; - nrecords = NRECORDS_WRITE; - H5TBwrite_records( file_id, TABLE_NAME, start, nrecords, dst_size, dst_offset, - dst_sizes, particle_in); - - /* read the table */ - H5TBread_table( file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf ); - - /* print it by rows */ - for (i=0; i @@ -24,142 +23,111 @@ *------------------------------------------------------------------------- */ -#define NFIELDS (hsize_t) 5 -#define NRECORDS (hsize_t) 8 -#define NRECORDS_ADD (hsize_t) 3 -#define TABLE_NAME "table" - - +#define NFIELDS (hsize_t)5 +#define NRECORDS (hsize_t)8 +#define NRECORDS_ADD (hsize_t)3 +#define TABLE_NAME "table" -int main( void ) +int +main(void) { - typedef struct Particle - { - char name[16]; - int lati; - int longi; - float pressure; - double temperature; - } Particle; - - /* Define a subset of Particle, with latitude and longitude fields */ - typedef struct Position - { - int lati; - int longi; - } Position; - - /* Calculate the type_size and the offsets of our struct members */ - Particle dst_buf[NRECORDS]; - size_t dst_size = sizeof( Particle ); - size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ), - HOFFSET( Particle, lati ), - HOFFSET( Particle, longi ), - HOFFSET( Particle, pressure ), - HOFFSET( Particle, temperature )}; - size_t dst_sizes[NFIELDS] = { sizeof( dst_buf[0].name), - sizeof( dst_buf[0].lati), - sizeof( dst_buf[0].longi), - sizeof( dst_buf[0].pressure), - sizeof( dst_buf[0].temperature)}; - - size_t field_offset_pos[2] = { HOFFSET( Position, lati ), - HOFFSET( Position, longi )}; - - /* Initially no data */ - Particle *p_data = NULL; - - /* Define field information */ - const char *field_names[NFIELDS] = - { "Name","Latitude", "Longitude", "Pressure", "Temperature" }; - hid_t field_type[NFIELDS]; - hid_t string_type; - hid_t file_id; - hsize_t chunk_size = 10; - Particle fill_data[1] = - { {"no data",-1,-1, -99.0f, -99.0} }; /* Fill value particle */ - int compress = 0; - hsize_t nfields; - hsize_t start; /* Record to start reading/writing */ - hsize_t nrecords; /* Number of records to read/write */ - int i; - - /* Define new values for the field "Pressure" */ - float pressure_in [NRECORDS_ADD] = - { 0.0f,1.0f,2.0f}; - int field_index_pre[1] = { 3 }; - int field_index_pos[2] = { 1,2 }; - - /* Define new values for the fields "Latitude,Longitude" */ - Position position_in[NRECORDS_ADD] = { {0,0}, - {10,10}, - {20,20} }; - - size_t field_sizes_pos[2]= - { - sizeof(position_in[0].longi), - sizeof(position_in[0].lati) - }; - - size_t field_sizes_pre[1]= - { - sizeof(float) - }; - - /* Initialize the field field_type */ - string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, 16 ); - field_type[0] = string_type; - field_type[1] = H5T_NATIVE_INT; - field_type[2] = H5T_NATIVE_INT; - field_type[3] = H5T_NATIVE_FLOAT; - field_type[4] = H5T_NATIVE_DOUBLE; - - /* Create a new file using default properties. */ - file_id = H5Fcreate( "ex_table_05.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - - /* Make the table */ - H5TBmake_table( "Table Title", file_id, TABLE_NAME,NFIELDS,NRECORDS, - dst_size,field_names, dst_offset, field_type, - chunk_size, fill_data, compress, p_data ); - - /* Write the pressure field starting at record 2 */ - nfields = 1; - start = 2; - nrecords = NRECORDS_ADD; - H5TBwrite_fields_index( file_id, TABLE_NAME, nfields, field_index_pre, start, nrecords, - sizeof( float ), 0, field_sizes_pre, pressure_in ); - - - /* Write the new longitude and latitude information starting at record 2 */ - nfields = 2; - start = 2; - nrecords = NRECORDS_ADD; - H5TBwrite_fields_index( file_id, TABLE_NAME, nfields, field_index_pos, start, nrecords, - sizeof( Position ), field_offset_pos, field_sizes_pos, position_in ); - - - /* read the table */ - H5TBread_table( file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf ); - - /* print it by rows */ - for (i=0; i #include - /*------------------------------------------------------------------------- * private functions *------------------------------------------------------------------------- */ -herr_t H5IM_get_palette(hid_t loc_id, - const char *image_name, - int pal_number, - hid_t tid, - void *pal_data); +herr_t H5IM_get_palette(hid_t loc_id, const char *image_name, int pal_number, hid_t tid, void *pal_data); /*------------------------------------------------------------------------- * Function: H5IMmake_image_8bitf @@ -48,77 +43,76 @@ herr_t H5IM_get_palette(hid_t loc_id, *------------------------------------------------------------------------- */ -herr_t H5IMmake_image_8bitf(hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - int_f *buf) +herr_t +H5IMmake_image_8bitf(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, int_f *buf) { - hid_t did; /* dataset ID */ - hid_t sid; /* space ID */ - hsize_t dims[IMAGE8_RANK]; /* dimensions */ + hid_t did; /* dataset ID */ + hid_t sid; /* space ID */ + hsize_t dims[IMAGE8_RANK]; /* dimensions */ - /* initialize the image dimensions */ - dims[0] = height; - dims[1] = width; + /* initialize the image dimensions */ + dims[0] = height; + dims[1] = width; -/*------------------------------------------------------------------------- - * create and write the dataset - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * create and write the dataset + *------------------------------------------------------------------------- + */ - /* create the data space for the dataset. */ - if((sid = H5Screate_simple(IMAGE8_RANK, dims, NULL)) < 0) - return -1; - - /* create the dataset as H5T_NATIVE_UCHAR */ - if((did = H5Dcreate2(loc_id, dset_name, H5T_NATIVE_UINT8, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - - /* write with memory type H5T_NATIVE_INT */ - /* Use long type if Fortran integer is 8 bytes and C long long is also 8 bytes*/ - /* Fail if otherwise */ - if(buf) { - if(sizeof(int_f) == sizeof(int)) { - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - return -1; - } else if(sizeof(int_f) == sizeof(long)) { - if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - return -1; - } else if(sizeof(int_f) == sizeof(long long)) { - if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - return -1; - } else - return -1; - } - - /* close */ - if(H5Dclose(did) < 0) - return -1; - if(H5Sclose(sid) < 0) - return -1; + /* create the data space for the dataset. */ + if ((sid = H5Screate_simple(IMAGE8_RANK, dims, NULL)) < 0) + return -1; -/*------------------------------------------------------------------------- - * attach the specification attributes - *------------------------------------------------------------------------- - */ + /* create the dataset as H5T_NATIVE_UCHAR */ + if ((did = H5Dcreate2(loc_id, dset_name, H5T_NATIVE_UINT8, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + return -1; - /* attach the CLASS attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) - return -1; + /* write with memory type H5T_NATIVE_INT */ + /* Use long type if Fortran integer is 8 bytes and C long long is also 8 bytes*/ + /* Fail if otherwise */ + if (buf) { + if (sizeof(int_f) == sizeof(int)) { + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } + else if (sizeof(int_f) == sizeof(long)) { + if (H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } + else if (sizeof(int_f) == sizeof(long long)) { + if (H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } + else + return -1; + } - /* attach the VERSION attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) - return -1; + /* close */ + if (H5Dclose(did) < 0) + return -1; + if (H5Sclose(sid) < 0) + return -1; - /* attach the IMAGE_SUBCLASS attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED") < 0) - return -1; + /*------------------------------------------------------------------------- + * attach the specification attributes + *------------------------------------------------------------------------- + */ - return 0; -} + /* attach the CLASS attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) + return -1; + /* attach the VERSION attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) + return -1; + + /* attach the IMAGE_SUBCLASS attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED") < 0) + return -1; + return 0; +} /*------------------------------------------------------------------------- * Function: H5IMmake_image_24bitf @@ -146,96 +140,94 @@ herr_t H5IMmake_image_8bitf(hid_t loc_id, *------------------------------------------------------------------------- */ -herr_t H5IMmake_image_24bitf(hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const char *interlace, - int_f *buf) +herr_t +H5IMmake_image_24bitf(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, + const char *interlace, int_f *buf) { - hid_t did; /* dataset ID */ - hid_t sid; /* space ID */ - hsize_t dims[IMAGE24_RANK]; /* dimensions */ + hid_t did; /* dataset ID */ + hid_t sid; /* space ID */ + hsize_t dims[IMAGE24_RANK]; /* dimensions */ + + /*------------------------------------------------------------------------- + * attach the image dimensions according to the interlace mode + *------------------------------------------------------------------------- + */ + if (strcmp(interlace, "INTERLACE_PIXEL") == 0) { + /* Number of color planes is defined as the third dimension */ + dims[0] = height; + dims[1] = width; + dims[2] = IMAGE24_RANK; + } + else if (strcmp(interlace, "INTERLACE_PLANE") == 0) { + /* Number of color planes is defined as the first dimension */ + dims[0] = IMAGE24_RANK; + dims[1] = height; + dims[2] = width; + } + else + return -1; -/*------------------------------------------------------------------------- - * attach the image dimensions according to the interlace mode - *------------------------------------------------------------------------- - */ - if(strcmp(interlace, "INTERLACE_PIXEL") == 0) { - /* Number of color planes is defined as the third dimension */ - dims[0] = height; - dims[1] = width; - dims[2] = IMAGE24_RANK; - } - else - if(strcmp(interlace, "INTERLACE_PLANE") == 0) { - /* Number of color planes is defined as the first dimension */ - dims[0] = IMAGE24_RANK; - dims[1] = height; - dims[2] = width; - } - else - return -1; + /*------------------------------------------------------------------------- + * create and write the dataset + *------------------------------------------------------------------------- + */ -/*------------------------------------------------------------------------- - * create and write the dataset - *------------------------------------------------------------------------- - */ + /* create the data space for the dataset. */ + if ((sid = H5Screate_simple(IMAGE24_RANK, dims, NULL)) < 0) + return -1; - /* create the data space for the dataset. */ - if((sid = H5Screate_simple(IMAGE24_RANK, dims, NULL)) < 0) - return -1; - - /* create the dataset as H5T_NATIVE_UCHAR */ - if((did = H5Dcreate2(loc_id, dset_name, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - - /* write with memory type H5T_NATIVE_INT */ - if(buf) { - if(sizeof(int_f) == sizeof(int)) { - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - return -1; - } else if(sizeof(int_f) == sizeof(long)) { - if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - return -1; - } else if(sizeof(int_f) == sizeof(long long)) { - if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - return -1; - } else - return -1; - } - - /* close */ - if(H5Dclose(did) < 0) - return -1; - if(H5Sclose(sid) < 0) - return -1; + /* create the dataset as H5T_NATIVE_UCHAR */ + if ((did = H5Dcreate2(loc_id, dset_name, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + return -1; -/*------------------------------------------------------------------------- - * attach the specification attributes - *------------------------------------------------------------------------- - */ + /* write with memory type H5T_NATIVE_INT */ + if (buf) { + if (sizeof(int_f) == sizeof(int)) { + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } + else if (sizeof(int_f) == sizeof(long)) { + if (H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } + else if (sizeof(int_f) == sizeof(long long)) { + if (H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } + else + return -1; + } - /* Attach the CLASS attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) - return -1; + /* close */ + if (H5Dclose(did) < 0) + return -1; + if (H5Sclose(sid) < 0) + return -1; - /* Attach the VERSION attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) - return -1; + /*------------------------------------------------------------------------- + * attach the specification attributes + *------------------------------------------------------------------------- + */ - /* Attach the IMAGE_SUBCLASS attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR") < 0) - return -1; + /* Attach the CLASS attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) + return -1; - /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ - if(H5LTset_attribute_string(loc_id, dset_name, "INTERLACE_MODE", interlace) < 0) - return -1; + /* Attach the VERSION attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) + return -1; - return 0; + /* Attach the IMAGE_SUBCLASS attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR") < 0) + return -1; -} + /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ + if (H5LTset_attribute_string(loc_id, dset_name, "INTERLACE_MODE", interlace) < 0) + return -1; + return 0; +} /*------------------------------------------------------------------------- * Function: H5IMread_imagef @@ -258,33 +250,32 @@ herr_t H5IMmake_image_24bitf(hid_t loc_id, *------------------------------------------------------------------------- */ -herr_t H5IMread_imagef(hid_t loc_id, - const char *dset_name, - int_f *buf) +herr_t +H5IMread_imagef(hid_t loc_id, const char *dset_name, int_f *buf) { - hid_t did; - hid_t tid; + hid_t did; + hid_t tid; /* open the dataset */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* determine appropriate datatype to use */ - if(sizeof(int_f) == sizeof(int)) + if (sizeof(int_f) == sizeof(int)) tid = H5T_NATIVE_INT; - else if(sizeof(int_f) == sizeof(long)) + else if (sizeof(int_f) == sizeof(long)) tid = H5T_NATIVE_LONG; - else if(sizeof(int_f) == sizeof(long long)) + else if (sizeof(int_f) == sizeof(long long)) tid = H5T_NATIVE_LLONG; else goto out; /* read to memory */ - if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Dclose(did)) + if (H5Dclose(did)) return -1; return 0; @@ -294,7 +285,6 @@ out: return -1; } - /*------------------------------------------------------------------------- * Function: H5IMmake_palettef * @@ -318,75 +308,75 @@ out: *------------------------------------------------------------------------- */ -herr_t H5IMmake_palettef(hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - int_f *pal_data) +herr_t +H5IMmake_palettef(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, int_f *pal_data) { - hid_t did; /* dataset ID */ - hid_t sid; /* space ID */ - int has_pal; + hid_t did; /* dataset ID */ + hid_t sid; /* space ID */ + int has_pal; - /* Check if the dataset already exists */ - has_pal = H5LTfind_dataset(loc_id, pal_name); + /* Check if the dataset already exists */ + has_pal = H5LTfind_dataset(loc_id, pal_name); - /* It exists. Return */ - if(has_pal == 1) - return 0; + /* It exists. Return */ + if (has_pal == 1) + return 0; -/*------------------------------------------------------------------------- - * create and write the dataset - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * create and write the dataset + *------------------------------------------------------------------------- + */ - /* create the data space for the dataset. */ - if((sid = H5Screate_simple(2, pal_dims, NULL)) < 0) - return -1; - - /* create the dataset as H5T_NATIVE_UCHAR */ - if((did = H5Dcreate2(loc_id, pal_name, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - - /* write with memory type H5T_NATIVE_INT */ - if(pal_data) { - if(sizeof(int_f) == sizeof(int)) { - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) - return -1; - } else if(sizeof(int_f) == sizeof(long)) { - if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) - return -1; - } else if(sizeof(int_f) == sizeof(long long)) { - if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) - return -1; - } else - return -1; - } - - /* close */ - if(H5Dclose(did) < 0) - return -1; - if(H5Sclose(sid) < 0) - return -1; + /* create the data space for the dataset. */ + if ((sid = H5Screate_simple(2, pal_dims, NULL)) < 0) + return -1; -/*------------------------------------------------------------------------- - * attach the specification attributes - *------------------------------------------------------------------------- - */ + /* create the dataset as H5T_NATIVE_UCHAR */ + if ((did = H5Dcreate2(loc_id, pal_name, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + return -1; - /* Attach the attribute "CLASS" to the >>palette<< dataset*/ - if(H5LTset_attribute_string(loc_id, pal_name, "CLASS", PALETTE_CLASS) < 0) - return -1; + /* write with memory type H5T_NATIVE_INT */ + if (pal_data) { + if (sizeof(int_f) == sizeof(int)) { + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) + return -1; + } + else if (sizeof(int_f) == sizeof(long)) { + if (H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) + return -1; + } + else if (sizeof(int_f) == sizeof(long long)) { + if (H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) + return -1; + } + else + return -1; + } - /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ - if(H5LTset_attribute_string(loc_id, pal_name, "PAL_VERSION", "1.2") < 0) - return -1; + /* close */ + if (H5Dclose(did) < 0) + return -1; + if (H5Sclose(sid) < 0) + return -1; - return 0; + /*------------------------------------------------------------------------- + * attach the specification attributes + *------------------------------------------------------------------------- + */ -} + /* Attach the attribute "CLASS" to the >>palette<< dataset*/ + if (H5LTset_attribute_string(loc_id, pal_name, "CLASS", PALETTE_CLASS) < 0) + return -1; + /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ + if (H5LTset_attribute_string(loc_id, pal_name, "PAL_VERSION", "1.2") < 0) + return -1; + + return 0; +} /*------------------------------------------------------------------------- * Function: H5IMget_palettef @@ -411,20 +401,17 @@ herr_t H5IMmake_palettef(hid_t loc_id, *------------------------------------------------------------------------- */ -herr_t H5IMget_palettef(hid_t loc_id, - const char *image_name, - int pal_number, - int_f *pal_data) +herr_t +H5IMget_palettef(hid_t loc_id, const char *image_name, int pal_number, int_f *pal_data) { - if(sizeof(int_f) == sizeof(int)) - return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_INT,pal_data); - else if(sizeof(int_f) == sizeof(long)) - return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LONG,pal_data); - else if(sizeof(int_f) == sizeof(long long)) - return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LLONG,pal_data); - else - return -1; - + if (sizeof(int_f) == sizeof(int)) + return H5IM_get_palette(loc_id, image_name, pal_number, H5T_NATIVE_INT, pal_data); + else if (sizeof(int_f) == sizeof(long)) + return H5IM_get_palette(loc_id, image_name, pal_number, H5T_NATIVE_LONG, pal_data); + else if (sizeof(int_f) == sizeof(long long)) + return H5IM_get_palette(loc_id, image_name, pal_number, H5T_NATIVE_LLONG, pal_data); + else + return -1; } /*------------------------------------------------------------------------- @@ -452,96 +439,88 @@ herr_t H5IMget_palettef(hid_t loc_id, * *------------------------------------------------------------------------- */ -herr_t H5IM_get_palette(hid_t loc_id, - const char *image_name, - int pal_number, - hid_t tid, - void *pal_data) +herr_t +H5IM_get_palette(hid_t loc_id, const char *image_name, int pal_number, hid_t tid, void *pal_data) { - hid_t image_id; - int has_pal; - hid_t attr_type; - hid_t attr_id; - hid_t attr_space_id; - hid_t attr_class; - hssize_t n_refs; - size_t dim_ref; - hobj_ref_t *refbuf; /* buffer to read references */ - hid_t pal_id; - - /* Open the dataset. */ - if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) - return -1; - - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - has_pal = H5IM_find_palette(image_id); + hid_t image_id; + int has_pal; + hid_t attr_type; + hid_t attr_id; + hid_t attr_space_id; + hid_t attr_class; + hssize_t n_refs; + size_t dim_ref; + hobj_ref_t *refbuf; /* buffer to read references */ + hid_t pal_id; + + /* Open the dataset. */ + if ((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + return -1; - if(has_pal == 1) - { + /* Try to find the attribute "PALETTE" on the >>image<< dataset */ + has_pal = H5IM_find_palette(image_id); - if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0) - goto out; + if (has_pal == 1) { - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if ((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0) + goto out; - if((attr_class = H5Tget_class(attr_type)) < 0) - goto out; + if ((attr_type = H5Aget_type(attr_id)) < 0) + goto out; - /* Check if it is really a reference */ - if(attr_class == H5T_REFERENCE) - { + if ((attr_class = H5Tget_class(attr_type)) < 0) + goto out; - /* Get the reference(s) */ - if((attr_space_id = H5Aget_space(attr_id)) < 0) - goto out; + /* Check if it is really a reference */ + if (attr_class == H5T_REFERENCE) { - n_refs = H5Sget_simple_extent_npoints(attr_space_id); + /* Get the reference(s) */ + if ((attr_space_id = H5Aget_space(attr_id)) < 0) + goto out; - dim_ref = (size_t)n_refs; + n_refs = H5Sget_simple_extent_npoints(attr_space_id); - refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * dim_ref); + dim_ref = (size_t)n_refs; - if(H5Aread(attr_id, attr_type, refbuf) < 0) - goto out; + refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * dim_ref); - /* Get the palette id */ - if((pal_id = H5Rdereference2(image_id, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) - goto out; + if (H5Aread(attr_id, attr_type, refbuf) < 0) + goto out; - /* Read the palette dataset using the memory type TID */ - if(H5Dread(pal_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) - goto out; + /* Get the palette id */ + if ((pal_id = H5Rdereference2(image_id, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) + goto out; - if(H5Sclose(attr_space_id) < 0) - goto out; + /* Read the palette dataset using the memory type TID */ + if (H5Dread(pal_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) + goto out; - /* close the dereferenced dataset */ - if(H5Dclose(pal_id) < 0) - goto out; + if (H5Sclose(attr_space_id) < 0) + goto out; - HDfree(refbuf); + /* close the dereferenced dataset */ + if (H5Dclose(pal_id) < 0) + goto out; - } /* H5T_REFERENCE */ + HDfree(refbuf); - if(H5Tclose(attr_type) < 0) - goto out; + } /* H5T_REFERENCE */ - /* Close the attribute. */ - if(H5Aclose(attr_id) < 0) - goto out; + if (H5Tclose(attr_type) < 0) + goto out; - } + /* Close the attribute. */ + if (H5Aclose(attr_id) < 0) + goto out; + } - /* Close the image dataset. */ - if(H5Dclose(image_id) < 0) - return -1; + /* Close the image dataset. */ + if (H5Dclose(image_id) < 0) + return -1; - return 0; + return 0; out: - H5Dclose(image_id); - return -1; - - + H5Dclose(image_id); + return -1; } diff --git a/hl/fortran/src/H5IMcc.h b/hl/fortran/src/H5IMcc.h index a65669d..34d3a4e 100644 --- a/hl/fortran/src/H5IMcc.h +++ b/hl/fortran/src/H5IMcc.h @@ -22,34 +22,16 @@ extern "C" { #endif +herr_t H5IMmake_image_8bitf(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, int_f *buf); -herr_t H5IMmake_image_8bitf( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - int_f *buf ); - -herr_t H5IMmake_image_24bitf( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const char *interlace, - int_f *buf); - -herr_t H5IMread_imagef( hid_t loc_id, - const char *dset_name, - int_f *buf ); - -herr_t H5IMmake_palettef( hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - int_f *pal_data ); - -herr_t H5IMget_palettef( hid_t loc_id, - const char *image_name, - int pal_number, - int_f *pal_data ); +herr_t H5IMmake_image_24bitf(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, + const char *interlace, int_f *buf); +herr_t H5IMread_imagef(hid_t loc_id, const char *dset_name, int_f *buf); + +herr_t H5IMmake_palettef(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, int_f *pal_data); + +herr_t H5IMget_palettef(hid_t loc_id, const char *image_name, int pal_number, int_f *pal_data); #ifdef __cplusplus } diff --git a/hl/fortran/src/H5IMfc.c b/hl/fortran/src/H5IMfc.c index cafd623..f892e51 100644 --- a/hl/fortran/src/H5IMfc.c +++ b/hl/fortran/src/H5IMfc.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* This files contains C stubs for H5D Fortran APIs */ @@ -18,51 +18,47 @@ #include "H5Eprivate.h" /*------------------------------------------------------------------------- -* Function: h5immake_image_8bit_c -* -* Purpose: Call H5IMmake_image_8bit -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5immake_image_8bit_c + * + * Purpose: Call H5IMmake_image_8bit + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5immake_image_8bit_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *width, - hsize_t_f *height, - int_f *buf) +h5immake_image_8bit_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *width, hsize_t_f *height, + int_f *buf) { int ret_value = -1; herr_t ret; hid_t c_loc_id; - char *c_name = NULL; - hsize_t w = (hsize_t)*width; - hsize_t h = (hsize_t)*height; + char * c_name = NULL; + hsize_t w = (hsize_t)*width; + hsize_t h = (hsize_t)*height; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * call H5IMmake_image_8bitf function. - */ + * call H5IMmake_image_8bitf function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5IMmake_image_8bitf(c_loc_id,c_name,w,h,buf); + ret = H5IMmake_image_8bitf(c_loc_id, c_name, w, h, buf); if (ret < 0) goto done; @@ -70,54 +66,49 @@ h5immake_image_8bit_c (hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; - - } /*------------------------------------------------------------------------- -* Function: h5imread_image_c -* -* Purpose: Call H5IMread_image -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5imread_image_c + * + * Purpose: Call H5IMread_image + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imread_image_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *buf) +h5imread_image_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *buf) { - int ret_value = -1; - herr_t ret; - char *c_name = NULL; + int ret_value = -1; + herr_t ret; + char * c_name = NULL; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * call H5IMread_image function. - */ - ret = H5IMread_imagef((hid_t)*loc_id,c_name,buf); + * call H5IMread_image function. + */ + ret = H5IMread_imagef((hid_t)*loc_id, c_name, buf); if (ret < 0) goto done; @@ -125,52 +116,46 @@ h5imread_image_c (hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5immake_image_24bit_c -* -* Purpose: Call H5IMmake_image_24bit -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5immake_image_24bit_c + * + * Purpose: Call H5IMmake_image_24bit + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5immake_image_24bit_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *ilen, - _fcd il, - hsize_t_f *width, - hsize_t_f *height, - void *buf) +h5immake_image_24bit_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *ilen, _fcd il, + hsize_t_f *width, hsize_t_f *height, void *buf) { int ret_value = -1; herr_t ret; hid_t c_loc_id; - char *c_name = NULL; - char *c_il = NULL; - hsize_t w = (hsize_t)*width; - hsize_t h = (hsize_t)*height; + char * c_name = NULL; + char * c_il = NULL; + hsize_t w = (hsize_t)*width; + hsize_t h = (hsize_t)*height; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; @@ -180,11 +165,11 @@ h5immake_image_24bit_c (hid_t_f *loc_id, goto done; /* - * call H5IMmake_image_24bitf function. - */ + * call H5IMmake_image_24bitf function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5IMmake_image_24bitf(c_loc_id,c_name,w,h,c_il,(int_f *)buf); + ret = H5IMmake_image_24bitf(c_loc_id, c_name, w, h, c_il, (int_f *)buf); if (ret < 0) goto done; @@ -192,238 +177,218 @@ h5immake_image_24bit_c (hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_il!=NULL) + if (c_il != NULL) HDfree(c_il); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5imget_image_info_c -* -* Purpose: Call H5IMget_image_info -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5imget_image_info_c + * + * Purpose: Call H5IMget_image_info + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imget_image_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *width, - hsize_t_f *height, - hsize_t_f *planes, - hsize_t_f *npals, - size_t_f *ilen, - _fcd interlace) +h5imget_image_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *width, hsize_t_f *height, + hsize_t_f *planes, hsize_t_f *npals, size_t_f *ilen, _fcd interlace) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - hsize_t c_width; - hsize_t c_height; - hsize_t c_planes; - hssize_t c_npals; - char *c_buf=NULL; /* buffer to hold C string */ + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + hsize_t c_width; + hsize_t c_height; + hsize_t c_planes; + hssize_t c_npals; + char * c_buf = NULL; /* buffer to hold C string */ /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * allocate buffer to hold name of an attribute - */ - if ((c_buf = (char *)HDmalloc((size_t)*ilen +1)) == NULL) + * allocate buffer to hold name of an attribute + */ + if ((c_buf = (char *)HDmalloc((size_t)*ilen + 1)) == NULL) goto done; /* - * call H5IMget_image_info function. - */ + * call H5IMget_image_info function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5IMget_image_info(c_loc_id,c_name,&c_width,&c_height,&c_planes,c_buf,&c_npals); + ret = H5IMget_image_info(c_loc_id, c_name, &c_width, &c_height, &c_planes, c_buf, &c_npals); if (ret < 0) goto done; - *width = (hsize_t_f) c_width; - *height = (hsize_t_f) c_height; - *planes = (hsize_t_f) c_planes; - *npals = (hsize_t_f) c_npals; + *width = (hsize_t_f)c_width; + *height = (hsize_t_f)c_height; + *planes = (hsize_t_f)c_planes; + *npals = (hsize_t_f)c_npals; /* - * convert C name to FORTRAN and place it in the given buffer - */ + * convert C name to FORTRAN and place it in the given buffer + */ HD5packFstring(c_buf, _fcdtocp(interlace), (size_t)*ilen); ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_buf!=NULL) + if (c_buf != NULL) HDfree(c_buf); return ret_value; } - /*------------------------------------------------------------------------- -* Function: h5imis_image_c -* -* Purpose: Call H5IMis_image -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5imis_image_c + * + * Purpose: Call H5IMis_image + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imis_image_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name) +h5imis_image_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name) { - hid_t c_loc_id; - char *c_name = NULL; - herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + herr_t ret; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return -1; + if (c_name == NULL) + return -1; /* - * call H5LTget_dataset_ndims function. - */ + * call H5LTget_dataset_ndims function. + */ c_loc_id = (hid_t)*loc_id; ret = H5IMis_image(c_loc_id, c_name); - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret; - } - /*------------------------------------------------------------------------- -* Function: h5immake_palette_c -* -* Purpose: Call H5IMmake_palette -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5immake_palette_c + * + * Purpose: Call H5IMmake_palette + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5immake_palette_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *dims, - void *buf) +h5immake_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *dims, void *buf) { - char *c_name = NULL; + char * c_name = NULL; hsize_t c_dims[H5S_MAX_RANK]; int i; - int rank=2; + int rank = 2; int_f ret_value = 0; /* - * convert FORTRAN name to C name - */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + * convert FORTRAN name to C name + */ + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - for(i = 0; i < rank ; i++) - c_dims[i] = (hsize_t)dims[i]; + for (i = 0; i < rank; i++) + c_dims[i] = (hsize_t)dims[i]; /* - * call H5IMmake_palette function. - */ - if(H5IMmake_palettef((hid_t)*loc_id, c_name, c_dims, (int_f *)buf) < 0) + * call H5IMmake_palette function. + */ + if (H5IMmake_palettef((hid_t)*loc_id, c_name, c_dims, (int_f *)buf) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } - /*------------------------------------------------------------------------- -* Function: h5imlink_palette_c -* -* Purpose: Call H5IMlink_palette -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5imlink_palette_c + * + * Purpose: Call H5IMlink_palette + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imlink_palette_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *ilen, - _fcd pal_name) +h5imlink_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *ilen, _fcd pal_name) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - char *c_namepal = NULL; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + char * c_namepal = NULL; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; @@ -433,11 +398,11 @@ h5imlink_palette_c (hid_t_f *loc_id, goto done; /* - * call H5IMlink_palette function. - */ + * call H5IMlink_palette function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5IMlink_palette(c_loc_id,c_name,c_namepal); + ret = H5IMlink_palette(c_loc_id, c_name, c_namepal); if (ret < 0) goto done; @@ -445,50 +410,45 @@ h5imlink_palette_c (hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_namepal!=NULL) + if (c_namepal != NULL) HDfree(c_namepal); return ret_value; } - /*------------------------------------------------------------------------- -* Function: h5imunlink_palette_c -* -* Purpose: Call H5IMunlink_palette -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5imunlink_palette_c + * + * Purpose: Call H5IMunlink_palette + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imunlink_palette_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *ilen, - _fcd pal_name) +h5imunlink_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *ilen, _fcd pal_name) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - char *c_namepal = NULL; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + char * c_namepal = NULL; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; @@ -498,11 +458,11 @@ h5imunlink_palette_c (hid_t_f *loc_id, goto done; /* - * call H5IMunlink_palette function. - */ + * call H5IMunlink_palette function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5IMunlink_palette(c_loc_id,c_name,c_namepal); + ret = H5IMunlink_palette(c_loc_id, c_name, c_namepal); if (ret < 0) goto done; @@ -510,62 +470,57 @@ h5imunlink_palette_c (hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_namepal!=NULL) + if (c_namepal != NULL) HDfree(c_namepal); return ret_value; } - - /*------------------------------------------------------------------------- -* Function: h5imget_npalettes_c -* -* Purpose: Call H5IMget_npalettes -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5imget_npalettes_c + * + * Purpose: Call H5IMget_npalettes + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imget_npalettes_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *npals) +h5imget_npalettes_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *npals) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - hssize_t c_npals; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + hssize_t c_npals; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * call H5IMget_image_info function. - */ + * call H5IMget_image_info function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5IMget_npalettes(c_loc_id,c_name,&c_npals); + ret = H5IMget_npalettes(c_loc_id, c_name, &c_npals); - *npals = (hsize_t_f) c_npals; + *npals = (hsize_t_f)c_npals; if (ret < 0) goto done; @@ -573,184 +528,166 @@ h5imget_npalettes_c(hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; } - - /*------------------------------------------------------------------------- -* Function: h5imget_palette_info_c -* -* Purpose: Call H5IMget_palette_info -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: h5imget_palette_info_c + * + * Purpose: Call H5IMget_palette_info + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imget_palette_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *pal_number, - hsize_t_f *dims) +h5imget_palette_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *pal_number, hsize_t_f *dims) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - hsize_t c_dims[2]; - int i; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + hsize_t c_dims[2]; + int i; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * call H5IMget_image_info function. - */ + * call H5IMget_image_info function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5IMget_palette_info(c_loc_id,c_name,*pal_number,c_dims); + ret = H5IMget_palette_info(c_loc_id, c_name, *pal_number, c_dims); if (ret < 0) goto done; - for (i = 0; i < 2 ; i++) - { - dims[i] = (hsize_t_f) c_dims[i]; + for (i = 0; i < 2; i++) { + dims[i] = (hsize_t_f)c_dims[i]; } ret_value = 0; - done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; } - /*------------------------------------------------------------------------- -* Function: h5imget_palette_c -* -* Purpose: Call H5IMget_palette -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: h5imget_palette_c + * + * Purpose: Call H5IMget_palette + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imget_palette_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *pal_number, - void *buf) +h5imget_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *pal_number, void *buf) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) - goto done; + goto done; /* - * call H5IMget_image_info function. - */ + * call H5IMget_image_info function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5IMget_palettef(c_loc_id,c_name,*pal_number,(int_f *)buf); + ret = H5IMget_palettef(c_loc_id, c_name, *pal_number, (int_f *)buf); if (ret < 0) - goto done; + goto done; ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; } - /*------------------------------------------------------------------------- -* Function: h5imis_palette_c -* -* Purpose: Call H5IMis_palette -* -* Return: true, false, fail -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5imis_palette_c + * + * Purpose: Call H5IMis_palette + * + * Return: true, false, fail + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5imis_palette_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name) +h5imis_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name) { - hid_t c_loc_id; - char *c_name; - herr_t ret; + hid_t c_loc_id; + char * c_name; + herr_t ret; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return -1; + if (c_name == NULL) + return -1; /* - * call H5IMis_palette function. - */ + * call H5IMis_palette function. + */ c_loc_id = (hid_t)*loc_id; ret = H5IMis_palette(c_loc_id, c_name); - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret; - } diff --git a/hl/fortran/src/H5LTf90proto.h b/hl/fortran/src/H5LTf90proto.h index 44a2fee..b3c0a72 100644 --- a/hl/fortran/src/H5LTf90proto.h +++ b/hl/fortran/src/H5LTf90proto.h @@ -1,16 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef _H5LTf90proto_H #define _H5LTf90proto_H @@ -22,414 +21,189 @@ /* These definitions should match those in fortran/src/H5f90kit.c */ -H5_FCDLL char* HD5f2cstring (_fcd fdesc, size_t len); -H5_FCDLL void HD5packFstring (char *src, char *dest, size_t len); +H5_FCDLL char *HD5f2cstring(_fcd fdesc, size_t len); +H5_FCDLL void HD5packFstring(char *src, char *dest, size_t len); /* * Functions from H5DSfc.c */ HDF5_HL_F90CSTUBDLL -int_f -h5dsset_scale_c(hid_t_f *dsid, _fcd dimname, size_t_f *dimnamelen); +int_f h5dsset_scale_c(hid_t_f *dsid, _fcd dimname, size_t_f *dimnamelen); HDF5_HL_F90CSTUBDLL -int_f -h5dsattach_scale_c( hid_t_f *did, hid_t_f *dsid, int_f *idx); +int_f h5dsattach_scale_c(hid_t_f *did, hid_t_f *dsid, int_f *idx); HDF5_HL_F90CSTUBDLL -int_f -h5dsdetach_scale_c( hid_t_f *did, hid_t_f *dsid, int_f *idx); +int_f h5dsdetach_scale_c(hid_t_f *did, hid_t_f *dsid, int_f *idx); HDF5_HL_F90CSTUBDLL -int_f -h5dsis_attached_c( hid_t_f *did, hid_t_f *dsid, int_f *idx, int_f *c_is_attached); +int_f h5dsis_attached_c(hid_t_f *did, hid_t_f *dsid, int_f *idx, int_f *c_is_attached); HDF5_HL_F90CSTUBDLL -int_f -h5dsis_scale_c(hid_t_f *did, int_f *is_scale); +int_f h5dsis_scale_c(hid_t_f *did, int_f *is_scale); HDF5_HL_F90CSTUBDLL -int_f -h5dsset_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *labellen); +int_f h5dsset_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *labellen); HDF5_HL_F90CSTUBDLL -int_f -h5dsget_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *size); +int_f h5dsget_label_c(hid_t_f *did, int_f *idx, _fcd label, size_t_f *size); HDF5_HL_F90CSTUBDLL -int_f -h5dsget_scale_name_c(hid_t_f *did, _fcd label, size_t_f *size); +int_f h5dsget_scale_name_c(hid_t_f *did, _fcd label, size_t_f *size); HDF5_HL_F90CSTUBDLL -int_f -h5dsget_num_scales_c( hid_t_f *did, int_f *idx, int_f *num_scales); +int_f h5dsget_num_scales_c(hid_t_f *did, int_f *idx, int_f *num_scales); /* * Functions from H5LTfc.c */ HDF5_HL_F90CSTUBDLL -int_f -h5ltmake_dataset_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *rank, - hsize_t_f *dims, - hid_t_f *type_id, - void *buf); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltread_dataset_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hid_t_f *type_id, - void *buf); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltset_attribute_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd dsetname, - size_t_f *attrnamelen, - _fcd attrname, - size_t_f *size, - void *buf, char *dtype, size_t_f *sizeof_val); - - -HDF5_HL_F90CSTUBDLL -int_f -h5ltget_attribute_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd dsetname, - size_t_f *attrnamelen, - _fcd attrname, - void *buf, char* dtype, size_t_f *sizeof_val); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltget_attribute_string_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd dsetname, - size_t_f *attrnamelen, - _fcd attrname, - _fcd buf, - size_t_f *buf_size); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltget_dataset_ndims_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *rank); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltfind_dataset_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltget_dataset_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *dims, - int_f *type_class, - size_t_f *type_size); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltget_attribute_ndims_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd dsetname, - size_t_f *attrnamelen, - _fcd attrname, - int_f *rank); -HDF5_HL_F90CSTUBDLL -int_f -h5ltget_attribute_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *attrnamelen, - _fcd attrname, - hsize_t_f *dims, - int_f *type_class, - size_t_f *type_size); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltmake_dataset_string_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *buflen, - char *buf); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltread_dataset_string_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - char *buf); - -HDF5_HL_F90CSTUBDLL -int_f -h5ltpath_valid_c(hid_t_f *loc_id, - _fcd path, - size_t_f *pathlen, - int_f *check_object_valid_c); +int_f h5ltmake_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *rank, hsize_t_f *dims, + hid_t_f *type_id, void *buf); + +HDF5_HL_F90CSTUBDLL +int_f h5ltread_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hid_t_f *type_id, void *buf); + +HDF5_HL_F90CSTUBDLL +int_f h5ltset_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, + _fcd attrname, size_t_f *size, void *buf, char *dtype, size_t_f *sizeof_val); + +HDF5_HL_F90CSTUBDLL +int_f h5ltget_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, + _fcd attrname, void *buf, char *dtype, size_t_f *sizeof_val); + +HDF5_HL_F90CSTUBDLL +int_f h5ltget_attribute_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, + _fcd attrname, _fcd buf, size_t_f *buf_size); + +HDF5_HL_F90CSTUBDLL +int_f h5ltget_dataset_ndims_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *rank); -/*------------------------------------------------------------------------- -* Image -*------------------------------------------------------------------------- -*/ HDF5_HL_F90CSTUBDLL -int_f -h5immake_image_8bit_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *width, - hsize_t_f *height, - int_f *buf); +int_f h5ltfind_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name); + HDF5_HL_F90CSTUBDLL -int_f -h5imread_image_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *buf); +int_f h5ltget_dataset_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *dims, + int_f *type_class, size_t_f *type_size); HDF5_HL_F90CSTUBDLL -int_f -h5immake_image_24bit_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *ilen, - _fcd il, - hsize_t_f *width, - hsize_t_f *height, - void *buf); +int_f h5ltget_attribute_ndims_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, + _fcd attrname, int_f *rank); HDF5_HL_F90CSTUBDLL -int_f -h5imget_image_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *width, - hsize_t_f *height, - hsize_t_f *planes, - hsize_t_f *npals, - size_t_f *ilen, - _fcd interlace); +int_f h5ltget_attribute_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *attrnamelen, + _fcd attrname, hsize_t_f *dims, int_f *type_class, size_t_f *type_size); +HDF5_HL_F90CSTUBDLL +int_f h5ltmake_dataset_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *buflen, char *buf); HDF5_HL_F90CSTUBDLL -int_f -h5imis_image_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name); +int_f h5ltread_dataset_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, char *buf); +HDF5_HL_F90CSTUBDLL +int_f h5ltpath_valid_c(hid_t_f *loc_id, _fcd path, size_t_f *pathlen, int_f *check_object_valid_c); +/*------------------------------------------------------------------------- + * Image + *------------------------------------------------------------------------- + */ HDF5_HL_F90CSTUBDLL -int_f -h5immake_palette_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *dims, - void *buf); +int_f h5immake_image_8bit_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *width, + hsize_t_f *height, int_f *buf); +HDF5_HL_F90CSTUBDLL +int_f h5imread_image_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *buf); HDF5_HL_F90CSTUBDLL -int_f -h5imlink_palette_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *ilen, - _fcd pal_name); +int_f h5immake_image_24bit_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *ilen, _fcd il, + hsize_t_f *width, hsize_t_f *height, void *buf); +HDF5_HL_F90CSTUBDLL +int_f h5imget_image_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *width, hsize_t_f *height, + hsize_t_f *planes, hsize_t_f *npals, size_t_f *ilen, _fcd interlace); HDF5_HL_F90CSTUBDLL -int_f -h5imunlink_palette_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *ilen, - _fcd pal_name); +int_f h5imis_image_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name); HDF5_HL_F90CSTUBDLL -int_f -h5imget_npalettes_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *npals); +int_f h5immake_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *dims, void *buf); +HDF5_HL_F90CSTUBDLL +int_f h5imlink_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *ilen, _fcd pal_name); HDF5_HL_F90CSTUBDLL -int_f -h5imget_palette_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *pal_number, - hsize_t_f *dims); +int_f h5imunlink_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *ilen, _fcd pal_name); HDF5_HL_F90CSTUBDLL -int_f -h5imget_palette_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *pal_number, - void *buf); +int_f h5imget_npalettes_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *npals); HDF5_HL_F90CSTUBDLL -int_f -h5imis_palette_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name); +int_f h5imget_palette_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *pal_number, + hsize_t_f *dims); +HDF5_HL_F90CSTUBDLL +int_f h5imget_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *pal_number, void *buf); +HDF5_HL_F90CSTUBDLL +int_f h5imis_palette_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name); /*------------------------------------------------------------------------- -* Table -*------------------------------------------------------------------------- -*/ - -HDF5_HL_F90CSTUBDLL -int_f -h5tbmake_table_c(size_t_f *namelen1, - _fcd name1, - hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *nfields, - hsize_t_f *nrecords, - size_t_f *type_size, - size_t_f *field_offset, - hid_t_f *field_types, - hsize_t_f *chunk_size, - int_f *compress, - size_t_f *char_len_field_names, /* field_names lengths */ - size_t_f *max_char_size_field_names, /* char len of fields */ - _fcd buf); /* field_names */ - -HDF5_HL_F90CSTUBDLL -int_f -h5tbread_table_c(hid_t_f *loc_id, - _fcd name, - size_t_f *namelen, - hsize_t_f *nfields, - size_t_f *dst_size, - size_t_f *dst_offset, - size_t_f *dst_sizes, - void *dst_buf); - - -HDF5_HL_F90CSTUBDLL -int_f -h5tbmake_table_ptr_c(size_t_f *namelen1, - _fcd name1, - hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *nfields, - hsize_t_f *nrecords, - size_t_f *type_size, - size_t_f *field_offset, - hid_t_f *field_types, - hsize_t_f *chunk_size, - void *fill_data, - int_f *compress, - size_t_f *char_len_field_names, /* field_names lengths */ - size_t_f *max_char_size_field_names, /* char len of fields */ - char *field_names, /* field_names */ - void *data); - -HDF5_HL_F90CSTUBDLL -int_f -h5tbwrite_field_name_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *namelen1, - _fcd field_name, - hsize_t_f *start, - hsize_t_f *nrecords, - size_t_f *type_size, - void *buf); - - - -HDF5_HL_F90CSTUBDLL -int_f -h5tbread_field_name_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *namelen1, - _fcd field_name, - hsize_t_f *start, - hsize_t_f *nrecords, - size_t_f *type_size, - void *buf); - - - -HDF5_HL_F90CSTUBDLL -int_f -h5tbwrite_field_index_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *field_index, - hsize_t_f *start, - hsize_t_f *nrecords, - size_t_f *type_size, - void *buf); - -HDF5_HL_F90CSTUBDLL -int_f -h5tbread_field_index_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *field_index, - hsize_t_f *start, - hsize_t_f *nrecords, - size_t_f *type_size, - void *buf); - -HDF5_HL_F90CSTUBDLL -int_f -h5tbinsert_field_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *namelen1, - _fcd field_name, - hid_t_f *field_type, - int_f *position, - void *buf); - -HDF5_HL_F90CSTUBDLL -int_f -h5tbdelete_field_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *namelen1, - _fcd field_name); - - -HDF5_HL_F90CSTUBDLL -int_f -h5tbget_table_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *nfields, - hsize_t_f *nrecords); - -HDF5_HL_F90CSTUBDLL -int_f -h5tbget_field_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *nfields, - size_t_f *field_sizes, - size_t_f *field_offsets, - size_t_f *type_size, - size_t_f *namelen2, - size_t_f *lenmax, - _fcd field_names, - size_t_f *maxlen_out); + * Table + *------------------------------------------------------------------------- + */ + +HDF5_HL_F90CSTUBDLL +int_f h5tbmake_table_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *namelen, _fcd name, + hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size, size_t_f *field_offset, + hid_t_f *field_types, hsize_t_f *chunk_size, int_f *compress, + size_t_f *char_len_field_names, /* field_names lengths */ + size_t_f *max_char_size_field_names, /* char len of fields */ + _fcd buf); /* field_names */ + +HDF5_HL_F90CSTUBDLL +int_f h5tbread_table_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hsize_t_f *nfields, size_t_f *dst_size, + size_t_f *dst_offset, size_t_f *dst_sizes, void *dst_buf); + +HDF5_HL_F90CSTUBDLL +int_f h5tbmake_table_ptr_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *namelen, _fcd name, + hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size, + size_t_f *field_offset, hid_t_f *field_types, hsize_t_f *chunk_size, + void *fill_data, int_f *compress, + size_t_f *char_len_field_names, /* field_names lengths */ + size_t_f *max_char_size_field_names, /* char len of fields */ + char * field_names, /* field_names */ + void * data); + +HDF5_HL_F90CSTUBDLL +int_f h5tbwrite_field_name_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, + _fcd field_name, hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, + void *buf); + +HDF5_HL_F90CSTUBDLL +int_f h5tbread_field_name_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, + _fcd field_name, hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, + void *buf); +HDF5_HL_F90CSTUBDLL +int_f h5tbwrite_field_index_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *field_index, + hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, void *buf); + +HDF5_HL_F90CSTUBDLL +int_f h5tbread_field_index_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *field_index, + hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, void *buf); + +HDF5_HL_F90CSTUBDLL +int_f h5tbinsert_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, _fcd field_name, + hid_t_f *field_type, int_f *position, void *buf); + +HDF5_HL_F90CSTUBDLL +int_f h5tbdelete_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, _fcd field_name); + +HDF5_HL_F90CSTUBDLL +int_f h5tbget_table_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *nfields, + hsize_t_f *nrecords); + +HDF5_HL_F90CSTUBDLL +int_f h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *nfields, + size_t_f *field_sizes, size_t_f *field_offsets, size_t_f *type_size, + size_t_f *namelen2, size_t_f *lenmax, _fcd field_names, size_t_f *maxlen_out); #endif /* _H5LTf90proto_H */ diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c index 3597c3a..afe6419 100644 --- a/hl/fortran/src/H5LTfc.c +++ b/hl/fortran/src/H5LTfc.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* This files contains C stubs for H5D Fortran APIs */ @@ -18,121 +18,111 @@ #include "H5Eprivate.h" /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_c -* -* Purpose: Call H5LTmake_dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: September 09, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTmake_dataset_c + * + * Purpose: Call H5LTmake_dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: September 09, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltmake_dataset_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *rank, - hsize_t_f *dims, - hid_t_f *type_id, - void *buf) +h5ltmake_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *rank, hsize_t_f *dims, + hid_t_f *type_id, void *buf) { - int ret_value = -1; - herr_t ret; - char *c_name = NULL; + int ret_value = -1; + herr_t ret; + char * c_name = NULL; hsize_t *c_dims = NULL; - int i; + int i; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; - c_dims = (hsize_t *)HDmalloc(sizeof(hsize_t) * ( (size_t)*rank )); + c_dims = (hsize_t *)HDmalloc(sizeof(hsize_t) * ((size_t)*rank)); if (c_dims == NULL) goto done; /* - * transpose dimension arrays because of C-FORTRAN storage order - */ - for (i = 0; i < *rank ; i++) - { - c_dims[i] = dims[*rank - i - 1]; + * transpose dimension arrays because of C-FORTRAN storage order + */ + for (i = 0; i < *rank; i++) { + c_dims[i] = dims[*rank - i - 1]; } /* - * call H5LTmake_dataset function. - */ + * call H5LTmake_dataset function. + */ - ret = H5LTmake_dataset((hid_t)*loc_id, c_name, (int)*rank, c_dims, (hid_t)*type_id, buf ); + ret = H5LTmake_dataset((hid_t)*loc_id, c_name, (int)*rank, c_dims, (hid_t)*type_id, buf); if (ret < 0) goto done; ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_dims!=NULL) + if (c_dims != NULL) HDfree(c_dims); return ret_value; } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_c -* -* Purpose: Call H5LTmake_dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: September 09, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_c + * + * Purpose: Call H5LTmake_dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: September 09, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltread_dataset_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hid_t_f *type_id, - void *buf) +h5ltread_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hid_t_f *type_id, void *buf) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - hid_t c_type_id; - char *c_name = NULL; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + hid_t c_type_id; + char * c_name = NULL; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * call H5LTread_dataset function. - */ - c_loc_id = (hid_t)*loc_id; + * call H5LTread_dataset function. + */ + c_loc_id = (hid_t)*loc_id; c_type_id = (hid_t)*type_id; - ret = H5LTread_dataset(c_loc_id, c_name, c_type_id, buf ); + ret = H5LTread_dataset(c_loc_id, c_name, c_type_id, buf); if (ret < 0) goto done; @@ -140,47 +130,43 @@ h5ltread_dataset_c (hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; } /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_string_c -* -* Purpose: Call H5LTmake_dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: September 09, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTmake_dataset_string_c + * + * Purpose: Call H5LTmake_dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: September 09, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltmake_dataset_string_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *buflen, - char *buf) +h5ltmake_dataset_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *buflen, char *buf) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - char *c_buf = NULL; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + char * c_buf = NULL; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; @@ -190,11 +176,11 @@ h5ltmake_dataset_string_c (hid_t_f *loc_id, goto done; /* - * call H5LTmake_dataset_string function. - */ + * call H5LTmake_dataset_string function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5LTmake_dataset_string(c_loc_id,c_name,c_buf); + ret = H5LTmake_dataset_string(c_loc_id, c_name, c_buf); if (ret < 0) goto done; @@ -202,58 +188,54 @@ h5ltmake_dataset_string_c (hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_buf!=NULL) + if (c_buf != NULL) HDfree(c_buf); return ret_value; } - /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_string_c -* -* Purpose: Call H5LTread_dataset_string -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: September 09, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_string_c + * + * Purpose: Call H5LTread_dataset_string + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: September 09, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltread_dataset_string_c (hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - char *buf) +h5ltread_dataset_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, char *buf) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * call H5LTread_dataset_string function. - */ + * call H5LTread_dataset_string function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5LTread_dataset_string(c_loc_id,c_name,buf); + ret = H5LTread_dataset_string(c_loc_id, c_name, buf); if (ret < 0) goto done; @@ -261,51 +243,46 @@ h5ltread_dataset_string_c (hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_int_c -* -* Purpose: Call H5LTset_attribute_int -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_int_c + * + * Purpose: Call H5LTset_attribute_int + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltset_attribute_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd dsetname, - size_t_f *attrnamelen, - _fcd attrname, - size_t_f *size, - void *buf, char *dtype, size_t_f *sizeof_val) +h5ltset_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, _fcd attrname, + size_t_f *size, void *buf, char *dtype, size_t_f *sizeof_val) { - int ret_value = -1; - herr_t ret = SUCCEED; - hid_t c_loc_id; - char *c_name = NULL; - char *c_attrname = NULL; - char *c_buf = NULL; - size_t c_size; + int ret_value = -1; + herr_t ret = SUCCEED; + hid_t c_loc_id; + char * c_name = NULL; + char * c_attrname = NULL; + char * c_buf = NULL; + size_t c_size; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen); if (c_name == NULL) goto done; @@ -315,93 +292,97 @@ h5ltset_attribute_c(hid_t_f *loc_id, goto done; /* - * call H5LTset_attribute_int function. - */ + * call H5LTset_attribute_int function. + */ c_loc_id = (hid_t)*loc_id; c_size = (size_t)*size; - if( HDstrncmp(dtype,"I",1) == 0 ) { - if ((size_t)*sizeof_val == sizeof(int)) - ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_INT, (const int *)buf); - else if ((size_t)*sizeof_val == sizeof(long)) - ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_LONG, (const long *)buf); + if (HDstrncmp(dtype, "I", 1) == 0) { + if ((size_t)*sizeof_val == sizeof(int)) + ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_INT, + (const int *)buf); + else if ((size_t)*sizeof_val == sizeof(long)) + ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_LONG, + (const long *)buf); #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if ((size_t)*sizeof_val == sizeof(long long)) - ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_LLONG, (const long long *)buf); + else if ((size_t)*sizeof_val == sizeof(long long)) + ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_LLONG, + (const long long *)buf); #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ - else - goto done; - } else if ( HDstrncmp(dtype,"R",1) == 0 ) { - if((size_t)*sizeof_val == sizeof(float)) - ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_FLOAT, (const float *)buf); - else if((size_t)*sizeof_val == sizeof(double)) - ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_DOUBLE, (const double *)buf); -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if((size_t)*sizeof_val == sizeof(long double)) - ret = H5LT_set_attribute_numerical(c_loc_id,c_name,c_attrname, c_size, H5T_NATIVE_LDOUBLE, (const long double *)buf); + else + goto done; + } + else if (HDstrncmp(dtype, "R", 1) == 0) { + if ((size_t)*sizeof_val == sizeof(float)) + ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_FLOAT, + (const float *)buf); + else if ((size_t)*sizeof_val == sizeof(double)) + ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_DOUBLE, + (const double *)buf); +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if ((size_t)*sizeof_val == sizeof(long double)) + ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_LDOUBLE, + (const long double *)buf); #endif - else - goto done; - } else if ( HDstrncmp(dtype,"C",1) == 0 ) { + else + goto done; + } + else if (HDstrncmp(dtype, "C", 1) == 0) { - c_buf = (char *)HD5f2cstring((_fcd)buf, c_size); - if (c_buf == NULL) - goto done; + c_buf = (char *)HD5f2cstring((_fcd)buf, c_size); + if (c_buf == NULL) + goto done; - ret = H5LTset_attribute_string(c_loc_id,c_name,c_attrname,c_buf); + ret = H5LTset_attribute_string(c_loc_id, c_name, c_attrname, c_buf); } if (ret < 0) - goto done; + goto done; ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_attrname!=NULL) + if (c_attrname != NULL) HDfree(c_attrname); - if(c_buf!=NULL) + if (c_buf != NULL) HDfree(c_buf); return ret_value; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_c -* -* Purpose: Call H5LTget_attribute_int -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_attribute_c + * + * Purpose: Call H5LTget_attribute_int + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltget_attribute_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd dsetname, - size_t_f *attrnamelen, - _fcd attrname, - void *buf, char *dtype, size_t_f *sizeof_val) +h5ltget_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, _fcd attrname, + void *buf, char *dtype, size_t_f *sizeof_val) { - int ret_value = -1; - herr_t ret = SUCCEED; - hid_t c_loc_id; - char *c_name = NULL; - char *c_attrname = NULL; + int ret_value = -1; + herr_t ret = SUCCEED; + hid_t c_loc_id; + char * c_name = NULL; + char * c_attrname = NULL; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen); if (c_name == NULL) goto done; @@ -411,32 +392,33 @@ h5ltget_attribute_c(hid_t_f *loc_id, goto done; /* - * call H5LTget_attribute_int function. - */ + * call H5LTget_attribute_int function. + */ c_loc_id = (hid_t)*loc_id; - if( HDstrncmp(dtype,"I",1) == 0) { - if((size_t)*sizeof_val == sizeof(int)) - ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_INT,buf); - else if ((size_t)*sizeof_val == sizeof(long)) - ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_LONG,buf); + if (HDstrncmp(dtype, "I", 1) == 0) { + if ((size_t)*sizeof_val == sizeof(int)) + ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_INT, buf); + else if ((size_t)*sizeof_val == sizeof(long)) + ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_LONG, buf); #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if ((size_t)*sizeof_val == sizeof(long long)) - ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_LLONG,buf); + else if ((size_t)*sizeof_val == sizeof(long long)) + ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_LLONG, buf); #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ - else - goto done; - } else if ( HDstrncmp(dtype,"R",1) == 0 ) { - if((size_t)*sizeof_val == sizeof(float)) - ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_FLOAT,buf); - else if((size_t)*sizeof_val == sizeof(double)) - ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_DOUBLE,buf); -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if((size_t)*sizeof_val == sizeof(long double)) - ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_LDOUBLE,buf); + else + goto done; + } + else if (HDstrncmp(dtype, "R", 1) == 0) { + if ((size_t)*sizeof_val == sizeof(float)) + ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_FLOAT, buf); + else if ((size_t)*sizeof_val == sizeof(double)) + ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_DOUBLE, buf); +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if ((size_t)*sizeof_val == sizeof(long double)) + ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_LDOUBLE, buf); #endif - else - goto done; + else + goto done; } if (ret < 0) @@ -445,50 +427,46 @@ h5ltget_attribute_c(hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_attrname!=NULL) + if (c_attrname != NULL) HDfree(c_attrname); return ret_value; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_string_c -* -* Purpose: Call H5LTget_attribute_string -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_attribute_string_c + * + * Purpose: Call H5LTget_attribute_string + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltget_attribute_string_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd dsetname, - size_t_f *attrnamelen, - _fcd attrname, - _fcd buf, size_t_f *buf_size) +h5ltget_attribute_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, + _fcd attrname, _fcd buf, size_t_f *buf_size) { - int ret_value = -1; - herr_t ret; - char *c_name = NULL; - char *c_attrname = NULL; - char *c_buf = NULL; + int ret_value = -1; + herr_t ret; + char * c_name = NULL; + char * c_attrname = NULL; + char * c_buf = NULL; /* - * Convert FORTRAN name to C name - */ + * Convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen); if (c_name == NULL) goto done; @@ -500,12 +478,12 @@ h5ltget_attribute_string_c(hid_t_f *loc_id, * Allocate buffer to hold C attribute string */ if ((c_buf = (char *)HDmalloc((size_t)*buf_size + 1)) == NULL) - goto done; + goto done; /* * Call H5LTget_attribute_int function. */ - ret = H5LTget_attribute_string((hid_t)*loc_id,c_name,c_attrname,c_buf); + ret = H5LTget_attribute_string((hid_t)*loc_id, c_name, c_attrname, c_buf); if (ret < 0) goto done; @@ -517,58 +495,54 @@ h5ltget_attribute_string_c(hid_t_f *loc_id, ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_attrname!=NULL) + if (c_attrname != NULL) HDfree(c_attrname); - if(c_buf!=NULL) + if (c_buf != NULL) HDfree(c_buf); return ret_value; } - /*------------------------------------------------------------------------- -* Function: H5LTget_dataset_ndims_c -* -* Purpose: Call H5LTget_dataset_ndims -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: September 09, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_dataset_ndims_c + * + * Purpose: Call H5LTget_dataset_ndims + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: September 09, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltget_dataset_ndims_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - int_f *rank) +h5ltget_dataset_ndims_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *rank) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - int c_rank; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + int c_rank; /* - * Convert FORTRAN name to C name - */ + * Convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * Call H5LTget_dataset_ndims function. - */ + * Call H5LTget_dataset_ndims function. + */ c_loc_id = (hid_t)*loc_id; ret = H5LTget_dataset_ndims(c_loc_id, c_name, &c_rank); @@ -576,113 +550,105 @@ h5ltget_dataset_ndims_c(hid_t_f *loc_id, if (ret < 0) goto done; - *rank = (int_f)c_rank; + *rank = (int_f)c_rank; ret_value = 0; - done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; } - /*------------------------------------------------------------------------- -* Function: h5ltfind_dataset_c -* -* Purpose: Call H5LTfind_dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: September 09, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5ltfind_dataset_c + * + * Purpose: Call H5LTfind_dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: September 09, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltfind_dataset_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name) +h5ltfind_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name) { - hid_t c_loc_id; - char *c_name = NULL; - herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + herr_t ret; /* - * Convert FORTRAN name to C name - */ + * Convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); - if (c_name == NULL) return -1; + if (c_name == NULL) + return -1; /* - * Call H5LTget_dataset_ndims function. - */ + * Call H5LTget_dataset_ndims function. + */ c_loc_id = (hid_t)*loc_id; ret = H5LTfind_dataset(c_loc_id, c_name); - if(c_name!=NULL) - HDfree(c_name); + if (c_name != NULL) + HDfree(c_name); return ret; - } /*------------------------------------------------------------------------- -* Function: h5ltget_dataset_info_c -* -* Purpose: Call H5LTget_dataset_info -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: September 09, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5ltget_dataset_info_c + * + * Purpose: Call H5LTget_dataset_info + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: September 09, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltget_dataset_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - hsize_t_f *dims, - int_f *type_class, - size_t_f *type_size) +h5ltget_dataset_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *dims, int_f *type_class, + size_t_f *type_size) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - H5T_class_t c_classtype; - size_t c_type_size; - hsize_t c_dims[32]; - int i; - int c_rank; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + H5T_class_t c_classtype; + size_t c_type_size; + hsize_t c_dims[32]; + int i; + int c_rank; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; /* - * call H5LTget_dataset_ndims function. - */ + * call H5LTget_dataset_ndims function. + */ c_loc_id = (hid_t)*loc_id; ret = H5LTget_dataset_info(c_loc_id, c_name, c_dims, &c_classtype, &c_type_size); @@ -690,68 +656,62 @@ h5ltget_dataset_info_c(hid_t_f *loc_id, goto done; *type_class = c_classtype; - *type_size = (size_t_f)c_type_size; + *type_size = (size_t_f)c_type_size; /* - * transpose dimension arrays because of C-FORTRAN storage order - */ + * transpose dimension arrays because of C-FORTRAN storage order + */ ret = H5LTget_dataset_ndims(c_loc_id, c_name, &c_rank); if (ret < 0) goto done; - for (i = 0; i < c_rank ; i++) - { - dims[i] = (hsize_t_f) c_dims[c_rank - i - 1]; + for (i = 0; i < c_rank; i++) { + dims[i] = (hsize_t_f)c_dims[c_rank - i - 1]; } - ret_value = 0; done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5ltget_attribute_ndims_c -* -* Purpose: Call H5LTget_attribute_ndims -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5ltget_attribute_ndims_c + * + * Purpose: Call H5LTget_attribute_ndims + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltget_attribute_ndims_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd dsetname, - size_t_f *attrnamelen, - _fcd attrname, - int_f *rank) +h5ltget_attribute_ndims_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, + _fcd attrname, int_f *rank) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - char *c_attrname = NULL; - int c_rank; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + char * c_attrname = NULL; + int c_rank; /* - * Convert FORTRAN name to C name - */ + * Convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen); if (c_name == NULL) goto done; @@ -761,72 +721,64 @@ h5ltget_attribute_ndims_c(hid_t_f *loc_id, goto done; /* - * Call H5LTset_attribute_ndims function. - */ + * Call H5LTset_attribute_ndims function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5LTget_attribute_ndims(c_loc_id,c_name,c_attrname,&c_rank); + ret = H5LTget_attribute_ndims(c_loc_id, c_name, c_attrname, &c_rank); if (ret < 0) goto done; - *rank = (int_f)c_rank; + *rank = (int_f)c_rank; ret_value = 0; - done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_attrname!=NULL) + if (c_attrname != NULL) HDfree(c_attrname); return ret_value; } - /*------------------------------------------------------------------------- -* Function: h5ltget_attribute_info_c -* -* Purpose: Call H5LTget_attribute_info -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: September 09, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5ltget_attribute_info_c + * + * Purpose: Call H5LTget_attribute_info + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: September 09, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltget_attribute_info_c(hid_t_f *loc_id, - size_t_f *namelen, - _fcd name, - size_t_f *attrnamelen, - _fcd attrname, - hsize_t_f *dims, - int_f *type_class, - size_t_f *type_size) +h5ltget_attribute_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *attrnamelen, _fcd attrname, + hsize_t_f *dims, int_f *type_class, size_t_f *type_size) { - int ret_value = -1; - herr_t ret; - hid_t c_loc_id; - char *c_name = NULL; - char *c_attrname = NULL; - H5T_class_t c_classtype; - size_t c_type_size; - hsize_t c_dims[32]; - int i; - int c_rank; + int ret_value = -1; + herr_t ret; + hid_t c_loc_id; + char * c_name = NULL; + char * c_attrname = NULL; + H5T_class_t c_classtype; + size_t c_type_size; + hsize_t c_dims[32]; + int i; + int c_rank; /* - * convert FORTRAN name to C name - */ + * convert FORTRAN name to C name + */ c_name = (char *)HD5f2cstring(name, (size_t)*namelen); if (c_name == NULL) goto done; @@ -836,90 +788,84 @@ h5ltget_attribute_info_c(hid_t_f *loc_id, goto done; /* - * call H5LTget_attribute_info function. - */ + * call H5LTget_attribute_info function. + */ c_loc_id = (hid_t)*loc_id; - ret = H5LTget_attribute_info(c_loc_id,c_name,c_attrname,c_dims,&c_classtype,&c_type_size); + ret = H5LTget_attribute_info(c_loc_id, c_name, c_attrname, c_dims, &c_classtype, &c_type_size); if (ret < 0) goto done; *type_class = c_classtype; - *type_size = (size_t_f)c_type_size; + *type_size = (size_t_f)c_type_size; /* - * transpose dimension arrays because of C-FORTRAN storage order - */ + * transpose dimension arrays because of C-FORTRAN storage order + */ - ret = H5LTget_attribute_ndims(c_loc_id,c_name,c_attrname,&c_rank); + ret = H5LTget_attribute_ndims(c_loc_id, c_name, c_attrname, &c_rank); if (ret < 0) goto done; - for (i = 0; i < c_rank ; i++) - { - dims[i] = (hsize_t_f) c_dims[c_rank - i - 1]; + for (i = 0; i < c_rank; i++) { + dims[i] = (hsize_t_f)c_dims[c_rank - i - 1]; } ret_value = 0; - done: - if(c_name!=NULL) + if (c_name != NULL) HDfree(c_name); - if(c_attrname!=NULL) + if (c_attrname != NULL) HDfree(c_attrname); - return ret_value; } /*------------------------------------------------------------------------- -* Function: h5ltpath_valid_c -* -* Purpose: Calls h5ltpath_valid -* -* Return: Success: 0, Failure: -1 -* -* Programmer: M. Scot Breitenfeld -* -* Date: February 18, 2012 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: h5ltpath_valid_c + * + * Purpose: Calls h5ltpath_valid + * + * Return: Success: 0, Failure: -1 + * + * Programmer: M. Scot Breitenfeld + * + * Date: February 18, 2012 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ int_f -h5ltpath_valid_c(hid_t_f *loc_id, - _fcd path, - size_t_f *pathlen, - int_f *check_object_valid_c) +h5ltpath_valid_c(hid_t_f *loc_id, _fcd path, size_t_f *pathlen, int_f *check_object_valid_c) { - htri_t ret = -1; - char *c_path = NULL; + htri_t ret = -1; + char * c_path = NULL; hbool_t check_object_valid; /* * convert FORTRAN name to C name */ - if( NULL == (c_path = (char *)HD5f2cstring(path, (size_t)*pathlen))) - goto done; + if (NULL == (c_path = (char *)HD5f2cstring(path, (size_t)*pathlen))) + goto done; check_object_valid = FALSE; - if(*check_object_valid_c == 1) - check_object_valid = TRUE; + if (*check_object_valid_c == 1) + check_object_valid = TRUE; /* * call H5LTpath_valid function. */ - ret = H5LTpath_valid( (hid_t)*loc_id, c_path, check_object_valid ); + ret = H5LTpath_valid((hid_t)*loc_id, c_path, check_object_valid); done: - if(c_path != NULL) - HDfree(c_path); + if (c_path != NULL) + HDfree(c_path); return (int_f)ret; } diff --git a/hl/fortran/src/H5TBfc.c b/hl/fortran/src/H5TBfc.c index 285cd84..c95600b 100644 --- a/hl/fortran/src/H5TBfc.c +++ b/hl/fortran/src/H5TBfc.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include @@ -20,579 +20,570 @@ #include "H5Eprivate.h" /*------------------------------------------------------------------------- -* Function: h5tbmake_table_c -* -* Purpose: Call H5TBmake_table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 06, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbmake_table_c + * + * Purpose: Call H5TBmake_table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 06, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f h5tbmake_table_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *namelen, _fcd name, - hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size, size_t_f *field_offset, - hid_t_f *field_types, hsize_t_f *chunk_size, int_f *compress, - size_t_f *char_len_field_names, /* field_names lengths */ - size_t_f *max_char_size_field_names, /* char len of fields */ - char *field_names) /* field_names */ + hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size, size_t_f *field_offset, + hid_t_f *field_types, hsize_t_f *chunk_size, int_f *compress, + size_t_f *char_len_field_names, /* field_names lengths */ + size_t_f *max_char_size_field_names, /* char len of fields */ + char * field_names) /* field_names */ { - char *c_name = NULL; - char *c_name1 = NULL; + char * c_name = NULL; + char * c_name1 = NULL; hsize_t num_elem; hsize_t i; - hsize_t c_nfields = (hsize_t)*nfields; + hsize_t c_nfields = (hsize_t)*nfields; size_t *c_field_offset = NULL; - hid_t *c_field_types = NULL; - char **c_field_names = NULL; - char *tmp = NULL, *tmp_p; - int_f ret_value = 0; + hid_t * c_field_types = NULL; + char ** c_field_names = NULL; + char * tmp = NULL, *tmp_p; + int_f ret_value = 0; num_elem = (hsize_t)*nfields; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_name1 = (char *)HD5f2cstring(name1, (size_t)*namelen1))) + if (NULL == (c_name1 = (char *)HD5f2cstring(name1, (size_t)*namelen1))) HGOTO_DONE(FAIL) - if(NULL == (c_field_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) + if (NULL == (c_field_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) - if(NULL == (c_field_types = (hid_t *)HDmalloc(sizeof(hid_t) * (size_t)c_nfields))) + if (NULL == (c_field_types = (hid_t *)HDmalloc(sizeof(hid_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) - for(i = 0; i < num_elem; i++) { - c_field_offset[i] = (size_t)field_offset[i]; - c_field_types[i] = field_types[i]; + for (i = 0; i < num_elem; i++) { + c_field_offset[i] = (size_t)field_offset[i]; + c_field_types[i] = field_types[i]; } /* end for */ /* * allocate array of character pointers */ - if(NULL == (c_field_names = (char **)HDcalloc((size_t)num_elem, sizeof(char *)))) + if (NULL == (c_field_names = (char **)HDcalloc((size_t)num_elem, sizeof(char *)))) HGOTO_DONE(FAIL) /* copy data to long C string */ - if(NULL == (tmp = (char *)HD5f2cstring(field_names, (size_t)*(max_char_size_field_names)*(size_t)num_elem))) + if (NULL == + (tmp = (char *)HD5f2cstring(field_names, (size_t) * (max_char_size_field_names) * (size_t)num_elem))) HGOTO_DONE(FAIL) /* * move data from temorary buffer */ tmp_p = tmp; - for(i = 0; i < num_elem; i++) { - if(NULL == (c_field_names[i] = (char *)HDmalloc((size_t)char_len_field_names[i] + 1))) + for (i = 0; i < num_elem; i++) { + if (NULL == (c_field_names[i] = (char *)HDmalloc((size_t)char_len_field_names[i] + 1))) HGOTO_DONE(FAIL) HDmemcpy(c_field_names[i], tmp_p, (size_t)char_len_field_names[i]); c_field_names[i][char_len_field_names[i]] = '\0'; - tmp_p = tmp_p + *max_char_size_field_names; + tmp_p = tmp_p + *max_char_size_field_names; } /* end for */ /* * call H5TBmake_table function. */ - if(H5TBmake_table(c_name1, (hid_t)*loc_id, c_name, c_nfields, (hsize_t)*nrecords, - (size_t)*type_size, (const char **)c_field_names, c_field_offset, c_field_types, - (hsize_t)*chunk_size, NULL, *compress, NULL) < 0) + if (H5TBmake_table(c_name1, (hid_t)*loc_id, c_name, c_nfields, (hsize_t)*nrecords, (size_t)*type_size, + (const char **)c_field_names, c_field_offset, c_field_types, (hsize_t)*chunk_size, + NULL, *compress, NULL) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); - if(c_name1) + if (c_name1) HDfree(c_name1); - if(c_field_names) { - for(i = 0; i < num_elem; i++) { - if(c_field_names[i]) + if (c_field_names) { + for (i = 0; i < num_elem; i++) { + if (c_field_names[i]) HDfree(c_field_names[i]); } /* end for */ HDfree(c_field_names); } /* end if */ - if(tmp) + if (tmp) HDfree(tmp); - if(c_field_offset) + if (c_field_offset) HDfree(c_field_offset); - if(c_field_types) + if (c_field_types) HDfree(c_field_types); return ret_value; } /* end h5tbmake_table_c() */ /*------------------------------------------------------------------------- -* Function: h5tbmake_table_ptr_c -* -* Purpose: Call H5TBmake_table using F2003 features -* -* Return: Success: 0, Failure: -1 -* -* Programmer: M. Scot Breitenfeld -* -* Date: Sept. 10, 2015 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbmake_table_ptr_c + * + * Purpose: Call H5TBmake_table using F2003 features + * + * Return: Success: 0, Failure: -1 + * + * Programmer: M. Scot Breitenfeld + * + * Date: Sept. 10, 2015 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f -h5tbmake_table_ptr_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *namelen, - _fcd name, hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size, - size_t_f *field_offset, hid_t_f *field_types, hsize_t_f *chunk_size, - void *fill_data, int_f *compress, - size_t_f *char_len_field_names, /* field_names lengths */ - size_t_f *max_char_size_field_names, /* char len of fields */ - char *field_names, - void *data) /* field_names */ +h5tbmake_table_ptr_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *namelen, _fcd name, + hsize_t_f *nfields, hsize_t_f *nrecords, size_t_f *type_size, size_t_f *field_offset, + hid_t_f *field_types, hsize_t_f *chunk_size, void *fill_data, int_f *compress, + size_t_f *char_len_field_names, /* field_names lengths */ + size_t_f *max_char_size_field_names, /* char len of fields */ + char *field_names, void *data) /* field_names */ { - char *c_name = NULL; - char *c_name1 = NULL; + char * c_name = NULL; + char * c_name1 = NULL; hsize_t num_elem; hsize_t i; - hsize_t c_nfields = (hsize_t)*nfields; + hsize_t c_nfields = (hsize_t)*nfields; size_t *c_field_offset = NULL; - hid_t *c_field_types = NULL; - char **c_field_names = NULL; - char *tmp = NULL, *tmp_p; - int_f ret_value = 0; + hid_t * c_field_types = NULL; + char ** c_field_names = NULL; + char * tmp = NULL, *tmp_p; + int_f ret_value = 0; num_elem = (hsize_t)*nfields; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_name1 = (char *)HD5f2cstring(name1, (size_t)*namelen1))) + if (NULL == (c_name1 = (char *)HD5f2cstring(name1, (size_t)*namelen1))) HGOTO_DONE(FAIL) - if(NULL == (c_field_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) + if (NULL == (c_field_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) - if(NULL == (c_field_types = (hid_t *)HDmalloc(sizeof(hid_t) * (size_t)c_nfields))) + if (NULL == (c_field_types = (hid_t *)HDmalloc(sizeof(hid_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) - for(i = 0; i < num_elem; i++) { - c_field_offset[i] = (size_t)field_offset[i]; - c_field_types[i] = field_types[i]; + for (i = 0; i < num_elem; i++) { + c_field_offset[i] = (size_t)field_offset[i]; + c_field_types[i] = field_types[i]; } /* end for */ /* * allocate array of character pointers */ - if(NULL == (c_field_names = (char **)HDcalloc((size_t)num_elem, sizeof(char *)))) + if (NULL == (c_field_names = (char **)HDcalloc((size_t)num_elem, sizeof(char *)))) HGOTO_DONE(FAIL) /* copy data to long C string */ - if(NULL == (tmp = (char *)HD5f2cstring(field_names, (size_t)*(max_char_size_field_names)*(size_t)num_elem))) + if (NULL == + (tmp = (char *)HD5f2cstring(field_names, (size_t) * (max_char_size_field_names) * (size_t)num_elem))) HGOTO_DONE(FAIL) /* * move data from temorary buffer */ tmp_p = tmp; - for(i = 0; i < num_elem; i++) { - if(NULL == (c_field_names[i] = (char *)HDmalloc((size_t)char_len_field_names[i] + 1))) + for (i = 0; i < num_elem; i++) { + if (NULL == (c_field_names[i] = (char *)HDmalloc((size_t)char_len_field_names[i] + 1))) HGOTO_DONE(FAIL) HDmemcpy(c_field_names[i], tmp_p, (size_t)char_len_field_names[i]); c_field_names[i][char_len_field_names[i]] = '\0'; - tmp_p = tmp_p + *max_char_size_field_names; + tmp_p = tmp_p + *max_char_size_field_names; } /* end for */ /* * call H5TBmake_table function. */ - if(H5TBmake_table(c_name1, (hid_t)*loc_id, c_name, c_nfields, (hsize_t)*nrecords, - (size_t)*type_size, (const char **)c_field_names, c_field_offset, c_field_types, - (hsize_t)*chunk_size, fill_data, *compress, data) < 0) + if (H5TBmake_table(c_name1, (hid_t)*loc_id, c_name, c_nfields, (hsize_t)*nrecords, (size_t)*type_size, + (const char **)c_field_names, c_field_offset, c_field_types, (hsize_t)*chunk_size, + fill_data, *compress, data) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); - if(c_name1) + if (c_name1) HDfree(c_name1); - if(c_field_names) { - for(i = 0; i < num_elem; i++) { - if(c_field_names[i]) + if (c_field_names) { + for (i = 0; i < num_elem; i++) { + if (c_field_names[i]) HDfree(c_field_names[i]); } /* end for */ HDfree(c_field_names); } /* end if */ - if(tmp) + if (tmp) HDfree(tmp); - if(c_field_offset) + if (c_field_offset) HDfree(c_field_offset); - if(c_field_types) + if (c_field_types) HDfree(c_field_types); return ret_value; } /* end h5tbmake_table_c() */ - /*------------------------------------------------------------------------- -* Function: h5tbread_table_c -* -* Purpose: Call H5TBread_table using F2003 features -* -* Return: Success: 0, Failure: -1 -* -* Programmer: M. Scot Breitenfeld -* -* Date: Sept. 14, 2015 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbread_table_c + * + * Purpose: Call H5TBread_table using F2003 features + * + * Return: Success: 0, Failure: -1 + * + * Programmer: M. Scot Breitenfeld + * + * Date: Sept. 14, 2015 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f -h5tbread_table_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hsize_t_f *nfields, - size_t_f *dst_size, size_t_f *dst_offset, size_t_f *dst_sizes, void *dst_buf) +h5tbread_table_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, hsize_t_f *nfields, size_t_f *dst_size, + size_t_f *dst_offset, size_t_f *dst_sizes, void *dst_buf) { - char *c_name = NULL; + char * c_name = NULL; size_t *c_dst_offset = NULL; - size_t *c_dst_sizes = NULL; - hsize_t c_nfields = (hsize_t)*nfields; - int_f ret_value = 0; + size_t *c_dst_sizes = NULL; + hsize_t c_nfields = (hsize_t)*nfields; + int_f ret_value = 0; hsize_t i; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_dst_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) + if (NULL == (c_dst_offset = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) - if(NULL == (c_dst_sizes = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) + if (NULL == (c_dst_sizes = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) - for(i = 0; i < c_nfields; i++) { - c_dst_offset[i] = (size_t)dst_offset[i]; - c_dst_sizes[i] = (size_t)dst_sizes[i]; + for (i = 0; i < c_nfields; i++) { + c_dst_offset[i] = (size_t)dst_offset[i]; + c_dst_sizes[i] = (size_t)dst_sizes[i]; } /* end for */ /* * call H5TBread_table function. */ - if(H5TBread_table( (hid_t)*loc_id, c_name, (size_t)*dst_size, c_dst_offset, - c_dst_sizes, dst_buf) < 0) + if (H5TBread_table((hid_t)*loc_id, c_name, (size_t)*dst_size, c_dst_offset, c_dst_sizes, dst_buf) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); - if(c_dst_offset) + if (c_dst_offset) HDfree(c_dst_offset); - if(c_dst_sizes) + if (c_dst_sizes) HDfree(c_dst_sizes); return ret_value; } /* end h5tbmake_table_c() */ - - - /*------------------------------------------------------------------------- -* Function: h5tbwrite_field_name_c -* -* Purpose: Call H5TBwrite_fields_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 12, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbwrite_field_name_c + * + * Purpose: Call H5TBwrite_fields_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 12, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f h5tbwrite_field_name_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, _fcd field_name, - hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, void *buf) + hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, void *buf) { - char *c_name = NULL; - char *c_name1 = NULL; - size_t c_type_size[1] = {(size_t)*type_size}; - int_f ret_value = 0; + char * c_name = NULL; + char * c_name1 = NULL; + size_t c_type_size[1] = {(size_t)*type_size}; + int_f ret_value = 0; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1))) + if (NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1))) HGOTO_DONE(FAIL) /* * call H5TBwrite_fields_name function. */ - if(H5TBwrite_fields_name((hid_t)*loc_id, c_name, c_name1, (hsize_t)*start, - (hsize_t)*nrecords, c_type_size[0], 0, c_type_size, buf) < 0) + if (H5TBwrite_fields_name((hid_t)*loc_id, c_name, c_name1, (hsize_t)*start, (hsize_t)*nrecords, + c_type_size[0], 0, c_type_size, buf) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); - if(c_name1) + if (c_name1) HDfree(c_name1); return ret_value; } - /*------------------------------------------------------------------------- -* Function: h5tbread_field_name_c -* -* Purpose: Call H5TBread_fields_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 12, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbread_field_name_c + * + * Purpose: Call H5TBread_fields_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 12, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f h5tbread_field_name_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, _fcd field_name, - hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, void *buf) + hsize_t_f *start, hsize_t_f *nrecords, size_t_f *type_size, void *buf) { - char *c_name = NULL; - char *c_name1 = NULL; - size_t c_type_size[1] = {(size_t)*type_size}; - int_f ret_value = 0; + char * c_name = NULL; + char * c_name1 = NULL; + size_t c_type_size[1] = {(size_t)*type_size}; + int_f ret_value = 0; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1))) + if (NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1))) HGOTO_DONE(FAIL) /* * call H5TBread_fields_name function. */ - if(H5TBread_fields_name((hid_t)*loc_id, c_name, c_name1, (hsize_t)*start, - (hsize_t)*nrecords, c_type_size[0], 0, c_type_size, buf) < 0) + if (H5TBread_fields_name((hid_t)*loc_id, c_name, c_name1, (hsize_t)*start, (hsize_t)*nrecords, + c_type_size[0], 0, c_type_size, buf) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); - if(c_name1) + if (c_name1) HDfree(c_name1); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5tbwrite_field_index_c -* -* Purpose: Call H5TBwrite_fields_index -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 12, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbwrite_field_index_c + * + * Purpose: Call H5TBwrite_fields_index + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 12, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f h5tbwrite_field_index_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *field_index, hsize_t_f *start, - hsize_t_f *nrecords, size_t_f *type_size, void *buf) + hsize_t_f *nrecords, size_t_f *type_size, void *buf) { - char *c_name = NULL; - size_t c_type_size = *type_size; - int c_field_index = *field_index - 1; /* C zero based index */ - int_f ret_value = 0; + char * c_name = NULL; + size_t c_type_size = *type_size; + int c_field_index = *field_index - 1; /* C zero based index */ + int_f ret_value = 0; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - /* * call H5TBwrite_fields_name function. */ - if(H5TBwrite_fields_index((hid_t)*loc_id, c_name, (hsize_t)1, &c_field_index, - (hsize_t)*start, (hsize_t)*nrecords, c_type_size, 0, &c_type_size, buf) < 0) + if (H5TBwrite_fields_index((hid_t)*loc_id, c_name, (hsize_t)1, &c_field_index, (hsize_t)*start, + (hsize_t)*nrecords, c_type_size, 0, &c_type_size, buf) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5tbread_field_index_c -* -* Purpose: Call H5TBread_fields_index -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 12, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbread_field_index_c + * + * Purpose: Call H5TBread_fields_index + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 12, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f h5tbread_field_index_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *field_index, hsize_t_f *start, - hsize_t_f *nrecords, size_t_f *type_size, void *buf) + hsize_t_f *nrecords, size_t_f *type_size, void *buf) { - char *c_name = NULL; - size_t c_type_size = *type_size; - int c_field_index = *field_index - 1; /* C zero based index */ - int_f ret_value = 0; + char * c_name = NULL; + size_t c_type_size = *type_size; + int c_field_index = *field_index - 1; /* C zero based index */ + int_f ret_value = 0; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) /* * call H5TBread_fields_index function. */ - if(H5TBread_fields_index((hid_t)*loc_id, c_name,(hsize_t)1, &c_field_index, - (hsize_t)*start, (hsize_t)*nrecords, c_type_size, 0, &c_type_size, buf) < 0) + if (H5TBread_fields_index((hid_t)*loc_id, c_name, (hsize_t)1, &c_field_index, (hsize_t)*start, + (hsize_t)*nrecords, c_type_size, 0, &c_type_size, buf) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5tbinsert_field_c -* -* Purpose: Call H5TBinsert_field -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 13, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbinsert_field_c + * + * Purpose: Call H5TBinsert_field + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 13, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f -h5tbinsert_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, - _fcd field_name, hid_t_f *field_type, int_f *position, void *buf) +h5tbinsert_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, _fcd field_name, + hid_t_f *field_type, int_f *position, void *buf) { - char *c_name = NULL; - char *c_name1 = NULL; - int_f ret_value = 0; + char *c_name = NULL; + char *c_name1 = NULL; + int_f ret_value = 0; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1))) + if (NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1))) HGOTO_DONE(FAIL) /* * call H5TBinsert_field function. */ - if(H5TBinsert_field((hid_t)*loc_id, c_name, c_name1, (hid_t)*field_type, - (hsize_t)*position, NULL, buf) < 0) + if (H5TBinsert_field((hid_t)*loc_id, c_name, c_name1, (hid_t)*field_type, (hsize_t)*position, NULL, buf) < + 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); - if(c_name1) + if (c_name1) HDfree(c_name1); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5tbdelete_field_c -* -* Purpose: Call H5TBdelete_field -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 13, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbdelete_field_c + * + * Purpose: Call H5TBdelete_field + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 13, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f -h5tbdelete_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, - size_t_f *namelen1, _fcd field_name) +h5tbdelete_field_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *namelen1, _fcd field_name) { - char *c_name = NULL; - char *c_name1 = NULL; - int_f ret_value = 0; + char *c_name = NULL; + char *c_name1 = NULL; + int_f ret_value = 0; /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1))) + if (NULL == (c_name1 = (char *)HD5f2cstring(field_name, (size_t)*namelen1))) HGOTO_DONE(FAIL) /* * call H5TBinsert_field function. */ - if(H5TBdelete_field((hid_t)*loc_id, c_name, c_name1) < 0) + if (H5TBdelete_field((hid_t)*loc_id, c_name, c_name1) < 0) HGOTO_DONE(FAIL) done: - if(c_name) + if (c_name) HDfree(c_name); - if(c_name1) + if (c_name1) HDfree(c_name1); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5tbget_table_info_c -* -* Purpose: Call H5TBread_fields_index -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 12, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbget_table_info_c + * + * Purpose: Call H5TBread_fields_index + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 12, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f -h5tbget_table_info_c(hid_t_f *loc_id, size_t_f *namelen, - _fcd name, hsize_t_f *nfields, hsize_t_f *nrecords) +h5tbget_table_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *nfields, hsize_t_f *nrecords) { - char *c_name = NULL; + char * c_name = NULL; hsize_t c_nfields; hsize_t c_nrecords; int_f ret_value = 0; @@ -600,62 +591,61 @@ h5tbget_table_info_c(hid_t_f *loc_id, size_t_f *namelen, /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - /* * call H5TBread_fields_index function. */ - if(H5TBget_table_info((hid_t)*loc_id, c_name, &c_nfields, &c_nrecords) < 0) + if (H5TBget_table_info((hid_t)*loc_id, c_name, &c_nfields, &c_nrecords) < 0) HGOTO_DONE(FAIL) - *nfields = (hsize_t_f) c_nfields; - *nrecords = (hsize_t_f) c_nrecords; + *nfields = (hsize_t_f)c_nfields; + *nrecords = (hsize_t_f)c_nrecords; done: - if(c_name) + if (c_name) HDfree(c_name); return ret_value; } /*------------------------------------------------------------------------- -* Function: h5tbget_field_info_c -* -* Purpose: Call H5TBget_field_info -* -* Return: Success: 0, Failure: -1 -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: October 13, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: h5tbget_field_info_c + * + * Purpose: Call H5TBget_field_info + * + * Return: Success: 0, Failure: -1 + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: October 13, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ int_f -h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *nfields, - size_t_f *field_sizes, size_t_f *field_offsets, size_t_f *type_size, - size_t_f *namelen2, /* field_names lengths */ - size_t_f *lenmax, /* character len max */ - _fcd field_names, /* field_names */ - size_t_f *maxlen_out) +h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *nfields, size_t_f *field_sizes, + size_t_f *field_offsets, size_t_f *type_size, + size_t_f *namelen2, /* field_names lengths */ + size_t_f *lenmax, /* character len max */ + _fcd field_names, /* field_names */ + size_t_f *maxlen_out) { - char *c_name = NULL; + char * c_name = NULL; hsize_t num_elem; - hsize_t c_nfields = *nfields; - size_t *c_field_sizes = NULL; + hsize_t c_nfields = *nfields; + size_t *c_field_sizes = NULL; size_t *c_field_offsets = NULL; size_t c_type_size; - char **c_field_names = NULL; - char *tmp = NULL, *tmp_p; + char ** c_field_names = NULL; + char * tmp = NULL, *tmp_p; hsize_t i; int_f ret_value = 0; - size_t c_lenmax; - size_t length = 0; + size_t c_lenmax; + size_t length = 0; c_lenmax = (size_t)*lenmax; @@ -664,47 +654,47 @@ h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *n /* * convert FORTRAN name to C name */ - if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) + if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen))) HGOTO_DONE(FAIL) - if(NULL == (c_field_offsets = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) + if (NULL == (c_field_offsets = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) - if(NULL == (c_field_sizes = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) + if (NULL == (c_field_sizes = (size_t *)HDmalloc(sizeof(size_t) * (size_t)c_nfields))) HGOTO_DONE(FAIL) - if(NULL == (c_field_names = (char **)HDcalloc((size_t)c_nfields, sizeof(char *)))) + if (NULL == (c_field_names = (char **)HDcalloc((size_t)c_nfields, sizeof(char *)))) HGOTO_DONE(FAIL) - for(i = 0; i < c_nfields; i++) - if(NULL == (c_field_names[i] = (char *)HDmalloc(sizeof(char) * HLTB_MAX_FIELD_LEN))) + for (i = 0; i < c_nfields; i++) + if (NULL == (c_field_names[i] = (char *)HDmalloc(sizeof(char) * HLTB_MAX_FIELD_LEN))) HGOTO_DONE(FAIL) /* * call H5TBget_field_info function. */ - if(H5TBget_field_info((hid_t)*loc_id, c_name, c_field_names, c_field_sizes, - c_field_offsets, &c_type_size) < 0) + if (H5TBget_field_info((hid_t)*loc_id, c_name, c_field_names, c_field_sizes, c_field_offsets, + &c_type_size) < 0) HGOTO_DONE(FAIL) /* return values */ /* names array */ - if(NULL == (tmp = (char *)HDmalloc((c_lenmax * (size_t)c_nfields) + 1))) + if (NULL == (tmp = (char *)HDmalloc((c_lenmax * (size_t)c_nfields) + 1))) HGOTO_DONE(FAIL) tmp_p = tmp; HDmemset(tmp, ' ', c_lenmax * (size_t)c_nfields); tmp[c_lenmax * c_nfields] = '\0'; - for(i = 0; i < c_nfields; i++) { - size_t field_name_len = HDstrlen(c_field_names[i]); + for (i = 0; i < c_nfields; i++) { + size_t field_name_len = HDstrlen(c_field_names[i]); - HDmemcpy(tmp_p, c_field_names[i], field_name_len); - namelen2[i] = (size_t_f)field_name_len; - length = MAX(length, strlen((c_field_names[i]))); - tmp_p = tmp_p + c_lenmax; + HDmemcpy(tmp_p, c_field_names[i], field_name_len); + namelen2[i] = (size_t_f)field_name_len; + length = MAX(length, strlen((c_field_names[i]))); + tmp_p = tmp_p + c_lenmax; } /* end for */ - HD5packFstring(tmp, _fcdtocp(field_names), (size_t)( c_lenmax* c_nfields)); + HD5packFstring(tmp, _fcdtocp(field_names), (size_t)(c_lenmax * c_nfields)); *type_size = (size_t_f)c_type_size; - for(i = 0; i < num_elem; i++) { + for (i = 0; i < num_elem; i++) { field_sizes[i] = (size_t_f)c_field_sizes[i]; field_offsets[i] = (size_t_f)c_field_offsets[i]; } /* end for */ @@ -712,21 +702,20 @@ h5tbget_field_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *n *maxlen_out = (size_t_f)length; done: - if(c_name) + if (c_name) HDfree(c_name); - if(c_field_names) { - for(i = 0; i < num_elem; i++) - if(c_field_names[i]) + if (c_field_names) { + for (i = 0; i < num_elem; i++) + if (c_field_names[i]) HDfree(c_field_names[i]); HDfree(c_field_names); } /* end if */ - if(tmp) + if (tmp) HDfree(tmp); - if(c_field_offsets) + if (c_field_offsets) HDfree(c_field_offsets); - if(c_field_sizes) + if (c_field_sizes) HDfree(c_field_sizes); return ret_value; } - diff --git a/hl/src/H5DO.c b/hl/src/H5DO.c index 66997cb..5b617cc 100644 --- a/hl/src/H5DO.c +++ b/hl/src/H5DO.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* High-level library internal header file */ #include "H5HLprivate2.h" @@ -18,7 +18,7 @@ #include "H5DOpublic.h" #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5DOwrite_chunk * @@ -33,8 +33,8 @@ *------------------------------------------------------------------------- */ herr_t -H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, - size_t data_size, const void *buf) +H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, size_t data_size, + const void *buf) { /* Call underlying H5D function */ if (H5Dwrite_chunk(dset_id, dxpl_id, filters, offset, data_size, buf) < 0) @@ -44,7 +44,6 @@ H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *o } /* end H5DOwrite_chunk() */ - /*------------------------------------------------------------------------- * Function: H5DOread_chunk * @@ -59,19 +58,17 @@ H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *o *--------------------------------------------------------------------------- */ herr_t -H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, - void *buf) +H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf) { /* Call underlying H5D function */ if (H5Dread_chunk(dset_id, dxpl_id, offset, filters, buf) < 0) return FAIL; else return SUCCEED; - } /* end H5DOread_chunk() */ +} /* end H5DOread_chunk() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: H5DOappend() * @@ -103,57 +100,56 @@ H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fi *------------------------------------------------------------------------- */ herr_t -H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, - hid_t memtype, const void *buf) +H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, hid_t memtype, const void *buf) { - hsize_t size[H5S_MAX_RANK]; /* The new size (after extension */ - hsize_t old_size = 0; /* The size of the dimension to be extended */ - int sndims; /* Number of dimensions in dataspace (signed) */ - unsigned ndims; /* Number of dimensions in dataspace */ - hid_t space_id = FAIL; /* Old file space */ - hid_t new_space_id = FAIL; /* New file space (after extension) */ - hid_t mem_space_id = FAIL; /* Memory space for data buffer */ - hssize_t snelmts; /* Number of elements in selection (signed) */ - hsize_t nelmts; /* Number of elements in selection */ - hid_t dapl = FAIL; /* Dataset access property list */ - - hsize_t start[H5S_MAX_RANK]; /* H5Sselect_Hyperslab: starting offset */ - hsize_t count[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of blocks to select */ - hsize_t stride[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements to move when selecting */ - hsize_t block[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements in a block */ - - hsize_t *boundary = NULL; /* Boundary set in append flush property */ - H5D_append_cb_t append_cb; /* Callback function set in append flush property */ - void *udata; /* User data set in append flush property */ - hbool_t hit = FALSE; /* Boundary is hit or not */ - hsize_t k; /* Local index variable */ - unsigned u; /* Local index variable */ - herr_t ret_value = FAIL; /* Return value */ + hsize_t size[H5S_MAX_RANK]; /* The new size (after extension */ + hsize_t old_size = 0; /* The size of the dimension to be extended */ + int sndims; /* Number of dimensions in dataspace (signed) */ + unsigned ndims; /* Number of dimensions in dataspace */ + hid_t space_id = FAIL; /* Old file space */ + hid_t new_space_id = FAIL; /* New file space (after extension) */ + hid_t mem_space_id = FAIL; /* Memory space for data buffer */ + hssize_t snelmts; /* Number of elements in selection (signed) */ + hsize_t nelmts; /* Number of elements in selection */ + hid_t dapl = FAIL; /* Dataset access property list */ + + hsize_t start[H5S_MAX_RANK]; /* H5Sselect_Hyperslab: starting offset */ + hsize_t count[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of blocks to select */ + hsize_t stride[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements to move when selecting */ + hsize_t block[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements in a block */ + + hsize_t * boundary = NULL; /* Boundary set in append flush property */ + H5D_append_cb_t append_cb; /* Callback function set in append flush property */ + void * udata; /* User data set in append flush property */ + hbool_t hit = FALSE; /* Boundary is hit or not */ + hsize_t k; /* Local index variable */ + unsigned u; /* Local index variable */ + herr_t ret_value = FAIL; /* Return value */ /* check arguments */ - if(H5I_DATASET != H5Iget_type(dset_id)) + if (H5I_DATASET != H5Iget_type(dset_id)) goto done; /* If the user passed in a default DXPL, sanity check it */ - if(H5P_DEFAULT != dxpl_id) - if(TRUE != H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) + if (H5P_DEFAULT != dxpl_id) + if (TRUE != H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) goto done; /* Get the dataspace of the dataset */ - if(FAIL == (space_id = H5Dget_space(dset_id))) + if (FAIL == (space_id = H5Dget_space(dset_id))) goto done; /* Get the rank of this dataspace */ - if((sndims = H5Sget_simple_extent_ndims(space_id)) < 0) + if ((sndims = H5Sget_simple_extent_ndims(space_id)) < 0) goto done; ndims = (unsigned)sndims; /* Verify correct axis */ - if(axis >= ndims) + if (axis >= ndims) goto done; /* Get the dimensions sizes of the dataspace */ - if(H5Sget_simple_extent_dims(space_id, size, NULL) < 0) + if (H5Sget_simple_extent_dims(space_id, size, NULL) < 0) goto done; /* Adjust the dimension size of the requested dimension, @@ -161,99 +157,98 @@ H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, */ old_size = size[axis]; size[axis] += extension; - if(size[axis] < old_size) + if (size[axis] < old_size) goto done; /* Set the extent of the dataset to the new dimension */ - if(H5Dset_extent(dset_id, size) < 0) + if (H5Dset_extent(dset_id, size) < 0) goto done; /* Get the new dataspace of the dataset */ - if(FAIL == (new_space_id = H5Dget_space(dset_id))) + if (FAIL == (new_space_id = H5Dget_space(dset_id))) goto done; /* Select a hyperslab corresponding to the append operation */ - for(u = 0 ; u < ndims ; u++) { - start[u] = 0; + for (u = 0; u < ndims; u++) { + start[u] = 0; stride[u] = 1; - count[u] = size[u]; - block[u] = 1; - if(u == axis) { + count[u] = size[u]; + block[u] = 1; + if (u == axis) { count[u] = extension; start[u] = old_size; } /* end if */ - } /* end for */ - if(FAIL == H5Sselect_hyperslab(new_space_id, H5S_SELECT_SET, start, stride, count, block)) + } /* end for */ + if (FAIL == H5Sselect_hyperslab(new_space_id, H5S_SELECT_SET, start, stride, count, block)) goto done; /* The # of elemnts in the new extended dataspace */ - if((snelmts = H5Sget_select_npoints(new_space_id)) < 0) + if ((snelmts = H5Sget_select_npoints(new_space_id)) < 0) goto done; nelmts = (hsize_t)snelmts; /* create a memory space */ - if(FAIL == (mem_space_id = H5Screate_simple(1, &nelmts, NULL))) + if (FAIL == (mem_space_id = H5Screate_simple(1, &nelmts, NULL))) goto done; /* Write the data */ - if(H5Dwrite(dset_id, memtype, mem_space_id, new_space_id, dxpl_id, buf) < 0) + if (H5Dwrite(dset_id, memtype, mem_space_id, new_space_id, dxpl_id, buf) < 0) goto done; /* Obtain the dataset's access property list */ - if((dapl = H5Dget_access_plist(dset_id)) < 0) + if ((dapl = H5Dget_access_plist(dset_id)) < 0) goto done; /* Allocate the boundary array */ boundary = (hsize_t *)HDmalloc(ndims * sizeof(hsize_t)); /* Retrieve the append flush property */ - if(H5Pget_append_flush(dapl, ndims, boundary, &append_cb, &udata) < 0) + if (H5Pget_append_flush(dapl, ndims, boundary, &append_cb, &udata) < 0) goto done; /* No boundary for this axis */ - if(boundary[axis] != 0) { + if (boundary[axis] != 0) { /* Determine whether a boundary is hit or not */ - for(k = start[axis]; k < size[axis]; k++) - if(!((k + 1) % boundary[axis])) { + for (k = start[axis]; k < size[axis]; k++) + if (!((k + 1) % boundary[axis])) { hit = TRUE; break; } - if(hit) { /* Hit the boundary */ + if (hit) { /* Hit the boundary */ /* Invoke callback if there is one */ - if(append_cb && append_cb(dset_id, size, udata) < 0) + if (append_cb && append_cb(dset_id, size, udata) < 0) goto done; - /* Do a dataset flush */ - if(H5Dflush(dset_id) < 0) + /* Do a dataset flush */ + if (H5Dflush(dset_id) < 0) goto done; } /* end if */ - } /* end if */ + } /* end if */ /* Indicate success */ ret_value = SUCCEED; done: /* Close old dataspace */ - if(space_id != FAIL && H5Sclose(space_id) < 0) + if (space_id != FAIL && H5Sclose(space_id) < 0) ret_value = FAIL; /* Close new dataspace */ - if(new_space_id != FAIL && H5Sclose(new_space_id) < 0) + if (new_space_id != FAIL && H5Sclose(new_space_id) < 0) ret_value = FAIL; /* Close memory dataspace */ - if(mem_space_id != FAIL && H5Sclose(mem_space_id) < 0) + if (mem_space_id != FAIL && H5Sclose(mem_space_id) < 0) ret_value = FAIL; /* Close the dataset access property list */ - if(dapl != FAIL && H5Pclose(dapl) < 0) + if (dapl != FAIL && H5Pclose(dapl) < 0) ret_value = FAIL; - if(boundary) + if (boundary) HDfree(boundary); return ret_value; } /* H5DOappend() */ - diff --git a/hl/src/H5DOpublic.h b/hl/src/H5DOpublic.h index e09ebca..214f1e5 100644 --- a/hl/src/H5DOpublic.h +++ b/hl/src/H5DOpublic.h @@ -25,8 +25,8 @@ extern "C" { *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, - size_t extension, hid_t memtype, const void *buf); +H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, hid_t memtype, + const void *buf); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -35,10 +35,10 @@ H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Compatibility wrappers for functionality moved to H5D */ -H5_HLDLL herr_t H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, - const hsize_t *offset, size_t data_size, const void *buf); -H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, - uint32_t *filters /*out*/, void *buf /*out*/); +H5_HLDLL herr_t H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, + size_t data_size, const void *buf); +H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters /*out*/, + void *buf /*out*/); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -47,4 +47,3 @@ H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offs #endif #endif - diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 63fb461..7cb5759 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -19,138 +19,133 @@ #include "H5IMprivate.h" #include "H5TBprivate.h" - /* Local routines */ static herr_t H5DS_is_reserved(hid_t did); -static hid_t H5DS_get_REFLIST_type(void); +static hid_t H5DS_get_REFLIST_type(void); /*------------------------------------------------------------------------- -* Function: H5DSset_scale -* -* Purpose: The dataset DSID is converted to a Dimension Scale dataset. -* Creates the CLASS attribute, set to the value "DIMENSION_SCALE" -* and an empty REFERENCE_LIST attribute. -* If DIMNAME is specified, then an attribute called NAME is created, -* with the value DIMNAME. -* -* Return: Success: SUCCEED, Failure: FAIL -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: January 04, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5DSset_scale(hid_t dsid, - const char *dimname) + * Function: H5DSset_scale + * + * Purpose: The dataset DSID is converted to a Dimension Scale dataset. + * Creates the CLASS attribute, set to the value "DIMENSION_SCALE" + * and an empty REFERENCE_LIST attribute. + * If DIMNAME is specified, then an attribute called NAME is created, + * with the value DIMNAME. + * + * Return: Success: SUCCEED, Failure: FAIL + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: January 04, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5DSset_scale(hid_t dsid, const char *dimname) { - int has_dimlist; + int has_dimlist; H5I_type_t it; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(dsid)) < 0) return FAIL; - if (H5I_DATASET!=it) + if (H5I_DATASET != it) return FAIL; /*------------------------------------------------------------------------- - * check if the dataset is a dataset wich has references to dimension scales - *------------------------------------------------------------------------- - */ + * check if the dataset is a dataset wich has references to dimension scales + *------------------------------------------------------------------------- + */ /* try to find the attribute "DIMENSION_LIST" */ - if ((has_dimlist = H5LT_find_attribute(dsid,DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(dsid, DIMENSION_LIST)) < 0) return FAIL; if (has_dimlist == 1) return FAIL; /*------------------------------------------------------------------------- - * write the standard attributes for a Dimension Scale dataset - *------------------------------------------------------------------------- - */ + * write the standard attributes for a Dimension Scale dataset + *------------------------------------------------------------------------- + */ - if (H5LT_set_attribute_string(dsid,"CLASS",DIMENSION_SCALE_CLASS) < 0) + if (H5LT_set_attribute_string(dsid, "CLASS", DIMENSION_SCALE_CLASS) < 0) return FAIL; - if (dimname!=NULL) - { - if (H5LT_set_attribute_string(dsid,"NAME",dimname) < 0) + if (dimname != NULL) { + if (H5LT_set_attribute_string(dsid, "NAME", dimname) < 0) return FAIL; } return SUCCEED; } - - /*------------------------------------------------------------------------- -* Function: H5DSattach_scale -* -* Purpose: Define Dimension Scale DSID to be associated with dimension IDX -* of Dataset DID. Entries are created in the DIMENSION_LIST and -* REFERENCE_LIST attributes. -* -* Return: -* Success: SUCCEED -* Failure: FAIL -* -* Fails if: Bad arguments -* If DSID is not a Dimension Scale -* If DID is a Dimension Scale (A Dimension Scale cannot have scales) -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: December 20, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5DSattach_scale(hid_t did, - hid_t dsid, - unsigned int idx) + * Function: H5DSattach_scale + * + * Purpose: Define Dimension Scale DSID to be associated with dimension IDX + * of Dataset DID. Entries are created in the DIMENSION_LIST and + * REFERENCE_LIST attributes. + * + * Return: + * Success: SUCCEED + * Failure: FAIL + * + * Fails if: Bad arguments + * If DSID is not a Dimension Scale + * If DID is a Dimension Scale (A Dimension Scale cannot have scales) + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: December 20, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) { - int has_dimlist; - int has_reflist; - int is_ds; - hssize_t nelmts; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ - ds_list_t dsl; /* attribute data in the DS pointing to the dataset */ - ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hobj_ref_t ref_to_ds; /* reference to the DS */ - hobj_ref_t ref_j; /* iterator reference */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + int has_dimlist; + int has_reflist; + int is_ds; + hssize_t nelmts; + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t ntid = -1; /* attribute native type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ + ds_list_t dsl; /* attribute data in the DS pointing to the dataset */ + ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + hobj_ref_t ref_to_ds; /* reference to the DS */ + hobj_ref_t ref_j; /* iterator reference */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ H5O_info2_t oi1, oi2; - H5I_type_t it1, it2; - int i; - size_t len; - int found_ds=0; - htri_t is_scale; + H5I_type_t it1, it2; + int i; + size_t len; + int found_ds = 0; + htri_t is_scale; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ if ((is_scale = H5DSis_scale(did)) < 0) return FAIL; @@ -160,20 +155,20 @@ herr_t H5DSattach_scale(hid_t did, return FAIL; /* get info for the dataset in the parameter list */ - if(H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0) return FAIL; /* get info for the scale in the parameter list */ - if(H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0) return FAIL; /* same object, not valid */ - if(oi1.fileno == oi2.fileno) { + if (oi1.fileno == oi2.fileno) { int token_cmp; - if(H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) + if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) return FAIL; - if(!token_cmp) + if (!token_cmp) return FAIL; } /* end if */ @@ -187,21 +182,20 @@ herr_t H5DSattach_scale(hid_t did, return FAIL; /* the DS dataset cannot have dimension scales */ - if (H5LT_find_attribute(dsid,DIMENSION_LIST)==1) + if (H5LT_find_attribute(dsid, DIMENSION_LIST) == 1) return FAIL; /* check if the dataset is a "reserved" dataset (image, table) */ - if (H5DS_is_reserved(did)==1) + if (H5DS_is_reserved(did) == 1) return FAIL; - /*------------------------------------------------------------------------- - * The dataset may or may not have the associated DS attribute - * First we try to open to see if it is already there; if not, it is created. - * If it exists, the array of references is extended to hold the reference - * to the new DS - *------------------------------------------------------------------------- - */ + * The dataset may or may not have the associated DS attribute + * First we try to open to see if it is already there; if not, it is created. + * If it exists, the array of references is extended to hold the reference + * to the new DS + *------------------------------------------------------------------------- + */ /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) @@ -220,14 +214,14 @@ herr_t H5DSattach_scale(hid_t did, return FAIL; /* parameter range checking */ - if (idx > (unsigned)rank-1) + if (idx > (unsigned)rank - 1) return FAIL; /*------------------------------------------------------------------------- - * two references are created: one to the DS, saved in "DIMENSION_LIST" - * and one to the dataset, saved in "REFERENCE_LIST" - *------------------------------------------------------------------------- - */ + * two references are created: one to the DS, saved in "DIMENSION_LIST" + * and one to the dataset, saved in "REFERENCE_LIST" + *------------------------------------------------------------------------- + */ /* create a reference for the >>DS<< dataset */ if (H5Rcreate(&ref_to_ds, dsid, ".", H5R_OBJECT, (hid_t)-1) < 0) return FAIL; @@ -237,57 +231,56 @@ herr_t H5DSattach_scale(hid_t did, return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if ((has_dimlist = H5LT_find_attribute(did,DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; /*------------------------------------------------------------------------- - * it does not exist. we create the attribute and its reference data - *------------------------------------------------------------------------- - */ - if (has_dimlist == 0) - { + * it does not exist. we create the attribute and its reference data + *------------------------------------------------------------------------- + */ + if (has_dimlist == 0) { dims[0] = (hsize_t)rank; /* space for the attribute */ - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) return FAIL; /* create the type for the attribute "DIMENSION_LIST" */ - if((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0) + if ((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0) goto out; /* create the attribute */ - if((aid = H5Acreate2(did, DIMENSION_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, DIMENSION_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* allocate and initialize the VL */ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; - for(i = 0; i < rank; i++) { + for (i = 0; i < rank; i++) { buf[i].len = 0; - buf[i].p = NULL; + buf[i].p = NULL; } /* store the REF information in the index of the dataset that has the DS */ - buf[idx].len = 1; - buf[idx].p = HDmalloc( 1 * sizeof(hobj_ref_t)); + buf[idx].len = 1; + buf[idx].p = HDmalloc(1 * sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; /* write the attribute with the reference */ - if(H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, buf) < 0) goto out; /* close */ - if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; HDfree(buf); @@ -295,218 +288,217 @@ herr_t H5DSattach_scale(hid_t did, } /*------------------------------------------------------------------------- - * the attribute already exists, open it, extend the buffer, - * and insert the new reference - *------------------------------------------------------------------------- - */ - else if(has_dimlist == 1) - { - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + * the attribute already exists, open it, extend the buffer, + * and insert the new reference + *------------------------------------------------------------------------- + */ + else if (has_dimlist == 1) { + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; /* read */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* check to avoid inserting duplicates. it is not FAIL, just do nothing */ /* iterate all the REFs in this dimension IDX */ - for(i = 0; i < (int)buf[idx].len; i++) { + for (i = 0; i < (int)buf[idx].len; i++) { /* get the reference */ ref_j = ((hobj_ref_t *)buf[idx].p)[i]; /* get the scale id for this REF */ - if((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0) + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0) goto out; /* get info for DS in the parameter list */ - if(H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0) goto out; /* get info for this DS */ - if(H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0) goto out; /* same object, so this DS scale is already in this DIM IDX */ - if(oi1.fileno == oi2.fileno) { + if (oi1.fileno == oi2.fileno) { int token_cmp; - if(H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) + if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) goto out; - if(!token_cmp) + if (!token_cmp) found_ds = 1; } /* end if */ /* close the dereferenced dataset */ - if(H5Dclose(dsid_j) < 0) + if (H5Dclose(dsid_j) < 0) goto out; } /* end for */ - if(found_ds == 0) { + if (found_ds == 0) { /* we are adding one more DS to this dimension */ - if(buf[idx].len > 0) { + if (buf[idx].len > 0) { buf[idx].len++; - len = buf[idx].len; - buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t)); + len = buf[idx].len; + buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[len - 1] = ref_to_ds; } /* end if */ else { /* store the REF information in the index of the dataset that has the DS */ - buf[idx].len = 1; - buf[idx].p = HDmalloc(sizeof(hobj_ref_t)); + buf[idx].len = 1; + buf[idx].p = HDmalloc(sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; } /* end else */ - } /* end if */ + } /* end if */ /* write the attribute with the new references */ - if(H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, buf) < 0) goto out; /* close */ - if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; HDfree(buf); buf = NULL; } /* has_dimlist */ /*------------------------------------------------------------------------- - * save DS info on the >>DS<< dataset - *------------------------------------------------------------------------- - */ + * save DS info on the >>DS<< dataset + *------------------------------------------------------------------------- + */ /* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */ - if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) + if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) goto out; /*------------------------------------------------------------------------- - * it does not exist. we create the attribute and its reference data - *------------------------------------------------------------------------- - */ - if(has_reflist == 0) { + * it does not exist. we create the attribute and its reference data + *------------------------------------------------------------------------- + */ + if (has_reflist == 0) { dims[0] = 1; /* space for the attribute */ - if((sid = H5Screate_simple(1,dims,NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* create the compound datatype for the attribute "REFERENCE_LIST" */ - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) goto out; /* insert reference field */ - if(H5Tinsert(tid, "dataset", HOFFSET(ds_list_t,ref), H5T_STD_REF_OBJ) < 0) + if (H5Tinsert(tid, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0) goto out; /* insert dimension idx of the dataset field */ - if(H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) + if (H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) goto out; /* create the attribute */ - if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* store the IDX information */ dsl.dim_idx = idx; /* write the attribute with the reference */ - if(H5Awrite(aid, tid, &dsl) < 0) + if (H5Awrite(aid, tid, &dsl) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; } /* end if */ /*------------------------------------------------------------------------- - * the "REFERENCE_LIST" array already exists, open it and extend it - *------------------------------------------------------------------------- - */ - else if(has_reflist == 1) { - if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) + * the "REFERENCE_LIST" array already exists, open it and extend it + *------------------------------------------------------------------------- + */ + else if (has_reflist == 1) { + if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* get native type to read attribute REFERENCE_LIST */ - if((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5DS_get_REFLIST_type()) < 0) goto out; /* get and save the old reference(s) */ - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; - if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) + if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; nelmts++; - dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); - if(dsbuf == NULL) + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf == NULL) goto out; - if(H5Aread(aid, ntid, dsbuf) < 0) + if (H5Aread(aid, ntid, dsbuf) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; /*------------------------------------------------------------------------- - * create a new attribute - *------------------------------------------------------------------------- - */ + * create a new attribute + *------------------------------------------------------------------------- + */ /* the attribute must be deleted, in order to the new one can reflect the changes*/ - if(H5Adelete(dsid, REFERENCE_LIST) < 0) + if (H5Adelete(dsid, REFERENCE_LIST) < 0) goto out; /* store the IDX information (index of the dataset that has the DS) */ - dsl.dim_idx = idx; + dsl.dim_idx = idx; dsbuf[nelmts - 1] = dsl; /* create a new data space for the new references array */ dims[0] = (hsize_t)nelmts; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* create the attribute again with the changes of space */ - if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* write the attribute with the new references */ - if(H5Awrite(aid, ntid, dsbuf) < 0) + if (H5Awrite(aid, ntid, dsbuf) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; if (H5Tclose(ntid) < 0) goto out; @@ -516,15 +508,15 @@ herr_t H5DSattach_scale(hid_t did, } /* has_reflist */ /*------------------------------------------------------------------------- - * write the standard attributes for a Dimension Scale dataset - *------------------------------------------------------------------------- - */ + * write the standard attributes for a Dimension Scale dataset + *------------------------------------------------------------------------- + */ - if((is_ds = H5DSis_scale(dsid)) < 0) + if ((is_ds = H5DSis_scale(dsid)) < 0) return FAIL; - if(is_ds == 0) { - if (H5LT_set_attribute_string(dsid,"CLASS",DIMENSION_SCALE_CLASS) < 0) + if (is_ds == 0) { + if (H5LT_set_attribute_string(dsid, "CLASS", DIMENSION_SCALE_CLASS) < 0) return FAIL; } @@ -532,117 +524,117 @@ herr_t H5DSattach_scale(hid_t did, /* error zone */ out: - if(buf) + if (buf) HDfree(buf); - if(dsbuf) + if (dsbuf) HDfree(dsbuf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Tclose(ntid); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /*------------------------------------------------------------------------- -* Function: H5DSdetach_scale -* -* Purpose: If possible, deletes association of Dimension Scale DSID with -* dimension IDX of Dataset DID. This deletes the entries in the -* DIMENSION_LIST and REFERENCE_LIST attributes. -* -* Return: -* Success: SUCCEED -* Failure: FAIL -* -* Fails if: Bad arguments -* The dataset DID or DSID do not exist. -* The DSID is not a Dimension Scale -* DSID is not attached to DID. -* Note that a scale may be associated with more than dimension of the same dataset. -* If so, the detach operation only deletes one of the associations, for DID. -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: December 20, 2004 -* -* Comments: -* -* Modifications: Function didn't delete DIMENSION_LIST attribute, when -* all dimension scales were detached from a dataset; added. -* 2010/05/13 EIP -* -*------------------------------------------------------------------------- -*/ - -herr_t H5DSdetach_scale(hid_t did, - hid_t dsid, - unsigned int idx) + * Function: H5DSdetach_scale + * + * Purpose: If possible, deletes association of Dimension Scale DSID with + * dimension IDX of Dataset DID. This deletes the entries in the + * DIMENSION_LIST and REFERENCE_LIST attributes. + * + * Return: + * Success: SUCCEED + * Failure: FAIL + * + * Fails if: Bad arguments + * The dataset DID or DSID do not exist. + * The DSID is not a Dimension Scale + * DSID is not attached to DID. + * Note that a scale may be associated with more than dimension of the same dataset. + * If so, the detach operation only deletes one of the associations, for DID. + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: December 20, 2004 + * + * Comments: + * + * Modifications: Function didn't delete DIMENSION_LIST attribute, when + * all dimension scales were detached from a dataset; added. + * 2010/05/13 EIP + * + *------------------------------------------------------------------------- + */ + +herr_t +H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) { - int has_dimlist; - int has_reflist; - hssize_t nelmts; - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ - hid_t did_i; /* dataset ID in REFERENCE_LIST */ - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ - hobj_ref_t ref; /* reference to the DS */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - int i; - size_t j; - hssize_t ii; + int has_dimlist; + int has_reflist; + hssize_t nelmts; + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + hid_t did_i; /* dataset ID in REFERENCE_LIST */ + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t ntid = -1; /* attribute native type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ + hobj_ref_t ref; /* reference to the DS */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + int i; + size_t j; + hssize_t ii; H5O_info2_t did_oi, dsid_oi, tmp_oi; - int found_dset = 0, found_ds = 0; - int have_ds = 0; - htri_t is_scale; + int found_dset = 0, found_ds = 0; + int have_ds = 0; + htri_t is_scale; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* check for valid types of identifiers */ - if(H5I_DATASET != H5Iget_type(did) || H5I_DATASET != H5Iget_type(dsid)) + if (H5I_DATASET != H5Iget_type(did) || H5I_DATASET != H5Iget_type(dsid)) return FAIL; - if((is_scale = H5DSis_scale(did)) < 0) + if ((is_scale = H5DSis_scale(did)) < 0) return FAIL; /* the dataset cannot be a DS dataset */ - if( is_scale == 1) + if (is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ - if(H5Oget_info3(did, &did_oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &did_oi, H5O_INFO_BASIC) < 0) return FAIL; /* get info for the scale in the parameter list */ - if(H5Oget_info3(dsid, &dsid_oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &dsid_oi, H5O_INFO_BASIC) < 0) return FAIL; /* same object, not valid */ - if(did_oi.fileno == dsid_oi.fileno) { + if (did_oi.fileno == dsid_oi.fileno) { int token_cmp; - if(H5Otoken_cmp(did, &did_oi.token, &dsid_oi.token, &token_cmp) < 0) + if (H5Otoken_cmp(did, &did_oi.token, &dsid_oi.token, &token_cmp) < 0) return FAIL; - if(!token_cmp) + if (!token_cmp) return FAIL; } /* end if */ - /*------------------------------------------------------------------------- - * Find "DIMENSION_LIST" - *------------------------------------------------------------------------- - */ + * Find "DIMENSION_LIST" + *------------------------------------------------------------------------- + */ /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; @@ -663,58 +655,56 @@ herr_t H5DSdetach_scale(hid_t did, return FAIL; /* parameter range checking */ - if (idx > (unsigned)rank-1) + if (idx > (unsigned)rank - 1) return FAIL; /*------------------------------------------------------------------------- - * find "REFERENCE_LIST" - *------------------------------------------------------------------------- - */ + * find "REFERENCE_LIST" + *------------------------------------------------------------------------- + */ /* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */ - if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) + if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) return FAIL; - if(has_reflist == 0) + if (has_reflist == 0) return FAIL; /*------------------------------------------------------------------------- - * open "DIMENSION_LIST", and delete the reference - *------------------------------------------------------------------------- - */ + * open "DIMENSION_LIST", and delete the reference + *------------------------------------------------------------------------- + */ - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) return FAIL; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; /* read */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* reset */ - if ( buf[idx].len > 0 ) - { - for (j=0; j 0) { + for (j = 0; j < buf[idx].len; j++) { /* get the reference */ ref = ((hobj_ref_t *)buf[idx].p)[j]; /* get the DS id */ - if ((dsid_j = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0) + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for this DS */ - if(H5Oget_info3(dsid_j, &tmp_oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid_j, &tmp_oi, H5O_INFO_BASIC) < 0) goto out; /* Close the dereferenced dataset */ @@ -722,12 +712,12 @@ herr_t H5DSdetach_scale(hid_t did, goto out; /* same object, reset */ - if(dsid_oi.fileno == tmp_oi.fileno) { + if (dsid_oi.fileno == tmp_oi.fileno) { int token_cmp; - if(H5Otoken_cmp(did, &dsid_oi.token, &tmp_oi.token, &token_cmp) < 0) + if (H5Otoken_cmp(did, &dsid_oi.token, &tmp_oi.token, &token_cmp) < 0) goto out; - if(!token_cmp) { + if (!token_cmp) { /* If there are more than one reference in the VL element and the reference we found is not the last one, copy the last one to replace the found one since the order @@ -738,10 +728,10 @@ herr_t H5DSdetach_scale(hid_t did, size_t len = buf[idx].len; - if(j < len - 1) - ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len-1]; + if (j < len - 1) + ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len - 1]; len = --buf[idx].len; - if(len == 0) { + if (len == 0) { HDfree(buf[idx].p); buf[idx].p = NULL; } @@ -750,108 +740,107 @@ herr_t H5DSdetach_scale(hid_t did, found_ds = 1; break; } /* end if */ - } /* end if */ - } /* j */ - } /* if */ + } /* end if */ + } /* j */ + } /* if */ /* the scale must be present to continue */ - if(found_ds == 0) + if (found_ds == 0) goto out; /* Write the attribute, but check first, if we have any scales left, because if not, we should delete the attribute according to the spec */ - for(i = 0; i < rank; i++) { - if(buf[i].len > 0) { + for (i = 0; i < rank; i++) { + if (buf[i].len > 0) { have_ds = 1; break; } } - if(have_ds) { - if(H5Awrite(aid, tid, buf) < 0) + if (have_ds) { + if (H5Awrite(aid, tid, buf) < 0) goto out; } else { - if(H5Adelete(did, DIMENSION_LIST) < 0) + if (H5Adelete(did, DIMENSION_LIST) < 0) goto out; } /* close */ - if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; HDfree(buf); buf = NULL; - /*------------------------------------------------------------------------- - * the "REFERENCE_LIST" array exists, update - *------------------------------------------------------------------------- - */ + * the "REFERENCE_LIST" array exists, update + *------------------------------------------------------------------------- + */ - if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* get native type to read attribute REFERENCE_LIST */ - if((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5DS_get_REFLIST_type()) < 0) goto out; /* get and save the old reference(s) */ - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; - if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) + if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); - if(dsbuf == NULL) + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf == NULL) goto out; - if(H5Aread(aid, ntid, dsbuf) < 0) + if (H5Aread(aid, ntid, dsbuf) < 0) goto out; - for(ii = 0; ii < nelmts; ii++) { + for (ii = 0; ii < nelmts; ii++) { /* First check if we have the same dimension index */ - if(idx == dsbuf[ii].dim_idx) { + if (idx == dsbuf[ii].dim_idx) { /* get the reference to the dataset */ ref = dsbuf[ii].ref; /* get the dataset id */ - if ((did_i = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0) + if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for this dataset */ - if(H5Oget_info3(did_i, &tmp_oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did_i, &tmp_oi, H5O_INFO_BASIC) < 0) goto out; /* close the dereferenced dataset */ - if(H5Dclose(did_i) < 0) + if (H5Dclose(did_i) < 0) goto out; /* same object, reset. we want to detach only for this DIM */ - if(did_oi.fileno == tmp_oi.fileno) { + if (did_oi.fileno == tmp_oi.fileno) { int token_cmp; - if(H5Otoken_cmp(did, &did_oi.token, &tmp_oi.token, &token_cmp) < 0) + if (H5Otoken_cmp(did, &did_oi.token, &tmp_oi.token, &token_cmp) < 0) goto out; - if(!token_cmp) { + if (!token_cmp) { /* copy the last one to replace the one which is found */ - dsbuf[ii] = dsbuf[nelmts-1]; + dsbuf[ii] = dsbuf[nelmts - 1]; nelmts--; - found_dset=1; + found_dset = 1; break; } /* end if */ - } /* end if */ - } /* if we have the same dimension index */ - } /* ii */ + } /* end if */ + } /* if we have the same dimension index */ + } /* ii */ /* close space and attribute */ if (H5Sclose(sid) < 0) @@ -860,44 +849,43 @@ herr_t H5DSdetach_scale(hid_t did, goto out; /*------------------------------------------------------------------------- - * check if we found the pointed dataset - *------------------------------------------------------------------------- - */ + * check if we found the pointed dataset + *------------------------------------------------------------------------- + */ /* the pointed dataset must exist */ if (found_dset == 0) goto out; /*------------------------------------------------------------------------- - * create a new attribute - *------------------------------------------------------------------------- - */ + * create a new attribute + *------------------------------------------------------------------------- + */ /* the attribute must be deleted, in order to the new one can reflect the changes*/ if (H5Adelete(dsid, REFERENCE_LIST) < 0) goto out; /* don't do anything for an empty array */ - if(nelmts) - { + if (nelmts) { /* create a new data space for the new references array */ - dims[0] = (hsize_t)nelmts; + dims[0] = (hsize_t)nelmts; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* create the attribute again with the changes of space */ - if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* write the new attribute with the new references */ - if(H5Awrite(aid, ntid, dsbuf) < 0) + if (H5Awrite(aid, ntid, dsbuf) < 0) goto out; /* close space and attribute */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; } /* nelmts */ @@ -914,108 +902,108 @@ herr_t H5DSdetach_scale(hid_t did, /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Tclose(ntid); H5Tclose(tid); - if(dsbuf) { + if (dsbuf) { HDfree(dsbuf); dsbuf = NULL; } - if(buf) { + if (buf) { /* Failure occured before H5Treclaim was called; free the pointers allocated when we read data in */ - for(i = 0; i < rank; i++) { - if(buf[i].p) + for (i = 0; i < rank; i++) { + if (buf[i].p) HDfree(buf[i].p); } HDfree(buf); buf = NULL; } - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; - } /*------------------------------------------------------------------------- -* Function: H5DSis_attached -* -* Purpose: Report if dimension scale DSID is currently attached to -* dimension IDX of dataset DID by checking if DID has a pointer in the REFERENCE_LIST -* attribute and DSID (scale ) has a pointer in the DIMENSION_LIST attribute -* -* Return: -* 1: both the DS and the dataset pointers match -* 0: one of them or both do not match -* FAIL (-1): error -* -* Fails if: Bad arguments -* If DSID is not a Dimension Scale -* If DID is a Dimension Scale (A Dimension Scale cannot have scales) -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: February 18, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -htri_t H5DSis_attached(hid_t did, - hid_t dsid, - unsigned int idx) + * Function: H5DSis_attached + * + * Purpose: Report if dimension scale DSID is currently attached to + * dimension IDX of dataset DID by checking if DID has a pointer in the REFERENCE_LIST + * attribute and DSID (scale ) has a pointer in the DIMENSION_LIST attribute + * + * Return: + * 1: both the DS and the dataset pointers match + * 0: one of them or both do not match + * FAIL (-1): error + * + * Fails if: Bad arguments + * If DSID is not a Dimension Scale + * If DID is a Dimension Scale (A Dimension Scale cannot have scales) + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: February 18, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +htri_t +H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) { - int has_dimlist; - int has_reflist; - hssize_t nelmts; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hobj_ref_t ref; /* reference to the DS */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ - hid_t did_i; /* dataset ID in REFERENCE_LIST */ + int has_dimlist; + int has_reflist; + hssize_t nelmts; + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t ntid = -1; /* attribute native type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + hobj_ref_t ref; /* reference to the DS */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + hid_t did_i; /* dataset ID in REFERENCE_LIST */ H5O_info2_t oi1, oi2, oi3, oi4; - H5I_type_t it1, it2; - int i; - int found_dset=0, found_ds=0; - htri_t is_scale; + H5I_type_t it1, it2; + int i; + int found_dset = 0, found_ds = 0; + htri_t is_scale; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ if ((is_scale = H5DSis_scale(did)) < 0) return FAIL; /* the dataset cannot be a DS dataset */ - if ( is_scale == 1) + if (is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ - if(H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0) return FAIL; /* get info for the scale in the parameter list */ - if(H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0) return FAIL; /* same object, not valid */ - if(oi1.fileno == oi2.fileno) { + if (oi1.fileno == oi2.fileno) { int token_cmp; - if(H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) + if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) return FAIL; - if(!token_cmp) + if (!token_cmp) return FAIL; } /* end if */ @@ -1029,16 +1017,16 @@ htri_t H5DSis_attached(hid_t did, return FAIL; /*------------------------------------------------------------------------- - * get space - *------------------------------------------------------------------------- - */ + * get space + *------------------------------------------------------------------------- + */ /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; /* get rank */ - if ((rank=H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* close dataset space */ @@ -1046,32 +1034,31 @@ htri_t H5DSis_attached(hid_t did, goto out; /* parameter range checking */ - if(idx > ((unsigned)rank - 1)) + if (idx > ((unsigned)rank - 1)) return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; /*------------------------------------------------------------------------- - * open "DIMENSION_LIST" - *------------------------------------------------------------------------- - */ + * open "DIMENSION_LIST" + *------------------------------------------------------------------------- + */ - if(has_dimlist == 1) - { - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + if (has_dimlist == 1) { + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ - buf = (hvl_t*)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); + if (buf == NULL) goto out; /* read */ @@ -1079,8 +1066,7 @@ htri_t H5DSis_attached(hid_t did, goto out; /* iterate all the REFs in this dimension IDX */ - for (i=0; i<(int)buf[idx].len; i++) - { + for (i = 0; i < (int)buf[idx].len; i++) { /* get the reference */ ref = ((hobj_ref_t *)buf[idx].p)[i]; @@ -1089,30 +1075,28 @@ htri_t H5DSis_attached(hid_t did, goto out; /* get info for DS in the parameter list */ - if(H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0) goto out; /* get info for this DS */ - if(H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0) goto out; /* same object */ - if(oi1.fileno == oi2.fileno) { + if (oi1.fileno == oi2.fileno) { int token_cmp; - if(H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) + if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) goto out; - if(!token_cmp) + if (!token_cmp) found_ds = 1; } /* end if */ /* close the dereferenced dataset */ if (H5Dclose(dsid_j) < 0) goto out; - } - /* close */ if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; @@ -1127,39 +1111,38 @@ htri_t H5DSis_attached(hid_t did, } /* has_dimlist */ /*------------------------------------------------------------------------- - * info on the >>DS<< dataset - *------------------------------------------------------------------------- - */ + * info on the >>DS<< dataset + *------------------------------------------------------------------------- + */ /* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */ - if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) + if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) goto out; /*------------------------------------------------------------------------- - * open "REFERENCE_LIST" - *------------------------------------------------------------------------- - */ + * open "REFERENCE_LIST" + *------------------------------------------------------------------------- + */ - if(has_reflist == 1) - { - if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) + if (has_reflist == 1) { + if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* get native type to read REFERENCE_LIST attribute */ - if((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5DS_get_REFLIST_type()) < 0) goto out; /* get and save the old reference(s) */ - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; - if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) + if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); if (dsbuf == NULL) goto out; @@ -1168,46 +1151,43 @@ htri_t H5DSis_attached(hid_t did, goto out; /*------------------------------------------------------------------------- - * iterate - *------------------------------------------------------------------------- - */ + * iterate + *------------------------------------------------------------------------- + */ - for(i = 0; i < nelmts; i++) - { + for (i = 0; i < nelmts; i++) { /* get the reference */ ref = dsbuf[i].ref; /* the reference was not deleted */ - if (ref) - { + if (ref) { /* get the dataset id */ if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for dataset in the parameter list */ - if(H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0) goto out; /* get info for this dataset */ - if(H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0) goto out; /* same object */ - if(oi3.fileno == oi4.fileno) { + if (oi3.fileno == oi4.fileno) { int token_cmp; - if(H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0) + if (H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0) goto out; - if(!token_cmp && (idx == dsbuf[i].dim_idx)) - found_dset=1; + if (!token_cmp && (idx == dsbuf[i].dim_idx)) + found_dset = 1; } /* end if */ /* close the dereferenced dataset */ if (H5Dclose(did_i) < 0) goto out; } /* if */ - } /* i */ - + } /* i */ /* close */ if (H5Sclose(sid) < 0) @@ -1230,18 +1210,20 @@ htri_t H5DSis_attached(hid_t did, /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); H5Tclose(ntid); - } H5E_END_TRY; + } + H5E_END_TRY; if (buf) { HDfree(buf); buf = NULL; } - if(dsbuf) { + if (dsbuf) { HDfree(dsbuf); dsbuf = NULL; } @@ -1249,88 +1231,84 @@ out: } /*------------------------------------------------------------------------- -* Function: H5DSiterate_scales -* -* Purpose: H5DSiterate_scales iterates over the scales attached to dimension DIM -* of dataset DID. For each scale in the list, the visitor_data and some -* additional information, specified below, are passed to the visitor function. -* The iteration begins with the IDX object in the group and the next element -* to be processed by the operator is returned in IDX. If IDX is NULL, then the -* iterator starts at zero. -* -* Parameters: -* -* hid_t DID; IN: the dataset -* unsigned int DIM; IN: the dimension of the dataset -* int *DS_IDX; IN/OUT: on input the dimension scale index to start iterating, -* on output the next index to visit. If NULL, start at -* the first position. -* H5DS_iterate_t VISITOR; IN: the visitor function -* void *VISITOR_DATA; IN: arbitrary data to pass to the visitor function. -* -* Iterate over all scales of DIM, calling an application callback -* with the item, key and any operator data. -* -* The operator callback receives a pointer to the item , -* and the pointer to the operator data passed -* in to H5SL_iterate ('op_data'). The return values from an operator are: -* A. Zero causes the iterator to continue, returning zero when all -* nodes of that type have been processed. -* B. Positive causes the iterator to immediately return that positive -* value, indicating short-circuit success. -* C. Negative causes the iterator to immediately return that value, -* indicating failure. -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: January 31, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5DSiterate_scales(hid_t did, - unsigned int dim, - int *ds_idx, - H5DS_iterate_t visitor, - void *visitor_data ) + * Function: H5DSiterate_scales + * + * Purpose: H5DSiterate_scales iterates over the scales attached to dimension DIM + * of dataset DID. For each scale in the list, the visitor_data and some + * additional information, specified below, are passed to the visitor function. + * The iteration begins with the IDX object in the group and the next element + * to be processed by the operator is returned in IDX. If IDX is NULL, then the + * iterator starts at zero. + * + * Parameters: + * + * hid_t DID; IN: the dataset + * unsigned int DIM; IN: the dimension of the dataset + * int *DS_IDX; IN/OUT: on input the dimension scale index to start iterating, + * on output the next index to visit. If NULL, start at + * the first position. + * H5DS_iterate_t VISITOR; IN: the visitor function + * void *VISITOR_DATA; IN: arbitrary data to pass to the visitor function. + * + * Iterate over all scales of DIM, calling an application callback + * with the item, key and any operator data. + * + * The operator callback receives a pointer to the item , + * and the pointer to the operator data passed + * in to H5SL_iterate ('op_data'). The return values from an operator are: + * A. Zero causes the iterator to continue, returning zero when all + * nodes of that type have been processed. + * B. Positive causes the iterator to immediately return that positive + * value, indicating short-circuit success. + * C. Negative causes the iterator to immediately return that value, + * indicating failure. + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: January 31, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visitor, void *visitor_data) { - hid_t scale_id; - int rank; - hobj_ref_t ref; /* reference to the DS */ - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - H5I_type_t it; /* ID type */ - herr_t ret_value=0; - int j_idx; - int nscales; - int has_dimlist; - int i; + hid_t scale_id; + int rank; + hobj_ref_t ref; /* reference to the DS */ + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + H5I_type_t it; /* ID type */ + herr_t ret_value = 0; + int j_idx; + int nscales; + int has_dimlist; + int i; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(did)) < 0) return FAIL; - if (H5I_DATASET!=it) + if (H5I_DATASET != it) return FAIL; /* get the number of scales assotiated with this DIM */ - if ((nscales = H5DSget_num_scales(did,dim)) < 0) + if ((nscales = H5DSget_num_scales(did, dim)) < 0) return FAIL; /* parameter range checking */ - if (ds_idx!=NULL) - { - if (*ds_idx>=nscales) + if (ds_idx != NULL) { + if (*ds_idx >= nscales) return FAIL; } @@ -1339,70 +1317,67 @@ herr_t H5DSiterate_scales(hid_t did, return FAIL; /* get rank */ - if ((rank=H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* close dataset space */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if ( dim >= (unsigned)rank ) + if (dim >= (unsigned)rank) return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; - if(has_dimlist == 0) + if (has_dimlist == 0) return SUCCEED; - else if(has_dimlist == 1) - { - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + else if (has_dimlist == 1) { + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ - buf = (hvl_t*)HDmalloc((size_t)rank * sizeof(hvl_t)); + buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; /* read */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; - if ( buf[dim].len > 0 ) - { - if (ds_idx!=NULL) + if (buf[dim].len > 0) { + if (ds_idx != NULL) j_idx = *ds_idx; else - j_idx=0; + j_idx = 0; /* iterate */ - for(i=j_idx; i= (unsigned)rank ) + if (idx >= (unsigned)rank) return FAIL; /*------------------------------------------------------------------------- - * attribute "DIMENSION_LABELS" - *------------------------------------------------------------------------- - */ + * attribute "DIMENSION_LABELS" + *------------------------------------------------------------------------- + */ /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */ if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0) return FAIL; /*------------------------------------------------------------------------- - * make the attribute and insert label - *------------------------------------------------------------------------- - */ + * make the attribute and insert label + *------------------------------------------------------------------------- + */ - if (has_labels == 0) - { + if (has_labels == 0) { dims[0] = (hsize_t)rank; /* space for the attribute */ @@ -1543,12 +1520,12 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; /* allocate and initialize */ - u.const_buf = (char const **) HDmalloc((size_t) rank * sizeof(char *)); + u.const_buf = (char const **)HDmalloc((size_t)rank * sizeof(char *)); if (u.const_buf == NULL) goto out; - for (i = 0; i < (unsigned int) rank; i++) + for (i = 0; i < (unsigned int)rank; i++) u.const_buf[i] = NULL; /* store the label information in the required index */ @@ -1565,20 +1542,18 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; if (H5Aclose(aid) < 0) goto out; - if (u.const_buf) - { + if (u.const_buf) { HDfree(u.const_buf); u.const_buf = NULL; } } /*------------------------------------------------------------------------- - * just insert label - *------------------------------------------------------------------------- - */ + * just insert label + *------------------------------------------------------------------------- + */ - else - { + else { if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0) goto out; @@ -1587,7 +1562,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; /* allocate and initialize */ - u.buf = (char **) HDmalloc((size_t) rank * sizeof(char *)); + u.buf = (char **)HDmalloc((size_t)rank * sizeof(char *)); if (u.buf == NULL) goto out; @@ -1611,8 +1586,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) u.buf[idx] = NULL; /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) - { + for (i = 0; i < (unsigned int)rank; i++) { if (u.buf[i]) HDfree(u.buf[i]); } @@ -1622,8 +1596,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; if (H5Aclose(aid) < 0) goto out; - if (u.buf) - { + if (u.buf) { HDfree(u.buf); u.buf = NULL; } @@ -1634,13 +1607,11 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) /* error zone */ out: - if (u.buf) - { - if (u.buf[idx]) /* check if we errored during H5Awrite */ + if (u.buf) { + 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++) - { + for (i = 0; i < (unsigned int)rank; i++) { if (u.buf[i]) HDfree(u.buf[i]); } @@ -1651,50 +1622,52 @@ out: H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); - }H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /*------------------------------------------------------------------------- -* Function: H5DSget_label -* -* Purpose: Read the label LABEL for dimension IDX of dataset DID -* Up to 'size' characters are stored in 'label' followed by a '\0' string -* terminator. If the label is longer than 'size'-1, -* the string terminator is stored in the last position of the buffer to -* properly terminate the string. -* -* Return: 0 if no label found, size of label if found, Failure: FAIL -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: January 11, 2005 -* -* Comments: -* -* Modifications: -* JIRA HDFFV-7673: Added a check to see if the label name exists, -* if not then returns zero. July 30, 2011. MSB -* -*------------------------------------------------------------------------- -*/ -ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) + * Function: H5DSget_label + * + * Purpose: Read the label LABEL for dimension IDX of dataset DID + * Up to 'size' characters are stored in 'label' followed by a '\0' string + * terminator. If the label is longer than 'size'-1, + * the string terminator is stored in the last position of the buffer to + * properly terminate the string. + * + * Return: 0 if no label found, size of label if found, Failure: FAIL + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: January 11, 2005 + * + * Comments: + * + * Modifications: + * JIRA HDFFV-7673: Added a check to see if the label name exists, + * if not then returns zero. July 30, 2011. MSB + * + *------------------------------------------------------------------------- + */ +ssize_t +H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { int has_labels; - hid_t sid = -1; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - char **buf = NULL; /* buffer to store in the attribute */ - H5I_type_t it; /* ID type */ + hid_t sid = -1; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + char ** buf = NULL; /* buffer to store in the attribute */ + H5I_type_t it; /* ID type */ size_t nbytes = 0; size_t copy_len; int i; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(did)) < 0) return FAIL; @@ -1702,7 +1675,7 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) if (H5I_DATASET != it) return FAIL; - /* get dataset space */ + /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; @@ -1714,41 +1687,39 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) if (H5Sclose(sid) < 0) goto out; - if ( idx >= (unsigned)rank ) + if (idx >= (unsigned)rank) return FAIL; /*------------------------------------------------------------------------- - * attribute "DIMENSION_LABELS" - *------------------------------------------------------------------------- - */ + * attribute "DIMENSION_LABELS" + *------------------------------------------------------------------------- + */ /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */ if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0) return FAIL; /* return 0 and NULL for label if no label found */ - if (has_labels == 0) - { + if (has_labels == 0) { if (label) label[0] = 0; return 0; } /*------------------------------------------------------------------------- - * open the attribute and read label - *------------------------------------------------------------------------- - */ + * open the attribute and read label + *------------------------------------------------------------------------- + */ - assert (has_labels == 1); + assert(has_labels == 1); if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0) goto out; - if ((tid = H5Aget_type(aid)) < 0) goto out; /* allocate and initialize */ - buf = (char **) HDmalloc((size_t) rank * sizeof(char *)); + buf = (char **)HDmalloc((size_t)rank * sizeof(char *)); if (buf == NULL) goto out; @@ -1758,27 +1729,23 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) goto out; /* do only if the label name exists for the dimension */ - if (buf[idx] != NULL) - { + if (buf[idx] != NULL) { /* get the real string length */ nbytes = HDstrlen(buf[idx]); /* compute the string length which will fit into the user's buffer */ - copy_len = MIN(size-1, nbytes); + copy_len = MIN(size - 1, nbytes); /* copy all/some of the name */ - if (label) - { + if (label) { HDmemcpy(label, buf[idx], copy_len); /* terminate the string */ label[copy_len] = '\0'; } - } /* free all the ptr's from the H5Aread() */ - for (i = 0; i < rank; i++) - { + for (i = 0; i < rank; i++) { if (buf[i]) HDfree(buf[i]); } @@ -1788,21 +1755,18 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) goto out; if (H5Aclose(aid) < 0) goto out; - if (buf) - { + if (buf) { HDfree(buf); buf = NULL; } - return (ssize_t) nbytes; + return (ssize_t)nbytes; /* error zone */ out: - if (buf) - { + if (buf) { /* free all the ptr's from the H5Aread() */ - for (i = 0; i < rank; i++) - { + for (i = 0; i < rank; i++) { if (buf[i]) HDfree(buf[i]); } @@ -1813,37 +1777,37 @@ out: H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); - }H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /*------------------------------------------------------------------------- -* Function: H5DSget_scale_name -* -* Purpose: Read the name of dataset scale DID into buffer NAME -* Up to 'size' characters are stored in 'name' followed by a '\0' string -* terminator. If the name is longer than 'size'-1, -* the string terminator is stored in the last position of the buffer to -* properly terminate the string. -* -* Return: size of name if found, zero if not found, Failure: FAIL -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: January 04, 2005 -* -* Comments: -* -* Modifications: -* The size of the name returned should not include the NULL termination -* in its value so as to be consistent with other HDF5 APIs. -* -*------------------------------------------------------------------------- -*/ - -ssize_t H5DSget_scale_name(hid_t did, - char *name, - size_t size) + * Function: H5DSget_scale_name + * + * Purpose: Read the name of dataset scale DID into buffer NAME + * Up to 'size' characters are stored in 'name' followed by a '\0' string + * terminator. If the name is longer than 'size'-1, + * the string terminator is stored in the last position of the buffer to + * properly terminate the string. + * + * Return: size of name if found, zero if not found, Failure: FAIL + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: January 04, 2005 + * + * Comments: + * + * Modifications: + * The size of the name returned should not include the NULL termination + * in its value so as to be consistent with other HDF5 APIs. + * + *------------------------------------------------------------------------- + */ + +ssize_t +H5DSget_scale_name(hid_t did, char *name, size_t size) { hid_t aid; /* attribute ID */ hid_t tid = -1; /* attribute type ID */ @@ -1852,26 +1816,26 @@ ssize_t H5DSget_scale_name(hid_t did, size_t nbytes; size_t copy_len; int has_name; - char *buf=NULL; + char * buf = NULL; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(did)) < 0) return FAIL; - if (H5I_DATASET!=it) + if (H5I_DATASET != it) return FAIL; - if ((H5DSis_scale(did))<=0) + if ((H5DSis_scale(did)) <= 0) return FAIL; /*------------------------------------------------------------------------- - * check if the DS has a name - *------------------------------------------------------------------------- - */ + * check if the DS has a name + *------------------------------------------------------------------------- + */ /* try to find the attribute "NAME" on the >>DS<< dataset */ if ((has_name = H5LT_find_attribute(did, "NAME")) < 0) @@ -1881,43 +1845,43 @@ ssize_t H5DSget_scale_name(hid_t did, return 0; /*------------------------------------------------------------------------- - * open the attribute - *------------------------------------------------------------------------- - */ + * open the attribute + *------------------------------------------------------------------------- + */ - if((aid = H5Aopen(did, "NAME", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "NAME", H5P_DEFAULT)) < 0) return FAIL; /* get space */ - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* get type */ - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* get the size */ - if((nbytes = H5Tget_size(tid)) == 0) + if ((nbytes = H5Tget_size(tid)) == 0) goto out; /* allocate a temporary buffer */ - buf = (char*)HDmalloc(nbytes * sizeof(char)); + buf = (char *)HDmalloc(nbytes * sizeof(char)); if (buf == NULL) goto out; /* read */ - if (H5Aread(aid,tid,buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* compute the string length which will fit into the user's buffer */ - copy_len = MIN(size-1, nbytes); + copy_len = MIN(size - 1, nbytes); /* copy all/some of the name */ if (name) { HDmemcpy(name, buf, copy_len); /* terminate the string */ - name[copy_len]='\0'; + name[copy_len] = '\0'; } /* close */ @@ -1934,221 +1898,222 @@ ssize_t H5DSget_scale_name(hid_t did, /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(tid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; if (buf) HDfree(buf); return FAIL; } /*------------------------------------------------------------------------- -* Function: H5DSis_scale -* -* Purpose: check if the dataset DID is a dimension scale -* -* Return: 1, is, 0, not, FAIL, error -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: January 04, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -htri_t H5DSis_scale(hid_t did) + * Function: H5DSis_scale + * + * Purpose: check if the dataset DID is a dimension scale + * + * Return: 1, is, 0, not, FAIL, error + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: January 04, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +htri_t +H5DSis_scale(hid_t did) { - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - herr_t has_class; /* has the "CLASS" attribute */ - htri_t is_ds; /* boolean return value */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + herr_t has_class; /* has the "CLASS" attribute */ + htri_t is_ds; /* boolean return value */ H5I_type_t it; /* ID type */ - char *buf; /* Name of attribute */ + char * buf; /* Name of attribute */ hsize_t storage_size; /* Size of storage for attribute */ /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(did)) < 0) return FAIL; - if(H5I_DATASET != it) + if (H5I_DATASET != it) return FAIL; /* try to find the attribute "CLASS" on the dataset */ - if((has_class = H5LT_find_attribute(did, "CLASS")) < 0) + if ((has_class = H5LT_find_attribute(did, "CLASS")) < 0) return FAIL; - if(has_class == 0) + if (has_class == 0) is_ds = 0; - else - { - if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + else { + if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* check to make sure attribute is a string */ - if(H5T_STRING != H5Tget_class(tid)) + if (H5T_STRING != H5Tget_class(tid)) goto out; /* check to make sure string is null-terminated */ - if(H5T_STR_NULLTERM != H5Tget_strpad(tid)) + if (H5T_STR_NULLTERM != H5Tget_strpad(tid)) goto out; /* allocate buffer large enough to hold string */ - if((storage_size = H5Aget_storage_size(aid)) == 0) + if ((storage_size = H5Aget_storage_size(aid)) == 0) goto out; - buf = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); - if(buf == NULL) + buf = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1); + if (buf == NULL) goto out; /* Read the attribute */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* compare strings */ - if(HDstrncmp(buf, DIMENSION_SCALE_CLASS, MIN(HDstrlen(DIMENSION_SCALE_CLASS),HDstrlen(buf)))==0) + if (HDstrncmp(buf, DIMENSION_SCALE_CLASS, MIN(HDstrlen(DIMENSION_SCALE_CLASS), HDstrlen(buf))) == 0) is_ds = 1; else is_ds = 0; HDfree(buf); - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; if (H5Aclose(aid) < 0) goto out; - - } return is_ds; /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; - } /*------------------------------------------------------------------------- -* Function: H5DSget_num_scales -* -* Purpose: get the number of scales linked to the IDX dimension of dataset DID -* -* Return: -* Success: number of scales -* Failure: FAIL -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: January 13, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -int H5DSget_num_scales(hid_t did, - unsigned int idx) + * Function: H5DSget_num_scales + * + * Purpose: get the number of scales linked to the IDX dimension of dataset DID + * + * Return: + * Success: number of scales + * Failure: FAIL + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: January 13, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +int +H5DSget_num_scales(hid_t did, unsigned int idx) { int has_dimlist; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - H5I_type_t it; /* ID type */ + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + H5I_type_t it; /* ID type */ int nscales; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ - if((it = H5Iget_type(did)) < 0) + if ((it = H5Iget_type(did)) < 0) return FAIL; - if(H5I_DATASET != it) + if (H5I_DATASET != it) return FAIL; /*------------------------------------------------------------------------- - * the attribute "DIMENSION_LIST" on the >>data<< dataset must exist - *------------------------------------------------------------------------- - */ + * the attribute "DIMENSION_LIST" on the >>data<< dataset must exist + *------------------------------------------------------------------------- + */ /* get dataset space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) return FAIL; /* get rank */ - if((rank = H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* close dataset space */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; /* dimemsion index IDX range checking */ - if(idx >= (unsigned int )rank) + if (idx >= (unsigned int)rank) return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; /* it does not exist */ - if(has_dimlist == 0) + if (has_dimlist == 0) return 0; /*------------------------------------------------------------------------- - * the attribute exists, open it - *------------------------------------------------------------------------- - */ + * the attribute exists, open it + *------------------------------------------------------------------------- + */ else { - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; /* read */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; nscales = (int)buf[idx].len; /* close */ - if(H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; HDfree(buf); buf = NULL; @@ -2158,84 +2123,85 @@ int H5DSget_num_scales(hid_t did, /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; - if(buf) + if (buf) HDfree(buf); return FAIL; } /*------------------------------------------------------------------------- -* Function: H5DS_is_reserved -* -* Purpose: Verify that a dataset's CLASS is either an image, palette or table -* -* Return: true, false, fail -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: March 19, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -static -herr_t H5DS_is_reserved(hid_t did) + * Function: H5DS_is_reserved + * + * Purpose: Verify that a dataset's CLASS is either an image, palette or table + * + * Return: true, false, fail + * + * Programmer: pvn@ncsa.uiuc.edu + * + * Date: March 19, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +static herr_t +H5DS_is_reserved(hid_t did) { - int has_class; - hid_t tid = -1; - hid_t aid = -1; - char *buf; /* Name of attribute */ + int has_class; + hid_t tid = -1; + hid_t aid = -1; + char * buf; /* Name of attribute */ hsize_t storage_size; /* Size of storage for attribute */ - herr_t ret; + herr_t ret; /* try to find the attribute "CLASS" on the dataset */ - if((has_class = H5LT_find_attribute(did, "CLASS")) < 0) + if ((has_class = H5LT_find_attribute(did, "CLASS")) < 0) return -1; - if(has_class == 0) + if (has_class == 0) return 0; - assert(has_class == 1); - if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + assert(has_class == 1); + if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* check to make sure attribute is a string */ - if(H5T_STRING != H5Tget_class(tid)) - goto out; + if (H5T_STRING != H5Tget_class(tid)) + goto out; /* check to make sure string is null-terminated */ - if(H5T_STR_NULLTERM != H5Tget_strpad(tid)) - goto out; + if (H5T_STR_NULLTERM != H5Tget_strpad(tid)) + goto out; /* allocate buffer large enough to hold string */ - if((storage_size = H5Aget_storage_size(aid)) == 0) - goto out; + if ((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; - buf = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); - if(buf == NULL) - goto out; + buf = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1); + if (buf == NULL) + goto out; /* Read the attribute */ - if(H5Aread(aid, tid, buf) < 0) - goto out; - + if (H5Aread(aid, tid, buf) < 0) + goto out; - if(HDstrncmp(buf, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS),HDstrlen(buf))) == 0 || - HDstrncmp(buf, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS),HDstrlen(buf))) == 0 || - HDstrncmp(buf, TABLE_CLASS, MIN(HDstrlen(TABLE_CLASS),HDstrlen(buf))) == 0 ) + if (HDstrncmp(buf, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS), HDstrlen(buf))) == 0 || + HDstrncmp(buf, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS), HDstrlen(buf))) == 0 || + HDstrncmp(buf, TABLE_CLASS, MIN(HDstrlen(TABLE_CLASS), HDstrlen(buf))) == 0) ret = 1; else ret = 0; @@ -2248,7 +2214,6 @@ herr_t H5DS_is_reserved(hid_t did) if (H5Aclose(aid) < 0) goto out; - return ret; /* error zone */ @@ -2257,31 +2222,32 @@ out: { H5Tclose(tid); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /*------------------------------------------------------------------------- -* Function: H5DS_get_REFLIST_type -* -* Purpose: This is a helper function to return a native type for -* the REFERENCE_LIST attribute. -* -* Return: Type identifier on success and negative on failure -* -* Programmer: epourmal@hdfgroup.org -* -* Date: May 22, 2010 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -static -hid_t H5DS_get_REFLIST_type(void) + * Function: H5DS_get_REFLIST_type + * + * Purpose: This is a helper function to return a native type for + * the REFERENCE_LIST attribute. + * + * Return: Type identifier on success and negative on failure + * + * Programmer: epourmal@hdfgroup.org + * + * Date: May 22, 2010 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +static hid_t +H5DS_get_REFLIST_type(void) { hid_t ntid_t = -1; @@ -2289,20 +2255,21 @@ hid_t H5DS_get_REFLIST_type(void) used to store ds_list_t structure in the REFERENCE_LIST attribute */ - if((ntid_t = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) + if ((ntid_t = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) goto out; - if(H5Tinsert(ntid_t, "dataset", HOFFSET(ds_list_t,ref), H5T_STD_REF_OBJ) < 0) + if (H5Tinsert(ntid_t, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0) goto out; - if(H5Tinsert(ntid_t, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) + if (H5Tinsert(ntid_t, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) goto out; return ntid_t; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(ntid_t); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } - diff --git a/hl/src/H5DSprivate.h b/hl/src/H5DSprivate.h index 9d20d48..58bb82e 100644 --- a/hl/src/H5DSprivate.h +++ b/hl/src/H5DSprivate.h @@ -20,21 +20,15 @@ /* public LT prototypes */ #include "H5DSpublic.h" - - - /* attribute type of a DS dataset */ typedef struct ds_list_t { - hobj_ref_t ref; /* object reference */ - unsigned int dim_idx; /* dimension index of the dataset */ + hobj_ref_t ref; /* object reference */ + unsigned int dim_idx; /* dimension index of the dataset */ } ds_list_t; - /*------------------------------------------------------------------------- * private functions *------------------------------------------------------------------------- */ - #endif - diff --git a/hl/src/H5DSpublic.h b/hl/src/H5DSpublic.h index 615122c..0c29a36 100644 --- a/hl/src/H5DSpublic.h +++ b/hl/src/H5DSpublic.h @@ -14,61 +14,37 @@ #ifndef _H5DSpublic_H #define _H5DSpublic_H - - #define DIMENSION_SCALE_CLASS "DIMENSION_SCALE" #define DIMENSION_LIST "DIMENSION_LIST" #define REFERENCE_LIST "REFERENCE_LIST" #define DIMENSION_LABELS "DIMENSION_LABELS" - -typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); - +typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); #ifdef __cplusplus extern "C" { #endif -H5_HLDLL herr_t H5DSattach_scale( hid_t did, - hid_t dsid, - unsigned int idx); - -H5_HLDLL herr_t H5DSdetach_scale( hid_t did, - hid_t dsid, - unsigned int idx); - -H5_HLDLL herr_t H5DSset_scale( hid_t dsid, - const char *dimname); +H5_HLDLL herr_t H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx); -H5_HLDLL int H5DSget_num_scales( hid_t did, - unsigned int dim); +H5_HLDLL herr_t H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx); -H5_HLDLL herr_t H5DSset_label( hid_t did, - unsigned int idx, - const char *label); +H5_HLDLL herr_t H5DSset_scale(hid_t dsid, const char *dimname); -H5_HLDLL ssize_t H5DSget_label( hid_t did, - unsigned int idx, - char *label, - size_t size); +H5_HLDLL int H5DSget_num_scales(hid_t did, unsigned int dim); -H5_HLDLL ssize_t H5DSget_scale_name( hid_t did, - char *name, - size_t size); +H5_HLDLL herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label); -H5_HLDLL htri_t H5DSis_scale( hid_t did); +H5_HLDLL ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size); -H5_HLDLL herr_t H5DSiterate_scales( hid_t did, - unsigned int dim, - int *idx, - H5DS_iterate_t visitor, - void *visitor_data); +H5_HLDLL ssize_t H5DSget_scale_name(hid_t did, char *name, size_t size); -H5_HLDLL htri_t H5DSis_attached( hid_t did, - hid_t dsid, - unsigned int idx); +H5_HLDLL htri_t H5DSis_scale(hid_t did); +H5_HLDLL herr_t H5DSiterate_scales(hid_t did, unsigned int dim, int *idx, H5DS_iterate_t visitor, + void *visitor_data); +H5_HLDLL htri_t H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx); #ifdef __cplusplus } diff --git a/hl/src/H5HLprivate2.h b/hl/src/H5HLprivate2.h index 45591e8..989c799 100644 --- a/hl/src/H5HLprivate2.h +++ b/hl/src/H5HLprivate2.h @@ -24,4 +24,3 @@ #include "H5private.h" #endif /* _H5HLprivate2_H */ - diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index 6f7414b..e08d006 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5IMprivate.h" #include "H5LTprivate.h" @@ -17,31 +17,29 @@ #include /*------------------------------------------------------------------------- -* Function: H5IMmake_image_8bit -* -* Purpose: Creates and writes an image an 8 bit image -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: June 13, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMmake_image_8bit( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const unsigned char *buf ) + * Function: H5IMmake_image_8bit + * + * Purpose: Creates and writes an image an 8 bit image + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: June 13, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMmake_image_8bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, + const unsigned char *buf) { - hsize_t dims[IMAGE8_RANK]; + hsize_t dims[IMAGE8_RANK]; /* check the arguments */ if (dset_name == NULL) @@ -52,56 +50,53 @@ herr_t H5IMmake_image_8bit( hid_t loc_id, dims[1] = width; /* Make the dataset */ - if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0) + if (H5LTmake_dataset(loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buf) < 0) return -1; /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) return -1; /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) return -1; /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED") < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5IMmake_image_24bit -* -* Purpose: -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: June 13, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Interlace Mode Dimensions in the Dataspace -* INTERLACE_PIXEL [height][width][pixel components] -* INTERLACE_PLANE [pixel components][height][width] -* -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMmake_image_24bit( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const char *interlace, - const unsigned char *buf ) + * Function: H5IMmake_image_24bit + * + * Purpose: + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: June 13, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Interlace Mode Dimensions in the Dataspace + * INTERLACE_PIXEL [height][width][pixel components] + * INTERLACE_PLANE [pixel components][height][width] + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMmake_image_24bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, + const char *interlace, const unsigned char *buf) { - hsize_t dims[IMAGE24_RANK]; + hsize_t dims[IMAGE24_RANK]; /* check the arguments */ if (interlace == NULL) @@ -109,73 +104,65 @@ herr_t H5IMmake_image_24bit( hid_t loc_id, if (dset_name == NULL) return -1; - /* Initialize the image dimensions */ - if ( HDstrncmp( interlace, "INTERLACE_PIXEL",15 ) == 0 ) - { + if (HDstrncmp(interlace, "INTERLACE_PIXEL", 15) == 0) { /* Number of color planes is defined as the third dimension */ dims[0] = height; dims[1] = width; dims[2] = IMAGE24_RANK; } + else if (HDstrncmp(interlace, "INTERLACE_PLANE", 15) == 0) { + /* Number of color planes is defined as the first dimension */ + dims[0] = IMAGE24_RANK; + dims[1] = height; + dims[2] = width; + } else - if ( HDstrncmp( interlace, "INTERLACE_PLANE",15 ) == 0 ) - { - /* Number of color planes is defined as the first dimension */ - dims[0] = IMAGE24_RANK; - dims[1] = height; - dims[2] = width; - } - else return -1; - - /* Make the dataset */ - if ( H5LTmake_dataset( loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0) - return -1; + return -1; - /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) - return -1; + /* Make the dataset */ + if (H5LTmake_dataset(loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buf) < 0) + return -1; - /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) - return -1; + /* Attach the CLASS attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) + return -1; - /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0) - return -1; + /* Attach the VERSION attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) + return -1; - /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ - if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0) - return -1; + /* Attach the IMAGE_SUBCLASS attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR") < 0) + return -1; - return 0; + /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ + if (H5LTset_attribute_string(loc_id, dset_name, "INTERLACE_MODE", interlace) < 0) + return -1; + return 0; } - - /*------------------------------------------------------------------------- -* Function: find_palette -* -* Purpose: operator function used by H5LT_find_palette -* -* Return: -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: May 28, 2001 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -static herr_t find_palette(hid_t loc_id, - const char *name, - const H5A_info_t *ainfo, - void *op_data) + * Function: find_palette + * + * Purpose: operator function used by H5LT_find_palette + * + * Return: + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 28, 2001 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_data) { int ret = H5_ITER_CONT; @@ -184,93 +171,90 @@ static herr_t find_palette(hid_t loc_id, return -1; /* Shut compiler up */ - loc_id = loc_id; ainfo = ainfo; op_data = op_data; + loc_id = loc_id; + ainfo = ainfo; + op_data = op_data; /* Define a positive value for return value if the attribute was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ - if(HDstrncmp(name, "PALETTE",7) == 0) + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ + if (HDstrncmp(name, "PALETTE", 7) == 0) ret = H5_ITER_STOP; return ret; } - /*------------------------------------------------------------------------- -* Function: H5IM_find_palette -* -* Purpose: Private function. Find the attribute "PALETTE" in the image dataset -* -* Return: Success: 1, Failure: 0 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: May 11, 2001 -* -* Comments: -* The function uses H5Aiterate2 with the operator function find_palette -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IM_find_palette( hid_t loc_id ) + * Function: H5IM_find_palette + * + * Purpose: Private function. Find the attribute "PALETTE" in the image dataset + * + * Return: Success: 1, Failure: 0 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 11, 2001 + * + * Comments: + * The function uses H5Aiterate2 with the operator function find_palette + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IM_find_palette(hid_t loc_id) { return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_palette, NULL); } - /*------------------------------------------------------------------------- -* Function: H5IMget_image_info -* -* Purpose: Gets information about an image dataset (dimensions, interlace mode -* and number of associated palettes). -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: July 25, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMget_image_info( hid_t loc_id, - const char *dset_name, - hsize_t *width, - hsize_t *height, - hsize_t *planes, - char *interlace, - hssize_t *npals ) + * Function: H5IMget_image_info + * + * Purpose: Gets information about an image dataset (dimensions, interlace mode + * and number of associated palettes). + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: July 25, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMget_image_info(hid_t loc_id, const char *dset_name, hsize_t *width, hsize_t *height, hsize_t *planes, + char *interlace, hssize_t *npals) { - hid_t did = -1; - hid_t sid = -1; + hid_t did = -1; + hid_t sid = -1; hsize_t dims[IMAGE24_RANK]; - hid_t aid = -1; - hid_t asid = -1; - hid_t atid = -1; + hid_t aid = -1; + hid_t asid = -1; + hid_t atid = -1; H5T_class_t aclass; int has_pal; int has_attr; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; if (interlace == NULL) - return -1; + return -1; /*assume initially we have no palettes attached*/ *npals = 0; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "INTERLACE_MODE" on the >>image<< dataset */ @@ -278,58 +262,55 @@ herr_t H5IMget_image_info( hid_t loc_id, goto out; /* It exists, get it */ - if(has_attr == 1) - { + if (has_attr == 1) { - if((aid = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Aread(aid, atid, interlace) < 0) + if (H5Aread(aid, atid, interlace) < 0) goto out; - if(H5Tclose(atid) < 0) + if (H5Tclose(atid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; } /* Get the dataspace handle */ - if ( (sid = H5Dget_space( did )) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* Get dimensions */ - if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* Initialize the image dimensions */ - if ( has_attr == 1 ) - /* This is a 24 bit image */ + if (has_attr == 1) + /* This is a 24 bit image */ { - if ( HDstrncmp( interlace, "INTERLACE_PIXEL", 15 ) == 0 ) - { + if (HDstrncmp(interlace, "INTERLACE_PIXEL", 15) == 0) { /* Number of color planes is defined as the third dimension */ *height = dims[0]; *width = dims[1]; *planes = dims[2]; } + else if (HDstrncmp(interlace, "INTERLACE_PLANE", 15) == 0) { + /* Number of color planes is defined as the first dimension */ + *planes = dims[0]; + *height = dims[1]; + *width = dims[2]; + } else - if ( HDstrncmp( interlace, "INTERLACE_PLANE", 15 ) == 0 ) - { - /* Number of color planes is defined as the first dimension */ - *planes = dims[0]; - *height = dims[1]; - *width = dims[2]; - } - else return -1; + return -1; } else - /* This is a 8 bit image */ + /* This is a 8 bit image */ { *height = dims[0]; *width = dims[1]; @@ -337,147 +318,135 @@ herr_t H5IMget_image_info( hid_t loc_id, } /* Close */ - if ( H5Sclose( sid ) < 0) + if (H5Sclose(sid) < 0) goto out; - /* Get number of palettes */ - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(did); - if(has_pal == 1) - { + if (has_pal == 1) { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if((aclass = H5Tget_class(atid)) < 0) + if ((aclass = H5Tget_class(atid)) < 0) goto out; /* Check if it is really a reference */ - if(aclass == H5T_REFERENCE) - { + if (aclass == H5T_REFERENCE) { /* Get the reference(s) */ - if ( (asid = H5Aget_space( aid )) < 0) + if ((asid = H5Aget_space(aid)) < 0) goto out; - *npals = H5Sget_simple_extent_npoints( asid ); + *npals = H5Sget_simple_extent_npoints(asid); - if ( H5Sclose( asid ) < 0) + if (H5Sclose(asid) < 0) goto out; } /* H5T_REFERENCE */ - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; /* Close the attribute. */ - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - } /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) goto out; return 0; out: - if(did > 0) - H5Dclose( did ); - if(aid > 0) - H5Aclose( aid ); - if(asid > 0) - H5Sclose( asid ); - if(atid > 0) - H5Tclose( atid ); + if (did > 0) + H5Dclose(did); + if (aid > 0) + H5Aclose(aid); + if (asid > 0) + H5Sclose(asid); + if (atid > 0) + H5Tclose(atid); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5IMread_image -* -* Purpose: Reads image data from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: June 13, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMread_image( hid_t loc_id, - const char *dset_name, - unsigned char *buf ) + * Function: H5IMread_image + * + * Purpose: Reads image data from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: June 13, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMread_image(hid_t loc_id, const char *dset_name, unsigned char *buf) { - hid_t did; + hid_t did; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Read */ - if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0) + if (H5Dread(did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) ) + if (H5Dclose(did)) return -1; return 0; out: - H5Dclose( did ); + H5Dclose(did); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5IMmake_palette -* -* Purpose: Creates and writes a palette. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: May 01, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMmake_palette( hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - const unsigned char *pal_data ) + * Function: H5IMmake_palette + * + * Purpose: Creates and writes a palette. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 01, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMmake_palette(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, const unsigned char *pal_data) { @@ -485,231 +454,221 @@ herr_t H5IMmake_palette( hid_t loc_id, /* check the arguments */ if (pal_name == NULL) - return -1; + return -1; /* Check if the dataset already exists */ - has_pal = H5LTfind_dataset( loc_id, pal_name ); + has_pal = H5LTfind_dataset(loc_id, pal_name); /* It exists. Return */ - if ( has_pal == 1 ) + if (has_pal == 1) return 0; /* Make the palette dataset. */ - if ( H5LTmake_dataset( loc_id, pal_name, 2, pal_dims, H5T_NATIVE_UCHAR, pal_data ) < 0 ) + if (H5LTmake_dataset(loc_id, pal_name, 2, pal_dims, H5T_NATIVE_UCHAR, pal_data) < 0) return -1; /* Attach the attribute "CLASS" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0) + if (H5LTset_attribute_string(loc_id, pal_name, "CLASS", PALETTE_CLASS) < 0) return -1; /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0) + if (H5LTset_attribute_string(loc_id, pal_name, "PAL_VERSION", "1.2") < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5IMlink_palette -* -* Purpose: This function attaches a palette to an existing image dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: May 01, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* An image (dataset) within an HDF5 file may optionally specify an array of -* palettes to be viewed with. The dataset will have an attribute -* which contains an array of object reference pointers which refer to palettes in the file. -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ) + * Function: H5IMlink_palette + * + * Purpose: This function attaches a palette to an existing image dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: May 01, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * An image (dataset) within an HDF5 file may optionally specify an array of + * palettes to be viewed with. The dataset will have an attribute + * which contains an array of object reference pointers which refer to palettes in the file. + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMlink_palette(hid_t loc_id, const char *image_name, const char *pal_name) { hid_t did; - hid_t atid=-1; - hid_t aid=-1; - hid_t asid=-1; - hobj_ref_t ref; /* write a new reference */ - hobj_ref_t *refbuf; /* buffer to read references */ + hid_t atid = -1; + hid_t aid = -1; + hid_t asid = -1; + hobj_ref_t ref; /* write a new reference */ + hobj_ref_t *refbuf; /* buffer to read references */ hssize_t n_refs; hsize_t dim_ref; int ok_pal; - /* check the arguments */ if (image_name == NULL) - return -1; + return -1; if (pal_name == NULL) - return -1; + return -1; /* The image dataset may or may not have the attribute "PALETTE" - * First we try to open to see if it is already there; if not, it is created. - * If it exists, the array of references is extended to hold the reference - * to the new palette - */ + * First we try to open to see if it is already there; if not, it is created. + * If it exists, the array of references is extended to hold the reference + * to the new palette + */ /* First we get the image id */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - ok_pal = H5LT_find_attribute( did, "PALETTE" ); + ok_pal = H5LT_find_attribute(did, "PALETTE"); /*------------------------------------------------------------------------- - * It does not exist. We create the attribute and one reference - *------------------------------------------------------------------------- - */ - if(ok_pal == 0 ) - { - if((asid = H5Screate(H5S_SCALAR)) < 0) + * It does not exist. We create the attribute and one reference + *------------------------------------------------------------------------- + */ + if (ok_pal == 0) { + if ((asid = H5Screate(H5S_SCALAR)) < 0) goto out; /* Create the attribute type for the reference */ - if((atid = H5Tcopy(H5T_STD_REF_OBJ)) < 0) + if ((atid = H5Tcopy(H5T_STD_REF_OBJ)) < 0) goto out; /* Create the attribute "PALETTE" to be attached to the image*/ - if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Create a reference. The reference is created on the local id. */ - if(H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; /* Write the attribute with the reference */ - if(H5Awrite(aid, atid, &ref) < 0) + if (H5Awrite(aid, atid, &ref) < 0) goto out; /* close */ - if(H5Sclose(asid) < 0) + if (H5Sclose(asid) < 0) goto out; - if(H5Tclose(atid) < 0) + if (H5Tclose(atid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - } /*------------------------------------------------------------------------- - * The attribute already exists, open it - *------------------------------------------------------------------------- - */ - else if(ok_pal == 1) - { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + * The attribute already exists, open it + *------------------------------------------------------------------------- + */ + else if (ok_pal == 1) { + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Tget_class(atid) < 0) + if (H5Tget_class(atid) < 0) goto out; /* Get and save the old reference(s) */ - if((asid = H5Aget_space(aid)) < 0) + if ((asid = H5Aget_space(aid)) < 0) goto out; n_refs = H5Sget_simple_extent_npoints(asid); dim_ref = (hsize_t)n_refs + 1; - refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref ); + refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref); - if ( H5Aread( aid, atid, refbuf ) < 0) + if (H5Aread(aid, atid, refbuf) < 0) goto out; /* The attribute must be deleted, in order to the new one can reflect the changes*/ - if(H5Adelete(did, "PALETTE") < 0) + if (H5Adelete(did, "PALETTE") < 0) goto out; /* Create a new reference for this palette. */ - if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1 ) < 0) + if (H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; refbuf[n_refs] = ref; /* Create the data space for the new references */ - if(H5Sclose(asid) < 0) + if (H5Sclose(asid) < 0) goto out; - if((asid = H5Screate_simple(1, &dim_ref, NULL)) < 0) + if ((asid = H5Screate_simple(1, &dim_ref, NULL)) < 0) goto out; /* Create the attribute again with the changes of space */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the attribute with the new references */ - if(H5Awrite(aid, atid, refbuf) < 0) + if (H5Awrite(aid, atid, refbuf) < 0) goto out; /* close */ - if(H5Sclose(asid) < 0) + if (H5Sclose(asid) < 0) goto out; - if(H5Tclose(atid) < 0) + if (H5Tclose(atid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - HDfree( refbuf ); + HDfree(refbuf); } /* ok_pal == 1 */ /* Close the image dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); - H5Sclose( asid ); - H5Tclose( atid ); - H5Aclose( aid ); + H5Dclose(did); + H5Sclose(asid); + H5Tclose(atid); + H5Aclose(aid); return -1; } - - /*------------------------------------------------------------------------- -* Function: H5IMunlink_palette -* -* Purpose: This function dettaches a palette from an existing image dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: September 10, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMunlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ) + * Function: H5IMunlink_palette + * + * Purpose: This function dettaches a palette from an existing image dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: September 10, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMunlink_palette(hid_t loc_id, const char *image_name, const char *pal_name) { hid_t did; hid_t atid; @@ -718,98 +677,94 @@ herr_t H5IMunlink_palette( hid_t loc_id, int ok_pal, has_pal; /* check the arguments */ - if(image_name == NULL) - return -1; - if(pal_name == NULL) - return -1; + if (image_name == NULL) + return -1; + if (pal_name == NULL) + return -1; /* Try to find the palette dataset */ - has_pal = H5LTfind_dataset( loc_id, pal_name ); + has_pal = H5LTfind_dataset(loc_id, pal_name); /* It does not exist. Return */ - if ( has_pal == 0 ) + if (has_pal == 0) return -1; /* The image dataset may or not have the attribute "PALETTE" - * First we try to open to see if it is already there; if not, it is created. - * If it exists, the array of references is extended to hold the reference - * to the new palette - */ + * First we try to open to see if it is already there; if not, it is created. + * If it exists, the array of references is extended to hold the reference + * to the new palette + */ /* First we get the image id */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ ok_pal = H5LT_find_attribute(did, "PALETTE"); /* It does not exist. Nothing to do */ - if(ok_pal == 0) + if (ok_pal == 0) return -1; /* The attribute exists, open it */ - else if(ok_pal == 1) - { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + else if (ok_pal == 1) { + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if((aclass = H5Tget_class(atid)) < 0) + if ((aclass = H5Tget_class(atid)) < 0) goto out; /* Check if it is really a reference */ - if(aclass == H5T_REFERENCE) - { + if (aclass == H5T_REFERENCE) { /* Delete the attribute */ - if(H5Adelete(did, "PALETTE") < 0) + if (H5Adelete(did, "PALETTE") < 0) goto out; - } /* H5T_REFERENCE */ + } /* H5T_REFERENCE */ - if(H5Tclose(atid) < 0) + if (H5Tclose(atid) < 0) goto out; /* Close the attribute. */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; } /* ok_pal */ /* Close the image dataset. */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); + H5Dclose(did); return -1; } - /*------------------------------------------------------------------------- -* Function: H5IMget_npalettes -* -* Purpose: Gets the number of palettes associated to an image -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: July 22, 2001 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMget_npalettes( hid_t loc_id, - const char *image_name, - hssize_t *npals ) + * Function: H5IMget_npalettes + * + * Purpose: Gets the number of palettes associated to an image + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: July 22, 2001 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMget_npalettes(hid_t loc_id, const char *image_name, hssize_t *npals) { hid_t did; hid_t atid; @@ -819,495 +774,469 @@ herr_t H5IMget_npalettes( hid_t loc_id, int has_pal; /* check the arguments */ - if(image_name == NULL) - return -1; + if (image_name == NULL) + return -1; /*assume initially we have no palettes attached*/ *npals = 0; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(did); - if(has_pal == 1 ) - { + if (has_pal == 1) { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if((aclass = H5Tget_class(atid)) < 0) + if ((aclass = H5Tget_class(atid)) < 0) goto out; /* Check if it is really a reference */ - if(aclass == H5T_REFERENCE) - { - if((asid = H5Aget_space(aid)) < 0) + if (aclass == H5T_REFERENCE) { + if ((asid = H5Aget_space(aid)) < 0) goto out; - *npals = H5Sget_simple_extent_npoints( asid ); + *npals = H5Sget_simple_extent_npoints(asid); - if ( H5Sclose( asid ) < 0) + if (H5Sclose(asid) < 0) goto out; } /* H5T_REFERENCE */ - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; /* Close the attribute. */ - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - } /* Close the image dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); + H5Dclose(did); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5IMget_palette_info -* -* Purpose: Get palette information -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: July 22, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMget_palette_info( hid_t loc_id, - const char *image_name, - int pal_number, - hsize_t *pal_dims ) + * Function: H5IMget_palette_info + * + * Purpose: Get palette information + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: July 22, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMget_palette_info(hid_t loc_id, const char *image_name, int pal_number, hsize_t *pal_dims) { - hid_t did; - int has_pal; - hid_t atid=-1; - hid_t aid; - hid_t asid=-1; - hssize_t n_refs; - hsize_t dim_ref; - hobj_ref_t *refbuf; /* buffer to read references */ - hid_t pal_id; - hid_t pal_space_id; - hsize_t pal_maxdims[2]; + hid_t did; + int has_pal; + hid_t atid = -1; + hid_t aid; + hid_t asid = -1; + hssize_t n_refs; + hsize_t dim_ref; + hobj_ref_t *refbuf; /* buffer to read references */ + hid_t pal_id; + hid_t pal_space_id; + hsize_t pal_maxdims[2]; /* check the arguments */ if (image_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(did); - if(has_pal == 1) - { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + if (has_pal == 1) { + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Tget_class(atid) < 0) + if (H5Tget_class(atid) < 0) goto out; /* Get the reference(s) */ - if((asid = H5Aget_space(aid)) < 0) + if ((asid = H5Aget_space(aid)) < 0) goto out; n_refs = H5Sget_simple_extent_npoints(asid); dim_ref = (hsize_t)n_refs; - refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref ); + refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref); - if ( H5Aread( aid, atid, refbuf ) < 0) + if (H5Aread(aid, atid, refbuf) < 0) goto out; /* Get the actual palette */ - if ( (pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) + if ((pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) goto out; - if ( (pal_space_id = H5Dget_space( pal_id )) < 0) + if ((pal_space_id = H5Dget_space(pal_id)) < 0) goto out; - if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0) + if (H5Sget_simple_extent_ndims(pal_space_id) < 0) goto out; - if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0) + if (H5Sget_simple_extent_dims(pal_space_id, pal_dims, pal_maxdims) < 0) goto out; /* close */ - if (H5Dclose(pal_id)<0) + if (H5Dclose(pal_id) < 0) goto out; - if ( H5Sclose( pal_space_id ) < 0) + if (H5Sclose(pal_space_id) < 0) goto out; - if ( H5Sclose( asid ) < 0) + if (H5Sclose(asid) < 0) goto out; - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - HDfree( refbuf ); - - + HDfree(refbuf); } /* Close the image dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); - H5Sclose( asid ); - H5Tclose( atid ); - H5Aclose( aid ); + H5Dclose(did); + H5Sclose(asid); + H5Tclose(atid); + H5Aclose(aid); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5IMget_palette -* -* Purpose: Read palette -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: August 30, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMget_palette( hid_t loc_id, - const char *image_name, - int pal_number, - unsigned char *pal_data ) + * Function: H5IMget_palette + * + * Purpose: Read palette + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: August 30, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMget_palette(hid_t loc_id, const char *image_name, int pal_number, unsigned char *pal_data) { - hid_t did; - int has_pal; - hid_t atid=-1; - hid_t aid; - hid_t asid=-1; - hssize_t n_refs; - hsize_t dim_ref; - hobj_ref_t *refbuf; /* buffer to read references */ - hid_t pal_id; + hid_t did; + int has_pal; + hid_t atid = -1; + hid_t aid; + hid_t asid = -1; + hssize_t n_refs; + hsize_t dim_ref; + hobj_ref_t *refbuf; /* buffer to read references */ + hid_t pal_id; /* check the arguments */ if (image_name == NULL) - return -1; + return -1; if (pal_data == NULL) - return -1; - + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(did); - if(has_pal == 1 ) - { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + if (has_pal == 1) { + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Tget_class(atid) < 0) + if (H5Tget_class(atid) < 0) goto out; /* Get the reference(s) */ - if((asid = H5Aget_space(aid)) < 0) + if ((asid = H5Aget_space(aid)) < 0) goto out; n_refs = H5Sget_simple_extent_npoints(asid); dim_ref = (hsize_t)n_refs; - refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref ); + refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref); - if ( H5Aread( aid, atid, refbuf ) < 0) + if (H5Aread(aid, atid, refbuf) < 0) goto out; /* Get the palette id */ - if ( (pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) + if ((pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) goto out; /* Read the palette dataset */ - if ( H5Dread( pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0) + if (H5Dread(pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) goto out; /* close */ - if (H5Dclose(pal_id)<0) + if (H5Dclose(pal_id) < 0) goto out; - if ( H5Sclose( asid ) < 0) + if (H5Sclose(asid) < 0) goto out; - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - HDfree( refbuf ); + HDfree(refbuf); } /* Close the image dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); - H5Sclose( asid ); - H5Tclose( atid ); - H5Aclose( aid ); + H5Dclose(did); + H5Sclose(asid); + H5Tclose(atid); + H5Aclose(aid); return -1; - } /*------------------------------------------------------------------------- -* Function: H5IMis_image -* -* Purpose: -* -* Return: true, false, fail -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: August 30, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMis_image( hid_t loc_id, - const char *dset_name ) + * Function: H5IMis_image + * + * Purpose: + * + * Return: true, false, fail + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: August 30, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMis_image(hid_t loc_id, const char *dset_name) { - hid_t did; - int has_class; - hid_t atid; - hid_t aid = -1; - char* attr_data; /* Name of attribute */ - hsize_t storage_size; /* Size of storage for attribute */ - herr_t ret; + hid_t did; + int has_class; + hid_t atid; + hid_t aid = -1; + char * attr_data; /* Name of attribute */ + hsize_t storage_size; /* Size of storage for attribute */ + herr_t ret; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Assume initially fail condition */ ret = -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "CLASS" on the dataset */ has_class = H5LT_find_attribute(did, "CLASS"); - if(has_class == 0) - { + if (has_class == 0) { H5Dclose(did); return 0; } - else if(has_class == 1) - { + else if (has_class == 1) { - if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - /* check to make sure attribute is a string */ - if(H5T_STRING != H5Tget_class(atid)) - goto out; + /* check to make sure attribute is a string */ + if (H5T_STRING != H5Tget_class(atid)) + goto out; - /* check to make sure string is null-terminated */ - if(H5T_STR_NULLTERM != H5Tget_strpad(atid)) - goto out; + /* check to make sure string is null-terminated */ + if (H5T_STR_NULLTERM != H5Tget_strpad(atid)) + goto out; - /* allocate buffer large enough to hold string */ - if((storage_size = H5Aget_storage_size(aid)) == 0) - goto out; + /* allocate buffer large enough to hold string */ + if ((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; - attr_data = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); - if(attr_data == NULL) - goto out; + attr_data = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1); + if (attr_data == NULL) + goto out; - if(H5Aread(aid, atid, attr_data) < 0) + if (H5Aread(aid, atid, attr_data) < 0) goto out; - if(HDstrncmp(attr_data, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS),HDstrlen(attr_data))) == 0) + if (HDstrncmp(attr_data, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS), HDstrlen(attr_data))) == 0) ret = 1; else ret = 0; - HDfree(attr_data); + HDfree(attr_data); - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - } /* Close the dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return ret; out: - H5Dclose( did ); + H5Dclose(did); return -1; - } /*------------------------------------------------------------------------- -* Function: H5IMis_palette -* -* Purpose: -* -* Return: true, false, fail -* -* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu -* -* Date: August 30, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMis_palette( hid_t loc_id, - const char *dset_name ) + * Function: H5IMis_palette + * + * Purpose: + * + * Return: true, false, fail + * + * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu + * + * Date: August 30, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMis_palette(hid_t loc_id, const char *dset_name) { - hid_t did; - int has_class; - hid_t atid; - hid_t aid = -1; - char* attr_data; /* Name of attribute */ - hsize_t storage_size; /* Size of storage for attribute */ - herr_t ret; + hid_t did; + int has_class; + hid_t atid; + hid_t aid = -1; + char * attr_data; /* Name of attribute */ + hsize_t storage_size; /* Size of storage for attribute */ + herr_t ret; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Assume initially fail condition */ ret = -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "CLASS" on the dataset */ has_class = H5LT_find_attribute(did, "CLASS"); - if(has_class == 0) - { - H5Dclose( did ); + if (has_class == 0) { + H5Dclose(did); return 0; } - else if(has_class == 1) - { + else if (has_class == 1) { - if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - /* check to make sure attribute is a string */ - if(H5T_STRING != H5Tget_class(atid)) - goto out; + /* check to make sure attribute is a string */ + if (H5T_STRING != H5Tget_class(atid)) + goto out; - /* check to make sure string is null-terminated */ - if(H5T_STR_NULLTERM != H5Tget_strpad(atid)) - goto out; + /* check to make sure string is null-terminated */ + if (H5T_STR_NULLTERM != H5Tget_strpad(atid)) + goto out; - /* allocate buffer large enough to hold string */ - if((storage_size = H5Aget_storage_size(aid)) == 0) - goto out; + /* allocate buffer large enough to hold string */ + if ((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; - attr_data = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); - if(attr_data == NULL) - goto out; + attr_data = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1); + if (attr_data == NULL) + goto out; - if(H5Aread(aid, atid, attr_data) < 0) + if (H5Aread(aid, atid, attr_data) < 0) goto out; - if(HDstrncmp(attr_data, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS),HDstrlen(attr_data))) == 0) + if (HDstrncmp(attr_data, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS), HDstrlen(attr_data))) == 0) ret = 1; else ret = 0; - HDfree(attr_data); + HDfree(attr_data); - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - } /* Close the dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return ret; out: - H5Dclose( did ); + H5Dclose(did); return -1; - } - diff --git a/hl/src/H5IMprivate.h b/hl/src/H5IMprivate.h index 6776c9d..0e47509 100644 --- a/hl/src/H5IMprivate.h +++ b/hl/src/H5IMprivate.h @@ -20,20 +20,16 @@ /* public IM prototypes */ #include "H5IMpublic.h" - #define IMAGE_CLASS "IMAGE" #define PALETTE_CLASS "PALETTE" #define IMAGE_VERSION "1.2" -#define IMAGE8_RANK 2 -#define IMAGE24_RANK 3 - +#define IMAGE8_RANK 2 +#define IMAGE24_RANK 3 /*------------------------------------------------------------------------- * Private functions *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5IM_find_palette(hid_t loc_id ); - +H5_HLDLL herr_t H5IM_find_palette(hid_t loc_id); #endif - diff --git a/hl/src/H5IMpublic.h b/hl/src/H5IMpublic.h index a95e439..745eade 100644 --- a/hl/src/H5IMpublic.h +++ b/hl/src/H5IMpublic.h @@ -14,69 +14,38 @@ #ifndef _H5IMpublic_H #define _H5IMpublic_H - #ifdef __cplusplus extern "C" { #endif +H5_HLDLL herr_t H5IMmake_image_8bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, + const unsigned char *buffer); + +H5_HLDLL herr_t H5IMmake_image_24bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, + const char *interlace, const unsigned char *buffer); + +H5_HLDLL herr_t H5IMget_image_info(hid_t loc_id, const char *dset_name, hsize_t *width, hsize_t *height, + hsize_t *planes, char *interlace, hssize_t *npals); + +H5_HLDLL herr_t H5IMread_image(hid_t loc_id, const char *dset_name, unsigned char *buffer); + +H5_HLDLL herr_t H5IMmake_palette(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, + const unsigned char *pal_data); + +H5_HLDLL herr_t H5IMlink_palette(hid_t loc_id, const char *image_name, const char *pal_name); + +H5_HLDLL herr_t H5IMunlink_palette(hid_t loc_id, const char *image_name, const char *pal_name); + +H5_HLDLL herr_t H5IMget_npalettes(hid_t loc_id, const char *image_name, hssize_t *npals); + +H5_HLDLL herr_t H5IMget_palette_info(hid_t loc_id, const char *image_name, int pal_number, hsize_t *pal_dims); + +H5_HLDLL herr_t H5IMget_palette(hid_t loc_id, const char *image_name, int pal_number, + unsigned char *pal_data); + +H5_HLDLL herr_t H5IMis_image(hid_t loc_id, const char *dset_name); -H5_HLDLL herr_t H5IMmake_image_8bit( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const unsigned char *buffer ); - -H5_HLDLL herr_t H5IMmake_image_24bit( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const char *interlace, - const unsigned char *buffer ); - -H5_HLDLL herr_t H5IMget_image_info( hid_t loc_id, - const char *dset_name, - hsize_t *width, - hsize_t *height, - hsize_t *planes, - char *interlace, - hssize_t *npals ); - -H5_HLDLL herr_t H5IMread_image( hid_t loc_id, - const char *dset_name, - unsigned char *buffer ); - -H5_HLDLL herr_t H5IMmake_palette( hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - const unsigned char *pal_data ); - -H5_HLDLL herr_t H5IMlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ); - -H5_HLDLL herr_t H5IMunlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ); - -H5_HLDLL herr_t H5IMget_npalettes( hid_t loc_id, - const char *image_name, - hssize_t *npals ); - -H5_HLDLL herr_t H5IMget_palette_info( hid_t loc_id, - const char *image_name, - int pal_number, - hsize_t *pal_dims ); - -H5_HLDLL herr_t H5IMget_palette( hid_t loc_id, - const char *image_name, - int pal_number, - unsigned char *pal_data ); - -H5_HLDLL herr_t H5IMis_image( hid_t loc_id, - const char *dset_name ); - -H5_HLDLL herr_t H5IMis_palette( hid_t loc_id, - const char *dset_name ); +H5_HLDLL herr_t H5IMis_palette(hid_t loc_id, const char *dset_name); #ifdef __cplusplus } diff --git a/hl/src/H5LD.c b/hl/src/H5LD.c index 3106ea8..7e8dc30 100644 --- a/hl/src/H5LD.c +++ b/hl/src/H5LD.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -26,10 +26,9 @@ static herr_t H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid); static herr_t H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims); static size_t H5LD_get_dset_type_size(hid_t did, const char *fields); -static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, - const hsize_t *cur_dims, const char *fields, void *buf); +static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, + const char *fields, void *buf); - /*------------------------------------------------------------------------- * Function: H5LD_clean_vector * @@ -47,30 +46,29 @@ static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, void H5LD_clean_vector(H5LD_memb_t *listv[]) { - unsigned n; /* Local index variable */ + unsigned n; /* Local index variable */ HDassert(listv); /* Go through info for each field stored in listv[] */ - for(n = 0; listv[n] != NULL; n++) { - if(listv[n]->names) { - HDfree(listv[n]->names); - listv[n]->names = NULL; - } /* end if */ - - /* Close the type id of the last member in the field */ - if(!(listv[n]->last_tid < 0)) { - H5Tclose(listv[n]->last_tid); - listv[n]->last_tid = -1; - } /* end if */ - - /* Free the H5LD_memb_t structure for the field */ - HDfree(listv[n]); - listv[n] = NULL; + for (n = 0; listv[n] != NULL; n++) { + if (listv[n]->names) { + HDfree(listv[n]->names); + listv[n]->names = NULL; + } /* end if */ + + /* Close the type id of the last member in the field */ + if (!(listv[n]->last_tid < 0)) { + H5Tclose(listv[n]->last_tid); + listv[n]->last_tid = -1; + } /* end if */ + + /* Free the H5LD_memb_t structure for the field */ + HDfree(listv[n]); + listv[n] = NULL; } /* end for */ } /* H5LD_clean_vector() */ - /*------------------------------------------------------------------------- * Function: H5LD_construct_info() * @@ -89,27 +87,27 @@ H5LD_clean_vector(H5LD_memb_t *listv[]) static herr_t H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid) { - hid_t tmp_tid = -1; /* Dataset type id */ - unsigned i; /* Local index variable */ - herr_t ret_value = FAIL; /* Return value */ + hid_t tmp_tid = -1; /* Dataset type id */ + unsigned i; /* Local index variable */ + herr_t ret_value = FAIL; /* Return value */ /* Make a copy of the incoming datatype */ tmp_tid = H5Tcopy(par_tid); /* Validate all the members in a field */ - for(i = 0; memb->names[i] != NULL; i++) { - hid_t memb_tid; /* Type id for a member in a field */ - int idx; /* Index # of a member in a compound datatype */ + for (i = 0; memb->names[i] != NULL; i++) { + hid_t memb_tid; /* Type id for a member in a field */ + int idx; /* Index # of a member in a compound datatype */ /* Get the member index and member type id */ - if((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0) + if ((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0) goto done; - if((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0) + if ((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0) goto done; - /* Sum up the offset of all the members in the field */ + /* Sum up the offset of all the members in the field */ memb->tot_offset += H5Tget_member_offset(tmp_tid, (unsigned)idx); - if(H5Tclose(tmp_tid) < 0) + if (H5Tclose(tmp_tid) < 0) goto done; tmp_tid = memb_tid; } /* end for */ @@ -125,13 +123,12 @@ H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid) done: H5E_BEGIN_TRY - H5Tclose(tmp_tid); + H5Tclose(tmp_tid); H5E_END_TRY - return(ret_value); + return (ret_value); } /* H5LD_construct_info() */ - /*------------------------------------------------------------------------- * Function: H5LD_construct_vector * @@ -157,84 +154,87 @@ done: * * Programmer: Vailin Choi; Aug 2010 * -*------------------------------------------------------------------------- -*/ + *------------------------------------------------------------------------- + */ int -H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid) +H5LD_construct_vector(char *fields, H5LD_memb_t *listv[] /*OUT*/, hid_t par_tid) { - int nfields; /* The # of comma-separated fields in "fields" */ - hbool_t end_of_fields = FALSE; /* end of "fields" */ - char *fields_ptr; /* Pointer to "fields" */ - int ret_value = FAIL; /* Return value */ + int nfields; /* The # of comma-separated fields in "fields" */ + hbool_t end_of_fields = FALSE; /* end of "fields" */ + char * fields_ptr; /* Pointer to "fields" */ + int ret_value = FAIL; /* Return value */ HDassert(listv); HDassert(fields); fields_ptr = fields; - nfields = 0; + nfields = 0; /* Process till end of "fields" */ - while(!end_of_fields) { - H5LD_memb_t *memb = NULL; /* Pointer to structure for storing a field's info */ - char *cur; /* Pointer to a member in a field */ - size_t len; /* Estimated # of members in a field */ - hbool_t gotcomma = FALSE; /* A comma encountered */ - hbool_t gotmember = FALSE; /* Getting member in a field */ - hbool_t valid = TRUE; /* Whether a field being processed is valid or not */ - int j = 0; /* The # of members in a field */ - - len = (HDstrlen(fields_ptr) / 2) + 2; - - /* Allocate memory for an H5LD_memb_t for storing a field's info */ - if(NULL == (memb = (H5LD_memb_t *)HDcalloc((size_t)1, sizeof(H5LD_memb_t)))) - goto done; - - /* Allocate memory for an array of pointers to member names */ - if(NULL == (memb->names = (char **)HDcalloc(len, sizeof(char *)))) - goto done; - - memb->names[j] = fields_ptr; - memb->last_tid = -1; - cur = fields_ptr; - - /* Continue processing till: not valid or comma encountered or "fields" ended */ - while(valid && !gotcomma && !end_of_fields) { - switch(*fields_ptr) { - case '\0': /* end of list */ - if(gotmember) { /* getting something and end of "fields" */ - *cur++ = '\0';; + while (!end_of_fields) { + H5LD_memb_t *memb = NULL; /* Pointer to structure for storing a field's info */ + char * cur; /* Pointer to a member in a field */ + size_t len; /* Estimated # of members in a field */ + hbool_t gotcomma = FALSE; /* A comma encountered */ + hbool_t gotmember = FALSE; /* Getting member in a field */ + hbool_t valid = TRUE; /* Whether a field being processed is valid or not */ + int j = 0; /* The # of members in a field */ + + len = (HDstrlen(fields_ptr) / 2) + 2; + + /* Allocate memory for an H5LD_memb_t for storing a field's info */ + if (NULL == (memb = (H5LD_memb_t *)HDcalloc((size_t)1, sizeof(H5LD_memb_t)))) + goto done; + + /* Allocate memory for an array of pointers to member names */ + if (NULL == (memb->names = (char **)HDcalloc(len, sizeof(char *)))) + goto done; + + memb->names[j] = fields_ptr; + memb->last_tid = -1; + cur = fields_ptr; + + /* Continue processing till: not valid or comma encountered or "fields" ended */ + while (valid && !gotcomma && !end_of_fields) { + switch (*fields_ptr) { + case '\0': /* end of list */ + if (gotmember) { /* getting something and end of "fields" */ + *cur++ = '\0'; + ; memb->names[++j] = NULL; - } /* end if */ + } /* end if */ else /* getting nothing but end of list */ valid = FALSE; end_of_fields = TRUE; break; - case '\\': /* escape character */ + case '\\': /* escape character */ ++fields_ptr; /* skip it */ - if(*fields_ptr == '\0') + if (*fields_ptr == '\0') valid = FALSE; else { - *cur++ = *fields_ptr++; + *cur++ = *fields_ptr++; gotmember = TRUE; } /* end else */ break; case '.': /* nested field separator */ - *fields_ptr++ = *cur++ = '\0';; - if(gotmember) { + *fields_ptr++ = *cur++ = '\0'; + ; + if (gotmember) { memb->names[++j] = cur; - gotmember = FALSE; + gotmember = FALSE; } /* end if */ else valid = FALSE; break; case ',': /* field separator */ - *fields_ptr++ = *cur++ = '\0';; - if(gotmember) { + *fields_ptr++ = *cur++ = '\0'; + ; + if (gotmember) { memb->names[++j] = NULL; - gotmember = FALSE; + gotmember = FALSE; } /* end if */ else valid = FALSE; @@ -242,37 +242,36 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid) break; default: - *cur++ = *fields_ptr++; + *cur++ = *fields_ptr++; gotmember = TRUE; break; - } /* end switch */ - } /* while (valid && !gotcomma && !end_of_fields) */ - - /* If valid, put into listv and continue processing further info */ - if(valid) { - listv[nfields++] = memb; - if(H5LD_construct_info(memb, par_tid) < 0) - goto done; - } /* end if */ + } /* end switch */ + } /* while (valid && !gotcomma && !end_of_fields) */ + + /* If valid, put into listv and continue processing further info */ + if (valid) { + listv[nfields++] = memb; + if (H5LD_construct_info(memb, par_tid) < 0) + goto done; + } /* end if */ else { - if(memb) + if (memb) HDfree(memb); - goto done; - } /* end else */ - } /* while !end_of_fields */ + goto done; + } /* end else */ + } /* while !end_of_fields */ /* Indicate success */ ret_value = nfields; done: listv[nfields] = NULL; - if(ret_value == FAIL) - H5LD_clean_vector(listv); + if (ret_value == FAIL) + H5LD_clean_vector(listv); - return(ret_value); -} /* H5LD_construct_vector() */ + return (ret_value); +} /* H5LD_construct_vector() */ - /*------------------------------------------------------------------------- * Function: H5LD_get_dset_dims * @@ -284,38 +283,39 @@ done: * * Programmer: Vailin Choi; March 2010 * -*------------------------------------------------------------------------- -*/ + *------------------------------------------------------------------------- + */ static herr_t H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims) { - hid_t sid = -1; /* Dataspace ID */ - herr_t ret_value = FAIL; /* Return Value */ + hid_t sid = -1; /* Dataspace ID */ + herr_t ret_value = FAIL; /* Return Value */ /* Verify parameter */ - if(cur_dims == NULL) + if (cur_dims == NULL) goto done; /* Get the dataset's dataspace */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto done; /* Get the current dimension size */ - if(H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0) goto done; /* Indicate success */ ret_value = SUCCEED; done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; - return(ret_value); + return (ret_value); } /* H5LD_get_dset_dims() */ - /*------------------------------------------------------------------------- * Function: H5LD_get_dset_type_size * @@ -334,73 +334,72 @@ done: static size_t H5LD_get_dset_type_size(hid_t did, const char *fields) { - hid_t dset_tid = -1; /* Dataset's type identifier */ - hid_t tid = -1; /* Native Type identifier */ - H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */ - char *dup_fields = NULL; /* A copy of "fields" */ - size_t ret_value = 0; /* Return value */ + hid_t dset_tid = -1; /* Dataset's type identifier */ + hid_t tid = -1; /* Native Type identifier */ + H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */ + char * dup_fields = NULL; /* A copy of "fields" */ + size_t ret_value = 0; /* Return value */ /* Get the datatype of the dataset */ - if((dset_tid = H5Dget_type(did)) < 0) + if ((dset_tid = H5Dget_type(did)) < 0) goto done; - if((tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0) + if ((tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0) goto done; - if(fields == NULL) /* If no "fields" is specified */ + if (fields == NULL) /* If no "fields" is specified */ ret_value = H5Tget_size(tid); - else { /* "fields" are specified */ - size_t len; /* Estimate the number of comma-separated fields in "fields" */ - size_t tot = 0; /* Data type size of all the fields in "fields" */ - int n = 0, num = 0; /* Local index variables */ + else { /* "fields" are specified */ + size_t len; /* Estimate the number of comma-separated fields in "fields" */ + size_t tot = 0; /* Data type size of all the fields in "fields" */ + int n = 0, num = 0; /* Local index variables */ HDassert(fields && *fields); /* Should be a compound datatype if "fields" exists */ - if(H5Tget_class(dset_tid) != H5T_COMPOUND) + if (H5Tget_class(dset_tid) != H5T_COMPOUND) goto done; - /* Get a copy of "fields" */ - if(NULL == (dup_fields = HDstrdup(fields))) + /* Get a copy of "fields" */ + if (NULL == (dup_fields = HDstrdup(fields))) goto done; - /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */ - len = (HDstrlen(fields) / 2) + 2; - if(NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *)))) + /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */ + len = (HDstrlen(fields) / 2) + 2; + if (NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *)))) goto done; - /* Process and store info for "fields" */ - if((num = H5LD_construct_vector(dup_fields, listv/*OUT*/, tid)) < 0) + /* Process and store info for "fields" */ + if ((num = H5LD_construct_vector(dup_fields, listv /*OUT*/, tid)) < 0) goto done; - /* Sum up the size of all the datatypes in "fields" */ - for(n = 0; n < num; n++) - tot += listv[n]->last_tsize; + /* Sum up the size of all the datatypes in "fields" */ + for (n = 0; n < num; n++) + tot += listv[n]->last_tsize; - /* Clean up the vector of H5LD_memb_t structures */ - H5LD_clean_vector(listv); + /* Clean up the vector of H5LD_memb_t structures */ + H5LD_clean_vector(listv); - /* Return the total size */ - ret_value = tot; + /* Return the total size */ + ret_value = tot; } /* end else */ done: H5E_BEGIN_TRY - H5Tclose(tid); - H5Tclose(dset_tid); + H5Tclose(tid); + H5Tclose(dset_tid); H5E_END_TRY /* Free the array of H5LD_memb_t pointers */ - if(listv) + if (listv) HDfree(listv); /* Free memory */ - if(dup_fields) + if (dup_fields) HDfree(dup_fields); - return(ret_value); + return (ret_value); } /* H5LD_get_dset_type_size() */ - /*------------------------------------------------------------------------- * Function: H5LD_get_dset_elmts * @@ -414,136 +413,136 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, - const char *fields, void *buf) +H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, + void *buf) { - hid_t dtid = -1, tid = -1; /* Dataset type id */ - hid_t sid = -1, mid = -1; /* Dataspace and memory space id */ - hssize_t snum_elmts; /* Number of dataset elements in the selection (signed) */ - hsize_t num_elmts; /* Number of dataset elements in the selection */ - hsize_t start[H5S_MAX_RANK];/* Starting offset */ - hsize_t count[H5S_MAX_RANK];/* ??offset */ - H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */ - char *dup_fields = NULL; /* A copy of "fields" */ - char *sav_buf = NULL; /* Saved pointer temporary buffer */ - unsigned ctr; /* Counter for # of curr_dims > prev_dims */ - int ndims; /* Number of dimensions for the dataset */ - int i; /* Local index variable */ - herr_t ret_value = FAIL; /* Return value */ + hid_t dtid = -1, tid = -1; /* Dataset type id */ + hid_t sid = -1, mid = -1; /* Dataspace and memory space id */ + hssize_t snum_elmts; /* Number of dataset elements in the selection (signed) */ + hsize_t num_elmts; /* Number of dataset elements in the selection */ + hsize_t start[H5S_MAX_RANK]; /* Starting offset */ + hsize_t count[H5S_MAX_RANK]; /* ??offset */ + H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */ + char * dup_fields = NULL; /* A copy of "fields" */ + char * sav_buf = NULL; /* Saved pointer temporary buffer */ + unsigned ctr; /* Counter for # of curr_dims > prev_dims */ + int ndims; /* Number of dimensions for the dataset */ + int i; /* Local index variable */ + herr_t ret_value = FAIL; /* Return value */ /* Verify parameters */ - if(prev_dims == NULL || cur_dims == NULL || buf == NULL) - goto done; + if (prev_dims == NULL || cur_dims == NULL || buf == NULL) + goto done; /* Get dataset's dataspace */ - if((sid = H5Dget_space(did)) < 0) - goto done; + if ((sid = H5Dget_space(did)) < 0) + goto done; /* Get the number of dimensions */ - if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) - goto done; + if ((ndims = H5Sget_simple_extent_ndims(sid)) < 0) + goto done; /* Verify that cur_dims must have one dimension whose size is greater than prev_dims */ HDmemset(start, 0, sizeof start); HDmemset(count, 0, sizeof count); ctr = 0; - for(i = 0; i < ndims; i++) - if(cur_dims[i] > prev_dims[i]) { - ++ctr; - count[i] = cur_dims[i] - prev_dims[i]; - start[i] = prev_dims[i]; - } /* end if */ + for (i = 0; i < ndims; i++) + if (cur_dims[i] > prev_dims[i]) { + ++ctr; + count[i] = cur_dims[i] - prev_dims[i]; + start[i] = prev_dims[i]; + } /* end if */ else { /* < or = */ - start[i] = 0; - count[i] = MIN(prev_dims[i], cur_dims[i]); - } /* end else */ - if(!ctr) - goto done; - - if(ctr == 1) { /* changes for only one dimension */ - /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) - goto done; - } /* end if */ + start[i] = 0; + count[i] = MIN(prev_dims[i], cur_dims[i]); + } /* end else */ + if (!ctr) + goto done; + + if (ctr == 1) { /* changes for only one dimension */ + /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + goto done; + } /* end if */ else { /* changes for more than one dimensions */ - HDmemset(start, 0, sizeof start); + HDmemset(start, 0, sizeof start); - /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0) - goto done; - if(H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0) - goto done; + /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0) + goto done; + if (H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0) + goto done; } /* end else */ /* Get the number of elements in the selection */ - if(0 == (snum_elmts = H5Sget_select_npoints(sid))) + if (0 == (snum_elmts = H5Sget_select_npoints(sid))) goto done; num_elmts = (hsize_t)snum_elmts; /* Create the memory space for the selection */ - if((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0) - goto done; + if ((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0) + goto done; /* Get the native datatype size */ - if((dtid = H5Dget_type(did)) < 0) + if ((dtid = H5Dget_type(did)) < 0) goto done; - if((tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) + if ((tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) goto done; - if(fields == NULL) { /* nothing in "fields" */ - /* Read and store all the elements in "buf" */ - if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0) - goto done; - } /* end if */ - else { /* "fields" is specified */ - unsigned char *buf_p = (unsigned char *)buf; /* Pointer to the destination buffer */ - char *tmp_buf; /* Temporary buffer for data read */ - size_t tot_tsize; /* Total datatype size */ - size_t len; /* Estimate the number of comma-separated fields in "fields" */ - - /* should be a compound datatype if "fields" exists */ - if(H5Tget_class(tid) != H5T_COMPOUND) - goto done; - - /* Get the total size of the dataset's datatypes */ - if(0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL))) - goto done; - - /* Allocate memory for reading in the elements in the dataset selection */ - if(NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize))) - goto done; - - /* Read the dataset elements in the selection */ - if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0) - goto done; - - /* Make a copy of "fields" */ - if(NULL == (dup_fields = HDstrdup(fields))) - goto done; - - /* Allocate memory for the vector of H5LD_memb_t pointers */ - len = (HDstrlen(fields) / 2) + 2; - if(NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *)))) - goto done; - - /* Process and store information for "fields" */ - if(H5LD_construct_vector(dup_fields, listv, tid) < 0) + if (fields == NULL) { /* nothing in "fields" */ + /* Read and store all the elements in "buf" */ + if (H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0) + goto done; + } /* end if */ + else { /* "fields" is specified */ + unsigned char *buf_p = (unsigned char *)buf; /* Pointer to the destination buffer */ + char * tmp_buf; /* Temporary buffer for data read */ + size_t tot_tsize; /* Total datatype size */ + size_t len; /* Estimate the number of comma-separated fields in "fields" */ + + /* should be a compound datatype if "fields" exists */ + if (H5Tget_class(tid) != H5T_COMPOUND) goto done; - /* Copy data for each dataset element in the selection */ - for(i = 0; i < (int)num_elmts; i++) { - int j; /* Local index variable */ + /* Get the total size of the dataset's datatypes */ + if (0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL))) + goto done; - /* Copy data for "fields" to the input buffer */ - for(j = 0; listv[j] != NULL; j++) { - HDmemcpy(buf_p, tmp_buf + listv[j]->tot_offset, listv[j]->last_tsize); - buf_p += listv[j]->last_tsize; - } /* end for */ - tmp_buf += tot_tsize; - } /* end for */ + /* Allocate memory for reading in the elements in the dataset selection */ + if (NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize))) + goto done; + + /* Read the dataset elements in the selection */ + if (H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0) + goto done; + + /* Make a copy of "fields" */ + if (NULL == (dup_fields = HDstrdup(fields))) + goto done; - /* Clean up the vector of H5LD_memb_t structures */ - H5LD_clean_vector(listv); + /* Allocate memory for the vector of H5LD_memb_t pointers */ + len = (HDstrlen(fields) / 2) + 2; + if (NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *)))) + goto done; + + /* Process and store information for "fields" */ + if (H5LD_construct_vector(dup_fields, listv, tid) < 0) + goto done; + + /* Copy data for each dataset element in the selection */ + for (i = 0; i < (int)num_elmts; i++) { + int j; /* Local index variable */ + + /* Copy data for "fields" to the input buffer */ + for (j = 0; listv[j] != NULL; j++) { + HDmemcpy(buf_p, tmp_buf + listv[j]->tot_offset, listv[j]->last_tsize); + buf_p += listv[j]->last_tsize; + } /* end for */ + tmp_buf += tot_tsize; + } /* end for */ + + /* Clean up the vector of H5LD_memb_t structures */ + H5LD_clean_vector(listv); } /* end else */ /* Indicate success */ @@ -551,23 +550,23 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims done: H5E_BEGIN_TRY - H5Tclose(dtid); - H5Tclose(tid); - H5Sclose(sid); - H5Sclose(mid); + H5Tclose(dtid); + H5Tclose(tid); + H5Sclose(sid); + H5Sclose(mid); H5E_END_TRY /* Free the array of H5LD_memb_t pointers */ - if(listv) + if (listv) HDfree(listv); /* Free memory */ - if(dup_fields) + if (dup_fields) HDfree(dup_fields); - if(sav_buf) + if (sav_buf) HDfree(sav_buf); - return(ret_value); + return (ret_value); } /* H5LD_get_dset_elmts() */ /*------------------------------------------------------------------------- @@ -577,7 +576,6 @@ done: *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: H5LDget_dset_dims * @@ -593,11 +591,9 @@ done: herr_t H5LDget_dset_dims(hid_t did, hsize_t *cur_dims) { - return(H5LD_get_dset_dims(did, cur_dims)); + return (H5LD_get_dset_dims(did, cur_dims)); } /* H5LDget_dset_dims() */ - - /*------------------------------------------------------------------------- * Function: H5LDget_dset_type_size * @@ -613,10 +609,9 @@ H5LDget_dset_dims(hid_t did, hsize_t *cur_dims) size_t H5LDget_dset_type_size(hid_t did, const char *fields) { - return(H5LD_get_dset_type_size(did, fields)); + return (H5LD_get_dset_type_size(did, fields)); } /* H5LDget_dset_type_size() */ - /*------------------------------------------------------------------------- * Function: H5LDget_dset_elmts * @@ -630,8 +625,8 @@ H5LDget_dset_type_size(hid_t did, const char *fields) *------------------------------------------------------------------------- */ herr_t -H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf) +H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, + void *buf) { - return(H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf) ); + return (H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf)); } /* H5LDget_dset_elmts() */ - diff --git a/hl/src/H5LDprivate.h b/hl/src/H5LDprivate.h index 203bcea..f499adc 100644 --- a/hl/src/H5LDprivate.h +++ b/hl/src/H5LDprivate.h @@ -26,7 +26,7 @@ typedef struct H5LD_memb_t { size_t tot_offset; size_t last_tsize; - hid_t last_tid; + hid_t last_tid; char **names; } H5LD_memb_t; @@ -44,11 +44,10 @@ extern "C" { * Decide to do #3 at this point of time after some discussion. */ H5_HLDLL void H5LD_clean_vector(H5LD_memb_t *listv[]); -H5_HLDLL int H5LD_construct_vector(char *fields, H5LD_memb_t *listv[], hid_t par_tid); +H5_HLDLL int H5LD_construct_vector(char *fields, H5LD_memb_t *listv[], hid_t par_tid); #ifdef __cplusplus } #endif #endif /* end _H5LDprivate_H */ - diff --git a/hl/src/H5LDpublic.h b/hl/src/H5LDpublic.h index e2bb745..43ea97b 100644 --- a/hl/src/H5LDpublic.h +++ b/hl/src/H5LDpublic.h @@ -20,12 +20,11 @@ extern "C" { H5_HLDLL herr_t H5LDget_dset_dims(hid_t did, hsize_t *cur_dims); H5_HLDLL size_t H5LDget_dset_type_size(hid_t did, const char *fields); -H5_HLDLL herr_t H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, - const hsize_t *cur_dims, const char *fields, void *buf); +H5_HLDLL herr_t H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, + const char *fields, void *buf); #ifdef __cplusplus } #endif #endif /* _H5LDpublic_H */ - diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index a631533..dce7421 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -19,15 +19,14 @@ #include "H5LTprivate.h" /* For Lex and Yacc */ -#define COL 3 -#define LIMIT 512 -#define INCREMENT 1024 -#define TMP_LEN 256 -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) -size_t input_len; -char *myinput; -size_t indent = 0; - +#define COL 3 +#define LIMIT 512 +#define INCREMENT 1024 +#define TMP_LEN 256 +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +size_t input_len; +char * myinput; +size_t indent = 0; /* File Image operations @@ -63,58 +62,58 @@ size_t indent = 0; /* Data structure to pass application data to callbacks. */ typedef struct { - void *app_image_ptr; /* Pointer to application buffer */ - size_t app_image_size; /* Size of application buffer */ - void *fapl_image_ptr; /* Pointer to FAPL buffer */ - size_t fapl_image_size; /* Size of FAPL buffer */ - int fapl_ref_count; /* Reference counter for FAPL buffer */ - void *vfd_image_ptr; /* Pointer to VFD buffer */ - size_t vfd_image_size; /* Size of VFD buffer */ - int vfd_ref_count; /* Reference counter for VFD buffer */ - unsigned flags; /* Flags indicate how the file image will */ - /* be open */ - int ref_count; /* Reference counter on udata struct */ + void * app_image_ptr; /* Pointer to application buffer */ + size_t app_image_size; /* Size of application buffer */ + void * fapl_image_ptr; /* Pointer to FAPL buffer */ + size_t fapl_image_size; /* Size of FAPL buffer */ + int fapl_ref_count; /* Reference counter for FAPL buffer */ + void * vfd_image_ptr; /* Pointer to VFD buffer */ + size_t vfd_image_size; /* Size of VFD buffer */ + int vfd_ref_count; /* Reference counter for VFD buffer */ + unsigned flags; /* Flags indicate how the file image will */ + /* be open */ + int ref_count; /* Reference counter on udata struct */ } H5LT_file_image_ud_t; /* callbacks prototypes for file image ops */ -static void *image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata); -static void *image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *udata); -static void *image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); +static void * image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata); +static void * image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, + void *udata); +static void * image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); static herr_t image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *udata); -static void *udata_copy(void *udata); +static void * udata_copy(void *udata); static herr_t udata_free(void *udata); /* Definition of callbacks for file image operations. */ - -/*------------------------------------------------------------------------- -* Function: image_malloc -* -* Purpose: Simulates malloc() function to avoid copying file images. -* The application buffer is set to the buffer on only one FAPL. -* Then the FAPL buffer can be copied to other FAPL buffers or -* to only one VFD buffer. -* -* Return: Address of "allocated" buffer, if successful. Otherwise, it returns -* NULL. -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ +/*------------------------------------------------------------------------- + * Function: image_malloc + * + * Purpose: Simulates malloc() function to avoid copying file images. + * The application buffer is set to the buffer on only one FAPL. + * Then the FAPL buffer can be copied to other FAPL buffers or + * to only one VFD buffer. + * + * Return: Address of "allocated" buffer, if successful. Otherwise, it returns + * NULL. + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static void * image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { - H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; - void * return_value = NULL; + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + void * return_value = NULL; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - switch ( file_image_op ) { + switch (file_image_op) { /* the app buffer is "copied" to only one FAPL. Afterwards, FAPLs can be "copied" */ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: if (udata->app_image_ptr == NULL) @@ -128,13 +127,13 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) if (udata->fapl_ref_count != 0) goto out; - udata->fapl_image_ptr = udata->app_image_ptr; + udata->fapl_image_ptr = udata->app_image_ptr; udata->fapl_image_size = udata->app_image_size; - return_value = udata->fapl_image_ptr; + return_value = udata->fapl_image_ptr; udata->fapl_ref_count++; - break; + break; - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: if (udata->fapl_image_ptr == NULL) goto out; if (udata->fapl_image_size != size) @@ -144,7 +143,7 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) return_value = udata->fapl_image_ptr; udata->fapl_ref_count++; - break; + break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: goto out; @@ -164,48 +163,46 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) if (udata->fapl_ref_count == 0) goto out; - udata->vfd_image_ptr = udata->fapl_image_ptr; - udata->vfd_image_size = size; + udata->vfd_image_ptr = udata->fapl_image_ptr; + udata->vfd_image_size = size; udata->vfd_ref_count++; return_value = udata->vfd_image_ptr; break; - /* added unused labels to shut the compiler up */ - case H5FD_FILE_IMAGE_OP_NO_OP: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: - case H5FD_FILE_IMAGE_OP_FILE_RESIZE: - case H5FD_FILE_IMAGE_OP_FILE_CLOSE: + /* added unused labels to shut the compiler up */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + case H5FD_FILE_IMAGE_OP_FILE_CLOSE: default: goto out; } /* end switch */ - return(return_value); + return (return_value); out: return NULL; } /* end image_malloc() */ - -/*------------------------------------------------------------------------- -* Function: image_memcpy -* -* Purpose: Simulates memcpy() function to avoid copying file images. -* The image buffer can be set to only one FAPL buffer, and -* "copied" to only one VFD buffer. The FAPL buffer can be -* "copied" to other FAPLs buffers. -* -* Return: The address of the destination buffer, if successful. Otherwise, it -* returns NULL. -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ +/*------------------------------------------------------------------------- + * Function: image_memcpy + * + * Purpose: Simulates memcpy() function to avoid copying file images. + * The image buffer can be set to only one FAPL buffer, and + * "copied" to only one VFD buffer. The FAPL buffer can be + * "copied" to other FAPLs buffers. + * + * Return: The address of the destination buffer, if successful. Otherwise, it + * returns NULL. + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static void * -image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, - void *_udata) +image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; @@ -213,7 +210,7 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - switch(file_image_op) { + switch (file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: if (dest != udata->fapl_image_ptr) goto out; @@ -256,42 +253,41 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file goto out; break; - /* added unused labels to shut the compiler up */ - case H5FD_FILE_IMAGE_OP_NO_OP: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: - case H5FD_FILE_IMAGE_OP_FILE_RESIZE: - case H5FD_FILE_IMAGE_OP_FILE_CLOSE: + /* added unused labels to shut the compiler up */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + case H5FD_FILE_IMAGE_OP_FILE_CLOSE: default: goto out; } /* end switch */ - return(dest); + return (dest); out: return NULL; } /* end image_memcpy() */ - -/*------------------------------------------------------------------------- -* Function: image_realloc -* -* Purpose: Reallocates the shared application image buffer and updates data -* structures that manage buffer "copying". -* -* Return: Address of reallocated buffer, if successful. Otherwise, it returns -* NULL. -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ +/*------------------------------------------------------------------------- + * Function: image_realloc + * + * Purpose: Reallocates the shared application image buffer and updates data + * structures that manage buffer "copying". + * + * Return: Address of reallocated buffer, if successful. Otherwise, it returns + * NULL. + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static void * image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { - H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; - void * return_value = NULL; + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + void * return_value = NULL; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) @@ -318,33 +314,32 @@ image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void * goto out; udata->vfd_image_size = size; - return_value = udata->vfd_image_ptr; + return_value = udata->vfd_image_ptr; } /* end if */ else goto out; - return(return_value); + return (return_value); out: return NULL; } /* end image_realloc() */ - /*------------------------------------------------------------------------- -* Function: image_free -* -* Purpose: Simulates deallocation of FAPL and VFD buffers by decreasing -* reference counters. Shared application buffer is actually -* deallocated if there are no outstanding references. -* -* Return: SUCCEED or FAIL -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ + * Function: image_free + * + * Purpose: Simulates deallocation of FAPL and VFD buffers by decreasing + * reference counters. Shared application buffer is actually + * deallocated if there are no outstanding references. + * + * Return: SUCCEED or FAIL + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static herr_t image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) { @@ -354,22 +349,23 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - switch(file_image_op) { + switch (file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: - if (udata->fapl_image_ptr != ptr) + if (udata->fapl_image_ptr != ptr) goto out; if (udata->fapl_ref_count == 0) goto out; udata->fapl_ref_count--; - /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ + /* release the shared buffer only if indicated by the respective flag and there are no outstanding + * references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && - !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { + !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->fapl_image_ptr); - udata->app_image_ptr = NULL; + udata->app_image_ptr = NULL; udata->fapl_image_ptr = NULL; - udata->vfd_image_ptr = NULL; + udata->vfd_image_ptr = NULL; } /* end if */ break; @@ -381,49 +377,49 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) udata->vfd_ref_count--; - /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ + /* release the shared buffer only if indicated by the respective flag and there are no outstanding + * references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && - !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { + !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->vfd_image_ptr); - udata->app_image_ptr = NULL; + udata->app_image_ptr = NULL; udata->fapl_image_ptr = NULL; - udata->vfd_image_ptr = NULL; + udata->vfd_image_ptr = NULL; } /* end if */ break; - /* added unused labels to keep the compiler quite */ - case H5FD_FILE_IMAGE_OP_NO_OP: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: - case H5FD_FILE_IMAGE_OP_FILE_OPEN: - case H5FD_FILE_IMAGE_OP_FILE_RESIZE: - default: + /* added unused labels to keep the compiler quite */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: + case H5FD_FILE_IMAGE_OP_FILE_OPEN: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + default: goto out; } /* end switch */ - return(SUCCEED); + return (SUCCEED); out: - return(FAIL); + return (FAIL); } /* end image_free() */ - -/*------------------------------------------------------------------------- -* Function: udata_copy -* -* Purpose: Simulates the copying of the user data structure utilized in the -* management of the "copying" of file images. -* -* Return: Address of "newly allocated" structure, if successful. Otherwise, it -* returns NULL. -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ +/*------------------------------------------------------------------------- + * Function: udata_copy + * + * Purpose: Simulates the copying of the user data structure utilized in the + * management of the "copying" of file images. + * + * Return: Address of "newly allocated" structure, if successful. Otherwise, it + * returns NULL. + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static void * udata_copy(void *_udata) { @@ -437,28 +433,27 @@ udata_copy(void *_udata) udata->ref_count++; - return(udata); + return (udata); out: return NULL; } /* end udata_copy */ - /*------------------------------------------------------------------------- -* Function: udata_free -* -* Purpose: Simulates deallocation of the user data structure utilized in the -* management of the "copying" of file images. The data structure is -* actually deallocated when there are no outstanding references. -* -* Return: SUCCEED or FAIL -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ + * Function: udata_free + * + * Purpose: Simulates deallocation of the user data structure utilized in the + * management of the "copying" of file images. The data structure is + * actually deallocated when there are no outstanding references. + * + * Return: SUCCEED or FAIL + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static herr_t udata_free(void *_udata) { @@ -473,409 +468,370 @@ udata_free(void *_udata) udata->ref_count--; /* checks that there are no references outstanding before deallocating udata */ - if (udata->ref_count == 0 && udata->fapl_ref_count == 0 && - udata->vfd_ref_count == 0) + if (udata->ref_count == 0 && udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0) HDfree(udata); - return(SUCCEED); + return (SUCCEED); out: - return(FAIL); + return (FAIL); } /* end udata_free */ /* End of callbacks definitions for file image operations */ /*------------------------------------------------------------------------- -* -* internal functions -* -*------------------------------------------------------------------------- -*/ -static herr_t H5LT_get_attribute_mem(hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data); - -/*------------------------------------------------------------------------- -* Function: H5LT_make_dataset -* -* Purpose: Creates and writes a dataset of a type tid -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Quincey Koziol, koziol@hdfgroup.org -* -* Date: October 10, 2007 -* -*------------------------------------------------------------------------- -*/ + * + * internal functions + * + *------------------------------------------------------------------------- + */ +static herr_t H5LT_get_attribute_mem(hid_t loc_id, const char *obj_name, const char *attr_name, + hid_t mem_type_id, void *data); + +/*------------------------------------------------------------------------- + * Function: H5LT_make_dataset + * + * Purpose: Creates and writes a dataset of a type tid + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Quincey Koziol + * + * Date: October 10, 2007 + * + *------------------------------------------------------------------------- + */ static herr_t -H5LT_make_dataset_numerical( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - hid_t tid, - const void *data ) +H5LT_make_dataset_numerical(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid, + const void *data) { - hid_t did = -1, sid = -1; + hid_t did = -1, sid = -1; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Create the data space for the dataset. */ - if((sid = H5Screate_simple(rank, dims, NULL)) < 0) + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; /* Create the dataset. */ - if((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the dataset only if there is data to write */ - if(data) - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (data) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto out; /* End access to the dataset and release resources used by it. */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) return -1; /* Terminate access to the data space. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- -* -* Public functions -* -*------------------------------------------------------------------------- -*/ + * + * Public functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset -* -* Purpose: Creates and writes a dataset of a type tid -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 19, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTmake_dataset + * + * Purpose: Creates and writes a dataset of a type tid + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 19, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - hid_t tid, - const void *data ) +herr_t +H5LTmake_dataset(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid, + const void *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data)); } /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_char -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTmake_dataset_char + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_char( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const char *data ) +herr_t +H5LTmake_dataset_char(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const char *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_short -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_short + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_short( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const short *data ) +herr_t +H5LTmake_dataset_short(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const short *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_int -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_INT type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_int + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_INT type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_int( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const int *data ) +herr_t +H5LTmake_dataset_int(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const int *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data)); } - - /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_long -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_long + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_long( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const long *data ) +herr_t +H5LTmake_dataset_long(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const long *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_float -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_float + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_float( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const float *data ) +herr_t +H5LTmake_dataset_float(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const float *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data)); } - - /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_double -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_double + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_double( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const double *data ) +herr_t +H5LTmake_dataset_double(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const double *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_string -* -* Purpose: Creates and writes a dataset of H5T_C_S1 type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_string + * + * Purpose: Creates and writes a dataset of H5T_C_S1 type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_string(hid_t loc_id, - const char *dset_name, - const char *buf ) +herr_t +H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf) { - hid_t did = -1; - hid_t sid = -1; - hid_t tid = -1; - size_t size; + hid_t did = -1; + hid_t sid = -1; + hid_t tid = -1; + size_t size; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* create a string data type */ - if((tid = H5Tcopy(H5T_C_S1)) < 0 ) + if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; size = HDstrlen(buf) + 1; /* extra null term */ - if(H5Tset_size(tid, size) < 0) + if (H5Tset_size(tid, size) < 0) goto out; - if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) goto out; /* Create the data space for the dataset. */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; /* Create the dataset. */ - if((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the dataset only if there is data to write */ - if(buf) - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (buf) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close*/ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Tclose(tid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - -/*------------------------------------------------------------------------- -* Function: H5LTopen_file_image -* -* Purpose: Open a user supplied file image using the core file driver. -* -* Return: File identifier, Failure: -1 -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ -hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) -{ - hid_t fapl=-1, file_id=-1; /* HDF5 identifiers */ - unsigned file_open_flags; /* Flags for image open */ - char file_name[64]; /* Filename buffer */ - size_t alloc_incr; /* Buffer allocation increment */ - size_t min_incr = 65536; /* Minimum buffer increment */ - double buf_prcnt = 0.1f; /* Percentage of buffer size to set - as increment */ - static long file_name_counter; - H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, - &image_realloc, &image_free, - &udata_copy, &udata_free, - (void *)NULL}; +/*------------------------------------------------------------------------- + * Function: H5LTopen_file_image + * + * Purpose: Open a user supplied file image using the core file driver. + * + * Return: File identifier, Failure: -1 + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ +hid_t +H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) +{ + hid_t fapl = -1, file_id = -1; /* HDF5 identifiers */ + unsigned file_open_flags; /* Flags for image open */ + char file_name[64]; /* Filename buffer */ + size_t alloc_incr; /* Buffer allocation increment */ + size_t min_incr = 65536; /* Minimum buffer increment */ + double buf_prcnt = 0.1f; /* Percentage of buffer size to set + as increment */ + static long file_name_counter; + H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, &image_realloc, &image_free, + &udata_copy, &udata_free, (void *)NULL}; /* check arguments */ if (buf_ptr == NULL) @@ -903,33 +859,33 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) /* Set callbacks for file image ops ONLY if the file image is NOT copied */ if (flags & H5LT_FILE_IMAGE_DONT_COPY) { - H5LT_file_image_ud_t *udata; /* Pointer to udata structure */ + H5LT_file_image_ud_t *udata; /* Pointer to udata structure */ /* Allocate buffer to communicate user data to callbacks */ if (NULL == (udata = (H5LT_file_image_ud_t *)HDmalloc(sizeof(H5LT_file_image_ud_t)))) goto out; /* Initialize udata with info about app buffer containing file image and flags */ - udata->app_image_ptr = buf_ptr; - udata->app_image_size = buf_size; - udata->fapl_image_ptr = NULL; + udata->app_image_ptr = buf_ptr; + udata->app_image_size = buf_size; + udata->fapl_image_ptr = NULL; udata->fapl_image_size = 0; - udata->fapl_ref_count = 0; - udata->vfd_image_ptr = NULL; - udata->vfd_image_size = 0; - udata->vfd_ref_count = 0; - udata->flags = flags; - udata->ref_count = 1; /* corresponding to the first FAPL */ + udata->fapl_ref_count = 0; + udata->vfd_image_ptr = NULL; + udata->vfd_image_size = 0; + udata->vfd_ref_count = 0; + udata->flags = flags; + udata->ref_count = 1; /* corresponding to the first FAPL */ /* copy address of udata into callbacks */ callbacks.udata = (void *)udata; /* Set file image callbacks */ - if (H5Pset_file_image_callbacks(fapl, &callbacks) < 0) { + if (H5Pset_file_image_callbacks(fapl, &callbacks) < 0) { HDfree(udata); goto out; } /* end if */ - } /* end if */ + } /* end if */ /* Assign file image in user buffer to FAPL */ if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0) @@ -956,46 +912,47 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) return file_id; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end H5LTopen_file_image() */ - /*------------------------------------------------------------------------- -* Function: H5LT_read_dataset -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Quincey Koziol, koziol@hdfgroup.org -* -* Date: October 8, 2007 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LT_read_dataset + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Quincey Koziol + * + * Date: October 8, 2007 + * + *------------------------------------------------------------------------- + */ static herr_t H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void *data) { - hid_t did; + hid_t did; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Read */ - if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto out; /* End access to the dataset and release resources used by it. */ - if(H5Dclose(did)) + if (H5Dclose(did)) return -1; return 0; @@ -1006,513 +963,497 @@ out: } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: June 13, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: June 13, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset(hid_t loc_id, - const char *dset_name, - hid_t tid, - void *data) +herr_t +H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t tid, void *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, tid, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, tid, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_char -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_char + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_char( hid_t loc_id, - const char *dset_name, - char *data ) +herr_t +H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data)); } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_short -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_short + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_short( hid_t loc_id, - const char *dset_name, - short *data ) +herr_t +H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_int -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_int + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_int( hid_t loc_id, - const char *dset_name, - int *data ) +herr_t +H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data)); } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_long -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_long + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_long( hid_t loc_id, - const char *dset_name, - long *data ) +herr_t +H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_float -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_float + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_float( hid_t loc_id, - const char *dset_name, - float *data ) +herr_t +H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_double -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_double + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_double( hid_t loc_id, - const char *dset_name, - double *data ) +herr_t +H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_string -* -* Purpose: Reads a dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: October 05, 2004 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_string + * + * Purpose: Reads a dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: October 05, 2004 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_string( hid_t loc_id, - const char *dset_name, - char *buf ) +herr_t +H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf) { - hid_t did = -1; - hid_t tid = -1; + hid_t did = -1; + hid_t tid = -1; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* Read */ - if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Dclose(did)) + if (H5Dclose(did)) goto out; - if(H5Tclose(tid)) + if (H5Tclose(tid)) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: H5LTget_dataset_ndims -* -* Purpose: Gets the dimensionality of a dataset. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 4, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_dataset_ndims + * + * Purpose: Gets the dimensionality of a dataset. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 4, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_dataset_ndims( hid_t loc_id, - const char *dset_name, - int *rank ) +herr_t +H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank) { - hid_t did = -1; - hid_t sid = -1; + hid_t did = -1; + hid_t sid = -1; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* Get rank */ - if((*rank = H5Sget_simple_extent_ndims(sid)) < 0) + if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* Terminate access to the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; /* End access to the dataset */ - if(H5Dclose(did)) + if (H5Dclose(did)) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: H5LTget_dataset_info -* -* Purpose: Gets information about a dataset. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 4, 2001 -* Modified: February 28, 2006: checked for NULL parameters -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_dataset_info + * + * Purpose: Gets information about a dataset. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 4, 2001 + * Modified: February 28, 2006: checked for NULL parameters + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_dataset_info( hid_t loc_id, - const char *dset_name, - hsize_t *dims, - H5T_class_t *type_class, - size_t *type_size ) +herr_t +H5LTget_dataset_info(hid_t loc_id, const char *dset_name, hsize_t *dims, H5T_class_t *type_class, + size_t *type_size) { - hid_t did = -1; - hid_t tid = -1; - hid_t sid = -1; + hid_t did = -1; + hid_t tid = -1; + hid_t sid = -1; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* get an identifier for the datatype. */ tid = H5Dget_type(did); /* get the class. */ - if(type_class != NULL) + if (type_class != NULL) *type_class = H5Tget_class(tid); /* get the size. */ - if(type_size!=NULL) + if (type_size != NULL) *type_size = H5Tget_size(tid); - if(dims != NULL) { + if (dims != NULL) { /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get dimensions */ - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* terminate access to the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; } /* end if */ /* release the datatype. */ - if(H5Tclose(tid)) + if (H5Tclose(tid)) return -1; /* end access to the dataset */ - if(H5Dclose(did)) + if (H5Dclose(did)) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid); H5Sclose(sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- -* Function: find_dataset -* -* Purpose: operator function used by H5LTfind_dataset -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: June 21, 2001 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ + * Function: find_dataset + * + * Purpose: operator function used by H5LTfind_dataset + * + * Programmer: Pedro Vicente + * + * Date: June 21, 2001 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ static herr_t find_dataset(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *op_data) { /* Define a default zero value for return. This will cause the iterator to continue if - * the dataset is not found yet. - */ + * the dataset is not found yet. + */ int ret = 0; /* check the arguments */ if (name == NULL) - return ret; + return ret; /* Shut the compiler up */ loc_id = loc_id; - linfo = linfo; + linfo = linfo; /* Define a positive value for return value if the dataset was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ - if(HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0) + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ + if (HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0) ret = 1; return ret; } - /*------------------------------------------------------------------------- -* Function: H5LTfind_dataset -* -* Purpose: Inquires if a dataset named dset_name exists attached -* to the object loc_id. -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: July 15, 2001 -* -* Return: -* Success: The return value of the first operator that -* returns non-zero, or zero if all members were -* processed with no operator returning non-zero. -* -* Failure: Negative if something goes wrong within the -* library, or the negative value returned by one -* of the operators. -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTfind_dataset + * + * Purpose: Inquires if a dataset named dset_name exists attached + * to the object loc_id. + * + * Programmer: Pedro Vicente + * + * Date: July 15, 2001 + * + * Return: + * Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + *------------------------------------------------------------------------- + */ /* H5Literate wants a non-const pointer but we have a const pointer in the API * call. It's safe to ignore this because we control the callback, don't * modify the op_data buffer (i.e.: dset_name) during the traversal, and the * library never modifies that buffer. */ -H5_GCC_DIAG_OFF(cast-qual) +H5_GCC_DIAG_OFF("cast-qual") herr_t -H5LTfind_dataset( hid_t loc_id, const char *dset_name ) +H5LTfind_dataset(hid_t loc_id, const char *dset_name) { return H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name); } -H5_GCC_DIAG_ON(cast-qual) +H5_GCC_DIAG_ON("cast-qual") /*------------------------------------------------------------------------- -* -* Set attribute functions -* -*------------------------------------------------------------------------- -*/ - + * + * Set attribute functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_string -* -* Purpose: Creates and writes a string attribute named attr_name and attaches -* it to the object specified by the name obj_name. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: July 23, 2001 -* -* Comments: If the attribute already exists, it is overwritten -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_string + * + * Purpose: Creates and writes a string attribute named attr_name and attaches + * it to the object specified by the name obj_name. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: July 23, 2001 + * + * Comments: If the attribute already exists, it is overwritten + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *attr_data ) +herr_t +H5LTset_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, const char *attr_data) { - hid_t attr_type; - hid_t attr_space_id; - hid_t attr_id; - hid_t obj_id; - int has_attr; - size_t attr_size; + hid_t attr_type; + hid_t attr_space_id; + hid_t attr_id; + hid_t obj_id; + int has_attr; + size_t attr_size; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; if (attr_data == NULL) - return -1; + return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Create the attribute */ - if ( (attr_type = H5Tcopy( H5T_C_S1 )) < 0 ) + if ((attr_type = H5Tcopy(H5T_C_S1)) < 0) goto out; - attr_size = HDstrlen( attr_data ) + 1; /* extra null term */ + attr_size = HDstrlen(attr_data) + 1; /* extra null term */ - if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 ) + if (H5Tset_size(attr_type, (size_t)attr_size) < 0) goto out; - if ( H5Tset_strpad( attr_type, H5T_STR_NULLTERM ) < 0 ) + if (H5Tset_strpad(attr_type, H5T_STR_NULLTERM) < 0) goto out; - if ( (attr_space_id = H5Screate( H5S_SCALAR )) < 0 ) + if ((attr_space_id = H5Screate(H5S_SCALAR)) < 0) goto out; /* Verify if the attribute already exists */ has_attr = H5LT_find_attribute(obj_id, attr_name); /* The attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(obj_id, attr_name) < 0) + if (has_attr == 1) + if (H5Adelete(obj_id, attr_name) < 0) goto out; /* Create and write the attribute */ - if((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, attr_type, attr_data) < 0) + if (H5Awrite(attr_id, attr_type, attr_data) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; - if(H5Sclose(attr_space_id) < 0) + if (H5Sclose(attr_space_id) < 0) goto out; - if(H5Tclose(attr_type) < 0) + if (H5Tclose(attr_type) < 0) goto out; /* Close the object */ - if(H5Oclose(obj_id) < 0) + if (H5Oclose(obj_id) < 0) return -1; return 0; @@ -1523,79 +1464,71 @@ out: return -1; } - - - - /*------------------------------------------------------------------------- -* Function: H5LT_set_attribute_numerical -* -* Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: July 25, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LT_set_attribute_numerical + * + * Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: July 25, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LT_set_attribute_numerical( hid_t loc_id, - const char *obj_name, - const char *attr_name, - size_t size, - hid_t tid, - const void *data ) +herr_t +H5LT_set_attribute_numerical(hid_t loc_id, const char *obj_name, const char *attr_name, size_t size, + hid_t tid, const void *data) { - hid_t obj_id, sid, attr_id; - hsize_t dim_size=size; - int has_attr; + hid_t obj_id, sid, attr_id; + hsize_t dim_size = size; + int has_attr; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Create the data space for the attribute. */ - if ( (sid = H5Screate_simple( 1, &dim_size, NULL )) < 0 ) + if ((sid = H5Screate_simple(1, &dim_size, NULL)) < 0) goto out; /* Verify if the attribute already exists */ has_attr = H5LT_find_attribute(obj_id, attr_name); /* The attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(obj_id, attr_name) < 0) + if (has_attr == 1) + if (H5Adelete(obj_id, attr_name) < 0) goto out; /* Create the attribute. */ - if((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the attribute data. */ - if(H5Awrite(attr_id, tid, data) < 0) + if (H5Awrite(attr_id, tid, data) < 0) goto out; /* Close the attribute. */ - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; /* Close the dataspace. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; /* Close the object */ - if(H5Oclose(obj_id) < 0) + if (H5Oclose(obj_id) < 0) return -1; return 0; @@ -1605,562 +1538,499 @@ out: return -1; } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_char -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_char + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *data, - size_t size ) +herr_t +H5LTset_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, const char *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_CHAR, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_CHAR, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_uchar -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_uchar + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned char *data, - size_t size ) +herr_t +H5LTset_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned char *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_UCHAR, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UCHAR, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_short -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_short + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const short *data, - size_t size ) +herr_t +H5LTset_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, const short *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_SHORT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_SHORT, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_ushort -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_ushort + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_ushort( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned short *data, - size_t size ) +herr_t +H5LTset_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned short *data, size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_USHORT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_USHORT, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_int -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_int + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const int *data, - size_t size ) +herr_t +H5LTset_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, const int *data, size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_INT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_INT, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_uint -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_uint + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_uint( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned int *data, - size_t size ) +herr_t +H5LTset_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned int *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_UINT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UINT, data) < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_long -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_long + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const long *data, - size_t size ) +herr_t +H5LTset_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_LONG, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LONG, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_long_long -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu -* -* Date: June 17, 2005 -* -* Comments: This function was added to support attributes of type long long -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_long_long + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Elena Pourmal + * + * Date: June 17, 2005 + * + * Comments: This function was added to support attributes of type long long + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const long long *data, - size_t size ) +herr_t +H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long long *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_LLONG, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LLONG, data) < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_ulong -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_ulong + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_ulong( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned long *data, - size_t size ) +herr_t +H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_ULONG, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULONG, data) < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_float -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: July 25, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTset_attribute_float + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: July 25, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const float *data, - size_t size ) +herr_t +H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_FLOAT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_double -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_double + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const double *data, - size_t size ) +herr_t +H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_DOUBLE, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0) return -1; return 0; - } - - /*------------------------------------------------------------------------- -* Function: find_attr -* -* Purpose: operator function used by H5LT_find_attribute -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: June 21, 2001 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ + * Function: find_attr + * + * Purpose: operator function used by H5LT_find_attribute + * + * Programmer: Pedro Vicente + * + * Date: June 21, 2001 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ static herr_t -find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, - void *op_data) +find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_data) { int ret = H5_ITER_CONT; /* check the arguments */ if (name == NULL) - return H5_ITER_CONT; + return H5_ITER_CONT; /* Shut compiler up */ - loc_id = loc_id; ainfo = ainfo; + loc_id = loc_id; + ainfo = ainfo; /* Define a positive value for return value if the attribute was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ - if(HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data),HDstrlen(name))) == 0) + if (HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data), HDstrlen(name))) == 0) ret = H5_ITER_STOP; return ret; } - /*------------------------------------------------------------------------- -* Function: H5LTfind_attribute -* -* Purpose: Inquires if an attribute named attr_name exists attached to -* the object loc_id. -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: May 17, 2006 -* -* Comments: -* Calls the private version of the function -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTfind_attribute + * + * Purpose: Inquires if an attribute named attr_name exists attached to + * the object loc_id. + * + * Programmer: Pedro Vicente + * + * Date: May 17, 2006 + * + * Comments: + * Calls the private version of the function + * + *------------------------------------------------------------------------- + */ -herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name ) +herr_t +H5LTfind_attribute(hid_t loc_id, const char *attr_name) { - return H5LT_find_attribute(loc_id,attr_name); + return H5LT_find_attribute(loc_id, attr_name); } - - /*------------------------------------------------------------------------- -* Function: H5LT_find_attribute -* -* Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id. -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: June 21, 2001 -* -* Comments: -* The function uses H5Aiterate2 with the operator function find_attr -* -* Return: -* Success: The return value of the first operator that -* returns non-zero, or zero if all members were -* processed with no operator returning non-zero. -* -* Failure: Negative if something goes wrong within the -* library, or the negative value returned by one -* of the operators. -* -*------------------------------------------------------------------------- -*/ + * Function: H5LT_find_attribute + * + * Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id. + * + * Programmer: Pedro Vicente + * + * Date: June 21, 2001 + * + * Comments: + * The function uses H5Aiterate2 with the operator function find_attr + * + * Return: + * Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + *------------------------------------------------------------------------- + */ /* H5Aiterate wants a non-const pointer but we have a const pointer in the API * call. It's safe to ignore this because we control the callback, don't * modify the op_data buffer (i.e.: attr_name) during the traversal, and the * library never modifies that buffer. */ -H5_GCC_DIAG_OFF(cast-qual) +H5_GCC_DIAG_OFF("cast-qual") herr_t -H5LT_find_attribute( hid_t loc_id, const char* attr_name ) +H5LT_find_attribute(hid_t loc_id, const char *attr_name) { return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name); } -H5_GCC_DIAG_ON(cast-qual) - - -/*------------------------------------------------------------------------- -* Function: H5LTget_attribute_ndims -* -* Purpose: Gets the dimensionality of an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 4, 2001 -* -*------------------------------------------------------------------------- -*/ +H5_GCC_DIAG_ON("cast-qual") + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ndims + * + * Purpose: Gets the dimensionality of an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 4, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_ndims( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *rank ) +herr_t +H5LTget_attribute_ndims(hid_t loc_id, const char *obj_name, const char *attr_name, int *rank) { - hid_t attr_id; - hid_t sid; - hid_t obj_id; + hid_t attr_id; + hid_t sid; + hid_t obj_id; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ - if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Open the attribute. */ - if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) - { + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) { H5Oclose(obj_id); return -1; } /* Get the dataspace handle */ - if((sid = H5Aget_space(attr_id)) < 0) + if ((sid = H5Aget_space(attr_id)) < 0) goto out; /* Get rank */ - if((*rank = H5Sget_simple_extent_ndims(sid)) < 0) + if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* Terminate access to the attribute */ - if ( H5Sclose( sid ) < 0 ) + if (H5Sclose(sid) < 0) goto out; /* End access to the attribute */ - if ( H5Aclose( attr_id ) ) - goto out;; + if (H5Aclose(attr_id)) + goto out; + ; /* Close the object */ - if(H5Oclose(obj_id) < 0 ) + if (H5Oclose(obj_id) < 0) return -1; return 0; out: - H5Aclose( attr_id ); + H5Aclose(attr_id); H5Oclose(obj_id); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_info -* -* Purpose: Gets information about an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 4, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_attribute_info + * + * Purpose: Gets information about an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 4, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_info( hid_t loc_id, - const char *obj_name, - const char *attr_name, - hsize_t *dims, - H5T_class_t *type_class, - size_t *type_size ) +herr_t +H5LTget_attribute_info(hid_t loc_id, const char *obj_name, const char *attr_name, hsize_t *dims, + H5T_class_t *type_class, size_t *type_size) { - hid_t attr_id; - hid_t tid; - hid_t sid; - hid_t obj_id; + hid_t attr_id; + hid_t tid; + hid_t sid; + hid_t obj_id; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ - if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Open the attribute. */ - if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) - { + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) { H5Oclose(obj_id); return -1; } @@ -2172,30 +2042,30 @@ herr_t H5LTget_attribute_info( hid_t loc_id, *type_class = H5Tget_class(tid); /* Get the size. */ - *type_size = H5Tget_size( tid ); + *type_size = H5Tget_size(tid); /* Get the dataspace handle */ - if ( (sid = H5Aget_space( attr_id )) < 0 ) + if ((sid = H5Aget_space(attr_id)) < 0) goto out; /* Get dimensions */ - if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 ) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* Terminate access to the dataspace */ - if ( H5Sclose( sid ) < 0 ) + if (H5Sclose(sid) < 0) goto out; /* Release the datatype. */ - if ( H5Tclose( tid ) ) + if (H5Tclose(tid)) goto out; /* End access to the attribute */ - if ( H5Aclose( attr_id ) ) + if (H5Aclose(attr_id)) goto out; /* Close the object */ - if(H5Oclose(obj_id) < 0 ) + if (H5Oclose(obj_id) < 0) return -1; return 0; @@ -2205,46 +2075,46 @@ out: H5Aclose(attr_id); H5Oclose(obj_id); return -1; - } /*------------------------------------------------------------------------- -* Function: H5LTtext_to_dtype -* -* Purpose: Convert DDL description to HDF5 data type. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Raymond Lu, slu@ncsa.uiuc.edu -* -* Date: October 6, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) + * Function: H5LTtext_to_dtype + * + * Purpose: Convert DDL description to HDF5 data type. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Raymond Lu + * + * Date: October 6, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) { - hid_t type_id; + hid_t type_id; /* check the arguments */ if (text == NULL) - return -1; + return -1; - if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) + if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; - if(lang_type != H5LT_DDL) { + if (lang_type != H5LT_DDL) { HDfprintf(stderr, "only DDL is supported for now.\n"); goto out; } input_len = HDstrlen(text); - myinput = HDstrdup(text); + myinput = HDstrdup(text); - if((type_id = H5LTyyparse()) < 0) { + if ((type_id = H5LTyyparse()) < 0) { HDfree(myinput); goto out; } @@ -2259,57 +2129,60 @@ out: } /*------------------------------------------------------------------------- -* Function: realloc_and_append -* -* Purpose: Expand the buffer and append a string to it. -* -* Return: void -* -* Programmer: Raymond Lu, songyulu@hdfgroup.org -* -* Date: 29 September 2011 -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -static char* + * Function: realloc_and_append + * + * Purpose: Expand the buffer and append a string to it. + * + * Return: void + * + * Programmer: Raymond Lu + * + * Date: 29 September 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static char * realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str_to_add) { size_t size_str_to_add, size_str; - if(_no_user_buf) { + if (_no_user_buf) { /* If the buffer isn't big enough, reallocate it. Otherwise, go to do strcat. */ - if(str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) { + if (str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) { *len += ((HDstrlen(buf) + HDstrlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT; - buf = (char*)HDrealloc(buf, *len); - } else if(!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) { + buf = (char *)HDrealloc(buf, *len); + } + else if (!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) { *len += INCREMENT; - buf = (char*)HDrealloc(buf, *len); + buf = (char *)HDrealloc(buf, *len); } } - if(!buf) - goto out; - - if(str_to_add) { - /* find the size of the buffer to add */ - size_str_to_add = HDstrlen(str_to_add); - /* find the size of the current buffer */ - size_str = HDstrlen(buf); - - /* Check to make sure the appended string does not - * extend past the allocated buffer; if it does then truncate the string - */ - if(size_str < *len - 1) { - if( size_str + size_str_to_add < *len - 1) { - HDstrncat(buf, str_to_add, size_str_to_add); - } else { - HDstrncat(buf, str_to_add, (*len - 1) - size_str); - } - } else { - buf[*len-1] = '\0'; /* buffer is full, null terminate */ - } + if (!buf) + goto out; + + if (str_to_add) { + /* find the size of the buffer to add */ + size_str_to_add = HDstrlen(str_to_add); + /* find the size of the current buffer */ + size_str = HDstrlen(buf); + + /* Check to make sure the appended string does not + * extend past the allocated buffer; if it does then truncate the string + */ + if (size_str < *len - 1) { + if (size_str + size_str_to_add < *len - 1) { + HDstrncat(buf, str_to_add, size_str_to_add); + } + else { + HDstrncat(buf, str_to_add, (*len - 1) - size_str); + } + } + else { + buf[*len - 1] = '\0'; /* buffer is full, null terminate */ + } } return buf; @@ -2319,32 +2192,33 @@ out: } /*------------------------------------------------------------------------- -* Function: indentation -* -* Purpose: Print spaces for indentation -* -* Return: void -* -* Programmer: Raymond Lu, slu@ncsa.uiuc.edu -* -* Date: December 6, 2005 -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -static char* -indentation(size_t x, char* str, hbool_t no_u_buf, size_t *s_len) + * Function: indentation + * + * Purpose: Print spaces for indentation + * + * Return: void + * + * Programmer: Raymond Lu + * + * Date: December 6, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static char * +indentation(size_t x, char *str, hbool_t no_u_buf, size_t *s_len) { - char tmp_str[TMP_LEN]; + char tmp_str[TMP_LEN]; if (x < 80) { HDmemset(tmp_str, ' ', x); - tmp_str[x]='\0'; - } else + tmp_str[x] = '\0'; + } + else HDsnprintf(tmp_str, TMP_LEN, "error: the indentation exceeds the number of cols."); - if(!(str = realloc_and_append(no_u_buf, s_len, str, tmp_str))) + if (!(str = realloc_and_append(no_u_buf, s_len, str, tmp_str))) goto out; return str; @@ -2354,98 +2228,99 @@ out: } /*------------------------------------------------------------------------- -* Function: print_enum -* -* Purpose: prints the enum data -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Raymond Lu -* -* Modifications: -* -*-----------------------------------------------------------------------*/ -static char* -print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) + * Function: print_enum + * + * Purpose: prints the enum data + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Raymond Lu + * + * Modifications: + * + *-----------------------------------------------------------------------*/ +static char * +print_enum(hid_t type, char *str, size_t *str_len, hbool_t no_ubuf, size_t indt) { - char **name = NULL; /*member names */ - unsigned char *value = NULL; /*value array */ - int nmembs; /*number of members */ - char tmp_str[TMP_LEN]; - int nchars; /*number of output characters */ - hid_t super = -1; /*enum base integer type */ - hid_t native = -1; /*native integer data type */ - size_t super_size; /*enum base type size */ - size_t dst_size; /*destination value type size */ - int i; + char ** name = NULL; /*member names */ + unsigned char *value = NULL; /*value array */ + int nmembs; /*number of members */ + char tmp_str[TMP_LEN]; + int nchars; /*number of output characters */ + hid_t super = -1; /*enum base integer type */ + hid_t native = -1; /*native integer data type */ + size_t super_size; /*enum base type size */ + size_t dst_size; /*destination value type size */ + int i; - if((nmembs = H5Tget_nmembers(type))<=0) + if ((nmembs = H5Tget_nmembers(type)) <= 0) goto out; - if((super = H5Tget_super(type)) < 0) + if ((super = H5Tget_super(type)) < 0) goto out; /* Use buffer of INT or UNSIGNED INT to print enum values because - * we don't expect these values to be so big that INT or UNSIGNED - * INT can't hold. - */ + * we don't expect these values to be so big that INT or UNSIGNED + * INT can't hold. + */ if (H5T_SGN_NONE == H5Tget_sign(super)) { native = H5T_NATIVE_UINT; - } else { + } + else { native = H5T_NATIVE_INT; } super_size = H5Tget_size(super); - dst_size = H5Tget_size(native); + dst_size = H5Tget_size(native); /* Get the names and raw values of all members */ - name = (char**)HDcalloc((size_t)nmembs, sizeof(char *)); - value = (unsigned char*)HDcalloc((size_t)nmembs, MAX(dst_size, super_size)); + name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)); + value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(dst_size, super_size)); for (i = 0; i < nmembs; i++) { - if((name[i] = H5Tget_member_name(type, (unsigned)i))==NULL) + if ((name[i] = H5Tget_member_name(type, (unsigned)i)) == NULL) goto out; - if(H5Tget_member_value(type, (unsigned)i, value + (size_t)i * super_size) < 0) + if (H5Tget_member_value(type, (unsigned)i, value + (size_t)i * super_size) < 0) goto out; } /* Convert values to native data type */ if (native > 0) { - if(H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) goto out; } /* - * Sort members by increasing value - * ***not implemented yet*** - */ + * Sort members by increasing value + * ***not implemented yet*** + */ /* Print members */ for (i = 0; i < nmembs; i++) { - if(!(str = indentation(indt + COL, str, no_ubuf, str_len))) + if (!(str = indentation(indt + COL, str, no_ubuf, str_len))) goto out; nchars = HDsnprintf(tmp_str, TMP_LEN, "\"%s\"", name[i]); - if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; HDmemset(tmp_str, ' ', (size_t)MAX(3, 19 - nchars) + 1); tmp_str[MAX(3, 19 - nchars)] = '\0'; - if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; if (H5T_SGN_NONE == H5Tget_sign(native)) HDsnprintf(tmp_str, TMP_LEN, "%u", *((unsigned int *)((void *)(value + (size_t)i * dst_size)))); else HDsnprintf(tmp_str, TMP_LEN, "%d", *((int *)((void *)(value + (size_t)i * dst_size)))); - if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; HDsnprintf(tmp_str, TMP_LEN, ";\n"); - if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; } /* Release resources */ - for(i = 0; i < nmembs; i++) + for (i = 0; i < nmembs; i++) H5free_memory(name[i]); HDfree(name); @@ -2456,71 +2331,73 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) out: - if(0 == nmembs) { + if (0 == nmembs) { str = realloc_and_append(no_ubuf, str_len, str, "\n"); HDassert((indt + 4) < TMP_LEN); HDmemset(tmp_str, ' ', (indt + 4) + 1); tmp_str[(indt + 4)] = '\0'; - str = realloc_and_append(no_ubuf, str_len, str, tmp_str); - str = realloc_and_append(no_ubuf, str_len, str, " "); + str = realloc_and_append(no_ubuf, str_len, str, tmp_str); + str = realloc_and_append(no_ubuf, str_len, str, " "); } /* end if */ /* Release resources */ - if(name) { - for(i = 0; i < nmembs; i++) - if(name[i]) + if (name) { + for (i = 0; i < nmembs; i++) + if (name[i]) HDfree(name[i]); HDfree(name); } /* end if */ - if(value) + if (value) HDfree(value); - if(super >= 0) + if (super >= 0) H5Tclose(super); return NULL; } /*------------------------------------------------------------------------- -* Function: H5LTdtype_to_text -* -* Purpose: Convert HDF5 data type to DDL description. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Raymond Lu, slu@ncsa.uiuc.edu -* -* Date: December 6, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) + * Function: H5LTdtype_to_text + * + * Purpose: Convert HDF5 data type to DDL description. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Raymond Lu + * + * Date: December 6, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) { - size_t str_len = INCREMENT; - char *text_str; - herr_t ret = SUCCEED; + size_t str_len = INCREMENT; + char * text_str; + herr_t ret = SUCCEED; - if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) + if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; - if(len && !str) { - text_str = (char*)HDcalloc(str_len, sizeof(char)); - text_str[0]='\0'; - if(!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1))) + if (len && !str) { + text_str = (char *)HDcalloc(str_len, sizeof(char)); + text_str[0] = '\0'; + if (!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1))) goto out; *len = HDstrlen(text_str) + 1; - if(text_str) + if (text_str) HDfree(text_str); text_str = NULL; - } else if(len && str) { - if(!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0))) + } + else if (len && str) { + if (!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0))) goto out; - str[*len-1] = '\0'; + str[*len - 1] = '\0'; } return ret; @@ -2530,38 +2407,38 @@ out: } /*------------------------------------------------------------------------- -* Function: H5LT_dtype_to_text -* -* Purpose: Private function to convert HDF5 data type to DDL description. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Raymond Lu, slu@ncsa.uiuc.edu -* -* Date: December 20, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, - hbool_t no_user_buf) + * Function: H5LT_dtype_to_text + * + * Purpose: Private function to convert HDF5 data type to DDL description. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Raymond Lu + * + * Date: December 20, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +char * +H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hbool_t no_user_buf) { H5T_class_t tcls; char tmp_str[TMP_LEN]; int i; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL))) goto out; - if(lang != H5LT_DDL) { + if (lang != H5LT_DDL) { HDsnprintf(dt_str, *slen, "only DDL is supported for now"); goto out; } - if((tcls = H5Tget_class(dtype)) < 0) + if ((tcls = H5Tget_class(dtype)) < 0) goto out; switch (tcls) { @@ -2569,57 +2446,83 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl case H5T_BITFIELD: if (H5Tequal(dtype, H5T_STD_I8BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I8BE"); - } else if (H5Tequal(dtype, H5T_STD_I8LE)) { + } + else if (H5Tequal(dtype, H5T_STD_I8LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I8LE"); - } else if (H5Tequal(dtype, H5T_STD_I16BE)) { + } + else if (H5Tequal(dtype, H5T_STD_I16BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I16BE"); - } else if (H5Tequal(dtype, H5T_STD_I16LE)) { + } + else if (H5Tequal(dtype, H5T_STD_I16LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I16LE"); - } else if (H5Tequal(dtype, H5T_STD_I32BE)) { + } + else if (H5Tequal(dtype, H5T_STD_I32BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I32BE"); - } else if (H5Tequal(dtype, H5T_STD_I32LE)) { + } + else if (H5Tequal(dtype, H5T_STD_I32LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I32LE"); - } else if (H5Tequal(dtype, H5T_STD_I64BE)) { + } + else if (H5Tequal(dtype, H5T_STD_I64BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I64BE"); - } else if (H5Tequal(dtype, H5T_STD_I64LE)) { + } + else if (H5Tequal(dtype, H5T_STD_I64LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I64LE"); - } else if (H5Tequal(dtype, H5T_STD_U8BE)) { + } + else if (H5Tequal(dtype, H5T_STD_U8BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U8BE"); - } else if (H5Tequal(dtype, H5T_STD_U8LE)) { + } + else if (H5Tequal(dtype, H5T_STD_U8LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U8LE"); - } else if (H5Tequal(dtype, H5T_STD_U16BE)) { + } + else if (H5Tequal(dtype, H5T_STD_U16BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U16BE"); - } else if (H5Tequal(dtype, H5T_STD_U16LE)) { + } + else if (H5Tequal(dtype, H5T_STD_U16LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U16LE"); - } else if (H5Tequal(dtype, H5T_STD_U32BE)) { + } + else if (H5Tequal(dtype, H5T_STD_U32BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U32BE"); - } else if (H5Tequal(dtype, H5T_STD_U32LE)) { + } + else if (H5Tequal(dtype, H5T_STD_U32LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U32LE"); - } else if (H5Tequal(dtype, H5T_STD_U64BE)) { + } + else if (H5Tequal(dtype, H5T_STD_U64BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U64BE"); - } else if (H5Tequal(dtype, H5T_STD_U64LE)) { + } + else if (H5Tequal(dtype, H5T_STD_U64LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U64LE"); - } else if (H5Tequal(dtype, H5T_NATIVE_SCHAR)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_SCHAR)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_SCHAR"); - } else if (H5Tequal(dtype, H5T_NATIVE_UCHAR)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_UCHAR)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_UCHAR"); - } else if (H5Tequal(dtype, H5T_NATIVE_SHORT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_SHORT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_SHORT"); - } else if (H5Tequal(dtype, H5T_NATIVE_USHORT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_USHORT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_USHORT"); - } else if (H5Tequal(dtype, H5T_NATIVE_INT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_INT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_INT"); - } else if (H5Tequal(dtype, H5T_NATIVE_UINT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_UINT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_UINT"); - } else if (H5Tequal(dtype, H5T_NATIVE_LONG)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_LONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LONG"); - } else if (H5Tequal(dtype, H5T_NATIVE_ULONG)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_ULONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_ULONG"); - } else if (H5Tequal(dtype, H5T_NATIVE_LLONG)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_LLONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LLONG"); - } else if (H5Tequal(dtype, H5T_NATIVE_ULLONG)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_ULLONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_ULLONG"); - } else { + } + else { HDsnprintf(dt_str, *slen, "undefined integer"); } @@ -2627,439 +2530,445 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl case H5T_FLOAT: if (H5Tequal(dtype, H5T_IEEE_F32BE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F32BE"); - } else if (H5Tequal(dtype, H5T_IEEE_F32LE)) { + } + else if (H5Tequal(dtype, H5T_IEEE_F32LE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F32LE"); - } else if (H5Tequal(dtype, H5T_IEEE_F64BE)) { + } + else if (H5Tequal(dtype, H5T_IEEE_F64BE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F64BE"); - } else if (H5Tequal(dtype, H5T_IEEE_F64LE)) { + } + else if (H5Tequal(dtype, H5T_IEEE_F64LE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F64LE"); - } else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_FLOAT"); - } else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_DOUBLE"); -#if H5_SIZEOF_LONG_DOUBLE !=0 - } else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) { +#if H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LDOUBLE"); #endif - } else { + } + else { HDsnprintf(dt_str, *slen, "undefined float"); } break; - case H5T_STRING: - { - /* Make a copy of type in memory in case when DTYPE is on disk, the size - * will be bigger than in memory. This makes it easier to compare - * types in memory. */ - hid_t str_type; - H5T_order_t order; - hid_t tmp_type; - size_t size; - H5T_str_t str_pad; - H5T_cset_t cset; - htri_t is_vlstr; - - if((tmp_type = H5Tcopy(dtype)) < 0) - goto out; - if((size = H5Tget_size(tmp_type))==0) - goto out; - if((str_pad = H5Tget_strpad(tmp_type)) < 0) - goto out; - if((cset = H5Tget_cset(tmp_type)) < 0) - goto out; - if((is_vlstr = H5Tis_variable_str(tmp_type)) < 0) - goto out; + case H5T_STRING: { + /* Make a copy of type in memory in case when DTYPE is on disk, the size + * will be bigger than in memory. This makes it easier to compare + * types in memory. */ + hid_t str_type; + H5T_order_t order; + hid_t tmp_type; + size_t size; + H5T_str_t str_pad; + H5T_cset_t cset; + htri_t is_vlstr; + + if ((tmp_type = H5Tcopy(dtype)) < 0) + goto out; + if ((size = H5Tget_size(tmp_type)) == 0) + goto out; + if ((str_pad = H5Tget_strpad(tmp_type)) < 0) + goto out; + if ((cset = H5Tget_cset(tmp_type)) < 0) + goto out; + if ((is_vlstr = H5Tis_variable_str(tmp_type)) < 0) + goto out; - /* Print lead-in */ - HDsnprintf(dt_str, *slen, "H5T_STRING {\n"); - indent += COL; + /* Print lead-in */ + HDsnprintf(dt_str, *slen, "H5T_STRING {\n"); + indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - if(is_vlstr) - HDsnprintf(tmp_str, TMP_LEN, "STRSIZE H5T_VARIABLE;\n"); - else - HDsnprintf(tmp_str, TMP_LEN, "STRSIZE %d;\n", (int)size); + if (is_vlstr) + HDsnprintf(tmp_str, TMP_LEN, "STRSIZE H5T_VARIABLE;\n"); + else + HDsnprintf(tmp_str, TMP_LEN, "STRSIZE %d;\n", (int)size); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - if (str_pad == H5T_STR_NULLTERM) - HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLTERM;\n"); - else if (str_pad == H5T_STR_NULLPAD) - HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLPAD;\n"); - else if (str_pad == H5T_STR_SPACEPAD) - HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_SPACEPAD;\n"); - else - HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_ERROR;\n"); + if (str_pad == H5T_STR_NULLTERM) + HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLTERM;\n"); + else if (str_pad == H5T_STR_NULLPAD) + HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLPAD;\n"); + else if (str_pad == H5T_STR_SPACEPAD) + HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_SPACEPAD;\n"); + else + HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_ERROR;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - if (cset == H5T_CSET_ASCII) - HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_ASCII;\n"); - else if (cset == H5T_CSET_UTF8) - HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_UTF8;\n"); - else - HDsnprintf(tmp_str, TMP_LEN, "CSET unknown;\n"); + if (cset == H5T_CSET_ASCII) + HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_ASCII;\n"); + else if (cset == H5T_CSET_UTF8) + HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_UTF8;\n"); + else + HDsnprintf(tmp_str, TMP_LEN, "CSET unknown;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - /* Reproduce a C type string */ - if((str_type = H5Tcopy(H5T_C_S1)) < 0) - goto out; - if(is_vlstr) { - if(H5Tset_size(str_type, H5T_VARIABLE) < 0) - goto out; - } else { - if(H5Tset_size(str_type, size) < 0) - goto out; - } - if(H5Tset_cset(str_type, cset) < 0) + /* Reproduce a C type string */ + if ((str_type = H5Tcopy(H5T_C_S1)) < 0) + goto out; + if (is_vlstr) { + if (H5Tset_size(str_type, H5T_VARIABLE) < 0) goto out; - if(H5Tset_strpad(str_type, str_pad) < 0) + } + else { + if (H5Tset_size(str_type, size) < 0) goto out; + } + if (H5Tset_cset(str_type, cset) < 0) + goto out; + if (H5Tset_strpad(str_type, str_pad) < 0) + goto out; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - /* Check C variable-length string first. Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - goto next; - } + /* Check C variable-length string first. Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + goto next; + } - /* Change the endianness and see if they're equal. */ - if((order = H5Tget_order(tmp_type)) < 0) + /* Change the endianness and see if they're equal. */ + if ((order = H5Tget_order(tmp_type)) < 0) + goto out; + if (order == H5T_ORDER_LE) { + if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) goto out; - if(order==H5T_ORDER_LE) { - if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) - goto out; - } else if(order==H5T_ORDER_BE) { - if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) - goto out; - } - - if (H5Tequal(tmp_type, str_type)) { - HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - goto next; - } - - /* If not equal to C variable-length string, check Fortran type. - * Actually H5Tequal can't tell difference between H5T_C_S1 and H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - if(H5Tclose(str_type) < 0) + } + else if (order == H5T_ORDER_BE) { + if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) goto out; - if((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0) + } + + if (H5Tequal(tmp_type, str_type)) { + HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; - if(H5Tset_cset(str_type, cset) < 0) + goto next; + } + + /* If not equal to C variable-length string, check Fortran type. + * Actually H5Tequal can't tell difference between H5T_C_S1 and + * H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + if (H5Tclose(str_type) < 0) + goto out; + if ((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0) + goto out; + if (H5Tset_cset(str_type, cset) < 0) + goto out; + if (H5Tset_size(str_type, size) < 0) + goto out; + if (H5Tset_strpad(str_type, str_pad) < 0) + goto out; + + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; - if(H5Tset_size(str_type, size) < 0) + goto next; + } + + /* Change the endianness and see if they're equal. */ + if ((order = H5Tget_order(tmp_type)) < 0) + goto out; + if (order == H5T_ORDER_LE) { + if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) goto out; - if(H5Tset_strpad(str_type, str_pad) < 0) + } + else if (order == H5T_ORDER_BE) { + if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) goto out; + } - /* Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - goto next; - } - - /* Change the endianness and see if they're equal. */ - if((order = H5Tget_order(tmp_type)) < 0) - goto out; - if(order==H5T_ORDER_LE) { - if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) - goto out; - } else if(order==H5T_ORDER_BE) { - if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) - goto out; - } - - /* Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - goto next; - } - - /* Type doesn't match any of above. */ - HDsnprintf(tmp_str, TMP_LEN, "CTYPE unknown_one_character_type;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; + goto next; + } + + /* Type doesn't match any of above. */ + HDsnprintf(tmp_str, TMP_LEN, "CTYPE unknown_one_character_type;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; next: - H5Tclose(str_type); - H5Tclose(tmp_type); + H5Tclose(str_type); + H5Tclose(tmp_type); - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - break; - } - case H5T_OPAQUE: - { + break; + } + case H5T_OPAQUE: { char *tag = NULL; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_OPAQUE {\n"); indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "OPQ_SIZE %lu;\n", (unsigned long)H5Tget_size(dtype)); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; tag = H5Tget_tag(dtype); - if(tag) { + if (tag) { HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"%s\";\n", tag); - if(tag) + if (tag) H5free_memory(tag); tag = NULL; - } else + } + else HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"\";\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; /* Print closing */ indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; break; - } - case H5T_ENUM: - { - hid_t super; - size_t super_len; - char* stmp = NULL; - - /* Print lead-in */ - HDsnprintf(dt_str, *slen, "H5T_ENUM {\n"); - indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + } + case H5T_ENUM: { + hid_t super; + size_t super_len; + char * stmp = NULL; - if((super = H5Tget_super(dtype)) < 0) - goto out; - if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) - goto out; - stmp = (char*)HDcalloc(super_len, sizeof(char)); - if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) - goto out; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) - goto out; + /* Print lead-in */ + HDsnprintf(dt_str, *slen, "H5T_ENUM {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - if(stmp) - HDfree(stmp); - stmp = NULL; + if ((super = H5Tget_super(dtype)) < 0) + goto out; + if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + goto out; + stmp = (char *)HDcalloc(super_len, sizeof(char)); + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + goto out; - HDsnprintf(tmp_str, TMP_LEN, ";\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - H5Tclose(super); + if (stmp) + HDfree(stmp); + stmp = NULL; - if(!(dt_str = print_enum(dtype, dt_str, slen, no_user_buf, indent))) - goto out; + HDsnprintf(tmp_str, TMP_LEN, ";\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (!(dt_str = print_enum(dtype, dt_str, slen, no_user_buf, indent))) + goto out; - break; - } - case H5T_VLEN: - { - hid_t super; - size_t super_len; - char* stmp = NULL; - - /* Print lead-in */ - HDsnprintf(dt_str, *slen, "H5T_VLEN {\n"); - indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - if((super = H5Tget_super(dtype)) < 0) - goto out; - if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) - goto out; - stmp = (char*)HDcalloc(super_len, sizeof(char)); - if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) - goto out; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) - goto out; + break; + } + case H5T_VLEN: { + hid_t super; + size_t super_len; + char * stmp = NULL; - if(stmp) - HDfree(stmp); - stmp = NULL; - HDsnprintf(tmp_str, TMP_LEN, "\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - H5Tclose(super); + /* Print lead-in */ + HDsnprintf(dt_str, *slen, "H5T_VLEN {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if ((super = H5Tget_super(dtype)) < 0) + goto out; + if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + goto out; + stmp = (char *)HDcalloc(super_len, sizeof(char)); + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + goto out; - break; - } - case H5T_ARRAY: - { - hid_t super; - size_t super_len; - char* stmp = NULL; - hsize_t dims[H5S_MAX_RANK]; - int ndims; - - /* Print lead-in */ - HDsnprintf(dt_str, *slen, "H5T_ARRAY {\n"); - indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (stmp) + HDfree(stmp); + stmp = NULL; + HDsnprintf(tmp_str, TMP_LEN, "\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_ARRAY: { + hid_t super; + size_t super_len; + char * stmp = NULL; + hsize_t dims[H5S_MAX_RANK]; + int ndims; + + /* Print lead-in */ + HDsnprintf(dt_str, *slen, "H5T_ARRAY {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + /* Get array information */ + if ((ndims = H5Tget_array_ndims(dtype)) < 0) + goto out; + if (H5Tget_array_dims2(dtype, dims) < 0) + goto out; + + /* Print array dimensions */ + for (i = 0; i < ndims; i++) { + HDsnprintf(tmp_str, TMP_LEN, "[%d]", (int)dims[i]); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; + } + HDsnprintf(tmp_str, TMP_LEN, " "); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + if ((super = H5Tget_super(dtype)) < 0) + goto out; + if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + goto out; + stmp = (char *)HDcalloc(super_len, sizeof(char)); + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + goto out; + if (stmp) + HDfree(stmp); + stmp = NULL; + HDsnprintf(tmp_str, TMP_LEN, "\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_COMPOUND: { + char * mname = NULL; + hid_t mtype; + size_t moffset; + H5T_class_t mclass; + size_t mlen; + char * mtmp = NULL; + int nmembs; + + if ((nmembs = H5Tget_nmembers(dtype)) < 0) + goto out; - /* Get array information */ - if((ndims = H5Tget_array_ndims(dtype)) < 0) + HDsnprintf(dt_str, *slen, "H5T_COMPOUND {\n"); + indent += COL; + + for (i = 0; i < nmembs; i++) { + if ((mname = H5Tget_member_name(dtype, (unsigned)i)) == NULL) + goto out; + if ((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0) goto out; - if(H5Tget_array_dims2(dtype, dims) < 0) + moffset = H5Tget_member_offset(dtype, (unsigned)i); + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; - /* Print array dimensions */ - for (i = 0; i < ndims; i++) { - HDsnprintf(tmp_str, TMP_LEN, "[%d]", (int) dims[i]); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - } - HDsnprintf(tmp_str, TMP_LEN, " "); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - - if((super = H5Tget_super(dtype)) < 0) + if ((mclass = H5Tget_class(mtype)) < 0) goto out; - if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + if (H5T_COMPOUND == mclass) + indent += COL; + + if (H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) goto out; - stmp = (char*)HDcalloc(super_len, sizeof(char)); - if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + mtmp = (char *)HDcalloc(mlen, sizeof(char)); + if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) goto out; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) - goto out; - if(stmp) - HDfree(stmp); - stmp = NULL; - HDsnprintf(tmp_str, TMP_LEN, "\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - H5Tclose(super); - - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (mtmp) + HDfree(mtmp); + mtmp = NULL; - break; - } - case H5T_COMPOUND: - { - char *mname = NULL; - hid_t mtype; - size_t moffset; - H5T_class_t mclass; - size_t mlen; - char* mtmp = NULL; - int nmembs; - - if((nmembs = H5Tget_nmembers(dtype)) < 0) - goto out; + if (H5T_COMPOUND == mclass) + indent -= COL; - HDsnprintf(dt_str, *slen, "H5T_COMPOUND {\n"); - indent += COL; - - for (i = 0; i < nmembs; i++) { - if((mname = H5Tget_member_name(dtype, (unsigned)i))==NULL) - goto out; - if((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0) - goto out; - moffset = H5Tget_member_offset(dtype, (unsigned)i); - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; - - if((mclass = H5Tget_class(mtype)) < 0) - goto out; - if (H5T_COMPOUND == mclass) - indent += COL; - - if(H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) - goto out; - mtmp = (char*)HDcalloc(mlen, sizeof(char)); - if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) - goto out; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) - goto out; - if(mtmp) - HDfree(mtmp); - mtmp = NULL; - - if (H5T_COMPOUND == mclass) - indent -= COL; - - HDsnprintf(tmp_str, TMP_LEN, " \"%s\"", mname); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - if(mname) - H5free_memory(mname); - mname = NULL; - - HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - } - - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + HDsnprintf(tmp_str, TMP_LEN, " \"%s\"", mname); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (mname) + H5free_memory(mname); + mname = NULL; - break; + HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; } + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } case H5T_TIME: HDsnprintf(dt_str, *slen, "H5T_TIME: not yet implemented"); break; @@ -3067,15 +2976,15 @@ next: HDsnprintf(dt_str, *slen, "H5T_NO_CLASS"); break; case H5T_REFERENCE: - if (H5Tequal(dtype, H5T_STD_REF_DSETREG) == TRUE) { - HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_DSETREG }"); - } - else { - HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_OBJECT }"); - } - break; + if (H5Tequal(dtype, H5T_STD_REF_DSETREG) == TRUE) { + HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_DSETREG }"); + } + else { + HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_OBJECT }"); + } + break; case H5T_NCLASSES: - break; + break; default: HDsnprintf(dt_str, *slen, "unknown data type"); } @@ -3087,747 +2996,701 @@ out: } /*------------------------------------------------------------------------- -* -* Get attribute functions -* -*------------------------------------------------------------------------- -*/ - + * + * Get attribute functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_string -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTget_attribute_string + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ) +herr_t +H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, char *data) { /* identifiers */ - hid_t obj_id; + hid_t obj_id; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ - if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) - { - H5Oclose(obj_id); - return -1; + if (H5LT_get_attribute_disk(obj_id, attr_name, data) < 0) { + H5Oclose(obj_id); + return -1; } /* Close the object */ - if(H5Oclose(obj_id) < 0) + if (H5Oclose(obj_id) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_char -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ) + * Function: H5LTget_attribute_char + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, char *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_uchar -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned char *data ) + * Function: H5LTget_attribute_uchar + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned char *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0) return -1; return 0; } - - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_short -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - short *data ) + * Function: H5LTget_attribute_short + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, short *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_ushort -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_ushort( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned short *data ) + * Function: H5LTget_attribute_ushort + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned short *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0) return -1; return 0; } - - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_int -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *data ) + * Function: H5LTget_attribute_int + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, int *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_uint -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_uint( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned int *data ) + * Function: H5LTget_attribute_uint + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned int *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0) return -1; return 0; } - - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_long -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long *data ) + * Function: H5LTget_attribute_long + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_long_long -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu -* -* Date: June 17, 2005 -* -* Comments: This function was added to support INTEGER*8 Fortran types -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long long *data ) + * Function: H5LTget_attribute_long_long + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Elena Pourmal + * + * Date: June 17, 2005 + * + * Comments: This function was added to support INTEGER*8 Fortran types + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, long long *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_ulong -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_ulong( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned long *data ) + * Function: H5LTget_attribute_ulong + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_float -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTget_attribute_float + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - float *data ) +herr_t +H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, float *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_double -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTget_attribute_double + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - double *data ) +herr_t +H5LTget_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, double *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute -* -* Purpose: Reads an attribute named attr_name with the memory type mem_type_id -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: Private function -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTget_attribute + * + * Purpose: Reads an attribute named attr_name with the memory type mem_type_id + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: Private function + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute( hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data ) +herr_t +H5LTget_attribute(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* private functions -*------------------------------------------------------------------------- -*/ - + * private functions + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5LT_get_attribute_mem -* -* Purpose: Reads an attribute named attr_name with the memory type mem_type_id -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: Private function -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LT_get_attribute_mem + * + * Purpose: Reads an attribute named attr_name with the memory type mem_type_id + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: Private function + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -static herr_t H5LT_get_attribute_mem(hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data) +static herr_t +H5LT_get_attribute_mem(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, + void *data) { /* identifiers */ - hid_t obj_id = -1; + hid_t obj_id = -1; hid_t attr_id = -1; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ - if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) goto out; - if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) goto out; - if(H5Aread(attr_id, mem_type_id, data) < 0) + if (H5Aread(attr_id, mem_type_id, data) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; attr_id = -1; /* Close the object */ - if(H5Oclose(obj_id) < 0) + if (H5Oclose(obj_id) < 0) goto out; obj_id = -1; return 0; out: - if(obj_id > 0) + if (obj_id > 0) H5Oclose(obj_id); - if(attr_id > 0) + if (attr_id > 0) H5Aclose(attr_id); return -1; } /*------------------------------------------------------------------------- -* Function: H5LT_get_attribute_disk -* -* Purpose: Reads an attribute named attr_name with the datatype stored on disk -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LT_get_attribute_disk + * + * Purpose: Reads an attribute named attr_name with the datatype stored on disk + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LT_get_attribute_disk( hid_t loc_id, - const char *attr_name, - void *attr_out ) +herr_t +H5LT_get_attribute_disk(hid_t loc_id, const char *attr_name, void *attr_out) { /* identifiers */ hid_t attr_id; hid_t attr_type; - if(( attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0) + if ((attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0) return -1; - if((attr_type = H5Aget_type(attr_id)) < 0) + if ((attr_type = H5Aget_type(attr_id)) < 0) goto out; - if(H5Aread(attr_id, attr_type, attr_out) < 0) + if (H5Aread(attr_id, attr_type, attr_out) < 0) goto out; - if(H5Tclose(attr_type) < 0) + if (H5Tclose(attr_type) < 0) goto out; - if ( H5Aclose( attr_id ) < 0 ) - return -1;; + if (H5Aclose(attr_id) < 0) + return -1; + ; return 0; out: - H5Tclose( attr_type ); - H5Aclose( attr_id ); + H5Tclose(attr_type); + H5Aclose(attr_id); return -1; } - -/*------------------------------------------------------------------------- -* Function: H5LT_set_attribute_string -* -* Purpose: creates and writes an attribute named NAME to the dataset DSET_ID -* -* Return: FAIL on error, SUCCESS on success -* -* Programmer: pvn@ncsa.uiuc.edu -* -* Date: January 04, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LT_set_attribute_string(hid_t dset_id, - const char *name, - const char *buf ) +/*------------------------------------------------------------------------- + * Function: H5LT_set_attribute_string + * + * Purpose: creates and writes an attribute named NAME to the dataset DSET_ID + * + * Return: FAIL on error, SUCCESS on success + * + * Programmer: Pedro Vicente + * + * Date: January 04, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf) { - hid_t tid; - hid_t sid = -1; - hid_t aid = -1; - int has_attr; - size_t size; + hid_t tid; + hid_t sid = -1; + hid_t aid = -1; + int has_attr; + size_t size; /* verify if the attribute already exists */ - has_attr = H5LT_find_attribute(dset_id,name); + has_attr = H5LT_find_attribute(dset_id, name); /* the attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(dset_id, name) < 0) + if (has_attr == 1) + if (H5Adelete(dset_id, name) < 0) return FAIL; /*------------------------------------------------------------------------- - * create the attribute type - *------------------------------------------------------------------------- - */ - if((tid = H5Tcopy(H5T_C_S1)) < 0) + * create the attribute type + *------------------------------------------------------------------------- + */ + if ((tid = H5Tcopy(H5T_C_S1)) < 0) return FAIL; size = HDstrlen(buf) + 1; /* extra null term */ - if(H5Tset_size(tid,(size_t)size) < 0) + if (H5Tset_size(tid, (size_t)size) < 0) goto out; - if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) goto out; - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; - /*------------------------------------------------------------------------- - * create and write the attribute - *------------------------------------------------------------------------- - */ - if((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * create and write the attribute + *------------------------------------------------------------------------- + */ + if ((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, buf) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; return SUCCEED; /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(tid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; - } htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid) - { - char *tmp_path = NULL; /* Temporary copy of the path */ - char *curr_name; /* Pointer to current component of path name */ - char *delimit; /* Pointer to path delimiter during traversal */ - H5I_type_t obj_type; - htri_t link_exists, obj_exists; - size_t path_length; - htri_t ret_value; - - /* Initialize */ - ret_value = FALSE; - - /* check the arguments */ - if (path == NULL) { - ret_value = FAIL; - goto done; - } - - /* Find the type of loc_id */ - if((obj_type = H5Iget_type(loc_id)) == H5I_BADID) { - ret_value = FAIL; - goto done; - } - - /* Find the length of the path */ - path_length = HDstrlen(path); - - /* Check if the identifier is the object itself, i.e. path is '.' */ - if(HDstrncmp(path, ".", path_length) == 0) { - if(check_object_valid) { - obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT); - ret_value = obj_exists; - goto done; - } else { - ret_value = TRUE; /* Since the object is the identifier itself, - * we can only check if loc_id is a valid type */ - goto done; - } - } - - /* Duplicate the path to use */ - if(NULL == (tmp_path = HDstrdup(path))) { - ret_value = FAIL; - goto done; - } - - curr_name = tmp_path; - - /* check if absolute pathname */ - if(HDstrncmp(path, "/", 1) == 0) curr_name++; - - /* check if relative path name starts with "./" */ - if(HDstrncmp(path, "./", 2) == 0) curr_name += 2; - - while((delimit=HDstrchr(curr_name,'/'))!=NULL) { - /* Change the delimiter to terminate the string */ - *delimit='\0'; - - obj_exists = FALSE; - if((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { - ret_value = FAIL; - goto done; - } - - /* If target link does not exist then no reason to - * continue checking the path */ - if(link_exists != TRUE) { - ret_value = FALSE; - goto done; - } - - /* Determine if link resolves to an actual object */ - if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { - ret_value = FAIL; - goto done; - } - - if(obj_exists != TRUE) - break; - - /* Change the delimiter back to '/' */ - *delimit='/'; - - /* Advance the pointer in the path to the start of the next component */ - curr_name = delimit + 1; - - } /* end while */ - - /* Should be pointing to the last component in the path name now... */ - - /* Check if link does not exist */ - if((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { - ret_value = FAIL; - } else { - ret_value = link_exists; - /* Determine if link resolves to an actual object for check_object_valid TRUE */ - if(check_object_valid == TRUE && link_exists == TRUE) { - if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { - ret_value = FAIL; - } else { - ret_value = obj_exists; - } - } - } +{ + char * tmp_path = NULL; /* Temporary copy of the path */ + char * curr_name; /* Pointer to current component of path name */ + char * delimit; /* Pointer to path delimiter during traversal */ + H5I_type_t obj_type; + htri_t link_exists, obj_exists; + size_t path_length; + htri_t ret_value; + + /* Initialize */ + ret_value = FALSE; + + /* check the arguments */ + if (path == NULL) { + ret_value = FAIL; + goto done; + } + + /* Find the type of loc_id */ + if ((obj_type = H5Iget_type(loc_id)) == H5I_BADID) { + ret_value = FAIL; + goto done; + } + + /* Find the length of the path */ + path_length = HDstrlen(path); + + /* Check if the identifier is the object itself, i.e. path is '.' */ + if (HDstrncmp(path, ".", path_length) == 0) { + if (check_object_valid) { + obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT); + ret_value = obj_exists; + goto done; + } + else { + ret_value = TRUE; /* Since the object is the identifier itself, + * we can only check if loc_id is a valid type */ + goto done; + } + } + + /* Duplicate the path to use */ + if (NULL == (tmp_path = HDstrdup(path))) { + ret_value = FAIL; + goto done; + } + + curr_name = tmp_path; + + /* check if absolute pathname */ + if (HDstrncmp(path, "/", 1) == 0) + curr_name++; + + /* check if relative path name starts with "./" */ + if (HDstrncmp(path, "./", 2) == 0) + curr_name += 2; + + while ((delimit = HDstrchr(curr_name, '/')) != NULL) { + /* Change the delimiter to terminate the string */ + *delimit = '\0'; + + obj_exists = FALSE; + if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + /* If target link does not exist then no reason to + * continue checking the path */ + if (link_exists != TRUE) { + ret_value = FALSE; + goto done; + } + + /* Determine if link resolves to an actual object */ + if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + if (obj_exists != TRUE) + break; + + /* Change the delimiter back to '/' */ + *delimit = '/'; + + /* Advance the pointer in the path to the start of the next component */ + curr_name = delimit + 1; + + } /* end while */ + + /* Should be pointing to the last component in the path name now... */ + + /* Check if link does not exist */ + if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + } + else { + ret_value = link_exists; + /* Determine if link resolves to an actual object for check_object_valid TRUE */ + if (check_object_valid == TRUE && link_exists == TRUE) { + if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + } + else { + ret_value = obj_exists; + } + } + } done: - if(tmp_path != NULL) - HDfree(tmp_path); + if (tmp_path != NULL) + HDfree(tmp_path); - return ret_value; - } + return ret_value; +} diff --git a/hl/src/H5LTprivate.h b/hl/src/H5LTprivate.h index 01c5ee6..0200725 100644 --- a/hl/src/H5LTprivate.h +++ b/hl/src/H5LTprivate.h @@ -25,26 +25,17 @@ *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LT_get_attribute_disk( hid_t obj_id, - const char *attr_name, - void *data ); +H5_HLDLL herr_t H5LT_get_attribute_disk(hid_t obj_id, const char *attr_name, void *data); -H5_HLDLL herr_t H5LT_set_attribute_numerical( hid_t loc_id, - const char *obj_name, - const char *attr_name, - size_t size, - hid_t type_id, - const void *data ); +H5_HLDLL herr_t H5LT_set_attribute_numerical(hid_t loc_id, const char *obj_name, const char *attr_name, + size_t size, hid_t type_id, const void *data); -H5_HLDLL herr_t H5LT_set_attribute_string( hid_t dset_id, - const char *name, - const char *buf ); +H5_HLDLL herr_t H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf); -H5_HLDLL herr_t H5LT_find_attribute( hid_t loc_id, const char *name ); +H5_HLDLL herr_t H5LT_find_attribute(hid_t loc_id, const char *name); - -H5_HLDLL char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, - size_t *slen, hbool_t no_user_buf); +H5_HLDLL char *H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, + hbool_t no_user_buf); H5_HLDLL hid_t H5LTyyparse(void); diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h index 6df7c4b..97129bf 100644 --- a/hl/src/H5LTpublic.h +++ b/hl/src/H5LTpublic.h @@ -15,13 +15,13 @@ #define _H5LTpublic_H /* Flag definitions for H5LTopen_file_image() */ -#define H5LT_FILE_IMAGE_OPEN_RW 0x0001 /* Open image for read-write */ -#define H5LT_FILE_IMAGE_DONT_COPY 0x0002 /* The HDF5 lib won't copy */ +#define H5LT_FILE_IMAGE_OPEN_RW 0x0001 /* Open image for read-write */ +#define H5LT_FILE_IMAGE_DONT_COPY 0x0002 /* The HDF5 lib won't copy */ /* user supplied image buffer. The same image is open with the core driver. */ #define H5LT_FILE_IMAGE_DONT_RELEASE 0x0004 /* The HDF5 lib won't */ /* deallocate user supplied image buffer. The user application is reponsible */ /* for doing so. */ -#define H5LT_FILE_IMAGE_ALL 0x0007 +#define H5LT_FILE_IMAGE_ALL 0x0007 typedef enum H5LT_lang_t { H5LT_LANG_ERR = -1, /*this is the first*/ @@ -42,53 +42,28 @@ extern "C" { *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LTmake_dataset( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - hid_t type_id, - const void *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_char( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const char *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_short( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const short *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_int( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const int *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_long( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const long *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_float( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const float *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_double( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const double *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_string( hid_t loc_id, - const char *dset_name, - const char *buf ); +H5_HLDLL herr_t H5LTmake_dataset(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + hid_t type_id, const void *buffer); +H5_HLDLL herr_t H5LTmake_dataset_char(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const char *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_short(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const short *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_int(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const int *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_long(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const long *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_float(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const float *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_double(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const double *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf); /*------------------------------------------------------------------------- * @@ -97,38 +72,21 @@ H5_HLDLL herr_t H5LTmake_dataset_string( hid_t loc_id, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LTread_dataset( hid_t loc_id, - const char *dset_name, - hid_t type_id, - void *buffer ); +H5_HLDLL herr_t H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t type_id, void *buffer); -H5_HLDLL herr_t H5LTread_dataset_char( hid_t loc_id, - const char *dset_name, - char *buffer ); +H5_HLDLL herr_t H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *buffer); -H5_HLDLL herr_t H5LTread_dataset_short( hid_t loc_id, - const char *dset_name, - short *buffer ); +H5_HLDLL herr_t H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *buffer); -H5_HLDLL herr_t H5LTread_dataset_int( hid_t loc_id, - const char *dset_name, - int *buffer ); +H5_HLDLL herr_t H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *buffer); -H5_HLDLL herr_t H5LTread_dataset_long( hid_t loc_id, - const char *dset_name, - long *buffer ); +H5_HLDLL herr_t H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *buffer); -H5_HLDLL herr_t H5LTread_dataset_float( hid_t loc_id, - const char *dset_name, - float *buffer ); +H5_HLDLL herr_t H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *buffer); -H5_HLDLL herr_t H5LTread_dataset_double( hid_t loc_id, - const char *dset_name, - double *buffer ); +H5_HLDLL herr_t H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *buffer); -H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id, - const char *dset_name, - char *buf ); +H5_HLDLL herr_t H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf); /*------------------------------------------------------------------------- * @@ -137,20 +95,12 @@ H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank); -H5_HLDLL herr_t H5LTget_dataset_ndims( hid_t loc_id, - const char *dset_name, - int *rank ); - -H5_HLDLL herr_t H5LTget_dataset_info( hid_t loc_id, - const char *dset_name, - hsize_t *dims, - H5T_class_t *type_class, - size_t *type_size ); - -H5_HLDLL herr_t H5LTfind_dataset( hid_t loc_id, const char *name ); - +H5_HLDLL herr_t H5LTget_dataset_info(hid_t loc_id, const char *dset_name, hsize_t *dims, + H5T_class_t *type_class, size_t *type_size); +H5_HLDLL herr_t H5LTfind_dataset(hid_t loc_id, const char *name); /*------------------------------------------------------------------------- * @@ -159,77 +109,41 @@ H5_HLDLL herr_t H5LTfind_dataset( hid_t loc_id, const char *name ); *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5LTset_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, + const char *attr_data); + +H5_HLDLL herr_t H5LTset_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, + const char *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned char *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, + const short *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned short *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, + const int *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned int *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, + const long *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, + const long long *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned long *buffer, size_t size); + +H5_HLDLL herr_t H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, + const float *buffer, size_t size); -H5_HLDLL herr_t H5LTset_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *attr_data ); - -H5_HLDLL herr_t H5LTset_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned char *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const short *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_ushort( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned short *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const int *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_uint( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned int *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const long *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const long long *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_ulong( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned long *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const float *buffer, - size_t size ); - -H5_HLDLL herr_t H5LTset_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const double *buffer, - size_t size ); +H5_HLDLL herr_t H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, + const double *buffer, size_t size); /*------------------------------------------------------------------------- * @@ -238,72 +152,41 @@ H5_HLDLL herr_t H5LTset_attribute_double( hid_t loc_id, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LTget_attribute( hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data ); - -H5_HLDLL herr_t H5LTget_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ); - -H5_HLDLL herr_t H5LTget_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ); - -H5_HLDLL herr_t H5LTget_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned char *data ); - -H5_HLDLL herr_t H5LTget_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - short *data ); - -H5_HLDLL herr_t H5LTget_attribute_ushort( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned short *data ); - -H5_HLDLL herr_t H5LTget_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *data ); - -H5_HLDLL herr_t H5LTget_attribute_uint( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned int *data ); - -H5_HLDLL herr_t H5LTget_attribute_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long *data ); - -H5_HLDLL herr_t H5LTget_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long long *data ); - -H5_HLDLL herr_t H5LTget_attribute_ulong( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned long *data ); - -H5_HLDLL herr_t H5LTget_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - float *data ); - -H5_HLDLL herr_t H5LTget_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - double *data ); +H5_HLDLL herr_t H5LTget_attribute(hid_t loc_id, const char *obj_name, const char *attr_name, + hid_t mem_type_id, void *data); +H5_HLDLL herr_t H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, + char *data); + +H5_HLDLL herr_t H5LTget_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, char *data); + +H5_HLDLL herr_t H5LTget_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned char *data); + +H5_HLDLL herr_t H5LTget_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, + short *data); + +H5_HLDLL herr_t H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned short *data); + +H5_HLDLL herr_t H5LTget_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, int *data); + +H5_HLDLL herr_t H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned int *data); + +H5_HLDLL herr_t H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data); + +H5_HLDLL herr_t H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, + long long *data); + +H5_HLDLL herr_t H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned long *data); + +H5_HLDLL herr_t H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, + float *data); + +H5_HLDLL herr_t H5LTget_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, + double *data); /*------------------------------------------------------------------------- * @@ -312,22 +195,10 @@ H5_HLDLL herr_t H5LTget_attribute_double( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5LTget_attribute_ndims(hid_t loc_id, const char *obj_name, const char *attr_name, int *rank); -H5_HLDLL herr_t H5LTget_attribute_ndims( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *rank ); - -H5_HLDLL herr_t H5LTget_attribute_info( hid_t loc_id, - const char *obj_name, - const char *attr_name, - hsize_t *dims, - H5T_class_t *type_class, - size_t *type_size ); - - - - +H5_HLDLL herr_t H5LTget_attribute_info(hid_t loc_id, const char *obj_name, const char *attr_name, + hsize_t *dims, H5T_class_t *type_class, size_t *type_size); /*------------------------------------------------------------------------- * @@ -336,10 +207,9 @@ H5_HLDLL herr_t H5LTget_attribute_info( hid_t loc_id, *------------------------------------------------------------------------- */ -H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type); +H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type); H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len); - /*------------------------------------------------------------------------- * * Utility functions @@ -347,7 +217,7 @@ H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LTfind_attribute( hid_t loc_id, const char *name ); +H5_HLDLL herr_t H5LTfind_attribute(hid_t loc_id, const char *name); H5_HLDLL htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid); @@ -365,4 +235,3 @@ H5_HLDLL hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flag #endif #endif - diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index f413bea..f397365 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -18,22 +18,21 @@ /* Packet Table private data */ -typedef struct -{ - hid_t dset_id; /* The ID of the dataset containing this table */ - hid_t type_id; /* The ID of the packet table's native datatype */ - hsize_t current_index; /* The index of the packet that get_next_packet will read next */ - hsize_t size; /* The number of packets currently contained in this table */ +typedef struct { + hid_t dset_id; /* The ID of the dataset containing this table */ + hid_t type_id; /* The ID of the packet table's native datatype */ + hsize_t current_index; /* The index of the packet that get_next_packet will read next */ + hsize_t size; /* The number of packets currently contained in this table */ } htbl_t; -static hsize_t H5PT_ptable_count = 0; +static hsize_t H5PT_ptable_count = 0; static H5I_type_t H5PT_ptable_id_type = H5I_UNINIT; #define H5PT_HASH_TABLE_SIZE 64 /* Packet Table private functions */ static herr_t H5PT_free_id(void *id); -static herr_t H5PT_close( htbl_t* table ); +static herr_t H5PT_close(htbl_t *table); static herr_t H5PT_create_index(htbl_t *table_id); static herr_t H5PT_set_index(htbl_t *table_id, hsize_t pt_index); static herr_t H5PT_get_index(htbl_t *table_id, hsize_t *pt_index); @@ -71,109 +70,105 @@ static herr_t H5PT_get_index(htbl_t *table_id, hsize_t *pt_index); * *------------------------------------------------------------------------- */ -hid_t H5PTcreate(hid_t loc_id, - const char *dset_name, - hid_t dtype_id, - hsize_t chunk_size, - hid_t plist_id) +hid_t +H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, hid_t plist_id) { - htbl_t * table = NULL; - hid_t dset_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t plistcopy_id = H5I_INVALID_HID; - hsize_t dims[1]; - hsize_t dims_chunk[1]; - hsize_t maxdims[1]; - hid_t ret_value = H5I_INVALID_HID; - - /* check the arguments */ - if (dset_name == NULL) { - goto error; - } - - /* Register the packet table ID type if this is the first table created */ - if(H5PT_ptable_id_type < 0) - if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) - goto error; - - /* Get memory for the table identifier */ - table = (htbl_t *)HDmalloc(sizeof(htbl_t)); - if ( table == NULL ) { - goto error; - } - table->dset_id = H5I_INVALID_HID; - table->type_id = H5I_INVALID_HID; - - /* Create a simple data space with unlimited size */ - dims[0] = 0; - dims_chunk[0] = chunk_size; - maxdims[0] = H5S_UNLIMITED; - if((space_id = H5Screate_simple(1, dims, maxdims)) < 0) - goto error; - - /* Modify dataset creation properties to enable chunking */ - if (plist_id == H5P_DEFAULT) { - plistcopy_id = H5Pcreate(H5P_DATASET_CREATE); - } - else { - plistcopy_id = H5Pcopy(plist_id); - } - if (chunk_size > 0) - { - if(H5Pset_chunk(plistcopy_id, 1, dims_chunk) < 0) - goto error; - } - - /* Create the dataset. */ - if((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plistcopy_id, H5P_DEFAULT)) < 0) - goto error; - - /* Create the table identifier */ - table->dset_id = dset_id; - - /* Terminate access to the data space. */ - if(H5Sclose(space_id) < 0) - goto error; - - /* End access to the property list */ - if(H5Pclose(plistcopy_id) < 0) - goto error; - - /* Make a copy of caller's datatype and save it in the table structure. - It will be closed when the table is closed */ - if((table->type_id = H5Tcopy(dtype_id)) < 0) - goto error; - - H5PT_create_index(table); - table->size = 0; - - /* Get an ID for this table */ - ret_value = H5Iregister(H5PT_ptable_id_type, table); - if(ret_value != H5I_INVALID_HID) - H5PT_ptable_count++; - else - H5PT_close(table); - - return ret_value; + htbl_t *table = NULL; + hid_t dset_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t plistcopy_id = H5I_INVALID_HID; + hsize_t dims[1]; + hsize_t dims_chunk[1]; + hsize_t maxdims[1]; + hid_t ret_value = H5I_INVALID_HID; + + /* check the arguments */ + if (dset_name == NULL) { + goto error; + } + + /* Register the packet table ID type if this is the first table created */ + if (H5PT_ptable_id_type < 0) + if ((H5PT_ptable_id_type = + H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + goto error; + + /* Get memory for the table identifier */ + table = (htbl_t *)HDmalloc(sizeof(htbl_t)); + if (table == NULL) { + goto error; + } + table->dset_id = H5I_INVALID_HID; + table->type_id = H5I_INVALID_HID; + + /* Create a simple data space with unlimited size */ + dims[0] = 0; + dims_chunk[0] = chunk_size; + maxdims[0] = H5S_UNLIMITED; + if ((space_id = H5Screate_simple(1, dims, maxdims)) < 0) + goto error; + + /* Modify dataset creation properties to enable chunking */ + if (plist_id == H5P_DEFAULT) { + plistcopy_id = H5Pcreate(H5P_DATASET_CREATE); + } + else { + plistcopy_id = H5Pcopy(plist_id); + } + if (chunk_size > 0) { + if (H5Pset_chunk(plistcopy_id, 1, dims_chunk) < 0) + goto error; + } + + /* Create the dataset. */ + if ((dset_id = + H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plistcopy_id, H5P_DEFAULT)) < 0) + goto error; + + /* Create the table identifier */ + table->dset_id = dset_id; + + /* Terminate access to the data space. */ + if (H5Sclose(space_id) < 0) + goto error; + + /* End access to the property list */ + if (H5Pclose(plistcopy_id) < 0) + goto error; + + /* Make a copy of caller's datatype and save it in the table structure. + It will be closed when the table is closed */ + if ((table->type_id = H5Tcopy(dtype_id)) < 0) + goto error; + + H5PT_create_index(table); + table->size = 0; + + /* Get an ID for this table */ + ret_value = H5Iregister(H5PT_ptable_id_type, table); + if (ret_value != H5I_INVALID_HID) + H5PT_ptable_count++; + else + H5PT_close(table); + + return ret_value; error: if (space_id != H5I_INVALID_HID) - H5Sclose(space_id); + H5Sclose(space_id); if (plistcopy_id != H5I_INVALID_HID) - H5Pclose(plistcopy_id); + H5Pclose(plistcopy_id); if (dset_id != H5I_INVALID_HID) - H5Dclose(dset_id); - if (table) - { + H5Dclose(dset_id); + if (table) { if (table->type_id != H5I_INVALID_HID) - H5Tclose(table->type_id); - HDfree(table); + H5Tclose(table->type_id); + HDfree(table); } return ret_value; } /* H5PTcreate */ - /*------------------------------------------------------------------------- * Function: H5PTcreate_fl * @@ -196,98 +191,95 @@ error: *------------------------------------------------------------------------- */ -hid_t H5PTcreate_fl ( hid_t loc_id, - const char *dset_name, - hid_t dtype_id, - hsize_t chunk_size, - int compression ) +hid_t +H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, int compression) { - htbl_t * table = NULL; - hid_t dset_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t plist_id = H5I_INVALID_HID; - hsize_t dims[1]; - hsize_t dims_chunk[1]; - hsize_t maxdims[1]; - hid_t ret_value = H5I_INVALID_HID; - - /* check the arguments */ - if (dset_name == NULL) { - goto error; - } - - /* Register the packet table ID type if this is the first table created */ - if(H5PT_ptable_id_type < 0) - if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) - goto error; - - /* Get memory for the table identifier */ - table = (htbl_t *)HDmalloc(sizeof(htbl_t)); - if ( table == NULL ) { - goto error; - } - table->dset_id = H5I_INVALID_HID; - table->type_id = H5I_INVALID_HID; - - /* Create a simple data space with unlimited size */ - dims[0] = 0; - dims_chunk[0] = chunk_size; - maxdims[0] = H5S_UNLIMITED; - if((space_id = H5Screate_simple(1, dims, maxdims)) < 0) - goto error; - - /* Modify dataset creation properties to enable chunking */ - plist_id = H5Pcreate(H5P_DATASET_CREATE); - if(H5Pset_chunk(plist_id, 1, dims_chunk) < 0) - goto error; - if(compression >= 0 && compression <= 9) - if(H5Pset_deflate(plist_id, (unsigned)compression) < 0) + htbl_t *table = NULL; + hid_t dset_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t plist_id = H5I_INVALID_HID; + hsize_t dims[1]; + hsize_t dims_chunk[1]; + hsize_t maxdims[1]; + hid_t ret_value = H5I_INVALID_HID; + + /* check the arguments */ + if (dset_name == NULL) { goto error; + } - /* Create the dataset. */ - if((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) - goto error; + /* Register the packet table ID type if this is the first table created */ + if (H5PT_ptable_id_type < 0) + if ((H5PT_ptable_id_type = + H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + goto error; - /* Create the table identifier */ - table->dset_id = dset_id; + /* Get memory for the table identifier */ + table = (htbl_t *)HDmalloc(sizeof(htbl_t)); + if (table == NULL) { + goto error; + } + table->dset_id = H5I_INVALID_HID; + table->type_id = H5I_INVALID_HID; + + /* Create a simple data space with unlimited size */ + dims[0] = 0; + dims_chunk[0] = chunk_size; + maxdims[0] = H5S_UNLIMITED; + if ((space_id = H5Screate_simple(1, dims, maxdims)) < 0) + goto error; - /* Terminate access to the data space. */ - if(H5Sclose(space_id) < 0) - goto error; + /* Modify dataset creation properties to enable chunking */ + plist_id = H5Pcreate(H5P_DATASET_CREATE); + if (H5Pset_chunk(plist_id, 1, dims_chunk) < 0) + goto error; + if (compression >= 0 && compression <= 9) + if (H5Pset_deflate(plist_id, (unsigned)compression) < 0) + goto error; - /* End access to the property list */ - if(H5Pclose(plist_id) < 0) - goto error; + /* Create the dataset. */ + if ((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) + goto error; - /* Make a copy of caller's datatype and save it in the table structure. - It will be closed when the table is closed */ - if((table->type_id = H5Tcopy(dtype_id)) < 0) - goto error; + /* Create the table identifier */ + table->dset_id = dset_id; - H5PT_create_index(table); - table->size = 0; + /* Terminate access to the data space. */ + if (H5Sclose(space_id) < 0) + goto error; + + /* End access to the property list */ + if (H5Pclose(plist_id) < 0) + goto error; + + /* Make a copy of caller's datatype and save it in the table structure. + It will be closed when the table is closed */ + if ((table->type_id = H5Tcopy(dtype_id)) < 0) + goto error; + + H5PT_create_index(table); + table->size = 0; - /* Get an ID for this table */ - ret_value = H5Iregister(H5PT_ptable_id_type, table); - if(ret_value != H5I_INVALID_HID) - H5PT_ptable_count++; - else - H5PT_close(table); + /* Get an ID for this table */ + ret_value = H5Iregister(H5PT_ptable_id_type, table); + if (ret_value != H5I_INVALID_HID) + H5PT_ptable_count++; + else + H5PT_close(table); - return ret_value; + return ret_value; error: if (space_id != H5I_INVALID_HID) - H5Sclose(space_id); + H5Sclose(space_id); if (plist_id != H5I_INVALID_HID) - H5Pclose(plist_id); + H5Pclose(plist_id); if (dset_id != H5I_INVALID_HID) - H5Dclose(dset_id); - if (table) - { + H5Dclose(dset_id); + if (table) { if (table->type_id != H5I_INVALID_HID) - H5Tclose(table->type_id); - HDfree(table); + H5Tclose(table->type_id); + HDfree(table); } return ret_value; @@ -317,87 +309,87 @@ error: * *------------------------------------------------------------------------- */ -hid_t H5PTopen( hid_t loc_id, - const char *dset_name ) +hid_t +H5PTopen(hid_t loc_id, const char *dset_name) { - hid_t type_id=H5I_INVALID_HID; - hid_t space_id=H5I_INVALID_HID; - htbl_t * table = NULL; - hsize_t dims[1]; - hid_t ret_value = H5I_INVALID_HID; - - /* check the arguments */ - if (dset_name == NULL) { - goto error; - } - - /* Register the packet table ID type if this is the first table created */ - if( H5PT_ptable_id_type < 0) - if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) - goto error; - - table = (htbl_t *)HDmalloc(sizeof(htbl_t)); - if ( table == NULL ) { - goto error; - } - table->dset_id = H5I_INVALID_HID; - table->type_id = H5I_INVALID_HID; - - /* Open the dataset */ - if((table->dset_id = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) - goto error; - - /* Get the dataset's disk datatype */ - if((type_id = H5Dget_type(table->dset_id)) < 0) - goto error; - - /* Make a copy of the datatype obtained and save it in the table structure. - It will be closed when the table is closed */ - if((table->type_id = H5Tcopy(type_id)) < 0) - goto error; - - /* Close the disk datatype */ - if(H5Tclose(type_id) < 0) - goto error; - type_id = H5I_INVALID_HID; - - /* Initialize the current record pointer */ - if((H5PT_create_index(table)) < 0) - goto error; - - /* Get number of records in table */ - if((space_id=H5Dget_space(table->dset_id)) < 0) - goto error; - if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) - goto error; - if(H5Sclose(space_id) < 0) - goto error; - space_id = H5I_INVALID_HID; - - table->size = dims[0]; - - /* Get an ID for this table */ - ret_value = H5Iregister(H5PT_ptable_id_type, table); - - if(ret_value != H5I_INVALID_HID) - H5PT_ptable_count++; - else - H5PT_close(table); - - return ret_value; + hid_t type_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + htbl_t *table = NULL; + hsize_t dims[1]; + hid_t ret_value = H5I_INVALID_HID; + + /* check the arguments */ + if (dset_name == NULL) { + goto error; + } + + /* Register the packet table ID type if this is the first table created */ + if (H5PT_ptable_id_type < 0) + if ((H5PT_ptable_id_type = + H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + goto error; + + table = (htbl_t *)HDmalloc(sizeof(htbl_t)); + if (table == NULL) { + goto error; + } + table->dset_id = H5I_INVALID_HID; + table->type_id = H5I_INVALID_HID; + + /* Open the dataset */ + if ((table->dset_id = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + goto error; + + /* Get the dataset's disk datatype */ + if ((type_id = H5Dget_type(table->dset_id)) < 0) + goto error; + + /* Make a copy of the datatype obtained and save it in the table structure. + It will be closed when the table is closed */ + if ((table->type_id = H5Tcopy(type_id)) < 0) + goto error; + + /* Close the disk datatype */ + if (H5Tclose(type_id) < 0) + goto error; + type_id = H5I_INVALID_HID; + + /* Initialize the current record pointer */ + if ((H5PT_create_index(table)) < 0) + goto error; + + /* Get number of records in table */ + if ((space_id = H5Dget_space(table->dset_id)) < 0) + goto error; + if (H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) + goto error; + if (H5Sclose(space_id) < 0) + goto error; + space_id = H5I_INVALID_HID; + + table->size = dims[0]; + + /* Get an ID for this table */ + ret_value = H5Iregister(H5PT_ptable_id_type, table); + + if (ret_value != H5I_INVALID_HID) + H5PT_ptable_count++; + else + H5PT_close(table); + + return ret_value; error: if (type_id != H5I_INVALID_HID) - H5Dclose(type_id); + H5Dclose(type_id); if (space_id != H5I_INVALID_HID) - H5Sclose(space_id); - if(table) - { + H5Sclose(space_id); + if (table) { if (table->type_id != H5I_INVALID_HID) - H5Tclose(table->type_id); - if (table->dset_id != H5I_INVALID_HID) - H5Dclose(table->dset_id); - HDfree(table); + H5Tclose(table->type_id); + if (table->dset_id != H5I_INVALID_HID) + H5Dclose(table->dset_id); + HDfree(table); } return ret_value; @@ -438,33 +430,32 @@ H5PT_free_id(void *id) *------------------------------------------------------------------------- */ static herr_t -H5PT_close( htbl_t* table) +H5PT_close(htbl_t *table) { - if(table == NULL) - goto error; + if (table == NULL) + goto error; - /* Close the dataset */ - if(H5Dclose(table->dset_id) < 0) - goto error; + /* Close the dataset */ + if (H5Dclose(table->dset_id) < 0) + goto error; - /* Close the memory datatype */ - if(H5Tclose(table->type_id) < 0) - goto error; + /* Close the memory datatype */ + if (H5Tclose(table->type_id) < 0) + goto error; - HDfree(table); + HDfree(table); - return SUCCEED; + return SUCCEED; error: - if(table) - { - H5E_BEGIN_TRY - H5Dclose(table->dset_id); - H5Tclose(table->type_id); - H5E_END_TRY - HDfree(table); - } - return FAIL; + if (table) { + H5E_BEGIN_TRY + H5Dclose(table->dset_id); + H5Tclose(table->type_id); + H5E_END_TRY + HDfree(table); + } + return FAIL; } /*------------------------------------------------------------------------- @@ -486,36 +477,35 @@ error: * *------------------------------------------------------------------------- */ -herr_t H5PTclose( hid_t table_id ) +herr_t +H5PTclose(hid_t table_id) { - htbl_t * table; + htbl_t *table; - /* Remove the ID from the library */ - if((table = (htbl_t *)H5Iremove_verify(table_id, H5PT_ptable_id_type)) ==NULL) - goto error; + /* Remove the ID from the library */ + if ((table = (htbl_t *)H5Iremove_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - /* If the library found the table, remove it */ - if( H5PT_close(table) < 0) - goto error; + /* If the library found the table, remove it */ + if (H5PT_close(table) < 0) + goto error; - /* One less packet table open */ - H5PT_ptable_count--; + /* One less packet table open */ + H5PT_ptable_count--; - /* Remove the packet table type ID if no more packet */ - /* tables are open */ - if(H5PT_ptable_count == 0) - { - H5Idestroy_type(H5PT_ptable_id_type); - H5PT_ptable_id_type = H5I_UNINIT; - } + /* Remove the packet table type ID if no more packet */ + /* tables are open */ + if (H5PT_ptable_count == 0) { + H5Idestroy_type(H5PT_ptable_id_type); + H5PT_ptable_id_type = H5I_UNINIT; + } - return SUCCEED; + return SUCCEED; error: - return FAIL; + return FAIL; } - /*------------------------------------------------------------------------- * * Write functions @@ -541,30 +531,28 @@ error: * *------------------------------------------------------------------------- */ -herr_t H5PTappend( hid_t table_id, - size_t nrecords, - const void * data ) +herr_t +H5PTappend(hid_t table_id, size_t nrecords, const void *data) { - htbl_t * table; + htbl_t *table; - /* Find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* Find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - /* If we are asked to write 0 records, just do nothing */ - if(nrecords == 0) - return SUCCEED; + /* If we are asked to write 0 records, just do nothing */ + if (nrecords == 0) + return SUCCEED; - if((H5TB_common_append_records(table->dset_id, table->type_id, - nrecords, table->size, data)) < 0) - goto error; + if ((H5TB_common_append_records(table->dset_id, table->type_id, nrecords, table->size, data)) < 0) + goto error; - /* Update table size */ - table->size += nrecords; - return SUCCEED; + /* Update table size */ + table->size += nrecords; + return SUCCEED; error: - return FAIL; + return FAIL; } /*------------------------------------------------------------------------- @@ -574,7 +562,6 @@ error: *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: H5PTget_next * @@ -595,30 +582,29 @@ error: * *------------------------------------------------------------------------- */ -herr_t H5PTget_next( hid_t table_id, - size_t nrecords, - void * data) +herr_t +H5PTget_next(hid_t table_id, size_t nrecords, void *data) { - htbl_t * table; + htbl_t *table; - /* Find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* Find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - /* If nrecords == 0, do nothing */ - if(nrecords == 0) - return SUCCEED; + /* If nrecords == 0, do nothing */ + if (nrecords == 0) + return SUCCEED; - if((H5TB_common_read_records(table->dset_id, table->type_id, - table->current_index, nrecords, table->size, data)) < 0) - goto error; + if ((H5TB_common_read_records(table->dset_id, table->type_id, table->current_index, nrecords, table->size, + data)) < 0) + goto error; - /* Update the current index */ - table->current_index += nrecords; - return SUCCEED; + /* Update the current index */ + table->current_index += nrecords; + return SUCCEED; error: - return FAIL; + return FAIL; } /*------------------------------------------------------------------------- @@ -640,30 +626,27 @@ error: * *------------------------------------------------------------------------- */ -herr_t H5PTread_packets( hid_t table_id, - hsize_t start, - size_t nrecords, - void *data) +herr_t +H5PTread_packets(hid_t table_id, hsize_t start, size_t nrecords, void *data) { - htbl_t * table; + htbl_t *table; - /* find the table struct from its ID */ - table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type); - if(table == NULL) - goto error; + /* find the table struct from its ID */ + table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type); + if (table == NULL) + goto error; - /* If nrecords == 0, do nothing */ - if(nrecords == 0) - return SUCCEED; + /* If nrecords == 0, do nothing */ + if (nrecords == 0) + return SUCCEED; - if( H5TB_common_read_records(table->dset_id, table->type_id, - start, nrecords, table->size, data) < 0) - goto error; + if (H5TB_common_read_records(table->dset_id, table->type_id, start, nrecords, table->size, data) < 0) + goto error; - return SUCCEED; + return SUCCEED; error: - return FAIL; + return FAIL; } /*------------------------------------------------------------------------- @@ -694,40 +677,36 @@ error: static herr_t H5PT_create_index(htbl_t *table) { - if( table != NULL) - { - table->current_index = 0; - return SUCCEED; - } - return FAIL; + if (table != NULL) { + table->current_index = 0; + return SUCCEED; + } + return FAIL; } static herr_t H5PT_set_index(htbl_t *table, hsize_t pt_index) { - /* Ensure index is valid */ - if( table != NULL ) - { - if( pt_index < table->size ) - { - table->current_index = pt_index; - return SUCCEED; + /* Ensure index is valid */ + if (table != NULL) { + if (pt_index < table->size) { + table->current_index = pt_index; + return SUCCEED; + } } - } - return FAIL; + return FAIL; } static herr_t H5PT_get_index(htbl_t *table, hsize_t *pt_index) { - /* Ensure index is valid */ - if( table != NULL ) - { - if(pt_index) - *pt_index = table->current_index; - return SUCCEED; - } - return FAIL; + /* Ensure index is valid */ + if (table != NULL) { + if (pt_index) + *pt_index = table->current_index; + return SUCCEED; + } + return FAIL; } /*------------------------------------------------------------------------- @@ -748,37 +727,40 @@ H5PT_get_index(htbl_t *table, hsize_t *pt_index) * *------------------------------------------------------------------------- */ -herr_t H5PTcreate_index(hid_t table_id) +herr_t +H5PTcreate_index(hid_t table_id) { - htbl_t * table; + htbl_t *table; - /* find the table struct from its ID */ - if((table = (htbl_t *) (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - return FAIL; + /* find the table struct from its ID */ + if ((table = (htbl_t *)(htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + return FAIL; - return H5PT_create_index(table); + return H5PT_create_index(table); } -herr_t H5PTset_index(hid_t table_id, hsize_t pt_index) +herr_t +H5PTset_index(hid_t table_id, hsize_t pt_index) { - htbl_t * table; + htbl_t *table; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - return FAIL; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + return FAIL; - return H5PT_set_index(table, pt_index); + return H5PT_set_index(table, pt_index); } -herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index) +herr_t +H5PTget_index(hid_t table_id, hsize_t *pt_index) { - htbl_t * table; + htbl_t *table; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - return FAIL; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + return FAIL; - return H5PT_get_index(table, pt_index); + return H5PT_get_index(table, pt_index); } /*------------------------------------------------------------------------- @@ -807,24 +789,24 @@ herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index) * *------------------------------------------------------------------------- */ -herr_t H5PTget_num_packets( hid_t table_id, hsize_t *nrecords) +herr_t +H5PTget_num_packets(hid_t table_id, hsize_t *nrecords) { - htbl_t * table; + htbl_t *table; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - if(nrecords) - *nrecords = table->size; + if (nrecords) + *nrecords = table->size; - return SUCCEED; + return SUCCEED; error: - return FAIL; + return FAIL; } - /*------------------------------------------------------------------------- * Function: H5PTis_valid * @@ -844,13 +826,14 @@ error: * *------------------------------------------------------------------------- */ -herr_t H5PTis_valid(hid_t table_id) +herr_t +H5PTis_valid(hid_t table_id) { - /* find the table struct from its ID */ - if(H5Iobject_verify(table_id, H5PT_ptable_id_type) ==NULL) - return FAIL; + /* find the table struct from its ID */ + if (H5Iobject_verify(table_id, H5PT_ptable_id_type) == NULL) + return FAIL; - return SUCCEED; + return SUCCEED; } /*------------------------------------------------------------------------- @@ -873,25 +856,26 @@ herr_t H5PTis_valid(hid_t table_id) * *------------------------------------------------------------------------- */ -herr_t H5PTis_varlen(hid_t table_id) +herr_t +H5PTis_varlen(hid_t table_id) { - H5T_class_t type; - htbl_t * table; + H5T_class_t type; + htbl_t * table; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - if((type = H5Tget_class( table->type_id )) == H5T_NO_CLASS) - goto error; + if ((type = H5Tget_class(table->type_id)) == H5T_NO_CLASS) + goto error; - if( type == H5T_VLEN ) - return 1; - else - return 0; + if (type == H5T_VLEN) + return 1; + else + return 0; error: - return FAIL; + return FAIL; } /*------------------------------------------------------------------------- @@ -923,38 +907,37 @@ error: *------------------------------------------------------------------------- */ -herr_t H5PTfree_vlen_buff( hid_t table_id, - size_t _bufflen, - void * buff ) +herr_t +H5PTfree_vlen_buff(hid_t table_id, size_t _bufflen, void *buff) { - hid_t space_id = H5I_INVALID_HID; - htbl_t * table; - hsize_t bufflen = _bufflen; - herr_t ret_value; + hid_t space_id = H5I_INVALID_HID; + htbl_t *table; + hsize_t bufflen = _bufflen; + herr_t ret_value; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - if((space_id = H5Screate_simple(1, &bufflen, NULL)) < 0) - goto error; + if ((space_id = H5Screate_simple(1, &bufflen, NULL)) < 0) + goto error; - /* Free the memory. If this succeeds, ret_value should be 0. */ - if((ret_value = H5Treclaim(table->type_id, space_id, H5P_DEFAULT, buff)) < 0) - goto error; + /* Free the memory. If this succeeds, ret_value should be 0. */ + if ((ret_value = H5Treclaim(table->type_id, space_id, H5P_DEFAULT, buff)) < 0) + goto error; - /* If the dataspace cannot be closed, return -2 to indicate that memory */ - /* was freed successfully but an error still occurred. */ - if(H5Sclose(space_id) < 0) - return -2; + /* If the dataspace cannot be closed, return -2 to indicate that memory */ + /* was freed successfully but an error still occurred. */ + if (H5Sclose(space_id) < 0) + return -2; - return ret_value; + return ret_value; error: - H5E_BEGIN_TRY + H5E_BEGIN_TRY H5Sclose(space_id); - H5E_END_TRY - return FAIL; + H5E_END_TRY + return FAIL; } /* H5PTfree_vlen_buff */ /*------------------------------------------------------------------------- @@ -981,20 +964,21 @@ error: * *------------------------------------------------------------------------- */ -hid_t H5PTget_dataset(hid_t table_id) +hid_t +H5PTget_dataset(hid_t table_id) { - htbl_t * table; - hid_t ret_value = H5I_INVALID_HID; + htbl_t *table; + hid_t ret_value = H5I_INVALID_HID; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - ret_value = table->dset_id; + ret_value = table->dset_id; error: - return ret_value; + return ret_value; } /*------------------------------------------------------------------------- @@ -1015,18 +999,19 @@ error: * *------------------------------------------------------------------------- */ -hid_t H5PTget_type( hid_t table_id) +hid_t +H5PTget_type(hid_t table_id) { - htbl_t * table; - hid_t ret_value = H5I_INVALID_HID; + htbl_t *table; + hid_t ret_value = H5I_INVALID_HID; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - ret_value = table->type_id; + ret_value = table->type_id; error: - return ret_value; + return ret_value; } diff --git a/hl/src/H5PTprivate.h b/hl/src/H5PTprivate.h index eec9df7..18ea3c2 100644 --- a/hl/src/H5PTprivate.h +++ b/hl/src/H5PTprivate.h @@ -21,4 +21,3 @@ #include "H5PTpublic.h" #endif - diff --git a/hl/src/H5PTpublic.h b/hl/src/H5PTpublic.h index 8a12c8c..a94e81c 100644 --- a/hl/src/H5PTpublic.h +++ b/hl/src/H5PTpublic.h @@ -14,7 +14,6 @@ #ifndef _H5PTpublic_H #define _H5PTpublic_H - #ifdef __cplusplus extern "C" { #endif @@ -25,17 +24,16 @@ extern "C" { */ /* NOTE: H5PTcreate is replacing H5PTcreate_fl for better name due to the removal of H5PTcreate_vl. H5PTcreate_fl may be retired in 1.8.19. */ -H5_HLDLL hid_t H5PTcreate(hid_t loc_id, const char *dset_name, - hid_t dtype_id, hsize_t chunk_size, hid_t plist_id); +H5_HLDLL hid_t H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, + hid_t plist_id); H5_HLDLL hid_t H5PTopen(hid_t loc_id, const char *dset_name); H5_HLDLL herr_t H5PTclose(hid_t table_id); /* This function may be removed from the packet table in release 1.8.19. */ -H5_HLDLL hid_t H5PTcreate_fl(hid_t loc_id, const char *dset_name, - hid_t dtype_id, hsize_t chunk_size, int compression); - +H5_HLDLL hid_t H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, + int compression); /*------------------------------------------------------------------------- * Write functions @@ -47,10 +45,9 @@ H5_HLDLL herr_t H5PTappend(hid_t table_id, size_t nrecords, const void *data); * Read functions *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5PTget_next(hid_t table_id, size_t nrecords, void * data); +H5_HLDLL herr_t H5PTget_next(hid_t table_id, size_t nrecords, void *data); -H5_HLDLL herr_t H5PTread_packets(hid_t table_id, hsize_t start, - size_t nrecords, void *data); +H5_HLDLL herr_t H5PTread_packets(hid_t table_id, hsize_t start, size_t nrecords, void *data); /*------------------------------------------------------------------------- * Inquiry functions @@ -80,13 +77,11 @@ H5_HLDLL hid_t H5PTget_type(hid_t table_id); *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5PTcreate_index( hid_t table_id ); +H5_HLDLL herr_t H5PTcreate_index(hid_t table_id); -H5_HLDLL herr_t H5PTset_index( hid_t table_id, - hsize_t pt_index ); +H5_HLDLL herr_t H5PTset_index(hid_t table_id, hsize_t pt_index); -H5_HLDLL herr_t H5PTget_index( hid_t table_id, - hsize_t *pt_index ); +H5_HLDLL herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index); /*------------------------------------------------------------------------- * @@ -95,13 +90,10 @@ H5_HLDLL herr_t H5PTget_index( hid_t table_id, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5PTfree_vlen_buff( hid_t table_id, - size_t bufflen, - void * buff ); +H5_HLDLL herr_t H5PTfree_vlen_buff(hid_t table_id, size_t bufflen, void *buff); #ifdef __cplusplus } #endif #endif - diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index c54c41f..5d51856 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -17,178 +17,160 @@ #include "H5LTprivate.h" #include "H5TBprivate.h" - /*------------------------------------------------------------------------- -* -* internal functions -* -*------------------------------------------------------------------------- -*/ - -static hbool_t H5TB_find_field(const char *field, - const char *field_list); - -static herr_t H5TB_attach_attributes(const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hid_t tid); - -static hid_t H5TB_create_type(hid_t loc_id, - const char *dset_name, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - hid_t ftype_id); + * + * internal functions + * + *------------------------------------------------------------------------- + */ + +static hbool_t H5TB_find_field(const char *field, const char *field_list); + +static herr_t H5TB_attach_attributes(const char *table_title, hid_t loc_id, const char *dset_name, + hsize_t nfields, hid_t tid); + +static hid_t H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, hid_t ftype_id); /*------------------------------------------------------------------------- -* -* Create functions -* -*------------------------------------------------------------------------- -*/ + * + * Create functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBmake_table -* -* Purpose: Make a table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* Quincey Koziol -* -* Date: January 17, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBmake_table(const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hsize_t nrecords, - size_t type_size, - const char *field_names[], - const size_t *field_offset, - const hid_t *field_types, - hsize_t chunk_size, - void *fill_data, - int compress, - const void *buf) + * Function: H5TBmake_table + * + * Purpose: Make a table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Quincey Koziol + * + * Date: January 17, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsize_t nfields, + hsize_t nrecords, size_t type_size, const char *field_names[], const size_t *field_offset, + const hid_t *field_types, hsize_t chunk_size, void *fill_data, int compress, const void *buf) { - hid_t did = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t plist_id = H5I_BADID; - hid_t attr_id = H5I_BADID; - hsize_t dims[1]; - hsize_t dims_chunk[1]; - hsize_t maxdims[1] = {H5S_UNLIMITED}; - char attr_name[255]; - char *member_name = NULL; - unsigned char *tmp_buf = NULL; - hsize_t i; - herr_t ret_val = -1; + hid_t did = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t mem_type_id = H5I_BADID; + hid_t plist_id = H5I_BADID; + hid_t attr_id = H5I_BADID; + hsize_t dims[1]; + hsize_t dims_chunk[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + char attr_name[255]; + char * member_name = NULL; + unsigned char *tmp_buf = NULL; + hsize_t i; + herr_t ret_val = -1; /* check the arguments */ if (table_title == NULL) { - goto out; + goto out; } if (dset_name == NULL) { - goto out; + goto out; } if (field_names == NULL) { - goto out; + goto out; } dims[0] = nrecords; dims_chunk[0] = chunk_size; /* create the memory data type. */ - if((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; /* insert fields. */ - for(i = 0; i < nfields; i++) - if(H5Tinsert(mem_type_id, field_names[i], field_offset[i], field_types[i] ) < 0) + for (i = 0; i < nfields; i++) + if (H5Tinsert(mem_type_id, field_names[i], field_offset[i], field_types[i]) < 0) goto out; /* create a simple data space with unlimited size */ - if((sid = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* modify dataset creation properties, i.e. enable chunking */ - if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_chunk(plist_id, 1, dims_chunk) < 0) + if (H5Pset_chunk(plist_id, 1, dims_chunk) < 0) goto out; /* set the fill value using a struct as the data type. */ - if(fill_data) - if(H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0) + if (fill_data) + if (H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0) goto out; /* dataset creation property list is modified to use GZIP compression with the compression effort set to 6. */ - if(compress) - if(H5Pset_deflate(plist_id, 6) < 0) + if (compress) + if (H5Pset_deflate(plist_id, 6) < 0) goto out; /* create the dataset. */ - if((did = H5Dcreate2(loc_id, dset_name, mem_type_id, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, dset_name, mem_type_id, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) goto out; /* only write if there is something to write */ - if(buf) - if(H5Dwrite(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (buf) + if (H5Dwrite(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* terminate access to the data space. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; sid = H5I_BADID; /* end access to the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; did = H5I_BADID; /* end access to the property list */ - if(H5Pclose(plist_id) < 0) + if (H5Pclose(plist_id) < 0) goto out; plist_id = H5I_BADID; /*------------------------------------------------------------------------- - * set the conforming table attributes - *------------------------------------------------------------------------- - */ + * set the conforming table attributes + *------------------------------------------------------------------------- + */ /* attach the CLASS attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0) goto out; /* attach the VERSION attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "VERSION", TABLE_VERSION) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "VERSION", TABLE_VERSION) < 0) goto out; /* attach the TITLE attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "TITLE", table_title) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "TITLE", table_title) < 0) goto out; /* attach the FIELD_ name attribute */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(mem_type_id, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(mem_type_id, (unsigned)i))) goto out; HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_NAME", (int)i); /* attach the attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0) goto out; H5free_memory(member_name); @@ -196,283 +178,269 @@ herr_t H5TBmake_table(const char *table_title, } /* end for */ /* attach the FIELD_ fill value attribute */ - if(fill_data) { + if (fill_data) { tmp_buf = (unsigned char *)fill_data; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); - if((attr_id = H5Acreate2(did, attr_name, field_types[i], sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did, attr_name, field_types[i], sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, field_types[i], tmp_buf + field_offset[i]) < 0) + if (H5Awrite(attr_id, field_types[i], tmp_buf + field_offset[i]) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; attr_id = H5I_BADID; } /* end for */ /* terminate access to the data space. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; sid = H5I_BADID; /* end access to the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; did = H5I_BADID; } /* end if */ /* release the datatype. */ - if(H5Tclose(mem_type_id) < 0) + if (H5Tclose(mem_type_id) < 0) goto out; mem_type_id = H5I_BADID; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(attr_id > 0) - if(H5Aclose(attr_id) < 0) + if (attr_id > 0) + if (H5Aclose(attr_id) < 0) ret_val = -1; - if(plist_id > 0) - if(H5Pclose(plist_id) < 0) + if (plist_id > 0) + if (H5Pclose(plist_id) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; return ret_val; } /* end H5TBmake_table() */ /*------------------------------------------------------------------------- -* -* Write functions -* -*------------------------------------------------------------------------- -*/ + * + * Write functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBappend_records -* -* Purpose: Appends records to a table -* -* Return: Success: 0, Failure: -1 -* -* Programmers: -* Pedro Vicente, pvn@ncsa.uiuc.edu -* Quincey Koziol -* -* Date: November 19, 2001 -* -* Comments: Uses memory offsets -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBappend_records(hid_t loc_id, - const char *dset_name, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf) + * Function: H5TBappend_records + * + * Purpose: Appends records to a table + * + * Return: Success: 0, Failure: -1 + * + * Programmers: + * Pedro Vicente, pvn@ncsa.uiuc.edu + * Quincey Koziol + * + * Date: November 19, 2001 + * + * Comments: Uses memory offsets + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBappend_records(hid_t loc_id, const char *dset_name, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hsize_t nrecords_orig; - hsize_t nfields; - herr_t ret_val = -1; + hid_t did = H5I_BADID; + hid_t tid = H5I_BADID; + hid_t mem_type_id = H5I_BADID; + hsize_t nrecords_orig; + hsize_t nfields; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* get the original number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatypes */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) goto out; /* append the records */ - if((H5TB_common_append_records(did, mem_type_id, (size_t)nrecords, nrecords_orig, buf)) < 0) + if ((H5TB_common_append_records(did, mem_type_id, (size_t)nrecords, nrecords_orig, buf)) < 0) goto out; ret_val = 0; out: - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBappend_records() */ /*------------------------------------------------------------------------- -* Function: H5TBwrite_records -* -* Purpose: Writes records -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 19, 2001 -* -* Comments: Uses memory offsets -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBwrite_records(hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf) + * Function: H5TBwrite_records + * + * Purpose: Writes records + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 19, 2001 + * + * Comments: Uses memory offsets + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBwrite_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t dims[1]; - herr_t ret_val = -1; + hid_t did = H5I_BADID; + hid_t tid = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; + hid_t mem_type_id = H5I_BADID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t dims[1]; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get records */ - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; - if(start + nrecords > dims[0]) + if (start + nrecords > dims[0]) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; ret_val = 0; out: - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBwrite_records() */ /*------------------------------------------------------------------------- -* Function: H5TBwrite_fields_name -* -* Purpose: Writes fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 21, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBwrite_fields_name(hid_t loc_id, - const char *dset_name, - const char *field_names, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf) + * Function: H5TBwrite_fields_name + * + * Purpose: Writes fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 21, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, hsize_t start, + hsize_t nrecords, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t write_type_id = H5I_BADID; + hid_t did = H5I_BADID; + hid_t tid = H5I_BADID; + hid_t write_type_id = H5I_BADID; hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t file_space_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; + hid_t nmtype_id = H5I_BADID; + hid_t m_sid = H5I_BADID; + hid_t file_space_id = H5I_BADID; + hid_t preserve_id = H5I_BADID; hssize_t nfields; hssize_t i, j; hsize_t count[1]; hsize_t offset[1]; - char *member_name = NULL; + char * member_name = NULL; size_t size_native; herr_t ret_val = -1; @@ -483,70 +451,70 @@ herr_t H5TBwrite_fields_name(hid_t loc_id, goto out; /* create xfer properties to preserve initialized data */ - if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; - if(H5Pset_preserve(preserve_id, 1) < 0) + if (H5Pset_preserve(preserve_id, 1) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* get the number of fields */ - if((nfields = H5Tget_nmembers(tid)) < 0) + if ((nfields = H5Tget_nmembers(tid)) < 0) goto out; /* create a write id */ - if((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; j = 0; /* iterate though the members */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) goto out; - if(H5TB_find_field(member_name, field_names)) { + if (H5TB_find_field(member_name, field_names)) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid, (unsigned)i)) < 0) goto out; /* convert to native type */ - if((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; /* adjust, if necessary */ - if(field_sizes[j] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[j]) < 0) + if (field_sizes[j] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[j]) < 0) goto out; /* the field in the file is found by its name */ - if(field_offset) { - if(H5Tinsert(write_type_id, member_name, field_offset[j], nmtype_id) < 0) + if (field_offset) { + if (H5Tinsert(write_type_id, member_name, field_offset[j], nmtype_id) < 0) goto out; } /* end if */ /* only one field */ else { - if(H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0) + if (H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0) goto out; } /* end else */ j++; /* close */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + if (H5Tclose(nmtype_id) < 0) goto out; nmtype_id = H5I_BADID; } /* end if */ @@ -556,156 +524,150 @@ herr_t H5TBwrite_fields_name(hid_t loc_id, } /* end for */ /* get the dataspace handle */ - if((file_space_id = H5Dget_space(did)) < 0) + if ((file_space_id = H5Dget_space(did)) < 0) goto out; - if((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* write */ - if(H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0) + if (H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0) goto out; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(preserve_id > 0) - if(H5Pclose(preserve_id) < 0) + if (preserve_id > 0) + if (H5Pclose(preserve_id) < 0) ret_val = -1; - if(write_type_id > 0) - if(H5Tclose(write_type_id) < 0) + if (write_type_id > 0) + if (H5Tclose(write_type_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(file_space_id > 0) - if(H5Sclose(file_space_id) < 0) + if (file_space_id > 0) + if (H5Sclose(file_space_id) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBwrite_fields_name() */ /*------------------------------------------------------------------------- -* Function: H5TBwrite_fields_index -* -* Purpose: Writes fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 21, 2001 -* -* Comments: Uses memory offsets -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBwrite_fields_index(hid_t loc_id, - const char *dset_name, - hsize_t nfields, - const int *field_index, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf) + * Function: H5TBwrite_fields_index + * + * Purpose: Writes fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 21, 2001 + * + * Comments: Uses memory offsets + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, const int *field_index, + hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t file_space_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t i; - size_t size_native; - char *member_name = NULL; - herr_t ret_val = -1; + hid_t did = H5I_BADID; + hid_t tid = H5I_BADID; + hid_t write_type_id = H5I_BADID; + hid_t member_type_id = H5I_BADID; + hid_t nmtype_id = H5I_BADID; + hid_t m_sid = H5I_BADID; + hid_t file_space_id = H5I_BADID; + hid_t preserve_id = H5I_BADID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t i; + size_t size_native; + char * member_name = NULL; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* create xfer properties to preserve initialized data */ - if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; - if(H5Pset_preserve(preserve_id, 1) < 0) + if (H5Pset_preserve(preserve_id, 1) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* create a write id */ - if((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; /* iterate tru the members */ - for(i = 0; i < nfields; i++) { - unsigned j; + for (i = 0; i < nfields; i++) { + unsigned j; /* Range check value */ - if(field_index[i] < 0) + if (field_index[i] < 0) goto out; j = (unsigned)field_index[i]; /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid, j))) + if (NULL == (member_name = H5Tget_member_name(tid, j))) goto out; /* get the member type */ - if((member_type_id = H5Tget_member_type(tid, j)) < 0) + if ((member_type_id = H5Tget_member_type(tid, j)) < 0) goto out; /* convert to native type */ - if((nmtype_id = H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; - if(field_sizes[i] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[i]) < 0) + if (field_sizes[i] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[i]) < 0) goto out; /* the field in the file is found by its name */ - if(field_offset) { - if(H5Tinsert(write_type_id, member_name, field_offset[i], nmtype_id) < 0) + if (field_offset) { + if (H5Tinsert(write_type_id, member_name, field_offset[i], nmtype_id) < 0) goto out; } /* end if */ /* only one field */ else { - if(H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0) + if (H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0) goto out; } /* end else */ /* close */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + if (H5Tclose(nmtype_id) < 0) goto out; nmtype_id = H5I_BADID; @@ -714,250 +676,236 @@ herr_t H5TBwrite_fields_index(hid_t loc_id, } /* end for */ /* get the dataspace handles */ - if((file_space_id = H5Dget_space(did)) < 0) + if ((file_space_id = H5Dget_space(did)) < 0) goto out; - if((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* write */ - if(H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0) + if (H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0) goto out; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(preserve_id > 0) - if(H5Pclose(preserve_id) < 0) + if (preserve_id > 0) + if (H5Pclose(preserve_id) < 0) ret_val = -1; - if(write_type_id > 0) - if(H5Tclose(write_type_id) < 0) + if (write_type_id > 0) + if (H5Tclose(write_type_id) < 0) ret_val = -1; - if(member_type_id > 0) - if(H5Tclose(member_type_id) < 0) + if (member_type_id > 0) + if (H5Tclose(member_type_id) < 0) ret_val = -1; - if(nmtype_id > 0) - if(H5Tclose(nmtype_id) < 0) + if (nmtype_id > 0) + if (H5Tclose(nmtype_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(file_space_id > 0) - if(H5Sclose(file_space_id) < 0) + if (file_space_id > 0) + if (H5Sclose(file_space_id) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBwrite_fields_index() */ - /*------------------------------------------------------------------------- -* -* Read functions -* -*------------------------------------------------------------------------- -*/ - + * + * Read functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBread_table -* -* Purpose: Reads a table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 20, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBread_table(hid_t loc_id, - const char *dset_name, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *dst_buf) + * Function: H5TBread_table + * + * Purpose: Reads a table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 20, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBread_table(hid_t loc_id, const char *dset_name, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, void *dst_buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t sid = H5I_BADID; - hsize_t dims[1]; - herr_t ret_val = -1; + hid_t did = H5I_BADID; + hid_t ftype_id = H5I_BADID; + hid_t mem_type_id = H5I_BADID; + hid_t sid = H5I_BADID; + hsize_t dims[1]; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get dimensions */ - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* get the datatypes */ - if((ftype_id = H5Dget_type (did)) < 0) + if ((ftype_id = H5Dget_type(did)) < 0) goto out; - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, ftype_id)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, ftype_id)) < + 0) goto out; /* read */ - if(H5Dread(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, dst_buf) < 0) + if (H5Dread(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, dst_buf) < 0) goto out; ret_val = 0; out: - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(ftype_id > 0) - if(H5Tclose(ftype_id) < 0) + if (ftype_id > 0) + if (H5Tclose(ftype_id) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBread_table() */ /*------------------------------------------------------------------------- -* Function: H5TBread_records -* -* Purpose: Reads records -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBread_records(hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf) + * Function: H5TBread_records + * + * Purpose: Reads records + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBread_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hsize_t nrecords_orig; - hsize_t nfields; - herr_t ret_val = -1; + hid_t did = H5I_BADID; + hid_t ftype_id = H5I_BADID; + hid_t mem_type_id = H5I_BADID; + hsize_t nrecords_orig; + hsize_t nfields; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) goto out; /* open the dataset */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatypes */ - if((ftype_id = H5Dget_type(did)) < 0) + if ((ftype_id = H5Dget_type(did)) < 0) goto out; - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, ftype_id)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, ftype_id)) < + 0) goto out; /* read the records */ - if((H5TB_common_read_records(did, mem_type_id, start, (size_t)nrecords, nrecords_orig, buf)) < 0) + if ((H5TB_common_read_records(did, mem_type_id, start, (size_t)nrecords, nrecords_orig, buf)) < 0) goto out; ret_val = 0; out: - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(ftype_id > 0) - if(H5Tclose(ftype_id) < 0) + if (ftype_id > 0) + if (H5Tclose(ftype_id) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBread_records() */ /*------------------------------------------------------------------------- -* Function: H5TBread_fields_name -* -* Purpose: Reads fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBread_fields_name(hid_t loc_id, - const char *dset_name, - const char *field_names, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf) + * Function: H5TBread_fields_name + * + * Purpose: Reads fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBread_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, hsize_t start, + hsize_t nrecords, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; + hid_t did = H5I_BADID; + hid_t ftype_id = H5I_BADID; hid_t mem_type_id = H5I_BADID; - hid_t mtype_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; + hid_t mtype_id = H5I_BADID; + hid_t nmtype_id = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; hssize_t nfields; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; size_t size_native; - char *member_name = NULL; + char * member_name = NULL; hssize_t i, j; herr_t ret_val = -1; - /* check the arguments */ if (dset_name == NULL) goto out; @@ -965,58 +913,58 @@ herr_t H5TBread_fields_name(hid_t loc_id, goto out; /* open the dataset */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((ftype_id = H5Dget_type(did)) < 0) + if ((ftype_id = H5Dget_type(did)) < 0) goto out; /* get the number of fields */ - if((nfields = H5Tget_nmembers(ftype_id)) < 0) + if ((nfields = H5Tget_nmembers(ftype_id)) < 0) goto out; /* create a memory read id */ - if((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; /* iterate through the members */ - for(i = 0, j = 0; i < nfields; i++) { + for (i = 0, j = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(ftype_id, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(ftype_id, (unsigned)i))) goto out; - if(H5TB_find_field(member_name, field_names)) { + if (H5TB_find_field(member_name, field_names)) { /* get the member type */ - if((mtype_id = H5Tget_member_type(ftype_id, (unsigned)i)) < 0) + if ((mtype_id = H5Tget_member_type(ftype_id, (unsigned)i)) < 0) goto out; /* convert to native type */ - if((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; - if(field_sizes[j] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[j]) < 0) + if (field_sizes[j] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[j]) < 0) goto out; /* the field in the file is found by its name */ - if(field_offset) { - if(H5Tinsert(mem_type_id, member_name, field_offset[j], nmtype_id) < 0) + if (field_offset) { + if (H5Tinsert(mem_type_id, member_name, field_offset[j], nmtype_id) < 0) goto out; } /* end if */ else { - if(H5Tinsert(mem_type_id, member_name, (size_t)0, nmtype_id) < 0) + if (H5Tinsert(mem_type_id, member_name, (size_t)0, nmtype_id) < 0) goto out; } /* end else */ /* close */ - if(H5Tclose(mtype_id) < 0) + if (H5Tclose(mtype_id) < 0) goto out; mtype_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + if (H5Tclose(nmtype_id) < 0) goto out; nmtype_id = H5I_BADID; j++; @@ -1027,159 +975,153 @@ herr_t H5TBread_fields_name(hid_t loc_id, } /* end for */ /* check to make sure field was found, no reason to continue if it does not exist */ - if(j == 0) - goto out; + if (j == 0) + goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; /* read */ - if(H5Dread(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dread(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(mtype_id > 0) - if(H5Tclose(mtype_id) < 0) + if (mtype_id > 0) + if (H5Tclose(mtype_id) < 0) ret_val = -1; - if(nmtype_id > 0) - if(H5Tclose(nmtype_id) < 0) + if (nmtype_id > 0) + if (H5Tclose(nmtype_id) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(ftype_id > 0) - if(H5Tclose(ftype_id) < 0) + if (ftype_id > 0) + if (H5Tclose(ftype_id) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBread_fields_name() */ /*------------------------------------------------------------------------- -* Function: H5TBread_fields_index -* -* Purpose: Reads fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBread_fields_index(hid_t loc_id, - const char *dset_name, - hsize_t nfields, - const int *field_index, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf) + * Function: H5TBread_fields_index + * + * Purpose: Reads fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, const int *field_index, + hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t read_type_id = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t i; - size_t size_native; - char *member_name = NULL; - herr_t ret_val = -1; + hid_t did = H5I_BADID; + hid_t tid = H5I_BADID; + hid_t read_type_id = H5I_BADID; + hid_t member_type_id = H5I_BADID; + hid_t nmtype_id = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t i; + size_t size_native; + char * member_name = NULL; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* create a read id */ - if((read_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((read_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; /* iterate tru the members */ - for(i = 0; i < nfields; i++) { - unsigned j; + for (i = 0; i < nfields; i++) { + unsigned j; /* Range check */ - if(field_index[i] < 0) + if (field_index[i] < 0) goto out; j = (unsigned)field_index[i]; /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)j))) + if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)j))) goto out; /* get the member type */ - if((member_type_id = H5Tget_member_type(tid, (unsigned)j)) < 0) + if ((member_type_id = H5Tget_member_type(tid, (unsigned)j)) < 0) goto out; /* convert to native type */ - if((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; - if(field_sizes[i] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[i]) < 0) + if (field_sizes[i] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[i]) < 0) goto out; /* the field in the file is found by its name */ - if(field_offset) { - if(H5Tinsert(read_type_id, member_name, field_offset[i], nmtype_id) < 0) + if (field_offset) { + if (H5Tinsert(read_type_id, member_name, field_offset[i], nmtype_id) < 0) goto out; } /* end if */ else { - if(H5Tinsert(read_type_id, member_name, (size_t)0, nmtype_id) < 0) + if (H5Tinsert(read_type_id, member_name, (size_t)0, nmtype_id) < 0) goto out; } /* end else */ /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + if (H5Tclose(nmtype_id) < 0) goto out; nmtype_id = H5I_BADID; @@ -1188,683 +1130,671 @@ herr_t H5TBread_fields_index(hid_t loc_id, } /* end for */ /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; /* read */ - if(H5Dread( did, read_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dread(did, read_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(read_type_id > 0) - if(H5Tclose(read_type_id) < 0) + if (read_type_id > 0) + if (H5Tclose(read_type_id) < 0) ret_val = -1; - if(member_type_id > 0) - if(H5Tclose(member_type_id) < 0) + if (member_type_id > 0) + if (H5Tclose(member_type_id) < 0) ret_val = -1; - if(nmtype_id > 0) - if(H5Tclose(nmtype_id) < 0) + if (nmtype_id > 0) + if (H5Tclose(nmtype_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBread_fields_index() */ - /*------------------------------------------------------------------------- -* -* Manipulation functions -* -*------------------------------------------------------------------------- -*/ + * + * Manipulation functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBdelete_record -* -* Purpose: Delete records from middle of table ("pulling up" all the records after it) -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 26, 2001 -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBdelete_record(hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords) + * Function: H5TBdelete_record + * + * Purpose: Delete records from middle of table ("pulling up" all the records after it) + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 26, 2001 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hsize_t nfields; - hsize_t ntotal_records; - hsize_t read_start; - hsize_t read_nrecords; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t dims[1]; - size_t src_size; - size_t *src_offset = NULL; - size_t *src_sizes = NULL; - unsigned char *tmp_buf = NULL; - herr_t ret_val = -1; - + hid_t did = H5I_BADID; + hid_t tid = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; + hid_t mem_type_id = H5I_BADID; + hsize_t nfields; + hsize_t ntotal_records; + hsize_t read_start; + hsize_t read_nrecords; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t dims[1]; + size_t src_size; + size_t * src_offset = NULL; + size_t * src_sizes = NULL; + unsigned char *tmp_buf = NULL; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /*------------------------------------------------------------------------- - * first we get information about type size and offsets on disk - *------------------------------------------------------------------------- - */ + * first we get information about type size and offsets on disk + *------------------------------------------------------------------------- + */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0) goto out; - if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; - if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id, dset_name, NULL, src_sizes, src_offset, &src_size) < 0) + if (H5TBget_field_info(loc_id, dset_name, NULL, src_sizes, src_offset, &src_size) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * read the records after the deleted one(s) - *------------------------------------------------------------------------- - */ + * read the records after the deleted one(s) + *------------------------------------------------------------------------- + */ - read_start = start + nrecords; + read_start = start + nrecords; read_nrecords = ntotal_records - read_start; - if(read_nrecords) { - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, src_size))) + if (read_nrecords) { + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, src_size))) goto out; /* read the records after the deleted one(s) */ - if(H5TBread_records(loc_id, dset_name, read_start, read_nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) + if (H5TBread_records(loc_id, dset_name, read_start, read_nrecords, src_size, src_offset, src_sizes, + tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * write the records in another position - *------------------------------------------------------------------------- - */ + * write the records in another position + *------------------------------------------------------------------------- + */ /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; - /* create the memory data type. */ - if((mem_type_id = H5TB_create_type( loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 0) - goto out; + /* create the memory data type. */ + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 0) + goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = read_nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) goto out; /* close */ - if(H5Sclose(m_sid) < 0) + if (H5Sclose(m_sid) < 0) goto out; m_sid = H5I_BADID; - if(H5Tclose(mem_type_id) < 0) - goto out; + if (H5Tclose(mem_type_id) < 0) + goto out; mem_type_id = H5I_BADID; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; sid = H5I_BADID; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; tid = H5I_BADID; } /* read_nrecords */ /*------------------------------------------------------------------------- - * change the dataset dimension - *------------------------------------------------------------------------- - */ + * change the dataset dimension + *------------------------------------------------------------------------- + */ dims[0] = ntotal_records - nrecords; - if(H5Dset_extent(did, dims) < 0) + if (H5Dset_extent(did, dims) < 0) goto out; ret_val = 0; out: - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(src_offset) + if (src_offset) HDfree(src_offset); - if(src_sizes) + if (src_sizes) HDfree(src_sizes); - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBdelete_record() */ /*------------------------------------------------------------------------- -* Function: H5TBinsert_record -* -* Purpose: Inserts records into middle of table ("pushing down" all the records after it) -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 26, 2001 -* -* Comments: Uses memory offsets -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBinsert_record(hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf) + * Function: H5TBinsert_record + * + * Purpose: Inserts records into middle of table ("pushing down" all the records after it) + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 26, 2001 + * + * Comments: Uses memory offsets + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBinsert_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t nfields; - hsize_t ntotal_records; - hsize_t read_nrecords; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t dims[1]; - hsize_t mem_dims[1]; + hid_t did = H5I_BADID; + hid_t tid = H5I_BADID; + hid_t mem_type_id = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; + hsize_t nfields; + hsize_t ntotal_records; + hsize_t read_nrecords; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t dims[1]; + hsize_t mem_dims[1]; unsigned char *tmp_buf = NULL; - herr_t ret_val = -1; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /*------------------------------------------------------------------------- - * read the records after the inserted one(s) - *------------------------------------------------------------------------- - */ + * read the records after the inserted one(s) + *------------------------------------------------------------------------- + */ /* get the dimensions */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* create the memory data type. */ - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) goto out; read_nrecords = ntotal_records - start; - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t) read_nrecords, type_size))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, type_size))) goto out; /* read the records after the inserted one(s) */ - if(H5TBread_records(loc_id, dset_name, start, read_nrecords, type_size, field_offset, field_sizes, tmp_buf) < 0) + if (H5TBread_records(loc_id, dset_name, start, read_nrecords, type_size, field_offset, field_sizes, + tmp_buf) < 0) goto out; /* extend the dataset */ dims[0] = ntotal_records + nrecords; - if(H5Dset_extent(did, dims) < 0) + if (H5Dset_extent(did, dims) < 0) goto out; /*------------------------------------------------------------------------- - * write the inserted records - *------------------------------------------------------------------------- - */ + * write the inserted records + *------------------------------------------------------------------------- + */ /* create a simple memory data space */ mem_dims[0] = nrecords; - if((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) goto out; /* get the file data space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* define a hyperslab in the dataset to write the new data */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; /* terminate access to the dataspace */ - if(H5Sclose(m_sid) < 0) + if (H5Sclose(m_sid) < 0) goto out; m_sid = H5I_BADID; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; sid = H5I_BADID; /*------------------------------------------------------------------------- - * write the "pushed down" records - *------------------------------------------------------------------------- - */ + * write the "pushed down" records + *------------------------------------------------------------------------- + */ /* create a simple memory data space */ mem_dims[0] = read_nrecords; - if((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) goto out; /* get the file data space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* define a hyperslab in the dataset to write the new data */ offset[0] = start + nrecords; count[0] = read_nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) goto out; ret_val = 0; out: - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBinsert_record() */ /*------------------------------------------------------------------------- -* Function: H5TBadd_records_from -* -* Purpose: Add records from first table to second table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: December 5, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBadd_records_from(hid_t loc_id, - const char *dset_name1, - hsize_t start1, - hsize_t nrecords, - const char *dset_name2, - hsize_t start2) + * Function: H5TBadd_records_from + * + * Purpose: Add records from first table to second table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: December 5, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBadd_records_from(hid_t loc_id, const char *dset_name1, hsize_t start1, hsize_t nrecords, + const char *dset_name2, hsize_t start2) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t nfields; - hsize_t ntotal_records; - size_t type_size1; - size_t src_size; - size_t *src_offset = NULL; - size_t *src_sizes = NULL; - unsigned char *tmp_buf = NULL; - herr_t ret_val = -1; + hid_t did = H5I_BADID; + hid_t tid = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t nfields; + hsize_t ntotal_records; + size_t type_size1; + size_t src_size; + size_t * src_offset = NULL; + size_t * src_sizes = NULL; + unsigned char *tmp_buf = NULL; + herr_t ret_val = -1; /* check the arguments */ if (dset_name1 == NULL) - goto out; + goto out; if (dset_name2 == NULL) - goto out; + goto out; /*------------------------------------------------------------------------- - * first we get information about type size and offsets on disk - *------------------------------------------------------------------------- - */ + * first we get information about type size and offsets on disk + *------------------------------------------------------------------------- + */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name1, &nfields, &ntotal_records) < 0) + if (H5TBget_table_info(loc_id, dset_name1, &nfields, &ntotal_records) < 0) goto out; - if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; - if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0) + if (H5TBget_field_info(loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0) goto out; /*------------------------------------------------------------------------- - * Get information about the first table and read it - *------------------------------------------------------------------------- - */ + * Get information about the first table and read it + *------------------------------------------------------------------------- + */ /* open the 1st dataset. */ - if((did = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get the size of the datatype */ - if(0 == (type_size1 = H5Tget_size(tid))) + if (0 == (type_size1 = H5Tget_size(tid))) goto out; - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size1))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size1))) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = start1; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread(did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * add to the second table - *------------------------------------------------------------------------- - */ - if(H5TBinsert_record(loc_id, dset_name2, start2, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) + * add to the second table + *------------------------------------------------------------------------- + */ + if (H5TBinsert_record(loc_id, dset_name2, start2, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) goto out; ret_val = 0; out: - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(src_offset) + if (src_offset) HDfree(src_offset); - if(src_sizes) + if (src_sizes) HDfree(src_sizes); - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBadd_records_from() */ /*------------------------------------------------------------------------- -* Function: H5TBcombine_tables -* -* Purpose: Combine records from two tables into a third -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: December 10, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBcombine_tables(hid_t loc_id1, - const char *dset_name1, - hid_t loc_id2, - const char *dset_name2, - const char *dset_name3) + * Function: H5TBcombine_tables + * + * Purpose: Combine records from two tables into a third + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: December 10, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2, const char *dset_name2, + const char *dset_name3) { /* identifiers for the 1st dataset. */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; + hid_t did_1 = H5I_BADID; + hid_t tid_1 = H5I_BADID; + hid_t sid_1 = H5I_BADID; + hid_t pid_1 = H5I_BADID; /* identifiers for the 2nd dataset. */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; + hid_t did_2 = H5I_BADID; + hid_t tid_2 = H5I_BADID; + hid_t sid_2 = H5I_BADID; + hid_t pid_2 = H5I_BADID; /* identifiers for the 3rd dataset. */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t sid_3 = H5I_BADID; - hid_t pid_3 = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t attr_id = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t nfields; - hsize_t nrecords; - hsize_t dims[1]; - hsize_t maxdims[1] = {H5S_UNLIMITED}; - hsize_t i; - size_t type_size; - size_t member_offset; - size_t src_size; - size_t *src_offset = NULL; - size_t *src_sizes = NULL; - char attr_name[255]; - unsigned char *tmp_buf = NULL; + hid_t did_3 = H5I_BADID; + hid_t tid_3 = H5I_BADID; + hid_t sid_3 = H5I_BADID; + hid_t pid_3 = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; + hid_t member_type_id = H5I_BADID; + hid_t attr_id = H5I_BADID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t nfields; + hsize_t nrecords; + hsize_t dims[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t i; + size_t type_size; + size_t member_offset; + size_t src_size; + size_t * src_offset = NULL; + size_t * src_sizes = NULL; + char attr_name[255]; + unsigned char *tmp_buf = NULL; unsigned char *tmp_fill_buf = NULL; - htri_t has_fill; - herr_t ret_val = -1; + htri_t has_fill; + herr_t ret_val = -1; /* check the arguments */ if (dset_name1 == NULL) - goto out; + goto out; if (dset_name2 == NULL) - goto out; + goto out; if (dset_name3 == NULL) - goto out; + goto out; /*------------------------------------------------------------------------- - * first we get information about type size and offsets on disk - *------------------------------------------------------------------------- - */ + * first we get information about type size and offsets on disk + *------------------------------------------------------------------------- + */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0) goto out; - if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; - if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0) + if (H5TBget_field_info(loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0) goto out; /*------------------------------------------------------------------------- - * get information about the first table - *------------------------------------------------------------------------- - */ + * get information about the first table + *------------------------------------------------------------------------- + */ /* open the 1st dataset. */ - if((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0) + if ((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid_1 = H5Dget_type(did_1)) < 0) + if ((tid_1 = H5Dget_type(did_1)) < 0) goto out; /* get the dataspace handle */ - if((sid_1 = H5Dget_space(did_1)) < 0) + if ((sid_1 = H5Dget_space(did_1)) < 0) goto out; /* get creation properties list */ - if((pid_1 = H5Dget_create_plist(did_1)) < 0) + if ((pid_1 = H5Dget_create_plist(did_1)) < 0) goto out; /* get the dimensions */ - if(H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0) goto out; /*------------------------------------------------------------------------- - * make the merged table with no data originally - *------------------------------------------------------------------------- - */ + * make the merged table with no data originally + *------------------------------------------------------------------------- + */ /* clone the property list */ - if((pid_3 = H5Pcopy(pid_1)) < 0) + if ((pid_3 = H5Pcopy(pid_1)) < 0) goto out; /* clone the type id */ - if((tid_3 = H5Tcopy(tid_1)) < 0) + if ((tid_3 = H5Tcopy(tid_1)) < 0) goto out; /*------------------------------------------------------------------------- - * here we do not clone the file space from the 1st dataset, because we want to create - * an empty table. Instead we create a new dataspace with zero records and expandable. - *------------------------------------------------------------------------- - */ + * here we do not clone the file space from the 1st dataset, because we want to create + * an empty table. Instead we create a new dataspace with zero records and expandable. + *------------------------------------------------------------------------- + */ dims[0] = 0; /* create a simple data space with unlimited size */ - if((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* create the dataset */ - if((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0) + if ((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * attach the conforming table attributes - *------------------------------------------------------------------------- - */ - if(H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0) + * attach the conforming table attributes + *------------------------------------------------------------------------- + */ + if (H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0) goto out; /*------------------------------------------------------------------------- - * get attributes - *------------------------------------------------------------------------- - */ - if(0 == (type_size = H5Tget_size(tid_3))) + * get attributes + *------------------------------------------------------------------------- + */ + if (0 == (type_size = H5Tget_size(tid_3))) goto out; /* alloc fill value attribute buffer */ - if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(type_size))) + if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(type_size))) goto out; /* get the fill value attributes */ - if((has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf)) < 0) + if ((has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf)) < 0) goto out; /*------------------------------------------------------------------------- - * attach the fill attributes from previous table - *------------------------------------------------------------------------- - */ - if(has_fill) { - if((sid = H5Screate(H5S_SCALAR)) < 0) + * attach the fill attributes from previous table + *------------------------------------------------------------------------- + */ + if (has_fill) { + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) goto out; /* get the member offset */ @@ -1872,249 +1802,245 @@ herr_t H5TBcombine_tables(hid_t loc_id1, HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); - if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; attr_id = H5I_BADID; - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; } /* end for */ /* close data space. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; sid = H5I_BADID; } /* end if */ /*------------------------------------------------------------------------- - * read data from 1st table - *------------------------------------------------------------------------- - */ - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size))) + * read data from 1st table + *------------------------------------------------------------------------- + */ + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size))) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; - if(H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread(did_1, tid_1, m_sid, sid_1, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did_1, tid_1, m_sid, sid_1, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * save data from 1st table into new table - *------------------------------------------------------------------------- - */ + * save data from 1st table into new table + *------------------------------------------------------------------------- + */ /* append the records to the new table */ - if(H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) + if (H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * release temporary resources - *------------------------------------------------------------------------- - */ - if(H5Sclose(m_sid) < 0) + * release temporary resources + *------------------------------------------------------------------------- + */ + if (H5Sclose(m_sid) < 0) goto out; m_sid = H5I_BADID; HDfree(tmp_buf); tmp_buf = NULL; /*------------------------------------------------------------------------- - * get information about the 2nd table - *------------------------------------------------------------------------- - */ + * get information about the 2nd table + *------------------------------------------------------------------------- + */ /* open the dataset. */ - if((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0) + if ((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid_2 = H5Dget_type(did_2)) < 0) + if ((tid_2 = H5Dget_type(did_2)) < 0) goto out; /* get the dataspace handle */ - if((sid_2 = H5Dget_space(did_2)) < 0) + if ((sid_2 = H5Dget_space(did_2)) < 0) goto out; /* get the property list handle */ - if((pid_2 = H5Dget_create_plist(did_2)) < 0) + if ((pid_2 = H5Dget_create_plist(did_2)) < 0) goto out; /* get the dimensions */ - if(H5TBget_table_info(loc_id2, dset_name2, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id2, dset_name2, &nfields, &nrecords) < 0) goto out; /*------------------------------------------------------------------------- - * read data from 2nd table - *------------------------------------------------------------------------- - */ + * read data from 2nd table + *------------------------------------------------------------------------- + */ - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size))) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; - if(H5Sselect_hyperslab(sid_2, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid_2, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread(did_2, tid_2, m_sid, sid_2, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did_2, tid_2, m_sid, sid_2, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * save data from 2nd table into new table - *------------------------------------------------------------------------- - */ + * save data from 2nd table into new table + *------------------------------------------------------------------------- + */ /* append the records to the new table */ - if(H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) + if (H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) goto out; ret_val = 0; out: - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(tmp_fill_buf) + if (tmp_fill_buf) HDfree(tmp_fill_buf); - if(src_offset) + if (src_offset) HDfree(src_offset); - if(src_sizes) + if (src_sizes) HDfree(src_sizes); - if(member_type_id > 0) - if(H5Tclose(member_type_id) < 0) + if (member_type_id > 0) + if (H5Tclose(member_type_id) < 0) ret_val = -1; - if(attr_id > 0) - if(H5Aclose(attr_id) < 0) + if (attr_id > 0) + if (H5Aclose(attr_id) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid_1 > 0) - if(H5Sclose(sid_1) < 0) + if (sid_1 > 0) + if (H5Sclose(sid_1) < 0) ret_val = -1; - if(tid_1 > 0) - if(H5Tclose(tid_1) < 0) + if (tid_1 > 0) + if (H5Tclose(tid_1) < 0) ret_val = -1; - if(pid_1 > 0) - if(H5Pclose(pid_1) < 0) + if (pid_1 > 0) + if (H5Pclose(pid_1) < 0) ret_val = -1; - if(did_1 > 0) - if(H5Dclose(did_1) < 0) + if (did_1 > 0) + if (H5Dclose(did_1) < 0) ret_val = -1; - if(sid_2 > 0) - if(H5Sclose(sid_2) < 0) + if (sid_2 > 0) + if (H5Sclose(sid_2) < 0) ret_val = -1; - if(tid_2 > 0) - if(H5Tclose(tid_2) < 0) + if (tid_2 > 0) + if (H5Tclose(tid_2) < 0) ret_val = -1; - if(pid_2 > 0) - if(H5Pclose(pid_2) < 0) + if (pid_2 > 0) + if (H5Pclose(pid_2) < 0) ret_val = -1; - if(did_2 > 0) - if(H5Dclose(did_2) < 0) + if (did_2 > 0) + if (H5Dclose(did_2) < 0) ret_val = -1; - if(sid_3 > 0) - if(H5Sclose(sid_3) < 0) + if (sid_3 > 0) + if (H5Sclose(sid_3) < 0) ret_val = -1; - if(tid_3 > 0) - if(H5Tclose(tid_3) < 0) + if (tid_3 > 0) + if (H5Tclose(tid_3) < 0) ret_val = -1; - if(pid_3 > 0) - if(H5Pclose(pid_3) < 0) + if (pid_3 > 0) + if (H5Pclose(pid_3) < 0) ret_val = -1; - if(did_3 > 0) - if(H5Dclose(did_3) < 0) + if (did_3 > 0) + if (H5Dclose(did_3) < 0) ret_val = -1; return ret_val; } /* end H5TBcombine_tables() */ /*------------------------------------------------------------------------- -* Function: H5TBinsert_field -* -* Purpose: Inserts a field -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: January 30, 2002 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBinsert_field(hid_t loc_id, - const char *dset_name, - const char *field_name, - hid_t field_type, - hsize_t position, - const void *fill_data, - const void *buf) + * Function: H5TBinsert_field + * + * Purpose: Inserts a field + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: January 30, 2002 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBinsert_field(hid_t loc_id, const char *dset_name, const char *field_name, hid_t field_type, + hsize_t position, const void *fill_data, const void *buf) { /* identifiers for the 1st, original dataset */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; - hid_t msid_1 = H5I_BADID; + hid_t did_1 = H5I_BADID; + hid_t tid_1 = H5I_BADID; + hid_t sid_1 = H5I_BADID; + hid_t pid_1 = H5I_BADID; + hid_t msid_1 = H5I_BADID; /* identifiers for the 2nd, new dataset */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; - hid_t msid_2 = H5I_BADID; + hid_t did_2 = H5I_BADID; + hid_t tid_2 = H5I_BADID; + hid_t sid_2 = H5I_BADID; + hid_t pid_2 = H5I_BADID; + hid_t msid_2 = H5I_BADID; /* identifiers for the 3rd, final dataset */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t sid_3 = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; - hid_t attr_id = H5I_BADID; - size_t member_size; - size_t new_member_size = 0; - size_t total_size; - size_t curr_offset; - hsize_t nfields; - hsize_t nrecords; - hsize_t dims_chunk[1]; - hsize_t dims[1]; - hsize_t maxdims[1] = { H5S_UNLIMITED }; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t i; - char table_title[255]; - char attr_name[255]; - char *member_name = NULL; - unsigned char *tmp_buf = NULL; + hid_t did_3 = H5I_BADID; + hid_t tid_3 = H5I_BADID; + hid_t sid_3 = H5I_BADID; + hid_t member_type_id = H5I_BADID; + hid_t write_type_id = H5I_BADID; + hid_t preserve_id = H5I_BADID; + hid_t attr_id = H5I_BADID; + size_t member_size; + size_t new_member_size = 0; + size_t total_size; + size_t curr_offset; + hsize_t nfields; + hsize_t nrecords; + hsize_t dims_chunk[1]; + hsize_t dims[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t i; + char table_title[255]; + char attr_name[255]; + char * member_name = NULL; + unsigned char *tmp_buf = NULL; unsigned char *tmp_fill_buf = NULL; - hbool_t inserted; - herr_t ret_val = -1; + hbool_t inserted; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) @@ -2123,7 +2049,7 @@ herr_t H5TBinsert_field(hid_t loc_id, goto out; /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; /*------------------------------------------------------------------------- @@ -2132,27 +2058,27 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* open the dataset. */ - if((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get creation properties list */ - if((pid_1 = H5Dget_create_plist(did_1)) < 0) + if ((pid_1 = H5Dget_create_plist(did_1)) < 0) goto out; /* get the datatype */ - if((tid_1 = H5Dget_type(did_1)) < 0) + if ((tid_1 = H5Dget_type(did_1)) < 0) goto out; /* get the size of the datatype */ - if(0 == (total_size = H5Tget_size(tid_1))) + if (0 == (total_size = H5Tget_size(tid_1))) goto out; /* get the dataspace handle */ - if((sid_1 = H5Dget_space(did_1)) < 0) + if ((sid_1 = H5Dget_space(did_1)) < 0) goto out; /* get dimension */ - if(H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0) goto out; /*------------------------------------------------------------------------- @@ -2161,15 +2087,15 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* get the table title */ - if((H5TBAget_title(did_1, table_title)) < 0) + if ((H5TBAget_title(did_1, table_title)) < 0) goto out; /* alloc fill value attribute buffer */ - if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(total_size))) + if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(total_size))) goto out; /* get the fill value attributes */ - if((H5TBAget_fill(loc_id, dset_name, did_1, tmp_fill_buf)) < 0) + if ((H5TBAget_fill(loc_id, dset_name, did_1, tmp_fill_buf)) < 0) goto out; /*------------------------------------------------------------------------- @@ -2178,31 +2104,31 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* get the new member size */ - if(0 == (member_size = H5Tget_size(field_type))) + if (0 == (member_size = H5Tget_size(field_type))) goto out; /* create the data type. */ - if((tid_2 = H5Tcreate(H5T_COMPOUND, (size_t)(total_size + member_size))) < 0) + if ((tid_2 = H5Tcreate(H5T_COMPOUND, (size_t)(total_size + member_size))) < 0) goto out; curr_offset = 0; inserted = FALSE; /* insert the old fields, counting with the new one */ - for(i = 0; i < nfields + 1; i++) { - hsize_t idx; + for (i = 0; i < nfields + 1; i++) { + hsize_t idx; idx = i; - if(inserted) + if (inserted) idx = i - 1; - if(i == position) { + if (i == position) { /* get the new member size */ - if(0 == (new_member_size = H5Tget_size(field_type))) + if (0 == (new_member_size = H5Tget_size(field_type))) goto out; /* insert the new field type */ - if(H5Tinsert(tid_2, field_name, curr_offset, field_type) < 0) + if (H5Tinsert(tid_2, field_name, curr_offset, field_type) < 0) goto out; curr_offset += new_member_size; @@ -2211,19 +2137,19 @@ herr_t H5TBinsert_field(hid_t loc_id, } /* end if */ else { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)idx))) + if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)idx))) goto out; /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_1, (unsigned)idx)) < 0) + if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)idx)) < 0) goto out; /* get the member size */ - if(0 == (member_size = H5Tget_size(member_type_id))) + if (0 == (member_size = H5Tget_size(member_type_id))) goto out; /* insert it into the new type */ - if(H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0) + if (H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0) goto out; curr_offset += member_size; @@ -2232,11 +2158,11 @@ herr_t H5TBinsert_field(hid_t loc_id, member_name = NULL; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; } /* end else */ - } /* end for */ + } /* end for */ /*------------------------------------------------------------------------- * create a new temporary dataset @@ -2244,21 +2170,21 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* retrieve the size of chunk */ - if(H5Pget_chunk(pid_1, 1, dims_chunk) < 0) + if (H5Pget_chunk(pid_1, 1, dims_chunk) < 0) goto out; /* create a new simple data space with unlimited size, using the dimension */ - if((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* modify dataset creation properties, i.e. enable chunking */ - if((pid_2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((pid_2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_chunk(pid_2, 1, dims_chunk) < 0) + if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0) goto out; /* create the dataset. */ - if((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) + if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- @@ -2266,21 +2192,21 @@ herr_t H5TBinsert_field(hid_t loc_id, *------------------------------------------------------------------------- */ - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, (size_t)total_size))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, (size_t)total_size))) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; - if(H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((msid_1 = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((msid_1 = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread(did_1, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did_1, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- @@ -2289,7 +2215,7 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* write */ - if(H5Dwrite(did_2, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dwrite(did_2, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- @@ -2298,27 +2224,27 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* create a write id */ - if((write_type_id = H5Tcreate(H5T_COMPOUND, (size_t)new_member_size)) < 0) + if ((write_type_id = H5Tcreate(H5T_COMPOUND, (size_t)new_member_size)) < 0) goto out; /* the field in the file is found by its name */ - if(H5Tinsert(write_type_id, field_name, (size_t)0, field_type) < 0) + if (H5Tinsert(write_type_id, field_name, (size_t)0, field_type) < 0) goto out; /* create xfer properties to preserve initialized data */ - if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; - if(H5Pset_preserve(preserve_id, 1) < 0) + if (H5Pset_preserve(preserve_id, 1) < 0) goto out; /* only write if there is something to write */ - if(buf) { + if (buf) { /* create a memory dataspace handle */ - if((msid_2 = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((msid_2 = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; /* write */ - if(H5Dwrite(did_2, write_type_id, msid_2, sid_2, preserve_id, buf) < 0) + if (H5Dwrite(did_2, write_type_id, msid_2, sid_2, preserve_id, buf) < 0) goto out; } /* end if */ @@ -2326,14 +2252,14 @@ herr_t H5TBinsert_field(hid_t loc_id, * delete 1st table *------------------------------------------------------------------------- */ - if(H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0) + if (H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- * rename 2nd table *------------------------------------------------------------------------- */ - if(H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- @@ -2342,33 +2268,33 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; /* open the dataset. */ - if((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid_3 = H5Dget_type(did_3)) < 0) + if ((tid_3 = H5Dget_type(did_3)) < 0) goto out; /* set the attributes */ - if(H5TB_attach_attributes(table_title, loc_id, dset_name, (hsize_t)nfields, tid_3) < 0) + if (H5TB_attach_attributes(table_title, loc_id, dset_name, (hsize_t)nfields, tid_3) < 0) goto out; /*------------------------------------------------------------------------- * attach the fill attributes from previous table *------------------------------------------------------------------------- */ - if((sid_3 = H5Screate(H5S_SCALAR)) < 0) + if ((sid_3 = H5Screate(H5S_SCALAR)) < 0) goto out; - for(i = 0; i < (nfields - 1); i++) { - size_t member_offset; + for (i = 0; i < (nfields - 1); i++) { + size_t member_offset; /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) goto out; /* get the member offset */ @@ -2376,18 +2302,18 @@ herr_t H5TBinsert_field(hid_t loc_id, HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); - if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; attr_id = H5I_BADID; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; } /* end for */ @@ -2396,24 +2322,24 @@ herr_t H5TBinsert_field(hid_t loc_id, * attach the fill attribute from the new field, if present *------------------------------------------------------------------------- */ - if(fill_data) { + if (fill_data) { HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)(nfields - 1)); /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_3, (unsigned)nfields - 1)) < 0) + if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)nfields - 1)) < 0) goto out; - if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, member_type_id, fill_data) < 0) + if (H5Awrite(attr_id, member_type_id, fill_data) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; attr_id = H5I_BADID; - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; } /* end fill_data */ @@ -2421,115 +2347,113 @@ herr_t H5TBinsert_field(hid_t loc_id, ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(tmp_fill_buf) + if (tmp_fill_buf) HDfree(tmp_fill_buf); - if(preserve_id > 0) - if(H5Pclose(preserve_id) < 0) + if (preserve_id > 0) + if (H5Pclose(preserve_id) < 0) ret_val = -1; - if(msid_1 > 0) - if(H5Sclose(msid_1) < 0) + if (msid_1 > 0) + if (H5Sclose(msid_1) < 0) ret_val = -1; - if(tid_1 > 0) - if(H5Tclose(tid_1) < 0) + if (tid_1 > 0) + if (H5Tclose(tid_1) < 0) ret_val = -1; - if(pid_1 > 0) - if(H5Pclose(pid_1) < 0) + if (pid_1 > 0) + if (H5Pclose(pid_1) < 0) ret_val = -1; - if(sid_1 > 0) - if(H5Sclose(sid_1) < 0) + if (sid_1 > 0) + if (H5Sclose(sid_1) < 0) ret_val = -1; - if(did_1 > 0) - if(H5Dclose(did_1) < 0) + if (did_1 > 0) + if (H5Dclose(did_1) < 0) ret_val = -1; - if(msid_2 > 0) - if(H5Sclose(msid_2) < 0) + if (msid_2 > 0) + if (H5Sclose(msid_2) < 0) ret_val = -1; - if(sid_2 > 0) - if(H5Sclose(sid_2) < 0) + if (sid_2 > 0) + if (H5Sclose(sid_2) < 0) ret_val = -1; - if(tid_2 > 0) - if(H5Tclose(tid_2) < 0) + if (tid_2 > 0) + if (H5Tclose(tid_2) < 0) ret_val = -1; - if(pid_2 > 0) - if(H5Pclose(pid_2) < 0) + if (pid_2 > 0) + if (H5Pclose(pid_2) < 0) ret_val = -1; - if(did_2 > 0) - if(H5Dclose(did_2) < 0) + if (did_2 > 0) + if (H5Dclose(did_2) < 0) ret_val = -1; - if(sid_3 > 0) - if(H5Sclose(sid_3) < 0) + if (sid_3 > 0) + if (H5Sclose(sid_3) < 0) ret_val = -1; - if(tid_3 > 0) - if(H5Tclose(tid_3) < 0) + if (tid_3 > 0) + if (H5Tclose(tid_3) < 0) ret_val = -1; - if(did_3 > 0) - if(H5Dclose(did_3) < 0) + if (did_3 > 0) + if (H5Dclose(did_3) < 0) ret_val = -1; return ret_val; } /* end H5TBinsert_field() */ /*------------------------------------------------------------------------- -* Function: H5TBdelete_field -* -* Purpose: Deletes a field -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: January 30, 2002 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBdelete_field(hid_t loc_id, - const char *dset_name, - const char *field_name) + * Function: H5TBdelete_field + * + * Purpose: Deletes a field + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: January 30, 2002 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name) { /* identifiers for the 1st original dataset */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; + hid_t did_1 = H5I_BADID; + hid_t tid_1 = H5I_BADID; + hid_t sid_1 = H5I_BADID; + hid_t pid_1 = H5I_BADID; /* identifiers for the 2nd new dataset */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; + hid_t did_2 = H5I_BADID; + hid_t tid_2 = H5I_BADID; + hid_t sid_2 = H5I_BADID; + hid_t pid_2 = H5I_BADID; /* identifiers for the 3rd final dataset */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; - hid_t read_type_id = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t attr_id = H5I_BADID; - size_t member_size; - size_t type_size1; - size_t type_size2; - size_t curr_offset; - size_t delete_member_size = 0; - size_t member_offset; - hsize_t nfields; - hsize_t nrecords; - hsize_t dims_chunk[1]; - hsize_t dims[1]; - hsize_t maxdims[1] = { H5S_UNLIMITED }; - hsize_t i; - char attr_name[255]; - char table_title[255]; - char *member_name = NULL; - unsigned char *tmp_buf = NULL; + hid_t did_3 = H5I_BADID; + hid_t tid_3 = H5I_BADID; + hid_t member_type_id = H5I_BADID; + hid_t preserve_id = H5I_BADID; + hid_t read_type_id = H5I_BADID; + hid_t write_type_id = H5I_BADID; + hid_t attr_id = H5I_BADID; + size_t member_size; + size_t type_size1; + size_t type_size2; + size_t curr_offset; + size_t delete_member_size = 0; + size_t member_offset; + hsize_t nfields; + hsize_t nrecords; + hsize_t dims_chunk[1]; + hsize_t dims[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t i; + char attr_name[255]; + char table_title[255]; + char * member_name = NULL; + unsigned char *tmp_buf = NULL; unsigned char *tmp_fill_buf = NULL; - htri_t has_fill = FALSE; - herr_t ret_val = -1; - + htri_t has_fill = FALSE; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) @@ -2538,61 +2462,61 @@ herr_t H5TBdelete_field(hid_t loc_id, goto out; /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; /*------------------------------------------------------------------------- - * get information about the old data type - *------------------------------------------------------------------------- - */ + * get information about the old data type + *------------------------------------------------------------------------- + */ /* open the dataset. */ - if((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get creation properties list */ - if((pid_1 = H5Dget_create_plist(did_1)) < 0) + if ((pid_1 = H5Dget_create_plist(did_1)) < 0) goto out; /* get the datatype */ - if((tid_1 = H5Dget_type(did_1)) < 0) + if ((tid_1 = H5Dget_type(did_1)) < 0) goto out; /* get the size of the datatype */ - if(0 == (type_size1 = H5Tget_size(tid_1))) + if (0 == (type_size1 = H5Tget_size(tid_1))) goto out; /* get the dataspace handle */ - if((sid_1 = H5Dget_space(did_1)) < 0) + if ((sid_1 = H5Dget_space(did_1)) < 0) goto out; /* get dimension */ - if(H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0) goto out; /*------------------------------------------------------------------------- - * create a new data type; first we find the size of the datatype to delete - *------------------------------------------------------------------------- - */ + * create a new data type; first we find the size of the datatype to delete + *------------------------------------------------------------------------- + */ /* check out the field */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) goto out; /* we want to find the field to delete */ - if(H5TB_find_field(member_name, field_name)) { + if (H5TB_find_field(member_name, field_name)) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) goto out; /* get the member size */ - if(0 == (delete_member_size = H5Tget_size(member_type_id))) + if (0 == (delete_member_size = H5Tget_size(member_type_id))) goto out; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; @@ -2607,75 +2531,75 @@ herr_t H5TBdelete_field(hid_t loc_id, } /* end for */ /* no field to delete was found */ - if(delete_member_size == 0) + if (delete_member_size == 0) goto out; /*------------------------------------------------------------------------- - * create a new data type; we now insert all the fields into the new type - *------------------------------------------------------------------------- - */ + * create a new data type; we now insert all the fields into the new type + *------------------------------------------------------------------------- + */ type_size2 = type_size1 - delete_member_size; /* create the data type. */ - if((tid_2 = H5Tcreate (H5T_COMPOUND, type_size2)) < 0) + if ((tid_2 = H5Tcreate(H5T_COMPOUND, type_size2)) < 0) goto out; curr_offset = 0; /* alloc fill value attribute buffer */ - if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc((size_t)type_size2))) + if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc((size_t)type_size2))) goto out; /*------------------------------------------------------------------------- - * get attributes from previous table in the process - *------------------------------------------------------------------------- - */ + * get attributes from previous table in the process + *------------------------------------------------------------------------- + */ /* get the table title */ - if((H5TBAget_title(did_1, table_title)) < 0) + if ((H5TBAget_title(did_1, table_title)) < 0) goto out; /* insert the old fields except the one to delete */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) goto out; /* we want to skip the field to delete */ - if(!H5TB_find_field(member_name, field_name)) { + if (!H5TB_find_field(member_name, field_name)) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) goto out; /* get the member size */ - if(0 == (member_size = H5Tget_size(member_type_id))) + if (0 == (member_size = H5Tget_size(member_type_id))) goto out; /* insert it into the new type */ - if(H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0) + if (H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0) goto out; /*------------------------------------------------------------------------- - * get the fill value information - *------------------------------------------------------------------------- - */ + * get the fill value information + *------------------------------------------------------------------------- + */ HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); /* check if we have the _FILL attribute */ - if((has_fill = H5LT_find_attribute(did_1, attr_name)) < 0) + if ((has_fill = H5LT_find_attribute(did_1, attr_name)) < 0) goto out; /* get it */ - if(has_fill) - if(H5LT_get_attribute_disk(did_1, attr_name, tmp_fill_buf + curr_offset) < 0) + if (has_fill) + if (H5LT_get_attribute_disk(did_1, attr_name, tmp_fill_buf + curr_offset) < 0) goto out; curr_offset += member_size; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; } /* end if */ @@ -2685,96 +2609,96 @@ herr_t H5TBdelete_field(hid_t loc_id, } /* end for */ /*------------------------------------------------------------------------- - * create a new temporary dataset - *------------------------------------------------------------------------- - */ + * create a new temporary dataset + *------------------------------------------------------------------------- + */ /* retrieve the size of chunk */ - if(H5Pget_chunk(pid_1, 1, dims_chunk) < 0) + if (H5Pget_chunk(pid_1, 1, dims_chunk) < 0) goto out; /* create a new simple data space with unlimited size, using the dimension */ - if((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* modify dataset creation properties, i.e. enable chunking */ pid_2 = H5Pcreate(H5P_DATASET_CREATE); - if(H5Pset_chunk(pid_2, 1, dims_chunk) < 0) + if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0) goto out; /* create the dataset. */ - if((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) + if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * we have to read field by field of the old dataset and save it into the new one - *------------------------------------------------------------------------- - */ - for(i = 0; i < nfields; i++) { + * we have to read field by field of the old dataset and save it into the new one + *------------------------------------------------------------------------- + */ + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) goto out; /* skip the field to delete */ - if(!H5TB_find_field(member_name, field_name)) { + if (!H5TB_find_field(member_name, field_name)) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) goto out; /* get the member size */ - if(0 == (member_size = H5Tget_size(member_type_id))) + if (0 == (member_size = H5Tget_size(member_type_id))) goto out; /* create a read id */ - if((read_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) + if ((read_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) goto out; /* insert it into the new type */ - if(H5Tinsert(read_type_id, member_name, (size_t)0, member_type_id) < 0) + if (H5Tinsert(read_type_id, member_name, (size_t)0, member_type_id) < 0) goto out; - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, member_size))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, member_size))) goto out; /* read */ - if(H5Dread(did_1, read_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did_1, read_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) goto out; /* create a write id */ - if((write_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) + if ((write_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) goto out; /* the field in the file is found by its name */ - if(H5Tinsert(write_type_id, member_name, (size_t)0, member_type_id) < 0) + if (H5Tinsert(write_type_id, member_name, (size_t)0, member_type_id) < 0) goto out; /* create xfer properties to preserve initialized data */ - if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; - if(H5Pset_preserve(preserve_id, 1) < 0) + if (H5Pset_preserve(preserve_id, 1) < 0) goto out; /* write */ - if(H5Dwrite(did_2, write_type_id, H5S_ALL, H5S_ALL, preserve_id, tmp_buf) < 0) + if (H5Dwrite(did_2, write_type_id, H5S_ALL, H5S_ALL, preserve_id, tmp_buf) < 0) goto out; /* end access to the property list */ - if(H5Pclose(preserve_id) < 0) + if (H5Pclose(preserve_id) < 0) goto out; preserve_id = H5I_BADID; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; /* close the read type */ - if(H5Tclose(read_type_id) < 0) + if (H5Tclose(read_type_id) < 0) goto out; read_type_id = H5I_BADID; /* close the write type */ - if(H5Tclose(write_type_id) < 0) + if (H5Tclose(write_type_id) < 0) goto out; write_type_id = H5I_BADID; @@ -2788,51 +2712,51 @@ herr_t H5TBdelete_field(hid_t loc_id, } /* end for */ /*------------------------------------------------------------------------- - * delete 1st table - *------------------------------------------------------------------------- - */ - if(H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0) + * delete 1st table + *------------------------------------------------------------------------- + */ + if (H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * rename 2nd table - *------------------------------------------------------------------------- - */ - if(H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + * rename 2nd table + *------------------------------------------------------------------------- + */ + if (H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * attach the conforming table attributes - *------------------------------------------------------------------------- - */ + * attach the conforming table attributes + *------------------------------------------------------------------------- + */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; /* open the dataset. */ - if((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid_3 = H5Dget_type(did_3)) < 0) + if ((tid_3 = H5Dget_type(did_3)) < 0) goto out; /* set the attributes */ - if(H5TB_attach_attributes(table_title, loc_id, dset_name, nfields, tid_3) < 0) + if (H5TB_attach_attributes(table_title, loc_id, dset_name, nfields, tid_3) < 0) goto out; /*------------------------------------------------------------------------- - * attach the fill attributes from previous table - *------------------------------------------------------------------------- - */ - if(has_fill) { - if((sid_1 = H5Screate(H5S_SCALAR)) < 0) + * attach the fill attributes from previous table + *------------------------------------------------------------------------- + */ + if (has_fill) { + if ((sid_1 = H5Screate(H5S_SCALAR)) < 0) goto out; - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) goto out; /* get the member offset */ @@ -2840,24 +2764,24 @@ herr_t H5TBdelete_field(hid_t loc_id, HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); - if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; attr_id = H5I_BADID; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; member_type_id = H5I_BADID; } /* end for */ /* close data space. */ - if(H5Sclose(sid_1) < 0) + if (H5Sclose(sid_1) < 0) goto out; sid_1 = H5I_BADID; } /* end if */ @@ -2865,232 +2789,227 @@ herr_t H5TBdelete_field(hid_t loc_id, ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(tmp_fill_buf) + if (tmp_fill_buf) HDfree(tmp_fill_buf); - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(attr_id > 0) - if(H5Aclose(attr_id) < 0) + if (attr_id > 0) + if (H5Aclose(attr_id) < 0) ret_val = -1; - if(preserve_id > 0) - if(H5Pclose(preserve_id) < 0) + if (preserve_id > 0) + if (H5Pclose(preserve_id) < 0) ret_val = -1; - if(member_type_id > 0) - if(H5Tclose(member_type_id) < 0) + if (member_type_id > 0) + if (H5Tclose(member_type_id) < 0) ret_val = -1; - if(read_type_id > 0) - if(H5Tclose(read_type_id) < 0) + if (read_type_id > 0) + if (H5Tclose(read_type_id) < 0) ret_val = -1; - if(write_type_id > 0) - if(H5Tclose(write_type_id) < 0) + if (write_type_id > 0) + if (H5Tclose(write_type_id) < 0) ret_val = -1; - if(tid_1 > 0) - if(H5Tclose(tid_1) < 0) + if (tid_1 > 0) + if (H5Tclose(tid_1) < 0) ret_val = -1; - if(pid_1 > 0) - if(H5Pclose(pid_1) < 0) + if (pid_1 > 0) + if (H5Pclose(pid_1) < 0) ret_val = -1; - if(sid_1 > 0) - if(H5Sclose(sid_1) < 0) + if (sid_1 > 0) + if (H5Sclose(sid_1) < 0) ret_val = -1; - if(did_1 > 0) - if(H5Dclose(did_1) < 0) + if (did_1 > 0) + if (H5Dclose(did_1) < 0) ret_val = -1; - if(sid_2 > 0) - if(H5Sclose(sid_2) < 0) + if (sid_2 > 0) + if (H5Sclose(sid_2) < 0) ret_val = -1; - if(tid_2 > 0) - if(H5Tclose(tid_2) < 0) + if (tid_2 > 0) + if (H5Tclose(tid_2) < 0) ret_val = -1; - if(pid_2 > 0) - if(H5Pclose(pid_2) < 0) + if (pid_2 > 0) + if (H5Pclose(pid_2) < 0) ret_val = -1; - if(did_2 > 0) - if(H5Dclose(did_2) < 0) + if (did_2 > 0) + if (H5Dclose(did_2) < 0) ret_val = -1; - if(tid_3 > 0) - if(H5Tclose(tid_3) < 0) + if (tid_3 > 0) + if (H5Tclose(tid_3) < 0) ret_val = -1; - if(did_3 > 0) - if(H5Dclose(did_3) < 0) + if (did_3 > 0) + if (H5Dclose(did_3) < 0) ret_val = -1; return ret_val; } /* end H5TBdelete_field() */ /*------------------------------------------------------------------------- -* -* Table attribute functions -* -*------------------------------------------------------------------------- -*/ + * + * Table attribute functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBAget_title -* -* Purpose: Read the table title -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: January 30, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBAget_title(hid_t loc_id, - char *table_title) + * Function: H5TBAget_title + * + * Purpose: Read the table title + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: January 30, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBAget_title(hid_t loc_id, char *table_title) { /* Get the TITLE attribute */ - if(H5LT_get_attribute_disk(loc_id, "TITLE", table_title) < 0) + if (H5LT_get_attribute_disk(loc_id, "TITLE", table_title) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5TBAget_fill -* -* Purpose: Read the table attribute fill values -* -* Return: Success: TRUE/FALSE, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: January 30, 2002 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -htri_t H5TBAget_fill(hid_t loc_id, - const char *dset_name, - hid_t dset_id, - unsigned char *dst_buf) + * Function: H5TBAget_fill + * + * Purpose: Read the table attribute fill values + * + * Return: Success: TRUE/FALSE, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: January 30, 2002 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +htri_t +H5TBAget_fill(hid_t loc_id, const char *dset_name, hid_t dset_id, unsigned char *dst_buf) { - hsize_t nfields; - hsize_t nrecords; - hsize_t i; - size_t *src_offset = NULL; - char attr_name[255]; - htri_t has_fill = FALSE; - htri_t ret_val = -1; + hsize_t nfields; + hsize_t nrecords; + hsize_t i; + size_t *src_offset = NULL; + char attr_name[255]; + htri_t has_fill = FALSE; + htri_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; - if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id, dset_name, NULL, NULL, src_offset, NULL) < 0) + if (H5TBget_field_info(loc_id, dset_name, NULL, NULL, src_offset, NULL) < 0) goto out; - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); /* check if we have the _FILL attribute */ - if((has_fill = H5LT_find_attribute(dset_id, attr_name)) < 0) + if ((has_fill = H5LT_find_attribute(dset_id, attr_name)) < 0) goto out; /* get it */ - if(has_fill) - if(H5LT_get_attribute_disk(dset_id, attr_name, dst_buf + src_offset[i]) < 0) + if (has_fill) + if (H5LT_get_attribute_disk(dset_id, attr_name, dst_buf + src_offset[i]) < 0) goto out; } /* end for */ ret_val = has_fill; out: - if(src_offset) + if (src_offset) HDfree(src_offset); return ret_val; } /* end H5TBAget_fill() */ - /*------------------------------------------------------------------------- -* -* Inquiry functions -* -*------------------------------------------------------------------------- -*/ + * + * Inquiry functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBget_table_info -* -* Purpose: Gets the number of records and fields of a table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBget_table_info(hid_t loc_id, - const char *dset_name, - hsize_t *nfields, - hsize_t *nrecords) + * Function: H5TBget_table_info + * + * Purpose: Gets the number of records and fields of a table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_t *nrecords) { - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t did = H5I_BADID; - hsize_t dims[1]; - int num_members; - herr_t ret_val = -1; + hid_t tid = H5I_BADID; + hid_t sid = H5I_BADID; + hid_t did = H5I_BADID; + hsize_t dims[1]; + int num_members; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* get the number of members */ - if((num_members = H5Tget_nmembers(tid)) < 0) + if ((num_members = H5Tget_nmembers(tid)) < 0) goto out; /*------------------------------------------------------------------------- - * get number of nfields - *------------------------------------------------------------------------- - */ - if(nfields) + * get number of nfields + *------------------------------------------------------------------------- + */ + if (nfields) *nfields = (hsize_t)num_members; /*------------------------------------------------------------------------- - * get number of records - *------------------------------------------------------------------------- - */ - if(nrecords) { + * get number of records + *------------------------------------------------------------------------- + */ + if (nrecords) { /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get dimension */ - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* terminate access to the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; sid = H5I_BADID; @@ -3100,106 +3019,103 @@ herr_t H5TBget_table_info(hid_t loc_id, ret_val = 0; out: - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBget_table_info() */ /*------------------------------------------------------------------------- -* Function: H5TBget_field_info -* -* Purpose: Get information about fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBget_field_info(hid_t loc_id, - const char *dset_name, - char *field_names[], - size_t *field_sizes, - size_t *field_offsets, - size_t *type_size) + * Function: H5TBget_field_info + * + * Purpose: Get information about fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBget_field_info(hid_t loc_id, const char *dset_name, char *field_names[], size_t *field_sizes, + size_t *field_offsets, size_t *type_size) { - hid_t did = H5I_BADID; /* dataset ID */ - hid_t tid = H5I_BADID; /* file type ID */ - hid_t n_tid = H5I_BADID; /* native type ID */ - hid_t m_tid = H5I_BADID; /* member type ID */ - hid_t nm_tid = H5I_BADID; /* native member ID */ - hssize_t nfields; - hssize_t i; - herr_t ret_val = -1; + hid_t did = H5I_BADID; /* dataset ID */ + hid_t tid = H5I_BADID; /* file type ID */ + hid_t n_tid = H5I_BADID; /* native type ID */ + hid_t m_tid = H5I_BADID; /* member type ID */ + hid_t nm_tid = H5I_BADID; /* native member ID */ + hssize_t nfields; + hssize_t i; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((n_tid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0) + if ((n_tid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0) goto out; /* get the type size */ - if(type_size) - if(0 == (*type_size = H5Tget_size(n_tid))) + if (type_size) + if (0 == (*type_size = H5Tget_size(n_tid))) goto out; /* get the number of members */ - if((nfields = H5Tget_nmembers(tid)) < 0) + if ((nfields = H5Tget_nmembers(tid)) < 0) goto out; /* iterate tru the members */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(field_names) { - char *member_name; + if (field_names) { + char *member_name; - if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) goto out; strcpy(field_names[i], member_name); H5free_memory(member_name); } /* end if */ /* get the member type */ - if((m_tid = H5Tget_member_type(tid, (unsigned)i)) < 0) + if ((m_tid = H5Tget_member_type(tid, (unsigned)i)) < 0) goto out; - if((nm_tid = H5Tget_native_type(m_tid, H5T_DIR_DEFAULT)) < 0) + if ((nm_tid = H5Tget_native_type(m_tid, H5T_DIR_DEFAULT)) < 0) goto out; /* get the member size */ - if(field_sizes) - if(0 == (field_sizes[i] = H5Tget_size(nm_tid))) + if (field_sizes) + if (0 == (field_sizes[i] = H5Tget_size(nm_tid))) goto out; /* get the member offset */ - if(field_offsets) - field_offsets[i] = H5Tget_member_offset(n_tid, (unsigned) i); + if (field_offsets) + field_offsets[i] = H5Tget_member_offset(n_tid, (unsigned)i); /* close the member types */ - if(H5Tclose(m_tid) < 0) + if (H5Tclose(m_tid) < 0) goto out; m_tid = H5I_BADID; - if(H5Tclose(nm_tid) < 0) + if (H5Tclose(nm_tid) < 0) goto out; nm_tid = H5I_BADID; } /* end for */ @@ -3207,122 +3123,119 @@ herr_t H5TBget_field_info(hid_t loc_id, ret_val = 0; out: - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(n_tid > 0) - if(H5Tclose(n_tid) < 0) + if (n_tid > 0) + if (H5Tclose(n_tid) < 0) ret_val = -1; - if(m_tid > 0) - if(H5Tclose(m_tid) < 0) + if (m_tid > 0) + if (H5Tclose(m_tid) < 0) ret_val = -1; - if(nm_tid > 0) - if(H5Tclose(nm_tid) < 0) + if (nm_tid > 0) + if (H5Tclose(nm_tid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBget_field_info() */ /*------------------------------------------------------------------------- -* -* internal functions -* -*------------------------------------------------------------------------- -*/ + * + * internal functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TB_find_field -* -* Purpose: Find a string field -* -* Return: Success: TRUE/FALSE, Failure: N/A -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 19, 2001 -* -*------------------------------------------------------------------------- -*/ -H5_ATTR_PURE static -hbool_t H5TB_find_field(const char *field, const char *field_list) + * Function: H5TB_find_field + * + * Purpose: Find a string field + * + * Return: Success: TRUE/FALSE, Failure: N/A + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 19, 2001 + * + *------------------------------------------------------------------------- + */ +H5_ATTR_PURE static hbool_t +H5TB_find_field(const char *field, const char *field_list) { const char *start = field_list; const char *end; /* check the arguments */ if (field == NULL) - return FALSE; + return FALSE; if (field_list == NULL) - return FALSE; + return FALSE; - while((end = HDstrstr(start, ",")) != 0) { + while ((end = HDstrstr(start, ",")) != 0) { ptrdiff_t count = end - start; - if(HDstrncmp(start, field, (size_t)count) == 0 && (size_t)count == HDstrlen(field)) + if (HDstrncmp(start, field, (size_t)count) == 0 && (size_t)count == HDstrlen(field)) return TRUE; start = end + 1; } /* end while */ - if(HDstrncmp(start, field, HDstrlen(field)) == 0) + if (HDstrncmp(start, field, HDstrlen(field)) == 0) return TRUE; return FALSE; } /* end H5TB_find_field() */ /*------------------------------------------------------------------------- -* Function: H5TB_attach_attributes -* -* Purpose: Private function that creates the conforming table attributes; -* Used by H5TBcombine_tables; not used by H5TBmake_table, which does not read -* the fill value attributes from an existing table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: December 6, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -static -herr_t H5TB_attach_attributes(const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hid_t tid) + * Function: H5TB_attach_attributes + * + * Purpose: Private function that creates the conforming table attributes; + * Used by H5TBcombine_tables; not used by H5TBmake_table, which does not read + * the fill value attributes from an existing table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: December 6, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5TB_attach_attributes(const char *table_title, hid_t loc_id, const char *dset_name, hsize_t nfields, + hid_t tid) { - char attr_name[255]; - char *member_name = NULL; - hsize_t i; - herr_t ret_val = -1; + char attr_name[255]; + char * member_name = NULL; + hsize_t i; + herr_t ret_val = -1; /* attach the CLASS attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0) goto out; /* attach the VERSION attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "VERSION", TABLE_VERSION) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "VERSION", TABLE_VERSION) < 0) goto out; /* attach the TITLE attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "TITLE", table_title) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "TITLE", table_title) < 0) goto out; /* attach the FIELD_ name attribute */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) goto out; HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_NAME", (int)i); /* attach the attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0) goto out; H5free_memory(member_name); @@ -3332,57 +3245,53 @@ herr_t H5TB_attach_attributes(const char *table_title, ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); return ret_val; } /* end H5TB_attach_attributes() */ /*------------------------------------------------------------------------- -* Function: H5TB_create_type -* -* Purpose: Private function that creates a memory type ID -* -* Return: Success: the memory type ID, Failure: -1 -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: March 31, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -static -hid_t H5TB_create_type(hid_t loc_id, - const char *dset_name, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - hid_t ftype_id) + * Function: H5TB_create_type + * + * Purpose: Private function that creates a memory type ID + * + * Return: Success: the memory type ID, Failure: -1 + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: March 31, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +static hid_t +H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, hid_t ftype_id) { hid_t mem_type_id = H5I_BADID; - hid_t mtype_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; + hid_t mtype_id = H5I_BADID; + hid_t nmtype_id = H5I_BADID; size_t size_native; hsize_t nfields = 0; - char **fnames = NULL; + char ** fnames = NULL; unsigned i; - hid_t ret_val = -1; + hid_t ret_val = -1; /* get the number of fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, NULL) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, NULL) < 0) goto out; - if(NULL == (fnames = (char**)HDcalloc(sizeof(char*), (size_t)nfields))) + if (NULL == (fnames = (char **)HDcalloc(sizeof(char *), (size_t)nfields))) goto out; - for(i = 0; i < nfields; i++) - if(NULL == (fnames[i] = (char*)HDmalloc(HLTB_MAX_FIELD_LEN))) + for (i = 0; i < nfields; i++) + if (NULL == (fnames[i] = (char *)HDmalloc(HLTB_MAX_FIELD_LEN))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id, dset_name, fnames, NULL, NULL, NULL) < 0) + if (H5TBget_field_info(loc_id, dset_name, fnames, NULL, NULL, NULL) < 0) goto out; /* create the memory data type */ @@ -3390,22 +3299,22 @@ hid_t H5TB_create_type(hid_t loc_id, goto out; /* get each field ID and adjust its size, if necessary */ - for(i = 0; i < nfields; i++) { - if((mtype_id = H5Tget_member_type(ftype_id, i)) < 0) + for (i = 0; i < nfields; i++) { + if ((mtype_id = H5Tget_member_type(ftype_id, i)) < 0) goto out; - if((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; - if(field_sizes[i] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[i]) < 0) + if (field_sizes[i] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[i]) < 0) goto out; - if(H5Tinsert(mem_type_id, fnames[i], field_offset[i], nmtype_id) < 0) + if (H5Tinsert(mem_type_id, fnames[i], field_offset[i], nmtype_id) < 0) goto out; - if(H5Tclose(mtype_id) < 0) + if (H5Tclose(mtype_id) < 0) goto out; mtype_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + if (H5Tclose(nmtype_id) < 0) goto out; nmtype_id = H5I_BADID; } /* end for */ @@ -3413,159 +3322,153 @@ hid_t H5TB_create_type(hid_t loc_id, ret_val = mem_type_id; out: - if(fnames) { - for(i = 0; i < nfields; i++) - if(fnames[i]) + if (fnames) { + for (i = 0; i < nfields; i++) + if (fnames[i]) HDfree(fnames[i]); HDfree(fnames); } /* end if */ - if(mtype_id > 0) - if(H5Tclose(mtype_id) < 0) + if (mtype_id > 0) + if (H5Tclose(mtype_id) < 0) ret_val = -1; - if(nmtype_id > 0) - if(H5Tclose(nmtype_id) < 0) + if (nmtype_id > 0) + if (H5Tclose(nmtype_id) < 0) ret_val = -1; - if(ret_val < 0 && mem_type_id > 0) + if (ret_val < 0 && mem_type_id > 0) H5Tclose(mem_type_id); return ret_val; } /* end H5TB_create_type() */ /*------------------------------------------------------------------------- -* -* Functions shared between H5TB and H5PT -* -*------------------------------------------------------------------------- -*/ + * + * Functions shared between H5TB and H5PT + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TB_common_append_records -* -* Purpose: Common code for reading records shared between H5PT and H5TB -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Nat Furrer, nfurrer@ncsa.uiuc.edu -* James Laird, jlaird@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: Called by H5TBappend_records and H5PTappend_records -* -*------------------------------------------------------------------------- -*/ -herr_t H5TB_common_append_records(hid_t dataset_id, - hid_t mem_type_id, - size_t nrecords, - hsize_t orig_table_size, - const void *buf) + * Function: H5TB_common_append_records + * + * Purpose: Common code for reading records shared between H5PT and H5TB + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Nat Furrer, nfurrer@ncsa.uiuc.edu + * James Laird, jlaird@ncsa.uiuc.edu + * + * Date: March 8, 2004 + * + * Comments: Called by H5TBappend_records and H5PTappend_records + * + *------------------------------------------------------------------------- + */ +herr_t +H5TB_common_append_records(hid_t dataset_id, hid_t mem_type_id, size_t nrecords, hsize_t orig_table_size, + const void *buf) { - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t dims[1]; - hsize_t mem_dims[1]; - herr_t ret_val = -1; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t dims[1]; + hsize_t mem_dims[1]; + herr_t ret_val = -1; /* extend the dataset */ dims[0] = nrecords + orig_table_size; - if(H5Dset_extent(dataset_id, dims) < 0) + if (H5Dset_extent(dataset_id, dims) < 0) goto out; /* create a simple memory data space */ mem_dims[0] = nrecords; - if((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) goto out; /* get a copy of the new file data space for writing */ - if((sid = H5Dget_space(dataset_id)) < 0) + if ((sid = H5Dget_space(dataset_id)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = orig_table_size; - count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + count[0] = nrecords; + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* write the records */ - if(H5Dwrite(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; ret_val = 0; out: - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; return ret_val; } /* end H5TB_common_append_records() */ /*------------------------------------------------------------------------- -* Function: H5TB_common_read_records -* -* Purpose: Common code for reading records shared between H5PT and H5TB -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Nat Furrer, nfurrer@ncsa.uiuc.edu -* James Laird, jlaird@ncsa.uiuc.edu -* -* Date: March 8, 2004 -* -* Comments: Called by H5TBread_records and H5PTread_records -* -*------------------------------------------------------------------------- -*/ -herr_t H5TB_common_read_records(hid_t dataset_id, - hid_t mem_type_id, - hsize_t start, - size_t nrecords, - hsize_t table_size, - void *buf) + * Function: H5TB_common_read_records + * + * Purpose: Common code for reading records shared between H5PT and H5TB + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Nat Furrer, nfurrer@ncsa.uiuc.edu + * James Laird, jlaird@ncsa.uiuc.edu + * + * Date: March 8, 2004 + * + * Comments: Called by H5TBread_records and H5PTread_records + * + *------------------------------------------------------------------------- + */ +herr_t +H5TB_common_read_records(hid_t dataset_id, hid_t mem_type_id, hsize_t start, size_t nrecords, + hsize_t table_size, void *buf) { - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - herr_t ret_val = -1; + hid_t sid = H5I_BADID; + hid_t m_sid = H5I_BADID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + herr_t ret_val = -1; /* make sure the read request is in bounds */ - if(start + nrecords > table_size) + if (start + nrecords > table_size) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(dataset_id)) < 0) + if ((sid = H5Dget_space(dataset_id)) < 0) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if((H5Dread(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf)) < 0) + if ((H5Dread(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf)) < 0) goto out; ret_val = 0; out: - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; return ret_val; } /* end H5TB_common_read_records() */ - diff --git a/hl/src/H5TBprivate.h b/hl/src/H5TBprivate.h index 17306fb..cdddfbc 100644 --- a/hl/src/H5TBprivate.h +++ b/hl/src/H5TBprivate.h @@ -20,10 +20,9 @@ /* public TB prototypes */ #include "H5TBpublic.h" - -#define TABLE_CLASS "TABLE" -#define TABLE_VERSION "3.0" -#define HLTB_MAX_FIELD_LEN 255 +#define TABLE_CLASS "TABLE" +#define TABLE_VERSION "3.0" +#define HLTB_MAX_FIELD_LEN 255 /*------------------------------------------------------------------------- * @@ -32,11 +31,8 @@ *------------------------------------------------------------------------- */ -herr_t H5TB_common_append_records( hid_t dataset_id, - hid_t mem_type_id, - size_t nrecords, - hsize_t orig_table_size, - const void * data); +herr_t H5TB_common_append_records(hid_t dataset_id, hid_t mem_type_id, size_t nrecords, + hsize_t orig_table_size, const void *data); /*------------------------------------------------------------------------- * @@ -45,16 +41,7 @@ herr_t H5TB_common_append_records( hid_t dataset_id, *------------------------------------------------------------------------- */ - -herr_t H5TB_common_read_records( hid_t dataset_id, - hid_t mem_type_id, - hsize_t start, - size_t nrecords, - hsize_t table_size, - void *data); - - - +herr_t H5TB_common_read_records(hid_t dataset_id, hid_t mem_type_id, hsize_t start, size_t nrecords, + hsize_t table_size, void *data); #endif - diff --git a/hl/src/H5TBpublic.h b/hl/src/H5TBpublic.h index 56aa915..3649225 100644 --- a/hl/src/H5TBpublic.h +++ b/hl/src/H5TBpublic.h @@ -14,12 +14,10 @@ #ifndef _H5TBpublic_H #define _H5TBpublic_H - #ifdef __cplusplus extern "C" { #endif - /*------------------------------------------------------------------------- * * Create functions @@ -27,20 +25,10 @@ extern "C" { *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5TBmake_table( const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hsize_t nrecords, - size_t type_size, - const char *field_names[], - const size_t *field_offset, - const hid_t *field_types, - hsize_t chunk_size, - void *fill_data, - int compress, - const void *buf ); - +H5_HLDLL herr_t H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsize_t nfields, + hsize_t nrecords, size_t type_size, const char *field_names[], + const size_t *field_offset, const hid_t *field_types, hsize_t chunk_size, + void *fill_data, int compress, const void *buf); /*------------------------------------------------------------------------- * @@ -49,45 +37,21 @@ H5_HLDLL herr_t H5TBmake_table( const char *table_title, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5TBappend_records( hid_t loc_id, - const char *dset_name, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *dst_sizes, - const void *buf ); - -H5_HLDLL herr_t H5TBwrite_records( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *dst_sizes, - const void *buf ); - - -H5_HLDLL herr_t H5TBwrite_fields_name( hid_t loc_id, - const char *dset_name, - const char *field_names, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *dst_sizes, - const void *buf ); - -H5_HLDLL herr_t H5TBwrite_fields_index( hid_t loc_id, - const char *dset_name, - hsize_t nfields, - const int *field_index, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *dst_sizes, - const void *buf ); +H5_HLDLL herr_t H5TBappend_records(hid_t loc_id, const char *dset_name, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *dst_sizes, const void *buf); + +H5_HLDLL herr_t H5TBwrite_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, + size_t type_size, const size_t *field_offset, const size_t *dst_sizes, + const void *buf); +H5_HLDLL herr_t H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, + hsize_t start, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *dst_sizes, const void *buf); + +H5_HLDLL herr_t H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, + const int *field_index, hsize_t start, hsize_t nrecords, + size_t type_size, const size_t *field_offset, const size_t *dst_sizes, + const void *buf); /*------------------------------------------------------------------------- * @@ -96,46 +60,21 @@ H5_HLDLL herr_t H5TBwrite_fields_index( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5TBread_table(hid_t loc_id, const char *dset_name, size_t dst_size, const size_t *dst_offset, + const size_t *dst_sizes, void *dst_buf); + +H5_HLDLL herr_t H5TBread_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, + hsize_t start, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *dst_sizes, void *buf); +H5_HLDLL herr_t H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, + const int *field_index, hsize_t start, hsize_t nrecords, + size_t type_size, const size_t *field_offset, const size_t *dst_sizes, + void *buf); -H5_HLDLL herr_t H5TBread_table( hid_t loc_id, - const char *dset_name, - size_t dst_size, - const size_t *dst_offset, - const size_t *dst_sizes, - void *dst_buf ); - - -H5_HLDLL herr_t H5TBread_fields_name( hid_t loc_id, - const char *dset_name, - const char *field_names, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *dst_sizes, - void *buf ); - -H5_HLDLL herr_t H5TBread_fields_index( hid_t loc_id, - const char *dset_name, - hsize_t nfields, - const int *field_index, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *dst_sizes, - void *buf ); - - -H5_HLDLL herr_t H5TBread_records( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *dst_offset, - const size_t *dst_sizes, - void *buf ); +H5_HLDLL herr_t H5TBread_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, + size_t type_size, const size_t *dst_offset, const size_t *dst_sizes, + void *buf); /*------------------------------------------------------------------------- * @@ -144,19 +83,10 @@ H5_HLDLL herr_t H5TBread_records( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_t *nrecords); -H5_HLDLL herr_t H5TBget_table_info ( hid_t loc_id, - const char *dset_name, - hsize_t *nfields, - hsize_t *nrecords ); - -H5_HLDLL herr_t H5TBget_field_info( hid_t loc_id, - const char *dset_name, - char *field_names[], - size_t *field_sizes, - size_t *field_offsets, - size_t *type_size ); - +H5_HLDLL herr_t H5TBget_field_info(hid_t loc_id, const char *dset_name, char *field_names[], + size_t *field_sizes, size_t *field_offsets, size_t *type_size); /*------------------------------------------------------------------------- * @@ -165,47 +95,22 @@ H5_HLDLL herr_t H5TBget_field_info( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords); -H5_HLDLL herr_t H5TBdelete_record( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords ); - - -H5_HLDLL herr_t H5TBinsert_record( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t dst_size, - const size_t *dst_offset, - const size_t *dst_sizes, - void *buf ); +H5_HLDLL herr_t H5TBinsert_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, + size_t dst_size, const size_t *dst_offset, const size_t *dst_sizes, + void *buf); -H5_HLDLL herr_t H5TBadd_records_from( hid_t loc_id, - const char *dset_name1, - hsize_t start1, - hsize_t nrecords, - const char *dset_name2, - hsize_t start2 ); +H5_HLDLL herr_t H5TBadd_records_from(hid_t loc_id, const char *dset_name1, hsize_t start1, hsize_t nrecords, + const char *dset_name2, hsize_t start2); -H5_HLDLL herr_t H5TBcombine_tables( hid_t loc_id1, - const char *dset_name1, - hid_t loc_id2, - const char *dset_name2, - const char *dset_name3 ); +H5_HLDLL herr_t H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2, + const char *dset_name2, const char *dset_name3); -H5_HLDLL herr_t H5TBinsert_field( hid_t loc_id, - const char *dset_name, - const char *field_name, - hid_t field_type, - hsize_t position, - const void *fill_data, - const void *buf ); - -H5_HLDLL herr_t H5TBdelete_field( hid_t loc_id, - const char *dset_name, - const char *field_name ); +H5_HLDLL herr_t H5TBinsert_field(hid_t loc_id, const char *dset_name, const char *field_name, + hid_t field_type, hsize_t position, const void *fill_data, const void *buf); +H5_HLDLL herr_t H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name); /*------------------------------------------------------------------------- * @@ -214,18 +119,12 @@ H5_HLDLL herr_t H5TBdelete_field( hid_t loc_id, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5TBAget_title( hid_t loc_id, - char *table_title ); +H5_HLDLL herr_t H5TBAget_title(hid_t loc_id, char *table_title); -H5_HLDLL htri_t H5TBAget_fill(hid_t loc_id, - const char *dset_name, - hid_t dset_id, - unsigned char *dst_buf); +H5_HLDLL htri_t H5TBAget_fill(hid_t loc_id, const char *dset_name, hid_t dset_id, unsigned char *dst_buf); #ifdef __cplusplus } #endif - #endif - diff --git a/hl/src/hdf5_hl.h b/hl/src/hdf5_hl.h index 3a7b8ee..51f8ab9 100644 --- a/hl/src/hdf5_hl.h +++ b/hl/src/hdf5_hl.h @@ -29,4 +29,3 @@ #include "H5LDpublic.h" /* lite dataset */ #endif /*H5_INCLUDE_HL*/ - diff --git a/hl/test/gen_test_ds.c b/hl/test/gen_test_ds.c index 285ab77..0138e19 100644 --- a/hl/test/gen_test_ds.c +++ b/hl/test/gen_test_ds.c @@ -31,9 +31,9 @@ /* prototypes */ static hid_t open_test_file(const char *fileext); -herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx); -herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx); -herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx); +herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx); +herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx); +herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx); herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx); herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx); @@ -43,47 +43,46 @@ static int test_long_scalenames(const char *filename); static int test_samelong_scalenames(const char *filename); static int test_foreign_scaleattached(const char *filename); - -#define DIM_DATA 12 -#define DIM1_SIZE 3 -#define DIM2_SIZE 4 -#define DIM3_SIZE 12 -#define DIM4_SIZE 2 -#define DIM0 0 -#define DIM1 1 -#define DIM2 2 -#define DIM3 3 - -#define DATASET_NAME "dset_" -#define DS_1_NAME "ds_1_" -#define DS_2_NAME "ds_2_" -#define DS_3_NAME "ds_3_" -#define DS_4_NAME "ds_4_" - -#define SCALE_1_NAME "scalename_1_" -#define SCALE_2_NAME "scalename_2_" -#define SCALE_3_NAME "scalename_3_" -#define SCALE_4_NAME "scalename_4_" - -#define FILENAME "test_ds_" -#define FILEEXT ".h5" +#define DIM_DATA 12 +#define DIM1_SIZE 3 +#define DIM2_SIZE 4 +#define DIM3_SIZE 12 +#define DIM4_SIZE 2 +#define DIM0 0 +#define DIM1 1 +#define DIM2 2 +#define DIM3 3 + +#define DATASET_NAME "dset_" +#define DS_1_NAME "ds_1_" +#define DS_2_NAME "ds_2_" +#define DS_3_NAME "ds_3_" +#define DS_4_NAME "ds_4_" + +#define SCALE_1_NAME "scalename_1_" +#define SCALE_2_NAME "scalename_2_" +#define SCALE_3_NAME "scalename_3_" +#define SCALE_4_NAME "scalename_4_" + +#define FILENAME "test_ds_" +#define FILEEXT ".h5" /*------------------------------------------------------------------------- * the main program *------------------------------------------------------------------------- */ -int main(int argc , char **argv) +int +main(int argc, char **argv) { - int nerrors=0; + int nerrors = 0; char filename[65]; - if (argc < 2) { HDprintf("Usage: gen_test [le | be]\n"); return 1; } - if ( argv[1] && (strcmp("le",argv[1])!=0) && (strcmp("be",argv[1])!=0) ) { + if (argv[1] && (strcmp("le", argv[1]) != 0) && (strcmp("be", argv[1]) != 0)) { HDprintf("Usage: gen_test [le | be]\n"); return 1; } @@ -92,26 +91,28 @@ int main(int argc , char **argv) strcpy(filename, FILENAME); strcat(filename, argv[1]); strcat(filename, FILEEXT); - if(H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT) < 0) { nerrors = 1; goto error; } - nerrors += test_long_attachscales(filename) < 0 ? 1 : 0; - nerrors += test_duplicatelong_attachscales(filename) < 0 ? 1 : 0; - nerrors += test_samelong_scalenames(filename) < 0 ? 1 : 0; - nerrors += test_foreign_scaleattached(filename) < 0 ? 1 : 0; - nerrors += test_long_scalenames(filename) < 0 ? 1 : 0; + nerrors += test_long_attachscales(filename) < 0 ? 1 : 0; + nerrors += test_duplicatelong_attachscales(filename) < 0 ? 1 : 0; + nerrors += test_samelong_scalenames(filename) < 0 ? 1 : 0; + nerrors += test_foreign_scaleattached(filename) < 0 ? 1 : 0; + nerrors += test_long_scalenames(filename) < 0 ? 1 : 0; - if(nerrors) goto error; + if (nerrors) + goto error; HDprintf("Dimension scales file generation passed.\n"); return 0; error: - HDprintf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n",nerrors); + HDprintf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n", nerrors); return 1; } -static hid_t open_test_file(const char *fileext) +static hid_t +open_test_file(const char *fileext) { char filename[65]; @@ -127,191 +128,197 @@ static hid_t open_test_file(const char *fileext) *------------------------------------------------------------------------- */ -herr_t create_long_dataset(hid_t fid, const char *name, const char *dsidx) +herr_t +create_long_dataset(hid_t fid, const char *name, const char *dsidx) { - int rank = 4; - int rankds = 1; - hsize_t dims[4] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE,DIM4_SIZE}; - long buf[DIM_DATA*3*2] = {1,2,3,4,5,6,7,8,9,10,11,12, - 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12, - 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12, - 1,2,3,4,5,6,7,8,9,10,11,12}; - hsize_t s1_dim[1] = {DIM1_SIZE}; - hsize_t s2_dim[1] = {DIM2_SIZE}; - hsize_t s3_dim[1] = {DIM3_SIZE}; - hsize_t s4_dim[1] = {DIM4_SIZE}; - long s1_wbuf[DIM1_SIZE] = {10,20,30}; - long s2_wbuf[DIM2_SIZE] = {100,200,300,400}; - long s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40}; - long s4_wbuf[DIM4_SIZE] = {18,18}; + int rank = 4; + int rankds = 1; + hsize_t dims[4] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE, DIM4_SIZE}; + long buf[DIM_DATA * 3 * 2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + hsize_t s1_dim[1] = {DIM1_SIZE}; + hsize_t s2_dim[1] = {DIM2_SIZE}; + hsize_t s3_dim[1] = {DIM3_SIZE}; + hsize_t s4_dim[1] = {DIM4_SIZE}; + long s1_wbuf[DIM1_SIZE] = {10, 20, 30}; + long s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400}; + long s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40}; + long s4_wbuf[DIM4_SIZE] = {18, 18}; /* make a dataset */ - if(H5LTmake_dataset_long(fid, name, rank, dims, buf) >= 0) { + if (H5LTmake_dataset_long(fid, name, rank, dims, buf) >= 0) { /* make a DS dataset for the first dimension */ char dsname[32]; strcpy(dsname, DS_1_NAME); strcat(dsname, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_long(fid, dsname, rankds, s1_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_long(fid, dsname, rankds, s1_dim, s1_wbuf) < 0) return FAIL; strcpy(dsname, DS_2_NAME); strcat(dsname, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_long(fid, dsname, rankds, s2_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_long(fid, dsname, rankds, s2_dim, s2_wbuf) < 0) return FAIL; strcpy(dsname, DS_3_NAME); strcat(dsname, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_long(fid, dsname, rankds, s3_dim, s3_wbuf) < 0) + if (H5LTmake_dataset_long(fid, dsname, rankds, s3_dim, s3_wbuf) < 0) return FAIL; strcpy(dsname, DS_4_NAME); strcat(dsname, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_long(fid, dsname, rankds, s4_dim, s4_wbuf) < 0) + if (H5LTmake_dataset_long(fid, dsname, rankds, s4_dim, s4_wbuf) < 0) return FAIL; - } - else - return FAIL; + } + else + return FAIL; return SUCCEED; } -herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx) +herr_t +test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx) { - herr_t ret_value = FAIL; - hid_t dsid = -1; + herr_t ret_value = FAIL; + hid_t dsid = -1; - if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 0) { - if(H5DSattach_scale(did, dsid, idx) >= 0) { - if(H5DSis_attached(did, dsid, idx) > 0) { + if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 0) { + if (H5DSattach_scale(did, dsid, idx) >= 0) { + if (H5DSis_attached(did, dsid, idx) > 0) { /* HDprintf(" scale attached "); */ ret_value = SUCCEED; } - else if(H5DSis_attached(did, dsid, idx) == 0) { + else if (H5DSis_attached(did, dsid, idx) == 0) { HDprintf(" scale not attached "); } } } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) ret_value = FAIL; } return ret_value; } -herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx) +herr_t +test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx) { - herr_t ret_value = FAIL; - hid_t dsid = -1; + herr_t ret_value = FAIL; + hid_t dsid = -1; - if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 1) { - if(H5DSdetach_scale(did, dsid, idx) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 0) { + if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 1) { + if (H5DSdetach_scale(did, dsid, idx) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 0) { ret_value = SUCCEED; } } } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) ret_value = FAIL; } return ret_value; } -herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx) +herr_t +test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx) { - herr_t ret_value = FAIL; - hid_t dsid = -1; + herr_t ret_value = FAIL; + hid_t dsid = -1; - if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 1) { - if(H5DSset_scale(dsid, scalename) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 1) { - ret_value = SUCCEED; + if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 1) { + if (H5DSset_scale(dsid, scalename) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 1) { + ret_value = SUCCEED; } } } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) ret_value = FAIL; } return ret_value; } -herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx) +herr_t +test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx) { herr_t ret_value = FAIL; - hid_t dsid = -1; + hid_t dsid = -1; ssize_t name_len; - char *name_out=NULL; - - if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 1) { - if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) { - name_out = (char*)HDmalloc((size_t)name_len * sizeof (char)); - if(name_out != NULL) { - if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) { - if(strcmp(scalename,name_out)==0) { + char * name_out = NULL; + + if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 1) { + if ((name_len = H5DSget_scale_name(dsid, NULL, (size_t)0)) > 0) { + name_out = (char *)HDmalloc((size_t)name_len * sizeof(char)); + if (name_out != NULL) { + if (H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) { + if (strcmp(scalename, name_out) == 0) { ret_value = SUCCEED; } HDfree(name_out); - name_out=NULL; + name_out = NULL; } } } } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) ret_value = FAIL; } return ret_value; } -static int test_long_attachscales(const char *filename) +static int +test_long_attachscales(const char *filename) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; strcpy(dsname, DATASET_NAME); strcat(dsname, "al"); HL_TESTING2("test_long_attachscales"); - if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto out; /* make a dataset */ - if(create_long_dataset(fid, dsname, "al") < 0) + if (create_long_dataset(fid, dsname, "al") < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { strcpy(scalename, DS_1_NAME); strcat(scalename, "al"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; strcpy(scalename, DS_2_NAME); strcat(scalename, "al"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; strcpy(scalename, DS_3_NAME); strcat(scalename, "al"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; strcpy(scalename, DS_4_NAME); strcat(scalename, "al"); - if(test_attach_scale(fid, did, scalename, DIM3) < 0) + if (test_attach_scale(fid, did, scalename, DIM3) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -323,56 +330,59 @@ static int test_long_attachscales(const char *filename) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_duplicatelong_attachscales(const char *filename) +static int +test_duplicatelong_attachscales(const char *filename) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; strcpy(dsname, DATASET_NAME); strcat(dsname, "al2"); HL_TESTING2("test_duplicatelong_attachscales"); - if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto out; /* make a dataset 2 */ - if(create_long_dataset(fid, dsname, "al2") < 0) + if (create_long_dataset(fid, dsname, "al2") < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { strcpy(scalename, DS_1_NAME); strcat(scalename, "al"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; strcpy(scalename, DS_2_NAME); strcat(scalename, "al"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; strcpy(scalename, DS_3_NAME); strcat(scalename, "al"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; strcpy(scalename, DS_4_NAME); strcat(scalename, "al"); - if(test_attach_scale(fid, did, scalename, DIM3) < 0) + if (test_attach_scale(fid, did, scalename, DIM3) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -384,71 +394,75 @@ static int test_duplicatelong_attachscales(const char *filename) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_long_scalenames(const char *filename) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; - char name[32]; +static int +test_long_scalenames(const char *filename) +{ + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; + char name[32]; strcpy(dsname, DATASET_NAME); strcat(dsname, "al"); - if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto out; HL_TESTING2("set long scale/cmp scale name"); - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { strcpy(scalename, DS_1_NAME); strcat(scalename, "al"); strcpy(name, SCALE_1_NAME); strcat(name, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; strcpy(scalename, DS_2_NAME); strcat(scalename, "al"); strcpy(name, SCALE_2_NAME); strcat(name, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; strcpy(scalename, DS_3_NAME); strcat(scalename, "al"); strcpy(name, SCALE_3_NAME); strcat(name, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; strcpy(scalename, DS_4_NAME); strcat(scalename, "al"); strcpy(name, SCALE_4_NAME); strcat(name, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM3) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM3) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -460,72 +474,76 @@ static int test_long_scalenames(const char *filename) { return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_samelong_scalenames(const char *filename) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; - char name[32]; +static int +test_samelong_scalenames(const char *filename) +{ + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; + char name[32]; strcpy(dsname, DATASET_NAME); strcat(dsname, "al2"); - if((fid = open_test_file(filename)) < 0) + if ((fid = open_test_file(filename)) < 0) goto out; HL_TESTING2("set same long scale/cmp scale name"); - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { strcpy(scalename, DS_1_NAME); strcat(scalename, "al"); strcpy(name, DS_1_NAME); strcat(name, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; strcpy(scalename, DS_2_NAME); strcat(scalename, "al"); strcpy(name, DS_2_NAME); strcat(name, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; strcpy(scalename, DS_3_NAME); strcat(scalename, "al"); strcpy(name, DS_3_NAME); strcat(name, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; strcpy(scalename, DS_4_NAME); strcat(scalename, "al"); strcpy(name, DS_4_NAME); strcat(name, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM3) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM3) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -537,43 +555,46 @@ static int test_samelong_scalenames(const char *filename) { return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_foreign_scaleattached(const char *filename) +static int +test_foreign_scaleattached(const char *filename) { - herr_t ret_value = FAIL; - hid_t fid = -1; - hid_t did = -1; - hid_t dsid = -1; + herr_t ret_value = FAIL; + hid_t fid = -1; + hid_t did = -1; + hid_t dsid = -1; HL_TESTING2("test_foreign_scaleattached"); - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto out; - if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) { - if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, 3) == 1) { + if ((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) { + if ((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, 3) == 1) { ret_value = SUCCEED; } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else goto out; - if(ret_value == FAIL) + if (ret_value == FAIL) goto out; PASSED(); @@ -582,10 +603,12 @@ static int test_foreign_scaleattached(const char *filename) return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); diff --git a/hl/test/gen_test_ld.c b/hl/test/gen_test_ld.c index 981aded..2a3beb5 100644 --- a/hl/test/gen_test_ld.c +++ b/hl/test/gen_test_ld.c @@ -31,28 +31,28 @@ * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR */ -#define ONE_DIMS0 10 -#define MAX_ONE_DIMS0 100 +#define ONE_DIMS0 10 +#define MAX_ONE_DIMS0 100 -#define DSET_ONE "DSET_ONE" -#define DSET_NONE "DSET_NONE" -#define DSET_NOMAX "DSET_NOMAX" -#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ONE "DSET_ONE" +#define DSET_NONE "DSET_NONE" +#define DSET_NOMAX "DSET_NOMAX" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" #define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" -#define DSET_CMPD "DSET_CMPD" -#define DSET_CMPD_ESC "DSET_CMPD_ESC" -#define DSET_NULL "DSET_NULL" -#define DSET_SCALAR "DSET_SCALAR" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_NULL "DSET_NULL" +#define DSET_SCALAR "DSET_SCALAR" -#define TWO_DIMS0 4 -#define TWO_DIMS1 10 -#define MAX_TWO_DIMS0 60 -#define MAX_TWO_DIMS1 100 +#define TWO_DIMS0 4 +#define TWO_DIMS1 10 +#define MAX_TWO_DIMS0 60 +#define MAX_TWO_DIMS1 100 -#define DSET_TWO "DSET_TWO" -#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" -#define CHUNK_SIZE 2 +#define CHUNK_SIZE 2 #define FILE "test_ld.h5" @@ -65,7 +65,7 @@ typedef struct sub22_t { typedef struct sub2_t { unsigned int a; - sub22_t b; + sub22_t b; unsigned int c; } sub2_t; @@ -76,9 +76,9 @@ typedef struct sub4_t { typedef struct set_t { unsigned int field1; - sub2_t field2; - double field3; - sub4_t field4; + sub2_t field2; + double field3; + sub4_t field4; } set_t; /* @@ -90,119 +90,119 @@ typedef struct set_t { ************************************************************************************** */ static int -generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, - hsize_t *maxdims, hid_t dtid, void *data) +generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, + void *data) { - hid_t dcpl = -1; /* Dataset creation property */ - hid_t did = -1; /* Dataset id */ - hid_t sid = -1; /* Dataspace id */ - int i; /* Local index variable */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t did = -1; /* Dataset id */ + hid_t sid = -1; /* Dataspace id */ + int i; /* Local index variable */ /* Create the dataspace */ - if((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) - goto done; + if ((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) + goto done; /* Set up dataset's creation properties */ - if(!HDstrcmp(dname, DSET_NONE)) - dcpl = H5P_DEFAULT; + if (!HDstrcmp(dname, DSET_NONE)) + dcpl = H5P_DEFAULT; else { - hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ - - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto done; - for(i = 0; i < ndims; i++) - chunk_dims[i] = CHUNK_SIZE; - if(H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) - goto done; + hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ + + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto done; + for (i = 0; i < ndims; i++) + chunk_dims[i] = CHUNK_SIZE; + if (H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) + goto done; } /* end else */ - if(!HDstrcmp(dname, DSET_ALLOC_LATE)) { - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) - goto done; + if (!HDstrcmp(dname, DSET_ALLOC_LATE)) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto done; } /* end if */ - else if(!HDstrcmp(dname, DSET_ALLOC_EARLY)) { - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) - goto done; + else if (!HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto done; } /* end if */ /* Create the dataset */ - if((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto done; + if ((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto done; /* Write to the dataset */ - if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) - goto done; + if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto done; /* Closing */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto done; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto done; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto done; - return(SUCCEED); + return (SUCCEED); done: H5E_BEGIN_TRY - H5Sclose(sid); - H5Pclose(dcpl); - H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl); + H5Dclose(did); H5E_END_TRY - return(FAIL); + return (FAIL); } /* generate_dset() */ int main(void) { - hid_t fid; /* File id */ - hid_t fapl; /* File access property list */ - hsize_t cur_dims[1]; /* Dimension sizes */ - hsize_t max_dims[1]; /* Maximum dimension sizes */ - hsize_t cur2_dims[2]; /* Current dimension sizes */ - hsize_t max2_dims[2]; /* Maximum dimension sizes */ - hid_t set_tid, esc_set_tid; /* Compound type id */ - hid_t sub22_tid; /* Compound type id */ - hid_t sub2_tid, esc_sub2_tid; /* Compound type id */ - hid_t sub4_tid, esc_sub4_tid; /* Compound type id */ - hid_t null_did, null_sid; /* H5S_NULL dataset & dataspace ids */ - hid_t scalar_did, scalar_sid; /* H5S_SCALAR dataset & dataspace ids */ - int one_data[ONE_DIMS0]; /* Buffer for data */ - int two_data[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data */ - set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ - set_t two_cbuf[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data with compound type */ - int i; /* Local index variable */ + hid_t fid; /* File id */ + hid_t fapl; /* File access property list */ + hsize_t cur_dims[1]; /* Dimension sizes */ + hsize_t max_dims[1]; /* Maximum dimension sizes */ + hsize_t cur2_dims[2]; /* Current dimension sizes */ + hsize_t max2_dims[2]; /* Maximum dimension sizes */ + hid_t set_tid, esc_set_tid; /* Compound type id */ + hid_t sub22_tid; /* Compound type id */ + hid_t sub2_tid, esc_sub2_tid; /* Compound type id */ + hid_t sub4_tid, esc_sub4_tid; /* Compound type id */ + hid_t null_did, null_sid; /* H5S_NULL dataset & dataspace ids */ + hid_t scalar_did, scalar_sid; /* H5S_SCALAR dataset & dataspace ids */ + int one_data[ONE_DIMS0]; /* Buffer for data */ + int two_data[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data */ + set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ + set_t two_cbuf[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data with compound type */ + int i; /* Local index variable */ /* Create a file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto done; /* Set to use latest library format */ - if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) + if ((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) goto done; /* Create a file */ - if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto done; + if ((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto done; /* Initialization for one-dimensional dataset */ cur_dims[0] = ONE_DIMS0; max_dims[0] = MAX_ONE_DIMS0; - for(i = 0; i < ONE_DIMS0; i++) + for (i = 0; i < ONE_DIMS0; i++) one_data[i] = i; /* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */ - if(generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) - goto done; - if(generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) - goto done; - if(generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) - goto done; - if(generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) - goto done; - if(generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) - goto done; + if (generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if (generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if (generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if (generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if (generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; /* Initialization for two-dimensional dataset */ cur2_dims[0] = TWO_DIMS0; @@ -210,99 +210,99 @@ main(void) max2_dims[0] = MAX_TWO_DIMS0; max2_dims[1] = MAX_TWO_DIMS1; - for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) + for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) two_data[i] = i; /* Generate DSET_TWO */ - if(generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) - goto done; + if (generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) + goto done; /* Initialization for one-dimensional compound typed dataset */ cur_dims[0] = ONE_DIMS0; max_dims[0] = MAX_ONE_DIMS0; for (i = 0; i < ONE_DIMS0; i++) { - one_cbuf[i].field1 = 1; - one_cbuf[i].field2.a = 2; - one_cbuf[i].field2.c = 4; + one_cbuf[i].field1 = 1; + one_cbuf[i].field2.a = 2; + one_cbuf[i].field2.c = 4; one_cbuf[i].field2.b.a = 20; one_cbuf[i].field2.b.b = 40; one_cbuf[i].field2.b.c = 80; - one_cbuf[i].field3 = 3.0f; - one_cbuf[i].field4.a = 4; - one_cbuf[i].field4.b = 8; + one_cbuf[i].field3 = 3.0f; + one_cbuf[i].field4.a = 4; + one_cbuf[i].field4.b = 8; } /* end for */ /* Create the compound type */ - if((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) - goto done; - if(H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) - goto done; - if(H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) - goto done; - if(H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) - goto done; - - if((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) - goto done; - if(H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) - goto done; - if(H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) - goto done; - if(H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) - goto done; - - if((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) - goto done; - if(H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) - goto done; - if(H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) - goto done; - - if((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) - goto done; - if(H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) - goto done; - if(H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) - goto done; - if(H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) - goto done; - if(H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) - goto done; + if ((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) + goto done; + if (H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if ((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if (H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if (H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if ((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if (H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if ((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if (H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) + goto done; + if (H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if (H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) + goto done; /* Create the compound type with escape/separator characters */ - if((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) - goto done; - if(H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) - goto done; - if(H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) - goto done; - if(H5Tinsert(esc_sub2_tid, "\\c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) - goto done; - - if((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) - goto done; - if(H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) - goto done; - if(H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) - goto done; - - if((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) - goto done; - if(H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) - goto done; - if(H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) - goto done; - if(H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) - goto done; - if(H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) - goto done; + if ((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if (H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if (H5Tinsert(esc_sub2_tid, "\\c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if ((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if (H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if ((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if (H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if (H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) + goto done; + if (H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if (H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) + goto done; /* Generate DSET_CMPD, DSET_CMPD_ESC */ - if(generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) - goto done; - if(generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) - goto done; + if (generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) + goto done; + if (generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) + goto done; /* Initialization for two-dimensional compound typed dataset */ cur2_dims[0] = TWO_DIMS0; @@ -311,76 +311,90 @@ main(void) max2_dims[0] = MAX_TWO_DIMS1; for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { - two_cbuf[i].field1 = 1; - two_cbuf[i].field2.a = 2; - two_cbuf[i].field2.c = 4; + two_cbuf[i].field1 = 1; + two_cbuf[i].field2.a = 2; + two_cbuf[i].field2.c = 4; two_cbuf[i].field2.b.a = 20; two_cbuf[i].field2.b.b = 40; two_cbuf[i].field2.b.c = 80; - two_cbuf[i].field3 = 3.0f; - two_cbuf[i].field4.a = 4; - two_cbuf[i].field4.b = 8; + two_cbuf[i].field3 = 3.0f; + two_cbuf[i].field4.a = 4; + two_cbuf[i].field4.b = 8; } /* end for */ /* Generate DSET_CMPD_TWO */ - if(generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) - goto done; + if (generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) + goto done; /* Create NULL dataspace */ - if((null_sid = H5Screate(H5S_NULL)) < 0) - goto done; + if ((null_sid = H5Screate(H5S_NULL)) < 0) + goto done; /* Create the NULL dataset */ - if((null_did = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_UINT, null_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto done; + if ((null_did = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_UINT, null_sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + goto done; /* Create SCALAR dataspace */ - if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) - goto done; + if ((scalar_sid = H5Screate(H5S_SCALAR)) < 0) + goto done; /* Create the SCALAR dataset */ - if((scalar_did = H5Dcreate2(fid, DSET_SCALAR, H5T_NATIVE_INT, scalar_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto done; + if ((scalar_did = H5Dcreate2(fid, DSET_SCALAR, H5T_NATIVE_INT, scalar_sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + goto done; /* Closing */ - if(H5Dclose(scalar_did) < 0) goto done; - if(H5Sclose(scalar_sid) < 0) goto done; + if (H5Dclose(scalar_did) < 0) + goto done; + if (H5Sclose(scalar_sid) < 0) + goto done; - if(H5Dclose(null_did) < 0) goto done; - if(H5Sclose(null_sid) < 0) goto done; + if (H5Dclose(null_did) < 0) + goto done; + if (H5Sclose(null_sid) < 0) + goto done; - if(H5Tclose(sub22_tid) < 0) goto done; - if(H5Tclose(sub2_tid) < 0) goto done; - if(H5Tclose(sub4_tid) < 0) goto done; - if(H5Tclose(set_tid) < 0) goto done; - if(H5Tclose(esc_sub2_tid) < 0) goto done; - if(H5Tclose(esc_sub4_tid) < 0) goto done; - if(H5Tclose(esc_set_tid) < 0) goto done; + if (H5Tclose(sub22_tid) < 0) + goto done; + if (H5Tclose(sub2_tid) < 0) + goto done; + if (H5Tclose(sub4_tid) < 0) + goto done; + if (H5Tclose(set_tid) < 0) + goto done; + if (H5Tclose(esc_sub2_tid) < 0) + goto done; + if (H5Tclose(esc_sub4_tid) < 0) + goto done; + if (H5Tclose(esc_set_tid) < 0) + goto done; - if(H5Pclose(fapl) < 0) goto done; - if(H5Fclose(fid) < 0) goto done; + if (H5Pclose(fapl) < 0) + goto done; + if (H5Fclose(fid) < 0) + goto done; exit(EXIT_SUCCESS); done: H5E_BEGIN_TRY - H5Tclose(sub22_tid); - H5Tclose(sub2_tid); - H5Tclose(sub4_tid); - H5Tclose(set_tid); - H5Tclose(esc_sub2_tid); - H5Tclose(esc_sub4_tid); - H5Tclose(esc_set_tid); - - H5Dclose(null_did); - H5Sclose(null_sid); - H5Dclose(scalar_did); - H5Sclose(scalar_sid); - - H5Pclose(fapl); - H5Fclose(fid); + H5Tclose(sub22_tid); + H5Tclose(sub2_tid); + H5Tclose(sub4_tid); + H5Tclose(set_tid); + H5Tclose(esc_sub2_tid); + H5Tclose(esc_sub4_tid); + H5Tclose(esc_set_tid); + + H5Dclose(null_did); + H5Sclose(null_sid); + H5Dclose(scalar_did); + H5Sclose(scalar_sid); + + H5Pclose(fapl); + H5Fclose(fid); H5E_END_TRY exit(EXIT_FAILURE); } /* main() */ - diff --git a/hl/test/h5hltest.h b/hl/test/h5hltest.h index 85f47bd..d694f0c 100644 --- a/hl/test/h5hltest.h +++ b/hl/test/h5hltest.h @@ -28,13 +28,24 @@ #include "H5HLprivate2.h" /* Macros used in HL tests */ -#define HL_TESTING2(WHAT) {HDprintf("Testing %-62s", WHAT); HDfflush(stdout);} -#define HL_TESTING3(WHAT) {HDprintf("Testing %-62s", WHAT); HDfflush(stdout);} +#define HL_TESTING2(WHAT) \ + { \ + HDprintf("Testing %-62s", WHAT); \ + HDfflush(stdout); \ + } +#define HL_TESTING3(WHAT) \ + { \ + HDprintf("Testing %-62s", WHAT); \ + HDfflush(stdout); \ + } /* Implements verbose 'assert' with 'goto error' exit */ -#define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0) +#define VERIFY(condition, string) \ + do { \ + if (!(condition)) \ + FAIL_PUTS_ERROR(string) \ + } while (0) int test_packet_table_with_varlen(void); #endif /* _H5HLTEST_H */ - diff --git a/hl/test/pal_rgb.h b/hl/test/pal_rgb.h index 4b22bea..a032a77 100644 --- a/hl/test/pal_rgb.h +++ b/hl/test/pal_rgb.h @@ -11,261 +11,41 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -const unsigned char pal_rgb[256*3] = {255,255,255, -0,0,131, -0,0,135, -0,0,139, -0,0,143, -0,0,147, -0,0,151, -0,0,155, -0,0,159, -0,0,163, -0,0,167, -0,0,171, -0,0,175, -0,0,179, -0,0,183, -0,0,187, -0,0,191, -0,0,195, -0,0,199, -0,0,203, -0,0,207, -0,0,211, -0,0,215, -0,0,219, -0,0,223, -0,0,227, -0,0,231, -0,0,235, -0,0,239, -0,0,243, -0,0,247, -0,0,251, -0,0,255, -0,0,255, -0,3,255, -0,7,255, -0,11,255, -0,15,255, -0,19,255, -0,23,255, -0,27,255, -0,31,255, -0,35,255, -0,39,255, -0,43,255, -0,47,255, -0,51,255, -0,55,255, -0,59,255, -0,63,255, -0,67,255, -0,71,255, -0,75,255, -0,79,255, -0,83,255, -0,87,255, -0,91,255, -0,95,255, -0,99,255, -0,103,255, -0,107,255, -0,111,255, -0,115,255, -0,119,255, -0,123,255, -0,127,255, -0,131,255, -0,135,255, -0,139,255, -0,143,255, -0,147,255, -0,151,255, -0,155,255, -0,159,255, -0,163,255, -0,167,255, -0,171,255, -0,175,255, -0,179,255, -0,183,255, -0,187,255, -0,191,255, -0,195,255, -0,199,255, -0,203,255, -0,207,255, -0,211,255, -0,215,255, -0,219,255, -0,223,255, -0,227,255, -0,231,255, -0,235,255, -0,239,255, -0,243,255, -0,247,255, -0,251,255, -0,255,255, -0,255,255, -3,255,251, -7,255,247, -11,255,243, -15,255,239, -19,255,235, -23,255,231, -27,255,227, -31,255,223, -35,255,219, -39,255,215, -43,255,211, -47,255,207, -51,255,203, -55,255,199, -59,255,195, -63,255,191, -67,255,187, -71,255,183, -75,255,179, -79,255,175, -83,255,171, -87,255,167, -91,255,163, -95,255,159, -99,255,155, -103,255,151, -107,255,147, -111,255,143, -115,255,139, -119,255,135, -123,255,131, -127,255,127, -131,255,123, -135,255,119, -139,255,115, -143,255,111, -147,255,107, -151,255,103, -155,255,99, -159,255,95, -163,255,91, -167,255,87, -171,255,83, -175,255,79, -179,255,75, -183,255,71, -187,255,67, -191,255,63, -195,255,59, -199,255,55, -203,255,51, -207,255,47, -211,255,43, -215,255,39, -219,255,35, -223,255,31, -227,255,27, -231,255,23, -235,255,19, -239,255,15, -243,255,11, -247,255,7, -251,255,3, -255,255,0, -255,251,0, -255,247,0, -255,243,0, -255,239,0, -255,235,0, -255,231,0, -255,227,0, -255,223,0, -255,219,0, -255,215,0, -255,211,0, -255,207,0, -255,203,0, -255,199,0, -255,195,0, -255,191,0, -255,187,0, -255,183,0, -255,179,0, -255,175,0, -255,171,0, -255,167,0, -255,163,0, -255,159,0, -255,155,0, -255,151,0, -255,147,0, -255,143,0, -255,139,0, -255,135,0, -255,131,0, -255,127,0, -255,123,0, -255,119,0, -255,115,0, -255,111,0, -255,107,0, -255,103,0, -255,99,0, -255,95,0, -255,91,0, -255,87,0, -255,83,0, -255,79,0, -255,75,0, -255,71,0, -255,67,0, -255,63,0, -255,59,0, -255,55,0, -255,51,0, -255,47,0, -255,43,0, -255,39,0, -255,35,0, -255,31,0, -255,27,0, -255,23,0, -255,19,0, -255,15,0, -255,11,0, -255,7,0, -255,3,0, -255,0,0, -250,0,0, -246,0,0, -241,0,0, -237,0,0, -233,0,0, -228,0,0, -224,0,0, -219,0,0, -215,0,0, -211,0,0, -206,0,0, -202,0,0, -197,0,0, -193,0,0, -189,0,0, -184,0,0, -180,0,0, -175,0,0, -171,0,0, -167,0,0, -162,0,0, -158,0,0, -153,0,0, -149,0,0, -145,0,0, -140,0,0, -136,0,0, -131,0,0, -127,0,0 -}; - +const unsigned char pal_rgb[256 * 3] = { + 255, 255, 255, 0, 0, 131, 0, 0, 135, 0, 0, 139, 0, 0, 143, 0, 0, 147, 0, 0, 151, + 0, 0, 155, 0, 0, 159, 0, 0, 163, 0, 0, 167, 0, 0, 171, 0, 0, 175, 0, 0, 179, + 0, 0, 183, 0, 0, 187, 0, 0, 191, 0, 0, 195, 0, 0, 199, 0, 0, 203, 0, 0, 207, + 0, 0, 211, 0, 0, 215, 0, 0, 219, 0, 0, 223, 0, 0, 227, 0, 0, 231, 0, 0, 235, + 0, 0, 239, 0, 0, 243, 0, 0, 247, 0, 0, 251, 0, 0, 255, 0, 0, 255, 0, 3, 255, + 0, 7, 255, 0, 11, 255, 0, 15, 255, 0, 19, 255, 0, 23, 255, 0, 27, 255, 0, 31, 255, + 0, 35, 255, 0, 39, 255, 0, 43, 255, 0, 47, 255, 0, 51, 255, 0, 55, 255, 0, 59, 255, + 0, 63, 255, 0, 67, 255, 0, 71, 255, 0, 75, 255, 0, 79, 255, 0, 83, 255, 0, 87, 255, + 0, 91, 255, 0, 95, 255, 0, 99, 255, 0, 103, 255, 0, 107, 255, 0, 111, 255, 0, 115, 255, + 0, 119, 255, 0, 123, 255, 0, 127, 255, 0, 131, 255, 0, 135, 255, 0, 139, 255, 0, 143, 255, + 0, 147, 255, 0, 151, 255, 0, 155, 255, 0, 159, 255, 0, 163, 255, 0, 167, 255, 0, 171, 255, + 0, 175, 255, 0, 179, 255, 0, 183, 255, 0, 187, 255, 0, 191, 255, 0, 195, 255, 0, 199, 255, + 0, 203, 255, 0, 207, 255, 0, 211, 255, 0, 215, 255, 0, 219, 255, 0, 223, 255, 0, 227, 255, + 0, 231, 255, 0, 235, 255, 0, 239, 255, 0, 243, 255, 0, 247, 255, 0, 251, 255, 0, 255, 255, + 0, 255, 255, 3, 255, 251, 7, 255, 247, 11, 255, 243, 15, 255, 239, 19, 255, 235, 23, 255, 231, + 27, 255, 227, 31, 255, 223, 35, 255, 219, 39, 255, 215, 43, 255, 211, 47, 255, 207, 51, 255, 203, + 55, 255, 199, 59, 255, 195, 63, 255, 191, 67, 255, 187, 71, 255, 183, 75, 255, 179, 79, 255, 175, + 83, 255, 171, 87, 255, 167, 91, 255, 163, 95, 255, 159, 99, 255, 155, 103, 255, 151, 107, 255, 147, + 111, 255, 143, 115, 255, 139, 119, 255, 135, 123, 255, 131, 127, 255, 127, 131, 255, 123, 135, 255, 119, + 139, 255, 115, 143, 255, 111, 147, 255, 107, 151, 255, 103, 155, 255, 99, 159, 255, 95, 163, 255, 91, + 167, 255, 87, 171, 255, 83, 175, 255, 79, 179, 255, 75, 183, 255, 71, 187, 255, 67, 191, 255, 63, + 195, 255, 59, 199, 255, 55, 203, 255, 51, 207, 255, 47, 211, 255, 43, 215, 255, 39, 219, 255, 35, + 223, 255, 31, 227, 255, 27, 231, 255, 23, 235, 255, 19, 239, 255, 15, 243, 255, 11, 247, 255, 7, + 251, 255, 3, 255, 255, 0, 255, 251, 0, 255, 247, 0, 255, 243, 0, 255, 239, 0, 255, 235, 0, + 255, 231, 0, 255, 227, 0, 255, 223, 0, 255, 219, 0, 255, 215, 0, 255, 211, 0, 255, 207, 0, + 255, 203, 0, 255, 199, 0, 255, 195, 0, 255, 191, 0, 255, 187, 0, 255, 183, 0, 255, 179, 0, + 255, 175, 0, 255, 171, 0, 255, 167, 0, 255, 163, 0, 255, 159, 0, 255, 155, 0, 255, 151, 0, + 255, 147, 0, 255, 143, 0, 255, 139, 0, 255, 135, 0, 255, 131, 0, 255, 127, 0, 255, 123, 0, + 255, 119, 0, 255, 115, 0, 255, 111, 0, 255, 107, 0, 255, 103, 0, 255, 99, 0, 255, 95, 0, + 255, 91, 0, 255, 87, 0, 255, 83, 0, 255, 79, 0, 255, 75, 0, 255, 71, 0, 255, 67, 0, + 255, 63, 0, 255, 59, 0, 255, 55, 0, 255, 51, 0, 255, 47, 0, 255, 43, 0, 255, 39, 0, + 255, 35, 0, 255, 31, 0, 255, 27, 0, 255, 23, 0, 255, 19, 0, 255, 15, 0, 255, 11, 0, + 255, 7, 0, 255, 3, 0, 255, 0, 0, 250, 0, 0, 246, 0, 0, 241, 0, 0, 237, 0, 0, + 233, 0, 0, 228, 0, 0, 224, 0, 0, 219, 0, 0, 215, 0, 0, 211, 0, 0, 206, 0, 0, + 202, 0, 0, 197, 0, 0, 193, 0, 0, 189, 0, 0, 184, 0, 0, 180, 0, 0, 175, 0, 0, + 171, 0, 0, 167, 0, 0, 162, 0, 0, 158, 0, 0, 153, 0, 0, 149, 0, 0, 145, 0, 0, + 140, 0, 0, 136, 0, 0, 131, 0, 0, 127, 0, 0}; diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 79e6f45..e98367f 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -29,27 +29,43 @@ static herr_t op_stop(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); /* prototypes */ static hid_t create_test_file(const char *fileext); static hid_t open_test_file(const char *fileext); -herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims); -herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims); -herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims); -herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims); -herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims); -herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf); -herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf); -herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf, char *s3_wbuf); -herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf); -herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf); -herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf, short *s3_wbuf); -herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf); -herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf); -herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf, int *s3_wbuf); -herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf); -herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf); -herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf); -herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf); -herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf); -herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf); -herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf, float *s3_wbuf); +herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims); +herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims); +herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims); +herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims); +herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims); +herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, + char *s1_wbuf); +herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, + char *s1_wbuf, char *s2_wbuf); +herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, + char *s1_wbuf, char *s2_wbuf, char *s3_wbuf); +herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, + short *s1_wbuf); +herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, + short *s1_wbuf, short *s2_wbuf); +herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, + short *s1_wbuf, short *s2_wbuf, short *s3_wbuf); +herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, + int *s1_wbuf); +herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, + int *s1_wbuf, int *s2_wbuf); +herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, + int *s1_wbuf, int *s2_wbuf, int *s3_wbuf); +herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, + long *s1_wbuf); +herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, + long *s1_wbuf, long *s2_wbuf); +herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, + long *s1_wbuf, long *s2_wbuf, long *s3_wbuf); +herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, + long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf); +herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, + float *s1_wbuf); +herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, + float *s1_wbuf, float *s2_wbuf); +herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, + float *s1_wbuf, float *s2_wbuf, float *s3_wbuf); herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx); herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx); herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx); @@ -78,64 +94,64 @@ static int test_rank(void); static int test_types(void); static int test_iterators(void); static int test_data(void); -static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf ); +static int read_data(const char *fname, int ndims, hsize_t *dims, float **buf); static int test_attach_detach(void); -#define RANK1 1 -#define RANK 2 -#define DIM_DATA 12 -#define DIM1_SIZE 3 -#define DIM2_SIZE 4 -#define DIM3_SIZE 12 -#define DIM4_SIZE 2 -#define DIM0 0 -#define DIM1 1 -#define DIM2 2 -#define DIM3 3 - -#define DATASET_NAME "dset_" -#define DS_1_NAME "ds_1_" -#define DS_11_NAME "ds_11_" -#define DS_2_NAME "ds_2_" -#define DS_21_NAME "ds_21_" -#define DS_22_NAME "ds_22_" -#define DS_3_NAME "ds_3_" -#define DS_31_NAME "ds_31_" -#define DS_32_NAME "ds_32_" -#define DS_33_NAME "ds_33_" -#define DS_4_NAME "ds_4_" -#define DS_41_NAME "ds_41_" -#define DS_42_NAME "ds_42_" -#define DS_43_NAME "ds_43_" -#define DS_44_NAME "ds_44_" - -#define SCALE_1_NAME "scalename_1_" -#define SCALE_11_NAME "scalename_11_" -#define SCALE_2_NAME "scalename_2_" -#define SCALE_21_NAME "scalename_21_" -#define SCALE_22_NAME "scalename_22_" -#define SCALE_3_NAME "scalename_3_" -#define SCALE_31_NAME "scalename_31_" -#define SCALE_32_NAME "scalename_32_" -#define SCALE_33_NAME "scalename_33_" -#define SCALE_4_NAME "scalename_4_" - -#define DIM0_LABEL "Latitude" -#define DIM1_LABEL "Longitude" - -#define FOREIGN_FILE1 "test_ds_le.h5" -#define FOREIGN_FILE2 "test_ds_be.h5" -#define FILENAME "test_ds" -#define FILEEXT ".h5" - -#define FILE1 "test_ds3.h5" -#define FILE2 "test_ds4.h5" -#define FILE3 "test_ds5.h5" -#define FILE4 "test_ds6.h5" -#define FILE5 "test_ds7.h5" -#define FILE6 "test_ds8.h5" -#define FILE7 "test_ds9.h5" -#define FILE8 "test_ds10.h5" +#define RANK1 1 +#define RANK 2 +#define DIM_DATA 12 +#define DIM1_SIZE 3 +#define DIM2_SIZE 4 +#define DIM3_SIZE 12 +#define DIM4_SIZE 2 +#define DIM0 0 +#define DIM1 1 +#define DIM2 2 +#define DIM3 3 + +#define DATASET_NAME "dset_" +#define DS_1_NAME "ds_1_" +#define DS_11_NAME "ds_11_" +#define DS_2_NAME "ds_2_" +#define DS_21_NAME "ds_21_" +#define DS_22_NAME "ds_22_" +#define DS_3_NAME "ds_3_" +#define DS_31_NAME "ds_31_" +#define DS_32_NAME "ds_32_" +#define DS_33_NAME "ds_33_" +#define DS_4_NAME "ds_4_" +#define DS_41_NAME "ds_41_" +#define DS_42_NAME "ds_42_" +#define DS_43_NAME "ds_43_" +#define DS_44_NAME "ds_44_" + +#define SCALE_1_NAME "scalename_1_" +#define SCALE_11_NAME "scalename_11_" +#define SCALE_2_NAME "scalename_2_" +#define SCALE_21_NAME "scalename_21_" +#define SCALE_22_NAME "scalename_22_" +#define SCALE_3_NAME "scalename_3_" +#define SCALE_31_NAME "scalename_31_" +#define SCALE_32_NAME "scalename_32_" +#define SCALE_33_NAME "scalename_33_" +#define SCALE_4_NAME "scalename_4_" + +#define DIM0_LABEL "Latitude" +#define DIM1_LABEL "Longitude" + +#define FOREIGN_FILE1 "test_ds_le.h5" +#define FOREIGN_FILE2 "test_ds_be.h5" +#define FILENAME "test_ds" +#define FILEEXT ".h5" + +#define FILE1 "test_ds3.h5" +#define FILE2 "test_ds4.h5" +#define FILE3 "test_ds5.h5" +#define FILE4 "test_ds6.h5" +#define FILE5 "test_ds7.h5" +#define FILE6 "test_ds8.h5" +#define FILE7 "test_ds9.h5" +#define FILE8 "test_ds10.h5" #define DIMENSION_LIST "DIMENSION_LIST" #define REFERENCE_LIST "REFERENCE_LIST" @@ -144,57 +160,57 @@ static int test_attach_detach(void); * the main program *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { - int nerrors=0; + int nerrors = 0; /* create file to be used in following tests */ - if(create_test_file("1") < 0) { + if (create_test_file("1") < 0) { nerrors = 1; goto error; } - nerrors += test_char_attachscales("1") < 0 ? 1 : 0; - nerrors += test_short_attachscales("1") < 0 ? 1 : 0; - nerrors += test_int_attachscales("1") < 0 ? 1 : 0; - nerrors += test_long_attachscales("1") < 0 ? 1 : 0; - nerrors += test_float_attachscales("1") < 0 ? 1 : 0; - nerrors += test_char_scalenames("1") < 0 ? 1 : 0; - nerrors += test_short_scalenames("1") < 0 ? 1 : 0; - nerrors += test_int_scalenames("1") < 0 ? 1 : 0; - nerrors += test_long_scalenames("1") < 0 ? 1 : 0; - nerrors += test_float_scalenames("1") < 0 ? 1 : 0; - nerrors += test_numberofscales("1") < 0 ? 1 : 0; - if(create_test_file("2") < 0) { + nerrors += test_char_attachscales("1") < 0 ? 1 : 0; + nerrors += test_short_attachscales("1") < 0 ? 1 : 0; + nerrors += test_int_attachscales("1") < 0 ? 1 : 0; + nerrors += test_long_attachscales("1") < 0 ? 1 : 0; + nerrors += test_float_attachscales("1") < 0 ? 1 : 0; + nerrors += test_char_scalenames("1") < 0 ? 1 : 0; + nerrors += test_short_scalenames("1") < 0 ? 1 : 0; + nerrors += test_int_scalenames("1") < 0 ? 1 : 0; + nerrors += test_long_scalenames("1") < 0 ? 1 : 0; + nerrors += test_float_scalenames("1") < 0 ? 1 : 0; + nerrors += test_numberofscales("1") < 0 ? 1 : 0; + if (create_test_file("2") < 0) { nerrors = 1; goto error; } - nerrors += test_long_attachscales("2") < 0 ? 1 : 0; - nerrors += test_duplicatelong_attachscales("2") < 0 ? 1 : 0; - nerrors += test_samelong_scalenames("2") < 0 ? 1 : 0; - nerrors += test_foreign_scaleattached(FOREIGN_FILE1) < 0 ? 1 : 0; - nerrors += test_foreign_scaleattached(FOREIGN_FILE2) < 0 ? 1 : 0; - nerrors += test_detachscales() < 0 ? 1 : 0; - nerrors += test_attach_detach() < 0 ? 1 : 0; -/* the following tests have not been rewritten to match those above */ - nerrors += test_simple() < 0 ?1:0; - nerrors += test_errors() < 0 ?1:0; - nerrors += test_errors2() < 0 ?1:0; - nerrors += test_rank() < 0 ?1:0; - nerrors += test_iterators() < 0 ?1:0; - nerrors += test_types() < 0 ?1:0; - nerrors += test_data() < 0 ?1:0; - - - if(nerrors) goto error; + nerrors += test_long_attachscales("2") < 0 ? 1 : 0; + nerrors += test_duplicatelong_attachscales("2") < 0 ? 1 : 0; + nerrors += test_samelong_scalenames("2") < 0 ? 1 : 0; + nerrors += test_foreign_scaleattached(FOREIGN_FILE1) < 0 ? 1 : 0; + nerrors += test_foreign_scaleattached(FOREIGN_FILE2) < 0 ? 1 : 0; + nerrors += test_detachscales() < 0 ? 1 : 0; + nerrors += test_attach_detach() < 0 ? 1 : 0; + /* the following tests have not been rewritten to match those above */ + nerrors += test_simple() < 0 ? 1 : 0; + nerrors += test_errors() < 0 ? 1 : 0; + nerrors += test_errors2() < 0 ? 1 : 0; + nerrors += test_rank() < 0 ? 1 : 0; + nerrors += test_iterators() < 0 ? 1 : 0; + nerrors += test_types() < 0 ? 1 : 0; + nerrors += test_data() < 0 ? 1 : 0; + + if (nerrors) + goto error; HDprintf("All dimension scales tests passed.\n"); return 0; error: - HDprintf("***** %d DIMENSION SCALES TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d DIMENSION SCALES TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } - /*------------------------------------------------------------------------- * DS API test * @@ -213,7 +229,8 @@ error: *------------------------------------------------------------------------- */ -static hid_t create_test_file(const char *fileext) +static hid_t +create_test_file(const char *fileext) { char filename[65]; @@ -222,7 +239,8 @@ static hid_t create_test_file(const char *fileext) return H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); } -static hid_t open_test_file(const char *fileext) +static hid_t +open_test_file(const char *fileext) { char filename[65]; @@ -235,261 +253,270 @@ static hid_t open_test_file(const char *fileext) * create "data" dataset *------------------------------------------------------------------------- */ -herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims) +herr_t +create_char_dataset(hid_t fid, const char *dsidx, int fulldims) { - int rank = 3; - int rankds = 1; - hsize_t dims[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; - char buf[DIM1_SIZE*DIM2_SIZE*DIM3_SIZE]; - hsize_t s1_dim[1] = {DIM1_SIZE}; - hsize_t s2_dim[1] = {DIM2_SIZE}; - hsize_t s3_dim[1] = {DIM3_SIZE}; - char s1_wbuf[DIM1_SIZE] = {1,2,3}; - char s11_wbuf[DIM1_SIZE] = {10,20,30}; - char s2_wbuf[DIM2_SIZE] = {10,20,30,40}; - char s21_wbuf[DIM2_SIZE] = {1,2,3,4}; - char s22_wbuf[DIM2_SIZE] = {5,10,50,100}; - char s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40}; - char s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4}; - char s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100}; - char s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,120,120,120}; + int rank = 3; + int rankds = 1; + hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE}; + char buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE]; + hsize_t s1_dim[1] = {DIM1_SIZE}; + hsize_t s2_dim[1] = {DIM2_SIZE}; + hsize_t s3_dim[1] = {DIM3_SIZE}; + char s1_wbuf[DIM1_SIZE] = {1, 2, 3}; + char s11_wbuf[DIM1_SIZE] = {10, 20, 30}; + char s2_wbuf[DIM2_SIZE] = {10, 20, 30, 40}; + char s21_wbuf[DIM2_SIZE] = {1, 2, 3, 4}; + char s22_wbuf[DIM2_SIZE] = {5, 10, 50, 100}; + char s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40}; + char s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; + char s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100}; + char s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 120, 120, 120}; char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx); /* make a dataset */ - if(H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) { - if(fulldims==0) { + if (H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) { + if (fulldims == 0) { /* make a DS dataset for the first dimension */ - if(create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) - return FAIL; + if (create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) + return FAIL; /* make a DS dataset for the second dimension */ - if(create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) - return FAIL; + if (create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) + return FAIL; /* make a DS dataset for the third dimension */ - if(create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0) - return FAIL; + if (create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0) + return FAIL; } else { - if(create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) - return FAIL; + if (create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) + return FAIL; - if(create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) - return FAIL; + if (create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) + return FAIL; - if(create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0) - return FAIL; + if (create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < + 0) + return FAIL; } - } - else - return FAIL; + } + else + return FAIL; return SUCCEED; } -herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims) +herr_t +create_short_dataset(hid_t fid, const char *dsidx, int fulldims) { - int rank = 3; - int rankds = 1; - hsize_t dims[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; - short buf[DIM1_SIZE*DIM2_SIZE*DIM3_SIZE]; - hsize_t s1_dim[1] = {DIM1_SIZE}; - hsize_t s2_dim[1] = {DIM2_SIZE}; - hsize_t s3_dim[1] = {DIM3_SIZE}; - short s1_wbuf[DIM1_SIZE] = {10,20,30}; - short s11_wbuf[DIM1_SIZE] = {10,100,300}; - short s2_wbuf[DIM2_SIZE] = {100,200,300,400}; - short s21_wbuf[DIM2_SIZE] = {10,20,30,40}; - short s22_wbuf[DIM2_SIZE] = {5,10,50,300}; - short s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40}; - short s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4}; - short s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100}; - short s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,140,140,140}; + int rank = 3; + int rankds = 1; + hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE}; + short buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE]; + hsize_t s1_dim[1] = {DIM1_SIZE}; + hsize_t s2_dim[1] = {DIM2_SIZE}; + hsize_t s3_dim[1] = {DIM3_SIZE}; + short s1_wbuf[DIM1_SIZE] = {10, 20, 30}; + short s11_wbuf[DIM1_SIZE] = {10, 100, 300}; + short s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400}; + short s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40}; + short s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300}; + short s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40}; + short s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; + short s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100}; + short s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 140, 140, 140}; char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx); /* make a dataset */ - if(H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) { - if(fulldims==0) { + if (H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) { + if (fulldims == 0) { /* make a DS dataset for the first dimension */ - if(create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) - return FAIL; + if (create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) + return FAIL; /* make a DS dataset for the second dimension */ - if(create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) - return FAIL; + if (create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) + return FAIL; /* make a DS dataset for the third dimension */ - if(create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0) - return FAIL; + if (create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0) + return FAIL; } else { - if(create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) - return FAIL; + if (create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) + return FAIL; - if(create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) - return FAIL; + if (create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) + return FAIL; - if(create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0) - return FAIL; + if (create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < + 0) + return FAIL; } - } - else - return FAIL; + } + else + return FAIL; return SUCCEED; } -herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims) +herr_t +create_int_dataset(hid_t fid, const char *dsidx, int fulldims) { - int rank = RANK; - int rankds = 1; - hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; - int buf[DIM1_SIZE*DIM2_SIZE]; - hsize_t s1_dim[1] = {DIM1_SIZE}; - hsize_t s2_dim[1] = {DIM2_SIZE}; - int s1_wbuf[DIM1_SIZE] = {10,20,30}; - int s11_wbuf[DIM1_SIZE] = {10,100,300}; - int s2_wbuf[DIM2_SIZE] = {100,200,300,400}; - int s21_wbuf[DIM2_SIZE] = {10,20,30,40}; - int s22_wbuf[DIM2_SIZE] = {5,10,50,300}; + int rank = RANK; + int rankds = 1; + hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; + int buf[DIM1_SIZE * DIM2_SIZE]; + hsize_t s1_dim[1] = {DIM1_SIZE}; + hsize_t s2_dim[1] = {DIM2_SIZE}; + int s1_wbuf[DIM1_SIZE] = {10, 20, 30}; + int s11_wbuf[DIM1_SIZE] = {10, 100, 300}; + int s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400}; + int s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40}; + int s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300}; char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx); /* make a dataset */ - if(H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) { - if(fulldims==0) { + if (H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) { + if (fulldims == 0) { /* make a DS dataset for the first dimension */ - if(create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) - return FAIL; + if (create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) + return FAIL; /* make a DS dataset for the second dimension */ - if(create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) - return FAIL; + if (create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) + return FAIL; } else { - if(create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) - return FAIL; + if (create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) + return FAIL; - if(create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) - return FAIL; + if (create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) + return FAIL; } - } - else - return FAIL; + } + else + return FAIL; return SUCCEED; } -herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims) +herr_t +create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims) { - int rank = 4; - int rankds = 1; - hsize_t dims[4] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE,DIM4_SIZE}; - long *buf; - hsize_t s1_dim[1] = {DIM1_SIZE}; - hsize_t s2_dim[1] = {DIM2_SIZE}; - hsize_t s3_dim[1] = {DIM3_SIZE}; - hsize_t s4_dim[1] = {DIM4_SIZE}; - long s1_wbuf[DIM1_SIZE] = {10,20,30}; - long s11_wbuf[DIM1_SIZE] = {10,100,300}; - long s2_wbuf[DIM2_SIZE] = {100,200,300,400}; - long s21_wbuf[DIM2_SIZE] = {10,20,30,40}; - long s22_wbuf[DIM2_SIZE] = {5,10,50,300}; - long s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40}; - long s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4}; - long s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100}; - long s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,140,140,140}; - long s4_wbuf[DIM4_SIZE] = {18,18}; - long s41_wbuf[DIM4_SIZE] = {8,8}; - long s42_wbuf[DIM4_SIZE] = {80,80}; - long s43_wbuf[DIM4_SIZE] = {180,180}; - long s44_wbuf[DIM4_SIZE] = {280,280}; + int rank = 4; + int rankds = 1; + hsize_t dims[4] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE, DIM4_SIZE}; + long * buf; + hsize_t s1_dim[1] = {DIM1_SIZE}; + hsize_t s2_dim[1] = {DIM2_SIZE}; + hsize_t s3_dim[1] = {DIM3_SIZE}; + hsize_t s4_dim[1] = {DIM4_SIZE}; + long s1_wbuf[DIM1_SIZE] = {10, 20, 30}; + long s11_wbuf[DIM1_SIZE] = {10, 100, 300}; + long s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400}; + long s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40}; + long s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300}; + long s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40}; + long s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; + long s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100}; + long s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 140, 140, 140}; + long s4_wbuf[DIM4_SIZE] = {18, 18}; + long s41_wbuf[DIM4_SIZE] = {8, 8}; + long s42_wbuf[DIM4_SIZE] = {80, 80}; + long s43_wbuf[DIM4_SIZE] = {180, 180}; + long s44_wbuf[DIM4_SIZE] = {280, 280}; /* Allocate buffer */ - if(NULL == (buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE))) - return FAIL; + if (NULL == (buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE))) + return FAIL; /* make a dataset */ - if(H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) { - if(fulldims==0) { + if (H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) { + if (fulldims == 0) { /* make a DS dataset for the first dimension */ - if(create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) - return FAIL; + if (create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) + return FAIL; /* make a DS dataset for the second dimension */ - if(create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) - return FAIL; + if (create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) + return FAIL; /* make a DS dataset for the third dimension */ - if(create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0) - return FAIL; + if (create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0) + return FAIL; /* make a DS dataset for the fourth dimension */ - if(create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, NULL, NULL, NULL, NULL) < 0) - return FAIL; + if (create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, NULL, NULL, NULL, NULL) < 0) + return FAIL; } else { - if(create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) - return FAIL; + if (create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) + return FAIL; - if(create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) - return FAIL; + if (create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) + return FAIL; - if(create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0) - return FAIL; + if (create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < + 0) + return FAIL; - if(create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, s41_wbuf, s42_wbuf, s43_wbuf, s44_wbuf) < 0) - return FAIL; + if (create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, s41_wbuf, s42_wbuf, s43_wbuf, + s44_wbuf) < 0) + return FAIL; } - } - else - return FAIL; + } + else + return FAIL; HDfree(buf); return SUCCEED; } -herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims) +herr_t +create_float_dataset(hid_t fid, const char *dsidx, int fulldims) { - int rank = RANK; - int rankds = 1; - hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; - float buf[DIM1_SIZE*DIM2_SIZE]; - hsize_t s1_dim[1] = {DIM1_SIZE}; - hsize_t s2_dim[1] = {DIM2_SIZE}; - float s1_wbuf[DIM1_SIZE] = {10,20,30}; - float s11_wbuf[DIM1_SIZE] = {10,100,300}; - float s2_wbuf[DIM2_SIZE] = {100,200,300,400}; - float s21_wbuf[DIM2_SIZE] = {10,20,30,40}; - float s22_wbuf[DIM2_SIZE] = {5,10,50,300}; + int rank = RANK; + int rankds = 1; + hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; + float buf[DIM1_SIZE * DIM2_SIZE]; + hsize_t s1_dim[1] = {DIM1_SIZE}; + hsize_t s2_dim[1] = {DIM2_SIZE}; + float s1_wbuf[DIM1_SIZE] = {10, 20, 30}; + float s11_wbuf[DIM1_SIZE] = {10, 100, 300}; + float s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400}; + float s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40}; + float s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300}; char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx); /* make a dataset */ - if(H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) { - if(fulldims==0) { + if (H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) { + if (fulldims == 0) { /* make a DS dataset for the first dimension */ - if(create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) - return FAIL; + if (create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) + return FAIL; /* make a DS dataset for the second dimension */ - if(create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) - return FAIL; + if (create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0) + return FAIL; } else { - if(create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) - return FAIL; + if (create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0) + return FAIL; - if(create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) - return FAIL; + if (create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0) + return FAIL; } - } - else - return FAIL; + } + else + return FAIL; return SUCCEED; } @@ -497,21 +524,23 @@ herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims) * create 2 dimension scales datasets for first dimension *------------------------------------------------------------------------- */ -herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf) +herr_t +create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, + char *s1_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } @@ -522,29 +551,31 @@ herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ * create 3 dimension scales datasets for second dimension *------------------------------------------------------------------------- */ -herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf) +herr_t +create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, + char *s1_wbuf, char *s2_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx); /* make a DS dataset for the second dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } @@ -555,37 +586,39 @@ herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ * create 1 dimension scales datasets for third dimension of dataset *------------------------------------------------------------------------- */ -herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf, char *s3_wbuf) +herr_t +create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, + char *s1_wbuf, char *s2_wbuf, char *s3_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } - if(s3_wbuf != NULL) { + if (s3_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s3_wbuf) < 0) + if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; } @@ -596,21 +629,23 @@ herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ * create 2 dimension scales datasets for first dimension *------------------------------------------------------------------------- */ -herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf) +herr_t +create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, + short *s1_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } @@ -621,29 +656,31 @@ herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize * create 3 dimension scales datasets for second dimension *------------------------------------------------------------------------- */ -herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf) +herr_t +create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, + short *s1_wbuf, short *s2_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx); /* make a DS dataset for the second dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } @@ -654,37 +691,39 @@ herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize * create 1 dimension scales datasets for third dimension of dataset *------------------------------------------------------------------------- */ -herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf, short *s3_wbuf) +herr_t +create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, + short *s1_wbuf, short *s2_wbuf, short *s3_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } - if(s3_wbuf != NULL) { + if (s3_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s3_wbuf) < 0) + if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; } @@ -695,21 +734,22 @@ herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize * create 2 dimension scales datasets for first dimension *------------------------------------------------------------------------- */ -herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf) +herr_t +create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } @@ -720,29 +760,31 @@ herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t * create 3 dimension scales datasets for second dimension *------------------------------------------------------------------------- */ -herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf) +herr_t +create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, + int *s2_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx); /* make a DS dataset for the second dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } @@ -753,37 +795,39 @@ herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t * create 1 dimension scales datasets for third dimension of dataset *------------------------------------------------------------------------- */ -herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf, int *s3_wbuf) +herr_t +create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, + int *s2_wbuf, int *s3_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } - if(s3_wbuf != NULL) { + if (s3_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ - if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s3_wbuf) < 0) + if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; } @@ -794,21 +838,23 @@ herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t * create 2 dimension scales datasets for first dimension *------------------------------------------------------------------------- */ -herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf) +herr_t +create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, + long *s1_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } @@ -819,29 +865,31 @@ herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ * create 3 dimension scales datasets for second dimension *------------------------------------------------------------------------- */ -herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf) +herr_t +create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, + long *s1_wbuf, long *s2_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx); /* make a DS dataset for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } @@ -852,37 +900,39 @@ herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ * create 3 dimension scales datasets for third dimension of dataset *------------------------------------------------------------------------- */ -herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf) +herr_t +create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, + long *s1_wbuf, long *s2_wbuf, long *s3_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } - if(s3_wbuf != NULL) { + if (s3_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; } @@ -893,45 +943,47 @@ herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ * create 4 dimension scales datasets for third dimension of dataset *------------------------------------------------------------------------- */ -herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf) +herr_t +create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, + long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_4_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_41_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_42_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } - if(s3_wbuf != NULL) { + if (s3_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_43_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; } - if(s4_wbuf != NULL) { + if (s4_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_44_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s4_wbuf) < 0) + if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s4_wbuf) < 0) return FAIL; } @@ -942,21 +994,23 @@ herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ * create 2 dimension scales datasets for first dimension *------------------------------------------------------------------------- */ -herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf) +herr_t +create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, + float *s1_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } @@ -967,29 +1021,31 @@ herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize * create 3 dimension scales datasets for second dimension *------------------------------------------------------------------------- */ -herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf) +herr_t +create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, + float *s1_wbuf, float *s2_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx); /* make a DS dataset for the second dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } @@ -1000,144 +1056,151 @@ herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize * create 3 dimension scales datasets for third dimension of dataset *------------------------------------------------------------------------- */ -herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf, float *s3_wbuf) +herr_t +create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, + float *s1_wbuf, float *s2_wbuf, float *s3_wbuf) { char name[64]; HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx); /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; - if(s1_wbuf != NULL) { + if (s1_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } - if(s2_wbuf != NULL) { + if (s2_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } - if(s3_wbuf != NULL) { + if (s3_wbuf != NULL) { HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ - if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s3_wbuf) < 0) + if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; } return SUCCEED; } -herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx) +herr_t +test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx) { - herr_t ret_value = FAIL; - hid_t dsid = -1; + herr_t ret_value = FAIL; + hid_t dsid = -1; - if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 0) { - if(H5DSattach_scale(did, dsid, idx) >= 0) { - if(H5DSis_attached(did, dsid, idx) > 0) { + if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 0) { + if (H5DSattach_scale(did, dsid, idx) >= 0) { + if (H5DSis_attached(did, dsid, idx) > 0) { ret_value = SUCCEED; } - else if(H5DSis_attached(did, dsid, idx) == 0) { + else if (H5DSis_attached(did, dsid, idx) == 0) { HDprintf(" scale not attached "); } } } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) ret_value = FAIL; } return ret_value; } -herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx) +herr_t +test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx) { - herr_t ret_value = FAIL; - hid_t dsid = -1; + herr_t ret_value = FAIL; + hid_t dsid = -1; - if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 1) { - if(H5DSdetach_scale(did, dsid, idx) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 0) { + if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 1) { + if (H5DSdetach_scale(did, dsid, idx) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 0) { ret_value = SUCCEED; } } } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) ret_value = FAIL; } return ret_value; } -herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx) +herr_t +test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx) { - herr_t ret_value = FAIL; - hid_t dsid = -1; + herr_t ret_value = FAIL; + hid_t dsid = -1; - if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 1) { - if(H5DSset_scale(dsid, scalename) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 1) { - ret_value = SUCCEED; + if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 1) { + if (H5DSset_scale(dsid, scalename) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 1) { + ret_value = SUCCEED; } } } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) ret_value = FAIL; } return ret_value; } -herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx) +herr_t +test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx) { herr_t ret_value = FAIL; - hid_t dsid = -1; + hid_t dsid = -1; ssize_t name_len; - char *name_out=NULL; - - if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, idx) == 1) { - if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) { - name_out = (char*)HDmalloc(((size_t)name_len+1) * sizeof (char)); - if(name_out != NULL) { - if(H5DSget_scale_name(dsid, name_out, (size_t)name_len+1) >= 0) { - if(HDstrncmp(scalename, name_out, (size_t)name_len)==0) { + char * name_out = NULL; + + if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, idx) == 1) { + if ((name_len = H5DSget_scale_name(dsid, NULL, (size_t)0)) > 0) { + name_out = (char *)HDmalloc(((size_t)name_len + 1) * sizeof(char)); + if (name_out != NULL) { + if (H5DSget_scale_name(dsid, name_out, (size_t)name_len + 1) >= 0) { + if (HDstrncmp(scalename, name_out, (size_t)name_len) == 0) { ret_value = SUCCEED; } HDfree(name_out); - name_out=NULL; + name_out = NULL; } } } } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) ret_value = FAIL; } return ret_value; } -static int test_detachscales(void) +static int +test_detachscales(void) { - hid_t fid = -1; - hid_t did = -1; - hid_t dsid = -1; - int rank1 = 1; - int rank3 = 3; - hsize_t dims[] = {1,2,3}; /*some bogus numbers, not important for the test*/ - int *buf = NULL; + hid_t fid = -1; + hid_t did = -1; + hid_t dsid = -1; + int rank1 = 1; + int rank3 = 3; + hsize_t dims[] = {1, 2, 3}; /*some bogus numbers, not important for the test*/ + int * buf = NULL; char dname[16]; int i; @@ -1148,52 +1211,52 @@ static int test_detachscales(void) HL_TESTING2("test_detachscales"); - if((fid = H5Fcreate("test_detach.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate("test_detach.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* make datasets; they are three dimensional*/ - for (i=0; i < 2; i++) { - HDsprintf(dname,"D%d", i); - if(H5LTmake_dataset_int(fid, dname, rank3, dims, buf) < 0) + for (i = 0; i < 2; i++) { + HDsprintf(dname, "D%d", i); + if (H5LTmake_dataset_int(fid, dname, rank3, dims, buf) < 0) goto out; } /* create datasets and make them dim. scales */ - for (i=0; i < 4; i++) { + for (i = 0; i < 4; i++) { HDsprintf(dname, "DS%d", i); - if(H5LTmake_dataset_int(fid, dname, rank1, dims, buf) < 0) + if (H5LTmake_dataset_int(fid, dname, rank1, dims, buf) < 0) goto out; } /* attach scales to the first dataset; first dimension will have two scales attached */ - if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) { - for (i=0; i<4; i++) { - HDsprintf(dname, "DS%d", i); - if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) - goto out; - if(H5DSattach_scale(did, dsid, (unsigned int) i%3) < 0) - goto out; - if(H5Dclose(dsid) < 0) - goto out; + if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) { + for (i = 0; i < 4; i++) { + HDsprintf(dname, "DS%d", i); + if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto out; + if (H5DSattach_scale(did, dsid, (unsigned int)i % 3) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else goto out; - /* attach scales to the second dataset */ - if((did = H5Dopen2(fid, "D1", H5P_DEFAULT)) >= 0) { - for (i=0; i<3; i++) { - HDsprintf(dname, "DS%d", i); - if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) - goto out; - if(H5DSattach_scale(did, dsid, (unsigned int) i) < 0) - goto out; - if(H5Dclose(dsid) < 0) - goto out; + /* attach scales to the second dataset */ + if ((did = H5Dopen2(fid, "D1", H5P_DEFAULT)) >= 0) { + for (i = 0; i < 3; i++) { + HDsprintf(dname, "DS%d", i); + if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto out; + if (H5DSattach_scale(did, dsid, (unsigned int)i) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1202,107 +1265,109 @@ static int test_detachscales(void) /* detach DS0 from first dimension of D0 and D1; then check that DS0 doesn't have attribute REFERENCE _LIST */ - if((dsid = H5Dopen2(fid, "DS0", H5P_DEFAULT)) < 0) - goto out; + if ((dsid = H5Dopen2(fid, "DS0", H5P_DEFAULT)) < 0) + goto out; - for (i=0; i<2; i++) { + for (i = 0; i < 2; i++) { HDsprintf(dname, "D%d", i); - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto out; - if(H5DSdetach_scale(did, dsid, (unsigned int)0) < 0) + if (H5DSdetach_scale(did, dsid, (unsigned int)0) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } /* Check that attribute "REFERENCE_LIST" doesn't exist anymore */ - if(H5Aexists(dsid, REFERENCE_LIST)!= 0) + if (H5Aexists(dsid, REFERENCE_LIST) != 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* Check that DS3 is the only dim. scale attached to the first dimension of D0 */ - if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) < 0) goto out; - if((dsid = H5Dopen2(fid, "DS3", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "DS3", H5P_DEFAULT)) < 0) goto out; - if(H5DSis_attached(did, dsid, (unsigned int) 0) <= 0) + if (H5DSis_attached(did, dsid, (unsigned int)0) <= 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* Detach the rest of the scales DS3, DS1, DS2 from D0 and make sure that attribute "DIMENSION_LIST" doesn't exist anymore */ - if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) { - for (i=1; i<4; i++) { - HDsprintf(dname, "DS%d", i); - if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) - goto out; - if(H5DSdetach_scale(did, dsid, (unsigned int) i%3) < 0) - goto out; - if(H5Dclose(dsid) < 0) - goto out; + if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) { + for (i = 1; i < 4; i++) { + HDsprintf(dname, "DS%d", i); + if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto out; + if (H5DSdetach_scale(did, dsid, (unsigned int)i % 3) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; } /* Check that attribute "DIMENSION_LIST" doesn't exist anymore */ - if(H5Aexists(did, DIMENSION_LIST)!= 0) + if (H5Aexists(did, DIMENSION_LIST) != 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else goto out; - PASSED(); H5Fclose(fid); return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Dclose(dsid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_char_attachscales(const char *fileext) +static int +test_char_attachscales(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "ac"); HL_TESTING2("test_char_attachscales"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; /* make a dataset */ - if(create_char_dataset(fid, "ac", 0) < 0) + if (create_char_dataset(fid, "ac", 0) < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "ac"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "ac"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "ac"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1314,72 +1379,75 @@ static int test_char_attachscales(const char *fileext) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_short_attachscales(const char *fileext) +static int +test_short_attachscales(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "as"); HL_TESTING2("test_short_attachscales"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; /* make a dataset */ - if(create_short_dataset(fid, "as", 1) < 0) + if (create_short_dataset(fid, "as", 1) < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_31_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_32_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_33_NAME, "as"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1391,56 +1459,59 @@ static int test_short_attachscales(const char *fileext) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_int_attachscales(const char *fileext) +static int +test_int_attachscales(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a"); HL_TESTING2("test_int_attachscales"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; /* make a dataset */ - if(create_int_dataset(fid, "a", 1) < 0) + if (create_int_dataset(fid, "a", 1) < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "a"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "a"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "a"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "a"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "a"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1452,52 +1523,55 @@ static int test_int_attachscales(const char *fileext) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_long_attachscales(const char *fileext) +static int +test_long_attachscales(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al"); HL_TESTING2("test_long_attachscales"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; /* make a dataset */ - if(create_long_dataset(fid, dsname, "al", 0) < 0) + if (create_long_dataset(fid, dsname, "al", 0) < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al"); - if(test_attach_scale(fid, did, scalename, DIM3) < 0) + if (test_attach_scale(fid, did, scalename, DIM3) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1509,52 +1583,55 @@ static int test_long_attachscales(const char *fileext) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_duplicatelong_attachscales(const char *fileext) +static int +test_duplicatelong_attachscales(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al2"); HL_TESTING2("test_duplicatelong_attachscales"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; /* make a dataset 2 */ - if(create_long_dataset(fid, dsname, "al2", 0) < 0) + if (create_long_dataset(fid, dsname, "al2", 0) < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al"); - if(test_attach_scale(fid, did, scalename, DIM2) < 0) + if (test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al"); - if(test_attach_scale(fid, did, scalename, DIM3) < 0) + if (test_attach_scale(fid, did, scalename, DIM3) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1566,56 +1643,59 @@ static int test_duplicatelong_attachscales(const char *fileext) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_float_attachscales(const char *fileext) +static int +test_float_attachscales(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "af"); HL_TESTING2("test_float_attachscales"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; /* make a dataset */ - if(create_float_dataset(fid, "af", 1) < 0) + if (create_float_dataset(fid, "af", 1) < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "af"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "af"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "af"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "af"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "af"); - if(test_attach_scale(fid, did, scalename, DIM1) < 0) + if (test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1627,45 +1707,48 @@ static int test_float_attachscales(const char *fileext) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_numberofscales(const char *fileext) +static int +test_numberofscales(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - int nscales; /* number of scales in DIM */ - char dsname[32]; - char scalename[32]; + hid_t fid = -1; + hid_t did = -1; + int nscales; /* number of scales in DIM */ + char dsname[32]; + char scalename[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a"); HL_TESTING2("test_numberofscales"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - if((nscales = H5DSget_num_scales(did, 0)) < 0) + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((nscales = H5DSget_num_scales(did, 0)) < 0) goto out; - if(nscales != 2) + if (nscales != 2) goto out; - if((nscales = H5DSget_num_scales(did, 1)) < 0) + if ((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; - if(nscales != 3) + if (nscales != 3) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1674,28 +1757,28 @@ static int test_numberofscales(const char *fileext) HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "b"); /* make a dataset */ - if(create_int_dataset(fid, "b", 1) < 0) + if (create_int_dataset(fid, "b", 1) < 0) goto out; /* make a DS dataset for the first dimension */ - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "b"); - if(test_attach_scale(fid, did, scalename, DIM0) < 0) + if (test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - if((nscales = H5DSget_num_scales(did, 0)) < 0) + if ((nscales = H5DSget_num_scales(did, 0)) < 0) goto out; - if(nscales != 1) + if (nscales != 1) goto out; - if((nscales = H5DSget_num_scales(did, 1)) < 0) + if ((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; - if(nscales != 0) + if (nscales != 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1707,55 +1790,59 @@ static int test_numberofscales(const char *fileext) return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_char_scalenames(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; - char name[32]; +static int +test_char_scalenames(const char *fileext) +{ + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; + char name[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "ac"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; HL_TESTING2("set char scale/cmp scale name"); - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "ac"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "ac"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "ac"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "ac"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "ac"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "ac"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1767,103 +1854,107 @@ static int test_char_scalenames(const char *fileext) { return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_short_scalenames(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; - char name[32]; +static int +test_short_scalenames(const char *fileext) +{ + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; + char name[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "as"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; HL_TESTING2("set short scale/cmp scale name"); - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_31_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_31_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_32_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_32_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_33_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_33_NAME, "as"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1875,71 +1966,75 @@ static int test_short_scalenames(const char *fileext) { return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_int_scalenames(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; - char name[32]; +static int +test_int_scalenames(const char *fileext) +{ + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; + char name[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; HL_TESTING2("set int scale/cmp scale name"); - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "a"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "a"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "a"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "a"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "a"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "a"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "a"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "a"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "a"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "a"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -1951,63 +2046,67 @@ static int test_int_scalenames(const char *fileext) { return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_long_scalenames(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; - char name[32]; +static int +test_long_scalenames(const char *fileext) +{ + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; + char name[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; HL_TESTING2("set long scale/cmp scale name"); - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_4_NAME, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM3) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM3) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -2019,63 +2118,67 @@ static int test_long_scalenames(const char *fileext) { return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_samelong_scalenames(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; - char name[32]; +static int +test_samelong_scalenames(const char *fileext) +{ + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; + char name[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al2"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; HL_TESTING2("set same long scale/cmp scale name"); - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", DS_4_NAME, "al"); - if(test_set_scalename(fid, did, scalename, name, DIM3) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM3) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -2087,71 +2190,75 @@ static int test_samelong_scalenames(const char *fileext) { return SUCCEED; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_float_scalenames(const char *fileext) { - hid_t fid = -1; - hid_t did = -1; - char dsname[32]; - char scalename[32]; - char name[32]; +static int +test_float_scalenames(const char *fileext) +{ + hid_t fid = -1; + hid_t did = -1; + char dsname[32]; + char scalename[32]; + char name[32]; HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "af"); - if((fid = open_test_file(fileext)) < 0) + if ((fid = open_test_file(fileext)) < 0) goto out; HL_TESTING2("set float scale/cmp scale name"); - if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { + if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "af"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "af"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "af"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "af"); - if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "af"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "af"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "af"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "af"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "af"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "af"); - if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) + if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else @@ -2163,44 +2270,47 @@ static int test_float_scalenames(const char *fileext) { return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_foreign_scaleattached(const char *fileforeign) +static int +test_foreign_scaleattached(const char *fileforeign) { - herr_t ret_value = FAIL; - hid_t fid = -1; - hid_t did = -1; - hid_t dsid = -1; - const char *filename = H5_get_srcdir_filename(fileforeign); + herr_t ret_value = FAIL; + hid_t fid = -1; + hid_t did = -1; + hid_t dsid = -1; + const char *filename = H5_get_srcdir_filename(fileforeign); HL_TESTING2("test_foreign_scaleattached"); - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto out; - if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) { - if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) { - if(H5DSis_attached(did, dsid, 3) == 1) { + if ((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) { + if ((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) { + if (H5DSis_attached(did, dsid, 3) == 1) { ret_value = SUCCEED; } - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } else goto out; - if(ret_value == FAIL) + if (ret_value == FAIL) goto out; PASSED(); @@ -2209,1225 +2319,1206 @@ static int test_foreign_scaleattached(const char *fileforeign) return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } -static int test_simple(void) +static int +test_simple(void) { - hid_t fid = -1; - hid_t did = -1; - hid_t dsid = -1; - hid_t sid = -1; - hid_t gid = -1; - int rank = RANK; - int rankds = 1; - hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; - int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12}; - hsize_t s1_dim[1] = {DIM1_SIZE}; - hsize_t s2_dim[1] = {DIM2_SIZE}; - char sname[30]; - char dname[30]; - int s1_wbuf[DIM1_SIZE] = {10,20,30}; - int s11_wbuf[DIM1_SIZE] = {10,100,300}; - int s2_wbuf[DIM2_SIZE] = {100,200,300,400}; - int s21_wbuf[DIM2_SIZE] = {10,20,30,40}; - int s22_wbuf[DIM2_SIZE] = {5,10,50,300}; - char dim0_label[16]; - char dim1_label[16]; - char *dim0_labeld; - char *dim1_labeld; - char dim0_labels[3]; - char dim1_labels[3]; - ssize_t dim0_label_size; - ssize_t dim1_label_size; + hid_t fid = -1; + hid_t did = -1; + hid_t dsid = -1; + hid_t sid = -1; + hid_t gid = -1; + int rank = RANK; + int rankds = 1; + hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; + int buf[DIM_DATA] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + hsize_t s1_dim[1] = {DIM1_SIZE}; + hsize_t s2_dim[1] = {DIM2_SIZE}; + char sname[30]; + char dname[30]; + int s1_wbuf[DIM1_SIZE] = {10, 20, 30}; + int s11_wbuf[DIM1_SIZE] = {10, 100, 300}; + int s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400}; + int s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40}; + int s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300}; + char dim0_label[16]; + char dim1_label[16]; + char * dim0_labeld; + char * dim1_labeld; + char dim0_labels[3]; + char dim1_labels[3]; + ssize_t dim0_label_size; + ssize_t dim1_label_size; unsigned int dim; - int scale_idx; - int nscales; - ssize_t name_len; - char *name_out=NULL; - char snames[3]; - int i, j; + int scale_idx; + int nscales; + ssize_t name_len; + char * name_out = NULL; + char snames[3]; + int i, j; HDprintf("Testing API functions\n"); /*------------------------------------------------------------------------- - * create a file for the test - *------------------------------------------------------------------------- - */ + * create a file for the test + *------------------------------------------------------------------------- + */ /* create a file using default properties */ - if((fid=H5Fcreate(FILE1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * create datasets: 1 "data" dataset and 4 dimension scales - *------------------------------------------------------------------------- - */ + * create datasets: 1 "data" dataset and 4 dimension scales + *------------------------------------------------------------------------- + */ /* make a dataset */ - if(H5LTmake_dataset_int(fid,"dset_a",rank,dims,buf) < 0) + if (H5LTmake_dataset_int(fid, "dset_a", rank, dims, buf) < 0) goto out; /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_int(fid,"ds_a_1",rankds,s1_dim,s1_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_a_1", rankds, s1_dim, s1_wbuf) < 0) goto out; /* make a DS dataset with an alternate scale for the 2nd dimension */ - if(H5LTmake_dataset_int(fid,"ds_a_11",rankds,s1_dim,s11_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_a_11", rankds, s1_dim, s11_wbuf) < 0) goto out; /* make a DS dataset for the second dimension */ - if(H5LTmake_dataset_int(fid,"ds_a_2",rankds,s2_dim,s2_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_a_2", rankds, s2_dim, s2_wbuf) < 0) goto out; /* make a DS dataset with an alternate scale for the 2nd dimension */ - if(H5LTmake_dataset_int(fid,"ds_a_21",rankds,s2_dim,s21_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_a_21", rankds, s2_dim, s21_wbuf) < 0) goto out; /* make a DS dataset with an alternate scale for the 2nd dimension */ - if(H5LTmake_dataset_int(fid,"ds_a_22",rankds,s2_dim,s22_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_a_22", rankds, s2_dim, s22_wbuf) < 0) goto out; /* get the dataset id for "dset_a" */ - if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * attach the DS_1_NAME dimension scale to "dset_a" - *------------------------------------------------------------------------- - */ + * attach the DS_1_NAME dimension scale to "dset_a" + *------------------------------------------------------------------------- + */ /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_a_1", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_a_1", H5P_DEFAULT)) < 0) goto out; /* attach the DS_1_NAME dimension scale to "dset_a" at dimension 0 */ - if(H5DSattach_scale(did,dsid,DIM0) < 0) + if (H5DSattach_scale(did, dsid, DIM0) < 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /*------------------------------------------------------------------------- - * attach the DS_11_NAME dimension scale to "dset_a" - *------------------------------------------------------------------------- - */ + * attach the DS_11_NAME dimension scale to "dset_a" + *------------------------------------------------------------------------- + */ /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_a_11", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_a_11", H5P_DEFAULT)) < 0) goto out; /* attach the DS_11_NAME dimension scale to "dset_a" at dimension 0 */ - if(H5DSattach_scale(did,dsid,DIM0) < 0) + if (H5DSattach_scale(did, dsid, DIM0) < 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /*------------------------------------------------------------------------- - * attach the DS_2_NAME dimension scale to "dset_a" - *------------------------------------------------------------------------- - */ + * attach the DS_2_NAME dimension scale to "dset_a" + *------------------------------------------------------------------------- + */ /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_a_2", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_a_2", H5P_DEFAULT)) < 0) goto out; /* attach the "ds2" dimension scale to "dset_a" as the 2nd dimension */ - if(H5DSattach_scale(did,dsid,DIM1) < 0) + if (H5DSattach_scale(did, dsid, DIM1) < 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /*------------------------------------------------------------------------- - * attach the DS_21_NAME dimension scale to "dset_a" - *------------------------------------------------------------------------- - */ + * attach the DS_21_NAME dimension scale to "dset_a" + *------------------------------------------------------------------------- + */ /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_a_21", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_a_21", H5P_DEFAULT)) < 0) goto out; /* attach the DS_21_NAME dimension scale to "dset_a" as the 2nd dimension */ - if(H5DSattach_scale(did,dsid,DIM1) < 0) + if (H5DSattach_scale(did, dsid, DIM1) < 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /*------------------------------------------------------------------------- - * attach the DS_22_NAME dimension scale to "dset_a" - *------------------------------------------------------------------------- - */ + * attach the DS_22_NAME dimension scale to "dset_a" + *------------------------------------------------------------------------- + */ /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_a_22", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_a_22", H5P_DEFAULT)) < 0) goto out; /* attach the "ds22" dimension scale to "dset_a" as the 2nd dimension */ - if(H5DSattach_scale(did,dsid,DIM1) < 0) + if (H5DSattach_scale(did, dsid, DIM1) < 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_a" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * create datasets: 1 "data" dataset and 1 dimension scale - *------------------------------------------------------------------------- - */ + * create datasets: 1 "data" dataset and 1 dimension scale + *------------------------------------------------------------------------- + */ /* make a dataset */ - if(H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf) < 0) + if (H5LTmake_dataset_int(fid, "dset_b", rank, dims, buf) < 0) goto out; /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_int(fid,"ds_b_1",rankds,s1_dim,s1_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_b_1", rankds, s1_dim, s1_wbuf) < 0) goto out; /*------------------------------------------------------------------------- - * attach the scale to "dset_b" - *------------------------------------------------------------------------- - */ + * attach the scale to "dset_b" + *------------------------------------------------------------------------- + */ - if((did = H5Dopen2(fid,"dset_b", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_b", H5P_DEFAULT)) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_b_1", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_b_1", H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did,dsid,0) < 0) + if (H5DSattach_scale(did, dsid, 0) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_b" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; - - /*------------------------------------------------------------------------- - * H5DSdetach_scale - *------------------------------------------------------------------------- - */ + * H5DSdetach_scale + *------------------------------------------------------------------------- + */ HL_TESTING2("detach scales "); - /*------------------------------------------------------------------------- - * create datasets: one "data" dataset and 4 dimension scales - *------------------------------------------------------------------------- - */ + * create datasets: one "data" dataset and 4 dimension scales + *------------------------------------------------------------------------- + */ /* make a dataset */ - if(H5LTmake_dataset_int(fid, "dset_c", rank, dims, buf) < 0) + if (H5LTmake_dataset_int(fid, "dset_c", rank, dims, buf) < 0) goto out; /* make a DS dataset for the first dimension */ - if(H5LTmake_dataset_int(fid, "ds_c_1", rankds, s1_dim, s1_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_c_1", rankds, s1_dim, s1_wbuf) < 0) goto out; /* make a DS dataset for the second dimension */ - if(H5LTmake_dataset_int(fid, "ds_c_2", rankds, s2_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_c_2", rankds, s2_dim, s2_wbuf) < 0) goto out; /* make a DS dataset with an alternate scale for the 2nd dimension */ - if(H5LTmake_dataset_int(fid, "ds_c_21", rankds, s2_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_c_21", rankds, s2_dim, s2_wbuf) < 0) goto out; /* make a DS dataset with an alternate scale for the 2nd dimension */ - if(H5LTmake_dataset_int(fid, "ds_c_22", rankds, s2_dim, s2_wbuf) < 0) + if (H5LTmake_dataset_int(fid, "ds_c_22", rankds, s2_dim, s2_wbuf) < 0) goto out; - /*------------------------------------------------------------------------- - * attach the scales to "dset_c" - *------------------------------------------------------------------------- - */ + * attach the scales to "dset_c" + *------------------------------------------------------------------------- + */ - if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_c_1", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_c_1", H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did, dsid, 0) < 0) + if (H5DSattach_scale(did, dsid, 0) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_c_2", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_c_2", H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did, dsid, 1) < 0) + if (H5DSattach_scale(did, dsid, 1) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_c_21", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_c_21", H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did, dsid, 1) < 0) + if (H5DSattach_scale(did, dsid, 1) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_c_22", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_c_22", H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did, dsid, 1) < 0) + if (H5DSattach_scale(did, dsid, 1) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * verify if "dset_c" has dimension scales - *------------------------------------------------------------------------- - */ + * verify if "dset_c" has dimension scales + *------------------------------------------------------------------------- + */ - if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0) goto out; /* verify that "dset_c" has 1 dimension scale at DIM 0 */ - if((nscales = H5DSget_num_scales(did, 0)) < 0) + if ((nscales = H5DSget_num_scales(did, 0)) < 0) goto out; - if(nscales != 1) + if (nscales != 1) goto out; /* verify that "dset_c" has 3 dimension scales at DIM 1 */ - if((nscales = H5DSget_num_scales(did, 1)) < 0) + if ((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; - if(nscales != 3) + if (nscales != 3) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * detach the "ds_c_21" dimension scale to "dset_c" - *------------------------------------------------------------------------- - */ + * detach the "ds_c_21" dimension scale to "dset_c" + *------------------------------------------------------------------------- + */ /* get the dataset id for "dset_c" */ - if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0) goto out; /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_c_21", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_c_21", H5P_DEFAULT)) < 0) goto out; /* detach the "ds_c_21" dimension scale to "dset_c" in DIM 1 */ - if(H5DSdetach_scale(did, dsid, 1) < 0) + if (H5DSdetach_scale(did, dsid, 1) < 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_c" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * "dset_c" must have now 2 dimension scales at DIM 1 - *------------------------------------------------------------------------- - */ + * "dset_c" must have now 2 dimension scales at DIM 1 + *------------------------------------------------------------------------- + */ - if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0) goto out; /* verify that "dset_c" has 2 dimension scales at DIM 1 */ - if((nscales = H5DSget_num_scales(did, 1)) < 0) + if ((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; - if(nscales != 2) + if (nscales != 2) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * detach the "ds_c_22" dimension scale to "dset_c" - *------------------------------------------------------------------------- - */ + * detach the "ds_c_22" dimension scale to "dset_c" + *------------------------------------------------------------------------- + */ /* get the dataset id for "dset_c" */ - if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0) goto out; /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_c_22", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_c_22", H5P_DEFAULT)) < 0) goto out; /* detach the "ds_c_22" dimension scale to "dset_c" in DIM 1 */ - if(H5DSdetach_scale(did, dsid, 1) < 0) + if (H5DSdetach_scale(did, dsid, 1) < 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_c" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * "dset_c" must have now 1 dimension scale at DIM 1 - *------------------------------------------------------------------------- - */ + * "dset_c" must have now 1 dimension scale at DIM 1 + *------------------------------------------------------------------------- + */ - if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0) goto out; /* verify that "dset_c" has 1 dimension scale at DIM 1 */ - if((nscales = H5DSget_num_scales(did, 1)) < 0) + if ((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; - if(nscales != 1) + if (nscales != 1) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * detach the "ds_c_2" dimension scale to "dset_c" - *------------------------------------------------------------------------- - */ + * detach the "ds_c_2" dimension scale to "dset_c" + *------------------------------------------------------------------------- + */ /* get the dataset id for "dset_c" */ - if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0) goto out; /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_c_2", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_c_2", H5P_DEFAULT)) < 0) goto out; /* detach the "ds_c_2" dimension scale to "dset_c" in DIM 1 */ - if(H5DSdetach_scale(did, dsid, 1) < 0) + if (H5DSdetach_scale(did, dsid, 1) < 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_c" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * "dset_c" must have now 0 dimension scales at DIM 1 - *------------------------------------------------------------------------- - */ + * "dset_c" must have now 0 dimension scales at DIM 1 + *------------------------------------------------------------------------- + */ - if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0) goto out; /* verify that "dset_c" has 1 dimension scale at DIM 1 */ - if((nscales = H5DSget_num_scales(did, 1)) < 0) + if ((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; - if(nscales != 0) + if (nscales != 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; - /*------------------------------------------------------------------------- - * create 3 datasets: 1 "data" dataset and 2 dimension scales - *------------------------------------------------------------------------- - */ - if(H5LTmake_dataset_int(fid,"dset_d",rank,dims,NULL) < 0) + * create 3 datasets: 1 "data" dataset and 2 dimension scales + *------------------------------------------------------------------------- + */ + if (H5LTmake_dataset_int(fid, "dset_d", rank, dims, NULL) < 0) goto out; - if(H5LTmake_dataset_int(fid,"ds_d_1",rankds,s1_dim,NULL) < 0) + if (H5LTmake_dataset_int(fid, "ds_d_1", rankds, s1_dim, NULL) < 0) goto out; - if(H5LTmake_dataset_int(fid,"ds_d_2",rankds,s2_dim,NULL) < 0) + if (H5LTmake_dataset_int(fid, "ds_d_2", rankds, s2_dim, NULL) < 0) goto out; /*------------------------------------------------------------------------- - * attach them - *------------------------------------------------------------------------- - */ - if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) + * attach them + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did, dsid, 0) < 0) + if (H5DSattach_scale(did, dsid, 0) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did, dsid, 1) < 0) + if (H5DSattach_scale(did, dsid, 1) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * verify - *------------------------------------------------------------------------- - */ + * verify + *------------------------------------------------------------------------- + */ - if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0) goto out; - if(H5DSis_attached(did,dsid,DIM0)<=0) + if (H5DSis_attached(did, dsid, DIM0) <= 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0) goto out; - if(H5DSis_attached(did,dsid,DIM1)<=0) + if (H5DSis_attached(did, dsid, DIM1) <= 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; - /*------------------------------------------------------------------------- - * detach - *------------------------------------------------------------------------- - */ + * detach + *------------------------------------------------------------------------- + */ /* get the dataset id for "dset_d" */ - if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0) goto out; /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0) goto out; /* detach the dimension scale to "dset_d" in DIM 0 */ - if(H5DSdetach_scale(did,dsid,DIM0) < 0) + if (H5DSdetach_scale(did, dsid, DIM0) < 0) goto out; /* verify attach, it must return 0 for no attach */ - if(H5DSis_attached(did,dsid,DIM0)!=0) + if (H5DSis_attached(did, dsid, DIM0) != 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_d" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * attach again - *------------------------------------------------------------------------- - */ + * attach again + *------------------------------------------------------------------------- + */ /* get the dataset id for "dset_d" */ - if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0) goto out; /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0) goto out; /* attach "ds_d_1" again in DIM 0 */ - if(H5DSattach_scale(did,dsid,DIM0) < 0) + if (H5DSattach_scale(did, dsid, DIM0) < 0) goto out; /* verify attach, it must return 1 for attach */ - if(H5DSis_attached(did,dsid,DIM0)!=1) + if (H5DSis_attached(did, dsid, DIM0) != 1) goto out; /* verify that "ds_d_1" has only 1 scale at DIM0 */ - if((nscales = H5DSget_num_scales(did,DIM0)) < 0) + if ((nscales = H5DSget_num_scales(did, DIM0)) < 0) goto out; - if(nscales != 1) + if (nscales != 1) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_d" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * detach/detach - *------------------------------------------------------------------------- - */ + * detach/detach + *------------------------------------------------------------------------- + */ /* get the dataset id for "dset_d" */ - if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0) goto out; /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0) goto out; /* detach the "ds_d_2" dimension scale to "dset_d" in DIM 1 */ - if(H5DSdetach_scale(did,dsid,DIM1) < 0) + if (H5DSdetach_scale(did, dsid, DIM1) < 0) goto out; /* detach again, it should fail */ - if(H5DSdetach_scale(did,dsid,DIM1)==SUCCEED) + if (H5DSdetach_scale(did, dsid, DIM1) == SUCCEED) goto out; /* verify attach, it must return 0 for no attach */ - if(H5DSis_attached(did,dsid,DIM1)!=0) + if (H5DSis_attached(did, dsid, DIM1) != 0) goto out; /* verify that "ds_d_1" has no scale at DIM1 */ - if((nscales = H5DSget_num_scales(did,DIM1)) < 0) + if ((nscales = H5DSget_num_scales(did, DIM1)) < 0) goto out; - if(nscales != 0) + if (nscales != 0) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_d" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * attach twice - *------------------------------------------------------------------------- - */ + * attach twice + *------------------------------------------------------------------------- + */ /* get the dataset id for "dset_d" */ - if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0) goto out; /* get the DS dataset id */ - if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0) goto out; /* attach "ds_d_2" in DIM 1 */ - if(H5DSattach_scale(did,dsid,DIM1) < 0) + if (H5DSattach_scale(did, dsid, DIM1) < 0) goto out; /* verify attach, it must return 1 for attach */ - if(H5DSis_attached(did,dsid,DIM1)!=1) + if (H5DSis_attached(did, dsid, DIM1) != 1) goto out; /* verify that "ds_d_2" has only 1 scale at DIM1 */ - if((nscales = H5DSget_num_scales(did,DIM0)) < 0) + if ((nscales = H5DSget_num_scales(did, DIM0)) < 0) goto out; - if(nscales != 1) + if (nscales != 1) goto out; /* attach "ds_d_2" again in DIM 1 */ - if(H5DSattach_scale(did,dsid,DIM1) < 0) + if (H5DSattach_scale(did, dsid, DIM1) < 0) goto out; /* verify attach, it must return 1 for attach */ - if(H5DSis_attached(did,dsid,DIM1)!=1) + if (H5DSis_attached(did, dsid, DIM1) != 1) goto out; /* verify that "ds_d_2" has only 1 scale at DIM1 */ - if((nscales = H5DSget_num_scales(did,DIM0)) < 0) + if ((nscales = H5DSget_num_scales(did, DIM0)) < 0) goto out; - if(nscales != 1) + if (nscales != 1) goto out; /* close DS id */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; /* close dataset ID of "dset_d" */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /*------------------------------------------------------------------------- - * create 10 datasets: 5 "data" dataset and 5 dimension scales - *------------------------------------------------------------------------- - */ + * create 10 datasets: 5 "data" dataset and 5 dimension scales + *------------------------------------------------------------------------- + */ /* create a group */ - if((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* create the data space for the dataset */ - if((sid = H5Screate_simple(rank,dims,NULL)) < 0) + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) goto out; - for(i = 0; i < 5; i++) { - HDsprintf(dname,"dset_%d",i); - if((did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 5; i++) { + HDsprintf(dname, "dset_%d", i); + if ((did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - HDsprintf(sname,"ds_%d",i); - if((dsid = H5Dcreate2(gid, sname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + HDsprintf(sname, "ds_%d", i); + if ((dsid = H5Dcreate2(gid, sname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5DSset_scale(dsid,"scale") < 0) + if (H5DSset_scale(dsid, "scale") < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } /*------------------------------------------------------------------------- - * attach for DIM 0 - *------------------------------------------------------------------------- - */ + * attach for DIM 0 + *------------------------------------------------------------------------- + */ - for(i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { HDsprintf(dname, "dset_%d", i); - if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) goto out; - for(j = 0; j < 5; j++) { + for (j = 0; j < 5; j++) { HDsprintf(sname, "ds_%d", j); - if((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did, dsid, DIM0) < 0) + if (H5DSattach_scale(did, dsid, DIM0) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } /*------------------------------------------------------------------------- - * dettach for DIM0 - *------------------------------------------------------------------------- - */ + * dettach for DIM0 + *------------------------------------------------------------------------- + */ - for(i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { HDsprintf(dname, "dset_%d", i); - if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) goto out; - for(j = 0; j < 5; j++) { + for (j = 0; j < 5; j++) { HDsprintf(sname, "ds_%d", j); - if((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) goto out; - if(H5DSdetach_scale(did, dsid, DIM0) < 0) + if (H5DSdetach_scale(did, dsid, DIM0) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } - /*------------------------------------------------------------------------- - * attach again for DIM0 - *------------------------------------------------------------------------- - */ + * attach again for DIM0 + *------------------------------------------------------------------------- + */ - for(i=0; i<5; i++) { - HDsprintf(dname,"dset_%d",i); - if((did = H5Dopen2(gid,dname, H5P_DEFAULT)) < 0) + for (i = 0; i < 5; i++) { + HDsprintf(dname, "dset_%d", i); + if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) goto out; - for(j=0; j<5; j++) { - HDsprintf(sname,"ds_%d",j); - if((dsid = H5Dopen2(gid,sname, H5P_DEFAULT)) < 0) + for (j = 0; j < 5; j++) { + HDsprintf(sname, "ds_%d", j); + if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did,dsid,DIM0) < 0) + if (H5DSattach_scale(did, dsid, DIM0) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; } /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - - /*------------------------------------------------------------------------- - * create a dataset and attach only to 1 dimension - *------------------------------------------------------------------------- - */ + * create a dataset and attach only to 1 dimension + *------------------------------------------------------------------------- + */ /* make a dataset */ - if(H5LTmake_dataset_int(fid,"dset_e",rank,dims,NULL) < 0) + if (H5LTmake_dataset_int(fid, "dset_e", rank, dims, NULL) < 0) goto out; /* make a scale */ - if(H5LTmake_dataset_int(fid,"ds_e_1",rankds,s1_dim,NULL) < 0) + if (H5LTmake_dataset_int(fid, "ds_e_1", rankds, s1_dim, NULL) < 0) goto out; /* attach the DS to dimension 1 */ - if((did = H5Dopen2(fid,"dset_e", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset_e", H5P_DEFAULT)) < 0) goto out; - if((dsid = H5Dopen2(fid,"ds_e_1", H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, "ds_e_1", H5P_DEFAULT)) < 0) goto out; - if(H5DSattach_scale(did,dsid,DIM1) < 0) + if (H5DSattach_scale(did, dsid, DIM1) < 0) goto out; - if(H5DSis_attached(did,dsid,DIM1)<=0) + if (H5DSis_attached(did, dsid, DIM1) <= 0) goto out; - /* try to detach all dimensions. for dimensions 0 and 2, it is an error */ - for(i=0; i #include @@ -19,21 +19,21 @@ #include "H5DOpublic.h" #if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) -# define H5_ZLIB_HEADER "zlib.h" +#define H5_ZLIB_HEADER "zlib.h" #endif #if defined(H5_ZLIB_HEADER) -#include H5_ZLIB_HEADER /* "zlib.h" */ +#include H5_ZLIB_HEADER /* "zlib.h" */ #endif -#define FILENAME "test_append.h5" -#define DNAME_NOTSET "dataset_notset" -#define DNAME_UNLIM "dataset_unlim" -#define DNAME_LESS "dataset_less" -#define DNAME_VARY "dataset_vary" -#define DNAME_ROW "dataset_row" -#define DNAME_COLUMN "dataset_column" -#define DBUGNAME1 "dataset_bug1" -#define DBUGNAME2 "dataset_bug2" +#define FILENAME "test_append.h5" +#define DNAME_NOTSET "dataset_notset" +#define DNAME_UNLIM "dataset_unlim" +#define DNAME_LESS "dataset_less" +#define DNAME_VARY "dataset_vary" +#define DNAME_ROW "dataset_row" +#define DNAME_COLUMN "dataset_column" +#define DBUGNAME1 "dataset_bug1" +#define DBUGNAME2 "dataset_bug2" /*------------------------------------------------------------------------- * Function: test_dataset_append_notset @@ -52,67 +52,67 @@ static int test_dataset_append_notset(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, 20}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10]; /* The data buffers */ - int i, j; /* Local index variables */ - h5_stat_t sb1, sb2; /* File info */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 20}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10]; /* The data buffers */ + int i, j; /* Local index variables */ + h5_stat_t sb1, sb2; /* File info */ HL_TESTING2("Append flush with H5DOappend()--append rows with default dapl"); /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Set to create a chunked dataset with extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_NOTSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DNAME_NOTSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Append 6 rows to the dataset */ - for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) lbuf[j] = (i * 10) + (j + 1); /* Append without boundary, callback and flush */ - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) FAIL_STACK_ERROR; } /* end for */ /* File size when not flushed */ - if(HDstat(FILENAME, &sb1) < 0) + if (HDstat(FILENAME, &sb1) < 0) TEST_ERROR; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; /* File size after flushing */ - if(HDstat(FILENAME, &sb2) < 0) + if (HDstat(FILENAME, &sb2) < 0) TEST_ERROR; /* File size before flushing should be less */ - if(sb1.st_size > sb2.st_size) + if (sb1.st_size > sb2.st_size) TEST_ERROR; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -120,12 +120,14 @@ test_dataset_append_notset(hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(sid); H5Dclose(did); H5Pclose(ffapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_dataset_append_notset() */ @@ -134,7 +136,7 @@ error: static herr_t flush_func(hid_t H5_ATTR_UNUSED obj_id, void *_udata) { - unsigned *flush_ct = (unsigned*)_udata; + unsigned *flush_ct = (unsigned *)_udata; ++(*flush_ct); return 0; } @@ -165,125 +167,125 @@ append_func(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void static int test_dataset_append_rows_columns(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10], cbuf[6]; /* The data buffers */ - int buf[6][13], rbuf[6][13]; /* The data buffers */ + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* The data buffers */ + int buf[6][13], rbuf[6][13]; /* The data buffers */ - hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ - int i, j; /* Local index variables */ + int i, j; /* Local index variables */ HL_TESTING2("Append flush with H5DOappend()--append rows & columns"); /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_UNLIM, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + if ((did = H5Dcreate2(fid, DNAME_UNLIM, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR; /* Append 6 rows to the dataset */ - for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) lbuf[j] = buf[i][j] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) TEST_ERROR; } /* end for */ /* Verify the # of appends */ - if(append_ct != 6) + if (append_ct != 6) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 6) + if (*flush_ptr != 6) TEST_ERROR; /* Append 3 columns to the dataset */ - for(i = 0; i < 3; i++) { - for(j = 0; j < 6; j++) + for (i = 0; i < 3; i++) { + for (j = 0; j < 6; j++) cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) TEST_ERROR; } /* end for */ /* Verify the # of appends */ - if(append_ct != 9) + if (append_ct != 9) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 9) + if (*flush_ptr != 9) TEST_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Clear the buffer */ HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen2(fid, DNAME_UNLIM, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DNAME_UNLIM, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -291,13 +293,15 @@ test_dataset_append_rows_columns(hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl); H5Pclose(dcpl); H5Pclose(sid); H5Dclose(did); H5Pclose(ffapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_dataset_append_rows_columns() */ @@ -319,105 +323,105 @@ error: static int test_dataset_append_rows(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, 10}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10]; /* The data buffer */ - int buf[6][10], rbuf[6][10]; /* The data buffers */ - int i, j; /* Local index variables */ - - hsize_t boundary[2] = {1, 0}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 10}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10]; /* The data buffer */ + int buf[6][10], rbuf[6][10]; /* The data buffers */ + int i, j; /* Local index variables */ + + hsize_t boundary[2] = {1, 0}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ HL_TESTING2("Append flush with H5DOappend()--append rows"); /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Set to create a chunked dataset with 1 extendible dimension */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_ROW, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + if ((did = H5Dcreate2(fid, DNAME_ROW, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR; /* Append 6 rows to the dataset */ - for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) lbuf[j] = buf[i][j] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) TEST_ERROR; } /* end for */ /* Verify the # of appends */ - if(append_ct != 6) + if (append_ct != 6) TEST_ERROR; - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 6) + if (*flush_ptr != 6) TEST_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 10; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 10; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Clear the buffer */ HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen2(fid, DNAME_ROW, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DNAME_ROW, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 10; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 10; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -425,13 +429,15 @@ test_dataset_append_rows(hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl); H5Pclose(dcpl); H5Pclose(sid); H5Dclose(did); H5Pclose(ffapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_dataset_append_rows() */ @@ -453,106 +459,106 @@ error: static int test_dataset_append_columns(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {6, 0}; /* Current dimension sizes */ - hsize_t maxdims[2] = {6, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int cbuf[6]; /* The data buffer */ - int buf[6][3], rbuf[6][3]; /* The data buffers */ - int i, j; /* Local index variable */ - - hsize_t boundary[2] = {0, 1}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {6, 0}; /* Current dimension sizes */ + hsize_t maxdims[2] = {6, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int cbuf[6]; /* The data buffer */ + int buf[6][3], rbuf[6][3]; /* The data buffers */ + int i, j; /* Local index variable */ + + hsize_t boundary[2] = {0, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ HL_TESTING2("Append flush with H5DOappend()--append columns"); /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Set to create a chunked dataset with 1 extendible dimension */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_COLUMN, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + if ((did = H5Dcreate2(fid, DNAME_COLUMN, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR; /* Append 3 columns to the dataset */ - for(i = 0; i < 3; i++) { - for(j = 0; j < 6; j++) + for (i = 0; i < 3; i++) { + for (j = 0; j < 6; j++) cbuf[j] = buf[j][i] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) TEST_ERROR; } /* end for */ /* Verify the # of appends */ - if(append_ct != 3) + if (append_ct != 3) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 3) + if (*flush_ptr != 3) TEST_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 3; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 3; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Clear the buffer */ HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen2(fid, DNAME_COLUMN, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DNAME_COLUMN, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 3; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 3; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -560,13 +566,15 @@ test_dataset_append_columns(hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl); H5Pclose(dcpl); H5Pclose(sid); H5Dclose(did); H5Pclose(ffapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_dataset_append_columns() */ @@ -597,123 +605,123 @@ error: static int test_dataset_append_BUG1(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* Dataset creation property */ - hid_t dapl = -1; /* Dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10], cbuf[6]; /* The data buffers */ - int buf[6][13], rbuf[6][13]; /* The data buffers */ - int i, j; /* Local index variables */ - - hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t dapl = -1; /* Dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* The data buffers */ + int buf[6][13], rbuf[6][13]; /* The data buffers */ + int i, j; /* Local index variables */ + + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ HL_TESTING2("Append flush with H5DOappend()--append rows & columns--BUG1"); /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DBUGNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + if ((did = H5Dcreate2(fid, DBUGNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR; /* Append 6 rows to the dataset */ - for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) lbuf[j] = buf[i][j] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) TEST_ERROR; } /* end for */ /* Verify the # of appends */ - if(append_ct != 6) + if (append_ct != 6) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 6) + if (*flush_ptr != 6) TEST_ERROR; /* Append 3 columns to the dataset */ - for(i = 0; i < 3; i++) { - for(j = 0; j < 6; j++) - cbuf[j] = buf[j][i+10] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + for (i = 0; i < 3; i++) { + for (j = 0; j < 6; j++) + cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) TEST_ERROR; } /* end for */ /* Verify the # of appends */ - if(append_ct != 9) + if (append_ct != 9) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 9) + if (*flush_ptr != 9) TEST_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen2(fid, DBUGNAME1, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DBUGNAME1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -721,13 +729,15 @@ test_dataset_append_BUG1(hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(dapl); H5Pclose(sid); H5Dclose(did); H5Pclose(ffapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_dataset_append_BUG1() */ @@ -758,124 +768,123 @@ error: static int test_dataset_append_BUG2(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* Dataset creation property */ - hid_t dapl = -1; /* Dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {50, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10], cbuf[6]; /* Data buffers */ - int buf[6][13], rbuf[6][13]; /* Data buffers */ - int i, j; /* Local index variables */ - - hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t dapl = -1; /* Dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {50, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j; /* Local index variables */ + + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ HL_TESTING2("Append flush with H5DOappend()--append rows & columns--BUG2"); /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DBUGNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + if ((did = H5Dcreate2(fid, DBUGNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR; /* Append 6 rows to the dataset */ - for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) + for (i = 0; i < 6; i++) { + for (j = 0; j < 10; j++) lbuf[j] = buf[i][j] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) TEST_ERROR; } /* end for */ /* Verify the # of appends */ - if(append_ct != 6) + if (append_ct != 6) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 6) + if (*flush_ptr != 6) TEST_ERROR; - /* Append 3 columns to the dataset */ - for(i = 0; i < 3; i++) { - for(j = 0; j < 6; j++) - cbuf[j] = buf[j][i+10] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + for (i = 0; i < 3; i++) { + for (j = 0; j < 6; j++) + cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) TEST_ERROR; } /* end for */ /* Verify the # of appends */ - if(append_ct != 9) + if (append_ct != 9) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 9) + if (*flush_ptr != 9) TEST_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen2(fid, DBUGNAME2, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DBUGNAME2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -883,18 +892,19 @@ test_dataset_append_BUG2(hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(dapl); H5Pclose(sid); H5Dclose(did); H5Pclose(ffapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_dataset_append_BUG2() */ - /*------------------------------------------------------------------------- * Function: test_dataset_append_less * @@ -913,127 +923,127 @@ error: static int test_dataset_append_less(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {100, 100}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[20], cbuf[6][3]; /* Data buffers */ - int buf[6][13], rbuf[6][13]; /* Data buffers */ - int i, j, k; /* Local index variables */ - - hsize_t boundary[2] = {3, 3}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {100, 100}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[20], cbuf[6][3]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j, k; /* Local index variables */ + + hsize_t boundary[2] = {3, 3}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ HL_TESTING2("Append flush with H5DOappend()--append size < boundary size"); /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_LESS, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + if ((did = H5Dcreate2(fid, DNAME_LESS, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR; /* Append to the dataset 2 rows at a time for 3 times */ - for(i = 0, k = 0; i < 6; i++) { - for(j = 0; j < 10; j++, k++) + for (i = 0, k = 0; i < 6; i++) { + for (j = 0; j < 10; j++, k++) buf[i][j] = lbuf[k] = (i * 10) + (j + 1); - if((i + 1) % 2 == 0) { - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)2, H5T_NATIVE_INT, lbuf) < 0) + if ((i + 1) % 2 == 0) { + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)2, H5T_NATIVE_INT, lbuf) < 0) TEST_ERROR; k = 0; } /* end if */ - } /* end for */ + } /* end for */ /* Verify the # of appends */ - if(append_ct != 2) + if (append_ct != 2) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 2) + if (*flush_ptr != 2) TEST_ERROR; /* Append 3 columns to the dataset, once */ - for(i = 0; i < 3; i++) - for(j = 0; j < 6; j++, k++) + for (i = 0; i < 3; i++) + for (j = 0; j < 6; j++, k++) cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0) TEST_ERROR; /* Verify the # of appends */ - if(append_ct != 3) + if (append_ct != 3) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 3) + if (*flush_ptr != 3) TEST_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Clear the buffer */ HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen2(fid, DNAME_LESS, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DNAME_LESS, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -1041,13 +1051,15 @@ test_dataset_append_less(hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl); H5Pclose(dcpl); H5Pclose(sid); H5Dclose(did); H5Pclose(ffapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_dataset_append_less() */ @@ -1073,122 +1085,122 @@ error: static int test_dataset_append_vary(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[60], cbuf[6][3]; /* Data buffers */ - int buf[6][13], rbuf[6][13]; /* Data buffers */ - int i, j, k; /* Local index variables */ - - hsize_t boundary[2] = {3, 7}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */ + int lbuf[60], cbuf[6][3]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j, k; /* Local index variables */ + + hsize_t boundary[2] = {3, 7}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ HL_TESTING2("Append flush with H5DOappend()--append & boundary size vary"); /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_VARY, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + if ((did = H5Dcreate2(fid, DNAME_VARY, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR; /* Append 6 rows to the dataset, once */ - for(i = 0, k = 0; i < 6; i++) - for(j = 0; j < 10; j++, k++) + for (i = 0, k = 0; i < 6; i++) + for (j = 0; j < 10; j++, k++) buf[i][j] = lbuf[k] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)6, H5T_NATIVE_INT, lbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)6, H5T_NATIVE_INT, lbuf) < 0) TEST_ERROR; /* Verify the # of appends */ - if(append_ct != 1) + if (append_ct != 1) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 1) + if (*flush_ptr != 1) TEST_ERROR; /* Append 3 columns to the dataset, once */ - for(i = 0; i < 3; i++) - for(j = 0; j < 6; j++, k++) + for (i = 0; i < 3; i++) + for (j = 0; j < 6; j++, k++) cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0) + if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0) TEST_ERROR; /* Verify the # of appends */ - if(append_ct != 1) + if (append_ct != 1) TEST_ERROR; /* Retrieve and verify object flush counts */ - if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) + if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) FAIL_STACK_ERROR; - if(*flush_ptr != 1) + if (*flush_ptr != 1) TEST_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Clear the dataset */ HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen2(fid, DNAME_VARY, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DNAME_VARY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data */ - for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) - if(buf[i][j] != rbuf[i][j]) + for (i = 0; i < 6; i++) + for (j = 0; j < 13; j++) + if (buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -1196,13 +1208,15 @@ test_dataset_append_vary(hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl); H5Pclose(dcpl); H5Pclose(sid); H5Dclose(did); H5Pclose(ffapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_dataset_append_vary() */ @@ -1219,64 +1233,66 @@ error: * *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - unsigned flush_ct = 0; /* The # of flushes */ - int nerrors = 0; /* The # of errors encountered */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + unsigned flush_ct = 0; /* The # of flushes */ + int nerrors = 0; /* The # of errors encountered */ /* Get a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR; /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR; /* Set object flush property */ - if(H5Pset_object_flush_cb(fapl, flush_func, &flush_ct) < 0) + if (H5Pset_object_flush_cb(fapl, flush_func, &flush_ct) < 0) FAIL_STACK_ERROR; /* Create the test file */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; nerrors += test_dataset_append_notset(fid); nerrors += test_dataset_append_rows(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_columns(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_rows_columns(fid); -/* - * The following tests illustrate the scenarios when H5DOappend does not work with extensible array indexing: - * - when the the dataset has 1 unlimited dimension and the other dimension is fixed but extendible - * - the dataset expands along 1 dimension and then expands along the other dimension - */ - flush_ct = 0; /* Reset flush counter */ + /* + * The following tests illustrate the scenarios when H5DOappend does not work with extensible array + * indexing: + * - when the the dataset has 1 unlimited dimension and the other dimension is fixed but extendible + * - the dataset expands along 1 dimension and then expands along the other dimension + */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_BUG1(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_BUG2(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_less(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_vary(fid); /* Closing */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Check for errors */ - if(nerrors) + if (nerrors) goto error; return EXIT_SUCCESS; @@ -1284,4 +1300,3 @@ int main(void) error: return EXIT_FAILURE; } - diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c index 504a3f5..5bf4a48 100644 --- a/hl/test/test_file_image.c +++ b/hl/test/test_file_image.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "h5hltest.h" #include "H5LTpublic.h" @@ -21,8 +21,8 @@ /* For superblock version 0, 1: the offset to "file consistency flags" is 20 with size of 4 bytes */ /* The file consistency flags is the "status_flags" field in H5F_super_t */ /* Note: the offset and size will be different when using superblock version 2 for the test file */ -#define SUPER_STATUS_FLAGS_OFF_V0_V1 20 -#define SUPER_STATUS_FLAGS_SIZE_V0_V1 4 +#define SUPER_STATUS_FLAGS_OFF_V0_V1 20 +#define SUPER_STATUS_FLAGS_SIZE_V0_V1 4 /* Test of file image operations. @@ -47,32 +47,32 @@ buffers if appropriate. */ /*------------------------------------------------------------------------- -* test file image operations -*------------------------------------------------------------------------- -*/ + * test file image operations + *------------------------------------------------------------------------- + */ static int test_file_image(size_t open_images, size_t nflags, unsigned *flags) { - hid_t *file_id, *dset_id, file_space, plist; /* HDF5 ids */ - hsize_t dims1[RANK] = {2,3}; /* original dimension of datasets */ - hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED}; - int data1[6] = {1,2,3,4,5,6}; /* original contents of dataset */ - int data2[6] = {7,8,9,10,11,12}; /* "wrong" contents of dataset */ - hsize_t dims3[RANK]; /* array to read dataset dimensions */ - int data3[15]; /* array to read dataset contents */ - hsize_t dims4[RANK] = {3,5}; /* extended dimensions of datasets */ - int data4[15] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - /* extended contents of dataset */ - ssize_t *buf_size; /* pointer to array of buffer sizes */ - void **buf_ptr; /* pointer to array of pointers to image buffers */ - char **filename; /* pointer to array of pointers to filenames */ - unsigned *input_flags; /* pointer to array of flag combinations */ - size_t i, j, k, nrow, n_values; - herr_t status1; - void *handle_ptr = NULL; /* pointers to driver buffer */ + hid_t * file_id, *dset_id, file_space, plist; /* HDF5 ids */ + hsize_t dims1[RANK] = {2, 3}; /* original dimension of datasets */ + hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED}; + int data1[6] = {1, 2, 3, 4, 5, 6}; /* original contents of dataset */ + int data2[6] = {7, 8, 9, 10, 11, 12}; /* "wrong" contents of dataset */ + hsize_t dims3[RANK]; /* array to read dataset dimensions */ + int data3[15]; /* array to read dataset contents */ + hsize_t dims4[RANK] = {3, 5}; /* extended dimensions of datasets */ + int data4[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + /* extended contents of dataset */ + ssize_t * buf_size; /* pointer to array of buffer sizes */ + void ** buf_ptr; /* pointer to array of pointers to image buffers */ + char ** filename; /* pointer to array of pointers to filenames */ + unsigned * input_flags; /* pointer to array of flag combinations */ + size_t i, j, k, nrow, n_values; + herr_t status1; + void * handle_ptr = NULL; /* pointers to driver buffer */ unsigned char **core_buf_ptr_ptr = NULL; - VERIFY(open_images > 1 , "The number of open images must be greater than 1"); + VERIFY(open_images > 1, "The number of open images must be greater than 1"); VERIFY(nflags > 0, "The number of flag combinations must be greater than 0"); @@ -131,7 +131,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("H5Pset_chunk() failed"); /* create and write an integer type dataset named "dset" */ - if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0) + if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space, H5P_DEFAULT, plist, + H5P_DEFAULT)) < 0) FAIL_PUTS_ERROR("H5Dcreate() failed"); /* dataset in open image 1 is written with "wrong" data */ @@ -172,7 +173,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* buffer for file image 2 is filled with counter data (non-valid image) */ if (i == 2) { for (j = 0; j < (size_t)buf_size[i]; j++) - ((char*)(buf_ptr[i]))[j] = (char)j; + ((char *)(buf_ptr[i]))[j] = (char)j; } /* end if */ /* buffers for the rest of the file images are filled with data from the respective files */ else { @@ -181,7 +182,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) } /* end else */ /* file close */ - if (H5Fclose (file_id[i]) < 0) + if (H5Fclose(file_id[i]) < 0) FAIL_PUTS_ERROR("H5Fclose() failed"); } /* end for */ @@ -193,10 +194,12 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) for (i = 0; i < open_images; i++) { /* open file image 2 filled with counter data (non-valid image) */ if (i == 2) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { /* attempt to set file image in the core driver */ file_id[i] = H5LTopen_file_image(buf_ptr[i], (size_t)buf_size[i], input_flags[i]); - } H5E_END_TRY + } + H5E_END_TRY VERIFY(file_id[i] < 0, "H5LTopen_file_image() should have failed"); } /* end if */ @@ -208,36 +211,41 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* get pointer to the image buffer of the core driver */ if (H5Fget_vfd_handle(file_id[i], H5P_DEFAULT, &handle_ptr) < 0) - FAIL_PUTS_ERROR("H5Fget_vfd_handle() failed"); + FAIL_PUTS_ERROR("H5Fget_vfd_handle() failed"); core_buf_ptr_ptr = (unsigned char **)handle_ptr; /* test whether the user buffer has been copied or not */ if (input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) - VERIFY(*core_buf_ptr_ptr == buf_ptr[i], "vfd buffer and user buffer should have been the same"); + VERIFY(*core_buf_ptr_ptr == buf_ptr[i], + "vfd buffer and user buffer should have been the same"); else VERIFY(*core_buf_ptr_ptr != buf_ptr[i], "vfd buffer and user buffer should be different"); - /* + /* * When the vfd and user buffers are different and H5LT_FILE_IMAGE_OPEN_RW is enabled, * status_flags in the superblock needs to be cleared in the vfd buffer for * the comparison to proceed as expected. The user buffer as returned from H5Fget_file_image() * has already cleared status_flags. The superblock's status_flags is used for the * implementation of file locking. */ - if(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW && !(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY)) { + if (input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW && !(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY)) { void *tmp_ptr = HDmalloc((size_t)buf_size[i]); /* Copy vfd buffer to a temporary buffer */ HDmemcpy(tmp_ptr, (void *)*core_buf_ptr_ptr, (size_t)buf_size[i]); - /* Clear status_flags in the superblock for the vfd buffer: file locking is using status_flags */ - HDmemset((uint8_t *)tmp_ptr + SUPER_STATUS_FLAGS_OFF_V0_V1, (int)0, (size_t)SUPER_STATUS_FLAGS_SIZE_V0_V1); + /* Clear status_flags in the superblock for the vfd buffer: file locking is using status_flags + */ + HDmemset((uint8_t *)tmp_ptr + SUPER_STATUS_FLAGS_OFF_V0_V1, (int)0, + (size_t)SUPER_STATUS_FLAGS_SIZE_V0_V1); /* Does the comparision */ - if(HDmemcmp(tmp_ptr, buf_ptr[i], (size_t)buf_size[i]) != 0) + if (HDmemcmp(tmp_ptr, buf_ptr[i], (size_t)buf_size[i]) != 0) FAIL_PUTS_ERROR("comparison of TMP vfd and user buffer failed"); /* Free the temporary buffer */ - if(tmp_ptr) HDfree(tmp_ptr); - } else { + if (tmp_ptr) + HDfree(tmp_ptr); + } + else { /* test whether the contents of the user buffer and driver buffer */ /* are equal. */ @@ -245,7 +253,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("comparison of vfd and user buffer failed"); } } /* end else */ - } /* end for */ + } /* end for */ PASSED(); @@ -272,7 +280,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("H5Sget_simple_extent_dims() failed"); /* read dataset */ - if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0) + if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0) FAIL_PUTS_ERROR("H5Dread() failed"); /* compute number of elements in dataset */ @@ -286,7 +294,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* compare file image values with original data */ for (j = 0; j < n_values / nrow; j++) for (k = 0; k < nrow; k++) - if (data3[j * nrow + k ] == data1[j * nrow + k ]) + if (data3[j * nrow + k] == data1[j * nrow + k]) FAIL_PUTS_ERROR("comparison of image values with original data should have failed"); } /* end if */ /* verify contents for the rest of the file images */ @@ -294,12 +302,12 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* compare file image values with original data */ for (j = 0; j < n_values / nrow; j++) for (k = 0; k < nrow; k++) - if (data3[j * nrow + k ] != data1[j * nrow + k ]) + if (data3[j * nrow + k] != data1[j * nrow + k]) FAIL_PUTS_ERROR("comparison of image values with original data failed"); } /* end else */ /* close dataspace */ - if (H5Sclose (file_space) < 0) + if (H5Sclose(file_space) < 0) FAIL_PUTS_ERROR("H5Sclose() failed"); } /* end for */ @@ -318,23 +326,29 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* test data write when file image access is read-only */ if (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW)) { /* write dataset without extending it */ - H5E_BEGIN_TRY { - status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); + } + H5E_END_TRY; VERIFY(status1 < 0, "H5Dwrite() should have failed"); /* extend dimensions of dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status1 = H5Dset_extent(dset_id[i], dims4); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(status1 < 0, "H5Dset_extent() should have failed"); /* write extended dataset */ - H5E_BEGIN_TRY { - status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4); + } + H5E_END_TRY; VERIFY(status1 < 0, "H5Dwrite() should have failed"); @@ -344,7 +358,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) } /* end if */ /* test data write where file image access is read-write */ else { - if ((input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) && (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) { + if ((input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) && + (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) { /* This test is disabled currently, since the new attribute causes the file * to increase in size, but the realloc call in H5FD_core_write() fails, causing * the flush operation to fail and the file to fail to close, eventually @@ -396,13 +411,13 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) H5Aclose(attr_id); } H5E_END_TRY; #endif - if (H5Dclose(dset_id[i]) < 0) - FAIL_PUTS_ERROR("H5Dclose() failed"); - dset_id[i] = -1; + if (H5Dclose(dset_id[i]) < 0) + FAIL_PUTS_ERROR("H5Dclose() failed"); + dset_id[i] = -1; } /* end if */ else { /* write dataset without extending it */ - if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0) + if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0) FAIL_PUTS_ERROR("H5Dwrite() failed"); /* extend dimensions of dataset */ @@ -410,15 +425,15 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("H5Dset_extent() failed"); /* write extended dataset */ - if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4) < 0) + if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4) < 0) FAIL_PUTS_ERROR("H5Dwrite() failed"); /* close dataset */ if (H5Dclose(dset_id[i]) < 0) FAIL_PUTS_ERROR("H5Dclose() failed"); } /* end else */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ PASSED(); @@ -427,7 +442,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* read open file images and verify data */ for (i = 0; i < open_images; i++) { /* if opening the file image failed, continue next iteration */ - if ((dset_id[i] < 0) || (file_id[i] < 0) || (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW ))) + if ((dset_id[i] < 0) || (file_id[i] < 0) || (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW))) continue; /* open dataset in file image */ @@ -443,7 +458,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("H5Sget_simple_extent_dims() failed"); /* read dataset */ - if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0) + if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0) FAIL_PUTS_ERROR("H5Dread() failed"); /* compute number of elements in dataset */ @@ -455,11 +470,11 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* verify contents for the file images */ for (j = 0; j < n_values / nrow; j++) for (k = 0; k < nrow; k++) - if (data3[j * nrow + k ] != data4[j * nrow + k ]) + if (data3[j * nrow + k] != data4[j * nrow + k]) FAIL_PUTS_ERROR("comparison of image values with original data failed"); /* close dataspace */ - if (H5Sclose (file_space) < 0) + if (H5Sclose(file_space) < 0) FAIL_PUTS_ERROR("H5Sclose() failed"); /* close dataset */ @@ -485,7 +500,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("HDremove() failed"); /* free shared buffer if appropriate */ - if (!(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) || (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) { + if (!(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) || + (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) { VERIFY(buf_ptr[i] != NULL, "buffer pointer must be non NULL"); HDfree(buf_ptr[i]); } /* end if */ @@ -512,15 +528,16 @@ error: } /*------------------------------------------------------------------------- -* the main program -*------------------------------------------------------------------------- -*/ -int main( void ) + * the main program + *------------------------------------------------------------------------- + */ +int +main(void) { - int nerrors = 0; - size_t open_images = 10; /* number of open file images */ - size_t nflags = 8; /* number of flag combinations */ - unsigned flags[8]; /* array with flag combinations */ + int nerrors = 0; + size_t open_images = 10; /* number of open file images */ + size_t nflags = 8; /* number of flag combinations */ + unsigned flags[8]; /* array with flag combinations */ /* set flag combinations for testing */ flags[0] = 0; @@ -533,14 +550,14 @@ int main( void ) flags[7] = H5LT_FILE_IMAGE_OPEN_RW | H5LT_FILE_IMAGE_DONT_COPY | H5LT_FILE_IMAGE_DONT_RELEASE; /* Test file image operations. The flag combinations are assigned to file images in round-robin fashion */ - nerrors += test_file_image(open_images, nflags, flags) < 0? 1 : 0; + nerrors += test_file_image(open_images, nflags, flags) < 0 ? 1 : 0; - if (nerrors) goto error; + if (nerrors) + goto error; HDprintf("File image tests passed.\n"); return 0; error: - HDprintf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d IMAGE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } - diff --git a/hl/test/test_h5do_compat.c b/hl/test/test_h5do_compat.c index 75028fb..7efef3f 100644 --- a/hl/test/test_h5do_compat.c +++ b/hl/test/test_h5do_compat.c @@ -20,12 +20,11 @@ #ifndef H5_NO_DEPRECATED_SYMBOLS -#define FILE_NAME "h5do_compat.h5" -#define DATASET_NAME "direct_chunk_io" - -#define NX 8 -#define CHUNK_NX 4 +#define FILE_NAME "h5do_compat.h5" +#define DATASET_NAME "direct_chunk_io" +#define NX 8 +#define CHUNK_NX 4 /*------------------------------------------------------------------------- * Function: test_direct_chunk_write @@ -40,12 +39,12 @@ static hid_t create_dataset(hid_t fid) { - hid_t did = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hsize_t dims[1] = {NX}; - hsize_t maxdims[1] = {H5S_UNLIMITED}; - hsize_t chunk_dims[1] = {CHUNK_NX}; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hsize_t dims[1] = {NX}; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t chunk_dims[1] = {CHUNK_NX}; int data[NX]; int i; @@ -79,19 +78,19 @@ create_dataset(hid_t fid) return did; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); H5Pclose(dcpl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return H5I_INVALID_HID; } /* end create_dataset() */ - - /*------------------------------------------------------------------------- * Function: test_direct_chunk_write * @@ -105,11 +104,11 @@ create_dataset(hid_t fid) static int test_direct_chunk_write(hid_t did) { - unsigned filter_mask = 0; - int chunk_data[CHUNK_NX]; - hsize_t offset[1]; - size_t data_size; - int i; + unsigned filter_mask = 0; + int chunk_data[CHUNK_NX]; + hsize_t offset[1]; + size_t data_size; + int i; HL_TESTING2("H5DOwrite_chunk wrapper"); @@ -124,7 +123,7 @@ test_direct_chunk_write(hid_t did) * dataset, using the direct writing function. */ offset[0] = 0; - for (i = 0; i < NX/CHUNK_NX; i++) { + for (i = 0; i < NX / CHUNK_NX; i++) { if (H5DOwrite_chunk(did, H5P_DEFAULT, filter_mask, offset, data_size, chunk_data) < 0) TEST_ERROR offset[0] += CHUNK_NX; @@ -138,7 +137,6 @@ error: return 1; } /* test_direct_chunk_write() */ - /*------------------------------------------------------------------------- * Function: test_direct_chunk_read * @@ -152,22 +150,22 @@ error: static int test_direct_chunk_read(hid_t did) { - hid_t mem_sid = H5I_INVALID_HID; - hid_t file_sid = H5I_INVALID_HID; - hsize_t dims[1] = {NX}; - hsize_t chunk_dims[1] = {CHUNK_NX}; + hid_t mem_sid = H5I_INVALID_HID; + hid_t file_sid = H5I_INVALID_HID; + hsize_t dims[1] = {NX}; + hsize_t chunk_dims[1] = {CHUNK_NX}; - unsigned filter_mask; - int chunk_data[CHUNK_NX]; /* Chunk read with H5DOread_chunk */ - int check[CHUNK_NX]; /* Chunk read with H5Dread */ - hsize_t offset[1]; + unsigned filter_mask; + int chunk_data[CHUNK_NX]; /* Chunk read with H5DOread_chunk */ + int check[CHUNK_NX]; /* Chunk read with H5Dread */ + hsize_t offset[1]; - hsize_t start[1]; /* Start of hyperslab */ - hsize_t stride[1]; /* Stride of hyperslab */ - hsize_t count[1]; /* Block count */ - hsize_t block[1]; /* Block sizes */ + hsize_t start[1]; /* Start of hyperslab */ + hsize_t stride[1]; /* Stride of hyperslab */ + hsize_t count[1]; /* Block count */ + hsize_t block[1]; /* Block sizes */ - int i,j; + int i, j; HL_TESTING2("H5DOread_chunk wrapper"); @@ -178,7 +176,7 @@ test_direct_chunk_read(hid_t did) TEST_ERROR /* For each chunk in the dataset, compare the result of H5Dread and H5DOread_chunk. */ - for (i = 0; i < NX/CHUNK_NX; i++) { + for (i = 0; i < NX / CHUNK_NX; i++) { /* Select hyperslab for one chunk in the file */ start[0] = (hsize_t)i * CHUNK_NX; @@ -197,7 +195,7 @@ test_direct_chunk_read(hid_t did) /* Read the raw chunk back */ HDmemset(chunk_data, 0, CHUNK_NX * sizeof(int)); filter_mask = UINT_MAX; - offset[0] = (hsize_t)i * CHUNK_NX; + offset[0] = (hsize_t)i * CHUNK_NX; if (H5DOread_chunk(did, H5P_DEFAULT, offset, &filter_mask, chunk_data) < 0) TEST_ERROR @@ -221,10 +219,12 @@ test_direct_chunk_read(hid_t did) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(mem_sid); H5Sclose(file_sid); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return 1; @@ -232,7 +232,6 @@ error: #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: main * @@ -244,7 +243,8 @@ error: * *------------------------------------------------------------------------- */ -int main( void ) +int +main(void) { #ifdef H5_NO_DEPRECATED_SYMBOLS @@ -254,9 +254,9 @@ int main( void ) #else - hid_t fid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - int nerrors = 0; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + int nerrors = 0; if ((fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 6d13419..c67b04f 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -39,10 +39,9 @@ #define PAL3_NAME "earth" #define PAL4_NAME "blue-red" - -#define WIDTH 400 -#define HEIGHT 200 -#define PAL_ENTRIES 256 +#define WIDTH 400 +#define HEIGHT 200 +#define PAL_ENTRIES 256 /* struct to store RGB values read from a .pal file */ typedef struct rgb_t { @@ -55,54 +54,57 @@ typedef struct rgb_t { static int test_simple(void); static int test_data(void); static int test_generate(void); -static int read_data(const char* file_name, hsize_t *width, hsize_t *height ); -static int read_palette(const char* file_name, rgb_t *palette, size_t palette_size); +static int read_data(const char *file_name, hsize_t *width, hsize_t *height); +static int read_palette(const char *file_name, rgb_t *palette, size_t palette_size); /* globals */ unsigned char *image_data = NULL; /*------------------------------------------------------------------------- -* the main program -*------------------------------------------------------------------------- -*/ + * the main program + *------------------------------------------------------------------------- + */ -int main(void) +int +main(void) { - int nerrors=0; + int nerrors = 0; - nerrors += test_simple()<0 ?1:0; - nerrors += test_data()<0 ?1:0; - nerrors += test_generate()<0 ?1:0; + nerrors += test_simple() < 0 ? 1 : 0; + nerrors += test_data() < 0 ? 1 : 0; + nerrors += test_generate() < 0 ? 1 : 0; - if (nerrors) goto error; + if (nerrors) + goto error; HDprintf("All image tests passed.\n"); return 0; error: - HDprintf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d IMAGE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } /*------------------------------------------------------------------------- -* a simple test that generates images and palettes -*------------------------------------------------------------------------- -*/ + * a simple test that generates images and palettes + *------------------------------------------------------------------------- + */ -static int test_simple(void) +static int +test_simple(void) { - hsize_t width = WIDTH; - hsize_t height = HEIGHT; - hsize_t planes; - hid_t fid; - int i, j, n, space; - hsize_t u; - char interlace[20]; - hssize_t npals; + hsize_t width = WIDTH; + hsize_t height = HEIGHT; + hsize_t planes; + hid_t fid; + int i, j, n, space; + hsize_t u; + char interlace[20]; + hssize_t npals; /* 8-bit image */ unsigned char *buf1 = NULL; - unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */ - hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */ + unsigned char pal[PAL_ENTRIES * 3]; /* palette array */ + hsize_t pal_dims[2] = {PAL_ENTRIES, 3}; /* palette dimensions */ /* 24-bit image */ unsigned char *buf2 = NULL; @@ -110,395 +112,376 @@ static int test_simple(void) /* read data */ unsigned char *buf1_out = NULL; unsigned char *buf2_out = NULL; - unsigned char pal_out[ PAL_ENTRIES * 3 ]; /* palette array */ - hsize_t pal_dims_out[2]; /* palette dimensions */ + unsigned char pal_out[PAL_ENTRIES * 3]; /* palette array */ + hsize_t pal_dims_out[2]; /* palette dimensions */ /* Allocate image buffers */ buf1 = (unsigned char *)HDmalloc(WIDTH * HEIGHT); HDassert(buf1); - buf2 = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3); + buf2 = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3); HDassert(buf2); buf1_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT); HDassert(buf1_out); - buf2_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3); + buf2_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3); HDassert(buf2_out); /* create an image */ - space = WIDTH*HEIGHT / PAL_ENTRIES; - for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ ) - { + space = WIDTH * HEIGHT / PAL_ENTRIES; + for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT; i++, j++) { buf1[i] = (unsigned char)n; - if ( j > space ) - { + if (j > space) { n++; - j=0; + j = 0; } - } /* create an image */ - space = WIDTH*HEIGHT / 256; - for (i=0, j=0, n=0; i < WIDTH*HEIGHT*3; i+=3, j++ ) - { - buf2[i] = (unsigned char)n; - buf2[i+1] = 0; - buf2[i+2] = (unsigned char)(255 - n); - if ( j > space ) - { + space = WIDTH * HEIGHT / 256; + for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT * 3; i += 3, j++) { + buf2[i] = (unsigned char)n; + buf2[i + 1] = 0; + buf2[i + 2] = (unsigned char)(255 - n); + if (j > space) { n++; - j=0; + j = 0; } } /*------------------------------------------------------------------------- - * define a palette, blue to red tones - *------------------------------------------------------------------------- - */ - for ( i=0, n=0; i INT_MAX / jmax) + if (imax > INT_MAX / jmax) goto out; - if(imax * jmax > INT_MAX / kmax) + if (imax * jmax > INT_MAX / kmax) goto out; n_elements = imax * jmax * kmax; /* Test buffer sizes for overflow */ - if(n_elements > INT_MAX / (int)sizeof(unsigned char)) + if (n_elements > INT_MAX / (int)sizeof(unsigned char)) goto out; - if(n_elements > INT_MAX / (int)sizeof(float)) + if (n_elements > INT_MAX / (int)sizeof(float)) goto out; data = (float *)HDmalloc((size_t)n_elements * sizeof(float)); - if(NULL == data) + if (NULL == data) goto out; image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); - if(NULL == image_data) + if (NULL == image_data) goto out; - for ( i = 0; i < n_elements; i++ ) - { - if(fscanf( f, "%f ", &value ) < 0 && HDferror(f)) { - HDprintf( "fscanf error in file %s.\n", data_file ); + for (i = 0; i < n_elements; i++) { + if (fscanf(f, "%f ", &value) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ data[i] = value; @@ -647,93 +629,90 @@ static int test_generate(void) f = NULL; /*------------------------------------------------------------------------- - * transform the data from floating point to unsigned char - * we are processing all the data here - *------------------------------------------------------------------------- - */ + * transform the data from floating point to unsigned char + * we are processing all the data here + *------------------------------------------------------------------------- + */ HL_TESTING2("make indexed image from all the data"); - for ( i = 0; i < n_elements; i++ ) - image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / (xmax - xmin )); + for (i = 0; i < n_elements; i++) + image_data[i] = (unsigned char)((255 * (data[i] - xmin)) / (xmax - xmin)); /* Make the image */ - if ((H5IMmake_image_8bit(fid,"All data",(hsize_t)imax,(hsize_t)jmax,image_data))<0) + if ((H5IMmake_image_8bit(fid, "All data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0) goto out; PASSED(); /*------------------------------------------------------------------------- - * transform the data from floating point to unsigned char - * here we just process the land data - *------------------------------------------------------------------------- - */ + * transform the data from floating point to unsigned char + * here we just process the land data + *------------------------------------------------------------------------- + */ HL_TESTING2("make indexed image from land data"); - for ( i = 0; i < n_elements; i++ ) - { - if ( data[i] < 0 ) + for (i = 0; i < n_elements; i++) { + if (data[i] < 0) image_data[i] = 0; else - image_data[i] = (unsigned char)(( 255 * (data[i] ) ) / xmax ); + image_data[i] = (unsigned char)((255 * (data[i])) / xmax); } /* make the image */ - if ((H5IMmake_image_8bit(fid,"Land data",(hsize_t)imax,(hsize_t)jmax,image_data))<0) + if ((H5IMmake_image_8bit(fid, "Land data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0) goto out; PASSED(); /*------------------------------------------------------------------------- - * transform the data from floating point to unsigned char - * here we just process the sea data - *------------------------------------------------------------------------- - */ + * transform the data from floating point to unsigned char + * here we just process the sea data + *------------------------------------------------------------------------- + */ HL_TESTING2("make indexed image from sea data"); - for ( i = 0; i < n_elements; i++ ) - { - if ( data[i] > 0 ) + for (i = 0; i < n_elements; i++) { + if (data[i] > 0) image_data[i] = 0; else - image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / xmin ); + image_data[i] = (unsigned char)((255 * (data[i] - xmin)) / xmin); } /* make the image */ - if ((H5IMmake_image_8bit(fid,"Sea data",(hsize_t)imax,(hsize_t)jmax,image_data))<0) + if ((H5IMmake_image_8bit(fid, "Sea data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0) goto out; PASSED(); /*------------------------------------------------------------------------- - * make a palette and attach it to the datasets - *------------------------------------------------------------------------- - */ + * make a palette and attach it to the datasets + *------------------------------------------------------------------------- + */ HL_TESTING2("attaching palettes"); /* make a palette */ - if ((H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb))<0) + if ((H5IMmake_palette(fid, PAL1_NAME, pal_dims, pal_rgb)) < 0) goto out; /* attach the palette to the image datasets */ - if ((H5IMlink_palette(fid,"All data",PAL1_NAME))<0) + if ((H5IMlink_palette(fid, "All data", PAL1_NAME)) < 0) goto out; - if ((H5IMlink_palette(fid,"Land data",PAL1_NAME))<0) + if ((H5IMlink_palette(fid, "Land data", PAL1_NAME)) < 0) goto out; - if ((H5IMlink_palette(fid,"Sea data",PAL1_NAME))<0) + if ((H5IMlink_palette(fid, "Sea data", PAL1_NAME)) < 0) goto out; PASSED(); - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if (H5Fclose(fid)<0) + * close + *------------------------------------------------------------------------- + */ + if (H5Fclose(fid) < 0) goto out; /* Release memory buffers */ @@ -746,122 +725,124 @@ static int test_generate(void) /* error zone, gracefully close */ out: /* Release memory buffers */ - if(data) + if (data) HDfree(data); - if(image_data) + if (image_data) HDfree(image_data); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; - if(f) + } + H5E_END_TRY; + if (f) HDfclose(f); H5_FAILED(); return retval; } - /*------------------------------------------------------------------------- -* read_data -* utility function to read ASCII image data -* the files have a header of the type -* -* components -* n -* height -* n -* width -* n -* -* followed by the image data -* -*------------------------------------------------------------------------- -*/ - -static int read_data(const char* fname, /*IN*/ - hsize_t *width, /*OUT*/ - hsize_t *height /*OUT*/) + * read_data + * utility function to read ASCII image data + * the files have a header of the type + * + * components + * n + * height + * n + * width + * n + * + * followed by the image data + * + *------------------------------------------------------------------------- + */ + +static int +read_data(const char *fname, /*IN*/ + hsize_t * width, /*OUT*/ + hsize_t * height /*OUT*/) { - int i, n; - int color_planes; - char str[20]; - FILE *f = NULL; - int w, h; - int n_elements; + int i, n; + int color_planes; + char str[20]; + FILE * f = NULL; + int w, h; + int n_elements; const char *data_file = H5_get_srcdir_filename(fname); - int ret_val = -1; + int ret_val = -1; /*------------------------------------------------------------------------- - * read - *------------------------------------------------------------------------- - */ + * read + *------------------------------------------------------------------------- + */ - if(NULL == (f = HDfopen(data_file, "r"))) { - HDprintf( "Could not open file %s. Try set $srcdir \n", data_file ); + if (NULL == (f = HDfopen(data_file, "r"))) { + HDprintf("Could not open file %s. Try set $srcdir \n", data_file); goto out; } - if(fscanf(f, "%s", str) < 0 && HDferror(f)) { - HDprintf( "fscanf error in file %s.\n", data_file ); + if (fscanf(f, "%s", str) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if(fscanf(f, "%d", &color_planes) < 0 && HDferror(f)) { - HDprintf( "fscanf error in file %s.\n", data_file ); + if (fscanf(f, "%d", &color_planes) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if(fscanf(f, "%s", str) < 0 && HDferror(f)) { - HDprintf( "fscanf error in file %s.\n", data_file ); + if (fscanf(f, "%s", str) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if(fscanf(f, "%d", &h) < 0 && HDferror(f)) { - HDprintf( "fscanf error in file %s.\n", data_file ); + if (fscanf(f, "%d", &h) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if(fscanf(f, "%s", str) < 0 && HDferror(f)) { - HDprintf( "fscanf error in file %s.\n", data_file ); + if (fscanf(f, "%s", str) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if(fscanf(f, "%d", &w) < 0 && HDferror(f)) { - HDprintf( "fscanf error in file %s.\n", data_file ); + if (fscanf(f, "%d", &w) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ /* Check product for overflow */ - if(w < 1 || h < 1 || color_planes < 1) + if (w < 1 || h < 1 || color_planes < 1) goto out; - if(w > INT_MAX / h) + if (w > INT_MAX / h) goto out; - if(w * h > INT_MAX / color_planes) + if (w * h > INT_MAX / color_planes) goto out; /* Compute buffer size */ n_elements = w * h * color_planes; /* Check buffer size for overflow */ - if(n_elements > INT_MAX / (int)sizeof(unsigned char)) + if (n_elements > INT_MAX / (int)sizeof(unsigned char)) goto out; /* Release the buffer, if it was previously allocated */ - if(image_data) + if (image_data) HDfree(image_data); /* Allocate the image data buffer */ image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); - if(NULL == image_data) + if (NULL == image_data) goto out; - *width = (hsize_t)w; + *width = (hsize_t)w; *height = (hsize_t)h; /* Read data elements */ - for(i = 0; i < n_elements; i++) { - if(fscanf(f, "%d", &n) < 0 && HDferror(f)) { - HDprintf( "fscanf error in file %s.\n", data_file ); + for (i = 0; i < n_elements; i++) { + if (fscanf(f, "%d", &n) < 0 && HDferror(f)) { + HDprintf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ image_data[i] = (unsigned char)n; @@ -871,123 +852,108 @@ static int read_data(const char* fname, /*IN*/ ret_val = 1; out: - if(f) + if (f) HDfclose(f); return ret_val; } /* end read_data() */ - /*------------------------------------------------------------------------- -* read_palette -* Read an ASCII palette file .PAL into an array -* the files have a header of the type -* -* Parameters: -* fname - name of file to read. -* palette - array of rgb_t to store the read palette. -* palette_size - number of elements in 'palette' array -* -*------------------------------------------------------------------------- -*/ - + * read_palette + * Read an ASCII palette file .PAL into an array + * the files have a header of the type + * + * Parameters: + * fname - name of file to read. + * palette - array of rgb_t to store the read palette. + * palette_size - number of elements in 'palette' array + * + *------------------------------------------------------------------------- + */ #define STRING_JASC "JASC-PAL" #define VERSION_JASC "0100" #define STRING_CWPAL "CWPAL" #define VERSION_CWPAL "100" -static int read_palette(const char* fname, - rgb_t *palette, - size_t palette_size) +static int +read_palette(const char *fname, rgb_t *palette, size_t palette_size) { - FILE *file; - char buffer[80]; - unsigned u; - unsigned int red; - unsigned int green; - unsigned int blue; - unsigned nentries; - const char *data_file = H5_get_srcdir_filename(fname); + FILE * file; + char buffer[80]; + unsigned u; + unsigned int red; + unsigned int green; + unsigned int blue; + unsigned nentries; + const char * data_file = H5_get_srcdir_filename(fname); /* ensure the given palette is valid */ if (!palette) return -1; /* open the input file */ - if (!(file = HDfopen(data_file, "r"))) - { - HDprintf( "Could not open file %s. Try set $srcdir \n", data_file ); + if (!(file = HDfopen(data_file, "r"))) { + HDprintf("Could not open file %s. Try set $srcdir \n", data_file); return -1; } /* read the file ident string */ - if (HDfgets(buffer, sizeof(buffer), file) == NULL) - { + if (HDfgets(buffer, sizeof(buffer), file) == NULL) { HDfclose(file); return -1; } /* ensure it matches the palette file ident string */ - if ( HDstrncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 && - HDstrncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0 ) - { + if (HDstrncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 && + HDstrncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0) { HDfclose(file); return -1; } /* read the version string */ - if (HDfgets(buffer, sizeof(buffer), file) == NULL) - { + if (HDfgets(buffer, sizeof(buffer), file) == NULL) { HDfclose(file); return -1; } /* ensure it matches the palette file version string */ - if ( HDstrncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 && - HDstrncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0 ) - { + if (HDstrncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 && + HDstrncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0) { HDfclose(file); return -1; } /* read the number of colors */ - if (HDfgets(buffer, sizeof(buffer), file) == NULL) - { + if (HDfgets(buffer, sizeof(buffer), file) == NULL) { HDfclose(file); return -1; } - /* extract the number of colors. check for missing version or number of colors in this case it reads the first entry */ - if ( HDstrlen( buffer ) > 4 ) - { + if (HDstrlen(buffer) > 4) { HDfclose(file); return -1; } - if (sscanf(buffer, "%u", &nentries) != 1) - { + if (sscanf(buffer, "%u", &nentries) != 1) { HDfclose(file); return -1; } /* ensure there are a sensible number of colors in the palette */ - if ((nentries > 256) || (nentries > palette_size)) - { + if ((nentries > 256) || (nentries > palette_size)) { HDfclose(file); - return(-1); + return (-1); } /* read the palette entries */ - for (u = 0; u < nentries; u++) - { + for (u = 0; u < nentries; u++) { /* extract the red, green and blue color components. */ - if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3) - { + if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3) { HDfclose(file); return -1; } @@ -1002,4 +968,3 @@ static int read_palette(const char* fname, return (int)nentries; } - diff --git a/hl/test/test_ld.c b/hl/test/test_ld.c index e3cde5d..342397a 100644 --- a/hl/test/test_ld.c +++ b/hl/test/test_ld.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -26,17 +26,17 @@ #define COPY_FILENAME "COPY_test_ld.h5" /* Dataset names */ -#define DSET_ONE "DSET_ONE" -#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ONE "DSET_ONE" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" #define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" -#define DSET_TWO "DSET_TWO" -#define TWO_DIM_1 4 -#define TWO_DIM_2 10 -#define DSET_CMPD "DSET_CMPD" -#define DSET_CMPD_ESC "DSET_CMPD_ESC" -#define DSET_CMPD_TWO "DSET_CMPD_TWO" -#define DSET_NULL "DSET_NULL" -#define DSET_SCALAR "DSET_SCALAR" +#define DSET_TWO "DSET_TWO" +#define TWO_DIM_1 4 +#define TWO_DIM_2 10 +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_NULL "DSET_NULL" +#define DSET_SCALAR "DSET_SCALAR" /* Selected compound field members for testing */ #define VALID_FIELDS1 "field1,field2.a,field3,field4" /* TEMPORORAY */ @@ -57,7 +57,7 @@ * Test variations (retained original) for one-dimensional dataset: * Varies from 10->13; 10->9, 10->10, 10->1, 10->11 */ -#define ONE_NTESTS 5 +#define ONE_NTESTS 5 int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1}; /* @@ -66,88 +66,92 @@ int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1}; * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} */ -#define TWO_NTESTS 9 -int two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0}, - {-1,2}, {-1,-1}, {-1,0}, - {0,2}, {0,-1}, {0,0} }; - +#define TWO_NTESTS 9 +int two_tests[TWO_NTESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {-1, -1}, {-1, 0}, {0, 2}, {0, -1}, {0, 0}}; /* Verify that the two input values are the same */ -#define VERIFY_EQUAL(_x, _y) \ -{ \ - long __x = (long)_x, __y = (long)_y; \ - if(__x != __y) TEST_ERROR \ -} +#define VERIFY_EQUAL(_x, _y) \ + { \ + long __x = (long)_x, __y = (long)_y; \ + if (__x != __y) \ + TEST_ERROR \ + } /* Temporary buffer for reading in the test file */ -#define TMP_BUF_SIZE 2048 -char g_tmp_buf[TMP_BUF_SIZE]; +#define TMP_BUF_SIZE 2048 +char g_tmp_buf[TMP_BUF_SIZE]; /* Macros for verifying compound fields */ /* Verify all fields */ -#define VERIFY_ELMTS_ALL(ent1, ent2) { \ - VERIFY_EQUAL(ent1.field1, ent2.field1); \ - VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \ - VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \ - VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \ - VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \ - VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \ - VERIFY_EQUAL(ent1.field3, ent2.field3); \ - VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ -} +#define VERIFY_ELMTS_ALL(ent1, ent2) \ + { \ + VERIFY_EQUAL(ent1.field1, ent2.field1); \ + VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \ + VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \ + VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \ + VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \ + VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \ + VERIFY_EQUAL(ent1.field3, ent2.field3); \ + VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ + } /* Verify fields selected in VALID_FIELDS1 */ -#define VERIFY_ELMTS_VALID1(ent1, ent2) { \ - VERIFY_EQUAL(ent1.field1, ent2.field1); \ - VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \ - VERIFY_EQUAL(ent1.field3, ent2.field3); \ - VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ - VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \ -} +#define VERIFY_ELMTS_VALID1(ent1, ent2) \ + { \ + VERIFY_EQUAL(ent1.field1, ent2.field1); \ + VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \ + VERIFY_EQUAL(ent1.field3, ent2.field3); \ + VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ + VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \ + } /* Verify fields selected in VALID_FIELDS2 */ -#define VERIFY_ELMTS_VALID2(ent1, ent2) { \ - VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \ - VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \ - VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \ -} +#define VERIFY_ELMTS_VALID2(ent1, ent2) \ + { \ + VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \ + VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \ + VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \ + } /* The types of 2-dimensional dataset: DSET_TWO or DSET_CMPD_TWO */ -#define TWO_NONE 0 /* DSET_TWO */ -#define TWO_CMPD_NULL 1 /* DSET_CMPD_TWO with NULL fields */ -#define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */ -#define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */ - -#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) { \ - if(type == TWO_NONE) { \ - int *iib = (int *)_ldbuf; \ - int *ib = (int *)_buf; \ - \ - VERIFY_EQUAL(iib[k], ib[ind + n]) \ - } else if(type == TWO_CMPD_NULL) { \ - set_t *ccb = (set_t *)_ldbuf; \ - set_t *cb = (set_t *)_buf; \ - \ - VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \ - } else if(type == TWO_CMPD_VALID1) { \ - test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \ - set_t *cb = (set_t *)_buf; \ - \ - VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \ - } else if(type == TWO_CMPD_VALID2) { \ - test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \ - set_t *cb = (set_t *)_buf; \ - \ - VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \ - } \ -} +#define TWO_NONE 0 /* DSET_TWO */ +#define TWO_CMPD_NULL 1 /* DSET_CMPD_TWO with NULL fields */ +#define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */ +#define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */ + +#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) \ + { \ + if (type == TWO_NONE) { \ + int *iib = (int *)_ldbuf; \ + int *ib = (int *)_buf; \ + \ + VERIFY_EQUAL(iib[k], ib[ind + n]) \ + } \ + else if (type == TWO_CMPD_NULL) { \ + set_t *ccb = (set_t *)_ldbuf; \ + set_t *cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \ + } \ + else if (type == TWO_CMPD_VALID1) { \ + test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \ + set_t * cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \ + } \ + else if (type == TWO_CMPD_VALID2) { \ + test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \ + set_t * cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \ + } \ + } /* Tests for test_LD_elmts_pipe() */ -#define ONE_TESTS 3 -int onetests[ONE_TESTS] = {3, 9, 1}; -#define TWO_TESTS 5 -int twotests[TWO_TESTS][2] = { {2,2}, {2,-1}, {2,0}, {-1,2}, {0,2} }; - +#define ONE_TESTS 3 +int onetests[ONE_TESTS] = {3, 9, 1}; +#define TWO_TESTS 5 +int twotests[TWO_TESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {0, 2}}; static herr_t test_LD_dims_params(const char *file); static herr_t test_LD_dims(const char *file); @@ -158,7 +162,7 @@ static herr_t test_LD_elmts_invalid(const char *file); static herr_t test_LD_elmts_one(const char *file, const char *dname, const char *fields); static herr_t test_LD_elmts_two(const char *file, const char *dname, const char *fields); -static herr_t verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf); +static herr_t verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf); /* data structures for compound data type */ typedef struct sub22_t { @@ -168,9 +172,9 @@ typedef struct sub22_t { } sub22_t; typedef struct sub2_t { - int a; + int a; sub22_t b; - int c; + int c; } sub2_t; typedef struct sub4_t { @@ -179,7 +183,7 @@ typedef struct sub4_t { } sub4_t; typedef struct set_t { - int field1; + int field1; sub2_t field2; double field3; sub4_t field4; @@ -195,8 +199,8 @@ typedef struct set_t { /* VALID_FIELDS1 "field1,field2.a,field3,field4" */ /* VALID_ESC_FIELDS1 "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */ typedef struct test_valid_fields1 { - int field1; - int field2_a; + int field1; + int field2_a; double field3; sub4_t field4; } test_valid_fields1; @@ -209,16 +213,14 @@ typedef struct test_valid_fields2 { int field4_b; } test_valid_fields2; - /* Temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */ -#define TEST_BUF_SIZE 100 -int *iibuf; /* buffer for storing retrieved elements */ -int *ibuf; /* buffer for storing retrieved elements (integer) */ -set_t *cbuf; /* buffer for storing retrieved elemnets (compound) */ -set_t *ccbuf; /* buffer for storing retrieved elemnets (compound) */ -test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */ -test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */ - +#define TEST_BUF_SIZE 100 +int * iibuf; /* buffer for storing retrieved elements */ +int * ibuf; /* buffer for storing retrieved elements (integer) */ +set_t * cbuf; /* buffer for storing retrieved elemnets (compound) */ +set_t * ccbuf; /* buffer for storing retrieved elemnets (compound) */ +test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */ +test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */ /* ********************************************************************************* @@ -236,109 +238,114 @@ test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) static herr_t test_LD_dims_params(const char *file) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ - hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ - hid_t invalid_id = -1; - herr_t ret; /* return value */ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ + hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ + hid_t invalid_id = -1; + herr_t ret; /* return value */ const char *filename = H5_get_srcdir_filename(file); HL_TESTING2("H5LDget_dset_dims"); /* Open the copied file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* * 1. Verify failure with negative dataset id */ - H5E_BEGIN_TRY { - ret = H5LDget_dset_dims(invalid_id, one_cur_dims); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5LDget_dset_dims(invalid_id, one_cur_dims); + } + H5E_END_TRY; VERIFY_EQUAL(ret, FAIL) /* * 2. Verify failure for NULL cur_dims */ - if((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - H5E_BEGIN_TRY { - ret = H5LDget_dset_dims(did, NULL); - } H5E_END_TRY; + if ((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + ret = H5LDget_dset_dims(did, NULL); + } + H5E_END_TRY; VERIFY_EQUAL(ret, FAIL) - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* * 3. Verify for nonNULL cur_dims */ - if((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5LDget_dset_dims(did, one_cur_dims) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR VERIFY_EQUAL(one_cur_dims[0], 10) - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* * 4. Verify nonNULL cur_dims for a 2-dimensional dataset */ - if((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if(H5LDget_dset_dims(did, two_cur_dims) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5LDget_dset_dims(did, two_cur_dims) < 0) + FAIL_STACK_ERROR VERIFY_EQUAL(two_cur_dims[0], TWO_DIM_1) VERIFY_EQUAL(two_cur_dims[1], TWO_DIM_2) - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* * 5. Verify nonNULL cur_dims for dataset with H5S_NULL dataspace */ one_cur_dims[0] = 0; - if((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if(H5LDget_dset_dims(did, one_cur_dims) < 0) - FAIL_STACK_ERROR + if (H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR VERIFY_EQUAL(one_cur_dims[0], 0) - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* * 6. Verify nonNULL cur_dims for dataset with H5S_SCALAR dataspace */ one_cur_dims[0] = 0; - if((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if(H5LDget_dset_dims(did, one_cur_dims) < 0) - FAIL_STACK_ERROR + if (H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR VERIFY_EQUAL(one_cur_dims[0], 0) - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Dclose(did); - H5Fclose(fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; - return(-1); + return (-1); } /* test_LD_dims_params() */ - /* ********************************************************************************* * @@ -379,93 +386,93 @@ error: static herr_t test_LD_dims(const char *file) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */ - hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ - hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */ - hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */ - hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ - hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/ - int i; /* local index variable */ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */ + hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ + hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */ + hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */ + hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ + hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/ + int i; /* local index variable */ HL_TESTING2("H5LDget_dset_dims with H5Dset_extent"); /* Make a copy of the test file */ - if(h5_make_local_copy(file, COPY_FILENAME) < 0) + if (h5_make_local_copy(file, COPY_FILENAME) < 0) TEST_ERROR /* Open the copied file */ - if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* * Testing with one-dimensional dataset: DSET_ONE */ - if((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Retrieve dimension sizes */ - if(H5LDget_dset_dims(did, one_prev_dims) < 0) - FAIL_STACK_ERROR + if (H5LDget_dset_dims(did, one_prev_dims) < 0) + FAIL_STACK_ERROR - for(i = 0; i < ONE_NTESTS; i++) { + for (i = 0; i < ONE_NTESTS; i++) { - /* Set up the extended dimension sizes */ - one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]); + /* Set up the extended dimension sizes */ + one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]); - /* Change the dimension size */ - if(H5Dset_extent(did, one_ext_dims) < 0) - FAIL_STACK_ERROR + /* Change the dimension size */ + if (H5Dset_extent(did, one_ext_dims) < 0) + FAIL_STACK_ERROR - /* Retrieve the dimension size */ - if(H5LDget_dset_dims(did, one_cur_dims) < 0) - FAIL_STACK_ERROR + /* Retrieve the dimension size */ + if (H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR - /* Verify that the retrieved dimension size is correct as expected */ - VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0]) + /* Verify that the retrieved dimension size is correct as expected */ + VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0]) } /* Close the dataset */ - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* * Testing with two-dimensional dataset: DSET_TWO */ - if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Retrieve the dimension sizes */ - if(H5LDget_dset_dims(did, two_prev_dims) < 0) - FAIL_STACK_ERROR + if (H5LDget_dset_dims(did, two_prev_dims) < 0) + FAIL_STACK_ERROR - for(i = 0; i < TWO_NTESTS; i++) { + for (i = 0; i < TWO_NTESTS; i++) { - /* Set up the extended dimension sizes */ - two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]); - two_ext_dims[1] = (hsize_t) ((int)two_prev_dims[1] + two_tests[i][1]); + /* Set up the extended dimension sizes */ + two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]); + two_ext_dims[1] = (hsize_t)((int)two_prev_dims[1] + two_tests[i][1]); - /* Change the dimension sizes */ - if(H5Dset_extent(did, two_ext_dims) < 0) - FAIL_STACK_ERROR + /* Change the dimension sizes */ + if (H5Dset_extent(did, two_ext_dims) < 0) + FAIL_STACK_ERROR - /* Retrieve the dimension sizes */ - if(H5LDget_dset_dims(did, two_cur_dims) < 0) - FAIL_STACK_ERROR + /* Retrieve the dimension sizes */ + if (H5LDget_dset_dims(did, two_cur_dims) < 0) + FAIL_STACK_ERROR - /* Verify that the retrieved dimension sizes are correct as expected */ - VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0]) - VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1]) + /* Verify that the retrieved dimension sizes are correct as expected */ + VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0]) + VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1]) } /* end TWO_NTESTS */ /* Close the dataset */ - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Remove the copied file */ HDremove(COPY_FILENAME); @@ -474,15 +481,16 @@ test_LD_dims(const char *file) return 0; error: - H5E_BEGIN_TRY { - H5Dclose(did); - H5Fclose(fid); - } H5E_END_TRY; - return(-1); + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); } /* test_LD_dims() */ - /* ********************************************************************************** * @@ -514,33 +522,35 @@ error: static int test_LD_size(const char *file) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hid_t dtid=-1; /* dataset's datatype identifier */ - hid_t invalid_id=-1; - hid_t memb0_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb1_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb2_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb3_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb_tid2=-1; /* type identifier for a member in the compound type */ - size_t dsize; /* size of the dataset's datatype */ - size_t ck_dsize; /* size of the dataset's datatype to be checked against */ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hid_t dtid = -1; /* dataset's datatype identifier */ + hid_t invalid_id = -1; + hid_t memb0_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb1_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb2_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb3_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb_tid = -1; /* type identifier for a member in the compound type */ + hid_t memb_tid2 = -1; /* type identifier for a member in the compound type */ + size_t dsize; /* size of the dataset's datatype */ + size_t ck_dsize; /* size of the dataset's datatype to be checked against */ const char *filename = H5_get_srcdir_filename(file); HL_TESTING2("H5LDget_dset_type_size"); /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* * Verify failure with an invalid dataset id */ - H5E_BEGIN_TRY { - dsize = H5LDget_dset_type_size(invalid_id, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + dsize = H5LDget_dset_type_size(invalid_id, NULL); + } + H5E_END_TRY; VERIFY_EQUAL(dsize, 0) /* @@ -549,91 +559,91 @@ test_LD_size(const char *file) */ /* Open dataset DSET_CMPD */ - if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Return size of the whole element */ - if((dsize = H5LDget_dset_type_size(did, NULL)) == 0) - FAIL_STACK_ERROR + if ((dsize = H5LDget_dset_type_size(did, NULL)) == 0) + FAIL_STACK_ERROR /* Get the dataset's datatype and then its datatype size */ - if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR - if((ck_dsize = H5Tget_size(dtid)) == 0) - FAIL_STACK_ERROR + if ((ck_dsize = H5Tget_size(dtid)) == 0) + FAIL_STACK_ERROR /* Verify case #1 */ VERIFY_EQUAL(dsize, ck_dsize) /* Get datatype id for each member */ - if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */ - FAIL_STACK_ERROR - if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */ - FAIL_STACK_ERROR - if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */ - FAIL_STACK_ERROR - if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */ - FAIL_STACK_ERROR + if ((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */ + FAIL_STACK_ERROR + if ((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */ + FAIL_STACK_ERROR + if ((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */ + FAIL_STACK_ERROR + if ((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */ + FAIL_STACK_ERROR /* Obtain size for VALID_FIELDS1: "field1,field2.a,field3,field4" */ - if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0) - FAIL_STACK_ERROR + if ((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0) + FAIL_STACK_ERROR /* Get the datatype size for "field1" */ - if((ck_dsize = H5Tget_size(memb0_tid)) == 0) - FAIL_STACK_ERROR + if ((ck_dsize = H5Tget_size(memb0_tid)) == 0) + FAIL_STACK_ERROR /* Add the datatype size for "field2.a" */ - if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) - FAIL_STACK_ERROR - if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + if ((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR /* Add the datatype size for "field3" */ - if((ck_dsize += H5Tget_size(memb2_tid)) == 0) - FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb2_tid)) == 0) + FAIL_STACK_ERROR /* Add the datatype size for "field4" */ - if((ck_dsize += H5Tget_size(memb3_tid)) == 0) - FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb3_tid)) == 0) + FAIL_STACK_ERROR /* Verify case #2 */ VERIFY_EQUAL(dsize, ck_dsize) /* Obtain datatype size for VALID_FIELDS2: "field2.b.a,field2.c,field4.b" */ - if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0) - FAIL_STACK_ERROR + if ((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0) + FAIL_STACK_ERROR /* Get the datatype size for "field2.b.a" */ - if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) - FAIL_STACK_ERROR - if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) - FAIL_STACK_ERROR - if((ck_dsize = H5Tget_size(memb_tid2)) == 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid2) < 0) - FAIL_STACK_ERROR + if ((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) + FAIL_STACK_ERROR + if ((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize = H5Tget_size(memb_tid2)) == 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid2) < 0) + FAIL_STACK_ERROR /* Add the datatype size for "field2.c" */ - if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) - FAIL_STACK_ERROR - if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + if ((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR /* Add the datatype size for "field4.b" */ - if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) - FAIL_STACK_ERROR - if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + if ((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR /* Verify case #3 */ VERIFY_EQUAL(dsize, ck_dsize) @@ -657,18 +667,18 @@ test_LD_size(const char *file) VERIFY_EQUAL(dsize, 0) /* Closing */ - if(H5Tclose(memb0_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(memb1_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(memb2_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(memb3_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(dtid) < 0) - FAIL_STACK_ERROR - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Tclose(memb0_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb1_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb2_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb3_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(dtid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* * Testing one-dimensional dataset with compound datatype and @@ -677,91 +687,91 @@ test_LD_size(const char *file) */ /* Open dataset DSET_CMPD_ESC */ - if((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Return size of the whole element */ - if((dsize = H5LDget_dset_type_size(did, NULL)) == 0) - FAIL_STACK_ERROR + if ((dsize = H5LDget_dset_type_size(did, NULL)) == 0) + FAIL_STACK_ERROR /* Get the dataset's datatype and then its datatype size */ - if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize = H5Tget_size(dtid)) == 0) FAIL_STACK_ERROR - if((ck_dsize = H5Tget_size(dtid)) == 0) - FAIL_STACK_ERROR /* Verify case #1 */ VERIFY_EQUAL(dsize, ck_dsize) /* Get datatype id for each member */ - if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */ - FAIL_STACK_ERROR - if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */ - FAIL_STACK_ERROR - if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */ - FAIL_STACK_ERROR - if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */ - FAIL_STACK_ERROR + if ((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */ + FAIL_STACK_ERROR + if ((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */ + FAIL_STACK_ERROR + if ((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */ + FAIL_STACK_ERROR + if ((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */ + FAIL_STACK_ERROR /* Obtain size for VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */ - if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0) - FAIL_STACK_ERROR + if ((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0) + FAIL_STACK_ERROR /* Get the datatype size for "field\\,1" */ - if((ck_dsize = H5Tget_size(memb0_tid)) == 0) - FAIL_STACK_ERROR + if ((ck_dsize = H5Tget_size(memb0_tid)) == 0) + FAIL_STACK_ERROR /* Add the datatype size for "field2\\..\\.a" */ - if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) - FAIL_STACK_ERROR - if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + if ((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR /* Add the datatype size for "field\\\\3" */ - if((ck_dsize += H5Tget_size(memb2_tid)) == 0) - FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb2_tid)) == 0) + FAIL_STACK_ERROR /* Add the datatype size for "field4\\," */ - if((ck_dsize += H5Tget_size(memb3_tid)) == 0) - FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb3_tid)) == 0) + FAIL_STACK_ERROR /* Verify case #2 */ VERIFY_EQUAL(dsize, ck_dsize) /* Obtain datatype size for VALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */ - if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0) - FAIL_STACK_ERROR + if ((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0) + FAIL_STACK_ERROR /* Get the datatype size for "field2\..,b.a" */ - if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) - FAIL_STACK_ERROR - if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) - FAIL_STACK_ERROR - if((ck_dsize = H5Tget_size(memb_tid2)) == 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid2) < 0) - FAIL_STACK_ERROR + if ((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) + FAIL_STACK_ERROR + if ((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize = H5Tget_size(memb_tid2)) == 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid2) < 0) + FAIL_STACK_ERROR /* Add the datatype size for "field2\..\\c" */ - if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) - FAIL_STACK_ERROR - if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + if ((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR /* Add the datatype size for "field4\,.b\," */ - if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) - FAIL_STACK_ERROR - if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR - if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + if ((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) + FAIL_STACK_ERROR + if ((ck_dsize += H5Tget_size(memb_tid)) == 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_tid) < 0) + FAIL_STACK_ERROR /* Verify case #3 */ VERIFY_EQUAL(dsize, ck_dsize) @@ -785,42 +795,43 @@ test_LD_size(const char *file) VERIFY_EQUAL(dsize, 0) /* Closing */ - if(H5Tclose(memb0_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(memb1_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(memb2_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(memb3_tid) < 0) - FAIL_STACK_ERROR - if(H5Tclose(dtid) < 0) - FAIL_STACK_ERROR - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR - - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Tclose(memb0_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb1_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb2_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb3_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(dtid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR + + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Tclose(memb0_tid); - H5Tclose(memb1_tid); - H5Tclose(memb2_tid); - H5Tclose(memb3_tid); - H5Tclose(memb_tid); - H5Tclose(memb_tid2); - H5Tclose(dtid); - H5Dclose(did); - H5Fclose(fid); - } H5E_END_TRY; - return(-1); + H5E_BEGIN_TRY + { + H5Tclose(memb0_tid); + H5Tclose(memb1_tid); + H5Tclose(memb2_tid); + H5Tclose(memb3_tid); + H5Tclose(memb_tid); + H5Tclose(memb_tid2); + H5Tclose(dtid); + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); } /* test_LD_size() */ - /* ************************************************************************************** * Testing for the High Level public routine: H5LDget_dset_elmts() @@ -844,32 +855,32 @@ error: static int test_LD_elmts_invalid(const char *file) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hid_t sid=-1; /* dataspace identifier */ - hid_t invalid_id=-1; - int ret; /* return value */ - hsize_t cur_dims[2]; /* current dimension sizes of the dataset */ - hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ - char tbuf[2]; /* temporary buffer for testing */ - int ndims; /* # of dimension sizes */ - int i; /* local index variable */ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hid_t sid = -1; /* dataspace identifier */ + hid_t invalid_id = -1; + int ret; /* return value */ + hsize_t cur_dims[2]; /* current dimension sizes of the dataset */ + hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ + char tbuf[2]; /* temporary buffer for testing */ + int ndims; /* # of dimension sizes */ + int i; /* local index variable */ const char *filename = H5_get_srcdir_filename(file); HL_TESTING2("H5LDget_dset_elmts on invalid conditions"); /* Open the copied file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* * Testing two-dimensional dataset: DSET_TWO */ /* Open dataset: DSET_TWO */ - if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify failure from case #1: cur_dims and prev_dims are NULL */ ret = H5LDget_dset_elmts(did, NULL, NULL, NULL, NULL); @@ -883,16 +894,16 @@ test_LD_elmts_invalid(const char *file) ret = H5LDget_dset_elmts(did, NULL, prev_dims, NULL, NULL); VERIFY_EQUAL(ret, FAIL) - if((sid = H5Dget_space(did)) < 0) - FAIL_STACK_ERROR + if ((sid = H5Dget_space(did)) < 0) + FAIL_STACK_ERROR /* Get the # of dimensions and current dimension sizes */ - if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0) - FAIL_STACK_ERROR + if ((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0) + FAIL_STACK_ERROR /* Set up valid cur_dims and prev_dims */ - for(i = 0; i < ndims; i++) - prev_dims[i] = cur_dims[i] - 1; + for (i = 0; i < ndims; i++) + prev_dims[i] = cur_dims[i] - 1; /* Verify failure from case #4: FIELDS is nonNULL but the dataset is not compound datatype */ ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, "field1", tbuf); @@ -905,12 +916,12 @@ test_LD_elmts_invalid(const char *file) /* Verify failure from case #6: cur_dims is not > than prev_dims */ cur_dims[0] = prev_dims[0] - 1; cur_dims[1] = prev_dims[1] - 1; - ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, tbuf); + ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, tbuf); VERIFY_EQUAL(ret, FAIL) /* Close DSET_TWO */ - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* * Testing one-dimensional dataset with compound datatype: @@ -918,18 +929,20 @@ test_LD_elmts_invalid(const char *file) */ /* Verify failure from case #1: an invalid dataset id */ - H5E_BEGIN_TRY { - ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf); + } + H5E_END_TRY; VERIFY_EQUAL(ret, FAIL) /* Open dataset: DSET_CMPD */ - if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Retrieve the current dimension sizes */ - if(H5LDget_dset_dims(did, cur_dims) < 0) - FAIL_STACK_ERROR + if (H5LDget_dset_dims(did, cur_dims) < 0) + FAIL_STACK_ERROR /* Set up valid cur_dims, prev_dims */ prev_dims[0] = cur_dims[0] - 1; @@ -939,27 +952,28 @@ test_LD_elmts_invalid(const char *file) VERIFY_EQUAL(ret, FAIL) /* Close DSET_CMPD */ - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Sclose(sid); - H5Dclose(did); - H5Fclose(fid); - } H5E_END_TRY; - return(-1); + H5E_BEGIN_TRY + { + H5Sclose(sid); + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); } /* test_LD_elmts_invalid() */ - /* ************************************************************************************** * Testing for the High Level public routine: H5LDget_dset_elmts() @@ -982,122 +996,122 @@ error: static herr_t test_LD_elmts_one(const char *file, const char *dname, const char *fields) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hid_t dtype=-1; /* dataset's data type */ - hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */ - hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */ - int i, j; /* local index variable */ - int ret = 0; /* return value */ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hid_t dtype = -1; /* dataset's data type */ + hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */ + hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */ + int i, j; /* local index variable */ + int ret = 0; /* return value */ HL_TESTING2("H5LDget_dset_elmts: one-dimensional dataset"); /* Copy the test file */ - if(h5_make_local_copy(file, COPY_FILENAME) < 0) + if (h5_make_local_copy(file, COPY_FILENAME) < 0) TEST_ERROR - for(i = 0; i < TEST_BUF_SIZE; i++) { - cbuf[i].field1 = i; - cbuf[i].field2.a = i; - cbuf[i].field2.b.a = i; - cbuf[i].field2.b.b = i; - cbuf[i].field2.b.c = i; - cbuf[i].field2.c = i; - cbuf[i].field3 = (double)i; - cbuf[i].field4.a = i; - cbuf[i].field4.b = i; - ibuf[i] = i; + for (i = 0; i < TEST_BUF_SIZE; i++) { + cbuf[i].field1 = i; + cbuf[i].field2.a = i; + cbuf[i].field2.b.a = i; + cbuf[i].field2.b.b = i; + cbuf[i].field2.b.c = i; + cbuf[i].field2.c = i; + cbuf[i].field3 = (double)i; + cbuf[i].field4.a = i; + cbuf[i].field4.b = i; + ibuf[i] = i; } /* end for */ /* Open the copied file */ - if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Open the dataset */ - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the dataset's data type */ - if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get current dimension sizes before extending the dataset's dimension sizes */ - if(H5LDget_dset_dims(did, prev_dims) < 0) - FAIL_STACK_ERROR - - /* Loop through different variations of extending the dataset */ - for(i = 0; i < ONE_NTESTS; i++) { - HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); - HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); - HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); - HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); - - ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]); - - /* Change the dimension sizes of the dataset */ - if(H5Dset_extent(did, ext_dims) < 0) + if (H5LDget_dset_dims(did, prev_dims) < 0) FAIL_STACK_ERROR - /* Initialize data */ - if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { - if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) - FAIL_STACK_ERROR - } /* end if */ - else if(!HDstrcmp(dname, DSET_ONE)) { - if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) - FAIL_STACK_ERROR - } /* end if */ + /* Loop through different variations of extending the dataset */ + for (i = 0; i < ONE_NTESTS; i++) { + HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); + HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); + HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); + HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); + + ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]); + + /* Change the dimension sizes of the dataset */ + if (H5Dset_extent(did, ext_dims) < 0) + FAIL_STACK_ERROR + + /* Initialize data */ + if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + FAIL_STACK_ERROR + } /* end if */ + else if (!HDstrcmp(dname, DSET_ONE)) { + if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + FAIL_STACK_ERROR + } /* end if */ - /* There are changes in dimension sizes */ - if(one_tests[i] > 0) { - if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { - if(fields) { - if(!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) { + /* There are changes in dimension sizes */ + if (one_tests[i] > 0) { + if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if (fields) { + if (!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) { /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) TEST_ERROR - for(j = 0; j < one_tests[i]; j++) + for (j = 0; j < one_tests[i]; j++) VERIFY_ELMTS_VALID1(vbuf1[j], cbuf[prev_dims[0] + (hsize_t)j]) } /* end if */ - else if(!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) { + else if (!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) { /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0) + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0) TEST_ERROR - for(j = 0; j < one_tests[i]; j++) + for (j = 0; j < one_tests[i]; j++) VERIFY_ELMTS_VALID2(vbuf2[j], cbuf[prev_dims[0] + (hsize_t)j]) } /* end else-if */ else - TEST_ERROR - } /* end if */ + TEST_ERROR + } /* end if */ else { - /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) - TEST_ERROR - for(j = 0; j < one_tests[i]; j++) - VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j]) - } /* end else-if */ - } /* end if */ + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) + TEST_ERROR + for (j = 0; j < one_tests[i]; j++) + VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j]) + } /* end else-if */ + } /* end if */ else { - /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) - TEST_ERROR - for(j = 0; j < one_tests[i]; j++) - VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j]) - } /* end else */ - } /* end if */ + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) + TEST_ERROR + for (j = 0; j < one_tests[i]; j++) + VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j]) + } /* end else */ + } /* end if */ else { /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); VERIFY_EQUAL(ret, FAIL) } /* end else */ - } /* end for */ + } /* end for */ /* Closing */ - if(H5Tclose(dtype) < 0) + if (H5Tclose(dtype) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Remove the copied file */ @@ -1107,15 +1121,16 @@ test_LD_elmts_one(const char *file, const char *dname, const char *fields) return 0; error: - H5E_BEGIN_TRY { - H5Tclose(dtype); - H5Dclose(did); - H5Fclose(fid); - } H5E_END_TRY; - return(-1); + H5E_BEGIN_TRY + { + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); } /* test_LD_elmts_one() */ - /* ************************************************************************************** * @@ -1137,36 +1152,35 @@ error: ************************************************************************************** */ static herr_t -verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf) +verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf) { - int k, m; /* Local index variable */ + int k, m; /* Local index variable */ k = 0; - for(m = 0; m < (int)ext_dims[0]; m++) { - int n, ind; /* Local index variable */ - - ind = m * (int)ext_dims[1]; - if(m < (int)prev_dims[0]) { - for(n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) { - VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) - ++k; - } /* end for */ - } /* end if */ + for (m = 0; m < (int)ext_dims[0]; m++) { + int n, ind; /* Local index variable */ + + ind = m * (int)ext_dims[1]; + if (m < (int)prev_dims[0]) { + for (n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) { + VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) + ++k; + } /* end for */ + } /* end if */ else { - for(n = 0; n < (int)ext_dims[1]; n++) { - VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) - ++k; - } /* end for */ - } /* end else */ - } /* end for */ + for (n = 0; n < (int)ext_dims[1]; n++) { + VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) + ++k; + } /* end for */ + } /* end else */ + } /* end for */ - return(0); + return (0); error: - return(-1); + return (-1); } /* verify_elmts_two() */ - /* ************************************************************************************** * Testing for the High Level public routine: H5LDget_dset_elmts() @@ -1193,126 +1207,126 @@ error: static herr_t test_LD_elmts_two(const char *file, const char *dname, const char *fields) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hid_t dtype=-1; /* dataset's data type */ - hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */ - hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ - int i; /* local index variable */ - int ret = 0; /* return value */ + hid_t fid = -1; /* file identifier */ + hid_t did = -1; /* dataset identifier */ + hid_t dtype = -1; /* dataset's data type */ + hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */ + hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ + int i; /* local index variable */ + int ret = 0; /* return value */ HL_TESTING2("H5LDget_dset_elmts: two-dimensional dataset"); /* Copy the test file */ - if(h5_make_local_copy(file, COPY_FILENAME) < 0) + if (h5_make_local_copy(file, COPY_FILENAME) < 0) TEST_ERROR - for(i = 0; i < TEST_BUF_SIZE; i++) { - cbuf[i].field1 = i; - cbuf[i].field2.a = i; - cbuf[i].field2.b.a = i; - cbuf[i].field2.b.b = i; - cbuf[i].field2.b.c = i; - cbuf[i].field2.c = i; - cbuf[i].field3 = (double)i; - cbuf[i].field4.a = i; - cbuf[i].field4.b = i; - ibuf[i] = i; + for (i = 0; i < TEST_BUF_SIZE; i++) { + cbuf[i].field1 = i; + cbuf[i].field2.a = i; + cbuf[i].field2.b.a = i; + cbuf[i].field2.b.b = i; + cbuf[i].field2.b.c = i; + cbuf[i].field2.c = i; + cbuf[i].field3 = (double)i; + cbuf[i].field4.a = i; + cbuf[i].field4.b = i; + ibuf[i] = i; } /* end for */ /* Open the copied file */ - if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Open the dataset */ - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the dataset's data type */ - if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get current dimension sizes before extending the dataset's dimension sizes */ - if(H5LDget_dset_dims(did, prev_dims) < 0) - FAIL_STACK_ERROR - - /* Loop through different variations of extending the dataset */ - for(i = 0; i < TWO_NTESTS; i++) { - HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); - HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); - HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); - HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); - - ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]); - ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]); - - /* Change the dimension sizes of the dataset */ - if(H5Dset_extent(did, ext_dims) < 0) + if (H5LDget_dset_dims(did, prev_dims) < 0) FAIL_STACK_ERROR - /* Initialize data */ - if(!HDstrcmp(dname, DSET_CMPD_TWO)) { - if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) - FAIL_STACK_ERROR - } /* end if */ - else if(!HDstrcmp(dname, DSET_TWO)) { - if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) - FAIL_STACK_ERROR - } /* end else-if */ + /* Loop through different variations of extending the dataset */ + for (i = 0; i < TWO_NTESTS; i++) { + HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); + HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); + HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); + HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); + + ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]); + ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]); + + /* Change the dimension sizes of the dataset */ + if (H5Dset_extent(did, ext_dims) < 0) + FAIL_STACK_ERROR + + /* Initialize data */ + if (!HDstrcmp(dname, DSET_CMPD_TWO)) { + if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + FAIL_STACK_ERROR + } /* end if */ + else if (!HDstrcmp(dname, DSET_TWO)) { + if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + FAIL_STACK_ERROR + } /* end else-if */ else TEST_ERROR - /* There are changes in dimension sizes */ - if(two_tests[i][0] > 0 || two_tests[i][1] > 0) { - if(!HDstrcmp(dname, DSET_CMPD_TWO)) { - if(fields) { - if(!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) { + /* There are changes in dimension sizes */ + if (two_tests[i][0] > 0 || two_tests[i][1] > 0) { + if (!HDstrcmp(dname, DSET_CMPD_TWO)) { + if (fields) { + if (!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) { /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) TEST_ERROR - if(verify_elmts_two(TWO_CMPD_VALID1, ext_dims, prev_dims, vbuf1, cbuf) < 0) + if (verify_elmts_two(TWO_CMPD_VALID1, ext_dims, prev_dims, vbuf1, cbuf) < 0) TEST_ERROR } /* end if */ - else if(!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) { + else if (!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) { /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0) + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0) TEST_ERROR - if(verify_elmts_two(TWO_CMPD_VALID2, ext_dims, prev_dims, vbuf2, cbuf) < 0) + if (verify_elmts_two(TWO_CMPD_VALID2, ext_dims, prev_dims, vbuf2, cbuf) < 0) TEST_ERROR } /* end else-if */ else TEST_ERROR - } /* end if */ + } /* end if */ else { - /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) - TEST_ERROR - if(verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0) - TEST_ERROR - } /* end else */ - } /* end if */ + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) + TEST_ERROR + if (verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0) + TEST_ERROR + } /* end else */ + } /* end if */ else { /* DSET_TWO */ - /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) - TEST_ERROR - if(verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0) - TEST_ERROR - } /* end else */ - } /* end if */ + /* Retrieve the elmemts in BUF */ + if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) + TEST_ERROR + if (verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0) + TEST_ERROR + } /* end else */ + } /* end if */ else { - /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ - ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); - VERIFY_EQUAL(ret, FAIL) - } /* end else */ - } /* end for */ + /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ + ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); + VERIFY_EQUAL(ret, FAIL) + } /* end else */ + } /* end for */ /* Closing */ - if(H5Tclose(dtype) < 0) - FAIL_STACK_ERROR; - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR; + if (H5Tclose(dtype) < 0) + FAIL_STACK_ERROR; + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR; + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; /* Remove the copied file */ HDremove(COPY_FILENAME); @@ -1321,37 +1335,40 @@ test_LD_elmts_two(const char *file, const char *dname, const char *fields) return 0; error: - H5E_BEGIN_TRY { - H5Tclose(dtype); - H5Dclose(did); - H5Fclose(fid); - } H5E_END_TRY; - return(-1); + H5E_BEGIN_TRY + { + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); + } + H5E_END_TRY; + return (-1); } /* test_LD_elmts_two() */ /* * Tests for High Level routines: * H5LDget_dset_dims(), H5LDget_dset_elmts, H5LDget_dset_type_size() */ -int main(void) +int +main(void) { - int nerrors = 0; + int nerrors = 0; /* Set up temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */ - if(NULL == (ibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; - if(NULL == (iibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + if (NULL == (ibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + if (NULL == (iibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; - if(NULL == (cbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; - if(NULL == (ccbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + if (NULL == (cbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + if (NULL == (ccbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; - if(NULL == (vbuf1 = (test_valid_fields1 *)HDmalloc(sizeof(test_valid_fields1) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; - if(NULL == (vbuf2 = (test_valid_fields2 *)HDmalloc(sizeof(test_valid_fields2) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + if (NULL == (vbuf1 = (test_valid_fields1 *)HDmalloc(sizeof(test_valid_fields1) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; + if (NULL == (vbuf2 = (test_valid_fields2 *)HDmalloc(sizeof(test_valid_fields2) * TEST_BUF_SIZE))) + FAIL_STACK_ERROR; /* * Testing H5LDget_dset_dims() @@ -1401,28 +1418,27 @@ int main(void) nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, VALID_FIELDS2); /* Free temporary buffers */ - if(ibuf) + if (ibuf) HDfree(ibuf); - if(iibuf) + if (iibuf) HDfree(iibuf); - if(cbuf) + if (cbuf) HDfree(cbuf); - if(ccbuf) + if (ccbuf) HDfree(ccbuf); - if(vbuf1) + if (vbuf1) HDfree(vbuf1); - if(vbuf2) + if (vbuf2) HDfree(vbuf2); /* check for errors */ - if(nerrors) - goto error; + if (nerrors) + goto error; puts("All tests for H5LD high level routines passed."); - return(0); + return (0); error: - return(1); + return (1); } /* main() */ - diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index e6b4668..a255e50 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -17,7 +17,7 @@ #include "H5srcdir.h" #include "H5LTpublic.h" -#define FILE_NAME "test_lite1.h5" +#define FILE_NAME "test_lite1.h5" #define FILE_NAME2 "test_lite2.h5" #define FILE_NAME3 "test_lite3.h5" #define FILE_NAME4 "test_lite4.h5" @@ -35,78 +35,76 @@ #define DIM 6 #define ATTR_NAME_SUB "att" -#define ATTR1_NAME "attr string" -#define ATTR2_NAME "attr char" -#define ATTR3_NAME "attr short" -#define ATTR4_NAME "attr int" +#define ATTR1_NAME "attr string" +#define ATTR2_NAME "attr char" +#define ATTR3_NAME "attr short" +#define ATTR4_NAME "attr int" #define ATTR_NAME_EXT "att int ext" -#define ATTR5_NAME "attr long" -#define ATTR6_NAME "attr uchar" -#define ATTR7_NAME "attr ushort" -#define ATTR8_NAME "attr uint" -#define ATTR9_NAME "attr ulong" -#define ATTR10_NAME "attr float" -#define ATTR11_NAME "attr double" - -static herr_t make_attributes( hid_t loc_id, const char* obj_name ); +#define ATTR5_NAME "attr long" +#define ATTR6_NAME "attr uchar" +#define ATTR7_NAME "attr ushort" +#define ATTR8_NAME "attr uint" +#define ATTR9_NAME "attr ulong" +#define ATTR10_NAME "attr float" +#define ATTR11_NAME "attr double" +static herr_t make_attributes(hid_t loc_id, const char *obj_name); /*------------------------------------------------------------------------- -* test dataset functions -*------------------------------------------------------------------------- -*/ + * test dataset functions + *------------------------------------------------------------------------- + */ -static int test_dsets( void ) +static int +test_dsets(void) { - int rank = 2; - hsize_t dims[2] = {2,3}; - hid_t file_id; - hid_t dataset_id; - char data_char_in[DIM] = {1,2,3,4,5,6}; - char data_char_out[DIM]; - short data_short_in[DIM] = {1,2,3,4,5,6}; - short data_short_out[DIM]; - int data_int_in[DIM] = {1,2,3,4,5,6}; - int data_int_out[DIM]; - long data_long_in[DIM] = {1,2,3,4,5,6}; - long data_long_out[DIM]; - float data_float_in[DIM] = {1,2,3,4,5,6}; - float data_float_out[DIM]; - double data_double_in[DIM] = {1,2,3,4,5,6}; - double data_double_out[DIM]; - const char *data_string_in = "This is a string"; - char data_string_out[20]; - int i; - + int rank = 2; + hsize_t dims[2] = {2, 3}; + hid_t file_id; + hid_t dataset_id; + char data_char_in[DIM] = {1, 2, 3, 4, 5, 6}; + char data_char_out[DIM]; + short data_short_in[DIM] = {1, 2, 3, 4, 5, 6}; + short data_short_out[DIM]; + int data_int_in[DIM] = {1, 2, 3, 4, 5, 6}; + int data_int_out[DIM]; + long data_long_in[DIM] = {1, 2, 3, 4, 5, 6}; + long data_long_out[DIM]; + float data_float_in[DIM] = {1, 2, 3, 4, 5, 6}; + float data_float_out[DIM]; + double data_double_in[DIM] = {1, 2, 3, 4, 5, 6}; + double data_double_out[DIM]; + const char *data_string_in = "This is a string"; + char data_string_out[20]; + int i; /* Create a new file using default properties. */ - file_id = H5Fcreate( FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); + file_id = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * H5LTmake_dataset test - *------------------------------------------------------------------------- - */ + * H5LTmake_dataset test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTmake_dataset"); /* Make dataset */ - if ( H5LTmake_dataset( file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in ) < 0 ) + if (H5LTmake_dataset(file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in) < 0) goto out; /* Read dataset using the basic HDF5 API */ - if ( ( dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT) ) < 0 ) + if ((dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT)) < 0) goto out; - if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 ) + if (H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out) < 0) goto out; - if ( H5Dclose( dataset_id ) < 0 ) + if (H5Dclose(dataset_id) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_int_in[i] != data_int_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_int_in[i] != data_int_out[i]) { goto out; } } @@ -114,18 +112,17 @@ static int test_dsets( void ) PASSED(); /*------------------------------------------------------------------------- - * read using the LT function H5LTread_dataset - *------------------------------------------------------------------------- - */ + * read using the LT function H5LTread_dataset + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTread_dataset"); - if ( H5LTread_dataset( file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out ) < 0 ) + if (H5LTread_dataset(file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_int_in[i] != data_int_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_int_in[i] != data_int_out[i]) { goto out; } } @@ -133,76 +130,70 @@ static int test_dsets( void ) PASSED(); /*------------------------------------------------------------------------- - * test the H5LTmake_dataset_ functions - *------------------------------------------------------------------------- - */ - + * test the H5LTmake_dataset_ functions + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5LTmake_dataset_char - *------------------------------------------------------------------------- - */ + * H5LTmake_dataset_char + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTmake_dataset_char"); /* Make dataset char */ - if ( H5LTmake_dataset_char( file_id, DSET1_NAME, rank, dims, data_char_in ) < 0 ) + if (H5LTmake_dataset_char(file_id, DSET1_NAME, rank, dims, data_char_in) < 0) goto out; /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out ) < 0 ) + if (H5LTread_dataset(file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_char_in[i] != data_char_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_char_in[i] != data_char_out[i]) { goto out; } } /* Read dataset */ - if ( H5LTread_dataset_char( file_id, DSET1_NAME, data_char_out ) < 0 ) + if (H5LTread_dataset_char(file_id, DSET1_NAME, data_char_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_char_in[i] != data_char_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_char_in[i] != data_char_out[i]) { goto out; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTmake_dataset_short - *------------------------------------------------------------------------- - */ + * H5LTmake_dataset_short + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTmake_dataset_short"); /* Make dataset short */ - if ( H5LTmake_dataset_short( file_id, DSET2_NAME, rank, dims, data_short_in ) < 0 ) + if (H5LTmake_dataset_short(file_id, DSET2_NAME, rank, dims, data_short_in) < 0) goto out; /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out ) < 0 ) + if (H5LTread_dataset(file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_short_in[i] != data_short_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_short_in[i] != data_short_out[i]) { goto out; } } /* Read dataset */ - if ( H5LTread_dataset_short( file_id, DSET2_NAME, data_short_out ) < 0 ) + if (H5LTread_dataset_short(file_id, DSET2_NAME, data_short_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_short_in[i] != data_short_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_short_in[i] != data_short_out[i]) { goto out; } } @@ -210,180 +201,165 @@ static int test_dsets( void ) PASSED(); /*------------------------------------------------------------------------- - * H5LTmake_dataset_int - *------------------------------------------------------------------------- - */ + * H5LTmake_dataset_int + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTmake_dataset_int"); /* Make dataset int */ - if ( H5LTmake_dataset_int( file_id, DSET3_NAME, rank, dims, data_int_in ) < 0 ) + if (H5LTmake_dataset_int(file_id, DSET3_NAME, rank, dims, data_int_in) < 0) goto out; /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out ) < 0 ) + if (H5LTread_dataset(file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_int_in[i] != data_int_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_int_in[i] != data_int_out[i]) { goto out; } } /* Read dataset */ - if ( H5LTread_dataset_int( file_id, DSET3_NAME, data_int_out ) < 0 ) + if (H5LTread_dataset_int(file_id, DSET3_NAME, data_int_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_int_in[i] != data_int_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_int_in[i] != data_int_out[i]) { goto out; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTmake_dataset_long - *------------------------------------------------------------------------- - */ + * H5LTmake_dataset_long + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTmake_dataset_long"); /* Make dataset long */ - if ( H5LTmake_dataset_long( file_id, DSET4_NAME, rank, dims, data_long_in ) < 0 ) + if (H5LTmake_dataset_long(file_id, DSET4_NAME, rank, dims, data_long_in) < 0) goto out; /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out ) < 0 ) + if (H5LTread_dataset(file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_long_in[i] != data_long_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_long_in[i] != data_long_out[i]) { goto out; } } /* Read dataset */ - if ( H5LTread_dataset_long( file_id, DSET4_NAME, data_long_out ) < 0 ) + if (H5LTread_dataset_long(file_id, DSET4_NAME, data_long_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if ( data_long_in[i] != data_long_out[i] ) { + for (i = 0; i < DIM; i++) { + if (data_long_in[i] != data_long_out[i]) { goto out; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTmake_dataset_float - *------------------------------------------------------------------------- - */ + * H5LTmake_dataset_float + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTmake_dataset_float"); /* Make dataset float */ - if ( H5LTmake_dataset_float( file_id, DSET5_NAME, rank, dims, data_float_in ) < 0 ) + if (H5LTmake_dataset_float(file_id, DSET5_NAME, rank, dims, data_float_in) < 0) goto out; /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out ) < 0 ) + if (H5LTread_dataset(file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if(!H5_FLT_ABS_EQUAL(data_float_in[i],data_float_out[i])) { + for (i = 0; i < DIM; i++) { + if (!H5_FLT_ABS_EQUAL(data_float_in[i], data_float_out[i])) { goto out; } } /* Read dataset */ - if ( H5LTread_dataset_float( file_id, DSET5_NAME, data_float_out ) < 0 ) + if (H5LTread_dataset_float(file_id, DSET5_NAME, data_float_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if(!H5_FLT_ABS_EQUAL(data_float_in[i],data_float_out[i])) { + for (i = 0; i < DIM; i++) { + if (!H5_FLT_ABS_EQUAL(data_float_in[i], data_float_out[i])) { goto out; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTmake_dataset_double - *------------------------------------------------------------------------- - */ + * H5LTmake_dataset_double + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTmake_dataset_double"); /* Make dataset double */ - if ( H5LTmake_dataset_double( file_id, DSET6_NAME, rank, dims, data_double_in ) < 0 ) + if (H5LTmake_dataset_double(file_id, DSET6_NAME, rank, dims, data_double_in) < 0) goto out; /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out ) < 0 ) + if (H5LTread_dataset(file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if(!H5_DBL_ABS_EQUAL(data_double_in[i],data_double_out[i])) { + for (i = 0; i < DIM; i++) { + if (!H5_DBL_ABS_EQUAL(data_double_in[i], data_double_out[i])) { goto out; } } /* Read dataset */ - if ( H5LTread_dataset_double( file_id, DSET6_NAME, data_double_out ) < 0 ) + if (H5LTread_dataset_double(file_id, DSET6_NAME, data_double_out) < 0) goto out; - for (i = 0; i < DIM; i++) - { - if(!H5_DBL_ABS_EQUAL(data_double_in[i],data_double_out[i])) { + for (i = 0; i < DIM; i++) { + if (!H5_DBL_ABS_EQUAL(data_double_in[i], data_double_out[i])) { goto out; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTmake_dataset_string - *------------------------------------------------------------------------- - */ + * H5LTmake_dataset_string + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTmake_dataset_string"); /* Make dataset string */ - if ( H5LTmake_dataset_string(file_id,DSET7_NAME,data_string_in) < 0 ) + if (H5LTmake_dataset_string(file_id, DSET7_NAME, data_string_in) < 0) goto out; /* Read dataset */ - if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 ) + if (H5LTread_dataset_string(file_id, DSET7_NAME, data_string_out) < 0) goto out; - if ( HDstrcmp(data_string_in,data_string_out) != 0 ) + if (HDstrcmp(data_string_in, data_string_out) != 0) goto out; - - /*------------------------------------------------------------------------- - * end tests - *------------------------------------------------------------------------- - */ + * end tests + *------------------------------------------------------------------------- + */ /* Close the file. */ - H5Fclose( file_id ); + H5Fclose(file_id); PASSED(); - return 0; out: @@ -393,75 +369,83 @@ out: } /*------------------------------------------------------------------------- -* test attribute functions -*------------------------------------------------------------------------- -*/ + * test attribute functions + *------------------------------------------------------------------------- + */ -static int test_attr(void) +static int +test_attr(void) { hid_t file_id; hid_t dataset_id; hid_t group_id; hid_t space_id; - hsize_t dims[1] = { 5 }; + hsize_t dims[1] = {5}; /* Create a new file using default properties. */ file_id = H5Fcreate(FILE_NAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * Create a dataset named "dset" on the root group - *------------------------------------------------------------------------- - */ + * Create a dataset named "dset" on the root group + *------------------------------------------------------------------------- + */ /* Create the data space */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) goto out; + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + goto out; /* Create the dataset */ - if((dataset_id = H5Dcreate2(file_id , "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; + if ((dataset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + goto out; /* Close */ H5Dclose(dataset_id); /*------------------------------------------------------------------------- - * Create a group named "grp" on the root group - *------------------------------------------------------------------------- - */ + * Create a group named "grp" on the root group + *------------------------------------------------------------------------- + */ /* Create a group. */ - if((group_id = H5Gcreate2(file_id, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; + if ((group_id = H5Gcreate2(file_id, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; /* Close */ H5Gclose(group_id); /*------------------------------------------------------------------------- - * - * Create attributes in the root group - * Note that we are calling the H5LTset_attribute functions with the name "." - * - *------------------------------------------------------------------------- - */ - if(make_attributes(file_id, ".") < 0) goto out; + * + * Create attributes in the root group + * Note that we are calling the H5LTset_attribute functions with the name "." + * + *------------------------------------------------------------------------- + */ + if (make_attributes(file_id, ".") < 0) + goto out; /*------------------------------------------------------------------------- - * - * Create attributes in the dataset "dset" - * - *------------------------------------------------------------------------- - */ - if(make_attributes(file_id, "dset") < 0) goto out; + * + * Create attributes in the dataset "dset" + * + *------------------------------------------------------------------------- + */ + if (make_attributes(file_id, "dset") < 0) + goto out; /*------------------------------------------------------------------------- - * - * Create attributes in the group "grp" - * - *------------------------------------------------------------------------- - */ - if(make_attributes(file_id, "grp") < 0) goto out; + * + * Create attributes in the group "grp" + * + *------------------------------------------------------------------------- + */ + if (make_attributes(file_id, "grp") < 0) + goto out; /*------------------------------------------------------------------------- - * end - *------------------------------------------------------------------------- - */ + * end + *------------------------------------------------------------------------- + */ /* Close the file. */ H5Fclose(file_id); @@ -476,113 +460,109 @@ out: } /*------------------------------------------------------------------------- -* make_attributes -*------------------------------------------------------------------------- -*/ + * make_attributes + *------------------------------------------------------------------------- + */ -static herr_t make_attributes( hid_t loc_id, const char* obj_name ) +static herr_t +make_attributes(hid_t loc_id, const char *obj_name) { int rank_out; - hsize_t *dims_out = 0; + hsize_t * dims_out = 0; H5T_class_t type_class; size_t type_size; int i; - char attr_str_in[] = {"My attribute"}; - char attr_str_out[20]; - char attr_char_in[5] = {1,2,3,4,5}; - char attr_char_out[5]; - short attr_short_in[5] = {1,2,3,4,5}; - short attr_short_out[5]; - int attr_int_in[5] = {1,2,3,4,5}; - int attr_int_out[5]; - long attr_long_in[5] = {1,2,3,4,5}; - long attr_long_out[5]; - float attr_float_in[5] = {1,2,3,4,5}; - float attr_float_out[5]; - double attr_double_in[5] = {1,2,3,4,5}; - double attr_double_out[5]; - unsigned char attr_uchar_in[5] = {1,2,3,4,5}; - unsigned char attr_uchar_out[5]; - unsigned short attr_ushort_in[5] = {1,2,3,4,5}; - unsigned short attr_ushort_out[5]; - unsigned int attr_uint_in[5] = {1,2,3,4,5}; - unsigned int attr_uint_out[5]; - unsigned long attr_ulong_in[5] = {1,2,3,4,5}; - unsigned long attr_ulong_out[5]; + char attr_str_in[] = {"My attribute"}; + char attr_str_out[20]; + char attr_char_in[5] = {1, 2, 3, 4, 5}; + char attr_char_out[5]; + short attr_short_in[5] = {1, 2, 3, 4, 5}; + short attr_short_out[5]; + int attr_int_in[5] = {1, 2, 3, 4, 5}; + int attr_int_out[5]; + long attr_long_in[5] = {1, 2, 3, 4, 5}; + long attr_long_out[5]; + float attr_float_in[5] = {1, 2, 3, 4, 5}; + float attr_float_out[5]; + double attr_double_in[5] = {1, 2, 3, 4, 5}; + double attr_double_out[5]; + unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5}; + unsigned char attr_uchar_out[5]; + unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5}; + unsigned short attr_ushort_out[5]; + unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5}; + unsigned int attr_uint_out[5]; + unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5}; + unsigned long attr_ulong_out[5]; /*------------------------------------------------------------------------- - * H5LTset_attribute_string test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_string test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_string"); /* Set the attribute */ - if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 ) + if (H5LTset_attribute_string(loc_id, obj_name, ATTR1_NAME, attr_str_in) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_string test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_string test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_string"); - /* Get the attribute */ - if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 ) + if (H5LTget_attribute_string(loc_id, obj_name, ATTR1_NAME, attr_str_out) < 0) return -1; - if ( HDstrcmp( attr_str_in, attr_str_out ) != 0 ) - { + if (HDstrcmp(attr_str_in, attr_str_out) != 0) { return -1; } PASSED(); - /*------------------------------------------------------------------------- - * H5LTset_attribute_char test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_char test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_char"); /* Set the attribute */ - if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_char(loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_char test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_char test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_char"); /* Get the attribute */ - if ( H5LTget_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_out ) < 0 ) + if (H5LTget_attribute_char(loc_id, obj_name, ATTR2_NAME, attr_char_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_char_in[i] != attr_char_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_char_in[i] != attr_char_out[i]) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_char_in[i] != attr_char_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_char_in[i] != attr_char_out[i]) { return -1; } } @@ -590,117 +570,109 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_short test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_short test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_short"); /* Set the attribute */ - if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_short(loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5) < 0) return -1; PASSED(); - /*------------------------------------------------------------------------- - * H5LTget_attribute_short test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_short test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_short"); /* Get the attribute */ - if ( H5LTget_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_out ) < 0 ) + if (H5LTget_attribute_short(loc_id, obj_name, ATTR3_NAME, attr_short_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_short_in[i] != attr_short_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_short_in[i] != attr_short_out[i]) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_short_in[i] != attr_short_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_short_in[i] != attr_short_out[i]) { return -1; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTset_attribute_int test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_int test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_int"); /* Set the attribute */ - if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_int(loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5) < 0) return -1; /* Set the attribute which is a substring of an existing attribute */ - if ( H5LTset_attribute_int( loc_id, obj_name, ATTR_NAME_SUB, attr_int_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_int(loc_id, obj_name, ATTR_NAME_SUB, attr_int_in, (size_t)5) < 0) return -1; /* Set the attribute which is an extension of an existing attribute */ - if ( H5LTset_attribute_int( loc_id, obj_name, ATTR_NAME_EXT, attr_int_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_int(loc_id, obj_name, ATTR_NAME_EXT, attr_int_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_int test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_int test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_int"); /* Get the attribute */ - if ( H5LTget_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_out ) < 0 ) + if (H5LTget_attribute_int(loc_id, obj_name, ATTR4_NAME, attr_int_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_int_in[i] != attr_int_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_int_in[i] != attr_int_out[i]) { return -1; } } - if ( H5LTget_attribute_int( loc_id, obj_name, ATTR_NAME_SUB, attr_int_out ) < 0 ) + if (H5LTget_attribute_int(loc_id, obj_name, ATTR_NAME_SUB, attr_int_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_int_in[i] != attr_int_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_int_in[i] != attr_int_out[i]) { return -1; } } - if ( H5LTget_attribute_int( loc_id, obj_name, ATTR_NAME_EXT, attr_int_out ) < 0 ) + if (H5LTget_attribute_int(loc_id, obj_name, ATTR_NAME_EXT, attr_int_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_int_in[i] != attr_int_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_int_in[i] != attr_int_out[i]) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_int_in[i] != attr_int_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_int_in[i] != attr_int_out[i]) { return -1; } } @@ -708,43 +680,41 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_long test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_long test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_long"); /* Set the attribute */ - if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_long(loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_long test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_long test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_long"); /* Get the attribute */ - if ( H5LTget_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_out ) < 0 ) + if (H5LTget_attribute_long(loc_id, obj_name, ATTR5_NAME, attr_long_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_long_in[i] != attr_long_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_long_in[i] != attr_long_out[i]) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_long_in[i] != attr_long_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_long_in[i] != attr_long_out[i]) { return -1; } } @@ -752,43 +722,41 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_uchar test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_uchar test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_uchar"); /* Set the attribute */ - if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_uchar(loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_uchar test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_uchar test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_uchar"); /* Get the attribute */ - if ( H5LTget_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_out ) < 0 ) + if (H5LTget_attribute_uchar(loc_id, obj_name, ATTR6_NAME, attr_uchar_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_uchar_in[i] != attr_uchar_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_uchar_in[i] != attr_uchar_out[i]) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_uchar_in[i] != attr_uchar_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_uchar_in[i] != attr_uchar_out[i]) { return -1; } } @@ -796,89 +764,83 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_ushort test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_ushort test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_ushort"); /* Set the attribute */ - if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_ushort(loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5) < 0) return -1; PASSED(); - /*------------------------------------------------------------------------- - * H5LTget_attribute_ushort test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_ushort test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_ushort"); /* Get the attribute */ - if ( H5LTget_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_out ) < 0 ) + if (H5LTget_attribute_ushort(loc_id, obj_name, ATTR7_NAME, attr_ushort_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_ushort_in[i] != attr_ushort_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_ushort_in[i] != attr_ushort_out[i]) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_ushort_in[i] != attr_ushort_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_ushort_in[i] != attr_ushort_out[i]) { return -1; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTset_attribute_int test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_int test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_uint"); /* Set the attribute */ - if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_uint(loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_int test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_int test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_uint"); /* Get the attribute */ - if ( H5LTget_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_out ) < 0 ) + if (H5LTget_attribute_uint(loc_id, obj_name, ATTR8_NAME, attr_uint_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_uint_in[i] != attr_uint_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_uint_in[i] != attr_uint_out[i]) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_uint_in[i] != attr_uint_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_uint_in[i] != attr_uint_out[i]) { return -1; } } @@ -886,89 +848,83 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_ulong test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_ulong test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_ulong"); /* Set the attribute */ - if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_ulong(loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_long test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_long test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_ulong"); /* Get the attribute */ - if ( H5LTget_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_out ) < 0 ) + if (H5LTget_attribute_ulong(loc_id, obj_name, ATTR9_NAME, attr_ulong_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_ulong_in[i] != attr_ulong_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_ulong_in[i] != attr_ulong_out[i]) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if ( attr_ulong_in[i] != attr_ulong_out[i] ) { + for (i = 0; i < 5; i++) { + if (attr_ulong_in[i] != attr_ulong_out[i]) { return -1; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTset_attribute_float test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_float test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_float"); /* Set the attribute */ - if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_float test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_float test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_float"); - /* Get the attribute */ - if ( H5LTget_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_out ) < 0 ) + if (H5LTget_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if(!H5_FLT_ABS_EQUAL(attr_float_in[i],attr_float_out[i])) { + for (i = 0; i < 5; i++) { + if (!H5_FLT_ABS_EQUAL(attr_float_in[i], attr_float_out[i])) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if(!H5_FLT_ABS_EQUAL(attr_float_in[i],attr_float_out[i])) { + for (i = 0; i < 5; i++) { + if (!H5_FLT_ABS_EQUAL(attr_float_in[i], attr_float_out[i])) { return -1; } } @@ -976,93 +932,90 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_double test - *------------------------------------------------------------------------- - */ + * H5LTset_attribute_double test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTset_attribute_double"); /* Set the attribute */ - if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 ) + if (H5LTset_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5) < 0) return -1; PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_double test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_double test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_double"); /* Get the attribute */ - if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 ) + if (H5LTget_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if(!H5_DBL_ABS_EQUAL(attr_double_in[i],attr_double_out[i])) { + for (i = 0; i < 5; i++) { + if (!H5_DBL_ABS_EQUAL(attr_double_in[i], attr_double_out[i])) { return -1; } } /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out ) < 0 ) + if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0) return -1; - for (i = 0; i < 5; i++) - { - if(!H5_DBL_ABS_EQUAL(attr_double_in[i],attr_double_out[i])) { + for (i = 0; i < 5; i++) { + if (!H5_DBL_ABS_EQUAL(attr_double_in[i], attr_double_out[i])) { return -1; } } PASSED(); - /*------------------------------------------------------------------------- - * H5LTget_attribute_ndims test - *------------------------------------------------------------------------- - */ - + * H5LTget_attribute_ndims test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_ndims"); - if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 ) + if (H5LTget_attribute_ndims(loc_id, obj_name, ATTR2_NAME, &rank_out) < 0) return -1; - if ( rank_out != 1 ) { + if (rank_out != 1) { return -1; } PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_info test - *------------------------------------------------------------------------- - */ + * H5LTget_attribute_info test + *------------------------------------------------------------------------- + */ HL_TESTING2("H5LTget_attribute_info"); - if(NULL==(dims_out = (hsize_t*) HDmalloc( sizeof(hsize_t) * (size_t)rank_out ))) return -1; + if (NULL == (dims_out = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)rank_out))) + return -1; - if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, &type_size) < 0 ) { - HDfree( dims_out ); + if (H5LTget_attribute_info(loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, &type_size) < 0) { + HDfree(dims_out); return -1; } for (i = 0; i < rank_out; i++) { - if ( dims_out[i] != 5 ) { - HDfree( dims_out ); + if (dims_out[i] != 5) { + HDfree(dims_out); return -1; } } - if ( type_class != H5T_INTEGER ) { - HDfree( dims_out ); + if (type_class != H5T_INTEGER) { + HDfree(dims_out); return -1; } - HDfree( dims_out ); + HDfree(dims_out); PASSED(); @@ -1070,52 +1023,53 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_integers(). -*------------------------------------------------------------------------- -*/ -static int test_integers(void) + * subroutine for test_text_dtype(): test_integers(). + *------------------------------------------------------------------------- + */ +static int +test_integers(void) { - hid_t dtype; - char* dt_str; - size_t str_len; + hid_t dtype; + char * dt_str; + size_t str_len; HL_TESTING3("\n text for integer types"); - if((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n", H5LT_DDL)) < 0) goto out; - if(!H5Tequal(dtype, H5T_NATIVE_INT)) + if (!H5Tequal(dtype, H5T_NATIVE_INT)) goto out; - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; - if((dtype = H5LTtext_to_dtype("H5T_STD_I8BE\n", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_STD_I8BE\n", H5LT_DDL)) < 0) goto out; - if(!H5Tequal(dtype, H5T_STD_I8BE)) + if (!H5Tequal(dtype, H5T_STD_I8BE)) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_STD_I8BE")) { + if (HDstrcmp(dt_str, "H5T_STD_I8BE")) { HDfree(dt_str); goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; - if((dtype = H5LTtext_to_dtype("H5T_STD_U16LE\n", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_STD_U16LE\n", H5LT_DDL)) < 0) goto out; - if(!H5Tequal(dtype, H5T_STD_U16LE)) + if (!H5Tequal(dtype, H5T_STD_U16LE)) goto out; - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; PASSED(); @@ -1127,52 +1081,53 @@ out: } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_fps(). -*------------------------------------------------------------------------- -*/ -static int test_fps(void) + * subroutine for test_text_dtype(): test_fps(). + *------------------------------------------------------------------------- + */ +static int +test_fps(void) { - hid_t dtype; - char* dt_str; - size_t str_len; + hid_t dtype; + char * dt_str; + size_t str_len; HL_TESTING3(" text for floating-point types"); - if((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n", H5LT_DDL)) < 0) goto out; - if(!H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) + if (!H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) goto out; - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; - if((dtype = H5LTtext_to_dtype("H5T_IEEE_F32BE\n", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_IEEE_F32BE\n", H5LT_DDL)) < 0) goto out; - if(!H5Tequal(dtype, H5T_IEEE_F32BE)) + if (!H5Tequal(dtype, H5T_IEEE_F32BE)) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_IEEE_F32BE")) { + if (HDstrcmp(dt_str, "H5T_IEEE_F32BE")) { HDfree(dt_str); goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; - if((dtype = H5LTtext_to_dtype("H5T_IEEE_F64LE\n", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_IEEE_F64LE\n", H5LT_DDL)) < 0) goto out; - if(!H5Tequal(dtype, H5T_IEEE_F64LE)) + if (!H5Tequal(dtype, H5T_IEEE_F64LE)) goto out; - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; PASSED(); @@ -1184,82 +1139,89 @@ out: } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_strings(). -*------------------------------------------------------------------------- -*/ -static int test_strings(void) + * subroutine for test_text_dtype(): test_strings(). + *------------------------------------------------------------------------- + */ +static int +test_strings(void) { - hid_t dtype; - size_t str_size; + hid_t dtype; + size_t str_size; H5T_str_t str_pad; H5T_cset_t str_cset; H5T_class_t type_class; - char* dt_str = NULL; - size_t str_len; + char * dt_str = NULL; + size_t str_len; HL_TESTING3(" text for string types"); - if((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE 13; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype( + "H5T_STRING { STRSIZE 13; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }", + H5LT_DDL)) < 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_STRING) + if (type_class != H5T_STRING) goto out; str_size = H5Tget_size(dtype); - if(str_size != 13) + if (str_size != 13) goto out; str_pad = H5Tget_strpad(dtype); - if(str_pad != H5T_STR_NULLTERM) + if (str_pad != H5T_STR_NULLTERM) goto out; str_cset = H5Tget_cset(dtype); - if(str_cset != H5T_CSET_ASCII) + if (str_cset != H5T_CSET_ASCII) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) { + if (HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET " + "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) { HDprintf("dt=\n%s\n", dt_str); HDfree(dt_str); goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; - if((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET " + "H5T_CSET_ASCII; CTYPE H5T_C_S1; }", + H5LT_DDL)) < 0) goto out; - if(!H5Tis_variable_str(dtype)) + if (!H5Tis_variable_str(dtype)) goto out; str_pad = H5Tget_strpad(dtype); - if(str_pad != H5T_STR_NULLPAD) + if (str_pad != H5T_STR_NULLPAD) goto out; str_cset = H5Tget_cset(dtype); - if(str_cset != H5T_CSET_ASCII) + if (str_cset != H5T_CSET_ASCII) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) { + if (HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n " + "CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) { HDprintf("dt=\n%s\n", dt_str); HDfree(dt_str); goto out; @@ -1268,97 +1230,108 @@ static int test_strings(void) /* Length of the character buffer is larger then needed */ str_len = str_len + 10; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) - goto out; + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) + goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { - HDfree(dt_str); - goto out; + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { + HDfree(dt_str); + goto out; } - if(HDstrncmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }", str_len-1)) { - HDprintf("dt=\n%s\n", dt_str); - HDfree(dt_str); - goto out; + if (HDstrncmp(dt_str, + "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET " + "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }", + str_len - 1)) { + HDprintf("dt=\n%s\n", dt_str); + HDfree(dt_str); + goto out; } HDfree(dt_str); /* Length of the character buffer is smaller then needed */ str_len = 21; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) - goto out; + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) + goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { - HDfree(dt_str); - goto out; + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { + HDfree(dt_str); + goto out; } /* check the truncated string */ - if(HDstrlen(dt_str) != str_len-1) goto out; + if (HDstrlen(dt_str) != str_len - 1) + goto out; str_len = HDstrlen(dt_str); - if(HDstrncmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }", str_len)) { - HDprintf("dt=\n%s\n", dt_str); - HDfree(dt_str); - goto out; + if (HDstrncmp(dt_str, + "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET " + "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }", + str_len)) { + HDprintf("dt=\n%s\n", dt_str); + HDfree(dt_str); + goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; PASSED(); return 0; out: - if(dt_str) - HDfree(dt_str); + if (dt_str) + HDfree(dt_str); H5_FAILED(); return -1; } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_opaques(). -*------------------------------------------------------------------------- -*/ -static int test_opaques(void) + * subroutine for test_text_dtype(): test_opaques(). + *------------------------------------------------------------------------- + */ +static int +test_opaques(void) { - hid_t dtype; - size_t opq_size; + hid_t dtype; + size_t opq_size; H5T_class_t type_class; - char* dt_str; - size_t str_len; + char * dt_str; + size_t str_len; HL_TESTING3(" text for opaque types"); - if((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }", + H5LT_DDL)) < 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_OPAQUE) + if (type_class != H5T_OPAQUE) goto out; - if((opq_size = H5Tget_size(dtype)) == 0) + if ((opq_size = H5Tget_size(dtype)) == 0) goto out; - if(opq_size != 19) + if (opq_size != 19) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) { + if (HDstrcmp( + dt_str, + "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) { HDprintf("dt=\n%s\n", dt_str); HDfree(dt_str); goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; PASSED(); @@ -1370,63 +1343,66 @@ out: } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_enums(). -*------------------------------------------------------------------------- -*/ -static int test_enums(void) + * subroutine for test_text_dtype(): test_enums(). + *------------------------------------------------------------------------- + */ +static int +test_enums(void) { - hid_t dtype; - size_t size = 16; - char name1[16]; - int value1 = 7; - const char *name2 = "WHITE"; - int value2; + hid_t dtype; + size_t size = 16; + char name1[16]; + int value1 = 7; + const char *name2 = "WHITE"; + int value2; H5T_class_t type_class; - char* dt_str; - size_t str_len; + char * dt_str; + size_t str_len; HL_TESTING3(" text for enum types"); - if((dtype = H5LTtext_to_dtype("H5T_ENUM { H5T_STD_I32LE; \"RED\" 5; \"GREEN\" 6; \"BLUE\" 7; \"WHITE\" 8; }", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype( + "H5T_ENUM { H5T_STD_I32LE; \"RED\" 5; \"GREEN\" 6; \"BLUE\" 7; \"WHITE\" 8; }", H5LT_DDL)) < 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_ENUM) + if (type_class != H5T_ENUM) goto out; /* Convert the variable before using it */ - if(!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) { - if(H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value1, NULL, H5P_DEFAULT) < 0) + if (!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) { + if (H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value1, NULL, H5P_DEFAULT) < 0) goto out; } - if(H5Tenum_nameof(dtype, &value1, name1, size)<0) + if (H5Tenum_nameof(dtype, &value1, name1, size) < 0) goto out; - if(HDstrcmp(name1, "BLUE")) + if (HDstrcmp(name1, "BLUE")) goto out; - if(H5Tenum_valueof(dtype, name2, &value2)<0) + if (H5Tenum_valueof(dtype, name2, &value2) < 0) goto out; /* Convert the variable before comparing it */ - if(!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) { - if(H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value2, NULL, H5P_DEFAULT) < 0) + if (!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) { + if (H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value2, NULL, H5P_DEFAULT) < 0) goto out; } - if(value2 != 8) + if (value2 != 8) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) { + if (HDstrcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" " + " 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) { HDprintf("dt=\n%s\n", dt_str); HDfree(dt_str); @@ -1435,7 +1411,7 @@ static int test_enums(void) HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; PASSED(); @@ -1447,54 +1423,55 @@ out: } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_variables(). -*------------------------------------------------------------------------- -*/ -static int test_variables(void) + * subroutine for test_text_dtype(): test_variables(). + *------------------------------------------------------------------------- + */ +static int +test_variables(void) { - hid_t dtype; + hid_t dtype; H5T_class_t type_class; - char* dt_str; - size_t str_len; + char * dt_str; + size_t str_len; HL_TESTING3(" text for variable types"); - if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_NATIVE_CHAR }\n", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_NATIVE_CHAR }\n", H5LT_DDL)) < 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_VLEN) + if (type_class != H5T_VLEN) goto out; - if(H5Tis_variable_str(dtype)) + if (H5Tis_variable_str(dtype)) goto out; - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; - if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }", H5LT_DDL)) < 0) goto out; - if(H5Tis_variable_str(dtype)) + if (H5Tis_variable_str(dtype)) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) { + if (HDstrcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) { HDprintf("dt=\n%s\n", dt_str); HDfree(dt_str); goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; PASSED(); @@ -1506,47 +1483,52 @@ out: } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_arrays(). -*------------------------------------------------------------------------- -*/ -static int test_arrays(void) + * subroutine for test_text_dtype(): test_arrays(). + *------------------------------------------------------------------------- + */ +static int +test_arrays(void) { - hid_t dtype; - int ndims; - hsize_t dims[3]; + hid_t dtype; + int ndims; + hsize_t dims[3]; H5T_class_t type_class; - char* dt_str; - size_t str_len; + char * dt_str; + size_t str_len; HL_TESTING3(" text for array types"); - if((dtype = H5LTtext_to_dtype("H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype("H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE " + "\"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }", + H5LT_DDL)) < 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_ARRAY) + if (type_class != H5T_ARRAY) goto out; - if((ndims = H5Tget_array_ndims(dtype))<0) + if ((ndims = H5Tget_array_ndims(dtype)) < 0) goto out; - if(ndims != 3) + if (ndims != 3) goto out; - if(H5Tget_array_dims2(dtype, dims) < 0) + if (H5Tget_array_dims2(dtype, dims) < 0) goto out; - if(dims[0] != 5 || dims[1] != 7 || dims[2] != 13) + if (dims[0] != 5 || dims[1] != 7 || dims[2] != 13) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE \"arr_compound_2\" : 1;\n }\n }\n }")) { + if (HDstrcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n " + " H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE " + "\"arr_compound_2\" : 1;\n }\n }\n }")) { HDprintf("dt=\n%s\n", dt_str); HDfree(dt_str); goto out; @@ -1554,7 +1536,7 @@ static int test_arrays(void) HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; PASSED(); @@ -1566,66 +1548,74 @@ out: } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_compounds(). -*------------------------------------------------------------------------- -*/ -static int test_compounds(void) + * subroutine for test_text_dtype(): test_compounds(). + *------------------------------------------------------------------------- + */ +static int +test_compounds(void) { - hid_t dtype; - int nmembs; - char *memb_name = NULL; + hid_t dtype; + int nmembs; + char * memb_name = NULL; H5T_class_t memb_class; H5T_class_t type_class; - char* dt_str; - size_t str_len; + char * dt_str; + size_t str_len; HL_TESTING3(" text for compound types"); - if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I16BE \"one_field\" : 2; H5T_STD_U8LE \"two_field\" : 6; }", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype( + "H5T_COMPOUND { H5T_STD_I16BE \"one_field\" : 2; H5T_STD_U8LE \"two_field\" : 6; }", H5LT_DDL)) < + 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_COMPOUND) + if (type_class != H5T_COMPOUND) goto out; - if((nmembs = H5Tget_nmembers(dtype))<0) + if ((nmembs = H5Tget_nmembers(dtype)) < 0) goto out; - if(nmembs != 2) + if (nmembs != 2) goto out; - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } - if(HDstrcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE \"two_field\" : 6;\n }")) { + if (HDstrcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE " + "\"two_field\" : 6;\n }")) { HDprintf("dt=\n%s\n", dt_str); HDfree(dt_str); goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; - if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I32BE \"i32_field\"; H5T_STD_I16BE \"i16_field\"; H5T_COMPOUND { H5T_STD_I16BE \"sec_field\"; H5T_COMPOUND { H5T_STD_I32BE \"thd_field\"; } \"grandchild\"; } \"child_compound\"; H5T_STD_I8BE \"i8_field\"; }", H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype( + "H5T_COMPOUND { H5T_STD_I32BE \"i32_field\"; H5T_STD_I16BE \"i16_field\"; H5T_COMPOUND { " + "H5T_STD_I16BE \"sec_field\"; H5T_COMPOUND { H5T_STD_I32BE \"thd_field\"; } \"grandchild\"; } " + "\"child_compound\"; H5T_STD_I8BE \"i8_field\"; }", + H5LT_DDL)) < 0) goto out; - if((memb_name = H5Tget_member_name(dtype, 1)) == NULL) + if ((memb_name = H5Tget_member_name(dtype, 1)) == NULL) goto out; - if(HDstrcmp(memb_name, "i16_field")) { + if (HDstrcmp(memb_name, "i16_field")) { H5free_memory(memb_name); goto out; } H5free_memory(memb_name); - if((memb_class = H5Tget_member_class(dtype, 2))<0) + if ((memb_class = H5Tget_member_class(dtype, 2)) < 0) goto out; - if(memb_class != H5T_COMPOUND) + if (memb_class != H5T_COMPOUND) goto out; PASSED(); @@ -1637,110 +1627,120 @@ out: } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_compound_bug(). Test case for -* issue 7701. -*------------------------------------------------------------------------- -*/ -static int test_compound_bug(void) + * subroutine for test_text_dtype(): test_compound_bug(). Test case for + * issue 7701. + *------------------------------------------------------------------------- + */ +static int +test_compound_bug(void) { hid_t dtype; H5T_class_t type_class; int nmembs; - char* memb_name = NULL; - char* dt_str; + char * memb_name = NULL; + char * dt_str; size_t str_len; - char text[] = "H5T_COMPOUND { H5T_STD_I32LE \"state_________________________________________________________________________________\"; H5T_STD_I32LE \"desc_________________________________________________________________________________________\"; H5T_VLEN { H5T_COMPOUND { H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" 1; \"TWO\" 2; \"THREE\" 3; } \"type____\"; H5T_STD_I32LE \"sub_______________________________________________________________________________________________________________\"; H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } \"sub_desc\"; H5T_STD_I32LE \"final___________________________________________________________________________________________________\"; } } \"sub\"; }"; - char text2[] = - "H5T_COMPOUND {\n" - " H5T_STD_I16LE \"state___________________________" - "__________________________________________________" - "____\" : 0;\n" - " H5T_STD_I16LE \"desc____________________________" - "__________________________________________________" - "___________\" : 2;\n" - " H5T_VLEN { H5T_COMPOUND {\n" - " H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" " - "1; \"TWO\" 2; \"THREE\" 3; } \"type____\" : 0;\n" - " H5T_STD_I32LE \"sub___________________________" - "__________________________________________________" - "__________________________________1\" : 4;\n" - " H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_" - "STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1;" - " } \"sub_desc\" : 8;\n" - " H5T_STD_I32LE \"final_________________________" - "__________________________________________________" - "________________________\" : 16;\n" - " } } \"sub\" : 8;\n" - "}\n"; + char text[] = "H5T_COMPOUND { H5T_STD_I32LE " + "\"state_________________________________________________________________________________" + "\"; H5T_STD_I32LE " + "\"desc____________________________________________________________________________________" + "_____\"; H5T_VLEN { H5T_COMPOUND { H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" 1; " + "\"TWO\" 2; \"THREE\" 3; } \"type____\"; H5T_STD_I32LE " + "\"sub_____________________________________________________________________________________" + "__________________________\"; H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_SPACEPAD; " + "CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } \"sub_desc\"; H5T_STD_I32LE " + "\"final___________________________________________________________________________________" + "________________\"; } } \"sub\"; }"; + char text2[] = "H5T_COMPOUND {\n" + " H5T_STD_I16LE \"state___________________________" + "__________________________________________________" + "____\" : 0;\n" + " H5T_STD_I16LE \"desc____________________________" + "__________________________________________________" + "___________\" : 2;\n" + " H5T_VLEN { H5T_COMPOUND {\n" + " H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" " + "1; \"TWO\" 2; \"THREE\" 3; } \"type____\" : 0;\n" + " H5T_STD_I32LE \"sub___________________________" + "__________________________________________________" + "__________________________________1\" : 4;\n" + " H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_" + "STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1;" + " } \"sub_desc\" : 8;\n" + " H5T_STD_I32LE \"final_________________________" + "__________________________________________________" + "________________________\" : 16;\n" + " } } \"sub\" : 8;\n" + "}\n"; HL_TESTING3(" text for compound type of bug fix"); - if((dtype = H5LTtext_to_dtype(text, H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype(text, H5LT_DDL)) < 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_COMPOUND) + if (type_class != H5T_COMPOUND) goto out; - if((memb_name = H5Tget_member_name(dtype, 2)) == NULL) + if ((memb_name = H5Tget_member_name(dtype, 2)) == NULL) goto out; - if(HDstrcmp(memb_name, "sub")) { + if (HDstrcmp(memb_name, "sub")) { H5free_memory(memb_name); goto out; } H5free_memory(memb_name); - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; - /* Test similar datatype in another format */ - if((dtype = H5LTtext_to_dtype(text2, H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype(text2, H5LT_DDL)) < 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_COMPOUND) + if (type_class != H5T_COMPOUND) goto out; - if((nmembs = H5Tget_nmembers(dtype))<0) + if ((nmembs = H5Tget_nmembers(dtype)) < 0) goto out; - if(nmembs != 3) + if (nmembs != 3) goto out; - if((memb_name = H5Tget_member_name(dtype, 1)) == NULL) + if ((memb_name = H5Tget_member_name(dtype, 1)) == NULL) goto out; - if(HDstrcmp(memb_name, "desc_________________________________________________________________________________________")) { + if (HDstrcmp(memb_name, "desc____________________________________________________________________________" + "_____________")) { H5free_memory(memb_name); goto out; } H5free_memory(memb_name); - if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) + if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0) goto out; - if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char)))) goto out; - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) { HDfree(dt_str); goto out; } HDfree(dt_str); - if(H5Tclose(dtype)<0) + if (H5Tclose(dtype) < 0) goto out; PASSED(); @@ -1752,66 +1752,67 @@ out: } /*------------------------------------------------------------------------- -* subroutine for test_text_dtype(): test_complicated_compound(). -*------------------------------------------------------------------------- -*/ -static int test_complicated_compound(void) + * subroutine for test_text_dtype(): test_complicated_compound(). + *------------------------------------------------------------------------- + */ +static int +test_complicated_compound(void) { - hid_t dtype; - int nmembs; + hid_t dtype; + int nmembs; H5T_class_t type_class; - char *line = NULL; - FILE *fp = NULL; - size_t size = 1024; + char * line = NULL; + FILE * fp = NULL; + size_t size = 1024; const char *filename = H5_get_srcdir_filename(INPUT_FILE); HL_TESTING3(" text for complicated compound types"); /* Open input file */ fp = HDfopen(filename, "r"); - if(fp == NULL) { - HDprintf( "Could not find file %s. Try set $srcdir \n", filename); + if (fp == NULL) { + HDprintf("Could not find file %s. Try set $srcdir \n", filename); goto out; } /* This part reads in the input as a string in a slow manner. GNU C - * Library has convenient function getline() but isn't available on - * all machines. - */ - if((line = (char*)HDcalloc(size, sizeof(char)))==NULL) + * Library has convenient function getline() but isn't available on + * all machines. + */ + if ((line = (char *)HDcalloc(size, sizeof(char))) == NULL) goto out; - if(HDfgets(line, (int)size, fp)==NULL) + if (HDfgets(line, (int)size, fp) == NULL) goto out; - while(HDstrlen(line)==size-1) { + while (HDstrlen(line) == size - 1) { size *= 2; - if(line) + if (line) HDfree(line); - if((line = (char*)HDcalloc(size, sizeof(char)))==NULL) + if ((line = (char *)HDcalloc(size, sizeof(char))) == NULL) goto out; - if(HDfseek(fp, 0L, SEEK_SET)!=0) + if (HDfseek(fp, 0L, SEEK_SET) != 0) goto out; - if(HDfgets(line, (int)size, fp)==NULL) + if (HDfgets(line, (int)size, fp) == NULL) goto out; } HDfclose(fp); fp = NULL; - if((dtype = H5LTtext_to_dtype(line, H5LT_DDL))<0) + if ((dtype = H5LTtext_to_dtype(line, H5LT_DDL)) < 0) goto out; - if((type_class = H5Tget_class(dtype))<0) + if ((type_class = H5Tget_class(dtype)) < 0) goto out; - if(type_class != H5T_COMPOUND) + if (type_class != H5T_COMPOUND) goto out; /* There should be 101 compound members */ - if((nmembs = H5Tget_nmembers(dtype))<0) + if ((nmembs = H5Tget_nmembers(dtype)) < 0) goto out; - if(nmembs != 101) + if (nmembs != 101) goto out; - if(line) + if (line) HDfree(line); PASSED(); @@ -1819,9 +1820,9 @@ static int test_complicated_compound(void) out: - if(line) + if (line) HDfree(line); - if(fp) + if (fp) HDfclose(fp); H5_FAILED(); @@ -1829,41 +1830,42 @@ out: } /*------------------------------------------------------------------------- -* test H5LTtext_to_dtype function -*------------------------------------------------------------------------- -*/ -static int test_text_dtype(void) + * test H5LTtext_to_dtype function + *------------------------------------------------------------------------- + */ +static int +test_text_dtype(void) { HL_TESTING2("H5LTtext_to_dtype"); - if(test_integers()<0) + if (test_integers() < 0) goto out; - if(test_fps()<0) + if (test_fps() < 0) goto out; - if(test_strings()<0) + if (test_strings() < 0) goto out; - if(test_opaques()<0) + if (test_opaques() < 0) goto out; - if(test_enums()<0) + if (test_enums() < 0) goto out; - if(test_variables()<0) + if (test_variables() < 0) goto out; - if(test_arrays()<0) + if (test_arrays() < 0) goto out; - if(test_compounds()<0) + if (test_compounds() < 0) goto out; - if(test_compound_bug()<0) + if (test_compound_bug() < 0) goto out; - if(test_complicated_compound()<0) + if (test_complicated_compound() < 0) goto out; return 0; @@ -1876,362 +1878,364 @@ out: * test H5LTpath_valid function *------------------------------------------------------------------------- */ -static int test_valid_path(void) +static int +test_valid_path(void) { - hid_t file_id, group; - htri_t path_valid; - const char *data_string_in = "test"; - - HL_TESTING2("H5LTpath_valid"); - - /* Create a new file using default properties. */ - - /************************************************************** - * The file structure should look like this: - * - * +----------------------------------+ - * | / | - * +----------------------------------+ - * / | \ \ - * / | \ \ - * / | \ \ - * / | \ G8 (dangled external link) - * / DS \ - * / \ - * G1 G2 - * | --> DS1 | - * / \--> DS3 / \ - * / / \ - * G2 DS4 G7 - * | (hard link (dangled soft link - * | to /G1/DS3) to /G1/G20 ) - * | - * | - * | --- Gcyc (soft link to /G1) - * / \ - * / \ - * G5 \ - * (soft link G6 (external link /G1 in FILENAME4) - * to /G2) - * - ****************************************************************/ - - file_id = H5Fcreate(FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create dataset "/DS" - */ - if(H5LTmake_dataset_string(file_id, "DS", data_string_in)<0) - goto out; - - /* - * Create an external dangled link - */ - if(H5Lcreate_external("NonExistant_File.h5", "G8", file_id, "DangledExternalLink", H5P_DEFAULT, H5P_DEFAULT)<0) - goto out; - - /* - * Create a group named "G2" in the file. - */ - if((group = H5Gcreate2(file_id, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0) - goto out; - - /* - * Create a dataset named "G2/DS4" in the file. - */ - if(H5LTmake_dataset_string(group, "/G2/DS4", data_string_in)<0) - goto out; - - /* - * Create a soft link - */ - if(H5Lcreate_soft("/G1/G20", file_id, "/G2/G7", H5P_DEFAULT, H5P_DEFAULT) <0) - goto out; - - if(H5Gclose(group)<0) - goto out; - - /* - * Create a group named "G1" in the file. - */ - if((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0) - goto out; - - /* - * Create a group named "G1/DS1" in the file. - */ - if(H5LTmake_dataset_string(group, "/G1/DS1", data_string_in)<0) - goto out; - - if(H5Gclose(group)<0) - goto out; - - /* - * Create a hard link - */ - if(H5Lcreate_hard(file_id, "/G2/DS4", file_id, "/G1/DS3",H5P_DEFAULT, H5P_DEFAULT)<0) - goto out; - /* - * Create a group named "/G1/G2" in the file. - */ - if((group = H5Gcreate2(file_id, "/G1/G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0) - goto out; - - /* - * Create a soft link - */ - if(H5Lcreate_soft("/G2", file_id, "/G1/G2/G5", H5P_DEFAULT, H5P_DEFAULT)<0) - goto out; - - /* - * Create a cyclic soft link - */ - if(H5Lcreate_soft("/G1", file_id, "/G1/G2/Gcyc", H5P_DEFAULT, H5P_DEFAULT)<0) - goto out; - - if(H5Gclose(group)<0) - goto out; - - /* - * Create a group named "/G1/G2/G6" in the file. - */ - if((group = H5Gcreate2(file_id, "/G1/G2/G6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0) - goto out; - - /* - * Create an external link - */ - if(H5Lcreate_external( FILE_NAME4, "G1", group, "ExternalLink", H5P_DEFAULT, H5P_DEFAULT)<0) - goto out; - - if(H5Gclose(group)<0) - goto out; - /* - * Close the file. - */ - if(H5Fclose (file_id) < 0) - goto out; - - /* Create another file for checking external links */ - - /************************************************************** - * The file structure should look like this: - * - * +----+ - * | / | - * +----+ - * | - * | - * | - * G1 - * / \ - * / \ - * DS1 G2 - * (dangled soft link to /G1/G20) - * - ****************************************************************/ - - /* Make external link file */ - file_id = H5Fcreate(FILE_NAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create a group named "G1" in the file. - */ - if((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0) - goto out; - /* - * Create a dataset named "G1/DS1" in the file. - */ - if(H5LTmake_dataset_string(group, "/G1/DS1", data_string_in)<0) - goto out; - - /* - * Create a dangling soft link - */ - - if(H5Lcreate_soft("/G1/G2", file_id, "/G1/G20", H5P_DEFAULT, H5P_DEFAULT)<0) - goto out; - - if(H5Gclose(group)<0) - goto out; - - H5Fclose(file_id); - - /* Open input file */ - if((file_id = H5Fopen(FILE_NAME3,H5F_ACC_RDONLY, H5P_DEFAULT))<0) - goto out; - - /************************************** - * CHECK ABSOLUTE PATHS - **************************************/ - - if( (path_valid = H5LTpath_valid(file_id, "/", TRUE)) != TRUE) { - goto out; - } - - if( (path_valid = H5LTpath_valid(file_id, "/", FALSE)) != TRUE) { - goto out; - } - - if( (path_valid = H5LTpath_valid(file_id, "/G1", TRUE)) != TRUE) { - goto out; - } - - if((path_valid = H5LTpath_valid(file_id, "/G1/DS1", TRUE)) != TRUE) - goto out; - - if( (path_valid = H5LTpath_valid(file_id, "/G1/DS3", TRUE)) != TRUE) - goto out; - - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2", TRUE)) != TRUE) - goto out; - - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G5", TRUE)) != TRUE) - goto out; + hid_t file_id, group; + htri_t path_valid; + const char *data_string_in = "test"; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", FALSE)) != TRUE) - goto out; + HL_TESTING2("H5LTpath_valid"); - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", TRUE)) != TRUE) - goto out; + /* Create a new file using default properties. */ - if( (path_valid = H5LTpath_valid(file_id, "/G2", TRUE)) != TRUE) - goto out; + /************************************************************** + * The file structure should look like this: + * + * +----------------------------------+ + * | / | + * +----------------------------------+ + * / | \ \ + * / | \ \ + * / | \ \ + * / | \ G8 (dangled external link) + * / DS \ + * / \ + * G1 G2 + * | --> DS1 | + * / \--> DS3 / \ + * / / \ + * G2 DS4 G7 + * | (hard link (dangled soft link + * | to /G1/DS3) to /G1/G20 ) + * | + * | + * | --- Gcyc (soft link to /G1) + * / \ + * / \ + * G5 \ + * (soft link G6 (external link /G1 in FILENAME4) + * to /G2) + * + ****************************************************************/ - /* check soft link points to a valid object*/ - if( (path_valid = H5LTpath_valid(file_id, "/G2/DS4", TRUE)) != TRUE) - goto out; + file_id = H5Fcreate(FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - /* check if path exist, but not the object */ - if( (path_valid = H5LTpath_valid(file_id, "/G2/G7", FALSE)) != TRUE ) - goto out; - /* check if path exist and if the object exists. It should fail - * since it is a dangling soft link - */ - if( (path_valid = H5LTpath_valid(file_id, "/G2/G7", TRUE)) == TRUE) - goto out; + /* + * Create dataset "/DS" + */ + if (H5LTmake_dataset_string(file_id, "DS", data_string_in) < 0) + goto out; - /* check soft links */ - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G5/DS4", TRUE)) != TRUE) - goto out; + /* + * Create an external dangled link + */ + if (H5Lcreate_external("NonExistant_File.h5", "G8", file_id, "DangledExternalLink", H5P_DEFAULT, + H5P_DEFAULT) < 0) + goto out; - /************************************** - * CHECK RELATIVE PATHS - ***************************************/ + /* + * Create a group named "G2" in the file. + */ + if ((group = H5Gcreate2(file_id, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - if( (group = H5Gopen2(file_id, "/", H5P_DEFAULT)) < 0) - goto out; + /* + * Create a dataset named "G2/DS4" in the file. + */ + if (H5LTmake_dataset_string(group, "/G2/DS4", data_string_in) < 0) + goto out; - if( (path_valid = H5LTpath_valid(group, "/", TRUE)) != TRUE) { - goto out; - } + /* + * Create a soft link + */ + if (H5Lcreate_soft("/G1/G20", file_id, "/G2/G7", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; - if( (path_valid = H5LTpath_valid(group, "/", FALSE)) != TRUE) { - goto out; - } + if (H5Gclose(group) < 0) + goto out; - if(H5Gclose(group)<0) - goto out; + /* + * Create a group named "G1" in the file. + */ + if ((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - if( (group = H5Gopen2(file_id, "/G1", H5P_DEFAULT)) < 0) - goto out; + /* + * Create a group named "G1/DS1" in the file. + */ + if (H5LTmake_dataset_string(group, "/G1/DS1", data_string_in) < 0) + goto out; - /* The identifier (file id) is the object itself, i.e. "." */ + if (H5Gclose(group) < 0) + goto out; - if((path_valid = H5LTpath_valid(file_id, ".", FALSE)) != TRUE) - goto out; + /* + * Create a hard link + */ + if (H5Lcreate_hard(file_id, "/G2/DS4", file_id, "/G1/DS3", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + /* + * Create a group named "/G1/G2" in the file. + */ + if ((group = H5Gcreate2(file_id, "/G1/G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - if( (path_valid = H5LTpath_valid(file_id, ".", TRUE)) != TRUE) - goto out; + /* + * Create a soft link + */ + if (H5Lcreate_soft("/G2", file_id, "/G1/G2/G5", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; - /* The identifier (group id) is the object itself, i.e. "." */ + /* + * Create a cyclic soft link + */ + if (H5Lcreate_soft("/G1", file_id, "/G1/G2/Gcyc", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + + if (H5Gclose(group) < 0) + goto out; + + /* + * Create a group named "/G1/G2/G6" in the file. + */ + if ((group = H5Gcreate2(file_id, "/G1/G2/G6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + /* + * Create an external link + */ + if (H5Lcreate_external(FILE_NAME4, "G1", group, "ExternalLink", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + + if (H5Gclose(group) < 0) + goto out; + /* + * Close the file. + */ + if (H5Fclose(file_id) < 0) + goto out; + + /* Create another file for checking external links */ + + /************************************************************** + * The file structure should look like this: + * + * +----+ + * | / | + * +----+ + * | + * | + * | + * G1 + * / \ + * / \ + * DS1 G2 + * (dangled soft link to /G1/G20) + * + ****************************************************************/ + + /* Make external link file */ + file_id = H5Fcreate(FILE_NAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* + * Create a group named "G1" in the file. + */ + if ((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + /* + * Create a dataset named "G1/DS1" in the file. + */ + if (H5LTmake_dataset_string(group, "/G1/DS1", data_string_in) < 0) + goto out; + + /* + * Create a dangling soft link + */ + + if (H5Lcreate_soft("/G1/G2", file_id, "/G1/G20", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + + if (H5Gclose(group) < 0) + goto out; + + H5Fclose(file_id); + + /* Open input file */ + if ((file_id = H5Fopen(FILE_NAME3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + goto out; + + /************************************** + * CHECK ABSOLUTE PATHS + **************************************/ + + if ((path_valid = H5LTpath_valid(file_id, "/", TRUE)) != TRUE) { + goto out; + } + + if ((path_valid = H5LTpath_valid(file_id, "/", FALSE)) != TRUE) { + goto out; + } + + if ((path_valid = H5LTpath_valid(file_id, "/G1", TRUE)) != TRUE) { + goto out; + } + + if ((path_valid = H5LTpath_valid(file_id, "/G1/DS1", TRUE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/DS3", TRUE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2", TRUE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G5", TRUE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", FALSE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", TRUE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G2", TRUE)) != TRUE) + goto out; + + /* check soft link points to a valid object*/ + if ((path_valid = H5LTpath_valid(file_id, "/G2/DS4", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(group, ".", TRUE)) != TRUE) - goto out; + /* check if path exist, but not the object */ + if ((path_valid = H5LTpath_valid(file_id, "/G2/G7", FALSE)) != TRUE) + goto out; + /* check if path exist and if the object exists. It should fail + * since it is a dangling soft link + */ + if ((path_valid = H5LTpath_valid(file_id, "/G2/G7", TRUE)) == TRUE) + goto out; - if( (path_valid = H5LTpath_valid(group, "DS3", FALSE)) != TRUE) - goto out; + /* check soft links */ + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G5/DS4", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(group, "DS3", TRUE)) != TRUE) - goto out; + /************************************** + * CHECK RELATIVE PATHS + ***************************************/ - if( (path_valid = H5LTpath_valid(group, "G2/G5", TRUE)) != TRUE) - goto out; + if ((group = H5Gopen2(file_id, "/", H5P_DEFAULT)) < 0) + goto out; - /* Check the "./" case */ - if( (path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, "/", TRUE)) != TRUE) { + goto out; + } - if( (path_valid = H5LTpath_valid(group, "./G2/G5", TRUE)) != TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, "/", FALSE)) != TRUE) { + goto out; + } + + if (H5Gclose(group) < 0) + goto out; - /* Should fail, does not exist */ - if( (path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE) - goto out; + if ((group = H5Gopen2(file_id, "/G1", H5P_DEFAULT)) < 0) + goto out; - /* Should fail, does not exist */ - if( (path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE) - goto out; + /* The identifier (file id) is the object itself, i.e. "." */ - if(H5Gclose(group)<0) - goto out; + if ((path_valid = H5LTpath_valid(file_id, ".", FALSE)) != TRUE) + goto out; - /***************************** - * Check external links - *****************************/ + if ((path_valid = H5LTpath_valid(file_id, ".", TRUE)) != TRUE) + goto out; - /* The dangled external link path is valid */ - if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", FALSE)) != TRUE) - goto out; + /* The identifier (group id) is the object itself, i.e. "." */ - /* The file however does not exists, so the link dangles -> should return false */ - if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", TRUE)) == TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, ".", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", FALSE)) != TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, "DS3", FALSE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", TRUE)) != TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, "DS3", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/DS1", TRUE)) != TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, "G2/G5", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", FALSE)) != TRUE) - goto out; + /* Check the "./" case */ + if ((path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/DS1", TRUE)) != TRUE) - goto out; + if ((path_valid = H5LTpath_valid(group, "./G2/G5", TRUE)) != TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", FALSE)) != TRUE) - goto out; + /* Should fail, does not exist */ + if ((path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE) + goto out; - /* Should fail, does not exist */ - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", TRUE)) == TRUE) - goto out; + /* Should fail, does not exist */ + if ((path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE) + goto out; - if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", TRUE)) == TRUE) - goto out; + if (H5Gclose(group) < 0) + goto out; + /***************************** + * Check external links + *****************************/ - if(H5Fclose(file_id)<0) - goto out; + /* The dangled external link path is valid */ + if ((path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", FALSE)) != TRUE) + goto out; - PASSED(); - return 0; + /* The file however does not exists, so the link dangles -> should return false */ + if ((path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", TRUE)) == TRUE) + goto out; - out: - H5_FAILED(); - return -1; + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", FALSE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", TRUE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/DS1", TRUE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", FALSE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/DS1", TRUE)) != TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", FALSE)) != TRUE) + goto out; + + /* Should fail, does not exist */ + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", TRUE)) == TRUE) + goto out; + + if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", TRUE)) == TRUE) + goto out; + + if (H5Fclose(file_id) < 0) + goto out; + + PASSED(); + return 0; + +out: + H5_FAILED(); + return -1; } /*------------------------------------------------------------------------- -* the main program -*------------------------------------------------------------------------- -*/ -int main( void ) + * the main program + *------------------------------------------------------------------------- + */ +int +main(void) { - int nerrors=0; + int nerrors = 0; /* test dataset functions */ nerrors += test_dsets(); diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index 61aebc7..fe17d38 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -23,41 +23,34 @@ *------------------------------------------------------------------------- */ -#define NRECORDS 8 -#define BIG_TABLE_SIZE 8000 -#define NFIELDS 5 -#define TEST_FILE_NAME "test_packet_table.h5" +#define NRECORDS 8 +#define BIG_TABLE_SIZE 8000 +#define NFIELDS 5 +#define TEST_FILE_NAME "test_packet_table.h5" #define TEST_COMPRESS_FILE "test_packet_compress.h5" -#define PT_NAME "Test Packet Table" -#define H5TB_TABLE_NAME "Table1" +#define PT_NAME "Test Packet Table" +#define H5TB_TABLE_NAME "Table1" /*------------------------------------------------------------------------- * structure used for some tests, a particle *------------------------------------------------------------------------- */ -typedef struct particle_t -{ - char name[16]; - int lati; - int longi; - float pressure; - double temperature; +typedef struct particle_t { + char name[16]; + int lati; + int longi; + float pressure; + double temperature; } particle_t; /*------------------------------------------------------------------------- * a static array of particles for writing and checking reads *------------------------------------------------------------------------- */ -static particle_t testPart[NRECORDS] = { - {"zero", 0,0, 0.0f, 0.0f}, - {"one", 10,10, 1.0f, 10.0f}, - {"two", 20,20, 2.0f, 20.0f}, - {"three",30,30, 3.0f, 30.0f}, - {"four", 40,40, 4.0f, 40.0f}, - {"five", 50,50, 5.0f, 50.0f}, - {"six", 60,60, 6.0f, 60.0f}, - {"seven",70,70, 7.0f, 70.0f} - }; +static particle_t testPart[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0f}, {"one", 10, 10, 1.0f, 10.0f}, + {"two", 20, 20, 2.0f, 20.0f}, {"three", 30, 30, 3.0f, 30.0f}, + {"four", 40, 40, 4.0f, 40.0f}, {"five", 50, 50, 5.0f, 50.0f}, + {"six", 60, 60, 6.0f, 60.0f}, {"seven", 70, 70, 7.0f, 70.0f}}; /*------------------------------------------------------------------------- * function that compares one particle @@ -65,16 +58,15 @@ static particle_t testPart[NRECORDS] = { * fields verbatim and not lose any bits. -JML *------------------------------------------------------------------------- */ -static int cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf ) +static int +cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf) { - if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) || - rbuf[i].lati != wbuf[j].lati || - rbuf[i].longi != wbuf[j].longi || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) || - !H5_DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) { - return FAIL; - } - return SUCCEED; + if ((HDstrcmp(rbuf[i].name, wbuf[j].name) != 0) || rbuf[i].lati != wbuf[j].lati || + rbuf[i].longi != wbuf[j].longi || !H5_FLT_ABS_EQUAL(rbuf[i].pressure, wbuf[j].pressure) || + !H5_DBL_ABS_EQUAL(rbuf[i].temperature, wbuf[j].temperature)) { + return FAIL; + } + return SUCCEED; } /*------------------------------------------------------------------------- @@ -84,53 +76,51 @@ static int cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf ) static hid_t make_particle_type(void) { - hid_t type_id; - hid_t string_type; - size_t type_size = sizeof(particle_t); - - /* Create the memory data type. */ - if ((type_id = H5Tcreate (H5T_COMPOUND, type_size )) < 0 ) - return FAIL; - - /* Insert fields. */ - if ((string_type = H5Tcopy(H5T_C_S1)) < 0) - return FAIL; - if (H5Tset_size(string_type, (size_t)16) < 0) - return FAIL; - - if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 ) - return FAIL; - if ( H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati) , H5T_NATIVE_INT ) < 0 ) - return FAIL; - if ( H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi) , H5T_NATIVE_INT ) < 0 ) - return FAIL; - if ( H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure) , H5T_NATIVE_FLOAT ) < 0 ) - return FAIL; - if ( H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature) , H5T_NATIVE_DOUBLE ) < 0 ) - return FAIL; - - return type_id; + hid_t type_id; + hid_t string_type; + size_t type_size = sizeof(particle_t); + + /* Create the memory data type. */ + if ((type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + return FAIL; + + /* Insert fields. */ + if ((string_type = H5Tcopy(H5T_C_S1)) < 0) + return FAIL; + if (H5Tset_size(string_type, (size_t)16) < 0) + return FAIL; + + if (H5Tinsert(type_id, "Name", HOFFSET(particle_t, name), string_type) < 0) + return FAIL; + if (H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati), H5T_NATIVE_INT) < 0) + return FAIL; + if (H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi), H5T_NATIVE_INT) < 0) + return FAIL; + if (H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure), H5T_NATIVE_FLOAT) < 0) + return FAIL; + if (H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature), H5T_NATIVE_DOUBLE) < 0) + return FAIL; + + return type_id; } - /* Create a normal HL table just like the HL examples do */ -static int create_hl_table(hid_t fid) +/* Create a normal HL table just like the HL examples do */ +static int +create_hl_table(hid_t fid) { - /* Calculate the offsets of the particle struct members in memory */ - size_t part_offset[NFIELDS] = { HOFFSET( particle_t, name ), - HOFFSET( particle_t, lati ), - HOFFSET( particle_t, longi ), - HOFFSET( particle_t, pressure ), - HOFFSET( particle_t, temperature )}; + /* Calculate the offsets of the particle struct members in memory */ + size_t part_offset[NFIELDS] = {HOFFSET(particle_t, name), HOFFSET(particle_t, lati), + HOFFSET(particle_t, longi), HOFFSET(particle_t, pressure), + HOFFSET(particle_t, temperature)}; /* Define field information */ - const char *field_names[NFIELDS] = - { "Name","Latitude", "Longitude", "Pressure", "Temperature" }; - hid_t field_type[NFIELDS]; - hid_t string_type; - hsize_t chunk_size = 10; - int *fill_data = NULL; - int compress = 0; - herr_t status; + const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"}; + hid_t field_type[NFIELDS]; + hid_t string_type; + hsize_t chunk_size = 10; + int * fill_data = NULL; + int compress = 0; + herr_t status; /* Initialize the field field_type */ if ((string_type = H5Tcopy(H5T_C_S1)) < 0) @@ -143,27 +133,24 @@ static int create_hl_table(hid_t fid) field_type[3] = H5T_NATIVE_FLOAT; field_type[4] = H5T_NATIVE_DOUBLE; + /*------------------------------------------------------------------------ + * H5TBmake_table + *------------------------------------------------------------------------- + */ - /*------------------------------------------------------------------------ - * H5TBmake_table - *------------------------------------------------------------------------- - */ - - status=H5TBmake_table( "Table Title", fid, H5TB_TABLE_NAME, (hsize_t)NFIELDS, - (hsize_t)NRECORDS, sizeof(particle_t), - field_names, part_offset, field_type, - chunk_size, fill_data, compress, testPart ); + status = H5TBmake_table("Table Title", fid, H5TB_TABLE_NAME, (hsize_t)NFIELDS, (hsize_t)NRECORDS, + sizeof(particle_t), field_names, part_offset, field_type, chunk_size, fill_data, + compress, testPart); - if (H5Tclose(string_type) < 0) - return FAIL; + if (H5Tclose(string_type) < 0) + return FAIL; - if(status<0) - return FAIL; - else - return SUCCEED; + if (status < 0) + return FAIL; + else + return SUCCEED; } - /*------------------------------------------------------------------------- * test_create_close * @@ -172,11 +159,12 @@ static int create_hl_table(hid_t fid) *------------------------------------------------------------------------- */ -static int test_create_close(hid_t fid) +static int +test_create_close(hid_t fid) { herr_t err; - hid_t table; - hid_t part_t; + hid_t table; + hid_t part_t; HL_TESTING2("H5PTcreate_fl and H5PTclose"); @@ -188,23 +176,23 @@ static int test_create_close(hid_t fid) /* Create the table */ table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1); if (H5Tclose(part_t) < 0) - goto error; - if( H5PTis_valid(table) < 0) - goto error; - if( H5PTis_varlen(table) != 0) - goto error; + goto error; + if (H5PTis_valid(table) < 0) + goto error; + if (H5PTis_varlen(table) != 0) + goto error; /* Close the table */ err = H5PTclose(table); - if( err < 0) + if (err < 0) goto error; PASSED(); return SUCCEED; error: - H5_FAILED(); - return FAIL; + H5_FAILED(); + return FAIL; } /*------------------------------------------------------------------------- @@ -214,32 +202,34 @@ error: * *------------------------------------------------------------------------- */ -static int test_open(hid_t fid) +static int +test_open(hid_t fid) { herr_t err; - hid_t table; + hid_t table; HL_TESTING2("H5PTopen"); /* Open the table */ table = H5PTopen(fid, PT_NAME); - if( H5PTis_valid(table) < 0) + if (H5PTis_valid(table) < 0) goto error; - if( H5PTis_varlen(table) != 0) + if (H5PTis_varlen(table) != 0) goto error; /* Close the table */ err = H5PTclose(table); - if( err < 0) + if (err < 0) goto error; PASSED(); return SUCCEED; error: - if (table > 0) H5PTclose(table); - H5_FAILED(); - return FAIL; + if (table > 0) + H5PTclose(table); + H5_FAILED(); + return FAIL; } /*------------------------------------------------------------------------- @@ -249,63 +239,64 @@ error: * *------------------------------------------------------------------------- */ -static int test_append(hid_t fid) +static int +test_append(hid_t fid) { - herr_t err; - hid_t table; + herr_t err; + hid_t table; hsize_t count = 0; HL_TESTING2("H5PTappend"); /* Open the table */ table = H5PTopen(fid, PT_NAME); - if( H5PTis_valid(table) < 0) + if (H5PTis_valid(table) < 0) goto error; /* Count the number of packets in the table */ err = H5PTget_num_packets(table, &count); - if( err < 0) + if (err < 0) goto error; /* There should be 0 records in the table */ - if( count != 0 ) + if (count != 0) goto error; /* Append one particle */ err = H5PTappend(table, (size_t)1, &(testPart[0])); - if( err < 0) + if (err < 0) goto error; /* Append several particles */ err = H5PTappend(table, (size_t)6, &(testPart[1])); - if( err < 0) + if (err < 0) goto error; /* Append one more particle */ err = H5PTappend(table, (size_t)1, &(testPart[7])); - if( err < 0) + if (err < 0) goto error; /* Count the number of packets in the table */ err = H5PTget_num_packets(table, &count); - if( err < 0) + if (err < 0) goto error; /* There should be 8 records in the table now */ - if( count != 8 ) + if (count != 8) goto error; /* Close the table */ err = H5PTclose(table); - if( err < 0) + if (err < 0) goto error; PASSED(); return SUCCEED; error: - H5_FAILED(); - if( H5PTis_valid(table) > 0) - H5PTclose(table); - return FAIL; + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -315,45 +306,45 @@ error: * *------------------------------------------------------------------------- */ -static int test_read(hid_t fid) +static int +test_read(hid_t fid) { - herr_t err; - hid_t table; + herr_t err; + hid_t table; particle_t readBuf[NRECORDS]; - size_t c; + size_t c; HL_TESTING2("H5PTread_packets"); /* Open the table */ table = H5PTopen(fid, PT_NAME); - if( H5PTis_valid(table) < 0) + if (H5PTis_valid(table) < 0) goto error; /* Read several particles */ err = H5PTread_packets(table, (hsize_t)0, 3, &(readBuf[0])); - if( err < 0) + if (err < 0) goto error; /* Read one particle */ err = H5PTread_packets(table, (hsize_t)3, 1, &(readBuf[3])); - if( err < 0) + if (err < 0) goto error; /* Read several particles */ - err = H5PTread_packets(table, (hsize_t)4, (NRECORDS - 4 ), &(readBuf[4])); - if( err < 0) + err = H5PTread_packets(table, (hsize_t)4, (NRECORDS - 4), &(readBuf[4])); + if (err < 0) goto error; /* Ensure that particles were read correctly */ - for(c=0; c 0) - H5PTclose(table); - return FAIL; + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -375,66 +366,63 @@ error: * *------------------------------------------------------------------------- */ -static int test_get_next(hid_t fid) +static int +test_get_next(hid_t fid) { - herr_t err; - hid_t table; + herr_t err; + hid_t table; particle_t readBuf[NRECORDS]; particle_t readBuf2[NRECORDS]; - size_t c; + size_t c; HL_TESTING2("H5PTget_next"); /* Open the table */ table = H5PTopen(fid, PT_NAME); - if( H5PTis_valid(table) < 0) + if (H5PTis_valid(table) < 0) goto error; /* Read several particles consecutively */ - for(c=0; c < NRECORDS; c++) - { + for (c = 0; c < NRECORDS; c++) { err = H5PTget_next(table, (size_t)1, &readBuf[c]); - if(err < 0) + if (err < 0) goto error; } /* Ensure that particles were read correctly */ - for(c=0; c 0) - H5PTclose(table); - return FAIL; + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -445,14 +433,15 @@ error: * *------------------------------------------------------------------------- */ -static int test_big_table(hid_t fid) +static int +test_big_table(hid_t fid) { - herr_t err; - hid_t table; - hid_t part_t; - size_t c; + herr_t err; + hid_t table; + hid_t part_t; + size_t c; particle_t readPart; - hsize_t count; + hsize_t count; HL_TESTING2("large packet table"); @@ -465,52 +454,50 @@ static int test_big_table(hid_t fid) table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, (hsize_t)33, -1); if (H5Tclose(part_t) < 0) goto error; - if( H5PTis_valid(table) < 0) + if (H5PTis_valid(table) < 0) goto error; - /* Add many particles */ - for(c = 0; c < BIG_TABLE_SIZE ; c+=8) - { + /* Add many particles */ + for (c = 0; c < BIG_TABLE_SIZE; c += 8) { /* Append eight particles at once*/ err = H5PTappend(table, (size_t)8, &(testPart[0])); - if( err < 0) + if (err < 0) goto error; } /* Count the number of packets in the table */ err = H5PTget_num_packets(table, &count); - if( err < 0) + if (err < 0) goto error; - if( count != BIG_TABLE_SIZE ) + if (count != BIG_TABLE_SIZE) goto error; /* Read particles to ensure that all of them were written correctly */ /* Also, ensure that H5PTcreate_fl set the current packet to */ /* the first packet in the table */ - for(c = 0; c < BIG_TABLE_SIZE; c++) - { + for (c = 0; c < BIG_TABLE_SIZE; c++) { err = H5PTget_next(table, (size_t)1, &readPart); - if(err < 0) + if (err < 0) goto error; /* Ensure that particles were read correctly */ - if( cmp_par(c % 8, 0, testPart, &readPart) != 0) + if (cmp_par(c % 8, 0, testPart, &readPart) != 0) goto error; } /* Close the table */ err = H5PTclose(table); - if( err < 0) + if (err < 0) goto error; PASSED(); return SUCCEED; error: - H5_FAILED(); - if( H5PTis_valid(table) > 0) - H5PTclose(table); - return FAIL; + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -520,63 +507,63 @@ error: * *------------------------------------------------------------------------- */ -static int test_opaque(hid_t fid) +static int +test_opaque(hid_t fid) { - herr_t err; - hid_t table; - hid_t part_t; - size_t c; + herr_t err; + hid_t table; + hid_t part_t; + size_t c; particle_t readBuf[NRECORDS]; HL_TESTING2("opaque data"); /* Create an opaque datatype for the particle struct */ - if ((part_t = H5Tcreate (H5T_OPAQUE, sizeof(particle_t) )) < 0 ) + if ((part_t = H5Tcreate(H5T_OPAQUE, sizeof(particle_t))) < 0) return FAIL; HDassert(part_t != -1); /* Tag the opaque datatype */ - if ( H5Tset_tag(part_t, "Opaque Particle" ) < 0) + if (H5Tset_tag(part_t, "Opaque Particle") < 0) return FAIL; /* Create a new table */ table = H5PTcreate_fl(fid, "Packet Test Dataset3", part_t, (hsize_t)100, -1); - if( H5Tclose(part_t) < 0) + if (H5Tclose(part_t) < 0) goto error; - if( H5PTis_valid(table) < 0) + if (H5PTis_valid(table) < 0) goto error; /* Append several particles, starting at particle 1 */ err = H5PTappend(table, (size_t)(NRECORDS - 1), &(testPart[1])); - if( err < 0) + if (err < 0) goto error; /* Read the particles back */ err = H5PTread_packets(table, (hsize_t)0, 7, &(readBuf[0])); - if( err < 0) + if (err < 0) goto error; /* Ensure that particles were read correctly */ - for(c=0; c 0) - H5PTclose(table); - return FAIL; + H5_FAILED(); + if (H5PTis_valid(table) > 0) + H5PTclose(table); + return FAIL; } /*------------------------------------------------------------------------- @@ -590,22 +577,23 @@ error: static int test_compress(void) { - hid_t fid1 = H5I_INVALID_HID; - herr_t err; - hid_t table = H5I_INVALID_HID; - hid_t part_t = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t plist_id = H5I_INVALID_HID; - size_t c; - size_t num_elems = 1; - unsigned filter_vals[1]; + hid_t fid1 = H5I_INVALID_HID; + herr_t err; + hid_t table = H5I_INVALID_HID; + hid_t part_t = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t plist_id = H5I_INVALID_HID; + size_t c; + size_t num_elems = 1; + unsigned filter_vals[1]; particle_t readPart[1]; - hsize_t count; + hsize_t count; HL_TESTING2("packet table compression"); /* Create a file. */ - if((fid1 = H5Fcreate(TEST_COMPRESS_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((fid1 = H5Fcreate(TEST_COMPRESS_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create a datatype for the particle struct */ part_t = make_particle_type(); @@ -614,106 +602,129 @@ test_compress(void) /* Create a new table with compression level 8 */ table = H5PTcreate_fl(fid1, "Compressed Test Dataset", part_t, (hsize_t)80, 8); - if( H5PTis_valid(table) < 0) TEST_ERROR; + if (H5PTis_valid(table) < 0) + TEST_ERROR; /* We can now use this table exactly the same way we use a normal uncompressed * packet table, and it should pass the same tests. */ - /* Add many particles */ - for(c = 0; c < BIG_TABLE_SIZE ; c+=8) - { + /* Add many particles */ + for (c = 0; c < BIG_TABLE_SIZE; c += 8) { /* Append eight particles at once*/ err = H5PTappend(table, (size_t)8, &(testPart[0])); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; } /* Count the number of packets in the table */ err = H5PTget_num_packets(table, &count); - if( err < 0) TEST_ERROR; - if( count != BIG_TABLE_SIZE ) TEST_ERROR; + if (err < 0) + TEST_ERROR; + if (count != BIG_TABLE_SIZE) + TEST_ERROR; /* Read particles to ensure that all of them were written correctly */ HDmemset(readPart, 0, sizeof(readPart)); - for(c = 0; c < BIG_TABLE_SIZE; c++) - { + for (c = 0; c < BIG_TABLE_SIZE; c++) { err = H5PTget_next(table, (size_t)1, readPart); - if(err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; /* Ensure that particles were read correctly */ - if( cmp_par(c % 8, 0, testPart, readPart) != 0) TEST_ERROR; + if (cmp_par(c % 8, 0, testPart, readPart) != 0) + TEST_ERROR; } /* Close the table */ err = H5PTclose(table); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; /* Open the packet table as a regular dataset and make sure that the * compression filter is set. */ dset_id = H5Dopen2(fid1, "Compressed Test Dataset", H5P_DEFAULT); - if( dset_id < 0) TEST_ERROR; + if (dset_id < 0) + TEST_ERROR; plist_id = H5Dget_create_plist(dset_id); - if( plist_id < 0) TEST_ERROR; + if (plist_id < 0) + TEST_ERROR; - err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, - filter_vals, 0, NULL, NULL); - if( err < 0) TEST_ERROR; + err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, filter_vals, 0, NULL, NULL); + if (err < 0) + TEST_ERROR; /* The compression level should be 8, the value we passed in */ - if(filter_vals[0] != 8) TEST_ERROR; + if (filter_vals[0] != 8) + TEST_ERROR; /* Clean up */ err = H5Pclose(plist_id); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; err = H5Dclose(dset_id); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; /* Create a new table without compression. */ table = H5PTcreate_fl(fid1, "Uncompressed Dataset", part_t, (hsize_t)80, -1); - if(table < 0) TEST_ERROR; + if (table < 0) + TEST_ERROR; /* Close the packet table */ err = H5PTclose(table); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; /* Open the packet table as a regular dataset and make sure that the * compression filter is not set. */ dset_id = H5Dopen2(fid1, "Uncompressed Dataset", H5P_DEFAULT); - if( dset_id < 0) TEST_ERROR; + if (dset_id < 0) + TEST_ERROR; plist_id = H5Dget_create_plist(dset_id); - if( plist_id < 0) TEST_ERROR; + if (plist_id < 0) + TEST_ERROR; - H5E_BEGIN_TRY { - err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, - filter_vals, 0, NULL, NULL); - if( err >= 0) TEST_ERROR; - } H5E_END_TRY + H5E_BEGIN_TRY + { + err = + H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, filter_vals, 0, NULL, NULL); + if (err >= 0) + TEST_ERROR; + } + H5E_END_TRY /* Clean up */ err = H5Pclose(plist_id); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; err = H5Dclose(dset_id); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; /* Close the datatype and the file */ err = H5Tclose(part_t); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; err = H5Fclose(fid1); - if( err < 0) TEST_ERROR; + if (err < 0) + TEST_ERROR; PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Pclose(plist_id); - H5Dclose(dset_id); - H5Tclose(part_t); - H5PTclose(table); - H5Fclose(fid1); - } H5E_END_TRY + H5E_BEGIN_TRY + { + H5Pclose(plist_id); + H5Dclose(dset_id); + H5Tclose(part_t); + H5PTclose(table); + H5Fclose(fid1); + } + H5E_END_TRY H5_FAILED(); return FAIL; } @@ -726,83 +737,85 @@ error: * *------------------------------------------------------------------------- */ -static int test_rw_nonnative_dt(hid_t fid) +static int +test_rw_nonnative_dt(hid_t fid) { - hid_t ptable; /* Packet table identifier */ + hid_t ptable; /* Packet table identifier */ - herr_t err; /* Function return status */ - hsize_t count; /* Number of records in the table */ + herr_t err; /* Function return status */ + hsize_t count; /* Number of records in the table */ - int x; /* Loop variable */ + int x; /* Loop variable */ - /* Buffers to hold data */ - int writeBuffer[5]; - int readBuffer[5]; + /* Buffers to hold data */ + int writeBuffer[5]; + int readBuffer[5]; - HL_TESTING2("reading/writing non-native packet table"); + HL_TESTING2("reading/writing non-native packet table"); - /* Initialize buffers */ - for(x=0; x<5; x++) { - writeBuffer[x]=x; - readBuffer[x] = -1; - } + /* Initialize buffers */ + for (x = 0; x < 5; x++) { + writeBuffer[x] = x; + readBuffer[x] = -1; + } - /* Create a fixed-length packet table within the file */ - /* This table's "packets" will be simple integers and it will use no compression */ - if(H5Tget_order(H5T_NATIVE_INT) == H5T_ORDER_LE) { - ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT); - } else { - ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, H5P_DEFAULT); - } - if(ptable == H5I_INVALID_HID) + /* Create a fixed-length packet table within the file */ + /* This table's "packets" will be simple integers and it will use no compression */ + if (H5Tget_order(H5T_NATIVE_INT) == H5T_ORDER_LE) { + ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT); + } + else { + ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, H5P_DEFAULT); + } + if (ptable == H5I_INVALID_HID) goto error; - /* Write one packet to the packet table */ - if( (err = H5PTappend(ptable, (size_t)1, &(writeBuffer[0]))) < 0 ) + /* Write one packet to the packet table */ + if ((err = H5PTappend(ptable, (size_t)1, &(writeBuffer[0]))) < 0) goto error; - /* Write several packets to the packet table */ - if( (err = H5PTappend(ptable, (size_t)4, &(writeBuffer[1]))) < 0) + /* Write several packets to the packet table */ + if ((err = H5PTappend(ptable, (size_t)4, &(writeBuffer[1]))) < 0) goto error; - if( (err = H5PTclose(ptable)) < 0) + if ((err = H5PTclose(ptable)) < 0) goto error; - /* Open the Packet table */ - if( (ptable = H5PTopen(fid, "Packet Test Dataset, Non-native")) < 0) + /* Open the Packet table */ + if ((ptable = H5PTopen(fid, "Packet Test Dataset, Non-native")) < 0) goto error; - /* Get the number of packets in the packet table. This should be five. */ - if( (err = H5PTget_num_packets(ptable, &count)) < 0) + /* Get the number of packets in the packet table. This should be five. */ + if ((err = H5PTget_num_packets(ptable, &count)) < 0) goto error; - if( (int)count != 5 ) + if ((int)count != 5) goto error; - /* Initialize packet table's "current record" */ - if( (err = H5PTcreate_index(ptable)) < 0) + /* Initialize packet table's "current record" */ + if ((err = H5PTcreate_index(ptable)) < 0) goto error; - /* Iterate through packets, read each one back */ - for(x=0; x<5; x++) { - if( (err = H5PTget_next(ptable, (size_t)1, &(readBuffer[x]))) < 0) - goto error; - if( x != readBuffer[x]) - goto error; - } + /* Iterate through packets, read each one back */ + for (x = 0; x < 5; x++) { + if ((err = H5PTget_next(ptable, (size_t)1, &(readBuffer[x]))) < 0) + goto error; + if (x != readBuffer[x]) + goto error; + } - /* Close the packet table */ - if( (err = H5PTclose(ptable)) < 0) + /* Close the packet table */ + if ((err = H5PTclose(ptable)) < 0) goto error; - PASSED(); - return SUCCEED; + PASSED(); + return SUCCEED; error: - H5_FAILED(); - if( H5PTis_valid(ptable) > 0) - H5PTclose(ptable); - return FAIL; + H5_FAILED(); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + return FAIL; } /*------------------------------------------------------------------------- @@ -813,109 +826,110 @@ error: * *------------------------------------------------------------------------- */ -static int test_error(hid_t fid) +static int +test_error(hid_t fid) { - hid_t id = H5I_INVALID_HID; - int id_open=0; - particle_t readBuf[1]; + hid_t id = H5I_INVALID_HID; + int id_open = 0; + particle_t readBuf[1]; - HL_TESTING2("error conditions"); + HL_TESTING2("error conditions"); - /* Create a HL table */ - if(create_hl_table(fid) < 0) + /* Create a HL table */ + if (create_hl_table(fid) < 0) goto error; - /* Try to open things that are not packet tables */ - H5E_BEGIN_TRY - if(H5PTopen(fid, "Bogus_name") >= 0) + /* Try to open things that are not packet tables */ + H5E_BEGIN_TRY + if (H5PTopen(fid, "Bogus_name") >= 0) goto error; - if(H5PTopen(fid, "group1") >= 0) + if (H5PTopen(fid, "group1") >= 0) goto error; - H5E_END_TRY + H5E_END_TRY - /* Try to execute packet table commands on an invalid ID */ - H5E_BEGIN_TRY - if(H5PTis_valid(id) >= 0) + /* Try to execute packet table commands on an invalid ID */ + H5E_BEGIN_TRY + if (H5PTis_valid(id) >= 0) goto error; - if(H5PTis_varlen(id) >= 0) + if (H5PTis_varlen(id) >= 0) goto error; - if(H5PTclose(id) >= 0) + if (H5PTclose(id) >= 0) goto error; - if(H5PTappend(id, (size_t)1, testPart) >= 0) + if (H5PTappend(id, (size_t)1, testPart) >= 0) goto error; - if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) + if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) goto error; - if(H5PTcreate_index(id) >= 0) + if (H5PTcreate_index(id) >= 0) goto error; - if(H5PTset_index(id, (hsize_t)1) >= 0) + if (H5PTset_index(id, (hsize_t)1) >= 0) goto error; - if(H5PTget_index(id, NULL) >= 0) + if (H5PTget_index(id, NULL) >= 0) goto error; - H5E_END_TRY + H5E_END_TRY - /* Open a high-level non-packet (H5TB) table and try to */ - /* execute commands on it. */ - if((id=H5Dopen2(fid, H5TB_TABLE_NAME, H5P_DEFAULT)) <0) + /* Open a high-level non-packet (H5TB) table and try to */ + /* execute commands on it. */ + if ((id = H5Dopen2(fid, H5TB_TABLE_NAME, H5P_DEFAULT)) < 0) goto error; - id_open = 1; + id_open = 1; - H5E_BEGIN_TRY - if(H5PTis_valid(id) >= 0) + H5E_BEGIN_TRY + if (H5PTis_valid(id) >= 0) goto error; - if(H5PTis_varlen(id) >= 0) + if (H5PTis_varlen(id) >= 0) goto error; - if(H5PTclose(id) >= 0) + if (H5PTclose(id) >= 0) goto error; - if(H5PTappend(id, (size_t)1, testPart) >= 0) + if (H5PTappend(id, (size_t)1, testPart) >= 0) goto error; - if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) + if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) goto error; - if(H5PTcreate_index(id) >= 0) + if (H5PTcreate_index(id) >= 0) goto error; - if(H5PTset_index(id, (hsize_t)1) >= 0) + if (H5PTset_index(id, (hsize_t)1) >= 0) goto error; - if(H5PTget_index(id, NULL) >= 0) + if (H5PTget_index(id, NULL) >= 0) goto error; - H5E_END_TRY + H5E_END_TRY - id_open=0; - if(H5Dclose(id) <0) + id_open = 0; + if (H5Dclose(id) < 0) goto error; - /* Open and close a packet table. Try to execute */ - /* commands on the closed ID. */ - if((id=H5PTopen(fid, PT_NAME))<0) + /* Open and close a packet table. Try to execute */ + /* commands on the closed ID. */ + if ((id = H5PTopen(fid, PT_NAME)) < 0) goto error; - if(H5PTclose(id) <0) + if (H5PTclose(id) < 0) goto error; - H5E_BEGIN_TRY - if(H5PTis_valid(id) >= 0) + H5E_BEGIN_TRY + if (H5PTis_valid(id) >= 0) goto error; - if(H5PTis_varlen(id) >= 0) + if (H5PTis_varlen(id) >= 0) goto error; - if(H5PTclose(id) >= 0) + if (H5PTclose(id) >= 0) goto error; - if(H5PTappend(id, (size_t)1, testPart) >= 0) + if (H5PTappend(id, (size_t)1, testPart) >= 0) goto error; - if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) + if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0) goto error; - if(H5PTcreate_index(id) >= 0) + if (H5PTcreate_index(id) >= 0) goto error; - if(H5PTset_index(id, (hsize_t)1) >= 0) + if (H5PTset_index(id, (hsize_t)1) >= 0) goto error; - if(H5PTget_index(id, NULL) >= 0) + if (H5PTget_index(id, NULL) >= 0) goto error; - H5E_END_TRY + H5E_END_TRY - PASSED(); - return SUCCEED; + PASSED(); + return SUCCEED; error: - H5_FAILED(); - if(id_open) - H5Dclose(id); - return FAIL; + H5_FAILED(); + if (id_open) + H5Dclose(id); + return FAIL; } /*------------------------------------------------------------------------- @@ -925,18 +939,19 @@ error: * *------------------------------------------------------------------------- */ -static int test_packet_table(hid_t fid) +static int +test_packet_table(hid_t fid) { - if( test_create_close(fid) < 0 ) + if (test_create_close(fid) < 0) return FAIL; - if( test_open(fid) < 0 ) + if (test_open(fid) < 0) return FAIL; /* test_append must be run before test_count and test_read, as it */ /* creates the packet table they use. */ - if( test_append(fid) < 0 ) + if (test_append(fid) < 0) return FAIL; /* These tests will not necessarily cause failures in each other, @@ -954,22 +969,23 @@ static int test_packet_table(hid_t fid) /* * -*/ -int main(void) + */ +int +main(void) { /* identifier for the file that is used in FL PT tests */ - hid_t fid; - int status = 0; + hid_t fid; + int status = 0; -/*------------------------------------------------------------------------- - * Packet test: test each function of the packet table library - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Packet test: test each function of the packet table library + *------------------------------------------------------------------------- + */ - /* create a file using default properties */ - fid=H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + /* create a file using default properties */ + fid = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDputs("Testing packet table"); + HDputs("Testing packet table"); /* Test packet table with fixed length */ if (test_packet_table(fid) < 0) @@ -981,7 +997,7 @@ int main(void) /* Close the file */ if (H5Fclose(fid) < 0) - status = 1; + status = 1; return status; } diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c index b41e73d..d2331d7 100644 --- a/hl/test/test_packet_vlen.c +++ b/hl/test/test_packet_vlen.c @@ -18,17 +18,17 @@ *------------------------------------------------------------------------- */ -#define NRECORDS 5 -#define TEST_FILE_NAME "test_packet_table_vlen.h5" +#define NRECORDS 5 +#define TEST_FILE_NAME "test_packet_table_vlen.h5" #define TESTFL_FILE_NAME "testfl_packet_table_vlen.h5" -#define PT_VLEN_ATOMIC "Dataset with VL of Atomic types" -#define PT_VLEN_COMP "Dataset with VL of Compound Types" -#define PT_COMP_VLEN "Dataset with Compound Type of VL types" -#define PT_VLEN_VLEN "Dataset with VL of VL types" -#define PT_FIXED_LEN "Fixed-length Packet Table" -#define L1_INCM 16 -#define L2_INCM 8 -#define NAME_BUF_SIZE 80 +#define PT_VLEN_ATOMIC "Dataset with VL of Atomic types" +#define PT_VLEN_COMP "Dataset with VL of Compound Types" +#define PT_COMP_VLEN "Dataset with Compound Type of VL types" +#define PT_VLEN_VLEN "Dataset with VL of VL types" +#define PT_FIXED_LEN "Fixed-length Packet Table" +#define L1_INCM 16 +#define L2_INCM 8 +#define NAME_BUF_SIZE 80 /*------------------------------------------------------------------------- * Local functions @@ -51,17 +51,18 @@ static int verify_attribute(hid_t fid, const char *table_name, const char *attr_ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int test_VLof_atomic(void) +static int +test_VLof_atomic(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ - hsize_t count; /* Number of records in the table */ - unsigned uu, vv; /* Loop variables */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */ + hsize_t count; /* Number of records in the table */ + unsigned uu, vv; /* Loop variables */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ HL_TESTING3(" with vlen of atomic"); @@ -71,84 +72,86 @@ static int test_VLof_atomic(void) if (writeBuf[uu].p == NULL) { HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].len = uu + 1; for (vv = 0; vv < (uu + 1); vv++) - ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv; + ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv; } /* end for */ /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a vlen type that uses an atomic datatype as its base type */ - vltype = H5Tvlen_create (H5T_NATIVE_UINT); + vltype = H5Tvlen_create(H5T_NATIVE_UINT); if (vltype < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of an atomic type */ ptable = H5PTcreate(fid, PT_VLEN_ATOMIC, vltype, (hsize_t)1, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Close the vlen datatype */ if (H5Tclose(vltype) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ - ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf ); + ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf); if (ret < 0) - goto error; + goto error; for (uu = 0; uu < NRECORDS; uu++) - for (vv = 0; vv < (uu + 1); vv++) - { - if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) { - HDprintf("Packet %u's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]); - HDprintf("Packet %u's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]); - } + for (vv = 0; vv < (uu + 1); vv++) { + if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) { + HDprintf("Packet %u's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]); + HDprintf("Packet %u's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]); + } } /* Free the buffers */ - ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf ); + ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (vltype > 0) H5Tclose(vltype); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - if (fid > 0) H5Fclose(fid); + if (vltype > 0) + H5Tclose(vltype); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + if (fid > 0) + H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); H5_FAILED(); @@ -162,134 +165,142 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int test_VLof_comptype(void) +static int +test_VLof_comptype(void) { /* Struct that the VL sequences are composed of */ typedef struct { unsigned u; - float f; + float f; } VLcomp_t; - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ - hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - hsize_t count; /* Number of records in the table */ - unsigned uu, vv; /* Loop variables */ - char msg[80]; /* For error message */ - herr_t ret; + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */ + hid_t cmptype = H5I_INVALID_HID; /* Compound datatype */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + hsize_t count; /* Number of records in the table */ + unsigned uu, vv; /* Loop variables */ + char msg[80]; /* For error message */ + herr_t ret; HL_TESTING3(" with vlen of compound datatypes"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(VLcomp_t)); - if(writeBuf[uu].p == NULL) { + if (writeBuf[uu].p == NULL) { HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].len = uu + 1; for (vv = 0; vv < (uu + 1); vv++) { ((VLcomp_t *)writeBuf[uu].p)[vv].u = uu + vv; ((VLcomp_t *)writeBuf[uu].p)[vv].f = (float)(uu + vv) / 3.0F; - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create the base compound type */ cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t)); if (cmptype < 0) - goto error; + goto error; /* Insert fields */ ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT); if (ret < 0) - goto error; + goto error; /* Create a variable length type that uses the VLcomp_t as its base type */ vltype = H5Tvlen_create(cmptype); if (vltype < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of compound datatype */ ptable = H5PTcreate(fid, PT_VLEN_COMP, vltype, (hsize_t)1, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release the datatypes */ if (H5Tclose(cmptype) < 0) - goto error; + goto error; if (H5Tclose(vltype) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ - ret = H5PTappend(ptable, (size_t)5, writeBuf ); + ret = H5PTappend(ptable, (size_t)5, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ - ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf ); + ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf); if (ret < 0) - goto error; + goto error; /* Compare data read in */ for (uu = 0; uu < NRECORDS; uu++) { if (writeBuf[uu].len != readBuf[uu].len) { - HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%d, readBuf[%u].len=%d\n", __LINE__, uu, (int)writeBuf[uu].len, uu, (int)readBuf[uu].len); - continue; - } /* write len != read len */ + HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%d, readBuf[%u].len=%d\n", + __LINE__, uu, (int)writeBuf[uu].len, uu, (int)readBuf[uu].len); + continue; + } /* write len != read len */ for (vv = 0; vv < (uu + 1); vv++) { - if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv] ) { - HDfprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%d]=%d, readBuf[uu].p[%d]=%d\n", vv, (int)((unsigned int *)writeBuf[uu].p)[vv], vv, (int)((unsigned int *)readBuf[uu].p)[vv]); + if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv]) { + HDfprintf( + stderr, "VL data values don't match!, writeBuf[uu].p[%d]=%d, readBuf[uu].p[%d]=%d\n", vv, + (int)((unsigned int *)writeBuf[uu].p)[vv], vv, (int)((unsigned int *)readBuf[uu].p)[vv]); continue; - } /* write value != read value */ - } + } /* write value != read value */ + } } /* end for */ /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (cmptype > 0) H5Tclose(cmptype); - if (vltype > 0) H5Tclose(vltype); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - if (fid > 0) H5Fclose(fid); + if (cmptype > 0) + H5Tclose(cmptype); + if (vltype > 0) + H5Tclose(vltype); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + if (fid > 0) + H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); H5_FAILED(); @@ -304,47 +315,47 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int test_compound_VL_VLtype(void) +static int +test_compound_VL_VLtype(void) { /* Struct that the VL sequences are composed of */ typedef struct { unsigned u; - float f; - hvl_t v; + float f; + hvl_t v; } compVLVL_t; - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ - hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */ - hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing - a VL of VL of atomic datatype */ - hsize_t count; /* Number of records in the table */ - compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */ - compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */ - hvl_t *t1, *t2; - unsigned uu, vv, ww; /* Loop variables */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */ + hid_t vlofvl = H5I_INVALID_HID; /* Variable length datatype */ + hid_t comp_vlvl = H5I_INVALID_HID; /* ID of a compound datatype containing + a VL of VL of atomic datatype */ + hsize_t count; /* Number of records in the table */ + compVLVL_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */ + hvl_t * t1, *t2; + unsigned uu, vv, ww; /* Loop variables */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ HL_TESTING3(" with compound datatype containing vlen datatype"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { - writeBuf[uu].u = uu * 10; - writeBuf[uu].f = (float)(uu * 20) / 3.0F; + writeBuf[uu].u = uu * 10; + writeBuf[uu].f = (float)(uu * 20) / 3.0F; writeBuf[uu].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t)); if (writeBuf[uu].v.p == NULL) { HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].v.len = uu + L1_INCM; - for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) - { + for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) { t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int)); - if (t1->p == NULL) { - HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); - goto error; - } + if (t1->p == NULL) { + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + goto error; + } t1->len = vv + L2_INCM; for (ww = 0; ww < vv + L2_INCM; ww++) ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww; @@ -354,123 +365,135 @@ static int test_compound_VL_VLtype(void) /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a VL datatype of an atomic type */ - vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); + vlatomic = H5Tvlen_create(H5T_NATIVE_UINT); if (vlatomic < 0) - goto error; + goto error; /* Create a VL datatype of the VL of atomic datatype */ - vlofvl = H5Tvlen_create (vlatomic); + vlofvl = H5Tvlen_create(vlatomic); if (vlofvl < 0) - goto error; + goto error; /* Create the base compound type */ comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t)); if (comp_vlvl < 0) - goto error; + goto error; /* Insert fields: atomic, atomic, vlen */ ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl); if (ret < 0) - goto error; + goto error; /* Create a packet table that uses a compound datatype of vlen datatype */ ptable = H5PTcreate(fid, PT_COMP_VLEN, comp_vlvl, (hsize_t)1, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release datatypes */ if (H5Tclose(vlatomic) < 0) - goto error; + goto error; if (H5Tclose(vlofvl) < 0) - goto error; + goto error; if (H5Tclose(comp_vlvl) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ - ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf ); + ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ - ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf ); + ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf); if (ret < 0) - goto error; + goto error; /* Compare data read in */ for (uu = 0; uu < NRECORDS; uu++) { if (writeBuf[uu].u != readBuf[uu].u) { - HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u); + HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, + writeBuf[uu].u, uu, readBuf[uu].u); continue; } /* end if */ - if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f,readBuf[uu].f)) { - HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f); + if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f, readBuf[uu].f)) { + HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, + (double)writeBuf[uu].f, uu, (double)readBuf[uu].f); continue; } /* end if */ if (writeBuf[uu].v.len != readBuf[uu].v.len) { - HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%d].v.len=%zu, readBuf[%d].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len); + HDfprintf(stderr, + "%d: VL data length don't match!, writeBuf[%d].v.len=%zu, readBuf[%d].v.len=%zu\n", + __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len); continue; } /* end if */ - for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) { + for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; + (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) { if (t1->len != t2->len) { - HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len); + HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", + __LINE__, uu, vv, t1->len, t2->len); continue; } /* end if */ for (ww = 0; (size_t)ww < t2->len; ww++) { - if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww] ) { - HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]); + if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww]) { + HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, + ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (vlatomic > 0) H5Tclose(vlatomic); - if (vlofvl > 0) H5Tclose(vlofvl); - if (comp_vlvl > 0) H5Tclose(comp_vlvl); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - if (fid > 0) H5Fclose(fid); + if (vlatomic > 0) + H5Tclose(vlatomic); + if (vlofvl > 0) + H5Tclose(vlofvl); + if (comp_vlvl > 0) + H5Tclose(comp_vlvl); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + if (fid > 0) + H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); H5_FAILED(); @@ -485,19 +508,20 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int test_VLof_VLtype(void) +static int +test_VLof_VLtype(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ - hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */ - hsize_t count; /* Number of records in the table */ - hvl_t *t1; /* pointer to advance */ - unsigned uu, vv, ww; /* Loop variables */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */ + hid_t vlofvl = H5I_INVALID_HID; /* VL datatype of VL datatypes */ + hsize_t count; /* Number of records in the table */ + hvl_t * t1; /* pointer to advance */ + unsigned uu, vv, ww; /* Loop variables */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ HL_TESTING3(" with vlen datatype of vlen datatype"); @@ -509,89 +533,92 @@ static int test_VLof_VLtype(void) goto error; } /* end if */ writeBuf[uu].len = uu + 1; - for (t1=(hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) - { + for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) { t1->p = HDmalloc((vv + 1) * sizeof(unsigned int)); - if (t1->p == NULL) { - HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); - goto error; - } + if (t1->p == NULL) { + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + goto error; + } t1->len = vv * 1; for (ww = 0; ww < (vv * 1); ww++) ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww; } /* end for */ - } /* end for */ + } /* end for */ /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a VL datatype of an atomic type */ - vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); + vlatomic = H5Tvlen_create(H5T_NATIVE_UINT); if (vlatomic < 0) - goto error; + goto error; - vlofvl = H5Tvlen_create (vlatomic); + vlofvl = H5Tvlen_create(vlatomic); if (vlofvl < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of vlen datatype */ ptable = H5PTcreate(fid, PT_VLEN_VLEN, vlofvl, (hsize_t)1, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release datatypes */ if (H5Tclose(vlatomic) < 0) - goto error; + goto error; if (H5Tclose(vlofvl) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ - ret = H5PTappend(ptable, (size_t)5, writeBuf ); + ret = H5PTappend(ptable, (size_t)5, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ - ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf ); + ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf); if (ret < 0) - goto error; + goto error; /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (vlatomic > 0) H5Tclose(vlatomic); - if (vlofvl > 0) H5Tclose(vlofvl); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - if (fid > 0) H5Fclose(fid); + if (vlatomic > 0) + H5Tclose(vlatomic); + if (vlofvl > 0) + H5Tclose(vlofvl); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + if (fid > 0) + H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); H5_FAILED(); @@ -606,40 +633,41 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int verify_ptlengthtype(hid_t fid, const char *table_name, herr_t expected_value) +static int +verify_ptlengthtype(hid_t fid, const char *table_name, herr_t expected_value) { - hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ - herr_t is_varlen = 0; - herr_t ret = FAIL; + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + herr_t is_varlen = 0; + herr_t ret = FAIL; /* Open the named packet table */ - if( (ptable = H5PTopen(fid, table_name)) < 0) - goto error; + if ((ptable = H5PTopen(fid, table_name)) < 0) + goto error; /* Verify the value returned from H5PTis_varlen is as expected */ is_varlen = H5PTis_varlen(ptable); if (is_varlen == FAIL) - goto error; + goto error; else if (is_varlen == expected_value) - ret = SUCCEED; - else - { - char lenthtype[20]; - HDstrcpy(lenthtype, "fixed-length"); - if (expected_value == 1) - HDstrcpy(lenthtype, "variable-length"); - HDfprintf(stderr, "\nPacket table '%s' should be %s but is not\n", table_name, lenthtype); - ret = FAIL; + ret = SUCCEED; + else { + char lenthtype[20]; + HDstrcpy(lenthtype, "fixed-length"); + if (expected_value == 1) + HDstrcpy(lenthtype, "variable-length"); + HDfprintf(stderr, "\nPacket table '%s' should be %s but is not\n", table_name, lenthtype); + ret = FAIL; } /* Close the packet table */ if (H5PTclose(ptable) < 0) - goto error; + goto error; return ret; error: /* An error has occurred. Clean up and exit. */ - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); return ret; } /* verify_ptlengthtype */ @@ -655,67 +683,69 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int test_H5PTis_varlen(void) +static int +test_H5PTis_varlen(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - herr_t ret; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + herr_t ret; /* Returned status from a callee */ HL_TESTING2("H5PTis_varlen"); /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a new table */ ptable = H5PTcreate(fid, PT_FIXED_LEN, H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Open each packet table, and verify that H5PTis_varlen returns correct type for each table */ ret = verify_ptlengthtype(fid, PT_VLEN_ATOMIC, 1); /* vlen of atomic */ if (ret < 0) - goto error; + goto error; ret = verify_ptlengthtype(fid, PT_VLEN_COMP, 1); /* vlen of compound */ if (ret < 0) - goto error; + goto error; ret = verify_ptlengthtype(fid, PT_COMP_VLEN, 0); /* compound of vlen, no vlen */ if (ret < 0) - goto error; + goto error; ret = verify_ptlengthtype(fid, PT_VLEN_VLEN, 1); /* vlen of vlen */ if (ret < 0) - goto error; + goto error; ret = verify_ptlengthtype(fid, PT_FIXED_LEN, 0); /* no vlen */ if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (fid > 0) H5Fclose(fid); + if (fid > 0) + H5Fclose(fid); H5_FAILED(); return FAIL; } /* test_H5PTis_varlen */ @@ -731,60 +761,64 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -#define ATTR_RANK 1 -#define ATTR_DIM 3 -int attr_data[ATTR_DIM]={256,11945,-22107}; /* values to be written to attr */ +#define ATTR_RANK 1 +#define ATTR_DIM 3 +int attr_data[ATTR_DIM] = {256, 11945, -22107}; /* values to be written to attr */ -static int adding_attribute(hid_t fid, const char *table_name, const char *attr_name) +static int +adding_attribute(hid_t fid, const char *table_name, const char *attr_name) { - hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ - hid_t space_id = H5I_INVALID_HID; /* Dataspace for the attribute */ - hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */ - hid_t dset_id = H5I_INVALID_HID; /* Dataset identifier */ - hsize_t dims[] = {ATTR_DIM}; /* Dimension for dataspace */ - int ret = FAIL; /* Returned status from a callee */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t space_id = H5I_INVALID_HID; /* Dataspace for the attribute */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */ + hid_t dset_id = H5I_INVALID_HID; /* Dataset identifier */ + hsize_t dims[] = {ATTR_DIM}; /* Dimension for dataspace */ + int ret = FAIL; /* Returned status from a callee */ /* Create dataspace for attribute */ space_id = H5Screate_simple(ATTR_RANK, dims, NULL); if (space_id < 0) - goto error; + goto error; /* Open the named packet table */ - if( (ptable = H5PTopen(fid, table_name)) < 0) - goto error; + if ((ptable = H5PTopen(fid, table_name)) < 0) + goto error; dset_id = H5PTget_dataset(ptable); if (dset_id < 0) - goto error; + goto error; /* Add the specified attribute to it */ attr_id = H5Acreate2(dset_id, attr_name, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT); if (attr_id < 0) - goto error; + goto error; /* Write attribute values */ ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data); if (ret < 0) - goto error; + goto error; /* Close the attribute */ if (H5Aclose(attr_id) < 0) - goto error; + goto error; /* Close the dataspace */ if (H5Sclose(space_id) < 0) - goto error; + goto error; /* Close the packet table */ if (H5PTclose(ptable) < 0) - goto error; + goto error; return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (attr_id > 0) H5Aclose(attr_id); - if (space_id > 0) H5Sclose(space_id); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); + if (attr_id > 0) + H5Aclose(attr_id); + if (space_id > 0) + H5Sclose(space_id); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); return ret; } /* adding_attribute */ @@ -795,53 +829,57 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static herr_t verify_attribute(hid_t fid, const char *table_name, const char *attr_name) +static herr_t +verify_attribute(hid_t fid, const char *table_name, const char *attr_name) { - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */ - hid_t dset_id=H5I_INVALID_HID; /* Dataset associated with the pt */ - int read_data[ATTR_DIM]; /* Output buffer */ - int ii; - herr_t ret = FAIL; /* Returned status from a callee */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */ + hid_t dset_id = H5I_INVALID_HID; /* Dataset associated with the pt */ + int read_data[ATTR_DIM]; /* Output buffer */ + int ii; + herr_t ret = FAIL; /* Returned status from a callee */ /* Open the named packet table */ ptable = H5PTopen(fid, table_name); if (ptable < 0) - goto error; + goto error; /* Get the dataset id of this packet table */ dset_id = H5PTget_dataset(ptable); if (dset_id < 0) - goto error; + goto error; /* Open first attribute for the dataset */ attr_id = H5Aopen(dset_id, attr_name, H5P_DEFAULT); if (attr_id < 0) - goto error; + goto error; /* Read attribute values */ ret = H5Aread(attr_id, H5T_NATIVE_INT, read_data); if (ret < 0) - goto error; + goto error; /* Verify values read in */ for (ii = 0; ii < ATTR_DIM; ii++) if (attr_data[ii] != read_data[ii]) - TestErrPrintf("%d: attribute data different: attr_data[%d]=%d, read_data[%d]=%d\n", __LINE__, ii, attr_data[ii], ii, read_data[ii]); + TestErrPrintf("%d: attribute data different: attr_data[%d]=%d, read_data[%d]=%d\n", __LINE__, ii, + attr_data[ii], ii, read_data[ii]); /* Close the attribute */ if (H5Aclose(attr_id) < 0) - goto error; + goto error; /* Close the packet table */ if (H5PTclose(ptable) < 0) - goto error; + goto error; return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (attr_id > 0) H5Aclose(attr_id); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); + if (attr_id > 0) + H5Aclose(attr_id); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); return ret; } /* verify_attribute */ @@ -854,59 +892,61 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int test_attributes(void) +static int +test_attributes(void) { - hid_t fid=H5I_INVALID_HID; /* File identifier */ - hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */ - herr_t ret = FAIL; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* File identifier */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */ + herr_t ret = FAIL; /* Returned status from a callee */ HL_TESTING2("adding attributes to packet tables"); /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Add an arbitrary attribute to a few packet tables, using helper func */ attr_id = adding_attribute(fid, PT_VLEN_ATOMIC, "Attribute 1"); if (attr_id < 0) - goto error; + goto error; attr_id = adding_attribute(fid, PT_VLEN_COMP, "Attribute 2"); if (attr_id < 0) - goto error; + goto error; attr_id = adding_attribute(fid, PT_COMP_VLEN, "Attribute 3"); if (attr_id < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; /* Open the file again */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Read each attribute and verify the values, using helper function */ ret = verify_attribute(fid, PT_VLEN_ATOMIC, "Attribute 1"); if (ret < 0) - goto error; + goto error; ret = verify_attribute(fid, PT_VLEN_COMP, "Attribute 2"); if (ret < 0) - goto error; + goto error; ret = verify_attribute(fid, PT_COMP_VLEN, "Attribute 3"); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); - return(ret); + return (ret); error: /* An error has occurred. Clean up and exit. */ - if (fid > 0) H5Fclose(fid); + if (fid > 0) + H5Fclose(fid); H5_FAILED(); return FAIL; } /* test_attributes */ @@ -928,35 +968,36 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static herr_t verify_accessors(hid_t fid, const char *table_name, hbool_t uses_vlen_type) +static herr_t +verify_accessors(hid_t fid, const char *table_name, hbool_t uses_vlen_type) { - hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ - hid_t dset_id = H5I_INVALID_HID; /* Dataset associated with the pt */ - hid_t dtype_id = H5I_INVALID_HID; /* Dataset identifier */ - char buf[NAME_BUF_SIZE]; + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t dset_id = H5I_INVALID_HID; /* Dataset associated with the pt */ + hid_t dtype_id = H5I_INVALID_HID; /* Dataset identifier */ + char buf[NAME_BUF_SIZE]; ssize_t name_size; - htri_t vlen_check_result = -1; + htri_t vlen_check_result = -1; /* Open the named packet table. */ - if((ptable = H5PTopen(fid, table_name)) < 0) + if ((ptable = H5PTopen(fid, table_name)) < 0) goto error; /* Get the associated dataset ID. */ - if((dset_id = H5PTget_dataset(ptable)) < 0) + if ((dset_id = H5PTget_dataset(ptable)) < 0) goto error; /* Check if the packet table's name matches its associated dataset's. */ *buf = '\0'; - if((name_size = H5Iget_name(dset_id, (char*)buf, NAME_BUF_SIZE)) < 0) + if ((name_size = H5Iget_name(dset_id, (char *)buf, NAME_BUF_SIZE)) < 0) goto error; VERIFY(HDstrcmp(buf, table_name), "Names of dataset and packet table don't match"); /* Get the packet table's datatype ID */ - if((dtype_id = H5PTget_type(ptable)) < 0) + if ((dtype_id = H5PTget_type(ptable)) < 0) goto error; /* Check if the type class matches that of the packet table. */ - if((vlen_check_result = H5Tdetect_class(dtype_id, H5T_VLEN)) < 0) + if ((vlen_check_result = H5Tdetect_class(dtype_id, H5T_VLEN)) < 0) goto error; /* Check if length types match */ @@ -996,10 +1037,11 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int test_accessors(void) +static int +test_accessors(void) { - hid_t fid=H5I_INVALID_HID; /* File identifier */ - herr_t ret = FAIL; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* File identifier */ + herr_t ret = FAIL; /* Returned status from a callee */ HL_TESTING2("accessor functions"); @@ -1044,17 +1086,18 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int testfl_VLof_atomic(void) +static int +testfl_VLof_atomic(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ - hsize_t count; /* Number of records in the table */ - unsigned uu, vv; /* Loop variables */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */ + hsize_t count; /* Number of records in the table */ + unsigned uu, vv; /* Loop variables */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ HL_TESTING3(" with vlen of atomic"); @@ -1064,84 +1107,86 @@ static int testfl_VLof_atomic(void) if (writeBuf[uu].p == NULL) { HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].len = uu + 1; for (vv = 0; vv < (uu + 1); vv++) - ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv; + ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv; } /* end for */ /* Open the file */ fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a vlen type that uses an atomic datatype as its base type */ - vltype = H5Tvlen_create (H5T_NATIVE_UINT); + vltype = H5Tvlen_create(H5T_NATIVE_UINT); if (vltype < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of an atomic type */ ptable = H5PTcreate_fl(fid, PT_VLEN_ATOMIC, vltype, (hsize_t)1, 0); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Close the vlen datatype */ if (H5Tclose(vltype) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ - ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf ); + ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf); if (ret < 0) - goto error; + goto error; for (uu = 0; uu < NRECORDS; uu++) - for (vv = 0; vv < (uu + 1); vv++) - { - if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) { - HDprintf("Packet %d's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]); - HDprintf("Packet %d's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]); - } + for (vv = 0; vv < (uu + 1); vv++) { + if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) { + HDprintf("Packet %d's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]); + HDprintf("Packet %d's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]); + } } /* Free the buffers */ - ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf ); + ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (vltype > 0) H5Tclose(vltype); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - if (fid > 0) H5Fclose(fid); + if (vltype > 0) + H5Tclose(vltype); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + if (fid > 0) + H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); H5_FAILED(); @@ -1155,134 +1200,142 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int testfl_VLof_comptype(void) +static int +testfl_VLof_comptype(void) { /* Struct that the VL sequences are composed of */ typedef struct { unsigned u; - float f; + float f; } VLcomp_t; - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ - hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - hsize_t count; /* Number of records in the table */ - unsigned uu, vv; /* Loop variables */ - char msg[80]; /* For error message */ - herr_t ret; + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */ + hid_t cmptype = H5I_INVALID_HID; /* Compound datatype */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + hsize_t count; /* Number of records in the table */ + unsigned uu, vv; /* Loop variables */ + char msg[80]; /* For error message */ + herr_t ret; HL_TESTING3(" with vlen of compound datatypes"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(VLcomp_t)); - if(writeBuf[uu].p == NULL) { + if (writeBuf[uu].p == NULL) { HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].len = uu + 1; for (vv = 0; vv < (uu + 1); vv++) { ((VLcomp_t *)writeBuf[uu].p)[vv].u = uu + vv; ((VLcomp_t *)writeBuf[uu].p)[vv].f = (float)(uu + vv) / 3.0F; - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Open the file */ fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create the base compound type */ cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t)); if (cmptype < 0) - goto error; + goto error; /* Insert fields */ ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT); if (ret < 0) - goto error; + goto error; /* Create a variable length type that uses the VLcomp_t as its base type */ vltype = H5Tvlen_create(cmptype); if (vltype < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of compound datatype */ ptable = H5PTcreate_fl(fid, PT_VLEN_COMP, vltype, (hsize_t)1, 0); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release the datatypes */ if (H5Tclose(cmptype) < 0) - goto error; + goto error; if (H5Tclose(vltype) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ - ret = H5PTappend(ptable, (size_t)5, writeBuf ); + ret = H5PTappend(ptable, (size_t)5, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ - ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf ); + ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf); if (ret < 0) - goto error; + goto error; /* Compare data read in */ for (uu = 0; uu < NRECORDS; uu++) { if (writeBuf[uu].len != readBuf[uu].len) { - HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%zu, readBuf[%u].len=%zu\n",__LINE__, uu, writeBuf[uu].len, uu, readBuf[uu].len); - continue; - } /* write len != read len */ + HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%zu, readBuf[%u].len=%zu\n", + __LINE__, uu, writeBuf[uu].len, uu, readBuf[uu].len); + continue; + } /* write len != read len */ for (vv = 0; vv < (uu + 1); vv++) { - if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv] ) { - HDfprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%u]=%u, readBuf[uu].p[%u]=%u\n", vv, ((unsigned int *)writeBuf[uu].p)[vv], vv, ((unsigned int *)readBuf[uu].p)[vv]); + if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv]) { + HDfprintf(stderr, + "VL data values don't match!, writeBuf[uu].p[%u]=%u, readBuf[uu].p[%u]=%u\n", vv, + ((unsigned int *)writeBuf[uu].p)[vv], vv, ((unsigned int *)readBuf[uu].p)[vv]); continue; - } /* write value != read value */ - } + } /* write value != read value */ + } } /* end for */ /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (cmptype > 0) H5Tclose(cmptype); - if (vltype > 0) H5Tclose(vltype); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - if (fid > 0) H5Fclose(fid); + if (cmptype > 0) + H5Tclose(cmptype); + if (vltype > 0) + H5Tclose(vltype); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + if (fid > 0) + H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); H5_FAILED(); @@ -1297,173 +1350,185 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int testfl_compound_VL_VLtype(void) +static int +testfl_compound_VL_VLtype(void) { /* Struct that the VL sequences are composed of */ typedef struct { unsigned u; - float f; - hvl_t v; + float f; + hvl_t v; } compVLVL_t; - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ - hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */ - hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing - a VL of VL of atomic datatype */ - hsize_t count; /* Number of records in the table */ - compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */ - compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */ - hvl_t *t1, *t2; - unsigned uu, vv, ww; /* Loop variables */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */ + hid_t vlofvl = H5I_INVALID_HID; /* Variable length datatype */ + hid_t comp_vlvl = H5I_INVALID_HID; /* ID of a compound datatype containing + a VL of VL of atomic datatype */ + hsize_t count; /* Number of records in the table */ + compVLVL_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */ + hvl_t * t1, *t2; + unsigned uu, vv, ww; /* Loop variables */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ HL_TESTING3(" with compound datatype containing vlen datatype"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { - writeBuf[uu].u = uu * 10; - writeBuf[uu].f = (float)(uu * 20) / 3.0F; + writeBuf[uu].u = uu * 10; + writeBuf[uu].f = (float)(uu * 20) / 3.0F; writeBuf[uu].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t)); if (writeBuf[uu].v.p == NULL) { HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].v.len = uu + L1_INCM; - for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) - { + for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) { t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int)); - if (t1->p == NULL) { - HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); - goto error; - } + if (t1->p == NULL) { + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + goto error; + } t1->len = vv + L2_INCM; for (ww = 0; ww < vv + L2_INCM; ww++) - ((unsigned int*)t1->p)[ww] = uu * 100 + vv * 10 + ww; + ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww; } } /* end for */ /* Open the file */ fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a VL datatype of an atomic type */ - vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); + vlatomic = H5Tvlen_create(H5T_NATIVE_UINT); if (vlatomic < 0) - goto error; + goto error; /* Create a VL datatype of the VL of atomic datatype */ - vlofvl = H5Tvlen_create (vlatomic); + vlofvl = H5Tvlen_create(vlatomic); if (vlofvl < 0) - goto error; + goto error; /* Create the base compound type */ comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t)); if (comp_vlvl < 0) - goto error; + goto error; /* Insert fields: atomic, atomic, vlen */ ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl); if (ret < 0) - goto error; + goto error; /* Create a packet table that uses a compound datatype of vlen datatype */ ptable = H5PTcreate_fl(fid, PT_COMP_VLEN, comp_vlvl, (hsize_t)1, 0); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release datatypes */ if (H5Tclose(vlatomic) < 0) - goto error; + goto error; if (H5Tclose(vlofvl) < 0) - goto error; + goto error; if (H5Tclose(comp_vlvl) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ - ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf ); + ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ - ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf ); + ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf); if (ret < 0) - goto error; + goto error; /* Compare data read in */ for (uu = 0; uu < NRECORDS; uu++) { if (writeBuf[uu].u != readBuf[uu].u) { - HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u); + HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, + writeBuf[uu].u, uu, readBuf[uu].u); continue; } /* end if */ if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f, readBuf[uu].f)) { - HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f); + HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, + (double)writeBuf[uu].f, uu, (double)readBuf[uu].f); continue; } /* end if */ if (writeBuf[uu].v.len != readBuf[uu].v.len) { - HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].v.len=%zu, readBuf[%u].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len); + HDfprintf(stderr, + "%d: VL data length don't match!, writeBuf[%u].v.len=%zu, readBuf[%u].v.len=%zu\n", + __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len); continue; } /* end if */ - for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) { + for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; + (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) { if (t1->len != t2->len) { - HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len); + HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", + __LINE__, uu, vv, t1->len, t2->len); continue; } /* end if */ for (ww = 0; (size_t)ww < t2->len; ww++) { - if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww] ) { - HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]); + if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww]) { + HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, + ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (vlatomic > 0) H5Tclose(vlatomic); - if (vlofvl > 0) H5Tclose(vlofvl); - if (comp_vlvl > 0) H5Tclose(comp_vlvl); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - if (fid > 0) H5Fclose(fid); + if (vlatomic > 0) + H5Tclose(vlatomic); + if (vlofvl > 0) + H5Tclose(vlofvl); + if (comp_vlvl > 0) + H5Tclose(comp_vlvl); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + if (fid > 0) + H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); H5_FAILED(); @@ -1478,19 +1543,20 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static int testfl_VLof_VLtype(void) +static int +testfl_VLof_VLtype(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ - hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */ - hsize_t count; /* Number of records in the table */ - hvl_t *t1; /* pointer to advance */ - unsigned uu, vv, ww; /* Loop variables */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ + hid_t fid = H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */ + hid_t vlofvl = H5I_INVALID_HID; /* VL datatype of VL datatypes */ + hsize_t count; /* Number of records in the table */ + hvl_t * t1; /* pointer to advance */ + unsigned uu, vv, ww; /* Loop variables */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ HL_TESTING3(" with vlen datatype of vlen datatype"); @@ -1502,89 +1568,92 @@ static int testfl_VLof_VLtype(void) goto error; } /* end if */ writeBuf[uu].len = uu + 1; - for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) - { + for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) { t1->p = HDmalloc((vv + 1) * sizeof(unsigned int)); - if (t1->p == NULL) { - HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); - goto error; - } + if (t1->p == NULL) { + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + goto error; + } t1->len = vv + 1; for (ww = 0; ww < (vv + 1); ww++) ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww; } /* end for */ - } /* end for */ + } /* end for */ /* Open the file */ fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a VL datatype of an atomic type */ - vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); + vlatomic = H5Tvlen_create(H5T_NATIVE_UINT); if (vlatomic < 0) - goto error; + goto error; - vlofvl = H5Tvlen_create (vlatomic); + vlofvl = H5Tvlen_create(vlatomic); if (vlofvl < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of vlen datatype */ ptable = H5PTcreate_fl(fid, PT_VLEN_VLEN, vlofvl, (hsize_t)1, 0); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release datatypes */ if (H5Tclose(vlatomic) < 0) - goto error; + goto error; if (H5Tclose(vlofvl) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ - ret = H5PTappend(ptable, (size_t)5, writeBuf ); + ret = H5PTappend(ptable, (size_t)5, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ - ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf ); + ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf); if (ret < 0) - goto error; + goto error; /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (vlatomic > 0) H5Tclose(vlatomic); - if (vlofvl > 0) H5Tclose(vlofvl); - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - if (fid > 0) H5Fclose(fid); + if (vlatomic > 0) + H5Tclose(vlatomic); + if (vlofvl > 0) + H5Tclose(vlofvl); + if (H5PTis_valid(ptable) > 0) + H5PTclose(ptable); + if (fid > 0) + H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); H5_FAILED(); @@ -1599,19 +1668,20 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -int test_packet_table_with_varlen(void) +int +test_packet_table_with_varlen(void) { - hid_t fid=H5I_INVALID_HID; /* File identifier */ - int status = SUCCEED; + hid_t fid = H5I_INVALID_HID; /* File identifier */ + int status = SUCCEED; /* Create a file using default properties */ fid = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid < 0) - return FAIL; + return FAIL; /* Close the file. The file will be opened by each test function below */ if (H5Fclose(fid) < 0) - return FAIL; + return FAIL; HDputs("Testing packet table with various variable-length datatypes"); @@ -1620,46 +1690,46 @@ int test_packet_table_with_varlen(void) /* Test variable length of a simple type */ if (test_VLof_atomic() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a compound type */ if (test_VLof_comptype() < 0) - status = FAIL; + status = FAIL; /* Test compound type with variable length */ if (test_compound_VL_VLtype() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a variable length */ if (test_VLof_VLtype() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a variable length */ if (test_H5PTis_varlen() < 0) - status = FAIL; + status = FAIL; /* Test adding attributes to packet table */ if (test_attributes() < 0) - status = FAIL; + status = FAIL; /* Test accessor functions */ if (test_accessors() < 0) - status = FAIL; + status = FAIL; -/************************************************************************** - Calling test functions for deprecated function H5PTcreate_fl - Mar 2016, -BMR + /************************************************************************** + Calling test functions for deprecated function H5PTcreate_fl + Mar 2016, -BMR -**************************************************************************/ + **************************************************************************/ /* Create a file using default properties */ fid = H5Fcreate(TESTFL_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid < 0) - return FAIL; + return FAIL; /* Close the file. The file will be opened by each test function below */ if (H5Fclose(fid) < 0) - return FAIL; + return FAIL; HDputs("Testing packet table with various variable-length datatypes - H5PTcreate_fl"); @@ -1668,19 +1738,19 @@ int test_packet_table_with_varlen(void) /* Test variable length of a simple type */ if (testfl_VLof_atomic() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a compound type */ if (testfl_VLof_comptype() < 0) - status = FAIL; + status = FAIL; /* Test compound type with variable length */ if (testfl_compound_VL_VLtype() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a variable length */ if (testfl_VLof_VLtype() < 0) - status = FAIL; + status = FAIL; - return(status); + return (status); } diff --git a/hl/test/test_table.c b/hl/test/test_table.c index 1d6bcec..3f953d4 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -17,46 +17,44 @@ #include "H5srcdir.h" #include "H5TBpublic.h" -#define TEST_FILE_BE "test_table_be.h5" -#define TEST_FILE_LE "test_table_le.h5" +#define TEST_FILE_BE "test_table_be.h5" +#define TEST_FILE_LE "test_table_le.h5" #define TEST_FILE_CRAY "test_table_cray.h5" - /*------------------------------------------------------------------------- -* Table API test -* -* Functions tested: -* -* H5TBmake_table -* H5TBread_table -* H5TBwrite_records -* H5TBread_records -* H5TBappend_records -* H5TBinsert_record -* H5TBdelete_record -* H5TBcombine_tables -* H5TBwrite_fields_name -* H5TBread_fields_name -* H5TBwrite_fields_index -* H5TBinsert_field -* H5TBdelete_field -* H5TBget_table_info -* H5TBget_field_info -* -*------------------------------------------------------------------------- -*/ - -#define TITLE "Title" -#define NFIELDS 5 -#define NRECORDS 8 -#define NRECORDS_ADD 3 + * Table API test + * + * Functions tested: + * + * H5TBmake_table + * H5TBread_table + * H5TBwrite_records + * H5TBread_records + * H5TBappend_records + * H5TBinsert_record + * H5TBdelete_record + * H5TBcombine_tables + * H5TBwrite_fields_name + * H5TBread_fields_name + * H5TBwrite_fields_index + * H5TBinsert_field + * H5TBdelete_field + * H5TBget_table_info + * H5TBget_field_info + * + *------------------------------------------------------------------------- + */ + +#define TITLE "Title" +#define NFIELDS 5 +#define NRECORDS 8 +#define NRECORDS_ADD 3 /*------------------------------------------------------------------------- -* structure used for all tests, a particle with properties -*------------------------------------------------------------------------- -*/ -typedef struct particle_t -{ + * structure used for all tests, a particle with properties + *------------------------------------------------------------------------- + */ +typedef struct particle_t { char name[16]; long longi; float pressure; @@ -65,31 +63,28 @@ typedef struct particle_t } particle_t; /*------------------------------------------------------------------------- -* a subset of particle_t, with latitude and longitude fields -*------------------------------------------------------------------------- -*/ -typedef struct position_t -{ - long longi; - int lati; + * a subset of particle_t, with latitude and longitude fields + *------------------------------------------------------------------------- + */ +typedef struct position_t { + long longi; + int lati; } position_t; /*------------------------------------------------------------------------- -* a subset of particle_t, with name and pressure fields -*------------------------------------------------------------------------- -*/ -typedef struct namepressure_t -{ - char name[16]; - float pressure; + * a subset of particle_t, with name and pressure fields + *------------------------------------------------------------------------- + */ +typedef struct namepressure_t { + char name[16]; + float pressure; } namepressure_t; /*------------------------------------------------------------------------- -* an extended particle, used in the insert field test -*------------------------------------------------------------------------- -*/ -typedef struct particle2_t -{ + * an extended particle, used in the insert field test + *------------------------------------------------------------------------- + */ +typedef struct particle2_t { char name[16]; long longi; float pressure; @@ -99,11 +94,10 @@ typedef struct particle2_t } particle2_t; /*------------------------------------------------------------------------- -* a particle with one field less, used in the delete field test -*------------------------------------------------------------------------- -*/ -typedef struct particle3_t -{ + * a particle with one field less, used in the delete field test + *------------------------------------------------------------------------- + */ +typedef struct particle3_t { char name[16]; long longi; double temperature; @@ -118,35 +112,34 @@ typedef struct particle3_t /* Push current alignment rule forcing 4-byte alignment boundary * to the internal stack ... */ -#pragma pack(push,4) - typedef struct particle4_t { - uint32_t state; - double posx; - double posy; - float atx[3]; - float aty[3]; - float rro[2]; - } particle4_t; +#pragma pack(push, 4) +typedef struct particle4_t { + uint32_t state; + double posx; + double posy; + float atx[3]; + float aty[3]; + float rro[2]; +} particle4_t; /* * ... and restore original alignment rules from stack */ #pragma pack(pop) - /*------------------------------------------------------------------------- -* function to open an HDF5 file and return its file identifier -*------------------------------------------------------------------------- -*/ -static hid_t h5file_open(const char *fname, unsigned flags) + * function to open an HDF5 file and return its file identifier + *------------------------------------------------------------------------- + */ +static hid_t +h5file_open(const char *fname, unsigned flags) { - hid_t fid; /* identifier for the file */ + hid_t fid; /* identifier for the file */ const char *data_file = H5_get_srcdir_filename(fname); /* open */ - if ((fid = H5Fopen(data_file,flags,H5P_DEFAULT))<0) - { - HDfprintf(stderr,"Error: Cannot open file <%s>\n",data_file ); + if ((fid = H5Fopen(data_file, flags, H5P_DEFAULT)) < 0) { + HDfprintf(stderr, "Error: Cannot open file <%s>\n", data_file); HDexit(1); } @@ -154,74 +147,68 @@ static hid_t h5file_open(const char *fname, unsigned flags) } /*------------------------------------------------------------------------- -* function that compares one particle -*------------------------------------------------------------------------- -*/ -static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ) + * function that compares one particle + *------------------------------------------------------------------------- + */ +static int +cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf) { - if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) || - rbuf[i].lati != wbuf[j].lati || - rbuf[i].longi != wbuf[j].longi || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) || - !H5_DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) - { - HDfprintf(stderr,"read and write buffers have differences\n"); - HDfprintf(stderr,"%s %ld %f %f %d\n", - rbuf[i].name,rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].temperature,rbuf[i].lati); - HDfprintf(stderr,"%s %ld %f %f %d\n", - wbuf[j].name,wbuf[j].longi,(double)wbuf[j].pressure,wbuf[j].temperature,wbuf[j].lati); + if ((HDstrcmp(rbuf[i].name, wbuf[j].name) != 0) || rbuf[i].lati != wbuf[j].lati || + rbuf[i].longi != wbuf[j].longi || !H5_FLT_ABS_EQUAL(rbuf[i].pressure, wbuf[j].pressure) || + !H5_DBL_ABS_EQUAL(rbuf[i].temperature, wbuf[j].temperature)) { + HDfprintf(stderr, "read and write buffers have differences\n"); + HDfprintf(stderr, "%s %ld %f %f %d\n", rbuf[i].name, rbuf[i].longi, (double)rbuf[i].pressure, + rbuf[i].temperature, rbuf[i].lati); + HDfprintf(stderr, "%s %ld %f %f %d\n", wbuf[j].name, wbuf[j].longi, (double)wbuf[j].pressure, + wbuf[j].temperature, wbuf[j].lati); return -1; } return 0; } /*------------------------------------------------------------------------- -* function to compare deleted records -*------------------------------------------------------------------------- -*/ -static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, - particle_t *rbuf, particle_t *wbuf) + * function to compare deleted records + *------------------------------------------------------------------------- + */ +static int +compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, particle_t *rbuf, particle_t *wbuf) { - hsize_t i,j; - for( i=0; i= istart && i < istart + irecords) - { + else if (i >= istart && i < istart + irecords) { j = i - istart; - if (cmp_par(i,j,rbuf,ibuf)<0) + if (cmp_par(i, j, rbuf, ibuf) < 0) goto out; } - else if ( i >= istart + irecords && i < 10 ) - { + else if (i >= istart + irecords && i < 10) { j = i - irecords; - if (cmp_par(i,j,rbuf,wbuf)<0) + if (cmp_par(i, j, rbuf, wbuf) < 0) goto out; } - else - { + else { j = i - 10; - if (cmp_par(i,j,rbuf,abuf)<0) + if (cmp_par(i, j, rbuf, abuf) < 0) goto out; } } @@ -678,198 +597,192 @@ static int test_table(hid_t fid, int do_write) } /*------------------------------------------------------------------------- - * - * Functions tested: - * - * H5TBdelete_record - * H5TBread_records - * - *------------------------------------------------------------------------- - */ - if (do_write) - { + * + * Functions tested: + * + * H5TBdelete_record + * H5TBread_records + * + *------------------------------------------------------------------------- + */ + if (do_write) { HL_TESTING2("deleting records"); /*------------------------------------------------------------------------- - * Create a table - * pos = 0 1 2 3 4 5 6 7 - * data= 0 1 2 3 4 5 6 7 - *------------------------------------------------------------------------- - */ - - for( i=0; i= 2 && i <= 4 ) - { - if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati || - rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) - { - HDfprintf(stderr,"%ld %f %d\n", - rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].lati); - HDfprintf(stderr,"%ld %f %d\n", - position_in[i].longi,(double)pressure_in[i],position_in[i].lati); + for (i = 0; i < NRECORDS; i++) { + if (i >= 2 && i <= 4) { + if (rbuf[i].lati != position_in[i - NRECORDS_ADD + 1].lati || + rbuf[i].longi != position_in[i - NRECORDS_ADD + 1].longi || + !H5_FLT_ABS_EQUAL(rbuf[i].pressure, pressure_in[i - NRECORDS_ADD + 1])) { + HDfprintf(stderr, "%ld %f %d\n", rbuf[i].longi, (double)rbuf[i].pressure, + rbuf[i].lati); + HDfprintf(stderr, "%ld %f %d\n", position_in[i].longi, (double)pressure_in[i], + position_in[i].lati); goto out; } } } } - - PASSED(); } /*write*/ /*------------------------------------------------------------------------- - * - * Functions tested: - * - * H5TBread_fields_name - * - *------------------------------------------------------------------------- - */ + * + * Functions tested: + * + * H5TBread_fields_name + * + *------------------------------------------------------------------------- + */ HL_TESTING2("reading fields by name"); /*------------------------------------------------------------------------- - * write and read the "Pressure" field - *------------------------------------------------------------------------- - */ - if (do_write) - { - if (H5TBmake_table(TITLE,fid,"table10",FIELDS,RECORDS,type_size_mem, - field_names,field_offset,field_type, - chunk_size,fill1,compress,0)<0) + * write and read the "Pressure" field + *------------------------------------------------------------------------- + */ + if (do_write) { + if (H5TBmake_table(TITLE, fid, "table10", FIELDS, RECORDS, type_size_mem, field_names, field_offset, + field_type, chunk_size, fill1, compress, 0) < 0) goto out; /* write the pressure field to all the records */ start = 0; nrecords = NRECORDS; - if ( H5TBwrite_fields_name(fid,"table10","Pressure",start,nrecords, - sizeof( float ),0,field_sizes_pre,pressure_in)<0) + if (H5TBwrite_fields_name(fid, "table10", "Pressure", start, nrecords, sizeof(float), 0, + field_sizes_pre, pressure_in) < 0) goto out; } @@ -1186,170 +1070,149 @@ static int test_table(hid_t fid, int do_write) nrecords = NRECORDS; /* read an invalid field, should fail */ - if ( H5TBread_fields_name(fid,"table10","DoesNotExist",start,nrecords, - sizeof(float),0,field_sizes_pre,pressure_out) >=0) - goto out; + if (H5TBread_fields_name(fid, "table10", "DoesNotExist", start, nrecords, sizeof(float), 0, + field_sizes_pre, pressure_out) >= 0) + goto out; /* read the "Pressure" field */ - if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords, - sizeof(float),0,field_sizes_pre,pressure_out)<0) + if (H5TBread_fields_name(fid, "table10", "Pressure", start, nrecords, sizeof(float), 0, field_sizes_pre, + pressure_out) < 0) goto out; /* Compare the extracted table with the initial values */ - for ( i = 0; i < NRECORDS; i++ ) - { - if ( !H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i]) ) { + for (i = 0; i < NRECORDS; i++) { + if (!H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i])) { goto out; } } /*------------------------------------------------------------------------- - * Write and read the "Latitude,Longitude" fields - *------------------------------------------------------------------------- - */ - if (do_write) - { + * Write and read the "Latitude,Longitude" fields + *------------------------------------------------------------------------- + */ + if (do_write) { /* Write the new longitude and latitude information to all the records */ start = 0; nrecords = NRECORDS_ADD; - if ( H5TBwrite_fields_name(fid,"table10", "Latitude,Longitude", start, nrecords, - sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 ) + if (H5TBwrite_fields_name(fid, "table10", "Latitude,Longitude", start, nrecords, sizeof(position_t), + field_offset_pos, field_sizes_pos, position_in) < 0) goto out; - }/*write*/ + } /*write*/ /* Read the "Latitude,Longitude" fields */ start = 0; nrecords = NRECORDS_ADD; - if ( H5TBread_fields_name( fid, "table10", "Latitude,Longitude", - start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 ) + if (H5TBread_fields_name(fid, "table10", "Latitude,Longitude", start, nrecords, sizeof(position_t), + field_offset_pos, field_sizes_pos, position_out) < 0) goto out; - /* Compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS_ADD; i++ ) - { - if ( position_out[i].lati != position_in[i].lati || - position_out[i].longi != position_in[i].longi ) + for (i = 0; i < NRECORDS_ADD; i++) { + if (position_out[i].lati != position_in[i].lati || position_out[i].longi != position_in[i].longi) goto out; } - /*------------------------------------------------------------------------- - * Write and read the "Name,Pressure" fields - *------------------------------------------------------------------------- - */ - if (do_write) - { + * Write and read the "Name,Pressure" fields + *------------------------------------------------------------------------- + */ + if (do_write) { /* Write the new name and pressure information to all the records */ start = 0; nrecords = NRECORDS; - if ( H5TBwrite_fields_name( fid, "table10", "Name,Pressure", start, nrecords, - sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 ) + if (H5TBwrite_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t), + field_offset_namepre, field_sizes_namepre, namepre_in) < 0) goto out; - }/*write*/ + } /*write*/ /* Read the "Name,Pressure" fields */ start = 0; nrecords = NRECORDS; - if ( H5TBread_fields_name( fid, "table10", "Name,Pressure", - start, nrecords, sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre, - namepre_out ) < 0 ) + if (H5TBread_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t), + field_offset_namepre, field_sizes_namepre, namepre_out) < 0) goto out; - /* Compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) - { - if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { - goto out; + for (i = 0; i < NRECORDS; i++) { + if ((HDstrcmp(namepre_out[i].name, namepre_in[i].name) != 0) || + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[i].pressure)) { + goto out; } } /* reset buffer */ - for( i = 0; i < NRECORDS; i++ ) - { - HDstrcpy( namepre_out[i].name, "\0" ); + for (i = 0; i < NRECORDS; i++) { + HDstrcpy(namepre_out[i].name, "\0"); namepre_out[i].pressure = -1; } /*------------------------------------------------------------------------- - * read only 3 records of the "Name,Pressure" fields, starting at record 2 - *------------------------------------------------------------------------- - */ + * read only 3 records of the "Name,Pressure" fields, starting at record 2 + *------------------------------------------------------------------------- + */ start = 2; nrecords = 3; - if ( H5TBread_fields_name( fid, "table10", "Name,Pressure", - start, nrecords, sizeof(namepressure_t), field_offset_namepre, - field_sizes_namepre, namepre_out ) < 0 ) + if (H5TBread_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t), + field_offset_namepre, field_sizes_namepre, namepre_out) < 0) goto out; - /* Compare the extracted table with the initial values */ - for( i = 0; i < 3; i++ ) - { + for (i = 0; i < 3; i++) { hsize_t iistart = start; - if ( ( HDstrcmp( namepre_out[i].name, namepre_in[iistart+i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart+i].pressure) ) { - goto out; + if ((HDstrcmp(namepre_out[i].name, namepre_in[iistart + i].name) != 0) || + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart + i].pressure)) { + goto out; } } - - PASSED(); /*------------------------------------------------------------------------- - * - * Functions tested: - * - * H5TBwrite_fields_index - * - *------------------------------------------------------------------------- - */ - if (do_write) - { + * + * Functions tested: + * + * H5TBwrite_fields_index + * + *------------------------------------------------------------------------- + */ + if (do_write) { HL_TESTING2("writing fields by index"); /* make an empty table */ - if (H5TBmake_table(TITLE,fid,"table11",FIELDS,RECORDS,type_size_mem, - field_names,field_offset,field_type, - chunk_size,fill,compress,NULL)<0) + if (H5TBmake_table(TITLE, fid, "table11", FIELDS, RECORDS, type_size_mem, field_names, field_offset, + field_type, chunk_size, fill, compress, NULL) < 0) goto out; /* write the pressure field starting at record 2 */ nfields = 1; start = 2; nrecords = NRECORDS_ADD; - if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords, - sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 ) + if (H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords, sizeof(float), + 0, field_sizes_pre, pressure_in) < 0) goto out; - /* write the new longitude and latitude information starting at record 2 */ nfields = 2; start = 2; nrecords = NRECORDS_ADD; - if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords, - sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 ) + if (H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords, + sizeof(position_t), field_offset_pos, field_sizes_pos, position_in) < 0) goto out; /* read back the all table */ nfields = 5; start = 0; nrecords = NRECORDS; - if ( H5TBread_fields_index(fid, "table11", nfields, field_index, - start, nrecords, type_size_mem, field_offset, field_size, rbuf ) < 0 ) + if (H5TBread_fields_index(fid, "table11", nfields, field_index, start, nrecords, type_size_mem, + field_offset, field_size, rbuf) < 0) goto out; /* Compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) - { - if ( i >= 2 && i <= 4 ) - { - if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati || - rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) + for (i = 0; i < NRECORDS; i++) { + if (i >= 2 && i <= 4) { + if (rbuf[i].lati != position_in[i - NRECORDS_ADD + 1].lati || + rbuf[i].longi != position_in[i - NRECORDS_ADD + 1].longi || + !H5_FLT_ABS_EQUAL(rbuf[i].pressure, pressure_in[i - NRECORDS_ADD + 1])) goto out; } } @@ -1357,37 +1220,34 @@ static int test_table(hid_t fid, int do_write) PASSED(); } - /*------------------------------------------------------------------------- - * - * Functions tested: - * - * H5TBread_fields_index - * - *------------------------------------------------------------------------- - */ + * + * Functions tested: + * + * H5TBread_fields_index + * + *------------------------------------------------------------------------- + */ HL_TESTING2("reading fields by index"); - if (do_write) - { + if (do_write) { /* make an empty table */ - if (H5TBmake_table(TITLE,fid,"table12",FIELDS,RECORDS,type_size_mem, - field_names,field_offset,field_type, - chunk_size,fill,compress,NULL)<0) + if (H5TBmake_table(TITLE, fid, "table12", FIELDS, RECORDS, type_size_mem, field_names, field_offset, + field_type, chunk_size, fill, compress, NULL) < 0) goto out; /*------------------------------------------------------------------------- - * write and read the "Pressure" field - *------------------------------------------------------------------------- - */ + * write and read the "Pressure" field + *------------------------------------------------------------------------- + */ /* write the pressure field to all the records */ nfields = 1; start = 0; nrecords = NRECORDS; - if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, - sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 ) + if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, sizeof(float), + 0, field_sizes_pre, pressure_in) < 0) goto out; } @@ -1395,196 +1255,178 @@ static int test_table(hid_t fid, int do_write) nfields = 1; start = 0; nrecords = NRECORDS; - if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pre, - start, nrecords, sizeof(float), 0, field_sizes_pre, pressure_out ) < 0 ) + if (H5TBread_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, sizeof(float), 0, + field_sizes_pre, pressure_out) < 0) goto out; /* compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) - { - if ( !H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i]) ) { + for (i = 0; i < NRECORDS; i++) { + if (!H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i])) { goto out; } } /*------------------------------------------------------------------------- - * write and read the "Latitude,Longitude" fields - *------------------------------------------------------------------------- - */ - if (do_write) - { + * write and read the "Latitude,Longitude" fields + *------------------------------------------------------------------------- + */ + if (do_write) { /* write the new longitude and latitude information to all the records */ - nfields = 2; + nfields = 2; start = 0; nrecords = NRECORDS; - if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords, - sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 ) + if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords, + sizeof(position_t), field_offset_pos, field_sizes_pos, position_in) < 0) goto out; } /*write*/ /* read the "Latitude,Longitude" fields */ - nfields = 2; + nfields = 2; start = 0; nrecords = NRECORDS_ADD; - if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pos, - start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 ) + if (H5TBread_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords, sizeof(position_t), + field_offset_pos, field_sizes_pos, position_out) < 0) goto out; /* compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS_ADD; i++ ) - { - if ( position_out[i].lati != position_in[i].lati || - position_out[i].longi != position_in[i].longi ) { - goto out; + for (i = 0; i < NRECORDS_ADD; i++) { + if (position_out[i].lati != position_in[i].lati || position_out[i].longi != position_in[i].longi) { + goto out; } } /*------------------------------------------------------------------------- - * write and read the "Name,Pressure" fields - *------------------------------------------------------------------------- - */ + * write and read the "Name,Pressure" fields + *------------------------------------------------------------------------- + */ - if (do_write) - { + if (do_write) { /* write the new name and pressure information to all the records */ - nfields = 2; + nfields = 2; start = 0; nrecords = NRECORDS; - if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords, - sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 ) + if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords, + sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre, + namepre_in) < 0) goto out; } /* read the "Name,Pressure" fields */ - nfields = 2; + nfields = 2; start = 0; nrecords = NRECORDS; - if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, - start, nrecords, sizeof(namepressure_t), field_offset_namepre, - field_sizes_namepre, namepre_out ) < 0 ) + if (H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords, + sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre, + namepre_out) < 0) goto out; /* compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) - { - if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { - goto out; - } + for (i = 0; i < NRECORDS; i++) { + if ((HDstrcmp(namepre_out[i].name, namepre_in[i].name) != 0) || + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[i].pressure)) { + goto out; + } } /* reset buffer */ - for( i = 0; i < NRECORDS; i++ ) - { - HDstrcpy( namepre_out[i].name, "\0" ); + for (i = 0; i < NRECORDS; i++) { + HDstrcpy(namepre_out[i].name, "\0"); namepre_out[i].pressure = -1; } /*------------------------------------------------------------------------- - * read only 3 records of the "Name,Pressure" fields, starting at record 2 - *------------------------------------------------------------------------- - */ + * read only 3 records of the "Name,Pressure" fields, starting at record 2 + *------------------------------------------------------------------------- + */ /* write the new name and pressure information to all the records */ nfields = 2; start = 2; nrecords = 3; - if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, - start, nrecords, sizeof(namepressure_t), field_offset_namepre, - field_sizes_namepre, namepre_out ) < 0 ) + if (H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords, + sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre, + namepre_out) < 0) goto out; /* compare the extracted table with the initial values */ - for( i = 0; i < 3; i++ ) - { - int iistart = (int) start; - if ( ( HDstrcmp( namepre_out[i].name, wbuf[iistart+(int)i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart+(int)i].pressure) ) { - goto out; + for (i = 0; i < 3; i++) { + int iistart = (int)start; + if ((HDstrcmp(namepre_out[i].name, wbuf[iistart + (int)i].name) != 0) || + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart + (int)i].pressure)) { + goto out; } } PASSED(); - /*------------------------------------------------------------------------- - * - * Functions tested: - * - * H5TBinsert_field - * - *------------------------------------------------------------------------- - */ + * + * Functions tested: + * + * H5TBinsert_field + * + *------------------------------------------------------------------------- + */ - if (do_write) - { + if (do_write) { HL_TESTING2("inserting fields"); /* make a table */ - if (H5TBmake_table(TITLE,fid,"table13",FIELDS,RECORDS,type_size_mem, - field_names,field_offset,field_type, - chunk_size,fill1,compress,wbuf)<0) + if (H5TBmake_table(TITLE, fid, "table13", FIELDS, RECORDS, type_size_mem, field_names, field_offset, + field_type, chunk_size, fill1, compress, wbuf) < 0) goto out; /* insert the new field at the end of the field list */ position = NFIELDS; - if ( H5TBinsert_field( fid, "table13", "New Field", field_type_new, position, - fill1_new, buf_new ) < 0 ) + if (H5TBinsert_field(fid, "table13", "New Field", field_type_new, position, fill1_new, buf_new) < 0) goto out; /* read the table */ - if ( H5TBread_table( fid, "table13", dst_size2, dst_offset2, dst_sizes2, rbuf2 ) < 0 ) + if (H5TBread_table(fid, "table13", dst_size2, dst_offset2, dst_sizes2, rbuf2) < 0) goto out; /* compare the extracted table with the original array */ - for( i = 0; i < NRECORDS; i++ ) - { - if ( ( HDstrcmp( rbuf2[i].name, wbuf[i].name ) != 0 ) || - rbuf2[i].lati != wbuf[i].lati || - rbuf2[i].longi != wbuf[i].longi || - !H5_FLT_ABS_EQUAL(rbuf2[i].pressure,wbuf[i].pressure) || - !H5_DBL_ABS_EQUAL(rbuf2[i].temperature,wbuf[i].temperature) || - rbuf2[i].new_field != buf_new[i] ) { - goto out; + for (i = 0; i < NRECORDS; i++) { + if ((HDstrcmp(rbuf2[i].name, wbuf[i].name) != 0) || rbuf2[i].lati != wbuf[i].lati || + rbuf2[i].longi != wbuf[i].longi || !H5_FLT_ABS_EQUAL(rbuf2[i].pressure, wbuf[i].pressure) || + !H5_DBL_ABS_EQUAL(rbuf2[i].temperature, wbuf[i].temperature) || + rbuf2[i].new_field != buf_new[i]) { + goto out; } } PASSED(); } /*------------------------------------------------------------------------- - * - * Functions tested: - * - * H5TBdelete_field - * - *------------------------------------------------------------------------- - */ - if (do_write) - { + * + * Functions tested: + * + * H5TBdelete_field + * + *------------------------------------------------------------------------- + */ + if (do_write) { HL_TESTING2("deleting fields"); /* make a table */ - if (H5TBmake_table(TITLE,fid,"table14",FIELDS,RECORDS,type_size_mem, - field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + if (H5TBmake_table(TITLE, fid, "table14", FIELDS, RECORDS, type_size_mem, field_names, field_offset, + field_type, chunk_size, fill, compress, wbuf) < 0) goto out; /* delete the field */ - if ( H5TBdelete_field(fid, "table14", "Pressure" ) < 0 ) + if (H5TBdelete_field(fid, "table14", "Pressure") < 0) goto out; /* read the table */ - if ( H5TBread_table(fid, "table14", dst_size3, dst_offset3, dst_sizes3, rbuf3 ) < 0 ) + if (H5TBread_table(fid, "table14", dst_size3, dst_offset3, dst_sizes3, rbuf3) < 0) goto out; /* compare the extracted table with the original array */ - for( i = 0; i < NRECORDS; i++ ) - { - if ( ( HDstrcmp( rbuf3[i].name, wbuf[i].name ) != 0 ) || - rbuf3[i].lati != wbuf[i].lati || + for (i = 0; i < NRECORDS; i++) { + if ((HDstrcmp(rbuf3[i].name, wbuf[i].name) != 0) || rbuf3[i].lati != wbuf[i].lati || rbuf3[i].longi != wbuf[i].longi || - !H5_DBL_ABS_EQUAL(rbuf3[i].temperature,wbuf[i].temperature) ) { - goto out; + !H5_DBL_ABS_EQUAL(rbuf3[i].temperature, wbuf[i].temperature)) { + goto out; } } @@ -1592,143 +1434,140 @@ static int test_table(hid_t fid, int do_write) } /*------------------------------------------------------------------------- - * - * Functions tested: - * - * H5TBget_table_info - * H5TBget_field_info - * - *------------------------------------------------------------------------- - */ + * + * Functions tested: + * + * H5TBget_table_info + * H5TBget_field_info + * + *------------------------------------------------------------------------- + */ HL_TESTING2("getting table info"); /* get table info */ - if ( H5TBget_table_info (fid, "table1", &rfields, &rrecords ) < 0 ) + if (H5TBget_table_info(fid, "table1", &rfields, &rrecords) < 0) goto out; - if ( NFIELDS != rfields || rrecords != NRECORDS ) { + if (NFIELDS != rfields || rrecords != NRECORDS) { goto out; } PASSED(); /*------------------------------------------------------------------------- - * - * Functions tested: - * - * H5TBget_field_info - * - *------------------------------------------------------------------------- - */ + * + * Functions tested: + * + * H5TBget_field_info + * + *------------------------------------------------------------------------- + */ HL_TESTING2("getting field info"); /* alocate */ - names_out = (char**) HDmalloc( sizeof(char*) * (size_t)NFIELDS ); - for ( i = 0; i < NFIELDS; i++) - { - names_out[i] = (char*) HDmalloc( sizeof(char) * 255 ); + names_out = (char **)HDmalloc(sizeof(char *) * (size_t)NFIELDS); + for (i = 0; i < NFIELDS; i++) { + names_out[i] = (char *)HDmalloc(sizeof(char) * 255); } /* Get field info */ - if ( H5TBget_field_info(fid, "table1", names_out, sizes_out, offset_out, &size_out ) < 0 ) + if (H5TBget_field_info(fid, "table1", names_out, sizes_out, offset_out, &size_out) < 0) goto out; - for ( i = 0; i < NFIELDS; i++) - { - if ( (HDstrcmp( field_names[i], names_out[i] ) != 0)) { + for (i = 0; i < NFIELDS; i++) { + if ((HDstrcmp(field_names[i], names_out[i]) != 0)) { goto out; } } /* release */ - for ( i = 0; i < NFIELDS; i++) - { - HDfree ( names_out[i] ); + for (i = 0; i < NFIELDS; i++) { + HDfree(names_out[i]); } - HDfree ( names_out ); + HDfree(names_out); PASSED(); /*------------------------------------------------------------------------- - * end - *------------------------------------------------------------------------- - */ + * end + *------------------------------------------------------------------------- + */ return 0; out: H5_FAILED(); return -1; } - /*------------------------------------------------------------------------- -* the main program -*------------------------------------------------------------------------- -*/ + * the main program + *------------------------------------------------------------------------- + */ -int main(void) +int +main(void) { - hid_t fid; /* identifier for the file */ - unsigned flags=H5F_ACC_RDONLY; + hid_t fid; /* identifier for the file */ + unsigned flags = H5F_ACC_RDONLY; /*------------------------------------------------------------------------- - * test1: create a file for the write/read test - *------------------------------------------------------------------------- - */ + * test1: create a file for the write/read test + *------------------------------------------------------------------------- + */ /* create a file using default properties */ - fid=H5Fcreate("test_table.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); + fid = H5Fcreate("test_table.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); HDputs("Testing table with file creation mode (read/write in native architecture):"); /* test, do write */ - if (test_table(fid,1)<0) + if (test_table(fid, 1) < 0) goto out; /* close */ H5Fclose(fid); /*------------------------------------------------------------------------- - * test2: open a file written in test1 on a big-endian machine - *------------------------------------------------------------------------- - */ + * test2: open a file written in test1 on a big-endian machine + *------------------------------------------------------------------------- + */ HDputs("Testing table with file open mode (read big-endian data):"); - fid=h5file_open(TEST_FILE_BE,flags); + fid = h5file_open(TEST_FILE_BE, flags); /* test, do not write */ - if (test_table(fid,0)<0) + if (test_table(fid, 0) < 0) goto out; /* close */ H5Fclose(fid); /*------------------------------------------------------------------------- - * test3: open a file written in test1 on a little-endian machine - *------------------------------------------------------------------------- - */ + * test3: open a file written in test1 on a little-endian machine + *------------------------------------------------------------------------- + */ HDputs("Testing table with file open mode (read little-endian data):"); - fid=h5file_open(TEST_FILE_LE,flags); + fid = h5file_open(TEST_FILE_LE, flags); /* test, do not write */ - if (test_table(fid,0)<0) + if (test_table(fid, 0) < 0) goto out; /* close */ H5Fclose(fid); /*------------------------------------------------------------------------- - * test4: open a file written in test1 on the Cray T3 machine - *------------------------------------------------------------------------- - */ + * test4: open a file written in test1 on the Cray T3 machine + *------------------------------------------------------------------------- + */ HDputs("Testing table with file open mode (read Cray data):"); - fid=h5file_open(TEST_FILE_CRAY,flags); + fid = h5file_open(TEST_FILE_CRAY, flags); /* test, do not write */ - if (test_table(fid,0)<0) + if (test_table(fid, 0) < 0) goto out; /* close */ @@ -1739,5 +1578,3 @@ out: H5Fclose(fid); return 1; } - - diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 129fa60..710d29f 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -15,45 +15,43 @@ #include "gif.h" -GIFWORD iWIDE, iHIGH, eWIDE, eHIGH, expand, numcols, strip, nostrip; -unsigned long cols[256]; -char *cmd; +GIFWORD iWIDE, iHIGH, eWIDE, eHIGH, expand, numcols, strip, nostrip; +unsigned long cols[256]; +char * cmd; FILE *fp; -static GIFWORD - XC = 0, YC = 0, /* Output X and Y coords of current pixel */ - InitCodeSize, /* Starting code size, used during Clear */ - CodeSize, /* Code size, read from GIF header */ - BytesPerScanline, /* Bytes per scanline in output raster */ - IWidth, IHeight; /* image dimensions */ -static int - BitOffset = 0, /* Bit Offset of next code */ - Pass = 0, /* Used by output routine if GIFWORDerlaced pic */ - OutCount = 0, /* Decompressor output 'stack count' */ - Code, /* Value returned by ReadCode */ - MaxCode, /* limiting value for current code size */ - ClearCode, /* GIF clear code */ - EOFCode, /* GIF end-of-information code */ - CurCode, OldCode, InCode, /* Decompressor variables */ - FirstFree, /* First free code, generated per GIF spec */ - FreeCode, /* Decompressor, next free slot in hash table */ - FinChar, /* Decompressor variable */ - DataMask, /* AND mask for data size */ - ReadMask; /* Code AND mask for current code size */ +static GIFWORD XC = 0, YC = 0, /* Output X and Y coords of current pixel */ + InitCodeSize, /* Starting code size, used during Clear */ + CodeSize, /* Code size, read from GIF header */ + BytesPerScanline, /* Bytes per scanline in output raster */ + IWidth, IHeight; /* image dimensions */ +static int BitOffset = 0, /* Bit Offset of next code */ + Pass = 0, /* Used by output routine if GIFWORDerlaced pic */ + OutCount = 0, /* Decompressor output 'stack count' */ + Code, /* Value returned by ReadCode */ + MaxCode, /* limiting value for current code size */ + ClearCode, /* GIF clear code */ + EOFCode, /* GIF end-of-information code */ + CurCode, OldCode, InCode, /* Decompressor variables */ + FirstFree, /* First free code, generated per GIF spec */ + FreeCode, /* Decompressor, next free slot in hash table */ + FinChar, /* Decompressor variable */ + DataMask, /* AND mask for data size */ + ReadMask; /* Code AND mask for current code size */ /*MODIFICATIONS*/ -GIFBYTE tempbyte[10]; -GIFBYTE * tempGIFBYTEptr[10]; -GIFWORD tempint[10]; -GIFWORD ImageCount = 0; +GIFBYTE tempbyte[10]; +GIFBYTE *tempGIFBYTEptr[10]; +GIFWORD tempint[10]; +GIFWORD ImageCount = 0; /*END MODIFICATION*/ boolean Interlace, HasColormap; -GIFBYTE *Image; /* The result array */ -GIFBYTE *RawGIF; /* The heap array to hold it, raw */ -GIFBYTE *Raster; /* The raster data stream, unblocked */ +GIFBYTE *Image; /* The result array */ +GIFBYTE *RawGIF; /* The heap array to hold it, raw */ +GIFBYTE *Raster; /* The raster data stream, unblocked */ /* The hash table used by the decompressor */ @@ -66,7 +64,7 @@ int *OutCode; /* The color map, read from the GIF header */ -int numused; +int numused; /* * Fetch the next code from the raster data stream. The codes can be any @@ -82,7 +80,7 @@ ReadCode(void) int RawCode, ByteOffset; ByteOffset = BitOffset / 8; - RawCode = Raster[ByteOffset] + (0x100 * Raster[ByteOffset + 1]); + RawCode = Raster[ByteOffset] + (0x100 * Raster[ByteOffset + 1]); if (CodeSize >= 8) RawCode += (0x10000 * Raster[ByteOffset + 2]); @@ -95,10 +93,8 @@ ReadCode(void) static void AddToPixel(GIFBYTE Index) { - if (YC= IHeight) { - Pass++; - YC = 4; - } - - break; - case 1: - YC += 8; - - if (YC >= IHeight) { - Pass++; - YC = 2; - } - - break; - case 2: - YC += 4; - - if (YC >= IHeight) { - Pass++; - YC = 1; - } - - break; - case 3: - YC += 2; - break; - default: - break; + case 0: + YC += 8; + + if (YC >= IHeight) { + Pass++; + YC = 4; + } + + break; + case 1: + YC += 8; + + if (YC >= IHeight) { + Pass++; + YC = 2; + } + + break; + case 2: + YC += 4; + + if (YC >= IHeight) { + Pass++; + YC = 1; + } + + break; + case 3: + YC += 2; + break; + default: + break; } } } @@ -172,20 +169,20 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) exit(EXIT_FAILURE); } - XC = 0; - YC = 0; - Pass = 0; - OutCount = 0; + XC = 0; + YC = 0; + Pass = 0; + OutCount = 0; BitOffset = 0; - DataMask = (1 << ((GifHead->PackedField & 0x07) +1)) -1; - Raster = GifImageDesc->GIFImage; + DataMask = (1 << ((GifHead->PackedField & 0x07) + 1)) - 1; + Raster = GifImageDesc->GIFImage; /* Check for image seperator */ /* Now read in values from the image descriptor */ - IWidth = GifImageDesc->ImageWidth; - IHeight = GifImageDesc->ImageHeight; + IWidth = GifImageDesc->ImageWidth; + IHeight = GifImageDesc->ImageHeight; Interlace = (uint8_t)(GifImageDesc->PackedField & 0x40); /* @@ -200,9 +197,9 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) * compute decompressor constant values, based on this code size. */ - CodeSize = GifImageDesc->CodeSize; + CodeSize = GifImageDesc->CodeSize; ClearCode = (1 << CodeSize); - EOFCode = ClearCode + 1; + EOFCode = ClearCode + 1; FreeCode = FirstFree = ClearCode + 2; /* @@ -214,8 +211,8 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) CodeSize++; InitCodeSize = CodeSize; - MaxCode = (1 << CodeSize); - ReadMask = MaxCode - 1; + MaxCode = (1 << CodeSize); + ReadMask = MaxCode - 1; /* * Read the raster data. Here we just transpose it from the GIF array to @@ -225,7 +222,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) /* Allocate the Image */ - if (!(Image = (GIFBYTE *)malloc((size_t)IWidth*(size_t)IHeight))) { + if (!(Image = (GIFBYTE *)malloc((size_t)IWidth * (size_t)IHeight))) { printf("Out of memory"); exit(EXIT_FAILURE); } @@ -246,13 +243,14 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) */ if (Code == ClearCode) { CodeSize = InitCodeSize; - MaxCode = (1 << CodeSize); + MaxCode = (1 << CodeSize); ReadMask = MaxCode - 1; FreeCode = FirstFree; CurCode = OldCode = Code = ReadCode(); - FinChar = CurCode & DataMask; + FinChar = CurCode & DataMask; AddToPixel((GIFBYTE)FinChar); - } else { + } + else { /* * If not a clear code, then must be data: save same as CurCode * and InCode @@ -264,7 +262,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) * repeat the last character decoded */ if (CurCode >= FreeCode) { - CurCode = OldCode; + CurCode = OldCode; OutCode[OutCount++] = FinChar; } @@ -279,11 +277,11 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) } OutCode[OutCount++] = Suffix[CurCode]; - CurCode = Prefix[CurCode]; + CurCode = Prefix[CurCode]; } /* The last code in the chain is treated as raw data. */ - FinChar = CurCode & DataMask; + FinChar = CurCode & DataMask; OutCode[OutCount++] = FinChar; /* @@ -301,7 +299,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) */ Prefix[FreeCode] = OldCode; Suffix[FreeCode] = FinChar; - OldCode = InCode; + OldCode = InCode; /* * Point to the next slot in the table. If we exceed the current diff --git a/hl/tools/gif2h5/gif.h b/hl/tools/gif2h5/gif.h index 0c0f963..cb54b9b 100644 --- a/hl/tools/gif2h5/gif.h +++ b/hl/tools/gif2h5/gif.h @@ -16,7 +16,7 @@ * Purpose: GIF Header file */ #ifndef GIF_H_ -#define GIF_H_ 1 +#define GIF_H_ 1 #include #include @@ -39,10 +39,10 @@ typedef unsigned char boolean; #endif #ifndef false -#define false 0 +#define false 0 #endif #ifndef true -#define true 1 +#define true 1 #endif /* Set the EndianOrder. @@ -50,7 +50,7 @@ typedef unsigned char boolean; ** Set EndianOrder = 0 if machine is little endian ** EndianOrder = 1 if machine is big endian. */ -extern int EndianOrder; +extern int EndianOrder; /* ** The GIF header format. @@ -59,31 +59,30 @@ extern int EndianOrder; ** descriptor, and the global color table for the GIF image. */ typedef struct _GifHeader { /* Offset Description */ - GIFBYTE PackedField; /* 0Ah Color Information */ + GIFBYTE PackedField; /* 0Ah Color Information */ GIFWORD TableSize; - GIFBYTE ImageCount; /* Keep a count of the number of images */ + GIFBYTE ImageCount; /* Keep a count of the number of images */ GIFBYTE CommentCount; GIFBYTE ApplicationCount; GIFBYTE PlainTextCount; GIFBYTE HDFPalette[256][3]; - GIFBYTE HeaderDump[6]; /* GIFBYTE array to dump header contents */ - GIFBYTE LSDDump[7]; /* Logical Screen Descriptor dump */ + GIFBYTE HeaderDump[6]; /* GIFBYTE array to dump header contents */ + GIFBYTE LSDDump[7]; /* Logical Screen Descriptor dump */ } GIFHEAD; - /* ** The GIF Image Descriptor. */ typedef struct _GifImageDescriptor { - GIFWORD ImageWidth; /* Width of the image in pixels */ - GIFWORD ImageHeight; /* Height of the image in pixels */ - GIFBYTE PackedField; /* Image and Color Table Data Information */ + GIFWORD ImageWidth; /* Width of the image in pixels */ + GIFWORD ImageHeight; /* Height of the image in pixels */ + GIFBYTE PackedField; /* Image and Color Table Data Information */ GIFWORD TableSize; - GIFWORD CodeSize; /* Minimum LZW CodeSize for image data */ + GIFWORD CodeSize; /* Minimum LZW CodeSize for image data */ GIFBYTE HDFPalette[256][3]; - GIFBYTE GIDDump[9]; /* GifImageDescriptor dump */ + GIFBYTE GIDDump[9]; /* GifImageDescriptor dump */ - GIFBYTE *Image; /* Decompressed Raster Image */ + GIFBYTE *Image; /* Decompressed Raster Image */ GIFBYTE *GIFImage; } GIFIMAGEDESC; @@ -91,36 +90,35 @@ typedef struct _GifImageDescriptor { ** GIF 89a Graphic Control Extension Block */ typedef struct _GifGraphicControlExtension { - GIFBYTE GCEDump[5]; /* Graphic Control Extension Dump */ + GIFBYTE GCEDump[5]; /* Graphic Control Extension Dump */ } GIFGRAPHICCONTROL; /* ** GIF 89a Plain Text Extension Block */ typedef struct _GifPlainTextExtension { - GIFBYTE PTEDump[15]; /* Plain Text Extension Dump */ - GIFBYTE *PlainTextData; /* Plain Text data sub-blocks */ - GIFWORD DataSize; + GIFBYTE PTEDump[15]; /* Plain Text Extension Dump */ + GIFBYTE *PlainTextData; /* Plain Text data sub-blocks */ + GIFWORD DataSize; } GIFPLAINTEXT; - /* ** GIF 89a Application Extension Block */ typedef struct _GifApplicationExtension { - GIFBYTE AEDump[14]; /* Application Extension Dump */ - GIFBYTE *ApplicationData; /* Application data sub-blocks */ - GIFWORD DataSize; + GIFBYTE AEDump[14]; /* Application Extension Dump */ + GIFBYTE *ApplicationData; /* Application data sub-blocks */ + GIFWORD DataSize; } GIFAPPLICATION; /* ** GIF 89a Comment Extension Block */ typedef struct _GifCommentExtension { - GIFBYTE CEDump[2]; /* Comment Extension Dump */ - GIFBYTE *CommentData; /* Comment data sub-blocks */ - GIFWORD DataSize; - GIFBYTE Terminator; /* Block Terminator (always 0) */ + GIFBYTE CEDump[2]; /* Comment Extension Dump */ + GIFBYTE *CommentData; /* Comment data sub-blocks */ + GIFWORD DataSize; + GIFBYTE Terminator; /* Block Terminator (always 0) */ } GIFCOMMENT; /* @@ -135,12 +133,12 @@ typedef struct _GifCommentExtension { ** extension. */ typedef struct _GifToMem { - GIFHEAD *GifHeader; - GIFIMAGEDESC **GifImageDesc; + GIFHEAD * GifHeader; + GIFIMAGEDESC ** GifImageDesc; GIFGRAPHICCONTROL **GifGraphicControlExtension; - GIFPLAINTEXT **GifPlainTextExtension; - GIFAPPLICATION **GifApplicationExtension; - GIFCOMMENT **GifCommentExtension; + GIFPLAINTEXT ** GifPlainTextExtension; + GIFAPPLICATION ** GifApplicationExtension; + GIFCOMMENT ** GifCommentExtension; } GIFTOMEM; /* @@ -159,12 +157,11 @@ int ReadGifApplication(GIFAPPLICATION *, GIFBYTE **); int ReadGifComment(GIFCOMMENT *, GIFBYTE **); /* HDFGIFWR.C */ -int hdfWriteGIF(FILE *fp, GIFBYTE *pic, int ptype, int w, int h, GIFBYTE *rmap, - GIFBYTE *gmap, GIFBYTE *bmap, GIFBYTE *pc2ncmap, int numcols, - int colorstyle, int BitsPerPixel); +int hdfWriteGIF(FILE *fp, GIFBYTE *pic, int ptype, int w, int h, GIFBYTE *rmap, GIFBYTE *gmap, GIFBYTE *bmap, + GIFBYTE *pc2ncmap, int numcols, int colorstyle, int BitsPerPixel); /* WRITEHDF.C */ -int WriteHDF(GIFTOMEM , GIFCHAR * ); +int WriteHDF(GIFTOMEM, GIFCHAR *); /* Function: ReadHDF ** Return: 0 on completion without error, -1 on error @@ -175,13 +172,13 @@ int WriteHDF(GIFTOMEM , GIFCHAR * ); ** GIFBYTE palette[256][3] - the corresponding palette ** hsize_t* image_size - the size of each dimension of the image */ -int ReadHDF(GIFBYTE** data, GIFBYTE palette[256][3], hsize_t *image_size, - GIFCHAR *h5_file, GIFCHAR *dset_name, GIFCHAR *pal_name); +int ReadHDF(GIFBYTE **data, GIFBYTE palette[256][3], hsize_t *image_size, GIFCHAR *h5_file, + GIFCHAR *dset_name, GIFCHAR *pal_name); GIFBYTE *Decompress(GIFIMAGEDESC *, GIFHEAD *); -GIFBYTE GetByte(GIFBYTE *); -GIFWORD GetWord(GIFBYTE *); +GIFBYTE GetByte(GIFBYTE *); +GIFWORD GetWord(GIFBYTE *); -void cleanup(GIFBYTE*); +void cleanup(GIFBYTE *); -#endif /* GIF_H_ */ +#endif /* GIF_H_ */ diff --git a/hl/tools/gif2h5/gif2hdf.c b/hl/tools/gif2h5/gif2hdf.c index 051ff56..939844c 100644 --- a/hl/tools/gif2h5/gif2hdf.c +++ b/hl/tools/gif2h5/gif2hdf.c @@ -18,11 +18,10 @@ #include "h5tools.h" #include "h5tools_utils.h" - int -main(int argv , char *argc[]) +main(int argv, char *argc[]) { - GIFTOMEM GifMemoryStruct; + GIFTOMEM GifMemoryStruct; GIFIMAGEDESC gifImageDesc; FILE *fpGif; @@ -51,11 +50,9 @@ main(int argv , char *argc[]) /* Initialize h5tools lib */ h5tools_init(); - if ( argc[1] && (strcmp("-V",argc[1])==0) ) - { + if (argc[1] && (strcmp("-V", argc[1]) == 0)) { print_version("gif2h5"); exit(EXIT_SUCCESS); - } if (argv < 3) { @@ -68,15 +65,15 @@ main(int argv , char *argc[]) GIFFileName = argc[1]; HDFFileName = argc[2]; - if (!(fpGif = fopen(GIFFileName,"rb"))) { + if (!(fpGif = fopen(GIFFileName, "rb"))) { printf("Unable to open GIF file for reading.\n"); exit(EXIT_FAILURE); } /* Get the whole file into memory. Mem's much faster than I/O */ - fseek(fpGif, 0L , 2); + fseek(fpGif, 0L, 2); filesize = ftell(fpGif); - fseek(fpGif, 0L , 0); + fseek(fpGif, 0L, 0); if (filesize == 0) printf("File Size Zero"); @@ -86,12 +83,12 @@ main(int argv , char *argc[]) exit(EXIT_FAILURE); } - if (fread(MemGif,(size_t)filesize,1,fpGif) != 1) { + if (fread(MemGif, (size_t)filesize, 1, fpGif) != 1) { printf("Corrupted Input File"); exit(EXIT_FAILURE); } - fseek(fpGif,0L,0); + fseek(fpGif, 0L, 0); /* * Call Gif2Mem and break the whole file into parts. Gif2Mem also calls @@ -100,8 +97,8 @@ main(int argv , char *argc[]) Gif2Mem(MemGif, &GifMemoryStruct); if (ferror(fpGif)) { - printf("File Stream Error\n\n"); - exit(EXIT_FAILURE); + printf("File Stream Error\n\n"); + exit(EXIT_FAILURE); } fclose(fpGif); @@ -110,54 +107,47 @@ main(int argv , char *argc[]) * Call WriteHDF from here. Go ahead and change WriteHDF to write whatever * format you want */ - if (WriteHDF(GifMemoryStruct , HDFFileName)) + if (WriteHDF(GifMemoryStruct, HDFFileName)) printf("HDF Write Error\n\n"); /* Free all buffers */ /* replacing int32 with long */ ImageCount = (long)((GifMemoryStruct.GifHeader)->ImageCount); - for(i = 0; i < ImageCount ; i++) { + for (i = 0; i < ImageCount; i++) { gifImageDesc = *(GifMemoryStruct.GifImageDesc[i]); if (gifImageDesc.Image != NULL) free(gifImageDesc.Image); - if (GifMemoryStruct.GifImageDesc[i] != NULL) - { + if (GifMemoryStruct.GifImageDesc[i] != NULL) { free(GifMemoryStruct.GifImageDesc[i]); GifMemoryStruct.GifImageDesc[i] = NULL; } - if (GifMemoryStruct.GifGraphicControlExtension[i] != NULL) - { + if (GifMemoryStruct.GifGraphicControlExtension[i] != NULL) { free(GifMemoryStruct.GifGraphicControlExtension[i]); GifMemoryStruct.GifGraphicControlExtension[i] = NULL; } } free(StartPos); - if (GifMemoryStruct.GifHeader != NULL) - { + if (GifMemoryStruct.GifHeader != NULL) { free(GifMemoryStruct.GifHeader); GifMemoryStruct.GifHeader = NULL; } - if (GifMemoryStruct.GifApplicationExtension != NULL) - { + if (GifMemoryStruct.GifApplicationExtension != NULL) { free(GifMemoryStruct.GifApplicationExtension); GifMemoryStruct.GifApplicationExtension = NULL; } - if (GifMemoryStruct.GifImageDesc != NULL) - { + if (GifMemoryStruct.GifImageDesc != NULL) { free(GifMemoryStruct.GifImageDesc); GifMemoryStruct.GifImageDesc = NULL; } - if (GifMemoryStruct.GifGraphicControlExtension != NULL) - { + if (GifMemoryStruct.GifGraphicControlExtension != NULL) { free(GifMemoryStruct.GifGraphicControlExtension); GifMemoryStruct.GifGraphicControlExtension = NULL; } - return EXIT_SUCCESS; } diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c index ae0a113..b1ea718 100644 --- a/hl/tools/gif2h5/gif2mem.c +++ b/hl/tools/gif2h5/gif2mem.c @@ -42,29 +42,29 @@ Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) * The gif structure outline for passing data to memory is given in gif.h. * These pointers are redunant, should take them out in ver. 2 */ - GIFHEAD *gifHead; /* GIF Header structure */ - GIFIMAGEDESC **gifImageDesc; /* Logical Image Descriptor struct */ - GIFPLAINTEXT **gifPlainText; /* Plain Text Extension structure */ - GIFAPPLICATION **gifApplication; /* Application Extension structure */ - GIFCOMMENT **gifComment; /* Comment Extension structure */ + GIFHEAD * gifHead; /* GIF Header structure */ + GIFIMAGEDESC ** gifImageDesc; /* Logical Image Descriptor struct */ + GIFPLAINTEXT ** gifPlainText; /* Plain Text Extension structure */ + GIFAPPLICATION ** gifApplication; /* Application Extension structure */ + GIFCOMMENT ** gifComment; /* Comment Extension structure */ GIFGRAPHICCONTROL **gifGraphicControl; /* Graphic Control Extension strct */ - register GIFWORD i; /* Loop counter */ - GIFBYTE Identifier; /* Extension block identifier holder */ - GIFBYTE Label; /* Extension block label holder */ - GIFBYTE ImageCount; /* Count of the number of images in the file */ - GIFBYTE ImageArray; /* Keep the size of the array to store Images */ - GIFBYTE CommentCount; - GIFBYTE CommentArray; - GIFBYTE ApplicationCount; - GIFBYTE ApplicationArray; - GIFBYTE PlainTextCount; - GIFBYTE PlainTextArray; - GIFBYTE GCEflag; - GIFBYTE aTemp; - GIFBYTE j; - GIFBYTE w; /* Two more variables needed only while testing */ - GIFBYTE *b; /* Endian Ordering */ + register GIFWORD i; /* Loop counter */ + GIFBYTE Identifier; /* Extension block identifier holder */ + GIFBYTE Label; /* Extension block label holder */ + GIFBYTE ImageCount; /* Count of the number of images in the file */ + GIFBYTE ImageArray; /* Keep the size of the array to store Images */ + GIFBYTE CommentCount; + GIFBYTE CommentArray; + GIFBYTE ApplicationCount; + GIFBYTE ApplicationArray; + GIFBYTE PlainTextCount; + GIFBYTE PlainTextArray; + GIFBYTE GCEflag; + GIFBYTE aTemp; + GIFBYTE j; + GIFBYTE w; /* Two more variables needed only while testing */ + GIFBYTE * b; /* Endian Ordering */ /* Allocate memory for the GIF structures */ /* Plug the structs into GifMemoryStruct at the end */ @@ -89,8 +89,8 @@ Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) /******************************/ /* Carry out Endian Testing and set Endian Order */ - w = 0x0001; - b = (GIFBYTE *) &w; + w = 0x0001; + b = (GIFBYTE *)&w; EndianOrder = (b[0] ? 1 : 0); /* Read the GIF image file header information */ @@ -103,22 +103,22 @@ Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) fputs("GIFHEAD: Error reading header information!\n", stderr); exit(EXIT_FAILURE); } -#endif /* 0 */ +#endif /* 0 */ /* * Identify, read, and display block information. */ - ImageCount = ImageArray = 0; - CommentCount = CommentArray = 0; + ImageCount = ImageArray = 0; + CommentCount = CommentArray = 0; ApplicationCount = ApplicationArray = 0; - PlainTextCount = PlainTextArray = 0; - GCEflag = 0; + PlainTextCount = PlainTextArray = 0; + GCEflag = 0; for (;;) { Identifier = *MemGif++; switch (Identifier) { - case 0x3B: /* Trailer */ + case 0x3B: /* Trailer */ /* * The counts are stored to make it easier while putting stuff * into the HDF file and then deallocating space. @@ -129,17 +129,17 @@ Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) gifHead->PlainTextCount = PlainTextCount; /* putting stuff into the gif2mem structure */ - GifMemoryStruct->GifHeader = gifHead; - GifMemoryStruct->GifImageDesc = gifImageDesc; - GifMemoryStruct->GifPlainTextExtension = gifPlainText; - GifMemoryStruct->GifApplicationExtension = gifApplication; - GifMemoryStruct->GifCommentExtension = gifComment; + GifMemoryStruct->GifHeader = gifHead; + GifMemoryStruct->GifImageDesc = gifImageDesc; + GifMemoryStruct->GifPlainTextExtension = gifPlainText; + GifMemoryStruct->GifApplicationExtension = gifApplication; + GifMemoryStruct->GifCommentExtension = gifComment; GifMemoryStruct->GifGraphicControlExtension = gifGraphicControl; /* return the struct */ return 0; - case 0x2C: /* Image Descriptor */ + case 0x2C: /* Image Descriptor */ /* * If there was no image descriptor before this increase image * count. If an imagedescriptor was present, reset GCEflag @@ -150,40 +150,37 @@ Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) GCEflag = 0; if (ImageCount > ImageArray) { - aTemp = ImageArray; + aTemp = ImageArray; ImageArray = (GIFBYTE)((ImageArray << 1) + 1); - if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc, - sizeof(GIFIMAGEDESC *) * ImageArray))) { + if (!(gifImageDesc = + (GIFIMAGEDESC **)realloc(gifImageDesc, sizeof(GIFIMAGEDESC *) * ImageArray))) { printf("Out of memory!"); exit(EXIT_FAILURE); } if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc( - gifGraphicControl, - sizeof(GIFGRAPHICCONTROL *) * ImageArray))) { + gifGraphicControl, sizeof(GIFGRAPHICCONTROL *) * ImageArray))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - for (j = aTemp ; j < ImageArray ; j++) { + for (j = aTemp; j < ImageArray; j++) { gifGraphicControl[j] = NULL; - gifImageDesc[j] = NULL; + gifImageDesc[j] = NULL; } } - if(!(gifImageDesc[ImageCount-1] = (GIFIMAGEDESC*)malloc(sizeof(GIFIMAGEDESC)))) { + if (!(gifImageDesc[ImageCount - 1] = (GIFIMAGEDESC *)malloc(sizeof(GIFIMAGEDESC)))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - - if (ReadGifImageDesc(gifImageDesc[ImageCount-1], &MemGif) == -1) + if (ReadGifImageDesc(gifImageDesc[ImageCount - 1], &MemGif) == -1) fputs("Error reading Image Descriptor information\n", stderr); /* Decompress the Image */ - gifImageDesc[ImageCount-1]->Image = Decompress(gifImageDesc[ImageCount-1], - gifHead); - free(gifImageDesc[ImageCount-1]->GIFImage); + gifImageDesc[ImageCount - 1]->Image = Decompress(gifImageDesc[ImageCount - 1], gifHead); + free(gifImageDesc[ImageCount - 1]->GIFImage); /* * Convert the local palette into an HDF compatible palette In @@ -191,150 +188,146 @@ Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) * the HDFPalette If it is absent the global table is written * as the HDFPalette. */ - if (!((gifImageDesc[ImageCount-1]->PackedField) & 0x80)) { + if (!((gifImageDesc[ImageCount - 1]->PackedField) & 0x80)) { /* Check to see if the global color table exists.... */ if (gifHead->PackedField & 0x80) { - for (i=0 ; iTableSize ; i++) { - gifImageDesc[ImageCount-1]->HDFPalette[i][0] = - gifHead->HDFPalette[i][0]; - gifImageDesc[ImageCount-1]->HDFPalette[i][1] = - gifHead->HDFPalette[i][1]; - gifImageDesc[ImageCount-1]->HDFPalette[i][2] = - gifHead->HDFPalette[i][2]; + for (i = 0; i < gifHead->TableSize; i++) { + gifImageDesc[ImageCount - 1]->HDFPalette[i][0] = gifHead->HDFPalette[i][0]; + gifImageDesc[ImageCount - 1]->HDFPalette[i][1] = gifHead->HDFPalette[i][1]; + gifImageDesc[ImageCount - 1]->HDFPalette[i][2] = gifHead->HDFPalette[i][2]; } } - gifImageDesc[ImageCount-1]->TableSize = gifHead->TableSize; + gifImageDesc[ImageCount - 1]->TableSize = gifHead->TableSize; } break; - case 0x21: /* Extension Block */ - Label = *MemGif++; + case 0x21: /* Extension Block */ + Label = *MemGif++; - switch (Label) { - case 0x01: /* Plain Text Extension */ + switch (Label) { + case 0x01: /* Plain Text Extension */ puts("Plain Text Extension\n"); PlainTextCount++; if (PlainTextCount > PlainTextArray) PlainTextArray = (GIFBYTE)((PlainTextArray << 1) + 1); - if (!(gifPlainText = (GIFPLAINTEXT **)realloc(gifPlainText , sizeof(GIFPLAINTEXT *) * PlainTextArray))) { + if (!(gifPlainText = (GIFPLAINTEXT **)realloc(gifPlainText, sizeof(GIFPLAINTEXT *) * + PlainTextArray))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - if(!(gifPlainText[PlainTextCount - 1] = (GIFPLAINTEXT*)malloc(sizeof(GIFPLAINTEXT)))) { + if (!(gifPlainText[PlainTextCount - 1] = + (GIFPLAINTEXT *)malloc(sizeof(GIFPLAINTEXT)))) { printf("Out of memory!"); exit(EXIT_FAILURE); } if (ReadGifPlainText(gifPlainText[PlainTextCount - 1], &MemGif)) - fprintf(stderr, - "Error reading Plain Text Extension information.\n"); + fprintf(stderr, "Error reading Plain Text Extension information.\n"); break; - case 0xFE: /* Comment Extension */ + case 0xFE: /* Comment Extension */ CommentCount++; if (CommentCount > CommentArray) CommentArray = (GIFBYTE)((CommentArray << 1) + 1); - if (!(gifComment = (GIFCOMMENT **)realloc(gifComment , sizeof(GIFCOMMENT *) * CommentArray))) { + if (!(gifComment = + (GIFCOMMENT **)realloc(gifComment, sizeof(GIFCOMMENT *) * CommentArray))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - if(!(gifComment[CommentCount - 1] = (GIFCOMMENT *)malloc(sizeof(GIFCOMMENT)))) { + if (!(gifComment[CommentCount - 1] = (GIFCOMMENT *)malloc(sizeof(GIFCOMMENT)))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - if (ReadGifComment(gifComment[CommentCount - 1], &MemGif)) - fprintf(stderr, - "Error reading Comment Extension information\n"); + fprintf(stderr, "Error reading Comment Extension information\n"); break; - case 0xF9: /* Graphic Control Extension */ - if (GCEflag == 0 ) + case 0xF9: /* Graphic Control Extension */ + if (GCEflag == 0) ImageCount++; GCEflag = 1; if (ImageCount > ImageArray) { - aTemp = ImageArray; + aTemp = ImageArray; ImageArray = (GIFBYTE)((ImageArray << 1) + 1); - if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(gifGraphicControl , sizeof(GIFGRAPHICCONTROL *) * ImageArray))) { + if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc( + gifGraphicControl, sizeof(GIFGRAPHICCONTROL *) * ImageArray))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc , sizeof(GIFIMAGEDESC *) * ImageArray))) { + if (!(gifImageDesc = (GIFIMAGEDESC **)realloc( + gifImageDesc, sizeof(GIFIMAGEDESC *) * ImageArray))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - for (j = aTemp ; j < ImageArray ; j++) { + for (j = aTemp; j < ImageArray; j++) { gifGraphicControl[j] = NULL; gifImageDesc[j] = NULL; } } - if(!(gifGraphicControl[ImageCount-1] = (GIFGRAPHICCONTROL*)malloc(sizeof(GIFGRAPHICCONTROL)))) { + if (!(gifGraphicControl[ImageCount - 1] = + (GIFGRAPHICCONTROL *)malloc(sizeof(GIFGRAPHICCONTROL)))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - - if (ReadGifGraphicControl(gifGraphicControl[ImageCount-1], &MemGif)) - fprintf(stderr, - "Error reading Graphic Control Extension information\n"); + if (ReadGifGraphicControl(gifGraphicControl[ImageCount - 1], &MemGif)) + fprintf(stderr, "Error reading Graphic Control Extension information\n"); (*MemGif)++; if ((!*MemGif) == 0) - fprintf(stderr, - "Error reading Graphic Control Extension\n"); + fprintf(stderr, "Error reading Graphic Control Extension\n"); break; - case 0xFF: /* Application Extension */ + case 0xFF: /* Application Extension */ ApplicationCount++; if (ApplicationCount > ApplicationArray) ApplicationArray = (GIFBYTE)((ApplicationArray << 1) + 1); - if (!(gifApplication = (GIFAPPLICATION **)realloc(gifApplication , sizeof(GIFAPPLICATION *) * ApplicationArray))) { + if (!(gifApplication = (GIFAPPLICATION **)realloc( + gifApplication, sizeof(GIFAPPLICATION *) * ApplicationArray))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - if(!(gifApplication[ApplicationCount - 1] = (GIFAPPLICATION *)malloc(sizeof(GIFAPPLICATION)))) { + if (!(gifApplication[ApplicationCount - 1] = + (GIFAPPLICATION *)malloc(sizeof(GIFAPPLICATION)))) { printf("Out of memory!"); exit(EXIT_FAILURE); } - if (ReadGifApplication(gifApplication[ApplicationCount - 1], &MemGif)) - fprintf(stderr, - "Error reading Application Extension information\n"); + fprintf(stderr, "Error reading Application Extension information\n"); break; default: printf("Unknown Extension Label: %#02x\n", Label); break; - } + } - break; + break; default: - fprintf(stderr, - "Unknown Block Separator Character: %#02x\n", Identifier); + fprintf(stderr, "Unknown Block Separator Character: %#02x\n", Identifier); } } } diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c index 79671aa..2b267ef 100644 --- a/hl/tools/gif2h5/gifread.c +++ b/hl/tools/gif2h5/gifread.c @@ -26,11 +26,12 @@ GetWord(GIFBYTE *MemGif) if (EndianOrder == 1) { /* LittleEndian */ - w = (GIFWORD) (*MemGif++ & 0xFF); - w |= (GIFWORD) ((*MemGif++ & 0xFF) << 0x08); - } else { - w = (GIFWORD) (*MemGif++ & 0xFF); - w = ((GIFWORD) (*MemGif++ & 0xFF)) | (w << 0x08); + w = (GIFWORD)(*MemGif++ & 0xFF); + w |= (GIFWORD)((*MemGif++ & 0xFF) << 0x08); + } + else { + w = (GIFWORD)(*MemGif++ & 0xFF); + w = ((GIFWORD)(*MemGif++ & 0xFF)) | (w << 0x08); } return w; @@ -53,23 +54,23 @@ GetByte(GIFBYTE *MemGif) * otherwise 0 if no error occured. */ int -ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ - GIFBYTE **MemGif2) /* GIF image file input FILE stream */ +ReadGifHeader(GIFHEAD * GifHead, /* Pointer to GIF header structure */ + GIFBYTE **MemGif2) /* GIF image file input FILE stream */ { - GIFWORD i; /* Loop counter */ - GIFWORD tableSize; /* Number of entires in the Global Color Table */ + GIFWORD i; /* Loop counter */ + GIFWORD tableSize; /* Number of entires in the Global Color Table */ GifHead->TableSize = 0; - for (i = 0 ; i < 6 ; i++) { + for (i = 0; i < 6; i++) { GifHead->HeaderDump[i] = *(*MemGif2)++; } - if (strncmp((const char *)GifHead->HeaderDump , "GIF" , (size_t)3)) { + if (strncmp((const char *)GifHead->HeaderDump, "GIF", (size_t)3)) { printf("The file does not appear to be a valid GIF file.\n"); exit(EXIT_FAILURE); } - for (i = 0 ; i < 7 ; i++) { + for (i = 0; i < 7; i++) { GifHead->LSDDump[i] = *(*MemGif2)++; } @@ -78,7 +79,7 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ /* Check if a Global Color Table is present */ if (GifHead->PackedField & 0x80) { /* Read number of color table entries */ - tableSize = (GIFWORD) (1L << ((GifHead->PackedField & 0x07) + 1)); + tableSize = (GIFWORD)(1L << ((GifHead->PackedField & 0x07) + 1)); GifHead->TableSize = tableSize; /* Read the Global Color Table */ @@ -100,12 +101,11 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ #if 0 if (ferror(FpGif)) return -1; -#endif /* 0 */ +#endif /* 0 */ - return 0; /* No FILE stream error occured */ + return 0; /* No FILE stream error occured */ } - /* ** Read a GIF Local Image Descriptor. ** @@ -120,93 +120,85 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ ** otherwise 0 if no error occured. */ int -ReadGifImageDesc( - GIFIMAGEDESC *GifImageDesc, /* Pointer to GIF image descriptor structure */ - GIFBYTE **MemGif2 /* GIF image file input FILE stream */ - ) +ReadGifImageDesc(GIFIMAGEDESC *GifImageDesc, /* Pointer to GIF image descriptor structure */ + GIFBYTE ** MemGif2 /* GIF image file input FILE stream */ +) { - GIFWORD i; /* Loop counter */ - GIFWORD tableSize; /* Number of entries in the Local Color Table */ - /* GIFBYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */ - GIFBYTE *TempPtr; - int ch , ch1; - - GifImageDesc->TableSize = 0; - for (i = 0 ; i < 9 ; i++) { - GifImageDesc->GIDDump[i] = *(*MemGif2)++; - } - - /* - ** Get the relevant fields. I need ImageWidth and Height actively hence I have - ** taken information from those fields. I intend to keep the GifImageDesc data - ** structure as it is so that anyone needing the rest of the fields can do so - ** quickly. - */ - - if (EndianOrder == 1) /* LittleEndian */ - { - GifImageDesc->ImageWidth = (GIFWORD) (GifImageDesc->GIDDump[4] & 0xFF); - GifImageDesc->ImageWidth |= (GIFWORD) ((GifImageDesc->GIDDump[5] & 0xFF) << 0x08); - - GifImageDesc->ImageHeight = (GIFWORD) (GifImageDesc->GIDDump[6] & 0xFF); - GifImageDesc->ImageHeight |= (GIFWORD) ((GifImageDesc->GIDDump[7] & 0xFF) << 0x08); - - } - else - { - GifImageDesc->ImageWidth = (GIFWORD) (GifImageDesc->GIDDump[4] & 0xFF); - GifImageDesc->ImageWidth = ((GIFWORD) (GifImageDesc->GIDDump[5] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); + GIFWORD i; /* Loop counter */ + GIFWORD tableSize; /* Number of entries in the Local Color Table */ + /* GIFBYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */ + GIFBYTE *TempPtr; + int ch, ch1; + + GifImageDesc->TableSize = 0; + for (i = 0; i < 9; i++) { + GifImageDesc->GIDDump[i] = *(*MemGif2)++; + } - GifImageDesc->ImageHeight = (GIFWORD) (GifImageDesc->GIDDump[6] & 0xFF); - GifImageDesc->ImageHeight = ((GIFWORD) (GifImageDesc->GIDDump[7] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); + /* + ** Get the relevant fields. I need ImageWidth and Height actively hence I have + ** taken information from those fields. I intend to keep the GifImageDesc data + ** structure as it is so that anyone needing the rest of the fields can do so + ** quickly. + */ + if (EndianOrder == 1) /* LittleEndian */ + { + GifImageDesc->ImageWidth = (GIFWORD)(GifImageDesc->GIDDump[4] & 0xFF); + GifImageDesc->ImageWidth |= (GIFWORD)((GifImageDesc->GIDDump[5] & 0xFF) << 0x08); - } + GifImageDesc->ImageHeight = (GIFWORD)(GifImageDesc->GIDDump[6] & 0xFF); + GifImageDesc->ImageHeight |= (GIFWORD)((GifImageDesc->GIDDump[7] & 0xFF) << 0x08); + } + else { + GifImageDesc->ImageWidth = (GIFWORD)(GifImageDesc->GIDDump[4] & 0xFF); + GifImageDesc->ImageWidth = + ((GIFWORD)(GifImageDesc->GIDDump[5] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); + + GifImageDesc->ImageHeight = (GIFWORD)(GifImageDesc->GIDDump[6] & 0xFF); + GifImageDesc->ImageHeight = + ((GIFWORD)(GifImageDesc->GIDDump[7] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); + } - GifImageDesc->PackedField = GifImageDesc->GIDDump[8]; + GifImageDesc->PackedField = GifImageDesc->GIDDump[8]; - /* Interlace = GifImageDesc->PackedField & 0x20; */ + /* Interlace = GifImageDesc->PackedField & 0x20; */ /* Check if a Local Color Table is present */ - if (GifImageDesc->PackedField & 0x80) - { + if (GifImageDesc->PackedField & 0x80) { /* Read number of color table entries */ - tableSize = (GIFWORD) (1L << ((GifImageDesc->PackedField & 0x07) + 1)); - GifImageDesc->TableSize = tableSize; + tableSize = (GIFWORD)(1L << ((GifImageDesc->PackedField & 0x07) + 1)); + GifImageDesc->TableSize = tableSize; /* Read the Local Color Table */ - for (i = 0; i < tableSize; i++) - { + for (i = 0; i < tableSize; i++) { GifImageDesc->HDFPalette[i][0] = *(*MemGif2)++; GifImageDesc->HDFPalette[i][1] = *(*MemGif2)++; GifImageDesc->HDFPalette[i][2] = *(*MemGif2)++; } } - /* - ** Get LZW minimum Code Size - */ - GifImageDesc->CodeSize = (GIFWORD)*(*MemGif2)++; - - /*GifImageDesc->GIFImage = ReadDataSubBlocks(FpGif);*/ - if (!(GifImageDesc->GIFImage = (GIFBYTE *)malloc((GifImageDesc->ImageWidth) * (GifImageDesc->ImageHeight)))) { - printf("Out of memory"); - exit(EXIT_FAILURE); - } - - - TempPtr = GifImageDesc->GIFImage; - do - { - ch = ch1 = (int)*(*MemGif2)++; - while (ch--) *TempPtr++ = *(*MemGif2)++; - } - while (ch1); + /* + ** Get LZW minimum Code Size + */ + GifImageDesc->CodeSize = (GIFWORD) * (*MemGif2)++; + + /*GifImageDesc->GIFImage = ReadDataSubBlocks(FpGif);*/ + if (!(GifImageDesc->GIFImage = + (GIFBYTE *)malloc((GifImageDesc->ImageWidth) * (GifImageDesc->ImageHeight)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + TempPtr = GifImageDesc->GIFImage; + do { + ch = ch1 = (int)*(*MemGif2)++; + while (ch--) + *TempPtr++ = *(*MemGif2)++; + } while (ch1); - return(0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occured */ } - /* ** Read a GIF Graphic Control Extension block. ** @@ -217,21 +209,19 @@ ReadGifImageDesc( ** otherwise 0 if no error occured. */ int -ReadGifGraphicControl( - GIFGRAPHICCONTROL *GifGraphicControl, /* Pointer to GC Extension structure */ - GIFBYTE **MemGif2 /* GIF image file input FILE stream */ - ) +ReadGifGraphicControl(GIFGRAPHICCONTROL *GifGraphicControl, /* Pointer to GC Extension structure */ + GIFBYTE ** MemGif2 /* GIF image file input FILE stream */ +) { int i; - for (i = 0 ; i < 5 ; i++) { - GifGraphicControl->GCEDump[i] = *(*MemGif2)++; + for (i = 0; i < 5; i++) { + GifGraphicControl->GCEDump[i] = *(*MemGif2)++; } - return(0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occured */ } - /* ** Read a GIF Plain Text Extension block. ** @@ -242,35 +232,33 @@ ReadGifGraphicControl( ** otherwise 0 if no error occured. */ int -ReadGifPlainText( - GIFPLAINTEXT *GifPlainText, /* Pointer to Plain Text Extension structure */ - GIFBYTE **MemGif2 /* GIF image file input FILE stream */ - ) +ReadGifPlainText(GIFPLAINTEXT *GifPlainText, /* Pointer to Plain Text Extension structure */ + GIFBYTE ** MemGif2 /* GIF image file input FILE stream */ +) { int i; - for (i = 0 ; i < 13 ; i++) { - GifPlainText->PTEDump[i] = *(*MemGif2)++; - } + for (i = 0; i < 13; i++) { + GifPlainText->PTEDump[i] = *(*MemGif2)++; + } /* Read in the Plain Text data sub-blocks */ - if (!(GifPlainText->PlainTextData = ReadDataSubBlocks(MemGif2 , &(GifPlainText->DataSize)))) - return(1); + if (!(GifPlainText->PlainTextData = ReadDataSubBlocks(MemGif2, &(GifPlainText->DataSize)))) + return (1); /* GifPlainText->Terminator = 0; */ /* Check for a FILE stream error */ - /* - if (ferror(FpGif)) - return(-1); - */ + /* + if (ferror(FpGif)) + return(-1); + */ - return(0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occured */ } - /* ** Read a GIF Application Extension block. ** @@ -281,34 +269,32 @@ ReadGifPlainText( ** otherwise 0 if no error occured. */ int -ReadGifApplication( - GIFAPPLICATION *GifApplication, /* Pointer to Application Extension structure */ - GIFBYTE **MemGif2 /* GIF image file input FILE stream */ - ) +ReadGifApplication(GIFAPPLICATION *GifApplication, /* Pointer to Application Extension structure */ + GIFBYTE ** MemGif2 /* GIF image file input FILE stream */ +) { int i; - for (i = 0 ; i < 12 ; i++) { - GifApplication->AEDump[i] = *(*MemGif2)++; - } + for (i = 0; i < 12; i++) { + GifApplication->AEDump[i] = *(*MemGif2)++; + } /* Read in the Plain Text data sub-blocks */ - if (!(GifApplication->ApplicationData = ReadDataSubBlocks(MemGif2 , &(GifApplication->DataSize)))) - return(1); - /* - GifApplication->Terminator = 0; - */ + if (!(GifApplication->ApplicationData = ReadDataSubBlocks(MemGif2, &(GifApplication->DataSize)))) + return (1); + /* + GifApplication->Terminator = 0; + */ - /* Check for a FILE stream error */ - /* - if (ferror(FpGif)) - return(-1); - */ + /* Check for a FILE stream error */ + /* + if (ferror(FpGif)) + return(-1); + */ - return(0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occured */ } - /* ** Read a GIF Comment Extension block. ** @@ -319,22 +305,20 @@ ReadGifApplication( ** otherwise 0 if no error occured. */ int -ReadGifComment( - GIFCOMMENT *GifComment, /* Pointer to GIF Comment Extension structure */ - GIFBYTE **MemGif2 /* GIF image file input FILE stream */ - ) +ReadGifComment(GIFCOMMENT *GifComment, /* Pointer to GIF Comment Extension structure */ + GIFBYTE ** MemGif2 /* GIF image file input FILE stream */ +) { /* Read in the Plain Text data sub-blocks */ - if (!(GifComment->CommentData = ReadDataSubBlocks(MemGif2 , &(GifComment->DataSize)))) - return(1); + if (!(GifComment->CommentData = ReadDataSubBlocks(MemGif2, &(GifComment->DataSize)))) + return (1); GifComment->Terminator = 0; - return(0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occured */ } - /* ** Read one or more GIF data sub-blocks and write the information ** to a buffer. @@ -347,55 +331,47 @@ ReadGifComment( */ static GIFBYTE * ReadDataSubBlocks(GIFBYTE **MemGif2, /* GIF image file input FILE stream */ - GIFWORD *DSize) + GIFWORD * DSize) { GIFBYTE *ptr1; /* Pointer used to "walk the heap" */ GIFBYTE *ptr2; /* Pointer used to mark the top of the heap */ - GIFBYTE dataSize; /* Size of the current data sub-block being read */ - GIFWORD bufSize; /* Total size of the Plain Text data buffer */ - int tempcount = 0; + GIFBYTE dataSize; /* Size of the current data sub-block being read */ + GIFWORD bufSize; /* Total size of the Plain Text data buffer */ + int tempcount = 0; - bufSize = 0; /* The output buffer is empty */ + bufSize = 0; /* The output buffer is empty */ - dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */ + dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */ /* Allocate initial data buffer */ - if (!(ptr1 = ptr2 = (GIFBYTE *) malloc((size_t)dataSize + 1))) { - printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or Application Extensions failed"); - return((GIFBYTE *) NULL); - } - for (;;) - { - tempcount++; - bufSize += (dataSize); /* Running total of the buffer size */ - *DSize = bufSize; + if (!(ptr1 = ptr2 = (GIFBYTE *)malloc((size_t)dataSize + 1))) { + printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or " + "Application Extensions failed"); + return ((GIFBYTE *)NULL); + } + for (;;) { + tempcount++; + bufSize += (dataSize); /* Running total of the buffer size */ + *DSize = bufSize; #ifdef COMMENTED_OUT - *ptr1++ = dataSize; /* Write the data count */ -#endif /* COMMENTED_OUT */ - while (dataSize--) /* Read/write the Plain Text data */ - *ptr1++ = *(*MemGif2)++; + *ptr1++ = dataSize; /* Write the data count */ +#endif /* COMMENTED_OUT */ + while (dataSize--) /* Read/write the Plain Text data */ + *ptr1++ = *(*MemGif2)++; /* Check if there is another data sub-block */ if ((dataSize = *(*MemGif2)++) == 0) - break; /* Block Terminator encountered */ + break; /* Block Terminator encountered */ /* Increase the buffer size to accomodate the next sub-block */ - if (!(ptr1 = ptr2 = (GIFBYTE *) realloc(ptr2, bufSize + dataSize + 1))) - return((GIFBYTE *) NULL); - - - ptr1 += bufSize; /* Move pointer to the end of the data */ - + if (!(ptr1 = ptr2 = (GIFBYTE *)realloc(ptr2, bufSize + dataSize + 1))) + return ((GIFBYTE *)NULL); + ptr1 += bufSize; /* Move pointer to the end of the data */ } *ptr1++ = '\0'; - return(ptr2); /* Return a pointer to the sub-block data */ + return (ptr2); /* Return a pointer to the sub-block data */ } - - - - - diff --git a/hl/tools/gif2h5/h52gifgentst.c b/hl/tools/gif2h5/h52gifgentst.c index 655563c..9bd7874 100644 --- a/hl/tools/gif2h5/h52gifgentst.c +++ b/hl/tools/gif2h5/h52gifgentst.c @@ -30,11 +30,11 @@ */ #define FILENAME "h52giftst.h5" -#define WIDTH 400 -#define HEIGHT 200 -#define PAL_ENTRIES 256 -#define IMAGE1_NAME "image" -#define PAL_NAME "palette" +#define WIDTH 400 +#define HEIGHT 200 +#define PAL_ENTRIES 256 +#define IMAGE1_NAME "image" +#define PAL_NAME "palette" /*------------------------------------------------------------------------- * Function: main @@ -44,65 +44,61 @@ *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { - hid_t fid; - int i, j, n, space; + hid_t fid; + int i, j, n, space; unsigned char *buf; - unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */ - hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */ - hsize_t width = WIDTH; - hsize_t height = HEIGHT; + unsigned char pal[PAL_ENTRIES * 3]; /* palette array */ + hsize_t pal_dims[2] = {PAL_ENTRIES, 3}; /* palette dimensions */ + hsize_t width = WIDTH; + hsize_t height = HEIGHT; /* Allocate buffer */ - if(NULL == (buf = (unsigned char *)malloc(WIDTH * HEIGHT))) + if (NULL == (buf = (unsigned char *)malloc(WIDTH * HEIGHT))) return EXIT_FAILURE; /* create a file */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return EXIT_FAILURE; /* create an image */ - space = WIDTH*HEIGHT / PAL_ENTRIES; - for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ ) - { + space = WIDTH * HEIGHT / PAL_ENTRIES; + for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT; i++, j++) { buf[i] = (unsigned char)n; - if ( j > space ) - { + if (j > space) { n++; - j=0; + j = 0; } - } /* make the image */ - if (H5IMmake_image_8bit( fid, IMAGE1_NAME, width, height, buf )<0) + if (H5IMmake_image_8bit(fid, IMAGE1_NAME, width, height, buf) < 0) return EXIT_FAILURE; - /*------------------------------------------------------------------------- - * define a palette, blue to red tones - *------------------------------------------------------------------------- - */ - for ( i=0, n=0; i>8)&0xff,fp); + fputc(w & 0xff, fp); + fputc((w >> 8) & 0xff, fp); } static void @@ -42,18 +41,18 @@ usage(void) fprintf(stdout, " h52gif -V \n"); fprintf(stdout, " Print HDF5 library version and exit\n"); printf("h52gif expects *at least* one h5_image.\n"); - } static void leave(int ret) { - h5tools_close(); - HDexit(ret); + h5tools_close(); + HDexit(ret); } FILE *fpGif = NULL; -int main(int argc , char **argv) +int +main(int argc, char **argv) { GIFBYTE *Image; @@ -61,25 +60,25 @@ int main(int argc , char **argv) GIFCHAR *HDFName = NULL; GIFCHAR *GIFName = NULL; - GIFBYTE* b; + GIFBYTE *b; - GIFBYTE GlobalPalette[256][3]; - GIFBYTE Red[256]; - GIFBYTE Green[256]; - GIFBYTE Blue[256]; + GIFBYTE GlobalPalette[256][3]; + GIFBYTE Red[256]; + GIFBYTE Green[256]; + GIFBYTE Blue[256]; - int RWidth, RHeight; - int ColorMapSize, InitCodeSize, Background, BitsPerPixel; - int j,nc; - int i; - int numcols = 0; + int RWidth, RHeight; + int ColorMapSize, InitCodeSize, Background, BitsPerPixel; + int j, nc; + int i; + int numcols = 0; - GIFBYTE pc2nc[256] , r1[256] , g1[256] , b1[256]; + GIFBYTE pc2nc[256], r1[256], g1[256], b1[256]; - int arg_index = 2; - int bool_is_image = 0; /* 0 = false , 1 = true */ - char *image_name = NULL; - int idx; + int arg_index = 2; + int bool_is_image = 0; /* 0 = false , 1 = true */ + char *image_name = NULL; + int idx; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -87,15 +86,12 @@ int main(int argc , char **argv) /* Initialize h5tools lib */ h5tools_init(); - if ( argv[1] && (strcmp("-V",argv[1])==0) ) - { + if (argv[1] && (strcmp("-V", argv[1]) == 0)) { print_version("gif2h5"); h5tools_setstatus(EXIT_SUCCESS); } - - if (argc < 4) - { + if (argc < 4) { /* they didn't supply at least one image -- bail */ usage(); h5tools_setstatus(EXIT_FAILURE); @@ -105,19 +101,17 @@ int main(int argc , char **argv) GIFName = argv[2]; /* get the options */ - while (arg_index++ < argc - 1) - { - if (!strcmp(argv[arg_index] , "-i")) { + while (arg_index++ < argc - 1) { + if (!strcmp(argv[arg_index], "-i")) { bool_is_image = 1; continue; } - if (bool_is_image) - { + if (bool_is_image) { /* allocate space to store the image name */ size_t len = strlen(argv[arg_index]); - image_name = (GIFCHAR*) malloc( len + 1); - strcpy(image_name , argv[arg_index]); + image_name = (GIFCHAR *)malloc(len + 1); + strcpy(image_name, argv[arg_index]); bool_is_image = 0; continue; @@ -129,80 +123,72 @@ int main(int argc , char **argv) goto out; } - /* Do Endian Order testing and set Endian Order */ - idx = 0x0001; - b = (GIFBYTE *) &idx; - EndianOrder = (b[0] ? 1:0); + /* Do Endian Order testing and set Endian Order */ + idx = 0x0001; + b = (GIFBYTE *)&idx; + EndianOrder = (b[0] ? 1 : 0); - if (!(fpGif = fopen(GIFName , "wb"))) - { + if (!(fpGif = fopen(GIFName, "wb"))) { printf("Error opening gif file for output. Aborting.\n"); goto out; } Background = 0; { - hsize_t width, height, planes; - hid_t fid; - char interlace[20]; - hssize_t npals; - hsize_t pal_dims[2]; + hsize_t width, height, planes; + hid_t fid; + char interlace[20]; + hssize_t npals; + hsize_t pal_dims[2]; unsigned char *pal; - if ((fid = H5Fopen(HDFName , H5F_ACC_RDONLY , H5P_DEFAULT)) < 0) - { - fprintf(stderr , "Unable to open HDF file for input. Aborting.\n"); + if ((fid = H5Fopen(HDFName, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + fprintf(stderr, "Unable to open HDF file for input. Aborting.\n"); goto out; } /* get image's information */ - if ( H5IMget_image_info( fid, image_name, &width, &height, &planes, interlace, &npals ) < 0 ) - { - fprintf(stderr , "Unable to get information of the image. Aborting.\n"); + if (H5IMget_image_info(fid, image_name, &width, &height, &planes, interlace, &npals) < 0) { + fprintf(stderr, "Unable to get information of the image. Aborting.\n"); goto out; } - if (width > IMAGE_WIDTH_MAX || height > IMAGE_HEIGHT_MAX) - { - fprintf(stderr, "HDF5 image is too large. Limit is %d by %d.\n", IMAGE_WIDTH_MAX, IMAGE_HEIGHT_MAX); + if (width > IMAGE_WIDTH_MAX || height > IMAGE_HEIGHT_MAX) { + fprintf(stderr, "HDF5 image is too large. Limit is %d by %d.\n", IMAGE_WIDTH_MAX, + IMAGE_HEIGHT_MAX); goto out; } /* tool can handle single plane images only. */ - if (planes > 1) - { + if (planes > 1) { fprintf(stderr, "Cannot handle multiple planes image\n"); goto out; } - Image = (GIFBYTE*) malloc( (size_t) width * (size_t) height ); + Image = (GIFBYTE *)malloc((size_t)width * (size_t)height); - if ( H5IMread_image( fid, image_name, Image ) < 0 ) - { - fprintf(stderr , "Unable to read the image. Aborting.\n"); + if (H5IMread_image(fid, image_name, Image) < 0) { + fprintf(stderr, "Unable to read the image. Aborting.\n"); goto out; } - if (npals) - { - if ( H5IMget_palette_info( fid, image_name, 0, pal_dims ) < 0 ) - { - fprintf(stderr , "Unable to get information of the palette. Aborting.\n"); + if (npals) { + if (H5IMget_palette_info(fid, image_name, 0, pal_dims) < 0) { + fprintf(stderr, "Unable to get information of the palette. Aborting.\n"); goto out; } - pal = (GIFBYTE*) malloc( (size_t) pal_dims[0] * (size_t) pal_dims[1] ); + pal = (GIFBYTE *)malloc((size_t)pal_dims[0] * (size_t)pal_dims[1]); - if ( H5IMget_palette( fid, image_name, 0, pal ) < 0 ) + if (H5IMget_palette(fid, image_name, 0, pal) < 0) goto out; - numcols = (int) pal_dims[0]; + numcols = (int)pal_dims[0]; - for (i = 0, j = 0 ; i < numcols ; j+=3, i++) - { + for (i = 0, j = 0; i < numcols; j += 3, i++) { GlobalPalette[i][0] = pal[j]; - GlobalPalette[i][1] = pal[j+1]; - GlobalPalette[i][2] = pal[j+2]; + GlobalPalette[i][1] = pal[j + 1]; + GlobalPalette[i][2] = pal[j + 2]; } free(pal); @@ -213,7 +199,6 @@ int main(int argc , char **argv) RWidth = (int)width; RHeight = (int)height; - /* * If the first image does not have a palette, I make my own global * color table Obviously this is not the best thing to do, better @@ -223,62 +208,52 @@ int main(int argc , char **argv) * palette * 2. Check for palettes in any of the other images. */ - if (!npals) - { + if (!npals) { numcols = 256; - for (i = 0 ; i < numcols ; i++) - { - Red[i] = (GIFBYTE)(255 - i); + for (i = 0; i < numcols; i++) { + Red[i] = (GIFBYTE)(255 - i); Green[i] = (GIFBYTE)(255 - i); - Blue[i] = (GIFBYTE)(255 - i); + Blue[i] = (GIFBYTE)(255 - i); } } - else - { - for (i = 0 ; i < numcols ; i++) - { - Red[i] = GlobalPalette[i][0]; + else { + for (i = 0; i < numcols; i++) { + Red[i] = GlobalPalette[i][0]; Green[i] = GlobalPalette[i][1]; - Blue[i] = GlobalPalette[i][2]; + Blue[i] = GlobalPalette[i][2]; } } - for (i = 0; i < numcols; i++) - { + for (i = 0; i < numcols; i++) { pc2nc[i] = r1[i] = g1[i] = b1[i] = 0; } /* compute number of unique colors */ nc = 0; - for (i = 0; i < numcols; i++) - { + for (i = 0; i < numcols; i++) { /* see if color #i is already used */ - for (j = 0; j < i; j++) - { + for (j = 0; j < i; j++) { if (Red[i] == Red[j] && Green[i] == Green[j] && Blue[i] == Blue[j]) break; } - if (j==i) - { + if (j == i) { /* wasn't found */ pc2nc[i] = (GIFBYTE)nc; - r1[nc] = Red[i]; - g1[nc] = Green[i]; - b1[nc] = Blue[i]; + r1[nc] = Red[i]; + g1[nc] = Green[i]; + b1[nc] = Blue[i]; nc++; } - else - { + else { pc2nc[i] = pc2nc[j]; } } /* figure out 'BitsPerPixel' */ - for (i = 1; i < 8; i++) - { - if ((1<= nc) + for (i = 1; i < 8; i++) { + if ((1 << i) >= nc) break; } @@ -290,59 +265,54 @@ int main(int argc , char **argv) else InitCodeSize = BitsPerPixel; - if (!fpGif) - { - fprintf(stderr, "WriteGIF: file not open for writing\n" ); + if (!fpGif) { + fprintf(stderr, "WriteGIF: file not open for writing\n"); goto out; } + fwrite("GIF87a", sizeof(char), 6, fpGif); /* the GIF magic number */ - fwrite("GIF87a", sizeof( char ), 6, fpGif); /* the GIF magic number */ - - putword(RWidth, fpGif); /* screen descriptor */ + putword(RWidth, fpGif); /* screen descriptor */ putword(RHeight, fpGif); - i = 0x00; /* No, there is no color map */ - i |= (8-1)<<4; /* OR in the color resolution (hardwired 8) */ - i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */ - fputc(i,fpGif); - - fputc(Background,fpGif); /* background color */ - fputc(0, fpGif); /* future expansion byte */ + i = 0x00; /* No, there is no color map */ + i |= (8 - 1) << 4; /* OR in the color resolution (hardwired 8) */ + i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */ + fputc(i, fpGif); + fputc(Background, fpGif); /* background color */ + fputc(0, fpGif); /* future expansion byte */ /* * Put Image Descriptor * Hardwiring Left Offset and Top Offset to 0x00 */ - fputc(0x2c , fpGif); - putword(0x00 , fpGif); - putword(0x00 , fpGif); - putword(RWidth , fpGif); - putword(RHeight , fpGif); + fputc(0x2c, fpGif); + putword(0x00, fpGif); + putword(0x00, fpGif); + putword(RWidth, fpGif); + putword(RHeight, fpGif); /* since we always have a local color palette ... */ - fputc((0x80 | (BitsPerPixel - 1)) , fpGif); + fputc((0x80 | (BitsPerPixel - 1)), fpGif); - for (i = 0; i < ColorMapSize; i++) - { + for (i = 0; i < ColorMapSize; i++) { /* write out Global colormap */ fputc(r1[i], fpGif); fputc(g1[i], fpGif); fputc(b1[i], fpGif); } - fputc(InitCodeSize , fpGif); + fputc(InitCodeSize, fpGif); - i = hdfWriteGIF(fpGif , Image , 0 , RHeight , RWidth , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel); + i = hdfWriteGIF(fpGif, Image, 0, RHeight, RWidth, r1, g1, b1, pc2nc, 256, 8, BitsPerPixel); fputc(0x00, fpGif); free(Image); } - if (fputc(';',fpGif) == EOF) - { + if (fputc(';', fpGif) == EOF) { /* Write GIF file terminator */ - fprintf(stderr , "Error!"); + fprintf(stderr, "Error!"); goto out; } @@ -353,7 +323,6 @@ int main(int argc , char **argv) leave(h5tools_getstatus()); - out: if (fpGif != NULL) diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index d44ff7a..7be68dc 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -44,7 +44,6 @@ * Joe Orost (decvax!vax135!petsd!joe) *****************************************************************/ - #include #include #include @@ -65,32 +64,32 @@ static void flush_char(void); #else static void compress(), output(), cl_block(), cl_hash(); static void char_init(), char_out(), flush_char(); -#endif /* __STDC__ */ +#endif /* __STDC__ */ static byte pc2nc[256]; /***********************************************************************/ static unsigned long cur_accum = 0; -static int cur_bits = 0; +static int cur_bits = 0; -#define MAXCODE(n_bits) ( (1 << (n_bits)) - 1) -#define XV_BITS 12 /* BITS was already defined on some systems */ -#define HSIZE 5003 /* 80% occupancy */ +#define MAXCODE(n_bits) ((1 << (n_bits)) - 1) +#define XV_BITS 12 /* BITS was already defined on some systems */ +#define HSIZE 5003 /* 80% occupancy */ -typedef unsigned char char_type; +typedef unsigned char char_type; static int n_bits; /* number of bits/code */ static int maxbits = XV_BITS; /* user settable max # bits/code */ static int maxcode; /* maximum code, given n_bits */ static int maxmaxcode = 1 << XV_BITS; /* NEVER generate this */ -static count_int *htab; -static unsigned short *codetab; +static count_int * htab; +static unsigned short *codetab; -#define HashTabOf(i) htab[i] -#define CodeTabOf(i) codetab[i] +#define HashTabOf(i) htab[i] +#define CodeTabOf(i) codetab[i] -static int hsize = HSIZE; /* for dynamic table sizing */ +static int hsize = HSIZE; /* for dynamic table sizing */ /* * To save much memory, we overlay the table used by compress() with those @@ -101,7 +100,7 @@ static int hsize = HSIZE; /* for dynamic table sizing */ * used to be 8000 characters). */ -static int free_ent = 0; /* first unused entry */ +static int free_ent = 0; /* first unused entry */ /* * block compression parameters -- after all codes are used up, @@ -109,8 +108,8 @@ static int free_ent = 0; /* first unused entry */ */ static int clear_flg = 0; -static long int in_count = 1; /* length of input */ -static long int out_count = 0; /* # of codes output (for debugging) */ +static long int in_count = 1; /* length of input */ +static long int out_count = 0; /* # of codes output (for debugging) */ /* * compress stdin to stdout @@ -128,19 +127,19 @@ static long int out_count = 0; /* # of codes output (for debugging) */ * about this implementation to ames!jaw. */ -static int g_init_bits; +static int g_init_bits; static FILE *g_outfile; static int ClearCode; static int EOFCode; /*************************************************************/ -int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, - byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, - int colorstyle, int BitsPerPixel) +int +hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, byte *gmap, byte *bmap, byte *pc2ncmap, + int numcols, int colorstyle, int BitsPerPixel) { - int InitCodeSize; - int i; + int InitCodeSize; + int i; byte *pic8 = pic; if (!(htab = calloc(HSIZE, sizeof(count_int)))) { @@ -153,15 +152,15 @@ int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, } /* Shut compiler up... */ - ptype=ptype; - rmap=rmap; - gmap=gmap; - bmap=bmap; - numcols=numcols; - colorstyle=colorstyle; + ptype = ptype; + rmap = rmap; + gmap = gmap; + bmap = bmap; + numcols = numcols; + colorstyle = colorstyle; for (i = 0; i < 256; i++) { - pc2nc[i] = pc2ncmap[i]; + pc2nc[i] = pc2ncmap[i]; } if (BitsPerPixel <= 1) @@ -170,11 +169,11 @@ int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, InitCodeSize = BitsPerPixel; if (!fp) { - fprintf(stderr, "WriteGIF: file not open for writing\n"); + fprintf(stderr, "WriteGIF: file not open for writing\n"); return 1; } - compress(InitCodeSize+1, fp, pic8, w*h); + compress(InitCodeSize + 1, fp, pic8, w * h); free(htab); free(codetab); @@ -182,19 +181,20 @@ int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, if (ferror(fp)) return -1; - return 0 ; + return 0; } /********************************************************/ -static void compress(int init_bits, FILE *outfile, byte *data, int len) +static void +compress(int init_bits, FILE *outfile, byte *data, int len) { register long fcode; - register int i = 0; - register int c; - register int ent; - register int disp; - register int hsize_reg; - register int hshift; + register int i = 0; + register int c; + register int ent; + register int disp; + register int hsize_reg; + register int hshift; /* * Set up the globals: g_init_bits - initial number of bits g_outfile - @@ -204,38 +204,38 @@ static void compress(int init_bits, FILE *outfile, byte *data, int len) g_outfile = outfile; /* initialize 'compress' globals */ - maxbits = XV_BITS; - maxmaxcode = 1<= 0) + if ((long)HashTabOf(i) >= 0) goto probe; nomatch: @@ -278,9 +279,10 @@ nomatch: ent = c; if (free_ent < maxmaxcode) { - CodeTabOf (i) = (unsigned short)free_ent++; /* code -> hashtable */ - HashTabOf (i) = fcode; - } else { + CodeTabOf(i) = (unsigned short)free_ent++; /* code -> hashtable */ + HashTabOf(i) = fcode; + } + else { cl_block(); } } @@ -291,7 +293,6 @@ nomatch: output(EOFCode); } - /***************************************************************** * TAG( output ) * @@ -309,11 +310,8 @@ nomatch: * code in turn. When the buffer fills up empty it and start over. */ -static -unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, - 0x001F, 0x003F, 0x007F, 0x00FF, - 0x01FF, 0x03FF, 0x07FF, 0x0FFF, - 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; +static unsigned long masks[] = {0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, + 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF}; static void output(int code) @@ -327,8 +325,8 @@ output(int code) cur_bits += n_bits; - while( cur_bits >= 8 ) { - char_out( (int)((unsigned int) cur_accum & 0xff) ); + while (cur_bits >= 8) { + char_out((int)((unsigned int)cur_accum & 0xff)); cur_accum >>= 8; cur_bits -= 8; } @@ -339,12 +337,13 @@ output(int code) */ if (free_ent > maxcode || clear_flg) { if (clear_flg) { - maxcode = MAXCODE (n_bits = g_init_bits); + maxcode = MAXCODE(n_bits = g_init_bits); clear_flg = 0; - } else { + } + else { n_bits++; - if ( n_bits == maxbits ) + if (n_bits == maxbits) maxcode = maxmaxcode; else maxcode = MAXCODE(n_bits); @@ -353,17 +352,17 @@ output(int code) if (code == EOFCode) { /* At EOF, write the rest of the buffer */ - while( cur_bits > 0 ) { - char_out( (int)((unsigned int)cur_accum & 0xff) ); + while (cur_bits > 0) { + char_out((int)((unsigned int)cur_accum & 0xff)); cur_accum >>= 8; cur_bits -= 8; } flush_char(); - fflush( g_outfile ); + fflush(g_outfile); #ifdef FOO - if(ferror( g_outfile)) + if (ferror(g_outfile)) FatalError("unable to write GIF file"); #endif } @@ -371,45 +370,45 @@ output(int code) /********************************/ static void -cl_block(void) /* table clear for block compress */ +cl_block(void) /* table clear for block compress */ { /* Clear out the hash table */ - cl_hash((count_int) hsize); - free_ent = ClearCode + 2; + cl_hash((count_int)hsize); + free_ent = ClearCode + 2; clear_flg = 1; output(ClearCode); } /********************************/ static void -cl_hash(count_int hashsize) /* reset code table */ +cl_hash(count_int hashsize) /* reset code table */ { - count_int *htab_p = htab+hashsize; - long i, m1 = -1; + count_int *htab_p = htab + hashsize; + long i, m1 = -1; i = hashsize - 16; - do { /* might use Sys V memset(3) here */ - *(htab_p-16) = m1; - *(htab_p-15) = m1; - *(htab_p-14) = m1; - *(htab_p-13) = m1; - *(htab_p-12) = m1; - *(htab_p-11) = m1; - *(htab_p-10) = m1; - *(htab_p-9) = m1; - *(htab_p-8) = m1; - *(htab_p-7) = m1; - *(htab_p-6) = m1; - *(htab_p-5) = m1; - *(htab_p-4) = m1; - *(htab_p-3) = m1; - *(htab_p-2) = m1; - *(htab_p-1) = m1; + do { /* might use Sys V memset(3) here */ + *(htab_p - 16) = m1; + *(htab_p - 15) = m1; + *(htab_p - 14) = m1; + *(htab_p - 13) = m1; + *(htab_p - 12) = m1; + *(htab_p - 11) = m1; + *(htab_p - 10) = m1; + *(htab_p - 9) = m1; + *(htab_p - 8) = m1; + *(htab_p - 7) = m1; + *(htab_p - 6) = m1; + *(htab_p - 5) = m1; + *(htab_p - 4) = m1; + *(htab_p - 3) = m1; + *(htab_p - 2) = m1; + *(htab_p - 1) = m1; htab_p -= 16; } while ((i -= 16) >= 0); - for ( i += 16; i > 0; i-- ) + for (i += 16; i > 0; i--) *--htab_p = m1; } @@ -436,7 +435,7 @@ char_init(void) /* * Define the storage for the packet accumulator */ -static char accum[ 256 ]; +static char accum[256]; /* * Add a character to the end of the current packet, and if it is 254 @@ -445,7 +444,7 @@ static char accum[ 256 ]; static void char_out(int c) { - accum[ a_count++ ] = (char)c; + accum[a_count++] = (char)c; if (a_count >= 254) flush_char(); @@ -458,8 +457,8 @@ static void flush_char(void) { if (a_count > 0) { - fputc( a_count, g_outfile ); - fwrite( accum, (size_t)1, (size_t)a_count, g_outfile); + fputc(a_count, g_outfile); + fwrite(accum, (size_t)1, (size_t)a_count, g_outfile); a_count = 0; } } diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index c2933c5..0cf3926 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -37,21 +37,21 @@ int WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName) { - GIFHEAD gifHead; /* GIF Header structure */ - GIFIMAGEDESC *gifImageDesc; /* Logical Image Descriptor struct */ - int has_pal=0; + GIFHEAD gifHead; /* GIF Header structure */ + GIFIMAGEDESC *gifImageDesc; /* Logical Image Descriptor struct */ + int has_pal = 0; - long ImageCount; /* number of images */ + long ImageCount; /* number of images */ #ifdef UNUSED - long CommentCount, /* number of comments */ - ApplicationCount, /* number of application extensions */ - PlainTextCount; /* number of plain text extensions */ -#endif /* UNUSED */ + long CommentCount, /* number of comments */ + ApplicationCount, /* number of application extensions */ + PlainTextCount; /* number of plain text extensions */ +#endif /* UNUSED */ - char ImageName[256]; /* Image name for the Image */ + char ImageName[256]; /* Image name for the Image */ /* H5 variables */ - hid_t file_id; /* H5 file id */ + hid_t file_id; /* H5 file id */ /* temp counter */ int i; @@ -62,35 +62,36 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName) /* get some data from gifHead */ ImageCount = gifHead.ImageCount; #ifdef UNUSED - CommentCount = (GIFWORD)gifHead.CommentCount; + CommentCount = (GIFWORD)gifHead.CommentCount; ApplicationCount = (GIFWORD)gifHead.ApplicationCount; - PlainTextCount = (GIFWORD)gifHead.PlainTextCount; + PlainTextCount = (GIFWORD)gifHead.PlainTextCount; #endif /* UNUSED */ - if ((file_id = H5Fcreate(HDFName , H5F_ACC_TRUNC , H5P_DEFAULT , H5P_DEFAULT)) < 0) { + if ((file_id = H5Fcreate(HDFName, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { /* error occured opening the HDF File for write */ - fprintf(stderr , "HDF file could not be opened for writing\n"); - fprintf(stderr , "NOTE: GIF file must be present in the same directory as the binary on UNIX systems.\n"); + fprintf(stderr, "HDF file could not be opened for writing\n"); + fprintf(stderr, + "NOTE: GIF file must be present in the same directory as the binary on UNIX systems.\n"); exit(1); } /* first create the global palette if there is one */ if (gifHead.PackedField & 0x80) { /* global palette exists */ - hsize_t dims[2]; /* specify the dimensions of the palette */ + hsize_t dims[2]; /* specify the dimensions of the palette */ /* size of the palette is tablesize (rows) X 3 (columns) */ dims[0] = gifHead.TableSize; dims[1] = 3; /* make a palette */ - if (H5IMmake_palette(file_id,PAL_NAME,dims,(unsigned char *)gifHead.HDFPalette)<0) - return -1; + if (H5IMmake_palette(file_id, PAL_NAME, dims, (unsigned char *)gifHead.HDFPalette) < 0) + return -1; - has_pal=1; + has_pal = 1; } - for(i = 0; i < ImageCount; i++) { - hsize_t dims[2]; /* dimensions for the dataset */ + for (i = 0; i < ImageCount; i++) { + hsize_t dims[2]; /* dimensions for the dataset */ /* get the gifImageDesc */ gifImageDesc = GifMemoryStruct.GifImageDesc[i]; @@ -99,26 +100,24 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName) dims[1] = gifImageDesc->ImageWidth; /* create the image name */ - sprintf(ImageName , "Image%d" , i); + sprintf(ImageName, "Image%d", i); /* write image */ - if (H5IMmake_image_8bit(file_id,ImageName,dims[1],dims[0],(gifImageDesc->Image))<0) - return -1; + if (H5IMmake_image_8bit(file_id, ImageName, dims[1], dims[0], (gifImageDesc->Image)) < 0) + return -1; /* attach the palette to the image dataset */ - if (has_pal) - { - if (H5IMlink_palette(file_id,ImageName,PAL_NAME)<0) + if (has_pal) { + if (H5IMlink_palette(file_id, ImageName, PAL_NAME) < 0) return -1; } } /* close the H5 file */ if (H5Fclose(file_id) < 0) { - fprintf(stderr , "Could not close HDF5 file. Aborting...\n"); + fprintf(stderr, "Could not close HDF5 file. Aborting...\n"); return -1; } return 0; } - diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c index 6b59ea1..8677601 100644 --- a/hl/tools/h5watch/extend_dset.c +++ b/hl/tools/h5watch/extend_dset.c @@ -16,18 +16,18 @@ /* * Extending datasets in WATCH.h5 generated by h5watchgentest.c */ -#define DSET_ONE "DSET_ONE" -#define DSET_TWO "DSET_TWO" -#define DSET_CMPD "DSET_CMPD" -#define DSET_CMPD_ESC "DSET_CMPD_ESC" -#define DSET_CMPD_TWO "DSET_CMPD_TWO" -#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ONE "DSET_ONE" +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" #define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" /* The message sent by this process (extend_dset) to the test script to start "h5watch" */ -#define WRITER_MESSAGE "writer_message" +#define WRITER_MESSAGE "writer_message" /* The message received from the test script to start extending dataset */ -#define READER_MESSAGE "reader_message" +#define READER_MESSAGE "reader_message" /* Size of data buffer */ #define TEST_BUF_SIZE 100 @@ -35,7 +35,6 @@ static herr_t extend_dset_two(const char *file, char *dname, int action1, int action2); static herr_t extend_dset_one(const char *file, char *dname, int action); - /* Data structures for datasets with compound data type */ typedef struct sub22_t { int a; @@ -44,9 +43,9 @@ typedef struct sub22_t { } sub22_t; typedef struct sub2_t { - int a; + int a; sub22_t b; - int c; + int c; } sub2_t; typedef struct sub4_t { @@ -55,7 +54,7 @@ typedef struct sub4_t { } sub4_t; typedef struct set_t { - int field1; + int field1; sub2_t field2; double field3; sub4_t field4; @@ -72,67 +71,67 @@ typedef struct set_t { static herr_t extend_dset_two(const char *file, char *dname, int action1, int action2) { - hid_t fid = -1; /* file id */ - hid_t fapl = -1; /* file access property list id */ - hid_t did = -1; /* dataset id */ - hid_t sid = -1; /* dataspace id */ - hid_t dtid = -1; /* dataset's datatype id */ - int ndims; /* # of dimension sizes */ - unsigned i; /* local index variable */ - hsize_t ext_dims[2]; /* new dimension sizes after extension */ - hsize_t cur_dims[2]; /* current dimension sizes */ - size_t dtype_size; /* size of the dataset's datatype */ - unsigned num_elmts; /* number of elements in the dataset */ - int *ibuf = NULL; /* buffer for storing retrieved elements (integer) */ - set_t *cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ + hid_t fid = -1; /* file id */ + hid_t fapl = -1; /* file access property list id */ + hid_t did = -1; /* dataset id */ + hid_t sid = -1; /* dataspace id */ + hid_t dtid = -1; /* dataset's datatype id */ + int ndims; /* # of dimension sizes */ + unsigned i; /* local index variable */ + hsize_t ext_dims[2]; /* new dimension sizes after extension */ + hsize_t cur_dims[2]; /* current dimension sizes */ + size_t dtype_size; /* size of the dataset's datatype */ + unsigned num_elmts; /* number of elements in the dataset */ + int * ibuf = NULL; /* buffer for storing retrieved elements (integer) */ + set_t * cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ /* Allocate memory */ - if(NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) + if (NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) goto error; - if(NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) + if (NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) goto error; /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Open the file and dataset with SWMR write */ - if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(file, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) goto error; - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto error; /* Send message to the test script to start "h5watch" */ h5_send_message(WRITER_MESSAGE, NULL, NULL); - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto error; - if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(sid)) < 0) goto error; /* Get the size of the dataset's datatype */ - if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) + if ((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) goto error; /* Get the dataset's data type */ - if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) goto error; /* Wait for message from the test script to start extending dataset */ - if(h5_wait_message(READER_MESSAGE) < 0) + if (h5_wait_message(READER_MESSAGE) < 0) goto error; /* sleep to emulate about 2 seconds of application operation */ HDsleep(2); /* Get current dimension sizes */ - if(H5LDget_dset_dims(did, cur_dims) < 0) + if (H5LDget_dset_dims(did, cur_dims) < 0) goto error; /* Set up the new extended dimension sizes */ @@ -140,68 +139,74 @@ extend_dset_two(const char *file, char *dname, int action1, int action2) ext_dims[1] = cur_dims[1] + (hsize_t)action2; /* Extend the dataset */ - if(H5Dset_extent(did, ext_dims) < 0) + if (H5Dset_extent(did, ext_dims) < 0) goto error; num_elmts = 1; - for(i = 0; i < (unsigned)ndims; i++) + for (i = 0; i < (unsigned)ndims; i++) num_elmts *= (unsigned)ext_dims[i]; /* Compound type */ - if(!HDstrcmp(dname, DSET_CMPD_TWO)) { + if (!HDstrcmp(dname, DSET_CMPD_TWO)) { HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); - for(i = 0; i < num_elmts; i++) { - cbuf[i].field1 = action1; - cbuf[i].field2.a = action1; - cbuf[i].field2.c = action1; + for (i = 0; i < num_elmts; i++) { + cbuf[i].field1 = action1; + cbuf[i].field2.a = action1; + cbuf[i].field2.c = action1; cbuf[i].field2.b.a = action1; cbuf[i].field2.b.b = action1; cbuf[i].field2.b.c = action1; - cbuf[i].field3 = action1; - cbuf[i].field4.a = action1; - cbuf[i].field4.b = action1; + cbuf[i].field3 = action1; + cbuf[i].field4.a = action1; + cbuf[i].field4.b = action1; } /* end for */ - /* Write to the dataset */ - if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + /* Write to the dataset */ + if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) goto error; - - } else { /* Integer type */ + } + else { /* Integer type */ HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int)); - for(i = 0; i < num_elmts; i++) + for (i = 0; i < num_elmts; i++) ibuf[i] = action1; /* Write to the dataset */ - if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) goto error; } /* end if-else */ - if(H5Dflush(did) < 0) + if (H5Dflush(did) < 0) goto error; /* Closing */ - if(H5Tclose(dtid) < 0) goto error; - if(H5Dclose(did) < 0) goto error; - if(H5Pclose(fapl) < 0) goto error; - if(H5Fclose(fid) < 0) goto error; + if (H5Tclose(dtid) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Pclose(fapl) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; - if(ibuf) HDfree(ibuf); - if(cbuf) HDfree(cbuf); + if (ibuf) + HDfree(ibuf); + if (cbuf) + HDfree(cbuf); return SUCCEED; error: H5E_BEGIN_TRY - H5Tclose(dtid); - H5Dclose(did); - H5Pclose(fapl); - H5Fclose(fid); + H5Tclose(dtid); + H5Dclose(did); + H5Pclose(fapl); + H5Fclose(fid); H5E_END_TRY - if(ibuf) + if (ibuf) HDfree(ibuf); - if(cbuf) + if (cbuf) HDfree(cbuf); return FAIL; @@ -219,98 +224,98 @@ error: static herr_t extend_dset_one(const char *file, char *dname, int action) { - hid_t fid = -1; /* file id */ - hid_t fapl = -1; /* file access property list id */ - hid_t did = -1; /* dataset id */ - hid_t dtid = -1; /* dataset's datatype id */ - hid_t sid = -1; /* dataspace id */ - hid_t mid = -1; /* memory space id */ - int i; /* local index variable */ - hsize_t cur_dims[1]; /* current dimension sizes */ - hsize_t ext_dims[1]; /* new dimension sizes after extension */ - hsize_t offset[1]; /* starting offsets of appended data */ - hsize_t count[1]; /* dimension sizes of appended data */ - size_t dtype_size; /* size of the dataset's datatype */ - int *ibuf = NULL; /* buffer for storing retrieved elements (integer) */ - set_t *cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ + hid_t fid = -1; /* file id */ + hid_t fapl = -1; /* file access property list id */ + hid_t did = -1; /* dataset id */ + hid_t dtid = -1; /* dataset's datatype id */ + hid_t sid = -1; /* dataspace id */ + hid_t mid = -1; /* memory space id */ + int i; /* local index variable */ + hsize_t cur_dims[1]; /* current dimension sizes */ + hsize_t ext_dims[1]; /* new dimension sizes after extension */ + hsize_t offset[1]; /* starting offsets of appended data */ + hsize_t count[1]; /* dimension sizes of appended data */ + size_t dtype_size; /* size of the dataset's datatype */ + int * ibuf = NULL; /* buffer for storing retrieved elements (integer) */ + set_t * cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ /* Allocate memory */ - if(NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) + if (NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) goto error; - if(NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) + if (NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) goto error; /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Open the file and dataset with SWMR write */ - if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(file, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) goto error; /* Send message to the test script to start "h5watch" */ h5_send_message(WRITER_MESSAGE, NULL, NULL); - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto error; /* Get size of the dataset's datatype */ - if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) + if ((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) goto error; /* Get dataset's datatype */ - if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) goto error; /* Wait for message from the test script to start extending dataset */ - if(h5_wait_message(READER_MESSAGE) < 0) + if (h5_wait_message(READER_MESSAGE) < 0) goto error; /* sleep to emulate about 2 seconds of application operation */ HDsleep(2); /* Get current dimension sizes */ - if(H5LDget_dset_dims(did, cur_dims) < 0) + if (H5LDget_dset_dims(did, cur_dims) < 0) goto error; /* Set up the new extended dimension sizes */ ext_dims[0] = cur_dims[0] + (hsize_t)action; /* Extend the dataset */ - if(H5Dset_extent(did, ext_dims) < 0) + if (H5Dset_extent(did, ext_dims) < 0) goto error; /* Write to the new appended region of the dataset */ - if(action > 0) { + if (action > 0) { /* Select the extended region */ offset[0] = cur_dims[0]; - count[0] = (hsize_t)action; - if((sid = H5Dget_space(did)) < 0) + count[0] = (hsize_t)action; + if ((sid = H5Dget_space(did)) < 0) goto error; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto error; /* Set up memory space and get dataset's datatype */ - if((mid = H5Screate_simple(1, count, NULL)) < 0) + if ((mid = H5Screate_simple(1, count, NULL)) < 0) goto error; /* Initialize data for the extended region of the dataset */ /* Compound type */ - if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); - for(i = 0; i < action; i++) { - cbuf[i].field1 = i + 1; - cbuf[i].field2.a = i + 2; + for (i = 0; i < action; i++) { + cbuf[i].field1 = i + 1; + cbuf[i].field2.a = i + 2; cbuf[i].field2.b.a = i + 2; cbuf[i].field2.b.b = i + 2; cbuf[i].field2.b.c = i + 2; - cbuf[i].field2.c = i + 2; + cbuf[i].field2.c = i + 2; cbuf[i].field3 = i + 3; @@ -319,57 +324,65 @@ extend_dset_one(const char *file, char *dname, int action) } /* end for */ /* Write to the extended region of the dataset */ - if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0) + if (H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0) goto error; - } else { /* Integer type */ + } + else { /* Integer type */ HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int)); - for(i = 0; i < action; i++) + for (i = 0; i < action; i++) ibuf[i] = (int)i; /* Write to the extended region of the dataset */ - if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0) + if (H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0) goto error; } /* end if-else */ /* Closing */ - if(H5Sclose(sid) < 0) goto error; - if(H5Sclose(mid) < 0) goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Sclose(mid) < 0) + goto error; } /* end if */ - if(H5Dflush(did) < 0) + if (H5Dflush(did) < 0) goto error; /* Closing */ - if(H5Tclose(dtid) < 0) goto error; - if(H5Dclose(did) < 0) goto error; - if(H5Pclose(fapl) < 0) goto error; - if(H5Fclose(fid) < 0) goto error; + if (H5Tclose(dtid) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Pclose(fapl) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; - if(ibuf) HDfree(ibuf); - if(cbuf) HDfree(cbuf); + if (ibuf) + HDfree(ibuf); + if (cbuf) + HDfree(cbuf); return SUCCEED; error: H5E_BEGIN_TRY - H5Sclose(sid); - H5Sclose(mid); - H5Tclose(dtid); - H5Dclose(did); - H5Pclose(fapl); - H5Fclose(fid); + H5Sclose(sid); + H5Sclose(mid); + H5Tclose(dtid); + H5Dclose(did); + H5Pclose(fapl); + H5Fclose(fid); H5E_END_TRY - if(ibuf) + if (ibuf) HDfree(ibuf); - if(cbuf) + if (cbuf) HDfree(cbuf); return FAIL; } /* end extend_dset_one() */ - /* *********************************************************************** * @@ -383,32 +396,33 @@ main(int argc, const char *argv[]) { char *dname = NULL; char *fname = NULL; - int action1, action2; + int action1, action2; - if(argc != 5) { + if (argc != 5) { HDfprintf(stderr, "Should have file name, dataset name, and the extended amount...\n"); goto error; } /* end if */ /* Get the dataset name to be extended */ - fname = HDstrdup(argv[1]); - dname = HDstrdup(argv[2]); + fname = HDstrdup(argv[1]); + dname = HDstrdup(argv[2]); action1 = HDatoi(argv[3]); action2 = HDatoi(argv[4]); - if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { - if(extend_dset_one(fname, dname, action1) < 0) + if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if (extend_dset_one(fname, dname, action1) < 0) goto error; - } else if(!HDstrcmp(dname, DSET_ONE) || - !HDstrcmp(dname, DSET_ALLOC_LATE) || - !HDstrcmp(dname, DSET_ALLOC_EARLY)) { - if(extend_dset_one(fname, dname, action1) < 0) + } + else if (!HDstrcmp(dname, DSET_ONE) || !HDstrcmp(dname, DSET_ALLOC_LATE) || + !HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if (extend_dset_one(fname, dname, action1) < 0) goto error; - } else if(!HDstrcmp(dname, DSET_TWO) || - !HDstrcmp(dname, DSET_CMPD_TWO)) { - if(extend_dset_two(fname, dname, action1, action2) < 0) + } + else if (!HDstrcmp(dname, DSET_TWO) || !HDstrcmp(dname, DSET_CMPD_TWO)) { + if (extend_dset_two(fname, dname, action1, action2) < 0) goto error; - } else { + } + else { HDfprintf(stdout, "Dataset cannot be extended...\n"); goto error; } /* end if-else */ @@ -416,9 +430,9 @@ main(int argc, const char *argv[]) HDexit(EXIT_SUCCESS); error: - if(dname) + if (dname) HDfree(dname); - if(fname) + if (fname) HDfree(fname); HDexit(EXIT_FAILURE); } /* end main() */ diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c index bda0d40..2d5ff15 100644 --- a/hl/tools/h5watch/h5watch.c +++ b/hl/tools/h5watch/h5watch.c @@ -18,10 +18,9 @@ /* * Note: This tool used private routine */ -#define PROGRAMNAME "h5watch" /* Name of tool */ -#define FIELD_SEP "," /* nested field separator */ -#define DEFAULT_RETRY 50 /* number of times to try opening the file */ - +#define PROGRAMNAME "h5watch" /* Name of tool */ +#define FIELD_SEP "," /* nested field separator */ +#define DEFAULT_RETRY 50 /* number of times to try opening the file */ /* * Note:(see comments in hl/src/H5LDprivate.h) @@ -29,80 +28,57 @@ * This tool uses H5LD_memb_t data structure declared in H5LDprivate.h */ -const char *progname = "h5watch"; /* tool name */ -static char *g_list_of_fields = NULL; /* command line input for "list_of_fields" */ -static char *g_dup_fields = NULL; /* copy of "list_of_fields" */ -static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */ +const char * progname = "h5watch"; /* tool name */ +static char * g_list_of_fields = NULL; /* command line input for "list_of_fields" */ +static char * g_dup_fields = NULL; /* copy of "list_of_fields" */ +static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */ -static hbool_t g_monitor_size_only = FALSE; /* monitor changes in dataset dimension sizes */ -static unsigned g_polling_interval = 1; /* polling interval to check appended data */ +static hbool_t g_monitor_size_only = FALSE; /* monitor changes in dataset dimension sizes */ +static unsigned g_polling_interval = 1; /* polling interval to check appended data */ -static hbool_t g_label = FALSE; /* label compound values */ -static int g_display_width = 80; /* output width in characters */ -static hbool_t g_simple_output = FALSE; /* make output more machine-readable */ -static unsigned g_retry = DEFAULT_RETRY; /* # of times to try opening the file if somehow file is unstable */ -static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */ -static hbool_t g_user_interrupt = FALSE; /* Flag to indicate that user interrupted execution */ +static hbool_t g_label = FALSE; /* label compound values */ +static int g_display_width = 80; /* output width in characters */ +static hbool_t g_simple_output = FALSE; /* make output more machine-readable */ +static unsigned g_retry = DEFAULT_RETRY; /* # of times to try opening the file if somehow file is unstable */ +static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */ +static hbool_t g_user_interrupt = FALSE; /* Flag to indicate that user interrupted execution */ static herr_t doprint(hid_t did, hsize_t *start, hsize_t *block, int rank); -static herr_t slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, - hsize_t *start, hsize_t *block, int rank, int subrank); +static herr_t slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, + int rank, int subrank); static herr_t monitor_dataset(hid_t fid, char *dsetname); static herr_t process_cmpd_fields(hid_t fid, char *dsetname); static herr_t check_dataset(hid_t fid, char *dsetname); -static void leave(int ret); -static void usage(const char *prog); -static void parse_command_line(int argc, const char *argv[]); - +static void leave(int ret); +static void usage(const char *prog); +static void parse_command_line(int argc, const char *argv[]); /* * Command-line options: The user can only specify long-named parameters. * The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -static const char *s_opts ="?"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - { "dim", no_arg, 'd' }, - { "di", no_arg, 'd' }, - { "label", no_arg, 'l' }, - { "labe", no_arg, 'l' }, - { "lab", no_arg, 'l' }, - { "la", no_arg, 'l' }, - { "simple", no_arg, 'S' }, - { "simpl", no_arg, 'S' }, - { "simp", no_arg, 'S' }, - { "sim", no_arg, 'S' }, - { "si", no_arg, 'S' }, - { "hexdump", no_arg, 'x' }, - { "hexdum", no_arg, 'x' }, - { "hexdu", no_arg, 'x' }, - { "hexd", no_arg, 'x' }, - { "hex", no_arg, 'x' }, - { "width", require_arg, 'w' }, - { "widt", require_arg, 'w' }, - { "wid", require_arg, 'w' }, - { "wi", require_arg, 'w' }, - { "polling", require_arg, 'p' }, - { "pollin", require_arg, 'p' }, - { "polli", require_arg, 'p' }, - { "poll", require_arg, 'p' }, - { "pol", require_arg, 'p' }, - { "po", require_arg, 'p' }, - { "fields", require_arg, 'f' }, - { "field", require_arg, 'f' }, - { "fiel", require_arg, 'f' }, - { "fie", require_arg, 'f' }, - { "fi", require_arg, 'f' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, - { "ver", no_arg, 'V' }, - { "ve", no_arg, 'V' }, - { NULL, 0, '\0' } -}; +static const char * s_opts = "?"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, + {"dim", no_arg, 'd'}, {"di", no_arg, 'd'}, + {"label", no_arg, 'l'}, {"labe", no_arg, 'l'}, + {"lab", no_arg, 'l'}, {"la", no_arg, 'l'}, + {"simple", no_arg, 'S'}, {"simpl", no_arg, 'S'}, + {"simp", no_arg, 'S'}, {"sim", no_arg, 'S'}, + {"si", no_arg, 'S'}, {"hexdump", no_arg, 'x'}, + {"hexdum", no_arg, 'x'}, {"hexdu", no_arg, 'x'}, + {"hexd", no_arg, 'x'}, {"hex", no_arg, 'x'}, + {"width", require_arg, 'w'}, {"widt", require_arg, 'w'}, + {"wid", require_arg, 'w'}, {"wi", require_arg, 'w'}, + {"polling", require_arg, 'p'}, {"pollin", require_arg, 'p'}, + {"polli", require_arg, 'p'}, {"poll", require_arg, 'p'}, + {"pol", require_arg, 'p'}, {"po", require_arg, 'p'}, + {"fields", require_arg, 'f'}, {"field", require_arg, 'f'}, + {"fiel", require_arg, 'f'}, {"fie", require_arg, 'f'}, + {"fi", require_arg, 'f'}, {"version", no_arg, 'V'}, + {"versio", no_arg, 'V'}, {"versi", no_arg, 'V'}, + {"vers", no_arg, 'V'}, {"ver", no_arg, 'V'}, + {"ve", no_arg, 'V'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: doprint() @@ -121,29 +97,29 @@ static struct long_options l_opts[] = { static herr_t doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) { - h5tools_context_t ctx; /* print context */ - h5tool_format_t info; /* Format info for the tools library */ - static char fmt_double[16], fmt_float[16]; /* Format info */ - struct subset_t subset; /* Subsetting info */ - hsize_t ss_start[H5S_MAX_RANK]; /* Info for hyperslab */ - hsize_t ss_stride[H5S_MAX_RANK]; /* Info for hyperslab */ - hsize_t ss_block[H5S_MAX_RANK]; /* Info for hyperslab */ - hsize_t ss_count[H5S_MAX_RANK]; /* Info for hyperslab */ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t info; /* Format info for the tools library */ + static char fmt_double[16], fmt_float[16]; /* Format info */ + struct subset_t subset; /* Subsetting info */ + hsize_t ss_start[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_stride[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_block[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_count[H5S_MAX_RANK]; /* Info for hyperslab */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ /* Subsetting information for the tools library printing routines */ - subset.start.data = ss_start; + subset.start.data = ss_start; subset.stride.data = ss_stride; - subset.block.data = ss_block; - subset.count.data = ss_count; + subset.block.data = ss_block; + subset.count.data = ss_count; /* Initialize subsetting information */ - for(i = 0; i < rank; i++) { + for (i = 0; i < rank; i++) { subset.stride.data[i] = 1; - subset.count.data[i] = 1; - subset.start.data[i] = start[i]; - subset.block.data[i] = block[i]; + subset.count.data[i] = 1; + subset.start.data[i] = start[i]; + subset.block.data[i] = block[i]; } /* end for */ HDmemset(&ctx, 0, sizeof(ctx)); @@ -152,13 +128,13 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) /* Set to all default values and then override */ HDmemset(&info, 0, sizeof info); - if(g_simple_output) { - info.idx_fmt = ""; - info.line_ncols = 65535; /*something big*/ - info.line_per_line = 1; + if (g_simple_output) { + info.idx_fmt = ""; + info.line_ncols = 65535; /*something big*/ + info.line_per_line = 1; info.line_multi_new = 0; - info.line_pre = " "; - info.line_cont = " "; + info.line_pre = " "; + info.line_cont = " "; info.arr_pre = ""; info.arr_suf = ""; @@ -169,18 +145,18 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) info.cmpd_sep = " "; /* The "fields" selected by the user */ - info.cmpd_listv = (const struct H5LD_memb_t * const *)g_listv; + info.cmpd_listv = (const struct H5LD_memb_t *const *)g_listv; - if(g_label) + if (g_label) info.cmpd_name = "%s="; - info.elmt_suf1 = " "; + info.elmt_suf1 = " "; info.str_locale = ESCAPE_HTML; - - } else { + } + else { info.idx_fmt = "(%s)"; - if(!g_display_width) { - info.line_ncols = 65535; + if (!g_display_width) { + info.line_ncols = 65535; info.line_per_line = 1; } /* end if */ else @@ -189,11 +165,11 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) info.line_multi_new = 1; /* The "fields" selected by the user */ - info.cmpd_listv = (const struct H5LD_memb_t * const *)g_listv; - if(g_label) + info.cmpd_listv = (const struct H5LD_memb_t *const *)g_listv; + if (g_label) info.cmpd_name = "%s="; - info.line_pre = " %s "; - info.line_cont = " %s "; + info.line_pre = " %s "; + info.line_cont = " %s "; info.str_repeat = 8; } /* end else */ @@ -203,25 +179,25 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) sprintf(fmt_double, "%%1.%dg", DBL_DIG); info.fmt_double = fmt_double; - info.dset_format = "DSET-%s "; + info.dset_format = "DSET-%s "; info.dset_hidefileno = 0; - info.obj_format = "-%lu:%" PRIuHADDR; + info.obj_format = "-%lu:%" PRIuHADDR; info.obj_hidefileno = 0; info.dset_blockformat_pre = "%sBlk%lu: "; - info.dset_ptformat_pre = "%sPt%lu: "; + info.dset_ptformat_pre = "%sPt%lu: "; info.line_indent = ""; - if(g_display_hex) { + if (g_display_hex) { /* Print all data in hexadecimal format if the `-x' or `--hexdump' * command line switch was given. */ info.raw = TRUE; } /* end if */ /* Print the values. */ - if((ret_value = h5tools_dump_dset(stdout, &info, &ctx, did)) < 0) + if ((ret_value = h5tools_dump_dset(stdout, &info, &ctx, did)) < 0) error_msg("unable to print data\n"); HDfprintf(stdout, "\n"); @@ -251,25 +227,26 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) *------------------------------------------------------------------------- */ static herr_t -slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, int rank, int subrank) +slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, int rank, + int subrank) { - int i; /* Local index variable */ - int ind; /* Index for the current rank */ + int i; /* Local index variable */ + int ind; /* Index for the current rank */ herr_t ret_value = SUCCEED; /* Return value */ ind = rank - subrank; - if((subrank - 1) > 0) { + if ((subrank - 1) > 0) { /* continue onto the next dimension */ - for (i = 0; i < (hssize_t)MIN(prev_dims[ind], cur_dims[ind]); i++){ + for (i = 0; i < (hssize_t)MIN(prev_dims[ind], cur_dims[ind]); i++) { start[ind] = (hsize_t)i; - if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, rank, subrank-1)) < 0) + if ((ret_value = slicendump(did, prev_dims, cur_dims, start, block, rank, subrank - 1)) < 0) goto done; } /* end for */ - } /* end if */ + } /* end if */ /* this dimension remains the same or shrinking */ - if(cur_dims[ind] <= prev_dims[ind]) + if (cur_dims[ind] <= prev_dims[ind]) goto done; /* select first the slice for the faster changing dimension */ @@ -277,7 +254,7 @@ slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsi start[ind] = prev_dims[ind]; block[ind] = cur_dims[ind] - prev_dims[ind]; - for(i = ind + 1; i < rank; i++){ + for (i = ind + 1; i < rank; i++) { start[i] = 0; block[i] = cur_dims[i]; } /* end for */ @@ -289,7 +266,6 @@ done: return ret_value; } /* end slicendump() */ - /*------------------------------------------------------------------------- * Function: monitor_dataset * @@ -309,30 +285,30 @@ done: static herr_t monitor_dataset(hid_t fid, char *dsetname) { - hid_t did; /* dataset id */ - hid_t sid; /* dataspace id */ - int ndims; /* # of dimensions in the dataspace */ - int i, u; /* local index variable */ - hsize_t prev_dims[H5S_MAX_RANK]; /* current dataspace dimensions */ - hsize_t cur_dims[H5S_MAX_RANK]; /* previous dataspace dimensions */ - herr_t ret_value = SUCCEED; /* return value */ + hid_t did; /* dataset id */ + hid_t sid; /* dataspace id */ + int ndims; /* # of dimensions in the dataspace */ + int i, u; /* local index variable */ + hsize_t prev_dims[H5S_MAX_RANK]; /* current dataspace dimensions */ + hsize_t cur_dims[H5S_MAX_RANK]; /* previous dataspace dimensions */ + herr_t ret_value = SUCCEED; /* return value */ HDfprintf(stdout, "Monitoring dataset %s...\n", dsetname); /* Open the dataset for minitoring */ - if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { error_msg("error in opening dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } - if((sid = H5Dget_space(did)) < 0) { + if ((sid = H5Dget_space(did)) < 0) { error_msg("error in getting dataspace id for dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Get the dataset's dimension sizes */ - if((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) { + if ((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) { error_msg("unable to get dimensions sizes for \"%s\"\n", dsetname); ret_value = FAIL; goto done; @@ -340,58 +316,59 @@ monitor_dataset(hid_t fid, char *dsetname) HDfflush(stdout); /* Loop until an error occurs or the user interrupts execution */ - while(!g_user_interrupt) { + while (!g_user_interrupt) { /* Refreshes the dataset */ - if(H5Drefresh(did) < 0) { + if (H5Drefresh(did) < 0) { ret_value = FAIL; goto done; } /* Get the dataset's current dimension sizes */ - if(H5LDget_dset_dims(did, cur_dims) < 0) { + if (H5LDget_dset_dims(did, cur_dims) < 0) { error_msg("unable to get dimension sizes for \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Check the dimension sizes */ - for(i = 0; i < ndims; i++) - if(cur_dims[i] != prev_dims[i]) + for (i = 0; i < ndims; i++) + if (cur_dims[i] != prev_dims[i]) break; /* at least one dimension has changed */ - if(i != ndims) { + if (i != ndims) { /* Printing changes in dimension sizes */ - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { HDfprintf(stdout, "dimension %u: %Hu->%Hu", (unsigned)u, prev_dims[u], cur_dims[u]); - if(cur_dims[u] > prev_dims[u]) + if (cur_dims[u] > prev_dims[u]) HDfprintf(stdout, " (increases)\n"); - else if(cur_dims[u] < prev_dims[u]) + else if (cur_dims[u] < prev_dims[u]) HDfprintf(stdout, " (decreases)\n"); else HDfprintf(stdout, " (unchanged)\n"); } /* Printing elements appended to the dataset if there is */ - if(!g_monitor_size_only) { + if (!g_monitor_size_only) { /* See if at least one dimension size has increased */ - for(u = 0; u < ndims; u++) { - int j; + for (u = 0; u < ndims; u++) { + int j; hsize_t start[H5S_MAX_RANK]; hsize_t block[H5S_MAX_RANK]; /* Print the new appended data to the dataset */ - if(cur_dims[u] > prev_dims[u]) { + if (cur_dims[u] > prev_dims[u]) { HDfprintf(stdout, " Data:\n"); - for(j = 0; j < ndims; j++) { + for (j = 0; j < ndims; j++) { start[j] = 0; block[j] = 1; } - if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) < 0) + if ((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) < + 0) goto done; break; } @@ -412,10 +389,10 @@ monitor_dataset(hid_t fid, char *dsetname) done: /* Closing */ H5E_BEGIN_TRY - H5Dclose(did); + H5Dclose(did); H5E_END_TRY - return(ret_value); + return (ret_value); } /* monitor_dataset() */ /*------------------------------------------------------------------------- @@ -433,53 +410,53 @@ done: static herr_t process_cmpd_fields(hid_t fid, char *dsetname) { - hid_t did=-1; /* dataset id */ - hid_t dtid=-1, tid=-1; /* dataset's data type id */ + hid_t did = -1; /* dataset id */ + hid_t dtid = -1, tid = -1; /* dataset's data type id */ size_t len; /* number of comma-separated fields in "g_list_of_fields" */ herr_t ret_value = SUCCEED; /* Return value */ HDassert(g_list_of_fields && *g_list_of_fields); /* Open the dataset */ - if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { error_msg("error in opening dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Get the dataset's datatype */ - if(((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) { + if (((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) { error_msg("error in getting dataset's datatype\n"); ret_value = FAIL; goto done; } /* Check to make sure that the dataset's datatype is compound type */ - if(H5Tget_class(dtid) != H5T_COMPOUND) { + if (H5Tget_class(dtid) != H5T_COMPOUND) { error_msg("dataset should be compound type for \n"); ret_value = FAIL; goto done; } /* Make a copy of "g_list_of_fields" */ - if((g_dup_fields = HDstrdup(g_list_of_fields)) == NULL) { + if ((g_dup_fields = HDstrdup(g_list_of_fields)) == NULL) { error_msg("error in duplicating g_list_of_fields\n"); ret_value = FAIL; goto done; } /* Estimate the number of comma-separated fields in "g_list of_fields" */ - len = HDstrlen(g_list_of_fields)/2 + 2; + len = HDstrlen(g_list_of_fields) / 2 + 2; /* Allocate memory for a list vector of H5LD_memb_t structures to store "g_list_of_fields" info */ - if((g_listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) { + if ((g_listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) { error_msg("error in allocating memory for H5LD_memb_t\n"); ret_value = FAIL; goto done; } /* Process and store info for "g_listv" */ - if(H5LD_construct_vector(g_dup_fields, g_listv, tid) < 0) { + if (H5LD_construct_vector(g_dup_fields, g_listv, tid) < 0) { error_msg("error in processing \n"); ret_value = FAIL; goto done; @@ -489,14 +466,13 @@ process_cmpd_fields(hid_t fid, char *dsetname) done: /* Closing */ H5E_BEGIN_TRY - H5Tclose(dtid); - H5Tclose(tid); - H5Dclose(did); + H5Tclose(dtid); + H5Tclose(tid); + H5Dclose(did); H5E_END_TRY - return(ret_value); + return (ret_value); } /* process_cmpd_fields() */ - /*------------------------------------------------------------------------- * Function: check_dataset * @@ -513,44 +489,44 @@ done: static herr_t check_dataset(hid_t fid, char *dsetname) { - hid_t did=-1; /* Dataset id */ - hid_t dcp=-1; /* Dataset creation property */ - hid_t sid=-1; /* Dataset's dataspace id */ - int ndims; /* # of dimensions in the dataspace */ - unsigned u; /* Local index variable */ - hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */ - hsize_t max_dims[H5S_MAX_RANK]; /* maximum size of dataspace dimensions */ - hbool_t unlim_max_dims = FALSE; /* whether dataset has unlimited or max. dimension setting */ - void *edata; - H5E_auto2_t func; - H5D_layout_t layout; - herr_t ret_value = SUCCEED; /* Return value */ + hid_t did = -1; /* Dataset id */ + hid_t dcp = -1; /* Dataset creation property */ + hid_t sid = -1; /* Dataset's dataspace id */ + int ndims; /* # of dimensions in the dataspace */ + unsigned u; /* Local index variable */ + hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */ + hsize_t max_dims[H5S_MAX_RANK]; /* maximum size of dataspace dimensions */ + hbool_t unlim_max_dims = FALSE; /* whether dataset has unlimited or max. dimension setting */ + void * edata; + H5E_auto2_t func; + H5D_layout_t layout; + herr_t ret_value = SUCCEED; /* Return value */ /* Disable error reporting */ H5Eget_auto2(H5E_DEFAULT, &func, &edata); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Open the dataset */ - if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { + if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) { error_msg("unable to open dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Get dataset's creation property list */ - if((dcp = H5Dget_create_plist(did)) < 0) { + if ((dcp = H5Dget_create_plist(did)) < 0) { error_msg("unable to get dataset's creation property list \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Query dataset's layout; the layout should be chunked or virtual */ - if((layout = H5Pget_layout(dcp)) < 0) { + if ((layout = H5Pget_layout(dcp)) < 0) { error_msg("unable to get dataset layout \"%s\"\n", dsetname); ret_value = FAIL; goto done; } - if(layout != H5D_CHUNKED && layout != H5D_VIRTUAL) { + if (layout != H5D_CHUNKED && layout != H5D_VIRTUAL) { error_msg("\"%s\" should be a chunked or virtual dataset\n", dsetname); ret_value = FAIL; goto done; @@ -560,27 +536,27 @@ check_dataset(hid_t fid, char *dsetname) HDmemset(max_dims, 0, sizeof max_dims); /* Get dataset's dataspace */ - if((sid = H5Dget_space(did)) < 0) { + if ((sid = H5Dget_space(did)) < 0) { error_msg("can't get dataset's dataspace\"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Get dimension size of dataset's dataspace */ - if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, max_dims)) < 0) { + if ((ndims = H5Sget_simple_extent_dims(sid, cur_dims, max_dims)) < 0) { error_msg("can't get dataspace dimensions for dataset \"%s\"\n", dsetname); ret_value = FAIL; goto done; } /* Check whether dataset has unlimited dimension or max. dimension setting */ - for(u = 0; u < (unsigned)ndims; u++) - if(max_dims[u] == H5S_UNLIMITED || cur_dims[u] != max_dims[u]) { - unlim_max_dims = TRUE; - break; - } + for (u = 0; u < (unsigned)ndims; u++) + if (max_dims[u] == H5S_UNLIMITED || cur_dims[u] != max_dims[u]) { + unlim_max_dims = TRUE; + break; + } - if(!unlim_max_dims) { + if (!unlim_max_dims) { error_msg("\"%s\" should have unlimited or max. dimension setting\n", dsetname); ret_value = FAIL; } @@ -590,15 +566,14 @@ done: /* Closing */ H5E_BEGIN_TRY - H5Sclose(sid); - H5Pclose(dcp); - H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcp); + H5Dclose(did); H5E_END_TRY - return(ret_value); + return (ret_value); } /* check_dataset() */ - /*------------------------------------------------------------------------- * Function: leave * @@ -619,7 +594,6 @@ leave(int ret) exit(ret); } - /*------------------------------------------------------------------------- * Function: usage * @@ -647,10 +621,12 @@ usage(const char *prog) HDfprintf(stdout, " A value of 0 sets the number of columns to the\n"); HDfprintf(stdout, " maximum (65535). The default width is 80 columns.\n"); HDfprintf(stdout, " --polling=N Set the polling interval to N (in seconds) when the\n"); - HDfprintf(stdout, " dataset will be checked for appended data. The default\n"); + HDfprintf(stdout, + " dataset will be checked for appended data. The default\n"); HDfprintf(stdout, " polling interval is 1.\n"); HDfprintf(stdout, " --fields=\n"); - HDfprintf(stdout, " Display data for the fields specified in \n"); + HDfprintf(stdout, + " Display data for the fields specified in \n"); HDfprintf(stdout, " for a compound data type. can be\n"); HDfprintf(stdout, " specified as follows:\n"); HDfprintf(stdout, " 1) A comma-separated list of field names in a\n"); @@ -660,7 +636,8 @@ usage(const char *prog) HDfprintf(stdout, " 2) A single field name in a compound data type.\n"); HDfprintf(stdout, " Can use this option multiple times.\n"); HDfprintf(stdout, " Note that backslash is the escape character to avoid\n"); - HDfprintf(stdout, " characters in field names that conflict with the tool's\n"); + HDfprintf(stdout, + " characters in field names that conflict with the tool's\n"); HDfprintf(stdout, " separators.\n"); HDfprintf(stdout, "\n"); HDfprintf(stdout, " OBJECT is specified as [//]\n"); @@ -669,11 +646,11 @@ usage(const char *prog) HDfprintf(stdout, " Path separated by slashes to the specified dataset\n"); HDfprintf(stdout, " Name of the dataset\n"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, " User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM).\n"); + HDfprintf(stdout, + " User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM).\n"); } /* usage() */ - /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -689,10 +666,10 @@ usage(const char *prog) static void parse_command_line(int argc, const char *argv[]) { - int opt; /* Command line option */ + int opt; /* Command line option */ int tmp; - /* no arguments */ + /* no arguments */ if (argc == 1) { usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -701,80 +678,77 @@ parse_command_line(int argc, const char *argv[]) /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { - case '?': - case 'h': /* --help */ - usage(h5tools_getprogname()); - leave(EXIT_SUCCESS); - break; - - case 'V': /* --version */ - print_version(progname); - leave(EXIT_SUCCESS); - break; - - case 'w': /* --width=N */ - g_display_width = (int)HDstrtol(opt_arg, NULL, 0); - if(g_display_width < 0) { + case '?': + case 'h': /* --help */ usage(h5tools_getprogname()); - leave(EXIT_FAILURE); - } - break; + leave(EXIT_SUCCESS); + break; - case 'd': /* --dim */ - g_monitor_size_only = TRUE; - break; + case 'V': /* --version */ + print_version(progname); + leave(EXIT_SUCCESS); + break; - case 'S': /* --simple */ - g_simple_output = TRUE; - break; + case 'w': /* --width=N */ + g_display_width = (int)HDstrtol(opt_arg, NULL, 0); + if (g_display_width < 0) { + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + break; - case 'l': /* --label */ - g_label = TRUE; - break; + case 'd': /* --dim */ + g_monitor_size_only = TRUE; + break; - case 'p': /* --polling=N */ - /* g_polling_interval = HDstrtod(opt_arg, NULL); */ - if((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) { - usage(h5tools_getprogname()); - leave(EXIT_FAILURE); - } - g_polling_interval = (unsigned)tmp; - break; + case 'S': /* --simple */ + g_simple_output = TRUE; + break; + + case 'l': /* --label */ + g_label = TRUE; + break; - case 'f': /* --fields= */ - if(g_list_of_fields == NULL) { - if((g_list_of_fields = HDstrdup(opt_arg)) == NULL) { - error_msg("memory allocation failed (file %s:line %d)\n", - __FILE__, __LINE__); + case 'p': /* --polling=N */ + /* g_polling_interval = HDstrtod(opt_arg, NULL); */ + if ((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) { + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } - } else { - char *str; + g_polling_interval = (unsigned)tmp; + break; - if((str = HDstrdup(opt_arg)) == NULL) { - error_msg("memory allocation failed (file %s:line %d)\n", - __FILE__, __LINE__); - leave(EXIT_FAILURE); + case 'f': /* --fields= */ + if (g_list_of_fields == NULL) { + if ((g_list_of_fields = HDstrdup(opt_arg)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); + leave(EXIT_FAILURE); + } } - if((g_list_of_fields = (char *)HDrealloc(g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) { - error_msg("memory allocation failed (file %s:line %d)\n", - __FILE__, __LINE__); - leave(EXIT_FAILURE); + else { + char *str; + if ((str = HDstrdup(opt_arg)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); + leave(EXIT_FAILURE); + } + if ((g_list_of_fields = (char *)HDrealloc( + g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) { + error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); + leave(EXIT_FAILURE); + } + HDstrcat(g_list_of_fields, FIELD_SEP); + HDstrcat(g_list_of_fields, str); } - HDstrcat(g_list_of_fields, FIELD_SEP); - HDstrcat(g_list_of_fields, str); - } - break; + break; - default: - usage(h5tools_getprogname()); - leave(EXIT_FAILURE); + default: + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); } } - /* check for object to be processed */ if (argc <= opt_ind) { error_msg("missing dataset name\n"); @@ -783,7 +757,6 @@ parse_command_line(int argc, const char *argv[]) } } /* parse_command_line() */ - /*------------------------------------------------------------------------- * Function: catch_signal * @@ -796,13 +769,13 @@ parse_command_line(int argc, const char *argv[]) * *------------------------------------------------------------------------- */ -static void catch_signal(int H5_ATTR_UNUSED signo) +static void +catch_signal(int H5_ATTR_UNUSED signo) { /* Set the flag to get out of the main loop */ g_user_interrupt = TRUE; } /* catch_signal() */ - /*------------------------------------------------------------------------- * Function: main * @@ -818,12 +791,12 @@ static void catch_signal(int H5_ATTR_UNUSED signo) int main(int argc, const char *argv[]) { - char drivername[50]; /* VFD name */ - char *fname = NULL; /* File name */ - char *dname = NULL; /* Dataset name */ - char *x; /* Temporary string pointer */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ + char drivername[50]; /* VFD name */ + char *fname = NULL; /* File name */ + char *dname = NULL; /* Dataset name */ + char *x; /* Temporary string pointer */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ /* Set up tool name and exit status */ h5tools_setprogname(PROGRAMNAME); @@ -833,13 +806,13 @@ main(int argc, const char *argv[]) h5tools_init(); /* To exit from h5watch for SIGTERM signal */ - if(HDsignal(SIGTERM, catch_signal) == SIG_ERR) { + if (HDsignal(SIGTERM, catch_signal) == SIG_ERR) { error_msg("An error occurred while setting a signal handler.\n"); leave(EXIT_FAILURE); } /* To exit from h5watch for SIGINT signal */ - if(HDsignal(SIGINT, catch_signal) == SIG_ERR) { + if (HDsignal(SIGINT, catch_signal) == SIG_ERR) { error_msg("An error occurred while setting a signal handler.\n"); leave(EXIT_FAILURE); } @@ -847,7 +820,7 @@ main(int argc, const char *argv[]) /* parse command line options */ parse_command_line(argc, argv); - if(argc <= opt_ind) { + if (argc <= opt_ind) { error_msg("missing dataset name\n"); usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -871,60 +844,61 @@ main(int argc, const char *argv[]) * then there must have been something wrong with the file (perhaps it * doesn't exist). */ - if((fname = HDstrdup(argv[opt_ind])) == NULL) { + if ((fname = HDstrdup(argv[opt_ind])) == NULL) { error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; } /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { h5tools_setstatus(EXIT_FAILURE); goto done; } /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { h5tools_setstatus(EXIT_FAILURE); goto done; } do { - while(fname && *fname) { - fid = h5tools_fopen(fname, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl, FALSE, drivername, sizeof drivername); + while (fname && *fname) { + fid = h5tools_fopen(fname, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl, FALSE, drivername, + sizeof drivername); - if(fid >= 0) { + if (fid >= 0) { HDfprintf(stdout, "Opened \"%s\" with %s driver.\n", fname, drivername); break; /*success*/ - } /* end if */ + } /* end if */ /* Shorten the file name; lengthen the object name */ - x = dname; + x = dname; dname = HDstrrchr(fname, '/'); - if(x) + if (x) *x = '/'; - if(!dname) + if (!dname) break; *dname = '\0'; } /* end while */ - /* Try opening the file again if somehow unstable */ - } while(g_retry-- > 0 && fid == FAIL); + /* Try opening the file again if somehow unstable */ + } while (g_retry-- > 0 && fid == FAIL); - if(fid < 0) { + if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); goto done; } - if(!dname) { + if (!dname) { error_msg("no dataset specified\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } else { *dname = '/'; - x = dname; - if((dname = HDstrdup(dname)) == NULL) { + x = dname; + if ((dname = HDstrdup(dname)) == NULL) { error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -932,13 +906,13 @@ main(int argc, const char *argv[]) else { *x = '\0'; /* Validate dataset */ - if(check_dataset(fid, dname) < 0) { + if (check_dataset(fid, dname) < 0) { h5tools_setstatus(EXIT_FAILURE); goto done; } /* Validate input "fields" */ - else if(g_list_of_fields && *g_list_of_fields) { - if(process_cmpd_fields(fid, dname) < 0) { + else if (g_list_of_fields && *g_list_of_fields) { + if (process_cmpd_fields(fid, dname) < 0) { h5tools_setstatus(EXIT_FAILURE); goto done; } @@ -947,33 +921,33 @@ main(int argc, const char *argv[]) } /* If everything is fine, start monitoring the datset */ - if(h5tools_getstatus() != EXIT_FAILURE) - if(monitor_dataset(fid, dname) < 0) + if (h5tools_getstatus() != EXIT_FAILURE) + if (monitor_dataset(fid, dname) < 0) h5tools_setstatus(EXIT_FAILURE); done: /* Free spaces */ - if(fname) + if (fname) HDfree(fname); - if(dname) + if (dname) HDfree(dname); - if(g_list_of_fields) + if (g_list_of_fields) HDfree(g_list_of_fields); - if(g_listv) { + if (g_listv) { H5LD_clean_vector(g_listv); HDfree(g_listv); } - if(g_dup_fields) + if (g_dup_fields) HDfree(g_dup_fields); /* Close the file access property list */ - if(fapl >= 0 && H5Pclose(fapl) < 0) { + if (fapl >= 0 && H5Pclose(fapl) < 0) { error_msg("unable to close file access property list\n"); h5tools_setstatus(EXIT_FAILURE); } /* Close the file */ - if(fid >= 0 && H5Fclose(fid) < 0) { + if (fid >= 0 && H5Fclose(fid) < 0) { error_msg("unable to close file\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -981,4 +955,3 @@ done: /* exit */ leave(h5tools_getstatus()); } /* main() */ - diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c index 19c9876..255ad41 100644 --- a/hl/tools/h5watch/h5watchgentest.c +++ b/hl/tools/h5watch/h5watchgentest.c @@ -33,26 +33,26 @@ * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR */ -#define ONE_DIMS0 10 -#define MAX_ONE_DIMS0 100 +#define ONE_DIMS0 10 +#define MAX_ONE_DIMS0 100 -#define DSET_ONE "DSET_ONE" -#define DSET_NONE "DSET_NONE" -#define DSET_NOMAX "DSET_NOMAX" -#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ONE "DSET_ONE" +#define DSET_NONE "DSET_NONE" +#define DSET_NOMAX "DSET_NOMAX" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" #define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" -#define DSET_CMPD "DSET_CMPD" -#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" -#define TWO_DIMS0 4 -#define TWO_DIMS1 10 -#define MAX_TWO_DIMS0 60 -#define MAX_TWO_DIMS1 100 +#define TWO_DIMS0 4 +#define TWO_DIMS1 10 +#define MAX_TWO_DIMS0 60 +#define MAX_TWO_DIMS1 100 -#define DSET_TWO "DSET_TWO" -#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" -#define CHUNK_SIZE 2 +#define CHUNK_SIZE 2 #define FILE "WATCH.h5" @@ -64,9 +64,9 @@ typedef struct sub22_t { } sub22_t; typedef struct sub2_t { - int a; + int a; sub22_t b; - int c; + int c; } sub2_t; typedef struct sub4_t { @@ -75,7 +75,7 @@ typedef struct sub4_t { } sub4_t; typedef struct set_t { - int field1; + int field1; sub2_t field2; double field3; sub4_t field4; @@ -90,58 +90,63 @@ typedef struct set_t { ************************************************************************************** */ static herr_t -generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, void *data) +generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, + void *data) { - hid_t dcpl=-1; /* Dataset creation property */ - hid_t did=-1; /* Dataset id */ - hid_t sid=-1; /* Dataspace id */ - int i; /* Local index variable */ - hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t did = -1; /* Dataset id */ + hid_t sid = -1; /* Dataspace id */ + int i; /* Local index variable */ + hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */ /* Create the dataspace */ - if((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) goto done; /* Set up dataset's creation properties */ - if(!HDstrcmp(dname, DSET_NONE)) + if (!HDstrcmp(dname, DSET_NONE)) dcpl = H5P_DEFAULT; else { - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto done; - for(i = 0; i < ndims; i++) + for (i = 0; i < ndims; i++) chunk_dims[i] = CHUNK_SIZE; - if(H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) goto done; } /* end else */ - if(!HDstrcmp(dname, DSET_ALLOC_LATE)) { - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + if (!HDstrcmp(dname, DSET_ALLOC_LATE)) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) goto done; - } else if(!HDstrcmp(dname, DSET_ALLOC_EARLY)) { - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + } + else if (!HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto done; } /* end if-else */ /* Create the dataset */ - if((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto done; /* Write to the dataset */ - if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto done; /* Closing */ - if(H5Pclose(dcpl) < 0) goto done; - if(H5Sclose(sid) < 0) goto done; - if(H5Dclose(did) < 0) goto done; + if (H5Pclose(dcpl) < 0) + goto done; + if (H5Sclose(sid) < 0) + goto done; + if (H5Dclose(did) < 0) + goto done; return SUCCEED; done: H5E_BEGIN_TRY - H5Sclose(sid); - H5Pclose(dcpl); - H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl); + H5Dclose(did); H5E_END_TRY return FAIL; @@ -150,49 +155,49 @@ done: int main(void) { - hid_t fid=-1; /* File id */ - hid_t fapl=-1; /* File access property list id */ - hsize_t cur_dims[1]; /* Dimension sizes */ - hsize_t max_dims[1]; /* Maximum dimension sizes */ - hsize_t cur2_dims[2]; /* Current dimension sizes */ - hsize_t max2_dims[2]; /* Maximum dimension sizes */ - hid_t set_tid=-1, esc_set_tid=-1; /* Compound type id */ - hid_t sub22_tid=-1; /* Compound type id */ - hid_t sub2_tid=-1, esc_sub2_tid=-1; /* Compound type id */ - hid_t sub4_tid=-1, esc_sub4_tid=-1; /* Compound type id */ - int one_data[ONE_DIMS0]; /* Buffer for data */ - int two_data[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data */ - set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ - set_t two_cbuf[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data with compound type */ - int i; /* Local index variable */ + hid_t fid = -1; /* File id */ + hid_t fapl = -1; /* File access property list id */ + hsize_t cur_dims[1]; /* Dimension sizes */ + hsize_t max_dims[1]; /* Maximum dimension sizes */ + hsize_t cur2_dims[2]; /* Current dimension sizes */ + hsize_t max2_dims[2]; /* Maximum dimension sizes */ + hid_t set_tid = -1, esc_set_tid = -1; /* Compound type id */ + hid_t sub22_tid = -1; /* Compound type id */ + hid_t sub2_tid = -1, esc_sub2_tid = -1; /* Compound type id */ + hid_t sub4_tid = -1, esc_sub4_tid = -1; /* Compound type id */ + int one_data[ONE_DIMS0]; /* Buffer for data */ + int two_data[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data */ + set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */ + set_t two_cbuf[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data with compound type */ + int i; /* Local index variable */ /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) HDexit(EXIT_FAILURE); /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) HDexit(EXIT_FAILURE); /* Create a file with the latest format */ - if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) HDexit(EXIT_FAILURE); /* Initialization for one-dimensional dataset */ cur_dims[0] = ONE_DIMS0; max_dims[0] = MAX_ONE_DIMS0; - for(i = 0; i < ONE_DIMS0; i++) + for (i = 0; i < ONE_DIMS0; i++) one_data[i] = i; /* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */ - if(generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) goto done; - if(generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) goto done; - if(generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) goto done; - if(generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) goto done; - if(generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + if (generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) goto done; /* Initialization for two-dimensional dataset */ @@ -201,98 +206,98 @@ main(void) max2_dims[0] = MAX_TWO_DIMS0; max2_dims[1] = MAX_TWO_DIMS1; - for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) + for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) two_data[i] = i; /* Generate DSET_TWO */ - if(generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) + if (generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) goto done; /* Initialization for one-dimensional compound typed dataset */ cur_dims[0] = ONE_DIMS0; max_dims[0] = MAX_ONE_DIMS0; - for(i = 0; i < ONE_DIMS0; i++) { - one_cbuf[i].field1 = 1; - one_cbuf[i].field2.a = 2; - one_cbuf[i].field2.c = 4; + for (i = 0; i < ONE_DIMS0; i++) { + one_cbuf[i].field1 = 1; + one_cbuf[i].field2.a = 2; + one_cbuf[i].field2.c = 4; one_cbuf[i].field2.b.a = 20; one_cbuf[i].field2.b.b = 40; one_cbuf[i].field2.b.c = 80; - one_cbuf[i].field3 = 3.0F; - one_cbuf[i].field4.a = 4; - one_cbuf[i].field4.b = 8; + one_cbuf[i].field3 = 3.0F; + one_cbuf[i].field4.a = 4; + one_cbuf[i].field4.b = 8; } /* end for */ /* Create the compound type */ - if((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) + if ((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) goto done; - if(H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) goto done; - if((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + if ((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) goto done; - if(H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) + if (H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) goto done; - if(H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) goto done; - if((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + if ((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) goto done; - if(H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + if (H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) goto done; - if((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + if ((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) goto done; - if(H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + if (H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) + if (H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) goto done; - if(H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + if (H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) goto done; - if(H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) + if (H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) goto done; /* Create the compound type with escape/separator characters */ - if((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + if ((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) goto done; - if(H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) + if (H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) goto done; - if(H5Tinsert(esc_sub2_tid, "\\K", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_sub2_tid, "\\K", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) goto done; - if((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + if ((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) goto done; - if(H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) goto done; - if((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + if ((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) goto done; - if(H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + if (H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) goto done; - if(H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) + if (H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) goto done; - if(H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + if (H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) goto done; - if(H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) + if (H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) goto done; /* Generate DSET_CMPD, DSET_CMPD_ESC */ - if(generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) + if (generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) goto done; - if(generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) + if (generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) goto done; /* Initialization for two-dimensional compound typed dataset */ @@ -301,48 +306,56 @@ main(void) max2_dims[0] = MAX_TWO_DIMS0; max2_dims[0] = MAX_TWO_DIMS1; - for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { - two_cbuf[i].field1 = 1; - two_cbuf[i].field2.a = 2; - two_cbuf[i].field2.c = 4; + for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { + two_cbuf[i].field1 = 1; + two_cbuf[i].field2.a = 2; + two_cbuf[i].field2.c = 4; two_cbuf[i].field2.b.a = 20; two_cbuf[i].field2.b.b = 40; two_cbuf[i].field2.b.c = 80; - two_cbuf[i].field3 = 3.0F; - two_cbuf[i].field4.a = 4; - two_cbuf[i].field4.b = 8; + two_cbuf[i].field3 = 3.0F; + two_cbuf[i].field4.a = 4; + two_cbuf[i].field4.b = 8; } /* end for */ /* Generate DSET_CMPD_TWO */ - if(generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) + if (generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) goto done; /* Closing */ - if(H5Tclose(sub22_tid) < 0) goto done; - if(H5Tclose(sub2_tid) < 0) goto done; - if(H5Tclose(sub4_tid) < 0) goto done; - if(H5Tclose(set_tid) < 0) goto done; - if(H5Tclose(esc_sub2_tid) < 0) goto done; - if(H5Tclose(esc_sub4_tid) < 0) goto done; - if(H5Tclose(esc_set_tid) < 0) goto done; - if(H5Pclose(fapl) < 0) goto done; - if(H5Fclose(fid) < 0) goto done; + if (H5Tclose(sub22_tid) < 0) + goto done; + if (H5Tclose(sub2_tid) < 0) + goto done; + if (H5Tclose(sub4_tid) < 0) + goto done; + if (H5Tclose(set_tid) < 0) + goto done; + if (H5Tclose(esc_sub2_tid) < 0) + goto done; + if (H5Tclose(esc_sub4_tid) < 0) + goto done; + if (H5Tclose(esc_set_tid) < 0) + goto done; + if (H5Pclose(fapl) < 0) + goto done; + if (H5Fclose(fid) < 0) + goto done; HDexit(EXIT_SUCCESS); done: H5E_BEGIN_TRY - H5Tclose(sub22_tid); - H5Tclose(sub2_tid); - H5Tclose(sub4_tid); - H5Tclose(set_tid); - H5Tclose(esc_sub2_tid); - H5Tclose(esc_sub4_tid); - H5Tclose(esc_set_tid); - H5Pclose(fapl); - H5Fclose(fid); + H5Tclose(sub22_tid); + H5Tclose(sub2_tid); + H5Tclose(sub4_tid); + H5Tclose(set_tid); + H5Tclose(esc_sub2_tid); + H5Tclose(esc_sub4_tid); + H5Tclose(esc_set_tid); + H5Pclose(fapl); + H5Fclose(fid); H5E_END_TRY HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/hl/tools/h5watch/swmr_check_compat_vfd.c b/hl/tools/h5watch/swmr_check_compat_vfd.c index 608f4a8..fb1c903 100644 --- a/hl/tools/h5watch/swmr_check_compat_vfd.c +++ b/hl/tools/h5watch/swmr_check_compat_vfd.c @@ -22,11 +22,10 @@ #include "H5private.h" /* This file needs to access the file driver testing code */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING -#include "H5FDpkg.h" /* File drivers */ +#include "H5FDpkg.h" /* File drivers */ - /*------------------------------------------------------------------------- * Function: main * @@ -48,10 +47,9 @@ main(void) driver = HDgetenv("HDF5_DRIVER"); - if(H5FD__supports_swmr_test(driver)) + if (H5FD__supports_swmr_test(driver)) return EXIT_SUCCESS; else return EXIT_FAILURE; } /* end main() */ - diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c index c08b67b..c5e7d85 100644 --- a/java/src/jni/exceptionImp.c +++ b/java/src/jni/exceptionImp.c @@ -21,7 +21,6 @@ extern "C" { #endif /* __cplusplus */ - /***********/ /* Headers */ /***********/ @@ -33,9 +32,8 @@ extern "C" { #include "h5jni.h" #include "exceptionImp.h" -extern H5E_auto2_t efunc; -extern void *edata; - +extern H5E_auto2_t efunc; +extern void * edata; /*******************/ /* Local Variables */ @@ -47,13 +45,13 @@ extern void *edata; * minor error numbers. */ typedef struct H5E_major_mesg_t { - hid_t error_code; - const char *str; + hid_t error_code; + const char *str; } H5E_major_mesg_t; typedef struct H5E_minor_mesg_t { - hid_t error_code; - const char *str; + hid_t error_code; + const char *str; } H5E_minor_mesg_t; /* major and minor error numbers */ @@ -66,42 +64,41 @@ typedef struct H5E_num_t { /* Local Macros */ /********************/ -#define THROWEXCEPTION(className, args) \ -{ \ - jmethodID jm; \ - jclass jc; \ - jobject ex; \ - \ - if (NULL == (jc = ENVPTR->FindClass(ENVONLY, (className)))) \ - CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ - \ - if (NULL == (jm = ENVPTR->GetMethodID(ENVONLY, jc, "", "(Ljava/lang/String;)V"))) { \ - HDprintf("THROWEXCEPTION FATAL ERROR: GetMethodID failed\n"); \ - CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ - } \ - \ - if (NULL == (ex = ENVPTR->NewObjectA(ENVONLY, jc, jm, (jvalue *)(args)))) { \ - HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Creation failed\n", (className)); \ - CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ - } \ - \ - if (ENVPTR->Throw(ENVONLY, (jthrowable)ex) < 0) { \ - HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Throw failed\n", (className)); \ - CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ - } \ -} +#define THROWEXCEPTION(className, args) \ + { \ + jmethodID jm; \ + jclass jc; \ + jobject ex; \ + \ + if (NULL == (jc = ENVPTR->FindClass(ENVONLY, (className)))) \ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ + \ + if (NULL == (jm = ENVPTR->GetMethodID(ENVONLY, jc, "", "(Ljava/lang/String;)V"))) { \ + HDprintf("THROWEXCEPTION FATAL ERROR: GetMethodID failed\n"); \ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ + } \ + \ + if (NULL == (ex = ENVPTR->NewObjectA(ENVONLY, jc, jm, (jvalue *)(args)))) { \ + HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Creation failed\n", (className)); \ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ + } \ + \ + if (ENVPTR->Throw(ENVONLY, (jthrowable)ex) < 0) { \ + HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Throw failed\n", (className)); \ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ + } \ + } /********************/ /* Local Prototypes */ /********************/ static const char *defineHDF5LibraryException(hid_t maj_num); -static jboolean H5JNIErrorClass(JNIEnv *env, const char *message, const char *className); +static jboolean H5JNIErrorClass(JNIEnv *env, const char *message, const char *className); /* get the major and minor error numbers on the top of the error stack */ static herr_t -walk_error_callback - (unsigned n, const H5E_error2_t *err_desc, void *_err_nums) +walk_error_callback(unsigned n, const H5E_error2_t *err_desc, void *_err_nums) { H5E_num_t *err_nums = (H5E_num_t *)_err_nums; @@ -122,8 +119,7 @@ walk_error_callback * */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5error_1off - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5error_1off(JNIEnv *env, jclass clss) { UNUSED(env); UNUSED(clss); @@ -144,8 +140,7 @@ Java_hdf_hdf5lib_H5_H5error_1off * */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5error_1on - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5error_1on(JNIEnv *env, jclass clss) { UNUSED(env); UNUSED(clss); @@ -161,11 +156,10 @@ Java_hdf_hdf5lib_H5_H5error_1on * Call the HDF-5 library to print the HDF-5 error stack to 'file_name'. */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0 - (JNIEnv *env, jobject obj, jstring file_name) +Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0(JNIEnv *env, jobject obj, jstring file_name) { - FILE *stream = NULL; - const char *file = NULL; + FILE * stream = NULL; + const char *file = NULL; UNUSED(obj); @@ -196,8 +190,7 @@ done: * Extract the HDF-5 major error number from the HDF-5 error stack. */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber - (JNIEnv *env, jobject obj) +Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber(JNIEnv *env, jobject obj) { H5E_num_t err_nums; @@ -221,8 +214,7 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber * Extract the HDF-5 minor error number from the HDF-5 error stack. */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber - (JNIEnv *env, jobject obj) +Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber(JNIEnv *env, jobject obj) { H5E_num_t err_nums; @@ -242,17 +234,16 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber * Routine to raise particular Java exceptions from C. */ static jboolean -H5JNIErrorClass - (JNIEnv *env, const char *message, const char *className) +H5JNIErrorClass(JNIEnv *env, const char *message, const char *className) { - jstring str; - char *args[2]; - jboolean retVal = JNI_FALSE; + jstring str; + char * args[2]; + jboolean retVal = JNI_FALSE; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, message))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - args[0] = (char *) str; + args[0] = (char *)str; args[1] = 0; THROWEXCEPTION(className, args); @@ -271,13 +262,11 @@ done: * exception. */ jboolean -h5outOfMemory - (JNIEnv *env, const char *functName) +h5outOfMemory(JNIEnv *env, const char *functName) { return H5JNIErrorClass(env, functName, "java/lang/OutOfMemoryError"); } /* end h5outOfMemory() */ - /* * A fatal error in a JNI call * Create and throw an 'InternalError' @@ -287,8 +276,7 @@ h5outOfMemory * exception. */ jboolean -h5JNIFatalError - (JNIEnv *env, const char *functName) +h5JNIFatalError(JNIEnv *env, const char *functName) { return H5JNIErrorClass(env, functName, "java/lang/InternalError"); } /* end h5JNIFatalError() */ @@ -302,8 +290,7 @@ h5JNIFatalError * exception. */ jboolean -h5nullArgument - (JNIEnv *env, const char *functName) +h5nullArgument(JNIEnv *env, const char *functName) { return H5JNIErrorClass(env, functName, "java/lang/NullPointerException"); } /* end h5nullArgument() */ @@ -317,8 +304,7 @@ h5nullArgument * exception. */ jboolean -h5badArgument - (JNIEnv *env, const char *functName) +h5badArgument(JNIEnv *env, const char *functName) { return H5JNIErrorClass(env, functName, "java/lang/IllegalArgumentException"); } /* end h5badArgument() */ @@ -332,8 +318,7 @@ h5badArgument * exception. */ jboolean -h5unimplemented - (JNIEnv *env, const char *functName) +h5unimplemented(JNIEnv *env, const char *functName) { return H5JNIErrorClass(env, functName, "java/lang/UnsupportedOperationException"); } /* end h5unimplemented() */ @@ -346,8 +331,7 @@ h5unimplemented * exception. */ jboolean -h5raiseException - (JNIEnv *env, const char *message, const char *exception) +h5raiseException(JNIEnv *env, const char *message, const char *exception) { return H5JNIErrorClass(env, message, exception); } /* end h5raiseException() */ @@ -364,20 +348,19 @@ h5raiseException * exception. */ jboolean -h5libraryError - (JNIEnv *env) +h5libraryError(JNIEnv *env) { const char *exception = NULL; H5E_type_t error_msg_type; H5E_num_t exceptionNumbers; - jstring str = NULL; + jstring str = NULL; ssize_t msg_size = 0; hid_t min_num; hid_t maj_num; hid_t stk_id = H5I_INVALID_HID; - char *args[2]; - char *msg_str = NULL; - jboolean retVal = JNI_FALSE; + char * args[2]; + char * msg_str = NULL; + jboolean retVal = JNI_FALSE; exceptionNumbers.maj_num = 0; exceptionNumbers.min_num = 0; @@ -408,7 +391,7 @@ h5libraryError goto done; if (msg_size > 0) { - if (NULL == (msg_str = (char *) HDcalloc((size_t)msg_size + 1, sizeof(char)))) + if (NULL == (msg_str = (char *)HDcalloc((size_t)msg_size + 1, sizeof(char)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5libraryerror: failed to allocate buffer for error message"); if ((msg_size = H5Eget_msg(min_num, &error_msg_type, msg_str, (size_t)msg_size + 1)) < 0) @@ -424,7 +407,7 @@ h5libraryError if (stk_id >= 0) H5Eset_current_stack(stk_id); - args[0] = (char *) str; + args[0] = (char *)str; args[1] = 0; THROWEXCEPTION(exception, args); @@ -443,8 +426,7 @@ done: * which goes with an HDF-5 error code. */ static const char * -defineHDF5LibraryException - (hid_t maj_num) +defineHDF5LibraryException(hid_t maj_num) { hid_t err_num = maj_num; @@ -497,4 +479,3 @@ defineHDF5LibraryException #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ - diff --git a/java/src/jni/exceptionImp.h b/java/src/jni/exceptionImp.h index 5873202..1a7ad92 100644 --- a/java/src/jni/exceptionImp.h +++ b/java/src/jni/exceptionImp.h @@ -27,9 +27,7 @@ extern "C" { * Signature: ()I * */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5error_1off - (JNIEnv *env, jclass clss ); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5error_1off(JNIEnv *env, jclass clss); /* * Class: hdf_hdf5lib_exceptions_HDF5Library @@ -37,10 +35,7 @@ Java_hdf_hdf5lib_H5_H5error_1off * Signature: ()V * */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5error_1on - (JNIEnv *env, jclass clss ); - +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5error_1on(JNIEnv *env, jclass clss); /* * Class: hdf_hdf5lib_exceptions_HDFLibraryException @@ -49,27 +44,25 @@ Java_hdf_hdf5lib_H5_H5error_1on * * Call the HDF-5 library to print the HDF-5 error stack to 'file_name'. */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0 - (JNIEnv *env, jobject obj, jstring file_name); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0(JNIEnv *env, + jobject obj, + jstring file_name); /* * Class: hdf_hdf5lib_exceptions_HDFLibraryException * Method: _getMajorErrorNumber * Signature: ()J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber - (JNIEnv *env, jobject obj); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber(JNIEnv *env, + jobject obj); /* * Class: hdf_hdf5lib_exceptions_HDFLibraryException * Method: _getMinorErrorNumber * Signature: ()J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber - (JNIEnv *env, jobject obj); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber(JNIEnv *env, + jobject obj); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index 8fdca35..101d777 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -26,546 +26,1278 @@ extern "C" { #include #include "h5jni.h" -H5_GCC_DIAG_OFF(missing-prototypes) -H5_GCC_DIAG_OFF(unused-parameter) +H5_GCC_DIAG_OFF("missing-prototypes") +H5_GCC_DIAG_OFF("unused-parameter") JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1QUARTER_1HADDR_1MAX(JNIEnv *env, jclass cls) { return (hsize_t)HADDR_MAX/4; } +Java_hdf_hdf5lib_HDF5Constants_H5_1QUARTER_1HADDR_1MAX(JNIEnv *env, jclass cls) +{ + return (hsize_t)HADDR_MAX / 4; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1ALLOW_1K13_1OPTION_1MASK(JNIEnv *env, jclass cls) { return H5_SZIP_ALLOW_K13_OPTION_MASK; } +Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1ALLOW_1K13_1OPTION_1MASK(JNIEnv *env, jclass cls) +{ + return H5_SZIP_ALLOW_K13_OPTION_MASK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1CHIP_1OPTION_1MASK(JNIEnv *env, jclass cls) { return H5_SZIP_CHIP_OPTION_MASK; } +Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1CHIP_1OPTION_1MASK(JNIEnv *env, jclass cls) +{ + return H5_SZIP_CHIP_OPTION_MASK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1EC_1OPTION_1MASK(JNIEnv *env, jclass cls) { return H5_SZIP_EC_OPTION_MASK; } +Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1EC_1OPTION_1MASK(JNIEnv *env, jclass cls) +{ + return H5_SZIP_EC_OPTION_MASK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1MAX_1PIXELS_1PER_1BLOCK(JNIEnv *env, jclass cls) { return H5_SZIP_MAX_PIXELS_PER_BLOCK; } +Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1MAX_1PIXELS_1PER_1BLOCK(JNIEnv *env, jclass cls) +{ + return H5_SZIP_MAX_PIXELS_PER_BLOCK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1NN_1OPTION_1MASK(JNIEnv *env, jclass cls) { return H5_SZIP_NN_OPTION_MASK; } +Java_hdf_hdf5lib_HDF5Constants_H5_1SZIP_1NN_1OPTION_1MASK(JNIEnv *env, jclass cls) +{ + return H5_SZIP_NN_OPTION_MASK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1UNKNOWN(JNIEnv *env, jclass cls) { return H5_INDEX_UNKNOWN; } +Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1UNKNOWN(JNIEnv *env, jclass cls) +{ + return H5_INDEX_UNKNOWN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1NAME(JNIEnv *env, jclass cls) { return H5_INDEX_NAME; } +Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1NAME(JNIEnv *env, jclass cls) +{ + return H5_INDEX_NAME; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1CRT_1ORDER(JNIEnv *env, jclass cls) { return H5_INDEX_CRT_ORDER; } +Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1CRT_1ORDER(JNIEnv *env, jclass cls) +{ + return H5_INDEX_CRT_ORDER; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1N(JNIEnv *env, jclass cls) { return H5_INDEX_N; } +Java_hdf_hdf5lib_HDF5Constants_H5_1INDEX_1N(JNIEnv *env, jclass cls) +{ + return H5_INDEX_N; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1UNKNOWN(JNIEnv *env, jclass cls) { return H5_ITER_UNKNOWN; } +Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1UNKNOWN(JNIEnv *env, jclass cls) +{ + return H5_ITER_UNKNOWN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1INC(JNIEnv *env, jclass cls) { return H5_ITER_INC; } +Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1INC(JNIEnv *env, jclass cls) +{ + return H5_ITER_INC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1DEC(JNIEnv *env, jclass cls) { return H5_ITER_DEC; } +Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1DEC(JNIEnv *env, jclass cls) +{ + return H5_ITER_DEC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1NATIVE(JNIEnv *env, jclass cls) { return H5_ITER_NATIVE; } +Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1NATIVE(JNIEnv *env, jclass cls) +{ + return H5_ITER_NATIVE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1N(JNIEnv *env, jclass cls) { return H5_ITER_N; } +Java_hdf_hdf5lib_HDF5Constants_H5_1ITER_1N(JNIEnv *env, jclass cls) +{ + return H5_ITER_N; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5AC_1CURR_1CACHE_1CONFIG_1VERSION(JNIEnv *env, jclass cls) { return H5AC__CURR_CACHE_CONFIG_VERSION; } +Java_hdf_hdf5lib_HDF5Constants_H5AC_1CURR_1CACHE_1CONFIG_1VERSION(JNIEnv *env, jclass cls) +{ + return H5AC__CURR_CACHE_CONFIG_VERSION; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5AC_1MAX_1TRACE_1FILE_1NAME_1LEN(JNIEnv *env, jclass cls) { return H5AC__MAX_TRACE_FILE_NAME_LEN; } +Java_hdf_hdf5lib_HDF5Constants_H5AC_1MAX_1TRACE_1FILE_1NAME_1LEN(JNIEnv *env, jclass cls) +{ + return H5AC__MAX_TRACE_FILE_NAME_LEN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5AC_1METADATA_1WRITE_1STRATEGY_1PROCESS_1ZERO_1ONLY(JNIEnv *env, jclass cls) { return H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY; } +Java_hdf_hdf5lib_HDF5Constants_H5AC_1METADATA_1WRITE_1STRATEGY_1PROCESS_1ZERO_1ONLY(JNIEnv *env, jclass cls) +{ + return H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5AC_1METADATA_1WRITE_1STRATEGY_1DISTRIBUTED(JNIEnv *env, jclass cls) { return H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED; } +Java_hdf_hdf5lib_HDF5Constants_H5AC_1METADATA_1WRITE_1STRATEGY_1DISTRIBUTED(JNIEnv *env, jclass cls) +{ + return H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5C_1incr_1off(JNIEnv *env, jclass cls) { return H5C_incr__off; } +Java_hdf_hdf5lib_HDF5Constants_H5C_1incr_1off(JNIEnv *env, jclass cls) +{ + return H5C_incr__off; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5C_1incr_1threshold(JNIEnv *env, jclass cls) { return H5C_incr__threshold; } +Java_hdf_hdf5lib_HDF5Constants_H5C_1incr_1threshold(JNIEnv *env, jclass cls) +{ + return H5C_incr__threshold; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5C_1flash_1incr_1off(JNIEnv *env, jclass cls) { return H5C_flash_incr__off; } +Java_hdf_hdf5lib_HDF5Constants_H5C_1flash_1incr_1off(JNIEnv *env, jclass cls) +{ + return H5C_flash_incr__off; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5C_1flash_1incr_1add_1space(JNIEnv *env, jclass cls) { return H5C_flash_incr__add_space; } +Java_hdf_hdf5lib_HDF5Constants_H5C_1flash_1incr_1add_1space(JNIEnv *env, jclass cls) +{ + return H5C_flash_incr__add_space; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1off(JNIEnv *env, jclass cls) { return H5C_decr__off; } +Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1off(JNIEnv *env, jclass cls) +{ + return H5C_decr__off; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1threshold(JNIEnv *env, jclass cls) { return H5C_decr__threshold; } +Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1threshold(JNIEnv *env, jclass cls) +{ + return H5C_decr__threshold; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1age_1out(JNIEnv *env, jclass cls) { return H5C_decr__age_out; } +Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1age_1out(JNIEnv *env, jclass cls) +{ + return H5C_decr__age_out; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1age_1out_1with_1threshold(JNIEnv *env, jclass cls) { return H5C_decr__age_out_with_threshold; } +Java_hdf_hdf5lib_HDF5Constants_H5C_1decr_1age_1out_1with_1threshold(JNIEnv *env, jclass cls) +{ + return H5C_decr__age_out_with_threshold; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1CHUNK_1IDX_1BTREE(JNIEnv *env, jclass cls) { return H5D_CHUNK_IDX_BTREE; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1CHUNK_1IDX_1BTREE(JNIEnv *env, jclass cls) +{ + return H5D_CHUNK_IDX_BTREE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1DEFAULT(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5D_ALLOC_TIME_DEFAULT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1EARLY(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_EARLY; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1EARLY(JNIEnv *env, jclass cls) +{ + return H5D_ALLOC_TIME_EARLY; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1ERROR(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1ERROR(JNIEnv *env, jclass cls) +{ + return H5D_ALLOC_TIME_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1INCR(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_INCR; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1INCR(JNIEnv *env, jclass cls) +{ + return H5D_ALLOC_TIME_INCR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1LATE(JNIEnv *env, jclass cls) { return H5D_ALLOC_TIME_LATE; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1ALLOC_1TIME_1LATE(JNIEnv *env, jclass cls) +{ + return H5D_ALLOC_TIME_LATE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1ERROR(JNIEnv *env, jclass cls) { return H5D_FILL_TIME_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1ERROR(JNIEnv *env, jclass cls) +{ + return H5D_FILL_TIME_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1ALLOC(JNIEnv *env, jclass cls) { return H5D_FILL_TIME_ALLOC; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1ALLOC(JNIEnv *env, jclass cls) +{ + return H5D_FILL_TIME_ALLOC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1NEVER(JNIEnv *env, jclass cls) { return H5D_FILL_TIME_NEVER; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1NEVER(JNIEnv *env, jclass cls) +{ + return H5D_FILL_TIME_NEVER; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1IFSET(JNIEnv *env, jclass cls) { return H5D_FILL_TIME_IFSET; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1TIME_1IFSET(JNIEnv *env, jclass cls) +{ + return H5D_FILL_TIME_IFSET; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1DEFAULT(JNIEnv *env, jclass cls) { return H5D_FILL_VALUE_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5D_FILL_VALUE_DEFAULT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1ERROR(JNIEnv *env, jclass cls) { return H5D_FILL_VALUE_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1ERROR(JNIEnv *env, jclass cls) +{ + return H5D_FILL_VALUE_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1UNDEFINED(JNIEnv *env, jclass cls) { return H5D_FILL_VALUE_UNDEFINED; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1UNDEFINED(JNIEnv *env, jclass cls) +{ + return H5D_FILL_VALUE_UNDEFINED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1USER_1DEFINED(JNIEnv *env, jclass cls) { return H5D_FILL_VALUE_USER_DEFINED; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1FILL_1VALUE_1USER_1DEFINED(JNIEnv *env, jclass cls) +{ + return H5D_FILL_VALUE_USER_DEFINED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1LAYOUT_1ERROR(JNIEnv *env, jclass cls) { return H5D_LAYOUT_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1LAYOUT_1ERROR(JNIEnv *env, jclass cls) +{ + return H5D_LAYOUT_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1CHUNKED(JNIEnv *env, jclass cls) { return H5D_CHUNKED; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1CHUNKED(JNIEnv *env, jclass cls) +{ + return H5D_CHUNKED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1COMPACT(JNIEnv *env, jclass cls) { return H5D_COMPACT; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1COMPACT(JNIEnv *env, jclass cls) +{ + return H5D_COMPACT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1CONTIGUOUS(JNIEnv *env, jclass cls) { return H5D_CONTIGUOUS; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1CONTIGUOUS(JNIEnv *env, jclass cls) +{ + return H5D_CONTIGUOUS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1VIRTUAL(JNIEnv *env, jclass cls) { return H5D_VIRTUAL; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1VIRTUAL(JNIEnv *env, jclass cls) +{ + return H5D_VIRTUAL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1NLAYOUTS(JNIEnv *env, jclass cls) { return H5D_NLAYOUTS; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1NLAYOUTS(JNIEnv *env, jclass cls) +{ + return H5D_NLAYOUTS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1ALLOCATED(JNIEnv *env, jclass cls) { return H5D_SPACE_STATUS_ALLOCATED; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1ALLOCATED(JNIEnv *env, jclass cls) +{ + return H5D_SPACE_STATUS_ALLOCATED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1ERROR(JNIEnv *env, jclass cls) { return H5D_SPACE_STATUS_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1ERROR(JNIEnv *env, jclass cls) +{ + return H5D_SPACE_STATUS_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1NOT_1ALLOCATED(JNIEnv *env, jclass cls) { return H5D_SPACE_STATUS_NOT_ALLOCATED; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1NOT_1ALLOCATED(JNIEnv *env, jclass cls) +{ + return H5D_SPACE_STATUS_NOT_ALLOCATED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1PART_1ALLOCATED(JNIEnv *env, jclass cls) { return H5D_SPACE_STATUS_PART_ALLOCATED; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1SPACE_1STATUS_1PART_1ALLOCATED(JNIEnv *env, jclass cls) +{ + return H5D_SPACE_STATUS_PART_ALLOCATED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1ERROR(JNIEnv *env, jclass cls) { return H5D_VDS_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1ERROR(JNIEnv *env, jclass cls) +{ + return H5D_VDS_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1FIRST_1MISSING(JNIEnv *env, jclass cls) { return H5D_VDS_FIRST_MISSING; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1FIRST_1MISSING(JNIEnv *env, jclass cls) +{ + return H5D_VDS_FIRST_MISSING; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1LAST_1AVAILABLE(JNIEnv *env, jclass cls) { return H5D_VDS_LAST_AVAILABLE; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1VDS_1LAST_1AVAILABLE(JNIEnv *env, jclass cls) +{ + return H5D_VDS_LAST_AVAILABLE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5D_1CHUNK_1DONT_1FILTER_1PARTIAL_1CHUNKS(JNIEnv *env, jclass cls) { return H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS; } +Java_hdf_hdf5lib_HDF5Constants_H5D_1CHUNK_1DONT_1FILTER_1PARTIAL_1CHUNKS(JNIEnv *env, jclass cls) +{ + return H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1ALIGNMENT(JNIEnv *env, jclass cls) { return H5E_ALIGNMENT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1ALIGNMENT(JNIEnv *env, jclass cls) +{ + return H5E_ALIGNMENT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1ALREADYEXISTS(JNIEnv *env, jclass cls) { return H5E_ALREADYEXISTS; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1ALREADYEXISTS(JNIEnv *env, jclass cls) +{ + return H5E_ALREADYEXISTS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1ALREADYINIT(JNIEnv *env, jclass cls) { return H5E_ALREADYINIT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1ALREADYINIT(JNIEnv *env, jclass cls) +{ + return H5E_ALREADYINIT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1ARGS(JNIEnv *env, jclass cls) { return H5E_ARGS; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1ARGS(JNIEnv *env, jclass cls) +{ + return H5E_ARGS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1ATOM(JNIEnv *env, jclass cls) { return H5E_ATOM; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1ATOM(JNIEnv *env, jclass cls) +{ + return H5E_ATOM; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1ATTR(JNIEnv *env, jclass cls) { return H5E_ATTR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1ATTR(JNIEnv *env, jclass cls) +{ + return H5E_ATTR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADATOM(JNIEnv *env, jclass cls) { return H5E_BADATOM; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADATOM(JNIEnv *env, jclass cls) +{ + return H5E_BADATOM; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADFILE(JNIEnv *env, jclass cls) { return H5E_BADFILE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADFILE(JNIEnv *env, jclass cls) +{ + return H5E_BADFILE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADGROUP(JNIEnv *env, jclass cls) { return H5E_BADGROUP; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADGROUP(JNIEnv *env, jclass cls) +{ + return H5E_BADGROUP; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADMESG(JNIEnv *env, jclass cls) { return H5E_BADMESG; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADMESG(JNIEnv *env, jclass cls) +{ + return H5E_BADMESG; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADRANGE(JNIEnv *env, jclass cls) { return H5E_BADRANGE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADRANGE(JNIEnv *env, jclass cls) +{ + return H5E_BADRANGE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADSELECT(JNIEnv *env, jclass cls) { return H5E_BADSELECT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADSELECT(JNIEnv *env, jclass cls) +{ + return H5E_BADSELECT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADSIZE(JNIEnv *env, jclass cls) { return H5E_BADSIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADSIZE(JNIEnv *env, jclass cls) +{ + return H5E_BADSIZE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADTYPE(JNIEnv *env, jclass cls) { return H5E_BADTYPE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADTYPE(JNIEnv *env, jclass cls) +{ + return H5E_BADTYPE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BADVALUE(JNIEnv *env, jclass cls) { return H5E_BADVALUE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BADVALUE(JNIEnv *env, jclass cls) +{ + return H5E_BADVALUE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1BTREE(JNIEnv *env, jclass cls) { return H5E_BTREE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1BTREE(JNIEnv *env, jclass cls) +{ + return H5E_BTREE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CACHE(JNIEnv *env, jclass cls) { return H5E_CACHE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CACHE(JNIEnv *env, jclass cls) +{ + return H5E_CACHE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CALLBACK(JNIEnv *env, jclass cls) { return H5E_CALLBACK; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CALLBACK(JNIEnv *env, jclass cls) +{ + return H5E_CALLBACK; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANAPPLY(JNIEnv *env, jclass cls) { return H5E_CANAPPLY; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANAPPLY(JNIEnv *env, jclass cls) +{ + return H5E_CANAPPLY; +} /*JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTALLOC(JNIEnv *env, jclass cls) { return H5E_CANTALLOC; }*/ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCLIP(JNIEnv *env, jclass cls) { return H5E_CANTCLIP; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCLIP(JNIEnv *env, jclass cls) +{ + return H5E_CANTCLIP; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCLOSEFILE(JNIEnv *env, jclass cls) { return H5E_CANTCLOSEFILE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCLOSEFILE(JNIEnv *env, jclass cls) +{ + return H5E_CANTCLOSEFILE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCONVERT(JNIEnv *env, jclass cls) { return H5E_CANTCONVERT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCONVERT(JNIEnv *env, jclass cls) +{ + return H5E_CANTCONVERT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCOPY(JNIEnv *env, jclass cls) { return H5E_CANTCOPY; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCOPY(JNIEnv *env, jclass cls) +{ + return H5E_CANTCOPY; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCOUNT(JNIEnv *env, jclass cls) { return H5E_CANTCOUNT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCOUNT(JNIEnv *env, jclass cls) +{ + return H5E_CANTCOUNT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCREATE(JNIEnv *env, jclass cls) { return H5E_CANTCREATE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTCREATE(JNIEnv *env, jclass cls) +{ + return H5E_CANTCREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDEC(JNIEnv *env, jclass cls) { return H5E_CANTDEC; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDEC(JNIEnv *env, jclass cls) +{ + return H5E_CANTDEC; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDECODE(JNIEnv *env, jclass cls) { return H5E_CANTDECODE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDECODE(JNIEnv *env, jclass cls) +{ + return H5E_CANTDECODE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDELETE(JNIEnv *env, jclass cls) { return H5E_CANTDELETE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDELETE(JNIEnv *env, jclass cls) +{ + return H5E_CANTDELETE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDELETEFILE(JNIEnv *env, jclass cls) { return H5E_CANTDELETEFILE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTDELETEFILE(JNIEnv *env, jclass cls) +{ + return H5E_CANTDELETEFILE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTENCODE(JNIEnv *env, jclass cls) { return H5E_CANTENCODE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTENCODE(JNIEnv *env, jclass cls) +{ + return H5E_CANTENCODE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTFLUSH(JNIEnv *env, jclass cls) { return H5E_CANTFLUSH; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTFLUSH(JNIEnv *env, jclass cls) +{ + return H5E_CANTFLUSH; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTFREE(JNIEnv *env, jclass cls) { return H5E_CANTFREE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTFREE(JNIEnv *env, jclass cls) +{ + return H5E_CANTFREE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTGET(JNIEnv *env, jclass cls) { return H5E_CANTGET; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTGET(JNIEnv *env, jclass cls) +{ + return H5E_CANTGET; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINC(JNIEnv *env, jclass cls) { return H5E_CANTINC; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINC(JNIEnv *env, jclass cls) +{ + return H5E_CANTINC; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINIT(JNIEnv *env, jclass cls) { return H5E_CANTINIT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINIT(JNIEnv *env, jclass cls) +{ + return H5E_CANTINIT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINSERT(JNIEnv *env, jclass cls) { return H5E_CANTINSERT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTINSERT(JNIEnv *env, jclass cls) +{ + return H5E_CANTINSERT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLIST(JNIEnv *env, jclass cls) { return H5E_CANTLIST; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLIST(JNIEnv *env, jclass cls) +{ + return H5E_CANTLIST; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLOAD(JNIEnv *env, jclass cls) { return H5E_CANTLOAD; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLOAD(JNIEnv *env, jclass cls) +{ + return H5E_CANTLOAD; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLOCK(JNIEnv *env, jclass cls) { return H5E_CANTLOCK; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTLOCK(JNIEnv *env, jclass cls) +{ + return H5E_CANTLOCK; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTNEXT(JNIEnv *env, jclass cls) { return H5E_CANTNEXT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTNEXT(JNIEnv *env, jclass cls) +{ + return H5E_CANTNEXT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTOPENFILE(JNIEnv *env, jclass cls) { return H5E_CANTOPENFILE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTOPENFILE(JNIEnv *env, jclass cls) +{ + return H5E_CANTOPENFILE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTOPENOBJ(JNIEnv *env, jclass cls) { return H5E_CANTOPENOBJ; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTOPENOBJ(JNIEnv *env, jclass cls) +{ + return H5E_CANTOPENOBJ; +} /*JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTRECV(JNIEnv *env, jclass cls) { return H5E_CANTRECV; }*/ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTREGISTER(JNIEnv *env, jclass cls) { return H5E_CANTREGISTER; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTREGISTER(JNIEnv *env, jclass cls) +{ + return H5E_CANTREGISTER; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTRELEASE(JNIEnv *env, jclass cls) { return H5E_CANTRELEASE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTRELEASE(JNIEnv *env, jclass cls) +{ + return H5E_CANTRELEASE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSELECT(JNIEnv *env, jclass cls) { return H5E_CANTSELECT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSELECT(JNIEnv *env, jclass cls) +{ + return H5E_CANTSELECT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSET(JNIEnv *env, jclass cls) { return H5E_CANTSET; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSET(JNIEnv *env, jclass cls) +{ + return H5E_CANTSET; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSPLIT(JNIEnv *env, jclass cls) { return H5E_CANTSPLIT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTSPLIT(JNIEnv *env, jclass cls) +{ + return H5E_CANTSPLIT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTUNLOCK(JNIEnv *env, jclass cls) { return H5E_CANTUNLOCK; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CANTUNLOCK(JNIEnv *env, jclass cls) +{ + return H5E_CANTUNLOCK; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1CLOSEERROR(JNIEnv *env, jclass cls) { return H5E_CLOSEERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1CLOSEERROR(JNIEnv *env, jclass cls) +{ + return H5E_CLOSEERROR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1COMPLEN(JNIEnv *env, jclass cls) { return H5E_COMPLEN; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1COMPLEN(JNIEnv *env, jclass cls) +{ + return H5E_COMPLEN; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1DATASET(JNIEnv *env, jclass cls) { return H5E_DATASET; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1DATASET(JNIEnv *env, jclass cls) +{ + return H5E_DATASET; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1DATASPACE(JNIEnv *env, jclass cls) { return H5E_DATASPACE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1DATASPACE(JNIEnv *env, jclass cls) +{ + return H5E_DATASPACE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1DATATYPE(JNIEnv *env, jclass cls) { return H5E_DATATYPE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1DATATYPE(JNIEnv *env, jclass cls) +{ + return H5E_DATATYPE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1DEFAULT(JNIEnv *env, jclass cls) { return H5E_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5E_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1DUPCLASS(JNIEnv *env, jclass cls) { return H5E_DUPCLASS; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1DUPCLASS(JNIEnv *env, jclass cls) +{ + return H5E_DUPCLASS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1EFL(JNIEnv *env, jclass cls) { return H5E_EFL; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1EFL(JNIEnv *env, jclass cls) +{ + return H5E_EFL; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1EXISTS(JNIEnv *env, jclass cls) { return H5E_EXISTS; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1EXISTS(JNIEnv *env, jclass cls) +{ + return H5E_EXISTS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1FCNTL(JNIEnv *env, jclass cls) { return H5E_FCNTL; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1FCNTL(JNIEnv *env, jclass cls) +{ + return H5E_FCNTL; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1FILE(JNIEnv *env, jclass cls) { return H5E_FILE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1FILE(JNIEnv *env, jclass cls) +{ + return H5E_FILE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1FILEEXISTS(JNIEnv *env, jclass cls) { return H5E_FILEEXISTS; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1FILEEXISTS(JNIEnv *env, jclass cls) +{ + return H5E_FILEEXISTS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1FILEOPEN(JNIEnv *env, jclass cls) { return H5E_FILEOPEN; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1FILEOPEN(JNIEnv *env, jclass cls) +{ + return H5E_FILEOPEN; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1FUNC(JNIEnv *env, jclass cls) { return H5E_FUNC; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1FUNC(JNIEnv *env, jclass cls) +{ + return H5E_FUNC; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1HEAP(JNIEnv *env, jclass cls) { return H5E_HEAP; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1HEAP(JNIEnv *env, jclass cls) +{ + return H5E_HEAP; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1INTERNAL(JNIEnv *env, jclass cls) { return H5E_INTERNAL; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1INTERNAL(JNIEnv *env, jclass cls) +{ + return H5E_INTERNAL; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1IO(JNIEnv *env, jclass cls) { return H5E_IO; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1IO(JNIEnv *env, jclass cls) +{ + return H5E_IO; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1LINK(JNIEnv *env, jclass cls) { return H5E_LINK; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1LINK(JNIEnv *env, jclass cls) +{ + return H5E_LINK; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1LINKCOUNT(JNIEnv *env, jclass cls) { return H5E_LINKCOUNT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1LINKCOUNT(JNIEnv *env, jclass cls) +{ + return H5E_LINKCOUNT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1MAJOR(JNIEnv *env, jclass cls) { return H5E_MAJOR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1MAJOR(JNIEnv *env, jclass cls) +{ + return H5E_MAJOR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1MINOR(JNIEnv *env, jclass cls) { return H5E_MINOR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1MINOR(JNIEnv *env, jclass cls) +{ + return H5E_MINOR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1MOUNT(JNIEnv *env, jclass cls) { return H5E_MOUNT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1MOUNT(JNIEnv *env, jclass cls) +{ + return H5E_MOUNT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1MPI(JNIEnv *env, jclass cls) { return H5E_MPI; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1MPI(JNIEnv *env, jclass cls) +{ + return H5E_MPI; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1MPIERRSTR(JNIEnv *env, jclass cls) { return H5E_MPIERRSTR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1MPIERRSTR(JNIEnv *env, jclass cls) +{ + return H5E_MPIERRSTR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1NOFILTER(JNIEnv *env, jclass cls) { return H5E_NOFILTER; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1NOFILTER(JNIEnv *env, jclass cls) +{ + return H5E_NOFILTER; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1NOIDS(JNIEnv *env, jclass cls) { return H5E_NOIDS; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1NOIDS(JNIEnv *env, jclass cls) +{ + return H5E_NOIDS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1NONE_1MAJOR(JNIEnv *env, jclass cls) { return H5E_NONE_MAJOR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1NONE_1MAJOR(JNIEnv *env, jclass cls) +{ + return H5E_NONE_MAJOR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1NONE_1MINOR(JNIEnv *env, jclass cls) { return H5E_NONE_MINOR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1NONE_1MINOR(JNIEnv *env, jclass cls) +{ + return H5E_NONE_MINOR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1NOSPACE(JNIEnv *env, jclass cls) { return H5E_NOSPACE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1NOSPACE(JNIEnv *env, jclass cls) +{ + return H5E_NOSPACE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTCACHED(JNIEnv *env, jclass cls) { return H5E_NOTCACHED; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTCACHED(JNIEnv *env, jclass cls) +{ + return H5E_NOTCACHED; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTFOUND(JNIEnv *env, jclass cls) { return H5E_NOTFOUND; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTFOUND(JNIEnv *env, jclass cls) +{ + return H5E_NOTFOUND; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTHDF5(JNIEnv *env, jclass cls) { return H5E_NOTHDF5; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1NOTHDF5(JNIEnv *env, jclass cls) +{ + return H5E_NOTHDF5; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1OHDR(JNIEnv *env, jclass cls) { return H5E_OHDR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1OHDR(JNIEnv *env, jclass cls) +{ + return H5E_OHDR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1OVERFLOW(JNIEnv *env, jclass cls) { return H5E_OVERFLOW; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1OVERFLOW(JNIEnv *env, jclass cls) +{ + return H5E_OVERFLOW; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1PLINE(JNIEnv *env, jclass cls) { return H5E_PLINE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1PLINE(JNIEnv *env, jclass cls) +{ + return H5E_PLINE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1PLIST(JNIEnv *env, jclass cls) { return H5E_PLIST; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1PLIST(JNIEnv *env, jclass cls) +{ + return H5E_PLIST; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1PROTECT(JNIEnv *env, jclass cls) { return H5E_PROTECT; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1PROTECT(JNIEnv *env, jclass cls) +{ + return H5E_PROTECT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1READERROR(JNIEnv *env, jclass cls) { return H5E_READERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1READERROR(JNIEnv *env, jclass cls) +{ + return H5E_READERROR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1REFERENCE(JNIEnv *env, jclass cls) { return H5E_REFERENCE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1REFERENCE(JNIEnv *env, jclass cls) +{ + return H5E_REFERENCE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1RESOURCE(JNIEnv *env, jclass cls) { return H5E_RESOURCE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1RESOURCE(JNIEnv *env, jclass cls) +{ + return H5E_RESOURCE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1RS(JNIEnv *env, jclass cls) { return H5E_RS; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1RS(JNIEnv *env, jclass cls) +{ + return H5E_RS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1SEEKERROR(JNIEnv *env, jclass cls) { return H5E_SEEKERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1SEEKERROR(JNIEnv *env, jclass cls) +{ + return H5E_SEEKERROR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1SETLOCAL(JNIEnv *env, jclass cls) { return H5E_SETLOCAL; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1SETLOCAL(JNIEnv *env, jclass cls) +{ + return H5E_SETLOCAL; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1STORAGE(JNIEnv *env, jclass cls) { return H5E_STORAGE; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1STORAGE(JNIEnv *env, jclass cls) +{ + return H5E_STORAGE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1SYM(JNIEnv *env, jclass cls) { return H5E_SYM; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1SYM(JNIEnv *env, jclass cls) +{ + return H5E_SYM; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1TRUNCATED(JNIEnv *env, jclass cls) { return H5E_TRUNCATED; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1TRUNCATED(JNIEnv *env, jclass cls) +{ + return H5E_TRUNCATED; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1TST(JNIEnv *env, jclass cls) { return H5E_TST; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1TST(JNIEnv *env, jclass cls) +{ + return H5E_TST; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1UNINITIALIZED(JNIEnv *env, jclass cls) { return H5E_UNINITIALIZED; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1UNINITIALIZED(JNIEnv *env, jclass cls) +{ + return H5E_UNINITIALIZED; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1UNSUPPORTED(JNIEnv *env, jclass cls) { return H5E_UNSUPPORTED; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1UNSUPPORTED(JNIEnv *env, jclass cls) +{ + return H5E_UNSUPPORTED; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1VERSION(JNIEnv *env, jclass cls) { return H5E_VERSION; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1VERSION(JNIEnv *env, jclass cls) +{ + return H5E_VERSION; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1VFL(JNIEnv *env, jclass cls) { return H5E_VFL; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1VFL(JNIEnv *env, jclass cls) +{ + return H5E_VFL; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1VOL(JNIEnv *env, jclass cls) { return H5E_VOL; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1VOL(JNIEnv *env, jclass cls) +{ + return H5E_VOL; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1DOWNWARD(JNIEnv *env, jclass cls) { return H5E_WALK_DOWNWARD; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1DOWNWARD(JNIEnv *env, jclass cls) +{ + return H5E_WALK_DOWNWARD; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1UPWARD(JNIEnv *env, jclass cls) { return H5E_WALK_UPWARD; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1UPWARD(JNIEnv *env, jclass cls) +{ + return H5E_WALK_UPWARD; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5E_1WRITEERROR(JNIEnv *env, jclass cls) { return H5E_WRITEERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5E_1WRITEERROR(JNIEnv *env, jclass cls) +{ + return H5E_WRITEERROR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1IN_1PROGRESS(JNIEnv *env, jclass cls) { return H5ES_STATUS_IN_PROGRESS; } +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1IN_1PROGRESS(JNIEnv *env, jclass cls) +{ + return H5ES_STATUS_IN_PROGRESS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1SUCCEED(JNIEnv *env, jclass cls) { return H5ES_STATUS_SUCCEED; } +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1SUCCEED(JNIEnv *env, jclass cls) +{ + return H5ES_STATUS_SUCCEED; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1FAIL(JNIEnv *env, jclass cls) { return H5ES_STATUS_FAIL; } +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1FAIL(JNIEnv *env, jclass cls) +{ + return H5ES_STATUS_FAIL; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1CANCELED(JNIEnv *env, jclass cls) { return H5ES_STATUS_CANCELED; } +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1CANCELED(JNIEnv *env, jclass cls) +{ + return H5ES_STATUS_CANCELED; +} /* Java does not have unsigned native types */ -H5_GCC_DIAG_OFF(sign-conversion) +H5_GCC_DIAG_OFF("sign-conversion") JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1CREAT(JNIEnv *env, jclass cls) { return H5F_ACC_CREAT; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1CREAT(JNIEnv *env, jclass cls) +{ + return H5F_ACC_CREAT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1EXCL(JNIEnv *env, jclass cls) { return H5F_ACC_EXCL; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1EXCL(JNIEnv *env, jclass cls) +{ + return H5F_ACC_EXCL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1RDONLY(JNIEnv *env, jclass cls) { return H5F_ACC_RDONLY; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1RDONLY(JNIEnv *env, jclass cls) +{ + return H5F_ACC_RDONLY; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1RDWR(JNIEnv *env, jclass cls) { return H5F_ACC_RDWR; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1RDWR(JNIEnv *env, jclass cls) +{ + return H5F_ACC_RDWR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1TRUNC(JNIEnv *env, jclass cls) { return H5F_ACC_TRUNC; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1TRUNC(JNIEnv *env, jclass cls) +{ + return H5F_ACC_TRUNC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1DEFAULT(JNIEnv *env, jclass cls) { return H5F_ACC_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5F_ACC_DEFAULT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1SWMR_1READ(JNIEnv *env, jclass cls) { return H5F_ACC_SWMR_READ; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1SWMR_1READ(JNIEnv *env, jclass cls) +{ + return H5F_ACC_SWMR_READ; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1SWMR_1WRITE(JNIEnv *env, jclass cls) { return H5F_ACC_SWMR_WRITE; } -H5_GCC_DIAG_ON(sign-conversion) +Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1SWMR_1WRITE(JNIEnv *env, jclass cls) +{ + return H5F_ACC_SWMR_WRITE; +} +H5_GCC_DIAG_ON("sign-conversion") JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1DEFAULT(JNIEnv *env, jclass cls) { return H5F_CLOSE_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5F_CLOSE_DEFAULT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1SEMI(JNIEnv *env, jclass cls) { return H5F_CLOSE_SEMI; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1SEMI(JNIEnv *env, jclass cls) +{ + return H5F_CLOSE_SEMI; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1STRONG(JNIEnv *env, jclass cls) { return H5F_CLOSE_STRONG; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1STRONG(JNIEnv *env, jclass cls) +{ + return H5F_CLOSE_STRONG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1WEAK(JNIEnv *env, jclass cls) { return H5F_CLOSE_WEAK; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1WEAK(JNIEnv *env, jclass cls) +{ + return H5F_CLOSE_WEAK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1ERROR(JNIEnv *env, jclass cls){return H5F_LIBVER_ERROR;} +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1ERROR(JNIEnv *env, jclass cls) +{ + return H5F_LIBVER_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1EARLIEST(JNIEnv *env, jclass cls){return H5F_LIBVER_EARLIEST;} +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1EARLIEST(JNIEnv *env, jclass cls) +{ + return H5F_LIBVER_EARLIEST; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V18(JNIEnv *env, jclass cls){return H5F_LIBVER_V18;} +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V18(JNIEnv *env, jclass cls) +{ + return H5F_LIBVER_V18; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V110(JNIEnv *env, jclass cls){return H5F_LIBVER_V110;} +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V110(JNIEnv *env, jclass cls) +{ + return H5F_LIBVER_V110; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V112(JNIEnv *env, jclass cls){return H5F_LIBVER_V112;} +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V112(JNIEnv *env, jclass cls) +{ + return H5F_LIBVER_V112; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V114(JNIEnv *env, jclass cls){return H5F_LIBVER_V114;} +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1V114(JNIEnv *env, jclass cls) +{ + return H5F_LIBVER_V114; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1NBOUNDS(JNIEnv *env, jclass cls){return H5F_LIBVER_NBOUNDS;} +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1NBOUNDS(JNIEnv *env, jclass cls) +{ + return H5F_LIBVER_NBOUNDS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1LATEST(JNIEnv *env, jclass cls){return H5F_LIBVER_LATEST;} +Java_hdf_hdf5lib_HDF5Constants_H5F_1LIBVER_1LATEST(JNIEnv *env, jclass cls) +{ + return H5F_LIBVER_LATEST; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1ALL(JNIEnv *env, jclass cls) { return H5F_OBJ_ALL; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1ALL(JNIEnv *env, jclass cls) +{ + return H5F_OBJ_ALL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1ATTR(JNIEnv *env, jclass cls) { return H5F_OBJ_ATTR; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1ATTR(JNIEnv *env, jclass cls) +{ + return H5F_OBJ_ATTR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1DATASET(JNIEnv *env, jclass cls) { return H5F_OBJ_DATASET; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1DATASET(JNIEnv *env, jclass cls) +{ + return H5F_OBJ_DATASET; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1DATATYPE(JNIEnv *env, jclass cls) { return H5F_OBJ_DATATYPE; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1DATATYPE(JNIEnv *env, jclass cls) +{ + return H5F_OBJ_DATATYPE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1FILE(JNIEnv *env, jclass cls) { return H5F_OBJ_FILE; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1FILE(JNIEnv *env, jclass cls) +{ + return H5F_OBJ_FILE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1GROUP(JNIEnv *env, jclass cls) { return H5F_OBJ_GROUP; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1GROUP(JNIEnv *env, jclass cls) +{ + return H5F_OBJ_GROUP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1LOCAL(JNIEnv *env, jclass cls) { return H5F_OBJ_LOCAL; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1OBJ_1LOCAL(JNIEnv *env, jclass cls) +{ + return H5F_OBJ_LOCAL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1SCOPE_1GLOBAL(JNIEnv *env, jclass cls) { return H5F_SCOPE_GLOBAL; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1SCOPE_1GLOBAL(JNIEnv *env, jclass cls) +{ + return H5F_SCOPE_GLOBAL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1SCOPE_1LOCAL(JNIEnv *env, jclass cls) { return H5F_SCOPE_LOCAL; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1SCOPE_1LOCAL(JNIEnv *env, jclass cls) +{ + return H5F_SCOPE_LOCAL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1UNLIMITED(JNIEnv *env, jclass cls) { return (jint)H5F_UNLIMITED; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1UNLIMITED(JNIEnv *env, jclass cls) +{ + return (jint)H5F_UNLIMITED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1FSM_1AGGR(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_FSM_AGGR; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1FSM_1AGGR(JNIEnv *env, jclass cls) +{ + return H5F_FSPACE_STRATEGY_FSM_AGGR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1AGGR(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_AGGR; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1AGGR(JNIEnv *env, jclass cls) +{ + return H5F_FSPACE_STRATEGY_AGGR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1PAGE(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_PAGE; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1PAGE(JNIEnv *env, jclass cls) +{ + return H5F_FSPACE_STRATEGY_PAGE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1NONE(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_NONE; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1NONE(JNIEnv *env, jclass cls) +{ + return H5F_FSPACE_STRATEGY_NONE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1NTYPES(JNIEnv *env, jclass cls) { return H5F_FSPACE_STRATEGY_NTYPES; } +Java_hdf_hdf5lib_HDF5Constants_H5F_1FSPACE_1STRATEGY_1NTYPES(JNIEnv *env, jclass cls) +{ + return H5F_FSPACE_STRATEGY_NTYPES; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1CORE(JNIEnv *env, jclass cls) { return H5FD_CORE; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1CORE(JNIEnv *env, jclass cls) +{ + return H5FD_CORE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1DIRECT(JNIEnv *env, jclass cls) { +Java_hdf_hdf5lib_HDF5Constants_H5FD_1DIRECT(JNIEnv *env, jclass cls) +{ #ifdef H5_HAVE_DIRECT return H5FD_DIRECT; #else - return -1; + return H5I_INVALID_HID; #endif } JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1FAMILY(JNIEnv *env, jclass cls) { return H5FD_FAMILY; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1FAMILY(JNIEnv *env, jclass cls) +{ + return H5FD_FAMILY; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1HDFS(JNIEnv *env, jclass cls) { +Java_hdf_hdf5lib_HDF5Constants_H5FD_1HDFS(JNIEnv *env, jclass cls) +{ #ifdef H5_HAVE_LIBHDFS return H5FD_HDFS; #else - return -1; + return H5I_INVALID_HID; #endif } JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG(JNIEnv *env, jclass cls) { return H5FD_LOG; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG(JNIEnv *env, jclass cls) +{ + return H5FD_LOG; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MPIO(JNIEnv *env, jclass cls) { return H5FD_MPIO; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MPIO(JNIEnv *env, jclass cls) +{ + return H5FD_MPIO; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MULTI(JNIEnv *env, jclass cls) { return H5FD_MULTI; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MULTI(JNIEnv *env, jclass cls) +{ + return H5FD_MULTI; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1SEC2(JNIEnv *env, jclass cls) { return H5FD_SEC2; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1SEC2(JNIEnv *env, jclass cls) +{ + return H5FD_SEC2; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1ROS3(JNIEnv *env, jclass cls) { +Java_hdf_hdf5lib_HDF5Constants_H5FD_1ROS3(JNIEnv *env, jclass cls) +{ #ifdef H5_HAVE_ROS3_VFD return H5FD_ROS3; #else - return -1; + return H5I_INVALID_HID; #endif } JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1STDIO(JNIEnv *env, jclass cls) { return H5FD_STDIO; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1STDIO(JNIEnv *env, jclass cls) +{ + return H5FD_STDIO; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1WINDOWS(JNIEnv *env, jclass cls) { +Java_hdf_hdf5lib_HDF5Constants_H5FD_1WINDOWS(JNIEnv *env, jclass cls) +{ #ifdef H5_HAVE_WINDOWS return H5FD_DIRECT; #else - return -1; + return H5I_INVALID_HID; #endif } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1READ(JNIEnv *env, jclass cls) { return H5FD_LOG_LOC_READ; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1READ(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_LOC_READ; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1WRITE(JNIEnv *env, jclass cls) { return H5FD_LOG_LOC_WRITE; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1WRITE(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_LOC_WRITE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1SEEK(JNIEnv *env, jclass cls) { return H5FD_LOG_LOC_SEEK; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1SEEK(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_LOC_SEEK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1IO(JNIEnv *env, jclass cls) { return H5FD_LOG_LOC_IO; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1LOC_1IO(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_LOC_IO; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1READ(JNIEnv *env, jclass cls) { return H5FD_LOG_FILE_READ; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1READ(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_FILE_READ; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1WRITE(JNIEnv *env, jclass cls) { return H5FD_LOG_FILE_WRITE; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1WRITE(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_FILE_WRITE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1IO(JNIEnv *env, jclass cls) { return H5FD_LOG_FILE_IO; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FILE_1IO(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_FILE_IO; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FLAVOR(JNIEnv *env, jclass cls) { return H5FD_LOG_FLAVOR; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1FLAVOR(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_FLAVOR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1READ(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_READ; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1READ(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_NUM_READ; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1WRITE(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_WRITE; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1WRITE(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_NUM_WRITE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1SEEK(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_SEEK; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1SEEK(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_NUM_SEEK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1TRUNCATE(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_TRUNCATE; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1TRUNCATE(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_NUM_TRUNCATE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1IO(JNIEnv *env, jclass cls) { return H5FD_LOG_NUM_IO; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1NUM_1IO(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_NUM_IO; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1OPEN(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_OPEN; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1OPEN(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_TIME_OPEN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1STAT(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_STAT; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1STAT(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_TIME_STAT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1READ(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_READ; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1READ(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_TIME_READ; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1WRITE(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_WRITE; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1WRITE(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_TIME_WRITE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1SEEK(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_SEEK; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1SEEK(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_TIME_SEEK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1CLOSE(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_CLOSE; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1CLOSE(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_TIME_CLOSE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1IO(JNIEnv *env, jclass cls) { return H5FD_LOG_TIME_IO; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1TIME_1IO(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_TIME_IO; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1ALLOC(JNIEnv *env, jclass cls) { return H5FD_LOG_ALLOC; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1ALLOC(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_ALLOC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1ALL(JNIEnv *env, jclass cls) { return H5FD_LOG_ALL; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1LOG_1ALL(JNIEnv *env, jclass cls) +{ + return H5FD_LOG_ALL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1NOLIST(JNIEnv *env, jclass cls) { return H5FD_MEM_NOLIST; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1NOLIST(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_NOLIST; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT(JNIEnv *env, jclass cls) { return H5FD_MEM_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_DEFAULT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1SUPER(JNIEnv *env, jclass cls) { return H5FD_MEM_SUPER; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1SUPER(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_SUPER; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1BTREE(JNIEnv *env, jclass cls) { return H5FD_MEM_BTREE; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1BTREE(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_BTREE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DRAW(JNIEnv *env, jclass cls) { return H5FD_MEM_DRAW; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DRAW(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_DRAW; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1GHEAP(JNIEnv *env, jclass cls) { return H5FD_MEM_GHEAP; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1GHEAP(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_GHEAP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1LHEAP(JNIEnv *env, jclass cls) { return H5FD_MEM_LHEAP; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1LHEAP(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_LHEAP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1OHDR(JNIEnv *env, jclass cls) { return H5FD_MEM_OHDR; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1OHDR(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_OHDR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1NTYPES(JNIEnv *env, jclass cls) { return H5FD_MEM_NTYPES; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1NTYPES(JNIEnv *env, jclass cls) +{ + return H5FD_MEM_NTYPES; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1DEFAULT_1HADDR_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(HADDR_MAX/H5FD_MEM_NTYPES); } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1DEFAULT_1HADDR_1SIZE(JNIEnv *env, jclass cls) +{ + return (hsize_t)(HADDR_MAX / H5FD_MEM_NTYPES); +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)0; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1SIZE(JNIEnv *env, jclass cls) +{ + return (hsize_t)0; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1SUPER_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)0; } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1SUPER_1SIZE(JNIEnv *env, jclass cls) +{ + return (hsize_t)0; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1BTREE_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(1 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1BTREE_1SIZE(JNIEnv *env, jclass cls) +{ + return (hsize_t)(1 * (HADDR_MAX / (H5FD_MEM_NTYPES - 1))); +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1DRAW_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(2 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1DRAW_1SIZE(JNIEnv *env, jclass cls) +{ + return (hsize_t)(2 * (HADDR_MAX / (H5FD_MEM_NTYPES - 1))); +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1GHEAP_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(3 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1GHEAP_1SIZE(JNIEnv *env, jclass cls) +{ + return (hsize_t)(3 * (HADDR_MAX / (H5FD_MEM_NTYPES - 1))); +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1LHEAP_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(4 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1LHEAP_1SIZE(JNIEnv *env, jclass cls) +{ + return (hsize_t)(4 * (HADDR_MAX / (H5FD_MEM_NTYPES - 1))); +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1OHDR_1SIZE(JNIEnv *env, jclass cls) { return (hsize_t)(5 * (HADDR_MAX / (H5FD_MEM_NTYPES-1))); } - +Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1OHDR_1SIZE(JNIEnv *env, jclass cls) +{ + return (hsize_t)(5 * (HADDR_MAX / (H5FD_MEM_NTYPES - 1))); +} /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -574,147 +1306,351 @@ Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1OHDR_1SIZE(JNIEnv *env, jclas #ifndef H5_NO_DEPRECATED_SYMBOLS JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1DATASET(JNIEnv *env, jclass cls) { return H5G_DATASET; } -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1GROUP(JNIEnv *env, jclass cls) { return H5G_GROUP; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1DATASET(JNIEnv *env, jclass cls) +{ + return H5G_DATASET; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK(JNIEnv *env, jclass cls) { return H5G_LINK; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1GROUP(JNIEnv *env, jclass cls) +{ + return H5G_GROUP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1UDLINK(JNIEnv *env, jclass cls) { return H5G_UDLINK; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK(JNIEnv *env, jclass cls) +{ + return H5G_LINK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_15(JNIEnv *env, jclass cls) { return H5G_RESERVED_5; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1UDLINK(JNIEnv *env, jclass cls) +{ + return H5G_UDLINK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_16(JNIEnv *env, jclass cls) { return H5G_RESERVED_6; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_15(JNIEnv *env, jclass cls) +{ + return H5G_RESERVED_5; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_17(JNIEnv *env, jclass cls) { return H5G_RESERVED_7; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_16(JNIEnv *env, jclass cls) +{ + return H5G_RESERVED_6; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1TYPE(JNIEnv *env, jclass cls) { return H5G_TYPE; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1RESERVED_17(JNIEnv *env, jclass cls) +{ + return H5G_RESERVED_7; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1UNKNOWN(JNIEnv *env, jclass cls) { return H5G_UNKNOWN; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1TYPE(JNIEnv *env, jclass cls) +{ + return H5G_TYPE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1ERROR(JNIEnv *env, jclass cls) { return H5G_LINK_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1UNKNOWN(JNIEnv *env, jclass cls) +{ + return H5G_UNKNOWN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1HARD(JNIEnv *env, jclass cls) { return H5G_LINK_HARD; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1ERROR(JNIEnv *env, jclass cls) +{ + return H5G_LINK_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1SOFT(JNIEnv *env, jclass cls) { return H5G_LINK_SOFT; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1HARD(JNIEnv *env, jclass cls) +{ + return H5G_LINK_HARD; +} +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5G_1LINK_1SOFT(JNIEnv *env, jclass cls) +{ + return H5G_LINK_SOFT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1NLIBTYPES(JNIEnv *env, jclass cls) { return H5G_NLIBTYPES; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1NLIBTYPES(JNIEnv *env, jclass cls) +{ + return H5G_NLIBTYPES; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1NTYPES(JNIEnv *env, jclass cls) { return H5G_NTYPES; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1NTYPES(JNIEnv *env, jclass cls) +{ + return H5G_NTYPES; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1NUSERTYPES(JNIEnv *env, jclass cls) { return H5G_NUSERTYPES; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1NUSERTYPES(JNIEnv *env, jclass cls) +{ + return H5G_NUSERTYPES; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1SAME_1LOC(JNIEnv *env, jclass cls) { return H5G_SAME_LOC; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1SAME_1LOC(JNIEnv *env, jclass cls) +{ + return H5G_SAME_LOC; +} #endif /* H5_NO_DEPRECATED_SYMBOLS */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1UNKNOWN(JNIEnv *env, jclass cls){ return H5G_STORAGE_TYPE_UNKNOWN; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1UNKNOWN(JNIEnv *env, jclass cls) +{ + return H5G_STORAGE_TYPE_UNKNOWN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1SYMBOL_1TABLE(JNIEnv *env, jclass cls){ return H5G_STORAGE_TYPE_SYMBOL_TABLE; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1SYMBOL_1TABLE(JNIEnv *env, jclass cls) +{ + return H5G_STORAGE_TYPE_SYMBOL_TABLE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1COMPACT(JNIEnv *env, jclass cls){ return H5G_STORAGE_TYPE_COMPACT; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1COMPACT(JNIEnv *env, jclass cls) +{ + return H5G_STORAGE_TYPE_COMPACT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1DENSE(JNIEnv *env, jclass cls){ return H5G_STORAGE_TYPE_DENSE; } +Java_hdf_hdf5lib_HDF5Constants_H5G_1STORAGE_1TYPE_1DENSE(JNIEnv *env, jclass cls) +{ + return H5G_STORAGE_TYPE_DENSE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1UNINIT(JNIEnv *env, jclass cls) { return H5I_UNINIT; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1UNINIT(JNIEnv *env, jclass cls) +{ + return H5I_UNINIT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1BADID(JNIEnv *env, jclass cls) { return H5I_BADID; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1BADID(JNIEnv *env, jclass cls) +{ + return H5I_BADID; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1FILE(JNIEnv *env, jclass cls) { return H5I_FILE; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1FILE(JNIEnv *env, jclass cls) +{ + return H5I_FILE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1GROUP(JNIEnv *env, jclass cls) { return H5I_GROUP; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1GROUP(JNIEnv *env, jclass cls) +{ + return H5I_GROUP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1DATATYPE(JNIEnv *env, jclass cls) { return H5I_DATATYPE; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1DATATYPE(JNIEnv *env, jclass cls) +{ + return H5I_DATATYPE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASPACE(JNIEnv *env, jclass cls) { return H5I_DATASPACE; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASPACE(JNIEnv *env, jclass cls) +{ + return H5I_DATASPACE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASET(JNIEnv *env, jclass cls) { return H5I_DATASET; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASET(JNIEnv *env, jclass cls) +{ + return H5I_DATASET; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1ATTR(JNIEnv *env, jclass cls) { return H5I_ATTR; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1ATTR(JNIEnv *env, jclass cls) +{ + return H5I_ATTR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1VFL(JNIEnv *env, jclass cls) { return H5I_VFL; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1VFL(JNIEnv *env, jclass cls) +{ + return H5I_VFL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1VOL(JNIEnv *env, jclass cls) { return H5I_VOL; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1VOL(JNIEnv *env, jclass cls) +{ + return H5I_VOL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1INVALID_1HID(JNIEnv *env, jclass cls) { return H5I_INVALID_HID; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1INVALID_1HID(JNIEnv *env, jclass cls) +{ + return H5I_INVALID_HID; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1GENPROP_1CLS(JNIEnv *env, jclass cls) { return H5I_GENPROP_CLS; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1GENPROP_1CLS(JNIEnv *env, jclass cls) +{ + return H5I_GENPROP_CLS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1GENPROP_1LST(JNIEnv *env, jclass cls) { return H5I_GENPROP_LST; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1GENPROP_1LST(JNIEnv *env, jclass cls) +{ + return H5I_GENPROP_LST; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1CLASS(JNIEnv *env, jclass cls) { return H5I_ERROR_CLASS; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1CLASS(JNIEnv *env, jclass cls) +{ + return H5I_ERROR_CLASS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1MSG(JNIEnv *env, jclass cls) { return H5I_ERROR_MSG; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1MSG(JNIEnv *env, jclass cls) +{ + return H5I_ERROR_MSG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1STACK(JNIEnv *env, jclass cls) { return H5I_ERROR_STACK; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1ERROR_1STACK(JNIEnv *env, jclass cls) +{ + return H5I_ERROR_STACK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1NTYPES(JNIEnv *env, jclass cls) { return H5I_NTYPES; } +Java_hdf_hdf5lib_HDF5Constants_H5I_1NTYPES(JNIEnv *env, jclass cls) +{ + return H5I_NTYPES; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1ERROR(JNIEnv *env, jclass cls) { return H5L_TYPE_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1ERROR(JNIEnv *env, jclass cls) +{ + return H5L_TYPE_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1HARD(JNIEnv *env, jclass cls) { return H5L_TYPE_HARD; } +Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1HARD(JNIEnv *env, jclass cls) +{ + return H5L_TYPE_HARD; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1SOFT(JNIEnv *env, jclass cls) { return H5L_TYPE_SOFT; } +Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1SOFT(JNIEnv *env, jclass cls) +{ + return H5L_TYPE_SOFT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1EXTERNAL(JNIEnv *env, jclass cls) { return H5L_TYPE_EXTERNAL; } +Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1EXTERNAL(JNIEnv *env, jclass cls) +{ + return H5L_TYPE_EXTERNAL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1MAX(JNIEnv *env, jclass cls) { return H5L_TYPE_MAX; } +Java_hdf_hdf5lib_HDF5Constants_H5L_1TYPE_1MAX(JNIEnv *env, jclass cls) +{ + return H5L_TYPE_MAX; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1SHALLOW_1HIERARCHY_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_SHALLOW_HIERARCHY_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1SHALLOW_1HIERARCHY_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_COPY_SHALLOW_HIERARCHY_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1SOFT_1LINK_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_EXPAND_SOFT_LINK_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1SOFT_1LINK_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_COPY_EXPAND_SOFT_LINK_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1EXT_1LINK_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_EXPAND_EXT_LINK_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1EXT_1LINK_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_COPY_EXPAND_EXT_LINK_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1REFERENCE_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_EXPAND_REFERENCE_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1EXPAND_1REFERENCE_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_COPY_EXPAND_REFERENCE_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1WITHOUT_1ATTR_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_WITHOUT_ATTR_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1WITHOUT_1ATTR_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_COPY_WITHOUT_ATTR_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1PRESERVE_1NULL_1FLAG(JNIEnv *env, jclass cls){return H5O_COPY_PRESERVE_NULL_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1COPY_1PRESERVE_1NULL_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_COPY_PRESERVE_NULL_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1BASIC(JNIEnv *env, jclass cls) { return H5O_INFO_BASIC; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1BASIC(JNIEnv *env, jclass cls) +{ + return H5O_INFO_BASIC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1TIME(JNIEnv *env, jclass cls) { return H5O_INFO_TIME; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1TIME(JNIEnv *env, jclass cls) +{ + return H5O_INFO_TIME; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1NUM_1ATTRS(JNIEnv *env, jclass cls) { return H5O_INFO_NUM_ATTRS; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1NUM_1ATTRS(JNIEnv *env, jclass cls) +{ + return H5O_INFO_NUM_ATTRS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1ALL(JNIEnv *env, jclass cls) { return H5O_INFO_ALL; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1INFO_1ALL(JNIEnv *env, jclass cls) +{ + return H5O_INFO_ALL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1HDR(JNIEnv *env, jclass cls) { return H5O_NATIVE_INFO_HDR; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1HDR(JNIEnv *env, jclass cls) +{ + return H5O_NATIVE_INFO_HDR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1META_1SIZE(JNIEnv *env, jclass cls) { return H5O_NATIVE_INFO_META_SIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1META_1SIZE(JNIEnv *env, jclass cls) +{ + return H5O_NATIVE_INFO_META_SIZE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1ALL(JNIEnv *env, jclass cls) { return H5O_NATIVE_INFO_ALL; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1NATIVE_1INFO_1ALL(JNIEnv *env, jclass cls) +{ + return H5O_NATIVE_INFO_ALL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1NONE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_NONE_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1NONE_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_SHMESG_NONE_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1SDSPACE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_SDSPACE_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1SDSPACE_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_SHMESG_SDSPACE_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1DTYPE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_DTYPE_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1DTYPE_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_SHMESG_DTYPE_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1FILL_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_FILL_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1FILL_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_SHMESG_FILL_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1PLINE_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_PLINE_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1PLINE_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_SHMESG_PLINE_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1ATTR_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_ATTR_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1ATTR_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_SHMESG_ATTR_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1ALL_1FLAG(JNIEnv *env, jclass cls){return H5O_SHMESG_ALL_FLAG; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1SHMESG_1ALL_1FLAG(JNIEnv *env, jclass cls) +{ + return H5O_SHMESG_ALL_FLAG; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1UNKNOWN(JNIEnv *env, jclass cls) { return H5O_TYPE_UNKNOWN; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1UNKNOWN(JNIEnv *env, jclass cls) +{ + return H5O_TYPE_UNKNOWN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1GROUP(JNIEnv *env, jclass cls) { return H5O_TYPE_GROUP; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1GROUP(JNIEnv *env, jclass cls) +{ + return H5O_TYPE_GROUP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1DATASET(JNIEnv *env, jclass cls) { return H5O_TYPE_DATASET; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1DATASET(JNIEnv *env, jclass cls) +{ + return H5O_TYPE_DATASET; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1NAMED_1DATATYPE(JNIEnv *env, jclass cls) { return H5O_TYPE_NAMED_DATATYPE; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1NAMED_1DATATYPE(JNIEnv *env, jclass cls) +{ + return H5O_TYPE_NAMED_DATATYPE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1NTYPES(JNIEnv *env, jclass cls) { return H5O_TYPE_NTYPES; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1TYPE_1NTYPES(JNIEnv *env, jclass cls) +{ + return H5O_TYPE_NTYPES; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5O_1MAX_1TOKEN_1SIZE(JNIEnv *env, jclass cls) { return H5O_MAX_TOKEN_SIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5O_1MAX_1TOKEN_1SIZE(JNIEnv *env, jclass cls) +{ + return H5O_MAX_TOKEN_SIZE; +} JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_HDF5Constants_H5O_1TOKEN_1UNDEF(JNIEnv *env, jclass cls) { @@ -725,695 +1661,1711 @@ Java_hdf_hdf5lib_HDF5Constants_H5O_1TOKEN_1UNDEF(JNIEnv *env, jclass cls) } JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1ROOT(JNIEnv *env, jclass cls){return H5P_ROOT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1ROOT(JNIEnv *env, jclass cls) +{ + return H5P_ROOT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1CREATE(JNIEnv *env, jclass cls){return H5P_OBJECT_CREATE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1CREATE(JNIEnv *env, jclass cls) +{ + return H5P_OBJECT_CREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1CREATE(JNIEnv *env, jclass cls){return H5P_FILE_CREATE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1CREATE(JNIEnv *env, jclass cls) +{ + return H5P_FILE_CREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1ACCESS(JNIEnv *env, jclass cls){return H5P_FILE_ACCESS;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1ACCESS(JNIEnv *env, jclass cls) +{ + return H5P_FILE_ACCESS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1CREATE(JNIEnv *env, jclass cls){return H5P_DATASET_CREATE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1CREATE(JNIEnv *env, jclass cls) +{ + return H5P_DATASET_CREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1ACCESS(JNIEnv *env, jclass cls){return H5P_DATASET_ACCESS;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1ACCESS(JNIEnv *env, jclass cls) +{ + return H5P_DATASET_ACCESS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1XFER(JNIEnv *env, jclass cls){return H5P_DATASET_XFER;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1XFER(JNIEnv *env, jclass cls) +{ + return H5P_DATASET_XFER; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1MOUNT(JNIEnv *env, jclass cls){return H5P_FILE_MOUNT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1MOUNT(JNIEnv *env, jclass cls) +{ + return H5P_FILE_MOUNT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1CREATE(JNIEnv *env, jclass cls){return H5P_GROUP_CREATE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1CREATE(JNIEnv *env, jclass cls) +{ + return H5P_GROUP_CREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1ACCESS(JNIEnv *env, jclass cls){return H5P_GROUP_ACCESS;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1ACCESS(JNIEnv *env, jclass cls) +{ + return H5P_GROUP_ACCESS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1CREATE(JNIEnv *env, jclass cls){return H5P_DATATYPE_CREATE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1CREATE(JNIEnv *env, jclass cls) +{ + return H5P_DATATYPE_CREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1ACCESS(JNIEnv *env, jclass cls){return H5P_DATATYPE_ACCESS;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1ACCESS(JNIEnv *env, jclass cls) +{ + return H5P_DATATYPE_ACCESS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1STRING_1CREATE(JNIEnv *env, jclass cls){return H5P_STRING_CREATE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1STRING_1CREATE(JNIEnv *env, jclass cls) +{ + return H5P_STRING_CREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_CREATE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE(JNIEnv *env, jclass cls) +{ + return H5P_ATTRIBUTE_CREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1ACCESS(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_ACCESS;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1ACCESS(JNIEnv *env, jclass cls) +{ + return H5P_ATTRIBUTE_ACCESS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1COPY(JNIEnv *env, jclass cls){return H5P_OBJECT_COPY;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1COPY(JNIEnv *env, jclass cls) +{ + return H5P_OBJECT_COPY; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1CREATE(JNIEnv *env, jclass cls){return H5P_LINK_CREATE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1CREATE(JNIEnv *env, jclass cls) +{ + return H5P_LINK_CREATE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1ACCESS(JNIEnv *env, jclass cls){return H5P_LINK_ACCESS;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1ACCESS(JNIEnv *env, jclass cls) +{ + return H5P_LINK_ACCESS; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1VOL_1INITIALIZE(JNIEnv *env, jclass cls){return H5P_VOL_INITIALIZE;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1VOL_1INITIALIZE(JNIEnv *env, jclass cls) +{ + return H5P_VOL_INITIALIZE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_FILE_CREATE_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_FILE_CREATE_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_FILE_ACCESS_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_FILE_ACCESS_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATASET_CREATE_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1CREATE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_DATASET_CREATE_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATASET_ACCESS_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_DATASET_ACCESS_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1XFER_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATASET_XFER_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATASET_1XFER_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_DATASET_XFER_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1MOUNT_1DEFAULT(JNIEnv *env, jclass cls){return H5P_FILE_MOUNT_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1FILE_1MOUNT_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_FILE_MOUNT_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_GROUP_CREATE_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1CREATE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_GROUP_CREATE_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_GROUP_ACCESS_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_GROUP_ACCESS_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATATYPE_CREATE_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_DATATYPE_CREATE_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATATYPE_ACCESS_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_DATATYPE_ACCESS_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_CREATE_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_ATTRIBUTE_CREATE_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_ACCESS_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_ATTRIBUTE_ACCESS_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1COPY_1DEFAULT(JNIEnv *env, jclass cls){return H5P_OBJECT_COPY_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1COPY_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_OBJECT_COPY_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_LINK_CREATE_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1CREATE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_LINK_CREATE_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_LINK_ACCESS_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_LINK_ACCESS_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1VOL_1INITIALIZE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_VOL_INITIALIZE_DEFAULT;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1VOL_1INITIALIZE_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_VOL_INITIALIZE_DEFAULT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1CRT_1ORDER_1TRACKED(JNIEnv *env, jclass cls){return H5P_CRT_ORDER_TRACKED;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1CRT_1ORDER_1TRACKED(JNIEnv *env, jclass cls) +{ + return H5P_CRT_ORDER_TRACKED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1CRT_1ORDER_1INDEXED(JNIEnv *env, jclass cls){return H5P_CRT_ORDER_INDEXED;} +Java_hdf_hdf5lib_HDF5Constants_H5P_1CRT_1ORDER_1INDEXED(JNIEnv *env, jclass cls) +{ + return H5P_CRT_ORDER_INDEXED; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1DEFAULT(JNIEnv *env, jclass cls) { return H5P_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5P_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5P_DEFAULT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5P_1NO_1CLASS(JNIEnv *env, jclass cls) { return H5P_ROOT; } +Java_hdf_hdf5lib_HDF5Constants_H5P_1NO_1CLASS(JNIEnv *env, jclass cls) +{ + return H5P_ROOT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1ERROR(JNIEnv *env, jclass cls) { return H5PL_TYPE_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1ERROR(JNIEnv *env, jclass cls) +{ + return H5PL_TYPE_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1FILTER(JNIEnv *env, jclass cls) { return H5PL_TYPE_FILTER; } +Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1FILTER(JNIEnv *env, jclass cls) +{ + return H5PL_TYPE_FILTER; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1VOL(JNIEnv *env, jclass cls) { return H5PL_TYPE_VOL; } +Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1VOL(JNIEnv *env, jclass cls) +{ + return H5PL_TYPE_VOL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1NONE(JNIEnv *env, jclass cls) { return H5PL_TYPE_NONE; } +Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1NONE(JNIEnv *env, jclass cls) +{ + return H5PL_TYPE_NONE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5PL_1FILTER_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_FILTER_PLUGIN; } +Java_hdf_hdf5lib_HDF5Constants_H5PL_1FILTER_1PLUGIN(JNIEnv *env, jclass cls) +{ + return H5PL_FILTER_PLUGIN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5PL_1VOL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_VOL_PLUGIN; } +Java_hdf_hdf5lib_HDF5Constants_H5PL_1VOL_1PLUGIN(JNIEnv *env, jclass cls) +{ + return H5PL_VOL_PLUGIN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5PL_1ALL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_ALL_PLUGIN; } +Java_hdf_hdf5lib_HDF5Constants_H5PL_1ALL_1PLUGIN(JNIEnv *env, jclass cls) +{ + return H5PL_ALL_PLUGIN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1BADTYPE(JNIEnv *env, jclass cls) { return H5R_BADTYPE; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1BADTYPE(JNIEnv *env, jclass cls) +{ + return H5R_BADTYPE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1MAXTYPE(JNIEnv *env, jclass cls) { return H5R_MAXTYPE; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1MAXTYPE(JNIEnv *env, jclass cls) +{ + return H5R_MAXTYPE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) { return H5R_REF_BUF_SIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) +{ + return H5R_REF_BUF_SIZE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJ_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) { return H5R_OBJ_REF_BUF_SIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJ_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) +{ + return H5R_OBJ_REF_BUF_SIZE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1DSET_1REG_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) { return H5R_DSET_REG_REF_BUF_SIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1DSET_1REG_1REF_1BUF_1SIZE(JNIEnv *env, jclass cls) +{ + return H5R_DSET_REG_REF_BUF_SIZE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1ATTR(JNIEnv *env, jclass cls) { return H5R_ATTR; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1ATTR(JNIEnv *env, jclass cls) +{ + return H5R_ATTR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT(JNIEnv *env, jclass cls) { return H5R_OBJECT; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT(JNIEnv *env, jclass cls) +{ + return H5R_OBJECT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT1(JNIEnv *env, jclass cls) { return H5R_OBJECT1; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT1(JNIEnv *env, jclass cls) +{ + return H5R_OBJECT1; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT2(JNIEnv *env, jclass cls) { return H5R_OBJECT2; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1OBJECT2(JNIEnv *env, jclass cls) +{ + return H5R_OBJECT2; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION(JNIEnv *env, jclass cls) { return H5R_DATASET_REGION; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION(JNIEnv *env, jclass cls) +{ + return H5R_DATASET_REGION; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION1(JNIEnv *env, jclass cls) { return H5R_DATASET_REGION1; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION1(JNIEnv *env, jclass cls) +{ + return H5R_DATASET_REGION1; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION2(JNIEnv *env, jclass cls) { return H5R_DATASET_REGION2; } +Java_hdf_hdf5lib_HDF5Constants_H5R_1DATASET_1REGION2(JNIEnv *env, jclass cls) +{ + return H5R_DATASET_REGION2; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1ALL(JNIEnv *env, jclass cls) { return H5S_ALL; } -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1MAX_1RANK(JNIEnv *env, jclass cls) { return H5S_MAX_RANK; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1ALL(JNIEnv *env, jclass cls) +{ + return H5S_ALL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1NO_1CLASS(JNIEnv *env, jclass cls) { return H5S_NO_CLASS; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1MAX_1RANK(JNIEnv *env, jclass cls) +{ + return H5S_MAX_RANK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1NULL(JNIEnv *env, jclass cls) { return H5S_NULL; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1NO_1CLASS(JNIEnv *env, jclass cls) +{ + return H5S_NO_CLASS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SCALAR(JNIEnv *env, jclass cls) { return H5S_SCALAR; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1NULL(JNIEnv *env, jclass cls) +{ + return H5S_NULL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1ALL(JNIEnv *env, jclass cls) { return H5S_SEL_ALL; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SCALAR(JNIEnv *env, jclass cls) +{ + return H5S_SCALAR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1ERROR(JNIEnv *env, jclass cls) { return H5S_SEL_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1ALL(JNIEnv *env, jclass cls) +{ + return H5S_SEL_ALL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1HYPERSLABS(JNIEnv *env, jclass cls) { return H5S_SEL_HYPERSLABS; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1ERROR(JNIEnv *env, jclass cls) +{ + return H5S_SEL_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1N(JNIEnv *env, jclass cls) { return H5S_SEL_N; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1HYPERSLABS(JNIEnv *env, jclass cls) +{ + return H5S_SEL_HYPERSLABS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1NONE(JNIEnv *env, jclass cls) { return H5S_SEL_NONE; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1N(JNIEnv *env, jclass cls) +{ + return H5S_SEL_N; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1POINTS(JNIEnv *env, jclass cls) { return H5S_SEL_POINTS; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1NONE(JNIEnv *env, jclass cls) +{ + return H5S_SEL_NONE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1AND(JNIEnv *env, jclass cls) { return H5S_SELECT_AND; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SEL_1POINTS(JNIEnv *env, jclass cls) +{ + return H5S_SEL_POINTS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1APPEND(JNIEnv *env, jclass cls) { return H5S_SELECT_APPEND; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1AND(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_AND; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1INVALID(JNIEnv *env, jclass cls) { return H5S_SELECT_INVALID; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1APPEND(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_APPEND; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOOP(JNIEnv *env, jclass cls) { return H5S_SELECT_NOOP; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1INVALID(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_INVALID; +} +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOOP(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_NOOP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOTA(JNIEnv *env, jclass cls) { return H5S_SELECT_NOTA; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOTA(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_NOTA; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOTB(JNIEnv *env, jclass cls) { return H5S_SELECT_NOTB; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1NOTB(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_NOTB; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1OR(JNIEnv *env, jclass cls) { return H5S_SELECT_OR; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1OR(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_OR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1PREPEND(JNIEnv *env, jclass cls) { return H5S_SELECT_PREPEND; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1PREPEND(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_PREPEND; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1SET(JNIEnv *env, jclass cls) { return H5S_SELECT_SET; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1SET(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_SET; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1XOR(JNIEnv *env, jclass cls) { return H5S_SELECT_XOR; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SELECT_1XOR(JNIEnv *env, jclass cls) +{ + return H5S_SELECT_XOR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1SIMPLE(JNIEnv *env, jclass cls) { return H5S_SIMPLE; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1SIMPLE(JNIEnv *env, jclass cls) +{ + return H5S_SIMPLE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5S_1UNLIMITED(JNIEnv *env, jclass cls) { return (jint)H5S_UNLIMITED; } +Java_hdf_hdf5lib_HDF5Constants_H5S_1UNLIMITED(JNIEnv *env, jclass cls) +{ + return (jint)H5S_UNLIMITED; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B16(JNIEnv *env, jclass cls) { return H5T_ALPHA_B16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B16(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_B16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B32(JNIEnv *env, jclass cls) { return H5T_ALPHA_B32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B32(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_B32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B64(JNIEnv *env, jclass cls) { return H5T_ALPHA_B64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B64(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_B64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B8(JNIEnv *env, jclass cls) { return H5T_ALPHA_B8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1B8(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_B8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1F32(JNIEnv *env, jclass cls) { return H5T_ALPHA_F32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1F32(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_F32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1F64(JNIEnv *env, jclass cls) { return H5T_ALPHA_F64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1F64(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_F64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I16(JNIEnv *env, jclass cls) { return H5T_ALPHA_I16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I16(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_I16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I32(JNIEnv *env, jclass cls) { return H5T_ALPHA_I32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I32(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_I32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I64(JNIEnv *env, jclass cls) { return H5T_ALPHA_I64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I64(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_I64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I8(JNIEnv *env, jclass cls) { return H5T_ALPHA_I8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1I8(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_I8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U16(JNIEnv *env, jclass cls) { return H5T_ALPHA_U16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U16(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_U16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U32(JNIEnv *env, jclass cls) { return H5T_ALPHA_U32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U32(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_U32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U64(JNIEnv *env, jclass cls) { return H5T_ALPHA_U64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U64(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_U64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U8(JNIEnv *env, jclass cls) { return H5T_ALPHA_U8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ALPHA_1U8(JNIEnv *env, jclass cls) +{ + return H5T_ALPHA_U8; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ARRAY(JNIEnv *env, jclass cls) { return H5T_ARRAY; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ARRAY(JNIEnv *env, jclass cls) +{ + return H5T_ARRAY; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1BITFIELD(JNIEnv *env, jclass cls) { return H5T_BITFIELD; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1BITFIELD(JNIEnv *env, jclass cls) +{ + return H5T_BITFIELD; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1BKG_1NO(JNIEnv *env, jclass cls) { return H5T_BKG_NO; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1BKG_1NO(JNIEnv *env, jclass cls) +{ + return H5T_BKG_NO; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1BKG_1YES(JNIEnv *env, jclass cls) { return H5T_BKG_YES; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1BKG_1YES(JNIEnv *env, jclass cls) +{ + return H5T_BKG_YES; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1C_1S1(JNIEnv *env, jclass cls) { return H5T_C_S1; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1C_1S1(JNIEnv *env, jclass cls) +{ + return H5T_C_S1; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1COMPOUND(JNIEnv *env, jclass cls) { return H5T_COMPOUND; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1COMPOUND(JNIEnv *env, jclass cls) +{ + return H5T_COMPOUND; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1CONV(JNIEnv *env, jclass cls) { return H5T_CONV_CONV; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1CONV(JNIEnv *env, jclass cls) +{ + return H5T_CONV_CONV; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1FREE(JNIEnv *env, jclass cls) { return H5T_CONV_FREE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1FREE(JNIEnv *env, jclass cls) +{ + return H5T_CONV_FREE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1INIT(JNIEnv *env, jclass cls) { return H5T_CONV_INIT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CONV_1INIT(JNIEnv *env, jclass cls) +{ + return H5T_CONV_INIT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1ERROR(JNIEnv *env, jclass cls) { return H5T_CSET_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1ERROR(JNIEnv *env, jclass cls) +{ + return H5T_CSET_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1ASCII(JNIEnv *env, jclass cls) { return H5T_CSET_ASCII; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1ASCII(JNIEnv *env, jclass cls) +{ + return H5T_CSET_ASCII; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1UTF8(JNIEnv *env, jclass cls) { return H5T_CSET_UTF8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1UTF8(JNIEnv *env, jclass cls) +{ + return H5T_CSET_UTF8; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_110(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_10; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_110(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_10; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_111(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_11; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_111(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_11; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_112(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_12; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_112(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_12; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_113(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_13; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_113(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_13; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_114(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_14; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_114(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_14; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_115(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_15; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_115(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_15; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_12(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_2; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_12(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_2; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_13(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_3; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_13(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_3; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_14(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_4; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_14(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_4; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_15(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_5; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_15(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_5; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_16(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_6; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_16(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_6; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_17(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_7; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_17(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_7; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_18(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_18(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_8; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_19(JNIEnv *env, jclass cls) { return H5T_CSET_RESERVED_9; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1CSET_1RESERVED_19(JNIEnv *env, jclass cls) +{ + return H5T_CSET_RESERVED_9; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1ASCEND(JNIEnv *env, jclass cls) { return H5T_DIR_ASCEND; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1ASCEND(JNIEnv *env, jclass cls) +{ + return H5T_DIR_ASCEND; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1DEFAULT(JNIEnv *env, jclass cls) { return H5T_DIR_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5T_DIR_DEFAULT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1DESCEND(JNIEnv *env, jclass cls) { return H5T_DIR_DESCEND; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1DIR_1DESCEND(JNIEnv *env, jclass cls) +{ + return H5T_DIR_DESCEND; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ENUM(JNIEnv *env, jclass cls) { return H5T_ENUM; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ENUM(JNIEnv *env, jclass cls) +{ + return H5T_ENUM; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1FLOAT(JNIEnv *env, jclass cls) { return H5T_FLOAT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1FLOAT(JNIEnv *env, jclass cls) +{ + return H5T_FLOAT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1FORTRAN_1S1(JNIEnv *env, jclass cls) { return H5T_FORTRAN_S1; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1FORTRAN_1S1(JNIEnv *env, jclass cls) +{ + return H5T_FORTRAN_S1; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F32BE(JNIEnv *env, jclass cls) { return H5T_IEEE_F32BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F32BE(JNIEnv *env, jclass cls) +{ + return H5T_IEEE_F32BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F32LE(JNIEnv *env, jclass cls) { return H5T_IEEE_F32LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F32LE(JNIEnv *env, jclass cls) +{ + return H5T_IEEE_F32LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F64BE(JNIEnv *env, jclass cls) { return H5T_IEEE_F64BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F64BE(JNIEnv *env, jclass cls) +{ + return H5T_IEEE_F64BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F64LE(JNIEnv *env, jclass cls) { return H5T_IEEE_F64LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F64LE(JNIEnv *env, jclass cls) +{ + return H5T_IEEE_F64LE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEGER(JNIEnv *env, jclass cls) { return H5T_INTEGER; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEGER(JNIEnv *env, jclass cls) +{ + return H5T_INTEGER; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B16(JNIEnv *env, jclass cls) { return H5T_INTEL_B16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B16(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_B16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B32(JNIEnv *env, jclass cls) { return H5T_INTEL_B32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B32(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_B32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B64(JNIEnv *env, jclass cls) { return H5T_INTEL_B64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B64(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_B64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B8(JNIEnv *env, jclass cls) { return H5T_INTEL_B8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1B8(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_B8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1F32(JNIEnv *env, jclass cls) { return H5T_INTEL_F32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1F32(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_F32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1F64(JNIEnv *env, jclass cls) { return H5T_INTEL_F64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1F64(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_F64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I16(JNIEnv *env, jclass cls) { return H5T_INTEL_I16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I16(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_I16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I32(JNIEnv *env, jclass cls) { return H5T_INTEL_I32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I32(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_I32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I64(JNIEnv *env, jclass cls) { return H5T_INTEL_I64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I64(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_I64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I8(JNIEnv *env, jclass cls) { return H5T_INTEL_I8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1I8(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_I8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U16(JNIEnv *env, jclass cls) { return H5T_INTEL_U16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U16(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_U16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U32(JNIEnv *env, jclass cls) { return H5T_INTEL_U32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U32(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_U32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U64(JNIEnv *env, jclass cls) { return H5T_INTEL_U64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U64(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_U64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U8(JNIEnv *env, jclass cls) { return H5T_INTEL_U8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1INTEL_1U8(JNIEnv *env, jclass cls) +{ + return H5T_INTEL_U8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B16(JNIEnv *env, jclass cls) { return H5T_MIPS_B16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B16(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_B16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B32(JNIEnv *env, jclass cls) { return H5T_MIPS_B32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B32(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_B32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B64(JNIEnv *env, jclass cls) { return H5T_MIPS_B64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B64(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_B64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B8(JNIEnv *env, jclass cls) { return H5T_MIPS_B8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1B8(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_B8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1F32(JNIEnv *env, jclass cls) { return H5T_MIPS_F32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1F32(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_F32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1F64(JNIEnv *env, jclass cls) { return H5T_MIPS_F64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1F64(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_F64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I16(JNIEnv *env, jclass cls) { return H5T_MIPS_I16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I16(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_I16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I32(JNIEnv *env, jclass cls) { return H5T_MIPS_I32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I32(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_I32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I64(JNIEnv *env, jclass cls) { return H5T_MIPS_I64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I64(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_I64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I8(JNIEnv *env, jclass cls) { return H5T_MIPS_I8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1I8(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_I8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U16(JNIEnv *env, jclass cls) { return H5T_MIPS_U16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U16(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_U16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U32(JNIEnv *env, jclass cls) { return H5T_MIPS_U32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U32(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_U32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U64(JNIEnv *env, jclass cls) { return H5T_MIPS_U64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U64(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_U64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U8(JNIEnv *env, jclass cls) { return H5T_MIPS_U8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1MIPS_1U8(JNIEnv *env, jclass cls) +{ + return H5T_MIPS_U8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B16(JNIEnv *env, jclass cls) { return H5T_NATIVE_B16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B16(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_B16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B32(JNIEnv *env, jclass cls) { return H5T_NATIVE_B32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B32(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_B32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B64(JNIEnv *env, jclass cls) { return H5T_NATIVE_B64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B64(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_B64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B8(JNIEnv *env, jclass cls) { return H5T_NATIVE_B8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1B8(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_B8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1CHAR(JNIEnv *env, jclass cls) { return H5T_NATIVE_CHAR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1CHAR(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_CHAR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1DOUBLE(JNIEnv *env, jclass cls) { return H5T_NATIVE_DOUBLE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1DOUBLE(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_DOUBLE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1FLOAT(JNIEnv *env, jclass cls) { return H5T_NATIVE_FLOAT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1FLOAT(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_FLOAT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HADDR(JNIEnv *env, jclass cls) { return H5T_NATIVE_HADDR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HADDR(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_HADDR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HBOOL(JNIEnv *env, jclass cls) { return H5T_NATIVE_HBOOL; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HBOOL(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_HBOOL; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HERR(JNIEnv *env, jclass cls) { return H5T_NATIVE_HERR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HERR(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_HERR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HSIZE(JNIEnv *env, jclass cls) { return H5T_NATIVE_HSIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HSIZE(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_HSIZE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HSSIZE(JNIEnv *env, jclass cls) { return H5T_NATIVE_HSSIZE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HSSIZE(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_HSSIZE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST16(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_FAST16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST16(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT_FAST16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST32(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_FAST32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST32(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT_FAST32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST64(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_FAST64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST64(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT_FAST64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST8(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_FAST8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1FAST8(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT_FAST8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST16(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_LEAST16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST16(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT_LEAST16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST32(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_LEAST32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST32(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT_LEAST32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST64(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_LEAST64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST64(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT_LEAST64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST8(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT_LEAST8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT_1LEAST8(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT_LEAST8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT16(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT16(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT32(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT32(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT64(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT64(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT8(JNIEnv *env, jclass cls) { return H5T_NATIVE_INT8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1INT8(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_INT8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LDOUBLE(JNIEnv *env, jclass cls) { return H5T_NATIVE_LDOUBLE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LDOUBLE(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_LDOUBLE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LLONG(JNIEnv *env, jclass cls) { return H5T_NATIVE_LLONG; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LLONG(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_LLONG; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LONG(JNIEnv *env, jclass cls) { return H5T_NATIVE_LONG; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1LONG(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_LONG; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1OPAQUE(JNIEnv *env, jclass cls) { return H5T_NATIVE_OPAQUE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1OPAQUE(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_OPAQUE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1SCHAR(JNIEnv *env, jclass cls) { return H5T_NATIVE_SCHAR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1SCHAR(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_SCHAR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1SHORT(JNIEnv *env, jclass cls) { return H5T_NATIVE_SHORT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1SHORT(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_SHORT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UCHAR(JNIEnv *env, jclass cls) { return H5T_NATIVE_UCHAR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UCHAR(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UCHAR; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST16(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_FAST16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST16(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT_FAST16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST32(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_FAST32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST32(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT_FAST32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST64(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_FAST64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST64(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT_FAST64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST8(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_FAST8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1FAST8(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT_FAST8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST16(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_LEAST16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST16(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT_LEAST16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST32(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_LEAST32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST32(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT_LEAST32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST64(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_LEAST64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST64(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT_LEAST64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST8(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT_LEAST8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT_1LEAST8(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT_LEAST8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT16(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT16; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT16(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT16; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT32(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT32; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT32(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT32; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT64(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT64; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT64(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT64; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT8(JNIEnv *env, jclass cls) { return H5T_NATIVE_UINT8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1UINT8(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_UINT8; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1ULLONG(JNIEnv *env, jclass cls) { return H5T_NATIVE_ULLONG; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1ULLONG(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_ULLONG; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1ULONG(JNIEnv *env, jclass cls) { return H5T_NATIVE_ULONG; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1ULONG(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_ULONG; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1USHORT(JNIEnv *env, jclass cls) { return H5T_NATIVE_USHORT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1USHORT(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_USHORT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NCLASSES(JNIEnv *env, jclass cls) { return H5T_NCLASSES; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NCLASSES(JNIEnv *env, jclass cls) +{ + return H5T_NCLASSES; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NO_1CLASS(JNIEnv *env, jclass cls) { return H5T_NO_CLASS; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NO_1CLASS(JNIEnv *env, jclass cls) +{ + return H5T_NO_CLASS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1ERROR(JNIEnv *env, jclass cls) { return H5T_NORM_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1ERROR(JNIEnv *env, jclass cls) +{ + return H5T_NORM_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1IMPLIED(JNIEnv *env, jclass cls) { return H5T_NORM_IMPLIED; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1IMPLIED(JNIEnv *env, jclass cls) +{ + return H5T_NORM_IMPLIED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1MSBSET(JNIEnv *env, jclass cls) { return H5T_NORM_MSBSET; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1MSBSET(JNIEnv *env, jclass cls) +{ + return H5T_NORM_MSBSET; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1NONE(JNIEnv *env, jclass cls) { return H5T_NORM_NONE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NORM_1NONE(JNIEnv *env, jclass cls) +{ + return H5T_NORM_NONE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NPAD(JNIEnv *env, jclass cls) { return H5T_NPAD; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NPAD(JNIEnv *env, jclass cls) +{ + return H5T_NPAD; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1NSGN(JNIEnv *env, jclass cls) { return H5T_NSGN; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1NSGN(JNIEnv *env, jclass cls) +{ + return H5T_NSGN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1OPAQUE(JNIEnv *env, jclass cls) { return H5T_OPAQUE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1OPAQUE(JNIEnv *env, jclass cls) +{ + return H5T_OPAQUE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1OPAQUE_1TAG_1MAX(JNIEnv *env, jclass cls) { return H5T_OPAQUE_TAG_MAX; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1OPAQUE_1TAG_1MAX(JNIEnv *env, jclass cls) +{ + return H5T_OPAQUE_TAG_MAX; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1BE(JNIEnv *env, jclass cls) { return H5T_ORDER_BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1BE(JNIEnv *env, jclass cls) +{ + return H5T_ORDER_BE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1ERROR(JNIEnv *env, jclass cls) { return H5T_ORDER_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1ERROR(JNIEnv *env, jclass cls) +{ + return H5T_ORDER_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1LE(JNIEnv *env, jclass cls) { return H5T_ORDER_LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1LE(JNIEnv *env, jclass cls) +{ + return H5T_ORDER_LE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1NONE(JNIEnv *env, jclass cls) { return H5T_ORDER_NONE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1NONE(JNIEnv *env, jclass cls) +{ + return H5T_ORDER_NONE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1VAX(JNIEnv *env, jclass cls) { return H5T_ORDER_VAX; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1ORDER_1VAX(JNIEnv *env, jclass cls) +{ + return H5T_ORDER_VAX; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1BACKGROUND(JNIEnv *env, jclass cls) { return H5T_PAD_BACKGROUND; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1BACKGROUND(JNIEnv *env, jclass cls) +{ + return H5T_PAD_BACKGROUND; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ERROR(JNIEnv *env, jclass cls) { return H5T_PAD_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ERROR(JNIEnv *env, jclass cls) +{ + return H5T_PAD_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ONE(JNIEnv *env, jclass cls) { return H5T_PAD_ONE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ONE(JNIEnv *env, jclass cls) +{ + return H5T_PAD_ONE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ZERO(JNIEnv *env, jclass cls) { return H5T_PAD_ZERO; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1PAD_1ZERO(JNIEnv *env, jclass cls) +{ + return H5T_PAD_ZERO; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1DONTCARE(JNIEnv *env, jclass cls) { return H5T_PERS_DONTCARE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1DONTCARE(JNIEnv *env, jclass cls) +{ + return H5T_PERS_DONTCARE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1HARD(JNIEnv *env, jclass cls) { return H5T_PERS_HARD; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1HARD(JNIEnv *env, jclass cls) +{ + return H5T_PERS_HARD; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1SOFT(JNIEnv *env, jclass cls) { return H5T_PERS_SOFT; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1PERS_1SOFT(JNIEnv *env, jclass cls) +{ + return H5T_PERS_SOFT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1REFERENCE(JNIEnv *env, jclass cls) { return H5T_REFERENCE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1REFERENCE(JNIEnv *env, jclass cls) +{ + return H5T_REFERENCE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_12(JNIEnv *env, jclass cls) { return H5T_SGN_2; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_12(JNIEnv *env, jclass cls) +{ + return H5T_SGN_2; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_1ERROR(JNIEnv *env, jclass cls) { return H5T_SGN_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_1ERROR(JNIEnv *env, jclass cls) +{ + return H5T_SGN_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_1NONE(JNIEnv *env, jclass cls) { return H5T_SGN_NONE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1SGN_1NONE(JNIEnv *env, jclass cls) +{ + return H5T_SGN_NONE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B16BE(JNIEnv *env, jclass cls) { return H5T_STD_B16BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B16BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_B16BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B16LE(JNIEnv *env, jclass cls) { return H5T_STD_B16LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B16LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_B16LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B32BE(JNIEnv *env, jclass cls) { return H5T_STD_B32BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B32BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_B32BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B32LE(JNIEnv *env, jclass cls) { return H5T_STD_B32LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B32LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_B32LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B64BE(JNIEnv *env, jclass cls) { return H5T_STD_B64BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B64BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_B64BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B64LE(JNIEnv *env, jclass cls) { return H5T_STD_B64LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B64LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_B64LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B8BE(JNIEnv *env, jclass cls) { return H5T_STD_B8BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B8BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_B8BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B8LE(JNIEnv *env, jclass cls) { return H5T_STD_B8LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1B8LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_B8LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I16BE(JNIEnv *env, jclass cls) { return H5T_STD_I16BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I16BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_I16BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I16LE(JNIEnv *env, jclass cls) { return H5T_STD_I16LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I16LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_I16LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I32BE(JNIEnv *env, jclass cls) { return H5T_STD_I32BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I32BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_I32BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I32LE(JNIEnv *env, jclass cls) { return H5T_STD_I32LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I32LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_I32LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I64BE(JNIEnv *env, jclass cls) { return H5T_STD_I64BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I64BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_I64BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I64LE(JNIEnv *env, jclass cls) { return H5T_STD_I64LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I64LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_I64LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I8BE(JNIEnv *env, jclass cls) { return H5T_STD_I8BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I8BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_I8BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I8LE(JNIEnv *env, jclass cls) { return H5T_STD_I8LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1I8LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_I8LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF_1DSETREG(JNIEnv *env, jclass cls) { return H5T_STD_REF_DSETREG; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF_1DSETREG(JNIEnv *env, jclass cls) +{ + return H5T_STD_REF_DSETREG; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF_1OBJ(JNIEnv *env, jclass cls) { return H5T_STD_REF_OBJ; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF_1OBJ(JNIEnv *env, jclass cls) +{ + return H5T_STD_REF_OBJ; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF(JNIEnv *env, jclass cls) { return H5T_STD_REF; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1REF(JNIEnv *env, jclass cls) +{ + return H5T_STD_REF; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U16BE(JNIEnv *env, jclass cls) { return H5T_STD_U16BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U16BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_U16BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U16LE(JNIEnv *env, jclass cls) { return H5T_STD_U16LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U16LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_U16LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U32BE(JNIEnv *env, jclass cls) { return H5T_STD_U32BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U32BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_U32BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U32LE(JNIEnv *env, jclass cls) { return H5T_STD_U32LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U32LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_U32LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U64BE(JNIEnv *env, jclass cls) { return H5T_STD_U64BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U64BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_U64BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U64LE(JNIEnv *env, jclass cls) { return H5T_STD_U64LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U64LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_U64LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U8BE(JNIEnv *env, jclass cls) { return H5T_STD_U8BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U8BE(JNIEnv *env, jclass cls) +{ + return H5T_STD_U8BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U8LE(JNIEnv *env, jclass cls) { return H5T_STD_U8LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STD_1U8LE(JNIEnv *env, jclass cls) +{ + return H5T_STD_U8LE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1ERROR(JNIEnv *env, jclass cls) { return H5T_STR_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1ERROR(JNIEnv *env, jclass cls) +{ + return H5T_STR_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1NULLPAD(JNIEnv *env, jclass cls) { return H5T_STR_NULLPAD; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1NULLPAD(JNIEnv *env, jclass cls) +{ + return H5T_STR_NULLPAD; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1NULLTERM(JNIEnv *env, jclass cls) { return H5T_STR_NULLTERM; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1NULLTERM(JNIEnv *env, jclass cls) +{ + return H5T_STR_NULLTERM; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_110(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_10; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_110(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_10; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_111(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_11; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_111(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_11; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_112(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_12; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_112(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_12; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_113(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_13; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_113(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_13; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_114(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_14; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_114(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_14; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_115(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_15; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_115(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_15; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_13(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_3; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_13(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_3; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_14(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_4; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_14(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_4; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_15(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_5; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_15(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_5; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_16(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_6; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_16(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_6; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_17(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_7; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_17(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_7; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_18(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_8; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_18(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_8; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_19(JNIEnv *env, jclass cls) { return H5T_STR_RESERVED_9; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1RESERVED_19(JNIEnv *env, jclass cls) +{ + return H5T_STR_RESERVED_9; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1SPACEPAD(JNIEnv *env, jclass cls) { return H5T_STR_SPACEPAD; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STR_1SPACEPAD(JNIEnv *env, jclass cls) +{ + return H5T_STR_SPACEPAD; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1STRING(JNIEnv *env, jclass cls) { return H5T_STRING; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1STRING(JNIEnv *env, jclass cls) +{ + return H5T_STRING; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1TIME(JNIEnv *env, jclass cls) { return H5T_TIME; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1TIME(JNIEnv *env, jclass cls) +{ + return H5T_TIME; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D32BE(JNIEnv *env, jclass cls) { return H5T_UNIX_D32BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D32BE(JNIEnv *env, jclass cls) +{ + return H5T_UNIX_D32BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D32LE(JNIEnv *env, jclass cls) { return H5T_UNIX_D32LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D32LE(JNIEnv *env, jclass cls) +{ + return H5T_UNIX_D32LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D64BE(JNIEnv *env, jclass cls) { return H5T_UNIX_D64BE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D64BE(JNIEnv *env, jclass cls) +{ + return H5T_UNIX_D64BE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D64LE(JNIEnv *env, jclass cls) { return H5T_UNIX_D64LE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1UNIX_1D64LE(JNIEnv *env, jclass cls) +{ + return H5T_UNIX_D64LE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1VARIABLE(JNIEnv *env, jclass cls) { return (int)H5T_VARIABLE; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1VARIABLE(JNIEnv *env, jclass cls) +{ + return (int)H5T_VARIABLE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1VLEN(JNIEnv *env, jclass cls) { return H5T_VLEN; } +Java_hdf_hdf5lib_HDF5Constants_H5T_1VLEN(JNIEnv *env, jclass cls) +{ + return H5T_VLEN; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5T_1VL_1T(JNIEnv *env, jclass cls) { return sizeof(hvl_t); } +Java_hdf_hdf5lib_HDF5Constants_H5T_1VL_1T(JNIEnv *env, jclass cls) +{ + return sizeof(hvl_t); +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1NONE(JNIEnv *env, jclass cls) { return H5VL_CAP_FLAG_NONE; } +Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1NONE(JNIEnv *env, jclass cls) +{ + return H5VL_CAP_FLAG_NONE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1THREADSAFE(JNIEnv *env, jclass cls) { return H5VL_CAP_FLAG_THREADSAFE; } +Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1THREADSAFE(JNIEnv *env, jclass cls) +{ + return H5VL_CAP_FLAG_THREADSAFE; +} JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE(JNIEnv *env, jclass cls) { return H5VL_NATIVE; } +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE(JNIEnv *env, jclass cls) +{ + return H5VL_NATIVE; +} JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1NAME(JNIEnv *env, jclass cls) { return (jstring)ENVPTR->NewStringUTF(ENVONLY, H5VL_NATIVE_NAME); } +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1NAME(JNIEnv *env, jclass cls) +{ + return (jstring)ENVPTR->NewStringUTF(ENVONLY, H5VL_NATIVE_NAME); +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VALUE(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VALUE; } +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VALUE(JNIEnv *env, jclass cls) +{ + return H5VL_NATIVE_VALUE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VERSION(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VERSION; } +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VERSION(JNIEnv *env, jclass cls) +{ + return H5VL_NATIVE_VERSION; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1INVALID(JNIEnv *env, jclass cls) { return H5_VOL_INVALID; } +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1INVALID(JNIEnv *env, jclass cls) +{ + return H5_VOL_INVALID; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1NATIVE(JNIEnv *env, jclass cls) { return H5_VOL_NATIVE; } +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1NATIVE(JNIEnv *env, jclass cls) +{ + return H5_VOL_NATIVE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1RESERVED(JNIEnv *env, jclass cls) { return H5_VOL_RESERVED; } +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1RESERVED(JNIEnv *env, jclass cls) +{ + return H5_VOL_RESERVED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1MAX(JNIEnv *env, jclass cls) { return H5_VOL_MAX; } +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1MAX(JNIEnv *env, jclass cls) +{ + return H5_VOL_MAX; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) +{ + return H5Z_CB_CONT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1ERROR(JNIEnv *env, jclass cls) { return H5Z_CB_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1ERROR(JNIEnv *env, jclass cls) +{ + return H5Z_CB_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1FAIL(JNIEnv *env, jclass cls) { return H5Z_CB_FAIL; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1FAIL(JNIEnv *env, jclass cls) +{ + return H5Z_CB_FAIL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1NO(JNIEnv *env, jclass cls) { return H5Z_CB_NO; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1NO(JNIEnv *env, jclass cls) +{ + return H5Z_CB_NO; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1DISABLE_1EDC(JNIEnv *env, jclass cls) { return H5Z_DISABLE_EDC; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1DISABLE_1EDC(JNIEnv *env, jclass cls) +{ + return H5Z_DISABLE_EDC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1ENABLE_1EDC(JNIEnv *env, jclass cls) { return H5Z_ENABLE_EDC; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1ENABLE_1EDC(JNIEnv *env, jclass cls) +{ + return H5Z_ENABLE_EDC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1ERROR_1EDC(JNIEnv *env, jclass cls) { return H5Z_ERROR_EDC; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1ERROR_1EDC(JNIEnv *env, jclass cls) +{ + return H5Z_ERROR_EDC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1CONFIG_1DECODE_1ENABLED(JNIEnv *env, jclass cls) { return H5Z_FILTER_CONFIG_DECODE_ENABLED; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1CONFIG_1DECODE_1ENABLED(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_CONFIG_DECODE_ENABLED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1CONFIG_1ENCODE_1ENABLED(JNIEnv *env, jclass cls) { return H5Z_FILTER_CONFIG_ENCODE_ENABLED; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1CONFIG_1ENCODE_1ENABLED(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_CONFIG_ENCODE_ENABLED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1DEFLATE(JNIEnv *env, jclass cls) { return H5Z_FILTER_DEFLATE; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1DEFLATE(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_DEFLATE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1ERROR(JNIEnv *env, jclass cls) { return H5Z_FILTER_ERROR; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1ERROR(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_ERROR; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1FLETCHER32(JNIEnv *env, jclass cls) { return H5Z_FILTER_FLETCHER32; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1FLETCHER32(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_FLETCHER32; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1MAX(JNIEnv *env, jclass cls) { return H5Z_FILTER_MAX; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1MAX(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_MAX; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1NBIT(JNIEnv *env, jclass cls) {return H5Z_FILTER_NBIT; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1NBIT(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_NBIT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1NONE(JNIEnv *env, jclass cls) { return H5Z_FILTER_NONE; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1NONE(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_NONE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1RESERVED(JNIEnv *env, jclass cls) { return H5Z_FILTER_RESERVED; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1RESERVED(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_RESERVED; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SCALEOFFSET(JNIEnv *env, jclass cls){ return H5Z_FILTER_SCALEOFFSET; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SCALEOFFSET(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_SCALEOFFSET; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SHUFFLE(JNIEnv *env, jclass cls) { return H5Z_FILTER_SHUFFLE; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SHUFFLE(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_SHUFFLE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SZIP(JNIEnv *env, jclass cls) { return H5Z_FILTER_SZIP; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1SZIP(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_SZIP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1DEFMASK(JNIEnv *env, jclass cls) { return H5Z_FLAG_DEFMASK; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1DEFMASK(JNIEnv *env, jclass cls) +{ + return H5Z_FLAG_DEFMASK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1INVMASK(JNIEnv *env, jclass cls) { return H5Z_FLAG_INVMASK; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1INVMASK(JNIEnv *env, jclass cls) +{ + return H5Z_FLAG_INVMASK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1MANDATORY(JNIEnv *env, jclass cls) { return H5Z_FLAG_MANDATORY; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1MANDATORY(JNIEnv *env, jclass cls) +{ + return H5Z_FLAG_MANDATORY; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1OPTIONAL(JNIEnv *env, jclass cls) { return H5Z_FLAG_OPTIONAL; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1OPTIONAL(JNIEnv *env, jclass cls) +{ + return H5Z_FLAG_OPTIONAL; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1REVERSE(JNIEnv *env, jclass cls) { return H5Z_FLAG_REVERSE; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1REVERSE(JNIEnv *env, jclass cls) +{ + return H5Z_FLAG_REVERSE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1SKIP_1EDC(JNIEnv *env, jclass cls) { return H5Z_FLAG_SKIP_EDC; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FLAG_1SKIP_1EDC(JNIEnv *env, jclass cls) +{ + return H5Z_FLAG_SKIP_EDC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1MAX_1NFILTERS(JNIEnv *env, jclass cls) { return H5Z_MAX_NFILTERS; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1MAX_1NFILTERS(JNIEnv *env, jclass cls) +{ + return H5Z_MAX_NFILTERS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1NO_1EDC(JNIEnv *env, jclass cls) { return H5Z_NO_EDC; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1NO_1EDC(JNIEnv *env, jclass cls) +{ + return H5Z_NO_EDC; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1INT_1MINBITS_1DEFAULT(JNIEnv *env, jclass cls) { return H5Z_SO_INT_MINBITS_DEFAULT; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1INT_1MINBITS_1DEFAULT(JNIEnv *env, jclass cls) +{ + return H5Z_SO_INT_MINBITS_DEFAULT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1FLOAT_1DSCALE(JNIEnv *env, jclass cls){return H5Z_SO_FLOAT_DSCALE; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1FLOAT_1DSCALE(JNIEnv *env, jclass cls) +{ + return H5Z_SO_FLOAT_DSCALE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1FLOAT_1ESCALE(JNIEnv *env, jclass cls){return H5Z_SO_FLOAT_ESCALE; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1FLOAT_1ESCALE(JNIEnv *env, jclass cls) +{ + return H5Z_SO_FLOAT_ESCALE; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1INT(JNIEnv *env, jclass cls){return H5Z_SO_INT; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SO_1INT(JNIEnv *env, jclass cls) +{ + return H5Z_SO_INT; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SHUFFLE_1USER_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SHUFFLE_USER_NPARMS; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SHUFFLE_1USER_1NPARMS(JNIEnv *env, jclass cls) +{ + return H5Z_SHUFFLE_USER_NPARMS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SHUFFLE_1TOTAL_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SHUFFLE_TOTAL_NPARMS; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SHUFFLE_1TOTAL_1NPARMS(JNIEnv *env, jclass cls) +{ + return H5Z_SHUFFLE_TOTAL_NPARMS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1USER_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SZIP_USER_NPARMS; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1USER_1NPARMS(JNIEnv *env, jclass cls) +{ + return H5Z_SZIP_USER_NPARMS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1TOTAL_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SZIP_TOTAL_NPARMS; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1TOTAL_1NPARMS(JNIEnv *env, jclass cls) +{ + return H5Z_SZIP_TOTAL_NPARMS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1MASK(JNIEnv *env, jclass cls) { return H5Z_SZIP_PARM_MASK; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1MASK(JNIEnv *env, jclass cls) +{ + return H5Z_SZIP_PARM_MASK; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1PPB(JNIEnv *env, jclass cls) { return H5Z_SZIP_PARM_PPB; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1PPB(JNIEnv *env, jclass cls) +{ + return H5Z_SZIP_PARM_PPB; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1BPP(JNIEnv *env, jclass cls) { return H5Z_SZIP_PARM_BPP; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1BPP(JNIEnv *env, jclass cls) +{ + return H5Z_SZIP_PARM_BPP; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1PPS(JNIEnv *env, jclass cls) { return H5Z_SZIP_PARM_PPS; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SZIP_1PARM_1PPS(JNIEnv *env, jclass cls) +{ + return H5Z_SZIP_PARM_PPS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1NBIT_1USER_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_NBIT_USER_NPARMS; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1NBIT_1USER_1NPARMS(JNIEnv *env, jclass cls) +{ + return H5Z_NBIT_USER_NPARMS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1SCALEOFFSET_1USER_1NPARMS(JNIEnv *env, jclass cls) { return H5Z_SCALEOFFSET_USER_NPARMS; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1SCALEOFFSET_1USER_1NPARMS(JNIEnv *env, jclass cls) +{ + return H5Z_SCALEOFFSET_USER_NPARMS; +} JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1ALL(JNIEnv *env, jclass cls) { return H5Z_FILTER_ALL; } +Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1ALL(JNIEnv *env, jclass cls) +{ + return H5Z_FILTER_ALL; +} -H5_GCC_DIAG_ON(missing-prototypes) -H5_GCC_DIAG_ON(unused-parameter) +H5_GCC_DIAG_ON("missing-prototypes") +H5_GCC_DIAG_ON("unused-parameter") #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ - diff --git a/java/src/jni/h5Imp.c b/java/src/jni/h5Imp.c index f0dd691..5773fff 100644 --- a/java/src/jni/h5Imp.c +++ b/java/src/jni/h5Imp.c @@ -46,8 +46,7 @@ extern "C" { * Signature: ()I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5open - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5open(JNIEnv *env, jclass clss) { herr_t retVal = FAIL; @@ -66,8 +65,7 @@ done: * Signature: ()I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5close - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5close(JNIEnv *env, jclass clss) { herr_t retVal = FAIL; @@ -86,8 +84,7 @@ done: * Signature: ()I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5dont_1atexit - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5dont_1atexit(JNIEnv *env, jclass clss) { herr_t retVal = FAIL; @@ -106,21 +103,22 @@ done: * Signature: ([I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5get_1libversion - (JNIEnv *env, jclass clss, jintArray libversion) +Java_hdf_hdf5lib_H5_H5get_1libversion(JNIEnv *env, jclass clss, jintArray libversion) { - jboolean libversionArrayIsCopy; - int *libversionArray = NULL; - herr_t status = FAIL; + jboolean libversionArrayIsCopy; + int * libversionArray = NULL; + herr_t status = FAIL; UNUSED(clss); if (libversion == NULL) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5get_libversion: libversion is NULL"); - PIN_INT_ARRAY(ENVONLY, libversion, libversionArray, &libversionArrayIsCopy, "H5get_libversion: libversion input not pinned"); + PIN_INT_ARRAY(ENVONLY, libversion, libversionArray, &libversionArrayIsCopy, + "H5get_libversion: libversion input not pinned"); - if ((status = H5get_libversion((unsigned *) &(libversionArray[0]), (unsigned *) &(libversionArray[1]), (unsigned *) &(libversionArray[2]))) < 0) + if ((status = H5get_libversion((unsigned *)&(libversionArray[0]), (unsigned *)&(libversionArray[1]), + (unsigned *)&(libversionArray[2]))) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -136,8 +134,7 @@ done: * Signature: (III)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5check_1version - (JNIEnv *env, jclass clss, jint majnum, jint minnum, jint relnum) +Java_hdf_hdf5lib_H5_H5check_1version(JNIEnv *env, jclass clss, jint majnum, jint minnum, jint relnum) { UNUSED(env); UNUSED(clss); @@ -152,8 +149,7 @@ Java_hdf_hdf5lib_H5_H5check_1version * */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5garbage_1collect - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5garbage_1collect(JNIEnv *env, jclass clss) { herr_t retVal = FAIL; @@ -172,16 +168,16 @@ done: * Signature: (IIIIII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits - (JNIEnv *env, jclass clss, jint reg_global_lim, jint reg_list_lim, - jint arr_global_lim, jint arr_list_lim, jint blk_global_lim, jint blk_list_lim ) +Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits(JNIEnv *env, jclass clss, jint reg_global_lim, + jint reg_list_lim, jint arr_global_lim, jint arr_list_lim, + jint blk_global_lim, jint blk_list_lim) { herr_t retVal = FAIL; UNUSED(clss); - if ((retVal = H5set_free_list_limits((int)reg_global_lim, (int)reg_list_lim, - (int)arr_global_lim, (int)arr_list_lim, (int)blk_global_lim, (int)blk_list_lim)) < 0) + if ((retVal = H5set_free_list_limits((int)reg_global_lim, (int)reg_list_lim, (int)arr_global_lim, + (int)arr_list_lim, (int)blk_global_lim, (int)blk_list_lim)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -194,8 +190,7 @@ done: * Signature: ()Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe(JNIEnv *env, jclass clss) { hbool_t is_ts = false; @@ -208,7 +203,6 @@ done: return (jboolean)is_ts; } /* end Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe */ - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5Imp.h b/java/src/jni/h5Imp.h index 756b8bb..696d7d2 100644 --- a/java/src/jni/h5Imp.h +++ b/java/src/jni/h5Imp.h @@ -26,45 +26,35 @@ extern "C" { * Method: H5open * Signature: ()I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5open - (JNIEnv *, jclass); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5open(JNIEnv *, jclass); /* * Class: hdf_hdf5lib_H5 * Method: H5close * Signature: ()I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5close - (JNIEnv *, jclass); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5close(JNIEnv *, jclass); /* * Class: hdf_hdf5lib_H5 * Method: H5dont_atexit * Signature: ()I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5dont_1atexit - (JNIEnv *, jclass); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5dont_1atexit(JNIEnv *, jclass); /* * Class: hdf_hdf5lib_H5 * Method: H5get_libversion * Signature: ([I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5get_1libversion - (JNIEnv *, jclass, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5get_1libversion(JNIEnv *, jclass, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5check_version * Signature: (III)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5check_1version - (JNIEnv *, jclass, jint, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5check_1version(JNIEnv *, jclass, jint, jint, jint); /* * Class: hdf_hdf5lib_H5 @@ -72,27 +62,22 @@ Java_hdf_hdf5lib_H5_H5check_1version * Signature: ()I * */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5garbage_1collect - (JNIEnv *, jclass); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5garbage_1collect(JNIEnv *, jclass); /* * Class: hdf_hdf5lib_H5 * Method: H5set_free_list_limits * Signature: (IIIIII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits - (JNIEnv *, jclass, jint, jint, jint, jint, jint, jint ); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits(JNIEnv *, jclass, jint, jint, jint, jint, + jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5is_library_threadsafe * Signature: ()Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe - (JNIEnv *, jclass); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe(JNIEnv *, jclass); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index 8b3f9e5..fdfa14c 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -54,19 +54,17 @@ static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *inf /* Local Macros */ /********************/ - /* * Class: hdf_hdf5lib_H5 * Method: H5Acreate * Signature: (JLjava/lang/String;JJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Acreate - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, - jlong space_id, jlong create_plist) +Java_hdf_hdf5lib_H5__1H5Acreate(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, + jlong space_id, jlong create_plist) { const char *attrName = NULL; - hid_t attr_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; UNUSED(clss); @@ -75,7 +73,8 @@ Java_hdf_hdf5lib_H5__1H5Acreate PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Acreate: attribute name not pinned"); - if ((attr_id = H5Acreate2((hid_t)loc_id, attrName, (hid_t)type_id, (hid_t)space_id, (hid_t)create_plist, (hid_t)H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2((hid_t)loc_id, attrName, (hid_t)type_id, (hid_t)space_id, (hid_t)create_plist, + (hid_t)H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -91,13 +90,12 @@ done: * Signature: (JLjava/lang/String;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring name) +Java_hdf_hdf5lib_H5__1H5Aopen_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name) { #ifndef H5_NO_DEPRECATED_SYMBOLS const char *attrName = NULL; #endif - hid_t attr_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; UNUSED(clss); @@ -111,7 +109,7 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1name PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Aopen_name: attribute name not pinned"); - if((attr_id = H5Aopen_name((hid_t)loc_id, attrName)) < 0) + if ((attr_id = H5Aopen_name((hid_t)loc_id, attrName)) < 0) H5_LIBRARY_ERROR(ENVONLY); #endif @@ -130,8 +128,7 @@ done: * Signature: (JI)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jint idx) +Java_hdf_hdf5lib_H5__1H5Aopen_1idx(JNIEnv *env, jclass clss, jlong loc_id, jint idx) { hid_t attr_id = H5I_INVALID_HID; @@ -142,7 +139,7 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1idx UNUSED(idx); H5_UNIMPLEMENTED(ENVONLY, "H5Aopen_idx: not implemented"); #else - if ((attr_id = H5Aopen_idx((hid_t) loc_id, (unsigned int) idx)) < 0) + if ((attr_id = H5Aopen_idx((hid_t)loc_id, (unsigned int)idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); #endif @@ -156,13 +153,13 @@ done: * Signature: (JJ[BZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Aread(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, + jboolean isCriticalPinning) { - jboolean readBufIsCopy; - jbyte *readBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean readBufIsCopy; + jbyte * readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -183,7 +180,8 @@ Java_hdf_hdf5lib_H5_H5Aread H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread: variable length type not supported"); if (isCriticalPinning) { - PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread: read buffer not critically pinned"); + PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Aread: read buffer not critically pinned"); } else { PIN_BYTE_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread: read buffer not pinned"); @@ -211,13 +209,13 @@ done: * Signature: (JJ[BZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Awrite(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, + jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - jbyte *writeBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean writeBufIsCopy; + jbyte * writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -238,7 +236,8 @@ Java_hdf_hdf5lib_H5_H5Awrite H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite: variable length type not supported"); if (isCriticalPinning) { - PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite: write buffer not critically pinned"); + PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Awrite: write buffer not critically pinned"); } else { PIN_BYTE_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite: write buffer not pinned"); @@ -266,13 +265,13 @@ done: * Signature: (JJ[SZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1short - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jshortArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Aread_1short(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jshortArray buf, jboolean isCriticalPinning) { - jboolean readBufIsCopy; - jshort *readBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean readBufIsCopy; + jshort * readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -293,7 +292,8 @@ Java_hdf_hdf5lib_H5_H5Aread_1short H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_short: variable length type not supported"); if (isCriticalPinning) { - PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_short: read buffer not critically pinned"); + PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Aread_short: read buffer not critically pinned"); } else { PIN_SHORT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_short: read buffer not pinned"); @@ -321,13 +321,13 @@ done: * Signature: (JJ[SZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1short - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jshortArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Awrite_1short(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jshortArray buf, jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - jshort *writeBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean writeBufIsCopy; + jshort * writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -348,7 +348,8 @@ Java_hdf_hdf5lib_H5_H5Awrite_1short H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_short: variable length type not supported"); if (isCriticalPinning) { - PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_short: write buffer not critically pinned"); + PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Awrite_short: write buffer not critically pinned"); } else { PIN_SHORT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_short: write buffer not pinned"); @@ -376,13 +377,13 @@ done: * Signature: (JJ[IZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1int - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Aread_1int(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, + jboolean isCriticalPinning) { - jboolean readBufIsCopy; - htri_t data_class; - jint *readBuf = NULL; - herr_t status = FAIL; + jboolean readBufIsCopy; + htri_t data_class; + jint * readBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -403,7 +404,8 @@ Java_hdf_hdf5lib_H5_H5Aread_1int H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_int: variable length type not supported"); if (isCriticalPinning) { - PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_int: read buffer not critically pinned"); + PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Aread_int: read buffer not critically pinned"); } else { PIN_INT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_int: read buffer not pinned"); @@ -431,13 +433,13 @@ done: * Signature: (JJ[IZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1int - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Awrite_1int(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, + jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - jint *writeBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean writeBufIsCopy; + jint * writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -458,7 +460,8 @@ Java_hdf_hdf5lib_H5_H5Awrite_1int H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_int: variable length type not supported"); if (isCriticalPinning) { - PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_int: write buffer not critically pinned"); + PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Awrite_int: write buffer not critically pinned"); } else { PIN_INT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_int: write buffer not pinned"); @@ -486,13 +489,13 @@ done: * Signature: (JJ[JZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1long - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Aread_1long(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, + jboolean isCriticalPinning) { - jboolean readBufIsCopy; - jlong *readBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean readBufIsCopy; + jlong * readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -513,7 +516,8 @@ Java_hdf_hdf5lib_H5_H5Aread_1long H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_long: variable length type not supported"); if (isCriticalPinning) { - PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_long: read buffer not critically pinned"); + PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Aread_long: read buffer not critically pinned"); } else { PIN_LONG_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_long: read buffer not pinned"); @@ -541,13 +545,13 @@ done: * Signature: (JJ[JZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1long - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Awrite_1long(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, + jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - jlong *writeBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean writeBufIsCopy; + jlong * writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -568,7 +572,8 @@ Java_hdf_hdf5lib_H5_H5Awrite_1long H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_long: variable length type not supported"); if (isCriticalPinning) { - PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_long: write buffer not critically pinned"); + PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Awrite_long: write buffer not critically pinned"); } else { PIN_LONG_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_long: write buffer not pinned"); @@ -596,13 +601,13 @@ done: * Signature: (JJ[FZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1float - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jfloatArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Aread_1float(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jfloatArray buf, jboolean isCriticalPinning) { - jboolean readBufIsCopy; - jfloat *readBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean readBufIsCopy; + jfloat * readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -623,7 +628,8 @@ Java_hdf_hdf5lib_H5_H5Aread_1float H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_float: variable length type not supported"); if (isCriticalPinning) { - PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_float: read buffer not critically pinned"); + PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Aread_float: read buffer not critically pinned"); } else { PIN_FLOAT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_float: read buffer not pinned"); @@ -651,13 +657,13 @@ done: * Signature: (JJ[FZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1float - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jfloatArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Awrite_1float(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jfloatArray buf, jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - jfloat *writeBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean writeBufIsCopy; + jfloat * writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -678,7 +684,8 @@ Java_hdf_hdf5lib_H5_H5Awrite_1float H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_float: variable length type not supported"); if (isCriticalPinning) { - PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_float: write buffer not critically pinned"); + PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Awrite_float: write buffer not critically pinned"); } else { PIN_FLOAT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_float: write buffer not pinned"); @@ -706,13 +713,13 @@ done: * Signature: (JJ[DZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1double - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jdoubleArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Aread_1double(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jdoubleArray buf, jboolean isCriticalPinning) { - jboolean readBufIsCopy; - jdouble *readBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean readBufIsCopy; + jdouble *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -733,7 +740,8 @@ Java_hdf_hdf5lib_H5_H5Aread_1double H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_double: variable length type not supported"); if (isCriticalPinning) { - PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_double: read buffer not critically pinned"); + PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Aread_double: read buffer not critically pinned"); } else { PIN_DOUBLE_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_double: read buffer not pinned"); @@ -761,13 +769,13 @@ done: * Signature: (JJ[DZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1double - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jdoubleArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Awrite_1double(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jdoubleArray buf, jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - jdouble *writeBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean writeBufIsCopy; + jdouble *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -788,7 +796,8 @@ Java_hdf_hdf5lib_H5_H5Awrite_1double H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_double: variable length type not supported"); if (isCriticalPinning) { - PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_double: write buffer not critically pinned"); + PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Awrite_double: write buffer not critically pinned"); } else { PIN_DOUBLE_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_double: write buffer not pinned"); @@ -816,16 +825,16 @@ done: * Signature: (JJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1string - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray j_buf) +Java_hdf_hdf5lib_H5_H5Aread_1string(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jobjectArray j_buf) { - jstring jstr; - size_t str_len; - size_t pos; - jsize i, n; - char *c_buf = NULL; - char *cstr = NULL; - herr_t status = FAIL; + jstring jstr; + size_t str_len; + size_t pos; + jsize i, n; + char * c_buf = NULL; + char * cstr = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -840,22 +849,23 @@ Java_hdf_hdf5lib_H5_H5Aread_1string if (!(str_len = H5Tget_size((hid_t)mem_type_id))) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (cstr = (char *) HDmalloc(str_len + 1))) + if (NULL == (cstr = (char *)HDmalloc(str_len + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); - if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) + if (NULL == (c_buf = (char *)HDmalloc((size_t)n * str_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, c_buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); for (i = 0, pos = 0; i < n; i++) { - HDmemcpy(cstr, c_buf+pos, str_len); + HDmemcpy(cstr, c_buf + pos, str_len); cstr[str_len] = '\0'; if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, cstr))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_string: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Aread_string: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, j_buf, i, jstr); @@ -881,14 +891,14 @@ done: * Signature: (JJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1string - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray j_buf) +Java_hdf_hdf5lib_H5_H5Awrite_1string(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jobjectArray j_buf) { const char *utf8 = NULL; jstring obj; size_t i, str_len; jsize n; - char *c_buf = NULL; + char * c_buf = NULL; herr_t status = FAIL; UNUSED(clss); @@ -904,11 +914,11 @@ Java_hdf_hdf5lib_H5_H5Awrite_1string if (!(str_len = H5Tget_size((hid_t)mem_type_id))) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) + if (NULL == (c_buf = (char *)HDmalloc((size_t)n * str_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Awrite_string: memory allocation failed"); - for (i = 0; i < (size_t) n; i++) { - if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize) i))) { + for (i = 0; i < (size_t)n; i++) { + if (NULL == (obj = (jstring)ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize)i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* @@ -951,16 +961,15 @@ done: * Signature: (JJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AreadVL - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) { H5T_class_t type_class; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; htri_t isComplex2 = 0; hid_t nested_tid = H5I_INVALID_HID; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -980,7 +989,7 @@ Java_hdf_hdf5lib_H5_H5AreadVL if ((num_members = H5Tget_nmembers(mem_type_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0; i < (unsigned) num_members; i++) { + for (i = 0; i < (unsigned)num_members; i++) { if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1023,21 +1032,21 @@ done: * buffer in turn. */ static herr_t -H5AreadVL_str - (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +H5AreadVL_str(JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) { - jstring jstr; - jsize i, n; - char **strs = NULL; - herr_t status = FAIL; + jstring jstr; + jsize i, n; + char ** strs = NULL; + herr_t status = FAIL; if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AreadVL_str: buf length < 0"); } - if (NULL == (strs = (char **) HDcalloc((size_t)n, sizeof(char *)))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadVL_str: failed to allocate variable length string read buffer"); + if (NULL == (strs = (char **)HDcalloc((size_t)n, sizeof(char *)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5AreadVL_str: failed to allocate variable length string read buffer"); if ((status = H5Aread(aid, tid, strs)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1081,18 +1090,17 @@ done: * in the output buffer in turn. */ static herr_t -H5AreadVL_asstr - (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +H5AreadVL_asstr(JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) { - hsize_t dims[H5S_MAX_RANK]; - jstring jstr; - h5str_t h5str; - size_t typeSize; - size_t i; - hid_t sid = H5I_INVALID_HID; - jsize n; - void *readBuf = NULL; - herr_t status = FAIL; + hsize_t dims[H5S_MAX_RANK]; + jstring jstr; + h5str_t h5str; + size_t typeSize; + size_t i; + hid_t sid = H5I_INVALID_HID; + jsize n; + void * readBuf = NULL; + herr_t status = FAIL; HDmemset(&h5str, 0, sizeof(h5str_t)); @@ -1122,16 +1130,16 @@ H5AreadVL_asstr H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate buffer"); /* Convert each element to a char string */ - for (i = 0; i < (size_t) n; i++) { + for (i = 0; i < (size_t)n; i++) { h5str.s[0] = '\0'; - if (!h5str_sprintf(ENVONLY, &h5str, aid, tid, &(((char *) readBuf)[i * typeSize]), typeSize, 0)) + if (!h5str_sprintf(ENVONLY, &h5str, aid, tid, &(((char *)readBuf)[i * typeSize]), typeSize, 0)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize) i, jstr); + ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize)i, jstr); CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); ENVPTR->DeleteLocalRef(ENVONLY, jstr); @@ -1156,16 +1164,15 @@ done: * Signature: (JJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AwriteVL - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5AwriteVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) { H5T_class_t type_class; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; htri_t isComplex2 = 0; hid_t nested_tid = H5I_INVALID_HID; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -1185,7 +1192,7 @@ Java_hdf_hdf5lib_H5_H5AwriteVL if ((num_members = H5Tget_nmembers(mem_type_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - for(i = 0; i < (unsigned) num_members; i++) { + for (i = 0; i < (unsigned)num_members; i++) { if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1227,28 +1234,28 @@ done: * The buffer of C-strings is then written to the HDF5 attribute specified. */ static herr_t -H5AwriteVL_str - (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +H5AwriteVL_str(JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) { - const char *utf8 = NULL; - jstring obj; - jsize size; - jint i; - char **writeBuf = NULL; - herr_t status = FAIL; - - if ((size = ENVPTR->GetArrayLength(ENVONLY, (jarray) buf)) < 0) { + const char *utf8 = NULL; + jstring obj; + jsize size; + jint i; + char ** writeBuf = NULL; + herr_t status = FAIL; + + if ((size = ENVPTR->GetArrayLength(ENVONLY, (jarray)buf)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AwriteVL_str: buf length < 0"); } - if (NULL == (writeBuf = (char **) HDcalloc((size_t)size + 1, sizeof(char *)))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate variable length string write buffer"); + if (NULL == (writeBuf = (char **)HDcalloc((size_t)size + 1, sizeof(char *)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5AwriteVL_str: failed to allocate variable length string write buffer"); for (i = 0; i < size; ++i) { jsize length; - if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray) buf, i))) { + if (NULL == (obj = (jstring)ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* @@ -1263,7 +1270,7 @@ H5AwriteVL_str PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5AwriteVL_str: string not pinned"); - if (NULL == (writeBuf[i] = (char *) HDmalloc((size_t)length + 1))) + if (NULL == (writeBuf[i] = (char *)HDmalloc((size_t)length + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate string buffer"); HDstrncpy(writeBuf[i], utf8, (size_t)length); @@ -1299,8 +1306,7 @@ done: * elements is then written to the HDF5 attribute. */ static herr_t -H5AwriteVL_asstr - (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +H5AwriteVL_asstr(JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) { const char *utf8 = NULL; hsize_t dims[H5S_MAX_RANK]; @@ -1309,8 +1315,8 @@ H5AwriteVL_asstr size_t i; hid_t sid = H5I_INVALID_HID; jsize n; - void *writeBuf = NULL; - herr_t status = FAIL; + void * writeBuf = NULL; + herr_t status = FAIL; if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); @@ -1333,14 +1339,14 @@ H5AwriteVL_asstr * free space in time. Instead, we use "H5free_memory(strs[i])" to free individual strings * once done. */ - for (i = 0; i < (size_t) n; i++) { - if (NULL == (jstr = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray) buf, (jsize) i))) { + for (i = 0; i < (size_t)n; i++) { + if (NULL == (jstr = (jstring)ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, (jsize)i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* * If the string object was NULL, skip it. */ - HDmemset(&(((char *) writeBuf)[i * typeSize]), 0, typeSize); + HDmemset(&(((char *)writeBuf)[i * typeSize]), 0, typeSize); continue; } @@ -1356,7 +1362,7 @@ H5AwriteVL_asstr * one before destroying it with h5str_convert. */ - if (!h5str_convert(ENVONLY, (char **) &utf8, aid, tid, &(((char *) writeBuf)[i * typeSize]), 0)) + if (!h5str_convert(ENVONLY, (char **)&utf8, aid, tid, &(((char *)writeBuf)[i * typeSize]), 0)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); UNPIN_JAVA_STRING(ENVONLY, jstr, utf8); @@ -1387,14 +1393,14 @@ done: * Signature: (JJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jobjectArray buf) { - H5R_ref_t *ref_data = NULL; - h5str_t h5str; - jstring jstr; - jsize i, n; - herr_t status = FAIL; + H5R_ref_t *ref_data = NULL; + h5str_t h5str; + jstring jstr; + jsize i, n; + herr_t status = FAIL; UNUSED(clss); @@ -1405,7 +1411,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_reg_ref: buf length < 0"); } - if (NULL == (ref_data = (H5R_ref_t *) HDcalloc(1, (size_t)n * sizeof(H5R_ref_t)))) + if (NULL == (ref_data = (H5R_ref_t *)HDcalloc(1, (size_t)n * sizeof(H5R_ref_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate read buffer"); if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, ref_data)) < 0) @@ -1419,7 +1425,7 @@ Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref for (i = 0; i < n; i++) { h5str.s[0] = '\0'; - if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)attr_id, (hid_t)mem_type_id, (void*)&ref_data[i], 0, 0)) + if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)attr_id, (hid_t)mem_type_id, (void *)&ref_data[i], 0, 0)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) @@ -1446,8 +1452,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aget_1space - (JNIEnv *env, jclass clss, jlong attr_id) +Java_hdf_hdf5lib_H5__1H5Aget_1space(JNIEnv *env, jclass clss, jlong attr_id) { hid_t retVal = H5I_INVALID_HID; @@ -1466,8 +1471,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aget_1type - (JNIEnv *env, jclass clss, jlong attr_id) +Java_hdf_hdf5lib_H5__1H5Aget_1type(JNIEnv *env, jclass clss, jlong attr_id) { hid_t retVal = H5I_INVALID_HID; @@ -1486,19 +1490,18 @@ done: * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1name - (JNIEnv *env, jclass clss, jlong attr_id) +Java_hdf_hdf5lib_H5_H5Aget_1name(JNIEnv *env, jclass clss, jlong attr_id) { - jstring str = NULL; - ssize_t buf_size; - char *attrName = NULL; + jstring str = NULL; + ssize_t buf_size; + char * attrName = NULL; UNUSED(clss); if ((buf_size = H5Aget_name((hid_t)attr_id, 0, NULL)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (attrName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (attrName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aget_name: failed to allocate attribute name buffer"); if (H5Aget_name((hid_t)attr_id, (size_t)buf_size + 1, attrName) < 0) @@ -1521,8 +1524,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs(JNIEnv *env, jclass clss, jlong loc_id) { int retVal = FAIL; @@ -1546,11 +1548,10 @@ done: * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Adelete - (JNIEnv *env, jclass clss, jlong loc_id, jstring name) +Java_hdf_hdf5lib_H5_H5Adelete(JNIEnv *env, jclass clss, jlong loc_id, jstring name) { const char *attrName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -1575,8 +1576,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Aclose - (JNIEnv *env, jclass clss, jlong attr_id) +Java_hdf_hdf5lib_H5__1H5Aclose(JNIEnv *env, jclass clss, jlong attr_id) { herr_t retVal = FAIL; @@ -1595,12 +1595,11 @@ done: * Signature: (JLjava/lang/String;JJJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Acreate2 - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, - jlong space_id, jlong create_plist, jlong access_plist) +Java_hdf_hdf5lib_H5__1H5Acreate2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, + jlong space_id, jlong create_plist, jlong access_plist) { const char *attrName = NULL; - hid_t status = H5I_INVALID_HID; + hid_t status = H5I_INVALID_HID; UNUSED(clss); @@ -1609,8 +1608,8 @@ Java_hdf_hdf5lib_H5__1H5Acreate2 PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Acreate2: attribute name not pinned"); - if ((status = H5Acreate2((hid_t)loc_id, attrName, (hid_t)type_id, - (hid_t)space_id, (hid_t)create_plist, (hid_t)access_plist)) < 0) + if ((status = H5Acreate2((hid_t)loc_id, attrName, (hid_t)type_id, (hid_t)space_id, (hid_t)create_plist, + (hid_t)access_plist)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1626,12 +1625,11 @@ done: * Signature: (JLjava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen - (JNIEnv *env, jclass clss, jlong obj_id, jstring name, jlong access_plist) +Java_hdf_hdf5lib_H5__1H5Aopen(JNIEnv *env, jclass clss, jlong obj_id, jstring name, jlong access_plist) { const char *attrName = NULL; - hid_t retVal = H5I_INVALID_HID; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -1656,11 +1654,11 @@ done: * Signature: (JLjava/lang/String;IIJJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint idx_type, jint order, jlong n, jlong aapl_id, jlong lapl_id) +Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint idx_type, + jint order, jlong n, jlong aapl_id, jlong lapl_id) { const char *objName = NULL; - hid_t retVal = H5I_INVALID_HID; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -1669,8 +1667,8 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Aopen_by_idx: object name not pinned"); - if ((retVal = H5Aopen_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, - (H5_iter_order_t)order, (hsize_t)n, (hid_t)aapl_id, (hid_t)lapl_id)) < 0) + if ((retVal = H5Aopen_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, + (hsize_t)n, (hid_t)aapl_id, (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1681,17 +1679,18 @@ done: } /* end Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx */ /* -* Class: hdf_hdf5lib_H5 -* Method: _H5Acreate_by_name -* Signature: (JLjava/lang/String;Ljava/lang/String;JJJJJ)J -*/ + * Class: hdf_hdf5lib_H5 + * Method: _H5Acreate_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;JJJJJ)J + */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong type_id, jlong space_id, jlong acpl_id, jlong aapl_id, jlong lapl_id) +Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jstring attr_name, jlong type_id, jlong space_id, jlong acpl_id, + jlong aapl_id, jlong lapl_id) { - const char *objName = NULL; + const char *objName = NULL; const char *attrName = NULL; - hid_t retVal = H5I_INVALID_HID; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -1703,8 +1702,8 @@ Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Acreate_by_name: object name not pinned"); PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Acreate_by_name: attribute name not pinned"); - if ((retVal = H5Acreate_by_name((hid_t)loc_id, objName, attrName, (hid_t)type_id, - (hid_t)space_id, (hid_t)acpl_id, (hid_t)aapl_id, (hid_t)lapl_id)) < 0) + if ((retVal = H5Acreate_by_name((hid_t)loc_id, objName, attrName, (hid_t)type_id, (hid_t)space_id, + (hid_t)acpl_id, (hid_t)aapl_id, (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1722,12 +1721,12 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String;J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Aexists_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Aexists_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jstring attr_name, jlong lapl_id) { - const char *objName = NULL; + const char *objName = NULL; const char *attrName = NULL; - htri_t bval = JNI_FALSE; + htri_t bval = JNI_FALSE; UNUSED(clss); @@ -1759,12 +1758,12 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Arename - (JNIEnv *env, jclass clss, jlong loc_id, jstring old_attr_name, jstring new_attr_name) +Java_hdf_hdf5lib_H5_H5Arename(JNIEnv *env, jclass clss, jlong loc_id, jstring old_attr_name, + jstring new_attr_name) { const char *oldAttrName = NULL; const char *newAttrName = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -1794,13 +1793,13 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Arename_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring old_attr_name, jstring new_attr_name, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Arename_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jstring old_attr_name, jstring new_attr_name, jlong lapl_id) { - const char *objName = NULL; + const char *objName = NULL; const char *oldAttrName = NULL; const char *newAttrName = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -1812,8 +1811,10 @@ Java_hdf_hdf5lib_H5_H5Arename_1by_1name H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Arename_by_name: new attribute name is NULL"); PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Arename_by_name: object name not pinned"); - PIN_JAVA_STRING(ENVONLY, old_attr_name, oldAttrName, NULL, "H5Arename_by_name: old attribute name not pinned"); - PIN_JAVA_STRING(ENVONLY, new_attr_name, newAttrName, NULL, "H5Arename_by_name: new attribute name not pinned"); + PIN_JAVA_STRING(ENVONLY, old_attr_name, oldAttrName, NULL, + "H5Arename_by_name: old attribute name not pinned"); + PIN_JAVA_STRING(ENVONLY, new_attr_name, newAttrName, NULL, + "H5Arename_by_name: new attribute name not pinned"); if ((retVal = H5Arename_by_name((hid_t)loc_id, objName, oldAttrName, newAttrName, (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1835,13 +1836,13 @@ done: * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jint idx_type, jint order, jlong n, jlong lapl_id) { - const char *objName = NULL; - jstring str = NULL; + const char *objName = NULL; + jstring str = NULL; ssize_t status_size = -1; - char *attrName = NULL; + char * attrName = NULL; UNUSED(clss); @@ -1851,15 +1852,16 @@ Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aget_name_by_idx: object name not pinned"); /* Get the length of the attribute name */ - if ((status_size = H5Aget_name_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, - (H5_iter_order_t) order, (hsize_t) n, (char *)NULL, (size_t)0, (hid_t)lapl_id)) < 0) + if ((status_size = + H5Aget_name_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, + (hsize_t)n, (char *)NULL, (size_t)0, (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (attrName = (char *) HDmalloc(sizeof(char) * (size_t) status_size + 1))) + if (NULL == (attrName = (char *)HDmalloc(sizeof(char) * (size_t)status_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aget_name_by_idx: failed to allocate buffer for attribute name"); - if ((H5Aget_name_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, - (H5_iter_order_t) order, (hsize_t) n, (char *)attrName, (size_t)status_size + 1, (hid_t)lapl_id)) < 0) + if ((H5Aget_name_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t)n, + (char *)attrName, (size_t)status_size + 1, (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); attrName[status_size] = '\0'; @@ -1881,8 +1883,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1storage_1size - (JNIEnv *env, jclass clss, jlong attr_id) +Java_hdf_hdf5lib_H5_H5Aget_1storage_1size(JNIEnv *env, jclass clss, jlong attr_id) { hsize_t retVal = 0; @@ -1901,8 +1902,7 @@ done: * Signature: (J)Lhdf/hdf5lib/structs/H5A_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1info - (JNIEnv *env, jclass clss, jlong attr_id) +Java_hdf_hdf5lib_H5_H5Aget_1info(JNIEnv *env, jclass clss, jlong attr_id) { H5A_info_t ainfo; jobject ret_obj = NULL; @@ -1930,8 +1930,8 @@ done: * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5A_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jint idx_type, jint order, jlong n, jlong lapl_id) { const char *objName = NULL; H5A_info_t ainfo; @@ -1946,8 +1946,8 @@ Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aget_info_by_idx: object name not pinned"); - if ((status = H5Aget_info_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, - (H5_iter_order_t)order, (hsize_t)n, &ainfo, (hid_t)lapl_id)) < 0) + if ((status = H5Aget_info_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, + (hsize_t)n, &ainfo, (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); args[0].z = ainfo.corder_valid; @@ -1970,10 +1970,10 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String;J)Lhdf/hdf5lib/structs/H5A_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jstring attr_name, jlong lapl_id) { - const char *objName = NULL; + const char *objName = NULL; const char *attrName = NULL; H5A_info_t ainfo; herr_t status; @@ -2015,12 +2015,12 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String;J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Adelete_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Adelete_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jstring attr_name, jlong lapl_id) { - const char *objName = NULL; + const char *objName = NULL; const char *attrName = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -2050,11 +2050,10 @@ done: * Signature: (JLjava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Aexists - (JNIEnv *env, jclass clss, jlong obj_id, jstring attr_name) +Java_hdf_hdf5lib_H5_H5Aexists(JNIEnv *env, jclass clss, jlong obj_id, jstring attr_name) { const char *attrName = NULL; - htri_t bval = JNI_FALSE; + htri_t bval = JNI_FALSE; UNUSED(clss); @@ -2081,11 +2080,11 @@ done: * Signature: (JLjava/lang/String;IIJJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jint idx_type, jint order, jlong n, jlong lapl_id) { const char *objName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -2094,7 +2093,8 @@ Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Adelete_by_idx: object name not pinned"); - if ((status = H5Adelete_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t)n, (hid_t)lapl_id)) < 0) + if ((status = H5Adelete_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, + (hsize_t)n, (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -2108,13 +2108,13 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String;JJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong aapl_id, jlong lapl_id) +Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, + jstring attr_name, jlong aapl_id, jlong lapl_id) { const char *attrName = NULL; - const char *objName = NULL; - hid_t status = H5I_INVALID_HID; + const char *objName = NULL; + hid_t status = H5I_INVALID_HID; UNUSED(clss); @@ -2144,8 +2144,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist - (JNIEnv *env, jclass clss, jlong attr_id) +Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist(JNIEnv *env, jclass clss, jlong attr_id) { hid_t retVal = H5I_INVALID_HID; @@ -2159,18 +2158,18 @@ done: } /* end Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist */ static herr_t -H5A_iterate_cb - (hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data) { +H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data) +{ cb_wrapper *wrapper = (cb_wrapper *)cb_data; jmethodID mid; - jobject cb_info_t = NULL; + jobject cb_info_t = NULL; jobject visit_callback = wrapper->visit_callback; jstring str; - JNIEnv *cbenv = NULL; + JNIEnv * cbenv = NULL; jclass cbcls; jvalue args[4]; - void *op_data = (void *)wrapper->op_data; - jint status = -1; + void * op_data = (void *)wrapper->op_data; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -2180,7 +2179,10 @@ H5A_iterate_cb if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I"))) + if (NULL == + (mid = CBENVPTR->GetMethodID( + CBENVONLY, cbcls, "callback", + "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) @@ -2209,13 +2211,12 @@ done: * Signature: (JIIJLjava/lang/Object;Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aiterate - (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, - jlong idx, jobject callback_op, jobject op_data) +Java_hdf_hdf5lib_H5_H5Aiterate(JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, jlong idx, + jobject callback_op, jobject op_data) { - cb_wrapper wrapper = { callback_op, op_data }; + cb_wrapper wrapper = {callback_op, op_data}; hsize_t start_idx = (hsize_t)idx; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -2227,7 +2228,8 @@ Java_hdf_hdf5lib_H5_H5Aiterate if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aiterate: callback_op is NULL"); - if ((status = H5Aiterate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)&wrapper)) < 0) + if ((status = H5Aiterate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, + (hsize_t *)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void *)&wrapper)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -2240,14 +2242,14 @@ done: * Signature: (JLjava/lang/String;IIJLjava/lang/Object;Ljava/lang/Object;J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name - (JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, - jlong idx, jobject callback_op, jobject op_data, jlong access_id) +Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name(JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, + jint order, jlong idx, jobject callback_op, jobject op_data, + jlong access_id) { - const char *objName = NULL; - cb_wrapper wrapper = { callback_op, op_data }; + const char *objName = NULL; + cb_wrapper wrapper = {callback_op, op_data}; hsize_t start_idx = (hsize_t)idx; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -2263,7 +2265,9 @@ Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Aiterate_by_name: object name not pinned"); - if ((status = H5Aiterate_by_name((hid_t)grp_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)&wrapper, (hid_t)access_id)) < 0) + if ((status = H5Aiterate_by_name((hid_t)grp_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, + (hsize_t *)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void *)&wrapper, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: diff --git a/java/src/jni/h5aImp.h b/java/src/jni/h5aImp.h index 15cc83e..d3a4246 100644 --- a/java/src/jni/h5aImp.h +++ b/java/src/jni/h5aImp.h @@ -21,430 +21,356 @@ extern "C" { #endif /* __cplusplus */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Acreate * Signature: (JLjava/lang/String;JJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Acreate - (JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Acreate(JNIEnv *, jclass, jlong, jstring, jlong, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aopen_name * Signature: (JLjava/lang/String;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen_1name - (JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1name(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Aopen_idx * Signature: (JI)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen_1idx - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1idx(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread * Signature: (JJ[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread - (JNIEnv *, jclass, jlong, jlong, jbyteArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread(JNIEnv *, jclass, jlong, jlong, jbyteArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite * Signature: (JJ[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite - (JNIEnv *, jclass, jlong, jlong, jbyteArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite(JNIEnv *, jclass, jlong, jlong, jbyteArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread_short * Signature: (JJ[SZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1short - (JNIEnv*, jclass, jlong, jlong, jshortArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1short(JNIEnv *, jclass, jlong, jlong, jshortArray, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite_short * Signature: (JJ[SZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1short - (JNIEnv*, jclass, jlong, jlong, jshortArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1short(JNIEnv *, jclass, jlong, jlong, jshortArray, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread_int * Signature: (JJ[IZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1int - (JNIEnv*, jclass, jlong, jlong, jintArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1int(JNIEnv *, jclass, jlong, jlong, jintArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite_int * Signature: (JJ[IZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1int - (JNIEnv*, jclass, jlong, jlong, jintArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1int(JNIEnv *, jclass, jlong, jlong, jintArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread_long * Signature: (JJ[JZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1long - (JNIEnv*, jclass, jlong, jlong, jlongArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1long(JNIEnv *, jclass, jlong, jlong, jlongArray, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite_long * Signature: (JJ[JZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1long - (JNIEnv*, jclass, jlong, jlong, jlongArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1long(JNIEnv *, jclass, jlong, jlong, jlongArray, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread_float * Signature: (JJ[FZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1float - (JNIEnv*, jclass, jlong, jlong, jfloatArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1float(JNIEnv *, jclass, jlong, jlong, jfloatArray, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite_float * Signature: (JJ[FZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1float - (JNIEnv*, jclass, jlong, jlong, jfloatArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1float(JNIEnv *, jclass, jlong, jlong, jfloatArray, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread_double * Signature: (JJ[DZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1double - (JNIEnv*, jclass, jlong, jlong, jdoubleArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1double(JNIEnv *, jclass, jlong, jlong, jdoubleArray, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite_double * Signature: (JJ[DZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1double - (JNIEnv*, jclass, jlong, jlong, jdoubleArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1double(JNIEnv *, jclass, jlong, jlong, jdoubleArray, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5AreadVL * Signature: (JJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AreadVL - (JNIEnv *, jclass, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5AwriteVL * Signature: (JJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AwriteVL - (JNIEnv *, jclass, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AwriteVL(JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread_string * Signature: (JJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1string - (JNIEnv*, jclass, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1string(JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite_string * Signature: (JJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1string -(JNIEnv*, jclass, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1string(JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread_VLStrings * Signature: (JJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1VLStrings -(JNIEnv*, jclass, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1VLStrings(JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite_VLStrings * Signature: (JJ[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Awrite_1VLStrings - (JNIEnv*, jclass, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1VLStrings(JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Aread_reg_ref * Signature: (JJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref -(JNIEnv*, jclass, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref(JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_space * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aget_1space - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1space(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_type * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aget_1type - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1type(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_name * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1name - (JNIEnv *, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Aget_1name(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_num_attrs * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Adelete * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Adelete - (JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Adelete(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Aclose * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Aclose - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Aclose(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Acreate2 * Signature: (JLjava/lang/String;JJJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Acreate2 -(JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Acreate2(JNIEnv *, jclass, jlong, jstring, jlong, jlong, + jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Aopen * Signature: (JLjava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen - (JNIEnv *, jclass, jlong, jstring, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Aopen_by_idx * Signature: (JLjava/lang/String;IIJJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx - (JNIEnv *, jclass, jlong, jstring, jint, jint, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, jint, + jlong, jlong, jlong); /* -* Class: hdf_hdf5lib_H5 -* Method: _H5Acreate_by_name -* Signature: (JLjava/lang/String;Ljava/lang/String;JJJJJ)J -*/ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name -(JNIEnv *, jclass, jlong, jstring, jstring, jlong, jlong, jlong, jlong, jlong); + * Class: hdf_hdf5lib_H5 + * Method: _H5Acreate_by_name + * Signature: (JLjava/lang/String;Ljava/lang/String;JJJJJ)J + */ +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name(JNIEnv *, jclass, jlong, jstring, jstring, + jlong, jlong, jlong, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aexists_by_name * Signature: (JLjava/lang/String;Ljava/lang/String;J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Aexists_1by_1name - (JNIEnv *, jclass, jlong, jstring, jstring, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Aexists_1by_1name(JNIEnv *, jclass, jlong, jstring, jstring, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Arename * Signature: (JLjava/lang/String;Ljava/lang/String)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Arename - (JNIEnv *, jclass, jlong, jstring, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Arename(JNIEnv *, jclass, jlong, jstring, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Arename_by_name * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Arename_1by_1name - (JNIEnv *, jclass, jlong, jstring, jstring, jstring, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Arename_1by_1name(JNIEnv *, jclass, jlong, jstring, jstring, + jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_name_by_idx * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx - (JNIEnv *, jclass, jlong, jstring, jint, jint, jlong, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, + jint, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_storage_size * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1storage_1size - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Aget_1storage_1size(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_info * Signature: (J)Lhdf/hdf5lib/structs/H5A_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1info - (JNIEnv *, jclass, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_info_by_idx * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5A_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx - (JNIEnv *, jclass, jlong, jstring, jint, jint, jlong, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, + jint, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_info_by_name * Signature: (JLjava/lang/String;Ljava/lang/String;J)Lhdf/hdf5lib/structs/H5A_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name - (JNIEnv *, jclass, jlong, jstring, jstring, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name(JNIEnv *, jclass, jlong, jstring, + jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Adelete_by_name * Signature: (JLjava/lang/String;Ljava/lang/String;J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Adelete_1by_1name - (JNIEnv *, jclass, jlong, jstring, jstring, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Adelete_1by_1name(JNIEnv *, jclass, jlong, jstring, jstring, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aexists * Signature: (JLjava/lang/String;)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Aexists - (JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Aexists(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Adelete_by_idx * Signature: (JLjava/lang/String;IIJJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx - (JNIEnv *, jclass, jlong, jstring, jint, jint, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, jint, + jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Aopen_by_name * Signature: (JLjava/lang/String;Ljava/lang/String;JJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name - (JNIEnv *, jclass, jlong, jstring, jstring, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name(JNIEnv *, jclass, jlong, jstring, jstring, + jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_create_plist * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Aiterate * Signature: (JIIJLjava/lang/Object;Ljava/lang/Object;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aiterate - (JNIEnv*, jclass, jlong, jint, jint, jlong, jobject, jobject); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aiterate(JNIEnv *, jclass, jlong, jint, jint, jlong, jobject, + jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Aiterate_by_name * Signature: (JLjava/lang/String;IIJLjava/lang/Object;Ljava/lang/Object;J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name - (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jobject, jobject, jlong); - +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name(JNIEnv *, jclass, jlong, jstring, jint, jint, + jlong, jobject, jobject, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index bcefe12..b34fe25 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -44,28 +44,30 @@ typedef struct _cb_wrapper { /* Local Prototypes */ /********************/ -static herr_t H5DreadVL_asstr(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); -static herr_t H5DreadVL_str(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); -static herr_t H5DwriteVL_asstr(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); -static herr_t H5DwriteVL_str(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DreadVL_asstr(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, + hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DreadVL_str(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, + hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DwriteVL_asstr(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, + hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DwriteVL_str(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, + hid_t xfer_plist_id, jobjectArray buf); /********************/ /* Local Macros */ /********************/ - /* * Class: hdf_hdf5lib_H5 * Method: _H5Dcreate * Signature: (JLjava/lang/String;JJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dcreate - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, - jlong space_id, jlong create_plist_id) +Java_hdf_hdf5lib_H5__1H5Dcreate(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, + jlong space_id, jlong create_plist_id) { const char *dsetName = NULL; - hid_t dset_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; UNUSED(clss); @@ -74,7 +76,8 @@ Java_hdf_hdf5lib_H5__1H5Dcreate PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dcreate: dataset name not pinned"); - if ((dset_id = H5Dcreate2((hid_t)loc_id, dsetName, (hid_t)type_id, (hid_t)space_id, H5P_DEFAULT, (hid_t)create_plist_id, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2((hid_t)loc_id, dsetName, (hid_t)type_id, (hid_t)space_id, H5P_DEFAULT, + (hid_t)create_plist_id, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -90,11 +93,10 @@ done: * Signature: (JLjava/lang/String;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dopen - (JNIEnv *env, jclass clss, jlong loc_id, jstring name) +Java_hdf_hdf5lib_H5__1H5Dopen(JNIEnv *env, jclass clss, jlong loc_id, jstring name) { const char *dsetName = NULL; - hid_t dset_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; UNUSED(clss); @@ -119,8 +121,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dget_1space - (JNIEnv *env, jclass clss, jlong dataset_id) +Java_hdf_hdf5lib_H5__1H5Dget_1space(JNIEnv *env, jclass clss, jlong dataset_id) { hid_t retVal = H5I_INVALID_HID; @@ -139,8 +140,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dget_1type - (JNIEnv *env, jclass clss, jlong dataset_id) +Java_hdf_hdf5lib_H5__1H5Dget_1type(JNIEnv *env, jclass clss, jlong dataset_id) { hid_t retVal = H5I_INVALID_HID; @@ -159,8 +159,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist - (JNIEnv *env, jclass clss, jlong dataset_id) +Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist(JNIEnv *env, jclass clss, jlong dataset_id) { hid_t retVal = H5I_INVALID_HID; @@ -179,14 +178,14 @@ done: * Signature: (JJJJJ[BZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dread(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, + jboolean isCriticalPinning) { - jboolean readBufIsCopy; - htri_t data_class; - jbyte *readBuf = NULL; - herr_t status = FAIL; + jboolean readBufIsCopy; + htri_t data_class; + jbyte * readBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -207,14 +206,15 @@ Java_hdf_hdf5lib_H5_H5Dread H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread: variable length type not supported"); if (isCriticalPinning) { - PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread: read buffer not critically pinned"); + PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Dread: read buffer not critically pinned"); } else { PIN_BYTE_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread: read buffer not pinned"); } - if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -236,14 +236,14 @@ done: * Signature: (JJJJJ[BZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dwrite(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, + jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - htri_t data_class; - jbyte *writeBuf = NULL; - herr_t status = FAIL; + jboolean writeBufIsCopy; + htri_t data_class; + jbyte * writeBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -264,14 +264,15 @@ Java_hdf_hdf5lib_H5_H5Dwrite H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite: variable length type not supported"); if (isCriticalPinning) { - PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite: write buffer not critically pinned"); + PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Dwrite: write buffer not critically pinned"); } else { PIN_BYTE_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite: write buffer not pinned"); } - if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, writeBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -293,8 +294,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Dclose - (JNIEnv *env, jclass clss, jlong dataset_id) +Java_hdf_hdf5lib_H5__1H5Dclose(JNIEnv *env, jclass clss, jlong dataset_id) { herr_t retVal = FAIL; @@ -313,8 +313,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Dget_1storage_1size - (JNIEnv *env, jclass clss, jlong dataset_id) +Java_hdf_hdf5lib_H5_H5Dget_1storage_1size(JNIEnv *env, jclass clss, jlong dataset_id) { hsize_t retVal = 0; @@ -336,15 +335,14 @@ done: * Signature: (JJJ[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim - (JNIEnv *env, jclass clss, jlong type_id, jlong space_id, - jlong xfer_plist_id, jbyteArray buf) +Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim(JNIEnv *env, jclass clss, jlong type_id, jlong space_id, + jlong xfer_plist_id, jbyteArray buf) { #ifndef H5_NO_DEPRECATED_SYMBOLS - jboolean vlenBufIsCopy; - jbyte *vlenBuf = NULL; + jboolean vlenBufIsCopy; + jbyte * vlenBuf = NULL; #endif - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -379,14 +377,14 @@ done: * Signature: (JJJJJ[SZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1short - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jshortArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dread_1short(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jshortArray buf, jboolean isCriticalPinning) { - jboolean readBufIsCopy; - jshort *readBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean readBufIsCopy; + jshort * readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -407,14 +405,15 @@ Java_hdf_hdf5lib_H5_H5Dread_1short H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_short: variable length type not supported"); if (isCriticalPinning) { - PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_short: read buffer not critically pinned"); + PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Dread_short: read buffer not critically pinned"); } else { PIN_SHORT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_short: read buffer not pinned"); } - if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -436,14 +435,14 @@ done: * Signature: (JJJJJ[SZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1short - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jshortArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dwrite_1short(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jshortArray buf, jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - jshort *writeBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean writeBufIsCopy; + jshort * writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -464,14 +463,15 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1short H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_short: variable length type not supported"); if (isCriticalPinning) { - PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_short: write buffer not critically pinned"); + PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Dwrite_short: write buffer not critically pinned"); } else { PIN_SHORT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_short: write buffer not pinned"); } - if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, writeBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -493,14 +493,14 @@ done: * Signature: (JJJJJ[IZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1int - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jintArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dread_1int(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jintArray buf, + jboolean isCriticalPinning) { - jboolean readBufIsCopy; - htri_t data_class; - jint *readBuf = NULL; - herr_t status = FAIL; + jboolean readBufIsCopy; + htri_t data_class; + jint * readBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -521,14 +521,15 @@ Java_hdf_hdf5lib_H5_H5Dread_1int H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_int: variable length type not supported"); if (isCriticalPinning) { - PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_int: read buffer not critically pinned"); + PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Dread_int: read buffer not critically pinned"); } else { PIN_INT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_int: read buffer not pinned"); } - if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -550,14 +551,14 @@ done: * Signature: (JJJJJ[IZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1int - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jintArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dwrite_1int(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jintArray buf, + jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - htri_t data_class; - jint *writeBuf = NULL; - herr_t status = FAIL; + jboolean writeBufIsCopy; + htri_t data_class; + jint * writeBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -578,14 +579,15 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1int H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_int: variable length type not supported"); if (isCriticalPinning) { - PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_int: write buffer not critically pinned"); + PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Dwrite_int: write buffer not critically pinned"); } else { PIN_INT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_int: write buffer not pinned"); } - if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, writeBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -607,14 +609,14 @@ done: * Signature: (JJJJJ[JZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1long - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jlongArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dread_1long(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jlongArray buf, jboolean isCriticalPinning) { - jboolean readBufIsCopy; - htri_t data_class; - jlong *readBuf = NULL; - herr_t status = FAIL; + jboolean readBufIsCopy; + htri_t data_class; + jlong * readBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -635,14 +637,15 @@ Java_hdf_hdf5lib_H5_H5Dread_1long H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_long: variable length type not supported"); if (isCriticalPinning) { - PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_long: read buffer not critically pinned"); + PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Dread_long: read buffer not critically pinned"); } else { PIN_LONG_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_long: read buffer not pinned"); } - if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -664,14 +667,14 @@ done: * Signature: (JJJJJ[JZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1long - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jlongArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dwrite_1long(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jlongArray buf, jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - htri_t data_class; - jlong *writeBuf = NULL; - herr_t status = FAIL; + jboolean writeBufIsCopy; + htri_t data_class; + jlong * writeBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -692,14 +695,15 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1long H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_long: variable length type not supported"); if (isCriticalPinning) { - PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_long: write buffer not critically pinned"); + PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Dwrite_long: write buffer not critically pinned"); } else { PIN_LONG_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_long: write buffer not pinned"); } - if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, writeBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -721,14 +725,14 @@ done: * Signature: (JJJJJ[FZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1float - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jfloatArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dread_1float(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jfloatArray buf, jboolean isCriticalPinning) { - jboolean readBufIsCopy; - htri_t data_class; - jfloat *readBuf = NULL; - herr_t status = FAIL; + jboolean readBufIsCopy; + htri_t data_class; + jfloat * readBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -749,14 +753,15 @@ Java_hdf_hdf5lib_H5_H5Dread_1float H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_float: variable length type not supported"); if (isCriticalPinning) { - PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_float: read buffer not critically pinned"); + PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Dread_float: read buffer not critically pinned"); } else { PIN_FLOAT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_float: read buffer not pinned"); } - if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -778,14 +783,14 @@ done: * Signature: (JJJJJ[FZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1float - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jfloatArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dwrite_1float(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jfloatArray buf, jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - htri_t data_class; - jfloat *writeBuf = NULL; - herr_t status = FAIL; + jboolean writeBufIsCopy; + htri_t data_class; + jfloat * writeBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -806,14 +811,15 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1float H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_float: variable length type not supported"); if (isCriticalPinning) { - PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_float: write buffer not critically pinned"); + PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Dwrite_float: write buffer not critically pinned"); } else { PIN_FLOAT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_float: write buffer not pinned"); } - if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, writeBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -835,14 +841,14 @@ done: * Signature: (JJJJJ[DZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1double - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jdoubleArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dread_1double(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jdoubleArray buf, jboolean isCriticalPinning) { - jboolean readBufIsCopy; - jdouble *readBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean readBufIsCopy; + jdouble *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -863,14 +869,15 @@ Java_hdf_hdf5lib_H5_H5Dread_1double H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_double: variable length type not supported"); if (isCriticalPinning) { - PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_double: read buffer not critically pinned"); + PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, + "H5Dread_double: read buffer not critically pinned"); } else { PIN_DOUBLE_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_double: read buffer not pinned"); } - if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -892,14 +899,14 @@ done: * Signature: (JJJJJ[DZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1double - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jdoubleArray buf, jboolean isCriticalPinning) +Java_hdf_hdf5lib_H5_H5Dwrite_1double(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jdoubleArray buf, jboolean isCriticalPinning) { - jboolean writeBufIsCopy; - jdouble *writeBuf = NULL; - htri_t data_class; - herr_t status = FAIL; + jboolean writeBufIsCopy; + jdouble *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; UNUSED(clss); @@ -920,14 +927,15 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1double H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_double: variable length type not supported"); if (isCriticalPinning) { - PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_double: write buffer not critically pinned"); + PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, + "H5Dwrite_double: write buffer not critically pinned"); } else { PIN_DOUBLE_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_double: write buffer not pinned"); } - if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, writeBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -949,17 +957,17 @@ done: * Signature: (JJJJJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1string - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray j_buf) +Java_hdf_hdf5lib_H5_H5Dread_1string(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jobjectArray j_buf) { - jstring jstr; - size_t str_len; - size_t pos; - jsize i, n; - char *c_buf = NULL; - char *cstr = NULL; - herr_t status = FAIL; + jstring jstr; + size_t str_len; + size_t pos; + jsize i, n; + char * c_buf = NULL; + char * cstr = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -974,23 +982,24 @@ Java_hdf_hdf5lib_H5_H5Dread_1string if (!(str_len = H5Tget_size((hid_t)mem_type_id))) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (cstr = (char *) HDmalloc(str_len + 1))) + if (NULL == (cstr = (char *)HDmalloc(str_len + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); - if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) + if (NULL == (c_buf = (char *)HDmalloc((size_t)n * str_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); - if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf)) < 0) + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, c_buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); for (i = 0, pos = 0; i < n; i++) { - HDmemcpy(cstr, c_buf+pos, str_len); + HDmemcpy(cstr, c_buf + pos, str_len); cstr[str_len] = '\0'; if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, cstr))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_string: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Dread_string: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, j_buf, i, jstr); @@ -1016,15 +1025,15 @@ done: * Signature: (JJJJJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1string - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray j_buf) +Java_hdf_hdf5lib_H5_H5Dwrite_1string(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jobjectArray j_buf) { const char *utf8 = NULL; jstring obj; size_t i, str_len; jsize n; - char *c_buf = NULL; + char * c_buf = NULL; herr_t status = FAIL; UNUSED(clss); @@ -1040,11 +1049,11 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1string if (!(str_len = H5Tget_size((hid_t)mem_type_id))) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) + if (NULL == (c_buf = (char *)HDmalloc((size_t)n * str_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dwrite_string: memory allocation failed"); - for (i = 0; i < (size_t) n; i++) { - if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize) i))) { + for (i = 0; i < (size_t)n; i++) { + if (NULL == (obj = (jstring)ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize)i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* @@ -1069,8 +1078,8 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1string ENVPTR->DeleteLocalRef(ENVONLY, obj); } /* end for */ - if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf)) < 0) + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + (hid_t)xfer_plist_id, c_buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1088,17 +1097,16 @@ done: * Signature: (JJJJJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5DreadVL - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5DreadVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { H5T_class_t type_class; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; htri_t isComplex2 = 0; hid_t nested_tid = H5I_INVALID_HID; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -1118,7 +1126,7 @@ Java_hdf_hdf5lib_H5_H5DreadVL if ((num_members = H5Tget_nmembers(mem_type_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0; i < (unsigned) num_members; i++) { + for (i = 0; i < (unsigned)num_members; i++) { if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1140,13 +1148,13 @@ Java_hdf_hdf5lib_H5_H5DreadVL } if (!isStr || isComplex || isVlenStr) { - if ((status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + if ((status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } else if (isStr) { - if ((status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + if ((status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } @@ -1163,21 +1171,22 @@ done: * buffer in turn. */ static herr_t -H5DreadVL_str - (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf) +H5DreadVL_str(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, + jobjectArray buf) { - jstring jstr; - jsize i, n; - char **strs = NULL; - herr_t status = FAIL; + jstring jstr; + jsize i, n; + char ** strs = NULL; + herr_t status = FAIL; if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5DreadVL_str: buf length < 0"); } - if (NULL == (strs = (char **) HDcalloc((size_t)n, sizeof(char *)))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DreadVL_str: failed to allocate variable length string read buffer"); + if (NULL == (strs = (char **)HDcalloc((size_t)n, sizeof(char *)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5DreadVL_str: failed to allocate variable length string read buffer"); if ((status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, strs)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1221,19 +1230,19 @@ done: * in the output buffer in turn. */ static herr_t -H5DreadVL_asstr - (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf) +H5DreadVL_asstr(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, + jobjectArray buf) { - H5T_class_t tclass; - jstring jstr; - h5str_t h5str; - hbool_t close_mem_space = FALSE; - size_t typeSize; - size_t i; - hid_t mem_space = mem_sid; - jsize n; - void *readBuf = NULL; - herr_t status = FAIL; + H5T_class_t tclass; + jstring jstr; + h5str_t h5str; + hbool_t close_mem_space = FALSE; + size_t typeSize; + size_t i; + hid_t mem_space = mem_sid; + jsize n; + void * readBuf = NULL; + herr_t status = FAIL; HDmemset(&h5str, 0, sizeof(h5str_t)); @@ -1278,16 +1287,16 @@ H5DreadVL_asstr H5_LIBRARY_ERROR(ENVONLY); /* Convert each element to a char string */ - for (i = 0; i < (size_t) n; i++) { + for (i = 0; i < (size_t)n; i++) { h5str.s[0] = '\0'; - if (!h5str_sprintf(ENVONLY, &h5str, did, tid, &(((char *) readBuf)[i * typeSize]), typeSize, 0)) + if (!h5str_sprintf(ENVONLY, &h5str, did, tid, &(((char *)readBuf)[i * typeSize]), typeSize, 0)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize) i, jstr); + ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize)i, jstr); CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); ENVPTR->DeleteLocalRef(ENVONLY, jstr); @@ -1319,12 +1328,12 @@ done: * Signature: (JJJJJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1VLStrings - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5Dread_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jobjectArray buf) { htri_t isVlenStr = 0; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -1335,8 +1344,8 @@ Java_hdf_hdf5lib_H5_H5Dread_1VLStrings H5_LIBRARY_ERROR(ENVONLY); if (isVlenStr) { - if ((status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + if ((status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); } else @@ -1352,17 +1361,16 @@ done: * Signature: (JJJJJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5DwriteVL - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5DwriteVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { H5T_class_t type_class; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; htri_t isComplex2 = 0; hid_t nested_tid = H5I_INVALID_HID; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -1382,7 +1390,7 @@ Java_hdf_hdf5lib_H5_H5DwriteVL if ((num_members = H5Tget_nmembers(mem_type_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0; i < (unsigned) num_members; i++) { + for (i = 0; i < (unsigned)num_members; i++) { if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1404,13 +1412,13 @@ Java_hdf_hdf5lib_H5_H5DwriteVL } if (!isStr || isComplex || isVlenStr) { - if ((status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + if ((status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } else if (isStr) { - if ((status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + if ((status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } @@ -1426,28 +1434,29 @@ done: * The buffer of C-strings is then written to the HDF5 dataset specified. */ static herr_t -H5DwriteVL_str - (JNIEnv *env, hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, jobjectArray buf) +H5DwriteVL_str(JNIEnv *env, hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t xfer_plist_id, jobjectArray buf) { - const char *utf8 = NULL; - jstring obj; - jsize size; - jsize i; - char **writeBuf = NULL; - herr_t status = FAIL; - - if ((size = ENVPTR->GetArrayLength(ENVONLY, (jarray) buf)) < 0) { + const char *utf8 = NULL; + jstring obj; + jsize size; + jsize i; + char ** writeBuf = NULL; + herr_t status = FAIL; + + if ((size = ENVPTR->GetArrayLength(ENVONLY, (jarray)buf)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5DwriteVL_str: buf length < 0"); } - if (NULL == (writeBuf = (char **) HDcalloc((size_t)size + 1, sizeof(char *)))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate variable length string write buffer"); + if (NULL == (writeBuf = (char **)HDcalloc((size_t)size + 1, sizeof(char *)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5DwriteVL_str: failed to allocate variable length string write buffer"); for (i = 0; i < size; ++i) { jsize length; - if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, i))) { + if (NULL == (obj = (jstring)ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* @@ -1462,7 +1471,7 @@ H5DwriteVL_str PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5DwriteVL_str: string not pinned"); - if (NULL == (writeBuf[i] = (char *) HDmalloc((size_t)length + 1))) + if (NULL == (writeBuf[i] = (char *)HDmalloc((size_t)length + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate string buffer"); HDstrncpy(writeBuf[i], utf8, (size_t)length + 1); @@ -1474,7 +1483,8 @@ H5DwriteVL_str ENVPTR->DeleteLocalRef(ENVONLY, obj); } /* end for (i = 0; i < size; ++i) */ - if ((status = H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, writeBuf)) < 0) + if ((status = H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, writeBuf)) < + 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1498,18 +1508,18 @@ done: * elements is then written to the HDF5 dataset. */ static herr_t -H5DwriteVL_asstr - (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf) +H5DwriteVL_asstr(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, + jobjectArray buf) { - const char *utf8 = NULL; - jstring obj = NULL; + const char *utf8 = NULL; + jstring obj = NULL; hbool_t close_mem_space = FALSE; size_t typeSize; size_t i; hid_t mem_space = mem_sid; jsize n; - void *writeBuf = NULL; - herr_t status = FAIL; + void * writeBuf = NULL; + herr_t status = FAIL; if (mem_space == H5S_ALL) { mem_space = file_sid; @@ -1538,14 +1548,14 @@ H5DwriteVL_asstr if (NULL == (writeBuf = HDcalloc((size_t)n, typeSize))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); - for (i = 0; i < (size_t) n; ++i) { - if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, (jsize) i))) { + for (i = 0; i < (size_t)n; ++i) { + if (NULL == (obj = (jstring)ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, (jsize)i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* * If the string object was NULL, skip it. */ - HDmemset(&(((char *) writeBuf)[i * typeSize]), 0, typeSize); + HDmemset(&(((char *)writeBuf)[i * typeSize]), 0, typeSize); continue; } @@ -1561,7 +1571,7 @@ H5DwriteVL_asstr * one before destroying it with h5str_convert. */ - if (!h5str_convert(ENVONLY, (char **) &utf8, did, tid, &(((char *) writeBuf)[i * typeSize]), 0)) + if (!h5str_convert(ENVONLY, (char **)&utf8, did, tid, &(((char *)writeBuf)[i * typeSize]), 0)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); UNPIN_JAVA_STRING(ENVONLY, obj, utf8); @@ -1592,12 +1602,12 @@ done: * Signature: (JJJJJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jobjectArray buf) { - htri_t isVlenStr = 0; - herr_t status = FAIL; + htri_t isVlenStr = 0; + herr_t status = FAIL; UNUSED(clss); @@ -1608,8 +1618,8 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings H5_LIBRARY_ERROR(ENVONLY); if (isVlenStr) { - if ((status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + if ((status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) H5_LIBRARY_ERROR(ENVONLY); } /* end if */ else @@ -1625,16 +1635,15 @@ done: * Signature: (JJJJJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref - (JNIEnv *env, jclass clss, - jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, + jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, + jobjectArray buf) { - H5R_ref_t *ref_data = NULL; - h5str_t h5str; - jstring jstr; - jsize i, n; - herr_t status = FAIL; + H5R_ref_t *ref_data = NULL; + h5str_t h5str; + jstring jstr; + jsize i, n; + herr_t status = FAIL; UNUSED(clss); @@ -1645,10 +1654,11 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_reg_ref: buf length < 0"); } - if (NULL == (ref_data = (H5R_ref_t *) HDcalloc(1, (size_t)n * sizeof(H5R_ref_t)))) + if (NULL == (ref_data = (H5R_ref_t *)HDcalloc(1, (size_t)n * sizeof(H5R_ref_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate read buffer"); - if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, xfer_plist_id, ref_data)) < 0) + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, + xfer_plist_id, ref_data)) < 0) H5_LIBRARY_ERROR(ENVONLY); h5str_new(&h5str, 1024); @@ -1659,7 +1669,8 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref for (i = 0; i < n; i++) { h5str.s[0] = '\0'; - if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)dataset_id, (hid_t)mem_type_id, (void*)&ref_data[i], 0, 0)) + if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)dataset_id, (hid_t)mem_type_id, (void *)&ref_data[i], 0, + 0)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) @@ -1686,12 +1697,12 @@ done: * Signature: (JLjava/lang/String;JJJJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dcreate2 - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, - jlong space_id, jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) +Java_hdf_hdf5lib_H5__1H5Dcreate2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, + jlong space_id, jlong link_plist_id, jlong create_plist_id, + jlong access_plist_id) { const char *dsetName = NULL; - hid_t dset_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; UNUSED(clss); @@ -1700,7 +1711,8 @@ Java_hdf_hdf5lib_H5__1H5Dcreate2 PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dcreate2: dataset name not pinned"); - if ((dset_id = H5Dcreate2((hid_t)loc_id, dsetName, (hid_t)type_id, (hid_t)space_id, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) + if ((dset_id = H5Dcreate2((hid_t)loc_id, dsetName, (hid_t)type_id, (hid_t)space_id, (hid_t)link_plist_id, + (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1716,11 +1728,10 @@ done: * Signature: (JLjava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dopen2 - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist) +Java_hdf_hdf5lib_H5__1H5Dopen2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist) { const char *dsetName = NULL; - hid_t dset_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; UNUSED(clss); @@ -1745,14 +1756,15 @@ done: * Signature: (JJJJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dcreate_1anon - (JNIEnv *env, jclass clss, jlong loc_id, jlong type_id, jlong space_id, jlong dcpl_id, jlong dapl_id) +Java_hdf_hdf5lib_H5__1H5Dcreate_1anon(JNIEnv *env, jclass clss, jlong loc_id, jlong type_id, jlong space_id, + jlong dcpl_id, jlong dapl_id) { hid_t dset_id = H5I_INVALID_HID; UNUSED(clss); - if ((dset_id = H5Dcreate_anon((hid_t)loc_id, (hid_t)type_id, (hid_t)space_id, (hid_t)dcpl_id, (hid_t)dapl_id)) < 0) + if ((dset_id = H5Dcreate_anon((hid_t)loc_id, (hid_t)type_id, (hid_t)space_id, (hid_t)dcpl_id, + (hid_t)dapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1765,8 +1777,7 @@ done: * Signature: (J)I; */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dget_1space_1status - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Dget_1space_1status(JNIEnv *env, jclass clss, jlong loc_id) { H5D_space_status_t space_status = H5D_SPACE_STATUS_ERROR; @@ -1785,8 +1796,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Dget_1access_1plist - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Dget_1access_1plist(JNIEnv *env, jclass clss, jlong loc_id) { hid_t retVal = H5I_INVALID_HID; @@ -1805,8 +1815,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Dget_1offset - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Dget_1offset(JNIEnv *env, jclass clss, jlong loc_id) { haddr_t offset = HADDR_UNDEF; @@ -1825,8 +1834,8 @@ done: * Signature: (JJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size - (JNIEnv *env, jclass clss, jlong dataset_id, jlong type_id, jlong space_id) +Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size(JNIEnv *env, jclass clss, jlong dataset_id, jlong type_id, + jlong space_id) { hsize_t sz = 0; @@ -1845,14 +1854,14 @@ done: * Signature: ([BJ[BJJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Dfill - (JNIEnv *env, jclass clss, jbyteArray fill, jlong fill_type_id, jbyteArray buf, jlong buf_type_id, jlong space_id) +Java_hdf_hdf5lib_H5_H5Dfill(JNIEnv *env, jclass clss, jbyteArray fill, jlong fill_type_id, jbyteArray buf, + jlong buf_type_id, jlong space_id) { - jboolean isCopy1; - jboolean isCopy2; - herr_t status = FAIL; - jbyte *fillP = NULL; - jbyte *buffP = NULL; + jboolean isCopy1; + jboolean isCopy2; + herr_t status = FAIL; + jbyte * fillP = NULL; + jbyte * buffP = NULL; UNUSED(clss); @@ -1865,7 +1874,8 @@ Java_hdf_hdf5lib_H5_H5Dfill PIN_BYTE_ARRAY(ENVONLY, fill, fillP, &isCopy1, "H5Dfill: fill buffer not pinned"); } - if ((status = H5Dfill((const void *)fillP, (hid_t)fill_type_id, (void *)buffP, (hid_t)buf_type_id, (hid_t)space_id)) < 0) + if ((status = H5Dfill((const void *)fillP, (hid_t)fill_type_id, (void *)buffP, (hid_t)buf_type_id, + (hid_t)space_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (fillP) { @@ -1886,15 +1896,14 @@ done: * Signature: (J[J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Dset_1extent - (JNIEnv *env, jclass clss, jlong loc_id, jlongArray buf) +Java_hdf_hdf5lib_H5_H5Dset_1extent(JNIEnv *env, jclass clss, jlong loc_id, jlongArray buf) { - jboolean isCopy; - hsize_t *dims = NULL; - herr_t status; - jsize rank; - jlong *dimsBuf = NULL; - int i = 0; + jboolean isCopy; + hsize_t *dims = NULL; + herr_t status; + jsize rank; + jlong * dimsBuf = NULL; + int i = 0; UNUSED(clss); @@ -1908,7 +1917,7 @@ Java_hdf_hdf5lib_H5_H5Dset_1extent PIN_LONG_ARRAY(ENVONLY, buf, dimsBuf, &isCopy, "H5Dset_extent: buffer not pinned"); - if (NULL == (dims = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + if (NULL == (dims = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dset_extent: failed to allocate dataset dimension buffer"); for (i = 0; i < rank; i++) @@ -1925,18 +1934,18 @@ done: } /* end Java_hdf_hdf5lib_H5_H5Dset_1extent */ static herr_t -H5D_iterate_cb - (void *elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *cb_data) { +H5D_iterate_cb(void *elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *cb_data) +{ cb_wrapper *wrapper = (cb_wrapper *)cb_data; jbyteArray elemArray; jlongArray pointArray; jmethodID mid; jobject visit_callback = wrapper->visit_callback; jclass cls; - JNIEnv *cbenv = NULL; + JNIEnv * cbenv = NULL; jint status = FAIL; jsize size; - void *op_data = (void *)wrapper->op_data; + void * op_data = (void *)wrapper->op_data; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -1946,7 +1955,8 @@ H5D_iterate_cb if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "([BJI[JLhdf/hdf5lib/callbacks/H5D_iterate_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", + "([BJI[JLhdf/hdf5lib/callbacks/H5D_iterate_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); if (NULL == elem) @@ -1969,7 +1979,8 @@ H5D_iterate_cb CBENVPTR->SetLongArrayRegion(CBENVONLY, pointArray, 0, 2, (const jlong *)point); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, (void *)elemArray, elem_id, ndim, pointArray, op_data); + status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, (void *)elemArray, elem_id, ndim, + pointArray, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); CBENVPTR->GetByteArrayRegion(CBENVONLY, elemArray, 0, size, (jbyte *)elem); @@ -1988,14 +1999,13 @@ done: * Signature: ([BJJLjava/lang/Object;Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Diterate - (JNIEnv *env, jclass clss, jbyteArray buf, jlong buf_type, jlong space, - jobject callback_op, jobject op_data) +Java_hdf_hdf5lib_H5_H5Diterate(JNIEnv *env, jclass clss, jbyteArray buf, jlong buf_type, jlong space, + jobject callback_op, jobject op_data) { - cb_wrapper wrapper = { callback_op, op_data }; - jboolean isCopy; - jbyte *iterBuf = NULL; - herr_t status = FAIL; + cb_wrapper wrapper = {callback_op, op_data}; + jboolean isCopy; + jbyte * iterBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -2011,12 +2021,14 @@ Java_hdf_hdf5lib_H5_H5Diterate PIN_BYTE_ARRAY(ENVONLY, buf, iterBuf, &isCopy, "H5Diterate: buffer not pinned"); - if ((status = H5Diterate((void *)iterBuf, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void *)&wrapper)) < 0) + if ((status = H5Diterate((void *)iterBuf, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, + (void *)&wrapper)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: if (iterBuf) - UNPIN_BYTE_ARRAY(ENVONLY, buf, iterBuf, (status < 0) ? (JNI_ABORT) : ((isCopy == JNI_TRUE) ? 0 : JNI_ABORT)); + UNPIN_BYTE_ARRAY(ENVONLY, buf, iterBuf, + (status < 0) ? (JNI_ABORT) : ((isCopy == JNI_TRUE) ? 0 : JNI_ABORT)); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Diterate */ @@ -2027,8 +2039,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Dflush - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Dflush(JNIEnv *env, jclass clss, jlong loc_id) { UNUSED(clss); @@ -2045,8 +2056,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Drefresh - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Drefresh(JNIEnv *env, jclass clss, jlong loc_id) { UNUSED(clss); diff --git a/java/src/jni/h5dImp.h b/java/src/jni/h5dImp.h index f824452..b9ad1bb 100644 --- a/java/src/jni/h5dImp.h +++ b/java/src/jni/h5dImp.h @@ -21,357 +21,303 @@ extern "C" { #endif /* __cplusplus */ - /* * Class: hdf_hdf5lib_H5 * Method: _H5Dcreate * Signature: (JLjava/lang/String;JJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dcreate - (JNIEnv*, jclass, jlong, jstring, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dcreate(JNIEnv *, jclass, jlong, jstring, jlong, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Dopen * Signature: (JLjava/lang/String;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dopen - (JNIEnv*, jclass, jlong, jstring); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dopen(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: _H5Dget_space * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dget_1space - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1space(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Dget_type * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dget_1type - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1type(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Dget_create_plist * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread * Signature: (JJJJJ[BZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jbyteArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jbyteArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite * Signature: (JJJJJ[BZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jbyteArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jbyteArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: _H5Dclose * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Dclose - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Dclose(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dget_storage_size * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Dget_1storage_1size - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dget_1storage_1size(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dvlen_reclaim * Signature: (JJJ[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim - (JNIEnv*, jclass, jlong, jlong, jlong, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim(JNIEnv *, jclass, jlong, jlong, jlong, + jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread_short * Signature: (JJJJJ[SZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1short - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jshortArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1short(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jshortArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_short * Signature: (JJJJJ[SZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1short - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jshortArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1short(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jshortArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread_int * Signature: (JJJJJ[IZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1int - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jintArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1int(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jintArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_int * Signature: (JJJJJ[IZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1int - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jintArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1int(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jintArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread_long * Signature: (JJJJJ[JZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1long - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jlongArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1long(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jlongArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_long * Signature: (JJJJJ[JZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1long - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jlongArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1long(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jlongArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread_float * Signature: (JJJJJ[FZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1float - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jfloatArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1float(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jfloatArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_float * Signature: (JJJJJ[FZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1float - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jfloatArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1float(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jfloatArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread_double * Signature: (JJJJJ[DZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1double - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jdoubleArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1double(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jdoubleArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_double * Signature: (JJJJJ[DZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1double - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jdoubleArray, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1double(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jdoubleArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5DreadVL * Signature: (JJJJJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5DreadVL -(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5DreadVL(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5DwriteVL * Signature: (JJJJJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5DwriteVL -(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5DwriteVL(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread_string * Signature: (JJJJJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1string - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1string(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_string * Signature: (JJJJJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1string -(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1string(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread_VLStrings * Signature: (JJJJJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1VLStrings -(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1VLStrings(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_VLStrings * Signature: (JJJJJ[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Dread_reg_ref * Signature: (JJJJJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref -(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: _H5Dcreate2 * Signature: (JLjava/lang/String;JJJJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dcreate2 - (JNIEnv*, jclass, jlong, jstring, jlong, jlong, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dcreate2(JNIEnv *, jclass, jlong, jstring, jlong, jlong, + jlong, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Dopen2 * Signature: (JLjava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dopen2 - (JNIEnv*, jclass, jlong, jstring, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dopen2(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Dcreate_anon * Signature: (JJJJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Dcreate_1anon - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dcreate_1anon(JNIEnv *, jclass, jlong, jlong, jlong, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dget_space_status * Signature: (J)I; */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dget_1space_1status - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dget_1space_1status(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dget_access_plist * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Dget_1access_1plist - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dget_1access_1plist(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dget_offset * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Dget_1offset - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dget_1offset(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dvlen_get_buf_size * Signature: (JJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size - (JNIEnv*, jclass, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size(JNIEnv *, jclass, jlong, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dfill * Signature: ([BJ[BJJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Dfill - (JNIEnv*, jclass, jbyteArray, jlong, jbyteArray, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dfill(JNIEnv *, jclass, jbyteArray, jlong, jbyteArray, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Dset_extent * Signature: (J[J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Dset_1extent - (JNIEnv*, jclass, jlong, jlongArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dset_1extent(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Diterate * Signature: ([BJJLjava/lang/Object;Ljava/lang/Object;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Diterate - (JNIEnv*, jclass, jbyteArray, jlong, jlong, jobject, jobject); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Diterate(JNIEnv *, jclass, jbyteArray, jlong, jlong, jobject, + jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Dflush * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Dflush - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dflush(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Drefresh * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Drefresh - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Drefresh(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c index 80e23a1..13826dc 100644 --- a/java/src/jni/h5eImp.c +++ b/java/src/jni/h5eImp.c @@ -61,8 +61,7 @@ static herr_t H5E_walk_cb(int nindx, const H5E_error2_t *info, void *cb_data); * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2 - (JNIEnv *env, jclass clss, jlong stk_id) +Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2(JNIEnv *env, jclass clss, jlong stk_id) { unsigned int is_stack = 0; @@ -84,13 +83,13 @@ done: * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Eregister_1class - (JNIEnv *env, jclass clss, jstring cls_name, jstring lib_name, jstring version) +Java_hdf_hdf5lib_H5_H5Eregister_1class(JNIEnv *env, jclass clss, jstring cls_name, jstring lib_name, + jstring version) { - const char* the_cls_name = NULL; - const char* the_lib_name = NULL; - const char* the_version = NULL; - hid_t ret_val = H5I_INVALID_HID; + const char *the_cls_name = NULL; + const char *the_lib_name = NULL; + const char *the_version = NULL; + hid_t ret_val = H5I_INVALID_HID; UNUSED(clss); @@ -125,8 +124,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eunregister_1class - (JNIEnv *env, jclass clss, jlong cls_id) +Java_hdf_hdf5lib_H5_H5Eunregister_1class(JNIEnv *env, jclass clss, jlong cls_id) { UNUSED(clss); @@ -146,8 +144,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eclose_1msg - (JNIEnv *env, jclass clss, jlong err_id) +Java_hdf_hdf5lib_H5_H5Eclose_1msg(JNIEnv *env, jclass clss, jlong err_id) { UNUSED(clss); @@ -167,12 +164,11 @@ done: * Signature: (JILjava/lang/String;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ecreate_1msg - (JNIEnv *env, jclass clss, jlong err_id, jint msg_type, jstring err_msg) +Java_hdf_hdf5lib_H5_H5Ecreate_1msg(JNIEnv *env, jclass clss, jlong err_id, jint msg_type, jstring err_msg) { H5E_type_t error_msg_type = (H5E_type_t)msg_type; - const char *the_err_msg = NULL; - hid_t ret_val = H5I_INVALID_HID; + const char *the_err_msg = NULL; + hid_t ret_val = H5I_INVALID_HID; UNUSED(clss); @@ -199,8 +195,7 @@ done: * Signature: ()J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ecreate_1stack - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5Ecreate_1stack(JNIEnv *env, jclass clss) { hid_t ret_val = H5I_INVALID_HID; @@ -219,8 +214,7 @@ done: * Signature: ()J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Eget_1current_1stack - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5Eget_1current_1stack(JNIEnv *env, jclass clss) { hid_t ret_val = H5I_INVALID_HID; @@ -239,8 +233,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eclose_1stack - (JNIEnv *env, jclass clss, jlong stk_id) +Java_hdf_hdf5lib_H5_H5Eclose_1stack(JNIEnv *env, jclass clss, jlong stk_id) { UNUSED(clss); @@ -260,8 +253,7 @@ done: * Signature: (JLjava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eprint2 - (JNIEnv *env, jclass clss, jlong stk_id, jobject stream_obj) +Java_hdf_hdf5lib_H5_H5Eprint2(JNIEnv *env, jclass clss, jlong stk_id, jobject stream_obj) { herr_t ret_val = FAIL; @@ -289,12 +281,11 @@ done: * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Eget_1class_1name - (JNIEnv *env, jclass clss, jlong cls_id) +Java_hdf_hdf5lib_H5_H5Eget_1class_1name(JNIEnv *env, jclass clss, jlong cls_id) { - jstring str = NULL; - ssize_t buf_size; - char *namePtr = NULL; + jstring str = NULL; + ssize_t buf_size; + char * namePtr = NULL; UNUSED(clss); @@ -308,7 +299,7 @@ Java_hdf_hdf5lib_H5_H5Eget_1class_1name if (!buf_size) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_class_name: no class name"); - if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (namePtr = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Eget_class_name: malloc failed"); if ((H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size + 1)) < 0) @@ -331,8 +322,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eset_1current_1stack - (JNIEnv *env, jclass clss, jlong stk_id) +Java_hdf_hdf5lib_H5_H5Eset_1current_1stack(JNIEnv *env, jclass clss, jlong stk_id) { UNUSED(clss); @@ -352,8 +342,7 @@ done: * Signature: (JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Epop - (JNIEnv *env, jclass clss, jlong stk_id, jlong count) +Java_hdf_hdf5lib_H5_H5Epop(JNIEnv *env, jclass clss, jlong stk_id, jlong count) { UNUSED(clss); @@ -373,13 +362,13 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String;IJJJLjava/lang/String;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Epush2 - (JNIEnv *env, jclass clss, jlong stk_id, jstring filename, jstring funcname, - jint linenumber, jlong class_id, jlong major_id, jlong minor_id, jstring err_desc) +Java_hdf_hdf5lib_H5_H5Epush2(JNIEnv *env, jclass clss, jlong stk_id, jstring filename, jstring funcname, + jint linenumber, jlong class_id, jlong major_id, jlong minor_id, + jstring err_desc) { - const char *fName = NULL; + const char *fName = NULL; const char *fncName = NULL; - const char *errMsg = NULL; + const char *errMsg = NULL; herr_t ret_val = FAIL; UNUSED(clss); @@ -404,7 +393,7 @@ Java_hdf_hdf5lib_H5_H5Epush2 PIN_JAVA_STRING(ENVONLY, err_desc, errMsg, NULL, "H5Epush2: error message not pinned"); if ((ret_val = H5Epush2((hid_t)stk_id, fName, fncName, (unsigned)linenumber, (hid_t)class_id, - (hid_t)major_id, (hid_t)minor_id, errMsg)) < 0) + (hid_t)major_id, (hid_t)minor_id, errMsg)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -422,8 +411,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eclear2 - (JNIEnv *env, jclass clss, jlong stk_id) +Java_hdf_hdf5lib_H5_H5Eclear2(JNIEnv *env, jclass clss, jlong stk_id) { UNUSED(clss); @@ -443,14 +431,13 @@ done: * Signature: (J[I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Eget_1msg - (JNIEnv *env, jclass clss, jlong msg_id, jintArray error_msg_type_list) +Java_hdf_hdf5lib_H5_H5Eget_1msg(JNIEnv *env, jclass clss, jlong msg_id, jintArray error_msg_type_list) { - H5E_type_t error_msg_type; - jstring str = NULL; - ssize_t buf_size; - jint *theArray = NULL; - char *namePtr = NULL; + H5E_type_t error_msg_type; + jstring str = NULL; + ssize_t buf_size; + jint * theArray = NULL; + char * namePtr = NULL; UNUSED(clss); @@ -466,7 +453,7 @@ Java_hdf_hdf5lib_H5_H5Eget_1msg if (!buf_size) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_msg: invalid message"); - if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (namePtr = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Eget_msg: malloc failed"); PIN_INT_ARRAY(ENVONLY, error_msg_type_list, theArray, NULL, "H5Eget_msg: error_msg_type_list not pinned"); @@ -495,8 +482,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Eget_1num - (JNIEnv *env, jclass clss, jlong stk_id) +Java_hdf_hdf5lib_H5_H5Eget_1num(JNIEnv *env, jclass clss, jlong stk_id) { ssize_t ret_val = -1; @@ -513,8 +499,7 @@ done: } /* end Java_hdf_hdf5lib_H5_H5Eget_1num */ static herr_t -H5E_walk_cb - (int nindx, const H5E_error2_t *info, void *cb_data) +H5E_walk_cb(int nindx, const H5E_error2_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; jmethodID mid; @@ -522,10 +507,10 @@ H5E_walk_cb jstring str1, str2, str3; jobject cb_info_t = NULL; jvalue args[7]; - JNIEnv *cbenv = NULL; + JNIEnv * cbenv = NULL; jclass cbcls; - void *op_data = (void *)wrapper->op_data; - jint status = FAIL; + void * op_data = (void *)wrapper->op_data; + jint status = FAIL; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -535,7 +520,9 @@ H5E_walk_cb if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID( + CBENVONLY, cbcls, "callback", + "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); args[0].j = info->cls_id; @@ -558,7 +545,8 @@ H5E_walk_cb args[6].l = str3; - CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5E_error2_t", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, cb_info_t); + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5E_error2_t", + "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, cb_info_t); status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, nindx, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); @@ -576,10 +564,10 @@ done: * Signature: (JJLjava/lang/Object;Ljava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Ewalk2 - (JNIEnv *env, jclass clss, jlong stk_id, jlong direction, jobject callback_op, jobject op_data) +Java_hdf_hdf5lib_H5_H5Ewalk2(JNIEnv *env, jclass clss, jlong stk_id, jlong direction, jobject callback_op, + jobject op_data) { - cb_wrapper wrapper = { callback_op, op_data }; + cb_wrapper wrapper = {callback_op, op_data}; UNUSED(clss); diff --git a/java/src/jni/h5eImp.h b/java/src/jni/h5eImp.h index 051b2ed..4754965 100644 --- a/java/src/jni/h5eImp.h +++ b/java/src/jni/h5eImp.h @@ -21,159 +21,125 @@ extern "C" { #endif /* __cplusplus */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Eauto_is_v2 * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2 - (JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Eregister_class * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Eregister_1class - (JNIEnv *, jclass, jstring, jstring, jstring); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Eregister_1class(JNIEnv *, jclass, jstring, jstring, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Eunregister_class * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eunregister_1class - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eunregister_1class(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Eclose_msg * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eclose_1msg - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclose_1msg(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ecreate_msg * Signature: (JILjava/lang/String;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ecreate_1msg - (JNIEnv *, jclass, jlong, jint, jstring); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ecreate_1msg(JNIEnv *, jclass, jlong, jint, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Ecreate_stack * Signature: ()J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ecreate_1stack - (JNIEnv *, jclass); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ecreate_1stack(JNIEnv *, jclass); /* * Class: hdf_hdf5lib_H5 * Method: H5Eget_current_stack * Signature: ()J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Eget_1current_1stack - (JNIEnv *, jclass); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Eget_1current_1stack(JNIEnv *, jclass); /* * Class: hdf_hdf5lib_H5 * Method: H5Eclose_stack * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eclose_1stack - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclose_1stack(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Eprint2 * Signature: (JLjava/lang/Object;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eprint2 - (JNIEnv *, jclass, jlong, jobject); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eprint2(JNIEnv *, jclass, jlong, jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Eget_class_name * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Eget_1class_1name - (JNIEnv *, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Eget_1class_1name(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Eset_current_stack * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eset_1current_1stack - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eset_1current_1stack(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Epop * Signature: (JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Epop - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Epop(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Epush2 * Signature: (JLjava/lang/String;Ljava/lang/String;IJJJLjava/lang/String;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Epush2 - (JNIEnv *, jclass, jlong, jstring, jstring, jint, jlong, jlong, jlong, jstring); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Epush2(JNIEnv *, jclass, jlong, jstring, jstring, jint, jlong, + jlong, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Eclear2 * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Eclear2 - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclear2(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Eget_msg * Signature: (J[I)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Eget_1msg - (JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Eget_1msg(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Eget_num * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Eget_1num - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Eget_1num(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ewalk2 * Signature: (JJLjava/lang/Object;Ljava/lang/Object;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Ewalk2 - (JNIEnv *, jclass, jlong, jlong, jobject, jobject); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ewalk2(JNIEnv *, jclass, jlong, jlong, jobject, jobject); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 3b7b96c..76c5ad7 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -39,11 +39,10 @@ extern "C" { * Signature: (Ljava/lang/String;IJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Fopen - (JNIEnv *env, jclass clss, jstring name, jint flags, jlong access_id) +Java_hdf_hdf5lib_H5__1H5Fopen(JNIEnv *env, jclass clss, jstring name, jint flags, jlong access_id) { const char *fileName = NULL; - hid_t status = H5I_INVALID_HID; + hid_t status = H5I_INVALID_HID; UNUSED(clss); @@ -68,11 +67,11 @@ done: * Signature: (Ljava/lang/String;IJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Fcreate - (JNIEnv *env, jclass clss, jstring name, jint flags, jlong create_id, jlong access_id) +Java_hdf_hdf5lib_H5__1H5Fcreate(JNIEnv *env, jclass clss, jstring name, jint flags, jlong create_id, + jlong access_id) { const char *fileName = NULL; - hid_t status = H5I_INVALID_HID; + hid_t status = H5I_INVALID_HID; UNUSED(clss); @@ -97,8 +96,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Fflush - (JNIEnv *env, jclass clss, jlong object_id, jint scope) +Java_hdf_hdf5lib_H5_H5Fflush(JNIEnv *env, jclass clss, jlong object_id, jint scope) { herr_t retVal = FAIL; @@ -117,12 +115,11 @@ done: * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1name - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fget_1name(JNIEnv *env, jclass clss, jlong file_id) { - jstring str = NULL; - ssize_t buf_size; - char *namePtr = NULL; + jstring str = NULL; + ssize_t buf_size; + char * namePtr = NULL; UNUSED(clss); @@ -130,7 +127,7 @@ Java_hdf_hdf5lib_H5_H5Fget_1name if ((buf_size = H5Fget_name((hid_t)file_id, NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (namePtr = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Fget_name: malloc failed"); if ((H5Fget_name((hid_t)file_id, namePtr, (size_t)buf_size + 1)) < 0) @@ -153,13 +150,12 @@ done: * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Fis_1hdf5 - (JNIEnv *env, jclass clss, jstring name) +Java_hdf_hdf5lib_H5_H5Fis_1hdf5(JNIEnv *env, jclass clss, jstring name) { #ifndef H5_NO_DEPRECATED_SYMBOLS const char *fileName = NULL; #endif - htri_t bval = JNI_FALSE; + htri_t bval = JNI_FALSE; UNUSED(clss); @@ -193,11 +189,10 @@ done: * Signature: (Ljava/lang/String;J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Fis_1accessible - (JNIEnv *env, jclass clss, jstring name, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fis_1accessible(JNIEnv *env, jclass clss, jstring name, jlong file_id) { const char *fileName = NULL; - htri_t bval = JNI_FALSE; + htri_t bval = JNI_FALSE; UNUSED(clss); @@ -224,8 +219,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist(JNIEnv *env, jclass clss, jlong file_id) { hid_t retVal = H5I_INVALID_HID; @@ -244,8 +238,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist(JNIEnv *env, jclass clss, jlong file_id) { hid_t retVal = H5I_INVALID_HID; @@ -264,8 +257,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1intent - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fget_1intent(JNIEnv *env, jclass clss, jlong file_id) { unsigned intent = 0; @@ -284,8 +276,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1fileno - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fget_1fileno(JNIEnv *env, jclass clss, jlong file_id) { unsigned long fileno = 0; @@ -304,8 +295,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Fclose - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5__1H5Fclose(JNIEnv *env, jclass clss, jlong file_id) { herr_t status = FAIL; @@ -324,11 +314,11 @@ done: * Signature: (JLjava/lang/String;JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Fmount - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong child_id, jlong plist_id) +Java_hdf_hdf5lib_H5_H5Fmount(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong child_id, + jlong plist_id) { const char *fileName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -353,11 +343,10 @@ done: * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Funmount - (JNIEnv *env, jclass clss, jlong loc_id, jstring name) +Java_hdf_hdf5lib_H5_H5Funmount(JNIEnv *env, jclass clss, jlong loc_id, jstring name) { const char *fileName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -382,8 +371,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1freespace - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fget_1freespace(JNIEnv *env, jclass clss, jlong file_id) { hssize_t ret_val = -1; @@ -402,8 +390,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Freopen - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5__1H5Freopen(JNIEnv *env, jclass clss, jlong file_id) { hid_t retVal = H5I_INVALID_HID; @@ -422,16 +409,15 @@ done: * Signature: (JIJ[J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids - (JNIEnv *env, jclass clss, jlong file_id, jint types, jlong maxObjs, - jlongArray obj_id_list) +Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids(JNIEnv *env, jclass clss, jlong file_id, jint types, jlong maxObjs, + jlongArray obj_id_list) { - jboolean isCopy; - ssize_t ret_val = -1; - size_t i; - jsize rank; - jlong *obj_id_listP = NULL; - hid_t *id_list = NULL; + jboolean isCopy; + ssize_t ret_val = -1; + size_t i; + jsize rank; + jlong * obj_id_listP = NULL; + hid_t * id_list = NULL; UNUSED(clss); @@ -445,7 +431,7 @@ Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Fget_obj_ids: obj_id_list length < 0"); } - if (NULL == (id_list = (hid_t *) HDmalloc((size_t)rank * sizeof(hid_t)))) + if (NULL == (id_list = (hid_t *)HDmalloc((size_t)rank * sizeof(hid_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Fget_obj_ids: malloc failed"); if ((ret_val = H5Fget_obj_ids((hid_t)file_id, (unsigned int)types, (size_t)maxObjs, id_list)) < 0) @@ -470,8 +456,7 @@ done: * Signature: (JI)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1obj_1count - (JNIEnv *env, jclass clss, jlong file_id, jint types) +Java_hdf_hdf5lib_H5_H5Fget_1obj_1count(JNIEnv *env, jclass clss, jlong file_id, jint types) { ssize_t ret_val = -1; @@ -490,8 +475,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1filesize - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fget_1filesize(JNIEnv *env, jclass clss, jlong file_id) { hsize_t size = 0; @@ -501,7 +485,7 @@ Java_hdf_hdf5lib_H5_H5Fget_1filesize H5_LIBRARY_ERROR(ENVONLY); done: - return (jlong) size; + return (jlong)size; } /* end Java_hdf_hdf5lib_H5_H5Fget_1filesize */ /* @@ -510,8 +494,7 @@ done: * Signature: (J)D */ JNIEXPORT jdouble JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate(JNIEnv *env, jclass clss, jlong file_id) { double rate = 0.0; @@ -530,14 +513,13 @@ done: * Signature: (J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size - (JNIEnv *env, jclass clss, jlong file_id, jlongArray metadata_cache) +Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size(JNIEnv *env, jclass clss, jlong file_id, jlongArray metadata_cache) { - jboolean isCopy; - size_t max_size = 0, min_clean_size = 0, cur_size = 0; - jlong *metadata_cache_ptr = NULL; - jsize size = 0; - int cur_num_entries = -1; + jboolean isCopy; + size_t max_size = 0, min_clean_size = 0, cur_size = 0; + jlong * metadata_cache_ptr = NULL; + jsize size = 0; + int cur_num_entries = -1; UNUSED(clss); @@ -555,7 +537,8 @@ Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size if (H5Fget_mdc_size((hid_t)file_id, &max_size, &min_clean_size, &cur_size, &cur_num_entries) < 0) H5_LIBRARY_ERROR(ENVONLY); - PIN_LONG_ARRAY(ENVONLY, metadata_cache, metadata_cache_ptr, &isCopy, "H5Fget_mdc_size: metadata_cache array not pinned"); + PIN_LONG_ARRAY(ENVONLY, metadata_cache, metadata_cache_ptr, &isCopy, + "H5Fget_mdc_size: metadata_cache array not pinned"); metadata_cache_ptr[0] = (jlong)max_size; metadata_cache_ptr[1] = (jlong)min_clean_size; @@ -574,8 +557,7 @@ done: * Signature: (J)Lhdf/hdf5lib/structs/H5F_info2_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1info - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Fget_1info(JNIEnv *env, jclass clss, jlong obj_id) { H5F_info2_t finfo; jobject ihinfobuf; @@ -604,7 +586,8 @@ Java_hdf_hdf5lib_H5_H5Fget_1info args[7].j = (jlong)finfo.sohm.hdr_size; args[8].l = ihinfobuf; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5F_info2_t", "(IJJIJJIJLhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5F_info2_t", + "(IJJIJJIJLhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); done: return ret_obj; @@ -616,8 +599,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats(JNIEnv *env, jclass clss, jlong file_id) { UNUSED(clss); @@ -634,8 +616,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache(JNIEnv *env, jclass clss, jlong file_id) { UNUSED(clss); @@ -652,8 +633,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write(JNIEnv *env, jclass clss, jlong file_id) { UNUSED(clss); @@ -670,8 +650,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging(JNIEnv *env, jclass clss, jlong file_id) { UNUSED(clss); @@ -688,8 +667,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging - (JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging(JNIEnv *env, jclass clss, jlong file_id) { UNUSED(clss); @@ -706,14 +684,14 @@ done: * Signature: (J[Z)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status - (JNIEnv *env, jclass clss, jlong file_id, jbooleanArray mdc_logging_status) +Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status(JNIEnv *env, jclass clss, jlong file_id, + jbooleanArray mdc_logging_status) { - jboolean *mdc_logging_status_ptr = NULL; - jboolean isCopy; - hbool_t is_enabled; - hbool_t is_currently_logging; - jsize size; + jboolean *mdc_logging_status_ptr = NULL; + jboolean isCopy; + hbool_t is_enabled; + hbool_t is_currently_logging; + jsize size; UNUSED(clss); @@ -731,7 +709,8 @@ Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status if (H5Fget_mdc_logging_status((hid_t)file_id, &is_enabled, &is_currently_logging) < 0) H5_LIBRARY_ERROR(ENVONLY); - PIN_BOOL_ARRAY(ENVONLY, mdc_logging_status, mdc_logging_status_ptr, &isCopy, "H5Fget_mdc_logging_status: mdc_logging_status array not pinned"); + PIN_BOOL_ARRAY(ENVONLY, mdc_logging_status, mdc_logging_status_ptr, &isCopy, + "H5Fget_mdc_logging_status: mdc_logging_status array not pinned"); mdc_logging_status_ptr[0] = (jboolean)is_enabled; mdc_logging_status_ptr[1] = (jboolean)is_currently_logging; @@ -749,8 +728,7 @@ done: * Signature: (JZ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fset_1dset_1no_1attrs_1hint -(JNIEnv *env, jclass clss, jlong file_id, jboolean minimize) +Java_hdf_hdf5lib_H5_H5Fset_1dset_1no_1attrs_1hint(JNIEnv *env, jclass clss, jlong file_id, jboolean minimize) { hbool_t minimize_val; herr_t retVal = FAIL; @@ -772,10 +750,9 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1dset_1no_1attrs_1hint -(JNIEnv *env, jclass clss, jlong file_id) +Java_hdf_hdf5lib_H5_H5Fget_1dset_1no_1attrs_1hint(JNIEnv *env, jclass clss, jlong file_id) { - jboolean bval = JNI_FALSE; + jboolean bval = JNI_FALSE; hbool_t minimize = FALSE; UNUSED(clss); @@ -784,7 +761,7 @@ Java_hdf_hdf5lib_H5_H5Fget_1dset_1no_1attrs_1hint H5_LIBRARY_ERROR(ENVONLY); if (minimize == TRUE) - bval = JNI_TRUE; + bval = JNI_TRUE; done: return bval; @@ -796,8 +773,7 @@ done: * Signature: (JII)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds - (JNIEnv *env, jclass clss, jlong file_id, jint low, jint high) +Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds(JNIEnv *env, jclass clss, jlong file_id, jint low, jint high) { herr_t retVal = FAIL; @@ -810,7 +786,6 @@ done: return; } /* end Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds */ - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h index fc02c76..6696218 100644 --- a/java/src/jni/h5fImp.h +++ b/java/src/jni/h5fImp.h @@ -26,270 +26,212 @@ extern "C" { * Method: H5Fopen * Signature: (Ljava/lang/String;IJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Fopen - (JNIEnv*, jclass, jstring, jint, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fopen(JNIEnv *, jclass, jstring, jint, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fcreate * Signature: (Ljava/lang/String;IJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Fcreate - (JNIEnv*, jclass, jstring, jint, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fcreate(JNIEnv *, jclass, jstring, jint, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fflush * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Fflush - (JNIEnv*, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fflush(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_name * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1name - (JNIEnv*, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Fget_1name(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fis_hdf5 * Signature: (Ljava/lang/String;)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Fis_1hdf5 - (JNIEnv*, jclass, jstring); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Fis_1hdf5(JNIEnv *, jclass, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Fis_accessible * Signature: (Ljava/lang/String;J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Fis_1accessible - (JNIEnv*, jclass, jstring, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Fis_1accessible(JNIEnv *, jclass, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_create_plist * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_access_plist * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_intent * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1intent - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fget_1intent(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_fileno * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1fileno - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1fileno(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fclose * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Fclose - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Fclose(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fmount * Signature: (JLjava/lang/String;JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Fmount - (JNIEnv*, jclass, jlong, jstring, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fmount(JNIEnv *, jclass, jlong, jstring, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Funmount * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Funmount - (JNIEnv*, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Funmount(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_freespace * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1freespace - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1freespace(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Freopen * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Freopen - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Freopen(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_obj_ids * Signature: (JIJ[J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids - (JNIEnv*, jclass, jlong, jint, jlong, jlongArray); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids(JNIEnv *, jclass, jlong, jint, jlong, + jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_obj_count * Signature: (JI)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1obj_1count - (JNIEnv*, jclass, jlong, jint); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1obj_1count(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_filesize * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1filesize - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1filesize(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_mdc_hit_rate * Signature: (J)D */ -JNIEXPORT jdouble JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate - (JNIEnv*, jclass, jlong); +JNIEXPORT jdouble JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_mdc_size * Signature: (J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size - (JNIEnv*, jclass, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Freset_mdc_hit_rate_stats * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_info * Signature: (J)Lhdf/hdf5lib/structs/H5F_info2_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1info - (JNIEnv*, jclass, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Fget_1info(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fclear_elink_file_cache * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fstart_swmr_write * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fstart_mdc_logging * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fstop_mdc_logging * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_mdc_logging_status * Signature: (J[Z)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status - (JNIEnv *, jclass, jlong, jbooleanArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status(JNIEnv *, jclass, jlong, + jbooleanArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Fset_dset_no_attrs_hint * Signature: (JZ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fset_1dset_1no_1attrs_1hint - (JNIEnv *, jclass, jlong, jboolean); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fset_1dset_1no_1attrs_1hint(JNIEnv *, jclass, jlong, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Fget_dset_no_attrs_hint * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Fget_1dset_1no_1attrs_1hint - (JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Fget_1dset_1no_1attrs_1hint(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Fset_libver_bounds * Signature: (JII)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds(JNIEnv *, jclass, jlong, jint, jint); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5gImp.c b/java/src/jni/h5gImp.c index 79b1b65..43a6122 100644 --- a/java/src/jni/h5gImp.c +++ b/java/src/jni/h5gImp.c @@ -40,8 +40,7 @@ extern "C" { * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Gclose - (JNIEnv *env, jclass clss, jlong group_id) +Java_hdf_hdf5lib_H5__1H5Gclose(JNIEnv *env, jclass clss, jlong group_id) { herr_t retVal = FAIL; @@ -65,8 +64,7 @@ done: * */ jobject -create_H5G_info_t - (JNIEnv *env, H5G_info_t group_info) +create_H5G_info_t(JNIEnv *env, H5G_info_t group_info) { jfieldID fid_storage_type, fid_nlinks, fid_max_corder, fid_mounted; jboolean jmounted; @@ -92,7 +90,7 @@ create_H5G_info_t if (NULL == (fid_mounted = ENVPTR->GetFieldID(ENVONLY, cls, "mounted", "Z"))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - jmounted = (group_info.mounted == 0) ? JNI_FALSE : JNI_TRUE; + jmounted = (group_info.mounted == 0) ? JNI_FALSE : JNI_TRUE; storage_type = (jint)group_info.storage_type; ENVPTR->SetIntField(ENVONLY, obj, fid_storage_type, (jint)storage_type); @@ -117,11 +115,10 @@ done: * Signature: (JLjava/lang/String;JJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Gcreate2 - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, - jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) +Java_hdf_hdf5lib_H5__1H5Gcreate2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong link_plist_id, + jlong create_plist_id, jlong access_plist_id) { - const char *grpName = NULL; + const char *grpName = NULL; hid_t group_id = H5I_INVALID_HID; UNUSED(clss); @@ -131,7 +128,8 @@ Java_hdf_hdf5lib_H5__1H5Gcreate2 PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gcreate2: group name not pinned"); - if ((group_id = H5Gcreate2((hid_t)loc_id, grpName, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) + if ((group_id = H5Gcreate2((hid_t)loc_id, grpName, (hid_t)link_plist_id, (hid_t)create_plist_id, + (hid_t)access_plist_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -147,8 +145,7 @@ done: * Signature: (JJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Gcreate_1anon - (JNIEnv *env, jclass clss, jlong loc_id, jlong gcpl_id, jlong gapl_id) +Java_hdf_hdf5lib_H5__1H5Gcreate_1anon(JNIEnv *env, jclass clss, jlong loc_id, jlong gcpl_id, jlong gapl_id) { hid_t group_id = H5I_INVALID_HID; @@ -167,10 +164,9 @@ done: * Signature: (JLjava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Gopen2 - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist_id) +Java_hdf_hdf5lib_H5__1H5Gopen2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist_id) { - const char *grpName = NULL; + const char *grpName = NULL; hid_t group_id = H5I_INVALID_HID; UNUSED(clss); @@ -190,15 +186,13 @@ done: return (jlong)group_id; } /* end Java_hdf_hdf5lib_H5__1H5Gopen2 */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Gget_create_plist * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1create_1plist - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Gget_1create_1plist(JNIEnv *env, jclass clss, jlong loc_id) { hid_t plist_id = H5I_INVALID_HID; @@ -217,8 +211,7 @@ done: * Signature: (J)Lhdf/hdf5lib/structs/H5G_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1info - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Gget_1info(JNIEnv *env, jclass clss, jlong loc_id) { H5G_info_t group_info; jobject obj = NULL; @@ -241,12 +234,12 @@ done: * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5G_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jlong lapl_id) { H5G_info_t group_info; const char *grpName = NULL; - jobject obj = NULL; + jobject obj = NULL; herr_t ret_val = FAIL; UNUSED(clss); @@ -277,16 +270,15 @@ done: * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5G_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_type, - jint order, jlong n, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_type, jint order, jlong n, jlong lapl_id) { - H5_iter_order_t corder = (H5_iter_order_t)order; - H5_index_t cindex_type = (H5_index_t)index_type; - H5G_info_t group_info; - const char *grpName = NULL; - jobject obj = NULL; - herr_t ret_val = FAIL; + H5_iter_order_t corder = (H5_iter_order_t)order; + H5_index_t cindex_type = (H5_index_t)index_type; + H5G_info_t group_info; + const char * grpName = NULL; + jobject obj = NULL; + herr_t ret_val = FAIL; UNUSED(clss); @@ -295,8 +287,8 @@ Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gget_info_by_idx: group name not pinned"); - if ((ret_val = H5Gget_info_by_idx((hid_t)loc_id, grpName, cindex_type, - corder, (hsize_t)n, &group_info, (hid_t)lapl_id)) < 0) + if ((ret_val = H5Gget_info_by_idx((hid_t)loc_id, grpName, cindex_type, corder, (hsize_t)n, &group_info, + (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (obj = create_H5G_info_t(env, group_info))) { @@ -317,8 +309,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Gflush - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Gflush(JNIEnv *env, jclass clss, jlong loc_id) { UNUSED(clss); @@ -335,8 +326,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Grefresh - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Grefresh(JNIEnv *env, jclass clss, jlong loc_id) { UNUSED(clss); @@ -347,8 +337,6 @@ done: return; } /* end Java_hdf_hdf5lib_H5_H5Grefresh */ - - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5gImp.h b/java/src/jni/h5gImp.h index a411658..3de21b7 100644 --- a/java/src/jni/h5gImp.h +++ b/java/src/jni/h5gImp.h @@ -21,97 +21,77 @@ extern "C" { #endif /* __cplusplus */ - /* * Class: hdf_hdf5lib_H5 * Method: _H5Gclose * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Gclose - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Gclose(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Gcreate2 * Signature: (JLjava/lang/String;JJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Gcreate2 - (JNIEnv*, jclass, jlong, jstring, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Gcreate2(JNIEnv *, jclass, jlong, jstring, jlong, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Gcreate_anon * Signature: (JJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Gcreate_1anon - (JNIEnv*, jclass, jlong, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Gcreate_1anon(JNIEnv *, jclass, jlong, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Gopen2 * Signature: (JLjava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Gopen2 - (JNIEnv*, jclass, jlong, jstring, jlong); - +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Gopen2(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Gget_create_plist * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1create_1plist -(JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Gget_1create_1plist(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Gget_info * Signature: (J)Lhdf/hdf5lib/structs/H5G_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1info - (JNIEnv*, jclass, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Gget_info_by_name * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5G_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name - (JNIEnv*, jclass, jlong, jstring, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Gget_info_by_idx * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5G_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx - (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, + jint, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Gflush * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Gflush - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Gflush(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Grefresh * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Grefresh - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Grefresh(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5iImp.c b/java/src/jni/h5iImp.c index e8030aee..78cc138 100644 --- a/java/src/jni/h5iImp.c +++ b/java/src/jni/h5iImp.c @@ -38,8 +38,7 @@ extern "C" { * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1type - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Iget_1type(JNIEnv *env, jclass clss, jlong obj_id) { H5I_type_t retVal = H5I_BADID; @@ -58,19 +57,19 @@ done: * Signature: (JLjava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1name_1long - (JNIEnv *env, jclass clss, jlong obj_id, jobjectArray name, jlong buf_size) +Java_hdf_hdf5lib_H5_H5Iget_1name_1long(JNIEnv *env, jclass clss, jlong obj_id, jobjectArray name, + jlong buf_size) { - ssize_t size = -1; - jstring str; - char *aName = NULL; + ssize_t size = -1; + jstring str; + char * aName = NULL; UNUSED(clss); if (buf_size < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Iget_name_long: buf_size < 0"); - if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (aName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Iget_name_long: malloc failed"); if ((size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size + 1)) < 0) @@ -90,19 +89,17 @@ done: return (jlong)size; } /* end Java_hdf_hdf5lib_H5_H5Iget_1name */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Iget_name * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1name - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Iget_1name(JNIEnv *env, jclass clss, jlong obj_id) { - jstring str = NULL; - ssize_t buf_size = -1; - char *aName = NULL; + jstring str = NULL; + ssize_t buf_size = -1; + char * aName = NULL; UNUSED(clss); @@ -110,7 +107,7 @@ Java_hdf_hdf5lib_H5_H5Iget_1name if ((buf_size = H5Iget_name((hid_t)obj_id, NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (aName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Iget_name: malloc failed"); if (H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size + 1) < 0) @@ -133,8 +130,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1ref - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Iget_1ref(JNIEnv *env, jclass clss, jlong obj_id) { int retVal = FAIL; @@ -153,8 +149,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iinc_1ref - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Iinc_1ref(JNIEnv *env, jclass clss, jlong obj_id) { int retVal = FAIL; @@ -173,8 +168,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Idec_1ref - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Idec_1ref(JNIEnv *env, jclass clss, jlong obj_id) { int retVal = FAIL; @@ -194,8 +188,7 @@ done: */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1file_1id - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Iget_1file_1id(JNIEnv *env, jclass clss, jlong obj_id) { hid_t file_id = H5I_INVALID_HID; @@ -205,7 +198,7 @@ Java_hdf_hdf5lib_H5_H5Iget_1file_1id H5_LIBRARY_ERROR(ENVONLY); done: - return (jlong) file_id; + return (jlong)file_id; } /* end Java_hdf_hdf5lib_H5_H5Iget_1file_1id */ /* @@ -214,8 +207,7 @@ done: * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1type_1ref - (JNIEnv *env, jclass clss, jint type) +Java_hdf_hdf5lib_H5_H5Iget_1type_1ref(JNIEnv *env, jclass clss, jint type) { int retVal = FAIL; @@ -234,8 +226,7 @@ done: * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Idec_1type_1ref - (JNIEnv *env, jclass clss, jint type) +Java_hdf_hdf5lib_H5_H5Idec_1type_1ref(JNIEnv *env, jclass clss, jint type) { int retVal = FAIL; @@ -254,8 +245,7 @@ done: * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref - (JNIEnv *env, jclass clss, jint type) +Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref(JNIEnv *env, jclass clss, jint type) { int retVal = FAIL; @@ -274,8 +264,7 @@ done: * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Inmembers - (JNIEnv *env, jclass clss, jint type) +Java_hdf_hdf5lib_H5_H5Inmembers(JNIEnv *env, jclass clss, jint type) { hsize_t num_members = 0; @@ -294,8 +283,7 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Iis_1valid - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Iis_1valid(JNIEnv *env, jclass clss, jlong obj_id) { htri_t bval = JNI_FALSE; @@ -315,8 +303,7 @@ done: * Signature: (I)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Itype_1exists - (JNIEnv *env, jclass clss, jint type) +Java_hdf_hdf5lib_H5_H5Itype_1exists(JNIEnv *env, jclass clss, jint type) { htri_t bval = JNI_FALSE; @@ -337,8 +324,7 @@ done: * Signature: (IZ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Iclear_1type - (JNIEnv *env, jclass clss, jint type, jboolean force) +Java_hdf_hdf5lib_H5_H5Iclear_1type(JNIEnv *env, jclass clss, jint type, jboolean force) { UNUSED(clss); @@ -355,8 +341,7 @@ done: * Signature: (I)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Idestroy_1type - (JNIEnv *env, jclass clss, jint type) +Java_hdf_hdf5lib_H5_H5Idestroy_1type(JNIEnv *env, jclass clss, jint type) { UNUSED(clss); diff --git a/java/src/jni/h5iImp.h b/java/src/jni/h5iImp.h index 2c854e6..ff407d9 100644 --- a/java/src/jni/h5iImp.h +++ b/java/src/jni/h5iImp.h @@ -26,54 +26,42 @@ extern "C" { * Method: H5Iget_type * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1type - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iget_1type(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Iget_name_long * Signature: (JLjava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1name_1long - (JNIEnv*, jclass, jlong, jobjectArray, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Iget_1name_1long(JNIEnv *, jclass, jlong, jobjectArray, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Iget_name * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1name - (JNIEnv*, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Iget_1name(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Iget_ref * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1ref - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iget_1ref(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Iinc_ref * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iinc_1ref - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iinc_1ref(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Idec_1ref * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Idec_1ref - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Idec_1ref(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 @@ -81,81 +69,63 @@ Java_hdf_hdf5lib_H5_H5Idec_1ref * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1file_1id - (JNIEnv*, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Iget_1file_1id(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Iget_type_ref * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iget_1type_1ref - (JNIEnv*, jclass, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iget_1type_1ref(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Idec_type_ref * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Idec_1type_1ref - (JNIEnv*, jclass, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Idec_1type_1ref(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Iinc_type_ref * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref - (JNIEnv*, jclass, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Inmembers * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Inmembers - (JNIEnv*, jclass, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Inmembers(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Iis_valid * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Iis_1valid - (JNIEnv*, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Iis_1valid(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Itype_exists * Signature: (I)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Itype_1exists - (JNIEnv*, jclass, jint); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Itype_1exists(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Iclear_type * Signature: (IZ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Iclear_1type - (JNIEnv*, jclass, jint, jboolean); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Iclear_1type(JNIEnv *, jclass, jint, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Idestroy_type * Signature: (I)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Idestroy_1type - (JNIEnv*, jclass, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Idestroy_1type(JNIEnv *, jclass, jint); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5jni.h b/java/src/jni/h5jni.h index f583630..346b605 100644 --- a/java/src/jni/h5jni.h +++ b/java/src/jni/h5jni.h @@ -26,26 +26,26 @@ #define _Included_h5jni #ifdef __cplusplus - #define ENVPTR (env) - #define ENVONLY - #define CBENVPTR (cbenv) - #define CBENVONLY - #define JVMPTR (jvm) - #define JVMPAR +#define ENVPTR (env) +#define ENVONLY +#define CBENVPTR (cbenv) +#define CBENVONLY +#define JVMPTR (jvm) +#define JVMPAR #else /* __cplusplus */ - #define ENVPTR (*env) - #define ENVONLY env - #define CBENVPTR (*cbenv) - #define CBENVONLY cbenv - #define JVMPTR (*jvm) - #define JVMPAR jvm +#define ENVPTR (*env) +#define ENVONLY env +#define CBENVPTR (*cbenv) +#define CBENVONLY cbenv +#define JVMPTR (*jvm) +#define JVMPAR jvm #endif /* __cplusplus */ /* * Used to silence compiler when a particular * function parameter is not used. */ -#define UNUSED(o) (void) o +#define UNUSED(o) (void)o /* * Macro to check for a JNI exception after a JNI method is called. @@ -57,205 +57,207 @@ * cleanup+return section of the native method, since at that point * cleaning up and returning is the only safe thing that can be done. */ -#define CHECK_JNI_EXCEPTION(envptr, clearException) \ -do { \ - if (JNI_TRUE == (*envptr)->ExceptionCheck(envptr)) { \ - if (JNI_TRUE == clearException) \ - (*envptr)->ExceptionClear(envptr); \ - else \ - goto done; \ - } \ -} while(0) +#define CHECK_JNI_EXCEPTION(envptr, clearException) \ + do { \ + if (JNI_TRUE == (*envptr)->ExceptionCheck(envptr)) { \ + if (JNI_TRUE == clearException) \ + (*envptr)->ExceptionClear(envptr); \ + else \ + goto done; \ + } \ + } while (0) /* Macros for class access */ /* Calling code must define ret_obj as jobject */ -#define CALL_CONSTRUCTOR(envptr, classname, classsig, args, ret_obj) \ -do { \ - jmethodID constructor; \ - jclass cls; \ - \ - if (NULL == (cls = (*envptr)->FindClass(envptr, (classname)))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, "JNI error: GetObjectClass"); \ - } \ - if (NULL == (constructor = (*envptr)->GetMethodID(envptr, cls, "", (classsig)))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, "JNI error: GetMethodID failed"); \ - } \ - if (NULL == (ret_obj = (*envptr)->NewObjectA(envptr, cls, constructor, (args)))) { \ - HDprintf("FATAL ERROR: %s: Creation failed\n", classname); \ - CHECK_JNI_EXCEPTION(envptr, JNI_FALSE); \ - } \ -} while(0) +#define CALL_CONSTRUCTOR(envptr, classname, classsig, args, ret_obj) \ + do { \ + jmethodID constructor; \ + jclass cls; \ + \ + if (NULL == (cls = (*envptr)->FindClass(envptr, (classname)))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, "JNI error: GetObjectClass"); \ + } \ + if (NULL == (constructor = (*envptr)->GetMethodID(envptr, cls, "", (classsig)))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, "JNI error: GetMethodID failed"); \ + } \ + if (NULL == (ret_obj = (*envptr)->NewObjectA(envptr, cls, constructor, (args)))) { \ + HDprintf("FATAL ERROR: %s: Creation failed\n", classname); \ + CHECK_JNI_EXCEPTION(envptr, JNI_FALSE); \ + } \ + } while (0) /* * Macros for pinning/unpinning objects. */ -#define PIN_BYTE_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (*envptr)->GetByteArrayElements(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define PIN_BYTE_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (jbyte *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define UNPIN_BYTE_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ -do { \ - (*envptr)->ReleaseByteArrayElements(envptr, pinnedArray, (jbyte *) bufToRelease, freeMode); \ -} while(0) - -#define PIN_SHORT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (*envptr)->GetShortArrayElements(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define PIN_SHORT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (jshort *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define UNPIN_SHORT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ -do { \ - (*envptr)->ReleaseShortArrayElements(envptr, pinnedArray, (jshort *) bufToRelease, freeMode); \ -} while(0) - -#define PIN_INT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (*envptr)->GetIntArrayElements(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define PIN_INT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (jint *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define UNPIN_INT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ -do { \ - (*envptr)->ReleaseIntArrayElements(envptr, pinnedArray, (jint *) bufToRelease, freeMode); \ -} while(0) - -#define PIN_LONG_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (*envptr)->GetLongArrayElements(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define PIN_LONG_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (jlong *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define UNPIN_LONG_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ -do { \ - (*envptr)->ReleaseLongArrayElements(envptr, pinnedArray, (jlong *) bufToRelease, freeMode); \ -} while(0) - -#define PIN_FLOAT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (*envptr)->GetFloatArrayElements(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define PIN_FLOAT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (jfloat *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define UNPIN_FLOAT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ -do { \ - (*envptr)->ReleaseFloatArrayElements(envptr, pinnedArray, (jfloat *) bufToRelease, freeMode); \ -} while(0) - -#define PIN_DOUBLE_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (*envptr)->GetDoubleArrayElements(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define PIN_DOUBLE_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (jdouble *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define UNPIN_DOUBLE_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ -do { \ - (*envptr)->ReleaseDoubleArrayElements(envptr, pinnedArray, (jdouble *) bufToRelease, freeMode); \ -} while(0) - -#define PIN_BOOL_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (*envptr)->GetBooleanArrayElements(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define PIN_BOOL_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ -do { \ - if (NULL == (outBuf = (jboolean *) (*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define UNPIN_BOOL_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ -do { \ - (*envptr)->ReleaseBooleanArrayElements(envptr, pinnedArray, (jboolean *) bufToRelease, freeMode); \ -} while(0) - -#define UNPIN_ARRAY_CRITICAL(envptr, pinnedArray, bufToRelease, freeMode) \ -do { \ - (*envptr)->ReleasePrimitiveArrayCritical(envptr, pinnedArray, bufToRelease, freeMode); \ -} while(0) +#define PIN_BYTE_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (*envptr)->GetByteArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define PIN_BYTE_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (jbyte *)(*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define UNPIN_BYTE_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ + do { \ + (*envptr)->ReleaseByteArrayElements(envptr, pinnedArray, (jbyte *)bufToRelease, freeMode); \ + } while (0) + +#define PIN_SHORT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (*envptr)->GetShortArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define PIN_SHORT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (jshort *)(*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define UNPIN_SHORT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ + do { \ + (*envptr)->ReleaseShortArrayElements(envptr, pinnedArray, (jshort *)bufToRelease, freeMode); \ + } while (0) + +#define PIN_INT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (*envptr)->GetIntArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define PIN_INT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (jint *)(*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define UNPIN_INT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ + do { \ + (*envptr)->ReleaseIntArrayElements(envptr, pinnedArray, (jint *)bufToRelease, freeMode); \ + } while (0) + +#define PIN_LONG_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (*envptr)->GetLongArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define PIN_LONG_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (jlong *)(*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define UNPIN_LONG_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ + do { \ + (*envptr)->ReleaseLongArrayElements(envptr, pinnedArray, (jlong *)bufToRelease, freeMode); \ + } while (0) + +#define PIN_FLOAT_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (*envptr)->GetFloatArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define PIN_FLOAT_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (jfloat *)(*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define UNPIN_FLOAT_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ + do { \ + (*envptr)->ReleaseFloatArrayElements(envptr, pinnedArray, (jfloat *)bufToRelease, freeMode); \ + } while (0) + +#define PIN_DOUBLE_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (*envptr)->GetDoubleArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define PIN_DOUBLE_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == \ + (outBuf = (jdouble *)(*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define UNPIN_DOUBLE_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ + do { \ + (*envptr)->ReleaseDoubleArrayElements(envptr, pinnedArray, (jdouble *)bufToRelease, freeMode); \ + } while (0) + +#define PIN_BOOL_ARRAY(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == (outBuf = (*envptr)->GetBooleanArrayElements(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define PIN_BOOL_ARRAY_CRITICAL(envptr, arrayToPin, outBuf, isCopy, failErrMsg) \ + do { \ + if (NULL == \ + (outBuf = (jboolean *)(*envptr)->GetPrimitiveArrayCritical(envptr, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define UNPIN_BOOL_ARRAY(envptr, pinnedArray, bufToRelease, freeMode) \ + do { \ + (*envptr)->ReleaseBooleanArrayElements(envptr, pinnedArray, (jboolean *)bufToRelease, freeMode); \ + } while (0) + +#define UNPIN_ARRAY_CRITICAL(envptr, pinnedArray, bufToRelease, freeMode) \ + do { \ + (*envptr)->ReleasePrimitiveArrayCritical(envptr, pinnedArray, bufToRelease, freeMode); \ + } while (0) /* Macros for string access */ -#define PIN_JAVA_STRING(envptr, stringToPin, outString, isCopy, failErrMsg) \ -do { \ - if (NULL == (outString = (*envptr)->GetStringUTFChars(envptr, stringToPin, isCopy))) { \ - CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ - H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ - } \ -} while(0) - -#define UNPIN_JAVA_STRING(envptr, pinnedString, stringToRelease) \ -do { \ - (*envptr)->ReleaseStringUTFChars(envptr, pinnedString, stringToRelease); \ -} while(0) +#define PIN_JAVA_STRING(envptr, stringToPin, outString, isCopy, failErrMsg) \ + do { \ + if (NULL == (outString = (*envptr)->GetStringUTFChars(envptr, stringToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(envptr, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(envptr, failErrMsg); \ + } \ + } while (0) + +#define UNPIN_JAVA_STRING(envptr, pinnedString, stringToRelease) \ + do { \ + (*envptr)->ReleaseStringUTFChars(envptr, pinnedString, stringToRelease); \ + } while (0) #ifdef __cplusplus extern "C" { @@ -267,7 +269,7 @@ extern jboolean h5badArgument(JNIEnv *env, const char *); extern jboolean h5outOfMemory(JNIEnv *env, const char *); extern jboolean h5libraryError(JNIEnv *env); extern jboolean h5raiseException(JNIEnv *env, const char *, const char *); -extern jboolean h5unimplemented( JNIEnv *env, const char *functName); +extern jboolean h5unimplemented(JNIEnv *env, const char *functName); /* * The following macros are to facilitate immediate cleanup+return @@ -279,52 +281,52 @@ extern jboolean h5unimplemented( JNIEnv *env, const char *functName); * Note that a native method can clear the exception when one occurs and * then do its own error handling, but we instead opt to immediately return. */ -#define H5_JNI_FATAL_ERROR(env, message) \ -do { \ - h5JNIFatalError(env, message); \ - goto done; \ -} while(0) - -#define H5_NULL_ARGUMENT_ERROR(env, message) \ -do { \ - h5nullArgument(env, message); \ - goto done; \ -} while(0) - -#define H5_BAD_ARGUMENT_ERROR(env, message) \ -do { \ - h5badArgument(env, message); \ - goto done; \ -} while(0) - -#define H5_OUT_OF_MEMORY_ERROR(env, message) \ -do { \ - h5outOfMemory(env, message); \ - goto done; \ -} while(0) - -#define H5_LIBRARY_ERROR(env) \ -do { \ - h5libraryError(env); \ - goto done; \ -} while(0) - -#define H5_RAISE_EXCEPTION(env, message, exception) \ -do { \ - h5raiseException(env, message, exception); \ - goto done; \ -} while(0) - -#define H5_UNIMPLEMENTED(env, message) \ -do { \ - h5unimplemented(env, message); \ - goto done; \ -} while(0) +#define H5_JNI_FATAL_ERROR(env, message) \ + do { \ + h5JNIFatalError(env, message); \ + goto done; \ + } while (0) + +#define H5_NULL_ARGUMENT_ERROR(env, message) \ + do { \ + h5nullArgument(env, message); \ + goto done; \ + } while (0) + +#define H5_BAD_ARGUMENT_ERROR(env, message) \ + do { \ + h5badArgument(env, message); \ + goto done; \ + } while (0) + +#define H5_OUT_OF_MEMORY_ERROR(env, message) \ + do { \ + h5outOfMemory(env, message); \ + goto done; \ + } while (0) + +#define H5_LIBRARY_ERROR(env) \ + do { \ + h5libraryError(env); \ + goto done; \ + } while (0) + +#define H5_RAISE_EXCEPTION(env, message, exception) \ + do { \ + h5raiseException(env, message, exception); \ + goto done; \ + } while (0) + +#define H5_UNIMPLEMENTED(env, message) \ + do { \ + h5unimplemented(env, message); \ + goto done; \ + } while (0) /* implemented at H5.c */ -extern jint get_enum_value(JNIEnv *env, jobject enum_obj); -extern jobject get_enum_object(JNIEnv *env, const char* enum_class_name, - jint enum_val, const char* enum_field_desc); +extern jint get_enum_value(JNIEnv *env, jobject enum_obj); +extern jobject get_enum_object(JNIEnv *env, const char *enum_class_name, jint enum_val, + const char *enum_field_desc); /* implemented at H5G.c */ extern jobject create_H5G_info_t(JNIEnv *env, H5G_info_t group_info); diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c index b5312bd..5dd2d0a 100644 --- a/java/src/jni/h5lImp.c +++ b/java/src/jni/h5lImp.c @@ -49,13 +49,12 @@ static herr_t H5L_iterate_cb(hid_t g_id, const char *name, const H5L_info2_t *in * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lcopy - (JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, - jstring dst_name, jlong create_id, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lcopy(JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, + jstring dst_name, jlong create_id, jlong access_id) { const char *lCurName = NULL; const char *lDstName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -67,7 +66,8 @@ Java_hdf_hdf5lib_H5_H5Lcopy PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcopy: src name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcopy: dest name not pinned"); - if ((status = H5Lcopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + if ((status = H5Lcopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -83,14 +83,13 @@ done: * Signature: (Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lcreate_1external - (JNIEnv *env, jclass clss, jstring file_name, jstring cur_name, - jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lcreate_1external(JNIEnv *env, jclass clss, jstring file_name, jstring cur_name, + jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { const char *lFileName = NULL; - const char *lCurName = NULL; - const char *lDstName = NULL; - herr_t status = FAIL; + const char *lCurName = NULL; + const char *lDstName = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -105,7 +104,8 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1external PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcreate_external: object name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcreate_external: link name not pinned"); - if ((status = H5Lcreate_external(lFileName, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + if ((status = H5Lcreate_external(lFileName, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -123,13 +123,12 @@ done: * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lcreate_1hard - (JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, - jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lcreate_1hard(JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, + jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { const char *lCurName = NULL; const char *lDstName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -141,7 +140,8 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1hard PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcreate_hard: object name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcreate_hard: link name not pinned"); - if ((status = H5Lcreate_hard((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + if ((status = H5Lcreate_hard((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -157,13 +157,12 @@ done: * Signature: (Ljava/lang/String;JLjava/lang/String;JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lcreate_1soft - (JNIEnv *env, jclass clss, jstring cur_name, jlong dst_loc_id, - jstring dst_name, jlong create_id, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lcreate_1soft(JNIEnv *env, jclass clss, jstring cur_name, jlong dst_loc_id, + jstring dst_name, jlong create_id, jlong access_id) { const char *linkTarget = NULL; - const char *linkName = NULL; - herr_t status = FAIL; + const char *linkName = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -175,7 +174,8 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1soft PIN_JAVA_STRING(ENVONLY, cur_name, linkTarget, NULL, "H5Lcreate_soft: link target not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, linkName, NULL, "H5Lcreate_soft: link name not pinned"); - if ((status = H5Lcreate_soft(linkTarget, (hid_t)dst_loc_id, linkName, (hid_t)create_id, (hid_t)access_id)) < 0) + if ((status = + H5Lcreate_soft(linkTarget, (hid_t)dst_loc_id, linkName, (hid_t)create_id, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -191,11 +191,10 @@ done: * Signature: (JLjava/lang/String;J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Ldelete - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +Java_hdf_hdf5lib_H5_H5Ldelete(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { const char *linkName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -218,13 +217,12 @@ done: * Signature: (JLjava/lang/String;IIJJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, - jint index_field, jint order, jlong link_n, jlong access_id) +Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, + jint order, jlong link_n, jlong access_id) { const char *groupName = NULL; - hsize_t n = (hsize_t)link_n; - herr_t status = FAIL; + hsize_t n = (hsize_t)link_n; + herr_t status = FAIL; UNUSED(clss); @@ -233,7 +231,8 @@ Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Ldelete_by_idx: group name not pinned"); - if ((status = H5Ldelete_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, n, (hid_t)access_id)) < 0) + if ((status = H5Ldelete_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, + n, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -247,11 +246,10 @@ done: * Signature: (JLjava/lang/String;J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Lexists - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lexists(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { const char *linkName = NULL; - htri_t bval = JNI_FALSE; + htri_t bval = JNI_FALSE; UNUSED(clss); @@ -278,14 +276,13 @@ done: * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5L_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1info - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lget_1info(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { - H5L_info2_t infobuf; - const char *linkName = NULL; - jvalue args[5]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5L_info2_t infobuf; + const char *linkName = NULL; + jvalue args[5]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); @@ -315,7 +312,8 @@ Java_hdf_hdf5lib_H5_H5Lget_1info args[3].i = infobuf.cset; args[4].l = token; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", + "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, ret_obj); } else { args[0].i = infobuf.type; @@ -340,15 +338,14 @@ done: * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5L_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, - jint index_field, jint order, jlong link_n, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, jlong access_id) { - H5L_info2_t infobuf; - const char *groupName = NULL; - jvalue args[5]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5L_info2_t infobuf; + const char *groupName = NULL; + jvalue args[5]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); @@ -357,7 +354,9 @@ Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Lget_info_by_idx: group name not pinned"); - if ((status = H5Lget_info_by_idx2((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) + if ((status = H5Lget_info_by_idx2((hid_t)loc_id, groupName, (H5_index_t)index_field, + (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < + 0) H5_LIBRARY_ERROR(ENVONLY); /* @@ -378,7 +377,8 @@ Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx args[3].i = infobuf.cset; args[4].l = token; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", + "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, ret_obj); } else { args[0].i = infobuf.type; @@ -403,14 +403,13 @@ done: * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, - jint index_field, jint order, jlong link_n, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, jlong access_id) { - const char *groupName = NULL; - jstring str = NULL; + const char *groupName = NULL; + jstring str = NULL; ssize_t status_size = -1; - char *linkName = NULL; + char * linkName = NULL; UNUSED(clss); @@ -420,14 +419,18 @@ Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Lget_name_by_idx: group name not pinned"); /* Get the length of the link name */ - if ((status_size = H5Lget_name_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char *)NULL, (size_t)0, H5P_DEFAULT)) < 0) + if ((status_size = + H5Lget_name_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, + (hsize_t)link_n, (char *)NULL, (size_t)0, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); /* add extra space for the null terminator */ - if (NULL == (linkName = (char *) HDmalloc(sizeof(char) * (size_t)status_size + 1))) + if (NULL == (linkName = (char *)HDmalloc(sizeof(char) * (size_t)status_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_name_by_idx: failed to allocate buffer for link name"); - if ((H5Lget_name_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char *)linkName, (size_t)status_size + 1, (hid_t)access_id)) < 0) + if ((H5Lget_name_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, + (hsize_t)link_n, (char *)linkName, (size_t)status_size + 1, (hid_t)access_id)) < + 0) H5_LIBRARY_ERROR(ENVONLY); linkName[status_size] = '\0'; @@ -449,16 +452,16 @@ done: * Signature: (JLjava/lang/String;[Ljava/lang/String;J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1value - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jobjectArray link_value, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lget_1value(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jobjectArray link_value, jlong access_id) { - H5L_info2_t infobuf; - const char *file_name = NULL; - const char *obj_name = NULL; - const char *linkName = NULL; - jstring str; - herr_t status; - char *linkValue = NULL; + H5L_info2_t infobuf; + const char *file_name = NULL; + const char *obj_name = NULL; + const char *linkName = NULL; + jstring str; + herr_t status; + char * linkValue = NULL; UNUSED(clss); @@ -476,16 +479,16 @@ Java_hdf_hdf5lib_H5_H5Lget_1value if (H5L_TYPE_HARD == infobuf.type) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Lget_val: hard links are unsupported"); - if (NULL == (linkValue = (char *) HDmalloc(sizeof(char) * infobuf.u.val_size + 1))) + if (NULL == (linkValue = (char *)HDmalloc(sizeof(char) * infobuf.u.val_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_val: failed to allocate buffer for link value"); - if ((status = H5Lget_val((hid_t)loc_id, linkName, (void *)linkValue, infobuf.u.val_size + 1, (hid_t)access_id)) < 0) + if ((status = H5Lget_val((hid_t)loc_id, linkName, (void *)linkValue, infobuf.u.val_size + 1, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); linkValue[infobuf.u.val_size] = '\0'; switch (infobuf.type) { - case H5L_TYPE_SOFT: - { + case H5L_TYPE_SOFT: { if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, linkValue))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -495,9 +498,9 @@ Java_hdf_hdf5lib_H5_H5Lget_1value break; } - case H5L_TYPE_EXTERNAL: - { - if ((status = H5Lunpack_elink_val(linkValue, (size_t)infobuf.u.val_size, (unsigned *)NULL, &file_name, &obj_name)) < 0) + case H5L_TYPE_EXTERNAL: { + if ((status = H5Lunpack_elink_val(linkValue, (size_t)infobuf.u.val_size, (unsigned *)NULL, + &file_name, &obj_name)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, obj_name))) @@ -538,17 +541,17 @@ done: * Signature: (JLjava/lang/String;IIJ[Ljava/lang/String;J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, - jlong link_n, jobjectArray link_value, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, + jobjectArray link_value, jlong access_id) { - H5L_info2_t infobuf; - const char *file_name = NULL; - const char *obj_name = NULL; - const char *grpName = NULL; - jstring str; - herr_t status; - void *linkValue = NULL; + H5L_info2_t infobuf; + const char *file_name = NULL; + const char *obj_name = NULL; + const char *grpName = NULL; + jstring str; + herr_t status; + void * linkValue = NULL; UNUSED(clss); @@ -560,7 +563,8 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lget_val_by_idx: group name not pinned"); /* Get the length of the link value */ - if ((status = H5Lget_info_by_idx2((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) + if ((status = H5Lget_info_by_idx2((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, + (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (H5L_TYPE_HARD == infobuf.type) @@ -569,16 +573,17 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx if (!infobuf.u.val_size) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (linkValue = (void *) HDmalloc(infobuf.u.val_size + 1))) + if (NULL == (linkValue = (void *)HDmalloc(infobuf.u.val_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Lget_val_by_idx: failed to allocate buffer for link value"); - if ((status = H5Lget_val_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void *)linkValue, infobuf.u.val_size + 1, (hid_t)access_id)) < 0) + if ((status = H5Lget_val_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, + (hsize_t)link_n, (void *)linkValue, infobuf.u.val_size + 1, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); - ((char *) linkValue)[infobuf.u.val_size] = '\0'; + ((char *)linkValue)[infobuf.u.val_size] = '\0'; switch (infobuf.type) { - case H5L_TYPE_SOFT: - { + case H5L_TYPE_SOFT: { if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, (char *)linkValue))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -588,9 +593,9 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx break; } - case H5L_TYPE_EXTERNAL: - { - if ((status = H5Lunpack_elink_val((char *)linkValue, (size_t)infobuf.u.val_size, (unsigned *)NULL, (const char **)&file_name, (const char**)&obj_name)) < 0) + case H5L_TYPE_EXTERNAL: { + if ((status = H5Lunpack_elink_val((char *)linkValue, (size_t)infobuf.u.val_size, (unsigned *)NULL, + (const char **)&file_name, (const char **)&obj_name)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, obj_name))) @@ -631,13 +636,12 @@ done: * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lmove - (JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, - jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lmove(JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, + jstring dst_name, jlong create_id, jlong access_id) { const char *lCurName = NULL; const char *lDstName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -649,7 +653,8 @@ Java_hdf_hdf5lib_H5_H5Lmove PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lmove: src name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lmove: dest name not pinned"); - if ((status = H5Lmove((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + if ((status = H5Lmove((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -663,19 +668,18 @@ done: * Shim function for link iteration and link visiting which */ static herr_t -H5L_iterate_cb - (hid_t g_id, const char *name, const H5L_info2_t *info, void *cb_data) +H5L_iterate_cb(hid_t g_id, const char *name, const H5L_info2_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; jmethodID mid; - jobject cb_info_t = NULL; + jobject cb_info_t = NULL; jobject visit_callback = wrapper->visit_callback; jstring str; - JNIEnv *cbenv = NULL; + JNIEnv * cbenv = NULL; jclass cbcls; jvalue args[5]; - void *op_data = (void *)wrapper->op_data; - jint status = -1; + void * op_data = (void *)wrapper->op_data; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -686,7 +690,9 @@ H5L_iterate_cb if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_opdata_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", + "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/" + "hdf5lib/callbacks/H5L_iterate_opdata_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) @@ -710,7 +716,8 @@ H5L_iterate_cb args[3].i = info->cset; args[4].l = token; - CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, cb_info_t); + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5L_info_t", + "(IZJILhdf/hdf5lib/structs/H5O_token_t;)V", args, cb_info_t); } else { args[0].i = info->type; @@ -738,12 +745,11 @@ done: * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lvisit - (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, - jobject callback_op, jobject op_data) +Java_hdf_hdf5lib_H5_H5Lvisit(JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, + jobject callback_op, jobject op_data) { - cb_wrapper wrapper = { callback_op, op_data }; - herr_t status = FAIL; + cb_wrapper wrapper = {callback_op, op_data}; + herr_t status = FAIL; UNUSED(clss); @@ -755,8 +761,8 @@ Java_hdf_hdf5lib_H5_H5Lvisit if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit: callback_op is NULL"); - if ((status = H5Lvisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, - H5L_iterate_cb, (void *)&wrapper)) < 0) + if ((status = H5Lvisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, H5L_iterate_cb, + (void *)&wrapper)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -769,13 +775,12 @@ done: * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name - (JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, - jobject callback_op, jobject op_data, jlong access_id) +Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name(JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, + jint order, jobject callback_op, jobject op_data, jlong access_id) { - cb_wrapper wrapper = { callback_op, op_data }; + cb_wrapper wrapper = {callback_op, op_data}; const char *grpName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -792,7 +797,7 @@ Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lvisit_by_name: group name not pinned"); if ((status = H5Lvisit_by_name2((hid_t)grp_id, grpName, (H5_index_t)idx_type, (H5_iter_order_t)order, - H5L_iterate_cb, (void *)&wrapper, (hid_t)access_id)) < 0) + H5L_iterate_cb, (void *)&wrapper, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -808,13 +813,12 @@ done: * Signature: (JIIJLjava/lang/Object;Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Literate - (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, - jlong idx, jobject callback_op, jobject op_data) +Java_hdf_hdf5lib_H5_H5Literate(JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, jlong idx, + jobject callback_op, jobject op_data) { - cb_wrapper wrapper = { callback_op, op_data }; + cb_wrapper wrapper = {callback_op, op_data}; hsize_t start_idx = (hsize_t)idx; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -826,8 +830,8 @@ Java_hdf_hdf5lib_H5_H5Literate if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate: callback_op is NULL"); - if ((status = H5Literate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, - &start_idx, H5L_iterate_cb, (void *)&wrapper)) < 0) + if ((status = H5Literate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, &start_idx, + H5L_iterate_cb, (void *)&wrapper)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -840,14 +844,14 @@ done: * Signature: (JLjava/lang/String;IIJLjava/lang/Object;Ljava/lang/Object;J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Literate_1by_1name - (JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, - jlong idx, jobject callback_op, jobject op_data, jlong access_id) +Java_hdf_hdf5lib_H5_H5Literate_1by_1name(JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, + jint order, jlong idx, jobject callback_op, jobject op_data, + jlong access_id) { - cb_wrapper wrapper = { callback_op, op_data }; + cb_wrapper wrapper = {callback_op, op_data}; const char *groupName = NULL; hsize_t start_idx = (hsize_t)idx; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -864,7 +868,7 @@ Java_hdf_hdf5lib_H5_H5Literate_1by_1name PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Literate_by_name: group name not pinned"); if ((status = H5Literate_by_name2((hid_t)grp_id, groupName, (H5_index_t)idx_type, (H5_iter_order_t)order, - &start_idx, H5L_iterate_cb, (void*)&wrapper, (hid_t)access_id)) < 0) + &start_idx, H5L_iterate_cb, (void *)&wrapper, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -880,8 +884,7 @@ done: * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lis_1registered - (JNIEnv *env, jclass clss, jint link_cls_id) +Java_hdf_hdf5lib_H5_H5Lis_1registered(JNIEnv *env, jclass clss, jint link_cls_id) { htri_t ret_val = FAIL; @@ -900,8 +903,7 @@ done: * Signature: (I)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lunregister - (JNIEnv *env, jclass clss, jint link_cls_id) +Java_hdf_hdf5lib_H5_H5Lunregister(JNIEnv *env, jclass clss, jint link_cls_id) { UNUSED(clss); @@ -912,7 +914,6 @@ done: return; } /* end Java_hdf_hdf5lib_H5_H5Lunregister */ - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5lImp.h b/java/src/jni/h5lImp.h index 3a7d8ea..7a93c71 100644 --- a/java/src/jni/h5lImp.h +++ b/java/src/jni/h5lImp.h @@ -21,177 +21,151 @@ extern "C" { #endif /* __cplusplus */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Lcopy * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lcopy - (JNIEnv*, jclass, jlong, jstring, jlong, jstring, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lcopy(JNIEnv *, jclass, jlong, jstring, jlong, jstring, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lcreate_external * Signature: (Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lcreate_1external -(JNIEnv*, jclass, jstring, jstring, jlong, jstring, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lcreate_1external(JNIEnv *, jclass, jstring, jstring, jlong, + jstring, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lcreate_hard * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lcreate_1hard - (JNIEnv*, jclass, jlong, jstring, jlong, jstring, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lcreate_1hard(JNIEnv *, jclass, jlong, jstring, jlong, jstring, + jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lcreate_soft * Signature: (Ljava/lang/String;JLjava/lang/String;JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lcreate_1soft - (JNIEnv*, jclass, jstring, jlong, jstring, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lcreate_1soft(JNIEnv *, jclass, jstring, jlong, jstring, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ldelete * Signature: (JLjava/lang/String;J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Ldelete - (JNIEnv*, jclass, jlong, jstring, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ldelete(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ldelete_by_idx * Signature: (JLjava/lang/String;IIJJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx -(JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, jint, + jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lexists * Signature: (JLjava/lang/String;J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Lexists - (JNIEnv*, jclass, jlong, jstring, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Lexists(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lget_info * Signature: (JLjava/lang/String;J)Lhdf/hdf5lib/structs/H5L_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1info -(JNIEnv*, jclass, jlong, jstring, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Lget_1info(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lget_info_by_idx * Signature: (JLjava/lang/String;IIJJ)Lhdf/hdf5lib/structs/H5L_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx -(JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, + jint, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lget_name_by_idx * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx -(JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, + jint, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lget_value * Signature: (JLjava/lang/String;[Ljava/lang/String;J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1value - (JNIEnv*, jclass, jlong, jstring, jobjectArray, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lget_1value(JNIEnv *, jclass, jlong, jstring, jobjectArray, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lget_value_by_idx * Signature: (JLjava/lang/String;IIJ[Ljava/lang/String;J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx -(JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jobjectArray, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, + jint, jlong, jobjectArray, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lmove * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lmove - (JNIEnv*, jclass, jlong, jstring, jlong, jstring, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lmove(JNIEnv *, jclass, jlong, jstring, jlong, jstring, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lvisit * Signature: (JIILjava/lang/Object;Ljava/lang/Object;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lvisit - (JNIEnv*, jclass, jlong, jint, jint, jobject, jobject); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lvisit(JNIEnv *, jclass, jlong, jint, jint, jobject, jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Lvisit_by_name * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name - (JNIEnv*, jclass, jlong, jstring, jint, jint, jobject, jobject, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name(JNIEnv *, jclass, jlong, jstring, jint, jint, + jobject, jobject, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Literate * Signature: (JIIJLjava/lang/Object;Ljava/lang/Object;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Literate - (JNIEnv*, jclass, jlong, jint, jint, jlong, jobject, jobject); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Literate(JNIEnv *, jclass, jlong, jint, jint, jlong, jobject, + jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Literate_by_name * Signature: (JLjava/lang/String;IIJLjava/lang/Object;Ljava/lang/Object;J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Literate_1by_1name - (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jobject, jobject, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Literate_1by_1name(JNIEnv *, jclass, jlong, jstring, jint, jint, + jlong, jobject, jobject, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Lis_registered * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Lis_1registered - (JNIEnv*, jclass, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lis_1registered(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Lunregister * Signature: (I)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Lunregister - (JNIEnv*, jclass, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lunregister(JNIEnv *, jclass, jint); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c index 33bec85..1582f04 100644 --- a/java/src/jni/h5oImp.c +++ b/java/src/jni/h5oImp.c @@ -46,22 +46,23 @@ static herr_t H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info2_t *in * Create a java object of hdf.hdf5lib.structs.H5O_token_t. */ jobject -create_H5O_token_t - (JNIEnv *envptr, const H5O_token_t *token, hbool_t is_critical_pinning) +create_H5O_token_t(JNIEnv *envptr, const H5O_token_t *token, hbool_t is_critical_pinning) { - jbyteArray tokenByteBuf; - jboolean token_buf_is_copy; - jvalue constructor_args[1]; - jbyte *token_buf = NULL; - jobject ret_token_obj = NULL; + jbyteArray tokenByteBuf; + jboolean token_buf_is_copy; + jvalue constructor_args[1]; + jbyte * token_buf = NULL; + jobject ret_token_obj = NULL; if (NULL == (tokenByteBuf = (*envptr)->NewByteArray(envptr, H5O_MAX_TOKEN_SIZE))) CHECK_JNI_EXCEPTION(envptr, JNI_FALSE); if (is_critical_pinning) - PIN_BYTE_ARRAY_CRITICAL(envptr, tokenByteBuf, token_buf, &token_buf_is_copy, "create_H5O_token_t: object token buffer not pinned"); + PIN_BYTE_ARRAY_CRITICAL(envptr, tokenByteBuf, token_buf, &token_buf_is_copy, + "create_H5O_token_t: object token buffer not pinned"); else - PIN_BYTE_ARRAY(envptr, tokenByteBuf, token_buf, &token_buf_is_copy, "create_H5O_token_t: object token buffer not pinned"); + PIN_BYTE_ARRAY(envptr, tokenByteBuf, token_buf, &token_buf_is_copy, + "create_H5O_token_t: object token buffer not pinned"); HDmemcpy(token_buf, token, sizeof(H5O_token_t)); @@ -99,11 +100,10 @@ done: * Signature: (JLjava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Oopen - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist_id) +Java_hdf_hdf5lib_H5__1H5Oopen(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist_id) { const char *objName = NULL; - hid_t status = H5I_INVALID_HID; + hid_t status = H5I_INVALID_HID; UNUSED(clss); @@ -128,8 +128,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Oclose - (JNIEnv *env, jclass clss, jlong object_id) +Java_hdf_hdf5lib_H5__1H5Oclose(JNIEnv *env, jclass clss, jlong object_id) { herr_t retVal = FAIL; @@ -148,13 +147,12 @@ done: * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Ocopy - (JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, - jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) +Java_hdf_hdf5lib_H5_H5Ocopy(JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, + jstring dst_name, jlong create_id, jlong access_id) { const char *lCurName = NULL; const char *lDstName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -166,7 +164,8 @@ Java_hdf_hdf5lib_H5_H5Ocopy PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Ocopy: src name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Ocopy: dest name not pinned"); - if ((status = H5Ocopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + if ((status = H5Ocopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -182,13 +181,12 @@ done: * Signature: (JI)Lhdf/hdf5lib/structs/H5O_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1info - (JNIEnv *env, jclass clss, jlong loc_id, jint fields) +Java_hdf_hdf5lib_H5_H5Oget_1info(JNIEnv *env, jclass clss, jlong loc_id, jint fields) { H5O_info2_t infobuf; jobject token; jvalue args[9]; - herr_t status = FAIL; + herr_t status = FAIL; jobject ret_obj = NULL; UNUSED(clss); @@ -209,7 +207,8 @@ Java_hdf_hdf5lib_H5_H5Oget_1info args[7].j = infobuf.btime; args[8].j = (jlong)infobuf.num_attrs; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", + "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); done: return ret_obj; @@ -221,15 +220,15 @@ done: * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint fields, jlong access_id) +Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint fields, + jlong access_id) { - H5O_info2_t infobuf; - const char *objName = NULL; - jobject token; - jvalue args[9]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5O_info2_t infobuf; + const char *objName = NULL; + jobject token; + jvalue args[9]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); @@ -238,7 +237,8 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_info_by_name: object name not pinned"); - if ((status = H5Oget_info_by_name3((hid_t)loc_id, objName, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + if ((status = + H5Oget_info_by_name3((hid_t)loc_id, objName, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); /* Create an H5O_token_t object */ @@ -255,7 +255,8 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name args[7].j = infobuf.btime; args[8].j = (jlong)infobuf.num_attrs; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", + "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); done: if (objName) @@ -270,16 +271,16 @@ done: * Signature: (JLjava/lang/String;IIJIJ)Lhdf/hdf5lib/structs/H5O_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, - jstring name, jint index_field, jint order, jlong link_n, jint fields, jlong access_id) +Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, jint fields, + jlong access_id) { - H5O_info2_t infobuf; - const char *grpName = NULL; - jobject token; - jvalue args[9]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5O_info2_t infobuf; + const char *grpName = NULL; + jobject token; + jvalue args[9]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); @@ -288,8 +289,8 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oget_info_by_idx: group name not pinned"); - if ((status = H5Oget_info_by_idx3((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, - &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + if ((status = H5Oget_info_by_idx3((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, + (hsize_t)link_n, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); /* Create an H5O_token_t object */ @@ -306,7 +307,8 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx args[7].j = infobuf.btime; args[8].j = (jlong)infobuf.num_attrs; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", + "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, ret_obj); done: if (grpName) @@ -321,15 +323,14 @@ done: * Signature: (JI)Lhdf/hdf5lib/structs/H5O_native_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1native_1info - (JNIEnv *env, jclass clss, jlong loc_id, jint fields) +Java_hdf_hdf5lib_H5_H5Oget_1native_1info(JNIEnv *env, jclass clss, jlong loc_id, jint fields) { H5O_native_info_t infobuf; jobject hdrinfobuf; jobject obj_ihinfobuf; jobject attr_ihinfobuf; jvalue args[10]; - herr_t status = FAIL; + herr_t status = FAIL; jobject ret_obj = NULL; UNUSED(clss); @@ -367,7 +368,10 @@ Java_hdf_hdf5lib_H5_H5Oget_1native_1info args[1].l = obj_ihinfobuf; args[2].l = attr_ihinfobuf; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", + "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/" + "structs/H5_ih_info_t;)V", + args, ret_obj); done: return ret_obj; @@ -379,17 +383,17 @@ done: * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_native_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint fields, jlong access_id) +Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint fields, jlong access_id) { - H5O_native_info_t infobuf; - const char *objName = NULL; - jobject hdrinfobuf; - jobject obj_ihinfobuf; - jobject attr_ihinfobuf; - jvalue args[10]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5O_native_info_t infobuf; + const char * objName = NULL; + jobject hdrinfobuf; + jobject obj_ihinfobuf; + jobject attr_ihinfobuf; + jvalue args[10]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); @@ -398,7 +402,8 @@ Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_native_info_by_name: object name not pinned"); - if ((status = H5Oget_native_info_by_name((hid_t)loc_id, objName, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + if ((status = H5Oget_native_info_by_name((hid_t)loc_id, objName, &infobuf, (unsigned)fields, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); args[0].i = (jint)infobuf.hdr.version; @@ -431,7 +436,10 @@ Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name args[1].l = obj_ihinfobuf; args[2].l = attr_ihinfobuf; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", + "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/" + "structs/H5_ih_info_t;)V", + args, ret_obj); done: if (objName) @@ -446,18 +454,18 @@ done: * Signature: (JLjava/lang/String;IIJIJ)Lhdf/hdf5lib/structs/H5O_native_info_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, - jstring name, jint index_field, jint order, jlong link_n, jint fields, jlong access_id) +Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jint index_field, jint order, jlong link_n, jint fields, + jlong access_id) { - H5O_native_info_t infobuf; - const char *grpName = NULL; - jobject hdrinfobuf; - jobject obj_ihinfobuf; - jobject attr_ihinfobuf; - jvalue args[10]; - herr_t status = FAIL; - jobject ret_obj = NULL; + H5O_native_info_t infobuf; + const char * grpName = NULL; + jobject hdrinfobuf; + jobject obj_ihinfobuf; + jobject attr_ihinfobuf; + jvalue args[10]; + herr_t status = FAIL; + jobject ret_obj = NULL; UNUSED(clss); @@ -466,8 +474,9 @@ Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oget_native_info_by_idx: group name not pinned"); - if ((status = H5Oget_native_info_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, - &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + if ((status = H5Oget_native_info_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, + (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, + (unsigned)fields, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); args[0].i = (jint)infobuf.hdr.version; @@ -500,7 +509,10 @@ Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx args[1].l = obj_ihinfobuf; args[2].l = attr_ihinfobuf; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_native_info_t", + "(Lhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/" + "structs/H5_ih_info_t;)V", + args, ret_obj); done: if (grpName) @@ -515,12 +527,11 @@ done: * Signature: (JJLjava/lang/String;JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Olink - (JNIEnv *env, jclass clss, jlong cur_loc_id, jlong dst_loc_id, - jstring dst_name, jlong create_id, jlong access_id) +Java_hdf_hdf5lib_H5_H5Olink(JNIEnv *env, jclass clss, jlong cur_loc_id, jlong dst_loc_id, jstring dst_name, + jlong create_id, jlong access_id) { const char *linkDstName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -529,7 +540,8 @@ Java_hdf_hdf5lib_H5_H5Olink PIN_JAVA_STRING(ENVONLY, dst_name, linkDstName, NULL, "H5Olink: link destination name not pinned"); - if ((status = H5Olink((hid_t)cur_loc_id, (hid_t)dst_loc_id, linkDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + if ((status = H5Olink((hid_t)cur_loc_id, (hid_t)dst_loc_id, linkDstName, (hid_t)create_id, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -538,20 +550,19 @@ done: } /* end Java_hdf_hdf5lib_H5_H5Olink */ static herr_t -H5O_iterate_cb - (hid_t g_id, const char *name, const H5O_info2_t *info, void *cb_data) +H5O_iterate_cb(hid_t g_id, const char *name, const H5O_info2_t *info, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; jmethodID mid; - jobject cb_info_t = NULL; + jobject cb_info_t = NULL; jobject visit_callback = wrapper->visit_callback; jobject token; jstring str; - JNIEnv *cbenv = NULL; + JNIEnv * cbenv = NULL; jclass cbcls; jvalue args[12]; - void *op_data = (void *)wrapper->op_data; - jint status = FAIL; + void * op_data = (void *)wrapper->op_data; + jint status = FAIL; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -561,7 +572,9 @@ H5O_iterate_cb if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_opdata_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", + "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/" + "hdf5lib/callbacks/H5O_iterate_opdata_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) @@ -582,7 +595,8 @@ H5O_iterate_cb args[8].j = (jlong)info->num_attrs; /* Get a reference to the H5O_info_t class */ - CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, cb_info_t); + CALL_CONSTRUCTOR(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t", + "(JLhdf/hdf5lib/structs/H5O_token_t;IIJJJJJ)V", args, cb_info_t); status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); @@ -600,12 +614,11 @@ done: * Signature: (JIILjava/lang/Object;Ljava/lang/Object;I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Ovisit - (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, - jobject callback_op, jobject op_data, jint fields) +Java_hdf_hdf5lib_H5_H5Ovisit(JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, + jobject callback_op, jobject op_data, jint fields) { - cb_wrapper wrapper = { callback_op, op_data }; - herr_t status = FAIL; + cb_wrapper wrapper = {callback_op, op_data}; + herr_t status = FAIL; UNUSED(clss); @@ -617,8 +630,8 @@ Java_hdf_hdf5lib_H5_H5Ovisit if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit: callback_op is NULL"); - if ((status = H5Ovisit3((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, - H5O_iterate_cb, (void *)&wrapper, (unsigned)fields)) < 0) + if ((status = H5Ovisit3((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, H5O_iterate_cb, + (void *)&wrapper, (unsigned)fields)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -631,13 +644,13 @@ done: * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;IJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name - (JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, - jobject callback_op, jobject op_data, jint fields, jlong access_id) +Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name(JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, + jint order, jobject callback_op, jobject op_data, jint fields, + jlong access_id) { - cb_wrapper wrapper = { callback_op, op_data }; + cb_wrapper wrapper = {callback_op, op_data}; const char *objName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -654,7 +667,8 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Ovisit_by_name: object name not pinned"); if ((status = H5Ovisit_by_name3((hid_t)grp_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, - H5O_iterate_cb, (void *)&wrapper, (unsigned)fields, (hid_t)access_id)) < 0) + H5O_iterate_cb, (void *)&wrapper, (unsigned)fields, (hid_t)access_id)) < + 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -670,11 +684,10 @@ done: * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oset_1comment - (JNIEnv *env, jclass clss, jlong loc_id, jstring comment) +Java_hdf_hdf5lib_H5_H5Oset_1comment(JNIEnv *env, jclass clss, jlong loc_id, jstring comment) { const char *oComment = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -695,11 +708,10 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String;J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, - jstring name, jstring comment, jlong access_id) +Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jstring comment, jlong access_id) { - const char *objName = NULL; + const char *objName = NULL; const char *objComment = NULL; jboolean isCopy; herr_t status = FAIL; @@ -712,7 +724,8 @@ Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oset_comment_by_name: object name not pinned"); if (NULL != comment) - PIN_JAVA_STRING(ENVONLY, comment, objComment, &isCopy, "H5Oset_comment_by_name: object comment not pinned"); + PIN_JAVA_STRING(ENVONLY, comment, objComment, &isCopy, + "H5Oset_comment_by_name: object comment not pinned"); if ((status = H5Oset_comment_by_name((hid_t)loc_id, objName, objComment, (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -730,13 +743,12 @@ done: * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1comment - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Oget_1comment(JNIEnv *env, jclass clss, jlong loc_id) { - jstring str = NULL; - ssize_t buf_size; - ssize_t status = -1; - char *oComment = NULL; + jstring str = NULL; + ssize_t buf_size; + ssize_t status = -1; + char * oComment = NULL; UNUSED(clss); @@ -745,7 +757,7 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment H5_LIBRARY_ERROR(ENVONLY); if (buf_size) { - if (NULL == (oComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (oComment = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer"); if ((status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size + 1)) < 0) @@ -769,14 +781,14 @@ done: * Signature: (JLjava/lang/String;J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, + jlong access_id) { const char *objName = NULL; - jstring str = NULL; + jstring str = NULL; ssize_t buf_size; ssize_t status; - char *objComment = NULL; + char * objComment = NULL; UNUSED(clss); @@ -790,10 +802,12 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name H5_LIBRARY_ERROR(ENVONLY); if (buf_size) { - if (NULL == (objComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Oget_comment_by_name: failed to allocate buffer for object comment"); + if (NULL == (objComment = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5Oget_comment_by_name: failed to allocate buffer for object comment"); - if ((status = H5Oget_comment_by_name((hid_t)loc_id, objName, objComment, (size_t)buf_size + 1, (hid_t)access_id)) < 0) + if ((status = H5Oget_comment_by_name((hid_t)loc_id, objName, objComment, (size_t)buf_size + 1, + (hid_t)access_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); objComment[buf_size] = '\0'; @@ -816,11 +830,10 @@ done: * Signature: (JLjava/lang/String;J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Oexists_1by_1name - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) +Java_hdf_hdf5lib_H5_H5Oexists_1by_1name(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { const char *objName = NULL; - htri_t bval = JNI_FALSE; + htri_t bval = JNI_FALSE; UNUSED(clss); @@ -847,8 +860,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Odecr_1refcount - (JNIEnv *env, jclass clss, jlong object_id) +Java_hdf_hdf5lib_H5_H5Odecr_1refcount(JNIEnv *env, jclass clss, jlong object_id) { UNUSED(clss); @@ -865,8 +877,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oincr_1refcount - (JNIEnv *env, jclass clss, jlong object_id) +Java_hdf_hdf5lib_H5_H5Oincr_1refcount(JNIEnv *env, jclass clss, jlong object_id) { UNUSED(clss); @@ -883,16 +894,15 @@ done: * Signature: (JLhdf/hdf5lib/structs/H5O_token_t;)J; */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Oopen_1by_1token - (JNIEnv *env, jclass clss, jlong loc_id, jobject token) +Java_hdf_hdf5lib_H5__1H5Oopen_1by_1token(JNIEnv *env, jclass clss, jlong loc_id, jobject token) { - H5O_token_t obj_token; - jboolean token_buf_is_copy; - jfieldID token_data_field_id; - jclass token_cls; - jbyte *token_buf = NULL; - jobject token_data; - hid_t retVal = H5I_INVALID_HID; + H5O_token_t obj_token; + jboolean token_buf_is_copy; + jfieldID token_data_field_id; + jclass token_cls; + jbyte * token_buf = NULL; + jobject token_data; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -905,7 +915,8 @@ Java_hdf_hdf5lib_H5__1H5Oopen_1by_1token token_data = ENVPTR->GetObjectField(ENVONLY, token, token_data_field_id); CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - PIN_BYTE_ARRAY(ENVONLY, (jbyteArray)token_data, token_buf, &token_buf_is_copy, "H5Oopen_by_token: token buffer not pinned"); + PIN_BYTE_ARRAY(ENVONLY, (jbyteArray)token_data, token_buf, &token_buf_is_copy, + "H5Oopen_by_token: token buffer not pinned"); HDmemcpy(&obj_token, token_buf, sizeof(H5O_token_t)); UNPIN_BYTE_ARRAY(ENVONLY, (jbyteArray)token_data, token_buf, JNI_ABORT); token_buf = NULL; @@ -926,12 +937,11 @@ done: * Signature: (JLjava/lang/String;IIJJ)J; */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, - jint index_field, jint order, jlong link_n, jlong lapl_id) +Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, + jint order, jlong link_n, jlong lapl_id) { const char *grpName = NULL; - hid_t retVal = H5I_INVALID_HID; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -940,7 +950,8 @@ Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oopen_by_idx: object name not pinned"); - if ((retVal = H5Oopen_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (hid_t)lapl_id)) < 0) + if ((retVal = H5Oopen_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, + (hsize_t)link_n, (hid_t)lapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -956,8 +967,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oflush - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Oflush(JNIEnv *env, jclass clss, jlong loc_id) { UNUSED(clss); @@ -974,8 +984,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Orefresh - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Orefresh(JNIEnv *env, jclass clss, jlong loc_id) { UNUSED(clss); @@ -992,8 +1001,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Odisable_1mdc_1flushes - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Odisable_1mdc_1flushes(JNIEnv *env, jclass clss, jlong loc_id) { UNUSED(clss); @@ -1010,8 +1018,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oenable_1mdc_1flushes - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Oenable_1mdc_1flushes(JNIEnv *env, jclass clss, jlong loc_id) { UNUSED(clss); @@ -1028,11 +1035,10 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Oare_1mdc_1flushes_1disabled - (JNIEnv *env, jclass clss, jlong loc_id) +Java_hdf_hdf5lib_H5_H5Oare_1mdc_1flushes_1disabled(JNIEnv *env, jclass clss, jlong loc_id) { - jboolean bval = JNI_FALSE; - hbool_t is_disabled = FALSE; + jboolean bval = JNI_FALSE; + hbool_t is_disabled = FALSE; UNUSED(clss); @@ -1040,14 +1046,12 @@ Java_hdf_hdf5lib_H5_H5Oare_1mdc_1flushes_1disabled H5_LIBRARY_ERROR(ENVONLY); if (is_disabled == TRUE) - bval = JNI_TRUE; + bval = JNI_TRUE; done: return bval; } /* end Java_hdf_hdf5lib_H5_H5Oare_1mdc_1flushes_1disabled */ - - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5oImp.h b/java/src/jni/h5oImp.h index 2b53fd3..965df19 100644 --- a/java/src/jni/h5oImp.h +++ b/java/src/jni/h5oImp.h @@ -21,240 +21,198 @@ extern "C" { #endif /* __cplusplus */ - /* * Class: hdf_hdf5lib_H5 * Method: _H5Oopen * Signature: (JLjava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Oopen - (JNIEnv*, jclass, jlong, jstring, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Oopen(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Oclose * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Oclose - (JNIEnv*, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Oclose(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ocopy * Signature: (JLjava/lang/String;JLjava/lang/String;JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Ocopy - (JNIEnv*, jclass, jlong, jstring, jlong, jstring, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ocopy(JNIEnv *, jclass, jlong, jstring, jlong, jstring, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oget_info * Signature: (JI)Lhdf/hdf5lib/structs/H5O_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1info -(JNIEnv*, jclass, jlong, jint fields); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info(JNIEnv *, jclass, jlong, jint fields); /* * Class: hdf_hdf5lib_H5 * Method: H5Oget_info_by_name * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name -(JNIEnv*, jclass, jlong, jstring, jint fields, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name(JNIEnv *, jclass, jlong, jstring, + jint fields, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oget_info_by_idx * Signature: (JLjava/lang/String;IIJIJ)Lhdf/hdf5lib/structs/H5O_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx -(JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jint fields, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, + jint, jlong, jint fields, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oget_native_info * Signature: (JI)Lhdf/hdf5lib/structs/H5O_native_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1native_1info -(JNIEnv*, jclass, jlong, jint fields); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1native_1info(JNIEnv *, jclass, jlong, jint fields); /* * Class: hdf_hdf5lib_H5 * Method: H5Oget_native_info_by_name * Signature: (JLjava/lang/String;IJ)Lhdf/hdf5lib/structs/H5O_native_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name -(JNIEnv*, jclass, jlong, jstring, jint fields, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1name(JNIEnv *, jclass, jlong, jstring, + jint fields, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oget_native_info_by_idx * Signature: (JLjava/lang/String;IIJIJ)Lhdf/hdf5lib/structs/H5O_native_info_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx -(JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jint fields, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1native_1info_1by_1idx(JNIEnv *, jclass, jlong, jstring, + jint, jint, jlong, jint fields, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Olink * Signature: (JJLjava/lang/String;JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Olink - (JNIEnv*, jclass, jlong, jlong, jstring, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Olink(JNIEnv *, jclass, jlong, jlong, jstring, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ovisit * Signature: (JIILjava/lang/Object;Ljava/lang/Object;I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Ovisit - (JNIEnv*, jclass, jlong, jint, jint, jobject, jobject, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Ovisit(JNIEnv *, jclass, jlong, jint, jint, jobject, jobject, + jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Ovisit_by_name * Signature: (JLjava/lang/String;IILjava/lang/Object;Ljava/lang/Object;IJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name - (JNIEnv*, jclass, jlong, jstring, jint, jint, jobject, jobject, jint, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name(JNIEnv *, jclass, jlong, jstring, jint, jint, + jobject, jobject, jint, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oset_comment * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oset_1comment - (JNIEnv*, jclass, jlong, jstring); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oset_1comment(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Oset_comment_by_name * Signature: (JLjava/lang/String;Ljava/lang/String;J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name - (JNIEnv*, jclass, jlong, jstring, jstring, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name(JNIEnv *, jclass, jlong, jstring, + jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oget_comment * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1comment - (JNIEnv*, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Oget_1comment(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oget_comment_by_name * Signature: (JLjava/lang/String;J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name - (JNIEnv*, jclass, jlong, jstring, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name(JNIEnv *, jclass, jlong, jstring, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oexists_by_name * Signature: (JLjava/lang/String;J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Oexists_1by_1name - (JNIEnv*, jclass, jlong, jstring, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Oexists_1by_1name(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Odecr_refcount * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Odecr_1refcount - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Odecr_1refcount(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oincr_refcount * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oincr_1refcount - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oincr_1refcount(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Oopen_by_token * Signature: (JLhdf/hdf5lib/structs/H5O_token_t;)J; */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Oopen_1by_1token - (JNIEnv*, jclass, jlong, jobject); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Oopen_1by_1token(JNIEnv *, jclass, jlong, jobject); /* * Class: hdf_hdf5lib_H5 * Method: _H5Oopen_by_idx * Signature: (JLjava/lang/String;IIJJ)J; */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx - (JNIEnv*, jclass, jlong, jstring, jint, jint, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx(JNIEnv *, jclass, jlong, jstring, jint, jint, + jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oflush * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oflush - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oflush(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Orefresh * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Orefresh - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Orefresh(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Odisable_mdc_flushes * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Odisable_1mdc_1flushes - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Odisable_1mdc_1flushes(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oenable_mdc_flushes * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Oenable_1mdc_1flushes - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oenable_1mdc_1flushes(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Oare_mdc_flushes_disabled * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Oare_1mdc_1flushes_1disabled - (JNIEnv*, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Oare_1mdc_1flushes_1disabled(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pDAPLImp.c b/java/src/jni/h5pDAPLImp.c index 2386df1..4654aa3 100644 --- a/java/src/jni/h5pDAPLImp.c +++ b/java/src/jni/h5pDAPLImp.c @@ -44,13 +44,12 @@ static herr_t H5D_append_cb(hid_t dataset_id, hsize_t *cur_dims, void *cb_data); * Signature: (JJJD)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache - (JNIEnv *env, jclass clss, jlong dapl, jlong rdcc_nslots, - jlong rdcc_nbytes, jdouble rdcc_w0) +Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache(JNIEnv *env, jclass clss, jlong dapl, jlong rdcc_nslots, + jlong rdcc_nbytes, jdouble rdcc_w0) { UNUSED(clss); - if (H5Pset_chunk_cache((hid_t)dapl, (size_t)rdcc_nslots, (size_t)rdcc_nbytes, (double) rdcc_w0) < 0) + if (H5Pset_chunk_cache((hid_t)dapl, (size_t)rdcc_nslots, (size_t)rdcc_nbytes, (double)rdcc_w0) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -63,37 +62,38 @@ done: * Signature: (J[J[J[D)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache - (JNIEnv *env, jclass clss, jlong dapl, jlongArray rdcc_nslots, - jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) +Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache(JNIEnv *env, jclass clss, jlong dapl, jlongArray rdcc_nslots, + jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) { - jboolean isCopy; - jdouble *w0Array = NULL; - jlong *rdcc_nslotsArray = NULL; - jlong *nbytesArray = NULL; - herr_t status = FAIL; + jboolean isCopy; + jdouble *w0Array = NULL; + jlong * rdcc_nslotsArray = NULL; + jlong * nbytesArray = NULL; + herr_t status = FAIL; UNUSED(clss); if (NULL != rdcc_w0) PIN_DOUBLE_ARRAY(ENVONLY, rdcc_w0, w0Array, &isCopy, "H5Pget_chunk_cache: rdcc_w0 array not pinned"); if (NULL != rdcc_nslots) - PIN_LONG_ARRAY(ENVONLY, rdcc_nslots, rdcc_nslotsArray, &isCopy, "H5Pget_chunk_cache: rdcc_nslots array not pinned"); + PIN_LONG_ARRAY(ENVONLY, rdcc_nslots, rdcc_nslotsArray, &isCopy, + "H5Pget_chunk_cache: rdcc_nslots array not pinned"); if (NULL != rdcc_nbytes) - PIN_LONG_ARRAY(ENVONLY, rdcc_nbytes, nbytesArray, &isCopy, "H5Pget_chunk_cache: nbytesArray array not pinned"); + PIN_LONG_ARRAY(ENVONLY, rdcc_nbytes, nbytesArray, &isCopy, + "H5Pget_chunk_cache: nbytesArray array not pinned"); { /* direct cast (size_t *)variable fails on 32-bit environment */ long long rdcc_nslots_temp = *rdcc_nslotsArray; - long long nbytes_temp = *nbytesArray; - size_t rdcc_nslots_t = (size_t) rdcc_nslots_temp; - size_t nbytes_t = (size_t) nbytes_temp; + long long nbytes_temp = *nbytesArray; + size_t rdcc_nslots_t = (size_t)rdcc_nslots_temp; + size_t nbytes_t = (size_t)nbytes_temp; if ((status = H5Pget_chunk_cache((hid_t)dapl, &rdcc_nslots_t, &nbytes_t, (double *)w0Array)) < 0) H5_LIBRARY_ERROR(ENVONLY); *rdcc_nslotsArray = (jlong)rdcc_nslots_t; - *nbytesArray = (jlong)nbytes_t; + *nbytesArray = (jlong)nbytes_t; } /* end direct cast special handling */ done: @@ -111,18 +111,18 @@ done: * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix - (JNIEnv *env, jclass clss, jlong dapl_id, jstring prefix) +Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix(JNIEnv *env, jclass clss, jlong dapl_id, jstring prefix) { const char *extFilePrefix = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); if (NULL == prefix) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_efile_prefix: external file prefix is NULL"); - PIN_JAVA_STRING(ENVONLY, prefix, extFilePrefix, NULL, "H5Pset_efile_prefix: external file prefix not pinned"); + PIN_JAVA_STRING(ENVONLY, prefix, extFilePrefix, NULL, + "H5Pset_efile_prefix: external file prefix not pinned"); if ((retVal = H5Pset_efile_prefix((hid_t)dapl_id, extFilePrefix)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -138,19 +138,18 @@ done: * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix - (JNIEnv *env, jclass clss, jlong dapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix(JNIEnv *env, jclass clss, jlong dapl_id) { - ssize_t prefix_size = -1; - char *pre = NULL; - jstring str = NULL; + ssize_t prefix_size = -1; + char * pre = NULL; + jstring str = NULL; UNUSED(clss); if ((prefix_size = H5Pget_efile_prefix((hid_t)dapl_id, (char *)NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t)prefix_size + 1))) + if (NULL == (pre = (char *)HDmalloc(sizeof(char) * (size_t)prefix_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_efile_prefix: memory allocation failed"); if (H5Pget_efile_prefix((hid_t)dapl_id, (char *)pre, (size_t)prefix_size + 1) < 0) @@ -159,7 +158,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_efile_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_efile_prefix: out of memory - unable to construct string from UTF characters"); } done: @@ -175,11 +175,11 @@ done: * Signature: (JI[JLjava/lang/Object;Ljava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1append_1flush - (JNIEnv *env, jclass clss, jlong plist_id, jint ndims, jlongArray boundary, jobject callback_op, jobject op_data) +Java_hdf_hdf5lib_H5_H5Pset_1append_1flush(JNIEnv *env, jclass clss, jlong plist_id, jint ndims, + jlongArray boundary, jobject callback_op, jobject op_data) { - cb_wrapper wrapper = { callback_op, op_data }; - herr_t status = FAIL; + cb_wrapper wrapper = {callback_op, op_data}; + herr_t status = FAIL; UNUSED(clss); @@ -191,7 +191,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1append_1flush if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_append_flush: callback_op is NULL"); - if ((status = H5Pset_append_flush((hid_t)plist_id, (unsigned)ndims, (const hsize_t *)boundary, (H5D_append_cb_t)H5D_append_cb, (void *)&wrapper)) < 0) + if ((status = H5Pset_append_flush((hid_t)plist_id, (unsigned)ndims, (const hsize_t *)boundary, + (H5D_append_cb_t)H5D_append_cb, (void *)&wrapper)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -208,8 +209,7 @@ done: * Signature: (JI)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view - (JNIEnv *env, jclass clss, jlong dapl_id, jint view) +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view(JNIEnv *env, jclass clss, jlong dapl_id, jint view) { UNUSED(clss); @@ -226,8 +226,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view - (JNIEnv *env, jclass clss, jlong dapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view(JNIEnv *env, jclass clss, jlong dapl_id) { H5D_vds_view_t virtual_view = H5D_VDS_ERROR; @@ -246,8 +245,7 @@ done: * Signature: (JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap - (JNIEnv *env, jclass clss, jlong dapl_id, jlong gap_size) +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap(JNIEnv *env, jclass clss, jlong dapl_id, jlong gap_size) { UNUSED(clss); @@ -264,8 +262,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap - (JNIEnv *env, jclass clss, jlong dapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap(JNIEnv *env, jclass clss, jlong dapl_id) { hsize_t gap_size = 0; @@ -279,17 +276,16 @@ done: } /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap */ static herr_t -H5D_append_cb - (hid_t dataset_id, hsize_t *cur_dims, void *cb_data) +H5D_append_cb(hid_t dataset_id, hsize_t *cur_dims, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; jlongArray cur_dimsArray; jmethodID mid; jobject visit_callback = wrapper->visit_callback; jclass cls; - JNIEnv *cbenv = NULL; - void *op_data = (void *)wrapper->op_data; - jint status = -1; + JNIEnv * cbenv = NULL; + void * op_data = (void *)wrapper->op_data; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -299,7 +295,8 @@ H5D_append_cb if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(J[JLhdf/hdf5lib/callbacks/H5D_append_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", + "(J[JLhdf/hdf5lib/callbacks/H5D_append_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); if (NULL != cur_dims) { diff --git a/java/src/jni/h5pDAPLImp.h b/java/src/jni/h5pDAPLImp.h index a9fbadd..85238e1 100644 --- a/java/src/jni/h5pDAPLImp.h +++ b/java/src/jni/h5pDAPLImp.h @@ -25,45 +25,38 @@ extern "C" { * Method: H5Pset_chunk_cache * Signature: (JJJD)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache -(JNIEnv *, jclass, jlong, jlong, jlong, jdouble); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache(JNIEnv *, jclass, jlong, jlong, jlong, + jdouble); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_chunk_cache * Signature: (J[J[J[D)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache -(JNIEnv *, jclass, jlong, jlongArray, jlongArray, jdoubleArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache(JNIEnv *, jclass, jlong, jlongArray, + jlongArray, jdoubleArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_efile_prefix * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_efile_prefix * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix -(JNIEnv *, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_append_flush * Signature: (JI[JLjava/lang/Object;Ljava/lang/Object;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1append_1flush - (JNIEnv*, jclass, jlong, jint, jlongArray, jobject, jobject); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1append_1flush(JNIEnv *, jclass, jlong, jint, jlongArray, + jobject, jobject); /* * TODO: H5Pget_append_flush @@ -74,36 +67,28 @@ Java_hdf_hdf5lib_H5_H5Pset_1append_1flush * Method: H5Pset_virtual_view * Signature: (JI)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_virtual_view * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_virtual_printf_gap * Signature: (JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_virtual_printf_gap * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pDCPLImp.c b/java/src/jni/h5pDCPLImp.c index f5bbcb1..df9c4eb 100644 --- a/java/src/jni/h5pDCPLImp.c +++ b/java/src/jni/h5pDCPLImp.c @@ -37,8 +37,7 @@ extern "C" { * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1layout - (JNIEnv *env, jclass clss, jlong plist, jint layout) +Java_hdf_hdf5lib_H5_H5Pset_1layout(JNIEnv *env, jclass clss, jlong plist, jint layout) { herr_t retVal = FAIL; @@ -57,8 +56,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1layout - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1layout(JNIEnv *env, jclass clss, jlong plist) { H5D_layout_t retVal = H5D_LAYOUT_ERROR; @@ -77,18 +75,17 @@ done: * Signature: (JI[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk - (JNIEnv *env, jclass clss, jlong plist, jint ndims, jbyteArray dim) +Java_hdf_hdf5lib_H5_H5Pset_1chunk(JNIEnv *env, jclass clss, jlong plist, jint ndims, jbyteArray dim) { - jboolean isCopy; - hsize_t *da = NULL; - hsize_t *lp = NULL; - size_t i; - size_t rank; - jsize arrLen; - jbyte *theArray = NULL; - jlong *jlp = NULL; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *da = NULL; + hsize_t *lp = NULL; + size_t i; + size_t rank; + jsize arrLen; + jbyte * theArray = NULL; + jlong * jlp = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -102,13 +99,13 @@ Java_hdf_hdf5lib_H5_H5Pset_1chunk H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_chunk: dim array length < 0"); } - rank = (size_t) arrLen / sizeof(jlong); - if (rank < (size_t) ndims) + rank = (size_t)arrLen / sizeof(jlong); + if (rank < (size_t)ndims) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_chunk: dims array rank < ndims"); PIN_BYTE_ARRAY(ENVONLY, dim, theArray, &isCopy, "H5Pset_chunk: dim array not pinned"); - if (NULL == (da = lp = (hsize_t *) HDmalloc(rank * sizeof(hsize_t)))) + if (NULL == (da = lp = (hsize_t *)HDmalloc(rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_chunk: memory allocation failed"); jlp = (jlong *)theArray; @@ -136,15 +133,14 @@ done: * Signature: (JI[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk - (JNIEnv *env, jclass clss, jlong plist, jint max_ndims, jlongArray dims) +Java_hdf_hdf5lib_H5_H5Pget_1chunk(JNIEnv *env, jclass clss, jlong plist, jint max_ndims, jlongArray dims) { - jboolean isCopy; - hsize_t *da = NULL; - jlong *theArray = NULL; - jsize arrLen; - int i; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *da = NULL; + jlong * theArray = NULL; + jsize arrLen; + int i; + herr_t status = FAIL; UNUSED(clss); @@ -160,7 +156,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1chunk PIN_LONG_ARRAY(ENVONLY, dims, theArray, &isCopy, "H5Pget_chunk: input dims not pinned"); - if (NULL == (da = (hsize_t *) HDmalloc((size_t)max_ndims * sizeof(hsize_t)))) + if (NULL == (da = (hsize_t *)HDmalloc((size_t)max_ndims * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_chunk: memory allocation failed"); if ((status = H5Pget_chunk((hid_t)plist, (int)max_ndims, da)) < 0) @@ -184,8 +180,7 @@ done: * Signature: (JI)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts - (JNIEnv *env, jclass clss, jlong dcpl_id, jint opts) +Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts(JNIEnv *env, jclass clss, jlong dcpl_id, jint opts) { herr_t retVal = FAIL; @@ -204,8 +199,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts - (JNIEnv *env, jclass clss, jlong dcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts(JNIEnv *env, jclass clss, jlong dcpl_id) { unsigned opts = 0; @@ -224,8 +218,7 @@ done: * Signature: (JZ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint -(JNIEnv *env, jclass clss, jlong dcpl_id, jboolean minimize) +Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint(JNIEnv *env, jclass clss, jlong dcpl_id, jboolean minimize) { hbool_t minimize_val; herr_t retVal = FAIL; @@ -247,11 +240,10 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint -(JNIEnv *env, jclass clss, jlong dcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint(JNIEnv *env, jclass clss, jlong dcpl_id) { hbool_t minimize = FALSE; - jboolean bval = JNI_FALSE; + jboolean bval = JNI_FALSE; UNUSED(clss); @@ -271,8 +263,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1deflate - (JNIEnv *env, jclass clss, jlong plist, jint level) +Java_hdf_hdf5lib_H5_H5Pset_1deflate(JNIEnv *env, jclass clss, jlong plist, jint level) { herr_t retVal = FAIL; @@ -291,12 +282,12 @@ done: * Signature: (JJ[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fill_1value - (JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value) +Java_hdf_hdf5lib_H5_H5Pset_1fill_1value(JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, + jbyteArray value) { - jboolean isCopy; - jbyte *byteP = NULL; - herr_t status = FAIL; + jboolean isCopy; + jbyte * byteP = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -324,12 +315,12 @@ done: * Signature: (JJ[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fill_1value - (JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value) +Java_hdf_hdf5lib_H5_H5Pget_1fill_1value(JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, + jbyteArray value) { - jboolean isCopy; - herr_t status = FAIL; - jbyte *byteP = NULL; + jboolean isCopy; + herr_t status = FAIL; + jbyte * byteP = NULL; UNUSED(clss); @@ -354,13 +345,12 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined - (JNIEnv *env, jclass clss, jlong plist, jintArray status) +Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined(JNIEnv *env, jclass clss, jlong plist, jintArray status) { - H5D_fill_value_t value = H5D_FILL_VALUE_ERROR; - jboolean isCopy; - jint *theArray = NULL; - herr_t retVal = FAIL; + H5D_fill_value_t value = H5D_FILL_VALUE_ERROR; + jboolean isCopy; + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -387,8 +377,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fill_1time - (JNIEnv *env, jclass clss, jlong plist, jint fill_time) +Java_hdf_hdf5lib_H5_H5Pset_1fill_1time(JNIEnv *env, jclass clss, jlong plist, jint fill_time) { herr_t retVal = FAIL; @@ -407,13 +396,12 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fill_1time - (JNIEnv *env, jclass clss, jlong plist, jintArray fill_time) +Java_hdf_hdf5lib_H5_H5Pget_1fill_1time(JNIEnv *env, jclass clss, jlong plist, jintArray fill_time) { - H5D_fill_time_t time = H5D_FILL_TIME_ERROR; - jboolean isCopy; - jint *theArray = NULL; - herr_t retVal = FAIL; + H5D_fill_time_t time = H5D_FILL_TIME_ERROR; + jboolean isCopy; + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -440,8 +428,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time - (JNIEnv *env, jclass clss, jlong plist, jint alloc_time) +Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time(JNIEnv *env, jclass clss, jlong plist, jint alloc_time) { herr_t retVal = FAIL; @@ -460,13 +447,12 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time - (JNIEnv *env, jclass clss, jlong plist, jintArray alloc_time) +Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time(JNIEnv *env, jclass clss, jlong plist, jintArray alloc_time) { - H5D_alloc_time_t time = H5D_ALLOC_TIME_ERROR; - jboolean isCopy; - jint *theArray = NULL; - herr_t retVal = FAIL; + H5D_alloc_time_t time = H5D_ALLOC_TIME_ERROR; + jboolean isCopy; + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -475,7 +461,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time PIN_INT_ARRAY(ENVONLY, alloc_time, theArray, &isCopy, "H5Pget_alloc_time: alloc_time not pinned"); - if ((retVal = H5Pget_alloc_time((hid_t)plist, &time)) < 0) + if ((retVal = H5Pget_alloc_time((hid_t)plist, &time)) < 0) H5_LIBRARY_ERROR(ENVONLY); theArray[0] = time; @@ -493,26 +479,25 @@ done: * Signature: (JIIJ[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1filter - (JNIEnv *env, jclass clss, jlong plist, jint filter, jint flags, - jlong cd_nelmts, jintArray cd_values) +Java_hdf_hdf5lib_H5_H5Pset_1filter(JNIEnv *env, jclass clss, jlong plist, jint filter, jint flags, + jlong cd_nelmts, jintArray cd_values) { - jboolean isCopy; - jint *theArray = NULL; - herr_t status = FAIL; + jboolean isCopy; + jint * theArray = NULL; + herr_t status = FAIL; UNUSED(clss); if (NULL == cd_values) { - if ((status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, - (unsigned int)flags, (size_t)cd_nelmts, NULL)) < 0) + if ((status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, (unsigned int)flags, + (size_t)cd_nelmts, NULL)) < 0) H5_LIBRARY_ERROR(ENVONLY); } else { PIN_INT_ARRAY(ENVONLY, cd_values, theArray, &isCopy, "H5Pset_filter: input array not pinned"); - if ((status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, - (unsigned int)flags, (size_t)cd_nelmts, (const unsigned int *)theArray)) < 0) + if ((status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, (unsigned int)flags, + (size_t)cd_nelmts, (const unsigned int *)theArray)) < 0) H5_LIBRARY_ERROR(ENVONLY); } @@ -529,8 +514,7 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail - (JNIEnv *env, jclass clss, jlong dcpl_id) +Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail(JNIEnv *env, jclass clss, jlong dcpl_id) { htri_t bval = JNI_FALSE; @@ -551,8 +535,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nfilters - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1nfilters(JNIEnv *env, jclass clss, jlong plist) { int retVal = -1; @@ -571,17 +554,17 @@ done: * Signature: (JI[I[J[IJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter - (JNIEnv *env, jclass clss, jlong plist, jint filter_number, jintArray flags, - jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name) +Java_hdf_hdf5lib_H5_H5Pget_1filter(JNIEnv *env, jclass clss, jlong plist, jint filter_number, jintArray flags, + jlongArray cd_nelmts, jintArray cd_values, jlong namelen, + jobjectArray name) { - jboolean isCopy; - jstring str; - jint *flagsArray = NULL; - jlong *cd_nelmtsArray = NULL; - jint *cd_valuesArray = NULL; - char *filter = NULL; - herr_t status = FAIL; + jboolean isCopy; + jstring str; + jint * flagsArray = NULL; + jlong * cd_nelmtsArray = NULL; + jint * cd_valuesArray = NULL; + char * filter = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -594,23 +577,22 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter if (NULL == cd_values) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter: cd_values is NULL"); - if (NULL == (filter = (char *) HDmalloc(sizeof(char) * (size_t)namelen))) + if (NULL == (filter = (char *)HDmalloc(sizeof(char) * (size_t)namelen))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter: flags array not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter: nelmts array not pinned"); PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, "H5Pget_filter: elmts array not pinned"); - /* direct cast (size_t *)variable fails on 32-bit environment */ { unsigned int filter_config; long long cd_nelmts_temp = *cd_nelmtsArray; - size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, - (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, - (size_t)namelen, filter, &filter_config)) < 0) + if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, (unsigned int *)flagsArray, + &cd_nelmts_t, (unsigned int *)cd_valuesArray, (size_t)namelen, filter, + &filter_config)) < 0) H5_LIBRARY_ERROR(ENVONLY); filter[namelen - 1] = '\0'; @@ -620,7 +602,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, filter))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_filter: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -645,19 +628,18 @@ done: * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter2 - (JNIEnv *env, jclass clss, jlong plist, jint filter_number, - jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, - jobjectArray name, jintArray filter_config) +Java_hdf_hdf5lib_H5_H5Pget_1filter2(JNIEnv *env, jclass clss, jlong plist, jint filter_number, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, + jobjectArray name, jintArray filter_config) { - jboolean isCopy; - jstring str; - jint *flagsArray = NULL; - jlong *cd_nelmtsArray = NULL; - jint *cd_valuesArray = NULL; - jint *filter_configArray = NULL; - char *filter = NULL; - herr_t status = FAIL; + jboolean isCopy; + jstring str; + jint * flagsArray = NULL; + jlong * cd_nelmtsArray = NULL; + jint * cd_valuesArray = NULL; + jint * filter_configArray = NULL; + char * filter = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -670,21 +652,22 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter2 if (NULL == filter_config) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter2: filter_config is NULL"); - if (NULL == (filter = (char *) HDmalloc(sizeof(char) * (size_t)namelen))) + if (NULL == (filter = (char *)HDmalloc(sizeof(char) * (size_t)namelen))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter2: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter2: flags array not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter2: nelmts array not pinned"); - PIN_INT_ARRAY(ENVONLY, filter_config, filter_configArray, &isCopy, "H5Pget_filter2: filter_config array not pinned"); + PIN_INT_ARRAY(ENVONLY, filter_config, filter_configArray, &isCopy, + "H5Pget_filter2: filter_config array not pinned"); if (NULL == cd_values && *cd_nelmtsArray == 0) { /* direct cast (size_t *)variable fails on 32-bit environment */ long long cd_nelmts_temp = 0; - size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, - (unsigned int *)flagsArray, &cd_nelmts_t, NULL, - (size_t)namelen, filter, (unsigned int *)filter_configArray)) < 0) + if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, (unsigned int *)flagsArray, + &cd_nelmts_t, NULL, (size_t)namelen, filter, + (unsigned int *)filter_configArray)) < 0) H5_LIBRARY_ERROR(ENVONLY); filter[namelen - 1] = '\0'; @@ -700,11 +683,11 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter2 { /* direct cast (size_t *)variable fails on 32-bit environment */ long long cd_nelmts_temp = *cd_nelmtsArray; - size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, - (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, - (size_t)namelen, filter, (unsigned int *)filter_configArray)) < 0) + if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, (unsigned int *)flagsArray, + &cd_nelmts_t, (unsigned int *)cd_valuesArray, (size_t)namelen, + filter, (unsigned int *)filter_configArray)) < 0) H5_LIBRARY_ERROR(ENVONLY); filter[namelen - 1] = '\0'; @@ -715,7 +698,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter2 if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, filter))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter2: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_filter2: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -742,19 +726,19 @@ done: * Signature: (JI[I[J[IJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id - (JNIEnv *env, jclass clss, jlong plist, jint filter, - jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name) +Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id(JNIEnv *env, jclass clss, jlong plist, jint filter, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, + jlong namelen, jobjectArray name) { - jboolean isCopy; - jstring str; - jlong *cd_nelmtsArray = NULL; - jint *cd_valuesArray = NULL; - jint *flagsArray = NULL; - char *aName = NULL; - long bs; - int rank; - herr_t status = FAIL; + jboolean isCopy; + jstring str; + jlong * cd_nelmtsArray = NULL; + jint * cd_valuesArray = NULL; + jint * flagsArray = NULL; + char * aName = NULL; + long bs; + int rank; + herr_t status = FAIL; UNUSED(clss); @@ -771,12 +755,13 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id if (NULL == name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: name is NULL"); - if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)bs))) + if (NULL == (aName = (char *)HDmalloc(sizeof(char) * (size_t)bs))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter_by_id: flags not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter_by_id: cd_nelms not pinned"); - PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, "H5Pget_filter_by_id: cd_values array not pinned"); + PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, + "H5Pget_filter_by_id: cd_values array not pinned"); if ((rank = ENVPTR->GetArrayLength(ENVONLY, cd_values)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); @@ -787,11 +772,11 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id /* direct cast (size_t *)variable fails on 32-bit environment */ unsigned int filter_config; long long cd_nelmts_temp = *cd_nelmtsArray; - size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - if ((status = H5Pget_filter_by_id2((hid_t)plist, (H5Z_filter_t)filter, - (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, - (size_t)namelen, (char *)aName, &filter_config)) < 0) + if ((status = H5Pget_filter_by_id2((hid_t)plist, (H5Z_filter_t)filter, (unsigned int *)flagsArray, + &cd_nelmts_t, (unsigned int *)cd_valuesArray, (size_t)namelen, + (char *)aName, &filter_config)) < 0) H5_LIBRARY_ERROR(ENVONLY); aName[bs - 1] = '\0'; @@ -801,7 +786,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_filter_by_id: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -826,19 +812,19 @@ done: * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 - (JNIEnv *env, jclass clss, jlong plist, jint filter, - jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name, jintArray filter_config) +Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2(JNIEnv *env, jclass clss, jlong plist, jint filter, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, + jlong namelen, jobjectArray name, jintArray filter_config) { - jboolean isCopy; - jstring str; - jlong *cd_nelmtsArray = NULL; - jint *cd_valuesArray = NULL; - jint *flagsArray = NULL; - jint *filter_configArray = NULL; - long bs; - char *aName = NULL; - herr_t status = FAIL; + jboolean isCopy; + jstring str; + jlong * cd_nelmtsArray = NULL; + jint * cd_valuesArray = NULL; + jint * flagsArray = NULL; + jint * filter_configArray = NULL; + long bs; + char * aName = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -857,22 +843,24 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 if (NULL == filter_config) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: filter_config is NULL"); - if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)bs))) + if (NULL == (aName = (char *)HDmalloc(sizeof(char) * (size_t)bs))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id2: memory allocation failed"); PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter_by_id2: flags not pinned"); PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter_by_id2: cd_nelms not pinned"); - PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, "H5Pget_filter_by_id2: cd_values array not pinned"); - PIN_INT_ARRAY(ENVONLY, filter_config, filter_configArray, &isCopy, "H5Pget_filter_by_id2: filter_config not pinned"); + PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, + "H5Pget_filter_by_id2: cd_values array not pinned"); + PIN_INT_ARRAY(ENVONLY, filter_config, filter_configArray, &isCopy, + "H5Pget_filter_by_id2: filter_config not pinned"); { /* direct cast (size_t *)variable fails on 32-bit environment */ long long cd_nelmts_temp = *cd_nelmtsArray; - size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - if ((status = H5Pget_filter_by_id2((hid_t)plist, (H5Z_filter_t)filter, - (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, - (size_t)namelen, (char *)aName, (unsigned int *)filter_configArray)) < 0) + if ((status = H5Pget_filter_by_id2((hid_t)plist, (H5Z_filter_t)filter, (unsigned int *)flagsArray, + &cd_nelmts_t, (unsigned int *)cd_valuesArray, (size_t)namelen, + (char *)aName, (unsigned int *)filter_configArray)) < 0) H5_LIBRARY_ERROR(ENVONLY); aName[bs - 1] = '\0'; @@ -882,7 +870,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_filter_by_id2: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_filter_by_id2: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -909,13 +898,12 @@ done: * Signature: (JIIJ[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pmodify_1filter - (JNIEnv *env, jclass clss, jlong plist, jint filter, - jint flags, jlong cd_nelmts, jintArray cd_values) +Java_hdf_hdf5lib_H5_H5Pmodify_1filter(JNIEnv *env, jclass clss, jlong plist, jint filter, jint flags, + jlong cd_nelmts, jintArray cd_values) { - jboolean isCopy; - jint *cd_valuesP = NULL; - herr_t status = FAIL; + jboolean isCopy; + jint * cd_valuesP = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -925,7 +913,7 @@ Java_hdf_hdf5lib_H5_H5Pmodify_1filter PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesP, &isCopy, "H5Pmodify_filter: cd_values not pinned"); if ((status = H5Pmodify_filter((hid_t)plist, (H5Z_filter_t)filter, (const unsigned int)flags, - (size_t)cd_nelmts, (unsigned int *)cd_valuesP)) < 0) + (size_t)cd_nelmts, (unsigned int *)cd_valuesP)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -941,8 +929,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5P1remove_1filter - (JNIEnv *env, jclass clss, jlong obj_id, jint filter) +Java_hdf_hdf5lib_H5_H5P1remove_1filter(JNIEnv *env, jclass clss, jlong obj_id, jint filter) { herr_t status = FAIL; @@ -961,8 +948,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pset_1fletcher32(JNIEnv *env, jclass clss, jlong plist) { herr_t retVal = FAIL; @@ -981,8 +967,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1nbit - (JNIEnv *env, jclass clss, jlong plist_id) +Java_hdf_hdf5lib_H5_H5Pset_1nbit(JNIEnv *env, jclass clss, jlong plist_id) { herr_t retVal = FAIL; @@ -1001,8 +986,8 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset - (JNIEnv *env, jclass clss, jlong plist_id, jint scale_type, jint scale_factor) +Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset(JNIEnv *env, jclass clss, jlong plist_id, jint scale_type, + jint scale_factor) { herr_t retVal = FAIL; @@ -1026,8 +1011,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shuffle - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pset_1shuffle(JNIEnv *env, jclass clss, jlong plist) { herr_t retVal = FAIL; @@ -1046,8 +1030,8 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1szip - (JNIEnv *env, jclass clss, jlong plist, jint options_mask, jint pixels_per_block) +Java_hdf_hdf5lib_H5_H5Pset_1szip(JNIEnv *env, jclass clss, jlong plist, jint options_mask, + jint pixels_per_block) { herr_t retVal = FAIL; @@ -1066,11 +1050,11 @@ done: * Signature: (JLjava/lang/String;JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1external - (JNIEnv *env, jclass clss, jlong plist, jstring name, jlong offset, jlong size) +Java_hdf_hdf5lib_H5_H5Pset_1external(JNIEnv *env, jclass clss, jlong plist, jstring name, jlong offset, + jlong size) { const char *fileName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -1095,18 +1079,17 @@ done: * Signature: (JIJ[Ljava/lang/String;[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1external - (JNIEnv *env, jclass clss, jlong plist, jint idx, jlong name_size, - jobjectArray name, jlongArray size) +Java_hdf_hdf5lib_H5_H5Pget_1external(JNIEnv *env, jclass clss, jlong plist, jint idx, jlong name_size, + jobjectArray name, jlongArray size) { - jboolean isCopy; - jstring str; - hsize_t s; - off_t o; - jsize arrLen; - jlong *theArray = NULL; - char *file = NULL; - herr_t status = FAIL; + jboolean isCopy; + jstring str; + hsize_t s; + off_t o; + jsize arrLen; + jlong * theArray = NULL; + char * file = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1121,11 +1104,11 @@ Java_hdf_hdf5lib_H5_H5Pget_1external H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_external: size input array < 2"); if (name_size > 0) - if (NULL == (file = (char *) HDmalloc(sizeof(char) * (size_t)name_size))) + if (NULL == (file = (char *)HDmalloc(sizeof(char) * (size_t)name_size))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_external: memory allocation failed"); - if ((status = H5Pget_external((hid_t) plist, (unsigned)idx, (size_t)name_size, - file, (off_t *)&o, (hsize_t *)&s)) < 0) + if ((status = H5Pget_external((hid_t)plist, (unsigned)idx, (size_t)name_size, file, (off_t *)&o, + (hsize_t *)&s)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL != size) { @@ -1140,7 +1123,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1external if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, file))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_external: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_external: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); @@ -1162,8 +1146,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1external_1count - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1external_1count(JNIEnv *env, jclass clss, jlong plist) { int retVal = -1; @@ -1182,12 +1165,11 @@ done: * Signature: (JJLjava/lang/String;Ljava/lang/String;J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong vspace_id, - jstring src_file_name, jstring src_dset_name, jlong src_space_id) +Java_hdf_hdf5lib_H5_H5Pset_1virtual(JNIEnv *env, jclass clss, jlong dcpl_id, jlong vspace_id, + jstring src_file_name, jstring src_dset_name, jlong src_space_id) { - const char *fstr = NULL; - const char *dstr = NULL; + const char *fstr = NULL; + const char *dstr = NULL; herr_t retVal = FAIL; UNUSED(clss); @@ -1216,8 +1198,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count - (JNIEnv *env, jclass clss, jlong dcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count(JNIEnv *env, jclass clss, jlong dcpl_id) { size_t s = 0; @@ -1236,29 +1217,30 @@ done: * Signature: (JJ)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname(JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) { - ssize_t buf_size; - char *dname = NULL; - jstring str = NULL; + ssize_t buf_size; + char * dname = NULL; + jstring str = NULL; UNUSED(clss); /* get the length of the filename */ - if ((buf_size = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t) idx, NULL, 0)) < 0) + if ((buf_size = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)idx, NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (dname = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (dname = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_dsetname: memory allocation failed"); - if (H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t) idx, dname, (size_t)buf_size + 1) < 0) + if (H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)idx, dname, (size_t)buf_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); dname[buf_size] = '\0'; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, dname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_dsetname: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, + "H5Pget_virtual_dsetname: out of memory - unable to construct string from UTF characters"); } done: @@ -1274,29 +1256,30 @@ done: * Signature: (JJ)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename(JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) { - ssize_t buf_size; - char *fname = NULL; - jstring str = NULL; + ssize_t buf_size; + char * fname = NULL; + jstring str = NULL; UNUSED(clss); /* get the length of the filename */ - if ((buf_size = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t) idx, NULL, 0)) < 0) + if ((buf_size = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)idx, NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (fname = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (fname = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_filename: memory allocation failed"); - if (H5Pget_virtual_filename((hid_t)dcpl_id, (size_t) idx, fname, (size_t)buf_size + 1) < 0) + if (H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)idx, fname, (size_t)buf_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); fname[buf_size] = '\0'; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, fname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_filename: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, + "H5Pget_virtual_filename: out of memory - unable to construct string from UTF characters"); } done: @@ -1312,14 +1295,13 @@ done: * Signature: (JJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace(JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) { hid_t space_id = H5I_INVALID_HID; UNUSED(clss); - if ((space_id = H5Pget_virtual_srcspace((hid_t)dcpl_id, (size_t) idx)) < 0) + if ((space_id = H5Pget_virtual_srcspace((hid_t)dcpl_id, (size_t)idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1332,14 +1314,13 @@ done: * Signature: (JJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace(JNIEnv *env, jclass clss, jlong dcpl_id, jlong idx) { hid_t space_id = H5I_INVALID_HID; UNUSED(clss); - if ((space_id = H5Pget_virtual_vspace((hid_t)dcpl_id, (size_t) idx)) < 0) + if ((space_id = H5Pget_virtual_vspace((hid_t)dcpl_id, (size_t)idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1352,11 +1333,10 @@ done: * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix - (JNIEnv *env, jclass clss, jlong dapl_id, jstring prefix) +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix(JNIEnv *env, jclass clss, jlong dapl_id, jstring prefix) { const char *virtPrefix = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -1379,28 +1359,28 @@ done: * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix - (JNIEnv *env, jclass clss, jlong dapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix(JNIEnv *env, jclass clss, jlong dapl_id) { - ssize_t prefix_size = -1; - char *pre = NULL; - jstring str = NULL; + ssize_t prefix_size = -1; + char * pre = NULL; + jstring str = NULL; UNUSED(clss); if ((prefix_size = H5Pget_virtual_prefix((hid_t)dapl_id, (char *)NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t) prefix_size + 1))) + if (NULL == (pre = (char *)HDmalloc(sizeof(char) * (size_t)prefix_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_prefix: memory allocation failed"); - if (H5Pget_virtual_prefix((hid_t)dapl_id, (char *)pre, (size_t) prefix_size + 1) < 0) + if (H5Pget_virtual_prefix((hid_t)dapl_id, (char *)pre, (size_t)prefix_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); pre[prefix_size] = '\0'; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_virtual_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_virtual_prefix: out of memory - unable to construct string from UTF characters"); } done: diff --git a/java/src/jni/h5pDCPLImp.h b/java/src/jni/h5pDCPLImp.h index 6e5c225..3a6a088 100644 --- a/java/src/jni/h5pDCPLImp.h +++ b/java/src/jni/h5pDCPLImp.h @@ -25,369 +25,297 @@ extern "C" { * Method: H5Pset_layout * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1layout -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1layout(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_layout * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1layout -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1layout(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_chunk * Signature: (JI[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk -(JNIEnv *, jclass, jlong, jint, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1chunk(JNIEnv *, jclass, jlong, jint, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_chunk * Signature: (JI[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk -(JNIEnv *, jclass, jlong, jint, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1chunk(JNIEnv *, jclass, jlong, jint, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_chunk_opts * Signature: (JI)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_chunk_opts * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_dset_no_attrs_hint * Signature: (JZ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint - (JNIEnv *, jclass, jlong, jboolean); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint(JNIEnv *, jclass, jlong, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_dset_no_attrs_hint * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint - (JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_deflate * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1deflate -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1deflate(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fill_value * Signature: (JJ[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fill_1value -(JNIEnv *, jclass, jlong, jlong, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fill_1value(JNIEnv *, jclass, jlong, jlong, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_fill_value * Signature: (JJ[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fill_1value -(JNIEnv *, jclass, jlong, jlong, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fill_1value(JNIEnv *, jclass, jlong, jlong, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pfill_value_defined * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fill_time * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fill_1time -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fill_1time(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_fill_time * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fill_1time -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fill_1time(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_alloc_time * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_alloc_time * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_filter * Signature: (JIIJ[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1filter -(JNIEnv *, jclass, jlong, jint, jint, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1filter(JNIEnv *, jclass, jlong, jint, jint, jlong, + jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pall_filters_avail * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail -(JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_nfilters * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nfilters -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1nfilters(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_filter * Signature: (JI[I[J[IJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter -(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1filter(JNIEnv *, jclass, jlong, jint, jintArray, + jlongArray, jintArray, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_filter2 * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter2 -(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1filter2(JNIEnv *, jclass, jlong, jint, jintArray, + jlongArray, jintArray, jlong, jobjectArray, + jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_filter_by_id * Signature: (JI[I[J[IJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id -(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id(JNIEnv *, jclass, jlong, jint, jintArray, + jlongArray, jintArray, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_filter_by_id2 * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 -(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2(JNIEnv *, jclass, jlong, jint, jintArray, + jlongArray, jintArray, jlong, jobjectArray, + jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pmodify_filter * Signature: (JIIJ[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pmodify_1filter -(JNIEnv *, jclass, jlong, jint, jint, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pmodify_1filter(JNIEnv *, jclass, jlong, jint, jint, jlong, + jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Premove_filter * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5P1remove_1filter -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5P1remove_1filter(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fletcher32 * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fletcher32(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_nbit * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1nbit -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1nbit(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_scaleoffset * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_shuffle * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shuffle -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1shuffle(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_szip * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1szip -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1szip(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_external * Signature: (JLjava/lang/String;JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1external -(JNIEnv *, jclass, jlong, jstring, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1external(JNIEnv *, jclass, jlong, jstring, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_external * Signature: (JIJ[Ljava/lang/String;[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1external -(JNIEnv *, jclass, jlong, jint, jlong, jobjectArray, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1external(JNIEnv *, jclass, jlong, jint, jlong, + jobjectArray, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_external_count * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1external_1count -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1external_1count(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_virtual * Signature: (JJLjava/lang/String;Ljava/lang/String;J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual -(JNIEnv *, jclass, jlong, jlong, jstring, jstring, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1virtual(JNIEnv *, jclass, jlong, jlong, jstring, jstring, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_virtual_count * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_virtual_dsetname * Signature: (JJ)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_virtual_filename * Signature: (JJ)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_virtual_srcspace * Signature: (JJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_virtual_vspace * Signature: (JJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_virtual_prefix * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_virtual_prefix * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix -(JNIEnv *, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pDXPLImp.c b/java/src/jni/h5pDXPLImp.c index 12e3367..f7f9f96 100644 --- a/java/src/jni/h5pDXPLImp.c +++ b/java/src/jni/h5pDXPLImp.c @@ -37,15 +37,15 @@ extern "C" { * Signature: (JJ[B[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1buffer - (JNIEnv *env, jclass clss, jlong plist, jlong size, jbyteArray tconv, jbyteArray bkg) +Java_hdf_hdf5lib_H5_H5Pset_1buffer(JNIEnv *env, jclass clss, jlong plist, jlong size, jbyteArray tconv, + jbyteArray bkg) { #ifdef notdef - jboolean isCopy; - jbyte *tconvP = NULL; - jbyte *bkgP = NULL; + jboolean isCopy; + jbyte * tconvP = NULL; + jbyte * bkgP = NULL; #endif - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); #ifndef notdef @@ -85,15 +85,14 @@ done: * Signature: (J[B[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1buffer - (JNIEnv *env, jclass clss, jlong plist, jbyteArray tconv, jbyteArray bkg) +Java_hdf_hdf5lib_H5_H5Pget_1buffer(JNIEnv *env, jclass clss, jlong plist, jbyteArray tconv, jbyteArray bkg) { #ifdef notdef - jboolean isCopy; - jbyte *tconvP = NULL; - jbyte *bkgP = NULL; + jboolean isCopy; + jbyte * tconvP = NULL; + jbyte * bkgP = NULL; #endif - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); #ifndef notdef @@ -135,8 +134,7 @@ done: * Signature: (JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size - (JNIEnv *env, jclass clss, jlong plist, jlong size) +Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size(JNIEnv *env, jclass clss, jlong plist, jlong size) { UNUSED(clss); @@ -153,8 +151,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size(JNIEnv *env, jclass clss, jlong plist) { size_t size = 0; @@ -173,10 +170,9 @@ done: * Signature: (JZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1preserve - (JNIEnv *env, jclass clss, jlong plist, jboolean status) +Java_hdf_hdf5lib_H5_H5Pset_1preserve(JNIEnv *env, jclass clss, jlong plist, jboolean status) { - hbool_t st = JNI_FALSE; + hbool_t st = JNI_FALSE; herr_t retVal = FAIL; UNUSED(clss); @@ -201,8 +197,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1preserve - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1preserve(JNIEnv *env, jclass clss, jlong plist) { herr_t retVal = FAIL; @@ -221,8 +216,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1edc_1check - (JNIEnv *env, jclass clss, jlong plist, jint check) +Java_hdf_hdf5lib_H5_H5Pset_1edc_1check(JNIEnv *env, jclass clss, jlong plist, jint check) { herr_t retVal = FAIL; @@ -241,8 +235,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1edc_1check - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1edc_1check(JNIEnv *env, jclass clss, jlong plist) { H5Z_EDC_t retVal = -1; @@ -265,18 +258,18 @@ done: * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1data_1transform - (JNIEnv *env, jclass clss, jlong plist_id, jstring expression) +Java_hdf_hdf5lib_H5_H5Pset_1data_1transform(JNIEnv *env, jclass clss, jlong plist_id, jstring expression) { const char *express = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); if (NULL == expression) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_data_transform: data transform expression is NULL"); - PIN_JAVA_STRING(ENVONLY, expression, express, NULL, "H5Pset_data_transform: data transform expression not pinned"); + PIN_JAVA_STRING(ENVONLY, expression, express, NULL, + "H5Pset_data_transform: data transform expression not pinned"); if ((retVal = H5Pset_data_transform((hid_t)plist_id, express)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -294,12 +287,12 @@ done: * Signature: (J[Ljava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1data_1transform - (JNIEnv *env, jclass clss, jlong plist_id, jobjectArray expression, jlong size) +Java_hdf_hdf5lib_H5_H5Pget_1data_1transform(JNIEnv *env, jclass clss, jlong plist_id, jobjectArray expression, + jlong size) { - jstring str = NULL; - char *express = NULL; - ssize_t express_size = -1; + jstring str = NULL; + char * express = NULL; + ssize_t express_size = -1; UNUSED(clss); @@ -309,7 +302,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1data_1transform if ((express_size = H5Pget_data_transform((hid_t)plist_id, (char *)NULL, (size_t)size)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (express = (char *) HDmalloc(sizeof(char) * (size_t)express_size + 1))) + if (NULL == (express = (char *)HDmalloc(sizeof(char) * (size_t)express_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_data_transform: memory allocation failed"); if (H5Pget_data_transform((hid_t)plist_id, express, (size_t)express_size + 1) < 0) @@ -318,7 +311,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1data_1transform if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, express))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_data_transform: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_data_transform: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, expression, 0, str); @@ -345,8 +339,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size - (JNIEnv *env, jclass clss, jlong plist, jlong vector_size) +Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size(JNIEnv *env, jclass clss, jlong plist, jlong vector_size) { herr_t retVal = FAIL; @@ -365,22 +358,22 @@ done: * Signature: (J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size - (JNIEnv *env, jclass clss, jlong plist, jlongArray vector_size) +Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size(JNIEnv *env, jclass clss, jlong plist, jlongArray vector_size) { - jboolean isCopy; - size_t size; - jlong *theArray = NULL; - herr_t retVal = FAIL; + jboolean isCopy; + size_t size; + jlong * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); if (NULL == vector_size) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_hyper_vector_size: vector_size is NULL"); - PIN_LONG_ARRAY(ENVONLY, vector_size, theArray, &isCopy, "H5Pget_hyper_vector_size: vector_size not pinned"); + PIN_LONG_ARRAY(ENVONLY, vector_size, theArray, &isCopy, + "H5Pget_hyper_vector_size: vector_size not pinned"); - if ((retVal = H5Pget_hyper_vector_size((hid_t)plist, &size)) < 0) + if ((retVal = H5Pget_hyper_vector_size((hid_t)plist, &size)) < 0) H5_LIBRARY_ERROR(ENVONLY); theArray[0] = (jlong)size; @@ -398,14 +391,14 @@ done: * Signature: (JDDD)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios - (JNIEnv *env, jclass clss, jlong plist_id, jdouble left, jdouble middle, jdouble right) +Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios(JNIEnv *env, jclass clss, jlong plist_id, jdouble left, + jdouble middle, jdouble right) { herr_t status = FAIL; UNUSED(clss); - if ((status = H5Pset_btree_ratios((hid_t)plist_id, (double)left,(double)middle, (double)right)) < 0) + if ((status = H5Pset_btree_ratios((hid_t)plist_id, (double)left, (double)middle, (double)right)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -418,15 +411,14 @@ done: * Signature: (J[D[D[D)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios - (JNIEnv *env, jclass clss, jlong plist_id, jdoubleArray left, - jdoubleArray middle, jdoubleArray right) +Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios(JNIEnv *env, jclass clss, jlong plist_id, jdoubleArray left, + jdoubleArray middle, jdoubleArray right) { - jboolean isCopy; - jdouble *leftP = NULL; - jdouble *middleP = NULL; - jdouble *rightP = NULL; - herr_t status = FAIL; + jboolean isCopy; + jdouble *leftP = NULL; + jdouble *middleP = NULL; + jdouble *rightP = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -441,8 +433,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios PIN_DOUBLE_ARRAY(ENVONLY, middle, middleP, &isCopy, "H5Pget_btree_ratios: middle array not pinned"); PIN_DOUBLE_ARRAY(ENVONLY, right, rightP, &isCopy, "H5Pget_btree_ratios: right array not pinned"); - if ((status = H5Pget_btree_ratios((hid_t)plist_id, (double *)leftP, - (double *)middleP, (double *)rightP)) < 0) + if ((status = + H5Pget_btree_ratios((hid_t)plist_id, (double *)leftP, (double *)middleP, (double *)rightP)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: diff --git a/java/src/jni/h5pDXPLImp.h b/java/src/jni/h5pDXPLImp.h index d62f9c5..9793ce7 100644 --- a/java/src/jni/h5pDXPLImp.h +++ b/java/src/jni/h5pDXPLImp.h @@ -25,72 +25,57 @@ extern "C" { * Method: H5Pset_buffer * Signature: (JJ[B[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1buffer -(JNIEnv *, jclass, jlong, jlong, jbyteArray, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1buffer(JNIEnv *, jclass, jlong, jlong, jbyteArray, + jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_buffer * Signature: (J[B[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1buffer -(JNIEnv *, jclass, jlong, jbyteArray, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1buffer(JNIEnv *, jclass, jlong, jbyteArray, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_buffer_size * Signature: (JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_buffer_size * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_preserve * Signature: (JZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1preserve -(JNIEnv *, jclass, jlong, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1preserve(JNIEnv *, jclass, jlong, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_preserve * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1preserve -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1preserve(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_edc_check * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1edc_1check -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1edc_1check(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_edc_check * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1edc_1check -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1edc_1check(JNIEnv *, jclass, jlong); /* * TODO: H5Pset_filter_callback @@ -101,18 +86,15 @@ Java_hdf_hdf5lib_H5_H5Pget_1edc_1check * Method: H5Pset_data_transform * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1data_1transform -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1data_1transform(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_data_transform * Signature: (J[Ljava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1data_1transform -(JNIEnv *, jclass, jlong, jobjectArray, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1data_1transform(JNIEnv *, jclass, jlong, jobjectArray, + jlong); /* * TODO: H5Pset_type_conv_cb @@ -127,36 +109,30 @@ Java_hdf_hdf5lib_H5_H5Pget_1data_1transform * Method: H5Pset_hyper_vector_size * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_hyper_vector_size * Signature: (J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size -(JNIEnv *, jclass, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_btree_ratios * Signature: (JDDD)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios -(JNIEnv *, jclass, jlong, jdouble, jdouble, jdouble); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios(JNIEnv *, jclass, jlong, jdouble, jdouble, + jdouble); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_btree_ratios * Signature: (J[D[D[D)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios -(JNIEnv *, jclass, jlong, jdoubleArray, jdoubleArray, jdoubleArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios(JNIEnv *, jclass, jlong, jdoubleArray, + jdoubleArray, jdoubleArray); /* * TODO: H5Pset_vlen_mem_manager diff --git a/java/src/jni/h5pFAPLImp.c b/java/src/jni/h5pFAPLImp.c index 9ae8775..bbeddaf 100644 --- a/java/src/jni/h5pFAPLImp.c +++ b/java/src/jni/h5pFAPLImp.c @@ -42,14 +42,13 @@ extern "C" { * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1driver - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1driver(JNIEnv *env, jclass clss, jlong plist) { hid_t retVal = H5I_INVALID_HID; UNUSED(clss); - if ((retVal = H5Pget_driver((hid_t) plist)) < 0) + if ((retVal = H5Pget_driver((hid_t)plist)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -66,8 +65,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree - (JNIEnv *env, jclass clss, jlong plist, jint fc_degree) +Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree(JNIEnv *env, jclass clss, jlong plist, jint fc_degree) { herr_t retVal = FAIL; @@ -86,8 +84,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree(JNIEnv *env, jclass clss, jlong plist) { H5F_close_degree_t degree = H5F_CLOSE_DEFAULT; @@ -106,8 +103,8 @@ done: * Signature: (JJZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core - (JNIEnv *env, jclass clss, jlong fapl_id, jlong increment, jboolean backing_store) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core(JNIEnv *env, jclass clss, jlong fapl_id, jlong increment, + jboolean backing_store) { herr_t retVal = FAIL; @@ -126,13 +123,13 @@ done: * Signature: (J[J[Z)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core - (JNIEnv *env, jclass clss, jlong fapl_id, jlongArray increment, jbooleanArray backing_store) +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core(JNIEnv *env, jclass clss, jlong fapl_id, jlongArray increment, + jbooleanArray backing_store) { jboolean isCopy; jboolean *backArray = NULL; - jlong *incArray = NULL; - herr_t status = FAIL; + jlong * incArray = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -147,7 +144,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core { /* Direct cast (size_t *)variable fails on 32-bit environment */ long long inc_temp = *incArray; - size_t inc_t = (size_t) inc_temp; + size_t inc_t = (size_t)inc_temp; if ((status = H5Pget_fapl_core((hid_t)fapl_id, &inc_t, (hbool_t *)backArray)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -178,16 +175,16 @@ done: * Signature: (JJJJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct - (JNIEnv *env, jclass clss, jlong fapl_id, jlong alignment, - jlong block_size, jlong cbuf_size) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct(JNIEnv *env, jclass clss, jlong fapl_id, jlong alignment, + jlong block_size, jlong cbuf_size) { herr_t retVal = FAIL; UNUSED(clss); #ifdef H5_HAVE_DIRECT - if ((retVal = H5Pset_fapl_direct((hid_t)fapl_id, (size_t)alignment, (size_t)block_size, (size_t)cbuf_size)) < 0) + if ((retVal = H5Pset_fapl_direct((hid_t)fapl_id, (size_t)alignment, (size_t)block_size, + (size_t)cbuf_size)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -208,18 +205,17 @@ done: * Signature: (J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct - (JNIEnv *env, jclass clss, jlong fapl_id, jlongArray info) +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct(JNIEnv *env, jclass clss, jlong fapl_id, jlongArray info) { #ifdef H5_HAVE_DIRECT - jboolean isCopy; - jlong *theArray = NULL; - size_t alignment = 0; - size_t block_size = 0; - size_t cbuf_size = 0; - jsize arrLen; + jboolean isCopy; + jlong * theArray = NULL; + size_t alignment = 0; + size_t block_size = 0; + size_t cbuf_size = 0; + jsize arrLen; #endif - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -261,10 +257,10 @@ done: * Signature: (JJJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family - (JNIEnv *env, jclass clss, jlong plist, jlong memb_size, jlong memb_plist) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family(JNIEnv *env, jclass clss, jlong plist, jlong memb_size, + jlong memb_plist) { - long ms = (long)memb_size; + long ms = (long)memb_size; herr_t retVal = FAIL; UNUSED(clss); @@ -282,16 +278,16 @@ done: * Signature: (J[J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family - (JNIEnv *env, jclass clss, jlong tid, jlongArray memb_size, jlongArray memb_plist) +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family(JNIEnv *env, jclass clss, jlong tid, jlongArray memb_size, + jlongArray memb_plist) { - jboolean isCopy; - hsize_t *sa = NULL; - size_t i; - jlong *sizeArray = NULL; - jlong *plistArray = NULL; - jsize rank; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *sa = NULL; + size_t i; + jlong * sizeArray = NULL; + jlong * plistArray = NULL; + jsize rank; + herr_t status = FAIL; UNUSED(clss); @@ -307,7 +303,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_family: memb_size array length < 0"); } - if (NULL == (sa = (hsize_t *) HDmalloc((size_t) rank * sizeof(hsize_t)))) + if (NULL == (sa = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_family: memory allocation failed"); PIN_LONG_ARRAY(ENVONLY, memb_plist, plistArray, &isCopy, "H5Pget_family: plistArray not pinned"); @@ -315,7 +311,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family if ((status = H5Pget_fapl_family((hid_t)tid, sa, (hid_t *)plistArray)) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0; i < (size_t) rank; i++) + for (i = 0; i < (size_t)rank; i++) sizeArray[i] = (jlong)sa[i]; done: @@ -335,8 +331,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1family_1offset - (JNIEnv *env, jclass clss, jlong fapl_id, jlong offset) +Java_hdf_hdf5lib_H5_H5Pset_1family_1offset(JNIEnv *env, jclass clss, jlong fapl_id, jlong offset) { herr_t retVal = FAIL; @@ -355,8 +350,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1family_1offset - (JNIEnv *env, jclass clss, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1family_1offset(JNIEnv *env, jclass clss, jlong fapl_id) { hsize_t offset = 0; herr_t retVal = FAIL; @@ -375,8 +369,7 @@ done: * Signature: (J)Lhdf/hdf5lib/structs/H5FD_hdfs_fapl_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs - (JNIEnv *env, jclass clss, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs(JNIEnv *env, jclass clss, jlong fapl_id) { #ifdef H5_HAVE_LIBHDFS H5FD_hdfs_fapl_t fa; @@ -387,7 +380,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs jstring j_kerb_cache_path = NULL; jint j_stream_buffer_size = 0; #endif /* H5_HAVE_LIBHDFS */ - jobject ret_obj = NULL; + jobject ret_obj = NULL; UNUSED(clss); @@ -397,7 +390,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs if (NULL == (j_namenode_name = ENVPTR->NewStringUTF(ENVONLY, fa.namenode_name))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create namenode_name string"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5Pget_fapl_hdfs: out of memory - can't create namenode_name string"); } args[0].l = j_namenode_name; @@ -411,13 +405,15 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs if (NULL == (j_kerb_cache_path = ENVPTR->NewStringUTF(ENVONLY, fa.kerberos_ticket_cache))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_hdfs: out of memory - can't create kerberos_ticket_cache string"); + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5Pget_fapl_hdfs: out of memory - can't create kerberos_ticket_cache string"); } args[3].l = j_kerb_cache_path; args[4].i = (jint)fa.stream_buffer_size; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_hdfs_fapl_t", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_hdfs_fapl_t", + "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;I)V", args, ret_obj); #else UNUSED(fapl_id); @@ -434,15 +430,14 @@ done: * Signature: (JLhdf/hdf5lib/structs/H5FD_hdfs_fapl_t;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1hdfs - (JNIEnv *env, jclass clss, jlong fapl_id, jobject fapl_config) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1hdfs(JNIEnv *env, jclass clss, jlong fapl_id, jobject fapl_config) { #ifdef H5_HAVE_LIBHDFS - H5FD_hdfs_fapl_t instance; - const char *str = NULL; - jfieldID fid; - jstring j_str; - jclass cls; + H5FD_hdfs_fapl_t instance; + const char * str = NULL; + jfieldID fid; + jstring j_str; + jclass cls; #endif /* H5_HAVE_LIBHDFS */ UNUSED(clss); @@ -508,7 +503,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1hdfs CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if (j_str) { - PIN_JAVA_STRING(ENVONLY, j_str, str, NULL, "H5FDset_fapl_hdfs: fapl_config kerberos_ticket_cache not pinned"); + PIN_JAVA_STRING(ENVONLY, j_str, str, NULL, + "H5FDset_fapl_hdfs: fapl_config kerberos_ticket_cache not pinned"); HDstrncpy(instance.kerberos_ticket_cache, str, H5FD__HDFS_KERB_CACHE_PATH_SPACE + 1); instance.kerberos_ticket_cache[H5FD__HDFS_KERB_CACHE_PATH_SPACE] = '\0'; @@ -526,7 +522,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1hdfs CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if (H5Pset_fapl_hdfs((hid_t)fapl_id, &instance) < 0) - H5_LIBRARY_ERROR(ENVONLY); + H5_LIBRARY_ERROR(ENVONLY); #else UNUSED(fapl_id); UNUSED(fapl_config); @@ -548,11 +544,11 @@ done: * Signature: (JLjava/lang/String;JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log - (JNIEnv *env, jclass clss, jlong fapl_id, jstring logfile, jlong flags, jlong buf_size) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log(JNIEnv *env, jclass clss, jlong fapl_id, jstring logfile, jlong flags, + jlong buf_size) { const char *pLogfile = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -591,24 +587,24 @@ done: * Signature: (J[I[J[Ljava/lang/String;[JZ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi - (JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, - jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr, jboolean relax) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi(JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, + jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr, + jboolean relax) { - const char * const *mName = NULL; - const char *utf8 = NULL; - jboolean isCopy; - jboolean bb; - jobject o; - jstring rstring; - jstring obj; - jclass Sjc; - size_t i; - jlong *thefaplArray = NULL; - jlong *theaddrArray = NULL; - jint *themapArray = NULL; - char *member_name[H5FD_MEM_NTYPES]; - herr_t status = FAIL; + const char *const *mName = NULL; + const char * utf8 = NULL; + jboolean isCopy; + jboolean bb; + jobject o; + jstring rstring; + jstring obj; + jclass Sjc; + size_t i; + jlong * thefaplArray = NULL; + jlong * theaddrArray = NULL; + jint * themapArray = NULL; + char * member_name[H5FD_MEM_NTYPES]; + herr_t status = FAIL; UNUSED(clss); @@ -625,7 +621,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi for (i = 0; i < H5FD_MEM_NTYPES; i++) { size_t str_len; - if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray) memb_name, (jsize) i))) { + if (NULL == + (obj = (jstring)ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)memb_name, (jsize)i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* @@ -644,7 +641,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi str_len = HDstrlen(utf8); - if (NULL == (member_name[i] = (char *) HDmalloc(str_len + 1))) + if (NULL == (member_name[i] = (char *)HDmalloc(str_len + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_fapl_multi: memory allocation failed"); HDstrncpy(member_name[i], utf8, str_len + 1); @@ -656,11 +653,11 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi ENVPTR->DeleteLocalRef(ENVONLY, obj); } - mName = (const char * const *)member_name; + mName = (const char *const *)member_name; } if ((status = H5Pset_fapl_multi((hid_t)tid, (const H5FD_mem_t *)themapArray, (const hid_t *)thefaplArray, - mName, (const haddr_t *)theaddrArray, (hbool_t)relax)) < 0) + mName, (const haddr_t *)theaddrArray, (hbool_t)relax)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (memb_name && mName) { @@ -668,14 +665,17 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); for (i = 0; i < H5FD_MEM_NTYPES; i++) { - if (!member_name[i]) continue; + if (!member_name[i]) + continue; if (NULL == (rstring = ENVPTR->NewStringUTF(ENVONLY, member_name[i]))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, + "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); } - if (NULL == (o = ENVPTR->GetObjectArrayElement(ENVONLY, memb_name, (jsize) i))) { + if (NULL == (o = ENVPTR->GetObjectArrayElement(ENVONLY, memb_name, (jsize)i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* @@ -686,7 +686,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi } if (JNI_TRUE == (bb = ENVPTR->IsInstanceOf(ENVONLY, o, Sjc))) { - ENVPTR->SetObjectArrayElement(ENVONLY, memb_name, (jsize) i, (jobject)rstring); + ENVPTR->SetObjectArrayElement(ENVONLY, memb_name, (jsize)i, (jobject)rstring); CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } @@ -719,20 +719,19 @@ done: * Signature: (J[I[J[Ljava/lang/String;[J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi - (JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, - jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr) +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi(JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, + jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr) { - jboolean isCopy; - jstring str; - herr_t status = FAIL; - size_t i; - jlong *thefaplArray = NULL; - jlong *theaddrArray = NULL; - jint *themapArray = NULL; - char **mName = NULL; - int relax = 0; - int retVal = 0; + jboolean isCopy; + jstring str; + herr_t status = FAIL; + size_t i; + jlong * thefaplArray = NULL; + jlong * theaddrArray = NULL; + jint * themapArray = NULL; + char ** mName = NULL; + int relax = 0; + int retVal = 0; UNUSED(clss); @@ -743,11 +742,11 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi if (memb_addr) PIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, &isCopy, "H5Pget_fapl_multi: memb_addr not pinned"); if (memb_name) - if (NULL == (mName = (char **) HDcalloc(H5FD_MEM_NTYPES, sizeof(*mName)))) + if (NULL == (mName = (char **)HDcalloc(H5FD_MEM_NTYPES, sizeof(*mName)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_multi: memory allocation failed"); - if ((status = H5Pget_fapl_multi((hid_t)tid, (H5FD_mem_t *)themapArray, (hid_t *)thefaplArray, - mName, (haddr_t *)theaddrArray, (hbool_t *)&relax)) < 0) + if ((status = H5Pget_fapl_multi((hid_t)tid, (H5FD_mem_t *)themapArray, (hid_t *)thefaplArray, mName, + (haddr_t *)theaddrArray, (hbool_t *)&relax)) < 0) H5_LIBRARY_ERROR(ENVONLY); if (memb_name && mName) { @@ -755,10 +754,12 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi if (mName[i]) { if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, mName[i]))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_fapl_multi: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, + "H5Pget_fapl_multi: out of memory - unable to construct string from UTF characters"); } - ENVPTR->SetObjectArrayElement(ENVONLY, memb_name, (jsize) i, (jobject)str); + ENVPTR->SetObjectArrayElement(ENVONLY, memb_name, (jsize)i, (jobject)str); CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); ENVPTR->DeleteLocalRef(ENVONLY, str); @@ -794,17 +795,16 @@ done: * Signature: (J)Lhdf/hdf5lib/structs/H5FD_ros3_fapl_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3 - (JNIEnv *env, jclass clss, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3(JNIEnv *env, jclass clss, jlong fapl_id) { #ifdef H5_HAVE_ROS3_VFD H5FD_ros3_fapl_t fa; jvalue args[3]; - jstring j_aws = NULL; - jstring j_id = NULL; - jstring j_key = NULL; + jstring j_aws = NULL; + jstring j_id = NULL; + jstring j_key = NULL; #endif /* H5_HAVE_ROS3_VFD */ - jobject ret_obj = NULL; + jobject ret_obj = NULL; UNUSED(clss); @@ -832,7 +832,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3 } args[2].l = j_key; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_ros3_fapl_t", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5FD_ros3_fapl_t", + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args, ret_obj); #else UNUSED(fapl_id); @@ -849,15 +850,14 @@ done: * Signature: (JLhdf/hdf5lib/structs/H5FD_ros3_fapl_t;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1ros3 - (JNIEnv *env, jclass clss, jlong fapl_id, jobject fapl_config) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1ros3(JNIEnv *env, jclass clss, jlong fapl_id, jobject fapl_config) { #ifdef H5_HAVE_ROS3_VFD - H5FD_ros3_fapl_t instance; - const char *str = NULL; - jfieldID fid; - jstring j_str; - jclass cls; + H5FD_ros3_fapl_t instance; + const char * str = NULL; + jfieldID fid; + jstring j_str; + jclass cls; #endif /* H5_HAVE_ROS3_VFD */ UNUSED(clss); @@ -928,7 +928,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1ros3 else HDmemset(instance.secret_key, 0, H5FD_ROS3_MAX_SECRET_KEY_LEN + 1); - if (instance.aws_region[0] != '\0' && instance.secret_id[0] !='\0' && instance.secret_key[0] !='\0') + if (instance.aws_region[0] != '\0' && instance.secret_id[0] != '\0' && instance.secret_key[0] != '\0') instance.authenticate = TRUE; if (H5Pset_fapl_ros3((hid_t)fapl_id, &instance) < 0) @@ -954,11 +954,11 @@ done: * Signature: (JLjava/lang/String;JLjava/lang/String;J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split - (JNIEnv *env, jclass clss, jlong fapl_id, jstring metaext, jlong meta_pl_id, jstring rawext, jlong raw_pl_id) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split(JNIEnv *env, jclass clss, jlong fapl_id, jstring metaext, + jlong meta_pl_id, jstring rawext, jlong raw_pl_id) { - const char *mstr = NULL; - const char *rstr = NULL; + const char *mstr = NULL; + const char *rstr = NULL; herr_t retVal = FAIL; UNUSED(clss); @@ -987,14 +987,13 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 - (JNIEnv *env, jclass clss, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2(JNIEnv *env, jclass clss, jlong fapl_id) { herr_t retVal = FAIL; UNUSED(clss); - if ((retVal = H5Pset_fapl_sec2((hid_t) fapl_id)) < 0) + if ((retVal = H5Pset_fapl_sec2((hid_t)fapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1007,14 +1006,13 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio - (JNIEnv *env, jclass clss, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio(JNIEnv *env, jclass clss, jlong fapl_id) { herr_t retVal = FAIL; UNUSED(clss); - if ((retVal = H5Pset_fapl_stdio((hid_t) fapl_id)) < 0) + if ((retVal = H5Pset_fapl_stdio((hid_t)fapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1027,15 +1025,14 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows - (JNIEnv *env, jclass clss, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows(JNIEnv *env, jclass clss, jlong fapl_id) { herr_t retVal = FAIL; UNUSED(clss); #ifdef H5_HAVE_WINDOWS - if ((retVal = H5Pset_fapl_windows((hid_t) fapl_id)) < 0) + if ((retVal = H5Pset_fapl_windows((hid_t)fapl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1068,8 +1065,7 @@ done: * Signature: (JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size - (JNIEnv *env, jclass clss, jlong plist, jlong size) +Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size(JNIEnv *env, jclass clss, jlong plist, jlong size) { long sz = (long)size; @@ -1088,8 +1084,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size(JNIEnv *env, jclass clss, jlong plist) { hsize_t s = 0; @@ -1116,8 +1111,7 @@ done: * Signature: (JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size - (JNIEnv *env, jclass clss, jlong plist, jlong size) +Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size(JNIEnv *env, jclass clss, jlong plist, jlong size) { size_t sz = (size_t)size; @@ -1136,8 +1130,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size(JNIEnv *env, jclass clss, jlong plist) { size_t s = 0; @@ -1156,11 +1149,10 @@ done: * Signature: (JJJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1alignment - (JNIEnv *env, jclass clss, jlong plist, jlong threshold, jlong alignment) +Java_hdf_hdf5lib_H5_H5Pset_1alignment(JNIEnv *env, jclass clss, jlong plist, jlong threshold, jlong alignment) { - long thr = (long)threshold; - long align = (long)alignment; + long thr = (long)threshold; + long align = (long)alignment; herr_t retVal = FAIL; UNUSED(clss); @@ -1178,15 +1170,14 @@ done: * Signature: (J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1alignment - (JNIEnv *env, jclass clss, jlong plist, jlongArray alignment) +Java_hdf_hdf5lib_H5_H5Pget_1alignment(JNIEnv *env, jclass clss, jlong plist, jlongArray alignment) { - jboolean isCopy; - hsize_t t = 0; - hsize_t a = 0; - jsize arrLen; - jlong *theArray = NULL; - herr_t status = FAIL; + jboolean isCopy; + hsize_t t = 0; + hsize_t a = 0; + jsize arrLen; + jlong * theArray = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1221,16 +1212,15 @@ done: * Signature: (JIJJD)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1cache - (JNIEnv *env, jclass clss, jlong plist, jint mdc_nelmts, jlong rdcc_nelmts, - jlong rdcc_nbytes, jdouble rdcc_w0) +Java_hdf_hdf5lib_H5_H5Pset_1cache(JNIEnv *env, jclass clss, jlong plist, jint mdc_nelmts, jlong rdcc_nelmts, + jlong rdcc_nbytes, jdouble rdcc_w0) { herr_t retVal = FAIL; UNUSED(clss); - if ((retVal = H5Pset_cache((hid_t)plist, (int)mdc_nelmts, (size_t)rdcc_nelmts, - (size_t)rdcc_nbytes, (double) rdcc_w0)) < 0) + if ((retVal = H5Pset_cache((hid_t)plist, (int)mdc_nelmts, (size_t)rdcc_nelmts, (size_t)rdcc_nbytes, + (double)rdcc_w0)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1243,15 +1233,14 @@ done: * Signature: (J[I[J[J[D)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1cache - (JNIEnv *env, jclass clss, jlong plist, jintArray mdc_nelmts, - jlongArray rdcc_nelmts, jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) +Java_hdf_hdf5lib_H5_H5Pget_1cache(JNIEnv *env, jclass clss, jlong plist, jintArray mdc_nelmts, + jlongArray rdcc_nelmts, jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) { - jboolean isCopy; - jdouble *w0Array = NULL; - jlong *rdcc_nelmtsArray = NULL; - jlong *nbytesArray = NULL; - herr_t status = FAIL; + jboolean isCopy; + jdouble *w0Array = NULL; + jlong * rdcc_nelmtsArray = NULL; + jlong * nbytesArray = NULL; + herr_t status = FAIL; UNUSED(clss); UNUSED(mdc_nelmts); @@ -1259,23 +1248,25 @@ Java_hdf_hdf5lib_H5_H5Pget_1cache if (NULL != rdcc_w0) PIN_DOUBLE_ARRAY(ENVONLY, rdcc_w0, w0Array, &isCopy, "H5Pget_cache: rdcc_w0 array not pinned"); if (NULL != rdcc_nelmts) - PIN_LONG_ARRAY(ENVONLY, rdcc_nelmts, rdcc_nelmtsArray, &isCopy, "H5Pget_cache: rdcc_nelmts array not pinned"); + PIN_LONG_ARRAY(ENVONLY, rdcc_nelmts, rdcc_nelmtsArray, &isCopy, + "H5Pget_cache: rdcc_nelmts array not pinned"); if (NULL != rdcc_nbytes) - PIN_LONG_ARRAY(ENVONLY, rdcc_nbytes, nbytesArray, &isCopy, "H5Pget_cache: nbytesArray array not pinned"); + PIN_LONG_ARRAY(ENVONLY, rdcc_nbytes, nbytesArray, &isCopy, + "H5Pget_cache: nbytesArray array not pinned"); { /* direct cast (size_t *)variable fails on 32-bit environment */ long long rdcc_nelmts_temp = *rdcc_nelmtsArray; - long long nbytes_temp = *nbytesArray; - size_t rdcc_nelmts_t = (size_t) rdcc_nelmts_temp; - size_t nbytes_t = (size_t) nbytes_temp; + long long nbytes_temp = *nbytesArray; + size_t rdcc_nelmts_t = (size_t)rdcc_nelmts_temp; + size_t nbytes_t = (size_t)nbytes_temp; - if ((status = H5Pget_cache((hid_t)plist, (int *)NULL, &rdcc_nelmts_t, - &nbytes_t, (double *)w0Array)) < 0) + if ((status = H5Pget_cache((hid_t)plist, (int *)NULL, &rdcc_nelmts_t, &nbytes_t, (double *)w0Array)) < + 0) H5_LIBRARY_ERROR(ENVONLY); *rdcc_nelmtsArray = (jlong)rdcc_nelmts_t; - *nbytesArray = (jlong)nbytes_t; + *nbytesArray = (jlong)nbytes_t; } /* end direct cast special */ done: @@ -1295,8 +1286,7 @@ done: * Signature: (JI)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size - (JNIEnv *env, jclass clss, jlong plist, jint size) +Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size(JNIEnv *env, jclass clss, jlong plist, jint size) { unsigned sz = (unsigned)size; @@ -1315,8 +1305,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size(JNIEnv *env, jclass clss, jlong plist) { unsigned s = 0; @@ -1335,11 +1324,10 @@ done: * Signature: (JZ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close - (JNIEnv *env, jclass clss, jlong fapl_id, jboolean evict_on_close) +Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close(JNIEnv *env, jclass clss, jlong fapl_id, jboolean evict_on_close) { hbool_t evict_on_close_val = FALSE; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -1358,11 +1346,10 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close - (JNIEnv *env, jclass clss, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close(JNIEnv *env, jclass clss, jlong fapl_id) { hbool_t evict_on_close_val = FALSE; - jboolean bval = JNI_FALSE; + jboolean bval = JNI_FALSE; UNUSED(clss); @@ -1381,8 +1368,7 @@ done: * Signature: (JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts - (JNIEnv *env, jclass clss, jlong plist_id, jlong attempts) +Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts(JNIEnv *env, jclass clss, jlong plist_id, jlong attempts) { UNUSED(clss); @@ -1402,8 +1388,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts - (JNIEnv *env, jclass clss, jlong plist_id) +Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts(JNIEnv *env, jclass clss, jlong plist_id) { unsigned attempts = 0; @@ -1413,7 +1398,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts H5_LIBRARY_ERROR(ENVONLY); done: - return (jlong) attempts; + return (jlong)attempts; } /* end Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts */ /* @@ -1422,18 +1407,17 @@ done: * Signature: (JLhdf/hdf5lib/structs/H5AC_cache_config_t;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config - (JNIEnv *env, jclass clss, jlong plist, jobject cache_config) +Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config(JNIEnv *env, jclass clss, jlong plist, jobject cache_config) { - H5AC_cache_config_t cacheinfo; - const char *str = NULL; - jfieldID fid; - jstring j_str; - jclass cls; - jint flash_incr_mode; - jint incr_mode; - jint decr_mode; - herr_t status = FAIL; + H5AC_cache_config_t cacheinfo; + const char * str = NULL; + jfieldID fid; + jstring j_str; + jclass cls; + jint flash_incr_mode; + jint incr_mode; + jint decr_mode; + herr_t status = FAIL; UNUSED(clss); @@ -1531,7 +1515,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config incr_mode = ENVPTR->GetIntField(ENVONLY, cache_config, fid); /*(enum H5C_cache_incr_mode) */ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - cacheinfo.incr_mode = (enum H5C_cache_incr_mode) incr_mode; + cacheinfo.incr_mode = (enum H5C_cache_incr_mode)incr_mode; if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "lower_hr_threshold", "D"))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1562,7 +1546,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config flash_incr_mode = ENVPTR->GetIntField(ENVONLY, cache_config, fid); /*(enum H5C_cache_flash_incr_mode) */ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - cacheinfo.flash_incr_mode = (enum H5C_cache_flash_incr_mode) flash_incr_mode; + cacheinfo.flash_incr_mode = (enum H5C_cache_flash_incr_mode)flash_incr_mode; if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "flash_multiple", "D"))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1581,7 +1565,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config decr_mode = ENVPTR->GetIntField(ENVONLY, cache_config, fid); /*(enum H5C_cache_decr_mode) */ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - cacheinfo.decr_mode = (enum H5C_cache_decr_mode) decr_mode; + cacheinfo.decr_mode = (enum H5C_cache_decr_mode)decr_mode; if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "upper_hr_threshold", "D"))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1651,13 +1635,12 @@ done: * Signature: (J)Lhdf/hdf5lib/structs/H5AC_cache_config_t; */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config(JNIEnv *env, jclass clss, jlong plist) { H5AC_cache_config_t cacheinfo; jstring j_str = NULL; jvalue args[30]; - herr_t status = FAIL; + herr_t status = FAIL; jobject ret_obj = NULL; UNUSED(clss); @@ -1675,15 +1658,16 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, cacheinfo.trace_file_name))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_config: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_mdc_config: out of memory - unable to construct string from UTF characters"); } - args[4].l = j_str; - args[5].z = cacheinfo.evictions_enabled; - args[6].z = cacheinfo.set_initial_size; - args[7].j = (jlong)cacheinfo.initial_size; - args[8].d = cacheinfo.min_clean_fraction; - args[9].j = (jlong)cacheinfo.max_size; + args[4].l = j_str; + args[5].z = cacheinfo.evictions_enabled; + args[6].z = cacheinfo.set_initial_size; + args[7].j = (jlong)cacheinfo.initial_size; + args[8].d = cacheinfo.min_clean_fraction; + args[9].j = (jlong)cacheinfo.max_size; args[10].j = (jlong)cacheinfo.min_size; args[11].j = cacheinfo.epoch_length; args[12].i = cacheinfo.incr_mode; @@ -1705,7 +1689,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config args[28].j = (jlong)cacheinfo.dirty_bytes_threshold; args[29].i = cacheinfo.metadata_write_strategy; - CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5AC_cache_config_t", "(IZZZLjava/lang/String;ZZJDJJJIDDZJIDDIDDZJIZDJI)V", args, ret_obj); + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5AC_cache_config_t", + "(IZZZLjava/lang/String;ZZJDJJJIDDZJIDDIDDZJIZDJI)V", args, ret_obj); done: return ret_obj; @@ -1725,8 +1710,8 @@ done: * Signature: (JZLjava/lang/String;Z)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options - (JNIEnv *env, jclass clss, jlong fapl_id, jboolean is_enabled, jstring location, jboolean start_on_access) +Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options(JNIEnv *env, jclass clss, jlong fapl_id, jboolean is_enabled, + jstring location, jboolean start_on_access) { const char *locStr = NULL; herr_t retVal = FAIL; @@ -1738,7 +1723,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options PIN_JAVA_STRING(ENVONLY, location, locStr, NULL, "H5Pset_mdc_log_options: location string not pinned"); - if ((retVal = H5Pset_mdc_log_options((hid_t)fapl_id, (hbool_t)is_enabled, locStr, (hbool_t)start_on_access)) < 0) + if ((retVal = H5Pset_mdc_log_options((hid_t)fapl_id, (hbool_t)is_enabled, locStr, + (hbool_t)start_on_access)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1752,18 +1738,18 @@ done: * Signature: (J[Z)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options - (JNIEnv *env, jclass clss, jlong fapl_id, jbooleanArray mdc_log_options) +Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options(JNIEnv *env, jclass clss, jlong fapl_id, + jbooleanArray mdc_log_options) { - jboolean isCopy; - jboolean *mdc_log_options_ptr = NULL; - hbool_t is_enabled; - hbool_t start_on_access; - ssize_t status = -1; - size_t location_size; - jsize arrLen; - char *lname = NULL; - jstring str = NULL; + jboolean isCopy; + jboolean *mdc_log_options_ptr = NULL; + hbool_t is_enabled; + hbool_t start_on_access; + ssize_t status = -1; + size_t location_size; + jsize arrLen; + char * lname = NULL; + jstring str = NULL; UNUSED(clss); @@ -1777,7 +1763,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options if (arrLen < 2) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_mdc_log_options: length of mdc_log_options < 2"); - PIN_BOOL_ARRAY(ENVONLY, mdc_log_options, mdc_log_options_ptr, &isCopy, "H5Pget_mdc_log_options: mdc_log_options array not pinned"); + PIN_BOOL_ARRAY(ENVONLY, mdc_log_options, mdc_log_options_ptr, &isCopy, + "H5Pget_mdc_log_options: mdc_log_options array not pinned"); /* get the length of the filename */ if (H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, NULL, &location_size, &start_on_access) < 0) @@ -1787,16 +1774,19 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_mdc_log_options: location_size is 0"); location_size++; /* add extra space for the null terminator */ - if (NULL == (lname = (char *) HDmalloc(sizeof(char) * location_size))) + if (NULL == (lname = (char *)HDmalloc(sizeof(char) * location_size))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_log_options: memory allocation failed"); - if ((status = H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, lname, &location_size, &start_on_access)) < 0) + if ((status = H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, lname, &location_size, + &start_on_access)) < 0) H5_LIBRARY_ERROR(ENVONLY); lname[location_size - 1] = '\0'; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, lname))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_mdc_log_options: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, + "H5Pget_mdc_log_options: out of memory - unable to construct string from UTF characters"); } mdc_log_options_ptr[0] = (jboolean)is_enabled; @@ -1833,11 +1823,10 @@ done: * Signature: (JZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1gc_1references - (JNIEnv *env, jclass clss, jlong fapl_id, jboolean gc_ref) +Java_hdf_hdf5lib_H5_H5Pset_1gc_1references(JNIEnv *env, jclass clss, jlong fapl_id, jboolean gc_ref) { unsigned gc_ref_val = 0; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -1856,11 +1845,10 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1gc_1references - (JNIEnv *env, jclass clss, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1gc_1references(JNIEnv *env, jclass clss, jlong fapl_id) { unsigned gc_ref_val = 0; - jboolean bval = JNI_FALSE; + jboolean bval = JNI_FALSE; UNUSED(clss); @@ -1879,10 +1867,9 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size - (JNIEnv *env, jclass clss, jlong plist, jlong size) +Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size(JNIEnv *env, jclass clss, jlong plist, jlong size) { - long sz = (long)size; + long sz = (long)size; herr_t retVal = FAIL; UNUSED(clss); @@ -1900,8 +1887,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size(JNIEnv *env, jclass clss, jlong plist) { hsize_t s = 0; @@ -1920,8 +1906,7 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds - (JNIEnv *env, jclass clss, jlong fapl_id, jint low, jint high) +Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds(JNIEnv *env, jclass clss, jlong fapl_id, jint low, jint high) { herr_t retVal = FAIL; @@ -1940,12 +1925,11 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds - (JNIEnv *env, jclass clss, jlong fapl_id, jintArray libver) +Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds(JNIEnv *env, jclass clss, jlong fapl_id, jintArray libver) { - jboolean isCopy; - jint *theArray = NULL; - herr_t retVal = FAIL; + jboolean isCopy; + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -1954,7 +1938,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds PIN_INT_ARRAY(ENVONLY, libver, theArray, &isCopy, "H5Pget_libver_bounds: input not pinned"); - if ((retVal = H5Pget_libver_bounds((hid_t)fapl_id, (H5F_libver_t *)&(theArray[0]), (H5F_libver_t *)&(theArray[1]))) < 0) + if ((retVal = H5Pget_libver_bounds((hid_t)fapl_id, (H5F_libver_t *)&(theArray[0]), + (H5F_libver_t *)&(theArray[1]))) < 0) H5_LIBRARY_ERROR(ENVONLY); done: diff --git a/java/src/jni/h5pFAPLImp.h b/java/src/jni/h5pFAPLImp.h index 9b353e6..8c9d7ab 100644 --- a/java/src/jni/h5pFAPLImp.h +++ b/java/src/jni/h5pFAPLImp.h @@ -29,9 +29,7 @@ extern "C" { * Method: H5Pget_driver * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1driver -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1driver(JNIEnv *, jclass, jlong); /* * TODO: H5Pget_driver_info @@ -42,36 +40,29 @@ Java_hdf_hdf5lib_H5_H5Pget_1driver * Method: H5Pset_fclose_degree * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_fclose_degree * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_core * Signature: (JJZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core -(JNIEnv *, jclass, jlong, jlong, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core(JNIEnv *, jclass, jlong, jlong, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_fapl_core * Signature: (J[J[Z)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core -(JNIEnv *, jclass, jlong, jlongArray, jbooleanArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core(JNIEnv *, jclass, jlong, jlongArray, + jbooleanArray); /* * TODO: H5Pset_core_write_tracking @@ -86,81 +77,64 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core * Method: H5Pset_fapl_direct * Signature: (JJJJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct -(JNIEnv *, jclass, jlong, jlong, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct(JNIEnv *, jclass, jlong, jlong, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_fapl_direct * Signature: (J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct -(JNIEnv *, jclass, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_family * Signature: (JJJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family -(JNIEnv *, jclass, jlong, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family(JNIEnv *, jclass, jlong, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_fapl_family * Signature: (J[J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family -(JNIEnv *, jclass, jlong, jlongArray, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family(JNIEnv *, jclass, jlong, jlongArray, + jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_family_offset * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1family_1offset -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1family_1offset(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_family_offset * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1family_1offset -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1family_1offset(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_fapl_hdfs * Signature: (J)Lhdf/hdf5lib/structs/H5FD_hdfs_fapl_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs -(JNIEnv *, jclass, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1hdfs(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_hdfs * Signature: (JLhdf/hdf5lib/structs/H5FD_hdfs_fapl_t;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1hdfs -(JNIEnv *, jclass, jlong, jobject); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1hdfs(JNIEnv *, jclass, jlong, jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_log * Signature: (JLjava/lang/String;JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log -(JNIEnv *, jclass, jlong, jstring, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log(JNIEnv *, jclass, jlong, jstring, jlong, jlong); /* * TODO: H5Pset_fapl_mpio @@ -183,18 +157,16 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log * Method: H5Pset_fapl_multi * Signature: (J[I[J[Ljava/lang/String;[JZ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi -(JNIEnv *, jclass, jlong, jintArray, jlongArray, jobjectArray, jlongArray, jboolean); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi(JNIEnv *, jclass, jlong, jintArray, jlongArray, + jobjectArray, jlongArray, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_fapl_multi * Signature: (J[I[J[Ljava/lang/String;[J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi -(JNIEnv *, jclass, jlong, jintArray, jlongArray, jobjectArray, jlongArray); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi(JNIEnv *, jclass, jlong, jintArray, + jlongArray, jobjectArray, jlongArray); /* * TODO: H5Pset_multi_type @@ -209,54 +181,43 @@ Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi * Method: H5Pget_fapl_ros3 * Signature: (J)Lhdf/hdf5lib/structs/H5FD_ros3_fapl_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3 -(JNIEnv *, jclass, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Pget_1fapl_1ros3(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_ros3 * Signature: (JLhdf/hdf5lib/structs/H5FD_ros3_fapl_t;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1ros3 -(JNIEnv *, jclass, jlong, jobject); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1ros3(JNIEnv *, jclass, jlong, jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_split * Signature: (JLjava/lang/String;JLjava/lang/String;J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split -(JNIEnv *, jclass, jlong, jstring, jlong, jstring, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split(JNIEnv *, jclass, jlong, jstring, jlong, + jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_sec2 * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_stdio * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_fapl_windows * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows(JNIEnv *, jclass, jlong); /* * TODO: H5Pset_file_image @@ -279,18 +240,14 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows * Method: H5Pset_meta_block_size * Signature: (JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_meta_block_size * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size(JNIEnv *, jclass, jlong); /* * TODO: H5Pset_page_buffer_size @@ -305,126 +262,100 @@ Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size * Method: H5Pset_sieve_buf_size * Signature: (JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_sieve_buf_size * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_alignment * Signature: (JJJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1alignment -(JNIEnv *, jclass, jlong, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1alignment(JNIEnv *, jclass, jlong, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_alignment * Signature: (J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1alignment -(JNIEnv *, jclass, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1alignment(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_cache * Signature: (JIJJD)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1cache -(JNIEnv *, jclass, jlong, jint, jlong, jlong, jdouble); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1cache(JNIEnv *, jclass, jlong, jint, jlong, jlong, + jdouble); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_cache * Signature: (J[I[J[J[D)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1cache -(JNIEnv *, jclass, jlong, jintArray, jlongArray, jlongArray, jdoubleArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1cache(JNIEnv *, jclass, jlong, jintArray, jlongArray, + jlongArray, jdoubleArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_elink_file_cache_size * Signature: (JI)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_elink_file_cache_size * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_evict_on_close * Signature: (JZ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close -(JNIEnv *, jclass, jlong, jboolean); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close(JNIEnv *, jclass, jlong, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_evict_on_close * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close -(JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_metadata_read_attempts * Signature: (JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_metadata_read_attempts * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_mdc_config * Signature: (JLhdf/hdf5lib/structs/H5AC_cache_config_t;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config -(JNIEnv *, jclass, jlong, jobject); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config(JNIEnv *, jclass, jlong, jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_mdc_config * Signature: (J)Lhdf/hdf5lib/structs/H5AC_cache_config_t; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config -(JNIEnv *, jclass, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config(JNIEnv *, jclass, jlong); /* * TODO: H5Pset_mdc_image_config @@ -439,18 +370,16 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config * Method: H5Pset_mdc_log_options * Signature: (JZLjava/lang/String;Z)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options -(JNIEnv *, jclass, jlong, jboolean, jstring, jboolean); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options(JNIEnv *, jclass, jlong, jboolean, + jstring, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_mdc_log_options * Signature: (J[Z)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options -(JNIEnv *, jclass, jlong, jbooleanArray); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options(JNIEnv *, jclass, jlong, + jbooleanArray); /* * TODO: H5Pset_all_coll_metadata_ops @@ -473,54 +402,42 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options * Method: H5Pset_gc_references * Signature: (JZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1gc_1references -(JNIEnv *, jclass, jlong, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1gc_1references(JNIEnv *, jclass, jlong, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_gc_references * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1gc_1references -(JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1gc_1references(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_small_data_block_size * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_small_data_block_size * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_libver_bounds * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_libver_bounds * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds(JNIEnv *, jclass, jlong, jintArray); /* * TODO: H5Pset_object_flush_cb diff --git a/java/src/jni/h5pFCPLImp.c b/java/src/jni/h5pFCPLImp.c index 2160496..fcb590e 100644 --- a/java/src/jni/h5pFCPLImp.c +++ b/java/src/jni/h5pFCPLImp.c @@ -37,10 +37,9 @@ extern "C" { * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1userblock - (JNIEnv *env, jclass clss, jlong plist, jlong size) +Java_hdf_hdf5lib_H5_H5Pset_1userblock(JNIEnv *env, jclass clss, jlong plist, jlong size) { - long sz = (long) size; + long sz = (long)size; herr_t retVal = FAIL; UNUSED(clss); @@ -58,13 +57,12 @@ done: * Signature: (J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1userblock - (JNIEnv *env, jclass clss, jlong plist, jlongArray size) +Java_hdf_hdf5lib_H5_H5Pget_1userblock(JNIEnv *env, jclass clss, jlong plist, jlongArray size) { - jboolean isCopy; - hsize_t s; - jlong *theArray = NULL; - herr_t status = FAIL; + jboolean isCopy; + hsize_t s; + jlong * theArray = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -91,8 +89,7 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sizes - (JNIEnv *env, jclass clss, jlong plist, jint sizeof_addr, jint sizeof_size) +Java_hdf_hdf5lib_H5_H5Pset_1sizes(JNIEnv *env, jclass clss, jlong plist, jint sizeof_addr, jint sizeof_size) { herr_t retVal = FAIL; @@ -111,15 +108,14 @@ done: * Signature: (J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sizes - (JNIEnv *env, jclass clss, jlong plist, jlongArray size) +Java_hdf_hdf5lib_H5_H5Pget_1sizes(JNIEnv *env, jclass clss, jlong plist, jlongArray size) { - jboolean isCopy; - jlong *theArray = NULL; - jsize arrLen; - size_t ss; - size_t sa; - herr_t status = FAIL; + jboolean isCopy; + jlong * theArray = NULL; + jsize arrLen; + size_t ss; + size_t sa; + herr_t status = FAIL; UNUSED(clss); @@ -154,8 +150,7 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sym_1k - (JNIEnv *env, jclass clss, jlong plist, jint ik, jint lk) +Java_hdf_hdf5lib_H5_H5Pset_1sym_1k(JNIEnv *env, jclass clss, jlong plist, jint ik, jint lk) { herr_t retVal = FAIL; @@ -174,13 +169,12 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sym_1k - (JNIEnv *env, jclass clss, jlong plist, jintArray size) +Java_hdf_hdf5lib_H5_H5Pget_1sym_1k(JNIEnv *env, jclass clss, jlong plist, jintArray size) { - jboolean isCopy; - jsize arrLen; - jint *theArray = NULL; - herr_t status = FAIL; + jboolean isCopy; + jsize arrLen; + jint * theArray = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -212,8 +206,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1istore_1k - (JNIEnv *env, jclass clss, jlong plist, jint ik) +Java_hdf_hdf5lib_H5_H5Pset_1istore_1k(JNIEnv *env, jclass clss, jlong plist, jint ik) { herr_t retVal = FAIL; @@ -232,12 +225,11 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1istore_1k - (JNIEnv *env, jclass clss, jlong plist, jintArray ik) +Java_hdf_hdf5lib_H5_H5Pget_1istore_1k(JNIEnv *env, jclass clss, jlong plist, jintArray ik) { - jboolean isCopy; - jint *theArray = NULL; - herr_t status = FAIL; + jboolean isCopy; + jint * theArray = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -262,8 +254,7 @@ done: * Signature: (JJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size - (JNIEnv *env, jclass clss, jlong fcpl_id, jlong fsp_size) +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size(JNIEnv *env, jclass clss, jlong fcpl_id, jlong fsp_size) { UNUSED(clss); @@ -280,8 +271,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size - (JNIEnv *env, jclass clss, jlong fcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size(JNIEnv *env, jclass clss, jlong fcpl_id) { hsize_t fsp_size = 0; @@ -300,12 +290,13 @@ done: * Signature: (JIZJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy - (JNIEnv *env, jclass clss, jlong fcpl_id, jint strategy, jboolean persist, jlong threshold) +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy(JNIEnv *env, jclass clss, jlong fcpl_id, jint strategy, + jboolean persist, jlong threshold) { UNUSED(clss); - if (H5Pset_file_space_strategy((hid_t)fcpl_id, (H5F_fspace_strategy_t)strategy, (hbool_t)persist, (hsize_t)threshold) < 0) + if (H5Pset_file_space_strategy((hid_t)fcpl_id, (H5F_fspace_strategy_t)strategy, (hbool_t)persist, + (hsize_t)threshold) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -318,23 +309,25 @@ done: * Signature: (J[Z[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy - (JNIEnv *env, jclass clss, jlong fcpl_id, jbooleanArray persist, jlongArray threshold) +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy(JNIEnv *env, jclass clss, jlong fcpl_id, + jbooleanArray persist, jlongArray threshold) { - H5F_fspace_strategy_t thestrategy = H5F_FSPACE_STRATEGY_FSM_AGGR; /* Library default */ - jboolean isCopy; - jboolean *persistArray = NULL; - jlong *thresholdArray = NULL; - herr_t status = FAIL; + H5F_fspace_strategy_t thestrategy = H5F_FSPACE_STRATEGY_FSM_AGGR; /* Library default */ + jboolean isCopy; + jboolean * persistArray = NULL; + jlong * thresholdArray = NULL; + herr_t status = FAIL; UNUSED(clss); if (persist) PIN_BOOL_ARRAY(ENVONLY, persist, persistArray, &isCopy, "H5Pget_file_space: persist not pinned"); if (threshold) - PIN_LONG_ARRAY(ENVONLY, threshold, thresholdArray, &isCopy, "H5Pget_file_space: threshold not pinned"); + PIN_LONG_ARRAY(ENVONLY, threshold, thresholdArray, &isCopy, + "H5Pget_file_space: threshold not pinned"); - if ((status = H5Pget_file_space_strategy((hid_t)fcpl_id, &thestrategy, (hbool_t *)persistArray, (hsize_t *)thresholdArray)) < 0) + if ((status = H5Pget_file_space_strategy((hid_t)fcpl_id, &thestrategy, (hbool_t *)persistArray, + (hsize_t *)thresholdArray)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -352,11 +345,10 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist - (JNIEnv *env, jclass clss, jlong fcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist(JNIEnv *env, jclass clss, jlong fcpl_id) { hbool_t persist = FALSE; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -373,11 +365,10 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold - (JNIEnv *env, jclass clss, jlong fcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold(JNIEnv *env, jclass clss, jlong fcpl_id) { hsize_t threshold = 0; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -394,15 +385,16 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes - (JNIEnv *env, jclass clss, jlong plist_id, jint nindexes) +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes(JNIEnv *env, jclass clss, jlong plist_id, jint nindexes) { herr_t retVal = FAIL; UNUSED(clss); if (nindexes > H5O_SHMESG_MAX_NINDEXES) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_nindexes: number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, + "H5Pset_shared_mesg_nindexes: number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); if ((retVal = H5Pset_shared_mesg_nindexes((hid_t)plist_id, (unsigned)nindexes)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -417,8 +409,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes - (JNIEnv *env, jclass clss, jlong fcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes(JNIEnv *env, jclass clss, jlong fcpl_id) { unsigned nindexes; @@ -437,9 +428,8 @@ done: * Signature: (JIII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index - (JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, - jint mesg_type_flags, jint min_mesg_size) +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index(JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, + jint mesg_type_flags, jint min_mesg_size) { unsigned nindexes; /* Number of SOHM indexes */ herr_t retVal = FAIL; @@ -447,7 +437,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index UNUSED(clss); /* Check arguments */ - if ((unsigned) mesg_type_flags > H5O_SHMESG_ALL_FLAG) + if ((unsigned)mesg_type_flags > H5O_SHMESG_ALL_FLAG) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_index: unrecognized flags in mesg_type_flags"); /* Read the current number of indexes */ @@ -455,10 +445,11 @@ Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index H5_LIBRARY_ERROR(ENVONLY); /* Range check */ - if ((unsigned) index_num >= nindexes) + if ((unsigned)index_num >= nindexes) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_index: index_num is too large; no such index"); - if ((retVal = H5Pset_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, (unsigned) mesg_type_flags, (unsigned) min_mesg_size)) < 0) + if ((retVal = H5Pset_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, (unsigned)mesg_type_flags, + (unsigned)min_mesg_size)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -471,13 +462,13 @@ done: * Signature: (JI[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index - (JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, jintArray mesg_info) +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index(JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, + jintArray mesg_info) { - jboolean isCopy; - unsigned nindexes; /* Number of SOHM indexes */ - jint *theArray = NULL; - herr_t retVal = FAIL; + jboolean isCopy; + unsigned nindexes; /* Number of SOHM indexes */ + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -489,12 +480,13 @@ Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index H5_LIBRARY_ERROR(ENVONLY); /* Range check */ - if ((unsigned) index_num >= nindexes) + if ((unsigned)index_num >= nindexes) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_shared_mesg_index: index_num is too large; no such index"); PIN_INT_ARRAY(ENVONLY, mesg_info, theArray, &isCopy, "H5Pget_shared_mesg_index: input not pinned"); - if ((retVal = H5Pget_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + if ((retVal = H5Pget_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, (unsigned *)&(theArray[0]), + (unsigned *)&(theArray[1]))) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -510,8 +502,8 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change - (JNIEnv *env, jclass clss, jlong fcpl_id, jint max_list, jint min_btree) +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change(JNIEnv *env, jclass clss, jlong fcpl_id, + jint max_list, jint min_btree) { herr_t retVal = FAIL; @@ -524,13 +516,20 @@ Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change */ if (max_list + 1 < min_btree) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_phase_change: minimum B-tree value is greater than maximum list value"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, + "H5Pset_shared_mesg_phase_change: minimum B-tree value is greater than maximum list value"); if (max_list > H5O_SHMESG_MAX_LIST_SIZE) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_phase_change: max list value is larger than H5O_SHMESG_MAX_LIST_SIZE"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, + "H5Pset_shared_mesg_phase_change: max list value is larger than H5O_SHMESG_MAX_LIST_SIZE"); if (min_btree > H5O_SHMESG_MAX_LIST_SIZE) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_phase_change: min btree value is larger than H5O_SHMESG_MAX_LIST_SIZE"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, + "H5Pset_shared_mesg_phase_change: min btree value is larger than H5O_SHMESG_MAX_LIST_SIZE"); - if ((retVal = H5Pset_shared_mesg_phase_change((hid_t)fcpl_id, (unsigned)max_list, (unsigned)min_btree)) < 0) + if ((retVal = H5Pset_shared_mesg_phase_change((hid_t)fcpl_id, (unsigned)max_list, (unsigned)min_btree)) < + 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -543,12 +542,12 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change - (JNIEnv *env, jclass clss, jlong fcpl_id, jintArray size) +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change(JNIEnv *env, jclass clss, jlong fcpl_id, + jintArray size) { - jboolean isCopy; - jint *theArray = NULL; - herr_t retVal = FAIL; + jboolean isCopy; + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -557,7 +556,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change PIN_INT_ARRAY(ENVONLY, size, theArray, &isCopy, "H5Pget_shared_mesg_phase_change: input not pinned"); - if ((retVal = H5Pget_shared_mesg_phase_change((hid_t)fcpl_id, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + if ((retVal = H5Pget_shared_mesg_phase_change((hid_t)fcpl_id, (unsigned *)&(theArray[0]), + (unsigned *)&(theArray[1]))) < 0) H5_LIBRARY_ERROR(ENVONLY); done: diff --git a/java/src/jni/h5pFCPLImp.h b/java/src/jni/h5pFCPLImp.h index 57fcae8..924e325 100644 --- a/java/src/jni/h5pFCPLImp.h +++ b/java/src/jni/h5pFCPLImp.h @@ -25,180 +25,147 @@ extern "C" { * Method: H5Pset_userblock * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1userblock -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1userblock(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_userblock * Signature: (J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1userblock -(JNIEnv *, jclass, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1userblock(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_sizes * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sizes -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1sizes(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_sizes * Signature: (J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sizes -(JNIEnv *, jclass, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1sizes(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_sym_k * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sym_1k -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1sym_1k(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_sym_k * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sym_1k -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1sym_1k(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_istore_k * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1istore_1k -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1istore_1k(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_istore_k * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1istore_1k -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1istore_1k(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_file_space_page_size * Signature: (JJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_file_space_page_size * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_file_space_strategy * Signature: (JIZJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy -(JNIEnv *, jclass, jlong, jint, jboolean, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy(JNIEnv *, jclass, jlong, jint, + jboolean, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_file_space_strategy * Signature: (J[Z[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy -(JNIEnv *, jclass, jlong, jbooleanArray, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy(JNIEnv *, jclass, jlong, + jbooleanArray, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_file_space_strategy_persist * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist -(JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist(JNIEnv *, jclass, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_file_space_strategy_threshold * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_shared_mesg_nindexes * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_shared_mesg_nindexes * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_shared_mesg_index * Signature: (JIII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index -(JNIEnv *, jclass, jlong, jint, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index(JNIEnv *, jclass, jlong, jint, jint, + jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_shared_mesg_index * Signature: (JI[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index -(JNIEnv *, jclass, jlong, jint, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index(JNIEnv *, jclass, jlong, jint, + jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_shared_mesg_phase_change * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change(JNIEnv *, jclass, jlong, jint, + jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_shared_mesg_phase_change * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change(JNIEnv *, jclass, jlong, + jintArray); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pGCPLImp.c b/java/src/jni/h5pGCPLImp.c index 2ba1c7d..67af902 100644 --- a/java/src/jni/h5pGCPLImp.c +++ b/java/src/jni/h5pGCPLImp.c @@ -37,8 +37,7 @@ extern "C" { * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint - (JNIEnv *env, jclass clss, jlong gcpl_id, jlong size_hint) +Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint(JNIEnv *env, jclass clss, jlong gcpl_id, jlong size_hint) { herr_t retVal = FAIL; @@ -57,8 +56,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint - (JNIEnv *env, jclass clss, jlong gcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint(JNIEnv *env, jclass clss, jlong gcpl_id) { size_t size_hint = 0; @@ -77,8 +75,8 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order - (JNIEnv *env, jclass clss, jlong gcpl_id, jint crt_order_flags) +Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order(JNIEnv *env, jclass clss, jlong gcpl_id, + jint crt_order_flags) { herr_t retVal = FAIL; @@ -97,8 +95,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order - (JNIEnv *env, jclass clss, jlong gcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order(JNIEnv *env, jclass clss, jlong gcpl_id) { unsigned crt_order_flags; @@ -117,8 +114,8 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info - (JNIEnv *env, jclass clss, jlong gcpl_id, jint est_num_entries, jint est_name_len) +Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info(JNIEnv *env, jclass clss, jlong gcpl_id, jint est_num_entries, + jint est_name_len) { herr_t retVal = FAIL; @@ -126,9 +123,11 @@ Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info /* Range check values */ if ((est_num_entries > 65535) || (est_name_len > 65535)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_est_link_info: est. name length or number of entries must be < 65536"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "H5Pset_est_link_info: est. name length or number of entries must be < 65536"); - if ((retVal = H5Pset_est_link_info((hid_t)gcpl_id, (unsigned)est_num_entries, (unsigned)est_name_len)) < 0) + if ((retVal = H5Pset_est_link_info((hid_t)gcpl_id, (unsigned)est_num_entries, (unsigned)est_name_len)) < + 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -141,12 +140,11 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info - (JNIEnv *env, jclass clss, jlong gcpl_id, jintArray link_info) +Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info(JNIEnv *env, jclass clss, jlong gcpl_id, jintArray link_info) { - jboolean isCopy; - jint *theArray = NULL; - herr_t retVal = FAIL; + jboolean isCopy; + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -155,7 +153,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info PIN_INT_ARRAY(ENVONLY, link_info, theArray, &isCopy, "H5Pget_est_link_info: input not pinned"); - if ((retVal = H5Pget_est_link_info((hid_t)gcpl_id, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + if ((retVal = H5Pget_est_link_info((hid_t)gcpl_id, (unsigned *)&(theArray[0]), + (unsigned *)&(theArray[1]))) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -171,15 +170,16 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change - (JNIEnv *env, jclass clss, jlong gcpl_id, jint max_compact, jint min_dense) +Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change(JNIEnv *env, jclass clss, jlong gcpl_id, jint max_compact, + jint min_dense) { herr_t retVal = FAIL; UNUSED(clss); if (max_compact < min_dense) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_link_phase_change: max compact value must be >= min dense value"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "H5Pset_link_phase_change: max compact value must be >= min dense value"); if (max_compact > 65535) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_link_phase_change: max compact value must be < 65536"); if (min_dense > 65535) @@ -198,12 +198,11 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change - (JNIEnv *env, jclass clss, jlong gcpl_id, jintArray links) +Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change(JNIEnv *env, jclass clss, jlong gcpl_id, jintArray links) { - jboolean isCopy; - jint *theArray = NULL; - herr_t retVal = FAIL; + jboolean isCopy; + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -212,7 +211,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change PIN_INT_ARRAY(ENVONLY, links, theArray, &isCopy, "H5Pget_link_phase_change: input not pinned"); - if ((retVal = H5Pget_link_phase_change((hid_t)gcpl_id, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + if ((retVal = H5Pget_link_phase_change((hid_t)gcpl_id, (unsigned *)&(theArray[0]), + (unsigned *)&(theArray[1]))) < 0) H5_LIBRARY_ERROR(ENVONLY); done: diff --git a/java/src/jni/h5pGCPLImp.h b/java/src/jni/h5pGCPLImp.h index 9c32063..920e799 100644 --- a/java/src/jni/h5pGCPLImp.h +++ b/java/src/jni/h5pGCPLImp.h @@ -25,72 +25,56 @@ extern "C" { * Method: H5Pset_local_heap_size_hint * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_local_heap_size_hint * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_link_creation_order * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_link_creation_order * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_est_link_info * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_est_link_info * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_link_phase_change * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_link_phase_change * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change(JNIEnv *, jclass, jlong, jintArray); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index 9e5b004..4ab359a 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -54,7 +54,7 @@ static herr_t H5P_cls_close_cb(hid_t prop_id, void *close_data); static herr_t H5P_prp_create_cb(const char *name, size_t size, void *value); static herr_t H5P_prp_copy_cb(const char *name, size_t size, void *value); static herr_t H5P_prp_close_cb(const char *name, size_t size, void *value); -static int H5P_prp_compare_cb(void *value1, void *value2, size_t size); +static int H5P_prp_compare_cb(void *value1, void *value2, size_t size); static herr_t H5P_prp_get_cb(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P_prp_set_cb(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P_prp_delete_cb(hid_t prop_id, const char *name, size_t size, void *value); @@ -67,14 +67,13 @@ static herr_t H5P_iterate_cb(hid_t prop_id, const char *name, void *cb_data); * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate - (JNIEnv *env, jclass clss, jlong type) +Java_hdf_hdf5lib_H5__1H5Pcreate(JNIEnv *env, jclass clss, jlong type) { hid_t retVal = H5I_INVALID_HID; UNUSED(clss); - if ((retVal = H5Pcreate((hid_t) type)) < 0) + if ((retVal = H5Pcreate((hid_t)type)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -87,14 +86,13 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1class(JNIEnv *env, jclass clss, jlong plist) { hid_t retVal = H5I_INVALID_HID; UNUSED(clss); - if ((retVal = H5Pget_class((hid_t) plist)) < 0) + if ((retVal = H5Pget_class((hid_t)plist)) < 0) H5_LIBRARY_ERROR(ENVONLY); /* @@ -112,14 +110,13 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcopy - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5__1H5Pcopy(JNIEnv *env, jclass clss, jlong plist) { hid_t retVal = H5I_INVALID_HID; UNUSED(clss); - if ((retVal = H5Pcopy((hid_t) plist)) < 0) + if ((retVal = H5Pcopy((hid_t)plist)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -132,15 +129,14 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Pclose - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5__1H5Pclose(JNIEnv *env, jclass clss, jlong plist) { herr_t retVal = FAIL; UNUSED(clss); if (plist >= 0) - if ((retVal = H5Pclose((hid_t) plist)) < 0) + if ((retVal = H5Pclose((hid_t)plist)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -158,29 +154,32 @@ done: /* * Class: hdf_hdf5lib_H5 * Method: _H5Pcreate_class - * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J + * Signature: + * (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate_1class - (JNIEnv *env, jclass clss, jlong parent_class, jstring name, jobject create_op, - jobject create_data, jobject copy_op, jobject copy_data, jobject close_op, jobject close_data) +Java_hdf_hdf5lib_H5__1H5Pcreate_1class(JNIEnv *env, jclass clss, jlong parent_class, jstring name, + jobject create_op, jobject create_data, jobject copy_op, + jobject copy_data, jobject close_op, jobject close_data) { - const char *cstr = NULL; + const char *cstr = NULL; hid_t class_id = H5I_INVALID_HID; UNUSED(clss); create_callback = create_op; - close_callback = close_op; - copy_callback = copy_op; + close_callback = close_op; + copy_callback = copy_op; if (NULL == name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "_H5Pcreate_class: class name is NULL"); PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "_H5Pcreate_class: class name not pinned"); - if ((class_id = H5Pcreate_class((hid_t)parent_class, cstr, (H5P_cls_create_func_t)H5P_cls_create_cb, (void *) create_data, - (H5P_cls_copy_func_t)H5P_cls_copy_cb, (void *) copy_data, (H5P_cls_close_func_t)H5P_cls_close_cb, (void *) close_data)) < 0) + if ((class_id = + H5Pcreate_class((hid_t)parent_class, cstr, (H5P_cls_create_func_t)H5P_cls_create_cb, + (void *)create_data, (H5P_cls_copy_func_t)H5P_cls_copy_cb, (void *)copy_data, + (H5P_cls_close_func_t)H5P_cls_close_cb, (void *)close_data)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -193,13 +192,13 @@ done: /* * Class: hdf_hdf5lib_H5 * Method: _H5Pcreate_class_nocb - * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J + * Signature: + * (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb - (JNIEnv *env, jclass clss, jlong parent_class, jstring name) +Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb(JNIEnv *env, jclass clss, jlong parent_class, jstring name) { - const char *cstr = NULL; + const char *cstr = NULL; hid_t class_id = H5I_INVALID_HID; UNUSED(clss); @@ -209,7 +208,7 @@ Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "_H5Pcreate_class_nocb: class name not pinned"); - if ((class_id = H5Pcreate_class((hid_t)parent_class, cstr, NULL, NULL, NULL, NULL, NULL, NULL)) < 0) + if ((class_id = H5Pcreate_class((hid_t)parent_class, cstr, NULL, NULL, NULL, NULL, NULL, NULL)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -222,39 +221,43 @@ done: /* * Class: hdf_hdf5lib_H5 * Method: H5Pregister2 - * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V + * Signature: + * (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pregister2 - (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, - jbyteArray def_value, jobject prp_create, jobject prp_set, jobject prp_get, jobject prp_delete, - jobject prp_copy, jobject prp_cmp, jobject prp_close) +Java_hdf_hdf5lib_H5_H5Pregister2(JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, + jbyteArray def_value, jobject prp_create, jobject prp_set, jobject prp_get, + jobject prp_delete, jobject prp_copy, jobject prp_cmp, jobject prp_close) { const char *cstr = NULL; jboolean isCopy; - herr_t status = FAIL; - jbyte *propValBuf = NULL; + herr_t status = FAIL; + jbyte * propValBuf = NULL; UNUSED(clss); - copy_callback = prp_copy; - close_callback = prp_close; - create_callback = prp_create; + copy_callback = prp_copy; + close_callback = prp_close; + create_callback = prp_create; compare_callback = prp_cmp; - set_callback = prp_set; - get_callback = prp_get; - delete_callback = prp_delete; + set_callback = prp_set; + get_callback = prp_get; + delete_callback = prp_delete; if (NULL == name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pregister2: property name is NULL"); PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pregister2: property name not pinned"); - PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pregister2: default property value buffer not pinned"); + PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, + "H5Pregister2: default property value buffer not pinned"); - if ((status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, (H5P_prp_create_func_t)H5P_prp_create_cb, - (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, - (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, (H5P_prp_close_func_t)H5P_prp_close_cb)) < 0) + if ((status = + H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, + (H5P_prp_create_func_t)H5P_prp_create_cb, (H5P_prp_set_func_t)H5P_prp_set_cb, + (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, + (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, + (H5P_prp_close_func_t)H5P_prp_close_cb)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -270,13 +273,13 @@ done: * Signature: (JLjava/lang/String;J[B)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pregister2_1nocb - (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, jbyteArray def_value) +Java_hdf_hdf5lib_H5_H5Pregister2_1nocb(JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, + jbyteArray def_value) { const char *cstr = NULL; jboolean isCopy; - herr_t status = FAIL; - jbyte *propValBuf = NULL; + herr_t status = FAIL; + jbyte * propValBuf = NULL; UNUSED(clss); @@ -285,9 +288,11 @@ Java_hdf_hdf5lib_H5_H5Pregister2_1nocb PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pregister2_nocb: property name not pinned"); - PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pregister2_nocb: default property value buffer not pinned"); + PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, + "H5Pregister2_nocb: default property value buffer not pinned"); - if ((status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) < 0) + if ((status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, NULL, NULL, NULL, + NULL, NULL, NULL, NULL)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -300,27 +305,27 @@ done: /* * Class: hdf_hdf5lib_H5 * Method: H5Pinsert2 - * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V + * Signature: + * (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pinsert2 - (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, - jbyteArray def_value, jobject prp_set, jobject prp_get, jobject prp_delete, - jobject prp_copy, jobject prp_cmp, jobject prp_close) +Java_hdf_hdf5lib_H5_H5Pinsert2(JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, + jbyteArray def_value, jobject prp_set, jobject prp_get, jobject prp_delete, + jobject prp_copy, jobject prp_cmp, jobject prp_close) { const char *cstr = NULL; jboolean isCopy; - herr_t status = FAIL; - jbyte *propValBuf = NULL; + herr_t status = FAIL; + jbyte * propValBuf = NULL; UNUSED(clss); - copy_callback = prp_copy; - close_callback = prp_close; + copy_callback = prp_copy; + close_callback = prp_close; compare_callback = prp_cmp; - set_callback = prp_set; - get_callback = prp_get; - delete_callback = prp_delete; + set_callback = prp_set; + get_callback = prp_get; + delete_callback = prp_delete; if (NULL == name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pinsert2: property name is NULL"); @@ -330,8 +335,10 @@ Java_hdf_hdf5lib_H5_H5Pinsert2 PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pinsert2: property value buffer not pinned"); if ((status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, - (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, - (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, (H5P_prp_close_func_t)H5P_prp_close_cb)) < 0) + (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, + (H5P_prp_delete_func_t)H5P_prp_delete_cb, (H5P_prp_copy_func_t)H5P_prp_copy_cb, + (H5P_prp_compare_func_t)H5P_prp_compare_cb, + (H5P_prp_close_func_t)H5P_prp_close_cb)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -347,13 +354,13 @@ done: * Signature: (JLjava/lang/String;J[B)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb - (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, jbyteArray def_value) +Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb(JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, + jbyteArray def_value) { const char *cstr = NULL; jboolean isCopy; - herr_t status = FAIL; - jbyte *propValBuf = NULL; + herr_t status = FAIL; + jbyte * propValBuf = NULL; UNUSED(clss); @@ -362,9 +369,11 @@ Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pinsert2_nocb: property name not pinned"); - PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pinsert2_nocb: property value buffer not pinned"); + PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, + "H5Pinsert2_nocb: property value buffer not pinned"); - if ((status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, NULL, NULL, NULL, NULL, NULL, NULL)) < 0) + if ((status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, NULL, NULL, NULL, + NULL, NULL, NULL)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -380,10 +389,9 @@ done: * Signature: (JLjava/lang/String;I)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pset - (JNIEnv *env, jclass clss, jlong plid, jstring name, jint val) +Java_hdf_hdf5lib_H5_H5Pset(JNIEnv *env, jclass clss, jlong plid, jstring name, jint val) { - const char *cstr = NULL; + const char *cstr = NULL; hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -409,8 +417,7 @@ done: * Signature: (JLjava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pexist - (JNIEnv *env, jclass clss, jlong plid, jstring name) +Java_hdf_hdf5lib_H5_H5Pexist(JNIEnv *env, jclass clss, jlong plid, jstring name) { const char *cstr = NULL; htri_t bval = JNI_FALSE; @@ -440,11 +447,10 @@ done: * Signature: (JLjava/lang/String;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1size - (JNIEnv *env, jclass clss, jlong plid, jstring name) +Java_hdf_hdf5lib_H5_H5Pget_1size(JNIEnv *env, jclass clss, jlong plid, jstring name) { - const char *cstr = NULL; - size_t size = 0; + const char *cstr = NULL; + size_t size = 0; herr_t status = FAIL; UNUSED(clss); @@ -461,7 +467,7 @@ done: if (cstr) UNPIN_JAVA_STRING(ENVONLY, name, cstr); - return (jlong) size; + return (jlong)size; } /* end Java_hdf_hdf5lib_H5_H5Pget_1size */ /* @@ -470,8 +476,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nprops - (JNIEnv *env, jclass clss, jlong plid) +Java_hdf_hdf5lib_H5_H5Pget_1nprops(JNIEnv *env, jclass clss, jlong plid) { size_t nprops = 0; @@ -490,11 +495,10 @@ done: * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class_1name - (JNIEnv *env, jclass clss, jlong plid) +Java_hdf_hdf5lib_H5_H5Pget_1class_1name(JNIEnv *env, jclass clss, jlong plid) { - char *c_str = NULL; - jstring j_str = NULL; + char * c_str = NULL; + jstring j_str = NULL; UNUSED(clss); @@ -503,7 +507,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1class_1name if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, c_str))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_class_name: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_class_name: out of memory - unable to construct string from UTF characters"); } done: @@ -519,8 +524,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class_1parent - (JNIEnv *env, jclass clss, jlong plid) +Java_hdf_hdf5lib_H5_H5Pget_1class_1parent(JNIEnv *env, jclass clss, jlong plid) { hid_t retVal = H5I_INVALID_HID; @@ -539,8 +543,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pisa_1class - (JNIEnv *env, jclass clss, jlong plid, jlong pcls) +Java_hdf_hdf5lib_H5_H5Pisa_1class(JNIEnv *env, jclass clss, jlong plid, jlong pcls) { htri_t retVal = FAIL; @@ -559,8 +562,7 @@ done: * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget - (JNIEnv *env, jclass clss, jlong plid, jstring name) +Java_hdf_hdf5lib_H5_H5Pget(JNIEnv *env, jclass clss, jlong plid, jstring name) { const char *cstr = NULL; jint val; @@ -589,8 +591,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pequal - (JNIEnv *env, jclass clss, jlong plid1, jlong plid2) +Java_hdf_hdf5lib_H5_H5Pequal(JNIEnv *env, jclass clss, jlong plid1, jlong plid2) { htri_t retVal = FAIL; @@ -609,13 +610,13 @@ done: * Signature: (J[ILjava/lang/Object;Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Piterate - (JNIEnv *env, jclass clss, jlong prop_id, jintArray idx, jobject callback_op, jobject op_data) +Java_hdf_hdf5lib_H5_H5Piterate(JNIEnv *env, jclass clss, jlong prop_id, jintArray idx, jobject callback_op, + jobject op_data) { - cb_wrapper wrapper = { callback_op, op_data }; - jboolean isCopy; - jint *theArray = NULL; - herr_t status = FAIL; + cb_wrapper wrapper = {callback_op, op_data}; + jboolean isCopy; + jint * theArray = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -634,7 +635,8 @@ Java_hdf_hdf5lib_H5_H5Piterate else { PIN_INT_ARRAY(ENVONLY, idx, theArray, &isCopy, "H5Piterate: idx not pinned"); - if ((status = H5Piterate((hid_t)prop_id, (int *)&theArray[0], (H5P_iterate_t)H5P_iterate_cb, (void *)&wrapper)) < 0) + if ((status = H5Piterate((hid_t)prop_id, (int *)&theArray[0], (H5P_iterate_t)H5P_iterate_cb, + (void *)&wrapper)) < 0) H5_LIBRARY_ERROR(ENVONLY); } @@ -651,10 +653,9 @@ done: * Signature: (JJLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pcopy_1prop - (JNIEnv *env, jclass clss, jlong dst_plid, jlong src_plid, jstring name) +Java_hdf_hdf5lib_H5_H5Pcopy_1prop(JNIEnv *env, jclass clss, jlong dst_plid, jlong src_plid, jstring name) { - const char *cstr = NULL; + const char *cstr = NULL; herr_t retVal = FAIL; UNUSED(clss); @@ -680,10 +681,9 @@ done: * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Premove - (JNIEnv *env, jclass clss, jlong plid, jstring name) +Java_hdf_hdf5lib_H5_H5Premove(JNIEnv *env, jclass clss, jlong plid, jstring name) { - const char *cstr = NULL; + const char *cstr = NULL; herr_t retVal = FAIL; UNUSED(clss); @@ -709,10 +709,9 @@ done: * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Punregister - (JNIEnv *env, jclass clss, jlong plid, jstring name) +Java_hdf_hdf5lib_H5_H5Punregister(JNIEnv *env, jclass clss, jlong plid, jstring name) { - const char *cstr = NULL; + const char *cstr = NULL; herr_t retVal = FAIL; UNUSED(clss); @@ -738,8 +737,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Pclose_1class - (JNIEnv *env, jclass clss, jlong plid) +Java_hdf_hdf5lib_H5__1H5Pclose_1class(JNIEnv *env, jclass clss, jlong plid) { herr_t retVal = FAIL; @@ -753,13 +751,12 @@ done: } /* end Java_hdf_hdf5lib_H5__1H5Pclose_1class */ static herr_t -H5P_cls_create_cb - (hid_t prop_id, void *create_data) +H5P_cls_create_cb(hid_t prop_id, void *create_data) { - jmethodID mid; - JNIEnv *cbenv = NULL; - jclass cls; - jint status = -1; + jmethodID mid; + JNIEnv * cbenv = NULL; + jclass cls; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -769,7 +766,8 @@ H5P_cls_create_cb if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, create_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLhdf/hdf5lib/callbacks/H5P_cls_create_func_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", + "(JLhdf/hdf5lib/callbacks/H5P_cls_create_func_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); status = CBENVPTR->CallIntMethod(CBENVONLY, create_callback, mid, prop_id, create_data); @@ -783,13 +781,12 @@ done: } /* end H5P_cls_create_cb */ static herr_t -H5P_cls_copy_cb - (hid_t new_prop_id, hid_t old_prop_id, void *copy_data) +H5P_cls_copy_cb(hid_t new_prop_id, hid_t old_prop_id, void *copy_data) { - jmethodID mid; - JNIEnv *cbenv = NULL; - jclass cls; - jint status = -1; + jmethodID mid; + JNIEnv * cbenv = NULL; + jclass cls; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -799,7 +796,8 @@ H5P_cls_copy_cb if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, copy_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JJLhdf/hdf5lib/callbacks/H5P_cls_copy_func_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", + "(JJLhdf/hdf5lib/callbacks/H5P_cls_copy_func_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); status = CBENVPTR->CallIntMethod(CBENVONLY, copy_callback, mid, new_prop_id, old_prop_id, copy_data); @@ -813,13 +811,12 @@ done: } /* end H5P_cls_copy_cb */ static herr_t -H5P_cls_close_cb - (hid_t prop_id, void *close_data) +H5P_cls_close_cb(hid_t prop_id, void *close_data) { - jmethodID mid; - JNIEnv *cbenv = NULL; - jclass cls; - jint status = -1; + jmethodID mid; + JNIEnv * cbenv = NULL; + jclass cls; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -829,7 +826,8 @@ H5P_cls_close_cb if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, close_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLhdf/hdf5lib/callbacks/H5P_cls_close_func_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", + "(JLhdf/hdf5lib/callbacks/H5P_cls_close_func_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); status = CBENVPTR->CallIntMethod(CBENVONLY, close_callback, mid, prop_id, close_data); @@ -843,14 +841,13 @@ done: } /* end H5P_cls_close_cb */ static herr_t -H5P_prp_create_cb - (const char *name, size_t size, void *value) +H5P_prp_create_cb(const char *name, size_t size, void *value) { - jmethodID mid; - jstring str; - jclass cls; - JNIEnv *cbenv = NULL; - jint status = -1; + jmethodID mid; + jstring str; + jclass cls; + JNIEnv * cbenv = NULL; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -877,14 +874,13 @@ done: } /* end H5P_prp_create_cb */ static herr_t -H5P_prp_set_cb - (hid_t prop_id, const char *name, size_t size, void *value) +H5P_prp_set_cb(hid_t prop_id, const char *name, size_t size, void *value) { - jmethodID mid; - jstring str; - jclass cls; - JNIEnv *cbenv = NULL; - jint status = -1; + jmethodID mid; + jstring str; + jclass cls; + JNIEnv * cbenv = NULL; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -911,14 +907,13 @@ done: } /* end H5P_prp_set_cb */ static herr_t -H5P_prp_get_cb - (hid_t prop_id, const char *name, size_t size, void *value) +H5P_prp_get_cb(hid_t prop_id, const char *name, size_t size, void *value) { - jmethodID mid; - jstring str; - jclass cls; - JNIEnv *cbenv = NULL; - jint status = -1; + jmethodID mid; + jstring str; + jclass cls; + JNIEnv * cbenv = NULL; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -945,14 +940,13 @@ done: } /* end H5P_prp_get_cb */ static herr_t -H5P_prp_delete_cb - (hid_t prop_id, const char *name, size_t size, void *value) +H5P_prp_delete_cb(hid_t prop_id, const char *name, size_t size, void *value) { - jmethodID mid; - jstring str; - jclass cls; - JNIEnv *cbenv = NULL; - jint status = -1; + jmethodID mid; + jstring str; + jclass cls; + JNIEnv * cbenv = NULL; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -979,14 +973,13 @@ done: } /* end H5P_prp_delete_cb */ static herr_t -H5P_prp_copy_cb - (const char *name, size_t size, void *value) +H5P_prp_copy_cb(const char *name, size_t size, void *value) { - jmethodID mid; - jstring str; - jclass cls; - JNIEnv *cbenv = NULL; - jint status = -1; + jmethodID mid; + jstring str; + jclass cls; + JNIEnv * cbenv = NULL; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -1013,13 +1006,12 @@ done: } /* end H5P_prp_copy_cb */ static int -H5P_prp_compare_cb - (void *value1, void *value2, size_t size) +H5P_prp_compare_cb(void *value1, void *value2, size_t size) { - jmethodID mid; - jclass cls; - JNIEnv *cbenv = NULL; - jint status = -1; + jmethodID mid; + jclass cls; + JNIEnv * cbenv = NULL; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -1043,14 +1035,13 @@ done: } /* end H5P_prp_compare_cb */ static herr_t -H5P_prp_close_cb - (const char *name, size_t size, void *value) +H5P_prp_close_cb(const char *name, size_t size, void *value) { - jmethodID mid; - jstring str; - jclass cls; - JNIEnv *cbenv = NULL; - jint status = -1; + jmethodID mid; + jstring str; + jclass cls; + JNIEnv * cbenv = NULL; + jint status = -1; if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); @@ -1077,19 +1068,18 @@ done: } /* end H5P_prp_close_cb */ static herr_t -H5P_iterate_cb - (hid_t prop_id, const char *name, void *cb_data) +H5P_iterate_cb(hid_t prop_id, const char *name, void *cb_data) { - cb_wrapper *wrapper = (cb_wrapper *) cb_data; + cb_wrapper *wrapper = (cb_wrapper *)cb_data; jmethodID mid; jobject visit_callback = wrapper->visit_callback; jstring str; jclass cls; - JNIEnv *cbenv = NULL; - void *op_data = (void *) wrapper->op_data; - jint status = -1; + JNIEnv * cbenv = NULL; + void * op_data = (void *)wrapper->op_data; + jint status = -1; - if (JVMPTR->AttachCurrentThread(JVMPAR, (void**)&cbenv, NULL) < 0) { + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_iterate_cb: failed to attach current thread to JVM"); } @@ -1097,7 +1087,8 @@ H5P_iterate_cb if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/callbacks/H5P_iterate_t;)I"))) + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", + "(JLjava/lang/String;Lhdf/hdf5lib/callbacks/H5P_iterate_t;)I"))) CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) diff --git a/java/src/jni/h5pImp.h b/java/src/jni/h5pImp.h index 8318be4..b35bf94 100644 --- a/java/src/jni/h5pImp.h +++ b/java/src/jni/h5pImp.h @@ -27,36 +27,28 @@ extern "C" { * Method: H5Pcreate * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcreate(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_class * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1class(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pcopy * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcopy -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcopy(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pclose * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Pclose -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Pclose(JNIEnv *, jclass, jlong); /* * TODO: H5Pencode @@ -69,182 +61,151 @@ Java_hdf_hdf5lib_H5__1H5Pclose /* * Class: hdf_hdf5lib_H5 * Method: _H5Pcreate_class - * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J + * Signature: + * (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate_1class - (JNIEnv*, jclass, jlong, jstring, jobject, jobject, jobject, jobject, jobject, jobject); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcreate_1class(JNIEnv *, jclass, jlong, jstring, jobject, + jobject, jobject, jobject, jobject, jobject); /* * Class: hdf_hdf5lib_H5 * Method: _H5Pcreate_class_nocb * Signature: (JLjava/lang/String;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb - (JNIEnv*, jclass, jlong, jstring); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Pregister2 - * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V + * Signature: + * (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pregister2 - (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray, jobject, jobject, jobject, jobject, jobject, jobject, jobject); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pregister2(JNIEnv *, jclass, jlong, jstring, jlong, jbyteArray, + jobject, jobject, jobject, jobject, jobject, jobject, + jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Pregister2_nocb * Signature: (JLjava/lang/String;J[B)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pregister2_1nocb - (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pregister2_1nocb(JNIEnv *, jclass, jlong, jstring, jlong, + jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pinsert2 - * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V + * Signature: + * (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pinsert2 - (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray, jobject, jobject, jobject, jobject, jobject, jobject); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pinsert2(JNIEnv *, jclass, jlong, jstring, jlong, jbyteArray, + jobject, jobject, jobject, jobject, jobject, jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Pinsert2_nocb * Signature: (JLjava/lang/String;J[B)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb - (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb(JNIEnv *, jclass, jlong, jstring, jlong, + jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset * Signature: (JLjava/lang/String;I)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pset -(JNIEnv *, jclass, jlong, jstring, jint); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pset(JNIEnv *, jclass, jlong, jstring, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pexist * Signature: (JLjava/lang/String;)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pexist -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pexist(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_size * Signature: (JLjava/lang/String;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1size -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1size(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_nprops * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nprops -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1nprops(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_class_name * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class_1name -(JNIEnv *, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1class_1name(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_class_parent * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class_1parent -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1class_1parent(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pisa_class * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pisa_1class -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pisa_1class(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Pequal * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pequal -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pequal(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Piterate * Signature: (J[ILjava/lang/Object;Ljava/lang/Object;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Piterate - (JNIEnv*, jclass, jlong, jintArray, jobject, jobject); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Piterate(JNIEnv *, jclass, jlong, jintArray, jobject, jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5Pcopy_prop * Signature: (JJLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pcopy_1prop -(JNIEnv *, jclass, jlong, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pcopy_1prop(JNIEnv *, jclass, jlong, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Premove * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Premove -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Premove(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Punregister * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Punregister -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Punregister(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: _H5Pclose_class * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Pclose_1class -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Pclose_1class(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pLAPLImp.c b/java/src/jni/h5pLAPLImp.c index 754bece..01b2bb1 100644 --- a/java/src/jni/h5pLAPLImp.c +++ b/java/src/jni/h5pLAPLImp.c @@ -37,8 +37,7 @@ extern "C" { * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1nlinks - (JNIEnv *env, jclass clss, jlong lapl_id, jlong nlinks) +Java_hdf_hdf5lib_H5_H5Pset_1nlinks(JNIEnv *env, jclass clss, jlong lapl_id, jlong nlinks) { herr_t retVal = FAIL; @@ -60,8 +59,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nlinks - (JNIEnv *env, jclass clss, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1nlinks(JNIEnv *env, jclass clss, jlong lapl_id) { size_t nlinks = 0; @@ -71,7 +69,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1nlinks H5_LIBRARY_ERROR(ENVONLY); done: - return (jlong) nlinks; + return (jlong)nlinks; } /* end Java_hdf_hdf5lib_H5_H5Pget_1nlinks */ /* @@ -88,11 +86,10 @@ done: * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix - (JNIEnv *env, jclass clss, jlong lapl_id, jstring prefix) +Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix(JNIEnv *env, jclass clss, jlong lapl_id, jstring prefix) { const char *linkPrefix = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -117,13 +114,12 @@ done: * Signature: (J[Ljava/lang/String;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix - (JNIEnv *env, jclass clss, jlong lapl_id, jobjectArray prefix) +Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix(JNIEnv *env, jclass clss, jlong lapl_id, jobjectArray prefix) { - ssize_t prefix_size = -1; - size_t size = 0; - char *pre = NULL; - jstring str = NULL; + ssize_t prefix_size = -1; + size_t size = 0; + char * pre = NULL; + jstring str = NULL; UNUSED(clss); @@ -133,16 +129,17 @@ Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix if ((prefix_size = H5Pget_elink_prefix((hid_t)lapl_id, (char *)NULL, size)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t) prefix_size + 1))) + if (NULL == (pre = (char *)HDmalloc(sizeof(char) * (size_t)prefix_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_elink_prefix: memory allocation failed"); - if (H5Pget_elink_prefix((hid_t)lapl_id, (char *)pre, (size_t) prefix_size + 1) < 0) + if (H5Pget_elink_prefix((hid_t)lapl_id, (char *)pre, (size_t)prefix_size + 1) < 0) H5_LIBRARY_ERROR(ENVONLY); pre[prefix_size] = '\0'; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pget_elink_prefix: out of memory - unable to construct string from UTF characters"); + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "H5Pget_elink_prefix: out of memory - unable to construct string from UTF characters"); } ENVPTR->SetObjectArrayElement(ENVONLY, prefix, 0, str); @@ -161,8 +158,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl - (JNIEnv *env, jclass clss, jlong lapl_id, jlong fapl_id) +Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl(JNIEnv *env, jclass clss, jlong lapl_id, jlong fapl_id) { herr_t retVal = FAIL; @@ -181,8 +177,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl - (JNIEnv *env, jclass clss, jlong lapl_id) +Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl(JNIEnv *env, jclass clss, jlong lapl_id) { hid_t retVal = H5I_INVALID_HID; @@ -201,8 +196,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags - (JNIEnv *env, jclass clss, jlong lapl_id, jint flags) +Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags(JNIEnv *env, jclass clss, jlong lapl_id, jint flags) { herr_t retVal = FAIL; @@ -212,7 +206,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags H5_LIBRARY_ERROR(ENVONLY); done: - return (jint) retVal; + return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags */ /* @@ -221,8 +215,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags - (JNIEnv *env, jclass clss, jlong lapl_id) +Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags(JNIEnv *env, jclass clss, jlong lapl_id) { unsigned flags; diff --git a/java/src/jni/h5pLAPLImp.h b/java/src/jni/h5pLAPLImp.h index 8efcfb5..c08e0c9 100644 --- a/java/src/jni/h5pLAPLImp.h +++ b/java/src/jni/h5pLAPLImp.h @@ -25,18 +25,14 @@ extern "C" { * Method: H5Pset_nlinks * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1nlinks -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1nlinks(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_nlinks * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nlinks -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1nlinks(JNIEnv *, jclass, jlong); /* * TODO: H5Pset_elink_cb @@ -51,54 +47,42 @@ Java_hdf_hdf5lib_H5_H5Pget_1nlinks * Method: H5Pset_elink_prefix * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix -(JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_elink_prefix * Signature: (J[Ljava/lang/String;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix -(JNIEnv *, jclass, jlong, jobjectArray); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix(JNIEnv *, jclass, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_elink_fapl * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Pget_elink_fapl * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_elink_acc_flags * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_elink_acc_flags * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pOCPLImp.c b/java/src/jni/h5pOCPLImp.c index 241842e..68fe471 100644 --- a/java/src/jni/h5pOCPLImp.c +++ b/java/src/jni/h5pOCPLImp.c @@ -37,8 +37,8 @@ extern "C" { * Signature: (JZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group - (JNIEnv *env, jclass clss, jlong lcpl_id, jboolean crt_intermed_group) +Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group(JNIEnv *env, jclass clss, jlong lcpl_id, + jboolean crt_intermed_group) { herr_t retVal = FAIL; @@ -57,8 +57,7 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group - (JNIEnv *env, jclass clss, jlong lcpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group(JNIEnv *env, jclass clss, jlong lcpl_id) { unsigned crt_intermed_group = 0; @@ -77,8 +76,7 @@ done: * Signature: (JZ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times - (JNIEnv *env, jclass clss, jlong objplid, jboolean track_times) +Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times(JNIEnv *env, jclass clss, jlong objplid, jboolean track_times) { hbool_t track = FALSE; @@ -99,11 +97,10 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times - (JNIEnv *env, jclass clss, jlong objplid) +Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times(JNIEnv *env, jclass clss, jlong objplid) { hbool_t track_times = FALSE; - jboolean retVal = JNI_FALSE; + jboolean retVal = JNI_FALSE; UNUSED(clss); @@ -122,8 +119,8 @@ done: * Signature: (JII)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change - (JNIEnv *env, jclass clss, jlong ocpl_id, jint max_compact, jint min_dense) +Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change(JNIEnv *env, jclass clss, jlong ocpl_id, jint max_compact, + jint min_dense) { herr_t retVal = FAIL; @@ -142,12 +139,11 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change - (JNIEnv *env, jclass clss, jlong ocpl_id, jintArray attributes) +Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change(JNIEnv *env, jclass clss, jlong ocpl_id, jintArray attributes) { - jboolean isCopy; - jint *theArray = NULL; - herr_t retVal = FAIL; + jboolean isCopy; + jint * theArray = NULL; + herr_t retVal = FAIL; UNUSED(clss); @@ -156,7 +152,8 @@ Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change PIN_INT_ARRAY(ENVONLY, attributes, theArray, &isCopy, "H5Pget_attr_phase_change: input not pinned"); - if ((retVal = H5Pget_attr_phase_change((hid_t)ocpl_id, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + if ((retVal = H5Pget_attr_phase_change((hid_t)ocpl_id, (unsigned *)&(theArray[0]), + (unsigned *)&(theArray[1]))) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -172,8 +169,8 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order - (JNIEnv *env, jclass clss, jlong ocpl_id, jint crt_order_flags) +Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order(JNIEnv *env, jclass clss, jlong ocpl_id, + jint crt_order_flags) { herr_t retVal = FAIL; @@ -192,8 +189,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order - (JNIEnv *env, jclass clss, jlong ocpl_id) +Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order(JNIEnv *env, jclass clss, jlong ocpl_id) { unsigned crt_order_flags = 0; diff --git a/java/src/jni/h5pOCPLImp.h b/java/src/jni/h5pOCPLImp.h index fe01f06..ad45ab9 100644 --- a/java/src/jni/h5pOCPLImp.h +++ b/java/src/jni/h5pOCPLImp.h @@ -25,72 +25,57 @@ extern "C" { * Method: H5Pset_create_intermediate_group * Signature: (JZ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group -(JNIEnv *, jclass, jlong, jboolean); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group(JNIEnv *, jclass, jlong, + jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_create_intermediate_group * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group -(JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_obj_track_times * Signature: (JZ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times -(JNIEnv *, jclass, jlong, jboolean); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times(JNIEnv *, jclass, jlong, jboolean); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_obj_track_times * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times -(JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_attr_phase_change * Signature: (JII)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change -(JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_attr_phase_change * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change -(JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Pset_attr_creation_order * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_attr_creation_order * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pOCpyPLImp.c b/java/src/jni/h5pOCpyPLImp.c index 9481f91..81664ce 100644 --- a/java/src/jni/h5pOCpyPLImp.c +++ b/java/src/jni/h5pOCpyPLImp.c @@ -37,8 +37,7 @@ extern "C" { * Signature: (JI)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1copy_1object - (JNIEnv *env, jclass clss, jlong ocp_plist_id, jint copy_options) +Java_hdf_hdf5lib_H5_H5Pset_1copy_1object(JNIEnv *env, jclass clss, jlong ocp_plist_id, jint copy_options) { herr_t retVal = FAIL; @@ -57,8 +56,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1copy_1object - (JNIEnv *env, jclass clss, jlong ocp_plist_id) +Java_hdf_hdf5lib_H5_H5Pget_1copy_1object(JNIEnv *env, jclass clss, jlong ocp_plist_id) { unsigned copy_options = 0; diff --git a/java/src/jni/h5pOCpyPLImp.h b/java/src/jni/h5pOCpyPLImp.h index f1dca58..662fba1 100644 --- a/java/src/jni/h5pOCpyPLImp.h +++ b/java/src/jni/h5pOCpyPLImp.h @@ -25,18 +25,14 @@ extern "C" { * Method: H5Pset_copy_object * Signature: (JI)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1copy_1object -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1copy_1object(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_copy_object * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1copy_1object -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1copy_1object(JNIEnv *, jclass, jlong); /* * TODO: H5Padd_merge_committed_dtype_path diff --git a/java/src/jni/h5pStrCPLImp.c b/java/src/jni/h5pStrCPLImp.c index e69847d..aceeb0b 100644 --- a/java/src/jni/h5pStrCPLImp.c +++ b/java/src/jni/h5pStrCPLImp.c @@ -37,8 +37,7 @@ extern "C" { * Signature: (JI)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding - (JNIEnv *env, jclass clss, jlong acpl, jint encoding) +Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding(JNIEnv *env, jclass clss, jlong acpl, jint encoding) { UNUSED(clss); @@ -55,8 +54,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding - (JNIEnv *env, jclass clss, jlong acpl) +Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding(JNIEnv *env, jclass clss, jlong acpl) { H5T_cset_t encoding = H5T_CSET_ERROR; diff --git a/java/src/jni/h5pStrCPLImp.h b/java/src/jni/h5pStrCPLImp.h index 6e140d3..1e89314 100644 --- a/java/src/jni/h5pStrCPLImp.h +++ b/java/src/jni/h5pStrCPLImp.h @@ -25,18 +25,14 @@ extern "C" { * Method: H5Pset_char_encoding * Signature: (JI)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding -(JNIEnv *, jclass, jlong, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Pget_char_encoding * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5plImp.c b/java/src/jni/h5plImp.c index ce42842..4d2743a 100644 --- a/java/src/jni/h5plImp.c +++ b/java/src/jni/h5plImp.c @@ -37,8 +37,7 @@ extern "C" { * Signature: (I)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLset_1loading_1state - (JNIEnv *env, jclass clss, jint plugin_flags) +Java_hdf_hdf5lib_H5_H5PLset_1loading_1state(JNIEnv *env, jclass clss, jint plugin_flags) { UNUSED(clss); @@ -55,8 +54,7 @@ done: * Signature: (V)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5PLget_1loading_1state - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5PLget_1loading_1state(JNIEnv *env, jclass clss) { unsigned int plugin_type = 0; @@ -75,11 +73,10 @@ done: * Signature: (Ljava/lang/String;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLappend - (JNIEnv *env, jclass clss, jobjectArray plugin_path) +Java_hdf_hdf5lib_H5_H5PLappend(JNIEnv *env, jclass clss, jobjectArray plugin_path) { const char *newPath = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -101,11 +98,10 @@ done: * Signature: (Ljava/lang/String;)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLprepend - (JNIEnv *env, jclass clss, jobjectArray plugin_path) +Java_hdf_hdf5lib_H5_H5PLprepend(JNIEnv *env, jclass clss, jobjectArray plugin_path) { const char *newPath = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -128,11 +124,10 @@ done: * Signature: (Ljava/lang/String;I)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLreplace - (JNIEnv *env, jclass clss, jobjectArray plugin_path, jint idx) +Java_hdf_hdf5lib_H5_H5PLreplace(JNIEnv *env, jclass clss, jobjectArray plugin_path, jint idx) { const char *newPath = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -144,7 +139,7 @@ Java_hdf_hdf5lib_H5_H5PLreplace PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLreplace: new path not pinned"); - if ((retVal = H5PLreplace(newPath, (unsigned) idx)) < 0) + if ((retVal = H5PLreplace(newPath, (unsigned)idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -158,11 +153,10 @@ done: * Signature: (Ljava/lang/String;I)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLinsert - (JNIEnv *env, jclass clss, jobjectArray plugin_path, jint idx) +Java_hdf_hdf5lib_H5_H5PLinsert(JNIEnv *env, jclass clss, jobjectArray plugin_path, jint idx) { const char *newPath = NULL; - herr_t retVal = FAIL; + herr_t retVal = FAIL; UNUSED(clss); @@ -174,7 +168,7 @@ Java_hdf_hdf5lib_H5_H5PLinsert PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLinsert: new path not pinned"); - if ((retVal = H5PLinsert(newPath, (unsigned) idx)) < 0) + if ((retVal = H5PLinsert(newPath, (unsigned)idx)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -188,15 +182,14 @@ done: * Signature: (I)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLremove - (JNIEnv *env, jclass clss, jint idx) +Java_hdf_hdf5lib_H5_H5PLremove(JNIEnv *env, jclass clss, jint idx) { UNUSED(clss); if (idx < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLremove: index < 0"); - if (H5PLremove((unsigned) idx) < 0) + if (H5PLremove((unsigned)idx) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -209,12 +202,11 @@ done: * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5PLget - (JNIEnv *env, jclass clss, jint idx) +Java_hdf_hdf5lib_H5_H5PLget(JNIEnv *env, jclass clss, jint idx) { - jstring str = NULL; - ssize_t buf_size; - char *aName = NULL; + jstring str = NULL; + ssize_t buf_size; + char * aName = NULL; UNUSED(clss); @@ -222,13 +214,13 @@ Java_hdf_hdf5lib_H5_H5PLget H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLget: index < 0"); /* Get the length of the name */ - if ((buf_size = H5PLget((unsigned) idx, NULL, 0)) < 0) + if ((buf_size = H5PLget((unsigned)idx, NULL, 0)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + if (NULL == (aName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5PLget: failed to allocate plugin name buffer"); - if ((H5PLget((unsigned) idx, aName, (size_t)buf_size + 1)) < 0) + if ((H5PLget((unsigned)idx, aName, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); aName[buf_size] = '\0'; @@ -248,8 +240,7 @@ done: * Signature: (V)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5PLsize - (JNIEnv *env, jclass clss) +Java_hdf_hdf5lib_H5_H5PLsize(JNIEnv *env, jclass clss) { unsigned int listsize = 0; diff --git a/java/src/jni/h5plImp.h b/java/src/jni/h5plImp.h index 5336621..82b0699 100644 --- a/java/src/jni/h5plImp.h +++ b/java/src/jni/h5plImp.h @@ -26,81 +26,63 @@ extern "C" { * Method: H5PLset_loading_state * Signature: (I)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLset_1loading_1state - (JNIEnv *, jclass, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLset_1loading_1state(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5PLget_loading_state * Signature: (V)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5PLget_1loading_1state - (JNIEnv *, jclass); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5PLget_1loading_1state(JNIEnv *, jclass); /* * Class: hdf_hdf5lib_H5 * Method: H5PLappend * Signature: (Ljava/lang/String;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLappend - (JNIEnv *, jclass, jobjectArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLappend(JNIEnv *, jclass, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5PLprepend * Signature: (Ljava/lang/String;)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLprepend - (JNIEnv *, jclass, jobjectArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLprepend(JNIEnv *, jclass, jobjectArray); /* * Class: hdf_hdf5lib_H5 * Method: H5PLreplace * Signature: (Ljava/lang/String;I)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLreplace - (JNIEnv *, jclass, jobjectArray, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLreplace(JNIEnv *, jclass, jobjectArray, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5PLinsert * Signature: (Ljava/lang/String;I)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLinsert - (JNIEnv *, jclass, jobjectArray, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLinsert(JNIEnv *, jclass, jobjectArray, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5PLremove * Signature: (I)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5PLremove - (JNIEnv *, jclass, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLremove(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5PLget * Signature: (I)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5PLget - (JNIEnv *, jclass, jint); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5PLget(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5PLsize * Signature: (V)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5PLsize - (JNIEnv *, jclass); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5PLsize(JNIEnv *, jclass); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c index e24fc2a..abdd8a1 100644 --- a/java/src/jni/h5rImp.c +++ b/java/src/jni/h5rImp.c @@ -26,7 +26,6 @@ extern "C" { #include "h5jni.h" #include "h5rImp.h" - /* H5R: HDF5 1.12 Reference API Functions */ /* @@ -35,13 +34,12 @@ extern "C" { * Signature: (JLjava/lang/String;)[B */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Rcreate_1object - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong aid) +Java_hdf_hdf5lib_H5_H5Rcreate_1object(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong aid) { const char *refName = NULL; - jbyteArray ref = NULL; - jbyte *refBuf = NULL; - herr_t status = FAIL; + jbyteArray ref = NULL; + jbyte * refBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -71,20 +69,19 @@ done: return ref; } /* end Java_hdf_hdf5lib_H5_H5Rcreate_1object */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Rcreate_region * Signature: (JLjava/lang/String;J)[B */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Rcreate_1region - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong space_id, jlong aid) +Java_hdf_hdf5lib_H5_H5Rcreate_1region(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong space_id, + jlong aid) { const char *refName = NULL; - jbyteArray ref = NULL; - jbyte *refBuf = NULL; - herr_t status = FAIL; + jbyteArray ref = NULL; + jbyte * refBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -96,7 +93,8 @@ Java_hdf_hdf5lib_H5_H5Rcreate_1region if (NULL == (refBuf = HDcalloc(1, H5R_REF_BUF_SIZE))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rcreate_region: failed to allocate reference buffer"); - if ((status = H5Rcreate_region((hid_t)loc_id, refName, space_id, (hid_t)aid, (const H5R_ref_t *)refBuf)) < 0) + if ((status = H5Rcreate_region((hid_t)loc_id, refName, space_id, (hid_t)aid, (const H5R_ref_t *)refBuf)) < + 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (ref = ENVPTR->NewByteArray(ENVONLY, (jsize)H5R_REF_BUF_SIZE))) @@ -120,14 +118,14 @@ done: * Signature: (JLjava/lang/String;Ljava/lang/String;)[B */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Rcreate_1attr - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jstring attr_name, jlong aid) +Java_hdf_hdf5lib_H5_H5Rcreate_1attr(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jstring attr_name, + jlong aid) { - const char *refName = NULL; + const char *refName = NULL; const char *attrName = NULL; - jbyteArray ref = NULL; - jbyte *refBuf = NULL; - herr_t status = FAIL; + jbyteArray ref = NULL; + jbyte * refBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -143,7 +141,8 @@ Java_hdf_hdf5lib_H5_H5Rcreate_1attr if (NULL == (refBuf = HDcalloc(1, H5R_REF_BUF_SIZE))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rcreate_attr: failed to allocate reference buffer"); - if ((status = H5Rcreate_attr((hid_t)loc_id, refName, attrName, (hid_t)aid, (const H5R_ref_t *)refBuf)) < 0) + if ((status = H5Rcreate_attr((hid_t)loc_id, refName, attrName, (hid_t)aid, (const H5R_ref_t *)refBuf)) < + 0) H5_LIBRARY_ERROR(ENVONLY); if (NULL == (ref = ENVPTR->NewByteArray(ENVONLY, (jsize)H5R_REF_BUF_SIZE))) @@ -169,13 +168,12 @@ done: * Signature: ([B)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Rdestroy - (JNIEnv *env, jclass clss, jbyteArray ref) +Java_hdf_hdf5lib_H5_H5Rdestroy(JNIEnv *env, jclass clss, jbyteArray ref) { - jboolean isCopy; - jbyte *refBuf = NULL; - jsize refBufLen; - herr_t status = FAIL; + jboolean isCopy; + jbyte * refBuf = NULL; + jsize refBufLen; + herr_t status = FAIL; UNUSED(clss); @@ -203,13 +201,12 @@ done: * Signature: ([B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1type - (JNIEnv *env, jclass clss, jbyteArray ref) +Java_hdf_hdf5lib_H5_H5Rget_1type(JNIEnv *env, jclass clss, jbyteArray ref) { - jboolean isCopy; - jbyte *refBuf = NULL; - jsize refBufLen; - H5R_type_t ref_type = -1; + jboolean isCopy; + jbyte * refBuf = NULL; + jsize refBufLen; + H5R_type_t ref_type = -1; UNUSED(clss); @@ -239,15 +236,14 @@ done: * Signature: ([B[B)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Requal - (JNIEnv *env, jclass clss, jbyteArray ref1, jbyteArray ref2) +Java_hdf_hdf5lib_H5_H5Requal(JNIEnv *env, jclass clss, jbyteArray ref1, jbyteArray ref2) { - jboolean isCopy; - jbyte *refBuf1 = NULL; - jbyte *refBuf2 = NULL; - jsize refBufLen; - htri_t bval = JNI_FALSE; - herr_t status = FAIL; + jboolean isCopy; + jbyte * refBuf1 = NULL; + jbyte * refBuf2 = NULL; + jsize refBufLen; + htri_t bval = JNI_FALSE; + herr_t status = FAIL; UNUSED(clss); @@ -292,15 +288,14 @@ done: * Signature: ([B)[B */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Rcopy - (JNIEnv *env, jclass clss, jbyteArray src_ref) +Java_hdf_hdf5lib_H5_H5Rcopy(JNIEnv *env, jclass clss, jbyteArray src_ref) { - jboolean isCopy; - jbyte *src_refBuf = NULL; - jsize refBufLen; - jbyteArray dst_ref = NULL; - jbyte *dst_refBuf = NULL; - herr_t status = FAIL; + jboolean isCopy; + jbyte * src_refBuf = NULL; + jsize refBufLen; + jbyteArray dst_ref = NULL; + jbyte * dst_refBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -341,13 +336,12 @@ done: * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1object - (JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) +Java_hdf_hdf5lib_H5_H5Ropen_1object(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) { - jboolean isCopy; - jbyte *refBuf = NULL; - jsize refBufLen; - hid_t retVal = H5I_INVALID_HID; + jboolean isCopy; + jbyte * refBuf = NULL; + jsize refBufLen; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -377,13 +371,12 @@ done: * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1region - (JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) +Java_hdf_hdf5lib_H5_H5Ropen_1region(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) { - jboolean isCopy; - jbyte *refBuf = NULL; - jsize refBufLen; - hid_t retVal = H5I_INVALID_HID; + jboolean isCopy; + jbyte * refBuf = NULL; + jsize refBufLen; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -413,13 +406,12 @@ done: * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1attr - (JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong aapl_id) +Java_hdf_hdf5lib_H5_H5Ropen_1attr(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong aapl_id) { - jboolean isCopy; - jbyte *refBuf = NULL; - jsize refBufLen; - hid_t retVal = H5I_INVALID_HID; + jboolean isCopy; + jbyte * refBuf = NULL; + jsize refBufLen; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -449,13 +441,12 @@ done: * Signature: ([BJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1obj_1type3 - (JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id) +Java_hdf_hdf5lib_H5_H5Rget_1obj_1type3(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id) { - H5O_type_t object_info = -1; - jboolean isCopy; - jbyte *refBuf = NULL; - int retVal = -1; + H5O_type_t object_info = -1; + jboolean isCopy; + jbyte * refBuf = NULL; + int retVal = -1; UNUSED(clss); @@ -483,15 +474,14 @@ done: * Signature: ([B)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1file_1name - (JNIEnv *env, jclass clss, jbyteArray ref) +Java_hdf_hdf5lib_H5_H5Rget_1file_1name(JNIEnv *env, jclass clss, jbyteArray ref) { - jboolean isCopy; - jbyte *refBuf = NULL; - jstring str = NULL; - ssize_t buf_size; - ssize_t check_size = -1; - char *namePtr = NULL; + jboolean isCopy; + jbyte * refBuf = NULL; + jstring str = NULL; + ssize_t buf_size; + ssize_t check_size = -1; + char * namePtr = NULL; UNUSED(clss); @@ -529,15 +519,14 @@ done: * Signature: ([BJ)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1obj_1name - (JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id) +Java_hdf_hdf5lib_H5_H5Rget_1obj_1name(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id) { - jboolean isCopy; - jbyte *refBuf = NULL; - jstring str = NULL; - ssize_t buf_size; - ssize_t check_size = -1; - char *namePtr = NULL; + jboolean isCopy; + jbyte * refBuf = NULL; + jstring str = NULL; + ssize_t buf_size; + ssize_t check_size = -1; + char * namePtr = NULL; UNUSED(clss); @@ -553,7 +542,8 @@ Java_hdf_hdf5lib_H5_H5Rget_1obj_1name if (NULL == (namePtr = HDmalloc(sizeof(char) * (size_t)buf_size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rget_obj_name: malloc failed"); - if ((check_size = H5Rget_obj_name((const H5R_ref_t *)refBuf, (hid_t)rapl_id, namePtr, (size_t)buf_size + 1)) < 0) + if ((check_size = + H5Rget_obj_name((const H5R_ref_t *)refBuf, (hid_t)rapl_id, namePtr, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); namePtr[buf_size] = '\0'; @@ -575,15 +565,14 @@ done: * Signature: ([B)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1attr_1name - (JNIEnv *env, jclass clss, jbyteArray ref) +Java_hdf_hdf5lib_H5_H5Rget_1attr_1name(JNIEnv *env, jclass clss, jbyteArray ref) { - jboolean isCopy; - jbyte *refBuf = NULL; - jstring str = NULL; - ssize_t buf_size; - ssize_t check_size = -1; - char *namePtr = NULL; + jboolean isCopy; + jbyte * refBuf = NULL; + jstring str = NULL; + ssize_t buf_size; + ssize_t check_size = -1; + char * namePtr = NULL; UNUSED(clss); @@ -623,12 +612,12 @@ done: * Signature: ([BJLjava/lang/String;IJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rcreate - (JNIEnv *env, jclass clss, jbyteArray ref, jlong loc_id, jstring name, jint ref_type, jlong space_id) +Java_hdf_hdf5lib_H5_H5Rcreate(JNIEnv *env, jclass clss, jbyteArray ref, jlong loc_id, jstring name, + jint ref_type, jlong space_id) { const char *refName = NULL; jboolean isCopy; - jbyte *refBuf = NULL; + jbyte * refBuf = NULL; jsize refBufLen; herr_t status = FAIL; @@ -647,7 +636,8 @@ Java_hdf_hdf5lib_H5_H5Rcreate if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "H5Rcreate: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: unknown reference type"); @@ -673,13 +663,13 @@ done: * Signature: (JJI[B)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Rdereference - (JNIEnv *env, jclass clss, jlong dataset, jlong access_list, jint ref_type, jbyteArray ref) +Java_hdf_hdf5lib_H5__1H5Rdereference(JNIEnv *env, jclass clss, jlong dataset, jlong access_list, + jint ref_type, jbyteArray ref) { - jboolean isCopy; - jbyte *refBuf = NULL; - jsize refBufLen; - hid_t retVal = H5I_INVALID_HID; + jboolean isCopy; + jbyte * refBuf = NULL; + jsize refBufLen; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -692,9 +682,11 @@ Java_hdf_hdf5lib_H5__1H5Rdereference } if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: reference input array length != H5R_OBJ_REF_BUF_SIZE"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "H5Rdereference: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, "H5Rdereference: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: unknown reference type"); @@ -716,13 +708,12 @@ done: * Signature: (JI[B)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Rget_1region - (JNIEnv *env, jclass clss, jlong dataset, jint ref_type, jbyteArray ref) +Java_hdf_hdf5lib_H5__1H5Rget_1region(JNIEnv *env, jclass clss, jlong dataset, jint ref_type, jbyteArray ref) { - jboolean isCopy; - jbyte *refBuf = NULL; - jsize refBufLen; - hid_t retVal = H5I_INVALID_HID; + jboolean isCopy; + jbyte * refBuf = NULL; + jsize refBufLen; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -737,7 +728,8 @@ Java_hdf_hdf5lib_H5__1H5Rget_1region } if (refBufLen != H5R_DSET_REG_REF_BUF_SIZE) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_region: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, "H5Rget_region: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_region: reference buffer not pinned"); @@ -757,13 +749,12 @@ done: * Signature: (JI[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1obj_1type - (JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref) +Java_hdf_hdf5lib_H5_H5Rget_1obj_1type(JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref) { - H5O_type_t object_info; - jboolean isCopy; - jbyte *refBuf = NULL; - int retVal = -1; + H5O_type_t object_info; + jboolean isCopy; + jbyte * refBuf = NULL; + int retVal = -1; UNUSED(clss); @@ -791,14 +782,14 @@ done: * Signature: (JI[B[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2 - (JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, jintArray ref_obj) +Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2(JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, + jintArray ref_obj) { - jboolean isCopy, isCopy2; - jbyte *refBuf = NULL; - jint *ref_objP = NULL; - jint status = -1; - int retVal = -1; + jboolean isCopy, isCopy2; + jbyte * refBuf = NULL; + jint * ref_objP = NULL; + jint status = -1; + int retVal = -1; UNUSED(clss); @@ -831,15 +822,15 @@ done: * Signature: (JI[B[Ljava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1name - (JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, jobjectArray name, jlong size) +Java_hdf_hdf5lib_H5_H5Rget_1name(JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, + jobjectArray name, jlong size) { - jboolean isCopy; - jstring str; - jsize refBufLen; - jbyte *refBuf = NULL; - char *aName = NULL; - jlong ret_val = -1; + jboolean isCopy; + jstring str; + jsize refBufLen; + jbyte * refBuf = NULL; + char * aName = NULL; + jlong ret_val = -1; UNUSED(clss); @@ -856,7 +847,8 @@ Java_hdf_hdf5lib_H5_H5Rget_1name if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: reference input array length != H5R_OBJ_REF_BUF_SIZE"); else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, "H5Rget_name: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: unknown reference type"); @@ -865,14 +857,15 @@ Java_hdf_hdf5lib_H5_H5Rget_1name if (NULL == (aName = HDmalloc(sizeof(char) * (size_t)size + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Rget_name: failed to allocate referenced object name buffer"); - if ((ret_val = (jlong)H5Rget_name((hid_t)loc_id, (H5R_type_t)ref_type, refBuf, aName, (size_t)size + 1)) < 0) + if ((ret_val = (jlong)H5Rget_name((hid_t)loc_id, (H5R_type_t)ref_type, refBuf, aName, (size_t)size + 1)) < + 0) H5_LIBRARY_ERROR(ENVONLY); aName[(size_t)size] = '\0'; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - ENVPTR->SetObjectArrayElement(ENVONLY, name, (jsize) 0, str); + ENVPTR->SetObjectArrayElement(ENVONLY, name, (jsize)0, str); CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); done: @@ -884,7 +877,6 @@ done: return ret_val; } /* end Java_hdf_hdf5lib_H5_H5Rget_1name */ - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5rImp.h b/java/src/jni/h5rImp.h index 3bdb266..d0c5e3b 100644 --- a/java/src/jni/h5rImp.h +++ b/java/src/jni/h5rImp.h @@ -28,126 +28,100 @@ extern "C" { * Method: H5Rcreate_object * Signature: (JLjava/lang/String;)[B */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Rcreate_1object - (JNIEnv *, jclass, jlong, jstring, jlong); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Rcreate_1object(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Rcreate_region * Signature: (JLjava/lang/String;J)[B */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Rcreate_1region - (JNIEnv *, jclass, jlong, jstring, jlong, jlong); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Rcreate_1region(JNIEnv *, jclass, jlong, jstring, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Rcreate_attr * Signature: (JLjava/lang/String;Ljava/lang/String;)[B */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Rcreate_1attr - (JNIEnv *, jclass, jlong, jstring, jstring, jlong); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Rcreate_1attr(JNIEnv *, jclass, jlong, jstring, jstring, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Rdestroy * Signature: ([B)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Rdestroy - (JNIEnv *, jclass, jbyteArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Rdestroy(JNIEnv *, jclass, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Rget_type * Signature: ([B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1type - (JNIEnv *, jclass, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rget_1type(JNIEnv *, jclass, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Requal * Signature: ([B[B)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Requal - (JNIEnv *, jclass, jbyteArray, jbyteArray); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Requal(JNIEnv *, jclass, jbyteArray, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Rcopy * Signature: ([B)[B */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Rcopy - (JNIEnv *, jclass, jbyteArray); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Rcopy(JNIEnv *, jclass, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Ropen_object * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1object - (JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1object(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ropen_region * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1region - (JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1region(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ropen_attr * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1attr - (JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1attr(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Rget_obj_type3 * Signature: ([BJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1obj_1type3 - (JNIEnv *, jclass, jbyteArray, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rget_1obj_1type3(JNIEnv *, jclass, jbyteArray, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Rget_file_name * Signature: ([B)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1file_1name - (JNIEnv *, jclass, jbyteArray); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Rget_1file_1name(JNIEnv *, jclass, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Rget_obj_name * Signature: ([BJ)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1obj_1name - (JNIEnv *, jclass, jbyteArray, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Rget_1obj_1name(JNIEnv *, jclass, jbyteArray, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Rget_attr_name * Signature: ([B)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1attr_1name - (JNIEnv *, jclass, jbyteArray); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Rget_1attr_1name(JNIEnv *, jclass, jbyteArray); /* H5R: HDF5 1.8 Reference API Functions */ @@ -156,54 +130,46 @@ Java_hdf_hdf5lib_H5_H5Rget_1attr_1name * Method: H5Rcreate * Signature: ([BJLjava/lang/String;IJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rcreate - (JNIEnv *, jclass, jbyteArray, jlong, jstring, jint, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rcreate(JNIEnv *, jclass, jbyteArray, jlong, jstring, jint, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Rdereference * Signature: (JJI[B)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Rdereference - (JNIEnv *, jclass, jlong, jlong, jint, jbyteArray); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Rdereference(JNIEnv *, jclass, jlong, jlong, jint, + jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Rget_region * Signature: (JI[B)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Rget_1region - (JNIEnv *, jclass, jlong, jint, jbyteArray); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Rget_1region(JNIEnv *, jclass, jlong, jint, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5G_obj_t H5Rget_obj_type * Signature: (JI[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1obj_1type - (JNIEnv *, jclass, jlong, jint, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rget_1obj_1type(JNIEnv *, jclass, jlong, jint, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: int H5Rget_obj_type2 * Signature: (JI[B[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2 - (JNIEnv *, jclass, jlong, jint, jbyteArray, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2(JNIEnv *, jclass, jlong, jint, jbyteArray, + jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Rget_name * Signature: (JI[B[Ljava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Rget_1name - (JNIEnv *, jclass, jlong, jint, jbyteArray, jobjectArray, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Rget_1name(JNIEnv *, jclass, jlong, jint, jbyteArray, + jobjectArray, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c index 3498392..2a9cff5 100644 --- a/java/src/jni/h5sImp.c +++ b/java/src/jni/h5sImp.c @@ -37,14 +37,13 @@ extern "C" { * Signature: (I)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Screate - (JNIEnv *env, jclass clss, jint type) +Java_hdf_hdf5lib_H5__1H5Screate(JNIEnv *env, jclass clss, jint type) { hid_t retVal = H5I_INVALID_HID; UNUSED(clss); - if ((retVal = H5Screate((H5S_class_t) type)) < 0) + if ((retVal = H5Screate((H5S_class_t)type)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -57,18 +56,18 @@ done: * Signature: (I[J[J)G */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Screate_1simple - (JNIEnv *env, jclass clss, jint rank, jlongArray dims, jlongArray maxdims) +Java_hdf_hdf5lib_H5__1H5Screate_1simple(JNIEnv *env, jclass clss, jint rank, jlongArray dims, + jlongArray maxdims) { - jboolean isCopy; - hsize_t *sa = NULL; - hsize_t *msa = NULL; - hsize_t *lp = NULL; - jlong *dimsP = NULL, *maxdimsP = NULL; - jlong *jlp = NULL; - jsize drank = 0, mrank = 0; - int i; - hid_t retVal = H5I_INVALID_HID; + jboolean isCopy; + hsize_t *sa = NULL; + hsize_t *msa = NULL; + hsize_t *lp = NULL; + jlong * dimsP = NULL, *maxdimsP = NULL; + jlong * jlp = NULL; + jsize drank = 0, mrank = 0; + int i; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -97,29 +96,29 @@ Java_hdf_hdf5lib_H5__1H5Screate_1simple PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Screate_simple: dims not pinned"); - if (NULL == (sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + if (NULL == (sa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Screate_simple: failed to allocate dims buffer"); - jlp = (jlong *) dimsP; + jlp = (jlong *)dimsP; for (i = 0; i < rank; i++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end for */ if (NULL == maxdims) { maxdimsP = NULL; - msa = (hsize_t *)maxdimsP; + msa = (hsize_t *)maxdimsP; } else { PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Screate_simple: maxdims not pinned"); - if (NULL == (msa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + if (NULL == (msa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Screate_simple: failed to allocate maxdims buffer"); - jlp = (jlong *) maxdimsP; + jlp = (jlong *)maxdimsP; for (i = 0; i < mrank; i++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end for */ @@ -147,8 +146,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Scopy - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5__1H5Scopy(JNIEnv *env, jclass clss, jlong space_id) { hid_t retVal = H5I_INVALID_HID; @@ -177,12 +175,12 @@ done: * Signature: (JII[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1elements - (JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, jlongArray coords) +Java_hdf_hdf5lib_H5_H5Sselect_1elements(JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, + jlongArray coords) { jboolean isCopy; hssize_t *sa = NULL; - jlong *P = NULL; + jlong * P = NULL; jint i; int rank; herr_t status = FAIL; @@ -194,7 +192,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements PIN_LONG_ARRAY(ENVONLY, coords, P, &isCopy, "H5Sselect_elements: coords not pinned"); - if (NULL == (sa = (hssize_t *) HDmalloc( (size_t)num_elemn * 2 * sizeof(hssize_t)))) + if (NULL == (sa = (hssize_t *)HDmalloc((size_t)num_elemn * 2 * sizeof(hssize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); for (i = 0; i < (num_elemn * 2); i++) { @@ -220,18 +218,18 @@ done: * Signature: (JII[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1elements - (JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, jbyteArray coords) +Java_hdf_hdf5lib_H5_H5Sselect_1elements(JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, + jbyteArray coords) { - jboolean isCopy; - hsize_t *lp = NULL; - hsize_t *llp = NULL; - jlong *jlp = NULL; - jbyte *P = NULL; - jsize size; - int ii; - int nlongs; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *lp = NULL; + hsize_t *llp = NULL; + jlong * jlp = NULL; + jbyte * P = NULL; + jsize size; + int ii; + int nlongs; + herr_t status = FAIL; UNUSED(clss); @@ -247,18 +245,19 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements nlongs = (int)((size_t)size / sizeof(jlong)); - if (NULL == (lp = (hsize_t *) HDmalloc((size_t)nlongs * sizeof(hsize_t)))) + if (NULL == (lp = (hsize_t *)HDmalloc((size_t)nlongs * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); - jlp = (jlong *) P; + jlp = (jlong *)P; llp = lp; for (ii = 0; ii < nlongs; ii++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end for */ - if ((status = H5Sselect_elements(space_id, (H5S_seloper_t)op, (size_t)num_elemn, (const hsize_t *)llp)) < 0) + if ((status = H5Sselect_elements(space_id, (H5S_seloper_t)op, (size_t)num_elemn, (const hsize_t *)llp)) < + 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -276,8 +275,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1all - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sselect_1all(JNIEnv *env, jclass clss, jlong space_id) { herr_t retVal = FAIL; @@ -287,7 +285,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1all H5_LIBRARY_ERROR(ENVONLY); done: - return (jint) retVal; + return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1all */ /* @@ -296,8 +294,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1none - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sselect_1none(JNIEnv *env, jclass clss, jlong space_id) { herr_t retVal = FAIL; @@ -307,7 +304,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1none H5_LIBRARY_ERROR(ENVONLY); done: - return (jint) retVal; + return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1none */ /* @@ -316,8 +313,7 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1valid - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sselect_1valid(JNIEnv *env, jclass clss, jlong space_id) { htri_t bval = JNI_FALSE; @@ -338,8 +334,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints(JNIEnv *env, jclass clss, jlong space_id) { hssize_t retVal = -1; @@ -349,7 +344,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints H5_LIBRARY_ERROR(ENVONLY); done: - return (jlong) retVal; + return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints */ /* @@ -358,8 +353,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints(JNIEnv *env, jclass clss, jlong space_id) { hssize_t retVal = -1; @@ -369,7 +363,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints H5_LIBRARY_ERROR(ENVONLY); done: - return (jlong) retVal; + return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints */ /* @@ -378,8 +372,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1type - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sget_1select_1type(JNIEnv *env, jclass clss, jlong space_id) { int retVal = -1; @@ -389,7 +382,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1type H5_LIBRARY_ERROR(ENVONLY); done: - return (jint) retVal; + return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1type */ /* @@ -398,8 +391,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims(JNIEnv *env, jclass clss, jlong space_id) { int retVal = -1; @@ -409,7 +401,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims H5_LIBRARY_ERROR(ENVONLY); done: - return (jint) retVal; + return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims */ /* @@ -418,23 +410,23 @@ done: * Signature: (J[J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims - (JNIEnv *env, jclass clss, jlong space_id, jlongArray dims, jlongArray maxdims) +Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims(JNIEnv *env, jclass clss, jlong space_id, jlongArray dims, + jlongArray maxdims) { - jboolean isCopy; - hsize_t *sa = NULL; - hsize_t *msa = NULL; - jlong *dimsP = NULL, *maxdimsP = NULL; - int i; - int rank = -1; - int mrank; - int status = -1; + jboolean isCopy; + hsize_t *sa = NULL; + hsize_t *msa = NULL; + jlong * dimsP = NULL, *maxdimsP = NULL; + int i; + int rank = -1; + int mrank; + int status = -1; UNUSED(clss); if (NULL == dims) { dimsP = NULL; - sa = (hsize_t *) dimsP; + sa = (hsize_t *)dimsP; } else { PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Sget_simple_extent_dims: dims not pinned"); @@ -444,18 +436,18 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_simple_extent_dims: dims array length < 0"); } - if (NULL == (sa = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + if (NULL == (sa = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate dimension buffer"); } if (NULL == maxdims) { maxdimsP = NULL; - msa = (hsize_t *) maxdimsP; + msa = (hsize_t *)maxdimsP; } else { PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Sget_simple_extent_dims: maxdims not pinned"); - if ((mrank = (int) ENVPTR->GetArrayLength(ENVONLY, maxdims)) < 0) { + if ((mrank = (int)ENVPTR->GetArrayLength(ENVONLY, maxdims)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_simple_extent_dims: maxdims array length < 0"); } @@ -465,8 +457,9 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims else if (mrank != rank) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_simple_extent_dims: maxdims rank not same as dims"); - if (NULL == (msa = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate maximum dimension buffer"); + if (NULL == (msa = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5Sget_simple_extent_dims: failed to allocate maximum dimension buffer"); } if ((status = H5Sget_simple_extent_dims(space_id, (hsize_t *)sa, (hsize_t *)msa)) < 0) @@ -503,8 +496,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type(JNIEnv *env, jclass clss, jlong space_id) { H5S_class_t retVal = H5S_NO_CLASS; @@ -526,18 +518,18 @@ done: * Signature: (JI[J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple - (JNIEnv *env, jclass clss, jlong space_id, jint rank, jlongArray dims, jlongArray maxdims) +Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple(JNIEnv *env, jclass clss, jlong space_id, jint rank, + jlongArray dims, jlongArray maxdims) { - jboolean isCopy; - hsize_t *sa = NULL; - hsize_t *msa = NULL; - hsize_t *lp = NULL; - jlong *dimsP = NULL, *maxdimsP = NULL; - jlong *jlp = NULL; - jsize drank, mrank; - int i; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *sa = NULL; + hsize_t *msa = NULL; + hsize_t *lp = NULL; + jlong * dimsP = NULL, *maxdimsP = NULL; + jlong * jlp = NULL; + jsize drank, mrank; + int i; + herr_t status = FAIL; UNUSED(clss); @@ -564,35 +556,36 @@ Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Sset_extent_simple: dims not pinned"); - if (NULL == (sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + if (NULL == (sa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate dimension buffer"); - jlp = (jlong *) dimsP; + jlp = (jlong *)dimsP; for (i = 0; i < rank; i++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end for */ if (NULL == maxdims) { maxdimsP = NULL; - msa = (hsize_t *) maxdimsP; + msa = (hsize_t *)maxdimsP; } else { PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Sset_extent_simple: maxdims not pinned"); - if (NULL == (msa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate maximum dimension buffer"); + if (NULL == (msa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5Sset_extent_simple: failed to allocate maximum dimension buffer"); - jlp = (jlong *) maxdimsP; + jlp = (jlong *)maxdimsP; for (i = 0; i < rank; i++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end for */ } - if ((status = H5Sset_extent_simple(space_id, rank, (hsize_t *) sa, (hsize_t *) msa)) < 0) + if ((status = H5Sset_extent_simple(space_id, rank, (hsize_t *)sa, (hsize_t *)msa)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -614,8 +607,7 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Sis_1simple - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sis_1simple(JNIEnv *env, jclass clss, jlong space_id) { htri_t bval = JNI_FALSE; @@ -636,16 +628,15 @@ done: * Signature: (J[B)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Soffset_1simple - (JNIEnv *env, jclass clss, jlong space_id, jbyteArray offset) +Java_hdf_hdf5lib_H5_H5Soffset_1simple(JNIEnv *env, jclass clss, jlong space_id, jbyteArray offset) { jboolean isCopy; hssize_t *sa = NULL; hssize_t *lp = NULL; size_t rank; jsize i; - jbyte *P = NULL; - jlong *jlp = NULL; + jbyte * P = NULL; + jlong * jlp = NULL; herr_t status = FAIL; UNUSED(clss); @@ -658,21 +649,21 @@ Java_hdf_hdf5lib_H5_H5Soffset_1simple H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Soffset_simple: offset array length < 0"); } - rank = (size_t) i / sizeof(jlong); + rank = (size_t)i / sizeof(jlong); - if (NULL == (sa = lp = (hssize_t *) HDmalloc((size_t)rank * sizeof(hssize_t)))) + if (NULL == (sa = lp = (hssize_t *)HDmalloc((size_t)rank * sizeof(hssize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Soffset_simple: failed to allocate offset buffer"); - jlp = (jlong *) P; - for (i = 0; (size_t) i < rank; i++) { - *lp = (hssize_t) *jlp; + jlp = (jlong *)P; + for (i = 0; (size_t)i < rank; i++) { + *lp = (hssize_t)*jlp; lp++; jlp++; } /* end for */ } else { - P = NULL; - sa = (hssize_t *) P; + P = NULL; + sa = (hssize_t *)P; } if ((status = H5Soffset_simple(space_id, sa)) < 0) @@ -693,8 +684,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sextent_1copy - (JNIEnv *env, jclass clss, jlong space_id, jlong src_id) +Java_hdf_hdf5lib_H5_H5Sextent_1copy(JNIEnv *env, jclass clss, jlong space_id, jlong src_id) { herr_t retVal = FAIL; @@ -713,8 +703,7 @@ done: * Signature: (JJ)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Sextent_1equal - (JNIEnv *env, jclass clss, jlong space_id, jlong src_id) +Java_hdf_hdf5lib_H5_H5Sextent_1equal(JNIEnv *env, jclass clss, jlong space_id, jlong src_id) { htri_t bval = JNI_FALSE; @@ -735,8 +724,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sset_1extent_1none - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5_H5Sset_1extent_1none(JNIEnv *env, jclass clss, jlong space_id) { herr_t retVal = FAIL; @@ -755,17 +743,17 @@ done: * Signature: (JI[J[J[J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab - (JNIEnv *env, jclass clss, jlong space_id, jint op, jlongArray start, jlongArray stride, jlongArray count, jlongArray block) +Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab(JNIEnv *env, jclass clss, jlong space_id, jint op, jlongArray start, + jlongArray stride, jlongArray count, jlongArray block) { - jboolean isCopy; - hsize_t *strt = NULL, *strd = NULL, *cnt = NULL, *blk = NULL; - hsize_t *lp = NULL; - jlong *startP = NULL, *strideP = NULL, *countP = NULL, *blockP = NULL; - jlong *jlp = NULL; - jsize start_rank, stride_rank, count_rank, block_rank; - int i; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *strt = NULL, *strd = NULL, *cnt = NULL, *blk = NULL; + hsize_t *lp = NULL; + jlong * startP = NULL, *strideP = NULL, *countP = NULL, *blockP = NULL; + jlong * jlp = NULL; + jsize start_rank, stride_rank, count_rank, block_rank; + int i; + herr_t status = FAIL; UNUSED(clss); @@ -788,31 +776,31 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sselect_hyperslab: start not pinned"); - if (NULL == (strt = lp = (hsize_t *) HDmalloc((size_t)start_rank * sizeof(hsize_t)))) + if (NULL == (strt = lp = (hsize_t *)HDmalloc((size_t)start_rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate start buffer"); - jlp = (jlong *) startP; + jlp = (jlong *)startP; for (i = 0; i < start_rank; i++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end if */ PIN_LONG_ARRAY(ENVONLY, count, countP, &isCopy, "H5Sselect_hyperslab: count not pinned"); - if (NULL == (cnt = lp = (hsize_t *) HDmalloc((size_t)count_rank * sizeof(hsize_t)))) + if (NULL == (cnt = lp = (hsize_t *)HDmalloc((size_t)count_rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate count buffer"); - jlp = (jlong *) countP; + jlp = (jlong *)countP; for (i = 0; i < count_rank; i++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end if */ if (NULL == stride) { strideP = NULL; - strd = (hsize_t *) strideP; + strd = (hsize_t *)strideP; } else { if ((stride_rank = ENVPTR->GetArrayLength(ENVONLY, stride)) < 0) { @@ -825,12 +813,12 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, stride, strideP, &isCopy, "H5Sselect_hyperslab: stride not pinned"); - if (NULL == (strd = lp = (hsize_t *) HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) + if (NULL == (strd = lp = (hsize_t *)HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate stride buffer"); - jlp = (jlong *) strideP; + jlp = (jlong *)strideP; for (i = 0; i < stride_rank; i++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end if */ @@ -838,7 +826,7 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab if (NULL == block) { blockP = NULL; - blk = (hsize_t *) blockP; + blk = (hsize_t *)blockP; } else { if ((block_rank = ENVPTR->GetArrayLength(ENVONLY, block)) < 0) { @@ -851,19 +839,19 @@ Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab PIN_LONG_ARRAY(ENVONLY, block, blockP, &isCopy, "H5Sselect_hyperslab: block not pinned"); - if (NULL == (blk = lp = (hsize_t *) HDmalloc((size_t)block_rank * sizeof(hsize_t)))) + if (NULL == (blk = lp = (hsize_t *)HDmalloc((size_t)block_rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate block buffer"); - jlp = (jlong *) blockP; + jlp = (jlong *)blockP; for (i = 0; i < block_rank; i++) { - *lp = (hsize_t) *jlp; + *lp = (hsize_t)*jlp; lp++; jlp++; } /* end for */ } - if ((status = H5Sselect_hyperslab(space_id, (H5S_seloper_t) op, (const hsize_t *) strt, (const hsize_t *) strd, - (const hsize_t *) cnt, (const hsize_t *) blk)) < 0) + if ((status = H5Sselect_hyperslab(space_id, (H5S_seloper_t)op, (const hsize_t *)strt, + (const hsize_t *)strd, (const hsize_t *)cnt, (const hsize_t *)blk)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -893,8 +881,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Sclose - (JNIEnv *env, jclass clss, jlong space_id) +Java_hdf_hdf5lib_H5__1H5Sclose(JNIEnv *env, jclass clss, jlong space_id) { herr_t retVal = FAIL; @@ -913,14 +900,13 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks - (JNIEnv *env, jclass clss, jlong spaceid) +Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks(JNIEnv *env, jclass clss, jlong spaceid) { hssize_t retVal = -1; UNUSED(clss); - if ((retVal = H5Sget_select_hyper_nblocks((hid_t) spaceid)) < 0) + if ((retVal = H5Sget_select_hyper_nblocks((hid_t)spaceid)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -933,14 +919,13 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints - (JNIEnv *env, jclass clss, jlong spaceid) +Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints(JNIEnv *env, jclass clss, jlong spaceid) { hssize_t retVal = -1; UNUSED(clss); - if ((retVal = H5Sget_select_elem_npoints((hid_t) spaceid)) < 0) + if ((retVal = H5Sget_select_elem_npoints((hid_t)spaceid)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -953,16 +938,16 @@ done: * Signature: (JJJ[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist - (JNIEnv *env, jclass clss, jlong spaceid, jlong startblock, jlong numblocks, jlongArray buf) +Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist(JNIEnv *env, jclass clss, jlong spaceid, + jlong startblock, jlong numblocks, jlongArray buf) { - jboolean isCopy; - hsize_t *ba = NULL; - size_t i, buf_size; - jlong *bufP = NULL; - jsize buflen; - int rank; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *ba = NULL; + size_t i, buf_size; + jlong * bufP = NULL; + jsize buflen; + int rank; + herr_t status = FAIL; UNUSED(clss); @@ -987,15 +972,17 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist PIN_LONG_ARRAY(ENVONLY, buf, bufP, &isCopy, "H5Sget_select_hyper_blocklist: buffer not pinned"); - buf_size = (size_t) numblocks * (size_t) 2 * (size_t) rank * sizeof(hsize_t); - if (NULL == (ba = (hsize_t *) HDmalloc(buf_size))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: failed to allocate block list buffer"); + buf_size = (size_t)numblocks * (size_t)2 * (size_t)rank * sizeof(hsize_t); + if (NULL == (ba = (hsize_t *)HDmalloc(buf_size))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5Sget_select_hyper_blocklist: failed to allocate block list buffer"); - if ((status = H5Sget_select_hyper_blocklist((hid_t)spaceid, (hsize_t) startblock, (hsize_t) numblocks, (hsize_t *)ba)) < 0) + if ((status = H5Sget_select_hyper_blocklist((hid_t)spaceid, (hsize_t)startblock, (hsize_t)numblocks, + (hsize_t *)ba)) < 0) H5_LIBRARY_ERROR(ENVONLY); for (i = 0; i < (buf_size / sizeof(hsize_t)); i++) { - bufP[i] = (jlong) ba[i]; + bufP[i] = (jlong)ba[i]; } /* end for */ done: @@ -1013,15 +1000,15 @@ done: * Signature: (JJJ[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist - (JNIEnv *env, jclass clss, jlong spaceid, jlong startpoint, jlong numpoints, jlongArray buf) +Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist(JNIEnv *env, jclass clss, jlong spaceid, jlong startpoint, + jlong numpoints, jlongArray buf) { - jboolean isCopy; - hsize_t *ba = NULL; - jlong *bufP = NULL; - jsize buflen; - int i, rank; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *ba = NULL; + jlong * bufP = NULL; + jsize buflen; + int i, rank; + herr_t status = FAIL; UNUSED(clss); @@ -1044,14 +1031,15 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist PIN_LONG_ARRAY(ENVONLY, buf, bufP, &isCopy, "H5Sget_select_elem_pointlist: buffer not pinned"); - if (NULL == (ba = (hsize_t *) HDmalloc(((size_t)numpoints * (size_t)rank) * sizeof(hsize_t)))) + if (NULL == (ba = (hsize_t *)HDmalloc(((size_t)numpoints * (size_t)rank) * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: failed to allocate point list buffer"); - if ((status = H5Sget_select_elem_pointlist((hid_t)spaceid, (hsize_t)startpoint, (hsize_t)numpoints, (hsize_t *)ba)) < 0) + if ((status = H5Sget_select_elem_pointlist((hid_t)spaceid, (hsize_t)startpoint, (hsize_t)numpoints, + (hsize_t *)ba)) < 0) H5_LIBRARY_ERROR(ENVONLY); for (i = 0; i < (numpoints * rank); i++) { - bufP[i] = (jlong) ba[i]; + bufP[i] = (jlong)ba[i]; } /* end for */ done: @@ -1069,16 +1057,16 @@ done: * Signature: (J[J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds - (JNIEnv *env, jclass clss, jlong spaceid, jlongArray start, jlongArray end) +Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds(JNIEnv *env, jclass clss, jlong spaceid, jlongArray start, + jlongArray end) { - jboolean isCopy; - hsize_t *strt = NULL; - hsize_t *en = NULL; - size_t i; - jlong *startP = NULL, *endP = NULL; - jsize rank; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *strt = NULL; + hsize_t *en = NULL; + size_t i; + jlong * startP = NULL, *endP = NULL; + jsize rank; + herr_t status = FAIL; UNUSED(clss); @@ -1094,20 +1082,20 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_bounds: start array length < 0"); } - if (NULL == (strt = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + if (NULL == (strt = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate start buffer"); PIN_LONG_ARRAY(ENVONLY, end, endP, &isCopy, "H5Sget_select_bounds: end not pinned"); - if (NULL == (en = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + if (NULL == (en = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate end buffer"); - if ((status = H5Sget_select_bounds((hid_t) spaceid, (hsize_t *) strt, (hsize_t *) en)) < 0) + if ((status = H5Sget_select_bounds((hid_t)spaceid, (hsize_t *)strt, (hsize_t *)en)) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0; i < (size_t) rank; i++) { - startP[i] = (jlong) strt[i]; - endP[i] = (jlong) en[i]; + for (i = 0; i < (size_t)rank; i++) { + startP[i] = (jlong)strt[i]; + endP[i] = (jlong)en[i]; } /* end for */ done: @@ -1129,12 +1117,11 @@ done: * Signature: (J)[B */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Sencode - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Sencode(JNIEnv *env, jclass clss, jlong obj_id) { - unsigned char *bufPtr = NULL; - size_t buf_size = 0; - herr_t status = FAIL; + unsigned char *bufPtr = NULL; + size_t buf_size = 0; + herr_t status = FAIL; jbyteArray returnedArray = NULL; UNUSED(clss); @@ -1148,16 +1135,16 @@ Java_hdf_hdf5lib_H5_H5Sencode if (buf_size == 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: buf_size = 0"); - if (NULL == (bufPtr = (unsigned char *) HDcalloc((size_t) 1, buf_size))) + if (NULL == (bufPtr = (unsigned char *)HDcalloc((size_t)1, buf_size))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer"); - if ((status = H5Sencode2((hid_t) obj_id, bufPtr, &buf_size, H5P_DEFAULT)) < 0) + if ((status = H5Sencode2((hid_t)obj_id, bufPtr, &buf_size, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (returnedArray = ENVPTR->NewByteArray(ENVONLY, (jsize) buf_size))) + if (NULL == (returnedArray = ENVPTR->NewByteArray(ENVONLY, (jsize)buf_size))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - ENVPTR->SetByteArrayRegion(ENVONLY, returnedArray, 0, (jsize) buf_size, (jbyte *) bufPtr); + ENVPTR->SetByteArrayRegion(ENVONLY, returnedArray, 0, (jsize)buf_size, (jbyte *)bufPtr); CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); done: @@ -1173,12 +1160,11 @@ done: * Signature: ([B)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sdecode - (JNIEnv *env, jclass clss, jbyteArray buf) +Java_hdf_hdf5lib_H5_H5Sdecode(JNIEnv *env, jclass clss, jbyteArray buf) { - jboolean isCopy; - jbyte *bufP = NULL; - hid_t sid = H5I_INVALID_HID; + jboolean isCopy; + jbyte * bufP = NULL; + hid_t sid = H5I_INVALID_HID; UNUSED(clss); @@ -1203,8 +1189,7 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab(JNIEnv *env, jclass clss, jlong obj_id) { htri_t bval = JNI_FALSE; @@ -1225,15 +1210,15 @@ done: * Signature: (J[J[J[J[J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab - (JNIEnv *env, jclass clss, jlong space_id, jlongArray start, jlongArray stride, jlongArray count, jlongArray block) +Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab(JNIEnv *env, jclass clss, jlong space_id, jlongArray start, + jlongArray stride, jlongArray count, jlongArray block) { - jboolean isCopy; - hsize_t *strt = NULL, *strd = NULL, *cnt = NULL, *blk = NULL; - jlong *startP = NULL, *strideP = NULL, *countP = NULL, *blockP = NULL; - jsize start_rank = -1, stride_rank = -1, count_rank = -1, block_rank = -1; - int i, rank = -1; - herr_t status = FAIL; + jboolean isCopy; + hsize_t *strt = NULL, *strd = NULL, *cnt = NULL, *blk = NULL; + jlong * startP = NULL, *strideP = NULL, *countP = NULL, *blockP = NULL; + jsize start_rank = -1, stride_rank = -1, count_rank = -1, block_rank = -1; + int i, rank = -1; + herr_t status = FAIL; UNUSED(clss); @@ -1245,7 +1230,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab if (NULL == start) { startP = NULL; - strt = (hsize_t *) startP; + strt = (hsize_t *)startP; } else { if ((start_rank = ENVPTR->GetArrayLength(ENVONLY, start)) < 0) { @@ -1254,17 +1239,18 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab } if (start_rank != rank) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: start rank doesn't match dataspace rank!"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "H5Sget_regular_hyperslab: start rank doesn't match dataspace rank!"); PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sget_regular_hyperslab: start not pinned"); - if (NULL == (strt = (hsize_t *) HDmalloc((size_t)start_rank * sizeof(hsize_t)))) + if (NULL == (strt = (hsize_t *)HDmalloc((size_t)start_rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate start buffer"); } if (NULL == stride) { strideP = NULL; - strd = (hsize_t *) strideP; + strd = (hsize_t *)strideP; } else { if ((stride_rank = ENVPTR->GetArrayLength(ENVONLY, stride)) < 0) { @@ -1273,17 +1259,18 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab } if (stride_rank != rank) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: stride rank doesn't match dataspace rank!"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "H5Sget_regular_hyperslab: stride rank doesn't match dataspace rank!"); PIN_LONG_ARRAY(ENVONLY, stride, strideP, &isCopy, "H5Sget_regular_hyperslab: stride not pinned"); - if (NULL == (strd = (hsize_t *) HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) + if (NULL == (strd = (hsize_t *)HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate stride buffer"); } if (NULL == count) { countP = NULL; - cnt = (hsize_t *) countP; + cnt = (hsize_t *)countP; } else { if ((count_rank = ENVPTR->GetArrayLength(ENVONLY, count)) < 0) { @@ -1292,17 +1279,18 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab } if (count_rank != rank) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: count rank doesn't match dataspace rank!"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "H5Sget_regular_hyperslab: count rank doesn't match dataspace rank!"); PIN_LONG_ARRAY(ENVONLY, count, countP, &isCopy, "H5Sget_regular_hyperslab: count not pinned"); - if (NULL == (cnt = (hsize_t *) HDmalloc((size_t)count_rank * sizeof(hsize_t)))) + if (NULL == (cnt = (hsize_t *)HDmalloc((size_t)count_rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate count buffer"); } if (NULL == block) { blockP = NULL; - blk = (hsize_t *) blockP; + blk = (hsize_t *)blockP; } else { if ((block_rank = ENVPTR->GetArrayLength(ENVONLY, block)) < 0) { @@ -1311,22 +1299,24 @@ Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab } if (block_rank != rank) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: block rank doesn't match dataspace rank!"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "H5Sget_regular_hyperslab: block rank doesn't match dataspace rank!"); PIN_LONG_ARRAY(ENVONLY, block, blockP, &isCopy, "H5Sget_regular_hyperslab: block not pinned"); - if (NULL == (blk = (hsize_t *) HDmalloc((size_t)block_rank * sizeof(hsize_t)))) + if (NULL == (blk = (hsize_t *)HDmalloc((size_t)block_rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate block buffer"); } - if ((status = H5Sget_regular_hyperslab(space_id, (hsize_t *) strt, (hsize_t *) strd, (hsize_t *) cnt, (hsize_t *) blk)) < 0) + if ((status = H5Sget_regular_hyperslab(space_id, (hsize_t *)strt, (hsize_t *)strd, (hsize_t *)cnt, + (hsize_t *)blk)) < 0) H5_LIBRARY_ERROR(ENVONLY); for (i = 0; i < start_rank; i++) { - startP[i] = (jlong) strt[i]; - countP[i] = (jlong) cnt[i]; - strideP[i] = (jlong) strd[i]; - blockP[i] = (jlong) blk[i]; + startP[i] = (jlong)strt[i]; + countP[i] = (jlong)cnt[i]; + strideP[i] = (jlong)strd[i]; + blockP[i] = (jlong)blk[i]; } /* end for */ done: diff --git a/java/src/jni/h5sImp.h b/java/src/jni/h5sImp.h index cea2ebf..ee28b39 100644 --- a/java/src/jni/h5sImp.h +++ b/java/src/jni/h5sImp.h @@ -26,27 +26,22 @@ extern "C" { * Method: _H5Screate * Signature: (I)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Screate -(JNIEnv *, jclass, jint); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Screate(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: _H5Screate_simple * Signature: (I[J[J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Screate_1simple -(JNIEnv *, jclass, jint, jlongArray, jlongArray); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Screate_1simple(JNIEnv *, jclass, jint, jlongArray, + jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: _H5Scopy * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Scopy -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Scopy(JNIEnv *, jclass, jlong); #ifdef notdef /* 10/28/99 -- added code to copy the array -- this is not used, @@ -63,9 +58,8 @@ Java_hdf_hdf5lib_H5__1H5Scopy * Method: H5Sselect_elements * Signature: (JII[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1elements -(JNIEnv *, jclass, jlong, jint, jint, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1elements(JNIEnv *, jclass, jlong, jint, jint, + jlongArray); #endif /* @@ -73,242 +67,197 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements * Method: H5Sselect_elements * Signature: (JII[B)I */ -JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1elements -(JNIEnv *, jclass, jlong, jint, jint, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1elements(JNIEnv *, jclass, jlong, jint, jint, + jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sselect_all * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1all -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1all(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sselect_none * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1none -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1none(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sselect_valid * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1valid -(JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1valid(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_simple_extent_npoints * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_select_npoints * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_select_type * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1type -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1type(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_simple_extent_ndims * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_simple_extent_dims * Signature: (J[J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims -(JNIEnv *, jclass, jlong, jlongArray, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims(JNIEnv *, jclass, jlong, jlongArray, + jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_simple_extent_type * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sset_extent_simple * Signature: (JI[J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple -(JNIEnv *, jclass, jlong, jint, jlongArray, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple(JNIEnv *, jclass, jlong, jint, jlongArray, + jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sis_simple * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Sis_1simple -(JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Sis_1simple(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Soffset_simple * Signature: (J[B)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Soffset_1simple -(JNIEnv *, jclass, jlong, jbyteArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Soffset_1simple(JNIEnv *, jclass, jlong, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sextent_copy * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sextent_1copy -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sextent_1copy(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sextent_equal * Signature: (JJ)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Sextent_1equal - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Sextent_1equal(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sset_extent_none * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sset_1extent_1none -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sset_1extent_1none(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sselect_hyperslab * Signature: (JI[J[J[J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab -(JNIEnv *, jclass, jlong, jint, jlongArray, jlongArray, jlongArray, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab(JNIEnv *, jclass, jlong, jint, jlongArray, + jlongArray, jlongArray, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sclose * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Sclose -(JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Sclose(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_select_hyper_nblocks * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_select_elem_npoints * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints -(JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_select_hyper_blocklist * Signature: (JJJ[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist -(JNIEnv *, jclass, jlong, jlong, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist(JNIEnv *, jclass, jlong, jlong, + jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_select_elem_pointlist * Signature: (JJJ[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist -(JNIEnv *, jclass, jlong, jlong, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist(JNIEnv *, jclass, jlong, jlong, + jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_select_bounds * Signature: (J[J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds -(JNIEnv *, jclass, jlong, jlongArray, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds(JNIEnv *, jclass, jlong, jlongArray, + jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sencode * Signature: (J)[B */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_H5_H5Sencode - (JNIEnv *, jclass, jlong); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Sencode(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sdecode * Signature: ([B)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Sdecode - (JNIEnv *, jclass, jbyteArray); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sdecode(JNIEnv *, jclass, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Sis_regular_hyperslab * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab - (JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Sget_regular_hyperslab * Signature: (J[J[J[J[J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab -(JNIEnv *, jclass, jlong, jlongArray, jlongArray, jlongArray, jlongArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab(JNIEnv *, jclass, jlong, jlongArray, + jlongArray, jlongArray, jlongArray); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c index 1cbf1a5..e968ad2 100644 --- a/java/src/jni/h5tImp.c +++ b/java/src/jni/h5tImp.c @@ -40,11 +40,10 @@ extern "C" { * Signature: (JLjava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Topen2 - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist) +Java_hdf_hdf5lib_H5__1H5Topen2(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist) { const char *datatypeName = NULL; - hid_t status = H5I_INVALID_HID; + hid_t status = H5I_INVALID_HID; UNUSED(clss); @@ -69,8 +68,7 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Tcommitted - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tcommitted(JNIEnv *env, jclass clss, jlong type_id) { htri_t bval = JNI_FALSE; @@ -91,14 +89,13 @@ done: * Signature: (IJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tcreate - (JNIEnv *env, jclass clss, jint dclass, jlong size) +Java_hdf_hdf5lib_H5__1H5Tcreate(JNIEnv *env, jclass clss, jint dclass, jlong size) { hid_t retVal = H5I_INVALID_HID; UNUSED(clss); - if ((retVal = H5Tcreate((H5T_class_t )dclass, (size_t)size)) < 0) + if ((retVal = H5Tcreate((H5T_class_t)dclass, (size_t)size)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -111,8 +108,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tcopy - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5__1H5Tcopy(JNIEnv *env, jclass clss, jlong type_id) { hid_t retVal = H5I_INVALID_HID; @@ -131,8 +127,7 @@ done: * Signature: (JJ)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Tequal - (JNIEnv *env, jclass clss, jlong type_id1, jlong type_id2) +Java_hdf_hdf5lib_H5_H5Tequal(JNIEnv *env, jclass clss, jlong type_id1, jlong type_id2) { htri_t bval = JNI_FALSE; @@ -153,8 +148,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tlock - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tlock(JNIEnv *env, jclass clss, jlong type_id) { herr_t retVal = FAIL; @@ -173,8 +167,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1class - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1class(JNIEnv *env, jclass clss, jlong type_id) { H5T_class_t retVal = H5T_NO_CLASS; @@ -193,8 +186,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1size - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1size(JNIEnv *env, jclass clss, jlong type_id) { size_t retVal = 0; @@ -213,10 +205,9 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1size - (JNIEnv *env, jclass clss, jlong type_id, jlong size) +Java_hdf_hdf5lib_H5_H5Tset_1size(JNIEnv *env, jclass clss, jlong type_id, jlong size) { - size_t tsize = (size_t)size; + size_t tsize = (size_t)size; herr_t retVal = FAIL; UNUSED(clss); @@ -234,8 +225,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1order - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1order(JNIEnv *env, jclass clss, jlong type_id) { H5T_order_t retVal = H5T_ORDER_ERROR; @@ -254,8 +244,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1order - (JNIEnv *env, jclass clss, jlong type_id, jint order) +Java_hdf_hdf5lib_H5_H5Tset_1order(JNIEnv *env, jclass clss, jlong type_id, jint order) { herr_t retVal = FAIL; @@ -274,8 +263,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1precision - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1precision(JNIEnv *env, jclass clss, jlong type_id) { size_t retVal = 0; @@ -294,8 +282,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1precision_1long - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1precision_1long(JNIEnv *env, jclass clss, jlong type_id) { size_t retVal = 0; @@ -314,8 +301,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1precision - (JNIEnv *env, jclass clss, jlong type_id, jlong precision) +Java_hdf_hdf5lib_H5_H5Tset_1precision(JNIEnv *env, jclass clss, jlong type_id, jlong precision) { herr_t retVal = FAIL; @@ -334,8 +320,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1offset - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1offset(JNIEnv *env, jclass clss, jlong type_id) { int retVal = -1; @@ -354,8 +339,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1offset - (JNIEnv *env, jclass clss, jlong type_id, jlong offset) +Java_hdf_hdf5lib_H5_H5Tset_1offset(JNIEnv *env, jclass clss, jlong type_id, jlong offset) { herr_t retVal = FAIL; @@ -374,12 +358,11 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1pad - (JNIEnv *env, jclass clss, jlong type_id, jintArray pad) +Java_hdf_hdf5lib_H5_H5Tget_1pad(JNIEnv *env, jclass clss, jlong type_id, jintArray pad) { - jboolean isCopy; - jint *P = NULL; - herr_t status = FAIL; + jboolean isCopy; + jint * P = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -404,8 +387,7 @@ done: * Signature: (JII)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1pad - (JNIEnv *env, jclass clss, jlong type_id, jint lsb, jint msb) +Java_hdf_hdf5lib_H5_H5Tset_1pad(JNIEnv *env, jclass clss, jlong type_id, jint lsb, jint msb) { herr_t retVal = FAIL; @@ -424,8 +406,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1sign - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1sign(JNIEnv *env, jclass clss, jlong type_id) { H5T_sign_t retVal = H5T_SGN_ERROR; @@ -444,8 +425,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1sign - (JNIEnv *env, jclass clss, jlong type_id, jint sign) +Java_hdf_hdf5lib_H5_H5Tset_1sign(JNIEnv *env, jclass clss, jlong type_id, jint sign) { herr_t retVal = FAIL; @@ -464,13 +444,12 @@ done: * Signature: (J[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1fields_1int - (JNIEnv *env, jclass clss, jlong type_id, jintArray fields) +Java_hdf_hdf5lib_H5_H5Tget_1fields_1int(JNIEnv *env, jclass clss, jlong type_id, jintArray fields) { - jboolean isCopy; - jsize arrLen; - jint *P = NULL; - herr_t status = FAIL; + jboolean isCopy; + jsize arrLen; + jint * P = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -486,7 +465,8 @@ Java_hdf_hdf5lib_H5_H5Tget_1fields_1int PIN_INT_ARRAY(ENVONLY, fields, P, &isCopy, "H5Tget_fields_int: fields not pinned"); - if ((status = H5Tget_fields((hid_t)type_id, (size_t *)&(P[0]), (size_t *)&(P[1]), (size_t *)&(P[2]), (size_t *)&(P[3]), (size_t *)&(P[4]))) < 0) + if ((status = H5Tget_fields((hid_t)type_id, (size_t *)&(P[0]), (size_t *)&(P[1]), (size_t *)&(P[2]), + (size_t *)&(P[3]), (size_t *)&(P[4]))) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -502,13 +482,12 @@ done: * Signature: (J[J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1fields - (JNIEnv *env, jclass clss, jlong type_id, jlongArray fields) +Java_hdf_hdf5lib_H5_H5Tget_1fields(JNIEnv *env, jclass clss, jlong type_id, jlongArray fields) { - jboolean isCopy; - jlong *fieldsArray = NULL; - jsize arrLen; - herr_t status = FAIL; + jboolean isCopy; + jlong * fieldsArray = NULL; + jsize arrLen; + herr_t status = FAIL; UNUSED(clss); @@ -525,21 +504,21 @@ Java_hdf_hdf5lib_H5_H5Tget_1fields PIN_LONG_ARRAY(ENVONLY, fields, fieldsArray, &isCopy, "H5Tget_fields: fields not pinned"); { /* Direct cast (size_t *)variable fails on 32-bit environment */ - size_t spos_t = 0; - size_t epos_t = 0; - size_t esize_t = 0; - size_t mpos_t = 0; - size_t msize_t = 0; + size_t spos_t = 0; + size_t epos_t = 0; + size_t esize_t = 0; + size_t mpos_t = 0; + size_t msize_t = 0; long long fields_temp = *(&fieldsArray[0]); - spos_t = (size_t)fields_temp; - fields_temp = *(&fieldsArray[1]); - epos_t = (size_t)fields_temp; - fields_temp = *(&fieldsArray[2]); - esize_t = (size_t)fields_temp; - fields_temp = *(&fieldsArray[3]); - mpos_t = (size_t)fields_temp; - fields_temp = *(&fieldsArray[4]); - msize_t = (size_t)fields_temp; + spos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[1]); + epos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[2]); + esize_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[3]); + mpos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[4]); + msize_t = (size_t)fields_temp; if ((status = H5Tget_fields((hid_t)type_id, &spos_t, &epos_t, &esize_t, &mpos_t, &msize_t)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -564,13 +543,13 @@ done: * Signature: (JJJJJJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1fields - (JNIEnv *env, jclass clss, jlong type_id, jlong spos, jlong epos, - jlong esize, jlong mpos, jlong msize) +Java_hdf_hdf5lib_H5_H5Tset_1fields(JNIEnv *env, jclass clss, jlong type_id, jlong spos, jlong epos, + jlong esize, jlong mpos, jlong msize) { UNUSED(clss); - if (H5Tset_fields((hid_t)type_id, (size_t)spos, (size_t)epos, (size_t)esize, (size_t)mpos, (size_t)msize) < 0) + if (H5Tset_fields((hid_t)type_id, (size_t)spos, (size_t)epos, (size_t)esize, (size_t)mpos, + (size_t)msize) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -583,14 +562,13 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1ebias - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1ebias(JNIEnv *env, jclass clss, jlong type_id) { size_t retVal = 0; UNUSED(clss); - if (!(retVal = H5Tget_ebias((hid_t)type_id))) + if (!(retVal = H5Tget_ebias((hid_t)type_id))) H5_LIBRARY_ERROR(ENVONLY); done: @@ -603,8 +581,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long(JNIEnv *env, jclass clss, jlong type_id) { size_t retVal = 0; @@ -623,8 +600,7 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1ebias - (JNIEnv *env, jclass clss, jlong type_id, jlong ebias) +Java_hdf_hdf5lib_H5_H5Tset_1ebias(JNIEnv *env, jclass clss, jlong type_id, jlong ebias) { herr_t retVal = FAIL; @@ -643,8 +619,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1norm - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1norm(JNIEnv *env, jclass clss, jlong type_id) { H5T_norm_t retVal = H5T_NORM_ERROR; @@ -663,14 +638,13 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1norm - (JNIEnv *env, jclass clss, jlong type_id, jint norm) +Java_hdf_hdf5lib_H5_H5Tset_1norm(JNIEnv *env, jclass clss, jlong type_id, jint norm) { herr_t retVal = FAIL; UNUSED(clss); - if ((retVal = H5Tset_norm((hid_t)type_id, (H5T_norm_t )norm)) < 0) + if ((retVal = H5Tset_norm((hid_t)type_id, (H5T_norm_t)norm)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -683,8 +657,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1inpad - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1inpad(JNIEnv *env, jclass clss, jlong type_id) { H5T_pad_t retVal = H5T_PAD_ERROR; @@ -703,14 +676,13 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1inpad - (JNIEnv *env, jclass clss, jlong type_id, jint inpad) +Java_hdf_hdf5lib_H5_H5Tset_1inpad(JNIEnv *env, jclass clss, jlong type_id, jint inpad) { herr_t retVal = FAIL; UNUSED(clss); - if ((retVal = H5Tset_inpad((hid_t)type_id, (H5T_pad_t) inpad)) < 0) + if ((retVal = H5Tset_inpad((hid_t)type_id, (H5T_pad_t)inpad)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -723,8 +695,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1cset - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1cset(JNIEnv *env, jclass clss, jlong type_id) { H5T_cset_t retVal = H5T_CSET_ERROR; @@ -743,8 +714,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1cset - (JNIEnv *env, jclass clss, jlong type_id, jint cset) +Java_hdf_hdf5lib_H5_H5Tset_1cset(JNIEnv *env, jclass clss, jlong type_id, jint cset) { herr_t retVal = FAIL; @@ -763,8 +733,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1strpad - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1strpad(JNIEnv *env, jclass clss, jlong type_id) { H5T_str_t retVal = H5T_STR_ERROR; @@ -783,8 +752,7 @@ done: * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1strpad - (JNIEnv *env, jclass clss, jlong type_id, jint strpad) +Java_hdf_hdf5lib_H5_H5Tset_1strpad(JNIEnv *env, jclass clss, jlong type_id, jint strpad) { herr_t retVal = FAIL; @@ -803,8 +771,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1nmembers - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1nmembers(JNIEnv *env, jclass clss, jlong type_id) { int retVal = -1; @@ -823,11 +790,10 @@ done: * Signature: (JI)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1name - (JNIEnv *env, jclass clss, jlong type_id, jint field_idx) +Java_hdf_hdf5lib_H5_H5Tget_1member_1name(JNIEnv *env, jclass clss, jlong type_id, jint field_idx) { - char *member_name = NULL; - jstring str = NULL; + char * member_name = NULL; + jstring str = NULL; UNUSED(clss); @@ -850,11 +816,10 @@ done: * Signature: (JLjava/lang/String)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1index - (JNIEnv *env, jclass clss, jlong type_id, jstring field_name) +Java_hdf_hdf5lib_H5_H5Tget_1member_1index(JNIEnv *env, jclass clss, jlong type_id, jstring field_name) { const char *datatypeName = NULL; - int index = -1; + int index = -1; UNUSED(clss); @@ -879,8 +844,7 @@ done: * Signature: (JI)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tget_1member_1type - (JNIEnv *env, jclass clss, jlong type_id, jint field_idx) +Java_hdf_hdf5lib_H5__1H5Tget_1member_1type(JNIEnv *env, jclass clss, jlong type_id, jint field_idx) { hid_t retVal = H5I_INVALID_HID; @@ -899,8 +863,7 @@ done: * Signature: (JI)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1offset - (JNIEnv *env, jclass clss, jlong type_id, jint memno) +Java_hdf_hdf5lib_H5_H5Tget_1member_1offset(JNIEnv *env, jclass clss, jlong type_id, jint memno) { UNUSED(env); UNUSED(clss); @@ -914,8 +877,7 @@ Java_hdf_hdf5lib_H5_H5Tget_1member_1offset * Signature: (JI)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1class - (JNIEnv *env, jclass clss, jlong type_id, jint memno) +Java_hdf_hdf5lib_H5_H5Tget_1member_1class(JNIEnv *env, jclass clss, jlong type_id, jint memno) { H5T_class_t retVal = H5T_NO_CLASS; @@ -934,12 +896,12 @@ done: * Signature: (JLjava/lang/String;JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tinsert - (JNIEnv *env, jclass clss, jlong type_id, jstring name, jlong offset, jlong field_id) +Java_hdf_hdf5lib_H5_H5Tinsert(JNIEnv *env, jclass clss, jlong type_id, jstring name, jlong offset, + jlong field_id) { const char *datatypeName = NULL; - long off = (long)offset; - herr_t status = FAIL; + long off = (long)offset; + herr_t status = FAIL; UNUSED(clss); @@ -964,8 +926,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tpack - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tpack(JNIEnv *env, jclass clss, jlong type_id) { herr_t retVal = FAIL; @@ -984,13 +945,12 @@ done: * Signature: (JJJ[B)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Treclaim - (JNIEnv *env, jclass clss, jlong type_id, jlong space_id, - jlong xfer_plist_id, jbyteArray buf) +Java_hdf_hdf5lib_H5_H5Treclaim(JNIEnv *env, jclass clss, jlong type_id, jlong space_id, jlong xfer_plist_id, + jbyteArray buf) { - jboolean bufIsCopy; - jbyte *pinBuf = NULL; - herr_t status = FAIL; + jboolean bufIsCopy; + jbyte * pinBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1013,8 +973,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Tclose - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5__1H5Tclose(JNIEnv *env, jclass clss, jlong type_id) { herr_t retVal = FAIL; @@ -1033,8 +992,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tvlen_1create - (JNIEnv *env, jclass clss, jlong base_id) +Java_hdf_hdf5lib_H5__1H5Tvlen_1create(JNIEnv *env, jclass clss, jlong base_id) { hid_t retVal = H5I_INVALID_HID; @@ -1053,8 +1011,7 @@ done: * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1tag - (JNIEnv *env, jclass clss, jlong type, jstring tag) +Java_hdf_hdf5lib_H5_H5Tset_1tag(JNIEnv *env, jclass clss, jlong type, jstring tag) { const char *tagBuf = NULL; herr_t status = FAIL; @@ -1082,11 +1039,10 @@ done: * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1tag - (JNIEnv *env, jclass clss, jlong type) +Java_hdf_hdf5lib_H5_H5Tget_1tag(JNIEnv *env, jclass clss, jlong type) { - jstring str = NULL; - char *tag = NULL; + jstring str = NULL; + char * tag = NULL; UNUSED(clss); @@ -1109,8 +1065,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tget_1super - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5__1H5Tget_1super(JNIEnv *env, jclass clss, jlong type_id) { hid_t retVal = H5I_INVALID_HID; @@ -1129,8 +1084,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tenum_1create - (JNIEnv *env, jclass clss, jlong base_id) +Java_hdf_hdf5lib_H5__1H5Tenum_1create(JNIEnv *env, jclass clss, jlong base_id) { hid_t retVal = H5I_INVALID_HID; @@ -1149,12 +1103,12 @@ done: * Signature: (JLjava/lang/String;[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int - (JNIEnv *env, jclass clss, jlong type_id, jstring name, jintArray value) +Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int(JNIEnv *env, jclass clss, jlong type_id, jstring name, + jintArray value) { const char *memberName = NULL; jboolean isCopy; - jint *intBuf = NULL; + jint * intBuf = NULL; herr_t status = FAIL; UNUSED(clss); @@ -1186,13 +1140,12 @@ done: * Signature: (JLjava/lang/String;[B)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1insert - (JNIEnv *env, jclass clss, jlong type_id, jstring name, jbyteArray value) +Java_hdf_hdf5lib_H5_H5Tenum_1insert(JNIEnv *env, jclass clss, jlong type_id, jstring name, jbyteArray value) { const char *memberName = NULL; jboolean isCopy; - jbyte *memberBuf = NULL; - herr_t status = FAIL; + jbyte * memberBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1221,15 +1174,14 @@ done: * Signature: (J[I[Ljava/lang/String;I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int - (JNIEnv *env, jclass clss, jlong type_id, jintArray value, jobjectArray name, - jint size) +Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int(JNIEnv *env, jclass clss, jlong type_id, jintArray value, + jobjectArray name, jint size) { - jboolean isCopy; - jstring str; - jint *intP = NULL; - char *nameP = NULL; - herr_t status = FAIL; + jboolean isCopy; + jstring str; + jint * intP = NULL; + char * nameP = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1238,7 +1190,7 @@ Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int if (size <= 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof_int: name size < 0"); - if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) + if (NULL == (nameP = (char *)HDmalloc(sizeof(char) * (size_t)size))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tenum_nameof_int: failed to allocate name buffer"); PIN_INT_ARRAY(ENVONLY, value, intP, &isCopy, "H5Tenum_nameof_int: value not pinned"); @@ -1268,14 +1220,13 @@ done: * Signature: (J[BJ)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1nameof - (JNIEnv *env, jclass clss, jlong type_id, jbyteArray value, jlong size) +Java_hdf_hdf5lib_H5_H5Tenum_1nameof(JNIEnv *env, jclass clss, jlong type_id, jbyteArray value, jlong size) { - jboolean isCopy; - jstring str = NULL; - jbyte *byteP = NULL; - char *nameP = NULL; - herr_t status = FAIL; + jboolean isCopy; + jstring str = NULL; + jbyte * byteP = NULL; + char * nameP = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1284,7 +1235,7 @@ Java_hdf_hdf5lib_H5_H5Tenum_1nameof if (NULL == value) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof: value is NULL"); - if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) + if (NULL == (nameP = (char *)HDmalloc(sizeof(char) * (size_t)size))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tenum_nameof: failed to allocate name buffer"); PIN_BYTE_ARRAY(ENVONLY, value, byteP, &isCopy, "H5Tenum_nameof: value not pinned"); @@ -1311,13 +1262,13 @@ done: * Signature: (JLjava/lang/String;[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int - (JNIEnv *env, jclass clss, jlong type_id, jstring name, jintArray value) +Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int(JNIEnv *env, jclass clss, jlong type_id, jstring name, + jintArray value) { const char *enumValue = NULL; jboolean isCopy; - jint *enumValueBuf = NULL; - herr_t status = FAIL; + jint * enumValueBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1348,13 +1299,12 @@ done: * Signature: (JLjava/lang/String;[B)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1valueof - (JNIEnv *env, jclass clss, jlong type_id, jstring name, jbyteArray value) +Java_hdf_hdf5lib_H5_H5Tenum_1valueof(JNIEnv *env, jclass clss, jlong type_id, jstring name, jbyteArray value) { const char *enumValue = NULL; jboolean isCopy; - jbyte *enumValueBuf = NULL; - herr_t status = FAIL; + jbyte * enumValueBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1383,12 +1333,12 @@ done: * Signature: (JI[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int - (JNIEnv *env, jclass clss, jlong type_id, jint membno, jintArray value) +Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int(JNIEnv *env, jclass clss, jlong type_id, jint membno, + jintArray value) { - jboolean isCopy; - jint *intP = NULL; - herr_t status = FAIL; + jboolean isCopy; + jint * intP = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1413,12 +1363,12 @@ done: * Signature: (JI[B)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1value - (JNIEnv *env, jclass clss, jlong type_id, jint membno, jbyteArray value) +Java_hdf_hdf5lib_H5_H5Tget_1member_1value(JNIEnv *env, jclass clss, jlong type_id, jint membno, + jbyteArray value) { - jboolean isCopy; - jbyte *byteP = NULL; - herr_t status = FAIL; + jboolean isCopy; + jbyte * byteP = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1441,8 +1391,7 @@ done: * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims(JNIEnv *env, jclass clss, jlong type_id) { int ndims = -1; @@ -1461,15 +1410,15 @@ done: * Signature: (J[I[I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1array_1dims - (JNIEnv *env, jclass clss, jlong type_id, jintArray dims, jintArray perms) +Java_hdf_hdf5lib_H5_H5Tget_1array_1dims(JNIEnv *env, jclass clss, jlong type_id, jintArray dims, + jintArray perms) { - jboolean isCopy; - hsize_t *cdims = NULL; - size_t i; - jsize dlen; - jint *dimsP = NULL; - int ndims = -1; + jboolean isCopy; + hsize_t *cdims = NULL; + size_t i; + jsize dlen; + jint * dimsP = NULL; + int ndims = -1; UNUSED(clss); UNUSED(perms); @@ -1484,14 +1433,14 @@ Java_hdf_hdf5lib_H5_H5Tget_1array_1dims H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tget_array_dims: dims array length < 0"); } - if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) + if (NULL == (cdims = (hsize_t *)HDmalloc((size_t)dlen * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tget_array_dims: failed to allocate dimension buffer"); if ((ndims = H5Tget_array_dims2((hid_t)type_id, cdims)) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0; i < (size_t) dlen; i++) { - dimsP[i] = (jint) cdims[i]; + for (i = 0; i < (size_t)dlen; i++) { + dimsP[i] = (jint)cdims[i]; } /* end for */ done: @@ -1509,8 +1458,7 @@ done: * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Tis_1variable_1str - (JNIEnv *env, jclass clss, jlong type_id) +Java_hdf_hdf5lib_H5_H5Tis_1variable_1str(JNIEnv *env, jclass clss, jlong type_id) { htri_t bval = JNI_FALSE; @@ -1531,8 +1479,7 @@ done: * Signature: (JI)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tget_1native_1type - (JNIEnv *env, jclass clss, jlong type_id, jint direction) +Java_hdf_hdf5lib_H5__1H5Tget_1native_1type(JNIEnv *env, jclass clss, jlong type_id, jint direction) { hid_t native_tid = H5I_INVALID_HID; @@ -1551,8 +1498,7 @@ done: * Signature: (JI)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Tdetect_1class - (JNIEnv *env, jclass clss, jlong type_id, jint dtype_class) +Java_hdf_hdf5lib_H5_H5Tdetect_1class(JNIEnv *env, jclass clss, jlong type_id, jint dtype_class) { htri_t bval = JNI_FALSE; @@ -1573,12 +1519,11 @@ done: * Signature: (JLjava/lang/String;JJJJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tcommit - (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type, - jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) +Java_hdf_hdf5lib_H5_H5Tcommit(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type, + jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) { const char *datatypeName = NULL; - herr_t status = FAIL; + herr_t status = FAIL; UNUSED(clss); @@ -1587,7 +1532,8 @@ Java_hdf_hdf5lib_H5_H5Tcommit PIN_JAVA_STRING(ENVONLY, name, datatypeName, NULL, "H5Tcommit: datatype name not pinned"); - if ((status = H5Tcommit2((hid_t)loc_id, datatypeName, (hid_t)type, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) + if ((status = H5Tcommit2((hid_t)loc_id, datatypeName, (hid_t)type, (hid_t)link_plist_id, + (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1601,15 +1547,14 @@ done: * Signature: (JI[J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tarray_1create2 - (JNIEnv *env, jclass clss, jlong base_id, jint rank, jlongArray dims) +Java_hdf_hdf5lib_H5__1H5Tarray_1create2(JNIEnv *env, jclass clss, jlong base_id, jint rank, jlongArray dims) { - jboolean isCopy; - hsize_t *cdims = NULL; - size_t i; - jlong *dimsP = NULL; - jsize dlen; - hid_t retVal = H5I_INVALID_HID; + jboolean isCopy; + hsize_t *cdims = NULL; + size_t i; + jlong * dimsP = NULL; + jsize dlen; + hid_t retVal = H5I_INVALID_HID; UNUSED(clss); @@ -1628,10 +1573,10 @@ Java_hdf_hdf5lib_H5__1H5Tarray_1create2 if (dlen != rank) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: dimension array length != array rank"); - if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) + if (NULL == (cdims = (hsize_t *)HDmalloc((size_t)dlen * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tarray_create: failed to allocate dimension buffer"); - for (i = 0; i < (size_t) dlen; i++) { + for (i = 0; i < (size_t)dlen; i++) { cdims[i] = (hsize_t)dimsP[i]; } /* end for */ @@ -1653,15 +1598,14 @@ done: * Signature: (J[J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 - (JNIEnv *env, jclass clss, jlong type_id, jlongArray dims) +Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2(JNIEnv *env, jclass clss, jlong type_id, jlongArray dims) { - jboolean isCopy; - hsize_t *cdims = NULL; - size_t i; - jlong *dimsP = NULL; - jsize dlen; - int ndims = -1; + jboolean isCopy; + hsize_t *cdims = NULL; + size_t i; + jlong * dimsP = NULL; + jsize dlen; + int ndims = -1; UNUSED(clss); @@ -1675,14 +1619,14 @@ Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tarray_get_dims2: dims array length < 0"); } - if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) + if (NULL == (cdims = (hsize_t *)HDmalloc((size_t)dlen * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Tarray_get_dims2: failed to allocate dimension buffer"); - if ((ndims = H5Tget_array_dims2((hid_t)type_id, (hsize_t*)cdims)) < 0) + if ((ndims = H5Tget_array_dims2((hid_t)type_id, (hsize_t *)cdims)) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0; i < (size_t) dlen; i++) { - dimsP[i] = (jlong) cdims[i]; + for (i = 0; i < (size_t)dlen; i++) { + dimsP[i] = (jlong)cdims[i]; } /* end for */ done: @@ -1700,14 +1644,13 @@ done: * Signature: (JJJ[B[BJ)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tconvert - (JNIEnv *env, jclass clss, jlong src_id, jlong dst_id, jlong nelmts, - jbyteArray buf, jbyteArray background, jlong plist_id) +Java_hdf_hdf5lib_H5_H5Tconvert(JNIEnv *env, jclass clss, jlong src_id, jlong dst_id, jlong nelmts, + jbyteArray buf, jbyteArray background, jlong plist_id) { - jboolean isCopy; - jbyte *bufP = NULL; - jbyte *bgP = NULL; - herr_t status = FAIL; + jboolean isCopy; + jbyte * bufP = NULL; + jbyte * bgP = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -1719,7 +1662,8 @@ Java_hdf_hdf5lib_H5_H5Tconvert if (background) PIN_BYTE_ARRAY(ENVONLY, background, bgP, &isCopy, "H5Tconvert: background buffer not pinned"); - if ((status = H5Tconvert((hid_t)src_id, (hid_t)dst_id, (size_t)nelmts, (void *)bufP, (void *)bgP, (hid_t)plist_id)) < 0) + if ((status = H5Tconvert((hid_t)src_id, (hid_t)dst_id, (size_t)nelmts, (void *)bufP, (void *)bgP, + (hid_t)plist_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: @@ -1763,7 +1707,6 @@ done: return; } - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5tImp.h b/java/src/jni/h5tImp.h index 78e4561..41f7681 100644 --- a/java/src/jni/h5tImp.h +++ b/java/src/jni/h5tImp.h @@ -26,612 +26,481 @@ extern "C" { * Method: _H5Topen2 * Signature: (JLjava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Topen2 - (JNIEnv *, jclass, jlong, jstring, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Topen2(JNIEnv *, jclass, jlong, jstring, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tcommitted * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Tcommitted - (JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tcommitted(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Tcreate * Signature: (IJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tcreate - (JNIEnv *, jclass, jint, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tcreate(JNIEnv *, jclass, jint, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Tcopy * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tcopy - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tcopy(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tequal * Signature: (JJ)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Tequal - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tequal(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tlock * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tlock - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tlock(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_class * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1class - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1class(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_size * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1size - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1size(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_size * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1size - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1size(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_order * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1order - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1order(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_order * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1order - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1order(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_precision * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1precision - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1precision(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_precision_long * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1precision_1long - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1precision_1long(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_precision * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1precision - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1precision(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_offset * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1offset - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1offset(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_offset * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1offset - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1offset(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_pad * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1pad - (JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1pad(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_pad * Signature: (JII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1pad - (JNIEnv *, jclass, jlong, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1pad(JNIEnv *, jclass, jlong, jint, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_sign * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1sign - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1sign(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_sign * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1sign - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1sign(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_fields_int * Signature: (J[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1fields_1int - (JNIEnv *, jclass, jlong, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1fields_1int(JNIEnv *, jclass, jlong, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_fields * Signature: (J[J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1fields - (JNIEnv *, jclass, jlong, jlongArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tget_1fields(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_fields * Signature: (JJJJJJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1fields - (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tset_1fields(JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_ebias * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1ebias - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1ebias(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_ebias_long * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_ebias * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1ebias - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1ebias(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_norm * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1norm - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1norm(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_norm * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1norm - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1norm(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_inpad * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1inpad - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1inpad(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_inpad * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1inpad - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1inpad(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_cset * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1cset - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1cset(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_cset * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1cset - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1cset(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_strpad * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1strpad - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1strpad(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_strpad * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1strpad - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1strpad(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_nmembers * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1nmembers - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1nmembers(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_member_name * Signature: (JI)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1name - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1name(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_member_index * Signature: (JLjava/lang/String)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1index - (JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1index(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_member_type * Signature: (JI)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tget_1member_1type - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1member_1type(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_member_offset * Signature: (JI)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1offset - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1offset(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_member_class * Signature: (JI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1class - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1class(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tinsert * Signature: (JLjava/lang/String;JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tinsert - (JNIEnv *, jclass, jlong, jstring, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tinsert(JNIEnv *, jclass, jlong, jstring, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tpack * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tpack - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tpack(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Treclaim * Signature: (JJJ[B)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Treclaim - (JNIEnv*, jclass, jlong, jlong, jlong, jbyteArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Treclaim(JNIEnv *, jclass, jlong, jlong, jlong, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: _H5Tclose * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Tclose - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Tclose(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Tvlen_create * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tvlen_1create - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tvlen_1create(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tset_tag * Signature: (JLjava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tset_1tag - (JNIEnv *, jclass, jlong, jstring); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1tag(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_tag * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1tag - (JNIEnv *, jclass, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tget_1tag(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_super * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tget_1super - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1super(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Tenum_create * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tenum_1create - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tenum_1create(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tenum_insert_int * Signature: (JLjava/lang/String;[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int - (JNIEnv *, jclass, jlong, jstring, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int(JNIEnv *, jclass, jlong, jstring, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tenum_insert * Signature: (JLjava/lang/String;[B)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1insert - (JNIEnv *, jclass, jlong, jstring, jbyteArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1insert(JNIEnv *, jclass, jlong, jstring, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tenum_nameof_int * Signature: (J[I[Ljava/lang/String;I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int - (JNIEnv *, jclass, jlong, jintArray, jobjectArray, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int(JNIEnv *, jclass, jlong, jintArray, + jobjectArray, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tenum_nameof * Signature: (J[BJ)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1nameof - (JNIEnv *, jclass, jlong, jbyteArray, jlong); +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1nameof(JNIEnv *, jclass, jlong, jbyteArray, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tenum_valueof_int * Signature: (JLjava/lang/String;[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int - (JNIEnv *, jclass, jlong, jstring, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int(JNIEnv *, jclass, jlong, jstring, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tenum_valueof * Signature: (JLjava/lang/String;[B)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tenum_1valueof - (JNIEnv *, jclass, jlong, jstring, jbyteArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1valueof(JNIEnv *, jclass, jlong, jstring, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_member_value_int * Signature: (JI[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int - (JNIEnv *, jclass, jlong, jint, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int(JNIEnv *, jclass, jlong, jint, + jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_member_value * Signature: (JI[B)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1member_1value - (JNIEnv *, jclass, jlong, jint, jbyteArray); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1value(JNIEnv *, jclass, jlong, jint, jbyteArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_array_ndims * Signature: (J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_array_dims * Signature: (J[I[I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1array_1dims - (JNIEnv *, jclass, jlong, jintArray, jintArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1array_1dims(JNIEnv *, jclass, jlong, jintArray, jintArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tis_variable_str * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Tis_1variable_1str - (JNIEnv *, jclass, jlong); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tis_1variable_1str(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_native_type * Signature: (JI)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tget_1native_1type - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1native_1type(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tdetect_class * Signature: (JI)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Tdetect_1class - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tdetect_1class(JNIEnv *, jclass, jlong, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Tcommit * Signature: (JLjava/lang/String;JJJJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tcommit - (JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tcommit(JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: _H5Tarray_create2 * Signature: (JI[J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Tarray_1create2 - (JNIEnv *, jclass, jlong, jint, jlongArray); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tarray_1create2(JNIEnv *, jclass, jlong, jint, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_array_dims2 * Signature: (J[J)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 - (JNIEnv *, jclass, jlong, jlongArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2(JNIEnv *, jclass, jlong, jlongArray); /* * Class: hdf_hdf5lib_H5 * Method: H5Tconvert * Signature: (JJJ[B[BJ)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tconvert - (JNIEnv *, jclass, jlong, jlong, jlong, jbyteArray, jbyteArray, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tconvert(JNIEnv *, jclass, jlong, jlong, jlong, jbyteArray, + jbyteArray, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Tflush * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Tflush - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tflush(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Trefresh * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Trefresh - (JNIEnv*, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Trefresh(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index f45902f..eff6d5b 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -31,8 +31,8 @@ extern "C" { #define SKIP_UNUSED_DUMP_ROUTINES /* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */ -hsize_t H5TOOLS_BUFSIZE = (32 * 1024 * 1024); /* 32 MB */ -int H5TOOLS_TEXT_BLOCK = 16; /* Number of elements on a line in a text export file */ +hsize_t H5TOOLS_BUFSIZE = (32 * 1024 * 1024); /* 32 MB */ +int H5TOOLS_TEXT_BLOCK = 16; /* Number of elements on a line in a text export file */ /* * Pointer to the JNI's Virtual Machine; used for callback functions. @@ -47,44 +47,46 @@ jobject get_callback; jobject set_callback; jobject delete_callback; -H5E_auto2_t efunc; -void *edata; +H5E_auto2_t efunc; +void * edata; /********************/ /* Local Prototypes */ /********************/ #ifndef SKIP_UNUSED_DUMP_ROUTINES -static int h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); -static int h5str_dump_region_points(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); +static int h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); +static int h5str_dump_region_points(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); #endif -static int h5str_is_zero(const void *_mem, size_t size); -static hid_t h5str_get_native_type(hid_t type); -static hid_t h5str_get_little_endian_type(hid_t type); -static hid_t h5str_get_big_endian_type(hid_t type); -static htri_t h5str_detect_vlen(hid_t tid); -static htri_t h5str_detect_vlen_str(hid_t tid); -static int h5tools_dump_simple_data(JNIEnv *env, FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts); -static int h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts); -static int render_bin_output_region_data_blocks(FILE *stream, hid_t region_id, - hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata); -static int render_bin_output_region_blocks(FILE *stream, hid_t region_space, - hid_t region_id, hid_t container); -static int render_bin_output_region_data_points(FILE *stream, hid_t region_space, hid_t region_id, - hid_t container, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata); -static int render_bin_output_region_points(FILE *stream, hid_t region_space, - hid_t region_id, hid_t container); +static int h5str_is_zero(const void *_mem, size_t size); +static hid_t h5str_get_native_type(hid_t type); +static hid_t h5str_get_little_endian_type(hid_t type); +static hid_t h5str_get_big_endian_type(hid_t type); +static htri_t h5str_detect_vlen(hid_t tid); +static htri_t h5str_detect_vlen_str(hid_t tid); +static int h5tools_dump_simple_data(JNIEnv *env, FILE *stream, hid_t container, hid_t type, void *_mem, + hsize_t nelmts); +static int h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, + hsize_t block_nelmts); +static int render_bin_output_region_data_blocks(FILE *stream, hid_t region_id, hid_t container, int ndims, + hid_t type_id, hssize_t nblocks, hsize_t *ptdata); +static int render_bin_output_region_blocks(FILE *stream, hid_t region_space, hid_t region_id, + hid_t container); +static int render_bin_output_region_data_points(FILE *stream, hid_t region_space, hid_t region_id, + hid_t container, int ndims, hid_t type_id, hssize_t npoints, + hsize_t *ptdata); +static int render_bin_output_region_points(FILE *stream, hid_t region_space, hid_t region_id, + hid_t container); /* Strings for output */ -#define H5_TOOLS_GROUP "GROUP" -#define H5_TOOLS_DATASET "DATASET" -#define H5_TOOLS_DATATYPE "DATATYPE" -#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE" +#define H5_TOOLS_GROUP "GROUP" +#define H5_TOOLS_DATASET "DATASET" +#define H5_TOOLS_DATATYPE "DATATYPE" +#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE" /** frees memory held by array of strings */ void -h5str_array_free - (char **strs, size_t len) +h5str_array_free(char **strs, size_t len) { size_t i; @@ -101,20 +103,18 @@ h5str_array_free /** allocate a new str with given length */ void -h5str_new - (h5str_t *str, size_t len) +h5str_new(h5str_t *str, size_t len) { if (str && len > 0) { - str->s = (char *)HDmalloc(len); - str->max = len; + str->s = (char *)HDmalloc(len); + str->max = len; str->s[0] = '\0'; } /* end if */ } /* end h5str_new */ /** free string memory */ void -h5str_free - (h5str_t *str) +h5str_free(h5str_t *str) { if (str && str->max > 0) { HDfree(str->s); @@ -127,15 +127,14 @@ h5str_free * TODO: no error return. malloc can fail. */ void -h5str_resize - (h5str_t *str, size_t new_len) +h5str_resize(h5str_t *str, size_t new_len) { char *new_str; if (!str || new_len <= 0 || str->max == new_len) return; - if (NULL == (new_str = (char *) HDmalloc(new_len))) + if (NULL == (new_str = (char *)HDmalloc(new_len))) return; if (new_len > str->max) /* increase memory */ @@ -144,7 +143,7 @@ h5str_resize HDstrncpy(new_str, str->s, new_len - 1); HDfree(str->s); - str->s = new_str; + str->s = new_str; str->max = new_len; } /* end h5str_resize */ @@ -152,9 +151,8 @@ h5str_resize Return Value: the char string point to str->s */ -char* -h5str_append - (h5str_t *str, const char* cstr) +char * +h5str_append(h5str_t *str, const char *cstr) { size_t len; @@ -180,22 +178,20 @@ h5str_append * FAILURE: 0 */ size_t -h5str_convert - (JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf, size_t out_buf_offset) +h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf, size_t out_buf_offset) { unsigned char *ucptr = NULL; static char fmt_llong[8], fmt_ullong[8]; - H5T_class_t tclass = H5T_NO_CLASS; - const char delimiter[] = " ," H5_COMPOUND_BEGIN_INDICATOR H5_COMPOUND_END_INDICATOR \ - H5_ARRAY_BEGIN_INDICATOR H5_ARRAY_END_INDICATOR \ - H5_VLEN_BEGIN_INDICATOR H5_VLEN_END_INDICATOR; - size_t typeSize = 0; - hid_t mtid = H5I_INVALID_HID; - char *this_str = NULL; - char *token; - char *cptr = NULL; - int n; - size_t retVal = 0; + H5T_class_t tclass = H5T_NO_CLASS; + const char delimiter[] = " ," H5_COMPOUND_BEGIN_INDICATOR H5_COMPOUND_END_INDICATOR + H5_ARRAY_BEGIN_INDICATOR H5_ARRAY_END_INDICATOR H5_VLEN_BEGIN_INDICATOR H5_VLEN_END_INDICATOR; + size_t typeSize = 0; + hid_t mtid = H5I_INVALID_HID; + char * this_str = NULL; + char * token; + char * cptr = NULL; + int n; + size_t retVal = 0; if (!in_str) H5_NULL_ARGUMENT_ERROR(ENVONLY, "h5str_convert: in_str is NULL"); @@ -203,8 +199,8 @@ h5str_convert H5_NULL_ARGUMENT_ERROR(ENVONLY, "h5str_convert: out_buf is NULL"); this_str = *in_str; - cptr = &(((char *) out_buf)[out_buf_offset]); - ucptr = &(((unsigned char *) out_buf)[out_buf_offset]); + cptr = &(((char *)out_buf)[out_buf_offset]); + ucptr = &(((unsigned char *)out_buf)[out_buf_offset]); if (H5T_NO_CLASS == (tclass = H5Tget_class(tid))) H5_LIBRARY_ERROR(ENVONLY); @@ -220,13 +216,11 @@ h5str_convert } /* end if */ switch (tclass) { - case H5T_FLOAT: - { + case H5T_FLOAT: { token = HDstrtok(this_str, delimiter); switch (typeSize) { - case sizeof(float): - { + case sizeof(float): { float tmp_float = 0.0f; sscanf(token, "%f", &tmp_float); @@ -234,8 +228,7 @@ h5str_convert break; } - case sizeof(double): - { + case sizeof(double): { double tmp_double = 0.0; sscanf(token, "%lf", &tmp_double); @@ -243,8 +236,7 @@ h5str_convert break; } #if H5_SIZEOF_LONG_DOUBLE != 0 && H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - case sizeof(long double): - { + case sizeof(long double): { long double tmp_ldouble = 0.0; sscanf(token, "%Lf", &tmp_ldouble); @@ -254,7 +246,9 @@ h5str_convert #endif default: - H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_convert: floating-point datatype size didn't match any of expected sizes"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, + "h5str_convert: floating-point datatype size didn't match any of expected sizes"); break; } @@ -263,8 +257,7 @@ h5str_convert break; } - case H5T_STRING: - { + case H5T_STRING: { size_t len = HDstrlen(this_str); if (len > 0) { @@ -280,8 +273,7 @@ h5str_convert break; } - case H5T_INTEGER: - { + case H5T_INTEGER: { H5T_sign_t nsign = H5T_SGN_ERROR; if (H5T_SGN_ERROR == (nsign = H5Tget_sign(tid))) @@ -290,10 +282,9 @@ h5str_convert token = HDstrtok(this_str, delimiter); switch (typeSize) { - case sizeof(char): - { + case sizeof(char): { unsigned char tmp_uchar = 0; - signed char tmp_char = 0; + signed char tmp_char = 0; if (H5T_SGN_NONE == nsign) { sscanf(token, "%hhu", &tmp_uchar); @@ -307,10 +298,9 @@ h5str_convert break; } - case sizeof(short): - { + case sizeof(short): { unsigned short tmp_ushort = 0; - short tmp_short = 0; + short tmp_short = 0; if (H5T_SGN_NONE == nsign) { sscanf(token, "%hu", &tmp_ushort); @@ -324,10 +314,9 @@ h5str_convert break; } - case sizeof(int): - { + case sizeof(int): { unsigned int tmp_uint = 0; - int tmp_int = 0; + int tmp_int = 0; if (H5T_SGN_NONE == nsign) { sscanf(token, "%u", &tmp_uint); @@ -342,10 +331,9 @@ h5str_convert } #if H5_SIZEOF_LONG != H5_SIZEOF_INT - case sizeof(long): - { + case sizeof(long): { unsigned long tmp_ulong = 0; - long tmp_long = 0; + long tmp_long = 0; if (H5T_SGN_NONE == nsign) { sscanf(token, "%lu", &tmp_ulong); @@ -360,10 +348,9 @@ h5str_convert } #endif #if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG - case sizeof(long long): - { + case sizeof(long long): { unsigned long long tmp_ullong = 0; - long long tmp_llong = 0; + long long tmp_llong = 0; if (H5T_SGN_NONE == nsign) { sscanf(token, fmt_ullong, &tmp_ullong); @@ -379,7 +366,8 @@ h5str_convert #endif default: - H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_convert: integer datatype size didn't match any of expected sizes"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, "h5str_convert: integer datatype size didn't match any of expected sizes"); break; } @@ -388,8 +376,7 @@ h5str_convert break; } - case H5T_COMPOUND: - { + case H5T_COMPOUND: { unsigned i; size_t member_offset; @@ -397,11 +384,14 @@ h5str_convert H5_LIBRARY_ERROR(ENVONLY); /* Skip whitespace and compound indicators */ - while (*this_str == ' ') this_str++; - if (*this_str == '{') this_str++; - while (*this_str == ' ') this_str++; - - for (i = 0; i < (unsigned) n; i++) { + while (*this_str == ' ') + this_str++; + if (*this_str == '{') + this_str++; + while (*this_str == ' ') + this_str++; + + for (i = 0; i < (unsigned)n; i++) { member_offset = H5Tget_member_offset(tid, i); if ((mtid = H5Tget_member_type(tid, i)) < 0) @@ -413,9 +403,12 @@ h5str_convert } /* Skip whitespace and commas */ - while (*this_str == ' ') this_str++; - if (*this_str == ',') this_str++; - while (*this_str == ' ') this_str++; + while (*this_str == ' ') + this_str++; + if (*this_str == ',') + this_str++; + while (*this_str == ' ') + this_str++; if (H5Tclose(mtid) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -423,11 +416,14 @@ h5str_convert } /* Skip whitespace and compound indicators */ - while (*this_str == ' ') this_str++; - if (*this_str == '}') this_str++; - while (*this_str == ' ') this_str++; + while (*this_str == ' ') + this_str++; + if (*this_str == '}') + this_str++; + while (*this_str == ' ') + this_str++; - retVal = typeSize * (size_t) n; + retVal = typeSize * (size_t)n; break; } @@ -437,47 +433,41 @@ h5str_convert cptr = NULL; break; - case H5T_ENUM: - { + case H5T_ENUM: { void *value; token = HDstrtok(this_str, delimiter); switch (typeSize) { - case sizeof(char): - { + case sizeof(char): { unsigned char tmp_uchar = 0; - value = &tmp_uchar; + value = &tmp_uchar; break; } - case sizeof(short): - { + case sizeof(short): { unsigned short tmp_ushort = 0; - value = &tmp_ushort; + value = &tmp_ushort; break; } #if H5_SIZEOF_LONG != H5_SIZEOF_INT - case sizeof(long): - { + case sizeof(long): { unsigned long tmp_ulong = 0; - value = &tmp_ulong; + value = &tmp_ulong; break; } #endif #if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG - case sizeof(long long): - { + case sizeof(long long): { unsigned long long tmp_ullong = 0; - value = &tmp_ullong; + value = &tmp_ullong; break; } #endif - default: - { + default: { unsigned int tmp_uint = 0; - value = &tmp_uint; + value = &tmp_uint; break; } } @@ -492,16 +482,18 @@ h5str_convert break; } - case H5T_ARRAY: - { + case H5T_ARRAY: { hsize_t i, dims[H5S_MAX_RANK], total_elmts; size_t baseTypeSize; int rank = 0; /* Skip whitespace and array indicators */ - while (*this_str == ' ') this_str++; - if (*this_str == '[') this_str++; - while (*this_str == ' ') this_str++; + while (*this_str == ' ') + this_str++; + if (*this_str == '[') + this_str++; + while (*this_str == ' ') + this_str++; if ((mtid = H5Tget_super(tid)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -515,10 +507,10 @@ h5str_convert if (H5Tget_array_dims2(tid, dims) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0, total_elmts = 1; i < (hsize_t) rank; i++) + for (i = 0, total_elmts = 1; i < (hsize_t)rank; i++) total_elmts *= dims[i]; - if (NULL == (cptr = (char *) HDcalloc((size_t)total_elmts, baseTypeSize))) + if (NULL == (cptr = (char *)HDcalloc((size_t)total_elmts, baseTypeSize))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_convert: failed to allocate array buffer"); for (i = 0; i < total_elmts; i++) { @@ -528,9 +520,12 @@ h5str_convert } /* Skip whitespace and commas */ - while (*this_str == ' ') this_str++; - if (*this_str == ',') this_str++; - while (*this_str == ' ') this_str++; + while (*this_str == ' ') + this_str++; + if (*this_str == ',') + this_str++; + while (*this_str == ' ') + this_str++; } if (H5Tclose(mtid) < 0) @@ -538,20 +533,22 @@ h5str_convert mtid = H5I_INVALID_HID; /* Skip whitespace and array indicators */ - while (*this_str == ' ') this_str++; - if (*this_str == ']') this_str++; - while (*this_str == ' ') this_str++; + while (*this_str == ' ') + this_str++; + if (*this_str == ']') + this_str++; + while (*this_str == ' ') + this_str++; retVal = typeSize * total_elmts; break; } - case H5T_VLEN: - { - size_t i, baseTypeSize; - hvl_t *vl_buf = (hvl_t *) out_buf; - char cur_char; + case H5T_VLEN: { + size_t i, baseTypeSize; + hvl_t *vl_buf = (hvl_t *)out_buf; + char cur_char; if ((mtid = H5Tget_super(tid)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -564,16 +561,19 @@ h5str_convert vl_buf->len = 1; /* Skip whitespace and vlen indicators */ - while (*this_str == ' ') this_str++; - if (*this_str == '(') this_str++; - while (*this_str == ' ') this_str++; + while (*this_str == ' ') + this_str++; + if (*this_str == '(') + this_str++; + while (*this_str == ' ') + this_str++; cur_char = *this_str; for (i = 0; cur_char != ')' && cur_char != '\0'; i++) { if (i >= vl_buf->len) { char *tmp_realloc; - if (NULL == (tmp_realloc = (char *) HDrealloc(vl_buf->p, vl_buf->len * 2 * baseTypeSize))) + if (NULL == (tmp_realloc = (char *)HDrealloc(vl_buf->p, vl_buf->len * 2 * baseTypeSize))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_convert: failed to reallocate vlen buffer"); vl_buf->len *= 2; vl_buf->p = tmp_realloc; @@ -586,9 +586,12 @@ h5str_convert } /* Skip whitespace and commas */ - while (*this_str == ' ') this_str++; - if (*this_str == ',') this_str++; - while (*this_str == ' ') this_str++; + while (*this_str == ' ') + this_str++; + if (*this_str == ',') + this_str++; + while (*this_str == ' ') + this_str++; } vl_buf->len = i; @@ -598,9 +601,12 @@ h5str_convert mtid = H5I_INVALID_HID; /* Skip whitespace and vlen indicators */ - while (*this_str == ' ') this_str++; - if (*this_str == ')') this_str++; - while (*this_str == ' ') this_str++; + while (*this_str == ' ') + this_str++; + if (*this_str == ')') + this_str++; + while (*this_str == ' ') + this_str++; retVal = typeSize; @@ -608,8 +614,7 @@ h5str_convert } case H5T_NCLASSES: - case H5T_NO_CLASS: - { + case H5T_NO_CLASS: { H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_convert: invalid datatype class"); break; } @@ -617,8 +622,7 @@ h5str_convert case H5T_TIME: case H5T_BITFIELD: case H5T_OPAQUE: - default: - { + default: { /* All other types get copied raw */ HDmemcpy(ucptr, this_str, typeSize); @@ -646,9 +650,9 @@ done: void h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, hid_t container, void *ref_p) { - ssize_t buf_size; - char *ref_name = NULL; - const H5R_ref_t *ref_vp = (H5R_ref_t *)ref_p; + ssize_t buf_size; + char * ref_name = NULL; + const H5R_ref_t *ref_vp = (H5R_ref_t *)ref_p; UNUSED(container); @@ -706,18 +710,18 @@ done: * FAILURE: 0 */ size_t -h5str_sprintf - (JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf, size_t in_buf_len, int expand_data) +h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf, size_t in_buf_len, + int expand_data) { - unsigned char *ucptr = (unsigned char *) in_buf; + unsigned char *ucptr = (unsigned char *)in_buf; static char fmt_llong[8], fmt_ullong[8]; - H5T_class_t tclass = H5T_NO_CLASS; + H5T_class_t tclass = H5T_NO_CLASS; size_t typeSize = 0; - H5T_sign_t nsign = H5T_SGN_ERROR; - hid_t mtid = H5I_INVALID_HID; - hid_t obj = H5I_INVALID_HID; - char *cptr = (char *) in_buf; - char *this_str = NULL; + H5T_sign_t nsign = H5T_SGN_ERROR; + hid_t mtid = H5I_INVALID_HID; + hid_t obj = H5I_INVALID_HID; + char * cptr = (char *)in_buf; + char * this_str = NULL; int n; size_t retVal = 0; @@ -742,16 +746,14 @@ h5str_sprintf } /* end if */ switch (tclass) { - case H5T_FLOAT: - { + case H5T_FLOAT: { switch (typeSize) { - case sizeof(float): - { + case sizeof(float): { float tmp_float = 0.0f; HDmemcpy(&tmp_float, cptr, sizeof(float)); - if (NULL == (this_str = (char *) HDmalloc(25))) + if (NULL == (this_str = (char *)HDmalloc(25))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%g", tmp_float) < 0) @@ -760,13 +762,12 @@ h5str_sprintf break; } - case sizeof(double): - { + case sizeof(double): { double tmp_double = 0.0; HDmemcpy(&tmp_double, cptr, sizeof(double)); - if (NULL == (this_str = (char *) HDmalloc(25))) + if (NULL == (this_str = (char *)HDmalloc(25))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%g", tmp_double) < 0) @@ -775,13 +776,12 @@ h5str_sprintf break; } #if H5_SIZEOF_LONG_DOUBLE != 0 && H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - case sizeof(long double): - { + case sizeof(long double): { long double tmp_ldouble = 0.0; HDmemcpy(&tmp_ldouble, cptr, sizeof(long double)); - if (NULL == (this_str = (char *) HDmalloc(27))) + if (NULL == (this_str = (char *)HDmalloc(27))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%Lf", tmp_ldouble) < 0) @@ -792,17 +792,18 @@ h5str_sprintf #endif default: - H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: floating-point datatype size didn't match any of expected sizes"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, + "h5str_sprintf: floating-point datatype size didn't match any of expected sizes"); break; } break; } - case H5T_STRING: - { - htri_t is_variable; - char *tmp_str; + case H5T_STRING: { + htri_t is_variable; + char * tmp_str; if ((is_variable = H5Tis_variable_str(tid)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -820,13 +821,13 @@ h5str_sprintf /* Check for NULL pointer for string */ if (!tmp_str) { - if (NULL == (this_str = (char *) HDmalloc(5))) + if (NULL == (this_str = (char *)HDmalloc(5))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); HDstrncpy(this_str, "NULL", 5); } else { if (typeSize > 0) { - if (NULL == (this_str = (char *) HDmalloc(typeSize + 1))) + if (NULL == (this_str = (char *)HDmalloc(typeSize + 1))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); HDstrncpy(this_str, tmp_str, typeSize); @@ -837,23 +838,22 @@ h5str_sprintf break; } - case H5T_INTEGER: - { + case H5T_INTEGER: { if (H5T_SGN_ERROR == (nsign = H5Tget_sign(tid))) H5_LIBRARY_ERROR(ENVONLY); switch (typeSize) { - case sizeof(char): - { + case sizeof(char): { unsigned char tmp_uchar = 0; - char tmp_char = 0; + char tmp_char = 0; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_uchar, cptr, sizeof(unsigned char)); - if (NULL == (this_str = (char *) HDmalloc(7))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(7))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hhu", tmp_uchar) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -861,8 +861,9 @@ h5str_sprintf else { HDmemcpy(&tmp_char, cptr, sizeof(char)); - if (NULL == (this_str = (char *) HDmalloc(7))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(7))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hhd", tmp_char) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -871,16 +872,16 @@ h5str_sprintf break; } - case sizeof(short): - { + case sizeof(short): { unsigned short tmp_ushort = 0; - short tmp_short = 0; + short tmp_short = 0; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); - if (NULL == (this_str = (char *) HDmalloc(9))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(9))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hu", tmp_ushort) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -888,8 +889,9 @@ h5str_sprintf else { HDmemcpy(&tmp_short, cptr, sizeof(short)); - if (NULL == (this_str = (char *) HDmalloc(9))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(9))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%hd", tmp_short) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -898,16 +900,16 @@ h5str_sprintf break; } - case sizeof(int): - { + case sizeof(int): { unsigned int tmp_uint = 0; - int tmp_int = 0; + int tmp_int = 0; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_uint, cptr, sizeof(unsigned int)); - if (NULL == (this_str = (char *) HDmalloc(14))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(14))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%u", tmp_uint) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -915,8 +917,9 @@ h5str_sprintf else { HDmemcpy(&tmp_int, cptr, sizeof(int)); - if (NULL == (this_str = (char *) HDmalloc(14))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(14))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%d", tmp_int) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -925,16 +928,16 @@ h5str_sprintf break; } #if H5_SIZEOF_LONG != H5_SIZEOF_INT - case sizeof(long): - { + case sizeof(long): { unsigned long tmp_ulong = 0; - long tmp_long = 0; + long tmp_long = 0; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_ulong, cptr, sizeof(unsigned long)); - if (NULL == (this_str = (char *) HDmalloc(23))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(23))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%lu", tmp_ulong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -942,8 +945,9 @@ h5str_sprintf else { HDmemcpy(&tmp_long, cptr, sizeof(long)); - if (NULL == (this_str = (char *) HDmalloc(23))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(23))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%ld", tmp_long) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -953,16 +957,16 @@ h5str_sprintf } #endif #if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG - case sizeof(long long): - { + case sizeof(long long): { unsigned long long tmp_ullong = 0; - long long tmp_llong = 0; + long long tmp_llong = 0; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_ullong, cptr, sizeof(unsigned long long)); - if (NULL == (this_str = (char *) HDmalloc(25))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(25))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, fmt_ullong, tmp_ullong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -970,8 +974,9 @@ h5str_sprintf else { HDmemcpy(&tmp_llong, cptr, sizeof(long long)); - if (NULL == (this_str = (char *) HDmalloc(25))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(25))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, fmt_llong, tmp_llong) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); @@ -982,15 +987,15 @@ h5str_sprintf #endif default: - H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: integer datatype size didn't match any of expected sizes"); + H5_BAD_ARGUMENT_ERROR( + ENVONLY, "h5str_sprintf: integer datatype size didn't match any of expected sizes"); break; } break; } - case H5T_COMPOUND: - { + case H5T_COMPOUND: { unsigned i; size_t offset; @@ -1000,7 +1005,7 @@ h5str_sprintf if (!h5str_append(out_str, H5_COMPOUND_BEGIN_INDICATOR)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - for (i = 0; i < (unsigned) n; i++) { + for (i = 0; i < (unsigned)n; i++) { offset = H5Tget_member_offset(tid, i); if ((mtid = H5Tget_member_type(tid, i)) < 0) @@ -1009,7 +1014,7 @@ h5str_sprintf if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &cptr[offset], in_buf_len, expand_data)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if ((i + 1) < (unsigned) n) + if ((i + 1) < (unsigned)n) if (!h5str_append(out_str, ", ")) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1024,8 +1029,7 @@ h5str_sprintf break; } - case H5T_ENUM: - { + case H5T_ENUM: { char enum_name[1024]; if (H5Tenum_nameof(tid, cptr, enum_name, sizeof enum_name) >= 0) { @@ -1035,7 +1039,7 @@ h5str_sprintf else { size_t i; - if (NULL == (this_str = (char *) HDmalloc(4 * (typeSize + 1)))) + if (NULL == (this_str = (char *)HDmalloc(4 * (typeSize + 1)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (1 == typeSize) { @@ -1052,8 +1056,7 @@ h5str_sprintf break; } - case H5T_REFERENCE: - { + case H5T_REFERENCE: { if (h5str_is_zero(cptr, typeSize)) { if (!h5str_append(out_str, "NULL")) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1061,29 +1064,29 @@ h5str_sprintf } if (H5Tequal(tid, H5T_STD_REF)) { - H5O_type_t obj_type = -1; /* Object type */ - H5R_type_t ref_type; /* Reference type */ + H5O_type_t obj_type = -1; /* Object type */ + H5R_type_t ref_type; /* Reference type */ const H5R_ref_t *ref_vp = (H5R_ref_t *)cptr; ref_type = H5Rget_type(ref_vp); H5Rget_obj_type3(ref_vp, H5P_DEFAULT, &obj_type); switch (ref_type) { - case H5R_OBJECT1: - { + case H5R_OBJECT1: { /* Object references -- show the type and OID of the referenced object. */ H5O_info2_t oi; - if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { H5Oget_info3(obj, &oi, H5O_INFO_BASIC); - if(H5Oclose(obj) < 0) + if (H5Oclose(obj) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } else CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if (NULL == (this_str = (char *) HDmalloc(14))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%u-", (unsigned) oi.type) < 0) + if (NULL == (this_str = (char *)HDmalloc(14))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); + if (HDsprintf(this_str, "%u-", (unsigned)oi.type) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); if (!h5str_append(out_str, this_str)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1121,21 +1124,22 @@ h5str_sprintf H5Otoken_to_str(tid, &oi.token, &token_str); - if (NULL == (this_str = (char *) HDmalloc(64 + strlen(token_str) + 1))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + if (NULL == (this_str = (char *)HDmalloc(64 + strlen(token_str) + 1))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_sprintf: failed to allocate string buffer"); if (HDsprintf(this_str, "%lu:%s", oi.fileno, token_str) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); H5free_memory(token_str); } - } + } - break; + break; case H5R_DATASET_REGION1: if (!h5str_append(out_str, H5_TOOLS_DATASET)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - h5str_sprint_reference(ENVONLY, out_str, container, (void*)cptr); + h5str_sprint_reference(ENVONLY, out_str, container, (void *)cptr); break; case H5R_OBJECT2: switch (obj_type) { @@ -1160,17 +1164,17 @@ h5str_sprintf default: break; } /* end switch */ - h5str_sprint_reference(ENVONLY, out_str, container, (void*)cptr); + h5str_sprint_reference(ENVONLY, out_str, container, (void *)cptr); break; case H5R_DATASET_REGION2: if (!h5str_append(out_str, H5_TOOLS_DATASET)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - h5str_sprint_reference(ENVONLY, out_str, container, (void*)cptr); + h5str_sprint_reference(ENVONLY, out_str, container, (void *)cptr); break; case H5R_ATTR: if (!h5str_append(out_str, H5_TOOLS_ATTRIBUTE)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - h5str_sprint_reference(ENVONLY, out_str, container, (void*)cptr); + h5str_sprint_reference(ENVONLY, out_str, container, (void *)cptr); break; case H5R_BADTYPE: case H5R_MAXTYPE: @@ -1190,8 +1194,7 @@ h5str_sprintf break; } - case H5T_ARRAY: - { + case H5T_ARRAY: { hsize_t dims[H5S_MAX_RANK], i, total_elmts; size_t baseSize; int rank = 0; @@ -1211,11 +1214,12 @@ h5str_sprintf if (H5Tget_array_dims2(tid, dims) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (i = 0, total_elmts = 1; i < (hsize_t) rank; i++) + for (i = 0, total_elmts = 1; i < (hsize_t)rank; i++) total_elmts *= dims[i]; for (i = 0; i < total_elmts; i++) { - if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &(cptr[i * baseSize]), in_buf_len, expand_data)) + if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &(cptr[i * baseSize]), in_buf_len, + expand_data)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if ((i + 1) < total_elmts) @@ -1233,11 +1237,10 @@ h5str_sprintf break; } - case H5T_VLEN: - { - unsigned int i; - size_t baseSize; - hvl_t *vl_buf = (hvl_t *) in_buf; + case H5T_VLEN: { + unsigned int i; + size_t baseSize; + hvl_t * vl_buf = (hvl_t *)in_buf; if ((mtid = H5Tget_super(tid)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1248,11 +1251,12 @@ h5str_sprintf if (!h5str_append(out_str, H5_VLEN_BEGIN_INDICATOR)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - for (i = 0; i < (unsigned) vl_buf->len; i++) { - if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &(((char *) vl_buf->p)[i * baseSize]), vl_buf->len, expand_data)) + for (i = 0; i < (unsigned)vl_buf->len; i++) { + if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &(((char *)vl_buf->p)[i * baseSize]), + vl_buf->len, expand_data)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if ((i + 1) < (unsigned) vl_buf->len) + if ((i + 1) < (unsigned)vl_buf->len) if (!h5str_append(out_str, ", ")) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } @@ -1268,8 +1272,7 @@ h5str_sprintf } case H5T_NO_CLASS: - case H5T_NCLASSES: - { + case H5T_NCLASSES: { H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: invalid datatype class"); break; } @@ -1277,13 +1280,12 @@ h5str_sprintf case H5T_TIME: case H5T_BITFIELD: case H5T_OPAQUE: - default: - { + default: { size_t i; /* All other types get printed as hexadecimal */ - if (NULL == (this_str = (char *) HDmalloc(4 * (typeSize + 1)))) + if (NULL == (this_str = (char *)HDmalloc(4 * (typeSize + 1)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (1 == typeSize) { @@ -1328,23 +1330,23 @@ done: *------------------------------------------------------------------------- */ static int -h5str_print_region_data_blocks - (JNIEnv *env, hid_t region_id, h5str_t *str, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) +h5str_print_region_data_blocks(JNIEnv *env, hid_t region_id, h5str_t *str, int ndims, hid_t type_id, + hssize_t nblocks, hsize_t *ptdata) { - unsigned indx; - hsize_t *dims1 = NULL; - hsize_t *start = NULL; - hsize_t *count = NULL; - hsize_t blkndx; - hsize_t total_size[H5S_MAX_RANK]; - hsize_t numelem; - hsize_t numindex; - size_t jndx; - size_t type_size; - hid_t mem_space = H5I_INVALID_HID; - hid_t sid1 = H5I_INVALID_HID; - void *region_buf = NULL; - int ret_value = FAIL; + unsigned indx; + hsize_t *dims1 = NULL; + hsize_t *start = NULL; + hsize_t *count = NULL; + hsize_t blkndx; + hsize_t total_size[H5S_MAX_RANK]; + hsize_t numelem; + hsize_t numindex; + size_t jndx; + size_t type_size; + hid_t mem_space = H5I_INVALID_HID; + hid_t sid1 = H5I_INVALID_HID; + void * region_buf = NULL; + int ret_value = FAIL; if (ndims < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_print_region_data_blocks: ndims < 0"); @@ -1356,13 +1358,14 @@ h5str_print_region_data_blocks H5_LIBRARY_ERROR(ENVONLY); /* Allocate space for the dimension array */ - if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate dimension array buffer"); + if (NULL == (dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_print_region_data_blocks: failed to allocate dimension array buffer"); /* Find the dimensions of each data space from the block coordinates */ - for (jndx = 0, numelem = 1; jndx < (size_t) ndims; jndx++) { + for (jndx = 0, numelem = 1; jndx < (size_t)ndims; jndx++) { dims1[jndx] = ptdata[jndx + (size_t)ndims] - ptdata[jndx] + 1; - numelem = dims1[jndx] * numelem; + numelem = dims1[jndx] * numelem; } /* end for */ /* Create dataspace for reading buffer */ @@ -1377,14 +1380,16 @@ h5str_print_region_data_blocks /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ /* 1 2 n 1 2 n */ - if (NULL == (start = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab start buffer"); + if (NULL == (start = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_print_region_data_blocks: failed to allocate hyperslab start buffer"); - if (NULL == (count = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab count buffer"); + if (NULL == (count = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_print_region_data_blocks: failed to allocate hyperslab count buffer"); - for (blkndx = 0; blkndx < (hsize_t) nblocks; blkndx++) { - for (indx = 0; indx < (unsigned) ndims; indx++) { + for (blkndx = 0; blkndx < (hsize_t)nblocks; blkndx++) { + for (indx = 0; indx < (unsigned)ndims; indx++) { start[indx] = ptdata[indx + blkndx * (hsize_t)ndims * 2]; count[indx] = dims1[indx]; } /* end for */ @@ -1399,14 +1404,15 @@ h5str_print_region_data_blocks H5_LIBRARY_ERROR(ENVONLY); for (numindex = 0; numindex < numelem; numindex++) { - if (!h5str_sprintf(ENVONLY, str, region_id, type_id, ((char *)region_buf + numindex * type_size), 0, 1)) + if (!h5str_sprintf(ENVONLY, str, region_id, type_id, ((char *)region_buf + numindex * type_size), + 0, 1)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); if (numindex + 1 < numelem) if (!h5str_append(str, ", ")) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */ - } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ + } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ ret_value = SUCCEED; @@ -1428,23 +1434,24 @@ done: } /* end h5str_print_region_data_blocks */ int -h5str_dump_region_blocks_data - (JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) +h5str_dump_region_blocks_data(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) { - hssize_t nblocks; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - hid_t dtype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - int ndims = -1; - int ret_value = FAIL; + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + int ndims = -1; + int ret_value = FAIL; /* * This function fails if the region does not have blocks. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { nblocks = H5Sget_select_hyper_nblocks(region); - } H5E_END_TRY; + } + H5E_END_TRY; if (nblocks < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1454,11 +1461,12 @@ h5str_dump_region_blocks_data /* Print block information */ alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); - if (alloc_size == (hsize_t)((size_t) alloc_size)) { - if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_blocks_data: failed to allocate region block buffer"); + if (alloc_size == (hsize_t)((size_t)alloc_size)) { + if (NULL == (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_dump_region_blocks_data: failed to allocate region block buffer"); - if (H5Sget_select_hyper_blocklist(region, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) + if (H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); if ((dtype = H5Dget_type(region_id)) < 0) @@ -1486,24 +1494,25 @@ done: #ifndef SKIP_UNUSED_DUMP_ROUTINES static int -h5str_dump_region_blocks - (JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) +h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) { - hssize_t nblocks; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - char tmp_str[256]; - int ndims = -1; - int ret_value = FAIL; + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + char tmp_str[256]; + int ndims = -1; + int ret_value = FAIL; UNUSED(region_id); /* * This function fails if the region does not have blocks. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { nblocks = H5Sget_select_hyper_nblocks(region); - } H5E_END_TRY; + } + H5E_END_TRY; if (nblocks < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1513,13 +1522,14 @@ h5str_dump_region_blocks /* Print block information */ alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); - if (alloc_size == (hsize_t)((size_t) alloc_size)) { + if (alloc_size == (hsize_t)((size_t)alloc_size)) { int i; - if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_blocks: failed to allocate region block buffer"); + if (NULL == (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_dump_region_blocks: failed to allocate region block buffer"); - if (H5Sget_select_hyper_blocklist(region, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) + if (H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); if (!h5str_append(str, " {")) @@ -1535,8 +1545,7 @@ h5str_dump_region_blocks for (j = 0; j < ndims; j++) { tmp_str[0] = '\0'; - if (HDsprintf(tmp_str, "%s%lu", j ? "," : "(", - (unsigned long) ptdata[i * 2 * ndims + j]) < 0) + if (HDsprintf(tmp_str, "%s%lu", j ? "," : "(", (unsigned long)ptdata[i * 2 * ndims + j]) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsprintf failure"); if (!h5str_append(str, tmp_str)) @@ -1547,7 +1556,7 @@ h5str_dump_region_blocks tmp_str[0] = '\0'; if (HDsprintf(tmp_str, "%s%lu", j ? "," : ")-(", - (unsigned long) ptdata[i * 2 * ndims + j + ndims]) < 0) + (unsigned long)ptdata[i * 2 * ndims + j + ndims]) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsprintf failure"); if (!h5str_append(str, tmp_str)) @@ -1585,16 +1594,16 @@ done: *------------------------------------------------------------------------- */ static int -h5str_print_region_data_points - (JNIEnv *env, hid_t region_space, hid_t region_id, h5str_t *str, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) +h5str_print_region_data_points(JNIEnv *env, hid_t region_space, hid_t region_id, h5str_t *str, int ndims, + hid_t type_id, hssize_t npoints, hsize_t *ptdata) { hsize_t *dims1 = NULL; hsize_t total_size[H5S_MAX_RANK]; size_t jndx; size_t type_size; - hid_t mem_space = H5I_INVALID_HID; - void *region_buf = NULL; - int ret_value = FAIL; + hid_t mem_space = H5I_INVALID_HID; + void * region_buf = NULL; + int ret_value = FAIL; UNUSED(ptdata); @@ -1602,8 +1611,9 @@ h5str_print_region_data_points H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_print_region_data_points: npoints < 0"); /* Allocate space for the dimension array */ - if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate dimension array buffer"); + if (NULL == (dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_print_region_data_points: failed to allocate dimension array buffer"); dims1[0] = (hsize_t)npoints; @@ -1620,14 +1630,14 @@ h5str_print_region_data_points if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) H5_LIBRARY_ERROR(ENVONLY); - for (jndx = 0; jndx < (size_t) npoints; jndx++) { + for (jndx = 0; jndx < (size_t)npoints; jndx++) { if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) H5_LIBRARY_ERROR(ENVONLY); if (!h5str_sprintf(ENVONLY, str, region_id, type_id, ((char *)region_buf + jndx * type_size), 0, 1)) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if (jndx + 1 < (size_t) npoints) + if (jndx + 1 < (size_t)npoints) if (!h5str_append(str, ", ")) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */ @@ -1646,23 +1656,24 @@ done: } /* end h5str_print_region_data_points */ int -h5str_dump_region_points_data - (JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) +h5str_dump_region_points_data(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) { - hssize_t npoints; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - hid_t dtype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - int ndims = -1; - int ret_value = FAIL; + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + int ndims = -1; + int ret_value = FAIL; /* * This function fails if the region does not have points. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { npoints = H5Sget_select_elem_npoints(region); - } H5E_END_TRY; + } + H5E_END_TRY; if (npoints < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1673,11 +1684,12 @@ h5str_dump_region_points_data /* Print point information */ if (npoints > 0) { alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); - if (alloc_size == (hsize_t)((size_t) alloc_size)) { - if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_points_data: failed to allocate region point data buffer"); + if (alloc_size == (hsize_t)((size_t)alloc_size)) { + if (NULL == (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) + H5_OUT_OF_MEMORY_ERROR( + ENVONLY, "h5str_dump_region_points_data: failed to allocate region point data buffer"); - if (H5Sget_select_elem_pointlist(region, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) + if (H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); if ((dtype = H5Dget_type(region_id)) < 0) @@ -1686,8 +1698,8 @@ h5str_dump_region_points_data if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); - if (h5str_print_region_data_points(ENVONLY, region, region_id, - str, ndims, type_id, npoints, ptdata) < 0) + if (h5str_print_region_data_points(ENVONLY, region, region_id, str, ndims, type_id, npoints, + ptdata) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } } @@ -1707,24 +1719,25 @@ done: #ifndef SKIP_UNUSED_DUMP_ROUTINES static int -h5str_dump_region_points - (JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) +h5str_dump_region_points(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) { - hssize_t npoints; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - char tmp_str[256]; - int ndims = -1; - int ret_value = FAIL; + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + char tmp_str[256]; + int ndims = -1; + int ret_value = FAIL; UNUSED(region_id); /* * This function fails if the region does not have points. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { npoints = H5Sget_select_elem_npoints(region); - } H5E_END_TRY; + } + H5E_END_TRY; if (npoints < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1737,11 +1750,12 @@ h5str_dump_region_points int i; alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); - if (alloc_size == (hsize_t)((size_t) alloc_size)) { - if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_region_points: failed to allocate region point buffer"); + if (alloc_size == (hsize_t)((size_t)alloc_size)) { + if (NULL == (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "h5str_dump_region_points: failed to allocate region point buffer"); - if (H5Sget_select_elem_pointlist(region, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) + if (H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata) < 0) H5_LIBRARY_ERROR(ENVONLY); if (!h5str_append(str, " {")) @@ -1756,8 +1770,8 @@ h5str_dump_region_points for (j = 0; j < ndims; j++) { tmp_str[0] = '\0'; - if (HDsprintf(tmp_str, "%s%lu", j ? "," : "(", - (unsigned long) (ptdata[i * ndims + j])) < 0) + if (HDsprintf(tmp_str, "%s%lu", j ? "," : "(", (unsigned long)(ptdata[i * ndims + j])) < + 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points: HDsprintf failure"); if (!h5str_append(str, tmp_str)) @@ -1771,7 +1785,7 @@ h5str_dump_region_points if (!h5str_append(str, " }")) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } /* end if (alloc_size == (hsize_t)((size_t) alloc_size)) */ - } /* end if (npoints > 0) */ + } /* end if (npoints > 0) */ ret_value = SUCCEED; @@ -1784,10 +1798,9 @@ done: #endif static int -h5str_is_zero - (const void *_mem, size_t size) +h5str_is_zero(const void *_mem, size_t size) { - const unsigned char *mem = (const unsigned char *) _mem; + const unsigned char *mem = (const unsigned char *)_mem; while (size-- > 0) if (mem[size]) @@ -1808,8 +1821,7 @@ h5str_is_zero *------------------------------------------------------------------------- */ static htri_t -h5str_detect_vlen - (hid_t tid) +h5str_detect_vlen(hid_t tid) { htri_t ret = FAIL; @@ -1840,48 +1852,47 @@ done: *------------------------------------------------------------------------- */ static htri_t -h5str_detect_vlen_str - (hid_t tid) +h5str_detect_vlen_str(hid_t tid) { H5T_class_t tclass = H5T_NO_CLASS; - htri_t ret = 0; + htri_t ret = 0; ret = H5Tis_variable_str(tid); - if((ret == 1) || (ret < 0)) + if ((ret == 1) || (ret < 0)) goto done; tclass = H5Tget_class(tid); - if(tclass == H5T_ARRAY || tclass == H5T_VLEN) { + if (tclass == H5T_ARRAY || tclass == H5T_VLEN) { hid_t btid = H5Tget_super(tid); - if(btid < 0) { + if (btid < 0) { ret = (htri_t)btid; goto done; } /* end if */ ret = h5str_detect_vlen_str(btid); - if((ret == 1) || (ret < 0)) { + if ((ret == 1) || (ret < 0)) { H5Tclose(btid); goto done; } /* end if */ - } /* end if */ - else if(tclass == H5T_COMPOUND) { + } /* end if */ + else if (tclass == H5T_COMPOUND) { unsigned i = 0; - int n = H5Tget_nmembers(tid); + int n = H5Tget_nmembers(tid); if (n < 0) goto done; - for(i = 0; i < (unsigned) n; i++) { + for (i = 0; i < (unsigned)n; i++) { hid_t mtid = H5Tget_member_type(tid, i); ret = h5str_detect_vlen_str(mtid); - if((ret == 1) || (ret < 0)) { + if ((ret == 1) || (ret < 0)) { H5Tclose(mtid); goto done; } H5Tclose(mtid); } /* end for */ - } /* end else */ + } /* end else */ done: return ret; @@ -1898,8 +1909,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -h5str_get_native_type - (hid_t type) +h5str_get_native_type(hid_t type) { H5T_class_t type_class; hid_t p_type = H5I_INVALID_HID; @@ -1913,10 +1923,9 @@ h5str_get_native_type p_type = H5Tget_native_type(type, H5T_DIR_DEFAULT); done: - return(p_type); + return (p_type); } /* end h5str_get_native_type */ - /*------------------------------------------------------------------------- * Function: h5str_get_little_endian_type * @@ -1927,8 +1936,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -h5str_get_little_endian_type - (hid_t tid) +h5str_get_little_endian_type(hid_t tid) { H5T_class_t type_class; H5T_sign_t sign; @@ -1944,56 +1952,52 @@ h5str_get_little_endian_type if ((sign = H5Tget_sign(tid)) < 0) goto done; - switch ( type_class ) { - case H5T_INTEGER: - { - if ( size == 1 && sign == H5T_SGN_2 ) + switch (type_class) { + case H5T_INTEGER: { + if (size == 1 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I8LE); - else if ( size == 2 && sign == H5T_SGN_2 ) + else if (size == 2 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I16LE); - else if ( size == 4 && sign == H5T_SGN_2 ) + else if (size == 4 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I32LE); - else if ( size == 8 && sign == H5T_SGN_2 ) + else if (size == 8 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I64LE); - else if ( size == 1 && sign == H5T_SGN_NONE ) + else if (size == 1 && sign == H5T_SGN_NONE) p_type = H5Tcopy(H5T_STD_U8LE); - else if ( size == 2 && sign == H5T_SGN_NONE ) + else if (size == 2 && sign == H5T_SGN_NONE) p_type = H5Tcopy(H5T_STD_U16LE); - else if ( size == 4 && sign == H5T_SGN_NONE ) + else if (size == 4 && sign == H5T_SGN_NONE) p_type = H5Tcopy(H5T_STD_U32LE); - else if ( size == 8 && sign == H5T_SGN_NONE ) + else if (size == 8 && sign == H5T_SGN_NONE) p_type = H5Tcopy(H5T_STD_U64LE); break; } - case H5T_FLOAT: - { - if ( size == 4 ) + case H5T_FLOAT: { + if (size == 4) p_type = H5Tcopy(H5T_IEEE_F32LE); - else if ( size == 8 ) + else if (size == 8) p_type = H5Tcopy(H5T_IEEE_F64LE); break; } - case H5T_BITFIELD: - { - if ( size == 1 ) + case H5T_BITFIELD: { + if (size == 1) p_type = H5Tcopy(H5T_STD_B8LE); - else if ( size == 2 ) + else if (size == 2) p_type = H5Tcopy(H5T_STD_B16LE); - else if ( size == 4 ) + else if (size == 4) p_type = H5Tcopy(H5T_STD_B32LE); - else if ( size == 8 ) + else if (size == 8) p_type = H5Tcopy(H5T_STD_B64LE); break; } case H5T_NO_CLASS: - case H5T_NCLASSES: - { + case H5T_NCLASSES: { goto done; break; } @@ -2013,7 +2017,7 @@ h5str_get_little_endian_type } done: - return(p_type); + return (p_type); } /* end h5str_get_little_endian_type */ /*------------------------------------------------------------------------- @@ -2026,8 +2030,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -h5str_get_big_endian_type - (hid_t tid) +h5str_get_big_endian_type(hid_t tid) { H5T_class_t type_class; H5T_sign_t sign; @@ -2043,56 +2046,52 @@ h5str_get_big_endian_type if ((sign = H5Tget_sign(tid)) < 0) goto done; - switch ( type_class ) { - case H5T_INTEGER: - { - if ( size == 1 && sign == H5T_SGN_2 ) + switch (type_class) { + case H5T_INTEGER: { + if (size == 1 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I8BE); - else if ( size == 2 && sign == H5T_SGN_2 ) + else if (size == 2 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I16BE); - else if ( size == 4 && sign == H5T_SGN_2 ) + else if (size == 4 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I32BE); - else if ( size == 8 && sign == H5T_SGN_2 ) + else if (size == 8 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I64BE); - else if ( size == 1 && sign == H5T_SGN_NONE ) + else if (size == 1 && sign == H5T_SGN_NONE) p_type = H5Tcopy(H5T_STD_U8BE); - else if ( size == 2 && sign == H5T_SGN_NONE ) + else if (size == 2 && sign == H5T_SGN_NONE) p_type = H5Tcopy(H5T_STD_U16BE); - else if ( size == 4 && sign == H5T_SGN_NONE ) + else if (size == 4 && sign == H5T_SGN_NONE) p_type = H5Tcopy(H5T_STD_U32BE); - else if ( size == 8 && sign == H5T_SGN_NONE ) + else if (size == 8 && sign == H5T_SGN_NONE) p_type = H5Tcopy(H5T_STD_U64BE); break; } - case H5T_FLOAT: - { - if ( size == 4 ) + case H5T_FLOAT: { + if (size == 4) p_type = H5Tcopy(H5T_IEEE_F32BE); - else if ( size == 8 ) + else if (size == 8) p_type = H5Tcopy(H5T_IEEE_F64BE); break; } - case H5T_BITFIELD: - { - if ( size == 1 ) + case H5T_BITFIELD: { + if (size == 1) p_type = H5Tcopy(H5T_STD_B8BE); - else if ( size == 2 ) + else if (size == 2) p_type = H5Tcopy(H5T_STD_B16BE); - else if ( size == 4 ) + else if (size == 4) p_type = H5Tcopy(H5T_STD_B32BE); - else if ( size == 8 ) + else if (size == 8) p_type = H5Tcopy(H5T_STD_B64BE); break; } case H5T_NO_CLASS: - case H5T_NCLASSES: - { + case H5T_NCLASSES: { goto done; break; } @@ -2112,7 +2111,7 @@ h5str_get_big_endian_type } done: - return(p_type); + return (p_type); } /* end h5str_get_big_endian_type */ /*------------------------------------------------------------------------- @@ -2125,13 +2124,12 @@ done: *------------------------------------------------------------------------- */ static int -h5str_render_bin_output - (FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) +h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) { - unsigned char *mem = (unsigned char*)_mem; + unsigned char *mem = (unsigned char *)_mem; H5T_class_t type_class; hsize_t block_index; - size_t size; /* datum size */ + size_t size; /* datum size */ int ret_value = 0; if (!(size = H5Tget_size(tid))) { @@ -2147,12 +2145,11 @@ h5str_render_bin_output switch (type_class) { case H5T_INTEGER: case H5T_FLOAT: - case H5T_ENUM: - { + case H5T_ENUM: { block_index = block_nelmts * size; while (block_index > 0) { - size_t bytes_in = 0; /* # of bytes to write */ - size_t bytes_wrote = 0; /* # of bytes written */ + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ if (block_index > sizeof(size_t)) bytes_in = sizeof(size_t); @@ -2173,12 +2170,11 @@ h5str_render_bin_output break; } - case H5T_STRING: - { - unsigned char tempuchar; - unsigned int i; - H5T_str_t pad; - char *s; + case H5T_STRING: { + unsigned char tempuchar; + unsigned int i; + H5T_str_t pad; + char * s; if ((pad = H5Tget_strpad(tid)) < 0) { ret_value = FAIL; @@ -2189,12 +2185,12 @@ h5str_render_bin_output mem = ((unsigned char *)_mem) + block_index * size; if (H5Tis_variable_str(tid)) { - s = *(char**) mem; + s = *(char **)mem; if (s != NULL) size = HDstrlen(s); } else { - s = (char *) mem; + s = (char *)mem; } for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); @@ -2210,8 +2206,7 @@ h5str_render_bin_output break; } - case H5T_COMPOUND: - { + case H5T_COMPOUND: { unsigned j; size_t offset; hid_t memb = H5I_INVALID_HID; @@ -2223,8 +2218,8 @@ h5str_render_bin_output } for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - for (j = 0; j < (unsigned) nmembs; j++) { + mem = ((unsigned char *)_mem) + block_index * size; + for (j = 0; j < (unsigned)nmembs; j++) { offset = H5Tget_member_offset(tid, j); memb = H5Tget_member_type(tid, j); @@ -2244,8 +2239,7 @@ h5str_render_bin_output break; } - case H5T_ARRAY: - { + case H5T_ARRAY: { hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; hid_t memb; int k, ndims; @@ -2270,11 +2264,11 @@ h5str_render_bin_output for (k = 0, nelmts = 1; k < ndims; k++) { temp_nelmts = nelmts; temp_nelmts *= dims[k]; - nelmts = (size_t) temp_nelmts; + nelmts = (size_t)temp_nelmts; } for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; + mem = ((unsigned char *)_mem) + block_index * size; /* dump the array element */ if (h5str_render_bin_output(stream, container, memb, mem, nelmts) < 0) { @@ -2288,8 +2282,7 @@ h5str_render_bin_output break; } - case H5T_VLEN: - { + case H5T_VLEN: { hsize_t nelmts; hid_t memb; @@ -2300,13 +2293,14 @@ h5str_render_bin_output } for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; + mem = ((unsigned char *)_mem) + block_index * size; /* Get the number of sequence elements */ - nelmts = ((hvl_t *) mem)->len; + nelmts = ((hvl_t *)mem)->len; /* dump the array element */ - if (h5str_render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) { + if (h5str_render_bin_output(stream, container, memb, ((char *)(((hvl_t *)mem)->p)), nelmts) < + 0) { ret_value = FAIL; break; } @@ -2317,26 +2311,28 @@ h5str_render_bin_output break; } - case H5T_REFERENCE: - { + case H5T_REFERENCE: { if (H5Tequal(tid, H5T_STD_REF)) { - hid_t region_id = H5I_INVALID_HID; - hid_t region_space = H5I_INVALID_HID; + hid_t region_id = H5I_INVALID_HID; + hid_t region_space = H5I_INVALID_HID; H5S_sel_type region_type; /* Region data */ for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - if((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) + mem = ((unsigned char *)_mem) + block_index * size; + if ((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) continue; else { - if((region_space = H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((region_space = + H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (!h5str_is_zero(mem, H5Tget_size(H5T_STD_REF))) { region_type = H5Sget_select_type(region_space); if (region_type == H5S_SEL_POINTS) - ret_value = render_bin_output_region_points(stream, region_space, region_id, container); + ret_value = render_bin_output_region_points(stream, region_space, + region_id, container); else - ret_value = render_bin_output_region_blocks(stream, region_space, region_id, container); + ret_value = render_bin_output_region_blocks(stream, region_space, + region_id, container); } H5Sclose(region_space); } /* end if (region_space >= 0) */ @@ -2363,8 +2359,7 @@ h5str_render_bin_output } case H5T_NO_CLASS: - case H5T_NCLASSES: - { + case H5T_NCLASSES: { ret_value = FAIL; goto done; break; @@ -2375,7 +2370,7 @@ h5str_render_bin_output case H5T_OPAQUE: default: for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; + mem = ((unsigned char *)_mem) + block_index * size; if (size != fwrite(mem, sizeof(char), size, stream)) { ret_value = FAIL; break; @@ -2400,8 +2395,8 @@ done: *------------------------------------------------------------------------- */ static int -render_bin_output_region_data_blocks - (FILE *stream, hid_t region_id, hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) +render_bin_output_region_data_blocks(FILE *stream, hid_t region_id, hid_t container, int ndims, hid_t type_id, + hssize_t nblocks, hsize_t *ptdata) { hsize_t *dims1 = NULL; hsize_t *start = NULL; @@ -2409,9 +2404,9 @@ render_bin_output_region_data_blocks hsize_t numelem; hsize_t total_size[H5S_MAX_RANK]; size_t type_size; - hid_t sid1 = H5I_INVALID_HID; - hid_t mem_space = H5I_INVALID_HID; - void *region_buf = NULL; + hid_t sid1 = H5I_INVALID_HID; + hid_t mem_space = H5I_INVALID_HID; + void * region_buf = NULL; int blkndx; int jndx; int ret_value = SUCCEED; @@ -2423,7 +2418,7 @@ render_bin_output_region_data_blocks } /* Allocate space for the dimension array */ - if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { + if (NULL == (dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { ret_value = FAIL; goto done; } @@ -2431,7 +2426,7 @@ render_bin_output_region_data_blocks /* Find the dimensions of each data space from the block coordinates */ for (jndx = 0, numelem = 1; jndx < ndims; jndx++) { dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1; - numelem = dims1[jndx] * numelem; + numelem = dims1[jndx] * numelem; } /* Create dataspace for reading buffer */ @@ -2452,12 +2447,12 @@ render_bin_output_region_data_blocks /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ /* 1 2 n 1 2 n */ - if (NULL == (start = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { + if (NULL == (start = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { ret_value = FAIL; goto done; } - if (NULL == (count = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { + if (NULL == (count = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { ret_value = FAIL; goto done; } @@ -2520,16 +2515,15 @@ done: *------------------------------------------------------------------------- */ static int -render_bin_output_region_blocks - (FILE *stream, hid_t region_space, hid_t region_id, hid_t container) +render_bin_output_region_blocks(FILE *stream, hid_t region_space, hid_t region_id, hid_t container) { - hssize_t nblocks; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - hid_t dtype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - int ndims; - int ret_value = SUCCEED; + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + int ndims; + int ret_value = SUCCEED; if ((nblocks = H5Sget_select_hyper_nblocks(region_space)) < 0) { ret_value = FAIL; @@ -2545,7 +2539,7 @@ render_bin_output_region_blocks alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); - if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t)alloc_size))) { + if (NULL == (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) { ret_value = FAIL; goto done; } @@ -2565,8 +2559,8 @@ render_bin_output_region_blocks goto done; } - if (render_bin_output_region_data_blocks(stream, region_id, container, - ndims, type_id, nblocks, ptdata) < 0) { + if (render_bin_output_region_data_blocks(stream, region_id, container, ndims, type_id, nblocks, + ptdata) < 0) { ret_value = FAIL; goto done; } @@ -2595,15 +2589,14 @@ done: *------------------------------------------------------------------------- */ static int -render_bin_output_region_data_points - (FILE *stream, hid_t region_space, hid_t region_id, - hid_t container, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) +render_bin_output_region_data_points(FILE *stream, hid_t region_space, hid_t region_id, hid_t container, + int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) { hsize_t *dims1 = NULL; size_t type_size; - hid_t mem_space = H5I_INVALID_HID; - void *region_buf = NULL; - int ret_value = SUCCEED; + hid_t mem_space = H5I_INVALID_HID; + void * region_buf = NULL; + int ret_value = SUCCEED; UNUSED(ptdata); @@ -2618,7 +2611,7 @@ render_bin_output_region_data_points } /* Allocate space for the dimension array */ - if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { + if (NULL == (dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { ret_value = FAIL; goto done; } @@ -2668,16 +2661,15 @@ done: *------------------------------------------------------------------------- */ static int -render_bin_output_region_points - (FILE *stream, hid_t region_space, hid_t region_id, hid_t container) +render_bin_output_region_points(FILE *stream, hid_t region_space, hid_t region_id, hid_t container) { - hssize_t npoints; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - hid_t dtype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - int ndims; - int ret_value = SUCCEED; + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + int ndims; + int ret_value = SUCCEED; if ((npoints = H5Sget_select_elem_npoints(region_space)) < 0) { ret_value = FAIL; @@ -2693,7 +2685,7 @@ render_bin_output_region_points alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); - if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t)alloc_size))) { + if (NULL == (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) { ret_value = FAIL; goto done; } @@ -2713,8 +2705,8 @@ render_bin_output_region_points goto done; } - if (render_bin_output_region_data_points(stream, region_space, region_id, - container, ndims, type_id, npoints, ptdata) < 0) { + if (render_bin_output_region_data_points(stream, region_space, region_id, container, ndims, type_id, + npoints, ptdata) < 0) { ret_value = FAIL; goto done; } @@ -2732,8 +2724,7 @@ done: } /* end render_bin_output_region_points */ int -h5str_dump_simple_dset - (JNIEnv *env, FILE *stream, hid_t dset, int binary_order) +h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order) { hsize_t elmtno; /* counter */ hsize_t zero[8]; /* vector of zeros */ @@ -2741,7 +2732,7 @@ h5str_dump_simple_dset size_t i; /* counter */ hid_t f_space = H5I_INVALID_HID; /* file data space */ int ndims; - int carry; /* counter carry value */ + int carry; /* counter carry value */ /* Print info */ hsize_t p_nelmts; /* total selected elmts */ @@ -2761,8 +2752,8 @@ h5str_dump_simple_dset /* VL data special information */ unsigned int vl_data = 0; /* contains VL datatypes */ - hid_t p_type = H5I_INVALID_HID; - hid_t f_type = H5I_INVALID_HID; + hid_t p_type = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; int ret_value = FAIL; @@ -2773,32 +2764,28 @@ h5str_dump_simple_dset H5_LIBRARY_ERROR(ENVONLY); switch (binary_order) { - case 1: - { + case 1: { if ((p_type = h5str_get_native_type(f_type)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); break; } - case 2: - { + case 2: { if ((p_type = h5str_get_little_endian_type(f_type)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); break; } - case 3: - { + case 3: { if ((p_type = h5str_get_big_endian_type(f_type)) < 0) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); break; } - default: - { + default: { if ((p_type = H5Tcopy(f_type)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -2820,7 +2807,7 @@ h5str_dump_simple_dset p_nelmts = 1; if (ndims > 0) { - for (i = 0; i < (size_t) ndims; i++) + for (i = 0; i < (size_t)ndims; i++) p_nelmts *= total_size[i]; } /* end if */ @@ -2839,7 +2826,7 @@ h5str_dump_simple_dset if (ndims > 0) { for (i = (size_t)ndims; i > 0; --i) { hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; - if ( size == 0 ) /* datum size > H5TOOLS_BUFSIZE */ + if (size == 0) /* datum size > H5TOOLS_BUFSIZE */ size = 1; sm_size[i - 1] = (((total_size[i - 1]) < (size)) ? (total_size[i - 1]) : (size)); sm_nbytes *= sm_size[i - 1]; @@ -2847,7 +2834,7 @@ h5str_dump_simple_dset } if (sm_nbytes > 0) { - if (NULL == (sm_buf = (unsigned char *) HDmalloc((size_t)sm_nbytes))) + if (NULL == (sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_dset: failed to allocate sm_buf"); sm_nelmts = sm_nbytes / p_type_nbytes; @@ -2862,8 +2849,10 @@ h5str_dump_simple_dset for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { /* Calculate the hyperslab size */ if (ndims > 0) { - for (i = 0, hs_nelmts = 1; i < (size_t) ndims; i++) { - hs_size[i] = (((total_size[i] - hs_offset[i]) < (sm_size[i])) ? (total_size[i] - hs_offset[i]) : (sm_size[i])); + for (i = 0, hs_nelmts = 1; i < (size_t)ndims; i++) { + hs_size[i] = (((total_size[i] - hs_offset[i]) < (sm_size[i])) + ? (total_size[i] - hs_offset[i]) + : (sm_size[i])); hs_nelmts *= hs_size[i]; } @@ -2934,23 +2923,24 @@ done: } /* end h5str_dump_simple_dset */ htri_t -H5Tdetect_variable_str(hid_t tid) { +H5Tdetect_variable_str(hid_t tid) +{ htri_t ret_val = 0; if (H5Tget_class(tid) == H5T_COMPOUND) { unsigned i; unsigned nm = (unsigned)H5Tget_nmembers(tid); - for(i = 0; i < nm; i++) { + for (i = 0; i < nm; i++) { htri_t status = 0; - hid_t mtid = 0; - if((mtid = H5Tget_member_type(tid, i)) < 0) + hid_t mtid = 0; + if ((mtid = H5Tget_member_type(tid, i)) < 0) return FAIL; /* exit immediately on error */ - if((status = H5Tdetect_variable_str(mtid)) < 0) + if ((status = H5Tdetect_variable_str(mtid)) < 0) return status; /* exit immediately on error */ ret_val |= status; - H5Tclose (mtid); + H5Tclose(mtid); } /* end for */ - } /* end if */ + } /* end if */ else ret_val = H5Tis_variable_str(tid); @@ -2958,8 +2948,7 @@ H5Tdetect_variable_str(hid_t tid) { } /* end H5Tdetect_variable_str */ static int -h5tools_dump_simple_data - (JNIEnv *env, FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts) +h5tools_dump_simple_data(JNIEnv *env, FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts) { unsigned char *mem = (unsigned char *)_mem; h5str_t buffer; /* string into which to render */ @@ -2972,8 +2961,8 @@ h5tools_dump_simple_data H5_LIBRARY_ERROR(ENVONLY); for (i = 0, line_count = 0; i < nelmts; i++, line_count++) { - size_t bytes_in = 0; /* # of bytes to write */ - void *memref = mem + i * size; + size_t bytes_in = 0; /* # of bytes to write */ + void * memref = mem + i * size; /* Render the data element*/ h5str_new(&buffer, 32 * size); @@ -3023,17 +3012,17 @@ done: * Signature: (JJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AreadComplex -(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5AreadComplex(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, + jobjectArray buf) { - h5str_t h5str; - jstring jstr; - size_t size; - size_t i; - hid_t p_type = H5I_INVALID_HID; - jsize n; - char *readBuf = NULL; - herr_t status = FAIL; + h5str_t h5str; + jstring jstr; + size_t size; + size_t i; + hid_t p_type = H5I_INVALID_HID; + jsize n; + char * readBuf = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -3042,14 +3031,15 @@ Java_hdf_hdf5lib_H5_H5AreadComplex if ((p_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); - size = (((H5Tget_size(mem_type_id))>(H5Tget_size(p_type))) ? (H5Tget_size(mem_type_id)) : (H5Tget_size(p_type))); + size = (((H5Tget_size(mem_type_id)) > (H5Tget_size(p_type))) ? (H5Tget_size(mem_type_id)) + : (H5Tget_size(p_type))); if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) <= 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AreadComplex: read buffer length <= 0"); } - if (NULL == (readBuf = (char *) HDmalloc((size_t)n * size))) + if (NULL == (readBuf = (char *)HDmalloc((size_t)n * size))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadComplex: failed to allocate read buffer"); if ((status = H5Aread(attr_id, mem_type_id, readBuf)) < 0) @@ -3060,7 +3050,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex if (!h5str.s) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5AreadComplex: failed to allocate string buffer"); - for (i = 0; i < (size_t) n; i++) { + for (i = 0; i < (size_t)n; i++) { h5str.s[0] = '\0'; if (!h5str_sprintf(ENVONLY, &h5str, attr_id, mem_type_id, readBuf + (i * size), 0, 0)) @@ -3069,7 +3059,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize) i, jstr); + ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize)i, jstr); CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); ENVPTR->DeleteLocalRef(ENVONLY, jstr); @@ -3093,16 +3083,15 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Acopy - (JNIEnv *env, jclass clss, jlong src_id, jlong dst_id) +Java_hdf_hdf5lib_H5_H5Acopy(JNIEnv *env, jclass clss, jlong src_id, jlong dst_id) { - hssize_t npoints; - hsize_t total_size = 0; - size_t type_size; - jbyte *buf = NULL; - hid_t tid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - herr_t retVal = FAIL; + hssize_t npoints; + hsize_t total_size = 0; + size_t type_size; + jbyte * buf = NULL; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + herr_t retVal = FAIL; UNUSED(clss); @@ -3118,7 +3107,7 @@ Java_hdf_hdf5lib_H5_H5Acopy H5_LIBRARY_ERROR(ENVONLY); total_size = (hsize_t)npoints * (hsize_t)type_size; - if (NULL == (buf = (jbyte *) HDmalloc((size_t)total_size * sizeof(jbyte)))) + if (NULL == (buf = (jbyte *)HDmalloc((size_t)total_size * sizeof(jbyte)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Acopy: failed to allocate buffer"); if ((retVal = H5Aread((hid_t)src_id, tid, buf)) < 0) @@ -3152,16 +3141,15 @@ done: * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dcopy - (JNIEnv *env, jclass clss, jlong src_id, jlong dst_id) +Java_hdf_hdf5lib_H5_H5Dcopy(JNIEnv *env, jclass clss, jlong src_id, jlong dst_id) { - hssize_t npoints; - hsize_t total_size = 0, total_allocated_size; - size_t type_size; - jbyte *buf = NULL; - hid_t tid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - herr_t retVal = FAIL; + hssize_t npoints; + hsize_t total_size = 0, total_allocated_size; + size_t type_size; + jbyte * buf = NULL; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + herr_t retVal = FAIL; UNUSED(clss); @@ -3180,7 +3168,7 @@ Java_hdf_hdf5lib_H5_H5Dcopy H5_LIBRARY_ERROR(ENVONLY); total_size = (hsize_t)npoints * (hsize_t)type_size; - if (NULL == (buf = (jbyte *) HDmalloc((size_t)total_size * sizeof(jbyte)))) + if (NULL == (buf = (jbyte *)HDmalloc((size_t)total_size * sizeof(jbyte)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Dcopy: failed to allocate buffer"); if ((retVal = H5Dread((hid_t)src_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)) < 0) @@ -3219,29 +3207,29 @@ done: */ #ifdef __cplusplus - herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); - herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); - int H5Gget_obj_info_max(hid_t, char **, int *, int *, H5O_token_t *, long); - int H5Gget_obj_info_full( hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, H5O_token_t *obj_token, int indexType, int indexOrder); +herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); +herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); +int H5Gget_obj_info_max(hid_t, char **, int *, int *, H5O_token_t *, long); +int H5Gget_obj_info_full(hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, + H5O_token_t *obj_token, int indexType, int indexOrder); #else - static herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); - static herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); - static int H5Gget_obj_info_max(hid_t, char **, int *, int *, H5O_token_t *, long); - static int H5Gget_obj_info_full( hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, H5O_token_t *obj_token, int indexType, int indexOrder); +static herr_t obj_info_all(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); +static herr_t obj_info_max(hid_t g_id, const char *name, const H5L_info2_t *linfo, void *op_data); +static int H5Gget_obj_info_max(hid_t, char **, int *, int *, H5O_token_t *, long); +static int H5Gget_obj_info_full(hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, + H5O_token_t *obj_token, int indexType, int indexOrder); #endif -typedef struct info_all -{ - char **objname; - int *otype; - int *ltype; - H5O_token_t *obj_token; +typedef struct info_all { + char ** objname; + int * otype; + int * ltype; + H5O_token_t * obj_token; unsigned long *fno; - unsigned long idxnum; - int count; + unsigned long idxnum; + int count; } info_all_t; - /* * Class: hdf_hdf5lib_H5 * Method: H5Gget_obj_info_full @@ -3253,26 +3241,26 @@ typedef struct info_all * end up overwriting memory heap-tracking info. */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full - (JNIEnv *env, jclass clss, jlong loc_id, jstring group_name, - jobjectArray objName, jintArray oType, jintArray lType, jlongArray fNo, - jobjectArray oToken, jint n, jint indx_type, jint indx_order) +Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full(JNIEnv *env, jclass clss, jlong loc_id, jstring group_name, + jobjectArray objName, jintArray oType, jintArray lType, + jlongArray fNo, jobjectArray oToken, jint n, jint indx_type, + jint indx_order) { - unsigned long *fnos = NULL; - H5O_token_t *tokens = NULL; - const char *gName = NULL; - char **oName = NULL; - jboolean isCopy; - jstring str; - jobject token; - jint *otarr = NULL; - jint *ltarr = NULL; - jlong *fnoP = NULL; - hid_t gid = (hid_t)loc_id; - int i; - int indexType = indx_type; - int indexOrder = indx_order; - herr_t ret_val = FAIL; + unsigned long *fnos = NULL; + H5O_token_t * tokens = NULL; + const char * gName = NULL; + char ** oName = NULL; + jboolean isCopy; + jstring str; + jobject token; + jint * otarr = NULL; + jint * ltarr = NULL; + jlong * fnoP = NULL; + hid_t gid = (hid_t)loc_id; + int i; + int indexType = indx_type; + int indexOrder = indx_order; + herr_t ret_val = FAIL; UNUSED(clss); @@ -3289,14 +3277,15 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full PIN_INT_ARRAY(ENVONLY, lType, ltarr, &isCopy, "H5Gget_obj_info_full: lType not pinned"); PIN_LONG_ARRAY(ENVONLY, fNo, fnoP, &isCopy, "H5Gget_obj_info_full: fNo not pinned"); - if (NULL == (oName = (char **) HDcalloc((size_t)n, sizeof(*oName)))) + if (NULL == (oName = (char **)HDcalloc((size_t)n, sizeof(*oName)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for object name"); - if (NULL == (tokens = (H5O_token_t *) HDcalloc((size_t)n, sizeof(H5O_token_t)))) + if (NULL == (tokens = (H5O_token_t *)HDcalloc((size_t)n, sizeof(H5O_token_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for object tokens"); - if (NULL == (fnos = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for file number info"); + if (NULL == (fnos = (unsigned long *)HDcalloc((size_t)n, sizeof(unsigned long)))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5Gget_obj_info_full: failed to allocate buffer for file number info"); if (group_name) { PIN_JAVA_STRING(ENVONLY, group_name, gName, &isCopy, "H5Gget_obj_info_full: group_name not pinned"); @@ -3305,7 +3294,8 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full H5_LIBRARY_ERROR(ENVONLY); } - if ((ret_val = H5Gget_obj_info_full(gid, oName, (int *)otarr, (int *)ltarr, fnos, tokens, indexType, indexOrder)) < 0) + if ((ret_val = H5Gget_obj_info_full(gid, oName, (int *)otarr, (int *)ltarr, fnos, tokens, indexType, + indexOrder)) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: retrieval of object info failed"); for (i = 0; i < n; i++) { @@ -3363,19 +3353,19 @@ done: * will most likely end up overwriting memory heap-tracking info. */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max - (JNIEnv *env, jclass clss, jlong loc_id, jobjectArray objName, - jintArray oType, jintArray lType, jobjectArray oToken, jlong maxnum, jint n) +Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max(JNIEnv *env, jclass clss, jlong loc_id, jobjectArray objName, + jintArray oType, jintArray lType, jobjectArray oToken, + jlong maxnum, jint n) { - H5O_token_t *tokens = NULL; - jboolean isCopy; - jstring str; - jobject token; - char **oName = NULL; - jint *otarr = NULL; - jint *ltarr = NULL; - int i; - herr_t ret_val = FAIL; + H5O_token_t *tokens = NULL; + jboolean isCopy; + jstring str; + jobject token; + char ** oName = NULL; + jint * otarr = NULL; + jint * ltarr = NULL; + int i; + herr_t ret_val = FAIL; UNUSED(clss); @@ -3389,10 +3379,10 @@ Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max PIN_INT_ARRAY(ENVONLY, oType, otarr, &isCopy, "H5Gget_obj_info_max: oType not pinned"); PIN_INT_ARRAY(ENVONLY, lType, ltarr, &isCopy, "H5Gget_obj_info_max: lType not pinned"); - if (NULL == (oName = (char **) HDcalloc((size_t)n, sizeof(*oName)))) + if (NULL == (oName = (char **)HDcalloc((size_t)n, sizeof(*oName)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for object name"); - if (NULL == (tokens = (H5O_token_t *) HDcalloc((size_t)n, sizeof(H5O_token_t)))) + if (NULL == (tokens = (H5O_token_t *)HDcalloc((size_t)n, sizeof(H5O_token_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for object tokens"); if ((ret_val = H5Gget_obj_info_max((hid_t)loc_id, oName, (int *)otarr, (int *)ltarr, tokens, maxnum)) < 0) @@ -3433,30 +3423,31 @@ done: } /* end Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max */ int -H5Gget_obj_info_full - (hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, H5O_token_t *obj_token, int indexType, int indexOrder) +H5Gget_obj_info_full(hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, + H5O_token_t *obj_token, int indexType, int indexOrder) { info_all_t info; - info.objname = objname; - info.otype = otype; - info.ltype = ltype; - info.idxnum = 0; - info.fno = fno; + info.objname = objname; + info.otype = otype; + info.ltype = ltype; + info.idxnum = 0; + info.fno = fno; info.obj_token = obj_token; - info.count = 0; + info.count = 0; - if (H5Literate2(loc_id, (H5_index_t)indexType, (H5_iter_order_t)indexOrder, NULL, obj_info_all, (void *)&info) < 0) { + if (H5Literate2(loc_id, (H5_index_t)indexType, (H5_iter_order_t)indexOrder, NULL, obj_info_all, + (void *)&info) < 0) { /* * Reset info stats; most importantly, reset the count. */ - info.objname = objname; - info.otype = otype; - info.ltype = ltype; - info.idxnum = 0; - info.fno = fno; + info.objname = objname; + info.otype = otype; + info.ltype = ltype; + info.idxnum = 0; + info.fno = fno; info.obj_token = obj_token; - info.count = 0; + info.count = 0; /* Iteration failed, try normal alphabetical order */ if (H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, obj_info_all, (void *)&info) < 0) @@ -3467,17 +3458,16 @@ H5Gget_obj_info_full } /* end H5Gget_obj_info_full */ int -H5Gget_obj_info_max - (hid_t loc_id, char **objname, int *otype, int *ltype, H5O_token_t *obj_token, long maxnum) +H5Gget_obj_info_max(hid_t loc_id, char **objname, int *otype, int *ltype, H5O_token_t *obj_token, long maxnum) { info_all_t info; - info.objname = objname; - info.otype = otype; - info.ltype = ltype; - info.idxnum = (unsigned long)maxnum; + info.objname = objname; + info.otype = otype; + info.ltype = ltype; + info.idxnum = (unsigned long)maxnum; info.obj_token = obj_token; - info.count = 0; + info.count = 0; if (H5Lvisit2(loc_id, H5_INDEX_NAME, H5_ITER_NATIVE, obj_info_max, (void *)&info) < 0) return -1; @@ -3486,20 +3476,19 @@ H5Gget_obj_info_max } /* end H5Gget_obj_info_max */ herr_t -obj_info_all - (hid_t loc_id, const char *name, const H5L_info2_t *info, void *op_data) +obj_info_all(hid_t loc_id, const char *name, const H5L_info2_t *info, void *op_data) { - info_all_t *datainfo = (info_all_t *)op_data; - H5O_info2_t object_info; - htri_t object_exists; - size_t str_len; + info_all_t *datainfo = (info_all_t *)op_data; + H5O_info2_t object_info; + htri_t object_exists; + size_t str_len; - datainfo->otype[datainfo->count] = -1; - datainfo->ltype[datainfo->count] = -1; + datainfo->otype[datainfo->count] = -1; + datainfo->ltype[datainfo->count] = -1; datainfo->obj_token[datainfo->count] = H5O_TOKEN_UNDEF; str_len = HDstrlen(name); - if (NULL == (datainfo->objname[datainfo->count] = (char *) HDmalloc(str_len + 1))) + if (NULL == (datainfo->objname[datainfo->count] = (char *)HDmalloc(str_len + 1))) goto done; HDstrncpy(datainfo->objname[datainfo->count], name, str_len); @@ -3514,7 +3503,7 @@ obj_info_all datainfo->otype[datainfo->count] = object_info.type; datainfo->ltype[datainfo->count] = info->type; - datainfo->fno[datainfo->count] = object_info.fileno; + datainfo->fno[datainfo->count] = object_info.fileno; HDmemcpy(&datainfo->obj_token[datainfo->count], &object_info.token, sizeof(object_info.token)); } @@ -3526,21 +3515,20 @@ done: } /* end obj_info_all */ herr_t -obj_info_max - (hid_t loc_id, const char *name, const H5L_info2_t *info, void *op_data) +obj_info_max(hid_t loc_id, const char *name, const H5L_info2_t *info, void *op_data) { - info_all_t *datainfo = (info_all_t *)op_data; - H5O_info2_t object_info; - size_t str_len; + info_all_t *datainfo = (info_all_t *)op_data; + H5O_info2_t object_info; + size_t str_len; - datainfo->otype[datainfo->count] = -1; - datainfo->ltype[datainfo->count] = -1; - datainfo->objname[datainfo->count] = NULL; + datainfo->otype[datainfo->count] = -1; + datainfo->ltype[datainfo->count] = -1; + datainfo->objname[datainfo->count] = NULL; datainfo->obj_token[datainfo->count] = H5O_TOKEN_UNDEF; /* This will be freed by h5str_array_free(oName, n) */ str_len = HDstrlen(name); - if (NULL == (datainfo->objname[datainfo->count] = (char *) HDmalloc(str_len + 1))) + if (NULL == (datainfo->objname[datainfo->count] = (char *)HDmalloc(str_len + 1))) goto done; HDstrncpy(datainfo->objname[datainfo->count], name, str_len); @@ -3569,17 +3557,17 @@ done: * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5export_1dataset - (JNIEnv *env, jclass clss, jstring file_export_name, jstring file_name, jstring object_path, jint binary_order) +Java_hdf_hdf5lib_H5_H5export_1dataset(JNIEnv *env, jclass clss, jstring file_export_name, jstring file_name, + jstring object_path, jint binary_order) { const char *file_export = NULL; const char *object_name = NULL; - const char *fileName = NULL; + const char *fileName = NULL; jboolean isCopy; - herr_t ret_val = FAIL; - hid_t file_id = H5I_INVALID_HID; + herr_t ret_val = FAIL; + hid_t file_id = H5I_INVALID_HID; hid_t dataset_id = H5I_INVALID_HID; - FILE *stream = NULL; + FILE * stream = NULL; UNUSED(clss); @@ -3602,7 +3590,8 @@ Java_hdf_hdf5lib_H5_H5export_1dataset if ((dataset_id = H5Dopen2(file_id, object_name, H5P_DEFAULT)) < 0) H5_LIBRARY_ERROR(ENVONLY); - PIN_JAVA_STRING(ENVONLY, file_export_name, file_export, NULL, "H5export_dataset: file_export name not pinned"); + PIN_JAVA_STRING(ENVONLY, file_export_name, file_export, NULL, + "H5export_dataset: file_export name not pinned"); if (NULL == (stream = HDfopen(file_export, "w+"))) H5_JNI_FATAL_ERROR(ENVONLY, "HDfopen failed"); diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h index 51b6594..7c5fb90 100644 --- a/java/src/jni/h5util.h +++ b/java/src/jni/h5util.h @@ -23,51 +23,51 @@ #include "h5jni.h" #ifndef SUCCEED -#define SUCCEED 0 +#define SUCCEED 0 #endif #ifndef FAIL -#define FAIL (-1) +#define FAIL (-1) #endif typedef struct h5str_t { - char *s; - size_t max; /* the allocated size of the string */ + char * s; + size_t max; /* the allocated size of the string */ } h5str_t; -extern void h5str_new(h5str_t *str, size_t len); -extern void h5str_free(h5str_t *str); -extern void h5str_resize(h5str_t *str, size_t new_len); -extern char* h5str_append(h5str_t *str, const char* cstr); -extern size_t h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf, size_t out_buf_offset); -extern void h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, hid_t container, void *ref_p); -extern size_t h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf, size_t in_buf_len, int expand_data); -extern void h5str_array_free(char **strs, size_t len); -extern int h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order); -extern int h5str_dump_region_blocks_data(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); -extern int h5str_dump_region_points_data(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); - -extern htri_t H5Tdetect_variable_str(hid_t tid); +extern void h5str_new(h5str_t *str, size_t len); +extern void h5str_free(h5str_t *str); +extern void h5str_resize(h5str_t *str, size_t new_len); +extern char * h5str_append(h5str_t *str, const char *cstr); +extern size_t h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf, + size_t out_buf_offset); +extern void h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, hid_t container, void *ref_p); +extern size_t h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf, + size_t in_buf_len, int expand_data); +extern void h5str_array_free(char **strs, size_t len); +extern int h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order); +extern int h5str_dump_region_blocks_data(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); +extern int h5str_dump_region_points_data(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); + +extern htri_t H5Tdetect_variable_str(hid_t tid); /* * Symbols used to format the output of h5str_sprintf and * to interpret the input to h5str_convert. */ #define H5_COMPOUND_BEGIN_INDICATOR "{" -#define H5_COMPOUND_END_INDICATOR "}" -#define H5_ARRAY_BEGIN_INDICATOR "[" -#define H5_ARRAY_END_INDICATOR "]" -#define H5_VLEN_BEGIN_INDICATOR "(" -#define H5_VLEN_END_INDICATOR ")" +#define H5_COMPOUND_END_INDICATOR "}" +#define H5_ARRAY_BEGIN_INDICATOR "[" +#define H5_ARRAY_END_INDICATOR "]" +#define H5_VLEN_BEGIN_INDICATOR "(" +#define H5_VLEN_END_INDICATOR ")" /* * Class: hdf_hdf5lib_H5 * Method: H5AreadComplex * Signature: (JJ[Ljava/lang/String;)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AreadComplex - (JNIEnv *, jclass, jlong, jlong, jobjectArray); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AreadComplex(JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Copies the content of one dataset to another dataset @@ -75,9 +75,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex * Method: H5Acopy * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Acopy - (JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Acopy(JNIEnv *, jclass, jlong, jlong); /* * Copies the content of one dataset to another dataset @@ -85,35 +83,33 @@ Java_hdf_hdf5lib_H5_H5Acopy * Method: H5Dcopy * Signature: (JJ)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dcopy - (JNIEnv*, jclass, jlong, jlong); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dcopy(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Gget_obj_info_full * Signature: (JLjava/lang/String;[Ljava/lang/String;[I[I[J[JIII)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full - (JNIEnv*, jclass, jlong, jstring, jobjectArray, jintArray, jintArray, jlongArray, jobjectArray, jint, jint, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full(JNIEnv *, jclass, jlong, jstring, + jobjectArray, jintArray, jintArray, + jlongArray, jobjectArray, jint, jint, + jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Gget_obj_info_max * Signature: (J[Ljava/lang/String;[I[I[JJI)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max - (JNIEnv*, jclass, jlong, jobjectArray, jintArray, jintArray, jlongArray, jlong, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max(JNIEnv *, jclass, jlong, jobjectArray, + jintArray, jintArray, jlongArray, jlong, + jint); /* * Class: hdf_hdf5lib_H5 * Method: H5export_dataset * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5export_1dataset - (JNIEnv*, jclass, jstring, jstring, jstring, jint); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5export_1dataset(JNIEnv *, jclass, jstring, jstring, jstring, + jint); -#endif /* H5UTIL_H__ */ +#endif /* H5UTIL_H__ */ diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c index 1ead30b..1460e5d 100644 --- a/java/src/jni/h5vlImp.c +++ b/java/src/jni/h5vlImp.c @@ -33,18 +33,19 @@ extern "C" { * Signature: (Ljava/lang/String;J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name - (JNIEnv *env, jclass clss, jobject connector_name, jlong vipl_id) +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name(JNIEnv *env, jclass clss, jobject connector_name, + jlong vipl_id) { const char *volName = NULL; - hid_t status = H5I_INVALID_HID; + hid_t status = H5I_INVALID_HID; UNUSED(clss); if (NULL == connector_name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLregister_connector_by_name: VOL connector name is NULL"); - PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLregister_connector_by_name: VOL connector name not pinned"); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, + "H5VLregister_connector_by_name: VOL connector name not pinned"); if ((status = H5VLregister_connector_by_name(volName, (hid_t)vipl_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -62,8 +63,8 @@ done: * Signature: (IJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value - (JNIEnv *env, jclass clss, jint connector_value, jlong vipl_id) +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value(JNIEnv *env, jclass clss, jint connector_value, + jlong vipl_id) { hid_t status = H5I_INVALID_HID; @@ -82,18 +83,18 @@ done: * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1name - (JNIEnv *env, jclass clss, jobject connector_name) +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1name(JNIEnv *env, jclass clss, jobject connector_name) { const char *volName = NULL; - htri_t bval = JNI_FALSE; + htri_t bval = JNI_FALSE; UNUSED(clss); if (NULL == connector_name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLis_connector_registered_by_name: VOL connector name is NULL"); - PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLis_connector_registered_by_name: VOL connector name not pinned"); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, + "H5VLis_connector_registered_by_name: VOL connector name not pinned"); if ((bval = H5VLis_connector_registered_by_name(volName)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -113,8 +114,7 @@ done: * Signature: (I)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1value - (JNIEnv *env, jclass clss, jint connector_value) +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1value(JNIEnv *env, jclass clss, jint connector_value) { htri_t bval = JNI_FALSE; @@ -138,8 +138,7 @@ done: * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLget_1connector_1id - (JNIEnv *env, jclass clss, jlong obj_id) +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id(JNIEnv *env, jclass clss, jlong obj_id) { hid_t status = H5I_INVALID_HID; @@ -158,18 +157,18 @@ done: * Signature: (Ljava/lang/String;)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1name - (JNIEnv *env, jclass clss, jobject connector_name) +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1name(JNIEnv *env, jclass clss, jobject connector_name) { const char *volName = NULL; - hid_t status = H5I_INVALID_HID; + hid_t status = H5I_INVALID_HID; UNUSED(clss); if (NULL == connector_name) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLget_connector_id_by_name: VOL connector name is NULL"); - PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLget_connector_id_by_name: VOL connector name not pinned"); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, + "H5VLget_connector_id_by_name: VOL connector name not pinned"); if ((status = H5VLget_connector_id_by_name(volName)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -187,8 +186,7 @@ done: * Signature: (I)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1value - (JNIEnv *env, jclass clss, jint connector_value) +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1value(JNIEnv *env, jclass clss, jint connector_value) { hid_t status = H5I_INVALID_HID; @@ -211,12 +209,11 @@ done: */ JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5VLget_1connector_1name - (JNIEnv *env, jclass clss, jlong object_id) +Java_hdf_hdf5lib_H5_H5VLget_1connector_1name(JNIEnv *env, jclass clss, jlong object_id) { - ssize_t buf_size, status; - char *volName = NULL; - jstring str = NULL; + ssize_t buf_size, status; + char * volName = NULL; + jstring str = NULL; UNUSED(clss); @@ -225,8 +222,9 @@ Java_hdf_hdf5lib_H5_H5VLget_1connector_1name H5_LIBRARY_ERROR(ENVONLY); if (buf_size > 0) { - if (NULL == (volName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) - H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5VLget_connector_name: failed to allocated VOL connector name buffer"); + if (NULL == (volName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_OUT_OF_MEMORY_ERROR(ENVONLY, + "H5VLget_connector_name: failed to allocated VOL connector name buffer"); if ((status = H5VLget_connector_name((hid_t)object_id, volName, (size_t)buf_size + 1)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -249,8 +247,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5VLclose - (JNIEnv *env, jclass clss, jlong connector_id) +Java_hdf_hdf5lib_H5_H5VLclose(JNIEnv *env, jclass clss, jlong connector_id) { herr_t retValue = FAIL; @@ -269,8 +266,7 @@ done: * Signature: (J)V */ JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5VLunregister_1connector - (JNIEnv *env, jclass clss, jlong connector_id) +Java_hdf_hdf5lib_H5_H5VLunregister_1connector(JNIEnv *env, jclass clss, jlong connector_id) { herr_t retValue = FAIL; @@ -283,7 +279,6 @@ done: return; } /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */ - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5vlImp.h b/java/src/jni/h5vlImp.h index a58abef..4fbf577 100644 --- a/java/src/jni/h5vlImp.h +++ b/java/src/jni/h5vlImp.h @@ -25,63 +25,52 @@ extern "C" { * Method: H5VLregister_connector_by_name * Signature: (Ljava/lang/String;J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name - (JNIEnv *, jclass, jobject, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name(JNIEnv *, jclass, jobject, + jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5VLregister_connector_by_value * Signature: (IJ)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value - (JNIEnv *, jclass, jint, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value(JNIEnv *, jclass, jint, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5VLis_connector_registered_by_name * Signature: (Ljava/lang/String;)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1name - (JNIEnv *, jclass, jobject); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1name(JNIEnv *, jclass, + jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5VLis_connector_registered_by_value * Signature: (I)Z */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1value - (JNIEnv *, jclass, jint); +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered_1by_1value(JNIEnv *, jclass, + jint); /* * Class: hdf_hdf5lib_H5 * Method: H5VLget_connector_id * Signature: (J)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLget_1connector_1id - (JNIEnv *, jclass, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLget_1connector_1id(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5VLget_connector_id_by_name * Signature: (Ljava/lang/String;)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1name - (JNIEnv *, jclass, jobject); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1name(JNIEnv *, jclass, jobject); /* * Class: hdf_hdf5lib_H5 * Method: H5VLget_connector_id_by_value * Signature: (I)J */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1value - (JNIEnv *, jclass, jint); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1value(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 @@ -89,27 +78,21 @@ Java_hdf_hdf5lib_H5_H5VLget_1connector_1id_1by_1value * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5VLget_1connector_1name - (JNIEnv *, jclass, jlong); +JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5VLget_1connector_1name(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5VLclose * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5VLclose - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5VLclose(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5VLunregister_connector * Signature: (J)V */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5VLunregister_1connector - (JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5VLunregister_1connector(JNIEnv *, jclass, jlong); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5zImp.c b/java/src/jni/h5zImp.c index a1c8517..5d9f442 100644 --- a/java/src/jni/h5zImp.c +++ b/java/src/jni/h5zImp.c @@ -33,8 +33,7 @@ extern "C" { * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Zunregister - (JNIEnv *env, jclass clss, jint filter) +Java_hdf_hdf5lib_H5_H5Zunregister(JNIEnv *env, jclass clss, jint filter) { herr_t retVal = FAIL; @@ -53,8 +52,7 @@ done: * Signature: (I)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Zfilter_1avail - (JNIEnv *env, jclass clss, jint filter) +Java_hdf_hdf5lib_H5_H5Zfilter_1avail(JNIEnv *env, jclass clss, jint filter) { herr_t retVal = FAIL; @@ -74,21 +72,19 @@ done: */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Zget_1filter_1info - (JNIEnv *env, jclass clss, jint filter) +Java_hdf_hdf5lib_H5_H5Zget_1filter_1info(JNIEnv *env, jclass clss, jint filter) { unsigned int flags = 0; UNUSED(clss); - if (H5Zget_filter_info((H5Z_filter_t) filter, (unsigned *) &flags) < 0) + if (H5Zget_filter_info((H5Z_filter_t)filter, (unsigned *)&flags) < 0) H5_LIBRARY_ERROR(ENVONLY); done: return (jint)flags; } /* end Java_hdf_hdf5lib_H5_H5Zget_1filter_1info */ - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5zImp.h b/java/src/jni/h5zImp.h index bffe9d8..58b088b 100644 --- a/java/src/jni/h5zImp.h +++ b/java/src/jni/h5zImp.h @@ -26,18 +26,14 @@ extern "C" { * Method: H5Zunregister * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Zunregister - (JNIEnv *, jclass, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Zunregister(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 * Method: H5Zfilter_avail * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Zfilter_1avail - (JNIEnv *, jclass, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Zfilter_1avail(JNIEnv *, jclass, jint); /* * Class: hdf_hdf5lib_H5 @@ -45,9 +41,7 @@ Java_hdf_hdf5lib_H5_H5Zfilter_1avail * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Zget_1filter_1info - (JNIEnv *, jclass, jint); +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Zget_1filter_1info(JNIEnv *, jclass, jint); #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/nativeData.c b/java/src/jni/nativeData.c index 3c3d3d5..d2f00ec 100644 --- a/java/src/jni/nativeData.c +++ b/java/src/jni/nativeData.c @@ -44,21 +44,20 @@ extern "C" { #include "h5jni.h" #include "nativeData.h" - /* returns int [] */ JNIEXPORT jintArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B - (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B(JNIEnv *env, jclass clss, + jbyteArray bdata) /* IN: array of bytes */ { - jintArray rarray = NULL; - jboolean bb; - jbyte *barr = NULL; - jint *iarray = NULL; - jint *iap = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jintArray rarray = NULL; + jboolean bb; + jbyte * barr = NULL; + jint * iarray = NULL; + jint * iap = NULL; + char * bp = NULL; + int blen; + int ii; + int len; UNUSED(clss); @@ -79,7 +78,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B PIN_INT_ARRAY(ENVONLY, rarray, iarray, &bb, "byteToInt: int array not pinned"); - bp = (char *)barr; + bp = (char *)barr; iap = iarray; for (ii = 0; ii < len; ii++) { *iap = *(jint *)bp; @@ -98,18 +97,18 @@ done: /* returns float [] */ JNIEXPORT jfloatArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B - (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B(JNIEnv *env, jclass clss, + jbyteArray bdata) /* IN: array of bytes */ { - jfloatArray rarray = NULL; - jboolean bb; - jfloat *farray = NULL; - jfloat *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jfloatArray rarray = NULL; + jboolean bb; + jfloat * farray = NULL; + jfloat * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; + int len; UNUSED(clss); @@ -130,7 +129,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B PIN_FLOAT_ARRAY(ENVONLY, rarray, farray, &bb, "byteToFloat: float array not pinned"); - bp = (char *)barr; + bp = (char *)barr; iap = farray; for (ii = 0; ii < len; ii++) { *iap = *(jfloat *)bp; @@ -149,18 +148,18 @@ done: /* returns short [] */ JNIEXPORT jshortArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B - (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B(JNIEnv *env, jclass clss, + jbyteArray bdata) /* IN: array of bytes */ { - jshortArray rarray = NULL; - jboolean bb; - jshort *sarray = NULL; - jshort *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jshortArray rarray = NULL; + jboolean bb; + jshort * sarray = NULL; + jshort * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; + int len; UNUSED(clss); @@ -181,7 +180,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B PIN_SHORT_ARRAY(ENVONLY, rarray, sarray, &bb, "byteToShort: short array not pinned"); - bp = (char *)barr; + bp = (char *)barr; iap = sarray; for (ii = 0; ii < len; ii++) { *iap = *(jshort *)bp; @@ -200,18 +199,18 @@ done: /* returns long [] */ JNIEXPORT jlongArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B - (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B(JNIEnv *env, jclass clss, + jbyteArray bdata) /* IN: array of bytes */ { - jlongArray rarray = NULL; - jboolean bb; - jlong *larray = NULL; - jlong *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jlongArray rarray = NULL; + jboolean bb; + jlong * larray = NULL; + jlong * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; + int len; UNUSED(clss); @@ -232,7 +231,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B PIN_LONG_ARRAY(ENVONLY, rarray, larray, &bb, "byteToLong: long array not pinned"); - bp = (char *)barr; + bp = (char *)barr; iap = larray; for (ii = 0; ii < len; ii++) { *iap = *(jlong *)bp; @@ -251,18 +250,18 @@ done: /* returns double [] */ JNIEXPORT jdoubleArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B - (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B(JNIEnv *env, jclass clss, + jbyteArray bdata) /* IN: array of bytes */ { - jdoubleArray rarray = NULL; - jboolean bb; - jdouble *darray = NULL; - jdouble *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jdoubleArray rarray = NULL; + jboolean bb; + jdouble * darray = NULL; + jdouble * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; + int len; UNUSED(clss); @@ -283,7 +282,7 @@ Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B PIN_DOUBLE_ARRAY(ENVONLY, rarray, darray, &bb, "byteToDouble: double array not pinned"); - bp = (char *)barr; + bp = (char *)barr; iap = darray; for (ii = 0; ii < len; ii++) { *iap = *(jdouble *)bp; @@ -302,17 +301,17 @@ done: /* returns int [] */ JNIEXPORT jintArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B - (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B(JNIEnv *env, jclass clss, jint start, jint len, + jbyteArray bdata) /* IN: array of bytes */ { - jintArray rarray = NULL; - jboolean bb; - jint *iarray = NULL; - jint *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jintArray rarray = NULL; + jboolean bb; + jint * iarray = NULL; + jint * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; UNUSED(clss); @@ -354,17 +353,17 @@ done: /* returns short [] */ JNIEXPORT jshortArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B - (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B(JNIEnv *env, jclass clss, jint start, jint len, + jbyteArray bdata) /* IN: array of bytes */ { - jshortArray rarray = NULL; - jboolean bb; - jshort *sarray = NULL; - jshort *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jshortArray rarray = NULL; + jboolean bb; + jshort * sarray = NULL; + jshort * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; UNUSED(clss); @@ -406,17 +405,17 @@ done: /* returns float [] */ JNIEXPORT jfloatArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B - (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B(JNIEnv *env, jclass clss, jint start, jint len, + jbyteArray bdata) /* IN: array of bytes */ { - jfloatArray rarray = NULL; - jboolean bb; - jfloat *farray = NULL; - jfloat *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jfloatArray rarray = NULL; + jboolean bb; + jfloat * farray = NULL; + jfloat * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; UNUSED(clss); @@ -458,17 +457,17 @@ done: /* returns long [] */ JNIEXPORT jlongArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B - (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B(JNIEnv *env, jclass clss, jint start, jint len, + jbyteArray bdata) /* IN: array of bytes */ { - jlongArray rarray = NULL; - jboolean bb; - jlong *larray = NULL; - jlong *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jlongArray rarray = NULL; + jboolean bb; + jlong * larray = NULL; + jlong * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; UNUSED(clss); @@ -510,17 +509,17 @@ done: /* returns double [] */ JNIEXPORT jdoubleArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B - (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ +Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B(JNIEnv *env, jclass clss, jint start, jint len, + jbyteArray bdata) /* IN: array of bytes */ { - jdoubleArray rarray = NULL; - jboolean bb; - jdouble *darray = NULL; - jdouble *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jdoubleArray rarray = NULL; + jboolean bb; + jdouble * darray = NULL; + jdouble * iap = NULL; + jbyte * barr = NULL; + char * bp = NULL; + int blen; + int ii; UNUSED(clss); @@ -562,21 +561,21 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I - (JNIEnv *env, jclass clss, jint start, jint len, jintArray idata) /* IN: array of int */ +Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I(JNIEnv *env, jclass clss, jint start, jint len, + jintArray idata) /* IN: array of int */ { - jbyteArray rarray = NULL; - jboolean bb; - jbyte *barray = NULL; - jbyte *bap = NULL; - jint *ip = NULL; - jint *iarr = NULL; - int ilen; - int blen; - int ii; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jbyte * barray = NULL; + jbyte * bap = NULL; + jint * ip = NULL; + jint * iarr = NULL; + int ilen; + int blen; + int ii; + int ij; union things { - int ival; + int ival; char bytes[4]; } u; @@ -607,11 +606,11 @@ Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; (size_t) ij < sizeof(jint); ij++) { + for (ij = 0; (size_t)ij < sizeof(jint); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - } /* end for */ + } /* end for */ done: if (barray) @@ -624,22 +623,22 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S - (JNIEnv *env, jclass clss, jint start, jint len, jshortArray sdata) /* IN: array of short */ +Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S(JNIEnv *env, jclass clss, jint start, jint len, + jshortArray sdata) /* IN: array of short */ { - jbyteArray rarray = NULL; - jboolean bb; - jshort *ip = NULL; - jshort *sarr = NULL; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ilen; - int blen; - int ii; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jshort * ip = NULL; + jshort * sarr = NULL; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ilen; + int blen; + int ii; + int ij; union things { short ival; - char bytes[4]; + char bytes[4]; } u; UNUSED(clss); @@ -669,11 +668,11 @@ Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; (size_t) ij < sizeof(jshort); ij++) { + for (ij = 0; (size_t)ij < sizeof(jshort); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - } /* end for */ + } /* end for */ done: if (barray) @@ -686,22 +685,22 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F - (JNIEnv *env, jclass clss, jint start, jint len, jfloatArray fdata) /* IN: array of float */ +Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F(JNIEnv *env, jclass clss, jint start, jint len, + jfloatArray fdata) /* IN: array of float */ { - jbyteArray rarray = NULL; - jboolean bb; - jfloat *ip = NULL; - jfloat *farr = NULL; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ilen; - int blen; - int ii; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jfloat * ip = NULL; + jfloat * farr = NULL; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ilen; + int blen; + int ii; + int ij; union things { float ival; - char bytes[4]; + char bytes[4]; } u; UNUSED(clss); @@ -731,11 +730,11 @@ Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; (size_t) ij < sizeof(jfloat); ij++) { + for (ij = 0; (size_t)ij < sizeof(jfloat); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - } /* end for */ + } /* end for */ done: if (barray) @@ -748,22 +747,22 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D - (JNIEnv *env, jclass clss, jint start, jint len, jdoubleArray ddata) /* IN: array of double */ +Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D(JNIEnv *env, jclass clss, jint start, jint len, + jdoubleArray ddata) /* IN: array of double */ { - jbyteArray rarray = NULL; - jboolean bb; - jdouble *ip = NULL; - jdouble *darr = NULL; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ilen; - int blen; - int ii; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jdouble * ip = NULL; + jdouble * darr = NULL; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ilen; + int blen; + int ii; + int ij; union things { double ival; - char bytes[8]; + char bytes[8]; } u; UNUSED(clss); @@ -793,11 +792,11 @@ Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; (size_t) ij < sizeof(jdouble); ij++) { + for (ij = 0; (size_t)ij < sizeof(jdouble); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - } /* end for */ + } /* end for */ done: if (barray) @@ -810,22 +809,22 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J - (JNIEnv *env, jclass clss, jint start, jint len, jlongArray ldata) /* IN: array of long */ +Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J(JNIEnv *env, jclass clss, jint start, jint len, + jlongArray ldata) /* IN: array of long */ { - jbyteArray rarray = NULL; - jboolean bb; - jlong *ip = NULL; - jlong *larr = NULL; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ilen; - int blen; - int ii; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jlong * ip = NULL; + jlong * larr = NULL; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ilen; + int blen; + int ii; + int ij; union things { jlong ival; - char bytes[8]; + char bytes[8]; } u; UNUSED(clss); @@ -855,11 +854,11 @@ Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; (size_t) ij < sizeof(jlong); ij++) { + for (ij = 0; (size_t)ij < sizeof(jlong); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - } /* end for */ + } /* end for */ done: if (barray) @@ -872,16 +871,15 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_intToByte__I - (JNIEnv *env, jclass clss, jint idata) /* IN: int */ +Java_hdf_hdf5lib_HDFNativeData_intToByte__I(JNIEnv *env, jclass clss, jint idata) /* IN: int */ { - jbyteArray rarray = NULL; - jboolean bb; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ij; union things { - int ival; + int ival; char bytes[sizeof(int)]; } u; @@ -892,9 +890,9 @@ Java_hdf_hdf5lib_HDFNativeData_intToByte__I PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "intToByte: byte array not pinned"); - bap = barray; + bap = barray; u.ival = idata; - for (ij = 0; (size_t) ij < sizeof(jint); ij++) { + for (ij = 0; (size_t)ij < sizeof(jint); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ @@ -908,17 +906,16 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_floatToByte__F - (JNIEnv *env, jclass clss, jfloat fdata) /* IN: float */ +Java_hdf_hdf5lib_HDFNativeData_floatToByte__F(JNIEnv *env, jclass clss, jfloat fdata) /* IN: float */ { - jbyteArray rarray = NULL; - jboolean bb; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ij; union things { float ival; - char bytes[sizeof(float)]; + char bytes[sizeof(float)]; } u; UNUSED(clss); @@ -928,9 +925,9 @@ Java_hdf_hdf5lib_HDFNativeData_floatToByte__F PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "floatToByte: byte array not pinned"); - bap = barray; + bap = barray; u.ival = fdata; - for (ij = 0; (size_t) ij < sizeof(jfloat); ij++) { + for (ij = 0; (size_t)ij < sizeof(jfloat); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ @@ -944,17 +941,16 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_shortToByte__S - (JNIEnv *env, jclass clss, jshort sdata) /* IN: short */ +Java_hdf_hdf5lib_HDFNativeData_shortToByte__S(JNIEnv *env, jclass clss, jshort sdata) /* IN: short */ { - jbyteArray rarray = NULL; - jboolean bb; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ij; union things { short ival; - char bytes[sizeof(short)]; + char bytes[sizeof(short)]; } u; UNUSED(clss); @@ -964,9 +960,9 @@ Java_hdf_hdf5lib_HDFNativeData_shortToByte__S PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "shortToByte: byte array not pinned"); - bap = barray; + bap = barray; u.ival = sdata; - for (ij = 0; (size_t) ij < sizeof(jshort); ij++) { + for (ij = 0; (size_t)ij < sizeof(jshort); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ @@ -980,17 +976,16 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D - (JNIEnv *env, jclass clss, jdouble ddata) /* IN: double */ +Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D(JNIEnv *env, jclass clss, jdouble ddata) /* IN: double */ { - jbyteArray rarray = NULL; - jboolean bb; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ij; union things { double ival; - char bytes[sizeof(double)]; + char bytes[sizeof(double)]; } u; UNUSED(clss); @@ -1000,9 +995,9 @@ Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "doubleToByte: byte array not pinned"); - bap = barray; + bap = barray; u.ival = ddata; - for (ij = 0; (size_t) ij < sizeof(jdouble); ij++) { + for (ij = 0; (size_t)ij < sizeof(jdouble); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ @@ -1016,17 +1011,16 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_longToByte__J - (JNIEnv *env, jclass clss, jlong ldata) /* IN: long */ +Java_hdf_hdf5lib_HDFNativeData_longToByte__J(JNIEnv *env, jclass clss, jlong ldata) /* IN: long */ { - jbyteArray rarray = NULL; - jboolean bb; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ij; union things { jlong ival; - char bytes[sizeof(jlong)]; + char bytes[sizeof(jlong)]; } u; UNUSED(clss); @@ -1036,9 +1030,9 @@ Java_hdf_hdf5lib_HDFNativeData_longToByte__J PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "longToByte: byte array not pinned"); - bap = barray; + bap = barray; u.ival = ldata; - for (ij = 0; (size_t) ij < sizeof(jlong); ij++) { + for (ij = 0; (size_t)ij < sizeof(jlong); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ @@ -1052,17 +1046,16 @@ done: /* returns byte [] */ JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToByte__B - (JNIEnv *env, jclass clss, jbyte bdata) /* IN: byte */ +Java_hdf_hdf5lib_HDFNativeData_byteToByte__B(JNIEnv *env, jclass clss, jbyte bdata) /* IN: byte */ { - jbyteArray rarray = NULL; - jboolean bb; - jbyte *barray = NULL; - jbyte *bap = NULL; - int ij; + jbyteArray rarray = NULL; + jboolean bb; + jbyte * barray = NULL; + jbyte * bap = NULL; + int ij; union things { jbyte ival; - char bytes[sizeof(jbyte)]; + char bytes[sizeof(jbyte)]; } u; UNUSED(clss); @@ -1072,9 +1065,9 @@ Java_hdf_hdf5lib_HDFNativeData_byteToByte__B PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "byteToByte: byte array not pinned"); - bap = barray; + bap = barray; u.ival = bdata; - for (ij = 0; (size_t) ij < sizeof(jbyte); ij++) { + for (ij = 0; (size_t)ij < sizeof(jbyte); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ @@ -1086,7 +1079,6 @@ done: return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToByte__B */ - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/nativeData.h b/java/src/jni/nativeData.h index e9e1a5d..012f73e 100644 --- a/java/src/jni/nativeData.h +++ b/java/src/jni/nativeData.h @@ -21,111 +21,78 @@ extern "C" { #endif /* __cplusplus */ - /* returns int [] */ -JNIEXPORT jintArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B -(JNIEnv *, jclass, jbyteArray); +JNIEXPORT jintArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B(JNIEnv *, jclass, jbyteArray); /* returns float [] */ -JNIEXPORT jfloatArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B -(JNIEnv *, jclass, jbyteArray); +JNIEXPORT jfloatArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B(JNIEnv *, jclass, jbyteArray); /* returns short [] */ -JNIEXPORT jshortArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B -(JNIEnv *, jclass, jbyteArray); +JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B(JNIEnv *, jclass, jbyteArray); /* returns long [] */ -JNIEXPORT jlongArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B -(JNIEnv *, jclass, jbyteArray); +JNIEXPORT jlongArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B(JNIEnv *, jclass, jbyteArray); /* returns double [] */ -JNIEXPORT jdoubleArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B -(JNIEnv *, jclass, jbyteArray); +JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B(JNIEnv *, jclass, jbyteArray); /* returns int [] */ -JNIEXPORT jintArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B -(JNIEnv *, jclass, jint, jint, jbyteArray); +JNIEXPORT jintArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B(JNIEnv *, jclass, jint, jint, + jbyteArray); /* returns short [] */ -JNIEXPORT jshortArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B -(JNIEnv *, jclass, jint, jint, jbyteArray); +JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B(JNIEnv *, jclass, jint, jint, + jbyteArray); /* returns float [] */ -JNIEXPORT jfloatArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B -(JNIEnv *, jclass, jint, jint, jbyteArray); +JNIEXPORT jfloatArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B(JNIEnv *, jclass, jint, jint, + jbyteArray); /* returns long [] */ -JNIEXPORT jlongArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B -(JNIEnv *, jclass, jint, jint, jbyteArray); +JNIEXPORT jlongArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B(JNIEnv *, jclass, jint, jint, + jbyteArray); /* returns double [] */ -JNIEXPORT jdoubleArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B -(JNIEnv *, jclass, jint, jint, jbyteArray); +JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B(JNIEnv *, jclass, jint, + jint, jbyteArray); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I -(JNIEnv *, jclass, jint, jint, jintArray); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I(JNIEnv *, jclass, jint, jint, + jintArray); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S -(JNIEnv *, jclass, jint, jint, jshortArray); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S(JNIEnv *, jclass, jint, jint, + jshortArray); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F -(JNIEnv *, jclass, jint, jint, jfloatArray); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F(JNIEnv *, jclass, jint, jint, + jfloatArray); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D -(JNIEnv *, jclass, jint, jint, jdoubleArray); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D(JNIEnv *, jclass, jint, jint, + jdoubleArray); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J -(JNIEnv *, jclass, jint, jint, jlongArray); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J(JNIEnv *, jclass, jint, jint, + jlongArray); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_intToByte__I -(JNIEnv *, jclass, jint); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_intToByte__I(JNIEnv *, jclass, jint); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_floatToByte__F -(JNIEnv *, jclass, jfloat); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_floatToByte__F(JNIEnv *, jclass, jfloat); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_shortToByte__S -(JNIEnv *, jclass, jshort); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_shortToByte__S(JNIEnv *, jclass, jshort); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D -(JNIEnv *env, jclass, jdouble); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D(JNIEnv *env, jclass, jdouble); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_longToByte__J -(JNIEnv *, jclass, jlong); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_longToByte__J(JNIEnv *, jclass, jlong); /* returns byte [] */ -JNIEXPORT jbyteArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToByte__B -(JNIEnv *, jclass, jbyte); +JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToByte__B(JNIEnv *, jclass, jbyte); #ifdef __cplusplus } /* end extern "C" */ diff --git a/src/H5.c b/src/H5.c index 4b9b36c..3827756 100644 --- a/src/H5.c +++ b/src/H5.c @@ -15,42 +15,38 @@ /* Module Setup */ /****************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FSprivate.h" /* File free space */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FSprivate.h" /* File free space */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static void H5_debug_mask(const char*); +static void H5_debug_mask(const char *); #ifdef H5_HAVE_PARALLEL static int H5_mpi_delete_cb(MPI_Comm comm, int keyval, void *attr_val, int *flag); #endif /*H5_HAVE_PARALLEL*/ @@ -59,7 +55,6 @@ static int H5_mpi_delete_cb(MPI_Comm comm, int keyval, void *attr_val, int *flag /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -73,23 +68,22 @@ hbool_t H5_api_entered_g = FALSE; #ifdef H5_HAVE_THREADSAFE H5_api_t H5_g; #else -hbool_t H5_libinit_g = FALSE; /* Library hasn't been initialized */ -hbool_t H5_libterm_g = FALSE; /* Library isn't being shutdown */ +hbool_t H5_libinit_g = FALSE; /* Library hasn't been initialized */ +hbool_t H5_libterm_g = FALSE; /* Library isn't being shutdown */ #endif #ifdef H5_HAVE_MPE -hbool_t H5_MPEinit_g = FALSE; /* MPE Library hasn't been initialized */ +hbool_t H5_MPEinit_g = FALSE; /* MPE Library hasn't been initialized */ #endif -char H5_lib_vers_info_g[] = H5_VERS_INFO; -static hbool_t H5_dont_atexit_g = FALSE; -H5_debug_t H5_debug_g; /* debugging info */ +char H5_lib_vers_info_g[] = H5_VERS_INFO; +static hbool_t H5_dont_atexit_g = FALSE; +H5_debug_t H5_debug_g; /* debugging info */ /*******************/ /* Local Variables */ /*******************/ - /*-------------------------------------------------------------------------- * NAME * H5_init_library -- Initialize library-global information @@ -113,12 +107,12 @@ H5_init_library(void) #ifdef H5_HAVE_PARALLEL { - int mpi_initialized; - int mpi_finalized; + int mpi_initialized; + int mpi_finalized; int mpi_code; - MPI_Initialized(&mpi_initialized); - MPI_Finalized(&mpi_finalized); + MPI_Initialized(&mpi_initialized); + MPI_Finalized(&mpi_finalized); #ifdef H5_HAVE_MPE /* Initialize MPE instrumentation library. */ @@ -126,7 +120,7 @@ H5_init_library(void) int mpe_code; if (mpi_initialized && !mpi_finalized) { mpe_code = MPE_Init_log(); - HDassert(mpe_code >=0); + HDassert(mpe_code >= 0); H5_MPEinit_g = TRUE; } } @@ -137,15 +131,15 @@ H5_init_library(void) if (mpi_initialized && !mpi_finalized) { int key_val; - if(MPI_SUCCESS != (mpi_code = MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN, - (MPI_Comm_delete_attr_function *)H5_mpi_delete_cb, - &key_val, NULL))) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_create_keyval( + MPI_COMM_NULL_COPY_FN, (MPI_Comm_delete_attr_function *)H5_mpi_delete_cb, + &key_val, NULL))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_create_keyval failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Comm_set_attr(MPI_COMM_SELF, key_val, NULL))) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_set_attr(MPI_COMM_SELF, key_val, NULL))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_set_attr failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Comm_free_keyval(&key_val))) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_free_keyval(&key_val))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_free_keyval failed", mpi_code) } } @@ -155,26 +149,26 @@ H5_init_library(void) * Make sure the package information is updated. */ HDmemset(&H5_debug_g, 0, sizeof H5_debug_g); - H5_debug_g.pkg[H5_PKG_A].name = "a"; + H5_debug_g.pkg[H5_PKG_A].name = "a"; H5_debug_g.pkg[H5_PKG_AC].name = "ac"; - H5_debug_g.pkg[H5_PKG_B].name = "b"; - H5_debug_g.pkg[H5_PKG_D].name = "d"; - H5_debug_g.pkg[H5_PKG_E].name = "e"; - H5_debug_g.pkg[H5_PKG_F].name = "f"; - H5_debug_g.pkg[H5_PKG_G].name = "g"; + H5_debug_g.pkg[H5_PKG_B].name = "b"; + H5_debug_g.pkg[H5_PKG_D].name = "d"; + H5_debug_g.pkg[H5_PKG_E].name = "e"; + H5_debug_g.pkg[H5_PKG_F].name = "f"; + H5_debug_g.pkg[H5_PKG_G].name = "g"; H5_debug_g.pkg[H5_PKG_HG].name = "hg"; H5_debug_g.pkg[H5_PKG_HL].name = "hl"; - H5_debug_g.pkg[H5_PKG_I].name = "i"; - H5_debug_g.pkg[H5_PKG_M].name = "m"; + H5_debug_g.pkg[H5_PKG_I].name = "i"; + H5_debug_g.pkg[H5_PKG_M].name = "m"; H5_debug_g.pkg[H5_PKG_MF].name = "mf"; H5_debug_g.pkg[H5_PKG_MM].name = "mm"; - H5_debug_g.pkg[H5_PKG_O].name = "o"; - H5_debug_g.pkg[H5_PKG_P].name = "p"; - H5_debug_g.pkg[H5_PKG_S].name = "s"; - H5_debug_g.pkg[H5_PKG_T].name = "t"; - H5_debug_g.pkg[H5_PKG_V].name = "v"; + H5_debug_g.pkg[H5_PKG_O].name = "o"; + H5_debug_g.pkg[H5_PKG_P].name = "p"; + H5_debug_g.pkg[H5_PKG_S].name = "s"; + H5_debug_g.pkg[H5_PKG_T].name = "t"; + H5_debug_g.pkg[H5_PKG_V].name = "v"; H5_debug_g.pkg[H5_PKG_VL].name = "vl"; - H5_debug_g.pkg[H5_PKG_Z].name = "z"; + H5_debug_g.pkg[H5_PKG_Z].name = "z"; /* * Install atexit() library cleanup routines unless the H5dont_atexit() @@ -189,7 +183,7 @@ H5_init_library(void) * This must be entered before the library cleanup code so it's * executed in LIFO order (i.e., last). */ - (void)HDatexit(H5TS_win32_process_exit); + (void)HDatexit(H5TS_win32_process_exit); #endif /* H5_HAVE_THREADSAFE && H5_HAVE_WIN_THREADS */ /* Normal library termination code */ @@ -212,25 +206,25 @@ H5_init_library(void) * When the application does not close the file, routines in the module might * be called via H5_term_library() when shutting down the file. */ - if(H5E_init() < 0) + if (H5E_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface") - if(H5VL_init_phase1() < 0) + if (H5VL_init_phase1() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") - if(H5P_init() < 0) + if (H5P_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") - if(H5T_init() < 0) + if (H5T_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize datatype interface") - if(H5D_init() < 0) + if (H5D_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataset interface") - if(H5AC_init() < 0) + if (H5AC_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface") - if(H5L_init() < 0) + if (H5L_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize link interface") - if(H5FS_init() < 0) + if (H5FS_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize FS interface") /* Finish initializing interfaces that depend on the interfaces above */ - if(H5VL_init_phase2() < 0) + if (H5VL_init_phase2() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") /* Debugging? */ @@ -241,7 +235,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5_init_library() */ - /*------------------------------------------------------------------------- * Function: H5_term_library * @@ -256,9 +249,9 @@ done: void H5_term_library(void) { - int pending, ntries = 0, n; - size_t at = 0; - char loop[1024]; + int pending, ntries = 0, n; + size_t at = 0; + char loop[1024]; H5E_auto2_t func; #ifdef H5_HAVE_THREADSAFE @@ -268,7 +261,7 @@ H5_term_library(void) #endif /* Don't do anything if the library is already closed */ - if(!(H5_INIT_GLOBAL)) + if (!(H5_INIT_GLOBAL)) goto done; /* Indicate that the library is being shut down */ @@ -285,15 +278,11 @@ H5_term_library(void) * value if they do something that might affect some other interface in a * way that would necessitate some cleanup work in the other interface. */ -#define DOWN(F) \ - (((n = H5##F##_term_package()) && (at + 8) < sizeof loop)? \ - (HDsprintf(loop + at, "%s%s", (at ? "," : ""), #F), \ - at += HDstrlen(loop + at), \ - n): \ - ((n > 0 && (at + 5) < sizeof loop) ? \ - (HDsprintf(loop + at, "..."), \ - at += HDstrlen(loop + at), \ - n) : n)) +#define DOWN(F) \ + (((n = H5##F##_term_package()) && (at + 8) < sizeof loop) \ + ? (HDsprintf(loop + at, "%s%s", (at ? "," : ""), #F), at += HDstrlen(loop + at), n) \ + : ((n > 0 && (at + 5) < sizeof loop) ? (HDsprintf(loop + at, "..."), at += HDstrlen(loop + at), n) \ + : n)) do { pending = 0; @@ -318,19 +307,19 @@ H5_term_library(void) pending += DOWN(T_top); /* Don't shut down the file code until objects in files are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(F); /* Don't shut down the property list code until all objects that might * use property lists are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(P); /* Wait to shut down the "bottom" of various interfaces until the * files are closed, so pieces of the file can be serialized * correctly. */ - if(pending == 0) { + if (pending == 0) { /* Shut down the "bottom" of the attribute, dataset, group, * reference, dataspace, and datatype interfaces, fully closing * out the interfaces now. @@ -349,48 +338,48 @@ H5_term_library(void) * from being closed "out from underneath" of the high-level objects * that depend on them. -QAK */ - if(pending == 0) { + if (pending == 0) { pending += DOWN(AC); pending += DOWN(Z); pending += DOWN(FD); pending += DOWN(VL); /* Don't shut down the plugin code until all "pluggable" interfaces (Z, FD, PL) are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(PL); /* Don't shut down the error code until other APIs which use it are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(E); /* Don't shut down the ID code until other APIs which use them are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(I); /* Don't shut down the skip list code until everything that uses it is down */ - if(pending == 0) + if (pending == 0) pending += DOWN(SL); /* Don't shut down the free list code until everything that uses it is down */ - if(pending == 0) + if (pending == 0) pending += DOWN(FL); /* Don't shut down the API context code until _everything_ else is down */ - if(pending == 0) + if (pending == 0) pending += DOWN(CX); } /* end if */ - } while(pending && ntries++ < 100); + } while (pending && ntries++ < 100); - if(pending) { + if (pending) { /* Only display the error message if the user is interested in them. */ - if(func) { + if (func) { HDfprintf(stderr, "HDF5: infinite loop closing library\n"); HDfprintf(stderr, " %s\n", loop); #ifndef NDEBUG HDabort(); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end if */ - } /* end if */ + } /* end if */ #ifdef H5_HAVE_MPE /* Close MPE instrumentation library. May need to move this * down if any of the below code involves using the instrumentation code. */ - if(H5_MPEinit_g) { + if (H5_MPEinit_g) { int mpi_initialized; int mpi_finalized; int mpe_code; @@ -400,15 +389,15 @@ H5_term_library(void) if (mpi_initialized && !mpi_finalized) { mpe_code = MPE_Finish_log("h5log"); - HDassert(mpe_code >=0); - } /* end if */ - H5_MPEinit_g = FALSE; /* turn it off no matter what */ - } /* end if */ + HDassert(mpe_code >= 0); + } /* end if */ + H5_MPEinit_g = FALSE; /* turn it off no matter what */ + } /* end if */ #endif /* Free open debugging streams */ - while(H5_debug_g.open_stream) { - H5_debug_open_stream_t *tmp_open_stream; + while (H5_debug_g.open_stream) { + H5_debug_open_stream_t *tmp_open_stream; tmp_open_stream = H5_debug_g.open_stream; (void)HDfclose(H5_debug_g.open_stream->stream); @@ -437,7 +426,6 @@ done: return; } /* end H5_term_library() */ - /*------------------------------------------------------------------------- * Function: H5dont_atexit * @@ -461,12 +449,12 @@ done: herr_t H5dont_atexit(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT_NOERR_NOFS H5TRACE0("e",""); - if(H5_dont_atexit_g) + if (H5_dont_atexit_g) ret_value = FAIL; else H5_dont_atexit_g = TRUE; @@ -474,7 +462,6 @@ H5dont_atexit(void) FUNC_LEAVE_API_NOFS(ret_value) } /* end H5dont_atexit() */ - /*------------------------------------------------------------------------- * Function: H5garbage_collect * @@ -495,20 +482,19 @@ H5dont_atexit(void) herr_t H5garbage_collect(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE0("e",""); /* Call the garbage collection routines in the library */ - if(H5FL_garbage_coll()<0) + if (H5FL_garbage_coll() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect objects") done: FUNC_LEAVE_API(ret_value) -} /* end H5garbage_collect() */ +} /* end H5garbage_collect() */ - /*------------------------------------------------------------------------- * Function: H5set_free_list_limits * @@ -537,25 +523,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, - int arr_list_lim, int blk_global_lim, int blk_list_lim) +H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE6("e", "IsIsIsIsIsIs", reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim); /* Call the free list function to actually set the limits */ - if(H5FL_set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, - blk_global_lim, blk_list_lim, blk_global_lim, blk_list_lim)<0) + if (H5FL_set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, + blk_list_lim, blk_global_lim, blk_list_lim) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "can't set garbage collection limits") done: FUNC_LEAVE_API(ret_value) -} /* end H5set_free_list_limits() */ +} /* end H5set_free_list_limits() */ - /*------------------------------------------------------------------------- * Function: H5get_free_list_sizes * @@ -579,23 +564,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, - size_t *fac_size) +H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "*z*z*z*z", reg_size, arr_size, blk_size, fac_size); /* Call the free list function to actually get the sizes */ - if(H5FL_get_free_list_sizes(reg_size, arr_size, blk_size, fac_size) < 0) + if (H5FL_get_free_list_sizes(reg_size, arr_size, blk_size, fac_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get garbage collection sizes") done: FUNC_LEAVE_API(ret_value) -} /* end H5get_free_list_sizes() */ +} /* end H5get_free_list_sizes() */ - /*------------------------------------------------------------------------- * Function: H5get_alloc_stats * @@ -623,20 +606,19 @@ done: herr_t H5get_alloc_stats(H5_alloc_stats_t *stats) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", stats); /* Call the internal allocation stat routine to get the values */ - if(H5MM_get_alloc_stats(stats) < 0) + if (H5MM_get_alloc_stats(stats) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get allocation stats") done: FUNC_LEAVE_API(ret_value) -} /* end H5get_alloc_stats() */ +} /* end H5get_alloc_stats() */ - /*------------------------------------------------------------------------- * Function: H5_debug_mask * @@ -663,84 +645,92 @@ done: static void H5_debug_mask(const char *s) { - FILE *stream = stderr; - char pkg_name[32], *rest; - size_t i; - hbool_t clear; + FILE * stream = stderr; + char pkg_name[32], *rest; + size_t i; + hbool_t clear; while (s && *s) { - if (HDisalpha(*s) || '-'==*s || '+'==*s) { + if (HDisalpha(*s) || '-' == *s || '+' == *s) { /* Enable or Disable debugging? */ - if ('-'==*s) { + if ('-' == *s) { clear = TRUE; s++; - } else if ('+'==*s) { + } + else if ('+' == *s) { clear = FALSE; s++; - } else { + } + else { clear = FALSE; } /* end if */ /* Get the name */ - for (i=0; HDisalpha(*s); i++, s++) - if (i=(size_t)H5_NPKGS) + } /* end if */ + } /* end for */ + if (i >= (size_t)H5_NPKGS) HDfprintf(stderr, "HDF5_DEBUG: ignored %s\n", pkg_name); } /* end if-else */ - - } else if (HDisdigit(*s)) { - int fd = (int)HDstrtol(s, &rest, 0); + } + else if (HDisdigit(*s)) { + int fd = (int)HDstrtol(s, &rest, 0); H5_debug_open_stream_t *open_stream; - if((stream = HDfdopen(fd, "w")) != NULL) { + if ((stream = HDfdopen(fd, "w")) != NULL) { (void)HDsetvbuf(stream, NULL, _IOLBF, (size_t)0); - if(NULL == (open_stream = (H5_debug_open_stream_t *)H5MM_malloc(sizeof(H5_debug_open_stream_t)))) { + if (NULL == + (open_stream = (H5_debug_open_stream_t *)H5MM_malloc(sizeof(H5_debug_open_stream_t)))) { (void)HDfclose(stream); return; } /* end if */ - open_stream->stream = stream; - open_stream->next = H5_debug_g.open_stream; + open_stream->stream = stream; + open_stream->next = H5_debug_g.open_stream; H5_debug_g.open_stream = open_stream; } /* end if */ s = rest; - } else { + } + else { s++; } /* end if-else */ - } /* end while */ + } /* end while */ return; } /* end H5_debug_mask() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5_mpi_delete_cb * @@ -751,14 +741,15 @@ H5_debug_mask(const char *s) * *------------------------------------------------------------------------- */ -static int H5_mpi_delete_cb(MPI_Comm H5_ATTR_UNUSED comm, int H5_ATTR_UNUSED keyval, void H5_ATTR_UNUSED *attr_val, int H5_ATTR_UNUSED *flag) +static int +H5_mpi_delete_cb(MPI_Comm H5_ATTR_UNUSED comm, int H5_ATTR_UNUSED keyval, void H5_ATTR_UNUSED *attr_val, + int H5_ATTR_UNUSED *flag) { H5_term_library(); return MPI_SUCCESS; } #endif /*H5_HAVE_PARALLEL*/ - /*------------------------------------------------------------------------- * Function: H5get_libversion * @@ -778,21 +769,23 @@ static int H5_mpi_delete_cb(MPI_Comm H5_ATTR_UNUSED comm, int H5_ATTR_UNUSED key herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE3("e", "*Iu*Iu*Iu", majnum, minnum, relnum); /* Set the version information */ - if (majnum) *majnum = H5_VERS_MAJOR; - if (minnum) *minnum = H5_VERS_MINOR; - if (relnum) *relnum = H5_VERS_RELEASE; + if (majnum) + *majnum = H5_VERS_MAJOR; + if (minnum) + *minnum = H5_VERS_MINOR; + if (relnum) + *relnum = H5_VERS_RELEASE; done: FUNC_LEAVE_API(ret_value) } /* end H5get_libversion() */ - /*------------------------------------------------------------------------- * Function: H5check_version * @@ -808,78 +801,76 @@ done: * *------------------------------------------------------------------------- */ -#define VERSION_MISMATCH_WARNING \ - "Warning! ***HDF5 library version mismatched error***\n" \ - "The HDF5 header files used to compile this application do not match\n" \ - "the version used by the HDF5 library to which this application is linked.\n" \ - "Data corruption or segmentation faults may occur if the application continues.\n" \ - "This can happen when an application was compiled by one version of HDF5 but\n" \ - "linked with a different version of static or shared HDF5 library.\n" \ - "You should recompile the application or check your shared library related\n" \ +#define VERSION_MISMATCH_WARNING \ + "Warning! ***HDF5 library version mismatched error***\n" \ + "The HDF5 header files used to compile this application do not match\n" \ + "the version used by the HDF5 library to which this application is linked.\n" \ + "Data corruption or segmentation faults may occur if the application continues.\n" \ + "This can happen when an application was compiled by one version of HDF5 but\n" \ + "linked with a different version of static or shared HDF5 library.\n" \ + "You should recompile the application or check your shared library related\n" \ "settings such as 'LD_LIBRARY_PATH'.\n" herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) { - char lib_str[256]; - char substr[] = H5_VERS_SUBRELEASE; - static int checked = 0; /* If we've already checked the version info */ - static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */ - static const char *version_mismatch_warning = VERSION_MISMATCH_WARNING; - herr_t ret_value = SUCCEED; /* Return value */ + char lib_str[256]; + char substr[] = H5_VERS_SUBRELEASE; + static int checked = 0; /* If we've already checked the version info */ + static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */ + static const char * version_mismatch_warning = VERSION_MISMATCH_WARNING; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT_NOERR_NOFS H5TRACE3("e", "IuIuIu", majnum, minnum, relnum); /* Don't check again, if we already have */ if (checked) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED) - { const char *s; /* Environment string for disabling version check */ + { + const char *s; /* Environment string for disabling version check */ /* Allow different versions of the header files and library? */ - s = HDgetenv ("HDF5_DISABLE_VERSION_CHECK"); + s = HDgetenv("HDF5_DISABLE_VERSION_CHECK"); if (s && HDisdigit(*s)) - disable_version_check = (unsigned int)HDstrtol (s, NULL, 0); + disable_version_check = (unsigned int)HDstrtol(s, NULL, 0); } - if (H5_VERS_MAJOR!=majnum || H5_VERS_MINOR!=minnum || - H5_VERS_RELEASE!=relnum) { + if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE != relnum) { switch (disable_version_check) { - case 0: - HDfprintf(stderr, "%s%s", version_mismatch_warning, - "You can, at your own risk, disable this warning by setting the environment\n" - "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n" - "Setting it to 2 or higher will suppress the warning messages totally.\n"); - /* Mention the versions we are referring to */ - HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", - majnum, minnum, relnum, - (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE); - /* Show library settings if available */ - HDfprintf (stderr, "%s", H5libhdf5_settings); - - /* Bail out now. */ - HDfputs ("Bye...\n", stderr); - HDabort (); - case 1: - /* continue with a warning */ - /* Note that the warning message is embedded in the format string.*/ - HDfprintf (stderr, - "%s'HDF5_DISABLE_VERSION_CHECK' " - "environment variable is set to %d, application will\n" - "continue at your own risk.\n", - version_mismatch_warning, disable_version_check); - /* Mention the versions we are referring to */ - HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", - majnum, minnum, relnum, - (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE); - /* Show library settings if available */ - HDfprintf (stderr, "%s", H5libhdf5_settings); - break; - default: - /* 2 or higher: continue silently */ - break; + case 0: + HDfprintf(stderr, "%s%s", version_mismatch_warning, + "You can, at your own risk, disable this warning by setting the environment\n" + "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n" + "Setting it to 2 or higher will suppress the warning messages totally.\n"); + /* Mention the versions we are referring to */ + HDfprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum, + (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE); + /* Show library settings if available */ + HDfprintf(stderr, "%s", H5libhdf5_settings); + + /* Bail out now. */ + HDfputs("Bye...\n", stderr); + HDabort(); + case 1: + /* continue with a warning */ + /* Note that the warning message is embedded in the format string.*/ + HDfprintf(stderr, + "%s'HDF5_DISABLE_VERSION_CHECK' " + "environment variable is set to %d, application will\n" + "continue at your own risk.\n", + version_mismatch_warning, disable_version_check); + /* Mention the versions we are referring to */ + HDfprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum, + (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE); + /* Show library settings if available */ + HDfprintf(stderr, "%s", H5libhdf5_settings); + break; + default: + /* 2 or higher: continue silently */ + break; } /* end switch */ } /* end if */ @@ -887,39 +878,38 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) /* Indicate that the version check has been performed */ checked = 1; - if (!disable_version_check){ - /* - * Verify if H5_VERS_INFO is consistent with the other version information. - * Check only the first sizeof(lib_str) char. Assume the information - * will fit within this size or enough significance. - */ - HDsnprintf(lib_str, sizeof(lib_str), "HDF5 library version: %d.%d.%d", - H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); - if(*substr) { - HDstrncat(lib_str, "-", (size_t)1); - HDstrncat(lib_str, substr, (sizeof(lib_str) - HDstrlen(lib_str)) - 1); - } /* end if */ - if (HDstrcmp(lib_str, H5_lib_vers_info_g)){ - HDfputs ("Warning! Library version information error.\n" - "The HDF5 library version information are not " - "consistent in its source code.\nThis is NOT a fatal error " - "but should be corrected. Setting the environment\n" - "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of 1 " - "will suppress\nthis warning.\n", - stderr); - HDfprintf (stderr, "Library version information are:\n" - "H5_VERS_MAJOR=%d, H5_VERS_MINOR=%d, H5_VERS_RELEASE=%d, " - "H5_VERS_SUBRELEASE=%s,\nH5_VERS_INFO=%s\n", - H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, - H5_VERS_SUBRELEASE, H5_VERS_INFO); - } /* end if */ + if (!disable_version_check) { + /* + * Verify if H5_VERS_INFO is consistent with the other version information. + * Check only the first sizeof(lib_str) char. Assume the information + * will fit within this size or enough significance. + */ + HDsnprintf(lib_str, sizeof(lib_str), "HDF5 library version: %d.%d.%d", H5_VERS_MAJOR, H5_VERS_MINOR, + H5_VERS_RELEASE); + if (*substr) { + HDstrncat(lib_str, "-", (size_t)1); + HDstrncat(lib_str, substr, (sizeof(lib_str) - HDstrlen(lib_str)) - 1); + } /* end if */ + if (HDstrcmp(lib_str, H5_lib_vers_info_g)) { + HDfputs("Warning! Library version information error.\n" + "The HDF5 library version information are not " + "consistent in its source code.\nThis is NOT a fatal error " + "but should be corrected. Setting the environment\n" + "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of 1 " + "will suppress\nthis warning.\n", + stderr); + HDfprintf(stderr, + "Library version information are:\n" + "H5_VERS_MAJOR=%d, H5_VERS_MINOR=%d, H5_VERS_RELEASE=%d, " + "H5_VERS_SUBRELEASE=%s,\nH5_VERS_INFO=%s\n", + H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, H5_VERS_SUBRELEASE, H5_VERS_INFO); + } /* end if */ } done: FUNC_LEAVE_API_NOFS(ret_value) } /* end H5check_version() */ - /*------------------------------------------------------------------------- * Function: H5open * @@ -935,7 +925,7 @@ done: herr_t H5open(void) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOPUSH(FAIL) /*NO TRACE*/ @@ -946,7 +936,6 @@ done: FUNC_LEAVE_API_NOPUSH(ret_value) } /* end H5open() */ - /*------------------------------------------------------------------------- * Function: H5close * @@ -972,7 +961,6 @@ H5close(void) FUNC_LEAVE_API_NOFS(SUCCEED) } /* end H5close() */ - /*------------------------------------------------------------------------- * Function: H5allocate_memory * @@ -1005,7 +993,7 @@ H5allocate_memory(size_t size, hbool_t clear) FUNC_ENTER_API_NOINIT H5TRACE2("*x", "zb", size, clear); - if(clear) + if (clear) ret_value = H5MM_calloc(size); else ret_value = H5MM_malloc(size); @@ -1013,7 +1001,6 @@ H5allocate_memory(size_t size, hbool_t clear) FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5allocate_memory() */ - /*------------------------------------------------------------------------- * Function: H5resize_memory * @@ -1051,7 +1038,6 @@ H5resize_memory(void *mem, size_t size) FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5resize_memory() */ - /*------------------------------------------------------------------------- * Function: H5free_memory * @@ -1076,7 +1062,6 @@ H5free_memory(void *mem) FUNC_LEAVE_API_NOINIT(SUCCEED) } /* end H5free_memory() */ - /*------------------------------------------------------------------------- * Function: H5is_library_threadsafe * @@ -1098,16 +1083,15 @@ H5is_library_threadsafe(hbool_t *is_ts) /* At this time, it is impossible for this to fail. */ #ifdef H5_HAVE_THREADSAFE *is_ts = TRUE; -#else /* H5_HAVE_THREADSAFE */ +#else /* H5_HAVE_THREADSAFE */ *is_ts = FALSE; #endif /* H5_HAVE_THREADSAFE */ FUNC_LEAVE_API_NOINIT(SUCCEED) } /* end H5is_library_threadsafe() */ - -#if defined(H5_HAVE_THREADSAFE) && defined(H5_BUILT_AS_DYNAMIC_LIB) \ - && defined(H5_HAVE_WIN32_API) && defined(H5_HAVE_WIN_THREADS) +#if defined(H5_HAVE_THREADSAFE) && defined(H5_BUILT_AS_DYNAMIC_LIB) && defined(H5_HAVE_WIN32_API) && \ + defined(H5_HAVE_WIN_THREADS) /*------------------------------------------------------------------------- * Function: DllMain * @@ -1135,35 +1119,33 @@ DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved) BOOL fOkay = TRUE; - switch(fdwReason) - { - case DLL_PROCESS_ATTACH: - break; + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + break; - case DLL_PROCESS_DETACH: - break; + case DLL_PROCESS_DETACH: + break; - case DLL_THREAD_ATTACH: + case DLL_THREAD_ATTACH: #ifdef H5_HAVE_WIN_THREADS - if(H5TS_win32_thread_enter() < 0) - fOkay = FALSE; + if (H5TS_win32_thread_enter() < 0) + fOkay = FALSE; #endif /* H5_HAVE_WIN_THREADS */ - break; + break; - case DLL_THREAD_DETACH: + case DLL_THREAD_DETACH: #ifdef H5_HAVE_WIN_THREADS - if(H5TS_win32_thread_exit() < 0) - fOkay = FALSE; + if (H5TS_win32_thread_exit() < 0) + fOkay = FALSE; #endif /* H5_HAVE_WIN_THREADS */ - break; + break; - default: - /* Shouldn't get here */ - fOkay = FALSE; - break; + default: + /* Shouldn't get here */ + fOkay = FALSE; + break; } return fOkay; } #endif /* H5_HAVE_WIN32_API && H5_BUILT_AS_DYNAMIC_LIB && H5_HAVE_WIN_THREADS && H5_HAVE_THREADSAFE*/ - diff --git a/src/H5A.c b/src/H5A.c index 2986466..1952022 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -15,30 +15,27 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5O_FRIEND /* Suppress error about including H5Opkg */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /* Suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspace functions */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspace functions */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -47,20 +44,17 @@ /* Data structure for callback for locating the index by name */ typedef struct H5A_iter_cb1 { const char *name; - int idx; + int idx; } H5A_iter_cb1; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -68,12 +62,10 @@ typedef struct H5A_iter_cb1 { /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -89,17 +81,15 @@ H5FL_BLK_DEFINE(attr_buf); /* Attribute ID class */ static const H5I_class_t H5I_ATTR_CLS[1] = {{ - H5I_ATTR, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5A__close_cb /* Callback routine for closing objects of this class */ + H5I_ATTR, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5A__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ static hbool_t H5A_top_package_initialize_s = FALSE; - - /*------------------------------------------------------------------------- * Function: H5A_init * @@ -113,7 +103,7 @@ static hbool_t H5A_top_package_initialize_s = FALSE; herr_t H5A_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -122,7 +112,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_init() */ - /*-------------------------------------------------------------------------- NAME H5A__init_package -- Initialize interface-specific information @@ -138,14 +127,14 @@ DESCRIPTION herr_t H5A__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* * Create attribute ID type. */ - if(H5I_register_type(H5I_ATTR_CLS) < 0) + if (H5I_register_type(H5I_ATTR_CLS) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Mark "top" of interface as initialized, too */ @@ -155,7 +144,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__init_package() */ - /*-------------------------------------------------------------------------- NAME H5A_top_term_package @@ -176,25 +164,24 @@ done: int H5A_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5A_top_package_initialize_s) { - if(H5I_nmembers(H5I_ATTR) > 0) { - (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); + if (H5A_top_package_initialize_s) { + if (H5I_nmembers(H5I_ATTR) > 0) { + (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark closed */ - if(0 == n) + if (0 == n) H5A_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5A_top_term_package() */ - /*-------------------------------------------------------------------------- NAME H5A_term_package @@ -217,11 +204,11 @@ H5A_top_term_package(void) int H5A_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_ATTR)); HDassert(FALSE == H5A_top_package_initialize_s); @@ -230,14 +217,13 @@ H5A_term_package(void) n += (H5I_dec_type_ref(H5I_ATTR) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5A_term_package() */ - /*-------------------------------------------------------------------------- * Function: H5Acreate2 * @@ -272,35 +258,34 @@ H5A_term_package(void) *------------------------------------------------------------------------- */ hid_t -H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, - hid_t acpl_id, hid_t aapl_id) +H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id) { - void *attr = NULL; /* Attribute created */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * attr = NULL; /* Attribute created */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "i*siiii", loc_id, attr_name, type_id, space_id, acpl_id, aapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(!attr_name) + if (!attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "attr_name parameter cannot be NULL") - if(!*attr_name) + if (!*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "attr_name parameter cannot be an empty string") /* Get correct property list */ - if(H5P_DEFAULT == acpl_id) + if (H5P_DEFAULT == acpl_id) acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ @@ -308,23 +293,23 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, loc_params.obj_type = H5I_get_type(loc_id); /* Create the attribute */ - if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, type_id, space_id, acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, type_id, space_id, acpl_id, aapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Acreate2() */ - /*-------------------------------------------------------------------------- NAME H5Acreate_by_name @@ -356,35 +341,34 @@ done: --------------------------------------------------------------------------*/ hid_t -H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, - hid_t lapl_id) +H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, hid_t space_id, + hid_t acpl_id, hid_t aapl_id, hid_t lapl_id) { - void *attr = NULL; /* attr object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * attr = NULL; /* attr object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE8("i", "i*s*siiiii", loc_id, obj_name, attr_name, type_id, space_id, acpl_id, aapl_id, lapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no attribute name") /* Get correct property list */ - if(H5P_DEFAULT == acpl_id) + if (H5P_DEFAULT == acpl_id) acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set attribute access property list info") - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set link access property list info") /* Set up location struct */ @@ -394,27 +378,27 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the attribute */ - if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, type_id, space_id, acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, type_id, space_id, acpl_id, aapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Acreate_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Aopen @@ -437,52 +421,52 @@ done: hid_t H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { - void *attr = NULL; /* attr object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + void * attr = NULL; /* attr object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, attr_name, aapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(!attr_name) + if (!attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*attr_name) + if (!*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", attr_name) /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen() */ - /*-------------------------------------------------------------------------- NAME H5Aopen_by_name @@ -505,29 +489,28 @@ done: H5Aclose or resource leaks will develop. --------------------------------------------------------------------------*/ hid_t -H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t aapl_id, hid_t lapl_id) +H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t aapl_id, hid_t lapl_id) { - void *attr = NULL; /* attr object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + void * attr = NULL; /* attr object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*s*sii", loc_id, obj_name, attr_name, aapl_id, lapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no attribute name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set attribute access property list info") - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set link access property list info") /* Fill in location struct fields */ @@ -541,23 +524,23 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "can't open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* end H5Aopen_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Aopen_by_idx @@ -583,32 +566,32 @@ done: H5Aclose or resource leaks will develop. --------------------------------------------------------------------------*/ hid_t -H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, hid_t aapl_id, hid_t lapl_id) +H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + hid_t aapl_id, hid_t lapl_id) { - void *attr = NULL; /* Attribute opened */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + void * attr = NULL; /* Attribute opened */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE7("i", "i*sIiIohii", loc_id, obj_name, idx_type, order, n, aapl_id, lapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set attribute access property list info") - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set link access property list info") /* Fill in location struct parameters */ @@ -621,27 +604,27 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, NULL, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, NULL, aapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen_by_idx() */ - /*-------------------------------------------------------------------------- NAME H5Awrite @@ -661,33 +644,32 @@ done: herr_t H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) { - H5VL_object_t *vol_obj; /* Attribute object for ID */ - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* Attribute object for ID */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(H5I_DATATYPE != H5I_get_type(dtype_id)) + if (H5I_DATATYPE != H5I_get_type(dtype_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == buf) + if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf parameter can't be NULL") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(attr_id) < 0) + if (H5CX_set_loc(attr_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Write the attribute data */ - if((ret_value = H5VL_attr_write(vol_obj, dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_attr_write(vol_obj, dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Awrite() */ - /*-------------------------------------------------------------------------- NAME H5Aread @@ -707,29 +689,28 @@ done: herr_t H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) { - H5VL_object_t *vol_obj; /* Attribute object for ID */ - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* Attribute object for ID */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(H5I_DATATYPE != H5I_get_type(dtype_id)) + if (H5I_DATATYPE != H5I_get_type(dtype_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == buf) + if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf parameter can't be NULL") /* Read the attribute data */ - if((ret_value = H5VL_attr_read(vol_obj, dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_attr_read(vol_obj, dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aread() */ - /*-------------------------------------------------------------------------- NAME H5Aget_space @@ -749,25 +730,25 @@ done: hid_t H5Aget_space(hid_t attr_id) { - H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the dataspace */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < + 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace of attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aget_space() */ - /*-------------------------------------------------------------------------- NAME H5Aget_type @@ -787,25 +768,24 @@ done: hid_t H5Aget_type(hid_t attr_id) { - H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the datatype */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype of attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aget_type() */ - /*-------------------------------------------------------------------------- NAME H5Aget_create_plist @@ -828,8 +808,8 @@ done: hid_t H5Aget_create_plist(hid_t attr_id) { - H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); @@ -837,18 +817,18 @@ H5Aget_create_plist(hid_t attr_id) HDassert(H5P_LST_ATTRIBUTE_CREATE_ID_g != -1); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the acpl */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_ACPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get creation property list for attribute") + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_ACPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, + "unable to get creation property list for attribute") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_create_plist() */ - /*-------------------------------------------------------------------------- NAME H5Aget_name @@ -873,32 +853,32 @@ done: ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) { - H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ - H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; + H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_loc_params_t loc_params; + ssize_t ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE3("Zs", "iz*s", attr_id, buf_size, buf); /* check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an attribute") - if(!buf && buf_size) + if (!buf && buf_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "buf cannot be NULL if buf_size is non-zero") /* Set location struct parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(attr_id); /* Get the attribute name */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, buf_size, buf, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + buf_size, buf, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute name") done: FUNC_LEAVE_API(ret_value) } /* H5Aget_name() */ - /*------------------------------------------------------------------------- * Function: H5Aget_name_by_idx * @@ -917,55 +897,54 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, - hid_t lapl_id) +H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + char *name /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; - ssize_t ret_value; /* Return value */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("Zs", "i*sIiIohxzi", loc_id, obj_name, idx_type, order, n, name, size, lapl_id); /* Check args */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(!name && size) + if (!name && size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name cannot be NULL if size is non-zero") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the name */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, size, name, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + size, name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get name") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Aget_storage_size * @@ -987,24 +966,24 @@ hsize_t H5Aget_storage_size(hid_t attr_id) { H5VL_object_t *vol_obj; - hsize_t ret_value; /* Return value */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", attr_id); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") /* Get the storage size */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, 0, "unable to get acpl") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_storage_size() */ - /*------------------------------------------------------------------------- * Function: H5Aget_info * @@ -1021,31 +1000,31 @@ done: herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", attr_id, ainfo); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(!ainfo) + if (!ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "attribute_info parameter cannot be NULL") - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(attr_id); /* Get the attribute information */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, ainfo) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_info() */ - /*------------------------------------------------------------------------- * Function: H5Aget_info_by_name * @@ -1060,48 +1039,48 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - H5A_info_t *ainfo, hid_t lapl_id) +H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo, + hid_t lapl_id) { - H5VL_object_t *vol_obj; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*s*xi", loc_id, obj_name, attr_name, ainfo, lapl_id); /* Check args */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - if(NULL == ainfo) + if (NULL == ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid info pointer") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Get the object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the attribute information */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, ainfo, attr_name) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + ainfo, attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Aget_info_by_idx * @@ -1117,31 +1096,31 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5A_info_t *ainfo, hid_t lapl_id) +H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5A_info_t *ainfo, hid_t lapl_id) { - H5VL_object_t *vol_obj; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIoh*xi", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id); /* Check args */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(NULL == ainfo) + if (NULL == ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid info pointer") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") loc_params.type = H5VL_OBJECT_BY_IDX; @@ -1153,18 +1132,18 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Get the object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the attribute information */ - if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, ainfo) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Arename * @@ -1180,41 +1159,42 @@ done: herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", loc_id, old_name, new_name); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!old_name) + if (!old_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "old attribute name cannot be NULL") - if(!*old_name) + if (!*old_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "old attribute name cannot be an empty string") - if(!new_name) + if (!new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new attribute name cannot be NULL") - if(!*new_name) + if (!*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new attribute name cannot be an empty string") /* Avoid thrashing things if the names are the same */ - if(HDstrcmp(old_name, new_name)) { - H5VL_object_t *vol_obj; + if (HDstrcmp(old_name, new_name)) { + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Rename the attribute */ - if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, old_name, new_name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ @@ -1222,7 +1202,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Arename() */ - /*------------------------------------------------------------------------- * Function: H5Arename_by_name * @@ -1236,45 +1215,46 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, - const char *new_attr_name, hid_t lapl_id) +H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, const char *new_attr_name, + hid_t lapl_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*s*si", loc_id, obj_name, old_attr_name, new_attr_name, lapl_id); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!old_attr_name || !*old_attr_name) + if (!old_attr_name || !*old_attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no old attribute name") - if(!new_attr_name || !*new_attr_name) + if (!new_attr_name || !*new_attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new attribute name") /* Avoid thrashing things if the names are the same */ - if(HDstrcmp(old_attr_name, new_attr_name)) { - H5VL_object_t *vol_obj; + if (HDstrcmp(old_attr_name, new_attr_name)) { + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Rename the attribute */ - if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, old_attr_name, new_attr_name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, old_attr_name, new_attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ @@ -1282,7 +1262,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Arename_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Aiterate2 @@ -1325,40 +1304,40 @@ done: attribute. --------------------------------------------------------------------------*/ herr_t -H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx, H5A_operator2_t op, void *op_data) +H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, + void *op_data) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIo*hx*x", loc_id, idx_type, order, idx, op, op_data); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); /* get the loc object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over attributes */ - if((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) + if ((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: FUNC_LEAVE_API(ret_value) } /* H5Aiterate2() */ - /*-------------------------------------------------------------------------- NAME H5Aiterate_by_name @@ -1403,50 +1382,49 @@ done: attribute. --------------------------------------------------------------------------*/ herr_t -H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, - hid_t lapl_id) +H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx, H5A_operator2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, obj_name, idx_type, order, idx, op, op_data, lapl_id); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.obj_type = H5I_get_type(loc_id); - loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = obj_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* get the loc object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over attributes */ - if((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) + if ((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); done: FUNC_LEAVE_API(ret_value) } /* H5Aiterate_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Adelete @@ -1464,42 +1442,42 @@ done: herr_t H5Adelete(hid_t loc_id, const char *name) { - H5VL_object_t *vol_obj = NULL; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Delete the attribute */ - if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Adelete() */ - /*-------------------------------------------------------------------------- NAME H5Adelete_by_name @@ -1517,26 +1495,25 @@ done: This function removes the named attribute from an object. --------------------------------------------------------------------------*/ herr_t -H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t lapl_id) +H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, obj_name, attr_name, lapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill in location struct fields */ @@ -1546,18 +1523,18 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, loc_params.obj_type = H5I_get_type(loc_id); /* Get the object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Delete the attribute */ - if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Adelete_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Adelete_by_idx @@ -1583,51 +1560,51 @@ done: object to operate on. --------------------------------------------------------------------------*/ herr_t -H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, hid_t lapl_id) +H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + hid_t lapl_id) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*sIiIohi", loc_id, obj_name, idx_type, order, n, lapl_id); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* get the object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Delete the attribute through the VOL */ - if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, NULL) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Adelete_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Aclose * @@ -1642,24 +1619,23 @@ done: herr_t H5Aclose(hid_t attr_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", attr_id); /* Check arguments */ - if(NULL == H5I_object_verify(attr_id, H5I_ATTR)) + if (NULL == H5I_object_verify(attr_id, H5I_ATTR)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Decrement references to that atom (and close it) */ - if(H5I_dec_app_ref(attr_id) < 0) + if (H5I_dec_app_ref(attr_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aclose() */ - /*------------------------------------------------------------------------- * Function: H5Aexists * @@ -1677,35 +1653,35 @@ done: htri_t H5Aexists(hid_t obj_id, const char *attr_name) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; - htri_t ret_value; /* Return value */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "i*s", obj_id, attr_name); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(obj_id)) + if (H5I_ATTR == H5I_get_type(obj_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") /* get the object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(obj_id); /* Check if the attribute exists */ - if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name, &ret_value) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: FUNC_LEAVE_API(ret_value) } /* H5Aexists() */ - /*------------------------------------------------------------------------- * Function: H5Aexists_by_name * @@ -1720,42 +1696,41 @@ done: *------------------------------------------------------------------------- */ htri_t -H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t lapl_id) +H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; - htri_t ret_value; /* Return value */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("t", "i*s*si", loc_id, obj_name, attr_name, lapl_id); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* get the object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Check existence of attribute */ - if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name, &ret_value) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: FUNC_LEAVE_API(ret_value) } /* H5Aexists_by_name() */ - diff --git a/src/H5AC.c b/src/H5AC.c index 9402634..36d6d0a 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -29,50 +29,44 @@ /* Module Setup */ /****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ -#define H5C_FRIEND /* Suppress error about including H5Cpkg */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ - +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5C_FRIEND /* Suppress error about including H5Cpkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Clog.h" /* Cache logging */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5AC__check_if_write_permitted(const H5F_t *f, - hbool_t *write_permitted_ptr); +static herr_t H5AC__check_if_write_permitted(const H5F_t *f, hbool_t *write_permitted_ptr); static herr_t H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, - H5C_auto_size_ctl_t *int_conf_ptr); + H5C_auto_size_ctl_t *int_conf_ptr); #if H5AC_DO_TAGGING_SANITY_CHECKS -static herr_t H5AC__verify_tag(const H5AC_class_t * type); +static herr_t H5AC__verify_tag(const H5AC_class_t *type); #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ - /*********************/ /* Package Variables */ /*********************/ @@ -89,7 +83,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; hbool_t H5_coll_api_sanity_check_g = false; #endif /* H5_HAVE_PARALLEL */ - /*******************/ /* Local Variables */ /*******************/ @@ -101,42 +94,40 @@ hbool_t H5_coll_api_sanity_check_g = false; */ static const H5AC_class_t *const H5AC_class_s[] = { - H5AC_BT, /* ( 0) B-tree nodes */ - H5AC_SNODE, /* ( 1) symbol table nodes */ - H5AC_LHEAP_PRFX, /* ( 2) local heap prefix */ - H5AC_LHEAP_DBLK, /* ( 3) local heap data block */ - H5AC_GHEAP, /* ( 4) global heap */ - H5AC_OHDR, /* ( 5) object header */ - H5AC_OHDR_CHK, /* ( 6) object header chunk */ - H5AC_BT2_HDR, /* ( 7) v2 B-tree header */ - H5AC_BT2_INT, /* ( 8) v2 B-tree internal node */ - H5AC_BT2_LEAF, /* ( 9) v2 B-tree leaf node */ - H5AC_FHEAP_HDR, /* (10) fractal heap header */ - H5AC_FHEAP_DBLOCK, /* (11) fractal heap direct block */ - H5AC_FHEAP_IBLOCK, /* (12) fractal heap indirect block */ - H5AC_FSPACE_HDR, /* (13) free space header */ - H5AC_FSPACE_SINFO, /* (14) free space sections */ - H5AC_SOHM_TABLE, /* (15) shared object header message */ - /* master table */ - H5AC_SOHM_LIST, /* (16) shared message index stored as */ - /* a list */ - H5AC_EARRAY_HDR, /* (17) extensible array header */ - H5AC_EARRAY_IBLOCK, /* (18) extensible array index block */ - H5AC_EARRAY_SBLOCK, /* (19) extensible array super block */ - H5AC_EARRAY_DBLOCK, /* (20) extensible array data block */ - H5AC_EARRAY_DBLK_PAGE, /* (21) extensible array data block page */ - H5AC_FARRAY_HDR, /* (22) fixed array header */ - H5AC_FARRAY_DBLOCK, /* (23) fixed array data block */ - H5AC_FARRAY_DBLK_PAGE, /* (24) fixed array data block page */ - H5AC_SUPERBLOCK, /* (25) file superblock */ - H5AC_DRVRINFO, /* (26) driver info block (supplements superblock) */ - H5AC_EPOCH_MARKER, /* (27) epoch marker - always internal to cache */ - H5AC_PROXY_ENTRY, /* (28) cache entry proxy */ - H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ + H5AC_BT, /* ( 0) B-tree nodes */ + H5AC_SNODE, /* ( 1) symbol table nodes */ + H5AC_LHEAP_PRFX, /* ( 2) local heap prefix */ + H5AC_LHEAP_DBLK, /* ( 3) local heap data block */ + H5AC_GHEAP, /* ( 4) global heap */ + H5AC_OHDR, /* ( 5) object header */ + H5AC_OHDR_CHK, /* ( 6) object header chunk */ + H5AC_BT2_HDR, /* ( 7) v2 B-tree header */ + H5AC_BT2_INT, /* ( 8) v2 B-tree internal node */ + H5AC_BT2_LEAF, /* ( 9) v2 B-tree leaf node */ + H5AC_FHEAP_HDR, /* (10) fractal heap header */ + H5AC_FHEAP_DBLOCK, /* (11) fractal heap direct block */ + H5AC_FHEAP_IBLOCK, /* (12) fractal heap indirect block */ + H5AC_FSPACE_HDR, /* (13) free space header */ + H5AC_FSPACE_SINFO, /* (14) free space sections */ + H5AC_SOHM_TABLE, /* (15) shared object header message */ + /* master table */ + H5AC_SOHM_LIST, /* (16) shared message index stored as */ + /* a list */ + H5AC_EARRAY_HDR, /* (17) extensible array header */ + H5AC_EARRAY_IBLOCK, /* (18) extensible array index block */ + H5AC_EARRAY_SBLOCK, /* (19) extensible array super block */ + H5AC_EARRAY_DBLOCK, /* (20) extensible array data block */ + H5AC_EARRAY_DBLK_PAGE, /* (21) extensible array data block page */ + H5AC_FARRAY_HDR, /* (22) fixed array header */ + H5AC_FARRAY_DBLOCK, /* (23) fixed array data block */ + H5AC_FARRAY_DBLK_PAGE, /* (24) fixed array data block page */ + H5AC_SUPERBLOCK, /* (25) file superblock */ + H5AC_DRVRINFO, /* (26) driver info block (supplements superblock) */ + H5AC_EPOCH_MARKER, /* (27) epoch marker - always internal to cache */ + H5AC_PROXY_ENTRY, /* (28) cache entry proxy */ + H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ }; - - /*------------------------------------------------------------------------- * Function: H5AC_init * @@ -153,7 +144,7 @@ static const H5AC_class_t *const H5AC_class_s[] = { herr_t H5AC_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -162,7 +153,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_init() */ - /*------------------------------------------------------------------------- * Function H5AC__init_package * @@ -185,11 +175,11 @@ H5AC__init_package(void) * sanity checks using MPI barriers */ { - const char *s; /* String for environment variables */ + const char *s; /* String for environment variables */ s = HDgetenv("H5_COLL_API_SANITY_CHECK"); - if(s && HDisdigit(*s)) { - long env_val = HDstrtol(s, NULL, 0); + if (s && HDisdigit(*s)) { + long env_val = HDstrtol(s, NULL, 0); H5_coll_api_sanity_check_g = (0 == env_val) ? FALSE : TRUE; } } @@ -198,7 +188,6 @@ H5AC__init_package(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5AC__init_package() */ - /*------------------------------------------------------------------------- * Function: H5AC_term_package * @@ -218,14 +207,13 @@ H5AC_term_package(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) + if (H5_PKG_INIT_VAR) /* Reset interface initialization flag */ H5_PKG_INIT_VAR = FALSE; FUNC_LEAVE_NOAPI(0) } /* end H5AC_term_package() */ - /*------------------------------------------------------------------------- * * Function: H5AC_cache_image_pending() @@ -248,8 +236,8 @@ H5AC_term_package(void) hbool_t H5AC_cache_image_pending(const H5F_t *f) { - H5C_t *cache_ptr; - hbool_t ret_value = FALSE; /* Return value */ + H5C_t * cache_ptr; + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -263,7 +251,6 @@ H5AC_cache_image_pending(const H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_cache_image_pending() */ - /*------------------------------------------------------------------------- * Function: H5AC_create * @@ -288,81 +275,81 @@ H5AC_cache_image_pending(const H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_config_t * image_config_ptr) +H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_config_t *image_config_ptr) { #ifdef H5_HAVE_PARALLEL - char prefix[H5C__PREFIX_LEN] = ""; - H5AC_aux_t * aux_ptr = NULL; + char prefix[H5C__PREFIX_LEN] = ""; + H5AC_aux_t *aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ struct H5C_cache_image_ctl_t int_ci_config = H5C__DEFAULT_CACHE_IMAGE_CTL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ HDassert(f); HDassert(NULL == f->shared->cache); - HDassert(config_ptr != NULL) ; - HDassert(image_config_ptr != NULL) ; + HDassert(config_ptr != NULL); + HDassert(image_config_ptr != NULL); HDassert(image_config_ptr->version == H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION); HDcompile_assert(NELMTS(H5AC_class_s) == H5AC_NTYPES); HDcompile_assert(H5C__MAX_NUM_TYPE_IDS == H5AC_NTYPES); /* Validate configurations */ - if(H5AC_validate_config(config_ptr) < 0) + if (H5AC_validate_config(config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache configuration") - if(H5AC_validate_cache_image_config(image_config_ptr) < 0) + if (H5AC_validate_cache_image_config(image_config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache image configuration") #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - MPI_Comm mpi_comm; - int mpi_rank; - int mpi_size; + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + MPI_Comm mpi_comm; + int mpi_rank; + int mpi_size; - if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI communicator") - if((mpi_rank = H5F_mpi_get_rank(f)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get mpi rank") - if((mpi_size = H5F_mpi_get_size(f)) < 0) + if ((mpi_size = H5F_mpi_get_size(f)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get mpi size") - if(NULL == (aux_ptr = H5FL_CALLOC(H5AC_aux_t))) + if (NULL == (aux_ptr = H5FL_CALLOC(H5AC_aux_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate H5AC auxiliary structure") - aux_ptr->magic = H5AC__H5AC_AUX_T_MAGIC; - aux_ptr->mpi_comm = mpi_comm; - aux_ptr->mpi_rank = mpi_rank; - aux_ptr->mpi_size = mpi_size; - aux_ptr->write_permitted = FALSE; - aux_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; - aux_ptr->dirty_bytes = 0; + aux_ptr->magic = H5AC__H5AC_AUX_T_MAGIC; + aux_ptr->mpi_comm = mpi_comm; + aux_ptr->mpi_rank = mpi_rank; + aux_ptr->mpi_size = mpi_size; + aux_ptr->write_permitted = FALSE; + aux_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; + aux_ptr->dirty_bytes = 0; aux_ptr->metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; #if H5AC_DEBUG_DIRTY_BYTES_CREATION - aux_ptr->dirty_bytes_propagations = 0; - aux_ptr->unprotect_dirty_bytes = 0; + aux_ptr->dirty_bytes_propagations = 0; + aux_ptr->unprotect_dirty_bytes = 0; aux_ptr->unprotect_dirty_bytes_updates = 0; - aux_ptr->insert_dirty_bytes = 0; - aux_ptr->insert_dirty_bytes_updates = 0; - aux_ptr->move_dirty_bytes = 0; - aux_ptr->move_dirty_bytes_updates = 0; + aux_ptr->insert_dirty_bytes = 0; + aux_ptr->insert_dirty_bytes_updates = 0; + aux_ptr->move_dirty_bytes = 0; + aux_ptr->move_dirty_bytes_updates = 0; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - aux_ptr->d_slist_ptr = NULL; - aux_ptr->c_slist_ptr = NULL; + aux_ptr->d_slist_ptr = NULL; + aux_ptr->c_slist_ptr = NULL; aux_ptr->candidate_slist_ptr = NULL; - aux_ptr->write_done = NULL; - aux_ptr->sync_point_done = NULL; - aux_ptr->p0_image_len = 0; + aux_ptr->write_done = NULL; + aux_ptr->sync_point_done = NULL; + aux_ptr->p0_image_len = 0; HDsprintf(prefix, "%d:", mpi_rank); - if(mpi_rank == 0) { - if(NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (mpi_rank == 0) { + if (NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create dirtied entry list") - if(NULL == (aux_ptr->c_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (aux_ptr->c_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cleaned entry list") } /* end if */ @@ -370,27 +357,22 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co * when the distributed strategy is selected as all processes * will use it in the case of a flush. */ - if(NULL == (aux_ptr->candidate_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (aux_ptr->candidate_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create candidate entry list") - if(aux_ptr != NULL) - if(aux_ptr->mpi_rank == 0) - f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), - H5AC_class_s, - H5AC__check_if_write_permitted, TRUE, H5AC__log_flushed_entry, - (void *)aux_ptr); + if (aux_ptr != NULL) + if (aux_ptr->mpi_rank == 0) + f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, + (H5AC_NTYPES - 1), H5AC_class_s, H5AC__check_if_write_permitted, + TRUE, H5AC__log_flushed_entry, (void *)aux_ptr); else - f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), - H5AC_class_s, - H5AC__check_if_write_permitted, TRUE, NULL, - (void *)aux_ptr); + f->shared->cache = + H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), + H5AC_class_s, H5AC__check_if_write_permitted, TRUE, NULL, (void *)aux_ptr); else - f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), - H5AC_class_s, - H5AC__check_if_write_permitted, TRUE, NULL, NULL); + f->shared->cache = + H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), + H5AC_class_s, H5AC__check_if_write_permitted, TRUE, NULL, NULL); } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ @@ -398,20 +380,19 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co * overwritten shortly by the subsequent set resize config call. * -- JRM */ - f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), - H5AC_class_s, - H5AC__check_if_write_permitted, TRUE, NULL, NULL); + f->shared->cache = + H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), + H5AC_class_s, H5AC__check_if_write_permitted, TRUE, NULL, NULL); #ifdef H5_HAVE_PARALLEL - } /* end else */ + } /* end else */ #endif /* H5_HAVE_PARALLEL */ - if(NULL == f->shared->cache) + if (NULL == f->shared->cache) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") #ifdef H5_HAVE_PARALLEL - if(aux_ptr != NULL) - if(H5C_set_prefix(f->shared->cache, prefix) < 0) + if (aux_ptr != NULL) + if (H5C_set_prefix(f->shared->cache, prefix) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "H5C_set_prefix() failed") #endif /* H5_HAVE_PARALLEL */ @@ -419,29 +400,26 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co * This will be JSON until we create a special API call. Trace output * is generated when logging is controlled by the struct. */ - if(H5F_USE_MDC_LOGGING(f)) - if(H5C_log_set_up(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5C_LOG_STYLE_JSON, H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) + if (H5F_USE_MDC_LOGGING(f)) + if (H5C_log_set_up(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5C_LOG_STYLE_JSON, + H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging setup failed") - /* Configure the metadata cache for VFD SWMR reader operation if + /* Configure the metadata cache for VFD SWMR reader operation if * specified. */ - if ( ( H5F_VFD_SWMR_CONFIG(f) ) && - ( !f->shared->vfd_swmr_config.writer ) ) { + if ((H5F_VFD_SWMR_CONFIG(f)) && (!f->shared->vfd_swmr_config.writer)) { HDassert(!(H5F_INTENT(f) & H5F_ACC_RDWR)); HDassert(f->shared->fs_page_size > 0); - if ( H5C_set_vfd_swmr_reader(f->shared->cache, TRUE, - f->shared->fs_page_size) < 0 ) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, \ - "can't configure MDC for VFD SWMR reader operations"); + if (H5C_set_vfd_swmr_reader(f->shared->cache, TRUE, f->shared->fs_page_size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't configure MDC for VFD SWMR reader operations"); } /* Set the cache parameters */ - if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + if (H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "auto resize configuration failed") /* Don't need to get the current H5C image config here since the @@ -454,35 +432,34 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co int_ci_config.generate_image = image_config_ptr->generate_image; int_ci_config.save_resize_status = image_config_ptr->save_resize_status; int_ci_config.entry_ageout = image_config_ptr->entry_ageout; - if(H5C_set_cache_image_config(f, f->shared->cache, &int_ci_config) < 0) + if (H5C_set_cache_image_config(f, f->shared->cache, &int_ci_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "auto resize configuration failed") done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_create_cache_msg(f->shared->cache, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_create_cache_msg(f->shared->cache, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") #ifdef H5_HAVE_PARALLEL /* if there is a failure, try to tidy up the auxiliary structure */ - if(ret_value < 0) { - if(aux_ptr != NULL) { - if(aux_ptr->d_slist_ptr != NULL) + if (ret_value < 0) { + if (aux_ptr != NULL) { + if (aux_ptr->d_slist_ptr != NULL) H5SL_close(aux_ptr->d_slist_ptr); - if(aux_ptr->c_slist_ptr != NULL) + if (aux_ptr->c_slist_ptr != NULL) H5SL_close(aux_ptr->c_slist_ptr); - if(aux_ptr->candidate_slist_ptr != NULL) + if (aux_ptr->candidate_slist_ptr != NULL) H5SL_close(aux_ptr->candidate_slist_ptr); aux_ptr->magic = 0; - aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); + aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_create() */ - /*------------------------------------------------------------------------- * Function: H5AC_dest * @@ -501,12 +478,12 @@ done: herr_t H5AC_dest(H5F_t *f) { - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ + hbool_t log_enabled; /* TRUE if logging was set up */ + hbool_t curr_logging; /* TRUE if currently logging */ #ifdef H5_HAVE_PARALLEL - H5AC_aux_t * aux_ptr = NULL; -#endif /* H5_HAVE_PARALLEL */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr = NULL; +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -521,23 +498,23 @@ H5AC_dest(H5F_t *f) #endif /* H5AC_DUMP_STATS_ON_CLOSE */ /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) + if (H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to get logging status") - if(log_enabled && curr_logging) - if(H5C_log_write_destroy_cache_msg(f->shared->cache) < 0) + if (log_enabled && curr_logging) + if (H5C_log_write_destroy_cache_msg(f->shared->cache) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") /* Tear down logging */ - if(log_enabled) - if(H5C_log_tear_down(f->shared->cache) < 0) + if (log_enabled) + if (H5C_log_tear_down(f->shared->cache) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") #ifdef H5_HAVE_PARALLEL /* destroying the cache, so clear all collective entries */ - if(H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) + if (H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed") aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); - if(aux_ptr) + if (aux_ptr) /* Sanity check */ HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -547,40 +524,39 @@ H5AC_dest(H5F_t *f) * Must not flush in the R/O case, as this will trigger the * free space manager settle routines. */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) - if(H5AC__flush_entries(f) < 0) + if (H5F_ACC_RDWR & H5F_INTENT(f)) + if (H5AC__flush_entries(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush") #endif /* H5_HAVE_PARALLEL */ /* Destroy the cache */ - if(H5C_dest(f) < 0) + if (H5C_dest(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't destroy cache") f->shared->cache = NULL; #ifdef H5_HAVE_PARALLEL - if(aux_ptr != NULL) { - if(aux_ptr->d_slist_ptr != NULL) { + if (aux_ptr != NULL) { + if (aux_ptr->d_slist_ptr != NULL) { HDassert(H5SL_count(aux_ptr->d_slist_ptr) == 0); H5SL_close(aux_ptr->d_slist_ptr); } /* end if */ - if(aux_ptr->c_slist_ptr != NULL) { + if (aux_ptr->c_slist_ptr != NULL) { HDassert(H5SL_count(aux_ptr->c_slist_ptr) == 0); H5SL_close(aux_ptr->c_slist_ptr); } /* end if */ - if(aux_ptr->candidate_slist_ptr != NULL) { + if (aux_ptr->candidate_slist_ptr != NULL) { HDassert(H5SL_count(aux_ptr->candidate_slist_ptr) == 0); H5SL_close(aux_ptr->candidate_slist_ptr); } /* end if */ aux_ptr->magic = 0; - aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); - } /* end if */ + aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); + } /* end if */ #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_dest() */ - /*------------------------------------------------------------------------- * Function: H5AC_evict * @@ -597,7 +573,7 @@ done: herr_t H5AC_evict(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -607,20 +583,19 @@ H5AC_evict(H5F_t *f) HDassert(f->shared->cache); /* Evict all entries in the cache except the pinned superblock entry */ - if(H5C_evict(f) < 0) + if (H5C_evict(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't evict cache") done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_evict_cache_msg(f->shared->cache, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_evict_cache_msg(f->shared->cache, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_evict() */ - /*------------------------------------------------------------------------- * Function: H5AC_expunge_entry * @@ -636,10 +611,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, - unsigned flags) +H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, unsigned flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -651,19 +625,18 @@ H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, HDassert(type->serialize); HDassert(H5F_addr_defined(addr)); - if(H5C_expunge_entry(f, type, addr, flags) < 0) + if (H5C_expunge_entry(f, type, addr, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "H5C_expunge_entry() failed") done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_expunge_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_flush * @@ -687,7 +660,7 @@ done: herr_t H5AC_flush(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -698,29 +671,28 @@ H5AC_flush(H5F_t *f) #ifdef H5_HAVE_PARALLEL /* flushing the cache, so clear all collective entries */ - if(H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) + if (H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed") /* Attempt to flush all entries from rank 0 & Bcast clean list to other ranks */ - if(H5AC__flush_entries(f) < 0) + if (H5AC__flush_entries(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush") #endif /* H5_HAVE_PARALLEL */ /* Flush the cache */ /* (Again, in parallel - writes out the superblock) */ - if(H5C_flush_cache(f, H5AC__NO_FLAGS_SET) < 0) + if (H5C_flush_cache(f, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_entry_status * @@ -745,41 +717,41 @@ done: herr_t H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status) { - hbool_t in_cache; /* Entry @ addr is in the cache */ - hbool_t is_dirty; /* Entry @ addr is in the cache and dirty */ - hbool_t is_protected; /* Entry @ addr is in the cache and protected */ - hbool_t is_pinned; /* Entry @ addr is in the cache and pinned */ - hbool_t is_corked; - hbool_t is_flush_dep_child; /* Entry @ addr is in the cache and is a flush dependency child */ - hbool_t is_flush_dep_parent; /* Entry @ addr is in the cache and is a flush dependency parent */ - hbool_t image_is_up_to_date; /* Entry @ addr is in the cache and has an up to date image */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t in_cache; /* Entry @ addr is in the cache */ + hbool_t is_dirty; /* Entry @ addr is in the cache and dirty */ + hbool_t is_protected; /* Entry @ addr is in the cache and protected */ + hbool_t is_pinned; /* Entry @ addr is in the cache and pinned */ + hbool_t is_corked; + hbool_t is_flush_dep_child; /* Entry @ addr is in the cache and is a flush dependency child */ + hbool_t is_flush_dep_parent; /* Entry @ addr is in the cache and is a flush dependency parent */ + hbool_t image_is_up_to_date; /* Entry @ addr is in the cache and has an up to date image */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((f == NULL) || (!H5F_addr_defined(addr)) || (status == NULL)) + if ((f == NULL) || (!H5F_addr_defined(addr)) || (status == NULL)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry") - if(H5C_get_entry_status(f, addr, NULL, &in_cache, &is_dirty, - &is_protected, &is_pinned, &is_corked, &is_flush_dep_parent, &is_flush_dep_child, &image_is_up_to_date) < 0) + if (H5C_get_entry_status(f, addr, NULL, &in_cache, &is_dirty, &is_protected, &is_pinned, &is_corked, + &is_flush_dep_parent, &is_flush_dep_child, &image_is_up_to_date) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_entry_status() failed") - if(in_cache) { + if (in_cache) { *status |= H5AC_ES__IN_CACHE; - if(is_dirty) - *status |= H5AC_ES__IS_DIRTY; - if(is_protected) - *status |= H5AC_ES__IS_PROTECTED; - if(is_pinned) - *status |= H5AC_ES__IS_PINNED; - if(is_corked) - *status |= H5AC_ES__IS_CORKED; - if(is_flush_dep_parent) - *status |= H5AC_ES__IS_FLUSH_DEP_PARENT; - if(is_flush_dep_child) - *status |= H5AC_ES__IS_FLUSH_DEP_CHILD; - if(image_is_up_to_date) - *status |= H5AC_ES__IMAGE_IS_UP_TO_DATE; + if (is_dirty) + *status |= H5AC_ES__IS_DIRTY; + if (is_protected) + *status |= H5AC_ES__IS_PROTECTED; + if (is_pinned) + *status |= H5AC_ES__IS_PINNED; + if (is_corked) + *status |= H5AC_ES__IS_CORKED; + if (is_flush_dep_parent) + *status |= H5AC_ES__IS_FLUSH_DEP_PARENT; + if (is_flush_dep_child) + *status |= H5AC_ES__IS_FLUSH_DEP_CHILD; + if (image_is_up_to_date) + *status |= H5AC_ES__IMAGE_IS_UP_TO_DATE; } /* end if */ else *status = 0; @@ -788,7 +760,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_entry_status() */ - /*------------------------------------------------------------------------- * Function: H5AC_insert_entry * @@ -805,10 +776,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, - unsigned int flags) +H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned int flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -822,45 +792,45 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert(thing); /* Check for invalid access request */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") #if H5AC_DO_TAGGING_SANITY_CHECKS - if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) + if (!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Bad tag value") #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ /* Insert entry into metadata cache */ - if(H5C_insert_entry(f, type, addr, thing, flags) < 0) + if (H5C_insert_entry(f, type, addr, thing, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C_insert_entry() failed") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { - /* Log the new entry */ - if(H5AC__log_inserted_entry((H5AC_info_t *)thing) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5AC__log_inserted_entry() failed") + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { + /* Log the new entry */ + if (H5AC__log_inserted_entry((H5AC_info_t *)thing) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5AC__log_inserted_entry() failed") - /* Check if we should try to flush */ - if(aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold) - if(H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point") - } /* end if */ -} + /* Check if we should try to flush */ + if (aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold) + if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point") + } /* end if */ + } #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags, ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags, + ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_insert_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_load_cache_image_on_next_protect * @@ -876,10 +846,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_load_cache_image_on_next_protect(H5F_t * f, haddr_t addr, hsize_t len, - hbool_t rw) +H5AC_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -888,14 +857,13 @@ H5AC_load_cache_image_on_next_protect(H5F_t * f, haddr_t addr, hsize_t len, HDassert(f->shared); HDassert(f->shared->cache); - if(H5C_load_cache_image_on_next_protect(f, addr, len, rw) < 0) + if (H5C_load_cache_image_on_next_protect(f, addr, len, rw) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "call to H5C_load_cache_image_on_next_protect failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_load_cache_image_on_next_protect() */ - /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_dirty * @@ -913,8 +881,8 @@ herr_t H5AC_mark_entry_dirty(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -926,30 +894,29 @@ H5AC_mark_entry_dirty(void *thing) cache_ptr = entry_ptr->cache_ptr; #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && - (entry_ptr->is_pinned) && (NULL != aux_ptr)) - if(H5AC__log_dirtied_entry(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && (entry_ptr->is_pinned) && + (NULL != aux_ptr)) + if (H5AC__log_dirtied_entry(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") + } #endif /* H5_HAVE_PARALLEL */ - if(H5C_mark_entry_dirty(thing) < 0) + if (H5C_mark_entry_dirty(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't mark pinned or protected entry dirty") done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_dirty() */ - /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_clean * @@ -967,8 +934,8 @@ herr_t H5AC_mark_entry_clean(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -979,30 +946,29 @@ H5AC_mark_entry_clean(void *thing) cache_ptr = entry_ptr->cache_ptr; #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && - (entry_ptr->is_pinned) && (NULL != aux_ptr)) - if(H5AC__log_cleaned_entry(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "can't log cleaned entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && (entry_ptr->is_pinned) && + (NULL != aux_ptr)) + if (H5AC__log_cleaned_entry(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "can't log cleaned entry") + } #endif /* H5_HAVE_PARALLEL */ - if(H5C_mark_entry_clean(thing) < 0) + if (H5C_mark_entry_clean(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "can't mark pinned or protected entry clean") done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_clean() */ - /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_unserialized * @@ -1020,8 +986,8 @@ herr_t H5AC_mark_entry_unserialized(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1032,19 +998,18 @@ H5AC_mark_entry_unserialized(void *thing) entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; - if(H5C_mark_entry_unserialized(thing) < 0) + if (H5C_mark_entry_unserialized(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, "can't mark entry unserialized") done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_unserialized() */ - /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_serialized * @@ -1062,8 +1027,8 @@ herr_t H5AC_mark_entry_serialized(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1073,19 +1038,18 @@ H5AC_mark_entry_serialized(void *thing) entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; - if(H5C_mark_entry_serialized(thing) < 0) + if (H5C_mark_entry_serialized(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "can't mark entry serialized") done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_serialized() */ - /*------------------------------------------------------------------------- * Function: H5AC_move_entry * @@ -1104,9 +1068,9 @@ herr_t H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr) { #ifdef H5_HAVE_PARALLEL - H5AC_aux_t *aux_ptr; -#endif /* H5_HAVE_PARALLEL */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr; +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1120,31 +1084,30 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne #ifdef H5_HAVE_PARALLEL /* Log moving the entry */ - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) - if(H5AC__log_moved_entry(f, old_addr, new_addr) < 0) + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) + if (H5AC__log_moved_entry(f, old_addr, new_addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log moved entry") #endif /* H5_HAVE_PARALLEL */ - if(H5C_move_entry(f->shared->cache, type, old_addr, new_addr) < 0) + if (H5C_move_entry(f->shared->cache, type, old_addr, new_addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "H5C_move_entry() failed") #ifdef H5_HAVE_PARALLEL /* Check if we should try to flush */ - if(NULL != aux_ptr && aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold) - if(H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) + if (NULL != aux_ptr && aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold) + if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point") #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_move_entry_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_move_entry_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_move_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_pin_protected_entry() * @@ -1161,9 +1124,9 @@ done: herr_t H5AC_pin_protected_entry(void *thing) { - H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1175,19 +1138,18 @@ H5AC_pin_protected_entry(void *thing) HDassert(cache_ptr); /* Pin entry */ - if(H5C_pin_protected_entry(thing) < 0) + if (H5C_pin_protected_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "can't pin entry") done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_pin_protected_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC_prep_for_file_close @@ -1209,7 +1171,7 @@ done: herr_t H5AC_prep_for_file_close(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1218,14 +1180,13 @@ H5AC_prep_for_file_close(H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - if(H5C_prep_for_file_close(f) < 0) + if (H5C_prep_for_file_close(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "cache prep for file close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_prep_for_file_close() */ - /*------------------------------------------------------------------------- * Function: H5AC_create_flush_dependency() * @@ -1240,11 +1201,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_create_flush_dependency(void * parent_thing, void * child_thing) +H5AC_create_flush_dependency(void *parent_thing, void *child_thing) { - H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1257,19 +1218,19 @@ H5AC_create_flush_dependency(void * parent_thing, void * child_thing) HDassert(cache_ptr); /* Create the flush dependency */ - if(H5C_create_flush_dependency(parent_thing, child_thing) < 0) + if (H5C_create_flush_dependency(parent_thing, child_thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "H5C_create_flush_dependency() failed") done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, + ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_create_flush_dependency() */ - /*------------------------------------------------------------------------- * Function: H5AC_protect * @@ -1295,11 +1256,10 @@ done: *------------------------------------------------------------------------- */ void * -H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, - unsigned flags) +H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, unsigned flags) { - void * thing = NULL; /* Pointer to native data structure for entry */ - void * ret_value = NULL; /* Return value */ + void *thing = NULL; /* Pointer to native data structure for entry */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1315,24 +1275,22 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, * only permitted in the parallel case. */ #ifdef H5_HAVE_PARALLEL - HDassert(0 == (flags & (unsigned)(~(H5C__READ_ONLY_FLAG | \ - H5C__FLUSH_LAST_FLAG | \ - H5C__FLUSH_COLLECTIVELY_FLAG)))); -#else /* H5_HAVE_PARALLEL */ - HDassert(0 == (flags & (unsigned)(~(H5C__READ_ONLY_FLAG | \ - H5C__FLUSH_LAST_FLAG)))); + HDassert(0 == (flags & + (unsigned)(~(H5C__READ_ONLY_FLAG | H5C__FLUSH_LAST_FLAG | H5C__FLUSH_COLLECTIVELY_FLAG)))); +#else /* H5_HAVE_PARALLEL */ + HDassert(0 == (flags & (unsigned)(~(H5C__READ_ONLY_FLAG | H5C__FLUSH_LAST_FLAG)))); #endif /* H5_HAVE_PARALLEL */ /* Check for invalid access request */ - if((0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) && (0 == (flags & H5C__READ_ONLY_FLAG))) + if ((0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) && (0 == (flags & H5C__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "no write intent on file") #if H5AC_DO_TAGGING_SANITY_CHECKS - if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) + if (!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Bad tag value") #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ - if(NULL == (thing = H5C_protect(f, type, addr, udata, flags))) + if (NULL == (thing = H5C_protect(f, type, addr, udata, flags))) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C_protect() failed") /* Set return value */ @@ -1343,15 +1301,15 @@ done: { herr_t fake_ret_value = (NULL == ret_value) ? FAIL : SUCCEED; - if(f->shared->cache->log_info->logging) - if(H5C_log_write_protect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, fake_ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_protect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, + fake_ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, NULL, "unable to emit log message") } FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_protect() */ - /*------------------------------------------------------------------------- * Function: H5AC_resize_entry * @@ -1368,8 +1326,8 @@ herr_t H5AC_resize_entry(void *thing, size_t new_size) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1381,30 +1339,29 @@ H5AC_resize_entry(void *thing, size_t new_size) HDassert(cache_ptr); /* Resize the entry */ - if(H5C_resize_entry(thing, new_size) < 0) + if (H5C_resize_entry(thing, new_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((!entry_ptr->is_dirty) && (NULL != aux_ptr)) - if(H5AC__log_dirtied_entry(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((!entry_ptr->is_dirty) && (NULL != aux_ptr)) + if (H5AC__log_dirtied_entry(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") + } #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_resize_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_unpin_entry() * @@ -1422,8 +1379,8 @@ herr_t H5AC_unpin_entry(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1435,19 +1392,18 @@ H5AC_unpin_entry(void *thing) HDassert(cache_ptr); /* Unpin the entry */ - if(H5C_unpin_entry(thing) < 0) + if (H5C_unpin_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unpin_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_destroy_flush_dependency() * @@ -1461,11 +1417,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) +H5AC_destroy_flush_dependency(void *parent_thing, void *child_thing) { - H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1478,19 +1434,19 @@ H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) HDassert(cache_ptr); /* Destroy the flush dependency */ - if(H5C_destroy_flush_dependency(parent_thing, child_thing) < 0) + if (H5C_destroy_flush_dependency(parent_thing, child_thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "H5C_destroy_flush_dependency() failed") done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, + ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_destroy_flush_dependency() */ - /*------------------------------------------------------------------------- * Function: H5AC_unprotect * @@ -1530,15 +1486,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, - unsigned flags) +H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags) { - hbool_t dirtied; - hbool_t deleted; + hbool_t dirtied; + hbool_t deleted; #ifdef H5_HAVE_PARALLEL - H5AC_aux_t * aux_ptr = NULL; -#endif /* H5_HAVE_PARALLEL */ - herr_t ret_value=SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr = NULL; +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1551,58 +1506,57 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert(type->image_len); HDassert(H5F_addr_defined(addr)); HDassert(thing); - HDassert( ((H5AC_info_t *)thing)->addr == addr ); - HDassert( ((H5AC_info_t *)thing)->type == type ); + HDassert(((H5AC_info_t *)thing)->addr == addr); + HDassert(((H5AC_info_t *)thing)->type == type); - dirtied = (hbool_t)(((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG) || - (((H5AC_info_t *)thing)->dirtied)); + dirtied = + (hbool_t)(((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG) || (((H5AC_info_t *)thing)->dirtied)); deleted = (hbool_t)((flags & H5C__DELETED_FLAG) == H5C__DELETED_FLAG); /* Check if the size changed out from underneath us, if we're not deleting * the entry. */ - if(dirtied && !deleted) { - size_t curr_size = 0; + if (dirtied && !deleted) { + size_t curr_size = 0; - if((type->image_len)(thing, &curr_size) < 0) + if ((type->image_len)(thing, &curr_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGETSIZE, FAIL, "Can't get size of thing") - if(((H5AC_info_t *)thing)->size != curr_size) + if (((H5AC_info_t *)thing)->size != curr_size) HGOTO_ERROR(H5E_CACHE, H5E_BADSIZE, FAIL, "size of entry changed") } /* end if */ #ifdef H5_HAVE_PARALLEL - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { - if(dirtied && ((H5AC_info_t *)thing)->is_dirty == FALSE) - if(H5AC__log_dirtied_entry((H5AC_info_t *)thing) < 0) + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { + if (dirtied && ((H5AC_info_t *)thing)->is_dirty == FALSE) + if (H5AC__log_dirtied_entry((H5AC_info_t *)thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log dirtied entry") - if(deleted && aux_ptr->mpi_rank == 0) - if(H5AC__log_deleted_entry((H5AC_info_t *)thing) < 0) + if (deleted && aux_ptr->mpi_rank == 0) + if (H5AC__log_deleted_entry((H5AC_info_t *)thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5AC__log_deleted_entry() failed") - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ - if(H5C_unprotect(f, addr, thing, flags) < 0) + if (H5C_unprotect(f, addr, thing, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5C_unprotect() failed") #ifdef H5_HAVE_PARALLEL /* Check if we should try to flush */ - if((aux_ptr != NULL) && (aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold)) - if(H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) + if ((aux_ptr != NULL) && (aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold)) + if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point") #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_unprotect_entry_msg(f->shared->cache, addr, type->id, flags, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_unprotect_entry_msg(f->shared->cache, addr, type->id, flags, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_cache_auto_resize_config * @@ -1616,40 +1570,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, - H5AC_cache_config_t *config_ptr) +H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; - hbool_t evictions_enabled; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t evictions_enabled; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if((cache_ptr == NULL) || (config_ptr == NULL) || - (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) + if ((cache_ptr == NULL) || (config_ptr == NULL) || + (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr or config_ptr on entry") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr on entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr on entry") + } #endif /* H5_HAVE_PARALLEL */ /* Retrieve the configuration */ - if(H5C_get_cache_auto_resize_config((const H5C_t *)cache_ptr, &internal_config) < 0) + if (H5C_get_cache_auto_resize_config((const H5C_t *)cache_ptr, &internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_auto_resize_config() failed") - if(H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) + if (H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_resize_enabled() failed") /* Set the information to return */ - if(internal_config.rpt_fcn == NULL) + if (internal_config.rpt_fcn == NULL) config_ptr->rpt_fcn_enabled = FALSE; else - config_ptr->rpt_fcn_enabled = TRUE; + config_ptr->rpt_fcn_enabled = TRUE; config_ptr->open_trace_file = FALSE; config_ptr->close_trace_file = FALSE; config_ptr->trace_file_name[0] = '\0'; @@ -1677,27 +1630,26 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, config_ptr->apply_empty_reserve = internal_config.apply_empty_reserve; config_ptr->empty_reserve = internal_config.empty_reserve; #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { - config_ptr->dirty_bytes_threshold = aux_ptr->dirty_bytes_threshold; - config_ptr->metadata_write_strategy = aux_ptr->metadata_write_strategy; - } /* end if */ - else { + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { + config_ptr->dirty_bytes_threshold = aux_ptr->dirty_bytes_threshold; + config_ptr->metadata_write_strategy = aux_ptr->metadata_write_strategy; + } /* end if */ + else { #endif /* H5_HAVE_PARALLEL */ - config_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; - config_ptr->metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; + config_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; + config_ptr->metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; #ifdef H5_HAVE_PARALLEL - } /* end else */ -} + } /* end else */ + } #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_cache_auto_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_cache_size * @@ -1711,22 +1663,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, - size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr) +H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, + uint32_t *cur_num_entries_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_get_cache_size((H5C_t *)cache_ptr, max_size_ptr, min_clean_size_ptr, - cur_size_ptr, cur_num_entries_ptr) < 0) + if (H5C_get_cache_size((H5C_t *)cache_ptr, max_size_ptr, min_clean_size_ptr, cur_size_ptr, + cur_num_entries_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_size() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_cache_size() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_cache_flush_in_progess * @@ -1742,18 +1693,17 @@ done: herr_t H5AC_get_cache_flush_in_progress(H5AC_t *cache_ptr, hbool_t *flush_in_progress_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_get_cache_flush_in_progress((H5C_t *)cache_ptr, flush_in_progress_ptr) < 0) + if (H5C_get_cache_flush_in_progress((H5C_t *)cache_ptr, flush_in_progress_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_flush_in_progress() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_cache_flush_in_progress() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_cache_hit_rate * @@ -1769,18 +1719,17 @@ done: herr_t H5AC_get_cache_hit_rate(H5AC_t *cache_ptr, double *hit_rate_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_get_cache_hit_rate((H5C_t *)cache_ptr, hit_rate_ptr) < 0) + if (H5C_get_cache_hit_rate((H5C_t *)cache_ptr, hit_rate_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_hit_rate() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_cache_hit_rate() */ - /*------------------------------------------------------------------------- * * Function: H5AC_reset_cache_hit_rate_stats() @@ -1794,20 +1743,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_reset_cache_hit_rate_stats(H5AC_t * cache_ptr) +H5AC_reset_cache_hit_rate_stats(H5AC_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_reset_cache_hit_rate_stats((H5C_t *)cache_ptr) < 0) + if (H5C_reset_cache_hit_rate_stats((H5C_t *)cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_reset_cache_hit_rate_stats() */ - /*------------------------------------------------------------------------- * Function: H5AC_set_cache_auto_resize_config * @@ -1824,27 +1772,27 @@ herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ HDassert(cache_ptr); - if(cache_ptr == NULL) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad cache_ptr on entry") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr on entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr on entry") + } #endif /* H5_HAVE_PARALLEL */ /* Validate external configuration */ - if(H5AC_validate_config(config_ptr) != SUCCEED) + if (H5AC_validate_config(config_ptr) != SUCCEED) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache configuration") /* If the cache config struct is being used to control logging, perform @@ -1853,53 +1801,52 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config * to write start/stop messages. */ /* close */ - if(config_ptr->close_trace_file) - if(H5C_log_tear_down((H5C_t *)cache_ptr) < 0) + if (config_ptr->close_trace_file) + if (H5C_log_tear_down((H5C_t *)cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") /* open */ - if(config_ptr->open_trace_file) { + if (config_ptr->open_trace_file) { /* Turn on metadata cache logging. * This will be trace output until we create a special API call. JSON * output is generated when logging is controlled by the H5P calls. */ - if(H5C_log_set_up((H5C_t *)cache_ptr, config_ptr->trace_file_name, H5C_LOG_STYLE_TRACE, TRUE) < 0) + if (H5C_log_set_up((H5C_t *)cache_ptr, config_ptr->trace_file_name, H5C_LOG_STYLE_TRACE, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging setup failed") } /* Convert external configuration to internal representation */ - if(H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) + if (H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC__ext_config_2_int_config() failed") /* Set configuration */ - if(H5C_set_cache_auto_resize_config(cache_ptr, &internal_config) < 0) + if (H5C_set_cache_auto_resize_config(cache_ptr, &internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_set_cache_auto_resize_config() failed") - if(H5C_set_evictions_enabled(cache_ptr, config_ptr->evictions_enabled) < 0) + if (H5C_set_evictions_enabled(cache_ptr, config_ptr->evictions_enabled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_set_evictions_enabled() failed") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - /* Set parallel configuration values */ - /* (Which are only held in the H5AC layer -QAK) */ - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { - aux_ptr->dirty_bytes_threshold = config_ptr->dirty_bytes_threshold; - aux_ptr->metadata_write_strategy = config_ptr->metadata_write_strategy; - } /* end if */ -} + /* Set parallel configuration values */ + /* (Which are only held in the H5AC layer -QAK) */ + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { + aux_ptr->dirty_bytes_threshold = config_ptr->dirty_bytes_threshold; + aux_ptr->metadata_write_strategy = config_ptr->metadata_write_strategy; + } /* end if */ + } #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_set_cache_config_msg(cache_ptr, config_ptr, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_set_cache_config_msg(cache_ptr, config_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_set_cache_auto_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5AC_validate_config() * @@ -1926,57 +1873,55 @@ herr_t H5AC_validate_config(H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) + if (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Unknown config version") /* don't bother to test trace_file_name unless open_trace_file is TRUE */ - if(config_ptr->open_trace_file) { - size_t name_len; + if (config_ptr->open_trace_file) { + size_t name_len; /* Can't really test the trace_file_name field without trying to * open the file, so we will content ourselves with a couple of * sanity checks on the length of the file name. */ name_len = HDstrlen(config_ptr->trace_file_name); - if(name_len == 0) + if (name_len == 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->trace_file_name is empty") - else if(name_len > H5AC__MAX_TRACE_FILE_NAME_LEN) + else if (name_len > H5AC__MAX_TRACE_FILE_NAME_LEN) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->trace_file_name too long") } /* end if */ - if((config_ptr->evictions_enabled == FALSE) && - ((config_ptr->incr_mode != H5C_incr__off) || - (config_ptr->flash_incr_mode != H5C_flash_incr__off) || - (config_ptr->decr_mode != H5C_decr__off))) + if ((config_ptr->evictions_enabled == FALSE) && + ((config_ptr->incr_mode != H5C_incr__off) || (config_ptr->flash_incr_mode != H5C_flash_incr__off) || + (config_ptr->decr_mode != H5C_decr__off))) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Can't disable evictions while auto-resize is enabled") - if(config_ptr->dirty_bytes_threshold < H5AC__MIN_DIRTY_BYTES_THRESHOLD) + if (config_ptr->dirty_bytes_threshold < H5AC__MIN_DIRTY_BYTES_THRESHOLD) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "dirty_bytes_threshold too small") - else if(config_ptr->dirty_bytes_threshold > H5AC__MAX_DIRTY_BYTES_THRESHOLD) + else if (config_ptr->dirty_bytes_threshold > H5AC__MAX_DIRTY_BYTES_THRESHOLD) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "dirty_bytes_threshold too big") - if((config_ptr->metadata_write_strategy != H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY) && - (config_ptr->metadata_write_strategy != H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) + if ((config_ptr->metadata_write_strategy != H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY) && + (config_ptr->metadata_write_strategy != H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->metadata_write_strategy out of range") - if(H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) + if (H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC__ext_config_2_int_config() failed") - if(H5C_validate_resize_config(&internal_config, H5C_RESIZE_CFG__VALIDATE_ALL) < 0) + if (H5C_validate_resize_config(&internal_config, H5C_RESIZE_CFG__VALIDATE_ALL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "error(s) in new config") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_validate_config() */ - /*------------------------------------------------------------------------- * Function: H5AC_validate_cache_image_config() * @@ -2004,15 +1949,15 @@ herr_t H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr) { H5C_cache_image_ctl_t internal_config = H5C__DEFAULT_CACHE_IMAGE_CTL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) + if (config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Unknown image config version") /* don't need to get the current H5C image config here since the @@ -2024,14 +1969,13 @@ H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr) internal_config.save_resize_status = config_ptr->save_resize_status; internal_config.entry_ageout = config_ptr->entry_ageout; - if(H5C_validate_cache_image_config(&internal_config) < 0) + if (H5C_validate_cache_image_config(&internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "error(s) in new cache image config") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_validate_cache_image_config() */ - /*------------------------------------------------------------------------- * * Function: H5AC__check_if_write_permitted @@ -2054,14 +1998,15 @@ done: static herr_t H5AC__check_if_write_permitted(const H5F_t #ifndef H5_HAVE_PARALLEL -H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - *f, hbool_t *write_permitted_ptr) + *f, + hbool_t *write_permitted_ptr) { #ifdef H5_HAVE_PARALLEL - H5AC_aux_t * aux_ptr = NULL; + H5AC_aux_t *aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ - hbool_t write_permitted = TRUE; + hbool_t write_permitted = TRUE; FUNC_ENTER_STATIC_NOERR @@ -2071,14 +2016,15 @@ H5_ATTR_UNUSED HDassert(f->shared != NULL); HDassert(f->shared->cache != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); - if(aux_ptr != NULL) { + if (aux_ptr != NULL) { HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if((aux_ptr->mpi_rank == 0) || (aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) + if ((aux_ptr->mpi_rank == 0) || + (aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) write_permitted = aux_ptr->write_permitted; else write_permitted = FALSE; - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ *write_permitted_ptr = write_permitted; @@ -2086,7 +2032,6 @@ H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__check_if_write_permitted() */ - /*------------------------------------------------------------------------- * Function: H5AC__ext_config_2_int_config() * @@ -2106,38 +2051,37 @@ H5_ATTR_UNUSED *------------------------------------------------------------------------- */ static herr_t -H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, - H5C_auto_size_ctl_t *int_conf_ptr) +H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, H5C_auto_size_ctl_t *int_conf_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if((ext_conf_ptr == NULL) || (ext_conf_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) || - (int_conf_ptr == NULL)) + if ((ext_conf_ptr == NULL) || (ext_conf_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) || + (int_conf_ptr == NULL)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad ext_conf_ptr or inf_conf_ptr on entry") - int_conf_ptr->version = H5C__CURR_AUTO_SIZE_CTL_VER; - if(ext_conf_ptr->rpt_fcn_enabled) - int_conf_ptr->rpt_fcn = H5C_def_auto_resize_rpt_fcn; + int_conf_ptr->version = H5C__CURR_AUTO_SIZE_CTL_VER; + if (ext_conf_ptr->rpt_fcn_enabled) + int_conf_ptr->rpt_fcn = H5C_def_auto_resize_rpt_fcn; else - int_conf_ptr->rpt_fcn = NULL; - - int_conf_ptr->set_initial_size = ext_conf_ptr->set_initial_size; - int_conf_ptr->initial_size = ext_conf_ptr->initial_size; - int_conf_ptr->min_clean_fraction = ext_conf_ptr->min_clean_fraction; - int_conf_ptr->max_size = ext_conf_ptr->max_size; - int_conf_ptr->min_size = ext_conf_ptr->min_size; - int_conf_ptr->epoch_length = (int64_t)(ext_conf_ptr->epoch_length); - - int_conf_ptr->incr_mode = ext_conf_ptr->incr_mode; - int_conf_ptr->lower_hr_threshold = ext_conf_ptr->lower_hr_threshold; - int_conf_ptr->increment = ext_conf_ptr->increment; - int_conf_ptr->apply_max_increment = ext_conf_ptr->apply_max_increment; - int_conf_ptr->max_increment = ext_conf_ptr->max_increment; - int_conf_ptr->flash_incr_mode = ext_conf_ptr->flash_incr_mode; - int_conf_ptr->flash_multiple = ext_conf_ptr->flash_multiple; - int_conf_ptr->flash_threshold = ext_conf_ptr->flash_threshold; + int_conf_ptr->rpt_fcn = NULL; + + int_conf_ptr->set_initial_size = ext_conf_ptr->set_initial_size; + int_conf_ptr->initial_size = ext_conf_ptr->initial_size; + int_conf_ptr->min_clean_fraction = ext_conf_ptr->min_clean_fraction; + int_conf_ptr->max_size = ext_conf_ptr->max_size; + int_conf_ptr->min_size = ext_conf_ptr->min_size; + int_conf_ptr->epoch_length = (int64_t)(ext_conf_ptr->epoch_length); + + int_conf_ptr->incr_mode = ext_conf_ptr->incr_mode; + int_conf_ptr->lower_hr_threshold = ext_conf_ptr->lower_hr_threshold; + int_conf_ptr->increment = ext_conf_ptr->increment; + int_conf_ptr->apply_max_increment = ext_conf_ptr->apply_max_increment; + int_conf_ptr->max_increment = ext_conf_ptr->max_increment; + int_conf_ptr->flash_incr_mode = ext_conf_ptr->flash_incr_mode; + int_conf_ptr->flash_multiple = ext_conf_ptr->flash_multiple; + int_conf_ptr->flash_threshold = ext_conf_ptr->flash_threshold; int_conf_ptr->decr_mode = ext_conf_ptr->decr_mode; int_conf_ptr->upper_hr_threshold = ext_conf_ptr->upper_hr_threshold; @@ -2152,7 +2096,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__ext_config_2_int_config() */ - /*------------------------------------------------------------------------------ * Function: H5AC_ignore_tags() * @@ -2171,7 +2114,7 @@ done: herr_t H5AC_ignore_tags(const H5F_t *f) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -2181,14 +2124,13 @@ H5AC_ignore_tags(const H5F_t *f) HDassert(f->shared->cache); /* Set up a new metadata tag */ - if(H5C_ignore_tags(f->shared->cache) < 0) + if (H5C_ignore_tags(f->shared->cache) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "H5C_ignore_tags() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_ignore_tags() */ - /*------------------------------------------------------------------------------ * Function: H5AC_tag() * @@ -2207,7 +2149,7 @@ H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Get the current tag value and return that (if prev_tag is NOT null) */ - if(prev_tag) + if (prev_tag) *prev_tag = H5CX_get_tag(); /* Set the provided tag */ @@ -2216,7 +2158,6 @@ H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag) FUNC_LEAVE_NOAPI_VOID } /* H5AC_tag */ - /*------------------------------------------------------------------------------ * Function: H5AC_retag_copied_metadata() * @@ -2234,7 +2175,7 @@ H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag) herr_t H5AC_retag_copied_metadata(const H5F_t *f, haddr_t metadata_tag) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2243,14 +2184,13 @@ H5AC_retag_copied_metadata(const H5F_t *f, haddr_t metadata_tag) HDassert(f->shared); /* Call cache-level function to re-tag entries with the COPIED tag */ - if(H5C_retag_entries(f->shared->cache, H5AC__COPIED_TAG, metadata_tag) < 0) + if (H5C_retag_entries(f->shared->cache, H5AC__COPIED_TAG, metadata_tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "Can't retag metadata") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_retag_copied_metadata() */ - /*------------------------------------------------------------------------------ * Function: H5AC_flush_tagged_metadata() * @@ -2278,14 +2218,13 @@ H5AC_flush_tagged_metadata(H5F_t *f, haddr_t metadata_tag) HDassert(f->shared); /* Call cache level function to flush metadata entries with specified tag */ - if(H5C_flush_tagged_entries(f, metadata_tag) < 0) + if (H5C_flush_tagged_entries(f, metadata_tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot flush metadata") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush_tagged_metadata */ - /*------------------------------------------------------------------------------ * Function: H5AC_evict_tagged_metadata() * @@ -2313,14 +2252,13 @@ H5AC_evict_tagged_metadata(H5F_t *f, haddr_t metadata_tag, hbool_t match_global) HDassert(f->shared); /* Call cache level function to evict metadata entries with specified tag */ - if(H5C_evict_tagged_entries(f, metadata_tag, match_global) < 0) + if (H5C_evict_tagged_entries(f, metadata_tag, match_global) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot evict metadata") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_evict_tagged_metadata() */ - /*------------------------------------------------------------------------------ * Function: H5AC_expunge_tag_type_metadata() * @@ -2347,14 +2285,13 @@ H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flag HDassert(f->shared); /* Call cache level function to expunge entries with specified tag and type id */ - if(H5C_expunge_tag_type_metadata(f, tag, type_id, flags, type_match)<0) + if (H5C_expunge_tag_type_metadata(f, tag, type_id, flags, type_match) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot expunge tagged type entries") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_expunge_tag_type_metadata*/ - /*------------------------------------------------------------------------------ * Function: H5AC_get_tag() * @@ -2381,14 +2318,13 @@ H5AC_get_tag(const void *thing, haddr_t *tag) HDassert(tag); /* Call cache level function to get the tag */ - if(H5C_get_tag(thing, tag) < 0) + if (H5C_get_tag(thing, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot get tag for metadata cache entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_get_tag() */ - /*------------------------------------------------------------------------- * Function: H5AC_cork * @@ -2403,7 +2339,7 @@ done: herr_t H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2419,15 +2355,15 @@ H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked) * Re-visit this optimization when we optimize tag info management * in the future. */ - if(action == H5AC__GET_CORKED) { + if (action == H5AC__GET_CORKED) { HDassert(corked); - if(H5C_get_num_objs_corked(f->shared->cache) == 0) { + if (H5C_get_num_objs_corked(f->shared->cache) == 0) { *corked = FALSE; HGOTO_DONE(SUCCEED) } } - if(H5C_cork(f->shared->cache, obj_addr, action, corked) < 0) + if (H5C_cork(f->shared->cache, obj_addr, action, corked) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Cannot perform the cork action") done: @@ -2435,7 +2371,7 @@ done: } /* H5AC_cork() */ #if H5AC_DO_TAGGING_SANITY_CHECKS - + /*------------------------------------------------------------------------- * * Function: H5AC__verify_tag @@ -2453,8 +2389,8 @@ done: static herr_t H5AC__verify_tag(const H5AC_class_t *type) { - haddr_t tag; /* Entry tag to validate */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t tag; /* Entry tag to validate */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2462,7 +2398,7 @@ H5AC__verify_tag(const H5AC_class_t *type) tag = H5CX_get_tag(); /* Verify legal tag value */ - if(H5C_verify_tag(type->id, tag) < 0) + if (H5C_verify_tag(type->id, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "tag verification failed") done: @@ -2470,7 +2406,6 @@ done: } /* H5AC__verify_tag */ #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ - /*------------------------------------------------------------------------- * Function: H5AC_get_entry_ring * @@ -2489,7 +2424,7 @@ done: herr_t H5AC_get_entry_ring(const H5F_t *f, haddr_t addr, H5AC_ring_t *ring) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2499,14 +2434,13 @@ H5AC_get_entry_ring(const H5F_t *f, haddr_t addr, H5AC_ring_t *ring) HDassert(ring); /* Retrieve the ring value for the entry at address */ - if(H5C_get_entry_ring(f, addr, ring) < 0) + if (H5C_get_entry_ring(f, addr, ring) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "Can't retrieve ring for entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_entry_ring() */ - /*------------------------------------------------------------------------- * Function: H5AC_set_ring * @@ -2528,7 +2462,7 @@ H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring) /* Note: orig_ring can be NULL so don't check it with HDassert() */ /* Get the current ring value and return that (if orig_ring is NOT null) */ - if(orig_ring) + if (orig_ring) *orig_ring = H5CX_get_ring(); /* Set the provided ring */ @@ -2537,7 +2471,6 @@ H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring) FUNC_LEAVE_NOAPI_VOID } /* end H5AC_set_ring() */ - /*------------------------------------------------------------------------- * Function: H5AC_unsettle_entry_ring() * @@ -2569,8 +2502,8 @@ H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring) herr_t H5AC_unsettle_entry_ring(void *_entry) { - H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2578,14 +2511,13 @@ H5AC_unsettle_entry_ring(void *_entry) HDassert(entry); /* Unsettle the entry's ring */ - if(H5C_unsettle_entry_ring(entry) < 0) + if (H5C_unsettle_entry_ring(entry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unsettle_entry_ring() */ - /*------------------------------------------------------------------------- * Function: H5AC_unsettle_ring() * @@ -2614,20 +2546,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_unsettle_ring(H5F_t * f, H5C_ring_t ring) +H5AC_unsettle_ring(H5F_t *f, H5C_ring_t ring) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(FAIL == (ret_value = H5C_unsettle_ring(f, ring))) + if (FAIL == (ret_value = H5C_unsettle_ring(f, ring))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_unsettle_ring() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unsettle_ring() */ - /*------------------------------------------------------------------------- * Function: H5AC_remove_entry() * @@ -2644,9 +2575,9 @@ done: herr_t H5AC_remove_entry(void *_entry) { - H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ - H5C_t *cache = NULL; /* Pointer to the entry's associated metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ + H5C_t * cache = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2656,19 +2587,18 @@ H5AC_remove_entry(void *_entry) HDassert(cache); /* Remove the entry from the cache*/ - if(H5C_remove_entry(entry) < 0) + if (H5C_remove_entry(entry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry") done: /* If currently logging, generate a message */ - if(cache->log_info->logging) - if(H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0) + if (cache->log_info->logging) + if (H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_remove_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_mdc_image_info * @@ -2683,14 +2613,13 @@ done: herr_t H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_get_mdc_image_info((H5C_t *)cache_ptr, image_addr, image_len) < 0) + if (H5C_get_mdc_image_info((H5C_t *)cache_ptr, image_addr, image_len) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't retrieve cache image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_mdc_image_info() */ - diff --git a/src/H5ACdbg.c b/src/H5ACdbg.c index b40f8d0..e6d1283 100644 --- a/src/H5ACdbg.c +++ b/src/H5ACdbg.c @@ -23,54 +23,45 @@ /****************/ /* Module Setup */ /****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5AC_stats * @@ -100,7 +91,7 @@ H5AC_stats(const H5F_t *f) } /* H5AC_stats() */ #ifndef NDEBUG - + /*------------------------------------------------------------------------- * Function: H5AC_dump_cache * @@ -117,7 +108,7 @@ H5AC_stats(const H5F_t *f) herr_t H5AC_dump_cache(const H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -126,7 +117,7 @@ H5AC_dump_cache(const H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - if(H5C_dump_cache(f->shared->cache, H5F_OPEN_NAME(f)) < 0) + if (H5C_dump_cache(f->shared->cache, H5F_OPEN_NAME(f)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_dump_cache() failed.") done: @@ -134,7 +125,6 @@ done: } /* H5AC_dump_cache() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5AC_get_entry_ptr_from_addr() @@ -178,8 +168,8 @@ done: herr_t H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr) { - H5C_t *cache_ptr; /* Ptr to cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr; /* Ptr to cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -188,7 +178,7 @@ H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr) HDassert(f->shared); cache_ptr = f->shared->cache; - if(H5C_get_entry_ptr_from_addr(cache_ptr, addr, entry_ptr_ptr) < 0) + if (H5C_get_entry_ptr_from_addr(cache_ptr, addr, entry_ptr_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_entry_ptr_from_addr() failed") done: @@ -196,7 +186,6 @@ done: } /* H5AC_get_entry_ptr_from_addr() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5AC_flush_dependency_exists() * @@ -224,11 +213,10 @@ done: */ #ifndef NDEBUG herr_t -H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, - hbool_t *fd_exists_ptr) +H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, hbool_t *fd_exists_ptr) { - H5C_t *cache_ptr; /* Ptr to cache */ - herr_t ret_value = FAIL; /* Return value */ + H5C_t *cache_ptr; /* Ptr to cache */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -243,7 +231,6 @@ H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, } /* H5AC_flush_dependency_exists() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5AC_verify_entry_type() @@ -278,12 +265,11 @@ H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, */ #ifndef NDEBUG herr_t -H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, - const H5AC_class_t *expected_type, hbool_t *in_cache_ptr, - hbool_t *type_ok_ptr) +H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, const H5AC_class_t *expected_type, hbool_t *in_cache_ptr, + hbool_t *type_ok_ptr) { - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -292,7 +278,7 @@ H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, HDassert(f->shared); cache_ptr = f->shared->cache; - if(H5C_verify_entry_type(cache_ptr, addr, expected_type, in_cache_ptr, type_ok_ptr) < 0) + if (H5C_verify_entry_type(cache_ptr, addr, expected_type, in_cache_ptr, type_ok_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_verify_entry_type() failed") done: @@ -300,7 +286,6 @@ done: } /* H5AC_verify_entry_type() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5AC_get_serialization_in_progress * @@ -319,7 +304,7 @@ hbool_t H5AC_get_serialization_in_progress(H5F_t *f) { H5C_t * cache_ptr; - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -335,7 +320,6 @@ H5AC_get_serialization_in_progress(H5F_t *f) } /* H5AC_get_serialization_in_progress() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5AC_cache_is_clean() @@ -359,8 +343,8 @@ H5AC_get_serialization_in_progress(H5F_t *f) hbool_t H5AC_cache_is_clean(const H5F_t *f, H5AC_ring_t inner_ring) { - H5C_t *cache_ptr; - hbool_t ret_value = FALSE; /* Return value */ + H5C_t * cache_ptr; + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -374,4 +358,3 @@ H5AC_cache_is_clean(const H5F_t *f, H5AC_ring_t inner_ring) FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_cache_is_clean() */ #endif /* NDEBUG */ - diff --git a/src/H5ACmodule.h b/src/H5ACmodule.h index e218b31..e4a09e3 100644 --- a/src/H5ACmodule.h +++ b/src/H5ACmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5AC_MODULE -#define H5_MY_PKG H5AC -#define H5_MY_PKG_ERR H5E_CACHE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5AC +#define H5_MY_PKG_ERR H5E_CACHE +#define H5_MY_PKG_INIT YES #endif /* _H5ACmodule_H */ - diff --git a/src/H5ACmpio.c b/src/H5ACmpio.c index 824475d..85fb236 100644 --- a/src/H5ACmpio.c +++ b/src/H5ACmpio.c @@ -27,20 +27,19 @@ /* Module Setup */ /****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Cprivate.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Cprivate.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_PARALLEL @@ -48,7 +47,6 @@ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -70,46 +68,41 @@ * removed when they appear in a clean entries broadcast. * ****************************************************************************/ -typedef struct H5AC_slist_entry_t -{ - haddr_t addr; +typedef struct H5AC_slist_entry_t { + haddr_t addr; } H5AC_slist_entry_t; /* User data for address list building callbacks */ -typedef struct H5AC_addr_list_ud_t -{ - H5AC_aux_t * aux_ptr; /* 'Auxiliary' parallel cache info */ - haddr_t * addr_buf_ptr; /* Array to store addresses */ - unsigned u; /* Counter for position in array */ +typedef struct H5AC_addr_list_ud_t { + H5AC_aux_t *aux_ptr; /* 'Auxiliary' parallel cache info */ + haddr_t * addr_buf_ptr; /* Array to store addresses */ + unsigned u; /* Counter for position in array */ } H5AC_addr_list_ud_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, - unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr); +static herr_t H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, + haddr_t **haddr_buf_ptr_ptr); static herr_t H5AC__broadcast_clean_list(H5AC_t *cache_ptr); -static herr_t H5AC__construct_candidate_list(H5AC_t *cache_ptr, - H5AC_aux_t *aux_ptr, int sync_point_op); -static herr_t H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, - unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr); -static herr_t H5AC__propagate_and_apply_candidate_list(H5F_t *f); -static herr_t H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f); +static herr_t H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t *aux_ptr, int sync_point_op); +static herr_t H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, + haddr_t **haddr_buf_ptr_ptr); +static herr_t H5AC__propagate_and_apply_candidate_list(H5F_t *f); +static herr_t H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f); static herr_t H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr); -static herr_t H5AC__receive_candidate_list(const H5AC_t *cache_ptr, - unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr); + haddr_t **haddr_buf_ptr_ptr); +static herr_t H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, + haddr_t **haddr_buf_ptr_ptr); static herr_t H5AC__receive_and_apply_clean_list(H5F_t *f); static herr_t H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, - haddr_t *candidates_list_ptr); + haddr_t *candidates_list_ptr); static herr_t H5AC__rsp__dist_md_write__flush(H5F_t *f); static herr_t H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f); static herr_t H5AC__rsp__p0_only__flush(H5F_t *f); static herr_t H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f); - /*********************/ /* Package Variables */ /*********************/ @@ -117,12 +110,10 @@ static herr_t H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f); /* Declare a free list to manage the H5AC_aux_t struct */ H5FL_DEFINE(H5AC_aux_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -130,8 +121,6 @@ H5FL_DEFINE(H5AC_aux_t); /* Declare a free list to manage the H5AC_slist_entry_t struct */ H5FL_DEFINE_STATIC(H5AC_slist_entry_t); - - /*------------------------------------------------------------------------- * Function: H5AC__set_sync_point_done_callback * @@ -148,10 +137,10 @@ H5FL_DEFINE_STATIC(H5AC_slist_entry_t); *------------------------------------------------------------------------- */ herr_t -H5AC__set_sync_point_done_callback(H5C_t * cache_ptr, - void (* sync_point_done)(unsigned num_writes, haddr_t * written_entries_tbl)) +H5AC__set_sync_point_done_callback(H5C_t *cache_ptr, + void (*sync_point_done)(unsigned num_writes, haddr_t *written_entries_tbl)) { - H5AC_aux_t * aux_ptr; + H5AC_aux_t *aux_ptr; FUNC_ENTER_PACKAGE_NOERR @@ -166,7 +155,6 @@ H5AC__set_sync_point_done_callback(H5C_t * cache_ptr, FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__set_sync_point_done_callback() */ - /*------------------------------------------------------------------------- * Function: H5AC__set_write_done_callback * @@ -182,9 +170,9 @@ H5AC__set_sync_point_done_callback(H5C_t * cache_ptr, *------------------------------------------------------------------------- */ herr_t -H5AC__set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)) +H5AC__set_write_done_callback(H5C_t *cache_ptr, void (*write_done)(void)) { - H5AC_aux_t * aux_ptr; + H5AC_aux_t *aux_ptr; FUNC_ENTER_PACKAGE_NOERR @@ -199,7 +187,6 @@ H5AC__set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__set_write_done_callback() */ - /*------------------------------------------------------------------------- * Function: H5AC_add_candidate() * @@ -219,11 +206,11 @@ H5AC__set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)) *------------------------------------------------------------------------- */ herr_t -H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr) +H5AC_add_candidate(H5AC_t *cache_ptr, haddr_t addr) { - H5AC_aux_t * aux_ptr; - H5AC_slist_entry_t * slist_entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t * aux_ptr; + H5AC_slist_entry_t *slist_entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -238,23 +225,22 @@ H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr) /* Construct an entry for the supplied address, and insert * it into the candidate slist. */ - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate candidate slist entry") - slist_entry_ptr->addr = addr; + slist_entry_ptr->addr = addr; - if(H5SL_insert(aux_ptr->candidate_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + if (H5SL_insert(aux_ptr->candidate_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into dirty entry slist") done: /* Clean up on error */ - if(ret_value < 0) - if(slist_entry_ptr) + if (ret_value < 0) + if (slist_entry_ptr) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_add_candidate() */ - /*------------------------------------------------------------------------- * * Function: H5AC__broadcast_candidate_list() @@ -280,14 +266,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr) +H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr) { - H5AC_aux_t * aux_ptr = NULL; - haddr_t * haddr_buf_ptr = NULL; - int mpi_result; - unsigned num_entries; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr = NULL; + haddr_t * haddr_buf_ptr = NULL; + int mpi_result; + unsigned num_entries; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -309,25 +294,26 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, * any, we are done. */ num_entries = (unsigned)H5SL_count(aux_ptr->candidate_slist_ptr); - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - if(num_entries > 0) { - size_t buf_size = 0; - unsigned chk_num_entries = 0; + if (num_entries > 0) { + size_t buf_size = 0; + unsigned chk_num_entries = 0; /* convert the candidate list into the format we * are used to receiving from process 0, and also load it * into a buffer for transmission. */ - if(H5AC__copy_candidate_list_to_buffer(cache_ptr, &chk_num_entries, &haddr_buf_ptr) < 0) + if (H5AC__copy_candidate_list_to_buffer(cache_ptr, &chk_num_entries, &haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate buffer.") HDassert(chk_num_entries == num_entries); HDassert(haddr_buf_ptr != NULL); /* Now broadcast the list of candidate entries */ buf_size = sizeof(haddr_t) * num_entries; - if(MPI_SUCCESS != (mpi_result = MPI_Bcast((void *)haddr_buf_ptr, (int)buf_size, MPI_BYTE, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast((void *)haddr_buf_ptr, (int)buf_size, MPI_BYTE, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) } /* end if */ @@ -335,18 +321,17 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, * back to the caller. Do this so that we can use the same code * to apply the candidate list to all the processes. */ - *num_entries_ptr = num_entries; + *num_entries_ptr = num_entries; *haddr_buf_ptr_ptr = haddr_buf_ptr; done: - if(ret_value < 0) - if(haddr_buf_ptr) + if (ret_value < 0) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__broadcast_candidate_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__broadcast_clean_list_cb() @@ -361,12 +346,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, - void *_udata) +H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5AC_slist_entry_t * slist_entry_ptr = (H5AC_slist_entry_t *)_item; /* Address of item */ - H5AC_addr_list_ud_t * udata = (H5AC_addr_list_ud_t *)_udata; /* Context for callback */ - haddr_t addr; + H5AC_slist_entry_t * slist_entry_ptr = (H5AC_slist_entry_t *)_item; /* Address of item */ + H5AC_addr_list_ud_t *udata = (H5AC_addr_list_ud_t *)_udata; /* Context for callback */ + haddr_t addr; FUNC_ENTER_STATIC_NOERR @@ -375,7 +359,7 @@ H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, HDassert(udata); /* Store the entry's address in the buffer */ - addr = slist_entry_ptr->addr; + addr = slist_entry_ptr->addr; udata->addr_buf_ptr[udata->u] = addr; udata->u++; @@ -385,13 +369,13 @@ H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, /* and also remove the matching entry from the dirtied list * if it exists. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(udata->aux_ptr->d_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(udata->aux_ptr->d_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__broadcast_clean_list_cb() */ - /*------------------------------------------------------------------------- * * Function: H5AC__broadcast_clean_list() @@ -413,13 +397,13 @@ H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, *------------------------------------------------------------------------- */ static herr_t -H5AC__broadcast_clean_list(H5AC_t * cache_ptr) +H5AC__broadcast_clean_list(H5AC_t *cache_ptr) { - haddr_t * addr_buf_ptr = NULL; - H5AC_aux_t * aux_ptr; - int mpi_result; - unsigned num_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t * addr_buf_ptr = NULL; + H5AC_aux_t *aux_ptr; + int mpi_result; + unsigned num_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -436,30 +420,31 @@ H5AC__broadcast_clean_list(H5AC_t * cache_ptr) * any, we are done. */ num_entries = (unsigned)H5SL_count(aux_ptr->c_slist_ptr); - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - if(num_entries > 0) { + if (num_entries > 0) { H5AC_addr_list_ud_t udata; - size_t buf_size; + size_t buf_size; /* allocate a buffer to store the list of entry base addresses in */ buf_size = sizeof(haddr_t) * num_entries; - if(NULL == (addr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) + if (NULL == (addr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for addr buffer") /* Set up user data for callback */ - udata.aux_ptr = aux_ptr; + udata.aux_ptr = aux_ptr; udata.addr_buf_ptr = addr_buf_ptr; - udata.u = 0; + udata.u = 0; /* Free all the clean list entries, building the address list in the callback */ /* (Callback also removes the matching entries from the dirtied list) */ - if(H5SL_free(aux_ptr->c_slist_ptr, H5AC__broadcast_clean_list_cb, &udata) < 0) + if (H5SL_free(aux_ptr->c_slist_ptr, H5AC__broadcast_clean_list_cb, &udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "Can't build address list for clean entries") /* Now broadcast the list of cleaned entries */ - if(MPI_SUCCESS != (mpi_result = MPI_Bcast((void *)addr_buf_ptr, (int)buf_size, MPI_BYTE, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast((void *)addr_buf_ptr, (int)buf_size, MPI_BYTE, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) } /* end if */ @@ -467,17 +452,16 @@ H5AC__broadcast_clean_list(H5AC_t * cache_ptr) * that this callback is defined purely for testing purposes, * and should be undefined under normal operating circumstances. */ - if(aux_ptr->sync_point_done) + if (aux_ptr->sync_point_done) (aux_ptr->sync_point_done)(num_entries, addr_buf_ptr); done: - if(addr_buf_ptr) + if (addr_buf_ptr) addr_buf_ptr = (haddr_t *)H5MM_xfree((void *)addr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__broadcast_clean_list() */ - /*------------------------------------------------------------------------- * Function: H5AC__construct_candidate_list() * @@ -498,10 +482,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t H5_ATTR_SANITY_CHECK *aux_ptr, - int sync_point_op) +H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t H5_ATTR_SANITY_CHECK *aux_ptr, int sync_point_op) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -516,29 +499,30 @@ H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t H5_ATTR_SANITY_CHEC HDassert(H5SL_count(aux_ptr->c_slist_ptr) == 0); HDassert(aux_ptr->candidate_slist_ptr != NULL); HDassert(H5SL_count(aux_ptr->candidate_slist_ptr) == 0); - HDassert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) || (sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_CACHE)); + HDassert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) || + (sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_CACHE)); - switch(sync_point_op) { - case H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN: - if(H5C_construct_candidate_list__min_clean((H5C_t *)cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_construct_candidate_list__min_clean() failed.") - break; + switch (sync_point_op) { + case H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN: + if (H5C_construct_candidate_list__min_clean((H5C_t *)cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_construct_candidate_list__min_clean() failed.") + break; - case H5AC_SYNC_POINT_OP__FLUSH_CACHE: - if(H5C_construct_candidate_list__clean_cache((H5C_t *)cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_construct_candidate_list__clean_cache() failed.") - break; + case H5AC_SYNC_POINT_OP__FLUSH_CACHE: + if (H5C_construct_candidate_list__clean_cache((H5C_t *)cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "H5C_construct_candidate_list__clean_cache() failed.") + break; default: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown sync point operation.") - break; + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown sync point operation.") + break; } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__construct_candidate_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__copy_candidate_list_to_buffer_cb @@ -553,11 +537,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__copy_candidate_list_to_buffer_cb(void *_item, void H5_ATTR_UNUSED *_key, - void *_udata) +H5AC__copy_candidate_list_to_buffer_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5AC_slist_entry_t * slist_entry_ptr = (H5AC_slist_entry_t *)_item; /* Address of item */ - H5AC_addr_list_ud_t * udata = (H5AC_addr_list_ud_t *)_udata; /* Context for callback */ + H5AC_slist_entry_t * slist_entry_ptr = (H5AC_slist_entry_t *)_item; /* Address of item */ + H5AC_addr_list_ud_t *udata = (H5AC_addr_list_ud_t *)_udata; /* Context for callback */ FUNC_ENTER_STATIC_NOERR @@ -575,7 +558,6 @@ H5AC__copy_candidate_list_to_buffer_cb(void *_item, void H5_ATTR_UNUSED *_key, FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__copy_candidate_list_to_buffer_cb() */ - /*------------------------------------------------------------------------- * * Function: H5AC__copy_candidate_list_to_buffer @@ -609,14 +591,14 @@ H5AC__copy_candidate_list_to_buffer_cb(void *_item, void H5_ATTR_UNUSED *_key, */ static herr_t H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr) + haddr_t **haddr_buf_ptr_ptr) { - H5AC_aux_t * aux_ptr = NULL; - H5AC_addr_list_ud_t udata; - haddr_t * haddr_buf_ptr = NULL; - size_t buf_size; - unsigned num_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t * aux_ptr = NULL; + H5AC_addr_list_ud_t udata; + haddr_t * haddr_buf_ptr = NULL; + size_t buf_size; + unsigned num_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -639,33 +621,32 @@ H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entri * base addresses in */ buf_size = sizeof(haddr_t) * num_entries; - if(NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) + if (NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for haddr buffer") /* Set up user data for callback */ - udata.aux_ptr = aux_ptr; + udata.aux_ptr = aux_ptr; udata.addr_buf_ptr = haddr_buf_ptr; - udata.u = 0; + udata.u = 0; /* Free all the candidate list entries, building the address list in the callback */ - if(H5SL_free(aux_ptr->candidate_slist_ptr, H5AC__copy_candidate_list_to_buffer_cb, &udata) < 0) + if (H5SL_free(aux_ptr->candidate_slist_ptr, H5AC__copy_candidate_list_to_buffer_cb, &udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "Can't build address list for candidate entries") /* Pass the number of entries and the buffer pointer * back to the caller. */ - *num_entries_ptr = num_entries; + *num_entries_ptr = num_entries; *haddr_buf_ptr_ptr = haddr_buf_ptr; done: - if(ret_value < 0) - if(haddr_buf_ptr) + if (ret_value < 0) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__copy_candidate_list_to_buffer() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_deleted_entry() @@ -686,16 +667,16 @@ done: herr_t H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - H5AC_slist_entry_t * slist_entry_ptr = NULL; - haddr_t addr; + H5AC_t * cache_ptr; + H5AC_aux_t * aux_ptr; + H5AC_slist_entry_t *slist_entry_ptr = NULL; + haddr_t addr; FUNC_ENTER_PACKAGE_NOERR /* Sanity checks */ HDassert(entry_ptr); - addr = entry_ptr->addr; + addr = entry_ptr->addr; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); @@ -706,17 +687,16 @@ H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr) HDassert(aux_ptr->c_slist_ptr != NULL); /* if the entry appears in the dirtied entry slist, remove it. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) + if (NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); /* if the entry appears in the cleaned entry slist, remove it. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) + if (NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__log_deleted_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_dirtied_entry() @@ -741,9 +721,9 @@ H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr) herr_t H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -756,36 +736,37 @@ H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if(aux_ptr->mpi_rank == 0) { + if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; - haddr_t addr = entry_ptr->addr; + haddr_t addr = entry_ptr->addr; /* Sanity checks */ HDassert(aux_ptr->d_slist_ptr != NULL); HDassert(aux_ptr->c_slist_ptr != NULL); - if(NULL == H5SL_search(aux_ptr->d_slist_ptr, (void *)(&addr))) { + if (NULL == H5SL_search(aux_ptr->d_slist_ptr, (void *)(&addr))) { /* insert the address of the entry in the dirty entry list, and * add its size to the dirty_bytes count. */ - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate dirty slist entry .") - slist_entry_ptr->addr = addr; + slist_entry_ptr->addr = addr; - if(H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + if (H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into dirty entry slist.") aux_ptr->dirty_bytes += entry_ptr->size; #if H5AC_DEBUG_DIRTY_BYTES_CREATION - aux_ptr->unprotect_dirty_bytes += entry_ptr->size; - aux_ptr->unprotect_dirty_bytes_updates += 1; -#endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ + aux_ptr->unprotect_dirty_bytes += entry_ptr->size; + aux_ptr->unprotect_dirty_bytes_updates += 1; +#endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ } /* end if */ /* the entry is dirty. If it exists on the cleaned entries list, * remove it. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); } /* end if */ else { @@ -794,13 +775,12 @@ H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) aux_ptr->unprotect_dirty_bytes += entry_size; aux_ptr->unprotect_dirty_bytes_updates += 1; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__log_dirtied_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_cleaned_entry() @@ -819,8 +799,8 @@ done: herr_t H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; FUNC_ENTER_PACKAGE_NOERR @@ -833,18 +813,20 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if(aux_ptr->mpi_rank == 0) { + if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; - haddr_t addr = entry_ptr->addr; + haddr_t addr = entry_ptr->addr; /* Sanity checks */ HDassert(aux_ptr->d_slist_ptr != NULL); HDassert(aux_ptr->c_slist_ptr != NULL); /* Remove it from both the cleaned list and the dirtied list. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); } /* end if */ @@ -855,7 +837,6 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__log_cleaned_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_flushed_entry() @@ -878,13 +859,12 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) *------------------------------------------------------------------------- */ herr_t -H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, - unsigned flags) +H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, unsigned flags) { - hbool_t cleared; - H5AC_aux_t * aux_ptr; - H5AC_slist_entry_t * slist_entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t cleared; + H5AC_aux_t * aux_ptr; + H5AC_slist_entry_t *slist_entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -899,32 +879,33 @@ H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, /* Set local flags */ cleared = ((flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); - if(cleared) { + if (cleared) { /* If the entry has been cleared, must remove it from both the * cleaned list and the dirtied list. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); } /* end if */ - else if(was_dirty) { - if(NULL == H5SL_search(aux_ptr->c_slist_ptr, (void *)(&addr))) { + else if (was_dirty) { + if (NULL == H5SL_search(aux_ptr->c_slist_ptr, (void *)(&addr))) { /* insert the address of the entry in the clean entry list. */ - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate clean slist entry .") slist_entry_ptr->addr = addr; - if(H5SL_insert(aux_ptr->c_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + if (H5SL_insert(aux_ptr->c_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into clean entry slist.") } /* end if */ - } /* end else-if */ + } /* end else-if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__log_flushed_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_inserted_entry() @@ -948,9 +929,9 @@ done: herr_t H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -962,27 +943,27 @@ H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if(aux_ptr->mpi_rank == 0) { + if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; HDassert(aux_ptr->d_slist_ptr != NULL); HDassert(aux_ptr->c_slist_ptr != NULL); /* Entry to insert should not be in dirty list currently */ - if(NULL != H5SL_search(aux_ptr->d_slist_ptr, (const void *)(&entry_ptr->addr))) + if (NULL != H5SL_search(aux_ptr->d_slist_ptr, (const void *)(&entry_ptr->addr))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Inserted entry already in dirty slist.") /* insert the address of the entry in the dirty entry list, and * add its size to the dirty_bytes count. */ - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate dirty slist entry .") - slist_entry_ptr->addr = entry_ptr->addr; - if(H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + slist_entry_ptr->addr = entry_ptr->addr; + if (H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into dirty entry slist.") /* Entry to insert should not be in clean list either */ - if(NULL != H5SL_search(aux_ptr->c_slist_ptr, (const void *)(&entry_ptr->addr))) + if (NULL != H5SL_search(aux_ptr->c_slist_ptr, (const void *)(&entry_ptr->addr))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Inserted entry in clean slist.") } /* end if */ @@ -997,7 +978,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__log_inserted_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_moved_entry() @@ -1047,12 +1027,12 @@ done: herr_t H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - hbool_t entry_in_cache; - hbool_t entry_dirty; - size_t entry_size; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + hbool_t entry_in_cache; + hbool_t entry_dirty; + size_t entry_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1066,14 +1046,14 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); /* get entry status, size, etc here */ - if(H5C_get_entry_status(f, old_addr, &entry_size, &entry_in_cache, - &entry_dirty, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5C_get_entry_status(f, old_addr, &entry_size, &entry_in_cache, &entry_dirty, NULL, NULL, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get entry status.") - if(!entry_in_cache) + if (!entry_in_cache) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry not in cache.") - if(aux_ptr->mpi_rank == 0) { - H5AC_slist_entry_t * slist_entry_ptr; + if (aux_ptr->mpi_rank == 0) { + H5AC_slist_entry_t *slist_entry_ptr; HDassert(aux_ptr->d_slist_ptr != NULL); HDassert(aux_ptr->c_slist_ptr != NULL); @@ -1081,24 +1061,26 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) /* if the entry appears in the cleaned entry slist, under its old * address, remove it. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&old_addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&old_addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); /* if the entry appears in the dirtied entry slist under its old * address, remove it, but don't free it. Set addr to new_addr. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&old_addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&old_addr)))) slist_entry_ptr->addr = new_addr; else { - /* otherwise, allocate a new entry that is ready - * for insertion, and increment dirty_bytes. - * - * Note that the fact that the entry wasn't in the dirtied - * list under its old address implies that it must have - * been clean to start with. - */ + /* otherwise, allocate a new entry that is ready + * for insertion, and increment dirty_bytes. + * + * Note that the fact that the entry wasn't in the dirtied + * list under its old address implies that it must have + * been clean to start with. + */ HDassert(!entry_dirty); - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate dirty slist entry .") slist_entry_ptr->addr = new_addr; @@ -1107,27 +1089,26 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) #if H5AC_DEBUG_DIRTY_BYTES_CREATION aux_ptr->move_dirty_bytes += entry_size; aux_ptr->move_dirty_bytes_updates += 1; -#endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ +#endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ } /* end else */ /* insert / reinsert the entry in the dirty slist */ - if(H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + if (H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into dirty entry slist.") } /* end if */ - else if(!entry_dirty) { + else if (!entry_dirty) { aux_ptr->dirty_bytes += entry_size; #if H5AC_DEBUG_DIRTY_BYTES_CREATION aux_ptr->move_dirty_bytes += entry_size; aux_ptr->move_dirty_bytes_updates += 1; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - } /* end else-if */ + } /* end else-if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__log_moved_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC__propagate_and_apply_candidate_list * @@ -1224,14 +1205,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__propagate_and_apply_candidate_list(H5F_t *f) +H5AC__propagate_and_apply_candidate_list(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - haddr_t * candidates_list_ptr = NULL; - int mpi_result; - unsigned num_candidates = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + haddr_t * candidates_list_ptr = NULL; + int mpi_result; + unsigned num_candidates = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1247,22 +1228,22 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) /* to prevent "messages from the future" we must synchronize all * processes before we write any entries. */ - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - if(aux_ptr->mpi_rank == 0) { - if(H5AC__broadcast_candidate_list(cache_ptr, &num_candidates, &candidates_list_ptr) < 0) + if (aux_ptr->mpi_rank == 0) { + if (H5AC__broadcast_candidate_list(cache_ptr, &num_candidates, &candidates_list_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't broadcast candidate slist.") HDassert(H5SL_count(aux_ptr->candidate_slist_ptr) == 0); } /* end if */ else { - if(H5AC__receive_candidate_list(cache_ptr, &num_candidates, &candidates_list_ptr) < 0) + if (H5AC__receive_candidate_list(cache_ptr, &num_candidates, &candidates_list_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't receive candidate broadcast.") } /* end else */ - if(num_candidates > 0) { - herr_t result; + if (num_candidates > 0) { + herr_t result; /* all processes apply the candidate list. * H5C_apply_candidate_list() handles the details of @@ -1273,34 +1254,34 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) aux_ptr->write_permitted = TRUE; /* Apply the candidate list */ - result = H5C_apply_candidate_list(f, cache_ptr, num_candidates, - candidates_list_ptr, aux_ptr->mpi_rank, aux_ptr->mpi_size); + result = H5C_apply_candidate_list(f, cache_ptr, num_candidates, candidates_list_ptr, + aux_ptr->mpi_rank, aux_ptr->mpi_size); /* Disable writes again */ aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't apply candidate list.") /* this code exists primarily for the test bed -- it allows us to * enforce posix semantics on the server that pretends to be a * file system in our parallel tests. */ - if(aux_ptr->write_done) - (aux_ptr->write_done)(); + if (aux_ptr->write_done) + (aux_ptr->write_done)(); /* to prevent "messages from the past" we must synchronize all * processes again before we go on. */ - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - /* if this is process zero, tidy up the dirtied, + /* if this is process zero, tidy up the dirtied, * and flushed and still clean lists. */ - if(aux_ptr->mpi_rank == 0) - if(H5AC__tidy_cache_0_lists(cache_ptr, num_candidates, candidates_list_ptr) < 0) + if (aux_ptr->mpi_rank == 0) + if (H5AC__tidy_cache_0_lists(cache_ptr, num_candidates, candidates_list_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't tidy up process 0 lists.") } /* end if */ @@ -1308,17 +1289,16 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) * that this callback is defined purely for testing purposes, * and should be undefined under normal operating circumstances. */ - if(aux_ptr->sync_point_done) + if (aux_ptr->sync_point_done) (aux_ptr->sync_point_done)(num_candidates, candidates_list_ptr); done: - if(candidates_list_ptr) + if (candidates_list_ptr) candidates_list_ptr = (haddr_t *)H5MM_xfree((void *)candidates_list_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__propagate_and_apply_candidate_list() */ - /*------------------------------------------------------------------------- * Function: H5AC__propagate_flushed_and_still_clean_entries_list * @@ -1391,11 +1371,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) +H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1408,20 +1388,18 @@ H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); - if(aux_ptr->mpi_rank == 0) { - if(H5AC__broadcast_clean_list(cache_ptr) < 0) + if (aux_ptr->mpi_rank == 0) { + if (H5AC__broadcast_clean_list(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't broadcast clean slist.") HDassert(H5SL_count(aux_ptr->c_slist_ptr) == 0); } /* end if */ - else - if(H5AC__receive_and_apply_clean_list(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't receive and/or process clean slist broadcast.") + else if (H5AC__receive_and_apply_clean_list(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't receive and/or process clean slist broadcast.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__propagate_flushed_and_still_clean_entries_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__receive_haddr_list() @@ -1443,13 +1421,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr) +H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr) { - haddr_t * haddr_buf_ptr = NULL; - int mpi_result; - unsigned num_entries; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t *haddr_buf_ptr = NULL; + int mpi_result; + unsigned num_entries; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1463,37 +1440,37 @@ H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, * can set up a buffer to receive them. If there aren't * any, we are done. */ - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - if(num_entries > 0) { + if (num_entries > 0) { size_t buf_size; /* allocate buffers to store the list of entry base addresses in */ buf_size = sizeof(haddr_t) * num_entries; - if(NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) + if (NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for haddr buffer") /* Now receive the list of candidate entries */ - if(MPI_SUCCESS != (mpi_result = MPI_Bcast((void *)haddr_buf_ptr, (int)buf_size, MPI_BYTE, 0, mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast((void *)haddr_buf_ptr, (int)buf_size, MPI_BYTE, 0, mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) } /* end if */ /* finally, pass the number of entries and the buffer pointer * back to the caller. */ - *num_entries_ptr = num_entries; + *num_entries_ptr = num_entries; *haddr_buf_ptr_ptr = haddr_buf_ptr; done: - if(ret_value < 0) - if(haddr_buf_ptr) + if (ret_value < 0) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__receive_haddr_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__receive_and_apply_clean_list() @@ -1515,11 +1492,11 @@ done: static herr_t H5AC__receive_and_apply_clean_list(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - haddr_t * haddr_buf_ptr = NULL; - unsigned num_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + haddr_t * haddr_buf_ptr = NULL; + unsigned num_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1533,29 +1510,28 @@ H5AC__receive_and_apply_clean_list(H5F_t *f) HDassert(aux_ptr->mpi_rank != 0); /* Retrieve the clean list from process 0 */ - if(H5AC__receive_haddr_list(aux_ptr->mpi_comm, &num_entries, &haddr_buf_ptr) < 0) + if (H5AC__receive_haddr_list(aux_ptr->mpi_comm, &num_entries, &haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't receive clean list") - if(num_entries > 0) + if (num_entries > 0) /* mark the indicated entries as clean */ - if(H5C_mark_entries_as_clean(f, num_entries, haddr_buf_ptr) < 0) + if (H5C_mark_entries_as_clean(f, num_entries, haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't mark entries clean.") /* if it is defined, call the sync point done callback. Note * that this callback is defined purely for testing purposes, * and should be undefined under normal operating circumstances. */ - if(aux_ptr->sync_point_done) + if (aux_ptr->sync_point_done) (aux_ptr->sync_point_done)(num_entries, haddr_buf_ptr); done: - if(haddr_buf_ptr) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__receive_and_apply_clean_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__receive_candidate_list() @@ -1577,11 +1553,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr) +H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr) { - H5AC_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1591,21 +1566,20 @@ H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->mpi_rank != 0); - HDassert(aux_ptr-> metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); + HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); HDassert(num_entries_ptr != NULL); HDassert(*num_entries_ptr == 0); HDassert(haddr_buf_ptr_ptr != NULL); HDassert(*haddr_buf_ptr_ptr == NULL); /* Retrieve the candidate list from process 0 */ - if(H5AC__receive_haddr_list(aux_ptr->mpi_comm, num_entries_ptr, haddr_buf_ptr_ptr) < 0) + if (H5AC__receive_haddr_list(aux_ptr->mpi_comm, num_entries_ptr, haddr_buf_ptr_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't receive clean list") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__receive_candidate_list() */ - /*------------------------------------------------------------------------- * Function: H5AC__rsp__dist_md_write__flush * @@ -1658,12 +1632,12 @@ done: static herr_t H5AC__rsp__dist_md_write__flush(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - haddr_t * haddr_buf_ptr = NULL; - int mpi_result; - unsigned num_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + haddr_t * haddr_buf_ptr = NULL; + int mpi_result; + unsigned num_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1679,16 +1653,16 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f) /* first construct the candidate list -- initially, this will be in the * form of a skip list. We will convert it later. */ - if(H5C_construct_candidate_list__clean_cache(cache_ptr) < 0) + if (H5C_construct_candidate_list__clean_cache(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate list.") - if(H5SL_count(aux_ptr->candidate_slist_ptr) > 0) { - herr_t result; + if (H5SL_count(aux_ptr->candidate_slist_ptr) > 0) { + herr_t result; /* convert the candidate list into the format we * are used to receiving from process 0. */ - if(H5AC__copy_candidate_list_to_buffer(cache_ptr, &num_entries, &haddr_buf_ptr) < 0) + if (H5AC__copy_candidate_list_to_buffer(cache_ptr, &num_entries, &haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate buffer.") /* Initial sync point barrier @@ -1696,40 +1670,40 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f) * When flushing from within the close operation from a file, * it's possible to skip this barrier (on the second flush of the cache). */ - if(!H5CX_get_mpi_file_flushing()) - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (!H5CX_get_mpi_file_flushing()) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) /* Enable writes during this operation */ aux_ptr->write_permitted = TRUE; /* Apply the candidate list */ - result = H5C_apply_candidate_list(f, cache_ptr, num_entries, - haddr_buf_ptr, aux_ptr->mpi_rank, aux_ptr->mpi_size); + result = H5C_apply_candidate_list(f, cache_ptr, num_entries, haddr_buf_ptr, aux_ptr->mpi_rank, + aux_ptr->mpi_size); /* Disable writes again */ aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't apply candidate list.") /* this code exists primarily for the test bed -- it allows us to * enforce posix semantics on the server that pretends to be a * file system in our parallel tests. */ - if(aux_ptr->write_done) + if (aux_ptr->write_done) (aux_ptr->write_done)(); /* final sync point barrier */ - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - /* if this is process zero, tidy up the dirtied, + /* if this is process zero, tidy up the dirtied, * and flushed and still clean lists. */ - if(aux_ptr->mpi_rank == 0) - if(H5AC__tidy_cache_0_lists(cache_ptr, num_entries, haddr_buf_ptr) < 0) + if (aux_ptr->mpi_rank == 0) + if (H5AC__tidy_cache_0_lists(cache_ptr, num_entries, haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't tidy up process 0 lists.") } /* end if */ @@ -1737,17 +1711,16 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f) * that this callback is defined purely for testing purposes, * and should be undefined under normal operating circumstances. */ - if(aux_ptr->sync_point_done) + if (aux_ptr->sync_point_done) (aux_ptr->sync_point_done)(num_entries, haddr_buf_ptr); done: - if(haddr_buf_ptr) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__rsp__dist_md_write__flush() */ - /*------------------------------------------------------------------------- * Function: H5AC__rsp__dist_md_write__flush_to_min_clean * @@ -1805,10 +1778,10 @@ done: static herr_t H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - hbool_t evictions_enabled; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + hbool_t evictions_enabled; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1822,17 +1795,18 @@ H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); /* Query if evictions are allowed */ - if(H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) + if (H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_get_evictions_enabled() failed.") - if(evictions_enabled) { + if (evictions_enabled) { /* construct candidate list -- process 0 only */ - if(aux_ptr->mpi_rank == 0) - if(H5AC__construct_candidate_list(cache_ptr, aux_ptr, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) + if (aux_ptr->mpi_rank == 0) + if (H5AC__construct_candidate_list(cache_ptr, aux_ptr, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < + 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate list.") /* propagate and apply candidate list -- all processes */ - if(H5AC__propagate_and_apply_candidate_list(f) < 0) + if (H5AC__propagate_and_apply_candidate_list(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't propagate and apply candidate list.") } /* evictions enabled */ @@ -1840,7 +1814,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__rsp__dist_md_write__flush_to_min_clean() */ - /*------------------------------------------------------------------------- * Function: H5AC__rsp__p0_only__flush * @@ -1880,10 +1853,10 @@ done: static herr_t H5AC__rsp__p0_only__flush(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - int mpi_result; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + int mpi_result; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1903,13 +1876,13 @@ H5AC__rsp__p0_only__flush(H5F_t *f) * However, when flushing from within the close operation from a file, * it's possible to skip this barrier (on the second flush of the cache). */ - if(!H5CX_get_mpi_file_flushing()) - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (!H5CX_get_mpi_file_flushing()) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) /* Flush data to disk, from rank 0 process */ - if(aux_ptr->mpi_rank == 0) { - herr_t result; + if (aux_ptr->mpi_rank == 0) { + herr_t result; /* Enable writes during this operation */ aux_ptr->write_permitted = TRUE; @@ -1921,26 +1894,25 @@ H5AC__rsp__p0_only__flush(H5F_t *f) aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush.") /* this code exists primarily for the test bed -- it allows us to * enforce POSIX semantics on the server that pretends to be a * file system in our parallel tests. */ - if(aux_ptr->write_done) + if (aux_ptr->write_done) (aux_ptr->write_done)(); } /* end if */ /* Propagate cleaned entries to other ranks. */ - if(H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0) + if (H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't propagate clean entries list.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__rsp__p0_only__flush() */ - /*------------------------------------------------------------------------- * Function: H5AC__rsp__p0_only__flush_to_min_clean * @@ -1986,10 +1958,10 @@ done: static herr_t H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - hbool_t evictions_enabled; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + hbool_t evictions_enabled; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2003,7 +1975,7 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); /* Query if evictions are allowed */ - if(H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) + if (H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_get_evictions_enabled() failed.") /* Flush if evictions are allowed -- following call @@ -2013,18 +1985,18 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) * * Otherwise, do nothing. */ - if(evictions_enabled) { - int mpi_result; + if (evictions_enabled) { + int mpi_result; /* to prevent "messages from the future" we must synchronize all * processes before we start the flush. This synchronization may * already be done -- hence the do_barrier parameter. */ - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - if(0 == aux_ptr->mpi_rank) { - herr_t result; + if (0 == aux_ptr->mpi_rank) { + herr_t result; /* here, process 0 flushes as many entries as necessary to * comply with the currently specified min clean size. @@ -2042,18 +2014,18 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_flush_to_min_clean() failed.") /* this call exists primarily for the test code -- it is used - * to enforce POSIX semantics on the process used to simulate - * reads and writes in t_cache.c. + * to enforce POSIX semantics on the process used to simulate + * reads and writes in t_cache.c. */ - if(aux_ptr->write_done) + if (aux_ptr->write_done) (aux_ptr->write_done)(); } /* end if */ - if(H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0) + if (H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't propagate clean entries list.") } /* end if */ @@ -2061,7 +2033,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__rsp__p0_only__flush_to_min_clean() */ - /*------------------------------------------------------------------------- * Function: H5AC__run_sync_point * @@ -2096,9 +2067,9 @@ done: herr_t H5AC__run_sync_point(H5F_t *f, int sync_point_op) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2110,18 +2081,14 @@ H5AC__run_sync_point(H5F_t *f, int sync_point_op) HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) || - (sync_point_op == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)); + (sync_point_op == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)); #if H5AC_DEBUG_DIRTY_BYTES_CREATION -HDfprintf(stdout, "%d:H5AC_propagate...:%u: (u/uu/i/iu/r/ru) = %zu/%u/%zu/%u/%zu/%u\n", - aux_ptr->mpi_rank, - aux_ptr->dirty_bytes_propagations, - aux_ptr->unprotect_dirty_bytes, - aux_ptr->unprotect_dirty_bytes_updates, - aux_ptr->insert_dirty_bytes, - aux_ptr->insert_dirty_bytes_updates, - aux_ptr->rename_dirty_bytes, - aux_ptr->rename_dirty_bytes_updates); + HDfprintf(stdout, "%d:H5AC_propagate...:%u: (u/uu/i/iu/r/ru) = %zu/%u/%zu/%u/%zu/%u\n", aux_ptr->mpi_rank, + aux_ptr->dirty_bytes_propagations, aux_ptr->unprotect_dirty_bytes, + aux_ptr->unprotect_dirty_bytes_updates, aux_ptr->insert_dirty_bytes, + aux_ptr->insert_dirty_bytes_updates, aux_ptr->rename_dirty_bytes, + aux_ptr->rename_dirty_bytes_updates); #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ /* clear collective access flag on half of the entries in the @@ -2129,56 +2096,58 @@ HDfprintf(stdout, "%d:H5AC_propagate...:%u: (u/uu/i/iu/r/ru) = %zu/%u/%zu/%u/%zu evicted later. All ranks are guaranteed to mark the same entries since we don't modify the order of the collectively accessed entries except through collective access. */ - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed.") - switch(aux_ptr->metadata_write_strategy) { + switch (aux_ptr->metadata_write_strategy) { case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - switch(sync_point_op) { + switch (sync_point_op) { case H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN: - if(H5AC__rsp__p0_only__flush_to_min_clean(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5AC__rsp__p0_only__flush_to_min_clean() failed.") - break; + if (H5AC__rsp__p0_only__flush_to_min_clean(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, + "H5AC__rsp__p0_only__flush_to_min_clean() failed.") + break; - case H5AC_SYNC_POINT_OP__FLUSH_CACHE: - if(H5AC__rsp__p0_only__flush(f) < 0) + case H5AC_SYNC_POINT_OP__FLUSH_CACHE: + if (H5AC__rsp__p0_only__flush(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5AC__rsp__p0_only__flush() failed.") - break; + break; - default: + default: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown flush op"); - break; - } /* end switch */ - break; + break; + } /* end switch */ + break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: - switch(sync_point_op) { + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + switch (sync_point_op) { case H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN: - if(H5AC__rsp__dist_md_write__flush_to_min_clean(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5AC__rsp__dist_md_write__flush_to_min_clean() failed.") - break; + if (H5AC__rsp__dist_md_write__flush_to_min_clean(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, + "H5AC__rsp__dist_md_write__flush_to_min_clean() failed.") + break; - case H5AC_SYNC_POINT_OP__FLUSH_CACHE: - if(H5AC__rsp__dist_md_write__flush(f) < 0) + case H5AC_SYNC_POINT_OP__FLUSH_CACHE: + if (H5AC__rsp__dist_md_write__flush(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5AC__rsp__dist_md_write__flush() failed.") - break; + break; - default: + default: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown flush op"); - break; - } /* end switch */ - break; + break; + } /* end switch */ + break; - default: + default: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown metadata write strategy.") - break; + break; } /* end switch */ /* reset the dirty bytes count */ aux_ptr->dirty_bytes = 0; #if H5AC_DEBUG_DIRTY_BYTES_CREATION - aux_ptr->dirty_bytes_propagations += 1; + aux_ptr->dirty_bytes_propagations += 1; aux_ptr->unprotect_dirty_bytes = 0; aux_ptr->unprotect_dirty_bytes_updates = 0; aux_ptr->insert_dirty_bytes = 0; @@ -2191,7 +2160,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__run_sync_point() */ - /*------------------------------------------------------------------------- * Function: H5AC__tidy_cache_0_lists() * @@ -2228,11 +2196,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, - haddr_t *candidates_list_ptr) +H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, haddr_t *candidates_list_ptr) { - H5AC_aux_t * aux_ptr; - unsigned u; + H5AC_aux_t *aux_ptr; + unsigned u; FUNC_ENTER_STATIC_NOERR @@ -2253,26 +2220,27 @@ H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, * cleaned list. However, for this metadata write strategy, * we just want to remove all references to the candidate entries. */ - for(u = 0; u < num_candidates; u++) { - H5AC_slist_entry_t * d_slist_entry_ptr; - H5AC_slist_entry_t * c_slist_entry_ptr; - haddr_t addr; + for (u = 0; u < num_candidates; u++) { + H5AC_slist_entry_t *d_slist_entry_ptr; + H5AC_slist_entry_t *c_slist_entry_ptr; + haddr_t addr; addr = candidates_list_ptr[u]; /* addr may be either on the dirtied list, or on the flushed * and still clean list. Remove it. */ - if(NULL != (d_slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)&addr))) + if (NULL != + (d_slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)&addr))) d_slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, d_slist_entry_ptr); - if(NULL != (c_slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)&addr))) + if (NULL != + (c_slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)&addr))) c_slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, c_slist_entry_ptr); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__tidy_cache_0_lists() */ - /*------------------------------------------------------------------------- * Function: H5AC__flush_entries * @@ -2292,7 +2260,7 @@ H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, herr_t H5AC__flush_entries(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2301,12 +2269,11 @@ H5AC__flush_entries(H5F_t *f) HDassert(f->shared->cache); /* Check if we have >1 ranks */ - if(H5C_get_aux_ptr(f->shared->cache)) - if(H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_CACHE) < 0) + if (H5C_get_aux_ptr(f->shared->cache)) + if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_CACHE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__flush_entries() */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 86ff385..5ec364a 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -34,12 +34,11 @@ #define _H5ACpkg_H /* Get package's private header */ -#include "H5ACprivate.h" /* Metadata cache */ - +#include "H5ACprivate.h" /* Metadata cache */ /* Get needed headers */ -#include "H5Cprivate.h" /* Cache */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Cprivate.h" /* Cache */ +#include "H5FLprivate.h" /* Free Lists */ /*****************************/ /* Package Private Variables */ @@ -48,12 +47,11 @@ /* Declare extern the free list to manage the H5AC_aux_t struct */ H5FL_EXTERN(H5AC_aux_t); - /**************************/ /* Package Private Macros */ /**************************/ -#define H5AC_DEBUG_DIRTY_BYTES_CREATION 0 +#define H5AC_DEBUG_DIRTY_BYTES_CREATION 0 #ifdef H5_HAVE_PARALLEL @@ -61,8 +59,8 @@ H5FL_EXTERN(H5AC_aux_t); * at a sync point. */ -#define H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN 0 -#define H5AC_SYNC_POINT_OP__FLUSH_CACHE 1 +#define H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN 0 +#define H5AC_SYNC_POINT_OP__FLUSH_CACHE 1 #endif /* H5_HAVE_PARALLEL */ @@ -73,12 +71,9 @@ H5FL_EXTERN(H5AC_aux_t); *------------------------------------------------------------------------- */ -#define H5AC__MIN_DIRTY_BYTES_THRESHOLD (size_t) \ - (H5C__MIN_MAX_CACHE_SIZE / 2) -#define H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD (256 * 1024) -#define H5AC__MAX_DIRTY_BYTES_THRESHOLD (size_t) \ - (H5C__MAX_MAX_CACHE_SIZE / 4) - +#define H5AC__MIN_DIRTY_BYTES_THRESHOLD (size_t)(H5C__MIN_MAX_CACHE_SIZE / 2) +#define H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD (256 * 1024) +#define H5AC__MAX_DIRTY_BYTES_THRESHOLD (size_t)(H5C__MAX_MAX_CACHE_SIZE / 4) /**************************************************************************** * @@ -359,57 +354,54 @@ H5FL_EXTERN(H5AC_aux_t); #ifdef H5_HAVE_PARALLEL -#define H5AC__H5AC_AUX_T_MAGIC (unsigned)0x00D0A01 +#define H5AC__H5AC_AUX_T_MAGIC (unsigned)0x00D0A01 -typedef struct H5AC_aux_t -{ - uint32_t magic; +typedef struct H5AC_aux_t { + uint32_t magic; - MPI_Comm mpi_comm; + MPI_Comm mpi_comm; - int mpi_rank; + int mpi_rank; - int mpi_size; + int mpi_size; - hbool_t write_permitted; + hbool_t write_permitted; - size_t dirty_bytes_threshold; + size_t dirty_bytes_threshold; - size_t dirty_bytes; + size_t dirty_bytes; - int32_t metadata_write_strategy; + int32_t metadata_write_strategy; #if H5AC_DEBUG_DIRTY_BYTES_CREATION - unsigned dirty_bytes_propagations; + unsigned dirty_bytes_propagations; - size_t unprotect_dirty_bytes; - unsigned unprotect_dirty_bytes_updates; + size_t unprotect_dirty_bytes; + unsigned unprotect_dirty_bytes_updates; - size_t insert_dirty_bytes; - unsigned insert_dirty_bytes_updates; + size_t insert_dirty_bytes; + unsigned insert_dirty_bytes_updates; - size_t move_dirty_bytes; - unsigned move_dirty_bytes_updates; + size_t move_dirty_bytes; + unsigned move_dirty_bytes_updates; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - H5SL_t * d_slist_ptr; + H5SL_t *d_slist_ptr; - H5SL_t * c_slist_ptr; + H5SL_t *c_slist_ptr; - H5SL_t * candidate_slist_ptr; + H5SL_t *candidate_slist_ptr; - void (* write_done)(void); + void (*write_done)(void); - void (* sync_point_done)(unsigned num_writes, - haddr_t * written_entries_tbl); + void (*sync_point_done)(unsigned num_writes, haddr_t *written_entries_tbl); - unsigned p0_image_len; + unsigned p0_image_len; } H5AC_aux_t; /* struct H5AC_aux_t */ -#endif /* H5_HAVE_PARALLEL */ - +#endif /* H5_HAVE_PARALLEL */ /******************************/ /* Package Private Prototypes */ @@ -420,18 +412,15 @@ typedef struct H5AC_aux_t H5_DLL herr_t H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr); H5_DLL herr_t H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr); H5_DLL herr_t H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr); -H5_DLL herr_t H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, - hbool_t was_dirty, unsigned flags); +H5_DLL herr_t H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, unsigned flags); H5_DLL herr_t H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr); -H5_DLL herr_t H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, - haddr_t new_addr); +H5_DLL herr_t H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr); H5_DLL herr_t H5AC__flush_entries(H5F_t *f); H5_DLL herr_t H5AC__run_sync_point(H5F_t *f, int sync_point_op); H5_DLL herr_t H5AC__set_sync_point_done_callback(H5C_t *cache_ptr, - void (*sync_point_done)(unsigned num_writes, haddr_t *written_entries_tbl)); -H5_DLL herr_t H5AC__set_write_done_callback(H5C_t * cache_ptr, - void (* write_done)(void)); + void (*sync_point_done)(unsigned num_writes, + haddr_t *written_entries_tbl)); +H5_DLL herr_t H5AC__set_write_done_callback(H5C_t *cache_ptr, void (*write_done)(void)); #endif /* H5_HAVE_PARALLEL */ #endif /* _H5ACpkg_H */ - diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 7010a60..35df4e4 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -26,57 +26,57 @@ #ifndef _H5ACprivate_H #define _H5ACprivate_H -#include "H5ACpublic.h" /*public prototypes */ +#include "H5ACpublic.h" /*public prototypes */ /* Pivate headers needed by this header */ -#include "H5private.h" /* Generic Functions */ -#include "H5Cprivate.h" /* Cache */ -#include "H5Fprivate.h" /* File access */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Cprivate.h" /* Cache */ +#include "H5Fprivate.h" /* File access */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip lists */ /* Global metadata tag values */ -#define H5AC__INVALID_TAG (haddr_t)0 -#define H5AC__IGNORE_TAG (haddr_t)1 -#define H5AC__COPIED_TAG (haddr_t)2 -#define H5AC__SUPERBLOCK_TAG (haddr_t)3 -#define H5AC__FREESPACE_TAG (haddr_t)4 -#define H5AC__SOHM_TAG (haddr_t)5 -#define H5AC__GLOBALHEAP_TAG (haddr_t)6 +#define H5AC__INVALID_TAG (haddr_t)0 +#define H5AC__IGNORE_TAG (haddr_t)1 +#define H5AC__COPIED_TAG (haddr_t)2 +#define H5AC__SUPERBLOCK_TAG (haddr_t)3 +#define H5AC__FREESPACE_TAG (haddr_t)4 +#define H5AC__SOHM_TAG (haddr_t)5 +#define H5AC__GLOBALHEAP_TAG (haddr_t)6 /* Types of metadata objects cached */ typedef enum { - H5AC_BT_ID = 0, /* ( 0) B-tree nodes */ - H5AC_SNODE_ID, /* ( 1) symbol table nodes */ - H5AC_LHEAP_PRFX_ID, /* ( 2) local heap prefix */ - H5AC_LHEAP_DBLK_ID, /* ( 3) local heap data block */ - H5AC_GHEAP_ID, /* ( 4) global heap */ - H5AC_OHDR_ID, /* ( 5) object header */ - H5AC_OHDR_CHK_ID, /* ( 6) object header chunk */ - H5AC_BT2_HDR_ID, /* ( 7) v2 B-tree header */ - H5AC_BT2_INT_ID, /* ( 8) v2 B-tree internal node */ - H5AC_BT2_LEAF_ID, /* ( 9) v2 B-tree leaf node */ - H5AC_FHEAP_HDR_ID, /* (10) fractal heap header */ - H5AC_FHEAP_DBLOCK_ID, /* (11) fractal heap direct block */ - H5AC_FHEAP_IBLOCK_ID, /* (12) fractal heap indirect block */ - H5AC_FSPACE_HDR_ID, /* (13) free space header */ - H5AC_FSPACE_SINFO_ID, /* (14) free space sections */ - H5AC_SOHM_TABLE_ID, /* (15) shared object header message master table */ - H5AC_SOHM_LIST_ID, /* (16) shared message index stored as a list */ - H5AC_EARRAY_HDR_ID, /* (17) extensible array header */ - H5AC_EARRAY_IBLOCK_ID, /* (18) extensible array index block */ - H5AC_EARRAY_SBLOCK_ID, /* (19) extensible array super block */ - H5AC_EARRAY_DBLOCK_ID, /* (20) extensible array data block */ - H5AC_EARRAY_DBLK_PAGE_ID, /* (21) extensible array data block page */ - H5AC_FARRAY_HDR_ID, /* (22) fixed array header */ - H5AC_FARRAY_DBLOCK_ID, /* (23) fixed array data block */ - H5AC_FARRAY_DBLK_PAGE_ID, /* (24) fixed array data block page */ - H5AC_SUPERBLOCK_ID, /* (25) file superblock */ - H5AC_DRVRINFO_ID, /* (26) driver info block (supplements superblock) */ - H5AC_EPOCH_MARKER_ID, /* (27) epoch marker - always internal to cache */ - H5AC_PROXY_ENTRY_ID, /* (28) cache entry proxy */ - H5AC_PREFETCHED_ENTRY_ID, /* (29) prefetched entry - always internal to cache */ - H5AC_NTYPES /* Number of types, must be last */ + H5AC_BT_ID = 0, /* ( 0) B-tree nodes */ + H5AC_SNODE_ID, /* ( 1) symbol table nodes */ + H5AC_LHEAP_PRFX_ID, /* ( 2) local heap prefix */ + H5AC_LHEAP_DBLK_ID, /* ( 3) local heap data block */ + H5AC_GHEAP_ID, /* ( 4) global heap */ + H5AC_OHDR_ID, /* ( 5) object header */ + H5AC_OHDR_CHK_ID, /* ( 6) object header chunk */ + H5AC_BT2_HDR_ID, /* ( 7) v2 B-tree header */ + H5AC_BT2_INT_ID, /* ( 8) v2 B-tree internal node */ + H5AC_BT2_LEAF_ID, /* ( 9) v2 B-tree leaf node */ + H5AC_FHEAP_HDR_ID, /* (10) fractal heap header */ + H5AC_FHEAP_DBLOCK_ID, /* (11) fractal heap direct block */ + H5AC_FHEAP_IBLOCK_ID, /* (12) fractal heap indirect block */ + H5AC_FSPACE_HDR_ID, /* (13) free space header */ + H5AC_FSPACE_SINFO_ID, /* (14) free space sections */ + H5AC_SOHM_TABLE_ID, /* (15) shared object header message master table */ + H5AC_SOHM_LIST_ID, /* (16) shared message index stored as a list */ + H5AC_EARRAY_HDR_ID, /* (17) extensible array header */ + H5AC_EARRAY_IBLOCK_ID, /* (18) extensible array index block */ + H5AC_EARRAY_SBLOCK_ID, /* (19) extensible array super block */ + H5AC_EARRAY_DBLOCK_ID, /* (20) extensible array data block */ + H5AC_EARRAY_DBLK_PAGE_ID, /* (21) extensible array data block page */ + H5AC_FARRAY_HDR_ID, /* (22) fixed array header */ + H5AC_FARRAY_DBLOCK_ID, /* (23) fixed array data block */ + H5AC_FARRAY_DBLK_PAGE_ID, /* (24) fixed array data block page */ + H5AC_SUPERBLOCK_ID, /* (25) file superblock */ + H5AC_DRVRINFO_ID, /* (26) driver info block (supplements superblock) */ + H5AC_EPOCH_MARKER_ID, /* (27) epoch marker - always internal to cache */ + H5AC_PROXY_ENTRY_ID, /* (28) cache entry proxy */ + H5AC_PREFETCHED_ENTRY_ID, /* (29) prefetched entry - always internal to cache */ + H5AC_NTYPES /* Number of types, must be last */ } H5AC_type_t; /* H5AC_DUMP_STATS_ON_CLOSE should always be FALSE when @@ -107,13 +107,13 @@ typedef enum { */ #if H5C_COLLECT_CACHE_STATS -#define H5AC_DUMP_STATS_ON_CLOSE 0 -#define H5AC_DUMP_IMAGE_STATS_ON_CLOSE 0 +#define H5AC_DUMP_STATS_ON_CLOSE 0 +#define H5AC_DUMP_IMAGE_STATS_ON_CLOSE 0 #else /* H5C_COLLECT_CACHE_STATS */ -#define H5AC_DUMP_STATS_ON_CLOSE 0 -#define H5AC_DUMP_IMAGE_STATS_ON_CLOSE 0 +#define H5AC_DUMP_STATS_ON_CLOSE 0 +#define H5AC_DUMP_IMAGE_STATS_ON_CLOSE 0 #endif /* H5C_COLLECT_CACHE_STATS */ @@ -121,8 +121,8 @@ typedef enum { * At present, these are the same as those given in H5Cprivate.h. */ -#define H5AC__DEFAULT_MAX_CACHE_SIZE H5C__DEFAULT_MAX_CACHE_SIZE -#define H5AC__DEFAULT_MIN_CLEAN_SIZE H5C__DEFAULT_MIN_CLEAN_SIZE +#define H5AC__DEFAULT_MAX_CACHE_SIZE H5C__DEFAULT_MAX_CACHE_SIZE +#define H5AC__DEFAULT_MIN_CLEAN_SIZE H5C__DEFAULT_MIN_CLEAN_SIZE /* Check if we are sanity checking tagging */ #if H5C_DO_TAGGING_SANITY_CHECKS @@ -137,16 +137,16 @@ typedef enum { * to cache the object. */ -#define H5AC__SERIALIZE_RESIZED_FLAG H5C__SERIALIZE_RESIZED_FLAG -#define H5AC__SERIALIZE_MOVED_FLAG H5C__SERIALIZE_MOVED_FLAG +#define H5AC__SERIALIZE_RESIZED_FLAG H5C__SERIALIZE_RESIZED_FLAG +#define H5AC__SERIALIZE_MOVED_FLAG H5C__SERIALIZE_MOVED_FLAG /* Cork actions: cork/uncork/get cork status of an object */ -#define H5AC__SET_CORK H5C__SET_CORK -#define H5AC__UNCORK H5C__UNCORK -#define H5AC__GET_CORKED H5C__GET_CORKED +#define H5AC__SET_CORK H5C__SET_CORK +#define H5AC__UNCORK H5C__UNCORK +#define H5AC__GET_CORKED H5C__GET_CORKED /* Aliases for the "ring" type and values */ -typedef H5C_ring_t H5AC_ring_t; +typedef H5C_ring_t H5AC_ring_t; #define H5AC_RING_INV H5C_RING_UNDEFINED #define H5AC_RING_USER H5C_RING_USER #define H5AC_RING_RDFSM H5C_RING_RDFSM @@ -156,154 +156,146 @@ typedef H5C_ring_t H5AC_ring_t; #define H5AC_RING_NTYPES H5C_RING_NTYPES /* Aliases for 'notify action' type & values */ -typedef H5C_notify_action_t H5AC_notify_action_t; -#define H5AC_NOTIFY_ACTION_AFTER_INSERT H5C_NOTIFY_ACTION_AFTER_INSERT -#define H5AC_NOTIFY_ACTION_AFTER_LOAD H5C_NOTIFY_ACTION_AFTER_LOAD -#define H5AC_NOTIFY_ACTION_AFTER_FLUSH H5C_NOTIFY_ACTION_AFTER_FLUSH -#define H5AC_NOTIFY_ACTION_BEFORE_EVICT H5C_NOTIFY_ACTION_BEFORE_EVICT -#define H5AC_NOTIFY_ACTION_ENTRY_DIRTIED H5C_NOTIFY_ACTION_ENTRY_DIRTIED -#define H5AC_NOTIFY_ACTION_ENTRY_CLEANED H5C_NOTIFY_ACTION_ENTRY_CLEANED -#define H5AC_NOTIFY_ACTION_CHILD_DIRTIED H5C_NOTIFY_ACTION_CHILD_DIRTIED -#define H5AC_NOTIFY_ACTION_CHILD_CLEANED H5C_NOTIFY_ACTION_CHILD_CLEANED +typedef H5C_notify_action_t H5AC_notify_action_t; +#define H5AC_NOTIFY_ACTION_AFTER_INSERT H5C_NOTIFY_ACTION_AFTER_INSERT +#define H5AC_NOTIFY_ACTION_AFTER_LOAD H5C_NOTIFY_ACTION_AFTER_LOAD +#define H5AC_NOTIFY_ACTION_AFTER_FLUSH H5C_NOTIFY_ACTION_AFTER_FLUSH +#define H5AC_NOTIFY_ACTION_BEFORE_EVICT H5C_NOTIFY_ACTION_BEFORE_EVICT +#define H5AC_NOTIFY_ACTION_ENTRY_DIRTIED H5C_NOTIFY_ACTION_ENTRY_DIRTIED +#define H5AC_NOTIFY_ACTION_ENTRY_CLEANED H5C_NOTIFY_ACTION_ENTRY_CLEANED +#define H5AC_NOTIFY_ACTION_CHILD_DIRTIED H5C_NOTIFY_ACTION_CHILD_DIRTIED +#define H5AC_NOTIFY_ACTION_CHILD_CLEANED H5C_NOTIFY_ACTION_CHILD_CLEANED #define H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED -#define H5AC_NOTIFY_ACTION_CHILD_SERIALIZED H5C_NOTIFY_ACTION_CHILD_SERIALIZED +#define H5AC_NOTIFY_ACTION_CHILD_SERIALIZED H5C_NOTIFY_ACTION_CHILD_SERIALIZED -#define H5AC__CLASS_NO_FLAGS_SET H5C__CLASS_NO_FLAGS_SET +#define H5AC__CLASS_NO_FLAGS_SET H5C__CLASS_NO_FLAGS_SET #define H5AC__CLASS_SPECULATIVE_LOAD_FLAG H5C__CLASS_SPECULATIVE_LOAD_FLAG /* The following flags should only appear in test code */ -#define H5AC__CLASS_SKIP_READS H5C__CLASS_SKIP_READS -#define H5AC__CLASS_SKIP_WRITES H5C__CLASS_SKIP_WRITES +#define H5AC__CLASS_SKIP_READS H5C__CLASS_SKIP_READS +#define H5AC__CLASS_SKIP_WRITES H5C__CLASS_SKIP_WRITES -typedef H5C_get_initial_load_size_func_t H5AC_get_initial_load_size_func_t; -typedef H5C_get_final_load_size_func_t H5AC_get_final_load_size_func_t; -typedef H5C_verify_chksum_func_t H5AC_verify_chksum_func_t; -typedef H5C_deserialize_func_t H5AC_deserialize_func_t; -typedef H5C_image_len_func_t H5AC_image_len_func_t; +typedef H5C_get_initial_load_size_func_t H5AC_get_initial_load_size_func_t; +typedef H5C_get_final_load_size_func_t H5AC_get_final_load_size_func_t; +typedef H5C_verify_chksum_func_t H5AC_verify_chksum_func_t; +typedef H5C_deserialize_func_t H5AC_deserialize_func_t; +typedef H5C_image_len_func_t H5AC_image_len_func_t; -#define H5AC__SERIALIZE_NO_FLAGS_SET H5C__SERIALIZE_NO_FLAGS_SET -#define H5AC__SERIALIZE_RESIZED_FLAG H5C__SERIALIZE_RESIZED_FLAG -#define H5AC__SERIALIZE_MOVED_FLAG H5C__SERIALIZE_MOVED_FLAG +#define H5AC__SERIALIZE_NO_FLAGS_SET H5C__SERIALIZE_NO_FLAGS_SET +#define H5AC__SERIALIZE_RESIZED_FLAG H5C__SERIALIZE_RESIZED_FLAG +#define H5AC__SERIALIZE_MOVED_FLAG H5C__SERIALIZE_MOVED_FLAG -typedef H5C_pre_serialize_func_t H5AC_pre_serialize_func_t; -typedef H5C_serialize_func_t H5AC_serialize_func_t; -typedef H5C_notify_func_t H5AC_notify_func_t; -typedef H5C_free_icr_func_t H5AC_free_icr_func_t; -typedef H5C_get_fsf_size_t H5AC_get_fsf_size_t; +typedef H5C_pre_serialize_func_t H5AC_pre_serialize_func_t; +typedef H5C_serialize_func_t H5AC_serialize_func_t; +typedef H5C_notify_func_t H5AC_notify_func_t; +typedef H5C_free_icr_func_t H5AC_free_icr_func_t; +typedef H5C_get_fsf_size_t H5AC_get_fsf_size_t; -typedef H5C_class_t H5AC_class_t; +typedef H5C_class_t H5AC_class_t; /* Cache entry info */ -typedef H5C_cache_entry_t H5AC_info_t; +typedef H5C_cache_entry_t H5AC_info_t; /* Typedef for metadata cache (defined in H5Cpkg.h) */ -typedef H5C_t H5AC_t; +typedef H5C_t H5AC_t; /* Metadata cache proxy entry type */ typedef struct H5AC_proxy_entry_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions */ - /* (MUST be first field in structure) */ + H5AC_info_t cache_info; /* Information for H5AC cache functions */ + /* (MUST be first field in structure) */ /* General fields */ - haddr_t addr; /* Address of the entry in the file */ - /* (Should be in 'temporary' address space) */ + haddr_t addr; /* Address of the entry in the file */ + /* (Should be in 'temporary' address space) */ /* Parent fields */ - H5SL_t *parents; /* Skip list to track parent addresses */ + H5SL_t *parents; /* Skip list to track parent addresses */ /* Child fields */ - size_t nchildren; /* Number of children */ - size_t ndirty_children; /* Number of dirty children */ - /* (Note that this currently duplicates some cache functionality) */ - size_t nunser_children; /* Number of unserialized children */ - /* (Note that this currently duplicates some cache functionality) */ + size_t nchildren; /* Number of children */ + size_t ndirty_children; /* Number of dirty children */ + /* (Note that this currently duplicates some cache functionality) */ + size_t nunser_children; /* Number of unserialized children */ + /* (Note that this currently duplicates some cache functionality) */ } H5AC_proxy_entry_t; /* Default cache configuration. */ -#define H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ - H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED +#define H5AC__DEFAULT_METADATA_WRITE_STRATEGY H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED #ifdef H5_HAVE_PARALLEL -#define H5AC__DEFAULT_CACHE_CONFIG \ -{ \ - /* int version = */ H5AC__CURR_CACHE_CONFIG_VERSION, \ - /* hbool_t rpt_fcn_enabled = */ FALSE, \ - /* hbool_t open_trace_file = */ FALSE, \ - /* hbool_t close_trace_file = */ FALSE, \ - /* char trace_file_name[] = */ "", \ - /* hbool_t evictions_enabled = */ TRUE, \ - /* hbool_t set_initial_size = */ TRUE, \ - /* size_t initial_size = */ ( 2 * 1024 * 1024), \ - /* double min_clean_fraction = */ 0.3f, \ - /* size_t max_size = */ (32 * 1024 * 1024), \ - /* size_t min_size = */ (1 * 1024 * 1024), \ - /* long int epoch_length = */ 50000, \ - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, \ - /* double lower_hr_threshold = */ 0.9f, \ - /* double increment = */ 2.0f, \ - /* hbool_t apply_max_increment = */ TRUE, \ - /* size_t max_increment = */ (4 * 1024 * 1024), \ - /* enum H5C_cache_flash_incr_mode */ \ - /* flash_incr_mode = */ H5C_flash_incr__add_space, \ - /* double flash_multiple = */ 1.0f, \ - /* double flash_threshold = */ 0.25f, \ - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold, \ - /* double upper_hr_threshold = */ 0.999f, \ - /* double decrement = */ 0.9f, \ - /* hbool_t apply_max_decrement = */ TRUE, \ - /* size_t max_decrement = */ (1 * 1024 * 1024), \ - /* int epochs_before_eviction = */ 3, \ - /* hbool_t apply_empty_reserve = */ TRUE, \ - /* double empty_reserve = */ 0.1f, \ - /* size_t dirty_bytes_threshold = */ (256 * 1024), \ - /* int metadata_write_strategy = */ \ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ -} +#define H5AC__DEFAULT_CACHE_CONFIG \ + { \ + /* int version = */ H5AC__CURR_CACHE_CONFIG_VERSION, \ + /* hbool_t rpt_fcn_enabled = */ FALSE, \ + /* hbool_t open_trace_file = */ FALSE, \ + /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", \ + /* hbool_t evictions_enabled = */ TRUE, \ + /* hbool_t set_initial_size = */ TRUE, \ + /* size_t initial_size = */ (2 * 1024 * 1024), \ + /* double min_clean_fraction = */ 0.3f, \ + /* size_t max_size = */ (32 * 1024 * 1024), \ + /* size_t min_size = */ (1 * 1024 * 1024), \ + /* long int epoch_length = */ 50000, \ + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, \ + /* double lower_hr_threshold = */ 0.9f, \ + /* double increment = */ 2.0f, \ + /* hbool_t apply_max_increment = */ TRUE, \ + /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode \ + */ \ + /* flash_incr_mode = */ H5C_flash_incr__add_space, \ + /* double flash_multiple = */ 1.0f, \ + /* double flash_threshold = */ 0.25f, \ + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold, \ + /* double upper_hr_threshold = */ 0.999f, \ + /* double decrement = */ 0.9f, \ + /* hbool_t apply_max_decrement = */ TRUE, \ + /* size_t max_decrement = */ (1 * 1024 * 1024), \ + /* int epochs_before_eviction = */ 3, /* hbool_t apply_empty_reserve = */ TRUE, \ + /* double empty_reserve = */ 0.1f, \ + /* size_t dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ \ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ + } #else /* H5_HAVE_PARALLEL */ -#define H5AC__DEFAULT_CACHE_CONFIG \ -{ \ - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, \ - /* hbool_t rpt_fcn_enabled = */ FALSE, \ - /* hbool_t open_trace_file = */ FALSE, \ - /* hbool_t close_trace_file = */ FALSE, \ - /* char trace_file_name[] = */ "", \ - /* hbool_t evictions_enabled = */ TRUE, \ - /* hbool_t set_initial_size = */ TRUE, \ - /* size_t initial_size = */ ( 2 * 1024 * 1024), \ - /* double min_clean_fraction = */ 0.01f, \ - /* size_t max_size = */ (32 * 1024 * 1024), \ - /* size_t min_size = */ ( 1 * 1024 * 1024), \ - /* long int epoch_length = */ 50000, \ - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, \ - /* double lower_hr_threshold = */ 0.9f, \ - /* double increment = */ 2.0f, \ - /* hbool_t apply_max_increment = */ TRUE, \ - /* size_t max_increment = */ (4 * 1024 * 1024), \ - /* enum H5C_cache_flash_incr_mode */ \ - /* flash_incr_mode = */ H5C_flash_incr__add_space, \ - /* double flash_multiple = */ 1.4f, \ - /* double flash_threshold = */ 0.25f, \ - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold,\ - /* double upper_hr_threshold = */ 0.999f, \ - /* double decrement = */ 0.9f, \ - /* hbool_t apply_max_decrement = */ TRUE, \ - /* size_t max_decrement = */ (1 * 1024 * 1024), \ - /* int epochs_before_eviction = */ 3, \ - /* hbool_t apply_empty_reserve = */ TRUE, \ - /* double empty_reserve = */ 0.1f, \ - /* size_t dirty_bytes_threshold = */ (256 * 1024), \ - /* int metadata_write_strategy = */ \ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ -} +#define H5AC__DEFAULT_CACHE_CONFIG \ + { \ + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, \ + /* hbool_t rpt_fcn_enabled = */ FALSE, \ + /* hbool_t open_trace_file = */ FALSE, \ + /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", \ + /* hbool_t evictions_enabled = */ TRUE, \ + /* hbool_t set_initial_size = */ TRUE, \ + /* size_t initial_size = */ (2 * 1024 * 1024), \ + /* double min_clean_fraction = */ 0.01f, \ + /* size_t max_size = */ (32 * 1024 * 1024), \ + /* size_t min_size = */ (1 * 1024 * 1024), \ + /* long int epoch_length = */ 50000, \ + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, \ + /* double lower_hr_threshold = */ 0.9f, \ + /* double increment = */ 2.0f, \ + /* hbool_t apply_max_increment = */ TRUE, \ + /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode \ + */ \ + /* flash_incr_mode = */ H5C_flash_incr__add_space, \ + /* double flash_multiple = */ 1.4f, \ + /* double flash_threshold = */ 0.25f, \ + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold, \ + /* double upper_hr_threshold = */ 0.999f, \ + /* double decrement = */ 0.9f, \ + /* hbool_t apply_max_decrement = */ TRUE, \ + /* size_t max_decrement = */ (1 * 1024 * 1024), \ + /* int epochs_before_eviction = */ 3, /* hbool_t apply_empty_reserve = */ TRUE, \ + /* double empty_reserve = */ 0.1f, \ + /* size_t dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ \ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ + } #endif /* H5_HAVE_PARALLEL */ -#define H5AC__DEFAULT_CACHE_IMAGE_CONFIG \ -{ \ - /* int32_t version = */ H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, \ - /* hbool_t generate_image = */ FALSE, \ - /* hbool_t save_resize_status = */ FALSE, \ - /* int32_t entry_ageout = */ H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE \ -} +#define H5AC__DEFAULT_CACHE_IMAGE_CONFIG \ + { \ + /* int32_t version = */ H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, \ + /* hbool_t generate_image = */ FALSE, /* hbool_t save_resize_status = */ FALSE, \ + /* int32_t entry_ageout = */ H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE \ + } /* * Library prototypes. */ @@ -313,35 +305,34 @@ typedef struct H5AC_proxy_entry_t { * the equivalent flags from H5Cprivate.h. */ -#define H5AC__NO_FLAGS_SET H5C__NO_FLAGS_SET -#define H5AC__SET_FLUSH_MARKER_FLAG H5C__SET_FLUSH_MARKER_FLAG -#define H5AC__DELETED_FLAG H5C__DELETED_FLAG -#define H5AC__DIRTIED_FLAG H5C__DIRTIED_FLAG -#define H5AC__PIN_ENTRY_FLAG H5C__PIN_ENTRY_FLAG -#define H5AC__UNPIN_ENTRY_FLAG H5C__UNPIN_ENTRY_FLAG -#define H5AC__FLUSH_INVALIDATE_FLAG H5C__FLUSH_INVALIDATE_FLAG -#define H5AC__FLUSH_CLEAR_ONLY_FLAG H5C__FLUSH_CLEAR_ONLY_FLAG +#define H5AC__NO_FLAGS_SET H5C__NO_FLAGS_SET +#define H5AC__SET_FLUSH_MARKER_FLAG H5C__SET_FLUSH_MARKER_FLAG +#define H5AC__DELETED_FLAG H5C__DELETED_FLAG +#define H5AC__DIRTIED_FLAG H5C__DIRTIED_FLAG +#define H5AC__PIN_ENTRY_FLAG H5C__PIN_ENTRY_FLAG +#define H5AC__UNPIN_ENTRY_FLAG H5C__UNPIN_ENTRY_FLAG +#define H5AC__FLUSH_INVALIDATE_FLAG H5C__FLUSH_INVALIDATE_FLAG +#define H5AC__FLUSH_CLEAR_ONLY_FLAG H5C__FLUSH_CLEAR_ONLY_FLAG #define H5AC__FLUSH_MARKED_ENTRIES_FLAG H5C__FLUSH_MARKED_ENTRIES_FLAG #define H5AC__FLUSH_IGNORE_PROTECTED_FLAG H5C__FLUSH_IGNORE_PROTECTED_FLAG -#define H5AC__READ_ONLY_FLAG H5C__READ_ONLY_FLAG -#define H5AC__FREE_FILE_SPACE_FLAG H5C__FREE_FILE_SPACE_FLAG +#define H5AC__READ_ONLY_FLAG H5C__READ_ONLY_FLAG +#define H5AC__FREE_FILE_SPACE_FLAG H5C__FREE_FILE_SPACE_FLAG #define H5AC__TAKE_OWNERSHIP_FLAG H5C__TAKE_OWNERSHIP_FLAG -#define H5AC__FLUSH_LAST_FLAG H5C__FLUSH_LAST_FLAG -#define H5AC__FLUSH_COLLECTIVELY_FLAG H5C__FLUSH_COLLECTIVELY_FLAG - +#define H5AC__FLUSH_LAST_FLAG H5C__FLUSH_LAST_FLAG +#define H5AC__FLUSH_COLLECTIVELY_FLAG H5C__FLUSH_COLLECTIVELY_FLAG /* #defines of flags used to report entry status in the * H5AC_get_entry_status() call. */ -#define H5AC_ES__IN_CACHE 0x0001 -#define H5AC_ES__IS_DIRTY 0x0002 -#define H5AC_ES__IS_PROTECTED 0x0004 -#define H5AC_ES__IS_PINNED 0x0008 -#define H5AC_ES__IS_FLUSH_DEP_PARENT 0x0010 -#define H5AC_ES__IS_FLUSH_DEP_CHILD 0x0020 -#define H5AC_ES__IS_CORKED 0x0040 -#define H5AC_ES__IMAGE_IS_UP_TO_DATE 0x0080 +#define H5AC_ES__IN_CACHE 0x0001 +#define H5AC_ES__IS_DIRTY 0x0002 +#define H5AC_ES__IS_PROTECTED 0x0004 +#define H5AC_ES__IS_PINNED 0x0008 +#define H5AC_ES__IS_FLUSH_DEP_PARENT 0x0010 +#define H5AC_ES__IS_FLUSH_DEP_CHILD 0x0020 +#define H5AC_ES__IS_CORKED 0x0040 +#define H5AC_ES__IMAGE_IS_UP_TO_DATE 0x0080 /* Metadata entry class declarations */ H5_DLLVAR const H5AC_class_t H5AC_BT[1]; @@ -375,100 +366,86 @@ H5_DLLVAR const H5AC_class_t H5AC_EPOCH_MARKER[1]; H5_DLLVAR const H5AC_class_t H5AC_PROXY_ENTRY[1]; H5_DLLVAR const H5AC_class_t H5AC_PREFETCHED_ENTRY[1]; - /* external function declarations: */ H5_DLL herr_t H5AC_init(void); H5_DLL herr_t H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, - H5AC_cache_image_config_t * image_config_ptr); -H5_DLL herr_t H5AC_get_entry_status(const H5F_t *f, haddr_t addr, - unsigned *status_ptr); -H5_DLL herr_t H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, - haddr_t addr, void *thing, unsigned int flags); + H5AC_cache_image_config_t *image_config_ptr); +H5_DLL herr_t H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status_ptr); +H5_DLL herr_t H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, + unsigned int flags); H5_DLL herr_t H5AC_pin_protected_entry(void *thing); H5_DLL herr_t H5AC_prep_for_file_close(H5F_t *f); H5_DLL herr_t H5AC_create_flush_dependency(void *parent_thing, void *child_thing); -H5_DLL void * H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, - void *udata, unsigned flags); +H5_DLL void * H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, unsigned flags); H5_DLL herr_t H5AC_resize_entry(void *thing, size_t new_size); H5_DLL herr_t H5AC_unpin_entry(void *thing); H5_DLL herr_t H5AC_destroy_flush_dependency(void *parent_thing, void *child_thing); -H5_DLL herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, - void *thing, unsigned flags); +H5_DLL herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags); H5_DLL herr_t H5AC_flush(H5F_t *f); H5_DLL herr_t H5AC_mark_entry_dirty(void *thing); H5_DLL herr_t H5AC_mark_entry_clean(void *thing); H5_DLL herr_t H5AC_mark_entry_unserialized(void *thing); H5_DLL herr_t H5AC_mark_entry_serialized(void *thing); -H5_DLL herr_t H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, - haddr_t old_addr, haddr_t new_addr); +H5_DLL herr_t H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr); H5_DLL herr_t H5AC_dest(H5F_t *f); H5_DLL herr_t H5AC_evict(H5F_t *f); -H5_DLL herr_t H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, - haddr_t addr, unsigned flags); +H5_DLL herr_t H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, unsigned flags); H5_DLL herr_t H5AC_remove_entry(void *entry); -H5_DLL herr_t H5AC_get_cache_auto_resize_config(const H5AC_t * cache_ptr, - H5AC_cache_config_t *config_ptr); -H5_DLL herr_t H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, - size_t *min_clean_size_ptr, size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); +H5_DLL herr_t H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); H5_DLL herr_t H5AC_get_cache_flush_in_progress(H5AC_t *cache_ptr, hbool_t *flush_in_progress_ptr); H5_DLL herr_t H5AC_get_cache_hit_rate(H5AC_t *cache_ptr, double *hit_rate_ptr); H5_DLL herr_t H5AC_reset_cache_hit_rate_stats(H5AC_t *cache_ptr); -H5_DLL herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, - H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr); H5_DLL herr_t H5AC_validate_config(H5AC_cache_config_t *config_ptr); /* Cache image routines */ -H5_DLL herr_t H5AC_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, - hsize_t len, hbool_t rw); -H5_DLL herr_t H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr); +H5_DLL herr_t H5AC_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw); +H5_DLL herr_t H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr); H5_DLL hbool_t H5AC_cache_image_pending(const H5F_t *f); -H5_DLL herr_t H5AC_force_cache_image_load(H5F_t * f); -H5_DLL herr_t H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, - hsize_t *image_len); +H5_DLL herr_t H5AC_force_cache_image_load(H5F_t *f); +H5_DLL herr_t H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); /* Tag & Ring routines */ -H5_DLL void H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag); +H5_DLL void H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag); H5_DLL herr_t H5AC_flush_tagged_metadata(H5F_t *f, haddr_t metadata_tag); H5_DLL herr_t H5AC_evict_tagged_metadata(H5F_t *f, haddr_t metadata_tag, hbool_t match_global); H5_DLL herr_t H5AC_retag_copied_metadata(const H5F_t *f, haddr_t metadata_tag); H5_DLL herr_t H5AC_ignore_tags(const H5F_t *f); H5_DLL herr_t H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked); H5_DLL herr_t H5AC_get_entry_ring(const H5F_t *f, haddr_t addr, H5AC_ring_t *ring); -H5_DLL void H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring); +H5_DLL void H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring); H5_DLL herr_t H5AC_unsettle_entry_ring(void *entry); -H5_DLL herr_t H5AC_unsettle_ring(H5F_t * f, H5AC_ring_t ring); -H5_DLL herr_t H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, - unsigned flags, hbool_t type_match); +H5_DLL herr_t H5AC_unsettle_ring(H5F_t *f, H5AC_ring_t ring); +H5_DLL herr_t H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags, + hbool_t type_match); H5_DLL herr_t H5AC_get_tag(const void *thing, /*OUT*/ haddr_t *tag); /* Virtual entry routines */ H5_DLL H5AC_proxy_entry_t *H5AC_proxy_entry_create(void); -H5_DLL herr_t H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *parent); -H5_DLL herr_t H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *parent); -H5_DLL herr_t H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, - void *child); -H5_DLL herr_t H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child); -H5_DLL herr_t H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry); +H5_DLL herr_t H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *parent); +H5_DLL herr_t H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *parent); +H5_DLL herr_t H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, void *child); +H5_DLL herr_t H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child); +H5_DLL herr_t H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry); #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr); +H5_DLL herr_t H5AC_add_candidate(H5AC_t *cache_ptr, haddr_t addr); #endif /* H5_HAVE_PARALLEL */ /* Debugging functions */ H5_DLL herr_t H5AC_stats(const H5F_t *f); #ifndef NDEBUG -H5_DLL herr_t H5AC_dump_cache(const H5F_t *f); -H5_DLL herr_t H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, - void **entry_ptr_ptr); -H5_DLL herr_t H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, - haddr_t child_addr, hbool_t *fd_exists_ptr); -H5_DLL herr_t H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, - const H5AC_class_t *expected_type, hbool_t *in_cache_ptr, - hbool_t *type_ok_ptr); +H5_DLL herr_t H5AC_dump_cache(const H5F_t *f); +H5_DLL herr_t H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr); +H5_DLL herr_t H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, + hbool_t *fd_exists_ptr); +H5_DLL herr_t H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, const H5AC_class_t *expected_type, + hbool_t *in_cache_ptr, hbool_t *type_ok_ptr); H5_DLL hbool_t H5AC_get_serialization_in_progress(H5F_t *f); H5_DLL hbool_t H5AC_cache_is_clean(const H5F_t *f, H5AC_ring_t inner_ring); #endif /* NDEBUG */ /* end debugging functions */ #endif /* !_H5ACprivate_H */ - diff --git a/src/H5ACproxy_entry.c b/src/H5ACproxy_entry.c index 1302b83..49041a6 100644 --- a/src/H5ACproxy_entry.c +++ b/src/H5ACproxy_entry.c @@ -25,40 +25,35 @@ /****************/ /* Module Setup */ /****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache (H5AC) callbacks */ static herr_t H5AC__proxy_entry_image_len(const void *thing, size_t *image_len); -static herr_t H5AC__proxy_entry_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); +static herr_t H5AC__proxy_entry_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); static herr_t H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *thing); static herr_t H5AC__proxy_entry_free_icr(void *thing); @@ -68,29 +63,27 @@ static herr_t H5AC__proxy_entry_free_icr(void *thing); /* H5AC proxy entries inherit cache-like properties from H5AC */ const H5AC_class_t H5AC_PROXY_ENTRY[1] = {{ - H5AC_PROXY_ENTRY_ID, /* Metadata client ID */ - "Proxy entry", /* Metadata client name (for debugging) */ - H5FD_MEM_SUPER, /* File space memory type for client */ - 0, /* Client class behavior flags */ - NULL, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - NULL, /* 'deserialize' callback */ - H5AC__proxy_entry_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5AC__proxy_entry_serialize, /* 'serialize' callback */ - H5AC__proxy_entry_notify, /* 'notify' callback */ - H5AC__proxy_entry_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_PROXY_ENTRY_ID, /* Metadata client ID */ + "Proxy entry", /* Metadata client name (for debugging) */ + H5FD_MEM_SUPER, /* File space memory type for client */ + 0, /* Client class behavior flags */ + NULL, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + NULL, /* 'deserialize' callback */ + H5AC__proxy_entry_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5AC__proxy_entry_serialize, /* 'serialize' callback */ + H5AC__proxy_entry_notify, /* 'notify' callback */ + H5AC__proxy_entry_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -98,8 +91,6 @@ const H5AC_class_t H5AC_PROXY_ENTRY[1] = {{ /* Declare a free list to manage H5AC_proxy_entry_t objects */ H5FL_DEFINE_STATIC(H5AC_proxy_entry_t); - - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_create * @@ -116,13 +107,13 @@ H5FL_DEFINE_STATIC(H5AC_proxy_entry_t); H5AC_proxy_entry_t * H5AC_proxy_entry_create(void) { - H5AC_proxy_entry_t *pentry = NULL; /* Pointer to new proxy entry */ - H5AC_proxy_entry_t *ret_value = NULL; /* Return value */ + H5AC_proxy_entry_t *pentry = NULL; /* Pointer to new proxy entry */ + H5AC_proxy_entry_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate new proxy entry */ - if(NULL == (pentry = H5FL_CALLOC(H5AC_proxy_entry_t))) + if (NULL == (pentry = H5FL_CALLOC(H5AC_proxy_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "can't allocate proxy entry") /* Set non-zero fields */ @@ -133,14 +124,13 @@ H5AC_proxy_entry_create(void) done: /* Release resources on error */ - if(!ret_value) - if(pentry) + if (!ret_value) + if (pentry) pentry = H5FL_FREE(H5AC_proxy_entry_t, pentry); FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_create() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_add_parent * @@ -156,8 +146,8 @@ done: herr_t H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *_parent) { - H5AC_info_t *parent = (H5AC_info_t *)_parent; /* Parent entry's cache info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *parent = (H5AC_info_t *)_parent; /* Parent entry's cache info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -166,20 +156,21 @@ H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *_parent) HDassert(pentry); /* Add parent to the list of parents */ - if(NULL == pentry->parents) - if(NULL == (pentry->parents = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to create skip list for parents of proxy entry") + if (NULL == pentry->parents) + if (NULL == (pentry->parents = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, + "unable to create skip list for parents of proxy entry") /* Insert parent address into skip list */ - if(H5SL_insert(pentry->parents, parent, &parent->addr) < 0) + if (H5SL_insert(pentry->parents, parent, &parent->addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert parent into proxy's skip list") /* Add flush dependency on parent */ - if(pentry->nchildren > 0) { + if (pentry->nchildren > 0) { /* Sanity check */ HDassert(H5F_addr_defined(pentry->addr)); - if(H5AC_create_flush_dependency(parent, pentry) < 0) + if (H5AC_create_flush_dependency(parent, pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "unable to set flush dependency on proxy entry") } /* end if */ @@ -187,7 +178,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_add_parent() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_remove_parent * @@ -203,9 +193,9 @@ done: herr_t H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *_parent) { - H5AC_info_t *parent = (H5AC_info_t *)_parent; /* Pointer to the parent entry */ - H5AC_info_t *rem_parent; /* Pointer to the removed parent entry */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *parent = (H5AC_info_t *)_parent; /* Pointer to the parent entry */ + H5AC_info_t *rem_parent; /* Pointer to the removed parent entry */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -215,31 +205,30 @@ H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *_parent) HDassert(parent); /* Remove parent from skip list */ - if(NULL == (rem_parent = (H5AC_info_t *)H5SL_remove(pentry->parents, &parent->addr))) + if (NULL == (rem_parent = (H5AC_info_t *)H5SL_remove(pentry->parents, &parent->addr))) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "unable to remove proxy entry parent from skip list") - if(!H5F_addr_eq(rem_parent->addr, parent->addr)) + if (!H5F_addr_eq(rem_parent->addr, parent->addr)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "removed proxy entry parent not the same as real parent") /* Shut down the skip list, if this is the last parent */ - if(0 == H5SL_count(pentry->parents)) { + if (0 == H5SL_count(pentry->parents)) { /* Sanity check */ HDassert(0 == pentry->nchildren); - if(H5SL_close(pentry->parents) < 0) + if (H5SL_close(pentry->parents) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CLOSEERROR, FAIL, "can't close proxy parent skip list") pentry->parents = NULL; } /* end if */ /* Remove flush dependency between the proxy entry and a parent */ - if(pentry->nchildren > 0) - if(H5AC_destroy_flush_dependency(parent, pentry) < 0) + if (pentry->nchildren > 0) + if (H5AC_destroy_flush_dependency(parent, pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "unable to remove flush dependency on proxy entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_remove_parent() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_add_child_cb * @@ -257,21 +246,21 @@ done: static int H5AC__proxy_entry_add_child_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5AC_info_t *parent = (H5AC_info_t *)_item; /* Pointer to the parent entry */ - H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_udata; /* Pointer to the proxy entry */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + H5AC_info_t * parent = (H5AC_info_t *)_item; /* Pointer to the parent entry */ + H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_udata; /* Pointer to the proxy entry */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC /* Add flush dependency on parent for proxy entry */ - if(H5AC_create_flush_dependency(parent, pentry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, H5_ITER_ERROR, "unable to set flush dependency for virtual entry") + if (H5AC_create_flush_dependency(parent, pentry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, H5_ITER_ERROR, + "unable to set flush dependency for virtual entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC__proxy_entry_add_child_cb() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_add_child * @@ -287,7 +276,7 @@ done: herr_t H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, void *child) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -296,32 +285,34 @@ H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, void *child) HDassert(child); /* Check for first child */ - if(0 == pentry->nchildren) { + if (0 == pentry->nchildren) { /* Get an address, if the proxy doesn't already have one */ - if(!H5F_addr_defined(pentry->addr)) - if(HADDR_UNDEF == (pentry->addr = H5MF_alloc_tmp(f, 1))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "temporary file space allocation failed for proxy entry") + if (!H5F_addr_defined(pentry->addr)) + if (HADDR_UNDEF == (pentry->addr = H5MF_alloc_tmp(f, 1))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "temporary file space allocation failed for proxy entry") /* Insert the proxy entry into the cache */ - if(H5AC_insert_entry(f, H5AC_PROXY_ENTRY, pentry->addr, pentry, H5AC__PIN_ENTRY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_PROXY_ENTRY, pentry->addr, pentry, H5AC__PIN_ENTRY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to cache proxy entry") /* Proxies start out clean (insertions are automatically marked dirty) */ - if(H5AC_mark_entry_clean(pentry) < 0) + if (H5AC_mark_entry_clean(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLEAN, FAIL, "can't mark proxy entry clean") /* Proxies start out serialized (insertions are automatically marked unserialized) */ - if(H5AC_mark_entry_serialized(pentry) < 0) + if (H5AC_mark_entry_serialized(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "can't mark proxy entry clean") - /* If there are currently parents, iterate over the list of parents, creating flush dependency on them */ - if(pentry->parents) - if(H5SL_iterate(pentry->parents, H5AC__proxy_entry_add_child_cb, pentry) < 0) + /* If there are currently parents, iterate over the list of parents, creating flush dependency on them + */ + if (pentry->parents) + if (H5SL_iterate(pentry->parents, H5AC__proxy_entry_add_child_cb, pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "can't visit parents") } /* end if */ /* Add flush dependency on proxy entry */ - if(H5AC_create_flush_dependency(pentry, child) < 0) + if (H5AC_create_flush_dependency(pentry, child) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "unable to set flush dependency on proxy entry") /* Increment count of children */ @@ -331,7 +322,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_add_child() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_remove_child_cb * @@ -349,21 +339,21 @@ done: static int H5AC__proxy_entry_remove_child_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5AC_info_t *parent = (H5AC_info_t *)_item; /* Pointer to the parent entry */ - H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_udata; /* Pointer to the proxy entry */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + H5AC_info_t * parent = (H5AC_info_t *)_item; /* Pointer to the parent entry */ + H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_udata; /* Pointer to the proxy entry */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC /* Remove flush dependency on parent for proxy entry */ - if(H5AC_destroy_flush_dependency(parent, pentry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, H5_ITER_ERROR, "unable to remove flush dependency for proxy entry") + if (H5AC_destroy_flush_dependency(parent, pentry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, H5_ITER_ERROR, + "unable to remove flush dependency for proxy entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC__proxy_entry_remove_child_cb() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_remove_child * @@ -379,7 +369,7 @@ done: herr_t H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -388,26 +378,26 @@ H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child) HDassert(child); /* Remove flush dependency on proxy entry */ - if(H5AC_destroy_flush_dependency(pentry, child) < 0) + if (H5AC_destroy_flush_dependency(pentry, child) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "unable to remove flush dependency on proxy entry") /* Decrement count of children */ pentry->nchildren--; /* Check for last child */ - if(0 == pentry->nchildren) { + if (0 == pentry->nchildren) { /* Check for flush dependencies on proxy's parents */ - if(pentry->parents) + if (pentry->parents) /* Iterate over the list of parents, removing flush dependency on them */ - if(H5SL_iterate(pentry->parents, H5AC__proxy_entry_remove_child_cb, pentry) < 0) + if (H5SL_iterate(pentry->parents, H5AC__proxy_entry_remove_child_cb, pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "can't visit parents") /* Unpin proxy */ - if(H5AC_unpin_entry(pentry) < 0) + if (H5AC_unpin_entry(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin proxy entry") /* Remove proxy entry from cache */ - if(H5AC_remove_entry(pentry) < 0) + if (H5AC_remove_entry(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "unable to remove proxy entry") } /* end if */ @@ -415,7 +405,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_remove_child() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_dest * @@ -431,7 +420,7 @@ done: herr_t H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -449,7 +438,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_dest() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_image_len * @@ -476,7 +464,6 @@ H5AC__proxy_entry_image_len(const void H5_ATTR_UNUSED *thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5AC__proxy_entry_image_len() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_serialize * @@ -493,19 +480,18 @@ H5AC__proxy_entry_image_len(const void H5_ATTR_UNUSED *thing, size_t *image_len) */ static herr_t H5AC__proxy_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *image, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) + size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - /* Should never be invoked */ - HDassert(0 && "Invalid callback?!?"); + /* Should never be invoked */ + HDassert(0 && "Invalid callback?!?"); HERROR(H5E_CACHE, H5E_CANTSERIALIZE, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5AC__proxy_entry_serialize() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_notify * @@ -521,33 +507,33 @@ H5AC__proxy_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED * static herr_t H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) { - H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(pentry); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - break; + break; - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: #ifdef NDEBUG HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid notify action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Invalid action?!?"); #endif /* NDEBUG */ break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: #ifdef NDEBUG HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid notify action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Invalid action?!?"); #endif /* NDEBUG */ - break; + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Sanity checks */ @@ -576,8 +562,8 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) pentry->ndirty_children++; /* Check for first dirty child */ - if(1 == pentry->ndirty_children) - if(H5AC_mark_entry_dirty(pentry) < 0) + if (1 == pentry->ndirty_children) + if (H5AC_mark_entry_dirty(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDIRTY, FAIL, "can't mark proxy entry dirty") break; @@ -589,8 +575,8 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) pentry->ndirty_children--; /* Check for last dirty child */ - if(0 == pentry->ndirty_children) - if(H5AC_mark_entry_clean(pentry) < 0) + if (0 == pentry->ndirty_children) + if (H5AC_mark_entry_clean(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLEAN, FAIL, "can't mark proxy entry clean") break; @@ -599,8 +585,8 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) pentry->nunser_children++; /* Check for first unserialized child */ - if(1 == pentry->nunser_children) - if(H5AC_mark_entry_unserialized(pentry) < 0) + if (1 == pentry->nunser_children) + if (H5AC_mark_entry_unserialized(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNSERIALIZE, FAIL, "can't mark proxy entry unserialized") break; @@ -612,24 +598,23 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) pentry->nunser_children--; /* Check for last unserialized child */ - if(0 == pentry->nunser_children) - if(H5AC_mark_entry_serialized(pentry) < 0) + if (0 == pentry->nunser_children) + if (H5AC_mark_entry_serialized(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "can't mark proxy entry serialized") break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unknown notify action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC__proxy_entry_notify() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_free_icr * @@ -646,16 +631,15 @@ done: static herr_t H5AC__proxy_entry_free_icr(void *_thing) { - H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Destroy the proxy entry */ - if(H5AC_proxy_entry_dest(pentry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to destroy proxy entry") + if (H5AC_proxy_entry_dest(pentry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to destroy proxy entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__proxy_entry_free_icr() */ - diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index a48aa69..72bffd0 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -438,74 +438,69 @@ extern "C" { * ****************************************************************************/ -#define H5AC__CURR_CACHE_CONFIG_VERSION 1 -#define H5AC__MAX_TRACE_FILE_NAME_LEN 1024 +#define H5AC__CURR_CACHE_CONFIG_VERSION 1 +#define H5AC__MAX_TRACE_FILE_NAME_LEN 1024 -#define H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY 0 -#define H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED 1 +#define H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY 0 +#define H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED 1 -typedef struct H5AC_cache_config_t -{ +typedef struct H5AC_cache_config_t { /* general configuration fields: */ - int version; + int version; - hbool_t rpt_fcn_enabled; + hbool_t rpt_fcn_enabled; - hbool_t open_trace_file; - hbool_t close_trace_file; - char trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + 1]; + hbool_t open_trace_file; + hbool_t close_trace_file; + char trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + 1]; - hbool_t evictions_enabled; + hbool_t evictions_enabled; - hbool_t set_initial_size; - size_t initial_size; + hbool_t set_initial_size; + size_t initial_size; - double min_clean_fraction; + double min_clean_fraction; - size_t max_size; - size_t min_size; - - long int epoch_length; + size_t max_size; + size_t min_size; + long int epoch_length; /* size increase control fields: */ enum H5C_cache_incr_mode incr_mode; - double lower_hr_threshold; - - double increment; + double lower_hr_threshold; - hbool_t apply_max_increment; - size_t max_increment; + double increment; - enum H5C_cache_flash_incr_mode flash_incr_mode; - double flash_multiple; - double flash_threshold; + hbool_t apply_max_increment; + size_t max_increment; + enum H5C_cache_flash_incr_mode flash_incr_mode; + double flash_multiple; + double flash_threshold; /* size decrease control fields: */ enum H5C_cache_decr_mode decr_mode; - double upper_hr_threshold; - - double decrement; + double upper_hr_threshold; - hbool_t apply_max_decrement; - size_t max_decrement; + double decrement; - int epochs_before_eviction; + hbool_t apply_max_decrement; + size_t max_decrement; - hbool_t apply_empty_reserve; - double empty_reserve; + int epochs_before_eviction; + hbool_t apply_empty_reserve; + double empty_reserve; /* parallel configuration fields: */ - size_t dirty_bytes_threshold; - int metadata_write_strategy; + size_t dirty_bytes_threshold; + int metadata_write_strategy; } H5AC_cache_config_t; - /**************************************************************************** * * structure H5AC_cache_image_config_t @@ -555,20 +550,19 @@ typedef struct H5AC_cache_config_t * ****************************************************************************/ -#define H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION 1 +#define H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION 1 -#define H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE -1 -#define H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX 100 +#define H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE -1 +#define H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX 100 typedef struct H5AC_cache_image_config_t { - int version; - hbool_t generate_image; - hbool_t save_resize_status; - int entry_ageout; + int version; + hbool_t generate_image; + hbool_t save_resize_status; + int entry_ageout; } H5AC_cache_image_config_t; #ifdef __cplusplus } #endif #endif - diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 3377aa2..590603a 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -26,24 +26,21 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5SMprivate.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5SMprivate.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -54,22 +51,20 @@ */ typedef struct H5A_fh_ud_cmp_t { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - const char *name; /* Name of attribute to compare */ - const H5A_dense_bt2_name_rec_t *record; /* v2 B-tree record for attribute */ - H5A_bt2_found_t found_op; /* Callback when correct attribute is found */ - void *found_op_data; /* Callback data when correct attribute is found */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + const char * name; /* Name of attribute to compare */ + const H5A_dense_bt2_name_rec_t *record; /* v2 B-tree record for attribute */ + H5A_bt2_found_t found_op; /* Callback when correct attribute is found */ + void * found_op_data; /* Callback data when correct attribute is found */ /* upward */ - int cmp; /* Comparison of two attribute names */ + int cmp; /* Comparison of two attribute names */ } H5A_fh_ud_cmp_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -79,51 +74,48 @@ typedef struct H5A_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5A__dense_btree2_corder_store(void *native, const void *udata); static herr_t H5A__dense_btree2_corder_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5A__dense_btree2_corder_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5A__dense_btree2_corder_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5A__dense_btree2_corder_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5A__dense_btree2_corder_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5A__dense_btree2_name_store(void *native, const void *udata); static herr_t H5A__dense_btree2_name_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5A__dense_btree2_name_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5A__dense_btree2_name_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5A__dense_btree2_name_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5A__dense_btree2_name_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Fractal heap function callbacks */ static herr_t H5A__dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data); - /*********************/ /* Package Variables */ /*********************/ /* v2 B-tree class for indexing 'name' field of attributes */ -const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */ - H5B2_ATTR_DENSE_NAME_ID, /* Type of B-tree */ - "H5B2_ATTR_DENSE_NAME_ID", /* Name of B-tree class */ - sizeof(H5A_dense_bt2_name_rec_t), /* Size of native record */ - NULL, /* Create client callback context */ - NULL, /* Destroy client callback context */ - H5A__dense_btree2_name_store, /* Record storage callback */ - H5A__dense_btree2_name_compare, /* Record comparison callback */ - H5A__dense_btree2_name_encode, /* Record encoding callback */ - H5A__dense_btree2_name_decode, /* Record decoding callback */ - H5A__dense_btree2_name_debug /* Record debugging callback */ +const H5B2_class_t H5A_BT2_NAME[1] = {{ + /* B-tree class information */ + H5B2_ATTR_DENSE_NAME_ID, /* Type of B-tree */ + "H5B2_ATTR_DENSE_NAME_ID", /* Name of B-tree class */ + sizeof(H5A_dense_bt2_name_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ + H5A__dense_btree2_name_store, /* Record storage callback */ + H5A__dense_btree2_name_compare, /* Record comparison callback */ + H5A__dense_btree2_name_encode, /* Record encoding callback */ + H5A__dense_btree2_name_decode, /* Record decoding callback */ + H5A__dense_btree2_name_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing 'creation order' field of attributes */ -const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ - H5B2_ATTR_DENSE_CORDER_ID, /* Type of B-tree */ - "H5B2_ATTR_DENSE_CORDER_ID", /* Name of B-tree class */ - sizeof(H5A_dense_bt2_corder_rec_t),/* Size of native record */ - NULL, /* Create client callback context */ - NULL, /* Destroy client callback context */ +const H5B2_class_t H5A_BT2_CORDER[1] = {{ + /* B-tree class information */ + H5B2_ATTR_DENSE_CORDER_ID, /* Type of B-tree */ + "H5B2_ATTR_DENSE_CORDER_ID", /* Name of B-tree class */ + sizeof(H5A_dense_bt2_corder_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5A__dense_btree2_corder_store, /* Record storage callback */ H5A__dense_btree2_corder_compare, /* Record comparison callback */ H5A__dense_btree2_corder_encode, /* Record encoding callback */ @@ -131,18 +123,14 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ H5A__dense_btree2_corder_debug /* Record debugging callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5A__dense_fh_name_cmp * @@ -160,43 +148,43 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ static herr_t H5A__dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata) { - H5A_fh_ud_cmp_t *udata = (H5A_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */ - H5A_t *attr = NULL; /* Pointer to attribute created from heap object */ - hbool_t took_ownership = FALSE; /* Whether the "found" operator took ownership of the attribute */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_fh_ud_cmp_t *udata = (H5A_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */ + H5A_t * attr = NULL; /* Pointer to attribute created from heap object */ + hbool_t took_ownership = FALSE; /* Whether the "found" operator took ownership of the attribute */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Decode attribute information */ - if(NULL == (attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, (const unsigned char *)obj))) + if (NULL == + (attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, (const unsigned char *)obj))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "can't decode attribute") /* Compare the string values */ udata->cmp = HDstrcmp(udata->name, attr->shared->name); /* Check for correct attribute & callback to make */ - if(udata->cmp == 0 && udata->found_op) { + if (udata->cmp == 0 && udata->found_op) { /* Check whether we should "reconstitute" the shared message info */ - if(udata->record->flags & H5O_MSG_FLAG_SHARED) + if (udata->record->flags & H5O_MSG_FLAG_SHARED) H5SM_reconstitute(&(attr->sh_loc), udata->f, H5O_ATTR_ID, udata->record->id); /* Set the creation order index for the attribute */ attr->shared->crt_idx = udata->record->corder; /* Make callback */ - if((udata->found_op)(attr, &took_ownership, udata->found_op_data) < 0) + if ((udata->found_op)(attr, &took_ownership, udata->found_op_data) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPERATE, FAIL, "attribute found callback failed") } /* end if */ done: /* Release the space allocated for the attrbute */ - if(attr && !took_ownership) + if (attr && !took_ownership) H5O_msg_free(H5O_ATTR_ID, attr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_fh_name_cmp() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_store * @@ -213,21 +201,20 @@ done: static herr_t H5A__dense_btree2_name_store(void *_nrecord, const void *_udata) { - const H5A_bt2_ud_ins_t *udata = (const H5A_bt2_ud_ins_t *)_udata; + const H5A_bt2_ud_ins_t * udata = (const H5A_bt2_ud_ins_t *)_udata; H5A_dense_bt2_name_rec_t *nrecord = (H5A_dense_bt2_name_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR /* Copy user information info native record */ - nrecord->id = udata->id; - nrecord->flags = udata->common.flags; + nrecord->id = udata->id; + nrecord->flags = udata->common.flags; nrecord->corder = udata->common.corder; - nrecord->hash = udata->common.name_hash; + nrecord->hash = udata->common.name_hash; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_store() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_compare * @@ -245,9 +232,9 @@ H5A__dense_btree2_name_store(void *_nrecord, const void *_udata) static herr_t H5A__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { - const H5A_bt2_ud_common_t *bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; - const H5A_dense_bt2_name_rec_t *bt2_rec = (const H5A_dense_bt2_name_rec_t *)_bt2_rec; - herr_t ret_value = SUCCEED; /* Return value */ + const H5A_bt2_ud_common_t * bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; + const H5A_dense_bt2_name_rec_t *bt2_rec = (const H5A_dense_bt2_name_rec_t *)_bt2_rec; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -256,37 +243,37 @@ H5A__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int HDassert(bt2_rec); /* Check hash value */ - if(bt2_udata->name_hash < bt2_rec->hash) + if (bt2_udata->name_hash < bt2_rec->hash) *result = (-1); - else if(bt2_udata->name_hash > bt2_rec->hash) + else if (bt2_udata->name_hash > bt2_rec->hash) *result = 1; else { - H5A_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */ - H5HF_t *fheap; /* Fractal heap handle to use for finding object */ + H5A_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5HF_t * fheap; /* Fractal heap handle to use for finding object */ /* Sanity check */ HDassert(bt2_udata->name_hash == bt2_rec->hash); /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; - fh_udata.name = bt2_udata->name; - fh_udata.record = bt2_rec; - fh_udata.found_op = bt2_udata->found_op; + fh_udata.f = bt2_udata->f; + fh_udata.name = bt2_udata->name; + fh_udata.record = bt2_rec; + fh_udata.found_op = bt2_udata->found_op; fh_udata.found_op_data = bt2_udata->found_op_data; /* up */ fh_udata.cmp = 0; /* Check for attribute in shared storage */ - if(bt2_rec->flags & H5O_MSG_FLAG_SHARED) + if (bt2_rec->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; HDassert(fheap); /* Check if the user's attribute and the B-tree's attribute have the same name */ - if(H5HF_op(fheap, &bt2_rec->id, H5A__dense_fh_name_cmp, &fh_udata) < 0) + if (H5HF_op(fheap, &bt2_rec->id, H5A__dense_fh_name_cmp, &fh_udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Callback will set comparison value */ @@ -297,7 +284,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__dense_btree2_name_compare() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_encode * @@ -328,7 +314,6 @@ H5A__dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_U FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_encode() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_decode * @@ -359,7 +344,6 @@ H5A__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_decode() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_debug * @@ -374,21 +358,20 @@ H5A__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U *------------------------------------------------------------------------- */ static herr_t -H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5A_dense_bt2_name_rec_t *nrecord = (const H5A_dense_bt2_name_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR HDfprintf(stream, "%*s%-*s {%016Hx, %02x, %u, %08lx}\n", indent, "", fwidth, - "Record:", - (hsize_t)nrecord->id.val, (unsigned)nrecord->flags, (unsigned)nrecord->corder, (unsigned long)nrecord->hash); + "Record:", (hsize_t)nrecord->id.val, (unsigned)nrecord->flags, (unsigned)nrecord->corder, + (unsigned long)nrecord->hash); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_debug() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_store * @@ -405,20 +388,19 @@ H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, static herr_t H5A__dense_btree2_corder_store(void *_nrecord, const void *_udata) { - const H5A_bt2_ud_ins_t *udata = (const H5A_bt2_ud_ins_t *)_udata; + const H5A_bt2_ud_ins_t * udata = (const H5A_bt2_ud_ins_t *)_udata; H5A_dense_bt2_corder_rec_t *nrecord = (H5A_dense_bt2_corder_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR /* Copy user information info native record */ - nrecord->id = udata->id; - nrecord->flags = udata->common.flags; + nrecord->id = udata->id; + nrecord->flags = udata->common.flags; nrecord->corder = udata->common.corder; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_store() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_compare * @@ -436,8 +418,8 @@ H5A__dense_btree2_corder_store(void *_nrecord, const void *_udata) static herr_t H5A__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { - const H5A_bt2_ud_common_t *bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; - const H5A_dense_bt2_corder_rec_t *bt2_rec = (const H5A_dense_bt2_corder_rec_t *)_bt2_rec; + const H5A_bt2_ud_common_t * bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; + const H5A_dense_bt2_corder_rec_t *bt2_rec = (const H5A_dense_bt2_corder_rec_t *)_bt2_rec; FUNC_ENTER_STATIC_NOERR @@ -446,9 +428,9 @@ H5A__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, i HDassert(bt2_rec); /* Check creation order value */ - if(bt2_udata->corder < bt2_rec->corder) + if (bt2_udata->corder < bt2_rec->corder) *result = -1; - else if(bt2_udata->corder > bt2_rec->corder) + else if (bt2_udata->corder > bt2_rec->corder) *result = 1; else *result = 0; @@ -456,7 +438,6 @@ H5A__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, i FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_compare() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_encode * @@ -486,7 +467,6 @@ H5A__dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_encode() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_decode * @@ -516,7 +496,6 @@ H5A__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_decode() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_debug * @@ -531,17 +510,15 @@ H5A__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR *------------------------------------------------------------------------- */ static herr_t -H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5A_dense_bt2_corder_rec_t *nrecord = (const H5A_dense_bt2_corder_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%016Hx, %02x, %u}\n", indent, "", fwidth, - "Record:", - (hsize_t)nrecord->id.val, (unsigned)nrecord->flags, (unsigned)nrecord->corder); + HDfprintf(stream, "%*s%-*s {%016Hx, %02x, %u}\n", indent, "", fwidth, "Record:", (hsize_t)nrecord->id.val, + (unsigned)nrecord->flags, (unsigned)nrecord->corder); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_debug() */ - diff --git a/src/H5Adense.c b/src/H5Adense.c index fd92e8f..4a81430 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -27,39 +27,36 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* v2 B-tree creation macros for 'name' field index */ -#define H5A_NAME_BT2_NODE_SIZE 512 -#define H5A_NAME_BT2_MERGE_PERC 40 -#define H5A_NAME_BT2_SPLIT_PERC 100 +#define H5A_NAME_BT2_NODE_SIZE 512 +#define H5A_NAME_BT2_MERGE_PERC 40 +#define H5A_NAME_BT2_SPLIT_PERC 100 /* v2 B-tree creation macros for 'corder' field index */ -#define H5A_CORDER_BT2_NODE_SIZE 512 -#define H5A_CORDER_BT2_MERGE_PERC 40 -#define H5A_CORDER_BT2_SPLIT_PERC 100 +#define H5A_CORDER_BT2_NODE_SIZE 512 +#define H5A_CORDER_BT2_MERGE_PERC 40 +#define H5A_CORDER_BT2_SPLIT_PERC 100 /* Size of stack buffer for serialized attributes */ -#define H5A_ATTR_BUF_SIZE 128 - +#define H5A_ATTR_BUF_SIZE 128 /******************/ /* Local Typedefs */ @@ -71,11 +68,11 @@ */ typedef struct H5A_bt2_od_wrt_t { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle to operate on */ - H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ - H5A_t *attr; /* Attribute to write */ - haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle to operate on */ + H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ + H5A_t * attr; /* Attribute to write */ + haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ } H5A_bt2_od_wrt_t; /* @@ -84,19 +81,19 @@ typedef struct H5A_bt2_od_wrt_t { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ - H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ - hsize_t count; /* # of attributes examined */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle */ + H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ + hsize_t count; /* # of attributes examined */ /* downward (from application) */ - hid_t loc_id; /* Object ID for application callback */ - hsize_t skip; /* Number of attributes to skip */ - const H5A_attr_iter_op_t *attr_op; /* Callback for each attribute */ - void *op_data; /* Callback data for each attribute */ + hid_t loc_id; /* Object ID for application callback */ + hsize_t skip; /* Number of attributes to skip */ + const H5A_attr_iter_op_t *attr_op; /* Callback for each attribute */ + void * op_data; /* Callback data for each attribute */ /* upward */ - int op_ret; /* Return value from callback */ + int op_ret; /* Return value from callback */ } H5A_bt2_ud_it_t; /* @@ -106,11 +103,11 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - const H5A_dense_bt2_name_rec_t *record; /* v2 B-tree record for attribute */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + const H5A_dense_bt2_name_rec_t *record; /* v2 B-tree record for attribute */ /* upward */ - H5A_t *attr; /* Copy of attribute */ + H5A_t *attr; /* Copy of attribute */ } H5A_fh_ud_cp_t; /* @@ -119,8 +116,8 @@ typedef struct { */ typedef struct H5A_bt2_ud_rm_t { /* downward */ - H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ - haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ + H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ + haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ } H5A_bt2_ud_rm_t; /* @@ -129,40 +126,33 @@ typedef struct H5A_bt2_ud_rm_t { */ typedef struct H5A_bt2_ud_rmbi_t { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ - H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ - H5_index_t idx_type; /* Index type for operation */ - haddr_t other_bt2_addr; /* v2 B-tree address of "other" index */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t * fheap; /* Fractal heap handle */ + H5HF_t * shared_fheap; /* Fractal heap handle for shared messages */ + H5_index_t idx_type; /* Index type for operation */ + haddr_t other_bt2_addr; /* v2 B-tree address of "other" index */ } H5A_bt2_ud_rmbi_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5A__dense_create * @@ -180,10 +170,10 @@ H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo) { H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for names */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for names */ + H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -192,96 +182,95 @@ H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo) HDassert(ainfo); /* Set fractal heap creation parameters */ -/* XXX: Give some control of these to applications? */ + /* XXX: Give some control of these to applications? */ HDmemset(&fheap_cparam, 0, sizeof(fheap_cparam)); - fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; + fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; fheap_cparam.managed.start_block_size = H5O_FHEAP_MAN_START_BLOCK_SIZE; - fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; - fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; - fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; - fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; - fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; + fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; + fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; + fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; + fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; + fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; /* Create fractal heap for storing attributes */ - if(NULL == (fheap = H5HF_create(f, &fheap_cparam))) + if (NULL == (fheap = H5HF_create(f, &fheap_cparam))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create fractal heap") /* Retrieve the heap's address in the file */ - if(H5HF_get_heap_addr(fheap, &ainfo->fheap_addr) < 0) + if (H5HF_get_heap_addr(fheap, &ainfo->fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address") #ifdef QAK -HDfprintf(stderr, "%s: ainfo->fheap_addr = %a\n", FUNC, ainfo->fheap_addr); + HDfprintf(stderr, "%s: ainfo->fheap_addr = %a\n", FUNC, ainfo->fheap_addr); #endif /* QAK */ #ifndef NDEBUG -{ - size_t fheap_id_len; /* Fractal heap ID length */ + { + size_t fheap_id_len; /* Fractal heap ID length */ - /* Retrieve the heap's ID length in the file */ - if(H5HF_get_id_len(fheap, &fheap_id_len) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") - HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); + /* Retrieve the heap's ID length in the file */ + if (H5HF_get_id_len(fheap, &fheap_id_len) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") + HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); #ifdef QAK -HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); + HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); #endif /* QAK */ -} + } #endif /* NDEBUG */ /* Create the name index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); - bt2_cparam.cls = H5A_BT2_NAME; + bt2_cparam.cls = H5A_BT2_NAME; bt2_cparam.node_size = (size_t)H5A_NAME_BT2_NODE_SIZE; - bt2_cparam.rrec_size = 4 + /* Name's hash value */ - 4 + /* Creation order index */ - 1 + /* Message flags */ - H5O_FHEAP_ID_LEN; /* Fractal heap ID */ + bt2_cparam.rrec_size = 4 + /* Name's hash value */ + 4 + /* Creation order index */ + 1 + /* Message flags */ + H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) + if (NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2_name, &ainfo->name_bt2_addr) < 0) + if (H5B2_get_addr(bt2_name, &ainfo->name_bt2_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get v2 B-tree address for name index") #ifdef QAK -HDfprintf(stderr, "%s: ainfo->name_bt2_addr = %a\n", FUNC, ainfo->name_bt2_addr); + HDfprintf(stderr, "%s: ainfo->name_bt2_addr = %a\n", FUNC, ainfo->name_bt2_addr); #endif /* QAK */ /* Check if we should create a creation order index v2 B-tree */ - if(ainfo->index_corder) { + if (ainfo->index_corder) { /* Create the creation order index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); - bt2_cparam.cls = H5A_BT2_CORDER; + bt2_cparam.cls = H5A_BT2_CORDER; bt2_cparam.node_size = (size_t)H5A_CORDER_BT2_NODE_SIZE; - bt2_cparam.rrec_size = 4 + /* Creation order index */ - 1 + /* Message flags */ - H5O_FHEAP_ID_LEN; /* Fractal heap ID */ + bt2_cparam.rrec_size = 4 + /* Creation order index */ + 1 + /* Message flags */ + H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) + if (NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2_corder, &ainfo->corder_bt2_addr) < 0) + if (H5B2_get_addr(bt2_corder, &ainfo->corder_bt2_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get v2 B-tree address for creation order index") #ifdef QAK -HDfprintf(stderr, "%s: ainfo->corder_bt2_addr = %a\n", FUNC, ainfo->corder_bt2_addr); + HDfprintf(stderr, "%s: ainfo->corder_bt2_addr = %a\n", FUNC, ainfo->corder_bt2_addr); #endif /* QAK */ - } /* end if */ + } /* end if */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_create() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_fnd_cb * @@ -298,7 +287,7 @@ static herr_t H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) { const H5A_t **user_attr = (const H5A_t **)_user_attr; /* User data from v2 B-tree attribute lookup */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -322,26 +311,25 @@ H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) * which may be merged/redistributed, we need to free the dynamically * allocated spaces for the intermediate decoded attribute. */ - if(*user_attr != NULL) { + if (*user_attr != NULL) { H5A_t *old_attr = *(H5A_t **)_user_attr; /* Free any dynamically allocated items */ - if(old_attr->shared) - if(H5A__shared_free(old_attr) < 0) + if (old_attr->shared) + if (H5A__shared_free(old_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") old_attr = H5FL_FREE(H5A_t, old_attr); - } /* end if */ + } /* end if */ /* Take over attribute ownership */ - *user_attr = attr; + *user_attr = attr; *took_ownership = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_fnd_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_open * @@ -357,13 +345,13 @@ done: H5A_t * H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { - H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ - htri_t attr_exists; /* Attribute exists in v2 B-tree */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t attr_sharable; /* Flag indicating attributes are sharable */ + htri_t attr_exists; /* Attribute exists in v2 B-tree */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -373,63 +361,62 @@ H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) HDassert(name); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record find */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.name = name; - udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.flags = 0; - udata.corder = 0; - udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.name = name; + udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.flags = 0; + udata.corder = 0; + udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.found_op_data = &ret_value; /* Find & copy the attribute in the 'name' index */ - if((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) + if ((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't search for attribute in name index") - else if(attr_exists == FALSE) + else if (attr_exists == FALSE) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't locate attribute in name index") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_open() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_insert * @@ -445,16 +432,16 @@ done: herr_t H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) { - H5A_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */ - H5HF_t *fheap = NULL; /* Fractal heap handle for attributes */ - H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ - uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing message */ - unsigned mesg_flags = 0; /* Flags for storing message */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */ + H5HF_t * fheap = NULL; /* Fractal heap handle for attributes */ + H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5WB_t * wb = NULL; /* Wrapped buffer for attribute data */ + uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing message */ + unsigned mesg_flags = 0; /* Flags for storing message */ + htri_t attr_sharable; /* Flag indicating attributes are sharable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -464,23 +451,23 @@ H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) HDassert(attr); /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ - htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ /* Check if message is already shared */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) < 0) + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared") - else if(shared_mesg > 0) + else if (shared_mesg > 0) /* Mark the message as shared */ mesg_flags |= H5O_MSG_FLAG_SHARED; else { /* Should this attribute be written as a SOHM? */ - if(H5SM_try_share(f, NULL, 0, H5O_ATTR_ID, attr, &mesg_flags) < 0) + if (H5SM_try_share(f, NULL, 0, H5O_ATTR_ID, attr, &mesg_flags) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Attributes can't be "unique be shareable" yet */ @@ -488,23 +475,23 @@ H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) } /* end else */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check for inserting shared attribute */ - if(mesg_flags & H5O_MSG_FLAG_SHARED) { + if (mesg_flags & H5O_MSG_FLAG_SHARED) { /* Sanity check */ HDassert(attr_sharable); @@ -512,80 +499,79 @@ H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) udata.id = attr->sh_loc.u.heap_id; } /* end if */ else { - void *attr_ptr; /* Pointer to serialized message */ - size_t attr_size; /* Size of serialized attribute in the heap */ + void * attr_ptr; /* Pointer to serialized message */ + size_t attr_size; /* Size of serialized attribute in the heap */ /* Find out the size of buffer needed for serialized message */ - if((attr_size = H5O_msg_raw_size(f, H5O_ATTR_ID, FALSE, attr)) == 0) + if ((attr_size = H5O_msg_raw_size(f, H5O_ATTR_ID, FALSE, attr)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get message size") /* Wrap the local buffer for serialized attributes */ - if(NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) + if (NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for attribute */ - if(NULL == (attr_ptr = H5WB_actual(wb, attr_size))) + if (NULL == (attr_ptr = H5WB_actual(wb, attr_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Create serialized form of attribute or shared message */ - if(H5O_msg_encode(f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, attr) < 0) + if (H5O_msg_encode(f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute") /* Insert the serialized attribute into the fractal heap */ /* (sets the heap ID in the user data) */ - if(H5HF_insert(fheap, attr_size, attr_ptr, &udata.id) < 0) + if (H5HF_insert(fheap, attr_size, attr_ptr, &udata.id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert attribute into fractal heap") } /* end else */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ - udata.common.f = f; - udata.common.fheap = fheap; + udata.common.f = f; + udata.common.fheap = fheap; udata.common.shared_fheap = shared_fheap; - udata.common.name = attr->shared->name; - udata.common.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); + udata.common.name = attr->shared->name; + udata.common.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); H5_CHECKED_ASSIGN(udata.common.flags, uint8_t, mesg_flags, unsigned); - udata.common.corder = attr->shared->crt_idx; - udata.common.found_op = NULL; + udata.common.corder = attr->shared->crt_idx; + udata.common.found_op = NULL; udata.common.found_op_data = NULL; /* udata.id already set */ /* Insert attribute into 'name' tracking v2 B-tree */ - if(H5B2_insert(bt2_name, &udata) < 0) + if (H5B2_insert(bt2_name, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") /* Check if we should create a creation order index v2 B-tree record */ - if(ainfo->index_corder) { + if (ainfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) + if (NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ - if(H5B2_insert(bt2_corder, &udata) < 0) + if (H5B2_insert(bt2_corder, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") } /* end if */ done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_insert() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_write_bt2_cb2 * @@ -603,7 +589,7 @@ static herr_t H5A__dense_write_bt2_cb2(void *_record, void *_op_data, hbool_t *changed) { H5A_dense_bt2_corder_rec_t *record = (H5A_dense_bt2_corder_rec_t *)_record; /* Record from B-tree */ - H5O_fheap_id_t *new_heap_id = (H5O_fheap_id_t *)_op_data; /* "op data" from v2 B-tree modify */ + H5O_fheap_id_t *new_heap_id = (H5O_fheap_id_t *)_op_data; /* "op data" from v2 B-tree modify */ FUNC_ENTER_STATIC_NOERR @@ -620,7 +606,6 @@ H5A__dense_write_bt2_cb2(void *_record, void *_op_data, hbool_t *changed) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5A__dense_write_bt2_cb2() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_write_bt2_cb * @@ -636,12 +621,12 @@ H5A__dense_write_bt2_cb2(void *_record, void *_op_data, hbool_t *changed) static herr_t H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) { - H5A_dense_bt2_name_rec_t *record = (H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ - H5A_bt2_od_wrt_t *op_data = (H5A_bt2_od_wrt_t *)_op_data; /* "op data" from v2 B-tree modify */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ - uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing attribute */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_dense_bt2_name_rec_t *record = (H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ + H5A_bt2_od_wrt_t * op_data = (H5A_bt2_od_wrt_t *)_op_data; /* "op data" from v2 B-tree modify */ + H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5WB_t * wb = NULL; /* Wrapped buffer for attribute data */ + uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing attribute */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -650,35 +635,37 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) HDassert(op_data); /* Check for modifying shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) { + if (record->flags & H5O_MSG_FLAG_SHARED) { /* Update the shared attribute in the SOHM info */ - if(H5O__attr_update_shared(op_data->f, NULL, op_data->attr, NULL) < 0) + if (H5O__attr_update_shared(op_data->f, NULL, op_data->attr, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute in shared storage") /* Update record's heap ID */ record->id = op_data->attr->sh_loc.u.heap_id; /* Check if we need to modify the creation order index with new heap ID */ - if(H5F_addr_defined(op_data->corder_bt2_addr)) { - H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ + if (H5F_addr_defined(op_data->corder_bt2_addr)) { + H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(op_data->f, op_data->corder_bt2_addr, NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Create the "udata" information for v2 B-tree record modify */ - udata.f = op_data->f; - udata.fheap = NULL; - udata.shared_fheap = NULL; - udata.name = NULL; - udata.name_hash = 0; - udata.flags = 0; - udata.corder = op_data->attr->shared->crt_idx; - udata.found_op = NULL; + udata.f = op_data->f; + udata.fheap = NULL; + udata.shared_fheap = NULL; + udata.name = NULL; + udata.name_hash = 0; + udata.flags = 0; + udata.corder = op_data->attr->shared->crt_idx; + udata.found_op = NULL; udata.found_op_data = NULL; /* Modify record for creation order index */ - if(H5B2_modify(bt2_corder, &udata, H5A__dense_write_bt2_cb2, &op_data->attr->sh_loc.u.heap_id) < 0) + if (H5B2_modify(bt2_corder, &udata, H5A__dense_write_bt2_cb2, &op_data->attr->sh_loc.u.heap_id) < + 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to modify record in v2 B-tree") } /* end if */ @@ -686,52 +673,51 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) *changed = TRUE; } /* end if */ else { - void *attr_ptr; /* Pointer to serialized message */ - size_t attr_size; /* Size of serialized attribute in the heap */ + void * attr_ptr; /* Pointer to serialized message */ + size_t attr_size; /* Size of serialized attribute in the heap */ /* Find out the size of buffer needed for serialized attribute */ - if((attr_size = H5O_msg_raw_size(op_data->f, H5O_ATTR_ID, FALSE, op_data->attr)) == 0) + if ((attr_size = H5O_msg_raw_size(op_data->f, H5O_ATTR_ID, FALSE, op_data->attr)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get attribute size") /* Wrap the local buffer for serialized attributes */ - if(NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) + if (NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for attribute */ - if(NULL == (attr_ptr = H5WB_actual(wb, attr_size))) + if (NULL == (attr_ptr = H5WB_actual(wb, attr_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Create serialized form of attribute */ - if(H5O_msg_encode(op_data->f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, op_data->attr) < 0) + if (H5O_msg_encode(op_data->f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, op_data->attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute") /* Sanity check */ #ifndef NDEBUG -{ - size_t obj_len; /* Length of existing encoded attribute */ + { + size_t obj_len; /* Length of existing encoded attribute */ - if(H5HF_get_obj_len(op_data->fheap, &record->id, &obj_len) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get object size") - HDassert(obj_len == attr_size); -} + if (H5HF_get_obj_len(op_data->fheap, &record->id, &obj_len) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get object size") + HDassert(obj_len == attr_size); + } #endif /* NDEBUG */ /* Update existing attribute in heap */ /* (might be more efficient as fractal heap 'op' callback, but leave that for later -QAK) */ - if(H5HF_write(op_data->fheap, &record->id, changed, attr_ptr) < 0) + if (H5HF_write(op_data->fheap, &record->id, changed, attr_ptr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute in heap") } /* end else */ done: /* Release resources */ - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_write_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_write * @@ -747,13 +733,13 @@ done: herr_t H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) { - H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ - H5A_bt2_od_wrt_t op_data; /* "Op data" for v2 B-tree modify */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ + H5A_bt2_od_wrt_t op_data; /* "Op data" for v2 B-tree modify */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t attr_sharable; /* Flag indicating attributes are sharable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -765,68 +751,67 @@ H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) HDassert(attr); /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.name = attr->shared->name; - udata.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); - udata.flags = 0; - udata.corder = 0; - udata.found_op = NULL; + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.name = attr->shared->name; + udata.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); + udata.flags = 0; + udata.corder = 0; + udata.found_op = NULL; udata.found_op_data = NULL; /* Create the "op_data" for the v2 B-tree record 'modify' callback */ - op_data.f = f; - op_data.fheap = fheap; - op_data.shared_fheap = shared_fheap; - op_data.attr = attr; + op_data.f = f; + op_data.fheap = fheap; + op_data.shared_fheap = shared_fheap; + op_data.attr = attr; op_data.corder_bt2_addr = ainfo->corder_bt2_addr; /* Modify attribute through 'name' tracking v2 B-tree */ - if(H5B2_modify(bt2_name, &udata, H5A__dense_write_bt2_cb, &op_data) < 0) + if (H5B2_modify(bt2_name, &udata, H5A__dense_write_bt2_cb, &op_data) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to modify record in v2 B-tree") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_write() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_copy_fh_cb * @@ -843,8 +828,8 @@ done: static herr_t H5A__dense_copy_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5A_fh_ud_cp_t *udata = (H5A_fh_ud_cp_t *)_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_fh_ud_cp_t *udata = (H5A_fh_ud_cp_t *)_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -855,21 +840,21 @@ H5A__dense_copy_fh_cb(const void *obj, size_t obj_len, void *_udata) * HDF5 routine, it could attempt to re-protect that direct block for the * heap, causing the HDF5 routine called to fail) */ - if(NULL == (udata->attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (udata->attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, FAIL, "can't decode attribute") /* Set the creation order index for the attribute */ udata->attr->shared->crt_idx = udata->record->corder; /* Check whether we should "reconstitute" the shared message info */ - if(udata->record->flags & H5O_MSG_FLAG_SHARED) + if (udata->record->flags & H5O_MSG_FLAG_SHARED) H5SM_reconstitute(&(udata->attr->sh_loc), udata->f, H5O_ATTR_ID, udata->record->id); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_copy_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_rename * @@ -883,19 +868,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, - const char *new_name) +H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, const char *new_name) { - H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order ndex */ - H5A_t *attr_copy = NULL; /* Copy of attribute to rename */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ - htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ - htri_t attr_exists; /* Attribute exists in v2 B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order ndex */ + H5A_t * attr_copy = NULL; /* Copy of attribute to rename */ + htri_t attr_sharable; /* Flag indicating attributes are sharable */ + htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ + htri_t attr_exists; /* Attribute exists in v2 B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -906,55 +890,55 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, HDassert(new_name); /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.name = old_name; - udata.name_hash = H5_checksum_lookup3(old_name, HDstrlen(old_name), 0); - udata.flags = 0; - udata.corder = 0; - udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.name = old_name; + udata.name_hash = H5_checksum_lookup3(old_name, HDstrlen(old_name), 0); + udata.flags = 0; + udata.corder = 0; + udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.found_op_data = &attr_copy; /* Get copy of attribute through 'name' tracking v2 B-tree */ - if((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) + if ((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") - else if(attr_exists == FALSE) + else if (attr_exists == FALSE) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute in name index") HDassert(attr_copy); /* Check if message is already shared */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) < 0) + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared") - else if(shared_mesg > 0) { + else if (shared_mesg > 0) { /* Reset shared status of copy */ /* (so it will get shared again if necessary) */ attr_copy->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; @@ -965,47 +949,48 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, attr_copy->shared->name = H5MM_xstrdup(new_name); /* Recompute the version to encode the attribute with */ - if(H5A__set_version(f, attr_copy) < 0) + if (H5A__set_version(f, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "unable to update attribute version") /* Need to remove the attribute from the creation order index v2 B-tree */ - if(ainfo->index_corder) { - htri_t corder_attr_exists; /* Attribute exists in v2 B-tree */ + if (ainfo->index_corder) { + htri_t corder_attr_exists; /* Attribute exists in v2 B-tree */ /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) + if (NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation index") /* Set up the creation order to search for */ udata.corder = attr_copy->shared->crt_idx; - if((corder_attr_exists = H5B2_find(bt2_corder, &udata, NULL, NULL)) < 0) + if ((corder_attr_exists = H5B2_find(bt2_corder, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") - if(corder_attr_exists) { + if (corder_attr_exists) { H5A_bt2_ud_rm_t rm_udata; /* Set up the creation order in user data for the v2 B-tree 'record remove' callback */ rm_udata.common.corder = attr_copy->shared->crt_idx; /* Remove the record from the creation order index v2 B-tree */ - if(H5B2_remove(bt2_corder, &rm_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from creation order index v2 B-tree") + if (H5B2_remove(bt2_corder, &rm_udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, + "unable to remove attribute from creation order index v2 B-tree") } } /* Insert renamed attribute back into dense storage */ /* (Possibly making it shared) */ - if(H5A__dense_insert(f, ainfo, attr_copy) < 0) + if (H5A__dense_insert(f, ainfo, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to add to dense storage") /* Was this attribute shared? */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) > 0) { - hsize_t attr_rc; /* Attribute's ref count in shared message storage */ + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) > 0) { + hsize_t attr_rc; /* Attribute's ref count in shared message storage */ /* Retrieve ref count for shared attribute */ - if(H5SM_get_refcount(f, H5O_ATTR_ID, &attr_copy->sh_loc, &attr_rc) < 0) + if (H5SM_get_refcount(f, H5O_ATTR_ID, &attr_copy->sh_loc, &attr_rc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") /* If the newly shared attribute needs to share "ownership" of the shared @@ -1015,42 +1000,41 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, * * *ick* -QAK, 2007/01/08 */ - if(attr_rc == 1) { + if (attr_rc == 1) { /* Increment reference count on attribute components */ - if(H5O__attr_link(f, NULL, attr_copy) < 0) + if (H5O__attr_link(f, NULL, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") } /* end if */ - } /* end if */ - else if(shared_mesg == 0) { + } /* end if */ + else if (shared_mesg == 0) { /* Increment reference count on attribute components */ /* (so that they aren't deleted when the attribute is removed shortly) */ - if(H5O__attr_link(f, NULL, attr_copy) < 0) + if (H5O__attr_link(f, NULL, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") } /* end if */ - else if(shared_mesg < 0) + else if (shared_mesg < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Delete old attribute from dense storage */ - if(H5A__dense_remove(f, ainfo, old_name) < 0) + if (H5A__dense_remove(f, ainfo, old_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(attr_copy) + if (attr_copy) H5O_msg_free(H5O_ATTR_ID, attr_copy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_rename() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_iterate_bt2_cb * @@ -1066,54 +1050,56 @@ done: static int H5A__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) { - const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ - H5A_bt2_ud_it_t *bt2_udata = (H5A_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + const H5A_dense_bt2_name_rec_t *record = + (const H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ + H5A_bt2_ud_it_t *bt2_udata = (H5A_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC /* Check for skipping attributes */ - if(bt2_udata->skip > 0) + if (bt2_udata->skip > 0) --bt2_udata->skip; else { - H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ - H5HF_t *fheap; /* Fractal heap handle for attribute storage */ + H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5HF_t * fheap; /* Fractal heap handle for attribute storage */ /* Check for iterating over shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) + if (record->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.record = record; - fh_udata.attr = NULL; + fh_udata.attr = NULL; /* Call fractal heap 'op' routine, to copy the attribute information */ - if(H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) + if (H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, H5_ITER_ERROR, "heap op callback failed") /* Check which type of callback to make */ - switch(bt2_udata->attr_op->op_type) { - case H5A_ATTR_OP_APP2: - { - H5A_info_t ainfo; /* Info for attribute */ + switch (bt2_udata->attr_op->op_type) { + case H5A_ATTR_OP_APP2: { + H5A_info_t ainfo; /* Info for attribute */ /* Get the attribute information */ - if(H5A__get_info(fh_udata.attr, &ainfo) < 0) + if (H5A__get_info(fh_udata.attr, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5_ITER_ERROR, "unable to get attribute info") /* Make the application callback */ - ret_value = (bt2_udata->attr_op->u.app_op2)(bt2_udata->loc_id, fh_udata.attr->shared->name, &ainfo, bt2_udata->op_data); + ret_value = (bt2_udata->attr_op->u.app_op2)(bt2_udata->loc_id, fh_udata.attr->shared->name, + &ainfo, bt2_udata->op_data); break; } #ifndef H5_NO_DEPRECATED_SYMBOLS case H5A_ATTR_OP_APP: /* Make the application callback */ - ret_value = (bt2_udata->attr_op->u.app_op)(bt2_udata->loc_id, fh_udata.attr->shared->name, bt2_udata->op_data); + ret_value = (bt2_udata->attr_op->u.app_op)(bt2_udata->loc_id, fh_udata.attr->shared->name, + bt2_udata->op_data); break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1126,7 +1112,7 @@ H5A__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) HDassert("unknown attribute op type" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unsupported attribute op type") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /* Release the space allocated for the attribute */ @@ -1138,14 +1124,13 @@ H5A__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) bt2_udata->count++; /* Check for callback failure and pass along return value */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_iterate_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_iterate * @@ -1159,16 +1144,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, - const H5A_attr_iter_op_t *attr_op, void *op_data) +H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, + void *op_data) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - herr_t ret_value = FAIL; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1180,12 +1165,12 @@ H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, HDassert(attr_op); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. */ - if(order == H5_ITER_NATIVE) { + if (order == H5_ITER_NATIVE) { HDassert(H5F_addr_defined(ainfo->name_bt2_addr)); bt2_addr = ainfo->name_bt2_addr; } /* end if */ @@ -1203,83 +1188,82 @@ H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, } /* end else */ /* Check on iteration order */ - if(order == H5_ITER_NATIVE && H5F_addr_defined(bt2_addr)) { - H5A_bt2_ud_it_t udata; /* User data for iterator callback */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + if (order == H5_ITER_NATIVE && H5F_addr_defined(bt2_addr)) { + H5A_bt2_ud_it_t udata; /* User data for iterator callback */ + htri_t attr_sharable; /* Flag indicating attributes are sharable */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ - udata.f = f; - udata.fheap = fheap; + udata.f = f; + udata.fheap = fheap; udata.shared_fheap = shared_fheap; - udata.loc_id = loc_id; - udata.skip = skip; - udata.count = 0; - udata.attr_op = attr_op; - udata.op_data = op_data; + udata.loc_id = loc_id; + udata.skip = skip; + udata.count = 0; + udata.attr_op = attr_op; + udata.op_data = op_data; /* Iterate over the records in the v2 B-tree's "native" order */ /* (by hash of name) */ - if((ret_value = H5B2_iterate(bt2, H5A__dense_iterate_bt2_cb, &udata)) < 0) + if ((ret_value = H5B2_iterate(bt2, H5A__dense_iterate_bt2_cb, &udata)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); /* Update the last attribute examined, if requested */ - if(last_attr) + if (last_attr) *last_attr = udata.count; } /* end if */ else { /* Build the table of attributes for this object */ /* (build table using the name index, but sort according to idx_type) */ - if(H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) + if (H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error building table of attributes") /* Iterate over attributes in table */ - if((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) + if ((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_iterate() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_remove_bt2_cb * @@ -1296,53 +1280,53 @@ static herr_t H5A__dense_remove_bt2_cb(const void *_record, void *_udata) { const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; - H5A_bt2_ud_rm_t *udata = (H5A_bt2_ud_rm_t *)_udata; /* User data for callback */ - H5A_t *attr = *(H5A_t **)udata->common.found_op_data; /* Pointer to attribute to remove */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_bt2_ud_rm_t * udata = (H5A_bt2_ud_rm_t *)_udata; /* User data for callback */ + H5A_t * attr = *(H5A_t **)udata->common.found_op_data; /* Pointer to attribute to remove */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for removing the link from the creation order index */ - if(H5F_addr_defined(udata->corder_bt2_addr)) { + if (H5F_addr_defined(udata->corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(udata->common.f, udata->corder_bt2_addr, NULL))) + if (NULL == (bt2_corder = H5B2_open(udata->common.f, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ udata->common.corder = attr->shared->crt_idx; /* Remove the record from the creation order index v2 B-tree */ - if(H5B2_remove(bt2_corder, udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from creation order index v2 B-tree") + if (H5B2_remove(bt2_corder, udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, + "unable to remove attribute from creation order index v2 B-tree") } /* end if */ /* Check for removing shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) { + if (record->flags & H5O_MSG_FLAG_SHARED) { /* Decrement the reference count on the shared attribute message */ - if(H5SM_delete(udata->common.f, NULL, &(attr->sh_loc)) < 0) + if (H5SM_delete(udata->common.f, NULL, &(attr->sh_loc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { /* Perform the deletion action on the attribute */ /* (takes care of shared & committed datatype/dataspace components) */ - if(H5O__attr_delete(udata->common.f, NULL, attr) < 0) + if (H5O__attr_delete(udata->common.f, NULL, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") /* Remove record from fractal heap */ - if(H5HF_remove(udata->common.fheap, &record->id) < 0) + if (H5HF_remove(udata->common.fheap, &record->id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from fractal heap") } /* end else */ done: /* Release resources */ - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_remove * @@ -1358,13 +1342,13 @@ done: herr_t H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { - H5A_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5A_t *attr_copy = NULL; /* Copy of attribute to remove */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5A_t * attr_copy = NULL; /* Copy of attribute to remove */ + htri_t attr_sharable; /* Flag indicating attributes are sharable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1374,62 +1358,61 @@ H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) HDassert(name && *name); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.common.f = f; - udata.common.fheap = fheap; - udata.common.shared_fheap = shared_fheap; - udata.common.name = name; - udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.common.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ + udata.common.f = f; + udata.common.fheap = fheap; + udata.common.shared_fheap = shared_fheap; + udata.common.name = name; + udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.common.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.common.found_op_data = &attr_copy; - udata.corder_bt2_addr = ainfo->corder_bt2_addr; + udata.corder_bt2_addr = ainfo->corder_bt2_addr; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove(bt2_name, &udata, H5A__dense_remove_bt2_cb, &udata) < 0) + if (H5B2_remove(bt2_name, &udata, H5A__dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from name index v2 B-tree") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(attr_copy) + if (attr_copy) H5O_msg_free_real(H5O_MSG_ATTR, attr_copy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_remove_by_idx_bt2_cb * @@ -1445,32 +1428,32 @@ done: static herr_t H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { - H5HF_t *fheap; /* Fractal heap handle */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ + H5HF_t * fheap; /* Fractal heap handle */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; /* v2 B-tree record */ - H5A_bt2_ud_rmbi_t *bt2_udata = (H5A_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */ - H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ - H5O_shared_t sh_loc; /* Shared message info for attribute */ - hbool_t use_sh_loc; /* Whether to use the attribute's shared location or the separate one */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_bt2_ud_rmbi_t * bt2_udata = (H5A_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */ + H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5O_shared_t sh_loc; /* Shared message info for attribute */ + hbool_t use_sh_loc; /* Whether to use the attribute's shared location or the separate one */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Set up the user data for fractal heap 'op' callback */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.record = record; - fh_udata.attr = NULL; + fh_udata.attr = NULL; /* Get correct fractal heap handle to use for operations */ - if(record->flags & H5O_MSG_FLAG_SHARED) + if (record->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; /* Check whether to make a copy of the attribute or just need the shared location info */ - if(H5F_addr_defined(bt2_udata->other_bt2_addr) || !(record->flags & H5O_MSG_FLAG_SHARED)) { + if (H5F_addr_defined(bt2_udata->other_bt2_addr) || !(record->flags & H5O_MSG_FLAG_SHARED)) { /* Call fractal heap 'op' routine, to make copy of attribute to remove */ - if(H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) + if (H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, FAIL, "attribute removal callback failed") HDassert(fh_udata.attr); @@ -1486,11 +1469,11 @@ H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Check for removing the link from the "other" index (creation order, when name used and vice versa) */ - if(H5F_addr_defined(bt2_udata->other_bt2_addr)) { - H5A_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ + if (H5F_addr_defined(bt2_udata->other_bt2_addr)) { + H5A_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ /* Determine the index being used */ - if(bt2_udata->idx_type == H5_INDEX_NAME) { + if (bt2_udata->idx_type == H5_INDEX_NAME) { /* Set up the user data for the v2 B-tree 'record remove' callback */ other_bt2_udata.corder = fh_udata.attr->shared->crt_idx; } /* end if */ @@ -1498,62 +1481,63 @@ H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) HDassert(bt2_udata->idx_type == H5_INDEX_CRT_ORDER); /* Set up the user data for the v2 B-tree 'record remove' callback */ - other_bt2_udata.f = bt2_udata->f; - other_bt2_udata.fheap = bt2_udata->fheap; + other_bt2_udata.f = bt2_udata->f; + other_bt2_udata.fheap = bt2_udata->fheap; other_bt2_udata.shared_fheap = bt2_udata->shared_fheap; - other_bt2_udata.name = fh_udata.attr->shared->name; - other_bt2_udata.name_hash = H5_checksum_lookup3(fh_udata.attr->shared->name, HDstrlen(fh_udata.attr->shared->name), 0); - other_bt2_udata.found_op = NULL; + other_bt2_udata.name = fh_udata.attr->shared->name; + other_bt2_udata.name_hash = + H5_checksum_lookup3(fh_udata.attr->shared->name, HDstrlen(fh_udata.attr->shared->name), 0); + other_bt2_udata.found_op = NULL; other_bt2_udata.found_op_data = NULL; } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set the common information for the v2 B-tree remove operation */ /* Remove the record from the "other" index v2 B-tree */ - if(H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove record from 'other' index v2 B-tree") + if (H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, + "unable to remove record from 'other' index v2 B-tree") } /* end if */ /* Check for removing shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) { - H5O_shared_t *sh_loc_ptr; /* Pointer to shared message info for attribute */ + if (record->flags & H5O_MSG_FLAG_SHARED) { + H5O_shared_t *sh_loc_ptr; /* Pointer to shared message info for attribute */ /* Set up pointer to correct shared location */ - if(use_sh_loc) + if (use_sh_loc) sh_loc_ptr = &sh_loc; else sh_loc_ptr = &(fh_udata.attr->sh_loc); /* Decrement the reference count on the shared attribute message */ - if(H5SM_delete(bt2_udata->f, NULL, sh_loc_ptr) < 0) + if (H5SM_delete(bt2_udata->f, NULL, sh_loc_ptr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { /* Perform the deletion action on the attribute */ /* (takes care of shared & committed datatype/dataspace components) */ - if(H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) + if (H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") /* Remove record from fractal heap */ - if(H5HF_remove(fheap, &record->id) < 0) + if (H5HF_remove(fheap, &record->id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from fractal heap") } /* end else */ done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(fh_udata.attr) + if (fh_udata.attr) H5O_msg_free(H5O_ATTR_ID, fh_udata.attr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_by_idx_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_remove_by_idx * @@ -1568,15 +1552,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - haddr_t bt2_addr; /* Address of v2 B-tree to use for operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1585,12 +1569,12 @@ H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type HDassert(ainfo); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. */ - if(order == H5_ITER_NATIVE) { + if (order == H5_ITER_NATIVE) { bt2_addr = ainfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ @@ -1608,79 +1592,78 @@ H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type } /* end else */ /* If there is an index defined for the field, use it */ - if(H5F_addr_defined(bt2_addr)) { - H5A_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + if (H5F_addr_defined(bt2_addr)) { + H5A_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */ + htri_t attr_sharable; /* Flag indicating attributes are sharable */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.idx_type = idx_type; + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.idx_type = idx_type; udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? ainfo->corder_bt2_addr : ainfo->name_bt2_addr; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove_by_idx(bt2, order, n, H5A__dense_remove_by_idx_bt2_cb, &udata) < 0) + if (H5B2_remove_by_idx(bt2, order, n, H5A__dense_remove_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from v2 B-tree index") } /* end if */ else { /* Build the table of attributes for this object */ /* (build table using the name index, but sort according to idx_type) */ - if(H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) + if (H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error building table of attributes") /* Check for skipping too many attributes */ - if(n >= atable.nattrs) + if (n >= atable.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Delete appropriate attribute from dense storage */ - if(H5A__dense_remove(f, ainfo, ((atable.attrs[n])->shared)->name) < 0) + if (H5A__dense_remove(f, ainfo, ((atable.attrs[n])->shared)->name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end else */ done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_exists * @@ -1697,12 +1680,12 @@ done: htri_t H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { - H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ - htri_t ret_value = TRUE; /* Return value */ + H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t attr_sharable; /* Flag indicating attributes are sharable */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE @@ -1712,61 +1695,60 @@ H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) HDassert(name); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") /* Get handle for shared message heap, if attributes are sharable */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record 'find' */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.name = name; - udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.flags = 0; - udata.corder = 0; - udata.found_op = NULL; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.name = name; + udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.flags = 0; + udata.corder = 0; + udata.found_op = NULL; /* v2 B-tree comparison callback */ udata.found_op_data = NULL; /* Find the attribute in the 'name' index */ - if((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) + if ((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_exists() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_delete_bt2_cb * @@ -1782,54 +1764,54 @@ done: static herr_t H5A__dense_delete_bt2_cb(const void *_record, void *_bt2_udata) { - const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ - H5A_bt2_ud_common_t *bt2_udata = (H5A_bt2_ud_common_t *)_bt2_udata; /* User data for callback */ - H5A_t *attr = NULL; /* Attribute being removed */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5A_dense_bt2_name_rec_t *record = + (const H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ + H5A_bt2_ud_common_t *bt2_udata = (H5A_bt2_ud_common_t *)_bt2_udata; /* User data for callback */ + H5A_t * attr = NULL; /* Attribute being removed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) { - H5O_shared_t sh_mesg; /* Temporary shared message info */ + if (record->flags & H5O_MSG_FLAG_SHARED) { + H5O_shared_t sh_mesg; /* Temporary shared message info */ /* "reconstitute" the shared message info for the attribute */ H5SM_reconstitute(&sh_mesg, bt2_udata->f, H5O_ATTR_ID, record->id); /* Decrement the reference count on the shared attribute message */ - if(H5SM_delete(bt2_udata->f, NULL, &sh_mesg) < 0) + if (H5SM_delete(bt2_udata->f, NULL, &sh_mesg) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { - H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.record = record; /* up */ fh_udata.attr = NULL; /* Call fractal heap 'op' routine, to copy the attribute information */ - if(H5HF_op(bt2_udata->fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, FAIL, "heap op callback failed") attr = fh_udata.attr; /* Perform the deletion action on the attribute */ /* (takes care of shared/committed datatype & dataspace components) */ - if(H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) + if (H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } /* end else */ done: /* Release resources */ - if(attr) + if (attr) H5O_msg_free_real(H5O_MSG_ATTR, attr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_delete_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_delete * @@ -1845,9 +1827,9 @@ done: herr_t H5A__dense_delete(H5F_t *f, H5O_ainfo_t *ainfo) { - H5A_bt2_ud_common_t udata; /* v2 B-tree user data for deleting attributes */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_bt2_ud_common_t udata; /* v2 B-tree user data for deleting attributes */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1856,47 +1838,46 @@ H5A__dense_delete(H5F_t *f, H5O_ainfo_t *ainfo) HDassert(ainfo); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Create the "udata" information for v2 B-tree 'delete' */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = NULL; - udata.name = NULL; - udata.name_hash = 0; - udata.flags = 0; - udata.found_op = NULL; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = NULL; + udata.name = NULL; + udata.name_hash = 0; + udata.flags = 0; + udata.found_op = NULL; /* v2 B-tree comparison callback */ udata.found_op_data = NULL; /* Delete name index v2 B-tree */ - if(H5B2_delete(f, ainfo->name_bt2_addr, NULL, H5A__dense_delete_bt2_cb, &udata) < 0) + if (H5B2_delete(f, ainfo->name_bt2_addr, NULL, H5A__dense_delete_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") ainfo->name_bt2_addr = HADDR_UNDEF; /* Release resources */ - if(H5HF_close(fheap) < 0) + if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") fheap = NULL; /* Check if we should delete the creation order index v2 B-tree */ - if(H5F_addr_defined(ainfo->corder_bt2_addr)) { + if (H5F_addr_defined(ainfo->corder_bt2_addr)) { /* Delete the creation order index, without adjusting the ref. count on the attributes */ - if(H5B2_delete(f, ainfo->corder_bt2_addr, NULL, NULL, NULL) < 0) + if (H5B2_delete(f, ainfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") ainfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ /* Delete fractal heap */ - if(H5HF_delete(f, ainfo->fheap_addr) < 0) + if (H5HF_delete(f, ainfo->fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") ainfo->fheap_addr = HADDR_UNDEF; done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_delete() */ - diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index dd5eae3..c445412 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -29,62 +29,53 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ -#include "H5VLprivate.h" /* Virtual object layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual object layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*-------------------------------------------------------------------------- NAME H5Acreate1 @@ -113,58 +104,57 @@ --------------------------------------------------------------------------*/ hid_t -H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, - hid_t acpl_id) +H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id) { - void *attr = NULL; /* attr object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * attr = NULL; /* attr object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, acpl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read") /* Get correct property list */ - if(H5P_DEFAULT == acpl_id) + if (H5P_DEFAULT == acpl_id) acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the attribute */ - if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, name, type_id, space_id, acpl_id, - H5P_ATTRIBUTE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == + (attr = H5VL_attr_create(vol_obj, &loc_params, name, type_id, space_id, acpl_id, + H5P_ATTRIBUTE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Clean up on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* end H5Acreate1() */ - /*-------------------------------------------------------------------------- NAME H5Aopen_name @@ -190,47 +180,46 @@ done: hid_t H5Aopen_name(hid_t loc_id, const char *name) { - void *attr = NULL; /* attr object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + void * attr = NULL; /* attr object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, name, H5P_ATTRIBUTE_ACCESS_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, name, H5P_ATTRIBUTE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Clean up on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen_name() */ - /*-------------------------------------------------------------------------- NAME H5Aopen_idx @@ -256,50 +245,49 @@ done: hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { - void *attr = NULL; /* attr object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * attr = NULL; /* attr object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "iIu", loc_id, idx); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = "."; - loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_CRT_ORDER; - loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; - loc_params.loc_data.loc_by_idx.n = (hsize_t)idx; - loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; + loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_CRT_ORDER; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = (hsize_t)idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, NULL, H5P_ATTRIBUTE_ACCESS_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, NULL, H5P_ATTRIBUTE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Clean up on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen_idx() */ - /*-------------------------------------------------------------------------- NAME H5Aget_num_attrs @@ -321,10 +309,10 @@ done: int H5Aget_num_attrs(hid_t loc_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_info2_t oinfo; - int ret_value = -1; + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5O_info2_t oinfo; + int ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", loc_id); @@ -333,11 +321,12 @@ H5Aget_num_attrs(hid_t loc_id) loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Get the number of attributes for the object */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &oinfo, H5O_INFO_NUM_ATTRS) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &oinfo, H5O_INFO_NUM_ATTRS) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute count for object") H5_CHECKED_ASSIGN(ret_value, int, oinfo.num_attrs, hsize_t); @@ -346,7 +335,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Aget_num_attrs() */ - /*-------------------------------------------------------------------------- NAME H5Aiterate1 @@ -387,26 +375,26 @@ done: herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(H5_ITER_ERROR) H5TRACE4("e", "i*Iux*x", loc_id, attr_num, op, op_data); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "location is not valid for an attribute") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") /* Call attribute iteration routine */ - if((ret_value = H5VL_attr_optional(vol_obj, H5VL_NATIVE_ATTR_ITERATE_OLD, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_id, attr_num, op, op_data)) < 0) + if ((ret_value = H5VL_attr_optional(vol_obj, H5VL_NATIVE_ATTR_ITERATE_OLD, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, loc_id, attr_num, op, op_data)) < 0) HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); done: FUNC_LEAVE_API(ret_value) } /* H5Aiterate1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Aint.c b/src/H5Aint.c index d6ea1f4..933cb3f 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -26,79 +26,73 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Data exchange structure to use when building table of compact attributes for an object */ typedef struct { - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5A_attr_table_t *atable; /* Pointer to attribute table to build */ - size_t curr_attr; /* Current attribute to operate on */ - hbool_t bogus_crt_idx; /* Whether bogus creation index values need to be set */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5A_attr_table_t *atable; /* Pointer to attribute table to build */ + size_t curr_attr; /* Current attribute to operate on */ + hbool_t bogus_crt_idx; /* Whether bogus creation index values need to be set */ } H5A_compact_bt_ud_t; /* Data exchange structure to use when building table of dense attributes for an object */ typedef struct { - H5A_attr_table_t *atable; /* Pointer to attribute table to build */ - size_t curr_attr; /* Current attribute to operate on */ + H5A_attr_table_t *atable; /* Pointer to attribute table to build */ + size_t curr_attr; /* Current attribute to operate on */ } H5A_dense_bt_ud_t; /* Data exchange structure to use when copying an attribute from _SRC to _DST */ typedef struct { - const H5O_ainfo_t *ainfo; /* dense information */ - H5F_t *file; /* file */ - hbool_t *recompute_size; /* Flag to indicate if size changed */ - H5O_copy_t *cpy_info; /* Information on copying options */ - const H5O_loc_t *oloc_src; - H5O_loc_t *oloc_dst; + const H5O_ainfo_t *ainfo; /* dense information */ + H5F_t * file; /* file */ + hbool_t * recompute_size; /* Flag to indicate if size changed */ + H5O_copy_t * cpy_info; /* Information on copying options */ + const H5O_loc_t * oloc_src; + H5O_loc_t * oloc_dst; } H5A_dense_file_cp_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5A__compact_build_table_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned *oh_flags_ptr, void *_udata/*in,out*/); +static herr_t H5A__compact_build_table_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned *oh_flags_ptr, void *_udata /*in,out*/); static herr_t H5A__dense_build_table_cb(const H5A_t *attr, void *_udata); -static int H5A__attr_cmp_name_inc(const void *attr1, const void *attr2); -static int H5A__attr_cmp_name_dec(const void *attr1, const void *attr2); -static int H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2); -static int H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2); -static herr_t H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, - H5_iter_order_t order); -static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5A_attr_iter_op_t *attr_op, void *op_data); +static int H5A__attr_cmp_name_inc(const void *attr1, const void *attr2); +static int H5A__attr_cmp_name_dec(const void *attr1, const void *attr2); +static int H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2); +static int H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2); +static herr_t H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, H5_iter_order_t order); +static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5A_attr_iter_op_t *attr_op, void *op_data); /*********************/ /* Package Variables */ @@ -106,26 +100,24 @@ static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, /* Format version bounds for attribute */ const unsigned H5O_attr_ver_bounds[] = { - H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_ATTR_VERSION_3, /* H5F_LIBVER_V18 */ - H5O_ATTR_VERSION_3, /* H5F_LIBVER_V110 */ - H5O_ATTR_VERSION_3, /* H5F_LIBVER_V112 */ - H5O_ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_ATTR_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_ATTR_VERSION_3, /* H5F_LIBVER_V110 */ + H5O_ATTR_VERSION_3, /* H5F_LIBVER_V112 */ + H5O_ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ -typedef H5A_t* H5A_t_ptr; +typedef H5A_t *H5A_t_ptr; H5FL_SEQ_DEFINE(H5A_t_ptr); - /*------------------------------------------------------------------------- * Function: H5A__create * @@ -139,14 +131,13 @@ H5FL_SEQ_DEFINE(H5A_t_ptr); *------------------------------------------------------------------------- */ H5A_t * -H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, - const H5S_t *space, hid_t acpl_id) +H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, const H5S_t *space, hid_t acpl_id) { - H5A_t *attr = NULL; /* Attribute created */ - hssize_t snelmts; /* elements in attribute */ - size_t nelmts; /* elements in attribute */ - htri_t exists; /* Whether attribute exists */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_t * attr = NULL; /* Attribute created */ + hssize_t snelmts; /* elements in attribute */ + size_t nelmts; /* elements in attribute */ + htri_t exists; /* Whether attribute exists */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->oloc->addr) @@ -161,38 +152,38 @@ H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, * name, but it's going to be hard to unwind all the special cases on * failure, so just check first, for now - QAK) */ - if((exists = H5O__attr_exists(loc->oloc, attr_name)) < 0) + if ((exists = H5O__attr_exists(loc->oloc, attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "error checking attributes") - else if(exists > 0) + else if (exists > 0) HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, NULL, "attribute already exists") /* Check if the dataspace has an extent set (or is NULL) */ - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, NULL, "dataspace extent has not been set") /* Check if the datatype is "sensible" for use in a dataset */ - if(H5T_is_sensible(type) != TRUE) + if (H5T_is_sensible(type) != TRUE) HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, NULL, "datatype is not sensible") /* Build the attribute information */ - if(NULL == (attr = H5FL_CALLOC(H5A_t))) + if (NULL == (attr = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed for attribute info") - if(NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) + if (NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "can't allocate shared attr structure") /* If the creation property list is H5P_ATTRIBUTE_CREATE_DEFAULT, use the default character encoding */ HDassert(acpl_id != H5P_DEFAULT); - if(acpl_id == H5P_ATTRIBUTE_CREATE_DEFAULT) + if (acpl_id == H5P_ATTRIBUTE_CREATE_DEFAULT) attr->shared->encoding = H5F_DEFAULT_CSET; else { - H5P_genplist_t *ac_plist; /* ACPL Property list */ + H5P_genplist_t *ac_plist; /* ACPL Property list */ /* Get a local copy of the attribute creation property list */ - if(NULL == (ac_plist = (H5P_genplist_t *)H5I_object(acpl_id))) + if (NULL == (ac_plist = (H5P_genplist_t *)H5I_object(acpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") - if(H5P_get(ac_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0) + if (H5P_get(ac_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get character encoding flag") } /* end else */ @@ -200,52 +191,52 @@ H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, attr->shared->name = H5MM_xstrdup(attr_name); /* Copy datatype */ - if(NULL == (attr->shared->dt = H5T_copy(type, H5T_COPY_ALL))) + if (NULL == (attr->shared->dt = H5T_copy(type, H5T_COPY_ALL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared datatype info") /* Convert a datatype (if committed) to a transient type if the committed datatype's file location is different from the file location where the attribute will be created */ - if(H5T_convert_committed_datatype(attr->shared->dt, loc->oloc->file) < 0) + if (H5T_convert_committed_datatype(attr->shared->dt, loc->oloc->file) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared datatype info") /* Mark datatype as being on disk now */ - if(H5T_set_loc(attr->shared->dt, H5F_VOL_OBJ(loc->oloc->file), H5T_LOC_DISK) < 0) + if (H5T_set_loc(attr->shared->dt, H5F_VOL_OBJ(loc->oloc->file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* Set the version for datatype */ - if(H5T_set_version(loc->oloc->file, attr->shared->dt) < 0) + if (H5T_set_version(loc->oloc->file, attr->shared->dt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set version of datatype") /* Copy the dataspace for the attribute */ attr->shared->ds = H5S_copy(space, FALSE, TRUE); /* Set the version for dataspace */ - if(H5S_set_version(loc->oloc->file, attr->shared->ds) < 0) + if (H5S_set_version(loc->oloc->file, attr->shared->ds) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set version of dataspace") /* Copy the object header information */ - if(H5O_loc_copy_deep(&(attr->oloc), loc->oloc) < 0) + if (H5O_loc_copy_deep(&(attr->oloc), loc->oloc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to copy entry") /* Deep copy of the group hierarchy path */ - if(H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0) + if (H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "unable to copy path") /* Check if any of the pieces should be (or are already) shared in the * SOHM table */ - if(H5SM_try_share(attr->oloc.file, NULL, 0, H5O_DTYPE_ID, attr->shared->dt, NULL) < 0) + if (H5SM_try_share(attr->oloc.file, NULL, 0, H5O_DTYPE_ID, attr->shared->dt, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "trying to share datatype failed") - if(H5SM_try_share(attr->oloc.file, NULL, 0, H5O_SDSPACE_ID, attr->shared->ds, NULL) < 0) + if (H5SM_try_share(attr->oloc.file, NULL, 0, H5O_SDSPACE_ID, attr->shared->ds, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "trying to share dataspace failed") /* Check whether datatype is committed & increment ref count * (to maintain ref. count incr/decr similarity with "shared message" * type of datatype sharing) */ - if(H5T_is_named(attr->shared->dt)) + if (H5T_is_named(attr->shared->dt)) /* Increment the reference count on the shared datatype */ - if(H5T_link(attr->shared->dt, 1) < 0) + if (H5T_link(attr->shared->dt, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, NULL, "unable to adjust shared datatype link count") /* Compute the size of pieces on disk. This is either the size of the @@ -256,7 +247,7 @@ H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, attr->shared->ds_size = H5O_msg_raw_size(attr->oloc.file, H5O_SDSPACE_ID, FALSE, attr->shared->ds); /* Get # of elements for attribute's dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, NULL, "dataspace is invalid") H5_CHECKED_ASSIGN(nelmts, size_t, snelmts, hssize_t); @@ -265,16 +256,16 @@ H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, attr->shared->data_size = nelmts * H5T_GET_SIZE(attr->shared->dt); /* Hold the symbol table entry (and file) open */ - if(H5O_open(&(attr->oloc)) < 0) + if (H5O_open(&(attr->oloc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open") attr->obj_opened = TRUE; /* Set the version to encode the attribute with */ - if(H5A__set_version(attr->oloc.file, attr) < 0) + if (H5A__set_version(attr->oloc.file, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, NULL, "unable to update attribute version") /* Insert the attribute into the object header */ - if(H5O__attr_create(&(attr->oloc), attr) < 0) + if (H5O__attr_create(&(attr->oloc), attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, NULL, "unable to create attribute in object header") /* Set return value */ @@ -282,13 +273,12 @@ H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, done: /* Cleanup on failure */ - if(NULL == ret_value && attr && H5A__close(attr)) + if (NULL == ret_value && attr && H5A__close(attr)) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__create() */ - /*------------------------------------------------------------------------- * Function: H5A__create_by_name * @@ -302,15 +292,15 @@ done: *------------------------------------------------------------------------- */ H5A_t * -H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name, - const H5T_t *type, const H5S_t *space, hid_t acpl_id) +H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name, const H5T_t *type, + const H5S_t *space, hid_t acpl_id) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - H5A_t *attr = NULL; /* Attribute from object header */ - H5A_t *ret_value = NULL; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + H5A_t * attr = NULL; /* Attribute from object header */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -325,12 +315,12 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Go do the real work for attaching the attribute to the object */ - if(NULL == (attr = H5A__create(&obj_loc, attr_name, type, space, acpl_id))) + if (NULL == (attr = H5A__create(&obj_loc, attr_name, type, space, acpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") /* Set return value */ @@ -338,18 +328,17 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") /* Cleanup on failure */ - if(ret_value == NULL) - if(attr && H5A__close(attr) < 0) + if (ret_value == NULL) + if (attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__create_by_name() */ - /*------------------------------------------------------------------------- * Function: H5A__open_common * @@ -370,7 +359,7 @@ done: herr_t H5A__open_common(const H5G_loc_t *loc, H5A_t *attr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -380,24 +369,24 @@ H5A__open_common(const H5G_loc_t *loc, H5A_t *attr) #if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG) /* Clear object location */ - if(H5O_loc_reset(&(attr->oloc)) < 0) + if (H5O_loc_reset(&(attr->oloc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to reset location") #endif /* H5_USING_MEMCHECKER */ /* Free any previous group hier. path */ - if(H5G_name_free(&(attr->path)) < 0) + if (H5G_name_free(&(attr->path)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release group hier. path") /* Deep copy of the symbol table entry */ - if(H5O_loc_copy_deep(&(attr->oloc), loc->oloc) < 0) + if (H5O_loc_copy_deep(&(attr->oloc), loc->oloc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") /* Deep copy of the group hier. path */ - if(H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0) + if (H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "unable to copy entry") /* Hold the symbol table entry (and file) open */ - if(H5O_open(&(attr->oloc)) < 0) + if (H5O_open(&(attr->oloc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open") attr->obj_opened = TRUE; @@ -405,7 +394,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_common() */ - /*------------------------------------------------------------------------- * Function: H5A__open * @@ -421,8 +409,8 @@ done: H5A_t * H5A__open(const H5G_loc_t *loc, const char *attr_name) { - H5A_t *attr = NULL; /* Attribute from object header */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_t *attr = NULL; /* Attribute from object header */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -431,11 +419,12 @@ H5A__open(const H5G_loc_t *loc, const char *attr_name) HDassert(attr_name); /* Read in attribute from object header */ - if(NULL == (attr = H5O__attr_open_by_name(loc->oloc, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to load attribute info from object header for attribute: '%s'", attr_name) + if (NULL == (attr = H5O__attr_open_by_name(loc->oloc, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, + "unable to load attribute info from object header for attribute: '%s'", attr_name) /* Finish initializing attribute */ - if(H5A__open_common(loc, attr) < 0) + if (H5A__open_common(loc, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to initialize attribute") /* Set return value */ @@ -443,14 +432,13 @@ H5A__open(const H5G_loc_t *loc, const char *attr_name) done: /* Cleanup on failure */ - if(ret_value == NULL) - if(attr && H5A__close(attr) < 0) + if (ret_value == NULL) + if (attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open() */ - /*------------------------------------------------------------------------- * Function: H5A__open_by_idx * @@ -464,15 +452,15 @@ done: *------------------------------------------------------------------------- */ H5A_t * -H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - H5A_t *attr = NULL; /* Attribute from object header */ - H5A_t *ret_value = NULL; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + H5A_t * attr = NULL; /* Attribute from object header */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -486,16 +474,16 @@ H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Read in attribute from object header */ - if(NULL == (attr = H5O__attr_open_by_idx(obj_loc.oloc, idx_type, order, n))) + if (NULL == (attr = H5O__attr_open_by_idx(obj_loc.oloc, idx_type, order, n))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to load attribute info from object header") /* Finish initializing attribute */ - if(H5A__open_common(&obj_loc, attr) < 0) + if (H5A__open_common(&obj_loc, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to initialize attribute") /* Set return value */ @@ -503,18 +491,17 @@ H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") /* Cleanup on failure */ - if(ret_value == NULL) - if(attr && H5A__close(attr) < 0) + if (ret_value == NULL) + if (attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5A__open_by_name * @@ -530,12 +517,12 @@ done: H5A_t * H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - H5A_t *attr = NULL; /* Attribute from object header */ - H5A_t *ret_value = NULL; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + H5A_t * attr = NULL; /* Attribute from object header */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -550,16 +537,16 @@ H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_n H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Read in attribute from object header */ - if(NULL == (attr = H5O__attr_open_by_name(obj_loc.oloc, attr_name))) + if (NULL == (attr = H5O__attr_open_by_name(obj_loc.oloc, attr_name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to load attribute info from object header") /* Finish initializing attribute */ - if(H5A__open_common(loc, attr) < 0) + if (H5A__open_common(loc, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to initialize attribute") /* Set return value */ @@ -567,18 +554,17 @@ H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_n done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") /* Cleanup on failure */ - if(ret_value == NULL) - if(attr && H5A__close(attr) < 0) + if (ret_value == NULL) + if (attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_by_name() */ - /*-------------------------------------------------------------------------- NAME H5A__read @@ -598,16 +584,16 @@ done: herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) { - uint8_t *tconv_buf = NULL; /* datatype conv buffer*/ - uint8_t *bkg_buf = NULL; /* background buffer */ - hssize_t snelmts; /* elements in attribute */ - size_t nelmts; /* elements in attribute*/ - H5T_path_t *tpath = NULL; /* type conversion info */ - hid_t src_id = -1, dst_id = -1;/* temporary type atoms*/ - size_t src_type_size; /* size of source type */ - size_t dst_type_size; /* size of destination type */ - size_t buf_size; /* desired buffer size */ - herr_t ret_value = SUCCEED; + uint8_t * tconv_buf = NULL; /* datatype conv buffer*/ + uint8_t * bkg_buf = NULL; /* background buffer */ + hssize_t snelmts; /* elements in attribute */ + size_t nelmts; /* elements in attribute*/ + H5T_path_t *tpath = NULL; /* type conversion info */ + hid_t src_id = -1, dst_id = -1; /* temporary type atoms*/ + size_t src_type_size; /* size of source type */ + size_t dst_type_size; /* size of destination type */ + size_t buf_size; /* desired buffer size */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_TAG(attr->oloc.addr) @@ -615,47 +601,49 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) HDassert(mem_type); HDassert(buf); - /* Patch the top level file pointer in attr->shared->dt->shared->u.vlen.f if needed */ - if(H5T_patch_vlen_file(attr->shared->dt, H5F_VOL_OBJ(attr->oloc.file)) < 0 ) + /* Patch the top level file pointer in attr->shared->dt->shared->u.vlen.f if needed */ + if (H5T_patch_vlen_file(attr->shared->dt, H5F_VOL_OBJ(attr->oloc.file)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch VL datatype file pointer") /* Create buffer for data to store on disk */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") H5_CHECKED_ASSIGN(nelmts, size_t, snelmts, hssize_t); - if(nelmts > 0) { + if (nelmts > 0) { /* Get the memory and file datatype sizes */ src_type_size = H5T_GET_SIZE(attr->shared->dt); dst_type_size = H5T_GET_SIZE(mem_type); /* Check if the attribute has any data yet, if not, fill with zeroes */ - if(attr->obj_opened && !attr->shared->data) + if (attr->obj_opened && !attr->shared->data) HDmemset(buf, 0, (dst_type_size * nelmts)); - else { /* Attribute exists and has a value */ + else { /* Attribute exists and has a value */ /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(attr->shared->dt, mem_type))) - HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dst datatypes") + if (NULL == (tpath = H5T_path_find(attr->shared->dt, mem_type))) + HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dst datatypes") /* Check for type conversion required */ - if(!H5T_path_noop(tpath)) { - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->shared->dt, H5T_COPY_ALL), FALSE)) < 0 || - (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL), FALSE)) < 0) + if (!H5T_path_noop(tpath)) { + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->shared->dt, H5T_COPY_ALL), FALSE)) < + 0 || + (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Get the maximum buffer size needed and allocate it */ buf_size = nelmts * MAX(src_type_size, dst_type_size); - if(NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) + if (NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the buffer for conversion */ H5MM_memcpy(tconv_buf, attr->shared->data, (src_type_size * nelmts)); /* Perform datatype conversion. */ - if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0) + if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") /* Copy the converted data into the user's buffer */ @@ -668,24 +656,23 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) /* Copy the attribute data into the user's buffer */ H5MM_memcpy(buf, attr->shared->data, (dst_type_size * nelmts)); } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ done: /* Release resources */ - if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + if (src_id >= 0 && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(tconv_buf) + if (tconv_buf) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__read() */ - /*-------------------------------------------------------------------------- NAME H5A__write @@ -705,17 +692,17 @@ done: herr_t H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) { - uint8_t *tconv_buf = NULL; /* datatype conv buffer */ - hbool_t tconv_owned = FALSE; /* Whether the datatype conv buffer is owned by attribute */ - uint8_t *bkg_buf = NULL; /* temp conversion buffer */ - hssize_t snelmts; /* elements in attribute */ - size_t nelmts; /* elements in attribute */ - H5T_path_t *tpath = NULL; /* conversion information*/ - hid_t src_id = -1, dst_id = -1;/* temporary type atoms */ - size_t src_type_size; /* size of source type */ - size_t dst_type_size; /* size of destination type*/ - size_t buf_size; /* desired buffer size */ - herr_t ret_value = SUCCEED; + uint8_t * tconv_buf = NULL; /* datatype conv buffer */ + hbool_t tconv_owned = FALSE; /* Whether the datatype conv buffer is owned by attribute */ + uint8_t * bkg_buf = NULL; /* temp conversion buffer */ + hssize_t snelmts; /* elements in attribute */ + size_t nelmts; /* elements in attribute */ + H5T_path_t *tpath = NULL; /* conversion information*/ + hid_t src_id = -1, dst_id = -1; /* temporary type atoms */ + size_t src_type_size; /* size of source type */ + size_t dst_type_size; /* size of destination type*/ + size_t buf_size; /* desired buffer size */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_TAG(attr->oloc.addr) @@ -724,56 +711,56 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) HDassert(buf); /* Get # of elements for attribute's dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") H5_CHECKED_ASSIGN(nelmts, size_t, snelmts, hssize_t); /* If there's actually data elements for the attribute, make a copy of the data passed in */ - if(nelmts > 0) { + if (nelmts > 0) { /* Get the memory and file datatype sizes */ src_type_size = H5T_GET_SIZE(mem_type); dst_type_size = H5T_GET_SIZE(attr->shared->dt); /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(mem_type, attr->shared->dt))) + if (NULL == (tpath = H5T_path_find(mem_type, attr->shared->dt))) HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dst datatypes") /* Check for type conversion required */ - if(!H5T_path_noop(tpath)) { - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL), FALSE)) < 0 || - (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->shared->dt, H5T_COPY_ALL), FALSE)) < 0) + if (!H5T_path_noop(tpath)) { + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL), FALSE)) < 0 || + (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->shared->dt, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Get the maximum buffer size needed and allocate it */ buf_size = nelmts * MAX(src_type_size, dst_type_size); - if(NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) + if (NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed") - if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Copy the user's data into the buffer for conversion */ H5MM_memcpy(tconv_buf, buf, (src_type_size * nelmts)); /* Perform datatype conversion */ - if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0) + if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") /* Free the previous attribute data buffer, if there is one */ - if(attr->shared->data) + if (attr->shared->data) attr->shared->data = H5FL_BLK_FREE(attr_buf, attr->shared->data); /* Set the pointer to the attribute data to the converted information */ attr->shared->data = tconv_buf; - tconv_owned = TRUE; + tconv_owned = TRUE; } /* end if */ /* No type conversion necessary */ else { HDassert(dst_type_size == src_type_size); /* Allocate the attribute buffer, if there isn't one */ - if(attr->shared->data == NULL) - if(NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size * nelmts))) + if (attr->shared->data == NULL) + if (NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size * nelmts))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the attribute data buffer */ @@ -781,25 +768,24 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) } /* end else */ /* Modify the attribute in the object header */ - if(H5O__attr_write(&(attr->oloc), attr) < 0) + if (H5O__attr_write(&(attr->oloc), attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to modify attribute") } /* end if */ done: /* Release resources */ - if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + if (src_id >= 0 && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(tconv_buf && !tconv_owned) + if (tconv_buf && !tconv_owned) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__write() */ - /*-------------------------------------------------------------------------- NAME H5A__get_name @@ -819,8 +805,8 @@ done: ssize_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) { - size_t copy_len, nbytes; - ssize_t ret_value = -1; /* Return value */ + size_t copy_len, nbytes; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -832,11 +818,11 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) copy_len = MIN(buf_size - 1, nbytes); /* Copy all/some of the name */ - if(buf && copy_len > 0) { + if (buf && copy_len > 0) { H5MM_memcpy(buf, attr->shared->name, copy_len); /* Terminate the string */ - buf[copy_len]='\0'; + buf[copy_len] = '\0'; } /* end if */ /* Set return value */ @@ -845,7 +831,6 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) FUNC_LEAVE_NOAPI(ret_value) } /* H5A__get_name() */ - /*------------------------------------------------------------------------- * Function: H5A_get_space * @@ -860,8 +845,8 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) hid_t H5A_get_space(H5A_t *attr) { - H5S_t *ds = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *ds = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_NOAPI_NOINIT @@ -882,7 +867,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_get_space() */ - /*------------------------------------------------------------------------- * Function: H5A__get_type * @@ -896,8 +880,8 @@ done: hid_t H5A__get_type(H5A_t *attr) { - H5T_t *dt = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5T_t *dt = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_PACKAGE @@ -937,14 +921,13 @@ H5A__get_type(H5A_t *attr) } done: - if(H5I_INVALID_HID == ret_value) - if(dt && H5T_close(dt) < 0) + if (H5I_INVALID_HID == ret_value) + if (dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_type() */ - /*-------------------------------------------------------------------------- NAME H5A__get_create_plist @@ -962,26 +945,26 @@ done: resource leaks will occur. --------------------------------------------------------------------------*/ hid_t -H5A__get_create_plist(H5A_t* attr) +H5A__get_create_plist(H5A_t *attr) { - H5P_genplist_t *plist; /* Default property list */ - hid_t new_plist_id; /* ID of ACPL to return */ - H5P_genplist_t *new_plist; /* ACPL to return */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t *plist; /* Default property list */ + hid_t new_plist_id; /* ID of ACPL to return */ + H5P_genplist_t *new_plist; /* ACPL to return */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE - if(NULL == (plist = (H5P_genplist_t *)H5I_object(H5P_LST_ATTRIBUTE_CREATE_ID_g))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(H5P_LST_ATTRIBUTE_CREATE_ID_g))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get default ACPL") /* Create the property list object to return */ - if((new_plist_id = H5P_copy_plist(plist, TRUE)) < 0) + if ((new_plist_id = H5P_copy_plist(plist, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy attribute creation properties") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_plist_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_plist_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") /* Set the character encoding on the new property list */ - if(H5P_set(new_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0) + if (H5P_set(new_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set character encoding") ret_value = new_plist_id; @@ -990,7 +973,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5A__get_info * @@ -1007,7 +989,7 @@ done: herr_t H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1016,22 +998,21 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) HDassert(ainfo); /* Set info for attribute */ - ainfo->cset = attr->shared->encoding; + ainfo->cset = attr->shared->encoding; ainfo->data_size = attr->shared->data_size; - if(attr->shared->crt_idx == H5O_MAX_CRT_ORDER_IDX) { + if (attr->shared->crt_idx == H5O_MAX_CRT_ORDER_IDX) { ainfo->corder_valid = FALSE; - ainfo->corder = 0; + ainfo->corder = 0; } /* end if */ else { ainfo->corder_valid = TRUE; - ainfo->corder = attr->shared->crt_idx; + ainfo->corder = attr->shared->crt_idx; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_info() */ - /*------------------------------------------------------------------------- * Function: H5A__copy * @@ -1048,9 +1029,9 @@ done: H5A_t * H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) { - H5A_t *new_attr = NULL; - hbool_t allocated_attr = FALSE; /* Whether the attribute was allocated */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_t * new_attr = NULL; + hbool_t allocated_attr = FALSE; /* Whether the attribute was allocated */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1058,8 +1039,8 @@ H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) HDassert(old_attr); /* Allocate attribute structure */ - if(_new_attr == NULL) { - if(NULL == (new_attr = H5FL_CALLOC(H5A_t))) + if (_new_attr == NULL) { + if (NULL == (new_attr = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") allocated_attr = TRUE; } /* end if */ @@ -1070,7 +1051,7 @@ H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) new_attr->sh_loc = old_attr->sh_loc; /* Deep copy of the group hierarchy path */ - if(H5G_name_copy(&(new_attr->path), &(old_attr->path), H5_COPY_DEEP) < 0) + if (H5G_name_copy(&(new_attr->path), &(old_attr->path), H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "unable to copy path") /* Share some attribute information */ @@ -1086,14 +1067,13 @@ H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) ret_value = new_attr; done: - if(ret_value == NULL) - if(allocated_attr && new_attr && H5A__close(new_attr) < 0) + if (ret_value == NULL) + if (allocated_attr && new_attr && H5A__close(new_attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__copy() */ - /*------------------------------------------------------------------------- * Function: H5A__shared_free * @@ -1112,7 +1092,7 @@ done: herr_t H5A__shared_free(H5A_t *attr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1122,21 +1102,21 @@ H5A__shared_free(H5A_t *attr) /* Free dynamically allocated items. * When possible, keep trying to shut things down (via HDONE_ERROR). */ - if(attr->shared->name) { + if (attr->shared->name) { H5MM_xfree(attr->shared->name); attr->shared->name = NULL; } - if(attr->shared->dt) { - if(H5T_close_real(attr->shared->dt) < 0) + if (attr->shared->dt) { + if (H5T_close_real(attr->shared->dt) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info") attr->shared->dt = NULL; } - if(attr->shared->ds) { - if(H5S_close(attr->shared->ds) < 0) + if (attr->shared->ds) { + if (H5S_close(attr->shared->ds) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info") attr->shared->ds = NULL; } - if(attr->shared->data) + if (attr->shared->data) attr->shared->data = H5FL_BLK_FREE(attr_buf, attr->shared->data); /* Destroy shared attribute struct */ @@ -1145,7 +1125,6 @@ H5A__shared_free(H5A_t *attr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__shared_free() */ - /*------------------------------------------------------------------------- * Function: H5A__close_cb * @@ -1158,7 +1137,7 @@ H5A__shared_free(H5A_t *attr) herr_t H5A__close_cb(H5VL_object_t *attr_vol_obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1166,18 +1145,17 @@ H5A__close_cb(H5VL_object_t *attr_vol_obj) HDassert(attr_vol_obj); /* Close the attribute */ - if((ret_value = H5VL_attr_close(attr_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_attr_close(attr_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "problem closing attribute") /* Free the VOL object */ - if(H5VL_free_object(attr_vol_obj) < 0) + if (H5VL_free_object(attr_vol_obj) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__close_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__close * @@ -1193,7 +1171,7 @@ done: herr_t H5A__close(H5A_t *attr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1201,14 +1179,14 @@ H5A__close(H5A_t *attr) HDassert(attr->shared); /* Close the object's symbol-table entry */ - if(attr->obj_opened && (H5O_close(&(attr->oloc), NULL) < 0)) + if (attr->obj_opened && (H5O_close(&(attr->oloc), NULL) < 0)) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release object header info") /* Reference count can be 0. It only happens when H5A__create fails. */ - if(attr->shared->nrefs <= 1) { + if (attr->shared->nrefs <= 1) { /* Free dynamically allocated items */ - if(attr->shared) - if(H5A__shared_free(attr) < 0) + if (attr->shared) + if (H5A__shared_free(attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") } /* end if */ else { @@ -1218,17 +1196,16 @@ H5A__close(H5A_t *attr) } /* end else */ /* Free group hierarchy path */ - if(H5G_name_free(&(attr->path)) < 0) + if (H5G_name_free(&(attr->path)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release group hier. path") attr->shared = NULL; - attr = H5FL_FREE(H5A_t, attr); + attr = H5FL_FREE(H5A_t, attr); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__close() */ - /*------------------------------------------------------------------------- * Function: H5A_oloc * @@ -1247,7 +1224,7 @@ done: H5O_loc_t * H5A_oloc(H5A_t *attr) { - H5O_loc_t *ret_value = NULL; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1260,7 +1237,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_oloc() */ - /*------------------------------------------------------------------------- * Function: H5A_nameof * @@ -1279,7 +1255,7 @@ done: H5G_name_t * H5A_nameof(H5A_t *attr) { - H5G_name_t *ret_value = NULL; /* Return value */ + H5G_name_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1292,7 +1268,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_nameof() */ - /*------------------------------------------------------------------------- * Function: H5A_type * @@ -1309,7 +1284,7 @@ done: H5T_t * H5A_type(const H5A_t *attr) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1322,7 +1297,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_type() */ - /*------------------------------------------------------------------------- * Function: H5A__exists_by_name * @@ -1338,11 +1312,11 @@ done: htri_t H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - htri_t ret_value = FAIL; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1352,23 +1326,22 @@ H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name) H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(&loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Check if the attribute exists */ - if((ret_value = H5O__attr_exists(obj_loc.oloc, attr_name)) < 0) + if ((ret_value = H5O__attr_exists(obj_loc.oloc, attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__exists_by_name() */ - /*------------------------------------------------------------------------- * Function: H5A__compact_build_table_cb * @@ -1387,11 +1360,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5A__compact_build_table_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5A__compact_build_table_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5A_compact_bt_ud_t *udata = (H5A_compact_bt_ud_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5A_compact_bt_ud_t *udata = (H5A_compact_bt_ud_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1399,26 +1372,26 @@ H5A__compact_build_table_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/ HDassert(mesg); /* Re-allocate the table if necessary */ - if(udata->curr_attr == udata->atable->nattrs) { - H5A_t **new_table; /* New table for attributes */ - size_t new_table_size; /* Number of attributes in new table */ + if (udata->curr_attr == udata->atable->nattrs) { + H5A_t **new_table; /* New table for attributes */ + size_t new_table_size; /* Number of attributes in new table */ /* Allocate larger table */ new_table_size = MAX(1, 2 * udata->atable->nattrs); - if(NULL == (new_table = (H5A_t **)H5FL_SEQ_REALLOC(H5A_t_ptr, udata->atable->attrs, new_table_size))) + if (NULL == (new_table = (H5A_t **)H5FL_SEQ_REALLOC(H5A_t_ptr, udata->atable->attrs, new_table_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "unable to extend attribute table") /* Update table information in user data */ - udata->atable->attrs = new_table; + udata->atable->attrs = new_table; udata->atable->nattrs = new_table_size; } /* end if */ /* Copy attribute into table */ - if(NULL == (udata->atable->attrs[udata->curr_attr] = H5A__copy(NULL, (const H5A_t *)mesg->native))) + if (NULL == (udata->atable->attrs[udata->curr_attr] = H5A__copy(NULL, (const H5A_t *)mesg->native))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") /* Assign [somewhat arbitrary] creation order value, if requested */ - if(udata->bogus_crt_idx) + if (udata->bogus_crt_idx) ((udata->atable->attrs[udata->curr_attr])->shared)->crt_idx = sequence; /* Increment current attribute */ @@ -1428,7 +1401,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__compact_build_table_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__compact_build_table * @@ -1446,12 +1418,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, - H5_iter_order_t order, H5A_attr_table_t *atable) +H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, H5_iter_order_t order, + H5A_attr_table_t *atable) { - H5A_compact_bt_ud_t udata; /* User data for iteration callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_compact_bt_ud_t udata; /* User data for iteration callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1461,29 +1433,29 @@ H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, HDassert(atable); /* Initialize table */ - atable->attrs = NULL; + atable->attrs = NULL; atable->nattrs = 0; /* Set up user data for iteration */ - udata.f = f; - udata.atable = atable; - udata.curr_attr = 0; - udata.bogus_crt_idx = (hbool_t)((oh->version == H5O_VERSION_1 || - !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) ? TRUE : FALSE); + udata.f = f; + udata.atable = atable; + udata.curr_attr = 0; + udata.bogus_crt_idx = (hbool_t)( + (oh->version == H5O_VERSION_1 || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) ? TRUE : FALSE); /* Iterate over existing attributes, checking for attribute with same name */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5A__compact_build_table_cb; - if(H5O__msg_iterate_real(f, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(f, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error building attribute table") /* Correct # of attributes in table */ atable->nattrs = udata.curr_attr; /* Don't sort an empty table. */ - if(atable->nattrs > 0) { + if (atable->nattrs > 0) { /* Sort attribute table in correct iteration order */ - if(H5A__attr_sort_table(atable, idx_type, order) < 0) + if (H5A__attr_sort_table(atable, idx_type, order) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSORT, FAIL, "error sorting attribute table") } /* end if */ @@ -1491,7 +1463,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__compact_build_table() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_build_table_cb * @@ -1508,8 +1479,8 @@ done: static herr_t H5A__dense_build_table_cb(const H5A_t *attr, void *_udata) { - H5A_dense_bt_ud_t *udata = (H5A_dense_bt_ud_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5A_dense_bt_ud_t *udata = (H5A_dense_bt_ud_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1519,11 +1490,11 @@ H5A__dense_build_table_cb(const H5A_t *attr, void *_udata) HDassert(udata->curr_attr < udata->atable->nattrs); /* Allocate attribute for entry in the table */ - if(NULL == (udata->atable->attrs[udata->curr_attr] = H5FL_CALLOC(H5A_t))) + if (NULL == (udata->atable->attrs[udata->curr_attr] = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, H5_ITER_ERROR, "can't allocate attribute") /* Copy attribute information. Share the attribute object in copying. */ - if(NULL == H5A__copy(udata->atable->attrs[udata->curr_attr], attr)) + if (NULL == H5A__copy(udata->atable->attrs[udata->curr_attr], attr)) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") /* Increment number of attributes stored */ @@ -1533,7 +1504,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_build_table_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_build_table * @@ -1552,12 +1522,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, H5A_attr_table_t *atable) +H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, + H5A_attr_table_t *atable) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - hsize_t nrec; /* # of records in v2 B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + hsize_t nrec; /* # of records in v2 B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1569,12 +1539,12 @@ H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, HDassert(atable); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ /* (should be same # of records in all indices) */ - if(H5B2_get_nrec(bt2_name, &nrec) < 0) + if (H5B2_get_nrec(bt2_name, &nrec) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve # of records in index") /* Set size of table */ @@ -1582,29 +1552,29 @@ H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, atable->nattrs = (size_t)nrec; /* Allocate space for the table entries */ - if(atable->nattrs > 0) { - H5A_dense_bt_ud_t udata; /* User data for iteration callback */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ + if (atable->nattrs > 0) { + H5A_dense_bt_ud_t udata; /* User data for iteration callback */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ /* Allocate the table to store the attributes */ - if((atable->attrs = (H5A_t **)H5FL_SEQ_CALLOC(H5A_t_ptr, atable->nattrs)) == NULL) + if ((atable->attrs = (H5A_t **)H5FL_SEQ_CALLOC(H5A_t_ptr, atable->nattrs)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set up user data for iteration */ - udata.atable = atable; + udata.atable = atable; udata.curr_attr = 0; /* Build iterator operator */ - attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.op_type = H5A_ATTR_OP_LIB; attr_op.u.lib_op = H5A__dense_build_table_cb; /* Iterate over the links in the group, building a table of the link messages */ - if(H5A__dense_iterate(f, (hid_t)0, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, - (hsize_t)0, NULL, &attr_op, &udata) < 0) + if (H5A__dense_iterate(f, (hid_t)0, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, + &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Sort attribute table in correct iteration order */ - if(H5A__attr_sort_table(atable, idx_type, order) < 0) + if (H5A__attr_sort_table(atable, idx_type, order) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSORT, FAIL, "error sorting attribute table") } /* end if */ else @@ -1612,13 +1582,12 @@ H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_build_table() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_name_inc * @@ -1641,11 +1610,10 @@ H5A__attr_cmp_name_inc(const void *attr1, const void *attr2) { FUNC_ENTER_STATIC_NOERR - FUNC_LEAVE_NOAPI(HDstrcmp((*(const H5A_t * const *)attr1)->shared->name, - (*(const H5A_t * const *)attr2)->shared->name)) + FUNC_LEAVE_NOAPI( + HDstrcmp((*(const H5A_t *const *)attr1)->shared->name, (*(const H5A_t *const *)attr2)->shared->name)) } /* end H5A__attr_cmp_name_inc() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_name_dec * @@ -1668,11 +1636,10 @@ H5A__attr_cmp_name_dec(const void *attr1, const void *attr2) { FUNC_ENTER_STATIC_NOERR - FUNC_LEAVE_NOAPI(HDstrcmp((*(const H5A_t * const *)attr2)->shared->name, - (*(const H5A_t * const *)attr1)->shared->name)) + FUNC_LEAVE_NOAPI( + HDstrcmp((*(const H5A_t *const *)attr2)->shared->name, (*(const H5A_t *const *)attr1)->shared->name)) } /* end H5A__attr_cmp_name_dec() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_corder_inc * @@ -1692,13 +1659,14 @@ H5A__attr_cmp_name_dec(const void *attr1, const void *attr2) static int H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR - if((*(const H5A_t * const *)attr1)->shared->crt_idx < (*(const H5A_t * const *)attr2)->shared->crt_idx) + if ((*(const H5A_t *const *)attr1)->shared->crt_idx < (*(const H5A_t *const *)attr2)->shared->crt_idx) ret_value = -1; - else if((*(const H5A_t * const *)attr1)->shared->crt_idx > (*(const H5A_t * const *)attr2)->shared->crt_idx) + else if ((*(const H5A_t *const *)attr1)->shared->crt_idx > + (*(const H5A_t *const *)attr2)->shared->crt_idx) ret_value = 1; else ret_value = 0; @@ -1706,7 +1674,6 @@ H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_cmp_corder_inc() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_corder_dec * @@ -1726,13 +1693,14 @@ H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) static int H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR - if((*(const H5A_t * const *)attr1)->shared->crt_idx < (*(const H5A_t * const *)attr2)->shared->crt_idx) + if ((*(const H5A_t *const *)attr1)->shared->crt_idx < (*(const H5A_t *const *)attr2)->shared->crt_idx) ret_value = 1; - else if((*(const H5A_t * const *)attr1)->shared->crt_idx > (*(const H5A_t * const *)attr2)->shared->crt_idx) + else if ((*(const H5A_t *const *)attr1)->shared->crt_idx > + (*(const H5A_t *const *)attr2)->shared->crt_idx) ret_value = -1; else ret_value = 0; @@ -1740,7 +1708,6 @@ H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_cmp_corder_dec() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_sort_table * @@ -1754,8 +1721,7 @@ H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2) *------------------------------------------------------------------------- */ static herr_t -H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, - H5_iter_order_t order) +H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, H5_iter_order_t order) { FUNC_ENTER_STATIC_NOERR @@ -1763,20 +1729,20 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, HDassert(atable); /* Pick appropriate comparison routine */ - if(idx_type == H5_INDEX_NAME) { - if(order == H5_ITER_INC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t*), H5A__attr_cmp_name_inc); - else if(order == H5_ITER_DEC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t*), H5A__attr_cmp_name_dec); + if (idx_type == H5_INDEX_NAME) { + if (order == H5_ITER_INC) + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_inc); + else if (order == H5_ITER_DEC) + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_dec); else HDassert(order == H5_ITER_NATIVE); } /* end if */ else { HDassert(idx_type == H5_INDEX_CRT_ORDER); - if(order == H5_ITER_INC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t*), H5A__attr_cmp_corder_inc); - else if(order == H5_ITER_DEC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t*), H5A__attr_cmp_corder_dec); + if (order == H5_ITER_INC) + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_inc); + else if (order == H5_ITER_DEC) + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_dec); else HDassert(order == H5_ITER_NATIVE); } /* end else */ @@ -1784,7 +1750,6 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5A__attr_sort_table() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_iterate_table * @@ -1799,12 +1764,11 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, *------------------------------------------------------------------------- */ herr_t -H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, - hsize_t *last_attr, hid_t loc_id, const H5A_attr_iter_op_t *attr_op, - void *op_data) +H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, hsize_t *last_attr, hid_t loc_id, + const H5A_attr_iter_op_t *attr_op, void *op_data) { - size_t u; /* Local index variable */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + size_t u; /* Local index variable */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_PACKAGE @@ -1813,20 +1777,19 @@ H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, HDassert(attr_op); /* Skip over attributes, if requested */ - if(last_attr) + if (last_attr) *last_attr = skip; /* Iterate over attribute messages */ H5_CHECKED_ASSIGN(u, size_t, skip, hsize_t) - for(; u < atable->nattrs && !ret_value; u++) { + for (; u < atable->nattrs && !ret_value; u++) { /* Check which type of callback to make */ - switch(attr_op->op_type) { - case H5A_ATTR_OP_APP2: - { - H5A_info_t ainfo; /* Info for attribute */ + switch (attr_op->op_type) { + case H5A_ATTR_OP_APP2: { + H5A_info_t ainfo; /* Info for attribute */ /* Get the attribute information */ - if(H5A__get_info(atable->attrs[u], &ainfo) < 0) + if (H5A__get_info(atable->attrs[u], &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5_ITER_ERROR, "unable to get attribute info") /* Make the application callback */ @@ -1850,23 +1813,22 @@ H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, HDassert("unknown attribute op type" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unsupported attribute op type") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /* Increment the number of entries passed through */ - if(last_attr) + if (last_attr) (*last_attr)++; } /* end for */ /* Check for callback failure and pass along return value */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_iterate_table() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_release_table * @@ -1882,7 +1844,7 @@ done: herr_t H5A__attr_release_table(H5A_attr_table_t *atable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1890,12 +1852,12 @@ H5A__attr_release_table(H5A_attr_table_t *atable) HDassert(atable); /* Release attribute info, if any. */ - if(atable->nattrs > 0) { - size_t u; /* Local index variable */ + if (atable->nattrs > 0) { + size_t u; /* Local index variable */ /* Free attribute message information */ - for(u = 0; u < atable->nattrs; u++) - if(atable->attrs[u] && H5A__close(atable->attrs[u]) < 0) + for (u = 0; u < atable->nattrs; u++) + if (atable->attrs[u] && H5A__close(atable->attrs[u]) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute") } /* end if */ else @@ -1907,7 +1869,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_release_table() */ - /*------------------------------------------------------------------------- * Function: H5A__get_ainfo * @@ -1924,8 +1885,8 @@ done: htri_t H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value = FAIL; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_TAG(oh->cache_info.addr, FAIL) @@ -1935,41 +1896,40 @@ H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo) HDassert(ainfo); /* Check if the "attribute info" message exists */ - if((ret_value = H5O_msg_exists_oh(oh, H5O_AINFO_ID)) < 0) + if ((ret_value = H5O_msg_exists_oh(oh, H5O_AINFO_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "unable to check object header") - if(ret_value > 0) { + if (ret_value > 0) { /* Retrieve the "attribute info" structure */ - if(NULL == H5O_msg_read_oh(f, oh, H5O_AINFO_ID, ainfo)) + if (NULL == H5O_msg_read_oh(f, oh, H5O_AINFO_ID, ainfo)) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't read AINFO message") /* Check if we don't know how many attributes there are */ - if(ainfo->nattrs == HSIZET_MAX) { + if (ainfo->nattrs == HSIZET_MAX) { /* Check if we are using "dense" attribute storage */ - if(H5F_addr_defined(ainfo->fheap_addr)) { + if (H5F_addr_defined(ainfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ /* (should be same # of records in all indices) */ - if(H5B2_get_nrec(bt2_name, &ainfo->nattrs) < 0) + if (H5B2_get_nrec(bt2_name, &ainfo->nattrs) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve # of records in index") } /* end if */ else /* Retrieve # of attributes from object header */ ainfo->nattrs = oh->attr_msgs_seen; } /* end if */ - } /* end if */ + } /* end if */ done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5A__get_ainfo() */ - /*------------------------------------------------------------------------- * Function: H5A__set_version * @@ -1987,9 +1947,10 @@ done: herr_t H5A__set_version(const H5F_t *f, H5A_t *attr) { - hbool_t type_shared, space_shared; /* Flags to indicate that shared messages are used for this attribute */ - uint8_t version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t type_shared, + space_shared; /* Flags to indicate that shared messages are used for this attribute */ + uint8_t version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1998,29 +1959,30 @@ H5A__set_version(const H5F_t *f, H5A_t *attr) HDassert(attr); /* Check whether datatype and dataspace are shared */ - if(H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt) > 0) + if (H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt) > 0) type_shared = TRUE; else type_shared = FALSE; - if(H5O_msg_is_shared(H5O_SDSPACE_ID, attr->shared->ds) > 0) + if (H5O_msg_is_shared(H5O_SDSPACE_ID, attr->shared->ds) > 0) space_shared = TRUE; else space_shared = FALSE; /* Check which version to encode attribute with */ - if(attr->shared->encoding != H5T_CSET_ASCII) - version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ - else if(type_shared || space_shared) - version = H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */ + if (attr->shared->encoding != H5T_CSET_ASCII) + version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ + else if (type_shared || space_shared) + version = + H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */ else - version = H5O_ATTR_VERSION_1; /* Write out basic version */ + version = H5O_ATTR_VERSION_1; /* Write out basic version */ /* Upgrade to the version indicated by the file's low bound if higher */ version = (uint8_t)MAX(version, (uint8_t)H5O_attr_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_ATTR, H5E_BADRANGE, FAIL, "attribute version out of bounds") /* Set the message version */ @@ -2030,7 +1992,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__set_version() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_copy_file * @@ -2053,20 +2014,20 @@ done: */ H5A_t * H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info) + H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info) { - H5A_t *attr_dst = NULL; /* Destination attribute */ - hid_t tid_src = -1; /* Datatype ID for source datatype */ - hid_t tid_dst = -1; /* Datatype ID for destination datatype */ - hid_t tid_mem = -1; /* Datatype ID for memory datatype */ - void *buf = NULL; /* Buffer for copying data */ - void *reclaim_buf = NULL; /* Buffer for reclaiming data */ - void *bkg_buf = NULL; /* Background buffer */ - hid_t buf_sid = -1; /* ID for buffer dataspace */ - hssize_t sdst_nelmts; /* # of elements in destination attribute (signed) */ - size_t dst_nelmts; /* # of elements in destination attribute */ - size_t dst_dt_size; /* Size of destination attribute datatype */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_t * attr_dst = NULL; /* Destination attribute */ + hid_t tid_src = -1; /* Datatype ID for source datatype */ + hid_t tid_dst = -1; /* Datatype ID for destination datatype */ + hid_t tid_mem = -1; /* Datatype ID for memory datatype */ + void * buf = NULL; /* Buffer for copying data */ + void * reclaim_buf = NULL; /* Buffer for reclaiming data */ + void * bkg_buf = NULL; /* Background buffer */ + hid_t buf_sid = -1; /* ID for buffer dataspace */ + hssize_t sdst_nelmts; /* # of elements in destination attribute (signed) */ + size_t dst_nelmts; /* # of elements in destination attribute */ + size_t dst_dt_size; /* Size of destination attribute datatype */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -2077,13 +2038,13 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s HDassert(!cpy_info->copy_without_attr); /* Allocate space for the destination message */ - if(NULL == (attr_dst = H5FL_CALLOC(H5A_t))) + if (NULL == (attr_dst = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the top level of the attribute */ *attr_dst = *attr_src; - if(NULL == (attr_dst->shared = H5FL_CALLOC(H5A_shared_t))) + if (NULL == (attr_dst->shared = H5FL_CALLOC(H5A_shared_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared attr structure") /* Don't have an opened group location for copy */ @@ -2102,19 +2063,19 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s /* Copy attribute's datatype */ /* If source is named, we will keep dst as named, but we will not actually * copy the target and update the message until post copy */ - if(NULL == (attr_dst->shared->dt = H5T_copy(attr_src->shared->dt, H5T_COPY_ALL))) + if (NULL == (attr_dst->shared->dt = H5T_copy(attr_src->shared->dt, H5T_COPY_ALL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "cannot copy datatype") /* Set the location of the destination datatype */ - if(H5T_set_loc(attr_dst->shared->dt, H5F_VOL_OBJ(file_dst), H5T_LOC_DISK) < 0) + if (H5T_set_loc(attr_dst->shared->dt, H5F_VOL_OBJ(file_dst), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "cannot mark datatype on disk") - if(!H5T_is_named(attr_src->shared->dt)) { + if (!H5T_is_named(attr_src->shared->dt)) { /* If the datatype is not named, it may have been shared in the * source file's heap. Un-share it for now. We'll try to shared * it in the destination file below. */ - if(H5O_msg_reset_share(H5O_DTYPE_ID, attr_dst->shared->dt) < 0) + if (H5O_msg_reset_share(H5O_DTYPE_ID, attr_dst->shared->dt) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to reset datatype sharing") } @@ -2126,16 +2087,16 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s /* Reset the dataspace's sharing in the source file before trying to share * it in the destination. */ - if(H5O_msg_reset_share(H5O_SDSPACE_ID, attr_dst->shared->ds) < 0) + if (H5O_msg_reset_share(H5O_SDSPACE_ID, attr_dst->shared->ds) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to reset dataspace sharing") /* Simulate trying to share both the datatype and dataset, to determine the * final size of the messages. This does nothing if the datatype is * committed or sharing is disabled. */ - if(H5SM_try_share(file_dst, NULL, H5SM_DEFER, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_DEFER, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "can't share attribute datatype") - if(H5SM_try_share(file_dst, NULL, H5SM_DEFER, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_DEFER, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "can't share attribute dataspace") /* Compute the sizes of the datatype and dataspace. This is their raw @@ -2148,70 +2109,74 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s /* Check whether to recompute the size of the attribute */ /* (happens when the datatype or dataspace changes sharing status) */ - if(attr_dst->shared->dt_size != attr_src->shared->dt_size || attr_dst->shared->ds_size != attr_src->shared->ds_size) + if (attr_dst->shared->dt_size != attr_src->shared->dt_size || + attr_dst->shared->ds_size != attr_src->shared->ds_size) *recompute_size = TRUE; /* Get # of elements for destination attribute's dataspace */ - if((sdst_nelmts = H5S_GET_EXTENT_NPOINTS(attr_dst->shared->ds)) < 0) + if ((sdst_nelmts = H5S_GET_EXTENT_NPOINTS(attr_dst->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, NULL, "dataspace is invalid") H5_CHECKED_ASSIGN(dst_nelmts, size_t, sdst_nelmts, hssize_t); /* Get size of destination attribute's datatype */ - if(0 == (dst_dt_size = H5T_get_size(attr_dst->shared->dt))) + if (0 == (dst_dt_size = H5T_get_size(attr_dst->shared->dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") /* Compute the size of the data */ - attr_dst->shared->data_size = dst_nelmts * dst_dt_size; + attr_dst->shared->data_size = dst_nelmts * dst_dt_size; /* Copy (& convert) the data, if necessary */ - if(attr_src->shared->data) { - if(NULL == (attr_dst->shared->data = H5FL_BLK_MALLOC(attr_buf, attr_dst->shared->data_size))) + if (attr_src->shared->data) { + if (NULL == (attr_dst->shared->data = H5FL_BLK_MALLOC(attr_buf, attr_dst->shared->data_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Check if we need to convert data */ - if(H5T_detect_class(attr_src->shared->dt, H5T_VLEN, FALSE) > 0) { - H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */ - H5T_t *dt_mem; /* Memory datatype */ - size_t src_dt_size; /* Source datatype size */ - size_t tmp_dt_size; /* Temp. datatype size */ - size_t max_dt_size; /* Max atatype size */ - H5S_t *buf_space; /* Dataspace describing buffer */ - hsize_t buf_dim; /* Dimension for buffer */ - size_t nelmts; /* Number of elements in buffer */ - size_t buf_size; /* Size of copy buffer */ + if (H5T_detect_class(attr_src->shared->dt, H5T_VLEN, FALSE) > 0) { + H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */ + H5T_t * dt_mem; /* Memory datatype */ + size_t src_dt_size; /* Source datatype size */ + size_t tmp_dt_size; /* Temp. datatype size */ + size_t max_dt_size; /* Max atatype size */ + H5S_t * buf_space; /* Dataspace describing buffer */ + hsize_t buf_dim; /* Dimension for buffer */ + size_t nelmts; /* Number of elements in buffer */ + size_t buf_size; /* Size of copy buffer */ /* Create datatype ID for src datatype */ - if((tid_src = H5I_register(H5I_DATATYPE, attr_src->shared->dt, FALSE)) < 0) + if ((tid_src = H5I_register(H5I_DATATYPE, attr_src->shared->dt, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register source file datatype") /* create a memory copy of the variable-length datatype */ - if(NULL == (dt_mem = H5T_copy(attr_src->shared->dt, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(attr_src->shared->dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register memory datatype") /* create variable-length datatype at the destinaton file */ - if((tid_dst = H5I_register(H5I_DATATYPE, attr_dst->shared->dt, FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register destination file datatype") + if ((tid_dst = H5I_register(H5I_DATATYPE, attr_dst->shared->dt, FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register destination file datatype") /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(attr_src->shared->dt, dt_mem))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, attr_dst->shared->dt))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to convert between mem and dst datatypes") + if (NULL == (tpath_src_mem = H5T_path_find(attr_src->shared->dt, dt_mem))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, + "unable to convert between src and mem datatypes") + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, attr_dst->shared->dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, + "unable to convert between mem and dst datatypes") /* Determine largest datatype size */ - if(0 == (src_dt_size = H5T_get_size(attr_src->shared->dt))) + if (0 == (src_dt_size = H5T_get_size(attr_src->shared->dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") - if(0 == (tmp_dt_size = H5T_get_size(dt_mem))) + if (0 == (tmp_dt_size = H5T_get_size(dt_mem))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") max_dt_size = MAX(src_dt_size, tmp_dt_size); - if(0 == (tmp_dt_size = H5T_get_size(attr_dst->shared->dt))) + if (0 == (tmp_dt_size = H5T_get_size(attr_dst->shared->dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, tmp_dt_size); /* Set number of whole elements that fit in buffer */ - if(0 == (nelmts = attr_src->shared->data_size / src_dt_size)) + if (0 == (nelmts = attr_src->shared->data_size / src_dt_size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "element size too large") /* Set up number of bytes to copy, and initial buffer size */ @@ -2221,99 +2186,98 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s buf_dim = nelmts; /* Create the space and set the initial extent */ - if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) + if (NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, NULL, "can't create simple dataspace") /* Atomize */ - if((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { + if ((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { H5S_close(buf_space); HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to register dataspace ID") } /* end if */ /* Allocate memory for recclaim buf */ - if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) + if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation NULLed for raw data chunk") /* Allocate memory for copying the chunk */ - if(NULL == (buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) + if (NULL == (buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation NULLed for raw data chunk") H5MM_memcpy(buf, attr_src->shared->data, attr_src->shared->data_size); /* Allocate background memory */ - if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst)) - if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + if (H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst)) + if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "datatype conversion NULLed") H5MM_memcpy(reclaim_buf, buf, buf_size); /* Set background buffer to all zeros */ - if(bkg_buf) + if (bkg_buf) HDmemset(bkg_buf, 0, buf_size); /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "datatype conversion NULLed") H5MM_memcpy(attr_dst->shared->data, buf, attr_dst->shared->data_size); - if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, NULL, "unable to reclaim variable-length data") - } /* end if */ + } /* end if */ else { HDassert(attr_dst->shared->data_size == attr_src->shared->data_size); H5MM_memcpy(attr_dst->shared->data, attr_src->shared->data, attr_src->shared->data_size); } /* end else */ - } /* end if(attr_src->shared->data) */ + } /* end if(attr_src->shared->data) */ /* Copy the creation order */ attr_dst->shared->crt_idx = attr_src->shared->crt_idx; /* Recompute the version to encode the destination attribute */ - if(H5A__set_version(file_dst, attr_dst) < 0) + if (H5A__set_version(file_dst, attr_dst) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, NULL, "unable to update attribute version") /* Recompute the destination attribute's size, if it's a different version */ - if(attr_src->shared->version != attr_dst->shared->version) + if (attr_src->shared->version != attr_dst->shared->version) *recompute_size = TRUE; /* Set return value */ ret_value = attr_dst; done: - if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) + if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary dataspace ID") - if(tid_src > 0) + if (tid_src > 0) /* Don't decrement ID, we want to keep underlying datatype */ - if(NULL == H5I_remove(tid_src)) + if (NULL == H5I_remove(tid_src)) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") - if(tid_dst > 0) + if (tid_dst > 0) /* Don't decrement ID, we want to keep underlying datatype */ - if(NULL == H5I_remove(tid_dst)) + if (NULL == H5I_remove(tid_dst)) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") - if(tid_mem > 0) + if (tid_mem > 0) /* Decrement the memory datatype ID, it's transient */ - if(H5I_dec_ref(tid_mem) < 0) + if (H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") - if(buf) + if (buf) buf = H5FL_BLK_FREE(attr_buf, buf); - if(reclaim_buf) + if (reclaim_buf) reclaim_buf = H5FL_BLK_FREE(attr_buf, reclaim_buf); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); /* Release destination attribute information on failure */ - if(!ret_value && attr_dst && H5A__close(attr_dst) < 0) + if (!ret_value && attr_dst && H5A__close(attr_dst) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__attr_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_post_copy_file * @@ -2331,11 +2295,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, - H5O_loc_t *dst_oloc, const H5A_t *attr_dst, H5O_copy_t *cpy_info) +H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, H5O_loc_t *dst_oloc, + const H5A_t *attr_dst, H5O_copy_t *cpy_info) { - H5F_t *file_src, *file_dst; - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file_src, *file_dst; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2352,8 +2316,8 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, HDassert(file_dst); if (H5T_is_named(attr_src->shared->dt)) { - H5O_loc_t *src_oloc_dt; /* Pointer to source datatype's object location */ - H5O_loc_t *dst_oloc_dt; /* Pointer to dest. datatype's object location */ + H5O_loc_t *src_oloc_dt; /* Pointer to source datatype's object location */ + H5O_loc_t *dst_oloc_dt; /* Pointer to dest. datatype's object location */ /* Get group entries for source & destination */ src_oloc_dt = H5T_oloc(attr_src->shared->dt); @@ -2366,7 +2330,7 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, dst_oloc_dt->file = file_dst; /* Copy the shared object from source to destination */ - if(H5O_copy_header_map(src_oloc_dt, dst_oloc_dt, cpy_info, FALSE, NULL, NULL) < 0) + if (H5O_copy_header_map(src_oloc_dt, dst_oloc_dt, cpy_info, FALSE, NULL, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Update shared message info from named datatype info */ @@ -2376,25 +2340,26 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, /* Try to share both the datatype and dataset. This does nothing if the * datatype is committed or sharing is disabled. */ - if(H5SM_try_share(file_dst, NULL, H5SM_WAS_DEFERRED, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_WAS_DEFERRED, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "can't share attribute datatype") - if(H5SM_try_share(file_dst, NULL, H5SM_WAS_DEFERRED, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_WAS_DEFERRED, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "can't share attribute dataspace") /* Only need to fix reference attribute with real data being copied to * another file. */ - if((NULL != attr_dst->shared->data) && (H5T_get_class(attr_dst->shared->dt, FALSE) == H5T_REFERENCE) ) { + if ((NULL != attr_dst->shared->data) && (H5T_get_class(attr_dst->shared->dt, FALSE) == H5T_REFERENCE)) { /* copy object pointed by reference. The current implementation does not * deal with nested reference such as reference in a compound structure */ /* Check for expanding references */ - if(cpy_info->expand_ref) { + if (cpy_info->expand_ref) { /* Copy objects referenced in source buffer to destination file and set destination elements */ - if(H5O_copy_expand_ref(file_src, H5I_INVALID_HID, attr_src->shared->dt, - attr_src->shared->data, attr_src->shared->data_size, file_dst, attr_dst->shared->data, cpy_info) < 0) + if (H5O_copy_expand_ref(file_src, H5I_INVALID_HID, attr_src->shared->dt, attr_src->shared->data, + attr_src->shared->data_size, file_dst, attr_dst->shared->data, + cpy_info) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "unable to copy reference attribute") } /* end if */ else @@ -2406,7 +2371,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__attr_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_post_copy_file_cb * @@ -2424,9 +2388,9 @@ done: static herr_t H5A__dense_post_copy_file_cb(const H5A_t *attr_src, void *_udata) { - H5A_dense_file_cp_ud_t *udata = (H5A_dense_file_cp_ud_t *)_udata; - H5A_t *attr_dst = NULL; - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5A_dense_file_cp_ud_t *udata = (H5A_dense_file_cp_ud_t *)_udata; + H5A_t * attr_dst = NULL; + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -2437,34 +2401,34 @@ H5A__dense_post_copy_file_cb(const H5A_t *attr_src, void *_udata) HDassert(udata->file); HDassert(udata->cpy_info); - if(NULL == (attr_dst = H5A__attr_copy_file(attr_src, udata->file, udata->recompute_size, udata->cpy_info))) + if (NULL == + (attr_dst = H5A__attr_copy_file(attr_src, udata->file, udata->recompute_size, udata->cpy_info))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") - if(H5A__attr_post_copy_file(udata->oloc_src, attr_src, udata->oloc_dst, attr_dst, udata->cpy_info) < 0) + if (H5A__attr_post_copy_file(udata->oloc_src, attr_src, udata->oloc_dst, attr_dst, udata->cpy_info) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") /* Reset shared location information */ - if(H5O_msg_reset_share(H5O_ATTR_ID, attr_dst) < 0) + if (H5O_msg_reset_share(H5O_ATTR_ID, attr_dst) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to reset attribute sharing") /* Set COPIED tag for destination object's metadata */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Insert attribute into dense storage */ - if(H5A__dense_insert(udata->file, udata->ainfo, attr_dst) < 0) + if (H5A__dense_insert(udata->file, udata->ainfo, attr_dst) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") /* Reset metadata tag */ H5_END_TAG done: - if(attr_dst && H5A__close(attr_dst) < 0) + if (attr_dst && H5A__close(attr_dst) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close destination attribute") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_post_copy_file_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_post_copy_file_all * @@ -2478,13 +2442,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainfo_src, - H5O_loc_t *dst_oloc, H5O_ainfo_t *ainfo_dst, H5O_copy_t *cpy_info) +H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainfo_src, H5O_loc_t *dst_oloc, + H5O_ainfo_t *ainfo_dst, H5O_copy_t *cpy_info) { - H5A_dense_file_cp_ud_t udata; /* User data for iteration callback */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hbool_t recompute_size = FALSE; /* recompute the size */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_dense_file_cp_ud_t udata; /* User data for iteration callback */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + hbool_t recompute_size = FALSE; /* recompute the size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2492,25 +2456,24 @@ H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainf HDassert(ainfo_src); HDassert(ainfo_dst); - udata.ainfo = ainfo_dst; /* Destination dense information */ - udata.file = dst_oloc->file; /* Destination file */ - udata.recompute_size = &recompute_size; /* Flag to indicate if size changed */ - udata.cpy_info = cpy_info; /* Information on copying options */ - udata.oloc_src = src_oloc; - udata.oloc_dst = dst_oloc; + udata.ainfo = ainfo_dst; /* Destination dense information */ + udata.file = dst_oloc->file; /* Destination file */ + udata.recompute_size = &recompute_size; /* Flag to indicate if size changed */ + udata.cpy_info = cpy_info; /* Information on copying options */ + udata.oloc_src = src_oloc; + udata.oloc_dst = dst_oloc; - attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.op_type = H5A_ATTR_OP_LIB; attr_op.u.lib_op = H5A__dense_post_copy_file_cb; - if(H5A__dense_iterate(src_oloc->file, (hid_t)0, ainfo_src, H5_INDEX_NAME, - H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, &udata) < 0) + if (H5A__dense_iterate(src_oloc->file, (hid_t)0, ainfo_src, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, + NULL, &attr_op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_post_copy_file_all */ - /*------------------------------------------------------------------------- * Function: H5A__rename_by_name * @@ -2524,43 +2487,41 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, - const char *new_attr_name) +H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, const char *new_attr_name) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Avoid thrashing things if the names are the same */ - if(HDstrcmp(old_attr_name, new_attr_name)) { + if (HDstrcmp(old_attr_name, new_attr_name)) { /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; obj_loc.path = &obj_path; H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(&loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Call attribute rename routine */ - if(H5O__attr_rename(obj_loc.oloc, old_attr_name, new_attr_name) < 0) + if (H5O__attr_rename(obj_loc.oloc, old_attr_name, new_attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__rename_by_name() */ - /*------------------------------------------------------------------------- * Function: H5A__iterate_common * @@ -2574,28 +2535,27 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx, H5A_attr_iter_op_t *attr_op, void *op_data) +H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5A_attr_iter_op_t *attr_op, void *op_data) { - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t start_idx; /* Index of attribute to start iterating at */ + hsize_t last_attr; /* Index of last attribute examined */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Call attribute iteration routine */ last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O__attr_iterate(loc_id, idx_type, order, start_idx, &last_attr, attr_op, op_data)) < 0) + if ((ret_value = H5O__attr_iterate(loc_id, idx_type, order, start_idx, &last_attr, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); /* Set the last attribute information */ - if(idx) + if (idx) *idx = last_attr; FUNC_LEAVE_NOAPI(ret_value) } /* H5A__iterate_common() */ - /*------------------------------------------------------------------------- * Function: H5A__iterate * @@ -2607,22 +2567,22 @@ H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, */ herr_t H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx, H5A_operator2_t op, void *op_data) + hsize_t *idx, H5A_operator2_t op, void *op_data) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t obj_loc_id = H5I_INVALID_HID; /* ID for object located */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - void *temp_obj = NULL; - H5I_type_t obj_type; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + hid_t obj_loc_id = H5I_INVALID_HID; /* ID for object located */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + void * temp_obj = NULL; + H5I_type_t obj_type; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; + attr_op.op_type = H5A_ATTR_OP_APP2; attr_op.u.app_op2 = op; /* Set up opened group location to fill in */ @@ -2631,36 +2591,36 @@ H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5 H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found"); loc_found = TRUE; /* Open the object */ - if(NULL == (temp_obj = H5O_open_by_loc(&obj_loc, &obj_type))) + if (NULL == (temp_obj = H5O_open_by_loc(&obj_loc, &obj_type))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object"); /* Get an ID for the object */ - if((obj_loc_id = H5VL_wrap_register(obj_type, temp_obj, TRUE)) < 0) + if ((obj_loc_id = H5VL_wrap_register(obj_type, temp_obj, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype"); /* Call internal attribute iteration routine */ - if((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) + if ((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") done: /* Release resources */ - if(obj_loc_id != H5I_INVALID_HID) { - if(H5I_dec_app_ref(obj_loc_id) < 0) + if (obj_loc_id != H5I_INVALID_HID) { + if (H5I_dec_app_ref(obj_loc_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); } /* end if */ - else if(loc_found && H5G_loc_free(&obj_loc) < 0) + else if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__iterate() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5A__iterate_old * @@ -2674,35 +2634,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, - void *op_data) +H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data) { - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t idx; /* Index of attribute to start iterating at */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + hsize_t idx; /* Index of attribute to start iterating at */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP; + attr_op.op_type = H5A_ATTR_OP_APP; attr_op.u.app_op = op; /* Set up index */ idx = (hsize_t)(attr_num ? *attr_num : 0); /* Call internal attribute iteration routine */ - if((ret_value = H5A__iterate_common(loc_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, &idx, &attr_op, op_data)) < 0) + if ((ret_value = H5A__iterate_common(loc_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, &idx, &attr_op, op_data)) < + 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); /* Translate hsize_t index value to legacy unsigned index value*/ - if(attr_num) + if (attr_num) *attr_num = (unsigned)idx; FUNC_LEAVE_NOAPI(ret_value) } /* H5A__iterate_old() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: H5A__delete_by_name * @@ -2718,11 +2677,11 @@ H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2732,23 +2691,22 @@ H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Delete the attribute from the location */ - if(H5O__attr_remove(obj_loc.oloc, attr_name) < 0) + if (H5O__attr_remove(obj_loc.oloc, attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__delete_by_name() */ - /*------------------------------------------------------------------------- * Function: H5A__delete_by_idx * @@ -2762,14 +2720,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2779,19 +2737,18 @@ H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_ty H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Delete the attribute from the location */ - if(H5O__attr_remove_by_idx(obj_loc.oloc, idx_type, order, n) < 0) + if (H5O__attr_remove_by_idx(obj_loc.oloc, idx_type, order, n) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__delete_by_idx() */ - diff --git a/src/H5Amodule.h b/src/H5Amodule.h index 8ed056b..551a0a4 100644 --- a/src/H5Amodule.h +++ b/src/H5Amodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5A_MODULE -#define H5_MY_PKG H5A -#define H5_MY_PKG_ERR H5E_ATTR -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5A +#define H5_MY_PKG_ERR H5E_ATTR +#define H5_MY_PKG_INIT YES #endif /* _H5Amodule_H */ - diff --git a/src/H5Apkg.h b/src/H5Apkg.h index f3870c0..9ec0b12 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -30,72 +30,70 @@ * Define this to enable debugging. */ #ifdef NDEBUG -# undef H5A_DEBUG +#undef H5A_DEBUG #endif /* Get package's private header */ #include "H5Aprivate.h" /* Other private headers needed by this file */ -#include "H5B2private.h" /* v2 B-trees */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5HFprivate.h" /* Fractal heaps */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspace */ -#include "H5Tprivate.h" /* Datatype functions */ - +#include "H5B2private.h" /* v2 B-trees */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HFprivate.h" /* Fractal heaps */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspace */ +#include "H5Tprivate.h" /* Datatype functions */ /**************************/ /* Package Private Macros */ /**************************/ /* This is the initial version, which does not have support for shared datatypes */ -#define H5O_ATTR_VERSION_1 1 +#define H5O_ATTR_VERSION_1 1 /* This version allows support for shared datatypes & dataspaces by adding a * 'flag' byte indicating when those components are shared. This version * also dropped the alignment on all the components. */ -#define H5O_ATTR_VERSION_2 2 +#define H5O_ATTR_VERSION_2 2 /* Add support for different character encodings of attribute names */ -#define H5O_ATTR_VERSION_3 3 +#define H5O_ATTR_VERSION_3 3 /* The latest version of the format. Look through the 'encode', 'decode' * and 'size' message callbacks for places to change when updating this. */ #define H5O_ATTR_VERSION_LATEST H5O_ATTR_VERSION_3 - /****************************/ /* Package Private Typedefs */ /****************************/ /* Define the shared attribute structure */ typedef struct H5A_shared_t { - uint8_t version; /* Version to encode attribute with */ + uint8_t version; /* Version to encode attribute with */ - char *name; /* Attribute's name */ - H5T_cset_t encoding; /* Character encoding of attribute name */ + char * name; /* Attribute's name */ + H5T_cset_t encoding; /* Character encoding of attribute name */ - H5T_t *dt; /* Attribute's datatype */ - size_t dt_size; /* Size of datatype on disk */ + H5T_t *dt; /* Attribute's datatype */ + size_t dt_size; /* Size of datatype on disk */ - H5S_t *ds; /* Attribute's dataspace */ - size_t ds_size; /* Size of dataspace on disk */ + H5S_t *ds; /* Attribute's dataspace */ + size_t ds_size; /* Size of dataspace on disk */ - void *data; /* Attribute data (on a temporary basis) */ - size_t data_size; /* Size of data on disk */ - H5O_msg_crt_idx_t crt_idx; /* Attribute's creation index in the object header */ - unsigned nrefs; /* Ref count for times this object is referred */ + void * data; /* Attribute data (on a temporary basis) */ + size_t data_size; /* Size of data on disk */ + H5O_msg_crt_idx_t crt_idx; /* Attribute's creation index in the object header */ + unsigned nrefs; /* Ref count for times this object is referred */ } H5A_shared_t; /* Define the main attribute structure */ struct H5A_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ - H5O_loc_t oloc; /* Object location for object attribute is on */ - hbool_t obj_opened; /* Object header entry opened? */ - H5G_name_t path; /* Group hierarchy path */ - H5A_shared_t *shared; /* Shared attribute information */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5O_loc_t oloc; /* Object location for object attribute is on */ + hbool_t obj_opened; /* Object header entry opened? */ + H5G_name_t path; /* Group hierarchy path */ + H5A_shared_t *shared; /* Shared attribute information */ }; /* Typedefs for "dense" attribute storage */ @@ -104,18 +102,18 @@ struct H5A_t { /* Typedef for native 'name' field index records in the v2 B-tree */ /* (Keep 'id' field first so generic record handling in callbacks works) */ typedef struct H5A_dense_bt2_name_rec_t { - H5O_fheap_id_t id; /* Heap ID for attribute */ - uint8_t flags; /* Object header message flags for attribute */ - H5O_msg_crt_idx_t corder; /* 'creation order' field value */ - uint32_t hash; /* Hash of 'name' field value */ + H5O_fheap_id_t id; /* Heap ID for attribute */ + uint8_t flags; /* Object header message flags for attribute */ + H5O_msg_crt_idx_t corder; /* 'creation order' field value */ + uint32_t hash; /* Hash of 'name' field value */ } H5A_dense_bt2_name_rec_t; /* Typedef for native 'creation order' field index records in the v2 B-tree */ /* (Keep 'id' field first so generic record handling in callbacks works) */ typedef struct H5A_dense_bt2_corder_rec_t { - H5O_fheap_id_t id; /* Heap ID for attribute */ - uint8_t flags; /* Object header message flags for attribute */ - H5O_msg_crt_idx_t corder; /* 'creation order' field value */ + H5O_fheap_id_t id; /* Heap ID for attribute */ + uint8_t flags; /* Object header message flags for attribute */ + H5O_msg_crt_idx_t corder; /* 'creation order' field value */ } H5A_dense_bt2_corder_rec_t; /* Define the 'found' callback function pointer for matching an attribute record in a v2 B-tree */ @@ -128,15 +126,15 @@ typedef herr_t (*H5A_bt2_found_t)(const H5A_t *attr, hbool_t *took_ownership, vo */ typedef struct H5A_bt2_ud_common_t { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ - H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ - const char *name; /* Name of attribute to compare */ - uint32_t name_hash; /* Hash of name of attribute to compare */ - uint8_t flags; /* Flags for attribute storage location */ - H5O_msg_crt_idx_t corder; /* Creation order value of attribute to compare */ - H5A_bt2_found_t found_op; /* Callback when correct attribute is found */ - void *found_op_data; /* Callback data when correct attribute is found */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t * fheap; /* Fractal heap handle */ + H5HF_t * shared_fheap; /* Fractal heap handle for shared messages */ + const char * name; /* Name of attribute to compare */ + uint32_t name_hash; /* Hash of name of attribute to compare */ + uint8_t flags; /* Flags for attribute storage location */ + H5O_msg_crt_idx_t corder; /* Creation order value of attribute to compare */ + H5A_bt2_found_t found_op; /* Callback when correct attribute is found */ + void * found_op_data; /* Callback data when correct attribute is found */ } H5A_bt2_ud_common_t; /* @@ -145,17 +143,16 @@ typedef struct H5A_bt2_ud_common_t { */ typedef struct H5A_bt2_ud_ins_t { /* downward */ - H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ - H5O_fheap_id_t id; /* Heap ID of attribute to insert */ + H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ + H5O_fheap_id_t id; /* Heap ID of attribute to insert */ } H5A_bt2_ud_ins_t; /* Data structure to hold table of attributes for an object */ typedef struct { - size_t nattrs; /* # of attributes in table */ - H5A_t **attrs; /* Pointer to array of attribute pointers */ + size_t nattrs; /* # of attributes in table */ + H5A_t **attrs; /* Pointer to array of attribute pointers */ } H5A_attr_table_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -175,47 +172,42 @@ H5_DLLVAR const H5B2_class_t H5A_BT2_NAME[1]; /* The v2 B-tree class for indexing 'creation order' field on attributes */ H5_DLLVAR const H5B2_class_t H5A_BT2_CORDER[1]; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Function prototypes for H5A package scope */ -H5_DLL H5A_t *H5A__create(const H5G_loc_t *loc, const char *attr_name, - const H5T_t *type, const H5S_t *space, hid_t acpl_id); -H5_DLL H5A_t *H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, - const char *attr_name, const H5T_t *type, const H5S_t *space, - hid_t acpl_id); +H5_DLL H5A_t *H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, const H5S_t *space, + hid_t acpl_id); +H5_DLL H5A_t *H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name, + const H5T_t *type, const H5S_t *space, hid_t acpl_id); H5_DLL H5A_t *H5A__open(const H5G_loc_t *loc, const char *attr_name); -H5_DLL H5A_t *H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, - const char *attr_name); -H5_DLL H5A_t *H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); +H5_DLL H5A_t *H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name); +H5_DLL H5A_t *H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); H5_DLL herr_t H5A__open_common(const H5G_loc_t *loc, H5A_t *attr); H5_DLL H5A_t *H5A__copy(H5A_t *new_attr, const H5A_t *old_attr); -H5_DLL hid_t H5A__get_type(H5A_t *attr); +H5_DLL hid_t H5A__get_type(H5A_t *attr); H5_DLL herr_t H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo); -H5_DLL hid_t H5A__get_create_plist(H5A_t* attr); +H5_DLL hid_t H5A__get_create_plist(H5A_t *attr); H5_DLL herr_t H5A__shared_free(H5A_t *attr); H5_DLL herr_t H5A__close(H5A_t *attr); H5_DLL herr_t H5A__close_cb(H5VL_object_t *attr_vol_obj); H5_DLL htri_t H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo); H5_DLL herr_t H5A__set_version(const H5F_t *f, H5A_t *attr); H5_DLL herr_t H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, - const char *new_attr_name); -H5_DLL herr_t H5A__iterate(const H5G_loc_t *loc, const char *obj_name,H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx, H5A_operator2_t op, void *op_data); + const char *new_attr_name); +H5_DLL herr_t H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data); #ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL herr_t H5A__iterate_old(hid_t loc_id, unsigned *attr_num, - H5A_operator1_t op, void *op_data); +H5_DLL herr_t H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ -H5_DLL herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, - const char *attr_name); -H5_DLL herr_t H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL htri_t H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name); -H5_DLL herr_t H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf); -H5_DLL herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf); +H5_DLL herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name); +H5_DLL herr_t H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL htri_t H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name); +H5_DLL herr_t H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf); +H5_DLL herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf); H5_DLL ssize_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf); /* Attribute "dense" storage routines */ @@ -223,55 +215,50 @@ H5_DLL herr_t H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo); H5_DLL H5A_t *H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name); H5_DLL herr_t H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr); H5_DLL herr_t H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr); -H5_DLL herr_t H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, - const char *old_name, const char *new_name); -H5_DLL herr_t H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, - const H5A_attr_iter_op_t *attr_op, void *op_data); -H5_DLL herr_t H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, - const char *name); -H5_DLL herr_t H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL htri_t H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, - const char *name); +H5_DLL herr_t H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, + const char *new_name); +H5_DLL herr_t H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, + const H5A_attr_iter_op_t *attr_op, void *op_data); +H5_DLL herr_t H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name); +H5_DLL herr_t H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL htri_t H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name); H5_DLL herr_t H5A__dense_delete(H5F_t *f, H5O_ainfo_t *ainfo); /* Attribute table operations */ -H5_DLL herr_t H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, - H5_iter_order_t order, H5A_attr_table_t *atable); -H5_DLL herr_t H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, H5A_attr_table_t *atable); -H5_DLL herr_t H5A__attr_iterate_table(const H5A_attr_table_t *atable, - hsize_t skip, hsize_t *last_attr, hid_t loc_id, - const H5A_attr_iter_op_t *attr_op, void *op_data); +H5_DLL herr_t H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, H5_iter_order_t order, + H5A_attr_table_t *atable); +H5_DLL herr_t H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, + H5_iter_order_t order, H5A_attr_table_t *atable); +H5_DLL herr_t H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, hsize_t *last_attr, + hid_t loc_id, const H5A_attr_iter_op_t *attr_op, void *op_data); H5_DLL herr_t H5A__attr_release_table(H5A_attr_table_t *atable); /* Attribute operations */ H5_DLL herr_t H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr); H5_DLL H5A_t *H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name); -H5_DLL H5A_t *H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, - H5O_shared_t *sh_mesg); +H5_DLL H5A_t *H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n); +H5_DLL herr_t H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, H5O_shared_t *sh_mesg); H5_DLL herr_t H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr); -H5_DLL herr_t H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, - const char *new_name); -H5_DLL herr_t H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, - const H5A_attr_iter_op_t *op, void *op_data); +H5_DLL herr_t H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, const char *new_name); +H5_DLL herr_t H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, + hsize_t *last_attr, const H5A_attr_iter_op_t *op, void *op_data); H5_DLL herr_t H5O__attr_remove(const H5O_loc_t *loc, const char *name); -H5_DLL herr_t H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n); H5_DLL htri_t H5O__attr_exists(const H5O_loc_t *loc, const char *name); #ifndef H5_NO_DEPRECATED_SYMBOLS H5_DLL int H5O__attr_count(const H5O_loc_t *loc); #endif /* H5_NO_DEPRECATED_SYMBOLS */ H5_DLL H5A_t *H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t *cpy_info); -H5_DLL herr_t H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *mesg_src, - H5O_loc_t *dst_oloc, const H5A_t *mesg_dst, H5O_copy_t *cpy_info); -H5_DLL herr_t H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t * ainfo_src, - H5O_loc_t *dst_oloc, H5O_ainfo_t *ainfo_dst, H5O_copy_t *cpy_info); + H5O_copy_t *cpy_info); +H5_DLL herr_t H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *mesg_src, H5O_loc_t *dst_oloc, + const H5A_t *mesg_dst, H5O_copy_t *cpy_info); +H5_DLL herr_t H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainfo_src, + H5O_loc_t *dst_oloc, H5O_ainfo_t *ainfo_dst, + H5O_copy_t *cpy_info); /* Testing functions */ #ifdef H5A_TESTING @@ -280,4 +267,3 @@ H5_DLL herr_t H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count); #endif /* H5A_TESTING */ #endif /* _H5Apkg_H */ - diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h index b288228..4164154 100644 --- a/src/H5Aprivate.h +++ b/src/H5Aprivate.h @@ -21,17 +21,15 @@ #include "H5Apublic.h" /* Private headers needed by this file */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspace */ -#include "H5Tprivate.h" /* Datatypes */ - +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspace */ +#include "H5Tprivate.h" /* Datatypes */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -45,42 +43,39 @@ typedef herr_t (*H5A_lib_iterate_t)(const H5A_t *attr, void *op_data); /* Describe kind of callback to make for each attribute */ typedef enum H5A_attr_iter_op_type_t { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5A_ATTR_OP_APP, /* Application callback */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5A_ATTR_OP_APP2, /* Revised application callback */ - H5A_ATTR_OP_LIB /* Library internal callback */ + H5A_ATTR_OP_APP, /* Application callback */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5A_ATTR_OP_APP2, /* Revised application callback */ + H5A_ATTR_OP_LIB /* Library internal callback */ } H5A_attr_iter_op_type_t; typedef struct H5A_attr_iter_op_t { H5A_attr_iter_op_type_t op_type; union { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5A_operator1_t app_op; /* Application callback for each attribute */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5A_operator2_t app_op2; /* Revised application callback for each attribute */ - H5A_lib_iterate_t lib_op; /* Library internal callback for each attribute */ + H5A_operator1_t app_op; /* Application callback for each attribute */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5A_operator2_t app_op2; /* Revised application callback for each attribute */ + H5A_lib_iterate_t lib_op; /* Library internal callback for each attribute */ } u; } H5A_attr_iter_op_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General attribute routines */ -H5_DLL herr_t H5A_init(void); +H5_DLL herr_t H5A_init(void); H5_DLL struct H5O_loc_t *H5A_oloc(H5A_t *attr); H5_DLL H5G_name_t *H5A_nameof(H5A_t *attr); H5_DLL H5T_t *H5A_type(const H5A_t *attr); -H5_DLL hid_t H5A_get_space(H5A_t *attr); -H5_DLL herr_t H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, - hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data); +H5_DLL hid_t H5A_get_space(H5A_t *attr); +H5_DLL herr_t H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, + const H5A_attr_iter_op_t *attr_op, void *op_data); #endif /* _H5Aprivate_H */ - diff --git a/src/H5Apublic.h b/src/H5Apublic.h index 7162f6e..89a3b04 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -18,28 +18,26 @@ #define _H5Apublic_H /* Public headers needed by this file */ -#include "H5Ipublic.h" /* IDs */ -#include "H5Opublic.h" /* Object Headers */ -#include "H5Tpublic.h" /* Datatypes */ +#include "H5Ipublic.h" /* IDs */ +#include "H5Opublic.h" /* Object Headers */ +#include "H5Tpublic.h" /* Datatypes */ /* Information struct for attribute (for H5Aget_info/H5Aget_info_by_idx) */ typedef struct { - hbool_t corder_valid; /* Indicate if creation order is valid */ - H5O_msg_crt_idx_t corder; /* Creation order */ - H5T_cset_t cset; /* Character set of attribute name */ - hsize_t data_size; /* Size of raw data */ + hbool_t corder_valid; /* Indicate if creation order is valid */ + H5O_msg_crt_idx_t corder; /* Creation order */ + H5T_cset_t cset; /* Character set of attribute name */ + hsize_t data_size; /* Size of raw data */ } H5A_info_t; /* Typedef for H5Aiterate2() callbacks */ -typedef herr_t (*H5A_operator2_t)(hid_t location_id/*in*/, - const char *attr_name/*in*/, const H5A_info_t *ainfo/*in*/, void *op_data/*in,out*/); - +typedef herr_t (*H5A_operator2_t)(hid_t location_id /*in*/, const char *attr_name /*in*/, + const H5A_info_t *ainfo /*in*/, void *op_data /*in,out*/); /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -47,16 +45,15 @@ typedef herr_t (*H5A_operator2_t)(hid_t location_id/*in*/, extern "C" { #endif -H5_DLL hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, - hid_t space_id, hid_t acpl_id, hid_t aapl_id); -H5_DLL hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id); +H5_DLL hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, + hid_t aapl_id); +H5_DLL hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, + hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id); H5_DLL hid_t H5Aopen(hid_t obj_id, const char *attr_name, hid_t aapl_id); -H5_DLL hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, - const char *attr_name, hid_t aapl_id, hid_t lapl_id); -H5_DLL hid_t H5Aopen_by_idx(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t aapl_id, - hid_t lapl_id); +H5_DLL hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t aapl_id, + hid_t lapl_id); +H5_DLL hid_t H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, hid_t aapl_id, hid_t lapl_id); H5_DLL herr_t H5Awrite(hid_t attr_id, hid_t type_id, const void *buf); H5_DLL herr_t H5Aread(hid_t attr_id, hid_t type_id, void *buf); H5_DLL herr_t H5Aclose(hid_t attr_id); @@ -64,32 +61,29 @@ H5_DLL hid_t H5Aget_space(hid_t attr_id); H5_DLL hid_t H5Aget_type(hid_t attr_id); H5_DLL hid_t H5Aget_create_plist(hid_t attr_id); H5_DLL ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf); -H5_DLL ssize_t H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - char *name /*out*/, size_t size, hid_t lapl_id); +H5_DLL ssize_t H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, + hid_t lapl_id); H5_DLL hsize_t H5Aget_storage_size(hid_t attr_id); H5_DLL herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/); -H5_DLL herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name, - const char *attr_name, H5A_info_t *ainfo /*out*/, hid_t lapl_id); -H5_DLL herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5A_info_t *ainfo /*out*/, hid_t lapl_id); +H5_DLL herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, + H5A_info_t *ainfo /*out*/, hid_t lapl_id); +H5_DLL herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5A_info_t *ainfo /*out*/, hid_t lapl_id); H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name); -H5_DLL herr_t H5Arename_by_name(hid_t loc_id, const char *obj_name, - const char *old_attr_name, const char *new_attr_name, hid_t lapl_id); -H5_DLL herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data); +H5_DLL herr_t H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, + const char *new_attr_name, hid_t lapl_id); +H5_DLL herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5A_operator2_t op, void *op_data); H5_DLL herr_t H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, - hid_t lapd_id); + H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, + hid_t lapd_id); H5_DLL herr_t H5Adelete(hid_t loc_id, const char *name); -H5_DLL herr_t H5Adelete_by_name(hid_t loc_id, const char *obj_name, - const char *attr_name, hid_t lapl_id); -H5_DLL herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id); +H5_DLL herr_t H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id); +H5_DLL herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, hid_t lapl_id); H5_DLL htri_t H5Aexists(hid_t obj_id, const char *attr_name); -H5_DLL htri_t H5Aexists_by_name(hid_t obj_id, const char *obj_name, - const char *attr_name, hid_t lapl_id); +H5_DLL htri_t H5Aexists_by_name(hid_t obj_id, const char *obj_name, const char *attr_name, hid_t lapl_id); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -99,22 +93,18 @@ H5_DLL htri_t H5Aexists_by_name(hid_t obj_id, const char *obj_name, /* Macros */ - /* Typedefs */ /* Typedef for H5Aiterate1() callbacks */ -typedef herr_t (*H5A_operator1_t)(hid_t location_id/*in*/, - const char *attr_name/*in*/, void *operator_data/*in,out*/); - +typedef herr_t (*H5A_operator1_t)(hid_t location_id /*in*/, const char *attr_name /*in*/, + void *operator_data /*in,out*/); /* Function prototypes */ -H5_DLL hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, - hid_t space_id, hid_t acpl_id); -H5_DLL hid_t H5Aopen_name(hid_t loc_id, const char *name); -H5_DLL hid_t H5Aopen_idx(hid_t loc_id, unsigned idx); -H5_DLL int H5Aget_num_attrs(hid_t loc_id); -H5_DLL herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, - void *op_data); +H5_DLL hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id); +H5_DLL hid_t H5Aopen_name(hid_t loc_id, const char *name); +H5_DLL hid_t H5Aopen_idx(hid_t loc_id, unsigned idx); +H5_DLL int H5Aget_num_attrs(hid_t loc_id); +H5_DLL herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -123,4 +113,3 @@ H5_DLL herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, #endif #endif /* _H5Apublic_H */ - diff --git a/src/H5Atest.c b/src/H5Atest.c index 6fc1cbf..dcbb4e3 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -24,58 +24,49 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5A_TESTING /* Suppress warning about H5A testing funcs */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5A_TESTING /* Suppress warning about H5A testing funcs */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5SMprivate.h" /* Shared object header messages */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5A__is_shared_test * @@ -91,13 +82,13 @@ htri_t H5A__is_shared_test(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ - htri_t ret_value = FAIL; /* Return value */ + H5A_t *attr; /* Attribute object for ID */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) + if (NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Check if attribute is shared */ @@ -107,7 +98,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__is_shared_test() */ - /*------------------------------------------------------------------------- * Function: H5A__get_shared_rc_test * @@ -123,18 +113,18 @@ done: herr_t H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) { - H5A_t *attr; /* Attribute object for ID */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t * attr; /* Attribute object for ID */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) + if (NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Push API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; @@ -142,13 +132,12 @@ H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) HDassert(H5O_msg_is_shared(H5O_ATTR_ID, attr)); /* Retrieve ref count for shared or shareable attribute */ - if(H5SM_get_refcount(attr->oloc.file, H5O_ATTR_ID, &attr->sh_loc, ref_count) < 0) + if (H5SM_get_refcount(attr->oloc.file, H5O_ATTR_ID, &attr->sh_loc, ref_count) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_shared_rc_test() */ - diff --git a/src/H5B.c b/src/H5B.c index f909d90..5743b1f 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -95,32 +95,33 @@ /* Module Setup */ /****************/ -#include "H5Bmodule.h" /* This source code file is part of the H5B module */ - +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bpkg.h" /* B-link trees */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Bpkg.h" /* B-link trees */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ -#define H5B_SIZEOF_HDR(F) \ - (H5_SIZEOF_MAGIC + /*magic number */ \ - 4 + /*type, level, num entries */ \ - 2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */ +#define H5B_SIZEOF_HDR(F) \ + (H5_SIZEOF_MAGIC + /*magic number */ \ + 4 + /*type, level, num entries */ \ + 2 * H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */ /* Default initializer for H5B_ins_ud_t */ -#define H5B_INS_UD_T_NULL {NULL, HADDR_UNDEF, H5AC__NO_FLAGS_SET} +#define H5B_INS_UD_T_NULL \ + { \ + NULL, HADDR_UNDEF, H5AC__NO_FLAGS_SET \ + } /******************/ /* Local Typedefs */ @@ -128,33 +129,29 @@ /* "user data" for iterating over B-tree (collects B-tree metadata size) */ typedef struct H5B_iter_ud_t { - H5B_info_t *bt_info; /* Information about B-tree */ - void *udata; /* Node type's 'udata' for loading & iterator callback */ + H5B_info_t *bt_info; /* Information about B-tree */ + void * udata; /* Node type's 'udata' for loading & iterator callback */ } H5B_info_ud_t; /* Convenience struct for the arguments needed to unprotect a b-tree after a * call to H5B__iterate_helper() or H5B__split() */ typedef struct H5B_ins_ud_t { - H5B_t *bt; /* B-tree */ - haddr_t addr; /* B-tree address */ - unsigned cache_flags; /* Cache flags for H5AC_unprotect() */ + H5B_t * bt; /* B-tree */ + haddr_t addr; /* B-tree address */ + unsigned cache_flags; /* Cache flags for H5AC_unprotect() */ } H5B_ins_ud_t; - /********************/ /* Local Prototypes */ /********************/ -static H5B_ins_t H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, - const H5B_class_t *type, uint8_t *lt_key, hbool_t *lt_key_changed, - uint8_t *md_key, void *udata, uint8_t *rt_key, hbool_t *rt_key_changed, - H5B_ins_ud_t *split_bt_ud/*out*/); -static herr_t H5B__insert_child(H5B_t *bt, unsigned *bt_flags, - unsigned idx, haddr_t child, - H5B_ins_t anchor, const void *md_key); -static herr_t H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, - void *udata, H5B_ins_ud_t *split_bt_ud/*out*/); -static H5B_t * H5B__copy(const H5B_t *old_bt); - +static H5B_ins_t H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, uint8_t *lt_key, + hbool_t *lt_key_changed, uint8_t *md_key, void *udata, uint8_t *rt_key, + hbool_t *rt_key_changed, H5B_ins_ud_t *split_bt_ud /*out*/); +static herr_t H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, haddr_t child, H5B_ins_t anchor, + const void *md_key); +static herr_t H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, void *udata, + H5B_ins_ud_t *split_bt_ud /*out*/); +static H5B_t *H5B__copy(const H5B_t *old_bt); /*********************/ /* Package Variables */ @@ -172,12 +169,10 @@ H5FL_BLK_DEFINE(native_block); /* Declare a free list to manage the H5B_t struct */ H5FL_DEFINE(H5B_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -191,8 +186,6 @@ H5FL_BLK_DEFINE_STATIC(page); /* Declare a free list to manage the native key offset sequence information */ H5FL_SEQ_DEFINE_STATIC(size_t); - - /*------------------------------------------------------------------------- * Function: H5B_create * @@ -212,11 +205,11 @@ H5FL_SEQ_DEFINE_STATIC(size_t); *------------------------------------------------------------------------- */ herr_t -H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p/*out*/) +H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p /*out*/) { - H5B_t *bt = NULL; - H5B_shared_t *shared=NULL; /* Pointer to shared B-tree info */ - herr_t ret_value = SUCCEED; + H5B_t * bt = NULL; + H5B_shared_t *shared = NULL; /* Pointer to shared B-tree info */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -230,49 +223,48 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p/*out* /* * Allocate file and memory data structures. */ - if(NULL == (bt = H5FL_MALLOC(H5B_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") + if (NULL == (bt = H5FL_MALLOC(H5B_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t)); - bt->level = 0; - bt->left = HADDR_UNDEF; - bt->right = HADDR_UNDEF; + bt->level = 0; + bt->left = HADDR_UNDEF; + bt->right = HADDR_UNDEF; bt->nchildren = 0; - if(NULL == (bt->rc_shared = (type->get_shared)(f, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree node buffer") + if (NULL == (bt->rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree node buffer") H5UC_INC(bt->rc_shared); - shared=(H5B_shared_t *)H5UC_GET_OBJ(bt->rc_shared); + shared = (H5B_shared_t *)H5UC_GET_OBJ(bt->rc_shared); HDassert(shared); - if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || - NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") - if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) + if (NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || + NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") + if (HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "file allocation failed for B-tree root node") /* * Cache the new B-tree node. */ - if(H5AC_insert_entry(f, H5AC_BT, *addr_p, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache") + if (H5AC_insert_entry(f, H5AC_BT, *addr_p, bt, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache") #ifdef H5B_DEBUG H5B__assert(f, *addr_p, shared->type, udata); #endif done: - if(ret_value < 0) { - if(shared && shared->sizeof_rnode>0) { - H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); + if (ret_value < 0) { + if (shared && shared->sizeof_rnode > 0) { + H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t); (void)H5MF_xfree(f, H5FD_MEM_BTREE, *addr_p, (hsize_t)shared->sizeof_rnode); } /* end if */ - if(bt) + if (bt) /* Destroy B-tree node */ - if(H5B__node_dest(bt) < 0) + if (H5B__node_dest(bt) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5B_create() */ /*lint !e818 Can't make udata a pointer to const */ +} /* end H5B_create() */ /*lint !e818 Can't make udata a pointer to const */ - /*------------------------------------------------------------------------- * Function: H5B_find * @@ -299,13 +291,13 @@ done: htri_t H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) { - H5B_t *bt = NULL; - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_t * bt = NULL; + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned idx = 0, lt = 0, rt; /* Final, left & right key indices */ - int cmp = 1; /* Key comparison value */ - htri_t ret_value = FAIL; /* Return value */ + unsigned idx = 0, lt = 0, rt; /* Final, left & right key indices */ + int cmp = 1; /* Key comparison value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -320,7 +312,7 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) HDassert(H5F_addr_defined(addr)); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -329,47 +321,46 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) * Perform a binary search to locate the child which contains * the thing for which we're searching. */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") rt = bt->nchildren; - while(lt < rt && cmp) { - idx = (lt + rt) / 2; - /* compare */ - if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, (idx + 1)))) < 0) - rt = idx; - else - lt = idx + 1; + while (lt < rt && cmp) { + idx = (lt + rt) / 2; + /* compare */ + if ((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, (idx + 1)))) < 0) + rt = idx; + else + lt = idx + 1; } /* end while */ /* Check if not found */ - if(cmp) - HGOTO_DONE(FALSE) + if (cmp) + HGOTO_DONE(FALSE) /* * Follow the link to the subtree or to the data node. */ HDassert(idx < bt->nchildren); - if(bt->level > 0) { - if((ret_value = H5B_find(f, type, bt->child[idx], udata)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't lookup key in subtree") + if (bt->level > 0) { + if ((ret_value = H5B_find(f, type, bt->child[idx], udata)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't lookup key in subtree") } /* end if */ else { - if((ret_value = (type->found)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), udata)) < 0) + if ((ret_value = (type->found)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), udata)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't lookup key in leaf node") } /* end else */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node") + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_find() */ - /*------------------------------------------------------------------------- * Function: H5B__split * @@ -393,14 +384,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, - void *udata, H5B_ins_ud_t *split_bt_ud/*out*/) +H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, void *udata, H5B_ins_ud_t *split_bt_ud /*out*/) { - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned nleft, nright; /* Number of keys in left & right halves */ - double split_ratios[3]; /* B-tree split ratios */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nleft, nright; /* Number of keys in left & right halves */ + double split_ratios[3]; /* B-tree split ratios */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -422,23 +412,23 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, HDassert(bt_ud->bt->nchildren == shared->two_k); /* Get B-tree split ratios */ - if(H5CX_get_btree_split_ratios(split_ratios) < 0) + if (H5CX_get_btree_split_ratios(split_ratios) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree split ratios") #ifdef H5B_DEBUG - if(H5DEBUG(B)) { - const char *side; - - if(!H5F_addr_defined(bt_ud->bt->left) && !H5F_addr_defined(bt_ud->bt->right)) - side = "ONLY"; - else if(!H5F_addr_defined(bt_ud->bt->right)) - side = "RIGHT"; - else if(!H5F_addr_defined(bt_ud->bt->left)) - side = "LEFT"; - else - side = "MIDDLE"; - HDfprintf(H5DEBUG(B), "H5B__split: %3u {%5.3f,%5.3f,%5.3f} %6s", - shared->two_k, split_ratios[0], split_ratios[1], split_ratios[2], side); + if (H5DEBUG(B)) { + const char *side; + + if (!H5F_addr_defined(bt_ud->bt->left) && !H5F_addr_defined(bt_ud->bt->right)) + side = "ONLY"; + else if (!H5F_addr_defined(bt_ud->bt->right)) + side = "RIGHT"; + else if (!H5F_addr_defined(bt_ud->bt->left)) + side = "LEFT"; + else + side = "MIDDLE"; + HDfprintf(H5DEBUG(B), "H5B__split: %3u {%5.3f,%5.3f,%5.3f} %6s", shared->two_k, split_ratios[0], + split_ratios[1], split_ratios[2], side); } #endif @@ -446,37 +436,38 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, * Decide how to split the children of the old node among the old node * and the new node. */ - if(!H5F_addr_defined(bt_ud->bt->right)) - nleft = (unsigned)((double)shared->two_k * split_ratios[2]); /*right*/ - else if(!H5F_addr_defined(bt_ud->bt->left)) - nleft = (unsigned)((double)shared->two_k * split_ratios[0]); /*left*/ + if (!H5F_addr_defined(bt_ud->bt->right)) + nleft = (unsigned)((double)shared->two_k * split_ratios[2]); /*right*/ + else if (!H5F_addr_defined(bt_ud->bt->left)) + nleft = (unsigned)((double)shared->two_k * split_ratios[0]); /*left*/ else - nleft = (unsigned)((double)shared->two_k * split_ratios[1]); /*middle*/ + nleft = (unsigned)((double)shared->two_k * split_ratios[1]); /*middle*/ /* * Keep the new child in the same node as the child that split. This can * result in nodes that have an unused child when data is written * sequentially, but it simplifies stuff below. */ - if(idx < nleft && nleft == shared->two_k) - --nleft; - else if(idx >= nleft && 0 == nleft) - nleft++; + if (idx < nleft && nleft == shared->two_k) + --nleft; + else if (idx >= nleft && 0 == nleft) + nleft++; nright = shared->two_k - nleft; #ifdef H5B_DEBUG - if(H5DEBUG(B)) + if (H5DEBUG(B)) HDfprintf(H5DEBUG(B), " split %3d/%-3d\n", nleft, nright); #endif /* * Create the new B-tree node. */ - if(H5B_create(f, shared->type, udata, &split_bt_ud->addr/*out*/) < 0) + if (H5B_create(f, shared->type, udata, &split_bt_ud->addr /*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree") - cache_udata.f = f; - cache_udata.type = shared->type; + cache_udata.f = f; + cache_udata.type = shared->type; cache_udata.rc_shared = bt_ud->bt->rc_shared; - if(NULL == (split_bt_ud->bt = (H5B_t *)H5AC_protect(f, H5AC_BT, split_bt_ud->addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (split_bt_ud->bt = + (H5B_t *)H5AC_protect(f, H5AC_BT, split_bt_ud->addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree") split_bt_ud->bt->level = bt_ud->bt->level; @@ -485,12 +476,9 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, */ split_bt_ud->cache_flags = H5AC__DIRTIED_FLAG; - H5MM_memcpy(split_bt_ud->bt->native, - bt_ud->bt->native + nleft * shared->type->sizeof_nkey, - (nright + 1) * shared->type->sizeof_nkey); - H5MM_memcpy(split_bt_ud->bt->child, - &bt_ud->bt->child[nleft], - nright * sizeof(haddr_t)); + H5MM_memcpy(split_bt_ud->bt->native, bt_ud->bt->native + nleft * shared->type->sizeof_nkey, + (nright + 1) * shared->type->sizeof_nkey); + H5MM_memcpy(split_bt_ud->bt->child, &bt_ud->bt->child[nleft], nright * sizeof(haddr_t)); split_bt_ud->bt->nchildren = nright; @@ -503,18 +491,19 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, /* * Update other sibling pointers. */ - split_bt_ud->bt->left = bt_ud->addr; + split_bt_ud->bt->left = bt_ud->addr; split_bt_ud->bt->right = bt_ud->bt->right; - if(H5F_addr_defined(bt_ud->bt->right)) { - H5B_t *tmp_bt; + if (H5F_addr_defined(bt_ud->bt->right)) { + H5B_t *tmp_bt; - if(NULL == (tmp_bt = (H5B_t *)H5AC_protect(f, H5AC_BT, bt_ud->bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == + (tmp_bt = (H5B_t *)H5AC_protect(f, H5AC_BT, bt_ud->bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load right sibling") tmp_bt->left = split_bt_ud->addr; - if(H5AC_unprotect(f, H5AC_BT, bt_ud->bt->right, tmp_bt, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_BT, bt_ud->bt->right, tmp_bt, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end if */ @@ -522,18 +511,18 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, HDassert(bt_ud->cache_flags & H5AC__DIRTIED_FLAG); done: - if(ret_value < 0) { - if(split_bt_ud->bt && H5AC_unprotect(f, H5AC_BT, split_bt_ud->addr, split_bt_ud->bt, split_bt_ud->cache_flags) < 0) + if (ret_value < 0) { + if (split_bt_ud->bt && + H5AC_unprotect(f, H5AC_BT, split_bt_ud->addr, split_bt_ud->bt, split_bt_ud->cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - split_bt_ud->bt = NULL; - split_bt_ud->addr = HADDR_UNDEF; + split_bt_ud->bt = NULL; + split_bt_ud->addr = HADDR_UNDEF; split_bt_ud->cache_flags = H5AC__NO_FLAGS_SET; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__split() */ - /*------------------------------------------------------------------------- * Function: H5B_insert * @@ -553,22 +542,22 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) /* * These are defined this way to satisfy alignment constraints. */ - uint64_t _lt_key[128], _md_key[128], _rt_key[128]; - uint8_t *lt_key=(uint8_t*)_lt_key; - uint8_t *md_key=(uint8_t*)_md_key; - uint8_t *rt_key=(uint8_t*)_rt_key; - - hbool_t lt_key_changed = FALSE, rt_key_changed = FALSE; - haddr_t old_root_addr = HADDR_UNDEF; - unsigned level; - H5B_ins_ud_t bt_ud = H5B_INS_UD_T_NULL; /* (Old) root node */ - H5B_ins_ud_t split_bt_ud = H5B_INS_UD_T_NULL; /* Split B-tree node */ - H5B_t *new_root_bt = NULL; /* New root node */ - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - H5B_ins_t my_ins = H5B_INS_ERROR; - herr_t ret_value = SUCCEED; + uint64_t _lt_key[128], _md_key[128], _rt_key[128]; + uint8_t *lt_key = (uint8_t *)_lt_key; + uint8_t *md_key = (uint8_t *)_md_key; + uint8_t *rt_key = (uint8_t *)_rt_key; + + hbool_t lt_key_changed = FALSE, rt_key_changed = FALSE; + haddr_t old_root_addr = HADDR_UNDEF; + unsigned level; + H5B_ins_ud_t bt_ud = H5B_INS_UD_T_NULL; /* (Old) root node */ + H5B_ins_ud_t split_bt_ud = H5B_INS_UD_T_NULL; /* Split B-tree node */ + H5B_t * new_root_bt = NULL; /* New root node */ + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + H5B_ins_t my_ins = H5B_INS_ERROR; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -579,27 +568,26 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) HDassert(H5F_addr_defined(addr)); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); /* Protect the root node */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - bt_ud.addr = addr; - if(NULL == (bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + bt_ud.addr = addr; + if (NULL == (bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to locate root of B-tree") /* Insert the object */ - if((int)(my_ins = H5B__insert_helper(f, &bt_ud, type, lt_key, - <_key_changed, md_key, udata, rt_key, &rt_key_changed, - &split_bt_ud/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key") + if ((int)(my_ins = H5B__insert_helper(f, &bt_ud, type, lt_key, <_key_changed, md_key, udata, rt_key, + &rt_key_changed, &split_bt_ud /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key") /* Check if the root node split */ - if(H5B_INS_NOOP == my_ins) { + if (H5B_INS_NOOP == my_ins) { /* The root node did not split - just return */ HDassert(!split_bt_ud.bt); HGOTO_DONE(SUCCEED) @@ -612,37 +600,37 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) level = bt_ud.bt->level; /* update left and right keys */ - if(!lt_key_changed) - H5MM_memcpy(lt_key, H5B_NKEY(bt_ud.bt,shared,0), type->sizeof_nkey); - if(!rt_key_changed) - H5MM_memcpy(rt_key, H5B_NKEY(split_bt_ud.bt,shared,split_bt_ud.bt->nchildren), type->sizeof_nkey); + if (!lt_key_changed) + H5MM_memcpy(lt_key, H5B_NKEY(bt_ud.bt, shared, 0), type->sizeof_nkey); + if (!rt_key_changed) + H5MM_memcpy(rt_key, H5B_NKEY(split_bt_ud.bt, shared, split_bt_ud.bt->nchildren), type->sizeof_nkey); /* * Copy the old root node to some other file location and make the new root * at the old root's previous address. This prevents the B-tree from * "moving". */ - H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); - if(HADDR_UNDEF == (old_root_addr = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move root") + H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t); + if (HADDR_UNDEF == (old_root_addr = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move root") /* * Move the node to the new location */ /* Make a copy of the old root information */ - if(NULL == (new_root_bt = H5B__copy(bt_ud.bt))) + if (NULL == (new_root_bt = H5B__copy(bt_ud.bt))) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to copy old root") /* Unprotect the old root so we can move it. Also force it to be marked * dirty so it is written to the new location. */ - if(H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release old root") - bt_ud.bt = NULL; /* Make certain future references will be caught */ + if (H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, H5AC__DIRTIED_FLAG) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release old root") + bt_ud.bt = NULL; /* Make certain future references will be caught */ /* Move the location of the old root on the disk */ - if(H5AC_move_entry(f, H5AC_BT, bt_ud.addr, old_root_addr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node") + if (H5AC_move_entry(f, H5AC_BT, bt_ud.addr, old_root_addr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node") bt_ud.addr = old_root_addr; /* Update the split b-tree's left pointer to point to the new location */ @@ -650,11 +638,11 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) split_bt_ud.cache_flags |= H5AC__DIRTIED_FLAG; /* clear the old root info at the old address (we already copied it) */ - new_root_bt->left = HADDR_UNDEF; + new_root_bt->left = HADDR_UNDEF; new_root_bt->right = HADDR_UNDEF; /* Set the new information for the copy */ - new_root_bt->level = level + 1; + new_root_bt->level = level + 1; new_root_bt->nchildren = 2; new_root_bt->child[0] = bt_ud.addr; @@ -665,31 +653,30 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) H5MM_memcpy(H5B_NKEY(new_root_bt, shared, 2), rt_key, shared->type->sizeof_nkey); /* Insert the modified copy of the old root into the file again */ - if(H5AC_insert_entry(f, H5AC_BT, addr, new_root_bt, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_BT, addr, new_root_bt, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to add old B-tree root node to cache") done: - if(ret_value < 0) - if(new_root_bt && H5B__node_dest(new_root_bt) < 0) + if (ret_value < 0) + if (new_root_bt && H5B__node_dest(new_root_bt) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to free B-tree root node"); - if(bt_ud.bt) - if(H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, bt_ud.cache_flags) < 0) + if (bt_ud.bt) + if (H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, bt_ud.cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect old root") - if(split_bt_ud.bt) - if(H5AC_unprotect(f, H5AC_BT, split_bt_ud.addr, split_bt_ud.bt, split_bt_ud.cache_flags) < 0) + if (split_bt_ud.bt) + if (H5AC_unprotect(f, H5AC_BT, split_bt_ud.addr, split_bt_ud.bt, split_bt_ud.cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect new child") #ifdef H5B_DEBUG - if(ret_value >= 0) + if (ret_value >= 0) H5B__assert(f, addr, type, udata); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_insert() */ - /*------------------------------------------------------------------------- * Function: H5B__insert_child * @@ -706,11 +693,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, - haddr_t child, H5B_ins_t anchor, const void *md_key) +H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, haddr_t child, H5B_ins_t anchor, + const void *md_key) { - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - uint8_t *base; /* Base offset for move */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + uint8_t * base; /* Base offset for move */ FUNC_ENTER_STATIC_NOERR @@ -725,32 +712,30 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, * records to an unlimited dimension chunked dataset) */ base = H5B_NKEY(bt, shared, (idx + 1)); - if((idx + 1) == bt->nchildren) { + if ((idx + 1) == bt->nchildren) { /* Make room for the new key */ H5MM_memcpy(base + shared->type->sizeof_nkey, base, - shared->type->sizeof_nkey); /* No overlap possible - memcpy() OK */ + shared->type->sizeof_nkey); /* No overlap possible - memcpy() OK */ H5MM_memcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ - if(H5B_INS_RIGHT == anchor) - idx++; /* Don't have to memmove() child addresses down, just add new child */ + if (H5B_INS_RIGHT == anchor) + idx++; /* Don't have to memmove() child addresses down, just add new child */ else /* Make room for the new child address */ bt->child[idx + 1] = bt->child[idx]; } /* end if */ else { /* Make room for the new key */ - HDmemmove(base + shared->type->sizeof_nkey, base, - (bt->nchildren - idx) * shared->type->sizeof_nkey); + HDmemmove(base + shared->type->sizeof_nkey, base, (bt->nchildren - idx) * shared->type->sizeof_nkey); H5MM_memcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ - if(H5B_INS_RIGHT == anchor) + if (H5B_INS_RIGHT == anchor) idx++; /* Make room for the new child address */ - HDmemmove(bt->child + idx + 1, bt->child + idx, - (bt->nchildren - idx) * sizeof(haddr_t)); + HDmemmove(bt->child + idx + 1, bt->child + idx, (bt->nchildren - idx) * sizeof(haddr_t)); } /* end if */ bt->child[idx] = child; @@ -762,7 +747,6 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B_insert_child() */ - /*------------------------------------------------------------------------- * Function: H5B__insert_helper * @@ -795,20 +779,20 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, *------------------------------------------------------------------------- */ static H5B_ins_t -H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, - uint8_t *lt_key, hbool_t *lt_key_changed, uint8_t *md_key, void *udata, - uint8_t *rt_key, hbool_t *rt_key_changed, H5B_ins_ud_t *split_bt_ud/*out*/) +H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, uint8_t *lt_key, + hbool_t *lt_key_changed, uint8_t *md_key, void *udata, uint8_t *rt_key, + hbool_t *rt_key_changed, H5B_ins_ud_t *split_bt_ud /*out*/) { - H5B_t *bt; /* Convenience pointer to B-tree */ - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned lt = 0, idx = 0, rt; /* Left, final & right index values */ - int cmp = -1; /* Key comparison value */ - H5B_ins_ud_t child_bt_ud = H5B_INS_UD_T_NULL; /* Child B-tree */ - H5B_ins_ud_t new_child_bt_ud = H5B_INS_UD_T_NULL; /* Newly split child B-tree */ - H5B_ins_t my_ins = H5B_INS_ERROR; - H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ + H5B_t * bt; /* Convenience pointer to B-tree */ + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + unsigned lt = 0, idx = 0, rt; /* Left, final & right index values */ + int cmp = -1; /* Key comparison value */ + H5B_ins_ud_t child_bt_ud = H5B_INS_UD_T_NULL; /* Child B-tree */ + H5B_ins_ud_t new_child_bt_ud = H5B_INS_UD_T_NULL; /* Newly split child B-tree */ + H5B_ins_t my_ins = H5B_INS_ERROR; + H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ FUNC_ENTER_STATIC @@ -838,8 +822,8 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, *rt_key_changed = FALSE; /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object") + if (NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -850,75 +834,78 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, */ rt = bt->nchildren; - while(lt < rt && cmp) { - idx = (lt + rt) / 2; - if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) - rt = idx; - else - lt = idx + 1; + while (lt < rt && cmp) { + idx = (lt + rt) / 2; + if ((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) + rt = idx; + else + lt = idx + 1; } /* end while */ /* Set up user data for cache callbacks */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(0 == bt->nchildren) { - /* - * The value being inserted will be the only value in this tree. We - * must necessarily be at level zero. - */ - HDassert(0 == bt->level); - if((type->new_node)(f, H5B_INS_FIRST, H5B_NKEY(bt, shared, 0), udata, - H5B_NKEY(bt, shared, 1), bt->child + 0/*out*/) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node") - bt->nchildren = 1; + if (0 == bt->nchildren) { + /* + * The value being inserted will be the only value in this tree. We + * must necessarily be at level zero. + */ + HDassert(0 == bt->level); + if ((type->new_node)(f, H5B_INS_FIRST, H5B_NKEY(bt, shared, 0), udata, H5B_NKEY(bt, shared, 1), + bt->child + 0 /*out*/) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node") + bt->nchildren = 1; bt_ud->cache_flags |= H5AC__DIRTIED_FLAG; - idx = 0; - - if(type->follow_min) { - if((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), - rt_key_changed, &new_child_bt_ud.addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node") - } /* end if */ + idx = 0; + + if (type->follow_min) { + if ((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &new_child_bt_ud.addr /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node") + } /* end if */ else - my_ins = H5B_INS_NOOP; - } else if(cmp < 0 && idx == 0) { - if(bt->level > 0) { + my_ins = H5B_INS_NOOP; + } + else if (cmp < 0 && idx == 0) { + if (bt->level > 0) { /* * The value being inserted is less than any value in this tree. * Follow the minimum branch out of this node to a subtree. */ child_bt_ud.addr = bt->child[idx]; - if(NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") - if((int)(my_ins = H5B__insert_helper(f, &child_bt_ud, type, - H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, - udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, - &new_child_bt_ud/*out*/)) < 0) + if ((int)(my_ins = H5B__insert_helper( + f, &child_bt_ud, type, H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, + H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &new_child_bt_ud /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum subtree") - } else if(type->follow_min) { + } + else if (type->follow_min) { /* * The value being inserted is less than any leaf node out of this * current node. Follow the minimum branch to a leaf node and let * the subclass handle the problem. */ - if((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), - rt_key_changed, &new_child_bt_ud.addr/*out*/)) < 0) + if ((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &new_child_bt_ud.addr /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") - } else { + } + else { /* * The value being inserted is less than any leaf node out of the * current node. Create a new minimum leaf node out of this B-tree * node. This node is not empty (handled above). */ my_ins = H5B_INS_LEFT; - H5MM_memcpy(md_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey); - if((type->new_node)(f, H5B_INS_LEFT, H5B_NKEY(bt, shared, idx), udata, - md_key, &new_child_bt_ud.addr/*out*/) < 0) + H5MM_memcpy(md_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey); + if ((type->new_node)(f, H5B_INS_LEFT, H5B_NKEY(bt, shared, idx), udata, md_key, + &new_child_bt_ud.addr /*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") *lt_key_changed = TRUE; } /* end else */ @@ -926,47 +913,50 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, #ifdef H5_STRICT_FORMAT_CHECKS /* Since we are to the left of the leftmost key there must not be a left * sibling */ - if(H5F_addr_defined(bt->left)) + if (H5F_addr_defined(bt->left)) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "internal error: likely corrupt key values") #endif /* H5_STRICT_FORMAT_CHECKS */ - } else if(cmp > 0 && idx + 1 >= bt->nchildren) { + } + else if (cmp > 0 && idx + 1 >= bt->nchildren) { if (bt->level > 0) { /* - * The value being inserted is larger than any value in this tree. - * Follow the maximum branch out of this node to a subtree. - */ - idx = bt->nchildren - 1; + * The value being inserted is larger than any value in this tree. + * Follow the maximum branch out of this node to a subtree. + */ + idx = bt->nchildren - 1; child_bt_ud.addr = bt->child[idx]; - if(NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") - if((int)(my_ins = H5B__insert_helper(f, &child_bt_ud, type, - H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, - H5B_NKEY(bt, shared, idx + 1), rt_key_changed, - &new_child_bt_ud/*out*/)) < 0) + if ((int)(my_ins = H5B__insert_helper( + f, &child_bt_ud, type, H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, + H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &new_child_bt_ud /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum subtree") - } else if(type->follow_max) { + } + else if (type->follow_max) { /* * The value being inserted is larger than any leaf node out of the * current node. Follow the maximum branch to a leaf node and let * the subclass handle the problem. */ idx = bt->nchildren - 1; - if((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), - rt_key_changed, &new_child_bt_ud.addr/*out*/)) < 0) + if ((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &new_child_bt_ud.addr /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") - } else { + } + else { /* * The value being inserted is larger than any leaf node out of the * current node. Create a new maximum leaf node out of this B-tree * node. */ - idx = bt->nchildren - 1; + idx = bt->nchildren - 1; my_ins = H5B_INS_RIGHT; H5MM_memcpy(md_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey); - if((type->new_node)(f, H5B_INS_RIGHT, md_key, udata, - H5B_NKEY(bt, shared, idx + 1), &new_child_bt_ud.addr/*out*/) < 0) + if ((type->new_node)(f, H5B_INS_RIGHT, md_key, udata, H5B_NKEY(bt, shared, idx + 1), + &new_child_bt_ud.addr /*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") *rt_key_changed = TRUE; } /* end else */ @@ -974,49 +964,53 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, #ifdef H5_STRICT_FORMAT_CHECKS /* Since we are to the right of the rightmost key there must not be a * right sibling */ - if(H5F_addr_defined(bt->right)) + if (H5F_addr_defined(bt->right)) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "internal error: likely corrupt key values") #endif /* H5_STRICT_FORMAT_CHECKS */ - } else if(cmp) { - /* - * We couldn't figure out which branch to follow out of this node. THIS - * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm. - */ - HDassert("INTERNAL HDF5 ERROR (contact rpm)" && 0); + } + else if (cmp) { + /* + * We couldn't figure out which branch to follow out of this node. THIS + * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm. + */ + HDassert("INTERNAL HDF5 ERROR (contact rpm)" && 0); #ifdef NDEBUG - HDabort(); + HDabort(); #endif /* NDEBUG */ - } else if(bt->level > 0) { - /* - * Follow a branch out of this node to another subtree. - */ - HDassert(idx < bt->nchildren); - child_bt_ud.addr = bt->child[idx]; - if(NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, H5AC__NO_FLAGS_SET))) + } + else if (bt->level > 0) { + /* + * Follow a branch out of this node to another subtree. + */ + HDassert(idx < bt->nchildren); + child_bt_ud.addr = bt->child[idx]; + if (NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") - if((int)(my_ins = H5B__insert_helper(f, &child_bt_ud, type, - H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, - H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &new_child_bt_ud/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree") - } else { - /* - * Follow a branch out of this node to a leaf node of some other type. - */ - HDassert(idx < bt->nchildren); - if((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), - rt_key_changed, &new_child_bt_ud.addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node") + if ((int)(my_ins = H5B__insert_helper(f, &child_bt_ud, type, H5B_NKEY(bt, shared, idx), + lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), + rt_key_changed, &new_child_bt_ud /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree") + } + else { + /* + * Follow a branch out of this node to a leaf node of some other type. + */ + HDassert(idx < bt->nchildren); + if ((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &new_child_bt_ud.addr /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node") } HDassert((int)my_ins >= 0); /* * Update the left and right keys of the current node. */ - if(*lt_key_changed) { + if (*lt_key_changed) { bt_ud->cache_flags |= H5AC__DIRTIED_FLAG; - if(idx > 0) { + if (idx > 0) { HDassert(type->critical_key == H5B_LEFT); HDassert(!(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins)); *lt_key_changed = FALSE; @@ -1024,9 +1018,9 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, else H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey); } /* end if */ - if(*rt_key_changed) { + if (*rt_key_changed) { bt_ud->cache_flags |= H5AC__DIRTIED_FLAG; - if(idx + 1 < bt->nchildren) { + if (idx + 1 < bt->nchildren) { HDassert(type->critical_key == H5B_RIGHT); HDassert(!(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins)); *rt_key_changed = FALSE; @@ -1039,76 +1033,77 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, * Handle changes/additions to children */ HDassert(!(bt->level == 0) != !(child_bt_ud.bt)); - if(H5B_INS_CHANGE == my_ins) { - /* - * The insertion simply changed the address for the child. - */ - HDassert(!child_bt_ud.bt); - HDassert(bt->level == 0); - bt->child[idx] = new_child_bt_ud.addr; + if (H5B_INS_CHANGE == my_ins) { + /* + * The insertion simply changed the address for the child. + */ + HDassert(!child_bt_ud.bt); + HDassert(bt->level == 0); + bt->child[idx] = new_child_bt_ud.addr; bt_ud->cache_flags |= H5AC__DIRTIED_FLAG; - } else if(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) { + } + else if (H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) { unsigned *tmp_bt_flags_ptr = NULL; - H5B_t *tmp_bt; - - /* - * If this node is full then split it before inserting the new child. - */ - if(bt->nchildren == shared->two_k) { - if(H5B__split(f, bt_ud, idx, udata, split_bt_ud/*out*/) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") - if(idx < bt->nchildren) { - tmp_bt = bt; + H5B_t * tmp_bt; + + /* + * If this node is full then split it before inserting the new child. + */ + if (bt->nchildren == shared->two_k) { + if (H5B__split(f, bt_ud, idx, udata, split_bt_ud /*out*/) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") + if (idx < bt->nchildren) { + tmp_bt = bt; tmp_bt_flags_ptr = &bt_ud->cache_flags; - } else { - idx -= bt->nchildren; - tmp_bt = split_bt_ud->bt; + } + else { + idx -= bt->nchildren; + tmp_bt = split_bt_ud->bt; tmp_bt_flags_ptr = &split_bt_ud->cache_flags; - } - } /* end if */ + } + } /* end if */ else { - tmp_bt = bt; + tmp_bt = bt; tmp_bt_flags_ptr = &bt_ud->cache_flags; - } /* end else */ + } /* end else */ - /* Insert the child */ - if(H5B__insert_child(tmp_bt, tmp_bt_flags_ptr, idx, new_child_bt_ud.addr, my_ins, md_key) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child") + /* Insert the child */ + if (H5B__insert_child(tmp_bt, tmp_bt_flags_ptr, idx, new_child_bt_ud.addr, my_ins, md_key) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child") } /* end else-if */ /* * If this node split, return the mid key (the one that is shared * by the left and right node). */ - if(split_bt_ud->bt) { - H5MM_memcpy(md_key, H5B_NKEY(split_bt_ud->bt, shared, 0), type->sizeof_nkey); - ret_value = H5B_INS_RIGHT; + if (split_bt_ud->bt) { + H5MM_memcpy(md_key, H5B_NKEY(split_bt_ud->bt, shared, 0), type->sizeof_nkey); + ret_value = H5B_INS_RIGHT; #ifdef H5B_DEBUG - /* - * The max key in the original left node must be equal to the min key - * in the new node. - */ - cmp = (type->cmp2)(H5B_NKEY(bt, shared, bt->nchildren), udata, - H5B_NKEY(split_bt_ud->bt, shared, 0)); - HDassert(0 == cmp); + /* + * The max key in the original left node must be equal to the min key + * in the new node. + */ + cmp = (type->cmp2)(H5B_NKEY(bt, shared, bt->nchildren), udata, H5B_NKEY(split_bt_ud->bt, shared, 0)); + HDassert(0 == cmp); #endif } /* end if */ else - ret_value = H5B_INS_NOOP; + ret_value = H5B_INS_NOOP; done: - if(child_bt_ud.bt) - if(H5AC_unprotect(f, H5AC_BT, child_bt_ud.addr, child_bt_ud.bt, child_bt_ud.cache_flags) < 0) + if (child_bt_ud.bt) + if (H5AC_unprotect(f, H5AC_BT, child_bt_ud.addr, child_bt_ud.bt, child_bt_ud.cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect child") - if(new_child_bt_ud.bt) - if(H5AC_unprotect(f, H5AC_BT, new_child_bt_ud.addr, new_child_bt_ud.bt, new_child_bt_ud.cache_flags) < 0) + if (new_child_bt_ud.bt) + if (H5AC_unprotect(f, H5AC_BT, new_child_bt_ud.addr, new_child_bt_ud.bt, + new_child_bt_ud.cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect new child") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_insert_helper() */ - /*------------------------------------------------------------------------- * Function: H5B__iterate_helper * @@ -1124,15 +1119,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B__iterate_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_operator_t op, void *udata) +H5B__iterate_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_operator_t op, void *udata) { - H5B_t *bt = NULL; /* Pointer to current B-tree node */ - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned u; /* Local index variable */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5B_t * bt = NULL; /* Pointer to current B-tree node */ + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + unsigned u; /* Local index variable */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1146,36 +1140,35 @@ H5B__iterate_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, HDassert(udata); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); /* Protect the initial/current node */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load B-tree node") /* Iterate over node's children */ - for(u = 0; u < bt->nchildren && ret_value == H5_ITER_CONT; u++) { - if(bt->level > 0) + for (u = 0; u < bt->nchildren && ret_value == H5_ITER_CONT; u++) { + if (bt->level > 0) ret_value = H5B__iterate_helper(f, type, bt->child[u], op, udata); else ret_value = (*op)(f, H5B_NKEY(bt, shared, u), bt->child[u], H5B_NKEY(bt, shared, u + 1), udata); - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_BTREE, H5E_BADITER, "B-tree iteration failed"); } /* end for */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__iterate_helper() */ - /*------------------------------------------------------------------------- * Function: H5B_iterate * @@ -1191,10 +1184,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_operator_t op, void *udata) +H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_operator_t op, void *udata) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -1208,13 +1200,12 @@ H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, HDassert(udata); /* Iterate over the B-tree records */ - if((ret_value = H5B__iterate_helper(f, type, addr, op, udata)) < 0) + if ((ret_value = H5B__iterate_helper(f, type, addr, op, udata)) < 0) HERROR(H5E_BTREE, H5E_BADITER, "B-tree iteration failed"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_iterate() */ - /*------------------------------------------------------------------------- * Function: H5B__remove_helper * @@ -1240,18 +1231,18 @@ H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, *------------------------------------------------------------------------- */ static H5B_ins_t -H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, - uint8_t *lt_key/*out*/, hbool_t *lt_key_changed/*out*/, void *udata, - uint8_t *rt_key/*out*/, hbool_t *rt_key_changed/*out*/) +H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, uint8_t *lt_key /*out*/, + hbool_t *lt_key_changed /*out*/, void *udata, uint8_t *rt_key /*out*/, + hbool_t *rt_key_changed /*out*/) { - H5B_t *bt = NULL, *sibling = NULL; - unsigned bt_flags = H5AC__NO_FLAGS_SET; - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_t * bt = NULL, *sibling = NULL; + unsigned bt_flags = H5AC__NO_FLAGS_SET; + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned idx = 0, lt = 0, rt; /* Final, left & right indices */ - int cmp = 1; /* Key comparison value */ - H5B_ins_t ret_value = H5B_INS_ERROR; + unsigned idx = 0, lt = 0, rt; /* Final, left & right indices */ + int cmp = 1; /* Key comparison value */ + H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_STATIC @@ -1265,8 +1256,8 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, HDassert(rt_key && rt_key_changed); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object") + if (NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -1274,54 +1265,55 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, * Perform a binary search to locate the child which contains the thing * for which we're searching. */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load B-tree node") + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load B-tree node") rt = bt->nchildren; - while(lt < rt && cmp) { - idx = (lt + rt) / 2; - if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) - rt = idx; - else - lt = idx + 1; + while (lt < rt && cmp) { + idx = (lt + rt) / 2; + if ((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) + rt = idx; + else + lt = idx + 1; } /* end while */ - if(cmp) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found") + if (cmp) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found") /* * Follow the link to the subtree or to the data node. The return value * will be one of H5B_INS_ERROR, H5B_INS_NOOP, or H5B_INS_REMOVE. */ HDassert(idx < bt->nchildren); - if(bt->level > 0) { - /* We're at an internal node -- call recursively */ - if((int)(ret_value = H5B__remove_helper(f, bt->child[idx], type, - level + 1, H5B_NKEY(bt, shared, idx)/*out*/, - lt_key_changed/*out*/, udata, H5B_NKEY(bt, shared, idx + 1)/*out*/, - rt_key_changed/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree") - } else if(type->remove) { - /* - * We're at a leaf node but the leaf node points to an object that - * has a removal method. Pass the removal request to the pointed-to - * object and let it decide how to progress. - */ - if((int)(ret_value = (type->remove)(f, bt->child[idx], - H5B_NKEY(bt, shared, idx), lt_key_changed, udata, - H5B_NKEY(bt, shared, idx + 1), rt_key_changed)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node") - } else { - /* - * We're at a leaf node which points to an object that has no removal - * method. The best we can do is to leave the object alone but - * remove the B-tree reference to the object. - */ - *lt_key_changed = FALSE; - *rt_key_changed = FALSE; - ret_value = H5B_INS_REMOVE; + if (bt->level > 0) { + /* We're at an internal node -- call recursively */ + if ((int)(ret_value = + H5B__remove_helper(f, bt->child[idx], type, level + 1, + H5B_NKEY(bt, shared, idx) /*out*/, lt_key_changed /*out*/, udata, + H5B_NKEY(bt, shared, idx + 1) /*out*/, rt_key_changed /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree") + } + else if (type->remove) { + /* + * We're at a leaf node but the leaf node points to an object that + * has a removal method. Pass the removal request to the pointed-to + * object and let it decide how to progress. + */ + if ((int)(ret_value = (type->remove)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node") + } + else { + /* + * We're at a leaf node which points to an object that has no removal + * method. The best we can do is to leave the object alone but + * remove the B-tree reference to the object. + */ + *lt_key_changed = FALSE; + *rt_key_changed = FALSE; + ret_value = H5B_INS_REMOVE; } /* @@ -1332,20 +1324,20 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, * key changed and it's the right most key of this node we must update * our right key and indicate that it changed. */ - if(*lt_key_changed) { + if (*lt_key_changed) { HDassert(type->critical_key == H5B_LEFT); bt_flags |= H5AC__DIRTIED_FLAG; - if(idx > 0) + if (idx > 0) /* Don't propagate change out of this B-tree node */ *lt_key_changed = FALSE; else H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey); } /* end if */ - if(*rt_key_changed) { + if (*rt_key_changed) { HDassert(type->critical_key == H5B_RIGHT); bt_flags |= H5AC__DIRTIED_FLAG; - if(idx + 1 < bt->nchildren) + if (idx + 1 < bt->nchildren) /* Don't propagate change out of this B-tree node */ *rt_key_changed = FALSE; else @@ -1356,14 +1348,14 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, * If the subtree returned H5B_INS_REMOVE then we should remove the * subtree entry from the current node. There are four cases: */ - if(H5B_INS_REMOVE == ret_value) { + if (H5B_INS_REMOVE == ret_value) { /* Clients should not change keys when a node is removed. This function * will handle it as appropriate, based on the value of bt->critical_key */ HDassert(!(*lt_key_changed)); HDassert(!(*rt_key_changed)); - if(1 == bt->nchildren) { + if (1 == bt->nchildren) { /* * The subtree is the only child of this node. Discard both * keys and the subtree pointer. Free this node (unless it's the @@ -1371,116 +1363,123 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, */ /* Only delete the node if it is not the root node. Note that this * "level" is the opposite of bt->level */ - if(level > 0) { + if (level > 0) { /* Fix siblings, making sure that the keys remain consistent * between siblings. Overwrite the key that that is not * "critical" for any child in its node to maintain this * consistency (and avoid breaking key/child consistency) */ - if(H5F_addr_defined(bt->left)) { - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node from tree") + if (H5F_addr_defined(bt->left)) { + if (NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, + H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, + "unable to load node from tree") /* Copy right-most key from deleted node to right-most key * in its left neighbor, but only if it is not the critical * key for the right-most child of the left neighbor */ - if(type->critical_key == H5B_LEFT) - H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren), - H5B_NKEY(bt, shared, 1), type->sizeof_nkey); + if (type->critical_key == H5B_LEFT) + H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren), H5B_NKEY(bt, shared, 1), + type->sizeof_nkey); sibling->right = bt->right; - if(H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling = NULL; /* Make certain future references will be caught */ - } /* end if */ - if(H5F_addr_defined(bt->right)) { - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree") + if (H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, + "unable to release node from tree") + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ + if (H5F_addr_defined(bt->right)) { + if (NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, + H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, + "unable to unlink node from tree") /* Copy left-most key from deleted node to left-most key in * its right neighbor, but only if it is not the critical * key for the left-most child of the right neighbor */ - if(type->critical_key == H5B_RIGHT) - H5MM_memcpy(H5B_NKEY(sibling, shared, 0), - H5B_NKEY(bt, shared, 0), type->sizeof_nkey); + if (type->critical_key == H5B_RIGHT) + H5MM_memcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, 0), type->sizeof_nkey); sibling->left = bt->left; - if(H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling = NULL; /* Make certain future references will be caught */ - } /* end if */ + if (H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, + "unable to release node from tree") + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ /* Update bt struct */ - bt->left = HADDR_UNDEF; - bt->right = HADDR_UNDEF; + bt->left = HADDR_UNDEF; + bt->right = HADDR_UNDEF; bt->nchildren = 0; /* Delete the node from disk (via the metadata cache) */ - bt_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; + bt_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t); - if(H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags | H5AC__DELETED_FLAG) < 0) { - bt = NULL; + if (H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags | H5AC__DELETED_FLAG) < 0) { + bt = NULL; bt_flags = H5AC__NO_FLAGS_SET; HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to free B-tree node") } /* end if */ - bt = NULL; + bt = NULL; bt_flags = H5AC__NO_FLAGS_SET; - } else { + } + else { /* We removed the last child in the root node, set the level * back to 0 (as well as nchildren) */ bt->nchildren = 0; - bt->level = 0; + bt->level = 0; bt_flags |= H5AC__DIRTIED_FLAG; } /* end else */ - } else if(0 == idx) { + } + else if (0 == idx) { /* * The subtree is the left-most child of this node. We update the * key and child arrays and lt_key as appropriate, depending on the * status of bt->critical_key. Return H5B_INS_NOOP. */ - if(type->critical_key == H5B_LEFT) { + if (type->critical_key == H5B_LEFT) { /* Slide all keys down 1, update lt_key */ HDmemmove(H5B_NKEY(bt, shared, 0), H5B_NKEY(bt, shared, 1), - bt->nchildren * type->sizeof_nkey); + bt->nchildren * type->sizeof_nkey); H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, 0), type->sizeof_nkey); *lt_key_changed = TRUE; - } else + } + else /* Slide all but the leftmost 2 keys down, leaving the leftmost * key intact (the right key of the leftmost child is * overwritten) */ HDmemmove(H5B_NKEY(bt, shared, 1), H5B_NKEY(bt, shared, 2), - (bt->nchildren - 1) * type->sizeof_nkey); + (bt->nchildren - 1) * type->sizeof_nkey); - HDmemmove(bt->child, - bt->child + 1, - (bt->nchildren - 1) * sizeof(haddr_t)); + HDmemmove(bt->child, bt->child + 1, (bt->nchildren - 1) * sizeof(haddr_t)); bt->nchildren -= 1; bt_flags |= H5AC__DIRTIED_FLAG; ret_value = H5B_INS_NOOP; - } else if(idx + 1 == bt->nchildren) { + } + else if (idx + 1 == bt->nchildren) { /* * The subtree is the right-most child of this node. We update the * key and child arrays and rt_key as appropriate, depending on the * status of bt->critical_key. Return H5B_INS_NOOP. */ - if(type->critical_key == H5B_LEFT) + if (type->critical_key == H5B_LEFT) /* Slide the rightmost key down one, overwriting the left key of * the deleted (righmost) child */ - HDmemmove(H5B_NKEY(bt, shared, bt->nchildren - 1), - H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); + HDmemmove(H5B_NKEY(bt, shared, bt->nchildren - 1), H5B_NKEY(bt, shared, bt->nchildren), + type->sizeof_nkey); else { /* Just update rt_key */ - H5MM_memcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren - 1), - type->sizeof_nkey); + H5MM_memcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren - 1), type->sizeof_nkey); *rt_key_changed = TRUE; } /* end else */ bt->nchildren -= 1; bt_flags |= H5AC__DIRTIED_FLAG; ret_value = H5B_INS_NOOP; - } else { + } + else { /* * There are subtrees out of this node to both the left and right of * the subtree being removed. The subtree and its critical key are @@ -1488,66 +1487,62 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, * shifted left by one place. The subtree has already been freed. * Return H5B_INS_NOOP. */ - if(type->critical_key == H5B_LEFT) - HDmemmove(H5B_NKEY(bt, shared, idx), - H5B_NKEY(bt, shared, idx + 1), - (bt->nchildren - idx) * type->sizeof_nkey); + if (type->critical_key == H5B_LEFT) + HDmemmove(H5B_NKEY(bt, shared, idx), H5B_NKEY(bt, shared, idx + 1), + (bt->nchildren - idx) * type->sizeof_nkey); else - HDmemmove(H5B_NKEY(bt, shared, idx + 1), - H5B_NKEY(bt, shared, idx + 2), - (bt->nchildren - 1 - idx) * type->sizeof_nkey); + HDmemmove(H5B_NKEY(bt, shared, idx + 1), H5B_NKEY(bt, shared, idx + 2), + (bt->nchildren - 1 - idx) * type->sizeof_nkey); - HDmemmove(bt->child + idx, - bt->child + idx + 1, - (bt->nchildren - 1 - idx) * sizeof(haddr_t)); + HDmemmove(bt->child + idx, bt->child + idx + 1, (bt->nchildren - 1 - idx) * sizeof(haddr_t)); bt->nchildren -= 1; bt_flags |= H5AC__DIRTIED_FLAG; ret_value = H5B_INS_NOOP; } /* end else */ - } else /* H5B_INS_REMOVE != ret_value */ + } + else /* H5B_INS_REMOVE != ret_value */ ret_value = H5B_INS_NOOP; /* Patch keys in neighboring trees if necessary */ - if(*lt_key_changed && H5F_addr_defined(bt->left)) { + if (*lt_key_changed && H5F_addr_defined(bt->left)) { HDassert(type->critical_key == H5B_LEFT); HDassert(level > 0); /* Update the rightmost key in the left sibling */ - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to protect node") - H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren), - H5B_NKEY(bt, shared, 0), type->sizeof_nkey); + H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren), H5B_NKEY(bt, shared, 0), + type->sizeof_nkey); - if(H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling = NULL; /* Make certain future references will be caught */ - } /* end if */ - else if(*rt_key_changed && H5F_addr_defined(bt->right)) { + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ + else if (*rt_key_changed && H5F_addr_defined(bt->right)) { HDassert(type->critical_key == H5B_RIGHT); HDassert(level > 0); /* Update the lefttmost key in the right sibling */ - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == + (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to protect node") - H5MM_memcpy(H5B_NKEY(sibling, shared, 0), - H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); + H5MM_memcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); - if(H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling = NULL; /* Make certain future references will be caught */ - } /* end else */ + sibling = NULL; /* Make certain future references will be caught */ + } /* end else */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node") + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__remove_helper() */ - /*------------------------------------------------------------------------- * Function: H5B_remove * @@ -1568,12 +1563,12 @@ herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) { /* These are defined this way to satisfy alignment constraints */ - uint64_t _lt_key[128], _rt_key[128]; - uint8_t *lt_key = (uint8_t*)_lt_key; /*left key*/ - uint8_t *rt_key = (uint8_t*)_rt_key; /*right key*/ - hbool_t lt_key_changed = FALSE; /*left key changed?*/ - hbool_t rt_key_changed = FALSE; /*right key changed?*/ - herr_t ret_value = SUCCEED; /* Return value */ + uint64_t _lt_key[128], _rt_key[128]; + uint8_t *lt_key = (uint8_t *)_lt_key; /*left key*/ + uint8_t *rt_key = (uint8_t *)_rt_key; /*right key*/ + hbool_t lt_key_changed = FALSE; /*left key changed?*/ + hbool_t rt_key_changed = FALSE; /*right key changed?*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1584,8 +1579,9 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) HDassert(H5F_addr_defined(addr)); /* The actual removal */ - if(H5B_INS_ERROR == H5B__remove_helper(f, addr, type, 0, lt_key, <_key_changed, udata, rt_key, &rt_key_changed)) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") + if (H5B_INS_ERROR == + H5B__remove_helper(f, addr, type, 0, lt_key, <_key_changed, udata, rt_key, &rt_key_changed)) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") #ifdef H5B_DEBUG H5B__assert(f, addr, type, udata); @@ -1594,7 +1590,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_remove() */ - /*------------------------------------------------------------------------- * Function: H5B_delete * @@ -1611,12 +1606,12 @@ done: herr_t H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) { - H5B_t *bt = NULL; /* B-tree node being operated on */ - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_t * bt = NULL; /* B-tree node being operated on */ + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1626,23 +1621,23 @@ H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) HDassert(H5F_addr_defined(addr)); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); /* Lock this B-tree node into memory for now */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") /* Iterate over all children in tree, deleting them */ - if(bt->level > 0) { + if (bt->level > 0) { /* Iterate over all children in node, deleting them */ - for(u = 0; u < bt->nchildren; u++) - if(H5B_delete(f, type, bt->child[u], udata) < 0) + for (u = 0; u < bt->nchildren; u++) + if (H5B_delete(f, type, bt->child[u], udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to delete B-tree node") } /* end if */ @@ -1650,26 +1645,24 @@ H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) hbool_t lt_key_changed, rt_key_changed; /* Whether key changed (unused here, just for callback) */ /* Check for removal callback */ - if(type->remove) { + if (type->remove) { /* Iterate over all entries in node, calling callback */ - for(u = 0; u < bt->nchildren; u++) { + for (u = 0; u < bt->nchildren; u++) { /* Call user's callback for each entry */ - if((type->remove)(f, bt->child[u], H5B_NKEY(bt, shared, u), - <_key_changed, udata, H5B_NKEY(bt, shared, u + 1), - &rt_key_changed) < H5B_INS_NOOP) + if ((type->remove)(f, bt->child[u], H5B_NKEY(bt, shared, u), <_key_changed, udata, + H5B_NKEY(bt, shared, u + 1), &rt_key_changed) < H5B_INS_NOOP) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't remove B-tree node") } /* end for */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node in cache") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_delete() */ - /*------------------------------------------------------------------------- * Function: H5B_shared_new * @@ -1687,9 +1680,9 @@ done: H5B_shared_t * H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey) { - H5B_shared_t *shared = NULL; /* New shared B-tree struct */ - size_t u; /* Local index variable */ - H5B_shared_t *ret_value = NULL; /* Return value */ + H5B_shared_t *shared = NULL; /* New shared B-tree struct */ + size_t u; /* Local index variable */ + H5B_shared_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1699,43 +1692,43 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey) HDassert(type); /* Allocate space for the shared structure */ - if(NULL == (shared = H5FL_CALLOC(H5B_shared_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for shared B-tree info") + if (NULL == (shared = H5FL_CALLOC(H5B_shared_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for shared B-tree info") /* Set up the "global" information for this file's groups */ - shared->type = type; - shared->two_k = 2 * H5F_KVALUE(f, type); + shared->type = type; + shared->two_k = 2 * H5F_KVALUE(f, type); shared->sizeof_addr = H5F_SIZEOF_ADDR(f); - shared->sizeof_len = H5F_SIZEOF_SIZE(f); + shared->sizeof_len = H5F_SIZEOF_SIZE(f); shared->sizeof_rkey = sizeof_rkey; HDassert(shared->sizeof_rkey); - shared->sizeof_keys = (shared->two_k + 1) * type->sizeof_nkey; - shared->sizeof_rnode = ((size_t)H5B_SIZEOF_HDR(f) + /*node header */ - shared->two_k * H5F_SIZEOF_ADDR(f) + /*child pointers */ - (shared->two_k + 1) * shared->sizeof_rkey); /*keys */ + shared->sizeof_keys = (shared->two_k + 1) * type->sizeof_nkey; + shared->sizeof_rnode = ((size_t)H5B_SIZEOF_HDR(f) + /*node header */ + shared->two_k * H5F_SIZEOF_ADDR(f) + /*child pointers */ + (shared->two_k + 1) * shared->sizeof_rkey); /*keys */ HDassert(shared->sizeof_rnode); /* Allocate and clear shared buffers */ - if(NULL == (shared->page = H5FL_BLK_MALLOC(page, shared->sizeof_rnode))) + if (NULL == (shared->page = H5FL_BLK_MALLOC(page, shared->sizeof_rnode))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree page") HDmemset(shared->page, 0, shared->sizeof_rnode); - if(NULL == (shared->nkey = H5FL_SEQ_MALLOC(size_t, (size_t)(shared->two_k + 1)))) + if (NULL == (shared->nkey = H5FL_SEQ_MALLOC(size_t, (size_t)(shared->two_k + 1)))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree native keys") /* Initialize the offsets into the native key buffer */ - for(u = 0; u < (shared->two_k + 1); u++) + for (u = 0; u < (shared->two_k + 1); u++) shared->nkey[u] = u * type->sizeof_nkey; /* Set return value */ ret_value = shared; done: - if(NULL == ret_value) - if(shared) { - if(shared->page) + if (NULL == ret_value) + if (shared) { + if (shared->page) shared->page = H5FL_BLK_FREE(page, shared->page); - if(shared->nkey) + if (shared->nkey) shared->nkey = H5FL_SEQ_FREE(size_t, shared->nkey); shared = H5FL_FREE(H5B_shared_t, shared); } /* end if */ @@ -1743,7 +1736,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_shared_new() */ - /*------------------------------------------------------------------------- * Function: H5B_shared_free * @@ -1775,7 +1767,6 @@ H5B_shared_free(void *_shared) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B_shared_free() */ - /*------------------------------------------------------------------------- * Function: H5B__copy * @@ -1794,9 +1785,9 @@ H5B_shared_free(void *_shared) static H5B_t * H5B__copy(const H5B_t *old_bt) { - H5B_t *new_node = NULL; - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_t *ret_value = NULL; /* Return value */ + H5B_t * new_node = NULL; + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1808,7 +1799,7 @@ H5B__copy(const H5B_t *old_bt) HDassert(shared); /* Allocate memory for the new H5B_t object */ - if(NULL == (new_node = H5FL_MALLOC(H5B_t))) + if (NULL == (new_node = H5FL_MALLOC(H5B_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node") /* Copy the main structure */ @@ -1817,8 +1808,8 @@ H5B__copy(const H5B_t *old_bt) /* Reset cache info */ HDmemset(&new_node->cache_info, 0, sizeof(H5AC_info_t)); - if(NULL == (new_node->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || - NULL == (new_node->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) + if (NULL == (new_node->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || + NULL == (new_node->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node") /* Copy the other structures */ @@ -1832,18 +1823,17 @@ H5B__copy(const H5B_t *old_bt) ret_value = new_node; done: - if(NULL == ret_value) { - if(new_node) { - new_node->native = H5FL_BLK_FREE(native_block, new_node->native); - new_node->child = H5FL_SEQ_FREE(haddr_t, new_node->child); - new_node = H5FL_FREE(H5B_t, new_node); + if (NULL == ret_value) { + if (new_node) { + new_node->native = H5FL_BLK_FREE(native_block, new_node->native); + new_node->child = H5FL_SEQ_FREE(haddr_t, new_node->child); + new_node = H5FL_FREE(H5B_t, new_node); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__copy() */ - /*------------------------------------------------------------------------- * Function: H5B__get_info_helper * @@ -1858,18 +1848,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, - const H5B_info_ud_t *info_udata) +H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, const H5B_info_ud_t *info_udata) { - H5B_t *bt = NULL; /* Pointer to current B-tree node */ - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned level; /* Node level */ - size_t sizeof_rnode; /* Size of raw (disk) node */ - haddr_t next_addr; /* Address of next node to the right */ - haddr_t left_child; /* Address of left-most child in node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B_t * bt = NULL; /* Pointer to current B-tree node */ + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + unsigned level; /* Node level */ + size_t sizeof_rnode; /* Size of raw (disk) node */ + haddr_t next_addr; /* Address of next node to the right */ + haddr_t left_child; /* Address of left-most child in node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1884,8 +1873,8 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, HDassert(info_udata->udata); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, info_udata->udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + if (NULL == (rc_shared = (type->get_shared)(f, info_udata->udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -1893,23 +1882,23 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, sizeof_rnode = shared->sizeof_rnode; /* Protect the initial/current node */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") /* Cache information from this node */ left_child = bt->child[0]; - next_addr = bt->right; - level = bt->level; + next_addr = bt->right; + level = bt->level; /* Update B-tree info */ info_udata->bt_info->size += sizeof_rnode; info_udata->bt_info->num_nodes++; /* Release current node */ - if(H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") bt = NULL; @@ -1917,10 +1906,10 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, * Follow the right-sibling pointer from node to node until we've * processed all nodes. */ - while(H5F_addr_defined(next_addr)) { + while (H5F_addr_defined(next_addr)) { /* Protect the next node to the right */ addr = next_addr; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "B-tree node") /* Cache information from this node */ @@ -1931,26 +1920,25 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, info_udata->bt_info->num_nodes++; /* Unprotect node */ - if(H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") bt = NULL; } /* end while */ /* Check for another "row" of B-tree nodes to iterate over */ - if(level > 0) { - /* Keep following the left-most child until we reach a leaf node. */ - if(H5B__get_info_helper(f, type, left_child, info_udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node") + if (level > 0) { + /* Keep following the left-most child until we reach a leaf node. */ + if (H5B__get_info_helper(f, type, left_child, info_udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node") } /* end if */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__get_info_helper() */ - /*------------------------------------------------------------------------- * Function: H5B_get_info * @@ -1964,11 +1952,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_info_t *bt_info, H5B_operator_t op, void *udata) +H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_info_t *bt_info, H5B_operator_t op, + void *udata) { - H5B_info_ud_t info_udata; /* User-data for B-tree size iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B_info_ud_t info_udata; /* User-data for B-tree size iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1986,23 +1974,22 @@ H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, /* Set up internal user-data for the B-tree 'get info' helper routine */ info_udata.bt_info = bt_info; - info_udata.udata = udata; + info_udata.udata = udata; /* Iterate over the B-tree nodes */ - if(H5B__get_info_helper(f, type, addr, &info_udata) < 0) + if (H5B__get_info_helper(f, type, addr, &info_udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_BADITER, FAIL, "B-tree iteration failed") /* Iterate over the B-tree records, making any "leaf" callbacks */ /* (Only if operator defined) */ - if(op) - if((ret_value = H5B__iterate_helper(f, type, addr, op, udata)) < 0) + if (op) + if ((ret_value = H5B__iterate_helper(f, type, addr, op, udata)) < 0) HERROR(H5E_BTREE, H5E_BADITER, "B-tree iteration failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_get_info() */ - /*------------------------------------------------------------------------- * Function: H5B_valid * @@ -2018,10 +2005,10 @@ done: htri_t H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr) { - H5B_t *bt = NULL; /* The B-tree */ - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - htri_t ret_value = SUCCEED; /* Return value */ + H5B_t * bt = NULL; /* The B-tree */ + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2031,32 +2018,31 @@ H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr) HDassert(f); HDassert(type); - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "address is undefined") /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, NULL))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + if (NULL == (rc_shared = (type->get_shared)(f, NULL))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") HDassert(H5UC_GET_OBJ(rc_shared) != NULL); /* * Load the tree node. */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree node") + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree node") done: /* Release the node */ - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_valid() */ - /*------------------------------------------------------------------------- * Function: H5B__node_dest * @@ -2080,11 +2066,10 @@ H5B__node_dest(H5B_t *bt) HDassert(bt); HDassert(bt->rc_shared); - bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); + bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); bt->native = H5FL_BLK_FREE(native_block, bt->native); H5UC_DEC(bt->rc_shared); bt = H5FL_FREE(H5B_t, bt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B__node_dest() */ - diff --git a/src/H5B2.c b/src/H5B2.c index 5c83de2..dfc596f 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -31,38 +31,32 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -90,27 +84,25 @@ extern const H5B2_class_t H5D_BT2_FILT[1]; extern const H5B2_class_t H5B2_TEST2[1]; const H5B2_class_t *const H5B2_client_class_g[] = { - H5B2_TEST, /* 0 - H5B2_TEST_ID */ - H5HF_HUGE_BT2_INDIR, /* 1 - H5B2_FHEAP_HUGE_INDIR_ID */ - H5HF_HUGE_BT2_FILT_INDIR, /* 2 - H5B2_FHEAP_HUGE_FILT_INDIR_ID */ - H5HF_HUGE_BT2_DIR, /* 3 - H5B2_FHEAP_HUGE_DIR_ID */ - H5HF_HUGE_BT2_FILT_DIR, /* 4 - H5B2_FHEAP_HUGE_FILT_DIR_ID */ - H5G_BT2_NAME, /* 5 - H5B2_GRP_DENSE_NAME_ID */ - H5G_BT2_CORDER, /* 6 - H5B2_GRP_DENSE_CORDER_ID */ - H5SM_INDEX, /* 7 - H5B2_SOHM_INDEX_ID */ - H5A_BT2_NAME, /* 8 - H5B2_ATTR_DENSE_NAME_ID */ - H5A_BT2_CORDER, /* 9 - H5B2_ATTR_DENSE_CORDER_ID */ - H5D_BT2, /* 10 - H5B2_CDSET_ID */ - H5D_BT2_FILT, /* 11 - H5B2_CDSET_FILT_ID */ - H5B2_TEST2 /* 12 - H5B2_TEST_ID */ + H5B2_TEST, /* 0 - H5B2_TEST_ID */ + H5HF_HUGE_BT2_INDIR, /* 1 - H5B2_FHEAP_HUGE_INDIR_ID */ + H5HF_HUGE_BT2_FILT_INDIR, /* 2 - H5B2_FHEAP_HUGE_FILT_INDIR_ID */ + H5HF_HUGE_BT2_DIR, /* 3 - H5B2_FHEAP_HUGE_DIR_ID */ + H5HF_HUGE_BT2_FILT_DIR, /* 4 - H5B2_FHEAP_HUGE_FILT_DIR_ID */ + H5G_BT2_NAME, /* 5 - H5B2_GRP_DENSE_NAME_ID */ + H5G_BT2_CORDER, /* 6 - H5B2_GRP_DENSE_CORDER_ID */ + H5SM_INDEX, /* 7 - H5B2_SOHM_INDEX_ID */ + H5A_BT2_NAME, /* 8 - H5B2_ATTR_DENSE_NAME_ID */ + H5A_BT2_CORDER, /* 9 - H5B2_ATTR_DENSE_CORDER_ID */ + H5D_BT2, /* 10 - H5B2_CDSET_ID */ + H5D_BT2_FILT, /* 11 - H5B2_CDSET_FILT_ID */ + H5B2_TEST2 /* 12 - H5B2_TEST_ID */ }; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -118,8 +110,6 @@ const H5B2_class_t *const H5B2_client_class_g[] = { /* Declare a free list to manage the H5B2_t struct */ H5FL_DEFINE_STATIC(H5B2_t); - - /*------------------------------------------------------------------------- * Function: H5B2_create * @@ -136,10 +126,10 @@ H5FL_DEFINE_STATIC(H5B2_t); H5B2_t * H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) { - H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ - H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - haddr_t hdr_addr; /* B-tree header address */ - H5B2_t *ret_value = NULL; /* Return value */ + H5B2_t * bt2 = NULL; /* Pointer to the B-tree */ + H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ + haddr_t hdr_addr; /* B-tree header address */ + H5B2_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -153,25 +143,27 @@ H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) HDcompile_assert(H5B2_NUM_BTREE_ID == NELMTS(H5B2_client_class_g)); /* Create shared v2 B-tree header */ - if(HADDR_UNDEF == (hdr_addr = H5B2__hdr_create(f, cparam, ctx_udata))) + if (HADDR_UNDEF == (hdr_addr = H5B2__hdr_create(f, cparam, ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header") /* Create v2 B-tree wrapper */ - if(NULL == (bt2 = H5FL_MALLOC(H5B2_t))) + if (NULL == (bt2 = H5FL_MALLOC(H5B2_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Look up the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ bt2->hdr = hdr; - if(H5B2__hdr_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment reference count on shared v2 B-tree header") + if (H5B2__hdr_incr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, + "can't increment reference count on shared v2 B-tree header") /* Increment # of files using this v2 B-tree header */ - if(H5B2__hdr_fuse_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment file reference count on shared v2 B-tree header") + if (H5B2__hdr_fuse_incr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, + "can't increment file reference count on shared v2 B-tree header") /* Set file pointer for this v2 B-tree open context */ bt2->f = f; @@ -180,16 +172,15 @@ H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) ret_value = bt2; done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") - if(!ret_value && bt2) - if(H5B2_close(bt2) < 0) + if (!ret_value && bt2) + if (H5B2_close(bt2) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close v2 B-tree") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_create() */ - /*------------------------------------------------------------------------- * Function: H5B2_open * @@ -206,9 +197,9 @@ done: H5B2_t * H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata) { - H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ - H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_t *ret_value = NULL; /* Return value */ + H5B2_t * bt2 = NULL; /* Pointer to the B-tree */ + H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ + H5B2_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -217,25 +208,27 @@ H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata) HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5B2__hdr_protect(f, addr, ctx_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Check for pending heap deletion */ - if(hdr->pending_delete) + if (hdr->pending_delete) HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, NULL, "can't open v2 B-tree pending deletion") /* Create v2 B-tree info */ - if(NULL == (bt2 = H5FL_MALLOC(H5B2_t))) + if (NULL == (bt2 = H5FL_MALLOC(H5B2_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Point v2 B-tree wrapper at header */ bt2->hdr = hdr; - if(H5B2__hdr_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment reference count on shared v2 B-tree header") + if (H5B2__hdr_incr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, + "can't increment reference count on shared v2 B-tree header") /* Increment # of files using this v2 B-tree header */ - if(H5B2__hdr_fuse_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment file reference count on shared v2 B-tree header") + if (H5B2__hdr_fuse_incr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, + "can't increment file reference count on shared v2 B-tree header") /* Set file pointer for this v2 B-tree open context */ bt2->f = f; @@ -244,16 +237,15 @@ H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata) ret_value = bt2; done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") - if(!ret_value && bt2) - if(H5B2_close(bt2) < 0) + if (!ret_value && bt2) + if (H5B2_close(bt2) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close v2 B-tree") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_open() */ - /*------------------------------------------------------------------------- * Function: H5B2_insert * @@ -269,8 +261,8 @@ done: herr_t H5B2_insert(H5B2_t *bt2, void *udata) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -285,14 +277,13 @@ H5B2_insert(H5B2_t *bt2, void *udata) hdr = bt2->hdr; /* Insert the record */ - if(H5B2__insert(hdr, udata) < 0) + if (H5B2__insert(hdr, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_insert() */ - /*------------------------------------------------------------------------- * Function: H5B2_update * @@ -311,9 +302,9 @@ done: herr_t H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - H5B2_update_status_t status = H5B2_UPDATE_UNKNOWN; /* Whether the record was inserted/modified */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_update_status_t status = H5B2_UPDATE_UNKNOWN; /* Whether the record was inserted/modified */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -328,19 +319,20 @@ H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) hdr = bt2->hdr; /* Check if the root node is allocated yet */ - if(!H5F_addr_defined(hdr->root.addr)) { + if (!H5F_addr_defined(hdr->root.addr)) { /* Create root node as leaf node in B-tree */ - if(H5B2__create_leaf(hdr, hdr, &(hdr->root)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") + if (H5B2__create_leaf(hdr, hdr, &(hdr->root)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") } /* end if */ /* Attempt to insert record into B-tree */ - if(hdr->depth > 0) { - if(H5B2__update_internal(hdr, hdr->depth, NULL, &hdr->root, &status, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) + if (hdr->depth > 0) { + if (H5B2__update_internal(hdr, hdr->depth, NULL, &hdr->root, &status, H5B2_POS_ROOT, hdr, udata, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in B-tree internal node") } /* end if */ else { - if(H5B2__update_leaf(hdr, &hdr->root, &status, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) + if (H5B2__update_leaf(hdr, &hdr->root, &status, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in B-tree leaf node") } /* end else */ @@ -348,13 +340,13 @@ H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) HDassert(H5B2_UPDATE_UNKNOWN != status); /* Use insert algorithm if nodes to leaf full */ - if(H5B2_UPDATE_INSERT_CHILD_FULL == status) { - if(H5B2__insert(hdr, udata) < 0) + if (H5B2_UPDATE_INSERT_CHILD_FULL == status) { + if (H5B2__insert(hdr, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree") } /* end if */ - else if(H5B2_UPDATE_SHADOW_DONE == status || H5B2_UPDATE_INSERT_DONE == status) { + else if (H5B2_UPDATE_SHADOW_DONE == status || H5B2_UPDATE_INSERT_DONE == status) { /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) + if (H5B2__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") } /* end else-if */ else { @@ -366,7 +358,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_update() */ - /*------------------------------------------------------------------------- * Function: H5B2_get_addr * @@ -396,7 +387,6 @@ H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr_p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5B2_iterate * @@ -416,8 +406,8 @@ H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr_p) herr_t H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -432,15 +422,14 @@ H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data) hdr = bt2->hdr; /* Iterate through records */ - if(hdr->root.node_nrec > 0) + if (hdr->root.node_nrec > 0) /* Iterate through nodes */ - if((ret_value = H5B2__iterate_node(hdr, hdr->depth, &hdr->root, hdr, op, op_data)) < 0) + if ((ret_value = H5B2__iterate_node(hdr, hdr->depth, &hdr->root, hdr, op, op_data)) < 0) HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_iterate() */ - /*------------------------------------------------------------------------- * Function: H5B2_find * @@ -466,14 +455,14 @@ H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data) htri_t H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void *parent = NULL; /* Parent of current node */ - uint16_t depth; /* Current depth of the tree */ - int cmp; /* Comparison value of records */ - unsigned idx; /* Location of record which matches key */ - H5B2_nodepos_t curr_pos; /* Position of the current node */ - htri_t ret_value = TRUE; /* Return value */ + H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ + void * parent = NULL; /* Parent of current node */ + uint16_t depth; /* Current depth of the tree */ + int cmp; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + H5B2_nodepos_t curr_pos; /* Position of the current node */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -490,83 +479,87 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) curr_node_ptr = hdr->root; /* Check for empty tree */ - if(curr_node_ptr.node_nrec == 0) + if (curr_node_ptr.node_nrec == 0) HGOTO_DONE(FALSE) /* Check record against min & max records in tree, to attempt to quickly * find candidates or avoid further searching. */ - if(hdr->min_native_rec != NULL) { - if((hdr->cls->compare)(udata, hdr->min_native_rec, &cmp) < 0) + if (hdr->min_native_rec != NULL) { + if ((hdr->cls->compare)(udata, hdr->min_native_rec, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp < 0) - HGOTO_DONE(FALSE) /* Less than the least record--not found */ - else if(cmp == 0) { /* Record is found */ - if(op && (op)(hdr->min_native_rec, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") - HGOTO_DONE(TRUE) - } /* end if */ - } /* end if */ - if(hdr->max_native_rec != NULL) { - if((hdr->cls->compare)(udata, hdr->max_native_rec, &cmp) < 0) + if (cmp < 0) + HGOTO_DONE(FALSE) /* Less than the least record--not found */ + else if (cmp == 0) { /* Record is found */ + if (op && (op)(hdr->min_native_rec, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") + HGOTO_DONE(TRUE) + } /* end if */ + } /* end if */ + if (hdr->max_native_rec != NULL) { + if ((hdr->cls->compare)(udata, hdr->max_native_rec, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp > 0) - HGOTO_DONE(FALSE) /* Less than the least record--not found */ - else if(cmp == 0) { /* Record is found */ - if(op && (op)(hdr->max_native_rec, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") - HGOTO_DONE(TRUE) - } /* end if */ - } /* end if */ + if (cmp > 0) + HGOTO_DONE(FALSE) /* Less than the least record--not found */ + else if (cmp == 0) { /* Record is found */ + if (op && (op)(hdr->max_native_rec, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") + HGOTO_DONE(TRUE) + } /* end if */ + } /* end if */ /* Current depth of the tree */ depth = hdr->depth; /* Set initial parent, if doing swmr writes */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = hdr; /* Walk down B-tree to find record or leaf node where record is located */ - cmp = -1; + cmp = -1; curr_pos = H5B2_POS_ROOT; - while(depth > 0) { - H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ - H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ + while (depth > 0) { + H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ + H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ /* Lock B-tree current node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) { + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) { /* Unlock current node before failing */ H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET); HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ - if(cmp > 0) + if (cmp > 0) idx++; - if(cmp != 0) { + if (cmp != 0) { /* Get node pointer for next node to search */ - next_node_ptr=internal->node_ptrs[idx]; + next_node_ptr = internal->node_ptrs[idx]; /* Set the position of the next node */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) curr_pos = H5B2_POS_LEFT; else curr_pos = H5B2_POS_MIDDLE; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) curr_pos = H5B2_POS_RIGHT; else curr_pos = H5B2_POS_MIDDLE; @@ -576,11 +569,12 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ @@ -588,16 +582,18 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) } /* end if */ else { /* Make callback for current record */ - if(op && (op)(H5B2_INT_NREC(internal, hdr, idx), op_data) < 0) { + if (op && (op)(H5B2_INT_NREC(internal, hdr, idx), op_data) < 0) { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Indicate record found */ @@ -609,29 +605,30 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) } /* end while */ { - H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) { + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < + 0) { /* Unlock current node before failing */ H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET); HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ - if(cmp != 0) { + if (cmp != 0) { /* Unlock leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Record not found */ @@ -639,52 +636,54 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) } /* end if */ else { /* Make callback for current record */ - if(op && (op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) { + if (op && (op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") } /* end if */ /* Check for record being the min or max for the tree */ /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec == NULL) + if (NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree min record info") H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec == NULL) + if (NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree max record info") H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end if */ + } /* end else */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end block */ done: - if(parent) { + if (parent) { HDassert(ret_value < 0); - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_find() */ - /*------------------------------------------------------------------------- * Function: H5B2_index * @@ -703,14 +702,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, - void *op_data) +H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void *parent = NULL; /* Parent of current node */ - uint16_t depth; /* Current depth of the tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ + void * parent = NULL; /* Parent of current node */ + uint16_t depth; /* Current depth of the tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -728,54 +726,57 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, curr_node_ptr = hdr->root; /* Check for empty tree */ - if(curr_node_ptr.node_nrec == 0) + if (curr_node_ptr.node_nrec == 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records") /* Check for index greater than the number of records in the tree */ - if(idx >= curr_node_ptr.all_nrec) + if (idx >= curr_node_ptr.all_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree doesn't have that many records") /* Current depth of the tree */ depth = hdr->depth; /* Set initial parent, if doing swmr writes */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = hdr; /* Check for reverse indexing and map requested index to appropriate forward index */ - if(order == H5_ITER_DEC) + if (order == H5_ITER_DEC) idx = curr_node_ptr.all_nrec - (idx + 1); /* Walk down B-tree to find record or leaf node where record is located */ - while(depth > 0) { - H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ - H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ - unsigned u; /* Local index variable */ + while (depth > 0) { + H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ + H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ + unsigned u; /* Local index variable */ /* Lock B-tree current node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Search for record with correct index */ - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Check if record is in child node */ - if(internal->node_ptrs[u].all_nrec > idx) { + if (internal->node_ptrs[u].all_nrec > idx) { /* Get node pointer for next node to search */ next_node_ptr = internal->node_ptrs[u]; /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ @@ -786,18 +787,21 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, } /* end if */ /* Check if record is in this node */ - if(internal->node_ptrs[u].all_nrec == idx) { + if (internal->node_ptrs[u].all_nrec == idx) { /* Make callback for current record */ - if((op)(H5B2_INT_NREC(internal, hdr, u), op_data) < 0) { + if ((op)(H5B2_INT_NREC(internal, hdr, u), op_data) < 0) { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_DONE(SUCCEED); @@ -810,18 +814,20 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, } /* end for */ /* Check last node pointer */ - if(u == internal->nrec) { + if (u == internal->nrec) { /* Check if record is in child node */ - if(internal->node_ptrs[u].all_nrec > idx) { + if (internal->node_ptrs[u].all_nrec > idx) { /* Get node pointer for next node to search */ next_node_ptr = internal->node_ptrs[u]; /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ @@ -837,15 +843,15 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, } /* end while */ { - H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ @@ -854,30 +860,29 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, HDassert(idx < leaf->nrec); /* Make callback for correct record */ - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) { + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end block */ done: - if(parent) { + if (parent) { HDassert(ret_value < 0); - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_index() */ - /*------------------------------------------------------------------------- * Function: H5B2_remove * @@ -893,8 +898,8 @@ done: herr_t H5B2_remove(H5B2_t *bt2, void *udata, H5B2_remove_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -908,34 +913,35 @@ H5B2_remove(H5B2_t *bt2, void *udata, H5B2_remove_t op, void *op_data) hdr = bt2->hdr; /* Check for empty B-tree */ - if(0 == hdr->root.all_nrec) + if (0 == hdr->root.all_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record is not in B-tree") /* Attempt to remove record from B-tree */ - if(hdr->depth > 0) { - hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */ + if (hdr->depth > 0) { + hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */ - if(H5B2__remove_internal(hdr, &depth_decreased, NULL, NULL, - hdr->depth, &(hdr->cache_info), NULL, H5B2_POS_ROOT, &hdr->root, - udata, op, op_data) < 0) + if (H5B2__remove_internal(hdr, &depth_decreased, NULL, NULL, hdr->depth, &(hdr->cache_info), NULL, + H5B2_POS_ROOT, &hdr->root, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") /* Check for decreasing the depth of the B-tree */ - if(depth_decreased) { + if (depth_decreased) { /* Destroy free list factories for previous depth */ - if(hdr->node_info[hdr->depth].nat_rec_fac) - if(H5FL_fac_term(hdr->node_info[hdr->depth].nat_rec_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory") - if(hdr->node_info[hdr->depth].node_ptr_fac) - if(H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory") + if (hdr->node_info[hdr->depth].nat_rec_fac) + if (H5FL_fac_term(hdr->node_info[hdr->depth].nat_rec_fac) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't destroy node's native record block factory") + if (hdr->node_info[hdr->depth].node_ptr_fac) + if (H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't destroy node's node pointer block factory") HDassert((uint16_t)(hdr->depth - depth_decreased) < hdr->depth); hdr->depth = (uint16_t)(hdr->depth - depth_decreased); } /* end for */ - } /* end if */ + } /* end if */ else { - if(H5B2__remove_leaf(hdr, &hdr->root, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) + if (H5B2__remove_leaf(hdr, &hdr->root, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node") } /* end else */ @@ -943,14 +949,13 @@ H5B2_remove(H5B2_t *bt2, void *udata, H5B2_remove_t op, void *op_data) hdr->root.all_nrec--; /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) + if (H5B2__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_remove() */ - /*------------------------------------------------------------------------- * Function: H5B2_remove_by_idx * @@ -964,11 +969,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, - H5B2_remove_t op, void *op_data) +H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -982,42 +986,43 @@ H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, hdr = bt2->hdr; /* Check for empty B-tree */ - if(0 == hdr->root.all_nrec) + if (0 == hdr->root.all_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record is not in B-tree") /* Check for index greater than the number of records in the tree */ - if(idx >= hdr->root.all_nrec) + if (idx >= hdr->root.all_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree doesn't have that many records") /* Check for reverse indexing and map requested index to appropriate forward index */ - if(H5_ITER_DEC == order) + if (H5_ITER_DEC == order) idx = hdr->root.all_nrec - (idx + 1); /* Attempt to remove record from B-tree */ - if(hdr->depth > 0) { - hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */ + if (hdr->depth > 0) { + hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */ - if(H5B2__remove_internal_by_idx(hdr, &depth_decreased, NULL, NULL, - hdr->depth, &(hdr->cache_info), NULL, &hdr->root, H5B2_POS_ROOT, - idx, op, op_data) < 0) + if (H5B2__remove_internal_by_idx(hdr, &depth_decreased, NULL, NULL, hdr->depth, &(hdr->cache_info), + NULL, &hdr->root, H5B2_POS_ROOT, idx, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") /* Check for decreasing the depth of the B-tree */ - if(depth_decreased) { + if (depth_decreased) { /* Destroy free list factories for previous depth */ - if(hdr->node_info[hdr->depth].nat_rec_fac) - if(H5FL_fac_term(hdr->node_info[hdr->depth].nat_rec_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory") - if(hdr->node_info[hdr->depth].node_ptr_fac) - if(H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory") + if (hdr->node_info[hdr->depth].nat_rec_fac) + if (H5FL_fac_term(hdr->node_info[hdr->depth].nat_rec_fac) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't destroy node's native record block factory") + if (hdr->node_info[hdr->depth].node_ptr_fac) + if (H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't destroy node's node pointer block factory") HDassert((uint16_t)(hdr->depth - depth_decreased) < hdr->depth); hdr->depth = (uint16_t)(hdr->depth - depth_decreased); } /* end for */ - } /* end if */ + } /* end if */ else { - if(H5B2__remove_leaf_by_idx(hdr, &hdr->root, H5B2_POS_ROOT, hdr, (unsigned)idx, op, op_data) < 0) + if (H5B2__remove_leaf_by_idx(hdr, &hdr->root, H5B2_POS_ROOT, hdr, (unsigned)idx, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node") } /* end else */ @@ -1025,14 +1030,13 @@ H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, hdr->root.all_nrec--; /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) + if (H5B2__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5B2_get_nrec * @@ -1060,7 +1064,6 @@ H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_get_nrec() */ - /*------------------------------------------------------------------------- * Function: H5B2_neighbor * @@ -1086,11 +1089,10 @@ H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec) *------------------------------------------------------------------------- */ herr_t -H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, - H5B2_found_t op, void *op_data) +H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1105,16 +1107,17 @@ H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, hdr = bt2->hdr; /* Check for empty tree */ - if(!H5F_addr_defined(hdr->root.addr)) + if (!H5F_addr_defined(hdr->root.addr)) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records") /* Attempt to find neighbor record in B-tree */ - if(hdr->depth > 0) { - if(H5B2__neighbor_internal(hdr, hdr->depth, &hdr->root, NULL, range, hdr, udata, op, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree internal node") + if (hdr->depth > 0) { + if (H5B2__neighbor_internal(hdr, hdr->depth, &hdr->root, NULL, range, hdr, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "unable to find neighbor record in B-tree internal node") } /* end if */ else { - if(H5B2__neighbor_leaf(hdr, &hdr->root, NULL, range, hdr, udata, op, op_data) < 0) + if (H5B2__neighbor_leaf(hdr, &hdr->root, NULL, range, hdr, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree leaf node") } /* end else */ @@ -1122,7 +1125,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_neighbor() */ - /*------------------------------------------------------------------------- * Function: H5B2_modify * @@ -1145,14 +1147,14 @@ done: herr_t H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void *parent = NULL; /* Parent of current node */ - H5B2_nodepos_t curr_pos; /* Position of current node */ - uint16_t depth; /* Current depth of the tree */ - int cmp; /* Comparison value of records */ - unsigned idx; /* Location of record which matches key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ + void * parent = NULL; /* Parent of current node */ + H5B2_nodepos_t curr_pos; /* Position of current node */ + uint16_t depth; /* Current depth of the tree */ + int cmp; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1170,59 +1172,61 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) curr_node_ptr = hdr->root; /* Check for empty tree */ - if(0 == curr_node_ptr.node_nrec) + if (0 == curr_node_ptr.node_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records") /* Current depth of the tree */ depth = hdr->depth; /* Set initial parent, if doing swmr writes */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = hdr; /* Walk down B-tree to find record or leaf node where record is located */ - cmp = -1; + cmp = -1; curr_pos = H5B2_POS_ROOT; - while(depth > 0) { - unsigned internal_flags = H5AC__NO_FLAGS_SET; - H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ - H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ + while (depth > 0) { + unsigned internal_flags = H5AC__NO_FLAGS_SET; + H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ + H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ /* Lock B-tree current node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) { + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) { /* Unlock current node before failing */ H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET); HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ - if(cmp > 0) + if (cmp > 0) idx++; - if(cmp != 0) { + if (cmp != 0) { /* Get node pointer for next node to search */ next_node_ptr = internal->node_ptrs[idx]; /* Set the position of the next node */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) curr_pos = H5B2_POS_LEFT; else curr_pos = H5B2_POS_MIDDLE; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) curr_pos = H5B2_POS_RIGHT; else curr_pos = H5B2_POS_MIDDLE; @@ -1232,36 +1236,39 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ curr_node_ptr = next_node_ptr; } /* end if */ else { - hbool_t changed; /* Whether the 'modify' callback changed the record */ + hbool_t changed; /* Whether the 'modify' callback changed the record */ /* Make callback for current record */ - if((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { + if ((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed == FALSE); /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, + "'modify' callback failed for B-tree find operation") } /* end if */ /* Mark the node as dirty if it changed */ internal_flags |= changed ? H5AC__DIRTIED_FLAG : 0; /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_DONE(SUCCEED); @@ -1272,97 +1279,100 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) } /* end while */ { - H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ - hbool_t changed = FALSE;/* Whether the 'modify' callback changed the record */ + H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) { + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < + 0) { /* Unlock current node before failing */ H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET); HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ - if(cmp != 0) { + if (cmp != 0) { /* Unlock leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - /* Note: don't push error on stack, leave that to next higher level, - * since many times the B-tree is searched in order to determine - * if an object exists in the B-tree or not. -QAK - */ + /* Note: don't push error on stack, leave that to next higher level, + * since many times the B-tree is searched in order to determine + * if an object exists in the B-tree or not. -QAK + */ #ifdef OLD_WAY - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node") -#else /* OLD_WAY */ - HGOTO_DONE(FAIL) -#endif /* OLD_WAY */ + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node") +#else /* OLD_WAY */ + HGOTO_DONE(FAIL) +#endif /* OLD_WAY */ } /* end if */ else { /* Make callback for current record */ - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed == FALSE); /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, + "'modify' callback failed for B-tree find operation") } /* end if */ /* Check for modified record being the min or max for the tree */ /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec == NULL) + if (NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree min record info") H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec == NULL) + if (NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree max record info") H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end if */ + } /* end else */ /* Mark the node as dirty if it changed */ leaf_flags |= (changed ? H5AC__DIRTIED_FLAG : 0); /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end block */ done: - if(parent) { + if (parent) { HDassert(ret_value < 0); - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_modify() */ - /*------------------------------------------------------------------------- * Function: H5B2_close * @@ -1378,9 +1388,9 @@ done: herr_t H5B2_close(H5B2_t *bt2) { - haddr_t bt2_addr = HADDR_UNDEF; /* Address of v2 B-tree (for deletion) */ - hbool_t pending_delete = FALSE; /* Whether the v2 B-tree is pending deletion */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t bt2_addr = HADDR_UNDEF; /* Address of v2 B-tree (for deletion) */ + hbool_t pending_delete = FALSE; /* Whether the v2 B-tree is pending deletion */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1389,45 +1399,47 @@ H5B2_close(H5B2_t *bt2) HDassert(bt2->f); /* Decrement file reference & check if this is the last open v2 B-tree using the shared B-tree header */ - if(0 == H5B2__hdr_fuse_decr(bt2->hdr)) { + if (0 == H5B2__hdr_fuse_decr(bt2->hdr)) { /* Set the shared v2 B-tree header's file context for this operation */ bt2->hdr->f = bt2->f; /* Check for pending B-tree deletion */ - if(bt2->hdr->pending_delete) { + if (bt2->hdr->pending_delete) { /* Set local info, so B-tree deletion can occur after decrementing the * header's ref count */ pending_delete = TRUE; - bt2_addr = bt2->hdr->addr; + bt2_addr = bt2->hdr->addr; } /* end if */ - } /* end if */ + } /* end if */ /* Check for pending v2 B-tree deletion */ - if(pending_delete) { - H5B2_hdr_t *hdr; /* Another pointer to v2 B-tree header */ + if (pending_delete) { + H5B2_hdr_t *hdr; /* Another pointer to v2 B-tree header */ /* Sanity check */ HDassert(H5F_addr_defined(bt2_addr)); #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Header's status in the metadata cache */ - - /* Check the header's status in the metadata cache */ - if(H5AC_get_entry_status(bt2->f, bt2_addr, &hdr_status) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to check metadata cache status for v2 B-tree header, address = %llu", (unsigned long long)bt2_addr) - - /* Sanity checks on header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PINNED); - HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); -} + { + unsigned hdr_status = 0; /* Header's status in the metadata cache */ + + /* Check the header's status in the metadata cache */ + if (H5AC_get_entry_status(bt2->f, bt2_addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, + "unable to check metadata cache status for v2 B-tree header, address = %llu", + (unsigned long long)bt2_addr) + + /* Sanity checks on header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PINNED); + HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); + } #endif /* NDEBUG */ /* Lock the v2 B-tree header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = H5B2__hdr_protect(bt2->f, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5B2__hdr_protect(bt2->f, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set the shared v2 B-tree header's file context for this operation */ @@ -1437,11 +1449,12 @@ H5B2_close(H5B2_t *bt2) /* (don't put in H5B2__hdr_fuse_decr() as the B-tree header may be evicted * immediately -QAK) */ - if(H5B2__hdr_decr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") + if (H5B2__hdr_decr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared v2 B-tree header") /* Delete v2 B-tree, starting with header (unprotects header) */ - if(H5B2__hdr_delete(hdr) < 0) + if (H5B2__hdr_delete(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree") } /* end if */ else { @@ -1449,8 +1462,9 @@ H5B2_close(H5B2_t *bt2) /* (don't put in H5B2__hdr_fuse_decr() as the B-tree header may be evicted * immediately -QAK) */ - if(H5B2__hdr_decr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") + if (H5B2__hdr_decr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared v2 B-tree header") } /* end else */ @@ -1461,7 +1475,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_close() */ - /*------------------------------------------------------------------------- * Function: H5B2_delete * @@ -1484,11 +1497,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, - void *op_data) +H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_data) { - H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1498,37 +1510,36 @@ H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, /* Lock the v2 B-tree header into memory */ #ifdef QAK -HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); + HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ - if(NULL == (hdr = H5B2__hdr_protect(f, addr, ctx_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5B2__hdr_protect(f, addr, ctx_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Remember the callback & context for later */ - hdr->remove_op = op; + hdr->remove_op = op; hdr->remove_op_data = op_data; /* Check for files using shared v2 B-tree header */ - if(hdr->file_rc) + if (hdr->file_rc) hdr->pending_delete = TRUE; else { /* Set the shared v2 B-tree header's file context for this operation */ hdr->f = f; /* Delete v2 B-tree now, starting with header (unprotects header) */ - if(H5B2__hdr_delete(hdr) < 0) + if (H5B2__hdr_delete(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree") hdr = NULL; } /* end if */ done: /* Unprotect the header, if an error occurred */ - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_delete() */ - /*------------------------------------------------------------------------- * Function: H5B2_depend * @@ -1546,8 +1557,8 @@ herr_t H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent) { /* Local variables */ - H5B2_hdr_t *hdr = bt2->hdr; /* Header for B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr = bt2->hdr; /* Header for B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(SUCCEED) @@ -1564,7 +1575,7 @@ H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent) * and the v2 B-tree header has already been setup. If it hasn't, then * set it up. */ - if(NULL == hdr->parent) { + if (NULL == hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); @@ -1572,16 +1583,15 @@ H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent) hdr->f = bt2->f; /* Add the v2 B-tree as a child of the parent (proxy) */ - if(H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) + if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, FAIL, "unable to add v2 B-tree as child of proxy") - hdr->parent = parent; + hdr->parent = parent; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_depend() */ - /*------------------------------------------------------------------------- * Function: H5B2_patch_file * @@ -1605,9 +1615,8 @@ H5B2_patch_file(H5B2_t *bt2, H5F_t *f) HDassert(bt2); HDassert(f); - if(bt2->f != f || bt2->hdr->f != f) + if (bt2->f != f || bt2->hdr->f != f) bt2->f = bt2->hdr->f = f; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_patch_file() */ - diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 5b0b8b2..f619b14 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -26,38 +26,33 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* B-tree format version #'s */ -#define H5B2_HDR_VERSION 0 /* Header */ -#define H5B2_INT_VERSION 0 /* Internal node */ -#define H5B2_LEAF_VERSION 0 /* Leaf node */ - +#define H5B2_HDR_VERSION 0 /* Header */ +#define H5B2_INT_VERSION 0 /* Internal node */ +#define H5B2_LEAF_VERSION 0 /* Leaf node */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -65,31 +60,25 @@ /* Metadata cache callbacks */ static herr_t H5B2__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void *H5B2__cache_hdr_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5B2__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_hdr_image_len(const void *thing, size_t *image_len); -static herr_t H5B2__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5B2__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *thing); static herr_t H5B2__cache_hdr_free_icr(void *thing); static herr_t H5B2__cache_int_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_int_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void *H5B2__cache_int_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5B2__cache_int_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_int_image_len(const void *thing, size_t *image_len); -static herr_t H5B2__cache_int_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5B2__cache_int_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_int_notify(H5AC_notify_action_t action, void *thing); static herr_t H5B2__cache_int_free_icr(void *thing); static herr_t H5B2__cache_leaf_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_leaf_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void *H5B2__cache_leaf_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5B2__cache_leaf_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_leaf_image_len(const void *thing, size_t *image_len); -static herr_t H5B2__cache_leaf_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5B2__cache_leaf_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *thing); static herr_t H5B2__cache_leaf_free_icr(void *thing); @@ -99,73 +88,69 @@ static herr_t H5B2__cache_leaf_free_icr(void *thing); /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_HDR[1] = {{ - H5AC_BT2_HDR_ID, /* Metadata client ID */ - "v2 B-tree header", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_HDR_ID, /* Metadata client ID */ + "v2 B-tree header", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_hdr_deserialize, /* 'deserialize' callback */ - H5B2__cache_hdr_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_hdr_serialize, /* 'serialize' callback */ - H5B2__cache_hdr_notify, /* 'notify' callback */ - H5B2__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_hdr_deserialize, /* 'deserialize' callback */ + H5B2__cache_hdr_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_hdr_serialize, /* 'serialize' callback */ + H5B2__cache_hdr_notify, /* 'notify' callback */ + H5B2__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_INT[1] = {{ - H5AC_BT2_INT_ID, /* Metadata client ID */ - "v2 B-tree internal node", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_INT_ID, /* Metadata client ID */ + "v2 B-tree internal node", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_int_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_int_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_int_deserialize, /* 'deserialize' callback */ - H5B2__cache_int_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_int_serialize, /* 'serialize' callback */ - H5B2__cache_int_notify, /* 'notify' callback */ - H5B2__cache_int_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_int_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_int_deserialize, /* 'deserialize' callback */ + H5B2__cache_int_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_int_serialize, /* 'serialize' callback */ + H5B2__cache_int_notify, /* 'notify' callback */ + H5B2__cache_int_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_LEAF[1] = {{ - H5AC_BT2_LEAF_ID, /* Metadata client ID */ - "v2 B-tree leaf node", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_LEAF_ID, /* Metadata client ID */ + "v2 B-tree leaf node", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_leaf_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_leaf_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_leaf_deserialize, /* 'deserialize' callback */ - H5B2__cache_leaf_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_leaf_serialize, /* 'serialize' callback */ - H5B2__cache_leaf_notify, /* 'notify' callback */ - H5B2__cache_leaf_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_leaf_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_leaf_deserialize, /* 'deserialize' callback */ + H5B2__cache_leaf_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_leaf_serialize, /* 'serialize' callback */ + H5B2__cache_leaf_notify, /* 'notify' callback */ + H5B2__cache_leaf_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_get_initial_load_size * @@ -197,7 +182,6 @@ H5B2__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_verify_chksum * @@ -214,10 +198,10 @@ H5B2__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -227,13 +211,12 @@ H5B2__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_deserialize * @@ -249,17 +232,17 @@ H5B2__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static void * -H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { - H5B2_hdr_t *hdr = NULL; /* B-tree header */ + H5B2_hdr_t * hdr = NULL; /* B-tree header */ H5B2_hdr_cache_ud_t *udata = (H5B2_hdr_cache_ud_t *)_udata; - H5B2_create_t cparam; /* B-tree creation parameters */ - H5B2_subid_t id; /* ID of B-tree class, as found in file */ - uint16_t depth; /* Depth of B-tree */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5B2_hdr_t *ret_value = NULL; /* Return value */ + H5B2_create_t cparam; /* B-tree creation parameters */ + H5B2_subid_t id; /* ID of B-tree class, as found in file */ + uint16_t depth; /* Depth of B-tree */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5B2_hdr_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -268,21 +251,21 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new B-tree header and reset cache info */ - if(NULL == (hdr = H5B2__hdr_alloc(udata->f))) + if (NULL == (hdr = H5B2__hdr_alloc(udata->f))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "allocation failed for B-tree header") /* Magic number */ - if(HDmemcmp(image, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree header signature") + if (HDmemcmp(image, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_HDR_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree header version") + if (*image++ != H5B2_HDR_VERSION) + HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree header version") /* B-tree class */ id = (H5B2_subid_t)*image++; - if(id >= H5B2_NUM_BTREE_ID) + if (id >= H5B2_NUM_BTREE_ID) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Node size (in bytes) */ @@ -313,7 +296,7 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, /* Initialize B-tree header info */ cparam.cls = H5B2_client_class_g[id]; - if(H5B2__hdr_init(hdr, &cparam, udata->ctx_udata, depth) < 0) + if (H5B2__hdr_init(hdr, &cparam, udata->ctx_udata, depth) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info") /* Set the B-tree header's address */ @@ -326,14 +309,13 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = hdr; done: - if(!ret_value && hdr) - if(H5B2__hdr_free(hdr) < 0) + if (!ret_value && hdr) + if (H5B2__hdr_free(hdr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, NULL, "can't release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_image_len * @@ -350,7 +332,7 @@ done: static herr_t H5B2__cache_hdr_image_len(const void *_thing, size_t *image_len) { - const H5B2_hdr_t *hdr = (const H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ + const H5B2_hdr_t *hdr = (const H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ FUNC_ENTER_STATIC_NOERR @@ -364,7 +346,6 @@ H5B2__cache_hdr_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_serialize * @@ -379,12 +360,11 @@ H5B2__cache_hdr_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) +H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { - H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ FUNC_ENTER_STATIC_NOERR @@ -436,7 +416,6 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_notify * @@ -453,8 +432,8 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le static herr_t H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -464,14 +443,14 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) HDassert(hdr); /* Check if the file was opened with SWMR-write access */ - if(hdr->swmr_write) { - switch(action) { + if (hdr->swmr_write) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: - /* do nothing */ + case H5AC_NOTIFY_ACTION_AFTER_LOAD: + /* do nothing */ break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Increment the shadow epoch, forcing new modifications to * internal and leaf nodes to create new shadow copies */ hdr->shadow_epoch++; @@ -483,39 +462,43 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ + /* do nothing */ break; - case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* If hdr->parent != NULL, hdr->parent is used to destroy * the flush dependency before the header is evicted. */ - if(hdr->parent) { + if (hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); - /* Destroy flush dependency on object header proxy */ - if(H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between v2 B-tree and proxy") + /* Destroy flush dependency on object header proxy */ + if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, + (void *)hdr->top_proxy) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between v2 B-tree and proxy") hdr->parent = NULL; - } /* end if */ + } /* end if */ /* Detach from 'top' proxy for extensible array */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between header and v2 B-tree 'top' proxy") + if (hdr->top_proxy) { + if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) + HGOTO_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between header and v2 B-tree 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ - break; + break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == hdr->parent); @@ -523,7 +506,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_free_icr * @@ -541,7 +523,7 @@ done: static herr_t H5B2__cache_hdr_free_icr(void *thing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -549,14 +531,13 @@ H5B2__cache_hdr_free_icr(void *thing) HDassert(thing); /* Destroy v2 B-tree header */ - if(H5B2__hdr_free((H5B2_hdr_t *)thing) < 0) + if (H5B2__hdr_free((H5B2_hdr_t *)thing) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree header") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_get_initial_load_size * @@ -588,7 +569,6 @@ H5B2__cache_int_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_int_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_verify_chksum * @@ -605,12 +585,12 @@ H5B2__cache_int_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ - size_t chk_size; /* Exact size of the node with checksum at the end */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ + size_t chk_size; /* Exact size of the node with checksum at the end */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -619,18 +599,18 @@ H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, voi HDassert(udata); /* Internal node prefix header + records + child pointer triplets: size with checksum at the end */ - chk_size = H5B2_INT_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size) + ((size_t)(udata->nrec + 1) * H5B2_INT_POINTER_SIZE(udata->hdr, udata->depth)); + chk_size = H5B2_INT_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size) + + ((size_t)(udata->nrec + 1) * H5B2_INT_POINTER_SIZE(udata->hdr, udata->depth)); /* Get stored and computed checksums */ H5F_get_checksums(image, chk_size, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_int_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_deserialize * @@ -646,18 +626,18 @@ H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, voi *------------------------------------------------------------------------- */ static void * -H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { - H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ - H5B2_internal_t *internal = NULL; /* Internal node read */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *native; /* Pointer to native record info */ - H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned u; /* Local index variable */ - H5B2_internal_t *ret_value = NULL; /* Return value */ - int node_nrec = 0; + H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ + H5B2_internal_t * internal = NULL; /* Internal node read */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * native; /* Pointer to native record info */ + H5B2_node_ptr_t * int_node_ptr; /* Pointer to node pointer info */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + unsigned u; /* Local index variable */ + H5B2_internal_t * ret_value = NULL; /* Return value */ + int node_nrec = 0; FUNC_ENTER_STATIC @@ -666,48 +646,52 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new internal node and reset cache info */ - if(NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(udata->hdr) < 0) + if (H5B2__hdr_incr(udata->hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") /* Share B-tree information */ - internal->hdr = udata->hdr; - internal->parent = udata->parent; + internal->hdr = udata->hdr; + internal->parent = udata->parent; internal->shadow_epoch = udata->hdr->shadow_epoch; /* Magic number */ - if(HDmemcmp(image, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree internal node signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_INT_VERSION) + if (*image++ != H5B2_INT_VERSION) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree internal node version") /* B-tree type */ - if(*image++ != (uint8_t)udata->hdr->cls->id) + if (*image++ != (uint8_t)udata->hdr->cls->id) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Allocate space for the native keys in memory */ - if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal native keys") + if (NULL == + (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for B-tree internal native keys") /* Allocate space for the node pointers in memory */ - if(NULL == (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].node_ptr_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal node pointers") + if (NULL == (internal->node_ptrs = + (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].node_ptr_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for B-tree internal node pointers") /* Set the number of records in the leaf & it's depth */ - internal->nrec = udata->nrec; + internal->nrec = udata->nrec; internal->depth = udata->depth; /* Deserialize records for internal node */ native = internal->int_native; - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Decode record */ - if((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -717,13 +701,14 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, /* Deserialize node pointers for internal node */ int_node_ptr = internal->node_ptrs; - for(u = 0; u < (unsigned)(internal->nrec + 1); u++) { + for (u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Decode node pointer */ H5F_addr_decode(udata->f, (const uint8_t **)&image, &(int_node_ptr->addr)); UINT64DECODE_VAR(image, node_nrec, udata->hdr->max_nrec_size); H5_CHECKED_ASSIGN(int_node_ptr->node_nrec, uint16_t, node_nrec, int); - if(udata->depth > 1) - UINT64DECODE_VAR(image, int_node_ptr->all_nrec, udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size) + if (udata->depth > 1) + UINT64DECODE_VAR(image, int_node_ptr->all_nrec, + udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size) else int_node_ptr->all_nrec = int_node_ptr->node_nrec; @@ -743,14 +728,13 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = internal; done: - if(!ret_value && internal) - if(H5B2__internal_free(internal) < 0) + if (!ret_value && internal) + if (H5B2__internal_free(internal) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_image_len * @@ -767,7 +751,8 @@ done: static herr_t H5B2__cache_int_image_len(const void *_thing, size_t *image_len) { - const H5B2_internal_t *internal = (const H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ + const H5B2_internal_t *internal = + (const H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ FUNC_ENTER_STATIC_NOERR @@ -782,7 +767,6 @@ H5B2__cache_int_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_int_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_serialize * @@ -797,16 +781,15 @@ H5B2__cache_int_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) +H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { - H5B2_internal_t *internal = (H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *native; /* Pointer to native record info */ - H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = (H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * native; /* Pointer to native record info */ + H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -830,9 +813,9 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Serialize records for internal node */ native = internal->int_native; - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Encode record */ - if((internal->hdr->cls->encode)(image, native, internal->hdr->cb_ctx) < 0) + if ((internal->hdr->cls->encode)(image, native, internal->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ @@ -842,12 +825,13 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Serialize node pointers for internal node */ int_node_ptr = internal->node_ptrs; - for(u = 0; u < (unsigned)(internal->nrec + 1); u++) { + for (u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Encode node pointer */ H5F_addr_encode(f, &image, int_node_ptr->addr); UINT64ENCODE_VAR(image, int_node_ptr->node_nrec, internal->hdr->max_nrec_size); - if(internal->depth > 1) - UINT64ENCODE_VAR(image, int_node_ptr->all_nrec, internal->hdr->node_info[internal->depth - 1].cum_max_nrec_size); + if (internal->depth > 1) + UINT64ENCODE_VAR(image, int_node_ptr->all_nrec, + internal->hdr->node_info[internal->depth - 1].cum_max_nrec_size); /* Move to next node pointer */ int_node_ptr++; @@ -869,7 +853,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_notify * @@ -886,8 +869,8 @@ done: static herr_t H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_internal_t *internal = (H5B2_internal_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_internal_t *internal = (H5B2_internal_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -898,34 +881,36 @@ H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) HDassert(internal->hdr); /* Check if the file was opened with SWMR-write access */ - if(internal->hdr->swmr_write) { - switch(action) { + if (internal->hdr->swmr_write) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5B2__create_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) + if (H5B2__create_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + /* Destroy flush dependency on parent */ + if (H5B2__destroy_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for v2 B-tree */ - if(internal->top_proxy) { - if(H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy") + if (internal->top_proxy) { + if (H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between internal node and v2 B-tree " + "'top' proxy") internal->top_proxy = NULL; } /* end if */ break; @@ -933,11 +918,11 @@ H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == internal->top_proxy); @@ -945,7 +930,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_int_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_free_icr * @@ -963,8 +947,8 @@ done: static herr_t H5B2__cache_int_free_icr(void *_thing) { - H5B2_internal_t *internal = (H5B2_internal_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = (H5B2_internal_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -972,14 +956,13 @@ H5B2__cache_int_free_icr(void *_thing) HDassert(internal); /* Release v2 B-tree internal node */ - if(H5B2__internal_free(internal) < 0) + if (H5B2__internal_free(internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_get_initial_load_size * @@ -1011,7 +994,6 @@ H5B2__cache_leaf_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_leaf_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_verify_chksum * @@ -1028,12 +1010,12 @@ H5B2__cache_leaf_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ - size_t chk_size; /* Exact size of the node with checksum at the end */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ + size_t chk_size; /* Exact size of the node with checksum at the end */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1047,13 +1029,12 @@ H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo /* Get stored and computed checksums */ H5F_get_checksums(image, chk_size, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_leaf_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_deserialize * @@ -1069,16 +1050,16 @@ H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo *------------------------------------------------------------------------- */ static void * -H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { H5B2_leaf_cache_ud_t *udata = (H5B2_leaf_cache_ud_t *)_udata; - H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *native; /* Pointer to native keys */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned u; /* Local index variable */ - H5B2_leaf_t *ret_value = NULL; /* Return value */ + H5B2_leaf_t * leaf = NULL; /* Pointer to lead node loaded */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * native; /* Pointer to native keys */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + unsigned u; /* Local index variable */ + H5B2_leaf_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1087,43 +1068,43 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new leaf node and reset cache info */ - if(NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed") + if (NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(udata->hdr) < 0) + if (H5B2__hdr_incr(udata->hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") /* Share B-tree header information */ - leaf->hdr = udata->hdr; - leaf->parent = udata->parent; + leaf->hdr = udata->hdr; + leaf->parent = udata->parent; leaf->shadow_epoch = udata->hdr->shadow_epoch; /* Magic number */ - if(HDmemcmp(image, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree leaf node signature") + if (HDmemcmp(image, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree leaf node signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_LEAF_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree leaf node version") + if (*image++ != H5B2_LEAF_VERSION) + HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree leaf node version") /* B-tree type */ - if(*image++ != (uint8_t)udata->hdr->cls->id) + if (*image++ != (uint8_t)udata->hdr->cls->id) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Allocate space for the native keys in memory */ - if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[0].nat_rec_fac))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree leaf native keys") + if (NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[0].nat_rec_fac))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree leaf native keys") /* Set the number of records in the leaf */ leaf->nrec = udata->nrec; /* Deserialize records for leaf node */ native = leaf->leaf_native; - for(u = 0; u < leaf->nrec; u++) { + for (u = 0; u < leaf->nrec; u++) { /* Decode record */ - if((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -1146,14 +1127,13 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = leaf; done: - if(!ret_value && leaf) - if(H5B2__leaf_free(leaf) < 0) + if (!ret_value && leaf) + if (H5B2__leaf_free(leaf) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_image_len * @@ -1170,7 +1150,7 @@ done: static herr_t H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) { - const H5B2_leaf_t *leaf = (const H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ + const H5B2_leaf_t *leaf = (const H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ FUNC_ENTER_STATIC_NOERR @@ -1185,7 +1165,6 @@ H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_leaf_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_serialize * @@ -1201,14 +1180,14 @@ H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) */ static herr_t H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) + void *_thing) { - H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *native; /* Pointer to native keys */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * native; /* Pointer to native keys */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1232,9 +1211,9 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H /* Serialize records for leaf node */ native = leaf->leaf_native; - for(u = 0; u < leaf->nrec; u++) { + for (u = 0; u < leaf->nrec; u++) { /* Encode record */ - if((leaf->hdr->cls->encode)(image, native, leaf->hdr->cb_ctx) < 0) + if ((leaf->hdr->cls->encode)(image, native, leaf->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ @@ -1243,7 +1222,8 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H } /* end for */ /* Compute metadata checksum */ - metadata_chksum = H5_checksum_metadata(_image, (size_t)((const uint8_t *)image - (const uint8_t *)_image), 0); + metadata_chksum = + H5_checksum_metadata(_image, (size_t)((const uint8_t *)image - (const uint8_t *)_image), 0); /* Metadata checksum */ UINT32ENCODE(image, metadata_chksum); @@ -1258,7 +1238,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_notify * @@ -1275,8 +1254,8 @@ done: static herr_t H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1287,16 +1266,16 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) HDassert(leaf->hdr); /* Check if the file was opened with SWMR-write access */ - if(leaf->hdr->swmr_write) { - switch(action) { + if (leaf->hdr->swmr_write) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5B2__create_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) + if (H5B2__create_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: @@ -1307,14 +1286,16 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) + /* Destroy flush dependency on parent */ + if (H5B2__destroy_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for v2 B-tree */ - if(leaf->top_proxy) { - if(H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") + if (leaf->top_proxy) { + if (H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) + HGOTO_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") leaf->top_proxy = NULL; } /* end if */ break; @@ -1322,11 +1303,11 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == leaf->top_proxy); @@ -1334,7 +1315,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_leaf_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_free_icr * @@ -1352,8 +1332,8 @@ done: static herr_t H5B2__cache_leaf_free_icr(void *_thing) { - H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1361,10 +1341,9 @@ H5B2__cache_leaf_free_icr(void *_thing) HDassert(leaf); /* Destroy v2 B-tree leaf node */ - if(H5B2__leaf_free(leaf) < 0) + if (H5B2__leaf_free(leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_free_icr() */ - diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index b5b1c03..f60fb91 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -26,52 +26,44 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_debug * @@ -87,12 +79,12 @@ */ herr_t H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5B2_class_t H5_ATTR_NDEBUG_UNUSED *type, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) + const H5B2_class_t H5_ATTR_NDEBUG_UNUSED *type, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { - H5B2_hdr_t *hdr = NULL; /* B-tree header info */ - unsigned u; /* Local index variable */ - char temp_str[128]; /* Temporary string, for formatting */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* B-tree header info */ + unsigned u; /* Local index variable */ + char temp_str[128]; /* Temporary string, for formatting */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -108,7 +100,7 @@ H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(type); /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5B2__hdr_protect(f, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -120,53 +112,36 @@ H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of node:", - (unsigned)hdr->node_size); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, + (unsigned)hdr->cls->id); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of node:", (unsigned)hdr->node_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + "Size of raw (disk) record:", (unsigned)hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - hdr->cache_info.is_dirty ? "True" : "False"); + "Dirty flag:", hdr->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Depth:", hdr->depth); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Number of records in tree:", hdr->root.all_nrec); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Depth:", - hdr->depth); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of records in tree:", - hdr->root.all_nrec); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of records in root node:", - hdr->root.node_nrec); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of root node:", - hdr->root.addr); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Split percent:", - hdr->split_percent); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Merge percent:", - hdr->merge_percent); + "Number of records in root node:", hdr->root.node_nrec); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of root node:", hdr->root.addr); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Split percent:", hdr->split_percent); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Merge percent:", hdr->merge_percent); /* Print relevant node info */ HDfprintf(stream, "%*sNode Info: (max_nrec/split_nrec/merge_nrec)\n", indent, ""); - for(u = 0; u < (unsigned)(hdr->depth + 1); u++) { + for (u = 0; u < (unsigned)(hdr->depth + 1); u++) { HDsnprintf(temp_str, sizeof(temp_str), "Depth %u:", u); - HDfprintf(stream, "%*s%-*s (%u/%u/%u)\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str, - hdr->node_info[u].max_nrec, hdr->node_info[u].split_nrec, hdr->node_info[u].merge_nrec); + HDfprintf(stream, "%*s%-*s (%u/%u/%u)\n", indent + 3, "", MAX(0, fwidth - 3), temp_str, + hdr->node_info[u].max_nrec, hdr->node_info[u].split_nrec, hdr->node_info[u].merge_nrec); } /* end for */ done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_debug() */ - /*------------------------------------------------------------------------- * Function: H5B2__int_debug * @@ -181,15 +156,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, unsigned depth, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) +H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B2_class_t *type, + haddr_t hdr_addr, unsigned nrec, unsigned depth, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { - H5B2_hdr_t *hdr = NULL; /* B-tree header */ - H5B2_internal_t *internal = NULL; /* B-tree internal node */ - H5B2_node_ptr_t node_ptr; /* Fake node pointer for protect */ - unsigned u; /* Local index variable */ - char temp_str[128]; /* Temporary string, for formatting */ - herr_t ret_value=SUCCEED; /* Return value */ + H5B2_hdr_t * hdr = NULL; /* B-tree header */ + H5B2_internal_t *internal = NULL; /* B-tree internal node */ + H5B2_node_ptr_t node_ptr; /* Fake node pointer for protect */ + unsigned u; /* Local index variable */ + char temp_str[128]; /* Temporary string, for formatting */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -207,7 +182,7 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(nrec > 0); /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ @@ -219,7 +194,8 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, H5_CHECK_OVERFLOW(depth, unsigned, uint16_t); node_ptr.addr = addr; H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned) - if(NULL == (internal = H5B2__protect_internal(hdr, NULL, &node_ptr, (uint16_t)depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (internal = H5B2__protect_internal(hdr, NULL, &node_ptr, (uint16_t)depth, FALSE, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree internal node") /* Print opening message */ @@ -228,57 +204,45 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of node:", - (unsigned)hdr->node_size); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, + (unsigned)hdr->cls->id); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of node:", (unsigned)hdr->node_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + "Size of raw (disk) record:", (unsigned)hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - internal->cache_info.is_dirty ? "True" : "False"); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of records in node:", - internal->nrec); + "Dirty flag:", internal->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of records in node:", internal->nrec); /* Print all node pointers and records */ - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Print node pointer */ HDsnprintf(temp_str, sizeof(temp_str), "Node pointer #%u: (all/node/addr)", u); - HDfprintf(stream, "%*s%-*s (%Hu/%u/%a)\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str, - internal->node_ptrs[u].all_nrec, - internal->node_ptrs[u].node_nrec, + HDfprintf(stream, "%*s%-*s (%Hu/%u/%a)\n", indent + 3, "", MAX(0, fwidth - 3), temp_str, + internal->node_ptrs[u].all_nrec, internal->node_ptrs[u].node_nrec, internal->node_ptrs[u].addr); /* Print record */ HDsnprintf(temp_str, sizeof(temp_str), "Record #%u:", u); - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_INT_NREC(internal, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_INT_NREC(internal, hdr, u), hdr->cb_ctx); + (void)(type->debug)(stream, indent + 6, MAX(0, fwidth - 6), H5B2_INT_NREC(internal, hdr, u), + hdr->cb_ctx); } /* end for */ /* Print final node pointer */ HDsnprintf(temp_str, sizeof(temp_str), "Node pointer #%u: (all/node/addr)", u); - HDfprintf(stream, "%*s%-*s (%Hu/%u/%a)\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str, - internal->node_ptrs[u].all_nrec, - internal->node_ptrs[u].node_nrec, - internal->node_ptrs[u].addr); + HDfprintf(stream, "%*s%-*s (%Hu/%u/%a)\n", indent + 3, "", MAX(0, fwidth - 3), temp_str, + internal->node_ptrs[u].all_nrec, internal->node_ptrs[u].node_nrec, internal->node_ptrs[u].addr); done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") - if(internal && H5AC_unprotect(f, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (internal && H5AC_unprotect(f, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__int_debug() */ - /*------------------------------------------------------------------------- * Function: H5B2__leaf_debug * @@ -293,15 +257,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) +H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B2_class_t *type, + haddr_t hdr_addr, unsigned nrec, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { - H5B2_hdr_t *hdr = NULL; /* B-tree header */ - H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ - H5B2_node_ptr_t node_ptr; /* Fake node pointer for protect */ - unsigned u; /* Local index variable */ - char temp_str[128]; /* Temporary string, for formatting */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t * hdr = NULL; /* B-tree header */ + H5B2_leaf_t * leaf = NULL; /* B-tree leaf node */ + H5B2_node_ptr_t node_ptr; /* Fake node pointer for protect */ + unsigned u; /* Local index variable */ + char temp_str[128]; /* Temporary string, for formatting */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -319,7 +283,7 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(nrec > 0); /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ @@ -331,7 +295,7 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, H5_CHECK_OVERFLOW(nrec, unsigned, uint16_t); node_ptr.addr = addr; H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned) - if(NULL == (leaf = H5B2__protect_leaf(hdr, NULL, &node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, NULL, &node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Print opening message */ @@ -340,37 +304,30 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of node:", - (unsigned)hdr->node_size); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, + (unsigned)hdr->cls->id); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of node:", (unsigned)hdr->node_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + "Size of raw (disk) record:", (unsigned)hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - leaf->cache_info.is_dirty ? "True" : "False"); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of records in node:", - leaf->nrec); + "Dirty flag:", leaf->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of records in node:", leaf->nrec); /* Print all node pointers and records */ - for(u = 0; u < leaf->nrec; u++) { + for (u = 0; u < leaf->nrec; u++) { /* Print record */ HDsnprintf(temp_str, sizeof(temp_str), "Record #%u:", u); - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_LEAF_NREC(leaf, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_LEAF_NREC(leaf, hdr, u), hdr->cb_ctx); + (void)(type->debug)(stream, indent + 6, MAX(0, fwidth - 6), H5B2_LEAF_NREC(leaf, hdr, u), + hdr->cb_ctx); } /* end for */ done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - if(leaf && H5AC_unprotect(f, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (leaf && H5AC_unprotect(f, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__leaf_debug() */ - diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 9ba8235..a535f0b 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -26,26 +26,24 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ /* Number of records that fit into leaf node */ -#define H5B2_NUM_LEAF_REC(n, r) \ - (((n) - H5B2_LEAF_PREFIX_SIZE) / (r)) +#define H5B2_NUM_LEAF_REC(n, r) (((n)-H5B2_LEAF_PREFIX_SIZE) / (r)) /* Uncomment this macro to enable extra sanity checking */ /* #define H5B2_DEBUG */ @@ -54,27 +52,22 @@ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -91,8 +84,6 @@ H5FL_SEQ_DEFINE_STATIC(size_t); /* Declare a free list to manage the 'H5B2_node_info_t' sequence information */ H5FL_SEQ_DEFINE(H5B2_node_info_t); - - /*------------------------------------------------------------------------- * Function: H5B2__hdr_init * @@ -106,13 +97,12 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t); *------------------------------------------------------------------------- */ herr_t -H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, - uint16_t depth) +H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, uint16_t depth) { - size_t sz_max_nrec; /* Temporary variable for range checking */ - unsigned u_max_nrec_size; /* Temporary variable for range checking */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t sz_max_nrec; /* Temporary variable for range checking */ + unsigned u_max_nrec_size; /* Temporary variable for range checking */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -123,7 +113,7 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, HDassert(cparam); HDassert(cparam->cls); HDassert((cparam->cls->crt_context && cparam->cls->dst_context) || - (NULL == cparam->cls->crt_context && NULL == cparam->cls->dst_context)); + (NULL == cparam->cls->crt_context && NULL == cparam->cls->dst_context)); HDassert(cparam->node_size > 0); HDassert(cparam->rrec_size > 0); HDassert(cparam->merge_percent > 0 && cparam->merge_percent <= 100); @@ -136,40 +126,41 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, /* Assign user's information */ hdr->split_percent = cparam->split_percent; hdr->merge_percent = cparam->merge_percent; - hdr->node_size = cparam->node_size; - hdr->rrec_size = cparam->rrec_size; + hdr->node_size = cparam->node_size; + hdr->rrec_size = cparam->rrec_size; /* Assign common type information */ hdr->cls = cparam->cls; /* Allocate "page" for node I/O */ - if(NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size))) + if (NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") HDmemset(hdr->page, 0, hdr->node_size); /* Allocate array of node info structs */ - if(NULL == (hdr->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(hdr->depth + 1)))) + if (NULL == (hdr->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(hdr->depth + 1)))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize leaf node info */ sz_max_nrec = H5B2_NUM_LEAF_REC(hdr->node_size, hdr->rrec_size); H5_CHECKED_ASSIGN(hdr->node_info[0].max_nrec, unsigned, sz_max_nrec, size_t) - hdr->node_info[0].split_nrec = (hdr->node_info[0].max_nrec * hdr->split_percent) / 100; - hdr->node_info[0].merge_nrec = (hdr->node_info[0].max_nrec * hdr->merge_percent) / 100; - hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; + hdr->node_info[0].split_nrec = (hdr->node_info[0].max_nrec * hdr->split_percent) / 100; + hdr->node_info[0].merge_nrec = (hdr->node_info[0].max_nrec * hdr->merge_percent) / 100; + hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; hdr->node_info[0].cum_max_nrec_size = 0; - if(NULL == (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec))) + if (NULL == + (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") hdr->node_info[0].node_ptr_fac = NULL; /* Allocate array of pointers to internal node native keys */ /* (uses leaf # of records because its the largest) */ - if(NULL == (hdr->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)hdr->node_info[0].max_nrec))) + if (NULL == (hdr->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)hdr->node_info[0].max_nrec))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize offsets in native key block */ /* (uses leaf # of records because its the largest) */ - for(u = 0; u < hdr->node_info[0].max_nrec; u++) + for (u = 0; u < hdr->node_info[0].max_nrec; u++) hdr->nat_off[u] = hdr->cls->nrec_size * u; /* Compute size to store # of records in each node */ @@ -179,8 +170,8 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, HDassert(hdr->max_nrec_size <= H5B2_SIZEOF_RECORDS_PER_NODE); /* Initialize internal node info */ - if(depth > 0) { - for(u = 1; u < (unsigned)(depth + 1); u++) { + if (depth > 0) { + for (u = 1; u < (unsigned)(depth + 1); u++) { sz_max_nrec = H5B2_NUM_INT_REC(hdr, u); H5_CHECKED_ASSIGN(hdr->node_info[u].max_nrec, unsigned, sz_max_nrec, size_t) HDassert(hdr->node_info[u].max_nrec <= hdr->node_info[u - 1].max_nrec); @@ -188,39 +179,42 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, hdr->node_info[u].split_nrec = (hdr->node_info[u].max_nrec * hdr->split_percent) / 100; hdr->node_info[u].merge_nrec = (hdr->node_info[u].max_nrec * hdr->merge_percent) / 100; - hdr->node_info[u].cum_max_nrec = ((hdr->node_info[u].max_nrec + 1) * - hdr->node_info[u - 1].cum_max_nrec) + hdr->node_info[u].max_nrec; + hdr->node_info[u].cum_max_nrec = + ((hdr->node_info[u].max_nrec + 1) * hdr->node_info[u - 1].cum_max_nrec) + + hdr->node_info[u].max_nrec; u_max_nrec_size = H5VM_limit_enc_size((uint64_t)hdr->node_info[u].cum_max_nrec); H5_CHECKED_ASSIGN(hdr->node_info[u].cum_max_nrec_size, uint8_t, u_max_nrec_size, unsigned) - if(NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec))) + if (NULL == (hdr->node_info[u].nat_rec_fac = + H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") - if(NULL == (hdr->node_info[u].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[u].max_nrec + 1)))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") + if (NULL == (hdr->node_info[u].node_ptr_fac = + H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[u].max_nrec + 1)))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, + "can't create internal 'branch' node node pointer block factory") } /* end for */ - } /* end if */ + } /* end if */ /* Determine if we are doing SWMR writes. Only enable for data chunks for now. */ - hdr->swmr_write = (H5F_INTENT(hdr->f) & H5F_ACC_SWMR_WRITE) > 0 - && (hdr->cls->id == H5B2_CDSET_ID || hdr->cls->id == H5B2_CDSET_FILT_ID); + hdr->swmr_write = (H5F_INTENT(hdr->f) & H5F_ACC_SWMR_WRITE) > 0 && + (hdr->cls->id == H5B2_CDSET_ID || hdr->cls->id == H5B2_CDSET_FILT_ID); /* Reset the shadow epoch */ hdr->shadow_epoch = 0; /* Create the callback context, if the callback exists */ - if(hdr->cls->crt_context) - if(NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) + if (hdr->cls->crt_context) + if (NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, FAIL, "unable to create v2 B-tree client callback context") done: - if(ret_value < 0) - if(H5B2__hdr_free(hdr) < 0) + if (ret_value < 0) + if (H5B2__hdr_free(hdr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free shared v2 B-tree info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_init() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_alloc * @@ -236,8 +230,8 @@ done: H5B2_hdr_t * H5B2__hdr_alloc(H5F_t *f) { - H5B2_hdr_t *hdr = NULL; /* v2 B-tree header */ - H5B2_hdr_t *ret_value = NULL; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* v2 B-tree header */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -247,15 +241,15 @@ H5B2__hdr_alloc(H5F_t *f) HDassert(f); /* Allocate space for the shared information */ - if(NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t))) + if (NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree header") /* Assign non-zero information */ - hdr->f = f; + hdr->f = f; hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); hdr->sizeof_size = H5F_SIZEOF_SIZE(f); - hdr->hdr_size = H5B2_HEADER_SIZE_HDR(hdr); - hdr->root.addr = HADDR_UNDEF; + hdr->hdr_size = H5B2_HEADER_SIZE_HDR(hdr); + hdr->root.addr = HADDR_UNDEF; /* Set return value */ ret_value = hdr; @@ -265,7 +259,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_alloc() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_create * @@ -281,9 +274,9 @@ done: haddr_t H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) { - H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_PACKAGE @@ -294,56 +287,58 @@ H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) HDassert(cparam); /* Allocate v2 B-tree header */ - if(NULL == (hdr = H5B2__hdr_alloc(f))) + if (NULL == (hdr = H5B2__hdr_alloc(f))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header") /* Initialize shared B-tree info */ - if(H5B2__hdr_init(hdr, cparam, ctx_udata, (uint16_t)0) < 0) + if (H5B2__hdr_init(hdr, cparam, ctx_udata, (uint16_t)0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info") /* Allocate space for the header on disk */ - if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)hdr->hdr_size))) + if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)hdr->hdr_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for B-tree header") /* Create 'top' proxy for extensible array entries */ - if(hdr->swmr_write) - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (hdr->swmr_write) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, HADDR_UNDEF, "can't create v2 B-tree proxy") /* Cache the new B-tree node */ - if(H5AC_insert_entry(f, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, HADDR_UNDEF, "can't add B-tree header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ - if(hdr->top_proxy) - if(H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, HADDR_UNDEF, "unable to add v2 B-tree header as child of array proxy") + if (hdr->top_proxy) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, HADDR_UNDEF, + "unable to add v2 B-tree header as child of array proxy") /* Set address of v2 B-tree header to return */ ret_value = hdr->addr; done: - if(!H5F_addr_defined(ret_value)) - if(hdr) { + if (!H5F_addr_defined(ret_value)) + if (hdr) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(hdr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, HADDR_UNDEF, "unable to remove v2 B-tree header from cache") + if (inserted) + if (H5AC_remove_entry(hdr) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove v2 B-tree header from cache") /* Release header's disk space */ - if(H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_BTREE, hdr->addr, (hsize_t)hdr->hdr_size) < 0) + if (H5F_addr_defined(hdr->addr) && + H5MF_xfree(f, H5FD_MEM_BTREE, hdr->addr, (hsize_t)hdr->hdr_size) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free v2 B-tree header") /* Destroy header */ - if(H5B2__hdr_free(hdr) < 0) + if (H5B2__hdr_free(hdr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release v2 B-tree header") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_create() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_incr * @@ -359,7 +354,7 @@ done: herr_t H5B2__hdr_incr(H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -367,8 +362,8 @@ H5B2__hdr_incr(H5B2_hdr_t *hdr) HDassert(hdr); /* Mark header as un-evictable when a B-tree node is depending on it */ - if(hdr->rc == 0) - if(H5AC_pin_protected_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_pin_protected_entry(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTPIN, FAIL, "unable to pin v2 B-tree header") /* Increment reference count on B-tree header */ @@ -378,7 +373,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_incr() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_decr * @@ -394,7 +388,7 @@ done: herr_t H5B2__hdr_decr(H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -406,15 +400,14 @@ H5B2__hdr_decr(H5B2_hdr_t *hdr) hdr->rc--; /* Mark header as evictable again when no nodes depend on it */ - if(hdr->rc == 0) - if(H5AC_unpin_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_unpin_entry(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin v2 B-tree header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_decr() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_fuse_incr * @@ -441,7 +434,6 @@ H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__hdr_fuse_incr() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_fuse_decr * @@ -469,7 +461,6 @@ H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr) FUNC_LEAVE_NOAPI(hdr->file_rc) } /* end H5B2__hdr_fuse_decr() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_dirty * @@ -485,7 +476,7 @@ H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr) herr_t H5B2__hdr_dirty(H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -493,14 +484,13 @@ H5B2__hdr_dirty(H5B2_hdr_t *hdr) HDassert(hdr); /* Mark B-tree header as dirty in cache */ - if(H5AC_mark_entry_dirty(hdr) < 0) + if (H5AC_mark_entry_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark v2 B-tree header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_dirty() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_protect * @@ -516,9 +506,9 @@ done: H5B2_hdr_t * H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags) { - H5B2_hdr_cache_ud_t udata; /* User data for cache callbacks */ - H5B2_hdr_t *hdr = NULL; /* v2 B-tree header */ - H5B2_hdr_t *ret_value = NULL; /* Return value */ + H5B2_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5B2_hdr_t * hdr = NULL; /* v2 B-tree header */ + H5B2_hdr_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -530,23 +520,24 @@ H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for cache callbacks */ - udata.f = f; - udata.addr = hdr_addr; + udata.f = f; + udata.addr = hdr_addr; udata.ctx_udata = ctx_udata; /* Protect the header */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, H5AC_BT2_HDR, hdr_addr, &udata, flags))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) - hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + if (NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, H5AC_BT2_HDR, hdr_addr, &udata, flags))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load v2 B-tree header, address = %llu", + (unsigned long long)hdr_addr) + hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ - if(hdr->swmr_write && NULL == hdr->top_proxy) { + if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for v2 B-tree entries */ - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, NULL, "can't create v2 B-tree proxy") /* Add header as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, NULL, "unable to add v2 B-tree header as child of proxy") } /* end if */ @@ -555,16 +546,16 @@ H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags) done: /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the header, if it was protected */ - if(hdr && H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) + if (hdr && H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, + "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_protect() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_unprotect * @@ -581,7 +572,7 @@ done: herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -589,14 +580,14 @@ H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags) HDassert(hdr); /* Unprotect the header */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr->addr) + if (H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr->addr) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_free * @@ -613,7 +604,7 @@ done: herr_t H5B2__hdr_free(H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -621,32 +612,34 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) HDassert(hdr); /* Destroy the callback context */ - if(hdr->cb_ctx) { - if((*hdr->cls->dst_context)(hdr->cb_ctx) < 0) + if (hdr->cb_ctx) { + if ((*hdr->cls->dst_context)(hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy v2 B-tree client callback context") hdr->cb_ctx = NULL; } /* end if */ /* Free the B-tree node buffer */ - if(hdr->page) + if (hdr->page) hdr->page = H5FL_BLK_FREE(node_page, hdr->page); /* Free the array of offsets into the native key block */ - if(hdr->nat_off) + if (hdr->nat_off) hdr->nat_off = H5FL_SEQ_FREE(size_t, hdr->nat_off); /* Release the node info */ - if(hdr->node_info) { - unsigned u; /* Local index variable */ + if (hdr->node_info) { + unsigned u; /* Local index variable */ /* Destroy free list factories */ - for(u = 0; u < (unsigned)(hdr->depth + 1); u++) { - if(hdr->node_info[u].nat_rec_fac) - if(H5FL_fac_term(hdr->node_info[u].nat_rec_fac) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory") - if(hdr->node_info[u].node_ptr_fac) - if(H5FL_fac_term(hdr->node_info[u].node_ptr_fac) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory") + for (u = 0; u < (unsigned)(hdr->depth + 1); u++) { + if (hdr->node_info[u].nat_rec_fac) + if (H5FL_fac_term(hdr->node_info[u].nat_rec_fac) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, + "can't destroy node's native record block factory") + if (hdr->node_info[u].node_ptr_fac) + if (H5FL_fac_term(hdr->node_info[u].node_ptr_fac) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, + "can't destroy node's node pointer block factory") } /* end for */ /* Free the array of node info structs */ @@ -654,14 +647,14 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) } /* end if */ /* Release the min & max record info, if set */ - if(hdr->min_native_rec) - hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); - if(hdr->max_native_rec) - hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); + if (hdr->min_native_rec) + hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); + if (hdr->max_native_rec) + hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); /* Destroy the 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_dest(hdr->top_proxy) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to destroy v2 B-tree 'top' proxy") hdr->top_proxy = NULL; } /* end if */ @@ -673,7 +666,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_free() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_delete * @@ -690,8 +682,8 @@ done: herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr) { - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting v2 B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting v2 B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -699,22 +691,23 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr) HDassert(hdr); #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* v2 B-tree header's status in the metadata cache */ - - /* Check the v2 B-tree header's status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to check metadata cache status for v2 B-tree header") - - /* Sanity checks on v2 B-tree header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); -} /* end block */ + { + unsigned hdr_status = 0; /* v2 B-tree header's status in the metadata cache */ + + /* Check the v2 B-tree header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, + "unable to check metadata cache status for v2 B-tree header") + + /* Sanity checks on v2 B-tree header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); + } /* end block */ #endif /* NDEBUG */ /* Delete all nodes in B-tree */ - if(H5F_addr_defined(hdr->root.addr)) - if(H5B2__delete_node(hdr, hdr->depth, &hdr->root, hdr, hdr->remove_op, hdr->remove_op_data) < 0) + if (H5F_addr_defined(hdr->root.addr)) + if (H5B2__delete_node(hdr, hdr->depth, &hdr->root, hdr, hdr->remove_op, hdr->remove_op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete B-tree nodes") /* Indicate that the heap header should be deleted & file space freed */ @@ -722,9 +715,8 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr) done: /* Unprotect the header with appropriate flags */ - if(H5B2__hdr_unprotect(hdr, cache_flags) < 0) + if (H5B2__hdr_unprotect(hdr, cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_delete() */ - diff --git a/src/H5B2int.c b/src/H5B2int.c index 53ac835..311d324 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -26,52 +26,44 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, - unsigned depth, const H5B2_node_ptr_t *node_ptrs, unsigned start_idx, - unsigned end_idx, void *old_parent, void *new_parent); - +static herr_t H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, + const H5B2_node_ptr_t *node_ptrs, unsigned start_idx, + unsigned end_idx, void *old_parent, void *new_parent); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -79,8 +71,6 @@ static herr_t H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, /* Declare a free list to manage the 'H5B2_node_info_t' sequence information */ H5FL_SEQ_EXTERN(H5B2_node_info_t); - - /*------------------------------------------------------------------------- * Function: H5B2__locate_record * @@ -103,23 +93,23 @@ H5FL_SEQ_EXTERN(H5B2_node_info_t); *------------------------------------------------------------------------- */ herr_t -H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, - const uint8_t *native, const void *udata, unsigned *idx, int *cmp) +H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, const uint8_t *native, + const void *udata, unsigned *idx, int *cmp) { - unsigned lo = 0, hi; /* Low & high index values */ - unsigned my_idx = 0; /* Final index value */ - herr_t ret_value = SUCCEED; + unsigned lo = 0, hi; /* Low & high index values */ + unsigned my_idx = 0; /* Final index value */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE *cmp = -1; hi = nrec; - while(lo < hi && *cmp) { + while (lo < hi && *cmp) { my_idx = (lo + hi) / 2; - if((type->compare)(udata, native + rec_off[my_idx], cmp) < 0) + if ((type->compare)(udata, native + rec_off[my_idx], cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(*cmp < 0) + if (*cmp < 0) hi = my_idx; else lo = my_idx + 1; @@ -131,7 +121,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__locate_record */ - /*------------------------------------------------------------------------- * Function: H5B2__split1 * @@ -148,19 +137,21 @@ done: */ herr_t H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx) + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ - void *left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ - uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */ - uint8_t *left_native, *right_native;/* Pointers to childs' native records */ - H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL;/* Pointers to childs' node pointer info */ - uint16_t mid_record; /* Index of "middle" record in current node */ - uint16_t old_node_nrec; /* Number of records in internal node split */ - unsigned left_child_flags = H5AC__NO_FLAGS_SET, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5AC_class_t *child_class; /* Pointer to child node's class info */ + haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ + void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ + uint16_t * left_nrec, *right_nrec; /* Pointers to child # of records */ + uint8_t * left_native, *right_native; /* Pointers to childs' native records */ + H5B2_node_ptr_t * left_node_ptrs = NULL, + *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ + uint16_t mid_record; /* Index of "middle" record in current node */ + uint16_t old_node_nrec; /* Number of records in internal node split */ + unsigned left_child_flags = H5AC__NO_FLAGS_SET, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -170,68 +161,75 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, HDassert(internal_flags_ptr); /* Slide records in parent node up one space, to make room for promoted record */ - if(idx < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx + 1), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size * (internal->nrec - idx)); - HDmemmove(&(internal->node_ptrs[idx + 2]), &(internal->node_ptrs[idx + 1]), sizeof(H5B2_node_ptr_t) * (internal->nrec - idx)); + if (idx < internal->nrec) { + HDmemmove(H5B2_INT_NREC(internal, hdr, idx + 1), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size * (internal->nrec - idx)); + HDmemmove(&(internal->node_ptrs[idx + 2]), &(internal->node_ptrs[idx + 1]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - idx)); } /* end if */ /* Check for the kind of B-tree node to split */ - if(depth > 1) { - H5B2_internal_t *left_int = NULL, *right_int = NULL; /* Pointers to old & new internal nodes */ + if (depth > 1) { + H5B2_internal_t *left_int = NULL, *right_int = NULL; /* Pointers to old & new internal nodes */ /* Create new internal node */ internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec = 0; - if(H5B2__create_internal(hdr, internal, &(internal->node_ptrs[idx + 1]), (uint16_t)(depth - 1)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node") + if (H5B2__create_internal(hdr, internal, &(internal->node_ptrs[idx + 1]), (uint16_t)(depth - 1)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node") /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Protect both leaves */ /* (Shadow left node if doing SWMR writes) */ - if(NULL == (left_int = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == + (left_int = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_int = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (right_int = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_int; - right_child = right_int; - left_nrec = &(left_int->nrec); - right_nrec = &(right_int->nrec); - left_native = left_int->int_native; - right_native = right_int->int_native; - left_node_ptrs = left_int->node_ptrs; + left_child = left_int; + right_child = right_int; + left_nrec = &(left_int->nrec); + right_nrec = &(right_int->nrec); + left_native = left_int->int_native; + right_native = right_int->int_native; + left_node_ptrs = left_int->node_ptrs; right_node_ptrs = right_int->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf = NULL, *right_leaf = NULL; /* Pointers to old & new leaf nodes */ + H5B2_leaf_t *left_leaf = NULL, *right_leaf = NULL; /* Pointers to old & new leaf nodes */ /* Create new leaf node */ internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec = 0; - if(H5B2__create_leaf(hdr, internal, &(internal->node_ptrs[idx + 1])) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new leaf node") + if (H5B2__create_leaf(hdr, internal, &(internal->node_ptrs[idx + 1])) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new leaf node") /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Protect both leaves */ /* (Shadow the left node if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; right_native = right_leaf->leaf_native; } /* end if */ @@ -243,16 +241,17 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Copy "upper half" of records to new child */ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), - H5B2_NAT_NREC(left_native, hdr, mid_record + (unsigned)1), - hdr->cls->nrec_size * (old_node_nrec - (mid_record + (unsigned)1))); + H5B2_NAT_NREC(left_native, hdr, mid_record + (unsigned)1), + hdr->cls->nrec_size * (old_node_nrec - (mid_record + (unsigned)1))); /* Copy "upper half" of node pointers, if the node is an internal node */ - if(depth > 1) + if (depth > 1) H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[mid_record + (unsigned)1]), - sizeof(H5B2_node_ptr_t) * (size_t)(old_node_nrec - mid_record)); + sizeof(H5B2_node_ptr_t) * (size_t)(old_node_nrec - mid_record)); /* Copy "middle" record to internal node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, mid_record), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, mid_record), + hdr->cls->nrec_size); /* Mark nodes as dirty */ left_child_flags |= H5AC__DIRTIED_FLAG; @@ -263,25 +262,25 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, internal->node_ptrs[idx + 1].node_nrec = *right_nrec = (uint16_t)(old_node_nrec - (mid_record + 1)); /* Determine total number of records in new child nodes */ - if(depth > 1) { - unsigned u; /* Local index variable */ - hsize_t new_left_all_nrec; /* New total number of records in left child */ - hsize_t new_right_all_nrec; /* New total number of records in right child */ + if (depth > 1) { + unsigned u; /* Local index variable */ + hsize_t new_left_all_nrec; /* New total number of records in left child */ + hsize_t new_right_all_nrec; /* New total number of records in right child */ /* Compute total of all records in each child node */ new_left_all_nrec = internal->node_ptrs[idx].node_nrec; - for(u = 0; u < (*left_nrec + (unsigned)1); u++) + for (u = 0; u < (*left_nrec + (unsigned)1); u++) new_left_all_nrec += left_node_ptrs[u].all_nrec; new_right_all_nrec = internal->node_ptrs[idx + 1].node_nrec; - for(u = 0; u < (*right_nrec + (unsigned)1); u++) + for (u = 0; u < (*right_nrec + (unsigned)1); u++) new_right_all_nrec += right_node_ptrs[u].all_nrec; - internal->node_ptrs[idx].all_nrec = new_left_all_nrec; + internal->node_ptrs[idx].all_nrec = new_left_all_nrec; internal->node_ptrs[idx + 1].all_nrec = new_right_all_nrec; } /* end if */ else { - internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; + internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec; } /* end else */ @@ -295,38 +294,39 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, curr_node_ptr->node_nrec++; /* Mark grandparent as dirty, if given */ - if(parent_cache_info_flags_ptr) + if (parent_cache_info_flags_ptr) *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG; /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, - 0, (unsigned)(*right_nrec + 1), left_child, right_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, 0, (unsigned)(*right_nrec + 1), + left_child, right_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)right_child); - H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, (H5B2_internal_t *)left_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)right_child); + H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, + (H5B2_internal_t *)left_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)right_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)right_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ done: /* Release child nodes (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__split1() */ - /*------------------------------------------------------------------------- * Function: H5B2__split_root * @@ -344,12 +344,12 @@ done: herr_t H5B2__split_root(H5B2_hdr_t *hdr) { - H5B2_internal_t *new_root = NULL; /* Pointer to new root node */ - unsigned new_root_flags = H5AC__NO_FLAGS_SET; /* Cache flags for new root node */ - H5B2_node_ptr_t old_root_ptr; /* Old node pointer to root node in B-tree */ - size_t sz_max_nrec; /* Temporary variable for range checking */ - unsigned u_max_nrec_size; /* Temporary variable for range checking */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *new_root = NULL; /* Pointer to new root node */ + unsigned new_root_flags = H5AC__NO_FLAGS_SET; /* Cache flags for new root node */ + H5B2_node_ptr_t old_root_ptr; /* Old node pointer to root node in B-tree */ + size_t sz_max_nrec; /* Temporary variable for range checking */ + unsigned u_max_nrec_size; /* Temporary variable for range checking */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -360,7 +360,8 @@ H5B2__split_root(H5B2_hdr_t *hdr) hdr->depth++; /* Re-allocate array of node info structs */ - if(NULL == (hdr->node_info = H5FL_SEQ_REALLOC(H5B2_node_info_t, hdr->node_info, (size_t)(hdr->depth + 1)))) + if (NULL == + (hdr->node_info = H5FL_SEQ_REALLOC(H5B2_node_info_t, hdr->node_info, (size_t)(hdr->depth + 1)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Update node info for new depth of tree */ @@ -368,43 +369,47 @@ H5B2__split_root(H5B2_hdr_t *hdr) H5_CHECKED_ASSIGN(hdr->node_info[hdr->depth].max_nrec, unsigned, sz_max_nrec, size_t) hdr->node_info[hdr->depth].split_nrec = (hdr->node_info[hdr->depth].max_nrec * hdr->split_percent) / 100; hdr->node_info[hdr->depth].merge_nrec = (hdr->node_info[hdr->depth].max_nrec * hdr->merge_percent) / 100; - hdr->node_info[hdr->depth].cum_max_nrec = ((hdr->node_info[hdr->depth].max_nrec + 1) * - hdr->node_info[hdr->depth - 1].cum_max_nrec) + hdr->node_info[hdr->depth].max_nrec; + hdr->node_info[hdr->depth].cum_max_nrec = + ((hdr->node_info[hdr->depth].max_nrec + 1) * hdr->node_info[hdr->depth - 1].cum_max_nrec) + + hdr->node_info[hdr->depth].max_nrec; u_max_nrec_size = H5VM_limit_enc_size((uint64_t)hdr->node_info[hdr->depth].cum_max_nrec); H5_CHECKED_ASSIGN(hdr->node_info[hdr->depth].cum_max_nrec_size, uint8_t, u_max_nrec_size, unsigned) - if(NULL == (hdr->node_info[hdr->depth].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[hdr->depth].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") - if(NULL == (hdr->node_info[hdr->depth].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[hdr->depth].max_nrec + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") + if (NULL == (hdr->node_info[hdr->depth].nat_rec_fac = + H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[hdr->depth].max_nrec))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + if (NULL == (hdr->node_info[hdr->depth].node_ptr_fac = + H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[hdr->depth].max_nrec + 1)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, + "can't create internal 'branch' node node pointer block factory") /* Keep old root node pointer info */ old_root_ptr = hdr->root; /* Create new internal node to use as root */ hdr->root.node_nrec = 0; - if(H5B2__create_internal(hdr, hdr, &(hdr->root), hdr->depth) < 0) + if (H5B2__create_internal(hdr, hdr, &(hdr->root), hdr->depth) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node") /* Protect new root node */ - if(NULL == (new_root = H5B2__protect_internal(hdr, hdr, &hdr->root, hdr->depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (new_root = H5B2__protect_internal(hdr, hdr, &hdr->root, hdr->depth, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set first node pointer in root node to old root node pointer info */ new_root->node_ptrs[0] = old_root_ptr; /* Split original root node */ - if(H5B2__split1(hdr, hdr->depth, &(hdr->root), NULL, new_root, &new_root_flags, 0) < 0) + if (H5B2__split1(hdr, hdr->depth, &(hdr->root), NULL, new_root, &new_root_flags, 0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split old root node") done: /* Release new root node (marked as dirty) */ - if(new_root && H5AC_unprotect(hdr->f, H5AC_BT2_INT, hdr->root.addr, new_root, new_root_flags) < 0) + if (new_root && H5AC_unprotect(hdr->f, H5AC_BT2_INT, hdr->root.addr, new_root, new_root_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__split_root() */ - /*------------------------------------------------------------------------- * Function: H5B2__redistribute2 * @@ -420,18 +425,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, - unsigned idx) +H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned idx) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ - void *left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ - uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */ - uint8_t *left_native, *right_native; /* Pointers to childs' native records */ - H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL;/* Pointers to childs' node pointer info */ + const H5AC_class_t *child_class; /* Pointer to child node's class info */ + haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ + void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ + uint16_t * left_nrec, *right_nrec; /* Pointers to child # of records */ + uint8_t * left_native, *right_native; /* Pointers to childs' native records */ + H5B2_node_ptr_t * left_node_ptrs = NULL, + *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ hssize_t left_moved_nrec = 0, right_moved_nrec = 0; /* Number of records moved, for internal redistrib */ - unsigned left_child_flags = H5AC__NO_FLAGS_SET, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned left_child_flags = H5AC__NO_FLAGS_SET, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -440,115 +446,132 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, HDassert(internal); /* Check for the kind of B-tree node to redistribute */ - if(depth > 1) { - H5B2_internal_t *left_internal; /* Pointer to left internal node */ - H5B2_internal_t *right_internal; /* Pointer to right internal node */ + if (depth > 1) { + H5B2_internal_t *left_internal; /* Pointer to left internal node */ + H5B2_internal_t *right_internal; /* Pointer to right internal node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Lock left & right B-tree child nodes */ /* (Shadow both nodes if doing SWMR writes) */ - if(NULL == (left_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (right_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_internal; - right_child = right_internal; - left_nrec = &(left_internal->nrec); - right_nrec = &(right_internal->nrec); - left_native = left_internal->int_native; - right_native = right_internal->int_native; - left_node_ptrs = left_internal->node_ptrs; + left_child = left_internal; + right_child = right_internal; + left_nrec = &(left_internal->nrec); + right_nrec = &(right_internal->nrec); + left_native = left_internal->int_native; + right_native = right_internal->int_native; + left_node_ptrs = left_internal->node_ptrs; right_node_ptrs = right_internal->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ - H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ + H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ + H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock left & right B-tree child nodes */ /* (Shadow both nodes if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; right_native = right_leaf->leaf_native; } /* end else */ #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)right_child); - H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, (H5B2_internal_t *)left_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)right_child); + H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, + (H5B2_internal_t *)left_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)right_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)right_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ /* Determine whether to shuffle records left or right */ - if(*left_nrec < *right_nrec) { + if (*left_nrec < *right_nrec) { /* Moving record from right node to left */ - uint16_t new_right_nrec = (uint16_t)((*left_nrec + *right_nrec) / 2); /* New number of records for right child */ - uint16_t move_nrec = (uint16_t)(*right_nrec - new_right_nrec); /* Number of records to move from right node to left */ + uint16_t new_right_nrec = + (uint16_t)((*left_nrec + *right_nrec) / 2); /* New number of records for right child */ + uint16_t move_nrec = + (uint16_t)(*right_nrec - new_right_nrec); /* Number of records to move from right node to left */ /* Copy record from parent node down into left child */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size); /* See if we need to move records from right node */ - if(move_nrec > 1) - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, (*left_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (size_t)(move_nrec - 1)); + if (move_nrec > 1) + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, (*left_nrec + 1)), + H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (size_t)(move_nrec - 1)); /* Move record from right node into parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), + hdr->cls->nrec_size); /* Slide records in right node down */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, move_nrec), hdr->cls->nrec_size * new_right_nrec); + HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, move_nrec), + hdr->cls->nrec_size * new_right_nrec); /* Handle node pointers, if we have an internal node */ - if(depth > 1) { - hsize_t moved_nrec = move_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec = move_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Count the number of records being moved */ - for(u = 0; u < move_nrec; u++) + for (u = 0; u < move_nrec; u++) moved_nrec += right_node_ptrs[u].all_nrec; H5_CHECKED_ASSIGN(left_moved_nrec, hssize_t, moved_nrec, hsize_t) right_moved_nrec -= (hssize_t)moved_nrec; /* Copy node pointers from right node to left */ - H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * move_nrec); + H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * move_nrec); /* Slide node pointers in right node down */ - HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[move_nrec]), sizeof(H5B2_node_ptr_t) * (new_right_nrec + (unsigned)1)); + HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[move_nrec]), + sizeof(H5B2_node_ptr_t) * (new_right_nrec + (unsigned)1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, - (unsigned)(*left_nrec + 1), (unsigned)(*left_nrec + move_nrec + 1), right_child, left_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, (unsigned)(*left_nrec + 1), + (unsigned)(*left_nrec + move_nrec + 1), right_child, + left_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update number of records in child nodes */ - *left_nrec = (uint16_t)(*left_nrec + move_nrec); + *left_nrec = (uint16_t)(*left_nrec + move_nrec); *right_nrec = new_right_nrec; /* Mark nodes as dirty */ @@ -558,53 +581,60 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, else { /* Moving record from left node to right */ - uint16_t new_left_nrec = (uint16_t)((*left_nrec + *right_nrec) / 2); /* New number of records for left child */ - uint16_t move_nrec = (uint16_t)(*left_nrec - new_left_nrec); /* Number of records to move from left node to right */ + uint16_t new_left_nrec = + (uint16_t)((*left_nrec + *right_nrec) / 2); /* New number of records for left child */ + uint16_t move_nrec = + (uint16_t)(*left_nrec - new_left_nrec); /* Number of records to move from left node to right */ /* Sanity check */ HDassert(*left_nrec > *right_nrec); /* Slide records in right node up */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, move_nrec), - H5B2_NAT_NREC(right_native, hdr, 0), - hdr->cls->nrec_size * (*right_nrec)); + HDmemmove(H5B2_NAT_NREC(right_native, hdr, move_nrec), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Copy record from parent node down into right child */ - H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size); /* See if we need to move records from left node */ - if(move_nrec > 1) - H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, ((*left_nrec - move_nrec) + 1)), hdr->cls->nrec_size * (size_t)(move_nrec - 1)); + if (move_nrec > 1) + H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), + H5B2_NAT_NREC(left_native, hdr, ((*left_nrec - move_nrec) + 1)), + hdr->cls->nrec_size * (size_t)(move_nrec - 1)); /* Move record from left node into parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, (*left_nrec - move_nrec)), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), + H5B2_NAT_NREC(left_native, hdr, (*left_nrec - move_nrec)), hdr->cls->nrec_size); /* Handle node pointers, if we have an internal node */ - if(depth > 1) { - hsize_t moved_nrec = move_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec = move_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Slide node pointers in right node up */ - HDmemmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + HDmemmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Copy node pointers from left node to right */ - H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * move_nrec); + H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), + sizeof(H5B2_node_ptr_t) * move_nrec); /* Count the number of records being moved */ - for(u = 0; u < move_nrec; u++) + for (u = 0; u < move_nrec; u++) moved_nrec += right_node_ptrs[u].all_nrec; left_moved_nrec -= (hssize_t)moved_nrec; H5_CHECKED_ASSIGN(right_moved_nrec, hssize_t, moved_nrec, hsize_t) } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, - 0, (unsigned)move_nrec, left_child, right_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, 0, (unsigned)move_nrec, + left_child, right_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update number of records in child nodes */ - *left_nrec = new_left_nrec; + *left_nrec = new_left_nrec; *right_nrec = (uint16_t)(*right_nrec + move_nrec); /* Mark nodes as dirty */ @@ -613,42 +643,45 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end else */ /* Update # of records in child nodes */ - internal->node_ptrs[idx].node_nrec = *left_nrec; + internal->node_ptrs[idx].node_nrec = *left_nrec; internal->node_ptrs[idx + 1].node_nrec = *right_nrec; /* Update total # of records in child B-trees */ - if(depth > 1) { - internal->node_ptrs[idx].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + left_moved_nrec); - internal->node_ptrs[idx + 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); + if (depth > 1) { + internal->node_ptrs[idx].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + left_moved_nrec); + internal->node_ptrs[idx + 1].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); } /* end if */ else { - internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; + internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec; } /* end else */ #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)right_child); - H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, (H5B2_internal_t *)left_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)right_child); + H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, + (H5B2_internal_t *)left_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)right_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)right_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ done: /* Release child nodes (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__redistribute2() */ - /*------------------------------------------------------------------------- * Function: H5B2__redistribute3 * @@ -664,25 +697,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx) +H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx) { - H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ - H5B2_node_ptr_t *middle_node_ptrs = NULL; /* Pointers to childs' node pointer info */ - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ - haddr_t middle_addr; /* Address of middle child node */ - void *left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ - void *middle_child = NULL; /* Pointers to middle child node */ - uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */ - uint16_t *middle_nrec; /* Pointers to middle child # of records */ - uint8_t *left_native, *right_native; /* Pointers to childs' native records */ - uint8_t *middle_native; /* Pointers to middle child's native records */ + H5B2_node_ptr_t *left_node_ptrs = NULL, + *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ + H5B2_node_ptr_t * middle_node_ptrs = NULL; /* Pointers to childs' node pointer info */ + const H5AC_class_t *child_class; /* Pointer to child node's class info */ + haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ + haddr_t middle_addr; /* Address of middle child node */ + void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ + void * middle_child = NULL; /* Pointers to middle child node */ + uint16_t * left_nrec, *right_nrec; /* Pointers to child # of records */ + uint16_t * middle_nrec; /* Pointers to middle child # of records */ + uint8_t * left_native, *right_native; /* Pointers to childs' native records */ + uint8_t * middle_native; /* Pointers to middle child's native records */ hssize_t left_moved_nrec = 0, right_moved_nrec = 0; /* Number of records moved, for internal split */ - hssize_t middle_moved_nrec = 0; /* Number of records moved, for internal split */ - unsigned left_child_flags = H5AC__NO_FLAGS_SET, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + hssize_t middle_moved_nrec = 0; /* Number of records moved, for internal split */ + unsigned left_child_flags = H5AC__NO_FLAGS_SET, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -692,79 +727,88 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, HDassert(internal_flags_ptr); /* Check for the kind of B-tree node to redistribute */ - if(depth > 1) { - H5B2_internal_t *left_internal; /* Pointer to left internal node */ - H5B2_internal_t *middle_internal; /* Pointer to middle internal node */ - H5B2_internal_t *right_internal; /* Pointer to right internal node */ + if (depth > 1) { + H5B2_internal_t *left_internal; /* Pointer to left internal node */ + H5B2_internal_t *middle_internal; /* Pointer to middle internal node */ + H5B2_internal_t *right_internal; /* Pointer to right internal node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Lock B-tree child nodes */ /* (Shadow all nodes if doing SWMR writes) */ - if(NULL == (left_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx - 1], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx - 1], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") left_addr = internal->node_ptrs[idx - 1].addr; - if(NULL == (middle_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (middle_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") middle_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (right_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_internal; - middle_child = middle_internal; - right_child = right_internal; - left_nrec = &(left_internal->nrec); - middle_nrec = &(middle_internal->nrec); - right_nrec = &(right_internal->nrec); - left_native = left_internal->int_native; - middle_native = middle_internal->int_native; - right_native = right_internal->int_native; - left_node_ptrs = left_internal->node_ptrs; + left_child = left_internal; + middle_child = middle_internal; + right_child = right_internal; + left_nrec = &(left_internal->nrec); + middle_nrec = &(middle_internal->nrec); + right_nrec = &(right_internal->nrec); + left_native = left_internal->int_native; + middle_native = middle_internal->int_native; + right_native = right_internal->int_native; + left_node_ptrs = left_internal->node_ptrs; middle_node_ptrs = middle_internal->node_ptrs; - right_node_ptrs = right_internal->node_ptrs; + right_node_ptrs = right_internal->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ - H5B2_leaf_t *middle_leaf; /* Pointer to middle leaf node */ - H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ + H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ + H5B2_leaf_t *middle_leaf; /* Pointer to middle leaf node */ + H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock B-tree child nodes */ /* (Shadow all nodes if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx - 1], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx - 1], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx - 1].addr; - if(NULL == (middle_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (middle_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") middle_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_leaf; - middle_child = middle_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - middle_nrec = &(middle_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + middle_child = middle_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + middle_nrec = &(middle_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; middle_native = middle_leaf->leaf_native; - right_native = right_leaf->leaf_native; + right_native = right_leaf->leaf_native; } /* end else */ /* Redistribute records */ { /* Compute new # of records in each node */ - unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); + unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); uint16_t new_middle_nrec = (uint16_t)((total_nrec - 2) / 3); - uint16_t new_left_nrec = (uint16_t)(((total_nrec - 2) - new_middle_nrec) / 2); - uint16_t new_right_nrec = (uint16_t)((total_nrec - 2) - (unsigned)(new_left_nrec + new_middle_nrec)); + uint16_t new_left_nrec = (uint16_t)(((total_nrec - 2) - new_middle_nrec) / 2); + uint16_t new_right_nrec = (uint16_t)((total_nrec - 2) - (unsigned)(new_left_nrec + new_middle_nrec)); uint16_t curr_middle_nrec = *middle_nrec; /* Sanity check rounding */ @@ -772,49 +816,57 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, HDassert(new_middle_nrec <= new_right_nrec); /* Move records into left node */ - if(new_left_nrec > *left_nrec) { - uint16_t moved_middle_nrec = 0; /* Number of records moved into left node */ + if (new_left_nrec > *left_nrec) { + uint16_t moved_middle_nrec = 0; /* Number of records moved into left node */ /* Move left parent record down to left node */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), + hdr->cls->nrec_size); /* Move records from middle node into left node */ - if((new_left_nrec - 1) > *left_nrec) { + if ((new_left_nrec - 1) > *left_nrec) { moved_middle_nrec = (uint16_t)(new_left_nrec - (*left_nrec + 1)); - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * moved_middle_nrec); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), + H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * moved_middle_nrec); } /* end if */ /* Move record from middle node up to parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), + H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size); moved_middle_nrec++; /* Slide records in middle node down */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size * (size_t)(*middle_nrec - moved_middle_nrec)); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), + H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), + hdr->cls->nrec_size * (size_t)(*middle_nrec - moved_middle_nrec)); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ - unsigned move_nptrs; /* Number of node pointers to move */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ + unsigned move_nptrs; /* Number of node pointers to move */ + unsigned u; /* Local index variable */ /* Move middle node pointers into left node */ move_nptrs = (unsigned)(new_left_nrec - *left_nrec); - H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t)*move_nptrs); + H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * move_nptrs); /* Count the number of records being moved into the left node */ - for(u = 0, moved_nrec = 0; u < move_nptrs; u++) + for (u = 0, moved_nrec = 0; u < move_nptrs; u++) moved_nrec += middle_node_ptrs[u].all_nrec; left_moved_nrec = (hssize_t)(moved_nrec + move_nptrs); middle_moved_nrec -= (hssize_t)(moved_nrec + move_nptrs); /* Slide the node pointers in middle node down */ - HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[move_nptrs]), sizeof(H5B2_node_ptr_t) * ((*middle_nrec - move_nptrs) + 1)); + HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[move_nptrs]), + sizeof(H5B2_node_ptr_t) * ((*middle_nrec - move_nptrs) + 1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, - (unsigned)(*left_nrec + 1), (unsigned)(*left_nrec + moved_middle_nrec + 1), middle_child, left_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, (unsigned)(*left_nrec + 1), + (unsigned)(*left_nrec + moved_middle_nrec + 1), + middle_child, left_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update the current number of records in middle node */ @@ -826,44 +878,55 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end if */ /* Move records into right node */ - if(new_right_nrec > *right_nrec) { - unsigned right_nrec_move = (unsigned)(new_right_nrec - *right_nrec); /* Number of records to move out of right node */ + if (new_right_nrec > *right_nrec) { + unsigned right_nrec_move = + (unsigned)(new_right_nrec - *right_nrec); /* Number of records to move out of right node */ /* Slide records in right node up */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, right_nrec_move), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec)); + HDmemmove(H5B2_NAT_NREC(right_native, hdr, right_nrec_move), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Move right parent record down to right node */ - H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), + H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); /* Move records from middle node into right node */ - if(right_nrec_move > 1) - H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, ((curr_middle_nrec - right_nrec_move) + 1)), hdr->cls->nrec_size * (right_nrec_move - 1)); + if (right_nrec_move > 1) + H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), + H5B2_NAT_NREC(middle_native, hdr, ((curr_middle_nrec - right_nrec_move) + 1)), + hdr->cls->nrec_size * (right_nrec_move - 1)); /* Move record from middle node up to parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec - right_nrec_move)), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), + H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec - right_nrec_move)), + hdr->cls->nrec_size); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Slide the node pointers in right node up */ - HDmemmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + HDmemmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Move middle node pointers into right node */ - H5MM_memcpy(&(right_node_ptrs[0]), &(middle_node_ptrs[(curr_middle_nrec - right_nrec_move) + 1]), sizeof(H5B2_node_ptr_t) * right_nrec_move); + H5MM_memcpy(&(right_node_ptrs[0]), + &(middle_node_ptrs[(curr_middle_nrec - right_nrec_move) + 1]), + sizeof(H5B2_node_ptr_t) * right_nrec_move); /* Count the number of records being moved into the right node */ - for(u = 0, moved_nrec = 0; u < right_nrec_move; u++) + for (u = 0, moved_nrec = 0; u < right_nrec_move; u++) moved_nrec += right_node_ptrs[u].all_nrec; right_moved_nrec = (hssize_t)(moved_nrec + right_nrec_move); middle_moved_nrec -= (hssize_t)(moved_nrec + right_nrec_move); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, - 0, (unsigned)right_nrec_move, middle_child, right_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, 0, + (unsigned)right_nrec_move, middle_child, + right_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update the current number of records in middle node */ @@ -875,44 +938,52 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end if */ /* Move records out of left node */ - if(new_left_nrec < *left_nrec) { - unsigned left_nrec_move = (unsigned)(*left_nrec - new_left_nrec); /* Number of records to move out of left node */ + if (new_left_nrec < *left_nrec) { + unsigned left_nrec_move = + (unsigned)(*left_nrec - new_left_nrec); /* Number of records to move out of left node */ /* Slide middle records up */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * curr_middle_nrec); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move), H5B2_NAT_NREC(middle_native, hdr, 0), + hdr->cls->nrec_size * curr_middle_nrec); /* Move left parent record down to middle node */ - H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move - 1), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move - 1), + H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size); /* Move left records to middle node */ - if(left_nrec_move > 1) - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, new_left_nrec + 1), hdr->cls->nrec_size * (left_nrec_move - 1)); + if (left_nrec_move > 1) + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), + H5B2_NAT_NREC(left_native, hdr, new_left_nrec + 1), + hdr->cls->nrec_size * (left_nrec_move - 1)); /* Move left parent record up from left node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(left_native, hdr, new_left_nrec), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(left_native, hdr, new_left_nrec), + hdr->cls->nrec_size); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Slide the node pointers in middle node up */ - HDmemmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(curr_middle_nrec + 1)); + HDmemmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(curr_middle_nrec + 1)); /* Move left node pointers into middle node */ - H5MM_memcpy(&(middle_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * left_nrec_move); + H5MM_memcpy(&(middle_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), + sizeof(H5B2_node_ptr_t) * left_nrec_move); /* Count the number of records being moved into the left node */ - for(u = 0, moved_nrec = 0; u < left_nrec_move; u++) + for (u = 0, moved_nrec = 0; u < left_nrec_move; u++) moved_nrec += middle_node_ptrs[u].all_nrec; left_moved_nrec -= (hssize_t)(moved_nrec + left_nrec_move); middle_moved_nrec += (hssize_t)(moved_nrec + left_nrec_move); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, - 0, (unsigned)left_nrec_move, left_child, middle_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, 0, + (unsigned)left_nrec_move, left_child, middle_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update the current number of records in middle node */ @@ -924,43 +995,51 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end if */ /* Move records out of right node */ - if(new_right_nrec < *right_nrec) { - unsigned right_nrec_move = (unsigned)(*right_nrec - new_right_nrec); /* Number of records to move out of right node */ + if (new_right_nrec < *right_nrec) { + unsigned right_nrec_move = + (unsigned)(*right_nrec - new_right_nrec); /* Number of records to move out of right node */ /* Move right parent record down to middle node */ - H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, curr_middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, curr_middle_nrec), + H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); /* Move right records to middle node */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (right_nrec_move - 1)); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec + 1)), + H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (right_nrec_move - 1)); /* Move right parent record up from right node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), + H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), hdr->cls->nrec_size); /* Slide right records down */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, right_nrec_move), hdr->cls->nrec_size * new_right_nrec); + HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, right_nrec_move), + hdr->cls->nrec_size * new_right_nrec); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Move right node pointers into middle node */ - H5MM_memcpy(&(middle_node_ptrs[curr_middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * right_nrec_move); + H5MM_memcpy(&(middle_node_ptrs[curr_middle_nrec + 1]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * right_nrec_move); /* Count the number of records being moved into the right node */ - for(u = 0, moved_nrec = 0; u < right_nrec_move; u++) + for (u = 0, moved_nrec = 0; u < right_nrec_move; u++) moved_nrec += right_node_ptrs[u].all_nrec; right_moved_nrec -= (hssize_t)(moved_nrec + right_nrec_move); middle_moved_nrec += (hssize_t)(moved_nrec + right_nrec_move); /* Slide the node pointers in right node down */ - HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[right_nrec_move]), sizeof(H5B2_node_ptr_t) * (size_t)(new_right_nrec + 1)); + HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[right_nrec_move]), + sizeof(H5B2_node_ptr_t) * (size_t)(new_right_nrec + 1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, - (unsigned)(curr_middle_nrec + 1), (unsigned)(curr_middle_nrec + right_nrec_move + 1), right_child, middle_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends( + hdr, depth, middle_node_ptrs, (unsigned)(curr_middle_nrec + 1), + (unsigned)(curr_middle_nrec + right_nrec_move + 1), right_child, middle_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Mark nodes as dirty */ @@ -969,25 +1048,28 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end if */ /* Update # of records in nodes */ - *left_nrec = new_left_nrec; + *left_nrec = new_left_nrec; *middle_nrec = new_middle_nrec; - *right_nrec = new_right_nrec; + *right_nrec = new_right_nrec; } /* end block */ /* Update # of records in child nodes */ internal->node_ptrs[idx - 1].node_nrec = *left_nrec; - internal->node_ptrs[idx].node_nrec = *middle_nrec; + internal->node_ptrs[idx].node_nrec = *middle_nrec; internal->node_ptrs[idx + 1].node_nrec = *right_nrec; /* Update total # of records in child B-trees */ - if(depth > 1) { - internal->node_ptrs[idx - 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx - 1].all_nrec + left_moved_nrec); - internal->node_ptrs[idx].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + middle_moved_nrec); - internal->node_ptrs[idx + 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); + if (depth > 1) { + internal->node_ptrs[idx - 1].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx - 1].all_nrec + left_moved_nrec); + internal->node_ptrs[idx].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + middle_moved_nrec); + internal->node_ptrs[idx + 1].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); } /* end if */ else { internal->node_ptrs[idx - 1].all_nrec = internal->node_ptrs[idx - 1].node_nrec; - internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; + internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec; } /* end else */ @@ -996,32 +1078,36 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx - 1].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)middle_child); - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child, (H5B2_internal_t *)left_child); - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child, (H5B2_internal_t *)right_child); - H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, (H5B2_internal_t *)middle_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx - 1].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)middle_child); + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child, + (H5B2_internal_t *)left_child); + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child, + (H5B2_internal_t *)right_child); + H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, + (H5B2_internal_t *)middle_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)middle_child); H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)middle_child, (H5B2_leaf_t *)right_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)right_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ done: /* Unlock child nodes (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if(middle_child && H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) + if (middle_child && + H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__redistribute3() */ - /*------------------------------------------------------------------------- * Function: H5B2__merge2 * @@ -1039,17 +1125,19 @@ done: */ herr_t H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx) + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ - void *left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */ - uint16_t *left_nrec, *right_nrec; /* Pointers to left & right child # of records */ - uint8_t *left_native, *right_native; /* Pointers to left & right children's native records */ - H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL;/* Pointers to childs' node pointer info */ - unsigned left_child_flags = H5AC__NO_FLAGS_SET, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5AC_class_t *child_class; /* Pointer to child node's class info */ + haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ + void * left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */ + uint16_t * left_nrec, *right_nrec; /* Pointers to left & right child # of records */ + uint8_t * left_native, *right_native; /* Pointers to left & right children's native records */ + H5B2_node_ptr_t * left_node_ptrs = NULL, + *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ + unsigned left_child_flags = H5AC__NO_FLAGS_SET, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1060,73 +1148,83 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, HDassert(internal_flags_ptr); /* Check for the kind of B-tree node to split */ - if(depth > 1) { - H5B2_internal_t *left_internal; /* Pointer to left internal node */ - H5B2_internal_t *right_internal; /* Pointer to right internal node */ + if (depth > 1) { + H5B2_internal_t *left_internal; /* Pointer to left internal node */ + H5B2_internal_t *right_internal; /* Pointer to right internal node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Lock left & right B-tree child nodes */ /* (Shadow the left node if doing SWMR writes) */ - if(NULL == (left_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for accessing child node information */ - left_child = left_internal; - right_child = right_internal; - left_nrec = &(left_internal->nrec); - right_nrec = &(right_internal->nrec); - left_native = left_internal->int_native; - right_native = right_internal->int_native; - left_node_ptrs = left_internal->node_ptrs; + left_child = left_internal; + right_child = right_internal; + left_nrec = &(left_internal->nrec); + right_nrec = &(right_internal->nrec); + left_native = left_internal->int_native; + right_native = right_internal->int_native; + left_node_ptrs = left_internal->node_ptrs; right_node_ptrs = right_internal->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ - H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ + H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ + H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock left & right B-tree child nodes */ /* (Shadow the left node if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for accessing child node information */ - left_child = left_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; right_native = right_leaf->leaf_native; } /* end else */ /* Redistribute records into left node */ { /* Copy record from parent node to proper location */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size); /* Copy records from right node to left node */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec)); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Copy node pointers from right node into left node */ - if(depth > 1) - H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + if (depth > 1) + H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, - (unsigned)(*left_nrec + 1), (unsigned)(*left_nrec + *right_nrec + 2), right_child, left_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, (unsigned)(*left_nrec + 1), + (unsigned)(*left_nrec + *right_nrec + 2), right_child, + left_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update # of records in left node */ @@ -1135,7 +1233,7 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Mark nodes as dirty */ left_child_flags |= H5AC__DIRTIED_FLAG; right_child_flags |= H5AC__DELETED_FLAG; - if(!(hdr->swmr_write)) + if (!(hdr->swmr_write)) right_child_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; } /* end block */ @@ -1146,9 +1244,11 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, internal->node_ptrs[idx].all_nrec += internal->node_ptrs[idx + 1].all_nrec + 1; /* Slide records in parent node down, to eliminate demoted record */ - if((idx + 1) < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), hdr->cls->nrec_size * (internal->nrec - (idx + 1))); - HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); + if ((idx + 1) < internal->nrec) { + HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), + hdr->cls->nrec_size * (internal->nrec - (idx + 1))); + HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); } /* end if */ /* Update # of records in parent node */ @@ -1161,12 +1261,12 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, curr_node_ptr->node_nrec--; /* Mark grandparent as dirty, if given */ - if(parent_cache_info_flags_ptr) + if (parent_cache_info_flags_ptr) *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG; #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) + if (depth > 1) H5B2__assert_internal(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child); else H5B2__assert_leaf(hdr, (H5B2_leaf_t *)left_child); @@ -1174,17 +1274,16 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, done: /* Unlock left node (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") /* Delete right node & remove from cache (marked as dirty) */ - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__merge2() */ - /*------------------------------------------------------------------------- * Function: H5B2__merge3 * @@ -1202,24 +1301,26 @@ done: */ herr_t H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx) + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ - haddr_t middle_addr; /* Address of middle child node */ - void *left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */ - void *middle_child = NULL; /* Pointer to middle child node */ - uint16_t *left_nrec, *right_nrec; /* Pointers to left & right child # of records */ - uint16_t *middle_nrec; /* Pointer to middle child # of records */ - uint8_t *left_native, *right_native; /* Pointers to left & right children's native records */ - uint8_t *middle_native; /* Pointer to middle child's native records */ - H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL;/* Pointers to childs' node pointer info */ - H5B2_node_ptr_t *middle_node_ptrs = NULL;/* Pointer to child's node pointer info */ - hsize_t middle_moved_nrec; /* Number of records moved, for internal split */ - unsigned left_child_flags = H5AC__NO_FLAGS_SET, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5AC_class_t *child_class; /* Pointer to child node's class info */ + haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ + haddr_t middle_addr; /* Address of middle child node */ + void * left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */ + void * middle_child = NULL; /* Pointer to middle child node */ + uint16_t * left_nrec, *right_nrec; /* Pointers to left & right child # of records */ + uint16_t * middle_nrec; /* Pointer to middle child # of records */ + uint8_t * left_native, *right_native; /* Pointers to left & right children's native records */ + uint8_t * middle_native; /* Pointer to middle child's native records */ + H5B2_node_ptr_t * left_node_ptrs = NULL, + *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ + H5B2_node_ptr_t *middle_node_ptrs = NULL; /* Pointer to child's node pointer info */ + hsize_t middle_moved_nrec; /* Number of records moved, for internal split */ + unsigned left_child_flags = H5AC__NO_FLAGS_SET, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1230,115 +1331,131 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, HDassert(internal_flags_ptr); /* Check for the kind of B-tree node to split */ - if(depth > 1) { - H5B2_internal_t *left_internal; /* Pointer to left internal node */ - H5B2_internal_t *middle_internal; /* Pointer to middle internal node */ - H5B2_internal_t *right_internal; /* Pointer to right internal node */ + if (depth > 1) { + H5B2_internal_t *left_internal; /* Pointer to left internal node */ + H5B2_internal_t *middle_internal; /* Pointer to middle internal node */ + H5B2_internal_t *right_internal; /* Pointer to right internal node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Lock B-tree child nodes */ /* (Shadow left and middle nodes if doing SWMR writes) */ - if(NULL == (left_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx - 1], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx - 1], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") left_addr = internal->node_ptrs[idx - 1].addr; - if(NULL == (middle_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (middle_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") middle_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for accessing child node information */ - left_child = left_internal; - middle_child = middle_internal; - right_child = right_internal; - left_nrec = &(left_internal->nrec); - middle_nrec = &(middle_internal->nrec); - right_nrec = &(right_internal->nrec); - left_native = left_internal->int_native; - middle_native = middle_internal->int_native; - right_native = right_internal->int_native; - left_node_ptrs = left_internal->node_ptrs; + left_child = left_internal; + middle_child = middle_internal; + right_child = right_internal; + left_nrec = &(left_internal->nrec); + middle_nrec = &(middle_internal->nrec); + right_nrec = &(right_internal->nrec); + left_native = left_internal->int_native; + middle_native = middle_internal->int_native; + right_native = right_internal->int_native; + left_node_ptrs = left_internal->node_ptrs; middle_node_ptrs = middle_internal->node_ptrs; - right_node_ptrs = right_internal->node_ptrs; + right_node_ptrs = right_internal->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ - H5B2_leaf_t *middle_leaf; /* Pointer to middle leaf node */ - H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ + H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ + H5B2_leaf_t *middle_leaf; /* Pointer to middle leaf node */ + H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock B-tree child nodes */ /* (Shadow left and middle nodes if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx - 1], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx - 1], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx - 1].addr; - if(NULL == (middle_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (middle_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") middle_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for accessing child node information */ - left_child = left_leaf; - middle_child = middle_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - middle_nrec = &(middle_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + middle_child = middle_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + middle_nrec = &(middle_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; middle_native = middle_leaf->leaf_native; - right_native = right_leaf->leaf_native; + right_native = right_leaf->leaf_native; } /* end else */ /* Redistribute records into left node */ { - unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); + unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); unsigned middle_nrec_move = ((total_nrec - 1) / 2) - *left_nrec; /* Set the base number of records moved from middle node */ middle_moved_nrec = middle_nrec_move; /* Copy record from parent node to proper location in left node */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), + hdr->cls->nrec_size); /* Copy records from middle node to left node */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * (middle_nrec_move - 1)); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), + hdr->cls->nrec_size * (middle_nrec_move - 1)); /* Copy record from middle node to proper location in parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(middle_native, hdr, (middle_nrec_move - 1)), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), + H5B2_NAT_NREC(middle_native, hdr, (middle_nrec_move - 1)), hdr->cls->nrec_size); /* Slide records in middle node down */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, middle_nrec_move), hdr->cls->nrec_size * (*middle_nrec - middle_nrec_move)); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, middle_nrec_move), + hdr->cls->nrec_size * (*middle_nrec - middle_nrec_move)); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - unsigned u; /* Local index variable */ + if (depth > 1) { + unsigned u; /* Local index variable */ /* Copy node pointers from middle node into left node */ - H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * middle_nrec_move); + H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * middle_nrec_move); /* Count the number of records being moved into the left node */ - for(u = 0; u < middle_nrec_move; u++) + for (u = 0; u < middle_nrec_move; u++) middle_moved_nrec += middle_node_ptrs[u].all_nrec; /* Slide the node pointers in middle node down */ - HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[middle_nrec_move]), sizeof(H5B2_node_ptr_t) * (size_t)((unsigned)(*middle_nrec + 1) - middle_nrec_move)); + HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[middle_nrec_move]), + sizeof(H5B2_node_ptr_t) * (size_t)((unsigned)(*middle_nrec + 1) - middle_nrec_move)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, - (unsigned)(*left_nrec + 1), (unsigned)(*left_nrec + middle_nrec_move + 1), middle_child, left_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, (unsigned)(*left_nrec + 1), + (unsigned)(*left_nrec + middle_nrec_move + 1), middle_child, + left_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update # of records in left & middle nodes */ - *left_nrec = (uint16_t)(*left_nrec + middle_nrec_move); + *left_nrec = (uint16_t)(*left_nrec + middle_nrec_move); *middle_nrec = (uint16_t)(*middle_nrec - middle_nrec_move); /* Mark nodes as dirty */ @@ -1349,20 +1466,24 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Redistribute records into middle node */ { /* Copy record from parent node to proper location in middle node */ - H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size); /* Copy records from right node to middle node */ - H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec)); + H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Move node pointers also if this is an internal node */ - if(depth > 1) + if (depth > 1) /* Copy node pointers from right node into middle node */ - H5MM_memcpy(&(middle_node_ptrs[*middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + H5MM_memcpy(&(middle_node_ptrs[*middle_nrec + 1]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, - (unsigned)(*middle_nrec + 1), (unsigned)(*middle_nrec + *right_nrec + 2), right_child, middle_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, (unsigned)(*middle_nrec + 1), + (unsigned)(*middle_nrec + *right_nrec + 2), right_child, + middle_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update # of records in middle node */ @@ -1371,22 +1492,24 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Mark nodes as dirty */ middle_child_flags |= H5AC__DIRTIED_FLAG; right_child_flags |= H5AC__DELETED_FLAG; - if(!(hdr->swmr_write)) + if (!(hdr->swmr_write)) right_child_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; } /* end block */ /* Update # of records in child nodes */ internal->node_ptrs[idx - 1].node_nrec = *left_nrec; - internal->node_ptrs[idx].node_nrec = *middle_nrec; + internal->node_ptrs[idx].node_nrec = *middle_nrec; /* Update total # of records in child B-trees */ internal->node_ptrs[idx - 1].all_nrec += middle_moved_nrec; internal->node_ptrs[idx].all_nrec += (internal->node_ptrs[idx + 1].all_nrec + 1) - middle_moved_nrec; /* Slide records in parent node down, to eliminate demoted record */ - if((idx + 1) < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), hdr->cls->nrec_size * (internal->nrec - (idx + 1))); - HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); + if ((idx + 1) < internal->nrec) { + HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), + hdr->cls->nrec_size * (internal->nrec - (idx + 1))); + HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); } /* end if */ /* Update # of records in parent node */ @@ -1399,36 +1522,37 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, curr_node_ptr->node_nrec--; /* Mark grandparent as dirty, if given */ - if(parent_cache_info_flags_ptr) + if (parent_cache_info_flags_ptr) *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG; #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx - 1].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)middle_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx - 1].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)middle_child); H5B2__assert_internal(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)middle_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)middle_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ done: /* Unlock left & middle nodes (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if(middle_child && H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) + if (middle_child && + H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") /* Delete right node & remove from cache (marked as dirty) */ - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__merge3() */ - /*------------------------------------------------------------------------- * Function: H5B2__insert * @@ -1445,7 +1569,7 @@ done: herr_t H5B2__insert(H5B2_hdr_t *hdr, void *udata) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1454,37 +1578,36 @@ H5B2__insert(H5B2_hdr_t *hdr, void *udata) HDassert(udata); /* Check if the root node is allocated yet */ - if(!H5F_addr_defined(hdr->root.addr)) { + if (!H5F_addr_defined(hdr->root.addr)) { /* Create root node as leaf node in B-tree */ - if(H5B2__create_leaf(hdr, hdr, &(hdr->root)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") + if (H5B2__create_leaf(hdr, hdr, &(hdr->root)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") } /* end if */ /* Check if we need to split the root node (equiv. to a 1->2 node split) */ - else if(hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) { + else if (hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) { /* Split root node */ - if(H5B2__split_root(hdr) < 0) + if (H5B2__split_root(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split root node") } /* end if */ /* Attempt to insert record into B-tree */ - if(hdr->depth > 0) { - if(H5B2__insert_internal(hdr, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, hdr, udata) < 0) + if (hdr->depth > 0) { + if (H5B2__insert_internal(hdr, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, hdr, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node") } /* end if */ else { - if(H5B2__insert_leaf(hdr, &hdr->root, H5B2_POS_ROOT, hdr, udata) < 0) + if (H5B2__insert_leaf(hdr, &hdr->root, H5B2_POS_ROOT, hdr, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node") } /* end else */ /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) + if (H5B2__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__insert() */ - /*------------------------------------------------------------------------- * Function: H5B2__iterate_node * @@ -1503,17 +1626,17 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, - void *parent, H5B2_operator_t op, void *op_data) +H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, + H5B2_operator_t op, void *op_data) { - const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */ - void *node = NULL; /* Pointers to current node */ - uint8_t *node_native; /* Pointers to node's native records */ - uint8_t *native = NULL; /* Pointers to copy of node's native records */ - H5B2_node_ptr_t *node_ptrs = NULL; /* Pointers to node's node pointers */ - hbool_t node_pinned = FALSE; /* Whether node is pinned */ - unsigned u; /* Local index */ - herr_t ret_value = H5_ITER_CONT; /* Iterator return value */ + const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */ + void * node = NULL; /* Pointers to current node */ + uint8_t * node_native; /* Pointers to node's native records */ + uint8_t * native = NULL; /* Pointers to copy of node's native records */ + H5B2_node_ptr_t * node_ptrs = NULL; /* Pointers to node's node pointers */ + hbool_t node_pinned = FALSE; /* Whether node is pinned */ + unsigned u; /* Local index */ + herr_t ret_value = H5_ITER_CONT; /* Iterator return value */ FUNC_ENTER_PACKAGE @@ -1523,86 +1646,94 @@ H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_ HDassert(op); /* Protect current node & set up variables */ - if(depth > 0) { - H5B2_internal_t *internal; /* Pointer to internal node */ + if (depth > 0) { + H5B2_internal_t *internal; /* Pointer to internal node */ /* Lock the current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, + H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set up information about current node */ curr_node_class = H5AC_BT2_INT; - node = internal; - node_native = internal->int_native; + node = internal; + node_native = internal->int_native; /* Allocate space for the node pointers in memory */ - if(NULL == (node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers") + if (NULL == (node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for B-tree internal node pointers") /* Copy the node pointers */ - H5MM_memcpy(node_ptrs, internal->node_ptrs, (sizeof(H5B2_node_ptr_t) * (size_t)(curr_node->node_nrec + 1))); + H5MM_memcpy(node_ptrs, internal->node_ptrs, + (sizeof(H5B2_node_ptr_t) * (size_t)(curr_node->node_nrec + 1))); } /* end if */ else { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ /* Lock the current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, (H5B2_node_ptr_t *)curr_node, FALSE, H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, (H5B2_node_ptr_t *)curr_node, FALSE, + H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Set up information about current node */ curr_node_class = H5AC_BT2_LEAF; - node = leaf; - node_native = leaf->leaf_native; + node = leaf; + node_native = leaf->leaf_native; } /* end else */ /* Allocate space for the native keys in memory */ - if(NULL == (native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys") + if (NULL == (native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for B-tree internal native keys") /* Copy the native keys */ H5MM_memcpy(native, node_native, (hdr->cls->nrec_size * curr_node->node_nrec)); /* Unlock the node */ - if(H5AC_unprotect(hdr->f, curr_node_class, curr_node->addr, node, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, curr_node_class, curr_node->addr, node, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - if(hdr->swmr_write) + if (hdr->swmr_write) node_pinned = TRUE; else node = NULL; /* Iterate through records, in order */ - for(u = 0; u < curr_node->node_nrec && !ret_value; u++) { + for (u = 0; u < curr_node->node_nrec && !ret_value; u++) { /* Descend into child node, if current node is an internal node */ - if(depth > 0) - if((ret_value = H5B2__iterate_node(hdr, (uint16_t)(depth - 1), &(node_ptrs[u]), node, op, op_data)) < 0) + if (depth > 0) + if ((ret_value = + H5B2__iterate_node(hdr, (uint16_t)(depth - 1), &(node_ptrs[u]), node, op, op_data)) < 0) HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); /* Make callback for current record */ - if(!ret_value) - if((ret_value = (op)(H5B2_NAT_NREC(native, hdr, u), op_data)) < 0) + if (!ret_value) + if ((ret_value = (op)(H5B2_NAT_NREC(native, hdr, u), op_data)) < 0) HERROR(H5E_BTREE, H5E_CANTLIST, "iterator function failed"); } /* end for */ /* Descend into last child node, if current node is an internal node */ - if(!ret_value && depth > 0) - if((ret_value = H5B2__iterate_node(hdr, (uint16_t)(depth - 1), &(node_ptrs[u]), node, op, op_data)) < 0) + if (!ret_value && depth > 0) + if ((ret_value = H5B2__iterate_node(hdr, (uint16_t)(depth - 1), &(node_ptrs[u]), node, op, op_data)) < + 0) HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); done: /* Unpin the node if it was pinned */ - if(node_pinned && H5AC_unpin_entry(node) < 0) + if (node_pinned && H5AC_unpin_entry(node) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "can't unpin node") /* Release the node pointers & native records, if they were copied */ - if(node_ptrs) + if (node_ptrs) node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_FREE(hdr->node_info[depth].node_ptr_fac, node_ptrs); - if(native) + if (native) native = (uint8_t *)H5FL_FAC_FREE(hdr->node_info[depth].nat_rec_fac, native); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__iterate_node() */ - /*------------------------------------------------------------------------- * Function: H5B2__delete_node * @@ -1618,13 +1749,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, - void *parent, H5B2_remove_t op, void *op_data) +H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, + H5B2_remove_t op, void *op_data) { const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */ - void *node = NULL; /* Pointers to current node */ - uint8_t *native; /* Pointers to node's native records */ - herr_t ret_value = SUCCEED; /* Return value */ + void * node = NULL; /* Pointers to current node */ + uint8_t * native; /* Pointers to node's native records */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1632,58 +1763,63 @@ H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_n HDassert(hdr); HDassert(curr_node); - if(depth > 0) { - H5B2_internal_t *internal; /* Pointer to internal node */ - unsigned u; /* Local index */ + if (depth > 0) { + H5B2_internal_t *internal; /* Pointer to internal node */ + unsigned u; /* Local index */ /* Lock the current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, + H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set up information about current node */ curr_node_class = H5AC_BT2_INT; - node = internal; - native = internal->int_native; + node = internal; + native = internal->int_native; /* Descend into children */ - for(u = 0; u < internal->nrec + (unsigned)1; u++) - if(H5B2__delete_node(hdr, (uint16_t)(depth - 1), &(internal->node_ptrs[u]), internal, op, op_data) < 0) + for (u = 0; u < internal->nrec + (unsigned)1; u++) + if (H5B2__delete_node(hdr, (uint16_t)(depth - 1), &(internal->node_ptrs[u]), internal, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node descent failed") } /* end if */ else { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ /* Lock the current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, (H5B2_node_ptr_t *)curr_node, FALSE, H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, (H5B2_node_ptr_t *)curr_node, FALSE, + H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Set up information about current node */ curr_node_class = H5AC_BT2_LEAF; - node = leaf; - native = leaf->leaf_native; + node = leaf; + native = leaf->leaf_native; } /* end else */ /* If there's a callback defined, iterate over the records in this node */ - if(op) { - unsigned u; /* Local index */ + if (op) { + unsigned u; /* Local index */ /* Iterate through records in this node */ - for(u = 0; u < curr_node->node_nrec; u++) { + for (u = 0; u < curr_node->node_nrec; u++) { /* Make callback for each record */ - if((op)(H5B2_NAT_NREC(native, hdr, u), op_data) < 0) + if ((op)(H5B2_NAT_NREC(native, hdr, u), op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "iterator function failed") } /* end for */ - } /* end if */ + } /* end if */ done: /* Unlock & delete current node */ - if(node && H5AC_unprotect(hdr->f, curr_node_class, curr_node->addr, node, (unsigned)(H5AC__DELETED_FLAG | (hdr->swmr_write ? 0 : H5AC__FREE_FILE_SPACE_FLAG))) < 0) + if (node && H5AC_unprotect( + hdr->f, curr_node_class, curr_node->addr, node, + (unsigned)(H5AC__DELETED_FLAG | (hdr->swmr_write ? 0 : H5AC__FREE_FILE_SPACE_FLAG))) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__delete_node() */ - /*------------------------------------------------------------------------- * Function: H5B2__node_size * @@ -1698,11 +1834,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, - void *parent, hsize_t *btree_size) +H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, + hsize_t *btree_size) { - H5B2_internal_t *internal = NULL; /* Pointer to internal node */ - herr_t ret_value = SUCCEED; /* Iterator return value */ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + herr_t ret_value = SUCCEED; /* Iterator return value */ FUNC_ENTER_PACKAGE @@ -1713,18 +1849,20 @@ H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_nod HDassert(depth > 0); /* Lock the current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ + if (NULL == (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, + H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Recursively descend into child nodes, if we are above the "twig" level in the B-tree */ - if(depth > 1) { - unsigned u; /* Local index */ + if (depth > 1) { + unsigned u; /* Local index */ /* Descend into children */ - for(u = 0; u < internal->nrec + (unsigned)1; u++) - if(H5B2__node_size(hdr, (uint16_t)(depth - 1), &(internal->node_ptrs[u]), internal, btree_size) < 0) + for (u = 0; u < internal->nrec + (unsigned)1; u++) + if (H5B2__node_size(hdr, (uint16_t)(depth - 1), &(internal->node_ptrs[u]), internal, btree_size) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") - } /* end if */ + } /* end if */ else /* depth is 1: count all the leaf nodes from this node */ *btree_size += (hsize_t)(internal->nrec + 1) * hdr->node_size; @@ -1732,13 +1870,12 @@ H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_nod *btree_size += hdr->node_size; done: - if(internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__node_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__create_flush_depend * @@ -1754,7 +1891,7 @@ done: herr_t H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1763,14 +1900,13 @@ H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) HDassert(child_entry); /* Create a flush dependency between parent and child entry */ - if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__create_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5B2__update_flush_depend * @@ -1785,13 +1921,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, - const H5B2_node_ptr_t *node_ptr, void *old_parent, void *new_parent) +H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptr, void *old_parent, + void *new_parent) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - void *child = NULL; /* Pointer to child node */ - unsigned node_status = 0; /* Node's status in the metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5AC_class_t *child_class; /* Pointer to child node's class info */ + void * child = NULL; /* Pointer to child node */ + unsigned node_status = 0; /* Node's status in the metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1803,26 +1939,28 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, HDassert(new_parent); /* Check the node's entry status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, node_ptr->addr, &node_status) < 0) + if (H5AC_get_entry_status(hdr->f, node_ptr->addr, &node_status) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to check status of B-tree node") /* If the node is in the cache, check for retargeting its parent */ - if(node_status & H5AC_ES__IN_CACHE) { - void **parent_ptr; /* Pointer to child node's parent */ - hbool_t update_deps = FALSE; /* Whether to update flush dependencies */ + if (node_status & H5AC_ES__IN_CACHE) { + void ** parent_ptr; /* Pointer to child node's parent */ + hbool_t update_deps = FALSE; /* Whether to update flush dependencies */ /* Get child node pointer */ - if(depth > 1) { + if (depth > 1) { H5B2_internal_t *child_int; /* Protect child */ - if(NULL == (child_int = H5B2__protect_internal(hdr, new_parent, (H5B2_node_ptr_t *)node_ptr, (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + if (NULL == (child_int = H5B2__protect_internal( + hdr, new_parent, (H5B2_node_ptr_t *)node_ptr, (uint16_t)(depth - 1), FALSE, + H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") child_class = H5AC_BT2_INT; - child = child_int; + child = child_int; - if(child_int->parent == old_parent) { - parent_ptr = &child_int->parent; + if (child_int->parent == old_parent) { + parent_ptr = &child_int->parent; update_deps = TRUE; } /* end if */ else @@ -1832,13 +1970,15 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, H5B2_leaf_t *child_leaf; /* Protect child */ - if(NULL == (child_leaf = H5B2__protect_leaf(hdr, new_parent, (H5B2_node_ptr_t *)node_ptr, FALSE, H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + if (NULL == + (child_leaf = H5B2__protect_leaf(hdr, new_parent, (H5B2_node_ptr_t *)node_ptr, FALSE, + H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") child_class = H5AC_BT2_LEAF; - child = child_leaf; + child = child_leaf; - if(child_leaf->parent == old_parent) { - parent_ptr = &child_leaf->parent; + if (child_leaf->parent == old_parent) { + parent_ptr = &child_leaf->parent; update_deps = TRUE; } /* end if */ else @@ -1846,29 +1986,28 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, } /* end else */ /* Update flush dependencies if necessary */ - if(update_deps) { + if (update_deps) { /* Sanity check */ HDassert(parent_ptr); /* Switch the flush dependency for the node */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)old_parent, (H5AC_info_t *)child) < 0) + if (H5B2__destroy_flush_depend((H5AC_info_t *)old_parent, (H5AC_info_t *)child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") *parent_ptr = new_parent; - if(H5B2__create_flush_depend((H5AC_info_t *)new_parent, (H5AC_info_t *)child) < 0) + if (H5B2__create_flush_depend((H5AC_info_t *)new_parent, (H5AC_info_t *)child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ - } /* end if */ + } /* end if */ done: /* Unprotect the child */ - if(child) - if(H5AC_unprotect(hdr->f, child_class, node_ptr->addr, child, H5AC__NO_FLAGS_SET) < 0) + if (child) + if (H5AC_unprotect(hdr->f, child_class, node_ptr->addr, child, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__update_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5B2__update_child_flush_depends * @@ -1883,12 +2022,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, - const H5B2_node_ptr_t *node_ptrs, unsigned start_idx, unsigned end_idx, - void *old_parent, void *new_parent) +H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptrs, + unsigned start_idx, unsigned end_idx, void *old_parent, void *new_parent) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1901,16 +2039,15 @@ H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, HDassert(new_parent); /* Loop over children */ - for(u = start_idx; u < end_idx; u++) + for (u = start_idx; u < end_idx; u++) /* Update parent for children */ - if(H5B2__update_flush_depend(hdr, depth - 1, &node_ptrs[u], old_parent, new_parent) < 0) + if (H5B2__update_flush_depend(hdr, depth - 1, &node_ptrs[u], old_parent, new_parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child node to new parent") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__update_child_flush_depends() */ - /*------------------------------------------------------------------------- * Function: H5B2__destroy_flush_depend * @@ -1926,7 +2063,7 @@ done: herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1935,10 +2072,9 @@ H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) HDassert(child_entry); /* Destroy a flush dependency between parent and child entry */ - if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__destroy_flush_depend() */ - diff --git a/src/H5B2internal.c b/src/H5B2internal.c index 1fee0af..2ac0c84 100644 --- a/src/H5B2internal.c +++ b/src/H5B2internal.c @@ -26,39 +26,33 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr); - /*********************/ /* Package Variables */ /*********************/ @@ -66,18 +60,14 @@ static herr_t H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t * /* Declare a free list to manage the H5B2_internal_t struct */ H5FL_DEFINE(H5B2_internal_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B2__create_internal * @@ -93,12 +83,11 @@ H5FL_DEFINE(H5B2_internal_t); *------------------------------------------------------------------------- */ herr_t -H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, - uint16_t depth) +H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, uint16_t depth) { - H5B2_internal_t *internal = NULL; /* Pointer to new internal node created */ - hbool_t inserted = FALSE; /* Whether the internal node was inserted into cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = NULL; /* Pointer to new internal node created */ + hbool_t inserted = FALSE; /* Whether the internal node was inserted into cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -108,24 +97,27 @@ H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, HDassert(depth > 0); /* Allocate memory for internal node information */ - if(NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal info") + if (NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal info") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, FAIL, "can't increment ref. count on B-tree header") + if (H5B2__hdr_incr(hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, FAIL, "can't increment ref. count on B-tree header") /* Share B-tree header information */ internal->hdr = hdr; /* Allocate space for the native keys in memory */ - if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys") + if (NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for B-tree internal native keys") HDmemset(internal->int_native, 0, hdr->cls->nrec_size * hdr->node_info[depth].max_nrec); /* Allocate space for the node pointers in memory */ - if(NULL == (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers") + if (NULL == + (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for B-tree internal node pointers") HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (hdr->node_info[depth].max_nrec + 1)); /* Set depth of the node */ @@ -138,43 +130,45 @@ H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, internal->shadow_epoch = hdr->shadow_epoch; /* Allocate space on disk for the internal node */ - if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree internal node") + if (HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree internal node") /* Cache the new B-tree node */ - if(H5AC_insert_entry(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree internal node to cache") + if (H5AC_insert_entry(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree internal node to cache") inserted = TRUE; /* Add internal node as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, internal) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, FAIL, "unable to add v2 B-tree node as child of proxy") internal->top_proxy = hdr->top_proxy; } /* end if */ done: - if(ret_value < 0) { - if(internal) { + if (ret_value < 0) { + if (internal) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(internal) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, "unable to remove v2 B-tree internal node from cache") + if (inserted) + if (H5AC_remove_entry(internal) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, + "unable to remove v2 B-tree internal node from cache") /* Release internal node's disk space */ - if(H5F_addr_defined(node_ptr->addr) && H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release file space for v2 B-tree internal node") + if (H5F_addr_defined(node_ptr->addr) && + H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, + "unable to release file space for v2 B-tree internal node") /* Destroy internal node */ - if(H5B2__internal_free(internal) < 0) + if (H5B2__internal_free(internal) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node") } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__create_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__protect_internal * @@ -189,12 +183,12 @@ done: *------------------------------------------------------------------------- */ H5B2_internal_t * -H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, - uint16_t depth, hbool_t shadow, unsigned flags) +H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, uint16_t depth, + hbool_t shadow, unsigned flags) { - H5B2_internal_cache_ud_t udata; /* User data to pass through to cache 'deserialize' callback */ - H5B2_internal_t *internal = NULL; /* v2 B-tree internal node */ - H5B2_internal_t *ret_value = NULL; /* Return value */ + H5B2_internal_cache_ud_t udata; /* User data to pass through to cache 'deserialize' callback */ + H5B2_internal_t * internal = NULL; /* v2 B-tree internal node */ + H5B2_internal_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -208,27 +202,29 @@ H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for callback */ - udata.f = hdr->f; - udata.hdr = hdr; + udata.f = hdr->f; + udata.hdr = hdr; udata.parent = parent; - udata.nrec = node_ptr->node_nrec; - udata.depth = depth; + udata.nrec = node_ptr->node_nrec; + udata.depth = depth; /* Protect the internal node */ - if(NULL == (internal = (H5B2_internal_t *)H5AC_protect(hdr->f, H5AC_BT2_INT, node_ptr->addr, &udata, flags))) + if (NULL == + (internal = (H5B2_internal_t *)H5AC_protect(hdr->f, H5AC_BT2_INT, node_ptr->addr, &udata, flags))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect B-tree internal node") /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == internal->top_proxy) { + if (hdr->top_proxy && NULL == internal->top_proxy) { /* Add internal node as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, internal) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, NULL, "unable to add v2 B-tree internal node as child of proxy") + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, NULL, + "unable to add v2 B-tree internal node as child of proxy") internal->top_proxy = hdr->top_proxy; } /* end if */ /* Shadow the node, if requested */ - if(shadow) - if(H5B2__shadow_internal(internal, node_ptr) < 0) + if (shadow) + if (H5B2__shadow_internal(internal, node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, NULL, "unable to shadow internal node") /* Set return value */ @@ -236,26 +232,29 @@ H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, done: /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the internal node, if it was protected */ - if(internal) { + if (internal) { /* Remove from v2 B-tree's proxy, if added */ - if(internal->top_proxy) { - if(H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, NULL, "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy") + if (internal->top_proxy) { + if (H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) + HDONE_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, NULL, + "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy") internal->top_proxy = NULL; } /* end if */ /* Unprotect internal node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to unprotect v2 B-tree internal node, address = %llu", (unsigned long long)node_ptr->addr) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, + "unable to unprotect v2 B-tree internal node, address = %llu", + (unsigned long long)node_ptr->addr) } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__protect_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__neighbor_internal * @@ -283,14 +282,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - void *neighbor_loc, H5B2_compare_t comp, void *parent, void *udata, - H5B2_found_t op, void *op_data) +H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, + H5B2_compare_t comp, void *parent, void *udata, H5B2_found_t op, void *op_data) { - H5B2_internal_t *internal; /* Pointer to internal node */ - unsigned idx = 0; /* Location of record which matches key */ - int cmp = 0; /* Comparison value of records */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal; /* Pointer to internal node */ + unsigned idx = 0; /* Location of record which matches key */ + int cmp = 0; /* Comparison value of records */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -302,46 +300,51 @@ H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_n HDassert(op); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp > 0) + if (cmp > 0) idx++; /* Set the neighbor location, if appropriate */ - if(comp == H5B2_COMPARE_LESS) { - if(idx > 0) + if (comp == H5B2_COMPARE_LESS) { + if (idx > 0) neighbor_loc = H5B2_INT_NREC(internal, hdr, idx - 1); } /* end if */ else { HDassert(comp == H5B2_COMPARE_GREATER); - if(idx < internal->nrec) + if (idx < internal->nrec) neighbor_loc = H5B2_INT_NREC(internal, hdr, idx); } /* end else */ /* Attempt to find neighboring record */ - if(depth > 1) { - if(H5B2__neighbor_internal(hdr, (uint16_t)(depth - 1), &internal->node_ptrs[idx], neighbor_loc, comp, internal, udata, op, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree internal node") + if (depth > 1) { + if (H5B2__neighbor_internal(hdr, (uint16_t)(depth - 1), &internal->node_ptrs[idx], neighbor_loc, comp, + internal, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "unable to find neighbor record in B-tree internal node") } /* end if */ else { - if(H5B2__neighbor_leaf(hdr, &internal->node_ptrs[idx], neighbor_loc, comp, internal, udata, op, op_data) < 0) + if (H5B2__neighbor_leaf(hdr, &internal->node_ptrs[idx], neighbor_loc, comp, internal, udata, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree leaf node") } /* end else */ done: /* Release the B-tree internal node */ - if(internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (internal && + H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__neighbor_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__insert_internal * @@ -357,14 +360,13 @@ done: */ herr_t H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_info_flags_ptr, - H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, - void *udata) + H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, void *udata) { - H5B2_internal_t *internal = NULL; /* Pointer to internal node */ - unsigned internal_flags = H5AC__NO_FLAGS_SET; - unsigned idx = 0; /* Location of record which matches key */ - H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + unsigned idx = 0; /* Location of record which matches key */ + H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -375,7 +377,8 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Sanity check number of records */ @@ -383,17 +386,17 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in /* Split or redistribute child node pointers, if necessary */ { - int cmp; /* Comparison value of records */ - unsigned retries; /* Number of times to attempt redistribution */ - size_t split_nrec; /* Number of records to split node at */ + int cmp; /* Comparison value of records */ + unsigned retries; /* Number of times to attempt redistribution */ + size_t split_nrec; /* Number of records to split node at */ /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, - udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp == 0) + if (cmp == 0) HGOTO_ERROR(H5E_BTREE, H5E_EXISTS, FAIL, "record is already in B-tree") - if(cmp > 0) + if (cmp > 0) idx++; /* Set the number of redistribution retries */ @@ -408,74 +411,82 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in split_nrec = hdr->node_info[depth - 1].split_nrec; /* Preemptively split/redistribute a node we will enter */ - while(internal->node_ptrs[idx].node_nrec == split_nrec) { + while (internal->node_ptrs[idx].node_nrec == split_nrec) { /* Attempt to redistribute records among children */ - if(idx == 0) { /* Left-most child */ - if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec < split_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (idx == 0) { /* Left-most child */ + if (retries > 0 && (internal->node_ptrs[idx + 1].node_nrec < split_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node") - } /* end else */ - } /* end if */ - else if(idx == internal->nrec) { /* Right-most child */ - if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec < split_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + } /* end else */ + } /* end if */ + else if (idx == internal->nrec) { /* Right-most child */ + if (retries > 0 && (internal->node_ptrs[idx - 1].node_nrec < split_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node") - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Middle child */ - if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec < split_nrec) || - (internal->node_ptrs[idx - 1].node_nrec < split_nrec))) { - if(H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec < split_nrec) || + (internal->node_ptrs[idx - 1].node_nrec < split_nrec))) { + if (H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node") } /* end else */ - } /* end else */ + } /* end else */ /* Locate node pointer for child (after split/redistribute) */ - /* Actually, this can be easily updated (for 2-node redistrib.) and shouldn't require re-searching */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, - udata, &idx, &cmp) < 0) + /* Actually, this can be easily updated (for 2-node redistrib.) and shouldn't require re-searching + */ + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp == 0) + if (cmp == 0) HGOTO_ERROR(H5E_BTREE, H5E_EXISTS, FAIL, "record is already in B-tree") - if(cmp > 0) + if (cmp > 0) idx++; /* Decrement the number of redistribution retries left */ retries--; } /* end while */ - } /* end block */ + } /* end block */ /* Check if this node is left/right-most */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_LEFT; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_RIGHT; } /* end else */ - } /* end if */ + } /* end if */ /* Attempt to insert node */ - if(depth > 1) { - if(H5B2__insert_internal(hdr, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], next_pos, internal, udata) < 0) + if (depth > 1) { + if (H5B2__insert_internal(hdr, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], + next_pos, internal, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node") } /* end if */ else { - if(H5B2__insert_leaf(hdr, &internal->node_ptrs[idx], next_pos, internal, udata) < 0) + if (H5B2__insert_leaf(hdr, &internal->node_ptrs[idx], next_pos, internal, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node") } /* end else */ @@ -487,21 +498,20 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in done: /* Release the B-tree internal node */ - if(internal) { + if (internal) { /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) - if(H5B2__shadow_internal(internal, curr_node_ptr) < 0) + if (hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) + if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal B-tree node") /* Unprotect node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__insert_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__update_internal * @@ -519,17 +529,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, - unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *parent, - void *udata, H5B2_modify_t op, void *op_data) +H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, + void *parent, void *udata, H5B2_modify_t op, void *op_data) { - H5B2_internal_t *internal = NULL; /* Pointer to internal node */ - unsigned internal_flags = H5AC__NO_FLAGS_SET; - int cmp; /* Comparison value of records */ - unsigned idx = 0; /* Location of record which matches key */ - H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + int cmp; /* Comparison value of records */ + unsigned idx = 0; /* Location of record which matches key */ + H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -540,26 +549,29 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Sanity check number of records */ HDassert(internal->nrec == curr_node_ptr->node_nrec); /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Check for modifying existing record */ - if(0 == cmp) { - hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ + if (0 == cmp) { + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ /* Make callback for current record */ - if((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { + if ((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed == FALSE); - HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree update operation") + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, + "'modify' callback failed for B-tree update operation") } /* end if */ /* Mark the node as dirty if it changed */ @@ -570,43 +582,47 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, } /* end if */ else { /* Adjust index to leave room for node to insert */ - if(cmp > 0) + if (cmp > 0) idx++; /* Check if this node is left/right-most */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_LEFT; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_RIGHT; } /* end else */ - } /* end if */ + } /* end if */ /* Attempt to update record in child */ - if(depth > 1) { - if(H5B2__update_internal(hdr, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], status, next_pos, internal, udata, op, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in internal B-tree node") + if (depth > 1) { + if (H5B2__update_internal(hdr, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], + status, next_pos, internal, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, + "unable to update record in internal B-tree node") } /* end if */ else { - if(H5B2__update_leaf(hdr, &internal->node_ptrs[idx], status, next_pos, internal, udata, op, op_data) < 0) + if (H5B2__update_leaf(hdr, &internal->node_ptrs[idx], status, next_pos, internal, udata, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in leaf B-tree node") } /* end else */ /* Take actions based on child's status report */ - switch(*status) { + switch (*status) { case H5B2_UPDATE_MODIFY_DONE: /* No action */ break; case H5B2_UPDATE_SHADOW_DONE: /* If child node was shadowed (if SWMR is enabled), mark this node dirty */ - if(hdr->swmr_write) + if (hdr->swmr_write) internal_flags |= H5AC__DIRTIED_FLAG; - /* No further modifications up the tree are necessary though, so downgrade to merely "modified" */ + /* No further modifications up the tree are necessary though, so downgrade to merely + * "modified" */ *status = H5B2_UPDATE_MODIFY_DONE; break; @@ -620,29 +636,30 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, case H5B2_UPDATE_INSERT_CHILD_FULL: /* Split/redistribute this node */ - if(internal->nrec == hdr->node_info[depth].split_nrec) { - hbool_t could_split = FALSE; /* Whether the child node could split */ + if (internal->nrec == hdr->node_info[depth].split_nrec) { + hbool_t could_split = FALSE; /* Whether the child node could split */ - if(idx == 0) { /* Left-most child */ + if (idx == 0) { /* Left-most child */ /* Check for left-most child and its neighbor being close to full */ - if((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) - >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + if ((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) >= + ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) could_split = TRUE; - } /* end if */ - else if(idx == internal->nrec) { /* Right-most child */ + } /* end if */ + else if (idx == internal->nrec) { /* Right-most child */ /* Check for right-most child and its neighbor being close to full */ - if((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) - >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + if ((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) >= + ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) could_split = TRUE; - } /* end else-if */ - else { /* Middle child */ + } /* end else-if */ + else { /* Middle child */ /* Check for middle child and its left neighbor being close to full */ - if((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) - >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + if ((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) >= + ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) could_split = TRUE; /* Check for middle child and its right neighbor being close to full */ - else if((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) - >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + else if ((internal->node_ptrs[idx].node_nrec + + internal->node_ptrs[idx + 1].node_nrec) >= + ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) could_split = TRUE; } /* end if */ @@ -650,19 +667,21 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, * cause a split, punt back up to caller, leaving the * "insert child full" status. */ - if(could_split) { + if (could_split) { /* Release the internal B-tree node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, + internal_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, + "unable to release internal B-tree node") internal = NULL; /* Punt back to caller */ HGOTO_DONE(SUCCEED); } /* end if */ - } /* end if */ + } /* end if */ /* Release the internal B-tree node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") internal = NULL; @@ -670,8 +689,10 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, *status = H5B2_UPDATE_INSERT_DONE; /* Dodge sideways into inserting a record into this node */ - if(H5B2__insert_internal(hdr, depth, parent_cache_info_flags_ptr, curr_node_ptr, curr_pos, parent, udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into internal B-tree node") + if (H5B2__insert_internal(hdr, depth, parent_cache_info_flags_ptr, curr_node_ptr, curr_pos, + parent, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, + "unable to insert record into internal B-tree node") break; case H5B2_UPDATE_UNKNOWN: @@ -679,32 +700,31 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, HDassert(0 && "Invalid update status"); HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "invalid update status") } /* end switch */ - } /* end else */ + } /* end else */ done: /* Release the internal B-tree node */ - if(internal) { + if (internal) { /* Check if we should shadow this node */ - if(hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) { + if (hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) { /* Attempt to shadow the node if doing SWMR writes */ - if(H5B2__shadow_internal(internal, curr_node_ptr) < 0) + if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal B-tree node") /* Change the state to "shadowed" if only modified currently */ /* (Triggers parent to be marked dirty) */ - if(*status == H5B2_UPDATE_MODIFY_DONE) + if (*status == H5B2_UPDATE_MODIFY_DONE) *status = H5B2_UPDATE_SHADOW_DONE; } /* end if */ /* Unprotect node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__update_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__shadow_internal * @@ -724,8 +744,8 @@ done: static herr_t H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr) { - H5B2_hdr_t *hdr; /* B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -744,8 +764,8 @@ H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr) * the readers so there will be no need to shadow. To check if it has been * shadowed, compare the epoch of this node and the header. If this node's * epoch is <= to the header's, it hasn't been shadowed yet. */ - if(internal->shadow_epoch <= hdr->shadow_epoch) { - haddr_t new_node_addr; /* Address to move node to */ + if (internal->shadow_epoch <= hdr->shadow_epoch) { + haddr_t new_node_addr; /* Address to move node to */ /* * We must clone the old node so readers with an out-of-date version of @@ -753,11 +773,11 @@ H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr) * shadowed node. Remove it from cache but do not mark it free on disk. */ /* Allocate space for the cloned node */ - if(HADDR_UNDEF == (new_node_addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) + if (HADDR_UNDEF == (new_node_addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move B-tree node") /* Move the location of the node on the disk */ - if(H5AC_move_entry(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, new_node_addr) < 0) + if (H5AC_move_entry(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, new_node_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMOVE, FAIL, "unable to move B-tree node") curr_node_ptr->addr = new_node_addr; @@ -773,7 +793,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__shadow_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__remove_internal * @@ -788,21 +807,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, - void *swap_loc, void *swap_parent, uint16_t depth, H5AC_info_t *parent_cache_info, - unsigned *parent_cache_info_flags_ptr, H5B2_nodepos_t curr_pos, - H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, void *op_data) +H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, void *swap_parent, + uint16_t depth, H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr, + H5B2_nodepos_t curr_pos, H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, + void *op_data) { - H5AC_info_t *new_cache_info; /* Pointer to new cache info */ - unsigned *new_cache_info_flags_ptr = NULL; - H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */ - H5B2_internal_t *internal; /* Pointer to internal node */ - H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of next node */ - unsigned internal_flags = H5AC__NO_FLAGS_SET; - haddr_t internal_addr = HADDR_UNDEF; /* Address of internal node */ - size_t merge_nrec; /* Number of records to merge node at */ - hbool_t collapsed_root = FALSE; /* Whether the root was collapsed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t * new_cache_info; /* Pointer to new cache info */ + unsigned * new_cache_info_flags_ptr = NULL; + H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */ + H5B2_internal_t *internal; /* Pointer to internal node */ + H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of next node */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + haddr_t internal_addr = HADDR_UNDEF; /* Address of internal node */ + size_t merge_nrec; /* Number of records to merge node at */ + hbool_t collapsed_root = FALSE; /* Whether the root was collapsed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -814,7 +833,8 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent_cache_info, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent_cache_info, curr_node_ptr, depth, FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") internal_addr = curr_node_ptr->addr; @@ -823,34 +843,35 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, /* Check for needing to collapse the root node */ /* (The root node is the only internal node allowed to have 1 record) */ - if(internal->nrec == 1 && - ((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) { + if (internal->nrec == 1 && + ((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) { /* Merge children of root node */ - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, 0) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, + 0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") /* Let the cache know that the object is deleted */ internal_flags |= H5AC__DELETED_FLAG; - if(!hdr->swmr_write) + if (!hdr->swmr_write) internal_flags |= H5AC__FREE_FILE_SPACE_FLAG; /* Reset information in header's root node pointer */ - curr_node_ptr->addr = internal->node_ptrs[0].addr; + curr_node_ptr->addr = internal->node_ptrs[0].addr; curr_node_ptr->node_nrec = internal->node_ptrs[0].node_nrec; /* Update flush dependency for child, if using SWMR */ - if(hdr->swmr_write) - if(H5B2__update_flush_depend(hdr, depth, curr_node_ptr, internal, hdr) < 0) + if (hdr->swmr_write) + if (H5B2__update_flush_depend(hdr, depth, curr_node_ptr, internal, hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child node to new parent") /* Indicate that the level of the B-tree decreased */ *depth_decreased = TRUE; /* Set pointers for advancing to child node */ - new_cache_info = parent_cache_info; + new_cache_info = parent_cache_info; new_cache_info_flags_ptr = parent_cache_info_flags_ptr; - new_node_ptr = curr_node_ptr; + new_node_ptr = curr_node_ptr; /* Set flag to indicate root was collapsed */ collapsed_root = TRUE; @@ -860,24 +881,25 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, } /* end if */ /* Merge or redistribute child node pointers, if necessary */ else { - unsigned idx = 0; /* Location of record which matches key */ - int cmp = 0; /* Comparison value of records */ - unsigned retries; /* Number of times to attempt redistribution */ + unsigned idx = 0; /* Location of record which matches key */ + int cmp = 0; /* Comparison value of records */ + unsigned retries; /* Number of times to attempt redistribution */ /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write) { - if(H5B2__shadow_internal(internal, curr_node_ptr) < 0) + if (hdr->swmr_write) { + if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal node") internal_addr = curr_node_ptr->addr; } /* end if */ /* Locate node pointer for child */ - if(swap_loc) + if (swap_loc) idx = 0; else { - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp >= 0) + if (cmp >= 0) idx++; } /* end else */ @@ -890,7 +912,7 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, retries = 2; /* Preemptively merge/redistribute a node we will enter */ - while(internal->node_ptrs[idx].node_nrec == merge_nrec) { + while (internal->node_ptrs[idx].node_nrec == merge_nrec) { /* Attempt to redistribute records among children */ /* (NOTE: These 2-node redistributions should actually get the * record to promote from the node with more records. - QAK) @@ -898,46 +920,54 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, /* (NOTE: This code is the same in both H5B2__remove_internal() and * H5B2__remove_internal_by_idx(), fix bugs in both places! - QAK) */ - if(idx == 0) { /* Left-most child */ - if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (idx == 0) { /* Left-most child */ + if (retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") - } /* end else */ - } /* end if */ - else if(idx == internal->nrec) { /* Right-most child */ - if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + } /* end else */ + } /* end if */ + else if (idx == internal->nrec) { /* Right-most child */ + if (retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, (idx - 1)) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, (idx - 1)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Middle child */ - if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) || - (internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) { - if(H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) || + (internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) { + if (H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge3(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__merge3(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") } /* end else */ - } /* end else */ + } /* end else */ /* Locate node pointer for child (after merge/redistribute) */ - if(swap_loc) + if (swap_loc) idx = 0; else { -/* Actually, this can be easily updated (for 2-node redistrib.) and shouldn't require re-searching */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) + /* Actually, this can be easily updated (for 2-node redistrib.) and shouldn't require + * re-searching */ + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, + &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp >= 0) + if (cmp >= 0) idx++; } /* end else */ @@ -946,66 +976,67 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, } /* end while */ /* Handle deleting a record from an internal node */ - if(!swap_loc && cmp == 0) { - swap_loc = H5B2_INT_NREC(internal, hdr, idx - 1); + if (!swap_loc && cmp == 0) { + swap_loc = H5B2_INT_NREC(internal, hdr, idx - 1); swap_parent = internal; } /* end if */ /* Swap record to delete with record from leaf, if we are the last internal node */ - if(swap_loc && depth == 1) - if(H5B2__swap_leaf(hdr, depth, internal, &internal_flags, idx, swap_loc) < 0) + if (swap_loc && depth == 1) + if (H5B2__swap_leaf(hdr, depth, internal, &internal_flags, idx, swap_loc) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSWAP, FAIL, "Can't swap records in B-tree") /* Set pointers for advancing to child node */ new_cache_info_flags_ptr = &internal_flags; - new_cache_info = &internal->cache_info; - new_node_ptr = &internal->node_ptrs[idx]; + new_cache_info = &internal->cache_info; + new_node_ptr = &internal->node_ptrs[idx]; /* Indicate position of next node */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_LEFT; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_RIGHT; } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Attempt to remove record from child node */ - if(depth > 1) { - if(H5B2__remove_internal(hdr, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), - new_cache_info, new_cache_info_flags_ptr, next_pos, new_node_ptr, udata, op, op_data) < 0) + if (depth > 1) { + if (H5B2__remove_internal(hdr, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), + new_cache_info, new_cache_info_flags_ptr, next_pos, new_node_ptr, udata, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") } /* end if */ else { - if(H5B2__remove_leaf(hdr, new_node_ptr, next_pos, new_cache_info, udata, op, op_data) < 0) + if (H5B2__remove_leaf(hdr, new_node_ptr, next_pos, new_cache_info, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node") } /* end else */ /* Update record count for node pointer to current node */ - if(!collapsed_root) + if (!collapsed_root) new_node_ptr->all_nrec--; /* Mark node as dirty */ - if(!(hdr->swmr_write && collapsed_root)) + if (!(hdr->swmr_write && collapsed_root)) internal_flags |= H5AC__DIRTIED_FLAG; #ifdef H5B2_DEBUG - H5B2__assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec - 1) : new_node_ptr->all_nrec), hdr, internal); + H5B2__assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec - 1) : new_node_ptr->all_nrec), hdr, + internal); #endif /* H5B2_DEBUG */ done: /* Release the B-tree internal node */ - if(internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) + if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__remove_internal_by_idx * @@ -1021,21 +1052,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, - void *swap_loc, void *swap_parent, uint16_t depth, H5AC_info_t *parent_cache_info, - unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, hsize_t n, H5B2_remove_t op, void *op_data) +H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, void *swap_parent, + uint16_t depth, H5AC_info_t *parent_cache_info, + unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, + H5B2_nodepos_t curr_pos, hsize_t n, H5B2_remove_t op, void *op_data) { - H5AC_info_t *new_cache_info; /* Pointer to new cache info */ - unsigned *new_cache_info_flags_ptr = NULL; - H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */ - H5B2_internal_t *internal; /* Pointer to internal node */ - H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of next node */ - unsigned internal_flags = H5AC__NO_FLAGS_SET; - haddr_t internal_addr = HADDR_UNDEF; /* Address of internal node */ - size_t merge_nrec; /* Number of records to merge node at */ - hbool_t collapsed_root = FALSE; /* Whether the root was collapsed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t * new_cache_info; /* Pointer to new cache info */ + unsigned * new_cache_info_flags_ptr = NULL; + H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */ + H5B2_internal_t *internal; /* Pointer to internal node */ + H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of next node */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + haddr_t internal_addr = HADDR_UNDEF; /* Address of internal node */ + size_t merge_nrec; /* Number of records to merge node at */ + hbool_t collapsed_root = FALSE; /* Whether the root was collapsed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1047,7 +1078,8 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent_cache_info, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent_cache_info, curr_node_ptr, depth, FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") internal_addr = curr_node_ptr->addr; HDassert(internal->nrec == curr_node_ptr->node_nrec); @@ -1058,35 +1090,36 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, /* Check for needing to collapse the root node */ /* (The root node is the only internal node allowed to have 1 record) */ - if(internal->nrec == 1 && - ((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) { + if (internal->nrec == 1 && + ((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) { HDassert(depth == hdr->depth); /* Merge children of root node */ - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, 0) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, + 0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") /* Let the cache know that the object is deleted */ internal_flags |= H5AC__DELETED_FLAG; - if(!hdr->swmr_write) + if (!hdr->swmr_write) internal_flags |= H5AC__FREE_FILE_SPACE_FLAG; /* Reset information in header's root node pointer */ - curr_node_ptr->addr = internal->node_ptrs[0].addr; + curr_node_ptr->addr = internal->node_ptrs[0].addr; curr_node_ptr->node_nrec = internal->node_ptrs[0].node_nrec; /* Update flush dependency for child, if using SWMR */ - if(hdr->swmr_write) - if(H5B2__update_flush_depend(hdr, depth, curr_node_ptr, internal, hdr) < 0) + if (hdr->swmr_write) + if (H5B2__update_flush_depend(hdr, depth, curr_node_ptr, internal, hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child node to new parent") /* Indicate that the level of the B-tree decreased */ *depth_decreased = TRUE; /* Set pointers for advancing to child node */ - new_cache_info = parent_cache_info; + new_cache_info = parent_cache_info; new_cache_info_flags_ptr = parent_cache_info_flags_ptr; - new_node_ptr = curr_node_ptr; + new_node_ptr = curr_node_ptr; /* Set flag to indicate root was collapsed */ collapsed_root = TRUE; @@ -1096,33 +1129,33 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, } /* end if */ /* Merge or redistribute child node pointers, if necessary */ else { - hsize_t orig_n = n; /* Original index looked for */ + hsize_t orig_n = n; /* Original index looked for */ unsigned idx; /* Location of record which matches key */ - hbool_t found = FALSE; /* Comparison value of records */ + hbool_t found = FALSE; /* Comparison value of records */ unsigned retries; /* Number of times to attempt redistribution */ /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write) { - if(H5B2__shadow_internal(internal, curr_node_ptr) < 0) + if (hdr->swmr_write) { + if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal node") internal_addr = curr_node_ptr->addr; } /* end if */ /* Locate node pointer for child */ - if(swap_loc) + if (swap_loc) idx = 0; else { /* Search for record with correct index */ - for(idx = 0; idx < internal->nrec; idx++) { + for (idx = 0; idx < internal->nrec; idx++) { /* Check which child node contains indexed record */ - if(internal->node_ptrs[idx].all_nrec >= n) { + if (internal->node_ptrs[idx].all_nrec >= n) { /* Check if record is in this node */ - if(internal->node_ptrs[idx].all_nrec == n) { + if (internal->node_ptrs[idx].all_nrec == n) { /* Indicate the record was found and that the index * in child nodes is zero from now on */ found = TRUE; - n = 0; + n = 0; /* Increment to next record */ idx++; @@ -1137,7 +1170,7 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, */ n -= (internal->node_ptrs[idx].all_nrec + 1); } /* end for */ - } /* end else */ + } /* end else */ /* Set the number of redistribution retries */ /* This takes care of the case where a B-tree node needs to be @@ -1148,7 +1181,7 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, retries = 2; /* Preemptively merge/redistribute a node we will enter */ - while(internal->node_ptrs[idx].node_nrec == merge_nrec) { + while (internal->node_ptrs[idx].node_nrec == merge_nrec) { /* Attempt to redistribute records among children */ /* (NOTE: These 2-node redistributions should actually get the * record to promote from the node with more records. - QAK) @@ -1156,40 +1189,46 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, /* (NOTE: This code is the same in both H5B2__remove_internal() and * H5B2__remove_internal_by_idx(), fix bugs in both places! - QAK) */ - if(idx == 0) { /* Left-most child */ - if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (idx == 0) { /* Left-most child */ + if (retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") - } /* end else */ - } /* end if */ - else if(idx == internal->nrec) { /* Right-most child */ - if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + } /* end else */ + } /* end if */ + else if (idx == internal->nrec) { /* Right-most child */ + if (retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, (idx - 1)) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, (idx - 1)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Middle child */ - if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) || - (internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) { - if(H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) || + (internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) { + if (H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge3(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__merge3(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") } /* end else */ - } /* end else */ + } /* end else */ /* Locate node pointer for child (after merge/redistribute) */ - if(swap_loc) + if (swap_loc) idx = 0; else { /* Count from the original index value again */ @@ -1201,16 +1240,16 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, found = FALSE; /* Search for record with correct index */ - for(idx = 0; idx < internal->nrec; idx++) { + for (idx = 0; idx < internal->nrec; idx++) { /* Check which child node contains indexed record */ - if(internal->node_ptrs[idx].all_nrec >= n) { + if (internal->node_ptrs[idx].all_nrec >= n) { /* Check if record is in this node */ - if(internal->node_ptrs[idx].all_nrec == n) { + if (internal->node_ptrs[idx].all_nrec == n) { /* Indicate the record was found and that the index * in child nodes is zero from now on */ found = TRUE; - n = 0; + n = 0; /* Increment to next record */ idx++; @@ -1225,73 +1264,75 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, */ n -= (internal->node_ptrs[idx].all_nrec + 1); } /* end for */ - } /* end else */ + } /* end else */ /* Decrement the number of redistribution retries left */ retries--; } /* end while */ /* Handle deleting a record from an internal node */ - if(!swap_loc && found) { - swap_loc = H5B2_INT_NREC(internal, hdr, idx - 1); + if (!swap_loc && found) { + swap_loc = H5B2_INT_NREC(internal, hdr, idx - 1); swap_parent = internal; } /* end if */ /* Swap record to delete with record from leaf, if we are the last internal node */ - if(swap_loc && depth == 1) - if(H5B2__swap_leaf(hdr, depth, internal, &internal_flags, idx, swap_loc) < 0) + if (swap_loc && depth == 1) + if (H5B2__swap_leaf(hdr, depth, internal, &internal_flags, idx, swap_loc) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSWAP, FAIL, "can't swap records in B-tree") /* Set pointers for advancing to child node */ new_cache_info_flags_ptr = &internal_flags; - new_cache_info = &internal->cache_info; - new_node_ptr = &internal->node_ptrs[idx]; + new_cache_info = &internal->cache_info; + new_node_ptr = &internal->node_ptrs[idx]; /* Indicate position of next node */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_LEFT; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_RIGHT; } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Attempt to remove record from child node */ - if(depth > 1) { - if(H5B2__remove_internal_by_idx(hdr, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), - new_cache_info, new_cache_info_flags_ptr, new_node_ptr, next_pos, n, op, op_data) < 0) + if (depth > 1) { + if (H5B2__remove_internal_by_idx(hdr, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), + new_cache_info, new_cache_info_flags_ptr, new_node_ptr, next_pos, n, + op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") } /* end if */ else { - if(H5B2__remove_leaf_by_idx(hdr, new_node_ptr, next_pos, new_cache_info, (unsigned)n, op, op_data) < 0) + if (H5B2__remove_leaf_by_idx(hdr, new_node_ptr, next_pos, new_cache_info, (unsigned)n, op, op_data) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node") } /* end else */ /* Update record count for node pointer to child node */ - if(!collapsed_root) + if (!collapsed_root) new_node_ptr->all_nrec--; /* Mark node as dirty */ - if(!(hdr->swmr_write && collapsed_root)) + if (!(hdr->swmr_write && collapsed_root)) internal_flags |= H5AC__DIRTIED_FLAG; #ifdef H5B2_DEBUG - H5B2__assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec - 1) : new_node_ptr->all_nrec), hdr, internal); + H5B2__assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec - 1) : new_node_ptr->all_nrec), hdr, + internal); #endif /* H5B2_DEBUG */ done: /* Release the B-tree internal node */ - if(internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) + if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_internal_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5B2__internal_free * @@ -1308,7 +1349,7 @@ done: herr_t H5B2__internal_free(H5B2_internal_t *internal) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1318,16 +1359,18 @@ H5B2__internal_free(H5B2_internal_t *internal) HDassert(internal); /* Release internal node's native key buffer */ - if(internal->int_native) - internal->int_native = (uint8_t *)H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].nat_rec_fac, internal->int_native); + if (internal->int_native) + internal->int_native = (uint8_t *)H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].nat_rec_fac, + internal->int_native); /* Release internal node's node pointer buffer */ - if(internal->node_ptrs) - internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); + if (internal->node_ptrs) + internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_FREE( + internal->hdr->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); /* Decrement ref. count on B-tree header */ - if(H5B2__hdr_decr(internal->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") + if (H5B2__hdr_decr(internal->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") /* Sanity check */ HDassert(NULL == internal->top_proxy); @@ -1340,7 +1383,7 @@ done: } /* end H5B2__internal_free() */ #ifdef H5B2_DEBUG - + /*------------------------------------------------------------------------- * Function: H5B2__assert_internal * @@ -1355,33 +1398,33 @@ done: *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_internal_t *internal) +H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, + const H5B2_internal_t *internal) { - hsize_t tot_all_nrec; /* Total number of records at or below this node */ - uint16_t u, v; /* Local index variables */ + hsize_t tot_all_nrec; /* Total number of records at or below this node */ + uint16_t u, v; /* Local index variables */ /* General sanity checking on node */ HDassert(internal->nrec <= hdr->node_info->split_nrec); /* Sanity checking on node pointers */ tot_all_nrec = internal->nrec; - for(u = 0; u < internal->nrec + 1; u++) { + for (u = 0; u < internal->nrec + 1; u++) { tot_all_nrec += internal->node_ptrs[u].all_nrec; HDassert(H5F_addr_defined(internal->node_ptrs[u].addr)); HDassert(internal->node_ptrs[u].addr > 0); - for(v = 0; v < u; v++) + for (v = 0; v < u; v++) HDassert(internal->node_ptrs[u].addr != internal->node_ptrs[v].addr); } /* end for */ /* Sanity check all_nrec total in parent */ - if(parent_all_nrec > 0) + if (parent_all_nrec > 0) HDassert(tot_all_nrec == parent_all_nrec); - return(0); + return (0); } /* end H5B2__assert_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__assert_internal2 * @@ -1396,32 +1439,32 @@ H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_U *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_internal_t *internal, const H5B2_internal_t *internal2) +H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, + const H5B2_internal_t *internal, const H5B2_internal_t *internal2) { - hsize_t tot_all_nrec; /* Total number of records at or below this node */ - uint16_t u, v; /* Local index variables */ + hsize_t tot_all_nrec; /* Total number of records at or below this node */ + uint16_t u, v; /* Local index variables */ /* General sanity checking on node */ HDassert(internal->nrec <= hdr->node_info->split_nrec); /* Sanity checking on node pointers */ - tot_all_nrec =internal->nrec; - for(u =0; u < internal->nrec + 1; u++) { + tot_all_nrec = internal->nrec; + for (u = 0; u < internal->nrec + 1; u++) { tot_all_nrec += internal->node_ptrs[u].all_nrec; HDassert(H5F_addr_defined(internal->node_ptrs[u].addr)); HDassert(internal->node_ptrs[u].addr > 0); - for(v = 0; v < u; v++) + for (v = 0; v < u; v++) HDassert(internal->node_ptrs[u].addr != internal->node_ptrs[v].addr); - for(v = 0; v < internal2->nrec + 1; v++) + for (v = 0; v < internal2->nrec + 1; v++) HDassert(internal->node_ptrs[u].addr != internal2->node_ptrs[v].addr); } /* end for */ /* Sanity check all_nrec total in parent */ - if(parent_all_nrec > 0) + if (parent_all_nrec > 0) HDassert(tot_all_nrec == parent_all_nrec); - return(0); + return (0); } /* end H5B2__assert_internal2() */ #endif /* H5B2_DEBUG */ - diff --git a/src/H5B2leaf.c b/src/H5B2leaf.c index 1fde36d..bdacdf9 100644 --- a/src/H5B2leaf.c +++ b/src/H5B2leaf.c @@ -26,40 +26,34 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_ptr); - /*********************/ /* Package Variables */ /*********************/ @@ -67,18 +61,14 @@ static herr_t H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_pt /* Declare a free list to manage the H5B2_leaf_t struct */ H5FL_DEFINE(H5B2_leaf_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B2__create_leaf * @@ -96,9 +86,9 @@ H5FL_DEFINE(H5B2_leaf_t); herr_t H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr) { - H5B2_leaf_t *leaf = NULL; /* Pointer to new leaf node created */ - hbool_t inserted = FALSE; /* Whether the leaf node was inserted into cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf = NULL; /* Pointer to new leaf node created */ + hbool_t inserted = FALSE; /* Whether the leaf node was inserted into cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -107,18 +97,18 @@ H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr) HDassert(node_ptr); /* Allocate memory for leaf information */ - if(NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf info") + if (NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf info") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(hdr) < 0) + if (H5B2__hdr_incr(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, FAIL, "can't increment ref. count on B-tree header") /* Share B-tree header information */ leaf->hdr = hdr; /* Allocate space for the native keys in memory */ - if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[0].nat_rec_fac))) + if (NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[0].nat_rec_fac))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf native keys") HDmemset(leaf->leaf_native, 0, hdr->cls->nrec_size * hdr->node_info[0].max_nrec); @@ -129,43 +119,45 @@ H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr) leaf->shadow_epoch = hdr->shadow_epoch; /* Allocate space on disk for the leaf */ - if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) + if (HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree leaf node") /* Cache the new B-tree node */ - if(H5AC_insert_entry(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree leaf to cache") inserted = TRUE; /* Add leaf node as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, leaf) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, FAIL, "unable to add v2 B-tree node as child of proxy") leaf->top_proxy = hdr->top_proxy; } /* end if */ done: - if(ret_value < 0) { - if(leaf) { + if (ret_value < 0) { + if (leaf) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(leaf) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, "unable to remove v2 B-tree leaf node from cache") + if (inserted) + if (H5AC_remove_entry(leaf) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, + "unable to remove v2 B-tree leaf node from cache") /* Release leaf node's disk space */ - if(H5F_addr_defined(node_ptr->addr) && H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release file space for v2 B-tree leaf node") + if (H5F_addr_defined(node_ptr->addr) && + H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, + "unable to release file space for v2 B-tree leaf node") /* Destroy leaf node */ - if(H5B2__leaf_free(leaf) < 0) + if (H5B2__leaf_free(leaf) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree leaf node") } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__create_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__protect_leaf * @@ -180,12 +172,11 @@ done: *------------------------------------------------------------------------- */ H5B2_leaf_t * -H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, - hbool_t shadow, unsigned flags) +H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, hbool_t shadow, unsigned flags) { - H5B2_leaf_cache_ud_t udata; /* User-data for callback */ - H5B2_leaf_t *leaf; /* v2 B-tree leaf node */ - H5B2_leaf_t *ret_value = NULL; /* Return value */ + H5B2_leaf_cache_ud_t udata; /* User-data for callback */ + H5B2_leaf_t * leaf; /* v2 B-tree leaf node */ + H5B2_leaf_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -198,26 +189,26 @@ H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for callback */ - udata.f = hdr->f; - udata.hdr = hdr; + udata.f = hdr->f; + udata.hdr = hdr; udata.parent = parent; - udata.nrec = node_ptr->node_nrec; + udata.nrec = node_ptr->node_nrec; /* Protect the leaf node */ - if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, &udata, flags))) + if (NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, &udata, flags))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect B-tree leaf node") /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == leaf->top_proxy) { + if (hdr->top_proxy && NULL == leaf->top_proxy) { /* Add leaf node as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, leaf) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, NULL, "unable to add v2 B-tree leaf node as child of proxy") leaf->top_proxy = hdr->top_proxy; } /* end if */ /* Shadow the node, if requested */ - if(shadow) - if(H5B2__shadow_leaf(leaf, node_ptr) < 0) + if (shadow) + if (H5B2__shadow_leaf(leaf, node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, NULL, "unable to shadow leaf node") /* Set return value */ @@ -225,26 +216,29 @@ H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, done: /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the leaf node, if it was protected */ - if(leaf) { + if (leaf) { /* Remove from v2 B-tree's proxy, if added */ - if(leaf->top_proxy) { - if(H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, NULL, "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") + if (leaf->top_proxy) { + if (H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) + HDONE_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, NULL, + "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") leaf->top_proxy = NULL; } /* end if */ /* Unprotect leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to unprotect v2 B-tree leaf node, address = %llu", (unsigned long long)node_ptr->addr) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, + "unable to unprotect v2 B-tree leaf node, address = %llu", + (unsigned long long)node_ptr->addr) } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__protect_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__neighbor_leaf * @@ -272,14 +266,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - void *neighbor_loc, H5B2_compare_t comp, void *parent, void *udata, H5B2_found_t op, - void *op_data) +H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, H5B2_compare_t comp, + void *parent, void *udata, H5B2_found_t op, void *op_data) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - unsigned idx = 0; /* Location of record which matches key */ - int cmp = 0; /* Comparison value of records */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + unsigned idx = 0; /* Location of record which matches key */ + int cmp = 0; /* Comparison value of records */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -290,48 +283,47 @@ H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(op); /* Lock current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp > 0) + if (cmp > 0) + idx++; + else if (cmp == 0 && comp == H5B2_COMPARE_GREATER) idx++; - else - if(cmp == 0 && comp == H5B2_COMPARE_GREATER) - idx++; /* Set the neighbor location, if appropriate */ - if(comp == H5B2_COMPARE_LESS) { - if(idx > 0) + if (comp == H5B2_COMPARE_LESS) { + if (idx > 0) neighbor_loc = H5B2_LEAF_NREC(leaf, hdr, idx - 1); } /* end if */ else { HDassert(comp == H5B2_COMPARE_GREATER); - if(idx < leaf->nrec) + if (idx < leaf->nrec) neighbor_loc = H5B2_LEAF_NREC(leaf, hdr, idx); } /* end else */ /* Make callback if neighbor record has been found */ - if(neighbor_loc) { + if (neighbor_loc) { /* Make callback for current record */ - if((op)(neighbor_loc, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree neighbor operation") + if ((op)(neighbor_loc, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree neighbor operation") } /* end if */ else HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree") done: /* Release the B-tree leaf node */ - if(leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__neighbor_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__insert_leaf * @@ -346,14 +338,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata) +H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, + void *udata) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ - int cmp; /* Comparison value of records */ - unsigned idx = 0; /* Location of record which matches key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ + int cmp; /* Comparison value of records */ + unsigned idx = 0; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -363,7 +355,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Must have a leaf node with enough space to insert a record now */ @@ -374,24 +366,25 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(leaf->nrec == curr_node_ptr->node_nrec); /* Check for inserting into empty leaf */ - if(leaf->nrec == 0) + if (leaf->nrec == 0) idx = 0; else { /* Find correct location to insert this record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp == 0) + if (cmp == 0) HGOTO_ERROR(H5E_BTREE, H5E_EXISTS, FAIL, "record is already in B-tree") - if(cmp > 0) + if (cmp > 0) idx++; /* Make room for new record */ - if(idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size * (leaf->nrec - idx)); + if (idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), + hdr->cls->nrec_size * (leaf->nrec - idx)); } /* end else */ /* Make callback to store record in native form */ - if((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) + if ((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into leaf node") /* Mark the node as dirty */ @@ -406,42 +399,43 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, /* Check for new record being the min or max for the tree */ /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec == NULL) + if (NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree min record info") H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec == NULL) + if (NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree max record info") H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Release the B-tree leaf node (marked as dirty) */ - if(leaf) { + if (leaf) { /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) - if(H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) + if (hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) + if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf B-tree node") /* Unprotect leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__insert_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__update_leaf * @@ -459,15 +453,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *parent, - void *udata, H5B2_modify_t op, void *op_data) +H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_modify_t op, void *op_data) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ - int cmp = -1; /* Comparison value of records */ - unsigned idx = 0; /* Location of record which matches key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ + int cmp = -1; /* Comparison value of records */ + unsigned idx = 0; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -477,7 +470,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Sanity check number of records */ @@ -485,17 +478,17 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(leaf->nrec == curr_node_ptr->node_nrec); /* Check for inserting into empty leaf */ - if(leaf->nrec == 0) + if (leaf->nrec == 0) idx = 0; else { /* Find correct location to insert this record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Check for inserting a record */ - if(0 != cmp) { + if (0 != cmp) { /* Check if the leaf node is full */ - if(curr_node_ptr->node_nrec == hdr->node_info[0].split_nrec) { + if (curr_node_ptr->node_nrec == hdr->node_info[0].split_nrec) { /* Indicate that the leaf is full, but we need to insert */ *status = H5B2_UPDATE_INSERT_CHILD_FULL; @@ -504,25 +497,27 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, } /* end if */ /* Adjust index to leave room for record to insert */ - if(cmp > 0) + if (cmp > 0) idx++; /* Make room for new record */ - if(idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size * (leaf->nrec - idx)); + if (idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), + hdr->cls->nrec_size * (leaf->nrec - idx)); } /* end if */ - } /* end else */ + } /* end else */ /* Check for modifying existing record */ - if(0 == cmp) { - hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ + if (0 == cmp) { + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ /* Make callback for current record */ - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed == FALSE); - HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree update operation") + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, + "'modify' callback failed for B-tree update operation") } /* end if */ /* Mark the node as dirty if it changed */ @@ -536,7 +531,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(curr_node_ptr->node_nrec < hdr->node_info[0].max_nrec); /* Make callback to store record in native form */ - if((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) + if ((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into leaf node") /* Mark the node as dirty */ @@ -555,49 +550,50 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, /* Check for new record being the min or max for the tree */ /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec == NULL) + if (NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree min record info") H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec == NULL) + if (NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree max record info") H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Release the B-tree leaf node */ - if(leaf) { + if (leaf) { /* Check if we should shadow this node */ - if(hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) { + if (hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) { /* Attempt to shadow the node if doing SWMR writes */ - if(H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) + if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf B-tree node") /* Change the state to "shadowed" if only modified currently */ /* (Triggers parent to be marked dirty) */ - if(*status == H5B2_UPDATE_MODIFY_DONE) + if (*status == H5B2_UPDATE_MODIFY_DONE) *status = H5B2_UPDATE_SHADOW_DONE; } /* end if */ /* Unprotect leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__update_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__swap_leaf * @@ -614,14 +610,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx, void *swap_loc) +H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx, void *swap_loc) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t child_addr; /* Address of child node */ - void *child = NULL; /* Pointer to child node */ - uint8_t *child_native; /* Pointer to child's native records */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5AC_class_t *child_class; /* Pointer to child node's class info */ + haddr_t child_addr; /* Address of child node */ + void * child = NULL; /* Pointer to child node */ + uint8_t * child_native; /* Pointer to child's native records */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -632,34 +628,37 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, HDassert(idx <= internal->nrec); /* Check for the kind of B-tree node to swap */ - if(depth > 1) { - H5B2_internal_t *child_internal; /* Pointer to internal node */ + if (depth > 1) { + H5B2_internal_t *child_internal; /* Pointer to internal node */ /* Setup information for unlocking child node */ child_class = H5AC_BT2_INT; /* Lock B-tree child nodes */ - if(NULL == (child_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (child_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") child_addr = internal->node_ptrs[idx].addr; /* More setup for accessing child node information */ - child = child_internal; + child = child_internal; child_native = child_internal->int_native; } /* end if */ else { - H5B2_leaf_t *child_leaf; /* Pointer to leaf node */ + H5B2_leaf_t *child_leaf; /* Pointer to leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock B-tree child node */ - if(NULL == (child_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (child_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") child_addr = internal->node_ptrs[idx].addr; /* More setup for accessing child node information */ - child = child_leaf; + child = child_leaf; child_native = child_leaf->leaf_native; } /* end else */ @@ -673,7 +672,7 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) + if (depth > 1) H5B2__assert_internal(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)child); else H5B2__assert_leaf(hdr, (H5B2_leaf_t *)child); @@ -681,13 +680,12 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, done: /* Unlock child node */ - if(child && H5AC_unprotect(hdr->f, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0) + if (child && H5AC_unprotect(hdr->f, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__swap_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__shadow_leaf * @@ -707,8 +705,8 @@ done: static herr_t H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_ptr) { - H5B2_hdr_t *hdr; /* B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -727,20 +725,20 @@ H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_ptr) * the readers so there will be no need to shadow. To check if it has been * shadowed, compare the epoch of this node and the header. If this node's * epoch is <= to the header's, it hasn't been shadowed yet. */ - if(leaf->shadow_epoch <= hdr->shadow_epoch) { - haddr_t new_node_addr; /* Address to move node to */ + if (leaf->shadow_epoch <= hdr->shadow_epoch) { + haddr_t new_node_addr; /* Address to move node to */ /* - * We must clone the old node so readers with an out-of-date version of - * the parent can still see the correct number of children, via the - * shadowed node. Remove it from cache but do not mark it free on disk. - */ + * We must clone the old node so readers with an out-of-date version of + * the parent can still see the correct number of children, via the + * shadowed node. Remove it from cache but do not mark it free on disk. + */ /* Allocate space for the cloned node */ - if(HADDR_UNDEF == (new_node_addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) + if (HADDR_UNDEF == (new_node_addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move B-tree node") /* Move the location of the old child on the disk */ - if(H5AC_move_entry(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, new_node_addr) < 0) + if (H5AC_move_entry(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, new_node_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMOVE, FAIL, "unable to move B-tree node") curr_node_ptr->addr = new_node_addr; @@ -756,7 +754,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__shadow_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__remove_leaf * @@ -771,15 +768,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_remove_t op, void *op_data) +H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, + void *udata, H5B2_remove_t op, void *op_data) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ - unsigned idx = 0; /* Location of record which matches key */ - int cmp; /* Comparison value of records */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ + unsigned idx = 0; /* Location of record which matches key */ + int cmp; /* Comparison value of records */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -789,7 +786,7 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") leaf_addr = curr_node_ptr->addr; @@ -798,47 +795,48 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(leaf->nrec == curr_node_ptr->node_nrec); /* Find correct location to remove this record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp != 0) + if (cmp != 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record is not in B-tree") /* Check for invalidating the min/max record for the tree */ - if(H5B2_POS_MIDDLE != curr_pos) { + if (H5B2_POS_MIDDLE != curr_pos) { /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec) + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec) hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec) + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec) hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Make 'remove' callback if there is one */ - if(op) - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) + if (op) + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record into leaf node") /* Update number of records in node */ leaf->nrec--; - if(leaf->nrec > 0) { + if (leaf->nrec > 0) { /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write) { - if(H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) + if (hdr->swmr_write) { + if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf node") leaf_addr = curr_node_ptr->addr; } /* end if */ /* Pack record out of leaf */ - if(idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), hdr->cls->nrec_size * (leaf->nrec - idx)); + if (idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), + hdr->cls->nrec_size * (leaf->nrec - idx)); /* Mark leaf node as dirty also */ leaf_flags |= H5AC__DIRTIED_FLAG; @@ -846,7 +844,7 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, else { /* Let the cache know that the object is deleted */ leaf_flags |= H5AC__DELETED_FLAG; - if(!hdr->swmr_write) + if (!hdr->swmr_write) leaf_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; /* Reset address of parent node pointer */ @@ -858,13 +856,12 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, done: /* Release the B-tree leaf node */ - if(leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) + if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__remove_leaf_by_idx * @@ -880,14 +877,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, unsigned idx, H5B2_remove_t op, - void *op_data) +H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, + void *parent, unsigned idx, H5B2_remove_t op, void *op_data) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -897,7 +893,7 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") leaf_addr = curr_node_ptr->addr; @@ -907,41 +903,42 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(idx < leaf->nrec); /* Check for invalidating the min/max record for the tree */ - if(H5B2_POS_MIDDLE != curr_pos) { + if (H5B2_POS_MIDDLE != curr_pos) { /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec) + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec) hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec) + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec) hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Make 'remove' callback if there is one */ - if(op) - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) + if (op) + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record into leaf node") /* Update number of records in node */ leaf->nrec--; - if(leaf->nrec > 0) { + if (leaf->nrec > 0) { /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write) { - if(H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) + if (hdr->swmr_write) { + if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf node") leaf_addr = curr_node_ptr->addr; } /* end if */ /* Pack record out of leaf */ - if(idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), hdr->cls->nrec_size * (leaf->nrec - idx)); + if (idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), + hdr->cls->nrec_size * (leaf->nrec - idx)); /* Mark leaf node as dirty also */ leaf_flags |= H5AC__DIRTIED_FLAG; @@ -949,7 +946,7 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, else { /* Let the cache know that the object is deleted */ leaf_flags |= H5AC__DELETED_FLAG; - if(!hdr->swmr_write) + if (!hdr->swmr_write) leaf_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; /* Reset address of parent node pointer */ @@ -961,13 +958,12 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, done: /* Release the B-tree leaf node */ - if(leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) + if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_leaf_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5B2__leaf_free * @@ -984,7 +980,7 @@ done: herr_t H5B2__leaf_free(H5B2_leaf_t *leaf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -994,12 +990,12 @@ H5B2__leaf_free(H5B2_leaf_t *leaf) HDassert(leaf); /* Release leaf's native key buffer */ - if(leaf->leaf_native) + if (leaf->leaf_native) leaf->leaf_native = (uint8_t *)H5FL_FAC_FREE(leaf->hdr->node_info[0].nat_rec_fac, leaf->leaf_native); /* Decrement ref. count on B-tree header */ - if(H5B2__hdr_decr(leaf->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") + if (H5B2__hdr_decr(leaf->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") /* Sanity check */ HDassert(NULL == leaf->top_proxy); @@ -1012,7 +1008,7 @@ done: } /* end H5B2__leaf_free() */ #ifdef H5B2_DEBUG - + /*------------------------------------------------------------------------- * Function: H5B2__assert_leaf * @@ -1027,16 +1023,14 @@ done: *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_leaf(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, - const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf) +H5B2__assert_leaf(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf) { /* General sanity checking on node */ HDassert(leaf->nrec <= hdr->node_info->split_nrec); - return(0); + return (0); } /* end H5B2__assert_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__assert_leaf2 * @@ -1051,12 +1045,12 @@ H5B2__assert_leaf(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_leaf2(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf, const H5B2_leaf_t H5_ATTR_UNUSED *leaf2) +H5B2__assert_leaf2(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf, + const H5B2_leaf_t H5_ATTR_UNUSED *leaf2) { /* General sanity checking on node */ HDassert(leaf->nrec <= hdr->node_info->split_nrec); - return(0); + return (0); } /* end H5B2__assert_leaf2() */ #endif /* H5B2_DEBUG */ - diff --git a/src/H5B2module.h b/src/H5B2module.h index 35c982c..9b0e0d9 100644 --- a/src/H5B2module.h +++ b/src/H5B2module.h @@ -25,10 +25,8 @@ * reporting macros. */ #define H5B2_MODULE -#define H5_MY_PKG H5B2 -#define H5_MY_PKG_ERR H5E_BTREE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5B2 +#define H5_MY_PKG_ERR H5E_BTREE +#define H5_MY_PKG_INIT NO #endif /* _H5B2module_H */ - - diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 7d73752..0b5833b 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -30,123 +30,113 @@ #include "H5B2private.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Size of storage for number of records per node (on disk) */ -#define H5B2_SIZEOF_RECORDS_PER_NODE (unsigned)2 +#define H5B2_SIZEOF_RECORDS_PER_NODE (unsigned)2 /* Size of a "tree pointer" (on disk) */ /* (essentially, the largest internal pointer allowed) */ -#define H5B2_TREE_POINTER_SIZE(sizeof_addr, sizeof_size) ( \ - (sizeof_addr) + \ - H5B2_SIZEOF_RECORDS_PER_NODE + \ - (sizeof_size) \ - ) +#define H5B2_TREE_POINTER_SIZE(sizeof_addr, sizeof_size) \ + ((sizeof_addr) + H5B2_SIZEOF_RECORDS_PER_NODE + (sizeof_size)) /* Size of a internal node pointer (on disk) */ -#define H5B2_INT_POINTER_SIZE(h, d) ( \ - (unsigned)(h)->sizeof_addr /* Address of child node */ \ - + (h)->max_nrec_size /* # of records in child node */ \ - + (h)->node_info[(d) - 1].cum_max_nrec_size /* Total # of records in child & below */ \ +#define H5B2_INT_POINTER_SIZE(h, d) \ + ((unsigned)(h)->sizeof_addr /* Address of child node */ \ + + (h)->max_nrec_size /* # of records in child node */ \ + + (h)->node_info[(d)-1].cum_max_nrec_size /* Total # of records in child & below */ \ ) /* Size of checksum information (on disk) */ -#define H5B2_SIZEOF_CHKSUM 4 +#define H5B2_SIZEOF_CHKSUM 4 /* Format overhead for all v2 B-tree metadata in the file */ -#define H5B2_METADATA_PREFIX_SIZE ( \ - (unsigned)H5_SIZEOF_MAGIC /* Signature */ \ - + (unsigned)1 /* Version */ \ - + (unsigned)1 /* Tree type */ \ - + (unsigned)H5B2_SIZEOF_CHKSUM /* Metadata checksum */ \ +#define H5B2_METADATA_PREFIX_SIZE \ + ((unsigned)H5_SIZEOF_MAGIC /* Signature */ \ + + (unsigned)1 /* Version */ \ + + (unsigned)1 /* Tree type */ \ + + (unsigned)H5B2_SIZEOF_CHKSUM /* Metadata checksum */ \ ) /* Size of the v2 B-tree header on disk */ -#define H5B2_HEADER_SIZE(sizeof_addr, sizeof_size) ( \ - /* General metadata fields */ \ - H5B2_METADATA_PREFIX_SIZE \ - \ - /* Header specific fields */ \ - + (unsigned)4 /* Node size, in bytes */ \ - + (unsigned)2 /* Record size, in bytes */ \ - + (unsigned)2 /* Depth of tree */ \ - + (unsigned)1 /* Split % of full (as integer, ie. "98" means 98%) */ \ - + (unsigned)1 /* Merge % of full (as integer, ie. "98" means 98%) */ \ - + H5B2_TREE_POINTER_SIZE(sizeof_addr, sizeof_size) /* Node pointer to root node in tree */ \ +#define H5B2_HEADER_SIZE(sizeof_addr, sizeof_size) \ + (/* General metadata fields */ \ + H5B2_METADATA_PREFIX_SIZE \ + \ + /* Header specific fields */ \ + + (unsigned)4 /* Node size, in bytes */ \ + + (unsigned)2 /* Record size, in bytes */ \ + + (unsigned)2 /* Depth of tree */ \ + + (unsigned)1 /* Split % of full (as integer, ie. "98" means 98%) */ \ + + (unsigned)1 /* Merge % of full (as integer, ie. "98" means 98%) */ \ + + H5B2_TREE_POINTER_SIZE(sizeof_addr, sizeof_size) /* Node pointer to root node in tree */ \ ) /* Size of the v2 B-tree header on disk (via file pointer) */ -#define H5B2_HEADER_SIZE_FILE(f) ( \ - H5B2_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f)) \ - ) +#define H5B2_HEADER_SIZE_FILE(f) (H5B2_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f))) /* Size of the v2 B-tree header on disk (via v2 B-tree header) */ -#define H5B2_HEADER_SIZE_HDR(h) ( \ - H5B2_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size) \ - ) +#define H5B2_HEADER_SIZE_HDR(h) (H5B2_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size)) /* Size of the v2 B-tree internal node prefix */ -#define H5B2_INT_PREFIX_SIZE ( \ - /* General metadata fields */ \ - H5B2_METADATA_PREFIX_SIZE \ - \ - /* Header specific fields */ \ - /* */ \ +#define H5B2_INT_PREFIX_SIZE \ + (/* General metadata fields */ \ + H5B2_METADATA_PREFIX_SIZE \ + \ + /* Header specific fields */ /* */ \ ) /* Size of the v2 B-tree leaf node prefix */ -#define H5B2_LEAF_PREFIX_SIZE ( \ - /* General metadata fields */ \ - H5B2_METADATA_PREFIX_SIZE \ - \ - /* Header specific fields */ \ - /* */ \ +#define H5B2_LEAF_PREFIX_SIZE \ + (/* General metadata fields */ \ + H5B2_METADATA_PREFIX_SIZE \ + \ + /* Header specific fields */ /* */ \ ) /* Macro to retrieve pointer to i'th native record for native record buffer */ -#define H5B2_NAT_NREC(b, hdr, idx) ((b) + (hdr)->nat_off[(idx)]) +#define H5B2_NAT_NREC(b, hdr, idx) ((b) + (hdr)->nat_off[(idx)]) /* Macro to retrieve pointer to i'th native record for internal node */ -#define H5B2_INT_NREC(i, hdr, idx) H5B2_NAT_NREC((i)->int_native, (hdr), (idx)) +#define H5B2_INT_NREC(i, hdr, idx) H5B2_NAT_NREC((i)->int_native, (hdr), (idx)) /* Macro to retrieve pointer to i'th native record for leaf node */ -#define H5B2_LEAF_NREC(l, hdr, idx) H5B2_NAT_NREC((l)->leaf_native, (hdr), (idx)) +#define H5B2_LEAF_NREC(l, hdr, idx) H5B2_NAT_NREC((l)->leaf_native, (hdr), (idx)) /* Number of records that fit into internal node */ /* (accounts for extra node pointer by counting it in with the prefix bytes) */ -#define H5B2_NUM_INT_REC(h, d) \ - (((h)->node_size - (H5B2_INT_PREFIX_SIZE + H5B2_INT_POINTER_SIZE(h, d))) / ((h)->rrec_size + H5B2_INT_POINTER_SIZE(h, d))) +#define H5B2_NUM_INT_REC(h, d) \ + (((h)->node_size - (H5B2_INT_PREFIX_SIZE + H5B2_INT_POINTER_SIZE(h, d))) / \ + ((h)->rrec_size + H5B2_INT_POINTER_SIZE(h, d))) /* Uncomment this macro to enable extra sanity checking */ /* #define H5B2_DEBUG */ - /****************************/ /* Package Private Typedefs */ /****************************/ /* A "node pointer" to another B-tree node */ typedef struct { - haddr_t addr; /* Address of other node */ - uint16_t node_nrec; /* Number of records used in node pointed to */ - hsize_t all_nrec; /* Number of records in node pointed to and all it's children */ + haddr_t addr; /* Address of other node */ + uint16_t node_nrec; /* Number of records used in node pointed to */ + hsize_t all_nrec; /* Number of records in node pointed to and all it's children */ } H5B2_node_ptr_t; /* Information about a node at a given depth */ typedef struct { - unsigned max_nrec; /* Max. number of records in node */ - unsigned split_nrec; /* Number of records to split node at */ - unsigned merge_nrec; /* Number of records to merge node at */ - hsize_t cum_max_nrec; /* Cumulative max. # of records below this node's depth */ - uint8_t cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */ - H5FL_fac_head_t *nat_rec_fac; /* Factory for native record blocks */ - H5FL_fac_head_t *node_ptr_fac; /* Factory for node pointer blocks */ + unsigned max_nrec; /* Max. number of records in node */ + unsigned split_nrec; /* Number of records to split node at */ + unsigned merge_nrec; /* Number of records to merge node at */ + hsize_t cum_max_nrec; /* Cumulative max. # of records below this node's depth */ + uint8_t cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */ + H5FL_fac_head_t *nat_rec_fac; /* Factory for native record blocks */ + H5FL_fac_head_t *node_ptr_fac; /* Factory for node pointer blocks */ } H5B2_node_info_t; /* The B-tree header information */ @@ -155,60 +145,60 @@ typedef struct H5B2_hdr_t { H5AC_info_t cache_info; /* Internal B-tree information (stored) */ - H5B2_node_ptr_t root; /* Node pointer to root node in B-tree */ + H5B2_node_ptr_t root; /* Node pointer to root node in B-tree */ /* Information set by user (stored) */ - uint8_t split_percent; /* Percent full at which to split the node, when inserting */ - uint8_t merge_percent; /* Percent full at which to merge the node, when deleting */ - uint32_t node_size; /* Size of B-tree nodes, in bytes */ - uint32_t rrec_size; /* Size of "raw" (on disk) record, in bytes */ + uint8_t split_percent; /* Percent full at which to split the node, when inserting */ + uint8_t merge_percent; /* Percent full at which to merge the node, when deleting */ + uint32_t node_size; /* Size of B-tree nodes, in bytes */ + uint32_t rrec_size; /* Size of "raw" (on disk) record, in bytes */ /* Dynamic information (stored) */ - uint16_t depth; /* B-tree's overall depth */ + uint16_t depth; /* B-tree's overall depth */ /* Derived information from user's information (not stored) */ - uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */ + uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */ /* Shared internal data structures (not stored) */ - H5F_t *f; /* Pointer to the file that the B-tree is in */ - haddr_t addr; /* Address of B-tree header in the file */ - size_t hdr_size; /* Size of the B-tree header on disk */ - size_t rc; /* Reference count of nodes using this header */ - size_t file_rc; /* Reference count of files using this header */ - hbool_t pending_delete; /* B-tree is pending deletion */ - uint8_t sizeof_size; /* Size of file sizes */ - uint8_t sizeof_addr; /* Size of file addresses */ - H5B2_remove_t remove_op; /* Callback operator for deleting B-tree */ - void *remove_op_data;/* B-tree deletion callback's context */ - uint8_t *page; /* Common disk page for I/O */ - size_t *nat_off; /* Array of offsets of native records */ - H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */ - void *min_native_rec; /* Pointer to minimum native record */ - void *max_native_rec; /* Pointer to maximum native record */ + H5F_t * f; /* Pointer to the file that the B-tree is in */ + haddr_t addr; /* Address of B-tree header in the file */ + size_t hdr_size; /* Size of the B-tree header on disk */ + size_t rc; /* Reference count of nodes using this header */ + size_t file_rc; /* Reference count of files using this header */ + hbool_t pending_delete; /* B-tree is pending deletion */ + uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_addr; /* Size of file addresses */ + H5B2_remove_t remove_op; /* Callback operator for deleting B-tree */ + void * remove_op_data; /* B-tree deletion callback's context */ + uint8_t * page; /* Common disk page for I/O */ + size_t * nat_off; /* Array of offsets of native records */ + H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */ + void * min_native_rec; /* Pointer to minimum native record */ + void * max_native_rec; /* Pointer to maximum native record */ /* SWMR / Flush dependency information (not stored) */ - hbool_t swmr_write; /* Whether we are doing SWMR writes */ + hbool_t swmr_write; /* Whether we are doing SWMR writes */ H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ - void *parent; /* Pointer to 'top' proxy flush dependency - * parent, if it exists, otherwise NULL. - * If the v2 B-tree is being used to index a - * chunked dataset and the dataset metadata is - * modified by a SWMR writer, this field will - * be set equal to the object header proxy - * that is the flush dependency parent - * of the v2 B-tree header. - * - * The field is used to avoid duplicate setups - * of the flush dependency relationship, and to - * allow the v2 B-tree header to destroy the - * flush dependency on receipt of an eviction - * notification from the metadata cache. - */ - uint64_t shadow_epoch; /* Epoch of header, for making shadow copies */ + void * parent; /* Pointer to 'top' proxy flush dependency + * parent, if it exists, otherwise NULL. + * If the v2 B-tree is being used to index a + * chunked dataset and the dataset metadata is + * modified by a SWMR writer, this field will + * be set equal to the object header proxy + * that is the flush dependency parent + * of the v2 B-tree header. + * + * The field is used to avoid duplicate setups + * of the flush dependency relationship, and to + * allow the v2 B-tree header to destroy the + * flush dependency on receipt of an eviction + * notification from the metadata cache. + */ + uint64_t shadow_epoch; /* Epoch of header, for making shadow copies */ /* Client information (not stored) */ - const H5B2_class_t *cls; /* Class of B-tree client */ - void *cb_ctx; /* Client callback context */ + const H5B2_class_t *cls; /* Class of B-tree client */ + void * cb_ctx; /* Client callback context */ } H5B2_hdr_t; /* B-tree leaf node information */ @@ -217,14 +207,14 @@ typedef struct H5B2_leaf_t { H5AC_info_t cache_info; /* Internal B-tree information */ - H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ - uint8_t *leaf_native; /* Pointer to native records */ - uint16_t nrec; /* Number of records in node */ + H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ + uint8_t * leaf_native; /* Pointer to native records */ + uint16_t nrec; /* Number of records in node */ /* SWMR / Flush dependency information (not stored) */ - H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ - void *parent; /* Flush dependency parent for leaf */ - uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ + void * parent; /* Flush dependency parent for leaf */ + uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ } H5B2_leaf_t; /* B-tree internal node information */ @@ -233,74 +223,73 @@ typedef struct H5B2_internal_t { H5AC_info_t cache_info; /* Internal B-tree information */ - H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ - uint8_t *int_native; /* Pointer to native records */ - H5B2_node_ptr_t *node_ptrs; /* Pointer to node pointers */ - uint16_t nrec; /* Number of records in node */ - uint16_t depth; /* Depth of this node in the B-tree */ + H5B2_hdr_t * hdr; /* Pointer to the [pinned] v2 B-tree header */ + uint8_t * int_native; /* Pointer to native records */ + H5B2_node_ptr_t *node_ptrs; /* Pointer to node pointers */ + uint16_t nrec; /* Number of records in node */ + uint16_t depth; /* Depth of this node in the B-tree */ /* SWMR / Flush dependency information (not stored) */ - H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ - void *parent; /* Flush dependency parent for internal node */ - uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ + void * parent; /* Flush dependency parent for internal node */ + uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ } H5B2_internal_t; /* v2 B-tree */ struct H5B2_t { - H5B2_hdr_t *hdr; /* Pointer to internal v2 B-tree header info */ - H5F_t *f; /* Pointer to file for v2 B-tree */ + H5B2_hdr_t *hdr; /* Pointer to internal v2 B-tree header info */ + H5F_t * f; /* Pointer to file for v2 B-tree */ }; /* Node position, for min/max determination */ typedef enum H5B2_nodepos_t { - H5B2_POS_ROOT, /* Node is root (i.e. both right & left-most in tree) */ - H5B2_POS_RIGHT, /* Node is right-most in tree, at a given depth */ - H5B2_POS_LEFT, /* Node is left-most in tree, at a given depth */ - H5B2_POS_MIDDLE /* Node is neither right or left-most in tree */ + H5B2_POS_ROOT, /* Node is root (i.e. both right & left-most in tree) */ + H5B2_POS_RIGHT, /* Node is right-most in tree, at a given depth */ + H5B2_POS_LEFT, /* Node is left-most in tree, at a given depth */ + H5B2_POS_MIDDLE /* Node is neither right or left-most in tree */ } H5B2_nodepos_t; /* Update status */ typedef enum H5B2_update_status_t { - H5B2_UPDATE_UNKNOWN, /* Unknown update status (initial state) */ - H5B2_UPDATE_MODIFY_DONE, /* Update successfully modified existing record */ - H5B2_UPDATE_SHADOW_DONE, /* Update modified existing record and modified node was shadowed */ - H5B2_UPDATE_INSERT_DONE, /* Update inserted record successfully */ - H5B2_UPDATE_INSERT_CHILD_FULL /* Update will insert record, but child is full */ + H5B2_UPDATE_UNKNOWN, /* Unknown update status (initial state) */ + H5B2_UPDATE_MODIFY_DONE, /* Update successfully modified existing record */ + H5B2_UPDATE_SHADOW_DONE, /* Update modified existing record and modified node was shadowed */ + H5B2_UPDATE_INSERT_DONE, /* Update inserted record successfully */ + H5B2_UPDATE_INSERT_CHILD_FULL /* Update will insert record, but child is full */ } H5B2_update_status_t; /* Callback info for loading a v2 B-tree header into the cache */ typedef struct H5B2_hdr_cache_ud_t { - H5F_t *f; /* File that v2 b-tree header is within */ - haddr_t addr; /* Address of B-tree header in the file */ - void *ctx_udata; /* User-data for protecting */ + H5F_t * f; /* File that v2 b-tree header is within */ + haddr_t addr; /* Address of B-tree header in the file */ + void * ctx_udata; /* User-data for protecting */ } H5B2_hdr_cache_ud_t; /* Callback info for loading a v2 B-tree internal node into the cache */ typedef struct H5B2_internal_cache_ud_t { - H5F_t *f; /* File that v2 b-tree header is within */ - H5B2_hdr_t *hdr; /* v2 B-tree header */ - void *parent; /* Flush dependency parent */ - uint16_t nrec; /* Number of records in node to load */ - uint16_t depth; /* Depth of node to load */ + H5F_t * f; /* File that v2 b-tree header is within */ + H5B2_hdr_t *hdr; /* v2 B-tree header */ + void * parent; /* Flush dependency parent */ + uint16_t nrec; /* Number of records in node to load */ + uint16_t depth; /* Depth of node to load */ } H5B2_internal_cache_ud_t; /* Callback info for loading a v2 B-tree leaf node into the cache */ typedef struct H5B2_leaf_cache_ud_t { - H5F_t *f; /* File that v2 b-tree header is within */ - H5B2_hdr_t *hdr; /* v2 B-tree header */ - void *parent; /* Flush dependency parent */ - uint16_t nrec; /* Number of records in node to load */ + H5F_t * f; /* File that v2 b-tree header is within */ + H5B2_hdr_t *hdr; /* v2 B-tree header */ + void * parent; /* Flush dependency parent */ + uint16_t nrec; /* Number of records in node to load */ } H5B2_leaf_cache_ud_t; #ifdef H5B2_TESTING /* Node information for testing */ typedef struct H5B2_node_info_test_t { - uint16_t depth; /* Depth of node */ - uint16_t nrec; /* Number of records in node */ + uint16_t depth; /* Depth of node */ + uint16_t nrec; /* Number of records in node */ } H5B2_node_info_test_t; #endif /* H5B2_TESTING */ - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -318,73 +307,65 @@ H5_DLLVAR const H5B2_class_t H5B2_TEST2[1]; /* B-tree record for testing H5B2_TEST2 class */ typedef struct H5B2_test_rec_t { - hsize_t key; /* Key for record */ - hsize_t val; /* Value for record */ + hsize_t key; /* Key for record */ + hsize_t val; /* Value for record */ } H5B2_test_rec_t; #endif /* H5B2_TESTING */ /* Array of v2 B-tree client ID -> client class mappings */ extern const H5B2_class_t *const H5B2_client_class_g[H5B2_NUM_BTREE_ID]; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Generic routines */ -H5_DLL herr_t H5B2__create_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); -H5_DLL herr_t H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, - const H5B2_node_ptr_t *node_ptr, void *old_parent, void *new_parent); -H5_DLL herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); +H5_DLL herr_t H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); +H5_DLL herr_t H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptr, + void *old_parent, void *new_parent); +H5_DLL herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Internal node management routines */ H5_DLL herr_t H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx); -H5_DLL herr_t H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, - H5B2_internal_t *internal, unsigned idx); -H5_DLL herr_t H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, - H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx); + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx); +H5_DLL herr_t H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned idx); +H5_DLL herr_t H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx); H5_DLL herr_t H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx); + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx); H5_DLL herr_t H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx); + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx); /* Routines for managing B-tree header info */ H5_DLL H5B2_hdr_t *H5B2__hdr_alloc(H5F_t *f); -H5_DLL haddr_t H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata); -H5_DLL herr_t H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, - void *ctx_udata, uint16_t depth); +H5_DLL haddr_t H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata); +H5_DLL herr_t H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, uint16_t depth); H5_DLL herr_t H5B2__hdr_incr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr); H5_DLL size_t H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_dirty(H5B2_hdr_t *hdr); -H5_DLL H5B2_hdr_t *H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, - void *ctx_udata, unsigned flags); -H5_DLL herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags); -H5_DLL herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr); +H5_DLL H5B2_hdr_t *H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags); +H5_DLL herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags); +H5_DLL herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr); /* Routines for operating on leaf nodes */ -H5_DLL H5B2_leaf_t * H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, - H5B2_node_ptr_t *node_ptr, hbool_t shadow, unsigned flags); -H5_DLL herr_t H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx, void *swap_loc); +H5_DLL H5B2_leaf_t *H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, + hbool_t shadow, unsigned flags); +H5_DLL herr_t H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx, void *swap_loc); /* Routines for operating on internal nodes */ -H5_DLL H5B2_internal_t *H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, - H5B2_node_ptr_t *node_ptr, uint16_t depth, hbool_t shadow, unsigned flags); +H5_DLL H5B2_internal_t *H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, + uint16_t depth, hbool_t shadow, unsigned flags); /* Routines for allocating nodes */ H5_DLL herr_t H5B2__split_root(H5B2_hdr_t *hdr); -H5_DLL herr_t H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, - H5B2_node_ptr_t *node_ptr); -H5_DLL herr_t H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, - H5B2_node_ptr_t *node_ptr, uint16_t depth); +H5_DLL herr_t H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr); +H5_DLL herr_t H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, uint16_t depth); /* Routines for releasing structures */ H5_DLL herr_t H5B2__hdr_free(H5B2_hdr_t *hdr); @@ -393,74 +374,74 @@ H5_DLL herr_t H5B2__internal_free(H5B2_internal_t *i); /* Routines for inserting records */ H5_DLL herr_t H5B2__insert(H5B2_hdr_t *hdr, void *udata); -H5_DLL herr_t H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, - unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata); -H5_DLL herr_t H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata); +H5_DLL herr_t H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, + void *udata); +H5_DLL herr_t H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, + void *parent, void *udata); /* Routines for update records */ -H5_DLL herr_t H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, - unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *parent, - void *udata, H5B2_modify_t op, void *op_data); -H5_DLL herr_t H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *parent, - void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_modify_t op, + void *op_data); +H5_DLL herr_t H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_modify_t op, + void *op_data); /* Routines for iterating over nodes/records */ -H5_DLL herr_t H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, - const H5B2_node_ptr_t *curr_node, void *parent, H5B2_operator_t op, void *op_data); -H5_DLL herr_t H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, - const H5B2_node_ptr_t *curr_node, void *parent, hsize_t *op_data); +H5_DLL herr_t H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, + void *parent, H5B2_operator_t op, void *op_data); +H5_DLL herr_t H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, + hsize_t *op_data); /* Routines for locating records */ -H5_DLL herr_t H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, - size_t *rec_off, const uint8_t *native, const void *udata, unsigned *idx, int *result); -H5_DLL herr_t H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, - H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, H5B2_compare_t comp, - void *parent, void *udata, H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - void *neighbor_loc, H5B2_compare_t comp, void *parent, void *udata, - H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, + const uint8_t *native, const void *udata, unsigned *idx, int *result); +H5_DLL herr_t H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, + void *neighbor_loc, H5B2_compare_t comp, void *parent, void *udata, + H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, + H5B2_compare_t comp, void *parent, void *udata, H5B2_found_t op, + void *op_data); /* Routines for removing records */ -H5_DLL herr_t H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, - void *swap_loc, void *swap_parent, uint16_t depth, H5AC_info_t *parent_cache_info, - unsigned *parent_cache_info_flags_ptr, H5B2_nodepos_t curr_pos, - H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, - void *op_data); -H5_DLL herr_t H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_remove_t op, - void *op_data); -H5_DLL herr_t H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, - hbool_t *depth_decreased, void *swap_loc, void *swap_parent, uint16_t depth, - H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr, - H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, hsize_t n, - H5B2_remove_t op, void *op_data); +H5_DLL herr_t H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, + void *swap_parent, uint16_t depth, H5AC_info_t *parent_cache_info, + unsigned *parent_cache_info_flags_ptr, H5B2_nodepos_t curr_pos, + H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, + void *op_data); +H5_DLL herr_t H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, + void *parent, void *udata, H5B2_remove_t op, void *op_data); +H5_DLL herr_t H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, + void *swap_parent, uint16_t depth, H5AC_info_t *parent_cache_info, + unsigned * parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, hsize_t n, + H5B2_remove_t op, void *op_data); H5_DLL herr_t H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, unsigned idx, H5B2_remove_t op, - void *op_data); + H5B2_nodepos_t curr_pos, void *parent, unsigned idx, H5B2_remove_t op, + void *op_data); /* Routines for deleting nodes */ -H5_DLL herr_t H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, - const H5B2_node_ptr_t *curr_node, void *parent, H5B2_remove_t op, - void *op_data); +H5_DLL herr_t H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, + void *parent, H5B2_remove_t op, void *op_data); /* Debugging routines for dumping file structures */ -H5_DLL herr_t H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, const H5B2_class_t *type, haddr_t obj_addr); -H5_DLL herr_t H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, unsigned depth, - haddr_t obj_addr); -H5_DLL herr_t H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, haddr_t obj_addr); +H5_DLL herr_t H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5B2_class_t *type, haddr_t obj_addr); +H5_DLL herr_t H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, unsigned depth, + haddr_t obj_addr); +H5_DLL herr_t H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, haddr_t obj_addr); /* Sanity checking routines */ #ifdef H5B2_DEBUG /* Don't label these with H5_ATTR_PURE or you'll get even more warnings... */ -H5_DLL herr_t H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal); -H5_DLL herr_t H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal, const H5B2_internal_t *internal2); +H5_DLL herr_t H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, + const H5B2_internal_t *internal); +H5_DLL herr_t H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, + const H5B2_internal_t *internal, const H5B2_internal_t *internal2); H5_DLL herr_t H5B2__assert_leaf(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf); H5_DLL herr_t H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, const H5B2_leaf_t *leaf2); #endif /* H5B2_DEBUG */ @@ -468,10 +449,8 @@ H5_DLL herr_t H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, /* Testing routines */ #ifdef H5B2_TESTING H5_DLL herr_t H5B2__get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr); -H5_DLL int H5B2__get_node_depth_test(H5B2_t *bt2, void *udata); -H5_DLL herr_t H5B2__get_node_info_test(H5B2_t *bt2, void *udata, - H5B2_node_info_test_t *ninfo); +H5_DLL int H5B2__get_node_depth_test(H5B2_t *bt2, void *udata); +H5_DLL herr_t H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo); #endif /* H5B2_TESTING */ #endif /* _H5B2pkg_H */ - diff --git a/src/H5B2private.h b/src/H5B2private.h index 9303d4f..e511897 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -26,34 +26,38 @@ #define _H5B2private_H /* Private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* B-tree IDs for various internal things. */ typedef enum H5B2_subid_t { - H5B2_TEST_ID = 0, /* B-tree is for testing (do not use for actual data) */ - H5B2_FHEAP_HUGE_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, non-filtered 'huge' objects */ - H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, filtered 'huge' objects */ - H5B2_FHEAP_HUGE_DIR_ID, /* B-tree is for fractal heap directly accessed, non-filtered 'huge' objects */ + H5B2_TEST_ID = 0, /* B-tree is for testing (do not use for actual data) */ + H5B2_FHEAP_HUGE_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, non-filtered 'huge' objects + */ + H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, filtered 'huge' objects + */ + H5B2_FHEAP_HUGE_DIR_ID, /* B-tree is for fractal heap directly accessed, non-filtered 'huge' objects */ H5B2_FHEAP_HUGE_FILT_DIR_ID, /* B-tree is for fractal heap directly accessed, filtered 'huge' objects */ - H5B2_GRP_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" link storage in groups */ - H5B2_GRP_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" link storage in groups */ - H5B2_SOHM_INDEX_ID, /* B-tree is an index for shared object header messages */ - H5B2_ATTR_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" attribute storage on objects */ - H5B2_ATTR_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" attribute storage on objects */ - H5B2_CDSET_ID, /* B-tree is for non-filtered chunked dataset storage w/ >1 unlim dims */ - H5B2_CDSET_FILT_ID, /* B-tree is for filtered chunked dataset storage w/ >1 unlim dims */ - H5B2_TEST2_ID, /* Another B-tree is for testing (do not use for actual data) */ - H5B2_NUM_BTREE_ID /* Number of B-tree IDs (must be last) */ + H5B2_GRP_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" link storage in groups */ + H5B2_GRP_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" link storage in + groups */ + H5B2_SOHM_INDEX_ID, /* B-tree is an index for shared object header messages */ + H5B2_ATTR_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" attribute storage on objects + */ + H5B2_ATTR_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" attribute storage + on objects */ + H5B2_CDSET_ID, /* B-tree is for non-filtered chunked dataset storage w/ >1 unlim dims */ + H5B2_CDSET_FILT_ID, /* B-tree is for filtered chunked dataset storage w/ >1 unlim dims */ + H5B2_TEST2_ID, /* Another B-tree is for testing (do not use for actual data) */ + H5B2_NUM_BTREE_ID /* Number of B-tree IDs (must be last) */ } H5B2_subid_t; /* Define the operator callback function pointer for H5B2_iterate() */ @@ -70,8 +74,8 @@ typedef herr_t (*H5B2_remove_t)(const void *record, void *op_data); /* Comparisons for H5B2_neighbor() call */ typedef enum H5B2_compare_t { - H5B2_COMPARE_LESS, /* Records with keys less than query value */ - H5B2_COMPARE_GREATER /* Records with keys greater than query value */ + H5B2_COMPARE_LESS, /* Records with keys less than query value */ + H5B2_COMPARE_GREATER /* Records with keys greater than query value */ } H5B2_compare_t; /* @@ -80,77 +84,69 @@ typedef enum H5B2_compare_t { */ typedef struct H5B2_class_t H5B2_class_t; struct H5B2_class_t { - H5B2_subid_t id; /* ID of B-tree class, as found in file */ - const char *name; /* Name of B-tree class, for debugging */ - size_t nrec_size; /* Size of native (memory) record */ + H5B2_subid_t id; /* ID of B-tree class, as found in file */ + const char * name; /* Name of B-tree class, for debugging */ + size_t nrec_size; /* Size of native (memory) record */ /* Extensible array client callback methods */ - void *(*crt_context)(void *udata); /* Create context for other client callbacks */ - herr_t (*dst_context)(void *ctx); /* Destroy client callback context */ - herr_t (*store)(void *nrecord, const void *udata); /* Store application record in native record table */ + void *(*crt_context)(void *udata); /* Create context for other client callbacks */ + herr_t (*dst_context)(void *ctx); /* Destroy client callback context */ + herr_t (*store)(void *nrecord, const void *udata); /* Store application record in native record table */ herr_t (*compare)(const void *rec1, const void *rec2, int *result); /* Compare two native records */ - herr_t (*encode)(uint8_t *raw, const void *record, void *ctx); /* Encode record from native form to disk storage form */ - herr_t (*decode)(const uint8_t *raw, void *record, void *ctx); /* Decode record from disk storage form to native form */ - herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */ - const void *record, const void *ctx); + herr_t (*encode)(uint8_t *raw, const void *record, + void *ctx); /* Encode record from native form to disk storage form */ + herr_t (*decode)(const uint8_t *raw, void *record, + void *ctx); /* Decode record from disk storage form to native form */ + herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */ + const void *record, const void *ctx); }; /* v2 B-tree creation parameters */ typedef struct H5B2_create_t { - const H5B2_class_t *cls; /* v2 B-tree client class */ - uint32_t node_size; /* Size of each node (in bytes) */ - uint32_t rrec_size; /* Size of raw record (in bytes) */ - uint8_t split_percent; /* % full to split nodes */ - uint8_t merge_percent; /* % full to merge nodes */ + const H5B2_class_t *cls; /* v2 B-tree client class */ + uint32_t node_size; /* Size of each node (in bytes) */ + uint32_t rrec_size; /* Size of raw record (in bytes) */ + uint8_t split_percent; /* % full to split nodes */ + uint8_t merge_percent; /* % full to merge nodes */ } H5B2_create_t; /* v2 B-tree metadata statistics info */ typedef struct H5B2_stat_t { - unsigned depth; /* Depth of B-tree */ - hsize_t nrecords; /* Number of records */ + unsigned depth; /* Depth of B-tree */ + hsize_t nrecords; /* Number of records */ } H5B2_stat_t; /* v2 B-tree info (forward decl - defined in H5B2pkg.h) */ typedef struct H5B2_t H5B2_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL H5B2_t *H5B2_create(H5F_t *f, const H5B2_create_t *cparam, - void *ctx_udata); +H5_DLL H5B2_t *H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata); H5_DLL H5B2_t *H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata); -H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr/*out*/); -H5_DLL herr_t H5B2_insert(H5B2_t *bt2, void *udata); -H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data); -H5_DLL htri_t H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, - H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, - H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, - void *op_data); -H5_DLL herr_t H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, - void *op_data); -H5_DLL herr_t H5B2_remove(H5B2_t *b2, void *udata, H5B2_remove_t op, - void *op_data); -H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, - hsize_t idx, H5B2_remove_t op, void *op_data); -H5_DLL herr_t H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec); -H5_DLL herr_t H5B2_size(H5B2_t *bt2, hsize_t *btree_size); -H5_DLL herr_t H5B2_close(H5B2_t *bt2); -H5_DLL herr_t H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, - H5B2_remove_t op, void *op_data); -H5_DLL herr_t H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent); -H5_DLL herr_t H5B2_patch_file(H5B2_t *fa, H5F_t *f); +H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr /*out*/); +H5_DLL herr_t H5B2_insert(H5B2_t *bt2, void *udata); +H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data); +H5_DLL htri_t H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2_remove(H5B2_t *b2, void *udata, H5B2_remove_t op, void *op_data); +H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, + void *op_data); +H5_DLL herr_t H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec); +H5_DLL herr_t H5B2_size(H5B2_t *bt2, hsize_t *btree_size); +H5_DLL herr_t H5B2_close(H5B2_t *bt2); +H5_DLL herr_t H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_data); +H5_DLL herr_t H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent); +H5_DLL herr_t H5B2_patch_file(H5B2_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info); #endif /* _H5B2private_H */ - diff --git a/src/H5B2stat.c b/src/H5B2stat.c index 5dd9cc2..fb2e0fe 100644 --- a/src/H5B2stat.c +++ b/src/H5B2stat.c @@ -22,52 +22,43 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5B2_stat_info * @@ -89,13 +80,12 @@ H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info) HDassert(info); /* Get information about the B-tree */ - info->depth = bt2->hdr->depth; + info->depth = bt2->hdr->depth; info->nrecords = bt2->hdr->root.all_nrec; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_stat_info() */ - /*------------------------------------------------------------------------- * Function: H5B2_size * @@ -112,8 +102,8 @@ H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info) herr_t H5B2_size(H5B2_t *bt2, hsize_t *btree_size) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -131,17 +121,16 @@ H5B2_size(H5B2_t *bt2, hsize_t *btree_size) *btree_size += hdr->hdr_size; /* Iterate through records */ - if(hdr->root.node_nrec > 0) { + if (hdr->root.node_nrec > 0) { /* Check for root node being a leaf */ - if(hdr->depth == 0) + if (hdr->depth == 0) *btree_size += hdr->node_size; else /* Iterate through nodes */ - if(H5B2__node_size(hdr, hdr->depth, &hdr->root, hdr, btree_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") + if (H5B2__node_size(hdr, hdr->depth, &hdr->root, hdr, btree_size) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_size() */ - diff --git a/src/H5B2test.c b/src/H5B2test.c index 7affd49..28b416f 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -18,113 +18,102 @@ * */ - /****************/ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ -#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ +#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* v2 B-tree client callback context */ typedef struct H5B2_test_ctx_t { - uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_size; /* Size of file sizes */ } H5B2_test_ctx_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* v2 B-tree driver callbacks for 'test' B-trees */ -static void *H5B2__test_crt_context(void *udata); +static void * H5B2__test_crt_context(void *udata); static herr_t H5B2__test_dst_context(void *ctx); static herr_t H5B2__test_store(void *nrecord, const void *udata); static herr_t H5B2__test_compare(const void *rec1, const void *rec2, int *result); static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *ctx); static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *ctx); -static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); /* v2 B-tree driver callbacks for 'test2' B-trees */ static herr_t H5B2__test2_store(void *nrecord, const void *udata); static herr_t H5B2__test2_compare(const void *rec1, const void *rec2, int *result); static herr_t H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *ctx); static herr_t H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *ctx); -static herr_t H5B2__test2_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); - +static herr_t H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); /*********************/ /* Package Variables */ /*********************/ /* Class structure for testing simple B-tree records */ -const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ - H5B2_TEST_ID, /* Type of B-tree */ - "H5B2_TEST_ID", /* Name of B-tree class */ - sizeof(hsize_t), /* Size of native record */ - H5B2__test_crt_context, /* Create client callback context */ - H5B2__test_dst_context, /* Destroy client callback context */ - H5B2__test_store, /* Record storage callback */ - H5B2__test_compare, /* Record comparison callback */ - H5B2__test_encode, /* Record encoding callback */ - H5B2__test_decode, /* Record decoding callback */ - H5B2__test_debug /* Record debugging callback */ +const H5B2_class_t H5B2_TEST[1] = {{ + /* B-tree class information */ + H5B2_TEST_ID, /* Type of B-tree */ + "H5B2_TEST_ID", /* Name of B-tree class */ + sizeof(hsize_t), /* Size of native record */ + H5B2__test_crt_context, /* Create client callback context */ + H5B2__test_dst_context, /* Destroy client callback context */ + H5B2__test_store, /* Record storage callback */ + H5B2__test_compare, /* Record comparison callback */ + H5B2__test_encode, /* Record encoding callback */ + H5B2__test_decode, /* Record decoding callback */ + H5B2__test_debug /* Record debugging callback */ }}; /* Class structure for testing key/value B-tree records */ -const H5B2_class_t H5B2_TEST2[1]={{ /* B-tree class information */ - H5B2_TEST2_ID, /* Type of B-tree */ - "H5B2_TEST2_ID", /* Name of B-tree class */ - sizeof(H5B2_test_rec_t), /* Size of native record */ - H5B2__test_crt_context, /* Create client callback context */ - H5B2__test_dst_context, /* Destroy client callback context */ - H5B2__test2_store, /* Record storage callback */ - H5B2__test2_compare, /* Record comparison callback */ - H5B2__test2_encode, /* Record encoding callback */ - H5B2__test2_decode, /* Record decoding callback */ - H5B2__test2_debug /* Record debugging callback */ +const H5B2_class_t H5B2_TEST2[1] = {{ + /* B-tree class information */ + H5B2_TEST2_ID, /* Type of B-tree */ + "H5B2_TEST2_ID", /* Name of B-tree class */ + sizeof(H5B2_test_rec_t), /* Size of native record */ + H5B2__test_crt_context, /* Create client callback context */ + H5B2__test_dst_context, /* Destroy client callback context */ + H5B2__test2_store, /* Record storage callback */ + H5B2__test2_compare, /* Record comparison callback */ + H5B2__test2_encode, /* Record encoding callback */ + H5B2__test2_decode, /* Record decoding callback */ + H5B2__test2_debug /* Record debugging callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /* Declare a free list to manage the H5B2_test_ctx_t struct */ H5FL_DEFINE_STATIC(H5B2_test_ctx_t); - /*------------------------------------------------------------------------- * Function: H5B2__test_crt_context * @@ -141,9 +130,9 @@ H5FL_DEFINE_STATIC(H5B2_test_ctx_t); static void * H5B2__test_crt_context(void *_f) { - H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ - H5B2_test_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ + H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ + H5B2_test_ctx_t *ctx; /* Callback context structure */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -151,7 +140,7 @@ H5B2__test_crt_context(void *_f) HDassert(f); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of lengths in the file */ @@ -164,7 +153,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__test_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_dst_context * @@ -181,7 +169,7 @@ done: static herr_t H5B2__test_dst_context(void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -194,7 +182,6 @@ H5B2__test_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_store * @@ -218,7 +205,6 @@ H5B2__test_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_store() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_compare * @@ -243,7 +229,6 @@ H5B2__test_compare(const void *rec1, const void *rec2, int *result) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_compare() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_encode * @@ -260,7 +245,7 @@ H5B2__test_compare(const void *rec1, const void *rec2, int *result) static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -272,7 +257,6 @@ H5B2__test_encode(uint8_t *raw, const void *nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_encode() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_decode * @@ -289,7 +273,7 @@ H5B2__test_encode(uint8_t *raw, const void *nrecord, void *_ctx) static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -301,7 +285,6 @@ H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_decode() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_debug * @@ -316,20 +299,17 @@ H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, - const void H5_ATTR_UNUSED *_udata) +H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, const void H5_ATTR_UNUSED *_udata) { FUNC_ENTER_STATIC_NOERR HDassert(record); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Record:", - *(const hsize_t *)record); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Record:", *(const hsize_t *)record); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_debug() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_store * @@ -353,7 +333,6 @@ H5B2__test2_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_store() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_compare * @@ -378,7 +357,6 @@ H5B2__test2_compare(const void *rec1, const void *rec2, int *result) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_compare() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_encode * @@ -395,7 +373,7 @@ H5B2__test2_compare(const void *rec1, const void *rec2, int *result) static herr_t H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -408,7 +386,6 @@ H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_encode() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_decode * @@ -425,7 +402,7 @@ H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) static herr_t H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -438,7 +415,6 @@ H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_decode() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_debug * @@ -453,21 +429,18 @@ H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, - const void H5_ATTR_UNUSED *_udata) +H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, const void H5_ATTR_UNUSED *_udata) { FUNC_ENTER_STATIC_NOERR HDassert(record); - HDfprintf(stream, "%*s%-*s (%Hu, %Hu)\n", indent, "", fwidth, "Record:", - ((const H5B2_test_rec_t *)record)->key, - ((const H5B2_test_rec_t *)record)->val); + HDfprintf(stream, "%*s%-*s (%Hu, %Hu)\n", indent, "", fwidth, + "Record:", ((const H5B2_test_rec_t *)record)->key, ((const H5B2_test_rec_t *)record)->val); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_debug() */ - /*------------------------------------------------------------------------- * Function: H5B2__get_root_addr_test * @@ -495,7 +468,6 @@ H5B2__get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__get_root_addr_test() */ - /*------------------------------------------------------------------------- * Function: H5B2__get_node_info_test * @@ -511,13 +483,13 @@ H5B2__get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr) herr_t H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void *parent = NULL; /* Parent of current node */ - uint16_t depth; /* Current depth of the tree */ - int cmp; /* Comparison value of records */ - unsigned idx; /* Location of record which matches key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ + void * parent = NULL; /* Parent of current node */ + uint16_t depth; /* Current depth of the tree */ + int cmp; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -533,52 +505,54 @@ H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) /* Make copy of the root node pointer to start search with */ curr_node_ptr = hdr->root; - /* Set initial parent, if doing swmr writes */ - if(hdr->swmr_write) + /* Set initial parent, if doing swmr writes */ + if (hdr->swmr_write) parent = hdr; /* Current depth of the tree */ depth = hdr->depth; /* Check for empty tree */ - if(0 == curr_node_ptr.node_nrec) + if (0 == curr_node_ptr.node_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records") /* Walk down B-tree to find record or leaf node where record is located */ cmp = -1; - while(depth > 0 && cmp != 0) { - H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ - H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ + while (depth > 0 && cmp != 0) { + H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ + H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ /* Lock B-tree current node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, - udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp > 0) + if (cmp > 0) idx++; - if(cmp != 0) { + if (cmp != 0) { /* Get node pointer for next node to search */ next_node_ptr = internal->node_ptrs[idx]; /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ @@ -586,12 +560,12 @@ H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) } /* end if */ else { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Fill in information about the node */ ninfo->depth = depth; - ninfo->nrec = curr_node_ptr.node_nrec; + ninfo->nrec = curr_node_ptr.node_nrec; /* Indicate success */ HGOTO_DONE(SUCCEED) @@ -602,48 +576,46 @@ H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) } /* end while */ { - H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, - udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Indicate the depth that the record was found */ - if(cmp != 0) + if (cmp != 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record not in B-tree") } /* end block */ /* Fill in information about the leaf node */ ninfo->depth = depth; - ninfo->nrec = curr_node_ptr.node_nrec; + ninfo->nrec = curr_node_ptr.node_nrec; done: - if(parent) { + if (parent) { HDassert(ret_value < 0); - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__get_node_info_test() */ - /*------------------------------------------------------------------------- * Function: H5B2__get_node_depth_test * @@ -664,8 +636,8 @@ done: int H5B2__get_node_depth_test(H5B2_t *bt2, void *udata) { - H5B2_node_info_test_t ninfo; /* Node information */ - int ret_value = -1; /* Return information */ + H5B2_node_info_test_t ninfo; /* Node information */ + int ret_value = -1; /* Return information */ FUNC_ENTER_PACKAGE @@ -673,7 +645,7 @@ H5B2__get_node_depth_test(H5B2_t *bt2, void *udata) HDassert(bt2); /* Get information abou the node */ - if(H5B2__get_node_info_test(bt2, udata, &ninfo) < 0) + if (H5B2__get_node_info_test(bt2, udata, &ninfo) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, (-1), "error looking up node info") /* Set return value */ @@ -682,4 +654,3 @@ H5B2__get_node_depth_test(H5B2_t *bt2, void *udata) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__get_node_depth_test() */ - diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 24a6716..3fd9b51 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -26,71 +26,62 @@ /* Module Setup */ /****************/ -#include "H5Bmodule.h" /* This source code file is part of the H5B module */ - +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bpkg.h" /* B-link trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Bpkg.h" /* B-link trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache callbacks */ static herr_t H5B__cache_get_initial_load_size(void *udata, size_t *image_len); -static void *H5B__cache_deserialize(const void *image, size_t len, void *udata, - hbool_t *dirty); +static void * H5B__cache_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B__cache_image_len(const void *thing, size_t *image_len); -static herr_t H5B__cache_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5B__cache_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B__cache_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5B inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT[1] = {{ - H5AC_BT_ID, /* Metadata client ID */ - "v1 B-tree", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5B__cache_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5B__cache_deserialize, /* 'deserialize' callback */ - H5B__cache_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B__cache_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5B__cache_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_BT_ID, /* Metadata client ID */ + "v1 B-tree", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5B__cache_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5B__cache_deserialize, /* 'deserialize' callback */ + H5B__cache_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B__cache_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5B__cache_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B__cache_get_initial_load_size * @@ -107,8 +98,8 @@ const H5AC_class_t H5AC_BT[1] = {{ static herr_t H5B__cache_get_initial_load_size(void *_udata, size_t *image_len) { - H5B_cache_ud_t *udata = (H5B_cache_ud_t *)_udata; /* User data for callback */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t *udata = (H5B_cache_ud_t *)_udata; /* User data for callback */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ FUNC_ENTER_STATIC_NOERR @@ -126,7 +117,6 @@ H5B__cache_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B__cache_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B__cache_deserialize * @@ -143,15 +133,15 @@ H5B__cache_get_initial_load_size(void *_udata, size_t *image_len) */ static void * H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) + hbool_t H5_ATTR_UNUSED *dirty) { - H5B_t *bt = NULL; /* Pointer to the deserialized B-tree node */ - H5B_cache_ud_t *udata = (H5B_cache_ud_t *)_udata; /* User data for callback */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into image buffer */ - uint8_t *native; /* Pointer to native keys */ - unsigned u; /* Local index variable */ - H5B_t *ret_value = NULL; /* Return value */ + H5B_t * bt = NULL; /* Pointer to the deserialized B-tree node */ + H5B_cache_ud_t *udata = (H5B_cache_ud_t *)_udata; /* User data for callback */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into image buffer */ + uint8_t * native; /* Pointer to native keys */ + unsigned u; /* Local index variable */ + H5B_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -160,8 +150,8 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda HDassert(udata); /* Allocate the B-tree node in memory */ - if(NULL == (bt = H5FL_MALLOC(H5B_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate B-tree struct") + if (NULL == (bt = H5FL_MALLOC(H5B_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate B-tree struct") HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t)); /* Set & increment the ref-counted "shared" B-tree information for the node */ @@ -173,26 +163,26 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda HDassert(shared); /* Allocate space for the native keys and child addresses */ - if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for native keys") - if(NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for child addresses") + if (NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for native keys") + if (NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for child addresses") /* magic number */ - if(HDmemcmp(image, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree signature") + if (HDmemcmp(image, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree signature") image += H5_SIZEOF_MAGIC; /* node type and level */ - if(*image++ != (uint8_t)udata->type->id) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type") + if (*image++ != (uint8_t)udata->type->id) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type") bt->level = *image++; /* entries used */ UINT16DECODE(image, bt->nchildren); /* Check if bt->nchildren is greater than two_k */ - if(bt->nchildren > shared->two_k) + if (bt->nchildren > shared->two_k) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "number of children is greater than maximum") /* sibling pointers */ @@ -201,9 +191,9 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda /* the child/key pairs */ native = bt->native; - for(u = 0; u < bt->nchildren; u++) { + for (u = 0; u < bt->nchildren; u++) { /* Decode native key value */ - if((udata->type->decode)(shared, image, native) < 0) + if ((udata->type->decode)(shared, image, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") image += shared->sizeof_rkey; native += udata->type->sizeof_nkey; @@ -213,9 +203,9 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda } /* end for */ /* Decode final key */ - if(bt->nchildren > 0) { + if (bt->nchildren > 0) { /* Decode native key value */ - if((udata->type->decode)(shared, image, native) < 0) + if ((udata->type->decode)(shared, image, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") } /* end if */ @@ -226,14 +216,13 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda ret_value = bt; done: - if(!ret_value && bt) - if(H5B__node_dest(bt) < 0) + if (!ret_value && bt) + if (H5B__node_dest(bt) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__cache_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B__cache_image_len * @@ -250,8 +239,8 @@ done: static herr_t H5B__cache_image_len(const void *_thing, size_t *image_len) { - const H5B_t *bt = (const H5B_t *)_thing; /* Pointer to the B-tree node */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + const H5B_t * bt = (const H5B_t *)_thing; /* Pointer to the B-tree node */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ FUNC_ENTER_STATIC_NOERR @@ -269,7 +258,6 @@ H5B__cache_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B__cache_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B__cache_serialize * @@ -284,15 +272,14 @@ H5B__cache_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) +H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { - H5B_t *bt = (H5B_t *)_thing; /* Pointer to the B-tree node */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - uint8_t *image = (uint8_t *)_image; /* Pointer into image buffer */ - uint8_t *native; /* Pointer to native keys */ - unsigned u; /* Local index counter */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B_t * bt = (H5B_t *)_thing; /* Pointer to the B-tree node */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + uint8_t * image = (uint8_t *)_image; /* Pointer into image buffer */ + uint8_t * native; /* Pointer to native keys */ + unsigned u; /* Local index counter */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -313,8 +300,8 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, *image++ = (uint8_t)shared->type->id; /* 2^8 limit: only 1 byte is used to store node level */ - if(bt->level >= HDpow(2, LEVEL_BITS)) - HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode node level") + if (bt->level >= HDpow(2, LEVEL_BITS)) + HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode node level") H5_CHECK_OVERFLOW(bt->level, unsigned, uint8_t); *image++ = (uint8_t)bt->level; @@ -328,9 +315,9 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, /* child keys and pointers */ native = bt->native; - for(u = 0; u < bt->nchildren; ++u) { + for (u = 0; u < bt->nchildren; ++u) { /* encode the key */ - if(shared->type->encode(shared, image, native) < 0) + if (shared->type->encode(shared, image, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key") image += shared->sizeof_rkey; native += shared->type->sizeof_nkey; @@ -338,9 +325,9 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, /* encode the child address */ H5F_addr_encode(f, &image, bt->child[u]); } /* end for */ - if(bt->nchildren > 0) { + if (bt->nchildren > 0) { /* Encode the final key */ - if(shared->type->encode(shared, image, native) < 0) + if (shared->type->encode(shared, image, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key") image += shared->sizeof_rkey; } /* end if */ @@ -355,7 +342,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__cache_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B__cache_free_icr * @@ -372,7 +358,7 @@ done: static herr_t H5B__cache_free_icr(void *thing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -380,10 +366,9 @@ H5B__cache_free_icr(void *thing) HDassert(thing); /* Destroy B-tree node */ - if(H5B__node_dest((H5B_t *)thing) < 0) + if (H5B__node_dest((H5B_t *)thing) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__cache_free_icr() */ - diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index d900852..612d876 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -26,19 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Bmodule.h" /* This source code file is part of the H5B module */ - +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bpkg.h" /* B-link trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Bpkg.h" /* B-link trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ - /*------------------------------------------------------------------------- * Function: H5B_debug * @@ -54,12 +51,12 @@ herr_t H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B_class_t *type, void *udata) { - H5B_t *bt = NULL; - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_t * bt = NULL; + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -77,7 +74,7 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5 HDassert(!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -85,73 +82,58 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5 /* * Load the tree node. */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") /* * Print the values. */ + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Tree type ID:", + ((shared->type->id) == H5B_SNODE_ID + ? "H5B_SNODE_ID" + : ((shared->type->id) == H5B_CHUNK_ID ? "H5B_CHUNK_ID" : "Unknown!"))); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", shared->sizeof_rnode); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of raw (disk) key:", shared->sizeof_rkey); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Tree type ID:", - ((shared->type->id) == H5B_SNODE_ID ? "H5B_SNODE_ID" : - ((shared->type->id) == H5B_CHUNK_ID ? "H5B_CHUNK_ID" : "Unknown!"))); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of node:", - shared->sizeof_rnode); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of raw (disk) key:", - shared->sizeof_rkey); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - bt->cache_info.is_dirty ? "True" : "False"); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Level:", - bt->level); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of left sibling:", - bt->left); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of right sibling:", - bt->right); - HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, - "Number of children (max):", - bt->nchildren, shared->two_k); + "Dirty flag:", bt->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Level:", bt->level); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of left sibling:", bt->left); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of right sibling:", bt->right); + HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, "Number of children (max):", bt->nchildren, + shared->two_k); /* * Print the child addresses */ - for(u = 0; u < bt->nchildren; u++) { + for (u = 0; u < bt->nchildren; u++) { HDfprintf(stream, "%*sChild %d...\n", indent, "", u); - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), - "Address:", bt->child[u]); + HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "Address:", bt->child[u]); /* If there is a key debugging routine, use it to display the left & right keys */ - if(type->debug_key) { + if (type->debug_key) { /* Decode the 'left' key & print it */ - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - "Left Key:"); - HDassert(H5B_NKEY(bt,shared,u)); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Left Key:"); + HDassert(H5B_NKEY(bt, shared, u)); (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), H5B_NKEY(bt, shared, u), udata); /* Decode the 'right' key & print it */ - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - "Right Key:"); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Right Key:"); HDassert(H5B_NKEY(bt, shared, u + 1)); - (void)(type->debug_key)(stream, indent + 6, MAX (0, fwidth - 6), H5B_NKEY(bt, shared, u + 1), udata); + (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), H5B_NKEY(bt, shared, u + 1), + udata); } /* end if */ - } /* end for */ + } /* end for */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_debug() */ - /*------------------------------------------------------------------------- * Function: H5B__assert * @@ -170,52 +152,52 @@ done: herr_t H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata) { - H5B_t *bt = NULL; - H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - int ncell, cmp; - static int ncalls = 0; - herr_t status; - herr_t ret_value = SUCCEED; /* Return value */ + H5B_t * bt = NULL; + H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + int ncell, cmp; + static int ncalls = 0; + herr_t status; + herr_t ret_value = SUCCEED; /* Return value */ /* A queue of child data */ struct child_t { - haddr_t addr; - unsigned level; - struct child_t *next; + haddr_t addr; + unsigned level; + struct child_t *next; } *head = NULL, *tail = NULL, *prev = NULL, *cur = NULL, *tmp = NULL; FUNC_ENTER_PACKAGE - if(0 == ncalls++) { - if(H5DEBUG(B)) + if (0 == ncalls++) { + if (H5DEBUG(B)) HDfprintf(H5DEBUG(B), "H5B: debugging B-trees (expensive)\n"); } /* end if */ /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); /* Initialize the queue */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG); + bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG); HDassert(bt); shared = (H5B_shared_t *)H5UC_GET_OBJ(bt->rc_shared); HDassert(shared); cur = (struct child_t *)H5MM_calloc(sizeof(struct child_t)); HDassert(cur); - cur->addr = addr; + cur->addr = addr; cur->level = bt->level; head = tail = cur; status = H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET); HDassert(status >= 0); - bt = NULL; /* Make certain future references will be caught */ + bt = NULL; /* Make certain future references will be caught */ /* * Do a breadth-first search of the tree. New nodes are added to the end @@ -223,58 +205,58 @@ H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata) * remove any nodes from the queue because we need them in the uniqueness * test. */ - for(ncell = 0; cur; ncell++) { + for (ncell = 0; cur; ncell++) { bt = (H5B_t *)H5AC_protect(f, H5AC_BT, cur->addr, &cache_udata, H5AC__READ_ONLY_FLAG); HDassert(bt); /* Check node header */ HDassert(bt->level == cur->level); - if(cur->next && cur->next->level == bt->level) + if (cur->next && cur->next->level == bt->level) HDassert(H5F_addr_eq(bt->right, cur->next->addr)); else HDassert(!H5F_addr_defined(bt->right)); - if(prev && prev->level == bt->level) + if (prev && prev->level == bt->level) HDassert(H5F_addr_eq(bt->left, prev->addr)); else HDassert(!H5F_addr_defined(bt->left)); - if(cur->level > 0) { + if (cur->level > 0) { unsigned u; - for(u = 0; u < bt->nchildren; u++) { + for (u = 0; u < bt->nchildren; u++) { /* * Check that child nodes haven't already been seen. If they * have then the tree has a cycle. */ - for(tmp = head; tmp; tmp = tmp->next) + for (tmp = head; tmp; tmp = tmp->next) HDassert(H5F_addr_ne(tmp->addr, bt->child[u])); /* Add the child node to the end of the queue */ tmp = (struct child_t *)H5MM_calloc(sizeof(struct child_t)); HDassert(tmp); - tmp->addr = bt->child[u]; + tmp->addr = bt->child[u]; tmp->level = bt->level - 1; tail->next = tmp; - tail = tmp; + tail = tmp; /* Check that the keys are monotonically increasing */ cmp = (type->cmp2)(H5B_NKEY(bt, shared, u), udata, H5B_NKEY(bt, shared, u + 1)); HDassert(cmp < 0); } /* end for */ - } /* end if */ + } /* end if */ /* Release node */ status = H5AC_unprotect(f, H5AC_BT, cur->addr, bt, H5AC__NO_FLAGS_SET); HDassert(status >= 0); - bt = NULL; /* Make certain future references will be caught */ + bt = NULL; /* Make certain future references will be caught */ /* Advance current location in queue */ prev = cur; - cur = cur->next; + cur = cur->next; } /* end for */ /* Free all entries from queue */ - while(head) { + while (head) { tmp = head->next; H5MM_xfree(head); head = tmp; @@ -284,4 +266,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__assert() */ #endif /* H5B_DEBUG */ - diff --git a/src/H5Bmodule.h b/src/H5Bmodule.h index c8e1546..a756541 100644 --- a/src/H5Bmodule.h +++ b/src/H5Bmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5B_MODULE -#define H5_MY_PKG H5B -#define H5_MY_PKG_ERR H5E_BTREE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5B +#define H5_MY_PKG_ERR H5E_BTREE +#define H5_MY_PKG_INIT NO #endif /* _H5Bmodule_H */ - diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index a57584e..37be7f2 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -30,18 +30,16 @@ #include "H5Bprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Get the native key at a given index */ -#define H5B_NKEY(b, shared, idx) ((b)->native + (shared)->nkey[(idx)]) -#define LEVEL_BITS 8 /* # of bits for node level: 1 byte */ - +#define H5B_NKEY(b, shared, idx) ((b)->native + (shared)->nkey[(idx)]) +#define LEVEL_BITS 8 /* # of bits for node level: 1 byte */ /****************************/ /* Package Private Typedefs */ @@ -49,22 +47,22 @@ /* The B-tree node as stored in memory... */ typedef struct H5B_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions */ - /* _must_ be first field in structure */ - H5UC_t *rc_shared; /*ref-counted shared info */ - unsigned level; /*node level */ - unsigned nchildren; /*number of child pointers */ - haddr_t left; /*address of left sibling */ - haddr_t right; /*address of right sibling */ - uint8_t *native; /*array of keys in native format */ - haddr_t *child; /*2k child pointers */ + H5AC_info_t cache_info; /* Information for H5AC cache functions */ + /* _must_ be first field in structure */ + H5UC_t * rc_shared; /*ref-counted shared info */ + unsigned level; /*node level */ + unsigned nchildren; /*number of child pointers */ + haddr_t left; /*address of left sibling */ + haddr_t right; /*address of right sibling */ + uint8_t *native; /*array of keys in native format */ + haddr_t *child; /*2k child pointers */ } H5B_t; /* Callback info for loading a B-tree node into the cache */ typedef struct H5B_cache_ud_t { - H5F_t *f; /* File that B-tree node is within */ - const struct H5B_class_t *type; /* Type of tree */ - H5UC_t *rc_shared; /* Ref-counted shared info */ + H5F_t * f; /* File that B-tree node is within */ + const struct H5B_class_t *type; /* Type of tree */ + H5UC_t * rc_shared; /* Ref-counted shared info */ } H5B_cache_ud_t; /*****************************/ @@ -80,7 +78,6 @@ H5FL_BLK_EXTERN(native_block); /* Declare a free list to manage the H5B_t struct */ H5FL_EXTERN(H5B_t); - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -90,4 +87,3 @@ herr_t H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata) #endif #endif /*_H5Bpkg_H*/ - diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 55bf5b3..ae47162 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -25,11 +25,10 @@ #ifndef _H5Bprivate_H #define _H5Bprivate_H - /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File access */ -#include "H5UCprivate.h" /* Reference counted object functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ +#include "H5UCprivate.h" /* Reference counted object functions */ /**************************/ /* Library Private Macros */ @@ -42,10 +41,9 @@ * being enabled. */ #ifdef NDEBUG -# undef H5B_DEBUG +#undef H5B_DEBUG #endif - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -55,47 +53,46 @@ * nodes) they use will need to be stored in the file somewhere. -QAK */ typedef enum H5B_subid_t { - H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */ - H5B_CHUNK_ID = 1, /*B-tree is for chunked dataset storage */ - H5B_NUM_BTREE_ID /* Number of B-tree key IDs (must be last) */ + H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */ + H5B_CHUNK_ID = 1, /*B-tree is for chunked dataset storage */ + H5B_NUM_BTREE_ID /* Number of B-tree key IDs (must be last) */ } H5B_subid_t; /* Define return values from B-tree insertion callbacks */ typedef enum H5B_ins_t { - H5B_INS_ERROR = -1, /*error return value */ - H5B_INS_NOOP = 0, /*insert made no changes */ - H5B_INS_LEFT = 1, /*insert new node to left of cur node */ - H5B_INS_RIGHT = 2, /*insert new node to right of cur node */ - H5B_INS_CHANGE = 3, /*change child address for cur node */ - H5B_INS_FIRST = 4, /*insert first node in (sub)tree */ - H5B_INS_REMOVE = 5 /*remove current node */ + H5B_INS_ERROR = -1, /*error return value */ + H5B_INS_NOOP = 0, /*insert made no changes */ + H5B_INS_LEFT = 1, /*insert new node to left of cur node */ + H5B_INS_RIGHT = 2, /*insert new node to right of cur node */ + H5B_INS_CHANGE = 3, /*change child address for cur node */ + H5B_INS_FIRST = 4, /*insert first node in (sub)tree */ + H5B_INS_REMOVE = 5 /*remove current node */ } H5B_ins_t; /* Enum for specifying the direction of the critical key in relation to the * child */ typedef enum H5B_dir_t { - H5B_LEFT = 0, /* Critical key is to the left */ - H5B_RIGHT = 1 /* Critical key is to the right */ + H5B_LEFT = 0, /* Critical key is to the left */ + H5B_RIGHT = 1 /* Critical key is to the right */ } H5B_dir_t; /* Define the operator callback function pointer for H5B_iterate() */ -typedef int (*H5B_operator_t)(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); +typedef int (*H5B_operator_t)(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); /* Each B-tree has certain information that can be shared across all * the instances of nodes in that B-tree. */ typedef struct H5B_shared_t { - const struct H5B_class_t *type; /* Type of tree */ - unsigned two_k; /* 2*"K" value for tree's nodes */ - size_t sizeof_rkey; /* Size of raw (disk) key */ - size_t sizeof_rnode; /* Size of raw (disk) node */ - size_t sizeof_keys; /* Size of native (memory) key node */ - size_t sizeof_addr; /* Size of file address (in bytes) */ - size_t sizeof_len; /* Size of file lengths (in bytes) */ - uint8_t *page; /* Disk page */ - size_t *nkey; /* Offsets of each native key in native key buffer */ - void *udata; /* 'Local' info for a B-tree */ + const struct H5B_class_t *type; /* Type of tree */ + unsigned two_k; /* 2*"K" value for tree's nodes */ + size_t sizeof_rkey; /* Size of raw (disk) key */ + size_t sizeof_rnode; /* Size of raw (disk) node */ + size_t sizeof_keys; /* Size of native (memory) key node */ + size_t sizeof_addr; /* Size of file address (in bytes) */ + size_t sizeof_len; /* Size of file lengths (in bytes) */ + uint8_t * page; /* Disk page */ + size_t * nkey; /* Offsets of each native key in native key buffer */ + void * udata; /* 'Local' info for a B-tree */ } H5B_shared_t; /* @@ -107,69 +104,57 @@ typedef struct H5B_shared_t { */ typedef struct H5B_class_t { - H5B_subid_t id; /*id as found in file*/ - size_t sizeof_nkey; /*size of native (memory) key*/ - H5UC_t * (*get_shared)(const H5F_t*, const void*); /*shared info for node */ - herr_t (*new_node)(H5F_t*, H5B_ins_t, void*, void*, void*, haddr_t*); - int (*cmp2)(void*, void*, void*); /*compare 2 keys */ - int (*cmp3)(void*, void*, void*); /*compare 3 keys */ - htri_t (*found)(H5F_t*, haddr_t, const void*, void*); + H5B_subid_t id; /*id as found in file*/ + size_t sizeof_nkey; /*size of native (memory) key*/ + H5UC_t *(*get_shared)(const H5F_t *, const void *); /*shared info for node */ + herr_t (*new_node)(H5F_t *, H5B_ins_t, void *, void *, void *, haddr_t *); + int (*cmp2)(void *, void *, void *); /*compare 2 keys */ + int (*cmp3)(void *, void *, void *); /*compare 3 keys */ + htri_t (*found)(H5F_t *, haddr_t, const void *, void *); /* insert new data */ - H5B_ins_t (*insert)(H5F_t*, haddr_t, void*, hbool_t*, void*, void*, - void*, hbool_t*, haddr_t*); + H5B_ins_t (*insert)(H5F_t *, haddr_t, void *, hbool_t *, void *, void *, void *, hbool_t *, haddr_t *); /* min insert uses min leaf, not new(), similarly for max insert */ - hbool_t follow_min; - hbool_t follow_max; + hbool_t follow_min; + hbool_t follow_max; /* The direction of the key that is intrinsically associated with each node */ - H5B_dir_t critical_key; + H5B_dir_t critical_key; /* remove existing data */ - H5B_ins_t (*remove)(H5F_t*, haddr_t, void*, hbool_t*, void*, void*, hbool_t*); + H5B_ins_t (*remove)(H5F_t *, haddr_t, void *, hbool_t *, void *, void *, hbool_t *); /* encode, decode, debug key values */ - herr_t (*decode)(const H5B_shared_t*, const uint8_t*, void*); - herr_t (*encode)(const H5B_shared_t*, uint8_t*, const void*); - herr_t (*debug_key)(FILE*, int, int, const void*, const void*); + herr_t (*decode)(const H5B_shared_t *, const uint8_t *, void *); + herr_t (*encode)(const H5B_shared_t *, uint8_t *, const void *); + herr_t (*debug_key)(FILE *, int, int, const void *, const void *); } H5B_class_t; /* Information about B-tree */ typedef struct H5B_info_t { - hsize_t size; /* Size of B-tree nodes */ - hsize_t num_nodes; /* Number of B-tree nodes */ + hsize_t size; /* Size of B-tree nodes */ + hsize_t num_nodes; /* Number of B-tree nodes */ } H5B_info_t; - - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL herr_t H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, - haddr_t *addr_p/*out*/); -H5_DLL herr_t H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, - void *udata); -H5_DLL herr_t H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, - void *udata); -H5_DLL herr_t H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_operator_t op, void *udata); -H5_DLL herr_t H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_info_t *bt_info, H5B_operator_t op, void *udata); -H5_DLL herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, - void *udata); -H5_DLL herr_t H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, - void *udata); -H5_DLL H5B_shared_t *H5B_shared_new(const H5F_t *f, const H5B_class_t *type, - size_t sizeof_rkey); -H5_DLL herr_t H5B_shared_free(void *_shared); -H5_DLL herr_t H5B_debug(H5F_t *f, haddr_t addr, FILE * stream, - int indent, int fwidth, const H5B_class_t *type, void *udata); +H5_DLL herr_t H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p /*out*/); +H5_DLL herr_t H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata); +H5_DLL herr_t H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata); +H5_DLL herr_t H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_operator_t op, void *udata); +H5_DLL herr_t H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_info_t *bt_info, + H5B_operator_t op, void *udata); +H5_DLL herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata); +H5_DLL herr_t H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata); +H5_DLL H5B_shared_t *H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey); +H5_DLL herr_t H5B_shared_free(void *_shared); +H5_DLL herr_t H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B_class_t *type, + void *udata); H5_DLL htri_t H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr); #endif /* _H5Bprivate_H */ - diff --git a/src/H5C.c b/src/H5C.c index 3b094da..3dac99e 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -72,37 +72,34 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /* suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /* suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5retry_private.h" /* Retry loops. */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5retry_private.h" /* Retry loops. */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ #if H5C_DO_MEMORY_SANITY_CHECKS -#define H5C_IMAGE_EXTRA_SPACE 8 +#define H5C_IMAGE_EXTRA_SPACE 8 #define H5C_IMAGE_SANITY_VALUE "DeadBeef" #else /* H5C_DO_MEMORY_SANITY_CHECKS */ #define H5C_IMAGE_EXTRA_SPACE 0 #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - /******************/ /* Local Typedefs */ /******************/ @@ -110,41 +107,32 @@ /* Alias for pointer to cache entry, for use when allocating sequences of them */ typedef H5C_cache_entry_t *H5C_cache_entry_ptr_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5C__pin_entry_from_client(H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr); +static herr_t H5C__pin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); -static herr_t H5C__unpin_entry_real(H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr, hbool_t update_rp); +static herr_t H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp); -static herr_t H5C__unpin_entry_from_client(H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr, hbool_t update_rp); +static herr_t H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp); static herr_t H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout(H5F_t * f, - double hit_rate, - enum H5C_resize_status * status_ptr, - size_t * new_max_cache_size_ptr, - hbool_t write_permitted); +static herr_t H5C__autoadjust__ageout(H5F_t *f, double hit_rate, enum H5C_resize_status *status_ptr, + size_t *new_max_cache_size_ptr, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t * cache_ptr); +static herr_t H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr); -static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, - hbool_t write_permitted); +static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr); +static herr_t H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr); -static herr_t H5C__autoadjust__ageout__remove_all_markers(H5C_t * cache_ptr); +static herr_t H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr); -static herr_t H5C__autoadjust__ageout__remove_excess_markers(H5C_t * cache_ptr); +static herr_t H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr); -static herr_t H5C__flash_increase_cache_size(H5C_t * cache_ptr, - size_t old_entry_size, size_t new_entry_size); +static herr_t H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t new_entry_size); static herr_t H5C__flush_invalidate_cache(H5F_t *f, unsigned flags); @@ -152,42 +140,37 @@ static herr_t H5C_flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flag static herr_t H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags); -static void * H5C_load_entry(H5F_t * f, +static void *H5C_load_entry(H5F_t *f, #ifdef H5_HAVE_PARALLEL - hbool_t coll_access, + hbool_t coll_access, #endif /* H5_HAVE_PARALLEL */ - const H5C_class_t * type, - haddr_t addr, - void * udata); + const H5C_class_t *type, haddr_t addr, void *udata); -static herr_t H5C__mark_flush_dep_dirty(H5C_cache_entry_t * entry); +static herr_t H5C__mark_flush_dep_dirty(H5C_cache_entry_t *entry); -static herr_t H5C__mark_flush_dep_clean(H5C_cache_entry_t * entry); +static herr_t H5C__mark_flush_dep_clean(H5C_cache_entry_t *entry); static herr_t H5C__serialize_ring(H5F_t *f, H5C_ring_t ring); -static herr_t H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr); +static herr_t H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); -static herr_t H5C__verify_len_eoa(H5F_t *f, const H5C_class_t * type, - haddr_t addr, size_t *len, hbool_t actual); +static herr_t H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, size_t *len, + hbool_t actual); #if H5C_DO_SLIST_SANITY_CHECKS -static hbool_t H5C_entry_in_skip_list(H5C_t * cache_ptr, - H5C_cache_entry_t *target_ptr); +static hbool_t H5C_entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr); #endif /* H5C_DO_SLIST_SANITY_CHECKS */ #if H5C_DO_EXTREME_SANITY_CHECKS -static herr_t H5C_validate_lru_list(H5C_t * cache_ptr); -static herr_t H5C_validate_pinned_entry_list(H5C_t * cache_ptr); -static herr_t H5C_validate_protected_entry_list(H5C_t * cache_ptr); +static herr_t H5C_validate_lru_list(H5C_t *cache_ptr); +static herr_t H5C_validate_pinned_entry_list(H5C_t *cache_ptr); +static herr_t H5C_validate_protected_entry_list(H5C_t *cache_ptr); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ #ifndef NDEBUG -static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t * entry, - const H5C_cache_entry_t * base_entry); +static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, + const H5C_cache_entry_t *base_entry); #endif /* NDEBUG */ - /*********************/ /* Package Variables */ /*********************/ @@ -198,12 +181,10 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Declare a free list to manage the tag info struct */ H5FL_DEFINE(H5C_tag_info_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -214,8 +195,6 @@ H5FL_DEFINE_STATIC(H5C_t); /* Declare a free list to manage arrays of cache entries */ H5FL_SEQ_DEFINE_STATIC(H5C_cache_entry_ptr_t); - - /*------------------------------------------------------------------------- * Function: H5C_create * @@ -241,209 +220,202 @@ H5FL_SEQ_DEFINE_STATIC(H5C_cache_entry_ptr_t); *------------------------------------------------------------------------- */ H5C_t * -H5C_create(size_t max_cache_size, - size_t min_clean_size, - int max_type_id, - const H5C_class_t * const * class_table_ptr, - H5C_write_permitted_func_t check_write_permitted, - hbool_t write_permitted, - H5C_log_flush_func_t log_flush, - void * aux_ptr) +H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, + const H5C_class_t *const *class_table_ptr, H5C_write_permitted_func_t check_write_permitted, + hbool_t write_permitted, H5C_log_flush_func_t log_flush, void *aux_ptr) { - int i; - H5C_t * cache_ptr = NULL; - H5C_t * ret_value = NULL; /* Return value */ + int i; + H5C_t *cache_ptr = NULL; + H5C_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - HDassert( max_cache_size >= H5C__MIN_MAX_CACHE_SIZE ); - HDassert( max_cache_size <= H5C__MAX_MAX_CACHE_SIZE ); - HDassert( min_clean_size <= max_cache_size ); + HDassert(max_cache_size >= H5C__MIN_MAX_CACHE_SIZE); + HDassert(max_cache_size <= H5C__MAX_MAX_CACHE_SIZE); + HDassert(min_clean_size <= max_cache_size); - HDassert( max_type_id >= 0 ); - HDassert( max_type_id < H5C__MAX_NUM_TYPE_IDS ); - HDassert( class_table_ptr ); + HDassert(max_type_id >= 0); + HDassert(max_type_id < H5C__MAX_NUM_TYPE_IDS); + HDassert(class_table_ptr); - for ( i = 0; i <= max_type_id; i++ ) { - HDassert( (class_table_ptr)[i] ); + for (i = 0; i <= max_type_id; i++) { + HDassert((class_table_ptr)[i]); HDassert(HDstrlen((class_table_ptr)[i]->name) > 0); } /* end for */ - if(NULL == (cache_ptr = H5FL_CALLOC(H5C_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (cache_ptr = H5FL_CALLOC(H5C_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, NULL, "can't create skip list") - if(NULL == (cache_ptr->tag_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (cache_ptr->tag_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, NULL, "can't create skip list for tagged entry addresses") /* If we get this far, we should succeed. Go ahead and initialize all * the fields. */ - cache_ptr->magic = H5C__H5C_T_MAGIC; + cache_ptr->magic = H5C__H5C_T_MAGIC; - cache_ptr->flush_in_progress = FALSE; + cache_ptr->flush_in_progress = FALSE; - if(NULL == (cache_ptr->log_info = (H5C_log_info_t *)H5MM_calloc(sizeof(H5C_log_info_t)))) + if (NULL == (cache_ptr->log_info = (H5C_log_info_t *)H5MM_calloc(sizeof(H5C_log_info_t)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed") - cache_ptr->aux_ptr = aux_ptr; + cache_ptr->aux_ptr = aux_ptr; - cache_ptr->max_type_id = max_type_id; + cache_ptr->max_type_id = max_type_id; - cache_ptr->class_table_ptr = class_table_ptr; + cache_ptr->class_table_ptr = class_table_ptr; - cache_ptr->max_cache_size = max_cache_size; - cache_ptr->min_clean_size = min_clean_size; + cache_ptr->max_cache_size = max_cache_size; + cache_ptr->min_clean_size = min_clean_size; - cache_ptr->check_write_permitted = check_write_permitted; - cache_ptr->write_permitted = write_permitted; + cache_ptr->check_write_permitted = check_write_permitted; + cache_ptr->write_permitted = write_permitted; - cache_ptr->log_flush = log_flush; + cache_ptr->log_flush = log_flush; - cache_ptr->evictions_enabled = TRUE; - cache_ptr->close_warning_received = FALSE; + cache_ptr->evictions_enabled = TRUE; + cache_ptr->close_warning_received = FALSE; - cache_ptr->index_len = 0; - cache_ptr->index_size = (size_t)0; - cache_ptr->clean_index_size = (size_t)0; - cache_ptr->dirty_index_size = (size_t)0; + cache_ptr->index_len = 0; + cache_ptr->index_size = (size_t)0; + cache_ptr->clean_index_size = (size_t)0; + cache_ptr->dirty_index_size = (size_t)0; - for(i = 0; i < H5C_RING_NTYPES; i++) { - cache_ptr->index_ring_len[i] = 0; - cache_ptr->index_ring_size[i] = (size_t)0; - cache_ptr->clean_index_ring_size[i] = (size_t)0; - cache_ptr->dirty_index_ring_size[i] = (size_t)0; + for (i = 0; i < H5C_RING_NTYPES; i++) { + cache_ptr->index_ring_len[i] = 0; + cache_ptr->index_ring_size[i] = (size_t)0; + cache_ptr->clean_index_ring_size[i] = (size_t)0; + cache_ptr->dirty_index_ring_size[i] = (size_t)0; - cache_ptr->slist_ring_len[i] = 0; - cache_ptr->slist_ring_size[i] = (size_t)0; + cache_ptr->slist_ring_len[i] = 0; + cache_ptr->slist_ring_size[i] = (size_t)0; } /* end for */ - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) { + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { (cache_ptr->index)[i] = NULL; } - cache_ptr->il_len = 0; - cache_ptr->il_size = (size_t)0; - cache_ptr->il_head = NULL; - cache_ptr->il_tail = NULL; + cache_ptr->il_len = 0; + cache_ptr->il_size = (size_t)0; + cache_ptr->il_head = NULL; + cache_ptr->il_tail = NULL; /* Fields supporting VFD SWMR */ - cache_ptr->vfd_swmr_reader = FALSE; - for(i = 0; i < H5C__PAGE_HASH_TABLE_LEN; i++) { + cache_ptr->vfd_swmr_reader = FALSE; + for (i = 0; i < H5C__PAGE_HASH_TABLE_LEN; i++) { (cache_ptr->page_index)[i] = NULL; } - cache_ptr->page_size = 0; + cache_ptr->page_size = 0; /* Tagging Field Initializations */ - cache_ptr->ignore_tags = FALSE; - cache_ptr->num_objs_corked = 0; + cache_ptr->ignore_tags = FALSE; + cache_ptr->num_objs_corked = 0; - cache_ptr->slist_changed = FALSE; - cache_ptr->slist_len = 0; - cache_ptr->slist_size = (size_t)0; + cache_ptr->slist_changed = FALSE; + cache_ptr->slist_len = 0; + cache_ptr->slist_size = (size_t)0; #if H5C_DO_SANITY_CHECKS - cache_ptr->slist_len_increase = 0; - cache_ptr->slist_size_increase = 0; + cache_ptr->slist_len_increase = 0; + cache_ptr->slist_size_increase = 0; #endif /* H5C_DO_SANITY_CHECKS */ - cache_ptr->entries_removed_counter = 0; - cache_ptr->last_entry_removed_ptr = NULL; - cache_ptr->entry_watched_for_removal = NULL; + cache_ptr->entries_removed_counter = 0; + cache_ptr->last_entry_removed_ptr = NULL; + cache_ptr->entry_watched_for_removal = NULL; - cache_ptr->pl_len = 0; - cache_ptr->pl_size = (size_t)0; - cache_ptr->pl_head_ptr = NULL; - cache_ptr->pl_tail_ptr = NULL; + cache_ptr->pl_len = 0; + cache_ptr->pl_size = (size_t)0; + cache_ptr->pl_head_ptr = NULL; + cache_ptr->pl_tail_ptr = NULL; - cache_ptr->pel_len = 0; - cache_ptr->pel_size = (size_t)0; - cache_ptr->pel_head_ptr = NULL; - cache_ptr->pel_tail_ptr = NULL; + cache_ptr->pel_len = 0; + cache_ptr->pel_size = (size_t)0; + cache_ptr->pel_head_ptr = NULL; + cache_ptr->pel_tail_ptr = NULL; - cache_ptr->LRU_list_len = 0; - cache_ptr->LRU_list_size = (size_t)0; - cache_ptr->LRU_head_ptr = NULL; - cache_ptr->LRU_tail_ptr = NULL; + cache_ptr->LRU_list_len = 0; + cache_ptr->LRU_list_size = (size_t)0; + cache_ptr->LRU_head_ptr = NULL; + cache_ptr->LRU_tail_ptr = NULL; #ifdef H5_HAVE_PARALLEL - cache_ptr->coll_list_len = 0; - cache_ptr->coll_list_size = (size_t)0; - cache_ptr->coll_head_ptr = NULL; - cache_ptr->coll_tail_ptr = NULL; - cache_ptr->coll_write_list = NULL; + cache_ptr->coll_list_len = 0; + cache_ptr->coll_list_size = (size_t)0; + cache_ptr->coll_head_ptr = NULL; + cache_ptr->coll_tail_ptr = NULL; + cache_ptr->coll_write_list = NULL; #endif /* H5_HAVE_PARALLEL */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - cache_ptr->cLRU_list_len = 0; - cache_ptr->cLRU_list_size = (size_t)0; - cache_ptr->cLRU_head_ptr = NULL; - cache_ptr->cLRU_tail_ptr = NULL; - - cache_ptr->dLRU_list_len = 0; - cache_ptr->dLRU_list_size = (size_t)0; - cache_ptr->dLRU_head_ptr = NULL; - cache_ptr->dLRU_tail_ptr = NULL; + cache_ptr->cLRU_list_len = 0; + cache_ptr->cLRU_list_size = (size_t)0; + cache_ptr->cLRU_head_ptr = NULL; + cache_ptr->cLRU_tail_ptr = NULL; + + cache_ptr->dLRU_list_len = 0; + cache_ptr->dLRU_list_size = (size_t)0; + cache_ptr->dLRU_head_ptr = NULL; + cache_ptr->dLRU_tail_ptr = NULL; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - cache_ptr->size_increase_possible = FALSE; - cache_ptr->flash_size_increase_possible = FALSE; - cache_ptr->flash_size_increase_threshold = 0; - cache_ptr->size_decrease_possible = FALSE; - cache_ptr->resize_enabled = FALSE; - cache_ptr->cache_full = FALSE; - cache_ptr->size_decreased = FALSE; - cache_ptr->resize_in_progress = FALSE; - cache_ptr->msic_in_progress = FALSE; - - (cache_ptr->resize_ctl).version = H5C__CURR_AUTO_SIZE_CTL_VER; - (cache_ptr->resize_ctl).rpt_fcn = NULL; - (cache_ptr->resize_ctl).set_initial_size = FALSE; - (cache_ptr->resize_ctl).initial_size = H5C__DEF_AR_INIT_SIZE; - (cache_ptr->resize_ctl).min_clean_fraction = H5C__DEF_AR_MIN_CLEAN_FRAC; - (cache_ptr->resize_ctl).max_size = H5C__DEF_AR_MAX_SIZE; - (cache_ptr->resize_ctl).min_size = H5C__DEF_AR_MIN_SIZE; - (cache_ptr->resize_ctl).epoch_length = H5C__DEF_AR_EPOCH_LENGTH; - - (cache_ptr->resize_ctl).incr_mode = H5C_incr__off; - (cache_ptr->resize_ctl).lower_hr_threshold = H5C__DEF_AR_LOWER_THRESHHOLD; - (cache_ptr->resize_ctl).increment = H5C__DEF_AR_INCREMENT; - (cache_ptr->resize_ctl).apply_max_increment = TRUE; - (cache_ptr->resize_ctl).max_increment = H5C__DEF_AR_MAX_INCREMENT; - - (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; - (cache_ptr->resize_ctl).flash_multiple = 1.0f; - (cache_ptr->resize_ctl).flash_threshold = 0.25f; - - (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; - (cache_ptr->resize_ctl).upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; - (cache_ptr->resize_ctl).decrement = H5C__DEF_AR_DECREMENT; - (cache_ptr->resize_ctl).apply_max_decrement = TRUE; - (cache_ptr->resize_ctl).max_decrement = H5C__DEF_AR_MAX_DECREMENT; + cache_ptr->size_increase_possible = FALSE; + cache_ptr->flash_size_increase_possible = FALSE; + cache_ptr->flash_size_increase_threshold = 0; + cache_ptr->size_decrease_possible = FALSE; + cache_ptr->resize_enabled = FALSE; + cache_ptr->cache_full = FALSE; + cache_ptr->size_decreased = FALSE; + cache_ptr->resize_in_progress = FALSE; + cache_ptr->msic_in_progress = FALSE; + + (cache_ptr->resize_ctl).version = H5C__CURR_AUTO_SIZE_CTL_VER; + (cache_ptr->resize_ctl).rpt_fcn = NULL; + (cache_ptr->resize_ctl).set_initial_size = FALSE; + (cache_ptr->resize_ctl).initial_size = H5C__DEF_AR_INIT_SIZE; + (cache_ptr->resize_ctl).min_clean_fraction = H5C__DEF_AR_MIN_CLEAN_FRAC; + (cache_ptr->resize_ctl).max_size = H5C__DEF_AR_MAX_SIZE; + (cache_ptr->resize_ctl).min_size = H5C__DEF_AR_MIN_SIZE; + (cache_ptr->resize_ctl).epoch_length = H5C__DEF_AR_EPOCH_LENGTH; + + (cache_ptr->resize_ctl).incr_mode = H5C_incr__off; + (cache_ptr->resize_ctl).lower_hr_threshold = H5C__DEF_AR_LOWER_THRESHHOLD; + (cache_ptr->resize_ctl).increment = H5C__DEF_AR_INCREMENT; + (cache_ptr->resize_ctl).apply_max_increment = TRUE; + (cache_ptr->resize_ctl).max_increment = H5C__DEF_AR_MAX_INCREMENT; + + (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; + (cache_ptr->resize_ctl).flash_multiple = 1.0f; + (cache_ptr->resize_ctl).flash_threshold = 0.25f; + + (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; + (cache_ptr->resize_ctl).upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; + (cache_ptr->resize_ctl).decrement = H5C__DEF_AR_DECREMENT; + (cache_ptr->resize_ctl).apply_max_decrement = TRUE; + (cache_ptr->resize_ctl).max_decrement = H5C__DEF_AR_MAX_DECREMENT; (cache_ptr->resize_ctl).epochs_before_eviction = H5C__DEF_AR_EPCHS_B4_EVICT; - (cache_ptr->resize_ctl).apply_empty_reserve = TRUE; - (cache_ptr->resize_ctl).empty_reserve = H5C__DEF_AR_EMPTY_RESERVE; + (cache_ptr->resize_ctl).apply_empty_reserve = TRUE; + (cache_ptr->resize_ctl).empty_reserve = H5C__DEF_AR_EMPTY_RESERVE; - cache_ptr->epoch_markers_active = 0; + cache_ptr->epoch_markers_active = 0; /* no need to initialize the ring buffer itself */ - cache_ptr->epoch_marker_ringbuf_first = 1; - cache_ptr->epoch_marker_ringbuf_last = 0; - cache_ptr->epoch_marker_ringbuf_size = 0; + cache_ptr->epoch_marker_ringbuf_first = 1; + cache_ptr->epoch_marker_ringbuf_last = 0; + cache_ptr->epoch_marker_ringbuf_size = 0; /* Initialize all epoch marker entries' fields to zero/FALSE/NULL */ HDmemset(cache_ptr->epoch_markers, 0, sizeof(cache_ptr->epoch_markers)); /* Set non-zero/FALSE/NULL fields for epoch markers */ - for ( i = 0; i < H5C__MAX_EPOCH_MARKERS; i++ ) - { - ((cache_ptr->epoch_markers)[i]).magic = - H5C__H5C_CACHE_ENTRY_T_MAGIC; - ((cache_ptr->epoch_markers)[i]).addr = (haddr_t)i; - ((cache_ptr->epoch_markers)[i]).type = H5AC_EPOCH_MARKER; + for (i = 0; i < H5C__MAX_EPOCH_MARKERS; i++) { + ((cache_ptr->epoch_markers)[i]).magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + ((cache_ptr->epoch_markers)[i]).addr = (haddr_t)i; + ((cache_ptr->epoch_markers)[i]).type = H5AC_EPOCH_MARKER; } /* Initialize cache image generation on file close related fields. @@ -456,68 +428,67 @@ H5C_create(size_t max_cache_size, cache_ptr->image_ctl.entry_ageout = -1; cache_ptr->image_ctl.flags = H5C_CI__ALL_FLAGS; - cache_ptr->serialization_in_progress= FALSE; - cache_ptr->load_image = FALSE; - cache_ptr->image_loaded = FALSE; - cache_ptr->delete_image = FALSE; - cache_ptr->image_addr = HADDR_UNDEF; - cache_ptr->image_len = 0; - cache_ptr->image_data_len = 0; - - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; - cache_ptr->entry_fd_height_change_counter = 0; - - cache_ptr->num_entries_in_image = 0; - cache_ptr->image_entries = NULL; - cache_ptr->image_buffer = NULL; + cache_ptr->serialization_in_progress = FALSE; + cache_ptr->load_image = FALSE; + cache_ptr->image_loaded = FALSE; + cache_ptr->delete_image = FALSE; + cache_ptr->image_addr = HADDR_UNDEF; + cache_ptr->image_len = 0; + cache_ptr->image_data_len = 0; + + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + cache_ptr->entry_fd_height_change_counter = 0; + + cache_ptr->num_entries_in_image = 0; + cache_ptr->image_entries = NULL; + cache_ptr->image_buffer = NULL; /* initialize free space manager related fields: */ - cache_ptr->rdfsm_settled = FALSE; - cache_ptr->mdfsm_settled = FALSE; + cache_ptr->rdfsm_settled = FALSE; + cache_ptr->mdfsm_settled = FALSE; /* fields supporting page buffer hints */ - cache_ptr->curr_io_type = NULL; - cache_ptr->curr_read_speculative = FALSE; + cache_ptr->curr_io_type = NULL; + cache_ptr->curr_read_speculative = FALSE; - if(H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) /* this should be impossible... */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "H5C_reset_cache_hit_rate_stats failed") H5C_stats__reset(cache_ptr); - cache_ptr->prefix[0] = '\0'; /* empty string */ + cache_ptr->prefix[0] = '\0'; /* empty string */ #ifndef NDEBUG - cache_ptr->get_entry_ptr_from_addr_counter = 0; - cache_ptr->curr_io_type = NULL; + cache_ptr->get_entry_ptr_from_addr_counter = 0; + cache_ptr->curr_io_type = NULL; #endif /* NDEBUG */ /* Set return value */ ret_value = cache_ptr; done: - if(NULL == ret_value) { - if(cache_ptr != NULL) { - if(cache_ptr->slist_ptr != NULL) + if (NULL == ret_value) { + if (cache_ptr != NULL) { + if (cache_ptr->slist_ptr != NULL) H5SL_close(cache_ptr->slist_ptr); - if(cache_ptr->tag_list != NULL) + if (cache_ptr->tag_list != NULL) H5SL_close(cache_ptr->tag_list); - if(cache_ptr->log_info != NULL) + if (cache_ptr->log_info != NULL) H5MM_xfree(cache_ptr->log_info); cache_ptr->magic = 0; - cache_ptr = H5FL_FREE(H5C_t, cache_ptr); + cache_ptr = H5FL_FREE(H5C_t, cache_ptr); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_create() */ - /*------------------------------------------------------------------------- * Function: H5C_def_auto_resize_rpt_fcn * @@ -534,168 +505,121 @@ done: *------------------------------------------------------------------------- */ void -H5C_def_auto_resize_rpt_fcn(H5C_t * cache_ptr, +H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, #ifndef NDEBUG int32_t version, -#else /* NDEBUG */ +#else /* NDEBUG */ int32_t H5_ATTR_UNUSED version, #endif /* NDEBUG */ - double hit_rate, - enum H5C_resize_status status, - size_t old_max_cache_size, - size_t new_max_cache_size, - size_t old_min_clean_size, - size_t new_min_clean_size) + double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, + size_t new_max_cache_size, size_t old_min_clean_size, size_t new_min_clean_size) { - HDassert( cache_ptr != NULL ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( version == H5C__CURR_AUTO_RESIZE_RPT_FCN_VER ); + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(version == H5C__CURR_AUTO_RESIZE_RPT_FCN_VER); - switch ( status ) - { + switch (status) { case in_spec: - HDfprintf(stdout, - "%sAuto cache resize -- no change. (hit rate = %lf)\n", - cache_ptr->prefix, hit_rate); + HDfprintf(stdout, "%sAuto cache resize -- no change. (hit rate = %lf)\n", cache_ptr->prefix, + hit_rate); break; case increase: - HDassert( hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold ); - HDassert( old_max_cache_size < new_max_cache_size ); - - HDfprintf(stdout, - "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).lower_hr_threshold); - - HDfprintf(stdout, - "%s cache size increased from (%Zu/%Zu) to (%Zu/%Zu).\n", - cache_ptr->prefix, - old_max_cache_size, - old_min_clean_size, - new_max_cache_size, - new_min_clean_size); + HDassert(hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold); + HDassert(old_max_cache_size < new_max_cache_size); + + HDfprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).lower_hr_threshold); + + HDfprintf(stdout, "%s cache size increased from (%Zu/%Zu) to (%Zu/%Zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); break; case flash_increase: - HDassert( old_max_cache_size < new_max_cache_size ); - - HDfprintf(stdout, - "%sflash cache resize(%d) -- size threshold = %Zu.\n", - cache_ptr->prefix, - (int)((cache_ptr->resize_ctl).flash_incr_mode), - cache_ptr->flash_size_increase_threshold); - - HDfprintf(stdout, - "%s cache size increased from (%Zu/%Zu) to (%Zu/%Zu).\n", - cache_ptr->prefix, - old_max_cache_size, - old_min_clean_size, - new_max_cache_size, - new_min_clean_size); - break; + HDassert(old_max_cache_size < new_max_cache_size); + + HDfprintf(stdout, "%sflash cache resize(%d) -- size threshold = %Zu.\n", cache_ptr->prefix, + (int)((cache_ptr->resize_ctl).flash_incr_mode), + cache_ptr->flash_size_increase_threshold); + + HDfprintf(stdout, "%s cache size increased from (%Zu/%Zu) to (%Zu/%Zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); + break; case decrease: - HDassert( old_max_cache_size > new_max_cache_size ); + HDassert(old_max_cache_size > new_max_cache_size); - switch ( (cache_ptr->resize_ctl).decr_mode ) - { + switch ((cache_ptr->resize_ctl).decr_mode) { case H5C_decr__off: - HDfprintf(stdout, - "%sAuto cache resize -- decrease off. HR = %lf\n", - cache_ptr->prefix, hit_rate); + HDfprintf(stdout, "%sAuto cache resize -- decrease off. HR = %lf\n", cache_ptr->prefix, + hit_rate); break; case H5C_decr__threshold: - HDassert( hit_rate > - (cache_ptr->resize_ctl).upper_hr_threshold ); + HDassert(hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold); - HDfprintf(stdout, - "%sAuto cache resize -- decrease by threshold. HR = %lf > %6.5lf\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).upper_hr_threshold); + HDfprintf(stdout, "%sAuto cache resize -- decrease by threshold. HR = %lf > %6.5lf\n", + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).upper_hr_threshold); - HDfprintf(stdout, "%sout of bounds high (%6.5lf).\n", - cache_ptr->prefix, + HDfprintf(stdout, "%sout of bounds high (%6.5lf).\n", cache_ptr->prefix, (cache_ptr->resize_ctl).upper_hr_threshold); break; case H5C_decr__age_out: - HDfprintf(stdout, - "%sAuto cache resize -- decrease by ageout. HR = %lf\n", + HDfprintf(stdout, "%sAuto cache resize -- decrease by ageout. HR = %lf\n", cache_ptr->prefix, hit_rate); break; case H5C_decr__age_out_with_threshold: - HDassert( hit_rate > - (cache_ptr->resize_ctl).upper_hr_threshold ); + HDassert(hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold); HDfprintf(stdout, "%sAuto cache resize -- decrease by ageout with threshold. HR = %lf > %6.5lf\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).upper_hr_threshold); + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).upper_hr_threshold); break; default: - HDfprintf(stdout, - "%sAuto cache resize -- decrease by unknown mode. HR = %lf\n", + HDfprintf(stdout, "%sAuto cache resize -- decrease by unknown mode. HR = %lf\n", cache_ptr->prefix, hit_rate); } - HDfprintf(stdout, - "%s cache size decreased from (%Zu/%Zu) to (%Zu/%Zu).\n", - cache_ptr->prefix, - old_max_cache_size, - old_min_clean_size, - new_max_cache_size, + HDfprintf(stdout, "%s cache size decreased from (%Zu/%Zu) to (%Zu/%Zu).\n", + cache_ptr->prefix, old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); break; case at_max_size: - HDfprintf(stdout, - "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).lower_hr_threshold); - HDfprintf(stdout, - "%s cache already at maximum size so no change.\n", - cache_ptr->prefix); + HDfprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).lower_hr_threshold); + HDfprintf(stdout, "%s cache already at maximum size so no change.\n", cache_ptr->prefix); break; case at_min_size: - HDfprintf(stdout, - "%sAuto cache resize -- hit rate (%lf) -- can't decrease.\n", - cache_ptr->prefix, hit_rate); - HDfprintf(stdout, "%s cache already at minimum size.\n", - cache_ptr->prefix); + HDfprintf(stdout, "%sAuto cache resize -- hit rate (%lf) -- can't decrease.\n", cache_ptr->prefix, + hit_rate); + HDfprintf(stdout, "%s cache already at minimum size.\n", cache_ptr->prefix); break; case increase_disabled: - HDfprintf(stdout, - "%sAuto cache resize -- increase disabled -- HR = %lf.", - cache_ptr->prefix, hit_rate); + HDfprintf(stdout, "%sAuto cache resize -- increase disabled -- HR = %lf.", cache_ptr->prefix, + hit_rate); break; case decrease_disabled: - HDfprintf(stdout, - "%sAuto cache resize -- decrease disabled -- HR = %lf.\n", - cache_ptr->prefix, hit_rate); + HDfprintf(stdout, "%sAuto cache resize -- decrease disabled -- HR = %lf.\n", cache_ptr->prefix, + hit_rate); break; case not_full: - HDassert( hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold ); - - HDfprintf(stdout, - "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).lower_hr_threshold); - HDfprintf(stdout, - "%s cache not full so no increase in size.\n", - cache_ptr->prefix); + HDassert(hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold); + + HDfprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).lower_hr_threshold); + HDfprintf(stdout, "%s cache not full so no increase in size.\n", cache_ptr->prefix); break; default: - HDfprintf(stdout, "%sAuto cache resize -- unknown status code.\n", - cache_ptr->prefix); + HDfprintf(stdout, "%sAuto cache resize -- unknown status code.\n", cache_ptr->prefix); break; } @@ -703,7 +627,6 @@ H5C_def_auto_resize_rpt_fcn(H5C_t * cache_ptr, } /* H5C_def_auto_resize_rpt_fcn() */ - /*------------------------------------------------------------------------- * Function: H5C_free_tag_list_cb * @@ -729,9 +652,8 @@ H5C_free_tag_list_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); FUNC_LEAVE_NOAPI(0) -} /* H5C_free_tag_list_cb() */ +} /* H5C_free_tag_list_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C_prep_for_file_close @@ -750,10 +672,10 @@ H5C_free_tag_list_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED herr_t H5C_prep_for_file_close(H5F_t *f) { - H5C_t * cache_ptr; - hbool_t image_generated = FALSE; /* Whether a cache image was */ - /* generated */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + hbool_t image_generated = FALSE; /* Whether a cache image was */ + /* generated */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -769,7 +691,7 @@ H5C_prep_for_file_close(H5F_t *f) * close warning more than once -- the following * if statement handles this. */ - if(cache_ptr->close_warning_received) + if (cache_ptr->close_warning_received) HGOTO_DONE(SUCCEED) cache_ptr->close_warning_received = TRUE; @@ -777,14 +699,12 @@ H5C_prep_for_file_close(H5F_t *f) HDassert(cache_ptr->pl_len == 0); /* Prepare cache image */ - if(H5C__prep_image_for_file_close(f, &image_generated) < 0) + if (H5C__prep_image_for_file_close(f, &image_generated) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cache image") #ifdef H5_HAVE_PARALLEL - if ( ( H5F_INTENT(f) & H5F_ACC_RDWR ) && - ( ! image_generated ) && - ( cache_ptr->aux_ptr != NULL ) && - ( f->shared->fs_persist ) ) { + if ((H5F_INTENT(f) & H5F_ACC_RDWR) && (!image_generated) && (cache_ptr->aux_ptr != NULL) && + (f->shared->fs_persist)) { /* If persistent free space managers are enabled, flushing the * metadata cache may result in the deletion, insertion, and/or * dirtying of entries. @@ -818,16 +738,15 @@ H5C_prep_for_file_close(H5F_t *f) * during a flush, and thus avoid any resulting entrie dirties, * deletions, insertion, or moves during the flush. */ - if(H5C__serialize_cache(f) < 0) + if (H5C__serialize_cache(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "serialization of the cache failed") - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_prep_for_file_close() */ - /*------------------------------------------------------------------------- * Function: H5C_dest * @@ -846,10 +765,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_dest(H5F_t * f) +H5C_dest(H5F_t *f) { - H5C_t * cache_ptr = f->shared->cache; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr = f->shared->cache; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -859,37 +778,37 @@ H5C_dest(H5F_t * f) HDassert(cache_ptr->close_warning_received); #if H5AC_DUMP_IMAGE_STATS_ON_CLOSE - if(H5C_image_stats(cache_ptr, TRUE) < 0) + if (H5C_image_stats(cache_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't display cache image stats") #endif /* H5AC_DUMP_IMAGE_STATS_ON_CLOSE */ /* Flush and invalidate all cache entries */ - if(H5C__flush_invalidate_cache(f, H5C__NO_FLAGS_SET) < 0 ) + if (H5C__flush_invalidate_cache(f, H5C__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") /* Generate & write cache image if requested */ - if(cache_ptr->image_ctl.generate_image) - if(H5C__generate_cache_image(f, cache_ptr) < 0) + if (cache_ptr->image_ctl.generate_image) + if (H5C__generate_cache_image(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "Can't generate metadata cache image") - if(cache_ptr->slist_ptr != NULL) { + if (cache_ptr->slist_ptr != NULL) { H5SL_close(cache_ptr->slist_ptr); cache_ptr->slist_ptr = NULL; } /* end if */ - if(cache_ptr->tag_list != NULL) { + if (cache_ptr->tag_list != NULL) { H5SL_destroy(cache_ptr->tag_list, H5C_free_tag_list_cb, NULL); cache_ptr->tag_list = NULL; } /* end if */ - if(cache_ptr->log_info != NULL) + if (cache_ptr->log_info != NULL) H5MM_xfree(cache_ptr->log_info); #ifndef NDEBUG #if H5C_DO_SANITY_CHECKS - if(cache_ptr->get_entry_ptr_from_addr_counter > 0) + if (cache_ptr->get_entry_ptr_from_addr_counter > 0) HDfprintf(stdout, "*** %ld calls to H5C_get_entry_ptr_from_add(). ***\n", - cache_ptr->get_entry_ptr_from_addr_counter); + cache_ptr->get_entry_ptr_from_addr_counter); #endif /* H5C_DO_SANITY_CHECKS */ cache_ptr->magic = 0; @@ -901,7 +820,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_dest() */ - /*------------------------------------------------------------------------- * Function: H5C_evict * @@ -915,9 +833,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_evict(H5F_t * f) +H5C_evict(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -925,84 +843,81 @@ H5C_evict(H5F_t * f) HDassert(f); /* Flush and invalidate all cache entries except the pinned entries */ - if(H5C__flush_invalidate_cache(f, H5C__EVICT_ALLOW_LAST_PINS_FLAG) < 0 ) + if (H5C__flush_invalidate_cache(f, H5C__EVICT_ALLOW_LAST_PINS_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict entries in the cache") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_evict() */ - /*------------------------------------------------------------------------- * Function: H5C_evict_or_refresh_all_entries_in_page * - * Purpose: When a file is opened in VFD SWMR reader mode, we must be - * able to ensure that the metadata cache contains no stale + * Purpose: When a file is opened in VFD SWMR reader mode, we must be + * able to ensure that the metadata cache contains no stale * entries at the end of each tick. * - * To do this, we must identify pages that have changed in + * To do this, we must identify pages that have changed in * the last tick, and either evict, or refresh all modified - * entries in the modified pages. If an evicted entry is - * needed subsequently, it must be reloaded, almost always + * entries in the modified pages. If an evicted entry is + * needed subsequently, it must be reloaded, almost always * from the metadata file. * * This function performs this function of a given page buffer * page. * * This is done by mapping the supplied page to associated - * hash bucket in the page_index, and then scanning the - * contents of the bucket for entries residing in the + * hash bucket in the page_index, and then scanning the + * contents of the bucket for entries residing in the * target page. * * For each such entry, we test to see if it is pinned. - * If it is not, we simply evict it. + * If it is not, we simply evict it. * - * Pinned entries may in turn be divided into tagged and + * Pinned entries may in turn be divided into tagged and * un-tagged entries. * - * For pinned tagged entries, it would be best if we could - * simply tell the associated cache client to refresh it. - * However, until we have that facility, we look up its tag, + * For pinned tagged entries, it would be best if we could + * simply tell the associated cache client to refresh it. + * However, until we have that facility, we look up its tag, * and evict all entries associated with that on disk object. * - * For pinned, un-tagged entries (i.e. super block, global - * heaps, etc. we must instruct the client to refresh the + * For pinned, un-tagged entries (i.e. super block, global + * heaps, etc. we must instruct the client to refresh the * entry. Fortunately, this is only necessary for the * super block in the initial VFD SWMR implementation. * - * Note that there is also the possibility that while the - * page was modified, one or more metadata entries in + * Note that there is also the possibility that while the + * page was modified, one or more metadata entries in * that page were not. Eventually we should write code * to detect this -- but not for the prototype. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer -- 12/16/18 - * + * * Changes: Added macro calls to maintain the page buffer hints. - * + * * JRM -- 3/20/20 * *------------------------------------------------------------------------- */ herr_t -H5C_evict_or_refresh_all_entries_in_page(H5F_t * f, uint64_t page, - uint32_t length, uint64_t tick) +H5C_evict_or_refresh_all_entries_in_page(H5F_t *f, uint64_t page, uint32_t length, uint64_t tick) { - int i; - size_t image_len; - size_t original_image_len; - void * image_ptr = NULL; - void * new_image_ptr = NULL; - unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG); - haddr_t tag; - H5C_t * cache_ptr = NULL; - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * follow_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - hbool_t found = FALSE; + int i; + size_t image_len; + size_t original_image_len; + void * image_ptr = NULL; + void * new_image_ptr = NULL; + unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); + haddr_t tag; + H5C_t * cache_ptr = NULL; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *follow_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + hbool_t found = FALSE; FUNC_ENTER_NOAPI(FAIL) @@ -1016,7 +931,7 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t * f, uint64_t page, HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert(cache_ptr->vfd_swmr_reader); -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "H5C_evict_or_refresh_all_entries_in_page() entering. page = %lld\n", page); @@ -1035,18 +950,16 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t * f, uint64_t page, HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if ( entry_ptr->page == page ) { + if (entry_ptr->page == page) { HDassert(entry_ptr->addr >= (haddr_t)(page * cache_ptr->page_size)); - HDassert(entry_ptr->addr < - (haddr_t)((page+1) * cache_ptr->page_size)); + HDassert(entry_ptr->addr < (haddr_t)((page + 1) * cache_ptr->page_size)); HDassert(length == cache_ptr->page_size || - page * cache_ptr->page_size + length <= - entry_ptr->addr + entry_ptr->size); + page * cache_ptr->page_size + length <= entry_ptr->addr + entry_ptr->size); found = TRUE; - /* since end of tick occurs only on API call entry in + /* since end of tick occurs only on API call entry in * the VFD SWMR reader case, the entry must not be protected. * * since the VFD SWMR reader must have opened the file R/O, @@ -1055,146 +968,135 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t * f, uint64_t page, HDassert(!(entry_ptr->is_protected)); HDassert(!(entry_ptr->is_dirty)); - /* we must evict the entry, as page has been modified, and + /* we must evict the entry, as page has been modified, and * thus the entry may be out of date. * * Note that we should eventually modify this code to be more * intelligent, and only evict entries if they have in fact changed. * However, no time for that in the first cut. */ - if ( entry_ptr->is_pinned ) { + if (entry_ptr->is_pinned) { - /* if the entry has tag_info and there is no refresh + /* if the entry has tag_info and there is no refresh * callback, a call to H5C_evict_tagged_entries() is the * only option available. */ - if ( ( entry_ptr->tag_info ) && - ( entry_ptr->type->refresh == NULL ) ) { + if ((entry_ptr->tag_info) && (entry_ptr->type->refresh == NULL)) { tag = entry_ptr->tag_info->tag; HDassert(!(entry_ptr->tag_info->corked)); -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "evicting tagged entries addr/page/tag == %lld/%lld/%lld\n", entry_ptr->addr, entry_ptr->page, tag); #endif /* JRM */ - /* passing TRUE for the match_global parameter. Look - * into this and verify that it is the right thing to + /* passing TRUE for the match_global parameter. Look + * into this and verify that it is the right thing to * do. */ - if ( H5C_evict_tagged_entries(f, tag, TRUE) < 0 ) + if (H5C_evict_tagged_entries(f, tag, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, \ - "can't evict pinned and tagged entries") + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't evict pinned and tagged entries") /* Both follow_ptr and entry_ptr may have been removed. * Set both to NULL to force the scan to restart. */ follow_ptr = entry_ptr = NULL; - } else if ( entry_ptr->type->refresh ) { -#if 0 /* JRM */ + } + else if (entry_ptr->type->refresh) { +#if 0 /* JRM */ HDfprintf(stderr, "refreshing addr/page/tag == %lld/%lld\n", entry_ptr->addr, entry_ptr->page); #endif /* JRM */ /* If there is a refresh callback, use it to minimize - * overhead. + * overhead. * - * At present, the only refresh call is for the + * At present, the only refresh call is for the * superblock. This is essential, as the superblock * is manually pinned for as long as the file is open, * and thus cannot be evicted. * - * there may be other examples of this, but for the + * there may be other examples of this, but for the * prototype, we seem to be able to avoid them. */ - /* 1) Get the on disk size of the entry. Since the - * the entry is already loaded, we can use the + /* 1) Get the on disk size of the entry. Since the + * the entry is already loaded, we can use the * size listed in the entry. * - * This will almost always be correct, but we - * allow a second try as it is possible that the + * This will almost always be correct, but we + * allow a second try as it is possible that the * version of the entry may change on the writer. */ - image_len = entry_ptr->size; + image_len = entry_ptr->size; original_image_len = image_len; - /* 2) Allocate and read the buffer. + /* 2) Allocate and read the buffer. * - * Note that this will be satisfied from the metadata + * Note that this will be satisfied from the metadata * file via the VFD SWMR reade VFD. * * For this reason, we don't nead to check for reads * past the EOA. Torn reads and checksums are also - * not an issue, since pages in the metadata file + * not an issue, since pages in the metadata file * are checksumed and re-tried if necessary in the * VFD SWMR reader VFD. */ - if ( NULL == (image_ptr = (uint8_t *) - H5MM_malloc(image_len + H5C_IMAGE_EXTRA_SPACE)) ) + if (NULL == (image_ptr = (uint8_t *)H5MM_malloc(image_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, \ - "memory allocation failed for image buffer") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - HDmemcpy(image_ptr + image_len, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE); + HDmemcpy(image_ptr + image_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - + H5C__SET_PB_READ_HINTS(cache_ptr, entry_ptr->type, TRUE) - if ( H5F_block_read(f, entry_ptr->type->mem_type, - entry_ptr->addr, - image_len, image_ptr) < 0 ) { + if (H5F_block_read(f, entry_ptr->type->mem_type, entry_ptr->addr, image_len, image_ptr) < + 0) { H5C__RESET_PB_READ_HINTS(cache_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, \ - "Can't read image (1)") + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read image (1)") } H5C__RESET_PB_READ_HINTS(cache_ptr) - /* 3) Call the refresh callback. If it doesn't + /* 3) Call the refresh callback. If it doesn't * request a different image size, goto 6) */ - if ( entry_ptr->type->refresh(f, (void *)entry_ptr, - image_ptr, &image_len) < 0 ) + if (entry_ptr->type->refresh(f, (void *)entry_ptr, image_ptr, &image_len) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, \ - "Can't refresh entry (1)") + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't refresh entry (1)") - if ( image_len != original_image_len ) { + if (image_len != original_image_len) { /* 4) If image_len has changed, re-allocate and re-read - * the image. + * the image. * - * Note: Generate a log entry in this case + * Note: Generate a log entry in this case */ - if ( NULL == (new_image_ptr = H5MM_realloc(image_ptr, - image_len + H5C_IMAGE_EXTRA_SPACE)) ) + if (NULL == + (new_image_ptr = H5MM_realloc(image_ptr, image_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, \ - "re-alloc of image buffer failed.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "re-alloc of image buffer failed.") image_ptr = new_image_ptr; #if H5C_DO_MEMORY_SANITY_CHECKS - HDmemcpy(image_ptr + image_len, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE); + HDmemcpy(image_ptr + image_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - + H5C__SET_PB_READ_HINTS(cache_ptr, entry_ptr->type, TRUE) - if ( H5F_block_read(f, entry_ptr->type->mem_type, - entry_ptr->addr, - image_len, image_ptr) < 0 ) { + if (H5F_block_read(f, entry_ptr->type->mem_type, entry_ptr->addr, image_len, + image_ptr) < 0) { H5C__RESET_PB_READ_HINTS(cache_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, \ - "Can't read image (2)") + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read image (2)") } H5C__RESET_PB_READ_HINTS(cache_ptr) @@ -1202,56 +1104,53 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t * f, uint64_t page, * a different buffer size again is an error. */ original_image_len = image_len; - if ( entry_ptr->type->refresh(f, (void *)entry_ptr, - image_ptr, - &image_len) < 0 ) + if (entry_ptr->type->refresh(f, (void *)entry_ptr, image_ptr, &image_len) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, \ - "Can't refresh entry (2)") + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't refresh entry (2)") - if ( image_len != original_image_len ) + if (image_len != original_image_len) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "2nd refresh call changed image_len.") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "2nd refresh call changed image_len.") } - /* 6) Mark the entry as having been looked at this + /* 6) Mark the entry as having been looked at this * this tick to accooadate later sanity chackes. */ entry_ptr->refreshed_in_tick = tick; - /* 7) Free the old image if it exists, and replace + /* 7) Free the old image if it exists, and replace * it with the new image. */ - if ( entry_ptr->image_ptr ) { + if (entry_ptr->image_ptr) { entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); } entry_ptr->image_ptr = image_ptr; - /* 8) Since *entry_ptr has been refreshed and not - * evicted, we can leave entry_ptr defined, and - * and continue the scan of the bucket from + /* 8) Since *entry_ptr has been refreshed and not + * evicted, we can leave entry_ptr defined, and + * and continue the scan of the bucket from * that point. */ - - } else { + } + else { /* The entry is pinned, is not tagged, and has no * refresh callback. * - * This should be un-reachable. If it is reached, we + * This should be un-reachable. If it is reached, we * probably have another refresh callback to write. */ HDassert(FALSE); } - } else { /* simply evict the entry */ + } + else { /* simply evict the entry */ - /* since the entry is clean, it must not be on the - * skip list -- thus no need for the + /* since the entry is clean, it must not be on the + * skip list -- thus no need for the * H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG. */ -#if 0 /* JRM */ +#if 0 /* JRM */ if ( entry_ptr->tag_info ) { HDfprintf(stderr, @@ -1264,63 +1163,63 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t * f, uint64_t page, entry_ptr->addr, entry_ptr->page); } #endif /* JRM */ - if ( H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0 ) + if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, \ - "can't evict unpinned entry") + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't evict unpinned entry") /* *entry_ptr should be evicted -- set entry_ptr to NULL */ entry_ptr = NULL; } - /* If entry_ptr is NULL, it was evicted, and we must continue - * the scan from follow_ptr, or start at the head of the + /* If entry_ptr is NULL, it was evicted, and we must continue + * the scan from follow_ptr, or start at the head of the * bucket list it follow_ptr is NULL as well. - * + * * If follow_ptr isn't NULL, set entry_ptr to follow_ptr->pi_next. * Otherwise, set entry_ptr to point to the first item in the hash * bucket. */ - if ( entry_ptr ) { + if (entry_ptr) { - /* *entry_ptr was refreshed, not evicted. Continue the + /* *entry_ptr was refreshed, not evicted. Continue the * the scan from that point, and update follow_ptr. */ follow_ptr = entry_ptr; - entry_ptr = entry_ptr->pi_next; - - } else if ( follow_ptr ) { + entry_ptr = entry_ptr->pi_next; + } + else if (follow_ptr) { /* *entry_ptr was evicted. Since follow_ptr is not NULL, * we can continue the scan from that point. */ entry_ptr = follow_ptr->pi_next; + } + else { - } else { - - /* follow_ptr is null as well, so we have to re-start + /* follow_ptr is null as well, so we have to re-start * the scan from the head of the page index bucket list. */ entry_ptr = (cache_ptr->page_index)[i]; } - } else { + } + else { /* entry belongs to another page -- skip it and go on. */ follow_ptr = entry_ptr; - entry_ptr = entry_ptr->pi_next; + entry_ptr = entry_ptr->pi_next; } } /* end while */ - /* at this point, all entries residing in the target page should have - * been either evicted or refreshed -- verify this. + /* at this point, all entries residing in the target page should have + * been either evicted or refreshed -- verify this. */ entry_ptr = (cache_ptr->page_index)[i]; while (entry_ptr) { - HDassert((entry_ptr->page != page) || - (entry_ptr->refreshed_in_tick == tick));; + HDassert((entry_ptr->page != page) || (entry_ptr->refreshed_in_tick == tick)); + ; entry_ptr = entry_ptr->pi_next; } @@ -1330,7 +1229,6 @@ done: } /* H5C_evict_or_refresh_all_entries_in_page() */ - /*------------------------------------------------------------------------- * Function: H5C_expunge_entry * @@ -1348,11 +1246,10 @@ done: herr_t H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flags) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = NULL; - unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG); - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = NULL; + unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1365,13 +1262,13 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag HDassert(H5F_addr_defined(addr)); #if H5C_DO_EXTREME_SANITY_CHECKS - if(H5C_validate_lru_list(cache_ptr) < 0) + if (H5C_validate_lru_list(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /* Look for entry in cache */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if((entry_ptr == NULL) || (entry_ptr->type != type)) + if ((entry_ptr == NULL) || (entry_ptr->type != type)) /* the target doesn't exist in the cache, so we are done. */ HGOTO_DONE(SUCCEED) @@ -1379,9 +1276,9 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag HDassert(entry_ptr->type == type); /* Check for entry being pinned or protected */ - if(entry_ptr->is_protected) + if (entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is protected") - if(entry_ptr->is_pinned) + if (entry_ptr->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is pinned") /* If we get this far, call H5C__flush_single_entry() with the @@ -1395,19 +1292,18 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag /* Delete the entry from the skip list on destroy */ flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - if(H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) + if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't flush entry") done: #if H5C_DO_EXTREME_SANITY_CHECKS - if(H5C_validate_lru_list(cache_ptr) < 0) + if (H5C_validate_lru_list(cache_ptr) < 0) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_expunge_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_flush_cache * @@ -1459,18 +1355,18 @@ herr_t H5C_flush_cache(H5F_t *f, unsigned flags) { #if H5C_DO_SANITY_CHECKS - int i; - uint32_t index_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - uint32_t slist_len = 0; + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_ring_t ring; - H5C_t * cache_ptr; - hbool_t destroy; - herr_t ret_value = SUCCEED; + H5C_ring_t ring; + H5C_t * cache_ptr; + hbool_t destroy; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1489,13 +1385,13 @@ H5C_flush_cache(H5F_t *f, unsigned flags) HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - for(i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { index_len += cache_ptr->index_ring_len[i]; index_size += cache_ptr->index_ring_size[i]; clean_index_size += cache_ptr->clean_index_ring_size[i]; dirty_index_size += cache_ptr->dirty_index_ring_size[i]; - slist_len += cache_ptr->slist_ring_len[i]; + slist_len += cache_ptr->slist_ring_len[i]; slist_size += cache_ptr->slist_ring_size[i]; } /* end for */ @@ -1508,66 +1404,65 @@ H5C_flush_cache(H5F_t *f, unsigned flags) #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - destroy = ( (flags & H5C__FLUSH_INVALIDATE_FLAG) != 0 ); - HDassert( ! ( destroy && ( (flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0 )) ); - HDassert( ! ( cache_ptr->flush_in_progress ) ); + destroy = ((flags & H5C__FLUSH_INVALIDATE_FLAG) != 0); + HDassert(!(destroy && ((flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0))); + HDassert(!(cache_ptr->flush_in_progress)); cache_ptr->flush_in_progress = TRUE; - if(destroy) { - if(H5C__flush_invalidate_cache(f, flags) < 0) + if (destroy) { + if (H5C__flush_invalidate_cache(f, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush invalidate failed") } /* end if */ else { - /* flush each ring, starting from the outermost ring and + /* flush each ring, starting from the outermost ring and * working inward. */ ring = H5C_RING_USER; - while(ring < H5C_RING_NTYPES) { + while (ring < H5C_RING_NTYPES) { /* Only call the free space manager settle routines when close * warning has been received. */ - if(cache_ptr->close_warning_received) { - switch(ring) { - case H5C_RING_USER: - break; + if (cache_ptr->close_warning_received) { + switch (ring) { + case H5C_RING_USER: + break; - case H5C_RING_RDFSM: + case H5C_RING_RDFSM: /* Settle raw data FSM */ - if(!cache_ptr->rdfsm_settled) - if(H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) + if (!cache_ptr->rdfsm_settled) + if (H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "RD FSM settle failed") - break; + break; - case H5C_RING_MDFSM: + case H5C_RING_MDFSM: /* Settle metadata FSM */ - if(!cache_ptr->mdfsm_settled) - if(H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) + if (!cache_ptr->mdfsm_settled) + if (H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "MD FSM settle failed") - break; + break; - case H5C_RING_SBE: - case H5C_RING_SB: - break; + case H5C_RING_SBE: + case H5C_RING_SB: + break; - default: + default: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown ring?!?!") - break; - } /* end switch */ - } /* end if */ + break; + } /* end switch */ + } /* end if */ - if(H5C__flush_ring(f, ring, flags) < 0) + if (H5C__flush_ring(f, ring, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush ring failed") ring++; } /* end while */ - } /* end else */ + } /* end else */ done: cache_ptr->flush_in_progress = FALSE; @@ -1575,7 +1470,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_cache() */ - /*------------------------------------------------------------------------- * Function: H5C_flush_to_min_clean * @@ -1601,40 +1495,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_flush_to_min_clean(H5F_t * f) +H5C_flush_to_min_clean(H5F_t *f) { - H5C_t * cache_ptr; - hbool_t write_permitted; - herr_t ret_value = SUCCEED; + H5C_t * cache_ptr; + hbool_t write_permitted; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(cache_ptr->check_write_permitted != NULL) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get write_permitted") } /* end if */ else write_permitted = cache_ptr->write_permitted; - if(!write_permitted) + if (!write_permitted) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "cache write is not permitted!?!") - if(H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0) + if (H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C__make_space_in_cache failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_to_min_clean() */ - /*------------------------------------------------------------------------- * Function: H5C_insert_entry * @@ -1652,60 +1545,54 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_insert_entry(H5F_t * f, - const H5C_class_t * type, - haddr_t addr, - void * thing, - unsigned int flags) +H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags) { - H5C_t *cache_ptr; - H5AC_ring_t ring = H5C_RING_UNDEFINED; - hbool_t insert_pinned; - hbool_t flush_last; + H5C_t * cache_ptr; + H5AC_ring_t ring = H5C_RING_UNDEFINED; + hbool_t insert_pinned; + hbool_t flush_last; #ifdef H5_HAVE_PARALLEL - hbool_t coll_access = FALSE; /* whether access to the cache */ - /* entry is done collectively */ -#endif /* H5_HAVE_PARALLEL */ - hbool_t set_flush_marker; - hbool_t write_permitted = TRUE; - size_t empty_space; - H5C_cache_entry_t *entry_ptr = NULL; - H5C_cache_entry_t *test_entry_ptr; - hbool_t entry_tagged = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t coll_access = FALSE; /* whether access to the cache */ + /* entry is done collectively */ +#endif /* H5_HAVE_PARALLEL */ + hbool_t set_flush_marker; + hbool_t write_permitted = TRUE; + size_t empty_space; + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *test_entry_ptr; + hbool_t entry_tagged = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* if this is a VFD SWMR reader, verify that the page size is defined */ - HDassert( ( ! cache_ptr->vfd_swmr_reader ) || - ( cache_ptr->page_size > 0 ) ); + HDassert((!cache_ptr->vfd_swmr_reader) || (cache_ptr->page_size > 0)); - HDassert( type ); - HDassert( type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type ); - HDassert( type->image_len ); - HDassert( H5F_addr_defined(addr) ); - HDassert( thing ); + HDassert(type); + HDassert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); + HDassert(type->image_len); + HDassert(H5F_addr_defined(addr)); + HDassert(thing); #if H5C_DO_EXTREME_SANITY_CHECKS /* no need to verify that entry is not already in the index as */ /* we already make that check below. */ - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - set_flush_marker = ( (flags & H5C__SET_FLUSH_MARKER_FLAG) != 0 ); - insert_pinned = ( (flags & H5C__PIN_ENTRY_FLAG) != 0 ); - flush_last = ( (flags & H5C__FLUSH_LAST_FLAG) != 0 ); + set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); + insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); /* Get the ring type from the API context */ ring = H5CX_get_ring(); @@ -1718,60 +1605,60 @@ H5C_insert_entry(H5F_t * f, H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - if(test_entry_ptr != NULL) { - if(test_entry_ptr == entry_ptr) + if (test_entry_ptr != NULL) { + if (test_entry_ptr == entry_ptr) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "entry already in cache") else HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "duplicate entry in cache") } /* end if */ - entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; entry_ptr->cache_ptr = cache_ptr; - entry_ptr->addr = addr; - entry_ptr->type = type; + entry_ptr->addr = addr; + entry_ptr->type = type; - entry_ptr->image_ptr = NULL; + entry_ptr->image_ptr = NULL; entry_ptr->image_up_to_date = FALSE; entry_ptr->is_protected = FALSE; entry_ptr->is_read_only = FALSE; entry_ptr->ro_ref_count = 0; - entry_ptr->is_pinned = insert_pinned; + entry_ptr->is_pinned = insert_pinned; entry_ptr->pinned_from_client = insert_pinned; - entry_ptr->pinned_from_cache = FALSE; - entry_ptr->flush_me_last = flush_last; + entry_ptr->pinned_from_cache = FALSE; + entry_ptr->flush_me_last = flush_last; /* newly inserted entries are assumed to be dirty */ entry_ptr->is_dirty = TRUE; /* not protected, so can't be dirtied */ - entry_ptr->dirtied = FALSE; + entry_ptr->dirtied = FALSE; /* Retrieve the size of the thing */ - if((type->image_len)(thing, &(entry_ptr->size)) < 0) + if ((type->image_len)(thing, &(entry_ptr->size)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGETSIZE, FAIL, "can't get size of thing") - HDassert(entry_ptr->size > 0 && entry_ptr->size < H5C_MAX_ENTRY_SIZE); + HDassert(entry_ptr->size > 0 && entry_ptr->size < H5C_MAX_ENTRY_SIZE); entry_ptr->in_slist = FALSE; #ifdef H5_HAVE_PARALLEL entry_ptr->clear_on_unprotect = FALSE; - entry_ptr->flush_immediately = FALSE; + entry_ptr->flush_immediately = FALSE; #endif /* H5_HAVE_PARALLEL */ - entry_ptr->flush_in_progress = FALSE; + entry_ptr->flush_in_progress = FALSE; entry_ptr->destroy_in_progress = FALSE; entry_ptr->ring = ring; /* Initialize flush dependency fields */ - entry_ptr->flush_dep_parent = NULL; - entry_ptr->flush_dep_nparents = 0; - entry_ptr->flush_dep_parent_nalloc = 0; - entry_ptr->flush_dep_nchildren = 0; - entry_ptr->flush_dep_ndirty_children = 0; - entry_ptr->flush_dep_nunser_children = 0; + entry_ptr->flush_dep_parent = NULL; + entry_ptr->flush_dep_nparents = 0; + entry_ptr->flush_dep_parent_nalloc = 0; + entry_ptr->flush_dep_nchildren = 0; + entry_ptr->flush_dep_ndirty_children = 0; + entry_ptr->flush_dep_nunser_children = 0; entry_ptr->ht_next = NULL; entry_ptr->ht_prev = NULL; @@ -1792,90 +1679,81 @@ H5C_insert_entry(H5F_t * f, #endif /* H5_HAVE_PARALLEL */ /* initialize cache image related fields */ - entry_ptr->include_in_image = FALSE; - entry_ptr->lru_rank = 0; - entry_ptr->image_dirty = FALSE; - entry_ptr->fd_parent_count = 0; - entry_ptr->fd_parent_addrs = NULL; - entry_ptr->fd_child_count = 0; - entry_ptr->fd_dirty_child_count = 0; - entry_ptr->image_fd_height = 0; - entry_ptr->prefetched = FALSE; - entry_ptr->prefetch_type_id = 0; - entry_ptr->age = 0; - entry_ptr->prefetched_dirty = FALSE; -#ifndef NDEBUG /* debugging field */ - entry_ptr->serialization_count = 0; + entry_ptr->include_in_image = FALSE; + entry_ptr->lru_rank = 0; + entry_ptr->image_dirty = FALSE; + entry_ptr->fd_parent_count = 0; + entry_ptr->fd_parent_addrs = NULL; + entry_ptr->fd_child_count = 0; + entry_ptr->fd_dirty_child_count = 0; + entry_ptr->image_fd_height = 0; + entry_ptr->prefetched = FALSE; + entry_ptr->prefetch_type_id = 0; + entry_ptr->age = 0; + entry_ptr->prefetched_dirty = FALSE; +#ifndef NDEBUG /* debugging field */ + entry_ptr->serialization_count = 0; #endif /* NDEBUG */ /* initialize tag list fields */ - entry_ptr->tl_next = NULL; - entry_ptr->tl_prev = NULL; - entry_ptr->tag_info = NULL; + entry_ptr->tl_next = NULL; + entry_ptr->tl_prev = NULL; + entry_ptr->tag_info = NULL; /* initialize fields supporting VFD SWMR */ - if ( cache_ptr->vfd_swmr_reader ) { + if (cache_ptr->vfd_swmr_reader) { - entry_ptr->page = (addr / cache_ptr->page_size); - - } else { + entry_ptr->page = (addr / cache_ptr->page_size); + } + else { - entry_ptr->page = 0; + entry_ptr->page = 0; } - entry_ptr->refreshed_in_tick = 0; - entry_ptr->pi_next = NULL; - entry_ptr->pi_prev = NULL; + entry_ptr->refreshed_in_tick = 0; + entry_ptr->pi_next = NULL; + entry_ptr->pi_prev = NULL; /* Apply tag to newly inserted entry */ - if(H5C__tag_entry(cache_ptr, entry_ptr) < 0) + if (H5C__tag_entry(cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") entry_tagged = TRUE; H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) - if ( cache_ptr->flash_size_increase_possible && - ( entry_ptr->size > cache_ptr->flash_size_increase_threshold ) ) { + if (cache_ptr->flash_size_increase_possible && + (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) { - if ( H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0 ) + if (H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ - "H5C__flash_increase_cache_size failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C__flash_increase_cache_size failed") } - if(cache_ptr->index_size >= cache_ptr->max_cache_size) { + if (cache_ptr->index_size >= cache_ptr->max_cache_size) { empty_space = 0; - - } else { + } + else { empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; } - if ( ( cache_ptr->evictions_enabled ) && - ( ( (cache_ptr->index_size + entry_ptr->size) > - cache_ptr->max_cache_size - ) - || - ( (empty_space + cache_ptr->clean_index_size) < - cache_ptr->min_clean_size - ) - ) - ) { + if ((cache_ptr->evictions_enabled) && + (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size))) { size_t space_needed; - if ( empty_space <= entry_ptr->size ) { + if (empty_space <= entry_ptr->size) { cache_ptr->cache_full = TRUE; } - if ( cache_ptr->check_write_permitted != NULL ) { + if (cache_ptr->check_write_permitted != NULL) { - if ( ( cache_ptr->check_write_permitted)(f, &write_permitted) < 0 ) + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ - "Can't get write_permitted") - - } else { + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "Can't get write_permitted") + } + else { write_permitted = cache_ptr->write_permitted; } @@ -1883,7 +1761,7 @@ H5C_insert_entry(H5F_t * f, HDassert(entry_ptr->size <= H5C_MAX_ENTRY_SIZE); space_needed = entry_ptr->size; - if ( space_needed > cache_ptr->max_cache_size ) { + if (space_needed > cache_ptr->max_cache_size) { space_needed = cache_ptr->max_cache_size; } @@ -1913,10 +1791,9 @@ H5C_insert_entry(H5F_t * f, * no point in worrying about the third. */ - if ( H5C__make_space_in_cache(f, space_needed, write_permitted) < 0 ) + if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ - "H5C__make_space_in_cache failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C__make_space_in_cache failed") } /* end if */ H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL) @@ -1928,34 +1805,30 @@ H5C_insert_entry(H5F_t * f, H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, FAIL) #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "an extreme sanity check failed just before done") + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed just before done") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /* If the entry's type has a 'notify' callback send a 'after insertion' * notice now that the entry is fully integrated into the cache. */ - if ( ( entry_ptr->type->notify ) && - ( (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_INSERT, - entry_ptr) < 0 ) ) + if ((entry_ptr->type->notify) && + ((entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_INSERT, entry_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "can't notify client about entry inserted into cache") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry inserted into cache") H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { coll_access = (H5P_USER_TRUE == f->coll_md_read ? TRUE : FALSE); - /* If not explicitly disabled, get the cmdr setting from the - * API context + /* If not explicitly disabled, get the cmdr setting from the + * API context */ - if(!coll_access && H5P_FORCE_FALSE != f->coll_md_read) { + if (!coll_access && H5P_FORCE_FALSE != f->coll_md_read) { coll_access = H5CX_get_coll_metadata_read(); } @@ -1963,55 +1836,47 @@ H5C_insert_entry(H5F_t * f, entry_ptr->coll_access = coll_access; - if(coll_access) { + if (coll_access) { H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, FAIL) - /* Make sure the size of the collective entries in the cache - * remain in check + /* Make sure the size of the collective entries in the cache + * remain in check */ - if(H5P_USER_TRUE == f->coll_md_read) { + if (H5P_USER_TRUE == f->coll_md_read) { - if ( cache_ptr->max_cache_size * 80 < - cache_ptr->coll_list_size * 100) { + if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) { - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "can't clear collective metadata entries") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") } /* end if */ - } /* end if */ + } /* end if */ else { - if ( cache_ptr->max_cache_size * 40 < - cache_ptr->coll_list_size * 100) { + if (cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) { - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "can't clear collective metadata entries") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ #endif done: #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "an extreme sanity check failed on exit") + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - if(ret_value < 0 && entry_tagged) - if(H5C__untag_entry(cache_ptr, entry_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, \ - "can't remove entry from tag list") + if (ret_value < 0 && entry_tagged) + if (H5C__untag_entry(cache_ptr, entry_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") FUNC_LEAVE_NOAPI(ret_value) } /* H5C_insert_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_mark_entry_dirty * @@ -2042,9 +1907,9 @@ done: herr_t H5C_mark_entry_dirty(void *thing) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2055,62 +1920,64 @@ H5C_mark_entry_dirty(void *thing) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if ( entry_ptr->is_protected ) { - HDassert( ! ((entry_ptr)->is_read_only) ); + if (entry_ptr->is_protected) { + HDassert(!((entry_ptr)->is_read_only)); /* set the dirtied flag */ entry_ptr->dirtied = TRUE; /* reset image_up_to_date */ - if(entry_ptr->image_up_to_date) { + if (entry_ptr->image_up_to_date) { entry_ptr->image_up_to_date = FALSE; - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") - }/* end if */ - } /* end if */ - else if ( entry_ptr->is_pinned ) { - hbool_t was_clean; /* Whether the entry was previously clean */ - hbool_t image_was_up_to_date; + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + } /* end if */ + else if (entry_ptr->is_pinned) { + hbool_t was_clean; /* Whether the entry was previously clean */ + hbool_t image_was_up_to_date; /* Remember previous dirty status */ - was_clean = !entry_ptr->is_dirty; + was_clean = !entry_ptr->is_dirty; /* Check if image is up to date */ image_was_up_to_date = entry_ptr->image_up_to_date; /* Mark the entry as dirty if it isn't already */ - entry_ptr->is_dirty = TRUE; - entry_ptr->image_up_to_date = FALSE; + entry_ptr->is_dirty = TRUE; + entry_ptr->image_up_to_date = FALSE; /* Modify cache data structures */ - if(was_clean) + if (was_clean) H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) - if(!entry_ptr->in_slist) + if (!entry_ptr->in_slist) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) /* Update stats for entry being marked dirty */ H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) /* Check for entry changing status and do notifications, etc. */ - if(was_clean) { + if (was_clean) { /* If the entry's type has a 'notify' callback send a 'entry dirtied' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") /* Propagate the dirty flag up the flush dependency chain if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_dirty(entry_ptr) < 0) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") } /* end if */ - if(image_was_up_to_date) - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") + if (image_was_up_to_date) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Entry is neither pinned nor protected??") @@ -2119,7 +1986,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entry_dirty() */ - /*------------------------------------------------------------------------- * Function: H5C_mark_entry_clean * @@ -2139,9 +2005,9 @@ done: herr_t H5C_mark_entry_clean(void *_thing) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2153,10 +2019,10 @@ H5C_mark_entry_clean(void *_thing) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Operate on pinned entry */ - if(entry_ptr->is_protected) + if (entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "entry is protected") - else if(entry_ptr->is_pinned) { - hbool_t was_dirty; /* Whether the entry was previously dirty */ + else if (entry_ptr->is_pinned) { + hbool_t was_dirty; /* Whether the entry was previously dirty */ /* Remember previous dirty status */ was_dirty = entry_ptr->is_dirty; @@ -2168,29 +2034,30 @@ H5C_mark_entry_clean(void *_thing) entry_ptr->flush_marker = FALSE; /* Modify cache data structures */ - if(was_dirty) + if (was_dirty) H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr) - if(entry_ptr->in_slist) + if (entry_ptr->in_slist) H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE) /* Update stats for entry being marked clean */ H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) /* Check for entry changing status and do notifications, etc. */ - if(was_dirty) { + if (was_dirty) { /* If the entry's type has a 'notify' callback send a 'entry cleaned' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag cleared") + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") /* Propagate the clean up the flush dependency chain, if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_clean(entry_ptr) < 0) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Can't propagate flush dep clean") } /* end if */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Entry is not pinned??") @@ -2198,7 +2065,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entry_clean() */ - /*------------------------------------------------------------------------- * Function: H5C_mark_entry_unserialized * @@ -2215,8 +2081,8 @@ done: herr_t H5C_mark_entry_unserialized(void *thing) { - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2224,26 +2090,27 @@ H5C_mark_entry_unserialized(void *thing) HDassert(entry); HDassert(H5F_addr_defined(entry->addr)); - if(entry->is_protected || entry->is_pinned) { + if (entry->is_protected || entry->is_pinned) { HDassert(!entry->is_read_only); /* Reset image_up_to_date */ - if(entry->image_up_to_date) { - entry->image_up_to_date = FALSE; + if (entry->image_up_to_date) { + entry->image_up_to_date = FALSE; - if(entry->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "Can't propagate serialization status to fd parents") - }/* end if */ - } /* end if */ + if (entry->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + } /* end if */ else - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, "Entry to unserialize is neither pinned nor protected??") + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, + "Entry to unserialize is neither pinned nor protected??") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entry_unserialized() */ - /*------------------------------------------------------------------------- * Function: H5C_mark_entry_serialized * @@ -2260,8 +2127,8 @@ done: herr_t H5C_mark_entry_serialized(void *_thing) { - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2270,20 +2137,21 @@ H5C_mark_entry_serialized(void *_thing) HDassert(H5F_addr_defined(entry->addr)); /* Operate on pinned entry */ - if(entry->is_protected) + if (entry->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "entry is protected") - else if(entry->is_pinned) { + else if (entry->is_pinned) { /* Check for entry changing status and do notifications, etc. */ - if(!entry->image_up_to_date) { - /* Set the image_up_to_date flag */ + if (!entry->image_up_to_date) { + /* Set the image_up_to_date flag */ entry->image_up_to_date = TRUE; /* Propagate the serialize up the flush dependency chain, if appropriate */ - if(entry->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_serialized(entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "Can't propagate flush dep serialize") + if (entry->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_serialized(entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, + "Can't propagate flush dep serialize") } /* end if */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "Entry is not pinned??") @@ -2291,7 +2159,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entry_serialized() */ - /*------------------------------------------------------------------------- * * Function: H5C_move_entry @@ -2305,20 +2172,17 @@ done: * 6/2/04 * * Changes: Added code to update cache entry page field required - * by VFD SWMR. + * by VFD SWMR. * JRM -- 12/13/18 * *------------------------------------------------------------------------- */ herr_t -H5C_move_entry(H5C_t * cache_ptr, - const H5C_class_t * type, - haddr_t old_addr, - haddr_t new_addr) +H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, haddr_t new_addr) { - H5C_cache_entry_t * entry_ptr = NULL; - H5C_cache_entry_t * test_entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *test_entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2326,8 +2190,7 @@ H5C_move_entry(H5C_t * cache_ptr, HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* if this is a VFD SWMR reader, verify that the page size is defined */ - HDassert(( ! cache_ptr->vfd_swmr_reader ) || - ( cache_ptr->page_size > 0 ) ); + HDassert((!cache_ptr->vfd_swmr_reader) || (cache_ptr->page_size > 0)); HDassert(type); HDassert(H5F_addr_defined(old_addr)); @@ -2335,17 +2198,15 @@ H5C_move_entry(H5C_t * cache_ptr, HDassert(H5F_addr_ne(old_addr, new_addr)); #if H5C_DO_EXTREME_SANITY_CHECKS - if ( ( H5C_validate_protected_entry_list(cache_ptr) < 0 ) || - ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || - ( H5C_validate_lru_list(cache_ptr) < 0 ) ) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "an extreme sanity check failed on entry") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ H5C__SEARCH_INDEX(cache_ptr, old_addr, entry_ptr, FAIL) - if ( ( entry_ptr == NULL ) || ( entry_ptr->type != type ) ) { + if ((entry_ptr == NULL) || (entry_ptr->type != type)) { /* the old item doesn't exist in the cache, so we are done. */ HGOTO_DONE(SUCCEED) @@ -2358,21 +2219,19 @@ H5C_move_entry(H5C_t * cache_ptr, /* (Moving a R/O entry would mark it dirty, which shouldn't * happen. QAK - 2016/12/02) */ - if ( entry_ptr->is_read_only ) + if (entry_ptr->is_read_only) HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "can't move R/O entry") H5C__SEARCH_INDEX(cache_ptr, new_addr, test_entry_ptr, FAIL) - if ( test_entry_ptr != NULL ) { /* we are hosed */ + if (test_entry_ptr != NULL) { /* we are hosed */ - if ( test_entry_ptr->type == type ) + if (test_entry_ptr->type == type) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, \ - "target already moved & reinserted???") + HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "target already moved & reinserted???") else - HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, \ - "new address already in use?") + HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "new address already in use?") } /* end if */ /* If we get this far we have work to do. Remove *entry_ptr from @@ -2390,49 +2249,48 @@ H5C_move_entry(H5C_t * cache_ptr, * change the addr. If the entry is only in the process of being flushed, * don't mark it as dirty either, lest we confuse the flush call back. */ - if ( ! entry_ptr->destroy_in_progress ) { + if (!entry_ptr->destroy_in_progress) { H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL) - if ( entry_ptr->in_slist ) { + if (entry_ptr->in_slist) { HDassert(cache_ptr->slist_ptr); H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE) } /* end if */ - } /* end if */ + } /* end if */ entry_ptr->addr = new_addr; - /* update the page in which the entry resides if the file is opened + /* update the page in which the entry resides if the file is opened * as a VFD SWMR reader. */ - if ( cache_ptr->vfd_swmr_reader ) { + if (cache_ptr->vfd_swmr_reader) { entry_ptr->page = (new_addr / cache_ptr->page_size); - } - if ( ! entry_ptr->destroy_in_progress ) { + if (!entry_ptr->destroy_in_progress) { - hbool_t was_dirty; /* Whether the entry was previously dirty */ + hbool_t was_dirty; /* Whether the entry was previously dirty */ /* Remember previous dirty status */ was_dirty = entry_ptr->is_dirty; /* Mark the entry as dirty if it isn't already */ - entry_ptr->is_dirty = TRUE; + entry_ptr->is_dirty = TRUE; - /* This shouldn't be needed, but it keeps the test code happy */ - if ( entry_ptr->image_up_to_date ) { + /* This shouldn't be needed, but it keeps the test code happy */ + if (entry_ptr->image_up_to_date) { entry_ptr->image_up_to_date = FALSE; - if ( entry_ptr->flush_dep_nparents > 0 ) { + if (entry_ptr->flush_dep_nparents > 0) { - if ( H5C__mark_flush_dep_unserialized(entry_ptr) < 0 ) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "Can't propagate serialization status to fd parents") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") } } /* end if */ @@ -2441,57 +2299,53 @@ H5C_move_entry(H5C_t * cache_ptr, H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) /* Skip some actions if we're in the middle of flushing the entry */ - if ( !entry_ptr->flush_in_progress ) { + if (!entry_ptr->flush_in_progress) { /* Update the replacement policy for the entry */ H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, FAIL) /* Check for entry changing status and do notifications, etc. */ - if(!was_dirty) { + if (!was_dirty) { - /* If the entry's type has a 'notify' callback send a 'entry - * dirtied' notice now that the entry is fully integrated + /* If the entry's type has a 'notify' callback send a 'entry + * dirtied' notice now that the entry is fully integrated * into the cache. */ - if ( ( entry_ptr->type->notify ) && - ( (entry_ptr->type->notify) - (H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0 ) ) + if ((entry_ptr->type->notify) && + ((entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "can't notify client about entry dirty flag set") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag set") - /* Propagate the dirty flag up the flush dependency chain - * if appropriate + /* Propagate the dirty flag up the flush dependency chain + * if appropriate */ - if ( entry_ptr->flush_dep_nparents > 0 ) { + if (entry_ptr->flush_dep_nparents > 0) { - if ( H5C__mark_flush_dep_dirty(entry_ptr) < 0 ) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, \ + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") } } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) done: #if H5C_DO_EXTREME_SANITY_CHECKS - if ( ( H5C_validate_protected_entry_list(cache_ptr) < 0 ) || - ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || - ( H5C_validate_lru_list(cache_ptr) < 0 ) ) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "an extreme sanity check failed on exit") + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_move_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_resize_entry * @@ -2511,9 +2365,9 @@ done: herr_t H5C_resize_entry(void *thing, size_t new_size) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2525,20 +2379,19 @@ H5C_resize_entry(void *thing, size_t new_size) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Check for usage errors */ - if(new_size <= 0) + if (new_size <= 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "New size is non-positive") - if(!(entry_ptr->is_pinned || entry_ptr->is_protected)) + if (!(entry_ptr->is_pinned || entry_ptr->is_protected)) HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, FAIL, "Entry isn't pinned or protected??") #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || (H5C_validate_pinned_entry_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /* update for change in entry size if necessary */ - if ( entry_ptr->size != new_size ) { - hbool_t was_clean; + if (entry_ptr->size != new_size) { + hbool_t was_clean; /* make note of whether the entry was clean to begin with */ was_clean = !entry_ptr->is_dirty; @@ -2547,99 +2400,94 @@ H5C_resize_entry(void *thing, size_t new_size) entry_ptr->is_dirty = TRUE; /* Reset the image up-to-date status */ - if(entry_ptr->image_up_to_date) { + if (entry_ptr->image_up_to_date) { entry_ptr->image_up_to_date = FALSE; - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") } /* end if */ /* Release the current image */ - if(entry_ptr->image_ptr) + if (entry_ptr->image_ptr) entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); /* do a flash cache size increase if appropriate */ - if ( cache_ptr->flash_size_increase_possible ) { + if (cache_ptr->flash_size_increase_possible) { - if ( new_size > entry_ptr->size ) { - size_t size_increase; + if (new_size > entry_ptr->size) { + size_t size_increase; size_increase = new_size - entry_ptr->size; - if(size_increase >= cache_ptr->flash_size_increase_threshold) { - if(H5C__flash_increase_cache_size(cache_ptr, entry_ptr->size, new_size) < 0) + if (size_increase >= cache_ptr->flash_size_increase_threshold) { + if (H5C__flash_increase_cache_size(cache_ptr, entry_ptr->size, new_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "flash cache increase failed") } } } /* update the pinned and/or protected entry list */ - if(entry_ptr->is_pinned) { - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pel_len), \ - (cache_ptr->pel_size), \ - (entry_ptr->size), (new_size)) + if (entry_ptr->is_pinned) { + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pel_len), (cache_ptr->pel_size), (entry_ptr->size), + (new_size)) } /* end if */ - if(entry_ptr->is_protected) { - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pl_len), \ - (cache_ptr->pl_size), \ - (entry_ptr->size), (new_size)) + if (entry_ptr->is_protected) { + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pl_len), (cache_ptr->pl_size), (entry_ptr->size), + (new_size)) } /* end if */ #ifdef H5_HAVE_PARALLEL - if(entry_ptr->coll_access) { - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->coll_list_len), \ - (cache_ptr->coll_list_size), \ + if (entry_ptr->coll_access) { + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->coll_list_len), (cache_ptr->coll_list_size), (entry_ptr->size), (new_size)) } /* end if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ /* update statistics just before changing the entry size */ - H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size); + H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size); /* update the hash table */ - H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \ - new_size, entry_ptr, was_clean); + H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size, entry_ptr, was_clean); /* if the entry is in the skip list, update that too */ - if(entry_ptr->in_slist) - H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size); + if (entry_ptr->in_slist) + H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size); - /* finally, update the entry size proper */ - entry_ptr->size = new_size; + /* finally, update the entry size proper */ + entry_ptr->size = new_size; - if(!entry_ptr->in_slist) + if (!entry_ptr->in_slist) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - if(entry_ptr->is_pinned) + if (entry_ptr->is_pinned) H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) /* Check for entry changing status and do notifications, etc. */ - if(was_clean) { + if (was_clean) { /* If the entry's type has a 'notify' callback send a 'entry dirtied' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") /* Propagate the dirty flag up the flush dependency chain if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_dirty(entry_ptr) < 0) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") } /* end if */ - } /* end if */ + } /* end if */ done: #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || (H5C_validate_pinned_entry_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_resize_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_pin_protected_entry() * @@ -2659,9 +2507,9 @@ done: herr_t H5C_pin_protected_entry(void *thing) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)thing; /* Pointer to entry to pin */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; /* Pointer to entry to pin */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2673,33 +2521,29 @@ H5C_pin_protected_entry(void *thing) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - /* Only protected entries can be pinned */ - if(!entry_ptr->is_protected) + if (!entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Entry isn't protected") /* Pin the entry from a client */ - if(H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") done: #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_pin_protected_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_protect * @@ -2723,82 +2567,77 @@ done: *------------------------------------------------------------------------- */ void * -H5C_protect(H5F_t * f, - const H5C_class_t * type, - haddr_t addr, - void * udata, - unsigned flags) +H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsigned flags) { - H5C_t * cache_ptr; - H5AC_ring_t ring = H5C_RING_UNDEFINED; - hbool_t hit; - hbool_t have_write_permitted = FALSE; - hbool_t read_only = FALSE; - hbool_t flush_last; + H5C_t * cache_ptr; + H5AC_ring_t ring = H5C_RING_UNDEFINED; + hbool_t hit; + hbool_t have_write_permitted = FALSE; + hbool_t read_only = FALSE; + hbool_t flush_last; #ifdef H5_HAVE_PARALLEL - hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ -#endif /* H5_HAVE_PARALLEL */ - hbool_t write_permitted; - hbool_t was_loaded = FALSE; /* Whether the entry was loaded as a result of the protect */ - size_t empty_space; - void * thing; - H5C_cache_entry_t * entry_ptr; - void * ret_value = NULL; /* Return value */ + hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ +#endif /* H5_HAVE_PARALLEL */ + hbool_t write_permitted; + hbool_t was_loaded = FALSE; /* Whether the entry was loaded as a result of the protect */ + size_t empty_space; + void * thing; + H5C_cache_entry_t *entry_ptr; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* check args */ - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( type ); - HDassert( type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type ); - HDassert( H5F_addr_defined(addr) ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(type); + HDassert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); + HDassert(H5F_addr_defined(addr)); #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /* Load the cache image, if requested */ - if(cache_ptr->load_image) { + if (cache_ptr->load_image) { cache_ptr->load_image = FALSE; - if(H5C__load_cache_image(f) < 0) + if (H5C__load_cache_image(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't load cache image") } /* end if */ - read_only = ( (flags & H5C__READ_ONLY_FLAG) != 0 ); - flush_last = ( (flags & H5C__FLUSH_LAST_FLAG) != 0 ); + read_only = ((flags & H5C__READ_ONLY_FLAG) != 0); + flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); /* Get the ring type from the API context */ ring = H5CX_get_ring(); #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) coll_access = H5CX_get_coll_metadata_read(); #endif /* H5_HAVE_PARALLEL */ /* first check to see if the target is in cache */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, NULL) - if(entry_ptr != NULL) { - if(entry_ptr->ring != ring) + if (entry_ptr != NULL) { + if (entry_ptr->ring != ring) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "ring type mismatch occurred for cache entry") HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(entry_ptr->prefetched) { + if (entry_ptr->prefetched) { /* This call removes the prefetched entry from the cache, * and replaces it with an entry deserialized from the * image of the prefetched entry. */ - if(H5C__deserialize_prefetched_entry(f, cache_ptr, &entry_ptr, type, addr, udata) < 0) + if (H5C__deserialize_prefetched_entry(f, cache_ptr, &entry_ptr, type, addr, udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't deserialize prefetched entry") HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -2807,154 +2646,151 @@ H5C_protect(H5F_t * f, } /* end if */ /* Check for trying to load the wrong type of entry from an address */ - if(entry_ptr->type != type) + if (entry_ptr->type != type) HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type") - /* if this is a collective metadata read, the entry is not - marked as collective, and is clean, it is possible that - other processes will not have it in its cache and will - expect a bcast of the entry from process 0. So process 0 - will bcast the entry to all other ranks. Ranks that _do_ have - the entry in their cache still have to participate in the - bcast. */ + /* if this is a collective metadata read, the entry is not + marked as collective, and is clean, it is possible that + other processes will not have it in its cache and will + expect a bcast of the entry from process 0. So process 0 + will bcast the entry to all other ranks. Ranks that _do_ have + the entry in their cache still have to participate in the + bcast. */ #ifdef H5_HAVE_PARALLEL - if(coll_access) { - if(!(entry_ptr->is_dirty) && !(entry_ptr->coll_access)) { - MPI_Comm comm; /* File MPI Communicator */ - int mpi_code; /* MPI error code */ - int buf_size; + if (coll_access) { + if (!(entry_ptr->is_dirty) && !(entry_ptr->coll_access)) { + MPI_Comm comm; /* File MPI Communicator */ + int mpi_code; /* MPI error code */ + int buf_size; - if(MPI_COMM_NULL == (comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") - if(entry_ptr->image_ptr == NULL) { + if (entry_ptr->image_ptr == NULL) { int mpi_rank; - if((mpi_rank = H5F_mpi_get_rank(f)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") - if(NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, + "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - if(0 == mpi_rank) - if(H5C__generate_image(f, cache_ptr, entry_ptr) < 0) + if (0 == mpi_rank) + if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't generate entry's image") } /* end if */ HDassert(entry_ptr->image_ptr); H5_CHECKED_ASSIGN(buf_size, int, entry_ptr->size, size_t); - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(entry_ptr->image_ptr, buf_size, MPI_BYTE, 0, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(entry_ptr->image_ptr, buf_size, MPI_BYTE, 0, comm))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) /* Mark the entry as collective and insert into the collective list */ entry_ptr->coll_access = TRUE; H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) } /* end if */ - else if(entry_ptr->coll_access) { + else if (entry_ptr->coll_access) { H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) } /* end else-if */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ #if H5C_DO_TAGGING_SANITY_CHECKS -{ - /* Verify tag value */ - if(cache_ptr->ignore_tags != TRUE) { - haddr_t tag; /* Tag value */ - - /* The entry is already in the cache, but make sure that the tag value - * is still legal. This will ensure that had the entry NOT been in the - * cache, tagging was still set up correctly and it would have received - * a legal tag value after getting loaded from disk. - */ + { + /* Verify tag value */ + if (cache_ptr->ignore_tags != TRUE) { + haddr_t tag; /* Tag value */ + + /* The entry is already in the cache, but make sure that the tag value + * is still legal. This will ensure that had the entry NOT been in the + * cache, tagging was still set up correctly and it would have received + * a legal tag value after getting loaded from disk. + */ - /* Get the tag */ - tag = H5CX_get_tag(); + /* Get the tag */ + tag = H5CX_get_tag(); - if(H5C_verify_tag(entry_ptr->type->id, tag) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "tag verification failed") - } /* end if */ -} + if (H5C_verify_tag(entry_ptr->type->id, tag) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "tag verification failed") + } /* end if */ + } #endif - hit = TRUE; + hit = TRUE; thing = (void *)entry_ptr; - - } else { + } + else { /* must try to load the entry from disk. */ hit = FALSE; - if(NULL == (thing = H5C_load_entry(f, + if (NULL == (thing = H5C_load_entry(f, #ifdef H5_HAVE_PARALLEL - coll_access, + coll_access, #endif /* H5_HAVE_PARALLEL */ - type, addr, udata))) + type, addr, udata))) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't load entry") entry_ptr = (H5C_cache_entry_t *)thing; cache_ptr->entries_loaded_counter++; - entry_ptr->ring = ring; + entry_ptr->ring = ring; #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && entry_ptr->coll_access) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && entry_ptr->coll_access) H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) #endif /* H5_HAVE_PARALLEL */ /* Apply tag to newly protected entry */ - if(H5C__tag_entry(cache_ptr, entry_ptr) < 0) + if (H5C__tag_entry(cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Cannot tag metadata entry") /* If the entry is very large, and we are configured to allow it, * we may wish to perform a flash cache size increase. */ - if ( ( cache_ptr->flash_size_increase_possible ) && - ( entry_ptr->size > cache_ptr->flash_size_increase_threshold ) ) { + if ((cache_ptr->flash_size_increase_possible) && + (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) { - if(H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) + if (H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__flash_increase_cache_size failed") } - if(cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; /* try to free up if necceary and if evictions are permitted. Note * that if evictions are enabled, we will call H5C__make_space_in_cache() * regardless if the min_free_space requirement is not met. */ - if ( ( cache_ptr->evictions_enabled ) && - ( ( (cache_ptr->index_size + entry_ptr->size) > - cache_ptr->max_cache_size) - || - ( ( empty_space + cache_ptr->clean_index_size ) < - cache_ptr->min_clean_size ) - ) - ) { + if ((cache_ptr->evictions_enabled) && + (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size))) { size_t space_needed; - if(empty_space <= entry_ptr->size) + if (empty_space <= entry_ptr->size) cache_ptr->cache_full = TRUE; - if(cache_ptr->check_write_permitted != NULL) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Can't get write_permitted 1") else have_write_permitted = TRUE; } /* end if */ else { - write_permitted = cache_ptr->write_permitted; + write_permitted = cache_ptr->write_permitted; have_write_permitted = TRUE; } /* end else */ HDassert(entry_ptr->size <= H5C_MAX_ENTRY_SIZE); space_needed = entry_ptr->size; - if(space_needed > cache_ptr->max_cache_size) + if (space_needed > cache_ptr->max_cache_size) space_needed = cache_ptr->max_cache_size; /* Note that space_needed is just the amount of space that @@ -2986,7 +2822,7 @@ H5C_protect(H5F_t * f, * see no point in worrying about the fourth. */ - if(H5C__make_space_in_cache(f, space_needed, write_permitted) < 0 ) + if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__make_space_in_cache failed") } /* end if */ @@ -2999,7 +2835,7 @@ H5C_protect(H5F_t * f, * ******************************************* * * Set the flush_last field - * of the newly loaded entry before inserting it into the + * of the newly loaded entry before inserting it into the * index. Must do this, as the index tracked the number of * entries with the flush_last field set, but assumes that * the field will not change after insertion into the index. @@ -3011,7 +2847,7 @@ H5C_protect(H5F_t * f, H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, NULL) - if ( ( entry_ptr->is_dirty ) && ( ! (entry_ptr->in_slist) ) ) { + if ((entry_ptr->is_dirty) && (!(entry_ptr->in_slist))) { H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, NULL) } @@ -3031,25 +2867,25 @@ H5C_protect(H5F_t * f, HDassert(entry_ptr->addr == addr); HDassert(entry_ptr->type == type); - if(entry_ptr->is_protected) { - if(read_only && entry_ptr->is_read_only) { - HDassert(entry_ptr->ro_ref_count > 0); - (entry_ptr->ro_ref_count)++; - } /* end if */ + if (entry_ptr->is_protected) { + if (read_only && entry_ptr->is_read_only) { + HDassert(entry_ptr->ro_ref_count > 0); + (entry_ptr->ro_ref_count)++; + } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Target already protected & not read only?!?") } /* end if */ else { - H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, NULL) + H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, NULL) - entry_ptr->is_protected = TRUE; + entry_ptr->is_protected = TRUE; - if ( read_only ) { - entry_ptr->is_read_only = TRUE; - entry_ptr->ro_ref_count = 1; - } /* end if */ + if (read_only) { + entry_ptr->is_read_only = TRUE; + entry_ptr->ro_ref_count = 1; + } /* end if */ - entry_ptr->dirtied = FALSE; + entry_ptr->dirtied = FALSE; } /* end else */ H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) @@ -3058,61 +2894,58 @@ H5C_protect(H5F_t * f, ret_value = thing; - if ( ( cache_ptr->evictions_enabled ) && - ( ( cache_ptr->size_decreased ) || - ( ( cache_ptr->resize_enabled ) && - ( cache_ptr->cache_accesses >= - (cache_ptr->resize_ctl).epoch_length ) ) ) ) { + if ((cache_ptr->evictions_enabled) && + ((cache_ptr->size_decreased) || + ((cache_ptr->resize_enabled) && + (cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length)))) { - if ( ! have_write_permitted ) { + if (!have_write_permitted) { - if ( cache_ptr->check_write_permitted != NULL ) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Can't get write_permitted") else have_write_permitted = TRUE; - } else { + } + else { write_permitted = cache_ptr->write_permitted; have_write_permitted = TRUE; - } } - if(cache_ptr->resize_enabled && - (cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length)) { + if (cache_ptr->resize_enabled && + (cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length)) { - if(H5C__auto_adjust_cache_size(f, write_permitted) < 0) + if (H5C__auto_adjust_cache_size(f, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Cache auto-resize failed") } /* end if */ - if(cache_ptr->size_decreased) { + if (cache_ptr->size_decreased) { cache_ptr->size_decreased = FALSE; /* check to see if the cache is now oversized due to the cache * size reduction. If it is, try to evict enough entries to * bring the cache size down to the current maximum cache size. - * - * Also, if the min_clean_size requirement is not met, we - * should also call H5C__make_space_in_cache() to bring us - * into complience. + * + * Also, if the min_clean_size requirement is not met, we + * should also call H5C__make_space_in_cache() to bring us + * into complience. */ - if(cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - if ( ( cache_ptr->index_size > cache_ptr->max_cache_size ) - || - ( ( empty_space + cache_ptr->clean_index_size ) < - cache_ptr->min_clean_size) ) { + if ((cache_ptr->index_size > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size)) { - if(cache_ptr->index_size > cache_ptr->max_cache_size) + if (cache_ptr->index_size > cache_ptr->max_cache_size) cache_ptr->cache_full = TRUE; - if(H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0 ) + if (H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__make_space_in_cache failed") } } /* end if */ @@ -3123,35 +2956,33 @@ H5C_protect(H5F_t * f, * the cache and protected. We must wait until it is protected so it is not * evicted during the notify callback. */ - if(was_loaded) { + if (was_loaded) { /* If the entry's type has a 'notify' callback send a 'after load' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, NULL, "can't notify client about entry inserted into cache") + if (entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, NULL, + "can't notify client about entry inserted into cache") } /* end if */ #ifdef H5_HAVE_PARALLEL /* Make sure the size of the collective entries in the cache remain in check */ - if(coll_access) - if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + if (coll_access) + if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") #endif /* H5_HAVE_PARALLEL */ done: #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_protect() */ - /*------------------------------------------------------------------------- * * Function: H5C_reset_cache_hit_rate_stats() @@ -3165,23 +2996,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_reset_cache_hit_rate_stats(H5C_t * cache_ptr) +H5C_reset_cache_hit_rate_stats(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - cache_ptr->cache_hits = 0; - cache_ptr->cache_accesses = 0; + cache_ptr->cache_hits = 0; + cache_ptr->cache_accesses = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_reset_cache_hit_rate_stats() */ - /*------------------------------------------------------------------------- * Function: H5C_set_cache_auto_resize_config * @@ -3202,36 +3032,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, - H5C_auto_size_ctl_t *config_ptr) +H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr) { - size_t new_max_cache_size; - size_t new_min_clean_size; - herr_t ret_value = SUCCEED; /* Return value */ + size_t new_max_cache_size; + size_t new_min_clean_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) + if (config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unknown config version") /* check general configuration section of the config: */ - if(H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_GENERAL) < 0) + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_GENERAL) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in general configuration fields of new config") /* check size increase control fields of the config: */ - if(H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INCREMENT) < 0) + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INCREMENT) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in the size increase control fields of new config") /* check size decrease control fields of the config: */ - if(H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_DECREMENT) < 0) + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_DECREMENT) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in the size decrease control fields of new config") /* check for conflicts between size increase and size decrease controls: */ - if(H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) < 0) + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "conflicting threshold fields in new config") /* will set the increase possible fields to FALSE later if needed */ @@ -3239,16 +3068,15 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, cache_ptr->flash_size_increase_possible = TRUE; cache_ptr->size_decrease_possible = TRUE; - switch(config_ptr->incr_mode) { + switch (config_ptr->incr_mode) { case H5C_incr__off: cache_ptr->size_increase_possible = FALSE; break; case H5C_incr__threshold: - if((config_ptr->lower_hr_threshold <= (double)0.0f) || - (config_ptr->increment <= (double)1.0f) || - ((config_ptr->apply_max_increment) && (config_ptr->max_increment <= 0))) - cache_ptr->size_increase_possible = FALSE; + if ((config_ptr->lower_hr_threshold <= (double)0.0f) || (config_ptr->increment <= (double)1.0f) || + ((config_ptr->apply_max_increment) && (config_ptr->max_increment <= 0))) + cache_ptr->size_increase_possible = FALSE; break; default: /* should be unreachable */ @@ -3260,28 +3088,27 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, * we wait until the end of the function, when this field is set. */ - switch(config_ptr->decr_mode) { + switch (config_ptr->decr_mode) { case H5C_decr__off: cache_ptr->size_decrease_possible = FALSE; break; case H5C_decr__threshold: - if((config_ptr->upper_hr_threshold >= (double)1.0f) || - (config_ptr->decrement >= (double)1.0f) || - ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) + if ((config_ptr->upper_hr_threshold >= (double)1.0f) || (config_ptr->decrement >= (double)1.0f) || + ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) cache_ptr->size_decrease_possible = FALSE; break; case H5C_decr__age_out: - if(((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= (double)1.0f)) || - ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) + if (((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= (double)1.0f)) || + ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) cache_ptr->size_decrease_possible = FALSE; break; case H5C_decr__age_out_with_threshold: - if(((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= (double)1.0f)) || - ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0)) || - (config_ptr->upper_hr_threshold >= (double)1.0f)) + if (((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= (double)1.0f)) || + ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0)) || + (config_ptr->upper_hr_threshold >= (double)1.0f)) cache_ptr->size_decrease_possible = FALSE; break; @@ -3289,17 +3116,16 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown decr_mode?!?!?") } /* end switch */ - if(config_ptr->max_size == config_ptr->min_size) { - cache_ptr->size_increase_possible = FALSE; - cache_ptr->flash_size_increase_possible = FALSE; - cache_ptr->size_decrease_possible = FALSE; + if (config_ptr->max_size == config_ptr->min_size) { + cache_ptr->size_increase_possible = FALSE; + cache_ptr->flash_size_increase_possible = FALSE; + cache_ptr->size_decrease_possible = FALSE; } /* end if */ /* flash_size_increase_possible is intentionally omitted from the * following: */ - cache_ptr->resize_enabled = cache_ptr->size_increase_possible || - cache_ptr->size_decrease_possible; + cache_ptr->resize_enabled = cache_ptr->size_increase_possible || cache_ptr->size_decrease_possible; cache_ptr->resize_ctl = *config_ptr; @@ -3311,18 +3137,16 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, * go through the exercise even if the current size is within * range and an initial size has not been provided. */ - if(cache_ptr->resize_ctl.set_initial_size) + if (cache_ptr->resize_ctl.set_initial_size) new_max_cache_size = cache_ptr->resize_ctl.initial_size; - else if(cache_ptr->max_cache_size > cache_ptr->resize_ctl.max_size) + else if (cache_ptr->max_cache_size > cache_ptr->resize_ctl.max_size) new_max_cache_size = cache_ptr->resize_ctl.max_size; - else if(cache_ptr->max_cache_size < cache_ptr->resize_ctl.min_size) + else if (cache_ptr->max_cache_size < cache_ptr->resize_ctl.min_size) new_max_cache_size = cache_ptr->resize_ctl.min_size; else new_max_cache_size = cache_ptr->max_cache_size; - new_min_clean_size = (size_t)((double)new_max_cache_size * - ((cache_ptr->resize_ctl).min_clean_fraction)); - + new_min_clean_size = (size_t)((double)new_max_cache_size * ((cache_ptr->resize_ctl).min_clean_fraction)); /* since new_min_clean_size is of type size_t, we have * @@ -3334,25 +3158,25 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, HDassert(cache_ptr->resize_ctl.min_size <= new_max_cache_size); HDassert(new_max_cache_size <= cache_ptr->resize_ctl.max_size); - if(new_max_cache_size < cache_ptr->max_cache_size) + if (new_max_cache_size < cache_ptr->max_cache_size) cache_ptr->size_decreased = TRUE; cache_ptr->max_cache_size = new_max_cache_size; cache_ptr->min_clean_size = new_min_clean_size; - if(H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) /* this should be impossible... */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") /* remove excess epoch markers if any */ - if((config_ptr->decr_mode == H5C_decr__age_out_with_threshold) || - (config_ptr->decr_mode == H5C_decr__age_out)) { - if(cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) - if(H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) + if ((config_ptr->decr_mode == H5C_decr__age_out_with_threshold) || + (config_ptr->decr_mode == H5C_decr__age_out)) { + if (cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) + if (H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") } /* end if */ - else if(cache_ptr->epoch_markers_active > 0) { - if(H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) + else if (cache_ptr->epoch_markers_active > 0) { + if (H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") } @@ -3364,29 +3188,28 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, * go ahead and configure it. */ - if(cache_ptr->flash_size_increase_possible) { - switch(config_ptr->flash_incr_mode) { + if (cache_ptr->flash_size_increase_possible) { + switch (config_ptr->flash_incr_mode) { case H5C_flash_incr__off: cache_ptr->flash_size_increase_possible = FALSE; break; case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_possible = TRUE; - cache_ptr->flash_size_increase_threshold = (size_t)(((double)(cache_ptr->max_cache_size)) * - ((cache_ptr->resize_ctl).flash_threshold)); + cache_ptr->flash_size_increase_possible = TRUE; + cache_ptr->flash_size_increase_threshold = (size_t)( + ((double)(cache_ptr->max_cache_size)) * ((cache_ptr->resize_ctl).flash_threshold)); break; default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; } /* end switch */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_cache_auto_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5C_set_evictions_enabled() * @@ -3403,11 +3226,11 @@ done: herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry") /* There is no fundamental reason why we should not permit @@ -3416,9 +3239,8 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) * want to, and allowing it would greatly complicate testing * the feature. Hence the following: */ - if((evictions_enabled != TRUE) && - ((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || - (cache_ptr->resize_ctl.decr_mode != H5C_decr__off))) + if ((evictions_enabled != TRUE) && ((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || + (cache_ptr->resize_ctl.decr_mode != H5C_decr__off))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't disable evictions when auto resize enabled") cache_ptr->evictions_enabled = evictions_enabled; @@ -3427,11 +3249,10 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_evictions_enabled() */ - /*------------------------------------------------------------------------- * Function: H5C_set_vfd_swmr_reader() * - * Purpose: Set cache_ptr->vfd_swmr_reader and cache_ptr->page_size to + * Purpose: Set cache_ptr->vfd_swmr_reader and cache_ptr->page_size to * the values specified in the parameter list. * * Return: SUCCEED on success, and FAIL on failure. @@ -3444,19 +3265,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_set_vfd_swmr_reader(H5C_t *cache_ptr, hbool_t vfd_swmr_reader, - hsize_t page_size) +H5C_set_vfd_swmr_reader(H5C_t *cache_ptr, hbool_t vfd_swmr_reader, hsize_t page_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry") cache_ptr->vfd_swmr_reader = vfd_swmr_reader; - cache_ptr->page_size = page_size; + cache_ptr->page_size = page_size; done: @@ -3464,7 +3284,6 @@ done: } /* H5C_set_vfd_swmr_reader() */ - /*------------------------------------------------------------------------- * Function: H5C_unpin_entry() * @@ -3477,16 +3296,16 @@ done: * 3/22/06 * * Changes: Added extreme sanity checks on entry and exit. - JRM -- 4/26/14 + JRM -- 4/26/14 * *------------------------------------------------------------------------- */ herr_t H5C_unpin_entry(void *_entry_ptr) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)_entry_ptr; /* Pointer to entry to unpin */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_entry_ptr; /* Pointer to entry to unpin */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3497,29 +3316,25 @@ H5C_unpin_entry(void *_entry_ptr) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - /* Unpin the entry */ - if(H5C__unpin_entry_from_client(cache_ptr, entry_ptr, TRUE) < 0) + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry from client") done: #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_unpin_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_unprotect * @@ -3546,62 +3361,61 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) +H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) { - H5C_t * cache_ptr; - hbool_t deleted; - hbool_t dirtied; - hbool_t set_flush_marker; - hbool_t pin_entry; - hbool_t unpin_entry; - hbool_t free_file_space; - hbool_t take_ownership; - hbool_t was_clean; + H5C_t * cache_ptr; + hbool_t deleted; + hbool_t dirtied; + hbool_t set_flush_marker; + hbool_t pin_entry; + hbool_t unpin_entry; + hbool_t free_file_space; + hbool_t take_ownership; + hbool_t was_clean; #ifdef H5_HAVE_PARALLEL - hbool_t clear_entry = FALSE; + hbool_t clear_entry = FALSE; #endif /* H5_HAVE_PARALLEL */ - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * test_entry_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *test_entry_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - deleted = ((flags & H5C__DELETED_FLAG) != 0); - dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); - set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); - pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); - unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); - free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); - take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); + deleted = ((flags & H5C__DELETED_FLAG) != 0); + dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); + set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); + pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); + free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); + take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( H5F_addr_defined(addr) ); - HDassert( thing ); - HDassert( ! ( pin_entry && unpin_entry ) ); - HDassert( ( ! free_file_space ) || ( deleted ) ); /* deleted flag must accompany free_file_space */ - HDassert( ( ! take_ownership ) || ( deleted ) ); /* deleted flag must accompany take_ownership */ - HDassert( ! ( free_file_space && take_ownership ) ); /* can't have both free_file_space & take_ownership */ + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(H5F_addr_defined(addr)); + HDassert(thing); + HDassert(!(pin_entry && unpin_entry)); + HDassert((!free_file_space) || (deleted)); /* deleted flag must accompany free_file_space */ + HDassert((!take_ownership) || (deleted)); /* deleted flag must accompany take_ownership */ + HDassert(!(free_file_space && take_ownership)); /* can't have both free_file_space & take_ownership */ entry_ptr = (H5C_cache_entry_t *)thing; - HDassert( entry_ptr->addr == addr ); + HDassert(entry_ptr->addr == addr); /* also set the dirtied variable if the dirtied field is set in * the entry. */ dirtied |= entry_ptr->dirtied; - was_clean = ! ( entry_ptr->is_dirty ); + was_clean = !(entry_ptr->is_dirty); #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -3609,38 +3423,40 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) * the ro_ref_counter. Don't actually unprotect until the ref count * drops to zero. */ - if(entry_ptr->ro_ref_count > 1) { + if (entry_ptr->ro_ref_count > 1) { /* Sanity check */ - HDassert(entry_ptr->is_protected); + HDassert(entry_ptr->is_protected); HDassert(entry_ptr->is_read_only); - if(dirtied) + if (dirtied) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") /* Reduce the RO ref count */ - (entry_ptr->ro_ref_count)--; + (entry_ptr->ro_ref_count)--; /* Pin or unpin the entry as requested. */ - if(pin_entry) { + if (pin_entry) { /* Pin the entry from a client */ - if(H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") - } else if(unpin_entry) { + } + else if (unpin_entry) { /* Unpin the entry from a client */ - if(H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") } /* end if */ - } else { - if(entry_ptr->is_read_only) { + } + else { + if (entry_ptr->is_read_only) { /* Sanity check */ - HDassert(entry_ptr->ro_ref_count == 1); + HDassert(entry_ptr->ro_ref_count == 1); - if(dirtied) + if (dirtied) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") - entry_ptr->is_read_only = FALSE; - entry_ptr->ro_ref_count = 0; - } /* end if */ + entry_ptr->is_read_only = FALSE; + entry_ptr->ro_ref_count = 0; + } /* end if */ #ifdef H5_HAVE_PARALLEL /* When the H5C code is used to implement the metadata cache in the @@ -3658,72 +3474,75 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) * are contiguous, with only one dirty flag, we have to let the supplied * functions deal with the resetting the is_dirty flag. */ - if(entry_ptr->clear_on_unprotect) { + if (entry_ptr->clear_on_unprotect) { /* Sanity check */ HDassert(entry_ptr->is_dirty); entry_ptr->clear_on_unprotect = FALSE; - if(!dirtied) + if (!dirtied) clear_entry = TRUE; } /* end if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ - if(!entry_ptr->is_protected) + if (!entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Entry already unprotected??") /* Mark the entry as dirty if appropriate */ entry_ptr->is_dirty = (entry_ptr->is_dirty || dirtied); - if(dirtied) - if(entry_ptr->image_up_to_date) { - entry_ptr->image_up_to_date = FALSE; - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") + if (dirtied) + if (entry_ptr->image_up_to_date) { + entry_ptr->image_up_to_date = FALSE; + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") } /* end if */ /* Check for newly dirtied entry */ - if(was_clean && entry_ptr->is_dirty) { + if (was_clean && entry_ptr->is_dirty) { /* Update index for newly dirtied entry */ H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) /* If the entry's type has a 'notify' callback send a 'entry dirtied' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") /* Propagate the flush dep dirty flag up the flush dependency chain * if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_dirty(entry_ptr) < 0) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") } /* end if */ /* Check for newly clean entry */ - else if(!was_clean && !entry_ptr->is_dirty) { + else if (!was_clean && !entry_ptr->is_dirty) { /* If the entry's type has a 'notify' callback send a 'entry cleaned' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag cleared") + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") /* Propagate the flush dep clean flag up the flush dependency chain * if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_clean(entry_ptr) < 0) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") } /* end else-if */ /* Pin or unpin the entry as requested. */ - if(pin_entry) { + if (pin_entry) { /* Pin the entry from a client */ - if(H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") - } else if(unpin_entry) { + } + else if (unpin_entry) { /* Unpin the entry from a client */ - if(H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") } /* end if */ @@ -3737,9 +3556,9 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) /* if the entry is dirty, 'or' its flush_marker with the set flush flag, * and then add it to the skip list if it isn't there already. */ - if(entry_ptr->is_dirty) { + if (entry_ptr->is_dirty) { entry_ptr->flush_marker |= set_flush_marker; - if(!entry_ptr->in_slist) + if (!entry_ptr->in_slist) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) } /* end if */ @@ -3752,628 +3571,632 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) * makes good use of existing code. * JRM - 5/19/04 */ - if(deleted) { - unsigned flush_flags = (H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_INVALIDATE_FLAG); + if (deleted) { + unsigned flush_flags = (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_INVALIDATE_FLAG); /* verify that the target entry is in the cache. */ H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - if(test_entry_ptr == NULL) + if (test_entry_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "entry not in hash table?!?") - else if(test_entry_ptr != entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "hash table contains multiple entries for addr?!?") + else if (test_entry_ptr != entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, + "hash table contains multiple entries for addr?!?") /* Set the 'free file space' flag for the flush, if needed */ - if(free_file_space) + if (free_file_space) flush_flags |= H5C__FREE_FILE_SPACE_FLAG; /* Set the "take ownership" flag for the flush, if needed */ - if(take_ownership) + if (take_ownership) flush_flags |= H5C__TAKE_OWNERSHIP_FLAG; /* Delete the entry from the skip list on destroy */ flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; HDassert(((!was_clean) || dirtied) == entry_ptr->in_slist); - if(H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) + if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't flush entry") } /* end if */ #ifdef H5_HAVE_PARALLEL - else if(clear_entry) { + else if (clear_entry) { /* verify that the target entry is in the cache. */ H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - if(test_entry_ptr == NULL) + if (test_entry_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "entry not in hash table?!?") - else if(test_entry_ptr != entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "hash table contains multiple entries for addr?!?") + else if (test_entry_ptr != entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, + "hash table contains multiple entries for addr?!?") - if(H5C__flush_single_entry(f, entry_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't clear entry") } /* end else if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ } H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) done: #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) { + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) { HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_unprotect() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_unprotect() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_unsettle_entry_ring - * - * Purpose: Advise the metadata cache that the specified entry's free space - * manager ring is no longer settled (if it was on entry). - * - * If the target free space manager ring is already - * unsettled, do nothing, and return SUCCEED. - * - * If the target free space manager ring is settled, and - * we are not in the process of a file shutdown, mark - * the ring as unsettled, and return SUCCEED. - * - * If the target free space manager is settled, and we - * are in the process of a file shutdown, post an error - * message, and return FAIL. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * January 3, 2017 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_unsettle_entry_ring(void *_entry) -{ - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry whose ring to unsettle */ - H5C_t *cache; /* Cache for file */ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * + * Function: H5C_unsettle_entry_ring + * + * Purpose: Advise the metadata cache that the specified entry's free space + * manager ring is no longer settled (if it was on entry). + * + * If the target free space manager ring is already + * unsettled, do nothing, and return SUCCEED. + * + * If the target free space manager ring is settled, and + * we are not in the process of a file shutdown, mark + * the ring as unsettled, and return SUCCEED. + * + * If the target free space manager is settled, and we + * are in the process of a file shutdown, post an error + * message, and return FAIL. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * January 3, 2017 + * + *------------------------------------------------------------------------- + */ + herr_t H5C_unsettle_entry_ring(void *_entry) + { + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry whose ring to unsettle */ + H5C_t * cache; /* Cache for file */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(FAIL) - /* Sanity checks */ - HDassert(entry); - HDassert(entry->ring != H5C_RING_UNDEFINED); - HDassert((H5C_RING_USER == entry->ring) || (H5C_RING_RDFSM == entry->ring) || (H5C_RING_MDFSM == entry->ring)); - cache = entry->cache_ptr; - HDassert(cache); - HDassert(cache->magic == H5C__H5C_T_MAGIC); - - switch(entry->ring) { - case H5C_RING_USER: - /* Do nothing */ - break; - - case H5C_RING_RDFSM: - if(cache->rdfsm_settled) { - if(cache->flush_in_progress || cache->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") - cache->rdfsm_settled = FALSE; - } /* end if */ - break; - - case H5C_RING_MDFSM: - if(cache->mdfsm_settled) { - if(cache->flush_in_progress || cache->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") - cache->mdfsm_settled = FALSE; - } /* end if */ - break; - - default: - HDassert(FALSE); /* this should be un-reachable */ - break; - } /* end switch */ + /* Sanity checks */ + HDassert(entry); + HDassert(entry->ring != H5C_RING_UNDEFINED); + HDassert((H5C_RING_USER == entry->ring) || (H5C_RING_RDFSM == entry->ring) || + (H5C_RING_MDFSM == entry->ring)); + cache = entry->cache_ptr; + HDassert(cache); + HDassert(cache->magic == H5C__H5C_T_MAGIC); + + switch (entry->ring) { + case H5C_RING_USER: + /* Do nothing */ + break; + + case H5C_RING_RDFSM: + if (cache->rdfsm_settled) { + if (cache->flush_in_progress || cache->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") + cache->rdfsm_settled = FALSE; + } /* end if */ + break; + + case H5C_RING_MDFSM: + if (cache->mdfsm_settled) { + if (cache->flush_in_progress || cache->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") + cache->mdfsm_settled = FALSE; + } /* end if */ + break; + + default: + HDassert(FALSE); /* this should be un-reachable */ + break; + } /* end switch */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_unsettle_entry_ring() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_unsettle_entry_ring() */ - -/*------------------------------------------------------------------------- - * Function: H5C_unsettle_ring() - * - * Purpose: Advise the metadata cache that the specified free space - * manager ring is no longer settled (if it was on entry). - * - * If the target free space manager ring is already - * unsettled, do nothing, and return SUCCEED. - * - * If the target free space manager ring is settled, and - * we are not in the process of a file shutdown, mark - * the ring as unsettled, and return SUCCEED. - * - * If the target free space manager is settled, and we - * are in the process of a file shutdown, post an error - * message, and return FAIL. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 10/15/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring) -{ - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5C_unsettle_ring() + * + * Purpose: Advise the metadata cache that the specified free space + * manager ring is no longer settled (if it was on entry). + * + * If the target free space manager ring is already + * unsettled, do nothing, and return SUCCEED. + * + * If the target free space manager ring is settled, and + * we are not in the process of a file shutdown, mark + * the ring as unsettled, and return SUCCEED. + * + * If the target free space manager is settled, and we + * are in the process of a file shutdown, post an error + * message, and return FAIL. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 10/15/16 + * + *------------------------------------------------------------------------- + */ + herr_t H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring) + { + H5C_t *cache_ptr; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(FAIL) - /* Sanity checks */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->cache); - HDassert((H5C_RING_RDFSM == ring) || (H5C_RING_MDFSM == ring)); - cache_ptr = f->shared->cache; - HDassert(H5C__H5C_T_MAGIC == cache_ptr->magic); - - switch(ring) { - case H5C_RING_RDFSM: - if(cache_ptr->rdfsm_settled) { - if(cache_ptr->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") - cache_ptr->rdfsm_settled = FALSE; - } /* end if */ - break; + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->cache); + HDassert((H5C_RING_RDFSM == ring) || (H5C_RING_MDFSM == ring)); + cache_ptr = f->shared->cache; + HDassert(H5C__H5C_T_MAGIC == cache_ptr->magic); + + switch (ring) { + case H5C_RING_RDFSM: + if (cache_ptr->rdfsm_settled) { + if (cache_ptr->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") + cache_ptr->rdfsm_settled = FALSE; + } /* end if */ + break; - case H5C_RING_MDFSM: - if(cache_ptr->mdfsm_settled) { - if(cache_ptr->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") - cache_ptr->mdfsm_settled = FALSE; - } /* end if */ - break; + case H5C_RING_MDFSM: + if (cache_ptr->mdfsm_settled) { + if (cache_ptr->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") + cache_ptr->mdfsm_settled = FALSE; + } /* end if */ + break; - default: - HDassert(FALSE); /* this should be un-reachable */ - break; - } /* end switch */ + default: + HDassert(FALSE); /* this should be un-reachable */ + break; + } /* end switch */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_unsettle_ring() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_unsettle_ring() */ - -/*------------------------------------------------------------------------- - * Function: H5C_validate_resize_config() - * - * Purpose: Run a sanity check on the specified sections of the - * provided instance of struct H5C_auto_size_ctl_t. - * - * Do nothing and return SUCCEED if no errors are detected, - * and flag an error and return FAIL otherwise. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 3/23/05 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, - unsigned int tests) -{ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5C_validate_resize_config() + * + * Purpose: Run a sanity check on the specified sections of the + * provided instance of struct H5C_auto_size_ctl_t. + * + * Do nothing and return SUCCEED if no errors are detected, + * and flag an error and return FAIL otherwise. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 3/23/05 + * + *------------------------------------------------------------------------- + */ + herr_t H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, unsigned int tests) + { + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(FAIL) - if(config_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") + if (config_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown config version") + if (config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown config version") - if((tests & H5C_RESIZE_CFG__VALIDATE_GENERAL) != 0) { + if ((tests & H5C_RESIZE_CFG__VALIDATE_GENERAL) != 0) { - if(config_ptr->max_size > H5C__MAX_MAX_CACHE_SIZE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "max_size too big") + if (config_ptr->max_size > H5C__MAX_MAX_CACHE_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "max_size too big") - if(config_ptr->min_size < H5C__MIN_MAX_CACHE_SIZE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size too small") + if (config_ptr->min_size < H5C__MIN_MAX_CACHE_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size too small") - if(config_ptr->min_size > config_ptr->max_size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size > max_size") + if (config_ptr->min_size > config_ptr->max_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size > max_size") - if(config_ptr->set_initial_size && - ((config_ptr->initial_size < config_ptr->min_size) || - (config_ptr->initial_size > config_ptr->max_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "initial_size must be in the interval [min_size, max_size]") + if (config_ptr->set_initial_size && ((config_ptr->initial_size < config_ptr->min_size) || + (config_ptr->initial_size > config_ptr->max_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "initial_size must be in the interval [min_size, max_size]") - if((config_ptr->min_clean_fraction < (double)0.0f) || + if ((config_ptr->min_clean_fraction < (double)0.0f) || (config_ptr->min_clean_fraction > (double)1.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_clean_fraction must be in the interval [0.0, 1.0]") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "min_clean_fraction must be in the interval [0.0, 1.0]") - if(config_ptr->epoch_length < H5C__MIN_AR_EPOCH_LENGTH) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too small") + if (config_ptr->epoch_length < H5C__MIN_AR_EPOCH_LENGTH) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too small") - if(config_ptr->epoch_length > H5C__MAX_AR_EPOCH_LENGTH) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too big") - } /* H5C_RESIZE_CFG__VALIDATE_GENERAL */ + if (config_ptr->epoch_length > H5C__MAX_AR_EPOCH_LENGTH) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too big") + } /* H5C_RESIZE_CFG__VALIDATE_GENERAL */ + if ((tests & H5C_RESIZE_CFG__VALIDATE_INCREMENT) != 0) { + if ((config_ptr->incr_mode != H5C_incr__off) && (config_ptr->incr_mode != H5C_incr__threshold)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid incr_mode") - if((tests & H5C_RESIZE_CFG__VALIDATE_INCREMENT) != 0) { - if((config_ptr->incr_mode != H5C_incr__off) && - (config_ptr->incr_mode != H5C_incr__threshold)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid incr_mode") - - if(config_ptr->incr_mode == H5C_incr__threshold) { - if((config_ptr->lower_hr_threshold < (double)0.0f) || + if (config_ptr->incr_mode == H5C_incr__threshold) { + if ((config_ptr->lower_hr_threshold < (double)0.0f) || (config_ptr->lower_hr_threshold > (double)1.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "lower_hr_threshold must be in the range [0.0, 1.0]") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "lower_hr_threshold must be in the range [0.0, 1.0]") - if(config_ptr->increment < (double)1.0f) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "increment must be greater than or equal to 1.0") + if (config_ptr->increment < (double)1.0f) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "increment must be greater than or equal to 1.0") - /* no need to check max_increment, as it is a size_t, - * and thus must be non-negative. - */ - } /* H5C_incr__threshold */ + /* no need to check max_increment, as it is a size_t, + * and thus must be non-negative. + */ + } /* H5C_incr__threshold */ - switch(config_ptr->flash_incr_mode) { - case H5C_flash_incr__off: - /* nothing to do here */ - break; + switch (config_ptr->flash_incr_mode) { + case H5C_flash_incr__off: + /* nothing to do here */ + break; - case H5C_flash_incr__add_space: - if((config_ptr->flash_multiple < (double)0.1f) || + case H5C_flash_incr__add_space: + if ((config_ptr->flash_multiple < (double)0.1f) || (config_ptr->flash_multiple > (double)10.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "flash_multiple must be in the range [0.1, 10.0]") - if((config_ptr->flash_threshold < (double)0.1f) || + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_multiple must be in the range [0.1, 10.0]") + if ((config_ptr->flash_threshold < (double)0.1f) || (config_ptr->flash_threshold > (double)1.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "flash_threshold must be in the range [0.1, 1.0]") - break; - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid flash_incr_mode") - break; - } /* end switch */ - } /* H5C_RESIZE_CFG__VALIDATE_INCREMENT */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_threshold must be in the range [0.1, 1.0]") + break; + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid flash_incr_mode") + break; + } /* end switch */ + } /* H5C_RESIZE_CFG__VALIDATE_INCREMENT */ - if ( (tests & H5C_RESIZE_CFG__VALIDATE_DECREMENT) != 0 ) { + if ((tests & H5C_RESIZE_CFG__VALIDATE_DECREMENT) != 0) { - if ( ( config_ptr->decr_mode != H5C_decr__off ) && - ( config_ptr->decr_mode != H5C_decr__threshold ) && - ( config_ptr->decr_mode != H5C_decr__age_out ) && - ( config_ptr->decr_mode != H5C_decr__age_out_with_threshold ) - ) { + if ((config_ptr->decr_mode != H5C_decr__off) && (config_ptr->decr_mode != H5C_decr__threshold) && + (config_ptr->decr_mode != H5C_decr__age_out) && + (config_ptr->decr_mode != H5C_decr__age_out_with_threshold)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid decr_mode") - } + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid decr_mode") + } - if ( config_ptr->decr_mode == H5C_decr__threshold ) { - if(config_ptr->upper_hr_threshold > (double)1.0f) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") + if (config_ptr->decr_mode == H5C_decr__threshold) { + if (config_ptr->upper_hr_threshold > (double)1.0f) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") - if((config_ptr->decrement > (double)1.0f) || - (config_ptr->decrement < (double)0.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") + if ((config_ptr->decrement > (double)1.0f) || (config_ptr->decrement < (double)0.0f)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") - /* no need to check max_decrement as it is a size_t - * and thus must be non-negative. - */ - } /* H5C_decr__threshold */ + /* no need to check max_decrement as it is a size_t + * and thus must be non-negative. + */ + } /* H5C_decr__threshold */ - if((config_ptr->decr_mode == H5C_decr__age_out) || + if ((config_ptr->decr_mode == H5C_decr__age_out) || (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) { - if(config_ptr->epochs_before_eviction < 1) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction must be positive") - if(config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction too big") + if (config_ptr->epochs_before_eviction < 1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction must be positive") + if (config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction too big") - if((config_ptr->apply_empty_reserve) && - ((config_ptr->empty_reserve > (double)1.0f) || - (config_ptr->empty_reserve < (double)0.0f))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty_reserve must be in the interval [0.0, 1.0]") + if ((config_ptr->apply_empty_reserve) && ((config_ptr->empty_reserve > (double)1.0f) || + (config_ptr->empty_reserve < (double)0.0f))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "empty_reserve must be in the interval [0.0, 1.0]") - /* no need to check max_decrement as it is a size_t - * and thus must be non-negative. - */ - } /* H5C_decr__age_out || H5C_decr__age_out_with_threshold */ + /* no need to check max_decrement as it is a size_t + * and thus must be non-negative. + */ + } /* H5C_decr__age_out || H5C_decr__age_out_with_threshold */ - if(config_ptr->decr_mode == H5C_decr__age_out_with_threshold) { - if((config_ptr->upper_hr_threshold > (double)1.0f) || + if (config_ptr->decr_mode == H5C_decr__age_out_with_threshold) { + if ((config_ptr->upper_hr_threshold > (double)1.0f) || (config_ptr->upper_hr_threshold < (double)0.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be in the interval [0.0, 1.0]") - } /* H5C_decr__age_out_with_threshold */ - } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ - - - if ( (tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0 ) { - if((config_ptr->incr_mode == H5C_incr__threshold) - && ((config_ptr->decr_mode == H5C_decr__threshold) || - (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) - && (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") - } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "upper_hr_threshold must be in the interval [0.0, 1.0]") + } /* H5C_decr__age_out_with_threshold */ + } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ + + if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { + if ((config_ptr->incr_mode == H5C_incr__threshold) && + ((config_ptr->decr_mode == H5C_decr__threshold) || + (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) && + (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") + } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_validate_resize_config() */ - - -/*------------------------------------------------------------------------- - * Function: H5C_create_flush_dependency() - * - * Purpose: Initiates a parent<->child entry flush dependency. The parent - * entry must be pinned or protected at the time of call, and must - * have all dependencies removed before the cache can shut down. - * - * Note: Flush dependencies in the cache indicate that a child entry - * must be flushed to the file before its parent. (This is - * currently used to implement Single-Writer/Multiple-Reader (SWMR) - * I/O access for data structures in the file). - * - * Creating a flush dependency between two entries will also pin - * the parent entry. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 3/05/09 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_create_flush_dependency(void * parent_thing, void * child_thing) -{ - H5C_t * cache_ptr; - H5C_cache_entry_t * parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent thing's entry */ - H5C_cache_entry_t * child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child thing's entry */ - herr_t ret_value = SUCCEED; /* Return value */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_validate_resize_config() */ - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(parent_entry); - HDassert(parent_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(H5F_addr_defined(parent_entry->addr)); - HDassert(child_entry); - HDassert(child_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(H5F_addr_defined(child_entry->addr)); - cache_ptr = parent_entry->cache_ptr; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr == child_entry->cache_ptr); -#ifndef NDEBUG - /* Make sure the parent is not already a parent */ + /*------------------------------------------------------------------------- + * Function: H5C_create_flush_dependency() + * + * Purpose: Initiates a parent<->child entry flush dependency. The parent + * entry must be pinned or protected at the time of call, and must + * have all dependencies removed before the cache can shut down. + * + * Note: Flush dependencies in the cache indicate that a child entry + * must be flushed to the file before its parent. (This is + * currently used to implement Single-Writer/Multiple-Reader (SWMR) + * I/O access for data structures in the file). + * + * Creating a flush dependency between two entries will also pin + * the parent entry. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * 3/05/09 + * + *------------------------------------------------------------------------- + */ + herr_t H5C_create_flush_dependency(void *parent_thing, void *child_thing) { - unsigned u; - - for(u = 0; u < child_entry->flush_dep_nparents; u++) - HDassert(child_entry->flush_dep_parent[u] != parent_entry); - } /* end block */ -#endif /* NDEBUG */ + H5C_t * cache_ptr; + H5C_cache_entry_t *parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent thing's entry */ + H5C_cache_entry_t *child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child thing's entry */ + herr_t ret_value = SUCCEED; /* Return value */ - /* More sanity checks */ - if(child_entry == parent_entry) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Child entry flush dependency parent can't be itself") - if(!(parent_entry->is_protected || parent_entry->is_pinned)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Parent entry isn't pinned or protected") + FUNC_ENTER_NOAPI(FAIL) - /* Check for parent not pinned */ - if(!parent_entry->is_pinned) { - /* Sanity check */ - HDassert(parent_entry->flush_dep_nchildren == 0); - HDassert(!parent_entry->pinned_from_client); - HDassert(!parent_entry->pinned_from_cache); + /* Sanity checks */ + HDassert(parent_entry); + HDassert(parent_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(H5F_addr_defined(parent_entry->addr)); + HDassert(child_entry); + HDassert(child_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(H5F_addr_defined(child_entry->addr)); + cache_ptr = parent_entry->cache_ptr; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr == child_entry->cache_ptr); +#ifndef NDEBUG + /* Make sure the parent is not already a parent */ + { + unsigned u; + + for (u = 0; u < child_entry->flush_dep_nparents; u++) + HDassert(child_entry->flush_dep_parent[u] != parent_entry); + } /* end block */ +#endif /* NDEBUG */ + + /* More sanity checks */ + if (child_entry == parent_entry) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, + "Child entry flush dependency parent can't be itself") + if (!(parent_entry->is_protected || parent_entry->is_pinned)) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Parent entry isn't pinned or protected") + + /* Check for parent not pinned */ + if (!parent_entry->is_pinned) { + /* Sanity check */ + HDassert(parent_entry->flush_dep_nchildren == 0); + HDassert(!parent_entry->pinned_from_client); + HDassert(!parent_entry->pinned_from_cache); - /* Pin the parent entry */ - parent_entry->is_pinned = TRUE; - H5C__UPDATE_STATS_FOR_PIN(cache_ptr, parent_entry) - } /* end else */ + /* Pin the parent entry */ + parent_entry->is_pinned = TRUE; + H5C__UPDATE_STATS_FOR_PIN(cache_ptr, parent_entry) + } /* end else */ - /* Mark the entry as pinned from the cache's action (possibly redundantly) */ - parent_entry->pinned_from_cache = TRUE; + /* Mark the entry as pinned from the cache's action (possibly redundantly) */ + parent_entry->pinned_from_cache = TRUE; - /* Check if we need to resize the child's parent array */ - if(child_entry->flush_dep_nparents >= child_entry->flush_dep_parent_nalloc) { - if(child_entry->flush_dep_parent_nalloc == 0) { - /* Array does not exist yet, allocate it */ - HDassert(!child_entry->flush_dep_parent); + /* Check if we need to resize the child's parent array */ + if (child_entry->flush_dep_nparents >= child_entry->flush_dep_parent_nalloc) { + if (child_entry->flush_dep_parent_nalloc == 0) { + /* Array does not exist yet, allocate it */ + HDassert(!child_entry->flush_dep_parent); - if(NULL == (child_entry->flush_dep_parent = H5FL_SEQ_MALLOC(H5C_cache_entry_ptr_t, H5C_FLUSH_DEP_PARENT_INIT))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for flush dependency parent list") - child_entry->flush_dep_parent_nalloc = H5C_FLUSH_DEP_PARENT_INIT; + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_MALLOC(H5C_cache_entry_ptr_t, H5C_FLUSH_DEP_PARENT_INIT))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") + child_entry->flush_dep_parent_nalloc = H5C_FLUSH_DEP_PARENT_INIT; + } /* end if */ + else { + /* Resize existing array */ + HDassert(child_entry->flush_dep_parent); + + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, + 2 * child_entry->flush_dep_parent_nalloc))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") + child_entry->flush_dep_parent_nalloc *= 2; + } /* end else */ + cache_ptr->entry_fd_height_change_counter++; } /* end if */ - else { - /* Resize existing array */ - HDassert(child_entry->flush_dep_parent); - - if(NULL == (child_entry->flush_dep_parent = H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, 2 * child_entry->flush_dep_parent_nalloc))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for flush dependency parent list") - child_entry->flush_dep_parent_nalloc *= 2; - } /* end else */ - cache_ptr->entry_fd_height_change_counter++; - } /* end if */ - /* Add the dependency to the child's parent array */ - child_entry->flush_dep_parent[child_entry->flush_dep_nparents] = parent_entry; - child_entry->flush_dep_nparents++; + /* Add the dependency to the child's parent array */ + child_entry->flush_dep_parent[child_entry->flush_dep_nparents] = parent_entry; + child_entry->flush_dep_nparents++; - /* Increment parent's number of children */ - parent_entry->flush_dep_nchildren++; + /* Increment parent's number of children */ + parent_entry->flush_dep_nchildren++; - /* Adjust the number of dirty children */ - if(child_entry->is_dirty) { - /* Sanity check */ - HDassert(parent_entry->flush_dep_ndirty_children < parent_entry->flush_dep_nchildren); + /* Adjust the number of dirty children */ + if (child_entry->is_dirty) { + /* Sanity check */ + HDassert(parent_entry->flush_dep_ndirty_children < parent_entry->flush_dep_nchildren); - parent_entry->flush_dep_ndirty_children++; + parent_entry->flush_dep_ndirty_children++; - /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ - if(parent_entry->type->notify && + /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ + if (parent_entry->type->notify && (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry dirty flag set") - } /* end if */ + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag set") + } /* end if */ - /* adjust the parent's number of unserialized children. Note - * that it is possible for and entry to be clean and unserialized. - */ - if(!child_entry->image_up_to_date) { - HDassert(parent_entry->flush_dep_nunser_children < parent_entry->flush_dep_nchildren); + /* adjust the parent's number of unserialized children. Note + * that it is possible for and entry to be clean and unserialized. + */ + if (!child_entry->image_up_to_date) { + HDassert(parent_entry->flush_dep_nunser_children < parent_entry->flush_dep_nchildren); - parent_entry->flush_dep_nunser_children++; + parent_entry->flush_dep_nunser_children++; - /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ - if(parent_entry->type->notify && + /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ + if (parent_entry->type->notify && (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry serialized flag reset") - } /* end if */ + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag reset") + } /* end if */ - /* Post-conditions, for successful operation */ - HDassert(parent_entry->is_pinned); - HDassert(parent_entry->flush_dep_nchildren > 0); - HDassert(child_entry->flush_dep_parent); - HDassert(child_entry->flush_dep_nparents > 0); - HDassert(child_entry->flush_dep_parent_nalloc > 0); + /* Post-conditions, for successful operation */ + HDassert(parent_entry->is_pinned); + HDassert(parent_entry->flush_dep_nchildren > 0); + HDassert(child_entry->flush_dep_parent); + HDassert(child_entry->flush_dep_nparents > 0); + HDassert(child_entry->flush_dep_parent_nalloc > 0); #ifndef NDEBUG - H5C__assert_flush_dep_nocycle(parent_entry, child_entry); + H5C__assert_flush_dep_nocycle(parent_entry, child_entry); #endif /* NDEBUG */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_create_flush_dependency() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_create_flush_dependency() */ - -/*------------------------------------------------------------------------- - * Function: H5C_destroy_flush_dependency() - * - * Purpose: Terminates a parent<-> child entry flush dependency. The - * parent entry must be pinned. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 3/05/09 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_destroy_flush_dependency(void *parent_thing, void * child_thing) -{ - H5C_t * cache_ptr; - H5C_cache_entry_t * parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent entry */ - H5C_cache_entry_t * child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child entry */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5C_destroy_flush_dependency() + * + * Purpose: Terminates a parent<-> child entry flush dependency. The + * parent entry must be pinned. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * 3/05/09 + * + *------------------------------------------------------------------------- + */ + herr_t H5C_destroy_flush_dependency(void *parent_thing, void *child_thing) + { + H5C_t * cache_ptr; + H5C_cache_entry_t *parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent entry */ + H5C_cache_entry_t *child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child entry */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(FAIL) - /* Sanity checks */ - HDassert(parent_entry); - HDassert(parent_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(H5F_addr_defined(parent_entry->addr)); - HDassert(child_entry); - HDassert(child_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(H5F_addr_defined(child_entry->addr)); - cache_ptr = parent_entry->cache_ptr; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr == child_entry->cache_ptr); - - /* Usage checks */ - if(!parent_entry->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry isn't pinned") - if(NULL == child_entry->flush_dep_parent) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Child entry doesn't have a flush dependency parent array") - if(0 == parent_entry->flush_dep_nchildren) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry flush dependency ref. count has no child dependencies") - - /* Search for parent in child's parent array. This is a linear search - * because we do not expect large numbers of parents. If this changes, we - * may wish to change the parent array to a skip list */ - for(u = 0; u < child_entry->flush_dep_nparents; u++) - if(child_entry->flush_dep_parent[u] == parent_entry) - break; - if(u == child_entry->flush_dep_nparents) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry isn't a flush dependency parent for child entry") - - /* Remove parent entry from child's parent array */ - if(u < (child_entry->flush_dep_nparents - 1)) - HDmemmove(&child_entry->flush_dep_parent[u], - &child_entry->flush_dep_parent[u + 1], - (child_entry->flush_dep_nparents - u - 1) * sizeof(child_entry->flush_dep_parent[0])); - child_entry->flush_dep_nparents--; - - /* Adjust parent entry's nchildren and unpin parent if it goes to zero */ - parent_entry->flush_dep_nchildren--; - if(0 == parent_entry->flush_dep_nchildren) { - /* Sanity check */ - HDassert(parent_entry->pinned_from_cache); + /* Sanity checks */ + HDassert(parent_entry); + HDassert(parent_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(H5F_addr_defined(parent_entry->addr)); + HDassert(child_entry); + HDassert(child_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(H5F_addr_defined(child_entry->addr)); + cache_ptr = parent_entry->cache_ptr; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr == child_entry->cache_ptr); + + /* Usage checks */ + if (!parent_entry->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry isn't pinned") + if (NULL == child_entry->flush_dep_parent) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Child entry doesn't have a flush dependency parent array") + if (0 == parent_entry->flush_dep_nchildren) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Parent entry flush dependency ref. count has no child dependencies") + + /* Search for parent in child's parent array. This is a linear search + * because we do not expect large numbers of parents. If this changes, we + * may wish to change the parent array to a skip list */ + for (u = 0; u < child_entry->flush_dep_nparents; u++) + if (child_entry->flush_dep_parent[u] == parent_entry) + break; + if (u == child_entry->flush_dep_nparents) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Parent entry isn't a flush dependency parent for child entry") + + /* Remove parent entry from child's parent array */ + if (u < (child_entry->flush_dep_nparents - 1)) + HDmemmove(&child_entry->flush_dep_parent[u], &child_entry->flush_dep_parent[u + 1], + (child_entry->flush_dep_nparents - u - 1) * sizeof(child_entry->flush_dep_parent[0])); + child_entry->flush_dep_nparents--; + + /* Adjust parent entry's nchildren and unpin parent if it goes to zero */ + parent_entry->flush_dep_nchildren--; + if (0 == parent_entry->flush_dep_nchildren) { + /* Sanity check */ + HDassert(parent_entry->pinned_from_cache); - /* Check if we should unpin parent entry now */ - if(!parent_entry->pinned_from_client) - if(H5C__unpin_entry_real(cache_ptr, parent_entry, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry") + /* Check if we should unpin parent entry now */ + if (!parent_entry->pinned_from_client) + if (H5C__unpin_entry_real(cache_ptr, parent_entry, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry") - /* Mark the entry as unpinned from the cache's action */ - parent_entry->pinned_from_cache = FALSE; - } /* end if */ + /* Mark the entry as unpinned from the cache's action */ + parent_entry->pinned_from_cache = FALSE; + } /* end if */ - /* Adjust parent entry's ndirty_children */ - if(child_entry->is_dirty) { - /* Sanity check */ - HDassert(parent_entry->flush_dep_ndirty_children > 0); + /* Adjust parent entry's ndirty_children */ + if (child_entry->is_dirty) { + /* Sanity check */ + HDassert(parent_entry->flush_dep_ndirty_children > 0); - parent_entry->flush_dep_ndirty_children--; + parent_entry->flush_dep_ndirty_children--; - /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ - if(parent_entry->type->notify && + /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ + if (parent_entry->type->notify && (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry dirty flag reset") - } /* end if */ + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag reset") + } /* end if */ - /* adjust parent entry's number of unserialized children */ - if(!child_entry->image_up_to_date) { - HDassert(parent_entry->flush_dep_nunser_children > 0); + /* adjust parent entry's number of unserialized children */ + if (!child_entry->image_up_to_date) { + HDassert(parent_entry->flush_dep_nunser_children > 0); - parent_entry->flush_dep_nunser_children--; + parent_entry->flush_dep_nunser_children--; - /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ - if(parent_entry->type->notify && + /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ + if (parent_entry->type->notify && (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry serialized flag set") - } /* end if */ + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag set") + } /* end if */ - /* Shrink or free the parent array if apporpriate */ - if(child_entry->flush_dep_nparents == 0) { - child_entry->flush_dep_parent = H5FL_SEQ_FREE(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent); - child_entry->flush_dep_parent_nalloc = 0; - } /* end if */ - else if(child_entry->flush_dep_parent_nalloc > H5C_FLUSH_DEP_PARENT_INIT - && child_entry->flush_dep_nparents <= (child_entry->flush_dep_parent_nalloc / 4)) { - if(NULL == (child_entry->flush_dep_parent = H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, child_entry->flush_dep_parent_nalloc / 4))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for flush dependency parent list") - child_entry->flush_dep_parent_nalloc /= 4; - } /* end if */ + /* Shrink or free the parent array if apporpriate */ + if (child_entry->flush_dep_nparents == 0) { + child_entry->flush_dep_parent = + H5FL_SEQ_FREE(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent); + child_entry->flush_dep_parent_nalloc = 0; + } /* end if */ + else if (child_entry->flush_dep_parent_nalloc > H5C_FLUSH_DEP_PARENT_INIT && + child_entry->flush_dep_nparents <= (child_entry->flush_dep_parent_nalloc / 4)) { + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, + child_entry->flush_dep_parent_nalloc / 4))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") + child_entry->flush_dep_parent_nalloc /= 4; + } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_destroy_flush_dependency() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_destroy_flush_dependency() */ - /*************************************************************************/ /**************************** Private Functions: *************************/ /*************************************************************************/ - /*------------------------------------------------------------------------- * Function: H5C__pin_entry_from_client() * @@ -4387,2965 +4210,2841 @@ done: *------------------------------------------------------------------------- */ #if H5C_COLLECT_CACHE_STATS -static herr_t -H5C__pin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) + static herr_t H5C__pin_entry_from_client(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr) #else static herr_t H5C__pin_entry_from_client(H5C_t H5_ATTR_UNUSED *cache_ptr, H5C_cache_entry_t *entry_ptr) #endif -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC + { + herr_t ret_value = SUCCEED; /* Return value */ - /* Sanity checks */ - HDassert(cache_ptr); - HDassert(entry_ptr); - HDassert(entry_ptr->is_protected); + FUNC_ENTER_STATIC - /* Check if the entry is already pinned */ - if(entry_ptr->is_pinned) { - /* Check if the entry was pinned through an explicit pin from a client */ - if(entry_ptr->pinned_from_client) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "entry is already pinned") - } /* end if */ - else { - entry_ptr->is_pinned = TRUE; + /* Sanity checks */ + HDassert(cache_ptr); + HDassert(entry_ptr); + HDassert(entry_ptr->is_protected); + + /* Check if the entry is already pinned */ + if (entry_ptr->is_pinned) { + /* Check if the entry was pinned through an explicit pin from a client */ + if (entry_ptr->pinned_from_client) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "entry is already pinned") + } /* end if */ + else { + entry_ptr->is_pinned = TRUE; - H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) - } /* end else */ + H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) + } /* end else */ - /* Mark that the entry was pinned through an explicit pin from a client */ - entry_ptr->pinned_from_client = TRUE; + /* Mark that the entry was pinned through an explicit pin from a client */ + entry_ptr->pinned_from_client = TRUE; done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__pin_entry_from_client() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__pin_entry_from_client() */ - -/*------------------------------------------------------------------------- - * Function: H5C__unpin_entry_real() - * - * Purpose: Internal routine to unpin a cache entry. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 1/6/18 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, - hbool_t update_rp) -{ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5C__unpin_entry_real() + * + * Purpose: Internal routine to unpin a cache entry. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * 1/6/18 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__unpin_entry_real(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr, hbool_t update_rp) + { + herr_t ret_value = SUCCEED; /* Return value */ #if H5C_DO_SANITY_CHECKS - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC #else FUNC_ENTER_STATIC_NOERR #endif - /* Sanity checking */ - HDassert(cache_ptr); - HDassert(entry_ptr); - HDassert(entry_ptr->is_pinned); + /* Sanity checking */ + HDassert(cache_ptr); + HDassert(entry_ptr); + HDassert(entry_ptr->is_pinned); - /* If requested, update the replacement policy if the entry is not protected */ - if(update_rp && !entry_ptr->is_protected) - H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, FAIL) + /* If requested, update the replacement policy if the entry is not protected */ + if (update_rp && !entry_ptr->is_protected) + H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, FAIL) - /* Unpin the entry now */ - entry_ptr->is_pinned = FALSE; + /* Unpin the entry now */ + entry_ptr->is_pinned = FALSE; - /* Update the stats for an unpin operation */ - H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) + /* Update the stats for an unpin operation */ + H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) #if H5C_DO_SANITY_CHECKS done: #endif - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__unpin_entry_real() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__unpin_entry_real() */ - -/*------------------------------------------------------------------------- - * Function: H5C__unpin_entry_from_client() - * - * Purpose: Internal routine to unpin a cache entry from a client action. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 3/24/09 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, - hbool_t update_rp) -{ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5C__unpin_entry_from_client() + * + * Purpose: Internal routine to unpin a cache entry from a client action. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * 3/24/09 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__unpin_entry_from_client(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr, + hbool_t update_rp) + { + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - /* Sanity checking */ - HDassert(cache_ptr); - HDassert(entry_ptr); + /* Sanity checking */ + HDassert(cache_ptr); + HDassert(entry_ptr); - /* Error checking (should be sanity checks?) */ - if(!entry_ptr->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry isn't pinned") - if(!entry_ptr->pinned_from_client) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry wasn't pinned by cache client") + /* Error checking (should be sanity checks?) */ + if (!entry_ptr->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry isn't pinned") + if (!entry_ptr->pinned_from_client) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry wasn't pinned by cache client") - /* Check if the entry is not pinned from a flush dependency */ - if(!entry_ptr->pinned_from_cache) - if(H5C__unpin_entry_real(cache_ptr, entry_ptr, update_rp) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") + /* Check if the entry is not pinned from a flush dependency */ + if (!entry_ptr->pinned_from_cache) + if (H5C__unpin_entry_real(cache_ptr, entry_ptr, update_rp) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") - /* Mark the entry as explicitly unpinned by the client */ - entry_ptr->pinned_from_client = FALSE; + /* Mark the entry as explicitly unpinned by the client */ + entry_ptr->pinned_from_client = FALSE; done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__unpin_entry_from_client() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__unpin_entry_from_client() */ -/*------------------------------------------------------------------------- - * - * Function: H5C__auto_adjust_cache_size - * - * Purpose: Obtain the current full cache hit rate, and compare it - * with the hit rate thresholds for modifying cache size. - * If one of the thresholds has been crossed, adjusts the - * size of the cache accordingly. - * - * The function then resets the full cache hit rate - * statistics, and exits. - * - * Return: Non-negative on success/Negative on failure or if there was - * an attempt to flush a protected item. - * - * - * Programmer: John Mainzer, 10/7/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) -{ - H5C_t * cache_ptr = f->shared->cache; - hbool_t reentrant_call = FALSE; - hbool_t inserted_epoch_marker = FALSE; - size_t new_max_cache_size = 0; - size_t old_max_cache_size = 0; - size_t new_min_clean_size = 0; - size_t old_min_clean_size = 0; - double hit_rate; - enum H5C_resize_status status = in_spec; /* will change if needed */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - HDassert( f ); - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( cache_ptr->cache_accesses >= - (cache_ptr->resize_ctl).epoch_length ); - HDassert( (double)0.0f <= (cache_ptr->resize_ctl).min_clean_fraction ); - HDassert( (cache_ptr->resize_ctl).min_clean_fraction <= (double)100.0f ); - - /* check to see if cache_ptr->resize_in_progress is TRUE. If it, this - * is a re-entrant call via a client callback called in the resize - * process. To avoid an infinite recursion, set reentrant_call to - * TRUE, and goto done. + /*------------------------------------------------------------------------- + * + * Function: H5C__auto_adjust_cache_size + * + * Purpose: Obtain the current full cache hit rate, and compare it + * with the hit rate thresholds for modifying cache size. + * If one of the thresholds has been crossed, adjusts the + * size of the cache accordingly. + * + * The function then resets the full cache hit rate + * statistics, and exits. + * + * Return: Non-negative on success/Negative on failure or if there was + * an attempt to flush a protected item. + * + * + * Programmer: John Mainzer, 10/7/04 + * + *------------------------------------------------------------------------- */ - if(cache_ptr->resize_in_progress) { - reentrant_call = TRUE; - HGOTO_DONE(SUCCEED) - } /* end if */ + static herr_t H5C__auto_adjust_cache_size(H5F_t * f, hbool_t write_permitted) + { + H5C_t * cache_ptr = f->shared->cache; + hbool_t reentrant_call = FALSE; + hbool_t inserted_epoch_marker = FALSE; + size_t new_max_cache_size = 0; + size_t old_max_cache_size = 0; + size_t new_min_clean_size = 0; + size_t old_min_clean_size = 0; + double hit_rate; + enum H5C_resize_status status = in_spec; /* will change if needed */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length); + HDassert((double)0.0f <= (cache_ptr->resize_ctl).min_clean_fraction); + HDassert((cache_ptr->resize_ctl).min_clean_fraction <= (double)100.0f); + + /* check to see if cache_ptr->resize_in_progress is TRUE. If it, this + * is a re-entrant call via a client callback called in the resize + * process. To avoid an infinite recursion, set reentrant_call to + * TRUE, and goto done. + */ + if (cache_ptr->resize_in_progress) { + reentrant_call = TRUE; + HGOTO_DONE(SUCCEED) + } /* end if */ - cache_ptr->resize_in_progress = TRUE; + cache_ptr->resize_in_progress = TRUE; - if(!cache_ptr->resize_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Auto cache resize disabled") + if (!cache_ptr->resize_enabled) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Auto cache resize disabled") - HDassert(((cache_ptr->resize_ctl).incr_mode != H5C_incr__off) || \ - ((cache_ptr->resize_ctl).decr_mode != H5C_decr__off)); + HDassert(((cache_ptr->resize_ctl).incr_mode != H5C_incr__off) || + ((cache_ptr->resize_ctl).decr_mode != H5C_decr__off)); - if(H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") + if (H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") - HDassert( ( (double)0.0f <= hit_rate ) && ( hit_rate <= (double)1.0f ) ); + HDassert(((double)0.0f <= hit_rate) && (hit_rate <= (double)1.0f)); - switch((cache_ptr->resize_ctl).incr_mode) { - case H5C_incr__off: - if(cache_ptr->size_increase_possible) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "size_increase_possible but H5C_incr__off?!?!?") - break; + switch ((cache_ptr->resize_ctl).incr_mode) { + case H5C_incr__off: + if (cache_ptr->size_increase_possible) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "size_increase_possible but H5C_incr__off?!?!?") + break; - case H5C_incr__threshold: - if ( hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold ) { + case H5C_incr__threshold: + if (hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold) { - if ( ! cache_ptr->size_increase_possible ) { + if (!cache_ptr->size_increase_possible) { - status = increase_disabled; + status = increase_disabled; + } + else if (cache_ptr->max_cache_size >= (cache_ptr->resize_ctl).max_size) { - } else if ( cache_ptr->max_cache_size >= - (cache_ptr->resize_ctl).max_size ) { + HDassert(cache_ptr->max_cache_size == (cache_ptr->resize_ctl).max_size); + status = at_max_size; + } + else if (!cache_ptr->cache_full) { - HDassert( cache_ptr->max_cache_size == \ - (cache_ptr->resize_ctl).max_size ); - status = at_max_size; + status = not_full; + } + else { - } else if ( ! cache_ptr->cache_full ) { + new_max_cache_size = (size_t)(((double)(cache_ptr->max_cache_size)) * + (cache_ptr->resize_ctl).increment); - status = not_full; + /* clip to max size if necessary */ + if (new_max_cache_size > (cache_ptr->resize_ctl).max_size) { - } else { + new_max_cache_size = (cache_ptr->resize_ctl).max_size; + } - new_max_cache_size = (size_t) - (((double)(cache_ptr->max_cache_size)) * - (cache_ptr->resize_ctl).increment); + /* clip to max increment if necessary */ + if (((cache_ptr->resize_ctl).apply_max_increment) && + ((cache_ptr->max_cache_size + (cache_ptr->resize_ctl).max_increment) < + new_max_cache_size)) { - /* clip to max size if necessary */ - if ( new_max_cache_size > - (cache_ptr->resize_ctl).max_size ) { + new_max_cache_size = + cache_ptr->max_cache_size + (cache_ptr->resize_ctl).max_increment; + } - new_max_cache_size = (cache_ptr->resize_ctl).max_size; + status = increase; } + } + break; - /* clip to max increment if necessary */ - if ( ( (cache_ptr->resize_ctl).apply_max_increment ) && - ( (cache_ptr->max_cache_size + - (cache_ptr->resize_ctl).max_increment) < - new_max_cache_size ) ) { + default: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown incr_mode") + } - new_max_cache_size = cache_ptr->max_cache_size + - (cache_ptr->resize_ctl).max_increment; - } + /* If the decr_mode is either age out or age out with threshold, we + * must run the marker maintenance code, whether we run the size + * reduction code or not. We do this in two places -- here we + * insert a new marker if the number of active epoch markers is + * is less than the the current epochs before eviction, and after + * the ageout call, we cycle the markers. + * + * However, we can't call the ageout code or cycle the markers + * unless there was a full complement of markers in place on + * entry. The inserted_epoch_marker flag is used to track this. + */ - status = increase; - } - } - break; + if ((((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out) || + ((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out_with_threshold)) && + (cache_ptr->epoch_markers_active < (cache_ptr->resize_ctl).epochs_before_eviction)) { - default: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown incr_mode") - } + if (H5C__autoadjust__ageout__insert_new_marker(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't insert new epoch marker") - /* If the decr_mode is either age out or age out with threshold, we - * must run the marker maintenance code, whether we run the size - * reduction code or not. We do this in two places -- here we - * insert a new marker if the number of active epoch markers is - * is less than the the current epochs before eviction, and after - * the ageout call, we cycle the markers. - * - * However, we can't call the ageout code or cycle the markers - * unless there was a full complement of markers in place on - * entry. The inserted_epoch_marker flag is used to track this. - */ + inserted_epoch_marker = TRUE; + } - if ( ( ( (cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out ) - || - ( (cache_ptr->resize_ctl).decr_mode == - H5C_decr__age_out_with_threshold - ) - ) - && - ( cache_ptr->epoch_markers_active < - (cache_ptr->resize_ctl).epochs_before_eviction - ) - ) { - - if(H5C__autoadjust__ageout__insert_new_marker(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't insert new epoch marker") - - inserted_epoch_marker = TRUE; - } + /* don't run the cache size decrease code unless the cache size + * increase code is disabled, or the size increase code sees no need + * for action. In either case, status == in_spec at this point. + */ - /* don't run the cache size decrease code unless the cache size - * increase code is disabled, or the size increase code sees no need - * for action. In either case, status == in_spec at this point. - */ + if (status == in_spec) { - if ( status == in_spec ) { + switch ((cache_ptr->resize_ctl).decr_mode) { + case H5C_decr__off: + break; - switch ( (cache_ptr->resize_ctl).decr_mode ) - { - case H5C_decr__off: - break; + case H5C_decr__threshold: + if (hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold) { - case H5C_decr__threshold: - if ( hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold ) { + if (!cache_ptr->size_decrease_possible) { - if ( ! cache_ptr->size_decrease_possible ) { + status = decrease_disabled; + } + else if (cache_ptr->max_cache_size <= (cache_ptr->resize_ctl).min_size) { - status = decrease_disabled; + HDassert(cache_ptr->max_cache_size == (cache_ptr->resize_ctl).min_size); + status = at_min_size; + } + else { - } else if ( cache_ptr->max_cache_size <= - (cache_ptr->resize_ctl).min_size ) { + new_max_cache_size = (size_t)(((double)(cache_ptr->max_cache_size)) * + (cache_ptr->resize_ctl).decrement); - HDassert( cache_ptr->max_cache_size == - (cache_ptr->resize_ctl).min_size ); - status = at_min_size; + /* clip to min size if necessary */ + if (new_max_cache_size < (cache_ptr->resize_ctl).min_size) { - } else { + new_max_cache_size = (cache_ptr->resize_ctl).min_size; + } - new_max_cache_size = (size_t) - (((double)(cache_ptr->max_cache_size)) * - (cache_ptr->resize_ctl).decrement); + /* clip to max decrement if necessary */ + if (((cache_ptr->resize_ctl).apply_max_decrement) && + (((cache_ptr->resize_ctl).max_decrement + new_max_cache_size) < + cache_ptr->max_cache_size)) { - /* clip to min size if necessary */ - if ( new_max_cache_size < - (cache_ptr->resize_ctl).min_size ) { + new_max_cache_size = + cache_ptr->max_cache_size - (cache_ptr->resize_ctl).max_decrement; + } - new_max_cache_size = - (cache_ptr->resize_ctl).min_size; + status = decrease; } - - /* clip to max decrement if necessary */ - if ( ( (cache_ptr->resize_ctl).apply_max_decrement ) && - ( ((cache_ptr->resize_ctl).max_decrement + - new_max_cache_size) < - cache_ptr->max_cache_size ) ) { - - new_max_cache_size = cache_ptr->max_cache_size - - (cache_ptr->resize_ctl).max_decrement; - } - - status = decrease; } - } - break; + break; - case H5C_decr__age_out_with_threshold: - case H5C_decr__age_out: - if(!inserted_epoch_marker) { - if(!cache_ptr->size_decrease_possible) - status = decrease_disabled; - else { - if(H5C__autoadjust__ageout(f, hit_rate, &status, &new_max_cache_size, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ageout code failed") - } /* end else */ - } /* end if */ - break; + case H5C_decr__age_out_with_threshold: + case H5C_decr__age_out: + if (!inserted_epoch_marker) { + if (!cache_ptr->size_decrease_possible) + status = decrease_disabled; + else { + if (H5C__autoadjust__ageout(f, hit_rate, &status, &new_max_cache_size, + write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ageout code failed") + } /* end else */ + } /* end if */ + break; - default: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown incr_mode") + default: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown incr_mode") + } } - } - /* cycle the epoch markers here if appropriate */ - if ( ( ( (cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out ) - || - ( (cache_ptr->resize_ctl).decr_mode == - H5C_decr__age_out_with_threshold - ) - ) - && - ( ! inserted_epoch_marker ) - ) { - - /* move last epoch marker to the head of the LRU list */ - if(H5C__autoadjust__ageout__cycle_epoch_marker(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error cycling epoch marker") - } + /* cycle the epoch markers here if appropriate */ + if ((((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out) || + ((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out_with_threshold)) && + (!inserted_epoch_marker)) { - if ( ( status == increase ) || ( status == decrease ) ) { + /* move last epoch marker to the head of the LRU list */ + if (H5C__autoadjust__ageout__cycle_epoch_marker(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error cycling epoch marker") + } - old_max_cache_size = cache_ptr->max_cache_size; - old_min_clean_size = cache_ptr->min_clean_size; + if ((status == increase) || (status == decrease)) { - new_min_clean_size = (size_t) - ((double)new_max_cache_size * - ((cache_ptr->resize_ctl).min_clean_fraction)); + old_max_cache_size = cache_ptr->max_cache_size; + old_min_clean_size = cache_ptr->min_clean_size; - /* new_min_clean_size is of size_t, and thus must be non-negative. - * Hence we have - * - * ( 0 <= new_min_clean_size ). - * - * by definition. - */ - HDassert( new_min_clean_size <= new_max_cache_size ); - HDassert( (cache_ptr->resize_ctl).min_size <= new_max_cache_size ); - HDassert( new_max_cache_size <= (cache_ptr->resize_ctl).max_size ); + new_min_clean_size = + (size_t)((double)new_max_cache_size * ((cache_ptr->resize_ctl).min_clean_fraction)); - cache_ptr->max_cache_size = new_max_cache_size; - cache_ptr->min_clean_size = new_min_clean_size; + /* new_min_clean_size is of size_t, and thus must be non-negative. + * Hence we have + * + * ( 0 <= new_min_clean_size ). + * + * by definition. + */ + HDassert(new_min_clean_size <= new_max_cache_size); + HDassert((cache_ptr->resize_ctl).min_size <= new_max_cache_size); + HDassert(new_max_cache_size <= (cache_ptr->resize_ctl).max_size); - if ( status == increase ) { + cache_ptr->max_cache_size = new_max_cache_size; + cache_ptr->min_clean_size = new_min_clean_size; - cache_ptr->cache_full = FALSE; + if (status == increase) { - } else if ( status == decrease ) { + cache_ptr->cache_full = FALSE; + } + else if (status == decrease) { - cache_ptr->size_decreased = TRUE; - } + cache_ptr->size_decreased = TRUE; + } - /* update flash cache size increase fields as appropriate */ - if ( cache_ptr->flash_size_increase_possible ) { + /* update flash cache size increase fields as appropriate */ + if (cache_ptr->flash_size_increase_possible) { - switch ( (cache_ptr->resize_ctl).flash_incr_mode ) - { - case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flash_size_increase_possible but H5C_flash_incr__off?!") - break; + switch ((cache_ptr->resize_ctl).flash_incr_mode) { + case H5C_flash_incr__off: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") + break; - case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_threshold = - (size_t) - (((double)(cache_ptr->max_cache_size)) * - ((cache_ptr->resize_ctl).flash_threshold)); - break; + case H5C_flash_incr__add_space: + cache_ptr->flash_size_increase_threshold = + (size_t)(((double)(cache_ptr->max_cache_size)) * + ((cache_ptr->resize_ctl).flash_threshold)); + break; - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; + } } } - } - if ( (cache_ptr->resize_ctl).rpt_fcn != NULL ) { - (*((cache_ptr->resize_ctl).rpt_fcn)) - (cache_ptr, - H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, - hit_rate, - status, - old_max_cache_size, - new_max_cache_size, - old_min_clean_size, - new_min_clean_size); - } + if ((cache_ptr->resize_ctl).rpt_fcn != NULL) { + (*((cache_ptr->resize_ctl).rpt_fcn))(cache_ptr, H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, hit_rate, + status, old_max_cache_size, new_max_cache_size, + old_min_clean_size, new_min_clean_size); + } - if(H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) - /* this should be impossible... */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + /* this should be impossible... */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") done: - /* Sanity checks */ - HDassert(cache_ptr->resize_in_progress); - if(!reentrant_call) - cache_ptr->resize_in_progress = FALSE; - HDassert((!reentrant_call) || (cache_ptr->resize_in_progress)); + /* Sanity checks */ + HDassert(cache_ptr->resize_in_progress); + if (!reentrant_call) + cache_ptr->resize_in_progress = FALSE; + HDassert((!reentrant_call) || (cache_ptr->resize_in_progress)); - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__auto_adjust_cache_size() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__auto_adjust_cache_size() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout - * - * Purpose: Implement the ageout automatic cache size decrement - * algorithm. Note that while this code evicts aged out - * entries, the code does not change the maximum cache size. - * Instead, the function simply computes the new value (if - * any change is indicated) and reports this value in - * *new_max_cache_size_ptr. - * - * Return: Non-negative on success/Negative on failure or if there was - * an attempt to flush a protected item. - * - * - * Programmer: John Mainzer, 11/18/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout(H5F_t * f, double hit_rate, enum H5C_resize_status * status_ptr, - size_t * new_max_cache_size_ptr, hbool_t write_permitted) -{ - H5C_t * cache_ptr = f->shared->cache; - size_t test_size; - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * + * Function: H5C__autoadjust__ageout + * + * Purpose: Implement the ageout automatic cache size decrement + * algorithm. Note that while this code evicts aged out + * entries, the code does not change the maximum cache size. + * Instead, the function simply computes the new value (if + * any change is indicated) and reports this value in + * *new_max_cache_size_ptr. + * + * Return: Non-negative on success/Negative on failure or if there was + * an attempt to flush a protected item. + * + * + * Programmer: John Mainzer, 11/18/04 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__autoadjust__ageout(H5F_t * f, double hit_rate, enum H5C_resize_status *status_ptr, + size_t *new_max_cache_size_ptr, hbool_t write_permitted) + { + H5C_t *cache_ptr = f->shared->cache; + size_t test_size; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT - HDassert( f ); - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( ( status_ptr ) && ( *status_ptr == in_spec ) ); - HDassert( ( new_max_cache_size_ptr ) && ( *new_max_cache_size_ptr == 0 ) ); + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert((status_ptr) && (*status_ptr == in_spec)); + HDassert((new_max_cache_size_ptr) && (*new_max_cache_size_ptr == 0)); - /* remove excess epoch markers if any */ - if(cache_ptr->epoch_markers_active > (cache_ptr->resize_ctl).epochs_before_eviction) - if(H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") + /* remove excess epoch markers if any */ + if (cache_ptr->epoch_markers_active > (cache_ptr->resize_ctl).epochs_before_eviction) + if (H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") - if ( ( (cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out ) - || - ( ( (cache_ptr->resize_ctl).decr_mode == - H5C_decr__age_out_with_threshold - ) - && - ( hit_rate >= (cache_ptr->resize_ctl).upper_hr_threshold ) - ) - ) { + if (((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out) || + (((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out_with_threshold) && + (hit_rate >= (cache_ptr->resize_ctl).upper_hr_threshold))) { - if ( cache_ptr->max_cache_size > (cache_ptr->resize_ctl).min_size ){ + if (cache_ptr->max_cache_size > (cache_ptr->resize_ctl).min_size) { - /* evict aged out cache entries if appropriate... */ - if(H5C__autoadjust__ageout__evict_aged_out_entries(f, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error flushing aged out entries") + /* evict aged out cache entries if appropriate... */ + if (H5C__autoadjust__ageout__evict_aged_out_entries(f, write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error flushing aged out entries") - /* ... and then reduce cache size if appropriate */ - if ( cache_ptr->index_size < cache_ptr->max_cache_size ) { + /* ... and then reduce cache size if appropriate */ + if (cache_ptr->index_size < cache_ptr->max_cache_size) { - if ( (cache_ptr->resize_ctl).apply_empty_reserve ) { + if ((cache_ptr->resize_ctl).apply_empty_reserve) { - test_size = (size_t)(((double)cache_ptr->index_size) / - (1 - (cache_ptr->resize_ctl).empty_reserve)); + test_size = (size_t)(((double)cache_ptr->index_size) / + (1 - (cache_ptr->resize_ctl).empty_reserve)); - if ( test_size < cache_ptr->max_cache_size ) { + if (test_size < cache_ptr->max_cache_size) { - *status_ptr = decrease; - *new_max_cache_size_ptr = test_size; + *status_ptr = decrease; + *new_max_cache_size_ptr = test_size; + } } - } else { + else { - *status_ptr = decrease; - *new_max_cache_size_ptr = cache_ptr->index_size; - } + *status_ptr = decrease; + *new_max_cache_size_ptr = cache_ptr->index_size; + } - if ( *status_ptr == decrease ) { + if (*status_ptr == decrease) { - /* clip to min size if necessary */ - if ( *new_max_cache_size_ptr < - (cache_ptr->resize_ctl).min_size ) { + /* clip to min size if necessary */ + if (*new_max_cache_size_ptr < (cache_ptr->resize_ctl).min_size) { - *new_max_cache_size_ptr = - (cache_ptr->resize_ctl).min_size; - } + *new_max_cache_size_ptr = (cache_ptr->resize_ctl).min_size; + } - /* clip to max decrement if necessary */ - if ( ( (cache_ptr->resize_ctl).apply_max_decrement ) && - ( ((cache_ptr->resize_ctl).max_decrement + - *new_max_cache_size_ptr) < - cache_ptr->max_cache_size ) ) { + /* clip to max decrement if necessary */ + if (((cache_ptr->resize_ctl).apply_max_decrement) && + (((cache_ptr->resize_ctl).max_decrement + *new_max_cache_size_ptr) < + cache_ptr->max_cache_size)) { - *new_max_cache_size_ptr = cache_ptr->max_cache_size - - (cache_ptr->resize_ctl).max_decrement; + *new_max_cache_size_ptr = + cache_ptr->max_cache_size - (cache_ptr->resize_ctl).max_decrement; + } } } } - } else { + else { - *status_ptr = at_min_size; + *status_ptr = at_min_size; + } } - } done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout() */ + } /* H5C__autoadjust__ageout() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__cycle_epoch_marker - * - * Purpose: Remove the oldest epoch marker from the LRU list, - * and reinsert it at the head of the LRU list. Also - * remove the epoch marker's index from the head of the - * ring buffer, and re-insert it at the tail of the ring - * buffer. - * - * Return: SUCCEED on success/FAIL on failure. - * - * Programmer: John Mainzer, 11/22/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t * cache_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - int i; + /*------------------------------------------------------------------------- + * + * Function: H5C__autoadjust__ageout__cycle_epoch_marker + * + * Purpose: Remove the oldest epoch marker from the LRU list, + * and reinsert it at the head of the LRU list. Also + * remove the epoch marker's index from the head of the + * ring buffer, and re-insert it at the tail of the ring + * buffer. + * + * Return: SUCCEED on success/FAIL on failure. + * + * Programmer: John Mainzer, 11/22/04 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t * cache_ptr) + { + herr_t ret_value = SUCCEED; /* Return value */ + int i; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(cache_ptr->epoch_markers_active <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "No active epoch markers on entry?!?!?") + if (cache_ptr->epoch_markers_active <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "No active epoch markers on entry?!?!?") - /* remove the last marker from both the ring buffer and the LRU list */ + /* remove the last marker from both the ring buffer and the LRU list */ - i = cache_ptr->epoch_marker_ringbuf[cache_ptr->epoch_marker_ringbuf_first]; + i = cache_ptr->epoch_marker_ringbuf[cache_ptr->epoch_marker_ringbuf_first]; - cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + cache_ptr->epoch_marker_ringbuf_first = + (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - cache_ptr->epoch_marker_ringbuf_size -= 1; + cache_ptr->epoch_marker_ringbuf_size -= 1; - if(cache_ptr->epoch_marker_ringbuf_size < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") - if((cache_ptr->epoch_marker_active)[i] != TRUE) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") + if (cache_ptr->epoch_marker_ringbuf_size < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + if ((cache_ptr->epoch_marker_active)[i] != TRUE) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") - H5C__DLL_REMOVE((&((cache_ptr->epoch_markers)[i])), \ - (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (FAIL)) + H5C__DLL_REMOVE((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, + (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, + (FAIL)) - /* now, re-insert it at the head of the LRU list, and at the tail of - * the ring buffer. - */ + /* now, re-insert it at the head of the LRU list, and at the tail of + * the ring buffer. + */ - HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); - HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); - HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); + HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); + HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); + HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); - cache_ptr->epoch_marker_ringbuf_last = - (cache_ptr->epoch_marker_ringbuf_last + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + cache_ptr->epoch_marker_ringbuf_last = + (cache_ptr->epoch_marker_ringbuf_last + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - (cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i; + (cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i; - cache_ptr->epoch_marker_ringbuf_size += 1; + cache_ptr->epoch_marker_ringbuf_size += 1; - if(cache_ptr->epoch_marker_ringbuf_size > H5C__MAX_EPOCH_MARKERS) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") + if (cache_ptr->epoch_marker_ringbuf_size > H5C__MAX_EPOCH_MARKERS) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") - H5C__DLL_PREPEND((&((cache_ptr->epoch_markers)[i])), \ - (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (FAIL)) + H5C__DLL_PREPEND((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, + (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, + (FAIL)) done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout__cycle_epoch_marker() */ + } /* H5C__autoadjust__ageout__cycle_epoch_marker() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__evict_aged_out_entries - * - * Purpose: Evict clean entries in the cache that haven't - * been accessed for at least - * (cache_ptr->resize_ctl).epochs_before_eviction epochs, - * and flush dirty entries that haven't been accessed for - * that amount of time. - * - * Depending on configuration, the function will either - * flush or evict all such entries, or all such entries it - * encounters until it has freed the maximum amount of space - * allowed under the maximum decrement. - * - * If we are running in parallel mode, writes may not be - * permitted. If so, the function simply skips any dirty - * entries it may encounter. - * - * The function makes no attempt to maintain the minimum - * clean size, as there is no guarantee that the cache size - * will be changed. - * - * If there is no cache size change, the minimum clean size - * constraint will be met through a combination of clean - * entries and free space in the cache. - * - * If there is a cache size reduction, the minimum clean size - * will be re-calculated, and will be enforced the next time - * we have to make space in the cache. - * - * Observe that this function cannot occasion a read. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 11/22/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitted) -{ - H5C_t * cache_ptr = f->shared->cache; - size_t eviction_size_limit; - size_t bytes_evicted = 0; - hbool_t prev_is_dirty = FALSE; - hbool_t restart_scan; - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * next_ptr; - H5C_cache_entry_t * prev_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - HDassert( f ); - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - - /* if there is a limit on the amount that the cache size can be decrease - * in any one round of the cache size reduction algorithm, load that - * limit into eviction_size_limit. Otherwise, set eviction_size_limit - * to the equivalent of infinity. The current size of the index will - * do nicely. + /*------------------------------------------------------------------------- + * + * Function: H5C__autoadjust__ageout__evict_aged_out_entries + * + * Purpose: Evict clean entries in the cache that haven't + * been accessed for at least + * (cache_ptr->resize_ctl).epochs_before_eviction epochs, + * and flush dirty entries that haven't been accessed for + * that amount of time. + * + * Depending on configuration, the function will either + * flush or evict all such entries, or all such entries it + * encounters until it has freed the maximum amount of space + * allowed under the maximum decrement. + * + * If we are running in parallel mode, writes may not be + * permitted. If so, the function simply skips any dirty + * entries it may encounter. + * + * The function makes no attempt to maintain the minimum + * clean size, as there is no guarantee that the cache size + * will be changed. + * + * If there is no cache size change, the minimum clean size + * constraint will be met through a combination of clean + * entries and free space in the cache. + * + * If there is a cache size reduction, the minimum clean size + * will be re-calculated, and will be enforced the next time + * we have to make space in the cache. + * + * Observe that this function cannot occasion a read. + * + * Return: Non-negative on success/Negative on failure. + * + * Programmer: John Mainzer, 11/22/04 + * + *------------------------------------------------------------------------- */ - if ( (cache_ptr->resize_ctl).apply_max_decrement ) { - - eviction_size_limit = (cache_ptr->resize_ctl).max_decrement; - - } else { - - eviction_size_limit = cache_ptr->index_size; /* i.e. infinity */ - } - - if ( write_permitted ) { + static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, hbool_t write_permitted) + { + H5C_t * cache_ptr = f->shared->cache; + size_t eviction_size_limit; + size_t bytes_evicted = 0; + hbool_t prev_is_dirty = FALSE; + hbool_t restart_scan; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *next_ptr; + H5C_cache_entry_t *prev_ptr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + + /* if there is a limit on the amount that the cache size can be decrease + * in any one round of the cache size reduction algorithm, load that + * limit into eviction_size_limit. Otherwise, set eviction_size_limit + * to the equivalent of infinity. The current size of the index will + * do nicely. + */ + if ((cache_ptr->resize_ctl).apply_max_decrement) { - restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; + eviction_size_limit = (cache_ptr->resize_ctl).max_decrement; + } + else { - while ( ( entry_ptr != NULL ) && - ( (entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID ) && - ( bytes_evicted < eviction_size_limit ) ) - { - hbool_t skipping_entry = FALSE; + eviction_size_limit = cache_ptr->index_size; /* i.e. infinity */ + } - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( (entry_ptr->ro_ref_count) == 0 ); + if (write_permitted) { - next_ptr = entry_ptr->next; - prev_ptr = entry_ptr->prev; + restart_scan = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; - if(prev_ptr != NULL) - prev_is_dirty = prev_ptr->is_dirty; + while ((entry_ptr != NULL) && ((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && + (bytes_evicted < eviction_size_limit)) { + hbool_t skipping_entry = FALSE; - if(entry_ptr->is_dirty ) { - HDassert(!entry_ptr->prefetched_dirty); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert((entry_ptr->ro_ref_count) == 0); - /* dirty corked entry is skipped */ - if(entry_ptr->tag_info && entry_ptr->tag_info->corked) - skipping_entry = TRUE; - else { - /* reset entries_removed_counter and - * last_entry_removed_ptr prior to the call to - * H5C__flush_single_entry() so that we can spot - * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry - * that is no longer in the cache. - */ - cache_ptr->entries_removed_counter = 0; - cache_ptr->last_entry_removed_ptr = NULL; + next_ptr = entry_ptr->next; + prev_ptr = entry_ptr->prev; - if(H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + if (prev_ptr != NULL) + prev_is_dirty = prev_ptr->is_dirty; - if(cache_ptr->entries_removed_counter > 1 || cache_ptr->last_entry_removed_ptr == prev_ptr) - restart_scan = TRUE; - } /* end else */ - } /* end if */ - else if(!entry_ptr->prefetched_dirty) { + if (entry_ptr->is_dirty) { + HDassert(!entry_ptr->prefetched_dirty); - bytes_evicted += entry_ptr->size; + /* dirty corked entry is skipped */ + if (entry_ptr->tag_info && entry_ptr->tag_info->corked) + skipping_entry = TRUE; + else { + /* reset entries_removed_counter and + * last_entry_removed_ptr prior to the call to + * H5C__flush_single_entry() so that we can spot + * unexpected removals of entries from the cache, + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry + * that is no longer in the cache. + */ + cache_ptr->entries_removed_counter = 0; + cache_ptr->last_entry_removed_ptr = NULL; - if(H5C__flush_single_entry(f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0 ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } /* end else-if */ - else { - HDassert(!entry_ptr->is_dirty); - HDassert(entry_ptr->prefetched_dirty); + if (H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - skipping_entry = TRUE; - } /* end else */ + if (cache_ptr->entries_removed_counter > 1 || + cache_ptr->last_entry_removed_ptr == prev_ptr) + restart_scan = TRUE; + } /* end else */ + } /* end if */ + else if (!entry_ptr->prefetched_dirty) { - if(prev_ptr != NULL) { - if(skipping_entry) - entry_ptr = prev_ptr; - else if(restart_scan || (prev_ptr->is_dirty != prev_is_dirty) - || (prev_ptr->next != next_ptr) - || (prev_ptr->is_protected) - || (prev_ptr->is_pinned)) { - /* Something has happened to the LRU -- start over - * from the tail. - */ - restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; + bytes_evicted += entry_ptr->size; - H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") } /* end else-if */ - else - entry_ptr = prev_ptr; - } /* end if */ - else - entry_ptr = NULL; - } /* end while */ + else { + HDassert(!entry_ptr->is_dirty); + HDassert(entry_ptr->prefetched_dirty); - /* for now at least, don't bother to maintain the minimum clean size, - * as the cache should now be less than its maximum size. Due to - * the vaguries of the cache size reduction algorthim, we may not - * reduce the size of the cache. - * - * If we do, we will calculate a new minimum clean size, which will - * be enforced the next time we try to make space in the cache. - * - * If we don't, no action is necessary, as we have just evicted and/or - * or flushed a bunch of entries and therefore the sum of the clean - * and free space in the cache must be greater than or equal to the - * min clean space requirement (assuming that requirement was met on - * entry). - */ + skipping_entry = TRUE; + } /* end else */ - } /* end if */ - else /* ! write_permitted */ { - /* Since we are not allowed to write, all we can do is evict - * any clean entries that we may encounter before we either - * hit the eviction size limit, or encounter the epoch marker. - * - * If we are operating read only, this isn't an issue, as there - * will not be any dirty entries. - * - * If we are operating in R/W mode, all the dirty entries we - * skip will be flushed the next time we attempt to make space - * when writes are permitted. This may have some local - * performance implications, but it shouldn't cause any net - * slowdown. - */ - HDassert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); - entry_ptr = cache_ptr->LRU_tail_ptr; - while(entry_ptr != NULL && - ((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && - (bytes_evicted < eviction_size_limit)) { - HDassert(!(entry_ptr->is_protected)); + if (prev_ptr != NULL) { + if (skipping_entry) + entry_ptr = prev_ptr; + else if (restart_scan || (prev_ptr->is_dirty != prev_is_dirty) || + (prev_ptr->next != next_ptr) || (prev_ptr->is_protected) || + (prev_ptr->is_pinned)) { + /* Something has happened to the LRU -- start over + * from the tail. + */ + restart_scan = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; - prev_ptr = entry_ptr->prev; + H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) + } /* end else-if */ + else + entry_ptr = prev_ptr; + } /* end if */ + else + entry_ptr = NULL; + } /* end while */ - if(!(entry_ptr->is_dirty) && !(entry_ptr->prefetched_dirty)) - if(H5C__flush_single_entry(f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") + /* for now at least, don't bother to maintain the minimum clean size, + * as the cache should now be less than its maximum size. Due to + * the vaguries of the cache size reduction algorthim, we may not + * reduce the size of the cache. + * + * If we do, we will calculate a new minimum clean size, which will + * be enforced the next time we try to make space in the cache. + * + * If we don't, no action is necessary, as we have just evicted and/or + * or flushed a bunch of entries and therefore the sum of the clean + * and free space in the cache must be greater than or equal to the + * min clean space requirement (assuming that requirement was met on + * entry). + */ - /* just skip the entry if it is dirty, as we can't do - * anything with it now since we can't write. - * - * Since all entries are clean, serialize() will not be called, - * and thus we needn't test to see if the LRU has been changed - * out from under us. + } /* end if */ + else /* ! write_permitted */ { + /* Since we are not allowed to write, all we can do is evict + * any clean entries that we may encounter before we either + * hit the eviction size limit, or encounter the epoch marker. + * + * If we are operating read only, this isn't an issue, as there + * will not be any dirty entries. + * + * If we are operating in R/W mode, all the dirty entries we + * skip will be flushed the next time we attempt to make space + * when writes are permitted. This may have some local + * performance implications, but it shouldn't cause any net + * slowdown. */ - entry_ptr = prev_ptr; - } /* end while */ - } /* end else */ + HDassert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); + entry_ptr = cache_ptr->LRU_tail_ptr; + while (entry_ptr != NULL && ((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && + (bytes_evicted < eviction_size_limit)) { + HDassert(!(entry_ptr->is_protected)); + + prev_ptr = entry_ptr->prev; + + if (!(entry_ptr->is_dirty) && !(entry_ptr->prefetched_dirty)) + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") + + /* just skip the entry if it is dirty, as we can't do + * anything with it now since we can't write. + * + * Since all entries are clean, serialize() will not be called, + * and thus we needn't test to see if the LRU has been changed + * out from under us. + */ + entry_ptr = prev_ptr; + } /* end while */ + } /* end else */ - if(cache_ptr->index_size < cache_ptr->max_cache_size) - cache_ptr->cache_full = FALSE; + if (cache_ptr->index_size < cache_ptr->max_cache_size) + cache_ptr->cache_full = FALSE; done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout__evict_aged_out_entries() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__autoadjust__ageout__evict_aged_out_entries() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__insert_new_marker - * - * Purpose: Find an unused marker cache entry, mark it as used, and - * insert it at the head of the LRU list. Also add the - * marker's index in the epoch_markers array. - * - * Return: SUCCEED on success/FAIL on failure. - * - * Programmer: John Mainzer, 11/19/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - int i; + /*------------------------------------------------------------------------- + * + * Function: H5C__autoadjust__ageout__insert_new_marker + * + * Purpose: Find an unused marker cache entry, mark it as used, and + * insert it at the head of the LRU list. Also add the + * marker's index in the epoch_markers array. + * + * Return: SUCCEED on success/FAIL on failure. + * + * Programmer: John Mainzer, 11/19/04 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr) + { + herr_t ret_value = SUCCEED; /* Return value */ + int i; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(cache_ptr->epoch_markers_active >= (cache_ptr->resize_ctl).epochs_before_eviction) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Already have a full complement of markers") + if (cache_ptr->epoch_markers_active >= (cache_ptr->resize_ctl).epochs_before_eviction) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Already have a full complement of markers") - /* find an unused marker */ - i = 0; - while((cache_ptr->epoch_marker_active)[i] && i < H5C__MAX_EPOCH_MARKERS) - i++; + /* find an unused marker */ + i = 0; + while ((cache_ptr->epoch_marker_active)[i] && i < H5C__MAX_EPOCH_MARKERS) + i++; - if(i >= H5C__MAX_EPOCH_MARKERS) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't find unused marker") + if (i >= H5C__MAX_EPOCH_MARKERS) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't find unused marker") - HDassert( ((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i ); - HDassert( ((cache_ptr->epoch_markers)[i]).next == NULL ); - HDassert( ((cache_ptr->epoch_markers)[i]).prev == NULL ); + HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); + HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); + HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); - (cache_ptr->epoch_marker_active)[i] = TRUE; + (cache_ptr->epoch_marker_active)[i] = TRUE; - cache_ptr->epoch_marker_ringbuf_last = - (cache_ptr->epoch_marker_ringbuf_last + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + cache_ptr->epoch_marker_ringbuf_last = + (cache_ptr->epoch_marker_ringbuf_last + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - (cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i; + (cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i; - cache_ptr->epoch_marker_ringbuf_size += 1; + cache_ptr->epoch_marker_ringbuf_size += 1; - if ( cache_ptr->epoch_marker_ringbuf_size > H5C__MAX_EPOCH_MARKERS ) { + if (cache_ptr->epoch_marker_ringbuf_size > H5C__MAX_EPOCH_MARKERS) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") + } - H5C__DLL_PREPEND((&((cache_ptr->epoch_markers)[i])), \ - (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (FAIL)) + H5C__DLL_PREPEND((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, + (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, + (FAIL)) - cache_ptr->epoch_markers_active += 1; + cache_ptr->epoch_markers_active += 1; done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout__insert_new_marker() */ + } /* H5C__autoadjust__ageout__insert_new_marker() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__remove_all_markers - * - * Purpose: Remove all epoch markers from the LRU list and mark them - * as inactive. - * - * Return: SUCCEED on success/FAIL on failure. - * - * Programmer: John Mainzer, 11/22/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__remove_all_markers(H5C_t * cache_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - int i; - int ring_buf_index; + /*------------------------------------------------------------------------- + * + * Function: H5C__autoadjust__ageout__remove_all_markers + * + * Purpose: Remove all epoch markers from the LRU list and mark them + * as inactive. + * + * Return: SUCCEED on success/FAIL on failure. + * + * Programmer: John Mainzer, 11/22/04 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__autoadjust__ageout__remove_all_markers(H5C_t * cache_ptr) + { + herr_t ret_value = SUCCEED; /* Return value */ + int i; + int ring_buf_index; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - while ( cache_ptr->epoch_markers_active > 0 ) - { - /* get the index of the last epoch marker in the LRU list - * and remove it from the ring buffer. - */ + while (cache_ptr->epoch_markers_active > 0) { + /* get the index of the last epoch marker in the LRU list + * and remove it from the ring buffer. + */ - ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; - i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; + ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; + i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; - cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + cache_ptr->epoch_marker_ringbuf_first = + (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - cache_ptr->epoch_marker_ringbuf_size -= 1; + cache_ptr->epoch_marker_ringbuf_size -= 1; - if(cache_ptr->epoch_marker_ringbuf_size < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + if (cache_ptr->epoch_marker_ringbuf_size < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") - if((cache_ptr->epoch_marker_active)[i] != TRUE) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") + if ((cache_ptr->epoch_marker_active)[i] != TRUE) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") - /* remove the epoch marker from the LRU list */ - H5C__DLL_REMOVE((&((cache_ptr->epoch_markers)[i])), \ - (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (FAIL)) + /* remove the epoch marker from the LRU list */ + H5C__DLL_REMOVE((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, + (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, + (FAIL)) - /* mark the epoch marker as unused. */ - (cache_ptr->epoch_marker_active)[i] = FALSE; + /* mark the epoch marker as unused. */ + (cache_ptr->epoch_marker_active)[i] = FALSE; - HDassert( ((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i ); - HDassert( ((cache_ptr->epoch_markers)[i]).next == NULL ); - HDassert( ((cache_ptr->epoch_markers)[i]).prev == NULL ); + HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); + HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); + HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); - /* decrement the number of active epoch markers */ - cache_ptr->epoch_markers_active -= 1; + /* decrement the number of active epoch markers */ + cache_ptr->epoch_markers_active -= 1; - HDassert( cache_ptr->epoch_markers_active == \ - cache_ptr->epoch_marker_ringbuf_size ); - } + HDassert(cache_ptr->epoch_markers_active == cache_ptr->epoch_marker_ringbuf_size); + } done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout__remove_all_markers() */ + } /* H5C__autoadjust__ageout__remove_all_markers() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__remove_excess_markers - * - * Purpose: Remove epoch markers from the end of the LRU list and - * mark them as inactive until the number of active markers - * equals the the current value of - * (cache_ptr->resize_ctl).epochs_before_eviction. - * - * Return: SUCCEED on success/FAIL on failure. - * - * Programmer: John Mainzer, 11/19/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__remove_excess_markers(H5C_t * cache_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - int i; - int ring_buf_index; + /*------------------------------------------------------------------------- + * + * Function: H5C__autoadjust__ageout__remove_excess_markers + * + * Purpose: Remove epoch markers from the end of the LRU list and + * mark them as inactive until the number of active markers + * equals the the current value of + * (cache_ptr->resize_ctl).epochs_before_eviction. + * + * Return: SUCCEED on success/FAIL on failure. + * + * Programmer: John Mainzer, 11/19/04 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__autoadjust__ageout__remove_excess_markers(H5C_t * cache_ptr) + { + herr_t ret_value = SUCCEED; /* Return value */ + int i; + int ring_buf_index; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(cache_ptr->epoch_markers_active <= (cache_ptr->resize_ctl).epochs_before_eviction) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "no excess markers on entry") + if (cache_ptr->epoch_markers_active <= (cache_ptr->resize_ctl).epochs_before_eviction) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "no excess markers on entry") - while(cache_ptr->epoch_markers_active > (cache_ptr->resize_ctl).epochs_before_eviction) { - /* get the index of the last epoch marker in the LRU list - * and remove it from the ring buffer. - */ + while (cache_ptr->epoch_markers_active > (cache_ptr->resize_ctl).epochs_before_eviction) { + /* get the index of the last epoch marker in the LRU list + * and remove it from the ring buffer. + */ - ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; - i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; + ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; + i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; - cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + cache_ptr->epoch_marker_ringbuf_first = + (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - cache_ptr->epoch_marker_ringbuf_size -= 1; + cache_ptr->epoch_marker_ringbuf_size -= 1; - if(cache_ptr->epoch_marker_ringbuf_size < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") - if((cache_ptr->epoch_marker_active)[i] != TRUE) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") + if (cache_ptr->epoch_marker_ringbuf_size < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + if ((cache_ptr->epoch_marker_active)[i] != TRUE) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") - /* remove the epoch marker from the LRU list */ - H5C__DLL_REMOVE((&((cache_ptr->epoch_markers)[i])), \ - (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (FAIL)) + /* remove the epoch marker from the LRU list */ + H5C__DLL_REMOVE((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, + (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, + (FAIL)) - /* mark the epoch marker as unused. */ - (cache_ptr->epoch_marker_active)[i] = FALSE; + /* mark the epoch marker as unused. */ + (cache_ptr->epoch_marker_active)[i] = FALSE; - HDassert( ((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i ); - HDassert( ((cache_ptr->epoch_markers)[i]).next == NULL ); - HDassert( ((cache_ptr->epoch_markers)[i]).prev == NULL ); + HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); + HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); + HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); - /* decrement the number of active epoch markers */ - cache_ptr->epoch_markers_active -= 1; + /* decrement the number of active epoch markers */ + cache_ptr->epoch_markers_active -= 1; - HDassert( cache_ptr->epoch_markers_active == \ - cache_ptr->epoch_marker_ringbuf_size ); - } + HDassert(cache_ptr->epoch_markers_active == cache_ptr->epoch_marker_ringbuf_size); + } done: - FUNC_LEAVE_NOAPI(ret_value) - -} /* H5C__autoadjust__ageout__remove_excess_markers() */ - - -/*------------------------------------------------------------------------- - * - * Function: H5C__flash_increase_cache_size - * - * Purpose: If there is not at least new_entry_size - old_entry_size - * bytes of free space in the cache and the current - * max_cache_size is less than (cache_ptr->resize_ctl).max_size, - * perform a flash increase in the cache size and then reset - * the full cache hit rate statistics, and exit. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 12/31/07 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__flash_increase_cache_size(H5C_t * cache_ptr, - size_t old_entry_size, - size_t new_entry_size) -{ - size_t new_max_cache_size = 0; - size_t old_max_cache_size = 0; - size_t new_min_clean_size = 0; - size_t old_min_clean_size = 0; - size_t space_needed; - enum H5C_resize_status status = flash_increase; /* may change */ - double hit_rate; - herr_t ret_value = SUCCEED; /* Return value */ + FUNC_LEAVE_NOAPI(ret_value) - FUNC_ENTER_NOAPI_NOINIT + } /* H5C__autoadjust__ageout__remove_excess_markers() */ - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( cache_ptr->flash_size_increase_possible ); - HDassert( new_entry_size > cache_ptr->flash_size_increase_threshold ); - HDassert( old_entry_size < new_entry_size ); + /*------------------------------------------------------------------------- + * + * Function: H5C__flash_increase_cache_size + * + * Purpose: If there is not at least new_entry_size - old_entry_size + * bytes of free space in the cache and the current + * max_cache_size is less than (cache_ptr->resize_ctl).max_size, + * perform a flash increase in the cache size and then reset + * the full cache hit rate statistics, and exit. + * + * Return: Non-negative on success/Negative on failure. + * + * Programmer: John Mainzer, 12/31/07 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__flash_increase_cache_size(H5C_t * cache_ptr, size_t old_entry_size, + size_t new_entry_size) + { + size_t new_max_cache_size = 0; + size_t old_max_cache_size = 0; + size_t new_min_clean_size = 0; + size_t old_min_clean_size = 0; + size_t space_needed; + enum H5C_resize_status status = flash_increase; /* may change */ + double hit_rate; + herr_t ret_value = SUCCEED; /* Return value */ - if(old_entry_size >= new_entry_size) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "old_entry_size >= new_entry_size") + FUNC_ENTER_NOAPI_NOINIT - space_needed = new_entry_size - old_entry_size; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->flash_size_increase_possible); + HDassert(new_entry_size > cache_ptr->flash_size_increase_threshold); + HDassert(old_entry_size < new_entry_size); - if ( ( (cache_ptr->index_size + space_needed) > - cache_ptr->max_cache_size ) && - ( cache_ptr->max_cache_size < (cache_ptr->resize_ctl).max_size ) ) { + if (old_entry_size >= new_entry_size) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "old_entry_size >= new_entry_size") - /* we have work to do */ + space_needed = new_entry_size - old_entry_size; - switch ( (cache_ptr->resize_ctl).flash_incr_mode ) - { - case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flash_size_increase_possible but H5C_flash_incr__off?!") - break; + if (((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) && + (cache_ptr->max_cache_size < (cache_ptr->resize_ctl).max_size)) { - case H5C_flash_incr__add_space: - if ( cache_ptr->index_size < cache_ptr->max_cache_size ) { + /* we have work to do */ - HDassert( (cache_ptr->max_cache_size - cache_ptr->index_size) - < space_needed ); - space_needed -= cache_ptr->max_cache_size - - cache_ptr->index_size; - } - space_needed = - (size_t)(((double)space_needed) * - (cache_ptr->resize_ctl).flash_multiple); + switch ((cache_ptr->resize_ctl).flash_incr_mode) { + case H5C_flash_incr__off: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") + break; - new_max_cache_size = cache_ptr->max_cache_size + space_needed; + case H5C_flash_incr__add_space: + if (cache_ptr->index_size < cache_ptr->max_cache_size) { - break; + HDassert((cache_ptr->max_cache_size - cache_ptr->index_size) < space_needed); + space_needed -= cache_ptr->max_cache_size - cache_ptr->index_size; + } + space_needed = (size_t)(((double)space_needed) * (cache_ptr->resize_ctl).flash_multiple); - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; - } + new_max_cache_size = cache_ptr->max_cache_size + space_needed; - if ( new_max_cache_size > (cache_ptr->resize_ctl).max_size ) { + break; - new_max_cache_size = (cache_ptr->resize_ctl).max_size; - } + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; + } - HDassert( new_max_cache_size > cache_ptr->max_cache_size ); + if (new_max_cache_size > (cache_ptr->resize_ctl).max_size) { - new_min_clean_size = (size_t) - ((double)new_max_cache_size * - ((cache_ptr->resize_ctl).min_clean_fraction)); + new_max_cache_size = (cache_ptr->resize_ctl).max_size; + } - HDassert( new_min_clean_size <= new_max_cache_size ); + HDassert(new_max_cache_size > cache_ptr->max_cache_size); - old_max_cache_size = cache_ptr->max_cache_size; - old_min_clean_size = cache_ptr->min_clean_size; + new_min_clean_size = + (size_t)((double)new_max_cache_size * ((cache_ptr->resize_ctl).min_clean_fraction)); - cache_ptr->max_cache_size = new_max_cache_size; - cache_ptr->min_clean_size = new_min_clean_size; + HDassert(new_min_clean_size <= new_max_cache_size); - /* update flash cache size increase fields as appropriate */ - HDassert ( cache_ptr->flash_size_increase_possible ); + old_max_cache_size = cache_ptr->max_cache_size; + old_min_clean_size = cache_ptr->min_clean_size; - switch ( (cache_ptr->resize_ctl).flash_incr_mode ) - { - case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flash_size_increase_possible but H5C_flash_incr__off?!") - break; + cache_ptr->max_cache_size = new_max_cache_size; + cache_ptr->min_clean_size = new_min_clean_size; - case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_threshold = - (size_t) - (((double)(cache_ptr->max_cache_size)) * - ((cache_ptr->resize_ctl).flash_threshold)); - break; + /* update flash cache size increase fields as appropriate */ + HDassert(cache_ptr->flash_size_increase_possible); - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; - } + switch ((cache_ptr->resize_ctl).flash_incr_mode) { + case H5C_flash_incr__off: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") + break; - /* note that we don't cycle the epoch markers. We can - * argue either way as to whether we should, but for now - * we don't. - */ + case H5C_flash_incr__add_space: + cache_ptr->flash_size_increase_threshold = (size_t)( + ((double)(cache_ptr->max_cache_size)) * ((cache_ptr->resize_ctl).flash_threshold)); + break; - if ( (cache_ptr->resize_ctl).rpt_fcn != NULL ) { + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; + } - /* get the hit rate for the reporting function. Should still - * be good as we haven't reset the hit rate statistics. + /* note that we don't cycle the epoch markers. We can + * argue either way as to whether we should, but for now + * we don't. */ - if(H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") - - (*((cache_ptr->resize_ctl).rpt_fcn)) - (cache_ptr, - H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, - hit_rate, - status, - old_max_cache_size, - new_max_cache_size, - old_min_clean_size, - new_min_clean_size); - } - - if(H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) - /* this should be impossible... */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") - } -done: + if ((cache_ptr->resize_ctl).rpt_fcn != NULL) { - FUNC_LEAVE_NOAPI(ret_value) + /* get the hit rate for the reporting function. Should still + * be good as we haven't reset the hit rate statistics. + */ + if (H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") -} /* H5C__flash_increase_cache_size() */ + (*((cache_ptr->resize_ctl).rpt_fcn))(cache_ptr, H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, hit_rate, + status, old_max_cache_size, new_max_cache_size, + old_min_clean_size, new_min_clean_size); + } - -/*------------------------------------------------------------------------- - * Function: H5C__flush_invalidate_cache - * - * Purpose: Flush and destroy the entries contained in the target - * cache. - * - * If the cache contains protected entries, the function will - * fail, as protected entries cannot be either flushed or - * destroyed. However all unprotected entries should be - * flushed and destroyed before the function returns failure. - * - * While pinned entries can usually be flushed, they cannot - * be destroyed. However, they should be unpinned when all - * the entries that reference them have been destroyed (thus - * reduding the pinned entry's reference count to 0, allowing - * it to be unpinned). - * - * If pinned entries are present, the function makes repeated - * passes through the cache, flushing all dirty entries - * (including the pinned dirty entries where permitted) and - * destroying all unpinned entries. This process is repeated - * until either the cache is empty, or the number of pinned - * entries stops decreasing on each pass. - * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. - * - * Programmer: John Mainzer - * 3/24/065 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) -{ - H5C_t * cache_ptr; - H5C_ring_t ring; - herr_t ret_value = SUCCEED; + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + /* this should be impossible... */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") + } - FUNC_ENTER_STATIC +done: - HDassert(f); - HDassert(f->shared); - cache_ptr = f->shared->cache; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr->slist_ptr); + FUNC_LEAVE_NOAPI(ret_value) -#if H5C_DO_SANITY_CHECKS -{ - int32_t i; - uint32_t index_len = 0; - uint32_t slist_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; + } /* H5C__flash_increase_cache_size() */ - HDassert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); - HDassert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); - HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + /*------------------------------------------------------------------------- + * Function: H5C__flush_invalidate_cache + * + * Purpose: Flush and destroy the entries contained in the target + * cache. + * + * If the cache contains protected entries, the function will + * fail, as protected entries cannot be either flushed or + * destroyed. However all unprotected entries should be + * flushed and destroyed before the function returns failure. + * + * While pinned entries can usually be flushed, they cannot + * be destroyed. However, they should be unpinned when all + * the entries that reference them have been destroyed (thus + * reduding the pinned entry's reference count to 0, allowing + * it to be unpinned). + * + * If pinned entries are present, the function makes repeated + * passes through the cache, flushing all dirty entries + * (including the pinned dirty entries where permitted) and + * destroying all unpinned entries. This process is repeated + * until either the cache is empty, or the number of pinned + * entries stops decreasing on each pass. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + * Programmer: John Mainzer + * 3/24/065 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__flush_invalidate_cache(H5F_t * f, unsigned flags) + { + H5C_t * cache_ptr; + H5C_ring_t ring; + herr_t ret_value = SUCCEED; - for(i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { - index_len += cache_ptr->index_ring_len[i]; - index_size += cache_ptr->index_ring_size[i]; - clean_index_size += cache_ptr->clean_index_ring_size[i]; - dirty_index_size += cache_ptr->dirty_index_ring_size[i]; + FUNC_ENTER_STATIC - slist_len += cache_ptr->slist_ring_len[i]; - slist_size += cache_ptr->slist_ring_size[i]; - } /* end for */ + HDassert(f); + HDassert(f->shared); + cache_ptr = f->shared->cache; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->slist_ptr); - HDassert(cache_ptr->index_len == index_len); - HDassert(cache_ptr->index_size == index_size); - HDassert(cache_ptr->clean_index_size == clean_index_size); - HDassert(cache_ptr->dirty_index_size == dirty_index_size); - HDassert(cache_ptr->slist_len == slist_len); - HDassert(cache_ptr->slist_size == slist_size); -} +#if H5C_DO_SANITY_CHECKS + { + int32_t i; + uint32_t index_len = 0; + uint32_t slist_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + + HDassert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); + HDassert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); + HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + index_len += cache_ptr->index_ring_len[i]; + index_size += cache_ptr->index_ring_size[i]; + clean_index_size += cache_ptr->clean_index_ring_size[i]; + dirty_index_size += cache_ptr->dirty_index_ring_size[i]; + + slist_len += cache_ptr->slist_ring_len[i]; + slist_size += cache_ptr->slist_ring_size[i]; + } /* end for */ + + HDassert(cache_ptr->index_len == index_len); + HDassert(cache_ptr->index_size == index_size); + HDassert(cache_ptr->clean_index_size == clean_index_size); + HDassert(cache_ptr->dirty_index_size == dirty_index_size); + HDassert(cache_ptr->slist_len == slist_len); + HDassert(cache_ptr->slist_size == slist_size); + } #endif /* H5C_DO_SANITY_CHECKS */ - /* remove ageout markers if present */ - if(cache_ptr->epoch_markers_active > 0) - if(H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") - - /* flush invalidate each ring, starting from the outermost ring and - * working inward. - */ - ring = H5C_RING_USER; - while(ring < H5C_RING_NTYPES) { - if(H5C_flush_invalidate_ring(f, ring, flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush invalidate ring failed") - ring++; - } /* end while */ - - /* Invariants, after destroying all entries in the hash table */ - if(!(flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG)) { - HDassert(cache_ptr->index_size == 0); - HDassert(cache_ptr->clean_index_size == 0); - HDassert(cache_ptr->pel_len == 0); - HDassert(cache_ptr->pel_size == 0); - } /* end if */ - else { - H5C_cache_entry_t *entry_ptr; /* Cache entry */ - unsigned u; /* Local index variable */ - - /* All rings except ring 4 should be empty now */ - /* (Ring 4 has the superblock) */ - for(u = H5C_RING_USER; u < H5C_RING_SB; u++) { - HDassert(cache_ptr->index_ring_len[u] == 0); - HDassert(cache_ptr->index_ring_size[u] == 0); - HDassert(cache_ptr->clean_index_ring_size[u] == 0); - } /* end for */ - - /* Check that any remaining pinned entries are in the superblock ring */ - entry_ptr = cache_ptr->pel_head_ptr; - while(entry_ptr) { - /* Check ring */ - HDassert(entry_ptr->ring == H5C_RING_SB); + /* remove ageout markers if present */ + if (cache_ptr->epoch_markers_active > 0) + if (H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") - /* Advance to next entry in pinned entry list */ - entry_ptr = entry_ptr->next; + /* flush invalidate each ring, starting from the outermost ring and + * working inward. + */ + ring = H5C_RING_USER; + while (ring < H5C_RING_NTYPES) { + if (H5C_flush_invalidate_ring(f, ring, flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush invalidate ring failed") + ring++; } /* end while */ - } /* end else */ - HDassert(cache_ptr->dirty_index_size == 0); - HDassert(cache_ptr->slist_len == 0); - HDassert(cache_ptr->slist_size == 0); - HDassert(cache_ptr->pl_len == 0); - HDassert(cache_ptr->pl_size == 0); - HDassert(cache_ptr->LRU_list_len == 0); - HDassert(cache_ptr->LRU_list_size == 0); + + /* Invariants, after destroying all entries in the hash table */ + if (!(flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG)) { + HDassert(cache_ptr->index_size == 0); + HDassert(cache_ptr->clean_index_size == 0); + HDassert(cache_ptr->pel_len == 0); + HDassert(cache_ptr->pel_size == 0); + } /* end if */ + else { + H5C_cache_entry_t *entry_ptr; /* Cache entry */ + unsigned u; /* Local index variable */ + + /* All rings except ring 4 should be empty now */ + /* (Ring 4 has the superblock) */ + for (u = H5C_RING_USER; u < H5C_RING_SB; u++) { + HDassert(cache_ptr->index_ring_len[u] == 0); + HDassert(cache_ptr->index_ring_size[u] == 0); + HDassert(cache_ptr->clean_index_ring_size[u] == 0); + } /* end for */ + + /* Check that any remaining pinned entries are in the superblock ring */ + entry_ptr = cache_ptr->pel_head_ptr; + while (entry_ptr) { + /* Check ring */ + HDassert(entry_ptr->ring == H5C_RING_SB); + + /* Advance to next entry in pinned entry list */ + entry_ptr = entry_ptr->next; + } /* end while */ + } /* end else */ + HDassert(cache_ptr->dirty_index_size == 0); + HDassert(cache_ptr->slist_len == 0); + HDassert(cache_ptr->slist_size == 0); + HDassert(cache_ptr->pl_len == 0); + HDassert(cache_ptr->pl_size == 0); + HDassert(cache_ptr->LRU_list_len == 0); + HDassert(cache_ptr->LRU_list_size == 0); done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_invalidate_cache() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__flush_invalidate_cache() */ - -/*------------------------------------------------------------------------- - * Function: H5C_flush_invalidate_ring - * - * Purpose: Flush and destroy the entries contained in the target - * cache and ring. - * - * If the ring contains protected entries, the function will - * fail, as protected entries cannot be either flushed or - * destroyed. However all unprotected entries should be - * flushed and destroyed before the function returns failure. - * - * While pinned entries can usually be flushed, they cannot - * be destroyed. However, they should be unpinned when all - * the entries that reference them have been destroyed (thus - * reduding the pinned entry's reference count to 0, allowing - * it to be unpinned). - * - * If pinned entries are present, the function makes repeated - * passes through the cache, flushing all dirty entries - * (including the pinned dirty entries where permitted) and - * destroying all unpinned entries. This process is repeated - * until either the cache is empty, or the number of pinned - * entries stops decreasing on each pass. - * - * If flush dependencies appear in the target ring, the - * function makes repeated passes through the cache flushing - * entries in flush dependency order. - * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. - * - * Programmer: John Mainzer - * 9/1/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) -{ - H5C_t *cache_ptr; - hbool_t restart_slist_scan; - uint32_t protected_entries = 0; - int32_t i; - int32_t cur_ring_pel_len; - int32_t old_ring_pel_len; - unsigned cooked_flags; - unsigned evict_flags; - H5SL_node_t *node_ptr = NULL; - H5C_cache_entry_t *entry_ptr = NULL; - H5C_cache_entry_t *next_entry_ptr = NULL; + /*------------------------------------------------------------------------- + * Function: H5C_flush_invalidate_ring + * + * Purpose: Flush and destroy the entries contained in the target + * cache and ring. + * + * If the ring contains protected entries, the function will + * fail, as protected entries cannot be either flushed or + * destroyed. However all unprotected entries should be + * flushed and destroyed before the function returns failure. + * + * While pinned entries can usually be flushed, they cannot + * be destroyed. However, they should be unpinned when all + * the entries that reference them have been destroyed (thus + * reduding the pinned entry's reference count to 0, allowing + * it to be unpinned). + * + * If pinned entries are present, the function makes repeated + * passes through the cache, flushing all dirty entries + * (including the pinned dirty entries where permitted) and + * destroying all unpinned entries. This process is repeated + * until either the cache is empty, or the number of pinned + * entries stops decreasing on each pass. + * + * If flush dependencies appear in the target ring, the + * function makes repeated passes through the cache flushing + * entries in flush dependency order. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + * Programmer: John Mainzer + * 9/1/15 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) + { + H5C_t * cache_ptr; + hbool_t restart_slist_scan; + uint32_t protected_entries = 0; + int32_t i; + int32_t cur_ring_pel_len; + int32_t old_ring_pel_len; + unsigned cooked_flags; + unsigned evict_flags; + H5SL_node_t * node_ptr = NULL; + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *next_entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS - uint32_t initial_slist_len = 0; - size_t initial_slist_size = 0; + uint32_t initial_slist_len = 0; + size_t initial_slist_size = 0; #endif /* H5C_DO_SANITY_CHECKS */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(f); - HDassert(f->shared); - cache_ptr = f->shared->cache; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr->slist_ptr); - HDassert(ring > H5C_RING_UNDEFINED); - HDassert(ring < H5C_RING_NTYPES); + herr_t ret_value = SUCCEED; - HDassert(cache_ptr->epoch_markers_active == 0); + FUNC_ENTER_NOAPI(FAIL) - /* Filter out the flags that are not relevant to the flush/invalidate. - */ - cooked_flags = flags & H5C__FLUSH_CLEAR_ONLY_FLAG; - evict_flags = flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG; - - /* The flush procedure here is a bit strange. - * - * In the outer while loop we make at least one pass through the - * cache, and then repeat until either all the pinned entries in - * the ring unpin themselves, or until the number of pinned entries - * in the ring stops declining. In this later case, we scream and die. - * - * Since the fractal heap can dirty, resize, and/or move entries - * in is flush callback, it is possible that the cache will still - * contain dirty entries at this point. If so, we must make more - * passes through the skip list to allow it to empty. - * - * Further, since clean entries can be dirtied, resized, and/or moved - * as the result of a flush call back (either the entries own, or that - * for some other cache entry), we can no longer promise to flush - * the cache entries in increasing address order. - * - * Instead, we just do the best we can -- making a pass through - * the skip list, and then a pass through the "clean" entries, and - * then repeating as needed. Thus it is quite possible that an - * entry will be evicted from the cache only to be re-loaded later - * in the flush process (From what Quincey tells me, the pin - * mechanism makes this impossible, but even it it is true now, - * we shouldn't count on it in the future.) - * - * The bottom line is that entries will probably be flushed in close - * to increasing address order, but there are no guarantees. - */ - - /* compute the number of pinned entries in this ring */ - entry_ptr = cache_ptr->pel_head_ptr; - cur_ring_pel_len = 0; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring >= ring); - if(entry_ptr->ring == ring) - cur_ring_pel_len++; + HDassert(f); + HDassert(f->shared); + cache_ptr = f->shared->cache; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->slist_ptr); + HDassert(ring > H5C_RING_UNDEFINED); + HDassert(ring < H5C_RING_NTYPES); - entry_ptr = entry_ptr->next; - } /* end while */ + HDassert(cache_ptr->epoch_markers_active == 0); - old_ring_pel_len = cur_ring_pel_len; - while(cache_ptr->index_ring_len[ring] > 0) { - /* first, try to flush-destroy any dirty entries. Do this by - * making a scan through the slist. Note that new dirty entries - * may be created by the flush call backs. Thus it is possible - * that the slist will not be empty after we finish the scan. + /* Filter out the flags that are not relevant to the flush/invalidate. */ + cooked_flags = flags & H5C__FLUSH_CLEAR_ONLY_FLAG; + evict_flags = flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG; -#if H5C_DO_SANITY_CHECKS - /* Depending on circumstances, H5C__flush_single_entry() will - * remove dirty entries from the slist as it flushes them. - * Thus for sanity checks we must make note of the initial - * slist length and size before we do any flushes. - */ - initial_slist_len = cache_ptr->slist_len; - initial_slist_size = cache_ptr->slist_size; - - /* There is also the possibility that entries will be - * dirtied, resized, moved, and/or removed from the cache - * as the result of calls to the flush callbacks. We use - * the slist_len_increase and slist_size_increase increase - * fields in struct H5C_t to track these changes for purpose - * of sanity checking. + /* The flush procedure here is a bit strange. * - * To this end, we must zero these fields before we start - * the pass through the slist. - */ - cache_ptr->slist_len_increase = 0; - cache_ptr->slist_size_increase = 0; -#endif /* H5C_DO_SANITY_CHECKS */ - - /* Set the cache_ptr->slist_changed to false. + * In the outer while loop we make at least one pass through the + * cache, and then repeat until either all the pinned entries in + * the ring unpin themselves, or until the number of pinned entries + * in the ring stops declining. In this later case, we scream and die. + * + * Since the fractal heap can dirty, resize, and/or move entries + * in is flush callback, it is possible that the cache will still + * contain dirty entries at this point. If so, we must make more + * passes through the skip list to allow it to empty. * - * This flag is set to TRUE by H5C__flush_single_entry if the slist - * is modified by a pre_serialize, serialize, or notify callback. + * Further, since clean entries can be dirtied, resized, and/or moved + * as the result of a flush call back (either the entries own, or that + * for some other cache entry), we can no longer promise to flush + * the cache entries in increasing address order. * - * H5C_flush_invalidate_ring() uses this flag to detect any - * modifications to the slist that might corrupt the scan of - * the slist -- and restart the scan in this event. + * Instead, we just do the best we can -- making a pass through + * the skip list, and then a pass through the "clean" entries, and + * then repeating as needed. Thus it is quite possible that an + * entry will be evicted from the cache only to be re-loaded later + * in the flush process (From what Quincey tells me, the pin + * mechanism makes this impossible, but even it it is true now, + * we shouldn't count on it in the future.) + * + * The bottom line is that entries will probably be flushed in close + * to increasing address order, but there are no guarantees. */ - cache_ptr->slist_changed = FALSE; - - /* this done, start the scan of the slist */ - restart_slist_scan = TRUE; - while(restart_slist_scan || (node_ptr != NULL)) { - if(restart_slist_scan) { - restart_slist_scan = FALSE; - - /* Start at beginning of skip list */ - node_ptr = H5SL_first(cache_ptr->slist_ptr); - if(node_ptr == NULL) - /* the slist is empty -- break out of inner loop */ - break; - - /* Get cache entry for this node */ - next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if(NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") - HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(next_entry_ptr->is_dirty); - HDassert(next_entry_ptr->in_slist); - HDassert(next_entry_ptr->ring >= ring); - } /* end if */ + /* compute the number of pinned entries in this ring */ + entry_ptr = cache_ptr->pel_head_ptr; + cur_ring_pel_len = 0; + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring >= ring); + if (entry_ptr->ring == ring) + cur_ring_pel_len++; - entry_ptr = next_entry_ptr; + entry_ptr = entry_ptr->next; + } /* end while */ - /* It is possible that entries will be dirtied, resized, - * flushed, or removed from the cache via the take ownership - * flag as the result of pre_serialize or serialized callbacks. - * - * This in turn can corrupt the scan through the slist. - * - * We test for slist modifications in the pre_serialize - * and serialize callbacks, and restart the scan of the - * slist if we find them. However, best we do some extra - * sanity checking just in case. + old_ring_pel_len = cur_ring_pel_len; + while (cache_ptr->index_ring_len[ring] > 0) { + /* first, try to flush-destroy any dirty entries. Do this by + * making a scan through the slist. Note that new dirty entries + * may be created by the flush call backs. Thus it is possible + * that the slist will not be empty after we finish the scan. */ - HDassert(entry_ptr != NULL); - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->in_slist); - HDassert(entry_ptr->is_dirty); - HDassert(entry_ptr->ring >= ring); - /* increment node pointer now, before we delete its target - * from the slist. +#if H5C_DO_SANITY_CHECKS + /* Depending on circumstances, H5C__flush_single_entry() will + * remove dirty entries from the slist as it flushes them. + * Thus for sanity checks we must make note of the initial + * slist length and size before we do any flushes. */ - node_ptr = H5SL_next(node_ptr); - if(node_ptr != NULL) { - next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if(NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") - HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(next_entry_ptr->is_dirty); - HDassert(next_entry_ptr->in_slist); - HDassert(next_entry_ptr->ring >= ring); - HDassert(entry_ptr != next_entry_ptr); - } /* end if */ - else - next_entry_ptr = NULL; + initial_slist_len = cache_ptr->slist_len; + initial_slist_size = cache_ptr->slist_size; + + /* There is also the possibility that entries will be + * dirtied, resized, moved, and/or removed from the cache + * as the result of calls to the flush callbacks. We use + * the slist_len_increase and slist_size_increase increase + * fields in struct H5C_t to track these changes for purpose + * of sanity checking. + * + * To this end, we must zero these fields before we start + * the pass through the slist. + */ + cache_ptr->slist_len_increase = 0; + cache_ptr->slist_size_increase = 0; +#endif /* H5C_DO_SANITY_CHECKS */ - /* Note that we now remove nodes from the slist as we flush - * the associated entries, instead of leaving them there - * until we are done, and then destroying all nodes in - * the slist. + /* Set the cache_ptr->slist_changed to false. * - * While this optimization used to be easy, with the possibility - * of new entries being added to the slist in the midst of the - * flush, we must keep the slist in canonical form at all - * times. + * This flag is set to TRUE by H5C__flush_single_entry if the slist + * is modified by a pre_serialize, serialize, or notify callback. + * + * H5C_flush_invalidate_ring() uses this flag to detect any + * modifications to the slist that might corrupt the scan of + * the slist -- and restart the scan in this event. */ - if(((!entry_ptr->flush_me_last) || - ((entry_ptr->flush_me_last) && - (cache_ptr->num_last_entries >= cache_ptr->slist_len))) && - (entry_ptr->flush_dep_nchildren == 0) && - (entry_ptr->ring == ring)) { - if(entry_ptr->is_protected) { - /* we have major problems -- but lets flush - * everything we can before we flag an error. - */ - protected_entries++; + cache_ptr->slist_changed = FALSE; + + /* this done, start the scan of the slist */ + restart_slist_scan = TRUE; + while (restart_slist_scan || (node_ptr != NULL)) { + if (restart_slist_scan) { + restart_slist_scan = FALSE; + + /* Start at beginning of skip list */ + node_ptr = H5SL_first(cache_ptr->slist_ptr); + if (node_ptr == NULL) + /* the slist is empty -- break out of inner loop */ + break; + + /* Get cache entry for this node */ + next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + if (NULL == next_entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") + + HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(next_entry_ptr->is_dirty); + HDassert(next_entry_ptr->in_slist); + HDassert(next_entry_ptr->ring >= ring); } /* end if */ - else if(entry_ptr->is_pinned) { - if(H5C__flush_single_entry(f, entry_ptr, H5C__DURING_FLUSH_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty pinned entry flush failed") - - if(cache_ptr->slist_changed) { - /* The slist has been modified by something - * other than the simple removal of the - * of the flushed entry after the flush. - * - * This has the potential to corrupt the - * scan through the slist, so restart it. - */ - restart_slist_scan = TRUE; - cache_ptr->slist_changed = FALSE; - H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr); - } /* end if */ - } /* end else-if */ - else { - if(H5C__flush_single_entry(f, entry_ptr, (cooked_flags | H5C__DURING_FLUSH_FLAG | H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty entry flush destroy failed") - if(cache_ptr->slist_changed) { - /* The slist has been modified by something - * other than the simple removal of the - * of the flushed entry after the flush. - * - * This has the potential to corrupt the - * scan through the slist, so restart it. + entry_ptr = next_entry_ptr; + + /* It is possible that entries will be dirtied, resized, + * flushed, or removed from the cache via the take ownership + * flag as the result of pre_serialize or serialized callbacks. + * + * This in turn can corrupt the scan through the slist. + * + * We test for slist modifications in the pre_serialize + * and serialize callbacks, and restart the scan of the + * slist if we find them. However, best we do some extra + * sanity checking just in case. + */ + HDassert(entry_ptr != NULL); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->in_slist); + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->ring >= ring); + + /* increment node pointer now, before we delete its target + * from the slist. + */ + node_ptr = H5SL_next(node_ptr); + if (node_ptr != NULL) { + next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + if (NULL == next_entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") + HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(next_entry_ptr->is_dirty); + HDassert(next_entry_ptr->in_slist); + HDassert(next_entry_ptr->ring >= ring); + HDassert(entry_ptr != next_entry_ptr); + } /* end if */ + else + next_entry_ptr = NULL; + + /* Note that we now remove nodes from the slist as we flush + * the associated entries, instead of leaving them there + * until we are done, and then destroying all nodes in + * the slist. + * + * While this optimization used to be easy, with the possibility + * of new entries being added to the slist in the midst of the + * flush, we must keep the slist in canonical form at all + * times. + */ + if (((!entry_ptr->flush_me_last) || + ((entry_ptr->flush_me_last) && (cache_ptr->num_last_entries >= cache_ptr->slist_len))) && + (entry_ptr->flush_dep_nchildren == 0) && (entry_ptr->ring == ring)) { + if (entry_ptr->is_protected) { + /* we have major problems -- but lets flush + * everything we can before we flag an error. */ - restart_slist_scan = TRUE; - cache_ptr->slist_changed = FALSE; - H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) + protected_entries++; } /* end if */ - } /* end else */ - } /* end if */ - } /* end while loop scanning skip list */ + else if (entry_ptr->is_pinned) { + if (H5C__flush_single_entry(f, entry_ptr, H5C__DURING_FLUSH_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty pinned entry flush failed") + + if (cache_ptr->slist_changed) { + /* The slist has been modified by something + * other than the simple removal of the + * of the flushed entry after the flush. + * + * This has the potential to corrupt the + * scan through the slist, so restart it. + */ + restart_slist_scan = TRUE; + cache_ptr->slist_changed = FALSE; + H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr); + } /* end if */ + } /* end else-if */ + else { + if (H5C__flush_single_entry(f, entry_ptr, + (cooked_flags | H5C__DURING_FLUSH_FLAG | + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty entry flush destroy failed") + + if (cache_ptr->slist_changed) { + /* The slist has been modified by something + * other than the simple removal of the + * of the flushed entry after the flush. + * + * This has the potential to corrupt the + * scan through the slist, so restart it. + */ + restart_slist_scan = TRUE; + cache_ptr->slist_changed = FALSE; + H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) + } /* end if */ + } /* end else */ + } /* end if */ + } /* end while loop scanning skip list */ #if H5C_DO_SANITY_CHECKS - /* It is possible that entries were added to the slist during - * the scan, either before or after scan pointer. The following - * asserts take this into account. - * - * Don't bother with the sanity checks if node_ptr != NULL, as - * in this case we broke out of the loop because it got changed - * out from under us. - */ + /* It is possible that entries were added to the slist during + * the scan, either before or after scan pointer. The following + * asserts take this into account. + * + * Don't bother with the sanity checks if node_ptr != NULL, as + * in this case we broke out of the loop because it got changed + * out from under us. + */ - if(node_ptr == NULL) { - HDassert(cache_ptr->slist_len == (uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase)); - HDassert(cache_ptr->slist_size == (size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase)); - } /* end if */ -#endif /* H5C_DO_SANITY_CHECKS */ - - /* Since we are doing a destroy, we must make a pass through - * the hash table and try to flush - destroy all entries that - * remain. - * - * It used to be that all entries remaining in the cache at - * this point had to be clean, but with the fractal heap mods - * this may not be the case. If so, we will flush entries out - * in increasing address order. - * - * Writes to disk are possible here. - */ + if (node_ptr == NULL) { + HDassert(cache_ptr->slist_len == + (uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase)); + HDassert(cache_ptr->slist_size == + (size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase)); + } /* end if */ +#endif /* H5C_DO_SANITY_CHECKS */ - /* reset the counters so that we can detect insertions, loads, - * and moves caused by the pre_serialize and serialize calls. - */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + /* Since we are doing a destroy, we must make a pass through + * the hash table and try to flush - destroy all entries that + * remain. + * + * It used to be that all entries remaining in the cache at + * this point had to be clean, but with the fractal heap mods + * this may not be the case. If so, we will flush entries out + * in increasing address order. + * + * Writes to disk are possible here. + */ - next_entry_ptr = cache_ptr->il_head; - while(next_entry_ptr != NULL) { - entry_ptr = next_entry_ptr; - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring >= ring); + /* reset the counters so that we can detect insertions, loads, + * and moves caused by the pre_serialize and serialize calls. + */ + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + + next_entry_ptr = cache_ptr->il_head; + while (next_entry_ptr != NULL) { + entry_ptr = next_entry_ptr; + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring >= ring); - next_entry_ptr = entry_ptr->il_next; - HDassert((next_entry_ptr == NULL) || - (next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC)); + next_entry_ptr = entry_ptr->il_next; + HDassert((next_entry_ptr == NULL) || (next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC)); - if((!entry_ptr->flush_me_last || (entry_ptr->flush_me_last && cache_ptr->num_last_entries >= cache_ptr->slist_len)) - && entry_ptr->flush_dep_nchildren == 0 && entry_ptr->ring == ring) { - if(entry_ptr->is_protected) { - /* we have major problems -- but lets flush and - * destroy everything we can before we flag an - * error. - */ - protected_entries++; - if(!entry_ptr->in_slist) - HDassert(!(entry_ptr->is_dirty)); - } /* end if */ - else if(!(entry_ptr->is_pinned)) { - /* if *entry_ptr is dirty, it is possible - * that one or more other entries may be - * either removed from the cache, loaded - * into the cache, or moved to a new location - * in the file as a side effect of the flush. - * - * It's also possible that removing a clean - * entry will remove the last child of a proxy - * entry, allowing it to be removed also and - * invalidating the next_entry_ptr. - * - * If either of these happen, and one of the target - * or proxy entries happens to be the next entry in - * the hash bucket, we could either find ourselves - * either scanning a non-existant entry, scanning - * through a different bucket, or skipping an entry. - * - * Neither of these are good, so restart the - * the scan at the head of the hash bucket - * after the flush if we detect that the next_entry_ptr - * becomes invalid. - * - * This is not as inefficient at it might seem, - * as hash buckets typically have at most two - * or three entries. - */ - cache_ptr->entry_watched_for_removal = next_entry_ptr; - - if(H5C__flush_single_entry(f, entry_ptr, (cooked_flags | H5C__DURING_FLUSH_FLAG | H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Entry flush destroy failed") - - /* Restart the index list scan if necessary. Must - * do this if the next entry is evicted, and also if - * one or more entries are inserted, loaded, or moved - * as these operations can result in part of the scan - * being skipped -- which can cause a spurious failure - * if this results in the size of the pinned entry - * failing to decline during the pass. - */ - if((NULL != next_entry_ptr && NULL == cache_ptr->entry_watched_for_removal) - || (cache_ptr->entries_loaded_counter > 0) - || (cache_ptr->entries_inserted_counter > 0) - || (cache_ptr->entries_relocated_counter > 0)) { + if ((!entry_ptr->flush_me_last || + (entry_ptr->flush_me_last && cache_ptr->num_last_entries >= cache_ptr->slist_len)) && + entry_ptr->flush_dep_nchildren == 0 && entry_ptr->ring == ring) { + if (entry_ptr->is_protected) { + /* we have major problems -- but lets flush and + * destroy everything we can before we flag an + * error. + */ + protected_entries++; + if (!entry_ptr->in_slist) + HDassert(!(entry_ptr->is_dirty)); + } /* end if */ + else if (!(entry_ptr->is_pinned)) { + /* if *entry_ptr is dirty, it is possible + * that one or more other entries may be + * either removed from the cache, loaded + * into the cache, or moved to a new location + * in the file as a side effect of the flush. + * + * It's also possible that removing a clean + * entry will remove the last child of a proxy + * entry, allowing it to be removed also and + * invalidating the next_entry_ptr. + * + * If either of these happen, and one of the target + * or proxy entries happens to be the next entry in + * the hash bucket, we could either find ourselves + * either scanning a non-existant entry, scanning + * through a different bucket, or skipping an entry. + * + * Neither of these are good, so restart the + * the scan at the head of the hash bucket + * after the flush if we detect that the next_entry_ptr + * becomes invalid. + * + * This is not as inefficient at it might seem, + * as hash buckets typically have at most two + * or three entries. + */ + cache_ptr->entry_watched_for_removal = next_entry_ptr; + + if (H5C__flush_single_entry(f, entry_ptr, + (cooked_flags | H5C__DURING_FLUSH_FLAG | + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Entry flush destroy failed") + + /* Restart the index list scan if necessary. Must + * do this if the next entry is evicted, and also if + * one or more entries are inserted, loaded, or moved + * as these operations can result in part of the scan + * being skipped -- which can cause a spurious failure + * if this results in the size of the pinned entry + * failing to decline during the pass. + */ + if ((NULL != next_entry_ptr && NULL == cache_ptr->entry_watched_for_removal) || + (cache_ptr->entries_loaded_counter > 0) || + (cache_ptr->entries_inserted_counter > 0) || + (cache_ptr->entries_relocated_counter > 0)) { - next_entry_ptr = cache_ptr->il_head; + next_entry_ptr = cache_ptr->il_head; - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; - H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) + H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) + } /* end if */ + else + cache_ptr->entry_watched_for_removal = NULL; } /* end if */ - else - cache_ptr->entry_watched_for_removal = NULL; - } /* end if */ - } /* end if */ - } /* end for loop scanning hash table */ - - /* We can't do anything if entries are pinned. The - * hope is that the entries will be unpinned as the - * result of destroys of entries that reference them. - * - * We detect this by noting the change in the number - * of pinned entries from pass to pass. If it stops - * shrinking before it hits zero, we scream and die. - */ - old_ring_pel_len = cur_ring_pel_len; - entry_ptr = cache_ptr->pel_head_ptr; - cur_ring_pel_len = 0; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring >= ring); + } /* end if */ + } /* end for loop scanning hash table */ - if(entry_ptr->ring == ring) - cur_ring_pel_len++; + /* We can't do anything if entries are pinned. The + * hope is that the entries will be unpinned as the + * result of destroys of entries that reference them. + * + * We detect this by noting the change in the number + * of pinned entries from pass to pass. If it stops + * shrinking before it hits zero, we scream and die. + */ + old_ring_pel_len = cur_ring_pel_len; + entry_ptr = cache_ptr->pel_head_ptr; + cur_ring_pel_len = 0; + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring >= ring); - entry_ptr = entry_ptr->next; - } /* end while */ + if (entry_ptr->ring == ring) + cur_ring_pel_len++; - /* Check if the number of pinned entries in the ring is positive, and - * it is not declining. Scream and die if so. - */ - if(cur_ring_pel_len > 0 && cur_ring_pel_len >= old_ring_pel_len) { - /* Don't error if allowed to have pinned entries remaining */ - if(evict_flags) - HGOTO_DONE(TRUE) + entry_ptr = entry_ptr->next; + } /* end while */ - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Pinned entry count not decreasing, cur_ring_pel_len = %d, old_ring_pel_len = %d, ring = %d", (int)cur_ring_pel_len, (int)old_ring_pel_len, (int)ring) - } /* end if */ + /* Check if the number of pinned entries in the ring is positive, and + * it is not declining. Scream and die if so. + */ + if (cur_ring_pel_len > 0 && cur_ring_pel_len >= old_ring_pel_len) { + /* Don't error if allowed to have pinned entries remaining */ + if (evict_flags) + HGOTO_DONE(TRUE) + + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, + "Pinned entry count not decreasing, cur_ring_pel_len = %d, old_ring_pel_len = " + "%d, ring = %d", + (int)cur_ring_pel_len, (int)old_ring_pel_len, (int)ring) + } /* end if */ - HDassert(protected_entries == cache_ptr->pl_len); + HDassert(protected_entries == cache_ptr->pl_len); - if(protected_entries > 0 && protected_entries == cache_ptr->index_len) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Only protected entries left in cache, protected_entries = %d", (int)protected_entries) - } /* main while loop */ + if (protected_entries > 0 && protected_entries == cache_ptr->index_len) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, + "Only protected entries left in cache, protected_entries = %d", + (int)protected_entries) + } /* main while loop */ - /* Invariants, after destroying all entries in the ring */ - for(i = (int)H5C_RING_UNDEFINED; i <= (int)ring; i++) { - HDassert(cache_ptr->index_ring_len[i] == 0); - HDassert(cache_ptr->index_ring_size[i] == (size_t)0); - HDassert(cache_ptr->clean_index_ring_size[i] == (size_t)0); - HDassert(cache_ptr->dirty_index_ring_size[i] == (size_t)0); + /* Invariants, after destroying all entries in the ring */ + for (i = (int)H5C_RING_UNDEFINED; i <= (int)ring; i++) { + HDassert(cache_ptr->index_ring_len[i] == 0); + HDassert(cache_ptr->index_ring_size[i] == (size_t)0); + HDassert(cache_ptr->clean_index_ring_size[i] == (size_t)0); + HDassert(cache_ptr->dirty_index_ring_size[i] == (size_t)0); - HDassert(cache_ptr->slist_ring_len[i] == 0); - HDassert(cache_ptr->slist_ring_size[i] == (size_t)0); - } /* end for */ + HDassert(cache_ptr->slist_ring_len[i] == 0); + HDassert(cache_ptr->slist_ring_size[i] == (size_t)0); + } /* end for */ - HDassert(protected_entries <= cache_ptr->pl_len); + HDassert(protected_entries <= cache_ptr->pl_len); - if(protected_entries > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cache has protected entries") - else if(cur_ring_pel_len > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't unpin all pinned entries in ring") + if (protected_entries > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cache has protected entries") + else if (cur_ring_pel_len > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't unpin all pinned entries in ring") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_flush_invalidate_ring() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_flush_invalidate_ring() */ - -/*------------------------------------------------------------------------- - * Function: H5C__flush_ring - * - * Purpose: Flush the entries contained in the specified cache and - * ring. All entries in rings outside the specified ring - * must have been flushed on entry. - * - * If the cache contains protected entries in the specified - * ring, the function will fail, as protected entries cannot - * be flushed. However all unprotected entries in the target - * ring should be flushed before the function returns failure. - * - * If flush dependencies appear in the target ring, the - * function makes repeated passes through the slist flushing - * entries in flush dependency order. - * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. - * - * Programmer: John Mainzer - * 9/1/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) -{ - H5C_t * cache_ptr = f->shared->cache; - hbool_t flushed_entries_last_pass; - hbool_t flush_marked_entries; - hbool_t ignore_protected; - hbool_t tried_to_flush_protected_entry = FALSE; - hbool_t restart_slist_scan; - uint32_t protected_entries = 0; - H5SL_node_t * node_ptr = NULL; - H5C_cache_entry_t * entry_ptr = NULL; - H5C_cache_entry_t * next_entry_ptr = NULL; + /*------------------------------------------------------------------------- + * Function: H5C__flush_ring + * + * Purpose: Flush the entries contained in the specified cache and + * ring. All entries in rings outside the specified ring + * must have been flushed on entry. + * + * If the cache contains protected entries in the specified + * ring, the function will fail, as protected entries cannot + * be flushed. However all unprotected entries in the target + * ring should be flushed before the function returns failure. + * + * If flush dependencies appear in the target ring, the + * function makes repeated passes through the slist flushing + * entries in flush dependency order. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + * Programmer: John Mainzer + * 9/1/15 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__flush_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) + { + H5C_t * cache_ptr = f->shared->cache; + hbool_t flushed_entries_last_pass; + hbool_t flush_marked_entries; + hbool_t ignore_protected; + hbool_t tried_to_flush_protected_entry = FALSE; + hbool_t restart_slist_scan; + uint32_t protected_entries = 0; + H5SL_node_t * node_ptr = NULL; + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *next_entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS - uint32_t initial_slist_len = 0; - size_t initial_slist_size = 0; + uint32_t initial_slist_len = 0; + size_t initial_slist_size = 0; #endif /* H5C_DO_SANITY_CHECKS */ - int i; - herr_t ret_value = SUCCEED; + int i; + herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr->slist_ptr); - HDassert((flags & H5C__FLUSH_INVALIDATE_FLAG) == 0); - HDassert(ring > H5C_RING_UNDEFINED); - HDassert(ring < H5C_RING_NTYPES); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->slist_ptr); + HDassert((flags & H5C__FLUSH_INVALIDATE_FLAG) == 0); + HDassert(ring > H5C_RING_UNDEFINED); + HDassert(ring < H5C_RING_NTYPES); #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - ignore_protected = ( (flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0 ); - flush_marked_entries = ( (flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) != 0 ); + ignore_protected = ((flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0); + flush_marked_entries = ((flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) != 0); - if(!flush_marked_entries) - for(i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++) - HDassert(cache_ptr->slist_ring_len[i] == 0); + if (!flush_marked_entries) + for (i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++) + HDassert(cache_ptr->slist_ring_len[i] == 0); - HDassert(cache_ptr->flush_in_progress); + HDassert(cache_ptr->flush_in_progress); - /* When we are only flushing marked entries, the slist will usually - * still contain entries when we have flushed everything we should. - * Thus we track whether we have flushed any entries in the last - * pass, and terminate if we haven't. - */ - flushed_entries_last_pass = TRUE; + /* When we are only flushing marked entries, the slist will usually + * still contain entries when we have flushed everything we should. + * Thus we track whether we have flushed any entries in the last + * pass, and terminate if we haven't. + */ + flushed_entries_last_pass = TRUE; - /* Set the cache_ptr->slist_changed to false. - * - * This flag is set to TRUE by H5C__flush_single_entry if the - * slist is modified by a pre_serialize, serialize, or notify callback. - * H5C_flush_cache uses this flag to detect any modifications - * to the slist that might corrupt the scan of the slist -- and - * restart the scan in this event. - */ - cache_ptr->slist_changed = FALSE; + /* Set the cache_ptr->slist_changed to false. + * + * This flag is set to TRUE by H5C__flush_single_entry if the + * slist is modified by a pre_serialize, serialize, or notify callback. + * H5C_flush_cache uses this flag to detect any modifications + * to the slist that might corrupt the scan of the slist -- and + * restart the scan in this event. + */ + cache_ptr->slist_changed = FALSE; - while((cache_ptr->slist_ring_len[ring] > 0) && - (protected_entries == 0) && - (flushed_entries_last_pass)) { - flushed_entries_last_pass = FALSE; + while ((cache_ptr->slist_ring_len[ring] > 0) && (protected_entries == 0) && + (flushed_entries_last_pass)) { + flushed_entries_last_pass = FALSE; #if H5C_DO_SANITY_CHECKS - /* For sanity checking, try to verify that the skip list has - * the expected size and number of entries at the end of each - * internal while loop (see below). - * - * Doing this get a bit tricky, as depending on flags, we may - * or may not flush all the entries in the slist. - * - * To make things more entertaining, with the advent of the - * fractal heap, the entry serialize callback can cause entries - * to be dirtied, resized, and/or moved. Also, the - * pre_serialize callback can result in an entry being - * removed from the cache via the take ownership flag. - * - * To deal with this, we first make note of the initial - * skip list length and size: - */ - initial_slist_len = cache_ptr->slist_len; - initial_slist_size = cache_ptr->slist_size; - - /* As mentioned above, there is the possibility that - * entries will be dirtied, resized, flushed, or removed - * from the cache via the take ownership flag during - * our pass through the skip list. To capture the number - * of entries added, and the skip list size delta, - * zero the slist_len_increase and slist_size_increase of - * the cache's instance of H5C_t. These fields will be - * updated elsewhere to account for slist insertions and/or - * dirty entry size changes. - */ - cache_ptr->slist_len_increase = 0; - cache_ptr->slist_size_increase = 0; + /* For sanity checking, try to verify that the skip list has + * the expected size and number of entries at the end of each + * internal while loop (see below). + * + * Doing this get a bit tricky, as depending on flags, we may + * or may not flush all the entries in the slist. + * + * To make things more entertaining, with the advent of the + * fractal heap, the entry serialize callback can cause entries + * to be dirtied, resized, and/or moved. Also, the + * pre_serialize callback can result in an entry being + * removed from the cache via the take ownership flag. + * + * To deal with this, we first make note of the initial + * skip list length and size: + */ + initial_slist_len = cache_ptr->slist_len; + initial_slist_size = cache_ptr->slist_size; + + /* As mentioned above, there is the possibility that + * entries will be dirtied, resized, flushed, or removed + * from the cache via the take ownership flag during + * our pass through the skip list. To capture the number + * of entries added, and the skip list size delta, + * zero the slist_len_increase and slist_size_increase of + * the cache's instance of H5C_t. These fields will be + * updated elsewhere to account for slist insertions and/or + * dirty entry size changes. + */ + cache_ptr->slist_len_increase = 0; + cache_ptr->slist_size_increase = 0; - /* at the end of the loop, use these values to compute the - * expected slist length and size and compare this with the - * value recorded in the cache's instance of H5C_t. - */ + /* at the end of the loop, use these values to compute the + * expected slist length and size and compare this with the + * value recorded in the cache's instance of H5C_t. + */ #endif /* H5C_DO_SANITY_CHECKS */ - restart_slist_scan = TRUE; + restart_slist_scan = TRUE; - while((restart_slist_scan ) || (node_ptr != NULL)) { - if(restart_slist_scan) { - restart_slist_scan = FALSE; + while ((restart_slist_scan) || (node_ptr != NULL)) { + if (restart_slist_scan) { + restart_slist_scan = FALSE; - /* Start at beginning of skip list */ - node_ptr = H5SL_first(cache_ptr->slist_ptr); + /* Start at beginning of skip list */ + node_ptr = H5SL_first(cache_ptr->slist_ptr); - if(node_ptr == NULL) - /* the slist is empty -- break out of inner loop */ - break; + if (node_ptr == NULL) + /* the slist is empty -- break out of inner loop */ + break; - /* Get cache entry for this node */ - next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + /* Get cache entry for this node */ + next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if(NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") + if (NULL == next_entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") - HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(next_entry_ptr->is_dirty); - HDassert(next_entry_ptr->in_slist); - } /* end if */ + HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(next_entry_ptr->is_dirty); + HDassert(next_entry_ptr->in_slist); + } /* end if */ - entry_ptr = next_entry_ptr; + entry_ptr = next_entry_ptr; + + /* With the advent of the fractal heap, the free space + * manager, and the version 3 cache, it is possible + * that the pre-serialize or serialize callback will + * dirty, resize, or take ownership of other entries + * in the cache. + * + * To deal with this, I have inserted code to detect any + * change in the skip list not directly under the control + * of this function. If such modifications are detected, + * we must re-start the scan of the skip list to avoid + * the possibility that the target of the next_entry_ptr + * may have been flushed or deleted from the cache. + * + * To verify that all such possibilities have been dealt + * with, we do a bit of extra sanity checking on + * entry_ptr. + */ + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->in_slist); + HDassert(entry_ptr->is_dirty); + if (!flush_marked_entries || entry_ptr->flush_marker) + HDassert(entry_ptr->ring >= ring); + + /* Advance node pointer now, before we delete its target + * from the slist. + */ + node_ptr = H5SL_next(node_ptr); + if (node_ptr != NULL) { + next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + if (NULL == next_entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") - /* With the advent of the fractal heap, the free space - * manager, and the version 3 cache, it is possible - * that the pre-serialize or serialize callback will - * dirty, resize, or take ownership of other entries - * in the cache. - * - * To deal with this, I have inserted code to detect any - * change in the skip list not directly under the control - * of this function. If such modifications are detected, - * we must re-start the scan of the skip list to avoid - * the possibility that the target of the next_entry_ptr - * may have been flushed or deleted from the cache. - * - * To verify that all such possibilities have been dealt - * with, we do a bit of extra sanity checking on - * entry_ptr. - */ - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->in_slist); - HDassert(entry_ptr->is_dirty); - if(!flush_marked_entries || entry_ptr->flush_marker) - HDassert(entry_ptr->ring >= ring); + HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(next_entry_ptr->is_dirty); + HDassert(next_entry_ptr->in_slist); - /* Advance node pointer now, before we delete its target - * from the slist. - */ - node_ptr = H5SL_next(node_ptr); - if(node_ptr != NULL) { - next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if(NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") + if (!flush_marked_entries || next_entry_ptr->flush_marker) + HDassert(next_entry_ptr->ring >= ring); - HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(next_entry_ptr->is_dirty); - HDassert(next_entry_ptr->in_slist); + HDassert(entry_ptr != next_entry_ptr); + } /* end if */ + else + next_entry_ptr = NULL; - if(!flush_marked_entries || next_entry_ptr->flush_marker) - HDassert(next_entry_ptr->ring >= ring); + if ((!flush_marked_entries || entry_ptr->flush_marker) && + (!entry_ptr->flush_me_last || + (entry_ptr->flush_me_last && (cache_ptr->num_last_entries >= cache_ptr->slist_len || + (flush_marked_entries && entry_ptr->flush_marker)))) && + (entry_ptr->flush_dep_nchildren == 0 || entry_ptr->flush_dep_ndirty_children == 0) && + entry_ptr->ring == ring) { - HDassert(entry_ptr != next_entry_ptr); - } /* end if */ - else - next_entry_ptr = NULL; - - if((!flush_marked_entries || entry_ptr->flush_marker) - && (!entry_ptr->flush_me_last || - (entry_ptr->flush_me_last - && (cache_ptr->num_last_entries >= cache_ptr->slist_len - || (flush_marked_entries && entry_ptr->flush_marker)))) - && (entry_ptr->flush_dep_nchildren == 0 - || entry_ptr->flush_dep_ndirty_children == 0) - && entry_ptr->ring == ring) { - - HDassert(entry_ptr->flush_dep_nunser_children == 0); - - if(entry_ptr->is_protected) { - /* we probably have major problems -- but lets - * flush everything we can before we decide - * whether to flag an error. - */ - tried_to_flush_protected_entry = TRUE; - protected_entries++; - } /* end if */ - else { - if(H5C__flush_single_entry(f, entry_ptr, (flags | H5C__DURING_FLUSH_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry") + HDassert(entry_ptr->flush_dep_nunser_children == 0); - if(cache_ptr->slist_changed) { - /* The slist has been modified by something - * other than the simple removal of the - * of the flushed entry after the flush. - * - * This has the potential to corrupt the - * scan through the slist, so restart it. + if (entry_ptr->is_protected) { + /* we probably have major problems -- but lets + * flush everything we can before we decide + * whether to flag an error. */ - restart_slist_scan = TRUE; - cache_ptr->slist_changed = FALSE; - H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) + tried_to_flush_protected_entry = TRUE; + protected_entries++; } /* end if */ + else { + if (H5C__flush_single_entry(f, entry_ptr, (flags | H5C__DURING_FLUSH_FLAG)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry") - flushed_entries_last_pass = TRUE; - } /* end else */ - } /* end if */ - } /* while ( ( restart_slist_scan ) || ( node_ptr != NULL ) ) */ + if (cache_ptr->slist_changed) { + /* The slist has been modified by something + * other than the simple removal of the + * of the flushed entry after the flush. + * + * This has the potential to corrupt the + * scan through the slist, so restart it. + */ + restart_slist_scan = TRUE; + cache_ptr->slist_changed = FALSE; + H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) + } /* end if */ + + flushed_entries_last_pass = TRUE; + } /* end else */ + } /* end if */ + } /* while ( ( restart_slist_scan ) || ( node_ptr != NULL ) ) */ #if H5C_DO_SANITY_CHECKS - /* Verify that the slist size and length are as expected. */ - HDassert((uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase) == cache_ptr->slist_len); - HDassert((size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase) == cache_ptr->slist_size); -#endif /* H5C_DO_SANITY_CHECKS */ - } /* while */ + /* Verify that the slist size and length are as expected. */ + HDassert((uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase) == + cache_ptr->slist_len); + HDassert((size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase) == + cache_ptr->slist_size); +#endif /* H5C_DO_SANITY_CHECKS */ + } /* while */ - HDassert(protected_entries <= cache_ptr->pl_len); + HDassert(protected_entries <= cache_ptr->pl_len); - if(((cache_ptr->pl_len > 0) && (!ignore_protected)) || (tried_to_flush_protected_entry)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "cache has protected items") + if (((cache_ptr->pl_len > 0) && (!ignore_protected)) || (tried_to_flush_protected_entry)) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "cache has protected items") #if H5C_DO_SANITY_CHECKS - if(!flush_marked_entries) { - HDassert(cache_ptr->slist_ring_len[ring] == 0); - HDassert(cache_ptr->slist_ring_size[ring] == 0); - } /* end if */ -#endif /* H5C_DO_SANITY_CHECKS */ + if (!flush_marked_entries) { + HDassert(cache_ptr->slist_ring_len[ring] == 0); + HDassert(cache_ptr->slist_ring_size[ring] == 0); + } /* end if */ +#endif /* H5C_DO_SANITY_CHECKS */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_ring() */ - - -/*------------------------------------------------------------------------- - * - * Function: H5C__flush_single_entry - * - * Purpose: Flush or clear (and evict if requested) the cache entry - * with the specified address and type. If the type is NULL, - * any unprotected entry at the specified address will be - * flushed (and possibly evicted). - * - * Attempts to flush a protected entry will result in an - * error. - * - * If the H5C__FLUSH_INVALIDATE_FLAG flag is set, the entry will - * be cleared and not flushed, and the call can't be part of a - * sequence of flushes. - * - * If the caller knows the address of the skip list node at - * which the target entry resides, it can avoid a lookup - * by supplying that address in the tgt_node_ptr parameter. - * If this parameter is NULL, the function will do a skip list - * search for the entry instead. - * - * The function does nothing silently if there is no entry - * at the supplied address, or if the entry found has the - * wrong type. - * - * Return: Non-negative on success/Negative on failure or if there was - * an attempt to flush a protected item. - * - * Programmer: John Mainzer, 5/5/04 - * - * Changes: Please maintain the changes list, and do not delete it - * unless you have merged it into the header comment - * proper. - * - * Added macro calls to maintain page buffer hints. - * - * JRM -- 3/20/20 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) -{ - H5C_t * cache_ptr; /* Cache for file */ - hbool_t destroy; /* external flag */ - hbool_t clear_only; /* external flag */ - hbool_t free_file_space; /* external flag */ - hbool_t take_ownership; /* external flag */ - hbool_t del_from_slist_on_destroy; /* external flag */ - hbool_t during_flush; /* external flag */ - hbool_t write_entry; /* internal flag */ - hbool_t destroy_entry; /* internal flag */ - hbool_t generate_image; /* internal flag */ - hbool_t update_page_buffer; /* internal flag */ - hbool_t was_dirty; - hbool_t suppress_image_entry_writes = FALSE; - hbool_t suppress_image_entry_frees = FALSE; - haddr_t entry_addr = HADDR_UNDEF; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__flush_ring() */ - HDassert(f); - cache_ptr = f->shared->cache; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(entry_ptr); - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring != H5C_RING_UNDEFINED); - HDassert(entry_ptr->type); - - /* setup external flags from the flags parameter */ - destroy = ((flags & H5C__FLUSH_INVALIDATE_FLAG) != 0); - clear_only = ((flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); - free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); - take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); - del_from_slist_on_destroy = ((flags & H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) != 0); - during_flush = ((flags & H5C__DURING_FLUSH_FLAG) != 0); - generate_image = ((flags & H5C__GENERATE_IMAGE_FLAG) != 0); - update_page_buffer = ((flags & H5C__UPDATE_PAGE_BUFFER_FLAG) != 0); - - /* Set the flag for destroying the entry, based on the 'take ownership' - * and 'destroy' flags + /*------------------------------------------------------------------------- + * + * Function: H5C__flush_single_entry + * + * Purpose: Flush or clear (and evict if requested) the cache entry + * with the specified address and type. If the type is NULL, + * any unprotected entry at the specified address will be + * flushed (and possibly evicted). + * + * Attempts to flush a protected entry will result in an + * error. + * + * If the H5C__FLUSH_INVALIDATE_FLAG flag is set, the entry will + * be cleared and not flushed, and the call can't be part of a + * sequence of flushes. + * + * If the caller knows the address of the skip list node at + * which the target entry resides, it can avoid a lookup + * by supplying that address in the tgt_node_ptr parameter. + * If this parameter is NULL, the function will do a skip list + * search for the entry instead. + * + * The function does nothing silently if there is no entry + * at the supplied address, or if the entry found has the + * wrong type. + * + * Return: Non-negative on success/Negative on failure or if there was + * an attempt to flush a protected item. + * + * Programmer: John Mainzer, 5/5/04 + * + * Changes: Please maintain the changes list, and do not delete it + * unless you have merged it into the header comment + * proper. + * + * Added macro calls to maintain page buffer hints. + * + * JRM -- 3/20/20 + * + *------------------------------------------------------------------------- */ - if(take_ownership) - destroy_entry = FALSE; - else - destroy_entry = destroy; + herr_t H5C__flush_single_entry(H5F_t * f, H5C_cache_entry_t * entry_ptr, unsigned flags) + { + H5C_t * cache_ptr; /* Cache for file */ + hbool_t destroy; /* external flag */ + hbool_t clear_only; /* external flag */ + hbool_t free_file_space; /* external flag */ + hbool_t take_ownership; /* external flag */ + hbool_t del_from_slist_on_destroy; /* external flag */ + hbool_t during_flush; /* external flag */ + hbool_t write_entry; /* internal flag */ + hbool_t destroy_entry; /* internal flag */ + hbool_t generate_image; /* internal flag */ + hbool_t update_page_buffer; /* internal flag */ + hbool_t was_dirty; + hbool_t suppress_image_entry_writes = FALSE; + hbool_t suppress_image_entry_frees = FALSE; + haddr_t entry_addr = HADDR_UNDEF; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + HDassert(f); + cache_ptr = f->shared->cache; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(entry_ptr); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring != H5C_RING_UNDEFINED); + HDassert(entry_ptr->type); + + /* setup external flags from the flags parameter */ + destroy = ((flags & H5C__FLUSH_INVALIDATE_FLAG) != 0); + clear_only = ((flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); + free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); + take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); + del_from_slist_on_destroy = ((flags & H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) != 0); + during_flush = ((flags & H5C__DURING_FLUSH_FLAG) != 0); + generate_image = ((flags & H5C__GENERATE_IMAGE_FLAG) != 0); + update_page_buffer = ((flags & H5C__UPDATE_PAGE_BUFFER_FLAG) != 0); + + /* Set the flag for destroying the entry, based on the 'take ownership' + * and 'destroy' flags + */ + if (take_ownership) + destroy_entry = FALSE; + else + destroy_entry = destroy; - /* we will write the entry to disk if it exists, is dirty, and if the - * clear only flag is not set. - */ - if(entry_ptr->is_dirty && !clear_only) - write_entry = TRUE; - else - write_entry = FALSE; + /* we will write the entry to disk if it exists, is dirty, and if the + * clear only flag is not set. + */ + if (entry_ptr->is_dirty && !clear_only) + write_entry = TRUE; + else + write_entry = FALSE; - /* if we have received close warning, and we have been instructed to - * generate a metadata cache image, and we have actually constructed - * the entry images, set suppress_image_entry_frees to TRUE. - * - * Set suppress_image_entry_writes to TRUE if indicated by the - * image_ctl flags. - */ - if(cache_ptr->close_warning_received && cache_ptr->image_ctl.generate_image - && cache_ptr->num_entries_in_image > 0 && cache_ptr->image_entries) { - /* Sanity checks */ - HDassert(entry_ptr->image_up_to_date || !(entry_ptr->include_in_image)); - HDassert(entry_ptr->image_ptr || !(entry_ptr->include_in_image)); - HDassert((!clear_only) || !(entry_ptr->include_in_image)); - HDassert((!take_ownership) || !(entry_ptr->include_in_image)); - HDassert((!free_file_space) || !(entry_ptr->include_in_image)); + /* if we have received close warning, and we have been instructed to + * generate a metadata cache image, and we have actually constructed + * the entry images, set suppress_image_entry_frees to TRUE. + * + * Set suppress_image_entry_writes to TRUE if indicated by the + * image_ctl flags. + */ + if (cache_ptr->close_warning_received && cache_ptr->image_ctl.generate_image && + cache_ptr->num_entries_in_image > 0 && cache_ptr->image_entries) { + /* Sanity checks */ + HDassert(entry_ptr->image_up_to_date || !(entry_ptr->include_in_image)); + HDassert(entry_ptr->image_ptr || !(entry_ptr->include_in_image)); + HDassert((!clear_only) || !(entry_ptr->include_in_image)); + HDassert((!take_ownership) || !(entry_ptr->include_in_image)); + HDassert((!free_file_space) || !(entry_ptr->include_in_image)); - suppress_image_entry_frees = TRUE; + suppress_image_entry_frees = TRUE; - if(cache_ptr->image_ctl.flags & H5C_CI__SUPRESS_ENTRY_WRITES) - suppress_image_entry_writes = TRUE; - } /* end if */ + if (cache_ptr->image_ctl.flags & H5C_CI__SUPRESS_ENTRY_WRITES) + suppress_image_entry_writes = TRUE; + } /* end if */ - /* run initial sanity checks */ + /* run initial sanity checks */ #if H5C_DO_SANITY_CHECKS - if(entry_ptr->in_slist) { - HDassert(entry_ptr->is_dirty); + if (entry_ptr->in_slist) { + HDassert(entry_ptr->is_dirty); - if((entry_ptr->flush_marker) && (!entry_ptr->is_dirty)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry in slist failed sanity checks") - } /* end if */ - else { - HDassert(!entry_ptr->is_dirty); - HDassert(!entry_ptr->flush_marker); + if ((entry_ptr->flush_marker) && (!entry_ptr->is_dirty)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry in slist failed sanity checks") + } /* end if */ + else { + HDassert(!entry_ptr->is_dirty); + HDassert(!entry_ptr->flush_marker); - if((entry_ptr->is_dirty) || (entry_ptr->flush_marker)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry failed sanity checks") - } /* end else */ -#endif /* H5C_DO_SANITY_CHECKS */ + if ((entry_ptr->is_dirty) || (entry_ptr->flush_marker)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry failed sanity checks") + } /* end else */ +#endif /* H5C_DO_SANITY_CHECKS */ - if(entry_ptr->is_protected) { - HDassert(!entry_ptr->is_protected); + if (entry_ptr->is_protected) { + HDassert(!entry_ptr->is_protected); - /* Attempt to flush a protected entry -- scream and die. */ - HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, "Attempt to flush a protected entry") - } /* end if */ + /* Attempt to flush a protected entry -- scream and die. */ + HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, "Attempt to flush a protected entry") + } /* end if */ - /* Set entry_ptr->flush_in_progress = TRUE and set - * entry_ptr->flush_marker = FALSE - * - * We will set flush_in_progress back to FALSE at the end if the - * entry still exists at that point. - */ - entry_ptr->flush_in_progress = TRUE; - entry_ptr->flush_marker = FALSE; + /* Set entry_ptr->flush_in_progress = TRUE and set + * entry_ptr->flush_marker = FALSE + * + * We will set flush_in_progress back to FALSE at the end if the + * entry still exists at that point. + */ + entry_ptr->flush_in_progress = TRUE; + entry_ptr->flush_marker = FALSE; - /* Preserve current dirty state for later */ - was_dirty = entry_ptr->is_dirty; + /* Preserve current dirty state for later */ + was_dirty = entry_ptr->is_dirty; - /* The entry is dirty, and we are doing a flush, a flush destroy or have - * been requested to generate an image. In those cases, serialize the - * entry. - */ - if(write_entry || generate_image) { - HDassert(entry_ptr->is_dirty); + /* The entry is dirty, and we are doing a flush, a flush destroy or have + * been requested to generate an image. In those cases, serialize the + * entry. + */ + if (write_entry || generate_image) { + HDassert(entry_ptr->is_dirty); - if(NULL == entry_ptr->image_ptr) { - if(NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") + if (NULL == entry_ptr->image_ptr) { + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - } /* end if */ + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + } /* end if */ - if(!(entry_ptr->image_up_to_date)) { - /* Sanity check */ - HDassert(!entry_ptr->prefetched); + if (!(entry_ptr->image_up_to_date)) { + /* Sanity check */ + HDassert(!entry_ptr->prefetched); - /* Generate the entry's image */ - if(H5C__generate_image(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't generate entry's image") - } /* end if ( ! (entry_ptr->image_up_to_date) ) */ - } /* end if */ + /* Generate the entry's image */ + if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't generate entry's image") + } /* end if ( ! (entry_ptr->image_up_to_date) ) */ + } /* end if */ - /* Finally, write the image to disk. - * - * Note that if the H5AC__CLASS_SKIP_WRITES flag is set in the - * in the entry's type, we silently skip the write. This - * flag should only be used in test code. - */ - if(write_entry) { - HDassert(entry_ptr->is_dirty); + /* Finally, write the image to disk. + * + * Note that if the H5AC__CLASS_SKIP_WRITES flag is set in the + * in the entry's type, we silently skip the write. This + * flag should only be used in test code. + */ + if (write_entry) { + HDassert(entry_ptr->is_dirty); #if H5C_DO_SANITY_CHECKS - if(cache_ptr->check_write_permitted && !(cache_ptr->write_permitted)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Write when writes are always forbidden!?!?!") + if (cache_ptr->check_write_permitted && !(cache_ptr->write_permitted)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Write when writes are always forbidden!?!?!") #endif /* H5C_DO_SANITY_CHECKS */ - /* Write the image to disk unless the write is suppressed. - * - * This happens if both suppress_image_entry_writes and - * entry_ptr->include_in_image are TRUE, or if the - * H5AC__CLASS_SKIP_WRITES is set in the entry's type. This - * flag should only be used in test code - */ - if((!suppress_image_entry_writes || !entry_ptr->include_in_image) - && (((entry_ptr->type->flags) & H5C__CLASS_SKIP_WRITES) == 0)) { - H5FD_mem_t mem_type = H5FD_MEM_DEFAULT; + /* Write the image to disk unless the write is suppressed. + * + * This happens if both suppress_image_entry_writes and + * entry_ptr->include_in_image are TRUE, or if the + * H5AC__CLASS_SKIP_WRITES is set in the entry's type. This + * flag should only be used in test code + */ + if ((!suppress_image_entry_writes || !entry_ptr->include_in_image) && + (((entry_ptr->type->flags) & H5C__CLASS_SKIP_WRITES) == 0)) { + H5FD_mem_t mem_type = H5FD_MEM_DEFAULT; #ifdef H5_HAVE_PARALLEL - if(cache_ptr->coll_write_list) { - if(H5SL_insert(cache_ptr->coll_write_list, entry_ptr, &entry_ptr->addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert skip list item") - } /* end if */ - else - { + if (cache_ptr->coll_write_list) { + if (H5SL_insert(cache_ptr->coll_write_list, entry_ptr, &entry_ptr->addr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert skip list item") + } /* end if */ + else { #endif /* H5_HAVE_PARALLEL */ - if(entry_ptr->prefetched) { - HDassert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); - mem_type = cache_ptr-> - class_table_ptr[entry_ptr->prefetch_type_id]-> - mem_type; - } /* end if */ - else - mem_type = entry_ptr->type->mem_type; + if (entry_ptr->prefetched) { + HDassert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); + mem_type = cache_ptr->class_table_ptr[entry_ptr->prefetch_type_id]->mem_type; + } /* end if */ + else + mem_type = entry_ptr->type->mem_type; - H5C__SET_PB_WRITE_HINTS(cache_ptr, entry_ptr->type) + H5C__SET_PB_WRITE_HINTS(cache_ptr, entry_ptr->type) - if ( H5F_block_write(f, mem_type, entry_ptr->addr, - entry_ptr->size, - entry_ptr->image_ptr) < 0 ) { + if (H5F_block_write(f, mem_type, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) < + 0) { - H5C__RESET_PB_WRITE_HINTS(cache_ptr) + H5C__RESET_PB_WRITE_HINTS(cache_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't write image to file") - } - H5C__RESET_PB_WRITE_HINTS(cache_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't write image to file") + } + H5C__RESET_PB_WRITE_HINTS(cache_ptr) #ifdef H5_HAVE_PARALLEL - } -#endif /* H5_HAVE_PARALLEL */ - } /* end if */ + } +#endif /* H5_HAVE_PARALLEL */ + } /* end if */ - /* if the entry has a notify callback, notify it that we have - * just flushed the entry. + /* if the entry has a notify callback, notify it that we have + * just flushed the entry. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_FLUSH, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client of entry flush") + } /* if ( write_entry ) */ + + /* At this point, all pre-serialize and serialize calls have been + * made if it was appropriate to make them. Similarly, the entry + * has been written to disk if desired. + * + * Thus it is now safe to update the cache data structures for the + * flush. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_FLUSH, entry_ptr) < 0 ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client of entry flush") - } /* if ( write_entry ) */ - /* At this point, all pre-serialize and serialize calls have been - * made if it was appropriate to make them. Similarly, the entry - * has been written to disk if desired. - * - * Thus it is now safe to update the cache data structures for the - * flush. - */ + /* start by updating the statistics */ + if (clear_only) { + /* only log a clear if the entry was dirty */ + if (was_dirty) { + H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) + } /* end if */ + } + else if (write_entry) { + HDassert(was_dirty); - /* start by updating the statistics */ - if(clear_only) { - /* only log a clear if the entry was dirty */ - if(was_dirty) { - H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) - } /* end if */ - } else if(write_entry) { - HDassert(was_dirty); + /* only log a flush if we actually wrote to disk */ + H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) + } /* end else if */ - /* only log a flush if we actually wrote to disk */ - H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) - } /* end else if */ - - /* Note that the algorithm below is (very) similar to the set of operations - * in H5C_remove_entry() and should be kept in sync with changes - * to that code. - QAK, 2016/11/30 - */ + /* Note that the algorithm below is (very) similar to the set of operations + * in H5C_remove_entry() and should be kept in sync with changes + * to that code. - QAK, 2016/11/30 + */ - /* Update the cache internal data structures. */ - if(destroy) { - /* Sanity checks */ - if(take_ownership) - HDassert(!destroy_entry); - else - HDassert(destroy_entry); - HDassert(!entry_ptr->is_pinned); + /* Update the cache internal data structures. */ + if (destroy) { + /* Sanity checks */ + if (take_ownership) + HDassert(!destroy_entry); + else + HDassert(destroy_entry); + HDassert(!entry_ptr->is_pinned); - /* Update stats, while entry is still in the cache */ - H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) + /* Update stats, while entry is still in the cache */ + H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) - /* If the entry's type has a 'notify' callback and the entry is about - * to be removed from the cache, send a 'before eviction' notice while - * the entry is still fully integrated in the cache. - */ - if(entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") + /* If the entry's type has a 'notify' callback and the entry is about + * to be removed from the cache, send a 'before eviction' notice while + * the entry is still fully integrated in the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") - /* Update the cache internal data structures as appropriate - * for a destroy. Specifically: - * - * 1) Delete it from the index - * - * 2) Delete it from the skip list if requested. - * - * 3) Delete it from the collective read access list. - * - * 4) Update the replacement policy for eviction - * - * 5) Remove it from the tag list for this object - * - * Finally, if the destroy_entry flag is set, discard the - * entry. - */ - H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL) + /* Update the cache internal data structures as appropriate + * for a destroy. Specifically: + * + * 1) Delete it from the index + * + * 2) Delete it from the skip list if requested. + * + * 3) Delete it from the collective read access list. + * + * 4) Update the replacement policy for eviction + * + * 5) Remove it from the tag list for this object + * + * Finally, if the destroy_entry flag is set, discard the + * entry. + */ + H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL) - if(entry_ptr->in_slist && del_from_slist_on_destroy) - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) + if (entry_ptr->in_slist && del_from_slist_on_destroy) + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) #ifdef H5_HAVE_PARALLEL - /* Check for collective read access flag */ - if(entry_ptr->coll_access) { - entry_ptr->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + /* Check for collective read access flag */ + if (entry_ptr->coll_access) { + entry_ptr->coll_access = FALSE; + H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ - H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, FAIL) + H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, FAIL) - /* Remove entry from tag list */ - if(H5C__untag_entry(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") + /* Remove entry from tag list */ + if (H5C__untag_entry(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") - /* verify that the entry is no longer part of any flush dependencies */ - HDassert(entry_ptr->flush_dep_nparents == 0); - HDassert(entry_ptr->flush_dep_nchildren == 0); - } /* end if */ - else { - HDassert(clear_only || write_entry); - HDassert(entry_ptr->is_dirty); - HDassert(entry_ptr->in_slist); + /* verify that the entry is no longer part of any flush dependencies */ + HDassert(entry_ptr->flush_dep_nparents == 0); + HDassert(entry_ptr->flush_dep_nchildren == 0); + } /* end if */ + else { + HDassert(clear_only || write_entry); + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->in_slist); - /* We are either doing a flush or a clear. - * - * A clear and a flush are the same from the point of - * view of the replacement policy and the slist. - * Hence no differentiation between them. - * - * JRM -- 7/7/07 - */ + /* We are either doing a flush or a clear. + * + * A clear and a flush are the same from the point of + * view of the replacement policy and the slist. + * Hence no differentiation between them. + * + * JRM -- 7/7/07 + */ - H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, FAIL) + H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, FAIL) - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) - /* mark the entry as clean and update the index for - * entry clean. Also, call the clear callback - * if defined. - */ - entry_ptr->is_dirty = FALSE; + /* mark the entry as clean and update the index for + * entry clean. Also, call the clear callback + * if defined. + */ + entry_ptr->is_dirty = FALSE; - H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr); + H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr); - /* Check for entry changing status and do notifications, etc. */ - if(was_dirty) { - /* If the entry's type has a 'notify' callback send a 'entry cleaned' - * notice now that the entry is fully integrated into the cache. - */ - if(entry_ptr->type->notify && + /* Check for entry changing status and do notifications, etc. */ + if (was_dirty) { + /* If the entry's type has a 'notify' callback send a 'entry cleaned' + * notice now that the entry is fully integrated into the cache. + */ + if (entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag cleared") - - /* Propagate the clean flag up the flush dependency chain if appropriate */ - if(entry_ptr->flush_dep_ndirty_children != 0) - HDassert(entry_ptr->flush_dep_ndirty_children == 0); - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_clean(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Can't propagate flush dep clean flag") - } /* end if */ - } /* end else */ - - /* reset the flush_in progress flag */ - entry_ptr->flush_in_progress = FALSE; + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") + + /* Propagate the clean flag up the flush dependency chain if appropriate */ + if (entry_ptr->flush_dep_ndirty_children != 0) + HDassert(entry_ptr->flush_dep_ndirty_children == 0); + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, + "Can't propagate flush dep clean flag") + } /* end if */ + } /* end else */ - /* capture the cache entry address for the log_flush call at the - end before the entry_ptr gets freed */ - entry_addr = entry_ptr->addr; + /* reset the flush_in progress flag */ + entry_ptr->flush_in_progress = FALSE; - /* Internal cache data structures should now be up to date, and - * consistent with the status of the entry. - * - * Now discard the entry if appropriate. - */ - if(destroy) { - /* Sanity check */ - HDassert(0 == entry_ptr->flush_dep_nparents); + /* capture the cache entry address for the log_flush call at the + end before the entry_ptr gets freed */ + entry_addr = entry_ptr->addr; - /* if both suppress_image_entry_frees and entry_ptr->include_in_image - * are true, simply set entry_ptr->image_ptr to NULL, as we have - * another pointer to the buffer in an instance of H5C_image_entry_t - * in cache_ptr->image_entries. + /* Internal cache data structures should now be up to date, and + * consistent with the status of the entry. * - * Otherwise, free the buffer if it exists. + * Now discard the entry if appropriate. */ - if(suppress_image_entry_frees && entry_ptr->include_in_image) - entry_ptr->image_ptr = NULL; - else if(entry_ptr->image_ptr != NULL) - entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); + if (destroy) { + /* Sanity check */ + HDassert(0 == entry_ptr->flush_dep_nparents); - /* If the entry is not a prefetched entry, verify that the flush - * dependency parents addresses array has been transferred. - * - * If the entry is prefetched, the free_isr routine will dispose of - * the flush dependency parents addresses array if necessary. - */ - if(!entry_ptr->prefetched) { - HDassert(0 == entry_ptr->fd_parent_count); - HDassert(NULL == entry_ptr->fd_parent_addrs); - } /* end if */ + /* if both suppress_image_entry_frees and entry_ptr->include_in_image + * are true, simply set entry_ptr->image_ptr to NULL, as we have + * another pointer to the buffer in an instance of H5C_image_entry_t + * in cache_ptr->image_entries. + * + * Otherwise, free the buffer if it exists. + */ + if (suppress_image_entry_frees && entry_ptr->include_in_image) + entry_ptr->image_ptr = NULL; + else if (entry_ptr->image_ptr != NULL) + entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); - /* Check whether we should free the space in the file that - * the entry occupies - */ - if(free_file_space) { - hsize_t fsf_size; + /* If the entry is not a prefetched entry, verify that the flush + * dependency parents addresses array has been transferred. + * + * If the entry is prefetched, the free_isr routine will dispose of + * the flush dependency parents addresses array if necessary. + */ + if (!entry_ptr->prefetched) { + HDassert(0 == entry_ptr->fd_parent_count); + HDassert(NULL == entry_ptr->fd_parent_addrs); + } /* end if */ - /* Sanity checks */ - HDassert(H5F_addr_defined(entry_ptr->addr)); - HDassert(!H5F_IS_TMP_ADDR(f, entry_ptr->addr)); + /* Check whether we should free the space in the file that + * the entry occupies + */ + if (free_file_space) { + hsize_t fsf_size; + + /* Sanity checks */ + HDassert(H5F_addr_defined(entry_ptr->addr)); + HDassert(!H5F_IS_TMP_ADDR(f, entry_ptr->addr)); #ifndef NDEBUG - { - size_t curr_len; + { + size_t curr_len; - /* Get the actual image size for the thing again */ - entry_ptr->type->image_len((void *)entry_ptr, &curr_len); - HDassert(curr_len == entry_ptr->size); - } + /* Get the actual image size for the thing again */ + entry_ptr->type->image_len((void *)entry_ptr, &curr_len); + HDassert(curr_len == entry_ptr->size); + } #endif /* NDEBUG */ - /* If the file space free size callback is defined, use - * it to get the size of the block of file space to free. - * Otherwise use entry_ptr->size. + /* If the file space free size callback is defined, use + * it to get the size of the block of file space to free. + * Otherwise use entry_ptr->size. + */ + if (entry_ptr->type->fsf_size) { + if ((entry_ptr->type->fsf_size)((void *)entry_ptr, &fsf_size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to get file space free size") + } /* end if */ + else /* no file space free size callback -- use entry size */ + fsf_size = entry_ptr->size; + + /* Release the space on disk */ + if (H5MF_xfree(f, entry_ptr->type->mem_type, entry_ptr->addr, fsf_size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to free file space for cache entry") + } /* end if ( free_file_space ) */ + + /* Reset the pointer to the cache the entry is within. -QAK */ + entry_ptr->cache_ptr = NULL; + + /* increment entries_removed_counter and set + * last_entry_removed_ptr. As we are likely abuut to + * free the entry, recall that last_entry_removed_ptr + * must NEVER be dereferenced. + * + * Recall that these fields are maintained to allow functions + * that perform scans of lists of entries to detect the + * unexpected removal of entries (via expunge, eviction, + * or take ownership at present), so that they can re-start + * their scans if necessary. + * + * Also check if the entry we are watching for removal is being + * removed (usually the 'next' entry for an iteration) and reset + * it to indicate that it was removed. */ - if(entry_ptr->type->fsf_size) { - if((entry_ptr->type->fsf_size)((void *)entry_ptr, &fsf_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to get file space free size") - } /* end if */ - else /* no file space free size callback -- use entry size */ - fsf_size = entry_ptr->size; - - /* Release the space on disk */ - if(H5MF_xfree(f, entry_ptr->type->mem_type, entry_ptr->addr, fsf_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to free file space for cache entry") - } /* end if ( free_file_space ) */ + cache_ptr->entries_removed_counter++; + cache_ptr->last_entry_removed_ptr = entry_ptr; + if (entry_ptr == cache_ptr->entry_watched_for_removal) + cache_ptr->entry_watched_for_removal = NULL; + + /* Check for actually destroying the entry in memory */ + /* (As opposed to taking ownership of it) */ + if (destroy_entry) { + if (entry_ptr->is_dirty) { + /* Reset dirty flag */ + entry_ptr->is_dirty = FALSE; + + /* If the entry's type has a 'notify' callback send a 'entry cleaned' + * notice now that the entry is fully integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") + } /* end if */ - /* Reset the pointer to the cache the entry is within. -QAK */ - entry_ptr->cache_ptr = NULL; + /* we are about to discard the in core representation -- + * set the magic field to bad magic so we can detect a + * freed entry if we see one. + */ + entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; - /* increment entries_removed_counter and set - * last_entry_removed_ptr. As we are likely abuut to - * free the entry, recall that last_entry_removed_ptr - * must NEVER be dereferenced. - * - * Recall that these fields are maintained to allow functions - * that perform scans of lists of entries to detect the - * unexpected removal of entries (via expunge, eviction, - * or take ownership at present), so that they can re-start - * their scans if necessary. - * - * Also check if the entry we are watching for removal is being - * removed (usually the 'next' entry for an iteration) and reset - * it to indicate that it was removed. - */ - cache_ptr->entries_removed_counter++; - cache_ptr->last_entry_removed_ptr = entry_ptr; - if(entry_ptr == cache_ptr->entry_watched_for_removal) - cache_ptr->entry_watched_for_removal = NULL; - - /* Check for actually destroying the entry in memory */ - /* (As opposed to taking ownership of it) */ - if(destroy_entry) { - if(entry_ptr->is_dirty) { - /* Reset dirty flag */ - entry_ptr->is_dirty = FALSE; + /* verify that the image has been freed */ + HDassert(entry_ptr->image_ptr == NULL); - /* If the entry's type has a 'notify' callback send a 'entry cleaned' - * notice now that the entry is fully integrated into the cache. - */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag cleared") + if (entry_ptr->type->free_icr((void *)entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed") } /* end if */ + else { + HDassert(take_ownership); - /* we are about to discard the in core representation -- - * set the magic field to bad magic so we can detect a - * freed entry if we see one. - */ - entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; + /* client is taking ownership of the entry. + * set bad magic here too so the cache will choke + * unless the entry is re-inserted properly + */ + entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; + } /* end else */ + } /* if (destroy) */ - /* verify that the image has been freed */ - HDassert(entry_ptr->image_ptr == NULL); + /* Check if we have to update the page buffer with cleared entries + * so it doesn't go out of date + */ - if(entry_ptr->type->free_icr((void *)entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed") - } /* end if */ - else { - HDassert(take_ownership); + /* VFD SWMR TODO: Think on this, and decide if we need to extend + * this for multi page metadata entries. + */ + if (update_page_buffer) { + /* Sanity check */ + HDassert(!destroy); + HDassert(entry_ptr->image_ptr); - /* client is taking ownership of the entry. - * set bad magic here too so the cache will choke - * unless the entry is re-inserted properly - */ - entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; - } /* end else */ - } /* if (destroy) */ + if ((f->shared->pb_ptr) && (f->shared->pb_ptr->page_size >= entry_ptr->size)) { - /* Check if we have to update the page buffer with cleared entries - * so it doesn't go out of date - */ + if (H5PB_update_entry(f->shared->pb_ptr, entry_ptr->addr, entry_ptr->size, + entry_ptr->image_ptr) > 0) - /* VFD SWMR TODO: Think on this, and decide if we need to extend - * this for multi page metadata entries. - */ - if(update_page_buffer) { - /* Sanity check */ - HDassert(!destroy); - HDassert(entry_ptr->image_ptr); + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Failed to update PB with metadata cache") + } + } /* end if */ - if ( ( f->shared->pb_ptr ) && - ( f->shared->pb_ptr->page_size >= entry_ptr->size ) ) { + if (cache_ptr->log_flush) + if ((cache_ptr->log_flush)(cache_ptr, entry_addr, was_dirty, flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "log_flush callback failed") - if ( H5PB_update_entry(f->shared->pb_ptr, entry_ptr->addr, - entry_ptr->size, entry_ptr->image_ptr) > 0 ) +done: + HDassert((ret_value != SUCCEED) || (destroy_entry) || (!entry_ptr->flush_in_progress)); + HDassert((ret_value != SUCCEED) || (destroy_entry) || (take_ownership) || (!entry_ptr->is_dirty)); - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Failed to update PB with metadata cache") - } - } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__flush_single_entry() */ - if(cache_ptr->log_flush) - if((cache_ptr->log_flush)(cache_ptr, entry_addr, was_dirty, flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "log_flush callback failed") + /*------------------------------------------------------------------------- + * + * Function: H5C__verify_len_eoa + * + * Purpose: Verify that 'len' does not exceed eoa when 'actual' is + * false i.e. 'len" is the initial speculative length from + * get_load_size callback with null image pointer. + * If exceed, adjust 'len' accordingly. + * + * Verify that 'len' should not exceed eoa when 'actual' is + * true i.e. 'len' is the actual length from get_load_size + * callback with non-null image pointer. + * If exceed, return error. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + * Programmer: Vailin Choi + * 9/6/15 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__verify_len_eoa(H5F_t * f, const H5C_class_t *type, haddr_t addr, size_t *len, + hbool_t actual) + { + H5FD_mem_t cooked_type; /* Modified type, accounting for switching global heaps */ + haddr_t eoa; /* End-of-allocation in the file */ + herr_t ret_value = SUCCEED; /* Return value */ -done: - HDassert( ( ret_value != SUCCEED ) || ( destroy_entry ) || - ( ! entry_ptr->flush_in_progress ) ); - HDassert( ( ret_value != SUCCEED ) || ( destroy_entry ) || - ( take_ownership ) || ( ! entry_ptr->is_dirty ) ); + FUNC_ENTER_STATIC - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_single_entry() */ + /* if type == H5FD_MEM_GHEAP, H5F_block_read() forces + * type to H5FD_MEM_DRAW via its call to H5F__accum_read(). + * Thus we do the same for purposes of computing the EOA + * for sanity checks. + */ + cooked_type = (type->mem_type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type->mem_type; - -/*------------------------------------------------------------------------- - * - * Function: H5C__verify_len_eoa - * - * Purpose: Verify that 'len' does not exceed eoa when 'actual' is - * false i.e. 'len" is the initial speculative length from - * get_load_size callback with null image pointer. - * If exceed, adjust 'len' accordingly. - * - * Verify that 'len' should not exceed eoa when 'actual' is - * true i.e. 'len' is the actual length from get_load_size - * callback with non-null image pointer. - * If exceed, return error. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Vailin Choi - * 9/6/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, - size_t *len, hbool_t actual) -{ - H5FD_mem_t cooked_type; /* Modified type, accounting for switching global heaps */ - haddr_t eoa; /* End-of-allocation in the file */ - herr_t ret_value = SUCCEED; /* Return value */ + /* Get the file's end-of-allocation value */ + eoa = H5F_get_eoa(f, cooked_type); + if (!H5F_addr_defined(eoa)) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid EOA address for file") - FUNC_ENTER_STATIC + /* Check for bad address in general */ + if (H5F_addr_gt(addr, eoa)) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "address of object past end of allocation") - /* if type == H5FD_MEM_GHEAP, H5F_block_read() forces - * type to H5FD_MEM_DRAW via its call to H5F__accum_read(). - * Thus we do the same for purposes of computing the EOA - * for sanity checks. - */ - cooked_type = (type->mem_type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type->mem_type; - - /* Get the file's end-of-allocation value */ - eoa = H5F_get_eoa(f, cooked_type); - if(!H5F_addr_defined(eoa)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid EOA address for file") - - /* Check for bad address in general */ - if(H5F_addr_gt(addr, eoa)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "address of object past end of allocation") - - /* Check if the amount of data to read will be past the EOA */ - if(H5F_addr_gt((addr + *len), eoa)) { - if(actual) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "actual len exceeds EOA") - else - /* Trim down the length of the metadata */ - *len = (size_t)(eoa - addr); - } /* end if */ + /* Check if the amount of data to read will be past the EOA */ + if (H5F_addr_gt((addr + *len), eoa)) { + if (actual) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "actual len exceeds EOA") + else + /* Trim down the length of the metadata */ + *len = (size_t)(eoa - addr); + } /* end if */ - if(*len <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "len not positive after adjustment for EOA") + if (*len <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "len not positive after adjustment for EOA") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__verify_len_eoa() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__verify_len_eoa() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_load_entry - * - * Purpose: Attempt to load the entry at the specified disk address - * and with the specified type into memory. If successful. - * return the in memory address of the entry. Return NULL - * on failure. - * - * Note that this function simply loads the entry into - * core. It does not insert it into the cache. - * - * Return: Non-NULL on success / NULL on failure. - * - * Programmer: John Mainzer, 5/18/04 - * - * Changes: Please maintain the change list and do not delete entries - * unless the have been folded into the header comment. - * - * Reverted optimization that avoided re-reading the prefix - * of a metadata entry when a speculative read proved too - * small. - * JRM -- 3/25/20 - * - * Added macro calls to maintain the page buffer read hints. - * - * JRM -- 3/20/20 - * - *------------------------------------------------------------------------- - */ -static void * -H5C_load_entry(H5F_t * f, + /*------------------------------------------------------------------------- + * + * Function: H5C_load_entry + * + * Purpose: Attempt to load the entry at the specified disk address + * and with the specified type into memory. If successful. + * return the in memory address of the entry. Return NULL + * on failure. + * + * Note that this function simply loads the entry into + * core. It does not insert it into the cache. + * + * Return: Non-NULL on success / NULL on failure. + * + * Programmer: John Mainzer, 5/18/04 + * + * Changes: Please maintain the change list and do not delete entries + * unless the have been folded into the header comment. + * + * Reverted optimization that avoided re-reading the prefix + * of a metadata entry when a speculative read proved too + * small. + * JRM -- 3/25/20 + * + * Added macro calls to maintain the page buffer read hints. + * + * JRM -- 3/20/20 + * + *------------------------------------------------------------------------- + */ + static void *H5C_load_entry(H5F_t * f, #ifdef H5_HAVE_PARALLEL - hbool_t coll_access, + hbool_t coll_access, #endif /* H5_HAVE_PARALLEL */ - const H5C_class_t * type, - haddr_t addr, - void * udata) -{ - hbool_t dirty = FALSE; /* Flag indicating whether thing */ - /* was dirtied during deserialize */ - uint8_t * image = NULL; /* Buffer for disk image */ - void * thing = NULL; /* Pointer to thing loaded */ - H5C_cache_entry_t *entry = NULL; /* Alias for thing loaded, as */ - /* cache entry */ + const H5C_class_t *type, haddr_t addr, void *udata) + { + hbool_t dirty = FALSE; /* Flag indicating whether thing */ + /* was dirtied during deserialize */ + uint8_t * image = NULL; /* Buffer for disk image */ + void * thing = NULL; /* Pointer to thing loaded */ + H5C_cache_entry_t *entry = NULL; /* Alias for thing loaded, as */ + /* cache entry */ #if 0 size_t init_len; #endif - size_t len; /* Size of image in file */ + size_t len; /* Size of image in file */ #ifdef H5_HAVE_PARALLEL - int mpi_rank = 0; /* MPI process rank */ - MPI_Comm comm = MPI_COMM_NULL; /* File MPI Communicator */ - int mpi_code; /* MPI error code */ -#endif /* H5_HAVE_PARALLEL */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT + int mpi_rank = 0; /* MPI process rank */ + MPI_Comm comm = MPI_COMM_NULL; /* File MPI Communicator */ + int mpi_code; /* MPI error code */ +#endif /* H5_HAVE_PARALLEL */ + void *ret_value = NULL; /* Return value */ - /* Sanity checks */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->cache); - HDassert(f->shared->cache->magic == H5C__H5C_T_MAGIC ); + FUNC_ENTER_NOAPI_NOINIT - /* if this is a VFD SWMR reader, verify that the page size is defined */ - HDassert( ( ! f->shared->cache->vfd_swmr_reader ) || - ( f->shared->cache->page_size > 0 ) ); + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->cache); + HDassert(f->shared->cache->magic == H5C__H5C_T_MAGIC); - HDassert(type); - HDassert(H5F_addr_defined(addr)); - HDassert(type->get_initial_load_size); + /* if this is a VFD SWMR reader, verify that the page size is defined */ + HDassert((!f->shared->cache->vfd_swmr_reader) || (f->shared->cache->page_size > 0)); - if ( type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG ) { + HDassert(type); + HDassert(H5F_addr_defined(addr)); + HDassert(type->get_initial_load_size); - HDassert(type->get_final_load_size); + if (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) { - } else { + HDassert(type->get_final_load_size); + } + else { - HDassert(NULL == type->get_final_load_size); - } + HDassert(NULL == type->get_final_load_size); + } - HDassert(type->deserialize); + HDassert(type->deserialize); - /* Can't see how skip reads could be usefully combined with - * the speculative read flag. Hence disallow. - */ - HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && - (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); + /* Can't see how skip reads could be usefully combined with + * the speculative read flag. Hence disallow. + */ + HDassert( + !((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); - /* Call the get_initial_load_size callback, to retrieve the initial - * size of image - */ - if ( type->get_initial_load_size(udata, &len) < 0 ) + /* Call the get_initial_load_size callback, to retrieve the initial + * size of image + */ + if (type->get_initial_load_size(udata, &len) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image size") + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image size") - HDassert(len > 0); + HDassert(len > 0); #if 0 init_len = len; #endif - /* Check for possible speculative read off the end of the file */ - if ( type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG ) { + /* Check for possible speculative read off the end of the file */ + if (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) { - if ( H5C__verify_len_eoa(f, type, addr, &len, FALSE) < 0 ) + if (H5C__verify_len_eoa(f, type, addr, &len, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, \ - "invalid len with respect to EOA") - } + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid len with respect to EOA") + } - /* Allocate the buffer for reading the on-disk entry image */ - if ( NULL == (image = (uint8_t *)H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE)) ) + /* Allocate the buffer for reading the on-disk entry image */ + if (NULL == (image = (uint8_t *)H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "memory allocation failed for on disk image buffer") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ #ifdef H5_HAVE_PARALLEL - if ( H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) ) { + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - if ( (mpi_rank = H5F_mpi_get_rank(f)) < 0 ) + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") - if ( (comm = H5F_mpi_get_comm(f)) == MPI_COMM_NULL ) + if ((comm = H5F_mpi_get_comm(f)) == MPI_COMM_NULL) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") - - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") - /* Get the on-disk entry image */ - if ( 0 == (type->flags & H5C__CLASS_SKIP_READS) ) { - - unsigned tries; /* The # of retries */ - htri_t chk_ret; /* return from verify_chksum callback */ - size_t actual_len = len; /* The actual length, after speculative */ - /* reads have been resolved */ - void *new_image; /* Pointer to image */ - hbool_t len_changed = TRUE; /* Whether to re-check speculative */ - /* entries */ - bool do_try; - h5_retry_t retry; - - /* - * This do/while loop performs the following till the metadata checksum - * is correct or the file's number of allowed read attempts are reached. - * --read the metadata - * --determine the actual size of the metadata - * --perform checksum verification - */ - for (do_try = h5_retry_init(&retry, H5F_GET_READ_ATTEMPTS(f), - 1, H5_RETRY_ONE_HOUR / 3600 / 100); - do_try; - do_try = h5_retry_next(&retry)) { - if ( actual_len != len ) { + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + + /* Get the on-disk entry image */ + if (0 == (type->flags & H5C__CLASS_SKIP_READS)) { + + unsigned tries; /* The # of retries */ + htri_t chk_ret; /* return from verify_chksum callback */ + size_t actual_len = len; /* The actual length, after speculative */ + /* reads have been resolved */ + void * new_image; /* Pointer to image */ + hbool_t len_changed = TRUE; /* Whether to re-check speculative */ + /* entries */ + bool do_try; + h5_retry_t retry; + + /* + * This do/while loop performs the following till the metadata checksum + * is correct or the file's number of allowed read attempts are reached. + * --read the metadata + * --determine the actual size of the metadata + * --perform checksum verification + */ + for (do_try = h5_retry_init(&retry, H5F_GET_READ_ATTEMPTS(f), 1, H5_RETRY_ONE_HOUR / 3600 / 100); + do_try; do_try = h5_retry_next(&retry)) { + if (actual_len != len) { - if ( NULL == (new_image = H5MM_realloc(image, - len + H5C_IMAGE_EXTRA_SPACE)) ) + if (NULL == (new_image = H5MM_realloc(image, len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "image null after H5MM_realloc()") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") - image = (uint8_t *)new_image; + image = (uint8_t *)new_image; #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - } /* end if */ + H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + } /* end if */ #ifdef H5_HAVE_PARALLEL - if ( !coll_access || 0 == mpi_rank ) { + if (!coll_access || 0 == mpi_rank) { #endif /* H5_HAVE_PARALLEL */ - H5C__SET_PB_READ_HINTS(f->shared->cache, type, TRUE) + H5C__SET_PB_READ_HINTS(f->shared->cache, type, TRUE) - if ( H5F_block_read(f, type->mem_type, addr, len, image) < 0 ) { + if (H5F_block_read(f, type->mem_type, addr, len, image) < 0) { - H5C__RESET_PB_READ_HINTS(f->shared->cache) + H5C__RESET_PB_READ_HINTS(f->shared->cache) - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, \ - "Can't read image*") - } + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") + } - H5C__RESET_PB_READ_HINTS(f->shared->cache) + H5C__RESET_PB_READ_HINTS(f->shared->cache) #ifdef H5_HAVE_PARALLEL - } /* end if */ - /* if the collective metadata read optimization is turned on, - * bcast the metadata read from process 0 to all ranks in the file - * communicator - */ - if ( coll_access ) { + } /* end if */ + /* if the collective metadata read optimization is turned on, + * bcast the metadata read from process 0 to all ranks in the file + * communicator + */ + if (coll_access) { - int buf_size; + int buf_size; - H5_CHECKED_ASSIGN(buf_size, int, len, size_t); - if ( MPI_SUCCESS != - (mpi_code = MPI_Bcast(image, buf_size, MPI_BYTE, 0, comm))) + H5_CHECKED_ASSIGN(buf_size, int, len, size_t); + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(image, buf_size, MPI_BYTE, 0, comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ - /* If the entry could be read speculatively and the length is still - * changing, check for updating the actual size - */ - if( ( type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG ) && - ( len_changed ) ) { + /* If the entry could be read speculatively and the length is still + * changing, check for updating the actual size + */ + if ((type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) && (len_changed)) { - /* Retrieve the actual length */ - actual_len = len; - if ( type->get_final_load_size(image, len, udata, - &actual_len) < 0 ) { + /* Retrieve the actual length */ + actual_len = len; + if (type->get_final_load_size(image, len, udata, &actual_len) < 0) { - /* Transfer control to while() and count towards retries */ - continue; - } + /* Transfer control to while() and count towards retries */ + continue; + } - /* Check for the length changing */ - if ( actual_len != len ) { + /* Check for the length changing */ + if (actual_len != len) { - /* Verify that the length isn't past the EOA for - * the file - */ - if ( H5C__verify_len_eoa(f, type, addr, - &actual_len, TRUE) < 0) + /* Verify that the length isn't past the EOA for + * the file + */ + if (H5C__verify_len_eoa(f, type, addr, &actual_len, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, \ - "actual_len exceeds EOA") + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "actual_len exceeds EOA") - /* Expand buffer to new size */ - if ( NULL == - (new_image = H5MM_realloc(image, - actual_len + H5C_IMAGE_EXTRA_SPACE))) + /* Expand buffer to new size */ + if (NULL == (new_image = H5MM_realloc(image, actual_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "image null after H5MM_realloc()") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") - image = (uint8_t *)new_image; + image = (uint8_t *)new_image; #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(image + actual_len, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE); + H5MM_memcpy(image + actual_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - if ( actual_len > len ) { + if (actual_len > len) { #ifdef H5_HAVE_PARALLEL - if ( !coll_access || 0 == mpi_rank ) { + if (!coll_access || 0 == mpi_rank) { #endif /* H5_HAVE_PARALLEL */ -#if 0 /* JRM */ +#if 0 /* JRM */ /* If the thing's image needs to be bigger for * a speculatively loaded thing, go get the * on-disk image again (the extra portion). @@ -7355,105 +7054,98 @@ H5C_load_entry(H5F_t * f, HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \ "can't read image") -#else /* JRM */ - - /* the original version of this code re-read - * the entire buffer. At some point, someone - * reworked this code to avoid re-reading the - * initial portion of the buffer. - * - * In addition to being of questionable utility, - * this optimization changed the invarient that - * that metadata is read and written atomically. - * While this didn't cause immediate problems, - * the page buffer in VFD SWMR depends on this - * invarient in its management of multi-page - * metadata entries. - * - * To repair this issue, I have reverted to - * the original algorithm for managing the - * speculative load case. Note that I have - * done so crudely -- before merge, we should - * remove the infrastructure that supports the - * optimization. - * - * We should also verify my impression that the - * that the optimization is of no measurable - * value. If it is, we will put it back, but - * disable it in the VFD SWMR case. - * - * While this issue was detected in the global - * heap case, note that the super bloc, the - * local heap, and the fractal heap also use - * speculative loads. - * - * JRM -- 3/24/20 - */ +#else /* JRM */ - H5C__SET_PB_READ_HINTS(f->shared->cache, type, \ - FALSE); + /* the original version of this code re-read + * the entire buffer. At some point, someone + * reworked this code to avoid re-reading the + * initial portion of the buffer. + * + * In addition to being of questionable utility, + * this optimization changed the invarient that + * that metadata is read and written atomically. + * While this didn't cause immediate problems, + * the page buffer in VFD SWMR depends on this + * invarient in its management of multi-page + * metadata entries. + * + * To repair this issue, I have reverted to + * the original algorithm for managing the + * speculative load case. Note that I have + * done so crudely -- before merge, we should + * remove the infrastructure that supports the + * optimization. + * + * We should also verify my impression that the + * that the optimization is of no measurable + * value. If it is, we will put it back, but + * disable it in the VFD SWMR case. + * + * While this issue was detected in the global + * heap case, note that the super bloc, the + * local heap, and the fractal heap also use + * speculative loads. + * + * JRM -- 3/24/20 + */ - if ( H5F_block_read(f, type->mem_type, addr, - actual_len, image) < 0 ) { + H5C__SET_PB_READ_HINTS(f->shared->cache, type, FALSE); - H5C__RESET_PB_READ_HINTS(f->shared->cache) + if (H5F_block_read(f, type->mem_type, addr, actual_len, image) < 0) { - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \ - "can't read image") - } H5C__RESET_PB_READ_HINTS(f->shared->cache) + + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") + } + H5C__RESET_PB_READ_HINTS(f->shared->cache) #endif /* JRM */ #ifdef H5_HAVE_PARALLEL - } - /* If the collective metadata read optimization is - * turned on, Bcast the metadata read from process - * 0 to all ranks in the file communicator - */ - if ( coll_access ) { + } + /* If the collective metadata read optimization is + * turned on, Bcast the metadata read from process + * 0 to all ranks in the file communicator + */ + if (coll_access) { - int buf_size; + int buf_size; - H5_CHECKED_ASSIGN(buf_size, int, actual_len - len, \ - size_t); + H5_CHECKED_ASSIGN(buf_size, int, actual_len - len, size_t); - if ( MPI_SUCCESS != - (mpi_code = MPI_Bcast(image + len, buf_size, - MPI_BYTE, 0, comm)) ) + if (MPI_SUCCESS != + (mpi_code = MPI_Bcast(image + len, buf_size, MPI_BYTE, 0, comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", \ - mpi_code) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - } /* end if */ - } /* end if (actual_len != len) */ - else { - /* The length has stabilized */ - len_changed = FALSE; + HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + } /* end if */ + } /* end if (actual_len != len) */ + else { + /* The length has stabilized */ + len_changed = FALSE; - /* Set the final length */ - len = actual_len; - } /* else */ - } /* end if */ + /* Set the final length */ + len = actual_len; + } /* else */ + } /* end if */ - /* If there's no way to verify the checksum for a piece of metadata - * (usually because there's no checksum in the file), leave now - */ - if(type->verify_chksum == NULL) - break; + /* If there's no way to verify the checksum for a piece of metadata + * (usually because there's no checksum in the file), leave now + */ + if (type->verify_chksum == NULL) + break; - /* Verify the checksum for the metadata image */ - if ( (chk_ret = type->verify_chksum(image, actual_len, udata)) < 0) + /* Verify the checksum for the metadata image */ + if ((chk_ret = type->verify_chksum(image, actual_len, udata)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, \ - "failure from verify_chksum callback") + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "failure from verify_chksum callback") - if(chk_ret == TRUE) - break; - } + if (chk_ret == TRUE) + break; + } - /* Check for too many tries */ - if (!do_try) { -#if 0 /* JRM */ + /* Check for too many tries */ + if (!do_try) { +#if 0 /* JRM */ haddr_t eoa; int64_t page = (int64_t)(addr / f->shared->cache->page_size); @@ -7467,499 +7159,462 @@ H5C_load_entry(H5F_t * f, page, f->shared->mdf_idx_entries_used); H5FD_vfd_swmr_dump_status(f->shared->lf, page); #endif /* JRM */ - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, \ - "incorrect metadata checksum after all read attempts addr %" PRIuHADDR " size %zu", addr, len); - } + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, + "incorrect metadata checksum after all read attempts addr %" PRIuHADDR + " size %zu", + addr, len); + } - /* Calculate and track the # of retries */ - if ((tries = h5_retry_tries(&retry)) > 1) { /* Does not track 0 retry */ + /* Calculate and track the # of retries */ + if ((tries = h5_retry_tries(&retry)) > 1) { /* Does not track 0 retry */ - if ( H5F_track_metadata_read_retries(f, (unsigned)type->mem_type, - tries - 1) < 0) + if (H5F_track_metadata_read_retries(f, (unsigned)type->mem_type, tries - 1) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, \ - "cannot track read tries = %u ", tries) - } + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "cannot track read tries = %u ", tries) + } - /* Set the final length (in case it wasn't set earlier) */ - len = actual_len; + /* Set the final length (in case it wasn't set earlier) */ + len = actual_len; - } /* end if !H5C__CLASS_SKIP_READS */ + } /* end if !H5C__CLASS_SKIP_READS */ - /* Deserialize the on-disk image into the native memory form */ - if(NULL == (thing = type->deserialize(image, len, udata, &dirty))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't deserialize image") + /* Deserialize the on-disk image into the native memory form */ + if (NULL == (thing = type->deserialize(image, len, udata, &dirty))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't deserialize image") - entry = (H5C_cache_entry_t *)thing; + entry = (H5C_cache_entry_t *)thing; - /* In general, an entry should be clean just after it is loaded. - * - * However, when this code is used in the metadata cache, it is - * possible that object headers will be dirty at this point, as - * the deserialize function will alter object headers if necessary to - * fix an old bug. - * - * In the following assert: - * - * HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); - * - * note that type ids 5 & 6 are associated with object headers in the - * metadata cache. - * - * When we get to using H5C for other purposes, we may wish to - * tighten up the assert so that the loophole only applies to the - * metadata cache. - */ + /* In general, an entry should be clean just after it is loaded. + * + * However, when this code is used in the metadata cache, it is + * possible that object headers will be dirty at this point, as + * the deserialize function will alter object headers if necessary to + * fix an old bug. + * + * In the following assert: + * + * HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); + * + * note that type ids 5 & 6 are associated with object headers in the + * metadata cache. + * + * When we get to using H5C for other purposes, we may wish to + * tighten up the assert so that the loophole only applies to the + * metadata cache. + */ - HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6) ); - - entry->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - entry->cache_ptr = f->shared->cache; - entry->addr = addr; - entry->size = len; - HDassert(entry->size < H5C_MAX_ENTRY_SIZE); - entry->image_ptr = image; - entry->image_up_to_date = !dirty; - entry->type = type; - entry->is_dirty = dirty; - entry->dirtied = FALSE; - entry->is_protected = FALSE; - entry->is_read_only = FALSE; - entry->ro_ref_count = 0; - entry->is_pinned = FALSE; - entry->in_slist = FALSE; - entry->flush_marker = FALSE; + HDassert((dirty == FALSE) || (type->id == 5 || type->id == 6)); + + entry->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + entry->cache_ptr = f->shared->cache; + entry->addr = addr; + entry->size = len; + HDassert(entry->size < H5C_MAX_ENTRY_SIZE); + entry->image_ptr = image; + entry->image_up_to_date = !dirty; + entry->type = type; + entry->is_dirty = dirty; + entry->dirtied = FALSE; + entry->is_protected = FALSE; + entry->is_read_only = FALSE; + entry->ro_ref_count = 0; + entry->is_pinned = FALSE; + entry->in_slist = FALSE; + entry->flush_marker = FALSE; #ifdef H5_HAVE_PARALLEL - entry->clear_on_unprotect = FALSE; - entry->flush_immediately = FALSE; - entry->coll_access = coll_access; + entry->clear_on_unprotect = FALSE; + entry->flush_immediately = FALSE; + entry->coll_access = coll_access; #endif /* H5_HAVE_PARALLEL */ - entry->flush_in_progress = FALSE; - entry->destroy_in_progress = FALSE; - - entry->ring = H5C_RING_UNDEFINED; - - /* Initialize flush dependency fields */ - entry->flush_dep_parent = NULL; - entry->flush_dep_nparents = 0; - entry->flush_dep_parent_nalloc = 0; - entry->flush_dep_nchildren = 0; - entry->flush_dep_ndirty_children = 0; - entry->flush_dep_nunser_children = 0; - entry->ht_next = NULL; - entry->ht_prev = NULL; - entry->il_next = NULL; - entry->il_prev = NULL; - - entry->next = NULL; - entry->prev = NULL; + entry->flush_in_progress = FALSE; + entry->destroy_in_progress = FALSE; + + entry->ring = H5C_RING_UNDEFINED; + + /* Initialize flush dependency fields */ + entry->flush_dep_parent = NULL; + entry->flush_dep_nparents = 0; + entry->flush_dep_parent_nalloc = 0; + entry->flush_dep_nchildren = 0; + entry->flush_dep_ndirty_children = 0; + entry->flush_dep_nunser_children = 0; + entry->ht_next = NULL; + entry->ht_prev = NULL; + entry->il_next = NULL; + entry->il_prev = NULL; + + entry->next = NULL; + entry->prev = NULL; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - entry->aux_next = NULL; - entry->aux_prev = NULL; + entry->aux_next = NULL; + entry->aux_prev = NULL; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL - entry->coll_next = NULL; - entry->coll_prev = NULL; + entry->coll_next = NULL; + entry->coll_prev = NULL; #endif /* H5_HAVE_PARALLEL */ - /* initialize cache image related fields */ - entry->include_in_image = FALSE; - entry->lru_rank = 0; - entry->image_dirty = FALSE; - entry->fd_parent_count = 0; - entry->fd_parent_addrs = NULL; - entry->fd_child_count = 0; - entry->fd_dirty_child_count = 0; - entry->image_fd_height = 0; - entry->prefetched = FALSE; - entry->prefetch_type_id = 0; - entry->age = 0; - entry->prefetched_dirty = FALSE; -#ifndef NDEBUG /* debugging field */ - entry->serialization_count = 0; + /* initialize cache image related fields */ + entry->include_in_image = FALSE; + entry->lru_rank = 0; + entry->image_dirty = FALSE; + entry->fd_parent_count = 0; + entry->fd_parent_addrs = NULL; + entry->fd_child_count = 0; + entry->fd_dirty_child_count = 0; + entry->image_fd_height = 0; + entry->prefetched = FALSE; + entry->prefetch_type_id = 0; + entry->age = 0; + entry->prefetched_dirty = FALSE; +#ifndef NDEBUG /* debugging field */ + entry->serialization_count = 0; #endif /* NDEBUG */ - /* initialize tag list fields */ - entry->tl_next = NULL; - entry->tl_prev = NULL; - entry->tag_info = NULL; - - /* initialize fields supporting VFD SWMR */ - if ( f->shared->cache->vfd_swmr_reader ) { + /* initialize tag list fields */ + entry->tl_next = NULL; + entry->tl_prev = NULL; + entry->tag_info = NULL; - entry->page = (addr / f->shared->cache->page_size); + /* initialize fields supporting VFD SWMR */ + if (f->shared->cache->vfd_swmr_reader) { - } else { + entry->page = (addr / f->shared->cache->page_size); + } + else { - entry->page = 0; - } - entry->refreshed_in_tick = 0; - entry->pi_next = NULL; - entry->pi_prev = NULL; + entry->page = 0; + } + entry->refreshed_in_tick = 0; + entry->pi_next = NULL; + entry->pi_prev = NULL; - H5C__RESET_CACHE_ENTRY_STATS(entry); + H5C__RESET_CACHE_ENTRY_STATS(entry); - ret_value = thing; + ret_value = thing; done: - /* Cleanup on error */ - if(NULL == ret_value) { - /* Release resources */ - if(thing && type->free_icr(thing) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "free_icr callback failed") - if(image) - image = (uint8_t *)H5MM_xfree(image); - } /* end if */ + /* Cleanup on error */ + if (NULL == ret_value) { + /* Release resources */ + if (thing && type->free_icr(thing) < 0) + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "free_icr callback failed") + if (image) + image = (uint8_t *)H5MM_xfree(image); + } /* end if */ - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_load_entry() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_load_entry() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__make_space_in_cache - * - * Purpose: Attempt to evict cache entries until the index_size - * is at least needed_space below max_cache_size. - * - * In passing, also attempt to bring cLRU_list_size to a - * value greater than min_clean_size. - * - * Depending on circumstances, both of these goals may - * be impossible, as in parallel mode, we must avoid generating - * a write as part of a read (to avoid deadlock in collective - * I/O), and in all cases, it is possible (though hopefully - * highly unlikely) that the protected list may exceed the - * maximum size of the cache. - * - * Thus the function simply does its best, returning success - * unless an error is encountered. - * - * Observe that this function cannot occasion a read. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 5/14/04 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) -{ - H5C_t * cache_ptr = f->shared->cache; + /*------------------------------------------------------------------------- + * + * Function: H5C__make_space_in_cache + * + * Purpose: Attempt to evict cache entries until the index_size + * is at least needed_space below max_cache_size. + * + * In passing, also attempt to bring cLRU_list_size to a + * value greater than min_clean_size. + * + * Depending on circumstances, both of these goals may + * be impossible, as in parallel mode, we must avoid generating + * a write as part of a read (to avoid deadlock in collective + * I/O), and in all cases, it is possible (though hopefully + * highly unlikely) that the protected list may exceed the + * maximum size of the cache. + * + * Thus the function simply does its best, returning success + * unless an error is encountered. + * + * Observe that this function cannot occasion a read. + * + * Return: Non-negative on success/Negative on failure. + * + * Programmer: John Mainzer, 5/14/04 + * + *------------------------------------------------------------------------- + */ + herr_t H5C__make_space_in_cache(H5F_t * f, size_t space_needed, hbool_t write_permitted) + { + H5C_t *cache_ptr = f->shared->cache; #if H5C_COLLECT_CACHE_STATS - int32_t clean_entries_skipped = 0; - int32_t dirty_pf_entries_skipped = 0; - int32_t total_entries_scanned = 0; + int32_t clean_entries_skipped = 0; + int32_t dirty_pf_entries_skipped = 0; + int32_t total_entries_scanned = 0; #endif /* H5C_COLLECT_CACHE_STATS */ - uint32_t entries_examined = 0; - uint32_t initial_list_len; - size_t empty_space; - hbool_t reentrant_call = FALSE; - hbool_t prev_is_dirty = FALSE; - hbool_t didnt_flush_entry = FALSE; - hbool_t restart_scan; - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * prev_ptr; - H5C_cache_entry_t * next_ptr; - uint32_t num_corked_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE + uint32_t entries_examined = 0; + uint32_t initial_list_len; + size_t empty_space; + hbool_t reentrant_call = FALSE; + hbool_t prev_is_dirty = FALSE; + hbool_t didnt_flush_entry = FALSE; + hbool_t restart_scan; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *prev_ptr; + H5C_cache_entry_t *next_ptr; + uint32_t num_corked_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE - /* Sanity checks */ - HDassert(f); - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); + /* Sanity checks */ + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); + + /* check to see if cache_ptr->msic_in_progress is TRUE. If it, this + * is a re-entrant call via a client callback called in the make + * space in cache process. To avoid an infinite recursion, set + * reentrant_call to TRUE, and goto done. + */ + if (cache_ptr->msic_in_progress) { + reentrant_call = TRUE; + HGOTO_DONE(SUCCEED); + } /* end if */ - /* check to see if cache_ptr->msic_in_progress is TRUE. If it, this - * is a re-entrant call via a client callback called in the make - * space in cache process. To avoid an infinite recursion, set - * reentrant_call to TRUE, and goto done. - */ - if(cache_ptr->msic_in_progress) { - reentrant_call = TRUE; - HGOTO_DONE(SUCCEED); - } /* end if */ + cache_ptr->msic_in_progress = TRUE; - cache_ptr->msic_in_progress = TRUE; - - if ( write_permitted ) { - restart_scan = FALSE; - initial_list_len = cache_ptr->LRU_list_len; - entry_ptr = cache_ptr->LRU_tail_ptr; - - if(cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; - else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - - while ( ( ( (cache_ptr->index_size + space_needed) - > - cache_ptr->max_cache_size - ) - || - ( - ( empty_space + cache_ptr->clean_index_size ) - < - ( cache_ptr->min_clean_size ) - ) - ) - && - ( entries_examined <= (2 * initial_list_len) ) - && - ( entry_ptr != NULL ) - ) - { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert( !(entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( (entry_ptr->ro_ref_count) == 0 ); + if (write_permitted) { + restart_scan = FALSE; + initial_list_len = cache_ptr->LRU_list_len; + entry_ptr = cache_ptr->LRU_tail_ptr; + + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; + else + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - next_ptr = entry_ptr->next; - prev_ptr = entry_ptr->prev; + while ((((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < (cache_ptr->min_clean_size))) && + (entries_examined <= (2 * initial_list_len)) && (entry_ptr != NULL)) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert((entry_ptr->ro_ref_count) == 0); - if(prev_ptr != NULL) - prev_is_dirty = prev_ptr->is_dirty; + next_ptr = entry_ptr->next; + prev_ptr = entry_ptr->prev; - if(entry_ptr->is_dirty && - (entry_ptr->tag_info && entry_ptr->tag_info->corked)) { + if (prev_ptr != NULL) + prev_is_dirty = prev_ptr->is_dirty; - /* Skip "dirty" corked entries. */ - ++num_corked_entries; - didnt_flush_entry = TRUE; + if (entry_ptr->is_dirty && (entry_ptr->tag_info && entry_ptr->tag_info->corked)) { - } else if ( ( (entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID ) && - ( ! entry_ptr->flush_in_progress ) && - ( ! entry_ptr->prefetched_dirty ) ) { + /* Skip "dirty" corked entries. */ + ++num_corked_entries; + didnt_flush_entry = TRUE; + } + else if (((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && (!entry_ptr->flush_in_progress) && + (!entry_ptr->prefetched_dirty)) { - didnt_flush_entry = FALSE; + didnt_flush_entry = FALSE; - if ( entry_ptr->is_dirty ) { + if (entry_ptr->is_dirty) { #if H5C_COLLECT_CACHE_STATS - if ( (cache_ptr->index_size + space_needed) - > - cache_ptr->max_cache_size ) { + if ((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) { - cache_ptr->entries_scanned_to_make_space++; - } + cache_ptr->entries_scanned_to_make_space++; + } #endif /* H5C_COLLECT_CACHE_STATS */ - /* reset entries_removed_counter and - * last_entry_removed_ptr prior to the call to - * H5C__flush_single_entry() so that we can spot - * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry - * that is no longer in the cache. - */ - cache_ptr->entries_removed_counter = 0; - cache_ptr->last_entry_removed_ptr = NULL; - - if(H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + /* reset entries_removed_counter and + * last_entry_removed_ptr prior to the call to + * H5C__flush_single_entry() so that we can spot + * unexpected removals of entries from the cache, + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry + * that is no longer in the cache. + */ + cache_ptr->entries_removed_counter = 0; + cache_ptr->last_entry_removed_ptr = NULL; - if ( ( cache_ptr->entries_removed_counter > 1 ) || - ( cache_ptr->last_entry_removed_ptr == prev_ptr ) ) + if (H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - restart_scan = TRUE; + if ((cache_ptr->entries_removed_counter > 1) || + (cache_ptr->last_entry_removed_ptr == prev_ptr)) - } else if ( (cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size + restart_scan = TRUE; + } + else if ((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size #ifdef H5_HAVE_PARALLEL - && !(entry_ptr->coll_access) + && !(entry_ptr->coll_access) #endif /* H5_HAVE_PARALLEL */ - ) { + ) { #if H5C_COLLECT_CACHE_STATS - cache_ptr->entries_scanned_to_make_space++; + cache_ptr->entries_scanned_to_make_space++; #endif /* H5C_COLLECT_CACHE_STATS */ - if(H5C__flush_single_entry(f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } else { - /* We have enough space so don't flush clean entry. */ + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + } + else { + /* We have enough space so don't flush clean entry. */ #if H5C_COLLECT_CACHE_STATS - clean_entries_skipped++; + clean_entries_skipped++; #endif /* H5C_COLLECT_CACHE_STATS */ - didnt_flush_entry = TRUE; - } + didnt_flush_entry = TRUE; + } #if H5C_COLLECT_CACHE_STATS - total_entries_scanned++; + total_entries_scanned++; #endif /* H5C_COLLECT_CACHE_STATS */ + } + else { - } else { - - /* Skip epoch markers, entries that are in the process - * of being flushed, and entries marked as prefetched_dirty - * (occurs in the R/O case only). - */ - didnt_flush_entry = TRUE; + /* Skip epoch markers, entries that are in the process + * of being flushed, and entries marked as prefetched_dirty + * (occurs in the R/O case only). + */ + didnt_flush_entry = TRUE; #if H5C_COLLECT_CACHE_STATS - if(entry_ptr->prefetched_dirty) - dirty_pf_entries_skipped++; + if (entry_ptr->prefetched_dirty) + dirty_pf_entries_skipped++; #endif /* H5C_COLLECT_CACHE_STATS */ - } - - if ( prev_ptr != NULL ) { - - if ( didnt_flush_entry ) { - - /* epoch markers don't get flushed, and we don't touch - * entries that are in the process of being flushed. - * Hence no need for sanity checks, as we haven't - * flushed anything. Thus just set entry_ptr to prev_ptr - * and go on. - */ - entry_ptr = prev_ptr; - - } else if ( ( restart_scan ) - || - ( prev_ptr->is_dirty != prev_is_dirty ) - || - ( prev_ptr->next != next_ptr ) - || - ( prev_ptr->is_protected ) - || - ( prev_ptr->is_pinned ) ) { - - /* something has happened to the LRU -- start over - * from the tail. - */ - restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; - H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) - - } else { - - entry_ptr = prev_ptr; + } - } - } else { + if (prev_ptr != NULL) { - entry_ptr = NULL; + if (didnt_flush_entry) { - } + /* epoch markers don't get flushed, and we don't touch + * entries that are in the process of being flushed. + * Hence no need for sanity checks, as we haven't + * flushed anything. Thus just set entry_ptr to prev_ptr + * and go on. + */ + entry_ptr = prev_ptr; + } + else if ((restart_scan) || (prev_ptr->is_dirty != prev_is_dirty) || + (prev_ptr->next != next_ptr) || (prev_ptr->is_protected) || + (prev_ptr->is_pinned)) { - entries_examined++; + /* something has happened to the LRU -- start over + * from the tail. + */ + restart_scan = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; + H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) + } + else { - if ( cache_ptr->index_size >= cache_ptr->max_cache_size ) { + entry_ptr = prev_ptr; + } + } + else { - empty_space = 0; + entry_ptr = NULL; + } - } else { + entries_examined++; - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + if (cache_ptr->index_size >= cache_ptr->max_cache_size) { - } + empty_space = 0; + } + else { - HDassert( cache_ptr->index_size == - (cache_ptr->clean_index_size + - cache_ptr->dirty_index_size) ); + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + } - } + HDassert(cache_ptr->index_size == + (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); + } #if H5C_COLLECT_CACHE_STATS - cache_ptr->calls_to_msic++; + cache_ptr->calls_to_msic++; - cache_ptr->total_entries_skipped_in_msic += clean_entries_skipped; - cache_ptr->total_dirty_pf_entries_skipped_in_msic += dirty_pf_entries_skipped; - cache_ptr->total_entries_scanned_in_msic += total_entries_scanned; + cache_ptr->total_entries_skipped_in_msic += clean_entries_skipped; + cache_ptr->total_dirty_pf_entries_skipped_in_msic += dirty_pf_entries_skipped; + cache_ptr->total_entries_scanned_in_msic += total_entries_scanned; - if ( clean_entries_skipped > cache_ptr->max_entries_skipped_in_msic ) { + if (clean_entries_skipped > cache_ptr->max_entries_skipped_in_msic) { - cache_ptr->max_entries_skipped_in_msic = clean_entries_skipped; - } + cache_ptr->max_entries_skipped_in_msic = clean_entries_skipped; + } - if(dirty_pf_entries_skipped > cache_ptr->max_dirty_pf_entries_skipped_in_msic) - cache_ptr->max_dirty_pf_entries_skipped_in_msic = dirty_pf_entries_skipped; + if (dirty_pf_entries_skipped > cache_ptr->max_dirty_pf_entries_skipped_in_msic) + cache_ptr->max_dirty_pf_entries_skipped_in_msic = dirty_pf_entries_skipped; - if ( total_entries_scanned > cache_ptr->max_entries_scanned_in_msic ) { + if (total_entries_scanned > cache_ptr->max_entries_scanned_in_msic) { - cache_ptr->max_entries_scanned_in_msic = total_entries_scanned; - } + cache_ptr->max_entries_scanned_in_msic = total_entries_scanned; + } #endif /* H5C_COLLECT_CACHE_STATS */ - - /* NEED: work on a better assert for corked entries */ - HDassert( ( entries_examined > (2 * initial_list_len) ) || - ( (cache_ptr->pl_size + cache_ptr->pel_size + cache_ptr->min_clean_size) > - cache_ptr->max_cache_size ) || - ( ( cache_ptr->clean_index_size + empty_space ) - >= cache_ptr->min_clean_size ) || - ( ( num_corked_entries ))); + /* NEED: work on a better assert for corked entries */ + HDassert((entries_examined > (2 * initial_list_len)) || + ((cache_ptr->pl_size + cache_ptr->pel_size + cache_ptr->min_clean_size) > + cache_ptr->max_cache_size) || + ((cache_ptr->clean_index_size + empty_space) >= cache_ptr->min_clean_size) || + ((num_corked_entries))); #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - HDassert( ( entries_examined > (2 * initial_list_len) ) || - ( cache_ptr->cLRU_list_size <= cache_ptr->clean_index_size ) ); - HDassert( ( entries_examined > (2 * initial_list_len) ) || - ( cache_ptr->dLRU_list_size <= cache_ptr->dirty_index_size ) ); + HDassert((entries_examined > (2 * initial_list_len)) || + (cache_ptr->cLRU_list_size <= cache_ptr->clean_index_size)); + HDassert((entries_examined > (2 * initial_list_len)) || + (cache_ptr->dLRU_list_size <= cache_ptr->dirty_index_size)); #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + } + else { - } else { - - HDassert( H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS ); + HDassert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - initial_list_len = cache_ptr->cLRU_list_len; - entry_ptr = cache_ptr->cLRU_tail_ptr; - - while ( ( (cache_ptr->index_size + space_needed) - > - cache_ptr->max_cache_size - ) - && - ( entries_examined <= initial_list_len ) - && - ( entry_ptr != NULL ) - ) - { - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( (entry_ptr->ro_ref_count) == 0 ); - HDassert( ! (entry_ptr->is_dirty) ); + initial_list_len = cache_ptr->cLRU_list_len; + entry_ptr = cache_ptr->cLRU_tail_ptr; - prev_ptr = entry_ptr->aux_prev; + while (((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) && + (entries_examined <= initial_list_len) && (entry_ptr != NULL)) { + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert((entry_ptr->ro_ref_count) == 0); + HDassert(!(entry_ptr->is_dirty)); - if ( ( !(entry_ptr->prefetched_dirty) ) + prev_ptr = entry_ptr->aux_prev; + + if ((!(entry_ptr->prefetched_dirty)) #ifdef H5_HAVE_PARALLEL - && ( ! (entry_ptr->coll_access) ) + && (!(entry_ptr->coll_access)) #endif /* H5_HAVE_PARALLEL */ - ) { - if(H5C__flush_single_entry(f, entry_ptr, - H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + ) { + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } /* end if */ + } /* end if */ - /* we are scanning the clean LRU, so the serialize function - * will not be called on any entry -- thus there is no - * concern about the list being modified out from under - * this function. - */ + /* we are scanning the clean LRU, so the serialize function + * will not be called on any entry -- thus there is no + * concern about the list being modified out from under + * this function. + */ - entry_ptr = prev_ptr; - entries_examined++; - } + entry_ptr = prev_ptr; + entries_examined++; + } #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - } + } done: - /* Sanity checks */ - HDassert(cache_ptr->msic_in_progress); - if(!reentrant_call) - cache_ptr->msic_in_progress = FALSE; - HDassert((!reentrant_call) || (cache_ptr->msic_in_progress)); + /* Sanity checks */ + HDassert(cache_ptr->msic_in_progress); + if (!reentrant_call) + cache_ptr->msic_in_progress = FALSE; + HDassert((!reentrant_call) || (cache_ptr->msic_in_progress)); - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__make_space_in_cache() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__make_space_in_cache() */ - /*------------------------------------------------------------------------- * * Function: H5C_validate_lru_list @@ -7983,111 +7638,84 @@ done: */ #if H5C_DO_EXTREME_SANITY_CHECKS -static herr_t -H5C_validate_lru_list(H5C_t * cache_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t * entry_ptr = NULL; + static herr_t H5C_validate_lru_list(H5C_t * cache_ptr) + { + herr_t ret_value = SUCCEED; /* Return value */ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if ( ( ( cache_ptr->LRU_head_ptr == NULL ) - || - ( cache_ptr->LRU_tail_ptr == NULL ) - ) - && - ( cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr ) - ) { + if (((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_tail_ptr == NULL)) && + (cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr)) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") + } - if(cache_ptr->LRU_list_len < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") + if (cache_ptr->LRU_list_len < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - if ( ( cache_ptr->LRU_list_len == 1 ) - && - ( ( cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr ) - || - ( cache_ptr->LRU_head_ptr == NULL ) - || - ( cache_ptr->LRU_head_ptr->size != cache_ptr->LRU_list_size ) - ) - ) { + if ((cache_ptr->LRU_list_len == 1) && + ((cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr) || (cache_ptr->LRU_head_ptr == NULL) || + (cache_ptr->LRU_head_ptr->size != cache_ptr->LRU_list_size))) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") + } - if ( ( cache_ptr->LRU_list_len >= 1 ) - && - ( ( cache_ptr->LRU_head_ptr == NULL ) - || - ( cache_ptr->LRU_head_ptr->prev != NULL ) - || - ( cache_ptr->LRU_tail_ptr == NULL ) - || - ( cache_ptr->LRU_tail_ptr->next != NULL ) - ) - ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") - } + if ((cache_ptr->LRU_list_len >= 1) && + ((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_head_ptr->prev != NULL) || + (cache_ptr->LRU_tail_ptr == NULL) || (cache_ptr->LRU_tail_ptr->next != NULL))) { - entry_ptr = cache_ptr->LRU_head_ptr; - while ( entry_ptr != NULL ) - { + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") + } - if ( ( entry_ptr != cache_ptr->LRU_head_ptr ) && - ( ( entry_ptr->prev == NULL ) || - ( entry_ptr->prev->next != entry_ptr ) ) ) { + entry_ptr = cache_ptr->LRU_head_ptr; + while (entry_ptr != NULL) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") - } + if ((entry_ptr != cache_ptr->LRU_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) { - if ( ( entry_ptr != cache_ptr->LRU_tail_ptr ) && - ( ( entry_ptr->next == NULL ) || - ( entry_ptr->next->prev != entry_ptr ) ) ) { + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") + } - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") - } + if ((entry_ptr != cache_ptr->LRU_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) { - if ( ( entry_ptr->is_pinned ) || - ( entry_ptr->pinned_from_client ) || - ( entry_ptr->pinned_from_cache ) ) { + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") + } - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") - } + if ((entry_ptr->is_pinned) || (entry_ptr->pinned_from_client) || (entry_ptr->pinned_from_cache)) { - len++; - size += entry_ptr->size; - entry_ptr = entry_ptr->next; - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") + } - if ( ( cache_ptr->LRU_list_len != len ) || - ( cache_ptr->LRU_list_size != size ) ) { + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") - } + if ((cache_ptr->LRU_list_len != len) || (cache_ptr->LRU_list_size != size)) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") + } done: - if ( ret_value != SUCCEED ) { + if (ret_value != SUCCEED) { - HDassert(0); - } + HDassert(0); + } - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_validate_lru_list() */ + } /* H5C_validate_lru_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - /*------------------------------------------------------------------------- * * Function: H5C_validate_pinned_entry_list @@ -8111,115 +7739,89 @@ done: */ #if H5C_DO_EXTREME_SANITY_CHECKS -static herr_t -H5C_validate_pinned_entry_list(H5C_t * cache_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t * entry_ptr = NULL; + static herr_t H5C_validate_pinned_entry_list(H5C_t * cache_ptr) + { + herr_t ret_value = SUCCEED; /* Return value */ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if ( ( ( cache_ptr->pel_head_ptr == NULL ) - || - ( cache_ptr->pel_tail_ptr == NULL ) - ) - && - ( cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr ) - ) { + if (((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_tail_ptr == NULL)) && + (cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr)) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") + } - if(cache_ptr->pel_len < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") + if (cache_ptr->pel_len < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - if ( ( cache_ptr->pel_len == 1 ) - && - ( ( cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr ) - || - ( cache_ptr->pel_head_ptr == NULL ) - || - ( cache_ptr->pel_head_ptr->size != cache_ptr->pel_size ) - ) - ) { + if ((cache_ptr->pel_len == 1) && + ((cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr) || (cache_ptr->pel_head_ptr == NULL) || + (cache_ptr->pel_head_ptr->size != cache_ptr->pel_size))) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") + } - if ( ( cache_ptr->pel_len >= 1 ) - && - ( ( cache_ptr->pel_head_ptr == NULL ) - || - ( cache_ptr->pel_head_ptr->prev != NULL ) - || - ( cache_ptr->pel_tail_ptr == NULL ) - || - ( cache_ptr->pel_tail_ptr->next != NULL ) - ) - ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") - } + if ((cache_ptr->pel_len >= 1) && + ((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_head_ptr->prev != NULL) || + (cache_ptr->pel_tail_ptr == NULL) || (cache_ptr->pel_tail_ptr->next != NULL))) { - entry_ptr = cache_ptr->pel_head_ptr; - while ( entry_ptr != NULL ) - { + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") + } - if ( ( entry_ptr != cache_ptr->pel_head_ptr ) && - ( ( entry_ptr->prev == NULL ) || - ( entry_ptr->prev->next != entry_ptr ) ) ) { + entry_ptr = cache_ptr->pel_head_ptr; + while (entry_ptr != NULL) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") - } + if ((entry_ptr != cache_ptr->pel_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) { - if ( ( entry_ptr != cache_ptr->pel_tail_ptr ) && - ( ( entry_ptr->next == NULL ) || - ( entry_ptr->next->prev != entry_ptr ) ) ) { + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") + } - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") - } + if ((entry_ptr != cache_ptr->pel_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) { - if ( ! entry_ptr->is_pinned ) { + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") + } - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") - } + if (!entry_ptr->is_pinned) { - if ( ! ( ( entry_ptr->pinned_from_client ) || - ( entry_ptr->pinned_from_cache ) ) ) { + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") + } - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") - } + if (!((entry_ptr->pinned_from_client) || (entry_ptr->pinned_from_cache))) { - len++; - size += entry_ptr->size; - entry_ptr = entry_ptr->next; - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") + } - if ( ( cache_ptr->pel_len != len ) || - ( cache_ptr->pel_size != size ) ) { + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 9 failed") - } + if ((cache_ptr->pel_len != len) || (cache_ptr->pel_size != size)) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 9 failed") + } done: - if ( ret_value != SUCCEED ) { + if (ret_value != SUCCEED) { - HDassert(0); - } + HDassert(0); + } - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_validate_pinned_entry_list() */ + } /* H5C_validate_pinned_entry_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - /*------------------------------------------------------------------------- * * Function: H5C_validate_protected_entry_list @@ -8243,108 +7845,87 @@ done: */ #if H5C_DO_EXTREME_SANITY_CHECKS -static herr_t -H5C_validate_protected_entry_list(H5C_t * cache_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t * entry_ptr = NULL; - - FUNC_ENTER_NOAPI_NOINIT - - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - - if(((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) - && (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - - if(cache_ptr->pl_len < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - - if ( ( cache_ptr->pl_len == 1 ) - && - ( ( cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr ) - || - ( cache_ptr->pl_head_ptr == NULL ) - || - ( cache_ptr->pl_head_ptr->size != cache_ptr->pl_size ) - ) - ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") - } + static herr_t H5C_validate_protected_entry_list(H5C_t * cache_ptr) + { + herr_t ret_value = SUCCEED; /* Return value */ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; - if ( ( cache_ptr->pl_len >= 1 ) - && - ( ( cache_ptr->pl_head_ptr == NULL ) - || - ( cache_ptr->pl_head_ptr->prev != NULL ) - || - ( cache_ptr->pl_tail_ptr == NULL ) - || - ( cache_ptr->pl_tail_ptr->next != NULL ) - ) - ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") - } + FUNC_ENTER_NOAPI_NOINIT - entry_ptr = cache_ptr->pl_head_ptr; - while ( entry_ptr != NULL ) - { + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if ( ( entry_ptr != cache_ptr->pl_head_ptr ) && - ( ( entry_ptr->prev == NULL ) || - ( entry_ptr->prev->next != entry_ptr ) ) ) { + if (((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) && + (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") - } + if (cache_ptr->pl_len < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - if ( ( entry_ptr != cache_ptr->pl_tail_ptr ) && - ( ( entry_ptr->next == NULL ) || - ( entry_ptr->next->prev != entry_ptr ) ) ) { + if ((cache_ptr->pl_len == 1) && + ((cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr) || (cache_ptr->pl_head_ptr == NULL) || + (cache_ptr->pl_head_ptr->size != cache_ptr->pl_size))) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") } - if ( ! entry_ptr->is_protected ) { + if ((cache_ptr->pl_len >= 1) && + ((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_head_ptr->prev != NULL) || + (cache_ptr->pl_tail_ptr == NULL) || (cache_ptr->pl_tail_ptr->next != NULL))) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") } - if ( ( entry_ptr->is_read_only ) && - ( entry_ptr->ro_ref_count <= 0 ) ) { + entry_ptr = cache_ptr->pl_head_ptr; + while (entry_ptr != NULL) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") - } + if ((entry_ptr != cache_ptr->pl_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) { - len++; - size += entry_ptr->size; - entry_ptr = entry_ptr->next; - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") + } - if ( ( cache_ptr->pl_len != len ) || - ( cache_ptr->pl_size != size ) ) { + if ((entry_ptr != cache_ptr->pl_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 9 failed") - } + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") + } + + if (!entry_ptr->is_protected) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") + } + + if ((entry_ptr->is_read_only) && (entry_ptr->ro_ref_count <= 0)) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") + } + + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } + + if ((cache_ptr->pl_len != len) || (cache_ptr->pl_size != size)) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 9 failed") + } done: - if ( ret_value != SUCCEED ) { + if (ret_value != SUCCEED) { - HDassert(0); - } + HDassert(0); + } - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_validate_protected_entry_list() */ + } /* H5C_validate_protected_entry_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - /*------------------------------------------------------------------------- * * Function: H5C_entry_in_skip_list @@ -8366,1280 +7947,1255 @@ done: */ #if H5C_DO_SLIST_SANITY_CHECKS -static hbool_t -H5C_entry_in_skip_list(H5C_t * cache_ptr, H5C_cache_entry_t *target_ptr) -{ - hbool_t in_slist = FALSE; - H5SL_node_t * node_ptr = NULL; - H5C_cache_entry_t * entry_ptr = NULL; - - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( cache_ptr->slist_ptr ); + static hbool_t H5C_entry_in_skip_list(H5C_t * cache_ptr, H5C_cache_entry_t * target_ptr) + { + hbool_t in_slist = FALSE; + H5SL_node_t * node_ptr = NULL; + H5C_cache_entry_t *entry_ptr = NULL; - node_ptr = H5SL_first(cache_ptr->slist_ptr); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->slist_ptr); - while ( ( node_ptr != NULL ) && ( ! in_slist ) ) - { - entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + node_ptr = H5SL_first(cache_ptr->slist_ptr); - HDassert( entry_ptr ); - HDassert( entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC ); - HDassert( entry_ptr->is_dirty ); - HDassert( entry_ptr->in_slist ); + while ((node_ptr != NULL) && (!in_slist)) { + entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if ( entry_ptr == target_ptr ) { + HDassert(entry_ptr); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->in_slist); - in_slist = TRUE; + if (entry_ptr == target_ptr) { - } else { + in_slist = TRUE; + } + else { - node_ptr = H5SL_next(node_ptr); - } - } + node_ptr = H5SL_next(node_ptr); + } + } - return(in_slist); + return (in_slist); -} /* H5C_entry_in_skip_list() */ + } /* H5C_entry_in_skip_list() */ #endif /* H5C_DO_SLIST_SANITY_CHECKS */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__flush_marked_entries - * - * Purpose: Flushes all marked entries in the cache. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Mike McGreevy - * November 3, 2010 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__flush_marked_entries(H5F_t * f) -{ - herr_t ret_value = SUCCEED; + /*------------------------------------------------------------------------- + * + * Function: H5C__flush_marked_entries + * + * Purpose: Flushes all marked entries in the cache. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + * Programmer: Mike McGreevy + * November 3, 2010 + * + *------------------------------------------------------------------------- + */ + herr_t H5C__flush_marked_entries(H5F_t * f) + { + herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE - /* Assertions */ - HDassert(f != NULL); + /* Assertions */ + HDassert(f != NULL); - /* Flush all marked entries */ - if(H5C_flush_cache(f, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_IGNORE_PROTECTED_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") + /* Flush all marked entries */ + if (H5C_flush_cache(f, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_IGNORE_PROTECTED_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_marked_entries */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__flush_marked_entries */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_cork - * - * Purpose: To cork/uncork/get cork status of an object depending on "action": - * H5C__SET_CORK: - * To cork the object - * Return error if the object is already corked - * H5C__UNCORK: - * To uncork the obejct - * Return error if the object is not corked - * H5C__GET_CORKED: - * To retrieve the cork status of an object in - * the parameter "corked" - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Vailin Choi - * January 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) -{ - H5C_tag_info_t *tag_info; /* Points to a tag info struct */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Assertions */ - HDassert(cache_ptr != NULL); - HDassert(H5F_addr_defined(obj_addr)); - HDassert(action == H5C__SET_CORK || action == H5C__UNCORK || action == H5C__GET_CORKED); + /*------------------------------------------------------------------------- + * + * Function: H5C_cork + * + * Purpose: To cork/uncork/get cork status of an object depending on "action": + * H5C__SET_CORK: + * To cork the object + * Return error if the object is already corked + * H5C__UNCORK: + * To uncork the obejct + * Return error if the object is not corked + * H5C__GET_CORKED: + * To retrieve the cork status of an object in + * the parameter "corked" + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * January 2014 + * + *------------------------------------------------------------------------- + */ + herr_t H5C_cork(H5C_t * cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) + { + H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + herr_t ret_value = SUCCEED; - /* Search the list of corked object addresses in the cache */ - tag_info = (H5C_tag_info_t *)H5SL_search(cache_ptr->tag_list, &obj_addr); + FUNC_ENTER_NOAPI_NOINIT - if(H5C__GET_CORKED == action) { - HDassert(corked); - if(tag_info != NULL && tag_info->corked) - *corked = TRUE; - else - *corked = FALSE; - } /* end if */ - else { - /* Sanity check */ - HDassert(H5C__SET_CORK == action || H5C__UNCORK == action); - - /* Perform appropriate action */ - if(H5C__SET_CORK == action) { - /* Check if this is the first entry for this tagged object */ - if(NULL == tag_info) { - /* Allocate new tag info struct */ - if(NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate tag info for cache entry") - - /* Set the tag for all entries */ - tag_info->tag = obj_addr; - - /* Insert tag info into skip list */ - if(H5SL_insert(cache_ptr->tag_list, tag_info, &(tag_info->tag)) < 0 ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert tag info in skip list") - } /* end if */ - else { - /* Check for object already corked */ - if(tag_info->corked) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCORK, FAIL, "object already corked") - HDassert(tag_info->entry_cnt > 0 && tag_info->head); - } /* end else */ + /* Assertions */ + HDassert(cache_ptr != NULL); + HDassert(H5F_addr_defined(obj_addr)); + HDassert(action == H5C__SET_CORK || action == H5C__UNCORK || action == H5C__GET_CORKED); - /* Set the corked status for the entire object */ - tag_info->corked = TRUE; - cache_ptr->num_objs_corked++; + /* Search the list of corked object addresses in the cache */ + tag_info = (H5C_tag_info_t *)H5SL_search(cache_ptr->tag_list, &obj_addr); + if (H5C__GET_CORKED == action) { + HDassert(corked); + if (tag_info != NULL && tag_info->corked) + *corked = TRUE; + else + *corked = FALSE; } /* end if */ else { /* Sanity check */ - HDassert(tag_info); - - /* Check for already uncorked */ - if(!tag_info->corked) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNCORK, FAIL, "object already uncorked") + HDassert(H5C__SET_CORK == action || H5C__UNCORK == action); + + /* Perform appropriate action */ + if (H5C__SET_CORK == action) { + /* Check if this is the first entry for this tagged object */ + if (NULL == tag_info) { + /* Allocate new tag info struct */ + if (NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate tag info for cache entry") + + /* Set the tag for all entries */ + tag_info->tag = obj_addr; + + /* Insert tag info into skip list */ + if (H5SL_insert(cache_ptr->tag_list, tag_info, &(tag_info->tag)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert tag info in skip list") + } /* end if */ + else { + /* Check for object already corked */ + if (tag_info->corked) + HGOTO_ERROR(H5E_CACHE, H5E_CANTCORK, FAIL, "object already corked") + HDassert(tag_info->entry_cnt > 0 && tag_info->head); + } /* end else */ - /* Set the corked status for the entire object */ - tag_info->corked = FALSE; - cache_ptr->num_objs_corked--; + /* Set the corked status for the entire object */ + tag_info->corked = TRUE; + cache_ptr->num_objs_corked++; - /* Remove the tag info from the tag list, if there's no more entries with this tag */ - if(0 == tag_info->entry_cnt) { + } /* end if */ + else { /* Sanity check */ - HDassert(NULL == tag_info->head); + HDassert(tag_info); - if(H5SL_remove(cache_ptr->tag_list, &(tag_info->tag)) != tag_info) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove tag info from list") + /* Check for already uncorked */ + if (!tag_info->corked) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNCORK, FAIL, "object already uncorked") - /* Release the tag info */ - tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); - } /* end if */ - else - HDassert(NULL != tag_info->head); - } /* end else */ - } /* end else */ + /* Set the corked status for the entire object */ + tag_info->corked = FALSE; + cache_ptr->num_objs_corked--; -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_cork() */ + /* Remove the tag info from the tag list, if there's no more entries with this tag */ + if (0 == tag_info->entry_cnt) { + /* Sanity check */ + HDassert(NULL == tag_info->head); - -/*------------------------------------------------------------------------- - * Function: H5C__mark_flush_dep_dirty() - * - * Purpose: Recursively propagate the flush_dep_ndirty_children flag - * up the dependency chain in response to entry either - * becoming dirty or having its flush_dep_ndirty_children - * increased from 0. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * 11/13/12 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__mark_flush_dep_dirty(H5C_cache_entry_t * entry) -{ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + if (H5SL_remove(cache_ptr->tag_list, &(tag_info->tag)) != tag_info) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove tag info from list") - FUNC_ENTER_STATIC + /* Release the tag info */ + tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); + } /* end if */ + else + HDassert(NULL != tag_info->head); + } /* end else */ + } /* end else */ - /* Sanity checks */ - HDassert(entry); +done: + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C_cork() */ + + /*------------------------------------------------------------------------- + * Function: H5C__mark_flush_dep_dirty() + * + * Purpose: Recursively propagate the flush_dep_ndirty_children flag + * up the dependency chain in response to entry either + * becoming dirty or having its flush_dep_ndirty_children + * increased from 0. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * 11/13/12 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__mark_flush_dep_dirty(H5C_cache_entry_t * entry) + { + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - /* Iterate over the parent entries, if any */ - for(u = 0; u < entry->flush_dep_nparents; u++) { - /* Sanity check */ - HDassert(entry->flush_dep_parent[u]->flush_dep_ndirty_children < entry->flush_dep_parent[u]->flush_dep_nchildren); + FUNC_ENTER_STATIC - /* Adjust the parent's number of dirty children */ - entry->flush_dep_parent[u]->flush_dep_ndirty_children++; + /* Sanity checks */ + HDassert(entry); - /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ - if(entry->flush_dep_parent[u]->type->notify && - (entry->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, entry->flush_dep_parent[u]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry dirty flag set") - } /* end for */ + /* Iterate over the parent entries, if any */ + for (u = 0; u < entry->flush_dep_nparents; u++) { + /* Sanity check */ + HDassert(entry->flush_dep_parent[u]->flush_dep_ndirty_children < + entry->flush_dep_parent[u]->flush_dep_nchildren); + + /* Adjust the parent's number of dirty children */ + entry->flush_dep_parent[u]->flush_dep_ndirty_children++; + + /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ + if (entry->flush_dep_parent[u]->type->notify && + (entry->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, + entry->flush_dep_parent[u]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag set") + } /* end for */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_flush_dep_dirty() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__mark_flush_dep_dirty() */ - -/*------------------------------------------------------------------------- - * Function: H5C__mark_flush_dep_clean() - * - * Purpose: Recursively propagate the flush_dep_ndirty_children flag - * up the dependency chain in response to entry either - * becoming clean or having its flush_dep_ndirty_children - * reduced to 0. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * 11/13/12 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__mark_flush_dep_clean(H5C_cache_entry_t * entry) -{ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5C__mark_flush_dep_clean() + * + * Purpose: Recursively propagate the flush_dep_ndirty_children flag + * up the dependency chain in response to entry either + * becoming clean or having its flush_dep_ndirty_children + * reduced to 0. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * 11/13/12 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__mark_flush_dep_clean(H5C_cache_entry_t * entry) + { + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - /* Sanity checks */ - HDassert(entry); + /* Sanity checks */ + HDassert(entry); - /* Iterate over the parent entries, if any */ - /* Note reverse iteration order, in case the callback removes the flush - * dependency - QAK, 2017/08/12 - */ - for(i = ((int)entry->flush_dep_nparents) - 1; i >= 0; i--) { - /* Sanity check */ - HDassert(entry->flush_dep_parent[i]->flush_dep_ndirty_children > 0); + /* Iterate over the parent entries, if any */ + /* Note reverse iteration order, in case the callback removes the flush + * dependency - QAK, 2017/08/12 + */ + for (i = ((int)entry->flush_dep_nparents) - 1; i >= 0; i--) { + /* Sanity check */ + HDassert(entry->flush_dep_parent[i]->flush_dep_ndirty_children > 0); - /* Adjust the parent's number of dirty children */ - entry->flush_dep_parent[i]->flush_dep_ndirty_children--; + /* Adjust the parent's number of dirty children */ + entry->flush_dep_parent[i]->flush_dep_ndirty_children--; - /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ - if(entry->flush_dep_parent[i]->type->notify && - (entry->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, entry->flush_dep_parent[i]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry dirty flag reset") - } /* end for */ + /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ + if (entry->flush_dep_parent[i]->type->notify && + (entry->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, + entry->flush_dep_parent[i]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag reset") + } /* end for */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_flush_dep_clean() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__mark_flush_dep_clean() */ - -/*------------------------------------------------------------------------- - * Function: H5C__mark_flush_dep_serialized() - * - * Purpose: Decrement the flush_dep_nunser_children fields of all the - * target entry's flush dependency parents in response to - * the target entry becoming serialized. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 8/30/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr) -{ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5C__mark_flush_dep_serialized() + * + * Purpose: Decrement the flush_dep_nunser_children fields of all the + * target entry's flush dependency parents in response to + * the target entry becoming serialized. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 8/30/16 + * + *------------------------------------------------------------------------- + */ + herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr) + { + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - /* Sanity checks */ - HDassert(entry_ptr); + /* Sanity checks */ + HDassert(entry_ptr); - /* Iterate over the parent entries, if any */ - /* Note reverse iteration order, in case the callback removes the flush - * dependency - QAK, 2017/08/12 - */ - for(i = ((int)entry_ptr->flush_dep_nparents) - 1; i >= 0; i--) { - /* Sanity checks */ - HDassert(entry_ptr->flush_dep_parent); - HDassert(entry_ptr->flush_dep_parent[i]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children > 0); - - /* decrement the parents number of unserialized children */ - entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children--; - - /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ - if(entry_ptr->flush_dep_parent[i]->type->notify && - (entry_ptr->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, entry_ptr->flush_dep_parent[i]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry serialized flag set") - } /* end for */ + /* Iterate over the parent entries, if any */ + /* Note reverse iteration order, in case the callback removes the flush + * dependency - QAK, 2017/08/12 + */ + for (i = ((int)entry_ptr->flush_dep_nparents) - 1; i >= 0; i--) { + /* Sanity checks */ + HDassert(entry_ptr->flush_dep_parent); + HDassert(entry_ptr->flush_dep_parent[i]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children > 0); + + /* decrement the parents number of unserialized children */ + entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children--; + + /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ + if (entry_ptr->flush_dep_parent[i]->type->notify && + (entry_ptr->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, + entry_ptr->flush_dep_parent[i]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag set") + } /* end for */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_flush_dep_serialized() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__mark_flush_dep_serialized() */ - -/*------------------------------------------------------------------------- - * Function: H5C__mark_flush_dep_unserialized() - * - * Purpose: Increment the flush_dep_nunser_children fields of all the - * target entry's flush dependency parents in response to - * the target entry becoming unserialized. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 8/30/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr) -{ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5C__mark_flush_dep_unserialized() + * + * Purpose: Increment the flush_dep_nunser_children fields of all the + * target entry's flush dependency parents in response to + * the target entry becoming unserialized. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 8/30/16 + * + *------------------------------------------------------------------------- + */ + herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr) + { + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - /* Sanity checks */ - HDassert(entry_ptr); + /* Sanity checks */ + HDassert(entry_ptr); - /* Iterate over the parent entries, if any */ - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) { - /* Sanity check */ - HDassert(entry_ptr->flush_dep_parent); - HDassert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children < - entry_ptr->flush_dep_parent[u]->flush_dep_nchildren); - - /* increment parents number of usserialized children */ - entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children++; - - /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ - if(entry_ptr->flush_dep_parent[u]->type->notify && - (entry_ptr->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, entry_ptr->flush_dep_parent[u]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry serialized flag reset") - } /* end for */ + /* Iterate over the parent entries, if any */ + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + /* Sanity check */ + HDassert(entry_ptr->flush_dep_parent); + HDassert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children < + entry_ptr->flush_dep_parent[u]->flush_dep_nchildren); + + /* increment parents number of usserialized children */ + entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children++; + + /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ + if (entry_ptr->flush_dep_parent[u]->type->notify && + (entry_ptr->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, + entry_ptr->flush_dep_parent[u]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag reset") + } /* end for */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_flush_dep_unserialized() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__mark_flush_dep_unserialized() */ - #ifndef NDEBUG -/*------------------------------------------------------------------------- - * Function: H5C__assert_flush_dep_nocycle() - * - * Purpose: Assert recursively that base_entry is not the same as - * entry, and perform the same assertion on all of entry's - * flush dependency parents. This is used to detect cycles - * created by flush dependencies. - * - * Return: void - * - * Programmer: Neil Fortner - * 12/10/12 - * - *------------------------------------------------------------------------- - */ -static void -H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t * entry, - const H5C_cache_entry_t * base_entry) -{ - unsigned u; /* Local index variable */ + /*------------------------------------------------------------------------- + * Function: H5C__assert_flush_dep_nocycle() + * + * Purpose: Assert recursively that base_entry is not the same as + * entry, and perform the same assertion on all of entry's + * flush dependency parents. This is used to detect cycles + * created by flush dependencies. + * + * Return: void + * + * Programmer: Neil Fortner + * 12/10/12 + * + *------------------------------------------------------------------------- + */ + static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, + const H5C_cache_entry_t *base_entry) + { + unsigned u; /* Local index variable */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC_NOERR - /* Sanity checks */ - HDassert(entry); - HDassert(base_entry); + /* Sanity checks */ + HDassert(entry); + HDassert(base_entry); - /* Make sure the entries are not the same */ - HDassert(base_entry != entry); + /* Make sure the entries are not the same */ + HDassert(base_entry != entry); - /* Iterate over entry's parents (if any) */ - for(u = 0; u < entry->flush_dep_nparents; u++) - H5C__assert_flush_dep_nocycle(entry->flush_dep_parent[u], base_entry); + /* Iterate over entry's parents (if any) */ + for (u = 0; u < entry->flush_dep_nparents; u++) + H5C__assert_flush_dep_nocycle(entry->flush_dep_parent[u], base_entry); - FUNC_LEAVE_NOAPI_VOID -} /* H5C__assert_flush_dep_nocycle() */ + FUNC_LEAVE_NOAPI_VOID + } /* H5C__assert_flush_dep_nocycle() */ #endif /* NDEBUG */ - -/*------------------------------------------------------------------------- - * Function: H5C__serialize_cache - * - * Purpose: Serialize (i.e. construct an on disk image) for all entries - * in the metadata cache including clean entries. - * - * Note that flush dependencies and "flush me last" flags - * must be observed in the serialization process. - * - * Note also that entries may be loaded, flushed, evicted, - * expunged, relocated, resized, or removed from the cache - * during this process, just as these actions may occur during - * a regular flush. - * - * However, we are given that the cache will contain no protected - * entries on entry to this routine (although entries may be - * briefly protected and then unprotected during the serialize - * process). - * - * The objective of this routine is serialize all entries and - * to force all entries into their actual locations on disk. - * - * The initial need for this routine is to settle all entries - * in the cache prior to construction of the metadata cache - * image so that the size of the cache image can be calculated. - * However, I gather that other uses for the routine are - * under consideration. - * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. - * - * Programmer: John Mainzer - * 7/22/15 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__serialize_cache(H5F_t *f) -{ + /*------------------------------------------------------------------------- + * Function: H5C__serialize_cache + * + * Purpose: Serialize (i.e. construct an on disk image) for all entries + * in the metadata cache including clean entries. + * + * Note that flush dependencies and "flush me last" flags + * must be observed in the serialization process. + * + * Note also that entries may be loaded, flushed, evicted, + * expunged, relocated, resized, or removed from the cache + * during this process, just as these actions may occur during + * a regular flush. + * + * However, we are given that the cache will contain no protected + * entries on entry to this routine (although entries may be + * briefly protected and then unprotected during the serialize + * process). + * + * The objective of this routine is serialize all entries and + * to force all entries into their actual locations on disk. + * + * The initial need for this routine is to settle all entries + * in the cache prior to construction of the metadata cache + * image so that the size of the cache image can be calculated. + * However, I gather that other uses for the routine are + * under consideration. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + * Programmer: John Mainzer + * 7/22/15 + * + *------------------------------------------------------------------------- + */ + herr_t H5C__serialize_cache(H5F_t * f) + { #if H5C_DO_SANITY_CHECKS - int i; - uint32_t index_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - uint32_t slist_len = 0; + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_ring_t ring; - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; + H5C_ring_t ring; + H5C_t * cache_ptr; + herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE - /* Sanity checks */ - HDassert(f); - HDassert(f->shared); - cache_ptr = f->shared->cache; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr->slist_ptr); + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + cache_ptr = f->shared->cache; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->slist_ptr); #if H5C_DO_SANITY_CHECKS - HDassert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); - HDassert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); - HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - - for(i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { - index_len += cache_ptr->index_ring_len[i]; - index_size += cache_ptr->index_ring_size[i]; - clean_index_size += cache_ptr->clean_index_ring_size[i]; - dirty_index_size += cache_ptr->dirty_index_ring_size[i]; - - slist_len += cache_ptr->slist_ring_len[i]; - slist_size += cache_ptr->slist_ring_size[i]; - } /* end for */ + HDassert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); + HDassert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); + HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + index_len += cache_ptr->index_ring_len[i]; + index_size += cache_ptr->index_ring_size[i]; + clean_index_size += cache_ptr->clean_index_ring_size[i]; + dirty_index_size += cache_ptr->dirty_index_ring_size[i]; + + slist_len += cache_ptr->slist_ring_len[i]; + slist_size += cache_ptr->slist_ring_size[i]; + } /* end for */ - HDassert(cache_ptr->index_len == index_len); - HDassert(cache_ptr->index_size == index_size); - HDassert(cache_ptr->clean_index_size == clean_index_size); - HDassert(cache_ptr->dirty_index_size == dirty_index_size); - HDassert(cache_ptr->slist_len == slist_len); - HDassert(cache_ptr->slist_size == slist_size); + HDassert(cache_ptr->index_len == index_len); + HDassert(cache_ptr->index_size == index_size); + HDassert(cache_ptr->clean_index_size == clean_index_size); + HDassert(cache_ptr->dirty_index_size == dirty_index_size); + HDassert(cache_ptr->slist_len == slist_len); + HDassert(cache_ptr->slist_size == slist_size); #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ #ifndef NDEBUG - /* if this is a debug build, set the serialization_count field of - * each entry in the cache to zero before we start the serialization. - * This allows us to detect the case in which any entry is serialized - * more than once (a performance issues), and more importantly, the - * case is which any flush depencency parent is serializes more than - * once (a correctness issue). - */ - { - H5C_cache_entry_t * scan_ptr = NULL; - - scan_ptr = cache_ptr->il_head; - while(scan_ptr != NULL) { - HDassert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - scan_ptr->serialization_count = 0; - scan_ptr = scan_ptr->il_next; - } /* end while */ - } /* end block */ -#endif /* NDEBUG */ - - /* set cache_ptr->serialization_in_progress to TRUE, and back - * to FALSE at the end of the function. Must maintain this flag - * to support H5C_get_serialization_in_progress(), which is in - * turn required to support sanity checking in some cache - * clients. - */ - HDassert(!cache_ptr->serialization_in_progress); - cache_ptr->serialization_in_progress = TRUE; + /* if this is a debug build, set the serialization_count field of + * each entry in the cache to zero before we start the serialization. + * This allows us to detect the case in which any entry is serialized + * more than once (a performance issues), and more importantly, the + * case is which any flush depencency parent is serializes more than + * once (a correctness issue). + */ + { + H5C_cache_entry_t *scan_ptr = NULL; + + scan_ptr = cache_ptr->il_head; + while (scan_ptr != NULL) { + HDassert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + scan_ptr->serialization_count = 0; + scan_ptr = scan_ptr->il_next; + } /* end while */ + } /* end block */ +#endif /* NDEBUG */ + + /* set cache_ptr->serialization_in_progress to TRUE, and back + * to FALSE at the end of the function. Must maintain this flag + * to support H5C_get_serialization_in_progress(), which is in + * turn required to support sanity checking in some cache + * clients. + */ + HDassert(!cache_ptr->serialization_in_progress); + cache_ptr->serialization_in_progress = TRUE; - /* Serialize each ring, starting from the outermost ring and - * working inward. - */ - ring = H5C_RING_USER; - while(ring < H5C_RING_NTYPES) { - HDassert(cache_ptr->close_warning_received); - switch(ring) { - case H5C_RING_USER: - break; + /* Serialize each ring, starting from the outermost ring and + * working inward. + */ + ring = H5C_RING_USER; + while (ring < H5C_RING_NTYPES) { + HDassert(cache_ptr->close_warning_received); + switch (ring) { + case H5C_RING_USER: + break; - case H5C_RING_RDFSM: - /* Settle raw data FSM */ - if(!cache_ptr->rdfsm_settled) - if(H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "RD FSM settle failed") - break; + case H5C_RING_RDFSM: + /* Settle raw data FSM */ + if (!cache_ptr->rdfsm_settled) + if (H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "RD FSM settle failed") + break; - case H5C_RING_MDFSM: - /* Settle metadata FSM */ - if(!cache_ptr->mdfsm_settled) - if(H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "MD FSM settle failed") - break; + case H5C_RING_MDFSM: + /* Settle metadata FSM */ + if (!cache_ptr->mdfsm_settled) + if (H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "MD FSM settle failed") + break; - case H5C_RING_SBE: - case H5C_RING_SB: - break; + case H5C_RING_SBE: + case H5C_RING_SB: + break; - default: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown ring?!?!") - break; - } /* end switch */ + default: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown ring?!?!") + break; + } /* end switch */ - if(H5C__serialize_ring(f, ring) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "serialize ring failed") + if (H5C__serialize_ring(f, ring) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "serialize ring failed") - ring++; - } /* end while */ + ring++; + } /* end while */ #ifndef NDEBUG - /* Verify that no entry has been serialized more than once. - * FD parents with multiple serializations should have been caught - * elsewhere, so no specific check for them here. - */ - { - H5C_cache_entry_t * scan_ptr = NULL; + /* Verify that no entry has been serialized more than once. + * FD parents with multiple serializations should have been caught + * elsewhere, so no specific check for them here. + */ + { + H5C_cache_entry_t *scan_ptr = NULL; - scan_ptr = cache_ptr->il_head; - while(scan_ptr != NULL) { - HDassert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(scan_ptr->serialization_count <= 1); + scan_ptr = cache_ptr->il_head; + while (scan_ptr != NULL) { + HDassert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(scan_ptr->serialization_count <= 1); - scan_ptr = scan_ptr->il_next; - } /* end while */ - } /* end block */ -#endif /* NDEBUG */ + scan_ptr = scan_ptr->il_next; + } /* end while */ + } /* end block */ +#endif /* NDEBUG */ done: - cache_ptr->serialization_in_progress = FALSE; - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__serialize_cache() */ + cache_ptr->serialization_in_progress = FALSE; + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__serialize_cache() */ - -/*------------------------------------------------------------------------- - * Function: H5C__serialize_ring - * - * Purpose: Serialize the entries contained in the specified cache and - * ring. All entries in rings outside the specified ring - * must have been serialized on entry. - * - * If the cache contains protected entries in the specified - * ring, the function will fail, as protected entries cannot - * be serialized. However all unprotected entries in the - * target ring should be serialized before the function - * returns failure. - * - * If flush dependencies appear in the target ring, the - * function makes repeated passes through the index list - * serializing entries in flush dependency order. - * - * All entries outside the H5C_RING_SBE are marked for - * inclusion in the cache image. Entries in H5C_RING_SBE - * and below are marked for exclusion from the image. - * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. - * - * Programmer: John Mainzer - * 9/11/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) -{ - hbool_t done = FALSE; - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr; - herr_t ret_value = SUCCEED; + /*------------------------------------------------------------------------- + * Function: H5C__serialize_ring + * + * Purpose: Serialize the entries contained in the specified cache and + * ring. All entries in rings outside the specified ring + * must have been serialized on entry. + * + * If the cache contains protected entries in the specified + * ring, the function will fail, as protected entries cannot + * be serialized. However all unprotected entries in the + * target ring should be serialized before the function + * returns failure. + * + * If flush dependencies appear in the target ring, the + * function makes repeated passes through the index list + * serializing entries in flush dependency order. + * + * All entries outside the H5C_RING_SBE are marked for + * inclusion in the cache image. Entries in H5C_RING_SBE + * and below are marked for exclusion from the image. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + * Programmer: John Mainzer + * 9/11/15 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__serialize_ring(H5F_t * f, H5C_ring_t ring) + { + hbool_t done = FALSE; + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr; + herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - /* Sanity checks */ - HDassert(f); - HDassert(f->shared); - cache_ptr = f->shared->cache; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(ring > H5C_RING_UNDEFINED); - HDassert(ring < H5C_RING_NTYPES); - - HDassert(cache_ptr->serialization_in_progress); - - /* The objective here is to serialize all entries in the cache ring - * in flush dependency order. - * - * The basic algorithm is to scan the cache index list looking for - * unserialized entries that are either not in a flush dependency - * relationship, or which have no unserialized children. Any such - * entry is serialized and its flush dependency parents (if any) are - * informed -- allowing them to decrement their userialized child counts. - * - * However, this algorithm is complicated by the ability - * of client serialization callbacks to perform operations on - * on the cache which can result in the insertion, deletion, - * relocation, resize, dirty, flush, eviction, or removal (via the - * take ownership flag) of entries. Changes in the flush dependency - * structure are also possible. - * - * On the other hand, the algorithm is simplified by the fact that - * we are serializing, not flushing. Thus, as long as all entries - * are serialized correctly, it doesn't matter if we have to go back - * and serialize an entry a second time. - * - * These possible actions result in the following modfications to - * tha basic algorithm: - * - * 1) In the event of an entry expunge, eviction or removal, we must - * restart the scan as it is possible that the next entry in our - * scan is no longer in the cache. Were we to examine this entry, - * we would be accessing deallocated memory. - * - * 2) A resize, dirty, or insertion of an entry may result in the - * the increment of a flush dependency parent's dirty and/or - * unserialized child count. In the context of serializing the - * the cache, this is a non-issue, as even if we have already - * serialized the parent, it will be marked dirty and its image - * marked out of date if appropriate when the child is serialized. - * - * However, this is a major issue for a flush, as were this to happen - * in a flush, it would violate the invariant that the flush dependency - * feature is intended to enforce. As the metadata cache has no - * control over the behavior of cache clients, it has no way of - * preventing this behaviour. However, it should detect it if at all - * possible. - * - * Do this by maintaining a count of the number of times each entry is - * serialized during a cache serialization. If any flush dependency - * parent is serialized more than once, throw an assertion failure. - * - * 3) An entry relocation will typically change the location of the - * entry in the index list. This shouldn't cause problems as we - * will scan the index list until we make a complete pass without - * finding anything to serialize -- making relocations of either - * the current or next entries irrelevant. - * - * Note that since a relocation may result in our skipping part of - * the index list, we must always do at least one more pass through - * the index list after an entry relocation. - * - * 4) Changes in the flush dependency structure are possible on - * entry insertion, load, expunge, evict, or remove. Destruction - * of a flush dependency has no effect, as it can only relax the - * flush dependencies. Creation of a flush dependency can create - * an unserialized child of a flush dependency parent where all - * flush dependency children were previously serialized. Should - * this child dirty the flush dependency parent when it is serialized, - * the parent will be re-serialized. - * - * Per the discussion of 2) above, this is a non issue for cache - * serialization, and a major problem for cache flush. Using the - * same detection mechanism, throw an assertion failure if this - * condition appears. - * - * Observe that either eviction or removal of entries as a result of - * a serialization is not a problem as long as the flush depencency - * tree does not change beyond the removal of a leaf. - */ - while(!done) { - /* Reset the counters so that we can detect insertions, loads, - * moves, and flush dependency height changes caused by the pre_serialize - * and serialize callbacks. + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + cache_ptr = f->shared->cache; + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(ring > H5C_RING_UNDEFINED); + HDassert(ring < H5C_RING_NTYPES); + + HDassert(cache_ptr->serialization_in_progress); + + /* The objective here is to serialize all entries in the cache ring + * in flush dependency order. + * + * The basic algorithm is to scan the cache index list looking for + * unserialized entries that are either not in a flush dependency + * relationship, or which have no unserialized children. Any such + * entry is serialized and its flush dependency parents (if any) are + * informed -- allowing them to decrement their userialized child counts. + * + * However, this algorithm is complicated by the ability + * of client serialization callbacks to perform operations on + * on the cache which can result in the insertion, deletion, + * relocation, resize, dirty, flush, eviction, or removal (via the + * take ownership flag) of entries. Changes in the flush dependency + * structure are also possible. + * + * On the other hand, the algorithm is simplified by the fact that + * we are serializing, not flushing. Thus, as long as all entries + * are serialized correctly, it doesn't matter if we have to go back + * and serialize an entry a second time. + * + * These possible actions result in the following modfications to + * tha basic algorithm: + * + * 1) In the event of an entry expunge, eviction or removal, we must + * restart the scan as it is possible that the next entry in our + * scan is no longer in the cache. Were we to examine this entry, + * we would be accessing deallocated memory. + * + * 2) A resize, dirty, or insertion of an entry may result in the + * the increment of a flush dependency parent's dirty and/or + * unserialized child count. In the context of serializing the + * the cache, this is a non-issue, as even if we have already + * serialized the parent, it will be marked dirty and its image + * marked out of date if appropriate when the child is serialized. + * + * However, this is a major issue for a flush, as were this to happen + * in a flush, it would violate the invariant that the flush dependency + * feature is intended to enforce. As the metadata cache has no + * control over the behavior of cache clients, it has no way of + * preventing this behaviour. However, it should detect it if at all + * possible. + * + * Do this by maintaining a count of the number of times each entry is + * serialized during a cache serialization. If any flush dependency + * parent is serialized more than once, throw an assertion failure. + * + * 3) An entry relocation will typically change the location of the + * entry in the index list. This shouldn't cause problems as we + * will scan the index list until we make a complete pass without + * finding anything to serialize -- making relocations of either + * the current or next entries irrelevant. + * + * Note that since a relocation may result in our skipping part of + * the index list, we must always do at least one more pass through + * the index list after an entry relocation. + * + * 4) Changes in the flush dependency structure are possible on + * entry insertion, load, expunge, evict, or remove. Destruction + * of a flush dependency has no effect, as it can only relax the + * flush dependencies. Creation of a flush dependency can create + * an unserialized child of a flush dependency parent where all + * flush dependency children were previously serialized. Should + * this child dirty the flush dependency parent when it is serialized, + * the parent will be re-serialized. + * + * Per the discussion of 2) above, this is a non issue for cache + * serialization, and a major problem for cache flush. Using the + * same detection mechanism, throw an assertion failure if this + * condition appears. + * + * Observe that either eviction or removal of entries as a result of + * a serialization is not a problem as long as the flush depencency + * tree does not change beyond the removal of a leaf. */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; - - done = TRUE; /* set to FALSE if any activity in inner loop */ - entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - - /* Verify that either the entry is already serialized, or - * that it is assigned to either the target or an inner - * ring. + while (!done) { + /* Reset the counters so that we can detect insertions, loads, + * moves, and flush dependency height changes caused by the pre_serialize + * and serialize callbacks. */ - HDassert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + + done = TRUE; /* set to FALSE if any activity in inner loop */ + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + + /* Verify that either the entry is already serialized, or + * that it is assigned to either the target or an inner + * ring. + */ + HDassert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); - /* Skip flush me last entries or inner ring entries */ - if(!entry_ptr->flush_me_last && entry_ptr->ring == ring) { + /* Skip flush me last entries or inner ring entries */ + if (!entry_ptr->flush_me_last && entry_ptr->ring == ring) { - /* if we encounter an unserialized entry in the current - * ring that is not marked flush me last, we are not done. - */ - if(!entry_ptr->image_up_to_date) - done = FALSE; + /* if we encounter an unserialized entry in the current + * ring that is not marked flush me last, we are not done. + */ + if (!entry_ptr->image_up_to_date) + done = FALSE; - /* Serialize the entry if its image is not up to date - * and it has no unserialized flush dependency children. - */ - if(!entry_ptr->image_up_to_date && entry_ptr->flush_dep_nunser_children == 0) { - HDassert(entry_ptr->serialization_count == 0); + /* Serialize the entry if its image is not up to date + * and it has no unserialized flush dependency children. + */ + if (!entry_ptr->image_up_to_date && entry_ptr->flush_dep_nunser_children == 0) { + HDassert(entry_ptr->serialization_count == 0); - /* Serialize the entry */ - if(H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") + /* Serialize the entry */ + if (H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") - HDassert(entry_ptr->flush_dep_nunser_children == 0); - HDassert(entry_ptr->serialization_count == 0); + HDassert(entry_ptr->flush_dep_nunser_children == 0); + HDassert(entry_ptr->serialization_count == 0); #ifndef NDEBUG - /* Increment serialization counter (to detect multiple serializations) */ - entry_ptr->serialization_count++; -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ + /* Increment serialization counter (to detect multiple serializations) */ + entry_ptr->serialization_count++; +#endif /* NDEBUG */ + } /* end if */ + } /* end if */ - /* Check for the cache being perturbed during the entry serialize */ - if((cache_ptr->entries_loaded_counter > 0) || - (cache_ptr->entries_inserted_counter > 0) || + /* Check for the cache being perturbed during the entry serialize */ + if ((cache_ptr->entries_loaded_counter > 0) || (cache_ptr->entries_inserted_counter > 0) || (cache_ptr->entries_relocated_counter > 0)) { #if H5C_COLLECT_CACHE_STATS - H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr); + H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr); #endif /* H5C_COLLECT_CACHE_STATS */ - /* Reset the counters */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + /* Reset the counters */ + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; - /* Restart scan */ - entry_ptr = cache_ptr->il_head; - } /* end if */ - else - /* Advance to next entry */ - entry_ptr = entry_ptr->il_next; - } /* while ( entry_ptr != NULL ) */ - } /* while ( ! done ) */ + /* Restart scan */ + entry_ptr = cache_ptr->il_head; + } /* end if */ + else + /* Advance to next entry */ + entry_ptr = entry_ptr->il_next; + } /* while ( entry_ptr != NULL ) */ + } /* while ( ! done ) */ + /* Reset the counters so that we can detect insertions, loads, + * moves, and flush dependency height changes caused by the pre_serialize + * and serialize callbacks. + */ + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + + /* At this point, all entries not marked "flush me last" and in + * the current ring or outside it should be serialized and have up + * to date images. Scan the index list again to serialize the + * "flush me last" entries (if they are in the current ring) and to + * verify that all other entries have up to date images. + */ + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring > H5C_RING_UNDEFINED); + HDassert(entry_ptr->ring < H5C_RING_NTYPES); + HDassert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); - /* Reset the counters so that we can detect insertions, loads, - * moves, and flush dependency height changes caused by the pre_serialize - * and serialize callbacks. - */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; - - /* At this point, all entries not marked "flush me last" and in - * the current ring or outside it should be serialized and have up - * to date images. Scan the index list again to serialize the - * "flush me last" entries (if they are in the current ring) and to - * verify that all other entries have up to date images. - */ - entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring > H5C_RING_UNDEFINED); - HDassert(entry_ptr->ring < H5C_RING_NTYPES); - HDassert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); - - if(entry_ptr->ring == ring) { - if(entry_ptr->flush_me_last) { - if(!entry_ptr->image_up_to_date) { - HDassert(entry_ptr->serialization_count == 0); - HDassert(entry_ptr->flush_dep_nunser_children == 0); + if (entry_ptr->ring == ring) { + if (entry_ptr->flush_me_last) { + if (!entry_ptr->image_up_to_date) { + HDassert(entry_ptr->serialization_count == 0); + HDassert(entry_ptr->flush_dep_nunser_children == 0); - /* Serialize the entry */ - if(H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") + /* Serialize the entry */ + if (H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") - /* Check for the cache changing */ - if((cache_ptr->entries_loaded_counter > 0) || + /* Check for the cache changing */ + if ((cache_ptr->entries_loaded_counter > 0) || (cache_ptr->entries_inserted_counter > 0) || (cache_ptr->entries_relocated_counter > 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flush_me_last entry serialization triggered restart") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flush_me_last entry serialization triggered restart") - HDassert(entry_ptr->flush_dep_nunser_children == 0); - HDassert(entry_ptr->serialization_count == 0); + HDassert(entry_ptr->flush_dep_nunser_children == 0); + HDassert(entry_ptr->serialization_count == 0); #ifndef NDEBUG - /* Increment serialization counter (to detect multiple serializations) */ - entry_ptr->serialization_count++; -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ - else { - HDassert(entry_ptr->image_up_to_date); - HDassert(entry_ptr->serialization_count <= 1); - HDassert(entry_ptr->flush_dep_nunser_children == 0); - } /* end else */ - } /* if ( entry_ptr->ring == ring ) */ + /* Increment serialization counter (to detect multiple serializations) */ + entry_ptr->serialization_count++; +#endif /* NDEBUG */ + } /* end if */ + } /* end if */ + else { + HDassert(entry_ptr->image_up_to_date); + HDassert(entry_ptr->serialization_count <= 1); + HDassert(entry_ptr->flush_dep_nunser_children == 0); + } /* end else */ + } /* if ( entry_ptr->ring == ring ) */ - entry_ptr = entry_ptr->il_next; - } /* while ( entry_ptr != NULL ) */ + entry_ptr = entry_ptr->il_next; + } /* while ( entry_ptr != NULL ) */ done: - HDassert(cache_ptr->serialization_in_progress); - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__serialize_ring() */ - - -/*------------------------------------------------------------------------- - * Function: H5C__serialize_single_entry - * - * Purpose: Serialize the cache entry pointed to by the entry_ptr - * parameter. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer, 7/24/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ + HDassert(cache_ptr->serialization_in_progress); + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__serialize_ring() */ - FUNC_ENTER_STATIC + /*------------------------------------------------------------------------- + * Function: H5C__serialize_single_entry + * + * Purpose: Serialize the cache entry pointed to by the entry_ptr + * parameter. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer, 7/24/15 + * + *------------------------------------------------------------------------- + */ + static herr_t H5C__serialize_single_entry(H5F_t * f, H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr) + { + herr_t ret_value = SUCCEED; /* Return value */ - /* Sanity checks */ - HDassert(f); - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(entry_ptr); - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(!entry_ptr->prefetched); - HDassert(!entry_ptr->image_up_to_date); - HDassert(entry_ptr->is_dirty); - HDassert(!entry_ptr->is_protected); - HDassert(!entry_ptr->flush_in_progress); - HDassert(entry_ptr->type); + FUNC_ENTER_STATIC - /* Set entry_ptr->flush_in_progress to TRUE so the the target entry - * will not be evicted out from under us. Must set it back to FALSE - * when we are done. - */ - entry_ptr->flush_in_progress = TRUE; + /* Sanity checks */ + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(entry_ptr); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(!entry_ptr->prefetched); + HDassert(!entry_ptr->image_up_to_date); + HDassert(entry_ptr->is_dirty); + HDassert(!entry_ptr->is_protected); + HDassert(!entry_ptr->flush_in_progress); + HDassert(entry_ptr->type); - /* Allocate buffer for the entry image if required. */ - if(NULL == entry_ptr->image_ptr) { - HDassert(entry_ptr->size > 0); - if(NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE)) ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") + /* Set entry_ptr->flush_in_progress to TRUE so the the target entry + * will not be evicted out from under us. Must set it back to FALSE + * when we are done. + */ + entry_ptr->flush_in_progress = TRUE; + + /* Allocate buffer for the entry image if required. */ + if (NULL == entry_ptr->image_ptr) { + HDassert(entry_ptr->size > 0); + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + image_size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - } /* end if */ + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + image_size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + } /* end if */ - /* Generate image for entry */ - if(H5C__generate_image(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "Can't generate image for cache entry") + /* Generate image for entry */ + if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "Can't generate image for cache entry") - /* Reset the flush_in progress flag */ - entry_ptr->flush_in_progress = FALSE; + /* Reset the flush_in progress flag */ + entry_ptr->flush_in_progress = FALSE; done: - HDassert((ret_value != SUCCEED) || (!entry_ptr->flush_in_progress)); - HDassert((ret_value != SUCCEED) || (entry_ptr->image_up_to_date)); - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__serialize_single_entry() */ + HDassert((ret_value != SUCCEED) || (!entry_ptr->flush_in_progress)); + HDassert((ret_value != SUCCEED) || (entry_ptr->image_up_to_date)); + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__serialize_single_entry() */ - -/*------------------------------------------------------------------------- - * Function: H5C__generate_image - * - * Purpose: Serialize an entry and generate its image. - * - * Note: This may cause the entry to be re-sized and/or moved in - * the cache. - * - * As we will not update the metadata cache's data structures - * until we we finish the write, we must touch up these - * data structures for size and location changes even if we - * are about to delete the entry from the cache (i.e. on a - * flush destroy). - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * 2/10/16 - * - * Changes: Added code to update the page field in the VFD SWMR reader - * case. - * - * JRM -- 12/14/18 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) -{ - haddr_t new_addr = HADDR_UNDEF; - haddr_t old_addr = HADDR_UNDEF; - size_t new_len = 0; - unsigned serialize_flags = H5C__SERIALIZE_NO_FLAGS_SET; - herr_t ret_value = SUCCEED; + /*------------------------------------------------------------------------- + * Function: H5C__generate_image + * + * Purpose: Serialize an entry and generate its image. + * + * Note: This may cause the entry to be re-sized and/or moved in + * the cache. + * + * As we will not update the metadata cache's data structures + * until we we finish the write, we must touch up these + * data structures for size and location changes even if we + * are about to delete the entry from the cache (i.e. on a + * flush destroy). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * 2/10/16 + * + * Changes: Added code to update the page field in the VFD SWMR reader + * case. + * + * JRM -- 12/14/18 + * + *------------------------------------------------------------------------- + */ + herr_t H5C__generate_image(H5F_t * f, H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr) + { + haddr_t new_addr = HADDR_UNDEF; + haddr_t old_addr = HADDR_UNDEF; + size_t new_len = 0; + unsigned serialize_flags = H5C__SERIALIZE_NO_FLAGS_SET; + herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE - /* Sanity check */ - HDassert(f); - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + /* Sanity check */ + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - /* if this is a VFD SWMR reader, verify that the page size is defined */ - HDassert( ( ! cache_ptr->vfd_swmr_reader ) || - ( cache_ptr->page_size > 0 ) ); + /* if this is a VFD SWMR reader, verify that the page size is defined */ + HDassert((!cache_ptr->vfd_swmr_reader) || (cache_ptr->page_size > 0)); - HDassert(entry_ptr); - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(!entry_ptr->image_up_to_date); - HDassert(entry_ptr->is_dirty); - HDassert(!entry_ptr->is_protected); - HDassert(entry_ptr->type); + HDassert(entry_ptr); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(!entry_ptr->image_up_to_date); + HDassert(entry_ptr->is_dirty); + HDassert(!entry_ptr->is_protected); + HDassert(entry_ptr->type); - /* make note of the entry's current address */ - old_addr = entry_ptr->addr; + /* make note of the entry's current address */ + old_addr = entry_ptr->addr; - /* Call client's pre-serialize callback, if there's one */ - if(entry_ptr->type->pre_serialize && - (entry_ptr->type->pre_serialize)(f, (void *)entry_ptr, - entry_ptr->addr, entry_ptr->size, &new_addr, &new_len, &serialize_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to pre-serialize entry") + /* Call client's pre-serialize callback, if there's one */ + if (entry_ptr->type->pre_serialize && + (entry_ptr->type->pre_serialize)(f, (void *)entry_ptr, entry_ptr->addr, entry_ptr->size, + &new_addr, &new_len, &serialize_flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to pre-serialize entry") - /* Check for any flags set in the pre-serialize callback */ - if ( serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET ) { + /* Check for any flags set in the pre-serialize callback */ + if (serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) { - /* Check for unexpected flags from serialize callback */ - if ( serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG | - H5C__SERIALIZE_MOVED_FLAG) ) + /* Check for unexpected flags from serialize callback */ + if (serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG | H5C__SERIALIZE_MOVED_FLAG)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "unknown serialize flag(s)") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unknown serialize flag(s)") #ifdef H5_HAVE_PARALLEL - /* In the parallel case, resizes and moves in - * the serialize operation can cause problems. - * If they occur, scream and die. - * - * At present, in the parallel case, the aux_ptr - * will only be set if there is more than one - * process. Thus we can use this to detect - * the parallel case. - * - * This works for now, but if we start using the - * aux_ptr for other purposes, we will have to - * change this test accordingly. - * - * NB: While this test detects entryies that attempt - * to resize or move themselves during a flush - * in the parallel case, it will not detect an - * entry that dirties, resizes, and/or moves - * other entries during its flush. - * - * From what Quincey tells me, this test is - * sufficient for now, as any flush routine that - * does the latter will also do the former. - * - * If that ceases to be the case, further - * tests will be necessary. - */ - if ( cache_ptr->aux_ptr != NULL ) + /* In the parallel case, resizes and moves in + * the serialize operation can cause problems. + * If they occur, scream and die. + * + * At present, in the parallel case, the aux_ptr + * will only be set if there is more than one + * process. Thus we can use this to detect + * the parallel case. + * + * This works for now, but if we start using the + * aux_ptr for other purposes, we will have to + * change this test accordingly. + * + * NB: While this test detects entryies that attempt + * to resize or move themselves during a flush + * in the parallel case, it will not detect an + * entry that dirties, resizes, and/or moves + * other entries during its flush. + * + * From what Quincey tells me, this test is + * sufficient for now, as any flush routine that + * does the latter will also do the former. + * + * If that ceases to be the case, further + * tests will be necessary. + */ + if (cache_ptr->aux_ptr != NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "resize/move in serialize occurred in parallel case") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "resize/move in serialize occurred in parallel case") #endif - /* If required, resize the buffer and update the entry and the cache - * data structures - */ - if ( serialize_flags & H5C__SERIALIZE_RESIZED_FLAG ) { + /* If required, resize the buffer and update the entry and the cache + * data structures + */ + if (serialize_flags & H5C__SERIALIZE_RESIZED_FLAG) { - /* Sanity check */ - HDassert(new_len > 0); + /* Sanity check */ + HDassert(new_len > 0); - /* Allocate a new image buffer */ - if ( NULL == (entry_ptr->image_ptr = - H5MM_realloc(entry_ptr->image_ptr, - new_len + H5C_IMAGE_EXTRA_SPACE)) ) + /* Allocate a new image buffer */ + if (NULL == (entry_ptr->image_ptr = + H5MM_realloc(entry_ptr->image_ptr, new_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, \ - "memory allocation failed for on disk image buffer") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + new_len, - H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + new_len, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - /* Update statistics for resizing the entry */ - H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, \ - new_len); + /* Update statistics for resizing the entry */ + H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_len); - /* Update the hash table for the size change */ - H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \ - new_len, entry_ptr, !(entry_ptr->is_dirty)); + /* Update the hash table for the size change */ + H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len, entry_ptr, + !(entry_ptr->is_dirty)); - /* The entry can't be protected since we are in the process of - * flushing it. Thus we must update the replacement policy data - * structures for the size change. The macro deals with the pinned - * case. - */ - H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_len); - - /* As we haven't updated the cache data structures for - * for the flush or flush destroy yet, the entry should - * be in the slist. Thus update it for the size change. - */ - HDassert(entry_ptr->is_dirty); - HDassert(entry_ptr->in_slist); - H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \ - new_len); + /* The entry can't be protected since we are in the process of + * flushing it. Thus we must update the replacement policy data + * structures for the size change. The macro deals with the pinned + * case. + */ + H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_len); - /* Finally, update the entry for its new size */ - entry_ptr->size = new_len; + /* As we haven't updated the cache data structures for + * for the flush or flush destroy yet, the entry should + * be in the slist. Thus update it for the size change. + */ + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->in_slist); + H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len); - } /* end if */ + /* Finally, update the entry for its new size */ + entry_ptr->size = new_len; - /* If required, udate the entry and the cache data structures - * for a move - */ - if ( serialize_flags & H5C__SERIALIZE_MOVED_FLAG ) { + } /* end if */ - /* Update stats and entries relocated counter */ - H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) + /* If required, udate the entry and the cache data structures + * for a move + */ + if (serialize_flags & H5C__SERIALIZE_MOVED_FLAG) { - /* We must update cache data structures for the change in address */ - if(entry_ptr->addr == old_addr) { + /* Update stats and entries relocated counter */ + H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) - /* Delete the entry from the hash table and the slist */ - H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL); - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE); + /* We must update cache data structures for the change in address */ + if (entry_ptr->addr == old_addr) { - /* Update the entry for its new address */ - entry_ptr->addr = new_addr; + /* Delete the entry from the hash table and the slist */ + H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL); + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE); - /* In the VFD SWMR reader case, update the entry page field */ - if ( cache_ptr->vfd_swmr_reader ) { + /* Update the entry for its new address */ + entry_ptr->addr = new_addr; - entry_ptr->page = (new_addr / cache_ptr->page_size); - } + /* In the VFD SWMR reader case, update the entry page field */ + if (cache_ptr->vfd_swmr_reader) { - /* And then reinsert in the index and slist */ - H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL); - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + entry_ptr->page = (new_addr / cache_ptr->page_size); + } - } else { /* move is already done for us -- just do sanity checks */ + /* And then reinsert in the index and slist */ + H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL); + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + } + else { /* move is already done for us -- just do sanity checks */ - HDassert(entry_ptr->addr == new_addr); - HDassert(( ! cache_ptr->vfd_swmr_reader ) || - ( entry_ptr->page == - (entry_ptr->addr / cache_ptr->page_size) )); - } - } /* end if */ - } /* end if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) */ + HDassert(entry_ptr->addr == new_addr); + HDassert((!cache_ptr->vfd_swmr_reader) || + (entry_ptr->page == (entry_ptr->addr / cache_ptr->page_size))); + } + } /* end if */ + } /* end if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) */ - /* Serialize object into buffer */ - if ( entry_ptr->type->serialize(f, entry_ptr->image_ptr, entry_ptr->size, - (void *)entry_ptr) < 0) + /* Serialize object into buffer */ + if (entry_ptr->type->serialize(f, entry_ptr->image_ptr, entry_ptr->size, (void *)entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to serialize entry") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to serialize entry") #if H5C_DO_MEMORY_SANITY_CHECKS - HDassert(0 == HDmemcmp(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, - H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE)); + HDassert(0 == HDmemcmp(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE)); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - entry_ptr->image_up_to_date = TRUE; + entry_ptr->image_up_to_date = TRUE; - /* Propagate the fact that the entry is serialized up the - * flush dependency chain if appropriate. Since the image must - * have been out of date for this function to have been called - * (see assertion on entry), no need to check that -- only check - * for flush dependency parents. - */ - HDassert(entry_ptr->flush_dep_nunser_children == 0); + /* Propagate the fact that the entry is serialized up the + * flush dependency chain if appropriate. Since the image must + * have been out of date for this function to have been called + * (see assertion on entry), no need to check that -- only check + * for flush dependency parents. + */ + HDassert(entry_ptr->flush_dep_nunser_children == 0); - if ( entry_ptr->flush_dep_nparents > 0 ) { + if (entry_ptr->flush_dep_nparents > 0) { - if ( H5C__mark_flush_dep_serialized(entry_ptr) < 0 ) + if (H5C__mark_flush_dep_serialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "Can't propagate serialization status to fd parents") - } + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") + } done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__generate_image */ + } /* H5C__generate_image */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_remove_entry - * - * Purpose: Remove an entry from the cache. Must be not protected, pinned, - * dirty, involved in flush dependencies, etc. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * September 17, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_remove_entry(void *_entry) -{ - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry to remove */ - H5C_t *cache; /* Cache for file */ - herr_t ret_value = SUCCEED; /* Return value */ + /*------------------------------------------------------------------------- + * + * Function: H5C_remove_entry + * + * Purpose: Remove an entry from the cache. Must be not protected, pinned, + * dirty, involved in flush dependencies, etc. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * September 17, 2016 + * + *------------------------------------------------------------------------- + */ + herr_t H5C_remove_entry(void *_entry) + { + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry to remove */ + H5C_t * cache; /* Cache for file */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(FAIL) - /* Sanity checks */ - HDassert(entry); - HDassert(entry->ring != H5C_RING_UNDEFINED); - cache = entry->cache_ptr; - HDassert(cache); - HDassert(cache->magic == H5C__H5C_T_MAGIC); - - /* Check for error conditions */ - if(entry->is_dirty) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove dirty entry from cache") - if(entry->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove protected entry from cache") - if(entry->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove pinned entry from cache") - /* NOTE: If these two errors are getting tripped because the entry is - * in a flush dependency with a freedspace entry, move the checks - * after the "before evict" message is sent, and add the - * "child being evicted" message to the "before evict" notify - * section below. QAK - 2017/08/03 - */ - if(entry->flush_dep_nparents > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry with flush dependency parents from cache") - if(entry->flush_dep_nchildren > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry with flush dependency children from cache") - - /* Additional internal cache consistency checks */ - HDassert(!entry->in_slist); - HDassert(!entry->flush_marker); - HDassert(!entry->flush_in_progress); - - /* Note that the algorithm below is (very) similar to the set of operations - * in H5C__flush_single_entry() and should be kept in sync with changes - * to that code. - QAK, 2016/11/30 - */ + /* Sanity checks */ + HDassert(entry); + HDassert(entry->ring != H5C_RING_UNDEFINED); + cache = entry->cache_ptr; + HDassert(cache); + HDassert(cache->magic == H5C__H5C_T_MAGIC); + + /* Check for error conditions */ + if (entry->is_dirty) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove dirty entry from cache") + if (entry->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove protected entry from cache") + if (entry->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove pinned entry from cache") + /* NOTE: If these two errors are getting tripped because the entry is + * in a flush dependency with a freedspace entry, move the checks + * after the "before evict" message is sent, and add the + * "child being evicted" message to the "before evict" notify + * section below. QAK - 2017/08/03 + */ + if (entry->flush_dep_nparents > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove entry with flush dependency parents from cache") + if (entry->flush_dep_nchildren > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove entry with flush dependency children from cache") + + /* Additional internal cache consistency checks */ + HDassert(!entry->in_slist); + HDassert(!entry->flush_marker); + HDassert(!entry->flush_in_progress); + + /* Note that the algorithm below is (very) similar to the set of operations + * in H5C__flush_single_entry() and should be kept in sync with changes + * to that code. - QAK, 2016/11/30 + */ - /* Update stats, as if we are "destroying" and taking ownership of the entry */ - H5C__UPDATE_STATS_FOR_EVICTION(cache, entry, TRUE) + /* Update stats, as if we are "destroying" and taking ownership of the entry */ + H5C__UPDATE_STATS_FOR_EVICTION(cache, entry, TRUE) - /* If the entry's type has a 'notify' callback, send a 'before eviction' - * notice while the entry is still fully integrated in the cache. - */ - if(entry->type->notify && (entry->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") - - /* Update the cache internal data structures as appropriate for a destroy. - * Specifically: - * 1) Delete it from the index - * 2) Delete it from the collective read access list - * 3) Update the replacement policy for eviction - * 4) Remove it from the tag list for this object - */ + /* If the entry's type has a 'notify' callback, send a 'before eviction' + * notice while the entry is still fully integrated in the cache. + */ + if (entry->type->notify && (entry->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") + + /* Update the cache internal data structures as appropriate for a destroy. + * Specifically: + * 1) Delete it from the index + * 2) Delete it from the collective read access list + * 3) Update the replacement policy for eviction + * 4) Remove it from the tag list for this object + */ - H5C__DELETE_FROM_INDEX(cache, entry, FAIL) + H5C__DELETE_FROM_INDEX(cache, entry, FAIL) #ifdef H5_HAVE_PARALLEL - /* Check for collective read access flag */ - if(entry->coll_access) { - entry->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache, entry, FAIL) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + /* Check for collective read access flag */ + if (entry->coll_access) { + entry->coll_access = FALSE; + H5C__REMOVE_FROM_COLL_LIST(cache, entry, FAIL) + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ - H5C__UPDATE_RP_FOR_EVICTION(cache, entry, FAIL) + H5C__UPDATE_RP_FOR_EVICTION(cache, entry, FAIL) - /* Remove entry from tag list */ - if(H5C__untag_entry(cache, entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") + /* Remove entry from tag list */ + if (H5C__untag_entry(cache, entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") - /* Increment entries_removed_counter and set last_entry_removed_ptr. - * As we me be about to free the entry, recall that last_entry_removed_ptr - * must NEVER be dereferenced. - * - * Recall that these fields are maintained to allow functions that perform - * scans of lists of entries to detect the unexpected removal of entries - * (via expunge, eviction, or take ownership at present), so that they can - * re-start their scans if necessary. - * - * Also check if the entry we are watching for removal is being - * removed (usually the 'next' entry for an iteration) and reset - * it to indicate that it was removed. - */ - cache->entries_removed_counter++; - cache->last_entry_removed_ptr = entry; - if(entry == cache->entry_watched_for_removal) - cache->entry_watched_for_removal = NULL; + /* Increment entries_removed_counter and set last_entry_removed_ptr. + * As we me be about to free the entry, recall that last_entry_removed_ptr + * must NEVER be dereferenced. + * + * Recall that these fields are maintained to allow functions that perform + * scans of lists of entries to detect the unexpected removal of entries + * (via expunge, eviction, or take ownership at present), so that they can + * re-start their scans if necessary. + * + * Also check if the entry we are watching for removal is being + * removed (usually the 'next' entry for an iteration) and reset + * it to indicate that it was removed. + */ + cache->entries_removed_counter++; + cache->last_entry_removed_ptr = entry; + if (entry == cache->entry_watched_for_removal) + cache->entry_watched_for_removal = NULL; - /* Internal cache data structures should now be up to date, and - * consistent with the status of the entry. - * - * Now clean up internal cache fields if appropriate. - */ + /* Internal cache data structures should now be up to date, and + * consistent with the status of the entry. + * + * Now clean up internal cache fields if appropriate. + */ - /* Free the buffer for the on disk image */ - if(entry->image_ptr != NULL) - entry->image_ptr = H5MM_xfree(entry->image_ptr); + /* Free the buffer for the on disk image */ + if (entry->image_ptr != NULL) + entry->image_ptr = H5MM_xfree(entry->image_ptr); - /* Reset the pointer to the cache the entry is within */ - entry->cache_ptr = NULL; + /* Reset the pointer to the cache the entry is within */ + entry->cache_ptr = NULL; - /* Client is taking ownership of the entry. Set bad magic here so the - * cache will choke unless the entry is re-inserted properly - */ - entry->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; + /* Client is taking ownership of the entry. Set bad magic here so the + * cache will choke unless the entry is re-inserted properly + */ + entry->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__remove_entry() */ - + FUNC_LEAVE_NOAPI(ret_value) + } /* H5C__remove_entry() */ diff --git a/src/H5CS.c b/src/H5CS.c index 3fccce4..cdeb977 100644 --- a/src/H5CS.c +++ b/src/H5CS.c @@ -25,20 +25,19 @@ * */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CSprivate.h" /* Function stack */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5CSprivate.h" /* Function stack */ +#include "H5Eprivate.h" /* Error handling */ #ifdef H5_HAVE_CODESTACK -#define H5CS_MIN_NSLOTS 16 /* Minimum number of records in an function stack */ +#define H5CS_MIN_NSLOTS 16 /* Minimum number of records in an function stack */ /* A function stack */ typedef struct H5CS_t { - unsigned nused; /* Number of records currently used in stack */ - unsigned nalloc; /* Number of records current allocated for stack */ - const char **rec; /* Array of function records */ + unsigned nused; /* Number of records currently used in stack */ + unsigned nalloc; /* Number of records current allocated for stack */ + const char **rec; /* Array of function records */ } H5CS_t; #ifdef H5_HAVE_THREADSAFE @@ -52,17 +51,16 @@ typedef struct H5CS_t { * by "H5CS_t *fstack =". */ static H5CS_t *H5CS__get_stack(void); -#define H5CS_get_my_stack() H5CS__get_stack() +#define H5CS_get_my_stack() H5CS__get_stack() #else /* H5_HAVE_THREADSAFE */ /* * The function stack. Eventually we'll have some sort of global table so each * thread has it's own stack. The stacks will be created on demand when the * thread first calls H5CS_push(). */ -H5CS_t H5CS_stack_g[1]; -#define H5CS_get_my_stack() (H5CS_stack_g+0) +H5CS_t H5CS_stack_g[1]; +#define H5CS_get_my_stack() (H5CS_stack_g + 0) #endif /* H5_HAVE_THREADSAFE */ - #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- * Function: H5CS__get_stack @@ -87,19 +85,21 @@ H5CS__get_stack(void) FUNC_ENTER_STATIC_NOERR_NOFS fstack = H5TS_get_thread_local_value(H5TS_funcstk_key_g); - if(!fstack) { + if (!fstack) { /* No associated value with current thread - create one */ #ifdef H5_HAVE_WIN_THREADS - fstack = (H5CS_t *)LocalAlloc(LPTR, sizeof(H5CS_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ + fstack = (H5CS_t *)LocalAlloc( + LPTR, sizeof(H5CS_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ #else - fstack = (H5CS_t *)HDmalloc(sizeof(H5CS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */ + fstack = (H5CS_t *)HDmalloc( + sizeof(H5CS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */ #endif /* H5_HAVE_WIN_THREADS */ HDassert(fstack); /* Set the thread-specific info */ - fstack->nused = 0; + fstack->nused = 0; fstack->nalloc = 0; - fstack->rec = NULL; + fstack->rec = NULL; /* (It's not necessary to release this in this API, it is * released by the "key destructor" set up in the H5TS @@ -110,9 +110,8 @@ H5CS__get_stack(void) FUNC_LEAVE_NOAPI_NOFS(fstack) } /* end H5CS__get_stack() */ -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ - /*------------------------------------------------------------------------- * Function: H5CS_print_stack * @@ -130,8 +129,8 @@ H5CS__get_stack(void) herr_t H5CS_print_stack(const H5CS_t *fstack, FILE *stream) { - const int indent = 2; /* Indention level */ - int i; /* Local index ariable */ + const int indent = 2; /* Indention level */ + int i; /* Local index ariable */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -140,23 +139,22 @@ H5CS_print_stack(const H5CS_t *fstack, FILE *stream) HDassert(fstack); /* Default to outputting information to stderr */ - if(!stream) + if (!stream) stream = stderr; HDfprintf(stream, "HDF5-DIAG: Function stack from %s ", H5_lib_vers_info_g); /* try show the process or thread id in multiple processes cases*/ HDfprintf(stream, "thread %" PRIu64 ".", H5TS_thread_id()); - if(fstack && fstack->nused>0) + if (fstack && fstack->nused > 0) HDfprintf(stream, " Back trace follows."); HDfputc('\n', stream); - for(i = fstack->nused - 1; i >= 0; --i) + for (i = fstack->nused - 1; i >= 0; --i) HDfprintf(stream, "%*s#%03d: Routine: %s\n", indent, "", i, fstack->rec[i]); FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_print_stack() */ - /*------------------------------------------------------------------------- * Function: H5CS_push * @@ -173,7 +171,7 @@ H5CS_print_stack(const H5CS_t *fstack, FILE *stream) herr_t H5CS_push(const char *func_name) { - H5CS_t *fstack = H5CS_get_my_stack(); /* Current function stack for library */ + H5CS_t *fstack = H5CS_get_my_stack(); /* Current function stack for library */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -184,7 +182,7 @@ H5CS_push(const char *func_name) HDassert(func_name); /* Check if we need to expand the stack of records */ - if(fstack->nused == fstack->nalloc) { + if (fstack->nused == fstack->nalloc) { size_t na = MAX((fstack->nalloc * 2), H5CS_MIN_NSLOTS); /* Don't use H5MM_realloc here */ @@ -192,7 +190,7 @@ H5CS_push(const char *func_name) /* (Avoid returning an error from this routine, currently -QAK) */ HDassert(x); - fstack->rec = x; + fstack->rec = x; fstack->nalloc = na; } /* end if */ @@ -203,7 +201,6 @@ H5CS_push(const char *func_name) FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_push() */ - /*------------------------------------------------------------------------- * Function: H5CS_pop * @@ -221,7 +218,7 @@ H5CS_push(const char *func_name) herr_t H5CS_pop(void) { - H5CS_t *fstack = H5CS_get_my_stack(); + H5CS_t *fstack = H5CS_get_my_stack(); /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -236,7 +233,6 @@ H5CS_pop(void) FUNC_LEAVE_NOAPI_NOFS(SUCCEED); } /* end H5CS_pop() */ - /*------------------------------------------------------------------------- * Function: H5CS_copy_stack * @@ -252,10 +248,10 @@ H5CS_pop(void) H5CS_t * H5CS_copy_stack(void) { - H5CS_t *old_stack = H5CS_get_my_stack(); /* Existing function stack for library */ - H5CS_t *new_stack; /* New function stack, for copy */ - unsigned u; /* Local index variable */ - H5CS_t *ret_value = NULL; /* Return value */ + H5CS_t * old_stack = H5CS_get_my_stack(); /* Existing function stack for library */ + H5CS_t * new_stack; /* New function stack, for copy */ + unsigned u; /* Local index variable */ + H5CS_t * ret_value = NULL; /* Return value */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOFS @@ -265,13 +261,13 @@ H5CS_copy_stack(void) /* Allocate a new stack */ /* (Don't use library allocate code, since this code stack supports it) */ - if(NULL == (new_stack = HDcalloc(1, sizeof(H5CS_t)))) + if (NULL == (new_stack = HDcalloc(1, sizeof(H5CS_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack") - if(NULL == (new_stack->rec = HDcalloc(old_stack->nused, sizeof(const char *)))) + if (NULL == (new_stack->rec = HDcalloc(old_stack->nused, sizeof(const char *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack records") /* Copy old stack to new one, duplicating the strings */ - for(u = 0; u < old_stack->nused; u++) + for (u = 0; u < old_stack->nused; u++) new_stack->rec[u] = HDstrdup(old_stack->rec[u]); new_stack->nused = new_stack->nalloc = old_stack->nused; @@ -282,7 +278,6 @@ done: FUNC_LEAVE_NOAPI_NOFS(ret_value) } /* end H5CS_copy_stack() */ - /*------------------------------------------------------------------------- * Function: H5CS_close_stack * @@ -298,7 +293,7 @@ done: herr_t H5CS_close_stack(H5CS_t *stack) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -307,20 +302,19 @@ H5CS_close_stack(H5CS_t *stack) HDassert(stack); /* Free stack */ - for(u = 0; u < stack->nused; u++) { - if(stack->rec[u]) + for (u = 0; u < stack->nused; u++) { + if (stack->rec[u]) HDfree((void *)stack->rec[u]); stack->rec[u] = NULL; } /* end for */ - if(stack->rec) { + if (stack->rec) { HDfree(stack->rec); stack->rec = NULL; } /* end if */ - if(stack) + if (stack) HDfree(stack); FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_close_stack() */ #endif /* H5_HAVE_CODESTACK */ - diff --git a/src/H5CSprivate.h b/src/H5CSprivate.h index 467dd9d..c86b209 100644 --- a/src/H5CSprivate.h +++ b/src/H5CSprivate.h @@ -26,11 +26,10 @@ /* Forward declarations for structure fields */ struct H5CS_t; -H5_DLL herr_t H5CS_push(const char *func_name); -H5_DLL herr_t H5CS_pop(void); -H5_DLL herr_t H5CS_print_stack(const struct H5CS_t *stack, FILE *stream); +H5_DLL herr_t H5CS_push(const char *func_name); +H5_DLL herr_t H5CS_pop(void); +H5_DLL herr_t H5CS_print_stack(const struct H5CS_t *stack, FILE *stream); H5_DLL struct H5CS_t *H5CS_copy_stack(void); -H5_DLL herr_t H5CS_close_stack(struct H5CS_t *stack); +H5_DLL herr_t H5CS_close_stack(struct H5CS_t *stack); #endif /* _H5CSprivate_H */ - diff --git a/src/H5CX.c b/src/H5CX.c index b78d9ec..c37361a 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -24,23 +24,20 @@ /* Module Setup */ /****************/ -#include "H5CXmodule.h" /* This source code file is part of the H5CX module */ - - +#include "H5CXmodule.h" /* This source code file is part of the H5CX module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ @@ -56,7 +53,7 @@ * In order for this macro to work, H5CX_get_my_context() must be preceeded * by "H5CX_node_t *ctx =". */ -#define H5CX_get_my_context() H5CX__get_context() +#define H5CX_get_my_context() H5CX__get_context() #else /* H5_HAVE_THREADSAFE */ /* * The current API context. @@ -65,84 +62,84 @@ #endif /* H5_HAVE_THREADSAFE */ /* Common macro for the retrieving the pointer to a property list */ -#define H5CX_RETRIEVE_PLIST(PL, FAILVAL) \ - /* Check if the property list is already available */ \ - if(NULL == (*head)->ctx.PL) \ - /* Get the property list pointer */ \ - if(NULL == ((*head)->ctx.PL = (H5P_genplist_t *)H5I_object((*head)->ctx.H5_GLUE(PL,_id)))) \ +#define H5CX_RETRIEVE_PLIST(PL, FAILVAL) \ + /* Check if the property list is already available */ \ + if (NULL == (*head)->ctx.PL) \ + /* Get the property list pointer */ \ + if (NULL == ((*head)->ctx.PL = (H5P_genplist_t *)H5I_object((*head)->ctx.H5_GLUE(PL, _id)))) \ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, (FAILVAL), "can't get property list") /* Common macro for the duplicated code to retrieve properties from a property list */ -#define H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - /* Check for default property list */ \ - if((*head)->ctx.H5_GLUE(PL,_id) == (DEF_PL)) \ - H5MM_memcpy(&(*head)->ctx.PROP_FIELD, &H5_GLUE3(H5CX_def_,PL,_cache).PROP_FIELD, sizeof(H5_GLUE3(H5CX_def_,PL,_cache).PROP_FIELD)); \ - else { \ - /* Retrieve the property list */ \ - H5CX_RETRIEVE_PLIST(PL, FAIL) \ - \ - /* Get the property */ \ - if(H5P_get((*head)->ctx.PL, (PROP_NAME), &(*head)->ctx.PROP_FIELD) < 0) \ - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't retrieve value from API context") \ - } /* end else */ \ - \ - /* Mark the field as valid */ \ - (*head)->ctx.H5_GLUE(PROP_FIELD,_valid) = TRUE; +#define H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ + /* Check for default property list */ \ + if ((*head)->ctx.H5_GLUE(PL, _id) == (DEF_PL)) \ + H5MM_memcpy(&(*head)->ctx.PROP_FIELD, &H5_GLUE3(H5CX_def_, PL, _cache).PROP_FIELD, \ + sizeof(H5_GLUE3(H5CX_def_, PL, _cache).PROP_FIELD)); \ + else { \ + /* Retrieve the property list */ \ + H5CX_RETRIEVE_PLIST(PL, FAIL) \ + \ + /* Get the property */ \ + if (H5P_get((*head)->ctx.PL, (PROP_NAME), &(*head)->ctx.PROP_FIELD) < 0) \ + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't retrieve value from API context") \ + } /* end else */ \ + \ + /* Mark the field as valid */ \ + (*head)->ctx.H5_GLUE(PROP_FIELD, _valid) = TRUE; /* Macro for the duplicated code to retrieve properties from a property list */ -#define H5CX_RETRIEVE_PROP_VALID(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - /* Check if the value has been retrieved already */ \ - if(!(*head)->ctx.H5_GLUE(PROP_FIELD,_valid)) { \ - H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ +#define H5CX_RETRIEVE_PROP_VALID(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ + /* Check if the value has been retrieved already */ \ + if (!(*head)->ctx.H5_GLUE(PROP_FIELD, _valid)) { \ + H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ } /* end if */ #ifdef H5_HAVE_PARALLEL /* Macro for the duplicated code to retrieve possibly set properties from a property list */ -#define H5CX_RETRIEVE_PROP_VALID_SET(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - /* Check if the value has been retrieved already */ \ - if(!((*head)->ctx.H5_GLUE(PROP_FIELD,_valid) || (*head)->ctx.H5_GLUE(PROP_FIELD,_set))) { \ - H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - } /* end if */ +#define H5CX_RETRIEVE_PROP_VALID_SET(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ + /* Check if the value has been retrieved already */ \ + if (!((*head)->ctx.H5_GLUE(PROP_FIELD, _valid) || (*head)->ctx.H5_GLUE(PROP_FIELD, _set))) { \ + H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ #if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_INSTRUMENTED_LIBRARY) /* Macro for the duplicated code to test and set properties for a property list */ -#define H5CX_TEST_SET_PROP(PROP_NAME, PROP_FIELD) \ -{ \ - htri_t check_prop = 0; /* Whether the property exists in the API context's DXPL */ \ - \ - /* Check if property exists in DXPL */ \ - if(!(*head)->ctx.H5_GLUE(PROP_FIELD,_set)) { \ - /* Retrieve the dataset transfer property list */ \ - H5CX_RETRIEVE_PLIST(dxpl, FAIL) \ - \ - if((check_prop = H5P_exist_plist((*head)->ctx.dxpl, PROP_NAME)) < 0) \ - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error checking for property") \ - } /* end if */ \ - \ - /* If property was already set or exists (for first set), update it */ \ - if((*head)->ctx.H5_GLUE(PROP_FIELD,_set) || check_prop > 0) { \ - /* Cache the value for later, marking it to set in DXPL when context popped */ \ - (*head)->ctx.PROP_FIELD = PROP_FIELD; \ - (*head)->ctx.H5_GLUE(PROP_FIELD,_set) = TRUE; \ - } /* end if */ \ -} +#define H5CX_TEST_SET_PROP(PROP_NAME, PROP_FIELD) \ + { \ + htri_t check_prop = 0; /* Whether the property exists in the API context's DXPL */ \ + \ + /* Check if property exists in DXPL */ \ + if (!(*head)->ctx.H5_GLUE(PROP_FIELD, _set)) { \ + /* Retrieve the dataset transfer property list */ \ + H5CX_RETRIEVE_PLIST(dxpl, FAIL) \ + \ + if ((check_prop = H5P_exist_plist((*head)->ctx.dxpl, PROP_NAME)) < 0) \ + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error checking for property") \ + } /* end if */ \ + \ + /* If property was already set or exists (for first set), update it */ \ + if ((*head)->ctx.H5_GLUE(PROP_FIELD, _set) || check_prop > 0) { \ + /* Cache the value for later, marking it to set in DXPL when context popped */ \ + (*head)->ctx.PROP_FIELD = PROP_FIELD; \ + (*head)->ctx.H5_GLUE(PROP_FIELD, _set) = TRUE; \ + } /* end if */ \ + } #endif /* defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_INSTRUMENTED_LIBRARY) */ #ifdef H5_HAVE_PARALLEL /* Macro for the duplicated code to test and set properties for a property list */ -#define H5CX_SET_PROP(PROP_NAME, PROP_FIELD) \ - if((*head)->ctx.H5_GLUE(PROP_FIELD,_set)) { \ - /* Retrieve the dataset transfer property list */ \ - H5CX_RETRIEVE_PLIST(dxpl, NULL) \ - \ - /* Set the property */ \ - if(H5P_set((*head)->ctx.dxpl, PROP_NAME, &(*head)->ctx.PROP_FIELD) < 0) \ - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, NULL, "error setting data xfer property") \ - } /* end if */ +#define H5CX_SET_PROP(PROP_NAME, PROP_FIELD) \ + if ((*head)->ctx.H5_GLUE(PROP_FIELD, _set)) { \ + /* Retrieve the dataset transfer property list */ \ + H5CX_RETRIEVE_PLIST(dxpl, NULL) \ + \ + /* Set the property */ \ + if (H5P_set((*head)->ctx.dxpl, PROP_NAME, &(*head)->ctx.PROP_FIELD) < 0) \ + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, NULL, "error setting data xfer property") \ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ - /******************/ /* Local Typedefs */ /******************/ @@ -180,142 +177,162 @@ */ typedef struct H5CX_t { /* DXPL */ - hid_t dxpl_id; /* DXPL ID for API operation */ - H5P_genplist_t *dxpl; /* Dataset Transfer Property List */ + hid_t dxpl_id; /* DXPL ID for API operation */ + H5P_genplist_t *dxpl; /* Dataset Transfer Property List */ /* LCPL */ - hid_t lcpl_id; /* LCPL ID for API operation */ - H5P_genplist_t *lcpl; /* Link Creation Property List */ + hid_t lcpl_id; /* LCPL ID for API operation */ + H5P_genplist_t *lcpl; /* Link Creation Property List */ /* LAPL */ - hid_t lapl_id; /* LAPL ID for API operation */ - H5P_genplist_t *lapl; /* Link Access Property List */ + hid_t lapl_id; /* LAPL ID for API operation */ + H5P_genplist_t *lapl; /* Link Access Property List */ /* DCPL */ - hid_t dcpl_id; /* DCPL ID for API operation */ - H5P_genplist_t *dcpl; /* Dataset Creation Property List */ + hid_t dcpl_id; /* DCPL ID for API operation */ + H5P_genplist_t *dcpl; /* Dataset Creation Property List */ /* DAPL */ - hid_t dapl_id; /* DAPL ID for API operation */ - H5P_genplist_t *dapl; /* Dataset Access Property List */ + hid_t dapl_id; /* DAPL ID for API operation */ + H5P_genplist_t *dapl; /* Dataset Access Property List */ /* FAPL */ - hid_t fapl_id; /* FAPL ID for API operation */ - H5P_genplist_t *fapl; /* File Access Property List */ + hid_t fapl_id; /* FAPL ID for API operation */ + H5P_genplist_t *fapl; /* File Access Property List */ /* Internal: Object tagging info */ - haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */ + haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */ /* Internal: Metadata cache info */ - H5AC_ring_t ring; /* Current metadata cache ring for entries */ + H5AC_ring_t ring; /* Current metadata cache ring for entries */ #ifdef H5_HAVE_PARALLEL /* Internal: Parallel I/O settings */ - hbool_t coll_metadata_read; /* Whether to use collective I/O for metadata read */ - MPI_Datatype btype; /* MPI datatype for buffer, when using collective I/O */ - MPI_Datatype ftype; /* MPI datatype for file, when using collective I/O */ - hbool_t mpi_file_flushing; /* Whether an MPI-opened file is being flushed */ - hbool_t rank0_bcast; /* Whether a dataset meets read-with-rank0-and-bcast requirements */ -#endif /* H5_HAVE_PARALLEL */ + hbool_t coll_metadata_read; /* Whether to use collective I/O for metadata read */ + MPI_Datatype btype; /* MPI datatype for buffer, when using collective I/O */ + MPI_Datatype ftype; /* MPI datatype for file, when using collective I/O */ + hbool_t mpi_file_flushing; /* Whether an MPI-opened file is being flushed */ + hbool_t rank0_bcast; /* Whether a dataset meets read-with-rank0-and-bcast requirements */ +#endif /* H5_HAVE_PARALLEL */ /* Cached DXPL properties */ - size_t max_temp_buf; /* Maximum temporary buffer size */ - hbool_t max_temp_buf_valid; /* Whether maximum temporary buffer size is valid */ - void *tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ - hbool_t tconv_buf_valid; /* Whether temporary conversion buffer is valid */ - void *bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ - hbool_t bkgr_buf_valid; /* Whether background conversion buffer is valid */ - H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_NAME) */ - hbool_t bkgr_buf_type_valid;/* Whether background buffer type is valid */ - double btree_split_ratio[3]; /* B-tree split ratios */ - hbool_t btree_split_ratio_valid; /* Whether B-tree split ratios are valid */ - size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ - hbool_t vec_size_valid; /* Whether hyperslab vector is valid */ + size_t max_temp_buf; /* Maximum temporary buffer size */ + hbool_t max_temp_buf_valid; /* Whether maximum temporary buffer size is valid */ + void * tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ + hbool_t tconv_buf_valid; /* Whether temporary conversion buffer is valid */ + void * bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ + hbool_t bkgr_buf_valid; /* Whether background conversion buffer is valid */ + H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_NAME) */ + hbool_t bkgr_buf_type_valid; /* Whether background buffer type is valid */ + double btree_split_ratio[3]; /* B-tree split ratios */ + hbool_t btree_split_ratio_valid; /* Whether B-tree split ratios are valid */ + size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ + hbool_t vec_size_valid; /* Whether hyperslab vector is valid */ #ifdef H5_HAVE_PARALLEL H5FD_mpio_xfer_t io_xfer_mode; /* Parallel transfer mode for this request (H5D_XFER_IO_XFER_MODE_NAME) */ - hbool_t io_xfer_mode_valid; /* Whether parallel transfer mode is valid */ - H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ - hbool_t mpio_coll_opt_valid; /* Whether parallel transfer option is valid */ - H5FD_mpio_chunk_opt_t mpio_chunk_opt_mode; /* Collective chunk option (H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME) */ - hbool_t mpio_chunk_opt_mode_valid; /* Whether collective chunk option is valid */ - unsigned mpio_chunk_opt_num; /* Collective chunk thrreshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ - hbool_t mpio_chunk_opt_num_valid; /* Whether collective chunk threshold is valid */ - unsigned mpio_chunk_opt_ratio; /* Collective chunk ratio (H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME) */ - hbool_t mpio_chunk_opt_ratio_valid; /* Whether collective chunk ratio is valid */ -#endif /* H5_HAVE_PARALLEL */ - H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ - hbool_t err_detect_valid; /* Whether error detection info is valid */ - H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ - hbool_t filter_cb_valid; /* Whether filter callback function is valid */ - H5Z_data_xform_t *data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ - hbool_t data_transform_valid; /* Whether data transform info is valid */ - H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ - hbool_t vl_alloc_info_valid; /* Whether VL datatype alloc info is valid */ - H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ - hbool_t dt_conv_cb_valid; /* Whether datatype conversion struct is valid */ + hbool_t io_xfer_mode_valid; /* Whether parallel transfer mode is valid */ + H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with + this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ + hbool_t mpio_coll_opt_valid; /* Whether parallel transfer option is valid */ + H5FD_mpio_chunk_opt_t + mpio_chunk_opt_mode; /* Collective chunk option (H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME) */ + hbool_t mpio_chunk_opt_mode_valid; /* Whether collective chunk option is valid */ + unsigned mpio_chunk_opt_num; /* Collective chunk thrreshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ + hbool_t mpio_chunk_opt_num_valid; /* Whether collective chunk threshold is valid */ + unsigned mpio_chunk_opt_ratio; /* Collective chunk ratio (H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME) */ + hbool_t mpio_chunk_opt_ratio_valid; /* Whether collective chunk ratio is valid */ +#endif /* H5_HAVE_PARALLEL */ + H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ + hbool_t err_detect_valid; /* Whether error detection info is valid */ + H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ + hbool_t filter_cb_valid; /* Whether filter callback function is valid */ + H5Z_data_xform_t * data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ + hbool_t data_transform_valid; /* Whether data transform info is valid */ + H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ + hbool_t vl_alloc_info_valid; /* Whether VL datatype alloc info is valid */ + H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ + hbool_t dt_conv_cb_valid; /* Whether datatype conversion struct is valid */ /* Return-only DXPL properties to return to application */ #ifdef H5_HAVE_PARALLEL - H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt; /* Chunk optimization mode used for parallel I/O (H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME) */ + H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt; /* Chunk optimization mode used for parallel I/O + (H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME) */ hbool_t mpio_actual_chunk_opt_set; /* Whether chunk optimization mode used for parallel I/O is set */ - H5D_mpio_actual_io_mode_t mpio_actual_io_mode; /* Actual I/O mode used for parallel I/O (H5D_MPIO_ACTUAL_IO_MODE_NAME) */ - hbool_t mpio_actual_io_mode_set; /* Whether actual I/O mode used for parallel I/O is set */ - uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ - hbool_t mpio_local_no_coll_cause_set; /* Whether local reason for breaking collective I/O is set */ - hbool_t mpio_local_no_coll_cause_valid; /* Whether local reason for breaking collective I/O is valid */ - uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ - hbool_t mpio_global_no_coll_cause_set; /* Whether global reason for breaking collective I/O is set */ + H5D_mpio_actual_io_mode_t + mpio_actual_io_mode; /* Actual I/O mode used for parallel I/O (H5D_MPIO_ACTUAL_IO_MODE_NAME) */ + hbool_t mpio_actual_io_mode_set; /* Whether actual I/O mode used for parallel I/O is set */ + uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O + (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ + hbool_t mpio_local_no_coll_cause_set; /* Whether local reason for breaking collective I/O is set */ + hbool_t mpio_local_no_coll_cause_valid; /* Whether local reason for breaking collective I/O is valid */ + uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O + (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ + hbool_t mpio_global_no_coll_cause_set; /* Whether global reason for breaking collective I/O is set */ hbool_t mpio_global_no_coll_cause_valid; /* Whether global reason for breaking collective I/O is valid */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - int mpio_coll_chunk_link_hard; /* Instrumented "collective chunk link hard" value (H5D_XFER_COLL_CHUNK_LINK_HARD_NAME) */ - hbool_t mpio_coll_chunk_link_hard_set; /* Whether instrumented "collective chunk link hard" value is set */ - int mpio_coll_chunk_multi_hard; /* Instrumented "collective chunk multi hard" value (H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME) */ - hbool_t mpio_coll_chunk_multi_hard_set; /* Whether instrumented "collective chunk multi hard" value is set */ - int mpio_coll_chunk_link_num_true; /* Instrumented "collective chunk link num true" value (H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME) */ - hbool_t mpio_coll_chunk_link_num_true_set; /* Whether instrumented "collective chunk link num true" value is set */ - int mpio_coll_chunk_link_num_false; /* Instrumented "collective chunk link num false" value (H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME) */ - hbool_t mpio_coll_chunk_link_num_false_set; /* Whether instrumented "collective chunk link num false" value is set */ - int mpio_coll_chunk_multi_ratio_coll; /* Instrumented "collective chunk multi ratio coll" value (H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME) */ - hbool_t mpio_coll_chunk_multi_ratio_coll_set; /* Whether instrumented "collective chunk multi ratio coll" value is set */ - int mpio_coll_chunk_multi_ratio_ind; /* Instrumented "collective chunk multi ratio ind" value (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ - hbool_t mpio_coll_chunk_multi_ratio_ind_set; /* Whether instrumented "collective chunk multi ratio ind" value is set */ - hbool_t mpio_coll_rank0_bcast; /* Instrumented "collective chunk multi ratio ind" value (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ - hbool_t mpio_coll_rank0_bcast_set; /* Whether instrumented "collective chunk multi ratio ind" value is set */ -#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ -#endif /* H5_HAVE_PARALLEL */ + int mpio_coll_chunk_link_hard; /* Instrumented "collective chunk link hard" value + (H5D_XFER_COLL_CHUNK_LINK_HARD_NAME) */ + hbool_t + mpio_coll_chunk_link_hard_set; /* Whether instrumented "collective chunk link hard" value is set */ + int mpio_coll_chunk_multi_hard; /* Instrumented "collective chunk multi hard" value + (H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME) */ + hbool_t + mpio_coll_chunk_multi_hard_set; /* Whether instrumented "collective chunk multi hard" value is set */ + int mpio_coll_chunk_link_num_true; /* Instrumented "collective chunk link num true" value + (H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME) */ + hbool_t mpio_coll_chunk_link_num_true_set; /* Whether instrumented "collective chunk link num true" value + is set */ + int mpio_coll_chunk_link_num_false; /* Instrumented "collective chunk link num false" value + (H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME) */ + hbool_t mpio_coll_chunk_link_num_false_set; /* Whether instrumented "collective chunk link num false" + value is set */ + int mpio_coll_chunk_multi_ratio_coll; /* Instrumented "collective chunk multi ratio coll" value + (H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME) */ + hbool_t mpio_coll_chunk_multi_ratio_coll_set; /* Whether instrumented "collective chunk multi ratio coll" + value is set */ + int mpio_coll_chunk_multi_ratio_ind; /* Instrumented "collective chunk multi ratio ind" value + (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ + hbool_t mpio_coll_chunk_multi_ratio_ind_set; /* Whether instrumented "collective chunk multi ratio ind" + value is set */ + hbool_t mpio_coll_rank0_bcast; /* Instrumented "collective chunk multi ratio ind" value + (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ + hbool_t + mpio_coll_rank0_bcast_set; /* Whether instrumented "collective chunk multi ratio ind" value is set */ +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ +#endif /* H5_HAVE_PARALLEL */ /* Cached LCPL properties */ - H5T_cset_t encoding; /* Link name character encoding */ - hbool_t encoding_valid; /* Whether link name character encoding is valid */ - unsigned intermediate_group; /* Whether to create intermediate groups */ - hbool_t intermediate_group_valid; /* Whether create intermediate group flag is valid */ + H5T_cset_t encoding; /* Link name character encoding */ + hbool_t encoding_valid; /* Whether link name character encoding is valid */ + unsigned intermediate_group; /* Whether to create intermediate groups */ + hbool_t intermediate_group_valid; /* Whether create intermediate group flag is valid */ /* Cached LAPL properties */ - size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ - hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ + size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ + hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ /* Cached DCPL properties */ - hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ - uint8_t ohdr_flags; /* Object header flags */ - hbool_t ohdr_flags_valid; /* Whether the object headers flags are valid */ + hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + uint8_t ohdr_flags; /* Object header flags */ + hbool_t ohdr_flags_valid; /* Whether the object headers flags are valid */ /* Cached DAPL properties */ - const char *extfile_prefix; /* Prefix for external file */ - hbool_t extfile_prefix_valid; /* Whether the prefix for external file is valid */ - const char *vds_prefix; /* Prefix for VDS */ - hbool_t vds_prefix_valid; /* Whether the prefix for VDS is valid */ + const char *extfile_prefix; /* Prefix for external file */ + hbool_t extfile_prefix_valid; /* Whether the prefix for external file is valid */ + const char *vds_prefix; /* Prefix for VDS */ + hbool_t vds_prefix_valid; /* Whether the prefix for VDS is valid */ /* Cached FAPL properties */ - H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ - hbool_t low_bound_valid; /* Whether low_bound property is valid */ - H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */ - hbool_t high_bound_valid; /* Whether high_bound property is valid */ + H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ + hbool_t low_bound_valid; /* Whether low_bound property is valid */ + H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */ + hbool_t high_bound_valid; /* Whether high_bound property is valid */ /* Cached VOL settings */ - H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info */ - hbool_t vol_connector_prop_valid; /* Whether property for VOL connector ID & info is valid */ - void *vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ + H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info */ + hbool_t vol_connector_prop_valid; /* Whether property for VOL connector ID & info is valid */ + void * vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ hbool_t vol_wrap_ctx_valid; /* Whether VOL connector's "wrap context" for creating IDs is valid */ } H5CX_t; @@ -326,8 +343,8 @@ typedef struct H5CX_t { * in H5CX__push_common(). */ typedef struct H5CX_node_t { - H5CX_t ctx; /* Context for current API call */ - struct H5CX_node_t *next; /* Pointer to previous context, on stack */ + H5CX_t ctx; /* Context for current API call */ + struct H5CX_node_t *next; /* Pointer to previous context, on stack */ } H5CX_node_t; /* Typedef for cached default dataset transfer property list information */ @@ -338,46 +355,50 @@ typedef struct H5CX_node_t { * up the property in the DXPL. */ typedef struct H5CX_dxpl_cache_t { - size_t max_temp_buf; /* Maximum temporary buffer size (H5D_XFER_MAX_TEMP_BUF_NAME) */ - void *tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ - void *bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ + size_t max_temp_buf; /* Maximum temporary buffer size (H5D_XFER_MAX_TEMP_BUF_NAME) */ + void * tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ + void * bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_NAME) */ - double btree_split_ratio[3]; /* B-tree split ratios (H5D_XFER_BTREE_SPLIT_RATIO_NAME) */ - size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ + double btree_split_ratio[3]; /* B-tree split ratios (H5D_XFER_BTREE_SPLIT_RATIO_NAME) */ + size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ #ifdef H5_HAVE_PARALLEL - H5FD_mpio_xfer_t io_xfer_mode; /* Parallel transfer mode for this request (H5D_XFER_IO_XFER_MODE_NAME) */ - H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ - uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ - uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ - H5FD_mpio_chunk_opt_t mpio_chunk_opt_mode; /* Collective chunk option (H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME) */ - unsigned mpio_chunk_opt_num; /* Collective chunk thrreshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ - unsigned mpio_chunk_opt_ratio; /* Collective chunk ratio (H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME) */ -#endif /* H5_HAVE_PARALLEL */ - H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ - H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ - H5Z_data_xform_t *data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ - H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ - H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ + H5FD_mpio_xfer_t io_xfer_mode; /* Parallel transfer mode for this request (H5D_XFER_IO_XFER_MODE_NAME) */ + H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with + this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ + uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O + (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ + uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O + (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ + H5FD_mpio_chunk_opt_t + mpio_chunk_opt_mode; /* Collective chunk option (H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME) */ + unsigned mpio_chunk_opt_num; /* Collective chunk thrreshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ + unsigned mpio_chunk_opt_ratio; /* Collective chunk ratio (H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME) */ +#endif /* H5_HAVE_PARALLEL */ + H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ + H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ + H5Z_data_xform_t * data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ + H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ + H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ } H5CX_dxpl_cache_t; /* Typedef for cached default link creation property list information */ /* (Same as the cached DXPL struct, above, except for the default LCPL) */ typedef struct H5CX_lcpl_cache_t { - H5T_cset_t encoding; /* Link name character encoding */ - unsigned intermediate_group; /* Whether to create intermediate groups */ + H5T_cset_t encoding; /* Link name character encoding */ + unsigned intermediate_group; /* Whether to create intermediate groups */ } H5CX_lcpl_cache_t; /* Typedef for cached default link access property list information */ /* (Same as the cached DXPL struct, above, except for the default LAPL) */ typedef struct H5CX_lapl_cache_t { - size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ + size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ } H5CX_lapl_cache_t; /* Typedef for cached default dataset creation property list information */ /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_dcpl_cache_t { - hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - uint8_t ohdr_flags; /* Object header flags */ + hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + uint8_t ohdr_flags; /* Object header flags */ } H5CX_dcpl_cache_t; /* Typedef for cached default dataset access property list information */ @@ -390,8 +411,8 @@ typedef struct H5CX_dapl_cache_t { /* Typedef for cached default file access property list information */ /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_fapl_cache_t { - H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ - H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */ + H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ + H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */ } H5CX_fapl_cache_t; /********************/ @@ -400,10 +421,9 @@ typedef struct H5CX_fapl_cache_t { #ifdef H5_HAVE_THREADSAFE static H5CX_node_t **H5CX__get_context(void); #endif /* H5_HAVE_THREADSAFE */ -static void H5CX__push_common(H5CX_node_t *cnode); +static void H5CX__push_common(H5CX_node_t *cnode); static H5CX_node_t *H5CX__pop_common(void); - /*********************/ /* Package Variables */ /*********************/ @@ -411,14 +431,13 @@ static H5CX_node_t *H5CX__pop_common(void); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*******************/ /* Local Variables */ /*******************/ #ifndef H5_HAVE_THREADSAFE -static H5CX_node_t *H5CX_head_g = NULL; /* Pointer to head of context stack */ -#endif /* H5_HAVE_THREADSAFE */ +static H5CX_node_t *H5CX_head_g = NULL; /* Pointer to head of context stack */ +#endif /* H5_HAVE_THREADSAFE */ /* Define a "default" dataset transfer property list cache structure to use for default DXPLs */ static H5CX_dxpl_cache_t H5CX_def_dxpl_cache; @@ -444,8 +463,6 @@ H5FL_DEFINE_STATIC(H5CX_node_t); /* Declare a static free list to manage H5CX_state_t structs */ H5FL_DEFINE_STATIC(H5CX_state_t); - - /*-------------------------------------------------------------------------- NAME H5CX__init_package -- Initialize interface-specific information @@ -459,13 +476,13 @@ DESCRIPTION herr_t H5CX__init_package(void) { - H5P_genplist_t *dx_plist; /* Data transfer property list */ - H5P_genplist_t *lc_plist; /* Link creation property list */ - H5P_genplist_t *la_plist; /* Link access property list */ - H5P_genplist_t *dc_plist; /* Dataset creation property list */ - H5P_genplist_t *da_plist; /* Dataset access property list */ - H5P_genplist_t *fa_plist; /* File access property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dx_plist; /* Data transfer property list */ + H5P_genplist_t *lc_plist; /* Link creation property list */ + H5P_genplist_t *la_plist; /* Link access property list */ + H5P_genplist_t *dc_plist; /* Dataset creation property list */ + H5P_genplist_t *da_plist; /* Dataset access property list */ + H5P_genplist_t *fa_plist; /* File access property list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -475,80 +492,82 @@ H5CX__init_package(void) /* Get the default DXPL cache information */ /* Get the default dataset transfer property list */ - if(NULL == (dx_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_XFER_DEFAULT))) + if (NULL == (dx_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_XFER_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get B-tree split ratios */ - if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &H5CX_def_dxpl_cache.btree_split_ratio) < 0) + if (H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &H5CX_def_dxpl_cache.btree_split_ratio) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve B-tree split ratios") /* Get maximum temporary buffer size value */ - if(H5P_get(dx_plist, H5D_XFER_MAX_TEMP_BUF_NAME, &H5CX_def_dxpl_cache.max_temp_buf) < 0) + if (H5P_get(dx_plist, H5D_XFER_MAX_TEMP_BUF_NAME, &H5CX_def_dxpl_cache.max_temp_buf) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve maximum temporary buffer size") /* Get temporary buffer pointer */ - if(H5P_get(dx_plist, H5D_XFER_TCONV_BUF_NAME, &H5CX_def_dxpl_cache.tconv_buf) < 0) + if (H5P_get(dx_plist, H5D_XFER_TCONV_BUF_NAME, &H5CX_def_dxpl_cache.tconv_buf) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve temporary buffer pointer") /* Get background buffer pointer */ - if(H5P_get(dx_plist, H5D_XFER_BKGR_BUF_NAME, &H5CX_def_dxpl_cache.bkgr_buf) < 0) + if (H5P_get(dx_plist, H5D_XFER_BKGR_BUF_NAME, &H5CX_def_dxpl_cache.bkgr_buf) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve background buffer pointer") /* Get background buffer type */ - if(H5P_get(dx_plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &H5CX_def_dxpl_cache.bkgr_buf_type) < 0) + if (H5P_get(dx_plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &H5CX_def_dxpl_cache.bkgr_buf_type) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve background buffer type") /* Get I/O vector size */ - if(H5P_get(dx_plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &H5CX_def_dxpl_cache.vec_size) < 0) + if (H5P_get(dx_plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &H5CX_def_dxpl_cache.vec_size) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve I/O vector size") #ifdef H5_HAVE_PARALLEL /* Collect Parallel I/O information for possible later use */ - if(H5P_get(dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &H5CX_def_dxpl_cache.io_xfer_mode) < 0) + if (H5P_get(dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &H5CX_def_dxpl_cache.io_xfer_mode) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve parallel transfer method") - if(H5P_get(dx_plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &H5CX_def_dxpl_cache.mpio_coll_opt) < 0) + if (H5P_get(dx_plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &H5CX_def_dxpl_cache.mpio_coll_opt) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve collective transfer option") - if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_mode) < 0) + if (H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_mode) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve chunk optimization option") - if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_num) < 0) + if (H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_num) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve chunk optimization threshold") - if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_ratio) < 0) + if (H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_ratio) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve chunk optimization ratio") /* Get the local & global reasons for breaking collective I/O values */ - if(H5P_get(dx_plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, &H5CX_def_dxpl_cache.mpio_local_no_coll_cause) < 0) + if (H5P_get(dx_plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, + &H5CX_def_dxpl_cache.mpio_local_no_coll_cause) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve local cause for breaking collective I/O") - if(H5P_get(dx_plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, &H5CX_def_dxpl_cache.mpio_global_no_coll_cause) < 0) + if (H5P_get(dx_plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, + &H5CX_def_dxpl_cache.mpio_global_no_coll_cause) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve global cause for breaking collective I/O") #endif /* H5_HAVE_PARALLEL */ /* Get error detection properties */ - if(H5P_get(dx_plist, H5D_XFER_EDC_NAME, &H5CX_def_dxpl_cache.err_detect) < 0) + if (H5P_get(dx_plist, H5D_XFER_EDC_NAME, &H5CX_def_dxpl_cache.err_detect) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve error detection info") /* Get filter callback function */ - if(H5P_get(dx_plist, H5D_XFER_FILTER_CB_NAME, &H5CX_def_dxpl_cache.filter_cb) < 0) + if (H5P_get(dx_plist, H5D_XFER_FILTER_CB_NAME, &H5CX_def_dxpl_cache.filter_cb) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve filter callback function") /* Look at the data transform property */ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need * to copy it and free this in the H5CX terminate routine. -QAK) */ - if(H5P_peek(dx_plist, H5D_XFER_XFORM_NAME, &H5CX_def_dxpl_cache.data_transform) < 0) + if (H5P_peek(dx_plist, H5D_XFER_XFORM_NAME, &H5CX_def_dxpl_cache.data_transform) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve data transform info") /* Get VL datatype alloc info */ - if(H5P_get(dx_plist, H5D_XFER_VLEN_ALLOC_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.alloc_func) < 0) + if (H5P_get(dx_plist, H5D_XFER_VLEN_ALLOC_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.alloc_func) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get(dx_plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.alloc_info) < 0) + if (H5P_get(dx_plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.alloc_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get(dx_plist, H5D_XFER_VLEN_FREE_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_func) < 0) + if (H5P_get(dx_plist, H5D_XFER_VLEN_FREE_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_func) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get(dx_plist, H5D_XFER_VLEN_FREE_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_info) < 0) + if (H5P_get(dx_plist, H5D_XFER_VLEN_FREE_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") /* Get datatype conversion struct */ - if(H5P_get(dx_plist, H5D_XFER_CONV_CB_NAME, &H5CX_def_dxpl_cache.dt_conv_cb) < 0) + if (H5P_get(dx_plist, H5D_XFER_CONV_CB_NAME, &H5CX_def_dxpl_cache.dt_conv_cb) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve datatype conversion exception callback") /* Reset the "default LCPL cache" information */ @@ -557,15 +576,15 @@ H5CX__init_package(void) /* Get the default LCPL cache information */ /* Get the default link creation property list */ - if(NULL == (lc_plist = (H5P_genplist_t *)H5I_object(H5P_LINK_CREATE_DEFAULT))) + if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(H5P_LINK_CREATE_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a link creation property list") /* Get link name character encoding */ - if(H5P_get(lc_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &H5CX_def_lcpl_cache.encoding) < 0) + if (H5P_get(lc_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &H5CX_def_lcpl_cache.encoding) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve link name encoding") /* Get flag whether to create intermediate groups */ - if(H5P_get(lc_plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &H5CX_def_lcpl_cache.intermediate_group) < 0) + if (H5P_get(lc_plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &H5CX_def_lcpl_cache.intermediate_group) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve intermediate group creation flag") /* Reset the "default LAPL cache" information */ @@ -574,11 +593,11 @@ H5CX__init_package(void) /* Get the default LAPL cache information */ /* Get the default link access property list */ - if(NULL == (la_plist = (H5P_genplist_t *)H5I_object(H5P_LINK_ACCESS_DEFAULT))) + if (NULL == (la_plist = (H5P_genplist_t *)H5I_object(H5P_LINK_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a link access property list") /* Get number of soft / UD links to traverse */ - if(H5P_get(la_plist, H5L_ACS_NLINKS_NAME, &H5CX_def_lapl_cache.nlinks) < 0) + if (H5P_get(la_plist, H5L_ACS_NLINKS_NAME, &H5CX_def_lapl_cache.nlinks) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve number of soft / UD links to traverse") /* Reset the "default DCPL cache" information */ @@ -587,15 +606,15 @@ H5CX__init_package(void) /* Get the default DCPL cache information */ /* Get the default dataset creation property list */ - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_CREATE_DEFAULT))) + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_CREATE_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list") /* Get flag to indicate whether to minimize dataset object header */ - if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) + if (H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") /* Get object header flags */ - if(H5P_get(dc_plist, H5O_CRT_OHDR_FLAGS_NAME, &H5CX_def_dcpl_cache.ohdr_flags) < 0) + if (H5P_get(dc_plist, H5O_CRT_OHDR_FLAGS_NAME, &H5CX_def_dcpl_cache.ohdr_flags) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve object header flags") /* Reset the "default DAPL cache" information */ @@ -604,15 +623,15 @@ H5CX__init_package(void) /* Get the default DAPL cache information */ /* Get the default dataset access property list */ - if(NULL == (da_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_ACCESS_DEFAULT))) + if (NULL == (da_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list") /* Get the prefix for the external file */ - if(H5P_peek(da_plist, H5D_ACS_EFILE_PREFIX_NAME, &H5CX_def_dapl_cache.extfile_prefix) < 0) + if (H5P_peek(da_plist, H5D_ACS_EFILE_PREFIX_NAME, &H5CX_def_dapl_cache.extfile_prefix) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for external file") /* Get the prefix for the VDS file */ - if(H5P_peek(da_plist, H5D_ACS_VDS_PREFIX_NAME, &H5CX_def_dapl_cache.vds_prefix) < 0) + if (H5P_peek(da_plist, H5D_ACS_VDS_PREFIX_NAME, &H5CX_def_dapl_cache.vds_prefix) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for VDS") /* Reset the "default FAPL cache" information */ @@ -621,21 +640,20 @@ H5CX__init_package(void) /* Get the default FAPL cache information */ /* Get the default file access property list */ - if(NULL == (fa_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + if (NULL == (fa_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list") /* Get low_bound */ - if(H5P_get(fa_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &H5CX_def_fapl_cache.low_bound) < 0) + if (H5P_get(fa_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &H5CX_def_fapl_cache.low_bound) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") - if(H5P_get(fa_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &H5CX_def_fapl_cache.high_bound) < 0) + if (H5P_get(fa_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &H5CX_def_fapl_cache.high_bound) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX__init_package() */ - /*------------------------------------------------------------------------- * Function: H5CX_term_package * @@ -655,8 +673,8 @@ H5CX_term_package(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - H5CX_node_t *cnode; /* Context node */ + if (H5_PKG_INIT_VAR) { + H5CX_node_t *cnode; /* Context node */ /* Pop the top context node from the stack */ /* (Can't check for errors, as rest of library is shut down) */ @@ -676,7 +694,6 @@ H5CX_term_package(void) FUNC_LEAVE_NOAPI(0) } /* end H5CX_term_package() */ - #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- * Function: H5CX__get_context @@ -701,7 +718,7 @@ H5CX__get_context(void) ctx = (H5CX_node_t **)H5TS_get_thread_local_value(H5TS_apictx_key_g); - if(!ctx) { + if (!ctx) { /* No associated value with current thread - create one */ #ifdef H5_HAVE_WIN_THREADS /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ @@ -727,9 +744,8 @@ H5CX__get_context(void) /* Set return value */ FUNC_LEAVE_NOAPI(ctx) } /* end H5CX__get_context() */ -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ - /*------------------------------------------------------------------------- * Function: H5CX__push_common * @@ -745,7 +761,8 @@ H5CX__get_context(void) static void H5CX__push_common(H5CX_node_t *cnode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_STATIC_NOERR @@ -759,17 +776,16 @@ H5CX__push_common(H5CX_node_t *cnode) cnode->ctx.lcpl_id = H5P_LINK_CREATE_DEFAULT; cnode->ctx.lapl_id = H5P_LINK_ACCESS_DEFAULT; cnode->ctx.fapl_id = H5P_FILE_ACCESS_DEFAULT; - cnode->ctx.tag = H5AC__INVALID_TAG; - cnode->ctx.ring = H5AC_RING_USER; + cnode->ctx.tag = H5AC__INVALID_TAG; + cnode->ctx.ring = H5AC_RING_USER; /* Push context node onto stack */ cnode->next = *head; - *head = cnode; + *head = cnode; FUNC_LEAVE_NOAPI_VOID } /* end H5CX__push_common() */ - /*------------------------------------------------------------------------- * Function: H5CX_push * @@ -785,13 +801,13 @@ H5CX__push_common(H5CX_node_t *cnode) herr_t H5CX_push(void) { - H5CX_node_t *cnode = NULL; /* Context node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t *cnode = NULL; /* Context node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Allocate & clear API context node */ - if(NULL == (cnode = H5FL_CALLOC(H5CX_node_t))) + if (NULL == (cnode = H5FL_CALLOC(H5CX_node_t))) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTALLOC, FAIL, "unable to allocate new struct") /* Set context info */ @@ -801,7 +817,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_push() */ - /*------------------------------------------------------------------------- * Function: H5CX_push_special * @@ -819,7 +834,7 @@ done: void H5CX_push_special(void) { - H5CX_node_t *cnode; /* Context node */ + H5CX_node_t *cnode; /* Context node */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -833,7 +848,6 @@ H5CX_push_special(void) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_push_special() */ - /*------------------------------------------------------------------------- * Function: H5CX_retrieve_state * @@ -854,8 +868,9 @@ H5CX_push_special(void) herr_t H5CX_retrieve_state(H5CX_state_t **api_state) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -864,52 +879,52 @@ H5CX_retrieve_state(H5CX_state_t **api_state) HDassert(api_state); /* Allocate & clear API context state */ - if(NULL == (*api_state = H5FL_CALLOC(H5CX_state_t))) + if (NULL == (*api_state = H5FL_CALLOC(H5CX_state_t))) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTALLOC, FAIL, "unable to allocate new API context state") /* Check for non-default DCPL */ - if(H5P_DATASET_CREATE_DEFAULT != (*head)->ctx.dcpl_id) { + if (H5P_DATASET_CREATE_DEFAULT != (*head)->ctx.dcpl_id) { /* Retrieve the DCPL property list */ H5CX_RETRIEVE_PLIST(dcpl, FAIL) /* Copy the DCPL ID */ - if(((*api_state)->dcpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.dcpl, FALSE)) < 0) + if (((*api_state)->dcpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.dcpl, FALSE)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") } /* end if */ else (*api_state)->dcpl_id = H5P_DATASET_CREATE_DEFAULT; /* Check for non-default DXPL */ - if(H5P_DATASET_XFER_DEFAULT != (*head)->ctx.dxpl_id) { + if (H5P_DATASET_XFER_DEFAULT != (*head)->ctx.dxpl_id) { /* Retrieve the DXPL property list */ H5CX_RETRIEVE_PLIST(dxpl, FAIL) /* Copy the DXPL ID */ - if(((*api_state)->dxpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.dxpl, FALSE)) < 0) + if (((*api_state)->dxpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.dxpl, FALSE)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") } /* end if */ else (*api_state)->dxpl_id = H5P_DATASET_XFER_DEFAULT; /* Check for non-default LAPL */ - if(H5P_LINK_ACCESS_DEFAULT != (*head)->ctx.lapl_id) { + if (H5P_LINK_ACCESS_DEFAULT != (*head)->ctx.lapl_id) { /* Retrieve the LAPL property list */ H5CX_RETRIEVE_PLIST(lapl, FAIL) /* Copy the LAPL ID */ - if(((*api_state)->lapl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.lapl, FALSE)) < 0) + if (((*api_state)->lapl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.lapl, FALSE)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") } /* end if */ else (*api_state)->lapl_id = H5P_LINK_ACCESS_DEFAULT; /* Check for non-default LCPL */ - if(H5P_LINK_CREATE_DEFAULT != (*head)->ctx.lcpl_id) { + if (H5P_LINK_CREATE_DEFAULT != (*head)->ctx.lcpl_id) { /* Retrieve the LCPL property list */ H5CX_RETRIEVE_PLIST(lcpl, FAIL) /* Copy the LCPL ID */ - if(((*api_state)->lcpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.lcpl, FALSE)) < 0) + if (((*api_state)->lcpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.lcpl, FALSE)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") } /* end if */ else @@ -917,37 +932,40 @@ H5CX_retrieve_state(H5CX_state_t **api_state) /* Keep a reference to the current VOL wrapping context */ (*api_state)->vol_wrap_ctx = (*head)->ctx.vol_wrap_ctx; - if(NULL != (*api_state)->vol_wrap_ctx) - if(H5VL_inc_vol_wrapper((*api_state)->vol_wrap_ctx) < 0) + if (NULL != (*api_state)->vol_wrap_ctx) + if (H5VL_inc_vol_wrapper((*api_state)->vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTINC, FAIL, "can't increment refcount on VOL wrapping context") /* Keep a copy of the VOL connector property, if there is one */ - if((*head)->ctx.vol_connector_prop_valid && (*head)->ctx.vol_connector_prop.connector_id > 0) { + if ((*head)->ctx.vol_connector_prop_valid && (*head)->ctx.vol_connector_prop.connector_id > 0) { /* Get the connector property */ - H5MM_memcpy(&(*api_state)->vol_connector_prop, &(*head)->ctx.vol_connector_prop, sizeof(H5VL_connector_prop_t)); + H5MM_memcpy(&(*api_state)->vol_connector_prop, &(*head)->ctx.vol_connector_prop, + sizeof(H5VL_connector_prop_t)); /* Check for actual VOL connector property */ - if((*api_state)->vol_connector_prop.connector_id) { + if ((*api_state)->vol_connector_prop.connector_id) { /* Copy connector info, if it exists */ - if((*api_state)->vol_connector_prop.connector_info) { - H5VL_class_t *connector; /* Pointer to connector */ - void *new_connector_info = NULL; /* Copy of connector info */ + if ((*api_state)->vol_connector_prop.connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ + void * new_connector_info = NULL; /* Copy of connector info */ /* Retrieve the connector for the ID */ - if(NULL == (connector = (H5VL_class_t *)H5I_object((*api_state)->vol_connector_prop.connector_id))) + if (NULL == + (connector = (H5VL_class_t *)H5I_object((*api_state)->vol_connector_prop.connector_id))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Allocate and copy connector info */ - if(H5VL_copy_connector_info(connector, &new_connector_info, (*api_state)->vol_connector_prop.connector_info) < 0) + if (H5VL_copy_connector_info(connector, &new_connector_info, + (*api_state)->vol_connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "connector info copy failed") (*api_state)->vol_connector_prop.connector_info = new_connector_info; } /* end if */ /* Increment the refcount on the connector ID */ - if(H5I_inc_ref((*api_state)->vol_connector_prop.connector_id, FALSE) < 0) + if (H5I_inc_ref((*api_state)->vol_connector_prop.connector_id, FALSE) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed") } /* end if */ - } /* end if */ + } /* end if */ #ifdef H5_HAVE_PARALLEL /* Save parallel I/O settings */ @@ -958,7 +976,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_retrieve_state() */ - /*------------------------------------------------------------------------- * Function: H5CX_restore_state * @@ -979,7 +996,8 @@ done: herr_t H5CX_restore_state(const H5CX_state_t *api_state) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -989,26 +1007,27 @@ H5CX_restore_state(const H5CX_state_t *api_state) /* Restore the DCPL info */ (*head)->ctx.dcpl_id = api_state->dcpl_id; - (*head)->ctx.dcpl = NULL; + (*head)->ctx.dcpl = NULL; /* Restore the DXPL info */ (*head)->ctx.dxpl_id = api_state->dxpl_id; - (*head)->ctx.dxpl = NULL; + (*head)->ctx.dxpl = NULL; /* Restore the LAPL info */ (*head)->ctx.lapl_id = api_state->lapl_id; - (*head)->ctx.lapl = NULL; + (*head)->ctx.lapl = NULL; /* Restore the LCPL info */ (*head)->ctx.lcpl_id = api_state->lcpl_id; - (*head)->ctx.lcpl = NULL; + (*head)->ctx.lcpl = NULL; /* Restore the VOL wrapper context */ (*head)->ctx.vol_wrap_ctx = api_state->vol_wrap_ctx; /* Restore the VOL connector info */ - if(api_state->vol_connector_prop.connector_id) { - H5MM_memcpy(&(*head)->ctx.vol_connector_prop, &api_state->vol_connector_prop, sizeof(H5VL_connector_prop_t)); + if (api_state->vol_connector_prop.connector_id) { + H5MM_memcpy(&(*head)->ctx.vol_connector_prop, &api_state->vol_connector_prop, + sizeof(H5VL_connector_prop_t)); (*head)->ctx.vol_connector_prop_valid = TRUE; } /* end if */ @@ -1020,7 +1039,6 @@ H5CX_restore_state(const H5CX_state_t *api_state) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5CX_restore_state() */ - /*------------------------------------------------------------------------- * Function: H5CX_free_state * @@ -1036,7 +1054,7 @@ H5CX_restore_state(const H5CX_state_t *api_state) herr_t H5CX_free_state(H5CX_state_t *api_state) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1044,38 +1062,39 @@ H5CX_free_state(H5CX_state_t *api_state) HDassert(api_state); /* Release the DCPL */ - if(api_state->dcpl_id != H5P_DATASET_CREATE_DEFAULT) - if(H5I_dec_ref(api_state->dcpl_id) < 0) + if (api_state->dcpl_id != H5P_DATASET_CREATE_DEFAULT) + if (H5I_dec_ref(api_state->dcpl_id) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on DCPL") /* Release the DXPL */ - if(api_state->dxpl_id != H5P_DATASET_XFER_DEFAULT) - if(H5I_dec_ref(api_state->dxpl_id) < 0) + if (api_state->dxpl_id != H5P_DATASET_XFER_DEFAULT) + if (H5I_dec_ref(api_state->dxpl_id) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on DXPL") /* Release the LAPL */ - if(api_state->lapl_id != H5P_LINK_ACCESS_DEFAULT) - if(H5I_dec_ref(api_state->lapl_id) < 0) + if (api_state->lapl_id != H5P_LINK_ACCESS_DEFAULT) + if (H5I_dec_ref(api_state->lapl_id) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on LAPL") /* Release the LCPL */ - if(api_state->lcpl_id != H5P_LINK_CREATE_DEFAULT) - if(H5I_dec_ref(api_state->lcpl_id) < 0) + if (api_state->lcpl_id != H5P_LINK_CREATE_DEFAULT) + if (H5I_dec_ref(api_state->lcpl_id) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on LCPL") /* Release the VOL wrapper context */ - if(api_state->vol_wrap_ctx) - if(H5VL_dec_vol_wrapper(api_state->vol_wrap_ctx) < 0) + if (api_state->vol_wrap_ctx) + if (H5VL_dec_vol_wrapper(api_state->vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on VOL wrapping context") /* Release the VOL connector property, if it was set */ - if(api_state->vol_connector_prop.connector_id) { + if (api_state->vol_connector_prop.connector_id) { /* Clean up any VOL connector info */ - if(api_state->vol_connector_prop.connector_info) - if(H5VL_free_connector_info(api_state->vol_connector_prop.connector_id, api_state->vol_connector_prop.connector_info) < 0) + if (api_state->vol_connector_prop.connector_info) + if (H5VL_free_connector_info(api_state->vol_connector_prop.connector_id, + api_state->vol_connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") /* Decrement connector ID */ - if(H5I_dec_ref(api_state->vol_connector_prop.connector_id) < 0) + if (H5I_dec_ref(api_state->vol_connector_prop.connector_id) < 0) HDONE_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't close VOL connector ID") } /* end if */ @@ -1086,7 +1105,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_free_state() */ - /*------------------------------------------------------------------------- * Function: H5CX_is_def_dxpl * @@ -1102,7 +1120,8 @@ done: hbool_t H5CX_is_def_dxpl(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1112,7 +1131,6 @@ H5CX_is_def_dxpl(void) FUNC_LEAVE_NOAPI((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT); } /* end H5CX_is_def_dxpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_dxpl * @@ -1128,7 +1146,8 @@ H5CX_is_def_dxpl(void) void H5CX_set_dxpl(hid_t dxpl_id) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1141,7 +1160,6 @@ H5CX_set_dxpl(hid_t dxpl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_dxpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_dcpl * @@ -1157,7 +1175,8 @@ H5CX_set_dxpl(hid_t dxpl_id) void H5CX_set_dcpl(hid_t dcpl_id) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1170,7 +1189,6 @@ H5CX_set_dcpl(hid_t dcpl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_dcpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_libver_bounds * @@ -1187,8 +1205,9 @@ H5CX_set_dcpl(hid_t dcpl_id) herr_t H5CX_set_libver_bounds(H5F_t *f) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1196,18 +1215,17 @@ H5CX_set_libver_bounds(H5F_t *f) HDassert(head && *head); /* Set the API context value */ - (*head)->ctx.low_bound = (f == NULL) ? H5F_LIBVER_LATEST : H5F_LOW_BOUND(f); + (*head)->ctx.low_bound = (f == NULL) ? H5F_LIBVER_LATEST : H5F_LOW_BOUND(f); (*head)->ctx.high_bound = (f == NULL) ? H5F_LIBVER_LATEST : H5F_HIGH_BOUND(f); /* Mark the values as valid */ - (*head)->ctx.low_bound_valid = TRUE; + (*head)->ctx.low_bound_valid = TRUE; (*head)->ctx.high_bound_valid = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_lcpl * @@ -1223,7 +1241,8 @@ done: void H5CX_set_lcpl(hid_t lcpl_id) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1236,7 +1255,6 @@ H5CX_set_lcpl(hid_t lcpl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_lcpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_lapl * @@ -1252,7 +1270,8 @@ H5CX_set_lcpl(hid_t lcpl_id) void H5CX_set_lapl(hid_t lapl_id) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1265,7 +1284,6 @@ H5CX_set_lapl(hid_t lapl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_lapl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_apl * @@ -1281,18 +1299,20 @@ H5CX_set_lapl(hid_t lapl_id) */ herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, - hid_t + hid_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - loc_id, hbool_t + loc_id, + hbool_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - is_collective) + is_collective) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1302,35 +1322,38 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, HDassert(head && *head); /* Set access plist to the default property list of the appropriate class if it's the generic default */ - if(H5P_DEFAULT == *acspl_id) + if (H5P_DEFAULT == *acspl_id) *acspl_id = *libclass->def_plist_id; else { - htri_t is_lapl; /* Whether the access property list is (or is derived from) a link access property list */ - htri_t is_dapl; /* Whether the access property list is (or is derived from) a dataset access property list */ - htri_t is_fapl; /* Whether the access property list is (or is derived from) a file access property list */ + htri_t is_lapl; /* Whether the access property list is (or is derived from) a link access property + list */ + htri_t is_dapl; /* Whether the access property list is (or is derived from) a dataset access property + list */ + htri_t is_fapl; /* Whether the access property list is (or is derived from) a file access property + list */ #ifdef H5CX_DEBUG /* Sanity check the access property list class */ - if(TRUE != H5P_isa_class(*acspl_id, *libclass->class_id)) + if (TRUE != H5P_isa_class(*acspl_id, *libclass->class_id)) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not the required access property list") #endif /* H5CX_DEBUG*/ /* Check for link access property and set API context if so */ - if((is_lapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_LACC->pclass)) < 0) + if ((is_lapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_LACC->pclass)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for link access class") - else if(is_lapl) + else if (is_lapl) (*head)->ctx.lapl_id = *acspl_id; /* Check for dataset access property and set API context if so */ - if((is_dapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_DACC->pclass)) < 0) + if ((is_dapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_DACC->pclass)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for dataset access class") - else if(is_dapl) + else if (is_dapl) (*head)->ctx.dapl_id = *acspl_id; /* Check for file access property and set API context if so */ - if((is_fapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_FACC->pclass)) < 0) + if ((is_fapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_FACC->pclass)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for file access class") - else if(is_fapl) + else if (is_fapl) (*head)->ctx.fapl_id = *acspl_id; #ifdef H5_HAVE_PARALLEL @@ -1338,28 +1361,28 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, * modify the structural metadata in a file), check if the application * specified a collective metadata read for just this operation. */ - if(!is_collective) { - H5P_genplist_t *plist; /* Property list pointer */ - H5P_coll_md_read_flag_t md_coll_read; /* Collective metadata read flag */ + if (!is_collective) { + H5P_genplist_t * plist; /* Property list pointer */ + H5P_coll_md_read_flag_t md_coll_read; /* Collective metadata read flag */ /* Get the plist structure for the access property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(*acspl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(*acspl_id))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the collective metadata read flag */ - if(H5P_peek(plist, H5_COLL_MD_READ_FLAG_NAME, &md_coll_read) < 0) + if (H5P_peek(plist, H5_COLL_MD_READ_FLAG_NAME, &md_coll_read) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't get core collective metadata read flag") /* If collective metadata read requested, set collective metadata read flag */ - if(H5P_USER_TRUE == md_coll_read) + if (H5P_USER_TRUE == md_coll_read) is_collective = TRUE; } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - } /* end else */ +#endif /* H5_HAVE_PARALLEL */ + } /* end else */ #ifdef H5_HAVE_PARALLEL /* Check for collective operation */ - if(is_collective) { + if (is_collective) { /* Set collective metadata read flag */ (*head)->ctx.coll_metadata_read = TRUE; @@ -1369,25 +1392,24 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, * happens only when the environment variable H5_COLL_BARRIER is set * to non 0. */ - if(H5_coll_api_sanity_check_g) { - MPI_Comm mpi_comm; /* File communicator */ + if (H5_coll_api_sanity_check_g) { + MPI_Comm mpi_comm; /* File communicator */ /* Retrieve the MPI communicator from the loc_id or the fapl_id */ - if(H5F_mpi_retrieve_comm(loc_id, *acspl_id, &mpi_comm) < 0) + if (H5F_mpi_retrieve_comm(loc_id, *acspl_id, &mpi_comm) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") /* issue the barrier */ - if(mpi_comm != MPI_COMM_NULL) + if (mpi_comm != MPI_COMM_NULL) MPI_Barrier(mpi_comm); } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_apl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_loc * @@ -1406,13 +1428,14 @@ done: herr_t H5CX_set_loc(hid_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - loc_id) + loc_id) { #ifdef H5_HAVE_PARALLEL - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1428,28 +1451,27 @@ H5CX_set_loc(hid_t * happens only when the environment variable H5_COLL_BARRIER is set * to non 0. */ - if(H5_coll_api_sanity_check_g) { - MPI_Comm mpi_comm; /* File communicator */ + if (H5_coll_api_sanity_check_g) { + MPI_Comm mpi_comm; /* File communicator */ /* Retrieve the MPI communicator from the loc_id or the fapl_id */ - if(H5F_mpi_retrieve_comm(loc_id, H5P_DEFAULT, &mpi_comm) < 0) + if (H5F_mpi_retrieve_comm(loc_id, H5P_DEFAULT, &mpi_comm) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") /* issue the barrier */ - if(mpi_comm != MPI_COMM_NULL) + if (mpi_comm != MPI_COMM_NULL) MPI_Barrier(mpi_comm); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -#else /* H5_HAVE_PARALLEL */ +#else /* H5_HAVE_PARALLEL */ FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(SUCCEED) #endif /* H5_HAVE_PARALLEL */ } /* end H5CX_set_loc() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_vol_wrap_ctx * @@ -1465,8 +1487,9 @@ done: herr_t H5CX_set_vol_wrap_ctx(void *vol_wrap_ctx) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1483,7 +1506,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vol_wrap_ctx() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_vol_connector_prop * @@ -1499,8 +1521,9 @@ done: herr_t H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1517,7 +1540,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vol_connector_prop() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_dxpl * @@ -1533,7 +1555,8 @@ done: hid_t H5CX_get_dxpl(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1543,7 +1566,6 @@ H5CX_get_dxpl(void) FUNC_LEAVE_NOAPI((*head)->ctx.dxpl_id) } /* end H5CX_get_dxpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_lapl * @@ -1559,7 +1581,8 @@ H5CX_get_dxpl(void) hid_t H5CX_get_lapl(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1569,7 +1592,6 @@ H5CX_get_lapl(void) FUNC_LEAVE_NOAPI((*head)->ctx.lapl_id) } /* end H5CX_get_lapl() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_vol_wrap_ctx * @@ -1585,8 +1607,9 @@ H5CX_get_lapl(void) herr_t H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1595,7 +1618,7 @@ H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) HDassert(head && *head); /* Check for value that was set */ - if((*head)->ctx.vol_wrap_ctx_valid) + if ((*head)->ctx.vol_wrap_ctx_valid) /* Get the value */ *vol_wrap_ctx = (*head)->ctx.vol_wrap_ctx; else @@ -1605,7 +1628,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vol_wrap_ctx() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_vol_connector_prop * @@ -1621,8 +1643,9 @@ done: herr_t H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1631,7 +1654,7 @@ H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) HDassert(head && *head); /* Check for value that was set */ - if((*head)->ctx.vol_connector_prop_valid) + if ((*head)->ctx.vol_connector_prop_valid) /* Get the value */ H5MM_memcpy(vol_connector_prop, &(*head)->ctx.vol_connector_prop, sizeof(H5VL_connector_prop_t)); else @@ -1641,7 +1664,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vol_connector_prop() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_tag * @@ -1657,7 +1679,8 @@ done: haddr_t H5CX_get_tag(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1667,7 +1690,6 @@ H5CX_get_tag(void) FUNC_LEAVE_NOAPI((*head)->ctx.tag) } /* end H5CX_get_tag() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_ring * @@ -1683,7 +1705,8 @@ H5CX_get_tag(void) H5AC_ring_t H5CX_get_ring(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1694,7 +1717,7 @@ H5CX_get_ring(void) } /* end H5CX_get_ring() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5CX_get_coll_metadata_read * @@ -1710,7 +1733,8 @@ H5CX_get_ring(void) hbool_t H5CX_get_coll_metadata_read(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1720,7 +1744,6 @@ H5CX_get_coll_metadata_read(void) FUNC_LEAVE_NOAPI((*head)->ctx.coll_metadata_read) } /* end H5CX_get_coll_metadata_read() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpi_coll_datatypes * @@ -1738,8 +1761,9 @@ H5CX_get_coll_metadata_read(void) herr_t H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1756,7 +1780,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpi_coll_datatypes() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpi_file_flushing * @@ -1772,7 +1795,8 @@ done: hbool_t H5CX_get_mpi_file_flushing(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1782,11 +1806,11 @@ H5CX_get_mpi_file_flushing(void) FUNC_LEAVE_NOAPI((*head)->ctx.mpi_file_flushing) } /* end H5CX_get_mpi_file_flushing() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_rank0_bcast * - * Purpose: Retrieves if the dataset meets read-with-rank0-and-bcast requirements for the current API call context. + * Purpose: Retrieves if the dataset meets read-with-rank0-and-bcast requirements for the current API call + *context. * * Return: Non-negative on success / Negative on failure * @@ -1798,7 +1822,8 @@ H5CX_get_mpi_file_flushing(void) hbool_t H5CX_get_mpio_rank0_bcast(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1809,7 +1834,6 @@ H5CX_get_mpio_rank0_bcast(void) } /* end H5CX_get_mpio_rank0_bcast() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5CX_get_btree_split_ratios * @@ -1825,8 +1849,9 @@ H5CX_get_mpio_rank0_bcast(void) herr_t H5CX_get_btree_split_ratios(double split_ratio[3]) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1835,7 +1860,8 @@ H5CX_get_btree_split_ratios(double split_ratio[3]) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_BTREE_SPLIT_RATIO_NAME, btree_split_ratio) + H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_BTREE_SPLIT_RATIO_NAME, + btree_split_ratio) /* Get the B-tree split ratio values */ H5MM_memcpy(split_ratio, &(*head)->ctx.btree_split_ratio, sizeof((*head)->ctx.btree_split_ratio)); @@ -1844,7 +1870,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_btree_split_ratios() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_max_temp_buf * @@ -1860,8 +1885,9 @@ done: herr_t H5CX_get_max_temp_buf(size_t *max_temp_buf) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1879,7 +1905,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_max_temp_buf() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_tconv_buf * @@ -1895,8 +1920,9 @@ done: herr_t H5CX_get_tconv_buf(void **tconv_buf) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1914,7 +1940,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_tconv_buf() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_bkgr_buf * @@ -1930,8 +1955,9 @@ done: herr_t H5CX_get_bkgr_buf(void **bkgr_buf) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1949,7 +1975,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_bkgr_buf() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_bkgr_buf_type * @@ -1965,8 +1990,9 @@ done: herr_t H5CX_get_bkgr_buf_type(H5T_bkg_t *bkgr_buf_type) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1984,7 +2010,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_bkgr_buf_type() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_vec_size * @@ -2000,8 +2025,9 @@ done: herr_t H5CX_get_vec_size(size_t *vec_size) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2020,7 +2046,7 @@ done: } /* end H5CX_get_vec_size() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5CX_get_io_xfer_mode * @@ -2036,8 +2062,9 @@ done: herr_t H5CX_get_io_xfer_mode(H5FD_mpio_xfer_t *io_xfer_mode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2055,7 +2082,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_io_xfer_mode() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_coll_opt * @@ -2071,8 +2097,9 @@ done: herr_t H5CX_get_mpio_coll_opt(H5FD_mpio_collective_opt_t *mpio_coll_opt) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2090,7 +2117,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_coll_opt() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_local_no_coll_cause * @@ -2106,8 +2132,9 @@ done: herr_t H5CX_get_mpio_local_no_coll_cause(uint32_t *mpio_local_no_coll_cause) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2116,7 +2143,8 @@ H5CX_get_mpio_local_no_coll_cause(uint32_t *mpio_local_no_coll_cause) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, mpio_local_no_coll_cause) + H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, + mpio_local_no_coll_cause) /* Get the value */ *mpio_local_no_coll_cause = (*head)->ctx.mpio_local_no_coll_cause; @@ -2125,7 +2153,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_local_no_coll_cause() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_global_no_coll_cause * @@ -2141,8 +2168,9 @@ done: herr_t H5CX_get_mpio_global_no_coll_cause(uint32_t *mpio_global_no_coll_cause) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2151,7 +2179,8 @@ H5CX_get_mpio_global_no_coll_cause(uint32_t *mpio_global_no_coll_cause) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, mpio_global_no_coll_cause) + H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, + mpio_global_no_coll_cause) /* Get the value */ *mpio_global_no_coll_cause = (*head)->ctx.mpio_global_no_coll_cause; @@ -2160,7 +2189,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_global_no_coll_cause() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_chunk_opt_mode * @@ -2176,8 +2204,9 @@ done: herr_t H5CX_get_mpio_chunk_opt_mode(H5FD_mpio_chunk_opt_t *mpio_chunk_opt_mode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2186,7 +2215,8 @@ H5CX_get_mpio_chunk_opt_mode(H5FD_mpio_chunk_opt_t *mpio_chunk_opt_mode) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, mpio_chunk_opt_mode) + H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, + mpio_chunk_opt_mode) /* Get the value */ *mpio_chunk_opt_mode = (*head)->ctx.mpio_chunk_opt_mode; @@ -2195,7 +2225,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_chunk_opt_mode() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_chunk_opt_num * @@ -2211,8 +2240,9 @@ done: herr_t H5CX_get_mpio_chunk_opt_num(unsigned *mpio_chunk_opt_num) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2221,7 +2251,8 @@ H5CX_get_mpio_chunk_opt_num(unsigned *mpio_chunk_opt_num) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, mpio_chunk_opt_num) + H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, + mpio_chunk_opt_num) /* Get the value */ *mpio_chunk_opt_num = (*head)->ctx.mpio_chunk_opt_num; @@ -2230,7 +2261,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_chunk_opt_num() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_chunk_opt_ratio * @@ -2246,8 +2276,9 @@ done: herr_t H5CX_get_mpio_chunk_opt_ratio(unsigned *mpio_chunk_opt_ratio) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2256,7 +2287,8 @@ H5CX_get_mpio_chunk_opt_ratio(unsigned *mpio_chunk_opt_ratio) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, mpio_chunk_opt_ratio) + H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, + mpio_chunk_opt_ratio) /* Get the value */ *mpio_chunk_opt_ratio = (*head)->ctx.mpio_chunk_opt_ratio; @@ -2266,7 +2298,6 @@ done: } /* end H5CX_get_mpio_chunk_opt_ratio() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5CX_get_err_detect * @@ -2282,8 +2313,9 @@ done: herr_t H5CX_get_err_detect(H5Z_EDC_t *err_detect) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2301,7 +2333,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_err_detect() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_filter_cb * @@ -2317,8 +2348,9 @@ done: herr_t H5CX_get_filter_cb(H5Z_cb_t *filter_cb) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2336,7 +2368,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_filter_cb() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_data_transform * @@ -2352,8 +2383,9 @@ done: herr_t H5CX_get_data_transform(H5Z_data_xform_t **data_transform) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2363,22 +2395,23 @@ H5CX_get_data_transform(H5Z_data_xform_t **data_transform) HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); /* Check if the value has been retrieved already */ - if(!(*head)->ctx.data_transform_valid) { + if (!(*head)->ctx.data_transform_valid) { /* Check for default DXPL */ - if((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT) + if ((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT) (*head)->ctx.data_transform = H5CX_def_dxpl_cache.data_transform; else { /* Check if the property list is already available */ - if(NULL == (*head)->ctx.dxpl) + if (NULL == (*head)->ctx.dxpl) /* Get the dataset transfer property list pointer */ - if(NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset transfer property list") + if (NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, + "can't get default dataset transfer property list") /* Get data transform info value */ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need * to copy it and free this in the H5CX pop routine. -QAK) */ - if(H5P_peek((*head)->ctx.dxpl, H5D_XFER_XFORM_NAME, &(*head)->ctx.data_transform) < 0) + if (H5P_peek((*head)->ctx.dxpl, H5D_XFER_XFORM_NAME, &(*head)->ctx.data_transform) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve data transform info") } /* end else */ @@ -2393,7 +2426,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_data_transform() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_vlen_alloc_info * @@ -2409,8 +2441,9 @@ done: herr_t H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2420,25 +2453,30 @@ H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info) HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); /* Check if the value has been retrieved already */ - if(!(*head)->ctx.vl_alloc_info_valid) { + if (!(*head)->ctx.vl_alloc_info_valid) { /* Check for default DXPL */ - if((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT) + if ((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT) (*head)->ctx.vl_alloc_info = H5CX_def_dxpl_cache.vl_alloc_info; else { /* Check if the property list is already available */ - if(NULL == (*head)->ctx.dxpl) + if (NULL == (*head)->ctx.dxpl) /* Get the dataset transfer property list pointer */ - if(NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset transfer property list") + if (NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, + "can't get default dataset transfer property list") /* Get VL datatype alloc info values */ - if(H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_ALLOC_NAME, &(*head)->ctx.vl_alloc_info.alloc_func) < 0) + if (H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_ALLOC_NAME, &(*head)->ctx.vl_alloc_info.alloc_func) < + 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_ALLOC_INFO_NAME, &(*head)->ctx.vl_alloc_info.alloc_info) < 0) + if (H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_ALLOC_INFO_NAME, + &(*head)->ctx.vl_alloc_info.alloc_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_FREE_NAME, &(*head)->ctx.vl_alloc_info.free_func) < 0) + if (H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_FREE_NAME, &(*head)->ctx.vl_alloc_info.free_func) < + 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_FREE_INFO_NAME, &(*head)->ctx.vl_alloc_info.free_info) < 0) + if (H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_FREE_INFO_NAME, + &(*head)->ctx.vl_alloc_info.free_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") } /* end else */ @@ -2453,7 +2491,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vlen_alloc_info() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_dt_conv_cb * @@ -2469,8 +2506,9 @@ done: herr_t H5CX_get_dt_conv_cb(H5T_conv_cb_t *dt_conv_cb) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2488,7 +2526,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_dt_conv_cb() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_encoding * @@ -2502,10 +2539,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5CX_get_encoding(H5T_cset_t* encoding) +H5CX_get_encoding(H5T_cset_t *encoding) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2523,7 +2561,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_encoding() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_intermediate_group * @@ -2537,10 +2574,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5CX_get_intermediate_group(unsigned* crt_intermed_group) +H5CX_get_intermediate_group(unsigned *crt_intermed_group) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2549,7 +2587,8 @@ H5CX_get_intermediate_group(unsigned* crt_intermed_group) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.lcpl_id); - H5CX_RETRIEVE_PROP_VALID(lcpl, H5P_LINK_CREATE_DEFAULT, H5L_CRT_INTERMEDIATE_GROUP_NAME, intermediate_group) + H5CX_RETRIEVE_PROP_VALID(lcpl, H5P_LINK_CREATE_DEFAULT, H5L_CRT_INTERMEDIATE_GROUP_NAME, + intermediate_group) /* Get the value */ *crt_intermed_group = (*head)->ctx.intermediate_group; @@ -2558,7 +2597,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_create_intermediate_group() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_nlinks * @@ -2574,8 +2612,9 @@ done: herr_t H5CX_get_nlinks(size_t *nlinks) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2593,7 +2632,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_nlinks() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_libver_bounds * @@ -2609,8 +2647,9 @@ done: herr_t H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high_bound) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2624,14 +2663,13 @@ H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high_bound) H5CX_RETRIEVE_PROP_VALID(fapl, H5P_FILE_ACCESS_DEFAULT, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high_bound) /* Get the values */ - *low_bound = (*head)->ctx.low_bound; + *low_bound = (*head)->ctx.low_bound; *high_bound = (*head)->ctx.high_bound; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_dset_min_ohdr_flag * @@ -2648,8 +2686,9 @@ done: herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2658,7 +2697,8 @@ H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, do_min_dset_ohdr) + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, + do_min_dset_ohdr) /* Get the value */ *dset_min_ohdr_flag = (*head)->ctx.do_min_dset_ohdr; @@ -2667,7 +2707,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_dset_min_ohdr_flag() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_ext_file_prefix * @@ -2683,8 +2722,9 @@ done: herr_t H5CX_get_ext_file_prefix(const char **extfile_prefix) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2694,22 +2734,23 @@ H5CX_get_ext_file_prefix(const char **extfile_prefix) HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); /* Check if the value has been retrieved already */ - if(!(*head)->ctx.extfile_prefix_valid) { + if (!(*head)->ctx.extfile_prefix_valid) { /* Check for default DAPL */ - if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) + if ((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) (*head)->ctx.extfile_prefix = H5CX_def_dapl_cache.extfile_prefix; else { /* Check if the property list is already available */ - if(NULL == (*head)->ctx.dapl) + if (NULL == (*head)->ctx.dapl) /* Get the dataset access property list pointer */ - if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list") + if (NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, + "can't get default dataset access property list") /* Get the prefix for the external file */ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need * to copy it and free this in the H5CX pop routine. -QAK) */ - if(H5P_peek((*head)->ctx.dapl, H5D_ACS_EFILE_PREFIX_NAME, &(*head)->ctx.extfile_prefix) < 0) + if (H5P_peek((*head)->ctx.dapl, H5D_ACS_EFILE_PREFIX_NAME, &(*head)->ctx.extfile_prefix) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve external file prefix") } /* end else */ @@ -2724,7 +2765,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_ext_file_prefix() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_vds_prefix * @@ -2740,8 +2780,9 @@ done: herr_t H5CX_get_vds_prefix(const char **vds_prefix) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2751,22 +2792,23 @@ H5CX_get_vds_prefix(const char **vds_prefix) HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); /* Check if the value has been retrieved already */ - if(!(*head)->ctx.vds_prefix_valid) { + if (!(*head)->ctx.vds_prefix_valid) { /* Check for default DAPL */ - if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) + if ((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) (*head)->ctx.vds_prefix = H5CX_def_dapl_cache.vds_prefix; else { /* Check if the property list is already available */ - if(NULL == (*head)->ctx.dapl) + if (NULL == (*head)->ctx.dapl) /* Get the dataset access property list pointer */ - if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list") + if (NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, + "can't get default dataset access property list") /* Get the prefix for the VDS */ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need * to copy it and free this in the H5CX pop routine. -QAK) */ - if(H5P_peek((*head)->ctx.dapl, H5D_ACS_VDS_PREFIX_NAME, &(*head)->ctx.vds_prefix) < 0) + if (H5P_peek((*head)->ctx.dapl, H5D_ACS_VDS_PREFIX_NAME, &(*head)->ctx.vds_prefix) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VDS prefix") } /* end else */ @@ -2781,7 +2823,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vds_prefix() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_tag * @@ -2797,7 +2838,8 @@ done: void H5CX_set_tag(haddr_t tag) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2809,7 +2851,6 @@ H5CX_set_tag(haddr_t tag) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_tag() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_ring * @@ -2825,7 +2866,8 @@ H5CX_set_tag(haddr_t tag) void H5CX_set_ring(H5AC_ring_t ring) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2838,7 +2880,7 @@ H5CX_set_ring(H5AC_ring_t ring) } /* end H5CX_set_ring() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5CX_set_coll_metadata_read * @@ -2854,7 +2896,8 @@ H5CX_set_ring(H5AC_ring_t ring) void H5CX_set_coll_metadata_read(hbool_t cmdr) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2866,7 +2909,6 @@ H5CX_set_coll_metadata_read(hbool_t cmdr) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_coll_metadata_read() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpi_coll_datatypes * @@ -2884,9 +2926,10 @@ H5CX_set_coll_metadata_read(hbool_t cmdr) herr_t H5CX_set_mpi_coll_datatypes(MPI_Datatype btype, MPI_Datatype ftype) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2901,7 +2944,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_mpi_coll_datatypes() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_io_xfer_mode * @@ -2917,8 +2959,9 @@ done: herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2935,7 +2978,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_io_xfer_mode() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_coll_opt * @@ -2951,8 +2993,9 @@ done: herr_t H5CX_set_mpio_coll_opt(H5FD_mpio_collective_opt_t mpio_coll_opt) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2969,7 +3012,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_mpio_coll_opt() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpi_file_flushing * @@ -2985,7 +3027,8 @@ done: void H5CX_set_mpi_file_flushing(hbool_t flushing) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2997,11 +3040,11 @@ H5CX_set_mpi_file_flushing(hbool_t flushing) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_mpi_file_flushing() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_rank0_bcast * - * Purpose: Sets the "dataset meets read-with-rank0-and-bcast requirements" flag for the current API call context. + * Purpose: Sets the "dataset meets read-with-rank0-and-bcast requirements" flag for the current API call + *context. * * Return: * @@ -3013,7 +3056,8 @@ H5CX_set_mpi_file_flushing(hbool_t flushing) void H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3026,7 +3070,6 @@ H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast) } /* end H5CX_set_mpio_rank0_bcast() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5CX_set_vlen_alloc_info * @@ -3040,11 +3083,11 @@ H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast) *------------------------------------------------------------------------- */ herr_t -H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, - void *alloc_info, H5MM_free_t free_func, void *free_info) +H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3054,8 +3097,8 @@ H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, /* Set the API context value */ (*head)->ctx.vl_alloc_info.alloc_func = alloc_func; (*head)->ctx.vl_alloc_info.alloc_info = alloc_info; - (*head)->ctx.vl_alloc_info.free_func = free_func; - (*head)->ctx.vl_alloc_info.free_info = free_info; + (*head)->ctx.vl_alloc_info.free_func = free_func; + (*head)->ctx.vl_alloc_info.free_info = free_info; /* Mark the value as valid */ (*head)->ctx.vl_alloc_info_valid = TRUE; @@ -3064,7 +3107,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vlen_alloc_info() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_nlinks * @@ -3080,8 +3122,9 @@ done: herr_t H5CX_set_nlinks(size_t nlinks) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3099,7 +3142,7 @@ done: } /* end H5CX_set_nlinks() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_actual_chunk_opt * @@ -3115,23 +3158,22 @@ done: void H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); /* Cache the value for later, marking it to set in DXPL when context popped */ - (*head)->ctx.mpio_actual_chunk_opt = mpio_actual_chunk_opt; + (*head)->ctx.mpio_actual_chunk_opt = mpio_actual_chunk_opt; (*head)->ctx.mpio_actual_chunk_opt_set = TRUE; FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_mpio_actual_chunk_opt() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_actual_io_mode * @@ -3147,23 +3189,22 @@ H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chun void H5CX_set_mpio_actual_io_mode(H5D_mpio_actual_io_mode_t mpio_actual_io_mode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); /* Cache the value for later, marking it to set in DXPL when context popped */ - (*head)->ctx.mpio_actual_io_mode = mpio_actual_io_mode; + (*head)->ctx.mpio_actual_io_mode = mpio_actual_io_mode; (*head)->ctx.mpio_actual_io_mode_set = TRUE; FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_mpio_actual_chunk_opt() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_local_no_coll_cause * @@ -3179,7 +3220,8 @@ H5CX_set_mpio_actual_io_mode(H5D_mpio_actual_io_mode_t mpio_actual_io_mode) void H5CX_set_mpio_local_no_coll_cause(uint32_t mpio_local_no_coll_cause) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3188,16 +3230,15 @@ H5CX_set_mpio_local_no_coll_cause(uint32_t mpio_local_no_coll_cause) HDassert((*head)->ctx.dxpl_id != H5P_DEFAULT); /* If we're using the default DXPL, don't modify it */ - if((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) { + if ((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) { /* Cache the value for later, marking it to set in DXPL when context popped */ - (*head)->ctx.mpio_local_no_coll_cause = mpio_local_no_coll_cause; + (*head)->ctx.mpio_local_no_coll_cause = mpio_local_no_coll_cause; (*head)->ctx.mpio_local_no_coll_cause_set = TRUE; } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_mpio_local_no_coll_cause() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_global_no_coll_cause * @@ -3213,7 +3254,8 @@ H5CX_set_mpio_local_no_coll_cause(uint32_t mpio_local_no_coll_cause) void H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3222,9 +3264,9 @@ H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) HDassert((*head)->ctx.dxpl_id != H5P_DEFAULT); /* If we're using the default DXPL, don't modify it */ - if((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) { + if ((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) { /* Cache the value for later, marking it to set in DXPL when context popped */ - (*head)->ctx.mpio_global_no_coll_cause = mpio_global_no_coll_cause; + (*head)->ctx.mpio_global_no_coll_cause = mpio_global_no_coll_cause; (*head)->ctx.mpio_global_no_coll_cause_set = TRUE; } /* end if */ @@ -3232,7 +3274,7 @@ H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) } /* end H5CX_set_mpio_global_no_coll_cause() */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - + /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_link_hard * @@ -3250,15 +3292,15 @@ H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) herr_t H5CX_test_set_mpio_coll_chunk_link_hard(int mpio_coll_chunk_link_hard) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, mpio_coll_chunk_link_hard) @@ -3266,7 +3308,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_link_hard() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_multi_hard * @@ -3284,15 +3325,15 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_multi_hard(int mpio_coll_chunk_multi_hard) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, mpio_coll_chunk_multi_hard) @@ -3300,7 +3341,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_multi_hard() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_link_num_true * @@ -3318,15 +3358,15 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_link_num_true(int mpio_coll_chunk_link_num_true) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, mpio_coll_chunk_link_num_true) @@ -3334,11 +3374,11 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_link_num_true() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_link_num_false * - * Purpose: Sets the instrumented "collective chunk link num false" value for the current API call context. + * Purpose: Sets the instrumented "collective chunk link num false" value for the current API call + *context. * * Note: Only sets value if property set in DXPL * @@ -3352,15 +3392,15 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_link_num_false(int mpio_coll_chunk_link_num_false) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, mpio_coll_chunk_link_num_false) @@ -3368,11 +3408,11 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_link_num_false() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_multi_ratio_coll * - * Purpose: Sets the instrumented "collective chunk multi ratio coll" value for the current API call context. + * Purpose: Sets the instrumented "collective chunk multi ratio coll" value for the current API call + *context. * * Note: Only sets value if property set in DXPL * @@ -3386,15 +3426,15 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(int mpio_coll_chunk_multi_ratio_coll) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, mpio_coll_chunk_multi_ratio_coll) @@ -3402,11 +3442,11 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_multi_ratio_coll() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_multi_ratio_ind * - * Purpose: Sets the instrumented "collective chunk multi ratio ind" value for the current API call context. + * Purpose: Sets the instrumented "collective chunk multi ratio ind" value for the current API call + *context. * * Note: Only sets value if property set in DXPL * @@ -3420,15 +3460,15 @@ done: herr_t H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(int mpio_coll_chunk_multi_ratio_ind) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, mpio_coll_chunk_multi_ratio_ind) @@ -3436,7 +3476,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_multi_ratio_ind() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_rank0_bcast * @@ -3454,15 +3493,15 @@ done: herr_t H5CX_test_set_mpio_coll_rank0_bcast(hbool_t mpio_coll_rank0_bcast) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_RANK0_BCAST_NAME, mpio_coll_rank0_bcast) @@ -3472,7 +3511,6 @@ done: #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5CX_get_ohdr_flags * @@ -3488,8 +3526,9 @@ done: herr_t H5CX_get_ohdr_flags(uint8_t *ohdr_flags) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3507,7 +3546,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* End H5CX_get_ohdr_flags() */ - /*------------------------------------------------------------------------- * Function: H5CX__pop_common * @@ -3523,8 +3561,9 @@ done: static H5CX_node_t * H5CX__pop_common(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - H5CX_node_t *ret_value = NULL; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t *ret_value = NULL; /* Return value */ #ifdef H5_HAVE_PARALLEL FUNC_ENTER_STATIC @@ -3554,7 +3593,7 @@ H5CX__pop_common(void) /* Pop the top context node from the stack */ ret_value = (*head); - (*head) = (*head)->next; + (*head) = (*head)->next; #ifdef H5_HAVE_PARALLEL done: @@ -3562,7 +3601,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX__pop_common() */ - /*------------------------------------------------------------------------- * Function: H5CX_pop * @@ -3578,13 +3616,13 @@ done: herr_t H5CX_pop(void) { - H5CX_node_t *cnode; /* Context node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t *cnode; /* Context node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Perform common operations and get top context from stack */ - if(NULL == (cnode = H5CX__pop_common())) + if (NULL == (cnode = H5CX__pop_common())) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error getting API context node") /* Free the context node */ @@ -3593,4 +3631,3 @@ H5CX_pop(void) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_pop() */ - diff --git a/src/H5CXmodule.h b/src/H5CXmodule.h index 186f8aa..6bfad98 100644 --- a/src/H5CXmodule.h +++ b/src/H5CXmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5CX_MODULE -#define H5_MY_PKG H5CX -#define H5_MY_PKG_ERR H5E_CONTEXT -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5CX +#define H5_MY_PKG_ERR H5E_CONTEXT +#define H5_MY_PKG_INIT YES #endif /* _H5CXmodule_H */ - diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index 2ae71f3..767ccf1 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -22,44 +22,40 @@ #endif /* NOT_YET */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ #ifdef H5_HAVE_PARALLEL -#include "H5FDprivate.h" /* File drivers */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5Zprivate.h" /* Data filters */ - +#include "H5FDprivate.h" /* File drivers */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5Zprivate.h" /* Data filters */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* API context state */ typedef struct H5CX_state_t { - hid_t dcpl_id; /* DCPL for operation */ - hid_t dxpl_id; /* DXPL for operation */ - hid_t lapl_id; /* LAPL for operation */ - hid_t lcpl_id; /* LCPL for operation */ - void *vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ - H5VL_connector_prop_t vol_connector_prop; /* VOL connector property */ + hid_t dcpl_id; /* DCPL for operation */ + hid_t dxpl_id; /* DXPL for operation */ + hid_t lapl_id; /* LAPL for operation */ + hid_t lcpl_id; /* LCPL for operation */ + void * vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ + H5VL_connector_prop_t vol_connector_prop; /* VOL connector property */ #ifdef H5_HAVE_PARALLEL /* Internal: Parallel I/O settings */ hbool_t coll_metadata_read; /* Whether to use collective I/O for metadata read */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ } H5CX_state_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -68,8 +64,8 @@ typedef struct H5CX_state_t { #ifndef _H5private_H H5_DLL herr_t H5CX_push(void); H5_DLL herr_t H5CX_pop(void); -#endif /* _H5private_H */ -H5_DLL void H5CX_push_special(void); +#endif /* _H5private_H */ +H5_DLL void H5CX_push_special(void); H5_DLL hbool_t H5CX_is_def_dxpl(void); /* API context state routines */ @@ -78,27 +74,27 @@ H5_DLL herr_t H5CX_restore_state(const H5CX_state_t *api_state); H5_DLL herr_t H5CX_free_state(H5CX_state_t *api_state); /* "Setter" routines for API context info */ -H5_DLL void H5CX_set_dxpl(hid_t dxpl_id); -H5_DLL void H5CX_set_lcpl(hid_t lcpl_id); -H5_DLL void H5CX_set_lapl(hid_t lapl_id); -H5_DLL void H5CX_set_dcpl(hid_t dcpl_id); +H5_DLL void H5CX_set_dxpl(hid_t dxpl_id); +H5_DLL void H5CX_set_lcpl(hid_t lcpl_id); +H5_DLL void H5CX_set_lapl(hid_t lapl_id); +H5_DLL void H5CX_set_dcpl(hid_t dcpl_id); H5_DLL herr_t H5CX_set_libver_bounds(H5F_t *f); -H5_DLL herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, - hid_t loc_id, hbool_t is_collective); +H5_DLL herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, hid_t loc_id, + hbool_t is_collective); H5_DLL herr_t H5CX_set_loc(hid_t loc_id); H5_DLL herr_t H5CX_set_vol_wrap_ctx(void *wrap_ctx); H5_DLL herr_t H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop); /* "Getter" routines for API context info */ -H5_DLL hid_t H5CX_get_dxpl(void); -H5_DLL hid_t H5CX_get_lapl(void); -H5_DLL herr_t H5CX_get_vol_wrap_ctx(void **wrap_ctx); -H5_DLL herr_t H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop); -H5_DLL haddr_t H5CX_get_tag(void); +H5_DLL hid_t H5CX_get_dxpl(void); +H5_DLL hid_t H5CX_get_lapl(void); +H5_DLL herr_t H5CX_get_vol_wrap_ctx(void **wrap_ctx); +H5_DLL herr_t H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop); +H5_DLL haddr_t H5CX_get_tag(void); H5_DLL H5AC_ring_t H5CX_get_ring(void); #ifdef H5_HAVE_PARALLEL H5_DLL hbool_t H5CX_get_coll_metadata_read(void); -H5_DLL herr_t H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype); +H5_DLL herr_t H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype); H5_DLL hbool_t H5CX_get_mpi_file_flushing(void); H5_DLL hbool_t H5CX_get_mpio_rank0_bcast(void); #endif /* H5_HAVE_PARALLEL */ @@ -126,8 +122,8 @@ H5_DLL herr_t H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info); H5_DLL herr_t H5CX_get_dt_conv_cb(H5T_conv_cb_t *cb_struct); /* "Getter" routines for LCPL properties cached in API context */ -H5_DLL herr_t H5CX_get_encoding(H5T_cset_t* encoding); -H5_DLL herr_t H5CX_get_intermediate_group(unsigned* crt_intermed_group); +H5_DLL herr_t H5CX_get_encoding(H5T_cset_t *encoding); +H5_DLL herr_t H5CX_get_intermediate_group(unsigned *crt_intermed_group); /* "Getter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks); @@ -147,19 +143,19 @@ H5_DLL herr_t H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high H5_DLL void H5CX_set_tag(haddr_t tag); H5_DLL void H5CX_set_ring(H5AC_ring_t ring); #ifdef H5_HAVE_PARALLEL -H5_DLL void H5CX_set_coll_metadata_read(hbool_t cmdr); +H5_DLL void H5CX_set_coll_metadata_read(hbool_t cmdr); H5_DLL herr_t H5CX_set_mpi_coll_datatypes(MPI_Datatype btype, MPI_Datatype ftype); H5_DLL herr_t H5CX_set_mpio_coll_opt(H5FD_mpio_collective_opt_t mpio_coll_opt); -H5_DLL void H5CX_set_mpi_file_flushing(hbool_t flushing); -H5_DLL void H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast); +H5_DLL void H5CX_set_mpi_file_flushing(hbool_t flushing); +H5_DLL void H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast); #endif /* H5_HAVE_PARALLEL */ /* "Setter" routines for DXPL properties cached in API context */ #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode); #endif /* H5_HAVE_PARALLEL */ -H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, - void *alloc_info, H5MM_free_t free_func, void *free_info); +H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, + void *free_info); /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); @@ -182,4 +178,3 @@ H5_DLL herr_t H5CX_test_set_mpio_coll_rank0_bcast(hbool_t rank0_bcast); #endif /* H5_HAVE_PARALLEL */ #endif /* _H5CXprivate_H */ - diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 749d49e..ca6a114 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -26,54 +26,44 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ #define H5AC_FRIEND - - - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata Cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Eprivate.h" /* Error Handling */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata Cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error Handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef NDEBUG - + /*------------------------------------------------------------------------- * Function: H5C_dump_cache * @@ -88,39 +78,39 @@ *------------------------------------------------------------------------- */ herr_t -H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) +H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) { - H5C_cache_entry_t * entry_ptr; - H5SL_t * slist_ptr = NULL; - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + H5SL_t * slist_ptr = NULL; + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(cache_ptr != NULL); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_name != NULL ); + HDassert(cache_name != NULL); /* First, create a skip list */ - if(NULL == (slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create skip list") /* Next, scan the index, and insert all entries in the skip list. * Do this, as we want to display cache entries in increasing address * order. */ - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) { + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { entry_ptr = cache_ptr->index[i]; - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(H5SL_insert(slist_ptr, entry_ptr, &(entry_ptr->addr)) < 0) + if (H5SL_insert(slist_ptr, entry_ptr, &(entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't insert entry in skip list") entry_ptr = entry_ptr->ht_next; } /* end while */ - } /* end for */ + } /* end for */ /* If we get this far, all entries in the cache are listed in the * skip list -- scan the skip list generating the desired output. @@ -138,17 +128,18 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) HDfprintf(stdout, "| Prot/Pin/Dirty"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); + HDfprintf(stdout, "--------------------------------------------------------------------------------------" + "--------------------------\n"); - i = 0; + i = 0; entry_ptr = (H5C_cache_entry_t *)H5SL_remove_first(slist_ptr); - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); /* Print entry */ HDfprintf(stdout, "%s%5d ", cache_ptr->prefix, i); HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); - if(NULL == entry_ptr->tag_info) + if (NULL == entry_ptr->tag_info) HDfprintf(stdout, " %16s ", "N/A"); else HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->tag_info->tag)); @@ -173,7 +164,7 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) done: /* Discard the skip list */ - if(slist_ptr) + if (slist_ptr) H5SL_close(slist_ptr); FUNC_LEAVE_NOAPI(ret_value) @@ -181,7 +172,7 @@ done: #endif /* NDEBUG */ #ifndef NDEBUG - + /*------------------------------------------------------------------------- * Function: H5C_dump_cache_LRU * @@ -198,21 +189,21 @@ done: herr_t H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) { - H5C_cache_entry_t * entry_ptr; - int i = 0; + H5C_cache_entry_t *entry_ptr; + int i = 0; FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(cache_ptr != NULL); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_name != NULL ); + HDassert(cache_name != NULL); HDfprintf(stdout, "\n\nDump of metadata cache LRU \"%s\"\n", cache_name); - HDfprintf(stdout, "LRU len = %d, LRU size = %d\n", - cache_ptr->LRU_list_len, (int)(cache_ptr->LRU_list_size)); - HDfprintf(stdout, "index_size = %d, max_cache_size = %d, delta = %d\n\n", - (int)(cache_ptr->index_size), (int)(cache_ptr->max_cache_size), + HDfprintf(stdout, "LRU len = %d, LRU size = %d\n", cache_ptr->LRU_list_len, + (int)(cache_ptr->LRU_list_size)); + HDfprintf(stdout, "index_size = %d, max_cache_size = %d, delta = %d\n\n", (int)(cache_ptr->index_size), + (int)(cache_ptr->max_cache_size), (int)(cache_ptr->max_cache_size) - (int)(cache_ptr->index_size)); /* Print header */ @@ -225,26 +216,25 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) HDfprintf(stdout, "| Dirty"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); + HDfprintf(stdout, "--------------------------------------------------------------------------------------" + "--------------------------\n"); entry_ptr = cache_ptr->LRU_head_ptr; - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); /* Print entry */ HDfprintf(stdout, "%s%5d ", cache_ptr->prefix, i); HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); - if(NULL == entry_ptr->tag_info) + if (NULL == entry_ptr->tag_info) HDfprintf(stdout, " %16s ", "N/A"); else - HDfprintf(stdout, " 0x%16llx ", - (long long)(entry_ptr->tag_info->tag)); + HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->tag_info->tag)); HDfprintf(stdout, " %5lld ", (long long)(entry_ptr->size)); HDfprintf(stdout, " %d ", (int)(entry_ptr->ring)); - HDfprintf(stdout, " %2d %-32s ", (int)(entry_ptr->type->id), - (entry_ptr->type->name)); + HDfprintf(stdout, " %2d %-32s ", (int)(entry_ptr->type->id), (entry_ptr->type->name)); HDfprintf(stdout, " %d", (int)(entry_ptr->is_dirty)); HDfprintf(stdout, "\n"); @@ -252,13 +242,13 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) entry_ptr = entry_ptr->next; } /* end while */ - HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); + HDfprintf(stdout, "--------------------------------------------------------------------------------------" + "--------------------------\n"); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_dump_cache_LRU() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5C_dump_cache_skip_list * @@ -275,12 +265,12 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) */ #ifndef NDEBUG herr_t -H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) +H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) { - herr_t ret_value = SUCCEED; /* Return value */ - int i; - H5C_cache_entry_t * entry_ptr = NULL; - H5SL_node_t * node_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + int i; + H5C_cache_entry_t *entry_ptr = NULL; + H5SL_node_t * node_ptr = NULL; FUNC_ENTER_NOAPI_NOERR @@ -292,46 +282,38 @@ H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) HDfprintf(stdout, " slist len = %" PRIu32 ".\n", cache_ptr->slist_len); HDfprintf(stdout, " slist size = %zu.\n", cache_ptr->slist_size); - if(cache_ptr->slist_len > 0) { + if (cache_ptr->slist_len > 0) { /* If we get this far, all entries in the cache are listed in the * skip list -- scan the skip list generating the desired output. */ - HDfprintf(stdout, - "Num: Addr: Len: Prot/Pind: Dirty: Type:\n"); + HDfprintf(stdout, "Num: Addr: Len: Prot/Pind: Dirty: Type:\n"); - i = 0; + i = 0; node_ptr = H5SL_first(cache_ptr->slist_ptr); - if(node_ptr != NULL) + if (node_ptr != NULL) entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); else entry_ptr = NULL; - while(entry_ptr != NULL) { - HDassert( entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC ); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDfprintf(stdout, - "%s%d 0x%016" PRIxHADDR " %4zu %d/%d %d %s\n", - cache_ptr->prefix, i, - entry_ptr->addr, - entry_ptr->size, - (int)(entry_ptr->is_protected), - (int)(entry_ptr->is_pinned), - (int)(entry_ptr->is_dirty), - entry_ptr->type->name); + HDfprintf(stdout, "%s%d 0x%016" PRIxHADDR " %4zu %d/%d %d %s\n", + cache_ptr->prefix, i, entry_ptr->addr, entry_ptr->size, (int)(entry_ptr->is_protected), + (int)(entry_ptr->is_pinned), (int)(entry_ptr->is_dirty), entry_ptr->type->name); - HDfprintf(stdout, " node_ptr = %p, item = %p\n", - node_ptr, H5SL_item(node_ptr)); + HDfprintf(stdout, " node_ptr = %p, item = %p\n", node_ptr, H5SL_item(node_ptr)); /* increment node_ptr before we delete its target */ node_ptr = H5SL_next(node_ptr); - if(node_ptr != NULL) + if (node_ptr != NULL) entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); else entry_ptr = NULL; i++; } /* end while */ - } /* end if */ + } /* end if */ HDfprintf(stdout, "\n\n"); @@ -339,7 +321,6 @@ H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) } /* H5C_dump_cache_skip_list() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5C_dump_coll_write_list * @@ -358,14 +339,14 @@ H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) #ifdef H5_HAVE_PARALLEL #ifndef NDEBUG herr_t -H5C_dump_coll_write_list(H5C_t * cache_ptr, char * calling_fcn) +H5C_dump_coll_write_list(H5C_t *cache_ptr, char *calling_fcn) { - herr_t ret_value = SUCCEED; /* Return value */ - int i; - int list_len; - H5AC_aux_t * aux_ptr = NULL; - H5C_cache_entry_t * entry_ptr = NULL; - H5SL_node_t * node_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + int i; + int list_len; + H5AC_aux_t * aux_ptr = NULL; + H5C_cache_entry_t *entry_ptr = NULL; + H5SL_node_t * node_ptr = NULL; FUNC_ENTER_NOAPI_NOERR @@ -381,21 +362,19 @@ H5C_dump_coll_write_list(H5C_t * cache_ptr, char * calling_fcn) list_len = (int)H5SL_count(cache_ptr->coll_write_list); - HDfprintf(stdout, "\n\nDumping MDC coll write list from %d:%s.\n", - aux_ptr->mpi_rank, calling_fcn); + HDfprintf(stdout, "\n\nDumping MDC coll write list from %d:%s.\n", aux_ptr->mpi_rank, calling_fcn); HDfprintf(stdout, " slist len = %u.\n", cache_ptr->slist_len); - if ( list_len > 0 ) { + if (list_len > 0) { /* scan the collective write list generating the desired output */ - HDfprintf(stdout, - "Num: Addr: Len: Prot/Pind: Dirty: Type:\n"); + HDfprintf(stdout, "Num: Addr: Len: Prot/Pind: Dirty: Type:\n"); i = 0; node_ptr = H5SL_first(cache_ptr->coll_write_list); - if ( node_ptr != NULL ) + if (node_ptr != NULL) entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); @@ -403,23 +382,17 @@ H5C_dump_coll_write_list(H5C_t * cache_ptr, char * calling_fcn) entry_ptr = NULL; - while ( entry_ptr != NULL ) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDfprintf(stdout, - "%s%d 0x%016" PRIxHADDR " %4%zu %d/%d %d %s\n", - cache_ptr->prefix, i, - entry_ptr->addr, - entry_ptr->size, - (int)(entry_ptr->is_protected), - (int)(entry_ptr->is_pinned), - (int)(entry_ptr->is_dirty), - entry_ptr->type->name); + HDfprintf(stdout, "%s%d 0x%016" PRIxHADDR " %4%zu %d/%d %d %s\n", + cache_ptr->prefix, i, entry_ptr->addr, entry_ptr->size, (int)(entry_ptr->is_protected), + (int)(entry_ptr->is_pinned), (int)(entry_ptr->is_dirty), entry_ptr->type->name); node_ptr = H5SL_next(node_ptr); - if ( node_ptr != NULL ) + if (node_ptr != NULL) entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); @@ -430,7 +403,7 @@ H5C_dump_coll_write_list(H5C_t * cache_ptr, char * calling_fcn) i++; } /* end while */ - } /* end if */ + } /* end if */ HDfprintf(stdout, "\n\n"); @@ -440,7 +413,6 @@ H5C_dump_coll_write_list(H5C_t * cache_ptr, char * calling_fcn) #endif /* NDEBUG */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5C_set_prefix * @@ -455,14 +427,14 @@ H5C_dump_coll_write_list(H5C_t * cache_ptr, char * calling_fcn) *------------------------------------------------------------------------- */ herr_t -H5C_set_prefix(H5C_t * cache_ptr, char * prefix) +H5C_set_prefix(H5C_t *cache_ptr, char *prefix) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || - (prefix == NULL) || (HDstrlen(prefix) >= H5C__PREFIX_LEN)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || (prefix == NULL) || + (HDstrlen(prefix) >= H5C__PREFIX_LEN)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry") HDstrncpy(&(cache_ptr->prefix[0]), prefix, (size_t)(H5C__PREFIX_LEN)); @@ -473,7 +445,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_prefix() */ - /*------------------------------------------------------------------------- * Function: H5C_stats * @@ -487,479 +458,328 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_stats(H5C_t * cache_ptr, - const char * cache_name, +H5C_stats(H5C_t *cache_ptr, const char *cache_name, hbool_t #if !H5C_COLLECT_CACHE_STATS - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5C_COLLECT_CACHE_STATS */ - display_detailed_stats) + display_detailed_stats) { #if H5C_COLLECT_CACHE_STATS - int i; - int64_t total_hits = 0; - int64_t total_misses = 0; - int64_t total_write_protects = 0; - int64_t total_read_protects = 0; - int64_t max_read_protects = 0; - int64_t total_insertions = 0; - int64_t total_pinned_insertions = 0; - int64_t total_clears = 0; - int64_t total_flushes = 0; - int64_t total_evictions = 0; - int64_t total_take_ownerships = 0; - int64_t total_moves = 0; - int64_t total_entry_flush_moves = 0; - int64_t total_cache_flush_moves = 0; - int64_t total_size_increases = 0; - int64_t total_size_decreases = 0; - int64_t total_entry_flush_size_changes = 0; - int64_t total_cache_flush_size_changes = 0; - int64_t total_pins = 0; - int64_t total_unpins = 0; - int64_t total_dirty_pins = 0; - int64_t total_pinned_flushes = 0; - int64_t total_pinned_clears = 0; - int32_t aggregate_max_accesses = 0; - int32_t aggregate_min_accesses = 1000000; - int32_t aggregate_max_clears = 0; - int32_t aggregate_max_flushes = 0; - size_t aggregate_max_size = 0; - int32_t aggregate_max_pins = 0; - double hit_rate; - double prefetch_use_rate; - double average_successful_search_depth = 0.0f; - double average_failed_search_depth = 0.0f; - double average_entries_skipped_per_calls_to_msic = 0.0f; - double average_dirty_pf_entries_skipped_per_call_to_msic = 0.0f; - double average_entries_scanned_per_calls_to_msic = 0.0f; -#endif /* H5C_COLLECT_CACHE_STATS */ - herr_t ret_value = SUCCEED; /* Return value */ + int i; + int64_t total_hits = 0; + int64_t total_misses = 0; + int64_t total_write_protects = 0; + int64_t total_read_protects = 0; + int64_t max_read_protects = 0; + int64_t total_insertions = 0; + int64_t total_pinned_insertions = 0; + int64_t total_clears = 0; + int64_t total_flushes = 0; + int64_t total_evictions = 0; + int64_t total_take_ownerships = 0; + int64_t total_moves = 0; + int64_t total_entry_flush_moves = 0; + int64_t total_cache_flush_moves = 0; + int64_t total_size_increases = 0; + int64_t total_size_decreases = 0; + int64_t total_entry_flush_size_changes = 0; + int64_t total_cache_flush_size_changes = 0; + int64_t total_pins = 0; + int64_t total_unpins = 0; + int64_t total_dirty_pins = 0; + int64_t total_pinned_flushes = 0; + int64_t total_pinned_clears = 0; + int32_t aggregate_max_accesses = 0; + int32_t aggregate_min_accesses = 1000000; + int32_t aggregate_max_clears = 0; + int32_t aggregate_max_flushes = 0; + size_t aggregate_max_size = 0; + int32_t aggregate_max_pins = 0; + double hit_rate; + double prefetch_use_rate; + double average_successful_search_depth = 0.0f; + double average_failed_search_depth = 0.0f; + double average_entries_skipped_per_calls_to_msic = 0.0f; + double average_dirty_pf_entries_skipped_per_call_to_msic = 0.0f; + double average_entries_scanned_per_calls_to_msic = 0.0f; +#endif /* H5C_COLLECT_CACHE_STATS */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* This would normally be an assert, but we need to use an HGOTO_ERROR * call to shut up the compiler. */ - if((NULL == cache_ptr) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || - (NULL == cache_name)) + if ((NULL == cache_ptr) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || (NULL == cache_name)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr or cache_name") #if H5C_COLLECT_CACHE_STATS - for(i = 0; i <= cache_ptr->max_type_id; i++ ) { - total_hits += cache_ptr->hits[i]; - total_misses += cache_ptr->misses[i]; - total_write_protects += cache_ptr->write_protects[i]; - total_read_protects += cache_ptr->read_protects[i]; - if(max_read_protects < cache_ptr->max_read_protects[i]) - max_read_protects = cache_ptr->max_read_protects[i]; - total_insertions += cache_ptr->insertions[i]; + for (i = 0; i <= cache_ptr->max_type_id; i++) { + total_hits += cache_ptr->hits[i]; + total_misses += cache_ptr->misses[i]; + total_write_protects += cache_ptr->write_protects[i]; + total_read_protects += cache_ptr->read_protects[i]; + if (max_read_protects < cache_ptr->max_read_protects[i]) + max_read_protects = cache_ptr->max_read_protects[i]; + total_insertions += cache_ptr->insertions[i]; total_pinned_insertions += cache_ptr->pinned_insertions[i]; - total_clears += cache_ptr->clears[i]; - total_flushes += cache_ptr->flushes[i]; - total_evictions += cache_ptr->evictions[i]; - total_take_ownerships += cache_ptr->take_ownerships[i]; - total_moves += cache_ptr->moves[i]; - total_entry_flush_moves += cache_ptr->entry_flush_moves[i]; - total_cache_flush_moves += cache_ptr->cache_flush_moves[i]; - total_size_increases += cache_ptr->size_increases[i]; - total_size_decreases += cache_ptr->size_decreases[i]; - total_entry_flush_size_changes - += cache_ptr->entry_flush_size_changes[i]; - total_cache_flush_size_changes - += cache_ptr->cache_flush_size_changes[i]; - total_pins += cache_ptr->pins[i]; - total_unpins += cache_ptr->unpins[i]; - total_dirty_pins += cache_ptr->dirty_pins[i]; - total_pinned_flushes += cache_ptr->pinned_flushes[i]; - total_pinned_clears += cache_ptr->pinned_clears[i]; + total_clears += cache_ptr->clears[i]; + total_flushes += cache_ptr->flushes[i]; + total_evictions += cache_ptr->evictions[i]; + total_take_ownerships += cache_ptr->take_ownerships[i]; + total_moves += cache_ptr->moves[i]; + total_entry_flush_moves += cache_ptr->entry_flush_moves[i]; + total_cache_flush_moves += cache_ptr->cache_flush_moves[i]; + total_size_increases += cache_ptr->size_increases[i]; + total_size_decreases += cache_ptr->size_decreases[i]; + total_entry_flush_size_changes += cache_ptr->entry_flush_size_changes[i]; + total_cache_flush_size_changes += cache_ptr->cache_flush_size_changes[i]; + total_pins += cache_ptr->pins[i]; + total_unpins += cache_ptr->unpins[i]; + total_dirty_pins += cache_ptr->dirty_pins[i]; + total_pinned_flushes += cache_ptr->pinned_flushes[i]; + total_pinned_clears += cache_ptr->pinned_clears[i]; #if H5C_COLLECT_CACHE_ENTRY_STATS - if(aggregate_max_accesses < cache_ptr->max_accesses[i]) + if (aggregate_max_accesses < cache_ptr->max_accesses[i]) aggregate_max_accesses = cache_ptr->max_accesses[i]; - if(aggregate_min_accesses > aggregate_max_accesses) + if (aggregate_min_accesses > aggregate_max_accesses) aggregate_min_accesses = aggregate_max_accesses; - if(aggregate_min_accesses > cache_ptr->min_accesses[i]) + if (aggregate_min_accesses > cache_ptr->min_accesses[i]) aggregate_min_accesses = cache_ptr->min_accesses[i]; - if(aggregate_max_clears < cache_ptr->max_clears[i]) + if (aggregate_max_clears < cache_ptr->max_clears[i]) aggregate_max_clears = cache_ptr->max_clears[i]; - if(aggregate_max_flushes < cache_ptr->max_flushes[i]) + if (aggregate_max_flushes < cache_ptr->max_flushes[i]) aggregate_max_flushes = cache_ptr->max_flushes[i]; - if(aggregate_max_size < cache_ptr->max_size[i]) + if (aggregate_max_size < cache_ptr->max_size[i]) aggregate_max_size = cache_ptr->max_size[i]; - if(aggregate_max_pins < cache_ptr->max_pins[i]) + if (aggregate_max_pins < cache_ptr->max_pins[i]) aggregate_max_pins = cache_ptr->max_pins[i]; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ - } /* end for */ + } /* end for */ - if((total_hits > 0) || (total_misses > 0)) - hit_rate = (double)100.0f * ((double)(total_hits)) / - ((double)(total_hits + total_misses)); + if ((total_hits > 0) || (total_misses > 0)) + hit_rate = (double)100.0f * ((double)(total_hits)) / ((double)(total_hits + total_misses)); else hit_rate = 0.0f; - if(cache_ptr->successful_ht_searches > 0) - average_successful_search_depth = - ((double)(cache_ptr->total_successful_ht_search_depth)) / - ((double)(cache_ptr->successful_ht_searches)); + if (cache_ptr->successful_ht_searches > 0) + average_successful_search_depth = ((double)(cache_ptr->total_successful_ht_search_depth)) / + ((double)(cache_ptr->successful_ht_searches)); - if(cache_ptr->failed_ht_searches > 0) + if (cache_ptr->failed_ht_searches > 0) average_failed_search_depth = - ((double)(cache_ptr->total_failed_ht_search_depth)) / - ((double)(cache_ptr->failed_ht_searches)); - + ((double)(cache_ptr->total_failed_ht_search_depth)) / ((double)(cache_ptr->failed_ht_searches)); - HDfprintf(stdout, "\n%sH5C: cache statistics for %s\n", - cache_ptr->prefix, cache_name); + HDfprintf(stdout, "\n%sH5C: cache statistics for %s\n", cache_ptr->prefix, cache_name); HDfprintf(stdout, "\n"); - HDfprintf(stdout, - "%s hash table insertion / deletions = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->total_ht_insertions), - (long)(cache_ptr->total_ht_deletions)); - - HDfprintf(stdout, - "%s HT successful / failed searches = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->successful_ht_searches), - (long)(cache_ptr->failed_ht_searches)); - - HDfprintf(stdout, - "%s Av. HT suc / failed search depth = %f / %f\n", - cache_ptr->prefix, - average_successful_search_depth, - average_failed_search_depth); - - HDfprintf(stdout, - "%s current (max) index size / length = %ld (%ld) / %lu (%lu)\n", - cache_ptr->prefix, - (long)(cache_ptr->index_size), - (long)(cache_ptr->max_index_size), - (unsigned long)(cache_ptr->index_len), - (unsigned long)(cache_ptr->max_index_len)); - - HDfprintf(stdout, - "%s current (max) clean/dirty idx size = %ld (%ld) / %ld (%ld)\n", - cache_ptr->prefix, - (long)(cache_ptr->clean_index_size), - (long)(cache_ptr->max_clean_index_size), - (long)(cache_ptr->dirty_index_size), - (long)(cache_ptr->max_dirty_index_size)); - - HDfprintf(stdout, - "%s current (max) slist size / length = %ld (%ld) / %lu (%lu)\n", - cache_ptr->prefix, - (long)(cache_ptr->slist_size), - (long)(cache_ptr->max_slist_size), - (unsigned long)(cache_ptr->slist_len), - (unsigned long)(cache_ptr->max_slist_len)); - - HDfprintf(stdout, - "%s current (max) PL size / length = %ld (%ld) / %lu (%lu)\n", - cache_ptr->prefix, - (long)(cache_ptr->pl_size), - (long)(cache_ptr->max_pl_size), - (unsigned long)(cache_ptr->pl_len), + HDfprintf(stdout, "%s hash table insertion / deletions = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->total_ht_insertions), (long)(cache_ptr->total_ht_deletions)); + + HDfprintf(stdout, "%s HT successful / failed searches = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->successful_ht_searches), (long)(cache_ptr->failed_ht_searches)); + + HDfprintf(stdout, "%s Av. HT suc / failed search depth = %f / %f\n", cache_ptr->prefix, + average_successful_search_depth, average_failed_search_depth); + + HDfprintf(stdout, "%s current (max) index size / length = %ld (%ld) / %lu (%lu)\n", cache_ptr->prefix, + (long)(cache_ptr->index_size), (long)(cache_ptr->max_index_size), + (unsigned long)(cache_ptr->index_len), (unsigned long)(cache_ptr->max_index_len)); + + HDfprintf(stdout, "%s current (max) clean/dirty idx size = %ld (%ld) / %ld (%ld)\n", cache_ptr->prefix, + (long)(cache_ptr->clean_index_size), (long)(cache_ptr->max_clean_index_size), + (long)(cache_ptr->dirty_index_size), (long)(cache_ptr->max_dirty_index_size)); + + HDfprintf(stdout, "%s current (max) slist size / length = %ld (%ld) / %lu (%lu)\n", cache_ptr->prefix, + (long)(cache_ptr->slist_size), (long)(cache_ptr->max_slist_size), + (unsigned long)(cache_ptr->slist_len), (unsigned long)(cache_ptr->max_slist_len)); + + HDfprintf(stdout, "%s current (max) PL size / length = %ld (%ld) / %lu (%lu)\n", cache_ptr->prefix, + (long)(cache_ptr->pl_size), (long)(cache_ptr->max_pl_size), (unsigned long)(cache_ptr->pl_len), (unsigned long)(cache_ptr->max_pl_len)); - HDfprintf(stdout, - "%s current (max) PEL size / length = %ld (%ld) / %lu (%lu)\n", - cache_ptr->prefix, - (long)(cache_ptr->pel_size), - (long)(cache_ptr->max_pel_size), - (unsigned long)(cache_ptr->pel_len), - (unsigned long)(cache_ptr->max_pel_len)); + HDfprintf(stdout, "%s current (max) PEL size / length = %ld (%ld) / %lu (%lu)\n", cache_ptr->prefix, + (long)(cache_ptr->pel_size), (long)(cache_ptr->max_pel_size), + (unsigned long)(cache_ptr->pel_len), (unsigned long)(cache_ptr->max_pel_len)); - HDfprintf(stdout, - "%s current LRU list size / length = %ld / %lu\n", - cache_ptr->prefix, - (long)(cache_ptr->LRU_list_size), - (unsigned long)(cache_ptr->LRU_list_len)); + HDfprintf(stdout, "%s current LRU list size / length = %ld / %lu\n", cache_ptr->prefix, + (long)(cache_ptr->LRU_list_size), (unsigned long)(cache_ptr->LRU_list_len)); #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - HDfprintf(stdout, - "%s current clean LRU size / length = %ld / %lu\n", - cache_ptr->prefix, - (long)(cache_ptr->cLRU_list_size), - (unsigned long)(cache_ptr->cLRU_list_len)); - - HDfprintf(stdout, - "%s current dirty LRU size / length = %ld / %lu\n", - cache_ptr->prefix, - (long)(cache_ptr->dLRU_list_size), - (unsigned long)(cache_ptr->dLRU_list_len)); + HDfprintf(stdout, "%s current clean LRU size / length = %ld / %lu\n", cache_ptr->prefix, + (long)(cache_ptr->cLRU_list_size), (unsigned long)(cache_ptr->cLRU_list_len)); + + HDfprintf(stdout, "%s current dirty LRU size / length = %ld / %lu\n", cache_ptr->prefix, + (long)(cache_ptr->dLRU_list_size), (unsigned long)(cache_ptr->dLRU_list_len)); #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - HDfprintf(stdout, - "%s Total hits / misses / hit_rate = %ld / %ld / %f\n", - cache_ptr->prefix, - (long)total_hits, - (long)total_misses, - hit_rate); - - HDfprintf(stdout, - "%s Total write / read (max) protects = %ld / %ld (%ld)\n", - cache_ptr->prefix, - (long)total_write_protects, - (long)total_read_protects, - (long)max_read_protects); - - HDfprintf(stdout, - "%s Total clears / flushes = %ld / %ld\n", - cache_ptr->prefix, - (long)total_clears, - (long)total_flushes); - - HDfprintf(stdout, - "%s Total evictions / take ownerships = %ld / %ld\n", - cache_ptr->prefix, - (long)total_evictions, - (long)total_take_ownerships); - - HDfprintf(stdout, - "%s Total insertions(pinned) / moves = %ld(%ld) / %ld\n", - cache_ptr->prefix, - (long)total_insertions, - (long)total_pinned_insertions, - (long)total_moves); - - HDfprintf(stdout, - "%s Total entry / cache flush moves = %ld / %ld\n", - cache_ptr->prefix, - (long)total_entry_flush_moves, - (long)total_cache_flush_moves); - - HDfprintf(stdout, "%s Total entry size incrs / decrs = %ld / %ld\n", - cache_ptr->prefix, - (long)total_size_increases, - (long)total_size_decreases); - - HDfprintf(stdout, "%s Ttl entry/cache flush size changes = %ld / %ld\n", - cache_ptr->prefix, - (long)total_entry_flush_size_changes, - (long)total_cache_flush_size_changes); - - HDfprintf(stdout, - "%s Total entry pins (dirty) / unpins = %ld (%ld) / %ld\n", - cache_ptr->prefix, - (long)total_pins, - (long)total_dirty_pins, - (long)total_unpins); - - HDfprintf(stdout, "%s Total pinned flushes / clears = %ld / %ld\n", - cache_ptr->prefix, - (long)total_pinned_flushes, - (long)total_pinned_clears); - - HDfprintf(stdout, "%s MSIC: (make space in cache) calls = %lld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s Total hits / misses / hit_rate = %ld / %ld / %f\n", cache_ptr->prefix, + (long)total_hits, (long)total_misses, hit_rate); + + HDfprintf(stdout, "%s Total write / read (max) protects = %ld / %ld (%ld)\n", cache_ptr->prefix, + (long)total_write_protects, (long)total_read_protects, (long)max_read_protects); + + HDfprintf(stdout, "%s Total clears / flushes = %ld / %ld\n", cache_ptr->prefix, + (long)total_clears, (long)total_flushes); + + HDfprintf(stdout, "%s Total evictions / take ownerships = %ld / %ld\n", cache_ptr->prefix, + (long)total_evictions, (long)total_take_ownerships); + + HDfprintf(stdout, "%s Total insertions(pinned) / moves = %ld(%ld) / %ld\n", cache_ptr->prefix, + (long)total_insertions, (long)total_pinned_insertions, (long)total_moves); + + HDfprintf(stdout, "%s Total entry / cache flush moves = %ld / %ld\n", cache_ptr->prefix, + (long)total_entry_flush_moves, (long)total_cache_flush_moves); + + HDfprintf(stdout, "%s Total entry size incrs / decrs = %ld / %ld\n", cache_ptr->prefix, + (long)total_size_increases, (long)total_size_decreases); + + HDfprintf(stdout, "%s Ttl entry/cache flush size changes = %ld / %ld\n", cache_ptr->prefix, + (long)total_entry_flush_size_changes, (long)total_cache_flush_size_changes); + + HDfprintf(stdout, "%s Total entry pins (dirty) / unpins = %ld (%ld) / %ld\n", cache_ptr->prefix, + (long)total_pins, (long)total_dirty_pins, (long)total_unpins); + + HDfprintf(stdout, "%s Total pinned flushes / clears = %ld / %ld\n", cache_ptr->prefix, + (long)total_pinned_flushes, (long)total_pinned_clears); + + HDfprintf(stdout, "%s MSIC: (make space in cache) calls = %lld\n", cache_ptr->prefix, (long long)(cache_ptr->calls_to_msic)); if (cache_ptr->calls_to_msic > 0) average_entries_skipped_per_calls_to_msic = - (((double)(cache_ptr->total_entries_skipped_in_msic)) / - ((double)(cache_ptr->calls_to_msic))); + (((double)(cache_ptr->total_entries_skipped_in_msic)) / ((double)(cache_ptr->calls_to_msic))); - HDfprintf(stdout, "%s MSIC: Average/max entries skipped = %lf / %ld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s MSIC: Average/max entries skipped = %lf / %ld\n", cache_ptr->prefix, (double)average_entries_skipped_per_calls_to_msic, (long)(cache_ptr->max_entries_skipped_in_msic)); - if(cache_ptr->calls_to_msic > 0) + if (cache_ptr->calls_to_msic > 0) average_dirty_pf_entries_skipped_per_call_to_msic = (((double)(cache_ptr->total_dirty_pf_entries_skipped_in_msic)) / - ((double)(cache_ptr->calls_to_msic))); + ((double)(cache_ptr->calls_to_msic))); - HDfprintf(stdout, - "%s MSIC: Average/max dirty pf entries skipped = %lf / %ld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s MSIC: Average/max dirty pf entries skipped = %lf / %ld\n", cache_ptr->prefix, average_dirty_pf_entries_skipped_per_call_to_msic, (long)(cache_ptr->max_dirty_pf_entries_skipped_in_msic)); - if(cache_ptr->calls_to_msic > 0) + if (cache_ptr->calls_to_msic > 0) average_entries_scanned_per_calls_to_msic = - (((double)(cache_ptr->total_entries_scanned_in_msic)) / - ((double)(cache_ptr->calls_to_msic))); + (((double)(cache_ptr->total_entries_scanned_in_msic)) / ((double)(cache_ptr->calls_to_msic))); - HDfprintf(stdout, "%s MSIC: Average/max entries scanned = %lf / %ld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s MSIC: Average/max entries scanned = %lf / %ld\n", cache_ptr->prefix, (double)average_entries_scanned_per_calls_to_msic, (long)(cache_ptr->max_entries_scanned_in_msic)); - HDfprintf(stdout, "%s MSIC: Scanned to make space(evict) = %lld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s MSIC: Scanned to make space(evict) = %lld\n", cache_ptr->prefix, (long long)(cache_ptr->entries_scanned_to_make_space)); - HDfprintf(stdout, "%s MSIC: Scanned to satisfy min_clean = %lld\n", - cache_ptr->prefix, - (long long)(cache_ptr->total_entries_scanned_in_msic - - cache_ptr->entries_scanned_to_make_space)); + HDfprintf( + stdout, "%s MSIC: Scanned to satisfy min_clean = %lld\n", cache_ptr->prefix, + (long long)(cache_ptr->total_entries_scanned_in_msic - cache_ptr->entries_scanned_to_make_space)); - HDfprintf(stdout, - "%s slist/LRU/index scan restarts = %lld / %lld / %lld.\n", - cache_ptr->prefix, - (long long)(cache_ptr->slist_scan_restarts), - (long long)(cache_ptr->LRU_scan_restarts), + HDfprintf(stdout, "%s slist/LRU/index scan restarts = %lld / %lld / %lld.\n", cache_ptr->prefix, + (long long)(cache_ptr->slist_scan_restarts), (long long)(cache_ptr->LRU_scan_restarts), (long long)(cache_ptr->index_scan_restarts)); - HDfprintf(stdout, - "%s cache image creations/reads/loads/size = %d / %d /%d / %Hu\n", - cache_ptr->prefix, - cache_ptr->images_created, - cache_ptr->images_read, - cache_ptr->images_loaded, + HDfprintf(stdout, "%s cache image creations/reads/loads/size = %d / %d /%d / %Hu\n", cache_ptr->prefix, + cache_ptr->images_created, cache_ptr->images_read, cache_ptr->images_loaded, cache_ptr->last_image_size); - HDfprintf(stdout, - "%s prefetches / dirty prefetches = %lld / %lld\n", - cache_ptr->prefix, - (long long)(cache_ptr->prefetches), - (long long)(cache_ptr->dirty_prefetches)); + HDfprintf(stdout, "%s prefetches / dirty prefetches = %lld / %lld\n", cache_ptr->prefix, + (long long)(cache_ptr->prefetches), (long long)(cache_ptr->dirty_prefetches)); - HDfprintf(stdout, - "%s prefetch hits/flushes/evictions = %lld / %lld / %lld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s prefetch hits/flushes/evictions = %lld / %lld / %lld\n", cache_ptr->prefix, (long long)(cache_ptr->prefetch_hits), (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID])); - if(cache_ptr->prefetches > 0) + if (cache_ptr->prefetches > 0) prefetch_use_rate = - (double)100.0f * ((double)(cache_ptr->prefetch_hits)) / - ((double)(cache_ptr->prefetches)); + (double)100.0f * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); else prefetch_use_rate = 0.0f; - HDfprintf(stdout, - "%s prefetched entry use rate = %lf\n", - cache_ptr->prefix, - prefetch_use_rate); + HDfprintf(stdout, "%s prefetched entry use rate = %lf\n", cache_ptr->prefix, prefetch_use_rate); #if H5C_COLLECT_CACHE_ENTRY_STATS - HDfprintf(stdout, "%s aggregate max / min accesses = %d / %d\n", - cache_ptr->prefix, - (int)aggregate_max_accesses, - (int)aggregate_min_accesses); + HDfprintf(stdout, "%s aggregate max / min accesses = %d / %d\n", cache_ptr->prefix, + (int)aggregate_max_accesses, (int)aggregate_min_accesses); - HDfprintf(stdout, "%s aggregate max_clears / max_flushes = %d / %d\n", - cache_ptr->prefix, - (int)aggregate_max_clears, - (int)aggregate_max_flushes); + HDfprintf(stdout, "%s aggregate max_clears / max_flushes = %d / %d\n", cache_ptr->prefix, + (int)aggregate_max_clears, (int)aggregate_max_flushes); - HDfprintf(stdout, "%s aggregate max_size / max_pins = %d / %d\n", - cache_ptr->prefix, - (int)aggregate_max_size, - (int)aggregate_max_pins); + HDfprintf(stdout, "%s aggregate max_size / max_pins = %d / %d\n", cache_ptr->prefix, + (int)aggregate_max_size, (int)aggregate_max_pins); #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ - if(display_detailed_stats) { - for(i = 0; i <= cache_ptr->max_type_id; i++) { + if (display_detailed_stats) { + for (i = 0; i <= cache_ptr->max_type_id; i++) { HDfprintf(stdout, "\n"); - HDfprintf(stdout, "%s Stats on %s:\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s Stats on %s:\n", cache_ptr->prefix, ((cache_ptr->class_table_ptr))[i]->name); - if((cache_ptr->hits[i] > 0) || (cache_ptr->misses[i] > 0)) + if ((cache_ptr->hits[i] > 0) || (cache_ptr->misses[i] > 0)) hit_rate = (double)100.0f * ((double)(cache_ptr->hits[i])) / - ((double)(cache_ptr->hits[i] + cache_ptr->misses[i])); + ((double)(cache_ptr->hits[i] + cache_ptr->misses[i])); else hit_rate = 0.0f; - HDfprintf(stdout, - "%s hits / misses / hit_rate = %ld / %ld / %f\n", - cache_ptr->prefix, - (long)(cache_ptr->hits[i]), - (long)(cache_ptr->misses[i]), - hit_rate); - - HDfprintf(stdout, - "%s write / read (max) protects = %ld / %ld (%d)\n", - cache_ptr->prefix, - (long)(cache_ptr->write_protects[i]), - (long)(cache_ptr->read_protects[i]), + HDfprintf(stdout, "%s hits / misses / hit_rate = %ld / %ld / %f\n", cache_ptr->prefix, + (long)(cache_ptr->hits[i]), (long)(cache_ptr->misses[i]), hit_rate); + + HDfprintf(stdout, "%s write / read (max) protects = %ld / %ld (%d)\n", cache_ptr->prefix, + (long)(cache_ptr->write_protects[i]), (long)(cache_ptr->read_protects[i]), (int)(cache_ptr->max_read_protects[i])); - HDfprintf(stdout, - "%s clears / flushes = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->clears[i]), - (long)(cache_ptr->flushes[i])); - - HDfprintf(stdout, - "%s evictions / take ownerships = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->evictions[i]), - (long)(cache_ptr->take_ownerships[i])); - - HDfprintf(stdout, - "%s insertions(pinned) / moves = %ld(%ld) / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->insertions[i]), - (long)(cache_ptr->pinned_insertions[i]), + HDfprintf(stdout, "%s clears / flushes = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->clears[i]), (long)(cache_ptr->flushes[i])); + + HDfprintf(stdout, "%s evictions / take ownerships = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->evictions[i]), (long)(cache_ptr->take_ownerships[i])); + + HDfprintf(stdout, "%s insertions(pinned) / moves = %ld(%ld) / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->insertions[i]), (long)(cache_ptr->pinned_insertions[i]), (long)(cache_ptr->moves[i])); - HDfprintf(stdout, - "%s entry / cache flush moves = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->entry_flush_moves[i]), - (long)(cache_ptr->cache_flush_moves[i])); - - HDfprintf(stdout, - "%s size increases / decreases = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->size_increases[i]), - (long)(cache_ptr->size_decreases[i])); - - HDfprintf(stdout, - "%s entry/cache flush size changes = %ld / %ld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s entry / cache flush moves = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->entry_flush_moves[i]), (long)(cache_ptr->cache_flush_moves[i])); + + HDfprintf(stdout, "%s size increases / decreases = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->size_increases[i]), (long)(cache_ptr->size_decreases[i])); + + HDfprintf(stdout, "%s entry/cache flush size changes = %ld / %ld\n", cache_ptr->prefix, (long)(cache_ptr->entry_flush_size_changes[i]), (long)(cache_ptr->cache_flush_size_changes[i])); + HDfprintf(stdout, "%s entry pins / unpins = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->pins[i]), (long)(cache_ptr->unpins[i])); - HDfprintf(stdout, - "%s entry pins / unpins = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->pins[i]), - (long)(cache_ptr->unpins[i])); - - HDfprintf(stdout, - "%s entry dirty pins/pin'd flushes = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->dirty_pins[i]), - (long)(cache_ptr->pinned_flushes[i])); + HDfprintf(stdout, "%s entry dirty pins/pin'd flushes = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->dirty_pins[i]), (long)(cache_ptr->pinned_flushes[i])); #if H5C_COLLECT_CACHE_ENTRY_STATS - HDfprintf(stdout, - "%s entry max / min accesses = %d / %d\n", - cache_ptr->prefix, - cache_ptr->max_accesses[i], - cache_ptr->min_accesses[i]); - - HDfprintf(stdout, - "%s entry max_clears / max_flushes = %d / %d\n", - cache_ptr->prefix, - cache_ptr->max_clears[i], - cache_ptr->max_flushes[i]); + HDfprintf(stdout, "%s entry max / min accesses = %d / %d\n", cache_ptr->prefix, + cache_ptr->max_accesses[i], cache_ptr->min_accesses[i]); - HDfprintf(stdout, - "%s entry max_size / max_pins = %d / %d\n", - cache_ptr->prefix, - (int)(cache_ptr->max_size[i]), - (int)(cache_ptr->max_pins[i])); + HDfprintf(stdout, "%s entry max_clears / max_flushes = %d / %d\n", cache_ptr->prefix, + cache_ptr->max_clears[i], cache_ptr->max_flushes[i]); + HDfprintf(stdout, "%s entry max_size / max_pins = %d / %d\n", cache_ptr->prefix, + (int)(cache_ptr->max_size[i]), (int)(cache_ptr->max_pins[i])); #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ } /* end for */ - } /* end if */ + } /* end if */ HDfprintf(stdout, "\n"); @@ -969,7 +789,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_stats() */ - /*------------------------------------------------------------------------- * * Function: H5C_stats__reset @@ -984,12 +803,12 @@ done: */ void #ifndef NDEBUG -H5C_stats__reset(H5C_t * cache_ptr) +H5C_stats__reset(H5C_t *cache_ptr) #else /* NDEBUG */ #if H5C_COLLECT_CACHE_STATS -H5C_stats__reset(H5C_t * cache_ptr) -#else /* H5C_COLLECT_CACHE_STATS */ -H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) +H5C_stats__reset(H5C_t *cache_ptr) +#else /* H5C_COLLECT_CACHE_STATS */ +H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ #endif /* NDEBUG */ { @@ -1001,52 +820,52 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); #if H5C_COLLECT_CACHE_STATS - for(i = 0; i <= cache_ptr->max_type_id; i++) { - cache_ptr->hits[i] = 0; - cache_ptr->misses[i] = 0; - cache_ptr->write_protects[i] = 0; - cache_ptr->read_protects[i] = 0; - cache_ptr->max_read_protects[i] = 0; - cache_ptr->insertions[i] = 0; - cache_ptr->pinned_insertions[i] = 0; - cache_ptr->clears[i] = 0; - cache_ptr->flushes[i] = 0; - cache_ptr->evictions[i] = 0; - cache_ptr->take_ownerships[i] = 0; - cache_ptr->moves[i] = 0; - cache_ptr->entry_flush_moves[i] = 0; - cache_ptr->cache_flush_moves[i] = 0; - cache_ptr->pins[i] = 0; - cache_ptr->unpins[i] = 0; - cache_ptr->dirty_pins[i] = 0; - cache_ptr->pinned_flushes[i] = 0; - cache_ptr->pinned_clears[i] = 0; - cache_ptr->size_increases[i] = 0; - cache_ptr->size_decreases[i] = 0; - cache_ptr->entry_flush_size_changes[i] = 0; - cache_ptr->cache_flush_size_changes[i] = 0; + for (i = 0; i <= cache_ptr->max_type_id; i++) { + cache_ptr->hits[i] = 0; + cache_ptr->misses[i] = 0; + cache_ptr->write_protects[i] = 0; + cache_ptr->read_protects[i] = 0; + cache_ptr->max_read_protects[i] = 0; + cache_ptr->insertions[i] = 0; + cache_ptr->pinned_insertions[i] = 0; + cache_ptr->clears[i] = 0; + cache_ptr->flushes[i] = 0; + cache_ptr->evictions[i] = 0; + cache_ptr->take_ownerships[i] = 0; + cache_ptr->moves[i] = 0; + cache_ptr->entry_flush_moves[i] = 0; + cache_ptr->cache_flush_moves[i] = 0; + cache_ptr->pins[i] = 0; + cache_ptr->unpins[i] = 0; + cache_ptr->dirty_pins[i] = 0; + cache_ptr->pinned_flushes[i] = 0; + cache_ptr->pinned_clears[i] = 0; + cache_ptr->size_increases[i] = 0; + cache_ptr->size_decreases[i] = 0; + cache_ptr->entry_flush_size_changes[i] = 0; + cache_ptr->cache_flush_size_changes[i] = 0; } /* end for */ - cache_ptr->total_ht_insertions = 0; - cache_ptr->total_ht_deletions = 0; - cache_ptr->successful_ht_searches = 0; - cache_ptr->total_successful_ht_search_depth = 0; - cache_ptr->failed_ht_searches = 0; - cache_ptr->total_failed_ht_search_depth = 0; + cache_ptr->total_ht_insertions = 0; + cache_ptr->total_ht_deletions = 0; + cache_ptr->successful_ht_searches = 0; + cache_ptr->total_successful_ht_search_depth = 0; + cache_ptr->failed_ht_searches = 0; + cache_ptr->total_failed_ht_search_depth = 0; - cache_ptr->max_index_len = 0; - cache_ptr->max_index_size = (size_t)0; - cache_ptr->max_clean_index_size = (size_t)0; - cache_ptr->max_dirty_index_size = (size_t)0; + cache_ptr->max_index_len = 0; + cache_ptr->max_index_size = (size_t)0; + cache_ptr->max_clean_index_size = (size_t)0; + cache_ptr->max_dirty_index_size = (size_t)0; - cache_ptr->max_slist_len = 0; - cache_ptr->max_slist_size = (size_t)0; + cache_ptr->max_slist_len = 0; + cache_ptr->max_slist_size = (size_t)0; - cache_ptr->max_pl_len = 0; - cache_ptr->max_pl_size = (size_t)0; + cache_ptr->max_pl_len = 0; + cache_ptr->max_pl_size = (size_t)0; - cache_ptr->max_pel_len = 0; - cache_ptr->max_pel_size = (size_t)0; + cache_ptr->max_pel_len = 0; + cache_ptr->max_pel_size = (size_t)0; cache_ptr->calls_to_msic = 0; cache_ptr->total_entries_skipped_in_msic = 0; @@ -1057,27 +876,27 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) cache_ptr->max_entries_scanned_in_msic = 0; cache_ptr->entries_scanned_to_make_space = 0; - cache_ptr->slist_scan_restarts = 0; - cache_ptr->LRU_scan_restarts = 0; - cache_ptr->index_scan_restarts = 0; + cache_ptr->slist_scan_restarts = 0; + cache_ptr->LRU_scan_restarts = 0; + cache_ptr->index_scan_restarts = 0; - cache_ptr->images_created = 0; - cache_ptr->images_read = 0; - cache_ptr->images_loaded = 0; - cache_ptr->last_image_size = (hsize_t)0; + cache_ptr->images_created = 0; + cache_ptr->images_read = 0; + cache_ptr->images_loaded = 0; + cache_ptr->last_image_size = (hsize_t)0; - cache_ptr->prefetches = 0; - cache_ptr->dirty_prefetches = 0; - cache_ptr->prefetch_hits = 0; + cache_ptr->prefetches = 0; + cache_ptr->dirty_prefetches = 0; + cache_ptr->prefetch_hits = 0; #if H5C_COLLECT_CACHE_ENTRY_STATS - for(i = 0; i <= cache_ptr->max_type_id; i++) { - cache_ptr->max_accesses[i] = 0; - cache_ptr->min_accesses[i] = 1000000; - cache_ptr->max_clears[i] = 0; - cache_ptr->max_flushes[i] = 0; - cache_ptr->max_size[i] = (size_t)0; - cache_ptr->max_pins[i] = 0; + for (i = 0; i <= cache_ptr->max_type_id; i++) { + cache_ptr->max_accesses[i] = 0; + cache_ptr->min_accesses[i] = 1000000; + cache_ptr->max_clears[i] = 0; + cache_ptr->max_flushes[i] = 0; + cache_ptr->max_size[i] = (size_t)0; + cache_ptr->max_pins[i] = 0; } /* end for */ #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ @@ -1086,25 +905,24 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) return; } /* H5C_stats__reset() */ -extern void -H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, - hbool_t dump_parents, const char *prefix, int indent); +extern void H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, hbool_t dump_parents, + const char *prefix, int indent); static void H5C__dump_parents(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, const char *prefix, int indent) { unsigned u; - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) H5C__dump_entry(cache_ptr, entry_ptr->flush_dep_parent[u], TRUE, prefix, indent + 2); } typedef struct H5C__dump_child_ctx_t { - H5C_t *cache_ptr; + H5C_t * cache_ptr; const H5C_cache_entry_t *parent; - hbool_t dump_parents; - const char *prefix; - int indent; + hbool_t dump_parents; + const char * prefix; + int indent; } H5C__dump_child_ctx_t; static int @@ -1112,49 +930,52 @@ H5C__dump_children_cb(H5C_cache_entry_t *entry_ptr, void *_ctx) { H5C__dump_child_ctx_t *ctx = (H5C__dump_child_ctx_t *)_ctx; - if(entry_ptr->tag_info->tag != entry_ptr->addr) { + if (entry_ptr->tag_info->tag != entry_ptr->addr) { unsigned u; HDassert(entry_ptr->flush_dep_nparents); - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) - if(ctx->parent == entry_ptr->flush_dep_parent[u]) + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) + if (ctx->parent == entry_ptr->flush_dep_parent[u]) H5C__dump_entry(ctx->cache_ptr, entry_ptr, ctx->dump_parents, ctx->prefix, ctx->indent + 2); } /* end if */ - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /* end H5C__dump_children_cb() */ static void -H5C__dump_children(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, - hbool_t dump_parents, const char *prefix, int indent) +H5C__dump_children(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, hbool_t dump_parents, + const char *prefix, int indent) { H5C__dump_child_ctx_t ctx; HDassert(entry_ptr->tag_info); - ctx.cache_ptr = cache_ptr; - ctx.parent = entry_ptr; + ctx.cache_ptr = cache_ptr; + ctx.parent = entry_ptr; ctx.dump_parents = dump_parents; - ctx.prefix = prefix; - ctx.indent = indent; + ctx.prefix = prefix; + ctx.indent = indent; H5C__iter_tagged_entries(cache_ptr, entry_ptr->tag_info->tag, FALSE, H5C__dump_children_cb, &ctx); } /* end H5C__dump_children() */ void -H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, - hbool_t dump_parents, const char *prefix, int indent) +H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, hbool_t dump_parents, + const char *prefix, int indent) { HDassert(cache_ptr); HDassert(entry_ptr); - HDfprintf(stderr, "%*s%s: entry_ptr = (%a, '%s', %a, %t, %u, %u/%u)\n", indent, "", prefix, entry_ptr->addr, entry_ptr->type->name, entry_ptr->tag_info ? entry_ptr->tag_info->tag : HADDR_UNDEF, entry_ptr->is_dirty, entry_ptr->flush_dep_nparents, entry_ptr->flush_dep_nchildren, entry_ptr->flush_dep_ndirty_children); - if(dump_parents && entry_ptr->flush_dep_nparents) + HDfprintf(stderr, "%*s%s: entry_ptr = (%a, '%s', %a, %t, %u, %u/%u)\n", indent, "", prefix, + entry_ptr->addr, entry_ptr->type->name, + entry_ptr->tag_info ? entry_ptr->tag_info->tag : HADDR_UNDEF, entry_ptr->is_dirty, + entry_ptr->flush_dep_nparents, entry_ptr->flush_dep_nchildren, + entry_ptr->flush_dep_ndirty_children); + if (dump_parents && entry_ptr->flush_dep_nparents) H5C__dump_parents(cache_ptr, entry_ptr, "Parent", indent); - if(entry_ptr->flush_dep_nchildren) + if (entry_ptr->flush_dep_nchildren) H5C__dump_children(cache_ptr, entry_ptr, FALSE, "Child", indent); } /* end H5C__dump_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_flush_dependency_exists() * @@ -1182,13 +1003,12 @@ H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, */ #ifndef NDEBUG herr_t -H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child_addr, - hbool_t *fd_exists_ptr) +H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child_addr, hbool_t *fd_exists_ptr) { - hbool_t fd_exists = FALSE; /* whether flush dependency exists */ - H5C_cache_entry_t * parent_ptr; /* Ptr to parent entry */ - H5C_cache_entry_t * child_ptr; /* Ptr to child entry */ - hbool_t ret_value = FALSE; /* Return value */ + hbool_t fd_exists = FALSE; /* whether flush dependency exists */ + H5C_cache_entry_t *parent_ptr; /* Ptr to parent entry */ + H5C_cache_entry_t *child_ptr; /* Ptr to child entry */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1202,25 +1022,25 @@ H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child H5C__SEARCH_INDEX(cache_ptr, parent_addr, parent_ptr, FAIL) H5C__SEARCH_INDEX(cache_ptr, child_addr, child_ptr, FAIL) - if(parent_ptr && child_ptr) { + if (parent_ptr && child_ptr) { HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(child_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(child_ptr->flush_dep_nparents > 0) { - unsigned u; /* Local index variable */ + if (child_ptr->flush_dep_nparents > 0) { + unsigned u; /* Local index variable */ HDassert(child_ptr->flush_dep_parent); HDassert(child_ptr->flush_dep_parent_nalloc >= child_ptr->flush_dep_nparents); - for(u = 0; u < child_ptr->flush_dep_nparents; u++) { - if(child_ptr->flush_dep_parent[u] == parent_ptr) { + for (u = 0; u < child_ptr->flush_dep_nparents; u++) { + if (child_ptr->flush_dep_parent[u] == parent_ptr) { fd_exists = TRUE; HDassert(parent_ptr->flush_dep_nchildren > 0); break; } /* end if */ - } /* end for */ - } /* end if */ - } /* end if */ + } /* end for */ + } /* end if */ + } /* end if */ *fd_exists_ptr = fd_exists; @@ -1229,7 +1049,6 @@ done: } /* H5C_flush_dependency_exists() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_validate_index_list @@ -1250,17 +1069,17 @@ done: herr_t H5C_validate_index_list(H5C_t *cache_ptr) { - H5C_cache_entry_t * entry_ptr = NULL; - uint32_t len = 0; - int32_t index_ring_len[H5C_RING_NTYPES]; - size_t size = 0; - size_t clean_size = 0; - size_t dirty_size = 0; - size_t index_ring_size[H5C_RING_NTYPES]; - size_t clean_index_ring_size[H5C_RING_NTYPES]; - size_t dirty_index_ring_size[H5C_RING_NTYPES]; - int i; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr = NULL; + uint32_t len = 0; + int32_t index_ring_len[H5C_RING_NTYPES]; + size_t size = 0; + size_t clean_size = 0; + size_t dirty_size = 0; + size_t index_ring_size[H5C_RING_NTYPES]; + size_t clean_index_ring_size[H5C_RING_NTYPES]; + size_t dirty_index_ring_size[H5C_RING_NTYPES]; + int i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1268,89 +1087,84 @@ H5C_validate_index_list(H5C_t *cache_ptr) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - for(i = 0; i < H5C_RING_NTYPES; i++) { - index_ring_len[i] = 0; - index_ring_size[i] = 0; - clean_index_ring_size[i] = 0; - dirty_index_ring_size[i] = 0; + for (i = 0; i < H5C_RING_NTYPES; i++) { + index_ring_len[i] = 0; + index_ring_size[i] = 0; + clean_index_ring_size[i] = 0; + dirty_index_ring_size[i] = 0; } /* end if */ - if(((cache_ptr->il_head == NULL) || (cache_ptr->il_tail == NULL)) - && (cache_ptr->il_head != cache_ptr->il_tail)) + if (((cache_ptr->il_head == NULL) || (cache_ptr->il_tail == NULL)) && + (cache_ptr->il_head != cache_ptr->il_tail)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list pointer validation failed") - if((cache_ptr->index_len == 1) && ((cache_ptr->il_head != cache_ptr->il_tail) - || (cache_ptr->il_head == NULL) || (cache_ptr->il_head->size != cache_ptr->index_size))) + if ((cache_ptr->index_len == 1) && + ((cache_ptr->il_head != cache_ptr->il_tail) || (cache_ptr->il_head == NULL) || + (cache_ptr->il_head->size != cache_ptr->index_size))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list pointer sanity checks failed") - if((cache_ptr->index_len >= 1) - && ((cache_ptr->il_head == NULL) - || (cache_ptr->il_head->il_prev != NULL) - || (cache_ptr->il_tail == NULL) - || (cache_ptr->il_tail->il_next != NULL))) + if ((cache_ptr->index_len >= 1) && + ((cache_ptr->il_head == NULL) || (cache_ptr->il_head->il_prev != NULL) || + (cache_ptr->il_tail == NULL) || (cache_ptr->il_tail->il_next != NULL))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list length sanity checks failed") entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - if((entry_ptr != cache_ptr->il_head) - && ((entry_ptr->il_prev == NULL) || (entry_ptr->il_prev->il_next != entry_ptr))) + while (entry_ptr != NULL) { + if ((entry_ptr != cache_ptr->il_head) && + ((entry_ptr->il_prev == NULL) || (entry_ptr->il_prev->il_next != entry_ptr))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list pointers for entry are invalid") - if((entry_ptr != cache_ptr->il_tail) - && ((entry_ptr->il_next == NULL) || (entry_ptr->il_next->il_prev != entry_ptr))) + if ((entry_ptr != cache_ptr->il_tail) && + ((entry_ptr->il_next == NULL) || (entry_ptr->il_next->il_prev != entry_ptr))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list pointers for entry are invalid") - HDassert(entry_ptr->ring > 0); - HDassert(entry_ptr->ring < H5C_RING_NTYPES); + HDassert(entry_ptr->ring > 0); + HDassert(entry_ptr->ring < H5C_RING_NTYPES); len++; - index_ring_len[entry_ptr->ring] += 1; + index_ring_len[entry_ptr->ring] += 1; size += entry_ptr->size; index_ring_size[entry_ptr->ring] += entry_ptr->size; - if(entry_ptr->is_dirty) { - dirty_size += entry_ptr->size; - dirty_index_ring_size[entry_ptr->ring] += entry_ptr->size; - } /* end if */ + if (entry_ptr->is_dirty) { + dirty_size += entry_ptr->size; + dirty_index_ring_size[entry_ptr->ring] += entry_ptr->size; + } /* end if */ else { - clean_size += entry_ptr->size; - clean_index_ring_size[entry_ptr->ring] += entry_ptr->size; - } /* end else */ + clean_size += entry_ptr->size; + clean_index_ring_size[entry_ptr->ring] += entry_ptr->size; + } /* end else */ entry_ptr = entry_ptr->il_next; } /* end while */ - if((cache_ptr->index_len != len) || (cache_ptr->il_len != len) - || (cache_ptr->index_size != size) || (cache_ptr->il_size != size) - || (cache_ptr->clean_index_size != clean_size) - || (cache_ptr->dirty_index_size != dirty_size) - || (clean_size + dirty_size != size)) + if ((cache_ptr->index_len != len) || (cache_ptr->il_len != len) || (cache_ptr->index_size != size) || + (cache_ptr->il_size != size) || (cache_ptr->clean_index_size != clean_size) || + (cache_ptr->dirty_index_size != dirty_size) || (clean_size + dirty_size != size)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index, clean and dirty sizes for cache are invalid") - size = 0; + size = 0; clean_size = 0; dirty_size = 0; - for(i = 0; i < H5C_RING_NTYPES; i++) { - size += clean_index_ring_size[i] + dirty_index_ring_size[i]; - clean_size += clean_index_ring_size[i]; - dirty_size += dirty_index_ring_size[i]; + for (i = 0; i < H5C_RING_NTYPES; i++) { + size += clean_index_ring_size[i] + dirty_index_ring_size[i]; + clean_size += clean_index_ring_size[i]; + dirty_size += dirty_index_ring_size[i]; } /* end for */ - if((cache_ptr->index_size != size) - || (cache_ptr->clean_index_size != clean_size) - || (cache_ptr->dirty_index_size != dirty_size)) + if ((cache_ptr->index_size != size) || (cache_ptr->clean_index_size != clean_size) || + (cache_ptr->dirty_index_size != dirty_size)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index, clean and dirty sizes for cache are invalid") done: - if(ret_value != SUCCEED) + if (ret_value != SUCCEED) HDassert(0); FUNC_LEAVE_NOAPI(ret_value) } /* H5C_validate_index_list() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_get_entry_ptr_from_addr() @@ -1391,8 +1205,8 @@ done: herr_t H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr) { - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1404,7 +1218,7 @@ H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) + if (entry_ptr == NULL) /* the entry doesn't exist in the cache -- report this * and quit. */ @@ -1412,8 +1226,8 @@ H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr else { *entry_ptr_ptr = entry_ptr; - /* increment call counter */ - (cache_ptr->get_entry_ptr_from_addr_counter)++; + /* increment call counter */ + (cache_ptr->get_entry_ptr_from_addr_counter)++; } /* end else */ done: @@ -1421,7 +1235,6 @@ done: } /* H5C_get_entry_ptr_from_addr() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5C_get_serialization_in_progress * @@ -1449,7 +1262,6 @@ H5C_get_serialization_in_progress(const H5C_t *cache_ptr) } /* H5C_get_serialization_in_progress() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_cache_is_clean() @@ -1471,8 +1283,8 @@ H5C_get_serialization_in_progress(const H5C_t *cache_ptr) hbool_t H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring) { - H5C_ring_t ring = H5C_RING_USER; - hbool_t ret_value = TRUE; /* Return value */ + H5C_ring_t ring = H5C_RING_USER; + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1482,11 +1294,11 @@ H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring) HDassert(inner_ring >= H5C_RING_USER); HDassert(inner_ring <= H5C_RING_SB); - while(ring <= inner_ring) { - if(cache_ptr->dirty_index_ring_size[ring] > 0) + while (ring <= inner_ring) { + if (cache_ptr->dirty_index_ring_size[ring] > 0) HGOTO_DONE(FALSE) - ring++; + ring++; } /* end while */ done: @@ -1494,7 +1306,6 @@ done: } /* H5C_cache_is_clean() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_verify_entry_type() @@ -1522,12 +1333,11 @@ done: */ #ifndef NDEBUG herr_t -H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, - const H5C_class_t *expected_type, hbool_t *in_cache_ptr, - hbool_t *type_ok_ptr) +H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, const H5C_class_t *expected_type, hbool_t *in_cache_ptr, + hbool_t *type_ok_ptr) { - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1541,7 +1351,7 @@ H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) + if (entry_ptr == NULL) /* the entry doesn't exist in the cache -- report this * and quit. */ @@ -1549,14 +1359,13 @@ H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, else { *in_cache_ptr = TRUE; - if(entry_ptr->prefetched) - *type_ok_ptr = (expected_type->id == entry_ptr->prefetch_type_id); - else - *type_ok_ptr = (expected_type == entry_ptr->type); + if (entry_ptr->prefetched) + *type_ok_ptr = (expected_type->id == entry_ptr->prefetch_type_id); + else + *type_ok_ptr = (expected_type == entry_ptr->type); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_verify_entry_type() */ #endif /* NDEBUG */ - diff --git a/src/H5Cepoch.c b/src/H5Cepoch.c index e6a395f..6154773 100644 --- a/src/H5Cepoch.c +++ b/src/H5Cepoch.c @@ -22,24 +22,20 @@ *------------------------------------------------------------------------- */ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -54,42 +50,34 @@ * epochs so that they can be evicted from the cache. * ****************************************************************************/ -static herr_t H5C__epoch_marker_get_initial_load_size(void *udata_ptr, - size_t *image_len_ptr); -static herr_t H5C__epoch_marker_get_final_load_size(const void *image_ptr, - size_t image_len_ptr, void *udata_ptr, size_t *actual_len); -static htri_t H5C__epoch_marker_verify_chksum(const void *image_ptr, - size_t len, void *udata_ptr); -static void * H5C__epoch_marker_deserialize(const void * image_ptr, - size_t len, void * udata, hbool_t * dirty_ptr); -static herr_t H5C__epoch_marker_image_len(const void * thing, - size_t *image_len_ptr); -static herr_t H5C__epoch_marker_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, size_t *new_len_ptr, - unsigned *flags_ptr); -static herr_t H5C__epoch_marker_serialize(const H5F_t *f, - void * image_ptr, size_t len, void * thing); +static herr_t H5C__epoch_marker_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr); +static herr_t H5C__epoch_marker_get_final_load_size(const void *image_ptr, size_t image_len_ptr, + void *udata_ptr, size_t *actual_len); +static htri_t H5C__epoch_marker_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); +static void * H5C__epoch_marker_deserialize(const void *image_ptr, size_t len, void *udata, + hbool_t *dirty_ptr); +static herr_t H5C__epoch_marker_image_len(const void *thing, size_t *image_len_ptr); +static herr_t H5C__epoch_marker_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr_ptr, size_t *new_len_ptr, + unsigned *flags_ptr); +static herr_t H5C__epoch_marker_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); static herr_t H5C__epoch_marker_notify(H5C_notify_action_t action, void *thing); -static herr_t H5C__epoch_marker_free_icr(void * thing); -static herr_t H5C__epoch_marker_fsf_size(const void H5_ATTR_UNUSED * thing, - hsize_t H5_ATTR_UNUSED * fsf_size_ptr); - +static herr_t H5C__epoch_marker_free_icr(void *thing); +static herr_t H5C__epoch_marker_fsf_size(const void H5_ATTR_UNUSED *thing, + hsize_t H5_ATTR_UNUSED *fsf_size_ptr); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - const H5AC_class_t H5AC_EPOCH_MARKER[1] = {{ /* id = */ H5AC_EPOCH_MARKER_ID, /* name = */ "epoch marker", @@ -108,7 +96,6 @@ const H5AC_class_t H5AC_EPOCH_MARKER[1] = {{ /* refresh = */ NULL, }}; - /*************************************************************************** * Class functions for H5C__EPOCH_MAKER_TYPE: * @@ -118,124 +105,109 @@ const H5AC_class_t H5AC_EPOCH_MARKER[1] = {{ * ***************************************************************************/ - static herr_t -H5C__epoch_marker_get_initial_load_size(void H5_ATTR_UNUSED *udata_ptr, - size_t H5_ATTR_UNUSED *image_len_ptr) +H5C__epoch_marker_get_initial_load_size(void H5_ATTR_UNUSED *udata_ptr, size_t H5_ATTR_UNUSED *image_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_get_initial_load_size() */ - static herr_t -H5C__epoch_marker_get_final_load_size(const void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED image_len, void H5_ATTR_UNUSED *udata_ptr, - size_t H5_ATTR_UNUSED *actual_len) +H5C__epoch_marker_get_final_load_size(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED image_len, + void H5_ATTR_UNUSED *udata_ptr, size_t H5_ATTR_UNUSED *actual_len) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_final_get_load_size() */ - static htri_t H5C__epoch_marker_verify_chksum(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED len, - void H5_ATTR_UNUSED *udata_ptr) + void H5_ATTR_UNUSED *udata_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FALSE) } /* end H5C__epoch_marker_verify_chksum() */ - static void * -H5C__epoch_marker_deserialize(const void H5_ATTR_UNUSED * image_ptr, size_t H5_ATTR_UNUSED len, - void H5_ATTR_UNUSED * udata, hbool_t H5_ATTR_UNUSED * dirty_ptr) +H5C__epoch_marker_deserialize(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED len, + void H5_ATTR_UNUSED *udata, hbool_t H5_ATTR_UNUSED *dirty_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(NULL) } /* end H5C__epoch_marker_deserialize() */ - static herr_t -H5C__epoch_marker_image_len(const void H5_ATTR_UNUSED *thing, - size_t H5_ATTR_UNUSED *image_len_ptr) +H5C__epoch_marker_image_len(const void H5_ATTR_UNUSED *thing, size_t H5_ATTR_UNUSED *image_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_image_len() */ - static herr_t -H5C__epoch_marker_pre_serialize(H5F_t H5_ATTR_UNUSED *f, - void H5_ATTR_UNUSED *thing, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len, - haddr_t H5_ATTR_UNUSED *new_addr_ptr, size_t H5_ATTR_UNUSED *new_len_ptr, - unsigned H5_ATTR_UNUSED *flags_ptr) +H5C__epoch_marker_pre_serialize(H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *thing, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len, + haddr_t H5_ATTR_UNUSED *new_addr_ptr, size_t H5_ATTR_UNUSED *new_len_ptr, + unsigned H5_ATTR_UNUSED *flags_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_pre_serialize() */ - static herr_t H5C__epoch_marker_serialize(const H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) + size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_serialize() */ - static herr_t -H5C__epoch_marker_notify(H5C_notify_action_t H5_ATTR_UNUSED action, - void H5_ATTR_UNUSED * thing) +H5C__epoch_marker_notify(H5C_notify_action_t H5_ATTR_UNUSED action, void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_notify() */ - static herr_t -H5C__epoch_marker_free_icr(void H5_ATTR_UNUSED * thing) +H5C__epoch_marker_free_icr(void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_free_icr() */ - static herr_t -H5C__epoch_marker_fsf_size(const void H5_ATTR_UNUSED * thing, hsize_t H5_ATTR_UNUSED *fsf_size_ptr) +H5C__epoch_marker_fsf_size(const void H5_ATTR_UNUSED *thing, hsize_t H5_ATTR_UNUSED *fsf_size_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_fsf_size() */ - diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 9a6d667..ca08127 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -27,68 +27,64 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_PARALLEL -#define H5AC_FRIEND /*suppress error about including H5ACpkg */ -#include "H5ACpkg.h" /* Metadata cache */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#define H5AC_FRIEND /*suppress error about including H5ACpkg */ +#include "H5ACpkg.h" /* Metadata cache */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ #if H5C_DO_MEMORY_SANITY_CHECKS -#define H5C_IMAGE_EXTRA_SPACE 8 +#define H5C_IMAGE_EXTRA_SPACE 8 #define H5C_IMAGE_SANITY_VALUE "DeadBeef" #else /* H5C_DO_MEMORY_SANITY_CHECKS */ #define H5C_IMAGE_EXTRA_SPACE 0 #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ /* Cache image buffer components, on disk */ -#define H5C__MDCI_BLOCK_SIGNATURE "MDCI" -#define H5C__MDCI_BLOCK_SIGNATURE_LEN 4 -#define H5C__MDCI_BLOCK_VERSION_0 0 +#define H5C__MDCI_BLOCK_SIGNATURE "MDCI" +#define H5C__MDCI_BLOCK_SIGNATURE_LEN 4 +#define H5C__MDCI_BLOCK_VERSION_0 0 /* Metadata cache image header flags -- max 8 bits */ -#define H5C__MDCI_HEADER_HAVE_RESIZE_STATUS 0x01 +#define H5C__MDCI_HEADER_HAVE_RESIZE_STATUS 0x01 /* Metadata cache image entry flags -- max 8 bits */ -#define H5C__MDCI_ENTRY_DIRTY_FLAG 0x01 -#define H5C__MDCI_ENTRY_IN_LRU_FLAG 0x02 -#define H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG 0x04 -#define H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG 0x08 +#define H5C__MDCI_ENTRY_DIRTY_FLAG 0x01 +#define H5C__MDCI_ENTRY_IN_LRU_FLAG 0x02 +#define H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG 0x04 +#define H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG 0x08 /* Limits on flush dependency values, stored in 16-bit values on disk */ -#define H5C__MDCI_MAX_FD_CHILDREN USHRT_MAX -#define H5C__MDCI_MAX_FD_PARENTS USHRT_MAX +#define H5C__MDCI_MAX_FD_CHILDREN USHRT_MAX +#define H5C__MDCI_MAX_FD_PARENTS USHRT_MAX /* Values for image entry magic field */ -#define H5C_IMAGE_ENTRY_T_MAGIC 0x005CAC08 -#define H5C_IMAGE_ENTRY_T_BAD_MAGIC 0xBeefDead +#define H5C_IMAGE_ENTRY_T_MAGIC 0x005CAC08 +#define H5C_IMAGE_ENTRY_T_BAD_MAGIC 0xBeefDead /* Maximum ring allowed in image */ -#define H5C_MAX_RING_IN_IMAGE H5C_RING_MDFSM - +#define H5C_MAX_RING_IN_IMAGE H5C_RING_MDFSM /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -96,33 +92,27 @@ /* Helper routines */ static size_t H5C__cache_image_block_entry_header_size(const H5F_t *f); static size_t H5C__cache_image_block_header_size(const H5F_t *f); -static herr_t H5C__decode_cache_image_header(const H5F_t *f, - H5C_t *cache_ptr, const uint8_t **buf); -#ifndef NDEBUG /* only used in assertions */ -static herr_t H5C__decode_cache_image_entry(const H5F_t *f, - const H5C_t *cache_ptr, const uint8_t **buf, unsigned entry_num); +static herr_t H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf); +#ifndef NDEBUG /* only used in assertions */ +static herr_t H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint8_t **buf, + unsigned entry_num); #endif /* NDEBUG */ /* only used in assertions */ -static herr_t H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, - H5C_cache_entry_t *pf_entry_ptr, H5C_cache_entry_t **fd_children); -static herr_t H5C__encode_cache_image_header(const H5F_t *f, - const H5C_t *cache_ptr, uint8_t **buf); -static herr_t H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, - uint8_t **buf, unsigned entry_num); +static herr_t H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr, + H5C_cache_entry_t **fd_children); +static herr_t H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, uint8_t **buf); +static herr_t H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigned entry_num); static herr_t H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr); -static void H5C__prep_for_file_close__compute_fd_heights_real( - H5C_cache_entry_t *entry_ptr, uint32_t fd_height); +static void H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, + uint32_t fd_height); static herr_t H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr); -static herr_t H5C__prep_for_file_close__scan_entries(const H5F_t *f, - H5C_t *cache_ptr); +static herr_t H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr); static herr_t H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr); -static H5C_cache_entry_t *H5C__reconstruct_cache_entry(const H5F_t *f, - H5C_t *cache_ptr, const uint8_t **buf); -static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create); -static herr_t H5C__read_cache_image(H5F_t * f, H5C_t *cache_ptr); -static herr_t H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr); -static herr_t H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr); -static herr_t H5C__free_image_entries_array(H5C_t *cache_ptr); - +static H5C_cache_entry_t *H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf); +static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create); +static herr_t H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr); +static herr_t H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr); +static herr_t H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr); +static herr_t H5C__free_image_entries_array(H5C_t *cache_ptr); /*********************/ /* Package Variables */ @@ -131,17 +121,14 @@ static herr_t H5C__free_image_entries_array(H5C_t *cache_ptr); /* Declare a free list to manage H5C_cache_entry_t objects */ H5FL_DEFINE(H5C_cache_entry_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * * Function: H5C_cache_image_pending() @@ -162,7 +149,7 @@ H5FL_DEFINE(H5C_cache_entry_t); hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr) { - hbool_t ret_value = TRUE; /* Return value */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -175,7 +162,6 @@ H5C_cache_image_pending(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_cache_image_pending() */ - /*------------------------------------------------------------------------- * Function: H5C_cache_image_status() * @@ -199,9 +185,9 @@ H5C_cache_image_pending(const H5C_t *cache_ptr) *------------------------------------------------------------------------- */ herr_t -H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) +H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -214,13 +200,12 @@ H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) HDassert(load_ci_ptr); HDassert(write_ci_ptr); - *load_ci_ptr = cache_ptr->load_image || cache_ptr->image_loaded; + *load_ci_ptr = cache_ptr->load_image || cache_ptr->image_loaded; *write_ci_ptr = cache_ptr->image_ctl.generate_image; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_cache_image_status() */ - /*------------------------------------------------------------------------- * Function: H5C__construct_cache_image_buffer() * @@ -238,12 +223,12 @@ H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) *------------------------------------------------------------------------- */ static herr_t -H5C__construct_cache_image_buffer(H5F_t * f, H5C_t *cache_ptr) +H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) { - uint8_t * p; /* Pointer into image buffer */ - uint32_t chksum; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *p; /* Pointer into image buffer */ + uint32_t chksum; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -261,25 +246,26 @@ H5C__construct_cache_image_buffer(H5F_t * f, H5C_t *cache_ptr) HDassert(cache_ptr->image_data_len <= cache_ptr->image_len); /* Allocate the buffer in which to construct the cache image block */ - if(NULL == (cache_ptr->image_buffer = H5MM_malloc(cache_ptr->image_len + 1))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for cache image buffer") + if (NULL == (cache_ptr->image_buffer = H5MM_malloc(cache_ptr->image_len + 1))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for cache image buffer") /* Construct the cache image block header image */ p = (uint8_t *)cache_ptr->image_buffer; - if(H5C__encode_cache_image_header(f, cache_ptr, &p) < 0) + if (H5C__encode_cache_image_header(f, cache_ptr, &p) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTENCODE, FAIL, "header image construction failed") HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) < cache_ptr->image_data_len); /* Construct the cache entry images */ - for(u = 0; u < cache_ptr->num_entries_in_image; u++) - if(H5C__encode_cache_image_entry(f, cache_ptr, &p, u) < 0) + for (u = 0; u < cache_ptr->num_entries_in_image; u++) + if (H5C__encode_cache_image_entry(f, cache_ptr, &p, u) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTENCODE, FAIL, "entry image construction failed") HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) < cache_ptr->image_data_len); /* Construct the adaptive resize status image -- not yet */ /* Compute the checksum and encode */ - chksum = H5_checksum_metadata(cache_ptr->image_buffer, (size_t)(cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM), 0); + chksum = H5_checksum_metadata(cache_ptr->image_buffer, + (size_t)(cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM), 0); UINT32ENCODE(p, chksum); HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) == cache_ptr->image_data_len); HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) <= cache_ptr->image_len); @@ -289,92 +275,99 @@ H5C__construct_cache_image_buffer(H5F_t * f, H5C_t *cache_ptr) * and comparing the result with the original data. */ { - uint32_t old_chksum; - const uint8_t * q; - H5C_t * fake_cache_ptr = NULL; - unsigned v; - herr_t status; /* Status from decoding */ + uint32_t old_chksum; + const uint8_t *q; + H5C_t * fake_cache_ptr = NULL; + unsigned v; + herr_t status; /* Status from decoding */ - fake_cache_ptr = (H5C_t *)H5MM_malloc(sizeof(H5C_t)); + fake_cache_ptr = (H5C_t *)H5MM_malloc(sizeof(H5C_t)); HDassert(fake_cache_ptr); fake_cache_ptr->magic = H5C__H5C_T_MAGIC; - /* needed for sanity checks */ - fake_cache_ptr->image_len = cache_ptr->image_len; - q = (const uint8_t *)cache_ptr->image_buffer; - status = H5C__decode_cache_image_header(f, fake_cache_ptr, &q); + /* needed for sanity checks */ + fake_cache_ptr->image_len = cache_ptr->image_len; + q = (const uint8_t *)cache_ptr->image_buffer; + status = H5C__decode_cache_image_header(f, fake_cache_ptr, &q); HDassert(status >= 0); HDassert(NULL != p); HDassert(fake_cache_ptr->num_entries_in_image == cache_ptr->num_entries_in_image); - fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_malloc(sizeof(H5C_image_entry_t) * - (size_t)(fake_cache_ptr->num_entries_in_image + 1)); - HDassert(fake_cache_ptr->image_entries); + fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_malloc( + sizeof(H5C_image_entry_t) * (size_t)(fake_cache_ptr->num_entries_in_image + 1)); + HDassert(fake_cache_ptr->image_entries); - for(u = 0; u < fake_cache_ptr->num_entries_in_image; u++) { - (fake_cache_ptr->image_entries)[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; + for (u = 0; u < fake_cache_ptr->num_entries_in_image; u++) { + (fake_cache_ptr->image_entries)[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; (fake_cache_ptr->image_entries)[u].image_ptr = NULL; - /* touch up f->shared->cache to satisfy sanity checks... */ + /* touch up f->shared->cache to satisfy sanity checks... */ f->shared->cache = fake_cache_ptr; - status = H5C__decode_cache_image_entry(f, fake_cache_ptr, &q, u); - HDassert(status >= 0); + status = H5C__decode_cache_image_entry(f, fake_cache_ptr, &q, u); + HDassert(status >= 0); - /* ...and then return f->shared->cache to its correct value */ + /* ...and then return f->shared->cache to its correct value */ f->shared->cache = cache_ptr; - /* verify expected contents */ - HDassert((cache_ptr->image_entries)[u].addr == (fake_cache_ptr->image_entries)[u].addr); - HDassert((cache_ptr->image_entries)[u].size == (fake_cache_ptr->image_entries)[u].size); - HDassert((cache_ptr->image_entries)[u].type_id == (fake_cache_ptr->image_entries)[u].type_id); - HDassert((cache_ptr->image_entries)[u].lru_rank == (fake_cache_ptr->image_entries)[u].lru_rank); - HDassert((cache_ptr->image_entries)[u].is_dirty == (fake_cache_ptr->image_entries)[u].is_dirty); - /* don't check image_fd_height as it is not stored in + /* verify expected contents */ + HDassert((cache_ptr->image_entries)[u].addr == (fake_cache_ptr->image_entries)[u].addr); + HDassert((cache_ptr->image_entries)[u].size == (fake_cache_ptr->image_entries)[u].size); + HDassert((cache_ptr->image_entries)[u].type_id == (fake_cache_ptr->image_entries)[u].type_id); + HDassert((cache_ptr->image_entries)[u].lru_rank == (fake_cache_ptr->image_entries)[u].lru_rank); + HDassert((cache_ptr->image_entries)[u].is_dirty == (fake_cache_ptr->image_entries)[u].is_dirty); + /* don't check image_fd_height as it is not stored in * the metadata cache image block. */ - HDassert((cache_ptr->image_entries)[u].fd_child_count == (fake_cache_ptr->image_entries)[u].fd_child_count); - HDassert((cache_ptr->image_entries)[u].fd_dirty_child_count == (fake_cache_ptr->image_entries)[u].fd_dirty_child_count); - HDassert((cache_ptr->image_entries)[u].fd_parent_count == (fake_cache_ptr->image_entries)[u].fd_parent_count); - - for(v = 0; v < (cache_ptr->image_entries)[u].fd_parent_count; v++) - HDassert((cache_ptr->image_entries)[u].fd_parent_addrs[v] == (fake_cache_ptr->image_entries)[u].fd_parent_addrs[v]); - - /* free the fd_parent_addrs array if it exists */ - if((fake_cache_ptr->image_entries)[u].fd_parent_addrs) { - HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count > 0); - (fake_cache_ptr->image_entries)[u].fd_parent_addrs = (haddr_t *)H5MM_xfree((fake_cache_ptr->image_entries)[u].fd_parent_addrs); - (fake_cache_ptr->image_entries)[u].fd_parent_count = 0; - } /* end if */ + HDassert((cache_ptr->image_entries)[u].fd_child_count == + (fake_cache_ptr->image_entries)[u].fd_child_count); + HDassert((cache_ptr->image_entries)[u].fd_dirty_child_count == + (fake_cache_ptr->image_entries)[u].fd_dirty_child_count); + HDassert((cache_ptr->image_entries)[u].fd_parent_count == + (fake_cache_ptr->image_entries)[u].fd_parent_count); + + for (v = 0; v < (cache_ptr->image_entries)[u].fd_parent_count; v++) + HDassert((cache_ptr->image_entries)[u].fd_parent_addrs[v] == + (fake_cache_ptr->image_entries)[u].fd_parent_addrs[v]); + + /* free the fd_parent_addrs array if it exists */ + if ((fake_cache_ptr->image_entries)[u].fd_parent_addrs) { + HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count > 0); + (fake_cache_ptr->image_entries)[u].fd_parent_addrs = + (haddr_t *)H5MM_xfree((fake_cache_ptr->image_entries)[u].fd_parent_addrs); + (fake_cache_ptr->image_entries)[u].fd_parent_count = 0; + } /* end if */ else - HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count == 0); + HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count == 0); - HDassert((cache_ptr->image_entries)[u].image_ptr); + HDassert((cache_ptr->image_entries)[u].image_ptr); HDassert((fake_cache_ptr->image_entries)[u].image_ptr); HDassert(!HDmemcmp((cache_ptr->image_entries)[u].image_ptr, (fake_cache_ptr->image_entries)[u].image_ptr, (cache_ptr->image_entries)[u].size)); - (fake_cache_ptr->image_entries)[u].image_ptr = H5MM_xfree((fake_cache_ptr->image_entries)[u].image_ptr); - } /* end for */ + (fake_cache_ptr->image_entries)[u].image_ptr = + H5MM_xfree((fake_cache_ptr->image_entries)[u].image_ptr); + } /* end for */ - HDassert((size_t)(q - (const uint8_t *)cache_ptr->image_buffer) == cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM); + HDassert((size_t)(q - (const uint8_t *)cache_ptr->image_buffer) == + cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM); /* compute the checksum */ old_chksum = chksum; - chksum = H5_checksum_metadata(cache_ptr->image_buffer, (size_t)(cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM), 0); - HDassert(chksum == old_chksum); + chksum = H5_checksum_metadata(cache_ptr->image_buffer, + (size_t)(cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM), 0); + HDassert(chksum == old_chksum); - fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(fake_cache_ptr->image_entries); - fake_cache_ptr = (H5C_t *)H5MM_xfree(fake_cache_ptr); - } /* end block */ + fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(fake_cache_ptr->image_entries); + fake_cache_ptr = (H5C_t *)H5MM_xfree(fake_cache_ptr); + } /* end block */ #endif /* NDEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__construct_cache_image_buffer() */ - /*------------------------------------------------------------------------- * Function: H5C__generate_cache_image() * @@ -391,7 +384,7 @@ done: herr_t H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -403,16 +396,16 @@ H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Construct cache image */ - if(H5C__construct_cache_image_buffer(f, cache_ptr) < 0) + if (H5C__construct_cache_image_buffer(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't create metadata cache image") /* Free image entries array */ - if(H5C__free_image_entries_array(cache_ptr) < 0) + if (H5C__free_image_entries_array(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't free image entries array") /* Write cache image block if so configured */ - if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) { - if(H5C__write_cache_image(f, cache_ptr) < 0) + if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) { + if (H5C__write_cache_image(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't write metadata cache image block to file") H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr); @@ -426,7 +419,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__generate_cache_image() */ - /*------------------------------------------------------------------------- * Function: H5C__deserialize_prefetched_entry() * @@ -464,29 +456,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, - H5C_cache_entry_t **entry_ptr_ptr, const H5C_class_t *type, - haddr_t addr, void *udata) +H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t **entry_ptr_ptr, + const H5C_class_t *type, haddr_t addr, void *udata) { - hbool_t dirty = FALSE; /* Flag indicating whether thing was - * dirtied during deserialize - */ - size_t len; /* Size of image in file */ - void * thing = NULL; /* Pointer to thing loaded */ - H5C_cache_entry_t * pf_entry_ptr; /* pointer to the prefetched entry */ - /* supplied in *entry_ptr_ptr. */ - H5C_cache_entry_t * ds_entry_ptr; /* Alias for thing loaded, as cache - * entry - */ - H5C_cache_entry_t** fd_children = NULL; /* Pointer to a dynamically */ - /* allocated array of pointers to */ - /* the flush dependency children of */ - /* the prefetched entry, or NULL if */ - /* that array does not exist. */ - unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG); - int i; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t dirty = FALSE; /* Flag indicating whether thing was + * dirtied during deserialize + */ + size_t len; /* Size of image in file */ + void * thing = NULL; /* Pointer to thing loaded */ + H5C_cache_entry_t *pf_entry_ptr; /* pointer to the prefetched entry */ + /* supplied in *entry_ptr_ptr. */ + H5C_cache_entry_t *ds_entry_ptr; /* Alias for thing loaded, as cache + * entry + */ + H5C_cache_entry_t **fd_children = NULL; /* Pointer to a dynamically */ + /* allocated array of pointers to */ + /* the flush dependency children of */ + /* the prefetched entry, or NULL if */ + /* that array does not exist. */ + unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); + int i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -517,8 +507,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, /* Can't see how skip reads could be usefully combined with * either the speculative read flag. Hence disallow. */ - HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && - (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); + HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); HDassert(H5F_addr_defined(addr)); HDassert(type->get_initial_load_size); HDassert(type->deserialize); @@ -528,7 +517,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * the deserialized entry if appropriate. */ HDassert(pf_entry_ptr->fd_parent_count == pf_entry_ptr->flush_dep_nparents); - for(i = (int)(pf_entry_ptr->fd_parent_count) - 1; i >= 0; i--) { + for (i = (int)(pf_entry_ptr->fd_parent_count) - 1; i >= 0; i--) { HDassert(pf_entry_ptr->flush_dep_parent); HDassert(pf_entry_ptr->flush_dep_parent[i]); HDassert(pf_entry_ptr->flush_dep_parent[i]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -536,7 +525,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, HDassert(pf_entry_ptr->fd_parent_addrs); HDassert(pf_entry_ptr->flush_dep_parent[i]->addr == pf_entry_ptr->fd_parent_addrs[i]); - if(H5C_destroy_flush_dependency(pf_entry_ptr->flush_dep_parent[i], pf_entry_ptr) < 0) + if (H5C_destroy_flush_dependency(pf_entry_ptr->flush_dep_parent[i], pf_entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry parent flush dependency") pf_entry_ptr->fd_parent_addrs[i] = HADDR_UNDEF; @@ -553,12 +542,14 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * pointers to the flush dependency children of *pf_enty_ptr for later * use. */ - if(pf_entry_ptr->fd_child_count > 0) { - if(NULL == (fd_children = (H5C_cache_entry_t **)H5MM_calloc(sizeof(H5C_cache_entry_t **) * (size_t)(pf_entry_ptr->fd_child_count + 1)))) + if (pf_entry_ptr->fd_child_count > 0) { + if (NULL == (fd_children = (H5C_cache_entry_t **)H5MM_calloc( + sizeof(H5C_cache_entry_t **) * (size_t)(pf_entry_ptr->fd_child_count + 1)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd child ptr array") - if(H5C__destroy_pf_entry_child_flush_deps(cache_ptr, pf_entry_ptr, fd_children) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry child flush dependency(s).") + if (H5C__destroy_pf_entry_child_flush_deps(cache_ptr, pf_entry_ptr, fd_children) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "can't destroy pf entry child flush dependency(s).") } /* end if */ /* Since the size of the on disk image is known exactly, there is @@ -572,7 +563,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, /* Deserialize the prefetched on-disk image of the entry into the * native memory form */ - if(NULL == (thing = type->deserialize(pf_entry_ptr->image_ptr, len, udata, &dirty))) + if (NULL == (thing = type->deserialize(pf_entry_ptr->image_ptr, len, udata, &dirty))) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't deserialize image") ds_entry_ptr = (H5C_cache_entry_t *)thing; @@ -602,81 +593,81 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * hence the value assigned to ds_entry_ptr->is_dirty below. */ - HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6) ); + HDassert((dirty == FALSE) || (type->id == 5 || type->id == 6)); - ds_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - ds_entry_ptr->cache_ptr = f->shared->cache; - ds_entry_ptr->addr = addr; - ds_entry_ptr->size = len; + ds_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + ds_entry_ptr->cache_ptr = f->shared->cache; + ds_entry_ptr->addr = addr; + ds_entry_ptr->size = len; HDassert(ds_entry_ptr->size < H5C_MAX_ENTRY_SIZE); - ds_entry_ptr->image_ptr = pf_entry_ptr->image_ptr; - ds_entry_ptr->image_up_to_date = !dirty; - ds_entry_ptr->type = type; - ds_entry_ptr->is_dirty = dirty | pf_entry_ptr->is_dirty; - ds_entry_ptr->dirtied = FALSE; - ds_entry_ptr->is_protected = FALSE; - ds_entry_ptr->is_read_only = FALSE; - ds_entry_ptr->ro_ref_count = 0; - ds_entry_ptr->is_pinned = FALSE; - ds_entry_ptr->in_slist = FALSE; - ds_entry_ptr->flush_marker = FALSE; + ds_entry_ptr->image_ptr = pf_entry_ptr->image_ptr; + ds_entry_ptr->image_up_to_date = !dirty; + ds_entry_ptr->type = type; + ds_entry_ptr->is_dirty = dirty | pf_entry_ptr->is_dirty; + ds_entry_ptr->dirtied = FALSE; + ds_entry_ptr->is_protected = FALSE; + ds_entry_ptr->is_read_only = FALSE; + ds_entry_ptr->ro_ref_count = 0; + ds_entry_ptr->is_pinned = FALSE; + ds_entry_ptr->in_slist = FALSE; + ds_entry_ptr->flush_marker = FALSE; #ifdef H5_HAVE_PARALLEL - ds_entry_ptr->clear_on_unprotect = FALSE; - ds_entry_ptr->flush_immediately = FALSE; - ds_entry_ptr->coll_access = FALSE; + ds_entry_ptr->clear_on_unprotect = FALSE; + ds_entry_ptr->flush_immediately = FALSE; + ds_entry_ptr->coll_access = FALSE; #endif /* H5_HAVE_PARALLEL */ - ds_entry_ptr->flush_in_progress = FALSE; - ds_entry_ptr->destroy_in_progress = FALSE; + ds_entry_ptr->flush_in_progress = FALSE; + ds_entry_ptr->destroy_in_progress = FALSE; - ds_entry_ptr->ring = pf_entry_ptr->ring; + ds_entry_ptr->ring = pf_entry_ptr->ring; /* Initialize flush dependency height fields */ - ds_entry_ptr->flush_dep_parent = NULL; - ds_entry_ptr->flush_dep_nparents = 0; - ds_entry_ptr->flush_dep_parent_nalloc = 0; - ds_entry_ptr->flush_dep_nchildren = 0; - ds_entry_ptr->flush_dep_ndirty_children = 0; - ds_entry_ptr->flush_dep_nunser_children = 0; + ds_entry_ptr->flush_dep_parent = NULL; + ds_entry_ptr->flush_dep_nparents = 0; + ds_entry_ptr->flush_dep_parent_nalloc = 0; + ds_entry_ptr->flush_dep_nchildren = 0; + ds_entry_ptr->flush_dep_ndirty_children = 0; + ds_entry_ptr->flush_dep_nunser_children = 0; /* Initialize fields supporting the hash table: */ - ds_entry_ptr->ht_next = NULL; - ds_entry_ptr->ht_prev = NULL; - ds_entry_ptr->il_next = NULL; - ds_entry_ptr->il_prev = NULL; + ds_entry_ptr->ht_next = NULL; + ds_entry_ptr->ht_prev = NULL; + ds_entry_ptr->il_next = NULL; + ds_entry_ptr->il_prev = NULL; /* Initialize fields supporting replacement policies: */ - ds_entry_ptr->next = NULL; - ds_entry_ptr->prev = NULL; + ds_entry_ptr->next = NULL; + ds_entry_ptr->prev = NULL; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - ds_entry_ptr->aux_next = NULL; - ds_entry_ptr->aux_prev = NULL; + ds_entry_ptr->aux_next = NULL; + ds_entry_ptr->aux_prev = NULL; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL - pf_entry_ptr->coll_next = NULL; - pf_entry_ptr->coll_prev = NULL; + pf_entry_ptr->coll_next = NULL; + pf_entry_ptr->coll_prev = NULL; #endif /* H5_HAVE_PARALLEL */ /* Initialize cache image related fields */ - ds_entry_ptr->include_in_image = FALSE; - ds_entry_ptr->lru_rank = 0; - ds_entry_ptr->image_dirty = FALSE; - ds_entry_ptr->fd_parent_count = 0; - ds_entry_ptr->fd_parent_addrs = NULL; - ds_entry_ptr->fd_child_count = pf_entry_ptr->fd_child_count; - ds_entry_ptr->fd_dirty_child_count = 0; - ds_entry_ptr->image_fd_height = 0; - ds_entry_ptr->prefetched = FALSE; - ds_entry_ptr->prefetch_type_id = 0; - ds_entry_ptr->age = 0; - ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; -#ifndef NDEBUG /* debugging field */ - ds_entry_ptr->serialization_count = 0; + ds_entry_ptr->include_in_image = FALSE; + ds_entry_ptr->lru_rank = 0; + ds_entry_ptr->image_dirty = FALSE; + ds_entry_ptr->fd_parent_count = 0; + ds_entry_ptr->fd_parent_addrs = NULL; + ds_entry_ptr->fd_child_count = pf_entry_ptr->fd_child_count; + ds_entry_ptr->fd_dirty_child_count = 0; + ds_entry_ptr->image_fd_height = 0; + ds_entry_ptr->prefetched = FALSE; + ds_entry_ptr->prefetch_type_id = 0; + ds_entry_ptr->age = 0; + ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; +#ifndef NDEBUG /* debugging field */ + ds_entry_ptr->serialization_count = 0; #endif /* NDEBUG */ H5C__RESET_CACHE_ENTRY_STATS(ds_entry_ptr); /* Apply to to the newly deserialized entry */ - if(H5C__tag_entry(cache_ptr, ds_entry_ptr) < 0) + if (H5C__tag_entry(cache_ptr, ds_entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") /* We have successfully deserialized the prefetched entry. @@ -700,12 +691,12 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * and H5C__FLUSH_CLEAR_ONLY_FLAG flags set. */ pf_entry_ptr->image_ptr = NULL; - if(pf_entry_ptr->is_dirty) { + if (pf_entry_ptr->is_dirty) { HDassert(pf_entry_ptr->in_slist); flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; } /* end if */ - if(H5C__flush_single_entry(f, pf_entry_ptr, flush_flags) < 0) + if (H5C__flush_single_entry(f, pf_entry_ptr, flush_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't expunge prefetched entry") #ifndef NDEGUG /* verify deletion */ @@ -718,7 +709,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C__INSERT_IN_INDEX(cache_ptr, ds_entry_ptr, FAIL) HDassert(!ds_entry_ptr->in_slist); - if(ds_entry_ptr->is_dirty) + if (ds_entry_ptr->is_dirty) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, ds_entry_ptr, FAIL) H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, ds_entry_ptr, FAIL) @@ -728,8 +719,8 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * send an "after load" notice now that the deserialized entry is fully * integrated into the cache. */ - if(ds_entry_ptr->type->notify && - (ds_entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, ds_entry_ptr) < 0) + if (ds_entry_ptr->type->notify && + (ds_entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, ds_entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry loaded into cache") /* Restore flush dependencies with the flush dependency children of @@ -738,10 +729,10 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * then unprotect it afterwards. */ i = 0; - if(fd_children != NULL) { + if (fd_children != NULL) { H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, ds_entry_ptr, FAIL) ds_entry_ptr->is_protected = TRUE; - while(fd_children[i] != NULL) { + while (fd_children[i] != NULL) { /* Sanity checks */ HDassert((fd_children[i])->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert((fd_children[i])->prefetched); @@ -750,13 +741,13 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, #ifndef NDEBUG { - int j; + int j; hbool_t found; - j = 0; + j = 0; found = FALSE; - while((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) { - if((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr) + while ((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) { + if ((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr) found = TRUE; j++; @@ -765,7 +756,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, } #endif /* NDEBUG */ - if(H5C_create_flush_dependency(ds_entry_ptr, fd_children[i]) < 0) + if (H5C_create_flush_dependency(ds_entry_ptr, fd_children[i]) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore child flush dependency") i++; @@ -783,18 +774,17 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, *entry_ptr_ptr = ds_entry_ptr; done: - if(fd_children) + if (fd_children) fd_children = (H5C_cache_entry_t **)H5MM_xfree((void *)fd_children); /* Release resources on error */ - if(FAIL == ret_value) - if(thing && type->free_icr(thing) < 0) + if (FAIL == ret_value) + if (thing && type->free_icr(thing) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed") FUNC_LEAVE_NOAPI(ret_value) } /* H5C__deserialize_prefetched_entry() */ - /*------------------------------------------------------------------------- * Function: H5C__free_image_entries_array * @@ -813,7 +803,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__free_image_entries_array(H5C_t * cache_ptr) +H5C__free_image_entries_array(H5C_t *cache_ptr) { FUNC_ENTER_STATIC_NOERR @@ -825,44 +815,43 @@ H5C__free_image_entries_array(H5C_t * cache_ptr) HDassert(cache_ptr->index_len == 0); /* Check for entries to free */ - if(cache_ptr->image_entries != NULL) { - unsigned u; /* Local index variable */ + if (cache_ptr->image_entries != NULL) { + unsigned u; /* Local index variable */ - for(u = 0; u < cache_ptr->num_entries_in_image; u++) { - H5C_image_entry_t *ie_ptr; /* Image entry to release */ + for (u = 0; u < cache_ptr->num_entries_in_image; u++) { + H5C_image_entry_t *ie_ptr; /* Image entry to release */ /* Get pointer to image entry */ - ie_ptr = &((cache_ptr->image_entries)[u]); + ie_ptr = &((cache_ptr->image_entries)[u]); /* Sanity checks */ - HDassert(ie_ptr); + HDassert(ie_ptr); HDassert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); - HDassert(ie_ptr->image_ptr); + HDassert(ie_ptr->image_ptr); - /* Free the parent addrs array if appropriate */ - if(ie_ptr->fd_parent_addrs) { - HDassert(ie_ptr->fd_parent_count > 0); + /* Free the parent addrs array if appropriate */ + if (ie_ptr->fd_parent_addrs) { + HDassert(ie_ptr->fd_parent_count > 0); - ie_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(ie_ptr->fd_parent_addrs); + ie_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(ie_ptr->fd_parent_addrs); } /* end if */ else - HDassert(ie_ptr->fd_parent_count == 0); + HDassert(ie_ptr->fd_parent_count == 0); /* Free the image */ ie_ptr->image_ptr = H5MM_xfree(ie_ptr->image_ptr); - /* Set magic field to bad magic so we can detect freed entries */ - ie_ptr->magic = H5C_IMAGE_ENTRY_T_BAD_MAGIC; - } /* end for */ + /* Set magic field to bad magic so we can detect freed entries */ + ie_ptr->magic = H5C_IMAGE_ENTRY_T_BAD_MAGIC; + } /* end for */ - /* Free the image entries array */ - cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(cache_ptr->image_entries); + /* Free the image entries array */ + cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(cache_ptr->image_entries); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C__free_image_entries_array() */ - /*------------------------------------------------------------------------- * Function: H5C_force_cache_image_load() * @@ -887,7 +876,7 @@ herr_t H5C_force_cache_image_load(H5F_t *f) { H5C_t *cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -900,9 +889,9 @@ H5C_force_cache_image_load(H5F_t *f) HDassert(cache_ptr->load_image); /* Load the cache image, if requested */ - if(cache_ptr->load_image) { + if (cache_ptr->load_image) { cache_ptr->load_image = FALSE; - if(H5C__load_cache_image(f) < 0) + if (H5C__load_cache_image(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") } /* end if */ @@ -910,7 +899,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_force_cache_image_load() */ - /*------------------------------------------------------------------------- * Function: H5C_get_cache_image_config * @@ -926,16 +914,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_image_config(const H5C_t * cache_ptr, - H5C_cache_image_ctl_t *config_ptr) +H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry") - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad config_ptr on entry") *config_ptr = cache_ptr->image_ctl; @@ -944,7 +931,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_image_config() */ - /*------------------------------------------------------------------------- * Function: H5C_image_stats * @@ -959,66 +945,59 @@ done: */ herr_t #if H5C_COLLECT_CACHE_STATS -H5C_image_stats(H5C_t * cache_ptr, hbool_t print_header) -#else /* H5C_COLLECT_CACHE_STATS */ -H5C_image_stats(H5C_t * cache_ptr, hbool_t H5_ATTR_UNUSED print_header) +H5C_image_stats(H5C_t *cache_ptr, hbool_t print_header) +#else /* H5C_COLLECT_CACHE_STATS */ +H5C_image_stats(H5C_t *cache_ptr, hbool_t H5_ATTR_UNUSED print_header) #endif /* H5C_COLLECT_CACHE_STATS */ { #if H5C_COLLECT_CACHE_STATS - int i; - int64_t total_hits = 0; - int64_t total_misses = 0; - double hit_rate; - double prefetch_use_rate; -#endif /* H5C_COLLECT_CACHE_STATS */ - herr_t ret_value = SUCCEED; /* Return value */ + int i; + int64_t total_hits = 0; + int64_t total_misses = 0; + double hit_rate; + double prefetch_use_rate; +#endif /* H5C_COLLECT_CACHE_STATS */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(!cache_ptr || cache_ptr->magic != H5C__H5C_T_MAGIC) + if (!cache_ptr || cache_ptr->magic != H5C__H5C_T_MAGIC) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") #if H5C_COLLECT_CACHE_STATS - for(i = 0; i <= cache_ptr->max_type_id; i++) { - total_hits += cache_ptr->hits[i]; - total_misses += cache_ptr->misses[i]; + for (i = 0; i <= cache_ptr->max_type_id; i++) { + total_hits += cache_ptr->hits[i]; + total_misses += cache_ptr->misses[i]; } /* end for */ - if((total_hits > 0) || (total_misses > 0)) + if ((total_hits > 0) || (total_misses > 0)) hit_rate = (double)100.0f * ((double)(total_hits)) / ((double)(total_hits + total_misses)); else hit_rate = 0.0f; - if(cache_ptr->prefetches > 0) - prefetch_use_rate = (double)100.0f * ((double)(cache_ptr->prefetch_hits)) / - ((double)(cache_ptr->prefetches)); + if (cache_ptr->prefetches > 0) + prefetch_use_rate = + (double)100.0f * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); else prefetch_use_rate = 0.0f; - if(print_header) { - HDfprintf(stdout, - "\nhit prefetches prefetch image pf hit\n"); - HDfprintf(stdout, - "rate: total: dirty: hits: flshs: evct: size: rate:\n"); + if (print_header) { + HDfprintf(stdout, "\nhit prefetches prefetch image pf hit\n"); + HDfprintf(stdout, "rate: total: dirty: hits: flshs: evct: size: rate:\n"); } /* end if */ - HDfprintf(stdout, - "%3.1lf %5lld %5lld %5lld %5lld %5lld %5lld %3.1lf\n", - hit_rate, - (long long)(cache_ptr->prefetches), - (long long)(cache_ptr->dirty_prefetches), - (long long)(cache_ptr->prefetch_hits), - (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), - (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID]), - (long long)(cache_ptr->last_image_size), - prefetch_use_rate); + HDfprintf(stdout, "%3.1lf %5lld %5lld %5lld %5lld %5lld %5lld %3.1lf\n", hit_rate, + (long long)(cache_ptr->prefetches), (long long)(cache_ptr->dirty_prefetches), + (long long)(cache_ptr->prefetch_hits), + (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), + (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID]), + (long long)(cache_ptr->last_image_size), prefetch_use_rate); #endif /* H5C_COLLECT_CACHE_STATS */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_image_stats() */ - /*------------------------------------------------------------------------- * Function: H5C__read_cache_image * @@ -1035,7 +1014,7 @@ done: static herr_t H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1047,71 +1026,64 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) HDassert(cache_ptr->image_buffer); #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; - int mpi_result; + { + H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; + int mpi_result; - if ( ( NULL == aux_ptr ) || ( aux_ptr->mpi_rank == 0 ) ) { + if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { - HDassert((NULL == aux_ptr) || - (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); + HDassert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); #endif /* H5_HAVE_PARALLEL */ - /* Read the buffer (if serial access, or rank 0 of parallel access) */ - - /* No need to set the page buffer hints here, as if paged - * allocation is in use, we know that the cache image was allocated - * directly from the free space manager, and thus either doesn't - * cross page boundaries, or is page aligned. Between this, - * and the fact that the cache image is never read speculatively, - * the page buffer should never request hints in this context. - * - * If for some reason it does, the NULL curr_io_type will trigger - * an assertion failure. - * - * Note that we will have to revisit this if we ever use - * cache_ptr->curr_io_type for something other than sanity - * checking - * JRM -- 3/30/20 - */ - if(H5F_block_read(f, H5FD_MEM_SUPER, cache_ptr->image_addr, - cache_ptr->image_len, cache_ptr->image_buffer) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read metadata cache image block") + /* Read the buffer (if serial access, or rank 0 of parallel access) */ + + /* No need to set the page buffer hints here, as if paged + * allocation is in use, we know that the cache image was allocated + * directly from the free space manager, and thus either doesn't + * cross page boundaries, or is page aligned. Between this, + * and the fact that the cache image is never read speculatively, + * the page buffer should never request hints in this context. + * + * If for some reason it does, the NULL curr_io_type will trigger + * an assertion failure. + * + * Note that we will have to revisit this if we ever use + * cache_ptr->curr_io_type for something other than sanity + * checking + * JRM -- 3/30/20 + */ + if (H5F_block_read(f, H5FD_MEM_SUPER, cache_ptr->image_addr, cache_ptr->image_len, + cache_ptr->image_buffer) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read metadata cache image block") - H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) + H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) #ifdef H5_HAVE_PARALLEL - if ( aux_ptr ) { + if (aux_ptr) { - /* Broadcast cache image */ - if ( MPI_SUCCESS != - (mpi_result = MPI_Bcast(cache_ptr->image_buffer, - (int)cache_ptr->image_len, MPI_BYTE, - 0, aux_ptr->mpi_comm)) ) + /* Broadcast cache image */ + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, + MPI_BYTE, 0, aux_ptr->mpi_comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) + HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - } /* end if */ - } /* end if */ - else if ( aux_ptr ) { - - /* Retrieve the contents of the metadata cache image from process 0 */ - if ( MPI_SUCCESS != - (mpi_result = MPI_Bcast(cache_ptr->image_buffer, - (int)cache_ptr->image_len, MPI_BYTE, - 0, aux_ptr->mpi_comm)) ) - - HMPI_GOTO_ERROR(FAIL, "can't receive cache image MPI_Bcast", \ - mpi_result) - } /* end else-if */ -} /* end block */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ + } /* end if */ + else if (aux_ptr) { + + /* Retrieve the contents of the metadata cache image from process 0 */ + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, + MPI_BYTE, 0, aux_ptr->mpi_comm))) + + HMPI_GOTO_ERROR(FAIL, "can't receive cache image MPI_Bcast", mpi_result) + } /* end else-if */ + } /* end block */ +#endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__read_cache_image() */ - /*------------------------------------------------------------------------- * Function: H5C__load_cache_image * @@ -1132,8 +1104,8 @@ done: herr_t H5C__load_cache_image(H5F_t *f) { - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1153,21 +1125,21 @@ H5C__load_cache_image(H5F_t *f) * no image exists, and that the load operation should be skipped * silently. */ - if(H5F_addr_defined(cache_ptr->image_addr)) { + if (H5F_addr_defined(cache_ptr->image_addr)) { /* Sanity checks */ HDassert(cache_ptr->image_len > 0); HDassert(cache_ptr->image_buffer == NULL); /* Allocate space for the image */ - if(NULL == (cache_ptr->image_buffer = H5MM_malloc(cache_ptr->image_len + 1))) + if (NULL == (cache_ptr->image_buffer = H5MM_malloc(cache_ptr->image_len + 1))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for cache image buffer") /* Load the image from file */ - if(H5C__read_cache_image(f, cache_ptr) < 0) + if (H5C__read_cache_image(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read metadata cache image block") /* Reconstruct cache contents, from image */ - if(H5C__reconstruct_cache_contents(f, cache_ptr) < 0) + if (H5C__reconstruct_cache_contents(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDECODE, FAIL, "Can't reconstruct cache contents from image block") /* Free the image buffer */ @@ -1182,21 +1154,21 @@ H5C__load_cache_image(H5F_t *f) } /* end if */ /* If directed, free the on disk metadata cache image */ - if(cache_ptr->delete_image) { - if(H5F__super_ext_remove_msg(f, H5O_MDCI_MSG_ID) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove metadata cache image message from superblock extension") + if (cache_ptr->delete_image) { + if (H5F__super_ext_remove_msg(f, H5O_MDCI_MSG_ID) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove metadata cache image message from superblock extension") /* Reset image block values */ - cache_ptr->image_len = 0; + cache_ptr->image_len = 0; cache_ptr->image_data_len = 0; - cache_ptr->image_addr = HADDR_UNDEF; + cache_ptr->image_addr = HADDR_UNDEF; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__load_cache_image() */ - /*------------------------------------------------------------------------- * Function: H5C_load_cache_image_on_next_protect() * @@ -1226,8 +1198,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, - hbool_t rw) +H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw) { H5C_t *cache_ptr; @@ -1241,15 +1212,13 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Set information needed to load cache image */ - cache_ptr->image_addr = addr, - cache_ptr->image_len = len; + cache_ptr->image_addr = addr, cache_ptr->image_len = len; cache_ptr->load_image = TRUE; cache_ptr->delete_image = rw; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_load_cache_image_on_next_protect() */ - /*------------------------------------------------------------------------- * Function: H5C__image_entry_cmp * @@ -1275,9 +1244,11 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, static int H5C__image_entry_cmp(const void *_entry1, const void *_entry2) { - const H5C_image_entry_t *entry1 = (const H5C_image_entry_t *)_entry1; /* Pointer to first image entry to compare */ - const H5C_image_entry_t *entry2 = (const H5C_image_entry_t *)_entry2; /* Pointer to second image entry to compare */ - int ret_value = 0; /* Return value */ + const H5C_image_entry_t *entry1 = + (const H5C_image_entry_t *)_entry1; /* Pointer to first image entry to compare */ + const H5C_image_entry_t *entry2 = + (const H5C_image_entry_t *)_entry2; /* Pointer to second image entry to compare */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1285,25 +1256,24 @@ H5C__image_entry_cmp(const void *_entry1, const void *_entry2) HDassert(entry1); HDassert(entry2); - if(entry1->image_fd_height > entry2->image_fd_height) + if (entry1->image_fd_height > entry2->image_fd_height) ret_value = -1; - else if(entry1->image_fd_height < entry2->image_fd_height) + else if (entry1->image_fd_height < entry2->image_fd_height) ret_value = 1; else { /* Sanity check */ HDassert(entry1->lru_rank >= -1); HDassert(entry2->lru_rank >= -1); - if(entry1->lru_rank < entry2->lru_rank) + if (entry1->lru_rank < entry2->lru_rank) ret_value = -1; - else if(entry1->lru_rank > entry2->lru_rank) + else if (entry1->lru_rank > entry2->lru_rank) ret_value = 1; } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C__image_entry_cmp() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_image_for_file_close * @@ -1354,10 +1324,10 @@ H5C__image_entry_cmp(const void *_entry1, const void *_entry2) herr_t H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) { - H5C_t * cache_ptr = NULL; - haddr_t eoa_frag_addr = HADDR_UNDEF; - hsize_t eoa_frag_size = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; + haddr_t eoa_frag_addr = HADDR_UNDEF; + hsize_t eoa_frag_size = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1374,10 +1344,10 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * any group or data set, it is possible that the cache image (if * it exists) has not been read yet. Do this now if required. */ - if(cache_ptr->load_image) { + if (cache_ptr->load_image) { cache_ptr->load_image = FALSE; - if(H5C__load_cache_image(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") + if (H5C__load_cache_image(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") } /* end if */ /* Before we start to generate the cache image (if requested), verify @@ -1394,9 +1364,8 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * Also verify that the file's high_bound is at least release * 1.10.x, otherwise cancel the request for a cache image */ - if((NULL == f->shared->sblock) || - (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) || - (f->shared->high_bound < H5F_LIBVER_V110)) { + if ((NULL == f->shared->sblock) || (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) || + (f->shared->high_bound < H5F_LIBVER_V110)) { H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; cache_ptr->image_ctl = default_image_ctl; @@ -1404,7 +1373,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) } /* end if */ /* Generate the cache image, if requested */ - if(cache_ptr->image_ctl.generate_image) { + if (cache_ptr->image_ctl.generate_image) { /* Create the cache image super block extension message. * * Note that the base address and length of the metadata cache @@ -1419,12 +1388,12 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * H5C_CI__GEN_MDCI_SBE_MESG bit is set in * cache_ptr->image_ctl.flags. */ - if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDCI_SBE_MESG) - if(H5C__write_cache_image_superblock_msg(f, TRUE) < 0) + if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDCI_SBE_MESG) + if (H5C__write_cache_image_superblock_msg(f, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "creation of cache image SB mesg failed.") /* Serialize the cache */ - if(H5C__serialize_cache(f) < 0) + if (H5C__serialize_cache(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "serialization of the cache failed") /* Scan the cache and record data needed to construct the @@ -1443,7 +1412,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * image. With the recent modifications of the free space * manager code, this size should be correct. */ - if(H5C__prep_for_file_close__scan_entries(f, cache_ptr) < 0) + if (H5C__prep_for_file_close__scan_entries(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C__prep_for_file_close__scan_entries failed") HDassert(HADDR_UNDEF == cache_ptr->image_addr); @@ -1451,23 +1420,25 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) /* In the parallel case, overwrite the image_len with the * value computed by process 0. */ - if(cache_ptr->aux_ptr) { /* we have multiple processes */ - int mpi_result; - unsigned p0_image_len; - H5AC_aux_t * aux_ptr; + if (cache_ptr->aux_ptr) { /* we have multiple processes */ + int mpi_result; + unsigned p0_image_len; + H5AC_aux_t *aux_ptr; aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; - if(aux_ptr->mpi_rank == 0) { + if (aux_ptr->mpi_rank == 0) { aux_ptr->p0_image_len = (unsigned)cache_ptr->image_data_len; - p0_image_len = aux_ptr->p0_image_len; + p0_image_len = aux_ptr->p0_image_len; - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&p0_image_len, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast(&p0_image_len, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) HDassert(p0_image_len == aux_ptr->p0_image_len); } /* end if */ else { - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&p0_image_len, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast(&p0_image_len, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) aux_ptr->p0_image_len = p0_image_len; @@ -1482,9 +1453,11 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * Note that we allocate the cache image directly from the file * driver so as to avoid unsettling the free space managers. */ - if(HADDR_UNDEF == (cache_ptr->image_addr = H5FD_alloc(f->shared->lf, H5FD_MEM_SUPER, f, - (hsize_t)p0_image_len, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "can't allocate file space for metadata cache image") + if (HADDR_UNDEF == + (cache_ptr->image_addr = H5FD_alloc(f->shared->lf, H5FD_MEM_SUPER, f, (hsize_t)p0_image_len, + &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, + "can't allocate file space for metadata cache image") } /* end if */ else #endif /* H5_HAVE_PARALLEL */ @@ -1492,9 +1465,10 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * this space directly from the file driver so as to avoid * unsettling the free space managers. */ - if(HADDR_UNDEF == (cache_ptr->image_addr = H5FD_alloc(f->shared->lf, H5FD_MEM_SUPER, f, - (hsize_t)(cache_ptr->image_data_len), &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "can't allocate file space for metadata cache image") + if (HADDR_UNDEF == (cache_ptr->image_addr = H5FD_alloc(f->shared->lf, H5FD_MEM_SUPER, f, + (hsize_t)(cache_ptr->image_data_len), + &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "can't allocate file space for metadata cache image") /* Make note of the eoa after allocation of the cache image * block. This value is used for sanity checking when we @@ -1502,7 +1476,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * we destroy the metadata cache. */ HDassert(HADDR_UNDEF == f->shared->eoa_post_mdci_fsalloc); - if(HADDR_UNDEF == (f->shared->eoa_post_mdci_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (f->shared->eoa_post_mdci_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") /* For now, drop any fragment left over from the allocation of the @@ -1534,8 +1508,8 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * H5C_CI__GEN_MDC_IMAGE_BLK bit is set in * cache_ptr->image_ctl.flags. */ - if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) - if(H5C__write_cache_image_superblock_msg(f, FALSE) < 0) + if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) + if (H5C__write_cache_image_superblock_msg(f, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "update of cache image SB mesg failed") /* At this point: @@ -1572,14 +1546,14 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * allow the file close to continue normally without the * unnecessary generation of the metadata cache image. */ - if(cache_ptr->num_entries_in_image > 0) { - if(H5C__prep_for_file_close__setup_image_entries_array(cache_ptr) < 0) + if (cache_ptr->num_entries_in_image > 0) { + if (H5C__prep_for_file_close__setup_image_entries_array(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINIT, FAIL, "can't setup image entries array.") /* Sort the entries */ HDqsort(cache_ptr->image_entries, (size_t)cache_ptr->num_entries_in_image, sizeof(H5C_image_entry_t), H5C__image_entry_cmp); - } /* end if */ + } /* end if */ else { /* cancel creation of metadata cache image */ HDassert(cache_ptr->image_entries == NULL); @@ -1588,9 +1562,10 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * H5C_CI__GEN_MDC_IMAGE_BLK flag is set in * cache_ptr->image_ctl.flags. */ - if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) - if(H5F__super_ext_remove_msg(f, H5O_MDCI_MSG_ID) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove MDC image msg from superblock ext") + if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) + if (H5F__super_ext_remove_msg(f, H5O_MDCI_MSG_ID) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove MDC image msg from superblock ext") cache_ptr->image_ctl.generate_image = FALSE; } /* end else */ @@ -1603,7 +1578,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__prep_image_for_file_close() */ - /*------------------------------------------------------------------------- * Function: H5C_set_cache_image_config * @@ -1633,10 +1607,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, - H5C_cache_image_ctl_t *config_ptr) +H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1646,11 +1619,11 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, HDassert(f->shared->cache == f->shared->cache); /* Check arguments */ - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry") /* Validate the config: */ - if(H5C_validate_cache_image_config(config_ptr) < 0) + if (H5C_validate_cache_image_config(config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid cache image configuration") #ifdef H5_HAVE_PARALLEL @@ -1659,11 +1632,11 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, * if there is more than one process. * JRM -- 11/8/16 */ - if(cache_ptr->aux_ptr) { - H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; + if (cache_ptr->aux_ptr) { + H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; cache_ptr->image_ctl = default_image_ctl; - HDassert(!(cache_ptr->image_ctl.generate_image)); + HDassert(!(cache_ptr->image_ctl.generate_image)); } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ @@ -1679,7 +1652,7 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, * If it is not, set the image configuration to the default, which has * the effect of silently disabling the cache image if it was requested. */ - if(H5F_INTENT(f) & H5F_ACC_RDWR) + if (H5F_INTENT(f) & H5F_ACC_RDWR) cache_ptr->image_ctl = *config_ptr; else { H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; @@ -1688,14 +1661,13 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, HDassert(!(cache_ptr->image_ctl.generate_image)); } /* end else */ #ifdef H5_HAVE_PARALLEL - } /* end else */ + } /* end else */ #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_cache_image_config() */ - /*------------------------------------------------------------------------- * Function: H5C_validate_cache_image_config() * @@ -1713,39 +1685,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_validate_cache_image_config(H5C_cache_image_ctl_t * ctl_ptr) +H5C_validate_cache_image_config(H5C_cache_image_ctl_t *ctl_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(ctl_ptr == NULL) + if (ctl_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL ctl_ptr on entry") - if(ctl_ptr->version != H5C__CURR_CACHE_IMAGE_CTL_VER) + if (ctl_ptr->version != H5C__CURR_CACHE_IMAGE_CTL_VER) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown cache image control version") /* At present, we do not support inclusion of the adaptive resize * configuration in the cache image. Thus the save_resize_status * field must be FALSE. */ - if(ctl_ptr->save_resize_status != FALSE) + if (ctl_ptr->save_resize_status != FALSE) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unexpected value in save_resize_status field") /* At present, we do not support prefetched entry ageouts. Thus * the entry_ageout field must be set to * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE. */ - if(ctl_ptr->entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) + if (ctl_ptr->entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unexpected value in entry_ageout field") - if((ctl_ptr->flags & ~H5C_CI__ALL_FLAGS) != 0) + if ((ctl_ptr->flags & ~H5C_CI__ALL_FLAGS) != 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unknown flag set") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_validate_cache_image_config() */ - /*************************************************************************/ /**************************** Private Functions: *************************/ /*************************************************************************/ @@ -1765,28 +1736,27 @@ done: *------------------------------------------------------------------------- */ static size_t -H5C__cache_image_block_entry_header_size(const H5F_t * f) +H5C__cache_image_block_entry_header_size(const H5F_t *f) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)( 1 + /* type */ - 1 + /* flags */ - 1 + /* ring */ - 1 + /* age */ - 2 + /* dependency child count */ - 2 + /* dirty dep child count */ - 2 + /* dependency parent count */ - 4 + /* index in LRU */ - H5F_SIZEOF_ADDR(f) + /* entry offset */ - H5F_SIZEOF_SIZE(f) ); /* entry length */ + ret_value = (size_t)(1 + /* type */ + 1 + /* flags */ + 1 + /* ring */ + 1 + /* age */ + 2 + /* dependency child count */ + 2 + /* dirty dep child count */ + 2 + /* dependency parent count */ + 4 + /* index in LRU */ + H5F_SIZEOF_ADDR(f) + /* entry offset */ + H5F_SIZEOF_SIZE(f)); /* entry length */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C__cache_image_block_entry_header_size() */ - /*------------------------------------------------------------------------- * Function: H5C__cache_image_block_header_size * @@ -1802,23 +1772,22 @@ H5C__cache_image_block_entry_header_size(const H5F_t * f) *------------------------------------------------------------------------- */ static size_t -H5C__cache_image_block_header_size(const H5F_t * f) +H5C__cache_image_block_header_size(const H5F_t *f) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)( 4 + /* signature */ - 1 + /* version */ - 1 + /* flags */ - H5F_SIZEOF_SIZE(f) + /* image data length */ - 4 ); /* num_entries */ + ret_value = (size_t)(4 + /* signature */ + 1 + /* version */ + 1 + /* flags */ + H5F_SIZEOF_SIZE(f) + /* image data length */ + 4); /* num_entries */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C__cache_image_block_header_size() */ - /*------------------------------------------------------------------------- * Function: H5C__decode_cache_image_header() * @@ -1835,16 +1804,15 @@ H5C__cache_image_block_header_size(const H5F_t * f) *------------------------------------------------------------------------- */ static herr_t -H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, - const uint8_t **buf) +H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf) { - uint8_t version; - uint8_t flags; - hbool_t have_resize_status = FALSE; - size_t actual_header_len; - size_t expected_header_len; - const uint8_t * p; - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t version; + uint8_t flags; + hbool_t have_resize_status = FALSE; + size_t actual_header_len; + size_t expected_header_len; + const uint8_t *p; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1858,38 +1826,38 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, p = *buf; /* Check signature */ - if(HDmemcmp(p, H5C__MDCI_BLOCK_SIGNATURE, (size_t)H5C__MDCI_BLOCK_SIGNATURE_LEN)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image header signature") + if (HDmemcmp(p, H5C__MDCI_BLOCK_SIGNATURE, (size_t)H5C__MDCI_BLOCK_SIGNATURE_LEN)) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image header signature") p += H5C__MDCI_BLOCK_SIGNATURE_LEN; /* Check version */ version = *p++; - if(version != (uint8_t)H5C__MDCI_BLOCK_VERSION_0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image version") + if (version != (uint8_t)H5C__MDCI_BLOCK_VERSION_0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image version") /* Decode flags */ flags = *p++; - if(flags & H5C__MDCI_HEADER_HAVE_RESIZE_STATUS) - have_resize_status = TRUE; - if(have_resize_status) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "MDC resize status not yet supported") + if (flags & H5C__MDCI_HEADER_HAVE_RESIZE_STATUS) + have_resize_status = TRUE; + if (have_resize_status) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "MDC resize status not yet supported") /* Read image data length */ H5F_DECODE_LENGTH(f, p, cache_ptr->image_data_len); /* For now -- will become <= eventually */ - if(cache_ptr->image_data_len != cache_ptr->image_len) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image data length") + if (cache_ptr->image_data_len != cache_ptr->image_len) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image data length") /* Read num entries */ UINT32DECODE(p, cache_ptr->num_entries_in_image); - if(cache_ptr->num_entries_in_image == 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache entry count") + if (cache_ptr->num_entries_in_image == 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache entry count") /* Verify expected length of header */ - actual_header_len = (size_t)(p - *buf); + actual_header_len = (size_t)(p - *buf); expected_header_len = H5C__cache_image_block_header_size(f); - if(actual_header_len != expected_header_len) + if (actual_header_len != expected_header_len) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad header image len") /* Update buffer pointer */ @@ -1900,7 +1868,7 @@ done: } /* H5C__decode_cache_image_header() */ #ifndef NDEBUG - + /*------------------------------------------------------------------------- * Function: H5C__decode_cache_image_entry() * @@ -1921,28 +1889,27 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, - const uint8_t **buf, unsigned entry_num) +H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint8_t **buf, unsigned entry_num) { - hbool_t is_dirty = FALSE; - hbool_t in_lru = FALSE; /* Only used in assertions */ - hbool_t is_fd_parent = FALSE; /* Only used in assertions */ - hbool_t is_fd_child = FALSE; /* Only used in assertions */ - haddr_t addr; - hsize_t size = 0; - void * image_ptr; - uint8_t flags = 0; - uint8_t type_id; - uint8_t ring; - uint8_t age; - uint16_t fd_child_count; - uint16_t fd_dirty_child_count; - uint16_t fd_parent_count; - haddr_t * fd_parent_addrs = NULL; - int32_t lru_rank; - H5C_image_entry_t * ie_ptr = NULL; - const uint8_t * p; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t is_dirty = FALSE; + hbool_t in_lru = FALSE; /* Only used in assertions */ + hbool_t is_fd_parent = FALSE; /* Only used in assertions */ + hbool_t is_fd_child = FALSE; /* Only used in assertions */ + haddr_t addr; + hsize_t size = 0; + void * image_ptr; + uint8_t flags = 0; + uint8_t type_id; + uint8_t ring; + uint8_t age; + uint16_t fd_child_count; + uint16_t fd_dirty_child_count; + uint16_t fd_parent_count; + haddr_t * fd_parent_addrs = NULL; + int32_t lru_rank; + H5C_image_entry_t *ie_ptr = NULL; + const uint8_t * p; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1967,13 +1934,13 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, /* Decode flags */ flags = *p++; - if(flags & H5C__MDCI_ENTRY_DIRTY_FLAG) + if (flags & H5C__MDCI_ENTRY_DIRTY_FLAG) is_dirty = TRUE; - if(flags & H5C__MDCI_ENTRY_IN_LRU_FLAG) + if (flags & H5C__MDCI_ENTRY_IN_LRU_FLAG) in_lru = TRUE; - if(flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG) + if (flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG) is_fd_parent = TRUE; - if(flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) + if (flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) is_fd_child = TRUE; /* Decode ring */ @@ -1990,7 +1957,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, /* Decode dirty dependency child count */ UINT16DECODE(p, fd_dirty_child_count); - if(fd_dirty_child_count > fd_child_count) + if (fd_dirty_child_count > fd_child_count) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid dirty flush dependency child count") /* Decode dependency parent count */ @@ -2003,37 +1970,37 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, /* Decode entry offset */ H5F_addr_decode(f, &p, &addr); - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid entry offset") /* Decode entry length */ H5F_DECODE_LENGTH(f, p, size); - if(size == 0) + if (size == 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid entry size") /* Verify expected length of entry image */ - if((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) + if ((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) HGOTO_ERROR(H5E_CACHE, H5E_BADSIZE, FAIL, "Bad entry image len") /* If parent count greater than zero, allocate array for parent * addresses, and decode addresses into the array. */ - if(fd_parent_count > 0) { - int i; /* Local index variable */ + if (fd_parent_count > 0) { + int i; /* Local index variable */ - if(NULL == (fd_parent_addrs = (haddr_t *)H5MM_malloc((size_t)(fd_parent_count) * H5F_SIZEOF_ADDR(f)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addrs buffer") + if (NULL == (fd_parent_addrs = (haddr_t *)H5MM_malloc((size_t)(fd_parent_count)*H5F_SIZEOF_ADDR(f)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addrs buffer") - for(i = 0; i < fd_parent_count; i++) { + for (i = 0; i < fd_parent_count; i++) { H5F_addr_decode(f, &p, &(fd_parent_addrs[i])); - if(!H5F_addr_defined(fd_parent_addrs[i])) + if (!H5F_addr_defined(fd_parent_addrs[i])) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid flush dependency parent offset") } /* end for */ - } /* end if */ + } /* end if */ /* Allocate buffer for entry image */ - if(NULL == (image_ptr = H5MM_malloc(size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") + if (NULL == (image_ptr = H5MM_malloc(size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS H5MM_memcpy(((uint8_t *)image_ptr) + size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); @@ -2065,7 +2032,6 @@ done: } /* H5C__decode_cache_image_entry() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5C__destroy_pf_entry_child_flush_deps() * @@ -2092,14 +2058,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, - H5C_cache_entry_t *pf_entry_ptr, H5C_cache_entry_t **fd_children) +H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr, + H5C_cache_entry_t **fd_children) { - H5C_cache_entry_t * entry_ptr; - unsigned entries_visited = 0; - int fd_children_found = 0; - hbool_t found; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + unsigned entries_visited = 0; + int fd_children_found = 0; + hbool_t found; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2116,68 +2082,69 @@ H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, /* Scan each entry on the index list */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Here we look at entry_ptr->flush_dep_nparents and not + /* Here we look at entry_ptr->flush_dep_nparents and not * entry_ptr->fd_parent_count as it is possible that some - * or all of the prefetched flush dependency child relationships - * have already been destroyed. + * or all of the prefetched flush dependency child relationships + * have already been destroyed. */ - if(entry_ptr->prefetched && (entry_ptr->flush_dep_nparents > 0)) { - unsigned u; /* Local index variable */ + if (entry_ptr->prefetched && (entry_ptr->flush_dep_nparents > 0)) { + unsigned u; /* Local index variable */ /* Re-init */ - u = 0; - found = FALSE; + u = 0; + found = FALSE; /* Sanity checks */ HDassert(entry_ptr->type); HDassert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); - HDassert(entry_ptr->fd_parent_count >= entry_ptr->flush_dep_nparents); - HDassert(entry_ptr->fd_parent_addrs); - HDassert(entry_ptr->flush_dep_parent); + HDassert(entry_ptr->fd_parent_count >= entry_ptr->flush_dep_nparents); + HDassert(entry_ptr->fd_parent_addrs); + HDassert(entry_ptr->flush_dep_parent); /* Look for correct entry */ - while(!found && (u < entry_ptr->fd_parent_count)) { + while (!found && (u < entry_ptr->fd_parent_count)) { /* Sanity check entry */ - HDassert(entry_ptr->flush_dep_parent[u]); - HDassert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->flush_dep_parent[u]); + HDassert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); /* Correct entry? */ - if(pf_entry_ptr == entry_ptr->flush_dep_parent[u]) - found = TRUE; + if (pf_entry_ptr == entry_ptr->flush_dep_parent[u]) + found = TRUE; - u++; + u++; } /* end while */ - if(found) { - HDassert(NULL == fd_children[fd_children_found]); + if (found) { + HDassert(NULL == fd_children[fd_children_found]); /* Remove flush dependency */ - fd_children[fd_children_found] = entry_ptr; - fd_children_found++; - if(H5C_destroy_flush_dependency(pf_entry_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry child flush dependency") + fd_children[fd_children_found] = entry_ptr; + fd_children_found++; + if (H5C_destroy_flush_dependency(pf_entry_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "can't destroy pf entry child flush dependency") #ifndef NDEBUG - /* Sanity check -- verify that the address of the parent + /* Sanity check -- verify that the address of the parent * appears in entry_ptr->fd_parent_addrs. Must do a search, * as with flush dependency creates and destroys, * entry_ptr->fd_parent_addrs and entry_ptr->flush_dep_parent * can list parents in different order. */ - found = FALSE; - u = 0; - while(!found && u < entry_ptr->fd_parent_count) { - if(pf_entry_ptr->addr == entry_ptr->fd_parent_addrs[u]) - found = TRUE; - u++; + found = FALSE; + u = 0; + while (!found && u < entry_ptr->fd_parent_count) { + if (pf_entry_ptr->addr == entry_ptr->fd_parent_addrs[u]) + found = TRUE; + u++; } /* end while */ - HDassert(found); -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ + HDassert(found); +#endif /* NDEBUG */ + } /* end if */ + } /* end if */ entries_visited++; entry_ptr = entry_ptr->il_next; @@ -2193,7 +2160,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__destroy_pf_entry_child_flush_deps() */ - /*------------------------------------------------------------------------- * Function: H5C__encode_cache_image_header() * @@ -2209,14 +2175,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, - uint8_t **buf) +H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, uint8_t **buf) { - size_t actual_header_len; - size_t expected_header_len; - uint8_t flags = 0; - uint8_t * p; /* Pointer into cache image buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t actual_header_len; + size_t expected_header_len; + uint8_t flags = 0; + uint8_t *p; /* Pointer into cache image buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2245,8 +2210,8 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, /* at present we don't support saving resize status */ HDassert(!cache_ptr->image_ctl.save_resize_status); - if(cache_ptr->image_ctl.save_resize_status) - flags |= H5C__MDCI_HEADER_HAVE_RESIZE_STATUS; + if (cache_ptr->image_ctl.save_resize_status) + flags |= H5C__MDCI_HEADER_HAVE_RESIZE_STATUS; *p++ = flags; @@ -2259,9 +2224,9 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, UINT32ENCODE(p, cache_ptr->num_entries_in_image); /* verify expected length of header */ - actual_header_len = (size_t)(p - *buf); + actual_header_len = (size_t)(p - *buf); expected_header_len = H5C__cache_image_block_header_size(f); - if(actual_header_len != expected_header_len) + if (actual_header_len != expected_header_len) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad header image len") /* Update buffer pointer */ @@ -2271,7 +2236,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__encode_cache_image_header() */ - /*------------------------------------------------------------------------- * Function: H5C__encode_cache_image_entry() * @@ -2287,14 +2251,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, - unsigned entry_num) +H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigned entry_num) { - H5C_image_entry_t * ie_ptr; /* Pointer to entry to encode */ - uint8_t flags = 0; /* Flags for entry */ - uint8_t * p; /* Pointer into cache image buffer */ - unsigned u; /* Local index value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_image_entry_t *ie_ptr; /* Pointer to entry to encode */ + uint8_t flags = 0; /* Flags for entry */ + uint8_t * p; /* Pointer into cache image buffer */ + unsigned u; /* Local index value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2317,19 +2280,19 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, p = *buf; /* Encode type */ - if((ie_ptr->type_id < 0) || (ie_ptr->type_id > 255)) + if ((ie_ptr->type_id < 0) || (ie_ptr->type_id > 255)) HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "type_id out of range.") *p++ = (uint8_t)(ie_ptr->type_id); /* Compose and encode flags */ - if(ie_ptr->is_dirty) - flags |= H5C__MDCI_ENTRY_DIRTY_FLAG; - if(ie_ptr->lru_rank > 0) - flags |= H5C__MDCI_ENTRY_IN_LRU_FLAG; - if(ie_ptr->fd_child_count > 0) - flags |= H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG; - if(ie_ptr->fd_parent_count > 0) - flags |= H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG; + if (ie_ptr->is_dirty) + flags |= H5C__MDCI_ENTRY_DIRTY_FLAG; + if (ie_ptr->lru_rank > 0) + flags |= H5C__MDCI_ENTRY_IN_LRU_FLAG; + if (ie_ptr->fd_child_count > 0) + flags |= H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG; + if (ie_ptr->fd_parent_count > 0) + flags |= H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG; *p++ = flags; /* Encode ring */ @@ -2339,17 +2302,17 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, *p++ = (uint8_t)(ie_ptr->age); /* Validate and encode dependency child count */ - if(ie_ptr->fd_child_count > H5C__MDCI_MAX_FD_CHILDREN) + if (ie_ptr->fd_child_count > H5C__MDCI_MAX_FD_CHILDREN) HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "fd_child_count out of range") UINT16ENCODE(p, (uint16_t)(ie_ptr->fd_child_count)); /* Validate and encode dirty dependency child count */ - if(ie_ptr->fd_dirty_child_count > H5C__MDCI_MAX_FD_CHILDREN) + if (ie_ptr->fd_dirty_child_count > H5C__MDCI_MAX_FD_CHILDREN) HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "fd_dirty_child_count out of range") UINT16ENCODE(p, (uint16_t)(ie_ptr->fd_dirty_child_count)); /* Validate and encode dependency parent count */ - if(ie_ptr->fd_parent_count > H5C__MDCI_MAX_FD_PARENTS) + if (ie_ptr->fd_parent_count > H5C__MDCI_MAX_FD_PARENTS) HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "fd_parent_count out of range") UINT16ENCODE(p, (uint16_t)(ie_ptr->fd_parent_count)); @@ -2363,12 +2326,12 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, H5F_ENCODE_LENGTH(f, p, ie_ptr->size); /* Verify expected length of entry image */ - if((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) + if ((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad entry image len") /* Encode dependency parent offsets -- if any */ - for(u = 0; u < ie_ptr->fd_parent_count; u++) - H5F_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]); + for (u = 0; u < ie_ptr->fd_parent_count; u++) + H5F_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]); /* Copy entry image */ H5MM_memcpy(p, ie_ptr->image_ptr, ie_ptr->size); @@ -2381,7 +2344,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__encode_cache_image_entry() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__compute_fd_heights * @@ -2448,14 +2410,14 @@ done: static herr_t H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) { - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * parent_ptr; - unsigned entries_removed_from_image = 0; - unsigned external_parent_fd_refs_removed = 0; - unsigned external_child_fd_refs_removed = 0; - hbool_t done = FALSE; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *parent_ptr; + unsigned entries_removed_from_image = 0; + unsigned external_parent_fd_refs_removed = 0; + unsigned external_child_fd_refs_removed = 0; + hbool_t done = FALSE; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -2471,36 +2433,35 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) * multiple passes through the index list. */ done = FALSE; - while(!done) { - done = TRUE; - entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (!done) { + done = TRUE; + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); /* Should this entry be in the image */ - if(entry_ptr->image_dirty && entry_ptr->include_in_image && - (entry_ptr->fd_parent_count > 0)) { - HDassert(entry_ptr->flush_dep_parent != NULL); - for(u = 0; u < entry_ptr->flush_dep_nparents; u++ ) { - parent_ptr = entry_ptr->flush_dep_parent[u]; + if (entry_ptr->image_dirty && entry_ptr->include_in_image && (entry_ptr->fd_parent_count > 0)) { + HDassert(entry_ptr->flush_dep_parent != NULL); + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring == parent_ptr->ring); + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring == parent_ptr->ring); - if(parent_ptr->is_dirty && !parent_ptr->include_in_image && - entry_ptr->include_in_image) { + if (parent_ptr->is_dirty && !parent_ptr->include_in_image && + entry_ptr->include_in_image) { - /* Must remove child from image -- only do this once */ - entries_removed_from_image++; - entry_ptr->include_in_image = FALSE; - } /* end if */ - } /* for */ - } /* end if */ + /* Must remove child from image -- only do this once */ + entries_removed_from_image++; + entry_ptr->include_in_image = FALSE; + } /* end if */ + } /* for */ + } /* end if */ - entry_ptr = entry_ptr->il_next; + entry_ptr = entry_ptr->il_next; } /* while ( entry_ptr != NULL ) */ - } /* while ( ! done ) */ + } /* while ( ! done ) */ /* at present, entries are included in the cache image if they reside * in a specified set of rings. Thus it should be impossible for @@ -2514,79 +2475,81 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) * flush dependency parents or children that are not in the cache image. */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - if(!entry_ptr->include_in_image && entry_ptr->flush_dep_nparents > 0) { - HDassert(entry_ptr->flush_dep_parent != NULL); + while (entry_ptr != NULL) { + if (!entry_ptr->include_in_image && entry_ptr->flush_dep_nparents > 0) { + HDassert(entry_ptr->flush_dep_parent != NULL); - for(u = 0; u < entry_ptr->flush_dep_nparents; u++ ) { - parent_ptr = entry_ptr->flush_dep_parent[u]; + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring == parent_ptr->ring); - - if(parent_ptr->include_in_image) { - /* Must remove reference to child */ - HDassert(parent_ptr->fd_child_count > 0); - parent_ptr->fd_child_count--; - - if(entry_ptr->is_dirty) { - HDassert(parent_ptr->fd_dirty_child_count > 0); - parent_ptr->fd_dirty_child_count--; - } /* end if */ - - external_child_fd_refs_removed++; - } /* end if */ - } /* for */ - } /* end if */ - else if(entry_ptr->include_in_image && entry_ptr->flush_dep_nparents > 0) { + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring == parent_ptr->ring); + + if (parent_ptr->include_in_image) { + /* Must remove reference to child */ + HDassert(parent_ptr->fd_child_count > 0); + parent_ptr->fd_child_count--; + + if (entry_ptr->is_dirty) { + HDassert(parent_ptr->fd_dirty_child_count > 0); + parent_ptr->fd_dirty_child_count--; + } /* end if */ + + external_child_fd_refs_removed++; + } /* end if */ + } /* for */ + } /* end if */ + else if (entry_ptr->include_in_image && entry_ptr->flush_dep_nparents > 0) { /* Sanity checks */ - HDassert(entry_ptr->flush_dep_parent != NULL); - HDassert(entry_ptr->flush_dep_nparents == entry_ptr->fd_parent_count); - HDassert(entry_ptr->fd_parent_addrs); + HDassert(entry_ptr->flush_dep_parent != NULL); + HDassert(entry_ptr->flush_dep_nparents == entry_ptr->fd_parent_count); + HDassert(entry_ptr->fd_parent_addrs); - for(u = 0; u < entry_ptr->flush_dep_nparents; u++ ) { - parent_ptr = entry_ptr->flush_dep_parent[u]; + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring == parent_ptr->ring); - - if(!parent_ptr->include_in_image) { - /* Must remove reference to parent */ - HDassert(entry_ptr->fd_parent_count > 0); - parent_ptr->fd_child_count--; - - HDassert(parent_ptr->addr == entry_ptr->fd_parent_addrs[u]); - - entry_ptr->fd_parent_addrs[u] = HADDR_UNDEF; - external_parent_fd_refs_removed++; - } /* end if */ - } /* for */ - - /* Touch up fd_parent_addrs array if necessary */ - if(entry_ptr->fd_parent_count == 0) { - H5MM_xfree(entry_ptr->fd_parent_addrs); - entry_ptr->fd_parent_addrs = NULL; - } /* end if */ - else if(entry_ptr->flush_dep_nparents > entry_ptr->fd_parent_count) { - haddr_t * old_fd_parent_addrs = entry_ptr->fd_parent_addrs; + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring == parent_ptr->ring); + + if (!parent_ptr->include_in_image) { + /* Must remove reference to parent */ + HDassert(entry_ptr->fd_parent_count > 0); + parent_ptr->fd_child_count--; + + HDassert(parent_ptr->addr == entry_ptr->fd_parent_addrs[u]); + + entry_ptr->fd_parent_addrs[u] = HADDR_UNDEF; + external_parent_fd_refs_removed++; + } /* end if */ + } /* for */ + + /* Touch up fd_parent_addrs array if necessary */ + if (entry_ptr->fd_parent_count == 0) { + H5MM_xfree(entry_ptr->fd_parent_addrs); + entry_ptr->fd_parent_addrs = NULL; + } /* end if */ + else if (entry_ptr->flush_dep_nparents > entry_ptr->fd_parent_count) { + haddr_t *old_fd_parent_addrs = entry_ptr->fd_parent_addrs; unsigned v; - if(NULL == (entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_calloc(sizeof(haddr_t) * (size_t)(entry_ptr->fd_parent_addrs)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addr array") + if (NULL == (entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_calloc( + sizeof(haddr_t) * (size_t)(entry_ptr->fd_parent_addrs)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for fd parent addr array") - v = 0; - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) { - if(old_fd_parent_addrs[u] != HADDR_UNDEF) { - entry_ptr->fd_parent_addrs[v] = old_fd_parent_addrs[u]; - v++; - } /* end if */ - } /* end for */ + v = 0; + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + if (old_fd_parent_addrs[u] != HADDR_UNDEF) { + entry_ptr->fd_parent_addrs[v] = old_fd_parent_addrs[u]; + v++; + } /* end if */ + } /* end for */ - HDassert(v == entry_ptr->fd_parent_count); - } /* end else-if */ - } /* end else-if */ + HDassert(v == entry_ptr->fd_parent_count); + } /* end else-if */ + } /* end else-if */ entry_ptr = entry_ptr->il_next; } /* while (entry_ptr != NULL) */ @@ -2609,17 +2572,16 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) * for all entries that may appear in the cache image. */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - if(entry_ptr->include_in_image && entry_ptr->fd_child_count == 0 && - entry_ptr->fd_parent_count > 0) { - for(u = 0; u < entry_ptr->fd_parent_count; u++) { - parent_ptr = entry_ptr->flush_dep_parent[u]; - - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(parent_ptr->include_in_image && parent_ptr->image_fd_height <= 0) - H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, 1); - } /* end for */ - } /* end if */ + while (entry_ptr != NULL) { + if (entry_ptr->include_in_image && entry_ptr->fd_child_count == 0 && entry_ptr->fd_parent_count > 0) { + for (u = 0; u < entry_ptr->fd_parent_count; u++) { + parent_ptr = entry_ptr->flush_dep_parent[u]; + + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + if (parent_ptr->include_in_image && parent_ptr->image_fd_height <= 0) + H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, 1); + } /* end for */ + } /* end if */ entry_ptr = entry_ptr->il_next; } /* while (entry_ptr != NULL) */ @@ -2628,7 +2590,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__prep_for_file_close__compute_fd_heights() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__compute_fd_heights_real * @@ -2678,8 +2639,7 @@ done: *------------------------------------------------------------------------- */ static void -H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, - uint32_t fd_height) +H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, uint32_t fd_height) { FUNC_ENTER_STATIC_NOERR @@ -2688,28 +2648,28 @@ H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->include_in_image); HDassert((entry_ptr->image_fd_height == 0) || (entry_ptr->image_fd_height < fd_height)); - HDassert(((fd_height == 0) && (entry_ptr->fd_child_count == 0)) || ((fd_height > 0) && (entry_ptr->fd_child_count > 0))); + HDassert(((fd_height == 0) && (entry_ptr->fd_child_count == 0)) || + ((fd_height > 0) && (entry_ptr->fd_child_count > 0))); entry_ptr->image_fd_height = fd_height; - if(entry_ptr->flush_dep_nparents > 0) { + if (entry_ptr->flush_dep_nparents > 0) { unsigned u; - HDassert(entry_ptr->flush_dep_parent); - for(u = 0; u < entry_ptr->fd_parent_count; u++) { + HDassert(entry_ptr->flush_dep_parent); + for (u = 0; u < entry_ptr->fd_parent_count; u++) { H5C_cache_entry_t *parent_ptr; - parent_ptr = entry_ptr->flush_dep_parent[u]; - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + parent_ptr = entry_ptr->flush_dep_parent[u]; + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(parent_ptr->include_in_image && parent_ptr->image_fd_height <= fd_height) - H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, fd_height + 1); + if (parent_ptr->include_in_image && parent_ptr->image_fd_height <= fd_height) + H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, fd_height + 1); } /* end for */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* H5C__prep_for_file_close__compute_fd_heights_real() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__setup_image_entries_array * @@ -2727,11 +2687,11 @@ H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, static herr_t H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) { - H5C_cache_entry_t * entry_ptr; - H5C_image_entry_t * image_entries = NULL; - uint32_t entries_visited = 0; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + H5C_image_entry_t *image_entries = NULL; + uint32_t entries_visited = 0; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2744,73 +2704,73 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) HDassert(cache_ptr->image_entries == NULL); /* Allocate and initialize image_entries array */ - if(NULL == (image_entries = (H5C_image_entry_t *)H5MM_calloc(sizeof(H5C_image_entry_t) * (size_t)(cache_ptr->num_entries_in_image + 1)))) + if (NULL == (image_entries = (H5C_image_entry_t *)H5MM_calloc( + sizeof(H5C_image_entry_t) * (size_t)(cache_ptr->num_entries_in_image + 1)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for image_entries") /* Initialize (non-zero/NULL/FALSE) fields */ - for(u = 0; u <= cache_ptr->num_entries_in_image; u++) { - image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; - image_entries[u].addr = HADDR_UNDEF; - image_entries[u].ring = H5C_RING_UNDEFINED; - image_entries[u].type_id = -1; + for (u = 0; u <= cache_ptr->num_entries_in_image; u++) { + image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; + image_entries[u].addr = HADDR_UNDEF; + image_entries[u].ring = H5C_RING_UNDEFINED; + image_entries[u].type_id = -1; } /* end for */ /* Scan each entry on the index list and populate the image_entries array */ - u = 0; + u = 0; entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(entry_ptr->include_in_image) { - /* Since we have already serialized the cache, the following + if (entry_ptr->include_in_image) { + /* Since we have already serialized the cache, the following * should hold. */ HDassert(entry_ptr->image_up_to_date); HDassert(entry_ptr->image_ptr); - HDassert(entry_ptr->type); + HDassert(entry_ptr->type); - image_entries[u].addr = entry_ptr->addr; - image_entries[u].size = entry_ptr->size; - image_entries[u].ring = entry_ptr->ring; + image_entries[u].addr = entry_ptr->addr; + image_entries[u].size = entry_ptr->size; + image_entries[u].ring = entry_ptr->ring; - /* When a prefetched entry is included in the image, store + /* When a prefetched entry is included in the image, store * its underlying type id in the image entry, not * H5AC_PREFETCHED_ENTRY_ID. In passing, also increment - * the age (up to H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX). + * the age (up to H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX). */ - if(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID) { - image_entries[u].type_id = entry_ptr->prefetch_type_id; - image_entries[u].age = entry_ptr->age + 1; + if (entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID) { + image_entries[u].type_id = entry_ptr->prefetch_type_id; + image_entries[u].age = entry_ptr->age + 1; - if(image_entries[u].age > H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX) - image_entries[u].age = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX; - } /* end if */ + if (image_entries[u].age > H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX) + image_entries[u].age = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX; + } /* end if */ else { - image_entries[u].type_id = entry_ptr->type->id; - image_entries[u].age = 0; - } /* end else */ - - image_entries[u].lru_rank = entry_ptr->lru_rank; - image_entries[u].is_dirty = entry_ptr->is_dirty; - image_entries[u].image_fd_height = entry_ptr->image_fd_height; - image_entries[u].fd_parent_count = entry_ptr->fd_parent_count; - image_entries[u].fd_parent_addrs = entry_ptr->fd_parent_addrs; - image_entries[u].fd_child_count = entry_ptr->fd_child_count; - image_entries[u].fd_dirty_child_count = - entry_ptr->fd_dirty_child_count; - image_entries[u].image_ptr = entry_ptr->image_ptr; - - /* Null out entry_ptr->fd_parent_addrs and set + image_entries[u].type_id = entry_ptr->type->id; + image_entries[u].age = 0; + } /* end else */ + + image_entries[u].lru_rank = entry_ptr->lru_rank; + image_entries[u].is_dirty = entry_ptr->is_dirty; + image_entries[u].image_fd_height = entry_ptr->image_fd_height; + image_entries[u].fd_parent_count = entry_ptr->fd_parent_count; + image_entries[u].fd_parent_addrs = entry_ptr->fd_parent_addrs; + image_entries[u].fd_child_count = entry_ptr->fd_child_count; + image_entries[u].fd_dirty_child_count = entry_ptr->fd_dirty_child_count; + image_entries[u].image_ptr = entry_ptr->image_ptr; + + /* Null out entry_ptr->fd_parent_addrs and set * entry_ptr->fd_parent_count to zero so that ownership of the * flush dependency parents address array is transferred to the - * image entry. + * image entry. */ - entry_ptr->fd_parent_count = 0; - entry_ptr->fd_parent_addrs = NULL; + entry_ptr->fd_parent_count = 0; + entry_ptr->fd_parent_addrs = NULL; u++; - HDassert(u <= cache_ptr->num_entries_in_image); + HDassert(u <= cache_ptr->num_entries_in_image); } /* end if */ entries_visited++; @@ -2831,7 +2791,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__prep_for_file_close__setup_image_entries_array() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__scan_entries * @@ -2865,18 +2824,18 @@ done: static herr_t H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) { - H5C_cache_entry_t * entry_ptr; - hbool_t include_in_image; - unsigned entries_visited = 0; - int lru_rank = 1; - uint32_t num_entries_tentatively_in_image = 0; - uint32_t num_entries_in_image = 0; - size_t image_len; - size_t entry_header_len; - size_t fd_parents_list_len; - int i; - unsigned j; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + hbool_t include_in_image; + unsigned entries_visited = 0; + int lru_rank = 1; + uint32_t num_entries_tentatively_in_image = 0; + uint32_t num_entries_in_image = 0; + size_t image_len; + size_t entry_header_len; + size_t fd_parents_list_len; + int i; + unsigned j; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2897,85 +2856,87 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) /* Scan each entry on the index list */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Since we have already serialized the cache, the following + /* Since we have already serialized the cache, the following * should hold. */ HDassert(entry_ptr->image_up_to_date); HDassert(entry_ptr->image_ptr); - /* Initially, we mark all entries in the rings included + /* Initially, we mark all entries in the rings included * in the cache image as being included in the in the * image. Depending on circumstances, we may exclude some * of these entries later. */ - if(entry_ptr->ring > H5C_MAX_RING_IN_IMAGE) - include_in_image = FALSE; + if (entry_ptr->ring > H5C_MAX_RING_IN_IMAGE) + include_in_image = FALSE; else - include_in_image = TRUE; + include_in_image = TRUE; entry_ptr->include_in_image = include_in_image; - if(include_in_image) { - entry_ptr->lru_rank = -1; - entry_ptr->image_dirty = entry_ptr->is_dirty; - entry_ptr->image_fd_height = 0; /* will compute this later */ + if (include_in_image) { + entry_ptr->lru_rank = -1; + entry_ptr->image_dirty = entry_ptr->is_dirty; + entry_ptr->image_fd_height = 0; /* will compute this later */ - /* Initially, include all flush dependency parents in the + /* Initially, include all flush dependency parents in the * the list of flush dependencies to be stored in the * image. We may remove some or all of these later. */ - if(entry_ptr->flush_dep_nparents > 0) { - /* The parents addresses array may already exist -- reallocate + if (entry_ptr->flush_dep_nparents > 0) { + /* The parents addresses array may already exist -- reallocate * as needed. */ - if(entry_ptr->flush_dep_nparents == entry_ptr->fd_parent_count ) { - /* parent addresses array should already be allocated + if (entry_ptr->flush_dep_nparents == entry_ptr->fd_parent_count) { + /* parent addresses array should already be allocated * and of the correct size. */ - HDassert(entry_ptr->fd_parent_addrs); - } /* end if */ - else if(entry_ptr->fd_parent_count > 0) { - HDassert(entry_ptr->fd_parent_addrs); + HDassert(entry_ptr->fd_parent_addrs); + } /* end if */ + else if (entry_ptr->fd_parent_count > 0) { + HDassert(entry_ptr->fd_parent_addrs); entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(entry_ptr->fd_parent_addrs); - } /* end else-if */ + } /* end else-if */ else { - HDassert(entry_ptr->fd_parent_count == 0); - HDassert(entry_ptr->fd_parent_addrs == NULL); - } /* end else */ - - entry_ptr->fd_parent_count = entry_ptr->flush_dep_nparents; - if(NULL == entry_ptr->fd_parent_addrs) - if(NULL == (entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_malloc(sizeof(haddr_t) * (size_t)(entry_ptr->fd_parent_count)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addrs buffer") - - for(i = 0; i < (int)(entry_ptr->fd_parent_count); i++) { - entry_ptr->fd_parent_addrs[i] = entry_ptr->flush_dep_parent[i]->addr; - HDassert(H5F_addr_defined(entry_ptr->fd_parent_addrs[i])); - } /* end for */ - } /* end if */ - else if(entry_ptr->fd_parent_count > 0) { - HDassert(entry_ptr->fd_parent_addrs); - entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(entry_ptr->fd_parent_addrs); - } /* end else-if */ + HDassert(entry_ptr->fd_parent_count == 0); + HDassert(entry_ptr->fd_parent_addrs == NULL); + } /* end else */ + + entry_ptr->fd_parent_count = entry_ptr->flush_dep_nparents; + if (NULL == entry_ptr->fd_parent_addrs) + if (NULL == (entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_malloc( + sizeof(haddr_t) * (size_t)(entry_ptr->fd_parent_count)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for fd parent addrs buffer") + + for (i = 0; i < (int)(entry_ptr->fd_parent_count); i++) { + entry_ptr->fd_parent_addrs[i] = entry_ptr->flush_dep_parent[i]->addr; + HDassert(H5F_addr_defined(entry_ptr->fd_parent_addrs[i])); + } /* end for */ + } /* end if */ + else if (entry_ptr->fd_parent_count > 0) { + HDassert(entry_ptr->fd_parent_addrs); + entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(entry_ptr->fd_parent_addrs); + } /* end else-if */ else - HDassert(entry_ptr->fd_parent_addrs == NULL); + HDassert(entry_ptr->fd_parent_addrs == NULL); - /* Initially, all flush dependency children are included int + /* Initially, all flush dependency children are included int * the count of flush dependency child relationships to be * represented in the cache image. Some or all of these * may be dropped from the image later. */ - if(entry_ptr->flush_dep_nchildren > 0) { - if(!entry_ptr->is_pinned) + if (entry_ptr->flush_dep_nchildren > 0) { + if (!entry_ptr->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "encountered unpinned fd parent?!?") - entry_ptr->fd_child_count = entry_ptr->flush_dep_nchildren; - entry_ptr->fd_dirty_child_count = entry_ptr->flush_dep_ndirty_children; - } /* end if */ + entry_ptr->fd_child_count = entry_ptr->flush_dep_nchildren; + entry_ptr->fd_dirty_child_count = entry_ptr->flush_dep_ndirty_children; + } /* end if */ - num_entries_tentatively_in_image++; + num_entries_tentatively_in_image++; } /* end if */ entries_visited++; @@ -3006,7 +2967,7 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) * exact contents of the image cannot be known until after this * call, computation of the image size is delayed. */ - if(H5C__prep_for_file_close__compute_fd_heights(cache_ptr) < 0) + if (H5C__prep_for_file_close__compute_fd_heights(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "computation of flush dependency heights failed?!?") /* At this point, all entries that will appear in the cache @@ -3014,12 +2975,12 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) * cache image. */ entries_visited = 0; - entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(entry_ptr->include_in_image) { - if(entry_ptr->fd_parent_count > 0) + if (entry_ptr->include_in_image) { + if (entry_ptr->fd_parent_count > 0) fd_parents_list_len = (size_t)(H5F_SIZEOF_ADDR(f) * entry_ptr->fd_parent_count); else fd_parents_list_len = (size_t)0; @@ -3035,14 +2996,14 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) HDassert(num_entries_in_image <= num_entries_tentatively_in_image); j = 0; - for(i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++) + for (i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++) j += cache_ptr->index_ring_len[i]; /* This will change */ HDassert(entries_visited == (num_entries_tentatively_in_image + j)); cache_ptr->num_entries_in_image = num_entries_in_image; - entries_visited = 0; + entries_visited = 0; /* Now scan the LRU list to set the lru_rank fields of all entries * on the LRU. @@ -3055,8 +3016,8 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) * the reconstructed LRU should be appropriate. */ entry_ptr = cache_ptr->LRU_head_ptr; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->type != NULL); /* to avoid confusion, don't set lru_rank on epoch markers. @@ -3068,10 +3029,10 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) * Do not set lru_rank or increment lru_rank for entries * that will not be included in the cache image. */ - if(entry_ptr->type->id == H5AC_EPOCH_MARKER_ID) - lru_rank++; - else if(entry_ptr->include_in_image) { - entry_ptr->lru_rank = lru_rank; + if (entry_ptr->type->id == H5AC_EPOCH_MARKER_ID) + lru_rank++; + else if (entry_ptr->include_in_image) { + entry_ptr->lru_rank = lru_rank; lru_rank++; } /* end else-if */ @@ -3087,7 +3048,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__prep_for_file_close__scan_entries() */ - /*------------------------------------------------------------------------- * Function: H5C__reconstruct_cache_contents() * @@ -3107,11 +3067,11 @@ done: static herr_t H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) { - H5C_cache_entry_t * pf_entry_ptr; /* Pointer to prefetched entry */ - H5C_cache_entry_t * parent_ptr; /* Pointer to parent of prefetched entry */ - const uint8_t * p; /* Pointer into image buffer */ - unsigned u, v; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *pf_entry_ptr; /* Pointer to prefetched entry */ + H5C_cache_entry_t *parent_ptr; /* Pointer to parent of prefetched entry */ + const uint8_t * p; /* Pointer into image buffer */ + unsigned u, v; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3126,7 +3086,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) /* Decode metadata cache image header */ p = (uint8_t *)cache_ptr->image_buffer; - if(H5C__decode_cache_image_header(f, cache_ptr, &p) < 0) + if (H5C__decode_cache_image_header(f, cache_ptr, &p) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDECODE, FAIL, "cache image header decode failed") HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) < cache_ptr->image_len); @@ -3136,14 +3096,14 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) HDassert(cache_ptr->num_entries_in_image > 0); /* Reconstruct entries in image */ - for(u = 0; u < cache_ptr->num_entries_in_image; u++) { - /* Create the prefetched entry described by the ith + for (u = 0; u < cache_ptr->num_entries_in_image; u++) { + /* Create the prefetched entry described by the ith * entry in cache_ptr->image_entrise. */ - if(NULL == (pf_entry_ptr = H5C__reconstruct_cache_entry(f, cache_ptr, &p))) + if (NULL == (pf_entry_ptr = H5C__reconstruct_cache_entry(f, cache_ptr, &p))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "reconstruction of cache entry failed") - /* Note that we make no checks on available cache space before + /* Note that we make no checks on available cache space before * inserting the reconstructed entry into the metadata cache. * * This is OK since the cache must be almost empty at the beginning @@ -3151,66 +3111,66 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) * reconstruction process. */ - /* Insert the prefetched entry in the index */ - H5C__INSERT_IN_INDEX(cache_ptr, pf_entry_ptr, FAIL) + /* Insert the prefetched entry in the index */ + H5C__INSERT_IN_INDEX(cache_ptr, pf_entry_ptr, FAIL) - /* If dirty, insert the entry into the slist. */ - if(pf_entry_ptr->is_dirty) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, pf_entry_ptr, FAIL) + /* If dirty, insert the entry into the slist. */ + if (pf_entry_ptr->is_dirty) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, pf_entry_ptr, FAIL) /* Append the entry to the LRU */ - H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, pf_entry_ptr, FAIL) + H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, pf_entry_ptr, FAIL) - H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, pf_entry_ptr->is_dirty) + H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, pf_entry_ptr->is_dirty) - /* If the prefetched entry is the child in one or more flush + /* If the prefetched entry is the child in one or more flush * dependency relationships, recreate those flush dependencies. */ - for(v = 0; v < pf_entry_ptr->fd_parent_count; v++) { + for (v = 0; v < pf_entry_ptr->fd_parent_count; v++) { /* Sanity checks */ - HDassert(pf_entry_ptr->fd_parent_addrs); - HDassert(H5F_addr_defined(pf_entry_ptr->fd_parent_addrs[v])); + HDassert(pf_entry_ptr->fd_parent_addrs); + HDassert(H5F_addr_defined(pf_entry_ptr->fd_parent_addrs[v])); /* Find the parent entry */ - parent_ptr = NULL; - H5C__SEARCH_INDEX(cache_ptr, pf_entry_ptr->fd_parent_addrs[v], parent_ptr, FAIL) - if(parent_ptr == NULL) + parent_ptr = NULL; + H5C__SEARCH_INDEX(cache_ptr, pf_entry_ptr->fd_parent_addrs[v], parent_ptr, FAIL) + if (parent_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "fd parent not in cache?!?") /* Sanity checks */ - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(parent_ptr->addr == pf_entry_ptr->fd_parent_addrs[v]); HDassert(parent_ptr->lru_rank == -1); - /* Must protect parent entry to set up a flush dependency. + /* Must protect parent entry to set up a flush dependency. * Do this now, and then uprotect when done. */ H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, parent_ptr, FAIL) parent_ptr->is_protected = TRUE; - /* Setup the flush dependency */ - if(H5C_create_flush_dependency(parent_ptr, pf_entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore flush dependency") + /* Setup the flush dependency */ + if (H5C_create_flush_dependency(parent_ptr, pf_entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore flush dependency") - /* And now unprotect */ - H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL) - parent_ptr->is_protected = FALSE; + /* And now unprotect */ + H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL) + parent_ptr->is_protected = FALSE; } /* end for */ - } /* end for */ + } /* end for */ #ifndef NDEBUG /* Scan the cache entries, and verify that each entry has * the expected flush dependency status. */ pf_entry_ptr = cache_ptr->il_head; - while(pf_entry_ptr != NULL) { + while (pf_entry_ptr != NULL) { HDassert(pf_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert((pf_entry_ptr->prefetched && pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) - || (!pf_entry_ptr->prefetched && pf_entry_ptr->type != H5AC_PREFETCHED_ENTRY)); - if(pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) + HDassert((pf_entry_ptr->prefetched && pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) || + (!pf_entry_ptr->prefetched && pf_entry_ptr->type != H5AC_PREFETCHED_ENTRY)); + if (pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) HDassert(pf_entry_ptr->fd_parent_count == pf_entry_ptr->flush_dep_nparents); - for(v = 0; v < pf_entry_ptr->fd_parent_count; v++) { + for (v = 0; v < pf_entry_ptr->fd_parent_count; v++) { parent_ptr = pf_entry_ptr->flush_dep_parent[v]; HDassert(parent_ptr); HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -3219,7 +3179,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) HDassert(parent_ptr->flush_dep_nchildren > 0); } /* end for */ - if(pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) { + if (pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) { HDassert(pf_entry_ptr->fd_child_count == pf_entry_ptr->flush_dep_nchildren); HDassert(pf_entry_ptr->fd_dirty_child_count == pf_entry_ptr->flush_dep_ndirty_children); } /* end if */ @@ -3231,26 +3191,24 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) * prefetched entries. */ { - int lru_rank_holes = 0; + int lru_rank_holes = 0; H5C_cache_entry_t *entry_ptr; - int i; /* Local index variable */ + int i; /* Local index variable */ - i = -1; + i = -1; entry_ptr = cache_ptr->LRU_head_ptr; - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->type != NULL); - if ( entry_ptr->prefetched ) { + if (entry_ptr->prefetched) { HDassert(entry_ptr->lru_rank != 0); - HDassert((entry_ptr->lru_rank == -1) || - (entry_ptr->lru_rank > i)); + HDassert((entry_ptr->lru_rank == -1) || (entry_ptr->lru_rank > i)); - if ( ( entry_ptr->lru_rank > 1 ) && - ( entry_ptr->lru_rank > i + 1 ) ) + if ((entry_ptr->lru_rank > 1) && (entry_ptr->lru_rank > i + 1)) lru_rank_holes += entry_ptr->lru_rank - (i + 1); @@ -3261,41 +3219,40 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) entry_ptr = entry_ptr->next; } /* end while */ - /* Holes in the sequences of LRU ranks can appear due to epoch + /* Holes in the sequences of LRU ranks can appear due to epoch * markers. They are left in to allow re-insertion of the * epoch markers on reconstruction of the cache -- thus * the following sanity check will have to be revised when * we add code to store and restore adaptive resize status. */ - HDassert(lru_rank_holes <= H5C__MAX_EPOCH_MARKERS); - } /* end block */ + HDassert(lru_rank_holes <= H5C__MAX_EPOCH_MARKERS); + } /* end block */ #endif /* NDEBUG */ /* Check to see if the cache is oversize, and evict entries as * necessary to remain within limits. */ - if(cache_ptr->index_size >= cache_ptr->max_cache_size) { - /* cache is oversized -- call H5C__make_space_in_cache() with zero + if (cache_ptr->index_size >= cache_ptr->max_cache_size) { + /* cache is oversized -- call H5C__make_space_in_cache() with zero * space needed to repair the situation if possible. */ hbool_t write_permitted = FALSE; - if(cache_ptr->check_write_permitted != NULL) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "Can't get write_permitted") } /* end if */ else write_permitted = cache_ptr->write_permitted; - if(H5C__make_space_in_cache(f, 0, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "H5C__make_space_in_cache failed") + if (H5C__make_space_in_cache(f, 0, write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "H5C__make_space_in_cache failed") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__reconstruct_cache_contents() */ - /*------------------------------------------------------------------------- * Function: H5C__reconstruct_cache_entry() * @@ -3314,20 +3271,19 @@ done: *------------------------------------------------------------------------- */ static H5C_cache_entry_t * -H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, - const uint8_t **buf) +H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf) { - H5C_cache_entry_t *pf_entry_ptr = NULL; /* Reconstructed cache entry */ - uint8_t flags = 0; - hbool_t is_dirty = FALSE; -#ifndef NDEBUG /* only used in assertions */ - hbool_t in_lru = FALSE; - hbool_t is_fd_parent = FALSE; - hbool_t is_fd_child = FALSE; + H5C_cache_entry_t *pf_entry_ptr = NULL; /* Reconstructed cache entry */ + uint8_t flags = 0; + hbool_t is_dirty = FALSE; +#ifndef NDEBUG /* only used in assertions */ + hbool_t in_lru = FALSE; + hbool_t is_fd_parent = FALSE; + hbool_t is_fd_child = FALSE; #endif /* NDEBUG */ /* only used in assertions */ - const uint8_t * p; + const uint8_t * p; hbool_t file_is_rw; - H5C_cache_entry_t *ret_value = NULL; /* Return value */ + H5C_cache_entry_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -3341,8 +3297,8 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, file_is_rw = cache_ptr->delete_image; /* Allocate space for the prefetched cache entry */ - if(NULL == (pf_entry_ptr = H5FL_CALLOC(H5C_cache_entry_t))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for prefetched cache entry") + if (NULL == (pf_entry_ptr = H5FL_CALLOC(H5C_cache_entry_t))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for prefetched cache entry") /* Get pointer to buffer */ p = *buf; @@ -3352,14 +3308,14 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Decode flags */ flags = *p++; - if(flags & H5C__MDCI_ENTRY_DIRTY_FLAG) + if (flags & H5C__MDCI_ENTRY_DIRTY_FLAG) is_dirty = TRUE; -#ifndef NDEBUG /* only used in assertions */ - if(flags & H5C__MDCI_ENTRY_IN_LRU_FLAG) +#ifndef NDEBUG /* only used in assertions */ + if (flags & H5C__MDCI_ENTRY_IN_LRU_FLAG) in_lru = TRUE; - if(flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG) + if (flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG) is_fd_parent = TRUE; - if(flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) + if (flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) is_fd_child = TRUE; #endif /* NDEBUG */ /* only used in assertions */ @@ -3387,18 +3343,20 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Decode dependency child count */ UINT16DECODE(p, pf_entry_ptr->fd_child_count); - HDassert((is_fd_parent && pf_entry_ptr->fd_child_count > 0) || (!is_fd_parent && pf_entry_ptr->fd_child_count == 0)); + HDassert((is_fd_parent && pf_entry_ptr->fd_child_count > 0) || + (!is_fd_parent && pf_entry_ptr->fd_child_count == 0)); /* Decode dirty dependency child count */ UINT16DECODE(p, pf_entry_ptr->fd_dirty_child_count); - if(!file_is_rw) - pf_entry_ptr->fd_dirty_child_count = 0; - if(pf_entry_ptr->fd_dirty_child_count > pf_entry_ptr->fd_child_count) + if (!file_is_rw) + pf_entry_ptr->fd_dirty_child_count = 0; + if (pf_entry_ptr->fd_dirty_child_count > pf_entry_ptr->fd_child_count) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid dirty flush dependency child count") /* Decode dependency parent count */ UINT16DECODE(p, pf_entry_ptr->fd_parent_count); - HDassert((is_fd_child && pf_entry_ptr->fd_parent_count > 0) || (!is_fd_child && pf_entry_ptr->fd_parent_count == 0)); + HDassert((is_fd_child && pf_entry_ptr->fd_parent_count > 0) || + (!is_fd_child && pf_entry_ptr->fd_parent_count == 0)); /* Decode index in LRU */ INT32DECODE(p, pf_entry_ptr->lru_rank); @@ -3406,37 +3364,38 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Decode entry offset */ H5F_addr_decode(f, &p, &pf_entry_ptr->addr); - if(!H5F_addr_defined(pf_entry_ptr->addr)) + if (!H5F_addr_defined(pf_entry_ptr->addr)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid entry offset") /* Decode entry length */ H5F_DECODE_LENGTH(f, p, pf_entry_ptr->size); - if(pf_entry_ptr->size == 0) + if (pf_entry_ptr->size == 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid entry size") /* Verify expected length of entry image */ - if((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) + if ((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) HGOTO_ERROR(H5E_CACHE, H5E_BADSIZE, NULL, "Bad entry image len") /* If parent count greater than zero, allocate array for parent * addresses, and decode addresses into the array. */ - if(pf_entry_ptr->fd_parent_count > 0) { - unsigned u; /* Local index variable */ + if (pf_entry_ptr->fd_parent_count > 0) { + unsigned u; /* Local index variable */ - if(NULL == (pf_entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_malloc((size_t)(pf_entry_ptr->fd_parent_count) * H5F_SIZEOF_ADDR(f)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for fd parent addrs buffer") + if (NULL == (pf_entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_malloc( + (size_t)(pf_entry_ptr->fd_parent_count) * H5F_SIZEOF_ADDR(f)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for fd parent addrs buffer") - for(u = 0; u < pf_entry_ptr->fd_parent_count; u++) { + for (u = 0; u < pf_entry_ptr->fd_parent_count; u++) { H5F_addr_decode(f, &p, &(pf_entry_ptr->fd_parent_addrs[u])); - if(!H5F_addr_defined(pf_entry_ptr->fd_parent_addrs[u])) + if (!H5F_addr_defined(pf_entry_ptr->fd_parent_addrs[u])) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid flush dependency parent offset") } /* end for */ - } /* end if */ + } /* end if */ /* Allocate buffer for entry image */ - if(NULL == (pf_entry_ptr->image_ptr = H5MM_malloc(pf_entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") + if (NULL == (pf_entry_ptr->image_ptr = H5MM_malloc(pf_entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS H5MM_memcpy(((uint8_t *)pf_entry_ptr->image_ptr) + size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ @@ -3447,12 +3406,12 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Initialize the rest of the fields in the prefetched entry */ /* (Only need to set non-zero/NULL/FALSE fields, due to calloc() above) */ - pf_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - pf_entry_ptr->cache_ptr = cache_ptr; - pf_entry_ptr->image_up_to_date = TRUE; - pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY; - pf_entry_ptr->prefetched = TRUE; - pf_entry_ptr->prefetched_dirty = is_dirty && (!file_is_rw); + pf_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + pf_entry_ptr->cache_ptr = cache_ptr; + pf_entry_ptr->image_up_to_date = TRUE; + pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY; + pf_entry_ptr->prefetched = TRUE; + pf_entry_ptr->prefetched_dirty = is_dirty && (!file_is_rw); /* Sanity checks */ HDassert(pf_entry_ptr->size > 0 && pf_entry_ptr->size < H5C_MAX_ENTRY_SIZE); @@ -3463,13 +3422,12 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, ret_value = pf_entry_ptr; done: - if(NULL == ret_value && pf_entry_ptr) + if (NULL == ret_value && pf_entry_ptr) pf_entry_ptr = H5FL_FREE(H5C_cache_entry_t, pf_entry_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5C__reconstruct_cache_entry() */ - /*------------------------------------------------------------------------- * Function: H5C__write_cache_image_superblock_msg * @@ -3490,12 +3448,12 @@ done: static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) { - H5C_t * cache_ptr; - H5O_mdci_t mdci_msg; /* metadata cache image message */ - /* to insert in the superblock */ - /* extension. */ - unsigned mesg_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5O_mdci_t mdci_msg; /* metadata cache image message */ + /* to insert in the superblock */ + /* extension. */ + unsigned mesg_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3514,8 +3472,8 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) */ mdci_msg.addr = cache_ptr->image_addr; #ifdef H5_HAVE_PARALLEL - if(cache_ptr->aux_ptr) { /* we have multiple processes */ - H5AC_aux_t * aux_ptr; + if (cache_ptr->aux_ptr) { /* we have multiple processes */ + H5AC_aux_t *aux_ptr; aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -3526,14 +3484,14 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) mdci_msg.size = cache_ptr->image_len; /* Write metadata cache image message to superblock extension */ - if(H5F__super_ext_write_msg(f, H5O_MDCI_MSG_ID, &mdci_msg, create, mesg_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "can't write metadata cache image message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_MDCI_MSG_ID, &mdci_msg, create, mesg_flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, + "can't write metadata cache image message to superblock extension") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__write_cache_image_superblock_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__write_cache_image * @@ -3550,7 +3508,7 @@ done: static herr_t H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3562,35 +3520,35 @@ H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr) HDassert(cache_ptr->image_buffer); #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; + { + H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; - if((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { - HDassert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); + if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { + HDassert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); #endif /* H5_HAVE_PARALLEL */ - /* Write the buffer (if serial access, or rank 0 for parallel access) */ + /* Write the buffer (if serial access, or rank 0 for parallel access) */ - /* No need to set the page buffer hints here. - * - * If paged allocation is in use, we know that the cache image - * was allocated directly from the free space manager, and thus - * either doesn't cross page boundaries, or is page aligned. - * Thus it should never trigger the sanity checks in the page buffer. - * - * If for some reason it does, the NULL curr_io_type will trigger - * an assertion failure. - * - * JRM -- 3/30/20 - */ - if(H5F_block_write(f, H5FD_MEM_SUPER, cache_ptr->image_addr, cache_ptr->image_len, cache_ptr->image_buffer) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't write metadata cache image block to file") + /* No need to set the page buffer hints here. + * + * If paged allocation is in use, we know that the cache image + * was allocated directly from the free space manager, and thus + * either doesn't cross page boundaries, or is page aligned. + * Thus it should never trigger the sanity checks in the page buffer. + * + * If for some reason it does, the NULL curr_io_type will trigger + * an assertion failure. + * + * JRM -- 3/30/20 + */ + if (H5F_block_write(f, H5FD_MEM_SUPER, cache_ptr->image_addr, cache_ptr->image_len, + cache_ptr->image_buffer) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't write metadata cache image block to file") #ifdef H5_HAVE_PARALLEL - } /* end if */ -} /* end block */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ + } /* end block */ +#endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__write_cache_image() */ - diff --git a/src/H5Clog.c b/src/H5Clog.c index 794d6bb..d48b7b1 100644 --- a/src/H5Clog.c +++ b/src/H5Clog.c @@ -23,55 +23,46 @@ /****************/ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #define H5AC_FRIEND /* Suppress error about including H5ACpkg */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Clog.h" /* Cache logging */ -#include "H5Eprivate.h" /* Error handling */ - +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5C_log_set_up * @@ -87,8 +78,8 @@ herr_t H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately) { - int mpi_rank = -1; /* -1 indicates serial (no MPI rank) */ - herr_t ret_value = SUCCEED; /* Return value */ + int mpi_rank = -1; /* -1 indicates serial (no MPI rank) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -97,24 +88,24 @@ H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, h HDassert(log_location); /* Check logging flags */ - if(cache->log_info->enabled) + if (cache->log_info->enabled) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging already set up") - /* Get the rank when MPI is in use. Logging clients will usually - * use that to create per-process logs. - */ + /* Get the rank when MPI is in use. Logging clients will usually + * use that to create per-process logs. + */ #ifdef H5_HAVE_PARALLEL - if(NULL != cache->aux_ptr) + if (NULL != cache->aux_ptr) mpi_rank = ((H5AC_aux_t *)(cache->aux_ptr))->mpi_rank; #endif /*H5_HAVE_PARALLEL*/ /* Set up logging */ - if(H5C_LOG_STYLE_JSON == style) { - if(H5C_log_json_set_up(cache->log_info, log_location, mpi_rank) < 0) + if (H5C_LOG_STYLE_JSON == style) { + if (H5C_log_json_set_up(cache->log_info, log_location, mpi_rank) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up json logging") } - else if(H5C_LOG_STYLE_TRACE == style) { - if(H5C_log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0) + else if (H5C_LOG_STYLE_TRACE == style) { + if (H5C_log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up trace logging") } else @@ -124,16 +115,15 @@ H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, h cache->log_info->enabled = TRUE; /* Start logging if requested */ - if(start_immediately) - if(H5C_start_logging(cache) < 0) + if (start_immediately) + if (H5C_start_logging(cache) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to start logging") - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_set_up() */ - /*------------------------------------------------------------------------- * Function: H5C_log_tear_down * @@ -149,7 +139,7 @@ H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, h herr_t H5C_log_tear_down(H5C_t *cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -157,27 +147,26 @@ H5C_log_tear_down(H5C_t *cache) HDassert(cache); /* Check logging flags */ - if(FALSE == cache->log_info->enabled) + if (FALSE == cache->log_info->enabled) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") /* Stop logging if that's going on */ - if(cache->log_info->logging) - if(H5C_stop_logging(cache) < 0) + if (cache->log_info->logging) + if (H5C_stop_logging(cache) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to stop logging") /* Tear down logging */ - if(cache->log_info->cls->tear_down_logging) - if(cache->log_info->cls->tear_down_logging(cache->log_info) < 0) + if (cache->log_info->cls->tear_down_logging) + if (cache->log_info->cls->tear_down_logging(cache->log_info) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific tear down call failed") /* Unset logging flags */ cache->log_info->enabled = FALSE; - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_tear_down() */ - /*------------------------------------------------------------------------- * Function: H5C_start_logging * @@ -193,7 +182,7 @@ H5C_log_tear_down(H5C_t *cache) herr_t H5C_start_logging(H5C_t *cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -201,27 +190,26 @@ H5C_start_logging(H5C_t *cache) HDassert(cache); /* Check logging flags */ - if(FALSE == cache->log_info->enabled) + if (FALSE == cache->log_info->enabled) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") /* Start logging */ - if(cache->log_info->cls->start_logging) - if(cache->log_info->cls->start_logging(cache->log_info) < 0) + if (cache->log_info->cls->start_logging) + if (cache->log_info->cls->start_logging(cache->log_info) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific start call failed") /* Set logging flags */ cache->log_info->logging = TRUE; /* Write a log message */ - if(cache->log_info->cls->write_start_log_msg) - if(cache->log_info->cls->write_start_log_msg(cache->log_info->udata) < 0) + if (cache->log_info->cls->write_start_log_msg) + if (cache->log_info->cls->write_start_log_msg(cache->log_info->udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write start call failed") - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_start_logging() */ - /*------------------------------------------------------------------------- * Function: H5C_stop_logging * @@ -237,7 +225,7 @@ H5C_start_logging(H5C_t *cache) herr_t H5C_stop_logging(H5C_t *cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -245,29 +233,28 @@ H5C_stop_logging(H5C_t *cache) HDassert(cache); /* Check logging flags */ - if(FALSE == cache->log_info->enabled) + if (FALSE == cache->log_info->enabled) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") - if(FALSE == cache->log_info->logging) + if (FALSE == cache->log_info->logging) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not in progress") /* Write a log message */ - if(cache->log_info->cls->write_stop_log_msg) - if(cache->log_info->cls->write_stop_log_msg(cache->log_info->udata) < 0) + if (cache->log_info->cls->write_stop_log_msg) + if (cache->log_info->cls->write_stop_log_msg(cache->log_info->udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write stop call failed") /* Stop logging */ - if(cache->log_info->cls->stop_logging) - if(cache->log_info->cls->stop_logging(cache->log_info) < 0) + if (cache->log_info->cls->stop_logging) + if (cache->log_info->cls->stop_logging(cache->log_info) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific stop call failed") /* Set logging flags */ cache->log_info->logging = FALSE; - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_stop_logging() */ - /*------------------------------------------------------------------------- * Function: H5C_get_logging_status * @@ -293,13 +280,12 @@ H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, HDassert(is_currently_logging); /* Get logging flags */ - *is_enabled = cache->log_info->enabled; + *is_enabled = cache->log_info->enabled; *is_currently_logging = cache->log_info->logging; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_get_logging_status() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_create_cache_msg * @@ -315,7 +301,7 @@ H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, herr_t H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -323,8 +309,8 @@ H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value) HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_create_cache_log_msg) - if(cache->log_info->cls->write_create_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + if (cache->log_info->cls->write_create_cache_log_msg) + if (cache->log_info->cls->write_create_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write create cache call failed") done: @@ -350,7 +336,7 @@ done: herr_t H5C_log_write_destroy_cache_msg(H5C_t *cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -358,15 +344,14 @@ H5C_log_write_destroy_cache_msg(H5C_t *cache) HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_destroy_cache_log_msg) - if(cache->log_info->cls->write_destroy_cache_log_msg(cache->log_info->udata) < 0) + if (cache->log_info->cls->write_destroy_cache_log_msg) + if (cache->log_info->cls->write_destroy_cache_log_msg(cache->log_info->udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write destroy cache call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_destroy_cache_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_evict_cache_msg * @@ -390,15 +375,14 @@ H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value) HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_evict_cache_log_msg) - if(cache->log_info->cls->write_evict_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + if (cache->log_info->cls->write_evict_cache_log_msg) + if (cache->log_info->cls->write_evict_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write evict cache call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_evict_cache_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_expunge_entry_msg * @@ -412,8 +396,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, - int type_id, herr_t fxn_ret_value) +H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, int type_id, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -423,15 +406,15 @@ H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_expunge_entry_log_msg) - if(cache->log_info->cls->write_expunge_entry_log_msg(cache->log_info->udata, address, type_id, fxn_ret_value) < 0) + if (cache->log_info->cls->write_expunge_entry_log_msg) + if (cache->log_info->cls->write_expunge_entry_log_msg(cache->log_info->udata, address, type_id, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write expunge entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_expunge_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_flush_cache_msg * @@ -455,15 +438,14 @@ H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value) HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_flush_cache_log_msg) - if(cache->log_info->cls->write_flush_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + if (cache->log_info->cls->write_flush_cache_log_msg) + if (cache->log_info->cls->write_flush_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific flush cache call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_flush_cache_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_insert_entry_msg * @@ -477,8 +459,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, - int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, size_t size, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -488,15 +470,15 @@ H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_insert_entry_log_msg) - if(cache->log_info->cls->write_insert_entry_log_msg(cache->log_info->udata, address, type_id, flags, size, fxn_ret_value) < 0) + if (cache->log_info->cls->write_insert_entry_log_msg) + if (cache->log_info->cls->write_insert_entry_log_msg(cache->log_info->udata, address, type_id, flags, + size, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific insert entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_insert_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_mark_entry_dirty_msg * @@ -510,8 +492,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -522,15 +503,15 @@ H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_mark_entry_dirty_log_msg) - if(cache->log_info->cls->write_mark_entry_dirty_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_mark_entry_dirty_log_msg) + if (cache->log_info->cls->write_mark_entry_dirty_log_msg(cache->log_info->udata, entry, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark dirty entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_mark_entry_dirty_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_mark_entry_clean_msg * @@ -544,10 +525,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -556,15 +536,15 @@ H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_mark_entry_clean_log_msg) - if(cache->log_info->cls->write_mark_entry_clean_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_mark_entry_clean_log_msg) + if (cache->log_info->cls->write_mark_entry_clean_log_msg(cache->log_info->udata, entry, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark clean entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_mark_entry_clean_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_mark_unserialized_entry_msg * @@ -578,8 +558,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, - const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -590,15 +569,15 @@ H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_mark_unserialized_entry_log_msg) - if(cache->log_info->cls->write_mark_unserialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_mark_unserialized_entry_log_msg) + if (cache->log_info->cls->write_mark_unserialized_entry_log_msg(cache->log_info->udata, entry, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark unserialized entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_mark_unserialized_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_mark_serialized_entry_msg * @@ -612,10 +591,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -624,15 +602,15 @@ H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *e /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_mark_serialized_entry_log_msg) - if(cache->log_info->cls->write_mark_serialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_mark_serialized_entry_log_msg) + if (cache->log_info->cls->write_mark_serialized_entry_log_msg(cache->log_info->udata, entry, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark serialized entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_mark_serialized_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_move_entry_msg * @@ -646,8 +624,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, - int type_id, herr_t fxn_ret_value) +H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -657,15 +635,15 @@ H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_move_entry_log_msg) - if(cache->log_info->cls->write_move_entry_log_msg(cache->log_info->udata, old_addr, new_addr, type_id, fxn_ret_value) < 0) + if (cache->log_info->cls->write_move_entry_log_msg) + if (cache->log_info->cls->write_move_entry_log_msg(cache->log_info->udata, old_addr, new_addr, + type_id, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific move entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_move_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_pin_entry_msg * @@ -679,8 +657,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -691,15 +668,14 @@ H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_pin_entry_log_msg) - if(cache->log_info->cls->write_pin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_pin_entry_log_msg) + if (cache->log_info->cls->write_pin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific pin entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_pin_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_create_fd_msg * @@ -714,8 +690,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) +H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -727,15 +703,15 @@ H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, /* Write a log message */ HDassert(parent); HDassert(child); - if(cache->log_info->cls->write_create_fd_log_msg) - if(cache->log_info->cls->write_create_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0) + if (cache->log_info->cls->write_create_fd_log_msg) + if (cache->log_info->cls->write_create_fd_log_msg(cache->log_info->udata, parent, child, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific create fd call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_create_fd_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_protect_entry_msg * @@ -749,8 +725,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, unsigned flags, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -761,15 +737,15 @@ H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_protect_entry_log_msg) - if(cache->log_info->cls->write_protect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, fxn_ret_value) < 0) + if (cache->log_info->cls->write_protect_entry_log_msg) + if (cache->log_info->cls->write_protect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific protect entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_protect_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_resize_entry_msg * @@ -783,8 +759,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - size_t new_size, herr_t fxn_ret_value) +H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -795,15 +771,15 @@ H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_resize_entry_log_msg) - if(cache->log_info->cls->write_resize_entry_log_msg(cache->log_info->udata, entry, new_size, fxn_ret_value) < 0) + if (cache->log_info->cls->write_resize_entry_log_msg) + if (cache->log_info->cls->write_resize_entry_log_msg(cache->log_info->udata, entry, new_size, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific resize entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_resize_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_unpin_entry_msg * @@ -817,8 +793,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -829,15 +804,14 @@ H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_unpin_entry_log_msg) - if(cache->log_info->cls->write_unpin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_unpin_entry_log_msg) + if (cache->log_info->cls->write_unpin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unpin entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_unpin_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_destroy_fd_msg * @@ -852,8 +826,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) +H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -865,15 +839,15 @@ H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, /* Write a log message */ HDassert(parent); HDassert(child); - if(cache->log_info->cls->write_destroy_fd_log_msg) - if(cache->log_info->cls->write_destroy_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0) + if (cache->log_info->cls->write_destroy_fd_log_msg) + if (cache->log_info->cls->write_destroy_fd_log_msg(cache->log_info->udata, parent, child, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific destroy fd call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_destroy_fd_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_unprotect_entry_msg * @@ -887,8 +861,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -898,15 +872,15 @@ H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_unprotect_entry_log_msg) - if(cache->log_info->cls->write_unprotect_entry_log_msg(cache->log_info->udata, address, type_id, flags, fxn_ret_value) < 0) + if (cache->log_info->cls->write_unprotect_entry_log_msg) + if (cache->log_info->cls->write_unprotect_entry_log_msg(cache->log_info->udata, address, type_id, + flags, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unprotect entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_unprotect_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_set_cache_config_msg * @@ -920,8 +894,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, - herr_t fxn_ret_value) +H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -932,15 +905,15 @@ H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *conf /* Write a log message */ HDassert(config); - if(cache->log_info->cls->write_set_cache_config_log_msg) - if(cache->log_info->cls->write_set_cache_config_log_msg(cache->log_info->udata, config, fxn_ret_value) < 0) + if (cache->log_info->cls->write_set_cache_config_log_msg) + if (cache->log_info->cls->write_set_cache_config_log_msg(cache->log_info->udata, config, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific set cache config call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_set_cache_config_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_remove_entry_msg * @@ -954,8 +927,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -966,11 +938,11 @@ H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_remove_entry_log_msg) - if(cache->log_info->cls->write_remove_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_remove_entry_log_msg) + if (cache->log_info->cls->write_remove_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < + 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific remove entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_remove_entry_msg() */ - diff --git a/src/H5Clog.h b/src/H5Clog.h index 0235c4a..e49c453 100644 --- a/src/H5Clog.h +++ b/src/H5Clog.h @@ -19,7 +19,7 @@ #define _H5Clog_H /* Get package's private header */ -#include "H5Cprivate.h" /* Cache */ +#include "H5Cprivate.h" /* Cache */ /**************************/ /* Package Private Macros */ @@ -34,7 +34,7 @@ typedef struct H5C_log_info_t H5C_log_info_t; /* Class for generating logging messages */ typedef struct H5C_log_class_t { - const char *name; /* String for debugging */ + const char *name; /* String for debugging */ /* Callbacks for writing log messages */ herr_t (*tear_down_logging)(H5C_log_info_t *log_info); @@ -47,68 +47,93 @@ typedef struct H5C_log_class_t { herr_t (*write_evict_cache_log_msg)(void *udata, herr_t fxn_ret_value); herr_t (*write_expunge_entry_log_msg)(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); herr_t (*write_flush_cache_log_msg)(void *udata, herr_t fxn_ret_value); - herr_t (*write_insert_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); - herr_t (*write_mark_entry_dirty_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_mark_entry_clean_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_mark_unserialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_mark_serialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_move_entry_log_msg)(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); + herr_t (*write_insert_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, + size_t size, herr_t fxn_ret_value); + herr_t (*write_mark_entry_dirty_log_msg)(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); + herr_t (*write_mark_entry_clean_log_msg)(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); + herr_t (*write_mark_unserialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); + herr_t (*write_mark_serialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); + herr_t (*write_move_entry_log_msg)(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value); herr_t (*write_pin_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_create_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); - herr_t (*write_protect_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); - herr_t (*write_resize_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); + herr_t (*write_create_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); + herr_t (*write_protect_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value); + herr_t (*write_resize_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value); herr_t (*write_unpin_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_destroy_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); - herr_t (*write_unprotect_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value); - herr_t (*write_set_cache_config_log_msg)(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); + herr_t (*write_destroy_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); + herr_t (*write_unprotect_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value); + herr_t (*write_set_cache_config_log_msg)(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value); herr_t (*write_remove_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); } H5C_log_class_t; /* Logging information */ struct H5C_log_info_t { - hbool_t enabled; /* Was the logging set up? */ - hbool_t logging; /* Are we currently logging? */ - H5C_log_class_t *cls; /* Callbacks for writing log messages */ - void *udata; /* Log-specific data */ + hbool_t enabled; /* Was the logging set up? */ + hbool_t logging; /* Are we currently logging? */ + H5C_log_class_t *cls; /* Callbacks for writing log messages */ + void * udata; /* Log-specific data */ }; - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately); +H5_DLL herr_t H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, + hbool_t start_immediately); H5_DLL herr_t H5C_log_tear_down(H5C_t *cache); H5_DLL herr_t H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value); H5_DLL herr_t H5C_log_write_destroy_cache_msg(H5C_t *cache); H5_DLL herr_t H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, int type_id, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, int type_id, + herr_t fxn_ret_value); H5_DLL herr_t H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, + size_t size, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value); H5_DLL herr_t H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); /* Logging-specific setup functions */ H5_DLL herr_t H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); H5_DLL herr_t H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); #endif /* _H5Clog_H */ - diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c index ab25a55..b77ab63 100644 --- a/src/H5Clog_json.c +++ b/src/H5Clog_json.c @@ -24,17 +24,16 @@ /****************/ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Clog.h" /* Cache logging */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -43,12 +42,10 @@ /* Max log message size */ #define H5C_MAX_JSON_LOG_MSG_SIZE 1024 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ @@ -58,7 +55,6 @@ typedef struct H5C_log_json_udata_t { char *message; } H5C_log_json_udata_t; - /********************/ /* Local Prototypes */ /********************/ @@ -73,35 +69,48 @@ static herr_t H5C__json_write_stop_log_msg(void *udata); static herr_t H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value); static herr_t H5C__json_write_destroy_cache_log_msg(void *udata); static herr_t H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value); -static herr_t H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); +static herr_t H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, + herr_t fxn_ret_value); static herr_t H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value); -static herr_t H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); -static herr_t H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); -static herr_t H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -static herr_t H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); -static herr_t H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); -static herr_t H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -static herr_t H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value); -static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); -static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - +static herr_t H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, + size_t size, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value); +static herr_t H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value); +static herr_t H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, + unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value); +static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -109,37 +118,33 @@ static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_ /* Note that there's no cache set up call since that's the * place where this struct is wired into the cache. */ -static H5C_log_class_t H5C_json_log_class_g = { - "json", - H5C__json_tear_down_logging, - NULL, /* start logging */ - NULL, /* stop logging */ - H5C__json_write_start_log_msg, - H5C__json_write_stop_log_msg, - H5C__json_write_create_cache_log_msg, - H5C__json_write_destroy_cache_log_msg, - H5C__json_write_evict_cache_log_msg, - H5C__json_write_expunge_entry_log_msg, - H5C__json_write_flush_cache_log_msg, - H5C__json_write_insert_entry_log_msg, - H5C__json_write_mark_entry_dirty_log_msg, - H5C__json_write_mark_entry_clean_log_msg, - H5C__json_write_mark_unserialized_entry_log_msg, - H5C__json_write_mark_serialized_entry_log_msg, - H5C__json_write_move_entry_log_msg, - H5C__json_write_pin_entry_log_msg, - H5C__json_write_create_fd_log_msg, - H5C__json_write_protect_entry_log_msg, - H5C__json_write_resize_entry_log_msg, - H5C__json_write_unpin_entry_log_msg, - H5C__json_write_destroy_fd_log_msg, - H5C__json_write_unprotect_entry_log_msg, - H5C__json_write_set_cache_config_log_msg, - H5C__json_write_remove_entry_log_msg -}; - - - +static H5C_log_class_t H5C_json_log_class_g = {"json", + H5C__json_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + H5C__json_write_start_log_msg, + H5C__json_write_stop_log_msg, + H5C__json_write_create_cache_log_msg, + H5C__json_write_destroy_cache_log_msg, + H5C__json_write_evict_cache_log_msg, + H5C__json_write_expunge_entry_log_msg, + H5C__json_write_flush_cache_log_msg, + H5C__json_write_insert_entry_log_msg, + H5C__json_write_mark_entry_dirty_log_msg, + H5C__json_write_mark_entry_clean_log_msg, + H5C__json_write_mark_unserialized_entry_log_msg, + H5C__json_write_mark_serialized_entry_log_msg, + H5C__json_write_move_entry_log_msg, + H5C__json_write_pin_entry_log_msg, + H5C__json_write_create_fd_log_msg, + H5C__json_write_protect_entry_log_msg, + H5C__json_write_resize_entry_log_msg, + H5C__json_write_unpin_entry_log_msg, + H5C__json_write_destroy_fd_log_msg, + H5C__json_write_unprotect_entry_log_msg, + H5C__json_write_set_cache_config_log_msg, + H5C__json_write_remove_entry_log_msg}; + /*------------------------------------------------------------------------- * Function: H5C__json_write_log_message * @@ -157,7 +162,7 @@ static herr_t H5C__json_write_log_message(H5C_log_json_udata_t *json_udata) { size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -168,7 +173,7 @@ H5C__json_write_log_message(H5C_log_json_udata_t *json_udata) /* Write the log message and flush */ n_chars = HDstrlen(json_udata->message); - if((int)n_chars != HDfprintf(json_udata->outfile, json_udata->message)) + if ((int)n_chars != HDfprintf(json_udata->outfile, json_udata->message)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message") HDmemset((void *)(json_udata->message), 0, (size_t)(n_chars * sizeof(char))); @@ -176,7 +181,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_log_message() */ - /*------------------------------------------------------------------------- * Function: H5C_log_json_set_up * @@ -205,9 +209,9 @@ herr_t H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) { H5C_log_json_udata_t *json_udata = NULL; - char *file_name = NULL; - size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + char * file_name = NULL; + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -219,12 +223,12 @@ H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi log_info->cls = &H5C_json_log_class_g; /* Allocate memory for the JSON-specific data */ - if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_json_udata_t)))) + if (NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_json_udata_t)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") json_udata = (H5C_log_json_udata_t *)(log_info->udata); /* Allocate memory for the message buffer */ - if(NULL == (json_udata->message = (char *)H5MM_calloc(H5C_MAX_JSON_LOG_MSG_SIZE * sizeof(char)))) + if (NULL == (json_udata->message = (char *)H5MM_calloc(H5C_MAX_JSON_LOG_MSG_SIZE * sizeof(char)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Possibly fix up the log file name. @@ -235,41 +239,41 @@ H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi * allocation size = "RANK_" + + dot + + \0 */ n_chars = 5 + 39 + 1 + HDstrlen(log_location) + 1; - if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + if (NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "can't allocate memory for mdc log file name manipulation") /* Add the rank to the log file name when MPI is in use */ - if(-1 == mpi_rank) + if (-1 == mpi_rank) HDsnprintf(file_name, n_chars, "%s", log_location); else HDsnprintf(file_name, n_chars, "RANK_%d.%s", mpi_rank, log_location); /* Open log file and set it to be unbuffered */ - if(NULL == (json_udata->outfile = HDfopen(file_name, "w"))) + if (NULL == (json_udata->outfile = HDfopen(file_name, "w"))) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file") HDsetbuf(json_udata->outfile, NULL); - done: - if(file_name) +done: + if (file_name) H5MM_xfree(file_name); /* Free and reset the log info struct on errors */ - if(FAIL == ret_value) { + if (FAIL == ret_value) { /* Free */ - if(json_udata && json_udata->message) + if (json_udata && json_udata->message) H5MM_xfree(json_udata->message); - if(json_udata) + if (json_udata) H5MM_xfree(json_udata); /* Reset */ log_info->udata = NULL; - log_info->cls = NULL; + log_info->cls = NULL; } FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_json_set_up() */ - /*------------------------------------------------------------------------- * Function: H5C__json_tear_down_logging * @@ -286,7 +290,7 @@ static herr_t H5C__json_tear_down_logging(H5C_log_info_t *log_info) { H5C_log_json_udata_t *json_udata = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -300,7 +304,7 @@ H5C__json_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(json_udata->message); /* Close log file */ - if(EOF == HDfclose(json_udata->outfile)) + if (EOF == HDfclose(json_udata->outfile)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") json_udata->outfile = NULL; @@ -308,14 +312,13 @@ H5C__json_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(json_udata); /* Reset the log class info and udata */ - log_info->cls = NULL; + log_info->cls = NULL; log_info->udata = NULL; - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_tear_down_logging() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_start_log_msg * @@ -332,7 +335,7 @@ static herr_t H5C__json_write_start_log_msg(void *udata) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -341,26 +344,24 @@ H5C__json_write_start_log_msg(void *udata) HDassert(json_udata->message); /* Create the log message string (opens the JSON array) */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\n\ \"HDF5 metadata cache log messages\" : [\n\ {\ \"timestamp\":%lld,\ \"action\":\"logging start\"\ },\n\ -" - , (long long)HDtime(NULL)); +", + (long long)HDtime(NULL)); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_start_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_stop_log_msg * @@ -377,7 +378,7 @@ static herr_t H5C__json_write_stop_log_msg(void *udata) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -386,25 +387,23 @@ H5C__json_write_stop_log_msg(void *udata) HDassert(json_udata->message); /* Create the log message string (closes the JSON array) */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"logging stop\"\ }\n\ ]}\n\ -" - , (long long)HDtime(NULL)); +", + (long long)HDtime(NULL)); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_stop_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_create_cache_log_msg * @@ -421,7 +420,7 @@ static herr_t H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -430,25 +429,23 @@ H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value) HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"create\",\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); +", + (long long)HDtime(NULL), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_create_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_destroy_cache_log_msg * @@ -465,7 +462,7 @@ static herr_t H5C__json_write_destroy_cache_log_msg(void *udata) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -474,24 +471,22 @@ H5C__json_write_destroy_cache_log_msg(void *udata) HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"destroy\"\ },\n\ -" - , (long long)HDtime(NULL)); +", + (long long)HDtime(NULL)); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_destroy_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_evict_cache_log_msg * @@ -508,7 +503,7 @@ static herr_t H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -517,25 +512,23 @@ H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value) HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"evict\",\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); +", + (long long)HDtime(NULL), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_evict_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_expunge_entry_log_msg * @@ -549,11 +542,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, - int type_id, herr_t fxn_ret_value) +H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -562,8 +554,7 @@ H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"expunge\",\ @@ -571,19 +562,17 @@ H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, \"type_id\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value); - +", + (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_expunge_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_flush_cache_log_msg * @@ -600,7 +589,7 @@ static herr_t H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -609,25 +598,23 @@ H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"flush\",\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); +", + (long long)HDtime(NULL), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_flush_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_insert_entry_log_msg * @@ -641,11 +628,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, - int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -654,8 +641,7 @@ H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"insert\",\ @@ -665,19 +651,18 @@ H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, \"size\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, type_id, flags, - (int)size, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)address, type_id, flags, (int)size, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_insert_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_mark_entry_dirty_log_msg * @@ -691,11 +676,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -705,26 +689,24 @@ H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *e HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"dirty\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_mark_entry_dirty_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_mark_entry_clean_log_msg * @@ -738,11 +720,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -752,26 +733,24 @@ H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *e HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"clean\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_mark_entry_clean_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_mark_unserialized_entry_log_msg * @@ -785,11 +764,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_mark_unserialized_entry_log_msg(void *udata, - const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -799,26 +778,24 @@ H5C__json_write_mark_unserialized_entry_log_msg(void *udata, HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"unserialized\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_mark_unserialized_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_mark_serialize_entry_log_msg * @@ -833,10 +810,10 @@ done: */ static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -846,26 +823,24 @@ H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"serialized\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_mark_serialized_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_move_entry_log_msg * @@ -879,11 +854,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, - int type_id, herr_t fxn_ret_value) +H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -892,8 +867,7 @@ H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_ad HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"move\",\ @@ -902,19 +876,18 @@ H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_ad \"type_id\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)old_addr, - (unsigned long)new_addr, type_id, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)old_addr, (unsigned long)new_addr, type_id, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_move_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_pin_entry_log_msg * @@ -928,11 +901,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -942,27 +914,24 @@ H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"pin\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_pin_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_create_fd_log_msg * @@ -978,10 +947,10 @@ done: */ static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) + const H5C_cache_entry_t *child, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -992,8 +961,7 @@ H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, HDassert(child); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"create_fd\",\ @@ -1001,19 +969,18 @@ H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, \"child_addr\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)parent->addr, - (unsigned long)child->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)parent->addr, (unsigned long)child->addr, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_create_fd_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_protect_entry_log_msg * @@ -1027,12 +994,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - char rw_s[16]; - herr_t ret_value = SUCCEED; + char rw_s[16]; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1041,14 +1008,13 @@ H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entr HDassert(json_udata->message); HDassert(entry); - if(H5C__READ_ONLY_FLAG == flags) + if (H5C__READ_ONLY_FLAG == flags) HDstrcpy(rw_s, "READ"); else HDstrcpy(rw_s, "WRITE"); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"protect\",\ @@ -1058,19 +1024,18 @@ H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entr \"size\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - type_id, rw_s, (int)entry->size, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, type_id, rw_s, (int)entry->size, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_protect_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_resize_entry_log_msg * @@ -1084,11 +1049,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - size_t new_size, herr_t fxn_ret_value) +H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1098,8 +1063,7 @@ H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"resize\",\ @@ -1107,19 +1071,17 @@ H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry \"new_size\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)new_size, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)new_size, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_resize_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_unpin_entry_log_msg * @@ -1133,11 +1095,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1147,27 +1108,24 @@ H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"unpin\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_unpin_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_destroy_fd_log_msg * @@ -1183,10 +1141,10 @@ done: */ static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) + const H5C_cache_entry_t *child, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1197,8 +1155,7 @@ H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, HDassert(child); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"destroy_fd\",\ @@ -1206,19 +1163,18 @@ H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, \"child_addr\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)parent->addr, - (unsigned long)child->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)parent->addr, (unsigned long)child->addr, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_destroy_fd_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_unprotect_entry_log_msg * @@ -1232,11 +1188,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1245,8 +1201,7 @@ H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"unprotect\",\ @@ -1255,19 +1210,17 @@ H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, \"flags\":%x,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, - type_id, flags, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)address, type_id, flags, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_unprotect_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_set_cache_config_log_msg * @@ -1282,10 +1235,10 @@ done: */ static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t H5_ATTR_NDEBUG_UNUSED *config, - herr_t fxn_ret_value) + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1295,26 +1248,23 @@ H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t HDassert(config); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"set_config\",\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); - +", + (long long)HDtime(NULL), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_set_cache_config_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_remove_entry_log_msg * @@ -1328,11 +1278,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1342,23 +1291,20 @@ H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"remove\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_remove_entry_log_msg() */ - diff --git a/src/H5Clog_trace.c b/src/H5Clog_trace.c index 63fe382..002b3f9 100644 --- a/src/H5Clog_trace.c +++ b/src/H5Clog_trace.c @@ -24,17 +24,16 @@ /****************/ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Clog.h" /* Cache logging */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -43,12 +42,10 @@ /* Max log message size */ #define H5C_MAX_TRACE_LOG_MSG_SIZE 4096 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ @@ -58,7 +55,6 @@ typedef struct H5C_log_trace_udata_t { char *message; } H5C_log_trace_udata_t; - /********************/ /* Local Prototypes */ /********************/ @@ -68,35 +64,48 @@ static herr_t H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata); /* Log message callbacks */ static herr_t H5C__trace_tear_down_logging(H5C_log_info_t *log_info); -static herr_t H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); +static herr_t H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, + herr_t fxn_ret_value); static herr_t H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value); -static herr_t H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); -static herr_t H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); -static herr_t H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -static herr_t H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); -static herr_t H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); -static herr_t H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -static herr_t H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value); -static herr_t H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); -static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - +static herr_t H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, + size_t size, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, + int type_id, herr_t fxn_ret_value); +static herr_t H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value); +static herr_t H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, + unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -104,37 +113,33 @@ static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache /* Note that there's no cache set up call since that's the * place where this struct is wired into the cache. */ -static H5C_log_class_t H5C_trace_log_class_g = { - "trace", - H5C__trace_tear_down_logging, - NULL, /* start logging */ - NULL, /* stop logging */ - NULL, /* write start message */ - NULL, /* write stop message */ - NULL, /* write create cache message */ - NULL, /* write destroy cache message */ - NULL, /* write evict cache message */ - H5C__trace_write_expunge_entry_log_msg, - H5C__trace_write_flush_cache_log_msg, - H5C__trace_write_insert_entry_log_msg, - H5C__trace_write_mark_entry_dirty_log_msg, - H5C__trace_write_mark_entry_clean_log_msg, - H5C__trace_write_mark_unserialized_entry_log_msg, - H5C__trace_write_mark_serialized_entry_log_msg, - H5C__trace_write_move_entry_log_msg, - H5C__trace_write_pin_entry_log_msg, - H5C__trace_write_create_fd_log_msg, - H5C__trace_write_protect_entry_log_msg, - H5C__trace_write_resize_entry_log_msg, - H5C__trace_write_unpin_entry_log_msg, - H5C__trace_write_destroy_fd_log_msg, - H5C__trace_write_unprotect_entry_log_msg, - H5C__trace_write_set_cache_config_log_msg, - H5C__trace_write_remove_entry_log_msg -}; - - - +static H5C_log_class_t H5C_trace_log_class_g = {"trace", + H5C__trace_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + NULL, /* write start message */ + NULL, /* write stop message */ + NULL, /* write create cache message */ + NULL, /* write destroy cache message */ + NULL, /* write evict cache message */ + H5C__trace_write_expunge_entry_log_msg, + H5C__trace_write_flush_cache_log_msg, + H5C__trace_write_insert_entry_log_msg, + H5C__trace_write_mark_entry_dirty_log_msg, + H5C__trace_write_mark_entry_clean_log_msg, + H5C__trace_write_mark_unserialized_entry_log_msg, + H5C__trace_write_mark_serialized_entry_log_msg, + H5C__trace_write_move_entry_log_msg, + H5C__trace_write_pin_entry_log_msg, + H5C__trace_write_create_fd_log_msg, + H5C__trace_write_protect_entry_log_msg, + H5C__trace_write_resize_entry_log_msg, + H5C__trace_write_unpin_entry_log_msg, + H5C__trace_write_destroy_fd_log_msg, + H5C__trace_write_unprotect_entry_log_msg, + H5C__trace_write_set_cache_config_log_msg, + H5C__trace_write_remove_entry_log_msg}; + /*------------------------------------------------------------------------- * Function: H5C__trace_write_log_message * @@ -152,7 +157,7 @@ static herr_t H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata) { size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -163,7 +168,7 @@ H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata) /* Write the log message and flush */ n_chars = HDstrlen(trace_udata->message); - if((int)n_chars != HDfprintf(trace_udata->outfile, trace_udata->message)) + if ((int)n_chars != HDfprintf(trace_udata->outfile, trace_udata->message)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message") HDmemset((void *)(trace_udata->message), 0, (size_t)(n_chars * sizeof(char))); @@ -171,7 +176,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_log_message() */ - /*------------------------------------------------------------------------- * Function: H5C_log_trace_set_up * @@ -200,9 +204,9 @@ herr_t H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) { H5C_log_trace_udata_t *trace_udata = NULL; - char *file_name = NULL; - size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + char * file_name = NULL; + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -214,12 +218,12 @@ H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mp log_info->cls = &H5C_trace_log_class_g; /* Allocate memory for the JSON-specific data */ - if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_trace_udata_t)))) + if (NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_trace_udata_t)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") trace_udata = (H5C_log_trace_udata_t *)(log_info->udata); /* Allocate memory for the message buffer */ - if(NULL == (trace_udata->message = (char *)H5MM_calloc(H5C_MAX_TRACE_LOG_MSG_SIZE * sizeof(char)))) + if (NULL == (trace_udata->message = (char *)H5MM_calloc(H5C_MAX_TRACE_LOG_MSG_SIZE * sizeof(char)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Possibly fix up the log file name. @@ -230,44 +234,44 @@ H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mp * allocation size = + dot + + \0 */ n_chars = HDstrlen(log_location) + 1 + 39 + 1; - if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + if (NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "can't allocate memory for mdc log file name manipulation") /* Add the rank to the log file name when MPI is in use */ - if(-1 == mpi_rank) + if (-1 == mpi_rank) HDsnprintf(file_name, n_chars, "%s", log_location); else HDsnprintf(file_name, n_chars, "%s.%d", log_location, mpi_rank); /* Open log file and set it to be unbuffered */ - if(NULL == (trace_udata->outfile = HDfopen(file_name, "w"))) + if (NULL == (trace_udata->outfile = HDfopen(file_name, "w"))) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file") HDsetbuf(trace_udata->outfile, NULL); /* Write the header */ HDfprintf(trace_udata->outfile, "### HDF5 metadata cache trace file version 1 ###\n"); - done: - if(file_name) +done: + if (file_name) H5MM_xfree(file_name); /* Free and reset the log info struct on errors */ - if(FAIL == ret_value) { + if (FAIL == ret_value) { /* Free */ - if(trace_udata && trace_udata->message) + if (trace_udata && trace_udata->message) H5MM_xfree(trace_udata->message); - if(trace_udata) + if (trace_udata) H5MM_xfree(trace_udata); /* Reset */ log_info->udata = NULL; - log_info->cls = NULL; + log_info->cls = NULL; } FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_trace_set_up() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_tear_down_logging * @@ -284,7 +288,7 @@ static herr_t H5C__trace_tear_down_logging(H5C_log_info_t *log_info) { H5C_log_trace_udata_t *trace_udata = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -298,7 +302,7 @@ H5C__trace_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(trace_udata->message); /* Close log file */ - if(EOF == HDfclose(trace_udata->outfile)) + if (EOF == HDfclose(trace_udata->outfile)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") trace_udata->outfile = NULL; @@ -306,14 +310,13 @@ H5C__trace_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(trace_udata); /* Reset the log class info and udata */ - log_info->cls = NULL; + log_info->cls = NULL; log_info->udata = NULL; - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_tear_down_logging() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_expunge_entry_log_msg * @@ -327,11 +330,10 @@ H5C__trace_tear_down_logging(H5C_log_info_t *log_info) *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, - int type_id, herr_t fxn_ret_value) +H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -341,17 +343,16 @@ H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_expunge_entry 0x%lx %d %d\n", - (unsigned long)address, type_id, (int)fxn_ret_value); + (unsigned long)address, type_id, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_expunge_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_flush_cache_log_msg * @@ -368,7 +369,7 @@ static herr_t H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -377,18 +378,16 @@ H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) HDassert(trace_udata->message); /* Create the log message string */ - HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_flush %d\n", - (int)fxn_ret_value); + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_flush %d\n", (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_flush_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_insert_entry_log_msg * @@ -402,11 +401,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, - int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -416,17 +415,16 @@ H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_insert_entry 0x%lx %d 0x%x %d %d\n", - (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value); + (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_insert_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_mark_entry_dirty_log_msg * @@ -440,11 +438,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -455,17 +452,16 @@ H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t * /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_dirty 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_mark_entry_dirty_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_mark_entry_clean_log_msg * @@ -479,11 +475,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -494,17 +489,16 @@ H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t * /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_clean 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_mark_entry_clean_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_mark_unserialized_entry_log_msg * @@ -518,11 +512,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, - const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -533,17 +527,16 @@ H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_unserialized 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_mark_unserialized_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_mark_serialized_entry_log_msg * @@ -558,10 +551,10 @@ done: */ static herr_t H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -572,17 +565,16 @@ H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entr /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_serialized 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_mark_serialized_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_move_entry_log_msg * @@ -596,11 +588,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, - int type_id, herr_t fxn_ret_value) +H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -610,17 +602,16 @@ H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_a /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_move_entry 0x%lx 0x%lx %d %d\n", - (unsigned long)old_addr, (unsigned long)new_addr, type_id, (int)fxn_ret_value); + (unsigned long)old_addr, (unsigned long)new_addr, type_id, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_move_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_pin_entry_log_msg * @@ -634,11 +625,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -649,17 +639,16 @@ H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_pin_protected_entry 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_pin_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_create_fd_log_msg * @@ -675,10 +664,10 @@ done: */ static herr_t H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) + const H5C_cache_entry_t *child, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -689,18 +678,18 @@ H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, HDassert(child); /* Create the log message string */ - HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_create_flush_dependency 0x%lx 0x%lx %d\n", - (unsigned long)(parent->addr), (unsigned long)(child->addr), (int)fxn_ret_value); + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, + "H5AC_create_flush_dependency 0x%lx 0x%lx %d\n", (unsigned long)(parent->addr), + (unsigned long)(child->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_create_fd_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_protect_entry_log_msg * @@ -714,11 +703,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -729,17 +718,16 @@ H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *ent /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_protect 0x%lx %d 0x%x %d %d\n", - (unsigned long)(entry->addr), type_id, flags, (int)(entry->size), (int)fxn_ret_value); + (unsigned long)(entry->addr), type_id, flags, (int)(entry->size), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_protect_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_resize_entry_log_msg * @@ -753,11 +741,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - size_t new_size, herr_t fxn_ret_value) +H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -768,17 +756,16 @@ H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entr /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_resize_entry 0x%lx %d %d\n", - (unsigned long)(entry->addr), (int)new_size, (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)new_size, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_resize_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_unpin_entry_log_msg * @@ -792,11 +779,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -807,17 +793,16 @@ H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_unpin_entry 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_unpin_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_destroy_fd_log_msg * @@ -833,10 +818,10 @@ done: */ static herr_t H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) + const H5C_cache_entry_t *child, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -847,18 +832,18 @@ H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent HDassert(child); /* Create the log message string */ - HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_destroy_flush_dependency 0x%lx 0x%lx %d\n", - (unsigned long)(parent->addr), (unsigned long)(child->addr), (int)fxn_ret_value); + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, + "H5AC_destroy_flush_dependency 0x%lx 0x%lx %d\n", (unsigned long)(parent->addr), + (unsigned long)(child->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_destroy_fd_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_unprotect_entry_log_msg * @@ -872,11 +857,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -886,17 +871,16 @@ H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_unprotect 0x%lx %d 0x%x %d\n", - (unsigned long)(address), type_id, flags, (int)fxn_ret_value); + (unsigned long)(address), type_id, flags, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_unprotect_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_set_cache_config_log_msg * @@ -911,10 +895,10 @@ done: */ static herr_t H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, - herr_t fxn_ret_value) + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -925,48 +909,28 @@ H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, - "H5AC_set_cache_auto_resize_config %d %d %d %d \"%s\" %d %d %d %f %d %d %ld %d %f %f %d %f %f %d %d %d %f %f %d %d %d %d %f %zu %d %d\n", - config->version, - (int)(config->rpt_fcn_enabled), - (int)(config->open_trace_file), - (int)(config->close_trace_file), - config->trace_file_name, - (int)(config->evictions_enabled), - (int)(config->set_initial_size), - (int)(config->initial_size), - config->min_clean_fraction, - (int)(config->max_size), - (int)(config->min_size), - config->epoch_length, - (int)(config->incr_mode), - config->lower_hr_threshold, - config->increment, - (int)(config->flash_incr_mode), - config->flash_multiple, - config->flash_threshold, - (int)(config->apply_max_increment), - (int)(config->max_increment), - (int)(config->decr_mode), - config->upper_hr_threshold, - config->decrement, - (int)(config->apply_max_decrement), - (int)(config->max_decrement), - config->epochs_before_eviction, - (int)(config->apply_empty_reserve), - config->empty_reserve, - config->dirty_bytes_threshold, - config->metadata_write_strategy, - (int)fxn_ret_value); + "H5AC_set_cache_auto_resize_config %d %d %d %d \"%s\" %d %d %d %f %d %d %ld %d %f %f %d %f %f " + "%d %d %d %f %f %d %d %d %d %f %zu %d %d\n", + config->version, (int)(config->rpt_fcn_enabled), (int)(config->open_trace_file), + (int)(config->close_trace_file), config->trace_file_name, (int)(config->evictions_enabled), + (int)(config->set_initial_size), (int)(config->initial_size), config->min_clean_fraction, + (int)(config->max_size), (int)(config->min_size), config->epoch_length, + (int)(config->incr_mode), config->lower_hr_threshold, config->increment, + (int)(config->flash_incr_mode), config->flash_multiple, config->flash_threshold, + (int)(config->apply_max_increment), (int)(config->max_increment), (int)(config->decr_mode), + config->upper_hr_threshold, config->decrement, (int)(config->apply_max_decrement), + (int)(config->max_decrement), config->epochs_before_eviction, + (int)(config->apply_empty_reserve), config->empty_reserve, config->dirty_bytes_threshold, + config->metadata_write_strategy, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_set_cache_config_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_remove_entry_log_msg * @@ -980,11 +944,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -995,13 +958,12 @@ H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entr /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_remove_entry 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_remove_entry_log_msg() */ - diff --git a/src/H5Cmodule.h b/src/H5Cmodule.h index 534404d..ecd9921 100644 --- a/src/H5Cmodule.h +++ b/src/H5Cmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5C_MODULE -#define H5_MY_PKG H5C -#define H5_MY_PKG_ERR H5E_CACHE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5C +#define H5_MY_PKG_ERR H5E_CACHE +#define H5_MY_PKG_INIT NO #endif /* _H5Cmodule_H */ - diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 16db2ad..2f60a3c 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -27,22 +27,20 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_PARALLEL /****************/ @@ -50,38 +48,31 @@ /****************/ #define H5C_APPLY_CANDIDATE_LIST__DEBUG 0 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5C__collective_write(H5F_t *f); static herr_t H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES], - unsigned entries_to_clear[H5C_RING_NTYPES]); -static herr_t H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, - unsigned entries_to_flush, unsigned entries_to_clear); - + unsigned entries_to_clear[H5C_RING_NTYPES]); +static herr_t H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flush, + unsigned entries_to_clear); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5C_apply_candidate_list * @@ -166,33 +157,29 @@ static herr_t H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, *------------------------------------------------------------------------- */ herr_t -H5C_apply_candidate_list(H5F_t * f, - H5C_t * cache_ptr, - unsigned num_candidates, - haddr_t * candidates_list_ptr, - int mpi_rank, - int mpi_size) +H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, haddr_t *candidates_list_ptr, + int mpi_rank, int mpi_size) { - int i; - int m; - unsigned n; - unsigned first_entry_to_flush; - unsigned last_entry_to_flush; - unsigned total_entries_to_clear = 0; - unsigned total_entries_to_flush = 0; - unsigned * candidate_assignment_table = NULL; - unsigned entries_to_flush[H5C_RING_NTYPES]; - unsigned entries_to_clear[H5C_RING_NTYPES]; - haddr_t addr; - H5C_cache_entry_t * entry_ptr = NULL; + int i; + int m; + unsigned n; + unsigned first_entry_to_flush; + unsigned last_entry_to_flush; + unsigned total_entries_to_clear = 0; + unsigned total_entries_to_flush = 0; + unsigned * candidate_assignment_table = NULL; + unsigned entries_to_flush[H5C_RING_NTYPES]; + unsigned entries_to_clear[H5C_RING_NTYPES]; + haddr_t addr; + H5C_cache_entry_t *entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS - haddr_t last_addr; + haddr_t last_addr; #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_APPLY_CANDIDATE_LIST__DEBUG - char tbl_buf[1024]; -#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + char tbl_buf[1024]; +#endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -215,93 +202,95 @@ H5C_apply_candidate_list(H5F_t * f, HDmemset(tbl_buf, 0, sizeof(tbl_buf)); HDsprintf(&(tbl_buf[0]), "candidate list = "); - for(u = 0; u < num_candidates; u++) + for (u = 0; u < num_candidates; u++) HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " 0x%llx", (long long)(*(candidates_list_ptr + u))); HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n"); HDfprintf(stdout, "%s", tbl_buf); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - if(f->shared->coll_md_write) { + if (f->shared->coll_md_write) { /* Sanity check */ HDassert(NULL == cache_ptr->coll_write_list); /* Create skip list of entries for collective write */ - if(NULL == (cache_ptr->coll_write_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (cache_ptr->coll_write_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for entries") } /* end if */ n = num_candidates / (unsigned)mpi_size; - if(num_candidates % (unsigned)mpi_size > INT_MAX) + if (num_candidates % (unsigned)mpi_size > INT_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "m overflow") m = (int)(num_candidates % (unsigned)mpi_size); - if(NULL == (candidate_assignment_table = (unsigned *)H5MM_malloc(sizeof(unsigned) * (size_t)(mpi_size + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for candidate assignment table") + if (NULL == + (candidate_assignment_table = (unsigned *)H5MM_malloc(sizeof(unsigned) * (size_t)(mpi_size + 1)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for candidate assignment table") - candidate_assignment_table[0] = 0; + candidate_assignment_table[0] = 0; candidate_assignment_table[mpi_size] = num_candidates; - if(m == 0) { /* mpi_size is an even divisor of num_candidates */ - for(i = 1; i < mpi_size; i++) + if (m == 0) { /* mpi_size is an even divisor of num_candidates */ + for (i = 1; i < mpi_size; i++) candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n; } /* end if */ else { - for(i = 1; i <= m; i++) + for (i = 1; i <= m; i++) candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n + 1; - if(num_candidates < (unsigned)mpi_size) { - for(i = m + 1; i < mpi_size; i++) + if (num_candidates < (unsigned)mpi_size) { + for (i = m + 1; i < mpi_size; i++) candidate_assignment_table[i] = num_candidates; } /* end if */ else { - for(i = m + 1; i < mpi_size; i++) + for (i = m + 1; i < mpi_size; i++) candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n; } /* end else */ - } /* end else */ + } /* end else */ HDassert((candidate_assignment_table[mpi_size - 1] + n) == num_candidates); #if H5C_DO_SANITY_CHECKS /* Verify that the candidate assignment table has the expected form */ - for(i = 1; i < mpi_size - 1; i++) { + for (i = 1; i < mpi_size - 1; i++) { unsigned a, b; a = candidate_assignment_table[i] - candidate_assignment_table[i - 1]; b = candidate_assignment_table[i + 1] - candidate_assignment_table[i]; - HDassert( n + 1 >= a ); - HDassert( a >= b ); - HDassert( b >= n ); + HDassert(n + 1 >= a); + HDassert(a >= b); + HDassert(b >= n); } #endif /* H5C_DO_SANITY_CHECKS */ first_entry_to_flush = candidate_assignment_table[mpi_rank]; - last_entry_to_flush = candidate_assignment_table[mpi_rank + 1] - 1; + last_entry_to_flush = candidate_assignment_table[mpi_rank + 1] - 1; #if H5C_APPLY_CANDIDATE_LIST__DEBUG - for ( i = 0; i < 1024; i++ ) + for (i = 0; i < 1024; i++) tbl_buf[i] = '\0'; HDsprintf(&(tbl_buf[0]), "candidate assignment table = "); - for(i = 0; i <= mpi_size; i++) + for (i = 0; i <= mpi_size; i++) HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %u", candidate_assignment_table[i]); HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n"); HDfprintf(stdout, "%s", tbl_buf); - HDfprintf(stdout, "%s:%d: flush entries [%u, %u].\n", - FUNC, mpi_rank, first_entry_to_flush, last_entry_to_flush); + HDfprintf(stdout, "%s:%d: flush entries [%u, %u].\n", FUNC, mpi_rank, first_entry_to_flush, + last_entry_to_flush); HDfprintf(stdout, "%s:%d: marking entries.\n", FUNC, mpi_rank); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - for(u = 0; u < num_candidates; u++) { + for (u = 0; u < num_candidates; u++) { addr = candidates_list_ptr[u]; HDassert(H5F_addr_defined(addr)); #if H5C_DO_SANITY_CHECKS - if(u > 0) { - if(last_addr == addr) + if (u > 0) { + if (last_addr == addr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "duplicate entry in cleaned list") - else if(last_addr > addr) + else if (last_addr > addr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "candidate list not sorted") } /* end if */ @@ -309,11 +298,11 @@ H5C_apply_candidate_list(H5F_t * f, #endif /* H5C_DO_SANITY_CHECKS */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) + if (entry_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "listed candidate entry not in cache?!?!?") - if(!entry_ptr->is_dirty) + if (!entry_ptr->is_dirty) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Listed entry not dirty?!?!?") - if(entry_ptr->is_protected) + if (entry_ptr->is_protected) /* For now at least, we can't deal with protected entries. * If we encounter one, scream and die. If it becomes an * issue, we should be able to work around this. @@ -332,7 +321,7 @@ H5C_apply_candidate_list(H5F_t * f, * pinned list shortly, and clear or flush according to these * markings. */ - if(u >= first_entry_to_flush && u <= last_entry_to_flush) { + if (u >= first_entry_to_flush && u <= last_entry_to_flush) { total_entries_to_flush++; entries_to_flush[entry_ptr->ring]++; entry_ptr->flush_immediately = TRUE; @@ -349,16 +338,16 @@ H5C_apply_candidate_list(H5F_t * f, * candidate list is collective and uniform across all * ranks. */ - if(entry_ptr->coll_access) { + if (entry_ptr->coll_access) { entry_ptr->coll_access = FALSE; H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) } /* end if */ - } /* end for */ + } /* end for */ #if H5C_DO_SANITY_CHECKS m = 0; n = 0; - for(i = 0; i < H5C_RING_NTYPES; i++) { + for (i = 0; i < H5C_RING_NTYPES; i++) { m += (int)entries_to_flush[i]; n += entries_to_clear[i]; } /* end if */ @@ -368,9 +357,8 @@ H5C_apply_candidate_list(H5F_t * f, #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_APPLY_CANDIDATE_LIST__DEBUG - HDfprintf(stdout, "%s:%d: num candidates/to clear/to flush = %u/%u/%u.\n", - FUNC, mpi_rank, num_candidates, total_entries_to_clear, - total_entries_to_flush); + HDfprintf(stdout, "%s:%d: num candidates/to clear/to flush = %u/%u/%u.\n", FUNC, mpi_rank, num_candidates, + total_entries_to_clear, total_entries_to_flush); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ /* We have now marked all the entries on the candidate list for @@ -383,24 +371,24 @@ H5C_apply_candidate_list(H5F_t * f, * If we don't do this, my experiments indicate that we will have a * noticeably poorer hit ratio as a result. */ - if(H5C__flush_candidate_entries(f, entries_to_flush, entries_to_clear) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush candidates failed") + if (H5C__flush_candidate_entries(f, entries_to_flush, entries_to_clear) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush candidates failed") /* If we've deferred writing to do it collectively, take care of that now */ - if(f->shared->coll_md_write) { + if (f->shared->coll_md_write) { /* Sanity check */ HDassert(cache_ptr->coll_write_list); /* Write collective list */ - if(H5C__collective_write(f) < 0) + if (H5C__collective_write(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "can't write metadata collectively") } /* end if */ done: - if(candidate_assignment_table != NULL) + if (candidate_assignment_table != NULL) candidate_assignment_table = (unsigned *)H5MM_xfree((void *)candidate_assignment_table); - if(cache_ptr->coll_write_list) { - if(H5SL_close(cache_ptr->coll_write_list) < 0) + if (cache_ptr->coll_write_list) { + if (H5SL_close(cache_ptr->coll_write_list) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "failed to destroy skip list") cache_ptr->coll_write_list = NULL; } /* end if */ @@ -408,7 +396,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_apply_candidate_list() */ - /*------------------------------------------------------------------------- * Function: H5C_construct_candidate_list__clean_cache * @@ -428,15 +415,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) +H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr) { - size_t space_needed; - herr_t ret_value = SUCCEED; /* Return value */ + size_t space_needed; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( cache_ptr != NULL ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* As a sanity check, set space needed to the size of the skip list. * This should be the sum total of the sizes of all the dirty entries @@ -448,58 +435,54 @@ H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) * point, it is possible that some dirty entries may reside on the * pinned list at this point. */ - HDassert( cache_ptr->slist_size <= - (cache_ptr->dLRU_list_size + cache_ptr->pel_size) ); - HDassert( cache_ptr->slist_len <= - (cache_ptr->dLRU_list_len + cache_ptr->pel_len) ); + HDassert(cache_ptr->slist_size <= (cache_ptr->dLRU_list_size + cache_ptr->pel_size)); + HDassert(cache_ptr->slist_len <= (cache_ptr->dLRU_list_len + cache_ptr->pel_len)); - if(space_needed > 0) { /* we have work to do */ + if (space_needed > 0) { /* we have work to do */ H5C_cache_entry_t *entry_ptr; - unsigned nominated_entries_count = 0; - size_t nominated_entries_size = 0; - haddr_t nominated_addr; + unsigned nominated_entries_count = 0; + size_t nominated_entries_size = 0; + haddr_t nominated_addr; - HDassert( cache_ptr->slist_len > 0 ); + HDassert(cache_ptr->slist_len > 0); /* Scan the dirty LRU list from tail forward and nominate sufficient * entries to free up the necessary space. */ entry_ptr = cache_ptr->dLRU_tail_ptr; - while((nominated_entries_size < space_needed) && - (nominated_entries_count < cache_ptr->slist_len) && - (entry_ptr != NULL)) { - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( entry_ptr->ro_ref_count == 0 ); - HDassert( entry_ptr->is_dirty ); - HDassert( entry_ptr->in_slist ); + while ((nominated_entries_size < space_needed) && (nominated_entries_count < cache_ptr->slist_len) && + (entry_ptr != NULL)) { + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert(entry_ptr->ro_ref_count == 0); + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->in_slist); nominated_addr = entry_ptr->addr; - if(H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) + if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; nominated_entries_count++; entry_ptr = entry_ptr->aux_prev; } /* end while */ - HDassert( entry_ptr == NULL ); + HDassert(entry_ptr == NULL); /* it is possible that there are some dirty entries on the * protected entry list as well -- scan it too if necessary */ entry_ptr = cache_ptr->pel_head_ptr; - while((nominated_entries_size < space_needed) && - (nominated_entries_count < cache_ptr->slist_len) && - (entry_ptr != NULL)) { - if(entry_ptr->is_dirty) { - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( entry_ptr->ro_ref_count == 0 ); - HDassert( entry_ptr->is_dirty ); - HDassert( entry_ptr->in_slist ); + while ((nominated_entries_size < space_needed) && (nominated_entries_count < cache_ptr->slist_len) && + (entry_ptr != NULL)) { + if (entry_ptr->is_dirty) { + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert(entry_ptr->ro_ref_count == 0); + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->in_slist); nominated_addr = entry_ptr->addr; - if(H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) + if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; @@ -509,15 +492,14 @@ H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) entry_ptr = entry_ptr->next; } /* end while */ - HDassert( nominated_entries_count == cache_ptr->slist_len ); - HDassert( nominated_entries_size == space_needed ); + HDassert(nominated_entries_count == cache_ptr->slist_len); + HDassert(nominated_entries_size == space_needed); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_construct_candidate_list__clean_cache() */ - /*------------------------------------------------------------------------- * Function: H5C_construct_candidate_list__min_clean * @@ -537,76 +519,71 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_construct_candidate_list__min_clean(H5C_t * cache_ptr) +H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr) { - size_t space_needed = 0; - herr_t ret_value = SUCCEED; /* Return value */ + size_t space_needed = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( cache_ptr != NULL ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* compute the number of bytes (if any) that must be flushed to get the * cache back within its min clean constraints. */ - if(cache_ptr->max_cache_size > cache_ptr->index_size) { - if(((cache_ptr->max_cache_size - cache_ptr->index_size) + - cache_ptr->cLRU_list_size) >= cache_ptr->min_clean_size) + if (cache_ptr->max_cache_size > cache_ptr->index_size) { + if (((cache_ptr->max_cache_size - cache_ptr->index_size) + cache_ptr->cLRU_list_size) >= + cache_ptr->min_clean_size) space_needed = 0; else space_needed = cache_ptr->min_clean_size - - ((cache_ptr->max_cache_size - cache_ptr->index_size) + - cache_ptr->cLRU_list_size); + ((cache_ptr->max_cache_size - cache_ptr->index_size) + cache_ptr->cLRU_list_size); } /* end if */ else { - if(cache_ptr->min_clean_size <= cache_ptr->cLRU_list_size) - space_needed = 0; + if (cache_ptr->min_clean_size <= cache_ptr->cLRU_list_size) + space_needed = 0; else - space_needed = cache_ptr->min_clean_size - - cache_ptr->cLRU_list_size; + space_needed = cache_ptr->min_clean_size - cache_ptr->cLRU_list_size; } /* end else */ - if(space_needed > 0) { /* we have work to do */ + if (space_needed > 0) { /* we have work to do */ H5C_cache_entry_t *entry_ptr; - unsigned nominated_entries_count = 0; - size_t nominated_entries_size = 0; + unsigned nominated_entries_count = 0; + size_t nominated_entries_size = 0; - HDassert( cache_ptr->slist_len > 0 ); + HDassert(cache_ptr->slist_len > 0); /* Scan the dirty LRU list from tail forward and nominate sufficient * entries to free up the necessary space. */ entry_ptr = cache_ptr->dLRU_tail_ptr; - while((nominated_entries_size < space_needed) && - (nominated_entries_count < cache_ptr->slist_len) && - (entry_ptr != NULL) && - (!entry_ptr->flush_me_last)) { + while ((nominated_entries_size < space_needed) && (nominated_entries_count < cache_ptr->slist_len) && + (entry_ptr != NULL) && (!entry_ptr->flush_me_last)) { haddr_t nominated_addr; - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( entry_ptr->ro_ref_count == 0 ); - HDassert( entry_ptr->is_dirty ); - HDassert( entry_ptr->in_slist ); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert(entry_ptr->ro_ref_count == 0); + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->in_slist); nominated_addr = entry_ptr->addr; - if(H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) + if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; nominated_entries_count++; entry_ptr = entry_ptr->aux_prev; } /* end while */ - HDassert( nominated_entries_count <= cache_ptr->slist_len ); - HDassert( nominated_entries_size >= space_needed ); + HDassert(nominated_entries_count <= cache_ptr->slist_len); + HDassert(nominated_entries_size >= space_needed); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_construct_candidate_list__min_clean() */ - /*------------------------------------------------------------------------- * * Function: H5C_mark_entries_as_clean @@ -639,85 +616,76 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_mark_entries_as_clean(H5F_t * f, - unsigned ce_array_len, - haddr_t * ce_array_ptr) +H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr) { - H5C_t * cache_ptr; - unsigned entries_cleared; - unsigned pinned_entries_cleared; - hbool_t progress; - unsigned entries_examined; - unsigned initial_list_len; - haddr_t addr; - unsigned pinned_entries_marked = 0; + H5C_t * cache_ptr; + unsigned entries_cleared; + unsigned pinned_entries_cleared; + hbool_t progress; + unsigned entries_examined; + unsigned initial_list_len; + haddr_t addr; + unsigned pinned_entries_marked = 0; #if H5C_DO_SANITY_CHECKS - unsigned protected_entries_marked = 0; - unsigned other_entries_marked = 0; - haddr_t last_addr; + unsigned protected_entries_marked = 0; + unsigned other_entries_marked = 0; + haddr_t last_addr; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_cache_entry_t * clear_ptr = NULL; - H5C_cache_entry_t * entry_ptr = NULL; - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *clear_ptr = NULL; + H5C_cache_entry_t *entry_ptr = NULL; + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert( ce_array_len > 0 ); - HDassert( ce_array_ptr != NULL ); + HDassert(ce_array_len > 0); + HDassert(ce_array_ptr != NULL); #if H5C_DO_EXTREME_SANITY_CHECKS - if(H5C_validate_protected_entry_list(cache_ptr) < 0 || - H5C_validate_pinned_entry_list(cache_ptr) < 0 || - H5C_validate_lru_list(cache_ptr) < 0) + if (H5C_validate_protected_entry_list(cache_ptr) < 0 || H5C_validate_pinned_entry_list(cache_ptr) < 0 || + H5C_validate_lru_list(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - for(u = 0; u < ce_array_len; u++) { + for (u = 0; u < ce_array_len; u++) { addr = ce_array_ptr[u]; #if H5C_DO_SANITY_CHECKS - if(u == 0) + if (u == 0) last_addr = addr; else { - if(last_addr == addr) + if (last_addr == addr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Duplicate entry in cleaned list") - if(last_addr > addr) + if (last_addr > addr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "cleaned list not sorted") } /* end else */ #if H5C_DO_EXTREME_SANITY_CHECKS - if(H5C_validate_protected_entry_list(cache_ptr) < 0 - || H5C_validate_pinned_entry_list(cache_ptr) < 0 - || H5C_validate_lru_list(cache_ptr) < 0) + if (H5C_validate_protected_entry_list(cache_ptr) < 0 || + H5C_validate_pinned_entry_list(cache_ptr) < 0 || H5C_validate_lru_list(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed in for loop") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ #endif /* H5C_DO_SANITY_CHECKS */ - HDassert( H5F_addr_defined(addr) ); + HDassert(H5F_addr_defined(addr)); H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) { + if (entry_ptr == NULL) { #if H5C_DO_SANITY_CHECKS - HDfprintf(stdout, - "H5C_mark_entries_as_clean: entry[%u] = %a not in cache.\n", - u, - addr); + HDfprintf(stdout, "H5C_mark_entries_as_clean: entry[%u] = %a not in cache.\n", u, addr); #endif /* H5C_DO_SANITY_CHECKS */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Listed entry not in cache?!?!?") } /* end if */ - else if(!entry_ptr->is_dirty) { + else if (!entry_ptr->is_dirty) { #if H5C_DO_SANITY_CHECKS - HDfprintf(stdout, - "H5C_mark_entries_as_clean: entry %a is not dirty!?!\n", - addr); + HDfprintf(stdout, "H5C_mark_entries_as_clean: entry %a is not dirty!?!\n", addr); #endif /* H5C_DO_SANITY_CHECKS */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Listed entry not dirty?!?!?") } /* end else-if */ @@ -729,16 +697,16 @@ H5C_mark_entries_as_clean(H5F_t * f, /* Make sure first that we clear the collective flag from it so it can be cleared */ - if(TRUE == entry_ptr->coll_access) { + if (TRUE == entry_ptr->coll_access) { entry_ptr->coll_access = FALSE; H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) } /* end if */ entry_ptr->clear_on_unprotect = TRUE; - if(entry_ptr->is_pinned) + if (entry_ptr->is_pinned) pinned_entries_marked++; #if H5C_DO_SANITY_CHECKS - else if(entry_ptr->is_protected) + else if (entry_ptr->is_protected) protected_entries_marked++; else other_entries_marked++; @@ -771,20 +739,20 @@ H5C_mark_entries_as_clean(H5F_t * f, * point. * JRM -- 4/7/15 */ - entries_cleared = 0; + entries_cleared = 0; entries_examined = 0; initial_list_len = cache_ptr->LRU_list_len; - entry_ptr = cache_ptr->LRU_tail_ptr; - while(entry_ptr != NULL && entries_examined <= initial_list_len && - entries_cleared < ce_array_len) { - if(entry_ptr->clear_on_unprotect) { + entry_ptr = cache_ptr->LRU_tail_ptr; + while (entry_ptr != NULL && entries_examined <= initial_list_len && entries_cleared < ce_array_len) { + if (entry_ptr->clear_on_unprotect) { entry_ptr->clear_on_unprotect = FALSE; - clear_ptr = entry_ptr; - entry_ptr = entry_ptr->prev; + clear_ptr = entry_ptr; + entry_ptr = entry_ptr->prev; entries_cleared++; - if(H5C__flush_single_entry(f, clear_ptr, - (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) + if (H5C__flush_single_entry(f, clear_ptr, + (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | + H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") } /* end if */ else @@ -793,69 +761,66 @@ H5C_mark_entries_as_clean(H5F_t * f, } /* end while */ #if H5C_DO_SANITY_CHECKS - HDassert( entries_cleared == other_entries_marked ); + HDassert(entries_cleared == other_entries_marked); #endif /* H5C_DO_SANITY_CHECKS */ /* It is also possible that some of the cleared entries are on the * pinned list. Must scan that also. */ pinned_entries_cleared = 0; - progress = TRUE; - while((pinned_entries_cleared < pinned_entries_marked) && progress) { - progress = FALSE; + progress = TRUE; + while ((pinned_entries_cleared < pinned_entries_marked) && progress) { + progress = FALSE; entry_ptr = cache_ptr->pel_head_ptr; - while(entry_ptr != NULL) { - if(entry_ptr->clear_on_unprotect && entry_ptr->flush_dep_ndirty_children == 0) { + while (entry_ptr != NULL) { + if (entry_ptr->clear_on_unprotect && entry_ptr->flush_dep_ndirty_children == 0) { entry_ptr->clear_on_unprotect = FALSE; - clear_ptr = entry_ptr; - entry_ptr = entry_ptr->next; + clear_ptr = entry_ptr; + entry_ptr = entry_ptr->next; entries_cleared++; pinned_entries_cleared++; progress = TRUE; - if(H5C__flush_single_entry(f, clear_ptr, - (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) + if (H5C__flush_single_entry(f, clear_ptr, + (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | + H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") } /* end if */ else entry_ptr = entry_ptr->next; - } /* end while */ - } /* end while */ + } /* end while */ + } /* end while */ #if H5C_DO_SANITY_CHECKS - HDassert( entries_cleared == pinned_entries_marked + other_entries_marked ); - HDassert( entries_cleared + protected_entries_marked == ce_array_len ); + HDassert(entries_cleared == pinned_entries_marked + other_entries_marked); + HDassert(entries_cleared + protected_entries_marked == ce_array_len); #endif /* H5C_DO_SANITY_CHECKS */ - HDassert( ( entries_cleared == ce_array_len ) || - ( (ce_array_len - entries_cleared) <= cache_ptr->pl_len ) ); + HDassert((entries_cleared == ce_array_len) || ((ce_array_len - entries_cleared) <= cache_ptr->pl_len)); #if H5C_DO_SANITY_CHECKS - u = 0; + u = 0; entry_ptr = cache_ptr->pl_head_ptr; - while ( entry_ptr != NULL ) - { - if ( entry_ptr->clear_on_unprotect ) { + while (entry_ptr != NULL) { + if (entry_ptr->clear_on_unprotect) { u++; } entry_ptr = entry_ptr->next; } - HDassert( (entries_cleared + u) == ce_array_len ); + HDassert((entries_cleared + u) == ce_array_len); #endif /* H5C_DO_SANITY_CHECKS */ done: #if H5C_DO_EXTREME_SANITY_CHECKS - if(H5C_validate_protected_entry_list(cache_ptr) < 0 - || H5C_validate_pinned_entry_list(cache_ptr) < 0 - || H5C_validate_lru_list(cache_ptr) < 0) + if (H5C_validate_protected_entry_list(cache_ptr) < 0 || H5C_validate_pinned_entry_list(cache_ptr) < 0 || + H5C_validate_lru_list(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entries_as_clean() */ - /*------------------------------------------------------------------------- * * Function: H5C_clear_coll_entries @@ -873,15 +838,15 @@ done: herr_t H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) { - uint32_t clear_cnt; - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; + uint32_t clear_cnt; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT entry_ptr = cache_ptr->coll_tail_ptr; clear_cnt = (partial ? cache_ptr->coll_list_len / 2 : cache_ptr->coll_list_len); - while(entry_ptr && clear_cnt > 0) { + while (entry_ptr && clear_cnt > 0) { H5C_cache_entry_t *prev_ptr = entry_ptr->coll_prev; /* Sanity check */ @@ -902,7 +867,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_clear_coll_entries */ - /*------------------------------------------------------------------------- * * Function: H5C__collective_write @@ -919,18 +883,18 @@ done: static herr_t H5C__collective_write(H5F_t *f) { - H5AC_t *cache_ptr; - H5FD_mpio_xfer_t orig_xfer_mode = H5FD_MPIO_COLLECTIVE; - int count; - int *length_array = NULL; - MPI_Aint *buf_array = NULL; - MPI_Aint *offset_array = NULL; - MPI_Datatype btype; - hbool_t btype_created = FALSE; - MPI_Datatype ftype; - hbool_t ftype_created = FALSE; - int mpi_code; - herr_t ret_value = SUCCEED; + H5AC_t * cache_ptr; + H5FD_mpio_xfer_t orig_xfer_mode = H5FD_MPIO_COLLECTIVE; + int count; + int * length_array = NULL; + MPI_Aint * buf_array = NULL; + MPI_Aint * offset_array = NULL; + MPI_Datatype btype; + hbool_t btype_created = FALSE; + MPI_Datatype ftype; + hbool_t ftype_created = FALSE; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -941,53 +905,56 @@ H5C__collective_write(H5F_t *f) HDassert(cache_ptr->coll_write_list != NULL); /* Get original transfer mode */ - if(H5CX_get_io_xfer_mode(&orig_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&orig_xfer_mode) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Get number of entries in collective write list */ count = (int)H5SL_count(cache_ptr->coll_write_list); - if(count > 0) { - H5FD_mpio_xfer_t xfer_mode = H5FD_MPIO_COLLECTIVE; - H5SL_node_t *node; - H5C_cache_entry_t *entry_ptr; - void *base_buf; - int i; + if (count > 0) { + H5FD_mpio_xfer_t xfer_mode = H5FD_MPIO_COLLECTIVE; + H5SL_node_t * node; + H5C_cache_entry_t *entry_ptr; + void * base_buf; + int i; /* Set new transfer mode */ - if(H5CX_set_io_xfer_mode(xfer_mode) < 0) + if (H5CX_set_io_xfer_mode(xfer_mode) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") /* Allocate arrays */ - if(NULL == (length_array = (int *)H5MM_malloc((size_t)count * sizeof(int))) ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for collective write table length array") - if(NULL == (buf_array = (MPI_Aint *)H5MM_malloc((size_t)count * sizeof(MPI_Aint))) ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for collective buf table length array") - if(NULL == (offset_array = (MPI_Aint *)H5MM_malloc((size_t)count * sizeof(MPI_Aint))) ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for collective offset table length array") + if (NULL == (length_array = (int *)H5MM_malloc((size_t)count * sizeof(int)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for collective write table length array") + if (NULL == (buf_array = (MPI_Aint *)H5MM_malloc((size_t)count * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for collective buf table length array") + if (NULL == (offset_array = (MPI_Aint *)H5MM_malloc((size_t)count * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for collective offset table length array") /* Fill arrays */ node = H5SL_first(cache_ptr->coll_write_list); HDassert(node); - if(NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) + if (NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't retrieve skip list item") /* Set up initial array position & buffer base address */ length_array[0] = (int)entry_ptr->size; - base_buf = entry_ptr->image_ptr; - buf_array[0] = (MPI_Aint)0; + base_buf = entry_ptr->image_ptr; + buf_array[0] = (MPI_Aint)0; offset_array[0] = (MPI_Aint)entry_ptr->addr; node = H5SL_next(node); - i = 1; - while(node) { + i = 1; + while (node) { - if(NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) + if (NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't retrieve skip list item") /* Set up array position */ length_array[i] = (int)entry_ptr->size; - buf_array[i] = (MPI_Aint)entry_ptr->image_ptr - (MPI_Aint)base_buf; + buf_array[i] = (MPI_Aint)entry_ptr->image_ptr - (MPI_Aint)base_buf; offset_array[i] = (MPI_Aint)entry_ptr->addr; /* Advance to next node & array location */ @@ -996,61 +963,63 @@ H5C__collective_write(H5F_t *f) } /* end while */ /* Create memory MPI type */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed(count, length_array, buf_array, MPI_BYTE, &btype))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed(count, length_array, buf_array, MPI_BYTE, &btype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) btype_created = TRUE; - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&btype))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&btype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* Create file MPI type */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed(count, length_array, offset_array, MPI_BYTE, &ftype))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed(count, length_array, offset_array, MPI_BYTE, &ftype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) ftype_created = TRUE; - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&ftype))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&ftype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* Pass buf type, file type to the file driver */ - if(H5CX_set_mpi_coll_datatypes(btype, ftype) < 0) + if (H5CX_set_mpi_coll_datatypes(btype, ftype) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set MPI-I/O properties") /* Write data */ /* - * At present the page buffer is disabled in the parallel case, and - * thus VFD SWMR can't be used either. Thus, for now, there is + * At present the page buffer is disabled in the parallel case, and + * thus VFD SWMR can't be used either. Thus, for now, there is * no point in setting the page buffer hints. * * More to the point, since we are actually writing a derived type - * containing multiple metadata cache entries, we couldn't set it + * containing multiple metadata cache entries, we couldn't set it * to a meaningful value. * - * When we enable the page buffer in parallel, we will have to + * When we enable the page buffer in parallel, we will have to * revisit this. * JRM -- 3/30/20 */ - if(H5F_block_write(f, H5FD_MEM_DEFAULT, (haddr_t)0, (size_t)1, base_buf) < 0) + if (H5F_block_write(f, H5FD_MEM_DEFAULT, (haddr_t)0, (size_t)1, base_buf) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to write entries collectively") } /* end if */ else { MPI_Status mpi_stat; - MPI_File *mpi_fh_p; - MPI_File mpi_fh; - MPI_Info *info_p; - MPI_Info info; + MPI_File * mpi_fh_p; + MPI_File mpi_fh; + MPI_Info * info_p; + MPI_Info info; -/* This should be rewritten to call H5F_block_write, with the correct - * buffer and file datatypes (null ones). -QAK, 2018/02/21 - */ - if(H5F_get_mpi_handle(f, (MPI_File **)&mpi_fh_p) < 0) + /* This should be rewritten to call H5F_block_write, with the correct + * buffer and file datatypes (null ones). -QAK, 2018/02/21 + */ + if (H5F_get_mpi_handle(f, (MPI_File **)&mpi_fh_p) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't get mpi file handle") - mpi_fh = *(MPI_File*)mpi_fh_p; + mpi_fh = *(MPI_File *)mpi_fh_p; - if(H5F_get_mpi_info(f, &info_p) < 0) + if (H5F_get_mpi_info(f, &info_p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get mpi file info") info = *info_p; @@ -1058,42 +1027,44 @@ H5C__collective_write(H5F_t *f) /* just to match up with the 1st MPI_File_set_view from * H5FD_mpio_write() */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(mpi_fh, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, "native", info))) + if (MPI_SUCCESS != + (mpi_code = MPI_File_set_view(mpi_fh, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, "native", info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) /* just to match up with MPI_File_write_at_all from H5FD_mpio_write() */ HDmemset(&mpi_stat, 0, sizeof(MPI_Status)); - if(MPI_SUCCESS != (mpi_code = MPI_File_write_at_all(mpi_fh, (MPI_Offset)0, NULL, 0, MPI_BYTE, &mpi_stat))) + if (MPI_SUCCESS != + (mpi_code = MPI_File_write_at_all(mpi_fh, (MPI_Offset)0, NULL, 0, MPI_BYTE, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mpi_code) /* just to match up with the 2nd MPI_File_set_view (reset) in * H5FD_mpio_write() */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(mpi_fh, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, "native", info))) + if (MPI_SUCCESS != + (mpi_code = MPI_File_set_view(mpi_fh, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, "native", info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end else */ done: /* Free arrays */ length_array = (int *)H5MM_xfree(length_array); - buf_array = (MPI_Aint *)H5MM_xfree(buf_array); + buf_array = (MPI_Aint *)H5MM_xfree(buf_array); offset_array = (MPI_Aint *)H5MM_xfree(offset_array); /* Free MPI Types */ - if(btype_created && MPI_SUCCESS != (mpi_code = MPI_Type_free(&btype))) + if (btype_created && MPI_SUCCESS != (mpi_code = MPI_Type_free(&btype))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(ftype_created && MPI_SUCCESS != (mpi_code = MPI_Type_free(&ftype))) + if (ftype_created && MPI_SUCCESS != (mpi_code = MPI_Type_free(&ftype))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) /* Reset transfer mode in API context, if changed */ - if(orig_xfer_mode != H5FD_MPIO_COLLECTIVE) - if(H5CX_set_io_xfer_mode(orig_xfer_mode) < 0) + if (orig_xfer_mode != H5FD_MPIO_COLLECTIVE) + if (H5CX_set_io_xfer_mode(orig_xfer_mode) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") FUNC_LEAVE_NOAPI(ret_value); } /* end H5C__collective_write() */ - /*------------------------------------------------------------------------- * Function: H5C__flush_candidate_entries * @@ -1134,20 +1105,20 @@ done: */ static herr_t H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES], - unsigned entries_to_clear[H5C_RING_NTYPES]) + unsigned entries_to_clear[H5C_RING_NTYPES]) { #if H5C_DO_SANITY_CHECKS - int i; - uint32_t index_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - uint32_t slist_len = 0; + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_ring_t ring; - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; + H5C_ring_t ring; + H5C_t * cache_ptr; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1171,7 +1142,7 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - for(i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { index_len += cache_ptr->index_ring_len[i]; index_size += cache_ptr->index_ring_size[i]; clean_index_size += cache_ptr->clean_index_ring_size[i]; @@ -1190,9 +1161,8 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_DO_EXTREME_SANITY_CHECKS - if(H5C_validate_protected_entry_list(cache_ptr) < 0 - || H5C_validate_pinned_entry_list(cache_ptr) < 0 - || H5C_validate_lru_list(cache_ptr) < 0) + if (H5C_validate_protected_entry_list(cache_ptr) < 0 || H5C_validate_pinned_entry_list(cache_ptr) < 0 || + H5C_validate_lru_list(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1202,12 +1172,12 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES * working inward. */ ring = H5C_RING_USER; - while(ring < H5C_RING_NTYPES) { - if(H5C__flush_candidates_in_ring(f, ring, entries_to_flush[ring], entries_to_clear[ring]) < 0) + while (ring < H5C_RING_NTYPES) { + if (H5C__flush_candidates_in_ring(f, ring, entries_to_flush[ring], entries_to_clear[ring]) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush candidates in ring failed") ring++; - } /* end while */ + } /* end while */ done: cache_ptr->flush_in_progress = FALSE; @@ -1215,7 +1185,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__flush_candidate_entries() */ - /*------------------------------------------------------------------------- * Function: H5C__flush_candidates_in_ring * @@ -1253,25 +1222,23 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, - unsigned entries_to_flush, unsigned entries_to_clear) +H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flush, unsigned entries_to_clear) { - H5C_t * cache_ptr; - hbool_t progress; - hbool_t restart_scan = FALSE; - unsigned entries_flushed = 0; - unsigned entries_cleared = 0; + H5C_t * cache_ptr; + hbool_t progress; + hbool_t restart_scan = FALSE; + unsigned entries_flushed = 0; + unsigned entries_cleared = 0; #if H5C_DO_SANITY_CHECKS - unsigned init_index_len; + unsigned init_index_len; #endif /* H5C_DO_SANITY_CHECKS */ - unsigned clear_flags = H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__GENERATE_IMAGE_FLAG | - H5C__UPDATE_PAGE_BUFFER_FLAG; - unsigned flush_flags = H5C__NO_FLAGS_SET; - unsigned op_flags; + unsigned clear_flags = + H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__UPDATE_PAGE_BUFFER_FLAG; + unsigned flush_flags = H5C__NO_FLAGS_SET; + unsigned op_flags; H5C_cache_entry_t *op_ptr; H5C_cache_entry_t *entry_ptr; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1286,9 +1253,8 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, HDassert(ring < H5C_RING_NTYPES); #if H5C_DO_EXTREME_SANITY_CHECKS - if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0) || - (H5C_validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1307,27 +1273,27 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * It is possible that this will change -- hence the assertion. */ restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; - while(((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear)) - && (entry_ptr != NULL)) { - hbool_t prev_is_dirty = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; + while (((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear)) && + (entry_ptr != NULL)) { + hbool_t prev_is_dirty = FALSE; H5C_cache_entry_t *next_ptr; /* Entries in the LRU must not have flush dependency children */ HDassert(entry_ptr->flush_dep_nchildren == 0); /* Remember dirty state of entry to advance to */ - if(entry_ptr->prev != NULL) + if (entry_ptr->prev != NULL) prev_is_dirty = entry_ptr->prev->is_dirty; /* If the entry is in the ring */ - if(entry_ptr->ring == ring) { + if (entry_ptr->ring == ring) { /* If this process needs to clear this entry. */ - if(entry_ptr->clear_on_unprotect) { + if (entry_ptr->clear_on_unprotect) { HDassert(entry_ptr->is_dirty); /* Set entry and flags for operation */ - op_ptr = entry_ptr; + op_ptr = entry_ptr; op_flags = clear_flags; /* Set next entry appropriately */ @@ -1337,11 +1303,11 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, entry_ptr->clear_on_unprotect = FALSE; entries_cleared++; } /* end if */ - else if(entry_ptr->flush_immediately) { + else if (entry_ptr->flush_immediately) { HDassert(entry_ptr->is_dirty); /* Set entry and flags for operation */ - op_ptr = entry_ptr; + op_ptr = entry_ptr; op_flags = flush_flags; /* Set next entry appropriately */ @@ -1363,7 +1329,7 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, entry_ptr = entry_ptr->prev; /* Check for operation */ - if(op_ptr) { + if (op_ptr) { /* reset entries_removed_counter and * last_entry_removed_ptr prior to the call to * H5C__flush_single_entry() so that we can spot @@ -1382,14 +1348,13 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, cache_ptr->entries_removed_counter = 0; cache_ptr->last_entry_removed_ptr = NULL; - if(H5C__flush_single_entry(f, op_ptr, op_flags) < 0) + if (H5C__flush_single_entry(f, op_ptr, op_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush entry") - if(cache_ptr->entries_removed_counter != 0 - || cache_ptr->last_entry_removed_ptr != NULL) + if (cache_ptr->entries_removed_counter != 0 || cache_ptr->last_entry_removed_ptr != NULL) restart_scan = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Remember "next" pointer (after advancing entries) */ next_ptr = entry_ptr; @@ -1399,10 +1364,9 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, } /* end else */ /* Check for restarts, etc. */ - if((entry_ptr != NULL) && - (restart_scan || (entry_ptr->is_dirty != prev_is_dirty) - || (entry_ptr->next != next_ptr) || entry_ptr->is_protected - || entry_ptr->is_pinned)) { + if ((entry_ptr != NULL) && + (restart_scan || (entry_ptr->is_dirty != prev_is_dirty) || (entry_ptr->next != next_ptr) || + entry_ptr->is_protected || entry_ptr->is_pinned)) { /* Something has happened to the LRU -- start over * from the tail. @@ -1422,11 +1386,11 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, HDassert(FALSE); /* see comment above */ restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; + entry_ptr = cache_ptr->LRU_tail_ptr; H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) } /* end if */ - } /* end while */ + } /* end while */ /* It is also possible that some of the cleared entries are on the * pinned list. Must scan that also. @@ -1450,26 +1414,26 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * such changes and cause this function to fail if they are detected. */ progress = TRUE; - while(progress && ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { - progress = FALSE; + while (progress && ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { + progress = FALSE; entry_ptr = cache_ptr->pel_head_ptr; - while((entry_ptr != NULL) && - ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { + while ((entry_ptr != NULL) && + ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { H5C_cache_entry_t *prev_ptr; - hbool_t next_is_dirty = FALSE; + hbool_t next_is_dirty = FALSE; HDassert(entry_ptr->is_pinned); /* Remember dirty state of entry to advance to */ - if(entry_ptr->next != NULL) + if (entry_ptr->next != NULL) next_is_dirty = entry_ptr->next->is_dirty; - if(entry_ptr->ring == ring && entry_ptr->flush_dep_ndirty_children == 0) { - if(entry_ptr->clear_on_unprotect) { + if (entry_ptr->ring == ring && entry_ptr->flush_dep_ndirty_children == 0) { + if (entry_ptr->clear_on_unprotect) { HDassert(entry_ptr->is_dirty); /* Set entry and flags for operation */ - op_ptr = entry_ptr; + op_ptr = entry_ptr; op_flags = clear_flags; /* Reset entry flag */ @@ -1477,11 +1441,11 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, entries_cleared++; progress = TRUE; } /* end if */ - else if(entry_ptr->flush_immediately) { + else if (entry_ptr->flush_immediately) { HDassert(entry_ptr->is_dirty); /* Set entry and flags for operation */ - op_ptr = entry_ptr; + op_ptr = entry_ptr; op_flags = flush_flags; /* Reset entry flag */ @@ -1494,7 +1458,7 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, op_ptr = NULL; /* Check for operation */ - if(op_ptr) { + if (op_ptr) { /* reset entries_removed_counter and * last_entry_removed_ptr prior to the call to * H5C__flush_single_entry() so that we can spot @@ -1520,14 +1484,13 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * * JRM -- 2/9/17 */ - if(H5C__flush_single_entry(f, op_ptr, op_flags) < 0) + if (H5C__flush_single_entry(f, op_ptr, op_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush entry") - if(cache_ptr->entries_removed_counter != 0 - || cache_ptr->last_entry_removed_ptr != NULL) + if (cache_ptr->entries_removed_counter != 0 || cache_ptr->last_entry_removed_ptr != NULL) restart_scan = TRUE; } /* end if */ - } /* end if */ + } /* end if */ /* Remember "previous" pointer (after advancing entries) */ prev_ptr = entry_ptr; @@ -1536,10 +1499,9 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, entry_ptr = entry_ptr->next; /* Check for restarts, etc. */ - if((entry_ptr != NULL) && - (restart_scan || (entry_ptr->is_dirty != next_is_dirty) - || (entry_ptr->prev != prev_ptr) || entry_ptr->is_protected - || !entry_ptr->is_pinned)) { + if ((entry_ptr != NULL) && + (restart_scan || (entry_ptr->is_dirty != next_is_dirty) || (entry_ptr->prev != prev_ptr) || + entry_ptr->is_protected || !entry_ptr->is_pinned)) { /* Something has happened to the pinned entry list -- start * over from the head. * @@ -1570,22 +1532,22 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * H5C__UPDATE_STATS_FOR_PEL_SCAN_RESTART(cache_ptr) */ } /* end if */ - } /* end while ( ( entry_ptr != NULL ) && - * ( ( entries_flushed > entries_to_flush ) || - * ( entries_cleared > entries_to_clear ) ) ) - */ - } /* end while ( ( ( entries_flushed > entries_to_flush ) || - * ( entries_cleared > entries_to_clear ) ) && - * ( progress ) ) - */ + } /* end while ( ( entry_ptr != NULL ) && + * ( ( entries_flushed > entries_to_flush ) || + * ( entries_cleared > entries_to_clear ) ) ) + */ + } /* end while ( ( ( entries_flushed > entries_to_flush ) || + * ( entries_cleared > entries_to_clear ) ) && + * ( progress ) ) + */ #if H5C_DO_SANITY_CHECKS HDassert(init_index_len == cache_ptr->index_len); #endif /* H5C_DO_SANITY_CHECKS */ - if(entries_flushed != entries_to_flush || entries_cleared != entries_to_clear) { + if (entries_flushed != entries_to_flush || entries_cleared != entries_to_clear) { entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(!entry_ptr->clear_on_unprotect || (entry_ptr->ring > ring)); HDassert(!entry_ptr->flush_immediately || (entry_ptr->ring > ring)); entry_ptr = entry_ptr->il_next; @@ -1598,4 +1560,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__flush_candidates_in_ring() */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index a5eafd6..ec2a84c 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -37,20 +37,20 @@ #include "H5Cprivate.h" /* Other private headers needed by this file */ -#include "H5Clog.h" /* Cache logging */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5Clog.h" /* Cache logging */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Number of epoch markers active */ -#define H5C__MAX_EPOCH_MARKERS 10 +#define H5C__MAX_EPOCH_MARKERS 10 /* Cache configuration settings */ -#define H5C__HASH_TABLE_LEN (64 * 1024) /* must be a power of 2 */ -#define H5C__PAGE_HASH_TABLE_LEN ( 4 * 1024) /* must be a poser of 2 */ -#define H5C__H5C_T_MAGIC 0x005CAC0E +#define H5C__HASH_TABLE_LEN (64 * 1024) /* must be a power of 2 */ +#define H5C__PAGE_HASH_TABLE_LEN (4 * 1024) /* must be a poser of 2 */ +#define H5C__H5C_T_MAGIC 0x005CAC0E /* Initial allocated size of the "flush_dep_parent" array */ #define H5C_FLUSH_DEP_PARENT_INIT 8 @@ -161,83 +161,46 @@ #if H5C_DO_SANITY_CHECKS -#define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -if ( ( (head_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (Size) < (entry_ptr)->size ) || \ - ( ( (entry_ptr)->prev == NULL ) && ( (head_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (head_ptr) == (entry_ptr) ) && \ - ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->next == NULL ) && \ - ( (entry_ptr)->prev == NULL ) && \ - ( (Size) == (entry_ptr)->size ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre remove SC failed") \ -} - -#define H5C__DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( (len) < 0 ) || \ - ( (Size) < 0 ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL sanity check failed") \ -} - -#define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->next != NULL ) || \ - ( (entry_ptr)->prev != NULL ) || \ - ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre insert SC failed") \ -} - -#define H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ -if ( ( (dll_len) <= 0 ) || \ - ( (dll_size) <= 0 ) || \ - ( (old_size) <= 0 ) || \ - ( (old_size) > (dll_size) ) || \ - ( (new_size) <= 0 ) || \ - ( ( (dll_len) == 1 ) && ( (old_size) != (dll_size) ) ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL pre size update SC failed") \ -} - -#define H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ -if ( ( (new_size) > (dll_size) ) || \ - ( ( (dll_len) == 1 ) && ( (new_size) != (dll_size) ) ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL post size update SC failed") \ -} +#define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + if (((head_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ + ((Size) < (entry_ptr)->size) || (((entry_ptr)->prev == NULL) && ((head_ptr) != (entry_ptr))) || \ + (((entry_ptr)->next == NULL) && ((tail_ptr) != (entry_ptr))) || \ + (((len) == 1) && \ + (!(((head_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->next == NULL) && \ + ((entry_ptr)->prev == NULL) && ((Size) == (entry_ptr)->size))))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre remove SC failed") \ + } + +#define H5C__DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || ((len) < 0) || \ + ((Size) < 0) || \ + (((len) == 1) && \ + (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((head_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->next != NULL)))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL sanity check failed") \ + } + +#define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + if (((entry_ptr) == NULL) || ((entry_ptr)->next != NULL) || ((entry_ptr)->prev != NULL) || \ + ((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || \ + (((len) == 1) && \ + (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((head_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->next != NULL)))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre insert SC failed") \ + } + +#define H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ + if (((dll_len) <= 0) || ((dll_size) <= 0) || ((old_size) <= 0) || ((old_size) > (dll_size)) || \ + ((new_size) <= 0) || (((dll_len) == 1) && ((old_size) != (dll_size)))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL pre size update SC failed") \ + } + +#define H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ + if (((new_size) > (dll_size)) || (((dll_len) == 1) && ((new_size) != (dll_size)))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL post size update SC failed") \ + } #else /* H5C_DO_SANITY_CHECKS */ @@ -249,144 +212,103 @@ if ( ( (new_size) > (dll_size) ) || \ #endif /* H5C_DO_SANITY_CHECKS */ - -#define H5C__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ -{ \ - H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->next = (entry_ptr); \ - (entry_ptr)->prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += (entry_ptr)->size; \ -} /* H5C__DLL_APPEND() */ - -#define H5C__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ -{ \ - H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->prev = (entry_ptr); \ - (entry_ptr)->next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ -} /* H5C__DLL_PREPEND() */ - -#define H5C__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ -{ \ - H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->prev = NULL; \ - } \ - else \ - (entry_ptr)->prev->next = (entry_ptr)->next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->next = NULL; \ - } \ - else \ - (entry_ptr)->next->prev = (entry_ptr)->prev; \ - entry_ptr->next = NULL; \ - entry_ptr->prev = NULL; \ - (len)--; \ - (Size) -= entry_ptr->size; \ - } \ -} /* H5C__DLL_REMOVE() */ - -#define H5C__DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size) \ -{ \ - H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ - (dll_size) -= (old_size); \ - (dll_size) += (new_size); \ - H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ -} /* H5C__DLL_UPDATE_FOR_SIZE_CHANGE() */ +#define H5C__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (tail_ptr)->next = (entry_ptr); \ + (entry_ptr)->prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += (entry_ptr)->size; \ + } /* H5C__DLL_APPEND() */ + +#define H5C__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (head_ptr)->prev = (entry_ptr); \ + (entry_ptr)->next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ + } /* H5C__DLL_PREPEND() */ + +#define H5C__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + if ((head_ptr) == (entry_ptr)) { \ + (head_ptr) = (entry_ptr)->next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->prev = NULL; \ + } \ + else \ + (entry_ptr)->prev->next = (entry_ptr)->next; \ + if ((tail_ptr) == (entry_ptr)) { \ + (tail_ptr) = (entry_ptr)->prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->next = NULL; \ + } \ + else \ + (entry_ptr)->next->prev = (entry_ptr)->prev; \ + entry_ptr->next = NULL; \ + entry_ptr->prev = NULL; \ + (len)--; \ + (Size) -= entry_ptr->size; \ + } \ + } /* H5C__DLL_REMOVE() */ + +#define H5C__DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size) \ + { \ + H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ + (dll_size) -= (old_size); \ + (dll_size) += (new_size); \ + H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) \ + } /* H5C__DLL_UPDATE_FOR_SIZE_CHANGE() */ #if H5C_DO_SANITY_CHECKS -#define H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (hd_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (Size) < (entry_ptr)->size ) || \ - ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->aux_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->aux_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->aux_next == NULL ) && \ - ( (entry_ptr)->aux_prev == NULL ) && \ - ( (Size) == (entry_ptr)->size ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "aux DLL pre remove SC failed") \ -} - -#define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( (len) < 0 ) || \ - ( (Size) < 0 ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->aux_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->aux_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL sanity check failed") \ -} - -#define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->aux_next != NULL ) || \ - ( (entry_ptr)->aux_prev != NULL ) || \ - ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (hd_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->aux_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->aux_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL pre insert SC failed") \ -} +#define H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((hd_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ + ((Size) < (entry_ptr)->size) || (((Size) == (entry_ptr)->size) && (!((len) == 1))) || \ + (((entry_ptr)->aux_prev == NULL) && ((hd_ptr) != (entry_ptr))) || \ + (((entry_ptr)->aux_next == NULL) && ((tail_ptr) != (entry_ptr))) || \ + (((len) == 1) && \ + (!(((hd_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->aux_next == NULL) && \ + ((entry_ptr)->aux_prev == NULL) && ((Size) == (entry_ptr)->size))))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "aux DLL pre remove SC failed") \ + } + +#define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || ((len) < 0) || \ + ((Size) < 0) || \ + (((len) == 1) && (((head_ptr) != (tail_ptr)) || ((Size) <= 0) || ((head_ptr) == NULL) || \ + ((head_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->aux_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->aux_next != NULL)))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL sanity check failed") \ + } + +#define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((entry_ptr) == NULL) || ((entry_ptr)->aux_next != NULL) || ((entry_ptr)->aux_prev != NULL) || \ + ((((hd_ptr) == NULL) || ((tail_ptr) == NULL)) && ((hd_ptr) != (tail_ptr))) || \ + (((len) == 1) && \ + (((hd_ptr) != (tail_ptr)) || ((Size) <= 0) || ((hd_ptr) == NULL) || ((hd_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((hd_ptr) == NULL) || ((hd_ptr)->aux_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->aux_next != NULL)))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL pre insert SC failed") \ + } #else /* H5C_DO_SANITY_CHECKS */ @@ -396,135 +318,97 @@ if ( ( (entry_ptr) == NULL ) || \ #endif /* H5C_DO_SANITY_CHECKS */ - -#define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val)\ -{ \ - H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->aux_next = (entry_ptr); \ - (entry_ptr)->aux_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ -} /* H5C__AUX_DLL_APPEND() */ - -#define H5C__AUX_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -{ \ - H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->aux_prev = (entry_ptr); \ - (entry_ptr)->aux_next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ -} /* H5C__AUX_DLL_PREPEND() */ - -#define H5C__AUX_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -{ \ - H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->aux_next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->aux_prev = NULL; \ - } \ - else \ - (entry_ptr)->aux_prev->aux_next = (entry_ptr)->aux_next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->aux_prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->aux_next = NULL; \ - } \ - else \ - (entry_ptr)->aux_next->aux_prev = (entry_ptr)->aux_prev; \ - entry_ptr->aux_next = NULL; \ - entry_ptr->aux_prev = NULL; \ - (len)--; \ - (Size) -= entry_ptr->size; \ - } \ -} /* H5C__AUX_DLL_REMOVE() */ +#define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (tail_ptr)->aux_next = (entry_ptr); \ + (entry_ptr)->aux_prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ + } /* H5C__AUX_DLL_APPEND() */ + +#define H5C__AUX_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (head_ptr)->aux_prev = (entry_ptr); \ + (entry_ptr)->aux_next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ + } /* H5C__AUX_DLL_PREPEND() */ + +#define H5C__AUX_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + if ((head_ptr) == (entry_ptr)) { \ + (head_ptr) = (entry_ptr)->aux_next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->aux_prev = NULL; \ + } \ + else \ + (entry_ptr)->aux_prev->aux_next = (entry_ptr)->aux_next; \ + if ((tail_ptr) == (entry_ptr)) { \ + (tail_ptr) = (entry_ptr)->aux_prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->aux_next = NULL; \ + } \ + else \ + (entry_ptr)->aux_next->aux_prev = (entry_ptr)->aux_prev; \ + entry_ptr->aux_next = NULL; \ + entry_ptr->aux_prev = NULL; \ + (len)--; \ + (Size) -= entry_ptr->size; \ + } \ + } /* H5C__AUX_DLL_REMOVE() */ #if H5C_DO_SANITY_CHECKS -#define H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (hd_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (Size) < (entry_ptr)->size ) || \ - ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->il_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->il_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->il_next == NULL ) && \ - ( (entry_ptr)->il_prev == NULL ) && \ - ( (Size) == (entry_ptr)->size ) \ - ) \ - ) \ - ) \ - ) { \ - HDassert(0 && "il DLL pre remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "il DLL pre remove SC failed") \ -} - -#define H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->il_next != NULL ) || \ - ( (entry_ptr)->il_prev != NULL ) || \ - ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (hd_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->il_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->il_next != NULL ) \ - ) \ - ) \ - ) { \ - HDassert(0 && "IL DLL pre insert SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL pre insert SC failed") \ -} - -#define H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->il_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->il_next != NULL ) \ - ) \ - ) \ - ) { \ - HDassert(0 && "IL DLL sanity check failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL sanity check failed") \ -} +#define H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((hd_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ + ((Size) < (entry_ptr)->size) || (((Size) == (entry_ptr)->size) && (!((len) == 1))) || \ + (((entry_ptr)->il_prev == NULL) && ((hd_ptr) != (entry_ptr))) || \ + (((entry_ptr)->il_next == NULL) && ((tail_ptr) != (entry_ptr))) || \ + (((len) == 1) && \ + (!(((hd_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->il_next == NULL) && \ + ((entry_ptr)->il_prev == NULL) && ((Size) == (entry_ptr)->size))))) { \ + HDassert(0 && "il DLL pre remove SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "il DLL pre remove SC failed") \ + } + +#define H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((entry_ptr) == NULL) || ((entry_ptr)->il_next != NULL) || ((entry_ptr)->il_prev != NULL) || \ + ((((hd_ptr) == NULL) || ((tail_ptr) == NULL)) && ((hd_ptr) != (tail_ptr))) || \ + (((len) == 1) && \ + (((hd_ptr) != (tail_ptr)) || ((Size) <= 0) || ((hd_ptr) == NULL) || ((hd_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((hd_ptr) == NULL) || ((hd_ptr)->il_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->il_next != NULL)))) { \ + HDassert(0 && "IL DLL pre insert SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL pre insert SC failed") \ + } + +#define H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || \ + (((len) == 1) && \ + (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((head_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->il_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->il_next != NULL)))) { \ + HDassert(0 && "IL DLL sanity check failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL sanity check failed") \ + } #else /* H5C_DO_SANITY_CHECKS */ @@ -534,56 +418,49 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #endif /* H5C_DO_SANITY_CHECKS */ +#define H5C__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (tail_ptr)->il_next = (entry_ptr); \ + (entry_ptr)->il_prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ + H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fail_val) \ + } /* H5C__IL_DLL_APPEND() */ + +#define H5C__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + if ((head_ptr) == (entry_ptr)) { \ + (head_ptr) = (entry_ptr)->il_next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->il_prev = NULL; \ + } \ + else \ + (entry_ptr)->il_prev->il_next = (entry_ptr)->il_next; \ + if ((tail_ptr) == (entry_ptr)) { \ + (tail_ptr) = (entry_ptr)->il_prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->il_next = NULL; \ + } \ + else \ + (entry_ptr)->il_next->il_prev = (entry_ptr)->il_prev; \ + entry_ptr->il_next = NULL; \ + entry_ptr->il_prev = NULL; \ + (len)--; \ + (Size) -= entry_ptr->size; \ + } \ + H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + } /* H5C__IL_DLL_REMOVE() */ -#define H5C__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val)\ -{ \ - H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->il_next = (entry_ptr); \ - (entry_ptr)->il_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ - H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fail_val) \ -} /* H5C__IL_DLL_APPEND() */ - -#define H5C__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -{ \ - H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->il_next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->il_prev = NULL; \ - } \ - else \ - (entry_ptr)->il_prev->il_next = (entry_ptr)->il_next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->il_prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->il_next = NULL; \ - } \ - else \ - (entry_ptr)->il_next->il_prev = (entry_ptr)->il_prev; \ - entry_ptr->il_next = NULL; \ - entry_ptr->il_prev = NULL; \ - (len)--; \ - (Size) -= entry_ptr->size; \ - } \ - H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -} /* H5C__IL_DLL_REMOVE() */ - - /*********************************************************************** * * Stats collection macros @@ -597,323 +474,297 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ * ***********************************************************************/ -#define H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) \ - (cache_ptr->cache_accesses)++; \ - if ( hit ) { \ - (cache_ptr->cache_hits)++; \ - } \ +#define H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) \ + (cache_ptr->cache_accesses)++; \ + if (hit) { \ + (cache_ptr->cache_hits)++; \ + } #if H5C_COLLECT_CACHE_STATS -#define H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ( (cache_ptr)->index_size > (cache_ptr)->max_index_size ) \ - (cache_ptr)->max_index_size = (cache_ptr)->index_size; \ - if ( (cache_ptr)->clean_index_size > \ - (cache_ptr)->max_clean_index_size ) \ - (cache_ptr)->max_clean_index_size = \ - (cache_ptr)->clean_index_size; \ - if ( (cache_ptr)->dirty_index_size > \ - (cache_ptr)->max_dirty_index_size ) \ - (cache_ptr)->max_dirty_index_size = \ - (cache_ptr)->dirty_index_size; - -#define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) \ - (((cache_ptr)->dirty_pins)[(entry_ptr)->type->id])++; - -#define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) \ - if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ - if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; - -#define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ - if ( cache_ptr->flush_in_progress ) \ - ((cache_ptr)->cache_flush_moves[(entry_ptr)->type->id])++; \ - if ( entry_ptr->flush_in_progress ) \ - ((cache_ptr)->entry_flush_moves[(entry_ptr)->type->id])++; \ - (((cache_ptr)->moves)[(entry_ptr)->type->id])++; \ - (cache_ptr)->entries_relocated_counter++; - -#define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size)\ - if ( cache_ptr->flush_in_progress ) \ - ((cache_ptr)->cache_flush_size_changes[(entry_ptr)->type->id])++; \ - if ( entry_ptr->flush_in_progress ) \ - ((cache_ptr)->entry_flush_size_changes[(entry_ptr)->type->id])++; \ - if ( (entry_ptr)->size < (new_size) ) { \ - ((cache_ptr)->size_increases[(entry_ptr)->type->id])++; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ - } else if ( (entry_ptr)->size > (new_size) ) { \ - ((cache_ptr)->size_decreases[(entry_ptr)->type->id])++; \ - } - -#define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ - (cache_ptr)->total_ht_insertions++; - -#define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ - (cache_ptr)->total_ht_deletions++; - -#define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ - if ( success ) { \ - (cache_ptr)->successful_ht_searches++; \ - (cache_ptr)->total_successful_ht_search_depth += depth; \ - } else { \ - (cache_ptr)->failed_ht_searches++; \ - (cache_ptr)->total_failed_ht_search_depth += depth; \ - } - -#define H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) \ - ((cache_ptr)->unpins)[(entry_ptr)->type->id]++; - -#define H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->slist_scan_restarts)++; - -#define H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->LRU_scan_restarts)++; - -#define H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->index_scan_restarts)++; - -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \ -{ \ - (cache_ptr)->images_created++; \ -} - -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) \ -{ \ - /* make sure image len is still good */ \ - HDassert((cache_ptr)->image_len > 0); \ - (cache_ptr)->images_read++; \ -} - -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) \ -{ \ - /* make sure image len is still good */ \ - HDassert((cache_ptr)->image_len > 0); \ - (cache_ptr)->images_loaded++; \ - (cache_ptr)->last_image_size = (cache_ptr)->image_len; \ -} - -#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) \ -{ \ - (cache_ptr)->prefetches++; \ - if ( dirty ) \ - (cache_ptr)->dirty_prefetches++; \ -} - -#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) \ -{ \ - (cache_ptr)->prefetch_hits++; \ -} +#define H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ((cache_ptr)->index_size > (cache_ptr)->max_index_size) \ + (cache_ptr)->max_index_size = (cache_ptr)->index_size; \ + if ((cache_ptr)->clean_index_size > (cache_ptr)->max_clean_index_size) \ + (cache_ptr)->max_clean_index_size = (cache_ptr)->clean_index_size; \ + if ((cache_ptr)->dirty_index_size > (cache_ptr)->max_dirty_index_size) \ + (cache_ptr)->max_dirty_index_size = (cache_ptr)->dirty_index_size; + +#define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) \ + (((cache_ptr)->dirty_pins)[(entry_ptr)->type->id])++; + +#define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) \ + if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; + +#define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ + if (cache_ptr->flush_in_progress) \ + ((cache_ptr)->cache_flush_moves[(entry_ptr)->type->id])++; \ + if (entry_ptr->flush_in_progress) \ + ((cache_ptr)->entry_flush_moves[(entry_ptr)->type->id])++; \ + (((cache_ptr)->moves)[(entry_ptr)->type->id])++; \ + (cache_ptr)->entries_relocated_counter++; + +#define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ + if (cache_ptr->flush_in_progress) \ + ((cache_ptr)->cache_flush_size_changes[(entry_ptr)->type->id])++; \ + if (entry_ptr->flush_in_progress) \ + ((cache_ptr)->entry_flush_size_changes[(entry_ptr)->type->id])++; \ + if ((entry_ptr)->size < (new_size)) { \ + ((cache_ptr)->size_increases[(entry_ptr)->type->id])++; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ + } \ + else if ((entry_ptr)->size > (new_size)) { \ + ((cache_ptr)->size_decreases[(entry_ptr)->type->id])++; \ + } + +#define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) (cache_ptr)->total_ht_insertions++; + +#define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) (cache_ptr)->total_ht_deletions++; + +#define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ + if (success) { \ + (cache_ptr)->successful_ht_searches++; \ + (cache_ptr)->total_successful_ht_search_depth += depth; \ + } \ + else { \ + (cache_ptr)->failed_ht_searches++; \ + (cache_ptr)->total_failed_ht_search_depth += depth; \ + } + +#define H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) ((cache_ptr)->unpins)[(entry_ptr)->type->id]++; + +#define H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) ((cache_ptr)->slist_scan_restarts)++; + +#define H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) ((cache_ptr)->LRU_scan_restarts)++; + +#define H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) ((cache_ptr)->index_scan_restarts)++; + +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \ + { \ + (cache_ptr)->images_created++; \ + } + +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) \ + { \ + /* make sure image len is still good */ \ + HDassert((cache_ptr)->image_len > 0); \ + (cache_ptr)->images_read++; \ + } + +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) \ + { \ + /* make sure image len is still good */ \ + HDassert((cache_ptr)->image_len > 0); \ + (cache_ptr)->images_loaded++; \ + (cache_ptr)->last_image_size = (cache_ptr)->image_len; \ + } + +#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) \ + { \ + (cache_ptr)->prefetches++; \ + if (dirty) \ + (cache_ptr)->dirty_prefetches++; \ + } + +#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) \ + { \ + (cache_ptr)->prefetch_hits++; \ + } #if H5C_COLLECT_CACHE_ENTRY_STATS -#define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) \ -{ \ - (entry_ptr)->accesses = 0; \ - (entry_ptr)->clears = 0; \ - (entry_ptr)->flushes = 0; \ - (entry_ptr)->pins = 0; \ -} - -#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ -{ \ - (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ - if((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ - ((entry_ptr)->clears)++; \ -} - -#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ -{ \ - (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ - if((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ - ((entry_ptr)->flushes)++; \ -} - -#define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ -{ \ - if ( take_ownership ) \ - (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ - else \ - (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ - if ( (entry_ptr)->accesses > \ - ((cache_ptr)->max_accesses)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_accesses)[(entry_ptr)->type->id] = \ - (entry_ptr)->accesses; \ - if ( (entry_ptr)->accesses < \ - ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] = \ - (entry_ptr)->accesses; \ - if ( (entry_ptr)->clears > \ - ((cache_ptr)->max_clears)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_clears)[(entry_ptr)->type->id] \ - = (entry_ptr)->clears; \ - if ( (entry_ptr)->flushes > \ - ((cache_ptr)->max_flushes)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_flushes)[(entry_ptr)->type->id] \ - = (entry_ptr)->flushes; \ - if ( (entry_ptr)->size > \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] \ - = (entry_ptr)->size; \ - if ( (entry_ptr)->pins > \ - ((cache_ptr)->max_pins)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_pins)[(entry_ptr)->type->id] \ - = (entry_ptr)->pins; \ -} - -#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ -{ \ - (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ - if ( (entry_ptr)->is_pinned ) { \ - (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - (entry_ptr)->pins++; \ - if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ - } \ - if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ - if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - if ( (entry_ptr)->size > \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] \ - = (entry_ptr)->size; \ - cache_ptr->entries_inserted_counter++; \ -} - -#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ -{ \ - if ( hit ) \ - ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ - else \ - ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ - if ( ! ((entry_ptr)->is_read_only) ) { \ - ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ - } else { \ - ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ - if ( ((entry_ptr)->ro_ref_count) > \ - ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = \ - ((entry_ptr)->ro_ref_count); \ - } \ - if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ( (cache_ptr)->pl_len > (cache_ptr)->max_pl_len ) \ - (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ - if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ - if ( (entry_ptr)->size > \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ - ((entry_ptr)->accesses)++; \ -} - -#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ -{ \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - (entry_ptr)->pins++; \ - if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ -} +#define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) \ + { \ + (entry_ptr)->accesses = 0; \ + (entry_ptr)->clears = 0; \ + (entry_ptr)->flushes = 0; \ + (entry_ptr)->pins = 0; \ + } + +#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ + { \ + (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ + if ((entry_ptr)->is_pinned) \ + (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ + ((entry_ptr)->clears)++; \ + } + +#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ + { \ + (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ + if ((entry_ptr)->is_pinned) \ + (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ + ((entry_ptr)->flushes)++; \ + } + +#define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ + { \ + if (take_ownership) \ + (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ + else \ + (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ + if ((entry_ptr)->accesses > ((cache_ptr)->max_accesses)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_accesses)[(entry_ptr)->type->id] = (entry_ptr)->accesses; \ + if ((entry_ptr)->accesses < ((cache_ptr)->min_accesses)[(entry_ptr)->type->id]) \ + ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] = (entry_ptr)->accesses; \ + if ((entry_ptr)->clears > ((cache_ptr)->max_clears)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_clears)[(entry_ptr)->type->id] = (entry_ptr)->clears; \ + if ((entry_ptr)->flushes > ((cache_ptr)->max_flushes)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_flushes)[(entry_ptr)->type->id] = (entry_ptr)->flushes; \ + if ((entry_ptr)->size > ((cache_ptr)->max_size)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ + if ((entry_ptr)->pins > ((cache_ptr)->max_pins)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_pins)[(entry_ptr)->type->id] = (entry_ptr)->pins; \ + } + +#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ + { \ + (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ + if ((entry_ptr)->is_pinned) { \ + (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ + ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + (entry_ptr)->pins++; \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ + } \ + if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + if ((entry_ptr)->size > ((cache_ptr)->max_size)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ + cache_ptr->entries_inserted_counter++; \ + } + +#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ + { \ + if (hit) \ + ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ + else \ + ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ + if (!((entry_ptr)->is_read_only)) { \ + ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ + } \ + else { \ + ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ + if (((entry_ptr)->ro_ref_count) > ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = ((entry_ptr)->ro_ref_count); \ + } \ + if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ((cache_ptr)->pl_len > (cache_ptr)->max_pl_len) \ + (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ + if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ + if ((entry_ptr)->size > ((cache_ptr)->max_size)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ + ((entry_ptr)->accesses)++; \ + } + +#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ + { \ + ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + (entry_ptr)->pins++; \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ + } #else /* H5C_COLLECT_CACHE_ENTRY_STATS */ #define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) -#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ -{ \ - (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ - if((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ -} - -#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ -{ \ - (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ - if ( (entry_ptr)->is_pinned ) \ - (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ -} - -#define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ -{ \ - if ( take_ownership ) \ - (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ - else \ - (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ -} - -#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ -{ \ - (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ - if ( (entry_ptr)->is_pinned ) { \ - (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ - } \ - if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ - if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - cache_ptr->entries_inserted_counter++; \ -} - -#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ -{ \ - if ( hit ) \ - ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ - else \ - ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ - if ( ! ((entry_ptr)->is_read_only) ) \ - ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ - else { \ - ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ - if ( ((entry_ptr)->ro_ref_count) > \ - ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = \ - ((entry_ptr)->ro_ref_count); \ - } \ - if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ( (cache_ptr)->pl_len > (cache_ptr)->max_pl_len ) \ - (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ - if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ -} - -#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ -{ \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ -} +#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ + { \ + (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ + if ((entry_ptr)->is_pinned) \ + (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ + } + +#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ + { \ + (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ + if ((entry_ptr)->is_pinned) \ + (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ + } + +#define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ + { \ + if (take_ownership) \ + (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ + else \ + (((cache_ptr)->evictions)[(entry_ptr)->type->id])++; \ + } + +#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ + { \ + (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ + if ((entry_ptr)->is_pinned) { \ + (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ + ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ + } \ + if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + cache_ptr->entries_inserted_counter++; \ + } + +#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ + { \ + if (hit) \ + ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ + else \ + ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ + if (!((entry_ptr)->is_read_only)) \ + ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ + else { \ + ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ + if (((entry_ptr)->ro_ref_count) > ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id]) \ + ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = ((entry_ptr)->ro_ref_count); \ + } \ + if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ((cache_ptr)->pl_len > (cache_ptr)->max_pl_len) \ + (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ + if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ + } + +#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ + { \ + ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ + } #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ @@ -945,7 +796,6 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #endif /* H5C_COLLECT_CACHE_STATS */ - /*********************************************************************** * * Hash table access and manipulation macros: @@ -978,9 +828,9 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ * * JRM -- 10/15/15 * - * - Updated the existing index macros to maintain a second - * hash table when cache_ptr->vfd_swrm_writer is true. This - * hash table bins entries by the page buffer page they reside + * - Updated the existing index macros to maintain a second + * hash table when cache_ptr->vfd_swrm_writer is true. This + * hash table bins entries by the page buffer page they reside * in, thus facilitating the eviction of entries on a given page * when that page is modified. * @@ -990,355 +840,248 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ /* H5C__HASH_TABLE_LEN is defined in H5Cpkg.h. It must be a power of two. */ -#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) +#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) -#define H5C__HASH_FCN(x) (int)((unsigned)((x) & H5C__HASH_MASK) >> 3) +#define H5C__HASH_FCN(x) (int)((unsigned)((x)&H5C__HASH_MASK) >> 3) - -/* H5C__PAGE_HASH_TABLE_LEN is defined in H5Cpkg.h. - * It must ve a power of two. +/* H5C__PAGE_HASH_TABLE_LEN is defined in H5Cpkg.h. + * It must ve a power of two. */ -#define H5C__PI_HASH_MASK ((uint64_t)(H5C__PAGE_HASH_TABLE_LEN - 1)) - -#define H5C__PI_HASH_FCN(x) (int)(((uint64_t)(x)) & H5C__PI_HASH_MASK) +#define H5C__PI_HASH_MASK ((uint64_t)(H5C__PAGE_HASH_TABLE_LEN - 1)) +#define H5C__PI_HASH_FCN(x) (int)(((uint64_t)(x)) & H5C__PI_HASH_MASK) #if H5C_DO_SANITY_CHECKS -#define H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (entry_ptr) == NULL ) || \ - ( ! H5F_addr_defined((entry_ptr)->addr) ) || \ - ( (entry_ptr)->ht_next != NULL ) || \ - ( (entry_ptr)->ht_prev != NULL ) || \ - ( (entry_ptr)->pi_next != NULL ) || \ - ( (entry_ptr)->pi_prev != NULL ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( H5C__HASH_FCN((entry_ptr)->addr) < 0 ) || \ - ( H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT insert SC failed") \ -} - -#define H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] == 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT insert SC failed") \ -} - -#define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len < 1 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( ! H5F_addr_defined((entry_ptr)->addr) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( H5C__HASH_FCN((entry_ptr)->addr) < 0 ) || \ - ( H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN ) || \ - ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] \ - == NULL ) || \ - ( ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] \ - != (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev == NULL ) ) || \ - ( ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == \ - (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev != NULL ) ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( ( (cache_ptr)->vfd_swmr_reader ) && \ - ( ( ( (cache_ptr)->page_index[(H5C__PI_HASH_FCN((entry_ptr)->page))] \ - != (entry_ptr) ) && \ - ( (entry_ptr)->pi_prev == NULL ) ) || \ - ( ( (cache_ptr)->page_index[(H5C__PI_HASH_FCN((entry_ptr)->page))] \ - == (entry_ptr) ) && \ - ( (entry_ptr)->pi_prev != NULL ) ) ) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] < \ - (entry_ptr)->size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ - HDassert(FALSE && "pre HT remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT remove SC failed") \ -} - -#define H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (entry_ptr) == NULL ) || \ - ( ! H5F_addr_defined((entry_ptr)->addr) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( (entry_ptr)->ht_prev != NULL ) || \ - ( (entry_ptr)->ht_next != NULL ) || \ - ( (entry_ptr)->pi_prev != NULL ) || \ - ( (entry_ptr)->pi_next != NULL ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ - HDassert(FALSE && "post HT remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT remove SC failed") \ -} +#define H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((entry_ptr) == NULL) || \ + (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->ht_next != NULL) || \ + ((entry_ptr)->ht_prev != NULL) || ((entry_ptr)->pi_next != NULL) || \ + ((entry_ptr)->pi_prev != NULL) || ((entry_ptr)->size <= 0) || \ + (H5C__HASH_FCN((entry_ptr)->addr) < 0) || \ + (H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT insert SC failed") \ + } + +#define H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] == 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT insert SC failed") \ + } + +#define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((cache_ptr)->index_len < 1) || \ + ((entry_ptr) == NULL) || ((cache_ptr)->index_size < (entry_ptr)->size) || \ + (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->size <= 0) || \ + (H5C__HASH_FCN((entry_ptr)->addr) < 0) || \ + (H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN) || \ + (((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == NULL) || \ + ((((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] != (entry_ptr)) && \ + ((entry_ptr)->ht_prev == NULL)) || \ + ((((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == (entry_ptr)) && \ + ((entry_ptr)->ht_prev != NULL)) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + (((cache_ptr)->vfd_swmr_reader) && \ + ((((cache_ptr)->page_index[(H5C__PI_HASH_FCN((entry_ptr)->page))] != (entry_ptr)) && \ + ((entry_ptr)->pi_prev == NULL)) || \ + (((cache_ptr)->page_index[(H5C__PI_HASH_FCN((entry_ptr)->page))] == (entry_ptr)) && \ + ((entry_ptr)->pi_prev != NULL)))) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] < (entry_ptr)->size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE && "pre HT remove SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT remove SC failed") \ + } + +#define H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((entry_ptr) == NULL) || \ + (!H5F_addr_defined((entry_ptr)->addr)) || ((entry_ptr)->size <= 0) || \ + ((entry_ptr)->ht_prev != NULL) || ((entry_ptr)->ht_next != NULL) || \ + ((entry_ptr)->pi_prev != NULL) || ((entry_ptr)->pi_next != NULL) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE && "post HT remove SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT remove SC failed") \ + } /* (Keep in sync w/H5C_TEST__PRE_HT_SEARCH_SC macro in test/cache_common.h -QAK) */ -#define H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( ! H5F_addr_defined(Addr) ) || \ - ( H5C__HASH_FCN(Addr) < 0 ) || \ - ( H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT search SC failed") \ -} - -/* (Keep in sync w/H5C_TEST__POST_SUC_HT_SEARCH_SC macro in - * test/cache_common.h -QAK) +#define H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + (!H5F_addr_defined(Addr)) || (H5C__HASH_FCN(Addr) < 0) || \ + (H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN)) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT search SC failed") \ + } + +/* (Keep in sync w/H5C_TEST__POST_SUC_HT_SEARCH_SC macro in + * test/cache_common.h -QAK) */ -#define H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len < 1 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( ((cache_ptr)->index)[k] == NULL ) || \ - ( ( ((cache_ptr)->index)[k] != (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev == NULL ) ) || \ - ( ( ((cache_ptr)->index)[k] == (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev != NULL ) ) || \ - ( ( (entry_ptr)->ht_prev != NULL ) && \ - ( (entry_ptr)->ht_prev->ht_next != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->ht_next != NULL ) && \ - ( (entry_ptr)->ht_next->ht_prev != (entry_ptr) ) ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, \ - "post successful HT search SC failed") \ -} - -/* (Keep in sync w/H5C_TEST__POST_HT_SHIFT_TO_FRONT macro in - * test/cache_common.h -QAK) +#define H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((cache_ptr)->index_len < 1) || \ + ((entry_ptr) == NULL) || ((cache_ptr)->index_size < (entry_ptr)->size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->size <= 0) || (((cache_ptr)->index)[k] == NULL) || \ + ((((cache_ptr)->index)[k] != (entry_ptr)) && ((entry_ptr)->ht_prev == NULL)) || \ + ((((cache_ptr)->index)[k] == (entry_ptr)) && ((entry_ptr)->ht_prev != NULL)) || \ + (((entry_ptr)->ht_prev != NULL) && ((entry_ptr)->ht_prev->ht_next != (entry_ptr))) || \ + (((entry_ptr)->ht_next != NULL) && ((entry_ptr)->ht_next->ht_prev != (entry_ptr)))) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post successful HT search SC failed") \ + } + +/* (Keep in sync w/H5C_TEST__POST_HT_SHIFT_TO_FRONT macro in + * test/cache_common.h -QAK) */ -#define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( ((cache_ptr)->index)[k] != (entry_ptr) ) || \ - ( (entry_ptr)->ht_prev != NULL ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, \ - "post HT shift to front SC failed") \ -} - -#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->index_len <= 0 ) || \ - ( (cache_ptr)->index_size <= 0 ) || \ - ( (new_size) <= 0 ) || \ - ( (old_size) > (cache_ptr)->index_size ) || \ - ( ( (cache_ptr)->index_len == 1 ) && \ - ( (cache_ptr)->index_size != (old_size) ) ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( ( !( was_clean ) || \ - ( (cache_ptr)->clean_index_size < (old_size) ) ) && \ - ( ( (was_clean) ) || \ - ( (cache_ptr)->dirty_index_size < (old_size) ) ) ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "pre HT entry size change SC failed") \ -} - -#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->index_len <= 0 ) || \ - ( (cache_ptr)->index_size <= 0 ) || \ - ( (new_size) > (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( ( !((entry_ptr)->is_dirty ) || \ - ( (cache_ptr)->dirty_index_size < (new_size) ) ) && \ - ( ( ((entry_ptr)->is_dirty) ) || \ - ( (cache_ptr)->clean_index_size < (new_size) ) ) ) || \ - ( ( (cache_ptr)->index_len == 1 ) && \ - ( (cache_ptr)->index_size != (new_size) ) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "post HT entry size change SC failed") \ -} - -#define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) \ -if ( \ - ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len <= 0 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->is_dirty != FALSE ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->dirty_index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "pre HT update for entry clean SC failed") \ -} - -#define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) \ -if ( \ - ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len <= 0 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->is_dirty != TRUE ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->clean_index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "pre HT update for entry dirty SC failed") \ -} - -#define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) \ -if ( ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "post HT update for entry clean SC failed") \ -} - -#define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) \ -if ( ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "post HT update for entry dirty SC failed") \ -} +#define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ + if (((cache_ptr) == NULL) || (((cache_ptr)->index)[k] != (entry_ptr)) || \ + ((entry_ptr)->ht_prev != NULL)) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT shift to front SC failed") \ + } + +#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr, was_clean) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->index_len <= 0) || ((cache_ptr)->index_size <= 0) || \ + ((new_size) <= 0) || ((old_size) > (cache_ptr)->index_size) || \ + (((cache_ptr)->index_len == 1) && ((cache_ptr)->index_size != (old_size))) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((!(was_clean) || ((cache_ptr)->clean_index_size < (old_size))) && \ + (((was_clean)) || ((cache_ptr)->dirty_index_size < (old_size)))) || \ + ((entry_ptr) == NULL) || ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || \ + ((entry_ptr)->ring >= H5C_RING_NTYPES) || ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT entry size change SC failed") \ + } + +#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->index_len <= 0) || ((cache_ptr)->index_size <= 0) || \ + ((new_size) > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((!((entry_ptr)->is_dirty) || ((cache_ptr)->dirty_index_size < (new_size))) && \ + ((((entry_ptr)->is_dirty)) || ((cache_ptr)->clean_index_size < (new_size)))) || \ + (((cache_ptr)->index_len == 1) && ((cache_ptr)->index_size != (new_size))) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring])) || \ + ((cache_ptr)->index_len != (cache_ptr)->il_len) || \ + ((cache_ptr)->index_size != (cache_ptr)->il_size)) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT entry size change SC failed") \ + } + +#define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_len <= 0) || ((entry_ptr) == NULL) || ((entry_ptr)->is_dirty != FALSE) || \ + ((cache_ptr)->index_size < (entry_ptr)->size) || \ + ((cache_ptr)->dirty_index_size < (entry_ptr)->size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT update for entry clean SC failed") \ + } + +#define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_len <= 0) || ((entry_ptr) == NULL) || ((entry_ptr)->is_dirty != TRUE) || \ + ((cache_ptr)->index_size < (entry_ptr)->size) || \ + ((cache_ptr)->clean_index_size < (entry_ptr)->size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->ring <= H5C_RING_UNDEFINED) || ((entry_ptr)->ring >= H5C_RING_NTYPES) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT update for entry dirty SC failed") \ + } + +#define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) \ + if (((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT update for entry clean SC failed") \ + } + +#define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) \ + if (((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->clean_index_size)) || \ + ((cache_ptr)->index_size < ((cache_ptr)->dirty_index_size)) || \ + ((cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size) || \ + ((cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT update for entry dirty SC failed") \ + } #else /* H5C_DO_SANITY_CHECKS */ @@ -1351,224 +1094,207 @@ if ( ( (cache_ptr)->index_size != \ #define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) #define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) #define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) -#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) -#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr) +#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr, was_clean) +#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr) #define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) #define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) #endif /* H5C_DO_SANITY_CHECKS */ +#define H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, fail_val) \ + { \ + int k; \ + H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ + if (cache_ptr->vfd_swmr_reader) { \ + k = H5C__PI_HASH_FCN((entry_ptr)->page); \ + if (((cache_ptr)->page_index)[k] != NULL) { \ + (entry_ptr)->pi_next = ((cache_ptr)->page_index)[k]; \ + (entry_ptr)->pi_next->pi_prev = (entry_ptr); \ + } \ + ((cache_ptr)->page_index)[k] = (entry_ptr); \ + } \ + k = H5C__HASH_FCN((entry_ptr)->addr); \ + if (((cache_ptr)->index)[k] != NULL) { \ + (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr); \ + } \ + ((cache_ptr)->index)[k] = (entry_ptr); \ + (cache_ptr)->index_len++; \ + (cache_ptr)->index_size += (entry_ptr)->size; \ + ((cache_ptr)->index_ring_len[entry_ptr->ring])++; \ + ((cache_ptr)->index_ring_size[entry_ptr->ring]) += (entry_ptr)->size; \ + if ((entry_ptr)->is_dirty) { \ + (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) += (entry_ptr)->size; \ + } \ + else { \ + (cache_ptr)->clean_index_size += (entry_ptr)->size; \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) += (entry_ptr)->size; \ + } \ + if ((entry_ptr)->flush_me_last) { \ + (cache_ptr)->num_last_entries++; \ + HDassert((cache_ptr)->num_last_entries <= 2); \ + } \ + H5C__IL_DLL_APPEND((entry_ptr), (cache_ptr)->il_head, (cache_ptr)->il_tail, (cache_ptr)->il_len, \ + (cache_ptr)->il_size, fail_val) \ + H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ + H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ + } + +#define H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, fail_val) \ + { \ + int k; \ + H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ + if (cache_ptr->vfd_swmr_reader) { \ + k = H5C__PI_HASH_FCN((entry_ptr)->page); \ + if ((entry_ptr)->pi_next) { \ + (entry_ptr)->pi_next->pi_prev = (entry_ptr)->pi_prev; \ + } \ + if ((entry_ptr)->pi_prev) { \ + (entry_ptr)->pi_prev->pi_next = (entry_ptr)->pi_next; \ + } \ + if (((cache_ptr)->page_index)[k] == (entry_ptr)) { \ + ((cache_ptr)->page_index)[k] = (entry_ptr)->pi_next; \ + } \ + (entry_ptr)->pi_next = NULL; \ + (entry_ptr)->pi_prev = NULL; \ + } \ + k = H5C__HASH_FCN((entry_ptr)->addr); \ + if ((entry_ptr)->ht_next) { \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + } \ + if ((entry_ptr)->ht_prev) { \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + } \ + if (((cache_ptr)->index)[k] == (entry_ptr)) { \ + ((cache_ptr)->index)[k] = (entry_ptr)->ht_next; \ + } \ + (entry_ptr)->ht_next = NULL; \ + (entry_ptr)->ht_prev = NULL; \ + (cache_ptr)->index_len--; \ + (cache_ptr)->index_size -= (entry_ptr)->size; \ + ((cache_ptr)->index_ring_len[entry_ptr->ring])--; \ + ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ + if ((entry_ptr)->is_dirty) { \ + (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ + } \ + else { \ + (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ + } \ + if ((entry_ptr)->flush_me_last) { \ + (cache_ptr)->num_last_entries--; \ + HDassert((cache_ptr)->num_last_entries <= 1); \ + } \ + H5C__IL_DLL_REMOVE((entry_ptr), (cache_ptr)->il_head, (cache_ptr)->il_tail, (cache_ptr)->il_len, \ + (cache_ptr)->il_size, fail_val) \ + H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ + H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) \ + } + +#define H5C__SEARCH_INDEX(cache_ptr, Addr, entry_ptr, fail_val) \ + { \ + int k; \ + int depth = 0; \ + H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ + k = H5C__HASH_FCN(Addr); \ + entry_ptr = ((cache_ptr)->index)[k]; \ + while (entry_ptr) { \ + if (H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ + H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ + if (entry_ptr != ((cache_ptr)->index)[k]) { \ + if ((entry_ptr)->ht_next) \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + HDassert((entry_ptr)->ht_prev != NULL); \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ + (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ + (entry_ptr)->ht_prev = NULL; \ + ((cache_ptr)->index)[k] = (entry_ptr); \ + H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ + } \ + break; \ + } \ + (entry_ptr) = (entry_ptr)->ht_next; \ + (depth)++; \ + } \ + H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, (entry_ptr != NULL), depth) \ + } + +#define H5C__SEARCH_INDEX_NO_STATS(cache_ptr, Addr, entry_ptr, fail_val) \ + { \ + int k; \ + H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ + k = H5C__HASH_FCN(Addr); \ + entry_ptr = ((cache_ptr)->index)[k]; \ + while (entry_ptr) { \ + if (H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ + H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ + if (entry_ptr != ((cache_ptr)->index)[k]) { \ + if ((entry_ptr)->ht_next) \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + HDassert((entry_ptr)->ht_prev != NULL); \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ + (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ + (entry_ptr)->ht_prev = NULL; \ + ((cache_ptr)->index)[k] = (entry_ptr); \ + H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ + } \ + break; \ + } \ + (entry_ptr) = (entry_ptr)->ht_next; \ + } \ + } + +#define H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr) \ + { \ + H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ + (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ + (cache_ptr)->clean_index_size += (entry_ptr)->size; \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) += (entry_ptr)->size; \ + H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ + } + +#define H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) \ + { \ + H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ + (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) -= (entry_ptr)->size; \ + (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) += (entry_ptr)->size; \ + H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ + } + +#define H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size, entry_ptr, was_clean) \ + { \ + H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr, was_clean) \ + (cache_ptr)->index_size -= (old_size); \ + (cache_ptr)->index_size += (new_size); \ + ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (old_size); \ + ((cache_ptr)->index_ring_size[entry_ptr->ring]) += (new_size); \ + if (was_clean) { \ + (cache_ptr)->clean_index_size -= (old_size); \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) -= (old_size); \ + } \ + else { \ + (cache_ptr)->dirty_index_size -= (old_size); \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) -= (old_size); \ + } \ + if ((entry_ptr)->is_dirty) { \ + (cache_ptr)->dirty_index_size += (new_size); \ + ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) += (new_size); \ + } \ + else { \ + (cache_ptr)->clean_index_size += (new_size); \ + ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) += (new_size); \ + } \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->il_len, (cache_ptr)->il_size, (old_size), (new_size)) \ + H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr) \ + } -#define H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, fail_val) \ -{ \ - int k; \ - H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ - if ( cache_ptr->vfd_swmr_reader ) { \ - k = H5C__PI_HASH_FCN((entry_ptr)->page); \ - if ( ( (cache_ptr)->page_index)[k] != NULL ) { \ - (entry_ptr)->pi_next = ((cache_ptr)->page_index)[k]; \ - (entry_ptr)->pi_next->pi_prev = (entry_ptr); \ - } \ - ((cache_ptr)->page_index)[k] = (entry_ptr); \ - } \ - k = H5C__HASH_FCN((entry_ptr)->addr); \ - if(((cache_ptr)->index)[k] != NULL) { \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr); \ - } \ - ((cache_ptr)->index)[k] = (entry_ptr); \ - (cache_ptr)->index_len++; \ - (cache_ptr)->index_size += (entry_ptr)->size; \ - ((cache_ptr)->index_ring_len[entry_ptr->ring])++; \ - ((cache_ptr)->index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ - if((entry_ptr)->is_dirty) { \ - (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ - } else { \ - (cache_ptr)->clean_index_size += (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ - } \ - if((entry_ptr)->flush_me_last) { \ - (cache_ptr)->num_last_entries++; \ - HDassert((cache_ptr)->num_last_entries <= 2); \ - } \ - H5C__IL_DLL_APPEND((entry_ptr), (cache_ptr)->il_head, \ - (cache_ptr)->il_tail, (cache_ptr)->il_len, \ - (cache_ptr)->il_size, fail_val) \ - H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ - H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ -} - -#define H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, fail_val) \ -{ \ - int k; \ - H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ - if ( cache_ptr->vfd_swmr_reader ) { \ - k = H5C__PI_HASH_FCN((entry_ptr)->page); \ - if ( (entry_ptr)->pi_next ) { \ - (entry_ptr)->pi_next->pi_prev = (entry_ptr)->pi_prev; \ - } \ - if ( (entry_ptr)->pi_prev ) { \ - (entry_ptr)->pi_prev->pi_next = (entry_ptr)->pi_next; \ - } \ - if ( ( (cache_ptr)->page_index)[k] == (entry_ptr) ) { \ - ((cache_ptr)->page_index)[k] = (entry_ptr)->pi_next; \ - } \ - (entry_ptr)->pi_next = NULL; \ - (entry_ptr)->pi_prev = NULL; \ - } \ - k = H5C__HASH_FCN((entry_ptr)->addr); \ - if ( (entry_ptr)->ht_next ) { \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - } \ - if ( (entry_ptr)->ht_prev ) { \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - } \ - if ( ( (cache_ptr)->index)[k] == (entry_ptr) ) { \ - ((cache_ptr)->index)[k] = (entry_ptr)->ht_next; \ - } \ - (entry_ptr)->ht_next = NULL; \ - (entry_ptr)->ht_prev = NULL; \ - (cache_ptr)->index_len--; \ - (cache_ptr)->index_size -= (entry_ptr)->size; \ - ((cache_ptr)->index_ring_len[entry_ptr->ring])--; \ - ((cache_ptr)->index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ - if ( (entry_ptr)->is_dirty ) { \ - (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ - } else { \ - (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ - } \ - if ( (entry_ptr)->flush_me_last ) { \ - (cache_ptr)->num_last_entries--; \ - HDassert((cache_ptr)->num_last_entries <= 1); \ - } \ - H5C__IL_DLL_REMOVE((entry_ptr), (cache_ptr)->il_head, \ - (cache_ptr)->il_tail, (cache_ptr)->il_len, \ - (cache_ptr)->il_size, fail_val) \ - H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ - H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) \ -} - -#define H5C__SEARCH_INDEX(cache_ptr, Addr, entry_ptr, fail_val) \ -{ \ - int k; \ - int depth = 0; \ - H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ - k = H5C__HASH_FCN(Addr); \ - entry_ptr = ((cache_ptr)->index)[k]; \ - while(entry_ptr) { \ - if(H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ - H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ - if(entry_ptr != ((cache_ptr)->index)[k]) { \ - if((entry_ptr)->ht_next) \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - HDassert((entry_ptr)->ht_prev != NULL); \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ - (entry_ptr)->ht_prev = NULL; \ - ((cache_ptr)->index)[k] = (entry_ptr); \ - H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ - } \ - break; \ - } \ - (entry_ptr) = (entry_ptr)->ht_next; \ - (depth)++; \ - } \ - H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, (entry_ptr != NULL), depth) \ -} - -#define H5C__SEARCH_INDEX_NO_STATS(cache_ptr, Addr, entry_ptr, fail_val) \ -{ \ - int k; \ - H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ - k = H5C__HASH_FCN(Addr); \ - entry_ptr = ((cache_ptr)->index)[k]; \ - while(entry_ptr) { \ - if(H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ - H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ - if(entry_ptr != ((cache_ptr)->index)[k]) { \ - if((entry_ptr)->ht_next) \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - HDassert((entry_ptr)->ht_prev != NULL); \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ - (entry_ptr)->ht_prev = NULL; \ - ((cache_ptr)->index)[k] = (entry_ptr); \ - H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ - } \ - break; \ - } \ - (entry_ptr) = (entry_ptr)->ht_next; \ - } \ -} - -#define H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr) \ -{ \ - H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ - (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ - (cache_ptr)->clean_index_size += (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ - H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ -} - -#define H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) \ -{ \ - H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ - (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ - (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ - H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ -} - -#define H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ -{ \ - H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ - (cache_ptr)->index_size -= (old_size); \ - (cache_ptr)->index_size += (new_size); \ - ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (old_size); \ - ((cache_ptr)->index_ring_size[entry_ptr->ring]) += (new_size); \ - if(was_clean) { \ - (cache_ptr)->clean_index_size -= (old_size); \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring])-= (old_size); \ - } else { \ - (cache_ptr)->dirty_index_size -= (old_size); \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring])-= (old_size); \ - } \ - if((entry_ptr)->is_dirty) { \ - (cache_ptr)->dirty_index_size += (new_size); \ - ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring])+= (new_size); \ - } else { \ - (cache_ptr)->clean_index_size += (new_size); \ - ((cache_ptr)->clean_index_ring_size[entry_ptr->ring])+= (new_size); \ - } \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->il_len, \ - (cache_ptr)->il_size, \ - (old_size), (new_size)) \ - H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr) \ -} - - /************************************************************************** * * Skip list insertion and deletion macros: @@ -1638,83 +1364,77 @@ if ( ( (cache_ptr)->index_size != \ */ #if H5C_DO_SLIST_SANITY_CHECKS -#define ENTRY_IN_SLIST(cache_ptr, entry_ptr) \ - H5C_entry_in_skip_list((cache_ptr), (entry_ptr)) +#define ENTRY_IN_SLIST(cache_ptr, entry_ptr) H5C_entry_in_skip_list((cache_ptr), (entry_ptr)) #else /* H5C_DO_SLIST_SANITY_CHECKS */ #define ENTRY_IN_SLIST(cache_ptr, entry_ptr) FALSE #endif /* H5C_DO_SLIST_SANITY_CHECKS */ #if H5C_DO_SANITY_CHECKS -#define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->size > 0 ); \ - HDassert( H5F_addr_defined((entry_ptr)->addr) ); \ - HDassert( !((entry_ptr)->in_slist) ); \ - HDassert( !ENTRY_IN_SLIST((cache_ptr), (entry_ptr)) ); \ - HDassert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - HDassert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - HDassert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - \ - if(H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ - \ - (entry_ptr)->in_slist = TRUE; \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len++; \ - (cache_ptr)->slist_size += (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size; \ - (cache_ptr)->slist_len_increase++; \ - (cache_ptr)->slist_size_increase += (int64_t)((entry_ptr)->size); \ - \ - HDassert( (cache_ptr)->slist_len > 0 ); \ - HDassert( (cache_ptr)->slist_size > 0 ); \ - \ -} /* H5C__INSERT_ENTRY_IN_SLIST */ +#define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->size > 0); \ + HDassert(H5F_addr_defined((entry_ptr)->addr)); \ + HDassert(!((entry_ptr)->in_slist)); \ + HDassert(!ENTRY_IN_SLIST((cache_ptr), (entry_ptr))); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + if (H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) < 0) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ + \ + (entry_ptr)->in_slist = TRUE; \ + (cache_ptr)->slist_changed = TRUE; \ + (cache_ptr)->slist_len++; \ + (cache_ptr)->slist_size += (entry_ptr)->size; \ + ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size; \ + (cache_ptr)->slist_len_increase++; \ + (cache_ptr)->slist_size_increase += (int64_t)((entry_ptr)->size); \ + \ + HDassert((cache_ptr)->slist_len > 0); \ + HDassert((cache_ptr)->slist_size > 0); \ + \ + } /* H5C__INSERT_ENTRY_IN_SLIST */ #else /* H5C_DO_SANITY_CHECKS */ -#define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->size > 0 ); \ - HDassert( H5F_addr_defined((entry_ptr)->addr) ); \ - HDassert( !((entry_ptr)->in_slist) ); \ - HDassert( !ENTRY_IN_SLIST((cache_ptr), (entry_ptr)) ); \ - HDassert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - HDassert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - HDassert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - \ - if(H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ - \ - (entry_ptr)->in_slist = TRUE; \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len++; \ - (cache_ptr)->slist_size += (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size; \ - \ - HDassert( (cache_ptr)->slist_len > 0 ); \ - HDassert( (cache_ptr)->slist_size > 0 ); \ - \ -} /* H5C__INSERT_ENTRY_IN_SLIST */ +#define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->size > 0); \ + HDassert(H5F_addr_defined((entry_ptr)->addr)); \ + HDassert(!((entry_ptr)->in_slist)); \ + HDassert(!ENTRY_IN_SLIST((cache_ptr), (entry_ptr))); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + if (H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) < 0) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ + \ + (entry_ptr)->in_slist = TRUE; \ + (cache_ptr)->slist_changed = TRUE; \ + (cache_ptr)->slist_len++; \ + (cache_ptr)->slist_size += (entry_ptr)->size; \ + ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size; \ + \ + HDassert((cache_ptr)->slist_len > 0); \ + HDassert((cache_ptr)->slist_size > 0); \ + \ + } /* H5C__INSERT_ENTRY_IN_SLIST */ #endif /* H5C_DO_SANITY_CHECKS */ - /*------------------------------------------------------------------------- * * Function: H5C__REMOVE_ENTRY_FROM_SLIST @@ -1731,79 +1451,70 @@ if ( ( (cache_ptr)->index_size != \ */ #if H5C_DO_SANITY_CHECKS -#define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - HDassert( (entry_ptr)->in_slist ); \ - HDassert( (cache_ptr)->slist_ptr ); \ - HDassert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - HDassert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - HDassert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - \ - if ( H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) \ - != (entry_ptr) ) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't delete entry from skip list") \ - \ - HDassert( (cache_ptr)->slist_len > 0 ); \ - if(!(during_flush)) \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len--; \ - HDassert( (cache_ptr)->slist_size >= (entry_ptr)->size ); \ - (cache_ptr)->slist_size -= (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= \ - (entry_ptr)->size ); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size; \ - (cache_ptr)->slist_len_increase--; \ - (cache_ptr)->slist_size_increase -= (int64_t)((entry_ptr)->size); \ - (entry_ptr)->in_slist = FALSE; \ -} /* H5C__REMOVE_ENTRY_FROM_SLIST */ +#define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + HDassert((entry_ptr)->in_slist); \ + HDassert((cache_ptr)->slist_ptr); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + if (H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) != (entry_ptr)) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't delete entry from skip list") \ + \ + HDassert((cache_ptr)->slist_len > 0); \ + if (!(during_flush)) \ + (cache_ptr)->slist_changed = TRUE; \ + (cache_ptr)->slist_len--; \ + HDassert((cache_ptr)->slist_size >= (entry_ptr)->size); \ + (cache_ptr)->slist_size -= (entry_ptr)->size; \ + ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (entry_ptr)->size); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size; \ + (cache_ptr)->slist_len_increase--; \ + (cache_ptr)->slist_size_increase -= (int64_t)((entry_ptr)->size); \ + (entry_ptr)->in_slist = FALSE; \ + } /* H5C__REMOVE_ENTRY_FROM_SLIST */ #else /* H5C_DO_SANITY_CHECKS */ -#define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->in_slist ); \ - HDassert( (cache_ptr)->slist_ptr ); \ - HDassert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - HDassert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - HDassert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - \ - if ( H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) \ - != (entry_ptr) ) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't delete entry from skip list") \ - \ - HDassert( (cache_ptr)->slist_len > 0 ); \ - if(!(during_flush)) \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len--; \ - HDassert( (cache_ptr)->slist_size >= (entry_ptr)->size ); \ - (cache_ptr)->slist_size -= (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= \ - (entry_ptr)->size ); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size; \ - (entry_ptr)->in_slist = FALSE; \ -} /* H5C__REMOVE_ENTRY_FROM_SLIST */ +#define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->in_slist); \ + HDassert((cache_ptr)->slist_ptr); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + if (H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) != (entry_ptr)) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't delete entry from skip list") \ + \ + HDassert((cache_ptr)->slist_len > 0); \ + if (!(during_flush)) \ + (cache_ptr)->slist_changed = TRUE; \ + (cache_ptr)->slist_len--; \ + HDassert((cache_ptr)->slist_size >= (entry_ptr)->size); \ + (cache_ptr)->slist_size -= (entry_ptr)->size; \ + ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (entry_ptr)->size); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size; \ + (entry_ptr)->in_slist = FALSE; \ + } /* H5C__REMOVE_ENTRY_FROM_SLIST */ #endif /* H5C_DO_SANITY_CHECKS */ - /*------------------------------------------------------------------------- * * Function: H5C__UPDATE_SLIST_FOR_SIZE_CHANGE @@ -1841,72 +1552,63 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_DO_SANITY_CHECKS -#define H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (old_size) > 0 ); \ - HDassert( (new_size) > 0 ); \ - HDassert( (old_size) <= (cache_ptr)->slist_size ); \ - HDassert( (cache_ptr)->slist_len > 0 ); \ - HDassert( ((cache_ptr)->slist_len > 1) || \ - ( (cache_ptr)->slist_size == (old_size) ) ); \ - HDassert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - HDassert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - HDassert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - \ - (cache_ptr)->slist_size -= (old_size); \ - (cache_ptr)->slist_size += (new_size); \ - \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr->ring)] >=(old_size) ); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ - \ - (cache_ptr)->slist_size_increase -= (int64_t)(old_size); \ - (cache_ptr)->slist_size_increase += (int64_t)(new_size); \ - \ - HDassert( (new_size) <= (cache_ptr)->slist_size ); \ - HDassert( ( (cache_ptr)->slist_len > 1 ) || \ - ( (cache_ptr)->slist_size == (new_size) ) ); \ -} /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ +#define H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((old_size) > 0); \ + HDassert((new_size) > 0); \ + HDassert((old_size) <= (cache_ptr)->slist_size); \ + HDassert((cache_ptr)->slist_len > 0); \ + HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (old_size))); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + (cache_ptr)->slist_size -= (old_size); \ + (cache_ptr)->slist_size += (new_size); \ + \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (old_size)); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ + \ + (cache_ptr)->slist_size_increase -= (int64_t)(old_size); \ + (cache_ptr)->slist_size_increase += (int64_t)(new_size); \ + \ + HDassert((new_size) <= (cache_ptr)->slist_size); \ + HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (new_size))); \ + } /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ #else /* H5C_DO_SANITY_CHECKS */ -#define H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (old_size) > 0 ); \ - HDassert( (new_size) > 0 ); \ - HDassert( (old_size) <= (cache_ptr)->slist_size ); \ - HDassert( (cache_ptr)->slist_len > 0 ); \ - HDassert( ((cache_ptr)->slist_len > 1) || \ - ( (cache_ptr)->slist_size == (old_size) ) ); \ - HDassert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - HDassert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - HDassert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - \ - (cache_ptr)->slist_size -= (old_size); \ - (cache_ptr)->slist_size += (new_size); \ - \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr->ring)] >=(old_size) ); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ - \ - HDassert( (new_size) <= (cache_ptr)->slist_size ); \ - HDassert( ( (cache_ptr)->slist_len > 1 ) || \ - ( (cache_ptr)->slist_size == (new_size) ) ); \ -} /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ +#define H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((old_size) > 0); \ + HDassert((new_size) > 0); \ + HDassert((old_size) <= (cache_ptr)->slist_size); \ + HDassert((cache_ptr)->slist_len > 0); \ + HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (old_size))); \ + HDassert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + HDassert((entry_ptr)->ring < H5C_RING_NTYPES); \ + HDassert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= (cache_ptr)->slist_len); \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= (cache_ptr)->slist_size); \ + \ + (cache_ptr)->slist_size -= (old_size); \ + (cache_ptr)->slist_size += (new_size); \ + \ + HDassert((cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= (old_size)); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ + ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ + \ + HDassert((new_size) <= (cache_ptr)->slist_size); \ + HDassert(((cache_ptr)->slist_len > 1) || ((cache_ptr)->slist_size == (new_size))); \ + } /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ #endif /* H5C_DO_SANITY_CHECKS */ - /************************************************************************** * * Replacement policy update macros: @@ -1952,103 +1654,87 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ((entry_ptr)->is_pinned) ) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head.\ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Use the dirty flag to infer whether the entry is on the clean or \ - * dirty LRU list, and remove it. Then insert it at the head of \ - * the same LRU list. \ - * \ - * At least initially, all entries should be clean. That may \ - * change, so we may as well deal with both cases now. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - } else { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ +#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if (!((entry_ptr)->is_pinned)) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Use the dirty flag to infer whether the entry is on the clean or \ + * dirty LRU list, and remove it. Then insert it at the head of \ + * the same LRU list. \ + * \ + * At least initially, all entries should be clean. That may \ + * change, so we may as well deal with both cases now. \ + */ \ + \ + if ((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + } /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ((entry_ptr)->is_pinned) ) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ +#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if (!((entry_ptr)->is_pinned)) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the head \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + } /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_EVICTION @@ -2094,72 +1780,66 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( !((entry_ptr)->is_pinned) ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* If the entry is clean when it is evicted, it should be on the \ - * clean LRU list, if it was dirty, it should be on the dirty LRU list. \ - * Remove it from the appropriate list according to the value of the \ - * dirty flag. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - } else { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ -} /* H5C__UPDATE_RP_FOR_EVICTION */ +#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert(!((entry_ptr)->is_pinned)); \ + HDassert((entry_ptr)->size > 0); \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* If the entry is clean when it is evicted, it should be on the \ + * clean LRU list, if it was dirty, it should be on the dirty LRU list. \ + * Remove it from the appropriate list according to the value of the \ + * dirty flag. \ + */ \ + \ + if ((entry_ptr)->is_dirty) { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + } /* H5C__UPDATE_RP_FOR_EVICTION */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( !((entry_ptr)->is_pinned) ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ -} /* H5C__UPDATE_RP_FOR_EVICTION */ +#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert(!((entry_ptr)->is_pinned)); \ + HDassert((entry_ptr)->size > 0); \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + } /* H5C__UPDATE_RP_FOR_EVICTION */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_FLUSH @@ -2207,103 +1887,89 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ((entry_ptr)->is_pinned) ) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* since the entry is being flushed or cleared, one would think \ - * that it must be dirty -- but that need not be the case. Use the \ - * dirty flag to infer whether the entry is on the clean or dirty \ - * LRU list, and remove it. Then insert it at the head of the \ - * clean LRU list. \ - * \ - * The function presumes that a dirty entry will be either cleared \ - * or flushed shortly, so it is OK if we put a dirty entry on the \ - * clean LRU list. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - } else { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__UPDATE_RP_FOR_FLUSH */ +#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if (!((entry_ptr)->is_pinned)) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the \ + * head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* since the entry is being flushed or cleared, one would think \ + * that it must be dirty -- but that need not be the case. Use the \ + * dirty flag to infer whether the entry is on the clean or dirty \ + * LRU list, and remove it. Then insert it at the head of the \ + * clean LRU list. \ + * \ + * The function presumes that a dirty entry will be either cleared \ + * or flushed shortly, so it is OK if we put a dirty entry on the \ + * clean LRU list. \ + */ \ + \ + if ((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + } /* H5C__UPDATE_RP_FOR_FLUSH */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ((entry_ptr)->is_pinned) ) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__UPDATE_RP_FOR_FLUSH */ +#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if (!((entry_ptr)->is_pinned)) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the \ + * head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + } /* H5C__UPDATE_RP_FOR_FLUSH */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_INSERT_APPEND @@ -2333,91 +1999,79 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the tail of the LRU list. */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* insert the entry at the tail of the clean or dirty LRU list as \ - * appropriate. \ - */ \ - \ - if ( entry_ptr->is_dirty ) { \ - H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - } else { \ - H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ -} +#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the tail of the LRU list. */ \ + \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* insert the entry at the tail of the clean or dirty LRU list as \ + * appropriate. \ + */ \ + \ + if (entry_ptr->is_dirty) { \ + H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + } #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the tail of the LRU list. */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} +#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the tail of the LRU list. */ \ + \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + } #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_INSERTION @@ -2467,91 +2121,79 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* insert the entry at the head of the clean or dirty LRU list as \ - * appropriate. \ - */ \ - \ - if ( entry_ptr->is_dirty ) { \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - } else { \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ -} +#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* insert the entry at the head of the clean or dirty LRU list as \ + * appropriate. \ + */ \ + \ + if (entry_ptr->is_dirty) { \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + } #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} +#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + } #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_PROTECT @@ -2602,112 +2244,95 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, remove the entry from the clean or dirty LRU list \ - * as appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - /* Regardless of the replacement policy, or whether the entry is \ - * pinned, now add the entry to the protected list. \ - */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ - (cache_ptr)->pl_tail_ptr, \ - (cache_ptr)->pl_len, \ - (cache_ptr)->pl_size, (fail_val)) \ -} /* H5C__UPDATE_RP_FOR_PROTECT */ +#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Similarly, remove the entry from the clean or dirty LRU list \ + * as appropriate. \ + */ \ + \ + if ((entry_ptr)->is_dirty) { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + \ + /* Regardless of the replacement policy, or whether the entry is \ + * pinned, now add the entry to the protected list. \ + */ \ + \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, (cache_ptr)->pl_tail_ptr, \ + (cache_ptr)->pl_len, (cache_ptr)->pl_size, (fail_val)) \ + } /* H5C__UPDATE_RP_FOR_PROTECT */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - /* Regardless of the replacement policy, or whether the entry is \ - * pinned, now add the entry to the protected list. \ - */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ - (cache_ptr)->pl_tail_ptr, \ - (cache_ptr)->pl_len, \ - (cache_ptr)->pl_size, (fail_val)) \ -} /* H5C__UPDATE_RP_FOR_PROTECT */ +#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + \ + /* Regardless of the replacement policy, or whether the entry is \ + * pinned, now add the entry to the protected list. \ + */ \ + \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, (cache_ptr)->pl_tail_ptr, \ + (cache_ptr)->pl_len, (cache_ptr)->pl_size, (fail_val)) \ + } /* H5C__UPDATE_RP_FOR_PROTECT */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_MOVE @@ -2729,116 +2354,91 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* remove the entry from either the clean or dirty LUR list as \ - * indicated by the was_dirty parameter \ - */ \ - if ( was_dirty ) { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ - } \ - \ - /* insert the entry at the head of either the clean or dirty \ - * LRU list as appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__UPDATE_RP_FOR_MOVE */ +#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if (!((entry_ptr)->is_pinned) && !((entry_ptr->is_protected))) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* remove the entry from either the clean or dirty LUR list as \ + * indicated by the was_dirty parameter \ + */ \ + if (was_dirty) { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* insert the entry at the head of either the clean or dirty \ + * LRU list as appropriate. \ + */ \ + \ + if ((entry_ptr)->is_dirty) { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + } /* H5C__UPDATE_RP_FOR_MOVE */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__UPDATE_RP_FOR_MOVE */ +#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + \ + if (!((entry_ptr)->is_pinned) && !((entry_ptr->is_protected))) { \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list, and re-insert it at the head. \ + */ \ + \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + } /* H5C__UPDATE_RP_FOR_MOVE */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_SIZE_CHANGE @@ -2873,108 +2473,92 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - HDassert( new_size > 0 ); \ - \ - if ( (entry_ptr)->coll_access ) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ - } \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* Update the size of the LRU list */ \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ - /* Similarly, update the size of the clean or dirty LRU list as \ - * appropriate. At present, the entry must be clean, but that \ - * could change. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ - } else { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ -} /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + HDassert(new_size > 0); \ + \ + if ((entry_ptr)->coll_access) { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, \ + (entry_ptr)->size, (new_size)); \ + } \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, (cache_ptr)->pel_size, (entry_ptr)->size, \ + (new_size)); \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* Update the size of the LRU list */ \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, \ + (entry_ptr)->size, (new_size)); \ + \ + /* Similarly, update the size of the clean or dirty LRU list as \ + * appropriate. At present, the entry must be clean, but that \ + * could change. \ + */ \ + \ + if ((entry_ptr)->is_dirty) { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, \ + (entry_ptr)->size, (new_size)); \ + } \ + else { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, \ + (entry_ptr)->size, (new_size)); \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + \ + } /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->size > 0 ); \ - HDassert( new_size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* Update the size of the LRU list */ \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ - /* End modified LRU specific code. */ \ - } \ - \ -} /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->size > 0); \ + HDassert(new_size > 0); \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, (cache_ptr)->pel_size, (entry_ptr)->size, \ + (new_size)); \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* Update the size of the LRU list */ \ + \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, \ + (entry_ptr)->size, (new_size)); \ + \ + /* End modified LRU specific code. */ \ + } \ + \ + } /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_UNPIN @@ -3006,96 +2590,81 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->is_pinned); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * pinned entry list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, insert the entry at the head of either the clean \ - * or dirty LRU list as appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - \ -} /* H5C__UPDATE_RP_FOR_UNPIN */ +#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->is_pinned); \ + HDassert((entry_ptr)->size > 0); \ + \ + /* Regardless of the replacement policy, remove the entry from the \ + * pinned entry list. \ + */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Similarly, insert the entry at the head of either the clean \ + * or dirty LRU list as appropriate. \ + */ \ + \ + if ((entry_ptr)->is_dirty) { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + \ + } /* H5C__UPDATE_RP_FOR_UNPIN */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (entry_ptr)->is_pinned); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * pinned entry list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - \ -} /* H5C__UPDATE_RP_FOR_UNPIN */ +#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert(!((entry_ptr)->is_protected)); \ + HDassert(!((entry_ptr)->is_read_only)); \ + HDassert(((entry_ptr)->ro_ref_count) == 0); \ + HDassert((entry_ptr)->is_pinned); \ + HDassert((entry_ptr)->size > 0); \ + \ + /* Regardless of the replacement policy, remove the entry from the \ + * pinned entry list. \ + */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + \ + } /* H5C__UPDATE_RP_FOR_UNPIN */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - /*------------------------------------------------------------------------- * * Macro: H5C__UPDATE_RP_FOR_UNPROTECT @@ -3142,101 +2711,87 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->is_protected); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * protected list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, \ - (cache_ptr)->pl_tail_ptr, (cache_ptr)->pl_len, \ - (cache_ptr)->pl_size, (fail_val)) \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, insert the entry at the head of either the clean or \ - * dirty LRU list as appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ -} /* H5C__UPDATE_RP_FOR_UNPROTECT */ +#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->is_protected); \ + HDassert((entry_ptr)->size > 0); \ + \ + /* Regardless of the replacement policy, remove the entry from the \ + * protected list. \ + */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, (cache_ptr)->pl_tail_ptr, \ + (cache_ptr)->pl_len, (cache_ptr)->pl_size, (fail_val)) \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Similarly, insert the entry at the head of either the clean or \ + * dirty LRU list as appropriate. \ + */ \ + \ + if ((entry_ptr)->is_dirty) { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, (cache_ptr)->dLRU_list_size, (fail_val)) \ + } \ + else { \ + \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ + \ + /* End modified LRU specific code. */ \ + } \ + \ + } /* H5C__UPDATE_RP_FOR_UNPROTECT */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->is_protected); \ - HDassert( (entry_ptr)->size > 0 ); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * protected list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, \ - (cache_ptr)->pl_tail_ptr, (cache_ptr)->pl_len, \ - (cache_ptr)->pl_size, (fail_val)) \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__UPDATE_RP_FOR_UNPROTECT */ +#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->is_protected); \ + HDassert((entry_ptr)->size > 0); \ + \ + /* Regardless of the replacement policy, remove the entry from the \ + * protected list. \ + */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, (cache_ptr)->pl_tail_ptr, \ + (cache_ptr)->pl_len, (cache_ptr)->pl_size, (fail_val)) \ + \ + if ((entry_ptr)->is_pinned) { \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, (cache_ptr)->pel_size, (fail_val)) \ + } \ + else { \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + } \ + } /* H5C__UPDATE_RP_FOR_UNPROTECT */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ @@ -3244,70 +2799,39 @@ if ( ( (cache_ptr)->index_size != \ #if H5C_DO_SANITY_CHECKS -#define H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (hd_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (Size) < (entry_ptr)->size ) || \ - ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->coll_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->coll_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->coll_next == NULL ) && \ - ( (entry_ptr)->coll_prev == NULL ) && \ - ( (Size) == (entry_ptr)->size ) \ - ) \ - ) \ - ) \ - ) { \ - HDassert(0 && "coll DLL pre remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "coll DLL pre remove SC failed") \ -} - -#define H5C__COLL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( (len) < 0 ) || \ - ( (Size) < 0 ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->coll_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->coll_next != NULL ) \ - ) \ - ) \ - ) { \ - HDassert(0 && "COLL DLL sanity check failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed") \ -} - -#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->coll_next != NULL ) || \ - ( (entry_ptr)->coll_prev != NULL ) || \ - ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (hd_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->coll_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->coll_next != NULL ) \ - ) \ - ) \ - ) { \ - HDassert(0 && "COLL DLL pre insert SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL pre insert SC failed") \ -} +#define H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((hd_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ + ((Size) < (entry_ptr)->size) || (((Size) == (entry_ptr)->size) && (!((len) == 1))) || \ + (((entry_ptr)->coll_prev == NULL) && ((hd_ptr) != (entry_ptr))) || \ + (((entry_ptr)->coll_next == NULL) && ((tail_ptr) != (entry_ptr))) || \ + (((len) == 1) && \ + (!(((hd_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->coll_next == NULL) && \ + ((entry_ptr)->coll_prev == NULL) && ((Size) == (entry_ptr)->size))))) { \ + HDassert(0 && "coll DLL pre remove SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "coll DLL pre remove SC failed") \ + } + +#define H5C__COLL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || ((len) < 0) || \ + ((Size) < 0) || \ + (((len) == 1) && (((head_ptr) != (tail_ptr)) || ((Size) <= 0) || ((head_ptr) == NULL) || \ + ((head_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->coll_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->coll_next != NULL)))) { \ + HDassert(0 && "COLL DLL sanity check failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed") \ + } + +#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((entry_ptr) == NULL) || ((entry_ptr)->coll_next != NULL) || ((entry_ptr)->coll_prev != NULL) || \ + ((((hd_ptr) == NULL) || ((tail_ptr) == NULL)) && ((hd_ptr) != (tail_ptr))) || \ + (((len) == 1) && \ + (((hd_ptr) != (tail_ptr)) || ((Size) <= 0) || ((hd_ptr) == NULL) || ((hd_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((hd_ptr) == NULL) || ((hd_ptr)->coll_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->coll_next != NULL)))) { \ + HDassert(0 && "COLL DLL pre insert SC failed"); \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL pre insert SC failed") \ + } #else /* H5C_DO_SANITY_CHECKS */ @@ -3317,74 +2841,64 @@ if ( ( (entry_ptr) == NULL ) || \ #endif /* H5C_DO_SANITY_CHECKS */ +#define H5C__COLL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (tail_ptr)->coll_next = (entry_ptr); \ + (entry_ptr)->coll_prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ + } /* H5C__COLL_DLL_APPEND() */ + +#define H5C__COLL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (head_ptr)->coll_prev = (entry_ptr); \ + (entry_ptr)->coll_next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ + } /* H5C__COLL_DLL_PREPEND() */ + +#define H5C__COLL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + if ((head_ptr) == (entry_ptr)) { \ + (head_ptr) = (entry_ptr)->coll_next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->coll_prev = NULL; \ + } \ + else { \ + (entry_ptr)->coll_prev->coll_next = (entry_ptr)->coll_next; \ + } \ + if ((tail_ptr) == (entry_ptr)) { \ + (tail_ptr) = (entry_ptr)->coll_prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->coll_next = NULL; \ + } \ + else \ + (entry_ptr)->coll_next->coll_prev = (entry_ptr)->coll_prev; \ + entry_ptr->coll_next = NULL; \ + entry_ptr->coll_prev = NULL; \ + (len)--; \ + (Size) -= entry_ptr->size; \ + } \ + } /* H5C__COLL_DLL_REMOVE() */ -#define H5C__COLL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ -{ \ - H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->coll_next = (entry_ptr); \ - (entry_ptr)->coll_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ -} /* H5C__COLL_DLL_APPEND() */ - -#define H5C__COLL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -{ \ - H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv)\ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->coll_prev = (entry_ptr); \ - (entry_ptr)->coll_next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ -} /* H5C__COLL_DLL_PREPEND() */ - -#define H5C__COLL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -{ \ - H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv)\ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->coll_next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->coll_prev = NULL; \ - } \ - else \ - { \ - (entry_ptr)->coll_prev->coll_next = (entry_ptr)->coll_next; \ - } \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->coll_prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->coll_next = NULL; \ - } \ - else \ - (entry_ptr)->coll_next->coll_prev = (entry_ptr)->coll_prev; \ - entry_ptr->coll_next = NULL; \ - entry_ptr->coll_prev = NULL; \ - (len)--; \ - (Size) -= entry_ptr->size; \ - } \ -} /* H5C__COLL_DLL_REMOVE() */ - - /*------------------------------------------------------------------------- * * Macro: H5C__INSERT_IN_COLL_LIST @@ -3398,23 +2912,19 @@ if ( ( (entry_ptr) == NULL ) || \ *------------------------------------------------------------------------- */ -#define H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - \ - /* insert the entry at the head of the list. */ \ - \ - H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, \ - (cache_ptr)->coll_tail_ptr, \ - (cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (fail_val)) \ - \ -} /* H5C__INSERT_IN_COLL_LIST */ - - +#define H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + \ + /* insert the entry at the head of the list. */ \ + \ + H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, (cache_ptr)->coll_tail_ptr, \ + (cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, (fail_val)) \ + \ + } /* H5C__INSERT_IN_COLL_LIST */ + /*------------------------------------------------------------------------- * * Macro: H5C__REMOVE_FROM_COLL_LIST @@ -3428,23 +2938,19 @@ if ( ( (entry_ptr) == NULL ) || \ *------------------------------------------------------------------------- */ -#define H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - \ - /* remove the entry from the list. */ \ - \ - H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, \ - (cache_ptr)->coll_tail_ptr, \ - (cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (fail_val)) \ - \ -} /* H5C__REMOVE_FROM_COLL_LIST */ - - +#define H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + \ + /* remove the entry from the list. */ \ + \ + H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, (cache_ptr)->coll_tail_ptr, \ + (cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, (fail_val)) \ + \ + } /* H5C__REMOVE_FROM_COLL_LIST */ + /*------------------------------------------------------------------------- * * Macro: H5C__MOVE_TO_TOP_IN_COLL_LIST @@ -3458,29 +2964,22 @@ if ( ( (entry_ptr) == NULL ) || \ *------------------------------------------------------------------------- */ -#define H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - \ - /* Remove entry and insert at the head of the list. */ \ - H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, \ - (cache_ptr)->coll_tail_ptr, \ - (cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (fail_val)) \ - \ - H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, \ - (cache_ptr)->coll_tail_ptr, \ - (cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (fail_val)) \ - \ -} /* H5C__MOVE_TO_TOP_IN_COLL_LIST */ +#define H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ + { \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ + \ + /* Remove entry and insert at the head of the list. */ \ + H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, (cache_ptr)->coll_tail_ptr, \ + (cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, (fail_val)) \ + \ + H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, (cache_ptr)->coll_tail_ptr, \ + (cache_ptr)->coll_list_len, (cache_ptr)->coll_list_size, (fail_val)) \ + \ + } /* H5C__MOVE_TO_TOP_IN_COLL_LIST */ #endif /* H5_HAVE_PARALLEL */ - /***************************************/ /* page buffer hint maintenance macros */ /***************************************/ @@ -3489,13 +2988,13 @@ if ( ( (entry_ptr) == NULL ) || \ * * Macro: H5C__SET/RESET_PB_READ_HINTS * - * Purpose: Set or reset the fields needed to provide hints to the + * Purpose: Set or reset the fields needed to provide hints to the * page buffer so that it can disambuate between speculative - * reads that cross page boundaries and read of metadata - * entries that cross page boundaries without starting on + * reads that cross page boundaries and read of metadata + * entries that cross page boundaries without starting on * a page boundary. This latter behaviour shouldn't happen, - * and the hints allow the page buffer to detect this - * behaviour by un-expected cache client. + * and the hints allow the page buffer to detect this + * behaviour by un-expected cache client. * * See the discussion of the PB hint fields in the header * comment for H5C_t for further details. @@ -3511,36 +3010,35 @@ if ( ( (entry_ptr) == NULL ) || \ *------------------------------------------------------------------------- */ -#define H5C__SET_PB_READ_HINTS(cache_ptr, type, may_be_speculative) \ -{ \ - HDassert(cache_ptr); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((cache_ptr)->curr_io_type == NULL); \ - HDassert(type); \ - (cache_ptr)->curr_io_type = (type); \ - (cache_ptr)->curr_read_speculative = (may_be_speculative) && \ - ((cache_ptr)->curr_io_type->flags & H5AC__CLASS_SPECULATIVE_LOAD_FLAG); \ - \ -} /* H5C__SET_PB_READ_HINTS() */ - -#define H5C__RESET_PB_READ_HINTS(cache_ptr) \ -{ \ - HDassert(cache_ptr); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((cache_ptr)->curr_io_type); \ - (cache_ptr)->curr_io_type = NULL; \ - (cache_ptr)->curr_read_speculative = FALSE; \ - \ -} /* H5C__SET_PB_READ_HINTS() */ - +#define H5C__SET_PB_READ_HINTS(cache_ptr, type, may_be_speculative) \ + { \ + HDassert(cache_ptr); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((cache_ptr)->curr_io_type == NULL); \ + HDassert(type); \ + (cache_ptr)->curr_io_type = (type); \ + (cache_ptr)->curr_read_speculative = \ + (may_be_speculative) && ((cache_ptr)->curr_io_type->flags & H5AC__CLASS_SPECULATIVE_LOAD_FLAG); \ + \ + } /* H5C__SET_PB_READ_HINTS() */ + +#define H5C__RESET_PB_READ_HINTS(cache_ptr) \ + { \ + HDassert(cache_ptr); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((cache_ptr)->curr_io_type); \ + (cache_ptr)->curr_io_type = NULL; \ + (cache_ptr)->curr_read_speculative = FALSE; \ + \ + } /* H5C__SET_PB_READ_HINTS() */ /*------------------------------------------------------------------------- * * Macro: H5C__SET/RESET_PB_WRITE_HINTS * - * Purpose: Set or reset the fields needed to provide hints to the + * Purpose: Set or reset the fields needed to provide hints to the * page buffer so that it can detect un-expected writes of - * metadata entries that cross page boundaries and do not + * metadata entries that cross page boundaries and do not * start on page boundaries. * * See the discussion of the PB hint fields in the header @@ -3557,25 +3055,24 @@ if ( ( (entry_ptr) == NULL ) || \ *------------------------------------------------------------------------- */ -#define H5C__SET_PB_WRITE_HINTS(cache_ptr, type) \ -{ \ - HDassert(cache_ptr); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((cache_ptr)->curr_io_type == NULL); \ - HDassert(type); \ - (cache_ptr)->curr_io_type = (type); \ - \ -} /* H5C__SET_PB_WRITE_HINTS() */ - -#define H5C__RESET_PB_WRITE_HINTS(cache_ptr) \ -{ \ - HDassert(cache_ptr); \ - HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - HDassert((cache_ptr)->curr_io_type); \ - (cache_ptr)->curr_io_type = NULL; \ - \ -} /* H5C__SET_PB_WRITE_HINTS() */ - +#define H5C__SET_PB_WRITE_HINTS(cache_ptr, type) \ + { \ + HDassert(cache_ptr); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((cache_ptr)->curr_io_type == NULL); \ + HDassert(type); \ + (cache_ptr)->curr_io_type = (type); \ + \ + } /* H5C__SET_PB_WRITE_HINTS() */ + +#define H5C__RESET_PB_WRITE_HINTS(cache_ptr) \ + { \ + HDassert(cache_ptr); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((cache_ptr)->curr_io_type); \ + (cache_ptr)->curr_io_type = NULL; \ + \ + } /* H5C__SET_PB_WRITE_HINTS() */ /****************************/ /* Package Private Typedefs */ @@ -3608,13 +3105,12 @@ if ( ( (entry_ptr) == NULL ) || \ * ****************************************************************************/ typedef struct H5C_tag_info_t { - haddr_t tag; /* Tag (address) of the entries (must be first, for skiplist) */ - H5C_cache_entry_t *head; /* Head of the list of entries for this tag */ - size_t entry_cnt; /* Number of entries on list */ - hbool_t corked; /* Whether this object is corked */ + haddr_t tag; /* Tag (address) of the entries (must be first, for skiplist) */ + H5C_cache_entry_t *head; /* Head of the list of entries for this tag */ + size_t entry_cnt; /* Number of entries on list */ + hbool_t corked; /* Whether this object is corked */ } H5C_tag_info_t; - /**************************************************************************** * * structure H5C_t @@ -3854,32 +3350,32 @@ typedef struct H5C_tag_info_t { * * Page Index: * - * For the VFD SWMR reader, it is necessary to map modified pages to - * entries contained in that page so that they can be invalidated. The + * For the VFD SWMR reader, it is necessary to map modified pages to + * entries contained in that page so that they can be invalidated. The * page index is a hash table that provides this service. Note that it * is only maintained for files that are opened in VFD SWMR reader mode. * - * Structurally, the page index is identical to the index in the page - * buffer. Specifically, it is a hash table with chaining. The hash - * table size must be a power of two, not the usual prime number. The + * Structurally, the page index is identical to the index in the page + * buffer. Specifically, it is a hash table with chaining. The hash + * table size must be a power of two, not the usual prime number. The * hash function simply clips the high order bits off the page offset * of the entry's base address. * - * The page index is maintained by the same macros that maintain the - * regular index. As such, it does not require separate length and - * size fields, as it shares them with the regular index. Instead, + * The page index is maintained by the same macros that maintain the + * regular index. As such, it does not require separate length and + * size fields, as it shares them with the regular index. Instead, * the only ancilary field needed is the vfd_swrm_reader boolean, which * indicates whether the page index must be maintained. * - * vfd_swmr_reader: Boolean flag that is TRUE iff the file has been - * opened as a VFD SWMR reader. The remaining fields in + * vfd_swmr_reader: Boolean flag that is TRUE iff the file has been + * opened as a VFD SWMR reader. The remaining fields in * the page index section are valid iff this field is TRUE. * - * page_index Array of pointer to H5C_cache_entry_t of size - * H5C__PAGE_HASH_TABLE_LEN. This size must be a power of + * page_index Array of pointer to H5C_cache_entry_t of size + * H5C__PAGE_HASH_TABLE_LEN. This size must be a power of * two, not the usual prime number. * - * page_size: Convenience copy of the page size used by the page + * page_size: Convenience copy of the page size used by the page * buffer. * * @@ -4511,7 +4007,7 @@ typedef struct H5C_tag_info_t { * * Page Buffer Related Fields: * - * Due to the irregular behavior of some of the cache clients, the + * Due to the irregular behavior of some of the cache clients, the * page buffer occasionally need hints to manage metadta I/O requests * from the metadata cache -- particularly in the context of VFD SWMR. * The following fields exist to support this. @@ -4519,36 +4015,36 @@ typedef struct H5C_tag_info_t { * * curr_io_type: Pointer to the instance of H5C_class_t associated with * the current I/O operation. This pointer should be set - * just before any I/O operation by the metadata cache, and - * re-set to NULL immediately thereafter. + * just before any I/O operation by the metadata cache, and + * re-set to NULL immediately thereafter. * - * This field exists because the fixed and variable length + * This field exists because the fixed and variable length * array cache clients allocate numerous entries in a single * block, and sub-allocate metadata cache entries out of this * block. The effect of this is to break the invarient, * normally maintained by the free space managers in paged * allocation mode, that no entry of less than a page in - * size crosses page boundaries, and that entries of page - * size or greater are page aligned. This in turn causes + * size crosses page boundaries, and that entries of page + * size or greater are page aligned. This in turn causes * problems for the page buffer -- particularly in VFD SWMR * mode. * - * The correct solution is to modify the fixed and variable - * length array cache client to repair this. However, in - * the interrim, this field exists to detect similar + * The correct solution is to modify the fixed and variable + * length array cache client to repair this. However, in + * the interrim, this field exists to detect similar * behaviour elsewhere. * - * To complicate matters, speculative reads for metadata - * cache entries which must determine their lengths via - * inspection of the on disk image of the entry, may mimic + * To complicate matters, speculative reads for metadata + * cache entries which must determine their lengths via + * inspection of the on disk image of the entry, may mimic * the behaviour of the fixed and extensible arrays. Thus * the curr_io_type is also needed to dis-ambiguate reads. - * + * * curr_read_speculative: Boolean flag indicating whether the current * read request is guaranteed to be of the correct length. - * Field is used to distinguish between the initial and final + * Field is used to distinguish between the initial and final * read attempts - * + * * * * Statistics collection fields: @@ -4883,314 +4379,306 @@ typedef struct H5C_tag_info_t { * * curr_io_type: Pointer to the instance of H5C_class_t associated with * the current I/O operation. This pointer should be set - * just before any I/O operation by the metadata cache, and - * re-set to NULL immediately thereafter. This field is + * just before any I/O operation by the metadata cache, and + * re-set to NULL immediately thereafter. This field is * only defined when NDEBUG is not #defined. * - * This field exists because the fixed and variable length + * This field exists because the fixed and variable length * array cache clients allocate numerous entries in a single * block, and sub-allocate metadata cache entries out of this * block. The effect of this is to break the invarient, * normally maintained by the free space managers in paged * allocation mode, that no entry of less than a page in - * size crosses page boundaries, and that entries of page - * size or greater are page aligned. This in turn causes + * size crosses page boundaries, and that entries of page + * size or greater are page aligned. This in turn causes * problems for the page buffer -- particularly in VFD SWMR * mode. * - * The correct solution is to modify the fixed and variable - * length array cache client to repair this. However, in - * the interrim, this field exists to detect similar + * The correct solution is to modify the fixed and variable + * length array cache client to repair this. However, in + * the interrim, this field exists to detect similar * behaviour elsewhere. * ****************************************************************************/ struct H5C_t { - uint32_t magic; - hbool_t flush_in_progress; - H5C_log_info_t *log_info; - void * aux_ptr; - int32_t max_type_id; - const H5C_class_t * const *class_table_ptr; - size_t max_cache_size; - size_t min_clean_size; - H5C_write_permitted_func_t check_write_permitted; - hbool_t write_permitted; - H5C_log_flush_func_t log_flush; - hbool_t evictions_enabled; - hbool_t close_warning_received; + uint32_t magic; + hbool_t flush_in_progress; + H5C_log_info_t * log_info; + void * aux_ptr; + int32_t max_type_id; + const H5C_class_t *const * class_table_ptr; + size_t max_cache_size; + size_t min_clean_size; + H5C_write_permitted_func_t check_write_permitted; + hbool_t write_permitted; + H5C_log_flush_func_t log_flush; + hbool_t evictions_enabled; + hbool_t close_warning_received; /* Fields for maintaining [hash table] index of entries */ - uint32_t index_len; - size_t index_size; - uint32_t index_ring_len[H5C_RING_NTYPES]; - size_t index_ring_size[H5C_RING_NTYPES]; - size_t clean_index_size; - size_t clean_index_ring_size[H5C_RING_NTYPES]; - size_t dirty_index_size; - size_t dirty_index_ring_size[H5C_RING_NTYPES]; - H5C_cache_entry_t * index[H5C__HASH_TABLE_LEN]; - uint32_t il_len; - size_t il_size; - H5C_cache_entry_t * il_head; - H5C_cache_entry_t * il_tail; + uint32_t index_len; + size_t index_size; + uint32_t index_ring_len[H5C_RING_NTYPES]; + size_t index_ring_size[H5C_RING_NTYPES]; + size_t clean_index_size; + size_t clean_index_ring_size[H5C_RING_NTYPES]; + size_t dirty_index_size; + size_t dirty_index_ring_size[H5C_RING_NTYPES]; + H5C_cache_entry_t *index[H5C__HASH_TABLE_LEN]; + uint32_t il_len; + size_t il_size; + H5C_cache_entry_t *il_head; + H5C_cache_entry_t *il_tail; /* Fields supporting VFD SWMR */ - hbool_t vfd_swmr_reader; - H5C_cache_entry_t * page_index[H5C__PAGE_HASH_TABLE_LEN]; - hsize_t page_size; + hbool_t vfd_swmr_reader; + H5C_cache_entry_t *page_index[H5C__PAGE_HASH_TABLE_LEN]; + hsize_t page_size; /* Fields to detect entries removed during scans */ - int64_t entries_removed_counter; - H5C_cache_entry_t * last_entry_removed_ptr; - H5C_cache_entry_t * entry_watched_for_removal; + int64_t entries_removed_counter; + H5C_cache_entry_t *last_entry_removed_ptr; + H5C_cache_entry_t *entry_watched_for_removal; /* Fields for maintaining list of in-order entries, for flushing */ - hbool_t slist_changed; - uint32_t slist_len; - size_t slist_size; - uint32_t slist_ring_len[H5C_RING_NTYPES]; - size_t slist_ring_size[H5C_RING_NTYPES]; - H5SL_t * slist_ptr; - uint32_t num_last_entries; + hbool_t slist_changed; + uint32_t slist_len; + size_t slist_size; + uint32_t slist_ring_len[H5C_RING_NTYPES]; + size_t slist_ring_size[H5C_RING_NTYPES]; + H5SL_t * slist_ptr; + uint32_t num_last_entries; #if H5C_DO_SANITY_CHECKS - int32_t slist_len_increase; - int64_t slist_size_increase; + int32_t slist_len_increase; + int64_t slist_size_increase; #endif /* H5C_DO_SANITY_CHECKS */ /* Fields for maintaining list of tagged entries */ - H5SL_t * tag_list; - hbool_t ignore_tags; - uint32_t num_objs_corked; + H5SL_t * tag_list; + hbool_t ignore_tags; + uint32_t num_objs_corked; /* Fields for tracking protected entries */ - uint32_t pl_len; - size_t pl_size; - H5C_cache_entry_t * pl_head_ptr; - H5C_cache_entry_t * pl_tail_ptr; + uint32_t pl_len; + size_t pl_size; + H5C_cache_entry_t *pl_head_ptr; + H5C_cache_entry_t *pl_tail_ptr; /* Fields for tracking pinned entries */ - uint32_t pel_len; - size_t pel_size; - H5C_cache_entry_t * pel_head_ptr; - H5C_cache_entry_t * pel_tail_ptr; + uint32_t pel_len; + size_t pel_size; + H5C_cache_entry_t *pel_head_ptr; + H5C_cache_entry_t *pel_tail_ptr; /* Fields for complete LRU list of entries */ - uint32_t LRU_list_len; - size_t LRU_list_size; - H5C_cache_entry_t * LRU_head_ptr; - H5C_cache_entry_t * LRU_tail_ptr; + uint32_t LRU_list_len; + size_t LRU_list_size; + H5C_cache_entry_t *LRU_head_ptr; + H5C_cache_entry_t *LRU_tail_ptr; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS /* Fields for clean LRU list of entries */ - uint32_t cLRU_list_len; - size_t cLRU_list_size; - H5C_cache_entry_t * cLRU_head_ptr; - H5C_cache_entry_t * cLRU_tail_ptr; + uint32_t cLRU_list_len; + size_t cLRU_list_size; + H5C_cache_entry_t *cLRU_head_ptr; + H5C_cache_entry_t *cLRU_tail_ptr; /* Fields for dirty LRU list of entries */ - uint32_t dLRU_list_len; - size_t dLRU_list_size; - H5C_cache_entry_t * dLRU_head_ptr; - H5C_cache_entry_t * dLRU_tail_ptr; + uint32_t dLRU_list_len; + size_t dLRU_list_size; + H5C_cache_entry_t *dLRU_head_ptr; + H5C_cache_entry_t *dLRU_tail_ptr; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL /* Fields for collective metadata reads */ - uint32_t coll_list_len; - size_t coll_list_size; - H5C_cache_entry_t * coll_head_ptr; - H5C_cache_entry_t * coll_tail_ptr; + uint32_t coll_list_len; + size_t coll_list_size; + H5C_cache_entry_t *coll_head_ptr; + H5C_cache_entry_t *coll_tail_ptr; /* Fields for collective metadata writes */ - H5SL_t * coll_write_list; + H5SL_t *coll_write_list; #endif /* H5_HAVE_PARALLEL */ /* Fields for automatic cache size adjustment */ - hbool_t size_increase_possible; - hbool_t flash_size_increase_possible; - size_t flash_size_increase_threshold; - hbool_t size_decrease_possible; - hbool_t resize_enabled; - hbool_t cache_full; - hbool_t size_decreased; - hbool_t resize_in_progress; - hbool_t msic_in_progress; - H5C_auto_size_ctl_t resize_ctl; + hbool_t size_increase_possible; + hbool_t flash_size_increase_possible; + size_t flash_size_increase_threshold; + hbool_t size_decrease_possible; + hbool_t resize_enabled; + hbool_t cache_full; + hbool_t size_decreased; + hbool_t resize_in_progress; + hbool_t msic_in_progress; + H5C_auto_size_ctl_t resize_ctl; /* Fields for epoch markers used in automatic cache size adjustment */ - int32_t epoch_markers_active; - hbool_t epoch_marker_active[H5C__MAX_EPOCH_MARKERS]; - int32_t epoch_marker_ringbuf[H5C__MAX_EPOCH_MARKERS+1]; - int32_t epoch_marker_ringbuf_first; - int32_t epoch_marker_ringbuf_last; - int32_t epoch_marker_ringbuf_size; - H5C_cache_entry_t epoch_markers[H5C__MAX_EPOCH_MARKERS]; + int32_t epoch_markers_active; + hbool_t epoch_marker_active[H5C__MAX_EPOCH_MARKERS]; + int32_t epoch_marker_ringbuf[H5C__MAX_EPOCH_MARKERS + 1]; + int32_t epoch_marker_ringbuf_first; + int32_t epoch_marker_ringbuf_last; + int32_t epoch_marker_ringbuf_size; + H5C_cache_entry_t epoch_markers[H5C__MAX_EPOCH_MARKERS]; /* Fields for cache hit rate collection */ - int64_t cache_hits; - int64_t cache_accesses; + int64_t cache_hits; + int64_t cache_accesses; /* fields supporting generation of a cache image on file close */ - H5C_cache_image_ctl_t image_ctl; - hbool_t serialization_in_progress; - hbool_t load_image; - hbool_t image_loaded; - hbool_t delete_image; - haddr_t image_addr; - hsize_t image_len; - hsize_t image_data_len; - int64_t entries_loaded_counter; - int64_t entries_inserted_counter; - int64_t entries_relocated_counter; - int64_t entry_fd_height_change_counter; - uint32_t num_entries_in_image; - H5C_image_entry_t * image_entries; - void * image_buffer; + H5C_cache_image_ctl_t image_ctl; + hbool_t serialization_in_progress; + hbool_t load_image; + hbool_t image_loaded; + hbool_t delete_image; + haddr_t image_addr; + hsize_t image_len; + hsize_t image_data_len; + int64_t entries_loaded_counter; + int64_t entries_inserted_counter; + int64_t entries_relocated_counter; + int64_t entry_fd_height_change_counter; + uint32_t num_entries_in_image; + H5C_image_entry_t * image_entries; + void * image_buffer; /* Free Space Manager Related fields */ - hbool_t rdfsm_settled; - hbool_t mdfsm_settled; + hbool_t rdfsm_settled; + hbool_t mdfsm_settled; /* Fields supporting page buffer hints */ - const H5C_class_t * curr_io_type; - hbool_t curr_read_speculative; + const H5C_class_t *curr_io_type; + hbool_t curr_read_speculative; #if H5C_COLLECT_CACHE_STATS /* stats fields */ - int64_t hits[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t misses[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t write_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t insertions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_insertions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t evictions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t take_ownerships[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t entry_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t cache_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t unpins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t dirty_pins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t size_increases[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t size_decreases[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t entry_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t cache_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t hits[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t misses[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t write_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t insertions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_insertions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t evictions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t take_ownerships[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t entry_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t cache_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t unpins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t dirty_pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t size_increases[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t size_decreases[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t entry_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t cache_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; /* Fields for hash table operations */ - int64_t total_ht_insertions; - int64_t total_ht_deletions; - int64_t successful_ht_searches; - int64_t total_successful_ht_search_depth; - int64_t failed_ht_searches; - int64_t total_failed_ht_search_depth; - uint32_t max_index_len; - size_t max_index_size; - size_t max_clean_index_size; - size_t max_dirty_index_size; + int64_t total_ht_insertions; + int64_t total_ht_deletions; + int64_t successful_ht_searches; + int64_t total_successful_ht_search_depth; + int64_t failed_ht_searches; + int64_t total_failed_ht_search_depth; + uint32_t max_index_len; + size_t max_index_size; + size_t max_clean_index_size; + size_t max_dirty_index_size; /* Fields for in-order skip list */ - uint32_t max_slist_len; - size_t max_slist_size; + uint32_t max_slist_len; + size_t max_slist_size; /* Fields for protected entry list */ - uint32_t max_pl_len; - size_t max_pl_size; + uint32_t max_pl_len; + size_t max_pl_size; /* Fields for pinned entry list */ - uint32_t max_pel_len; - size_t max_pel_size; + uint32_t max_pel_len; + size_t max_pel_size; /* Fields for tracking 'make space in cache' (msic) operations */ - int64_t calls_to_msic; - int64_t total_entries_skipped_in_msic; - int64_t total_dirty_pf_entries_skipped_in_msic; - int64_t total_entries_scanned_in_msic; - int32_t max_entries_skipped_in_msic; - int32_t max_dirty_pf_entries_skipped_in_msic; - int32_t max_entries_scanned_in_msic; - int64_t entries_scanned_to_make_space; + int64_t calls_to_msic; + int64_t total_entries_skipped_in_msic; + int64_t total_dirty_pf_entries_skipped_in_msic; + int64_t total_entries_scanned_in_msic; + int32_t max_entries_skipped_in_msic; + int32_t max_dirty_pf_entries_skipped_in_msic; + int32_t max_entries_scanned_in_msic; + int64_t entries_scanned_to_make_space; /* Fields for tracking skip list scan restarts */ - int64_t slist_scan_restarts; - int64_t LRU_scan_restarts; - int64_t index_scan_restarts; + int64_t slist_scan_restarts; + int64_t LRU_scan_restarts; + int64_t index_scan_restarts; /* Fields for tracking cache image operations */ - int32_t images_created; - int32_t images_read; - int32_t images_loaded; - hsize_t last_image_size; + int32_t images_created; + int32_t images_read; + int32_t images_loaded; + hsize_t last_image_size; /* Fields for tracking prefetched entries */ - int64_t prefetches; - int64_t dirty_prefetches; - int64_t prefetch_hits; + int64_t prefetches; + int64_t dirty_prefetches; + int64_t prefetch_hits; #if H5C_COLLECT_CACHE_ENTRY_STATS - int32_t max_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t min_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - size_t max_size[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t min_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + size_t max_size[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_pins[H5C__MAX_NUM_TYPE_IDS + 1]; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #endif /* H5C_COLLECT_CACHE_STATS */ - char prefix[H5C__PREFIX_LEN]; + char prefix[H5C__PREFIX_LEN]; #ifndef NDEBUG - int64_t get_entry_ptr_from_addr_counter; + int64_t get_entry_ptr_from_addr_counter; #endif /* NDEBUG */ }; /* Define typedef for tagged cache entry iteration callbacks */ typedef int (*H5C_tag_iter_cb_t)(H5C_cache_entry_t *entry, void *ctx); - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ H5_DLL herr_t H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated); -H5_DLL herr_t H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t * cache_ptr, - H5C_cache_entry_t** entry_ptr_ptr, const H5C_class_t * type, haddr_t addr, - void * udata); +H5_DLL herr_t H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t **entry_ptr_ptr, + const H5C_class_t *type, haddr_t addr, void *udata); /* General routines */ -H5_DLL herr_t H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, - unsigned flags); +H5_DLL herr_t H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags); H5_DLL herr_t H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr); H5_DLL herr_t H5C__load_cache_image(H5F_t *f); -H5_DLL herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr); -H5_DLL herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr); -H5_DLL herr_t H5C__make_space_in_cache(H5F_t * f, size_t space_needed, - hbool_t write_permitted); -H5_DLL herr_t H5C__flush_marked_entries(H5F_t * f); -H5_DLL herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr); +H5_DLL herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t *entry_ptr); +H5_DLL herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t *entry_ptr); +H5_DLL herr_t H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted); +H5_DLL herr_t H5C__flush_marked_entries(H5F_t *f); +H5_DLL herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); H5_DLL herr_t H5C__serialize_cache(H5F_t *f); -H5_DLL herr_t H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, - H5C_tag_iter_cb_t cb, void *cb_ctx); +H5_DLL herr_t H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, H5C_tag_iter_cb_t cb, + void *cb_ctx); /* Routines for operating on entry tags */ -H5_DLL herr_t H5C__tag_entry(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr); +H5_DLL herr_t H5C__tag_entry(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); H5_DLL herr_t H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry); /* Testing functions */ #ifdef H5C_TESTING H5_DLL herr_t H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status); -H5_DLL void H5C_set_curr_io_type_splitable(H5C_t * cache_ptr, - hbool_t set_splitable); +H5_DLL void H5C_set_curr_io_type_splitable(H5C_t *cache_ptr, hbool_t set_splitable); #endif /* H5C_TESTING */ #endif /* _H5Cpkg_H */ - diff --git a/src/H5Cprefetched.c b/src/H5Cprefetched.c index 0c32fd5..7cd1be3 100644 --- a/src/H5Cprefetched.c +++ b/src/H5Cprefetched.c @@ -22,26 +22,22 @@ *------------------------------------------------------------------------- */ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -51,27 +47,20 @@ * Declarations for prefetched cache entry callbacks. * ****************************************************************************/ -static herr_t H5C__prefetched_entry_get_initial_load_size(void *udata_ptr, - size_t *image_len_ptr); -static herr_t H5C__prefetched_entry_get_final_load_size(const void *image_ptr, - size_t image_len, void *udata_ptr, size_t *actual_len_ptr); -static htri_t H5C__prefetched_entry_verify_chksum(const void *image_ptr, - size_t len, void *udata_ptr); -static void * H5C__prefetched_entry_deserialize(const void *image_ptr, - size_t len, void *udata, hbool_t *dirty_ptr); -static herr_t H5C__prefetched_entry_image_len(const void *thing, - size_t *image_len_ptr); -static herr_t H5C__prefetched_entry_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, size_t *new_len_ptr, - unsigned *flags_ptr); -static herr_t H5C__prefetched_entry_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t H5C__prefetched_entry_notify(H5C_notify_action_t action, - void *thing); +static herr_t H5C__prefetched_entry_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr); +static herr_t H5C__prefetched_entry_get_final_load_size(const void *image_ptr, size_t image_len, + void *udata_ptr, size_t *actual_len_ptr); +static htri_t H5C__prefetched_entry_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); +static void * H5C__prefetched_entry_deserialize(const void *image_ptr, size_t len, void *udata, + hbool_t *dirty_ptr); +static herr_t H5C__prefetched_entry_image_len(const void *thing, size_t *image_len_ptr); +static herr_t H5C__prefetched_entry_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr_ptr, size_t *new_len_ptr, + unsigned *flags_ptr); +static herr_t H5C__prefetched_entry_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t H5C__prefetched_entry_notify(H5C_notify_action_t action, void *thing); static herr_t H5C__prefetched_entry_free_icr(void *thing); -static herr_t H5C__prefetched_entry_fsf_size(const void *thing, - hsize_t *fsf_size_ptr); - +static herr_t H5C__prefetched_entry_fsf_size(const void *thing, hsize_t *fsf_size_ptr); /*********************/ /* Package Variables */ @@ -80,17 +69,14 @@ static herr_t H5C__prefetched_entry_fsf_size(const void *thing, /* Declare external the free list for H5C_cache_entry_t's */ H5FL_EXTERN(H5C_cache_entry_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - const H5AC_class_t H5AC_PREFETCHED_ENTRY[1] = {{ /* id = */ H5AC_PREFETCHED_ENTRY_ID, /* name = */ "prefetched entry", @@ -109,8 +95,6 @@ const H5AC_class_t H5AC_PREFETCHED_ENTRY[1] = {{ /* refresh = */ NULL, }}; - - /*************************************************************************** * With two exceptions, these functions should never be called, and thus * there is little point in documenting them separately as they all simply @@ -124,91 +108,83 @@ const H5AC_class_t H5AC_PREFETCHED_ENTRY[1] = {{ static herr_t H5C__prefetched_entry_get_initial_load_size(void H5_ATTR_UNUSED *udata_ptr, - size_t H5_ATTR_UNUSED *image_len_ptr) + size_t H5_ATTR_UNUSED *image_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_get_initial_load_size() */ static herr_t H5C__prefetched_entry_get_final_load_size(const void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED image_len, void H5_ATTR_UNUSED *udata_ptr, - size_t H5_ATTR_UNUSED *actual_len_ptr) + size_t H5_ATTR_UNUSED image_len, void H5_ATTR_UNUSED *udata_ptr, + size_t H5_ATTR_UNUSED *actual_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_get_final_load_size() */ static htri_t -H5C__prefetched_entry_verify_chksum(const void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *udata_ptr) +H5C__prefetched_entry_verify_chksum(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED len, + void H5_ATTR_UNUSED *udata_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_verify_chksum() */ - static void * -H5C__prefetched_entry_deserialize(const void H5_ATTR_UNUSED * image_ptr, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED * udata, - hbool_t H5_ATTR_UNUSED * dirty_ptr) +H5C__prefetched_entry_deserialize(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED len, + void H5_ATTR_UNUSED *udata, hbool_t H5_ATTR_UNUSED *dirty_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(NULL) } /* end H5C__prefetched_entry_deserialize() */ - static herr_t -H5C__prefetched_entry_image_len(const void H5_ATTR_UNUSED *thing, - size_t H5_ATTR_UNUSED *image_len_ptr) +H5C__prefetched_entry_image_len(const void H5_ATTR_UNUSED *thing, size_t H5_ATTR_UNUSED *image_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_image_len() */ - static herr_t H5C__prefetched_entry_pre_serialize(H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *thing, - haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len, - haddr_t H5_ATTR_UNUSED *new_addr_ptr, size_t H5_ATTR_UNUSED *new_len_ptr, - unsigned H5_ATTR_UNUSED *flags_ptr) + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len, + haddr_t H5_ATTR_UNUSED *new_addr_ptr, size_t H5_ATTR_UNUSED *new_len_ptr, + unsigned H5_ATTR_UNUSED *flags_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_pre_serialize() */ - static herr_t -H5C__prefetched_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, - void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) +H5C__prefetched_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *image_ptr, + size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_serialize() */ - /*------------------------------------------------------------------------- * Function: H5C__prefetched_entry_notify * @@ -229,9 +205,9 @@ H5C__prefetched_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, static herr_t H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) { - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)_thing; - unsigned u; - herr_t ret_value = SUCCEED; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; + unsigned u; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -240,7 +216,7 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->prefetched); - switch(action) { + switch (action) { case H5C_NOTIFY_ACTION_AFTER_INSERT: case H5C_NOTIFY_ACTION_AFTER_LOAD: case H5C_NOTIFY_ACTION_AFTER_FLUSH: @@ -254,8 +230,8 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) break; case H5C_NOTIFY_ACTION_BEFORE_EVICT: - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) { - H5C_cache_entry_t * parent_ptr; + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + H5C_cache_entry_t *parent_ptr; /* Sanity checks */ HDassert(entry_ptr->flush_dep_parent); @@ -265,10 +241,11 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) HDassert(parent_ptr->flush_dep_nchildren > 0); /* Destroy flush dependency with flush dependency parent */ - if(H5C_destroy_flush_dependency(parent_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "unable to destroy prefetched entry flush dependency") + if (H5C_destroy_flush_dependency(parent_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy prefetched entry flush dependency") - if(parent_ptr->prefetched) { + if (parent_ptr->prefetched) { /* In prefetched entries, the fd_child_count field is * used in sanity checks elsewhere. Thus update this * field to reflect the destruction of the flush @@ -277,7 +254,7 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) HDassert(parent_ptr->fd_child_count > 0); (parent_ptr->fd_child_count)--; } /* end if */ - } /* end for */ + } /* end for */ break; default: @@ -289,7 +266,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5C__prefetched_entry_notify() */ - /*------------------------------------------------------------------------- * Function: H5C__prefetched_entry_free_icr * @@ -309,7 +285,7 @@ static herr_t H5C__prefetched_entry_free_icr(void *_thing) { H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -319,15 +295,15 @@ H5C__prefetched_entry_free_icr(void *_thing) HDassert(entry_ptr->prefetched); /* Release array for flush dependency parent addresses */ - if(entry_ptr->fd_parent_addrs != NULL) { - HDassert(entry_ptr->fd_parent_count > 0); - entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree((void *)entry_ptr->fd_parent_addrs); + if (entry_ptr->fd_parent_addrs != NULL) { + HDassert(entry_ptr->fd_parent_count > 0); + entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree((void *)entry_ptr->fd_parent_addrs); } /* end if */ else - HDassert(entry_ptr->fd_parent_count == 0); + HDassert(entry_ptr->fd_parent_count == 0); - if(entry_ptr->image_ptr != NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "prefetched entry image buffer still attatched?") + if (entry_ptr->image_ptr != NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "prefetched entry image buffer still attatched?") entry_ptr = H5FL_FREE(H5C_cache_entry_t, entry_ptr); @@ -335,15 +311,12 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5C__prefetched_entry_free_icr() */ - static herr_t -H5C__prefetched_entry_fsf_size(const void H5_ATTR_UNUSED *thing, - hsize_t H5_ATTR_UNUSED *fsf_size_ptr) +H5C__prefetched_entry_fsf_size(const void H5_ATTR_UNUSED *thing, hsize_t H5_ATTR_UNUSED *fsf_size_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_fsf_size() */ - diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 7678911..8b14f9e 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -28,19 +28,19 @@ #ifndef _H5Cprivate_H #define _H5Cprivate_H -#include "H5Cpublic.h" /* public prototypes */ +#include "H5Cpublic.h" /* public prototypes */ /* Private headers needed by this header */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File access */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ /* Cache configuration settings */ -#define H5C__MAX_NUM_TYPE_IDS 30 -#define H5C__PREFIX_LEN 32 +#define H5C__MAX_NUM_TYPE_IDS 30 +#define H5C__PREFIX_LEN 32 /* This sanity checking constant was picked out of the air. Increase * or decrease it if appropriate. Its purposes is to detect corrupt @@ -48,32 +48,32 @@ * * JRM - 5/17/04 */ -#define H5C_MAX_ENTRY_SIZE ((size_t)(32 * 1024 * 1024)) +#define H5C_MAX_ENTRY_SIZE ((size_t)(32 * 1024 * 1024)) #ifdef H5_HAVE_PARALLEL /* we must maintain the clean and dirty LRU lists when we are compiled * with parallel support. */ -#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 1 +#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 1 #else /* H5_HAVE_PARALLEL */ /* The clean and dirty LRU lists don't buy us anything here -- we may * want them on for testing on occasion, but in general they should be * off. */ -#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 0 +#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 0 #endif /* H5_HAVE_PARALLEL */ /* Flags for cache client class behavior */ -#define H5C__CLASS_NO_FLAGS_SET ((unsigned)0x0) -#define H5C__CLASS_SPECULATIVE_LOAD_FLAG ((unsigned)0x1) +#define H5C__CLASS_NO_FLAGS_SET ((unsigned)0x0) +#define H5C__CLASS_SPECULATIVE_LOAD_FLAG ((unsigned)0x1) /* The following flags may only appear in test code */ -#define H5C__CLASS_SKIP_READS ((unsigned)0x2) -#define H5C__CLASS_SKIP_WRITES ((unsigned)0x4) +#define H5C__CLASS_SKIP_READS ((unsigned)0x2) +#define H5C__CLASS_SKIP_WRITES ((unsigned)0x4) /* Flags for pre-serialize callback */ -#define H5C__SERIALIZE_NO_FLAGS_SET ((unsigned)0) -#define H5C__SERIALIZE_RESIZED_FLAG ((unsigned)0x1) -#define H5C__SERIALIZE_MOVED_FLAG ((unsigned)0x2) +#define H5C__SERIALIZE_NO_FLAGS_SET ((unsigned)0) +#define H5C__SERIALIZE_RESIZED_FLAG ((unsigned)0x1) +#define H5C__SERIALIZE_MOVED_FLAG ((unsigned)0x2) /* Upper and lower limits on cache size. These limits are picked * out of a hat -- you should be able to change them as necessary. @@ -83,55 +83,51 @@ * upper bound on cache size is rather large for the current hash table * size. */ -#define H5C__MAX_MAX_CACHE_SIZE ((size_t)(128 * 1024 * 1024)) -#define H5C__MIN_MAX_CACHE_SIZE ((size_t)(1024)) +#define H5C__MAX_MAX_CACHE_SIZE ((size_t)(128 * 1024 * 1024)) +#define H5C__MIN_MAX_CACHE_SIZE ((size_t)(1024)) /* Default max cache size and min clean size are give here to make * them generally accessible. */ -#define H5C__DEFAULT_MAX_CACHE_SIZE ((size_t)(4 * 1024 * 1024)) -#define H5C__DEFAULT_MIN_CLEAN_SIZE ((size_t)(2 * 1024 * 1024)) +#define H5C__DEFAULT_MAX_CACHE_SIZE ((size_t)(4 * 1024 * 1024)) +#define H5C__DEFAULT_MIN_CLEAN_SIZE ((size_t)(2 * 1024 * 1024)) /* Values for cache entry magic field */ -#define H5C__H5C_CACHE_ENTRY_T_MAGIC 0x005CAC0A -#define H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC 0xDeadBeef +#define H5C__H5C_CACHE_ENTRY_T_MAGIC 0x005CAC0A +#define H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC 0xDeadBeef /* Cache configuration validation definitions */ -#define H5C_RESIZE_CFG__VALIDATE_GENERAL 0x1 -#define H5C_RESIZE_CFG__VALIDATE_INCREMENT 0x2 -#define H5C_RESIZE_CFG__VALIDATE_DECREMENT 0x4 -#define H5C_RESIZE_CFG__VALIDATE_INTERACTIONS 0x8 -#define H5C_RESIZE_CFG__VALIDATE_ALL \ -( \ - H5C_RESIZE_CFG__VALIDATE_GENERAL | \ - H5C_RESIZE_CFG__VALIDATE_INCREMENT | \ - H5C_RESIZE_CFG__VALIDATE_DECREMENT | \ - H5C_RESIZE_CFG__VALIDATE_INTERACTIONS \ -) +#define H5C_RESIZE_CFG__VALIDATE_GENERAL 0x1 +#define H5C_RESIZE_CFG__VALIDATE_INCREMENT 0x2 +#define H5C_RESIZE_CFG__VALIDATE_DECREMENT 0x4 +#define H5C_RESIZE_CFG__VALIDATE_INTERACTIONS 0x8 +#define H5C_RESIZE_CFG__VALIDATE_ALL \ + (H5C_RESIZE_CFG__VALIDATE_GENERAL | H5C_RESIZE_CFG__VALIDATE_INCREMENT | \ + H5C_RESIZE_CFG__VALIDATE_DECREMENT | H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) /* Cache configuration versions */ -#define H5C__CURR_AUTO_SIZE_CTL_VER 1 -#define H5C__CURR_AUTO_RESIZE_RPT_FCN_VER 1 -#define H5C__CURR_CACHE_IMAGE_CTL_VER 1 +#define H5C__CURR_AUTO_SIZE_CTL_VER 1 +#define H5C__CURR_AUTO_RESIZE_RPT_FCN_VER 1 +#define H5C__CURR_CACHE_IMAGE_CTL_VER 1 /* Default configuration settings */ -#define H5C__DEF_AR_UPPER_THRESHHOLD 0.9999f -#define H5C__DEF_AR_LOWER_THRESHHOLD 0.9f -#define H5C__DEF_AR_MAX_SIZE ((size_t)(16 * 1024 * 1024)) -#define H5C__DEF_AR_INIT_SIZE ((size_t)( 1 * 1024 * 1024)) -#define H5C__DEF_AR_MIN_SIZE ((size_t)( 1 * 1024 * 1024)) -#define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5f -#define H5C__DEF_AR_INCREMENT 2.0f -#define H5C__DEF_AR_MAX_INCREMENT ((size_t)( 2 * 1024 * 1024)) -#define H5C__DEF_AR_FLASH_MULTIPLE 1.0f -#define H5C__DEV_AR_FLASH_THRESHOLD 0.25f -#define H5C__DEF_AR_DECREMENT 0.9f -#define H5C__DEF_AR_MAX_DECREMENT ((size_t)( 1 * 1024 * 1024)) -#define H5C__DEF_AR_EPCHS_B4_EVICT 3 -#define H5C__DEF_AR_EMPTY_RESERVE 0.05f -#define H5C__MIN_AR_EPOCH_LENGTH 100 -#define H5C__DEF_AR_EPOCH_LENGTH 50000 -#define H5C__MAX_AR_EPOCH_LENGTH 1000000 +#define H5C__DEF_AR_UPPER_THRESHHOLD 0.9999f +#define H5C__DEF_AR_LOWER_THRESHHOLD 0.9f +#define H5C__DEF_AR_MAX_SIZE ((size_t)(16 * 1024 * 1024)) +#define H5C__DEF_AR_INIT_SIZE ((size_t)(1 * 1024 * 1024)) +#define H5C__DEF_AR_MIN_SIZE ((size_t)(1 * 1024 * 1024)) +#define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5f +#define H5C__DEF_AR_INCREMENT 2.0f +#define H5C__DEF_AR_MAX_INCREMENT ((size_t)(2 * 1024 * 1024)) +#define H5C__DEF_AR_FLASH_MULTIPLE 1.0f +#define H5C__DEV_AR_FLASH_THRESHOLD 0.25f +#define H5C__DEF_AR_DECREMENT 0.9f +#define H5C__DEF_AR_MAX_DECREMENT ((size_t)(1 * 1024 * 1024)) +#define H5C__DEF_AR_EPCHS_B4_EVICT 3 +#define H5C__DEF_AR_EMPTY_RESERVE 0.05f +#define H5C__MIN_AR_EPOCH_LENGTH 100 +#define H5C__DEF_AR_EPOCH_LENGTH 50000 +#define H5C__MAX_AR_EPOCH_LENGTH 1000000 /* #defines of flags used in the flags parameters in some of the * following function calls. Note that not all flags are applicable @@ -185,47 +181,47 @@ * H5C__GENERATE_IMAGE_FLAG * H5C__UPDATE_PAGE_BUFFER_FLAG */ -#define H5C__NO_FLAGS_SET 0x00000 -#define H5C__SET_FLUSH_MARKER_FLAG 0x00001 -#define H5C__DELETED_FLAG 0x00002 -#define H5C__DIRTIED_FLAG 0x00004 -#define H5C__PIN_ENTRY_FLAG 0x00008 -#define H5C__UNPIN_ENTRY_FLAG 0x00010 -#define H5C__FLUSH_INVALIDATE_FLAG 0x00020 -#define H5C__FLUSH_CLEAR_ONLY_FLAG 0x00040 -#define H5C__FLUSH_MARKED_ENTRIES_FLAG 0x00080 -#define H5C__FLUSH_IGNORE_PROTECTED_FLAG 0x00100 -#define H5C__READ_ONLY_FLAG 0x00200 -#define H5C__FREE_FILE_SPACE_FLAG 0x00400 -#define H5C__TAKE_OWNERSHIP_FLAG 0x00800 -#define H5C__FLUSH_LAST_FLAG 0x01000 -#define H5C__FLUSH_COLLECTIVELY_FLAG 0x02000 -#define H5C__EVICT_ALLOW_LAST_PINS_FLAG 0x04000 -#define H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG 0x08000 -#define H5C__DURING_FLUSH_FLAG 0x10000 /* Set when the entire cache is being flushed */ -#define H5C__GENERATE_IMAGE_FLAG 0x20000 /* Set during parallel I/O */ -#define H5C__UPDATE_PAGE_BUFFER_FLAG 0x40000 /* Set during parallel I/O */ +#define H5C__NO_FLAGS_SET 0x00000 +#define H5C__SET_FLUSH_MARKER_FLAG 0x00001 +#define H5C__DELETED_FLAG 0x00002 +#define H5C__DIRTIED_FLAG 0x00004 +#define H5C__PIN_ENTRY_FLAG 0x00008 +#define H5C__UNPIN_ENTRY_FLAG 0x00010 +#define H5C__FLUSH_INVALIDATE_FLAG 0x00020 +#define H5C__FLUSH_CLEAR_ONLY_FLAG 0x00040 +#define H5C__FLUSH_MARKED_ENTRIES_FLAG 0x00080 +#define H5C__FLUSH_IGNORE_PROTECTED_FLAG 0x00100 +#define H5C__READ_ONLY_FLAG 0x00200 +#define H5C__FREE_FILE_SPACE_FLAG 0x00400 +#define H5C__TAKE_OWNERSHIP_FLAG 0x00800 +#define H5C__FLUSH_LAST_FLAG 0x01000 +#define H5C__FLUSH_COLLECTIVELY_FLAG 0x02000 +#define H5C__EVICT_ALLOW_LAST_PINS_FLAG 0x04000 +#define H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG 0x08000 +#define H5C__DURING_FLUSH_FLAG 0x10000 /* Set when the entire cache is being flushed */ +#define H5C__GENERATE_IMAGE_FLAG 0x20000 /* Set during parallel I/O */ +#define H5C__UPDATE_PAGE_BUFFER_FLAG 0x40000 /* Set during parallel I/O */ /* Debugging/sanity checking/statistics settings */ #ifndef NDEBUG -#define H5C_DO_SANITY_CHECKS 1 -#define H5C_DO_SLIST_SANITY_CHECKS 0 -#define H5C_DO_TAGGING_SANITY_CHECKS 1 -#define H5C_DO_EXTREME_SANITY_CHECKS 0 +#define H5C_DO_SANITY_CHECKS 1 +#define H5C_DO_SLIST_SANITY_CHECKS 0 +#define H5C_DO_TAGGING_SANITY_CHECKS 1 +#define H5C_DO_EXTREME_SANITY_CHECKS 0 #else /* NDEBUG */ /* With rare execptions, the following defines should be set * to 0 if NDEBUG is defined */ -#define H5C_DO_SANITY_CHECKS 0 -#define H5C_DO_SLIST_SANITY_CHECKS 0 -#define H5C_DO_TAGGING_SANITY_CHECKS 0 -#define H5C_DO_EXTREME_SANITY_CHECKS 0 +#define H5C_DO_SANITY_CHECKS 0 +#define H5C_DO_SLIST_SANITY_CHECKS 0 +#define H5C_DO_TAGGING_SANITY_CHECKS 0 +#define H5C_DO_EXTREME_SANITY_CHECKS 0 #endif /* NDEBUG */ /* Cork actions: cork/uncork/get cork status of an object */ -#define H5C__SET_CORK 0x1 -#define H5C__UNCORK 0x2 -#define H5C__GET_CORKED 0x4 +#define H5C__SET_CORK 0x1 +#define H5C__UNCORK 0x2 +#define H5C__GET_CORKED 0x4 /* Note: The memory sanity checks aren't going to work until I/O filters are * changed to call a particular alloc/free routine for their buffers, @@ -235,7 +231,7 @@ * routines that the fractal heap direct block (and global heap) serialize * calls can use when resizing (and re-allocating) their image in the * cache. -QAK */ -#define H5C_DO_MEMORY_SANITY_CHECKS 0 +#define H5C_DO_MEMORY_SANITY_CHECKS 0 /* H5C_COLLECT_CACHE_STATS controls overall collection of statistics * on cache activity. In general, this #define should be set to 1 in @@ -243,9 +239,9 @@ */ #ifndef NDEBUG -#define H5C_COLLECT_CACHE_STATS 1 +#define H5C_COLLECT_CACHE_STATS 1 #else /* NDEBUG */ -#define H5C_COLLECT_CACHE_STATS 0 +#define H5C_COLLECT_CACHE_STATS 0 #endif /* NDEBUG */ /* H5C_COLLECT_CACHE_ENTRY_STATS controls collection of statistics @@ -255,12 +251,11 @@ * H5C_COLLECT_CACHE_STATS is also defined to true. */ #if H5C_COLLECT_CACHE_STATS -#define H5C_COLLECT_CACHE_ENTRY_STATS 1 +#define H5C_COLLECT_CACHE_ENTRY_STATS 1 #else -#define H5C_COLLECT_CACHE_ENTRY_STATS 0 +#define H5C_COLLECT_CACHE_ENTRY_STATS 0 #endif /* H5C_COLLECT_CACHE_STATS */ - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -384,7 +379,7 @@ typedef struct H5C_t H5C_t; * * The typedef for the get_load_size callback is as follows: * - * typedef + * typedef * herr_t (*H5C_get_final_load_size_func_t)(const void *image_ptr, * size_t image_len, * void *udata_ptr, @@ -405,7 +400,7 @@ typedef struct H5C_t H5C_t; * actual_len_ptr: Pointer to the location containing the actual length * of the metadata entry on disk. * - * Processing in the get_final_load_size function should proceed as + * Processing in the get_final_load_size function should proceed as * follows: * * If successful, the function will place the length in the *actual_len_ptr @@ -847,13 +842,13 @@ typedef struct H5C_t H5C_t; * * REFRESH_ENTRY: Pointer to the refresh entry callback. * - * This callback exists to support VFD SWMR readers, and should not + * This callback exists to support VFD SWMR readers, and should not * be used outside this context. * * At the end of each tick, the VFD SWMR reader is informed of pages * in the page buffer that have been modified since the last tick. * - * To avoid message from the past bugs, it is necessary to either + * To avoid message from the past bugs, it is necessary to either * evict or refresh entries that have been modified in the past tick, * and thus reside in such modified pages. * @@ -862,33 +857,33 @@ typedef struct H5C_t H5C_t; * pages, or determine that the entry in question has not been modified, * and thus that no action is required. * - * If the entry is unpinned, it is possible to simply evict it, and + * If the entry is unpinned, it is possible to simply evict it, and * this is probably the most efficient way to address the issue. * - * If the entry is pinned and tagged, it is possible to evict the + * If the entry is pinned and tagged, it is possible to evict the * entire on disk data structure of which it is part via the evict * tagged entry facility. This is inefficient, but it is simple and - * uses existing code -- hence this is plan A for the initial + * uses existing code -- hence this is plan A for the initial * implementation of VFD SWMR. * - * However, there remains the case of the pinned entry that is not + * However, there remains the case of the pinned entry that is not * tagged, and thus not subject to eviction via the evict tagged * entries call -- the most important example of this is the super * block which is pinned and may not be evicted until file close. * * Another example is free space manager headers -- however, these * are a non-issue in the context of VFD SWMR readers as such files - * must only be opened R/O and thus will not have active free space + * must only be opened R/O and thus will not have active free space * managers. * - * The refresh entry callback exists to address this issue. As + * The refresh entry callback exists to address this issue. As * indicated above, it is essential for the superblock, and desireable - * whenever it is not possible to simply evict an entry that resides + * whenever it is not possible to simply evict an entry that resides * in a modified page cache page. * - * Functionally, the call is similar to the deserialize call, the - * primary difference being that the client receives both a pointer - * to the existing entry, and a buffer containing its image. The + * Functionally, the call is similar to the deserialize call, the + * primary difference being that the client receives both a pointer + * to the existing entry, and a buffer containing its image. The * client must deserialize this image an update itself as appropriate. * * The typedef for the VFD SWMR refresh callback is as follows: @@ -902,124 +897,117 @@ typedef struct H5C_t H5C_t; * * f: Pointer to the containing instance of H5F_t. * - * entry_ptr: Pointer to the metadata cache entry that is being - * refreshed. This entry is place on the protected list - * for the duration of the refresh callback as the client + * entry_ptr: Pointer to the metadata cache entry that is being + * refreshed. This entry is place on the protected list + * for the duration of the refresh callback as the client * will typically modify it during the refresh operation. * * image_ptr: Pointer to a buffer of length *len_ptr containing the - * most recent version of the entry's on disk image from - * the VFD SWMR metadata file. The length of the buffer + * most recent version of the entry's on disk image from + * the VFD SWMR metadata file. The length of the buffer * is specified in the len parameter below. * - * len_ptr: Pointer to size_t containing the length in - * bytes of the buffer pointed to by *image_ptr. + * len_ptr: Pointer to size_t containing the length in + * bytes of the buffer pointed to by *image_ptr. * - * If the supplied buffer is too small, the callback must + * If the supplied buffer is too small, the callback must * place the correct value in *len_ptr and return success. * The metadata cache will read the larger image, and call * the refresh function again. * * Processing in the refresh function should proceed as follows: * - * The target entry will be protected for the duration of the - * refresh call. This allows entry resizes if necessary, and + * The target entry will be protected for the duration of the + * refresh call. This allows entry resizes if necessary, and * prevents re-entrant refresh calls. * - * If the supplied image contains valid data, and is of the correct - * length, the refresh function must parse it, and apply updates to + * If the supplied image contains valid data, and is of the correct + * length, the refresh function must parse it, and apply updates to * the in core representatin of the metadata cache entry as required. - * Note that since the file is opened R/O, any updates must not + * Note that since the file is opened R/O, any updates must not * cause the entry to be marked dirty. * * If the image contains valid data, but is too small, the refresh - * callback must copy the correct image length to *len_ptr, and - * return success. The metadata cache will make a second call with - * the correct image length. If the entry must change size, the - * refresh callback must call H5C_resize_entry(). + * callback must copy the correct image length to *len_ptr, and + * return success. The metadata cache will make a second call with + * the correct image length. If the entry must change size, the + * refresh callback must call H5C_resize_entry(). * * If the image contains invalid data, or if, for whatever reason, - * the refresh function cannot apply its contents, the refresh + * the refresh function cannot apply its contents, the refresh * function must return failure. * ***************************************************************************/ /* Actions that can be reported to 'notify' client callback */ typedef enum H5C_notify_action_t { - H5C_NOTIFY_ACTION_AFTER_INSERT, /* Entry has been added to the cache - * via the insert call - */ - H5C_NOTIFY_ACTION_AFTER_LOAD, /* Entry has been loaded into the - * from file via the protect call - */ - H5C_NOTIFY_ACTION_AFTER_FLUSH, /* Entry has just been flushed to - * file. - */ - H5C_NOTIFY_ACTION_BEFORE_EVICT, /* Entry is about to be evicted - * from cache. - */ - H5C_NOTIFY_ACTION_ENTRY_DIRTIED, /* Entry has been marked dirty. */ - H5C_NOTIFY_ACTION_ENTRY_CLEANED, /* Entry has been marked clean. */ - H5C_NOTIFY_ACTION_CHILD_DIRTIED, /* Dependent child has been marked - * dirty. - */ - H5C_NOTIFY_ACTION_CHILD_CLEANED, /* Dependent child has been marked - * clean. - */ - H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, /* Dependent child has been marked - * unserialized. - */ - H5C_NOTIFY_ACTION_CHILD_SERIALIZED /* Dependent child has been marked - * serialized. - */ + H5C_NOTIFY_ACTION_AFTER_INSERT, /* Entry has been added to the cache + * via the insert call + */ + H5C_NOTIFY_ACTION_AFTER_LOAD, /* Entry has been loaded into the + * from file via the protect call + */ + H5C_NOTIFY_ACTION_AFTER_FLUSH, /* Entry has just been flushed to + * file. + */ + H5C_NOTIFY_ACTION_BEFORE_EVICT, /* Entry is about to be evicted + * from cache. + */ + H5C_NOTIFY_ACTION_ENTRY_DIRTIED, /* Entry has been marked dirty. */ + H5C_NOTIFY_ACTION_ENTRY_CLEANED, /* Entry has been marked clean. */ + H5C_NOTIFY_ACTION_CHILD_DIRTIED, /* Dependent child has been marked + * dirty. + */ + H5C_NOTIFY_ACTION_CHILD_CLEANED, /* Dependent child has been marked + * clean. + */ + H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, /* Dependent child has been marked + * unserialized. + */ + H5C_NOTIFY_ACTION_CHILD_SERIALIZED /* Dependent child has been marked + * serialized. + */ } H5C_notify_action_t; /* Cache client callback function pointers */ -typedef herr_t (*H5C_get_initial_load_size_func_t)(void *udata_ptr, - size_t *image_len_ptr); -typedef herr_t (*H5C_get_final_load_size_func_t)(const void *image_ptr, - size_t image_len, void *udata_ptr, size_t *actual_len_ptr); -typedef htri_t (*H5C_verify_chksum_func_t)(const void *image_ptr, size_t len, - void *udata_ptr); -typedef void *(*H5C_deserialize_func_t)(const void *image_ptr, - size_t len, void *udata_ptr, hbool_t *dirty_ptr); -typedef herr_t (*H5C_image_len_func_t)(const void *thing, - size_t *image_len_ptr); -typedef herr_t (*H5C_pre_serialize_func_t)(H5F_t *f, void *thing, haddr_t addr, - size_t len, haddr_t *new_addr_ptr, size_t *new_len_ptr, - unsigned *flags_ptr); -typedef herr_t (*H5C_serialize_func_t)(const H5F_t *f, void *image_ptr, - size_t len, void *thing); +typedef herr_t (*H5C_get_initial_load_size_func_t)(void *udata_ptr, size_t *image_len_ptr); +typedef herr_t (*H5C_get_final_load_size_func_t)(const void *image_ptr, size_t image_len, void *udata_ptr, + size_t *actual_len_ptr); +typedef htri_t (*H5C_verify_chksum_func_t)(const void *image_ptr, size_t len, void *udata_ptr); +typedef void *(*H5C_deserialize_func_t)(const void *image_ptr, size_t len, void *udata_ptr, + hbool_t *dirty_ptr); +typedef herr_t (*H5C_image_len_func_t)(const void *thing, size_t *image_len_ptr); +typedef herr_t (*H5C_pre_serialize_func_t)(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr_ptr, size_t *new_len_ptr, unsigned *flags_ptr); +typedef herr_t (*H5C_serialize_func_t)(const H5F_t *f, void *image_ptr, size_t len, void *thing); typedef herr_t (*H5C_notify_func_t)(H5C_notify_action_t action, void *thing); typedef herr_t (*H5C_free_icr_func_t)(void *thing); -typedef herr_t (*H5C_get_fsf_size_t)(const void * thing, hsize_t *fsf_size_ptr); -typedef herr_t (*H5C_vfd_swmr_refresh_func_t)(H5F_t * f, void * entry_ptr, - const void * image_ptr, size_t *len_ptr); +typedef herr_t (*H5C_get_fsf_size_t)(const void *thing, hsize_t *fsf_size_ptr); +typedef herr_t (*H5C_vfd_swmr_refresh_func_t)(H5F_t *f, void *entry_ptr, const void *image_ptr, + size_t *len_ptr); /* Metadata cache client class definition */ typedef struct H5C_class_t { - int id; - const char * name; - H5FD_mem_t mem_type; - unsigned flags; - H5C_get_initial_load_size_func_t get_initial_load_size; - H5C_get_final_load_size_func_t get_final_load_size; - H5C_verify_chksum_func_t verify_chksum; - H5C_deserialize_func_t deserialize; - H5C_image_len_func_t image_len; - H5C_pre_serialize_func_t pre_serialize; - H5C_serialize_func_t serialize; - H5C_notify_func_t notify; - H5C_free_icr_func_t free_icr; - H5C_get_fsf_size_t fsf_size; - H5C_vfd_swmr_refresh_func_t refresh; + int id; + const char * name; + H5FD_mem_t mem_type; + unsigned flags; + H5C_get_initial_load_size_func_t get_initial_load_size; + H5C_get_final_load_size_func_t get_final_load_size; + H5C_verify_chksum_func_t verify_chksum; + H5C_deserialize_func_t deserialize; + H5C_image_len_func_t image_len; + H5C_pre_serialize_func_t pre_serialize; + H5C_serialize_func_t serialize; + H5C_notify_func_t notify; + H5C_free_icr_func_t free_icr; + H5C_get_fsf_size_t fsf_size; + H5C_vfd_swmr_refresh_func_t refresh; } H5C_class_t; /* Type definitions of callback functions used by the cache as a whole */ -typedef herr_t (*H5C_write_permitted_func_t)(const H5F_t *f, - hbool_t *write_permitted_ptr); -typedef herr_t (*H5C_log_flush_func_t)(H5C_t *cache_ptr, haddr_t addr, - hbool_t was_dirty, unsigned flags); +typedef herr_t (*H5C_write_permitted_func_t)(const H5F_t *f, hbool_t *write_permitted_ptr); +typedef herr_t (*H5C_log_flush_func_t)(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, unsigned flags); /**************************************************************************** * @@ -1067,17 +1055,16 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t *cache_ptr, haddr_t addr, * debugging. */ -#define H5C_RING_UNDEFINED 0 /* shouldn't appear in the cache */ -#define H5C_RING_USER 1 /* outermost ring */ -#define H5C_RING_RDFSM 2 -#define H5C_RING_MDFSM 3 -#define H5C_RING_SBE 4 -#define H5C_RING_SB 5 /* innermost ring */ -#define H5C_RING_NTYPES 6 +#define H5C_RING_UNDEFINED 0 /* shouldn't appear in the cache */ +#define H5C_RING_USER 1 /* outermost ring */ +#define H5C_RING_RDFSM 2 +#define H5C_RING_MDFSM 3 +#define H5C_RING_SBE 4 +#define H5C_RING_SB 5 /* innermost ring */ +#define H5C_RING_NTYPES 6 typedef int H5C_ring_t; - /**************************************************************************** * * structure H5C_cache_entry_t @@ -1690,32 +1677,32 @@ typedef int H5C_ring_t; * * Fields supporting VFD SWMR * - * The following fields exist to support the page index. These fields are + * The following fields exist to support the page index. These fields are * only defined when the vfd_swmr_reader field in the associated instance of * H5C_t is set to TRUE. * - * page: Page offset of the page containing the base address of the + * page: Page offset of the page containing the base address of the * metadata cache entry. * * refreshed_in_tick: When an entry is refreshed as part of the VFD SWMR - * reader end of tick processing, this field is used to - * record the tick in which this occured. The field is + * reader end of tick processing, this field is used to + * record the tick in which this occured. The field is * used primarily for sanity checking. * * pi_next: Next pointer used by the page index hash table that maps - * page buffer pages to any metadata cache entries that + * page buffer pages to any metadata cache entries that * reside in the target page. - * - * This field points to the next entry in the doubly linked - * list of entries in the hash bin, or NULL if there is no + * + * This field points to the next entry in the doubly linked + * list of entries in the hash bin, or NULL if there is no * next entry. * * pi_prev: Prev pointer used by the page index hash table that maps - * page buffer pages to any metadata cache entries that + * page buffer pages to any metadata cache entries that * reside in the target page. - * - * This field points to the next entry in the doubly linked - * list of entries in the hash bin, or NULL if there is no + * + * This field points to the next entry in the doubly linked + * list of entries in the hash bin, or NULL if there is no * next entry * * Cache entry stats collection fields: @@ -1738,100 +1725,99 @@ typedef int H5C_ring_t; * ****************************************************************************/ typedef struct H5C_cache_entry_t { - uint32_t magic; - H5C_t *cache_ptr; - haddr_t addr; - size_t size; - void *image_ptr; - hbool_t image_up_to_date; - const H5C_class_t *type; - hbool_t is_dirty; - hbool_t dirtied; - hbool_t is_protected; - hbool_t is_read_only; - int ro_ref_count; - hbool_t is_pinned; - hbool_t in_slist; - hbool_t flush_marker; - hbool_t flush_me_last; + uint32_t magic; + H5C_t * cache_ptr; + haddr_t addr; + size_t size; + void * image_ptr; + hbool_t image_up_to_date; + const H5C_class_t *type; + hbool_t is_dirty; + hbool_t dirtied; + hbool_t is_protected; + hbool_t is_read_only; + int ro_ref_count; + hbool_t is_pinned; + hbool_t in_slist; + hbool_t flush_marker; + hbool_t flush_me_last; #ifdef H5_HAVE_PARALLEL - hbool_t clear_on_unprotect; - hbool_t flush_immediately; - hbool_t coll_access; + hbool_t clear_on_unprotect; + hbool_t flush_immediately; + hbool_t coll_access; #endif /* H5_HAVE_PARALLEL */ - hbool_t flush_in_progress; - hbool_t destroy_in_progress; + hbool_t flush_in_progress; + hbool_t destroy_in_progress; /* fields supporting rings for purposes of flush ordering */ - H5C_ring_t ring; + H5C_ring_t ring; /* fields supporting the 'flush dependency' feature: */ - struct H5C_cache_entry_t ** flush_dep_parent; - unsigned flush_dep_nparents; - unsigned flush_dep_parent_nalloc; - unsigned flush_dep_nchildren; - unsigned flush_dep_ndirty_children; - unsigned flush_dep_nunser_children; - hbool_t pinned_from_client; - hbool_t pinned_from_cache; + struct H5C_cache_entry_t **flush_dep_parent; + unsigned flush_dep_nparents; + unsigned flush_dep_parent_nalloc; + unsigned flush_dep_nchildren; + unsigned flush_dep_ndirty_children; + unsigned flush_dep_nunser_children; + hbool_t pinned_from_client; + hbool_t pinned_from_cache; /* fields supporting the hash table: */ - struct H5C_cache_entry_t *ht_next; - struct H5C_cache_entry_t *ht_prev; - struct H5C_cache_entry_t *il_next; - struct H5C_cache_entry_t *il_prev; + struct H5C_cache_entry_t *ht_next; + struct H5C_cache_entry_t *ht_prev; + struct H5C_cache_entry_t *il_next; + struct H5C_cache_entry_t *il_prev; /* fields supporting replacement policies: */ - struct H5C_cache_entry_t *next; - struct H5C_cache_entry_t *prev; + struct H5C_cache_entry_t *next; + struct H5C_cache_entry_t *prev; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - struct H5C_cache_entry_t *aux_next; - struct H5C_cache_entry_t *aux_prev; + struct H5C_cache_entry_t *aux_next; + struct H5C_cache_entry_t *aux_prev; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL - struct H5C_cache_entry_t *coll_next; - struct H5C_cache_entry_t *coll_prev; + struct H5C_cache_entry_t *coll_next; + struct H5C_cache_entry_t *coll_prev; #endif /* H5_HAVE_PARALLEL */ /* fields supporting cache image */ - hbool_t include_in_image; - int32_t lru_rank; - hbool_t image_dirty; - uint64_t fd_parent_count; - haddr_t *fd_parent_addrs; - uint64_t fd_child_count; - uint64_t fd_dirty_child_count; - uint32_t image_fd_height; - hbool_t prefetched; - int prefetch_type_id; - int32_t age; - hbool_t prefetched_dirty; - -#ifndef NDEBUG /* debugging field */ - int serialization_count; + hbool_t include_in_image; + int32_t lru_rank; + hbool_t image_dirty; + uint64_t fd_parent_count; + haddr_t *fd_parent_addrs; + uint64_t fd_child_count; + uint64_t fd_dirty_child_count; + uint32_t image_fd_height; + hbool_t prefetched; + int prefetch_type_id; + int32_t age; + hbool_t prefetched_dirty; + +#ifndef NDEBUG /* debugging field */ + int serialization_count; #endif /* NDEBUG */ /* fields supporting tag lists */ - struct H5C_cache_entry_t *tl_next; - struct H5C_cache_entry_t *tl_prev; - struct H5C_tag_info_t *tag_info; + struct H5C_cache_entry_t *tl_next; + struct H5C_cache_entry_t *tl_prev; + struct H5C_tag_info_t * tag_info; /* fields supporting VFD SWMR */ - uint64_t page; - uint64_t refreshed_in_tick; - struct H5C_cache_entry_t *pi_next; - struct H5C_cache_entry_t *pi_prev; + uint64_t page; + uint64_t refreshed_in_tick; + struct H5C_cache_entry_t *pi_next; + struct H5C_cache_entry_t *pi_prev; #if H5C_COLLECT_CACHE_ENTRY_STATS /* cache entry stats fields */ - int32_t accesses; - int32_t clears; - int32_t flushes; - int32_t pins; + int32_t accesses; + int32_t clears; + int32_t flushes; + int32_t pins; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ } H5C_cache_entry_t; - /**************************************************************************** * * structure H5C_image_entry_t @@ -1977,20 +1963,20 @@ typedef struct H5C_cache_entry_t { ****************************************************************************/ typedef struct H5C_image_entry_t { - uint32_t magic; - haddr_t addr; - size_t size; - H5C_ring_t ring; - int32_t age; - int32_t type_id; - int32_t lru_rank; - hbool_t is_dirty; - unsigned image_fd_height; - uint64_t fd_parent_count; - haddr_t *fd_parent_addrs; - uint64_t fd_child_count; - uint64_t fd_dirty_child_count; - void *image_ptr; + uint32_t magic; + haddr_t addr; + size_t size; + H5C_ring_t ring; + int32_t age; + int32_t type_id; + int32_t lru_rank; + hbool_t is_dirty; + unsigned image_fd_height; + uint64_t fd_parent_count; + haddr_t * fd_parent_addrs; + uint64_t fd_child_count; + uint64_t fd_dirty_child_count; + void * image_ptr; } H5C_image_entry_t; /**************************************************************************** @@ -2233,8 +2219,7 @@ typedef struct H5C_image_entry_t { * ****************************************************************************/ -enum H5C_resize_status -{ +enum H5C_resize_status { in_spec, increase, flash_increase, @@ -2246,40 +2231,41 @@ enum H5C_resize_status not_full }; /* enum H5C_resize_conditions */ -typedef void (*H5C_auto_resize_rpt_fcn)(H5C_t * cache_ptr, int32_t version, - double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, - size_t new_max_cache_size, size_t old_min_clean_size, size_t new_min_clean_size); +typedef void (*H5C_auto_resize_rpt_fcn)(H5C_t *cache_ptr, int32_t version, double hit_rate, + enum H5C_resize_status status, size_t old_max_cache_size, + size_t new_max_cache_size, size_t old_min_clean_size, + size_t new_min_clean_size); typedef struct H5C_auto_size_ctl_t { /* general configuration fields: */ - int32_t version; - H5C_auto_resize_rpt_fcn rpt_fcn; - hbool_t set_initial_size; - size_t initial_size; - double min_clean_fraction; - size_t max_size; - size_t min_size; - int64_t epoch_length; + int32_t version; + H5C_auto_resize_rpt_fcn rpt_fcn; + hbool_t set_initial_size; + size_t initial_size; + double min_clean_fraction; + size_t max_size; + size_t min_size; + int64_t epoch_length; /* size increase control fields: */ - enum H5C_cache_incr_mode incr_mode; - double lower_hr_threshold; - double increment; - hbool_t apply_max_increment; - size_t max_increment; - enum H5C_cache_flash_incr_mode flash_incr_mode; - double flash_multiple; - double flash_threshold; + enum H5C_cache_incr_mode incr_mode; + double lower_hr_threshold; + double increment; + hbool_t apply_max_increment; + size_t max_increment; + enum H5C_cache_flash_incr_mode flash_incr_mode; + double flash_multiple; + double flash_threshold; /* size decrease control fields: */ - enum H5C_cache_decr_mode decr_mode; - double upper_hr_threshold; - double decrement; - hbool_t apply_max_decrement; - size_t max_decrement; - int32_t epochs_before_eviction; - hbool_t apply_empty_reserve; - double empty_reserve; + enum H5C_cache_decr_mode decr_mode; + double upper_hr_threshold; + double decrement; + hbool_t apply_max_decrement; + size_t max_decrement; + int32_t epochs_before_eviction; + hbool_t apply_empty_reserve; + double empty_reserve; } H5C_auto_size_ctl_t; /**************************************************************************** @@ -2340,176 +2326,148 @@ typedef struct H5C_auto_size_ctl_t { * ****************************************************************************/ -#define H5C_CI__GEN_MDCI_SBE_MESG ((unsigned)0x0001) -#define H5C_CI__GEN_MDC_IMAGE_BLK ((unsigned)0x0002) -#define H5C_CI__SUPRESS_ENTRY_WRITES ((unsigned)0x0004) -#define H5C_CI__WRITE_CACHE_IMAGE ((unsigned)0x0008) +#define H5C_CI__GEN_MDCI_SBE_MESG ((unsigned)0x0001) +#define H5C_CI__GEN_MDC_IMAGE_BLK ((unsigned)0x0002) +#define H5C_CI__SUPRESS_ENTRY_WRITES ((unsigned)0x0004) +#define H5C_CI__WRITE_CACHE_IMAGE ((unsigned)0x0008) /* This #define must set all defined H5C_CI flags. It is * used in the default value for instances of H5C_cache_image_ctl_t. * This value will only be modified in test code. */ -#define H5C_CI__ALL_FLAGS ((unsigned)0x000F) +#define H5C_CI__ALL_FLAGS ((unsigned)0x000F) -#define H5C__DEFAULT_CACHE_IMAGE_CTL \ -{ \ - /* version = */ H5C__CURR_CACHE_IMAGE_CTL_VER, \ - /* generate_image = */ FALSE, \ - /* save_resize_status = */ FALSE, \ - /* entry_ageout = */ H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE, \ - /* flags = */ H5C_CI__ALL_FLAGS \ -} +#define H5C__DEFAULT_CACHE_IMAGE_CTL \ + { \ + /* version = */ H5C__CURR_CACHE_IMAGE_CTL_VER, /* generate_image = */ FALSE, \ + /* save_resize_status = */ FALSE, \ + /* entry_ageout = */ H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE, \ + /* flags = */ H5C_CI__ALL_FLAGS \ + } typedef struct H5C_cache_image_ctl_t { - int32_t version; - hbool_t generate_image; - hbool_t save_resize_status; - int32_t entry_ageout; - unsigned flags; + int32_t version; + hbool_t generate_image; + hbool_t save_resize_status; + int32_t entry_ageout; + unsigned flags; } H5C_cache_image_ctl_t; /* The cache logging output style */ -typedef enum H5C_log_style_t { - H5C_LOG_STYLE_JSON, - H5C_LOG_STYLE_TRACE -} H5C_log_style_t; +typedef enum H5C_log_style_t { H5C_LOG_STYLE_JSON, H5C_LOG_STYLE_TRACE } H5C_log_style_t; /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL H5C_t *H5C_create(size_t max_cache_size, size_t min_clean_size, - int max_type_id, const H5C_class_t * const *class_table_ptr, - H5C_write_permitted_func_t check_write_permitted, hbool_t write_permitted, - H5C_log_flush_func_t log_flush, void *aux_ptr); -H5_DLL void H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, int32_t version, - double hit_rate, enum H5C_resize_status status, - size_t old_max_cache_size, size_t new_max_cache_size, - size_t old_min_clean_size, size_t new_min_clean_size); +H5_DLL H5C_t *H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, + const H5C_class_t *const * class_table_ptr, + H5C_write_permitted_func_t check_write_permitted, hbool_t write_permitted, + H5C_log_flush_func_t log_flush, void *aux_ptr); +H5_DLL void H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, int32_t version, double hit_rate, + enum H5C_resize_status status, size_t old_max_cache_size, + size_t new_max_cache_size, size_t old_min_clean_size, + size_t new_min_clean_size); H5_DLL herr_t H5C_dest(H5F_t *f); H5_DLL herr_t H5C_evict(H5F_t *f); -H5_DLL herr_t H5C_evict_or_refresh_all_entries_in_page(H5F_t * f, uint64_t page, - uint32_t length, uint64_t tick); -H5_DLL herr_t H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, - unsigned flags); +H5_DLL herr_t H5C_evict_or_refresh_all_entries_in_page(H5F_t *f, uint64_t page, uint32_t length, + uint64_t tick); +H5_DLL herr_t H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flags); H5_DLL herr_t H5C_flush_cache(H5F_t *f, unsigned flags); H5_DLL herr_t H5C_flush_tagged_entries(H5F_t *f, haddr_t tag); -H5_DLL herr_t H5C_force_cache_image_load(H5F_t * f); +H5_DLL herr_t H5C_force_cache_image_load(H5F_t *f); H5_DLL herr_t H5C_evict_tagged_entries(H5F_t *f, haddr_t tag, hbool_t match_global); -H5_DLL herr_t H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags, hbool_t type_match); +H5_DLL herr_t H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags, + hbool_t type_match); H5_DLL herr_t H5C_get_tag(const void *thing, /*OUT*/ haddr_t *tag); #if H5C_DO_TAGGING_SANITY_CHECKS herr_t H5C_verify_tag(int id, haddr_t tag); #endif -H5_DLL herr_t H5C_flush_to_min_clean(H5F_t *f); -H5_DLL herr_t H5C_get_cache_auto_resize_config(const H5C_t *cache_ptr, - H5C_auto_size_ctl_t *config_ptr); -H5_DLL herr_t H5C_get_cache_image_config(const H5C_t * cache_ptr, - H5C_cache_image_ctl_t *config_ptr); -H5_DLL herr_t H5C_get_cache_size(H5C_t *cache_ptr, size_t *max_size_ptr, - size_t *min_clean_size_ptr, size_t *cur_size_ptr, - uint32_t *cur_num_entries_ptr); -H5_DLL herr_t H5C_get_cache_flush_in_progress(H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr); -H5_DLL herr_t H5C_get_cache_hit_rate(H5C_t *cache_ptr, double *hit_rate_ptr); -H5_DLL int H5C_get_curr_io_client_type(H5C_t * cache_ptr); -H5_DLL hbool_t H5C_get_curr_read_speculative(H5C_t * cache_ptr); -H5_DLL herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, - size_t *size_ptr, hbool_t *in_cache_ptr, hbool_t *is_dirty_ptr, - hbool_t *is_protected_ptr, hbool_t *is_pinned_ptr, hbool_t *is_corked_ptr, - hbool_t *is_flush_dep_parent_ptr, hbool_t *is_flush_dep_child_ptr, - hbool_t *image_up_to_date_ptr); -H5_DLL herr_t H5C_get_evictions_enabled(const H5C_t *cache_ptr, - hbool_t *evictions_enabled_ptr); -H5_DLL void * H5C_get_aux_ptr(const H5C_t *cache_ptr); -H5_DLL herr_t H5C_image_stats(H5C_t * cache_ptr, hbool_t print_header); -H5_DLL herr_t H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, - void *thing, unsigned int flags); -H5_DLL herr_t H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, - hsize_t len, hbool_t rw); -H5_DLL herr_t H5C_mark_entry_dirty(void *thing); -H5_DLL herr_t H5C_mark_entry_clean(void *thing); -H5_DLL herr_t H5C_mark_entry_unserialized(void *thing); -H5_DLL herr_t H5C_mark_entry_serialized(void *thing); -H5_DLL herr_t H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, - haddr_t old_addr, haddr_t new_addr); -H5_DLL herr_t H5C_pin_protected_entry(void *thing); -H5_DLL herr_t H5C_prep_for_file_close(H5F_t *f); -H5_DLL herr_t H5C_create_flush_dependency(void *parent_thing, - void *child_thing); -H5_DLL void * H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, - void *udata, unsigned flags); -H5_DLL herr_t H5C_reset_cache_hit_rate_stats(H5C_t *cache_ptr); -H5_DLL herr_t H5C_resize_entry(void *thing, size_t new_size); -H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr); -H5_DLL herr_t H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, - H5C_cache_image_ctl_t *config_ptr); -H5_DLL herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, - hbool_t evictions_enabled); -H5_DLL herr_t H5C_set_vfd_swmr_reader(H5C_t *cache_ptr, - hbool_t vfd_swmr_reader, hsize_t page_size); +H5_DLL herr_t H5C_flush_to_min_clean(H5F_t *f); +H5_DLL herr_t H5C_get_cache_auto_resize_config(const H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr); +H5_DLL herr_t H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); +H5_DLL herr_t H5C_get_cache_size(H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); +H5_DLL herr_t H5C_get_cache_flush_in_progress(H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr); +H5_DLL herr_t H5C_get_cache_hit_rate(H5C_t *cache_ptr, double *hit_rate_ptr); +H5_DLL int H5C_get_curr_io_client_type(H5C_t *cache_ptr); +H5_DLL hbool_t H5C_get_curr_read_speculative(H5C_t *cache_ptr); +H5_DLL herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, size_t *size_ptr, hbool_t *in_cache_ptr, + hbool_t *is_dirty_ptr, hbool_t *is_protected_ptr, hbool_t *is_pinned_ptr, + hbool_t *is_corked_ptr, hbool_t *is_flush_dep_parent_ptr, + hbool_t *is_flush_dep_child_ptr, hbool_t *image_up_to_date_ptr); +H5_DLL herr_t H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t *evictions_enabled_ptr); +H5_DLL void * H5C_get_aux_ptr(const H5C_t *cache_ptr); +H5_DLL herr_t H5C_image_stats(H5C_t *cache_ptr, hbool_t print_header); +H5_DLL herr_t H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, + unsigned int flags); +H5_DLL herr_t H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw); +H5_DLL herr_t H5C_mark_entry_dirty(void *thing); +H5_DLL herr_t H5C_mark_entry_clean(void *thing); +H5_DLL herr_t H5C_mark_entry_unserialized(void *thing); +H5_DLL herr_t H5C_mark_entry_serialized(void *thing); +H5_DLL herr_t H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, haddr_t new_addr); +H5_DLL herr_t H5C_pin_protected_entry(void *thing); +H5_DLL herr_t H5C_prep_for_file_close(H5F_t *f); +H5_DLL herr_t H5C_create_flush_dependency(void *parent_thing, void *child_thing); +H5_DLL void * H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsigned flags); +H5_DLL herr_t H5C_reset_cache_hit_rate_stats(H5C_t *cache_ptr); +H5_DLL herr_t H5C_resize_entry(void *thing, size_t new_size); +H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr); +H5_DLL herr_t H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); +H5_DLL herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled); +H5_DLL herr_t H5C_set_vfd_swmr_reader(H5C_t *cache_ptr, hbool_t vfd_swmr_reader, hsize_t page_size); H5_DLL herr_t H5C_set_prefix(H5C_t *cache_ptr, char *prefix); -H5_DLL herr_t H5C_stats(H5C_t *cache_ptr, const char *cache_name, - hbool_t display_detailed_stats); -H5_DLL void H5C_stats__reset(H5C_t *cache_ptr); +H5_DLL herr_t H5C_stats(H5C_t *cache_ptr, const char *cache_name, hbool_t display_detailed_stats); +H5_DLL void H5C_stats__reset(H5C_t *cache_ptr); H5_DLL herr_t H5C_unpin_entry(void *thing); -H5_DLL herr_t H5C_destroy_flush_dependency(void *parent_thing, - void *child_thing); -H5_DLL herr_t H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, - unsigned int flags); -H5_DLL herr_t H5C_validate_cache_image_config(H5C_cache_image_ctl_t * ctl_ptr); -H5_DLL herr_t H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, - unsigned int tests); +H5_DLL herr_t H5C_destroy_flush_dependency(void *parent_thing, void *child_thing); +H5_DLL herr_t H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned int flags); +H5_DLL herr_t H5C_validate_cache_image_config(H5C_cache_image_ctl_t *ctl_ptr); +H5_DLL herr_t H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests); H5_DLL herr_t H5C_ignore_tags(H5C_t *cache_ptr); -H5_DLL hbool_t H5C_get_ignore_tags(const H5C_t *cache_ptr); +H5_DLL hbool_t H5C_get_ignore_tags(const H5C_t *cache_ptr); H5_DLL uint32_t H5C_get_num_objs_corked(const H5C_t *cache_ptr); -H5_DLL herr_t H5C_retag_entries(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag); -H5_DLL herr_t H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, - hbool_t *corked); -H5_DLL herr_t H5C_get_entry_ring(const H5F_t *f, haddr_t addr, - H5C_ring_t *ring); -H5_DLL herr_t H5C_unsettle_entry_ring(void *thing); -H5_DLL herr_t H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring); -H5_DLL herr_t H5C_remove_entry(void *thing); -H5_DLL herr_t H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, - hbool_t *write_ci_ptr); -H5_DLL hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr); -H5_DLL herr_t H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, - hsize_t *image_len); +H5_DLL herr_t H5C_retag_entries(H5C_t *cache_ptr, haddr_t src_tag, haddr_t dest_tag); +H5_DLL herr_t H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked); +H5_DLL herr_t H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring); +H5_DLL herr_t H5C_unsettle_entry_ring(void *thing); +H5_DLL herr_t H5C_unsettle_ring(H5F_t *f, H5C_ring_t ring); +H5_DLL herr_t H5C_remove_entry(void *thing); +H5_DLL herr_t H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr); +H5_DLL hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr); +H5_DLL herr_t H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); /* Logging functions */ H5_DLL herr_t H5C_start_logging(H5C_t *cache); H5_DLL herr_t H5C_stop_logging(H5C_t *cache); -H5_DLL herr_t H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, /*OUT*/ hbool_t *is_currently_logging); +H5_DLL herr_t H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, + /*OUT*/ hbool_t *is_currently_logging); #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, - unsigned num_candidates, haddr_t *candidates_list_ptr, int mpi_rank, - int mpi_size); +H5_DLL herr_t H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, + haddr_t *candidates_list_ptr, int mpi_rank, int mpi_size); H5_DLL herr_t H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr); H5_DLL herr_t H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr); -H5_DLL herr_t H5C_clear_coll_entries(H5C_t * cache_ptr, hbool_t partial); -H5_DLL herr_t H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, - haddr_t *ce_array_ptr); +H5_DLL herr_t H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial); +H5_DLL herr_t H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr); #endif /* H5_HAVE_PARALLEL */ -#ifndef NDEBUG /* debugging functions */ -H5_DLL herr_t H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name); -H5_DLL herr_t H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name); +#ifndef NDEBUG /* debugging functions */ +H5_DLL herr_t H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name); +H5_DLL herr_t H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name); H5_DLL hbool_t H5C_get_serialization_in_progress(const H5C_t *cache_ptr); H5_DLL hbool_t H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring); -H5_DLL herr_t H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn); +H5_DLL herr_t H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn); #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5C_dump_coll_write_list(H5C_t * cache_ptr, char * calling_fcn); +H5_DLL herr_t H5C_dump_coll_write_list(H5C_t *cache_ptr, char *calling_fcn); #endif /* H5_HAVE_PARALLEL */ -H5_DLL herr_t H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, - void **entry_ptr_ptr); -H5_DLL herr_t H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, - haddr_t child_addr, hbool_t *fd_exists_ptr); -H5_DLL herr_t H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, - const H5C_class_t *expected_type, hbool_t *in_cache_ptr, - hbool_t *type_ok_ptr); +H5_DLL herr_t H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr); +H5_DLL herr_t H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child_addr, + hbool_t *fd_exists_ptr); +H5_DLL herr_t H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, const H5C_class_t *expected_type, + hbool_t *in_cache_ptr, hbool_t *type_ok_ptr); H5_DLL herr_t H5C_validate_index_list(H5C_t *cache_ptr); #endif /* NDEBUG */ #endif /* !_H5Cprivate_H */ - diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h index 62107d9..d735745 100644 --- a/src/H5Cpublic.h +++ b/src/H5Cpublic.h @@ -33,20 +33,11 @@ extern "C" { #endif -enum H5C_cache_incr_mode -{ - H5C_incr__off, - H5C_incr__threshold -}; +enum H5C_cache_incr_mode { H5C_incr__off, H5C_incr__threshold }; -enum H5C_cache_flash_incr_mode -{ - H5C_flash_incr__off, - H5C_flash_incr__add_space -}; +enum H5C_cache_flash_incr_mode { H5C_flash_incr__off, H5C_flash_incr__add_space }; -enum H5C_cache_decr_mode -{ +enum H5C_cache_decr_mode { H5C_decr__off, H5C_decr__threshold, H5C_decr__age_out, diff --git a/src/H5Cquery.c b/src/H5Cquery.c index 477a8ba..4d93467 100644 --- a/src/H5Cquery.c +++ b/src/H5Cquery.c @@ -27,50 +27,41 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5C_get_cache_auto_resize_config * @@ -86,28 +77,26 @@ *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_auto_resize_config(const H5C_t * cache_ptr, - H5C_auto_size_ctl_t *config_ptr) +H5C_get_cache_auto_resize_config(const H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad config_ptr on entry.") *config_ptr = cache_ptr->resize_ctl; config_ptr->set_initial_size = FALSE; - config_ptr->initial_size = cache_ptr->max_cache_size; + config_ptr->initial_size = cache_ptr->max_cache_size; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_auto_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5C_get_cache_size * @@ -125,36 +114,32 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_size(H5C_t * cache_ptr, - size_t * max_size_ptr, - size_t * min_clean_size_ptr, - size_t * cur_size_ptr, - uint32_t * cur_num_entries_ptr) +H5C_get_cache_size(H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, + uint32_t *cur_num_entries_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(max_size_ptr != NULL) + if (max_size_ptr != NULL) *max_size_ptr = cache_ptr->max_cache_size; - if(min_clean_size_ptr != NULL) + if (min_clean_size_ptr != NULL) *min_clean_size_ptr = cache_ptr->min_clean_size; - if(cur_size_ptr != NULL) + if (cur_size_ptr != NULL) *cur_size_ptr = cache_ptr->index_size; - if(cur_num_entries_ptr != NULL) + if (cur_num_entries_ptr != NULL) *cur_num_entries_ptr = cache_ptr->index_len; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_size() */ - /*------------------------------------------------------------------------- * Function: H5C_get_cache_flush_in_progress * @@ -166,23 +151,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_flush_in_progress(H5C_t * cache_ptr, hbool_t *flush_in_progress_ptr) +H5C_get_cache_flush_in_progress(H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(flush_in_progress_ptr != NULL) + if (flush_in_progress_ptr != NULL) *flush_in_progress_ptr = cache_ptr->flush_in_progress; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_flush_in_progress() */ - /*------------------------------------------------------------------------- * Function: H5C_get_cache_hit_rate * @@ -200,23 +184,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_hit_rate(H5C_t * cache_ptr, double * hit_rate_ptr) +H5C_get_cache_hit_rate(H5C_t *cache_ptr, double *hit_rate_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(hit_rate_ptr == NULL) + if (hit_rate_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad hit_rate_ptr on entry.") HDassert(cache_ptr->cache_hits >= 0); HDassert(cache_ptr->cache_accesses >= cache_ptr->cache_hits); - if(cache_ptr->cache_accesses > 0) - *hit_rate_ptr = ((double)(cache_ptr->cache_hits)) / - ((double)(cache_ptr->cache_accesses)); + if (cache_ptr->cache_accesses > 0) + *hit_rate_ptr = ((double)(cache_ptr->cache_hits)) / ((double)(cache_ptr->cache_accesses)); else *hit_rate_ptr = 0.0f; @@ -224,7 +207,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_hit_rate() */ - /*------------------------------------------------------------------------- * * Function: H5C_get_entry_status @@ -248,21 +230,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_entry_status(const H5F_t *f, - haddr_t addr, - size_t * size_ptr, - hbool_t * in_cache_ptr, - hbool_t * is_dirty_ptr, - hbool_t * is_protected_ptr, - hbool_t * is_pinned_ptr, - hbool_t * is_corked_ptr, - hbool_t * is_flush_dep_parent_ptr, - hbool_t * is_flush_dep_child_ptr, - hbool_t * image_up_to_date_ptr) +H5C_get_entry_status(const H5F_t *f, haddr_t addr, size_t *size_ptr, hbool_t *in_cache_ptr, + hbool_t *is_dirty_ptr, hbool_t *is_protected_ptr, hbool_t *is_pinned_ptr, + hbool_t *is_corked_ptr, hbool_t *is_flush_dep_parent_ptr, + hbool_t *is_flush_dep_child_ptr, hbool_t *image_up_to_date_ptr) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -280,12 +255,12 @@ H5C_get_entry_status(const H5F_t *f, /* this test duplicates two of the above asserts, but we need an * invocation of HGOTO_ERROR to keep the compiler happy. */ - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) { + if (entry_ptr == NULL) { /* the entry doesn't exist in the cache -- report this * and quit. */ @@ -293,21 +268,21 @@ H5C_get_entry_status(const H5F_t *f, } /* end if */ else { *in_cache_ptr = TRUE; - if(size_ptr != NULL) + if (size_ptr != NULL) *size_ptr = entry_ptr->size; - if(is_dirty_ptr != NULL) + if (is_dirty_ptr != NULL) *is_dirty_ptr = entry_ptr->is_dirty; - if(is_protected_ptr != NULL) + if (is_protected_ptr != NULL) *is_protected_ptr = entry_ptr->is_protected; - if(is_pinned_ptr != NULL) + if (is_pinned_ptr != NULL) *is_pinned_ptr = entry_ptr->is_pinned; - if(is_corked_ptr != NULL) + if (is_corked_ptr != NULL) *is_corked_ptr = entry_ptr->tag_info ? entry_ptr->tag_info->corked : FALSE; - if(is_flush_dep_parent_ptr != NULL) + if (is_flush_dep_parent_ptr != NULL) *is_flush_dep_parent_ptr = (entry_ptr->flush_dep_nchildren > 0); - if(is_flush_dep_child_ptr != NULL) + if (is_flush_dep_child_ptr != NULL) *is_flush_dep_child_ptr = (entry_ptr->flush_dep_nparents > 0); - if(image_up_to_date_ptr != NULL ) + if (image_up_to_date_ptr != NULL) *image_up_to_date_ptr = entry_ptr->image_up_to_date; } /* end else */ @@ -315,7 +290,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_entry_status() */ - /*------------------------------------------------------------------------- * Function: H5C_get_evictions_enabled() * @@ -330,17 +304,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_evictions_enabled(const H5C_t *cache_ptr, - hbool_t * evictions_enabled_ptr) +H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t *evictions_enabled_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL ) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(evictions_enabled_ptr == NULL) + if (evictions_enabled_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad evictions_enabled_ptr on entry.") *evictions_enabled_ptr = cache_ptr->evictions_enabled; @@ -349,7 +322,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_evictions_enabled() */ - /*------------------------------------------------------------------------- * Function: H5C_get_aux_ptr * @@ -377,7 +349,6 @@ H5C_get_aux_ptr(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(cache_ptr->aux_ptr) } /* H5C_get_aux_ptr() */ - /*------------------------------------------------------------------------- * Function: H5C_get_entry_ring * @@ -396,9 +367,9 @@ H5C_get_aux_ptr(const H5C_t *cache_ptr) herr_t H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring) { - H5C_t *cache_ptr; /* Pointer to cache */ - H5C_cache_entry_t *entry_ptr; /* Pointer to cache entry at address */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; /* Pointer to cache */ + H5C_cache_entry_t *entry_ptr; /* Pointer to cache entry at address */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -412,7 +383,7 @@ H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring) /* Locate the entry at the address */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) + if (entry_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't find entry in index") /* Return the ring value */ @@ -434,25 +405,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_mdc_image_info(H5C_t * cache_ptr, haddr_t *image_addr, hsize_t *image_len) +H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - if(image_addr) + if (image_addr) *image_addr = cache_ptr->image_addr; - if(image_len) + if (image_len) *image_len = cache_ptr->image_len; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_mdc_image_info() */ - /*------------------------------------------------------------------------- * Function: H5C_get_curr_io_client_type * @@ -486,46 +456,44 @@ done: */ int -H5C_get_curr_io_client_type(H5C_t * cache_ptr) +H5C_get_curr_io_client_type(H5C_t *cache_ptr) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if ( cache_ptr->curr_io_type ) { + if (cache_ptr->curr_io_type) { ret_value = cache_ptr->curr_io_type->id; } - FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_curr_io_client_type() */ - /*------------------------------------------------------------------------- * Function: H5C_get_curr_read_speculative * * Purpose: Return a boolean flag indicating whether the current - * read is speculative. - * + * read is speculative. + * * Note that this value is only defined during a read generated * by the metadatat cache. At all other times, the return - * value undefined (although the current implementation + * value undefined (although the current implementation * returns FALSE in such cases). * - * Note also that this function exists to provide hints to the + * Note also that this function exists to provide hints to the * page buffer, which for now at least, is only available in - * the serial case. It should not be depended upon in the - * parallel case -- at least until verified, and potential + * the serial case. It should not be depended upon in the + * parallel case -- at least until verified, and potential * interactions with collective metadata reads are investigated * and dismissed. * - * Return: True if the current call to H5F_block_read() by the - * metadata cache is an initial read attempt for a cache + * Return: True if the current call to H5F_block_read() by the + * metadata cache is an initial read attempt for a cache * client whose speculative read flag is set (in H5AC_class_t), * and false otherwise. * @@ -541,16 +509,16 @@ H5C_get_curr_io_client_type(H5C_t * cache_ptr) */ hbool_t -H5C_get_curr_read_speculative(H5C_t * cache_ptr) +H5C_get_curr_read_speculative(H5C_t *cache_ptr) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if ( cache_ptr->curr_io_type ) { + if (cache_ptr->curr_io_type) { ret_value = cache_ptr->curr_read_speculative; } @@ -558,5 +526,3 @@ H5C_get_curr_read_speculative(H5C_t * cache_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_curr_read_speculative() */ - - diff --git a/src/H5Ctag.c b/src/H5Ctag.c index 2573e93..5ef95b5 100644 --- a/src/H5Ctag.c +++ b/src/H5Ctag.c @@ -27,69 +27,64 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Typedef for tagged entry iterator callback context - evict tagged entries */ typedef struct { - H5F_t *f; /* File pointer for evicting entry */ - hbool_t evicted_entries_last_pass; /* Flag to indicate that an entry - * was evicted when iterating over - * cache - */ - hbool_t pinned_entries_need_evicted;/* Flag to indicate that a pinned - * entry was attempted to be evicted - */ - hbool_t skipped_pf_dirty_entries; /* Flag indicating that one or more - * entries marked prefetched_dirty - * were encountered and not - * evicted. - */ + H5F_t * f; /* File pointer for evicting entry */ + hbool_t evicted_entries_last_pass; /* Flag to indicate that an entry + * was evicted when iterating over + * cache + */ + hbool_t pinned_entries_need_evicted; /* Flag to indicate that a pinned + * entry was attempted to be evicted + */ + hbool_t skipped_pf_dirty_entries; /* Flag indicating that one or more + * entries marked prefetched_dirty + * were encountered and not + * evicted. + */ } H5C_tag_iter_evict_ctx_t; /* Typedef for tagged entry iterator callback context - expunge tag type metadata */ typedef struct { - H5F_t *f; /* File pointer for evicting entry */ - int type_id; /* Cache entry type to expunge */ - unsigned flags; /* Flags for expunging entry */ - hbool_t type_match; + H5F_t * f; /* File pointer for evicting entry */ + int type_id; /* Cache entry type to expunge */ + unsigned flags; /* Flags for expunging entry */ + hbool_t type_match; } H5C_tag_iter_ettm_ctx_t; /* Typedef for tagged entry iterator callback context - mark corked */ typedef struct { - hbool_t cork_val; /* Corked value */ + hbool_t cork_val; /* Corked value */ } H5C_tag_iter_cork_ctx_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t H5C__mark_tagged_entries(H5C_t *cache_ptr, haddr_t tag); - /*********************/ /* Package Variables */ /*********************/ @@ -97,18 +92,14 @@ static herr_t H5C__mark_tagged_entries(H5C_t *cache_ptr, haddr_t tag); /* Declare extern free list to manage the tag info struct */ H5FL_EXTERN(H5C_tag_info_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * * Function: H5C_ignore_tags @@ -132,7 +123,7 @@ H5FL_EXTERN(H5C_tag_info_t); *------------------------------------------------------------------------- */ herr_t -H5C_ignore_tags(H5C_t * cache_ptr) +H5C_ignore_tags(H5C_t *cache_ptr) { FUNC_ENTER_NOAPI_NOERR @@ -146,7 +137,6 @@ H5C_ignore_tags(H5C_t * cache_ptr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_ignore_tags */ - /*------------------------------------------------------------------------- * * Function: H5C_get_ignore_tags @@ -173,7 +163,6 @@ H5C_get_ignore_tags(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(cache_ptr->ignore_tags) } /* H5C_get_ignore_tags */ - /*------------------------------------------------------------------------- * * Function: H5C_get_num_objs_corked @@ -199,7 +188,6 @@ H5C_get_num_objs_corked(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(cache_ptr->num_objs_corked) } /* H5C_get_num_objs_corked */ - /*------------------------------------------------------------------------- * * Function: H5C__tag_entry @@ -219,9 +207,9 @@ H5C_get_num_objs_corked(const H5C_t *cache_ptr) herr_t H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) { - H5C_tag_info_t *tag_info; /* Points to a tag info struct */ - haddr_t tag; /* Tag value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + haddr_t tag; /* Tag value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -233,7 +221,7 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) /* Get the tag */ tag = H5CX_get_tag(); - if(cache->ignore_tags) { + if (cache->ignore_tags) { /* if we're ignoring tags, it's because we're running tests on internal functions and may not have inserted a tag value into a given API context before creating some metadata. Thus, @@ -241,13 +229,13 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) arbitrarily set it to something for the sake of passing the tests. If the tag value is set, then we'll just let it get assigned without additional checking for correctness. */ - if(!H5F_addr_defined(tag)) + if (!H5F_addr_defined(tag)) tag = H5AC__IGNORE_TAG; } /* end if */ #if H5C_DO_TAGGING_SANITY_CHECKS else { /* Perform some sanity checks to ensure that a correct tag is being applied */ - if(H5C_verify_tag(entry->type->id, tag) < 0) + if (H5C_verify_tag(entry->type->id, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "tag verification failed") } /* end else */ #endif @@ -256,16 +244,16 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) tag_info = (H5C_tag_info_t *)H5SL_search(cache->tag_list, &tag); /* Check if this is the first entry for this tagged object */ - if(NULL == tag_info) { + if (NULL == tag_info) { /* Allocate new tag info struct */ - if(NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) + if (NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate tag info for cache entry") /* Set the tag for all entries */ tag_info->tag = tag; /* Insert tag info into skip list */ - if(H5SL_insert(cache->tag_list, tag_info, &(tag_info->tag)) < 0 ) + if (H5SL_insert(cache->tag_list, tag_info, &(tag_info->tag)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert tag info in skip list") } /* end if */ else @@ -277,9 +265,9 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) HDassert(entry->tag_info == NULL); /* Add the entry to the list for the tagged object */ - entry->tl_next = tag_info->head; + entry->tl_next = tag_info->head; entry->tag_info = tag_info; - if(tag_info->head) + if (tag_info->head) tag_info->head->tl_prev = entry; tag_info->head = entry; tag_info->entry_cnt++; @@ -288,7 +276,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__tag_entry */ - /*------------------------------------------------------------------------- * * Function: H5C__untag_entry @@ -306,8 +293,8 @@ done: herr_t H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) { - H5C_tag_info_t *tag_info; /* Points to a tag info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -317,27 +304,27 @@ H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Get the entry's tag info struct */ - if(NULL != (tag_info = entry->tag_info)) { + if (NULL != (tag_info = entry->tag_info)) { /* Remove the entry from the list */ - if(entry->tl_next) + if (entry->tl_next) entry->tl_next->tl_prev = entry->tl_prev; - if(entry->tl_prev) + if (entry->tl_prev) entry->tl_prev->tl_next = entry->tl_next; - if(tag_info->head == entry) + if (tag_info->head == entry) tag_info->head = entry->tl_next; tag_info->entry_cnt--; /* Reset pointers, to avoid confusion */ - entry->tl_next = NULL; - entry->tl_prev = NULL; + entry->tl_next = NULL; + entry->tl_prev = NULL; entry->tag_info = NULL; /* Remove the tag info from the tag list, if there's no more entries with this tag */ - if(!tag_info->corked && 0 == tag_info->entry_cnt) { + if (!tag_info->corked && 0 == tag_info->entry_cnt) { /* Sanity check */ HDassert(NULL == tag_info->head); - if(H5SL_remove(cache->tag_list, &(tag_info->tag)) != tag_info) + if (H5SL_remove(cache->tag_list, &(tag_info->tag)) != tag_info) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove tag info from list") /* Release the tag info */ @@ -351,7 +338,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__untag_entry */ - /*------------------------------------------------------------------------- * * Function: H5C__iter_tagged_entries_real @@ -366,11 +352,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, - void *cb_ctx) +H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, void *cb_ctx) { - H5C_tag_info_t *tag_info; /* Points to a tag info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -383,9 +368,9 @@ H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, tag_info = (H5C_tag_info_t *)H5SL_search(cache->tag_list, &tag); /* If there's any entries for this tag, iterate over them */ - if(tag_info) { - H5C_cache_entry_t *entry; /* Pointer to current entry */ - H5C_cache_entry_t *next_entry; /* Pointer to next entry in hash bucket chain */ + if (tag_info) { + H5C_cache_entry_t *entry; /* Pointer to current entry */ + H5C_cache_entry_t *next_entry; /* Pointer to next entry in hash bucket chain */ /* Sanity check */ HDassert(tag_info->head); @@ -393,24 +378,23 @@ H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, /* Iterate over the entries for this tag */ entry = tag_info->head; - while(entry) { + while (entry) { /* Acquire pointer to next entry */ next_entry = entry->tl_next; /* Make callback for entry */ - if((cb)(entry, cb_ctx) != H5_ITER_CONT) + if ((cb)(entry, cb_ctx) != H5_ITER_CONT) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "tagged entry iteration callback failed") /* Advance to next entry */ entry = next_entry; } /* end while */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__iter_tagged_entries_real() */ - /*------------------------------------------------------------------------- * * Function: H5C__iter_tagged_entries @@ -425,10 +409,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, - H5C_tag_iter_cb_t cb, void *cb_ctx) +H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, H5C_tag_iter_cb_t cb, void *cb_ctx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_PACKAGE @@ -438,17 +421,17 @@ H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Iterate over the entries for this tag */ - if(H5C__iter_tagged_entries_real(cache, tag, cb, cb_ctx) < 0) + if (H5C__iter_tagged_entries_real(cache, tag, cb, cb_ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") /* Check for iterating over global metadata */ - if(match_global) { + if (match_global) { /* Iterate over the entries for SOHM entries */ - if(H5C__iter_tagged_entries_real(cache, H5AC__SOHM_TAG, cb, cb_ctx) < 0) + if (H5C__iter_tagged_entries_real(cache, H5AC__SOHM_TAG, cb, cb_ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") /* Iterate over the entries for global heap entries */ - if(H5C__iter_tagged_entries_real(cache, H5AC__GLOBALHEAP_TAG, cb, cb_ctx) < 0) + if (H5C__iter_tagged_entries_real(cache, H5AC__GLOBALHEAP_TAG, cb, cb_ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") } /* end if */ @@ -456,7 +439,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__iter_tagged_entries() */ - /*------------------------------------------------------------------------- * * Function: H5C__evict_tagged_entries_cb @@ -474,7 +456,7 @@ static int H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) { H5C_tag_iter_evict_ctx_t *ctx = (H5C_tag_iter_evict_ctx_t *)_ctx; /* Get pointer to iterator context */ - int ret_value = H5_ITER_CONT; /* Return value */ + int ret_value = H5_ITER_CONT; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -484,18 +466,20 @@ H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) HDassert(ctx); /* Attempt to evict entry */ - if(entry->is_protected) + if (entry->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Cannot evict protected entry") - else if(entry->is_dirty) + else if (entry->is_dirty) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Cannot evict dirty entry") - else if(entry->is_pinned) + else if (entry->is_pinned) /* Can't evict at this time, but let's note that we hit a pinned entry and we'll loop back around again (as evicting other entries will hopefully unpin this entry) */ ctx->pinned_entries_need_evicted = TRUE; - else if(!entry->prefetched_dirty) { + else if (!entry->prefetched_dirty) { /* Evict the Entry */ - if(H5C__flush_single_entry(ctx->f, entry, H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + if (H5C__flush_single_entry(ctx->f, entry, + H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Entry eviction failed.") ctx->evicted_entries_last_pass = TRUE; } @@ -506,7 +490,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__evict_tagged_entries_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C_evict_tagged_entries @@ -521,11 +504,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_evict_tagged_entries(H5F_t * f, haddr_t tag, hbool_t match_global) +H5C_evict_tagged_entries(H5F_t *f, haddr_t tag, hbool_t match_global) { - H5C_t *cache; /* Pointer to cache structure */ - H5C_tag_iter_evict_ctx_t ctx; /* Context for iterator callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache; /* Pointer to cache structure */ + H5C_tag_iter_evict_ctx_t ctx; /* Context for iterator callback */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_NOAPI(FAIL) @@ -533,7 +516,7 @@ H5C_evict_tagged_entries(H5F_t * f, haddr_t tag, hbool_t match_global) /* Sanity checks */ HDassert(f); HDassert(f->shared); - cache = f->shared->cache; /* Get cache pointer */ + cache = f->shared->cache; /* Get cache pointer */ HDassert(cache != NULL); HDassert(cache->magic == H5C__H5C_T_MAGIC); @@ -544,15 +527,15 @@ H5C_evict_tagged_entries(H5F_t * f, haddr_t tag, hbool_t match_global) do { /* Reset pinned/evicted tracking flags */ ctx.pinned_entries_need_evicted = FALSE; - ctx.evicted_entries_last_pass = FALSE; - ctx.skipped_pf_dirty_entries = FALSE; + ctx.evicted_entries_last_pass = FALSE; + ctx.skipped_pf_dirty_entries = FALSE; /* Iterate through entries in the cache */ - if(H5C__iter_tagged_entries(cache, tag, match_global, H5C__evict_tagged_entries_cb, &ctx) < 0) + if (H5C__iter_tagged_entries(cache, tag, match_global, H5C__evict_tagged_entries_cb, &ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed") /* Keep doing this until we have stopped evicted entries */ - } while(TRUE == ctx.evicted_entries_last_pass); + } while (TRUE == ctx.evicted_entries_last_pass); /* In most cases, fail if we have finished evicting entries and pinned * entries still need evicted @@ -579,14 +562,13 @@ H5C_evict_tagged_entries(H5F_t * f, haddr_t tag, hbool_t match_global) * Thus we must ignore ctx.pinned_entries_need_evicted if * ctx.skipped_pf_dirty_entries is TRUE. */ - if((!ctx.skipped_pf_dirty_entries) && (ctx.pinned_entries_need_evicted)) + if ((!ctx.skipped_pf_dirty_entries) && (ctx.pinned_entries_need_evicted)) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Pinned entries still need evicted?!") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_evict_tagged_entries() */ - /*------------------------------------------------------------------------- * * Function: H5C__mark_tagged_entries_cb @@ -611,13 +593,12 @@ H5C__mark_tagged_entries_cb(H5C_cache_entry_t *entry, void H5_ATTR_UNUSED *_ctx) /* We only want to set the flush marker on entries that * actually need flushed (i.e., dirty ones) */ - if(entry->is_dirty) + if (entry->is_dirty) entry->flush_marker = TRUE; FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* H5C__mark_tagged_entries_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C__mark_tagged_entries @@ -635,7 +616,7 @@ H5C__mark_tagged_entries_cb(H5C_cache_entry_t *entry, void H5_ATTR_UNUSED *_ctx) static herr_t H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -647,7 +628,7 @@ H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag) /* Iterate through hash table entries, marking those with specified tag, as * well as any major global entries which should always be flushed * when flushing based on tag value */ - if(H5C__iter_tagged_entries(cache, tag, TRUE, H5C__mark_tagged_entries_cb, NULL) < 0) + if (H5C__iter_tagged_entries(cache, tag, TRUE, H5C__mark_tagged_entries_cb, NULL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed") done: @@ -655,7 +636,7 @@ done: } /* H5C__mark_tagged_entries() */ #if H5C_DO_TAGGING_SANITY_CHECKS - + /*------------------------------------------------------------------------- * * Function: H5C_verify_tag @@ -679,10 +660,10 @@ H5C_verify_tag(int id, haddr_t tag) /* Perform some sanity checks on tag value. Certain entry * types require certain tag values, so check that these * constraints are met. */ - if(tag == H5AC__IGNORE_TAG) + if (tag == H5AC__IGNORE_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "cannot ignore a tag while doing verification.") - else if(tag == H5AC__INVALID_TAG) { - if(id != H5AC_PROXY_ENTRY_ID) + else if (tag == H5AC__INVALID_TAG) { + if (id != H5AC_PROXY_ENTRY_ID) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "no metadata tag provided") } /* end else-if */ else { @@ -691,41 +672,42 @@ H5C_verify_tag(int id, haddr_t tag) * constraints are met. */ /* Superblock */ - if((id == H5AC_SUPERBLOCK_ID) || (id == H5AC_DRVRINFO_ID)) { - if(tag != H5AC__SUPERBLOCK_TAG) + if ((id == H5AC_SUPERBLOCK_ID) || (id == H5AC_DRVRINFO_ID)) { + if (tag != H5AC__SUPERBLOCK_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "superblock not tagged with H5AC__SUPERBLOCK_TAG") } /* end if */ else { - if(tag == H5AC__SUPERBLOCK_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__SUPERBLOCK_TAG applied to non-superblock entry") + if (tag == H5AC__SUPERBLOCK_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, + "H5AC__SUPERBLOCK_TAG applied to non-superblock entry") } /* end else */ /* Free Space Manager */ - if(tag == H5AC__FREESPACE_TAG && ((id != H5AC_FSPACE_HDR_ID) && (id != H5AC_FSPACE_SINFO_ID))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__FREESPACE_TAG applied to non-freespace entry") + if (tag == H5AC__FREESPACE_TAG && ((id != H5AC_FSPACE_HDR_ID) && (id != H5AC_FSPACE_SINFO_ID))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__FREESPACE_TAG applied to non-freespace entry") /* SOHM */ - if((id == H5AC_SOHM_TABLE_ID) || (id == H5AC_SOHM_LIST_ID)) - if(tag != H5AC__SOHM_TAG) + if ((id == H5AC_SOHM_TABLE_ID) || (id == H5AC_SOHM_LIST_ID)) + if (tag != H5AC__SOHM_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "sohm entry not tagged with H5AC__SOHM_TAG") /* Global Heap */ - if(id == H5AC_GHEAP_ID) { - if(tag != H5AC__GLOBALHEAP_TAG) + if (id == H5AC_GHEAP_ID) { + if (tag != H5AC__GLOBALHEAP_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "global heap not tagged with H5AC__GLOBALHEAP_TAG") } /* end if */ else { - if(tag == H5AC__GLOBALHEAP_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__GLOBALHEAP_TAG applied to non-globalheap entry") + if (tag == H5AC__GLOBALHEAP_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, + "H5AC__GLOBALHEAP_TAG applied to non-globalheap entry") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_verify_tag */ #endif - /*------------------------------------------------------------------------- * * Function: H5C_flush_tagged_entries @@ -743,8 +725,8 @@ herr_t H5C_flush_tagged_entries(H5F_t *f, haddr_t tag) { /* Variable Declarations */ - H5C_t *cache_ptr = NULL; - herr_t ret_value = SUCCEED; + H5C_t *cache_ptr = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -756,18 +738,17 @@ H5C_flush_tagged_entries(H5F_t *f, haddr_t tag) cache_ptr = f->shared->cache; /* Mark all entries with specified tag */ - if(H5C__mark_tagged_entries(cache_ptr, tag) < 0) + if (H5C__mark_tagged_entries(cache_ptr, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't mark tagged entries") /* Flush all marked entries */ - if(H5C__flush_marked_entries(f) < 0) + if (H5C__flush_marked_entries(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush marked entries") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_tagged_entries */ - /*------------------------------------------------------------------------- * * Function: H5C_retag_entries @@ -786,8 +767,8 @@ done: herr_t H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) { - H5C_tag_info_t *tag_info; /* Points to a tag info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_NOAPI(FAIL) @@ -796,12 +777,12 @@ H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) HDassert(cache); /* Remove tag info from tag list */ - if(NULL != (tag_info = (H5C_tag_info_t *)H5SL_remove(cache->tag_list, &src_tag))) { + if (NULL != (tag_info = (H5C_tag_info_t *)H5SL_remove(cache->tag_list, &src_tag))) { /* Change to new tag */ tag_info->tag = dest_tag; /* Re-insert tag info into skip list */ - if(H5SL_insert(cache->tag_list, tag_info, &(tag_info->tag)) < 0) + if (H5SL_insert(cache->tag_list, tag_info, &(tag_info->tag)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert tag info in skip list") } /* end if */ @@ -809,7 +790,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_retag_entries() */ - /*------------------------------------------------------------------------- * * Function: H5C__expunge_tag_type_metadata_cb @@ -828,7 +808,7 @@ static int H5C__expunge_tag_type_metadata_cb(H5C_cache_entry_t *entry, void *_ctx) { H5C_tag_iter_ettm_ctx_t *ctx = (H5C_tag_iter_ettm_ctx_t *)_ctx; /* Get pointer to iterator context */ - int ret_value = H5_ITER_CONT; /* Return value */ + int ret_value = H5_ITER_CONT; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -838,15 +818,14 @@ H5C__expunge_tag_type_metadata_cb(H5C_cache_entry_t *entry, void *_ctx) HDassert(ctx); /* Found one with the same tag and type id */ - if(entry->type->id == ctx->type_id || !ctx->type_match) - if(H5C_expunge_entry(ctx->f, entry->type, entry->addr, ctx->flags) < 0) + if (entry->type->id == ctx->type_id || !ctx->type_match) + if (H5C_expunge_entry(ctx->f, entry->type, entry->addr, ctx->flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, H5_ITER_ERROR, "can't expunge entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__expunge_tag_type_metadata_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C_expunge_tag_type_metadata @@ -864,9 +843,9 @@ done: herr_t H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags, hbool_t type_match) { - H5C_t *cache; /* Pointer to cache structure */ - H5C_tag_iter_ettm_ctx_t ctx; /* Context for iterator callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache; /* Pointer to cache structure */ + H5C_tag_iter_ettm_ctx_t ctx; /* Context for iterator callback */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_NOAPI(FAIL) @@ -874,25 +853,24 @@ H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags /* Sanity checks */ HDassert(f); HDassert(f->shared); - cache = f->shared->cache; /* Get cache pointer */ + cache = f->shared->cache; /* Get cache pointer */ HDassert(cache != NULL); HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Construct context for iterator callbacks */ - ctx.f = f; - ctx.type_id = type_id; - ctx.flags = flags; + ctx.f = f; + ctx.type_id = type_id; + ctx.flags = flags; ctx.type_match = type_match; /* Iterate through hash table entries, expunge those with specified tag and type id */ - if(H5C__iter_tagged_entries(cache, tag, FALSE, H5C__expunge_tag_type_metadata_cb, &ctx) < 0) + if (H5C__iter_tagged_entries(cache, tag, FALSE, H5C__expunge_tag_type_metadata_cb, &ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_expunge_tag_type_metadata() */ - /*------------------------------------------------------------------------- * * Function: H5C_get_tag() @@ -909,7 +887,7 @@ done: herr_t H5C_get_tag(const void *thing, haddr_t *tag /*OUT*/) { - const H5C_cache_entry_t *entry = (const H5C_cache_entry_t *)thing; /* Pointer to cache entry */ + const H5C_cache_entry_t *entry = (const H5C_cache_entry_t *)thing; /* Pointer to cache entry */ FUNC_ENTER_NOAPI_NOERR @@ -922,4 +900,3 @@ H5C_get_tag(const void *thing, haddr_t *tag /*OUT*/) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_get_tag() */ - diff --git a/src/H5Ctest.c b/src/H5Ctest.c index b549da5..72aed27 100644 --- a/src/H5Ctest.c +++ b/src/H5Ctest.c @@ -27,58 +27,50 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5C_TESTING /*suppress warning about H5C testing funcs*/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5C_TESTING /*suppress warning about H5C testing funcs*/ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ #include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Typedef for tagged entry iterator callback context - verify cork tag */ typedef struct { - hbool_t status; /* Corked status */ + hbool_t status; /* Corked status */ } H5C_tag_iter_vct_ctx_t; - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5C__verify_cork_tag_test_cb * @@ -95,8 +87,8 @@ static int H5C__verify_cork_tag_test_cb(H5C_cache_entry_t *entry, void *_ctx) { H5C_tag_iter_vct_ctx_t *ctx = (H5C_tag_iter_vct_ctx_t *)_ctx; /* Get pointer to iterator context */ - hbool_t is_corked; /* Corked status for entry */ - int ret_value = H5_ITER_CONT; /* Return value */ + hbool_t is_corked; /* Corked status for entry */ + int ret_value = H5_ITER_CONT; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -109,14 +101,13 @@ H5C__verify_cork_tag_test_cb(H5C_cache_entry_t *entry, void *_ctx) is_corked = entry->tag_info ? entry->tag_info->corked : FALSE; /* Verify corked status for entry */ - if(is_corked != ctx->status) + if (is_corked != ctx->status) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, H5_ITER_ERROR, "bad cork status") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__verify_cork_tag_test_cb() */ - /*------------------------------------------------------------------------- * Function: H5C__verify_cork_tag_test * @@ -133,22 +124,22 @@ done: herr_t H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status) { - H5F_t * f; /* File Pointer */ - H5C_t * cache; /* Cache Pointer */ - H5C_tag_iter_vct_ctx_t ctx; /* Context for iterator callback */ - haddr_t tag; /* Tagged address */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * f; /* File Pointer */ + H5C_t * cache; /* Cache Pointer */ + H5C_tag_iter_vct_ctx_t ctx; /* Context for iterator callback */ + haddr_t tag; /* Tagged address */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_PACKAGE /* Get file pointer */ - if(NULL == (f = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) + if (NULL == (f = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Convert token to address */ tag = HADDR_UNDEF; - if(H5VL_native_token_to_addr(f, H5I_FILE, tag_token, &tag) < 0) + if (H5VL_native_token_to_addr(f, H5I_FILE, tag_token, &tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't get address for token") /* Get cache pointer */ @@ -158,35 +149,34 @@ H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status) ctx.status = status; /* Iterate through tagged entries in the cache */ - if(H5C__iter_tagged_entries(cache, tag, FALSE, H5C__verify_cork_tag_test_cb, &ctx) < 0) + if (H5C__iter_tagged_entries(cache, tag, FALSE, H5C__verify_cork_tag_test_cb, &ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__verify_cork_tag_test() */ - /*------------------------------------------------------------------------- * Function: H5C_set_curr_io_type_splitable() * - * Purpose: To test the meta data entry splitting capability in the page + * Purpose: To test the meta data entry splitting capability in the page * buffer (needed to deal with H5FA and H5EA's unfortunate - * design choice of sub-allocating multiple metadata entries + * design choice of sub-allocating multiple metadata entries * out of a single file space allocation), we must be able - * to configure the metadata cache to report that the + * to configure the metadata cache to report that the * current I/O request is for such an entry. * - * To do this, we must set cache_ptr->curr_io_type to - * point to the instance of H5C_class_t with one such + * To do this, we must set cache_ptr->curr_io_type to + * point to the instance of H5C_class_t with one such * client. * * This function does this by setting cache_ptr->curr_io_type - * to H5AC_EARRAY_DBLK_PAGE if set_splitable is TRUE, and to + * to H5AC_EARRAY_DBLK_PAGE if set_splitable is TRUE, and to * NULL otherwise. * * Needless to say, this is purely a testing function, and * should not be called otherwise. - * + * * Return: void * * Programmer: John Mainzer @@ -198,24 +188,22 @@ done: */ void -H5C_set_curr_io_type_splitable(H5C_t * cache_ptr, hbool_t set_splitable) +H5C_set_curr_io_type_splitable(H5C_t *cache_ptr, hbool_t set_splitable) { FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if ( set_splitable ) { + if (set_splitable) { cache_ptr->curr_io_type = H5AC_EARRAY_DBLK_PAGE; - - } else { + } + else { cache_ptr->curr_io_type = NULL; } - FUNC_LEAVE_NOAPI_VOID } /* H5C_set_curr_io_type_splitable() */ - diff --git a/src/H5D.c b/src/H5D.c index 3428d77..f342499 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -15,38 +15,33 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -54,7 +49,6 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -62,13 +56,10 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Dcreate2 * @@ -96,37 +87,36 @@ H5FL_BLK_EXTERN(type_conv); *------------------------------------------------------------------------- */ hid_t -H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, - hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) +H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, + hid_t dapl_id) { - void *dset = NULL; /* New dataset's info */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * dset = NULL; /* New dataset's info */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE7("i", "i*siiiii", loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); /* Check arguments */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Get link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") /* Get dataset creation property list */ - if(H5P_DEFAULT == dcpl_id) + if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "dcpl_id is not a dataset create property list ID") + else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, + "dcpl_id is not a dataset create property list ID") /* Set the DCPL for the API context */ H5CX_set_dcpl(dcpl_id); @@ -135,34 +125,34 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Create the dataset */ - if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, lcpl_id, type_id, space_id, dcpl_id, + dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an ID for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: - if(H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate2() */ - /*------------------------------------------------------------------------- * Function: H5Dcreate_anon * @@ -196,33 +186,31 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, - hid_t dapl_id) +H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - void *dset = NULL; /* dset object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * dset = NULL; /* dset object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "iiiii", loc_id, type_id, space_id, dcpl_id, dapl_id); /* Check arguments */ - if(H5P_DEFAULT == dcpl_id) + if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") /* Set the DCPL for the API context */ H5CX_set_dcpl(dcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ @@ -230,23 +218,24 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, loc_params.obj_type = H5I_get_type(loc_id); /* Create the dataset */ - if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, type_id, space_id, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == + (dset = H5VL_dataset_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, type_id, space_id, + dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate_anon() */ - /*------------------------------------------------------------------------- * Function: H5Dopen2 * @@ -265,49 +254,49 @@ done: hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) { - void *dset = NULL; /* dset object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * dset = NULL; /* dset object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, dapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set the location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Open the dataset */ - if(NULL == (dset = H5VL_dataset_open(vol_obj, &loc_params, name, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (dset = H5VL_dataset_open(vol_obj, &loc_params, name, dapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Register an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: - if(H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dopen2() */ - /*------------------------------------------------------------------------- * Function: H5Dclose * @@ -322,26 +311,25 @@ done: herr_t H5Dclose(hid_t dset_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(H5I_DATASET != H5I_get_type(dset_id)) + if (H5I_DATASET != H5I_get_type(dset_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset ID") /* Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref_always_close(dset_id) < 0) + if (H5I_dec_app_ref_always_close(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID") done: FUNC_LEAVE_API(ret_value) } /* end H5Dclose() */ - /*------------------------------------------------------------------------- * Function: H5Dget_space * @@ -358,25 +346,25 @@ done: hid_t H5Dget_space(hid_t dset_id) { - H5VL_object_t *vol_obj = NULL; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataspace */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_space() */ - /*------------------------------------------------------------------------- * Function: H5Dget_space_status * @@ -389,25 +377,25 @@ done: herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) { - H5VL_object_t *vol_obj = NULL; /* Dataset structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Ds", dset_id, allocation); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") /* Get dataspace status */ - if((ret_value = H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE_STATUS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, allocation)) < 0) + if ((ret_value = H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE_STATUS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, allocation)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get space status") done: FUNC_LEAVE_API(ret_value) } /* H5Dget_space_status() */ - /*------------------------------------------------------------------------- * Function: H5Dget_type * @@ -424,25 +412,25 @@ done: hid_t H5Dget_type(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the datatype */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_type() */ - /*------------------------------------------------------------------------- * Function: H5Dget_create_plist * @@ -462,25 +450,25 @@ done: hid_t H5Dget_create_plist(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataset creation property list */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset creation properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Dget_access_plist * @@ -517,25 +505,25 @@ done: hid_t H5Dget_access_plist(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataset access property list */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset access properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_access_plist() */ - /*------------------------------------------------------------------------- * Function: H5Dget_storage_size * @@ -554,25 +542,25 @@ done: hsize_t H5Dget_storage_size(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - hsize_t ret_value = 0; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier") /* Get the storage size */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "unable to get storage size") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_storage_size() */ - /*------------------------------------------------------------------------- * Function: H5Dget_offset * @@ -587,25 +575,25 @@ done: haddr_t H5Dget_offset(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_API(HADDR_UNDEF) H5TRACE1("a", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier") /* Get the offset */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_OFFSET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_OFFSET, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, HADDR_UNDEF, "unable to get offset") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_offset() */ - /*------------------------------------------------------------------------- * Function: H5Diterate * @@ -666,42 +654,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, - void *operator_data) +H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, void *operator_data) { - H5T_t *type; /* Datatype */ - H5S_t *space; /* Dataspace for iteration */ - H5S_sel_iter_op_t dset_op; /* Operator for iteration */ - herr_t ret_value; /* Return value */ + H5T_t * type; /* Datatype */ + H5S_t * space; /* Dataspace for iteration */ + H5S_sel_iter_op_t dset_op; /* Operator for iteration */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*xiix*x", buf, type_id, space_id, op, operator_data); /* Check args */ - if(NULL == op) + if (NULL == op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator") - if(NULL == buf) + if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") - if(H5I_DATATYPE != H5I_get_type(type_id)) + if (H5I_DATATYPE != H5I_get_type(type_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") - dset_op.op_type = H5S_SEL_ITER_OP_APP; - dset_op.u.app_op.op = op; + dset_op.op_type = H5S_SEL_ITER_OP_APP; + dset_op.u.app_op.op = op; dset_op.u.app_op.type_id = type_id; ret_value = H5S_select_iterate(buf, type, space, &dset_op, operator_data); done: FUNC_LEAVE_API(ret_value) -} /* end H5Diterate() */ +} /* end H5Diterate() */ - /*------------------------------------------------------------------------- * Function: H5Dvlen_get_buf_size * @@ -721,35 +707,37 @@ done: herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - hbool_t supported; /* Whether 'get vlen buf size' operation is supported by VOL connector */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + hbool_t supported; /* Whether 'get vlen buf size' operation is supported by VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iii*h", dataset_id, type_id, space_id, size); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(dataset_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(dataset_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - if(H5I_DATATYPE != H5I_get_type(type_id)) + if (H5I_DATATYPE != H5I_get_type(type_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype identifier") - if(H5I_DATASPACE != H5I_get_type(space_id)) + if (H5I_DATASPACE != H5I_get_type(space_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace identifier") - if(size == NULL) + if (size == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid 'size' pointer") /* Check if the 'get_vlen_buf_size' callback is supported */ supported = FALSE; - if(H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE, &supported) < 0) + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE, + &supported) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'get vlen buf size' operation") - if(supported) { + if (supported) { /* Make the 'get_vlen_buf_size' callback */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id, space_id, size) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, type_id, space_id, size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get vlen buf size") } /* end if */ else { /* Perform a generic operation that will work with all VOL connectors */ - if(H5D__vlen_get_buf_size_gen(vol_obj, type_id, space_id, size) < 0) + if (H5D__vlen_get_buf_size_gen(vol_obj, type_id, space_id, size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get vlen buf size") } /* end else */ @@ -757,7 +745,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Dvlen_get_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5Dset_extent * @@ -771,31 +758,31 @@ done: herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") - if(!size) + if (!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size array cannot be NULL") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Set the extent */ - if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, size)) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, size)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set dataset extent") done: FUNC_LEAVE_API(ret_value) } /* end H5Dset_extent() */ - /*------------------------------------------------------------------------- * Function: H5Dflush * @@ -808,32 +795,32 @@ done: herr_t H5Dflush(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Flush dataset information cached in memory * XXX: Note that we need to pass the ID to the VOL since the H5F_flush_cb_t * callback needs it and that's in the public API. */ - if((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_id)) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_FLUSH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") done: FUNC_LEAVE_API(ret_value) } /* H5Dflush */ - /*------------------------------------------------------------------------- * Function: H5Drefresh * @@ -846,29 +833,29 @@ done: herr_t H5Drefresh(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Refresh the dataset object */ - if((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_id)) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_REFRESH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") done: FUNC_LEAVE_API(ret_value) } /* end H5Drefresh() */ - /*------------------------------------------------------------------------- * Function: H5Dformat_convert (Internal) * @@ -889,29 +876,29 @@ done: herr_t H5Dformat_convert(hid_t dset_id) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Convert the dataset */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_FORMAT_CONVERT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_FORMAT_CONVERT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_INTERNAL, FAIL, "can't convert dataset format") done: FUNC_LEAVE_API(ret_value) } /* H5Dformat_convert */ - /*------------------------------------------------------------------------- * Function: H5Dget_chunk_index_type (Internal) * @@ -927,27 +914,27 @@ done: herr_t H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Dk", dset_id, idx_type); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") - if(NULL == idx_type) + if (NULL == idx_type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_type parameter cannot be NULL") /* Get the chunk indexing type */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, idx_type) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, idx_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk index type") done: FUNC_LEAVE_API(ret_value) } /* H5Dget_chunk_index_type() */ - /*------------------------------------------------------------------------- * Function: H5Dget_chunk_storage_size * @@ -966,29 +953,29 @@ done: herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_nbytes) { - H5VL_object_t *vol_obj; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*h*h", dset_id, offset, chunk_nbytes); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") - if(NULL == offset) + if (NULL == offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset parameter cannot be NULL") - if(NULL == chunk_nbytes) + if (NULL == chunk_nbytes) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "chunk_nbytes parameter cannot be NULL") /* Get the dataset creation property list */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, offset, chunk_nbytes) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, offset, chunk_nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") done: FUNC_LEAVE_API(ret_value); } /* H5Dget_chunk_storage_size() */ - /*------------------------------------------------------------------------- * Function: H5Dget_num_chunks * @@ -1013,27 +1000,27 @@ done: herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks) { - H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*h", dset_id, fspace_id, nchunks); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - if(NULL == nchunks) + if (NULL == nchunks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)") /* Get the number of written chunks */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_NUM_CHUNKS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fspace_id, nchunks) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_NUM_CHUNKS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fspace_id, nchunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get number of chunks") done: FUNC_LEAVE_API(ret_value); } /* H5Dget_num_chunks() */ - /*------------------------------------------------------------------------- * Function: H5Dget_chunk_info * @@ -1057,10 +1044,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) +H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *offset, unsigned *filter_mask, + haddr_t *addr, hsize_t *size) { - H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ - hsize_t nchunks = 0; + H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ + hsize_t nchunks = 0; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -1068,28 +1056,30 @@ H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *of filter_mask, addr, size); /* Check arguments */ - if(NULL == offset && NULL == filter_mask && NULL == addr && NULL == size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid arguments, must have at least one non-null output argument") - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == offset && NULL == filter_mask && NULL == addr && NULL == size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid arguments, must have at least one non-null output argument") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") /* Get the number of written chunks to check range */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_NUM_CHUNKS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fspace_id, &nchunks) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_NUM_CHUNKS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fspace_id, &nchunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get number of chunks") /* Check range for chunk index */ - if(chk_index >= nchunks) + if (chk_index >= nchunks) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk index is out of range") /* Call private function to get the chunk info given the chunk's index */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fspace_id, chk_index, offset, filter_mask, addr, size) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fspace_id, chk_index, offset, filter_mask, addr, size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get chunk info by index") done: FUNC_LEAVE_API(ret_value); } /* H5Dget_chunk_info() */ - /*------------------------------------------------------------------------- * Function: H5Dget_chunk_info_by_coord * @@ -1112,24 +1102,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) +H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filter_mask, haddr_t *addr, + hsize_t *size) { - H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*h*Iu*a*h", dset_id, offset, filter_mask, addr, size); /* Check arguments */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - if(NULL == filter_mask && NULL == addr && NULL == size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid arguments, must have at least one non-null output argument") - if(NULL == offset) + if (NULL == filter_mask && NULL == addr && NULL == size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid arguments, must have at least one non-null output argument") + if (NULL == offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)") /* Call private function to get the chunk info given the chunk's index */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, offset, filter_mask, addr, size) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, offset, filter_mask, addr, size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get chunk info by its logical coordinates") done: diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 7741e99..78d4c24 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -24,31 +24,29 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bprivate.h" /* B-link trees */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector and array functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Bprivate.h" /* B-link trees */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -68,82 +66,72 @@ * The chunk's file address is part of the B-tree and not part of the key. */ typedef struct H5D_btree_key_t { - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*logical offset to start*/ - uint32_t nbytes; /*size of stored data */ - unsigned filter_mask; /*excluded filters */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*logical offset to start*/ + uint32_t nbytes; /*size of stored data */ + unsigned filter_mask; /*excluded filters */ } H5D_btree_key_t; /* B-tree callback info for iteration over chunks */ typedef struct H5D_btree_it_ud_t { - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ - H5D_chunk_cb_func_t cb; /* Chunk callback routine */ - void *udata; /* User data for chunk callback routine */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + H5D_chunk_cb_func_t cb; /* Chunk callback routine */ + void * udata; /* User data for chunk callback routine */ } H5D_btree_it_ud_t; /* B-tree callback info for debugging */ typedef struct H5D_btree_dbg_t { - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ - unsigned ndims; /* Number of dimensions */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + unsigned ndims; /* Number of dimensions */ } H5D_btree_dbg_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t H5D__btree_shared_free(void *_shared); static herr_t H5D__btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store, - const H5O_layout_chunk_t *layout); + const H5O_layout_chunk_t *layout); /* B-tree iterator callbacks */ -static int H5D__btree_idx_iterate_cb(H5F_t *f, const void *left_key, - haddr_t addr, const void *right_key, void *_udata); +static int H5D__btree_idx_iterate_cb(H5F_t *f, const void *left_key, haddr_t addr, const void *right_key, + void *_udata); /* B-tree callbacks */ -static H5UC_t *H5D__btree_get_shared(const H5F_t *f, const void *_udata); -static herr_t H5D__btree_new_node(H5F_t *f, H5B_ins_t, void *_lt_key, - void *_udata, void *_rt_key, haddr_t *addr_p /*out*/); -static int H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key); -static int H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key); -static htri_t H5D__btree_found(H5F_t *f, haddr_t addr, - const void *_lt_key, void *_udata); -static H5B_ins_t H5D__btree_insert(H5F_t *f, haddr_t addr, - void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, - void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node/*out*/); -static H5B_ins_t H5D__btree_remove( H5F_t *f, haddr_t addr, void *_lt_key, - hbool_t *lt_key_changed, void *_udata, void *_rt_key, hbool_t *rt_key_changed); -static herr_t H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, - void *_key); -static herr_t H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, - const void *_key); -static herr_t H5D__btree_debug_key(FILE *stream, int indent, int fwidth, - const void *key, const void *udata); +static H5UC_t * H5D__btree_get_shared(const H5F_t *f, const void *_udata); +static herr_t H5D__btree_new_node(H5F_t *f, H5B_ins_t, void *_lt_key, void *_udata, void *_rt_key, + haddr_t *addr_p /*out*/); +static int H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key); +static int H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key); +static htri_t H5D__btree_found(H5F_t *f, haddr_t addr, const void *_lt_key, void *_udata); +static H5B_ins_t H5D__btree_insert(H5F_t *f, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, + void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, + haddr_t *new_node /*out*/); +static H5B_ins_t H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, + void *_udata, void *_rt_key, hbool_t *rt_key_changed); +static herr_t H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key); +static herr_t H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key); +static herr_t H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *key, const void *udata); /* Chunked layout indexing callbacks */ -static herr_t H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__btree_idx_dump(const H5O_storage_chunk_t *storage, - FILE *stream); -static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info); - +static herr_t H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst); +static herr_t H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__btree_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info); /*********************/ /* Package Variables */ @@ -151,50 +139,48 @@ static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info); /* v1 B-tree indexed chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_BTREE[1] = {{ - FALSE, /* v1 B-tree indices does not support SWMR access */ - H5D__btree_idx_init, /* insert */ - H5D__btree_idx_create, /* create */ - H5D__btree_idx_is_space_alloc, /* is_space_alloc */ - H5D__btree_idx_insert, /* insert */ - H5D__btree_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__btree_idx_iterate, /* iterate */ - H5D__btree_idx_remove, /* remove */ - H5D__btree_idx_delete, /* delete */ - H5D__btree_idx_copy_setup, /* copy_setup */ - H5D__btree_idx_copy_shutdown, /* copy_shutdown */ - H5D__btree_idx_size, /* size */ - H5D__btree_idx_reset, /* reset */ - H5D__btree_idx_dump, /* dump */ - H5D__btree_idx_dest, /* destroy */ - NULL /* close */ + FALSE, /* v1 B-tree indices does not support SWMR access */ + H5D__btree_idx_init, /* insert */ + H5D__btree_idx_create, /* create */ + H5D__btree_idx_is_space_alloc, /* is_space_alloc */ + H5D__btree_idx_insert, /* insert */ + H5D__btree_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__btree_idx_iterate, /* iterate */ + H5D__btree_idx_remove, /* remove */ + H5D__btree_idx_delete, /* delete */ + H5D__btree_idx_copy_setup, /* copy_setup */ + H5D__btree_idx_copy_shutdown, /* copy_shutdown */ + H5D__btree_idx_size, /* size */ + H5D__btree_idx_reset, /* reset */ + H5D__btree_idx_dump, /* dump */ + H5D__btree_idx_dest, /* destroy */ + NULL /* close */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ /* inherits B-tree like properties from H5B */ H5B_class_t H5B_BTREE[1] = {{ - H5B_CHUNK_ID, /*id */ - sizeof(H5D_btree_key_t), /*sizeof_nkey */ - H5D__btree_get_shared, /*get_shared */ - H5D__btree_new_node, /*new */ - H5D__btree_cmp2, /*cmp2 */ - H5D__btree_cmp3, /*cmp3 */ - H5D__btree_found, /*found */ - H5D__btree_insert, /*insert */ - FALSE, /*follow min branch? */ - FALSE, /*follow max branch? */ - H5B_LEFT, /*critical key */ - H5D__btree_remove, /*remove */ - H5D__btree_decode_key, /*decode */ - H5D__btree_encode_key, /*encode */ - H5D__btree_debug_key /*debug */ + H5B_CHUNK_ID, /*id */ + sizeof(H5D_btree_key_t), /*sizeof_nkey */ + H5D__btree_get_shared, /*get_shared */ + H5D__btree_new_node, /*new */ + H5D__btree_cmp2, /*cmp2 */ + H5D__btree_cmp3, /*cmp3 */ + H5D__btree_found, /*found */ + H5D__btree_insert, /*insert */ + FALSE, /*follow min branch? */ + FALSE, /*follow max branch? */ + H5B_LEFT, /*critical key */ + H5D__btree_remove, /*remove */ + H5D__btree_decode_key, /*decode */ + H5D__btree_encode_key, /*encode */ + H5D__btree_debug_key /*debug */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -202,8 +188,6 @@ H5B_class_t H5B_BTREE[1] = {{ /* Declare a free list to manage H5O_layout_chunk_t objects */ H5FL_DEFINE_STATIC(H5O_layout_chunk_t); - - /*------------------------------------------------------------------------- * Function: H5D__btree_get_shared * @@ -221,7 +205,7 @@ H5FL_DEFINE_STATIC(H5O_layout_chunk_t); static H5UC_t * H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata) { - const H5D_chunk_common_ud_t *udata = (const H5D_chunk_common_ud_t *) _udata; + const H5D_chunk_common_ud_t *udata = (const H5D_chunk_common_ud_t *)_udata; FUNC_ENTER_STATIC_NOERR @@ -234,7 +218,6 @@ H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata) FUNC_LEAVE_NOAPI(udata->storage->u.btree.shared) } /* end H5D__btree_get_shared() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_new_node * @@ -254,14 +237,14 @@ H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, void *_udata, - void *_rt_key, haddr_t *addr_p/*out*/) +H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, void *_udata, void *_rt_key, + haddr_t *addr_p /*out*/) { - H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key; - H5D_btree_key_t *rt_key = (H5D_btree_key_t *) _rt_key; - H5D_chunk_ud_t *udata = (H5D_chunk_ud_t *) _udata; - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; + H5D_btree_key_t *rt_key = (H5D_btree_key_t *)_rt_key; + H5D_chunk_ud_t * udata = (H5D_chunk_ud_t *)_udata; + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -284,26 +267,25 @@ H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, */ H5_CHECKED_ASSIGN(lt_key->nbytes, uint32_t, udata->chunk_block.length, hsize_t); lt_key->filter_mask = udata->filter_mask; - for(u = 0; u < udata->common.layout->ndims; u++) + for (u = 0; u < udata->common.layout->ndims; u++) lt_key->scaled[u] = udata->common.scaled[u]; /* * The right key might already be present. If not, then add a zero-width * chunk. */ - if(H5B_INS_LEFT != op) { - rt_key->nbytes = 0; + if (H5B_INS_LEFT != op) { + rt_key->nbytes = 0; rt_key->filter_mask = 0; - for(u = 0; u < udata->common.layout->ndims; u++) { + for (u = 0; u < udata->common.layout->ndims; u++) { HDassert(udata->common.scaled[u] + 1 > udata->common.scaled[u]); rt_key->scaled[u] = udata->common.scaled[u] + 1; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_new_node() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_cmp2 * @@ -326,10 +308,10 @@ H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, static int H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key) { - H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key; - H5D_btree_key_t *rt_key = (H5D_btree_key_t *) _rt_key; - H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *) _udata; - int ret_value = -1; /* Return value */ + H5D_btree_key_t * lt_key = (H5D_btree_key_t *)_lt_key; + H5D_btree_key_t * rt_key = (H5D_btree_key_t *)_rt_key; + H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *)_udata; + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -344,7 +326,6 @@ H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_cmp2() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_cmp3 * @@ -375,10 +356,10 @@ H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key) static int H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key) { - H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key; - H5D_btree_key_t *rt_key = (H5D_btree_key_t *) _rt_key; - H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *) _udata; - int ret_value = 0; + H5D_btree_key_t * lt_key = (H5D_btree_key_t *)_lt_key; + H5D_btree_key_t * rt_key = (H5D_btree_key_t *)_rt_key; + H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *)_udata; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR @@ -393,26 +374,24 @@ H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key) /* slightly odd way the library initializes the right-most node in the */ /* indexed storage B-tree... */ /* (Dump the B-tree with h5debug to look at it) -QAK */ - if(udata->layout->ndims == 2) { - if(udata->scaled[0] > rt_key->scaled[0]) + if (udata->layout->ndims == 2) { + if (udata->scaled[0] > rt_key->scaled[0]) ret_value = 1; - else if(udata->scaled[0] == rt_key->scaled[0] && - udata->scaled[1] >= rt_key->scaled[1]) + else if (udata->scaled[0] == rt_key->scaled[0] && udata->scaled[1] >= rt_key->scaled[1]) ret_value = 1; - else if(udata->scaled[0] < lt_key->scaled[0]) + else if (udata->scaled[0] < lt_key->scaled[0]) ret_value = (-1); } /* end if */ else { - if(H5VM_vector_ge_u(udata->layout->ndims, udata->scaled, rt_key->scaled)) + if (H5VM_vector_ge_u(udata->layout->ndims, udata->scaled, rt_key->scaled)) ret_value = 1; - else if(H5VM_vector_lt_u(udata->layout->ndims, udata->scaled, lt_key->scaled)) + else if (H5VM_vector_lt_u(udata->layout->ndims, udata->scaled, lt_key->scaled)) ret_value = (-1); } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_cmp3() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_found * @@ -438,13 +417,12 @@ H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key) *------------------------------------------------------------------------- */ static htri_t -H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, haddr_t addr, const void *_lt_key, - void *_udata) +H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, haddr_t addr, const void *_lt_key, void *_udata) { - H5D_chunk_ud_t *udata = (H5D_chunk_ud_t *) _udata; - const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *) _lt_key; - unsigned u; - htri_t ret_value = TRUE; /* Return value */ + H5D_chunk_ud_t * udata = (H5D_chunk_ud_t *)_udata; + const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *)_lt_key; + unsigned u; + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -455,21 +433,20 @@ H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, haddr_t addr, const void *_lt_key, HDassert(lt_key); /* Is this *really* the requested chunk? */ - for(u = 0; u < udata->common.layout->ndims; u++) - if(udata->common.scaled[u] >= (lt_key->scaled[u] + 1)) + for (u = 0; u < udata->common.layout->ndims; u++) + if (udata->common.scaled[u] >= (lt_key->scaled[u] + 1)) HGOTO_DONE(FALSE) /* Initialize return values */ HDassert(lt_key->nbytes > 0); udata->chunk_block.offset = addr; udata->chunk_block.length = lt_key->nbytes; - udata->filter_mask = lt_key->filter_mask; + udata->filter_mask = lt_key->filter_mask; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_found() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_disjoint * @@ -488,8 +465,8 @@ done: static hbool_t H5D__chunk_disjoint(unsigned n, const hsize_t *scaled1, const hsize_t *scaled2) { - unsigned u; /* Local index variable */ - hbool_t ret_value = FALSE; /* Return value */ + unsigned u; /* Local index variable */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -499,15 +476,14 @@ H5D__chunk_disjoint(unsigned n, const hsize_t *scaled1, const hsize_t *scaled2) HDassert(scaled2); /* Loop over two chunks, detecting disjointness and getting out quickly */ - for(u = 0; u < n; u++) - if((scaled1[u] + 1) <= scaled2[u] || (scaled2[u] + 1) <= scaled1[u]) + for (u = 0; u < n; u++) + if ((scaled1[u] + 1) <= scaled2[u] || (scaled2[u] + 1) <= scaled1[u]) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_disjoint() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_insert * @@ -537,17 +513,17 @@ done: *------------------------------------------------------------------------- */ static H5B_ins_t -H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED addr, void *_lt_key, hbool_t *lt_key_changed, - void *_md_key, void *_udata, void *_rt_key, hbool_t H5_ATTR_UNUSED *rt_key_changed, - haddr_t *new_node_p/*out*/) +H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED addr, void *_lt_key, + hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, + hbool_t H5_ATTR_UNUSED *rt_key_changed, haddr_t *new_node_p /*out*/) { - H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key; - H5D_btree_key_t *md_key = (H5D_btree_key_t *) _md_key; - H5D_btree_key_t *rt_key = (H5D_btree_key_t *) _rt_key; - H5D_chunk_ud_t *udata = (H5D_chunk_ud_t *) _udata; - int cmp; - unsigned u; - H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ + H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; + H5D_btree_key_t *md_key = (H5D_btree_key_t *)_md_key; + H5D_btree_key_t *rt_key = (H5D_btree_key_t *)_rt_key; + H5D_chunk_ud_t * udata = (H5D_chunk_ud_t *)_udata; + int cmp; + unsigned u; + H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ FUNC_ENTER_STATIC @@ -564,48 +540,47 @@ H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED cmp = H5D__btree_cmp3(lt_key, udata, rt_key); HDassert(cmp <= 0); - if(cmp < 0) { + if (cmp < 0) { /* Negative indices not supported yet */ HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error") - - } else if(H5VM_vector_eq_u(udata->common.layout->ndims, - udata->common.scaled, lt_key->scaled) && lt_key->nbytes > 0) { + } + else if (H5VM_vector_eq_u(udata->common.layout->ndims, udata->common.scaled, lt_key->scaled) && + lt_key->nbytes > 0) { /* * Already exists. If the new size is not the same as the old size * then we should reallocate storage. */ - if(lt_key->nbytes != udata->chunk_block.length) { - /* Set node's address (already re-allocated by main chunk routines) */ - HDassert(H5F_addr_defined(udata->chunk_block.offset)); + if (lt_key->nbytes != udata->chunk_block.length) { + /* Set node's address (already re-allocated by main chunk routines) */ + HDassert(H5F_addr_defined(udata->chunk_block.offset)); *new_node_p = udata->chunk_block.offset; H5_CHECKED_ASSIGN(lt_key->nbytes, uint32_t, udata->chunk_block.length, hsize_t); lt_key->filter_mask = udata->filter_mask; - *lt_key_changed = TRUE; - ret_value = H5B_INS_CHANGE; - } else { - /* Already have address in udata, from main chunk routines */ - HDassert(H5F_addr_defined(udata->chunk_block.offset)); + *lt_key_changed = TRUE; + ret_value = H5B_INS_CHANGE; + } + else { + /* Already have address in udata, from main chunk routines */ + HDassert(H5F_addr_defined(udata->chunk_block.offset)); ret_value = H5B_INS_NOOP; } - - } else if (H5D__chunk_disjoint(udata->common.layout->ndims, - lt_key->scaled, udata->common.scaled)) { - HDassert(H5D__chunk_disjoint(udata->common.layout->ndims, - rt_key->scaled, udata->common.scaled)); + } + else if (H5D__chunk_disjoint(udata->common.layout->ndims, lt_key->scaled, udata->common.scaled)) { + HDassert(H5D__chunk_disjoint(udata->common.layout->ndims, rt_key->scaled, udata->common.scaled)); /* * Split this node, inserting the new new node to the right of the * current node. The MD_KEY is where the split occurs. */ H5_CHECKED_ASSIGN(md_key->nbytes, uint32_t, udata->chunk_block.length, hsize_t); md_key->filter_mask = udata->filter_mask; - for(u = 0; u < udata->common.layout->ndims; u++) + for (u = 0; u < udata->common.layout->ndims; u++) md_key->scaled[u] = udata->common.scaled[u]; - HDassert(H5F_addr_defined(udata->chunk_block.offset)); + HDassert(H5F_addr_defined(udata->chunk_block.offset)); *new_node_p = udata->chunk_block.offset; - ret_value = H5B_INS_RIGHT; - - } else { + ret_value = H5B_INS_RIGHT; + } + else { HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error") } @@ -613,7 +588,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_remove * @@ -628,21 +602,19 @@ done: *------------------------------------------------------------------------- */ static H5B_ins_t -H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */ , - hbool_t *lt_key_changed /*out */ , - void H5_ATTR_UNUSED * _udata /*in,out */ , - void H5_ATTR_UNUSED * _rt_key /*in,out */ , - hbool_t *rt_key_changed /*out */ ) +H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */, hbool_t *lt_key_changed /*out */, + void H5_ATTR_UNUSED *_udata /*in,out */, void H5_ATTR_UNUSED *_rt_key /*in,out */, + hbool_t *rt_key_changed /*out */) { - H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; - H5B_ins_t ret_value=H5B_INS_REMOVE; /* Return value */ + H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; + H5B_ins_t ret_value = H5B_INS_REMOVE; /* Return value */ FUNC_ENTER_STATIC /* Remove raw data chunk from file */ H5_CHECK_OVERFLOW(lt_key->nbytes, uint32_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes) < 0) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk") + if (H5MF_xfree(f, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes) < 0) + HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk") /* Mark keys as unchanged */ *lt_key_changed = FALSE; @@ -652,7 +624,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_decode_key * @@ -668,11 +639,11 @@ done: static herr_t H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) { - const H5O_layout_chunk_t *layout; /* Chunk layout description */ - H5D_btree_key_t *key = (H5D_btree_key_t *) _key; /* Pointer to decoded key */ - hsize_t tmp_offset; /* Temporary coordinate offset, from file */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_chunk_t *layout; /* Chunk layout description */ + H5D_btree_key_t * key = (H5D_btree_key_t *)_key; /* Pointer to decoded key */ + hsize_t tmp_offset; /* Temporary coordinate offset, from file */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -687,8 +658,8 @@ H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key /* decode */ UINT32DECODE(raw, key->nbytes); UINT32DECODE(raw, key->filter_mask); - for(u = 0; u < layout->ndims; u++) { - if(layout->dim[u] == 0) + for (u = 0; u < layout->ndims; u++) { + if (layout->dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) /* Retrieve coordinate offset */ @@ -703,7 +674,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_decode_key() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_encode_key * @@ -719,10 +689,10 @@ done: static herr_t H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) { - const H5O_layout_chunk_t *layout; /* Chunk layout description */ - const H5D_btree_key_t *key = (const H5D_btree_key_t *)_key; - hsize_t tmp_offset; /* Temporary coordinate offset, from file */ - unsigned u; /* Local index variable */ + const H5O_layout_chunk_t *layout; /* Chunk layout description */ + const H5D_btree_key_t * key = (const H5D_btree_key_t *)_key; + hsize_t tmp_offset; /* Temporary coordinate offset, from file */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -737,16 +707,15 @@ H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key /* encode */ UINT32ENCODE(raw, key->nbytes); UINT32ENCODE(raw, key->filter_mask); - for(u = 0; u < layout->ndims; u++) { + for (u = 0; u < layout->ndims; u++) { /* Compute coordinate offset from scaled offset */ tmp_offset = key->scaled[u] * layout->dim[u]; - UINT64ENCODE(raw, tmp_offset); + UINT64ENCODE(raw, tmp_offset); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__btree_encode_key() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_debug_key * @@ -760,12 +729,11 @@ H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key *------------------------------------------------------------------------- */ static herr_t -H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, - const void *_udata) +H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, const void *_udata) { - const H5D_btree_key_t *key = (const H5D_btree_key_t *)_key; - const H5D_btree_dbg_t *udata = (const H5D_btree_dbg_t *)_udata; - unsigned u; + const H5D_btree_key_t *key = (const H5D_btree_key_t *)_key; + const H5D_btree_dbg_t *udata = (const H5D_btree_dbg_t *)_udata; + unsigned u; FUNC_ENTER_STATIC_NOERR @@ -774,14 +742,13 @@ H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Chunk size:", (unsigned)key->nbytes); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "Filter mask:", key->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < udata->ndims; u++) - HDfprintf(stream, "%s%Hd", u?", ":"", (key->scaled[u] * udata->common.layout->dim[u])); + for (u = 0; u < udata->ndims; u++) + HDfprintf(stream, "%s%Hd", u ? ", " : "", (key->scaled[u] * udata->common.layout->dim[u])); HDfputs("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__btree_debug_key() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_shared_free * @@ -797,8 +764,8 @@ H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, static herr_t H5D__btree_shared_free(void *_shared) { - H5B_shared_t *shared = (H5B_shared_t *)_shared; - herr_t ret_value = SUCCEED; /* Return value */ + H5B_shared_t *shared = (H5B_shared_t *)_shared; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -806,14 +773,13 @@ H5D__btree_shared_free(void *_shared) shared->udata = H5FL_FREE(H5O_layout_chunk_t, shared->udata); /* Chain up to the generic B-tree shared info free routine */ - if(H5B_shared_free(shared) < 0) + if (H5B_shared_free(shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't free shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_shared_free() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_shared_create * @@ -827,44 +793,42 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store, - const H5O_layout_chunk_t *layout) +H5D__btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store, const H5O_layout_chunk_t *layout) { - H5B_shared_t *shared; /* Shared B-tree node info */ - H5O_layout_chunk_t *my_layout = NULL; /* Pointer to copy of layout info */ - size_t sizeof_rkey; /* Size of raw (disk) key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B_shared_t * shared; /* Shared B-tree node info */ + H5O_layout_chunk_t *my_layout = NULL; /* Pointer to copy of layout info */ + size_t sizeof_rkey; /* Size of raw (disk) key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Set the raw key size */ - sizeof_rkey = 4 + /*storage size */ - 4 + /*filter mask */ - layout->ndims * 8; /*dimension indices */ + sizeof_rkey = 4 + /*storage size */ + 4 + /*filter mask */ + layout->ndims * 8; /*dimension indices */ /* Allocate & initialize global info for the shared structure */ - if(NULL == (shared = H5B_shared_new(f, H5B_BTREE, sizeof_rkey))) - HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "memory allocation failed for shared B-tree info") + if (NULL == (shared = H5B_shared_new(f, H5B_BTREE, sizeof_rkey))) + HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "memory allocation failed for shared B-tree info") /* Set up the "local" information for this dataset's chunks */ - if(NULL == (my_layout = H5FL_MALLOC(H5O_layout_chunk_t))) + if (NULL == (my_layout = H5FL_MALLOC(H5O_layout_chunk_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk layout") H5MM_memcpy(my_layout, layout, sizeof(H5O_layout_chunk_t)); shared->udata = my_layout; /* Make shared B-tree info reference counted */ - if(NULL == (store->u.btree.shared = H5UC_create(shared, H5D__btree_shared_free))) - HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") + if (NULL == (store->u.btree.shared = H5UC_create(shared, H5D__btree_shared_free))) + HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") done: - if(ret_value < 0) - if(my_layout) + if (ret_value < 0) + if (my_layout) my_layout = H5FL_FREE(H5O_layout_chunk_t, my_layout); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_shared_create() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_init * @@ -879,9 +843,9 @@ done: */ static herr_t H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, - haddr_t dset_ohdr_addr) + haddr_t dset_ohdr_addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -896,14 +860,13 @@ H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUS idx_info->storage->u.btree.dset_ohdr_addr = dset_ohdr_addr; /* Allocate the shared structure */ - if(H5D__btree_shared_create(idx_info->f, idx_info->storage, idx_info->layout) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") + if (H5D__btree_shared_create(idx_info->f, idx_info->storage, idx_info->layout) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_create * @@ -925,8 +888,8 @@ done: static herr_t H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5D_chunk_common_ud_t udata; /* User data for B-tree callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_common_ud_t udata; /* User data for B-tree callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -939,18 +902,17 @@ H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); /* Initialize "user" data for B-tree callbacks, etc. */ - udata.layout = idx_info->layout; + udata.layout = idx_info->layout; udata.storage = idx_info->storage; /* Create the v1 B-tree for the chunk index */ - if(H5B_create(idx_info->f, H5B_BTREE, &udata, &(idx_info->storage->idx_addr)/*out*/) < 0) + if (H5B_create(idx_info->f, H5B_BTREE, &udata, &(idx_info->storage->idx_addr) /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_is_space_alloc * @@ -974,7 +936,6 @@ H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__btree_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_insert * @@ -989,9 +950,9 @@ H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage) */ static herr_t H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t H5_ATTR_UNUSED *dset) + const H5D_t H5_ATTR_UNUSED *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1007,14 +968,13 @@ H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, * Create the chunk it if it doesn't exist, or reallocate the chunk if * its size changed. */ - if(H5B_insert(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) + if (H5B_insert(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_get_addr * @@ -1032,7 +992,7 @@ done: static herr_t H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1046,14 +1006,13 @@ H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udat HDassert(udata); /* Go get the chunk information from the B-tree */ - if(H5B_find(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) + if (H5B_find(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_iterate_cb * @@ -1070,13 +1029,13 @@ done: *------------------------------------------------------------------------- */ static int -H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key, - haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata) +H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key, haddr_t addr, + const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - H5D_btree_it_ud_t *udata = (H5D_btree_it_ud_t *)_udata; /* User data */ - const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *)_lt_key; /* B-tree key for chunk */ - H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ - int ret_value = -1; /* Return value */ + H5D_btree_it_ud_t * udata = (H5D_btree_it_ud_t *)_udata; /* User data */ + const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *)_lt_key; /* B-tree key for chunk */ + H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1093,13 +1052,12 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key, chunk_rec.chunk_addr = addr; /* Make "generic chunk" callback */ - if((ret_value = (udata->cb)(&chunk_rec, udata->udata)) < 0) + if ((ret_value = (udata->cb)(&chunk_rec, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_iterate * @@ -1114,11 +1072,10 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key, *------------------------------------------------------------------------- */ static int -H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */ - int ret_value = -1; /* Return value */ + H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1133,19 +1090,19 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, /* Initialize userdata */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = idx_info->layout; + udata.common.layout = idx_info->layout; udata.common.storage = idx_info->storage; - udata.cb = chunk_cb; - udata.udata = chunk_udata; + udata.cb = chunk_cb; + udata.udata = chunk_udata; /* Iterate over existing chunks */ - if((ret_value = H5B_iterate(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, H5D__btree_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5B_iterate(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, + H5D__btree_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk B-tree"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_remove * @@ -1161,7 +1118,7 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, static herr_t H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1176,14 +1133,13 @@ H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t /* Remove the chunk from the v1 B-tree index and release the space for the * chunk (in the B-tree callback). */ - if(H5B_remove(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) + if (H5B_remove(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_delete * @@ -1201,7 +1157,7 @@ done: static herr_t H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1213,30 +1169,30 @@ H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { - H5O_storage_chunk_t tmp_storage; /* Local copy of storage info */ - H5D_chunk_common_ud_t udata; /* User data for B-tree operations */ + if (H5F_addr_defined(idx_info->storage->idx_addr)) { + H5O_storage_chunk_t tmp_storage; /* Local copy of storage info */ + H5D_chunk_common_ud_t udata; /* User data for B-tree operations */ /* Set up temporary chunked storage info */ tmp_storage = *idx_info->storage; /* Set up the shared structure */ - if(H5D__btree_shared_create(idx_info->f, &tmp_storage, idx_info->layout) < 0) + if (H5D__btree_shared_create(idx_info->f, &tmp_storage, idx_info->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") /* Set up B-tree user data */ HDmemset(&udata, 0, sizeof udata); - udata.layout = idx_info->layout; + udata.layout = idx_info->layout; udata.storage = &tmp_storage; /* Delete entire B-tree */ - if(H5B_delete(idx_info->f, H5B_BTREE, tmp_storage.idx_addr, &udata) < 0) + if (H5B_delete(idx_info->f, H5B_BTREE, tmp_storage.idx_addr, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk B-tree") /* Release the shared B-tree page */ - if(NULL == tmp_storage.u.btree.shared) + if (NULL == tmp_storage.u.btree.shared) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "ref-counted page nil") - if(H5UC_DEC(tmp_storage.u.btree.shared) < 0) + if (H5UC_DEC(tmp_storage.u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") } /* end if */ @@ -1244,7 +1200,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_copy_setup * @@ -1258,10 +1213,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG) @@ -1278,13 +1232,14 @@ H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Create shared B-tree info for each file */ - if(H5D__btree_shared_create(idx_info_src->f, idx_info_src->storage, idx_info_src->layout) < 0) + if (H5D__btree_shared_create(idx_info_src->f, idx_info_src->storage, idx_info_src->layout) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for source shared B-tree info") - if(H5D__btree_shared_create(idx_info_dst->f, idx_info_dst->storage, idx_info_dst->layout) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for destination shared B-tree info") + if (H5D__btree_shared_create(idx_info_dst->f, idx_info_dst->storage, idx_info_dst->layout) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, + "can't create wrapper for destination shared B-tree info") /* Create the root of the B-tree that describes chunked storage in the dest. file */ - if(H5D__btree_idx_create(idx_info_dst) < 0) + if (H5D__btree_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1292,7 +1247,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__btree_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_copy_shutdown * @@ -1306,10 +1260,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1317,16 +1270,15 @@ H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst); /* Decrement refcount on shared B-tree info */ - if(H5UC_DEC(storage_src->u.btree.shared) < 0) + if (H5UC_DEC(storage_src->u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref-counted page") - if(H5UC_DEC(storage_dst->u.btree.shared) < 0) + if (H5UC_DEC(storage_dst->u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref-counted page") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_size * @@ -1343,9 +1295,9 @@ done: static herr_t H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5D_chunk_common_ud_t udata; /* User-data for loading B-tree nodes */ - H5B_info_t bt_info; /* B-tree info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_common_ud_t udata; /* User-data for loading B-tree nodes */ + H5B_info_t bt_info; /* B-tree info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1359,11 +1311,11 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) /* Initialize B-tree node user-data */ HDmemset(&udata, 0, sizeof udata); - udata.layout = idx_info->layout; + udata.layout = idx_info->layout; udata.storage = idx_info->storage; /* Get metadata information for B-tree */ - if(H5B_get_info(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata) < 0) + if (H5B_get_info(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to iterate over chunk B-tree") /* Set the size of the B-tree */ @@ -1373,7 +1325,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_reset * @@ -1394,14 +1345,13 @@ H5D__btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; storage->u.btree.shared = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__btree_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_dump * @@ -1427,7 +1377,6 @@ H5D__btree_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__btree_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_dest * @@ -1443,7 +1392,7 @@ H5D__btree_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1454,16 +1403,15 @@ H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Free the raw B-tree node buffer */ - if(NULL == idx_info->storage->u.btree.shared) + if (NULL == idx_info->storage->u.btree.shared) HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil") - if(H5UC_DEC(idx_info->storage->u.btree.shared) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") + if (H5UC_DEC(idx_info->storage->u.btree.shared) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_dest() */ - /*------------------------------------------------------------------------- * Function: H5D_btree_debug * @@ -1477,15 +1425,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_btree_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, - int fwidth, unsigned ndims, const uint32_t *dim) +H5D_btree_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, unsigned ndims, + const uint32_t *dim) { - H5D_btree_dbg_t udata; /* User data for B-tree callback */ - H5O_storage_chunk_t storage; /* Storage information for B-tree callback */ - H5O_layout_chunk_t layout; /* Layout information for B-tree callback */ - hbool_t shared_init = FALSE; /* Whether B-tree shared info is initialized */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_btree_dbg_t udata; /* User data for B-tree callback */ + H5O_storage_chunk_t storage; /* Storage information for B-tree callback */ + H5O_layout_chunk_t layout; /* Layout information for B-tree callback */ + hbool_t shared_init = FALSE; /* Whether B-tree shared info is initialized */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1496,33 +1444,31 @@ H5D_btree_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, /* Reset "fake" layout info */ HDmemset(&layout, 0, sizeof(layout)); layout.ndims = ndims; - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) layout.dim[u] = dim[u]; /* Allocate the shared structure */ - if(H5D__btree_shared_create(f, &storage, &layout) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") + if (H5D__btree_shared_create(f, &storage, &layout) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") shared_init = TRUE; /* Set up user data for callback */ - udata.common.layout = &layout; + udata.common.layout = &layout; udata.common.storage = &storage; - udata.common.scaled = NULL; - udata.ndims = ndims; + udata.common.scaled = NULL; + udata.ndims = ndims; /* Dump the records for the B-tree */ (void)H5B_debug(f, addr, stream, indent, fwidth, H5B_BTREE, &udata); done: - if(shared_init) { + if (shared_init) { /* Free the raw B-tree node buffer */ - if(NULL == storage.u.btree.shared) + if (NULL == storage.u.btree.shared) HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted shared info nil") - else - if(H5UC_DEC(storage.u.btree.shared) < 0) - HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted shared info") + else if (H5UC_DEC(storage.u.btree.shared) < 0) + HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted shared info") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_btree_debug() */ - diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index 65a020f..966c666 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -22,64 +22,60 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for creating callback context */ typedef struct H5D_bt2_ctx_ud_t { - const H5F_t *f; /* Pointer to file info */ - uint32_t chunk_size; /* Size of chunk (bytes; for filtered object) */ - unsigned ndims; /* Number of dimensions */ - uint32_t *dim; /* Size of chunk in elements */ + const H5F_t *f; /* Pointer to file info */ + uint32_t chunk_size; /* Size of chunk (bytes; for filtered object) */ + unsigned ndims; /* Number of dimensions */ + uint32_t * dim; /* Size of chunk in elements */ } H5D_bt2_ctx_ud_t; /* The callback context */ typedef struct H5D_bt2_ctx_t { - uint32_t chunk_size; /* Size of chunk (bytes; constant for unfiltered object) */ - size_t sizeof_addr; /* Size of file addresses in the file (bytes) */ - size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ - unsigned ndims; /* Number of dimensions in chunk */ - uint32_t *dim; /* Size of chunk in elements */ + uint32_t chunk_size; /* Size of chunk (bytes; constant for unfiltered object) */ + size_t sizeof_addr; /* Size of file addresses in the file (bytes) */ + size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ + unsigned ndims; /* Number of dimensions in chunk */ + uint32_t *dim; /* Size of chunk in elements */ } H5D_bt2_ctx_t; /* Callback info for iteration over chunks in v2 B-tree */ typedef struct H5D_bt2_it_ud_t { - H5D_chunk_cb_func_t cb; /* Callback routine for the chunk */ - void *udata; /* User data for the chunk's callback routine */ + H5D_chunk_cb_func_t cb; /* Callback routine for the chunk */ + void * udata; /* User data for the chunk's callback routine */ } H5D_bt2_it_ud_t; /* User data for compare callback */ typedef struct H5D_bt2_ud_t { - H5D_chunk_rec_t rec; /* The record to search for */ - unsigned ndims; /* Number of dimensions for the chunked dataset */ + H5D_chunk_rec_t rec; /* The record to search for */ + unsigned ndims; /* Number of dimensions for the chunked dataset */ } H5D_bt2_ud_t; - /********************/ /* Local Prototypes */ /********************/ /* Shared v2 B-tree methods for indexing filtered and non-filtered chunked datasets */ -static void *H5D__bt2_crt_context(void *udata); +static void * H5D__bt2_crt_context(void *udata); static herr_t H5D__bt2_dst_context(void *ctx); static herr_t H5D__bt2_store(void *native, const void *udata); static herr_t H5D__bt2_compare(const void *rec1, const void *rec2, int *result); @@ -87,14 +83,14 @@ static herr_t H5D__bt2_compare(const void *rec1, const void *rec2, int *result); /* v2 B-tree class for indexing non-filtered chunked datasets */ static herr_t H5D__bt2_unfilt_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5D__bt2_unfilt_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *u_ctx); +static herr_t H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *u_ctx); /* v2 B-tree class for indexing filtered chunked datasets */ static herr_t H5D__bt2_filt_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5D__bt2_filt_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *u_ctx); +static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *u_ctx); /* Helper routine */ static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info); @@ -116,29 +112,24 @@ static herr_t H5D__bt2_remove_cb(const void *nrecord, void *_udata); static herr_t H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed); /* Chunked layout indexing callbacks for v2 B-tree indexing */ -static herr_t H5D__bt2_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__bt2_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); -static herr_t H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, - FILE *stream); -static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); - +static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst); +static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); /*********************/ /* Package Variables */ @@ -146,59 +137,59 @@ static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Chunked dataset I/O ops for v2 B-tree indexing */ const H5D_chunk_ops_t H5D_COPS_BT2[1] = {{ - TRUE, /* Fixed array indices support SWMR access */ - H5D__bt2_idx_init, /* init */ - H5D__bt2_idx_create, /* create */ - H5D__bt2_idx_is_space_alloc, /* is_space_alloc */ - H5D__bt2_idx_insert, /* insert */ - H5D__bt2_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__bt2_idx_iterate, /* iterate */ - H5D__bt2_idx_remove, /* remove */ - H5D__bt2_idx_delete, /* delete */ - H5D__bt2_idx_copy_setup, /* copy_setup */ - H5D__bt2_idx_copy_shutdown, /* copy_shutdown */ - H5D__bt2_idx_size, /* size */ - H5D__bt2_idx_reset, /* reset */ - H5D__bt2_idx_dump, /* dump */ - H5D__bt2_idx_dest, /* destroy */ - H5D__bt2_idx_dest /* close (same as destroy) */ + TRUE, /* Fixed array indices support SWMR access */ + H5D__bt2_idx_init, /* init */ + H5D__bt2_idx_create, /* create */ + H5D__bt2_idx_is_space_alloc, /* is_space_alloc */ + H5D__bt2_idx_insert, /* insert */ + H5D__bt2_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__bt2_idx_iterate, /* iterate */ + H5D__bt2_idx_remove, /* remove */ + H5D__bt2_idx_delete, /* delete */ + H5D__bt2_idx_copy_setup, /* copy_setup */ + H5D__bt2_idx_copy_shutdown, /* copy_shutdown */ + H5D__bt2_idx_size, /* size */ + H5D__bt2_idx_reset, /* reset */ + H5D__bt2_idx_dump, /* dump */ + H5D__bt2_idx_dest, /* destroy */ + H5D__bt2_idx_dest /* close (same as destroy) */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ /* v2 B-tree class for indexing non-filtered chunked datasets */ -const H5B2_class_t H5D_BT2[1] = {{ /* B-tree class information */ - H5B2_CDSET_ID, /* Type of B-tree */ - "H5B2_CDSET_ID", /* Name of B-tree class */ - sizeof(H5D_chunk_rec_t), /* Size of native record */ - H5D__bt2_crt_context, /* Create client callback context */ - H5D__bt2_dst_context, /* Destroy client callback context */ - H5D__bt2_store, /* Record storage callback */ - H5D__bt2_compare, /* Record comparison callback */ - H5D__bt2_unfilt_encode, /* Record encoding callback */ - H5D__bt2_unfilt_decode, /* Record decoding callback */ - H5D__bt2_unfilt_debug /* Record debugging callback */ +const H5B2_class_t H5D_BT2[1] = {{ + /* B-tree class information */ + H5B2_CDSET_ID, /* Type of B-tree */ + "H5B2_CDSET_ID", /* Name of B-tree class */ + sizeof(H5D_chunk_rec_t), /* Size of native record */ + H5D__bt2_crt_context, /* Create client callback context */ + H5D__bt2_dst_context, /* Destroy client callback context */ + H5D__bt2_store, /* Record storage callback */ + H5D__bt2_compare, /* Record comparison callback */ + H5D__bt2_unfilt_encode, /* Record encoding callback */ + H5D__bt2_unfilt_decode, /* Record decoding callback */ + H5D__bt2_unfilt_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing filtered chunked datasets */ -const H5B2_class_t H5D_BT2_FILT[1] = {{ /* B-tree class information */ - H5B2_CDSET_FILT_ID, /* Type of B-tree */ - "H5B2_CDSET_FILT_ID", /* Name of B-tree class */ - sizeof(H5D_chunk_rec_t), /* Size of native record */ - H5D__bt2_crt_context, /* Create client callback context */ - H5D__bt2_dst_context, /* Destroy client callback context */ - H5D__bt2_store, /* Record storage callback */ - H5D__bt2_compare, /* Record comparison callback */ - H5D__bt2_filt_encode, /* Record encoding callback */ - H5D__bt2_filt_decode, /* Record decoding callback */ - H5D__bt2_filt_debug /* Record debugging callback */ +const H5B2_class_t H5D_BT2_FILT[1] = {{ + /* B-tree class information */ + H5B2_CDSET_FILT_ID, /* Type of B-tree */ + "H5B2_CDSET_FILT_ID", /* Name of B-tree class */ + sizeof(H5D_chunk_rec_t), /* Size of native record */ + H5D__bt2_crt_context, /* Create client callback context */ + H5D__bt2_dst_context, /* Destroy client callback context */ + H5D__bt2_store, /* Record storage callback */ + H5D__bt2_compare, /* Record comparison callback */ + H5D__bt2_filt_encode, /* Record encoding callback */ + H5D__bt2_filt_decode, /* Record decoding callback */ + H5D__bt2_filt_debug /* Record debugging callback */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -209,8 +200,6 @@ H5FL_DEFINE_STATIC(H5D_bt2_ctx_t); /* Declare a free list to manage the page elements */ H5FL_ARR_DEFINE_STATIC(uint32_t, H5O_LAYOUT_NDIMS); - - /*------------------------------------------------------------------------- * Function: H5D__bt2_crt_context * @@ -227,9 +216,9 @@ static void * H5D__bt2_crt_context(void *_udata) { H5D_bt2_ctx_ud_t *udata = (H5D_bt2_ctx_ud_t *)_udata; /* User data for building callback context */ - H5D_bt2_ctx_t *ctx; /* Callback context structure */ - uint32_t *my_dim = NULL; /* Pointer to copy of chunk dimension size */ - void *ret_value = NULL; /* Return value */ + H5D_bt2_ctx_t * ctx; /* Callback context structure */ + uint32_t * my_dim = NULL; /* Pointer to copy of chunk dimension size */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -239,16 +228,16 @@ H5D__bt2_crt_context(void *_udata) HDassert(udata->ndims > 0 && udata->ndims < H5O_LAYOUT_NDIMS); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5D_bt2_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5D_bt2_ctx_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of addresses and set the chunk size and # of dimensions for the dataset */ ctx->sizeof_addr = H5F_SIZEOF_ADDR(udata->f); - ctx->chunk_size = udata->chunk_size; - ctx->ndims = udata->ndims; + ctx->chunk_size = udata->chunk_size; + ctx->ndims = udata->ndims; /* Set up the "local" information for this dataset's chunk dimension sizes */ - if(NULL == (my_dim = (uint32_t *)H5FL_ARR_MALLOC(uint32_t, H5O_LAYOUT_NDIMS))) + if (NULL == (my_dim = (uint32_t *)H5FL_ARR_MALLOC(uint32_t, H5O_LAYOUT_NDIMS))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate chunk dims") H5MM_memcpy(my_dim, udata->dim, H5O_LAYOUT_NDIMS * sizeof(uint32_t)); ctx->dim = my_dim; @@ -258,7 +247,7 @@ H5D__bt2_crt_context(void *_udata) * allowing for an extra byte, in case the filter makes the chunk larger. */ ctx->chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)udata->chunk_size) + 8) / 8); - if(ctx->chunk_size_len > 8) + if (ctx->chunk_size_len > 8) ctx->chunk_size_len = 8; /* Set return value */ @@ -268,7 +257,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_dst_context * @@ -284,7 +272,7 @@ done: static herr_t H5D__bt2_dst_context(void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -292,7 +280,7 @@ H5D__bt2_dst_context(void *_ctx) HDassert(ctx); /* Free array for chunk dimension sizes */ - if(ctx->dim) + if (ctx->dim) H5FL_ARR_FREE(uint32_t, ctx->dim); /* Release callback context */ ctx = H5FL_FREE(H5D_bt2_ctx_t, ctx); @@ -300,7 +288,6 @@ H5D__bt2_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_store * @@ -317,7 +304,7 @@ H5D__bt2_dst_context(void *_ctx) static herr_t H5D__bt2_store(void *record, const void *_udata) { - const H5D_bt2_ud_t *udata = (const H5D_bt2_ud_t *)_udata; /* User data */ + const H5D_bt2_ud_t *udata = (const H5D_bt2_ud_t *)_udata; /* User data */ FUNC_ENTER_STATIC_NOERR @@ -326,7 +313,6 @@ H5D__bt2_store(void *record, const void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_store() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_compare * @@ -344,10 +330,10 @@ H5D__bt2_store(void *record, const void *_udata) static herr_t H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) { - const H5D_bt2_ud_t *udata = (const H5D_bt2_ud_t *)_udata; /* User data */ - const H5D_chunk_rec_t *rec1 = &(udata->rec); /* The search record */ - const H5D_chunk_rec_t *rec2 = (const H5D_chunk_rec_t *)_rec2; /* The native record */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_bt2_ud_t * udata = (const H5D_bt2_ud_t *)_udata; /* User data */ + const H5D_chunk_rec_t *rec1 = &(udata->rec); /* The search record */ + const H5D_chunk_rec_t *rec2 = (const H5D_chunk_rec_t *)_rec2; /* The native record */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -361,7 +347,6 @@ H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_compare() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_encode * @@ -378,9 +363,9 @@ H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) static herr_t H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -390,13 +375,12 @@ H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) /* Encode the record's fields */ H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); /* (Don't encode the chunk size & filter mask for non-filtered B-tree records) */ - for(u = 0; u < ctx->ndims; u++) - UINT64ENCODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64ENCODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_decode * @@ -413,9 +397,9 @@ H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) static herr_t H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ - H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -424,15 +408,14 @@ H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) /* Decode the record's fields */ H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); - record->nbytes = ctx->chunk_size; + record->nbytes = ctx->chunk_size; record->filter_mask = 0; - for(u = 0; u < ctx->ndims; u++) - UINT64DECODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64DECODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_debug * @@ -446,12 +429,11 @@ H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, - const void *_record, const void *_ctx) +H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *_record, const void *_ctx) { const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - const H5D_bt2_ctx_t *ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ - unsigned u; /* Local index variable */ + const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -463,14 +445,13 @@ H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Chunk address:", record->chunk_addr); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < ctx->ndims; u++) - HDfprintf(stream, "%s%Hd", u?", ":"", record->scaled[u] * ctx->dim[u]); + for (u = 0; u < ctx->ndims; u++) + HDfprintf(stream, "%s%Hd", u ? ", " : "", record->scaled[u] * ctx->dim[u]); HDfputs("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_encode * @@ -487,9 +468,9 @@ H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, static herr_t H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -503,13 +484,12 @@ H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); UINT64ENCODE_VAR(raw, record->nbytes, ctx->chunk_size_len); UINT32ENCODE(raw, record->filter_mask); - for(u = 0; u < ctx->ndims; u++) - UINT64ENCODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64ENCODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_decode * @@ -526,9 +506,9 @@ H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) static herr_t H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) { - H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ - H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -540,8 +520,8 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); UINT64DECODE_VAR(raw, record->nbytes, ctx->chunk_size_len); UINT32DECODE(raw, record->filter_mask); - for(u = 0; u < ctx->ndims; u++) - UINT64DECODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64DECODE(raw, record->scaled[u]); /* Sanity checks */ HDassert(H5F_addr_defined(record->chunk_addr)); @@ -550,7 +530,6 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_debug * @@ -564,12 +543,11 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, - const void *_record, const void *_ctx) +H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, const void *_record, const void *_ctx) { - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - const H5D_bt2_ctx_t *ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ - unsigned u; /* Local index variable */ + const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ + const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -583,14 +561,13 @@ H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "Filter mask:", record->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < ctx->ndims; u++) - HDfprintf(stream, "%s%Hd", u?", ":"", record->scaled[u] * ctx->dim[u]); + for (u = 0; u < ctx->ndims; u++) + HDfprintf(stream, "%s%Hd", u ? ", " : "", record->scaled[u] * ctx->dim[u]); HDfputs("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_init * @@ -604,8 +581,8 @@ H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, - const H5S_t H5_ATTR_UNUSED *space, haddr_t dset_ohdr_addr) +H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, const H5S_t H5_ATTR_UNUSED *space, + haddr_t dset_ohdr_addr) { FUNC_ENTER_STATIC_NOERR @@ -617,7 +594,6 @@ H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__btree2_idx_depend * @@ -635,10 +611,10 @@ H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, static herr_t H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5O_loc_t oloc; /* Temporary object header location for dataset */ + H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -660,26 +636,26 @@ H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; /* Get header */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Retrieve the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_get_proxy(oh))) + if (NULL == (oh_proxy = H5O_get_proxy(oh))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataset object header proxy") /* Make the v2 B-tree a child flush dependency of the dataset's object header proxy */ - if(H5B2_depend(idx_info->storage->u.btree2.bt2, oh_proxy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header proxy") + if (H5B2_depend(idx_info->storage->u.btree2.bt2, oh_proxy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header proxy") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree2_idx_depend() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_open() * @@ -700,8 +676,8 @@ done: static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) { - H5D_bt2_ctx_ud_t u_ctx; /* user data for creating context */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_bt2_ctx_ud_t u_ctx; /* user data for creating context */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -716,25 +692,26 @@ H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.btree2.bt2); /* Set up the user data */ - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; + u_ctx.dim = idx_info->layout->dim; /* Open v2 B-tree for the chunk index */ - if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->storage->idx_addr, &u_ctx))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset") + if (NULL == + (idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->storage->idx_addr, &u_ctx))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__btree2_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__btree2_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_open() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_create * @@ -749,9 +726,9 @@ done: static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -763,54 +740,55 @@ H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); - bt2_cparam.rrec_size = H5F_SIZEOF_ADDR(idx_info->f) /* Address of chunk */ - + (idx_info->layout->ndims - 1) * 8; /* # of dimensions x 64-bit chunk offsets */ + bt2_cparam.rrec_size = H5F_SIZEOF_ADDR(idx_info->f) /* Address of chunk */ + + (idx_info->layout->ndims - 1) * 8; /* # of dimensions x 64-bit chunk offsets */ /* General parameters */ - if(idx_info->pline->nused > 0) { - unsigned chunk_size_len; /* Size of encoded chunk size */ + if (idx_info->pline->nused > 0) { + unsigned chunk_size_len; /* Size of encoded chunk size */ /* - * Compute the size required for encoding the size of a chunk, + * Compute the size required for encoding the size of a chunk, * allowing for an extra byte, in case the filter makes the chunk larger. */ chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)idx_info->layout->size) + 8) / 8); - if(chunk_size_len > 8) + if (chunk_size_len > 8) chunk_size_len = 8; - bt2_cparam.rrec_size += chunk_size_len + 4; /* Size of encoded chunk size & filter mask */ - bt2_cparam.cls = H5D_BT2_FILT; + bt2_cparam.rrec_size += chunk_size_len + 4; /* Size of encoded chunk size & filter mask */ + bt2_cparam.cls = H5D_BT2_FILT; } /* end if */ else - bt2_cparam.cls = H5D_BT2; + bt2_cparam.cls = H5D_BT2; - bt2_cparam.node_size = idx_info->layout->u.btree2.cparam.node_size; + bt2_cparam.node_size = idx_info->layout->u.btree2.cparam.node_size; bt2_cparam.split_percent = idx_info->layout->u.btree2.cparam.split_percent; bt2_cparam.merge_percent = idx_info->layout->u.btree2.cparam.merge_percent; - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; + u_ctx.dim = idx_info->layout->dim; /* Create the v2 B-tree for the chunked dataset */ - if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, &bt2_cparam, &u_ctx))) + if (NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, &bt2_cparam, &u_ctx))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking chunked dataset") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(idx_info->storage->u.btree2.bt2, &(idx_info->storage->idx_addr)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking chunked dataset") + if (H5B2_get_addr(idx_info->storage->u.btree2.bt2, &(idx_info->storage->idx_addr)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't get v2 B-tree address for tracking chunked dataset") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__btree2_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__btree2_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_is_space_alloc * @@ -833,7 +811,6 @@ H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__bt2_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_mod_cb * @@ -851,19 +828,19 @@ H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage) static herr_t H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) { - H5D_bt2_ud_t *op_data = (H5D_bt2_ud_t *)_op_data; /* User data for v2 B-tree calls */ - H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* Chunk record */ + H5D_bt2_ud_t * op_data = (H5D_bt2_ud_t *)_op_data; /* User data for v2 B-tree calls */ + H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* Chunk record */ FUNC_ENTER_STATIC_NOERR /* Sanity check */ #ifndef NDEBUG -{ - unsigned u; /* Local index variable */ + { + unsigned u; /* Local index variable */ - for(u = 0; u < op_data->ndims; u++) - HDassert(record->scaled[u] == op_data->rec.scaled[u]); -} + for (u = 0; u < op_data->ndims; u++) + HDassert(record->scaled[u] == op_data->rec.scaled[u]); + } #endif /* NDEBUG */ /* Modify record */ @@ -875,7 +852,6 @@ H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_mod_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_insert * @@ -896,12 +872,12 @@ H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) */ static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t H5_ATTR_UNUSED *dset) + const H5D_t H5_ATTR_UNUSED *dset) { - H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ - H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -916,41 +892,40 @@ H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, HDassert(H5F_addr_defined(udata->chunk_block.offset)); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* end if */ - else /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + } /* end if */ + else /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Set up callback info */ - bt2_udata.ndims = idx_info->layout->ndims - 1; + bt2_udata.ndims = idx_info->layout->ndims - 1; bt2_udata.rec.chunk_addr = udata->chunk_block.offset; - if(idx_info->pline->nused > 0) { /* filtered chunk */ + if (idx_info->pline->nused > 0) { /* filtered chunk */ H5_CHECKED_ASSIGN(bt2_udata.rec.nbytes, uint32_t, udata->chunk_block.length, hsize_t); bt2_udata.rec.filter_mask = udata->filter_mask; - } /* end if */ + } /* end if */ else { /* non-filtered chunk */ - bt2_udata.rec.nbytes = idx_info->layout->size; + bt2_udata.rec.nbytes = idx_info->layout->size; bt2_udata.rec.filter_mask = 0; } /* end else */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->common.scaled[u]; /* Update record for v2 B-tree (could be insert or modify) */ - if(H5B2_update(bt2, &bt2_udata, H5D__bt2_mod_cb, &bt2_udata) < 0) + if (H5B2_update(bt2, &bt2_udata, H5D__bt2_mod_cb, &bt2_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTUPDATE, FAIL, "unable to update record in v2 B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_found_cb * @@ -975,7 +950,6 @@ H5D__bt2_found_cb(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_found_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_get_addr * @@ -992,11 +966,11 @@ H5D__bt2_found_cb(const void *nrecord, void *op_data) static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ - H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ - H5D_chunk_rec_t found_rec; /* Record found from searching for object */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ + H5D_chunk_rec_t found_rec; /* Record found from searching for object */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1011,63 +985,62 @@ H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) HDassert(udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* end if */ - else /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + } /* end if */ + else /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Clear the found record */ - found_rec.chunk_addr = HADDR_UNDEF; - found_rec.nbytes = 0; + found_rec.chunk_addr = HADDR_UNDEF; + found_rec.nbytes = 0; found_rec.filter_mask = 0; /* Prepare user data for compare callback */ bt2_udata.rec.chunk_addr = HADDR_UNDEF; - bt2_udata.ndims = idx_info->layout->ndims - 1; + bt2_udata.ndims = idx_info->layout->ndims - 1; /* Set the chunk offset to be searched for */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->common.scaled[u]; /* Go get chunk information from v2 B-tree */ - if(H5B2_find(bt2, &bt2_udata, H5D__bt2_found_cb, &found_rec) < 0) + if (H5B2_find(bt2, &bt2_udata, H5D__bt2_found_cb, &found_rec) < 0) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in v2 B-tree") /* Set common info for the chunk */ udata->chunk_block.offset = found_rec.chunk_addr; /* Check for setting other info */ - if(H5F_addr_defined(udata->chunk_block.offset)) { + if (H5F_addr_defined(udata->chunk_block.offset)) { /* Sanity check */ HDassert(0 != found_rec.nbytes); /* Set other info for the chunk */ - if(idx_info->pline->nused > 0) { /* filtered chunk */ + if (idx_info->pline->nused > 0) { /* filtered chunk */ udata->chunk_block.length = found_rec.nbytes; - udata->filter_mask = found_rec.filter_mask; - } /* end if */ + udata->filter_mask = found_rec.filter_mask; + } /* end if */ else { /* non-filtered chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ - } /* end if */ + } /* end if */ else { udata->chunk_block.length = 0; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_iterate_cb * @@ -1087,20 +1060,19 @@ done: static int H5D__bt2_idx_iterate_cb(const void *_record, void *_udata) { - H5D_bt2_it_ud_t *udata = (H5D_bt2_it_ud_t *)_udata; /* User data */ - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* Native record */ - int ret_value = -1; /* Return value */ + H5D_bt2_it_ud_t * udata = (H5D_bt2_it_ud_t *)_udata; /* User data */ + const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* Native record */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Make "generic chunk" callback */ - if((ret_value = (udata->cb)(record, udata->udata)) < 0) + if ((ret_value = (udata->cb)(record, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_iterate * @@ -1114,12 +1086,11 @@ H5D__bt2_idx_iterate_cb(const void *_record, void *_udata) *------------------------------------------------------------------------- */ static int -H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ - H5D_bt2_it_ud_t udata; /* User data for B-tree iterator callback */ - int ret_value = FAIL; /* Return value */ + H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5D_bt2_it_ud_t udata; /* User data for B-tree iterator callback */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC @@ -1134,31 +1105,30 @@ H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* end if */ - else /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + } /* end if */ + else /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Prepare user data for iterate callback */ - udata.cb = chunk_cb; + udata.cb = chunk_cb; udata.udata = chunk_udata; /* Iterate over the records in the v2 B-tree */ - if((ret_value = H5B2_iterate(bt2, H5D__bt2_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5B2_iterate(bt2, H5D__bt2_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk v2 B-tree"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_remove_cb() * @@ -1177,9 +1147,9 @@ done: static herr_t H5D__bt2_remove_cb(const void *_record, void *_udata) { - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - H5F_t *f = (H5F_t *)_udata; /* User data for removal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ + H5F_t * f = (H5F_t *)_udata; /* User data for removal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1188,14 +1158,13 @@ H5D__bt2_remove_cb(const void *_record, void *_udata) /* Free the space in the file for the object being removed */ H5_CHECK_OVERFLOW(record->nbytes, uint32_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, record->chunk_addr, (hsize_t)record->nbytes) < 0) + if (H5MF_xfree(f, H5FD_MEM_DRAW, record->chunk_addr, (hsize_t)record->nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_remove_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_remove * @@ -1210,10 +1179,10 @@ done: static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ - H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree find call */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree find call */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1227,14 +1196,14 @@ H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *u HDassert(udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* end if */ - else /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + } /* end if */ + else /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; @@ -1243,19 +1212,20 @@ H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *u bt2_udata.ndims = idx_info->layout->ndims - 1; /* Initialize the record to search for */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->scaled[u]; /* Remove the record for the "dataset chunk" object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(bt2, &bt2_udata, (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) ? NULL : H5D__bt2_remove_cb, idx_info->f) < 0) + if (H5B2_remove(bt2, &bt2_udata, + (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) ? NULL : H5D__bt2_remove_cb, + idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_delete * @@ -1279,9 +1249,9 @@ done: static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) { - H5B2_remove_t remove_op; /* The removal callback */ - H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_remove_t remove_op; /* The removal callback */ + H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1293,32 +1263,31 @@ H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { - /* Set up user data for creating context */ - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; - u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; - - /* Set remove operation. Do not remove chunks in SWMR_WRITE mode */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5F_addr_defined(idx_info->storage->idx_addr)) { + /* Set up user data for creating context */ + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.chunk_size = idx_info->layout->size; + u_ctx.dim = idx_info->layout->dim; + + /* Set remove operation. Do not remove chunks in SWMR_WRITE mode */ + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) remove_op = NULL; else remove_op = H5D__bt2_remove_cb; - /* Delete the v2 B-tree */ - /*(space in the file for each object is freed in the 'remove' callback) */ - if(H5B2_delete(idx_info->f, idx_info->storage->idx_addr, &u_ctx, remove_op, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") + /* Delete the v2 B-tree */ + /*(space in the file for each object is freed in the 'remove' callback) */ + if (H5B2_delete(idx_info->f, idx_info->storage->idx_addr, &u_ctx, remove_op, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") - idx_info->storage->idx_addr = HADDR_UNDEF; + idx_info->storage->idx_addr = HADDR_UNDEF; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_copy_setup * @@ -1331,10 +1300,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1354,15 +1322,15 @@ H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Check if the source v2 B-tree is open yet */ - if(NULL == idx_info_src->storage->u.btree2.bt2) - if(H5D__bt2_idx_open(idx_info_src) < 0) + if (NULL == idx_info_src->storage->u.btree2.bt2) + if (H5D__bt2_idx_open(idx_info_src) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create v2 B-tree that describes the chunked dataset in the destination file */ - if(H5D__bt2_idx_create(idx_info_dst) < 0) + if (H5D__bt2_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1373,7 +1341,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_copy_shutdown * @@ -1386,10 +1353,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1400,12 +1366,12 @@ H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst->u.btree2.bt2); /* Close v2 B-tree for source file */ - if(H5B2_close(storage_src->u.btree2.bt2) < 0) + if (H5B2_close(storage_src->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close v2 B-tree") storage_src->u.btree2.bt2 = NULL; /* Close v2 B-tree for destination file */ - if(H5B2_close(storage_dst->u.btree2.bt2) < 0) + if (H5B2_close(storage_dst->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close v2 B-tree") storage_dst->u.btree2.bt2 = NULL; @@ -1413,7 +1379,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_size * @@ -1429,8 +1394,8 @@ done: static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5B2_t *bt2_cdset = NULL; /* Pointer to v2 B-tree structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t *bt2_cdset = NULL; /* Pointer to v2 B-tree structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1444,26 +1409,25 @@ H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) HDassert(index_size); /* Open v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") + if (H5D__bt2_idx_open(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") /* Set convenience pointer to v2 B-tree structure */ bt2_cdset = idx_info->storage->u.btree2.bt2; /* Get v2 B-tree size for indexing chunked dataset */ - if(H5B2_size(bt2_cdset, index_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve v2 B-tree storage info for chunked dataset") + if (H5B2_size(bt2_cdset, index_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve v2 B-tree storage info for chunked dataset") done: /* Close v2 B-tree index */ - if(bt2_cdset && H5B2_close(bt2_cdset) < 0) + if (bt2_cdset && H5B2_close(bt2_cdset) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for tracking chunked dataset") idx_info->storage->u.btree2.bt2 = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_reset * @@ -1484,14 +1448,13 @@ H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; storage->u.btree2.bt2 = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_dump * @@ -1517,7 +1480,6 @@ H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_dest * @@ -1532,7 +1494,7 @@ H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1542,14 +1504,14 @@ H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the v2-btree is open */ - if(idx_info->storage->u.btree2.bt2) { + if (idx_info->storage->u.btree2.bt2) { - /* Patch the top level file pointer contained in bt2 if needed */ - if(H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) + /* Patch the top level file pointer contained in bt2 if needed */ + if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Close v2 B-tree */ - if(H5B2_close(idx_info->storage->u.btree2.bt2) < 0) + if (H5B2_close(idx_info->storage->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree") idx_info->storage->u.btree2.bt2 = NULL; } /* end if */ @@ -1557,4 +1519,3 @@ H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_dest() */ - diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 7e7d6b4..07ae03f 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -42,26 +42,24 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_PARALLEL -#include "H5ACprivate.h" /* Metadata cache */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File functions */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5ACprivate.h" /* Metadata cache */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File functions */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ @@ -69,16 +67,17 @@ /* Macros for iterating over chunks to operate on */ #define H5D_CHUNK_GET_FIRST_NODE(map) (map->use_single ? (H5SL_node_t *)(1) : H5SL_first(map->sel_chunks)) -#define H5D_CHUNK_GET_NODE_INFO(map, node) (map->use_single ? map->single_chunk_info : (H5D_chunk_info_t *)H5SL_item(node)) -#define H5D_CHUNK_GET_NEXT_NODE(map, node) (map->use_single ? (H5SL_node_t *)NULL : H5SL_next(node)) +#define H5D_CHUNK_GET_NODE_INFO(map, node) \ + (map->use_single ? map->single_chunk_info : (H5D_chunk_info_t *)H5SL_item(node)) +#define H5D_CHUNK_GET_NEXT_NODE(map, node) (map->use_single ? (H5SL_node_t *)NULL : H5SL_next(node)) /* Sanity check on chunk index types: commonly used by a lot of routines in this file */ -#define H5D_CHUNK_STORAGE_INDEX_CHK(storage) \ - HDassert((H5D_CHUNK_IDX_EARRAY == (storage)->idx_type && H5D_COPS_EARRAY == (storage)->ops) || \ - (H5D_CHUNK_IDX_FARRAY == (storage)->idx_type && H5D_COPS_FARRAY == (storage)->ops) || \ - (H5D_CHUNK_IDX_BT2 == (storage)->idx_type && H5D_COPS_BT2 == (storage)->ops) || \ - (H5D_CHUNK_IDX_BTREE == (storage)->idx_type && H5D_COPS_BTREE == (storage)->ops) || \ - (H5D_CHUNK_IDX_SINGLE == (storage)->idx_type && H5D_COPS_SINGLE == (storage)->ops) || \ +#define H5D_CHUNK_STORAGE_INDEX_CHK(storage) \ + HDassert((H5D_CHUNK_IDX_EARRAY == (storage)->idx_type && H5D_COPS_EARRAY == (storage)->ops) || \ + (H5D_CHUNK_IDX_FARRAY == (storage)->idx_type && H5D_COPS_FARRAY == (storage)->ops) || \ + (H5D_CHUNK_IDX_BT2 == (storage)->idx_type && H5D_COPS_BT2 == (storage)->ops) || \ + (H5D_CHUNK_IDX_BTREE == (storage)->idx_type && H5D_COPS_BTREE == (storage)->ops) || \ + (H5D_CHUNK_IDX_SINGLE == (storage)->idx_type && H5D_COPS_SINGLE == (storage)->ops) || \ (H5D_CHUNK_IDX_NONE == (storage)->idx_type && H5D_COPS_NONE == (storage)->ops)); /* @@ -108,10 +107,10 @@ /*#define H5D_CHUNK_DEBUG */ /* Flags for the "edge_chunk_state" field below */ -#define H5D_RDCC_DISABLE_FILTERS 0x01u /* Disable filters on this chunk */ -#define H5D_RDCC_NEWLY_DISABLED_FILTERS 0x02u /* Filters have been disabled since - * the last flush */ - +#define H5D_RDCC_DISABLE_FILTERS 0x01u /* Disable filters on this chunk */ +#define H5D_RDCC_NEWLY_DISABLED_FILTERS \ + 0x02u /* Filters have been disabled since \ + * the last flush */ /******************/ /* Local Typedefs */ @@ -119,129 +118,130 @@ /* Raw data chunks are cached. Each entry in the cache is: */ typedef struct H5D_rdcc_ent_t { - hbool_t locked; /*entry is locked in cache */ - hbool_t dirty; /*needs to be written to disk? */ - hbool_t deleted; /*chunk about to be deleted */ - unsigned edge_chunk_state; /*states related to edge chunks (see above) */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled chunk 'name' (coordinates) */ - uint32_t rd_count; /*bytes remaining to be read */ - uint32_t wr_count; /*bytes remaining to be written */ - H5F_block_t chunk_block; /*offset/length of chunk in file */ - hsize_t chunk_idx; /*index of chunk in dataset */ - uint8_t *chunk; /*the unfiltered chunk data */ - unsigned idx; /*index in hash table */ - struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list */ - struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list */ - struct H5D_rdcc_ent_t *tmp_next;/*next item in temporary doubly-linked list */ - struct H5D_rdcc_ent_t *tmp_prev;/*previous item in temporary doubly-linked list */ + hbool_t locked; /*entry is locked in cache */ + hbool_t dirty; /*needs to be written to disk? */ + hbool_t deleted; /*chunk about to be deleted */ + unsigned edge_chunk_state; /*states related to edge chunks (see above) */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled chunk 'name' (coordinates) */ + uint32_t rd_count; /*bytes remaining to be read */ + uint32_t wr_count; /*bytes remaining to be written */ + H5F_block_t chunk_block; /*offset/length of chunk in file */ + hsize_t chunk_idx; /*index of chunk in dataset */ + uint8_t * chunk; /*the unfiltered chunk data */ + unsigned idx; /*index in hash table */ + struct H5D_rdcc_ent_t *next; /*next item in doubly-linked list */ + struct H5D_rdcc_ent_t *prev; /*previous item in doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_next; /*next item in temporary doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_prev; /*previous item in temporary doubly-linked list */ } H5D_rdcc_ent_t; typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ /* Callback info for iteration to prune chunks */ typedef struct H5D_chunk_it_ud1_t { - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ - const H5D_chk_idx_info_t *idx_info; /* Chunked index info */ - const H5D_io_info_t *io_info; /* I/O info for dataset operation */ - const hsize_t *space_dim; /* New dataset dimensions */ - const hbool_t *shrunk_dim; /* Dimensions which have been shrunk */ - H5S_t *chunk_space; /* Dataspace for a chunk */ - uint32_t elmts_per_chunk;/* Elements in chunk */ - hsize_t *hyper_start; /* Starting location of hyperslab */ - H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ - hbool_t fb_info_init; /* Whether the fill value buffer has been initialized */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + const H5D_chk_idx_info_t *idx_info; /* Chunked index info */ + const H5D_io_info_t * io_info; /* I/O info for dataset operation */ + const hsize_t * space_dim; /* New dataset dimensions */ + const hbool_t * shrunk_dim; /* Dimensions which have been shrunk */ + H5S_t * chunk_space; /* Dataspace for a chunk */ + uint32_t elmts_per_chunk; /* Elements in chunk */ + hsize_t * hyper_start; /* Starting location of hyperslab */ + H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ + hbool_t fb_info_init; /* Whether the fill value buffer has been initialized */ } H5D_chunk_it_ud1_t; -/* Callback info for iteration to obtain chunk address and the index of the chunk for all chunks in the B-tree. */ +/* Callback info for iteration to obtain chunk address and the index of the chunk for all chunks in the + * B-tree. */ typedef struct H5D_chunk_it_ud2_t { /* down */ - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ /* up */ - haddr_t *chunk_addr; /* Array of chunk addresses to fill in */ + haddr_t *chunk_addr; /* Array of chunk addresses to fill in */ } H5D_chunk_it_ud2_t; /* Callback info for iteration to copy data */ typedef struct H5D_chunk_it_ud3_t { - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ - H5F_t *file_src; /* Source file for copy */ - H5D_chk_idx_info_t *idx_info_dst; /* Dest. chunk index info object */ - void *buf; /* Buffer to hold chunk data for read/write */ - void *bkg; /* Buffer for background information during type conversion */ - size_t buf_size; /* Buffer size */ - hbool_t do_convert; /* Whether to perform type conversions */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + H5F_t * file_src; /* Source file for copy */ + H5D_chk_idx_info_t * idx_info_dst; /* Dest. chunk index info object */ + void * buf; /* Buffer to hold chunk data for read/write */ + void * bkg; /* Buffer for background information during type conversion */ + size_t buf_size; /* Buffer size */ + hbool_t do_convert; /* Whether to perform type conversions */ /* needed for converting variable-length data */ - hid_t tid_src; /* Datatype ID for source datatype */ - hid_t tid_dst; /* Datatype ID for destination datatype */ - hid_t tid_mem; /* Datatype ID for memory datatype */ - const H5T_t *dt_src; /* Source datatype */ - H5T_path_t *tpath_src_mem; /* Datatype conversion path from source file to memory */ - H5T_path_t *tpath_mem_dst; /* Datatype conversion path from memory to dest. file */ - void *reclaim_buf; /* Buffer for reclaiming data */ - size_t reclaim_buf_size; /* Reclaim buffer size */ - uint32_t nelmts; /* Number of elements in buffer */ - H5S_t *buf_space; /* Dataspace describing buffer */ + hid_t tid_src; /* Datatype ID for source datatype */ + hid_t tid_dst; /* Datatype ID for destination datatype */ + hid_t tid_mem; /* Datatype ID for memory datatype */ + const H5T_t *dt_src; /* Source datatype */ + H5T_path_t * tpath_src_mem; /* Datatype conversion path from source file to memory */ + H5T_path_t * tpath_mem_dst; /* Datatype conversion path from memory to dest. file */ + void * reclaim_buf; /* Buffer for reclaiming data */ + size_t reclaim_buf_size; /* Reclaim buffer size */ + uint32_t nelmts; /* Number of elements in buffer */ + H5S_t * buf_space; /* Dataspace describing buffer */ /* needed for compressed variable-length data */ - const H5O_pline_t *pline; /* Filter pipeline */ - unsigned dset_ndims; /* Number of dimensions in dataset */ - const hsize_t *dset_dims; /* Dataset dimensions */ + const H5O_pline_t *pline; /* Filter pipeline */ + unsigned dset_ndims; /* Number of dimensions in dataset */ + const hsize_t * dset_dims; /* Dataset dimensions */ /* needed for copy object pointed by refs */ - H5O_copy_t *cpy_info; /* Copy options */ + H5O_copy_t *cpy_info; /* Copy options */ /* needed for getting raw data from chunk cache */ - hbool_t chunk_in_cache; - uint8_t *chunk; /* the unfiltered chunk data */ + hbool_t chunk_in_cache; + uint8_t *chunk; /* the unfiltered chunk data */ } H5D_chunk_it_ud3_t; /* Callback info for iteration to dump index */ typedef struct H5D_chunk_it_ud4_t { - FILE *stream; /* Output stream */ - hbool_t header_displayed; /* Node's header is displayed? */ - unsigned ndims; /* Number of dimensions for chunk/dataset */ - uint32_t *chunk_dim; /* Chunk dimensions */ + FILE * stream; /* Output stream */ + hbool_t header_displayed; /* Node's header is displayed? */ + unsigned ndims; /* Number of dimensions for chunk/dataset */ + uint32_t *chunk_dim; /* Chunk dimensions */ } H5D_chunk_it_ud4_t; /* Callback info for iteration to format convert chunks */ typedef struct H5D_chunk_it_ud5_t { - H5D_chk_idx_info_t *new_idx_info; /* Dest. chunk index info object */ - unsigned dset_ndims; /* Number of dimensions in dataset */ - hsize_t *dset_dims; /* Dataset dimensions */ + H5D_chk_idx_info_t *new_idx_info; /* Dest. chunk index info object */ + unsigned dset_ndims; /* Number of dimensions in dataset */ + hsize_t * dset_dims; /* Dataset dimensions */ } H5D_chunk_it_ud5_t; /* Callback info for nonexistent readvv operation */ typedef struct H5D_chunk_readvv_ud_t { - unsigned char *rbuf; /* Read buffer to initialize */ - const H5D_t *dset; /* Dataset to operate on */ + unsigned char *rbuf; /* Read buffer to initialize */ + const H5D_t * dset; /* Dataset to operate on */ } H5D_chunk_readvv_ud_t; /* Typedef for chunk info iterator callback */ typedef struct H5D_chunk_info_iter_ud_t { - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset of the chunk */ - hsize_t ndims; /* Number of dimensions in the dataset */ - uint32_t nbytes; /* Size of stored data in the chunk */ - unsigned filter_mask; /* Excluded filters */ - haddr_t chunk_addr; /* Address of the chunk in file */ - hsize_t chunk_idx; /* Chunk index, where the iteration needs to stop */ - hsize_t curr_idx; /* Current index, where the iteration is */ - unsigned idx_hint; /* Index of chunk in cache, if present */ - hbool_t found; /* Whether the chunk was found */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset of the chunk */ + hsize_t ndims; /* Number of dimensions in the dataset */ + uint32_t nbytes; /* Size of stored data in the chunk */ + unsigned filter_mask; /* Excluded filters */ + haddr_t chunk_addr; /* Address of the chunk in file */ + hsize_t chunk_idx; /* Chunk index, where the iteration needs to stop */ + hsize_t curr_idx; /* Current index, where the iteration is */ + unsigned idx_hint; /* Index of chunk in cache, if present */ + hbool_t found; /* Whether the chunk was found */ } H5D_chunk_info_iter_ud_t; /* Callback info for file selection iteration */ typedef struct H5D_chunk_file_iter_ud_t { - H5D_chunk_map_t *fm; /* File->memory chunk mapping info */ + H5D_chunk_map_t *fm; /* File->memory chunk mapping info */ #ifdef H5_HAVE_PARALLEL - const H5D_io_info_t *io_info; /* I/O info for operation */ -#endif /* H5_HAVE_PARALLEL */ + const H5D_io_info_t *io_info; /* I/O info for operation */ +#endif /* H5_HAVE_PARALLEL */ } H5D_chunk_file_iter_ud_t; #ifdef H5_HAVE_PARALLEL /* information to construct a collective I/O operation for filling chunks */ typedef struct H5D_chunk_coll_info_t { - size_t num_io; /* Number of write operations */ - haddr_t *addr; /* array of the file addresses of the write operation */ + size_t num_io; /* Number of write operations */ + haddr_t *addr; /* array of the file addresses of the write operation */ } H5D_chunk_coll_info_t; #endif /* H5_HAVE_PARALLEL */ @@ -252,17 +252,15 @@ typedef struct H5D_chunk_coll_info_t { /* Chunked layout operation callbacks */ static herr_t H5D__chunk_construct(H5F_t *f, H5D_t *dset); static herr_t H5D__chunk_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); -static herr_t H5D__chunk_io_init(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, H5D_chunk_map_t *fm); -static herr_t H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); -static herr_t H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *fm); -static herr_t H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *fm); +static herr_t H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t *fm); +static herr_t H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + H5D_chunk_map_t *fm); +static herr_t H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); +static herr_t H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); static herr_t H5D__chunk_flush(H5D_t *dset); static herr_t H5D__chunk_io_term(const H5D_chunk_map_t *fm); static herr_t H5D__chunk_dest(H5D_t *dset); @@ -275,111 +273,77 @@ static int H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata static int H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); /* "Nonexistent" layout operation callback */ -static ssize_t -H5D__nonexistent_readvv(const H5D_io_info_t *io_info, - size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); +static ssize_t H5D__nonexistent_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, + size_t *chunk_curr_seq, size_t chunk_len_arr[], + hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_offset_arr[]); /* format convert cb */ static int H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); /* Helper routines */ -static herr_t H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, - const hsize_t *curr_dims, const hsize_t *max_dims); -static void *H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline); -static void *H5D__chunk_mem_xfree(void *chk, const void *pline); -static void *H5D__chunk_mem_realloc(void *chk, size_t size, - const H5O_pline_t *pline); -static herr_t H5D__chunk_cinfo_cache_reset(H5D_chunk_cached_t *last); -static herr_t H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, - const H5D_chunk_ud_t *udata); -static hbool_t H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, - H5D_chunk_ud_t *udata); -static herr_t H5D__free_chunk_info(void *item, void *key, void *opdata); -static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm, - const H5D_io_info_t *io_info); -static herr_t H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, - const H5D_io_info_t *io_info); -static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, - const H5D_io_info_t *io_info); +static herr_t H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims, + const hsize_t *max_dims); +static void * H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline); +static void * H5D__chunk_mem_xfree(void *chk, const void *pline); +static void * H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline); +static herr_t H5D__chunk_cinfo_cache_reset(H5D_chunk_cached_t *last); +static herr_t H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *udata); +static hbool_t H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *udata); +static herr_t H5D__free_chunk_info(void *item, void *key, void *opdata); +static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t *io_info); +static herr_t H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t *io_info); +static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t *io_info); static herr_t H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm); -static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm); -static herr_t H5D__chunk_file_cb(void *elem, const H5T_t *type, unsigned ndims, - const hsize_t *coords, void *fm); -static herr_t H5D__chunk_mem_cb(void *elem, const H5T_t *type, unsigned ndims, - const hsize_t *coords, void *fm); +static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm); +static herr_t H5D__chunk_file_cb(void *elem, const H5T_t *type, unsigned ndims, const hsize_t *coords, + void *fm); +static herr_t H5D__chunk_mem_cb(void *elem, const H5T_t *type, unsigned ndims, const hsize_t *coords, + void *fm); static unsigned H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled); -static herr_t H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, - hbool_t reset); -static herr_t H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, - hbool_t flush); -static hbool_t H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, - const uint32_t *chunk_dims, const hsize_t *chunk_scaled, const hsize_t *dset_dims); -static void *H5D__chunk_lock(const H5D_io_info_t *io_info, - H5D_chunk_ud_t *udata, hbool_t relax, hbool_t prev_unfilt_chunk); -static herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, - const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, uint32_t naccessed); -static herr_t H5D__chunk_cache_prune(const H5D_t *dset, size_t size); -static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk); +static herr_t H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset); +static herr_t H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush); +static hbool_t H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims, + const hsize_t *chunk_scaled, const hsize_t *dset_dims); +static void * H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax, + hbool_t prev_unfilt_chunk); +static herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbool_t dirty, + void *chunk, uint32_t naccessed); +static herr_t H5D__chunk_cache_prune(const H5D_t *dset, size_t size); +static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk); #ifdef H5_HAVE_PARALLEL -static herr_t H5D__chunk_collective_fill(const H5D_t *dset, - H5D_chunk_coll_info_t *chunk_info, size_t chunk_size, const void *fill_buf); -static int H5D__chunk_cmp_addr(const void *addr1, const void *addr2); +static herr_t H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, + size_t chunk_size, const void *fill_buf); +static int H5D__chunk_cmp_addr(const void *addr1, const void *addr2); #endif /* H5_HAVE_PARALLEL */ -static int -H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); +static int H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); /*********************/ /* Package Variables */ /*********************/ /* Chunked storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {{ - H5D__chunk_construct, - H5D__chunk_init, - H5D__chunk_is_space_alloc, - H5D__chunk_is_data_cached, - H5D__chunk_io_init, - H5D__chunk_read, - H5D__chunk_write, +const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = { + {H5D__chunk_construct, H5D__chunk_init, H5D__chunk_is_space_alloc, H5D__chunk_is_data_cached, + H5D__chunk_io_init, H5D__chunk_read, H5D__chunk_write, #ifdef H5_HAVE_PARALLEL - H5D__chunk_collective_read, - H5D__chunk_collective_write, + H5D__chunk_collective_read, H5D__chunk_collective_write, #endif /* H5_HAVE_PARALLEL */ - NULL, - NULL, - H5D__chunk_flush, - H5D__chunk_io_term, - H5D__chunk_dest -}}; - + NULL, NULL, H5D__chunk_flush, H5D__chunk_io_term, H5D__chunk_dest}}; /*******************/ /* Local Variables */ /*******************/ /* "nonexistent" storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = {{ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, +const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = {{NULL, NULL, NULL, NULL, NULL, NULL, NULL, #ifdef H5_HAVE_PARALLEL - NULL, - NULL, + NULL, NULL, #endif /* H5_HAVE_PARALLEL */ - H5D__nonexistent_readvv, - NULL, - NULL, - NULL, - NULL -}}; + H5D__nonexistent_readvv, NULL, NULL, NULL, NULL}}; /* Declare a free list to manage the H5F_rdcc_ent_ptr_t sequence information */ H5FL_SEQ_DEFINE_STATIC(H5D_rdcc_ent_ptr_t); @@ -396,7 +360,6 @@ H5FL_BLK_DEFINE_STATIC(chunk); /* Declare extern free list to manage the H5S_sel_iter_t struct */ H5FL_EXTERN(H5S_sel_iter_t); - /*------------------------------------------------------------------------- * Function: H5D__chunk_direct_write * @@ -410,16 +373,16 @@ H5FL_EXTERN(H5S_sel_iter_t); *------------------------------------------------------------------------- */ herr_t -H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, - uint32_t data_size, const void *buf) +H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, uint32_t data_size, + const void *buf) { - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - H5F_block_t old_chunk; /* Offset/length of old chunk */ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + H5F_block_t old_chunk; /* Offset/length of old chunk */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -427,14 +390,14 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, HDassert(layout->type == H5D_CHUNKED); /* Allocate dataspace and initialize it if it hasn't been. */ - if(!H5D__chunk_is_space_alloc(&layout->storage)) { - H5D_io_info_t io_info; /* to hold the dset info */ + if (!H5D__chunk_is_space_alloc(&layout->storage)) { + H5D_io_info_t io_info; /* to hold the dset info */ io_info.dset = dset; io_info.f_sh = H5F_SHARED(dset->oloc.file); /* Allocate storage */ - if(H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, FALSE, NULL) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") } @@ -443,12 +406,12 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, scaled[dset->shared->ndims] = 0; /* Find out the file address of the chunk (if any) */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ HDassert((H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length > 0) || - (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); /* Set the file block information for the old chunk */ /* (Which is only defined when overwriting an existing chunk) */ @@ -460,22 +423,22 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, */ /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &(dset->shared->dcpl_cache.pline); - idx_info.layout = &(dset->shared->layout.u.chunk); + idx_info.f = dset->oloc.file; + idx_info.pline = &(dset->shared->dcpl_cache.pline); + idx_info.layout = &(dset->shared->layout.u.chunk); idx_info.storage = &(dset->shared->layout.storage.u.chunk); /* Set up the size of chunk for user data */ udata.chunk_block.length = data_size; - if(0 == idx_info.pline->nused && H5F_addr_defined(old_chunk.offset)) + if (0 == idx_info.pline->nused && H5F_addr_defined(old_chunk.offset)) /* If there are no filters and we are overwriting the chunk we can just set values */ need_insert = FALSE; else { /* Otherwise, create the chunk it if it doesn't exist, or reallocate the chunk * if its size has changed. */ - if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert, scaled) < 0) + if (H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert, scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") /* Cache the new chunk information */ @@ -483,28 +446,29 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, } /* end else */ /* Make sure the address of the chunk is returned. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) + if (!H5F_addr_defined(udata.chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk address isn't defined") /* Evict the (old) entry from the cache if present, but do not flush * it to disk */ - if(UINT_MAX != udata.idx_hint) { - const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ + if (UINT_MAX != udata.idx_hint) { + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ - if(H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], FALSE) < 0) + if (H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") } /* end if */ /* Write the data to the file */ - if(H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, data_size, buf) < 0) + if (H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, + data_size, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data to file") /* Insert the chunk record into the index */ - if(need_insert && layout->storage.u.chunk.ops->insert) { + if (need_insert && layout->storage.u.chunk.ops->insert) { /* Set the chunk's filter mask to the new settings */ udata.filter_mask = filters; - if((layout->storage.u.chunk.ops->insert)(&idx_info, &udata, dset) < 0) + if ((layout->storage.u.chunk.ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") } /* end if */ @@ -512,7 +476,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__chunk_direct_write() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_direct_read * @@ -526,14 +489,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, - void *buf) +H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t *filters, void *buf) { - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + const H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -546,8 +508,7 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, *filters = 0; /* Allocate dataspace and initialize it if it hasn't been. */ - if(!H5D__chunk_is_space_alloc(&layout->storage) - && !H5D__chunk_is_data_cached(dset->shared)) + if (!H5D__chunk_is_space_alloc(&layout->storage) && !H5D__chunk_is_data_cached(dset->shared)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "storage is not initialized") /* Calculate the index of this chunk */ @@ -555,23 +516,23 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, scaled[dset->shared->ndims] = 0; /* Reset fields about the chunk we are looking for */ - udata.filter_mask = 0; + udata.filter_mask = 0; udata.chunk_block.offset = HADDR_UNDEF; udata.chunk_block.length = 0; - udata.idx_hint = UINT_MAX; + udata.idx_hint = UINT_MAX; /* Find out the file address of the chunk */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ HDassert((H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length > 0) || - (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); /* Check if the requested chunk exists in the chunk cache */ - if(UINT_MAX != udata.idx_hint) { + if (UINT_MAX != udata.idx_hint) { H5D_rdcc_ent_t *ent = rdcc->slot[udata.idx_hint]; - hbool_t flush; + hbool_t flush; /* Sanity checks */ HDassert(udata.idx_hint < rdcc->nslots); @@ -580,26 +541,27 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, flush = (ent->dirty == TRUE) ? TRUE : FALSE; /* Flush the chunk to disk and clear the cache entry */ - if(H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], flush) < 0) + if (H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], flush) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") /* Reset fields about the chunk we are looking for */ - udata.filter_mask = 0; + udata.filter_mask = 0; udata.chunk_block.offset = HADDR_UNDEF; udata.chunk_block.length = 0; - udata.idx_hint = UINT_MAX; + udata.idx_hint = UINT_MAX; /* Get the new file address / chunk size after flushing */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") } /* Make sure the address of the chunk is returned. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) + if (!H5F_addr_defined(udata.chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined") /* Read the chunk data into the supplied buffer */ - if(H5F_shared_block_read(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, udata.chunk_block.length, buf) < 0) + if (H5F_shared_block_read(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, + udata.chunk_block.length, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") /* Return the filter mask */ @@ -609,7 +571,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__chunk_direct_read() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_storage_size * @@ -625,11 +586,11 @@ done: herr_t H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage_size) { - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + const H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -641,7 +602,7 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage *storage_size = 0; /* Allocate dataspace and initialize it if it hasn't been. */ - if(!(*layout->ops->is_space_alloc)(&layout->storage)) + if (!(*layout->ops->is_space_alloc)(&layout->storage)) HGOTO_DONE(SUCCEED) /* Calculate the index of this chunk */ @@ -651,24 +612,24 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage /* Reset fields about the chunk we are looking for */ udata.chunk_block.offset = HADDR_UNDEF; udata.chunk_block.length = 0; - udata.idx_hint = UINT_MAX; + udata.idx_hint = UINT_MAX; /* Find out the file address of the chunk */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ HDassert((H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length > 0) || - (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); /* The requested chunk is not in cache or on disk */ - if(!H5F_addr_defined(udata.chunk_block.offset) && UINT_MAX == udata.idx_hint) + if (!H5F_addr_defined(udata.chunk_block.offset) && UINT_MAX == udata.idx_hint) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk storage is not allocated") /* Check if there are filters registered to the dataset */ - if( dset->shared->dcpl_cache.pline.nused > 0 ) { + if (dset->shared->dcpl_cache.pline.nused > 0) { /* Check if the requested chunk exists in the chunk cache */ - if(UINT_MAX != udata.idx_hint) { + if (UINT_MAX != udata.idx_hint) { H5D_rdcc_ent_t *ent = rdcc->slot[udata.idx_hint]; /* Sanity checks */ @@ -676,24 +637,24 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage HDassert(rdcc->slot[udata.idx_hint]); /* If the cached chunk is dirty, it must be flushed to get accurate size */ - if( ent->dirty == TRUE ) { + if (ent->dirty == TRUE) { /* Flush the chunk to disk and clear the cache entry */ - if(H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], TRUE) < 0) + if (H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") /* Reset fields about the chunk we are looking for */ udata.chunk_block.offset = HADDR_UNDEF; udata.chunk_block.length = 0; - udata.idx_hint = UINT_MAX; + udata.idx_hint = UINT_MAX; /* Get the new file address / chunk size after flushing */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") } } /* Make sure the address of the chunk is returned. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) + if (!H5F_addr_defined(udata.chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined") /* Return the chunk size on disk */ @@ -707,7 +668,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5D__get_chunk_storage_size */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_set_info_real * @@ -721,11 +681,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, - const hsize_t *curr_dims, const hsize_t *max_dims) +H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims, + const hsize_t *max_dims) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -735,15 +695,14 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, HDassert(curr_dims); /* Compute the # of chunks in dataset dimensions */ - for(u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { + for (u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { /* Round up to the next integer # of chunks, to accommodate partial chunks */ layout->chunks[u] = ((curr_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; - if(H5S_UNLIMITED == max_dims[u]) + if (H5S_UNLIMITED == max_dims[u]) layout->max_chunks[u] = H5S_UNLIMITED; - else - { + else { /* Sanity check */ - if(layout->dim[u] == 0) + if (layout->dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dimension size must be > 0, dim = %u ", u) layout->max_chunks[u] = ((max_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; @@ -755,16 +714,15 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, } /* end for */ /* Get the "down" sizes for each dimension */ - if(H5VM_array_down(ndims, layout->chunks, layout->down_chunks) < 0) + if (H5VM_array_down(ndims, layout->chunks, layout->down_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") - if(H5VM_array_down(ndims, layout->max_chunks, layout->max_down_chunks) < 0) + if (H5VM_array_down(ndims, layout->max_chunks, layout->max_down_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_set_info_real() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_set_info * @@ -780,7 +738,7 @@ done: herr_t H5D__chunk_set_info(const H5D_t *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -788,18 +746,19 @@ H5D__chunk_set_info(const H5D_t *dset) HDassert(dset); /* Set the base layout information */ - if(H5D__chunk_set_info_real(&dset->shared->layout.u.chunk, dset->shared->ndims, dset->shared->curr_dims, dset->shared->max_dims) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") + if (H5D__chunk_set_info_real(&dset->shared->layout.u.chunk, dset->shared->ndims, dset->shared->curr_dims, + dset->shared->max_dims) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") /* Call the index's "resize" callback */ - if(dset->shared->layout.storage.u.chunk.ops->resize && (dset->shared->layout.storage.u.chunk.ops->resize)(&dset->shared->layout.u.chunk) < 0) + if (dset->shared->layout.storage.u.chunk.ops->resize && + (dset->shared->layout.storage.u.chunk.ops->resize)(&dset->shared->layout.u.chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to resize chunk index information") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_set_info() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_set_sizes * @@ -818,7 +777,7 @@ H5D__chunk_set_sizes(H5D_t *dset) uint64_t chunk_size; /* Size of chunk in bytes */ unsigned max_enc_bytes_per_dim; /* Max. number of bytes required to encode this dimension */ unsigned u; /* Iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -829,18 +788,19 @@ H5D__chunk_set_sizes(H5D_t *dset) dset->shared->layout.u.chunk.ndims++; /* Set the last dimension of the chunk size to the size of the datatype */ - dset->shared->layout.u.chunk.dim[dset->shared->layout.u.chunk.ndims - 1] = (uint32_t)H5T_GET_SIZE(dset->shared->type); + dset->shared->layout.u.chunk.dim[dset->shared->layout.u.chunk.ndims - 1] = + (uint32_t)H5T_GET_SIZE(dset->shared->type); /* Compute number of bytes to use for encoding chunk dimensions */ max_enc_bytes_per_dim = 0; - for(u = 0; u < (unsigned)dset->shared->layout.u.chunk.ndims; u++) { - unsigned enc_bytes_per_dim; /* Number of bytes required to encode this dimension */ + for (u = 0; u < (unsigned)dset->shared->layout.u.chunk.ndims; u++) { + unsigned enc_bytes_per_dim; /* Number of bytes required to encode this dimension */ /* Get encoded size of dim, in bytes */ enc_bytes_per_dim = (H5VM_log2_gen(dset->shared->layout.u.chunk.dim[u]) + 8) / 8; /* Check if this is the largest value so far */ - if(enc_bytes_per_dim > max_enc_bytes_per_dim) + if (enc_bytes_per_dim > max_enc_bytes_per_dim) max_enc_bytes_per_dim = enc_bytes_per_dim; } /* end for */ HDassert(max_enc_bytes_per_dim > 0 && max_enc_bytes_per_dim <= 8); @@ -848,12 +808,13 @@ H5D__chunk_set_sizes(H5D_t *dset) /* Compute and store the total size of a chunk */ /* (Use 64-bit value to ensure that we can detect >4GB chunks) */ - for(u = 1, chunk_size = (uint64_t)dset->shared->layout.u.chunk.dim[0]; u < dset->shared->layout.u.chunk.ndims; u++) + for (u = 1, chunk_size = (uint64_t)dset->shared->layout.u.chunk.dim[0]; + u < dset->shared->layout.u.chunk.ndims; u++) chunk_size *= (uint64_t)dset->shared->layout.u.chunk.dim[u]; /* Check for chunk larger than can be represented in 32-bits */ /* (Chunk size is encoded in 32-bit value in v1 B-tree records) */ - if(chunk_size > (uint64_t)0xffffffff) + if (chunk_size > (uint64_t)0xffffffff) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "chunk size must be < 4GB") H5_CHECKED_ASSIGN(dset->shared->layout.u.chunk.size, uint32_t, chunk_size, uint64_t); @@ -862,7 +823,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_set_sizes */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_construct * @@ -878,8 +838,8 @@ done: static herr_t H5D__chunk_construct(H5F_t H5_ATTR_UNUSED *f, H5D_t *dset) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -888,24 +848,24 @@ H5D__chunk_construct(H5F_t H5_ATTR_UNUSED *f, H5D_t *dset) HDassert(dset); /* Check for invalid chunk dimension rank */ - if(0 == dset->shared->layout.u.chunk.ndims) + if (0 == dset->shared->layout.u.chunk.ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "no chunk information set?") - if(dset->shared->layout.u.chunk.ndims != dset->shared->ndims) + if (dset->shared->layout.u.chunk.ndims != dset->shared->ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dimensionality of chunks doesn't match the dataspace") /* Set chunk sizes */ - if(H5D__chunk_set_sizes(dset) < 0) + if (H5D__chunk_set_sizes(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to set chunk sizes") HDassert((unsigned)(dset->shared->layout.u.chunk.ndims) <= NELMTS(dset->shared->layout.u.chunk.dim)); /* Chunked storage is not compatible with external storage (currently) */ - if(dset->shared->dcpl_cache.efl.nused > 0) + if (dset->shared->dcpl_cache.efl.nused > 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "external storage not supported with chunked layout") /* Sanity check dimensions */ - for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) { + for (u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) { /* Don't allow zero-sized chunk dimensions */ - if(0 == dset->shared->layout.u.chunk.dim[u]) + if (0 == dset->shared->layout.u.chunk.dim[u]) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "chunk size must be > 0, dim = %u ", u) /* @@ -913,19 +873,20 @@ H5D__chunk_construct(H5F_t H5_ATTR_UNUSED *f, H5D_t *dset) * the maximum dimension size. If any dimension size is zero, there * will be no such restriction. */ - if(dset->shared->curr_dims[u] && dset->shared->max_dims[u] != H5S_UNLIMITED && dset->shared->max_dims[u] < dset->shared->layout.u.chunk.dim[u]) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "chunk size must be <= maximum dimension size for fixed-sized dimensions") + if (dset->shared->curr_dims[u] && dset->shared->max_dims[u] != H5S_UNLIMITED && + dset->shared->max_dims[u] < dset->shared->layout.u.chunk.dim[u]) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "chunk size must be <= maximum dimension size for fixed-sized dimensions") } /* end for */ /* Reset address and pointer of the array struct for the chunked storage index */ - if(H5D_chunk_idx_reset(&dset->shared->layout.storage.u.chunk, TRUE) < 0) + if (H5D_chunk_idx_reset(&dset->shared->layout.storage.u.chunk, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_construct() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_init * @@ -940,13 +901,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) +H5D__chunk_init(H5F_t *f, const H5D_t *const dset, hid_t dapl_id) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ - H5P_genplist_t *dapl; /* Data access property list object pointer */ - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ + H5P_genplist_t * dapl; /* Data access property list object pointer */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -955,31 +916,31 @@ H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) HDassert(dset); H5D_CHUNK_STORAGE_INDEX_CHK(sc); - if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + if (NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for fapl ID") /* Use the properties in dapl_id if they have been set, otherwise use the properties from the file */ - if(H5P_get(dapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc->nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots") - if(rdcc->nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) + if (H5P_get(dapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc->nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache number of slots") + if (rdcc->nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) rdcc->nslots = H5F_RDCC_NSLOTS(f); - if(H5P_get(dapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc->nbytes_max) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size") - if(rdcc->nbytes_max == H5D_CHUNK_CACHE_NBYTES_DEFAULT) + if (H5P_get(dapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc->nbytes_max) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache byte size") + if (rdcc->nbytes_max == H5D_CHUNK_CACHE_NBYTES_DEFAULT) rdcc->nbytes_max = H5F_RDCC_NBYTES(f); - if(H5P_get(dapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc->w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks") - if(rdcc->w0 < 0) + if (H5P_get(dapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc->w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get preempt read chunks") + if (rdcc->w0 < 0) rdcc->w0 = H5F_RDCC_W0(f); /* If nbytes_max or nslots is 0, set them both to 0 and avoid allocating space */ - if(!rdcc->nbytes_max || !rdcc->nslots) + if (!rdcc->nbytes_max || !rdcc->nslots) rdcc->nbytes_max = rdcc->nslots = 0; else { rdcc->slot = H5FL_SEQ_CALLOC(H5D_rdcc_ent_ptr_t, rdcc->nslots); - if(NULL == rdcc->slot) + if (NULL == rdcc->slot) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Reset any cached chunk info for this dataset */ @@ -987,21 +948,21 @@ H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) } /* end else */ /* Compute scaled dimension info, if dataset dims > 1 */ - if(dset->shared->ndims > 1) { - unsigned u; /* Local index value */ + if (dset->shared->ndims > 1) { + unsigned u; /* Local index value */ - for(u = 0; u < dset->shared->ndims; u++) { - hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ + for (u = 0; u < dset->shared->ndims; u++) { + hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ /* Initial scaled dimension sizes */ - if(dset->shared->layout.u.chunk.dim[u] == 0) + if (dset->shared->layout.u.chunk.dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) /* Round up to the next integer # of chunks, to accommodate partial chunks */ rdcc->scaled_dims[u] = (dset->shared->curr_dims[u] + dset->shared->layout.u.chunk.dim[u] - 1) / - dset->shared->layout.u.chunk.dim[u]; + dset->shared->layout.u.chunk.dim[u]; - if( !(scaled_power2up = H5VM_power2up(rdcc->scaled_dims[u])) ) + if (!(scaled_power2up = H5VM_power2up(rdcc->scaled_dims[u]))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get the next power of 2") /* Inital 'power2up' values for scaled dimensions */ @@ -1010,27 +971,26 @@ H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) /* Number of bits required to encode scaled dimension size */ rdcc->scaled_encode_bits[u] = H5VM_log2_gen(rdcc->scaled_power2up[u]); } /* end for */ - } /* end if */ + } /* end if */ /* Compose chunked index info struct */ - idx_info.f = f; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = f; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Allocate any indexing structures */ - if(sc->ops->init && (sc->ops->init)(&idx_info, dset->shared->space, dset->oloc.addr) < 0) + if (sc->ops->init && (sc->ops->init)(&idx_info, dset->shared->space, dset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") /* Set the number of chunks in dataset, etc. */ - if(H5D__chunk_set_info(dset) < 0) + if (H5D__chunk_set_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set # of chunks for dataset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_init() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_is_space_alloc * @@ -1046,8 +1006,8 @@ done: hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage) { - const H5O_storage_chunk_t *sc = &(storage->u.chunk); - hbool_t ret_value = FALSE; /* Return value */ + const H5O_storage_chunk_t *sc = &(storage->u.chunk); + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -1061,7 +1021,6 @@ H5D__chunk_is_space_alloc(const H5O_storage_t *storage) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_is_data_cached * @@ -1085,7 +1044,6 @@ H5D__chunk_is_data_cached(const H5D_shared_t *shared_dset) FUNC_LEAVE_NOAPI(shared_dset->cache.chunk.nused > 0) } /* end H5D__chunk_is_data_cached() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_io_init * @@ -1099,17 +1057,16 @@ H5D__chunk_is_data_cached(const H5D_shared_t *shared_dset) *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *fm) +H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm) { - const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ - hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset */ - htri_t file_space_normalized = FALSE; /* File dataspace was normalized */ - unsigned f_ndims; /* The number of dimensions of the file's dataspace */ - int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ + hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset */ + htri_t file_space_normalized = FALSE; /* File dataspace was normalized */ + unsigned f_ndims; /* The number of dimensions of the file's dataspace */ + int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1118,7 +1075,7 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf fm->nelmts = nelmts; /* Check if the memory space is scalar & make equivalent memory space */ - if((sm_ndims = H5S_GET_EXTENT_NDIMS(mem_space)) < 0) + if ((sm_ndims = H5S_GET_EXTENT_NDIMS(mem_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimension number") /* Set the number of dimensions for the memory dataspace */ H5_CHECKED_ASSIGN(fm->m_ndims, unsigned, sm_ndims, int); @@ -1132,50 +1089,50 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf * speed up hyperslab calculations by removing the extra checks and/or * additions involving the offset and the hyperslab selection -QAK) */ - if((file_space_normalized = H5S_hyper_normalize_offset((H5S_t *)file_space, old_offset)) < 0) + if ((file_space_normalized = H5S_hyper_normalize_offset((H5S_t *)file_space, old_offset)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to normalize selection") /* Decide the number of chunks in each dimension */ - for(u = 0; u < f_ndims; u++) + for (u = 0; u < f_ndims; u++) /* Keep the size of the chunk dimensions as hsize_t for various routines */ fm->chunk_dim[u] = fm->layout->u.chunk.dim[u]; #ifdef H5_HAVE_PARALLEL /* Calculate total chunk in file map*/ fm->select_chunk = NULL; - if(io_info->using_mpi_vfd) { + if (io_info->using_mpi_vfd) { H5_CHECK_OVERFLOW(fm->layout->u.chunk.nchunks, hsize_t, size_t); - if(fm->layout->u.chunk.nchunks) - if(NULL == (fm->select_chunk = (H5D_chunk_info_t **)H5MM_calloc((size_t)fm->layout->u.chunk.nchunks * sizeof(H5D_chunk_info_t *)))) + if (fm->layout->u.chunk.nchunks) + if (NULL == (fm->select_chunk = (H5D_chunk_info_t **)H5MM_calloc( + (size_t)fm->layout->u.chunk.nchunks * sizeof(H5D_chunk_info_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ - /* Initialize "last chunk" information */ - fm->last_index = (hsize_t)-1; + fm->last_index = (hsize_t)-1; fm->last_chunk_info = NULL; /* Point at the dataspaces */ fm->file_space = file_space; - fm->mem_space = mem_space; + fm->mem_space = mem_space; - if(H5D__chunk_io_init_selections(io_info, type_info, fm) < 0) + if (H5D__chunk_io_init_selections(io_info, type_info, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file and memory chunk selections") done: /* Reset the global dataspace info */ fm->file_space = NULL; - fm->mem_space = NULL; + fm->mem_space = NULL; - if(file_space_normalized == TRUE) - if(H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset) < 0) /* (Casting away const OK -QAK) */ + if (file_space_normalized == TRUE) + if (H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset) < + 0) /* (Casting away const OK -QAK) */ HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't denormalize selection") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_io_init() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_io_init_selections * @@ -1189,49 +1146,50 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm) +H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + H5D_chunk_map_t *fm) { - const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ - const H5T_t *mem_type = type_info->mem_type; /* Local pointer to memory datatype */ - H5S_t *tmp_mspace = NULL; /* Temporary memory dataspace */ - H5T_t *file_type = NULL; /* Temporary copy of file datatype for iteration */ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ - char bogus; /* "bogus" buffer to pass to selection iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ + const H5T_t *mem_type = type_info->mem_type; /* Local pointer to memory datatype */ + H5S_t * tmp_mspace = NULL; /* Temporary memory dataspace */ + H5T_t * file_type = NULL; /* Temporary copy of file datatype for iteration */ + hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ + char bogus; /* "bogus" buffer to pass to selection iterator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Special case for only one element in selection */ /* (usually appending a record) */ - if(fm->nelmts == 1 + if (fm->nelmts == 1 #ifdef H5_HAVE_PARALLEL - && !(io_info->using_mpi_vfd) + && !(io_info->using_mpi_vfd) #endif /* H5_HAVE_PARALLEL */ - && H5S_SEL_ALL != H5S_GET_SELECT_TYPE(fm->file_space)) { + && H5S_SEL_ALL != H5S_GET_SELECT_TYPE(fm->file_space)) { /* Initialize skip list for chunk selections */ fm->sel_chunks = NULL; fm->use_single = TRUE; /* Initialize single chunk dataspace */ - if(NULL == dataset->shared->cache.chunk.single_space) { + if (NULL == dataset->shared->cache.chunk.single_space) { /* Make a copy of the dataspace for the dataset */ - if((dataset->shared->cache.chunk.single_space = H5S_copy(fm->file_space, TRUE, FALSE)) == NULL) + if ((dataset->shared->cache.chunk.single_space = H5S_copy(fm->file_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file space") /* Resize chunk's dataspace dimensions to size of chunk */ - if(H5S_set_extent_real(dataset->shared->cache.chunk.single_space, fm->chunk_dim) < 0) + if (H5S_set_extent_real(dataset->shared->cache.chunk.single_space, fm->chunk_dim) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust chunk dimensions") /* Set the single chunk dataspace to 'all' selection */ - if(H5S_select_all(dataset->shared->cache.chunk.single_space, TRUE) < 0) + if (H5S_select_all(dataset->shared->cache.chunk.single_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "unable to set all selection") } /* end if */ fm->single_space = dataset->shared->cache.chunk.single_space; HDassert(fm->single_space); /* Allocate the single chunk information */ - if(NULL == dataset->shared->cache.chunk.single_chunk_info) - if(NULL == (dataset->shared->cache.chunk.single_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) + if (NULL == dataset->shared->cache.chunk.single_chunk_info) + if (NULL == (dataset->shared->cache.chunk.single_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") fm->single_chunk_info = dataset->shared->cache.chunk.single_chunk_info; HDassert(fm->single_chunk_info); @@ -1240,15 +1198,16 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ fm->mchunk_tmpl = NULL; /* Set up chunk mapping for single element */ - if(H5D__create_chunk_map_single(fm, io_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create chunk selections for single element") + if (H5D__create_chunk_map_single(fm, io_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to create chunk selections for single element") } /* end if */ else { - hbool_t sel_hyper_flag; /* Whether file selection is a hyperslab */ + hbool_t sel_hyper_flag; /* Whether file selection is a hyperslab */ /* Initialize skip list for chunk selections */ - if(NULL == dataset->shared->cache.chunk.sel_chunks) - if(NULL == (dataset->shared->cache.chunk.sel_chunks = H5SL_create(H5SL_TYPE_HSIZE, NULL))) + if (NULL == dataset->shared->cache.chunk.sel_chunks) + if (NULL == (dataset->shared->cache.chunk.sel_chunks = H5SL_create(H5SL_TYPE_HSIZE, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for chunk selections") fm->sel_chunks = dataset->shared->cache.chunk.sel_chunks; HDassert(fm->sel_chunks); @@ -1257,38 +1216,38 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ fm->use_single = FALSE; /* Get type of selection on disk & in memory */ - if((fm->fsel_type = H5S_GET_SELECT_TYPE(fm->file_space)) < H5S_SEL_NONE) + if ((fm->fsel_type = H5S_GET_SELECT_TYPE(fm->file_space)) < H5S_SEL_NONE) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to get type of selection") - if((fm->msel_type = H5S_GET_SELECT_TYPE(fm->mem_space)) < H5S_SEL_NONE) + if ((fm->msel_type = H5S_GET_SELECT_TYPE(fm->mem_space)) < H5S_SEL_NONE) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to get type of selection") /* If the selection is NONE or POINTS, set the flag to FALSE */ - if(fm->fsel_type == H5S_SEL_POINTS || fm->fsel_type == H5S_SEL_NONE) + if (fm->fsel_type == H5S_SEL_POINTS || fm->fsel_type == H5S_SEL_NONE) sel_hyper_flag = FALSE; else sel_hyper_flag = TRUE; /* Check if file selection is a not a hyperslab selection */ - if(sel_hyper_flag) { + if (sel_hyper_flag) { /* Build the file selection for each chunk */ - if(H5S_SEL_ALL == fm->fsel_type) { - if(H5D__create_chunk_file_map_all(fm, io_info) < 0) + if (H5S_SEL_ALL == fm->fsel_type) { + if (H5D__create_chunk_file_map_all(fm, io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") } /* end if */ else { /* Sanity check */ HDassert(fm->fsel_type == H5S_SEL_HYPERSLABS); - if(H5D__create_chunk_file_map_hyper(fm, io_info) < 0) + if (H5D__create_chunk_file_map_hyper(fm, io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") } /* end else */ - } /* end if */ + } /* end if */ else { - H5S_sel_iter_op_t iter_op; /* Operator for iteration */ - H5D_chunk_file_iter_ud_t udata; /* User data for iteration */ + H5S_sel_iter_op_t iter_op; /* Operator for iteration */ + H5D_chunk_file_iter_ud_t udata; /* User data for iteration */ /* Create temporary datatypes for selection iteration */ - if(NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) + if (NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy file datatype") /* Initialize the user data */ @@ -1297,89 +1256,89 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ udata.io_info = io_info; #endif /* H5_HAVE_PARALLEL */ - iter_op.op_type = H5S_SEL_ITER_OP_LIB; + iter_op.op_type = H5S_SEL_ITER_OP_LIB; iter_op.u.lib_op = H5D__chunk_file_cb; /* Spaces might not be the same shape, iterate over the file selection directly */ - if(H5S_select_iterate(&bogus, file_type, fm->file_space, &iter_op, &udata) < 0) + if (H5S_select_iterate(&bogus, file_type, fm->file_space, &iter_op, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") /* Reset "last chunk" info */ - fm->last_index = (hsize_t)-1; + fm->last_index = (hsize_t)-1; fm->last_chunk_info = NULL; } /* end else */ /* Build the memory selection for each chunk */ - if(sel_hyper_flag && H5S_SELECT_SHAPE_SAME(fm->file_space, fm->mem_space) == TRUE) { + if (sel_hyper_flag && H5S_SELECT_SHAPE_SAME(fm->file_space, fm->mem_space) == TRUE) { /* Reset chunk template information */ fm->mchunk_tmpl = NULL; /* If the selections are the same shape, use the file chunk information * to generate the memory chunk information quickly. */ - if(H5D__create_chunk_mem_map_hyper(fm) < 0) + if (H5D__create_chunk_mem_map_hyper(fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") } /* end if */ - else if(sel_hyper_flag && fm->f_ndims == 1 && fm->m_ndims == 1 && - H5S_SELECT_IS_REGULAR(fm->mem_space) && H5S_SELECT_IS_SINGLE(fm->mem_space)) { - if(H5D__create_chunk_mem_map_1d(fm) < 0) + else if (sel_hyper_flag && fm->f_ndims == 1 && fm->m_ndims == 1 && + H5S_SELECT_IS_REGULAR(fm->mem_space) && H5S_SELECT_IS_SINGLE(fm->mem_space)) { + if (H5D__create_chunk_mem_map_1d(fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") } /* end else-if */ else { - H5S_sel_iter_op_t iter_op; /* Operator for iteration */ - size_t elmt_size; /* Memory datatype size */ + H5S_sel_iter_op_t iter_op; /* Operator for iteration */ + size_t elmt_size; /* Memory datatype size */ /* Make a copy of equivalent memory space */ - if((tmp_mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) + if ((tmp_mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") /* De-select the mem space copy */ - if(H5S_select_none(tmp_mspace) < 0) + if (H5S_select_none(tmp_mspace) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to de-select memory space") /* Save chunk template information */ fm->mchunk_tmpl = tmp_mspace; /* Create temporary datatypes for selection iteration */ - if(!file_type) - if(NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) + if (!file_type) + if (NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy file datatype") /* Create selection iterator for memory selection */ - if(0 == (elmt_size = H5T_get_size(mem_type))) + if (0 == (elmt_size = H5T_get_size(mem_type))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid") - if(H5S_select_iter_init(&(fm->mem_iter), fm->mem_space, elmt_size, 0) < 0) + if (H5S_select_iter_init(&(fm->mem_iter), fm->mem_space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - iter_init = TRUE; /* Selection iteration info has been initialized */ + iter_init = TRUE; /* Selection iteration info has been initialized */ - iter_op.op_type = H5S_SEL_ITER_OP_LIB; + iter_op.op_type = H5S_SEL_ITER_OP_LIB; iter_op.u.lib_op = H5D__chunk_mem_cb; /* Spaces aren't the same shape, iterate over the memory selection directly */ - if(H5S_select_iterate(&bogus, file_type, fm->file_space, &iter_op, fm) < 0) + if (H5S_select_iterate(&bogus, file_type, fm->file_space, &iter_op, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") } /* end else */ - } /* end else */ + } /* end else */ done: /* Release the [potentially partially built] chunk mapping information if an error occurs */ - if(ret_value < 0) { - if(tmp_mspace && !fm->mchunk_tmpl) - if(H5S_close(tmp_mspace) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") - if(H5D__chunk_io_term(fm) < 0) + if (ret_value < 0) { + if (tmp_mspace && !fm->mchunk_tmpl) + if (H5S_close(tmp_mspace) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, + "can't release memory chunk dataspace template") + if (H5D__chunk_io_term(fm) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping") } /* end if */ - if(iter_init && H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(file_type && (H5T_close_real(file_type) < 0)) + if (file_type && (H5T_close_real(file_type) < 0)) HDONE_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Can't free temporary datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_io_init_selections() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_alloc * @@ -1397,13 +1356,13 @@ done: static void * H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(size); - if(pline && pline->nused) + if (pline && pline->nused) ret_value = H5MM_malloc(size); else ret_value = H5FL_BLK_MALLOC(chunk, size); @@ -1411,7 +1370,6 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_mem_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_xfree * @@ -1433,8 +1391,8 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline) FUNC_ENTER_STATIC_NOERR - if(chk) { - if(pline && pline->nused) + if (chk) { + if (pline && pline->nused) H5MM_xfree(chk); else chk = H5FL_BLK_FREE(chunk, chk); @@ -1443,7 +1401,6 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline) FUNC_LEAVE_NOAPI(NULL) } /* H5D__chunk_mem_xfree() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_realloc * @@ -1461,14 +1418,14 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline) static void * H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(size); HDassert(pline); - if(pline->nused > 0) + if (pline->nused > 0) ret_value = H5MM_realloc(chk, size); else ret_value = H5FL_BLK_REALLOC(chunk, chk, size); @@ -1476,7 +1433,6 @@ H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_mem_realloc() */ - /*-------------------------------------------------------------------------- NAME H5D__free_chunk_info @@ -1504,21 +1460,20 @@ H5D__free_chunk_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED * HDassert(chunk_info); /* Close the chunk's file dataspace, if it's not shared */ - if(!chunk_info->fspace_shared) + if (!chunk_info->fspace_shared) (void)H5S_close(chunk_info->fspace); else H5S_select_all(chunk_info->fspace, TRUE); /* Close the chunk's memory dataspace, if it's not shared */ - if(!chunk_info->mspace_shared && chunk_info->mspace) + if (!chunk_info->mspace_shared && chunk_info->mspace) (void)H5S_close(chunk_info->mspace); /* Free the actual chunk info */ chunk_info = H5FL_FREE(H5D_chunk_info_t, chunk_info); FUNC_LEAVE_NOAPI(0) -} /* H5D__free_chunk_info() */ - +} /* H5D__free_chunk_info() */ /*------------------------------------------------------------------------- * Function: H5D__create_chunk_map_single @@ -1535,16 +1490,16 @@ H5D__free_chunk_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED * static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - *io_info) + *io_info) { - H5D_chunk_info_t *chunk_info; /* Chunk information to insert into skip list */ - hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk */ - hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ - hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_info_t *chunk_info; /* Chunk information to insert into skip list */ + hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk */ + hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ + hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1552,38 +1507,39 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t HDassert(fm->f_ndims > 0); /* Get coordinate for selection */ - if(H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Initialize the 'single chunk' file & memory chunk information */ - chunk_info = fm->single_chunk_info; + chunk_info = fm->single_chunk_info; chunk_info->chunk_points = 1; /* Set chunk location & hyperslab size */ - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { /* Validate this chunk dimension */ - if(fm->layout->u.chunk.dim[u] == 0) + if (fm->layout->u.chunk.dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) HDassert(sel_start[u] == sel_end[u]); chunk_info->scaled[u] = sel_start[u] / fm->layout->u.chunk.dim[u]; - coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u]; + coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u]; } /* end for */ chunk_info->scaled[fm->f_ndims] = 0; /* Calculate the index of this chunk */ - chunk_info->index = H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, chunk_info->scaled); + chunk_info->index = + H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, chunk_info->scaled); /* Copy selection for file's dataspace into chunk dataspace */ - if(H5S_select_copy(fm->single_space, fm->file_space, FALSE) < 0) + if (H5S_select_copy(fm->single_space, fm->file_space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file selection") /* Move selection back to have correct offset in chunk */ - if(H5S_SELECT_ADJUST_U(fm->single_space, coords) < 0) + if (H5S_SELECT_ADJUST_U(fm->single_space, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection") #ifdef H5_HAVE_PARALLEL /* store chunk selection information */ - if(io_info->using_mpi_vfd) + if (io_info->using_mpi_vfd) fm->select_chunk[chunk_info->index] = chunk_info; #endif /* H5_HAVE_PARALLEL */ @@ -1604,7 +1560,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_map_single() */ - /*------------------------------------------------------------------------- * Function: H5D__create_chunk_file_map_all * @@ -1620,24 +1575,25 @@ done: static herr_t H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - *io_info) + *io_info) { - H5S_t *tmp_fchunk = NULL; /* Temporary file dataspace */ - hsize_t file_dims[H5S_MAX_RANK]; /* File dataspace dims */ - hsize_t sel_points; /* Number of elements in file selection */ - hsize_t zeros[H5S_MAX_RANK]; /* All zero vector (for start parameter to setting hyperslab on partial chunks) */ - hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */ - hsize_t end[H5S_MAX_RANK]; /* Final coordinates of chunk */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - hsize_t chunk_index; /* "Index" of chunk */ - hsize_t curr_partial_clip[H5S_MAX_RANK]; /* Current partial dimension sizes to clip against */ - hsize_t partial_dim_size[H5S_MAX_RANK]; /* Size of a partial dimension */ - hbool_t is_partial_dim[H5S_MAX_RANK]; /* Whether a dimension is currently a partial chunk */ - unsigned num_partial_dims; /* Current number of partial dimensions */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t * tmp_fchunk = NULL; /* Temporary file dataspace */ + hsize_t file_dims[H5S_MAX_RANK]; /* File dataspace dims */ + hsize_t sel_points; /* Number of elements in file selection */ + hsize_t zeros[H5S_MAX_RANK]; /* All zero vector (for start parameter to setting hyperslab on partial + chunks) */ + hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */ + hsize_t end[H5S_MAX_RANK]; /* Final coordinates of chunk */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + hsize_t chunk_index; /* "Index" of chunk */ + hsize_t curr_partial_clip[H5S_MAX_RANK]; /* Current partial dimension sizes to clip against */ + hsize_t partial_dim_size[H5S_MAX_RANK]; /* Size of a partial dimension */ + hbool_t is_partial_dim[H5S_MAX_RANK]; /* Whether a dimension is currently a partial chunk */ + unsigned num_partial_dims; /* Current number of partial dimensions */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1648,51 +1604,51 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t sel_points = fm->nelmts; /* Get dataspace dimensions */ - if(H5S_get_simple_extent_dims(fm->file_space, file_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(fm->file_space, file_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Set initial chunk location, partial dimensions, etc */ num_partial_dims = 0; HDmemset(zeros, 0, sizeof(zeros)); - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { /* Validate this chunk dimension */ - if(fm->layout->u.chunk.dim[u] == 0) + if (fm->layout->u.chunk.dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) /* Set up start / end coordinates for first chunk */ scaled[u] = 0; coords[u] = 0; - end[u] = fm->chunk_dim[u] - 1; + end[u] = fm->chunk_dim[u] - 1; /* Iniitialize partial chunk dimension information */ partial_dim_size[u] = file_dims[u] % fm->chunk_dim[u]; - if(file_dims[u] < fm->chunk_dim[u]) { + if (file_dims[u] < fm->chunk_dim[u]) { curr_partial_clip[u] = partial_dim_size[u]; - is_partial_dim[u] = TRUE; + is_partial_dim[u] = TRUE; num_partial_dims++; } /* end if */ else { curr_partial_clip[u] = fm->chunk_dim[u]; - is_partial_dim[u] = FALSE; + is_partial_dim[u] = FALSE; } /* end else */ - } /* end for */ + } /* end for */ /* Set the index of this chunk */ chunk_index = 0; /* Create "temporary" chunk for selection operations (copy file space) */ - if(NULL == (tmp_fchunk = H5S_create_simple(fm->f_ndims, fm->chunk_dim, NULL))) + if (NULL == (tmp_fchunk = H5S_create_simple(fm->f_ndims, fm->chunk_dim, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create dataspace for chunk") /* Iterate through each chunk in the dataset */ - while(sel_points) { - H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ - hsize_t chunk_points; /* Number of elements in chunk selection */ + while (sel_points) { + H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ + hsize_t chunk_points; /* Number of elements in chunk selection */ /* Add temporary chunk to the list of chunks */ /* Allocate the file & memory chunk information */ - if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) + if (NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk info") /* Initialize the chunk information */ @@ -1702,22 +1658,23 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t #ifdef H5_HAVE_PARALLEL /* Store chunk selection information, for multi-chunk I/O */ - if(io_info->using_mpi_vfd) + if (io_info->using_mpi_vfd) fm->select_chunk[chunk_index] = new_chunk_info; #endif /* H5_HAVE_PARALLEL */ /* Set the file chunk dataspace */ - if(NULL == (new_chunk_info->fspace = H5S_copy(tmp_fchunk, TRUE, FALSE))) + if (NULL == (new_chunk_info->fspace = H5S_copy(tmp_fchunk, TRUE, FALSE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy chunk dataspace") new_chunk_info->fspace_shared = FALSE; /* If there are partial dimensions for this chunk, set the hyperslab for them */ - if(num_partial_dims > 0) - if(H5S_select_hyperslab(new_chunk_info->fspace, H5S_SELECT_SET, zeros, NULL, curr_partial_clip, NULL) < 0) + if (num_partial_dims > 0) + if (H5S_select_hyperslab(new_chunk_info->fspace, H5S_SELECT_SET, zeros, NULL, curr_partial_clip, + NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk selection") /* Set the memory chunk dataspace */ - new_chunk_info->mspace = NULL; + new_chunk_info->mspace = NULL; new_chunk_info->mspace_shared = FALSE; /* Copy the chunk's scaled coordinates */ @@ -1725,7 +1682,7 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t new_chunk_info->scaled[fm->f_ndims] = 0; /* Insert the new chunk into the skip list */ - if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { + if (H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { H5D__free_chunk_info(new_chunk_info, NULL, NULL); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list") } /* end if */ @@ -1738,8 +1695,8 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t sel_points -= chunk_points; /* Advance to next chunk if we are not done */ - if(sel_points > 0) { - int curr_dim; /* Current dimension to increment */ + if (sel_points > 0) { + int curr_dim; /* Current dimension to increment */ /* Increment chunk index */ chunk_index++; @@ -1753,21 +1710,21 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t end[curr_dim] += fm->chunk_dim[curr_dim]; /* Bring chunk location back into bounds, if necessary */ - if(coords[curr_dim] >= file_dims[curr_dim]) { + if (coords[curr_dim] >= file_dims[curr_dim]) { do { /* Reset current dimension's location to 0 */ coords[curr_dim] = 0; scaled[curr_dim] = 0; - end[curr_dim] = fm->chunk_dim[curr_dim] - 1; + end[curr_dim] = fm->chunk_dim[curr_dim] - 1; /* Check for previous partial chunk in this dimension */ - if(is_partial_dim[curr_dim] && end[curr_dim] < file_dims[curr_dim]) { + if (is_partial_dim[curr_dim] && end[curr_dim] < file_dims[curr_dim]) { /* Sanity check */ HDassert(num_partial_dims > 0); /* Reset partial chunk information for this dimension */ curr_partial_clip[curr_dim] = fm->chunk_dim[curr_dim]; - is_partial_dim[curr_dim] = FALSE; + is_partial_dim[curr_dim] = FALSE; num_partial_dims--; } /* end if */ @@ -1775,40 +1732,39 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t curr_dim--; /* Check for valid current dim */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Increment chunk location in current dimension */ coords[curr_dim] += fm->chunk_dim[curr_dim]; scaled[curr_dim]++; end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1; } /* end if */ - } while(curr_dim >= 0 && (coords[curr_dim] >= file_dims[curr_dim])); + } while (curr_dim >= 0 && (coords[curr_dim] >= file_dims[curr_dim])); } /* end if */ /* Check for valid current dim */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Check for partial chunk in this dimension */ - if(!is_partial_dim[curr_dim] && file_dims[curr_dim] <= end[curr_dim]) { + if (!is_partial_dim[curr_dim] && file_dims[curr_dim] <= end[curr_dim]) { /* Set partial chunk information for this dimension */ curr_partial_clip[curr_dim] = partial_dim_size[curr_dim]; - is_partial_dim[curr_dim] = TRUE; + is_partial_dim[curr_dim] = TRUE; num_partial_dims++; /* Sanity check */ HDassert(num_partial_dims <= fm->f_ndims); } /* end if */ - } /* end if */ - } /* end if */ - } /* end while */ + } /* end if */ + } /* end if */ + } /* end while */ done: /* Clean up */ - if(tmp_fchunk && H5S_close(tmp_fchunk) < 0) + if (tmp_fchunk && H5S_close(tmp_fchunk) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_file_map_all() */ - /*------------------------------------------------------------------------- * Function: H5D__create_chunk_file_map_hyper * @@ -1824,23 +1780,23 @@ done: static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - *io_info) + *io_info) { - H5S_t *tmp_fchunk = NULL; /* Temporary file dataspace */ - hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ - hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ - hsize_t sel_points; /* Number of elements in file selection */ - hsize_t start_coords[H5O_LAYOUT_NDIMS]; /* Starting coordinates of selection */ - hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ - hsize_t end[H5O_LAYOUT_NDIMS]; /* Final coordinates of chunk */ - hsize_t chunk_index; /* Index of chunk */ - hsize_t start_scaled[H5S_MAX_RANK]; /* Starting scaled coordinates of selection */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - int curr_dim; /* Current dimension to increment */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t * tmp_fchunk = NULL; /* Temporary file dataspace */ + hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ + hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ + hsize_t sel_points; /* Number of elements in file selection */ + hsize_t start_coords[H5O_LAYOUT_NDIMS]; /* Starting coordinates of selection */ + hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ + hsize_t end[H5O_LAYOUT_NDIMS]; /* Final coordinates of chunk */ + hsize_t chunk_index; /* Index of chunk */ + hsize_t start_scaled[H5S_MAX_RANK]; /* Starting scaled coordinates of selection */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + int curr_dim; /* Current dimension to increment */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1851,48 +1807,50 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t sel_points = fm->nelmts; /* Get bounding box for selection (to reduce the number of chunks to iterate over) */ - if(H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Set initial chunk location & hyperslab size */ - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { /* Validate this chunk dimension */ - if(fm->layout->u.chunk.dim[u] == 0) + if (fm->layout->u.chunk.dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) scaled[u] = start_scaled[u] = sel_start[u] / fm->layout->u.chunk.dim[u]; coords[u] = start_coords[u] = scaled[u] * fm->layout->u.chunk.dim[u]; - end[u] = (coords[u] + fm->chunk_dim[u]) - 1; + end[u] = (coords[u] + fm->chunk_dim[u]) - 1; } /* end for */ /* Calculate the index of this chunk */ chunk_index = H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, scaled); /* Iterate through each chunk in the dataset */ - while(sel_points) { + while (sel_points) { /* Check for intersection of current chunk and file selection */ /* (Casting away const OK - QAK) */ - if(TRUE == H5S_SELECT_INTERSECT_BLOCK(fm->file_space, coords, end)) { - H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ - hsize_t chunk_points; /* Number of elements in chunk selection */ + if (TRUE == H5S_SELECT_INTERSECT_BLOCK(fm->file_space, coords, end)) { + H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ + hsize_t chunk_points; /* Number of elements in chunk selection */ /* Create dataspace for chunk, 'AND'ing the overall selection with * the current chunk. */ - if(H5S_combine_hyperslab(fm->file_space, H5S_SELECT_AND, coords, NULL, fm->chunk_dim, NULL, &tmp_fchunk) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to combine file space selection with chunk block") + if (H5S_combine_hyperslab(fm->file_space, H5S_SELECT_AND, coords, NULL, fm->chunk_dim, NULL, + &tmp_fchunk) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, + "unable to combine file space selection with chunk block") /* Resize chunk's dataspace dimensions to size of chunk */ - if(H5S_set_extent_real(tmp_fchunk, fm->chunk_dim) < 0) + if (H5S_set_extent_real(tmp_fchunk, fm->chunk_dim) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk dimensions") /* Move selection back to have correct offset in chunk */ - if(H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0) + if (H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk selection") /* Add temporary chunk to the list of chunks */ /* Allocate the file & memory chunk information */ - if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) + if (NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk info") /* Initialize the chunk information */ @@ -1902,17 +1860,17 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t #ifdef H5_HAVE_PARALLEL /* Store chunk selection information, for multi-chunk I/O */ - if(io_info->using_mpi_vfd) + if (io_info->using_mpi_vfd) fm->select_chunk[chunk_index] = new_chunk_info; #endif /* H5_HAVE_PARALLEL */ /* Set the file chunk dataspace */ - new_chunk_info->fspace = tmp_fchunk; + new_chunk_info->fspace = tmp_fchunk; new_chunk_info->fspace_shared = FALSE; - tmp_fchunk = NULL; + tmp_fchunk = NULL; /* Set the memory chunk dataspace */ - new_chunk_info->mspace = NULL; + new_chunk_info->mspace = NULL; new_chunk_info->mspace_shared = FALSE; /* Copy the chunk's scaled coordinates */ @@ -1920,7 +1878,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t new_chunk_info->scaled[fm->f_ndims] = 0; /* Insert the new chunk into the skip list */ - if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { + if (H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { H5D__free_chunk_info(new_chunk_info, NULL, NULL); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list") } /* end if */ @@ -1933,7 +1891,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t sel_points -= chunk_points; /* Leave if we are done */ - if(sel_points == 0) + if (sel_points == 0) HGOTO_DONE(SUCCEED) } /* end if */ @@ -1949,40 +1907,40 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t scaled[curr_dim]++; /* Bring chunk location back into bounds, if necessary */ - if(coords[curr_dim] > sel_end[curr_dim]) { + if (coords[curr_dim] > sel_end[curr_dim]) { do { /* Reset current dimension's location to 0 */ scaled[curr_dim] = start_scaled[curr_dim]; - coords[curr_dim] = start_coords[curr_dim]; /*lint !e771 The start_coords will always be initialized */ + coords[curr_dim] = + start_coords[curr_dim]; /*lint !e771 The start_coords will always be initialized */ end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1; /* Decrement current dimension */ curr_dim--; /* Check for valid current dim */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Increment chunk location in current dimension */ scaled[curr_dim]++; coords[curr_dim] += fm->chunk_dim[curr_dim]; end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1; } /* end if */ - } while(curr_dim >= 0 && (coords[curr_dim] > sel_end[curr_dim])); + } while (curr_dim >= 0 && (coords[curr_dim] > sel_end[curr_dim])); /* Re-calculate the index of this chunk */ chunk_index = H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, scaled); } /* end if */ - } /* end while */ + } /* end while */ done: /* Clean up on failure */ - if(ret_value < 0) - if(tmp_fchunk && H5S_close(tmp_fchunk) < 0) + if (ret_value < 0) + if (tmp_fchunk && H5S_close(tmp_fchunk) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_file_map_hyper() */ - /*------------------------------------------------------------------------- * Function: H5D__create_chunk_mem_map_hyper * @@ -2002,23 +1960,23 @@ done: static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) { - H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ - H5SL_node_t *curr_node; /* Current node in skip list */ - hsize_t file_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ - hsize_t file_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ - hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ - hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ - hssize_t adjust[H5S_MAX_RANK]; /* Adjustment to make to all file chunks */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ + H5SL_node_t * curr_node; /* Current node in skip list */ + hsize_t file_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ + hsize_t file_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ + hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ + hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ + hssize_t adjust[H5S_MAX_RANK]; /* Adjustment to make to all file chunks */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ - HDassert(fm->f_ndims>0); + HDassert(fm->f_ndims > 0); /* Check for all I/O going to a single chunk */ - if(H5SL_count(fm->sel_chunks)==1) { + if (H5SL_count(fm->sel_chunks) == 1) { /* Get the node */ curr_node = H5SL_first(fm->sel_chunks); @@ -2035,16 +1993,16 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) } /* end if */ else { /* Get bounding box for file selection */ - if(H5S_SELECT_BOUNDS(fm->file_space, file_sel_start, file_sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->file_space, file_sel_start, file_sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Get bounding box for memory selection */ - if(H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Calculate the adjustment for memory selection from file selection */ HDassert(fm->m_ndims == fm->f_ndims); - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { H5_CHECK_OVERFLOW(file_sel_start[u], hsize_t, hssize_t); H5_CHECK_OVERFLOW(mem_sel_start[u], hsize_t, hssize_t); adjust[u] = (hssize_t)file_sel_start[u] - (hssize_t)mem_sel_start[u]; @@ -2052,37 +2010,38 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) /* Iterate over each chunk in the chunk list */ curr_node = H5SL_first(fm->sel_chunks); - while(curr_node) { - hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */ - hssize_t chunk_adjust[H5S_MAX_RANK]; /* Adjustment to make to a particular chunk */ - H5S_sel_type chunk_sel_type; /* Chunk's selection type */ + while (curr_node) { + hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */ + hssize_t chunk_adjust[H5S_MAX_RANK]; /* Adjustment to make to a particular chunk */ + H5S_sel_type chunk_sel_type; /* Chunk's selection type */ /* Get pointer to chunk's information */ chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node); HDassert(chunk_info); /* Compute the chunk coordinates from the scaled coordinates */ - for(u = 0; u < fm->f_ndims; u++) + for (u = 0; u < fm->f_ndims; u++) coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u]; /* Copy the information */ /* Copy the memory dataspace */ - if((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) + if ((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") /* Get the chunk's selection type */ - if((chunk_sel_type = H5S_GET_SELECT_TYPE(chunk_info->fspace)) < H5S_SEL_NONE) + if ((chunk_sel_type = H5S_GET_SELECT_TYPE(chunk_info->fspace)) < H5S_SEL_NONE) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to get type of selection") /* Set memory selection for "all" chunk selections */ - if(H5S_SEL_ALL == chunk_sel_type) { + if (H5S_SEL_ALL == chunk_sel_type) { /* Adjust the chunk coordinates */ - for(u = 0; u < fm->f_ndims; u++) + for (u = 0; u < fm->f_ndims; u++) coords[u] = (hsize_t)((hssize_t)coords[u] - adjust[u]); /* Set to same shape as chunk */ - if(H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, coords, NULL, fm->chunk_dim, NULL) < 0) + if (H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, coords, NULL, fm->chunk_dim, + NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk memory selection") } /* end if */ else { @@ -2090,31 +2049,30 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) HDassert(H5S_SEL_HYPERSLABS == chunk_sel_type); /* Copy the file chunk's selection */ - if(H5S_SELECT_COPY(chunk_info->mspace, chunk_info->fspace, FALSE) < 0) + if (H5S_SELECT_COPY(chunk_info->mspace, chunk_info->fspace, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection") /* Compute the adjustment for this chunk */ - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { /* Compensate for the chunk offset */ H5_CHECK_OVERFLOW(coords[u], hsize_t, hssize_t); chunk_adjust[u] = adjust[u] - (hssize_t)coords[u]; } /* end for */ /* Adjust the selection */ - if(H5S_SELECT_ADJUST_S(chunk_info->mspace, chunk_adjust) < 0) + if (H5S_SELECT_ADJUST_S(chunk_info->mspace, chunk_adjust) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to adjust selection") } /* end else */ /* Get the next chunk node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_mem_map_hyper() */ - /*------------------------------------------------------------------------- * Function: H5D__create_mem_map_1d * @@ -2131,17 +2089,17 @@ done: static herr_t H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) { - H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ - H5SL_node_t *curr_node; /* Current node in skip list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ + H5SL_node_t * curr_node; /* Current node in skip list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ - HDassert(fm->f_ndims>0); + HDassert(fm->f_ndims > 0); /* Check for all I/O going to a single chunk */ - if(H5SL_count(fm->sel_chunks)==1) { + if (H5SL_count(fm->sel_chunks) == 1) { /* Get the node */ curr_node = H5SL_first(fm->sel_chunks); @@ -2157,31 +2115,32 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) chunk_info->mspace_shared = TRUE; } /* end if */ else { - hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ - hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ + hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ + hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ HDassert(fm->m_ndims == 1); - if(H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Iterate over each chunk in the chunk list */ curr_node = H5SL_first(fm->sel_chunks); - while(curr_node) { - hsize_t chunk_points; /* Number of elements in chunk selection */ - hsize_t tmp_count = 1; + while (curr_node) { + hsize_t chunk_points; /* Number of elements in chunk selection */ + hsize_t tmp_count = 1; /* Get pointer to chunk's information */ chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node); HDassert(chunk_info); /* Copy the memory dataspace */ - if((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) + if ((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") chunk_points = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); - if(H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, mem_sel_start, NULL, &tmp_count, &chunk_points) < 0) + if (H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, mem_sel_start, NULL, &tmp_count, + &chunk_points) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk memory selection") mem_sel_start[0] += chunk_points; @@ -2189,13 +2148,12 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) /* Get the next chunk node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_mem_map_1d() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_file_cb * @@ -2210,24 +2168,26 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, const hsize_t *coords, void *_udata) +H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, + const hsize_t *coords, void *_udata) { - H5D_chunk_file_iter_ud_t *udata = (H5D_chunk_file_iter_ud_t *)_udata; /* User data for operation */ - H5D_chunk_map_t *fm = udata->fm; /* File<->memory chunk mapping info */ - H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ - hsize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */ - hsize_t chunk_index; /* Chunk index */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_file_iter_ud_t *udata = (H5D_chunk_file_iter_ud_t *)_udata; /* User data for operation */ + H5D_chunk_map_t * fm = udata->fm; /* File<->memory chunk mapping info */ + H5D_chunk_info_t * chunk_info; /* Chunk information for current chunk */ + hsize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */ + hsize_t chunk_index; /* Chunk index */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Calculate the index of this chunk */ - chunk_index = H5VM_chunk_index_scaled(ndims, coords, fm->layout->u.chunk.dim, fm->layout->u.chunk.down_chunks, scaled); + chunk_index = H5VM_chunk_index_scaled(ndims, coords, fm->layout->u.chunk.dim, + fm->layout->u.chunk.down_chunks, scaled); /* Find correct chunk in file & memory skip list */ - if(chunk_index==fm->last_index) { + if (chunk_index == fm->last_index) { /* If the chunk index is the same as the last chunk index we used, * get the cached info to operate on. */ @@ -2238,37 +2198,37 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, * find the chunk in the skip list. */ /* Get the chunk node from the skip list */ - if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_index))) { - H5S_t *fspace; /* Memory chunk's dataspace */ + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_index))) { + H5S_t *fspace; /* Memory chunk's dataspace */ /* Allocate the file & memory chunk information */ - if (NULL==(chunk_info = H5FL_MALLOC (H5D_chunk_info_t))) + if (NULL == (chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") /* Initialize the chunk information */ /* Set the chunk index */ - chunk_info->index=chunk_index; + chunk_info->index = chunk_index; /* Create a dataspace for the chunk */ - if((fspace = H5S_create_simple(fm->f_ndims,fm->chunk_dim,NULL))==NULL) { + if ((fspace = H5S_create_simple(fm->f_ndims, fm->chunk_dim, NULL)) == NULL) { chunk_info = H5FL_FREE(H5D_chunk_info_t, chunk_info); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace for chunk") } /* end if */ /* De-select the chunk space */ - if(H5S_select_none(fspace) < 0) { + if (H5S_select_none(fspace) < 0) { (void)H5S_close(fspace); chunk_info = H5FL_FREE(H5D_chunk_info_t, chunk_info); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to de-select dataspace") } /* end if */ /* Set the file chunk dataspace */ - chunk_info->fspace = fspace; + chunk_info->fspace = fspace; chunk_info->fspace_shared = FALSE; /* Set the memory chunk dataspace */ - chunk_info->mspace = NULL; + chunk_info->mspace = NULL; chunk_info->mspace_shared = FALSE; /* Set the number of selected elements in chunk to zero */ @@ -2280,29 +2240,29 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, H5MM_memcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); /* Insert the new chunk into the skip list */ - if(H5SL_insert(fm->sel_chunks,chunk_info,&chunk_info->index) < 0) { - H5D__free_chunk_info(chunk_info,NULL,NULL); - HGOTO_ERROR(H5E_DATASPACE,H5E_CANTINSERT,FAIL,"can't insert chunk into skip list") + if (H5SL_insert(fm->sel_chunks, chunk_info, &chunk_info->index) < 0) { + H5D__free_chunk_info(chunk_info, NULL, NULL); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list") } /* end if */ - } /* end if */ + } /* end if */ #ifdef H5_HAVE_PARALLEL /* Store chunk selection information, for collective multi-chunk I/O */ - if(udata->io_info->using_mpi_vfd) + if (udata->io_info->using_mpi_vfd) fm->select_chunk[chunk_index] = chunk_info; #endif /* H5_HAVE_PARALLEL */ /* Update the "last chunk seen" information */ - fm->last_index = chunk_index; + fm->last_index = chunk_index; fm->last_chunk_info = chunk_info; } /* end else */ /* Get the offset of the element within the chunk */ - for(u = 0; u < fm->f_ndims; u++) + for (u = 0; u < fm->f_ndims; u++) coords_in_chunk[u] = coords[u] - (scaled[u] * fm->layout->u.chunk.dim[u]); /* Add point to file selection for chunk */ - if(H5S_select_elements(chunk_info->fspace, H5S_SELECT_APPEND, (size_t)1, coords_in_chunk) < 0) + if (H5S_select_elements(chunk_info->fspace, H5S_SELECT_APPEND, (size_t)1, coords_in_chunk) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element") /* Increment the number of elemented selected in chunk */ @@ -2312,7 +2272,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_file_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_cb * @@ -2327,13 +2286,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, const hsize_t *coords, void *_fm) +H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, + const hsize_t *coords, void *_fm) { - H5D_chunk_map_t *fm = (H5D_chunk_map_t *)_fm; /* File<->memory chunk mapping info */ - H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ - hsize_t coords_in_mem[H5S_MAX_RANK]; /* Coordinates of element in memory */ - hsize_t chunk_index; /* Chunk index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_map_t * fm = (H5D_chunk_map_t *)_fm; /* File<->memory chunk mapping info */ + H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ + hsize_t coords_in_mem[H5S_MAX_RANK]; /* Coordinates of element in memory */ + hsize_t chunk_index; /* Chunk index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2341,7 +2301,7 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u chunk_index = H5VM_chunk_index(ndims, coords, fm->layout->u.chunk.dim, fm->layout->u.chunk.down_chunks); /* Find correct chunk in file & memory skip list */ - if(chunk_index == fm->last_index) { + if (chunk_index == fm->last_index) { /* If the chunk index is the same as the last chunk index we used, * get the cached spaces to operate on. */ @@ -2352,43 +2312,42 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u * find the chunk in the skip list. */ /* Get the chunk node from the skip list */ - if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_index))) + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_index))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, H5_ITER_ERROR, "can't locate chunk in skip list") /* Check if the chunk already has a memory space */ - if(NULL == chunk_info->mspace) + if (NULL == chunk_info->mspace) /* Copy the template memory chunk dataspace */ - if(NULL == (chunk_info->mspace = H5S_copy(fm->mchunk_tmpl, FALSE, FALSE))) + if (NULL == (chunk_info->mspace = H5S_copy(fm->mchunk_tmpl, FALSE, FALSE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy file space") /* Update the "last chunk seen" information */ - fm->last_index = chunk_index; + fm->last_index = chunk_index; fm->last_chunk_info = chunk_info; } /* end else */ /* Get coordinates of selection iterator for memory */ - if(H5S_SELECT_ITER_COORDS(&fm->mem_iter, coords_in_mem) < 0) + if (H5S_SELECT_ITER_COORDS(&fm->mem_iter, coords_in_mem) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, H5_ITER_ERROR, "unable to get iterator coordinates") /* Add point to memory selection for chunk */ - if(fm->msel_type == H5S_SEL_POINTS) { - if(H5S_select_elements(chunk_info->mspace, H5S_SELECT_APPEND, (size_t)1, coords_in_mem) < 0) + if (fm->msel_type == H5S_SEL_POINTS) { + if (H5S_select_elements(chunk_info->mspace, H5S_SELECT_APPEND, (size_t)1, coords_in_mem) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, H5_ITER_ERROR, "unable to select element") } /* end if */ else { - if(H5S_hyper_add_span_element(chunk_info->mspace, fm->m_ndims, coords_in_mem) < 0) + if (H5S_hyper_add_span_element(chunk_info->mspace, fm->m_ndims, coords_in_mem) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, H5_ITER_ERROR, "unable to select element") } /* end else */ /* Move memory selection iterator to next element in selection */ - if(H5S_SELECT_ITER_NEXT(&fm->mem_iter, (size_t)1) < 0) + if (H5S_SELECT_ITER_NEXT(&fm->mem_iter, (size_t)1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, H5_ITER_ERROR, "unable to move to next iterator location") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_mem_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cacheable * @@ -2405,9 +2364,9 @@ done: htri_t H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_op) { - const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ - hbool_t has_filters = FALSE; /* Whether there are filters on the chunk or not */ - htri_t ret_value = FAIL; /* Return value */ + const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ + hbool_t has_filters = FALSE; /* Whether there are filters on the chunk or not */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -2418,29 +2377,26 @@ H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_ /* Must bring the whole chunk in if there are any filters on the chunk. * Make sure to check if filters are on the dataset but disabled for the * chunk because it is a partial edge chunk. */ - if(dataset->shared->dcpl_cache.pline.nused > 0) { - if(dataset->shared->layout.u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { + if (dataset->shared->dcpl_cache.pline.nused > 0) { + if (dataset->shared->layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { has_filters = !H5D__chunk_is_partial_edge_chunk( - io_info->dset->shared->ndims, - io_info->dset->shared->layout.u.chunk.dim, - io_info->store->chunk.scaled, - io_info->dset->shared->curr_dims); + io_info->dset->shared->ndims, io_info->dset->shared->layout.u.chunk.dim, + io_info->store->chunk.scaled, io_info->dset->shared->curr_dims); } /* end if */ else has_filters = TRUE; } /* end if */ - if(has_filters) + if (has_filters) ret_value = TRUE; else { #ifdef H5_HAVE_PARALLEL - /* If MPI based VFD is used and the file is opened for write access, must - * bypass the chunk-cache scheme because other MPI processes could - * be writing to other elements in the same chunk. Do a direct - * write-through of only the elements requested. - */ - if(io_info->using_mpi_vfd && (H5F_ACC_RDWR & H5F_INTENT(dataset->oloc.file))) + /* If MPI based VFD is used and the file is opened for write access, must + * bypass the chunk-cache scheme because other MPI processes could + * be writing to other elements in the same chunk. Do a direct + * write-through of only the elements requested. + */ + if (io_info->using_mpi_vfd && (H5F_ACC_RDWR & H5F_INTENT(dataset->oloc.file))) ret_value = FALSE; else { #endif /* H5_HAVE_PARALLEL */ @@ -2449,38 +2405,39 @@ H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_ * cache, just write the data to it directly. */ H5_CHECK_OVERFLOW(dataset->shared->layout.u.chunk.size, uint32_t, size_t); - if((size_t)dataset->shared->layout.u.chunk.size > dataset->shared->cache.chunk.nbytes_max) { - if(write_op && !H5F_addr_defined(caddr)) { + if ((size_t)dataset->shared->layout.u.chunk.size > dataset->shared->cache.chunk.nbytes_max) { + if (write_op && !H5F_addr_defined(caddr)) { const H5O_fill_t *fill = &(dataset->shared->dcpl_cache.fill); /* Fill value info */ - H5D_fill_value_t fill_status; /* Fill value status */ + H5D_fill_value_t fill_status; /* Fill value status */ /* Revtrieve the fill value status */ - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If the fill value needs to be written then we will need * to use the cache to write the fill value */ - if(fill->fill_time == H5D_FILL_TIME_ALLOC || - (fill->fill_time == H5D_FILL_TIME_IFSET && - (fill_status == H5D_FILL_VALUE_USER_DEFINED || - fill_status == H5D_FILL_VALUE_DEFAULT))) + if (fill->fill_time == H5D_FILL_TIME_ALLOC || + (fill->fill_time == H5D_FILL_TIME_IFSET && + (fill_status == H5D_FILL_VALUE_USER_DEFINED || + fill_status == H5D_FILL_VALUE_DEFAULT))) ret_value = TRUE; else ret_value = FALSE; - } else + } + else ret_value = FALSE; - } else + } + else ret_value = TRUE; #ifdef H5_HAVE_PARALLEL } /* end else */ -#endif /* H5_HAVE_PARALLEL */ - } /* end else */ +#endif /* H5_HAVE_PARALLEL */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_cacheable() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_read * @@ -2494,20 +2451,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t *fm) +H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t H5_ATTR_UNUSED nelmts, + const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, + H5D_chunk_map_t *fm) { - H5SL_node_t *chunk_node; /* Current node in chunk skip list */ - H5D_io_info_t nonexistent_io_info; /* "nonexistent" I/O info object */ - H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ - H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ - H5D_io_info_t cpt_io_info; /* Compact I/O info object */ - H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ - hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ - uint32_t src_accessed_bytes = 0; /* Total accessed size in a chunk */ - hbool_t skip_missing_chunks = FALSE; /* Whether to skip missing chunks */ - herr_t ret_value = SUCCEED; /*return value */ + H5SL_node_t * chunk_node; /* Current node in chunk skip list */ + H5D_io_info_t nonexistent_io_info; /* "nonexistent" I/O info object */ + H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ + H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ + H5D_io_info_t cpt_io_info; /* Compact I/O info object */ + H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ + hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ + uint32_t src_accessed_bytes = 0; /* Total accessed size in a chunk */ + hbool_t skip_missing_chunks = FALSE; /* Whether to skip missing chunks */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_STATIC @@ -2523,69 +2480,69 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); - ctg_io_info.store = &ctg_store; + ctg_io_info.store = &ctg_store; ctg_io_info.layout_ops = *H5D_LOPS_CONTIG; /* Initialize temporary contiguous storage info */ - H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, uint32_t); + H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, + uint32_t); /* Set up compact I/O info object */ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info)); - cpt_io_info.store = &cpt_store; + cpt_io_info.store = &cpt_store; cpt_io_info.layout_ops = *H5D_LOPS_COMPACT; /* Initialize temporary compact storage info */ cpt_store.compact.dirty = &cpt_dirty; { - const H5O_fill_t *fill = &(io_info->dset->shared->dcpl_cache.fill); /* Fill value info */ - H5D_fill_value_t fill_status; /* Fill value status */ + const H5O_fill_t *fill = &(io_info->dset->shared->dcpl_cache.fill); /* Fill value info */ + H5D_fill_value_t fill_status; /* Fill value status */ /* Check the fill value status */ - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are never to return fill values, or if we would return them * but they aren't set, set the flag to skip missing chunks. */ - if(fill->fill_time == H5D_FILL_TIME_NEVER || - (fill->fill_time == H5D_FILL_TIME_IFSET && - fill_status != H5D_FILL_VALUE_USER_DEFINED && - fill_status != H5D_FILL_VALUE_DEFAULT)) + if (fill->fill_time == H5D_FILL_TIME_NEVER || + (fill->fill_time == H5D_FILL_TIME_IFSET && fill_status != H5D_FILL_VALUE_USER_DEFINED && + fill_status != H5D_FILL_VALUE_DEFAULT)) skip_missing_chunks = TRUE; } /* Iterate through nodes in chunk skip list */ chunk_node = H5D_CHUNK_GET_FIRST_NODE(fm); - while(chunk_node) { - H5D_chunk_info_t *chunk_info; /* Chunk information */ - H5D_chunk_ud_t udata; /* Chunk index pass-through */ + while (chunk_node) { + H5D_chunk_info_t *chunk_info; /* Chunk information */ + H5D_chunk_ud_t udata; /* Chunk index pass-through */ /* Get the actual chunk information from the skip list node */ chunk_info = H5D_CHUNK_GET_NODE_INFO(fm, chunk_node); /* Get the info for the chunk in the file */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ HDassert((H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length > 0) || - (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); /* Check for non-existant chunk & skip it if appropriate */ - if(H5F_addr_defined(udata.chunk_block.offset) || UINT_MAX != udata.idx_hint - || !skip_missing_chunks) { - H5D_io_info_t *chk_io_info; /* Pointer to I/O info object for this chunk */ - void *chunk = NULL; /* Pointer to locked chunk buffer */ - htri_t cacheable; /* Whether the chunk is cacheable */ + if (H5F_addr_defined(udata.chunk_block.offset) || UINT_MAX != udata.idx_hint || + !skip_missing_chunks) { + H5D_io_info_t *chk_io_info; /* Pointer to I/O info object for this chunk */ + void * chunk = NULL; /* Pointer to locked chunk buffer */ + htri_t cacheable; /* Whether the chunk is cacheable */ /* Set chunk's [scaled] coordinates */ io_info->store->chunk.scaled = chunk_info->scaled; /* Determine if we should use the chunk cache */ - if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, FALSE)) < 0) + if ((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") - if(cacheable) { + if (cacheable) { /* Load the chunk into cache and lock it. */ /* Compute # of bytes accessed in chunk */ @@ -2593,7 +2550,7 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, src_accessed_bytes = chunk_info->chunk_points * (uint32_t)type_info->src_type_size; /* Lock the chunk into the cache */ - if(NULL == (chunk = H5D__chunk_lock(io_info, &udata, FALSE, FALSE))) + if (NULL == (chunk = H5D__chunk_lock(io_info, &udata, FALSE, FALSE))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") /* Set up the storage buffer information for this chunk */ @@ -2602,7 +2559,7 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Point I/O info at contiguous I/O info for this chunk */ chk_io_info = &cpt_io_info; } /* end if */ - else if(H5F_addr_defined(udata.chunk_block.offset)) { + else if (H5F_addr_defined(udata.chunk_block.offset)) { /* Set up the storage address information for this chunk */ ctg_store.contig.dset_addr = udata.chunk_block.offset; @@ -2615,12 +2572,12 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, } /* end else */ /* Perform the actual read operation */ - if((io_info->io_ops.single_read)(chk_io_info, type_info, - (hsize_t)chunk_info->chunk_points, chunk_info->fspace, chunk_info->mspace) < 0) + if ((io_info->io_ops.single_read)(chk_io_info, type_info, (hsize_t)chunk_info->chunk_points, + chunk_info->fspace, chunk_info->mspace) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "chunked read failed") /* Release the cache lock on the chunk. */ - if(chunk && H5D__chunk_unlock(io_info, &udata, FALSE, chunk, src_accessed_bytes) < 0) + if (chunk && H5D__chunk_unlock(io_info, &udata, FALSE, chunk, src_accessed_bytes) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk") } /* end if */ @@ -2637,15 +2594,13 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, * entries. After we write refresh routines for those entries, this * stopgap fix can go away. */ - if(H5D__chunk_index_close(io_info->dset, false) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, - "unable to close chunk index") + if (H5D__chunk_index_close(io_info->dset, false) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to close chunk index") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_read() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_write * @@ -2659,18 +2614,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t *fm) +H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t H5_ATTR_UNUSED nelmts, + const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, + H5D_chunk_map_t *fm) { - H5SL_node_t *chunk_node; /* Current node in chunk skip list */ - H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ - H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ - H5D_io_info_t cpt_io_info; /* Compact I/O info object */ - H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ - hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ - uint32_t dst_accessed_bytes = 0; /* Total accessed size in a chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SL_node_t * chunk_node; /* Current node in chunk skip list */ + H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ + H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ + H5D_io_info_t cpt_io_info; /* Compact I/O info object */ + H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ + hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ + uint32_t dst_accessed_bytes = 0; /* Total accessed size in a chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2682,15 +2637,16 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); - ctg_io_info.store = &ctg_store; + ctg_io_info.store = &ctg_store; ctg_io_info.layout_ops = *H5D_LOPS_CONTIG; /* Initialize temporary contiguous storage info */ - H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, uint32_t); + H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, + uint32_t); /* Set up compact I/O info object */ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info)); - cpt_io_info.store = &cpt_store; + cpt_io_info.store = &cpt_store; cpt_io_info.layout_ops = *H5D_LOPS_COMPACT; /* Initialize temporary compact storage info */ @@ -2698,49 +2654,49 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Iterate through nodes in chunk skip list */ chunk_node = H5D_CHUNK_GET_FIRST_NODE(fm); - while(chunk_node) { - H5D_chunk_info_t *chunk_info; /* Chunk information */ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_io_info_t *chk_io_info; /* Pointer to I/O info object for this chunk */ - void *chunk; /* Pointer to locked chunk buffer */ - H5D_chunk_ud_t udata; /* Index pass-through */ - htri_t cacheable; /* Whether the chunk is cacheable */ - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + while (chunk_node) { + H5D_chunk_info_t * chunk_info; /* Chunk information */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_io_info_t * chk_io_info; /* Pointer to I/O info object for this chunk */ + void * chunk; /* Pointer to locked chunk buffer */ + H5D_chunk_ud_t udata; /* Index pass-through */ + htri_t cacheable; /* Whether the chunk is cacheable */ + hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ /* Get the actual chunk information from the skip list node */ chunk_info = H5D_CHUNK_GET_NODE_INFO(fm, chunk_node); /* Look up the chunk */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ HDassert((H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length > 0) || - (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); - /* Set chunk's [scaled] coordinates */ - io_info->store->chunk.scaled = chunk_info->scaled; + /* Set chunk's [scaled] coordinates */ + io_info->store->chunk.scaled = chunk_info->scaled; /* Determine if we should use the chunk cache */ - if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, TRUE)) < 0) + if ((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") - if(cacheable) { + if (cacheable) { /* Load the chunk into cache. But if the whole chunk is written, * simply allocate space instead of load the chunk. */ - hbool_t entire_chunk = TRUE; /* Whether whole chunk is selected */ + hbool_t entire_chunk = TRUE; /* Whether whole chunk is selected */ /* Compute # of bytes accessed in chunk */ H5_CHECK_OVERFLOW(type_info->dst_type_size, /*From:*/ size_t, /*To:*/ uint32_t); dst_accessed_bytes = chunk_info->chunk_points * (uint32_t)type_info->dst_type_size; /* Determine if we will access all the data in the chunk */ - if(dst_accessed_bytes != ctg_store.contig.dset_size || - (chunk_info->chunk_points * type_info->src_type_size) != ctg_store.contig.dset_size || - fm->fsel_type == H5S_SEL_POINTS) + if (dst_accessed_bytes != ctg_store.contig.dset_size || + (chunk_info->chunk_points * type_info->src_type_size) != ctg_store.contig.dset_size || + fm->fsel_type == H5S_SEL_POINTS) entire_chunk = FALSE; /* Lock the chunk into the cache */ - if(NULL == (chunk = H5D__chunk_lock(io_info, &udata, entire_chunk, FALSE))) + if (NULL == (chunk = H5D__chunk_lock(io_info, &udata, entire_chunk, FALSE))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") /* Set up the storage buffer information for this chunk */ @@ -2751,22 +2707,24 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, } /* end if */ else { /* If the chunk hasn't been allocated on disk, do so now. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) { + if (!H5F_addr_defined(udata.chunk_block.offset)) { /* Compose chunked index info struct */ - idx_info.f = io_info->dset->oloc.file; - idx_info.pline = &(io_info->dset->shared->dcpl_cache.pline); - idx_info.layout = &(io_info->dset->shared->layout.u.chunk); + idx_info.f = io_info->dset->oloc.file; + idx_info.pline = &(io_info->dset->shared->dcpl_cache.pline); + idx_info.layout = &(io_info->dset->shared->layout.u.chunk); idx_info.storage = &(io_info->dset->shared->layout.storage.u.chunk); /* Set up the size of chunk for user data */ udata.chunk_block.length = io_info->dset->shared->layout.u.chunk.size; /* Allocate the chunk */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, chunk_info->scaled) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") + if (H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, + chunk_info->scaled) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, + "unable to insert/resize chunk on chunk level") /* Make sure the address of the chunk is returned. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) + if (!H5F_addr_defined(udata.chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined") /* Cache the new chunk information */ @@ -2784,20 +2742,20 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, } /* end else */ /* Perform the actual write operation */ - if((io_info->io_ops.single_write)(chk_io_info, type_info, - (hsize_t)chunk_info->chunk_points, chunk_info->fspace, chunk_info->mspace) < 0) + if ((io_info->io_ops.single_write)(chk_io_info, type_info, (hsize_t)chunk_info->chunk_points, + chunk_info->fspace, chunk_info->mspace) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "chunked write failed") - /* Release the cache lock on the chunk, or insert chunk into index. */ - if(chunk) { - if(H5D__chunk_unlock(io_info, &udata, TRUE, chunk, dst_accessed_bytes) < 0) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk") - } /* end if */ - else { - if(need_insert && io_info->dset->shared->layout.storage.u.chunk.ops->insert) - if((io_info->dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata, NULL) < 0) + /* Release the cache lock on the chunk, or insert chunk into index. */ + if (chunk) { + if (H5D__chunk_unlock(io_info, &udata, TRUE, chunk, dst_accessed_bytes) < 0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk") + } /* end if */ + else { + if (need_insert && io_info->dset->shared->layout.storage.u.chunk.ops->insert) + if ((io_info->dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") - } /* end else */ + } /* end else */ /* Advance to next chunk in list */ chunk_node = H5D_CHUNK_GET_NEXT_NODE(fm, chunk_node); @@ -2807,7 +2765,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_write() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_flush * @@ -2824,10 +2781,10 @@ done: static herr_t H5D__chunk_flush(H5D_t *dset) { - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); - H5D_rdcc_ent_t *ent, *next; - unsigned nerrors = 0; /* Count of any errors encountered when flushing chunks */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); + H5D_rdcc_ent_t *ent, *next; + unsigned nerrors = 0; /* Count of any errors encountered when flushing chunks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2835,19 +2792,18 @@ H5D__chunk_flush(H5D_t *dset) HDassert(dset); /* Loop over all entries in the chunk cache */ - for(ent = rdcc->head; ent; ent = next) { - next = ent->next; - if(H5D__chunk_flush_entry(dset, ent, FALSE) < 0) + for (ent = rdcc->head; ent; ent = next) { + next = ent->next; + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) nerrors++; } /* end for */ - if(nerrors) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") + if (nerrors) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_flush() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_io_term * @@ -2863,12 +2819,12 @@ done: static herr_t H5D__chunk_io_term(const H5D_chunk_map_t *fm) { - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_STATIC /* Single element I/O vs. multiple element I/O cleanup */ - if(fm->use_single) { + if (fm->use_single) { /* Sanity checks */ HDassert(fm->sel_chunks == NULL); HDassert(fm->single_chunk_info); @@ -2880,17 +2836,17 @@ H5D__chunk_io_term(const H5D_chunk_map_t *fm) } /* end if */ else { /* Release the nodes on the list of selected chunks */ - if(fm->sel_chunks) - if(H5SL_free(fm->sel_chunks, H5D__free_chunk_info, NULL) < 0) + if (fm->sel_chunks) + if (H5SL_free(fm->sel_chunks, H5D__free_chunk_info, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTNEXT, FAIL, "can't iterate over chunks") } /* end else */ /* Free the memory chunk dataspace template */ - if(fm->mchunk_tmpl) - if(H5S_close(fm->mchunk_tmpl) < 0) + if (fm->mchunk_tmpl) + if (H5S_close(fm->mchunk_tmpl) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") #ifdef H5_HAVE_PARALLEL - if(fm->select_chunk) + if (fm->select_chunk) H5MM_xfree(fm->select_chunk); #endif /* H5_HAVE_PARALLEL */ @@ -2909,25 +2865,24 @@ done: static herr_t H5D__chunk_index_close(const H5D_t *dset, bool destroy) { - H5D_chk_idx_info_t idx_info; - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; + H5O_storage_chunk_t * sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ H5D_chunk_close_func_t fn; FUNC_ENTER_STATIC H5D_CHUNK_STORAGE_INDEX_CHK(sc); - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; fn = destroy ? sc->ops->dest : sc->ops->close; if (fn != NULL && (*fn)(&idx_info) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, - "unable to release chunk index info") + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") } done: @@ -2950,10 +2905,10 @@ done: static herr_t H5D__chunk_dest(H5D_t *dset) { - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Dataset's chunk cache */ - H5D_rdcc_ent_t *ent = NULL, *next = NULL; /* Pointer to current & next cache entries */ - int nerrors = 0; /* Accumulated count of errors */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* Dataset's chunk cache */ + H5D_rdcc_ent_t *ent = NULL, *next = NULL; /* Pointer to current & next cache entries */ + int nerrors = 0; /* Accumulated count of errors */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dset->oloc.addr) @@ -2961,31 +2916,29 @@ H5D__chunk_dest(H5D_t *dset) HDassert(dset); /* Flush all the cached chunks */ - for(ent = rdcc->head; ent; ent = next) { + for (ent = rdcc->head; ent; ent = next) { next = ent->next; - if(H5D__chunk_cache_evict(dset, ent, TRUE) < 0) + if (H5D__chunk_cache_evict(dset, ent, TRUE) < 0) nerrors++; } /* end for */ /* Continue even if there are failures. */ - if(nerrors) + if (nerrors) HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") /* Release cache structures */ - if(rdcc->slot) + if (rdcc->slot) rdcc->slot = H5FL_SEQ_FREE(H5D_rdcc_ent_ptr_t, rdcc->slot); HDmemset(rdcc, 0, sizeof(H5D_rdcc_t)); if (H5D__chunk_index_close(dset, true) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, - "unable to close chunk index") + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to close chunk index") } done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__chunk_dest() */ - /*------------------------------------------------------------------------- * Function: H5D_chunk_idx_reset * @@ -3001,7 +2954,7 @@ done: herr_t H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3011,14 +2964,13 @@ H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) H5D_CHUNK_STORAGE_INDEX_CHK(storage); /* Reset index structures */ - if((storage->ops->reset)(storage, reset_addr) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset chunk index info") + if ((storage->ops->reset)(storage, reset_addr) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset chunk index info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cinfo_cache_reset * @@ -3045,7 +2997,6 @@ H5D__chunk_cinfo_cache_reset(H5D_chunk_cached_t *last) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__chunk_cinfo_cache_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cinfo_cache_update * @@ -3073,7 +3024,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud H5MM_memcpy(last->scaled, udata->common.scaled, sizeof(hsize_t) * udata->common.layout->ndims); last->addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(last->nbytes, uint32_t, udata->chunk_block.length, hsize_t); - last->chunk_idx = udata->chunk_idx; + last->chunk_idx = udata->chunk_idx; last->filter_mask = udata->filter_mask; /* Indicate that the cached info is valid */ @@ -3082,7 +3033,6 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__chunk_cinfo_cache_update() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cinfo_cache_found * @@ -3098,7 +3048,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud static hbool_t H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *udata) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -3109,19 +3059,19 @@ H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *uda HDassert(udata->common.scaled); /* Check if the cached information is what is desired */ - if(last->valid) { - unsigned u; /* Local index variable */ + if (last->valid) { + unsigned u; /* Local index variable */ /* Check that the scaled offset is the same */ - for(u = 0; u < udata->common.layout->ndims; u++) - if(last->scaled[u] != udata->common.scaled[u]) + for (u = 0; u < udata->common.layout->ndims; u++) + if (last->scaled[u] != udata->common.scaled[u]) HGOTO_DONE(FALSE) /* Retrieve the information from the cache */ udata->chunk_block.offset = last->addr; udata->chunk_block.length = last->nbytes; - udata->chunk_idx = last->chunk_idx; - udata->filter_mask = last->filter_mask; + udata->chunk_idx = last->chunk_idx; + udata->filter_mask = last->filter_mask; /* Indicate that the data was found */ HGOTO_DONE(TRUE) @@ -3131,7 +3081,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_cinfo_cache_found() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_create * @@ -3150,42 +3099,42 @@ done: herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ HDassert(dset); HDassert(H5D_CHUNKED == dset->shared->layout.type); - HDassert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + HDassert(dset->shared->layout.u.chunk.ndims > 0 && + dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); H5D_CHUNK_STORAGE_INDEX_CHK(sc); #ifndef NDEBUG -{ - unsigned u; /* Local index variable */ + { + unsigned u; /* Local index variable */ - for(u = 0; u < dset->shared->layout.u.chunk.ndims; u++) - HDassert(dset->shared->layout.u.chunk.dim[u] > 0); -} + for (u = 0; u < dset->shared->layout.u.chunk.ndims; u++) + HDassert(dset->shared->layout.u.chunk.dim[u] > 0); + } #endif /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Create the index for the chunks */ - if((sc->ops->create)(&idx_info) < 0) + if ((sc->ops->create)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create chunk index") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_create() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_hash_val * @@ -3201,10 +3150,10 @@ done: static unsigned H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) { - hsize_t val; /* Intermediate value */ - unsigned ndims = shared->ndims; /* Rank of dataset */ - unsigned ret = 0; /* Value to return */ - unsigned u; /* Local index variable */ + hsize_t val; /* Intermediate value */ + unsigned ndims = shared->ndims; /* Rank of dataset */ + unsigned ret = 0; /* Value to return */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -3216,7 +3165,7 @@ H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) * other dimensions too */ val = scaled[0]; - for(u = 1; u < ndims; u++) { + for (u = 1; u < ndims; u++) { val <<= shared->cache.chunk.scaled_encode_bits[u]; val ^= scaled[u]; } /* end for */ @@ -3227,7 +3176,6 @@ H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) FUNC_LEAVE_NOAPI(ret) } /* H5D__chunk_hash_val() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_lookup * @@ -3242,14 +3190,13 @@ H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) *------------------------------------------------------------------------- */ herr_t -H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, - H5D_chunk_ud_t *udata) +H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udata) { - H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - unsigned idx; /* Index of chunk in cache, if present */ - hbool_t found = FALSE; /* In cache? */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_rdcc_ent_t * ent = NULL; /* Cache entry */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + unsigned idx; /* Index of chunk in cache, if present */ + hbool_t found = FALSE; /* In cache? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3261,43 +3208,44 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, HDassert(udata); /* Initialize the query information about the chunk we are looking for */ - udata->common.layout = &(dset->shared->layout.u.chunk); + udata->common.layout = &(dset->shared->layout.u.chunk); udata->common.storage = sc; - udata->common.scaled = scaled; + udata->common.scaled = scaled; /* Reset information about the chunk we are looking for */ udata->chunk_block.offset = HADDR_UNDEF; udata->chunk_block.length = 0; - udata->filter_mask = 0; - udata->new_unfilt_chunk = FALSE; + udata->filter_mask = 0; + udata->new_unfilt_chunk = FALSE; /* Check for chunk in cache */ - if(dset->shared->cache.chunk.nslots > 0) { + if (dset->shared->cache.chunk.nslots > 0) { /* Determine the chunk's location in the hash table */ idx = H5D__chunk_hash_val(dset->shared, scaled); /* Get the chunk cache entry for that location */ ent = dset->shared->cache.chunk.slot[idx]; - if(ent) { - unsigned u; /* Counter */ + if (ent) { + unsigned u; /* Counter */ /* Speculatively set the 'found' flag */ found = TRUE; /* Verify that the cache entry is the correct chunk */ - for(u = 0; u < dset->shared->ndims; u++) - if(scaled[u] != ent->scaled[u]) { + for (u = 0; u < dset->shared->ndims; u++) + if (scaled[u] != ent->scaled[u]) { found = FALSE; break; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Retrieve chunk addr */ - if(found) { - udata->idx_hint = idx; + if (found) { + udata->idx_hint = idx; udata->chunk_block.offset = ent->chunk_block.offset; - udata->chunk_block.length = ent->chunk_block.length;; + udata->chunk_block.length = ent->chunk_block.length; + ; udata->chunk_idx = ent->chunk_idx; } /* end if */ else { @@ -3305,13 +3253,13 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, udata->idx_hint = UINT_MAX; /* Check for cached information */ - if(!H5D__chunk_cinfo_cache_found(&dset->shared->cache.chunk.last, udata)) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ + if (!H5D__chunk_cinfo_cache_found(&dset->shared->cache.chunk.last, udata)) { + H5D_chk_idx_info_t idx_info; /* Chunked index info */ /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; #ifdef H5_HAVE_PARALLEL @@ -3319,57 +3267,53 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, * highly unlikely that users would read the same chunks from all * processes. */ - if(H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) H5CX_set_coll_metadata_read(FALSE); #endif /* H5_HAVE_PARALLEL */ /* Go get the chunk information */ - if((sc->ops->get_addr)(&idx_info, udata) < 0) + if ((sc->ops->get_addr)(&idx_info, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query chunk address") - /* - * Cache the information retrieved. - * - * Note that if we are writing to the dataset in parallel and filters - * are involved, we skip caching this information as it is highly likely - * that the chunk information will be invalidated as a result of the - * filter operation (e.g. the chunk gets re-allocated to a different - * address in the file and/or gets re-allocated with a different size). - * If we were to cache this information, subsequent reads/writes would - * retrieve the invalid information and cause a variety of issues. - * - * It has been verified that in the serial library, when writing to chunks - * with the real chunk cache disabled and with filters involved, the - * functions within this file are correctly called in such a manner that - * this single chunk cache is always updated correctly. Therefore, this - * check is not needed for the serial library. - * - * This is an ugly and potentially frail check, but the - * H5D__chunk_cinfo_cache_reset() function is not currently available - * to functions outside of this file, so outside functions can not - * invalidate this single chunk cache. Even if the function were available, - * this check prevents us from doing the work of going through and caching - * each chunk in the write operation, when we're only going to invalidate - * the cache at the end of a parallel write anyway. - * - * - JTH (7/13/2018) - */ + /* + * Cache the information retrieved. + * + * Note that if we are writing to the dataset in parallel and filters + * are involved, we skip caching this information as it is highly likely + * that the chunk information will be invalidated as a result of the + * filter operation (e.g. the chunk gets re-allocated to a different + * address in the file and/or gets re-allocated with a different size). + * If we were to cache this information, subsequent reads/writes would + * retrieve the invalid information and cause a variety of issues. + * + * It has been verified that in the serial library, when writing to chunks + * with the real chunk cache disabled and with filters involved, the + * functions within this file are correctly called in such a manner that + * this single chunk cache is always updated correctly. Therefore, this + * check is not needed for the serial library. + * + * This is an ugly and potentially frail check, but the + * H5D__chunk_cinfo_cache_reset() function is not currently available + * to functions outside of this file, so outside functions can not + * invalidate this single chunk cache. Even if the function were available, + * this check prevents us from doing the work of going through and caching + * each chunk in the write operation, when we're only going to invalidate + * the cache at the end of a parallel write anyway. + * + * - JTH (7/13/2018) + */ #ifdef H5_HAVE_PARALLEL - if ( !( (H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) - && (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR) - && dset->shared->dcpl_cache.pline.nused - ) - ) + if (!((H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) && + (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR) && dset->shared->dcpl_cache.pline.nused)) #endif H5D__chunk_cinfo_cache_update(&dset->shared->cache.chunk.last, udata); } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_lookup() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_flush_entry * @@ -3388,10 +3332,10 @@ done: static herr_t H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) { - void *buf = NULL; /* Temporary buffer */ - hbool_t point_of_no_return = FALSE; - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + void * buf = NULL; /* Temporary buffer */ + hbool_t point_of_no_return = FALSE; + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3402,42 +3346,41 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) HDassert(!ent->locked); buf = ent->chunk; - if(ent->dirty) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_chunk_ud_t udata; /* pass through B-tree */ - hbool_t must_alloc = FALSE; /* Whether the chunk must be allocated */ - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + if (ent->dirty) { + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_chunk_ud_t udata; /* pass through B-tree */ + hbool_t must_alloc = FALSE; /* Whether the chunk must be allocated */ + hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ /* Set up user data for index callbacks */ - udata.common.layout = &dset->shared->layout.u.chunk; - udata.common.storage = sc; - udata.common.scaled = ent->scaled; + udata.common.layout = &dset->shared->layout.u.chunk; + udata.common.storage = sc; + udata.common.scaled = ent->scaled; udata.chunk_block.offset = ent->chunk_block.offset; udata.chunk_block.length = dset->shared->layout.u.chunk.size; - udata.filter_mask = 0; - udata.chunk_idx = ent->chunk_idx; + udata.filter_mask = 0; + udata.chunk_idx = ent->chunk_idx; /* Should the chunk be filtered before writing it to disk? */ - if(dset->shared->dcpl_cache.pline.nused - && !(ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS)) { - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ - size_t alloc = udata.chunk_block.length; /* Bytes allocated for BUF */ - size_t nbytes; /* Chunk size (in bytes) */ + if (dset->shared->dcpl_cache.pline.nused && !(ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS)) { + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ + size_t alloc = udata.chunk_block.length; /* Bytes allocated for BUF */ + size_t nbytes; /* Chunk size (in bytes) */ /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + if (H5CX_get_err_detect(&err_detect) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get error detection info") - if(H5CX_get_filter_cb(&filter_cb) < 0) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") - if(!reset) { + if (!reset) { /* * Copy the chunk to a new buffer before running it through * the pipeline because we'll want to save the original buffer * for later. */ - if(NULL == (buf = H5MM_malloc(alloc))) + if (NULL == (buf = H5MM_malloc(alloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline") H5MM_memcpy(buf, ent->chunk, alloc); } /* end if */ @@ -3450,15 +3393,15 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) * even if we can't write the data to disk. */ point_of_no_return = TRUE; - ent->chunk = NULL; + ent->chunk = NULL; } /* end else */ H5_CHECKED_ASSIGN(nbytes, size_t, udata.chunk_block.length, hsize_t); - if(H5Z_pipeline(&(dset->shared->dcpl_cache.pline), 0, &(udata.filter_mask), - err_detect, filter_cb, &nbytes, &alloc, &buf) < 0) + if (H5Z_pipeline(&(dset->shared->dcpl_cache.pline), 0, &(udata.filter_mask), err_detect, + filter_cb, &nbytes, &alloc, &buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFILTER, FAIL, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if(nbytes > ((size_t)0xffffffff)) + if (nbytes > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") #endif /* H5_SIZEOF_SIZE_T > 4 */ H5_CHECKED_ASSIGN(udata.chunk_block.length, hsize_t, nbytes, size_t); @@ -3466,7 +3409,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) /* Indicate that the chunk must be allocated */ must_alloc = TRUE; } /* end if */ - else if(!H5F_addr_defined(udata.chunk_block.offset)) { + else if (!H5F_addr_defined(udata.chunk_block.offset)) { /* Indicate that the chunk must be allocated */ must_alloc = TRUE; @@ -3474,7 +3417,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) */ ent->edge_chunk_state &= ~H5D_RDCC_NEWLY_DISABLED_FILTERS; } /* end else */ - else if(ent->edge_chunk_state & H5D_RDCC_NEWLY_DISABLED_FILTERS) { + else if (ent->edge_chunk_state & H5D_RDCC_NEWLY_DISABLED_FILTERS) { /* Chunk on disk is still filtered, must insert to allocate correct * size */ must_alloc = TRUE; @@ -3490,17 +3433,18 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) /* Check if the chunk needs to be allocated (it also could exist already * and the chunk alloc operation could resize it) */ - if(must_alloc) { + if (must_alloc) { /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if(H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert, ent->scaled) < 0) + if (H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert, + ent->scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Update the chunk entry's info, in case it was allocated or relocated */ @@ -3511,12 +3455,13 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) /* Write the data to the file */ HDassert(H5F_addr_defined(udata.chunk_block.offset)); H5_CHECK_OVERFLOW(udata.chunk_block.length, hsize_t, size_t); - if(H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, (size_t)udata.chunk_block.length, buf) < 0) + if (H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, + (size_t)udata.chunk_block.length, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data to file") /* Insert the chunk record into the index */ - if(need_insert && sc->ops->insert) - if((sc->ops->insert)(&idx_info, &udata, dset) < 0) + if (need_insert && sc->ops->insert) + if ((sc->ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") /* Cache the chunk's info, in case it's accessed again shortly */ @@ -3530,19 +3475,20 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) } /* end if */ /* Reset, but do not free or removed from list */ - if(reset) { + if (reset) { point_of_no_return = FALSE; - if(buf == ent->chunk) + if (buf == ent->chunk) buf = NULL; - if(ent->chunk != NULL) + if (ent->chunk != NULL) ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, - ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) ? NULL - : &(dset->shared->dcpl_cache.pline))); + ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) + ? NULL + : &(dset->shared->dcpl_cache.pline))); } /* end if */ done: /* Free the temp buffer only if it's different than the entry chunk */ - if(buf != ent->chunk) + if (buf != ent->chunk) H5MM_xfree(buf); /* @@ -3551,16 +3497,16 @@ done: * output pipeline failed. Do not free the entry or remove it from the * list. */ - if(ret_value < 0 && point_of_no_return) - if(ent->chunk) + if (ret_value < 0 && point_of_no_return) + if (ent->chunk) ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, - ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) ? NULL - : &(dset->shared->dcpl_cache.pline))); + ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) + ? NULL + : &(dset->shared->dcpl_cache.pline))); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_flush_entry() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cache_evict * @@ -3577,8 +3523,8 @@ done: static herr_t H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush) { - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3588,37 +3534,38 @@ H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush) HDassert(!ent->locked); HDassert(ent->idx < rdcc->nslots); - if(flush) { + if (flush) { /* Flush */ - if(H5D__chunk_flush_entry(dset, ent, TRUE) < 0) + if (H5D__chunk_flush_entry(dset, ent, TRUE) < 0) HDONE_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") } /* end if */ else { /* Don't flush, just free chunk */ - if(ent->chunk != NULL) + if (ent->chunk != NULL) ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, - ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) ? NULL - : &(dset->shared->dcpl_cache.pline))); + ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) + ? NULL + : &(dset->shared->dcpl_cache.pline))); } /* end else */ /* Unlink from list */ - if(ent->prev) + if (ent->prev) ent->prev->next = ent->next; else rdcc->head = ent->next; - if(ent->next) + if (ent->next) ent->next->prev = ent->prev; else rdcc->tail = ent->prev; ent->prev = ent->next = NULL; /* Unlink from temporary list */ - if(ent->tmp_prev) { + if (ent->tmp_prev) { HDassert(rdcc->tmp_head->tmp_next); ent->tmp_prev->tmp_next = ent->tmp_next; - if(ent->tmp_next) { + if (ent->tmp_next) { ent->tmp_next->tmp_prev = ent->tmp_prev; - ent->tmp_next = NULL; + ent->tmp_next = NULL; } /* end if */ ent->tmp_prev = NULL; } /* end if */ @@ -3639,7 +3586,6 @@ H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_cache_evict() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cache_prune * @@ -3657,14 +3603,14 @@ H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush) static herr_t H5D__chunk_cache_prune(const H5D_t *dset, size_t size) { - const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); - size_t total = rdcc->nbytes_max; - const int nmeth = 2; /*number of methods */ - int w[1]; /*weighting as an interval */ - H5D_rdcc_ent_t *p[2], *cur; /*list pointers */ - H5D_rdcc_ent_t *n[2]; /*list next pointers */ - int nerrors = 0; /* Accumulated error count during preemptions */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); + size_t total = rdcc->nbytes_max; + const int nmeth = 2; /*number of methods */ + int w[1]; /*weighting as an interval */ + H5D_rdcc_ent_t * p[2], *cur; /*list pointers */ + H5D_rdcc_ent_t * n[2]; /*list next pointers */ + int nerrors = 0; /* Accumulated error count during preemptions */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3682,71 +3628,72 @@ H5D__chunk_cache_prune(const H5D_t *dset, size_t size) p[0] = rdcc->head; p[1] = NULL; - while((p[0] || p[1]) && (rdcc->nbytes_used + size) > total) { - int i; /* Local index variable */ + while ((p[0] || p[1]) && (rdcc->nbytes_used + size) > total) { + int i; /* Local index variable */ - /* Introduce new pointers */ - for(i = 0; i < nmeth - 1; i++) - if(0 == w[i]) + /* Introduce new pointers */ + for (i = 0; i < nmeth - 1; i++) + if (0 == w[i]) p[i + 1] = rdcc->head; - /* Compute next value for each pointer */ - for(i = 0; i < nmeth; i++) + /* Compute next value for each pointer */ + for (i = 0; i < nmeth; i++) n[i] = p[i] ? p[i]->next : NULL; - /* Give each method a chance */ - for(i = 0; i < nmeth && (rdcc->nbytes_used + size) > total; i++) { - if(0 == i && p[0] && !p[0]->locked && - ((0 == p[0]->rd_count && 0 == p[0]->wr_count) || - (0 == p[0]->rd_count && dset->shared->layout.u.chunk.size == p[0]->wr_count) || - (dset->shared->layout.u.chunk.size == p[0]->rd_count && 0 == p[0]->wr_count))) { - /* - * Method 0: Preempt entries that have been completely written - * and/or completely read but not entries that are partially - * written or partially read. - */ - cur = p[0]; - } else if(1 == i && p[1] && !p[1]->locked) { - /* - * Method 1: Preempt the entry without regard to - * considerations other than being locked. This is the last - * resort preemption. - */ - cur = p[1]; - } else { - /* Nothing to preempt at this point */ - cur = NULL; - } + /* Give each method a chance */ + for (i = 0; i < nmeth && (rdcc->nbytes_used + size) > total; i++) { + if (0 == i && p[0] && !p[0]->locked && + ((0 == p[0]->rd_count && 0 == p[0]->wr_count) || + (0 == p[0]->rd_count && dset->shared->layout.u.chunk.size == p[0]->wr_count) || + (dset->shared->layout.u.chunk.size == p[0]->rd_count && 0 == p[0]->wr_count))) { + /* + * Method 0: Preempt entries that have been completely written + * and/or completely read but not entries that are partially + * written or partially read. + */ + cur = p[0]; + } + else if (1 == i && p[1] && !p[1]->locked) { + /* + * Method 1: Preempt the entry without regard to + * considerations other than being locked. This is the last + * resort preemption. + */ + cur = p[1]; + } + else { + /* Nothing to preempt at this point */ + cur = NULL; + } - if(cur) { - int j; /* Local index variable */ + if (cur) { + int j; /* Local index variable */ - for(j = 0; j < nmeth; j++) { - if(p[j] == cur) + for (j = 0; j < nmeth; j++) { + if (p[j] == cur) p[j] = NULL; - if(n[j] == cur) + if (n[j] == cur) n[j] = cur->next; - } /* end for */ - if(H5D__chunk_cache_evict(dset, cur, TRUE) < 0) + } /* end for */ + if (H5D__chunk_cache_evict(dset, cur, TRUE) < 0) nerrors++; - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ - /* Advance pointers */ - for(i = 0; i < nmeth; i++) + /* Advance pointers */ + for (i = 0; i < nmeth; i++) p[i] = n[i]; - for(i = 0; i < nmeth - 1; i++) + for (i = 0; i < nmeth - 1; i++) w[i] -= 1; } /* end while */ - if(nerrors) - HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to preempt one or more raw data cache entry") + if (nerrors) + HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to preempt one or more raw data cache entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_cache_prune() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_lock * @@ -3775,22 +3722,23 @@ done: *------------------------------------------------------------------------- */ static void * -H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, - hbool_t relax, hbool_t prev_unfilt_chunk) +H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax, hbool_t prev_unfilt_chunk) { - const H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ - const H5O_pline_t *pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info - always equal to the pline passed to H5D__chunk_mem_alloc */ - const H5O_pline_t *old_pline = pline; /* Old pipeline, i.e. pipeline used to read the chunk */ - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - const H5O_fill_t *fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ - H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ - hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache*/ - H5D_rdcc_ent_t *ent; /*cache entry */ - size_t chunk_size; /*size of a chunk */ + const H5D_t * dset = io_info->dset; /* Local pointer to the dataset info */ + const H5O_pline_t *pline = + &(dset->shared->dcpl_cache + .pline); /* I/O pipeline info - always equal to the pline passed to H5D__chunk_mem_alloc */ + const H5O_pline_t * old_pline = pline; /* Old pipeline, i.e. pipeline used to read the chunk */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + const H5O_fill_t * fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ + H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ + hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ + H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache*/ + H5D_rdcc_ent_t * ent; /*cache entry */ + size_t chunk_size; /*size of a chunk */ hbool_t disable_filters = FALSE; /* Whether to disable filters (when adding to cache) */ - void *chunk = NULL; /*the file chunk */ - void *ret_value = NULL; /* Return value */ + void * chunk = NULL; /*the file chunk */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -3807,7 +3755,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, H5_CHECKED_ASSIGN(chunk_size, size_t, layout->u.chunk.size, uint32_t); /* Check if the chunk is in the cache */ - if(UINT_MAX != udata->idx_hint) { + if (UINT_MAX != udata->idx_hint) { /* Sanity check */ HDassert(udata->idx_hint < rdcc->nslots); HDassert(rdcc->slot[udata->idx_hint]); @@ -3816,13 +3764,13 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, ent = rdcc->slot[udata->idx_hint]; #ifndef NDEBUG -{ - unsigned u; /*counters */ + { + unsigned u; /*counters */ - /* Make sure this is the right chunk */ - for(u = 0; u < layout->u.chunk.ndims - 1; u++) - HDassert(io_info->store->chunk.scaled[u] == ent->scaled[u]); -} + /* Make sure this is the right chunk */ + for (u = 0; u < layout->u.chunk.ndims - 1; u++) + HDassert(io_info->store->chunk.scaled[u] == ent->scaled[u]); + } #endif /* NDEBUG */ /* @@ -3831,15 +3779,14 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, rdcc->stats.nhits++; /* Make adjustments if the edge chunk status changed recently */ - if(pline->nused) { + if (pline->nused) { /* If the chunk recently became an unfiltered partial edge chunk * while in cache, we must make some changes to the entry */ - if(udata->new_unfilt_chunk) { + if (udata->new_unfilt_chunk) { /* If this flag is set then partial chunk filters must be * disabled, and the chunk must not have previously been a * partial chunk (with disabled filters) */ - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); HDassert(!(ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS)); HDassert(old_pline->nused); @@ -3850,24 +3797,24 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Reallocate the chunk so H5D__chunk_mem_xfree doesn't get confused */ - if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") + if (NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") H5MM_memcpy(chunk, ent->chunk, chunk_size); ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, old_pline); ent->chunk = (uint8_t *)chunk; - chunk = NULL; + chunk = NULL; /* Mark the chunk as having filters disabled as well as "newly * disabled" so it is inserted on flush */ ent->edge_chunk_state |= H5D_RDCC_DISABLE_FILTERS; ent->edge_chunk_state |= H5D_RDCC_NEWLY_DISABLED_FILTERS; } /* end if */ - else if(prev_unfilt_chunk) { + else if (prev_unfilt_chunk) { /* If this flag is set then partial chunk filters must be * disabled, and the chunk must have previously been a partial * chunk (with disabled filters) */ - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); HDassert((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS)); HDassert(pline->nused); @@ -3876,82 +3823,79 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Reallocate the chunk so H5D__chunk_mem_xfree doesn't get confused */ - if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") + if (NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") H5MM_memcpy(chunk, ent->chunk, chunk_size); ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, old_pline); ent->chunk = (uint8_t *)chunk; - chunk = NULL; + chunk = NULL; /* Mark the chunk as having filters enabled */ - ent->edge_chunk_state &= ~(H5D_RDCC_DISABLE_FILTERS - | H5D_RDCC_NEWLY_DISABLED_FILTERS); + ent->edge_chunk_state &= ~(H5D_RDCC_DISABLE_FILTERS | H5D_RDCC_NEWLY_DISABLED_FILTERS); } /* end else */ - } /* end if */ + } /* end if */ /* * If the chunk is not at the beginning of the cache; move it backward * by one slot. This is how we implement the LRU preemption * algorithm. */ - if(ent->next) { - if(ent->next->next) + if (ent->next) { + if (ent->next->next) ent->next->next->prev = ent; else rdcc->tail = ent; ent->next->prev = ent->prev; - if(ent->prev) + if (ent->prev) ent->prev->next = ent->next; else rdcc->head = ent->next; - ent->prev = ent->next; - ent->next = ent->next->next; + ent->prev = ent->next; + ent->next = ent->next->next; ent->prev->next = ent; } /* end if */ - } /* end if */ + } /* end if */ else { - haddr_t chunk_addr; /* Address of chunk on disk */ - hsize_t chunk_alloc; /* Length of chunk on disk */ + haddr_t chunk_addr; /* Address of chunk on disk */ + hsize_t chunk_alloc; /* Length of chunk on disk */ /* Save the chunk info so the cache stays consistent */ - chunk_addr = udata->chunk_block.offset; + chunk_addr = udata->chunk_block.offset; chunk_alloc = udata->chunk_block.length; /* Check if we should disable filters on this chunk */ - if(pline->nused) { - if(udata->new_unfilt_chunk) { - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + if (pline->nused) { + if (udata->new_unfilt_chunk) { + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); /* Disable the filters for writing */ disable_filters = TRUE; - pline = NULL; + pline = NULL; } /* end if */ - else if(prev_unfilt_chunk) { - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + else if (prev_unfilt_chunk) { + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); /* Mark the filters as having been previously disabled (for the * chunk as currently on disk) - disable the filters for reading */ old_pline = NULL; } /* end if */ - else if(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { + else if (layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { /* Check if this is an edge chunk */ - if(H5D__chunk_is_partial_edge_chunk(io_info->dset->shared->ndims, - layout->u.chunk.dim, io_info->store->chunk.scaled, - io_info->dset->shared->curr_dims)) { + if (H5D__chunk_is_partial_edge_chunk(io_info->dset->shared->ndims, layout->u.chunk.dim, + io_info->store->chunk.scaled, + io_info->dset->shared->curr_dims)) { /* Disable the filters for both writing and reading */ disable_filters = TRUE; - old_pline = NULL; - pline = NULL; + old_pline = NULL; + pline = NULL; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ - if(relax) { + if (relax) { /* * Not in the cache, but we're about to overwrite the whole thing * anyway, so just allocate a buffer for it but don't initialize that @@ -3960,7 +3904,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, */ rdcc->stats.nhits++; - if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) + if (NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") /* In the case that some dataset functions look through this data, @@ -3974,65 +3918,69 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, */ /* Check if the chunk exists on disk */ - if(H5F_addr_defined(chunk_addr)) { - size_t my_chunk_alloc = chunk_alloc; /* Allocated buffer size */ - size_t buf_alloc = chunk_alloc; /* [Re-]allocated buffer size */ + if (H5F_addr_defined(chunk_addr)) { + size_t my_chunk_alloc = chunk_alloc; /* Allocated buffer size */ + size_t buf_alloc = chunk_alloc; /* [Re-]allocated buffer size */ /* Chunk size on disk isn't [likely] the same size as the final chunk * size in memory, so allocate memory big enough. */ - if(NULL == (chunk = H5D__chunk_mem_alloc(my_chunk_alloc, (udata->new_unfilt_chunk ? old_pline : pline)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") - if(H5F_shared_block_read(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, chunk_addr, my_chunk_alloc, chunk) < 0) + if (NULL == (chunk = H5D__chunk_mem_alloc(my_chunk_alloc, + (udata->new_unfilt_chunk ? old_pline : pline)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") + if (H5F_shared_block_read(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, chunk_addr, + my_chunk_alloc, chunk) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk") - if(old_pline && old_pline->nused) { - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ + if (old_pline && old_pline->nused) { + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + if (H5CX_get_err_detect(&err_detect) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get error detection info") - if(H5CX_get_filter_cb(&filter_cb) < 0) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get I/O filter callback function") - if(H5Z_pipeline(old_pline, H5Z_FLAG_REVERSE, &(udata->filter_mask), - err_detect, filter_cb, &my_chunk_alloc, &buf_alloc, &chunk) < 0) + if (H5Z_pipeline(old_pline, H5Z_FLAG_REVERSE, &(udata->filter_mask), err_detect, + filter_cb, &my_chunk_alloc, &buf_alloc, &chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFILTER, NULL, "data pipeline read failed") /* Reallocate chunk if necessary */ - if(udata->new_unfilt_chunk) { + if (udata->new_unfilt_chunk) { void *tmp_chunk = chunk; - if(NULL == (chunk = H5D__chunk_mem_alloc(my_chunk_alloc, pline))) { + if (NULL == (chunk = H5D__chunk_mem_alloc(my_chunk_alloc, pline))) { (void)H5D__chunk_mem_xfree(tmp_chunk, old_pline); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") } /* end if */ H5MM_memcpy(chunk, tmp_chunk, chunk_size); (void)H5D__chunk_mem_xfree(tmp_chunk, old_pline); } /* end if */ - } /* end if */ + } /* end if */ /* Increment # of cache misses */ rdcc->stats.nmisses++; } /* end if */ else { - H5D_fill_value_t fill_status; + H5D_fill_value_t fill_status; /* Sanity check */ HDassert(fill->alloc_time != H5D_ALLOC_TIME_EARLY); /* Chunk size on disk isn't [likely] the same size as the final chunk * size in memory, so allocate memory big enough. */ - if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") + if (NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't tell if fill value defined") - if(fill->fill_time == H5D_FILL_TIME_ALLOC || - (fill->fill_time == H5D_FILL_TIME_IFSET && - (fill_status == H5D_FILL_VALUE_USER_DEFINED || - fill_status == H5D_FILL_VALUE_DEFAULT))) { + if (fill->fill_time == H5D_FILL_TIME_ALLOC || + (fill->fill_time == H5D_FILL_TIME_IFSET && + (fill_status == H5D_FILL_VALUE_USER_DEFINED || fill_status == H5D_FILL_VALUE_DEFAULT))) { /* * The chunk doesn't exist in the file. Replicate the fill * value throughout the chunk, if the fill value is defined. @@ -4040,16 +3988,16 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Initialize the fill value buffer */ /* (use the compact dataset storage buffer as the fill value buffer) */ - if(H5D__fill_init(&fb_info, chunk, NULL, NULL, NULL, NULL, - &dset->shared->dcpl_cache.fill, dset->shared->type, - dset->shared->type_id, (size_t)0, chunk_size) < 0) + if (H5D__fill_init(&fb_info, chunk, NULL, NULL, NULL, NULL, + &dset->shared->dcpl_cache.fill, dset->shared->type, + dset->shared->type_id, (size_t)0, chunk_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't initialize fill buffer info") fb_info_init = TRUE; /* Check for VL datatype & non-default fill value */ - if(fb_info.has_vlen_fill_type) + if (fb_info.has_vlen_fill_type) /* Fill the buffer with VL datatype fill values */ - if(H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) + if (H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, NULL, "can't refill fill value buffer") } /* end if */ else @@ -4058,36 +4006,36 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Increment # of creations */ rdcc->stats.ninits++; } /* end else */ - } /* end else */ + } /* end else */ /* See if the chunk can be cached */ - if(rdcc->nslots > 0 && chunk_size <= rdcc->nbytes_max) { + if (rdcc->nslots > 0 && chunk_size <= rdcc->nbytes_max) { /* Calculate the index */ udata->idx_hint = H5D__chunk_hash_val(io_info->dset->shared, udata->common.scaled); /* Add the chunk to the cache only if the slot is not already locked */ ent = rdcc->slot[udata->idx_hint]; - if(!ent || !ent->locked) { + if (!ent || !ent->locked) { /* Preempt enough things from the cache to make room */ - if(ent) { - if(H5D__chunk_cache_evict(io_info->dset, ent, TRUE) < 0) + if (ent) { + if (H5D__chunk_cache_evict(io_info->dset, ent, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk from cache") } /* end if */ - if(H5D__chunk_cache_prune(io_info->dset, chunk_size) < 0) + if (H5D__chunk_cache_prune(io_info->dset, chunk_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache") /* Create a new entry */ - if(NULL == (ent = H5FL_CALLOC(H5D_rdcc_ent_t))) + if (NULL == (ent = H5FL_CALLOC(H5D_rdcc_ent_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate raw data chunk entry") ent->edge_chunk_state = disable_filters ? H5D_RDCC_DISABLE_FILTERS : 0; - if(udata->new_unfilt_chunk) + if (udata->new_unfilt_chunk) ent->edge_chunk_state |= H5D_RDCC_NEWLY_DISABLED_FILTERS; /* Initialize the new entry */ ent->chunk_block.offset = chunk_addr; ent->chunk_block.length = chunk_alloc; - ent->chunk_idx = udata->chunk_idx; + ent->chunk_idx = udata->chunk_idx; H5MM_memcpy(ent->scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); H5_CHECKED_ASSIGN(ent->rd_count, uint32_t, chunk_size, size_t); H5_CHECKED_ASSIGN(ent->wr_count, uint32_t, chunk_size, size_t); @@ -4096,15 +4044,15 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Add it to the cache */ HDassert(NULL == rdcc->slot[udata->idx_hint]); rdcc->slot[udata->idx_hint] = ent; - ent->idx = udata->idx_hint; + ent->idx = udata->idx_hint; rdcc->nbytes_used += chunk_size; rdcc->nused++; /* Add it to the linked list */ - if(rdcc->tail) { + if (rdcc->tail) { rdcc->tail->next = ent; - ent->prev = rdcc->tail; - rdcc->tail = ent; + ent->prev = rdcc->tail; + rdcc->tail = ent; } /* end if */ else rdcc->head = rdcc->tail = ent; @@ -4115,16 +4063,16 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, else /* We did not add the chunk to cache */ ent = NULL; - } /* end else */ + } /* end else */ else /* No cache set up, or chunk is too large: chunk is uncacheable */ ent = NULL; } /* end else */ /* Lock the chunk into the cache */ - if(ent) { + if (ent) { HDassert(!ent->locked); ent->locked = TRUE; - chunk = ent->chunk; + chunk = ent->chunk; } /* end if */ else /* @@ -4139,18 +4087,17 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, NULL, "Can't release fill buffer info") /* Release the chunk allocated, on error */ - if(!ret_value) - if(chunk) + if (!ret_value) + if (chunk) chunk = H5D__chunk_mem_xfree(chunk, pline); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_lock() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_unlock * @@ -4174,12 +4121,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, - hbool_t dirty, void *chunk, uint32_t naccessed) +H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, + uint32_t naccessed) { - const H5O_layout_t *layout = &(io_info->dset->shared->layout); /* Dataset layout */ - const H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout = &(io_info->dset->shared->layout); /* Dataset layout */ + const H5D_rdcc_t * rdcc = &(io_info->dset->shared->cache.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4187,7 +4134,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, HDassert(io_info); HDassert(udata); - if(UINT_MAX == udata->idx_hint) { + if (UINT_MAX == udata->idx_hint) { /* * It's not in the cache, probably because it's too big. If it's * dirty then flush it to disk. In any case, free the chunk. @@ -4195,57 +4142,57 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbool_t is_unfiltered_edge_chunk = FALSE; /* Whether the chunk is an unfiltered edge chunk */ /* Check if we should disable filters on this chunk */ - if(udata->new_unfilt_chunk) { + if (udata->new_unfilt_chunk) { HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); is_unfiltered_edge_chunk = TRUE; } /* end if */ - else if(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { + else if (layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { /* Check if the chunk is an edge chunk, and disable filters if so */ is_unfiltered_edge_chunk = H5D__chunk_is_partial_edge_chunk( - io_info->dset->shared->ndims, layout->u.chunk.dim, - io_info->store->chunk.scaled, io_info->dset->shared->curr_dims); + io_info->dset->shared->ndims, layout->u.chunk.dim, io_info->store->chunk.scaled, + io_info->dset->shared->curr_dims); } /* end if */ - if(dirty) { - H5D_rdcc_ent_t fake_ent; /* "fake" chunk cache entry */ + if (dirty) { + H5D_rdcc_ent_t fake_ent; /* "fake" chunk cache entry */ HDmemset(&fake_ent, 0, sizeof(fake_ent)); fake_ent.dirty = TRUE; - if(is_unfiltered_edge_chunk) + if (is_unfiltered_edge_chunk) fake_ent.edge_chunk_state = H5D_RDCC_DISABLE_FILTERS; - if(udata->new_unfilt_chunk) + if (udata->new_unfilt_chunk) fake_ent.edge_chunk_state |= H5D_RDCC_NEWLY_DISABLED_FILTERS; - H5MM_memcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); + H5MM_memcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); HDassert(layout->u.chunk.size > 0); - fake_ent.chunk_idx = udata->chunk_idx; + fake_ent.chunk_idx = udata->chunk_idx; fake_ent.chunk_block.offset = udata->chunk_block.offset; fake_ent.chunk_block.length = udata->chunk_block.length; - fake_ent.chunk = (uint8_t *)chunk; + fake_ent.chunk = (uint8_t *)chunk; - if(H5D__chunk_flush_entry(io_info->dset, &fake_ent, TRUE) < 0) + if (H5D__chunk_flush_entry(io_info->dset, &fake_ent, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") } /* end if */ else { - if(chunk) - chunk = H5D__chunk_mem_xfree(chunk, (is_unfiltered_edge_chunk ? NULL - : &(io_info->dset->shared->dcpl_cache.pline))); + if (chunk) + chunk = H5D__chunk_mem_xfree( + chunk, (is_unfiltered_edge_chunk ? NULL : &(io_info->dset->shared->dcpl_cache.pline))); } /* end else */ - } /* end if */ + } /* end if */ else { - H5D_rdcc_ent_t *ent; /* Chunk's entry in the cache */ + H5D_rdcc_ent_t *ent; /* Chunk's entry in the cache */ /* Sanity check */ - HDassert(udata->idx_hint < rdcc->nslots); - HDassert(rdcc->slot[udata->idx_hint]); - HDassert(rdcc->slot[udata->idx_hint]->chunk == chunk); + HDassert(udata->idx_hint < rdcc->nslots); + HDassert(rdcc->slot[udata->idx_hint]); + HDassert(rdcc->slot[udata->idx_hint]->chunk == chunk); /* * It's in the cache so unlock it. */ ent = rdcc->slot[udata->idx_hint]; HDassert(ent->locked); - if(dirty) { + if (dirty) { ent->dirty = TRUE; ent->wr_count -= MIN(ent->wr_count, naccessed); } /* end if */ @@ -4258,7 +4205,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_unlock() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_allocated_cb * @@ -4284,7 +4230,6 @@ H5D__chunk_allocated_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* H5D__chunk_allocated_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_allocated * @@ -4302,12 +4247,12 @@ H5D__chunk_allocated_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) herr_t H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Raw data chunk cache */ - H5D_rdcc_ent_t *ent; /* Cache entry */ - hsize_t chunk_bytes = 0; /* Number of bytes allocated for chunks */ - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + const H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* Raw data chunk cache */ + H5D_rdcc_ent_t * ent; /* Cache entry */ + hsize_t chunk_bytes = 0; /* Number of bytes allocated for chunks */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4316,20 +4261,21 @@ H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes) H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Search for cached chunks that haven't been written out */ - for(ent = rdcc->head; ent; ent = ent->next) + for (ent = rdcc->head; ent; ent = ent->next) /* Flush the chunk out to disk, to make certain the size is correct later */ - if(H5D__chunk_flush_entry(dset, ent, FALSE) < 0) + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Iterate over the chunks */ - if((sc->ops->iterate)(&idx_info, H5D__chunk_allocated_cb, &chunk_bytes) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") + if ((sc->ops->iterate)(&idx_info, H5D__chunk_allocated_cb, &chunk_bytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve allocated chunk information from index") /* Set number of bytes for caller */ *nbytes = chunk_bytes; @@ -4338,7 +4284,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_allocated() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_allocate * @@ -4356,41 +4301,46 @@ done: herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]) { - const H5D_t *dset = io_info->dset; /* the dataset pointer */ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - const H5D_chunk_ops_t *ops = dset->shared->layout.storage.u.chunk.ops; /* Chunk operations */ - hsize_t min_unalloc[H5O_LAYOUT_NDIMS]; /* First chunk in each dimension that is unallocated (in scaled coordinates) */ - hsize_t max_unalloc[H5O_LAYOUT_NDIMS]; /* Last chunk in each dimension that is unallocated (in scaled coordinates) */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Offset of current chunk (in scaled coordinates) */ - size_t orig_chunk_size; /* Original size of chunk in bytes */ - size_t chunk_size; /* Actual size of chunk in bytes, possibly filtered */ - unsigned filter_mask = 0; /* Filter mask for chunks that have them */ - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - const H5O_pline_t *pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info */ - const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default pipeline */ - const H5O_fill_t *fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ - H5D_fill_value_t fill_status; /* The fill value status */ - hbool_t should_fill = FALSE; /* Whether fill values should be written */ - void *unfilt_fill_buf = NULL; /* Unfiltered fill value buffer */ - void **fill_buf = NULL; /* Pointer to the fill buffer to use for a chunk */ + const H5D_t * dset = io_info->dset; /* the dataset pointer */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + const H5D_chunk_ops_t *ops = dset->shared->layout.storage.u.chunk.ops; /* Chunk operations */ + hsize_t min_unalloc[H5O_LAYOUT_NDIMS]; /* First chunk in each dimension that is unallocated (in scaled + coordinates) */ + hsize_t max_unalloc[H5O_LAYOUT_NDIMS]; /* Last chunk in each dimension that is unallocated (in scaled + coordinates) */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Offset of current chunk (in scaled coordinates) */ + size_t orig_chunk_size; /* Original size of chunk in bytes */ + size_t chunk_size; /* Actual size of chunk in bytes, possibly filtered */ + unsigned filter_mask = 0; /* Filter mask for chunks that have them */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + const H5O_pline_t * pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info */ + const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default pipeline */ + const H5O_fill_t * fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ + H5D_fill_value_t fill_status; /* The fill value status */ + hbool_t should_fill = FALSE; /* Whether fill values should be written */ + void * unfilt_fill_buf = NULL; /* Unfiltered fill value buffer */ + void ** fill_buf = NULL; /* Pointer to the fill buffer to use for a chunk */ #ifdef H5_HAVE_PARALLEL - hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */ - hbool_t using_mpi = FALSE; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */ + hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */ + hbool_t using_mpi = + FALSE; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */ H5D_chunk_coll_info_t chunk_info; /* chunk address information for doing I/O */ -#endif /* H5_HAVE_PARALLEL */ - hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ - unsigned space_ndims; /* Dataset's space rank */ - const hsize_t *space_dim; /* Dataset's dataspace dimensions */ - const uint32_t *chunk_dim = layout->u.chunk.dim; /* Convenience pointer to chunk dimensions */ - unsigned op_dim; /* Current operating dimension */ - H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ - hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ - hbool_t has_unfilt_edge_chunks = FALSE; /* Whether there are partial edge chunks with disabled filters */ - hbool_t unfilt_edge_chunk_dim[H5O_LAYOUT_NDIMS]; /* Whether there are unfiltered edge chunks at the edge of each dimension */ - hsize_t edge_chunk_scaled[H5O_LAYOUT_NDIMS]; /* Offset of the unfiltered edge chunks at the edge of each dimension */ - unsigned nunfilt_edge_chunk_dims = 0; /* Number of dimensions on an edge */ - const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ +#endif /* H5_HAVE_PARALLEL */ + hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ + unsigned space_ndims; /* Dataset's space rank */ + const hsize_t * space_dim; /* Dataset's dataspace dimensions */ + const uint32_t * chunk_dim = layout->u.chunk.dim; /* Convenience pointer to chunk dimensions */ + unsigned op_dim; /* Current operating dimension */ + H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ + hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ + hbool_t has_unfilt_edge_chunks = FALSE; /* Whether there are partial edge chunks with disabled filters */ + hbool_t unfilt_edge_chunk_dim[H5O_LAYOUT_NDIMS]; /* Whether there are unfiltered edge chunks at the edge + of each dimension */ + hsize_t edge_chunk_scaled[H5O_LAYOUT_NDIMS]; /* Offset of the unfiltered edge chunks at the edge of each + dimension */ + unsigned nunfilt_edge_chunk_dims = 0; /* Number of dimensions on an edge */ + const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4400,7 +4350,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Retrieve the dataset dimensions */ - space_dim = dset->shared->curr_dims; + space_dim = dset->shared->curr_dims; space_ndims = dset->shared->ndims; /* The last dimension in scaled chunk coordinates is always 0 */ @@ -4408,8 +4358,8 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ /* Check if any space dimensions are 0, if so we do not have to do anything */ - for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) - if(space_dim[op_dim] == 0) { + for (op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) + if (space_dim[op_dim] == 0) { /* Reset any cached chunk info for this dataset */ H5D__chunk_cinfo_cache_reset(&dset->shared->cache.chunk.last); HGOTO_DONE(SUCCEED) @@ -4417,23 +4367,23 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ - if(H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) { /* Set the MPI-capable file driver flag */ using_mpi = TRUE; /* init chunk info stuff for collective I/O */ chunk_info.num_io = 0; - chunk_info.addr = NULL; - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + chunk_info.addr = NULL; + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ /* Calculate the minimum and maximum chunk offsets in each dimension, and * determine if there are any unfiltered partial edge chunks. Note that we * assume here that all elements of space_dim are > 0. This is checked at * the top of this function. */ - for(op_dim=0; op_dim 0, dim = %u ", op_dim) min_unalloc[op_dim] = (old_dim[op_dim] + chunk_dim[op_dim] - 1) / chunk_dim[op_dim]; max_unalloc[op_dim] = (space_dim[op_dim] - 1) / chunk_dim[op_dim]; @@ -4441,13 +4391,11 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ /* Calculate if there are unfiltered edge chunks at the edge of this * dimension. Note the edge_chunk_scaled is uninitialized for * dimensions where unfilt_edge_chunk_dim is FALSE. Also */ - if((layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) - && pline->nused > 0 - && space_dim[op_dim] % chunk_dim[op_dim] != 0) { - has_unfilt_edge_chunks = TRUE; + if ((layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && pline->nused > 0 && + space_dim[op_dim] % chunk_dim[op_dim] != 0) { + has_unfilt_edge_chunks = TRUE; unfilt_edge_chunk_dim[op_dim] = TRUE; - edge_chunk_scaled[op_dim] = max_unalloc[op_dim]; + edge_chunk_scaled[op_dim] = max_unalloc[op_dim]; } /* end if */ else unfilt_edge_chunk_dim[op_dim] = FALSE; @@ -4457,7 +4405,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ H5_CHECKED_ASSIGN(orig_chunk_size, size_t, layout->u.chunk.size, uint32_t); /* Check the dataset's fill-value status */ - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are filling the dataset on allocation or "if set" and @@ -4465,22 +4413,21 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ * or if there are any pipeline filters defined, * set the "should fill" flag */ - if((!full_overwrite && (fill->fill_time == H5D_FILL_TIME_ALLOC || - (fill->fill_time == H5D_FILL_TIME_IFSET && - (fill_status == H5D_FILL_VALUE_USER_DEFINED || - fill_status == H5D_FILL_VALUE_DEFAULT)))) - || pline->nused > 0) + if ((!full_overwrite && + (fill->fill_time == H5D_FILL_TIME_ALLOC || + (fill->fill_time == H5D_FILL_TIME_IFSET && + (fill_status == H5D_FILL_VALUE_USER_DEFINED || fill_status == H5D_FILL_VALUE_DEFAULT)))) || + pline->nused > 0) should_fill = TRUE; /* Check if fill values should be written to chunks */ - if(should_fill) { + if (should_fill) { /* Initialize the fill value buffer */ /* (delay allocating fill buffer for VL datatypes until refilling) */ /* (casting away const OK - QAK) */ - if(H5D__fill_init(&fb_info, NULL, (H5MM_allocate_t)H5D__chunk_mem_alloc, - (void *)pline, (H5MM_free_t)H5D__chunk_mem_xfree, (void *)pline, - &dset->shared->dcpl_cache.fill, dset->shared->type, - dset->shared->type_id, (size_t)0, orig_chunk_size) < 0) + if (H5D__fill_init(&fb_info, NULL, (H5MM_allocate_t)H5D__chunk_mem_alloc, (void *)pline, + (H5MM_free_t)H5D__chunk_mem_xfree, (void *)pline, &dset->shared->dcpl_cache.fill, + dset->shared->type, dset->shared->type_id, (size_t)0, orig_chunk_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; @@ -4493,40 +4440,42 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ /* (only do this in advance when the chunk info can be re-used (i.e. * it doesn't contain any non-default VL datatype fill values) */ - if(!fb_info.has_vlen_fill_type && pline->nused > 0) { - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ - size_t buf_size = orig_chunk_size; + if (!fb_info.has_vlen_fill_type && pline->nused > 0) { + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ + size_t buf_size = orig_chunk_size; /* If the dataset has disabled partial chunk filters, create a copy * of the unfiltered fill_buf to use for partial chunks */ - if(has_unfilt_edge_chunks) { - if(NULL == (unfilt_fill_buf = H5D__chunk_mem_alloc(orig_chunk_size, &def_pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk") + if (has_unfilt_edge_chunks) { + if (NULL == (unfilt_fill_buf = H5D__chunk_mem_alloc(orig_chunk_size, &def_pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for raw data chunk") H5MM_memcpy(unfilt_fill_buf, fb_info.fill_buf, orig_chunk_size); } /* end if */ /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + if (H5CX_get_err_detect(&err_detect) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get error detection info") - if(H5CX_get_filter_cb(&filter_cb) < 0) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") /* Push the chunk through the filters */ - if(H5Z_pipeline(pline, 0, &filter_mask, err_detect, filter_cb, &orig_chunk_size, &buf_size, &fb_info.fill_buf) < 0) + if (H5Z_pipeline(pline, 0, &filter_mask, err_detect, filter_cb, &orig_chunk_size, &buf_size, + &fb_info.fill_buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if(orig_chunk_size > ((size_t)0xffffffff)) + if (orig_chunk_size > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") -#endif /* H5_SIZEOF_SIZE_T > 4 */ +#endif /* H5_SIZEOF_SIZE_T > 4 */ } /* end if */ - } /* end if */ + } /* end if */ /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Loop over all chunks */ @@ -4551,114 +4500,116 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ * */ chunk_size = orig_chunk_size; - for(op_dim = 0; op_dim < space_ndims; op_dim++) { - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - unsigned u; /* Local index variable */ - int i; /* Local index variable */ + for (op_dim = 0; op_dim < space_ndims; op_dim++) { + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + unsigned u; /* Local index variable */ + int i; /* Local index variable */ /* Check if allocation along this dimension is really necessary */ - if(min_unalloc[op_dim] > max_unalloc[op_dim]) + if (min_unalloc[op_dim] > max_unalloc[op_dim]) continue; else { /* Reset the chunk offset indices */ HDmemset(scaled, 0, (space_ndims * sizeof(scaled[0]))); scaled[op_dim] = min_unalloc[op_dim]; - if(has_unfilt_edge_chunks) { + if (has_unfilt_edge_chunks) { /* Initialize nunfilt_edge_chunk_dims */ nunfilt_edge_chunk_dims = 0; - for(u = 0; u < space_ndims; u++) - if(unfilt_edge_chunk_dim[u] && scaled[u] - == edge_chunk_scaled[u]) + for (u = 0; u < space_ndims; u++) + if (unfilt_edge_chunk_dim[u] && scaled[u] == edge_chunk_scaled[u]) nunfilt_edge_chunk_dims++; /* Initialize chunk_size and fill_buf */ - if(should_fill && !fb_info.has_vlen_fill_type) { + if (should_fill && !fb_info.has_vlen_fill_type) { HDassert(fb_info_init); HDassert(unfilt_fill_buf); - if(nunfilt_edge_chunk_dims) { - fill_buf = &unfilt_fill_buf; + if (nunfilt_edge_chunk_dims) { + fill_buf = &unfilt_fill_buf; chunk_size = layout->u.chunk.size; } /* end if */ else { - fill_buf = &fb_info.fill_buf; + fill_buf = &fb_info.fill_buf; chunk_size = orig_chunk_size; } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ carry = FALSE; } /* end else */ - while(!carry) { - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + while (!carry) { + hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ /* Look up this chunk */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") #ifndef NDEBUG /* None of the chunks should be allocated */ - if(H5D_CHUNK_IDX_NONE != sc->idx_type) { + if (H5D_CHUNK_IDX_NONE != sc->idx_type) { HDassert(!H5F_addr_defined(udata.chunk_block.offset)); } /* Make sure the chunk is really in the dataset and outside the * original dimensions */ { - unsigned v; /* Local index variable */ - hbool_t outside_orig = FALSE; + unsigned v; /* Local index variable */ + hbool_t outside_orig = FALSE; - for(v = 0; v < space_ndims; v++) { + for (v = 0; v < space_ndims; v++) { HDassert((scaled[v] * chunk_dim[v]) < space_dim[v]); - if((scaled[v] * chunk_dim[v]) >= old_dim[v]) + if ((scaled[v] * chunk_dim[v]) >= old_dim[v]) outside_orig = TRUE; } /* end for */ HDassert(outside_orig); } /* end block */ -#endif /* NDEBUG */ +#endif /* NDEBUG */ /* Check for VL datatype & non-default fill value */ - if(fb_info_init && fb_info.has_vlen_fill_type) { + if (fb_info_init && fb_info.has_vlen_fill_type) { /* Sanity check */ HDassert(should_fill); HDassert(!unfilt_fill_buf); #ifdef H5_HAVE_PARALLEL - HDassert(!using_mpi); /* Can't write VL datatypes in parallel currently */ + HDassert(!using_mpi); /* Can't write VL datatypes in parallel currently */ #endif /* Check to make sure the buffer is large enough. It is * possible (though ill-advised) for the filter to shrink the * buffer. */ - if(fb_info.fill_buf_size < orig_chunk_size) { - if(NULL == (fb_info.fill_buf = H5D__chunk_mem_realloc(fb_info.fill_buf, orig_chunk_size, pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory reallocation failed for raw data chunk") + if (fb_info.fill_buf_size < orig_chunk_size) { + if (NULL == + (fb_info.fill_buf = H5D__chunk_mem_realloc(fb_info.fill_buf, orig_chunk_size, pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory reallocation failed for raw data chunk") fb_info.fill_buf_size = orig_chunk_size; } /* end if */ /* Fill the buffer with VL datatype fill values */ - if(H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) + if (H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") /* Check if there are filters which need to be applied to the chunk */ - if((pline->nused > 0) && !nunfilt_edge_chunk_dims) { - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ - size_t nbytes = orig_chunk_size; + if ((pline->nused > 0) && !nunfilt_edge_chunk_dims) { + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ + size_t nbytes = orig_chunk_size; /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + if (H5CX_get_err_detect(&err_detect) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get error detection info") - if(H5CX_get_filter_cb(&filter_cb) < 0) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") /* Push the chunk through the filters */ - if(H5Z_pipeline(pline, 0, &filter_mask, err_detect, filter_cb, &nbytes, &fb_info.fill_buf_size, &fb_info.fill_buf) < 0) + if (H5Z_pipeline(pline, 0, &filter_mask, err_detect, filter_cb, &nbytes, + &fb_info.fill_buf_size, &fb_info.fill_buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if(nbytes > ((size_t)0xffffffff)) + if (nbytes > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") #endif /* H5_SIZEOF_SIZE_T > 4 */ @@ -4672,36 +4623,38 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ } /* end if */ /* Initialize the chunk information */ - udata.common.layout = &layout->u.chunk; - udata.common.storage = sc; - udata.common.scaled = scaled; + udata.common.layout = &layout->u.chunk; + udata.common.storage = sc; + udata.common.scaled = scaled; udata.chunk_block.offset = HADDR_UNDEF; H5_CHECKED_ASSIGN(udata.chunk_block.length, uint32_t, chunk_size, size_t); udata.filter_mask = filter_mask; /* Allocate the chunk (with all processes) */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, scaled) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") + if (H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, scaled) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") HDassert(H5F_addr_defined(udata.chunk_block.offset)); /* Check if fill values should be written to chunks */ - if(should_fill) { + if (should_fill) { /* Sanity check */ HDassert(fb_info_init); HDassert(udata.chunk_block.length == chunk_size); #ifdef H5_HAVE_PARALLEL /* Check if this file is accessed with an MPI-capable file driver */ - if(using_mpi) { + if (using_mpi) { /* collect all chunk addresses to be written to write collectively at the end */ /* allocate/resize address array if no more space left */ /* Note that if we add support for parallel filters we must * also store an array of chunk sizes and pass it to the * apporpriate collective write function */ - if(0 == chunk_info.num_io % 1024) - if(NULL == (chunk_info.addr = (haddr_t *)H5MM_realloc(chunk_info.addr, (chunk_info.num_io + 1024) * sizeof(haddr_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for chunk addresses") + if (0 == chunk_info.num_io % 1024) + if (NULL == (chunk_info.addr = (haddr_t *)H5MM_realloc( + chunk_info.addr, (chunk_info.num_io + 1024) * sizeof(haddr_t)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "memory allocation failed for chunk addresses") /* Store the chunk's address for later */ chunk_info.addr[chunk_info.num_io] = udata.chunk_block.offset; @@ -4712,62 +4665,64 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ - if(H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, chunk_size, *fill_buf) < 0) + if (H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, + udata.chunk_block.offset, chunk_size, *fill_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") #ifdef H5_HAVE_PARALLEL } /* end else */ -#endif /* H5_HAVE_PARALLEL */ - } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + } /* end if */ /* Insert the chunk record into the index */ - if(need_insert && ops->insert) - if((ops->insert)(&idx_info, &udata, dset) < 0) + if (need_insert && ops->insert) + if ((ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") /* Increment indices and adjust the edge chunk state */ carry = TRUE; - for(i = ((int)space_ndims - 1); i >= 0; --i) { + for (i = ((int)space_ndims - 1); i >= 0; --i) { scaled[i]++; - if(scaled[i] > max_unalloc[i]) { - if((unsigned)i == op_dim) + if (scaled[i] > max_unalloc[i]) { + if ((unsigned)i == op_dim) scaled[i] = min_unalloc[i]; else scaled[i] = 0; /* Check if we just left the edge in this dimension */ - if(unfilt_edge_chunk_dim[i] - && edge_chunk_scaled[i] == max_unalloc[i] - && scaled[i] < edge_chunk_scaled[i]) { + if (unfilt_edge_chunk_dim[i] && edge_chunk_scaled[i] == max_unalloc[i] && + scaled[i] < edge_chunk_scaled[i]) { nunfilt_edge_chunk_dims--; - if(should_fill && nunfilt_edge_chunk_dims == 0 && !fb_info.has_vlen_fill_type) { - HDassert(!H5D__chunk_is_partial_edge_chunk(space_ndims, chunk_dim, scaled, space_dim)); - fill_buf = &fb_info.fill_buf; + if (should_fill && nunfilt_edge_chunk_dims == 0 && !fb_info.has_vlen_fill_type) { + HDassert( + !H5D__chunk_is_partial_edge_chunk(space_ndims, chunk_dim, scaled, space_dim)); + fill_buf = &fb_info.fill_buf; chunk_size = orig_chunk_size; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* Check if we just entered the edge in this dimension */ - if(unfilt_edge_chunk_dim[i] && scaled[i] == edge_chunk_scaled[i]) { + if (unfilt_edge_chunk_dim[i] && scaled[i] == edge_chunk_scaled[i]) { HDassert(edge_chunk_scaled[i] == max_unalloc[i]); nunfilt_edge_chunk_dims++; - if(should_fill && nunfilt_edge_chunk_dims == 1 && !fb_info.has_vlen_fill_type) { - HDassert(H5D__chunk_is_partial_edge_chunk(space_ndims, chunk_dim, scaled, space_dim)); - fill_buf = &unfilt_fill_buf; + if (should_fill && nunfilt_edge_chunk_dims == 1 && !fb_info.has_vlen_fill_type) { + HDassert( + H5D__chunk_is_partial_edge_chunk(space_ndims, chunk_dim, scaled, space_dim)); + fill_buf = &unfilt_fill_buf; chunk_size = layout->u.chunk.size; } /* end if */ - } /* end if */ + } /* end if */ carry = FALSE; break; } /* end else */ - } /* end for */ - } /* end while(!carry) */ + } /* end for */ + } /* end while(!carry) */ /* Adjust max_unalloc so we don't allocate the same chunk twice. Also * check if this dimension started from 0 (and hence allocated all of * the chunks. */ - if(min_unalloc[op_dim] == 0) + if (min_unalloc[op_dim] == 0) break; else max_unalloc[op_dim] = min_unalloc[op_dim] - 1; @@ -4775,8 +4730,8 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ #ifdef H5_HAVE_PARALLEL /* do final collective I/O */ - if(using_mpi && blocks_written) - if(H5D__chunk_collective_fill(dset, &chunk_info, chunk_size, fb_info.fill_buf) < 0) + if (using_mpi && blocks_written) + if (H5D__chunk_collective_fill(dset, &chunk_info, chunk_size, fb_info.fill_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") #endif /* H5_HAVE_PARALLEL */ @@ -4785,21 +4740,20 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") /* Free the unfiltered fill value buffer */ unfilt_fill_buf = H5D__chunk_mem_xfree(unfilt_fill_buf, &def_pline); #ifdef H5_HAVE_PARALLEL - if(using_mpi && chunk_info.addr) + if (using_mpi && chunk_info.addr) H5MM_free(chunk_info.addr); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_allocate() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_update_old_edge_chunks * @@ -4819,21 +4773,24 @@ done: herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) { - hsize_t old_edge_chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of first previously incomplete chunk in each dimension */ - hsize_t max_edge_chunk_sc[H5O_LAYOUT_NDIMS]; /* largest offset of chunks that might need to be modified in each dimension */ - hbool_t new_full_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of chunks in this dimension needs to be modified */ + hsize_t old_edge_chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of first previously incomplete chunk in each + dimension */ + hsize_t max_edge_chunk_sc[H5O_LAYOUT_NDIMS]; /* largest offset of chunks that might need to be modified in + each dimension */ + hbool_t new_full_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of chunks in this dimension needs to be + modified */ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - hsize_t chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of current chunk */ - const uint32_t *chunk_dim = layout->u.chunk.dim; /* Convenience pointer to chunk dimensions */ - unsigned space_ndims; /* Dataset's space rank */ - const hsize_t *space_dim; /* Dataset's dataspace dimensions */ - unsigned op_dim; /* Current operationg dimension */ - H5D_io_info_t chk_io_info; /* Chunked I/O info object */ - H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ - H5D_storage_t chk_store; /* Chunk storage information */ - void *chunk; /* The file chunk */ - hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of current chunk */ + const uint32_t * chunk_dim = layout->u.chunk.dim; /* Convenience pointer to chunk dimensions */ + unsigned space_ndims; /* Dataset's space rank */ + const hsize_t * space_dim; /* Dataset's dataspace dimensions */ + unsigned op_dim; /* Current operationg dimension */ + H5D_io_info_t chk_io_info; /* Chunked I/O info object */ + H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ + H5D_storage_t chk_store; /* Chunk storage information */ + void * chunk; /* The file chunk */ + hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4842,11 +4799,10 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); H5D_CHUNK_STORAGE_INDEX_CHK(&layout->storage.u.chunk); HDassert(dset->shared->dcpl_cache.pline.nused > 0); - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); /* Retrieve the dataset dimensions */ - space_dim = dset->shared->curr_dims; + space_dim = dset->shared->curr_dims; space_ndims = dset->shared->ndims; /* The last dimension in chunk_offset is always 0 */ @@ -4854,8 +4810,8 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) /* Check if any current dimensions are smaller than the chunk size, or if * any old dimensions are 0. If so we do not have to do anything. */ - for(op_dim=0; op_dimshared->cache.chunk.last); HGOTO_DONE(SUCCEED) @@ -4870,12 +4826,12 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) /* * Determine the edges of the dataset which need to be modified */ - for(op_dim=0; op_dim 0, dim = %u ", op_dim) /* Calculate offset of first previously incomplete chunk in this @@ -4885,24 +4841,24 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) /* Calculate the largest offset of chunks that might need to be * modified in this dimension */ max_edge_chunk_sc[op_dim] = MIN((old_dim[op_dim] - 1) / chunk_dim[op_dim], - MAX((space_dim[op_dim] / chunk_dim[op_dim]), 1) - 1); + MAX((space_dim[op_dim] / chunk_dim[op_dim]), 1) - 1); /* Check for old_dim aligned with chunk boundary in this dimension, if * so we do not need to modify chunks along the edge in this dimension */ - if(old_dim[op_dim] % chunk_dim[op_dim] == 0) + if (old_dim[op_dim] % chunk_dim[op_dim] == 0) continue; /* Check if the dataspace expanded enough to cause the old edge chunks * in this dimension to become full */ - if((space_dim[op_dim]/chunk_dim[op_dim]) >= (old_edge_chunk_sc[op_dim] + 1)) + if ((space_dim[op_dim] / chunk_dim[op_dim]) >= (old_edge_chunk_sc[op_dim] + 1)) new_full_dim[op_dim] = TRUE; } /* end for */ /* Main loop: fix old edge chunks */ - for(op_dim=0; op_dim= 0; --i) { - if((unsigned)i != op_dim) { - ++chunk_sc[i]; - if(chunk_sc[i] > (hsize_t) max_edge_chunk_sc[i]) + for (i = ((int)space_ndims - 1); i >= 0; --i) { + if ((unsigned)i != op_dim) { + ++chunk_sc[i]; + if (chunk_sc[i] > (hsize_t)max_edge_chunk_sc[i]) chunk_sc[i] = 0; else { carry = FALSE; break; } /* end else */ - } /* end if */ - } /* end for */ - } /* end while(!carry) */ + } /* end if */ + } /* end for */ + } /* end while(!carry) */ /* Adjust max_edge_chunk_sc so we don't modify the same chunk twice. * Also check if this dimension started from 0 (and hence modified all * of the old edge chunks. */ - if(old_edge_chunk_sc[op_dim] == 0) + if (old_edge_chunk_sc[op_dim] == 0) break; else --max_edge_chunk_sc[op_dim]; @@ -4987,41 +4942,41 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, - size_t chunk_size, const void *fill_buf) +H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, size_t chunk_size, + const void *fill_buf) { - MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */ - int mpi_rank = (-1); /* This process's rank */ - int mpi_size = (-1); /* MPI Comm size */ - int mpi_code; /* MPI return code */ - size_t num_blocks; /* Number of blocks between processes. */ - size_t leftover_blocks; /* Number of leftover blocks to handle */ - int blocks, leftover, block_len; /* converted to int for MPI */ - MPI_Aint *chunk_disp_array = NULL; - int *block_lens = NULL; - MPI_Datatype mem_type, file_type; - H5FD_mpio_xfer_t prev_xfer_mode; /* Previous data xfer mode */ - hbool_t have_xfer_mode = FALSE; /* Whether the previous xffer mode has been retrieved */ - hbool_t need_addr_sort = FALSE; - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */ + int mpi_rank = (-1); /* This process's rank */ + int mpi_size = (-1); /* MPI Comm size */ + int mpi_code; /* MPI return code */ + size_t num_blocks; /* Number of blocks between processes. */ + size_t leftover_blocks; /* Number of leftover blocks to handle */ + int blocks, leftover, block_len; /* converted to int for MPI */ + MPI_Aint * chunk_disp_array = NULL; + int * block_lens = NULL; + MPI_Datatype mem_type, file_type; + H5FD_mpio_xfer_t prev_xfer_mode; /* Previous data xfer mode */ + hbool_t have_xfer_mode = FALSE; /* Whether the previous xffer mode has been retrieved */ + hbool_t need_addr_sort = FALSE; + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get the MPI communicator */ - if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) + if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator") /* Get the MPI rank */ - if((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank") /* Get the MPI size */ - if((mpi_size = H5F_mpi_get_size(dset->oloc.file)) < 0) + if ((mpi_size = H5F_mpi_get_size(dset->oloc.file)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size") /* Distribute evenly the number of blocks between processes. */ - if(mpi_size == 0) + if (mpi_size == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Resulted in division by zero") num_blocks = (size_t)(chunk_info->num_io / (size_t)mpi_size); /* value should be the same on all procs */ @@ -5033,34 +4988,34 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, /* Cast values to types needed by MPI */ H5_CHECKED_ASSIGN(blocks, int, num_blocks, size_t); H5_CHECKED_ASSIGN(leftover, int, leftover_blocks, size_t); - H5_CHECKED_ASSIGN(block_len, int, chunk_size, size_t); + H5_CHECKED_ASSIGN(block_len, int, chunk_size, size_t); /* Allocate buffers */ /* (MSC - should not need block_lens if MPI_type_create_hindexed_block is working) */ - if(NULL == (block_lens = (int *)H5MM_malloc((size_t)(blocks + 1) * sizeof(int)))) + if (NULL == (block_lens = (int *)H5MM_malloc((size_t)(blocks + 1) * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk lengths buffer") - if(NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc((size_t)(blocks + 1) * sizeof(MPI_Aint)))) + if (NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc((size_t)(blocks + 1) * sizeof(MPI_Aint)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file displacement buffer") - for(i = 0 ; i < blocks ; i++) { + for (i = 0; i < blocks; i++) { /* store the chunk address as an MPI_Aint */ - chunk_disp_array[i] = (MPI_Aint)(chunk_info->addr[i + mpi_rank*blocks]); + chunk_disp_array[i] = (MPI_Aint)(chunk_info->addr[i + mpi_rank * blocks]); /* MSC - should not need this if MPI_type_create_hindexed_block is working */ block_lens[i] = block_len; /* make sure that the addresses in the datatype are monotonically non decreasing */ - if(i && (chunk_disp_array[i] < chunk_disp_array[i - 1])) + if (i && (chunk_disp_array[i] < chunk_disp_array[i - 1])) need_addr_sort = TRUE; } /* end for */ /* calculate if there are any leftover blocks after evenly distributing. If there are, then round robin the distribution to processes 0 -> leftover. */ - if(leftover && leftover > mpi_rank) { - chunk_disp_array[blocks] = (MPI_Aint)chunk_info->addr[blocks*mpi_size + mpi_rank]; - if(blocks && (chunk_disp_array[blocks] < chunk_disp_array[blocks - 1])) + if (leftover && leftover > mpi_rank) { + chunk_disp_array[blocks] = (MPI_Aint)chunk_info->addr[blocks * mpi_size + mpi_rank]; + if (blocks && (chunk_disp_array[blocks] < chunk_disp_array[blocks - 1])) need_addr_sort = TRUE; block_lens[blocks] = block_len; blocks++; @@ -5070,57 +5025,58 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, * Ensure that the blocks are sorted in monotonically non-decreasing * order of offset in the file. */ - if(need_addr_sort) + if (need_addr_sort) HDqsort(chunk_disp_array, blocks, sizeof(MPI_Aint), H5D__chunk_cmp_addr); /* MSC - should use this if MPI_type_create_hindexed block is working: * mpi_code = MPI_Type_create_hindexed_block(blocks, block_len, chunk_disp_array, MPI_BYTE, &file_type); */ mpi_code = MPI_Type_create_hindexed(blocks, block_lens, chunk_disp_array, MPI_BYTE, &file_type); - if(mpi_code != MPI_SUCCESS) + if (mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&file_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&file_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) mpi_code = MPI_Type_create_hvector(blocks, block_len, 0, MPI_BYTE, &mem_type); - if(mpi_code != MPI_SUCCESS) + if (mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&mem_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&mem_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* Set MPI-IO VFD properties */ /* Set MPI datatypes for operation */ - if(H5CX_set_mpi_coll_datatypes(mem_type, file_type) < 0) + if (H5CX_set_mpi_coll_datatypes(mem_type, file_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O properties") /* Get current transfer mode */ - if(H5CX_get_io_xfer_mode(&prev_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&prev_xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode") have_xfer_mode = TRUE; /* Set transfer mode */ - if(H5CX_set_io_xfer_mode(H5FD_MPIO_COLLECTIVE) < 0) + if (H5CX_set_io_xfer_mode(H5FD_MPIO_COLLECTIVE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode") /* Low-level write (collective) */ - if(H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, (haddr_t)0, (blocks) ? (size_t)1 : (size_t)0, fill_buf) < 0) + if (H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, (haddr_t)0, + (blocks) ? (size_t)1 : (size_t)0, fill_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") /* Barrier so processes don't race ahead */ - if(MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) done: - if(have_xfer_mode) + if (have_xfer_mode) /* Set transfer mode */ - if(H5CX_set_io_xfer_mode(prev_xfer_mode) < 0) + if (H5CX_set_io_xfer_mode(prev_xfer_mode) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode") /* free things */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) H5MM_xfree(chunk_disp_array); H5MM_xfree(block_lens); @@ -5128,25 +5084,24 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_fill() */ - static int H5D__chunk_cmp_addr(const void *addr1, const void *addr2) { MPI_Aint _addr1 = (MPI_Aint)0, _addr2 = (MPI_Aint)0; - int ret_value = 0; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - _addr1 = *((const MPI_Aint *) addr1); - _addr2 = *((const MPI_Aint *) addr2); + _addr1 = *((const MPI_Aint *)addr1); + _addr2 = *((const MPI_Aint *)addr2); #if MPI_VERSION >= 3 && MPI_SUBVERSION >= 1 { MPI_Aint diff = MPI_Aint_diff(_addr1, _addr2); - if(diff < (MPI_Aint)0) + if (diff < (MPI_Aint)0) ret_value = -1; - else if(diff > (MPI_Aint)0) + else if (diff > (MPI_Aint)0) ret_value = 1; else ret_value = 0; @@ -5159,7 +5114,6 @@ H5D__chunk_cmp_addr(const void *addr1, const void *addr2) } /* end H5D__chunk_cmp_addr() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_prune_fill * @@ -5176,21 +5130,21 @@ H5D__chunk_cmp_addr(const void *addr1, const void *addr2) static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) { - const H5D_io_info_t *io_info = udata->io_info; /* Local pointer to I/O info */ - const H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset's layout */ - unsigned rank = udata->common.layout->ndims - 1; /* Dataset rank */ - const hsize_t *scaled = udata->common.scaled; /* Scaled chunk offset */ - H5S_sel_iter_t *chunk_iter = NULL; /* Memory selection iteration info */ - hbool_t chunk_iter_init = FALSE; /* Whether the chunk iterator has been initialized */ - hsize_t sel_nelmts; /* Number of elements in selection */ - hsize_t count[H5O_LAYOUT_NDIMS]; /* Element count of hyperslab */ - size_t chunk_size; /*size of a chunk */ - void *chunk; /* The file chunk */ - H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ - uint32_t bytes_accessed; /* Bytes accessed in chunk */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_io_info_t *io_info = udata->io_info; /* Local pointer to I/O info */ + const H5D_t * dset = io_info->dset; /* Local pointer to the dataset info */ + const H5O_layout_t * layout = &(dset->shared->layout); /* Dataset's layout */ + unsigned rank = udata->common.layout->ndims - 1; /* Dataset rank */ + const hsize_t * scaled = udata->common.scaled; /* Scaled chunk offset */ + H5S_sel_iter_t * chunk_iter = NULL; /* Memory selection iteration info */ + hbool_t chunk_iter_init = FALSE; /* Whether the chunk iterator has been initialized */ + hsize_t sel_nelmts; /* Number of elements in selection */ + hsize_t count[H5O_LAYOUT_NDIMS]; /* Element count of hyperslab */ + size_t chunk_size; /*size of a chunk */ + void * chunk; /* The file chunk */ + H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ + uint32_t bytes_accessed; /* Bytes accessed in chunk */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -5199,44 +5153,42 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) H5_CHECKED_ASSIGN(chunk_size, size_t, layout->u.chunk.size, uint32_t); /* Get the info for the chunk in the file */ - if(H5D__chunk_lookup(dset, scaled, &chk_udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &chk_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") chk_udata.new_unfilt_chunk = new_unfilt_chunk; /* If this chunk does not exist in cache or on disk, no need to do anything */ - if(!H5F_addr_defined(chk_udata.chunk_block.offset) && UINT_MAX == chk_udata.idx_hint) + if (!H5F_addr_defined(chk_udata.chunk_block.offset) && UINT_MAX == chk_udata.idx_hint) HGOTO_DONE(SUCCEED) /* Initialize the fill value buffer, if necessary */ - if(!udata->fb_info_init) { + if (!udata->fb_info_init) { H5_CHECK_OVERFLOW(udata->elmts_per_chunk, uint32_t, size_t); - if(H5D__fill_init(&udata->fb_info, NULL, NULL, NULL, NULL, NULL, - &dset->shared->dcpl_cache.fill, - dset->shared->type, dset->shared->type_id, (size_t)udata->elmts_per_chunk, - chunk_size) < 0) + if (H5D__fill_init(&udata->fb_info, NULL, NULL, NULL, NULL, NULL, &dset->shared->dcpl_cache.fill, + dset->shared->type, dset->shared->type_id, (size_t)udata->elmts_per_chunk, + chunk_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") udata->fb_info_init = TRUE; } /* end if */ /* Compute the # of elements to leave with existing value, in each dimension */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { count[u] = MIN(layout->u.chunk.dim[u], (udata->space_dim[u] - (scaled[u] * layout->u.chunk.dim[u]))); HDassert(count[u] > 0); } /* end for */ /* Select all elements in chunk, to begin with */ - if(H5S_select_all(udata->chunk_space, TRUE) < 0) + if (H5S_select_all(udata->chunk_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "unable to select space") /* "Subtract out" the elements to keep */ - if(H5S_select_hyperslab(udata->chunk_space, H5S_SELECT_NOTB, udata->hyper_start, NULL, count, NULL) < 0) + if (H5S_select_hyperslab(udata->chunk_space, H5S_SELECT_NOTB, udata->hyper_start, NULL, count, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "unable to select hyperslab") /* Lock the chunk into the cache, to get a pointer to the chunk buffer */ - if(NULL == (chunk = (void *)H5D__chunk_lock(io_info, &chk_udata, FALSE, FALSE))) + if (NULL == (chunk = (void *)H5D__chunk_lock(io_info, &chk_udata, FALSE, FALSE))) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to lock raw data chunk") - /* Fill the selection in the memory buffer */ /* Use the size of the elements in the chunk directly instead of */ /* relying on the fill.size, which might be set to 0 if there is */ @@ -5247,45 +5199,43 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) H5_CHECK_OVERFLOW(sel_nelmts, hsize_t, size_t); /* Check for VL datatype & non-default fill value */ - if(udata->fb_info.has_vlen_fill_type) + if (udata->fb_info.has_vlen_fill_type) /* Re-fill the buffer to use for this I/O operation */ - if(H5D__fill_refill_vl(&udata->fb_info, (size_t)sel_nelmts) < 0) + if (H5D__fill_refill_vl(&udata->fb_info, (size_t)sel_nelmts) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") /* Allocate the chunk selection iterator */ - if(NULL == (chunk_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (chunk_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk selection iterator") /* Create a selection iterator for scattering the elements to memory buffer */ - if(H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank], 0) < 0) + if (H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank], 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunk selection information") chunk_iter_init = TRUE; /* Scatter the data into memory */ - if(H5D__scatter_mem(udata->fb_info.fill_buf, chunk_iter, (size_t)sel_nelmts, chunk/*out*/) < 0) + if (H5D__scatter_mem(udata->fb_info.fill_buf, chunk_iter, (size_t)sel_nelmts, chunk /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed") - /* The number of bytes accessed in the chunk */ /* (i.e. the bytes replaced with fill values) */ H5_CHECK_OVERFLOW(sel_nelmts, hssize_t, uint32_t); bytes_accessed = (uint32_t)sel_nelmts * layout->u.chunk.dim[rank]; /* Release lock on chunk */ - if(H5D__chunk_unlock(io_info, &chk_udata, TRUE, chunk, bytes_accessed) < 0) + if (H5D__chunk_unlock(io_info, &chk_udata, TRUE, chunk, bytes_accessed) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk") done: /* Release the selection iterator */ - if(chunk_iter_init && H5S_SELECT_ITER_RELEASE(chunk_iter) < 0) + if (chunk_iter_init && H5S_SELECT_ITER_RELEASE(chunk_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(chunk_iter) + if (chunk_iter) chunk_iter = H5FL_FREE(H5S_sel_iter_t, chunk_iter); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_prune_fill */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_prune_by_extent * @@ -5388,34 +5338,38 @@ done: herr_t H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) { - hsize_t min_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of first chunk to modify in each dimension */ - hsize_t max_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk to modify in each dimension */ - hssize_t max_fill_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk that might be filled in each dimension */ - hbool_t fill_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension needs to be filled */ - hsize_t min_partial_chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of first partial (or empty) chunk in each dimension */ - hbool_t new_unfilt_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension are newly unfiltered */ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_io_info_t chk_io_info; /* Chunked I/O info object */ - H5D_storage_t chk_store; /* Chunk storage information */ - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset's layout */ - const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ - unsigned space_ndims; /* Dataset's space rank */ - const hsize_t *space_dim; /* Current dataspace dimensions */ - unsigned op_dim; /* Current operating dimension */ - hbool_t shrunk_dim[H5O_LAYOUT_NDIMS]; /* Dimensions which have shrunk */ - H5D_chunk_it_ud1_t udata; /* Chunk index iterator user data */ - hbool_t udata_init = FALSE; /* Whether the chunk index iterator user data has been initialized */ - H5D_chunk_common_ud_t idx_udata; /* User data for index removal routine */ - H5S_t *chunk_space = NULL; /* Dataspace for a chunk */ - hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Chunk dimensions */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Scaled offset of current chunk */ - hsize_t hyper_start[H5O_LAYOUT_NDIMS]; /* Starting location of hyperslab */ - uint32_t elmts_per_chunk; /* Elements in chunk */ - hbool_t disable_edge_filters = FALSE; /* Whether to disable filters on partial edge chunks */ - hbool_t new_unfilt_chunk = FALSE; /* Whether the chunk is newly unfiltered */ - unsigned u; /* Local index variable */ - const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t min_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of first chunk to modify in each dimension */ + hsize_t max_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk to modify in each dimension */ + hssize_t max_fill_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk that might be filled in each + dimension */ + hbool_t fill_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension needs to be + filled */ + hsize_t min_partial_chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of first partial (or empty) chunk in each + dimension */ + hbool_t new_unfilt_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension are newly + unfiltered */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_io_info_t chk_io_info; /* Chunked I/O info object */ + H5D_storage_t chk_store; /* Chunk storage information */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset's layout */ + const H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ + unsigned space_ndims; /* Dataset's space rank */ + const hsize_t * space_dim; /* Current dataspace dimensions */ + unsigned op_dim; /* Current operating dimension */ + hbool_t shrunk_dim[H5O_LAYOUT_NDIMS]; /* Dimensions which have shrunk */ + H5D_chunk_it_ud1_t udata; /* Chunk index iterator user data */ + hbool_t udata_init = FALSE; /* Whether the chunk index iterator user data has been initialized */ + H5D_chunk_common_ud_t idx_udata; /* User data for index removal routine */ + H5S_t * chunk_space = NULL; /* Dataspace for a chunk */ + hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Chunk dimensions */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Scaled offset of current chunk */ + hsize_t hyper_start[H5O_LAYOUT_NDIMS]; /* Starting location of hyperslab */ + uint32_t elmts_per_chunk; /* Elements in chunk */ + hbool_t disable_edge_filters = FALSE; /* Whether to disable filters on partial edge chunks */ + hbool_t new_unfilt_chunk = FALSE; /* Whether the chunk is newly unfiltered */ + unsigned u; /* Local index variable */ + const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5425,15 +5379,15 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Go get the rank & dimensions (including the element size) */ - space_dim = dset->shared->curr_dims; + space_dim = dset->shared->curr_dims; space_ndims = dset->shared->ndims; /* The last dimension in scaled is always 0 */ scaled[space_ndims] = (hsize_t)0; /* Check if any old dimensions are 0, if so we do not have to do anything */ - for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) - if(old_dim[op_dim] == 0) { + for (op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) + if (old_dim[op_dim] == 0) { /* Reset any cached chunk info for this dataset */ H5D__chunk_cinfo_cache_reset(&dset->shared->cache.chunk.last); HGOTO_DONE(SUCCEED) @@ -5445,15 +5399,15 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) /* (also copy the chunk dimensions into 'hsize_t' array for creating dataspace) */ /* (also compute the dimensions which have been shrunk) */ elmts_per_chunk = 1; - for(u = 0; u < space_ndims; u++) { + for (u = 0; u < space_ndims; u++) { elmts_per_chunk *= layout->u.chunk.dim[u]; - chunk_dim[u] = layout->u.chunk.dim[u]; - shrunk_dim[u] = (space_dim[u] < old_dim[u]); + chunk_dim[u] = layout->u.chunk.dim[u]; + shrunk_dim[u] = (space_dim[u] < old_dim[u]); } /* end for */ /* Create a dataspace for a chunk & set the extent */ - if(NULL == (chunk_space = H5S_create_simple(space_ndims, chunk_dim, NULL))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") + if (NULL == (chunk_space = H5S_create_simple(space_ndims, chunk_dim, NULL))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Reset hyperslab start array */ /* (hyperslabs will always start from origin) */ @@ -5466,42 +5420,41 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) H5D_BUILD_IO_INFO_RD(&chk_io_info, dset, &chk_store, NULL); /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Initialize the user data for the iteration */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = &layout->u.chunk; - udata.common.storage = sc; - udata.common.scaled = scaled; - udata.io_info = &chk_io_info; - udata.idx_info = &idx_info; - udata.space_dim = space_dim; - udata.shrunk_dim = shrunk_dim; + udata.common.layout = &layout->u.chunk; + udata.common.storage = sc; + udata.common.scaled = scaled; + udata.io_info = &chk_io_info; + udata.idx_info = &idx_info; + udata.space_dim = space_dim; + udata.shrunk_dim = shrunk_dim; udata.elmts_per_chunk = elmts_per_chunk; - udata.chunk_space = chunk_space; - udata.hyper_start = hyper_start; - udata_init = TRUE; + udata.chunk_space = chunk_space; + udata.hyper_start = hyper_start; + udata_init = TRUE; /* Initialize user data for removal */ - idx_udata.layout = &layout->u.chunk; + idx_udata.layout = &layout->u.chunk; idx_udata.storage = sc; /* Determine if partial edge chunk filters are disabled */ - disable_edge_filters = (layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) - && (idx_info.pline->nused > 0); + disable_edge_filters = (layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + (idx_info.pline->nused > 0); /* * Determine the chunks which need to be filled or removed */ HDmemset(min_mod_chunk_sc, 0, sizeof(min_mod_chunk_sc)); HDmemset(max_mod_chunk_sc, 0, sizeof(max_mod_chunk_sc)); - for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { + for (op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { /* Validate this chunk dimension */ - if(chunk_dim[op_dim] == 0) + if (chunk_dim[op_dim] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", op_dim) /* Calculate the largest offset of chunks that might need to be @@ -5510,13 +5463,13 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) /* Calculate the largest offset of chunks that might need to be * filled in this dimension */ - if(0 == space_dim[op_dim]) + if (0 == space_dim[op_dim]) max_fill_chunk_sc[op_dim] = -1; else - max_fill_chunk_sc[op_dim] = (hssize_t)(((MIN(space_dim[op_dim], old_dim[op_dim]) - 1) - / chunk_dim[op_dim])); + max_fill_chunk_sc[op_dim] = + (hssize_t)(((MIN(space_dim[op_dim], old_dim[op_dim]) - 1) / chunk_dim[op_dim])); - if(shrunk_dim[op_dim]) { + if (shrunk_dim[op_dim]) { /* Calculate the smallest offset of chunks that might need to be * modified in this dimension. Note that this array contains * garbage for all dimensions which are not shrunk. These locations @@ -5524,41 +5477,41 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) min_mod_chunk_sc[op_dim] = space_dim[op_dim] / chunk_dim[op_dim]; /* Determine if we need to fill chunks in this dimension */ - if((hssize_t)min_mod_chunk_sc[op_dim] == max_fill_chunk_sc[op_dim]) { + if ((hssize_t)min_mod_chunk_sc[op_dim] == max_fill_chunk_sc[op_dim]) { fill_dim[op_dim] = TRUE; /* If necessary, check if chunks in this dimension that need to * be filled are new partial edge chunks */ - if(disable_edge_filters && old_dim[op_dim] >= (min_mod_chunk_sc[op_dim] + 1)) + if (disable_edge_filters && old_dim[op_dim] >= (min_mod_chunk_sc[op_dim] + 1)) new_unfilt_dim[op_dim] = TRUE; else new_unfilt_dim[op_dim] = FALSE; } /* end if */ else { - fill_dim[op_dim] = FALSE; + fill_dim[op_dim] = FALSE; new_unfilt_dim[op_dim] = FALSE; } /* end else */ - } /* end if */ + } /* end if */ else { - fill_dim[op_dim] = FALSE; + fill_dim[op_dim] = FALSE; new_unfilt_dim[op_dim] = FALSE; } /* end else */ /* If necessary, calculate the smallest offset of non-previously full * chunks in this dimension, so we know these chunks were previously * unfiltered */ - if(disable_edge_filters) + if (disable_edge_filters) min_partial_chunk_sc[op_dim] = old_dim[op_dim] / chunk_dim[op_dim]; } /* end for */ /* Main loop: fill or remove chunks */ - for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { + for (op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { hbool_t dims_outside_fill[H5O_LAYOUT_NDIMS]; /* Dimensions in chunk offset outside fill dimensions */ - int ndims_outside_fill; /* Number of dimensions in chunk offset outside fill dimensions */ - hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ + int ndims_outside_fill; /* Number of dimensions in chunk offset outside fill dimensions */ + hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ /* Check if modification along this dimension is really necessary */ - if(!shrunk_dim[op_dim]) + if (!shrunk_dim[op_dim]) continue; else { HDassert(max_mod_chunk_sc[op_dim] >= min_mod_chunk_sc[op_dim]); @@ -5569,8 +5522,8 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) /* Initialize "dims_outside_fill" array */ ndims_outside_fill = 0; - for(u = 0; u < space_ndims; u++) - if((hssize_t)scaled[u] > max_fill_chunk_sc[u]) { + for (u = 0; u < space_ndims; u++) + if ((hssize_t)scaled[u] > max_fill_chunk_sc[u]) { dims_outside_fill[u] = TRUE; ndims_outside_fill++; } /* end if */ @@ -5579,101 +5532,104 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) } /* end else */ carry = FALSE; - while(!carry) { - int i; /* Local index variable */ + while (!carry) { + int i; /* Local index variable */ udata.common.scaled = scaled; - if(0 == ndims_outside_fill) { + if (0 == ndims_outside_fill) { HDassert(fill_dim[op_dim]); HDassert(scaled[op_dim] == min_mod_chunk_sc[op_dim]); /* Make sure this is an edge chunk */ - HDassert(H5D__chunk_is_partial_edge_chunk(space_ndims, layout->u.chunk.dim, scaled, space_dim)); + HDassert( + H5D__chunk_is_partial_edge_chunk(space_ndims, layout->u.chunk.dim, scaled, space_dim)); /* Determine if the chunk just became an unfiltered chunk */ - if(new_unfilt_dim[op_dim]) { + if (new_unfilt_dim[op_dim]) { new_unfilt_chunk = TRUE; - for(u = 0; u < space_ndims; u++) - if(scaled[u] == min_partial_chunk_sc[u]) { + for (u = 0; u < space_ndims; u++) + if (scaled[u] == min_partial_chunk_sc[u]) { new_unfilt_chunk = FALSE; break; } /* end if */ - } /* end if */ + } /* end if */ /* Make sure that, if we think this is a new unfiltered chunk, * it was previously not an edge chunk */ - HDassert(!new_unfilt_dim[op_dim] || (!new_unfilt_chunk != - !H5D__chunk_is_partial_edge_chunk(space_ndims, layout->u.chunk.dim, scaled, old_dim))); + HDassert(!new_unfilt_dim[op_dim] || + (!new_unfilt_chunk != !H5D__chunk_is_partial_edge_chunk( + space_ndims, layout->u.chunk.dim, scaled, old_dim))); HDassert(!new_unfilt_chunk || new_unfilt_dim[op_dim]); /* Fill the unused parts of the chunk */ - if(H5D__chunk_prune_fill(&udata, new_unfilt_chunk) < 0) + if (H5D__chunk_prune_fill(&udata, new_unfilt_chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write fill value") } /* end if */ else { - H5D_chunk_ud_t chk_udata; /* User data for getting chunk info */ + H5D_chunk_ud_t chk_udata; /* User data for getting chunk info */ #ifndef NDEBUG /* Make sure this chunk is really outside the new dimensions */ { hbool_t outside_dim = FALSE; - for(u = 0; u < space_ndims; u++) - if((scaled[u] * chunk_dim[u]) >= space_dim[u]) { + for (u = 0; u < space_ndims; u++) + if ((scaled[u] * chunk_dim[u]) >= space_dim[u]) { outside_dim = TRUE; break; } /* end if */ HDassert(outside_dim); } /* end block */ -#endif /* NDEBUG */ +#endif /* NDEBUG */ /* Check if the chunk exists in cache or on disk */ - if(H5D__chunk_lookup(dset, scaled, &chk_udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &chk_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk") /* Evict the entry from the cache if present, but do not flush * it to disk */ - if(UINT_MAX != chk_udata.idx_hint) - if(H5D__chunk_cache_evict(dset, rdcc->slot[chk_udata.idx_hint], FALSE) < 0) + if (UINT_MAX != chk_udata.idx_hint) + if (H5D__chunk_cache_evict(dset, rdcc->slot[chk_udata.idx_hint], FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") /* Remove the chunk from disk, if present */ - if(H5F_addr_defined(chk_udata.chunk_block.offset)) { + if (H5F_addr_defined(chk_udata.chunk_block.offset)) { /* Update the offset in idx_udata */ - idx_udata.scaled = udata.common.scaled; + idx_udata.scaled = udata.common.scaled; /* Remove the chunk from disk */ - if((sc->ops->remove)(&idx_info, &idx_udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry from index") + if ((sc->ops->remove)(&idx_info, &idx_udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, + "unable to remove chunk entry from index") } /* end if */ - } /* end else */ + } /* end else */ /* Increment indices */ carry = TRUE; - for(i = (int)(space_ndims - 1); i >= 0; --i) { + for (i = (int)(space_ndims - 1); i >= 0; --i) { scaled[i]++; - if(scaled[i] > max_mod_chunk_sc[i]) { + if (scaled[i] > max_mod_chunk_sc[i]) { /* Left maximum dimensions, "wrap around" and check if this * dimension is no longer outside the fill dimension */ - if((unsigned)i == op_dim) { + if ((unsigned)i == op_dim) { scaled[i] = min_mod_chunk_sc[i]; - if(dims_outside_fill[i] && fill_dim[i]) { + if (dims_outside_fill[i] && fill_dim[i]) { dims_outside_fill[i] = FALSE; ndims_outside_fill--; } /* end if */ - } /* end if */ + } /* end if */ else { scaled[i] = 0; - if(dims_outside_fill[i] && max_fill_chunk_sc[i] >= 0) { + if (dims_outside_fill[i] && max_fill_chunk_sc[i] >= 0) { dims_outside_fill[i] = FALSE; ndims_outside_fill--; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Check if we just went outside the fill dimension */ - if(!dims_outside_fill[i] && (hssize_t)scaled[i] > max_fill_chunk_sc[i]) { + if (!dims_outside_fill[i] && (hssize_t)scaled[i] > max_fill_chunk_sc[i]) { dims_outside_fill[i] = TRUE; ndims_outside_fill++; } /* end if */ @@ -5682,13 +5638,13 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) carry = FALSE; break; } /* end else */ - } /* end for */ - } /* end while(!carry) */ + } /* end for */ + } /* end while(!carry) */ /* Adjust max_mod_chunk_sc so we don't modify the same chunk twice. * Also check if this dimension started from 0 (and hence removed all * of the chunks). */ - if(min_mod_chunk_sc[op_dim] == 0) + if (min_mod_chunk_sc[op_dim] == 0) break; else max_mod_chunk_sc[op_dim] = min_mod_chunk_sc[op_dim] - 1; @@ -5699,10 +5655,10 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) done: /* Release resources */ - if(chunk_space && H5S_close(chunk_space) < 0) + if (chunk_space && H5S_close(chunk_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(udata_init) - if(udata.fb_info_init && H5D__fill_term(&udata.fb_info) < 0) + if (udata_init) + if (udata.fb_info_init && H5D__fill_term(&udata.fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) @@ -5726,9 +5682,9 @@ done: static int H5D__chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5D_chunk_it_ud2_t *udata = (H5D_chunk_it_ud2_t *)_udata; /* User data for callback */ - unsigned rank = udata->common.layout->ndims - 1; /* # of dimensions of dataset */ - hsize_t chunk_index; + H5D_chunk_it_ud2_t *udata = (H5D_chunk_it_ud2_t *)_udata; /* User data for callback */ + unsigned rank = udata->common.layout->ndims - 1; /* # of dimensions of dataset */ + hsize_t chunk_index; FUNC_ENTER_STATIC_NOERR @@ -5741,7 +5697,6 @@ H5D__chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_addrmap_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_addrmap * @@ -5758,11 +5713,11 @@ H5D__chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) herr_t H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - const H5D_t *dset = io_info->dset; /* Local pointer to dataset info */ - H5D_chunk_it_ud2_t udata; /* User data for iteration callback */ - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + const H5D_t * dset = io_info->dset; /* Local pointer to dataset info */ + H5D_chunk_it_ud2_t udata; /* User data for iteration callback */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5773,18 +5728,18 @@ H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) /* Set up user data for B-tree callback */ HDmemset(&udata, 0, sizeof(udata)); - udata.common.layout = &dset->shared->layout.u.chunk; + udata.common.layout = &dset->shared->layout.u.chunk; udata.common.storage = sc; - udata.chunk_addr = chunk_addr; + udata.chunk_addr = chunk_addr; /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Iterate over chunks to build mapping of chunk addresses */ - if((sc->ops->iterate)(&idx_info, H5D__chunk_addrmap_cb, &udata) < 0) + if ((sc->ops->iterate)(&idx_info, H5D__chunk_addrmap_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to iterate over chunk index to build address map") done: @@ -5792,7 +5747,6 @@ done: } /* end H5D__chunk_addrmap() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_delete * @@ -5809,13 +5763,13 @@ done: herr_t H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5O_layout_t layout; /* Dataset layout message */ - hbool_t layout_read = FALSE; /* Whether the layout message was read from the file */ - H5O_pline_t pline; /* I/O pipeline message */ - hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read from the file */ - htri_t exists; /* Flag if header message of interest exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5O_layout_t layout; /* Dataset layout message */ + hbool_t layout_read = FALSE; /* Whether the layout message was read from the file */ + H5O_pline_t pline; /* I/O pipeline message */ + hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read from the file */ + htri_t exists; /* Flag if header message of interest exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5826,10 +5780,10 @@ H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) H5D_CHUNK_STORAGE_INDEX_CHK(&storage->u.chunk); /* Check for I/O pipeline message */ - if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to check for object header message") - else if(exists) { - if(NULL == H5O_msg_read_oh(f, oh, H5O_PLINE_ID, &pline)) + else if (exists) { + if (NULL == H5O_msg_read_oh(f, oh, H5O_PLINE_ID, &pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O pipeline message") pline_read = TRUE; } /* end else if */ @@ -5837,10 +5791,10 @@ H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) HDmemset(&pline, 0, sizeof(pline)); /* Retrieve dataset layout message */ - if((exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to check for object header message") - else if(exists) { - if(NULL == H5O_msg_read_oh(f, oh, H5O_LAYOUT_ID, &layout)) + else if (exists) { + if (NULL == H5O_msg_read_oh(f, oh, H5O_LAYOUT_ID, &layout)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout message") layout_read = TRUE; } /* end else if */ @@ -5848,28 +5802,27 @@ H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "can't find layout message") /* Compose chunked index info struct */ - idx_info.f = f; - idx_info.pline = &pline; - idx_info.layout = &layout.u.chunk; + idx_info.f = f; + idx_info.pline = &pline; + idx_info.layout = &layout.u.chunk; idx_info.storage = &storage->u.chunk; /* Delete the chunked storage information in the file */ - if((storage->u.chunk.ops->idx_delete)(&idx_info) < 0) + if ((storage->u.chunk.ops->idx_delete)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk index") done: /* Clean up any messages read in */ - if(pline_read) - if(H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) + if (pline_read) + if (H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") - if(layout_read) - if(H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) + if (layout_read) + if (H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout message") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_update_cache * @@ -5887,17 +5840,18 @@ done: herr_t H5D__chunk_update_cache(H5D_t *dset) { - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ - H5D_rdcc_ent_t *ent, *next; /*cache entry */ - H5D_rdcc_ent_t tmp_head; /* Sentinel entry for temporary entry list */ - H5D_rdcc_ent_t *tmp_tail; /* Tail pointer for temporary entry list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ + H5D_rdcc_ent_t *ent, *next; /*cache entry */ + H5D_rdcc_ent_t tmp_head; /* Sentinel entry for temporary entry list */ + H5D_rdcc_ent_t *tmp_tail; /* Tail pointer for temporary entry list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ HDassert(dset && H5D_CHUNKED == dset->shared->layout.type); - HDassert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + HDassert(dset->shared->layout.u.chunk.ndims > 0 && + dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); /* Check the rank */ HDassert((dset->shared->layout.u.chunk.ndims - 1) > 1); @@ -5905,25 +5859,25 @@ H5D__chunk_update_cache(H5D_t *dset) /* Add temporary entry list to rdcc */ (void)HDmemset(&tmp_head, 0, sizeof(tmp_head)); rdcc->tmp_head = &tmp_head; - tmp_tail = &tmp_head; + tmp_tail = &tmp_head; /* Recompute the index for each cached chunk that is in a dataset */ - for(ent = rdcc->head; ent; ent = next) { - unsigned old_idx; /* Previous index number */ + for (ent = rdcc->head; ent; ent = next) { + unsigned old_idx; /* Previous index number */ /* Get the pointer to the next cache entry */ next = ent->next; /* Compute the index for the chunk entry */ - old_idx = ent->idx; /* Save for later */ + old_idx = ent->idx; /* Save for later */ ent->idx = H5D__chunk_hash_val(dset->shared, ent->scaled); - if(old_idx != ent->idx) { - H5D_rdcc_ent_t *old_ent; /* Old cache entry */ + if (old_idx != ent->idx) { + H5D_rdcc_ent_t *old_ent; /* Old cache entry */ /* Check if there is already a chunk at this chunk's new location */ old_ent = rdcc->slot[ent->idx]; - if(old_ent != NULL) { + if (old_ent != NULL) { HDassert(old_ent->locked == FALSE); HDassert(old_ent->deleted == FALSE); @@ -5933,8 +5887,8 @@ H5D__chunk_update_cache(H5D_t *dset) HDassert(!old_ent->tmp_next); HDassert(!old_ent->tmp_prev); tmp_tail->tmp_next = old_ent; - old_ent->tmp_prev = tmp_tail; - tmp_tail = old_ent; + old_ent->tmp_prev = tmp_tail; + tmp_tail = old_ent; } /* end if */ /* Insert this chunk into correct location in hash table */ @@ -5943,13 +5897,13 @@ H5D__chunk_update_cache(H5D_t *dset) /* If this chunk was previously on the temporary list and therefore * not in the hash table, remove it from the temporary list. * Otherwise clear the old hash table slot. */ - if(ent->tmp_prev) { + if (ent->tmp_prev) { HDassert(tmp_head.tmp_next); HDassert(tmp_tail != &tmp_head); ent->tmp_prev->tmp_next = ent->tmp_next; - if(ent->tmp_next) { + if (ent->tmp_next) { ent->tmp_next->tmp_prev = ent->tmp_prev; - ent->tmp_next = NULL; + ent->tmp_next = NULL; } /* end if */ else { HDassert(tmp_tail == ent); @@ -5960,18 +5914,18 @@ H5D__chunk_update_cache(H5D_t *dset) else rdcc->slot[old_idx] = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* tmp_tail is no longer needed, and will be invalidated by * H5D_chunk_cache_evict anyways. */ tmp_tail = NULL; /* Evict chunks that are still on the temporary list */ - while(tmp_head.tmp_next) { + while (tmp_head.tmp_next) { ent = tmp_head.tmp_next; /* Remove the old entry from the cache */ - if(H5D__chunk_cache_evict(dset, ent, TRUE) < 0) + if (H5D__chunk_cache_evict(dset, ent, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") } /* end while */ @@ -5982,7 +5936,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_update_cache() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_copy_cb * @@ -5999,23 +5952,23 @@ done: static int H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5D_chunk_it_ud3_t *udata = (H5D_chunk_it_ud3_t *)_udata; /* User data for callback */ - H5D_chunk_ud_t udata_dst; /* User data about new destination chunk */ - hbool_t is_vlen = FALSE; /* Whether datatype is variable-length */ - hbool_t fix_ref = FALSE; /* Whether to fix up references in the dest. file */ - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + H5D_chunk_it_ud3_t *udata = (H5D_chunk_it_ud3_t *)_udata; /* User data for callback */ + H5D_chunk_ud_t udata_dst; /* User data about new destination chunk */ + hbool_t is_vlen = FALSE; /* Whether datatype is variable-length */ + hbool_t fix_ref = FALSE; /* Whether to fix up references in the dest. file */ + hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ /* General information about chunk copy */ - void *bkg = udata->bkg; /* Background buffer for datatype conversion */ - void *buf = udata->buf; /* Chunk buffer for I/O & datatype conversions */ - size_t buf_size = udata->buf_size; /* Size of chunk buffer */ - const H5O_pline_t *pline = udata->pline; /* I/O pipeline for applying filters */ + void * bkg = udata->bkg; /* Background buffer for datatype conversion */ + void * buf = udata->buf; /* Chunk buffer for I/O & datatype conversions */ + size_t buf_size = udata->buf_size; /* Size of chunk buffer */ + const H5O_pline_t *pline = udata->pline; /* I/O pipeline for applying filters */ /* needed for commpressed variable length data */ - hbool_t must_filter = FALSE; /* Whether chunk must be filtered during copy */ - size_t nbytes; /* Size of chunk in file (in bytes) */ - H5Z_cb_t filter_cb; /* Filter failure callback struct */ - int ret_value = H5_ITER_CONT; /* Return value */ + hbool_t must_filter = FALSE; /* Whether chunk must be filtered during copy */ + size_t nbytes; /* Size of chunk in file (in bytes) */ + H5Z_cb_t filter_cb; /* Filter failure callback struct */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -6024,81 +5977,85 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Check for filtered chunks */ /* Check for an edge chunk that is not filtered */ - if(pline && pline->nused) { + if (pline && pline->nused) { must_filter = TRUE; - if((udata->common.layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && - H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim, chunk_rec->scaled, udata->dset_dims)) + if ((udata->common.layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim, chunk_rec->scaled, + udata->dset_dims)) must_filter = FALSE; } /* Check parameter for type conversion */ - if(udata->do_convert) { - if(H5T_detect_class(udata->dt_src, H5T_VLEN, FALSE) > 0) + if (udata->do_convert) { + if (H5T_detect_class(udata->dt_src, H5T_VLEN, FALSE) > 0) is_vlen = TRUE; - else if((H5T_get_class(udata->dt_src, FALSE) == H5T_REFERENCE) && (udata->file_src != udata->idx_info_dst->f)) + else if ((H5T_get_class(udata->dt_src, FALSE) == H5T_REFERENCE) && + (udata->file_src != udata->idx_info_dst->f)) fix_ref = TRUE; else HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy dataset elements") } /* end if */ /* Resize the buf if it is too small to hold the data */ - if(nbytes > buf_size) { - void *new_buf; /* New buffer for data */ + if (nbytes > buf_size) { + void *new_buf; /* New buffer for data */ /* Re-allocate memory for copying the chunk */ - if(NULL == (new_buf = H5MM_realloc(udata->buf, nbytes))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk") + if (NULL == (new_buf = H5MM_realloc(udata->buf, nbytes))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, + "memory allocation failed for raw data chunk") udata->buf = new_buf; - if(udata->bkg) { - if(NULL == (new_buf = H5MM_realloc(udata->bkg, nbytes))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk") + if (udata->bkg) { + if (NULL == (new_buf = H5MM_realloc(udata->bkg, nbytes))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, + "memory allocation failed for raw data chunk") udata->bkg = new_buf; - if(!udata->cpy_info->expand_ref) + if (!udata->cpy_info->expand_ref) HDmemset((uint8_t *)udata->bkg + buf_size, 0, (size_t)(nbytes - buf_size)); bkg = udata->bkg; } /* end if */ - buf = udata->buf; + buf = udata->buf; udata->buf_size = buf_size = nbytes; } /* end if */ - if(udata->chunk_in_cache && udata->chunk) { + if (udata->chunk_in_cache && udata->chunk) { HDassert(!H5F_addr_defined(chunk_rec->chunk_addr)); H5MM_memcpy(buf, udata->chunk, nbytes); udata->chunk = NULL; } else { - H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ - unsigned idx; /* Index of chunk in cache, if present */ - unsigned u; /* Counter */ - H5D_shared_t *shared_fo = (H5D_shared_t *)udata->cpy_info->shared_fo; + H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ + unsigned idx; /* Index of chunk in cache, if present */ + unsigned u; /* Counter */ + H5D_shared_t * shared_fo = (H5D_shared_t *)udata->cpy_info->shared_fo; /* See if the written chunk is in the chunk cache */ - if(shared_fo && shared_fo->cache.chunk.nslots > 0) { + if (shared_fo && shared_fo->cache.chunk.nslots > 0) { /* Determine the chunk's location in the hash table */ idx = H5D__chunk_hash_val(shared_fo, chunk_rec->scaled); /* Get the chunk cache entry for that location */ ent = shared_fo->cache.chunk.slot[idx]; - if(ent) { + if (ent) { /* Speculatively set the 'found' flag */ udata->chunk_in_cache = TRUE; /* Verify that the cache entry is the correct chunk */ - for(u = 0; u < shared_fo->ndims; u++) - if(chunk_rec->scaled[u] != ent->scaled[u]) { + for (u = 0; u < shared_fo->ndims; u++) + if (chunk_rec->scaled[u] != ent->scaled[u]) { udata->chunk_in_cache = FALSE; break; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ - if(udata->chunk_in_cache) { + if (udata->chunk_in_cache) { HDassert(H5F_addr_defined(chunk_rec->chunk_addr)); HDassert(H5F_addr_defined(ent->chunk_block.offset)); @@ -6107,33 +6064,36 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) } else { /* read chunk data from the source file */ - if(H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, buf) < 0) + if (H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk") } } - /* Need to uncompress filtered variable-length & reference data elements that are not found in chunk cache */ - if(must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) { + /* Need to uncompress filtered variable-length & reference data elements that are not found in chunk cache + */ + if (must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) { unsigned filter_mask = chunk_rec->filter_mask; - if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, &buf) < 0) + if (H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, + &buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "data pipeline read failed") } /* end if */ /* Perform datatype conversion, if necessary */ - if(is_vlen) { - H5T_path_t *tpath_src_mem = udata->tpath_src_mem; - H5T_path_t *tpath_mem_dst = udata->tpath_mem_dst; - H5S_t *buf_space = udata->buf_space; - hid_t tid_src = udata->tid_src; - hid_t tid_dst = udata->tid_dst; - hid_t tid_mem = udata->tid_mem; - void *reclaim_buf = udata->reclaim_buf; - size_t reclaim_buf_size = udata->reclaim_buf_size; + if (is_vlen) { + H5T_path_t *tpath_src_mem = udata->tpath_src_mem; + H5T_path_t *tpath_mem_dst = udata->tpath_mem_dst; + H5S_t * buf_space = udata->buf_space; + hid_t tid_src = udata->tid_src; + hid_t tid_dst = udata->tid_dst; + hid_t tid_mem = udata->tid_mem; + void * reclaim_buf = udata->reclaim_buf; + size_t reclaim_buf_size = udata->reclaim_buf_size; /* Convert from source file to memory */ H5_CHECK_OVERFLOW(udata->nelmts, uint32_t, size_t); - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, (size_t)udata->nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, (size_t)udata->nelmts, (size_t)0, (size_t)0, buf, + bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed") /* Copy into another buffer, to reclaim memory later */ @@ -6143,19 +6103,20 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDmemset(bkg, 0, buf_size); /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, udata->nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, udata->nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed") /* Reclaim space from variable length data */ - if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, H5_ITER_ERROR, "unable to reclaim variable-length data") } /* end if */ - else if(fix_ref) { + else if (fix_ref) { /* Check for expanding references */ /* (background buffer has already been zeroed out, if not expanding) */ - if(udata->cpy_info->expand_ref) { + if (udata->cpy_info->expand_ref) { /* Copy the reference elements */ - if(H5O_copy_expand_ref(udata->file_src, udata->tid_src, udata->dt_src, buf, nbytes, udata->idx_info_dst->f, bkg, udata->cpy_info) < 0) + if (H5O_copy_expand_ref(udata->file_src, udata->tid_src, udata->dt_src, buf, nbytes, + udata->idx_info_dst->f, bkg, udata->cpy_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy reference attribute") } /* end if */ @@ -6164,48 +6125,53 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) } /* end if */ /* Set up destination chunk callback information for insertion */ - udata_dst.common.layout = udata->idx_info_dst->layout; - udata_dst.common.storage = udata->idx_info_dst->storage; - udata_dst.common.scaled = chunk_rec->scaled; + udata_dst.common.layout = udata->idx_info_dst->layout; + udata_dst.common.storage = udata->idx_info_dst->storage; + udata_dst.common.scaled = chunk_rec->scaled; udata_dst.chunk_block.offset = HADDR_UNDEF; udata_dst.chunk_block.length = chunk_rec->nbytes; - udata_dst.filter_mask = chunk_rec->filter_mask; + udata_dst.filter_mask = chunk_rec->filter_mask; - /* Need to compress variable-length or reference data elements or a chunk found in cache before writing to file */ - if(must_filter && (is_vlen || fix_ref || udata->chunk_in_cache) ) { - if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, &buf) < 0) + /* Need to compress variable-length or reference data elements or a chunk found in cache before writing to + * file */ + if (must_filter && (is_vlen || fix_ref || udata->chunk_in_cache)) { + if (H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, + &buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if(nbytes > ((size_t)0xffffffff)) + if (nbytes > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, H5_ITER_ERROR, "chunk too large for 32-bit length") #endif /* H5_SIZEOF_SIZE_T > 4 */ H5_CHECKED_ASSIGN(udata_dst.chunk_block.length, uint32_t, nbytes, size_t); - udata->buf = buf; + udata->buf = buf; udata->buf_size = buf_size; } /* end if */ udata->chunk_in_cache = FALSE; - udata_dst.chunk_idx = H5VM_array_offset_pre(udata_dst.common.layout->ndims - 1, - udata_dst.common.layout->max_down_chunks, udata_dst.common.scaled); + udata_dst.chunk_idx = + H5VM_array_offset_pre(udata_dst.common.layout->ndims - 1, udata_dst.common.layout->max_down_chunks, + udata_dst.common.scaled); /* Allocate chunk in the file */ - if(H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert, udata_dst.common.scaled) < 0) + if (H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert, + udata_dst.common.scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Write chunk data to destination file */ HDassert(H5F_addr_defined(udata_dst.chunk_block.offset)); - if(H5F_block_write(udata->idx_info_dst->f, H5FD_MEM_DRAW, udata_dst.chunk_block.offset, nbytes, buf) < 0) + if (H5F_block_write(udata->idx_info_dst->f, H5FD_MEM_DRAW, udata_dst.chunk_block.offset, nbytes, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write raw data to file") /* Set metadata tag in API context */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Insert chunk record into index */ - if(need_insert && udata->idx_info_dst->storage->ops->insert) - if((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst, NULL) < 0) - HGOTO_ERROR_TAG(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk addr into index") + if (need_insert && udata->idx_info_dst->storage->ops->insert) + if ((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst, NULL) < 0) + HGOTO_ERROR_TAG(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, + "unable to insert chunk addr into index") /* Reset metadata tag in API context */ H5_END_TAG @@ -6214,7 +6180,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_copy_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_copy * @@ -6229,34 +6194,33 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, - H5O_layout_chunk_t *layout_src, H5F_t *f_dst, H5O_storage_chunk_t *storage_dst, - const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, - const H5O_pline_t *pline_src, H5O_copy_t *cpy_info) +H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk_t *layout_src, H5F_t *f_dst, + H5O_storage_chunk_t *storage_dst, const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, + const H5O_pline_t *pline_src, H5O_copy_t *cpy_info) { - H5D_chunk_it_ud3_t udata; /* User data for iteration callback */ - H5D_chk_idx_info_t idx_info_dst; /* Dest. chunked index info */ - H5D_chk_idx_info_t idx_info_src; /* Source chunked index info */ - int sndims; /* Rank of dataspace */ - hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ - hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ - H5O_pline_t _pline; /* Temporary pipeline info */ - const H5O_pline_t *pline; /* Pointer to pipeline info to use */ - H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ - hid_t tid_src = -1; /* Datatype ID for source datatype */ - hid_t tid_dst = -1; /* Datatype ID for destination datatype */ - hid_t tid_mem = -1; /* Datatype ID for memory datatype */ - size_t buf_size; /* Size of copy buffer */ - size_t reclaim_buf_size; /* Size of reclaim buffer */ - void *buf = NULL; /* Buffer for copying data */ - void *bkg = NULL; /* Buffer for background during type conversion */ - void *reclaim_buf = NULL; /* Buffer for reclaiming data */ - H5S_t *buf_space = NULL; /* Dataspace describing buffer */ - hid_t sid_buf = -1; /* ID for buffer dataspace */ - uint32_t nelmts = 0; /* Number of elements in buffer */ - hbool_t do_convert = FALSE; /* Indicate that type conversions should be performed */ - hbool_t copy_setup_done = FALSE; /* Indicate that 'copy setup' is done */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_it_ud3_t udata; /* User data for iteration callback */ + H5D_chk_idx_info_t idx_info_dst; /* Dest. chunked index info */ + H5D_chk_idx_info_t idx_info_src; /* Source chunked index info */ + int sndims; /* Rank of dataspace */ + hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ + hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ + H5O_pline_t _pline; /* Temporary pipeline info */ + const H5O_pline_t *pline; /* Pointer to pipeline info to use */ + H5T_path_t * tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ + hid_t tid_src = -1; /* Datatype ID for source datatype */ + hid_t tid_dst = -1; /* Datatype ID for destination datatype */ + hid_t tid_mem = -1; /* Datatype ID for memory datatype */ + size_t buf_size; /* Size of copy buffer */ + size_t reclaim_buf_size; /* Size of reclaim buffer */ + void * buf = NULL; /* Buffer for copying data */ + void * bkg = NULL; /* Buffer for background during type conversion */ + void * reclaim_buf = NULL; /* Buffer for reclaiming data */ + H5S_t * buf_space = NULL; /* Dataspace describing buffer */ + hid_t sid_buf = -1; /* ID for buffer dataspace */ + uint32_t nelmts = 0; /* Number of elements in buffer */ + hbool_t do_convert = FALSE; /* Indicate that type conversions should be performed */ + hbool_t copy_setup_done = FALSE; /* Indicate that 'copy setup' is done */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -6272,7 +6236,7 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, HDassert(dt_src); /* Initialize the temporary pipeline info */ - if(NULL == pline_src) { + if (NULL == pline_src) { HDmemset(&_pline, 0, sizeof(_pline)); pline = &_pline; } /* end if */ @@ -6280,118 +6244,119 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, pline = pline_src; /* Layout is not created in the destination file, reset index address */ - if(H5D_chunk_idx_reset(storage_dst, TRUE) < 0) + if (H5D_chunk_idx_reset(storage_dst, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") /* Initialize layout information */ { - unsigned ndims; /* Rank of dataspace */ + unsigned ndims; /* Rank of dataspace */ /* Get the dim info for dataset */ - if((sndims = H5S_extent_get_dims(ds_extent_src, curr_dims, max_dims)) < 0) + if ((sndims = H5S_extent_get_dims(ds_extent_src, curr_dims, max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace dimensions") H5_CHECKED_ASSIGN(ndims, unsigned, sndims, int); /* Set the source layout chunk information */ - if(H5D__chunk_set_info_real(layout_src, ndims, curr_dims, max_dims) < 0) + if (H5D__chunk_set_info_real(layout_src, ndims, curr_dims, max_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") } /* end block */ /* Compose source & dest chunked index info structs */ - idx_info_src.f = f_src; - idx_info_src.pline = pline; - idx_info_src.layout = layout_src; + idx_info_src.f = f_src; + idx_info_src.pline = pline; + idx_info_src.layout = layout_src; idx_info_src.storage = storage_src; - idx_info_dst.f = f_dst; - idx_info_dst.pline = pline; /* Use same I/O filter pipeline for dest. */ - idx_info_dst.layout = layout_src /* Use same layout for dest. */; + idx_info_dst.f = f_dst; + idx_info_dst.pline = pline; /* Use same I/O filter pipeline for dest. */ + idx_info_dst.layout = layout_src /* Use same layout for dest. */; idx_info_dst.storage = storage_dst; /* Call the index-specific "copy setup" routine */ - if((storage_src->ops->copy_setup)(&idx_info_src, &idx_info_dst) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up index-specific chunk copying information") + if ((storage_src->ops->copy_setup)(&idx_info_src, &idx_info_dst) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to set up index-specific chunk copying information") copy_setup_done = TRUE; /* Create datatype ID for src datatype */ - if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) + if ((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") /* If there's a VLEN source datatype, set up type conversion information */ - if(H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { - H5T_t *dt_dst; /* Destination datatype */ - H5T_t *dt_mem; /* Memory datatype */ - size_t mem_dt_size; /* Memory datatype size */ - size_t tmp_dt_size; /* Temp. datatype size */ - size_t max_dt_size; /* Max atatype size */ - hsize_t buf_dim; /* Dimension for buffer */ + if (H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { + H5T_t * dt_dst; /* Destination datatype */ + H5T_t * dt_mem; /* Memory datatype */ + size_t mem_dt_size; /* Memory datatype size */ + size_t tmp_dt_size; /* Temp. datatype size */ + size_t max_dt_size; /* Max atatype size */ + hsize_t buf_dim; /* Dimension for buffer */ unsigned u; /* create a memory copy of the variable-length datatype */ - if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { (void)H5T_close_real(dt_mem); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ /* create variable-length datatype at the destinaton file */ - if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") - if(H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { + if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ - if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { + if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype") } /* end if */ /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) + if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes") /* Determine largest datatype size */ - if(0 == (max_dt_size = H5T_get_size(dt_src))) + if (0 == (max_dt_size = H5T_get_size(dt_src))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") - if(0 == (mem_dt_size = H5T_get_size(dt_mem))) + if (0 == (mem_dt_size = H5T_get_size(dt_mem))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, mem_dt_size); - if(0 == (tmp_dt_size = H5T_get_size(dt_dst))) + if (0 == (tmp_dt_size = H5T_get_size(dt_dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, tmp_dt_size); /* Compute the number of elements per chunk */ nelmts = 1; - for(u = 0; u < (layout_src->ndims - 1); u++) + for (u = 0; u < (layout_src->ndims - 1); u++) nelmts *= layout_src->dim[u]; /* Create the space and set the initial extent */ buf_dim = nelmts; - if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) + if (NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Atomize */ - if((sid_buf = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { + if ((sid_buf = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { (void)H5S_close(buf_space); HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") } /* end if */ /* Set initial buffer sizes */ - buf_size = nelmts * max_dt_size; + buf_size = nelmts * max_dt_size; reclaim_buf_size = nelmts * mem_dt_size; /* Allocate memory for reclaim buf */ - if(NULL == (reclaim_buf = H5MM_malloc(reclaim_buf_size))) + if (NULL == (reclaim_buf = H5MM_malloc(reclaim_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk") /* Indicate that type conversion should be performed */ do_convert = TRUE; } /* end if */ else { - if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { + if (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { /* Indicate that type conversion should be performed */ do_convert = TRUE; } /* end if */ @@ -6401,69 +6366,68 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, } /* end else */ /* Set up conversion buffer, if appropriate */ - if(do_convert) { + if (do_convert) { /* Allocate background memory for converting the chunk */ - if(NULL == (bkg = H5MM_malloc(buf_size))) + if (NULL == (bkg = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk") /* Check for reference datatype and no expanding references & clear background buffer */ - if(!cpy_info->expand_ref && - ((H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) && (f_src != f_dst))) + if (!cpy_info->expand_ref && ((H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) && (f_src != f_dst))) /* Reset value to zero */ HDmemset(bkg, 0, buf_size); } /* end if */ /* Allocate memory for copying the chunk */ - if(NULL == (buf = H5MM_malloc(buf_size))) + if (NULL == (buf = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk") /* Initialize the callback structure for the source */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = layout_src; - udata.common.storage = storage_src; - udata.file_src = f_src; - udata.idx_info_dst = &idx_info_dst; - udata.buf = buf; - udata.bkg = bkg; - udata.buf_size = buf_size; - udata.tid_src = tid_src; - udata.tid_mem = tid_mem; - udata.tid_dst = tid_dst; - udata.dt_src = dt_src; - udata.do_convert = do_convert; - udata.tpath_src_mem = tpath_src_mem; - udata.tpath_mem_dst = tpath_mem_dst; - udata.reclaim_buf = reclaim_buf; + udata.common.layout = layout_src; + udata.common.storage = storage_src; + udata.file_src = f_src; + udata.idx_info_dst = &idx_info_dst; + udata.buf = buf; + udata.bkg = bkg; + udata.buf_size = buf_size; + udata.tid_src = tid_src; + udata.tid_mem = tid_mem; + udata.tid_dst = tid_dst; + udata.dt_src = dt_src; + udata.do_convert = do_convert; + udata.tpath_src_mem = tpath_src_mem; + udata.tpath_mem_dst = tpath_mem_dst; + udata.reclaim_buf = reclaim_buf; udata.reclaim_buf_size = reclaim_buf_size; - udata.buf_space = buf_space; - udata.nelmts = nelmts; - udata.pline = pline; - udata.dset_ndims = (unsigned)sndims; - udata.dset_dims = curr_dims; - udata.cpy_info = cpy_info; - udata.chunk_in_cache = FALSE; - udata.chunk = NULL; + udata.buf_space = buf_space; + udata.nelmts = nelmts; + udata.pline = pline; + udata.dset_ndims = (unsigned)sndims; + udata.dset_dims = curr_dims; + udata.cpy_info = cpy_info; + udata.chunk_in_cache = FALSE; + udata.chunk = NULL; /* Iterate over chunks to copy data */ - if((storage_src->ops->iterate)(&idx_info_src, H5D__chunk_copy_cb, &udata) < 0) + if ((storage_src->ops->iterate)(&idx_info_src, H5D__chunk_copy_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to copy data") /* Iterate over the chunk cache to copy data for chunks with undefined address */ - if(udata.cpy_info->shared_fo) { - H5D_rdcc_ent_t *ent, *next; + if (udata.cpy_info->shared_fo) { + H5D_rdcc_ent_t *ent, *next; H5D_chunk_rec_t chunk_rec; - H5D_shared_t *shared_fo = (H5D_shared_t *)udata.cpy_info->shared_fo; + H5D_shared_t * shared_fo = (H5D_shared_t *)udata.cpy_info->shared_fo; - chunk_rec.nbytes = layout_src->size; + chunk_rec.nbytes = layout_src->size; chunk_rec.filter_mask = 0; - chunk_rec.chunk_addr = HADDR_UNDEF; + chunk_rec.chunk_addr = HADDR_UNDEF; - for(ent = shared_fo->cache.chunk.head; ent; ent = next) { - if(!H5F_addr_defined(ent->chunk_block.offset)) { + for (ent = shared_fo->cache.chunk.head; ent; ent = next) { + if (!H5F_addr_defined(ent->chunk_block.offset)) { H5MM_memcpy(chunk_rec.scaled, ent->scaled, sizeof(chunk_rec.scaled)); - udata.chunk = ent->chunk; + udata.chunk = ent->chunk; udata.chunk_in_cache = TRUE; - if(H5D__chunk_copy_cb(&chunk_rec, &udata) < 0) + if (H5D__chunk_copy_cb(&chunk_rec, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy chunk data in cache") } next = ent->next; @@ -6475,30 +6439,30 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, bkg = udata.bkg; done: - if(sid_buf > 0 && H5I_dec_ref(sid_buf) < 0) + if (sid_buf > 0 && H5I_dec_ref(sid_buf) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(buf) + if (buf) H5MM_xfree(buf); - if(bkg) + if (bkg) H5MM_xfree(bkg); - if(reclaim_buf) + if (reclaim_buf) H5MM_xfree(reclaim_buf); /* Clean up any index information */ - if(copy_setup_done) - if(storage_src->ops->copy_shutdown && (storage_src->ops->copy_shutdown)(storage_src, storage_dst) < 0) + if (copy_setup_done) + if (storage_src->ops->copy_shutdown && + (storage_src->ops->copy_shutdown)(storage_src, storage_dst) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to shut down index copying info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_copy() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_bh_info * @@ -6513,17 +6477,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, - hsize_t *index_size) +H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, hsize_t *index_size) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5S_t *space = NULL; /* Dataset's dataspace */ - H5O_pline_t pline; /* I/O pipeline message */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5S_t * space = NULL; /* Dataset's dataspace */ + H5O_pline_t pline; /* I/O pipeline message */ H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); - htri_t exists; /* Flag if header message of interest exists */ - hbool_t idx_info_init = FALSE; /* Whether the chunk index info has been initialized */ - hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t exists; /* Flag if header message of interest exists */ + hbool_t idx_info_init = FALSE; /* Whether the chunk index info has been initialized */ + hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -6536,10 +6499,10 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, HDassert(index_size); /* Check for I/O pipeline message */ - if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") - else if(exists) { - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_PLINE_ID, &pline)) + else if (exists) { + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_PLINE_ID, &pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't find I/O pipeline message") pline_read = TRUE; } /* end else if */ @@ -6547,37 +6510,36 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, HDmemset(&pline, 0, sizeof(pline)); /* Compose chunked index info struct */ - idx_info.f = loc->file; - idx_info.pline = &pline; - idx_info.layout = &layout->u.chunk; + idx_info.f = loc->file; + idx_info.pline = &pline; + idx_info.layout = &layout->u.chunk; idx_info.storage = sc; /* Get the dataspace for the dataset */ - if(NULL == (space = H5S_read(loc))) + if (NULL == (space = H5S_read(loc))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") /* Allocate any indexing structures */ - if(sc->ops->init && (sc->ops->init)(&idx_info, space, loc->addr) < 0) + if (sc->ops->init && (sc->ops->init)(&idx_info, space, loc->addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") idx_info_init = TRUE; /* Get size of index structure */ - if(sc->ops->size && (sc->ops->size)(&idx_info, index_size) < 0) + if (sc->ops->size && (sc->ops->size)(&idx_info, index_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve chunk index info") done: /* Free resources, if they've been initialized */ - if(idx_info_init && sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) + if (idx_info_init && sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") - if(pline_read && H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) + if (pline_read && H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") - if(space && H5S_close(space) < 0) + if (space && H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_bh_info() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_dump_index_cb * @@ -6596,25 +6558,27 @@ done: static int H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5D_chunk_it_ud4_t *udata = (H5D_chunk_it_ud4_t *)_udata; /* User data from caller */ + H5D_chunk_it_ud4_t *udata = (H5D_chunk_it_ud4_t *)_udata; /* User data from caller */ FUNC_ENTER_STATIC_NOERR - if(udata->stream) { - unsigned u; /* Local index variable */ + if (udata->stream) { + unsigned u; /* Local index variable */ /* Print header if not already displayed */ - if(!udata->header_displayed) { + if (!udata->header_displayed) { HDfprintf(udata->stream, " Flags Bytes Address Logical Offset\n"); - HDfprintf(udata->stream, " ========== ======== ========== ==============================\n"); + HDfprintf(udata->stream, + " ========== ======== ========== ==============================\n"); /* Set flag that the headers has been printed */ udata->header_displayed = TRUE; } /* end if */ /* Print information about this chunk */ - HDfprintf(udata->stream, " 0x%08x %8Zu %10a [", chunk_rec->filter_mask, chunk_rec->nbytes, chunk_rec->chunk_addr); - for(u = 0; u < udata->ndims; u++) + HDfprintf(udata->stream, " 0x%08x %8Zu %10a [", chunk_rec->filter_mask, chunk_rec->nbytes, + chunk_rec->chunk_addr); + for (u = 0; u < udata->ndims; u++) HDfprintf(udata->stream, "%s%Hu", (u ? ", " : ""), (chunk_rec->scaled[u] * udata->chunk_dim[u])); HDfputs("]\n", udata->stream); } /* end if */ @@ -6622,7 +6586,6 @@ H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* H5D__chunk_dump_index_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_dump_index * @@ -6640,8 +6603,8 @@ H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) herr_t H5D__chunk_dump_index(H5D_t *dset, FILE *stream) { - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -6650,29 +6613,30 @@ H5D__chunk_dump_index(H5D_t *dset, FILE *stream) H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Only display info if stream is defined */ - if(stream) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_chunk_it_ud4_t udata; /* User data for callback */ + if (stream) { + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_chunk_it_ud4_t udata; /* User data for callback */ /* Display info for index */ - if((sc->ops->dump)(sc, stream) < 0) + if ((sc->ops->dump)(sc, stream) < 0) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to dump chunk index info") /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Set up user data for callback */ - udata.stream = stream; + udata.stream = stream; udata.header_displayed = FALSE; - udata.ndims = dset->shared->layout.u.chunk.ndims; - udata.chunk_dim = dset->shared->layout.u.chunk.dim; + udata.ndims = dset->shared->layout.u.chunk.ndims; + udata.chunk_dim = dset->shared->layout.u.chunk.dim; /* Iterate over index and dump chunk info */ - if((sc->ops->iterate)(&idx_info, H5D__chunk_dump_index_cb, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to dump chunk info") + if ((sc->ops->iterate)(&idx_info, H5D__chunk_dump_index_cb, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, + "unable to iterate over chunk index to dump chunk info") } /* end if */ done: @@ -6698,10 +6662,10 @@ done: herr_t H5D__chunk_stats(const H5D_t *dset, hbool_t headers) { - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); - double miss_rate; - char ascii[32]; - herr_t ret_value=SUCCEED; /* Return value */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); + double miss_rate; + char ascii[32]; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -6710,10 +6674,10 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) if (headers) { HDfprintf(H5DEBUG(AC), "H5D: raw data cache statistics\n"); - HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", - "Layer", "Hits", "Misses", "MissRate", "Inits", "Flushes"); - HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", - "-----", "----", "------", "--------", "-----", "-------"); + HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", "Layer", "Hits", "Misses", "MissRate", + "Inits", "Flushes"); + HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", "-----", "----", "------", "--------", + "-----", "-------"); } #ifdef H5AC_DEBUG @@ -6722,21 +6686,22 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) #endif if (headers) { - if (rdcc->stats.nhits>0 || rdcc->stats.nmisses>0) { - miss_rate = 100.0 * rdcc->stats.nmisses / - (rdcc->stats.nhits + rdcc->stats.nmisses); - } else { + if (rdcc->stats.nhits > 0 || rdcc->stats.nmisses > 0) { + miss_rate = 100.0 * rdcc->stats.nmisses / (rdcc->stats.nhits + rdcc->stats.nmisses); + } + else { miss_rate = 0.0; } if (miss_rate > 100) { - HDsprintf(ascii, "%7d%%", (int) (miss_rate + 0.5)); - } else { + HDsprintf(ascii, "%7d%%", (int)(miss_rate + 0.5)); + } + else { HDsprintf(ascii, "%7.2f%%", miss_rate); } - HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", - "raw data chunks", rdcc->stats.nhits, rdcc->stats.nmisses, ascii, - rdcc->stats.ninits, (long)(rdcc->stats.nflushes)-(long)(rdcc->stats.ninits)); + HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", "raw data chunks", rdcc->stats.nhits, + rdcc->stats.nmisses, ascii, rdcc->stats.ninits, + (long)(rdcc->stats.nflushes) - (long)(rdcc->stats.ninits)); } done: @@ -6744,7 +6709,6 @@ done: } /* end H5D__chunk_stats() */ #endif /* H5D_CHUNK_DEBUG */ - /*------------------------------------------------------------------------- * Function: H5D__nonexistent_readvv_cb * @@ -6764,36 +6728,34 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__nonexistent_readvv_cb(hsize_t H5_ATTR_UNUSED dst_off, hsize_t src_off, size_t len, - void *_udata) +H5D__nonexistent_readvv_cb(hsize_t H5_ATTR_UNUSED dst_off, hsize_t src_off, size_t len, void *_udata) { H5D_chunk_readvv_ud_t *udata = (H5D_chunk_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ - hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ + hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Initialize the fill value buffer */ - if(H5D__fill_init(&fb_info, (udata->rbuf + src_off), NULL, NULL, NULL, NULL, - &udata->dset->shared->dcpl_cache.fill, udata->dset->shared->type, - udata->dset->shared->type_id, (size_t)0, len) < 0) + if (H5D__fill_init(&fb_info, (udata->rbuf + src_off), NULL, NULL, NULL, NULL, + &udata->dset->shared->dcpl_cache.fill, udata->dset->shared->type, + udata->dset->shared->type_id, (size_t)0, len) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; /* Check for VL datatype & fill the buffer with VL datatype fill values */ - if(fb_info.has_vlen_fill_type && H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) + if (fb_info.has_vlen_fill_type && H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) } /* H5D__nonexistent_readvv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__nonexistent_readvv * @@ -6815,12 +6777,12 @@ done: *------------------------------------------------------------------------- */ static ssize_t -H5D__nonexistent_readvv(const H5D_io_info_t *io_info, - size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +H5D__nonexistent_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, size_t *chunk_curr_seq, + size_t chunk_len_arr[], hsize_t chunk_off_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_chunk_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value = -1; /* Return value */ + H5D_chunk_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -6838,16 +6800,15 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info, udata.dset = io_info->dset; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__nonexistent_readvv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__nonexistent_readvv_cb, &udata)) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized fill value init") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__nonexistent_readvv() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_is_partial_edge_chunk * @@ -6863,11 +6824,11 @@ done: *------------------------------------------------------------------------- */ static hbool_t -H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims, - const hsize_t scaled[], const hsize_t *dset_dims) +H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims, const hsize_t scaled[], + const hsize_t *dset_dims) { - unsigned u; /* Local index variable */ - hbool_t ret_value = FALSE; /* Return value */ + unsigned u; /* Local index variable */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -6878,15 +6839,14 @@ H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims HDassert(chunk_dims); /* check if this is a partial edge chunk */ - for(u = 0; u < dset_ndims; u++) - if(((scaled[u] + 1) * chunk_dims[u]) > dset_dims[u]) + for (u = 0; u < dset_ndims; u++) + if (((scaled[u] + 1) * chunk_dims[u]) > dset_dims[u]) HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_is_partial_edge_chunk() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_file_alloc() * @@ -6903,10 +6863,10 @@ done: */ herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk, - H5F_block_t *new_chunk, hbool_t *need_insert, const hsize_t *scaled) + H5F_block_t *new_chunk, hbool_t *need_insert, const hsize_t *scaled) { - hbool_t alloc_chunk = FALSE; /* Whether to allocate chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t alloc_chunk = FALSE; /* Whether to allocate chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6922,72 +6882,72 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old *need_insert = FALSE; /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { + if (idx_info->pline->nused > 0) { /* Sanity/error checking block */ - HDassert(idx_info->storage->idx_type != H5D_CHUNK_IDX_NONE); + HDassert(idx_info->storage->idx_type != H5D_CHUNK_IDX_NONE); { - unsigned allow_chunk_size_len; /* Allowed size of encoded chunk size */ - unsigned new_chunk_size_len; /* Size of encoded chunk size */ + unsigned allow_chunk_size_len; /* Allowed size of encoded chunk size */ + unsigned new_chunk_size_len; /* Size of encoded chunk size */ /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. */ allow_chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)(idx_info->layout->size)) + 8) / 8); - if(allow_chunk_size_len > 8) + if (allow_chunk_size_len > 8) allow_chunk_size_len = 8; /* Compute encoded size of chunk */ new_chunk_size_len = (H5VM_log2_gen((uint64_t)(new_chunk->length)) + 8) / 8; - if(new_chunk_size_len > 8) + if (new_chunk_size_len > 8) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "encoded chunk size is more than 8 bytes?!?") /* Check if the chunk became too large to be encoded */ - if(new_chunk_size_len > allow_chunk_size_len) + if (new_chunk_size_len > allow_chunk_size_len) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk size can't be encoded") } /* end block */ - if(old_chunk && H5F_addr_defined(old_chunk->offset)) { + if (old_chunk && H5F_addr_defined(old_chunk->offset)) { /* Sanity check */ - HDassert(!H5F_addr_defined(new_chunk->offset) || H5F_addr_eq(new_chunk->offset, old_chunk->offset)); + HDassert(!H5F_addr_defined(new_chunk->offset) || + H5F_addr_eq(new_chunk->offset, old_chunk->offset)); /* Check for chunk being same size */ - if(new_chunk->length != old_chunk->length) { + if (new_chunk->length != old_chunk->length) { /* Release previous chunk */ /* Only free the old location if not doing SWMR writes - otherwise * we must keep the old chunk around in case a reader has an * outdated version of the B-tree node */ - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, old_chunk->offset, old_chunk->length) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, old_chunk->offset, old_chunk->length) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") alloc_chunk = TRUE; } /* end if */ else { /* Don't need to reallocate chunk, but send its address back up */ - if(!H5F_addr_defined(new_chunk->offset)) + if (!H5F_addr_defined(new_chunk->offset)) new_chunk->offset = old_chunk->offset; } /* end else */ - } /* end if */ + } /* end if */ else { HDassert(!H5F_addr_defined(new_chunk->offset)); alloc_chunk = TRUE; } /* end else */ - } /* end if */ + } /* end if */ else { - HDassert(!H5F_addr_defined(new_chunk->offset)); - HDassert(new_chunk->length == idx_info->layout->size); - alloc_chunk = TRUE; - } /* end else */ + HDassert(!H5F_addr_defined(new_chunk->offset)); + HDassert(new_chunk->length == idx_info->layout->size); + alloc_chunk = TRUE; + } /* end else */ /* Actually allocate space for the chunk in the file */ - if(alloc_chunk) { - switch(idx_info->storage->idx_type) { - case H5D_CHUNK_IDX_NONE: - { + if (alloc_chunk) { + switch (idx_info->storage->idx_type) { + case H5D_CHUNK_IDX_NONE: { H5D_chunk_ud_t udata; udata.common.scaled = scaled; - if((idx_info->storage->ops->get_addr)(idx_info, &udata) < 0) + if ((idx_info->storage->ops->get_addr)(idx_info, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query chunk address") new_chunk->offset = udata.chunk_block.offset; HDassert(new_chunk->length == udata.chunk_block.length); @@ -7000,9 +6960,9 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old case H5D_CHUNK_IDX_BTREE: case H5D_CHUNK_IDX_SINGLE: HDassert(new_chunk->length > 0); - H5_CHECK_OVERFLOW(new_chunk->length, /*From: */uint32_t, /*To: */hsize_t); + H5_CHECK_OVERFLOW(new_chunk->length, /*From: */ uint32_t, /*To: */ hsize_t); new_chunk->offset = H5MF_alloc(idx_info->f, H5FD_MEM_DRAW, (hsize_t)new_chunk->length); - if(!H5F_addr_defined(new_chunk->offset)) + if (!H5F_addr_defined(new_chunk->offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "file allocation failed") *need_insert = TRUE; break; @@ -7012,7 +6972,7 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old HDassert(0 && "This should never be executed!"); break; } /* end switch */ - } /* end if */ + } /* end if */ HDassert(H5F_addr_defined(new_chunk->offset)); @@ -7020,7 +6980,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_file_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_format_convert_cb * @@ -7038,13 +6997,13 @@ done: static int H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5D_chunk_it_ud5_t *udata = (H5D_chunk_it_ud5_t *)_udata; /* User data */ - H5D_chk_idx_info_t *new_idx_info; /* The new chunk index information */ - H5D_chunk_ud_t insert_udata; /* Chunk information to be inserted */ - haddr_t chunk_addr; /* Chunk address */ - size_t nbytes; /* Chunk size */ - void *buf = NULL; /* Pointer to buffer of chunk data */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_chunk_it_ud5_t *udata = (H5D_chunk_it_ud5_t *)_udata; /* User data */ + H5D_chk_idx_info_t *new_idx_info; /* The new chunk index information */ + H5D_chunk_ud_t insert_udata; /* Chunk information to be inserted */ + haddr_t chunk_addr; /* Chunk address */ + size_t nbytes; /* Chunk size */ + void * buf = NULL; /* Pointer to buffer of chunk data */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -7054,32 +7013,35 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) chunk_addr = chunk_rec->chunk_addr; if (new_idx_info->pline->nused && - (new_idx_info->layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && - (H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, new_idx_info->layout->dim, chunk_rec->scaled, udata->dset_dims))) { + (new_idx_info->layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + (H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, new_idx_info->layout->dim, chunk_rec->scaled, + udata->dset_dims))) { /* This is a partial non-filtered edge chunk */ /* Convert the chunk to a filtered edge chunk for v1 B-tree chunk index */ unsigned filter_mask = chunk_rec->filter_mask; - H5Z_cb_t filter_cb; /* Filter failure callback struct */ - size_t read_size = nbytes; /* Bytes to read */ + H5Z_cb_t filter_cb; /* Filter failure callback struct */ + size_t read_size = nbytes; /* Bytes to read */ HDassert(read_size == new_idx_info->layout->size); /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer for chunk data */ if (NULL == (buf = H5MM_malloc(read_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, + "memory allocation failed for raw data chunk") /* Read the non-filtered edge chunk */ if (H5F_block_read(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, read_size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk") /* Pass the chunk through the pipeline */ - if (H5Z_pipeline(new_idx_info->pline, 0, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, &buf) < 0) + if (H5Z_pipeline(new_idx_info->pline, 0, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, + &buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 @@ -7101,10 +7063,10 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Set up chunk information for insertion to chunk index */ insert_udata.chunk_block.offset = chunk_addr; insert_udata.chunk_block.length = nbytes; - insert_udata.filter_mask = chunk_rec->filter_mask; - insert_udata.common.scaled = chunk_rec->scaled; - insert_udata.common.layout = new_idx_info->layout; - insert_udata.common.storage = new_idx_info->storage; + insert_udata.filter_mask = chunk_rec->filter_mask; + insert_udata.common.scaled = chunk_rec->scaled; + insert_udata.common.layout = new_idx_info->layout; + insert_udata.common.storage = new_idx_info->storage; /* Insert chunk into the v1 B-tree chunk index */ if ((new_idx_info->storage->ops->insert)(new_idx_info, &insert_udata, NULL) < 0) @@ -7117,7 +7079,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_format_convert_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_format_convert * @@ -7134,8 +7095,8 @@ done: herr_t H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx_info_t *new_idx_info) { - H5D_chunk_it_ud5_t udata; /* User data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_it_ud5_t udata; /* User data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -7144,18 +7105,18 @@ H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx /* Set up user data */ udata.new_idx_info = new_idx_info; - udata.dset_ndims = dset->shared->ndims; - udata.dset_dims = dset->shared->curr_dims; + udata.dset_ndims = dset->shared->ndims; + udata.dset_dims = dset->shared->curr_dims; - /* Iterate over the chunks in the current index and insert the chunk addresses into version 1 B-tree index */ - if((idx_info->storage->ops->iterate)(idx_info, H5D__chunk_format_convert_cb, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to chunk info") + /* Iterate over the chunks in the current index and insert the chunk addresses into version 1 B-tree index + */ + if ((idx_info->storage->ops->iterate)(idx_info, H5D__chunk_format_convert_cb, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to chunk info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_format_convert() */ - /*------------------------------------------------------------------------- * Function: H5D__get_num_chunks_cb * @@ -7176,7 +7137,7 @@ static int H5D__get_num_chunks_cb(const H5D_chunk_rec_t H5_ATTR_UNUSED *chunk_rec, void *_udata) { hsize_t *num_chunks = (hsize_t *)_udata; - int ret_value = H5_ITER_CONT; /* Callback return value */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -7187,7 +7148,6 @@ H5D__get_num_chunks_cb(const H5D_chunk_rec_t H5_ATTR_UNUSED *chunk_rec, void *_u FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_num_chunks_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__get_num_chunks * @@ -7207,11 +7167,11 @@ H5D__get_num_chunks_cb(const H5D_chunk_rec_t H5_ATTR_UNUSED *chunk_rec, void *_u herr_t H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_t *nchunks) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - hsize_t num_chunks = 0; /* Number of written chunks */ - H5D_rdcc_ent_t *ent; /* Cache entry */ - const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + hsize_t num_chunks = 0; /* Number of written chunks */ + H5D_rdcc_ent_t * ent; /* Cache entry */ + const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7224,24 +7184,26 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ HDassert(rdcc); /* Search for cached chunks that haven't been written out */ - for(ent = rdcc->head; ent; ent = ent->next) + for (ent = rdcc->head; ent; ent = ent->next) /* Flush the chunk out to disk, to make certain the size is correct later */ - if(H5D__chunk_flush_entry(dset, ent, FALSE) < 0) + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = &dset->shared->layout.storage.u.chunk; /* If the dataset is not written, number of chunks will be 0 */ - if(!H5F_addr_defined(idx_info.storage->idx_addr)) + if (!H5F_addr_defined(idx_info.storage->idx_addr)) *nchunks = 0; else { /* Iterate over the allocated chunks */ - if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_num_chunks_cb, &num_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") + if ((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_num_chunks_cb, + &num_chunks) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve allocated chunk information from index") *nchunks = num_chunks; } @@ -7249,7 +7211,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_num_chunks() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info_cb * @@ -7268,7 +7229,7 @@ static int H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { H5D_chunk_info_iter_ud_t *chunk_info = (H5D_chunk_info_iter_ud_t *)_udata; - int ret_value = H5_ITER_CONT; /* Callback return value */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -7277,14 +7238,14 @@ H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(chunk_info); /* If this is the queried chunk, retrieve its info and stop iterating */ - if(chunk_info->curr_idx == chunk_info->chunk_idx) { - hsize_t ii = 0; /* Dimension index */ + if (chunk_info->curr_idx == chunk_info->chunk_idx) { + hsize_t ii = 0; /* Dimension index */ /* Copy info */ chunk_info->filter_mask = chunk_rec->filter_mask; - chunk_info->chunk_addr = chunk_rec->chunk_addr; - chunk_info->nbytes = chunk_rec->nbytes; - for(ii = 0; ii < chunk_info->ndims; ii++) + chunk_info->chunk_addr = chunk_rec->chunk_addr; + chunk_info->nbytes = chunk_rec->nbytes; + for (ii = 0; ii < chunk_info->ndims; ii++) chunk_info->scaled[ii] = chunk_rec->scaled[ii]; chunk_info->found = TRUE; @@ -7298,7 +7259,6 @@ H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_chunk_info_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info * @@ -7317,14 +7277,15 @@ H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_t chk_index, hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) +H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_t chk_index, hsize_t *offset, + unsigned *filter_mask, haddr_t *addr, hsize_t *size) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_chunk_info_iter_ud_t udata; /* User data for callback */ - const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ - H5D_rdcc_ent_t *ent; /* Cache entry index */ - hsize_t ii = 0; /* Dimension index */ - herr_t ret_value = SUCCEED;/* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_chunk_info_iter_ud_t udata; /* User data for callback */ + const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */ + H5D_rdcc_ent_t * ent; /* Cache entry index */ + hsize_t ii = 0; /* Dimension index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7337,15 +7298,15 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ HDassert(rdcc); /* Search for cached chunks that haven't been written out */ - for(ent = rdcc->head; ent; ent = ent->next) + for (ent = rdcc->head; ent; ent = ent->next) /* Flush the chunk out to disk, to make certain the size is correct later */ - if(H5D__chunk_flush_entry(dset, ent, FALSE) < 0) + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Set addr & size for when dset is not written or queried chunk is not found */ @@ -7355,39 +7316,40 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ *size = 0; /* If the chunk is written, get its info, otherwise, return without error */ - if(H5F_addr_defined(idx_info.storage->idx_addr)) { + if (H5F_addr_defined(idx_info.storage->idx_addr)) { /* Initialize before iteration */ - udata.chunk_idx = chk_index; - udata.curr_idx = 0; - udata.ndims = dset->shared->ndims; - udata.nbytes = 0; + udata.chunk_idx = chk_index; + udata.curr_idx = 0; + udata.ndims = dset->shared->ndims; + udata.nbytes = 0; udata.filter_mask = 0; - udata.chunk_addr = HADDR_UNDEF; - udata.found = FALSE; + udata.chunk_addr = HADDR_UNDEF; + udata.found = FALSE; /* Iterate over the allocated chunks */ - if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_chunk_info_cb, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") + if ((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_chunk_info_cb, &udata) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve allocated chunk information from index") /* Obtain requested info if the chunk is found */ - if(udata.found) { - if(filter_mask) + if (udata.found) { + if (filter_mask) *filter_mask = udata.filter_mask; - if(addr) + if (addr) *addr = udata.chunk_addr; - if(size) + if (size) *size = udata.nbytes; - if(offset) - for(ii = 0; ii < udata.ndims; ii++) + if (offset) + for (ii = 0; ii < udata.ndims; ii++) offset[ii] = udata.scaled[ii] * dset->shared->layout.u.chunk.dim[ii]; } /* end if */ - } /* end if H5F_addr_defined */ + } /* end if H5F_addr_defined */ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_chunk_info() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info_by_coord_cb * @@ -7406,9 +7368,9 @@ static int H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { H5D_chunk_info_iter_ud_t *chunk_info = (H5D_chunk_info_iter_ud_t *)_udata; - hbool_t different = FALSE; /* TRUE when a scaled value pair mismatch */ - hsize_t ii; /* Local index value */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + hbool_t different = FALSE; /* TRUE when a scaled value pair mismatch */ + hsize_t ii; /* Local index value */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -7423,10 +7385,10 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Same scaled coords means the chunk is found, copy the chunk info */ if (!different) { - chunk_info->nbytes = chunk_rec->nbytes; + chunk_info->nbytes = chunk_rec->nbytes; chunk_info->filter_mask = chunk_rec->filter_mask; - chunk_info->chunk_addr = chunk_rec->chunk_addr; - chunk_info->found = TRUE; + chunk_info->chunk_addr = chunk_rec->chunk_addr; + chunk_info->found = TRUE; /* Stop iterating */ ret_value = H5_ITER_STOP; @@ -7435,7 +7397,6 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_chunk_info_by_coord_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info_by_coord * @@ -7451,14 +7412,15 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned* filter_mask, haddr_t *addr, hsize_t *size) +H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned *filter_mask, haddr_t *addr, + hsize_t *size) { - const H5O_layout_t *layout = NULL; /* Dataset layout */ - const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ - H5D_rdcc_ent_t *ent; /* Cache entry index */ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_chunk_info_iter_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t * layout = NULL; /* Dataset layout */ + const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */ + H5D_rdcc_ent_t * ent; /* Cache entry index */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_chunk_info_iter_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7469,58 +7431,59 @@ H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned* /* Get dataset layout and raw data chunk cache */ layout = &(dset->shared->layout); - rdcc = &(dset->shared->cache.chunk); + rdcc = &(dset->shared->cache.chunk); HDassert(layout); HDassert(rdcc); HDassert(H5D_CHUNKED == layout->type); /* Search for cached chunks that haven't been written out */ - for(ent = rdcc->head; ent; ent = ent->next) + for (ent = rdcc->head; ent; ent = ent->next) /* Flush the chunk out to disk, to make certain the size is correct later */ - if(H5D__chunk_flush_entry(dset, ent, FALSE) < 0) + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") /* Set addr & size for when dset is not written or queried chunk is not found */ - if(addr) + if (addr) *addr = HADDR_UNDEF; - if(size) + if (size) *size = 0; /* Compose chunked index info struct */ - idx_info.f = dset->oloc.file; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = &dset->shared->layout.storage.u.chunk; /* If the dataset is not written, return without errors */ - if(H5F_addr_defined(idx_info.storage->idx_addr)) { + if (H5F_addr_defined(idx_info.storage->idx_addr)) { /* Calculate the scaled of this chunk */ H5VM_chunk_scaled(dset->shared->ndims, offset, layout->u.chunk.dim, udata.scaled); udata.scaled[dset->shared->ndims] = 0; /* Initialize before iteration */ - udata.ndims = dset->shared->ndims; - udata.nbytes = 0; + udata.ndims = dset->shared->ndims; + udata.nbytes = 0; udata.filter_mask = 0; - udata.chunk_addr = HADDR_UNDEF; - udata.found = FALSE; + udata.chunk_addr = HADDR_UNDEF; + udata.found = FALSE; /* Iterate over the allocated chunks to find the requested chunk */ - if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_chunk_info_by_coord_cb, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve information of the chunk by its scaled coordinates") + if ((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_chunk_info_by_coord_cb, + &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve information of the chunk by its scaled coordinates") /* Obtain requested info if the chunk is found */ - if(udata.found) { - if(filter_mask) + if (udata.found) { + if (filter_mask) *filter_mask = udata.filter_mask; - if(addr) + if (addr) *addr = udata.chunk_addr; - if(size) + if (size) *size = udata.nbytes; } /* end if */ - } /* end if H5F_addr_defined */ + } /* end if H5F_addr_defined */ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_chunk_info_by_coord() */ - diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 809cdfc..8bbe1c6 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -23,78 +23,61 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Layout operation callbacks */ -static herr_t H5D__compact_construct(H5F_t *f, H5D_t *dset); +static herr_t H5D__compact_construct(H5F_t *f, H5D_t *dset); static hbool_t H5D__compact_is_space_alloc(const H5O_storage_t *storage); -static herr_t H5D__compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *cm); -static ssize_t H5D__compact_readvv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]); -static ssize_t H5D__compact_writevv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]); -static herr_t H5D__compact_flush(H5D_t *dset); -static herr_t H5D__compact_dest(H5D_t *dset); - +static herr_t H5D__compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t *cm); +static ssize_t H5D__compact_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]); +static ssize_t H5D__compact_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]); +static herr_t H5D__compact_flush(H5D_t *dset); +static herr_t H5D__compact_dest(H5D_t *dset); /*********************/ /* Package Variables */ /*********************/ /* Compact storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{ - H5D__compact_construct, - NULL, - H5D__compact_is_space_alloc, - NULL, - H5D__compact_io_init, - H5D__contig_read, - H5D__contig_write, +const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = { + {H5D__compact_construct, NULL, H5D__compact_is_space_alloc, NULL, H5D__compact_io_init, H5D__contig_read, + H5D__contig_write, #ifdef H5_HAVE_PARALLEL - NULL, - NULL, + NULL, NULL, #endif /* H5_HAVE_PARALLEL */ - H5D__compact_readvv, - H5D__compact_writevv, - H5D__compact_flush, - NULL, - H5D__compact_dest -}}; - + H5D__compact_readvv, H5D__compact_writevv, H5D__compact_flush, NULL, H5D__compact_dest}}; /*******************/ /* Local Variables */ @@ -103,8 +86,6 @@ const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{ /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - - /*------------------------------------------------------------------------- * Function: H5D__compact_fill * @@ -120,9 +101,9 @@ H5FL_BLK_EXTERN(type_conv); herr_t H5D__compact_fill(const H5D_t *dset) { - H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ - hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ + hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -134,28 +115,26 @@ H5D__compact_fill(const H5D_t *dset) /* Initialize the fill value buffer */ /* (use the compact dataset storage buffer as the fill value buffer) */ - if(H5D__fill_init(&fb_info, dset->shared->layout.storage.u.compact.buf, - NULL, NULL, NULL, NULL, - &dset->shared->dcpl_cache.fill, dset->shared->type, - dset->shared->type_id, (size_t)0, dset->shared->layout.storage.u.compact.size) < 0) + if (H5D__fill_init(&fb_info, dset->shared->layout.storage.u.compact.buf, NULL, NULL, NULL, NULL, + &dset->shared->dcpl_cache.fill, dset->shared->type, dset->shared->type_id, (size_t)0, + dset->shared->layout.storage.u.compact.size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; /* Check for VL datatype & non-default fill value */ - if(fb_info.has_vlen_fill_type) + if (fb_info.has_vlen_fill_type) /* Fill the buffer with VL datatype fill values */ - if(H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) + if (H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_construct * @@ -171,11 +150,11 @@ done: static herr_t H5D__compact_construct(H5F_t *f, H5D_t *dset) { - hssize_t stmp_size; /* Temporary holder for raw data size */ - hsize_t tmp_size; /* Temporary holder for raw data size */ - hsize_t max_comp_data_size; /* Max. allowed size of compact data */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hssize_t stmp_size; /* Temporary holder for raw data size */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + hsize_t max_comp_data_size; /* Max. allowed size of compact data */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -184,8 +163,8 @@ H5D__compact_construct(H5F_t *f, H5D_t *dset) HDassert(dset); /* Check for invalid dataset dimensions */ - for(u = 0; u < dset->shared->ndims; u++) - if(dset->shared->max_dims[u] > dset->shared->curr_dims[u]) + for (u = 0; u < dset->shared->ndims; u++) + if (dset->shared->max_dims[u] > dset->shared->curr_dims[u]) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible compact dataset not allowed") /* @@ -203,14 +182,14 @@ H5D__compact_construct(H5F_t *f, H5D_t *dset) * (64KB) minus other layout message fields. */ max_comp_data_size = H5O_MESG_MAX_SIZE - H5D__layout_meta_size(f, &(dset->shared->layout), FALSE); - if(dset->shared->layout.storage.u.compact.size > max_comp_data_size) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "compact dataset size is bigger than header message maximum size") + if (dset->shared->layout.storage.u.compact.size > max_comp_data_size) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "compact dataset size is bigger than header message maximum size") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_construct() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_is_space_alloc * @@ -235,7 +214,6 @@ H5D__compact_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) FUNC_LEAVE_NOAPI(TRUE) } /* end H5D__compact_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_io_init * @@ -250,18 +228,17 @@ H5D__compact_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) */ static herr_t H5D__compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *cm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR - io_info->store->compact.buf = io_info->dset->shared->layout.storage.u.compact.buf; + io_info->store->compact.buf = io_info->dset->shared->layout.storage.u.compact.buf; io_info->store->compact.dirty = &io_info->dset->shared->layout.storage.u.compact.dirty; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__compact_io_init() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_readvv * @@ -281,25 +258,26 @@ H5D__compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR *------------------------------------------------------------------------- */ static ssize_t -H5D__compact_readvv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]) +H5D__compact_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]) { - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC HDassert(io_info); /* Use the vectorized memory copy routine to do actual work */ - if((ret_value = H5VM_memcpyvv(io_info->u.rbuf, mem_max_nseq, mem_curr_seq, mem_size_arr, mem_offset_arr, io_info->store->compact.buf, dset_max_nseq, dset_curr_seq, dset_size_arr, dset_offset_arr)) < 0) + if ((ret_value = H5VM_memcpyvv(io_info->u.rbuf, mem_max_nseq, mem_curr_seq, mem_size_arr, mem_offset_arr, + io_info->store->compact.buf, dset_max_nseq, dset_curr_seq, dset_size_arr, + dset_offset_arr)) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__compact_readvv() */ +} /* end H5D__compact_readvv() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_writevv * @@ -322,18 +300,20 @@ done: *------------------------------------------------------------------------- */ static ssize_t -H5D__compact_writevv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]) +H5D__compact_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]) { - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC HDassert(io_info); /* Use the vectorized memory copy routine to do actual work */ - if((ret_value = H5VM_memcpyvv(io_info->store->compact.buf, dset_max_nseq, dset_curr_seq, dset_size_arr, dset_offset_arr, io_info->u.wbuf, mem_max_nseq, mem_curr_seq, mem_size_arr, mem_offset_arr)) < 0) + if ((ret_value = H5VM_memcpyvv(io_info->store->compact.buf, dset_max_nseq, dset_curr_seq, dset_size_arr, + dset_offset_arr, io_info->u.wbuf, mem_max_nseq, mem_curr_seq, mem_size_arr, + mem_offset_arr)) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") /* Mark the compact dataset's buffer as dirty */ @@ -341,9 +321,8 @@ H5D__compact_writevv(const H5D_io_info_t *io_info, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__compact_writevv() */ +} /* end H5D__compact_writevv() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_flush * @@ -359,7 +338,7 @@ done: static herr_t H5D__compact_flush(H5D_t *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -367,9 +346,9 @@ H5D__compact_flush(H5D_t *dset) HDassert(dset); /* Check if the buffered compact information is dirty */ - if(dset->shared->layout.storage.u.compact.dirty) { + if (dset->shared->layout.storage.u.compact.dirty) { dset->shared->layout.storage.u.compact.dirty = FALSE; - if(H5O_msg_write(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dset->shared->layout)) < 0) { + if (H5O_msg_write(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dset->shared->layout)) < 0) { dset->shared->layout.storage.u.compact.dirty = TRUE; HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message") } @@ -379,7 +358,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_flush() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_dest * @@ -406,7 +384,6 @@ H5D__compact_dest(H5D_t *dset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__compact_dest() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_copy * @@ -421,18 +398,19 @@ H5D__compact_dest(H5D_t *dset) */ herr_t H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_dst, - H5O_storage_compact_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info) + H5O_storage_compact_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info) { - hid_t tid_src = -1; /* Datatype ID for source datatype */ - hid_t tid_dst = -1; /* Datatype ID for destination datatype */ - hid_t tid_mem = -1; /* Datatype ID for memory datatype */ - void *buf = NULL; /* Buffer for copying data */ - void *bkg = NULL; /* Temporary buffer for copying data */ - void *reclaim_buf = NULL; /* Buffer for reclaiming data */ - hid_t buf_sid = -1; /* ID for buffer dataspace */ - H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ - H5O_storage_compact_t *storage_src = _storage_src; /* Pointer to storage_src */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t tid_src = -1; /* Datatype ID for source datatype */ + hid_t tid_dst = -1; /* Datatype ID for destination datatype */ + hid_t tid_mem = -1; /* Datatype ID for memory datatype */ + void * buf = NULL; /* Buffer for copying data */ + void * bkg = NULL; /* Temporary buffer for copying data */ + void * reclaim_buf = NULL; /* Buffer for reclaiming data */ + hid_t buf_sid = -1; /* ID for buffer dataspace */ + H5D_shared_t *shared_fo = + (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ + H5O_storage_compact_t *storage_src = _storage_src; /* Pointer to storage_src */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -445,64 +423,64 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds HDassert(dt_src); /* If the dataset is open in the file, point to "layout" in the shared struct */ - if(shared_fo != NULL) + if (shared_fo != NULL) storage_src = &(shared_fo->layout.storage.u.compact); /* Create datatype ID for src datatype, so it gets freed */ - if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) + if ((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") /* If there's a VLEN source datatype, do type conversion information */ - if(H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { - H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */ - H5T_t *dt_dst; /* Destination datatype */ - H5T_t *dt_mem; /* Memory datatype */ - H5S_t *buf_space; /* Dataspace describing buffer */ - size_t buf_size; /* Size of copy buffer */ - size_t nelmts; /* Number of elements in buffer */ - size_t src_dt_size; /* Source datatype size */ - size_t tmp_dt_size; /* Temporary datatype size */ - size_t max_dt_size; /* Max atatype size */ - hsize_t buf_dim; /* Dimension for buffer */ + if (H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { + H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */ + H5T_t * dt_dst; /* Destination datatype */ + H5T_t * dt_mem; /* Memory datatype */ + H5S_t * buf_space; /* Dataspace describing buffer */ + size_t buf_size; /* Size of copy buffer */ + size_t nelmts; /* Number of elements in buffer */ + size_t src_dt_size; /* Source datatype size */ + size_t tmp_dt_size; /* Temporary datatype size */ + size_t max_dt_size; /* Max atatype size */ + hsize_t buf_dim; /* Dimension for buffer */ /* create a memory copy of the variable-length datatype */ - if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { (void)H5T_close_real(dt_mem); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ /* create variable-length datatype at the destinaton file */ - if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") - if(H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { + if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ - if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { + if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype") } /* end if */ /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) + if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes") /* Determine largest datatype size */ - if(0 == (src_dt_size = H5T_get_size(dt_src))) + if (0 == (src_dt_size = H5T_get_size(dt_src))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") - if(0 == (tmp_dt_size = H5T_get_size(dt_mem))) + if (0 == (tmp_dt_size = H5T_get_size(dt_mem))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(src_dt_size, tmp_dt_size); - if(0 == (tmp_dt_size = H5T_get_size(dt_dst))) + if (0 == (tmp_dt_size = H5T_get_size(dt_dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, tmp_dt_size); /* Set number of whole elements that fit in buffer */ - if(0 == (nelmts = storage_src->size / src_dt_size)) + if (0 == (nelmts = storage_src->size / src_dt_size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large") /* Set up number of bytes to copy, and initial buffer size */ @@ -512,31 +490,31 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds buf_dim = nelmts; /* Create the space and set the initial extent */ - if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) + if (NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Atomize */ - if((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { + if ((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { H5S_close(buf_space); HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") } /* end if */ /* Allocate memory for recclaim buf */ - if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Allocate memory for copying the chunk */ - if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") H5MM_memcpy(buf, storage_src->buf, storage_src->size); /* allocate temporary bkg buff for data conversion */ - if(NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Copy into another buffer, to reclaim memory later */ @@ -546,21 +524,22 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds HDmemset(bkg, 0, buf_size); /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") H5MM_memcpy(storage_dst->buf, buf, storage_dst->size); - if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data") } /* end if */ - else if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { - if(f_src != f_dst) { + else if (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { + if (f_src != f_dst) { /* Check for expanding references */ - if(cpy_info->expand_ref) { - /* Copy objects referenced in source buffer to destination file and set destination elements */ - if (H5O_copy_expand_ref(f_src, tid_src, dt_src, storage_src->buf, - storage_src->size, f_dst, storage_dst->buf, cpy_info) < 0) + if (cpy_info->expand_ref) { + /* Copy objects referenced in source buffer to destination file and set destination elements + */ + if (H5O_copy_expand_ref(f_src, tid_src, dt_src, storage_src->buf, storage_src->size, f_dst, + storage_dst->buf, cpy_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute") } /* end if */ else @@ -579,21 +558,20 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds storage_dst->dirty = TRUE; done: - if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) + if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(buf) + if (buf) buf = H5FL_BLK_FREE(type_conv, buf); - if(reclaim_buf) + if (reclaim_buf) reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf); - if(bkg) + if (bkg) bkg = H5FL_BLK_FREE(type_conv, bkg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_copy() */ - diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 655f660..4667d1d 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -25,115 +25,97 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Callback info for sieve buffer readvv operation */ typedef struct H5D_contig_readvv_sieve_ud_t { - H5F_shared_t *f_sh; /* Shared file for dataset */ - H5D_rdcdc_t *dset_contig; /* Cached information about contiguous data */ - const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */ - unsigned char *rbuf; /* Pointer to buffer to fill */ + H5F_shared_t * f_sh; /* Shared file for dataset */ + H5D_rdcdc_t * dset_contig; /* Cached information about contiguous data */ + const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */ + unsigned char * rbuf; /* Pointer to buffer to fill */ } H5D_contig_readvv_sieve_ud_t; /* Callback info for [plain] readvv operation */ typedef struct H5D_contig_readvv_ud_t { - H5F_shared_t *f_sh; /* Shared file for dataset */ - haddr_t dset_addr; /* Address of dataset */ - unsigned char *rbuf; /* Pointer to buffer to fill */ + H5F_shared_t * f_sh; /* Shared file for dataset */ + haddr_t dset_addr; /* Address of dataset */ + unsigned char *rbuf; /* Pointer to buffer to fill */ } H5D_contig_readvv_ud_t; /* Callback info for sieve buffer writevv operation */ typedef struct H5D_contig_writevv_sieve_ud_t { - H5F_shared_t *f_sh; /* Shared file for dataset */ - H5D_rdcdc_t *dset_contig; /* Cached information about contiguous data */ - const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */ - const unsigned char *wbuf; /* Pointer to buffer to write */ + H5F_shared_t * f_sh; /* Shared file for dataset */ + H5D_rdcdc_t * dset_contig; /* Cached information about contiguous data */ + const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */ + const unsigned char * wbuf; /* Pointer to buffer to write */ } H5D_contig_writevv_sieve_ud_t; /* Callback info for [plain] writevv operation */ typedef struct H5D_contig_writevv_ud_t { - H5F_shared_t *f_sh; /* Shared file for dataset */ - haddr_t dset_addr; /* Address of dataset */ - const unsigned char *wbuf; /* Pointer to buffer to write */ + H5F_shared_t * f_sh; /* Shared file for dataset */ + haddr_t dset_addr; /* Address of dataset */ + const unsigned char *wbuf; /* Pointer to buffer to write */ } H5D_contig_writevv_ud_t; - /********************/ /* Local Prototypes */ /********************/ /* Layout operation callbacks */ -static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset); -static herr_t H5D__contig_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); -static herr_t H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *cm); -static ssize_t H5D__contig_readvv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); -static ssize_t H5D__contig_writevv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); -static herr_t H5D__contig_flush(H5D_t *dset); +static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset); +static herr_t H5D__contig_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); +static herr_t H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t *cm); +static ssize_t H5D__contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); +static ssize_t H5D__contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); +static herr_t H5D__contig_flush(H5D_t *dset); /* Helper routines */ -static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, - size_t size); - +static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, size_t size); /*********************/ /* Package Variables */ /*********************/ /* Contiguous storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {{ - H5D__contig_construct, - H5D__contig_init, - H5D__contig_is_space_alloc, - H5D__contig_is_data_cached, - H5D__contig_io_init, - H5D__contig_read, - H5D__contig_write, +const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = { + {H5D__contig_construct, H5D__contig_init, H5D__contig_is_space_alloc, H5D__contig_is_data_cached, + H5D__contig_io_init, H5D__contig_read, H5D__contig_write, #ifdef H5_HAVE_PARALLEL - H5D__contig_collective_read, - H5D__contig_collective_write, + H5D__contig_collective_read, H5D__contig_collective_write, #endif /* H5_HAVE_PARALLEL */ - H5D__contig_readvv, - H5D__contig_writevv, - H5D__contig_flush, - NULL, - NULL -}}; - + H5D__contig_readvv, H5D__contig_writevv, H5D__contig_flush, NULL, NULL}}; /*******************/ /* Local Variables */ @@ -145,8 +127,6 @@ H5FL_BLK_DEFINE(sieve_buf); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - - /*------------------------------------------------------------------------- * Function: H5D__contig_alloc * @@ -160,9 +140,9 @@ H5FL_BLK_EXTERN(type_conv); *------------------------------------------------------------------------- */ herr_t -H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */ ) +H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -171,14 +151,13 @@ H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */ ) HDassert(storage); /* Allocate space for the contiguous data */ - if(HADDR_UNDEF == (storage->addr = H5MF_alloc(f, H5FD_MEM_DRAW, storage->size))) + if (HADDR_UNDEF == (storage->addr = H5MF_alloc(f, H5FD_MEM_DRAW, storage->size))) HGOTO_ERROR(H5E_IO, H5E_NOSPACE, FAIL, "unable to reserve file space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_alloc */ - /*------------------------------------------------------------------------- * Function: H5D__contig_fill * @@ -194,23 +173,24 @@ done: herr_t H5D__contig_fill(const H5D_io_info_t *io_info) { - const H5D_t *dset = io_info->dset; /* the dataset pointer */ - H5D_io_info_t ioinfo; /* Dataset I/O info */ - H5D_storage_t store; /* Union of storage info for dataset */ - hssize_t snpoints; /* Number of points in space (for error checking) */ - size_t npoints; /* Number of points in space */ - hsize_t offset; /* Offset of dataset */ - size_t max_temp_buf; /* Maximum size of temporary buffer */ + const H5D_t * dset = io_info->dset; /* the dataset pointer */ + H5D_io_info_t ioinfo; /* Dataset I/O info */ + H5D_storage_t store; /* Union of storage info for dataset */ + hssize_t snpoints; /* Number of points in space (for error checking) */ + size_t npoints; /* Number of points in space */ + hsize_t offset; /* Offset of dataset */ + size_t max_temp_buf; /* Maximum size of temporary buffer */ #ifdef H5_HAVE_PARALLEL - MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */ - int mpi_rank = (-1); /* This process's rank */ - int mpi_code; /* MPI return code */ - hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */ - hbool_t using_mpi = FALSE; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */ -#endif /* H5_HAVE_PARALLEL */ - H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ - hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */ + int mpi_rank = (-1); /* This process's rank */ + int mpi_code; /* MPI return code */ + hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */ + hbool_t using_mpi = + FALSE; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */ +#endif /* H5_HAVE_PARALLEL */ + H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ + hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -223,37 +203,36 @@ H5D__contig_fill(const H5D_io_info_t *io_info) #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ - if(H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) { /* Get the MPI communicator */ - if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) + if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator") /* Get the MPI rank */ - if((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank") /* Set the MPI-capable file driver flag */ using_mpi = TRUE; - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ /* Initialize storage info for this dataset */ store.contig.dset_addr = dset->shared->layout.storage.u.contig.addr; store.contig.dset_size = dset->shared->layout.storage.u.contig.size; /* Get the number of elements in the dataset's dataspace */ - if((snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) + if ((snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "dataset has negative number of elements") H5_CHECKED_ASSIGN(npoints, size_t, snpoints, hssize_t); /* Get the maximum size of temporary buffers */ - if(H5CX_get_max_temp_buf(&max_temp_buf) < 0) + if (H5CX_get_max_temp_buf(&max_temp_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve max. temp. buf size") /* Initialize the fill value buffer */ - if(H5D__fill_init(&fb_info, NULL, NULL, NULL, NULL, NULL, - &dset->shared->dcpl_cache.fill, - dset->shared->type, dset->shared->type_id, npoints, max_temp_buf) < 0) + if (H5D__fill_init(&fb_info, NULL, NULL, NULL, NULL, NULL, &dset->shared->dcpl_cache.fill, + dset->shared->type, dset->shared->type_id, npoints, max_temp_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; @@ -270,67 +249,66 @@ H5D__contig_fill(const H5D_io_info_t *io_info) */ /* Loop through writing the fill value to the dataset */ - while(npoints > 0) { - size_t curr_points; /* Number of elements to write on this iteration of the loop */ - size_t size; /* Size of buffer to write */ + while (npoints > 0) { + size_t curr_points; /* Number of elements to write on this iteration of the loop */ + size_t size; /* Size of buffer to write */ /* Compute # of elements and buffer size to write for this iteration */ curr_points = MIN(fb_info.elmts_per_buf, npoints); - size = curr_points * fb_info.file_elmt_size; + size = curr_points * fb_info.file_elmt_size; /* Check for VL datatype & non-default fill value */ - if(fb_info.has_vlen_fill_type) + if (fb_info.has_vlen_fill_type) /* Re-fill the buffer to use for this I/O operation */ - if(H5D__fill_refill_vl(&fb_info, curr_points) < 0) + if (H5D__fill_refill_vl(&fb_info, curr_points) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") #ifdef H5_HAVE_PARALLEL - /* Check if this file is accessed with an MPI-capable file driver */ - if(using_mpi) { - /* Write the chunks out from only one process */ - /* !! Use the internal "independent" DXPL!! -QAK */ - if(H5_PAR_META_WRITE == mpi_rank) - if(H5D__contig_write_one(&ioinfo, offset, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") - - /* Indicate that blocks are being written */ - blocks_written = TRUE; - } /* end if */ - else { -#endif /* H5_HAVE_PARALLEL */ - H5_CHECK_OVERFLOW(size, size_t, hsize_t); - if(H5D__contig_write_one(&ioinfo, offset, size) < 0) + /* Check if this file is accessed with an MPI-capable file driver */ + if (using_mpi) { + /* Write the chunks out from only one process */ + /* !! Use the internal "independent" DXPL!! -QAK */ + if (H5_PAR_META_WRITE == mpi_rank) + if (H5D__contig_write_one(&ioinfo, offset, size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") -#ifdef H5_HAVE_PARALLEL - } /* end else */ + + /* Indicate that blocks are being written */ + blocks_written = TRUE; + } /* end if */ + else { #endif /* H5_HAVE_PARALLEL */ + H5_CHECK_OVERFLOW(size, size_t, hsize_t); + if (H5D__contig_write_one(&ioinfo, offset, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") +#ifdef H5_HAVE_PARALLEL + } /* end else */ +#endif /* H5_HAVE_PARALLEL */ - npoints -= curr_points; - offset += size; - } /* end while */ + npoints -= curr_points; + offset += size; + } /* end while */ #ifdef H5_HAVE_PARALLEL /* Only need to block at the barrier if we actually wrote fill values */ /* And if we are using an MPI-capable file driver */ - if(using_mpi && blocks_written) { + if (using_mpi && blocks_written) { /* Wait at barrier to avoid race conditions where some processes are * still writing out fill values and other processes race ahead to data * in, getting bogus data. */ - if(MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_delete * @@ -346,7 +324,7 @@ done: herr_t H5D__contig_delete(H5F_t *f, const H5O_storage_t *storage) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -355,14 +333,13 @@ H5D__contig_delete(H5F_t *f, const H5O_storage_t *storage) HDassert(storage); /* Free the file space for the chunk */ - if(H5MF_xfree(f, H5FD_MEM_DRAW, storage->u.contig.addr, storage->u.contig.size) < 0) + if (H5MF_xfree(f, H5FD_MEM_DRAW, storage->u.contig.addr, storage->u.contig.size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free contiguous storage space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_delete */ - /*------------------------------------------------------------------------- * Function: H5D__contig_construct * @@ -378,13 +355,13 @@ done: static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset) { - hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ - hsize_t nelmts; /* Number of elements in dataspace */ - size_t dt_size; /* Size of datatype */ - hsize_t tmp_size; /* Temporary holder for raw data size */ - size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ + hsize_t nelmts; /* Number of elements in dataspace */ + size_t dt_size; /* Size of datatype */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -399,24 +376,25 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset) */ /* Check for invalid dataset dimensions */ - for(u = 0; u < dset->shared->ndims; u++) - if(dset->shared->max_dims[u] > dset->shared->curr_dims[u]) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible contiguous non-external dataset not allowed") + for (u = 0; u < dset->shared->ndims; u++) + if (dset->shared->max_dims[u] > dset->shared->curr_dims[u]) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "extendible contiguous non-external dataset not allowed") /* Retrieve the number of elements in the dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") nelmts = (hsize_t)snelmts; /* Get the datatype's size */ - if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) + if (0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") /* Compute the size of the dataset's contiguous storage */ tmp_size = nelmts * dt_size; /* Check for overflow during multiplication */ - if(nelmts != (tmp_size / dt_size)) + if (nelmts != (tmp_size / dt_size)) HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") /* Assign the dataset's contiguous storage size */ @@ -427,7 +405,7 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset) /* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size * from the file access property. (SLU - 2012/3/30) */ - if(tmp_size < tmp_sieve_buf_size) + if (tmp_size < tmp_sieve_buf_size) dset->shared->cache.contig.sieve_buf_size = tmp_size; else dset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size; @@ -436,7 +414,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_construct() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_init * @@ -451,12 +428,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, - hid_t H5_ATTR_UNUSED dapl_id) +H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, hid_t H5_ATTR_UNUSED dapl_id) { - hsize_t tmp_size; /* Temporary holder for raw data size */ - size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -468,25 +444,25 @@ H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, * layout message less than version 3 because versions 1 & 2 would * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ - if(dset->shared->layout.version < 3) { - hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ - hsize_t nelmts; /* Number of elements in dataspace */ - size_t dt_size; /* Size of datatype */ + if (dset->shared->layout.version < 3) { + hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ + hsize_t nelmts; /* Number of elements in dataspace */ + size_t dt_size; /* Size of datatype */ /* Retrieve the number of elements in the dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") nelmts = (hsize_t)snelmts; /* Get the datatype's size */ - if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) + if (0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") /* Compute the size of the dataset's contiguous storage */ tmp_size = nelmts * dt_size; /* Check for overflow during multiplication */ - if(nelmts != (tmp_size / dt_size)) + if (nelmts != (tmp_size / dt_size)) HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") /* Assign the dataset's contiguous storage size */ @@ -500,7 +476,7 @@ H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, /* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size * from the file access property. (SLU - 2012/3/30) */ - if(tmp_size < tmp_sieve_buf_size) + if (tmp_size < tmp_sieve_buf_size) dset->shared->cache.contig.sieve_buf_size = tmp_size; else dset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size; @@ -509,7 +485,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_init() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_is_space_alloc * @@ -525,7 +500,7 @@ done: hbool_t H5D__contig_is_space_alloc(const H5O_storage_t *storage) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -538,7 +513,6 @@ H5D__contig_is_space_alloc(const H5O_storage_t *storage) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_is_data_cached * @@ -562,7 +536,6 @@ H5D__contig_is_data_cached(const H5D_shared_t *shared_dset) FUNC_LEAVE_NOAPI(shared_dset->cache.contig.sieve_size > 0) } /* end H5D__contig_is_data_cached() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_io_init * @@ -577,8 +550,8 @@ H5D__contig_is_data_cached(const H5D_shared_t *shared_dset) */ static herr_t H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *cm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR @@ -588,7 +561,6 @@ H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__contig_io_init() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_read * @@ -602,11 +574,10 @@ H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_ *------------------------------------------------------------------------- */ herr_t -H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *fm) +H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_PACKAGE @@ -618,14 +589,13 @@ H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(file_space); /* Read data */ - if((io_info->io_ops.single_read)(io_info, type_info, nelmts, file_space, mem_space) < 0) + if ((io_info->io_ops.single_read)(io_info, type_info, nelmts, file_space, mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "contiguous read failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_read() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_write * @@ -639,11 +609,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *fm) +H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_PACKAGE @@ -655,14 +624,13 @@ H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(file_space); /* Write data */ - if((io_info->io_ops.single_write)(io_info, type_info, nelmts, file_space, mem_space) < 0) + if ((io_info->io_ops.single_write)(io_info, type_info, nelmts, file_space, mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "contiguous write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_write() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_write_one * @@ -680,27 +648,26 @@ done: static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, size_t size) { - hsize_t dset_off = offset; /* Offset in dataset */ - size_t dset_len = size; /* Length in dataset */ - size_t dset_curr_seq = 0; /* "Current sequence" in dataset */ - hsize_t mem_off = 0; /* Offset in memory */ - size_t mem_len = size; /* Length in memory */ - size_t mem_curr_seq = 0; /* "Current sequence" in memory */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t dset_off = offset; /* Offset in dataset */ + size_t dset_len = size; /* Length in dataset */ + size_t dset_curr_seq = 0; /* "Current sequence" in dataset */ + hsize_t mem_off = 0; /* Offset in memory */ + size_t mem_len = size; /* Length in memory */ + size_t mem_curr_seq = 0; /* "Current sequence" in memory */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(io_info); - if(H5D__contig_writevv(io_info, (size_t)1, &dset_curr_seq, &dset_len, &dset_off, - (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0) + if (H5D__contig_writevv(io_info, (size_t)1, &dset_curr_seq, &dset_len, &dset_off, (size_t)1, + &mem_curr_seq, &mem_len, &mem_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_write_one() */ +} /* end H5D__contig_write_one() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_readvv_sieve_cb * @@ -714,30 +681,31 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, - void *_udata) +H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_contig_readvv_sieve_ud_t *udata = (H5D_contig_readvv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */ - H5D_rdcdc_t *dset_contig = udata->dset_contig; /* Cached information about contiguous data */ - const H5D_contig_storage_t *store_contig = udata->store_contig; /* Contiguous storage info for this I/O operation */ - unsigned char *buf; /* Pointer to buffer to fill */ - haddr_t addr; /* Actual address to read */ - haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */ - haddr_t contig_end; /* End locations of block to write */ - size_t sieve_size = (size_t)-1; /* Size of sieve buffer */ - haddr_t rel_eoa; /* Relative end of file address */ - hsize_t max_data; /* Actual maximum size of data to cache */ - hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_contig_readvv_sieve_ud_t *udata = + (H5D_contig_readvv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */ + H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */ + H5D_rdcdc_t * dset_contig = udata->dset_contig; /* Cached information about contiguous data */ + const H5D_contig_storage_t *store_contig = + udata->store_contig; /* Contiguous storage info for this I/O operation */ + unsigned char *buf; /* Pointer to buffer to fill */ + haddr_t addr; /* Actual address to read */ + haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */ + haddr_t contig_end; /* End locations of block to write */ + size_t sieve_size = (size_t)-1; /* Size of sieve buffer */ + haddr_t rel_eoa; /* Relative end of file address */ + hsize_t max_data; /* Actual maximum size of data to cache */ + hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Stash local copies of these value */ - if(dset_contig->sieve_buf != NULL) { + if (dset_contig->sieve_buf != NULL) { sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; + sieve_size = dset_contig->sieve_size; + sieve_end = sieve_start + sieve_size; } /* end if */ /* Compute offset on disk */ @@ -747,22 +715,22 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, buf = udata->rbuf + src_off; /* Check if the sieve buffer is allocated yet */ - if(NULL == dset_contig->sieve_buf) { + if (NULL == dset_contig->sieve_buf) { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(len > dset_contig->sieve_buf_size) { - if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) + if (len > dset_contig->sieve_buf_size) { + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") } /* end if */ else { /* Allocate room for the data sieve buffer */ - if(NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size))) + if (NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Determine the new sieve buffer size & location */ dset_contig->sieve_loc = addr; /* Make certain we don't read off the end of the file */ - if(HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) + if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size") /* Set up the buffer parameters */ @@ -773,7 +741,8 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t); /* Read the new sieve buffer */ - if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") /* Grab the data out of the buffer (must be first piece of data in buffer ) */ @@ -782,13 +751,13 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty = FALSE; } /* end else */ - } /* end if */ + } /* end if */ else { /* Compute end of sequence to retrieve */ contig_end = addr + len - 1; /* If entire read is within the sieve buffer, read it from the buffer */ - if(addr >= sieve_start && contig_end < sieve_end) { + if (addr >= sieve_start && contig_end < sieve_end) { unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start); /* Grab the data out of the buffer */ @@ -797,31 +766,33 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Entire request is not within this data sieve buffer */ else { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(len > dset_contig->sieve_buf_size) { + if (len > dset_contig->sieve_buf_size) { /* Check for any overlap with the current sieve buffer */ - if((sieve_start >= addr && sieve_start < (contig_end + 1)) - || ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) { + if ((sieve_start >= addr && sieve_start < (contig_end + 1)) || + ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) { /* Flush the sieve buffer, if it's dirty */ - if(dset_contig->sieve_dirty) { + if (dset_contig->sieve_dirty) { /* Write to file */ - if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty = FALSE; } /* end if */ - } /* end if */ + } /* end if */ /* Read directly into the user's buffer */ - if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") } /* end if */ /* Element size fits within the buffer size */ else { /* Flush the sieve buffer if it's dirty */ - if(dset_contig->sieve_dirty) { + if (dset_contig->sieve_dirty) { /* Write to file */ - if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ @@ -832,7 +803,7 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, dset_contig->sieve_loc = addr; /* Make certain we don't read off the end of the file */ - if(HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) + if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size") /* Only need this when resizing sieve buffer */ @@ -847,7 +818,8 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t); /* Read the new sieve buffer */ - if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, + dset_contig->sieve_size, dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") /* Grab the data out of the buffer (must be first piece of data in buffer ) */ @@ -856,14 +828,13 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty = FALSE; } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_readvv_sieve_cb() */ +} /* end H5D__contig_readvv_sieve_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_readvv_cb * @@ -880,20 +851,19 @@ static herr_t H5D__contig_readvv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { H5D_contig_readvv_ud_t *udata = (H5D_contig_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Write data */ - if(H5F_shared_block_read(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), - len, (udata->rbuf + src_off)) < 0) + if (H5F_shared_block_read(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len, + (udata->rbuf + src_off)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_readvv_cb() */ +} /* end H5D__contig_readvv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_readvv * @@ -913,11 +883,11 @@ done: *------------------------------------------------------------------------- */ static ssize_t -H5D__contig_readvv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +H5D__contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_off_arr[]) { - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -931,41 +901,40 @@ H5D__contig_readvv(const H5D_io_info_t *io_info, HDassert(mem_off_arr); /* Check if data sieving is enabled */ - if(H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) { - H5D_contig_readvv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */ + if (H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) { + H5D_contig_readvv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */ /* Set up user data for H5VM_opvv() */ - udata.f_sh = io_info->f_sh; - udata.dset_contig = &(io_info->dset->shared->cache.contig); + udata.f_sh = io_info->f_sh; + udata.dset_contig = &(io_info->dset->shared->cache.contig); udata.store_contig = &(io_info->store->contig); - udata.rbuf = (unsigned char *)io_info->u.rbuf; + udata.rbuf = (unsigned char *)io_info->u.rbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__contig_readvv_sieve_cb, &udata)) < 0) + if ((ret_value = + H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_readvv_sieve_cb, &udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized sieve buffer read") } /* end if */ else { - H5D_contig_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ + H5D_contig_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ /* Set up user data for H5VM_opvv() */ - udata.f_sh = io_info->f_sh; + udata.f_sh = io_info->f_sh; udata.dset_addr = io_info->store->contig.dset_addr; - udata.rbuf = (unsigned char *)io_info->u.rbuf; + udata.rbuf = (unsigned char *)io_info->u.rbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__contig_readvv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_readvv_cb, &udata)) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized read") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_readvv() */ +} /* end H5D__contig_readvv() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_writevv_sieve_cb * @@ -979,30 +948,31 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, - void *_udata) +H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_contig_writevv_sieve_ud_t *udata = (H5D_contig_writevv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */ - H5D_rdcdc_t *dset_contig = udata->dset_contig; /* Cached information about contiguous data */ - const H5D_contig_storage_t *store_contig = udata->store_contig; /* Contiguous storage info for this I/O operation */ - const unsigned char *buf; /* Pointer to buffer to fill */ - haddr_t addr; /* Actual address to read */ - haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */ - haddr_t contig_end; /* End locations of block to write */ - size_t sieve_size = (size_t)-1; /* size of sieve buffer */ - haddr_t rel_eoa; /* Relative end of file address */ - hsize_t max_data; /* Actual maximum size of data to cache */ - hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_contig_writevv_sieve_ud_t *udata = + (H5D_contig_writevv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */ + H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */ + H5D_rdcdc_t * dset_contig = udata->dset_contig; /* Cached information about contiguous data */ + const H5D_contig_storage_t *store_contig = + udata->store_contig; /* Contiguous storage info for this I/O operation */ + const unsigned char *buf; /* Pointer to buffer to fill */ + haddr_t addr; /* Actual address to read */ + haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */ + haddr_t contig_end; /* End locations of block to write */ + size_t sieve_size = (size_t)-1; /* size of sieve buffer */ + haddr_t rel_eoa; /* Relative end of file address */ + hsize_t max_data; /* Actual maximum size of data to cache */ + hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Stash local copies of these values */ - if(dset_contig->sieve_buf != NULL) { + if (dset_contig->sieve_buf != NULL) { sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; + sieve_size = dset_contig->sieve_size; + sieve_end = sieve_start + sieve_size; } /* end if */ /* Compute offset on disk */ @@ -1012,26 +982,26 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, buf = udata->wbuf + src_off; /* No data sieve buffer yet, go allocate one */ - if(NULL == dset_contig->sieve_buf) { + if (NULL == dset_contig->sieve_buf) { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(len > dset_contig->sieve_buf_size) { - if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) + if (len > dset_contig->sieve_buf_size) { + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") } /* end if */ else { /* Allocate room for the data sieve buffer */ - if(NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size))) + if (NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Clear memory */ - if(dset_contig->sieve_size > len) + if (dset_contig->sieve_size > len) HDmemset(dset_contig->sieve_buf + len, 0, (dset_contig->sieve_size - len)); /* Determine the new sieve buffer size & location */ dset_contig->sieve_loc = addr; /* Make certain we don't read off the end of the file */ - if(HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) + if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size") /* Set up the buffer parameters */ @@ -1042,9 +1012,10 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t); /* Check if there is any point in reading the data from the file */ - if(dset_contig->sieve_size > len) { + if (dset_contig->sieve_size > len) { /* Read the new sieve buffer */ - if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, + dset_contig->sieve_size, dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") } /* end if */ @@ -1056,16 +1027,16 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Stash local copies of these values */ sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; + sieve_size = dset_contig->sieve_size; + sieve_end = sieve_start + sieve_size; } /* end else */ - } /* end if */ + } /* end if */ else { /* Compute end of sequence to retrieve */ contig_end = addr + len - 1; /* If entire write is within the sieve buffer, write it to the buffer */ - if(addr >= sieve_start && contig_end < sieve_end) { + if (addr >= sieve_start && contig_end < sieve_end) { unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start); /* Put the data into the sieve buffer */ @@ -1077,14 +1048,15 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Entire request is not within this data sieve buffer */ else { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(len > dset_contig->sieve_buf_size) { + if (len > dset_contig->sieve_buf_size) { /* Check for any overlap with the current sieve buffer */ - if((sieve_start >= addr && sieve_start < (contig_end + 1)) - || ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) { + if ((sieve_start >= addr && sieve_start < (contig_end + 1)) || + ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) { /* Flush the sieve buffer, if it's dirty */ - if(dset_contig->sieve_dirty) { + if (dset_contig->sieve_dirty) { /* Write to file */ - if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ @@ -1092,24 +1064,24 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, } /* end if */ /* Force the sieve buffer to be re-read the next time */ - dset_contig->sieve_loc = HADDR_UNDEF; + dset_contig->sieve_loc = HADDR_UNDEF; dset_contig->sieve_size = 0; } /* end if */ /* Write directly from the user's buffer */ - if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") } /* end if */ /* Element size fits within the buffer size */ else { /* Check if it is possible to (exactly) prepend or append to existing (dirty) sieve buffer */ - if(((addr + len) == sieve_start || addr == sieve_end) && - (len + sieve_size) <= dset_contig->sieve_buf_size && - dset_contig->sieve_dirty) { + if (((addr + len) == sieve_start || addr == sieve_end) && + (len + sieve_size) <= dset_contig->sieve_buf_size && dset_contig->sieve_dirty) { /* Prepend to existing sieve buffer */ - if((addr + len) == sieve_start) { + if ((addr + len) == sieve_start) { /* Move existing sieve information to correct location */ - HDmemmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf, dset_contig->sieve_size); + HDmemmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf, + dset_contig->sieve_size); /* Copy in new information (must be first in sieve buffer) */ H5MM_memcpy(dset_contig->sieve_buf, buf, len); @@ -1130,9 +1102,10 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Can't add the new data onto the existing sieve buffer */ else { /* Flush the sieve buffer if it's dirty */ - if(dset_contig->sieve_dirty) { + if (dset_contig->sieve_dirty) { /* Write to file */ - if(H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ @@ -1143,7 +1116,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, dset_contig->sieve_loc = addr; /* Make certain we don't read off the end of the file */ - if(HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) + if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size") /* Only need this when resizing sieve buffer */ @@ -1158,9 +1131,10 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t); /* Check if there is any point in reading the data from the file */ - if(dset_contig->sieve_size > len) { + if (dset_contig->sieve_size > len) { /* Read the new sieve buffer */ - if(H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, + dset_contig->sieve_size, dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") } /* end if */ @@ -1170,15 +1144,14 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Set sieve buffer dirty flag */ dset_contig->sieve_dirty = TRUE; } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_writevv_sieve_cb() */ +} /* end H5D__contig_writevv_sieve_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_writevv_cb * @@ -1194,20 +1167,21 @@ done: static herr_t H5D__contig_writevv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_contig_writevv_ud_t *udata = (H5D_contig_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_contig_writevv_ud_t *udata = + (H5D_contig_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Write data */ - if(H5F_shared_block_write(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len, (udata->wbuf + src_off)) < 0) + if (H5F_shared_block_write(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len, + (udata->wbuf + src_off)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_writevv_cb() */ +} /* end H5D__contig_writevv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_writevv * @@ -1227,11 +1201,11 @@ done: *------------------------------------------------------------------------- */ static ssize_t -H5D__contig_writevv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +H5D__contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_off_arr[]) { - ssize_t ret_value = -1; /* Return value (Size of sequence in bytes) */ + ssize_t ret_value = -1; /* Return value (Size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -1245,41 +1219,40 @@ H5D__contig_writevv(const H5D_io_info_t *io_info, HDassert(mem_off_arr); /* Check if data sieving is enabled */ - if(H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) { - H5D_contig_writevv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */ + if (H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) { + H5D_contig_writevv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */ /* Set up user data for H5VM_opvv() */ - udata.f_sh = io_info->f_sh; - udata.dset_contig = &(io_info->dset->shared->cache.contig); + udata.f_sh = io_info->f_sh; + udata.dset_contig = &(io_info->dset->shared->cache.contig); udata.store_contig = &(io_info->store->contig); - udata.wbuf = (const unsigned char *)io_info->u.wbuf; + udata.wbuf = (const unsigned char *)io_info->u.wbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__contig_writevv_sieve_cb, &udata)) < 0) + if ((ret_value = + H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_writevv_sieve_cb, &udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized sieve buffer write") } /* end if */ else { - H5D_contig_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ + H5D_contig_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ /* Set up user data for H5VM_opvv() */ - udata.f_sh = io_info->f_sh; + udata.f_sh = io_info->f_sh; udata.dset_addr = io_info->store->contig.dset_addr; - udata.wbuf = (const unsigned char *)io_info->u.wbuf; + udata.wbuf = (const unsigned char *)io_info->u.wbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__contig_writevv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_writevv_cb, &udata)) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized read") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_writevv() */ +} /* end H5D__contig_writevv() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_flush * @@ -1295,7 +1268,7 @@ done: static herr_t H5D__contig_flush(H5D_t *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1303,14 +1276,13 @@ H5D__contig_flush(H5D_t *dset) HDassert(dset); /* Flush any data in sieve buffer */ - if(H5D__flush_sieve_buf(dset) < 0) + if (H5D__flush_sieve_buf(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush sieve buffer") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_flush() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_copy * @@ -1324,41 +1296,41 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, - H5F_t *f_dst, H5O_storage_contig_t *storage_dst, H5T_t *dt_src, - H5O_copy_t *cpy_info) +H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f_dst, + H5O_storage_contig_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info) { - haddr_t addr_src; /* File offset in source dataset */ - haddr_t addr_dst; /* File offset in destination dataset */ - H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ - H5T_t *dt_dst = NULL; /* Destination datatype */ - H5T_t *dt_mem = NULL; /* Memory datatype */ - hid_t tid_src = -1; /* Datatype ID for source datatype */ - hid_t tid_dst = -1; /* Datatype ID for destination datatype */ - hid_t tid_mem = -1; /* Datatype ID for memory datatype */ - size_t src_dt_size = 0; /* Source datatype size */ - size_t mem_dt_size = 0; /* Memory datatype size */ - size_t dst_dt_size = 0; /* Destination datatype size */ - size_t max_dt_size; /* Max. datatype size */ - size_t nelmts = 0; /* Number of elements in buffer */ - size_t src_nbytes; /* Number of bytes to read from source */ - size_t mem_nbytes; /* Number of bytes to convert in memory */ - size_t dst_nbytes; /* Number of bytes to write to destination */ - hsize_t total_src_nbytes; /* Total number of bytes to copy */ - size_t buf_size; /* Size of copy buffer */ - void *buf = NULL; /* Buffer for copying data */ - void *bkg = NULL; /* Temporary buffer for copying data */ - void *reclaim_buf = NULL; /* Buffer for reclaiming data */ - H5S_t *buf_space = NULL; /* Dataspace describing buffer */ - hid_t buf_sid = -1; /* ID for buffer dataspace */ - hsize_t buf_dim[1] = {0}; /* Dimension for buffer */ - hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */ - hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */ - H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ - hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */ - haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */ - haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t addr_src; /* File offset in source dataset */ + haddr_t addr_dst; /* File offset in destination dataset */ + H5T_path_t * tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ + H5T_t * dt_dst = NULL; /* Destination datatype */ + H5T_t * dt_mem = NULL; /* Memory datatype */ + hid_t tid_src = -1; /* Datatype ID for source datatype */ + hid_t tid_dst = -1; /* Datatype ID for destination datatype */ + hid_t tid_mem = -1; /* Datatype ID for memory datatype */ + size_t src_dt_size = 0; /* Source datatype size */ + size_t mem_dt_size = 0; /* Memory datatype size */ + size_t dst_dt_size = 0; /* Destination datatype size */ + size_t max_dt_size; /* Max. datatype size */ + size_t nelmts = 0; /* Number of elements in buffer */ + size_t src_nbytes; /* Number of bytes to read from source */ + size_t mem_nbytes; /* Number of bytes to convert in memory */ + size_t dst_nbytes; /* Number of bytes to write to destination */ + hsize_t total_src_nbytes; /* Total number of bytes to copy */ + size_t buf_size; /* Size of copy buffer */ + void * buf = NULL; /* Buffer for copying data */ + void * bkg = NULL; /* Temporary buffer for copying data */ + void * reclaim_buf = NULL; /* Buffer for reclaiming data */ + H5S_t * buf_space = NULL; /* Dataspace describing buffer */ + hid_t buf_sid = -1; /* ID for buffer dataspace */ + hsize_t buf_dim[1] = {0}; /* Dimension for buffer */ + hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */ + hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */ + H5D_shared_t *shared_fo = + (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ + hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */ + haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */ + haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1370,7 +1342,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, HDassert(dt_src); /* Allocate space for destination raw data */ - if(H5D__contig_alloc(f_dst, storage_dst) < 0) + if (H5D__contig_alloc(f_dst, storage_dst) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to allocate contiguous storage") /* Set up number of bytes to copy, and initial buffer size */ @@ -1382,49 +1354,49 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, /* Create datatype ID for src datatype. We may or may not use this ID, * but this ensures that the src datatype will be freed. */ - if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) + if ((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") /* If there's a VLEN source datatype, set up type conversion information */ - if(H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { + if (H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { /* create a memory copy of the variable-length datatype */ - if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { (void)H5T_close_real(dt_mem); HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ /* create variable-length datatype at the destinaton file */ - if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy") - if(H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { + if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ - if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { + if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype") } /* end if */ /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) + if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes") /* Determine largest datatype size */ - if(0 == (src_dt_size = H5T_get_size(dt_src))) + if (0 == (src_dt_size = H5T_get_size(dt_src))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size") - if(0 == (mem_dt_size = H5T_get_size(dt_mem))) + if (0 == (mem_dt_size = H5T_get_size(dt_mem))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(src_dt_size, mem_dt_size); - if(0 == (dst_dt_size = H5T_get_size(dt_dst))) + if (0 == (dst_dt_size = H5T_get_size(dt_dst))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, dst_dt_size); /* Set maximum number of whole elements that fit in buffer */ - if(0 == (nelmts = buf_size / max_dt_size)) + if (0 == (nelmts = buf_size / max_dt_size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large") /* Set the number of bytes to transfer */ @@ -1439,11 +1411,11 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, buf_dim[0] = nelmts; /* Create the space and set the initial extent */ - if(NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL))) + if (NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Atomize */ - if((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { + if ((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { H5S_close(buf_space); HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") } /* end if */ @@ -1453,9 +1425,9 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end if */ else { /* Check for reference datatype */ - if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { + if (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { /* Need to fix values of references when copying across files */ - if(f_src != f_dst) + if (f_src != f_dst) fix_ref = TRUE; } /* end if */ @@ -1465,16 +1437,16 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, /* Allocate space for copy buffer */ HDassert(buf_size); - if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") /* Need extra buffer for datatype conversions, to prevent stranding/leaking memory */ - if(is_vlen || fix_ref) { - if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (is_vlen || fix_ref) { + if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") /* allocate temporary bkg buff for data conversion */ - if(NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") } /* end if */ @@ -1484,23 +1456,22 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, /* If data sieving is enabled and the dataset is open in the file, set up to copy data out of the sieve buffer if deemed possible later */ - if(H5F_HAS_FEATURE(f_src, H5FD_FEAT_DATA_SIEVE) && - shared_fo && shared_fo->cache.contig.sieve_buf) { - try_sieve = TRUE; + if (H5F_HAS_FEATURE(f_src, H5FD_FEAT_DATA_SIEVE) && shared_fo && shared_fo->cache.contig.sieve_buf) { + try_sieve = TRUE; sieve_start = shared_fo->cache.contig.sieve_loc; - sieve_end = sieve_start + shared_fo->cache.contig.sieve_size; + sieve_end = sieve_start + shared_fo->cache.contig.sieve_size; } - while(total_src_nbytes > 0) { + while (total_src_nbytes > 0) { /* Check if we should reduce the number of bytes to transfer */ - if(total_src_nbytes < src_nbytes) { + if (total_src_nbytes < src_nbytes) { /* Adjust bytes to transfer */ src_nbytes = (size_t)total_src_nbytes; /* Adjust dataspace describing buffer */ - if(is_vlen) { + if (is_vlen) { /* Adjust destination & memory bytes to transfer */ - nelmts = src_nbytes / src_dt_size; + nelmts = src_nbytes / src_dt_size; dst_nbytes = nelmts * dst_dt_size; mem_nbytes = nelmts * mem_dt_size; @@ -1508,7 +1479,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, buf_dim[0] = nelmts; /* Adjust size of buffer's dataspace */ - if(H5S_set_extent_real(buf_space, buf_dim) < 0) + if (H5S_set_extent_real(buf_space, buf_dim) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to change buffer dataspace size") } /* end if */ else @@ -1517,19 +1488,20 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end if */ /* If the entire copy is within the sieve buffer, copy data from the sieve buffer */ - if(try_sieve && (addr_src >= sieve_start) && ((addr_src + src_nbytes -1) < sieve_end)) { + if (try_sieve && (addr_src >= sieve_start) && ((addr_src + src_nbytes - 1) < sieve_end)) { unsigned char *base_sieve_buf = shared_fo->cache.contig.sieve_buf + (addr_src - sieve_start); H5MM_memcpy(buf, base_sieve_buf, src_nbytes); - } else + } + else /* Read raw data from source file */ - if(H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, src_nbytes, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data") + if (H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, src_nbytes, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data") /* Perform datatype conversion, if necessary */ - if(is_vlen) { + if (is_vlen) { /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Copy into another buffer, to reclaim memory later */ @@ -1539,22 +1511,22 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, HDmemset(bkg, 0, buf_size); /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Reclaim space from variable length data */ - if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data") } /* end if */ - else if(fix_ref) { + else if (fix_ref) { /* Check for expanding references */ - if(cpy_info->expand_ref) { + if (cpy_info->expand_ref) { /* Copy the reference elements */ - if(H5O_copy_expand_ref(f_src, tid_src, dt_src, buf, buf_size, f_dst, bkg, cpy_info) < 0) + if (H5O_copy_expand_ref(f_src, tid_src, dt_src, buf, buf_size, f_dst, bkg, cpy_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute") /* After fix ref, copy the new reference elements to the buffer to write out */ - H5MM_memcpy(buf, bkg, buf_size); + H5MM_memcpy(buf, bkg, buf_size); } /* end if */ else /* Reset value to zero */ @@ -1562,7 +1534,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end if */ /* Write raw data to destination file */ - if(H5F_block_write(f_dst, H5FD_MEM_DRAW, addr_dst, dst_nbytes, buf) < 0) + if (H5F_block_write(f_dst, H5FD_MEM_DRAW, addr_dst, dst_nbytes, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data") /* Adjust loop variables */ @@ -1572,21 +1544,20 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end while */ done: - if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) + if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(buf) + if (buf) buf = H5FL_BLK_FREE(type_conv, buf); - if(reclaim_buf) + if (reclaim_buf) reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf); - if(bkg) + if (bkg) bkg = H5FL_BLK_FREE(type_conv, bkg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_copy() */ - diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c index d11a5d8..8c10983 100644 --- a/src/H5Ddbg.c +++ b/src/H5Ddbg.c @@ -15,51 +15,42 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Ddebug * @@ -73,23 +64,22 @@ herr_t H5Ddebug(hid_t dset_id) { - H5D_t *dset; /* Dataset to debug */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset; /* Dataset to debug */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Print B-tree information */ - if(H5D_CHUNKED == dset->shared->layout.type) + if (H5D_CHUNKED == dset->shared->layout.type) (void)H5D__chunk_dump_index(dset, stdout); - else if(H5D_CONTIGUOUS == dset->shared->layout.type) + else if (H5D_CONTIGUOUS == dset->shared->layout.type) HDfprintf(stdout, " %-10s %a\n", "Address:", dset->shared->layout.storage.u.contig.addr); done: FUNC_LEAVE_API(ret_value) } /* end H5Ddebug() */ - diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index f4f4223..0b8aef5 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -29,57 +29,48 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Dcreate1 * @@ -110,62 +101,60 @@ *------------------------------------------------------------------------- */ hid_t -H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, - hid_t dcpl_id) +H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - void *dset = NULL; /* dset object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + void * dset = NULL; /* dset object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, dcpl_id); /* Check arguments */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read") - if(H5P_DEFAULT == dcpl_id) + if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") /* Set the DCPL for the API context */ H5CX_set_dcpl(dcpl_id); /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the dataset through the VOL */ - if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, H5P_LINK_CREATE_DEFAULT, type_id, space_id, dcpl_id, - H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, H5P_LINK_CREATE_DEFAULT, type_id, + space_id, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: if (H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate1() */ - /*------------------------------------------------------------------------- * Function: H5Dopen1 * @@ -186,10 +175,10 @@ done: hid_t H5Dopen1(hid_t loc_id, const char *name) { - void *dset = NULL; /* dset object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + void * dset = NULL; /* dset object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); @@ -201,30 +190,30 @@ H5Dopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the dataset */ - if(NULL == (dset = H5VL_dataset_open(vol_obj, &loc_params, name, H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (dset = H5VL_dataset_open(vol_obj, &loc_params, name, H5P_DATASET_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Get an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: - if(H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dopen1() */ - /*------------------------------------------------------------------------- * Function: H5Dextend * @@ -244,33 +233,34 @@ done: herr_t H5Dextend(hid_t dset_id, const hsize_t size[]) { - H5VL_object_t *vol_obj = NULL; /* Dataset structure */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - H5S_t *ds = NULL; /* Dataspace struct */ - int ndims; /* Dataset/space rank */ - hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + H5S_t * ds = NULL; /* Dataspace struct */ + int ndims; /* Dataset/space rank */ + hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - if(!size) + if (!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") /* Get the dataspace pointer for the dataset */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &sid) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &sid) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataspace") - if(H5I_INVALID_HID == sid) + if (H5I_INVALID_HID == sid) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "received an invalid dataspace from the dataset") - if(NULL == (ds = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get dataspace structure from ID") /* Get the dataset's current extent */ - if(H5S_get_simple_extent_dims(ds, dset_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(ds, dset_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") /* Get the dataset dimensions */ @@ -283,21 +273,22 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) * XXX (VOL_MERGE): I feel like we should fail here instead of just silently * not doing what we're supposed to do. */ - for(i = 0; i < ndims; i++) - if(size[i] > dset_dims[i]) + for (i = 0; i < ndims; i++) + if (size[i] > dset_dims[i]) dset_dims[i] = size[i]; /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Increase size */ - if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_dims)) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, dset_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to extend dataset") done: /* Close the dataspace */ - if(sid != H5I_INVALID_HID && H5I_dec_app_ref(sid) < 0) + if (sid != H5I_INVALID_HID && H5I_dec_app_ref(sid) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close dataspace") FUNC_LEAVE_API(ret_value) @@ -321,26 +312,25 @@ done: herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) { - H5S_t *space; /* Dataspace for iteration */ - herr_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace for iteration */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf); /* Check args */ - if(H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL) + if (H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") /* Get the default dataset transfer property list if the user didn't provide one */ - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); @@ -350,7 +340,6 @@ H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) done: FUNC_LEAVE_API(ret_value) -} /* end H5Dvlen_reclaim() */ +} /* end H5Dvlen_reclaim() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Dearray.c b/src/H5Dearray.c index 8f34a07..f14540c 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -25,30 +25,30 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EAprivate.h" /* Extensible arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EAprivate.h" /* Extensible arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Value to fill unset array elements with */ -#define H5D_EARRAY_FILL HADDR_UNDEF -#define H5D_EARRAY_FILT_FILL {HADDR_UNDEF, 0, 0} - +#define H5D_EARRAY_FILL HADDR_UNDEF +#define H5D_EARRAY_FILT_FILL \ + { \ + HADDR_UNDEF, 0, 0 \ + } /******************/ /* Local Typedefs */ @@ -56,33 +56,32 @@ /* Extensible array create/open user data */ typedef struct H5D_earray_ctx_ud_t { - const H5F_t *f; /* Pointer to file info */ - uint32_t chunk_size; /* Size of chunk (bytes) */ + const H5F_t *f; /* Pointer to file info */ + uint32_t chunk_size; /* Size of chunk (bytes) */ } H5D_earray_ctx_ud_t; /* Extensible array callback context */ typedef struct H5D_earray_ctx_t { - size_t file_addr_len; /* Size of addresses in the file (bytes) */ - size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ + size_t file_addr_len; /* Size of addresses in the file (bytes) */ + size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ } H5D_earray_ctx_t; /* Extensible Array callback info for iteration over chunks */ typedef struct H5D_earray_it_ud_t { - H5D_chunk_common_ud_t common; /* Common info for Fixed Array user data (must be first) */ - H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ - hbool_t filtered; /* Whether the chunks are filtered */ - H5D_chunk_cb_func_t cb; /* Chunk callback routine */ - void *udata; /* User data for chunk callback routine */ + H5D_chunk_common_ud_t common; /* Common info for Fixed Array user data (must be first) */ + H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ + hbool_t filtered; /* Whether the chunks are filtered */ + H5D_chunk_cb_func_t cb; /* Chunk callback routine */ + void * udata; /* User data for chunk callback routine */ } H5D_earray_it_ud_t; /* Native extensible array element for chunks w/filters */ typedef struct H5D_earray_filt_elmt_t { - haddr_t addr; /* Address of chunk */ - uint32_t nbytes; /* Size of chunk (in file) */ - uint32_t filter_mask; /* Excluded filters for chunk */ + haddr_t addr; /* Address of chunk */ + uint32_t nbytes; /* Size of chunk (in file) */ + uint32_t filter_mask; /* Excluded filters for chunk */ } H5D_earray_filt_elmt_t; - /********************/ /* Local Prototypes */ /********************/ @@ -91,120 +90,107 @@ static int H5D__earray_idx_iterate_cb(hsize_t idx, const void *_elmt, void *_uda static int H5D__earray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); /* Extensible array class callbacks for chunks w/o filters */ -static void *H5D__earray_crt_context(void *udata); +static void * H5D__earray_crt_context(void *udata); static herr_t H5D__earray_dst_context(void *ctx); static herr_t H5D__earray_fill(void *nat_blk, size_t nelmts); -static herr_t H5D__earray_encode(void *raw, const void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__earray_decode(const void *raw, void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__earray_debug(FILE *stream, int indent, int fwidth, - hsize_t idx, const void *elmt); -static void *H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr); +static herr_t H5D__earray_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); +static herr_t H5D__earray_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); +static herr_t H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); +static void * H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr); static herr_t H5D__earray_dst_dbg_context(void *dbg_ctx); /* Extensible array class callbacks for chunks w/filters */ /* (some shared with callbacks for chunks w/o filters) */ static herr_t H5D__earray_filt_fill(void *nat_blk, size_t nelmts); -static herr_t H5D__earray_filt_encode(void *raw, const void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__earray_filt_decode(const void *raw, void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, - hsize_t idx, const void *elmt); +static herr_t H5D__earray_filt_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); +static herr_t H5D__earray_filt_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); +static herr_t H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Chunked layout indexing callbacks */ -static herr_t H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static herr_t H5D__earray_idx_resize(H5O_layout_chunk_t *layout); -static int H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, - FILE *stream); -static herr_t H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static herr_t H5D__earray_idx_resize(H5O_layout_chunk_t *layout); +static int H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst); +static herr_t H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Generic extensible array routines */ static herr_t H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info); static herr_t H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info); - /*********************/ /* Package Variables */ /*********************/ /* Extensible array indexed chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_EARRAY[1] = {{ - TRUE, /* Extensible array indices support SWMR access */ - H5D__earray_idx_init, /* init */ - H5D__earray_idx_create, /* create */ - H5D__earray_idx_is_space_alloc, /* is_space_alloc */ - H5D__earray_idx_insert, /* insert */ - H5D__earray_idx_get_addr, /* get_addr */ - H5D__earray_idx_resize, /* resize */ - H5D__earray_idx_iterate, /* iterate */ - H5D__earray_idx_remove, /* remove */ - H5D__earray_idx_delete, /* delete */ - H5D__earray_idx_copy_setup, /* copy_setup */ - H5D__earray_idx_copy_shutdown, /* copy_shutdown */ - H5D__earray_idx_size, /* size */ - H5D__earray_idx_reset, /* reset */ - H5D__earray_idx_dump, /* dump */ - H5D__earray_idx_dest, /* destroy */ - H5D__earray_idx_dest /* close (same as destroy) */ + TRUE, /* Extensible array indices support SWMR access */ + H5D__earray_idx_init, /* init */ + H5D__earray_idx_create, /* create */ + H5D__earray_idx_is_space_alloc, /* is_space_alloc */ + H5D__earray_idx_insert, /* insert */ + H5D__earray_idx_get_addr, /* get_addr */ + H5D__earray_idx_resize, /* resize */ + H5D__earray_idx_iterate, /* iterate */ + H5D__earray_idx_remove, /* remove */ + H5D__earray_idx_delete, /* delete */ + H5D__earray_idx_copy_setup, /* copy_setup */ + H5D__earray_idx_copy_shutdown, /* copy_shutdown */ + H5D__earray_idx_size, /* size */ + H5D__earray_idx_reset, /* reset */ + H5D__earray_idx_dump, /* dump */ + H5D__earray_idx_dest, /* destroy */ + H5D__earray_idx_dest /* close (same as destroy) */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ /* Extensible array class callbacks for dataset chunks w/o filters */ -const H5EA_class_t H5EA_CLS_CHUNK[1]={{ - H5EA_CLS_CHUNK_ID, /* Type of extensible array */ - "Chunk w/o filters", /* Name of extensible array class */ - sizeof(haddr_t), /* Size of native element */ - H5D__earray_crt_context, /* Create context */ - H5D__earray_dst_context, /* Destroy context */ - H5D__earray_fill, /* Fill block of missing elements callback */ - H5D__earray_encode, /* Element encoding callback */ - H5D__earray_decode, /* Element decoding callback */ - H5D__earray_debug, /* Element debugging callback */ +const H5EA_class_t H5EA_CLS_CHUNK[1] = {{ + H5EA_CLS_CHUNK_ID, /* Type of extensible array */ + "Chunk w/o filters", /* Name of extensible array class */ + sizeof(haddr_t), /* Size of native element */ + H5D__earray_crt_context, /* Create context */ + H5D__earray_dst_context, /* Destroy context */ + H5D__earray_fill, /* Fill block of missing elements callback */ + H5D__earray_encode, /* Element encoding callback */ + H5D__earray_decode, /* Element decoding callback */ + H5D__earray_debug, /* Element debugging callback */ H5D__earray_crt_dbg_context, /* Create debugging context */ H5D__earray_dst_dbg_context /* Destroy debugging context */ }}; /* Extensible array class callbacks for dataset chunks w/filters */ -const H5EA_class_t H5EA_CLS_FILT_CHUNK[1]={{ - H5EA_CLS_FILT_CHUNK_ID, /* Type of extensible array */ - "Chunk w/filters", /* Name of extensible array class */ +const H5EA_class_t H5EA_CLS_FILT_CHUNK[1] = {{ + H5EA_CLS_FILT_CHUNK_ID, /* Type of extensible array */ + "Chunk w/filters", /* Name of extensible array class */ sizeof(H5D_earray_filt_elmt_t), /* Size of native element */ - H5D__earray_crt_context, /* Create context */ - H5D__earray_dst_context, /* Destroy context */ - H5D__earray_filt_fill, /* Fill block of missing elements callback */ - H5D__earray_filt_encode, /* Element encoding callback */ - H5D__earray_filt_decode, /* Element decoding callback */ - H5D__earray_filt_debug, /* Element debugging callback */ - H5D__earray_crt_dbg_context, /* Create debugging context */ - H5D__earray_dst_dbg_context /* Destroy debugging context */ + H5D__earray_crt_context, /* Create context */ + H5D__earray_dst_context, /* Destroy context */ + H5D__earray_filt_fill, /* Fill block of missing elements callback */ + H5D__earray_filt_encode, /* Element encoding callback */ + H5D__earray_filt_decode, /* Element decoding callback */ + H5D__earray_filt_debug, /* Element debugging callback */ + H5D__earray_crt_dbg_context, /* Create debugging context */ + H5D__earray_dst_dbg_context /* Destroy debugging context */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -214,8 +200,6 @@ const H5EA_class_t H5EA_CLS_FILT_CHUNK[1]={{ H5FL_DEFINE_STATIC(H5D_earray_ctx_t); H5FL_DEFINE_STATIC(H5D_earray_ctx_ud_t); - - /*------------------------------------------------------------------------- * Function: H5D__earray_crt_context * @@ -232,9 +216,9 @@ H5FL_DEFINE_STATIC(H5D_earray_ctx_ud_t); static void * H5D__earray_crt_context(void *_udata) { - H5D_earray_ctx_t *ctx; /* Extensible array callback context */ + H5D_earray_ctx_t * ctx; /* Extensible array callback context */ H5D_earray_ctx_ud_t *udata = (H5D_earray_ctx_ud_t *)_udata; /* User data for extensible array context */ - void *ret_value = NULL; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -244,8 +228,9 @@ H5D__earray_crt_context(void *_udata) HDassert(udata->chunk_size > 0); /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5D_earray_ctx_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate extensible array client callback context") + if (NULL == (ctx = H5FL_MALLOC(H5D_earray_ctx_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Initialize the context */ ctx->file_addr_len = H5F_SIZEOF_ADDR(udata->f); @@ -254,7 +239,7 @@ H5D__earray_crt_context(void *_udata) * for an extra byte, in case the filter makes the chunk larger. */ ctx->chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)udata->chunk_size) + 8) / 8); - if(ctx->chunk_size_len > 8) + if (ctx->chunk_size_len > 8) ctx->chunk_size_len = 8; /* Set return value */ @@ -264,7 +249,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_dst_context * @@ -281,7 +265,7 @@ done: static herr_t H5D__earray_dst_context(void *_ctx) { - H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ + H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ FUNC_ENTER_STATIC_NOERR @@ -294,7 +278,6 @@ H5D__earray_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_fill * @@ -311,7 +294,7 @@ H5D__earray_dst_context(void *_ctx) static herr_t H5D__earray_fill(void *nat_blk, size_t nelmts) { - haddr_t fill_val = H5D_EARRAY_FILL; /* Value to fill elements with */ + haddr_t fill_val = H5D_EARRAY_FILL; /* Value to fill elements with */ FUNC_ENTER_STATIC_NOERR @@ -324,7 +307,6 @@ H5D__earray_fill(void *nat_blk, size_t nelmts) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_encode * @@ -341,8 +323,8 @@ H5D__earray_fill(void *nat_blk, size_t nelmts) static herr_t H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) { - H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ - const haddr_t *elmt = (const haddr_t *)_elmt; /* Convenience pointer to native elements */ + H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ + const haddr_t * elmt = (const haddr_t *)_elmt; /* Convenience pointer to native elements */ FUNC_ENTER_STATIC_NOERR @@ -353,7 +335,7 @@ H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) HDassert(ctx); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, (uint8_t **)&raw, *elmt); @@ -368,7 +350,6 @@ H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_decode * @@ -385,9 +366,9 @@ H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) static herr_t H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) { - H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ - haddr_t *elmt = (haddr_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ + haddr_t * elmt = (haddr_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t * raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ FUNC_ENTER_STATIC_NOERR @@ -397,7 +378,7 @@ H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) HDassert(nelmts); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, elmt); @@ -412,7 +393,6 @@ H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_debug * @@ -427,10 +407,9 @@ H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, - const void *elmt) +H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) { - char temp_str[128]; /* Temporary string, for formatting */ + char temp_str[128]; /* Temporary string, for formatting */ FUNC_ENTER_STATIC_NOERR @@ -440,13 +419,11 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /* Print element */ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, temp_str, - *(const haddr_t *)elmt); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_filt_fill * @@ -463,7 +440,7 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, static herr_t H5D__earray_filt_fill(void *nat_blk, size_t nelmts) { - H5D_earray_filt_elmt_t fill_val = H5D_EARRAY_FILT_FILL; /* Value to fill elements with */ + H5D_earray_filt_elmt_t fill_val = H5D_EARRAY_FILT_FILL; /* Value to fill elements with */ FUNC_ENTER_STATIC_NOERR @@ -477,7 +454,6 @@ H5D__earray_filt_fill(void *nat_blk, size_t nelmts) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_filt_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_filt_encode * @@ -494,9 +470,10 @@ H5D__earray_filt_fill(void *nat_blk, size_t nelmts) static herr_t H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx) { - H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ - uint8_t *raw = (uint8_t *)_raw; /* Convenience pointer to raw elements */ - const H5D_earray_filt_elmt_t *elmt = (const H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + H5D_earray_ctx_t * ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ + uint8_t * raw = (uint8_t *)_raw; /* Convenience pointer to raw elements */ + const H5D_earray_filt_elmt_t *elmt = + (const H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ FUNC_ENTER_STATIC_NOERR @@ -507,7 +484,7 @@ H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx HDassert(ctx); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); @@ -524,7 +501,6 @@ H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_filt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_filt_decode * @@ -541,8 +517,9 @@ H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx static herr_t H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) { - H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ - H5D_earray_filt_elmt_t *elmt = (H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + H5D_earray_ctx_t * ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ + H5D_earray_filt_elmt_t *elmt = + (H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ FUNC_ENTER_STATIC_NOERR @@ -553,7 +530,7 @@ H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx HDassert(nelmts); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); @@ -570,7 +547,6 @@ H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_filt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_filt_debug * @@ -585,11 +561,11 @@ H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx *------------------------------------------------------------------------- */ static herr_t -H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, - const void *_elmt) +H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *_elmt) { - const H5D_earray_filt_elmt_t *elmt = (const H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ - char temp_str[128]; /* Temporary string, for formatting */ + const H5D_earray_filt_elmt_t *elmt = + (const H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + char temp_str[128]; /* Temporary string, for formatting */ FUNC_ENTER_STATIC_NOERR @@ -599,13 +575,12 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /* Print element */ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); - HDfprintf(stream, "%*s%-*s {%a, %u, %0x}\n", indent, "", fwidth, temp_str, - elmt->addr, elmt->nbytes, elmt->filter_mask); + HDfprintf(stream, "%*s%-*s {%a, %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr, elmt->nbytes, + elmt->filter_mask); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_filt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_crt_dbg_context * @@ -622,11 +597,11 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, static void * H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) { - H5D_earray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ - H5O_loc_t obj_loc; /* Pointer to an object's location */ - hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ - H5O_layout_t layout; /* Layout message */ - void *ret_value = NULL; /* Return value */ + H5D_earray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ + H5O_loc_t obj_loc; /* Pointer to an object's location */ + hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ + H5O_layout_t layout; /* Layout message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -635,8 +610,9 @@ H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) HDassert(H5F_addr_defined(obj_addr)); /* Allocate context for debugging callback */ - if(NULL == (dbg_ctx = H5FL_MALLOC(H5D_earray_ctx_ud_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate extensible array client callback context") + if (NULL == (dbg_ctx = H5FL_MALLOC(H5D_earray_ctx_ud_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Set up the object header location info */ H5O_loc_reset(&obj_loc); @@ -644,20 +620,20 @@ H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) obj_loc.addr = obj_addr; /* Open the object header where the layout message resides */ - if(H5O_open(&obj_loc) < 0) + if (H5O_open(&obj_loc) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "can't open object header") obj_opened = TRUE; /* Read the layout message */ - if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout)) + if (NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info") /* close the object header */ - if(H5O_close(&obj_loc, NULL) < 0) + if (H5O_close(&obj_loc, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") /* Create user data */ - dbg_ctx->f = f; + dbg_ctx->f = f; dbg_ctx->chunk_size = layout.u.chunk.size; /* Set return value */ @@ -665,21 +641,20 @@ H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) done: /* Cleanup on error */ - if(ret_value == NULL) { + if (ret_value == NULL) { /* Release context structure */ - if(dbg_ctx) + if (dbg_ctx) dbg_ctx = H5FL_FREE(H5D_earray_ctx_ud_t, dbg_ctx); /* Close object header */ - if(obj_opened) - if(H5O_close(&obj_loc, NULL) < 0) + if (obj_opened) + if (H5O_close(&obj_loc, NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_crt_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_dst_dbg_context * @@ -696,7 +671,8 @@ done: static herr_t H5D__earray_dst_dbg_context(void *_dbg_ctx) { - H5D_earray_ctx_ud_t *dbg_ctx = (H5D_earray_ctx_ud_t *)_dbg_ctx; /* Context for extensible array callback */ + H5D_earray_ctx_ud_t *dbg_ctx = + (H5D_earray_ctx_ud_t *)_dbg_ctx; /* Context for extensible array callback */ FUNC_ENTER_STATIC_NOERR @@ -709,7 +685,6 @@ H5D__earray_dst_dbg_context(void *_dbg_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_dst_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_depend * @@ -727,10 +702,10 @@ H5D__earray_dst_dbg_context(void *_dbg_ctx) static herr_t H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5O_loc_t oloc; /* Temporary object header location for dataset */ + H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -752,26 +727,26 @@ H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info) oloc.addr = idx_info->storage->u.earray.dset_ohdr_addr; /* Get header */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Retrieve the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_get_proxy(oh))) + if (NULL == (oh_proxy = H5O_get_proxy(oh))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataset object header proxy") /* Make the extensible array a child flush dependency of the dataset's object header */ - if(H5EA_depend(idx_info->storage->u.earray.ea, oh_proxy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header proxy") + if (H5EA_depend(idx_info->storage->u.earray.ea, oh_proxy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header proxy") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_depend() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_open * @@ -793,8 +768,8 @@ done: static herr_t H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info) { - H5D_earray_ctx_ud_t udata; /* User data for extensible array open call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_earray_ctx_ud_t udata; /* User data for extensible array open call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -810,23 +785,24 @@ H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.earray.ea); /* Set up the user data */ - udata.f = idx_info->f; + udata.f = idx_info->f; udata.chunk_size = idx_info->layout->size; /* Open the extensible array for the chunk index */ - if(NULL == (idx_info->storage->u.earray.ea = H5EA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) + if (NULL == + (idx_info->storage->u.earray.ea = H5EA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open extensible array") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__earray_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__earray_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_open() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_init * @@ -840,15 +816,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, - haddr_t dset_ohdr_addr) +H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, haddr_t dset_ohdr_addr) { - hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Max. size of dataset dimensions */ - int unlim_dim; /* Rank of the dataset's unlimited dimension */ - int sndims; /* Rank of dataspace */ - unsigned ndims; /* Rank of dataspace */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Max. size of dataset dimensions */ + int unlim_dim; /* Rank of the dataset's unlimited dimension */ + int sndims; /* Rank of dataspace */ + unsigned ndims; /* Rank of dataspace */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -862,26 +837,26 @@ H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, HDassert(H5F_addr_defined(dset_ohdr_addr)); /* Get the dim info for dataset */ - if((sndims = H5S_get_simple_extent_dims(space, NULL, max_dims)) < 0) + if ((sndims = H5S_get_simple_extent_dims(space, NULL, max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace dimensions") H5_CHECKED_ASSIGN(ndims, unsigned, sndims, int); /* Find the rank of the unlimited dimension */ unlim_dim = (-1); - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { /* Check for unlimited dimension */ - if(H5S_UNLIMITED == max_dims[u]) { + if (H5S_UNLIMITED == max_dims[u]) { /* Check if we've already found an unlimited dimension */ - if(unlim_dim >= 0) + if (unlim_dim >= 0) HGOTO_ERROR(H5E_DATASET, H5E_ALREADYINIT, FAIL, "already found unlimited dimension") /* Set the unlimited dimension */ unlim_dim = (int)u; } /* end if */ - } /* end for */ + } /* end for */ /* Check if we didn't find an unlimited dimension */ - if(unlim_dim < 0) + if (unlim_dim < 0) HGOTO_ERROR(H5E_DATASET, H5E_UNINITIALIZED, FAIL, "didn't find unlimited dimension") /* Set the unlimited dimension for the layout's future use */ @@ -894,7 +869,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_create * @@ -916,9 +890,9 @@ done: static herr_t H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5EA_create_t cparam; /* Extensible array creation parameters */ - H5D_earray_ctx_ud_t udata; /* User data for extensible array create call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_create_t cparam; /* Extensible array creation parameters */ + H5D_earray_ctx_ud_t udata; /* User data for extensible array create call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -932,21 +906,21 @@ H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.earray.ea); /* General parameters */ - if(idx_info->pline->nused > 0) { - unsigned chunk_size_len; /* Size of encoded chunk size */ + if (idx_info->pline->nused > 0) { + unsigned chunk_size_len; /* Size of encoded chunk size */ /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. */ chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)idx_info->layout->size) + 8) / 8); - if(chunk_size_len > 8) + if (chunk_size_len > 8) chunk_size_len = 8; - cparam.cls = H5EA_CLS_FILT_CHUNK; + cparam.cls = H5EA_CLS_FILT_CHUNK; cparam.raw_elmt_size = (uint8_t)(H5F_SIZEOF_ADDR(idx_info->f) + chunk_size_len + 4); } /* end if */ else { - cparam.cls = H5EA_CLS_CHUNK; + cparam.cls = H5EA_CLS_CHUNK; cparam.raw_elmt_size = (uint8_t)H5F_SIZEOF_ADDR(idx_info->f); } /* end else */ cparam.max_nelmts_bits = idx_info->layout->u.earray.cparam.max_nelmts_bits; @@ -961,27 +935,27 @@ H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(cparam.max_dblk_page_nelmts_bits > 0); /* Set up the user data */ - udata.f = idx_info->f; + udata.f = idx_info->f; udata.chunk_size = idx_info->layout->size; /* Create the extensible array for the chunk index */ - if(NULL == (idx_info->storage->u.earray.ea = H5EA_create(idx_info->f, &cparam, &udata))) + if (NULL == (idx_info->storage->u.earray.ea = H5EA_create(idx_info->f, &cparam, &udata))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create extensible array") /* Get the address of the extensible array in file */ - if(H5EA_get_addr(idx_info->storage->u.earray.ea, &(idx_info->storage->idx_addr)) < 0) + if (H5EA_get_addr(idx_info->storage->u.earray.ea, &(idx_info->storage->idx_addr)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array address") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__earray_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__earray_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_is_space_alloc * @@ -1005,7 +979,6 @@ H5D__earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__earray_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_insert * @@ -1019,10 +992,10 @@ H5D__earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) */ static herr_t H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t H5_ATTR_UNUSED *dset) + const H5D_t H5_ATTR_UNUSED *dset) { - H5EA_t *ea; /* Pointer to extensible array structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_t *ea; /* Pointer to extensible array structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1036,36 +1009,37 @@ H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) { + if (NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") - } else /* Patch the top level file pointer contained in ea if needed */ + } + else /* Patch the top level file pointer contained in ea if needed */ H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "The chunk should have allocated already") - if(udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ + if (udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk index must be less than 2^32") /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_earray_filt_elmt_t elmt; /* Extensible array element */ + if (idx_info->pline->nused > 0) { + H5D_earray_filt_elmt_t elmt; /* Extensible array element */ elmt.addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(elmt.nbytes, uint32_t, udata->chunk_block.length, hsize_t); elmt.filter_mask = udata->filter_mask; /* Set the info for the chunk */ - if(H5EA_set(ea, udata->chunk_idx, &elmt) < 0) + if (H5EA_set(ea, udata->chunk_idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info") } /* end if */ else { /* Set the address for the chunk */ - if(H5EA_set(ea, udata->chunk_idx, &udata->chunk_block.offset) < 0) + if (H5EA_set(ea, udata->chunk_idx, &udata->chunk_block.offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk address") } /* end else */ @@ -1073,7 +1047,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__earray_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_get_addr * @@ -1091,9 +1064,9 @@ done: static herr_t H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - H5EA_t *ea; /* Pointer to extensible array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_t *ea; /* Pointer to extensible array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1107,69 +1080,71 @@ H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HDassert(udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) { + if (NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") - } else /* Patch the top level file pointer contained in ea if needed */ + } + else /* Patch the top level file pointer contained in ea if needed */ H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; /* Check for unlimited dim. not being the slowest-changing dim. */ - if(idx_info->layout->u.earray.unlim_dim > 0) { - hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ + if (idx_info->layout->u.earray.unlim_dim > 0) { + hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */ unsigned u; /* Compute coordinate offset from scaled offset */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) swizzled_coords[u] = udata->common.scaled[u] * idx_info->layout->dim[u]; H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim); /* Calculate the index of this chunk */ - idx = H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, idx_info->layout->u.earray.swizzled_max_down_chunks); + idx = H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, + idx_info->layout->u.earray.swizzled_max_down_chunks); } /* end if */ else { /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->common.scaled); + idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->common.scaled); } /* end else */ udata->chunk_idx = idx; /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_earray_filt_elmt_t elmt; /* Extensible array element */ + if (idx_info->pline->nused > 0) { + H5D_earray_filt_elmt_t elmt; /* Extensible array element */ /* Get the information for the chunk */ - if(H5EA_get(ea, idx, &elmt) < 0) + if (H5EA_get(ea, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") /* Set the info for the chunk */ udata->chunk_block.offset = elmt.addr; udata->chunk_block.length = elmt.nbytes; - udata->filter_mask = elmt.filter_mask; + udata->filter_mask = elmt.filter_mask; } /* end if */ else { /* Get the address for the chunk */ - if(H5EA_get(ea, idx, &udata->chunk_block.offset) < 0) + if (H5EA_get(ea, idx, &udata->chunk_block.offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Update the other (constant) information for the chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) udata->chunk_block.length = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__earray_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_resize * @@ -1186,7 +1161,7 @@ done: static herr_t H5D__earray_idx_resize(H5O_layout_chunk_t *layout) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1194,9 +1169,10 @@ H5D__earray_idx_resize(H5O_layout_chunk_t *layout) HDassert(layout); /* "Swizzle" constant dimensions for this dataset */ - if(layout->u.earray.unlim_dim > 0) { - hsize_t swizzled_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of # of chunks in each dimension */ - hsize_t swizzled_max_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of max # of chunks in each dimension */ + if (layout->u.earray.unlim_dim > 0) { + hsize_t swizzled_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of # of chunks in each dimension */ + hsize_t + swizzled_max_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of max # of chunks in each dimension */ /* Get the swizzled chunk dimensions */ H5MM_memcpy(layout->u.earray.swizzled_dim, layout->dim, (layout->ndims - 1) * sizeof(layout->dim[0])); @@ -1207,15 +1183,17 @@ H5D__earray_idx_resize(H5O_layout_chunk_t *layout) H5VM_swizzle_coords(hsize_t, swizzled_chunks, layout->u.earray.unlim_dim); /* Get the swizzled "down" sizes for each dimension */ - if(H5VM_array_down((layout->ndims - 1), swizzled_chunks, layout->u.earray.swizzled_down_chunks) < 0) + if (H5VM_array_down((layout->ndims - 1), swizzled_chunks, layout->u.earray.swizzled_down_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute swizzled 'down' chunk size value") /* Get the swizzled max number of chunks in each dimension */ - H5MM_memcpy(swizzled_max_chunks, layout->max_chunks, (layout->ndims - 1) * sizeof(swizzled_max_chunks[0])); + H5MM_memcpy(swizzled_max_chunks, layout->max_chunks, + (layout->ndims - 1) * sizeof(swizzled_max_chunks[0])); H5VM_swizzle_coords(hsize_t, swizzled_max_chunks, layout->u.earray.unlim_dim); /* Get the swizzled max "down" sizes for each dimension */ - if(H5VM_array_down((layout->ndims - 1), swizzled_max_chunks, layout->u.earray.swizzled_max_down_chunks) < 0) + if (H5VM_array_down((layout->ndims - 1), swizzled_max_chunks, + layout->u.earray.swizzled_max_down_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute swizzled 'down' chunk size value") } /* end if */ @@ -1223,7 +1201,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_resize() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_iterate_cb * @@ -1238,39 +1215,39 @@ done: static int H5D__earray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void *_udata) { - H5D_earray_it_ud_t *udata = (H5D_earray_it_ud_t *)_udata; /* User data */ - unsigned ndims; /* Rank of chunk */ - int curr_dim; /* Current dimension */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_earray_it_ud_t *udata = (H5D_earray_it_ud_t *)_udata; /* User data */ + unsigned ndims; /* Rank of chunk */ + int curr_dim; /* Current dimension */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Compose generic chunk record for callback */ - if(udata->filtered) { + if (udata->filtered) { const H5D_earray_filt_elmt_t *filt_elmt = (const H5D_earray_filt_elmt_t *)_elmt; - udata->chunk_rec.chunk_addr = filt_elmt->addr; - udata->chunk_rec.nbytes = filt_elmt->nbytes; + udata->chunk_rec.chunk_addr = filt_elmt->addr; + udata->chunk_rec.nbytes = filt_elmt->nbytes; udata->chunk_rec.filter_mask = filt_elmt->filter_mask; } /* end if */ else udata->chunk_rec.chunk_addr = *(const haddr_t *)_elmt; /* Make "generic chunk" callback */ - if(H5F_addr_defined(udata->chunk_rec.chunk_addr)) - if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) + if (H5F_addr_defined(udata->chunk_rec.chunk_addr)) + if ((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); /* Update coordinates of chunk in dataset */ ndims = udata->common.layout->ndims - 1; HDassert(ndims > 0); curr_dim = (int)(ndims - 1); - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Increment coordinate in current dimension */ udata->chunk_rec.scaled[curr_dim]++; /* Check if we went off the end of the current dimension */ - if(udata->chunk_rec.scaled[curr_dim] >= udata->common.layout->max_chunks[curr_dim]) { + if (udata->chunk_rec.scaled[curr_dim] >= udata->common.layout->max_chunks[curr_dim]) { /* Reset coordinate & move to next faster dimension */ udata->chunk_rec.scaled[curr_dim] = 0; curr_dim--; @@ -1282,7 +1259,6 @@ H5D__earray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * FUNC_LEAVE_NOAPI(ret_value) } /* H5D__earray_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_iterate * @@ -1301,12 +1277,11 @@ H5D__earray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * *------------------------------------------------------------------------- */ static int -H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5EA_t *ea; /* Pointer to extensible array structure */ - H5EA_stat_t ea_stat; /* Extensible array statistics */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5EA_t * ea; /* Pointer to extensible array structure */ + H5EA_stat_t ea_stat; /* Extensible array statistics */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1321,38 +1296,39 @@ H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) { + if (NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") - } else /* Patch the top level file pointer contained in ea if needed */ + } + else /* Patch the top level file pointer contained in ea if needed */ H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; /* Get the extensible array statistics */ - if(H5EA_get_stats(ea, &ea_stat) < 0) + if (H5EA_get_stats(ea, &ea_stat) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array statistics") - if(ea_stat.stored.max_idx_set > 0) { - H5D_earray_it_ud_t udata; /* User data for iteration callback */ + if (ea_stat.stored.max_idx_set > 0) { + H5D_earray_it_ud_t udata; /* User data for iteration callback */ /* Initialize userdata */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = idx_info->layout; + udata.common.layout = idx_info->layout; udata.common.storage = idx_info->storage; HDmemset(&udata.chunk_rec, 0, sizeof(udata.chunk_rec)); udata.filtered = (idx_info->pline->nused > 0); - if(!udata.filtered) { - udata.chunk_rec.nbytes = idx_info->layout->size; + if (!udata.filtered) { + udata.chunk_rec.nbytes = idx_info->layout->size; udata.chunk_rec.filter_mask = 0; } /* end if */ - udata.cb = chunk_cb; + udata.cb = chunk_cb; udata.udata = chunk_udata; /* Iterate over the extensible array elements */ - if((ret_value = H5EA_iterate(ea, H5D__earray_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5EA_iterate(ea, H5D__earray_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over fixed array chunk index"); } /* end if */ @@ -1360,7 +1336,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_remove * @@ -1376,9 +1351,9 @@ done: static herr_t H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5EA_t *ea; /* Pointer to extensible array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_t *ea; /* Pointer to extensible array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1392,78 +1367,81 @@ H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t HDassert(udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) { + if (NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") - } else /* Patch the top level file pointer contained in ea if needed */ - if(H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch earray file pointer") + } + else /* Patch the top level file pointer contained in ea if needed */ + if (H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch earray file pointer") /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; /* Check for unlimited dim. not being the slowest-changing dim. */ - if(idx_info->layout->u.earray.unlim_dim > 0) { - hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ + if (idx_info->layout->u.earray.unlim_dim > 0) { + hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */ unsigned u; /* Compute coordinate offset from scaled offset */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) swizzled_coords[u] = udata->scaled[u] * idx_info->layout->dim[u]; H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim); /* Calculate the index of this chunk */ - idx = H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, idx_info->layout->u.earray.swizzled_max_down_chunks); + idx = H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, + idx_info->layout->u.earray.swizzled_max_down_chunks); } /* end if */ else { /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->scaled); + idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->scaled); } /* end else */ /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_earray_filt_elmt_t elmt; /* Extensible array element */ + if (idx_info->pline->nused > 0) { + H5D_earray_filt_elmt_t elmt; /* Extensible array element */ /* Get the info about the chunk for the index */ - if(H5EA_get(ea, idx, &elmt) < 0) + if (H5EA_get(ea, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") /* Remove raw data chunk from file if not doing SWMR writes */ HDassert(H5F_addr_defined(elmt.addr)); - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { - H5_CHECK_OVERFLOW(elmt.nbytes, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, elmt.addr, (hsize_t)elmt.nbytes) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + H5_CHECK_OVERFLOW(elmt.nbytes, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, elmt.addr, (hsize_t)elmt.nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") } /* end if */ /* Reset the info about the chunk for the index */ - elmt.addr = HADDR_UNDEF; - elmt.nbytes = 0; + elmt.addr = HADDR_UNDEF; + elmt.nbytes = 0; elmt.filter_mask = 0; - if(H5EA_set(ea, idx, &elmt) < 0) + if (H5EA_set(ea, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to reset chunk info") } /* end if */ else { - haddr_t addr = HADDR_UNDEF; /* Chunk address */ + haddr_t addr = HADDR_UNDEF; /* Chunk address */ /* Get the address of the chunk for the index */ - if(H5EA_get(ea, idx, &addr) < 0) + if (H5EA_get(ea, idx, &addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Remove raw data chunk from file if not doing SWMR writes */ HDassert(H5F_addr_defined(addr)); - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { - H5_CHECK_OVERFLOW(idx_info->layout->size, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, addr, (hsize_t)idx_info->layout->size) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + H5_CHECK_OVERFLOW(idx_info->layout->size, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, addr, (hsize_t)idx_info->layout->size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") } /* end if */ /* Reset the address of the chunk for the index */ addr = HADDR_UNDEF; - if(H5EA_set(ea, idx, &addr) < 0) + if (H5EA_set(ea, idx, &addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to reset chunk address") } /* end else */ @@ -1471,7 +1449,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__earray_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_delete_cb * @@ -1488,8 +1465,8 @@ done: static int H5D__earray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1500,15 +1477,14 @@ H5D__earray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(f); /* Remove raw data chunk from file */ - H5_CHECK_OVERFLOW(chunk_rec->nbytes, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, chunk_rec->chunk_addr, (hsize_t)chunk_rec->nbytes) < 0) + H5_CHECK_OVERFLOW(chunk_rec->nbytes, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(f, H5FD_MEM_DRAW, chunk_rec->chunk_addr, (hsize_t)chunk_rec->nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_delete_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_delete * @@ -1530,7 +1506,7 @@ done: static herr_t H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1542,24 +1518,24 @@ H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { + if (H5F_addr_defined(idx_info->storage->idx_addr)) { H5D_earray_ctx_ud_t ctx_udata; /* User data for extensible array open call */ /* Iterate over the chunk addresses in the extensible array, deleting each chunk */ - if(H5D__earray_idx_iterate(idx_info, H5D__earray_idx_delete_cb, idx_info->f) < 0) + if (H5D__earray_idx_iterate(idx_info, H5D__earray_idx_delete_cb, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk addresses") /* Close extensible array */ - if(H5EA_close(idx_info->storage->u.earray.ea) < 0) + if (H5EA_close(idx_info->storage->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") idx_info->storage->u.earray.ea = NULL; /* Set up the context user data */ - ctx_udata.f = idx_info->f; + ctx_udata.f = idx_info->f; ctx_udata.chunk_size = idx_info->layout->size; /* Delete extensible array */ - if(H5EA_delete(idx_info->f, idx_info->storage->idx_addr, &ctx_udata) < 0) + if (H5EA_delete(idx_info->f, idx_info->storage->idx_addr, &ctx_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk extensible array") idx_info->storage->idx_addr = HADDR_UNDEF; } /* end if */ @@ -1570,7 +1546,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_copy_setup * @@ -1584,10 +1559,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1605,16 +1579,16 @@ H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Check if the source extensible array is open yet */ - if(NULL == idx_info_src->storage->u.earray.ea) + if (NULL == idx_info_src->storage->u.earray.ea) /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info_src) < 0) + if (H5D__earray_idx_open(idx_info_src) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create the extensible array that describes chunked storage in the dest. file */ - if(H5D__earray_idx_create(idx_info_dst) < 0) + if (H5D__earray_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1625,7 +1599,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_copy_shutdown * @@ -1639,10 +1612,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1653,10 +1625,10 @@ H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst->u.earray.ea); /* Close extensible arrays */ - if(H5EA_close(storage_src->u.earray.ea) < 0) + if (H5EA_close(storage_src->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") storage_src->u.earray.ea = NULL; - if(H5EA_close(storage_dst->u.earray.ea) < 0) + if (H5EA_close(storage_dst->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") storage_dst->u.earray.ea = NULL; @@ -1664,7 +1636,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_size * @@ -1681,9 +1652,9 @@ done: static herr_t H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5EA_t *ea; /* Pointer to extensible array structure */ - H5EA_stat_t ea_stat; /* Extensible array statistics */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_t * ea; /* Pointer to extensible array structure */ + H5EA_stat_t ea_stat; /* Extensible array statistics */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1697,23 +1668,23 @@ H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) HDassert(index_size); /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; /* Get the extensible array statistics */ - if(H5EA_get_stats(ea, &ea_stat) < 0) + if (H5EA_get_stats(ea, &ea_stat) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array statistics") /* Set the size of the extensible array */ - *index_size = ea_stat.computed.hdr_size + ea_stat.computed.index_blk_size - + ea_stat.stored.super_blk_size + ea_stat.stored.data_blk_size; + *index_size = ea_stat.computed.hdr_size + ea_stat.computed.index_blk_size + + ea_stat.stored.super_blk_size + ea_stat.stored.data_blk_size; done: - if(idx_info->storage->u.earray.ea) { - if(H5EA_close(idx_info->storage->u.earray.ea) < 0) + if (idx_info->storage->u.earray.ea) { + if (H5EA_close(idx_info->storage->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") idx_info->storage->u.earray.ea = NULL; } /* end if */ @@ -1721,7 +1692,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_reset * @@ -1743,8 +1713,8 @@ H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) { - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) { + storage->idx_addr = HADDR_UNDEF; storage->u.earray.dset_ohdr_addr = HADDR_UNDEF; } /* end if */ storage->u.earray.ea = NULL; @@ -1752,7 +1722,6 @@ H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_dump * @@ -1779,7 +1748,6 @@ H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_dest * @@ -1795,7 +1763,7 @@ H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1805,14 +1773,14 @@ H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the extensible array is open */ - if(idx_info->storage->u.earray.ea) { + if (idx_info->storage->u.earray.ea) { /* Patch the top level file pointer contained in ea if needed */ - if(H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f) < 0) + if (H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch earray file pointer") /* Close extensible array */ - if(H5EA_close(idx_info->storage->u.earray.ea) < 0) + if (H5EA_close(idx_info->storage->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") idx_info->storage->u.earray.ea = NULL; } /* end if */ @@ -1820,4 +1788,3 @@ H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_dest() */ - diff --git a/src/H5Defl.c b/src/H5Defl.c index 91caa61..f4327e7 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -20,99 +20,77 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Callback info for readvv operation */ typedef struct H5D_efl_readvv_ud_t { - const H5O_efl_t *efl; /* Pointer to efl info */ - const H5D_t *dset; /* The dataset */ - unsigned char *rbuf; /* Read buffer */ + const H5O_efl_t *efl; /* Pointer to efl info */ + const H5D_t * dset; /* The dataset */ + unsigned char * rbuf; /* Read buffer */ } H5D_efl_readvv_ud_t; /* Callback info for writevv operation */ typedef struct H5D_efl_writevv_ud_t { - const H5O_efl_t *efl; /* Pointer to efl info */ - const H5D_t *dset; /* The dataset */ - const unsigned char *wbuf; /* Write buffer */ + const H5O_efl_t * efl; /* Pointer to efl info */ + const H5D_t * dset; /* The dataset */ + const unsigned char *wbuf; /* Write buffer */ } H5D_efl_writevv_ud_t; - /********************/ /* Local Prototypes */ /********************/ /* Layout operation callbacks */ static herr_t H5D__efl_construct(H5F_t *f, H5D_t *dset); -static herr_t H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *cm); -static ssize_t H5D__efl_readvv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); -static ssize_t H5D__efl_writevv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); +static herr_t H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *cm); +static ssize_t H5D__efl_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); +static ssize_t H5D__efl_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); /* Helper routines */ -static herr_t H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, - uint8_t *buf); +static herr_t H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, uint8_t *buf); static herr_t H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, - const uint8_t *buf); - + const uint8_t *buf); /*********************/ /* Package Variables */ /*********************/ /* External File List (EFL) storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ - H5D__efl_construct, - NULL, - H5D__efl_is_space_alloc, - NULL, - H5D__efl_io_init, - H5D__contig_read, - H5D__contig_write, +const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{H5D__efl_construct, NULL, H5D__efl_is_space_alloc, NULL, + H5D__efl_io_init, H5D__contig_read, H5D__contig_write, #ifdef H5_HAVE_PARALLEL - NULL, - NULL, + NULL, NULL, #endif /* H5_HAVE_PARALLEL */ - H5D__efl_readvv, - H5D__efl_writevv, - NULL, - NULL, - NULL -}}; - + H5D__efl_readvv, H5D__efl_writevv, NULL, NULL, NULL}}; /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5D__efl_construct * @@ -128,13 +106,13 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ static herr_t H5D__efl_construct(H5F_t *f, H5D_t *dset) { - size_t dt_size; /* Size of datatype */ - hssize_t stmp_size; /* Temporary holder for raw data size */ - hsize_t tmp_size; /* Temporary holder for raw data size */ - hsize_t max_points; /* Maximum elements */ - hsize_t max_storage; /* Maximum storage size */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t dt_size; /* Size of datatype */ + hssize_t stmp_size; /* Temporary holder for raw data size */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + hsize_t max_points; /* Maximum elements */ + hsize_t max_storage; /* Maximum storage size */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -149,24 +127,24 @@ H5D__efl_construct(H5F_t *f, H5D_t *dset) */ /* Check for invalid dataset dimensions */ - for(u = 1; u < dset->shared->ndims; u++) - if(dset->shared->max_dims[u] > dset->shared->curr_dims[u]) + for (u = 1; u < dset->shared->ndims; u++) + if (dset->shared->max_dims[u] > dset->shared->curr_dims[u]) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "only the first dimension can be extendible") /* Retrieve the size of the dataset's datatype */ - if(0 == (dt_size = H5T_get_size(dset->shared->type))) + if (0 == (dt_size = H5T_get_size(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size") /* Check for storage overflows */ - max_points = H5S_get_npoints_max(dset->shared->space); + max_points = H5S_get_npoints_max(dset->shared->space); max_storage = H5O_efl_total_size(&dset->shared->dcpl_cache.efl); - if(H5S_UNLIMITED == max_points) { - if(H5O_EFL_UNLIMITED != max_storage) + if (H5S_UNLIMITED == max_points) { + if (H5O_EFL_UNLIMITED != max_storage) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unlimited dataspace but finite storage") } /* end if */ - else if((max_points * dt_size) < max_points) + else if ((max_points * dt_size) < max_points) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace * type size overflowed") - else if((max_points * dt_size) > max_storage) + else if ((max_points * dt_size) > max_storage) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace size exceeds external storage size") /* Compute the total size of dataset */ @@ -182,7 +160,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_construct() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_is_space_alloc * @@ -207,7 +184,6 @@ H5D__efl_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) FUNC_LEAVE_NOAPI(TRUE) } /* end H5D__efl_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_io_init * @@ -222,8 +198,8 @@ H5D__efl_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) */ static herr_t H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *cm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR @@ -232,7 +208,6 @@ H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__efl_io_init() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_read * @@ -251,17 +226,17 @@ H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNU static herr_t H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, uint8_t *buf) { - int fd = -1; - size_t to_read; + int fd = -1; + size_t to_read; #ifndef NDEBUG - hsize_t tempto_read; + hsize_t tempto_read; #endif /* NDEBUG */ - hsize_t skip = 0; - haddr_t cur; - ssize_t n; - size_t u; /* Local index variable */ - char *full_name = NULL; /* File name with prefix */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t skip = 0; + haddr_t cur; + ssize_t n; + size_t u; /* Local index variable */ + char * full_name = NULL; /* File name with prefix */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -272,8 +247,8 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size HDassert(buf || 0 == size); /* Find the first efl member from which to read */ - for (u=0, cur=0; unused; u++) { - if(H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { + for (u = 0, cur = 0; u < efl->nused; u++) { + if (H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { skip = addr - cur; break; } /* end if */ @@ -281,28 +256,28 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size } /* end for */ /* Read the data */ - while(size) { + while (size) { HDassert(buf); - if(u >= efl->nused) + if (u >= efl->nused) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file") - if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) + if (H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) + if (H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - if((fd = HDopen(full_name, O_RDONLY)) < 0) + if ((fd = HDopen(full_name, O_RDONLY)) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") - if(HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) + if (HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) HGOTO_ERROR(H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") #ifndef NDEBUG - tempto_read = MIN((size_t)(efl->slot[u].size-skip), (hsize_t)size); + tempto_read = MIN((size_t)(efl->slot[u].size - skip), (hsize_t)size); H5_CHECK_OVERFLOW(tempto_read, hsize_t, size_t); to_read = (size_t)tempto_read; -#else /* NDEBUG */ - to_read = MIN((size_t)(efl->slot[u].size - skip), (hsize_t)size); +#else /* NDEBUG */ + to_read = MIN((size_t)(efl->slot[u].size - skip), (hsize_t)size); #endif /* NDEBUG */ - if((n = HDread(fd, buf, to_read)) < 0) + if ((n = HDread(fd, buf, to_read)) < 0) HGOTO_ERROR(H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file") - else if((size_t)n < to_read) + else if ((size_t)n < to_read) HDmemset(buf + n, 0, to_read - (size_t)n); full_name = (char *)H5MM_xfree(full_name); HDclose(fd); @@ -314,15 +289,14 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size } /* end while */ done: - if(full_name) + if (full_name) full_name = (char *)H5MM_xfree(full_name); - if(fd >= 0) + if (fd >= 0) HDclose(fd); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_read() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_write * @@ -344,16 +318,16 @@ done: static herr_t H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, const uint8_t *buf) { - int fd = -1; - size_t to_write; + int fd = -1; + size_t to_write; #ifndef NDEBUG - hsize_t tempto_write; + hsize_t tempto_write; #endif /* NDEBUG */ - haddr_t cur; - hsize_t skip = 0; - size_t u; /* Local index variable */ - char *full_name = NULL; /* File name with prefix */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t cur; + hsize_t skip = 0; + size_t u; /* Local index variable */ + char * full_name = NULL; /* File name with prefix */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -364,8 +338,8 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz HDassert(buf || 0 == size); /* Find the first efl member in which to write */ - for(u = 0, cur = 0; u < efl->nused; u++) { - if(H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { + for (u = 0, cur = 0; u < efl->nused; u++) { + if (H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { skip = addr - cur; break; } /* end if */ @@ -373,33 +347,33 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz } /* end for */ /* Write the data */ - while(size) { + while (size) { HDassert(buf); - if(u >= efl->nused) + if (u >= efl->nused) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file") - if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) + if (H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) + if (H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - if((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_CREATE_MODE_RW)) < 0) { - if(HDaccess(full_name, F_OK) < 0) + if ((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_CREATE_MODE_RW)) < 0) { + if (HDaccess(full_name, F_OK) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist") else HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") - } /* end if */ - if(HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) + } /* end if */ + if (HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) HGOTO_ERROR(H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") #ifndef NDEBUG tempto_write = MIN(efl->slot[u].size - skip, (hsize_t)size); H5_CHECK_OVERFLOW(tempto_write, hsize_t, size_t); to_write = (size_t)tempto_write; -#else /* NDEBUG */ +#else /* NDEBUG */ to_write = MIN((size_t)(efl->slot[u].size - skip), size); #endif /* NDEBUG */ - if((size_t)HDwrite(fd, buf, to_write) != to_write) + if ((size_t)HDwrite(fd, buf, to_write) != to_write) HGOTO_ERROR(H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file") full_name = (char *)H5MM_xfree(full_name); - HDclose (fd); + HDclose(fd); fd = -1; size -= to_write; buf += to_write; @@ -408,15 +382,14 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz } /* end while */ done: - if(full_name) + if (full_name) full_name = (char *)H5MM_xfree(full_name); - if(fd >= 0) + if (fd >= 0) HDclose(fd); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_write() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_readvv_cb * @@ -432,20 +405,19 @@ done: static herr_t H5D__efl_readvv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_efl_readvv_ud_t *udata = (H5D_efl_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_efl_readvv_ud_t *udata = (H5D_efl_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Read data */ - if(H5D__efl_read(udata->efl, udata->dset, dst_off, len, (udata->rbuf + src_off)) < 0) + if (H5D__efl_read(udata->efl, udata->dset, dst_off, len, (udata->rbuf + src_off)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "EFL read failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_readvv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_readvv * @@ -462,12 +434,12 @@ done: *------------------------------------------------------------------------- */ static ssize_t -H5D__efl_readvv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +H5D__efl_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_efl_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ + H5D_efl_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -485,21 +457,19 @@ H5D__efl_readvv(const H5D_io_info_t *io_info, HDassert(mem_off_arr); /* Set up user data for H5VM_opvv() */ - udata.efl = &(io_info->store->efl); + udata.efl = &(io_info->store->efl); udata.dset = io_info->dset; udata.rbuf = (unsigned char *)io_info->u.rbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__efl_readvv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__efl_readvv_cb, &udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized EFL read") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_readvv() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_writevv_cb * @@ -515,20 +485,19 @@ done: static herr_t H5D__efl_writevv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_efl_writevv_ud_t *udata = (H5D_efl_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_efl_writevv_ud_t *udata = (H5D_efl_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Write data */ - if(H5D__efl_write(udata->efl, udata->dset, dst_off, len, (udata->wbuf + src_off)) < 0) + if (H5D__efl_write(udata->efl, udata->dset, dst_off, len, (udata->wbuf + src_off)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "EFL write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_writevv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_writevv * @@ -545,12 +514,12 @@ done: *------------------------------------------------------------------------- */ static ssize_t -H5D__efl_writevv(const H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +H5D__efl_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, + size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_efl_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ + H5D_efl_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -568,20 +537,18 @@ H5D__efl_writevv(const H5D_io_info_t *io_info, HDassert(mem_off_arr); /* Set up user data for H5VM_opvv() */ - udata.efl = &(io_info->store->efl); + udata.efl = &(io_info->store->efl); udata.dset = io_info->dset; udata.wbuf = (const unsigned char *)io_info->u.wbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__efl_writevv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__efl_writevv_cb, &udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized EFL write") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_writevv() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_bh_info * @@ -598,7 +565,7 @@ done: herr_t H5D__efl_bh_info(H5F_t *f, H5O_efl_t *efl, hsize_t *heap_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -609,7 +576,7 @@ H5D__efl_bh_info(H5F_t *f, H5O_efl_t *efl, hsize_t *heap_size) HDassert(heap_size); /* Get the size of the local heap for EFL's file list */ - if(H5HL_heapsize(f, efl->heap_addr, heap_size) < 0) + if (H5HL_heapsize(f, efl->heap_addr, heap_size) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, FAIL, "unable to retrieve local heap info") done: diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index 122fbd1..290ede6 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -24,29 +24,29 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FAprivate.h" /* Fixed arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FAprivate.h" /* Fixed arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Value to fill unset array elements with */ -#define H5D_FARRAY_FILL HADDR_UNDEF -#define H5D_FARRAY_FILT_FILL {HADDR_UNDEF, 0, 0} - +#define H5D_FARRAY_FILL HADDR_UNDEF +#define H5D_FARRAY_FILT_FILL \ + { \ + HADDR_UNDEF, 0, 0 \ + } /******************/ /* Local Typedefs */ @@ -54,33 +54,32 @@ /* Fixed array create/open user data */ typedef struct H5D_farray_ctx_ud_t { - const H5F_t *f; /* Pointer to file info */ - uint32_t chunk_size; /* Size of chunk (bytes) */ + const H5F_t *f; /* Pointer to file info */ + uint32_t chunk_size; /* Size of chunk (bytes) */ } H5D_farray_ctx_ud_t; /* Fixed array callback context */ typedef struct H5D_farray_ctx_t { - size_t file_addr_len; /* Size of addresses in the file (bytes) */ - size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ + size_t file_addr_len; /* Size of addresses in the file (bytes) */ + size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ } H5D_farray_ctx_t; /* Fixed Array callback info for iteration over chunks */ typedef struct H5D_farray_it_ud_t { - H5D_chunk_common_ud_t common; /* Common info for Fixed Array user data (must be first) */ - H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ - hbool_t filtered; /* Whether the chunks are filtered */ - H5D_chunk_cb_func_t cb; /* Chunk callback routine */ - void *udata; /* User data for chunk callback routine */ + H5D_chunk_common_ud_t common; /* Common info for Fixed Array user data (must be first) */ + H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ + hbool_t filtered; /* Whether the chunks are filtered */ + H5D_chunk_cb_func_t cb; /* Chunk callback routine */ + void * udata; /* User data for chunk callback routine */ } H5D_farray_it_ud_t; /* Native fixed array element for chunks w/filters */ typedef struct H5D_farray_filt_elmt_t { - haddr_t addr; /* Address of chunk */ - uint32_t nbytes; /* Size of chunk (in file) */ - uint32_t filter_mask; /* Excluded filters for chunk */ + haddr_t addr; /* Address of chunk */ + uint32_t nbytes; /* Size of chunk (in file) */ + uint32_t filter_mask; /* Excluded filters for chunk */ } H5D_farray_filt_elmt_t; - /********************/ /* Local Prototypes */ /********************/ @@ -90,51 +89,42 @@ static int H5D__farray_idx_iterate_cb(hsize_t idx, const void *_elmt, void *_uda static int H5D__farray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); /* Fixed array class callbacks for chunks w/o filters */ -static void *H5D__farray_crt_context(void *udata); +static void * H5D__farray_crt_context(void *udata); static herr_t H5D__farray_dst_context(void *ctx); static herr_t H5D__farray_fill(void *nat_blk, size_t nelmts); -static herr_t H5D__farray_encode(void *raw, const void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__farray_decode(const void *raw, void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__farray_debug(FILE *stream, int indent, int fwidth, - hsize_t idx, const void *elmt); -static void *H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr); +static herr_t H5D__farray_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); +static herr_t H5D__farray_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); +static herr_t H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); +static void * H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr); static herr_t H5D__farray_dst_dbg_context(void *dbg_ctx); /* Fixed array class callbacks for chunks w/filters */ /* (some shared with callbacks for chunks w/o filters) */ static herr_t H5D__farray_filt_fill(void *nat_blk, size_t nelmts); -static herr_t H5D__farray_filt_encode(void *raw, const void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__farray_filt_decode(const void *raw, void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, - hsize_t idx, const void *elmt); +static herr_t H5D__farray_filt_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); +static herr_t H5D__farray_filt_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); +static herr_t H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Chunked layout indexing callbacks */ -static herr_t H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__farray_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__farray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); -static herr_t H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst); +static herr_t H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__farray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Generic fixed array routines */ static herr_t H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info); @@ -146,63 +136,61 @@ static herr_t H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info); /* Fixed array indexed chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_FARRAY[1] = {{ - TRUE, /* Fixed array indices support SWMR access */ - H5D__farray_idx_init, /* init */ - H5D__farray_idx_create, /* create */ - H5D__farray_idx_is_space_alloc, /* is_space_alloc */ - H5D__farray_idx_insert, /* insert */ - H5D__farray_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__farray_idx_iterate, /* iterate */ - H5D__farray_idx_remove, /* remove */ - H5D__farray_idx_delete, /* delete */ - H5D__farray_idx_copy_setup, /* copy_setup */ - H5D__farray_idx_copy_shutdown, /* copy_shutdown */ - H5D__farray_idx_size, /* size */ - H5D__farray_idx_reset, /* reset */ - H5D__farray_idx_dump, /* dump */ - H5D__farray_idx_dest, /* destroy */ - H5D__farray_idx_dest /* close (same as destroy) */ + TRUE, /* Fixed array indices support SWMR access */ + H5D__farray_idx_init, /* init */ + H5D__farray_idx_create, /* create */ + H5D__farray_idx_is_space_alloc, /* is_space_alloc */ + H5D__farray_idx_insert, /* insert */ + H5D__farray_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__farray_idx_iterate, /* iterate */ + H5D__farray_idx_remove, /* remove */ + H5D__farray_idx_delete, /* delete */ + H5D__farray_idx_copy_setup, /* copy_setup */ + H5D__farray_idx_copy_shutdown, /* copy_shutdown */ + H5D__farray_idx_size, /* size */ + H5D__farray_idx_reset, /* reset */ + H5D__farray_idx_dump, /* dump */ + H5D__farray_idx_dest, /* destroy */ + H5D__farray_idx_dest /* close (same as destroy) */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Fixed array class callbacks for dataset chunks w/o filters */ -const H5FA_class_t H5FA_CLS_CHUNK[1]={{ - H5FA_CLS_CHUNK_ID, /* Type of fixed array */ - "Chunk w/o filters", /* Name of fixed array class */ - sizeof(haddr_t), /* Size of native element */ - H5D__farray_crt_context, /* Create context */ - H5D__farray_dst_context, /* Destroy context */ - H5D__farray_fill, /* Fill block of missing elements callback */ - H5D__farray_encode, /* Element encoding callback */ - H5D__farray_decode, /* Element decoding callback */ - H5D__farray_debug, /* Element debugging callback */ +const H5FA_class_t H5FA_CLS_CHUNK[1] = {{ + H5FA_CLS_CHUNK_ID, /* Type of fixed array */ + "Chunk w/o filters", /* Name of fixed array class */ + sizeof(haddr_t), /* Size of native element */ + H5D__farray_crt_context, /* Create context */ + H5D__farray_dst_context, /* Destroy context */ + H5D__farray_fill, /* Fill block of missing elements callback */ + H5D__farray_encode, /* Element encoding callback */ + H5D__farray_decode, /* Element decoding callback */ + H5D__farray_debug, /* Element debugging callback */ H5D__farray_crt_dbg_context, /* Create debugging context */ - H5D__farray_dst_dbg_context /* Destroy debugging context */ + H5D__farray_dst_dbg_context /* Destroy debugging context */ }}; /* Fixed array class callbacks for dataset chunks w/filters */ -const H5FA_class_t H5FA_CLS_FILT_CHUNK[1]={{ - H5FA_CLS_FILT_CHUNK_ID, /* Type of fixed array */ - "Chunk w/filters", /* Name of fixed array class */ +const H5FA_class_t H5FA_CLS_FILT_CHUNK[1] = {{ + H5FA_CLS_FILT_CHUNK_ID, /* Type of fixed array */ + "Chunk w/filters", /* Name of fixed array class */ sizeof(H5D_farray_filt_elmt_t), /* Size of native element */ - H5D__farray_crt_context, /* Create context */ - H5D__farray_dst_context, /* Destroy context */ - H5D__farray_filt_fill, /* Fill block of missing elements callback */ - H5D__farray_filt_encode, /* Element encoding callback */ - H5D__farray_filt_decode, /* Element decoding callback */ - H5D__farray_filt_debug, /* Element debugging callback */ - H5D__farray_crt_dbg_context, /* Create debugging context */ - H5D__farray_dst_dbg_context /* Destroy debugging context */ + H5D__farray_crt_context, /* Create context */ + H5D__farray_dst_context, /* Destroy context */ + H5D__farray_filt_fill, /* Fill block of missing elements callback */ + H5D__farray_filt_encode, /* Element encoding callback */ + H5D__farray_filt_decode, /* Element decoding callback */ + H5D__farray_filt_debug, /* Element debugging callback */ + H5D__farray_crt_dbg_context, /* Create debugging context */ + H5D__farray_dst_dbg_context /* Destroy debugging context */ }}; /* Declare a free list to manage the H5D_farray_ctx_t struct */ @@ -211,7 +199,6 @@ H5FL_DEFINE_STATIC(H5D_farray_ctx_t); /* Declare a free list to manage the H5D_farray_ctx_ud_t struct */ H5FL_DEFINE_STATIC(H5D_farray_ctx_ud_t); - /*------------------------------------------------------------------------- * Function: H5D__farray_crt_context * @@ -228,9 +215,9 @@ H5FL_DEFINE_STATIC(H5D_farray_ctx_ud_t); static void * H5D__farray_crt_context(void *_udata) { - H5D_farray_ctx_t *ctx; /* Fixed array callback context */ - H5D_farray_ctx_ud_t *udata = (H5D_farray_ctx_ud_t *)_udata; /* User data for fixed array context */ - void *ret_value = NULL; /* Return value */ + H5D_farray_ctx_t * ctx; /* Fixed array callback context */ + H5D_farray_ctx_ud_t *udata = (H5D_farray_ctx_ud_t *)_udata; /* User data for fixed array context */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -240,17 +227,17 @@ H5D__farray_crt_context(void *_udata) HDassert(udata->chunk_size > 0); /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5D_farray_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5D_farray_ctx_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") - /* Initialize the context */ + /* Initialize the context */ ctx->file_addr_len = H5F_SIZEOF_ADDR(udata->f); /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. */ ctx->chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)udata->chunk_size) + 8) / 8); - if(ctx->chunk_size_len > 8) + if (ctx->chunk_size_len > 8) ctx->chunk_size_len = 8; /* Set return value */ @@ -260,7 +247,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_dst_context * @@ -277,7 +263,7 @@ done: static herr_t H5D__farray_dst_context(void *_ctx) { - H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ + H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ FUNC_ENTER_STATIC_NOERR @@ -290,7 +276,6 @@ H5D__farray_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_fill * @@ -307,7 +292,7 @@ H5D__farray_dst_context(void *_ctx) static herr_t H5D__farray_fill(void *nat_blk, size_t nelmts) { - haddr_t fill_val = H5D_FARRAY_FILL; /* Value to fill elements with */ + haddr_t fill_val = H5D_FARRAY_FILL; /* Value to fill elements with */ FUNC_ENTER_STATIC_NOERR @@ -320,7 +305,6 @@ H5D__farray_fill(void *nat_blk, size_t nelmts) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_encode * @@ -337,8 +321,8 @@ H5D__farray_fill(void *nat_blk, size_t nelmts) static herr_t H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) { - H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ - const haddr_t *elmt = (const haddr_t *)_elmt; /* Convenience pointer to native elements */ + H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ + const haddr_t * elmt = (const haddr_t *)_elmt; /* Convenience pointer to native elements */ FUNC_ENTER_STATIC_NOERR @@ -349,7 +333,7 @@ H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) HDassert(ctx); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, (uint8_t **)&raw, *elmt); @@ -364,7 +348,6 @@ H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_decode * @@ -381,9 +364,9 @@ H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) static herr_t H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) { - H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ - haddr_t *elmt = (haddr_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ + haddr_t * elmt = (haddr_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t * raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ FUNC_ENTER_STATIC_NOERR @@ -393,7 +376,7 @@ H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) HDassert(nelmts); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, elmt); @@ -408,7 +391,6 @@ H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_debug * @@ -423,10 +405,9 @@ H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, - const void *elmt) +H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) { - char temp_str[128]; /* Temporary string, for formatting */ + char temp_str[128]; /* Temporary string, for formatting */ FUNC_ENTER_STATIC_NOERR @@ -436,13 +417,11 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /* Print element */ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, temp_str, - *(const haddr_t *)elmt); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_crt_dbg_context * @@ -460,11 +439,11 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, static void * H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) { - H5D_farray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ - H5O_loc_t obj_loc; /* Pointer to an object's location */ - hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ - H5O_layout_t layout; /* Layout message */ - void *ret_value = NULL; /* Return value */ + H5D_farray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ + H5O_loc_t obj_loc; /* Pointer to an object's location */ + hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ + H5O_layout_t layout; /* Layout message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -473,7 +452,7 @@ H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) HDassert(H5F_addr_defined(obj_addr)); /* Allocate context for debugging callback */ - if(NULL == (dbg_ctx = H5FL_MALLOC(H5D_farray_ctx_ud_t))) + if (NULL == (dbg_ctx = H5FL_MALLOC(H5D_farray_ctx_ud_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") /* Set up the object header location info */ @@ -482,20 +461,20 @@ H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) obj_loc.addr = obj_addr; /* Open the object header where the layout message resides */ - if(H5O_open(&obj_loc) < 0) + if (H5O_open(&obj_loc) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "can't open object header") obj_opened = TRUE; /* Read the layout message */ - if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout)) + if (NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info") /* close the object header */ - if(H5O_close(&obj_loc, NULL) < 0) + if (H5O_close(&obj_loc, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") /* Create user data */ - dbg_ctx->f = f; + dbg_ctx->f = f; dbg_ctx->chunk_size = layout.u.chunk.size; /* Set return value */ @@ -503,21 +482,20 @@ H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) done: /* Cleanup on error */ - if(ret_value == NULL) { + if (ret_value == NULL) { /* Release context structure */ - if(dbg_ctx) + if (dbg_ctx) dbg_ctx = H5FL_FREE(H5D_farray_ctx_ud_t, dbg_ctx); /* Close object header */ - if(obj_opened) - if(H5O_close(&obj_loc, NULL) < 0) + if (obj_opened) + if (H5O_close(&obj_loc, NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_crt_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_dst_dbg_context * @@ -548,7 +526,6 @@ H5D__farray_dst_dbg_context(void *_dbg_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_dst_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_filt_fill * @@ -565,7 +542,7 @@ H5D__farray_dst_dbg_context(void *_dbg_ctx) static herr_t H5D__farray_filt_fill(void *nat_blk, size_t nelmts) { - H5D_farray_filt_elmt_t fill_val = H5D_FARRAY_FILT_FILL; /* Value to fill elements with */ + H5D_farray_filt_elmt_t fill_val = H5D_FARRAY_FILT_FILL; /* Value to fill elements with */ FUNC_ENTER_STATIC_NOERR @@ -579,7 +556,6 @@ H5D__farray_filt_fill(void *nat_blk, size_t nelmts) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_filt_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_filt_encode * @@ -596,9 +572,10 @@ H5D__farray_filt_fill(void *nat_blk, size_t nelmts) static herr_t H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx) { - H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ - uint8_t *raw = (uint8_t *)_raw; /* Convenience pointer to raw elements */ - const H5D_farray_filt_elmt_t *elmt = (const H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + H5D_farray_ctx_t * ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ + uint8_t * raw = (uint8_t *)_raw; /* Convenience pointer to raw elements */ + const H5D_farray_filt_elmt_t *elmt = + (const H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ FUNC_ENTER_STATIC_NOERR @@ -609,7 +586,7 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx HDassert(ctx); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); @@ -626,7 +603,6 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_filt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_filt_decode * @@ -643,8 +619,9 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx static herr_t H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) { - H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ - H5D_farray_filt_elmt_t *elmt = (H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + H5D_farray_ctx_t * ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ + H5D_farray_filt_elmt_t *elmt = + (H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ FUNC_ENTER_STATIC_NOERR @@ -655,7 +632,7 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx HDassert(nelmts); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); @@ -672,7 +649,6 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_filt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_filt_debug * @@ -687,11 +663,11 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx *------------------------------------------------------------------------- */ static herr_t -H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, - const void *_elmt) +H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *_elmt) { - const H5D_farray_filt_elmt_t *elmt = (const H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ - char temp_str[128]; /* Temporary string, for formatting */ + const H5D_farray_filt_elmt_t *elmt = + (const H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + char temp_str[128]; /* Temporary string, for formatting */ FUNC_ENTER_STATIC_NOERR @@ -701,13 +677,12 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /* Print element */ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); - HDfprintf(stream, "%*s%-*s {%a, %u, %0x}\n", indent, "", fwidth, temp_str, - elmt->addr, elmt->nbytes, elmt->filter_mask); + HDfprintf(stream, "%*s%-*s {%a, %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr, elmt->nbytes, + elmt->filter_mask); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_filt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_depend * @@ -725,10 +700,10 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, static herr_t H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t oloc; /* Temporary object header location for dataset */ - H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5O_loc_t oloc; /* Temporary object header location for dataset */ + H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -750,26 +725,26 @@ H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info) oloc.addr = idx_info->storage->u.farray.dset_ohdr_addr; /* Get header */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Retrieve the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_get_proxy(oh))) + if (NULL == (oh_proxy = H5O_get_proxy(oh))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataset object header proxy") /* Make the fixed array a child flush dependency of the dataset's object header proxy */ - if(H5FA_depend(idx_info->storage->u.farray.fa, oh_proxy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header proxy") + if (H5FA_depend(idx_info->storage->u.farray.fa, oh_proxy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header proxy") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_depend() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_init * @@ -783,7 +758,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, haddr_t dset_ohdr_addr) +H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, + haddr_t dset_ohdr_addr) { FUNC_ENTER_STATIC_NOERR @@ -797,7 +773,6 @@ H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_open * @@ -815,8 +790,8 @@ H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNU static herr_t H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info) { - H5D_farray_ctx_ud_t udata; /* User data for fixed array open call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_farray_ctx_ud_t udata; /* User data for fixed array open call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -832,23 +807,24 @@ H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.farray.fa); /* Set up the user data */ - udata.f = idx_info->f; + udata.f = idx_info->f; udata.chunk_size = idx_info->layout->size; /* Open the fixed array for the chunk index */ - if(NULL == (idx_info->storage->u.farray.fa = H5FA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) + if (NULL == + (idx_info->storage->u.farray.fa = H5FA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open fixed array") - /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__farray_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + /* Check for SWMR writes to the file */ + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__farray_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_open() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_create * @@ -870,9 +846,9 @@ done: static herr_t H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5FA_create_t cparam; /* Fixed array creation parameters */ - H5D_farray_ctx_ud_t udata; /* User data for fixed array create call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_create_t cparam; /* Fixed array creation parameters */ + H5D_farray_ctx_ud_t udata; /* User data for fixed array create call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -887,21 +863,21 @@ H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->layout->nchunks); /* General parameters */ - if(idx_info->pline->nused > 0) { - unsigned chunk_size_len; /* Size of encoded chunk size */ + if (idx_info->pline->nused > 0) { + unsigned chunk_size_len; /* Size of encoded chunk size */ /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. */ chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)idx_info->layout->size) + 8) / 8); - if(chunk_size_len > 8) + if (chunk_size_len > 8) chunk_size_len = 8; - cparam.cls = H5FA_CLS_FILT_CHUNK; + cparam.cls = H5FA_CLS_FILT_CHUNK; cparam.raw_elmt_size = (uint8_t)(H5F_SIZEOF_ADDR(idx_info->f) + chunk_size_len + 4); } /* end if */ else { - cparam.cls = H5FA_CLS_CHUNK; + cparam.cls = H5FA_CLS_CHUNK; cparam.raw_elmt_size = (uint8_t)H5F_SIZEOF_ADDR(idx_info->f); } /* end else */ cparam.max_dblk_page_nelmts_bits = idx_info->layout->u.farray.cparam.max_dblk_page_nelmts_bits; @@ -909,27 +885,27 @@ H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) cparam.nelmts = idx_info->layout->max_nchunks; /* Set up the user data */ - udata.f = idx_info->f; + udata.f = idx_info->f; udata.chunk_size = idx_info->layout->size; /* Create the fixed array for the chunk index */ - if(NULL == (idx_info->storage->u.farray.fa = H5FA_create(idx_info->f, &cparam, &udata))) + if (NULL == (idx_info->storage->u.farray.fa = H5FA_create(idx_info->f, &cparam, &udata))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create fixed array") /* Get the address of the fixed array in file */ - if(H5FA_get_addr(idx_info->storage->u.farray.fa, &(idx_info->storage->idx_addr)) < 0) + if (H5FA_get_addr(idx_info->storage->u.farray.fa, &(idx_info->storage->idx_addr)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array address") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__farray_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__farray_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_is_space_alloc * @@ -953,7 +929,6 @@ H5D__farray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__farray_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_insert * @@ -967,10 +942,10 @@ H5D__farray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) */ static herr_t H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t H5_ATTR_UNUSED *dset) + const H5D_t H5_ATTR_UNUSED *dset) { - H5FA_t *fa; /* Pointer to fixed array structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -984,36 +959,37 @@ H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) { + if (NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") - } else /* Patch the top level file pointer contained in fa if needed */ + } + else /* Patch the top level file pointer contained in fa if needed */ H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "The chunk should have allocated already") - if(udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ + if (udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk index must be less than 2^32") /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_farray_filt_elmt_t elmt; /* Fixed array element */ + if (idx_info->pline->nused > 0) { + H5D_farray_filt_elmt_t elmt; /* Fixed array element */ elmt.addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(elmt.nbytes, uint32_t, udata->chunk_block.length, hsize_t); elmt.filter_mask = udata->filter_mask; /* Set the info for the chunk */ - if(H5FA_set(fa, udata->chunk_idx, &elmt) < 0) + if (H5FA_set(fa, udata->chunk_idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info") } /* end if */ else { /* Set the address for the chunk */ - if(H5FA_set(fa, udata->chunk_idx, &udata->chunk_block.offset) < 0) + if (H5FA_set(fa, udata->chunk_idx, &udata->chunk_block.offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk address") } /* end else */ @@ -1021,7 +997,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__farray_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_get_addr * @@ -1039,9 +1014,9 @@ done: static herr_t H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - H5FA_t *fa; /* Pointer to fixed array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1055,52 +1030,53 @@ H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HDassert(udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) { + if (NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") - } else /* Patch the top level file pointer contained in fa if needed */ + } + else /* Patch the top level file pointer contained in fa if needed */ H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->common.scaled); + idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->common.scaled); udata->chunk_idx = idx; /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_farray_filt_elmt_t elmt; /* Fixed array element */ + if (idx_info->pline->nused > 0) { + H5D_farray_filt_elmt_t elmt; /* Fixed array element */ /* Get the information for the chunk */ - if(H5FA_get(fa, idx, &elmt) < 0) + if (H5FA_get(fa, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") /* Set the info for the chunk */ udata->chunk_block.offset = elmt.addr; udata->chunk_block.length = elmt.nbytes; - udata->filter_mask = elmt.filter_mask; + udata->filter_mask = elmt.filter_mask; } /* end if */ else { /* Get the address for the chunk */ - if(H5FA_get(fa, idx, &udata->chunk_block.offset) < 0) + if (H5FA_get(fa, idx, &udata->chunk_block.offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Update the other (constant) information for the chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) udata->chunk_block.length = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__farray_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_iterate_cb * @@ -1116,39 +1092,39 @@ done: static int H5D__farray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void *_udata) { - H5D_farray_it_ud_t *udata = (H5D_farray_it_ud_t *)_udata; /* User data */ - unsigned ndims; /* Rank of chunk */ - int curr_dim; /* Current dimension */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_farray_it_ud_t *udata = (H5D_farray_it_ud_t *)_udata; /* User data */ + unsigned ndims; /* Rank of chunk */ + int curr_dim; /* Current dimension */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Compose generic chunk record for callback */ - if(udata->filtered) { + if (udata->filtered) { const H5D_farray_filt_elmt_t *filt_elmt = (const H5D_farray_filt_elmt_t *)_elmt; - udata->chunk_rec.chunk_addr = filt_elmt->addr; - udata->chunk_rec.nbytes = filt_elmt->nbytes; + udata->chunk_rec.chunk_addr = filt_elmt->addr; + udata->chunk_rec.nbytes = filt_elmt->nbytes; udata->chunk_rec.filter_mask = filt_elmt->filter_mask; } /* end if */ else udata->chunk_rec.chunk_addr = *(const haddr_t *)_elmt; /* Make "generic chunk" callback */ - if(H5F_addr_defined(udata->chunk_rec.chunk_addr)) - if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) + if (H5F_addr_defined(udata->chunk_rec.chunk_addr)) + if ((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); /* Update coordinates of chunk in dataset */ ndims = udata->common.layout->ndims - 1; HDassert(ndims > 0); curr_dim = (int)(ndims - 1); - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Increment coordinate in current dimension */ udata->chunk_rec.scaled[curr_dim]++; /* Check if we went off the end of the current dimension */ - if(udata->chunk_rec.scaled[curr_dim] >= udata->common.layout->max_chunks[curr_dim]) { + if (udata->chunk_rec.scaled[curr_dim] >= udata->common.layout->max_chunks[curr_dim]) { /* Reset coordinate & move to next faster dimension */ udata->chunk_rec.scaled[curr_dim] = 0; curr_dim--; @@ -1160,7 +1136,6 @@ H5D__farray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * FUNC_LEAVE_NOAPI(ret_value) } /* H5D__farray_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_iterate * @@ -1175,12 +1150,11 @@ H5D__farray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * *------------------------------------------------------------------------- */ static int -H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5FA_t *fa; /* Pointer to fixed array structure */ - H5FA_stat_t fa_stat; /* Fixed array statistics */ - int ret_value = FAIL; /* Return value */ + H5FA_t * fa; /* Pointer to fixed array structure */ + H5FA_stat_t fa_stat; /* Fixed array statistics */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC @@ -1195,39 +1169,40 @@ H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) { + if (NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") - } else /* Patch the top level file pointer contained in fa if needed */ + } + else /* Patch the top level file pointer contained in fa if needed */ H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Get the fixed array statistics */ - if(H5FA_get_stats(fa, &fa_stat) < 0) + if (H5FA_get_stats(fa, &fa_stat) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array statistics") /* Check if there are any array elements */ - if(fa_stat.nelmts > 0) { - H5D_farray_it_ud_t udata; /* User data for iteration callback */ + if (fa_stat.nelmts > 0) { + H5D_farray_it_ud_t udata; /* User data for iteration callback */ /* Initialize userdata */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = idx_info->layout; + udata.common.layout = idx_info->layout; udata.common.storage = idx_info->storage; HDmemset(&udata.chunk_rec, 0, sizeof(udata.chunk_rec)); udata.filtered = (idx_info->pline->nused > 0); - if(!udata.filtered) { - udata.chunk_rec.nbytes = idx_info->layout->size; + if (!udata.filtered) { + udata.chunk_rec.nbytes = idx_info->layout->size; udata.chunk_rec.filter_mask = 0; } /* end if */ - udata.cb = chunk_cb; + udata.cb = chunk_cb; udata.udata = chunk_udata; /* Iterate over the fixed array elements */ - if((ret_value = H5FA_iterate(fa, H5D__farray_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5FA_iterate(fa, H5D__farray_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over fixed array chunk index"); } /* end if */ @@ -1235,7 +1210,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_remove * @@ -1251,9 +1225,9 @@ done: static herr_t H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5FA_t *fa; /* Pointer to fixed array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1267,61 +1241,63 @@ H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t HDassert(udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) { + if (NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") - } else /* Patch the top level file pointer contained in fa if needed */ - if(H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch fixed array file pointer") + } + else /* Patch the top level file pointer contained in fa if needed */ + if (H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch fixed array file pointer") /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->scaled); + idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->scaled); /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_farray_filt_elmt_t elmt; /* Fixed array element */ + if (idx_info->pline->nused > 0) { + H5D_farray_filt_elmt_t elmt; /* Fixed array element */ /* Get the info about the chunk for the index */ - if(H5FA_get(fa, idx, &elmt) < 0) + if (H5FA_get(fa, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") /* Remove raw data chunk from file if not doing SWMR writes */ HDassert(H5F_addr_defined(elmt.addr)); - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { - H5_CHECK_OVERFLOW(elmt.nbytes, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, elmt.addr, (hsize_t)elmt.nbytes) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + H5_CHECK_OVERFLOW(elmt.nbytes, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, elmt.addr, (hsize_t)elmt.nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") } /* end if */ /* Reset the info about the chunk for the index */ - elmt.addr = HADDR_UNDEF; - elmt.nbytes = 0; + elmt.addr = HADDR_UNDEF; + elmt.nbytes = 0; elmt.filter_mask = 0; - if(H5FA_set(fa, idx, &elmt) < 0) + if (H5FA_set(fa, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to reset chunk info") } /* end if */ else { - haddr_t addr = HADDR_UNDEF; /* Chunk address */ + haddr_t addr = HADDR_UNDEF; /* Chunk address */ /* Get the address of the chunk for the index */ - if(H5FA_get(fa, idx, &addr) < 0) + if (H5FA_get(fa, idx, &addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Remove raw data chunk from file if not doing SWMR writes */ HDassert(H5F_addr_defined(addr)); - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { - H5_CHECK_OVERFLOW(idx_info->layout->size, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, addr, (hsize_t)idx_info->layout->size) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + H5_CHECK_OVERFLOW(idx_info->layout->size, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, addr, (hsize_t)idx_info->layout->size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") } /* end if */ /* Reset the address of the chunk for the index */ addr = HADDR_UNDEF; - if(H5FA_set(fa, idx, &addr) < 0) + if (H5FA_set(fa, idx, &addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to reset chunk address") } /* end else */ @@ -1329,7 +1305,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__farray_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_delete_cb * @@ -1346,8 +1321,8 @@ done: static int H5D__farray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1358,15 +1333,14 @@ H5D__farray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(f); /* Remove raw data chunk from file */ - H5_CHECK_OVERFLOW(chunk_rec->nbytes, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, chunk_rec->chunk_addr, (hsize_t)chunk_rec->nbytes) < 0) + H5_CHECK_OVERFLOW(chunk_rec->nbytes, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(f, H5FD_MEM_DRAW, chunk_rec->chunk_addr, (hsize_t)chunk_rec->nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_delete_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_delete * @@ -1384,7 +1358,7 @@ done: static herr_t H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1396,24 +1370,24 @@ H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { - H5D_farray_ctx_ud_t ctx_udata; /* User data for fixed array open call */ + if (H5F_addr_defined(idx_info->storage->idx_addr)) { + H5D_farray_ctx_ud_t ctx_udata; /* User data for fixed array open call */ /* Iterate over the chunk addresses in the fixed array, deleting each chunk */ - if(H5D__farray_idx_iterate(idx_info, H5D__farray_idx_delete_cb, idx_info->f) < 0) + if (H5D__farray_idx_iterate(idx_info, H5D__farray_idx_delete_cb, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk addresses") /* Close fixed array */ - if(H5FA_close(idx_info->storage->u.farray.fa) < 0) + if (H5FA_close(idx_info->storage->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") idx_info->storage->u.farray.fa = NULL; /* Set up the user data */ - ctx_udata.f = idx_info->f; + ctx_udata.f = idx_info->f; ctx_udata.chunk_size = idx_info->layout->size; /* Delete fixed array */ - if(H5FA_delete(idx_info->f, idx_info->storage->idx_addr, &ctx_udata) < 0) + if (H5FA_delete(idx_info->f, idx_info->storage->idx_addr, &ctx_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk fixed array") idx_info->storage->idx_addr = HADDR_UNDEF; } /* end if */ @@ -1424,7 +1398,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_copy_setup * @@ -1438,10 +1411,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1459,16 +1431,16 @@ H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Check if the source fixed array is open yet */ - if(NULL == idx_info_src->storage->u.farray.fa) + if (NULL == idx_info_src->storage->u.farray.fa) /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info_src) < 0) + if (H5D__farray_idx_open(idx_info_src) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create the fixed array that describes chunked storage in the dest. file */ - if(H5D__farray_idx_create(idx_info_dst) < 0) + if (H5D__farray_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1479,7 +1451,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_copy_shutdown * @@ -1493,10 +1464,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1507,10 +1477,10 @@ H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst->u.farray.fa); /* Close fixed arrays */ - if(H5FA_close(storage_src->u.farray.fa) < 0) + if (H5FA_close(storage_src->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") storage_src->u.farray.fa = NULL; - if(H5FA_close(storage_dst->u.farray.fa) < 0) + if (H5FA_close(storage_dst->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") storage_dst->u.farray.fa = NULL; @@ -1518,7 +1488,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_size * @@ -1535,9 +1504,9 @@ done: static herr_t H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5FA_t *fa; /* Pointer to fixed array structure */ - H5FA_stat_t fa_stat; /* Fixed array statistics */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t * fa; /* Pointer to fixed array structure */ + H5FA_stat_t fa_stat; /* Fixed array statistics */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1551,22 +1520,22 @@ H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) HDassert(index_size); /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Get the fixed array statistics */ - if(H5FA_get_stats(fa, &fa_stat) < 0) + if (H5FA_get_stats(fa, &fa_stat) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array statistics") *index_size = fa_stat.hdr_size; *index_size += fa_stat.dblk_size; done: - if(idx_info->storage->u.farray.fa) { - if(H5FA_close(idx_info->storage->u.farray.fa) < 0) + if (idx_info->storage->u.farray.fa) { + if (H5FA_close(idx_info->storage->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") idx_info->storage->u.farray.fa = NULL; } /* end if */ @@ -1574,7 +1543,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_reset * @@ -1596,14 +1564,13 @@ H5D__farray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) + if (reset_addr) storage->idx_addr = HADDR_UNDEF; storage->u.farray.fa = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_dump * @@ -1630,7 +1597,6 @@ H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_dest * @@ -1646,7 +1612,7 @@ H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1656,14 +1622,14 @@ H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the fixed array is open */ - if(idx_info->storage->u.farray.fa) { + if (idx_info->storage->u.farray.fa) { /* Patch the top level file pointer contained in fa if needed */ - if(H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) + if (H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch fixed array file pointer") /* Close fixed array */ - if(H5FA_close(idx_info->storage->u.farray.fa) < 0) + if (H5FA_close(idx_info->storage->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") idx_info->storage->u.farray.fa = NULL; } /* end if */ @@ -1671,4 +1637,3 @@ H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_dest() */ - diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 94c7b1c..8bba9dc 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -26,45 +26,39 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5D__fill_release(H5D_fill_buf_info_t *fb_info); - /*********************/ /* Package Variables */ /*********************/ @@ -72,12 +66,10 @@ static herr_t H5D__fill_release(H5D_fill_buf_info_t *fb_info); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -91,7 +83,6 @@ H5FL_BLK_DEFINE_STATIC(zero_fill); /* Declare extern free list to manage the H5S_sel_iter_t struct */ H5FL_EXTERN(H5S_sel_iter_t); - /*-------------------------------------------------------------------------- NAME H5Dfill @@ -127,24 +118,23 @@ H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_ H5TRACE5("e", "*xi*xii", fill, fill_type_id, buf, buf_type_id, space_id); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace") - if(NULL == (fill_type = (H5T_t *)H5I_object_verify(fill_type_id, H5I_DATATYPE))) + if (NULL == (fill_type = (H5T_t *)H5I_object_verify(fill_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") - if(NULL == (buf_type = (H5T_t *)H5I_object_verify(buf_type_id, H5I_DATATYPE))) + if (NULL == (buf_type = (H5T_t *)H5I_object_verify(buf_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") /* Fill the selection in the memory buffer */ - if(H5D__fill(fill, fill_type, buf, buf_type, space) < 0) + if (H5D__fill(fill, fill_type, buf, buf_type, space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") done: FUNC_LEAVE_API(ret_value) -} /* H5Dfill() */ +} /* H5Dfill() */ - /*-------------------------------------------------------------------------- NAME H5D__fill @@ -174,20 +164,19 @@ done: on each element so that each of them has a copy of the VL data. --------------------------------------------------------------------------*/ herr_t -H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, - const H5T_t *buf_type, const H5S_t *space) +H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_type, const H5S_t *space) { - H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info */ - hbool_t mem_iter_init = FALSE; /* Whether the memory selection iterator has been initialized */ - H5WB_t *elem_wb = NULL; /* Wrapped buffer for element data */ - uint8_t elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for element data */ - H5WB_t *bkg_elem_wb = NULL; /* Wrapped buffer for background data */ - uint8_t bkg_elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for background data */ - uint8_t *bkg_buf = NULL; /* Background conversion buffer */ - uint8_t *tmp_buf = NULL; /* Temp conversion buffer */ - hid_t src_id = -1, dst_id = -1; /* Temporary type IDs */ - size_t dst_type_size; /* Size of destination type*/ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info */ + hbool_t mem_iter_init = FALSE; /* Whether the memory selection iterator has been initialized */ + H5WB_t * elem_wb = NULL; /* Wrapped buffer for element data */ + uint8_t elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for element data */ + H5WB_t * bkg_elem_wb = NULL; /* Wrapped buffer for background data */ + uint8_t bkg_elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for background data */ + uint8_t * bkg_buf = NULL; /* Background conversion buffer */ + uint8_t * tmp_buf = NULL; /* Temp conversion buffer */ + hid_t src_id = -1, dst_id = -1; /* Temporary type IDs */ + size_t dst_type_size; /* Size of destination type*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -198,32 +187,32 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, HDassert(space); /* Make sure the dataspace has an extent set (or is NULL) */ - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace extent has not been set") /* Get the memory datatype size */ dst_type_size = H5T_get_size(buf_type); /* If there's no fill value, just use zeros */ - if(fill == NULL) { - void *elem_ptr; /* Pointer to element to use for fill value */ + if (fill == NULL) { + void *elem_ptr; /* Pointer to element to use for fill value */ /* Wrap the local buffer for elements */ - if(NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) + if (NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for element */ - if(NULL == (elem_ptr = H5WB_actual_clear(elem_wb, dst_type_size))) + if (NULL == (elem_ptr = H5WB_actual_clear(elem_wb, dst_type_size))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Fill the selection in the memory buffer */ - if(H5S_select_fill(elem_ptr, dst_type_size, space, buf) < 0) + if (H5S_select_fill(elem_ptr, dst_type_size, space, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") } /* end if */ else { - H5T_path_t *tpath; /* Conversion path information */ - size_t src_type_size; /* Size of source type */ - size_t buf_size; /* Desired buffer size */ + H5T_path_t *tpath; /* Conversion path information */ + size_t src_type_size; /* Size of source type */ + size_t buf_size; /* Desired buffer size */ /* Get the file datatype size */ src_type_size = H5T_get_size(fill_type); @@ -232,15 +221,15 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, buf_size = MAX(src_type_size, dst_type_size); /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(fill_type, buf_type))) + if (NULL == (tpath = H5T_path_find(fill_type, buf_type))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") /* Construct source & destination datatype IDs, if we will need them */ - if(!H5T_path_noop(tpath)) { - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill_type, H5T_COPY_ALL), FALSE)) < 0) + if (!H5T_path_noop(tpath)) { + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill_type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") - if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(buf_type, H5T_COPY_ALL), FALSE)) < 0) + if ((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(buf_type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") } /* end if */ @@ -248,55 +237,58 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, * then do conversion on each element so that each of them has a copy * of the VL data. */ - if(TRUE == H5T_detect_class(fill_type, H5T_VLEN, FALSE)) { - hsize_t nelmts; /* Number of data elements */ + if (TRUE == H5T_detect_class(fill_type, H5T_VLEN, FALSE)) { + hsize_t nelmts; /* Number of data elements */ /* Get the number of elements in the selection */ nelmts = H5S_GET_SELECT_NPOINTS(space); H5_CHECK_OVERFLOW(nelmts, hsize_t, size_t); /* Allocate a temporary buffer */ - if(NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size))) + if (NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Allocate a background buffer, if necessary */ - if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)nelmts * buf_size))) + if (H5T_path_bkg(tpath) && + NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)nelmts * buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Replicate the file's fill value into the temporary buffer */ H5VM_array_fill(tmp_buf, fill, src_type_size, (size_t)nelmts); /* Convert from file's fill value into memory form */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)nelmts, (size_t)0, (size_t)0, tmp_buf, bkg_buf) < 0) + if (H5T_convert(tpath, src_id, dst_id, (size_t)nelmts, (size_t)0, (size_t)0, tmp_buf, bkg_buf) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") /* Allocate the chunk selection iterator */ - if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory selection iterator") /* Create a selection iterator for scattering the elements to memory buffer */ - if(H5S_select_iter_init(mem_iter, space, dst_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") + if (H5S_select_iter_init(mem_iter, space, dst_type_size, 0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize memory selection information") mem_iter_init = TRUE; /* Scatter the data into memory */ - if(H5D__scatter_mem(tmp_buf, mem_iter, (size_t)nelmts, buf/*out*/) < 0) + if (H5D__scatter_mem(tmp_buf, mem_iter, (size_t)nelmts, buf /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") } /* end if */ else { - const uint8_t *fill_buf; /* Buffer to use for writing fill values */ + const uint8_t *fill_buf; /* Buffer to use for writing fill values */ /* Convert disk buffer into memory buffer */ - if(!H5T_path_noop(tpath)) { - void *elem_ptr; /* Pointer to element to use for fill value */ - void *bkg_ptr = NULL; /* Pointer to background element to use for fill value */ + if (!H5T_path_noop(tpath)) { + void *elem_ptr; /* Pointer to element to use for fill value */ + void *bkg_ptr = NULL; /* Pointer to background element to use for fill value */ /* Wrap the local buffer for elements */ - if(NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) + if (NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for element */ - if(NULL == (elem_ptr = H5WB_actual(elem_wb, buf_size))) + if (NULL == (elem_ptr = H5WB_actual(elem_wb, buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Copy the user's data into the buffer for conversion */ @@ -304,18 +296,19 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, /* If there's no VL type of data, do conversion first then fill the data into * the memory buffer. */ - if(H5T_path_bkg(tpath)) { + if (H5T_path_bkg(tpath)) { /* Wrap the local buffer for background elements */ - if(NULL == (bkg_elem_wb = H5WB_wrap(bkg_elem_buf, sizeof(bkg_elem_buf)))) + if (NULL == (bkg_elem_wb = H5WB_wrap(bkg_elem_buf, sizeof(bkg_elem_buf)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for element */ - if(NULL == (bkg_ptr = H5WB_actual_clear(bkg_elem_wb, buf_size))) + if (NULL == (bkg_ptr = H5WB_actual_clear(bkg_elem_wb, buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") } /* end if */ /* Perform datatype conversion */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, elem_ptr, bkg_ptr) < 0) + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, elem_ptr, bkg_ptr) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") /* Point at element buffer */ @@ -325,33 +318,32 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, fill_buf = (const uint8_t *)fill; /* Fill the selection in the memory buffer */ - if(H5S_select_fill(fill_buf, dst_type_size, space, buf) < 0) + if (H5S_select_fill(fill_buf, dst_type_size, space, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") } /* end else */ - } /* end else */ + } /* end else */ done: - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(mem_iter) + if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); - if(src_id != (-1) && H5I_dec_ref(src_id) < 0) + if (src_id != (-1) && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(dst_id != (-1) && H5I_dec_ref(dst_id) < 0) + if (dst_id != (-1) && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tmp_buf) + if (tmp_buf) tmp_buf = H5FL_BLK_FREE(type_conv, tmp_buf); - if(elem_wb && H5WB_unwrap(elem_wb) < 0) + if (elem_wb && H5WB_unwrap(elem_wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") - if(bkg_elem_wb && H5WB_unwrap(bkg_elem_wb) < 0) + if (bkg_elem_wb && H5WB_unwrap(bkg_elem_wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__fill() */ - /*------------------------------------------------------------------------- * Function: H5D__fill_init * @@ -365,13 +357,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, - H5MM_allocate_t alloc_func, void *alloc_info, - H5MM_free_t free_func, void *free_info, - const H5O_fill_t *fill, const H5T_t *dset_type, hid_t dset_type_id, - size_t total_nelmts, size_t max_buf_size) +H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, H5MM_allocate_t alloc_func, + void *alloc_info, H5MM_free_t free_func, void *free_info, const H5O_fill_t *fill, + const H5T_t *dset_type, hid_t dset_type_id, size_t total_nelmts, size_t max_buf_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -385,29 +375,29 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, HDmemset(fb_info, 0, sizeof(*fb_info)); /* Cache constant information from the dataset */ - fb_info->fill = fill; - fb_info->file_type = dset_type; - fb_info->file_tid = dset_type_id; + fb_info->fill = fill; + fb_info->file_type = dset_type; + fb_info->file_tid = dset_type_id; fb_info->fill_alloc_func = alloc_func; fb_info->fill_alloc_info = alloc_info; - fb_info->fill_free_func = free_func; - fb_info->fill_free_info = free_info; + fb_info->fill_free_func = free_func; + fb_info->fill_free_info = free_info; /* Fill the buffer with the user's fill value */ - if(fill->buf) { - htri_t has_vlen_type; /* Whether the datatype has a VL component */ + if (fill->buf) { + htri_t has_vlen_type; /* Whether the datatype has a VL component */ /* Detect whether the datatype has a VL component */ - if((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN, FALSE)) < 0) + if ((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to detect vlen datatypes?") fb_info->has_vlen_fill_type = (hbool_t)has_vlen_type; /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ - if(fb_info->has_vlen_fill_type) { + if (fb_info->has_vlen_fill_type) { /* Create temporary datatype for conversion operation */ - if(NULL == (fb_info->mem_type = H5T_copy(dset_type, H5T_COPY_TRANSIENT))) + if (NULL == (fb_info->mem_type = H5T_copy(dset_type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy file datatype") - if((fb_info->mem_tid = H5I_register(H5I_DATATYPE, fb_info->mem_type, FALSE)) < 0) + if ((fb_info->mem_tid = H5I_register(H5I_DATATYPE, fb_info->mem_type, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") /* Retrieve sizes of memory & file datatypes */ @@ -420,7 +410,7 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, fb_info->max_elmt_size = MAX(fb_info->mem_elmt_size, fb_info->file_elmt_size); /* Compute the number of elements that fit within a buffer to write */ - if(total_nelmts > 0) + if (total_nelmts > 0) fb_info->elmts_per_buf = MIN(total_nelmts, MAX(1, (max_buf_size / fb_info->max_elmt_size))); else fb_info->elmts_per_buf = max_buf_size / fb_info->max_elmt_size; @@ -430,48 +420,50 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, fb_info->fill_buf_size = MIN(max_buf_size, (fb_info->elmts_per_buf * fb_info->max_elmt_size)); /* Allocate fill buffer */ - if(caller_fill_buf) { - fb_info->fill_buf = caller_fill_buf; + if (caller_fill_buf) { + fb_info->fill_buf = caller_fill_buf; fb_info->use_caller_fill_buf = TRUE; } /* end if */ else { - if(alloc_func) + if (alloc_func) fb_info->fill_buf = alloc_func(fb_info->fill_buf_size, alloc_info); else fb_info->fill_buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); - if(NULL == fb_info->fill_buf) + if (NULL == fb_info->fill_buf) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") } /* end else */ /* Get the datatype conversion path for this operation */ - if(NULL == (fb_info->fill_to_mem_tpath = H5T_path_find(dset_type, fb_info->mem_type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") + if (NULL == (fb_info->fill_to_mem_tpath = H5T_path_find(dset_type, fb_info->mem_type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert between src and dst datatypes") /* Get the inverse datatype conversion path for this operation */ - if(NULL == (fb_info->mem_to_dset_tpath = H5T_path_find(fb_info->mem_type, dset_type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") + if (NULL == (fb_info->mem_to_dset_tpath = H5T_path_find(fb_info->mem_type, dset_type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert between src and dst datatypes") /* Check if we need to allocate a background buffer */ - if(H5T_path_bkg(fb_info->fill_to_mem_tpath) || H5T_path_bkg(fb_info->mem_to_dset_tpath)) { + if (H5T_path_bkg(fb_info->fill_to_mem_tpath) || H5T_path_bkg(fb_info->mem_to_dset_tpath)) { /* Check for inverse datatype conversion needing a background buffer */ /* (do this first, since it needs a larger buffer) */ - if(H5T_path_bkg(fb_info->mem_to_dset_tpath)) + if (H5T_path_bkg(fb_info->mem_to_dset_tpath)) fb_info->bkg_buf_size = fb_info->elmts_per_buf * fb_info->max_elmt_size; else fb_info->bkg_buf_size = fb_info->max_elmt_size; /* Allocate the background buffer */ - if(NULL == (fb_info->bkg_buf = H5FL_BLK_MALLOC(type_conv, fb_info->bkg_buf_size))) + if (NULL == (fb_info->bkg_buf = H5FL_BLK_MALLOC(type_conv, fb_info->bkg_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ - } /* end if */ + } /* end if */ else { /* If fill value is not library default, use it to set the element size */ HDassert(fill->size >= 0); fb_info->max_elmt_size = fb_info->file_elmt_size = fb_info->mem_elmt_size = (size_t)fill->size; /* Compute the number of elements that fit within a buffer to write */ - if(total_nelmts > 0) + if (total_nelmts > 0) fb_info->elmts_per_buf = MIN(total_nelmts, MAX(1, (max_buf_size / fb_info->max_elmt_size))); else fb_info->elmts_per_buf = max_buf_size / fb_info->max_elmt_size; @@ -481,30 +473,30 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, fb_info->fill_buf_size = MIN(max_buf_size, fb_info->elmts_per_buf * fb_info->max_elmt_size); /* Allocate temporary buffer */ - if(caller_fill_buf) { - fb_info->fill_buf = caller_fill_buf; + if (caller_fill_buf) { + fb_info->fill_buf = caller_fill_buf; fb_info->use_caller_fill_buf = TRUE; } /* end if */ else { - if(alloc_func) + if (alloc_func) fb_info->fill_buf = alloc_func(fb_info->fill_buf_size, alloc_info); else fb_info->fill_buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); - if(NULL == fb_info->fill_buf) + if (NULL == fb_info->fill_buf) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") } /* end else */ /* Replicate the fill value into the cached buffer */ H5VM_array_fill(fb_info->fill_buf, fill->buf, fb_info->max_elmt_size, fb_info->elmts_per_buf); - } /* end else */ - } /* end if */ - else { /* Fill the buffer with the default fill value */ + } /* end else */ + } /* end if */ + else { /* Fill the buffer with the default fill value */ /* Retrieve size of elements */ fb_info->max_elmt_size = fb_info->file_elmt_size = fb_info->mem_elmt_size = H5T_get_size(dset_type); HDassert(fb_info->max_elmt_size > 0); /* Compute the number of elements that fit within a buffer to write */ - if(total_nelmts > 0) + if (total_nelmts > 0) fb_info->elmts_per_buf = MIN(total_nelmts, MAX(1, (max_buf_size / fb_info->max_elmt_size))); else fb_info->elmts_per_buf = max_buf_size / fb_info->max_elmt_size; @@ -514,43 +506,44 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, fb_info->fill_buf_size = MIN(max_buf_size, (fb_info->elmts_per_buf * fb_info->max_elmt_size)); /* Use (and zero) caller's buffer, if provided */ - if(caller_fill_buf) { - fb_info->fill_buf = caller_fill_buf; + if (caller_fill_buf) { + fb_info->fill_buf = caller_fill_buf; fb_info->use_caller_fill_buf = TRUE; HDmemset(fb_info->fill_buf, 0, fb_info->fill_buf_size); } /* end if */ else { - if(alloc_func) { + if (alloc_func) { fb_info->fill_buf = alloc_func(fb_info->fill_buf_size, alloc_info); HDmemset(fb_info->fill_buf, 0, fb_info->fill_buf_size); } /* end if */ else { - htri_t buf_avail = H5FL_BLK_AVAIL(zero_fill, fb_info->fill_buf_size); /* Check if there is an already zeroed out buffer available */ + htri_t buf_avail = H5FL_BLK_AVAIL( + zero_fill, + fb_info->fill_buf_size); /* Check if there is an already zeroed out buffer available */ HDassert(buf_avail != FAIL); /* Allocate temporary buffer (zeroing it if no buffer is available) */ - if(!buf_avail) + if (!buf_avail) fb_info->fill_buf = H5FL_BLK_CALLOC(zero_fill, fb_info->fill_buf_size); else fb_info->fill_buf = H5FL_BLK_MALLOC(zero_fill, fb_info->fill_buf_size); } /* end else */ - if(fb_info->fill_buf == NULL) + if (fb_info->fill_buf == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") } /* end else */ - } /* end else */ + } /* end else */ done: /* Cleanup on error */ - if(ret_value < 0) - if(H5D__fill_term(fb_info) < 0) + if (ret_value < 0) + if (H5D__fill_term(fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__fill_init() */ - /*------------------------------------------------------------------------- * Function: H5D__fill_refill_vl * @@ -566,8 +559,8 @@ done: herr_t H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts) { - herr_t ret_value = SUCCEED; /* Return value */ - void * buf = NULL; /* Temporary fill buffer */ + herr_t ret_value = SUCCEED; /* Return value */ + void * buf = NULL; /* Temporary fill buffer */ FUNC_ENTER_PACKAGE @@ -580,49 +573,52 @@ H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts) H5MM_memcpy(fb_info->fill_buf, fb_info->fill->buf, fb_info->file_elmt_size); /* Reset first element of background buffer, if necessary */ - if(H5T_path_bkg(fb_info->fill_to_mem_tpath)) + if (H5T_path_bkg(fb_info->fill_to_mem_tpath)) HDmemset(fb_info->bkg_buf, 0, fb_info->max_elmt_size); /* Type convert the dataset buffer, to copy any VL components */ - if(H5T_convert(fb_info->fill_to_mem_tpath, fb_info->file_tid, fb_info->mem_tid, (size_t)1, (size_t)0, (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) + if (H5T_convert(fb_info->fill_to_mem_tpath, fb_info->file_tid, fb_info->mem_tid, (size_t)1, (size_t)0, + (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") /* Replicate the fill value into the cached buffer */ - if(nelmts > 1) - H5VM_array_fill((void *)((unsigned char *)fb_info->fill_buf + fb_info->mem_elmt_size), fb_info->fill_buf, fb_info->mem_elmt_size, (nelmts - 1)); + if (nelmts > 1) + H5VM_array_fill((void *)((unsigned char *)fb_info->fill_buf + fb_info->mem_elmt_size), + fb_info->fill_buf, fb_info->mem_elmt_size, (nelmts - 1)); /* Reset the entire background buffer, if necessary */ - if(H5T_path_bkg(fb_info->mem_to_dset_tpath)) + if (H5T_path_bkg(fb_info->mem_to_dset_tpath)) HDmemset(fb_info->bkg_buf, 0, fb_info->bkg_buf_size); /* Make a copy of the fill buffer so we can free dynamic elements after conversion */ - if(fb_info->fill_alloc_func) + if (fb_info->fill_alloc_func) buf = fb_info->fill_alloc_func(fb_info->fill_buf_size, fb_info->fill_alloc_info); else buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); - if(!buf) + if (!buf) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary fill buffer") H5MM_memcpy(buf, fb_info->fill_buf, fb_info->fill_buf_size); /* Type convert the dataset buffer, to copy any VL components */ - if(H5T_convert(fb_info->mem_to_dset_tpath, fb_info->mem_tid, fb_info->file_tid, nelmts, (size_t)0, (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) + if (H5T_convert(fb_info->mem_to_dset_tpath, fb_info->mem_tid, fb_info->file_tid, nelmts, (size_t)0, + (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") done: - if(buf) { + if (buf) { /* Free dynamically allocated VL elements in fill buffer */ - if(fb_info->fill->type) { - if(H5T_vlen_reclaim_elmt(buf, fb_info->fill->type) < 0) + if (fb_info->fill->type) { + if (H5T_vlen_reclaim_elmt(buf, fb_info->fill->type) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") } /* end if */ else { - if(H5T_vlen_reclaim_elmt(buf, fb_info->mem_type) < 0) + if (H5T_vlen_reclaim_elmt(buf, fb_info->mem_type) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") } /* end else */ /* Free temporary fill buffer */ - if(fb_info->fill_free_func) + if (fb_info->fill_free_func) fb_info->fill_free_func(buf, fb_info->fill_free_info); else buf = H5FL_BLK_FREE(non_zero_fill, buf); @@ -631,7 +627,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__fill_refill_vl() */ - /*------------------------------------------------------------------------- * Function: H5D__fill_release * @@ -654,11 +649,11 @@ H5D__fill_release(H5D_fill_buf_info_t *fb_info) HDassert(fb_info->fill); /* Free the buffer for fill values */ - if(!fb_info->use_caller_fill_buf && fb_info->fill_buf) { - if(fb_info->fill_free_func) + if (!fb_info->use_caller_fill_buf && fb_info->fill_buf) { + if (fb_info->fill_free_func) fb_info->fill_free_func(fb_info->fill_buf, fb_info->fill_free_info); else { - if(fb_info->fill->buf) + if (fb_info->fill->buf) fb_info->fill_buf = H5FL_BLK_FREE(non_zero_fill, fb_info->fill_buf); else fb_info->fill_buf = H5FL_BLK_FREE(zero_fill, fb_info->fill_buf); @@ -669,7 +664,6 @@ H5D__fill_release(H5D_fill_buf_info_t *fb_info) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__fill_release() */ - /*------------------------------------------------------------------------- * Function: H5D__fill_term * @@ -694,15 +688,14 @@ H5D__fill_term(H5D_fill_buf_info_t *fb_info) H5D__fill_release(fb_info); /* Free other resources for vlen fill values */ - if(fb_info->has_vlen_fill_type) { - if(fb_info->mem_tid > 0) + if (fb_info->has_vlen_fill_type) { + if (fb_info->mem_tid > 0) H5I_dec_ref(fb_info->mem_tid); - else if(fb_info->mem_type) + else if (fb_info->mem_type) (void)H5T_close_real(fb_info->mem_type); - if(fb_info->bkg_buf) + if (fb_info->bkg_buf) fb_info->bkg_buf = H5FL_BLK_FREE(type_conv, fb_info->bkg_buf); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__fill_term() */ - diff --git a/src/H5Dint.c b/src/H5Dint.c index 8ba9b4f..689b1e6 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -15,30 +15,27 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -46,58 +43,55 @@ /* Shared data structure for computing variable-length dataset's total size */ /* (Used for both native and generic 'get vlen buf size' operation) */ typedef struct { - void *fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ - void *vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ - size_t vl_tbuf_size; /* Current size of the temp. buffer for VL data */ - hsize_t size; /* Accumulated number of bytes for the selection */ + void * fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ + void * vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ + size_t vl_tbuf_size; /* Current size of the temp. buffer for VL data */ + hsize_t size; /* Accumulated number of bytes for the selection */ } H5D_vlen_bufsize_common_t; /* Internal data structure for computing variable-length dataset's total size */ /* (Used for native 'get vlen buf size' operation) */ typedef struct { - H5D_t *dset; /* Dataset for operation */ - H5S_t *fspace; /* Dataset's dataspace for operation */ - H5S_t *mspace; /* Memory dataspace for operation */ - H5D_vlen_bufsize_common_t common; /* VL data buffers & accumulatd size */ + H5D_t * dset; /* Dataset for operation */ + H5S_t * fspace; /* Dataset's dataspace for operation */ + H5S_t * mspace; /* Memory dataspace for operation */ + H5D_vlen_bufsize_common_t common; /* VL data buffers & accumulatd size */ } H5D_vlen_bufsize_native_t; /* Internal data structure for computing variable-length dataset's total size */ /* (Used for generic 'get vlen buf size' operation) */ typedef struct { - H5VL_object_t *dset_vol_obj; /* VOL object for the dataset */ - hid_t fspace_id; /* Dataset dataspace ID of the dataset we are working on */ - H5S_t *fspace; /* Dataset's dataspace for operation */ - hid_t mspace_id; /* Memory dataspace ID of the dataset we are working on */ - hid_t dxpl_id; /* Dataset transfer property list to pass to dataset read */ - H5D_vlen_bufsize_common_t common; /* VL data buffers & accumulatd size */ + H5VL_object_t * dset_vol_obj; /* VOL object for the dataset */ + hid_t fspace_id; /* Dataset dataspace ID of the dataset we are working on */ + H5S_t * fspace; /* Dataset's dataspace for operation */ + hid_t mspace_id; /* Memory dataspace ID of the dataset we are working on */ + hid_t dxpl_id; /* Dataset transfer property list to pass to dataset read */ + H5D_vlen_bufsize_common_t common; /* VL data buffers & accumulatd size */ } H5D_vlen_bufsize_generic_t; - /********************/ /* Local Prototypes */ /********************/ /* General stuff */ static H5D_shared_t *H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type); -static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type); -static herr_t H5D__cache_dataspace_info(const H5D_t *dset); -static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); -static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); +static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type); +static herr_t H5D__cache_dataspace_info(const H5D_t *dset); +static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); +static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix); static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id); -static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, - hsize_t old_dim[]); +static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id); static herr_t H5D__close_cb(H5VL_object_t *dset_vol_obj); static herr_t H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize); static herr_t H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc); static size_t H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr); -static void *H5D__vlen_get_buf_size_alloc(size_t size, void *info); -static herr_t H5D__vlen_get_buf_size_cb(void *elem, hid_t type_id, unsigned ndim, - const hsize_t *point, void *op_data); -static herr_t H5D__vlen_get_buf_size_gen_cb(void *elem, hid_t type_id, unsigned ndim, - const hsize_t *point, void *op_data); - +static void * H5D__vlen_get_buf_size_alloc(size_t size, void *info); +static herr_t H5D__vlen_get_buf_size_cb(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *op_data); +static herr_t H5D__vlen_get_buf_size_gen_cb(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *op_data); /*********************/ /* Package Variables */ @@ -109,12 +103,10 @@ H5FL_BLK_DEFINE(vlen_vl_buf); /* Declare a free list to manage other blocks of VL data */ H5FL_BLK_DEFINE(vlen_fl_buf); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -133,17 +125,17 @@ H5FL_EXTERN(H5D_chunk_info_t); H5FL_BLK_EXTERN(type_conv); /* Disable warning for intentional identical branches here -QAK */ -H5_GCC_DIAG_OFF(larger-than=) +H5_GCC_DIAG_OFF("larger-than=") /* Define a static "default" dataset structure to use to initialize new datasets */ static H5D_shared_t H5D_def_dset; -H5_GCC_DIAG_ON(larger-than=) +H5_GCC_DIAG_ON("larger-than=") /* Dataset ID class */ static const H5I_class_t H5I_DATASET_CLS[1] = {{ - H5I_DATASET, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5D__close_cb /* Callback routine for closing objects of this class */ + H5I_DATASET, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5D__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ @@ -154,7 +146,6 @@ static hbool_t H5D_top_package_initialize_s = FALSE; static const char *H5D_prefix_ext_env = NULL; static const char *H5D_prefix_vds_env = NULL; - /*------------------------------------------------------------------------- * Function: H5D_init * @@ -168,7 +159,7 @@ static const char *H5D_prefix_vds_env = NULL; herr_t H5D_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -177,7 +168,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_init() */ - /*-------------------------------------------------------------------------- NAME H5D__init_package -- Initialize interface-specific information @@ -196,13 +186,13 @@ NOTES herr_t H5D__init_package(void) { - H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the dataset IDs */ - if(H5I_register_type(H5I_DATASET_CLS) < 0) + if (H5I_register_type(H5I_DATASET_CLS) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Reset the "default dataset" information */ @@ -214,19 +204,19 @@ H5D__init_package(void) /* Get the default dataset creation property list values and initialize the * default dataset with them. */ - if(NULL == (def_dcpl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_CREATE_ID_g))) + if (NULL == (def_dcpl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_CREATE_ID_g))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get default dataset creation property list") /* Get the default data storage layout */ - if(H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") + if (H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Get the default dataset creation properties */ - if(H5P_get(def_dcpl, H5D_CRT_EXT_FILE_LIST_NAME, &H5D_def_dset.dcpl_cache.efl) < 0) + if (H5P_get(def_dcpl, H5D_CRT_EXT_FILE_LIST_NAME, &H5D_def_dset.dcpl_cache.efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve external file list") - if(H5P_get(def_dcpl, H5D_CRT_FILL_VALUE_NAME, &H5D_def_dset.dcpl_cache.fill) < 0) + if (H5P_get(def_dcpl, H5D_CRT_FILL_VALUE_NAME, &H5D_def_dset.dcpl_cache.fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value") - if(H5P_get(def_dcpl, H5O_CRT_PIPELINE_NAME, &H5D_def_dset.dcpl_cache.pline) < 0) + if (H5P_get(def_dcpl, H5O_CRT_PIPELINE_NAME, &H5D_def_dset.dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter") /* Mark "top" of interface as initialized, too */ @@ -240,7 +230,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_package() */ - /*------------------------------------------------------------------------- * Function: H5D_top_term_package * @@ -254,12 +243,12 @@ done: int H5D_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5D_top_package_initialize_s) { - if(H5I_nmembers(H5I_DATASET) > 0) { + if (H5D_top_package_initialize_s) { + if (H5I_nmembers(H5I_DATASET) > 0) { /* The dataset API uses the "force" flag set to true because it * is using the "file objects" (H5FO) API functions to track open * objects in the file. Using the H5FO code means that dataset @@ -284,17 +273,16 @@ H5D_top_term_package(void) */ (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark closed */ - if(0 == n) + if (0 == n) H5D_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5D_top_term_package() */ - /*------------------------------------------------------------------------- * Function: H5D_term_package * @@ -311,11 +299,11 @@ H5D_top_term_package(void) int H5D_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_DATASET)); HDassert(FALSE == H5D_top_package_initialize_s); @@ -324,14 +312,13 @@ H5D_term_package(void) n += (H5I_dec_type_ref(H5I_DATASET) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5D_term_package() */ - /*------------------------------------------------------------------------- * Function: H5D__close_cb * @@ -344,7 +331,7 @@ H5D_term_package(void) static herr_t H5D__close_cb(H5VL_object_t *dset_vol_obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -352,7 +339,7 @@ H5D__close_cb(H5VL_object_t *dset_vol_obj) HDassert(dset_vol_obj); /* Close the dataset */ - if(H5VL_dataset_close(dset_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_dataset_close(dset_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset"); done: @@ -362,13 +349,12 @@ done: */ /* Free the VOL object */ - if(H5VL_free_object(dset_vol_obj) < 0) + if (H5VL_free_object(dset_vol_obj) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__close_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__create_named * @@ -380,12 +366,12 @@ done: *------------------------------------------------------------------------- */ H5D_t * -H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, - const H5S_t *space, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) +H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, const H5S_t *space, hid_t lcpl_id, + hid_t dcpl_id, hid_t dapl_id) { - H5O_obj_create_t ocrt_info; /* Information for object creation */ - H5D_obj_create_t dcrt_info; /* Information for dataset creation */ - H5D_t *ret_value = NULL; /* Return value */ + H5O_obj_create_t ocrt_info; /* Information for object creation */ + H5D_obj_create_t dcrt_info; /* Information for dataset creation */ + H5D_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -400,17 +386,17 @@ H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, /* Set up dataset creation info */ dcrt_info.type_id = type_id; - dcrt_info.space = space; + dcrt_info.space = space; dcrt_info.dcpl_id = dcpl_id; dcrt_info.dapl_id = dapl_id; /* Set up object creation information */ ocrt_info.obj_type = H5O_TYPE_DATASET; ocrt_info.crt_info = &dcrt_info; - ocrt_info.new_obj = NULL; + ocrt_info.new_obj = NULL; /* Create the new dataset and link it to its parent group */ - if(H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) + if (H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create and link to dataset") HDassert(ocrt_info.new_obj); @@ -421,7 +407,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_named() */ - /*------------------------------------------------------------------------- * Function: H5D__get_space_status * @@ -435,48 +420,48 @@ done: herr_t H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE HDassert(dset); /* Check for chunked layout */ - if(dset->shared->layout.type == H5D_CHUNKED) { - hsize_t space_allocated; /* The number of bytes allocated for chunks */ - hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ - hsize_t nelmts; /* Number of elements in dataspace */ - size_t dt_size; /* Size of datatype */ - hsize_t full_size; /* The number of bytes in the dataset when fully populated */ + if (dset->shared->layout.type == H5D_CHUNKED) { + hsize_t space_allocated; /* The number of bytes allocated for chunks */ + hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ + hsize_t nelmts; /* Number of elements in dataspace */ + size_t dt_size; /* Size of datatype */ + hsize_t full_size; /* The number of bytes in the dataset when fully populated */ /* For chunked layout set the space status by the storage size */ /* Get the dataset's dataspace */ HDassert(dset->shared->space); /* Get the total number of elements in dataset's dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") nelmts = (hsize_t)snelmts; /* Get the size of the dataset's datatype */ - if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) + if (0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") /* Compute the maximum size of the dataset in bytes */ full_size = nelmts * dt_size; /* Check for overflow during multiplication */ - if(nelmts != (full_size / dt_size)) + if (nelmts != (full_size / dt_size)) HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") /* Difficult to error check, since the error value is 0 and 0 is a valid value... :-/ */ - if(H5D__get_storage_size(dset, &space_allocated) < 0) + if (H5D__get_storage_size(dset, &space_allocated) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") /* Decide on how much of the space is allocated */ - if(space_allocated == 0) + if (space_allocated == 0) *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED; - else if(space_allocated == full_size) + else if (space_allocated == full_size) *allocation = H5D_SPACE_STATUS_ALLOCATED; else *allocation = H5D_SPACE_STATUS_PART_ALLOCATED; @@ -484,7 +469,7 @@ H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation) else { /* For non-chunked layouts set space status by result of is_space_alloc * function */ - if(dset->shared->layout.ops->is_space_alloc(&dset->shared->layout.storage)) + if (dset->shared->layout.ops->is_space_alloc(&dset->shared->layout.storage)) *allocation = H5D_SPACE_STATUS_ALLOCATED; else *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED; @@ -494,7 +479,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_space_status() */ - /*------------------------------------------------------------------------- * Function: H5D__new * @@ -507,14 +491,14 @@ done: static H5D_shared_t * H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) { - H5D_shared_t *new_dset = NULL; /* New dataset object */ - H5P_genplist_t *plist; /* Property list created */ - H5D_shared_t *ret_value = NULL; /* Return value */ + H5D_shared_t * new_dset = NULL; /* New dataset object */ + H5P_genplist_t *plist; /* Property list created */ + H5D_shared_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate new shared dataset structure */ - if(NULL == (new_dset = H5FL_MALLOC(H5D_shared_t))) + if (NULL == (new_dset = H5FL_MALLOC(H5D_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the default dataset information */ @@ -523,27 +507,27 @@ H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) /* If we are using the default dataset creation property list, during creation * don't bother to copy it, just increment the reference count */ - if(!vl_type && creating && dcpl_id == H5P_DATASET_CREATE_DEFAULT) { - if(H5I_inc_ref(dcpl_id, FALSE) < 0) + if (!vl_type && creating && dcpl_id == H5P_DATASET_CREATE_DEFAULT) { + if (H5I_inc_ref(dcpl_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment default DCPL ID") new_dset->dcpl_id = dcpl_id; } /* end if */ else { /* Get the property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") new_dset->dcpl_id = H5P_copy_plist(plist, FALSE); } /* end else */ - if(!vl_type && creating && dapl_id == H5P_DATASET_ACCESS_DEFAULT) { - if(H5I_inc_ref(dapl_id, FALSE) < 0) + if (!vl_type && creating && dapl_id == H5P_DATASET_ACCESS_DEFAULT) { + if (H5I_inc_ref(dapl_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment default DAPL ID") new_dset->dapl_id = dapl_id; } /* end if */ else { /* Get the property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") new_dset->dapl_id = H5P_copy_plist(plist, FALSE); @@ -553,11 +537,11 @@ H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) ret_value = new_dset; done: - if(ret_value == NULL) - if(new_dset != NULL) { - if(new_dset->dcpl_id != 0 && H5I_dec_ref(new_dset->dcpl_id) < 0) + if (ret_value == NULL) + if (new_dset != NULL) { + if (new_dset->dcpl_id != 0 && H5I_dec_ref(new_dset->dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "can't decrement temporary datatype ID") - if(new_dset->dapl_id != 0 && H5I_dec_ref(new_dset->dapl_id) < 0) + if (new_dset->dapl_id != 0 && H5I_dec_ref(new_dset->dapl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "can't decrement temporary datatype ID") new_dset = H5FL_FREE(H5D_shared_t, new_dset); } /* end if */ @@ -565,7 +549,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__new() */ - /*------------------------------------------------------------------------- * Function: H5D__init_type * @@ -579,10 +562,10 @@ done: static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) { - htri_t relocatable; /* Flag whether the type is relocatable */ - htri_t immutable; /* Flag whether the type is immutable */ - hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t relocatable; /* Flag whether the type is relocatable */ + htri_t immutable; /* Flag whether the type is immutable */ + hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -592,55 +575,54 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) HDassert(type); /* Check whether the datatype is relocatable */ - if((relocatable = H5T_is_relocatable(type)) < 0) + if ((relocatable = H5T_is_relocatable(type)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?") /* Check whether the datatype is immutable */ - if((immutable = H5T_is_immutable(type)) < 0) + if ((immutable = H5T_is_immutable(type)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?") /* To use at least v18 format versions or not */ use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); /* Copy the datatype if it's a custom datatype or if it'll change when its location is changed */ - if(!immutable || relocatable || use_at_least_v18) { + if (!immutable || relocatable || use_at_least_v18) { /* Copy datatype for dataset */ - if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL) + if ((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy datatype") /* Convert a datatype (if committed) to a transient type if the committed datatype's file * location is different from the file location where the dataset will be created. */ - if(H5T_convert_committed_datatype(dset->shared->type, file) < 0) + if (H5T_convert_committed_datatype(dset->shared->type, file) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get shared datatype info") /* Mark any datatypes as being on disk now */ - if(H5T_set_loc(dset->shared->type, H5F_VOL_OBJ(file), H5T_LOC_DISK) < 0) + if (H5T_set_loc(dset->shared->type, H5F_VOL_OBJ(file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't set datatype location") /* Set the version for datatype */ - if(H5T_set_version(file, dset->shared->type) < 0) + if (H5T_set_version(file, dset->shared->type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype") /* Get a datatype ID for the dataset's datatype */ - if((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type, FALSE)) < 0) + if ((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") } /* end if */ /* Not a custom datatype, just use it directly */ else { - if(H5I_inc_ref(type_id, FALSE) < 0) + if (H5I_inc_ref(type_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, FAIL, "Can't increment datatype ID") /* Use existing datatype */ dset->shared->type_id = type_id; - dset->shared->type = (H5T_t *)type; /* (Cast away const OK - QAK) */ - } /* end else */ + dset->shared->type = (H5T_t *)type; /* (Cast away const OK - QAK) */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_type() */ - /*------------------------------------------------------------------------- * Function: H5D__cache_dataspace_info * @@ -653,9 +635,9 @@ done: static herr_t H5D__cache_dataspace_info(const H5D_t *dset) { - int sndims; /* Signed number of dimensions of dataspace rank */ - unsigned u; /* Local index value */ - herr_t ret_value = SUCCEED; /* Return value */ + int sndims; /* Signed number of dimensions of dataspace rank */ + unsigned u; /* Local index value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -663,15 +645,16 @@ H5D__cache_dataspace_info(const H5D_t *dset) HDassert(dset); /* Cache info for dataset's dataspace */ - if((sndims = H5S_get_simple_extent_dims(dset->shared->space, dset->shared->curr_dims, dset->shared->max_dims)) < 0) + if ((sndims = H5S_get_simple_extent_dims(dset->shared->space, dset->shared->curr_dims, + dset->shared->max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't cache dataspace dimensions") dset->shared->ndims = (unsigned)sndims; /* Compute the initial 'power2up' values */ - for(u = 0; u < dset->shared->ndims; u++) { - hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ + for (u = 0; u < dset->shared->ndims; u++) { + hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ - if( !(scaled_power2up = H5VM_power2up(dset->shared->curr_dims[u])) ) + if (!(scaled_power2up = H5VM_power2up(dset->shared->curr_dims[u]))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get the next power of 2") dset->shared->curr_power2up[u] = scaled_power2up; } @@ -680,7 +663,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__cache_dataspace_info() */ - /*------------------------------------------------------------------------- * Function: H5D__init_space * @@ -694,7 +676,7 @@ done: static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -704,26 +686,25 @@ H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space) HDassert(space); /* Copy dataspace for dataset */ - if(NULL == (dset->shared->space = H5S_copy(space, FALSE, TRUE))) + if (NULL == (dset->shared->space = H5S_copy(space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataspace") /* Cache the dataset's dataspace info */ - if(H5D__cache_dataspace_info(dset) < 0) + if (H5D__cache_dataspace_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") /* Set the version for dataspace */ - if(H5S_set_version(file, dset->shared->space) < 0) + if (H5S_set_version(file, dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype") /* Set the dataset's dataspace to 'all' selection */ - if(H5S_select_all(dset->shared->space, TRUE) < 0) + if (H5S_select_all(dset->shared->space, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set all selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_space() */ - /*------------------------------------------------------------------------- * Function: H5D__use_minimized_dset_headers * @@ -741,7 +722,7 @@ done: static herr_t H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -749,19 +730,19 @@ H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize) HDassert(minimize); /* Get the dataset object header minimize flag for this call */ - if(H5CX_get_dset_min_ohdr_flag(minimize) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset object header minimize flag from API context") + if (H5CX_get_dset_min_ohdr_flag(minimize) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't get dataset object header minimize flag from API context") - if(FALSE == *minimize) + if (FALSE == *minimize) *minimize = H5F_get_min_dset_ohdr(file); done: - if(FAIL == ret_value) + if (FAIL == ret_value) *minimize = FALSE; FUNC_LEAVE_NOAPI(ret_value); } /* H5D__use_minimized_dset_headers */ - /*------------------------------------------------------------------------- * Function: H5D__calculate_minimium_header_size * @@ -777,7 +758,7 @@ done: static size_t H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) { - H5T_t *type = NULL; + H5T_t * type = NULL; H5O_fill_t *fill_prop = NULL; hbool_t use_at_least_v18 = FALSE; const char continuation[1] = ""; /* requred for work-around */ @@ -790,8 +771,8 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) HDassert(dset); HDassert(ohdr); - type = dset->shared->type; - fill_prop = &(dset->shared->dcpl_cache.fill); + type = dset->shared->type; + fill_prop = &(dset->shared->dcpl_cache.fill); use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); /* Datatype message size */ @@ -828,7 +809,7 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) ret_value += get_value; /* Fill Value (backwards compatability) message size */ - if(fill_prop->buf && !use_at_least_v18) { + if (fill_prop->buf && !use_at_least_v18) { H5O_fill_t old_fill_prop; /* Copy for writing "old" fill value */ /* Shallow copy the fill value property */ @@ -840,14 +821,15 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) get_value = H5O_msg_size_oh(file, ohdr, H5O_FILL_ID, &old_fill_prop, 0); if (get_value == 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of fill value (backwards compat) message") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, + "can't get size of fill value (backwards compat) message") ret_value += get_value; } /* Filter/Pipeline message size */ - if(H5D_CHUNKED == dset->shared->layout.type) { + if (H5D_CHUNKED == dset->shared->layout.type) { H5O_pline_t *pline = &dset->shared->dcpl_cache.pline; - if(pline->nused > 0) { + if (pline->nused > 0) { get_value = H5O_msg_size_oh(file, ohdr, H5O_PLINE_ID, pline, 0); if (get_value == 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of filter message") @@ -856,7 +838,7 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) } /* External File Link message size */ - if(dset->shared->dcpl_cache.efl.nused > 0) { + if (dset->shared->dcpl_cache.efl.nused > 0) { get_value = H5O_msg_size_oh(file, ohdr, H5O_EFL_ID, &dset->shared->dcpl_cache.efl, 0); if (get_value == 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of external file link message") @@ -864,10 +846,10 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) } /* Modification Time message size */ - if(H5O_HDR_STORE_TIMES & H5O_OH_GET_FLAGS(ohdr)) { + if (H5O_HDR_STORE_TIMES & H5O_OH_GET_FLAGS(ohdr)) { HDassert(H5O_OH_GET_VERSION(ohdr) >= 1); /* 1 :: H5O_VERSION_1 (H5Opkg.h) */ - if(H5O_OH_GET_VERSION(ohdr) == 1) { + if (H5O_OH_GET_VERSION(ohdr) == 1) { /* v1 object headers store modification time as a message */ time_t mtime; get_value = H5O_msg_size_oh(file, ohdr, H5O_MTIME_NEW_ID, &mtime, 0); @@ -881,7 +863,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5D__calculate_minimum_header_size */ - /*------------------------------------------------------------------------- * Function: H5D__prepare_minimized_oh * @@ -898,9 +879,9 @@ done: static herr_t H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) { - H5O_t *oh = NULL; - size_t ohdr_size = 0; - herr_t ret_value = SUCCEED; + H5O_t *oh = NULL; + size_t ohdr_size = 0; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -909,22 +890,21 @@ H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) HDassert(oloc); oh = H5O__create_ohdr(file, dset->shared->dcpl_id); - if(NULL == oh) + if (NULL == oh) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't instantiate object header") ohdr_size = H5D__calculate_minimum_header_size(file, dset, oh); if (ohdr_size == 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "computed header size is invalid") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "computed header size is invalid") /* Special allocation of space for compact datsets is handled by the call here. */ - if(H5O__apply_ohdr(file, oh, dset->shared->dcpl_id, ohdr_size, (size_t)1, oloc) == FAIL) + if (H5O__apply_ohdr(file, oh, dset->shared->dcpl_id, ohdr_size, (size_t)1, oloc) == FAIL) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't apply object header to file") done: FUNC_LEAVE_NOAPI(ret_value); } /* H5D__prepare_minimized_oh */ - /*------------------------------------------------------------------------- * Function: H5D__update_oh_info * @@ -937,18 +917,18 @@ done: static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) { - H5O_t *oh = NULL; /* Pointer to dataset's object header */ - size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ - H5O_loc_t *oloc = NULL; /* Dataset's object location */ - H5O_layout_t *layout; /* Dataset's layout information */ - H5T_t *type; /* Dataset's datatype */ - H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ - H5D_fill_value_t fill_status; /* Fill value status */ - hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ - hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ - hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ - hbool_t use_minimized_header = FALSE; /* Flag to use minimized dataset object headers */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Pointer to dataset's object header */ + size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ + H5O_loc_t * oloc = NULL; /* Dataset's object location */ + H5O_layout_t * layout; /* Dataset's layout information */ + H5T_t * type; /* Dataset's datatype */ + H5O_fill_t * fill_prop; /* Pointer to dataset's fill value information */ + H5D_fill_value_t fill_status; /* Fill value status */ + hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ + hbool_t use_minimized_header = FALSE; /* Flag to use minimized dataset object headers */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -957,22 +937,22 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) HDassert(dset); /* Set some local variables, for convenience */ - oloc = &dset->oloc; - layout = &dset->shared->layout; - type = dset->shared->type; + oloc = &dset->oloc; + layout = &dset->shared->layout; + type = dset->shared->type; fill_prop = &dset->shared->dcpl_cache.fill; /* To use at least v18 format versions or not */ use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); /* Retrieve "defined" status of fill value */ - if(H5P_is_fill_value_defined(fill_prop, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill_prop, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Special case handling for variable-length types */ - if(H5T_detect_class(type, H5T_VLEN, FALSE)) { + if (H5T_detect_class(type, H5T_VLEN, FALSE)) { /* If the default fill value is chosen for variable-length types, always write it */ - if(fill_prop->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_DEFAULT) { + if (fill_prop->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_DEFAULT) { /* Update dataset creation property */ fill_prop->fill_time = H5D_FILL_TIME_ALLOC; @@ -981,81 +961,84 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) } /* end if */ /* Don't allow never writing fill values with variable-length types */ - if(fill_prop->fill_time == H5D_FILL_TIME_NEVER) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Dataset doesn't support VL datatype when fill value is not defined") + if (fill_prop->fill_time == H5D_FILL_TIME_NEVER) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "Dataset doesn't support VL datatype when fill value is not defined") } /* end if */ /* Determine whether fill value is defined or not */ - if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { + if (fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { /* Convert fill value buffer to dataset's datatype */ - if(fill_prop->buf && fill_prop->size > 0 && H5O_fill_convert(fill_prop, type, &fill_changed) < 0) + if (fill_prop->buf && fill_prop->size > 0 && H5O_fill_convert(fill_prop, type, &fill_changed) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert fill value to dataset type") fill_prop->fill_defined = TRUE; } - else if(fill_status == H5D_FILL_VALUE_UNDEFINED) + else if (fill_status == H5D_FILL_VALUE_UNDEFINED) fill_prop->fill_defined = FALSE; else HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine if fill value is defined") /* Check for invalid fill & allocation time setting */ - if(fill_prop->fill_defined == FALSE && fill_prop->fill_time == H5D_FILL_TIME_ALLOC) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "fill value writing on allocation set, but no fill value defined") + if (fill_prop->fill_defined == FALSE && fill_prop->fill_time == H5D_FILL_TIME_ALLOC) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "fill value writing on allocation set, but no fill value defined") /* Check if the fill value info changed */ - if(fill_changed) { - H5P_genplist_t *dc_plist; /* Dataset's creation property list */ + if (fill_changed) { + H5P_genplist_t *dc_plist; /* Dataset's creation property list */ /* Get dataset's property list object */ HDassert(dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT); - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Update dataset creation property */ - if(H5P_set(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) + if (H5P_set(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value info") } /* end if */ - if(H5D__use_minimized_dset_headers(file, &use_minimized_header) == FAIL) + if (H5D__use_minimized_dset_headers(file, &use_minimized_header) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get minimize settings") - if(TRUE == use_minimized_header) { - if(H5D__prepare_minimized_oh(file, dset, oloc) == FAIL) + if (TRUE == use_minimized_header) { + if (H5D__prepare_minimized_oh(file, dset, oloc) == FAIL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create minimized dataset object header") - } else { + } + else { /* Add the dataset's raw data size to the size of the header, if the * raw data will be stored as compact */ - if(H5D_COMPACT == layout->type) + if (H5D_COMPACT == layout->type) ohdr_size += layout->storage.u.compact.size; /* Create an object header for the dataset */ - if(H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc/*out*/) < 0) + if (H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") } /* if using default/minimized object headers */ HDassert(file == dset->oloc.file); /* Pin the object header */ - if(NULL == (oh = H5O_pin(oloc))) + if (NULL == (oh = H5O_pin(oloc))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") /* Write the dataspace header message */ - if(H5S_append(file, oh, dset->shared->space) < 0) + if (H5S_append(file, oh, dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update dataspace header message") /* Write the datatype header message */ - if(H5O_msg_append_oh(file, oh, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT, 0, type) < 0) + if (H5O_msg_append_oh(file, oh, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT, 0, type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update datatype header message") /* Write new fill value message */ - if(H5O_msg_append_oh(file, oh, H5O_FILL_NEW_ID, H5O_MSG_FLAG_CONSTANT, 0, fill_prop) < 0) + if (H5O_msg_append_oh(file, oh, H5O_FILL_NEW_ID, H5O_MSG_FLAG_CONSTANT, 0, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update new fill value header message") /* If there is valid information for the old fill value struct, add it */ /* (only if we aren't using v18 format versions and above */ - if(fill_prop->buf && !use_at_least_v18) { - H5O_fill_t old_fill_prop; /* Copy of fill value property, for writing as "old" fill value */ + if (fill_prop->buf && !use_at_least_v18) { + H5O_fill_t old_fill_prop; /* Copy of fill value property, for writing as "old" fill value */ /* Shallow copy the fill value property */ /* (we only want to make certain that the shared component isn't modified) */ @@ -1065,72 +1048,70 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) H5O_msg_reset_share(H5O_FILL_ID, &old_fill_prop); /* Write old fill value */ - if(H5O_msg_append_oh(file, oh, H5O_FILL_ID, H5O_MSG_FLAG_CONSTANT, 0, &old_fill_prop) < 0) + if (H5O_msg_append_oh(file, oh, H5O_FILL_ID, H5O_MSG_FLAG_CONSTANT, 0, &old_fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update old fill value header message") } /* end if */ /* Update/create the layout (and I/O pipeline & EFL) messages */ - if(H5D__layout_oh_create(file, oh, dset, dapl_id) < 0) + if (H5D__layout_oh_create(file, oh, dset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout/pline/efl header message") /* Indicate that the layout information was initialized */ layout_init = TRUE; #ifdef H5O_ENABLE_BOGUS -{ - H5P_genplist_t *dc_plist; /* Dataset's creation property list */ + { + H5P_genplist_t *dc_plist; /* Dataset's creation property list */ - /* Get dataset's property list object */ - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") + /* Get dataset's property list object */ + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") - /* Check whether to add a "bogus" message */ - if( (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME) > 0) && - (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_ID_NAME) > 0) ) { + /* Check whether to add a "bogus" message */ + if ((H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME) > 0) && + (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_ID_NAME) > 0)) { - uint8_t bogus_flags = 0; /* Flags for creating "bogus" message */ - unsigned bogus_id; /* "bogus" ID */ + uint8_t bogus_flags = 0; /* Flags for creating "bogus" message */ + unsigned bogus_id; /* "bogus" ID */ - /* Retrieve "bogus" message ID */ - if(H5P_get(dc_plist, H5O_BOGUS_MSG_ID_NAME, &bogus_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus ID options") - /* Retrieve "bogus" message flags */ - if(H5P_get(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus message options") + /* Retrieve "bogus" message ID */ + if (H5P_get(dc_plist, H5O_BOGUS_MSG_ID_NAME, &bogus_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus ID options") + /* Retrieve "bogus" message flags */ + if (H5P_get(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus message options") - /* Add a "bogus" message (for error testing). */ - if(H5O_bogus_oh(file, oh, bogus_id, (unsigned)bogus_flags) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create 'bogus' message") - } /* end if */ -} + /* Add a "bogus" message (for error testing). */ + if (H5O_bogus_oh(file, oh, bogus_id, (unsigned)bogus_flags) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create 'bogus' message") + } /* end if */ + } #endif /* H5O_ENABLE_BOGUS */ /* Add a modification time message, if using older format. */ /* (If using v18 format versions and above, the the modification time is part of the object * header and doesn't use a separate message -QAK) */ - if(!use_at_least_v18) - if(H5O_touch_oh(file, oh, TRUE) < 0) + if (!use_at_least_v18) + if (H5O_touch_oh(file, oh, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message") done: /* Release pointer to object header itself */ - if(oh != NULL) - if(H5O_unpin(oh) < 0) + if (oh != NULL) + if (H5O_unpin(oh) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") /* Error cleanup */ - if(ret_value < 0) - if(layout_init) + if (ret_value < 0) + if (layout_init) /* Destroy the layout information for the dataset */ - if(dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) + if (dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__update_oh_info() */ - - /*-------------------------------------------------------------------------- * Function: H5D__build_file_prefix * @@ -1144,12 +1125,12 @@ done: static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix /*out*/) { - const char *prefix = NULL; /* prefix used to look for the file */ - char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ - size_t filepath_len; /* length of file path */ - size_t prefix_len; /* length of prefix */ - size_t file_prefix_len; /* length of expanded prefix */ - herr_t ret_value = SUCCEED; /* Return value */ + const char *prefix = NULL; /* prefix used to look for the file */ + char * filepath = NULL; /* absolute path of directory the HDF5 file is in */ + size_t filepath_len; /* length of file path */ + size_t prefix_len; /* length of prefix */ + size_t file_prefix_len; /* length of expanded prefix */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1162,19 +1143,19 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(H5F_PREFIX_VDS == prefix_type) { + if (H5F_PREFIX_VDS == prefix_type) { prefix = H5D_prefix_vds_env; - if(prefix == NULL || *prefix == '\0') { - if(H5CX_get_vds_prefix(&prefix) < 0) + if (prefix == NULL || *prefix == '\0') { + if (H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } } - else if(H5F_PREFIX_EFILE == prefix_type) { + else if (H5F_PREFIX_EFILE == prefix_type) { prefix = H5D_prefix_ext_env; - if(prefix == NULL || *prefix == '\0') { - if(H5CX_get_ext_file_prefix(&prefix) < 0) + if (prefix == NULL || *prefix == '\0') { + if (H5CX_get_ext_file_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for the external file") } } @@ -1184,34 +1165,33 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** /* Prefix has to be checked for NULL / empty string again because the * code above might have updated it. */ - if(prefix == NULL || *prefix == '\0' || HDstrcmp(prefix, ".") == 0) { + if (prefix == NULL || *prefix == '\0' || HDstrcmp(prefix, ".") == 0) { /* filename is interpreted as relative to the current directory, * does not need to be expanded */ *file_prefix = NULL; } /* end if */ else { - if(HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { + if (HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { /* Replace ${ORIGIN} at beginning of prefix by directory of HDF5 file */ - filepath_len = HDstrlen(filepath); - prefix_len = HDstrlen(prefix); + filepath_len = HDstrlen(filepath); + prefix_len = HDstrlen(prefix); file_prefix_len = filepath_len + prefix_len - HDstrlen("${ORIGIN}") + 1; - if(NULL == (*file_prefix = (char *)H5MM_malloc(file_prefix_len))) + if (NULL == (*file_prefix = (char *)H5MM_malloc(file_prefix_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate buffer") HDsnprintf(*file_prefix, file_prefix_len, "%s%s", filepath, prefix + HDstrlen("${ORIGIN}")); } /* end if */ else { - if(NULL == (*file_prefix = (char *)H5MM_strdup(prefix))) + if (NULL == (*file_prefix = (char *)H5MM_strdup(prefix))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__build_file_prefix() */ - /*------------------------------------------------------------------------- * Function: H5D__create * @@ -1228,21 +1208,20 @@ done: *------------------------------------------------------------------------- */ H5D_t * -H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, - hid_t dapl_id) +H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id) { - H5T_t *type = NULL; /* Datatype for dataset (VOL pointer) */ - H5T_t *dt = NULL; /* Datatype for dataset (non-VOL pointer) */ - H5D_t *new_dset = NULL; - H5P_genplist_t *dc_plist = NULL; /* New Property list */ - hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */ - hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ - hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ - hbool_t fill_copied = FALSE; /* Flag to indicate that fill-value message was copied */ - hbool_t pline_copied = FALSE; /* Flag to indicate that pipeline message was copied */ - hbool_t efl_copied = FALSE; /* Flag to indicate that external file list message was copied */ - H5G_loc_t dset_loc; /* Dataset location */ - H5D_t *ret_value = NULL; /* Return value */ + H5T_t * type = NULL; /* Datatype for dataset (VOL pointer) */ + H5T_t * dt = NULL; /* Datatype for dataset (non-VOL pointer) */ + H5D_t * new_dset = NULL; + H5P_genplist_t *dc_plist = NULL; /* New Property list */ + hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ + hbool_t fill_copied = FALSE; /* Flag to indicate that fill-value message was copied */ + hbool_t pline_copied = FALSE; /* Flag to indicate that pipeline message was copied */ + hbool_t efl_copied = FALSE; /* Flag to indicate that external file list message was copied */ + H5G_loc_t dset_loc; /* Dataset location */ + H5D_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1253,26 +1232,26 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HDassert(H5I_GENPROP_LST == H5I_get_type(dcpl_id)); /* Get the dataset's datatype */ - if(NULL == (dt = (H5T_t *)H5I_object(type_id))) + if (NULL == (dt = (H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") /* If this is a named datatype, get the pointer via the VOL plugin */ type = H5T_get_actual_type(dt); /* Check if the datatype is "sensible" for use in a dataset */ - if(H5T_is_sensible(type) != TRUE) + if (H5T_is_sensible(type) != TRUE) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") /* Check if the datatype is/contains a VL-type */ - if(H5T_detect_class(type, H5T_VLEN, FALSE)) + if (H5T_detect_class(type, H5T_VLEN, FALSE)) has_vl_type = TRUE; /* Check if the dataspace has an extent set (or is NULL) */ - if(!H5S_has_extent(space)) + if (!H5S_has_extent(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "dataspace extent has not been set.") /* Initialize the dataset object */ - if(NULL == (new_dset = H5FL_CALLOC(H5D_t))) + if (NULL == (new_dset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set up & reset dataset location */ @@ -1281,123 +1260,125 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, H5G_loc_reset(&dset_loc); /* Initialize the shared dataset space */ - if(NULL == (new_dset->shared = H5D__new(dcpl_id, dapl_id, TRUE, has_vl_type))) + if (NULL == (new_dset->shared = H5D__new(dcpl_id, dapl_id, TRUE, has_vl_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy & initialize datatype for dataset */ - if(H5D__init_type(file, new_dset, type_id, type) < 0) + if (H5D__init_type(file, new_dset, type_id, type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy datatype") /* Copy & initialize dataspace for dataset */ - if(H5D__init_space(file, new_dset, space) < 0) + if (H5D__init_space(file, new_dset, space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy dataspace") /* Set the dataset's checked_filters flag to enable writing */ new_dset->shared->checked_filters = TRUE; /* Check if the dataset has a non-default DCPL & get important values, if so */ - if(new_dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) { - H5O_layout_t *layout; /* Dataset's layout information */ - H5O_pline_t *pline; /* Dataset's I/O pipeline information */ - H5O_fill_t *fill; /* Dataset's fill value info */ - H5O_efl_t *efl; /* Dataset's external file list info */ + if (new_dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) { + H5O_layout_t *layout; /* Dataset's layout information */ + H5O_pline_t * pline; /* Dataset's I/O pipeline information */ + H5O_fill_t * fill; /* Dataset's fill value info */ + H5O_efl_t * efl; /* Dataset's external file list info */ /* Check if the filters in the DCPL can be applied to this dataset */ - if(H5Z_can_apply(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) + if (H5Z_can_apply(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "I/O filters can't operate on this dataset") /* Make the "set local" filter callbacks for this dataset */ - if(H5Z_set_local(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) + if (H5Z_set_local(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") /* Get new dataset's property list object */ - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(new_dset->shared->dcpl_id))) + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(new_dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") /* Retrieve the properties we need */ pline = &new_dset->shared->dcpl_cache.pline; - if(H5P_get(dc_plist, H5O_CRT_PIPELINE_NAME, pline) < 0) + if (H5P_get(dc_plist, H5O_CRT_PIPELINE_NAME, pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve pipeline filter") pline_copied = TRUE; - layout = &new_dset->shared->layout; - if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, layout) < 0) + layout = &new_dset->shared->layout; + if (H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve layout") layout_copied = TRUE; - fill = &new_dset->shared->dcpl_cache.fill; - if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill) < 0) + fill = &new_dset->shared->dcpl_cache.fill; + if (H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve fill value info") fill_copied = TRUE; - efl = &new_dset->shared->dcpl_cache.efl; - if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, efl) < 0) + efl = &new_dset->shared->dcpl_cache.efl; + if (H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve external file list") efl_copied = TRUE; /* Check that chunked layout is used if filters are enabled */ - if(pline->nused > 0 && H5D_CHUNKED != layout->type) + if (pline->nused > 0 && H5D_CHUNKED != layout->type) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "filters can only be used with chunked layout") /* Check if the alloc_time is the default and error out */ - if(fill->alloc_time == H5D_ALLOC_TIME_DEFAULT) + if (fill->alloc_time == H5D_ALLOC_TIME_DEFAULT) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "invalid space allocation state") /* Don't allow compact datasets to allocate space later */ - if(layout->type == H5D_COMPACT && fill->alloc_time != H5D_ALLOC_TIME_EARLY) + if (layout->type == H5D_COMPACT && fill->alloc_time != H5D_ALLOC_TIME_EARLY) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset must have early space allocation") } /* end if */ /* Set the version for the I/O pipeline message */ - if(H5O_pline_set_version(file, &new_dset->shared->dcpl_cache.pline) < 0) + if (H5O_pline_set_version(file, &new_dset->shared->dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of I/O filter pipeline") /* Set the version for the fill message */ - if(H5O_fill_set_version(file, &new_dset->shared->dcpl_cache.fill) < 0) + if (H5O_fill_set_version(file, &new_dset->shared->dcpl_cache.fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of fill value") /* Set the latest version for the layout message */ - if(H5D__layout_set_version(file, &new_dset->shared->layout) < 0) + if (H5D__layout_set_version(file, &new_dset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of layout") - if(new_dset->shared->layout.version >= H5O_LAYOUT_VERSION_4) { + if (new_dset->shared->layout.version >= H5O_LAYOUT_VERSION_4) { /* Use latest indexing type for layout message version >= 4 */ - if(H5D__layout_set_latest_indexing(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) + if (H5D__layout_set_latest_indexing(&new_dset->shared->layout, new_dset->shared->space, + &new_dset->shared->dcpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest indexing") } /* end if */ /* Check if this dataset is going into a parallel file and set space allocation time */ - if(H5F_HAS_FEATURE(file, H5FD_FEAT_ALLOCATE_EARLY)) + if (H5F_HAS_FEATURE(file, H5FD_FEAT_ALLOCATE_EARLY)) new_dset->shared->dcpl_cache.fill.alloc_time = H5D_ALLOC_TIME_EARLY; /* Set the dataset's I/O operations */ - if(H5D__layout_set_io_ops(new_dset) < 0) + if (H5D__layout_set_io_ops(new_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize I/O operations") /* Create the layout information for the new dataset */ - if(new_dset->shared->layout.ops->construct && (new_dset->shared->layout.ops->construct)(file, new_dset) < 0) + if (new_dset->shared->layout.ops->construct && + (new_dset->shared->layout.ops->construct)(file, new_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to construct layout information") /* Update the dataset's object header info. */ - if(H5D__update_oh_info(file, new_dset, new_dset->shared->dapl_id) < 0) + if (H5D__update_oh_info(file, new_dset, new_dset->shared->dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update the metadata cache") /* Indicate that the layout information was initialized */ layout_init = TRUE; /* Set up append flush parameters for the dataset */ - if(H5D__append_flush_setup(new_dset, new_dset->shared->dapl_id) < 0) + if (H5D__append_flush_setup(new_dset, new_dset->shared->dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") /* Set the external file prefix */ - if(H5D__build_file_prefix(new_dset, H5F_PREFIX_EFILE, &new_dset->shared->extfile_prefix) < 0) + if (H5D__build_file_prefix(new_dset, H5F_PREFIX_EFILE, &new_dset->shared->extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Set the VDS file prefix */ - if(H5D__build_file_prefix(new_dset, H5F_PREFIX_VDS, &new_dset->shared->vds_prefix) < 0) + if (H5D__build_file_prefix(new_dset, H5F_PREFIX_VDS, &new_dset->shared->vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Add the dataset to the list of opened objects in the file */ - if(H5FO_top_incr(new_dset->oloc.file, new_dset->oloc.addr) < 0) + if (H5FO_top_incr(new_dset->oloc.file, new_dset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't incr object ref. count") - if(H5FO_insert(new_dset->oloc.file, new_dset->oloc.addr, new_dset->shared, TRUE) < 0) + if (H5FO_insert(new_dset->oloc.file, new_dset->oloc.addr, new_dset->shared, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") new_dset->shared->fo_count = 1; @@ -1405,63 +1386,63 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, ret_value = new_dset; done: - if(!ret_value && new_dset) { - if(new_dset->shared) { - if(layout_init) - if(new_dset->shared->layout.ops->dest && (new_dset->shared->layout.ops->dest)(new_dset) < 0) + if (!ret_value && new_dset) { + if (new_dset->shared) { + if (layout_init) + if (new_dset->shared->layout.ops->dest && (new_dset->shared->layout.ops->dest)(new_dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy layout info") - if(pline_copied) - if(H5O_msg_reset(H5O_PLINE_ID, &new_dset->shared->dcpl_cache.pline) < 0) + if (pline_copied) + if (H5O_msg_reset(H5O_PLINE_ID, &new_dset->shared->dcpl_cache.pline) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset I/O pipeline info") - if(layout_copied) - if(H5O_msg_reset(H5O_LAYOUT_ID, &new_dset->shared->layout) < 0) + if (layout_copied) + if (H5O_msg_reset(H5O_LAYOUT_ID, &new_dset->shared->layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset layout info") - if(fill_copied) - if(H5O_msg_reset(H5O_FILL_ID, &new_dset->shared->dcpl_cache.fill) < 0) + if (fill_copied) + if (H5O_msg_reset(H5O_FILL_ID, &new_dset->shared->dcpl_cache.fill) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset fill-value info") - if(efl_copied) - if(H5O_msg_reset(H5O_EFL_ID, &new_dset->shared->dcpl_cache.efl) < 0) + if (efl_copied) + if (H5O_msg_reset(H5O_EFL_ID, &new_dset->shared->dcpl_cache.efl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset external file list info") - if(new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) + if (new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") - if(new_dset->shared->type) { - if(new_dset->shared->type_id > 0) { - if(H5I_dec_ref(new_dset->shared->type_id) < 0) + if (new_dset->shared->type) { + if (new_dset->shared->type_id > 0) { + if (H5I_dec_ref(new_dset->shared->type_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") } /* end if */ else { - if(H5T_close_real(new_dset->shared->type) < 0) + if (H5T_close_real(new_dset->shared->type) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") } /* end else */ - } /* end if */ + } /* end if */ - if(H5F_addr_defined(new_dset->oloc.addr)) { - if(H5O_dec_rc_by_loc(&(new_dset->oloc)) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - if(H5O_close(&(new_dset->oloc), NULL) < 0) + if (H5F_addr_defined(new_dset->oloc.addr)) { + if (H5O_dec_rc_by_loc(&(new_dset->oloc)) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, + "unable to decrement refcount on newly created object") + if (H5O_close(&(new_dset->oloc), NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") - if(file) { - if(H5O_delete(file, new_dset->oloc.addr) < 0) + if (file) { + if (H5O_delete(file, new_dset->oloc.addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header") } /* end if */ - } /* end if */ - if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) + } /* end if */ + if (new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") - if(new_dset->shared->dapl_id != 0 && H5I_dec_ref(new_dset->shared->dapl_id) < 0) + if (new_dset->shared->dapl_id != 0 && H5I_dec_ref(new_dset->shared->dapl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix); - new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); - new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); + new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); + new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); } /* end if */ new_dset->oloc.file = NULL; - new_dset = H5FL_FREE(H5D_t, new_dset); + new_dset = H5FL_FREE(H5D_t, new_dset); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create() */ - /*------------------------------------------------------------------------- * Function: H5D__open_name * @@ -1474,13 +1455,13 @@ done: H5D_t * H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id) { - H5D_t *dset = NULL; - H5G_loc_t dset_loc; /* Object location of dataset */ - H5G_name_t path; /* Dataset group hier. path */ - H5O_loc_t oloc; /* Dataset object location */ - H5O_type_t obj_type; /* Type of object at location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ - H5D_t *ret_value = NULL; /* Return value */ + H5D_t * dset = NULL; + H5G_loc_t dset_loc; /* Object location of dataset */ + H5G_name_t path; /* Dataset group hier. path */ + H5O_loc_t oloc; /* Dataset object location */ + H5O_type_t obj_type; /* Type of object at location */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + H5D_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1494,32 +1475,31 @@ H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id) H5G_loc_reset(&dset_loc); /* Find the dataset object */ - if(H5G_loc_find(loc, name, &dset_loc) < 0) + if (H5G_loc_find(loc, name, &dset_loc) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") loc_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type) < 0) + if (H5O_obj_type(&oloc, &obj_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get object type") - if(obj_type != H5O_TYPE_DATASET) + if (obj_type != H5O_TYPE_DATASET) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, NULL, "not a dataset") /* Open the dataset */ - if(NULL == (dset = H5D_open(&dset_loc, dapl_id))) + if (NULL == (dset = H5D_open(&dset_loc, dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't open dataset") /* Set return value */ ret_value = dset; done: - if(!ret_value) - if(loc_found && H5G_loc_free(&dset_loc) < 0) + if (!ret_value) + if (loc_found && H5G_loc_free(&dset_loc) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__open_name() */ - /* *------------------------------------------------------------------------- * Function: H5D_open @@ -1534,11 +1514,11 @@ done: H5D_t * H5D_open(const H5G_loc_t *loc, hid_t dapl_id) { - H5D_shared_t *shared_fo = NULL; - H5D_t *dataset = NULL; - char *extfile_prefix = NULL; /* Expanded external file prefix */ - char *vds_prefix = NULL; /* Expanded vds prefix */ - H5D_t *ret_value = NULL; /* Return value */ + H5D_shared_t *shared_fo = NULL; + H5D_t * dataset = NULL; + char * extfile_prefix = NULL; /* Expanded external file prefix */ + char * vds_prefix = NULL; /* Expanded vds prefix */ + H5D_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1546,40 +1526,40 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) HDassert(loc); /* Allocate the dataset structure */ - if(NULL == (dataset = H5FL_CALLOC(H5D_t))) + if (NULL == (dataset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Shallow copy (take ownership) of the object location object */ - if(H5O_loc_copy_shallow(&(dataset->oloc), loc->oloc) < 0) + if (H5O_loc_copy_shallow(&(dataset->oloc), loc->oloc) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy object location") /* Shallow copy (take ownership) of the group hier. path */ - if(H5G_name_copy(&(dataset->path), loc->path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(dataset->path), loc->path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path") /* Get the external file prefix */ - if(H5D__build_file_prefix(dataset, H5F_PREFIX_EFILE, &extfile_prefix) < 0) + if (H5D__build_file_prefix(dataset, H5F_PREFIX_EFILE, &extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Get the VDS prefix */ - if(H5D__build_file_prefix(dataset, H5F_PREFIX_VDS, &vds_prefix) < 0) + if (H5D__build_file_prefix(dataset, H5F_PREFIX_VDS, &vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Check if dataset was already open */ - if(NULL == (shared_fo = (H5D_shared_t *)H5FO_opened(dataset->oloc.file, dataset->oloc.addr))) { + if (NULL == (shared_fo = (H5D_shared_t *)H5FO_opened(dataset->oloc.file, dataset->oloc.addr))) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open the dataset object */ - if(H5D__open_oid(dataset, dapl_id) < 0) + if (H5D__open_oid(dataset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") /* Add the dataset to the list of opened objects in the file */ - if(H5FO_insert(dataset->oloc.file, dataset->oloc.addr, dataset->shared, FALSE) < 0) + if (H5FO_insert(dataset->oloc.file, dataset->oloc.addr, dataset->shared, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") /* Increment object count for the object in the top file */ - if(H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count") /* We're the first dataset to use the the shared info */ @@ -1606,23 +1586,28 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) /* Check whether the external file prefix of the already open dataset * matches the new external file prefix */ - if(extfile_prefix && dataset->shared->extfile_prefix) { - if(HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset") - } else { - if(extfile_prefix || dataset->shared->extfile_prefix) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset") + if (extfile_prefix && dataset->shared->extfile_prefix) { + if (HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0) + HGOTO_ERROR( + H5E_DATASET, H5E_CANTOPENOBJ, NULL, + "new external file prefix does not match external file prefix of already open dataset") + } + else { + if (extfile_prefix || dataset->shared->extfile_prefix) + HGOTO_ERROR( + H5E_DATASET, H5E_CANTOPENOBJ, NULL, + "new external file prefix does not match external file prefix of already open dataset") } /* Check if the object has been opened through the top file yet */ - if(H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { + if (H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { /* Open the object through this top file */ - if(H5O_open(&(dataset->oloc)) < 0) + if (H5O_open(&(dataset->oloc)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ @@ -1631,15 +1616,15 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) done: extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - vds_prefix = (char *)H5MM_xfree(vds_prefix); + vds_prefix = (char *)H5MM_xfree(vds_prefix); - if(ret_value == NULL) { + if (ret_value == NULL) { /* Free the location--casting away const*/ - if(dataset) { - if(shared_fo == NULL && dataset->shared) { /* Need to free shared fo */ + if (dataset) { + if (shared_fo == NULL && dataset->shared) { /* Need to free shared fo */ dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); - dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); - dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); + dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); + dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); } H5O_loc_free(&(dataset->oloc)); @@ -1647,14 +1632,13 @@ done: dataset = H5FL_FREE(H5D_t, dataset); } /* end if */ - if(shared_fo) + if (shared_fo) shared_fo->fo_count--; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_open() */ - /* *------------------------------------------------------------------------- * Function: H5D__flush_append_setup @@ -1667,7 +1651,7 @@ done: static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -1676,60 +1660,60 @@ H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id) HDassert(dset->shared); /* Set default append flush values */ - HDmemset(&dset->shared->append_flush, 0, sizeof(dset->shared->append_flush)); + HDmemset(&dset->shared->append_flush, 0, sizeof(dset->shared->append_flush)); /* If the dataset is chunked and there is a non-default DAPL */ - if(dapl_id != H5P_DATASET_ACCESS_DEFAULT && dset->shared->layout.type == H5D_CHUNKED) { - H5P_genplist_t *dapl; /* data access property list object pointer */ + if (dapl_id != H5P_DATASET_ACCESS_DEFAULT && dset->shared->layout.type == H5D_CHUNKED) { + H5P_genplist_t *dapl; /* data access property list object pointer */ /* Get dataset access property list */ - if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + if (NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for dapl ID"); /* Check if append flush property exists */ - if(H5P_exist_plist(dapl, H5D_ACS_APPEND_FLUSH_NAME) > 0) { + if (H5P_exist_plist(dapl, H5D_ACS_APPEND_FLUSH_NAME) > 0) { H5D_append_flush_t info; /* Get append flush property */ - if(H5P_get(dapl, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) + if (H5P_get(dapl, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get append flush info") - if(info.ndims > 0) { - hsize_t curr_dims[H5S_MAX_RANK]; /* current dimension sizes */ - hsize_t max_dims[H5S_MAX_RANK]; /* current dimension sizes */ - int rank; /* dataspace # of dimensions */ - unsigned u; /* local index variable */ + if (info.ndims > 0) { + hsize_t curr_dims[H5S_MAX_RANK]; /* current dimension sizes */ + hsize_t max_dims[H5S_MAX_RANK]; /* current dimension sizes */ + int rank; /* dataspace # of dimensions */ + unsigned u; /* local index variable */ /* Get dataset rank */ - if((rank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, max_dims)) < 0) + if ((rank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") - if(info.ndims != (unsigned)rank) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "boundary dimension rank does not match dataset rank") + if (info.ndims != (unsigned)rank) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, + "boundary dimension rank does not match dataset rank") /* Validate boundary sizes */ - for(u = 0; u < info.ndims; u++) - if(info.boundary[u] != 0) /* when a non-zero boundary is set */ + for (u = 0; u < info.ndims; u++) + if (info.boundary[u] != 0) /* when a non-zero boundary is set */ /* the dimension is extendible? */ - if(max_dims[u] != H5S_UNLIMITED && max_dims[u] == curr_dims[u]) + if (max_dims[u] != H5S_UNLIMITED && max_dims[u] == curr_dims[u]) break; /* At least one boundary dimension is not extendible */ - if(u != info.ndims) + if (u != info.ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "boundary dimension is not valid") /* Copy append flush settings */ dset->shared->append_flush.ndims = info.ndims; - dset->shared->append_flush.func = info.func; + dset->shared->append_flush.func = info.func; dset->shared->append_flush.udata = info.udata; H5MM_memcpy(dset->shared->append_flush.boundary, info.boundary, sizeof(info.boundary)); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__append_flush_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__open_oid * @@ -1741,12 +1725,12 @@ done: static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id) { - H5P_genplist_t *plist; /* Property list */ - H5O_fill_t *fill_prop; /* Pointer to dataset's fill value info */ - unsigned alloc_time_state; /* Allocation time state */ - htri_t msg_exists; /* Whether a particular type of message exists */ - hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_fill_t * fill_prop; /* Pointer to dataset's fill value info */ + unsigned alloc_time_state; /* Allocation time state */ + htri_t msg_exists; /* Whether a particular type of message exists */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dataset->oloc.addr) @@ -1754,67 +1738,67 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) HDassert(dataset); /* (Set the 'vl_type' parameter to FALSE since it doesn't matter from here) */ - if(NULL == (dataset->shared = H5D__new(H5P_DATASET_CREATE_DEFAULT, dapl_id, FALSE, FALSE))) + if (NULL == (dataset->shared = H5D__new(H5P_DATASET_CREATE_DEFAULT, dapl_id, FALSE, FALSE))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Open the dataset object */ - if(H5O_open(&(dataset->oloc)) < 0) + if (H5O_open(&(dataset->oloc)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open") /* Get the type and space */ - if(NULL == (dataset->shared->type = (H5T_t *)H5O_msg_read(&(dataset->oloc), H5O_DTYPE_ID, NULL))) + if (NULL == (dataset->shared->type = (H5T_t *)H5O_msg_read(&(dataset->oloc), H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load type info from dataset header") - if(H5T_set_loc(dataset->shared->type, H5F_VOL_OBJ(dataset->oloc.file), H5T_LOC_DISK) < 0) + if (H5T_set_loc(dataset->shared->type, H5F_VOL_OBJ(dataset->oloc.file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") - if(NULL == (dataset->shared->space = H5S_read(&(dataset->oloc)))) + if (NULL == (dataset->shared->space = H5S_read(&(dataset->oloc)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") /* Cache the dataset's dataspace info */ - if(H5D__cache_dataspace_info(dataset) < 0) + if (H5D__cache_dataspace_info(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") /* Get a datatype ID for the dataset's datatype */ - if((dataset->shared->type_id = H5I_register(H5I_DATATYPE, dataset->shared->type, FALSE)) < 0) + if ((dataset->shared->type_id = H5I_register(H5I_DATATYPE, dataset->shared->type, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") /* Get dataset creation property list object */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dataset->shared->dcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dataset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Get the layout/pline/efl message information */ - if(H5D__layout_oh_read(dataset, dapl_id, plist) < 0) + if (H5D__layout_oh_read(dataset, dapl_id, plist) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout/pline/efl info") /* Indicate that the layout information was initialized */ layout_init = TRUE; /* Set up flush append property */ - if(H5D__append_flush_setup(dataset, dapl_id)) + if (H5D__append_flush_setup(dataset, dapl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set up flush append property") /* Point at dataset's copy, to cache it for later */ fill_prop = &dataset->shared->dcpl_cache.fill; /* Try to get the new fill value message from the object header */ - if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_NEW_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_NEW_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") - if(msg_exists) { - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_FILL_NEW_ID, fill_prop)) + if (msg_exists) { + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_FILL_NEW_ID, fill_prop)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") } /* end if */ else { - /* For backward compatibility, try to retrieve the old fill value message */ - if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_ID)) < 0) + /* For backward compatibility, try to retrieve the old fill value message */ + if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") - if(msg_exists) { - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_FILL_ID, fill_prop)) + if (msg_exists) { + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_FILL_ID, fill_prop)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") } /* end if */ else { /* Set the space allocation time appropriately, based on the type of dataset storage */ - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_COMPACT: fill_prop->alloc_time = H5D_ALLOC_TIME_EARLY; break; @@ -1836,24 +1820,24 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "not implemented yet") } /* end switch */ /*lint !e788 All appropriate cases are covered */ - } /* end else */ + } /* end else */ /* If "old" fill value size is 0 (undefined), map it to -1 */ - if(fill_prop->size == 0) + if (fill_prop->size == 0) fill_prop->size = (ssize_t)-1; } /* end if */ alloc_time_state = 0; - if((dataset->shared->layout.type == H5D_COMPACT && fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) - || (dataset->shared->layout.type == H5D_CONTIGUOUS && fill_prop->alloc_time == H5D_ALLOC_TIME_LATE) - || (dataset->shared->layout.type == H5D_CHUNKED && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR) - || (dataset->shared->layout.type == H5D_VIRTUAL && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR)) + if ((dataset->shared->layout.type == H5D_COMPACT && fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) || + (dataset->shared->layout.type == H5D_CONTIGUOUS && fill_prop->alloc_time == H5D_ALLOC_TIME_LATE) || + (dataset->shared->layout.type == H5D_CHUNKED && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR) || + (dataset->shared->layout.type == H5D_VIRTUAL && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR)) alloc_time_state = 1; /* Set revised fill value properties, if they are different from the defaults */ - if(H5P_fill_value_cmp(&H5D_def_dset.dcpl_cache.fill, fill_prop, sizeof(H5O_fill_t))) { - if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) + if (H5P_fill_value_cmp(&H5D_def_dset.dcpl_cache.fill, fill_prop, sizeof(H5O_fill_t))) { + if (H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set fill value") - if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + if (H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set allocation time state") } /* end if */ @@ -1862,44 +1846,43 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) * This is important only for parallel I/O where the space must * be fully allocated before I/O can happen. */ - if((H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR) - && !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) - && H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_ALLOCATE_EARLY)) { + if ((H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR) && + !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) && + H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_ALLOCATE_EARLY)) { H5D_io_info_t io_info; io_info.dset = dataset; - if(H5D__alloc_storage(&io_info, H5D_ALLOC_OPEN, FALSE, NULL) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_OPEN, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file storage") } /* end if */ done: - if(ret_value < 0) { - if(H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc), NULL) < 0) + if (ret_value < 0) { + if (H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc), NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") - if(dataset->shared) { - if(layout_init) - if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) + if (dataset->shared) { + if (layout_init) + if (dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") - if(dataset->shared->space && H5S_close(dataset->shared->space) < 0) + if (dataset->shared->space && H5S_close(dataset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(dataset->shared->type) { - if(dataset->shared->type_id > 0) { - if(H5I_dec_ref(dataset->shared->type_id) < 0) + if (dataset->shared->type) { + if (dataset->shared->type_id > 0) { + if (H5I_dec_ref(dataset->shared->type_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ else { - if(H5T_close_real(dataset->shared->type) < 0) + if (H5T_close_real(dataset->shared->type) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end else */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__open_oid() */ - /*------------------------------------------------------------------------- * Function: H5D_close * @@ -1913,10 +1896,10 @@ done: herr_t H5D_close(H5D_t *dataset) { - hbool_t free_failed = FALSE; /* Set if freeing sub-components failed */ - hbool_t corked; /* Whether the dataset is corked or not */ - hbool_t file_closed = TRUE; /* H5O_close also closed the file? */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t free_failed = FALSE; /* Set if freeing sub-components failed */ + hbool_t corked; /* Whether the dataset is corked or not */ + hbool_t file_closed = TRUE; /* H5O_close also closed the file? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1930,10 +1913,10 @@ H5D_close(H5D_t *dataset) #endif /* H5D_CHUNK_DEBUG */ dataset->shared->fo_count--; - if(dataset->shared->fo_count == 0) { + if (dataset->shared->fo_count == 0) { /* Flush the dataset's information. Continue to close even if it fails. */ - if(H5D__flush_real(dataset) < 0) + if (H5D__flush_real(dataset) < 0) HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") /* Set a flag to indicate the dataset is closing, before we start freeing things */ @@ -1943,30 +1926,32 @@ H5D_close(H5D_t *dataset) dataset->shared->closing = TRUE; /* Free cached information for each kind of dataset */ - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CONTIGUOUS: /* Free the data sieve buffer, if it's been allocated */ - if(dataset->shared->cache.contig.sieve_buf) - dataset->shared->cache.contig.sieve_buf = (unsigned char *)H5FL_BLK_FREE(sieve_buf,dataset->shared->cache.contig.sieve_buf); + if (dataset->shared->cache.contig.sieve_buf) + dataset->shared->cache.contig.sieve_buf = + (unsigned char *)H5FL_BLK_FREE(sieve_buf, dataset->shared->cache.contig.sieve_buf); break; case H5D_CHUNKED: /* Check for skip list for iterating over chunks during I/O to close */ - if(dataset->shared->cache.chunk.sel_chunks) { + if (dataset->shared->cache.chunk.sel_chunks) { HDassert(H5SL_count(dataset->shared->cache.chunk.sel_chunks) == 0); H5SL_close(dataset->shared->cache.chunk.sel_chunks); dataset->shared->cache.chunk.sel_chunks = NULL; } /* end if */ /* Check for cached single chunk dataspace */ - if(dataset->shared->cache.chunk.single_space) { + if (dataset->shared->cache.chunk.single_space) { (void)H5S_close(dataset->shared->cache.chunk.single_space); dataset->shared->cache.chunk.single_space = NULL; } /* end if */ /* Check for cached single element chunk info */ - if(dataset->shared->cache.chunk.single_chunk_info) { - dataset->shared->cache.chunk.single_chunk_info = H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); + if (dataset->shared->cache.chunk.single_chunk_info) { + dataset->shared->cache.chunk.single_chunk_info = + H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); dataset->shared->cache.chunk.single_chunk_info = NULL; } /* end if */ break; @@ -1975,32 +1960,35 @@ H5D_close(H5D_t *dataset) /* Nothing special to do (info freed in the layout destroy) */ break; - case H5D_VIRTUAL: - { + case H5D_VIRTUAL: { size_t i, j; - HDassert(dataset->shared->layout.storage.u.virt.list || (dataset->shared->layout.storage.u.virt.list_nused == 0)); + HDassert(dataset->shared->layout.storage.u.virt.list || + (dataset->shared->layout.storage.u.virt.list_nused == 0)); /* Close source datasets */ - for(i = 0; i < dataset->shared->layout.storage.u.virt.list_nused; i++) { + for (i = 0; i < dataset->shared->layout.storage.u.virt.list_nused; i++) { /* Close source dataset */ - if(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) { + if (dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) { HDassert(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset != dataset); - if(H5D_close(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) < 0) + if (H5D_close(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") dataset->shared->layout.storage.u.virt.list[i].source_dset.dset = NULL; } /* end if */ /* Close sub datasets */ - for(j = 0; j < dataset->shared->layout.storage.u.virt.list[i].sub_dset_nused; j++) - if(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) { - HDassert(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset != dataset); - if(H5D_close(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") + for (j = 0; j < dataset->shared->layout.storage.u.virt.list[i].sub_dset_nused; j++) + if (dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) { + HDassert(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset != + dataset); + if (H5D_close(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) < + 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to close source dataset") dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset = NULL; } /* end if */ - } /* end for */ - } /* end block */ + } /* end for */ + } /* end block */ break; case H5D_LAYOUT_ERROR: @@ -2009,11 +1997,11 @@ H5D_close(H5D_t *dataset) HDassert("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Destroy any cached layout information for the dataset */ - if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) + if (dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") /* Free the external file prefix */ @@ -2023,43 +2011,42 @@ H5D_close(H5D_t *dataset) dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); /* Release layout, fill-value, efl & pipeline messages */ - if(dataset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) + if (dataset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) free_failed |= (H5O_msg_reset(H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline) < 0) || - (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) || - (H5O_msg_reset(H5O_FILL_ID, &dataset->shared->dcpl_cache.fill) < 0) || - (H5O_msg_reset(H5O_EFL_ID, &dataset->shared->dcpl_cache.efl) < 0); + (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) || + (H5O_msg_reset(H5O_FILL_ID, &dataset->shared->dcpl_cache.fill) < 0) || + (H5O_msg_reset(H5O_EFL_ID, &dataset->shared->dcpl_cache.efl) < 0); /* Uncork cache entries with object address tag */ - if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) + if (corked) + if (H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* Release datatype, dataspace, and creation and access property lists -- there isn't * much we can do if one of these fails, so we just continue. */ - free_failed |= (H5I_dec_ref(dataset->shared->type_id) < 0) || - (H5S_close(dataset->shared->space) < 0) || - (H5I_dec_ref(dataset->shared->dcpl_id) < 0) || - (H5I_dec_ref(dataset->shared->dapl_id) < 0); + free_failed |= + (H5I_dec_ref(dataset->shared->type_id) < 0) || (H5S_close(dataset->shared->space) < 0) || + (H5I_dec_ref(dataset->shared->dcpl_id) < 0) || (H5I_dec_ref(dataset->shared->dapl_id) < 0); /* Remove the dataset from the list of opened objects in the file */ - if(H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") - if(H5FO_delete(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_delete(dataset->oloc.file, dataset->oloc.addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") /* Close the dataset object */ /* (This closes the file, if this is the last object open) */ - if(H5O_close(&(dataset->oloc), &file_closed) < 0) + if (H5O_close(&(dataset->oloc), &file_closed) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") /* Evict dataset metadata if evicting on close */ - if(!file_closed && H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) { - if(H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr) < 0) + if (!file_closed && H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) { + if (H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") - if(H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, FALSE) < 0) + if (H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, FALSE) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict tagged metadata") } /* end if */ @@ -2070,41 +2057,41 @@ H5D_close(H5D_t *dataset) * above). */ dataset->oloc.file = NULL; - dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); + dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); } /* end if */ else { /* Decrement the ref. count for this object in the top file */ - if(H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Check reference count for this object in the top file */ - if(H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { - if(H5O_close(&(dataset->oloc), NULL) < 0) + if (H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { + if (H5O_close(&(dataset->oloc), NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to close") } /* end if */ else /* Free object location (i.e. "unhold" the file if appropriate) */ - if(H5O_loc_free(&(dataset->oloc)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "problem attempting to free location") + if (H5O_loc_free(&(dataset->oloc)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "problem attempting to free location") } /* end else */ /* Release the dataset's path info */ - if(H5G_name_free(&(dataset->path)) < 0) + if (H5G_name_free(&(dataset->path)) < 0) free_failed = TRUE; /* Free the dataset's memory structure */ dataset = H5FL_FREE(H5D_t, dataset); /* Check if anything failed in the middle... */ - if(free_failed) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free a component of the dataset, but the dataset was freed anyway.") + if (free_failed) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "couldn't free a component of the dataset, but the dataset was freed anyway.") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_close() */ - /*------------------------------------------------------------------------- * Function: H5D_mult_refresh_close * @@ -2117,12 +2104,12 @@ done: herr_t H5D_mult_refresh_close(hid_t dset_id) { - H5D_t *dataset; /* Dataset to refresh */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dataset; /* Dataset to refresh */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) - if(NULL == (dataset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) + if (NULL == (dataset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* check args */ @@ -2131,32 +2118,34 @@ H5D_mult_refresh_close(hid_t dset_id) HDassert(dataset->shared); HDassert(dataset->shared->fo_count > 0); - if(dataset->shared->fo_count > 1) { + if (dataset->shared->fo_count > 1) { /* Free cached information for each kind of dataset */ - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CONTIGUOUS: /* Free the data sieve buffer, if it's been allocated */ - if(dataset->shared->cache.contig.sieve_buf) - dataset->shared->cache.contig.sieve_buf = (unsigned char *)H5FL_BLK_FREE(sieve_buf,dataset->shared->cache.contig.sieve_buf); + if (dataset->shared->cache.contig.sieve_buf) + dataset->shared->cache.contig.sieve_buf = + (unsigned char *)H5FL_BLK_FREE(sieve_buf, dataset->shared->cache.contig.sieve_buf); break; case H5D_CHUNKED: /* Check for skip list for iterating over chunks during I/O to close */ - if(dataset->shared->cache.chunk.sel_chunks) { + if (dataset->shared->cache.chunk.sel_chunks) { HDassert(H5SL_count(dataset->shared->cache.chunk.sel_chunks) == 0); H5SL_close(dataset->shared->cache.chunk.sel_chunks); dataset->shared->cache.chunk.sel_chunks = NULL; } /* end if */ /* Check for cached single chunk dataspace */ - if(dataset->shared->cache.chunk.single_space) { + if (dataset->shared->cache.chunk.single_space) { (void)H5S_close(dataset->shared->cache.chunk.single_space); dataset->shared->cache.chunk.single_space = NULL; } /* end if */ /* Check for cached single element chunk info */ - if(dataset->shared->cache.chunk.single_chunk_info) { - dataset->shared->cache.chunk.single_chunk_info = H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); + if (dataset->shared->cache.chunk.single_chunk_info) { + dataset->shared->cache.chunk.single_chunk_info = + H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); dataset->shared->cache.chunk.single_chunk_info = NULL; } /* end if */ break; @@ -2172,11 +2161,11 @@ H5D_mult_refresh_close(hid_t dset_id) HDassert("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Destroy any cached layout information for the dataset */ - if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) + if (dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") } /* end if */ @@ -2184,7 +2173,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_mult_refresh_close() */ - /*------------------------------------------------------------------------- * Function: H5D_mult_refresh_reopen * @@ -2197,7 +2185,7 @@ done: herr_t H5D_mult_refresh_reopen(H5D_t *dataset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2205,25 +2193,25 @@ H5D_mult_refresh_reopen(H5D_t *dataset) HDassert(dataset && dataset->oloc.file && dataset->shared); HDassert(dataset->shared->fo_count > 0); - if(dataset->shared->fo_count > 1) { + if (dataset->shared->fo_count > 1) { /* Release dataspace info */ - if(H5S_close(dataset->shared->space) < 0) + if (H5S_close(dataset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") /* Re-load dataspace info */ - if(NULL == (dataset->shared->space = H5S_read(&(dataset->oloc)))) + if (NULL == (dataset->shared->space = H5S_read(&(dataset->oloc)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") /* Cache the dataset's dataspace info */ - if(H5D__cache_dataspace_info(dataset) < 0) + if (H5D__cache_dataspace_info(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") /* Release layout info */ - if(H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) + if (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info") /* Re-load layout message info */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout))) + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") } /* end if */ @@ -2231,7 +2219,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D_mult_refresh_reopen() */ - /*------------------------------------------------------------------------- * Function: H5D_oloc * @@ -2250,7 +2237,6 @@ H5D_oloc(H5D_t *dataset) FUNC_LEAVE_NOAPI(dataset ? &(dataset->oloc) : (H5O_loc_t *)NULL) } /* end H5D_oloc() */ - /*------------------------------------------------------------------------- * Function: H5D_nameof * @@ -2269,7 +2255,6 @@ H5D_nameof(const H5D_t *dataset) FUNC_LEAVE_NOAPI(dataset ? &(dataset->path) : NULL) } /* end H5D_nameof() */ - /*------------------------------------------------------------------------- * Function: H5D__alloc_storage * @@ -2279,15 +2264,15 @@ H5D_nameof(const H5D_t *dataset) *------------------------------------------------------------------------- */ herr_t -H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, - hbool_t full_overwrite, hsize_t old_dim[]) +H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, hbool_t full_overwrite, + hsize_t old_dim[]) { - const H5D_t *dset = io_info->dset; /* The dataset object */ - H5F_t *f = dset->oloc.file; /* The dataset's file pointer */ - H5O_layout_t *layout; /* The dataset's layout information */ - hbool_t must_init_space = FALSE; /* Flag to indicate that space should be initialized */ - hbool_t addr_set = FALSE; /* Flag to indicate that the dataset's storage address was set */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_t * dset = io_info->dset; /* The dataset object */ + H5F_t * f = dset->oloc.file; /* The dataset's file pointer */ + H5O_layout_t *layout; /* The dataset's layout information */ + hbool_t must_init_space = FALSE; /* Flag to indicate that space should be initialized */ + hbool_t addr_set = FALSE; /* Flag to indicate that the dataset's storage address was set */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2299,17 +2284,17 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, * We assume that external storage is already * allocated by the caller, or at least will be before I/O is performed. */ - if(!(0 == H5S_GET_EXTENT_NPOINTS(dset->shared->space) || dset->shared->dcpl_cache.efl.nused > 0)) { + if (!(0 == H5S_GET_EXTENT_NPOINTS(dset->shared->space) || dset->shared->dcpl_cache.efl.nused > 0)) { /* Get a pointer to the dataset's layout information */ layout = &(dset->shared->layout); - switch(layout->type) { + switch (layout->type) { case H5D_CONTIGUOUS: - if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { + if (!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { /* Check if we have a zero-sized dataset */ - if(layout->storage.u.contig.size > 0) { + if (layout->storage.u.contig.size > 0) { /* Reserve space in the file for the entire array */ - if(H5D__contig_alloc(f, &layout->storage.u.contig/*out*/) < 0) + if (H5D__contig_alloc(f, &layout->storage.u.contig /*out*/) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage") /* Indicate that we should initialize storage space */ @@ -2324,9 +2309,9 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, break; case H5D_CHUNKED: - if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { + if (!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { /* Create the root of the index that manages chunked storage */ - if(H5D__chunk_create(dset /*in,out*/) < 0) + if (H5D__chunk_create(dset /*in,out*/) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") /* Indicate that we set the storage addr */ @@ -2340,21 +2325,24 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, * the dataset, indicate that space should be allocated, so the * index gets expanded. -QAK */ - if(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY && time_alloc == H5D_ALLOC_EXTEND) + if (dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY && + time_alloc == H5D_ALLOC_EXTEND) must_init_space = TRUE; break; case H5D_COMPACT: /* Check if space is already allocated */ - if(NULL == layout->storage.u.compact.buf) { + if (NULL == layout->storage.u.compact.buf) { /* Reserve space in layout header message for the entire array. * Starting from the 1.8.7 release, we allow dataspace to have * zero dimension size. So the storage size can be zero. * SLU 2011/4/4 */ - if(layout->storage.u.compact.size > 0) { - if(NULL == (layout->storage.u.compact.buf = H5MM_malloc(layout->storage.u.compact.size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for compact dataset") - if(!full_overwrite) + if (layout->storage.u.compact.size > 0) { + if (NULL == + (layout->storage.u.compact.buf = H5MM_malloc(layout->storage.u.compact.size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate memory for compact dataset") + if (!full_overwrite) HDmemset(layout->storage.u.compact.buf, 0, layout->storage.u.compact.size); layout->storage.u.compact.dirty = TRUE; @@ -2363,7 +2351,7 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, } else { layout->storage.u.compact.dirty = FALSE; - must_init_space = FALSE; + must_init_space = FALSE; } } /* end if */ break; @@ -2383,12 +2371,12 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, HDassert("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Check if we need to initialize the space */ - if(must_init_space) { - if(layout->type == H5D_CHUNKED) { + if (must_init_space) { + if (layout->type == H5D_CHUNKED) { /* If we are doing incremental allocation and the index got * created during a H5Dwrite call, don't initialize the storage * now, wait for the actual writes to each block and let the @@ -2398,25 +2386,29 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, * fill values to the chunks they allocate space for. Yes, * this is icky. -QAK */ - if(!(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_INCR && time_alloc == H5D_ALLOC_WRITE)) - if(H5D__init_storage(io_info, full_overwrite, old_dim) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") + if (!(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_INCR && + time_alloc == H5D_ALLOC_WRITE)) + if (H5D__init_storage(io_info, full_overwrite, old_dim) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize dataset with fill value") } /* end if */ else { - H5D_fill_value_t fill_status; /* The fill value status */ + H5D_fill_value_t fill_status; /* The fill value status */ /* Check the dataset's fill-value status */ - if(H5P_is_fill_value_defined(&dset->shared->dcpl_cache.fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(&dset->shared->dcpl_cache.fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are filling the dataset on allocation or "if set" and * the fill value _is_ set, do that now */ - if(dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || - (dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED)) - if(H5D__init_storage(io_info, full_overwrite, old_dim) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") + if (dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || + (dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET && + fill_status == H5D_FILL_VALUE_USER_DEFINED)) + if (H5D__init_storage(io_info, full_overwrite, old_dim) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize dataset with fill value") } /* end else */ - } /* end if */ + } /* end if */ /* If we set the address (and aren't in the middle of creating the * dataset), mark the layout header message for later writing to @@ -2425,9 +2417,9 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, /* (The layout message is already in the dataset's object header, this * operation just sets the address and makes it constant) */ - if(time_alloc != H5D_ALLOC_CREATE && addr_set) + if (time_alloc != H5D_ALLOC_CREATE && addr_set) /* Mark the layout as dirty, for later writing to the file */ - if(H5D__mark(dset, H5D_MARK_LAYOUT) < 0) + if (H5D__mark(dset, H5D_MARK_LAYOUT) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark dataspace as dirty") } /* end if */ @@ -2435,7 +2427,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__alloc_storage() */ - /*------------------------------------------------------------------------- * Function: H5D__init_storage * @@ -2449,8 +2440,8 @@ done: static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]) { - const H5D_t *dset = io_info->dset; /* dataset pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_t *dset = io_info->dset; /* dataset pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2459,18 +2450,20 @@ H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t switch (dset->shared->layout.type) { case H5D_COMPACT: /* If we will be immediately overwriting the values, don't bother to clear them */ - if(!full_overwrite) { + if (!full_overwrite) { /* Fill the compact dataset storage */ - if(H5D__compact_fill(dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize compact dataset storage") + if (H5D__compact_fill(dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize compact dataset storage") } /* end if */ break; case H5D_CONTIGUOUS: /* Don't write default fill values to external files */ /* If we will be immediately overwriting the values, don't bother to clear them */ - if((dset->shared->dcpl_cache.efl.nused == 0 || dset->shared->dcpl_cache.fill.buf) && !full_overwrite) - if(H5D__contig_fill(io_info) < 0) + if ((dset->shared->dcpl_cache.efl.nused == 0 || dset->shared->dcpl_cache.fill.buf) && + !full_overwrite) + if (H5D__contig_fill(io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") break; @@ -2480,13 +2473,13 @@ H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t * for all chunks now and initialize each chunk with the fill value. */ { - hsize_t zero_dim[H5O_LAYOUT_NDIMS] = {0}; + hsize_t zero_dim[H5O_LAYOUT_NDIMS] = {0}; /* Use zeros for old dimensions if not specified */ - if(old_dim == NULL) + if (old_dim == NULL) old_dim = zero_dim; - if(H5D__chunk_allocate(io_info, full_overwrite, old_dim) < 0) + if (H5D__chunk_allocate(io_info, full_overwrite, old_dim) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") break; } /* end block */ @@ -2500,14 +2493,13 @@ H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t HDassert("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_storage() */ - /*------------------------------------------------------------------------- * Function: H5D__get_storage_size * @@ -2520,15 +2512,16 @@ done: herr_t H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) - switch(dset->shared->layout.type) { + switch (dset->shared->layout.type) { case H5D_CHUNKED: - if((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { - if(H5D__chunk_allocated(dset, storage_size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve chunked dataset allocated size") + if ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { + if (H5D__chunk_allocated(dset, storage_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't retrieve chunked dataset allocated size") } /* end if */ else *storage_size = 0; @@ -2536,7 +2529,7 @@ H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size) case H5D_CONTIGUOUS: /* Datasets which are not allocated yet are using no space on disk */ - if((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) + if ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) *storage_size = dset->shared->layout.storage.u.contig.size; else *storage_size = 0; @@ -2562,7 +2555,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_storage_size() */ - /*------------------------------------------------------------------------- * Function: H5D__get_offset * @@ -2578,13 +2570,13 @@ done: haddr_t H5D__get_offset(const H5D_t *dset) { - haddr_t ret_value = HADDR_UNDEF; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_PACKAGE HDassert(dset); - switch(dset->shared->layout.type) { + switch (dset->shared->layout.type) { case H5D_VIRTUAL: case H5D_CHUNKED: case H5D_COMPACT: @@ -2594,7 +2586,8 @@ H5D__get_offset(const H5D_t *dset) /* If dataspace hasn't been allocated or dataset is stored in * an external file, the value will be HADDR_UNDEF. */ - if(dset->shared->dcpl_cache.efl.nused == 0 || H5F_addr_defined(dset->shared->layout.storage.u.contig.addr)) + if (dset->shared->dcpl_cache.efl.nused == 0 || + H5F_addr_defined(dset->shared->layout.storage.u.contig.addr)) /* Return the absolute dataset offset from the beginning of file. */ ret_value = dset->shared->layout.storage.u.contig.addr + H5F_BASE_ADDR(dset->oloc.file); break; @@ -2609,7 +2602,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_offset() */ - /*------------------------------------------------------------------------- * Function: H5D__vlen_get_buf_size_alloc * @@ -2626,13 +2618,14 @@ static void * H5D__vlen_get_buf_size_alloc(size_t size, void *info) { H5D_vlen_bufsize_common_t *vlen_bufsize_com = (H5D_vlen_bufsize_common_t *)info; - void *ret_value = NULL; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check for increasing the size of the temporary space for VL data */ - if(size > vlen_bufsize_com->vl_tbuf_size) { - if(NULL == (vlen_bufsize_com->vl_tbuf = H5FL_BLK_REALLOC(vlen_vl_buf, vlen_bufsize_com->vl_tbuf, size))) + if (size > vlen_bufsize_com->vl_tbuf_size) { + if (NULL == + (vlen_bufsize_com->vl_tbuf = H5FL_BLK_REALLOC(vlen_vl_buf, vlen_bufsize_com->vl_tbuf, size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't reallocate temporary VL data buffer") vlen_bufsize_com->vl_tbuf_size = size; } /* end if */ @@ -2647,7 +2640,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__vlen_get_buf_size_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__vlen_get_buf_size_cb * @@ -2658,11 +2650,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__vlen_get_buf_size_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, - unsigned H5_ATTR_UNUSED ndim, const hsize_t *point, void *op_data) +H5D__vlen_get_buf_size_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, + const hsize_t *point, void *op_data) { H5D_vlen_bufsize_native_t *vlen_bufsize = (H5D_vlen_bufsize_native_t *)op_data; - herr_t ret_value = H5_ITER_CONT; /* Return value */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -2672,18 +2664,18 @@ H5D__vlen_get_buf_size_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, HDassert(op_data); /* Select point to read in */ - if(H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) + if (H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, H5_ITER_ERROR, "can't select point") /* Read in the point (with the custom VL memory allocator) */ - if(H5D__read(vlen_bufsize->dset, type_id, vlen_bufsize->mspace, vlen_bufsize->fspace, vlen_bufsize->common.fl_tbuf) < 0) + if (H5D__read(vlen_bufsize->dset, type_id, vlen_bufsize->mspace, vlen_bufsize->fspace, + vlen_bufsize->common.fl_tbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, H5_ITER_ERROR, "can't read point") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__vlen_get_buf_size_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__vlen_get_buf_size * @@ -2709,80 +2701,78 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, - hsize_t *size) +H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, hsize_t *size) { H5D_vlen_bufsize_native_t vlen_bufsize = {NULL, NULL, NULL, {NULL, NULL, 0, 0}}; - H5S_t *fspace = NULL; /* Dataset's dataspace */ - H5S_t *mspace = NULL; /* Memory dataspace */ - char bogus; /* bogus value to pass to H5Diterate() */ - H5S_t *space; /* Dataspace for iteration */ - H5T_t *type; /* Datatype */ - H5S_sel_iter_op_t dset_op; /* Operator for iteration */ - herr_t ret_value = FAIL; /* Return value */ + H5S_t * fspace = NULL; /* Dataset's dataspace */ + H5S_t * mspace = NULL; /* Memory dataspace */ + char bogus; /* bogus value to pass to H5Diterate() */ + H5S_t * space; /* Dataspace for iteration */ + H5T_t * type; /* Datatype */ + H5S_sel_iter_op_t dset_op; /* Operator for iteration */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (type = (H5T_t *)H5I_object(type_id))) + if (NULL == (type = (H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") - if(NULL == (space = (H5S_t *)H5I_object(space_id))) + if (NULL == (space = (H5S_t *)H5I_object(space_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") /* Save the dataset */ vlen_bufsize.dset = dset; /* Get a copy of the dataset's dataspace */ - if(NULL == (fspace = H5S_copy(dset->shared->space, FALSE, TRUE))) + if (NULL == (fspace = H5S_copy(dset->shared->space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to get dataspace") vlen_bufsize.fspace = fspace; /* Create a scalar for the memory dataspace */ - if(NULL == (mspace = H5S_create(H5S_SCALAR))) + if (NULL == (mspace = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") vlen_bufsize.mspace = mspace; /* Grab the temporary buffers required */ - if(NULL == (vlen_bufsize.common.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, H5T_get_size(type)))) + if (NULL == (vlen_bufsize.common.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, H5T_get_size(type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") - if(NULL == (vlen_bufsize.common.vl_tbuf = H5FL_BLK_MALLOC(vlen_vl_buf, (size_t)1))) + if (NULL == (vlen_bufsize.common.vl_tbuf = H5FL_BLK_MALLOC(vlen_vl_buf, (size_t)1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") vlen_bufsize.common.vl_tbuf_size = 1; /* Set the memory manager to the special allocation routine */ - if(H5CX_set_vlen_alloc_info(H5D__vlen_get_buf_size_alloc, &vlen_bufsize.common, NULL, NULL) < 0) + if (H5CX_set_vlen_alloc_info(H5D__vlen_get_buf_size_alloc, &vlen_bufsize.common, NULL, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set VL data allocation routine") /* Set the initial number of bytes required */ vlen_bufsize.common.size = 0; /* Call H5S_select_iterate with args, etc. */ - dset_op.op_type = H5S_SEL_ITER_OP_APP; - dset_op.u.app_op.op = H5D__vlen_get_buf_size_cb; - dset_op.u.app_op.type_id = type_id; + dset_op.op_type = H5S_SEL_ITER_OP_APP; + dset_op.u.app_op.op = H5D__vlen_get_buf_size_cb; + dset_op.u.app_op.type_id = type_id; ret_value = H5S_select_iterate(&bogus, type, space, &dset_op, &vlen_bufsize); /* Get the size if we succeeded */ - if(ret_value >= 0) + if (ret_value >= 0) *size = vlen_bufsize.common.size; done: - if(fspace && H5S_close(fspace) < 0) + if (fspace && H5S_close(fspace) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - if(mspace && H5S_close(mspace) < 0) + if (mspace && H5S_close(mspace) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - if(vlen_bufsize.common.fl_tbuf != NULL) + if (vlen_bufsize.common.fl_tbuf != NULL) vlen_bufsize.common.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.common.fl_tbuf); - if(vlen_bufsize.common.vl_tbuf != NULL) + if (vlen_bufsize.common.vl_tbuf != NULL) vlen_bufsize.common.vl_tbuf = H5FL_BLK_FREE(vlen_vl_buf, vlen_bufsize.common.vl_tbuf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__vlen_get_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5D__vlen_get_buf_size_gen_cb * @@ -2805,12 +2795,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__vlen_get_buf_size_gen_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, - unsigned H5_ATTR_UNUSED ndim, const hsize_t *point, void *op_data) +H5D__vlen_get_buf_size_gen_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, + const hsize_t *point, void *op_data) { H5D_vlen_bufsize_generic_t *vlen_bufsize = (H5D_vlen_bufsize_generic_t *)op_data; - H5T_t *dt; /* Datatype for operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * dt; /* Datatype for operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2819,26 +2809,28 @@ H5D__vlen_get_buf_size_gen_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, HDassert(op_data); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object(type_id))) + if (NULL == (dt = (H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a datatype") /* Make certain there is enough fixed-length buffer available */ - if(NULL == (vlen_bufsize->common.fl_tbuf = H5FL_BLK_REALLOC(vlen_fl_buf, vlen_bufsize->common.fl_tbuf, H5T_get_size(dt)))) + if (NULL == (vlen_bufsize->common.fl_tbuf = + H5FL_BLK_REALLOC(vlen_fl_buf, vlen_bufsize->common.fl_tbuf, H5T_get_size(dt)))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't resize tbuf") /* Select point to read in */ - if(H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) + if (H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't select point") /* Read in the point (with the custom VL memory allocator) */ - if(H5VL_dataset_read(vlen_bufsize->dset_vol_obj, type_id, vlen_bufsize->mspace_id, vlen_bufsize->fspace_id, vlen_bufsize->dxpl_id, vlen_bufsize->common.fl_tbuf, H5_REQUEST_NULL) < 0) + if (H5VL_dataset_read(vlen_bufsize->dset_vol_obj, type_id, vlen_bufsize->mspace_id, + vlen_bufsize->fspace_id, vlen_bufsize->dxpl_id, vlen_bufsize->common.fl_tbuf, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__vlen_get_buf_size_gen_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__vlen_get_buf_size_gen * @@ -2853,105 +2845,105 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id, - hsize_t *size) +H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id, hsize_t *size) { - H5D_vlen_bufsize_generic_t vlen_bufsize = {NULL, H5I_INVALID_HID, NULL, H5I_INVALID_HID, H5I_INVALID_HID, {NULL, NULL, 0, 0}}; - H5P_genplist_t *dxpl = NULL; /* DXPL for operation */ - H5S_t *mspace = NULL; /* Memory dataspace */ - char bogus; /* Bogus value to pass to H5Diterate() */ - H5S_t *space; /* Dataspace for iteration */ - H5T_t *type; /* Datatype */ - H5S_sel_iter_op_t dset_op; /* Operator for iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_vlen_bufsize_generic_t vlen_bufsize = { + NULL, H5I_INVALID_HID, NULL, H5I_INVALID_HID, H5I_INVALID_HID, {NULL, NULL, 0, 0}}; + H5P_genplist_t * dxpl = NULL; /* DXPL for operation */ + H5S_t * mspace = NULL; /* Memory dataspace */ + char bogus; /* Bogus value to pass to H5Diterate() */ + H5S_t * space; /* Dataspace for iteration */ + H5T_t * type; /* Datatype */ + H5S_sel_iter_op_t dset_op; /* Operator for iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (type = (H5T_t *)H5I_object(type_id))) + if (NULL == (type = (H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not an valid datatype") - if(NULL == (space = (H5S_t *)H5I_object(space_id))) + if (NULL == (space = (H5S_t *)H5I_object(space_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "invalid dataspace") - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dataspace does not have extent set") /* Save the dataset */ vlen_bufsize.dset_vol_obj = vol_obj; /* Get a copy of the dataset's dataspace */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &vlen_bufsize.fspace_id) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &vlen_bufsize.fspace_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace") - if(NULL == (vlen_bufsize.fspace = (H5S_t *)H5I_object(vlen_bufsize.fspace_id))) + if (NULL == (vlen_bufsize.fspace = (H5S_t *)H5I_object(vlen_bufsize.fspace_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataspace") /* Create a scalar for the memory dataspace */ - if(NULL == (mspace = H5S_create(H5S_SCALAR))) + if (NULL == (mspace = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create dataspace") - if((vlen_bufsize.mspace_id = H5I_register(H5I_DATASPACE, mspace, TRUE)) < 0) + if ((vlen_bufsize.mspace_id = H5I_register(H5I_DATASPACE, mspace, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") /* Grab the temporary buffers required */ - if(NULL == (vlen_bufsize.common.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, H5T_get_size(type)))) + if (NULL == (vlen_bufsize.common.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, H5T_get_size(type)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "no temporary buffers available") - if(NULL == (vlen_bufsize.common.vl_tbuf = H5FL_BLK_MALLOC(vlen_vl_buf, (size_t)1))) + if (NULL == (vlen_bufsize.common.vl_tbuf = H5FL_BLK_MALLOC(vlen_vl_buf, (size_t)1))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "no temporary buffers available") vlen_bufsize.common.vl_tbuf_size = 1; /* Set the VL allocation callbacks on a DXPL */ - if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(H5P_DATASET_XFER_DEFAULT))) + if (NULL == (dxpl = (H5P_genplist_t *)H5I_object(H5P_DATASET_XFER_DEFAULT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get default DXPL") - if((vlen_bufsize.dxpl_id = H5P_copy_plist(dxpl, TRUE)) < 0) + if ((vlen_bufsize.dxpl_id = H5P_copy_plist(dxpl, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy property list"); - if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(vlen_bufsize.dxpl_id))) + if (NULL == (dxpl = (H5P_genplist_t *)H5I_object(vlen_bufsize.dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get copied DXPL") - if(H5P_set_vlen_mem_manager(dxpl, H5D__vlen_get_buf_size_alloc, &vlen_bufsize.common, NULL, NULL) < 0) + if (H5P_set_vlen_mem_manager(dxpl, H5D__vlen_get_buf_size_alloc, &vlen_bufsize.common, NULL, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set VL data allocation routine on DXPL") /* Set the initial number of bytes required */ vlen_bufsize.common.size = 0; /* Call H5S_select_iterate with args, etc. */ - dset_op.op_type = H5S_SEL_ITER_OP_APP; - dset_op.u.app_op.op = H5D__vlen_get_buf_size_gen_cb; - dset_op.u.app_op.type_id = type_id; + dset_op.op_type = H5S_SEL_ITER_OP_APP; + dset_op.u.app_op.op = H5D__vlen_get_buf_size_gen_cb; + dset_op.u.app_op.type_id = type_id; ret_value = H5S_select_iterate(&bogus, type, space, &dset_op, &vlen_bufsize); /* Get the size if we succeeded */ - if(ret_value >= 0) + if (ret_value >= 0) *size = vlen_bufsize.common.size; done: - if(vlen_bufsize.fspace_id >= 0) { - if(H5I_dec_app_ref(vlen_bufsize.fspace_id) < 0) + if (vlen_bufsize.fspace_id >= 0) { + if (H5I_dec_app_ref(vlen_bufsize.fspace_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "problem freeing id") vlen_bufsize.fspace = NULL; } /* end if */ - if(vlen_bufsize.fspace && H5S_close(vlen_bufsize.fspace) < 0) + if (vlen_bufsize.fspace && H5S_close(vlen_bufsize.fspace) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - if(vlen_bufsize.mspace_id >= 0) { - if(H5I_dec_app_ref(vlen_bufsize.mspace_id) < 0) + if (vlen_bufsize.mspace_id >= 0) { + if (H5I_dec_app_ref(vlen_bufsize.mspace_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "problem freeing id") mspace = NULL; } /* end if */ - if(mspace && H5S_close(mspace) < 0) + if (mspace && H5S_close(mspace) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - if(vlen_bufsize.common.fl_tbuf != NULL) + if (vlen_bufsize.common.fl_tbuf != NULL) vlen_bufsize.common.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.common.fl_tbuf); - if(vlen_bufsize.common.vl_tbuf != NULL) + if (vlen_bufsize.common.vl_tbuf != NULL) vlen_bufsize.common.vl_tbuf = H5FL_BLK_FREE(vlen_vl_buf, vlen_bufsize.common.vl_tbuf); - if(vlen_bufsize.dxpl_id != H5I_INVALID_HID) { - if(H5I_dec_app_ref(vlen_bufsize.dxpl_id) < 0) + if (vlen_bufsize.dxpl_id != H5I_INVALID_HID) { + if (H5I_dec_app_ref(vlen_bufsize.dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close property list") dxpl = NULL; } /* end if */ - if(dxpl && H5P_close(dxpl) < 0) + if (dxpl && H5P_close(dxpl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release DXPL") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__vlen_get_buf_size_gen() */ - /*------------------------------------------------------------------------- * Function: H5D__check_filters * @@ -2963,8 +2955,8 @@ done: herr_t H5D__check_filters(H5D_t *dataset) { - H5O_fill_t *fill; /* Dataset's fill value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_fill_t *fill; /* Dataset's fill value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2977,31 +2969,30 @@ H5D__check_filters(H5D_t *dataset) * that requires writing on an extend. */ fill = &dataset->shared->dcpl_cache.fill; - if(!dataset->shared->checked_filters) { - H5D_fill_value_t fill_status; /* Whether the fill value is defined */ + if (!dataset->shared->checked_filters) { + H5D_fill_value_t fill_status; /* Whether the fill value is defined */ /* Retrieve the "defined" status of the fill value */ - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset.") /* See if we can check the filter status */ - if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { - if(fill->fill_time == H5D_FILL_TIME_ALLOC || - (fill->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED)) { + if (fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { + if (fill->fill_time == H5D_FILL_TIME_ALLOC || + (fill->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED)) { /* Filters must have encoding enabled. Ensure that all filters can be applied */ - if(H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) < 0) + if (H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") dataset->shared->checked_filters = TRUE; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__check_filters() */ - /*------------------------------------------------------------------------- * Function: H5D__set_extent * @@ -3014,11 +3005,11 @@ done: herr_t H5D__set_extent(H5D_t *dset, const hsize_t *size) { - hsize_t curr_dims[H5S_MAX_RANK]; /* Current dimension sizes */ - htri_t changed; /* Whether the dataspace changed size */ - size_t u, v; /* Local index variable */ - unsigned dim_idx; /* Dimension index */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t curr_dims[H5S_MAX_RANK]; /* Current dimension sizes */ + htri_t changed; /* Whether the dataspace changed size */ + size_t u, v; /* Local index variable */ + unsigned dim_idx; /* Dimension index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -3027,17 +3018,18 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) HDassert(size); /* Check if we are allowed to modify this file */ - if(0 == (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file") - /* Check if we are allowed to modify the space; only datasets with chunked and external storage are allowed to be modified */ - if(H5D_COMPACT == dset->shared->layout.type) + /* Check if we are allowed to modify the space; only datasets with chunked and external storage are + * allowed to be modified */ + if (H5D_COMPACT == dset->shared->layout.type) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataset has compact storage") - if(H5D_CONTIGUOUS == dset->shared->layout.type && 0 == dset->shared->dcpl_cache.efl.nused) + if (H5D_CONTIGUOUS == dset->shared->layout.type && 0 == dset->shared->dcpl_cache.efl.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "dataset has contiguous storage") /* Check if the filters in the DCPL will need to encode, and if so, can they? */ - if(H5D__check_filters(dset) < 0) + if (H5D__check_filters(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't apply filters") /* Keep the current dataspace dimensions for later */ @@ -3045,61 +3037,63 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) H5MM_memcpy(curr_dims, dset->shared->curr_dims, H5S_MAX_RANK * sizeof(curr_dims[0])); /* Modify the size of the dataspace */ - if((changed = H5S_set_extent(dset->shared->space, size)) < 0) + if ((changed = H5S_set_extent(dset->shared->space, size)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") /* Don't bother updating things, unless they've changed */ - if(changed) { - hbool_t shrink = FALSE; /* Flag to indicate a dimension has shrank */ - hbool_t expand = FALSE; /* Flag to indicate a dimension has grown */ - hbool_t update_chunks = FALSE; /* Flag to indicate chunk cache update is needed */ + if (changed) { + hbool_t shrink = FALSE; /* Flag to indicate a dimension has shrank */ + hbool_t expand = FALSE; /* Flag to indicate a dimension has grown */ + hbool_t update_chunks = FALSE; /* Flag to indicate chunk cache update is needed */ /* Determine if we are shrinking and/or expanding any dimensions */ - for(dim_idx = 0; dim_idx < dset->shared->ndims; dim_idx++) { + for (dim_idx = 0; dim_idx < dset->shared->ndims; dim_idx++) { /* Check for various status changes */ - if(size[dim_idx] < curr_dims[dim_idx]) + if (size[dim_idx] < curr_dims[dim_idx]) shrink = TRUE; - if(size[dim_idx] > curr_dims[dim_idx]) + if (size[dim_idx] > curr_dims[dim_idx]) expand = TRUE; /* Chunked storage specific checks */ - if(H5D_CHUNKED == dset->shared->layout.type && dset->shared->ndims > 1) { - hsize_t scaled; /* Scaled value */ + if (H5D_CHUNKED == dset->shared->layout.type && dset->shared->ndims > 1) { + hsize_t scaled; /* Scaled value */ /* Compute the scaled dimension size value */ - if(dset->shared->layout.u.chunk.dim[dim_idx] == 0) + if (dset->shared->layout.u.chunk.dim[dim_idx] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", dim_idx) scaled = size[dim_idx] / dset->shared->layout.u.chunk.dim[dim_idx]; /* Check if scaled dimension size changed */ - if(scaled != dset->shared->cache.chunk.scaled_dims[dim_idx]) { - hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ + if (scaled != dset->shared->cache.chunk.scaled_dims[dim_idx]) { + hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ /* Update the scaled dimension size value for the current dimension */ dset->shared->cache.chunk.scaled_dims[dim_idx] = scaled; /* Check if algorithm for computing hash values will change */ - if((scaled > dset->shared->cache.chunk.nslots && - dset->shared->cache.chunk.scaled_dims[dim_idx] <= dset->shared->cache.chunk.nslots) - || (scaled <= dset->shared->cache.chunk.nslots && - dset->shared->cache.chunk.scaled_dims[dim_idx] > dset->shared->cache.chunk.nslots)) + if ((scaled > dset->shared->cache.chunk.nslots && + dset->shared->cache.chunk.scaled_dims[dim_idx] <= + dset->shared->cache.chunk.nslots) || + (scaled <= dset->shared->cache.chunk.nslots && + dset->shared->cache.chunk.scaled_dims[dim_idx] > dset->shared->cache.chunk.nslots)) update_chunks = TRUE; - if(!(scaled_power2up = H5VM_power2up(scaled))) + if (!(scaled_power2up = H5VM_power2up(scaled))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get the next power of 2") /* Check if the number of bits required to encode the scaled size value changed */ - if(dset->shared->cache.chunk.scaled_power2up[dim_idx] != scaled_power2up) { + if (dset->shared->cache.chunk.scaled_power2up[dim_idx] != scaled_power2up) { /* Update the 'power2up' & 'encode_bits' values for the current dimension */ dset->shared->cache.chunk.scaled_power2up[dim_idx] = scaled_power2up; - dset->shared->cache.chunk.scaled_encode_bits[dim_idx] = H5VM_log2_gen(scaled_power2up); + dset->shared->cache.chunk.scaled_encode_bits[dim_idx] = + H5VM_log2_gen(scaled_power2up); /* Indicate that the cached chunk indices need to be updated */ update_chunks = TRUE; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Update the cached copy of the dataset's dimensions */ dset->shared->curr_dims[dim_idx] = size[dim_idx]; @@ -3110,34 +3104,38 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) *------------------------------------------------------------------------- */ /* Update the index values for the cached chunks for this dataset */ - if(H5D_CHUNKED == dset->shared->layout.type) { + if (H5D_CHUNKED == dset->shared->layout.type) { /* Set the cached chunk info */ - if(H5D__chunk_set_info(dset) < 0) + if (H5D__chunk_set_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to update # of chunks") /* Check if updating the chunk cache indices is necessary */ - if(update_chunks) + if (update_chunks) /* Update the chunk cache indices */ - if(H5D__chunk_update_cache(dset) < 0) + if (H5D__chunk_update_cache(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") } /* end if */ /* Operations for virtual datasets */ - if(H5D_VIRTUAL == dset->shared->layout.type) { + if (H5D_VIRTUAL == dset->shared->layout.type) { /* Check that the dimensions of the VDS are large enough */ - if(H5D_virtual_check_min_dims(dset) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual dataset dimensions not large enough to contain all limited dimensions in all selections") + if (H5D_virtual_check_min_dims(dset) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual dataset dimensions not large enough to contain all limited dimensions " + "in all selections") /* Patch the virtual selection dataspaces */ - for(u = 0; u < dset->shared->layout.storage.u.virt.list_nused; u++) { + for (u = 0; u < dset->shared->layout.storage.u.virt.list_nused; u++) { /* Patch extent */ - if(H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].source_dset.virtual_select, size) < 0) + if (H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].source_dset.virtual_select, + size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") dset->shared->layout.storage.u.virt.list[u].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT; /* Patch sub-source datasets */ - for(v = 0; v < dset->shared->layout.storage.u.virt.list[u].sub_dset_nused; v++) - if(H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].sub_dset[v].virtual_select, size) < 0) + for (v = 0; v < dset->shared->layout.storage.u.virt.list[u].sub_dset_nused; v++) + if (H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].sub_dset[v].virtual_select, + size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") } /* end for */ @@ -3147,12 +3145,12 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) } /* end if */ /* Allocate space for the new parts of the dataset, if appropriate */ - if(expand && dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY) { + if (expand && dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY) { H5D_io_info_t io_info; io_info.dset = dset; - if(H5D__alloc_storage(&io_info, H5D_ALLOC_EXTEND, FALSE, curr_dims) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_EXTEND, FALSE, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset storage") } /*------------------------------------------------------------------------- @@ -3161,23 +3159,25 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) * and if the chunks are written *------------------------------------------------------------------------- */ - if(H5D_CHUNKED == dset->shared->layout.type) { - if(shrink && ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage) - || (dset->shared->layout.ops->is_data_cached && (*dset->shared->layout.ops->is_data_cached)(dset->shared)))) + if (H5D_CHUNKED == dset->shared->layout.type) { + if (shrink && ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage) || + (dset->shared->layout.ops->is_data_cached && + (*dset->shared->layout.ops->is_data_cached)(dset->shared)))) /* Remove excess chunks */ - if(H5D__chunk_prune_by_extent(dset, curr_dims) < 0) + if (H5D__chunk_prune_by_extent(dset, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks") /* Update chunks that are no longer edge chunks as a result of * expansion */ - if(expand && (dset->shared->layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) - && (dset->shared->dcpl_cache.pline.nused > 0)) - if(H5D__chunk_update_old_edge_chunks(dset, curr_dims) < 0) + if (expand && + (dset->shared->layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + (dset->shared->dcpl_cache.pline.nused > 0)) + if (H5D__chunk_update_old_edge_chunks(dset, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to do update old edge chunks") } /* end if */ /* Mark the dataspace as dirty, for later writing to the file */ - if(H5D__mark(dset, H5D_MARK_SPACE) < 0) + if (H5D__mark(dset, H5D_MARK_SPACE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark dataspace as dirty") } /* end if */ @@ -3185,7 +3185,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__set_extent() */ - /*------------------------------------------------------------------------- * Function: H5D__flush_sieve_buf * @@ -3198,7 +3197,7 @@ done: herr_t H5D__flush_sieve_buf(H5D_t *dataset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3206,11 +3205,13 @@ H5D__flush_sieve_buf(H5D_t *dataset) HDassert(dataset); /* Flush the raw data buffer, if we have a dirty one */ - if(dataset->shared->cache.contig.sieve_buf && dataset->shared->cache.contig.sieve_dirty) { - HDassert(dataset->shared->layout.type != H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ + if (dataset->shared->cache.contig.sieve_buf && dataset->shared->cache.contig.sieve_dirty) { + HDassert(dataset->shared->layout.type != + H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ /* Write dirty data sieve buffer to file */ - if(H5F_shared_block_write(H5F_SHARED(dataset->oloc.file), H5FD_MEM_DRAW, dataset->shared->cache.contig.sieve_loc, + if (H5F_shared_block_write( + H5F_SHARED(dataset->oloc.file), H5FD_MEM_DRAW, dataset->shared->cache.contig.sieve_loc, dataset->shared->cache.contig.sieve_size, dataset->shared->cache.contig.sieve_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") @@ -3222,7 +3223,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__flush_sieve_buf() */ - /*------------------------------------------------------------------------- * Function: H5D__flush_real * @@ -3235,7 +3235,7 @@ done: herr_t H5D__flush_real(H5D_t *dataset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dataset->oloc.addr) @@ -3244,16 +3244,15 @@ H5D__flush_real(H5D_t *dataset) HDassert(dataset->shared); /* Avoid flushing the dataset (again) if it's closing */ - if(!dataset->shared->closing) + if (!dataset->shared->closing) /* Flush cached raw data for each kind of dataset layout */ - if(dataset->shared->layout.ops->flush && (dataset->shared->layout.ops->flush)(dataset) < 0) + if (dataset->shared->layout.ops->flush && (dataset->shared->layout.ops->flush)(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush raw data") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__flush_real() */ - /*------------------------------------------------------------------------- * Function: H5D__flush * @@ -3266,7 +3265,7 @@ done: herr_t H5D__flush(H5D_t *dset, hid_t dset_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3275,18 +3274,17 @@ H5D__flush(H5D_t *dset, hid_t dset_id) HDassert(dset->shared); /* Flush any dataset information still cached in memory */ - if(H5D__flush_real(dset) < 0) + if (H5D__flush_real(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush cached dataset info") /* Flush object's metadata to file */ - if(H5O_flush_common(&dset->oloc, dset_id) < 0) + if (H5O_flush_common(&dset->oloc, dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset and object flush callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__flush() */ - /*------------------------------------------------------------------------- * Function: H5D__format_convert * @@ -3300,81 +3298,83 @@ done: herr_t H5D__format_convert(H5D_t *dataset) { - H5D_chk_idx_info_t new_idx_info; /* Index info for the new layout */ - H5D_chk_idx_info_t idx_info; /* Index info for the current layout */ - H5O_layout_t *newlayout = NULL; /* The new layout */ - hbool_t init_new_index = FALSE; /* Indicate that the new chunk index is initialized */ - hbool_t delete_old_layout = FALSE; /* Indicate that the old layout message is deleted */ - hbool_t add_new_layout = FALSE; /* Indicate that the new layout message is added */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t new_idx_info; /* Index info for the new layout */ + H5D_chk_idx_info_t idx_info; /* Index info for the current layout */ + H5O_layout_t * newlayout = NULL; /* The new layout */ + hbool_t init_new_index = FALSE; /* Indicate that the new chunk index is initialized */ + hbool_t delete_old_layout = FALSE; /* Indicate that the old layout message is deleted */ + hbool_t add_new_layout = FALSE; /* Indicate that the new layout message is added */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dataset->oloc.addr) /* Check args */ HDassert(dataset); - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CHUNKED: HDassert(dataset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE); - if(NULL == (newlayout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + if (NULL == (newlayout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate buffer") /* Set up the current index info */ - idx_info.f = dataset->oloc.file; - idx_info.pline = &dataset->shared->dcpl_cache.pline; - idx_info.layout = &dataset->shared->layout.u.chunk; + idx_info.f = dataset->oloc.file; + idx_info.pline = &dataset->shared->dcpl_cache.pline; + idx_info.layout = &dataset->shared->layout.u.chunk; idx_info.storage = &dataset->shared->layout.storage.u.chunk; /* Copy the current layout info to the new layout */ H5MM_memcpy(newlayout, &dataset->shared->layout, sizeof(H5O_layout_t)); /* Set up info for version 1 B-tree in the new layout */ - newlayout->version = H5O_LAYOUT_VERSION_3; - newlayout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE; - newlayout->storage.u.chunk.idx_addr = HADDR_UNDEF; - newlayout->storage.u.chunk.ops = H5D_COPS_BTREE; + newlayout->version = H5O_LAYOUT_VERSION_3; + newlayout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE; + newlayout->storage.u.chunk.idx_addr = HADDR_UNDEF; + newlayout->storage.u.chunk.ops = H5D_COPS_BTREE; newlayout->storage.u.chunk.u.btree.shared = NULL; /* Set up the index info to version 1 B-tree */ - new_idx_info.f = dataset->oloc.file; - new_idx_info.pline = &dataset->shared->dcpl_cache.pline; - new_idx_info.layout = &(newlayout->u).chunk; + new_idx_info.f = dataset->oloc.file; + new_idx_info.pline = &dataset->shared->dcpl_cache.pline; + new_idx_info.layout = &(newlayout->u).chunk; new_idx_info.storage = &(newlayout->storage).u.chunk; /* Initialize version 1 B-tree */ - if(new_idx_info.storage->ops->init && (new_idx_info.storage->ops->init)(&new_idx_info, dataset->shared->space, dataset->oloc.addr) < 0) + if (new_idx_info.storage->ops->init && + (new_idx_info.storage->ops->init)(&new_idx_info, dataset->shared->space, dataset->oloc.addr) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") init_new_index = TRUE; /* If the current chunk index exists */ - if(H5F_addr_defined(idx_info.storage->idx_addr)) { + if (H5F_addr_defined(idx_info.storage->idx_addr)) { /* Create v1 B-tree chunk index */ - if((new_idx_info.storage->ops->create)(&new_idx_info) < 0) + if ((new_idx_info.storage->ops->create)(&new_idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create chunk index") /* Iterate over the chunks in the current index and insert the chunk addresses * into the version 1 B-tree chunk index */ - if(H5D__chunk_format_convert(dataset, &idx_info, &new_idx_info) < 0) + if (H5D__chunk_format_convert(dataset, &idx_info, &new_idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate/convert chunk index") } /* end if */ /* Delete the old "current" layout message */ - if(H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) + if (H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete layout message") delete_old_layout = TRUE; /* Append the new layout message to the object header */ - if(H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, newlayout) < 0) + if (H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, newlayout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout header message") add_new_layout = TRUE; /* Release the old (current) chunk index */ - if(idx_info.storage->ops->dest && (idx_info.storage->ops->dest)(&idx_info) < 0) + if (idx_info.storage->ops->dest && (idx_info.storage->ops->dest)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") /* Copy the new layout to the dataset's layout */ @@ -3386,7 +3386,8 @@ H5D__format_convert(H5D_t *dataset) case H5D_COMPACT: HDassert(dataset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT); dataset->shared->layout.version = H5O_LAYOUT_VERSION_DEFAULT; - if(H5O_msg_write(&(dataset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dataset->shared->layout)) < 0) + if (H5O_msg_write(&(dataset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, + &(dataset->shared->layout)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message") break; @@ -3402,42 +3403,43 @@ H5D__format_convert(H5D_t *dataset) } /* end switch */ done: - if(ret_value < 0 && dataset->shared->layout.type == H5D_CHUNKED) { + if (ret_value < 0 && dataset->shared->layout.type == H5D_CHUNKED) { /* Remove new layout message */ - if(add_new_layout) - if(H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) + if (add_new_layout) + if (H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete layout message") /* Add back old layout message */ - if(delete_old_layout) - if(H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &dataset->shared->layout) < 0) + if (delete_old_layout) + if (H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &dataset->shared->layout) < + 0) HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to add layout header message") /* Clean up v1 b-tree chunk index */ - if(init_new_index) { - if(H5F_addr_defined(new_idx_info.storage->idx_addr)) { + if (init_new_index) { + if (H5F_addr_defined(new_idx_info.storage->idx_addr)) { /* Check for valid address i.e. tag */ - if(!H5F_addr_defined(dataset->oloc.addr)) + if (!H5F_addr_defined(dataset->oloc.addr)) HDONE_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "address undefined") /* Expunge from cache all v1 B-tree type entries associated with tag */ - if(H5AC_expunge_tag_type_metadata(dataset->oloc.file, dataset->oloc.addr, H5AC_BT_ID, H5AC__NO_FLAGS_SET, TRUE)) + if (H5AC_expunge_tag_type_metadata(dataset->oloc.file, dataset->oloc.addr, H5AC_BT_ID, + H5AC__NO_FLAGS_SET, TRUE)) HDONE_ERROR(H5E_DATASET, H5E_CANTEXPUNGE, FAIL, "unable to expunge index metadata") } /* end if */ /* Delete v1 B-tree chunk index */ - if(new_idx_info.storage->ops->dest && (new_idx_info.storage->ops->dest)(&new_idx_info) < 0) + if (new_idx_info.storage->ops->dest && (new_idx_info.storage->ops->dest)(&new_idx_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") } /* end if */ - } /* end if */ + } /* end if */ - if(newlayout != NULL) + if (newlayout != NULL) newlayout = (H5O_layout_t *)H5MM_xfree(newlayout); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__format_convert() */ - /*------------------------------------------------------------------------- * Function: H5D__mark * @@ -3450,8 +3452,8 @@ done: herr_t H5D__mark(const H5D_t *dataset, unsigned flags) { - H5O_t *oh = NULL; /* Pointer to dataset's object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Pointer to dataset's object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3460,16 +3462,16 @@ H5D__mark(const H5D_t *dataset, unsigned flags) HDassert(!(flags & (unsigned)~(H5D_MARK_SPACE | H5D_MARK_LAYOUT))); /* Mark aspects of the dataset as dirty */ - if(flags) { - unsigned update_flags = H5O_UPDATE_TIME; /* Modification time flag */ + if (flags) { + unsigned update_flags = H5O_UPDATE_TIME; /* Modification time flag */ /* Pin the object header */ - if(NULL == (oh = H5O_pin(&dataset->oloc))) + if (NULL == (oh = H5O_pin(&dataset->oloc))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") /* Update the layout on disk, if it's been changed */ - if(flags & H5D_MARK_LAYOUT) { - if(H5D__layout_oh_write(dataset, oh, update_flags) < 0) + if (flags & H5D_MARK_LAYOUT) { + if (H5D__layout_oh_write(dataset, oh, update_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout info") /* Reset the "update the modification time" flag, so we only do it once */ @@ -3477,8 +3479,8 @@ H5D__mark(const H5D_t *dataset, unsigned flags) } /* end if */ /* Update the dataspace on disk, if it's been changed */ - if(flags & H5D_MARK_SPACE) { - if(H5S_write(dataset->oloc.file, oh, update_flags, dataset->shared->space) < 0) + if (flags & H5D_MARK_SPACE) { + if (H5S_write(dataset->oloc.file, oh, update_flags, dataset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") /* Reset the "update the modification time" flag, so we only do it once */ @@ -3491,14 +3493,13 @@ H5D__mark(const H5D_t *dataset, unsigned flags) done: /* Release pointer to object header */ - if(oh != NULL) - if(H5O_unpin(oh) < 0) + if (oh != NULL) + if (H5O_unpin(oh) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mark() */ - /*------------------------------------------------------------------------- * Function: H5D__flush_all_cb * @@ -3511,9 +3512,9 @@ done: static int H5D__flush_all_cb(void *_dataset, hid_t H5_ATTR_UNUSED id, void *_udata) { - H5D_t *dataset = (H5D_t *)_dataset; /* Dataset pointer */ - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_t *dataset = (H5D_t *)_dataset; /* Dataset pointer */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -3522,16 +3523,15 @@ H5D__flush_all_cb(void *_dataset, hid_t H5_ATTR_UNUSED id, void *_udata) HDassert(f); /* Check for dataset in same file */ - if(f == dataset->oloc.file) + if (f == dataset->oloc.file) /* Flush the dataset's information */ - if(H5D__flush_real(dataset) < 0) + if (H5D__flush_real(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to flush cached dataset info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__flush_all_cb() */ - /*------------------------------------------------------------------------- * Function: H5D_flush_all * @@ -3544,7 +3544,7 @@ done: herr_t H5D_flush_all(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3552,14 +3552,13 @@ H5D_flush_all(H5F_t *f) HDassert(f); /* Iterate over all the open datasets */ - if(H5I_iterate(H5I_DATASET, H5D__flush_all_cb, f, FALSE) < 0) /* Casting away const OK -QAK */ + if (H5I_iterate(H5I_DATASET, H5D__flush_all_cb, f, FALSE) < 0) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to flush cached dataset info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_flush_all() */ - /*------------------------------------------------------------------------- * Function: H5D_get_create_plist * @@ -3574,37 +3573,37 @@ done: hid_t H5D_get_create_plist(const H5D_t *dset) { - H5P_genplist_t *dcpl_plist; /* Dataset's DCPL */ - H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */ - H5O_layout_t copied_layout; /* Layout to tweak */ - H5O_fill_t copied_fill; /* Fill value to tweak */ - H5O_efl_t copied_efl; /* External file list to tweak */ - hid_t new_dcpl_id = FAIL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t *dcpl_plist; /* Dataset's DCPL */ + H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */ + H5O_layout_t copied_layout; /* Layout to tweak */ + H5O_fill_t copied_fill; /* Fill value to tweak */ + H5O_efl_t copied_efl; /* External file list to tweak */ + hid_t new_dcpl_id = FAIL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(NULL == (dcpl_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) + if (NULL == (dcpl_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get property list") /* Copy the creation property list */ - if((new_dcpl_id = H5P_copy_plist(dcpl_plist, TRUE)) < 0) + if ((new_dcpl_id = H5P_copy_plist(dcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dcpl_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dcpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get property list") /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&dset->oloc, new_plist) < 0) + if (H5O_get_create_plist(&dset->oloc, new_plist) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object creation info") /* Get the layout property */ - if(H5P_peek(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) + if (H5P_peek(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout") /* Reset layout values set when dataset is created */ copied_layout.ops = NULL; - switch(copied_layout.type) { + switch (copied_layout.type) { case H5D_COMPACT: copied_layout.storage.u.compact.buf = H5MM_xfree(copied_layout.storage.u.compact.buf); HDmemset(&copied_layout.storage.u.compact, 0, sizeof(copied_layout.storage.u.compact)); @@ -3620,10 +3619,11 @@ H5D_get_create_plist(const H5D_t *dset) copied_layout.u.chunk.size = 0; /* Reset index info, if the chunk ops are set */ - if(copied_layout.storage.u.chunk.ops) + if (copied_layout.storage.u.chunk.ops) /* Reset address and pointer of the array struct for the chunked storage index */ - if(H5D_chunk_idx_reset(&copied_layout.storage.u.chunk, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") + if (H5D_chunk_idx_reset(&copied_layout.storage.u.chunk, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to reset chunked storage index in dest") /* Reset chunk index ops */ copied_layout.storage.u.chunk.ops = NULL; @@ -3631,7 +3631,7 @@ H5D_get_create_plist(const H5D_t *dset) case H5D_VIRTUAL: copied_layout.storage.u.virt.serial_list_hobjid.addr = HADDR_UNDEF; - copied_layout.storage.u.virt.serial_list_hobjid.idx = 0; + copied_layout.storage.u.virt.serial_list_hobjid.idx = 0; break; case H5D_LAYOUT_ERROR: @@ -3641,102 +3641,103 @@ H5D_get_create_plist(const H5D_t *dset) } /* end switch */ /* Set back the (possibly modified) layout property to property list */ - if(H5P_poke(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) + if (H5P_poke(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set layout") /* Get the fill value property */ - if(H5P_peek(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) + if (H5P_peek(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value") /* Check if there is a fill value, but no type yet */ - if(copied_fill.buf != NULL && copied_fill.type == NULL) { - H5T_path_t *tpath; /* Conversion information*/ + if (copied_fill.buf != NULL && copied_fill.type == NULL) { + H5T_path_t *tpath; /* Conversion information*/ /* Copy the dataset type into the fill value message */ - if(NULL == (copied_fill.type = H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT))) + if (NULL == (copied_fill.type = H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset datatype for fill value") /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(dset->shared->type, copied_fill.type))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") + if (NULL == (tpath = H5T_path_find(dset->shared->type, copied_fill.type))) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest data types") /* Convert disk form of fill value into memory form */ - if(!H5T_path_noop(tpath)) { - hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */ - uint8_t *bkg_buf = NULL; /* Background conversion buffer */ - size_t bkg_size; /* Size of background buffer */ + if (!H5T_path_noop(tpath)) { + hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */ + uint8_t *bkg_buf = NULL; /* Background conversion buffer */ + size_t bkg_size; /* Size of background buffer */ /* Wrap copies of types to convert */ dst_id = H5I_register(H5I_DATATYPE, H5T_copy(copied_fill.type, H5T_COPY_TRANSIENT), FALSE); - if(dst_id < 0) + if (dst_id < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype") src_id = H5I_register(H5I_DATATYPE, H5T_copy(dset->shared->type, H5T_COPY_ALL), FALSE); - if(src_id < 0) { + if (src_id < 0) { H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy/register datatype") } /* end if */ /* Allocate a background buffer */ bkg_size = MAX(H5T_GET_SIZE(copied_fill.type), H5T_GET_SIZE(dset->shared->type)); - if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { + if (H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed") } /* end if */ /* Convert fill value */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, copied_fill.buf, bkg_buf) < 0) { + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, copied_fill.buf, + bkg_buf) < 0) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end if */ /* Release local resources */ - if(H5I_dec_ref(src_id) < 0) + if (H5I_dec_ref(src_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(H5I_dec_ref(dst_id) < 0) + if (H5I_dec_ref(dst_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); } /* end if */ - } /* end if */ + } /* end if */ /* Set back the (possibly modified) fill value property to property list */ - if(H5P_poke(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) + if (H5P_poke(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set fill value") /* Get the fill value property */ - if(H5P_peek(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) + if (H5P_peek(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get external file list") /* Reset efl name_offset and heap_addr, these are the values when the dataset is created */ - if(copied_efl.slot) { + if (copied_efl.slot) { unsigned u; copied_efl.heap_addr = HADDR_UNDEF; - for(u = 0; u < copied_efl.nused; u++) + for (u = 0; u < copied_efl.nused; u++) copied_efl.slot[u].name_offset = 0; } /* end if */ /* Set back the (possibly modified) external file list property to property list */ - if(H5P_poke(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) + if (H5P_poke(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set external file list") /* Set the return value */ ret_value = new_dcpl_id; done: - if(ret_value < 0) - if(new_dcpl_id > 0) - if(H5I_dec_app_ref(new_dcpl_id) < 0) + if (ret_value < 0) + if (new_dcpl_id > 0) + if (H5I_dec_app_ref(new_dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5D_get_access_plist * @@ -3750,90 +3751,92 @@ done: hid_t H5D_get_access_plist(const H5D_t *dset) { - H5P_genplist_t *old_plist; /* Stored DAPL from dset */ - H5P_genplist_t *new_plist; /* New DAPL */ - H5P_genplist_t *def_fapl; /* Default FAPL */ - H5D_append_flush_t def_append_flush_info = {0}; /* Default append flush property */ - H5D_rdcc_t def_chunk_info; /* Default chunk cache property */ - hid_t new_dapl_id = FAIL; - hid_t ret_value = FAIL; + H5P_genplist_t * old_plist; /* Stored DAPL from dset */ + H5P_genplist_t * new_plist; /* New DAPL */ + H5P_genplist_t * def_fapl; /* Default FAPL */ + H5D_append_flush_t def_append_flush_info = {0}; /* Default append flush property */ + H5D_rdcc_t def_chunk_info; /* Default chunk cache property */ + hid_t new_dapl_id = FAIL; + hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT /* Make a copy of the dataset's dataset access property list */ - if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(dset->shared->dapl_id))) + if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(dset->shared->dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get property list") - if((new_dapl_id = H5P_copy_plist(old_plist, TRUE)) < 0) + if ((new_dapl_id = H5P_copy_plist(old_plist, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy dataset access property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dapl_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* If the dataset is chunked then copy the rdcc & append flush parameters. * Otherwise, use the default values. */ - if(dset->shared->layout.type == H5D_CHUNKED) { - if(H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(dset->shared->cache.chunk.nslots)) < 0) + if (dset->shared->layout.type == H5D_CHUNKED) { + if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(dset->shared->cache.chunk.nslots)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots") - if(H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(dset->shared->cache.chunk.nbytes_max)) < 0) + if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(dset->shared->cache.chunk.nbytes_max)) < + 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") - if(H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &(dset->shared->cache.chunk.w0)) < 0) + if (H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &(dset->shared->cache.chunk.w0)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") - if(H5P_set(new_plist, H5D_ACS_APPEND_FLUSH_NAME, &dset->shared->append_flush) < 0) + if (H5P_set(new_plist, H5D_ACS_APPEND_FLUSH_NAME, &dset->shared->append_flush) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set append flush property") - } else { + } + else { /* Get the default FAPL */ - if(NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) + if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a property list") /* Set the data cache number of slots to the value of the default FAPL */ if (H5P_get(def_fapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &def_chunk_info.nslots) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET,FAIL, "can't get data number of slots"); - if(H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &def_chunk_info.nslots) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data number of slots"); + if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &def_chunk_info.nslots) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set data cache number of slots") /* Set the data cache byte size to the value of the default FAPL */ if (H5P_get(def_fapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &def_chunk_info.nbytes_max) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET,FAIL, "can't get data cache byte size"); - if(H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &def_chunk_info.nbytes_max) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data cache byte size"); + if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &def_chunk_info.nbytes_max) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set data cache byte size") /* Set the preempt read chunks property to the value of the default FAPL */ if (H5P_get(def_fapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &def_chunk_info.w0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET,FAIL, "can't get preempt read chunks"); - if(H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &def_chunk_info.w0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get preempt read chunks"); + if (H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &def_chunk_info.w0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set preempt read chunks") /* Set the append flush property to its default value */ - if(H5P_set(new_plist, H5D_ACS_APPEND_FLUSH_NAME, &def_append_flush_info) < 0) + if (H5P_set(new_plist, H5D_ACS_APPEND_FLUSH_NAME, &def_append_flush_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set append flush property") - }/* end if-else */ + } /* end if-else */ /* Set the VDS view & printf gap options */ - if(H5P_set(new_plist, H5D_ACS_VDS_VIEW_NAME, &(dset->shared->layout.storage.u.virt.view)) < 0) + if (H5P_set(new_plist, H5D_ACS_VDS_VIEW_NAME, &(dset->shared->layout.storage.u.virt.view)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VDS view") - if(H5P_set(new_plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &(dset->shared->layout.storage.u.virt.printf_gap)) < 0) + if (H5P_set(new_plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &(dset->shared->layout.storage.u.virt.printf_gap)) < + 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VDS printf gap") /* Set the vds prefix option */ - if(H5P_set(new_plist, H5D_ACS_VDS_PREFIX_NAME, &(dset->shared->vds_prefix)) < 0) + if (H5P_set(new_plist, H5D_ACS_VDS_PREFIX_NAME, &(dset->shared->vds_prefix)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vds prefix") /* Set the external file prefix option */ - if(H5P_set(new_plist, H5D_ACS_EFILE_PREFIX_NAME, &(dset->shared->extfile_prefix)) < 0) + if (H5P_set(new_plist, H5D_ACS_EFILE_PREFIX_NAME, &(dset->shared->extfile_prefix)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file prefix") /* Set the return value */ ret_value = new_dapl_id; done: - if(ret_value < 0) - if(new_dapl_id > 0) - if(H5I_dec_app_ref(new_dapl_id) < 0) + if (ret_value < 0) + if (new_dapl_id > 0) + if (H5I_dec_app_ref(new_dapl_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_access_plist() */ - /*------------------------------------------------------------------------- * Function: H5D__get_space * @@ -3846,34 +3849,33 @@ done: hid_t H5D__get_space(const H5D_t *dset) { - H5S_t *space = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *space = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_PACKAGE /* If the layout is virtual, update the extent */ - if(dset->shared->layout.type == H5D_VIRTUAL) - if(H5D__virtual_set_extent_unlim(dset) < 0) + if (dset->shared->layout.type == H5D_VIRTUAL) + if (H5D__virtual_set_extent_unlim(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update virtual dataset extent") /* Read the dataspace message and return a dataspace object */ - if(NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE))) + if (NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") /* Create an atom */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") done: - if(ret_value < 0) - if(space != NULL) - if(H5S_close(space) < 0) + if (ret_value < 0) + if (space != NULL) + if (H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_space() */ - /*------------------------------------------------------------------------- * Function: H5D__get_type * @@ -3887,49 +3889,47 @@ done: hid_t H5D__get_type(const H5D_t *dset) { - H5T_t *dt = NULL; - hid_t ret_value = FAIL; + H5T_t *dt = NULL; + hid_t ret_value = FAIL; FUNC_ENTER_PACKAGE /* Patch the datatype's "top level" file pointer */ - if(H5T_patch_file(dset->shared->type, dset->oloc.file) < 0) + if (H5T_patch_file(dset->shared->type, dset->oloc.file) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to patch datatype's file pointer") /* Copy the dataset's datatype */ - if(NULL == (dt = H5T_copy_reopen(dset->shared->type))) + if (NULL == (dt = H5T_copy_reopen(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") /* Mark any datatypes as being in memory now */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") /* Lock copied type */ - if(H5T_lock(dt, FALSE) < 0) + if (H5T_lock(dt, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to lock transient datatype") /* Create an atom */ - if(H5T_is_named(dt)) { + if (H5T_is_named(dt)) { /* If this is a committed datatype, we need to recreate the * two-level IDs, where the VOL object is a copy of the * returned datatype. */ - if((ret_value = H5VL_wrap_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5VL_wrap_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") } /* end if */ - else - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + else if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") done: - if(ret_value < 0) - if(dt && H5T_close(dt) < 0) + if (ret_value < 0) + if (dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_type() */ - /*------------------------------------------------------------------------- * Function: H5D__refresh * @@ -3941,9 +3941,9 @@ done: herr_t H5D__refresh(hid_t dset_id, H5D_t *dset) { - H5D_virtual_held_file_t *head = NULL; /* Pointer to list of files held open */ - hbool_t virt_dsets_held = FALSE; /* Whether virtual datasets' files are held open */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_virtual_held_file_t *head = NULL; /* Pointer to list of files held open */ + hbool_t virt_dsets_held = FALSE; /* Whether virtual datasets' files are held open */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3952,27 +3952,26 @@ H5D__refresh(hid_t dset_id, H5D_t *dset) HDassert(dset->shared); /* If the layout is virtual... */ - if(dset->shared->layout.type == H5D_VIRTUAL) { + if (dset->shared->layout.type == H5D_VIRTUAL) { /* Hold open the source datasets' files */ - if(H5D__virtual_hold_source_dset_files(dset, &head) < 0) + if (H5D__virtual_hold_source_dset_files(dset, &head) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, FAIL, "unable to hold VDS source files open") virt_dsets_held = TRUE; /* Refresh source datasets for virtual dataset */ - if(H5D__virtual_refresh_source_dsets(dset) < 0) + if (H5D__virtual_refresh_source_dsets(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh VDS source datasets") } /* end if */ /* Refresh dataset object */ - if((H5O_refresh_metadata(dset_id, dset->oloc)) < 0) + if ((H5O_refresh_metadata(dset_id, dset->oloc)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh dataset") done: /* Release hold on (source) virtual datasets' files */ - if(virt_dsets_held) - if(H5D__virtual_release_source_dset_files(head) < 0) + if (virt_dsets_held) + if (H5D__virtual_release_source_dset_files(head) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't release VDS source files held open") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__refresh() */ - diff --git a/src/H5Dio.c b/src/H5Dio.c index a972e00..0c5071f 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -15,55 +15,49 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Sprivate.h" /* Dataspace */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Sprivate.h" /* Dataspace */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Setup/teardown routines */ -static herr_t H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, - H5D_storage_t *store, H5D_io_info_t *io_info); -static herr_t H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, - hbool_t do_write, H5D_type_info_t *type_info); +static herr_t H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, H5D_storage_t *store, + H5D_io_info_t *io_info); +static herr_t H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, + H5D_type_info_t *type_info); #ifdef H5_HAVE_PARALLEL -static herr_t H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, - const H5S_t *file_space, const H5S_t *mem_space, const H5D_type_info_t *type_info); +static herr_t H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, const H5S_t *file_space, + const H5S_t *mem_space, const H5D_type_info_t *type_info); #endif /* H5_HAVE_PARALLEL */ static herr_t H5D__typeinfo_term(const H5D_type_info_t *type_info); - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ @@ -74,8 +68,6 @@ H5FL_BLK_DEFINE(type_conv); /* Declare a free list to manage the H5D_chunk_map_t struct */ H5FL_DEFINE(H5D_chunk_map_t); - - /*------------------------------------------------------------------------- * Function: H5D__get_offset_copy * @@ -93,7 +85,7 @@ herr_t H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy) { unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -125,7 +117,6 @@ done: } /* end H5D__get_offset_copy() */ - /*------------------------------------------------------------------------- * Function: H5Dread * @@ -157,11 +148,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t dxpl_id, void *buf/*out*/) +H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, + void *buf /*out*/) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id, @@ -180,22 +171,21 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Read the data */ - if ((ret_value = H5VL_dataset_read(vol_obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_dataset_read(vol_obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: FUNC_LEAVE_API(ret_value) } /* end H5Dread() */ - /*------------------------------------------------------------------------- * Function: H5Dread_chunk * @@ -209,11 +199,10 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, - void *buf) +H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*h*Iu*x", dset_id, dxpl_id, offset, filters, buf); @@ -231,22 +220,21 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Read the raw chunk */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_READ, dxpl_id, H5_REQUEST_NULL, offset, filters, buf) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_READ, dxpl_id, H5_REQUEST_NULL, offset, + filters, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") done: FUNC_LEAVE_API(ret_value) } /* end H5Dread_chunk() */ - /*------------------------------------------------------------------------- * Function: H5Dwrite * @@ -279,11 +267,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t dxpl_id, const void *buf) +H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, + const void *buf) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiii*x", dset_id, mem_type_id, mem_space_id, file_space_id, @@ -302,22 +290,21 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Write the data */ - if ((ret_value = H5VL_dataset_write(vol_obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_dataset_write(vol_obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: FUNC_LEAVE_API(ret_value) } /* end H5Dwrite() */ - /*------------------------------------------------------------------------- * Function: H5Dwrite_chunk * @@ -331,12 +318,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, - size_t data_size, const void *buf) +H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, size_t data_size, + const void *buf) { - H5VL_object_t *vol_obj = NULL; - uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiIu*hz*x", dset_id, dxpl_id, filters, offset, data_size, buf); @@ -359,22 +346,21 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Write chunk */ - if(H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_WRITE, dxpl_id, H5_REQUEST_NULL, filters, offset, data_size_32, buf) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_WRITE, dxpl_id, H5_REQUEST_NULL, filters, + offset, data_size_32, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") done: FUNC_LEAVE_API(ret_value) } /* end H5Dwrite_chunk() */ - /*------------------------------------------------------------------------- * Function: H5D__read * @@ -389,84 +375,85 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, - const H5S_t *file_space, void *buf/*out*/) +H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, + void *buf /*out*/) { - H5D_chunk_map_t *fm = NULL; /* Chunk file<->memory mapping */ - H5D_io_info_t io_info; /* Dataset I/O info */ - H5D_type_info_t type_info; /* Datatype info for operation */ - hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */ - H5S_t * projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ - /* projection of the supplied mem_space to a new */ - /* dataspace with rank equal to that of */ - /* file_space. */ - /* */ - /* This field is only used if */ - /* H5S_select_shape_same() returns TRUE when */ - /* comparing the mem_space and the data_space, */ - /* and the mem_space have different rank. */ - /* */ - /* Note that if this variable is used, the */ - /* projected mem space must be discarded at the */ - /* end of the function to avoid a memory leak. */ - H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - hsize_t nelmts; /* total number of elmts */ - hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ - char fake_char; /* Temporary variable for NULL buffer pointers */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_map_t *fm = NULL; /* Chunk file<->memory mapping */ + H5D_io_info_t io_info; /* Dataset I/O info */ + H5D_type_info_t type_info; /* Datatype info for operation */ + hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */ + H5S_t * projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ + /* projection of the supplied mem_space to a new */ + /* dataspace with rank equal to that of */ + /* file_space. */ + /* */ + /* This field is only used if */ + /* H5S_select_shape_same() returns TRUE when */ + /* comparing the mem_space and the data_space, */ + /* and the mem_space have different rank. */ + /* */ + /* Note that if this variable is used, the */ + /* projected mem space must be discarded at the */ + /* end of the function to avoid a memory leak. */ + H5D_storage_t store; /* union of EFL and chunk pointer in file space */ + hsize_t nelmts; /* total number of elmts */ + hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ + char fake_char; /* Temporary variable for NULL buffer pointers */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dataset->oloc.addr) /* check args */ HDassert(dataset && dataset->oloc.file); - if(!file_space) + if (!file_space) file_space = dataset->shared->space; - if(!mem_space) + if (!mem_space) mem_space = file_space; nelmts = H5S_GET_SELECT_NPOINTS(mem_space); /* Set up datatype info for operation */ - if(H5D__typeinfo_init(dataset, mem_type_id, FALSE, &type_info) < 0) + if (H5D__typeinfo_init(dataset, mem_type_id, FALSE, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up type info") type_info_init = TRUE; #ifdef H5_HAVE_PARALLEL /* Check for non-MPI-based VFD */ - if(!(H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI))) { - H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ + if (!(H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI))) { + H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ /* Get I/O transfer mode */ - if(H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Collective access is not permissible without a MPI based VFD */ - if(io_xfer_mode == H5FD_MPIO_COLLECTIVE) + if (io_xfer_mode == H5FD_MPIO_COLLECTIVE) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based drivers only") - } /* end if */ + } /* end if */ #endif /*H5_HAVE_PARALLEL*/ /* Make certain that the number of elements in each selection is the same */ - if(nelmts != H5S_GET_SELECT_NPOINTS(file_space)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") + if (nelmts != H5S_GET_SELECT_NPOINTS(file_space)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "src and dest dataspaces have different number of elements selected") /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ - if(NULL == buf) { + if (NULL == buf) { /* Check for any elements selected (which is invalid) */ - if(nelmts > 0) + if (nelmts > 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") - /* If the buffer is nil, and 0 element is selected, make a fake buffer. - * This is for some MPI package like ChaMPIon on NCSA's tungsten which - * doesn't support this feature. - */ + /* If the buffer is nil, and 0 element is selected, make a fake buffer. + * This is for some MPI package like ChaMPIon on NCSA's tungsten which + * doesn't support this feature. + */ buf = &fake_char; } /* end if */ /* Make sure that both selections have their extents set */ - if(!(H5S_has_extent(file_space))) + if (!(H5S_has_extent(file_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") - if(!(H5S_has_extent(mem_space))) + if (!(H5S_has_extent(mem_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set") /* H5S_select_shape_same() has been modified to accept topologically identical @@ -482,23 +469,23 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * Note that in general, this requires us to touch up the memory buffer as * well. */ - if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && - H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { - const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ - /* to the beginning of the projected mem space. */ + if (TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && + H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { + const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ + /* to the beginning of the projected mem space. */ /* Attempt to construct projected dataspace for memory dataspace */ - if(H5S_select_construct_projection(mem_space, &projected_mem_space, - (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf, type_info.dst_type_size) < 0) + if (H5S_select_construct_projection(mem_space, &projected_mem_space, + (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf, + type_info.dst_type_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace") HDassert(projected_mem_space); HDassert(adj_buf); /* Switch to using projected memory dataspace & adjusted buffer */ mem_space = projected_mem_space; - buf = (void *)adj_buf; /* Casting away 'const' OK -QAK */ - } /* end if */ - + buf = (void *)adj_buf; /* Casting away 'const' OK -QAK */ + } /* end if */ /* Retrieve dataset properties */ /* */ @@ -509,26 +496,30 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * fill time is NEVER, there is no way to tell whether part of data * has been overwritten. So just proceed in reading. */ - if(nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && - !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) && - !(dataset->shared->layout.ops->is_data_cached && (*dataset->shared->layout.ops->is_data_cached)(dataset->shared))) { - H5D_fill_value_t fill_status; /* Whether/How the fill value is defined */ + if (nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && + !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) && + !(dataset->shared->layout.ops->is_data_cached && + (*dataset->shared->layout.ops->is_data_cached)(dataset->shared))) { + H5D_fill_value_t fill_status; /* Whether/How the fill value is defined */ /* Retrieve dataset's fill-value properties */ - if(H5P_is_fill_value_defined(&dataset->shared->dcpl_cache.fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(&dataset->shared->dcpl_cache.fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Should be impossible, but check anyway... */ - if(fill_status == H5D_FILL_VALUE_UNDEFINED && - (dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET)) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "read failed: dataset doesn't exist, no data can be read") + if (fill_status == H5D_FILL_VALUE_UNDEFINED && + (dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || + dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET)) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, + "read failed: dataset doesn't exist, no data can be read") /* If we're never going to fill this dataset, just leave the junk in the user's buffer */ - if(dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_NEVER) + if (dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_NEVER) HGOTO_DONE(SUCCEED) /* Go fill the user's selection with the dataset's fill value */ - if(H5D__fill(dataset->shared->dcpl_cache.fill.buf, dataset->shared->type, buf, type_info.mem_type, mem_space) < 0) + if (H5D__fill(dataset->shared->dcpl_cache.fill.buf, dataset->shared->type, buf, type_info.mem_type, + mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "filling buf failed") else HGOTO_DONE(SUCCEED) @@ -536,56 +527,56 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Set up I/O operation */ io_info.op_type = H5D_IO_OP_READ; - io_info.u.rbuf = buf; - if(H5D__ioinfo_init(dataset, &type_info, &store, &io_info) < 0) + io_info.u.rbuf = buf; + if (H5D__ioinfo_init(dataset, &type_info, &store, &io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to set up I/O operation") /* Sanity check that space is allocated, if there are elements */ - if(nelmts > 0) - HDassert((*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) - || (dataset->shared->layout.ops->is_data_cached && (*dataset->shared->layout.ops->is_data_cached)(dataset->shared)) - || dataset->shared->dcpl_cache.efl.nused > 0 - || dataset->shared->layout.type == H5D_COMPACT); + if (nelmts > 0) + HDassert((*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) || + (dataset->shared->layout.ops->is_data_cached && + (*dataset->shared->layout.ops->is_data_cached)(dataset->shared)) || + dataset->shared->dcpl_cache.efl.nused > 0 || dataset->shared->layout.type == H5D_COMPACT); /* Allocate the chunk map */ - if(NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) + if (NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk map") /* Call storage method's I/O initialization routine */ - if(io_info.layout_ops.io_init && (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) + if (io_info.layout_ops.io_init && + (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info") io_op_init = TRUE; #ifdef H5_HAVE_PARALLEL /* Adjust I/O info for any parallel I/O */ - if(H5D__ioinfo_adjust(&io_info, dataset, file_space, mem_space, &type_info) < 0) + if (H5D__ioinfo_adjust(&io_info, dataset, file_space, mem_space, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to adjust I/O info for parallel I/O") #endif /*H5_HAVE_PARALLEL*/ /* Invoke correct "high level" I/O routine */ - if((*io_info.io_ops.multi_read)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) + if ((*io_info.io_ops.multi_read)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: /* Shut down the I/O op information */ - if(io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0) + if (io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info") - if(fm) + if (fm) fm = H5FL_FREE(H5D_chunk_map_t, fm); /* Shut down datatype info for operation */ - if(type_info_init && H5D__typeinfo_term(&type_info) < 0) + if (type_info_init && H5D__typeinfo_term(&type_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down type info") /* discard projected mem space if it was created */ - if(NULL != projected_mem_space) - if(H5S_close(projected_mem_space) < 0) + if (NULL != projected_mem_space) + if (H5S_close(projected_mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down projected memory dataspace") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__read() */ - /*------------------------------------------------------------------------- * Function: H5D__write * @@ -600,31 +591,31 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, - const H5S_t *file_space, const void *buf) +H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, + const void *buf) { - H5D_chunk_map_t *fm = NULL; /* Chunk file<->memory mapping */ - H5D_io_info_t io_info; /* Dataset I/O info */ - H5D_type_info_t type_info; /* Datatype info for operation */ - hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */ - H5S_t * projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ - /* projection of the supplied mem_space to a new */ - /* dataspace with rank equal to that of */ - /* file_space. */ - /* */ - /* This field is only used if */ - /* H5S_select_shape_same() returns TRUE when */ - /* comparing the mem_space and the data_space, */ - /* and the mem_space have different rank. */ - /* */ - /* Note that if this variable is used, the */ - /* projected mem space must be discarded at the */ - /* end of the function to avoid a memory leak. */ - H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - hsize_t nelmts; /* total number of elmts */ - hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ - char fake_char; /* Temporary variable for NULL buffer pointers */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_map_t *fm = NULL; /* Chunk file<->memory mapping */ + H5D_io_info_t io_info; /* Dataset I/O info */ + H5D_type_info_t type_info; /* Datatype info for operation */ + hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */ + H5S_t * projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ + /* projection of the supplied mem_space to a new */ + /* dataspace with rank equal to that of */ + /* file_space. */ + /* */ + /* This field is only used if */ + /* H5S_select_shape_same() returns TRUE when */ + /* comparing the mem_space and the data_space, */ + /* and the mem_space have different rank. */ + /* */ + /* Note that if this variable is used, the */ + /* projected mem space must be discarded at the */ + /* end of the function to avoid a memory leak. */ + H5D_storage_t store; /* union of EFL and chunk pointer in file space */ + hsize_t nelmts; /* total number of elmts */ + hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ + char fake_char; /* Temporary variable for NULL buffer pointers */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dataset->oloc.addr) @@ -632,73 +623,75 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, HDassert(dataset && dataset->oloc.file); /* All filters in the DCPL must have encoding enabled. */ - if(!dataset->shared->checked_filters) { - if(H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) < 0) + if (!dataset->shared->checked_filters) { + if (H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") dataset->shared->checked_filters = TRUE; } /* end if */ /* Check if we are allowed to write to this file */ - if(0 == (H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file") /* Set up datatype info for operation */ - if(H5D__typeinfo_init(dataset, mem_type_id, TRUE, &type_info) < 0) + if (H5D__typeinfo_init(dataset, mem_type_id, TRUE, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up type info") type_info_init = TRUE; /* Various MPI based checks */ #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI)) { /* If MPI based VFD is used, no VL or region reference datatype support yet. */ /* This is because they use the global heap in the file and we don't */ /* support parallel access of that yet */ - if(H5T_is_vl_storage(type_info.mem_type) > 0) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Parallel IO does not support writing VL or region reference datatypes yet") + if (H5T_is_vl_storage(type_info.mem_type) > 0) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "Parallel IO does not support writing VL or region reference datatypes yet") } /* end if */ else { - H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ + H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ /* Get I/O transfer mode */ - if(H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Collective access is not permissible without a MPI based VFD */ - if(io_xfer_mode == H5FD_MPIO_COLLECTIVE) + if (io_xfer_mode == H5FD_MPIO_COLLECTIVE) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based driver only") - } /* end else */ + } /* end else */ #endif /*H5_HAVE_PARALLEL*/ /* Initialize dataspace information */ - if(!file_space) + if (!file_space) file_space = dataset->shared->space; - if(!mem_space) + if (!mem_space) mem_space = file_space; nelmts = H5S_GET_SELECT_NPOINTS(mem_space); /* Make certain that the number of elements in each selection is the same */ - if(nelmts != H5S_GET_SELECT_NPOINTS(file_space)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") + if (nelmts != H5S_GET_SELECT_NPOINTS(file_space)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "src and dest dataspaces have different number of elements selected") /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ - if(NULL == buf) { + if (NULL == buf) { /* Check for any elements selected (which is invalid) */ - if(nelmts > 0) + if (nelmts > 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") - /* If the buffer is nil, and 0 element is selected, make a fake buffer. - * This is for some MPI package like ChaMPIon on NCSA's tungsten which - * doesn't support this feature. - */ + /* If the buffer is nil, and 0 element is selected, make a fake buffer. + * This is for some MPI package like ChaMPIon on NCSA's tungsten which + * doesn't support this feature. + */ buf = &fake_char; } /* end if */ /* Make sure that both selections have their extents set */ - if(!(H5S_has_extent(file_space))) + if (!(H5S_has_extent(file_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") - if(!(H5S_has_extent(mem_space))) + if (!(H5S_has_extent(mem_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set") /* H5S_select_shape_same() has been modified to accept topologically @@ -714,21 +707,22 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * Note that in general, this requires us to touch up the memory buffer * as well. */ - if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && - H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { - const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ - /* to the beginning of the projected mem space. */ + if (TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && + H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { + const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ + /* to the beginning of the projected mem space. */ /* Attempt to construct projected dataspace for memory dataspace */ - if(H5S_select_construct_projection(mem_space, &projected_mem_space, - (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf, type_info.src_type_size) < 0) + if (H5S_select_construct_projection(mem_space, &projected_mem_space, + (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf, + type_info.src_type_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace") HDassert(projected_mem_space); HDassert(adj_buf); /* Switch to using projected memory dataspace & adjusted buffer */ mem_space = projected_mem_space; - buf = adj_buf; + buf = adj_buf; } /* end if */ /* Retrieve dataset properties */ @@ -736,88 +730,88 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Set up I/O operation */ io_info.op_type = H5D_IO_OP_WRITE; - io_info.u.wbuf = buf; - if(H5D__ioinfo_init(dataset, &type_info, &store, &io_info) < 0) + io_info.u.wbuf = buf; + if (H5D__ioinfo_init(dataset, &type_info, &store, &io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up I/O operation") /* Allocate dataspace and initialize it if it hasn't been. */ - if(nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && - !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage)) { - hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ - hbool_t full_overwrite; /* Whether we are over-writing all the elements */ + if (nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && + !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage)) { + hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ + hbool_t full_overwrite; /* Whether we are over-writing all the elements */ /* Get the number of elements in file dataset's dataspace */ - if((file_nelmts = H5S_GET_EXTENT_NPOINTS(file_space)) < 0) + if ((file_nelmts = H5S_GET_EXTENT_NPOINTS(file_space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "can't retrieve number of elements in file dataset") /* Always allow fill values to be written if the dataset has a VL datatype */ - if(H5T_detect_class(dataset->shared->type, H5T_VLEN, FALSE)) + if (H5T_detect_class(dataset->shared->type, H5T_VLEN, FALSE)) full_overwrite = FALSE; else full_overwrite = (hbool_t)((hsize_t)file_nelmts == nelmts ? TRUE : FALSE); /* Allocate storage */ - if(H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, full_overwrite, NULL) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, full_overwrite, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") } /* end if */ /* Allocate the chunk map */ - if(NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) + if (NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk map") /* Call storage method's I/O initialization routine */ - if(io_info.layout_ops.io_init && (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) + if (io_info.layout_ops.io_init && + (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info") io_op_init = TRUE; #ifdef H5_HAVE_PARALLEL /* Adjust I/O info for any parallel I/O */ - if(H5D__ioinfo_adjust(&io_info, dataset, file_space, mem_space, &type_info) < 0) + if (H5D__ioinfo_adjust(&io_info, dataset, file_space, mem_space, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to adjust I/O info for parallel I/O") #endif /*H5_HAVE_PARALLEL*/ /* Invoke correct "high level" I/O routine */ - if((*io_info.io_ops.multi_write)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) + if ((*io_info.io_ops.multi_write)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") #ifdef OLD_WAY -/* - * This was taken out because it can be called in a parallel program with - * independent access, causing the metadata cache to get corrupted. Its been - * disabled for all types of access (serial as well as parallel) to make the - * modification time consistent for all programs. -QAK - * - * We should set a value in the dataset's shared information instead and flush - * it to the file when the dataset is being closed. -QAK - */ + /* + * This was taken out because it can be called in a parallel program with + * independent access, causing the metadata cache to get corrupted. Its been + * disabled for all types of access (serial as well as parallel) to make the + * modification time consistent for all programs. -QAK + * + * We should set a value in the dataset's shared information instead and flush + * it to the file when the dataset is being closed. -QAK + */ /* * Update modification time. We have to do this explicitly because * writing to a dataset doesn't necessarily change the object header. */ - if(H5O_touch(&(dataset->oloc), FALSE) < 0) + if (H5O_touch(&(dataset->oloc), FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time") #endif /* OLD_WAY */ done: /* Shut down the I/O op information */ - if(io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0) + if (io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info") - if(fm) + if (fm) fm = H5FL_FREE(H5D_chunk_map_t, fm); /* Shut down datatype info for operation */ - if(type_info_init && H5D__typeinfo_term(&type_info) < 0) + if (type_info_init && H5D__typeinfo_term(&type_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down type info") /* discard projected mem space if it was created */ - if(NULL != projected_mem_space) - if(H5S_close(projected_mem_space) < 0) + if (NULL != projected_mem_space) + if (H5S_close(projected_mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down projected memory dataspace") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__write() */ - /*------------------------------------------------------------------------- * Function: H5D__ioinfo_init * @@ -832,8 +826,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, - H5D_storage_t *store, H5D_io_info_t *io_info) +H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, H5D_storage_t *store, H5D_io_info_t *io_info) { FUNC_ENTER_STATIC_NOERR @@ -845,31 +838,31 @@ H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, HDassert(io_info); /* Set up "normal" I/O fields */ - io_info->dset = dset; - io_info->f_sh = H5F_SHARED(dset->oloc.file); + io_info->dset = dset; + io_info->f_sh = H5F_SHARED(dset->oloc.file); io_info->store = store; /* Set I/O operations to initial values */ io_info->layout_ops = *dset->shared->layout.ops; /* Set the "high-level" I/O operations for the dataset */ - io_info->io_ops.multi_read = dset->shared->layout.ops->ser_read; + io_info->io_ops.multi_read = dset->shared->layout.ops->ser_read; io_info->io_ops.multi_write = dset->shared->layout.ops->ser_write; /* Set the I/O operations for reading/writing single blocks on disk */ - if(type_info->is_xform_noop && type_info->is_conv_noop) { + if (type_info->is_xform_noop && type_info->is_conv_noop) { /* * If there is no data transform or type conversion then read directly into * the application's buffer. This saves at least one mem-to-mem copy. */ - io_info->io_ops.single_read = H5D__select_read; + io_info->io_ops.single_read = H5D__select_read; io_info->io_ops.single_write = H5D__select_write; } /* end if */ else { /* * This is the general case (type conversion, usually). */ - io_info->io_ops.single_read = H5D__scatgath_read; + io_info->io_ops.single_read = H5D__scatgath_read; io_info->io_ops.single_write = H5D__scatgath_write; } /* end else */ @@ -881,7 +874,6 @@ H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__ioinfo_init() */ - /*------------------------------------------------------------------------- * Function: H5D__typeinfo_init * @@ -896,13 +888,12 @@ H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, *------------------------------------------------------------------------- */ static herr_t -H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, - H5D_type_info_t *type_info) +H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, H5D_type_info_t *type_info) { - const H5T_t *src_type; /* Source datatype */ - const H5T_t *dst_type; /* Destination datatype */ - H5Z_data_xform_t *data_transform; /* Data transform info */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5T_t * src_type; /* Source datatype */ + const H5T_t * dst_type; /* Destination datatype */ + H5Z_data_xform_t *data_transform; /* Data transform info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -911,26 +902,26 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, HDassert(dset); /* Patch the top level file pointer for dt->shared->u.vlen.f if needed */ - if(H5T_patch_vlen_file(dset->shared->type, H5F_VOL_OBJ(dset->oloc.file)) < 0 ) + if (H5T_patch_vlen_file(dset->shared->type, H5F_VOL_OBJ(dset->oloc.file)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch VL datatype file pointer") /* Initialize type info safely */ HDmemset(type_info, 0, sizeof(*type_info)); /* Get the memory & dataset datatypes */ - if(NULL == (type_info->mem_type = (const H5T_t *)H5I_object_verify(mem_type_id, H5I_DATATYPE))) + if (NULL == (type_info->mem_type = (const H5T_t *)H5I_object_verify(mem_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") type_info->dset_type = dset->shared->type; - if(do_write) { - src_type = type_info->mem_type; - dst_type = dset->shared->type; + if (do_write) { + src_type = type_info->mem_type; + dst_type = dset->shared->type; type_info->src_type_id = mem_type_id; type_info->dst_type_id = dset->shared->type_id; } /* end if */ else { - src_type = dset->shared->type; - dst_type = type_info->mem_type; + src_type = dset->shared->type; + dst_type = type_info->mem_type; type_info->src_type_id = dset->shared->type_id; type_info->dst_type_id = mem_type_id; } /* end else */ @@ -942,73 +933,72 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, * enough value in xfer_parms since turning off datatype conversion also * turns off background preservation. */ - if(NULL == (type_info->tpath = H5T_path_find(src_type, dst_type))) + if (NULL == (type_info->tpath = H5T_path_find(src_type, dst_type))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") /* Retrieve info from API context */ - if(H5CX_get_data_transform(&data_transform) < 0) + if (H5CX_get_data_transform(&data_transform) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info") /* Precompute some useful information */ type_info->src_type_size = H5T_get_size(src_type); type_info->dst_type_size = H5T_get_size(dst_type); type_info->max_type_size = MAX(type_info->src_type_size, type_info->dst_type_size); - type_info->is_conv_noop = H5T_path_noop(type_info->tpath); + type_info->is_conv_noop = H5T_path_noop(type_info->tpath); type_info->is_xform_noop = H5Z_xform_noop(data_transform); - if(type_info->is_xform_noop && type_info->is_conv_noop) { + if (type_info->is_xform_noop && type_info->is_conv_noop) { type_info->cmpd_subset = NULL; - type_info->need_bkg = H5T_BKG_NO; + type_info->need_bkg = H5T_BKG_NO; } /* end if */ else { - void *tconv_buf; /* Temporary conversion buffer pointer */ - void *bkgr_buf; /* Background conversion buffer pointer */ - size_t max_temp_buf; /* Maximum temporary buffer size */ - H5T_bkg_t bkgr_buf_type; /* Background buffer type */ - size_t target_size; /* Desired buffer size */ + void * tconv_buf; /* Temporary conversion buffer pointer */ + void * bkgr_buf; /* Background conversion buffer pointer */ + size_t max_temp_buf; /* Maximum temporary buffer size */ + H5T_bkg_t bkgr_buf_type; /* Background buffer type */ + size_t target_size; /* Desired buffer size */ /* Get info from API context */ - if(H5CX_get_max_temp_buf(&max_temp_buf) < 0) + if (H5CX_get_max_temp_buf(&max_temp_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve max. temp. buf size") - if(H5CX_get_tconv_buf(&tconv_buf) < 0) + if (H5CX_get_tconv_buf(&tconv_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve temp. conversion buffer pointer") - if(H5CX_get_bkgr_buf(&bkgr_buf) < 0) + if (H5CX_get_bkgr_buf(&bkgr_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve background conversion buffer pointer") - if(H5CX_get_bkgr_buf_type(&bkgr_buf_type) < 0) + if (H5CX_get_bkgr_buf_type(&bkgr_buf_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve background buffer type") /* Check if the datatypes are compound subsets of one another */ type_info->cmpd_subset = H5T_path_compound_subset(type_info->tpath); /* Check if we need a background buffer */ - if(do_write && H5T_detect_class(dset->shared->type, H5T_VLEN, FALSE)) + if (do_write && H5T_detect_class(dset->shared->type, H5T_VLEN, FALSE)) type_info->need_bkg = H5T_BKG_YES; else { - H5T_bkg_t path_bkg; /* Type conversion's background info */ + H5T_bkg_t path_bkg; /* Type conversion's background info */ - if((path_bkg = H5T_path_bkg(type_info->tpath))) { + if ((path_bkg = H5T_path_bkg(type_info->tpath))) { /* Retrieve the bkgr buffer property */ type_info->need_bkg = bkgr_buf_type; type_info->need_bkg = MAX(path_bkg, type_info->need_bkg); } /* end if */ else type_info->need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/ - } /* end else */ - + } /* end else */ /* Set up datatype conversion/background buffers */ target_size = max_temp_buf; /* If the buffer is too small to hold even one element, try to make it bigger */ - if(target_size < type_info->max_type_size) { - hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ + if (target_size < type_info->max_type_size) { + hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ /* Detect if we have all default settings for buffers */ - default_buffer_info = (hbool_t)((H5D_TEMP_BUF_SIZE == max_temp_buf) - && (NULL == tconv_buf) && (NULL == bkgr_buf)); + default_buffer_info = + (hbool_t)((H5D_TEMP_BUF_SIZE == max_temp_buf) && (NULL == tconv_buf) && (NULL == bkgr_buf)); /* Check if we are using the default buffer info */ - if(default_buffer_info) + if (default_buffer_info) /* OK to get bigger for library default settings */ target_size = type_info->max_type_size; else @@ -1020,42 +1010,43 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, type_info->request_nelmts = target_size / type_info->max_type_size; /* Sanity check elements in temporary buffer */ - if(type_info->request_nelmts == 0) + if (type_info->request_nelmts == 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* Get a temporary buffer for type conversion unless the app has already * supplied one through the xfer properties. Instead of allocating a * buffer which is the exact size, we allocate the target size. */ - if(NULL == (type_info->tconv_buf = (uint8_t *)tconv_buf)) { + if (NULL == (type_info->tconv_buf = (uint8_t *)tconv_buf)) { /* Allocate temporary buffer */ - if(NULL == (type_info->tconv_buf = H5FL_BLK_CALLOC(type_conv, target_size))) + if (NULL == (type_info->tconv_buf = H5FL_BLK_CALLOC(type_conv, target_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") type_info->tconv_buf_allocated = TRUE; } /* end if */ - if(type_info->need_bkg && NULL == (type_info->bkg_buf = (uint8_t *)bkgr_buf)) { - size_t bkg_size; /* Desired background buffer size */ + if (type_info->need_bkg && NULL == (type_info->bkg_buf = (uint8_t *)bkgr_buf)) { + size_t bkg_size; /* Desired background buffer size */ /* Compute the background buffer size */ /* (don't try to use buffers smaller than the default size) */ bkg_size = type_info->request_nelmts * type_info->dst_type_size; - if(bkg_size < max_temp_buf) + if (bkg_size < max_temp_buf) bkg_size = max_temp_buf; /* Allocate background buffer */ /* (Need calloc()-like call since memory needs to be initialized) */ - if(NULL == (type_info->bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") + if (NULL == (type_info->bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for background conversion") type_info->bkg_buf_allocated = TRUE; } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__typeinfo_init() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5D__ioinfo_adjust * @@ -1069,11 +1060,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, - const H5S_t *file_space, const H5S_t *mem_space, - const H5D_type_info_t *type_info) +H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, const H5S_t *file_space, const H5S_t *mem_space, + const H5D_type_info_t *type_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1090,34 +1080,34 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, * the DXPL (if it's non-default) was previously used in a collective * I/O operation. */ - if(!H5CX_is_def_dxpl()) { + if (!H5CX_is_def_dxpl()) { H5CX_set_mpio_actual_chunk_opt(H5D_MPIO_NO_CHUNK_OPTIMIZATION); H5CX_set_mpio_actual_io_mode(H5D_MPIO_NO_COLLECTIVE); } /* end if */ /* Make any parallel I/O adjustments */ - if(io_info->using_mpi_vfd) { + if (io_info->using_mpi_vfd) { H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request */ - htri_t opt; /* Flag whether a selection is optimizable */ + htri_t opt; /* Flag whether a selection is optimizable */ /* Get the original state of parallel I/O transfer mode */ - if(H5CX_get_io_xfer_mode(&xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Get MPI communicator */ - if(MPI_COMM_NULL == (io_info->comm = H5F_mpi_get_comm(dset->oloc.file))) + if (MPI_COMM_NULL == (io_info->comm = H5F_mpi_get_comm(dset->oloc.file))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve MPI communicator") /* Check if we can set direct MPI-IO read/write functions */ - if((opt = H5D__mpio_opt_possible(io_info, file_space, mem_space, type_info)) < 0) + if ((opt = H5D__mpio_opt_possible(io_info, file_space, mem_space, type_info)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "invalid check for direct IO dataspace ") /* Check if we can use the optimized parallel I/O routines */ - if(opt == TRUE) { + if (opt == TRUE) { /* Override the I/O op pointers to the MPI-specific routines */ - io_info->io_ops.multi_read = dset->shared->layout.ops->par_read; - io_info->io_ops.multi_write = dset->shared->layout.ops->par_write; - io_info->io_ops.single_read = H5D__mpio_select_read; + io_info->io_ops.multi_read = dset->shared->layout.ops->par_read; + io_info->io_ops.multi_write = dset->shared->layout.ops->par_write; + io_info->io_ops.single_read = H5D__mpio_select_read; io_info->io_ops.single_write = H5D__mpio_select_write; } /* end if */ else { @@ -1126,41 +1116,46 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, * otherwise there will be metadata inconsistencies in the file. */ if (io_info->op_type == H5D_IO_OP_WRITE && io_info->dset->shared->dcpl_cache.pline.nused > 0) { - H5D_mpio_no_collective_cause_t cause; - uint32_t local_no_collective_cause; - uint32_t global_no_collective_cause; - hbool_t local_error_message_previously_written = FALSE; - hbool_t global_error_message_previously_written = FALSE; - size_t idx; - size_t cause_strings_len; - char local_no_collective_cause_string[512] = ""; - char global_no_collective_cause_string[512] = ""; - const char *cause_strings[] = { "independent I/O was requested", - "datatype conversions were required", - "data transforms needed to be applied", - "optimized MPI types flag wasn't set", - "one of the dataspaces was neither simple nor scalar", - "dataset was not contiguous or chunked", - "parallel writes to filtered datasets are disabled", - "an error occurred while checking if collective I/O was possible" }; + H5D_mpio_no_collective_cause_t cause; + uint32_t local_no_collective_cause; + uint32_t global_no_collective_cause; + hbool_t local_error_message_previously_written = FALSE; + hbool_t global_error_message_previously_written = FALSE; + size_t idx; + size_t cause_strings_len; + char local_no_collective_cause_string[512] = ""; + char global_no_collective_cause_string[512] = ""; + const char * cause_strings[] = { + "independent I/O was requested", + "datatype conversions were required", + "data transforms needed to be applied", + "optimized MPI types flag wasn't set", + "one of the dataspaces was neither simple nor scalar", + "dataset was not contiguous or chunked", + "parallel writes to filtered datasets are disabled", + "an error occurred while checking if collective I/O was possible"}; cause_strings_len = sizeof(cause_strings) / sizeof(cause_strings[0]); - if(H5CX_get_mpio_local_no_coll_cause(&local_no_collective_cause) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get local no collective cause value") - if(H5CX_get_mpio_global_no_coll_cause(&global_no_collective_cause) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get global no collective cause value") + if (H5CX_get_mpio_local_no_coll_cause(&local_no_collective_cause) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to get local no collective cause value") + if (H5CX_get_mpio_global_no_coll_cause(&global_no_collective_cause) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to get global no collective cause value") /* Append each of the "reason for breaking collective I/O" error messages to the * local and global no collective cause strings */ - for (cause = 1, idx = 0; (cause < H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE) && (idx < cause_strings_len); cause <<= 1, idx++) { + for (cause = 1, idx = 0; + (cause < H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE) && (idx < cause_strings_len); + cause <<= 1, idx++) { size_t cause_strlen = HDstrlen(cause_strings[idx]); if (cause & local_no_collective_cause) { - /* Check if there were any previous error messages included. If so, prepend a semicolon - * to separate the messages. + /* Check if there were any previous error messages included. If so, prepend a + * semicolon to separate the messages. */ - if(local_error_message_previously_written) + if (local_error_message_previously_written) HDstrncat(local_no_collective_cause_string, "; ", 2); HDstrncat(local_no_collective_cause_string, cause_strings[idx], cause_strlen); @@ -1168,44 +1163,43 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, local_error_message_previously_written = TRUE; } /* end if */ - if(cause & global_no_collective_cause) { - /* Check if there were any previous error messages included. If so, prepend a semicolon - * to separate the messages. + if (cause & global_no_collective_cause) { + /* Check if there were any previous error messages included. If so, prepend a + * semicolon to separate the messages. */ - if(global_error_message_previously_written) + if (global_error_message_previously_written) HDstrncat(global_no_collective_cause_string, "; ", 2); HDstrncat(global_no_collective_cause_string, cause_strings[idx], cause_strlen); global_error_message_previously_written = TRUE; } /* end if */ - } /* end for */ - - HGOTO_ERROR(H5E_IO, H5E_NO_INDEPENDENT, FAIL, "Can't perform independent write with filters in pipeline.\n" - " The following caused a break from collective I/O:\n" - " Local causes: %s\n" - " Global causes: %s", - local_no_collective_cause_string, - global_no_collective_cause_string); + } /* end for */ + + HGOTO_ERROR(H5E_IO, H5E_NO_INDEPENDENT, FAIL, + "Can't perform independent write with filters in pipeline.\n" + " The following caused a break from collective I/O:\n" + " Local causes: %s\n" + " Global causes: %s", + local_no_collective_cause_string, global_no_collective_cause_string); } /* end if */ /* If we won't be doing collective I/O, but the user asked for * collective I/O, change the request to use independent I/O */ - if(xfer_mode == H5FD_MPIO_COLLECTIVE) { + if (xfer_mode == H5FD_MPIO_COLLECTIVE) { /* Change the xfer_mode to independent for handling the I/O */ - if(H5CX_set_io_xfer_mode(H5FD_MPIO_INDEPENDENT) < 0) + if (H5CX_set_io_xfer_mode(H5FD_MPIO_INDEPENDENT) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__ioinfo_adjust() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5D__typeinfo_term * @@ -1224,15 +1218,14 @@ H5D__typeinfo_term(const H5D_type_info_t *type_info) FUNC_ENTER_STATIC_NOERR /* Check for releasing datatype conversion & background buffers */ - if(type_info->tconv_buf_allocated) { + if (type_info->tconv_buf_allocated) { HDassert(type_info->tconv_buf); (void)H5FL_BLK_FREE(type_conv, type_info->tconv_buf); } /* end if */ - if(type_info->bkg_buf_allocated) { + if (type_info->bkg_buf_allocated) { HDassert(type_info->bkg_buf); (void)H5FL_BLK_FREE(type_conv, type_info->bkg_buf); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__typeinfo_term() */ - diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 679a33b..160f9f5 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -15,58 +15,49 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLprivate.h" /* Local heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLprivate.h" /* Local heaps */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ /* Format version bounds for layout */ const unsigned H5O_layout_ver_bounds[] = { - H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ /* H5O_LAYOUT_VERSION_DEFAULT */ - H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V110 */ - H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V112 */ - H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ /* H5O_LAYOUT_VERSION_DEFAULT */ + H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V110 */ + H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V112 */ + H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - - /*------------------------------------------------------------------------- * Function: H5D__layout_set_io_ops * @@ -83,7 +74,7 @@ const unsigned H5O_layout_ver_bounds[] = { herr_t H5D__layout_set_io_ops(const H5D_t *dataset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -91,9 +82,9 @@ H5D__layout_set_io_ops(const H5D_t *dataset) HDassert(dataset); /* Set the I/O functions for each layout type */ - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CONTIGUOUS: - if(dataset->shared->dcpl_cache.efl.nused > 0) + if (dataset->shared->dcpl_cache.efl.nused > 0) dataset->shared->layout.ops = H5D_LOPS_EFL; else dataset->shared->layout.ops = H5D_LOPS_CONTIG; @@ -103,7 +94,7 @@ H5D__layout_set_io_ops(const H5D_t *dataset) dataset->shared->layout.ops = H5D_LOPS_CHUNK; /* Set the chunk operations */ - switch(dataset->shared->layout.u.chunk.idx_type) { + switch (dataset->shared->layout.u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_BTREE; break; @@ -153,7 +144,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_io_ops() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_meta_size * @@ -172,7 +162,7 @@ done: size_t H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE @@ -180,32 +170,32 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ HDassert(f); HDassert(layout); - ret_value = 1 + /* Version number */ - 1; /* layout class type */ + ret_value = 1 + /* Version number */ + 1; /* layout class type */ - switch(layout->type) { + switch (layout->type) { case H5D_COMPACT: /* This information only present in older versions of message */ /* Size of raw data */ ret_value += 2; - if(include_compact_data) + if (include_compact_data) ret_value += layout->storage.u.compact.size; /* data for compact dataset */ break; case H5D_CONTIGUOUS: /* This information only present in older versions of message */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ + ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ + ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ break; case H5D_CHUNKED: - if(layout->version < H5O_LAYOUT_VERSION_4) { + if (layout->version < H5O_LAYOUT_VERSION_4) { /* Number of dimensions (1 byte) */ HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); ret_value++; /* B-tree address */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ + ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ /* Dimension sizes */ ret_value += layout->u.chunk.ndims * 4; @@ -228,9 +218,10 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ /* Type of chunk index */ ret_value++; - switch(layout->u.chunk.idx_type) { + switch (layout->u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, 0, "v1 B-tree index type found for layout message >v3") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, 0, + "v1 B-tree index type found for layout message >v3") case H5D_CHUNK_IDX_NONE: /* nothing */ @@ -238,10 +229,10 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ case H5D_CHUNK_IDX_SINGLE: /* Possible filter information */ - if(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { - ret_value += H5F_SIZEOF_SIZE(f); /* Size of chunk (in file) */ - ret_value += 4; /* Filter mask for chunk */ - } /* end if */ + if (layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + ret_value += H5F_SIZEOF_SIZE(f); /* Size of chunk (in file) */ + ret_value += 4; /* Filter mask for chunk */ + } /* end if */ break; case H5D_CHUNK_IDX_FARRAY: @@ -270,8 +261,8 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ break; case H5D_VIRTUAL: - ret_value += H5F_SIZEOF_ADDR(f); /* Address of global heap */ - ret_value += 4; /* Global heap index */ + ret_value += H5F_SIZEOF_ADDR(f); /* Address of global heap */ + ret_value += 4; /* Global heap index */ break; case H5D_LAYOUT_ERROR: @@ -284,7 +275,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_meta_size() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_set_version * @@ -299,8 +289,8 @@ done: herr_t H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -312,7 +302,7 @@ H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) version = MAX(layout->version, H5O_layout_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "layout version out of bounds") /* Set the message version */ @@ -322,7 +312,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_version() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_set_latest_indexing * @@ -336,10 +325,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, - const H5D_dcpl_cache_t *dcpl_cache) +H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, const H5D_dcpl_cache_t *dcpl_cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -349,104 +337,104 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, HDassert(dcpl_cache); /* The indexing methods only apply to chunked datasets (currently) */ - if(layout->type == H5D_CHUNKED) { - int sndims; /* Rank of dataspace */ - unsigned ndims; /* Rank of dataspace */ + if (layout->type == H5D_CHUNKED) { + int sndims; /* Rank of dataspace */ + unsigned ndims; /* Rank of dataspace */ /* Query the dimensionality of the dataspace */ - if((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0) + if ((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "invalid dataspace rank") ndims = (unsigned)sndims; /* Avoid scalar/null dataspace */ - if(ndims > 0) { - hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Maximum dimension sizes */ - hsize_t cur_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ - unsigned unlim_count = 0; /* Count of unlimited max. dimensions */ - hbool_t single = TRUE; /* Fulfill single chunk indexing */ - unsigned u; /* Local index variable */ + if (ndims > 0) { + hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Maximum dimension sizes */ + hsize_t cur_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ + unsigned unlim_count = 0; /* Count of unlimited max. dimensions */ + hbool_t single = TRUE; /* Fulfill single chunk indexing */ + unsigned u; /* Local index variable */ /* Query the dataspace's dimensions */ - if(H5S_get_simple_extent_dims(space, cur_dims, max_dims) < 0) + if (H5S_get_simple_extent_dims(space, cur_dims, max_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace max. dimensions") /* Spin through the max. dimensions, looking for unlimited dimensions */ - for(u = 0; u < ndims; u++) { - if(max_dims[u] == H5S_UNLIMITED) + for (u = 0; u < ndims; u++) { + if (max_dims[u] == H5S_UNLIMITED) unlim_count++; - if(cur_dims[u] != max_dims[u] || cur_dims[u] != layout->u.chunk.dim[u]) + if (cur_dims[u] != max_dims[u] || cur_dims[u] != layout->u.chunk.dim[u]) single = FALSE; } /* end for */ /* Chunked datasets with unlimited dimension(s) */ - if(unlim_count) { /* dataset with unlimited dimension(s) must be chunked */ - if(1 == unlim_count) { /* Chunked dataset with only 1 unlimited dimension */ + if (unlim_count) { /* dataset with unlimited dimension(s) must be chunked */ + if (1 == unlim_count) { /* Chunked dataset with only 1 unlimited dimension */ /* Set the chunk index type to an extensible array */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_EARRAY; + layout->u.chunk.idx_type = H5D_CHUNK_IDX_EARRAY; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_EARRAY; - layout->storage.u.chunk.ops = H5D_COPS_EARRAY; + layout->storage.u.chunk.ops = H5D_COPS_EARRAY; /* Set the extensible array creation parameters */ /* (use hard-coded defaults for now, until we give applications * control over this with a property list - QAK) */ - layout->u.chunk.u.earray.cparam.max_nelmts_bits = H5D_EARRAY_MAX_NELMTS_BITS; - layout->u.chunk.u.earray.cparam.idx_blk_elmts = H5D_EARRAY_IDX_BLK_ELMTS; + layout->u.chunk.u.earray.cparam.max_nelmts_bits = H5D_EARRAY_MAX_NELMTS_BITS; + layout->u.chunk.u.earray.cparam.idx_blk_elmts = H5D_EARRAY_IDX_BLK_ELMTS; layout->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs = H5D_EARRAY_SUP_BLK_MIN_DATA_PTRS; - layout->u.chunk.u.earray.cparam.data_blk_min_elmts = H5D_EARRAY_DATA_BLK_MIN_ELMTS; - layout->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS; - } /* end if */ + layout->u.chunk.u.earray.cparam.data_blk_min_elmts = H5D_EARRAY_DATA_BLK_MIN_ELMTS; + layout->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = + H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS; + } /* end if */ else { /* Chunked dataset with > 1 unlimited dimensions */ /* Set the chunk index type to v2 B-tree */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_BT2; + layout->u.chunk.idx_type = H5D_CHUNK_IDX_BT2; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BT2; - layout->storage.u.chunk.ops = H5D_COPS_BT2; + layout->storage.u.chunk.ops = H5D_COPS_BT2; /* Set the v2 B-tree creation parameters */ /* (use hard-coded defaults for now, until we give applications * control over this with a property list - QAK) */ - layout->u.chunk.u.btree2.cparam.node_size = H5D_BT2_NODE_SIZE; + layout->u.chunk.u.btree2.cparam.node_size = H5D_BT2_NODE_SIZE; layout->u.chunk.u.btree2.cparam.split_percent = H5D_BT2_SPLIT_PERC; - layout->u.chunk.u.btree2.cparam.merge_percent = H5D_BT2_MERGE_PERC; - } /* end else */ - } /* end if */ - else { /* Chunked dataset with fixed dimensions */ + layout->u.chunk.u.btree2.cparam.merge_percent = H5D_BT2_MERGE_PERC; + } /* end else */ + } /* end if */ + else { /* Chunked dataset with fixed dimensions */ /* Check for correct condition for using "single chunk" chunk index */ - if(single) { - layout->u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; + if (single) { + layout->u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; - layout->storage.u.chunk.ops = H5D_COPS_SINGLE; + layout->storage.u.chunk.ops = H5D_COPS_SINGLE; } /* end if */ - else if(!dcpl_cache->pline.nused && - dcpl_cache->fill.alloc_time == H5D_ALLOC_TIME_EARLY) { + else if (!dcpl_cache->pline.nused && dcpl_cache->fill.alloc_time == H5D_ALLOC_TIME_EARLY) { /* Set the chunk index type to "none" Index */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_NONE; + layout->u.chunk.idx_type = H5D_CHUNK_IDX_NONE; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_NONE; - layout->storage.u.chunk.ops = H5D_COPS_NONE; + layout->storage.u.chunk.ops = H5D_COPS_NONE; } /* end else-if */ else { /* Set the chunk index type to Fixed Array */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; + layout->u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; - layout->storage.u.chunk.ops = H5D_COPS_FARRAY; + layout->storage.u.chunk.ops = H5D_COPS_FARRAY; /* Set the fixed array creation parameters */ /* (use hard-coded defaults for now, until we give applications * control over this with a property list - QAK) */ - layout->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS; + layout->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = + H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS; } /* end else */ - } /* end else */ - } /* end if */ - } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_latest_indexing() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_oh_create * @@ -463,11 +451,11 @@ done: herr_t H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) { - H5O_layout_t *layout; /* Dataset's layout information */ - const H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ - unsigned layout_mesg_flags; /* Flags for inserting layout message */ - hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t * layout; /* Dataset's layout information */ + const H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ + unsigned layout_mesg_flags; /* Flags for inserting layout message */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -477,20 +465,21 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) HDassert(dset); /* Set some local variables, for convenience */ - layout = &dset->shared->layout; + layout = &dset->shared->layout; fill_prop = &dset->shared->dcpl_cache.fill; /* Update the filters message, if this is a chunked dataset */ - if(layout->type == H5D_CHUNKED) { - H5O_pline_t *pline; /* Dataset's I/O pipeline information */ + if (layout->type == H5D_CHUNKED) { + H5O_pline_t *pline; /* Dataset's I/O pipeline information */ pline = &dset->shared->dcpl_cache.pline; - if(pline->nused > 0 && H5O_msg_append_oh(file, oh, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, pline) < 0) + if (pline->nused > 0 && + H5O_msg_append_oh(file, oh, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update filter header message") } /* end if */ /* Initialize the layout information for the new dataset */ - if(dset->shared->layout.ops->init && (dset->shared->layout.ops->init)(file, dset, dapl_id) < 0) + if (dset->shared->layout.ops->init && (dset->shared->layout.ops->init)(file, dset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize layout information") /* Indicate that the layout information was initialized */ @@ -500,46 +489,46 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) * Allocate storage if space allocate time is early; otherwise delay * allocation until later. */ - if(fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) { + if (fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) { H5D_io_info_t io_info; io_info.dset = dset; - if(H5D__alloc_storage(&io_info, H5D_ALLOC_CREATE, FALSE, NULL) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_CREATE, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") } /* Update external storage message, if it's used */ - if(dset->shared->dcpl_cache.efl.nused > 0) { + if (dset->shared->dcpl_cache.efl.nused > 0) { H5O_efl_t *efl = &dset->shared->dcpl_cache.efl; /* Dataset's external file list */ - H5HL_t *heap; /* Pointer to local heap for EFL file names */ - size_t heap_size = H5HL_ALIGN(1); - size_t u; + H5HL_t * heap; /* Pointer to local heap for EFL file names */ + size_t heap_size = H5HL_ALIGN(1); + size_t u; /* Determine size of heap needed to stored the file names */ - for(u = 0; u < efl->nused; ++u) + for (u = 0; u < efl->nused; ++u) heap_size += H5HL_ALIGN(HDstrlen(efl->slot[u].name) + 1); /* Create the heap for the EFL file names */ - if(H5HL_create(file, heap_size, &efl->heap_addr/*out*/) < 0) + if (H5HL_create(file, heap_size, &efl->heap_addr /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create EFL file name heap") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(file, efl->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(file, efl->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect EFL file name heap") /* Insert "empty" name first */ - if(UFAIL == H5HL_insert(file, heap, (size_t)1, "")) { + if (UFAIL == H5HL_insert(file, heap, (size_t)1, "")) { H5HL_unprotect(heap); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap") } /* end if */ - for(u = 0; u < efl->nused; ++u) { - size_t offset; /* Offset of file name in heap */ + for (u = 0; u < efl->nused; ++u) { + size_t offset; /* Offset of file name in heap */ /* Insert file name into heap */ - if(UFAIL == (offset = H5HL_insert(file, heap, - HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name))) { + if (UFAIL == + (offset = H5HL_insert(file, heap, HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name))) { H5HL_unprotect(heap); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap") } /* end if */ @@ -549,12 +538,12 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) } /* end for */ /* Release the heap */ - if(H5HL_unprotect(heap) < 0) + if (H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to unprotect EFL file name heap") heap = NULL; /* Insert EFL message into dataset object header */ - if(H5O_msg_append_oh(file, oh, H5O_EFL_ID, H5O_MSG_FLAG_CONSTANT, 0, efl) < 0) + if (H5O_msg_append_oh(file, oh, H5O_EFL_ID, H5O_MSG_FLAG_CONSTANT, 0, efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update external file list message") } /* end if */ @@ -562,34 +551,32 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) /* (Don't make layout message constant unless allocation time is early and * non-filtered and has >0 elements, since space may not be allocated -QAK) */ /* (Note: this is relying on H5D__alloc_storage not calling H5O_msg_write during dataset creation) */ - if(fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type - && !dset->shared->dcpl_cache.pline.nused - && (0 != H5S_GET_EXTENT_NPOINTS(dset->shared->space))) + if (fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type && + !dset->shared->dcpl_cache.pline.nused && (0 != H5S_GET_EXTENT_NPOINTS(dset->shared->space))) layout_mesg_flags = H5O_MSG_FLAG_CONSTANT; else - layout_mesg_flags = 0; + layout_mesg_flags = 0; /* Store VDS info in global heap */ - if(H5D_VIRTUAL == layout->type) - if(H5D__virtual_store_layout(file, layout) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to store VDS info") + if (H5D_VIRTUAL == layout->type) + if (H5D__virtual_store_layout(file, layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to store VDS info") /* Create layout message */ - if(H5O_msg_append_oh(file, oh, H5O_LAYOUT_ID, layout_mesg_flags, 0, layout) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout") + if (H5O_msg_append_oh(file, oh, H5O_LAYOUT_ID, layout_mesg_flags, 0, layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout") done: /* Error cleanup */ - if(ret_value < 0) - if(layout_init) + if (ret_value < 0) + if (layout_init) /* Destroy any cached layout information for the dataset */ - if(dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) + if (dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__layout_oh_create() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_oh_read * @@ -606,9 +593,9 @@ done: herr_t H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) { - htri_t msg_exists; /* Whether a particular type of message exists */ - hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t msg_exists; /* Whether a particular type of message exists */ + hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -617,15 +604,15 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) HDassert(plist); /* Get the optional filters message */ - if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_PLINE_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") - if(msg_exists) { + if (msg_exists) { /* Retrieve the I/O pipeline message */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline)) + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") /* Set the I/O pipeline info in the property list */ - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &dataset->shared->dcpl_cache.pline) < 0) + if (H5P_set(plist, H5O_CRT_PIPELINE_NAME, &dataset->shared->dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set pipeline") } /* end if */ @@ -635,20 +622,20 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) * values are copied to the dataset create plist so the user can query * them. */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout))) + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") layout_copied = TRUE; /* Check for external file list message (which might not exist) */ - if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_EFL_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_EFL_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") - if(msg_exists) { + if (msg_exists) { /* Retrieve the EFL message */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_EFL_ID, &dataset->shared->dcpl_cache.efl)) + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_EFL_ID, &dataset->shared->dcpl_cache.efl)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") /* Set the EFL info in the property list */ - if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->dcpl_cache.efl) < 0) + if (H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->dcpl_cache.efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set external file list") /* Set the dataset's I/O operations */ @@ -659,31 +646,31 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) HDassert(dataset->shared->layout.ops); /* Initialize the layout information for the dataset */ - if(dataset->shared->layout.ops->init && (dataset->shared->layout.ops->init)(dataset->oloc.file, dataset, dapl_id) < 0) + if (dataset->shared->layout.ops->init && + (dataset->shared->layout.ops->init)(dataset->oloc.file, dataset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize layout information") /* Adjust chunk dimensions to omit datatype size (in last dimension) for creation property */ - if(H5D_CHUNKED == dataset->shared->layout.type) + if (H5D_CHUNKED == dataset->shared->layout.type) dataset->shared->layout.u.chunk.ndims--; /* Copy layout to the DCPL */ - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout) < 0) + if (H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout") /* Set chunk sizes */ - if(H5D_CHUNKED == dataset->shared->layout.type) - if(H5D__chunk_set_sizes(dataset) < 0) + if (H5D_CHUNKED == dataset->shared->layout.type) + if (H5D__chunk_set_sizes(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to set chunk sizes") done: - if(ret_value < 0 && layout_copied) - if(H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) + if (ret_value < 0 && layout_copied) + if (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_oh_read() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_oh_write * @@ -700,8 +687,8 @@ done: herr_t H5D__layout_oh_write(const H5D_t *dataset, H5O_t *oh, unsigned update_flags) { - htri_t msg_exists; /* Whether the layout message exists */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t msg_exists; /* Whether the layout message exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -710,15 +697,15 @@ H5D__layout_oh_write(const H5D_t *dataset, H5O_t *oh, unsigned update_flags) HDassert(oh); /* Check if the layout message has been added to the dataset's header */ - if((msg_exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) + if ((msg_exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to check if layout message exists") - if(msg_exists) { + if (msg_exists) { /* Write the layout message to the dataset's header */ - if(H5O_msg_write_oh(dataset->oloc.file, oh, H5O_LAYOUT_ID, 0, update_flags, &dataset->shared->layout) < 0) + if (H5O_msg_write_oh(dataset->oloc.file, oh, H5O_LAYOUT_ID, 0, update_flags, + &dataset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout message") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_oh_write() */ - diff --git a/src/H5Dmodule.h b/src/H5Dmodule.h index 27ccf54..178e50f 100644 --- a/src/H5Dmodule.h +++ b/src/H5Dmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5D_MODULE -#define H5_MY_PKG H5D -#define H5_MY_PKG_ERR H5E_DATASET -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5D +#define H5_MY_PKG_ERR H5E_DATASET +#define H5_MY_PKG_INIT YES #endif /* _H5Dmodule_H */ - diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index cfed02e..3bed43f 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -25,24 +25,23 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VMprivate.h" /* Vector */ #ifdef H5_HAVE_PARALLEL @@ -67,7 +66,7 @@ #define H5D_OBTAIN_ALL_CHUNK_ADDR_COL 2 /* Macros to define the default ratio of obtaining all chunk addresses for one linked-chunk IO case */ -#define H5D_ALL_CHUNK_ADDR_THRES_COL 30 +#define H5D_ALL_CHUNK_ADDR_THRES_COL 30 #define H5D_ALL_CHUNK_ADDR_THRES_COL_NUM 10000 /***** Macros for multi-chunk collective IO case. *****/ @@ -77,31 +76,29 @@ */ /* Macros to represent different IO modes(NONE, Independent or collective)for multiple chunk IO case */ -#define H5D_CHUNK_IO_MODE_COL 1 +#define H5D_CHUNK_IO_MODE_COL 1 /* Macros to represent the regularity of the selection for multiple chunk IO case. */ -#define H5D_CHUNK_SELECT_REG 1 - +#define H5D_CHUNK_SELECT_REG 1 /******************/ /* Local Typedefs */ /******************/ /* Combine chunk address and chunk info into a struct for better performance. */ typedef struct H5D_chunk_addr_info_t { - haddr_t chunk_addr; + haddr_t chunk_addr; H5D_chunk_info_t chunk_info; } H5D_chunk_addr_info_t; /* Rank 0 Bcast values */ typedef enum H5D_mpio_no_rank0_bcast_cause_t { - H5D_MPIO_RANK0_BCAST = 0x00, - H5D_MPIO_RANK0_NOT_H5S_ALL = 0x01, - H5D_MPIO_RANK0_NOT_CONTIGUOUS = 0x02, - H5D_MPIO_RANK0_NOT_FIXED_SIZE = 0x04, + H5D_MPIO_RANK0_BCAST = 0x00, + H5D_MPIO_RANK0_NOT_H5S_ALL = 0x01, + H5D_MPIO_RANK0_NOT_CONTIGUOUS = 0x02, + H5D_MPIO_RANK0_NOT_FIXED_SIZE = 0x04, H5D_MPIO_RANK0_GREATER_THAN_2GB = 0x08 } H5D_mpio_no_rank0_bcast_cause_t; - /* * Information about a single chunk when performing collective filtered I/O. All * of the fields of one of these structs are initialized at the start of collective @@ -186,91 +183,93 @@ typedef enum H5D_mpio_no_rank0_bcast_cause_t { * receive_buffer_array fields. */ typedef struct H5D_filtered_collective_io_info_t { - hsize_t index; - hsize_t scaled[H5O_LAYOUT_NDIMS]; - hbool_t full_overwrite; - size_t num_writers; - size_t io_size; - void *buf; - - struct { - H5F_block_t chunk_current; - H5F_block_t new_chunk; - } chunk_states; - - struct { - int original_owner; - int new_owner; - } owners; - - struct { - MPI_Request *receive_requests_array; - unsigned char **receive_buffer_array; - int num_receive_requests; - } async_info; + hsize_t index; + hsize_t scaled[H5O_LAYOUT_NDIMS]; + hbool_t full_overwrite; + size_t num_writers; + size_t io_size; + void * buf; + + struct { + H5F_block_t chunk_current; + H5F_block_t new_chunk; + } chunk_states; + + struct { + int original_owner; + int new_owner; + } owners; + + struct { + MPI_Request * receive_requests_array; + unsigned char **receive_buffer_array; + int num_receive_requests; + } async_info; } H5D_filtered_collective_io_info_t; /********************/ /* Local Prototypes */ /********************/ -static herr_t H5D__chunk_collective_io(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); -static herr_t H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); -static herr_t H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); -static herr_t H5D__link_chunk_collective_io(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, H5D_chunk_map_t *fm, int sum_chunk); -static herr_t H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); -static herr_t H5D__inter_collective_io(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, const H5S_t *file_space, - const H5S_t *mem_space); -static herr_t H5D__final_collective_io(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, MPI_Datatype mpi_file_type, - MPI_Datatype mpi_buf_type); +static herr_t H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + H5D_chunk_map_t *fm); +static herr_t H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + H5D_chunk_map_t *fm); +static herr_t H5D__multi_chunk_filtered_collective_io(H5D_io_info_t * io_info, + const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); +static herr_t H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + H5D_chunk_map_t *fm, int sum_chunk); +static herr_t H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + H5D_chunk_map_t *fm); +static herr_t H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + const H5S_t *file_space, const H5S_t *mem_space); +static herr_t H5D__final_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, MPI_Datatype mpi_file_type, MPI_Datatype mpi_buf_type); static herr_t H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, - H5D_chunk_addr_info_t chunk_addr_info_array[], int many_chunk_opt); -static herr_t H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, - uint8_t assign_io_mode[], haddr_t chunk_addr[]); -static herr_t H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, - const H5D_chunk_map_t *fm, int *sum_chunkf); -static herr_t H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, const H5D_chunk_map_t *fm, - H5D_filtered_collective_io_info_t **chunk_list, size_t *num_entries); + H5D_chunk_addr_info_t chunk_addr_info_array[], int many_chunk_opt); +static herr_t H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assign_io_mode[], + haddr_t chunk_addr[]); +static herr_t H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, + int *sum_chunkf); +static herr_t H5D__construct_filtered_io_info_list(const H5D_io_info_t * io_info, + const H5D_type_info_t * type_info, + const H5D_chunk_map_t * fm, + H5D_filtered_collective_io_info_t **chunk_list, + size_t * num_entries); #if MPI_VERSION >= 3 -static herr_t H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, const H5D_chunk_map_t *fm, - H5D_filtered_collective_io_info_t *local_chunk_array, size_t *local_chunk_array_num_entries); +static herr_t H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t * io_info, + const H5D_type_info_t * type_info, + const H5D_chunk_map_t * fm, + H5D_filtered_collective_io_info_t *local_chunk_array, + size_t *local_chunk_array_num_entries); #endif static herr_t H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, - size_t array_entry_size, void **gathered_array, size_t *gathered_array_num_entries, - hbool_t allgather, int root, MPI_Comm comm, int (*sort_func)(const void *, const void *)); -static herr_t H5D__mpio_filtered_collective_write_type( - H5D_filtered_collective_io_info_t *chunk_list, size_t num_entries, - MPI_Datatype *new_mem_type, hbool_t *mem_type_derived, - MPI_Datatype *new_file_type, hbool_t *file_type_derived); + size_t array_entry_size, void **gathered_array, + size_t *gathered_array_num_entries, hbool_t allgather, int root, + MPI_Comm comm, int (*sort_func)(const void *, const void *)); +static herr_t H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chunk_list, + size_t num_entries, MPI_Datatype *new_mem_type, + hbool_t *mem_type_derived, MPI_Datatype *new_file_type, + hbool_t *file_type_derived); static herr_t H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk_entry, - const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5D_chunk_map_t *fm); -static int H5D__cmp_chunk_addr(const void *chunk_addr_info1, const void *chunk_addr_info2); -static int H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_info_entry1, - const void *filtered_collective_io_info_entry2); + const H5D_io_info_t * io_info, + const H5D_type_info_t * type_info, + const H5D_chunk_map_t * fm); +static int H5D__cmp_chunk_addr(const void *chunk_addr_info1, const void *chunk_addr_info2); +static int H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_info_entry1, + const void *filtered_collective_io_info_entry2); #if MPI_VERSION >= 3 static int H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective_io_info_entry1, - const void *filtered_collective_io_info_entry2); + const void *filtered_collective_io_info_entry2); #endif - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5D__mpio_opt_possible * @@ -286,15 +285,15 @@ static int H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered *------------------------------------------------------------------------- */ htri_t -H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, - const H5S_t *mem_space, const H5D_type_info_t *type_info) +H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, const H5S_t *mem_space, + const H5D_type_info_t *type_info) { - H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ - unsigned local_cause[2] = {0,0}; /* [0] Local reason(s) for breaking collective mode */ - /* [1] Flag if dataset is both: H5S_ALL and small */ - unsigned global_cause[2] = {0,0}; /* Global reason(s) for breaking collective mode */ - htri_t is_vl_storage; /* Whether the dataset's datatype is stored in a variable-length form */ - htri_t ret_value = SUCCEED; /* Return value */ + H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ + unsigned local_cause[2] = {0, 0}; /* [0] Local reason(s) for breaking collective mode */ + /* [1] Flag if dataset is both: H5S_ALL and small */ + unsigned global_cause[2] = {0, 0}; /* Global reason(s) for breaking collective mode */ + htri_t is_vl_storage; /* Whether the dataset's datatype is stored in a variable-length form */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -304,47 +303,46 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, HDassert(file_space); HDassert(type_info); - /* For independent I/O, get out quickly and don't try to form consensus */ - if(H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) /* Set error flag, but keep going */ local_cause[0] |= H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE; - if(io_xfer_mode == H5FD_MPIO_INDEPENDENT) + if (io_xfer_mode == H5FD_MPIO_INDEPENDENT) local_cause[0] |= H5D_MPIO_SET_INDEPENDENT; /* Optimized MPI types flag must be set */ /* (based on 'HDF5_MPI_OPT_TYPES' environment variable) */ - if(!H5FD_mpi_opt_types_g) + if (!H5FD_mpi_opt_types_g) local_cause[0] |= H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED; /* Don't allow collective operations if datatype conversions need to happen */ - if(!type_info->is_conv_noop) + if (!type_info->is_conv_noop) local_cause[0] |= H5D_MPIO_DATATYPE_CONVERSION; /* Don't allow collective operations if data transform operations should occur */ - if(!type_info->is_xform_noop) + if (!type_info->is_xform_noop) local_cause[0] |= H5D_MPIO_DATA_TRANSFORMS; /* Check whether these are both simple or scalar dataspaces */ - if(!((H5S_SIMPLE == H5S_GET_EXTENT_TYPE(mem_space) || H5S_SCALAR == H5S_GET_EXTENT_TYPE(mem_space)) - && (H5S_SIMPLE == H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR == H5S_GET_EXTENT_TYPE(file_space)))) + if (!((H5S_SIMPLE == H5S_GET_EXTENT_TYPE(mem_space) || H5S_SCALAR == H5S_GET_EXTENT_TYPE(mem_space)) && + (H5S_SIMPLE == H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR == H5S_GET_EXTENT_TYPE(file_space)))) local_cause[0] |= H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES; /* Dataset storage must be contiguous or chunked */ - if(!(io_info->dset->shared->layout.type == H5D_CONTIGUOUS || - io_info->dset->shared->layout.type == H5D_CHUNKED)) + if (!(io_info->dset->shared->layout.type == H5D_CONTIGUOUS || + io_info->dset->shared->layout.type == H5D_CHUNKED)) local_cause[0] |= H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET; /* check if external-file storage is used */ - if(io_info->dset->shared->dcpl_cache.efl.nused > 0) + if (io_info->dset->shared->dcpl_cache.efl.nused > 0) local_cause[0] |= H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET; - /* The handling of memory space is different for chunking and contiguous - * storage. For contiguous storage, mem_space and file_space won't change - * when it it is doing disk IO. For chunking storage, mem_space will - * change for different chunks. So for chunking storage, whether we can - * use collective IO will defer until each chunk IO is reached. - */ + /* The handling of memory space is different for chunking and contiguous + * storage. For contiguous storage, mem_space and file_space won't change + * when it it is doing disk IO. For chunking storage, mem_space will + * change for different chunks. So for chunking storage, whether we can + * use collective IO will defer until each chunk IO is reached. + */ #if MPI_VERSION < 3 /* @@ -352,9 +350,8 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, * is less than 3. The functions needed (MPI_Mprobe and MPI_Imrecv) will * not be available. */ - if(io_info->op_type == H5D_IO_OP_WRITE && - io_info->dset->shared->layout.type == H5D_CHUNKED && - io_info->dset->shared->dcpl_cache.pline.nused > 0) + if (io_info->op_type == H5D_IO_OP_WRITE && io_info->dset->shared->layout.type == H5D_CHUNKED && + io_info->dset->shared->dcpl_cache.pline.nused > 0) local_cause[0] |= H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED; #endif @@ -363,29 +360,29 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, */ /* Check to see if the process is reading the entire dataset */ - if(H5S_GET_SELECT_TYPE(file_space) != H5S_SEL_ALL) + if (H5S_GET_SELECT_TYPE(file_space) != H5S_SEL_ALL) local_cause[1] |= H5D_MPIO_RANK0_NOT_H5S_ALL; /* Only perform this optimization for contigous datasets, currently */ - else if(H5D_CONTIGUOUS != io_info->dset->shared->layout.type) + else if (H5D_CONTIGUOUS != io_info->dset->shared->layout.type) /* Flag to do a MPI_Bcast of the data from one proc instead of * having all the processes involved in the collective I/O. */ local_cause[1] |= H5D_MPIO_RANK0_NOT_CONTIGUOUS; - else if((is_vl_storage = H5T_is_vl_storage(type_info->dset_type)) < 0) + else if ((is_vl_storage = H5T_is_vl_storage(type_info->dset_type)) < 0) local_cause[0] |= H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE; - else if(is_vl_storage) + else if (is_vl_storage) local_cause[1] |= H5D_MPIO_RANK0_NOT_FIXED_SIZE; else { - size_t type_size; /* Size of dataset's datatype */ + size_t type_size; /* Size of dataset's datatype */ /* Retrieve the size of the dataset's datatype */ - if(0 == (type_size = H5T_GET_SIZE(type_info->dset_type))) + if (0 == (type_size = H5T_GET_SIZE(type_info->dset_type))) local_cause[0] |= H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE; else { - hssize_t snelmts; /* [Signed] # of elements in dataset's dataspace */ + hssize_t snelmts; /* [Signed] # of elements in dataset's dataspace */ /* Retrieve the size of the dataset's datatype */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(file_space)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(file_space)) < 0) local_cause[0] |= H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE; else { hsize_t dset_size; @@ -393,26 +390,27 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, /* Determine dataset size */ dset_size = ((hsize_t)snelmts) * type_size; - /* If the size of the dataset is less than 2GB then do an MPI_Bcast - * of the data from one process instead of having all the processes - * involved in the collective I/O. - */ - if(dset_size > ((hsize_t)(2.0F * H5_GB) - 1)) + /* If the size of the dataset is less than 2GB then do an MPI_Bcast + * of the data from one process instead of having all the processes + * involved in the collective I/O. + */ + if (dset_size > ((hsize_t)(2.0F * H5_GB) - 1)) local_cause[1] |= H5D_MPIO_RANK0_GREATER_THAN_2GB; } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Check for independent I/O */ - if(local_cause[0] & H5D_MPIO_SET_INDEPENDENT) + if (local_cause[0] & H5D_MPIO_SET_INDEPENDENT) global_cause[0] = local_cause[0]; else { - int mpi_code; /* MPI error code */ + int mpi_code; /* MPI error code */ /* Form consensus opinion among all processes about whether to perform * collective I/O */ - if(MPI_SUCCESS != (mpi_code = MPI_Allreduce(&local_cause, &global_cause, 2, MPI_UNSIGNED, MPI_BOR, io_info->comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Allreduce(&local_cause, &global_cause, 2, MPI_UNSIGNED, MPI_BOR, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) } /* end else */ @@ -421,12 +419,12 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, H5CX_set_mpio_global_no_coll_cause(global_cause[0]); /* Set read-with-rank0-and-bcast flag if possible */ - if(global_cause[0] == 0 && global_cause[1] == 0) { + if (global_cause[0] == 0 && global_cause[1] == 0) { H5CX_set_mpio_rank0_bcast(TRUE); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY H5CX_test_set_mpio_coll_rank0_bcast(TRUE); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - } /* end if */ + } /* end if */ /* Set the return value, based on the global cause */ ret_value = global_cause[0] > 0 ? FALSE : TRUE; @@ -435,7 +433,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__mpio_opt_possible() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_select_read * @@ -449,22 +446,24 @@ done: */ herr_t H5D__mpio_select_read(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *type_info, - hsize_t mpi_buf_count, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space) + hsize_t mpi_buf_count, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space) { - const H5D_contig_storage_t *store_contig = &(io_info->store->contig); /* Contiguous storage info for this I/O operation */ + const H5D_contig_storage_t *store_contig = + &(io_info->store->contig); /* Contiguous storage info for this I/O operation */ herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE H5_CHECK_OVERFLOW(mpi_buf_count, hsize_t, size_t); - if(H5F_shared_block_read(io_info->f_sh, H5FD_MEM_DRAW, store_contig->dset_addr, (size_t)mpi_buf_count, io_info->u.rbuf) < 0) + if (H5F_shared_block_read(io_info->f_sh, H5FD_MEM_DRAW, store_contig->dset_addr, (size_t)mpi_buf_count, + io_info->u.rbuf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "can't finish collective parallel read") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_select_read() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_select_write * @@ -478,23 +477,25 @@ done: */ herr_t H5D__mpio_select_write(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *type_info, - hsize_t mpi_buf_count, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space) + hsize_t mpi_buf_count, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space) { - const H5D_contig_storage_t *store_contig = &(io_info->store->contig); /* Contiguous storage info for this I/O operation */ + const H5D_contig_storage_t *store_contig = + &(io_info->store->contig); /* Contiguous storage info for this I/O operation */ herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE /*OKAY: CAST DISCARDS CONST QUALIFIER*/ H5_CHECK_OVERFLOW(mpi_buf_count, hsize_t, size_t); - if(H5F_shared_block_write(io_info->f_sh, H5FD_MEM_DRAW, store_contig->dset_addr, (size_t)mpi_buf_count, io_info->u.wbuf) < 0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "can't finish collective parallel write") + if (H5F_shared_block_write(io_info->f_sh, H5FD_MEM_DRAW, store_contig->dset_addr, (size_t)mpi_buf_count, + io_info->u.wbuf) < 0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "can't finish collective parallel write") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_select_write() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_array_gatherv * @@ -524,17 +525,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, - size_t array_entry_size, void **_gathered_array, size_t *_gathered_array_num_entries, - hbool_t allgather, int root, MPI_Comm comm, int (*sort_func)(const void *, const void *)) +H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, size_t array_entry_size, + void **_gathered_array, size_t *_gathered_array_num_entries, hbool_t allgather, + int root, MPI_Comm comm, int (*sort_func)(const void *, const void *)) { - size_t gathered_array_num_entries = 0; /* The size of the newly-constructed array */ - void *gathered_array = NULL; /* The newly-constructed array returned to the caller */ - int *receive_counts_array = NULL; /* Array containing number of entries each processor is contributing */ - int *displacements_array = NULL; /* Array of displacements where each processor places its data in the final array */ - int mpi_code, mpi_rank, mpi_size; - int sendcount; - herr_t ret_value = SUCCEED; + size_t gathered_array_num_entries = 0; /* The size of the newly-constructed array */ + void * gathered_array = NULL; /* The newly-constructed array returned to the caller */ + int *receive_counts_array = NULL; /* Array containing number of entries each processor is contributing */ + int *displacements_array = + NULL; /* Array of displacements where each processor places its data in the final array */ + int mpi_code, mpi_rank, mpi_size; + int sendcount; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -547,38 +549,43 @@ H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, /* Determine the size of the end result array by collecting the number * of entries contributed by each processor into a single total. */ - if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&local_array_num_entries, &gathered_array_num_entries, 1, MPI_INT, MPI_SUM, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&local_array_num_entries, &gathered_array_num_entries, 1, + MPI_INT, MPI_SUM, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) - /* If 0 entries resulted from the collective operation, no processor is contributing anything and there is nothing to do */ + /* If 0 entries resulted from the collective operation, no processor is contributing anything and there is + * nothing to do */ if (gathered_array_num_entries > 0) { /* - * If gathering to all processors, all processors need to allocate space for the resulting array, as well as - * the receive counts and displacements arrays for the collective MPI_Allgatherv call. Otherwise, only the - * root processor needs to allocate the space for an MPI_Gatherv call. + * If gathering to all processors, all processors need to allocate space for the resulting array, as + * well as the receive counts and displacements arrays for the collective MPI_Allgatherv call. + * Otherwise, only the root processor needs to allocate the space for an MPI_Gatherv call. */ if (allgather || (mpi_rank == root)) { if (NULL == (gathered_array = H5MM_malloc(gathered_array_num_entries * array_entry_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate gathered array") - if (NULL == (receive_counts_array = (int *) H5MM_malloc((size_t) mpi_size * sizeof(int)))) + if (NULL == (receive_counts_array = (int *)H5MM_malloc((size_t)mpi_size * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate receive counts array") - if (NULL == (displacements_array = (int *) H5MM_malloc((size_t) mpi_size * sizeof(int)))) + if (NULL == (displacements_array = (int *)H5MM_malloc((size_t)mpi_size * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate receive displacements array") } /* end if */ /* * If gathering to all processors, inform each processor of how many entries each other processor is * contributing to the resulting array by collecting the counts into each processor's "receive counts" - * array. Otherwise, inform only the root processor of how many entries each other processor is contributing. + * array. Otherwise, inform only the root processor of how many entries each other processor is + * contributing. */ if (allgather) { - if (MPI_SUCCESS != (mpi_code = MPI_Allgather(&local_array_num_entries, 1, MPI_INT, receive_counts_array, 1, MPI_INT, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Allgather(&local_array_num_entries, 1, MPI_INT, + receive_counts_array, 1, MPI_INT, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allgather failed", mpi_code) } /* end if */ else { - if (MPI_SUCCESS != (mpi_code = MPI_Gather(&local_array_num_entries, 1, MPI_INT, receive_counts_array, 1, MPI_INT, root, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Gather(&local_array_num_entries, 1, MPI_INT, + receive_counts_array, 1, MPI_INT, root, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Gather failed", mpi_code) } /* end else */ @@ -586,26 +593,29 @@ H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, size_t i; /* Multiply each receive count by the size of the array entry, since the data is sent as bytes. */ - for (i = 0; i < (size_t) mpi_size; i++) - H5_CHECKED_ASSIGN(receive_counts_array[i], int, (size_t) receive_counts_array[i] * array_entry_size, size_t); + for (i = 0; i < (size_t)mpi_size; i++) + H5_CHECKED_ASSIGN(receive_counts_array[i], int, + (size_t)receive_counts_array[i] * array_entry_size, size_t); /* Set receive buffer offsets for the collective MPI_Allgatherv/MPI_Gatherv call. */ displacements_array[0] = 0; - for (i = 1; i < (size_t) mpi_size; i++) + for (i = 1; i < (size_t)mpi_size; i++) displacements_array[i] = displacements_array[i - 1] + receive_counts_array[i - 1]; } /* end if */ /* As the data is sent as bytes, calculate the true sendcount for the data. */ - H5_CHECKED_ASSIGN(sendcount, int, local_array_num_entries * array_entry_size, size_t); + H5_CHECKED_ASSIGN(sendcount, int, local_array_num_entries *array_entry_size, size_t); if (allgather) { - if (MPI_SUCCESS != (mpi_code = MPI_Allgatherv(local_array, sendcount, MPI_BYTE, - gathered_array, receive_counts_array, displacements_array, MPI_BYTE, comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Allgatherv(local_array, sendcount, MPI_BYTE, gathered_array, + receive_counts_array, displacements_array, MPI_BYTE, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allgatherv failed", mpi_code) } /* end if */ else { - if (MPI_SUCCESS != (mpi_code = MPI_Gatherv(local_array, sendcount, MPI_BYTE, - gathered_array, receive_counts_array, displacements_array, MPI_BYTE, root, comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Gatherv(local_array, sendcount, MPI_BYTE, gathered_array, + receive_counts_array, displacements_array, MPI_BYTE, root, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Gatherv failed", mpi_code) } /* end else */ @@ -613,7 +623,7 @@ H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, HDqsort(gathered_array, gathered_array_num_entries, array_entry_size, sort_func); } /* end if */ - *_gathered_array = gathered_array; + *_gathered_array = gathered_array; *_gathered_array_num_entries = gathered_array_num_entries; done: @@ -625,7 +635,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_array_gatherv() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_get_sum_chunk * @@ -640,30 +649,29 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, - int *sum_chunkf) +H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, int *sum_chunkf) { - int num_chunkf; /* Number of chunks to iterate over */ + int num_chunkf; /* Number of chunks to iterate over */ size_t ori_num_chunkf; - int mpi_code; /* MPI return code */ + int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Get the number of chunks to perform I/O on */ - num_chunkf = 0; + num_chunkf = 0; ori_num_chunkf = H5SL_count(fm->sel_chunks); H5_CHECKED_ASSIGN(num_chunkf, int, ori_num_chunkf, size_t); /* Determine the summation of number of chunks for all processes */ - if(MPI_SUCCESS != (mpi_code = MPI_Allreduce(&num_chunkf, sum_chunkf, 1, MPI_INT, MPI_SUM, io_info->comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Allreduce(&num_chunkf, sum_chunkf, 1, MPI_INT, MPI_SUM, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_get_sum_chunk() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_collective_read * @@ -679,11 +687,11 @@ done: */ herr_t H5D__contig_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *fm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t H5_ATTR_UNUSED *fm) { H5D_mpio_actual_io_mode_t actual_io_mode = H5D_MPIO_CONTIGUOUS_COLLECTIVE; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -691,7 +699,7 @@ H5D__contig_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_ HDassert(H5FD_MPIO == H5F_DRIVER_ID(io_info->dset->oloc.file)); /* Call generic internal collective I/O routine */ - if(H5D__inter_collective_io(io_info, type_info, file_space, mem_space) < 0) + if (H5D__inter_collective_io(io_info, type_info, file_space, mem_space) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't finish shared collective MPI-IO") /* Set the actual I/O mode property. internal_collective_io will not break to @@ -703,7 +711,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_collective_read() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_collective_write * @@ -719,11 +726,11 @@ done: */ herr_t H5D__contig_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *fm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t H5_ATTR_UNUSED *fm) { H5D_mpio_actual_io_mode_t actual_io_mode = H5D_MPIO_CONTIGUOUS_COLLECTIVE; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -731,7 +738,7 @@ H5D__contig_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type HDassert(H5FD_MPIO == H5F_DRIVER_ID(io_info->dset->oloc.file)); /* Call generic internal collective I/O routine */ - if(H5D__inter_collective_io(io_info, type_info, file_space, mem_space) < 0) + if (H5D__inter_collective_io(io_info, type_info, file_space, mem_space) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "couldn't finish shared collective MPI-IO") /* Set the actual I/O mode property. internal_collective_io will not break to @@ -743,7 +750,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_collective_write() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_collective_io * @@ -781,16 +787,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm) +H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm) { H5FD_mpio_chunk_opt_t chunk_opt_mode; - int io_option = H5D_MULTI_CHUNK_IO_MORE_OPT; - int sum_chunk = -1; + int io_option = H5D_MULTI_CHUNK_IO_MORE_OPT; + int sum_chunk = -1; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - htri_t temp_not_link_io = FALSE; + htri_t temp_not_link_io = FALSE; #endif - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -805,58 +810,61 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf H5CX_set_coll_metadata_read(FALSE); /* Check the optional property list for the collective chunk IO optimization option */ - if(H5CX_get_mpio_chunk_opt_mode(&chunk_opt_mode) < 0) + if (H5CX_get_mpio_chunk_opt_mode(&chunk_opt_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get chunk optimization option") - if(H5FD_MPIO_CHUNK_ONE_IO == chunk_opt_mode) - io_option = H5D_ONE_LINK_CHUNK_IO; /*no opt*/ + if (H5FD_MPIO_CHUNK_ONE_IO == chunk_opt_mode) + io_option = H5D_ONE_LINK_CHUNK_IO; /*no opt*/ /* direct request to multi-chunk-io */ - else if(H5FD_MPIO_CHUNK_MULTI_IO == chunk_opt_mode) + else if (H5FD_MPIO_CHUNK_MULTI_IO == chunk_opt_mode) io_option = H5D_MULTI_CHUNK_IO; /* via default path. branch by num threshold */ else { - unsigned one_link_chunk_io_threshold; /* Threshold to use single collective I/O for all chunks */ - int mpi_size; /* Number of processes in MPI job */ + unsigned one_link_chunk_io_threshold; /* Threshold to use single collective I/O for all chunks */ + int mpi_size; /* Number of processes in MPI job */ - if(H5D__mpio_get_sum_chunk(io_info, fm, &sum_chunk) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSWAP, FAIL, "unable to obtain the total chunk number of all processes"); - if((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) + if (H5D__mpio_get_sum_chunk(io_info, fm, &sum_chunk) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSWAP, FAIL, + "unable to obtain the total chunk number of all processes"); + if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") /* Get the chunk optimization option threshold */ - if(H5CX_get_mpio_chunk_opt_num(&one_link_chunk_io_threshold) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get chunk optimization option threshold value") + if (H5CX_get_mpio_chunk_opt_num(&one_link_chunk_io_threshold) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "couldn't get chunk optimization option threshold value") /* step 1: choose an IO option */ - /* If the average number of chunk per process is greater than a threshold, we will do one link chunked IO. */ - if((unsigned)sum_chunk / (unsigned)mpi_size >= one_link_chunk_io_threshold) + /* If the average number of chunk per process is greater than a threshold, we will do one link chunked + * IO. */ + if ((unsigned)sum_chunk / (unsigned)mpi_size >= one_link_chunk_io_threshold) io_option = H5D_ONE_LINK_CHUNK_IO_MORE_OPT; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY else temp_not_link_io = TRUE; #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - } /* end else */ + } /* end else */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY -{ - /*** Set collective chunk user-input optimization APIs. ***/ - if(H5D_ONE_LINK_CHUNK_IO == io_option) { - if(H5CX_test_set_mpio_coll_chunk_link_hard(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - } /* end if */ - else if(H5D_MULTI_CHUNK_IO == io_option) { - if(H5CX_test_set_mpio_coll_chunk_multi_hard(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - } /* end else-if */ - else if(H5D_ONE_LINK_CHUNK_IO_MORE_OPT == io_option) { - if(H5CX_test_set_mpio_coll_chunk_link_num_true(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - } /* end if */ - else if(temp_not_link_io) { - if(H5CX_test_set_mpio_coll_chunk_link_num_false(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - } /* end if */ -} + { + /*** Set collective chunk user-input optimization APIs. ***/ + if (H5D_ONE_LINK_CHUNK_IO == io_option) { + if (H5CX_test_set_mpio_coll_chunk_link_hard(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + } /* end if */ + else if (H5D_MULTI_CHUNK_IO == io_option) { + if (H5CX_test_set_mpio_coll_chunk_multi_hard(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + } /* end else-if */ + else if (H5D_ONE_LINK_CHUNK_IO_MORE_OPT == io_option) { + if (H5CX_test_set_mpio_coll_chunk_link_num_true(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + } /* end if */ + else if (temp_not_link_io) { + if (H5CX_test_set_mpio_coll_chunk_link_num_false(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + } /* end if */ + } #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /* step 2: Go ahead to do IO.*/ @@ -864,37 +872,38 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf case H5D_ONE_LINK_CHUNK_IO: case H5D_ONE_LINK_CHUNK_IO_MORE_OPT: /* Check if there are any filters in the pipeline */ - if(io_info->dset->shared->dcpl_cache.pline.nused > 0) { + if (io_info->dset->shared->dcpl_cache.pline.nused > 0) { /* For now, Multi-chunk IO must be forced for parallel filtered read, * so that data can be unfiltered as it is received. There is significant * complexity in unfiltering the data when it is read all at once into a * single buffer. */ - if(io_info->op_type == H5D_IO_OP_READ) { - if(H5D__multi_chunk_filtered_collective_io(io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple filtered chunk MPI-IO") + if (io_info->op_type == H5D_IO_OP_READ) { + if (H5D__multi_chunk_filtered_collective_io(io_info, type_info, fm) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, + "couldn't finish optimized multiple filtered chunk MPI-IO") } /* end if */ - else - if(H5D__link_chunk_filtered_collective_io(io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish filtered linked chunk MPI-IO") + else if (H5D__link_chunk_filtered_collective_io(io_info, type_info, fm) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish filtered linked chunk MPI-IO") } /* end if */ else /* Perform unfiltered link chunk collective IO */ - if(H5D__link_chunk_collective_io(io_info, type_info, fm, sum_chunk) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish linked chunk MPI-IO") + if (H5D__link_chunk_collective_io(io_info, type_info, fm, sum_chunk) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish linked chunk MPI-IO") break; case H5D_MULTI_CHUNK_IO: /* direct request to do multi-chunk IO */ default: /* multiple chunk IO via threshold */ /* Check if there are any filters in the pipeline */ - if(io_info->dset->shared->dcpl_cache.pline.nused > 0) { - if(H5D__multi_chunk_filtered_collective_io(io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple filtered chunk MPI-IO") + if (io_info->dset->shared->dcpl_cache.pline.nused > 0) { + if (H5D__multi_chunk_filtered_collective_io(io_info, type_info, fm) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, + "couldn't finish optimized multiple filtered chunk MPI-IO") } /* end if */ else /* Perform unfiltered multi chunk collective IO */ - if(H5D__multi_chunk_collective_io(io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple chunk MPI-IO") + if (H5D__multi_chunk_collective_io(io_info, type_info, fm) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple chunk MPI-IO") break; } /* end switch */ @@ -902,7 +911,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_io */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_collective_read * @@ -918,22 +926,21 @@ done: */ herr_t H5D__chunk_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t *fm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t *fm) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Call generic selection operation */ - if(H5D__chunk_collective_io(io_info, type_info, fm) < 0) + if (H5D__chunk_collective_io(io_info, type_info, fm) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_read() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_collective_write * @@ -949,22 +956,21 @@ done: */ herr_t H5D__chunk_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t *fm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t *fm) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Call generic selection operation */ - if(H5D__chunk_collective_io(io_info, type_info, fm) < 0) + if (H5D__chunk_collective_io(io_info, type_info, fm) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_write() */ - /*------------------------------------------------------------------------- * Function: H5D__link_chunk_collective_io * @@ -983,26 +989,28 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm, int sum_chunk) +H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm, + int sum_chunk) { H5D_chunk_addr_info_t *chunk_addr_info_array = NULL; - MPI_Datatype chunk_final_mtype; /* Final memory MPI datatype for all chunks with seletion */ - hbool_t chunk_final_mtype_is_derived = FALSE; - MPI_Datatype chunk_final_ftype; /* Final file MPI datatype for all chunks with seletion */ - hbool_t chunk_final_ftype_is_derived = FALSE; - H5D_storage_t ctg_store; /* Storage info for "fake" contiguous dataset */ - size_t total_chunks; - MPI_Datatype *chunk_mtype = NULL; - MPI_Datatype *chunk_ftype = NULL; - MPI_Aint *chunk_disp_array = NULL; - MPI_Aint *chunk_mem_disp_array = NULL; - hbool_t *chunk_mft_is_derived_array = NULL; /* Flags to indicate each chunk's MPI file datatype is derived */ - hbool_t *chunk_mbt_is_derived_array = NULL; /* Flags to indicate each chunk's MPI memory datatype is derived */ - int *chunk_mpi_file_counts = NULL; /* Count of MPI file datatype for each chunk */ - int *chunk_mpi_mem_counts = NULL; /* Count of MPI memory datatype for each chunk */ - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; + MPI_Datatype chunk_final_mtype; /* Final memory MPI datatype for all chunks with seletion */ + hbool_t chunk_final_mtype_is_derived = FALSE; + MPI_Datatype chunk_final_ftype; /* Final file MPI datatype for all chunks with seletion */ + hbool_t chunk_final_ftype_is_derived = FALSE; + H5D_storage_t ctg_store; /* Storage info for "fake" contiguous dataset */ + size_t total_chunks; + MPI_Datatype * chunk_mtype = NULL; + MPI_Datatype * chunk_ftype = NULL; + MPI_Aint * chunk_disp_array = NULL; + MPI_Aint * chunk_mem_disp_array = NULL; + hbool_t * chunk_mft_is_derived_array = + NULL; /* Flags to indicate each chunk's MPI file datatype is derived */ + hbool_t *chunk_mbt_is_derived_array = + NULL; /* Flags to indicate each chunk's MPI memory datatype is derived */ + int * chunk_mpi_file_counts = NULL; /* Count of MPI file datatype for each chunk */ + int * chunk_mpi_mem_counts = NULL; /* Count of MPI memory datatype for each chunk */ + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1014,9 +1022,10 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ H5CX_set_mpio_actual_io_mode(H5D_MPIO_CHUNK_COLLECTIVE); /* Get the sum # of chunks, if not already available */ - if(sum_chunk < 0) { - if(H5D__mpio_get_sum_chunk(io_info, fm, &sum_chunk) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSWAP, FAIL, "unable to obtain the total chunk number of all processes"); + if (sum_chunk < 0) { + if (H5D__mpio_get_sum_chunk(io_info, fm, &sum_chunk) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSWAP, FAIL, + "unable to obtain the total chunk number of all processes"); } /* end if */ /* Retrieve total # of chunks in dataset */ @@ -1026,15 +1035,15 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ * the dataset. [This sometimes is used by developers who want the * equivalent of compressed contiguous datasets - QAK] */ - if(total_chunks == 1) { - H5SL_node_t *chunk_node; /* Pointer to chunk node for selection */ - H5S_t *fspace; /* Dataspace describing chunk & selection in it */ - H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ + if (total_chunks == 1) { + H5SL_node_t *chunk_node; /* Pointer to chunk node for selection */ + H5S_t * fspace; /* Dataspace describing chunk & selection in it */ + H5S_t * mspace; /* Dataspace describing selection in memory corresponding to this chunk */ /* Check for this process having selection in this chunk */ chunk_node = H5SL_first(fm->sel_chunks); - if(chunk_node == NULL) { + if (chunk_node == NULL) { /* Set the dataspace info for I/O to NULL, this process doesn't have any I/O to perform */ fspace = mspace = NULL; @@ -1042,11 +1051,11 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ ctg_store.contig.dset_addr = 0; } /* end if */ else { - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - H5D_chunk_info_t *chunk_info; /* Info for chunk in skiplist */ + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + H5D_chunk_info_t *chunk_info; /* Info for chunk in skiplist */ /* Get the chunk info, for the selection in the chunk */ - if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skip list") /* Set the dataspace info for I/O */ @@ -1054,7 +1063,7 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ mspace = chunk_info->mspace; /* Look up address of chunk */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk address") ctg_store.contig.dset_addr = udata.chunk_block.offset; } /* end else */ @@ -1063,66 +1072,72 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ io_info->store = &ctg_store; #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before inter_collective_io for total chunk = 1 \n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before inter_collective_io for total chunk = 1 \n"); #endif /* Perform I/O */ - if(H5D__inter_collective_io(io_info, type_info, fspace, mspace) < 0) + if (H5D__inter_collective_io(io_info, type_info, fspace, mspace) < 0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't finish shared collective MPI-IO") } /* end if */ else { - hsize_t mpi_buf_count; /* Number of MPI types */ - size_t num_chunk; /* Number of chunks for this process */ - size_t u; /* Local index variable */ + hsize_t mpi_buf_count; /* Number of MPI types */ + size_t num_chunk; /* Number of chunks for this process */ + size_t u; /* Local index variable */ /* Get the number of chunks with a selection */ num_chunk = H5SL_count(fm->sel_chunks); H5_CHECK_OVERFLOW(num_chunk, size_t, int); #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"total_chunks = %Zu, num_chunk = %Zu\n", total_chunks, num_chunk); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "total_chunks = %Zu, num_chunk = %Zu\n", total_chunks, num_chunk); #endif /* Set up MPI datatype for chunks selected */ - if(num_chunk) { + if (num_chunk) { /* Allocate chunking information */ - if(NULL == (chunk_addr_info_array = (H5D_chunk_addr_info_t *)H5MM_malloc(num_chunk * sizeof(H5D_chunk_addr_info_t)))) + if (NULL == (chunk_addr_info_array = + (H5D_chunk_addr_info_t *)H5MM_malloc(num_chunk * sizeof(H5D_chunk_addr_info_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk array buffer") - if(NULL == (chunk_mtype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk memory datatype buffer") - if(NULL == (chunk_ftype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) + if (NULL == (chunk_mtype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk memory datatype buffer") + if (NULL == (chunk_ftype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file datatype buffer") - if(NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc(num_chunk * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file displacement buffer") - if(NULL == (chunk_mem_disp_array = (MPI_Aint *)H5MM_calloc(num_chunk * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk memory displacement buffer") - if(NULL == (chunk_mpi_mem_counts = (int *)H5MM_calloc(num_chunk * sizeof(int)))) + if (NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc(num_chunk * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk file displacement buffer") + if (NULL == (chunk_mem_disp_array = (MPI_Aint *)H5MM_calloc(num_chunk * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk memory displacement buffer") + if (NULL == (chunk_mpi_mem_counts = (int *)H5MM_calloc(num_chunk * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk memory counts buffer") - if(NULL == (chunk_mpi_file_counts = (int *)H5MM_calloc(num_chunk * sizeof(int)))) + if (NULL == (chunk_mpi_file_counts = (int *)H5MM_calloc(num_chunk * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file counts buffer") - if(NULL == (chunk_mbt_is_derived_array = (hbool_t *)H5MM_calloc(num_chunk * sizeof(hbool_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk memory is derived datatype flags buffer") - if(NULL == (chunk_mft_is_derived_array = (hbool_t *)H5MM_calloc(num_chunk * sizeof(hbool_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file is derived datatype flags buffer") + if (NULL == (chunk_mbt_is_derived_array = (hbool_t *)H5MM_calloc(num_chunk * sizeof(hbool_t)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk memory is derived datatype flags buffer") + if (NULL == (chunk_mft_is_derived_array = (hbool_t *)H5MM_calloc(num_chunk * sizeof(hbool_t)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk file is derived datatype flags buffer") #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before sorting the chunk address \n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before sorting the chunk address \n"); #endif /* Sort the chunk address */ - if(H5D__sort_chunk(io_info, fm, chunk_addr_info_array, sum_chunk) < 0) + if (H5D__sort_chunk(io_info, fm, chunk_addr_info_array, sum_chunk) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSWAP, FAIL, "unable to sort chunk address") ctg_store.contig.dset_addr = chunk_addr_info_array[0].chunk_addr; #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"after sorting the chunk address \n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "after sorting the chunk address \n"); #endif /* Obtain MPI derived datatype from all individual chunks */ - for(u = 0; u < num_chunk; u++) { + for (u = 0; u < num_chunk; u++) { hsize_t *permute_map = NULL; /* array that holds the mapping from the old, out-of-order displacements to the in-order displacements of the MPI datatypes of the @@ -1134,46 +1149,43 @@ if(H5DEBUG(D)) * and will be fed into the next call to H5S_mpio_space_type * where it will be freed. */ - if(H5S_mpio_space_type(chunk_addr_info_array[u].chunk_info.fspace, - type_info->src_type_size, - &chunk_ftype[u], /* OUT: datatype created */ - &chunk_mpi_file_counts[u], /* OUT */ - &(chunk_mft_is_derived_array[u]), /* OUT */ - TRUE, /* this is a file space, - so permute the - datatype if the point - selections are out of - order */ - &permute_map,/* OUT: a map to indicate the - permutation of points - selected in case they - are out of order */ - &is_permuted /* OUT */) < 0) + if (H5S_mpio_space_type(chunk_addr_info_array[u].chunk_info.fspace, type_info->src_type_size, + &chunk_ftype[u], /* OUT: datatype created */ + &chunk_mpi_file_counts[u], /* OUT */ + &(chunk_mft_is_derived_array[u]), /* OUT */ + TRUE, /* this is a file space, + so permute the + datatype if the point + selections are out of + order */ + &permute_map, /* OUT: a map to indicate the + permutation of points + selected in case they + are out of order */ + &is_permuted /* OUT */) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create MPI file type") /* Sanity check */ - if(is_permuted) + if (is_permuted) HDassert(permute_map); - if(H5S_mpio_space_type(chunk_addr_info_array[u].chunk_info.mspace, - type_info->dst_type_size, &chunk_mtype[u], - &chunk_mpi_mem_counts[u], - &(chunk_mbt_is_derived_array[u]), - FALSE, /* this is a memory - space, so if the file - space is not - permuted, there is no - need to permute the - datatype if the point - selections are out of - order*/ - &permute_map, /* IN: the permutation map - generated by the - file_space selection - and applied to the - memory selection */ - &is_permuted /* IN */) < 0) + if (H5S_mpio_space_type(chunk_addr_info_array[u].chunk_info.mspace, type_info->dst_type_size, + &chunk_mtype[u], &chunk_mpi_mem_counts[u], + &(chunk_mbt_is_derived_array[u]), FALSE, /* this is a memory + space, so if the file + space is not + permuted, there is no + need to permute the + datatype if the point + selections are out of + order*/ + &permute_map, /* IN: the permutation map + generated by the + file_space selection + and applied to the + memory selection */ + &is_permuted /* IN */) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create MPI buf type") /* Sanity check */ - if(is_permuted) + if (is_permuted) HDassert(!permute_map); /* Chunk address relative to the first chunk */ @@ -1185,34 +1197,38 @@ if(H5DEBUG(D)) } /* end for */ /* Create final MPI derived datatype for the file */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)num_chunk, chunk_mpi_file_counts, chunk_disp_array, chunk_ftype, &chunk_final_ftype))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct((int)num_chunk, chunk_mpi_file_counts, chunk_disp_array, + chunk_ftype, &chunk_final_ftype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&chunk_final_ftype))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&chunk_final_ftype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) chunk_final_ftype_is_derived = TRUE; /* Create final MPI derived datatype for memory */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)num_chunk, chunk_mpi_mem_counts, chunk_mem_disp_array, chunk_mtype, &chunk_final_mtype))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct((int)num_chunk, chunk_mpi_mem_counts, chunk_mem_disp_array, + chunk_mtype, &chunk_final_mtype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&chunk_final_mtype))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&chunk_final_mtype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) chunk_final_mtype_is_derived = TRUE; /* Free the file & memory MPI datatypes for each chunk */ - for(u = 0; u < num_chunk; u++) { - if(chunk_mbt_is_derived_array[u]) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(chunk_mtype + u))) + for (u = 0; u < num_chunk; u++) { + if (chunk_mbt_is_derived_array[u]) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(chunk_mtype + u))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(chunk_mft_is_derived_array[u]) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(chunk_ftype + u))) + if (chunk_mft_is_derived_array[u]) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(chunk_ftype + u))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) } /* end for */ /* We have a single, complicated MPI datatype for both memory & file */ - mpi_buf_count = (hsize_t)1; - } /* end if */ - else { /* no selection at all for this process */ + mpi_buf_count = (hsize_t)1; + } /* end if */ + else { /* no selection at all for this process */ ctg_store.contig.dset_addr = 0; /* Set the MPI datatype */ @@ -1220,56 +1236,57 @@ if(H5DEBUG(D)) chunk_final_mtype = MPI_BYTE; /* No chunks selected for this process */ - mpi_buf_count = (hsize_t)0; + mpi_buf_count = (hsize_t)0; } /* end else */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before coming to final collective IO\n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before coming to final collective IO\n"); #endif /* Set up the base storage address for this chunk */ io_info->store = &ctg_store; /* Perform final collective I/O operation */ - if(H5D__final_collective_io(io_info, type_info, mpi_buf_count, chunk_final_ftype, chunk_final_mtype) < 0) + if (H5D__final_collective_io(io_info, type_info, mpi_buf_count, chunk_final_ftype, + chunk_final_mtype) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish MPI-IO") } /* end else */ done: #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before freeing memory inside H5D_link_collective_io ret_value = %d\n", ret_value); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before freeing memory inside H5D_link_collective_io ret_value = %d\n", + ret_value); #endif /* Release resources */ - if(chunk_addr_info_array) + if (chunk_addr_info_array) H5MM_xfree(chunk_addr_info_array); - if(chunk_mtype) + if (chunk_mtype) H5MM_xfree(chunk_mtype); - if(chunk_ftype) + if (chunk_ftype) H5MM_xfree(chunk_ftype); - if(chunk_disp_array) + if (chunk_disp_array) H5MM_xfree(chunk_disp_array); - if(chunk_mem_disp_array) + if (chunk_mem_disp_array) H5MM_xfree(chunk_mem_disp_array); - if(chunk_mpi_mem_counts) + if (chunk_mpi_mem_counts) H5MM_xfree(chunk_mpi_mem_counts); - if(chunk_mpi_file_counts) + if (chunk_mpi_file_counts) H5MM_xfree(chunk_mpi_file_counts); - if(chunk_mbt_is_derived_array) + if (chunk_mbt_is_derived_array) H5MM_xfree(chunk_mbt_is_derived_array); - if(chunk_mft_is_derived_array) + if (chunk_mft_is_derived_array) H5MM_xfree(chunk_mft_is_derived_array); /* Free the MPI buf and file types, if they were derived */ - if(chunk_final_mtype_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_final_mtype))) + if (chunk_final_mtype_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_final_mtype))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(chunk_final_ftype_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_final_ftype))) + if (chunk_final_ftype_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_final_ftype))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__link_chunk_collective_io */ - /*------------------------------------------------------------------------- * Function: H5D__link_chunk_filtered_collective_io * @@ -1319,21 +1336,22 @@ if(H5DEBUG(D)) */ static herr_t H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm) + H5D_chunk_map_t *fm) { H5D_filtered_collective_io_info_t *chunk_list = NULL; /* The list of chunks being read/written */ - H5D_filtered_collective_io_info_t *collective_chunk_list = NULL; /* The list of chunks used during collective operations */ - H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ - MPI_Datatype mem_type = MPI_BYTE; - MPI_Datatype file_type = MPI_BYTE; - hbool_t mem_type_is_derived = FALSE; - hbool_t file_type_is_derived = FALSE; - size_t chunk_list_num_entries; - size_t collective_chunk_list_num_entries; - size_t *num_chunks_selected_array = NULL; /* Array of number of chunks selected on each process */ - size_t i; /* Local index variable */ - int mpi_rank, mpi_size, mpi_code; - herr_t ret_value = SUCCEED; + H5D_filtered_collective_io_info_t *collective_chunk_list = + NULL; /* The list of chunks used during collective operations */ + H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ + MPI_Datatype mem_type = MPI_BYTE; + MPI_Datatype file_type = MPI_BYTE; + hbool_t mem_type_is_derived = FALSE; + hbool_t file_type_is_derived = FALSE; + size_t chunk_list_num_entries; + size_t collective_chunk_list_num_entries; + size_t * num_chunks_selected_array = NULL; /* Array of number of chunks selected on each process */ + size_t i; /* Local index variable */ + int mpi_rank, mpi_size, mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1356,7 +1374,8 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in H5CX_set_mpio_actual_io_mode(H5D_MPIO_CHUNK_COLLECTIVE); /* Build a list of selected chunks in the collective io operation */ - if (H5D__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < 0) + if (H5D__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't construct filtered I/O info list") if (io_info->op_type == H5D_IO_OP_WRITE) { /* Filtered collective write */ @@ -1365,15 +1384,15 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in hsize_t mpi_buf_count; /* Construct chunked index info */ - index_info.f = io_info->dset->oloc.file; - index_info.pline = &(io_info->dset->shared->dcpl_cache.pline); - index_info.layout = &(io_info->dset->shared->layout.u.chunk); + index_info.f = io_info->dset->oloc.file; + index_info.pline = &(io_info->dset->shared->dcpl_cache.pline); + index_info.layout = &(io_info->dset->shared->layout.u.chunk); index_info.storage = &(io_info->dset->shared->layout.storage.u.chunk); /* Set up chunk information for insertion to chunk index */ - udata.common.layout = index_info.layout; + udata.common.layout = index_info.layout; udata.common.storage = index_info.storage; - udata.filter_mask = 0; + udata.filter_mask = 0; /* Iterate through all the chunks in the collective write operation, * updating each chunk with the data modifications from other processes, @@ -1387,8 +1406,10 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in /* Gather the new chunk sizes to all processes for a collective reallocation * of the chunks in the file. */ - if (H5D__mpio_array_gatherv(chunk_list, chunk_list_num_entries, sizeof(H5D_filtered_collective_io_info_t), - (void **) &collective_chunk_list, &collective_chunk_list_num_entries, true, 0, io_info->comm, NULL) < 0) + if (H5D__mpio_array_gatherv(chunk_list, chunk_list_num_entries, + sizeof(H5D_filtered_collective_io_info_t), + (void **)&collective_chunk_list, &collective_chunk_list_num_entries, true, + 0, io_info->comm, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, "couldn't gather new chunk sizes") /* Collectively re-allocate the modified chunks (from each process) in the file */ @@ -1396,15 +1417,17 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in hbool_t insert; if (H5D__chunk_file_alloc(&index_info, &collective_chunk_list[i].chunk_states.chunk_current, - &collective_chunk_list[i].chunk_states.new_chunk, &insert, collective_chunk_list[i].scaled) < 0) + &collective_chunk_list[i].chunk_states.new_chunk, &insert, + collective_chunk_list[i].scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") } /* end for */ - if (NULL == (num_chunks_selected_array = (size_t *) H5MM_malloc((size_t) mpi_size * sizeof(size_t)))) + if (NULL == (num_chunks_selected_array = (size_t *)H5MM_malloc((size_t)mpi_size * sizeof(size_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate num chunks selected array") - if (MPI_SUCCESS != (mpi_code = MPI_Allgather(&chunk_list_num_entries, 1, MPI_UNSIGNED_LONG_LONG, num_chunks_selected_array, - 1, MPI_UNSIGNED_LONG_LONG, io_info->comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Allgather(&chunk_list_num_entries, 1, MPI_UNSIGNED_LONG_LONG, + num_chunks_selected_array, 1, MPI_UNSIGNED_LONG_LONG, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allgather failed", mpi_code) /* If this process has any chunks selected, create a MPI type for collectively @@ -1424,14 +1447,16 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in * of the local array. This works correctly because the array gather function guarantees * that the chunk data in the collective array is ordered in blocks by rank. */ - for (i = 0, offset = 0; i < (size_t) mpi_rank; i++) + for (i = 0, offset = 0; i < (size_t)mpi_rank; i++) offset += num_chunks_selected_array[i]; - H5MM_memcpy(chunk_list, &collective_chunk_list[offset], num_chunks_selected_array[mpi_rank] * sizeof(H5D_filtered_collective_io_info_t)); + H5MM_memcpy(chunk_list, &collective_chunk_list[offset], + num_chunks_selected_array[mpi_rank] * sizeof(H5D_filtered_collective_io_info_t)); /* Create single MPI type encompassing each selection in the dataspace */ - if (H5D__mpio_filtered_collective_write_type(chunk_list, chunk_list_num_entries, - &mem_type, &mem_type_is_derived, &file_type, &file_type_is_derived) < 0) + if (H5D__mpio_filtered_collective_write_type(chunk_list, chunk_list_num_entries, &mem_type, + &mem_type_is_derived, &file_type, + &file_type_is_derived) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "couldn't create MPI link chunk I/O type") /* Override the write buffer to point to the address of the first @@ -1441,11 +1466,11 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in } /* end if */ /* We have a single, complicated MPI datatype for both memory & file */ - mpi_buf_count = (mem_type_is_derived && file_type_is_derived) ? (hsize_t) 1 : (hsize_t) 0; + mpi_buf_count = (mem_type_is_derived && file_type_is_derived) ? (hsize_t)1 : (hsize_t)0; /* Set up the base storage address for this operation */ ctg_store.contig.dset_addr = 0; /* Write address must be set to address 0 */ - io_info->store = &ctg_store; + io_info->store = &ctg_store; /* Perform I/O */ if (H5D__final_collective_io(io_info, type_info, mpi_buf_count, file_type, mem_type) < 0) @@ -1455,14 +1480,14 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in * in this iteration into the chunk index */ for (i = 0; i < collective_chunk_list_num_entries; i++) { - udata.chunk_block = collective_chunk_list[i].chunk_states.new_chunk; + udata.chunk_block = collective_chunk_list[i].chunk_states.new_chunk; udata.common.scaled = collective_chunk_list[i].scaled; - udata.chunk_idx = collective_chunk_list[i].index; + udata.chunk_idx = collective_chunk_list[i].index; if ((index_info.storage->ops->insert)(&index_info, &udata, io_info->dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk address into index") } /* end for */ - } /* end if */ + } /* end if */ done: /* Free resources used by a process which had some selection */ @@ -1488,7 +1513,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__link_chunk_filtered_collective_io() */ - /*------------------------------------------------------------------------- * Function: H5D__multi_chunk_collective_io * @@ -1507,25 +1531,27 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm) +H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm) { - H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ - H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ - H5D_io_info_t cpt_io_info; /* Compact I/O info object */ - H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ - hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ - uint8_t *chunk_io_option = NULL; - haddr_t *chunk_addr = NULL; - H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - H5FD_mpio_collective_opt_t last_coll_opt_mode = H5FD_MPIO_COLLECTIVE_IO; /* Last parallel transfer with independent IO or collective IO with this mode */ - size_t total_chunk; /* Total # of chunks in dataset */ + H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ + H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ + H5D_io_info_t cpt_io_info; /* Compact I/O info object */ + H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ + hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ + uint8_t * chunk_io_option = NULL; + haddr_t * chunk_addr = NULL; + H5D_storage_t store; /* union of EFL and chunk pointer in file space */ + H5FD_mpio_collective_opt_t last_coll_opt_mode = + H5FD_MPIO_COLLECTIVE_IO; /* Last parallel transfer with independent IO or collective IO with this mode + */ + size_t total_chunk; /* Total # of chunks in dataset */ #ifdef H5Dmpio_DEBUG int mpi_rank; #endif - size_t u; /* Local index variable */ - H5D_mpio_actual_io_mode_t actual_io_mode = H5D_MPIO_NO_COLLECTIVE; /* Local variable for tracking the I/O mode used. */ - herr_t ret_value = SUCCEED; + size_t u; /* Local index variable */ + H5D_mpio_actual_io_mode_t actual_io_mode = + H5D_MPIO_NO_COLLECTIVE; /* Local variable for tracking the I/O mode used. */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1544,17 +1570,17 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty chunk_io_option = (uint8_t *)H5MM_calloc(total_chunk); chunk_addr = (haddr_t *)H5MM_calloc(total_chunk * sizeof(haddr_t)); #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "total_chunk %Zu\n", total_chunk); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "total_chunk %Zu\n", total_chunk); #endif /* Obtain IO option for each chunk */ - if(H5D__obtain_mpio_mode(io_info, fm, chunk_io_option, chunk_addr) < 0) + if (H5D__obtain_mpio_mode(io_info, fm, chunk_io_option, chunk_addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRECV, FAIL, "unable to obtain MPIO mode") /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); - ctg_io_info.store = &ctg_store; + ctg_io_info.store = &ctg_store; ctg_io_info.layout_ops = *H5D_LOPS_CONTIG; /* Initialize temporary contiguous storage info */ @@ -1562,7 +1588,7 @@ if(H5DEBUG(D)) /* Set up compact I/O info object */ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info)); - cpt_io_info.store = &cpt_store; + cpt_io_info.store = &cpt_store; cpt_io_info.layout_ops = *H5D_LOPS_COMPACT; /* Initialize temporary compact storage info */ @@ -1572,38 +1598,39 @@ if(H5DEBUG(D)) io_info->store = &store; /* Loop over _all_ the chunks */ - for(u = 0; u < total_chunk; u++) { - H5D_chunk_info_t *chunk_info; /* Chunk info for current chunk */ - H5S_t *fspace; /* Dataspace describing chunk & selection in it */ - H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ + for (u = 0; u < total_chunk; u++) { + H5D_chunk_info_t *chunk_info; /* Chunk info for current chunk */ + H5S_t * fspace; /* Dataspace describing chunk & selection in it */ + H5S_t * mspace; /* Dataspace describing selection in memory corresponding to this chunk */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"mpi_rank = %d, chunk index = %Zu\n", mpi_rank, u); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "mpi_rank = %d, chunk index = %Zu\n", mpi_rank, u); #endif /* Get the chunk info for this chunk, if there are elements selected */ chunk_info = fm->select_chunk[u]; /* Set the storage information for chunks with selections */ - if(chunk_info) { + if (chunk_info) { HDassert(chunk_info->index == u); /* Pass in chunk's coordinates in a union. */ - store.chunk.scaled = chunk_info->scaled; + store.chunk.scaled = chunk_info->scaled; } /* end if */ /* Collective IO for this chunk, * Note: even there is no selection for this process, the process still * needs to contribute MPI NONE TYPE. */ - if(chunk_io_option[u] == H5D_CHUNK_IO_MODE_COL) { + if (chunk_io_option[u] == H5D_CHUNK_IO_MODE_COL) { #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"inside collective chunk IO mpi_rank = %d, chunk index = %Zu\n", mpi_rank, u); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "inside collective chunk IO mpi_rank = %d, chunk index = %Zu\n", + mpi_rank, u); #endif /* Set the file & memory dataspaces */ - if(chunk_info) { + if (chunk_info) { fspace = chunk_info->fspace; mspace = chunk_info->mspace; @@ -1613,7 +1640,7 @@ if(H5DEBUG(D)) * to ease switching between to mixed I/O without checking the current * value of the property. You can see the definition in H5Ppublic.h */ - actual_io_mode = (H5D_mpio_actual_io_mode_t) (actual_io_mode | H5D_MPIO_CHUNK_COLLECTIVE); + actual_io_mode = (H5D_mpio_actual_io_mode_t)(actual_io_mode | H5D_MPIO_CHUNK_COLLECTIVE); } /* end if */ else { @@ -1621,8 +1648,8 @@ if(H5DEBUG(D)) } /* end else */ /* Switch back to collective I/O */ - if(last_coll_opt_mode != H5FD_MPIO_COLLECTIVE_IO) { - if(H5CX_set_mpio_coll_opt(H5FD_MPIO_COLLECTIVE_IO) < 0) + if (last_coll_opt_mode != H5FD_MPIO_COLLECTIVE_IO) { + if (H5CX_set_mpio_coll_opt(H5FD_MPIO_COLLECTIVE_IO) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't switch to collective I/O") last_coll_opt_mode = H5FD_MPIO_COLLECTIVE_IO; } /* end if */ @@ -1631,32 +1658,33 @@ if(H5DEBUG(D)) ctg_store.contig.dset_addr = chunk_addr[u]; /* Perform the I/O */ - if(H5D__inter_collective_io(&ctg_io_info, type_info, fspace, mspace) < 0) + if (H5D__inter_collective_io(&ctg_io_info, type_info, fspace, mspace) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish shared collective MPI-IO") - } /* end if */ - else { /* possible independent IO for this chunk */ + } /* end if */ + else { /* possible independent IO for this chunk */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"inside independent IO mpi_rank = %d, chunk index = %Zu\n", mpi_rank, u); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "inside independent IO mpi_rank = %d, chunk index = %Zu\n", mpi_rank, + u); #endif HDassert(chunk_io_option[u] == 0); /* Set the file & memory dataspaces */ - if(chunk_info) { + if (chunk_info) { fspace = chunk_info->fspace; mspace = chunk_info->mspace; /* Update the local variable tracking the actual io mode. */ - actual_io_mode = (H5D_mpio_actual_io_mode_t) (actual_io_mode | H5D_MPIO_CHUNK_INDEPENDENT); + actual_io_mode = (H5D_mpio_actual_io_mode_t)(actual_io_mode | H5D_MPIO_CHUNK_INDEPENDENT); } /* end if */ else { fspace = mspace = NULL; } /* end else */ /* Using independent I/O with file setview.*/ - if(last_coll_opt_mode != H5FD_MPIO_INDIVIDUAL_IO) { - if(H5CX_set_mpio_coll_opt(H5FD_MPIO_INDIVIDUAL_IO) < 0) + if (last_coll_opt_mode != H5FD_MPIO_INDIVIDUAL_IO) { + if (H5CX_set_mpio_coll_opt(H5FD_MPIO_INDIVIDUAL_IO) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't switch to individual I/O") last_coll_opt_mode = H5FD_MPIO_INDIVIDUAL_IO; } /* end if */ @@ -1665,28 +1693,27 @@ if(H5DEBUG(D)) ctg_store.contig.dset_addr = chunk_addr[u]; /* Perform the I/O */ - if(H5D__inter_collective_io(&ctg_io_info, type_info, fspace, mspace) < 0) + if (H5D__inter_collective_io(&ctg_io_info, type_info, fspace, mspace) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish shared collective MPI-IO") #ifdef H5D_DEBUG - if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"after inter collective IO\n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "after inter collective IO\n"); #endif } /* end else */ - } /* end for */ + } /* end for */ /* Write the local value of actual io mode to the API context. */ H5CX_set_mpio_actual_io_mode(actual_io_mode); done: - if(chunk_io_option) + if (chunk_io_option) H5MM_xfree(chunk_io_option); - if(chunk_addr) + if (chunk_addr) H5MM_xfree(chunk_addr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__multi_chunk_collective_io */ - /*------------------------------------------------------------------------- * Function: H5D__multi_chunk_filtered_collective_io * @@ -1745,23 +1772,25 @@ done: */ static herr_t H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm) + H5D_chunk_map_t *fm) { H5D_filtered_collective_io_info_t *chunk_list = NULL; /* The list of chunks being read/written */ - H5D_filtered_collective_io_info_t *collective_chunk_list = NULL; /* The list of chunks used during collective operations */ - H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ - H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ - MPI_Datatype *file_type_array = NULL; - MPI_Datatype *mem_type_array = NULL; - hbool_t *file_type_is_derived_array = NULL; - hbool_t *mem_type_is_derived_array = NULL; - hbool_t *has_chunk_selected_array = NULL; /* Array of whether or not each process is contributing a chunk to each iteration */ - size_t chunk_list_num_entries; - size_t collective_chunk_list_num_entries; - size_t i, j; /* Local index variable */ - int mpi_rank, mpi_size, mpi_code; - herr_t ret_value = SUCCEED; + H5D_filtered_collective_io_info_t *collective_chunk_list = + NULL; /* The list of chunks used during collective operations */ + H5D_storage_t store; /* union of EFL and chunk pointer in file space */ + H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ + H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ + MPI_Datatype *file_type_array = NULL; + MPI_Datatype *mem_type_array = NULL; + hbool_t * file_type_is_derived_array = NULL; + hbool_t * mem_type_is_derived_array = NULL; + hbool_t * has_chunk_selected_array = + NULL; /* Array of whether or not each process is contributing a chunk to each iteration */ + size_t chunk_list_num_entries; + size_t collective_chunk_list_num_entries; + size_t i, j; /* Local index variable */ + int mpi_rank, mpi_size, mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1784,16 +1813,17 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i H5CX_set_mpio_actual_io_mode(H5D_MPIO_CHUNK_COLLECTIVE); /* Build a list of selected chunks in the collective IO operation */ - if (H5D__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < 0) + if (H5D__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't construct filtered I/O info list") /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); - ctg_io_info.store = &ctg_store; + ctg_io_info.store = &ctg_store; ctg_io_info.layout_ops = *H5D_LOPS_CONTIG; /* Initialize temporary contiguous storage info */ - ctg_store.contig.dset_size = (hsize_t) io_info->dset->shared->layout.u.chunk.size; + ctg_store.contig.dset_size = (hsize_t)io_info->dset->shared->layout.u.chunk.size; ctg_store.contig.dset_addr = 0; /* Set dataset storage for I/O info */ @@ -1803,7 +1833,7 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i for (i = 0; i < chunk_list_num_entries; i++) if (H5D__filtered_collective_chunk_entry_io(&chunk_list[i], io_info, type_info, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't process chunk entry") - } /* end if */ + } /* end if */ else { /* Filtered collective write */ H5D_chk_idx_info_t index_info; H5D_chunk_ud_t udata; @@ -1811,37 +1841,38 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i hsize_t mpi_buf_count; /* Construct chunked index info */ - index_info.f = io_info->dset->oloc.file; - index_info.pline = &(io_info->dset->shared->dcpl_cache.pline); - index_info.layout = &(io_info->dset->shared->layout.u.chunk); + index_info.f = io_info->dset->oloc.file; + index_info.pline = &(io_info->dset->shared->dcpl_cache.pline); + index_info.layout = &(io_info->dset->shared->layout.u.chunk); index_info.storage = &(io_info->dset->shared->layout.storage.u.chunk); /* Set up chunk information for insertion to chunk index */ - udata.common.layout = index_info.layout; + udata.common.layout = index_info.layout; udata.common.storage = index_info.storage; - udata.filter_mask = 0; + udata.filter_mask = 0; /* Retrieve the maximum number of chunks being written among all processes */ - if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&chunk_list_num_entries, &max_num_chunks, - 1, MPI_UNSIGNED_LONG_LONG, MPI_MAX, io_info->comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&chunk_list_num_entries, &max_num_chunks, 1, + MPI_UNSIGNED_LONG_LONG, MPI_MAX, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) /* If no one is writing anything at all, end the operation */ - if (!(max_num_chunks > 0)) HGOTO_DONE(SUCCEED); + if (!(max_num_chunks > 0)) + HGOTO_DONE(SUCCEED); /* Allocate arrays for storing MPI file and mem types and whether or not the * types were derived. */ - if (NULL == (file_type_array = (MPI_Datatype *) H5MM_malloc(max_num_chunks * sizeof(MPI_Datatype)))) + if (NULL == (file_type_array = (MPI_Datatype *)H5MM_malloc(max_num_chunks * sizeof(MPI_Datatype)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file type array") - if (NULL == (file_type_is_derived_array = (hbool_t *) H5MM_calloc(max_num_chunks * sizeof(hbool_t)))) + if (NULL == (file_type_is_derived_array = (hbool_t *)H5MM_calloc(max_num_chunks * sizeof(hbool_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file type is derived array") - if (NULL == (mem_type_array = (MPI_Datatype *) H5MM_malloc(max_num_chunks * sizeof(MPI_Datatype)))) + if (NULL == (mem_type_array = (MPI_Datatype *)H5MM_malloc(max_num_chunks * sizeof(MPI_Datatype)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate mem type array") - if (NULL == (mem_type_is_derived_array = (hbool_t *) H5MM_calloc(max_num_chunks * sizeof(hbool_t)))) + if (NULL == (mem_type_is_derived_array = (hbool_t *)H5MM_calloc(max_num_chunks * sizeof(hbool_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate mem type is derived array") /* Iterate over the max number of chunks among all processes, as this process could @@ -1850,7 +1881,8 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i */ for (i = 0; i < max_num_chunks; i++) { /* Check if this process has a chunk to work on for this iteration */ - hbool_t have_chunk_to_process = (i < chunk_list_num_entries) && (mpi_rank == chunk_list[i].owners.new_owner); + hbool_t have_chunk_to_process = + (i < chunk_list_num_entries) && (mpi_rank == chunk_list[i].owners.new_owner); if (have_chunk_to_process) if (H5D__filtered_collective_chunk_entry_io(&chunk_list[i], io_info, type_info, fm) < 0) @@ -1859,8 +1891,10 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i /* Gather the new chunk sizes to all processes for a collective re-allocation * of the chunks in the file */ - if (H5D__mpio_array_gatherv(&chunk_list[i], have_chunk_to_process ? 1 : 0, sizeof(H5D_filtered_collective_io_info_t), - (void **) &collective_chunk_list, &collective_chunk_list_num_entries, true, 0, io_info->comm, NULL) < 0) + if (H5D__mpio_array_gatherv(&chunk_list[i], have_chunk_to_process ? 1 : 0, + sizeof(H5D_filtered_collective_io_info_t), + (void **)&collective_chunk_list, &collective_chunk_list_num_entries, + true, 0, io_info->comm, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, "couldn't gather new chunk sizes") /* Participate in the collective re-allocation of all chunks modified @@ -1870,15 +1904,18 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i hbool_t insert = FALSE; if (H5D__chunk_file_alloc(&index_info, &collective_chunk_list[j].chunk_states.chunk_current, - &collective_chunk_list[j].chunk_states.new_chunk, &insert, chunk_list[j].scaled) < 0) + &collective_chunk_list[j].chunk_states.new_chunk, &insert, + chunk_list[j].scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") } /* end for */ - if (NULL == (has_chunk_selected_array = (hbool_t *) H5MM_malloc((size_t) mpi_size * sizeof(hbool_t)))) + if (NULL == + (has_chunk_selected_array = (hbool_t *)H5MM_malloc((size_t)mpi_size * sizeof(hbool_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate num chunks selected array") - if (MPI_SUCCESS != (mpi_code = MPI_Allgather(&have_chunk_to_process, 1, MPI_C_BOOL, has_chunk_selected_array, - 1, MPI_C_BOOL, io_info->comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Allgather(&have_chunk_to_process, 1, MPI_C_BOOL, has_chunk_selected_array, 1, + MPI_C_BOOL, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allgather failed", mpi_code) /* If this process has a chunk to work on, create a MPI type for the @@ -1888,26 +1925,30 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i size_t offset; int mpi_type_count; - for (j = 0, offset = 0; j < (size_t) mpi_rank; j++) + for (j = 0, offset = 0; j < (size_t)mpi_rank; j++) offset += has_chunk_selected_array[j]; /* Collect the new chunk info back to the local copy, since only the record in the * collective array gets updated by the chunk re-allocation */ - H5MM_memcpy(&chunk_list[i].chunk_states.new_chunk, &collective_chunk_list[offset].chunk_states.new_chunk, sizeof(chunk_list[i].chunk_states.new_chunk)); + H5MM_memcpy(&chunk_list[i].chunk_states.new_chunk, + &collective_chunk_list[offset].chunk_states.new_chunk, + sizeof(chunk_list[i].chunk_states.new_chunk)); H5_CHECKED_ASSIGN(mpi_type_count, int, chunk_list[i].chunk_states.new_chunk.length, hsize_t); /* Create MPI memory type for writing to chunk */ - if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(mpi_type_count, MPI_BYTE, &mem_type_array[i]))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_contiguous(mpi_type_count, MPI_BYTE, &mem_type_array[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&mem_type_array[i]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&mem_type_array[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) mem_type_is_derived_array[i] = TRUE; /* Create MPI file type for writing to chunk */ - if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(mpi_type_count, MPI_BYTE, &file_type_array[i]))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_contiguous(mpi_type_count, MPI_BYTE, &file_type_array[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&file_type_array[i]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&file_type_array[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) file_type_is_derived_array[i] = TRUE; @@ -1923,34 +1964,36 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i } /* end if */ else { mem_type_array[i] = file_type_array[i] = MPI_BYTE; - mpi_buf_count = 0; + mpi_buf_count = 0; } /* end else */ /* Perform the I/O */ - if (H5D__final_collective_io(&ctg_io_info, type_info, mpi_buf_count, file_type_array[i], mem_type_array[i]) < 0) + if (H5D__final_collective_io(&ctg_io_info, type_info, mpi_buf_count, file_type_array[i], + mem_type_array[i]) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish MPI-IO") /* Participate in the collective re-insertion of all chunks modified * in this iteration into the chunk index */ for (j = 0; j < collective_chunk_list_num_entries; j++) { - udata.chunk_block = collective_chunk_list[j].chunk_states.new_chunk; + udata.chunk_block = collective_chunk_list[j].chunk_states.new_chunk; udata.common.scaled = collective_chunk_list[j].scaled; - udata.chunk_idx = collective_chunk_list[j].index; + udata.chunk_idx = collective_chunk_list[j].index; if ((index_info.storage->ops->insert)(&index_info, &udata, io_info->dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk address into index") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, + "unable to insert chunk address into index") } /* end for */ - if (collective_chunk_list){ + if (collective_chunk_list) { H5MM_free(collective_chunk_list); collective_chunk_list = NULL; } /* end if */ - if (has_chunk_selected_array){ + if (has_chunk_selected_array) { H5MM_free(has_chunk_selected_array); has_chunk_selected_array = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* Free the MPI file and memory types, if they were derived */ for (i = 0; i < max_num_chunks; i++) { @@ -1962,7 +2005,7 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type_array[i]))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) } /* end for */ - } /* end else */ + } /* end else */ done: if (chunk_list) { @@ -1987,7 +2030,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__multi_chunk_filtered_collective_io() */ - /*------------------------------------------------------------------------- * Function: H5D__inter_collective_io * @@ -2002,20 +2044,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5S_t *file_space, const H5S_t *mem_space) +H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space, + const H5S_t *mem_space) { - int mpi_buf_count; /* # of MPI types */ - hbool_t mbt_is_derived = FALSE; - hbool_t mft_is_derived = FALSE; - MPI_Datatype mpi_file_type, mpi_buf_type; - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* return value */ + int mpi_buf_count; /* # of MPI types */ + hbool_t mbt_is_derived = FALSE; + hbool_t mft_is_derived = FALSE; + MPI_Datatype mpi_file_type, mpi_buf_type; + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC - if((file_space != NULL) && (mem_space != NULL)) { - int mpi_file_count; /* Number of file "objects" to transfer */ + if ((file_space != NULL) && (mem_space != NULL)) { + int mpi_file_count; /* Number of file "objects" to transfer */ hsize_t *permute_map = NULL; /* array that holds the mapping from the old, out-of-order displacements to the in-order displacements of the MPI datatypes of the @@ -2027,39 +2069,40 @@ H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf * and will be fed into the next call to H5S_mpio_space_type * where it will be freed. */ - if(H5S_mpio_space_type(file_space, type_info->src_type_size, - &mpi_file_type, &mpi_file_count, &mft_is_derived, /* OUT: datatype created */ - TRUE, /* this is a file space, so - permute the datatype if the - point selection is out of - order */ - &permute_map, /* OUT: a map to indicate - the permutation of - points selected in - case they are out of - order */ - &is_permuted /* OUT */) < 0) + if (H5S_mpio_space_type(file_space, type_info->src_type_size, &mpi_file_type, &mpi_file_count, + &mft_is_derived, /* OUT: datatype created */ + TRUE, /* this is a file space, so + permute the datatype if the + point selection is out of + order */ + &permute_map, /* OUT: a map to indicate + the permutation of + points selected in + case they are out of + order */ + &is_permuted /* OUT */) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create MPI file type") /* Sanity check */ - if(is_permuted) + if (is_permuted) HDassert(permute_map); - if(H5S_mpio_space_type(mem_space, type_info->src_type_size, - &mpi_buf_type, &mpi_buf_count, &mbt_is_derived, /* OUT: datatype created */ - FALSE, /* this is a memory space, so if - the file space is not - permuted, there is no need to - permute the datatype if the - point selections are out of - order*/ - &permute_map /* IN: the permutation map - generated by the - file_space selection - and applied to the - memory selection */, - &is_permuted /* IN */) < 0) + if (H5S_mpio_space_type(mem_space, type_info->src_type_size, &mpi_buf_type, &mpi_buf_count, + &mbt_is_derived, /* OUT: datatype created */ + FALSE, /* this is a memory space, so if + the file space is not + permuted, there is no need to + permute the datatype if the + point selections are out of + order*/ + &permute_map /* IN: the permutation map + generated by the + file_space selection + and applied to the + memory selection */ + , + &is_permuted /* IN */) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create MPI buffer type") /* Sanity check */ - if(is_permuted) + if (is_permuted) HDassert(!permute_map); } /* end if */ else { @@ -2072,30 +2115,29 @@ H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf } /* end else */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before final collective IO \n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before final collective IO \n"); #endif /* Perform final collective I/O operation */ - if(H5D__final_collective_io(io_info, type_info, (hsize_t)mpi_buf_count, mpi_file_type, mpi_buf_type) < 0) + if (H5D__final_collective_io(io_info, type_info, (hsize_t)mpi_buf_count, mpi_file_type, mpi_buf_type) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish collective MPI-IO") done: /* Free the MPI buf and file types, if they were derived */ - if(mbt_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mpi_buf_type))) + if (mbt_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mpi_buf_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(mft_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mpi_file_type))) + if (mft_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mpi_file_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before leaving inter_collective_io ret_value = %d\n",ret_value); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before leaving inter_collective_io ret_value = %d\n", ret_value); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__inter_collective_io() */ - /*------------------------------------------------------------------------- * Function: H5D__final_collective_io * @@ -2109,35 +2151,34 @@ if(H5DEBUG(D)) *------------------------------------------------------------------------- */ static herr_t -H5D__final_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t mpi_buf_count, MPI_Datatype mpi_file_type, MPI_Datatype mpi_buf_type) +H5D__final_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t mpi_buf_count, + MPI_Datatype mpi_file_type, MPI_Datatype mpi_buf_type) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Pass buf type, file type to the file driver. */ - if(H5CX_set_mpi_coll_datatypes(mpi_buf_type, mpi_file_type) < 0) + if (H5CX_set_mpi_coll_datatypes(mpi_buf_type, mpi_file_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O collective I/O datatypes") - if(io_info->op_type == H5D_IO_OP_WRITE) { - if((io_info->io_ops.single_write)(io_info, type_info, mpi_buf_count, NULL, NULL) < 0) + if (io_info->op_type == H5D_IO_OP_WRITE) { + if ((io_info->io_ops.single_write)(io_info, type_info, mpi_buf_count, NULL, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed") } /* end if */ else { - if((io_info->io_ops.single_read)(io_info, type_info, mpi_buf_count, NULL, NULL) < 0) + if ((io_info->io_ops.single_read)(io_info, type_info, mpi_buf_count, NULL, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "optimized read failed") } /* end else */ done: #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"ret_value before leaving final_collective_io=%d\n",ret_value); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "ret_value before leaving final_collective_io=%d\n", ret_value); #endif - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__final_collective_io */ - /*------------------------------------------------------------------------- * Function: H5D__cmp_chunk_addr * @@ -2155,17 +2196,16 @@ if(H5DEBUG(D)) static int H5D__cmp_chunk_addr(const void *chunk_addr_info1, const void *chunk_addr_info2) { - haddr_t addr1 = HADDR_UNDEF, addr2 = HADDR_UNDEF; + haddr_t addr1 = HADDR_UNDEF, addr2 = HADDR_UNDEF; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC_NOERR - addr1 = ((const H5D_chunk_addr_info_t *)chunk_addr_info1)->chunk_addr; - addr2 = ((const H5D_chunk_addr_info_t *)chunk_addr_info2)->chunk_addr; + addr1 = ((const H5D_chunk_addr_info_t *)chunk_addr_info1)->chunk_addr; + addr2 = ((const H5D_chunk_addr_info_t *)chunk_addr_info2)->chunk_addr; - FUNC_LEAVE_NOAPI(H5F_addr_cmp(addr1, addr2)) + FUNC_LEAVE_NOAPI(H5F_addr_cmp(addr1, addr2)) } /* end H5D__cmp_chunk_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__cmp_filtered_collective_io_info_entry * @@ -2183,20 +2223,23 @@ H5D__cmp_chunk_addr(const void *chunk_addr_info1, const void *chunk_addr_info2) *------------------------------------------------------------------------- */ static int -H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_info_entry1, const void *filtered_collective_io_info_entry2) +H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_info_entry1, + const void *filtered_collective_io_info_entry2) { haddr_t addr1 = HADDR_UNDEF, addr2 = HADDR_UNDEF; FUNC_ENTER_STATIC_NOERR - addr1 = ((const H5D_filtered_collective_io_info_t *) filtered_collective_io_info_entry1)->chunk_states.new_chunk.offset; - addr2 = ((const H5D_filtered_collective_io_info_t *) filtered_collective_io_info_entry2)->chunk_states.new_chunk.offset; + addr1 = ((const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry1) + ->chunk_states.new_chunk.offset; + addr2 = ((const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry2) + ->chunk_states.new_chunk.offset; FUNC_LEAVE_NOAPI(H5F_addr_cmp(addr1, addr2)) } /* end H5D__cmp_filtered_collective_io_info_entry() */ #if MPI_VERSION >= 3 - + /*------------------------------------------------------------------------- * Function: H5D__cmp_filtered_collective_io_info_entry_owner * @@ -2215,20 +2258,22 @@ H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_in *------------------------------------------------------------------------- */ static int -H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective_io_info_entry1, const void *filtered_collective_io_info_entry2) +H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective_io_info_entry1, + const void *filtered_collective_io_info_entry2) { int owner1 = -1, owner2 = -1; FUNC_ENTER_STATIC_NOERR - owner1 = ((const H5D_filtered_collective_io_info_t *) filtered_collective_io_info_entry1)->owners.original_owner; - owner2 = ((const H5D_filtered_collective_io_info_t *) filtered_collective_io_info_entry2)->owners.original_owner; + owner1 = ((const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry1) + ->owners.original_owner; + owner2 = ((const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry2) + ->owners.original_owner; FUNC_LEAVE_NOAPI(owner1 - owner2) } /* end H5D__cmp_filtered_collective_io_info_entry_owner() */ #endif - /*------------------------------------------------------------------------- * Function: H5D__sort_chunk * @@ -2243,8 +2288,8 @@ H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective * Parameters: * Input: H5D_io_info_t* io_info, * H5D_chunk_map_t *fm(global chunk map struct) - * Input/Output: H5D_chunk_addr_info_t chunk_addr_info_array[] : array to store chunk address and information - * many_chunk_opt : flag to optimize the way to obtain chunk addresses + * Input/Output: H5D_chunk_addr_info_t chunk_addr_info_array[] : array to store chunk address + *and information many_chunk_opt : flag to optimize the way to obtain chunk addresses * for many chunks * * Return: Non-negative on success/Negative on failure @@ -2256,24 +2301,24 @@ H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective */ static herr_t H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, - H5D_chunk_addr_info_t chunk_addr_info_array[], int sum_chunk) + H5D_chunk_addr_info_t chunk_addr_info_array[], int sum_chunk) { - H5SL_node_t *chunk_node; /* Current node in chunk skip list */ - H5D_chunk_info_t *chunk_info; /* Current chunking info. of this node. */ - haddr_t chunk_addr; /* Current chunking address of this node */ - haddr_t *total_chunk_addr_array = NULL; /* The array of chunk address for the total number of chunk */ - hbool_t do_sort = FALSE; /* Whether the addresses need to be sorted */ - int bsearch_coll_chunk_threshold; - int many_chunk_opt = H5D_OBTAIN_ONE_CHUNK_ADDR_IND; - int mpi_size; /* Number of MPI processes */ - int mpi_code; /* MPI return code */ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SL_node_t * chunk_node; /* Current node in chunk skip list */ + H5D_chunk_info_t *chunk_info; /* Current chunking info. of this node. */ + haddr_t chunk_addr; /* Current chunking address of this node */ + haddr_t *total_chunk_addr_array = NULL; /* The array of chunk address for the total number of chunk */ + hbool_t do_sort = FALSE; /* Whether the addresses need to be sorted */ + int bsearch_coll_chunk_threshold; + int many_chunk_opt = H5D_OBTAIN_ONE_CHUNK_ADDR_IND; + int mpi_size; /* Number of MPI processes */ + int mpi_code; /* MPI return code */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Retrieve # of MPI processes */ - if((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) + if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") /* Calculate the actual threshold to obtain all chunk addresses collectively @@ -2285,56 +2330,59 @@ H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, * for each process. */ bsearch_coll_chunk_threshold = (sum_chunk * 100) / ((int)fm->layout->u.chunk.nchunks * mpi_size); - if((bsearch_coll_chunk_threshold > H5D_ALL_CHUNK_ADDR_THRES_COL) - && ((sum_chunk / mpi_size) >= H5D_ALL_CHUNK_ADDR_THRES_COL_NUM)) + if ((bsearch_coll_chunk_threshold > H5D_ALL_CHUNK_ADDR_THRES_COL) && + ((sum_chunk / mpi_size) >= H5D_ALL_CHUNK_ADDR_THRES_COL_NUM)) many_chunk_opt = H5D_OBTAIN_ALL_CHUNK_ADDR_COL; #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "many_chunk_opt= %d\n", many_chunk_opt); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "many_chunk_opt= %d\n", many_chunk_opt); #endif /* If we need to optimize the way to obtain the chunk address */ - if(many_chunk_opt != H5D_OBTAIN_ONE_CHUNK_ADDR_IND) { + if (many_chunk_opt != H5D_OBTAIN_ONE_CHUNK_ADDR_IND) { int mpi_rank; #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "Coming inside H5D_OBTAIN_ALL_CHUNK_ADDR_COL\n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "Coming inside H5D_OBTAIN_ALL_CHUNK_ADDR_COL\n"); #endif /* Allocate array for chunk addresses */ - if(NULL == (total_chunk_addr_array = (haddr_t *)H5MM_malloc(sizeof(haddr_t) * (size_t)fm->layout->u.chunk.nchunks))) + if (NULL == (total_chunk_addr_array = + (haddr_t *)H5MM_malloc(sizeof(haddr_t) * (size_t)fm->layout->u.chunk.nchunks))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory chunk address array") /* Retrieve all the chunk addresses with process 0 */ - if((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi rank") - if(mpi_rank == 0) { - if(H5D__chunk_addrmap(io_info, total_chunk_addr_array) < 0) + if (mpi_rank == 0) { + if (H5D__chunk_addrmap(io_info, total_chunk_addr_array) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") } /* end if */ /* Broadcasting the MPI_IO option info. and chunk address info. */ - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(total_chunk_addr_array, (int)(sizeof(haddr_t) * fm->layout->u.chunk.nchunks), MPI_BYTE, (int)0, io_info->comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(total_chunk_addr_array, + (int)(sizeof(haddr_t) * fm->layout->u.chunk.nchunks), + MPI_BYTE, (int)0, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code) } /* end if */ /* Start at first node in chunk skip list */ i = 0; - if(NULL == (chunk_node = H5SL_first(fm->sel_chunks))) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL,"couldn't get chunk node from skipped list") + if (NULL == (chunk_node = H5SL_first(fm->sel_chunks))) + HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk node from skipped list") /* Iterate over all chunks for this process */ - while(chunk_node) { - if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL,"couldn't get chunk info from skipped list") + while (chunk_node) { + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) + HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skipped list") - if(many_chunk_opt == H5D_OBTAIN_ONE_CHUNK_ADDR_IND) { - H5D_chunk_ud_t udata; /* User data for querying chunk info */ + if (many_chunk_opt == H5D_OBTAIN_ONE_CHUNK_ADDR_IND) { + H5D_chunk_ud_t udata; /* User data for querying chunk info */ /* Get address of chunk */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skipped list") chunk_addr = udata.chunk_block.offset; } /* end if */ @@ -2342,7 +2390,7 @@ if(H5DEBUG(D)) chunk_addr = total_chunk_addr_array[chunk_info->index]; /* Check if chunk addresses are not in increasing order in the file */ - if(i > 0 && chunk_addr < chunk_addr_info_array[i - 1].chunk_addr) + if (i > 0 && chunk_addr < chunk_addr_info_array[i - 1].chunk_addr) do_sort = TRUE; /* Set the address & info for this chunk */ @@ -2355,23 +2403,22 @@ if(H5DEBUG(D)) } /* end while */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before Qsort\n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before Qsort\n"); #endif - if(do_sort) { + if (do_sort) { size_t num_chunks = H5SL_count(fm->sel_chunks); HDqsort(chunk_addr_info_array, num_chunks, sizeof(chunk_addr_info_array[0]), H5D__cmp_chunk_addr); } /* end if */ done: - if(total_chunk_addr_array) + if (total_chunk_addr_array) H5MM_xfree(total_chunk_addr_array); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__sort_chunk() */ - /*------------------------------------------------------------------------- * Function: H5D__obtain_mpio_mode * @@ -2392,7 +2439,8 @@ done: * c) Build MPI derived datatype to combine "chunk address" and "assign_io" information * in order to do MPI Bcast only once * d) MPI Bcast the IO mode and chunk address information for each chunk. - * 4) Each process then retrieves IO mode and chunk address information to assign_io_mode and chunk_addr. + * 4) Each process then retrieves IO mode and chunk address information to assign_io_mode and + *chunk_addr. * * Parameters: * @@ -2409,17 +2457,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, - uint8_t assign_io_mode[], haddr_t chunk_addr[]) +H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assign_io_mode[], + haddr_t chunk_addr[]) { size_t total_chunks; unsigned percent_nproc_per_chunk, threshold_nproc_per_chunk; - uint8_t* io_mode_info = NULL; - uint8_t* recv_io_mode_info = NULL; - uint8_t* mergebuf = NULL; - uint8_t* tempbuf; - H5SL_node_t* chunk_node; - H5D_chunk_info_t* chunk_info; + uint8_t * io_mode_info = NULL; + uint8_t * recv_io_mode_info = NULL; + uint8_t * mergebuf = NULL; + uint8_t * tempbuf; + H5SL_node_t * chunk_node; + H5D_chunk_info_t *chunk_info; int mpi_size, mpi_rank; MPI_Comm comm; int root; @@ -2430,91 +2478,90 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, FUNC_ENTER_STATIC /* Assign the rank 0 to the root */ - root = 0; - comm = io_info->comm; + root = 0; + comm = io_info->comm; /* Obtain the number of process and the current rank of the process */ - if((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi rank") - if((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) + if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") /* Setup parameters */ H5_CHECKED_ASSIGN(total_chunks, size_t, fm->layout->u.chunk.nchunks, hsize_t); - if(H5CX_get_mpio_chunk_opt_ratio(&percent_nproc_per_chunk) < 0) + if (H5CX_get_mpio_chunk_opt_ratio(&percent_nproc_per_chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get percent nproc per chunk") /* if ratio is 0, perform collective io */ - if(0 == percent_nproc_per_chunk) { - if(H5D__chunk_addrmap(io_info, chunk_addr) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address"); - for(ic = 0; ic < total_chunks; ic++) - assign_io_mode[ic] = H5D_CHUNK_IO_MODE_COL; + if (0 == percent_nproc_per_chunk) { + if (H5D__chunk_addrmap(io_info, chunk_addr) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address"); + for (ic = 0; ic < total_chunks; ic++) + assign_io_mode[ic] = H5D_CHUNK_IO_MODE_COL; HGOTO_DONE(SUCCEED) } /* end if */ - threshold_nproc_per_chunk = (unsigned)mpi_size * percent_nproc_per_chunk/100; + threshold_nproc_per_chunk = (unsigned)mpi_size * percent_nproc_per_chunk / 100; /* Allocate memory */ - if(NULL == (io_mode_info = (uint8_t *)H5MM_calloc(total_chunks))) + if (NULL == (io_mode_info = (uint8_t *)H5MM_calloc(total_chunks))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate I/O mode info buffer") - if(NULL == (mergebuf = (uint8_t *)H5MM_malloc((sizeof(haddr_t) + 1) * total_chunks))) + if (NULL == (mergebuf = (uint8_t *)H5MM_malloc((sizeof(haddr_t) + 1) * total_chunks))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate mergebuf buffer") - tempbuf = mergebuf + total_chunks; - if(mpi_rank == root) - if(NULL == (recv_io_mode_info = (uint8_t *)H5MM_malloc(total_chunks * (size_t)mpi_size))) + tempbuf = mergebuf + total_chunks; + if (mpi_rank == root) + if (NULL == (recv_io_mode_info = (uint8_t *)H5MM_malloc(total_chunks * (size_t)mpi_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate recv I/O mode info buffer") /* Obtain the regularity and selection information for all chunks in this process. */ - chunk_node = H5SL_first(fm->sel_chunks); - while(chunk_node) { - chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node); + chunk_node = H5SL_first(fm->sel_chunks); + while (chunk_node) { + chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node); io_mode_info[chunk_info->index] = H5D_CHUNK_SELECT_REG; /* this chunk is selected and is "regular" */ - chunk_node = H5SL_next(chunk_node); + chunk_node = H5SL_next(chunk_node); } /* end while */ /* Gather all the information */ H5_CHECK_OVERFLOW(total_chunks, size_t, int) - if(MPI_SUCCESS != (mpi_code = MPI_Gather(io_mode_info, (int)total_chunks, MPI_BYTE, - recv_io_mode_info, (int)total_chunks, MPI_BYTE, root, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Gather(io_mode_info, (int)total_chunks, MPI_BYTE, recv_io_mode_info, + (int)total_chunks, MPI_BYTE, root, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Gather failed", mpi_code) /* Calculate the mode for IO(collective, independent or none) at root process */ - if(mpi_rank == root) { - size_t nproc; - unsigned* nproc_per_chunk; + if (mpi_rank == root) { + size_t nproc; + unsigned *nproc_per_chunk; /* pre-computing: calculate number of processes and regularity of the selection occupied in each chunk */ - if(NULL == (nproc_per_chunk = (unsigned*)H5MM_calloc(total_chunks * sizeof(unsigned)))) + if (NULL == (nproc_per_chunk = (unsigned *)H5MM_calloc(total_chunks * sizeof(unsigned)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate nproc_per_chunk buffer") /* calculating the chunk address */ - if(H5D__chunk_addrmap(io_info, chunk_addr) < 0) { + if (H5D__chunk_addrmap(io_info, chunk_addr) < 0) { H5MM_free(nproc_per_chunk); HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") } /* end if */ /* checking for number of process per chunk and regularity of the selection*/ - for(nproc = 0; nproc < (size_t)mpi_size; nproc++) { + for (nproc = 0; nproc < (size_t)mpi_size; nproc++) { uint8_t *tmp_recv_io_mode_info = recv_io_mode_info + (nproc * total_chunks); /* Calculate the number of process per chunk and adding irregular selection option */ - for(ic = 0; ic < total_chunks; ic++, tmp_recv_io_mode_info++) { - if(*tmp_recv_io_mode_info != 0) { + for (ic = 0; ic < total_chunks; ic++, tmp_recv_io_mode_info++) { + if (*tmp_recv_io_mode_info != 0) { nproc_per_chunk[ic]++; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Calculating MPIO mode for each chunk (collective, independent, none) */ - for(ic = 0; ic < total_chunks; ic++) { - if(nproc_per_chunk[ic] > MAX(1, threshold_nproc_per_chunk)) { + for (ic = 0; ic < total_chunks; ic++) { + if (nproc_per_chunk[ic] > MAX(1, threshold_nproc_per_chunk)) { assign_io_mode[ic] = H5D_CHUNK_IO_MODE_COL; } /* end if */ - } /* end for */ - + } /* end for */ /* merge buffer io_mode info and chunk addr into one */ H5MM_memcpy(mergebuf, assign_io_mode, total_chunks); @@ -2524,38 +2571,39 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, } /* end if */ /* Broadcasting the MPI_IO option info. and chunk address info. */ - if((sizeof(haddr_t) + 1) * total_chunks > INT_MAX) + if ((sizeof(haddr_t) + 1) * total_chunks > INT_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "result overflow") - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(mergebuf, (int)((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Bcast(mergebuf, (int)((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code) H5MM_memcpy(assign_io_mode, mergebuf, total_chunks); H5MM_memcpy(chunk_addr, tempbuf, sizeof(haddr_t) * total_chunks); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY -{ - hbool_t coll_op = FALSE; + { + hbool_t coll_op = FALSE; + + for (ic = 0; ic < total_chunks; ic++) + if (assign_io_mode[ic] == H5D_CHUNK_IO_MODE_COL) { + if (H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + coll_op = TRUE; + break; + } /* end if */ - for(ic = 0; ic < total_chunks; ic++) - if(assign_io_mode[ic] == H5D_CHUNK_IO_MODE_COL) { - if(H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(0) < 0) + if (!coll_op) + if (H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - coll_op = TRUE; - break; - } /* end if */ - - if(!coll_op) - if(H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") -} + } #endif done: - if(io_mode_info) + if (io_mode_info) H5MM_free(io_mode_info); - if(mergebuf) + if (mergebuf) H5MM_free(mergebuf); - if(recv_io_mode_info) { + if (recv_io_mode_info) { HDassert(mpi_rank == root); H5MM_free(recv_io_mode_info); } /* end if */ @@ -2563,7 +2611,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__obtain_mpio_mode() */ - /*------------------------------------------------------------------------- * Function: H5D__construct_filtered_io_info_list * @@ -2584,13 +2631,15 @@ done: */ static herr_t H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5D_chunk_map_t *fm, H5D_filtered_collective_io_info_t **chunk_list, size_t *num_entries) + const H5D_chunk_map_t * fm, + H5D_filtered_collective_io_info_t **chunk_list, size_t *num_entries) { - H5D_filtered_collective_io_info_t *local_info_array = NULL; /* The list of initially selected chunks for this process */ - size_t num_chunks_selected; - size_t i; - int mpi_rank; - herr_t ret_value = SUCCEED; + H5D_filtered_collective_io_info_t *local_info_array = + NULL; /* The list of initially selected chunks for this process */ + size_t num_chunks_selected; + size_t i; + int mpi_rank; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -2607,35 +2656,37 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ if ((num_chunks_selected = H5SL_count(fm->sel_chunks))) { H5D_chunk_info_t *chunk_info; H5D_chunk_ud_t udata; - H5SL_node_t *chunk_node; + H5SL_node_t * chunk_node; hsize_t select_npoints; hssize_t chunk_npoints; - if(NULL == (local_info_array = (H5D_filtered_collective_io_info_t *) H5MM_malloc(num_chunks_selected * sizeof(H5D_filtered_collective_io_info_t)))) + if (NULL == (local_info_array = (H5D_filtered_collective_io_info_t *)H5MM_malloc( + num_chunks_selected * sizeof(H5D_filtered_collective_io_info_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate local io info array buffer") chunk_node = H5SL_first(fm->sel_chunks); - for(i = 0; chunk_node; i++) { - chunk_info = (H5D_chunk_info_t *) H5SL_item(chunk_node); + for (i = 0; chunk_node; i++) { + chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node); /* Obtain this chunk's address */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") - local_info_array[i].index = chunk_info->index; - local_info_array[i].chunk_states.chunk_current = local_info_array[i].chunk_states.new_chunk = udata.chunk_block; - local_info_array[i].num_writers = 0; + local_info_array[i].index = chunk_info->index; + local_info_array[i].chunk_states.chunk_current = local_info_array[i].chunk_states.new_chunk = + udata.chunk_block; + local_info_array[i].num_writers = 0; local_info_array[i].owners.original_owner = local_info_array[i].owners.new_owner = mpi_rank; - local_info_array[i].buf = NULL; + local_info_array[i].buf = NULL; - local_info_array[i].async_info.num_receive_requests = 0; - local_info_array[i].async_info.receive_buffer_array = NULL; + local_info_array[i].async_info.num_receive_requests = 0; + local_info_array[i].async_info.receive_buffer_array = NULL; local_info_array[i].async_info.receive_requests_array = NULL; H5MM_memcpy(local_info_array[i].scaled, chunk_info->scaled, sizeof(chunk_info->scaled)); - select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); - local_info_array[i].io_size = (size_t) select_npoints * type_info->src_type_size; + select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); + local_info_array[i].io_size = (size_t)select_npoints * type_info->src_type_size; /* Currently the full overwrite status of a chunk is only obtained on a per-process * basis. This means that if the total selection in the chunk, as determined by the combination @@ -2648,22 +2699,26 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ if ((chunk_npoints = H5S_GET_EXTENT_NPOINTS(chunk_info->fspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") local_info_array[i].full_overwrite = - (local_info_array[i].io_size >= (hsize_t) chunk_npoints * type_info->dst_type_size) ? TRUE : FALSE; + (local_info_array[i].io_size >= (hsize_t)chunk_npoints * type_info->dst_type_size) ? TRUE + : FALSE; chunk_node = H5SL_next(chunk_node); } /* end for */ - } /* end if */ + } /* end if */ /* Redistribute shared chunks to new owners as necessary */ if (io_info->op_type == H5D_IO_OP_WRITE) #if MPI_VERSION >= 3 - if (H5D__chunk_redistribute_shared_chunks(io_info, type_info, fm, local_info_array, &num_chunks_selected) < 0) + if (H5D__chunk_redistribute_shared_chunks(io_info, type_info, fm, local_info_array, + &num_chunks_selected) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to redistribute shared chunks") #else - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to redistribute shared chunks - MPI version < 3 (MPI_Mprobe and MPI_Imrecv missing)") + HGOTO_ERROR( + H5E_DATASET, H5E_WRITEERROR, FAIL, + "unable to redistribute shared chunks - MPI version < 3 (MPI_Mprobe and MPI_Imrecv missing)") #endif - *chunk_list = local_info_array; + *chunk_list = local_info_array; *num_entries = num_chunks_selected; done: @@ -2671,7 +2726,7 @@ done: } /* end H5D__construct_filtered_io_info_list() */ #if MPI_VERSION >= 3 - + /*------------------------------------------------------------------------- * Function: H5D__chunk_redistribute_shared_chunks * @@ -2713,23 +2768,27 @@ done: */ static herr_t H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5D_chunk_map_t *fm, H5D_filtered_collective_io_info_t *local_chunk_array, size_t *local_chunk_array_num_entries) + const H5D_chunk_map_t * fm, + H5D_filtered_collective_io_info_t *local_chunk_array, + size_t * local_chunk_array_num_entries) { - H5D_filtered_collective_io_info_t *shared_chunks_info_array = NULL; /* The list of all chunks selected in the operation by all processes */ - H5S_sel_iter_t *mem_iter = NULL; /* Memory iterator for H5D__gather_mem */ - unsigned char **mod_data = NULL; /* Array of chunk modification data buffers sent by a process to new chunk owners */ - MPI_Request *send_requests = NULL; /* Array of MPI_Isend chunk modification data send requests */ - MPI_Status *send_statuses = NULL; /* Array of MPI_Isend chunk modification send statuses */ - hbool_t mem_iter_init = FALSE; - size_t shared_chunks_info_array_num_entries = 0; - size_t num_send_requests = 0; - size_t *num_assigned_chunks_array = NULL; - size_t i, last_assigned_idx; - int *send_counts = NULL; - int *send_displacements = NULL; - int scatter_recvcount_int; - int mpi_rank, mpi_size, mpi_code; - herr_t ret_value = SUCCEED; + H5D_filtered_collective_io_info_t *shared_chunks_info_array = + NULL; /* The list of all chunks selected in the operation by all processes */ + H5S_sel_iter_t *mem_iter = NULL; /* Memory iterator for H5D__gather_mem */ + unsigned char **mod_data = + NULL; /* Array of chunk modification data buffers sent by a process to new chunk owners */ + MPI_Request *send_requests = NULL; /* Array of MPI_Isend chunk modification data send requests */ + MPI_Status * send_statuses = NULL; /* Array of MPI_Isend chunk modification send statuses */ + hbool_t mem_iter_init = FALSE; + size_t shared_chunks_info_array_num_entries = 0; + size_t num_send_requests = 0; + size_t * num_assigned_chunks_array = NULL; + size_t i, last_assigned_idx; + int * send_counts = NULL; + int * send_displacements = NULL; + int scatter_recvcount_int; + int mpi_rank, mpi_size, mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -2747,58 +2806,63 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty H5CX_set_libver_bounds(NULL); if (*local_chunk_array_num_entries) - if (NULL == (send_requests = (MPI_Request *) H5MM_malloc(*local_chunk_array_num_entries * sizeof(MPI_Request)))) + if (NULL == (send_requests = + (MPI_Request *)H5MM_malloc(*local_chunk_array_num_entries * sizeof(MPI_Request)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate send requests buffer") - if (NULL == (mem_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t)))) + if (NULL == (mem_iter = (H5S_sel_iter_t *)H5MM_malloc(sizeof(H5S_sel_iter_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate memory iterator") - /* Gather every rank's list of chunks to rank 0 to allow it to perform the redistribution operation. After this - * call, the gathered list will initially be sorted in increasing order of chunk offset in the file. + /* Gather every rank's list of chunks to rank 0 to allow it to perform the redistribution operation. After + * this call, the gathered list will initially be sorted in increasing order of chunk offset in the file. */ - if (H5D__mpio_array_gatherv(local_chunk_array, *local_chunk_array_num_entries, sizeof(H5D_filtered_collective_io_info_t), - (void **) &shared_chunks_info_array, &shared_chunks_info_array_num_entries, false, 0, - io_info->comm, H5D__cmp_filtered_collective_io_info_entry) < 0) + if (H5D__mpio_array_gatherv(local_chunk_array, *local_chunk_array_num_entries, + sizeof(H5D_filtered_collective_io_info_t), (void **)&shared_chunks_info_array, + &shared_chunks_info_array_num_entries, false, 0, io_info->comm, + H5D__cmp_filtered_collective_io_info_entry) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, "couldn't gather array") /* Rank 0 redistributes any shared chunks to new owners as necessary */ if (mpi_rank == 0) { - if (NULL == (send_counts = (int *) H5MM_calloc((size_t) mpi_size * sizeof(int)))) + if (NULL == (send_counts = (int *)H5MM_calloc((size_t)mpi_size * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate send counts buffer") - if (NULL == (send_displacements = (int *) H5MM_malloc((size_t) mpi_size * sizeof(int)))) + if (NULL == (send_displacements = (int *)H5MM_malloc((size_t)mpi_size * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate send displacements buffer") - if (NULL == (num_assigned_chunks_array = (size_t *) H5MM_calloc((size_t) mpi_size * sizeof(size_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate number of assigned chunks array") + if (NULL == (num_assigned_chunks_array = (size_t *)H5MM_calloc((size_t)mpi_size * sizeof(size_t)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "unable to allocate number of assigned chunks array") for (i = 0; i < shared_chunks_info_array_num_entries;) { H5D_filtered_collective_io_info_t chunk_entry; - haddr_t last_seen_addr = shared_chunks_info_array[i].chunk_states.chunk_current.offset; - size_t set_begin_index = i; - size_t num_writers = 0; - int new_chunk_owner = shared_chunks_info_array[i].owners.original_owner; + haddr_t last_seen_addr = shared_chunks_info_array[i].chunk_states.chunk_current.offset; + size_t set_begin_index = i; + size_t num_writers = 0; + int new_chunk_owner = shared_chunks_info_array[i].owners.original_owner; /* Process each set of duplicate entries caused by another process writing to the same chunk */ do { chunk_entry = shared_chunks_info_array[i]; - send_counts[chunk_entry.owners.original_owner] += (int) sizeof(chunk_entry); + send_counts[chunk_entry.owners.original_owner] += (int)sizeof(chunk_entry); /* The new owner of the chunk is determined by the process * writing to the chunk which currently has the least amount * of chunks assigned to it */ - if (num_assigned_chunks_array[chunk_entry.owners.original_owner] < num_assigned_chunks_array[new_chunk_owner]) + if (num_assigned_chunks_array[chunk_entry.owners.original_owner] < + num_assigned_chunks_array[new_chunk_owner]) new_chunk_owner = chunk_entry.owners.original_owner; num_writers++; - } while (++i < shared_chunks_info_array_num_entries && shared_chunks_info_array[i].chunk_states.chunk_current.offset == last_seen_addr); + } while (++i < shared_chunks_info_array_num_entries && + shared_chunks_info_array[i].chunk_states.chunk_current.offset == last_seen_addr); /* Set all of the chunk entries' "new_owner" fields */ for (; set_begin_index < i; set_begin_index++) { shared_chunks_info_array[set_begin_index].owners.new_owner = new_chunk_owner; - shared_chunks_info_array[set_begin_index].num_writers = num_writers; + shared_chunks_info_array[set_begin_index].num_writers = num_writers; } /* end for */ num_assigned_chunks_array[new_chunk_owner]++; @@ -2807,19 +2871,22 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty /* Sort the new list in order of previous owner so that each original owner of a chunk * entry gets that entry back, with the possibly newly-modified "new_owner" field */ - if(shared_chunks_info_array_num_entries > 1) + if (shared_chunks_info_array_num_entries > 1) HDqsort(shared_chunks_info_array, shared_chunks_info_array_num_entries, - sizeof(H5D_filtered_collective_io_info_t), H5D__cmp_filtered_collective_io_info_entry_owner); + sizeof(H5D_filtered_collective_io_info_t), + H5D__cmp_filtered_collective_io_info_entry_owner); send_displacements[0] = 0; - for (i = 1; i < (size_t) mpi_size; i++) + for (i = 1; i < (size_t)mpi_size; i++) send_displacements[i] = send_displacements[i - 1] + send_counts[i - 1]; } /* end if */ /* Scatter the segments of the list back to each process */ - H5_CHECKED_ASSIGN(scatter_recvcount_int, int, *local_chunk_array_num_entries * sizeof(H5D_filtered_collective_io_info_t), size_t); - if (MPI_SUCCESS != (mpi_code = MPI_Scatterv(shared_chunks_info_array, send_counts, send_displacements, - MPI_BYTE, local_chunk_array, scatter_recvcount_int, MPI_BYTE, 0, io_info->comm))) + H5_CHECKED_ASSIGN(scatter_recvcount_int, int, + *local_chunk_array_num_entries * sizeof(H5D_filtered_collective_io_info_t), size_t); + if (MPI_SUCCESS != + (mpi_code = MPI_Scatterv(shared_chunks_info_array, send_counts, send_displacements, MPI_BYTE, + local_chunk_array, scatter_recvcount_int, MPI_BYTE, 0, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "unable to scatter shared chunks info buffer", mpi_code) if (shared_chunks_info_array) { @@ -2833,7 +2900,8 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty * chunks it is assigned, in order to avoid potential deadlocking issues. */ if (*local_chunk_array_num_entries) - if (NULL == (mod_data = (unsigned char **) H5MM_malloc(*local_chunk_array_num_entries * sizeof(unsigned char *)))) + if (NULL == (mod_data = (unsigned char **)H5MM_malloc(*local_chunk_array_num_entries * + sizeof(unsigned char *)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate modification data buffer array") for (i = 0, last_assigned_idx = 0; i < *local_chunk_array_num_entries; i++) { @@ -2841,50 +2909,54 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty if (mpi_rank != chunk_entry->owners.new_owner) { H5D_chunk_info_t *chunk_info = NULL; - unsigned char *mod_data_p = NULL; + unsigned char * mod_data_p = NULL; hsize_t iter_nelmts; size_t mod_data_size; /* Look up the chunk and get its file and memory dataspaces */ - if(NULL == (chunk_info = (H5D_chunk_info_t *) H5SL_search(fm->sel_chunks, &chunk_entry->index))) + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_entry->index))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, FAIL, "can't locate chunk in skip list") /* Determine size of serialized chunk file dataspace, plus the size of * the data being written */ - if(H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0) + if (H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to get encoded dataspace size") iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); H5_CHECK_OVERFLOW(iter_nelmts, hsize_t, size_t); - mod_data_size += (size_t) iter_nelmts * type_info->src_type_size; + mod_data_size += (size_t)iter_nelmts * type_info->src_type_size; - if(NULL == (mod_data[num_send_requests] = (unsigned char *) H5MM_malloc(mod_data_size))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk modification send buffer") + if (NULL == (mod_data[num_send_requests] = (unsigned char *)H5MM_malloc(mod_data_size))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk modification send buffer") /* Serialize the chunk's file dataspace into the buffer */ mod_data_p = mod_data[num_send_requests]; - if(H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0) + if (H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to encode dataspace") /* Initialize iterator for memory selection */ - if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") + if (H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize memory selection information") mem_iter_init = TRUE; /* Collect the modification data into the buffer */ - if(0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t)iter_nelmts, mod_data_p)) + if (0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t)iter_nelmts, mod_data_p)) HGOTO_ERROR(H5E_IO, H5E_CANTGATHER, FAIL, "couldn't gather from write buffer") /* Send modification data to new owner */ H5_CHECK_OVERFLOW(mod_data_size, size_t, int) H5_CHECK_OVERFLOW(chunk_entry->index, hsize_t, int) - if(MPI_SUCCESS != (mpi_code = MPI_Isend(mod_data[num_send_requests], (int) mod_data_size, MPI_BYTE, - chunk_entry->owners.new_owner, (int) chunk_entry->index, io_info->comm, &send_requests[num_send_requests]))) + if (MPI_SUCCESS != + (mpi_code = MPI_Isend(mod_data[num_send_requests], (int)mod_data_size, MPI_BYTE, + chunk_entry->owners.new_owner, (int)chunk_entry->index, io_info->comm, + &send_requests[num_send_requests]))) HMPI_GOTO_ERROR(FAIL, "MPI_Isend failed", mpi_code) - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release memory selection iterator") mem_iter_init = FALSE; @@ -2897,11 +2969,14 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty MPI_Status status; size_t j; - chunk_entry->async_info.num_receive_requests = (int) chunk_entry->num_writers - 1; - if (NULL == (chunk_entry->async_info.receive_requests_array = (MPI_Request *) H5MM_malloc((size_t) chunk_entry->async_info.num_receive_requests * sizeof(MPI_Request)))) + chunk_entry->async_info.num_receive_requests = (int)chunk_entry->num_writers - 1; + if (NULL == (chunk_entry->async_info.receive_requests_array = (MPI_Request *)H5MM_malloc( + (size_t)chunk_entry->async_info.num_receive_requests * sizeof(MPI_Request)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate async requests array") - if (NULL == (chunk_entry->async_info.receive_buffer_array = (unsigned char **) H5MM_malloc((size_t) chunk_entry->async_info.num_receive_requests * sizeof(unsigned char *)))) + if (NULL == + (chunk_entry->async_info.receive_buffer_array = (unsigned char **)H5MM_malloc( + (size_t)chunk_entry->async_info.num_receive_requests * sizeof(unsigned char *)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate async receive buffers") for (j = 0; j < chunk_entry->num_writers - 1; j++) { @@ -2911,35 +2986,39 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty * from the receive queue in the process and allocating that much memory * for the asynchronous receive */ - if (MPI_SUCCESS != (mpi_code = MPI_Mprobe(MPI_ANY_SOURCE, (int) chunk_entry->index, io_info->comm, &message, &status))) + if (MPI_SUCCESS != (mpi_code = MPI_Mprobe(MPI_ANY_SOURCE, (int)chunk_entry->index, + io_info->comm, &message, &status))) HMPI_GOTO_ERROR(FAIL, "MPI_Mprobe failed", mpi_code) if (MPI_SUCCESS != (mpi_code = MPI_Get_count(&status, MPI_BYTE, &count))) HMPI_GOTO_ERROR(FAIL, "MPI_Get_count failed", mpi_code) HDassert(count >= 0); - if (NULL == (chunk_entry->async_info.receive_buffer_array[j] = (unsigned char *) H5MM_malloc((size_t) count * sizeof(char *)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate modification data receive buffer") - - if (MPI_SUCCESS != (mpi_code = MPI_Imrecv(chunk_entry->async_info.receive_buffer_array[j], count, MPI_BYTE, - &message, &chunk_entry->async_info.receive_requests_array[j]))) + if (NULL == (chunk_entry->async_info.receive_buffer_array[j] = + (unsigned char *)H5MM_malloc((size_t)count * sizeof(char *)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "unable to allocate modification data receive buffer") + + if (MPI_SUCCESS != (mpi_code = MPI_Imrecv( + chunk_entry->async_info.receive_buffer_array[j], count, MPI_BYTE, + &message, &chunk_entry->async_info.receive_requests_array[j]))) HMPI_GOTO_ERROR(FAIL, "MPI_Imrecv failed", mpi_code) } /* end for */ - } /* end if */ + } /* end if */ local_chunk_array[last_assigned_idx++] = local_chunk_array[i]; } /* end else */ - } /* end for */ + } /* end for */ *local_chunk_array_num_entries = last_assigned_idx; /* Wait for all async send requests to complete before returning */ if (num_send_requests) { - if (NULL == (send_statuses = (MPI_Status *) H5MM_malloc(num_send_requests * sizeof(MPI_Status)))) + if (NULL == (send_statuses = (MPI_Status *)H5MM_malloc(num_send_requests * sizeof(MPI_Status)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate send statuses buffer") H5_CHECK_OVERFLOW(num_send_requests, size_t, int); - if (MPI_SUCCESS != (mpi_code = MPI_Waitall((int) num_send_requests, send_requests, send_statuses))) + if (MPI_SUCCESS != (mpi_code = MPI_Waitall((int)num_send_requests, send_requests, send_statuses))) HMPI_GOTO_ERROR(FAIL, "MPI_Waitall failed", mpi_code) } /* end if */ @@ -2975,7 +3054,6 @@ done: } /* end H5D__chunk_redistribute_shared_chunks() */ #endif - /*------------------------------------------------------------------------- * Function: H5D__mpio_filtered_collective_write_type * @@ -2992,14 +3070,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chunk_list, - size_t num_entries, MPI_Datatype *new_mem_type, hbool_t *mem_type_derived, - MPI_Datatype *new_file_type, hbool_t *file_type_derived) +H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chunk_list, size_t num_entries, + MPI_Datatype *new_mem_type, hbool_t *mem_type_derived, + MPI_Datatype *new_file_type, hbool_t *file_type_derived) { - MPI_Aint *write_buf_array = NULL; /* Relative displacements of filtered chunk data buffers */ + MPI_Aint *write_buf_array = NULL; /* Relative displacements of filtered chunk data buffers */ MPI_Aint *file_offset_array = NULL; /* Chunk offsets in the file */ - int *length_array = NULL; /* Filtered Chunk lengths */ - herr_t ret_value = SUCCEED; + int * length_array = NULL; /* Filtered Chunk lengths */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -3012,40 +3090,46 @@ H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chun if (num_entries > 0) { size_t i; int mpi_code; - void *base_buf; + void * base_buf; H5_CHECK_OVERFLOW(num_entries, size_t, int); /* Allocate arrays */ - if (NULL == (length_array = (int *) H5MM_malloc((size_t) num_entries * sizeof(int)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed for filtered collective write length array") - if (NULL == (write_buf_array = (MPI_Aint *) H5MM_malloc((size_t) num_entries * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed for filtered collective write buf length array") - if (NULL == (file_offset_array = (MPI_Aint *) H5MM_malloc((size_t) num_entries * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed for collective write offset array") + if (NULL == (length_array = (int *)H5MM_malloc((size_t)num_entries * sizeof(int)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for filtered collective write length array") + if (NULL == (write_buf_array = (MPI_Aint *)H5MM_malloc((size_t)num_entries * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for filtered collective write buf length array") + if (NULL == (file_offset_array = (MPI_Aint *)H5MM_malloc((size_t)num_entries * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for collective write offset array") /* Ensure the list is sorted in ascending order of offset in the file */ - HDqsort(chunk_list, num_entries, sizeof(H5D_filtered_collective_io_info_t), H5D__cmp_filtered_collective_io_info_entry); + HDqsort(chunk_list, num_entries, sizeof(H5D_filtered_collective_io_info_t), + H5D__cmp_filtered_collective_io_info_entry); base_buf = chunk_list[0].buf; for (i = 0; i < num_entries; i++) { /* Set up the offset in the file, the length of the chunk data, and the relative * displacement of the chunk data write buffer */ - file_offset_array[i] = (MPI_Aint) chunk_list[i].chunk_states.new_chunk.offset; - length_array[i] = (int) chunk_list[i].chunk_states.new_chunk.length; - write_buf_array[i] = (MPI_Aint) chunk_list[i].buf - (MPI_Aint) base_buf; + file_offset_array[i] = (MPI_Aint)chunk_list[i].chunk_states.new_chunk.offset; + length_array[i] = (int)chunk_list[i].chunk_states.new_chunk.length; + write_buf_array[i] = (MPI_Aint)chunk_list[i].buf - (MPI_Aint)base_buf; } /* end for */ /* Create memory MPI type */ - if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int) num_entries, length_array, write_buf_array, MPI_BYTE, new_mem_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)num_entries, length_array, + write_buf_array, MPI_BYTE, new_mem_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) *mem_type_derived = TRUE; if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_mem_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* Create file MPI type */ - if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int) num_entries, length_array, file_offset_array, MPI_BYTE, new_file_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)num_entries, length_array, + file_offset_array, MPI_BYTE, new_file_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) *file_type_derived = TRUE; if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_file_type))) @@ -3053,17 +3137,16 @@ H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chun } /* end if */ done: - if(write_buf_array) + if (write_buf_array) H5MM_free(write_buf_array); - if(file_offset_array) + if (file_offset_array) H5MM_free(file_offset_array); - if(length_array) + if (length_array) H5MM_free(length_array); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_filtered_collective_write_type() */ - /*------------------------------------------------------------------------- * Function: H5D__filtered_collective_chunk_entry_io * @@ -3081,27 +3164,28 @@ done: */ static herr_t H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk_entry, - const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5D_chunk_map_t *fm) + const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + const H5D_chunk_map_t *fm) { H5D_chunk_info_t *chunk_info = NULL; - H5S_sel_iter_t *mem_iter = NULL; /* Memory iterator for H5D__scatter_mem/H5D__gather_mem */ - H5S_sel_iter_t *file_iter = NULL; - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ + H5S_sel_iter_t * mem_iter = NULL; /* Memory iterator for H5D__scatter_mem/H5D__gather_mem */ + H5S_sel_iter_t * file_iter = NULL; + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ unsigned filter_mask = 0; - hsize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */ + hsize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */ hssize_t extent_npoints; hsize_t true_chunk_size; - hbool_t mem_iter_init = FALSE; + hbool_t mem_iter_init = FALSE; hbool_t file_iter_init = FALSE; size_t buf_size; size_t i; - H5S_t *dataspace = NULL; /* Other process' dataspace for the chunk */ - void *tmp_gath_buf = NULL; /* Temporary gather buffer to gather into from application buffer + H5S_t * dataspace = NULL; /* Other process' dataspace for the chunk */ + void * tmp_gath_buf = NULL; /* Temporary gather buffer to gather into from application buffer before scattering out to the chunk data buffer (when writing data), or vice versa (when reading data) */ - int mpi_code; - herr_t ret_value = SUCCEED; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -3111,18 +3195,18 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk HDassert(fm); /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + if (H5CX_get_err_detect(&err_detect) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get error detection info") - if(H5CX_get_filter_cb(&filter_cb) < 0) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") /* Look up the chunk and get its file and memory dataspaces */ - if (NULL == (chunk_info = (H5D_chunk_info_t *) H5SL_search(fm->sel_chunks, &chunk_entry->index))) + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_entry->index))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, FAIL, "can't locate chunk in skip list") if ((extent_npoints = H5S_GET_EXTENT_NPOINTS(chunk_info->fspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") - true_chunk_size = (hsize_t) extent_npoints * type_info->src_type_size; + true_chunk_size = (hsize_t)extent_npoints * type_info->src_type_size; /* If the size of the filtered chunk is larger than the number of points in the * chunk file space extent times the datatype size, allocate enough space to hold the @@ -3137,7 +3221,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk /* If this is not a full chunk overwrite or this is a read operation, the chunk must be * read from the file and unfiltered. */ - if(!chunk_entry->full_overwrite || io_info->op_type == H5D_IO_OP_READ) { + if (!chunk_entry->full_overwrite || io_info->op_type == H5D_IO_OP_READ) { H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request */ chunk_entry->chunk_states.new_chunk.length = chunk_entry->chunk_states.chunk_current.length; @@ -3147,24 +3231,25 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk * this should be refactored to use collective chunk reads - JTH */ /* Get the original state of parallel I/O transfer mode */ - if(H5CX_get_io_xfer_mode(&xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Change the xfer_mode to independent for handling the I/O */ - if(H5CX_set_io_xfer_mode(H5FD_MPIO_INDEPENDENT) < 0) + if (H5CX_set_io_xfer_mode(H5FD_MPIO_INDEPENDENT) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") - if(H5F_shared_block_read(io_info->f_sh, H5FD_MEM_DRAW, chunk_entry->chunk_states.chunk_current.offset, - chunk_entry->chunk_states.new_chunk.length, chunk_entry->buf) < 0) + if (H5F_shared_block_read(io_info->f_sh, H5FD_MEM_DRAW, + chunk_entry->chunk_states.chunk_current.offset, + chunk_entry->chunk_states.new_chunk.length, chunk_entry->buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data chunk") /* Return to the original I/O transfer mode setting */ - if(H5CX_set_io_xfer_mode(xfer_mode) < 0) + if (H5CX_set_io_xfer_mode(xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") - if(H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, H5Z_FLAG_REVERSE, - &filter_mask, err_detect, filter_cb, (size_t *)&chunk_entry->chunk_states.new_chunk.length, - &buf_size, &chunk_entry->buf) < 0) + if (H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, H5Z_FLAG_REVERSE, &filter_mask, err_detect, + filter_cb, (size_t *)&chunk_entry->chunk_states.new_chunk.length, &buf_size, + &chunk_entry->buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFILTER, FAIL, "couldn't unfilter chunk for modifying") } /* end if */ else { @@ -3172,10 +3257,10 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk } /* end else */ /* Initialize iterator for memory selection */ - if (NULL == (mem_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t)))) + if (NULL == (mem_iter = (H5S_sel_iter_t *)H5MM_malloc(sizeof(H5S_sel_iter_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate memory iterator") - if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0) + if (H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init = TRUE; @@ -3185,26 +3270,27 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk * from the current process, then apply any modifications from other processes. Finally, * filter the newly-updated chunk. */ - switch(io_info->op_type) { + switch (io_info->op_type) { case H5D_IO_OP_READ: - if(NULL == (file_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t)))) + if (NULL == (file_iter = (H5S_sel_iter_t *)H5MM_malloc(sizeof(H5S_sel_iter_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file iterator") - if(H5S_select_iter_init(file_iter, chunk_info->fspace, type_info->src_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") + if (H5S_select_iter_init(file_iter, chunk_info->fspace, type_info->src_type_size, 0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize memory selection information") file_iter_init = TRUE; iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); - if(NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) + if (NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer") - if(!H5D__gather_mem(chunk_entry->buf, file_iter, (size_t) iter_nelmts, tmp_gath_buf)) + if (!H5D__gather_mem(chunk_entry->buf, file_iter, (size_t)iter_nelmts, tmp_gath_buf)) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't gather from chunk buffer") iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); - if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0) + if (H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t)iter_nelmts, io_info->u.rbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer") break; @@ -3212,20 +3298,21 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk case H5D_IO_OP_WRITE: iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); - if(NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) + if (NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer") /* Gather modification data from the application write buffer into a temporary buffer */ - if(0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t) iter_nelmts, tmp_gath_buf)) + if (0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t)iter_nelmts, tmp_gath_buf)) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "couldn't gather from write buffer") - if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") mem_iter_init = FALSE; /* Initialize iterator for file selection */ - if(H5S_select_iter_init(mem_iter, chunk_info->fspace, type_info->dst_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") + if (H5S_select_iter_init(mem_iter, chunk_info->fspace, type_info->dst_type_size, 0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize file selection information") mem_iter_init = TRUE; iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); @@ -3233,43 +3320,45 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk /* Scatter the owner's modification data into the chunk data buffer according to * the file space. */ - if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0) + if (H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t)iter_nelmts, chunk_entry->buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to chunk data buffer") - if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") mem_iter_init = FALSE; - if(MPI_SUCCESS != (mpi_code = MPI_Waitall(chunk_entry->async_info.num_receive_requests, - chunk_entry->async_info.receive_requests_array, MPI_STATUSES_IGNORE))) + if (MPI_SUCCESS != + (mpi_code = MPI_Waitall(chunk_entry->async_info.num_receive_requests, + chunk_entry->async_info.receive_requests_array, MPI_STATUSES_IGNORE))) HMPI_GOTO_ERROR(FAIL, "MPI_Waitall failed", mpi_code) /* For each asynchronous receive call previously posted, receive the chunk modification * buffer from another rank and update the chunk data */ - for(i = 0; i < (size_t) chunk_entry->async_info.num_receive_requests; i++) { + for (i = 0; i < (size_t)chunk_entry->async_info.num_receive_requests; i++) { const unsigned char *mod_data_p; /* Decode the process' chunk file dataspace */ mod_data_p = chunk_entry->async_info.receive_buffer_array[i]; - if(NULL == (dataspace = H5S_decode(&mod_data_p))) + if (NULL == (dataspace = H5S_decode(&mod_data_p))) HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, FAIL, "unable to decode dataspace") - if(H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") + if (H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size, 0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize memory selection information") mem_iter_init = TRUE; iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace); /* Update the chunk data with the received modification data */ - if(H5D__scatter_mem(mod_data_p, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0) + if (H5D__scatter_mem(mod_data_p, mem_iter, (size_t)iter_nelmts, chunk_entry->buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't scatter to write buffer") - if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") mem_iter_init = FALSE; - if(dataspace) { - if(H5S_close(dataspace) < 0) + if (dataspace) { + if (H5S_close(dataspace) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") dataspace = NULL; } @@ -3277,14 +3366,14 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk } /* end for */ /* Filter the chunk */ - if(H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, 0, &filter_mask, - err_detect, filter_cb, (size_t *)&chunk_entry->chunk_states.new_chunk.length, - &buf_size, &chunk_entry->buf) < 0) + if (H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, 0, &filter_mask, err_detect, filter_cb, + (size_t *)&chunk_entry->chunk_states.new_chunk.length, &buf_size, + &chunk_entry->buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if (chunk_entry->chunk_states.new_chunk.length > ((size_t) 0xffffffff)) + if (chunk_entry->chunk_states.new_chunk.length > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") #endif break; @@ -3314,5 +3403,4 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__filtered_collective_chunk_entry_io() */ -#endif /* H5_HAVE_PARALLEL */ - +#endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Dnone.c b/src/H5Dnone.c index e054f08..3521457 100644 --- a/src/H5Dnone.c +++ b/src/H5Dnone.c @@ -28,51 +28,43 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Non Index chunking I/O ops */ -static herr_t H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__none_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__none_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__none_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__none_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__none_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__none_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); - +static herr_t H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__none_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__none_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__none_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__none_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__none_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); /*********************/ /* Package Variables */ @@ -80,37 +72,33 @@ static herr_t H5D__none_idx_dump(const H5O_storage_chunk_t *storage, FILE *strea /* Non Index chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_NONE[1] = {{ - FALSE, /* Non-indexed chunking don't current support SWMR access */ - NULL, /* init */ - H5D__none_idx_create, /* create */ - H5D__none_idx_is_space_alloc, /* is_space_alloc */ - NULL, /* insert */ - H5D__none_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__none_idx_iterate, /* iterate */ - H5D__none_idx_remove, /* remove */ - H5D__none_idx_delete, /* delete */ - H5D__none_idx_copy_setup, /* copy_setup */ - NULL, /* copy_shutdown */ - H5D__none_idx_size, /* size */ - H5D__none_idx_reset, /* reset */ - H5D__none_idx_dump, /* dump */ - NULL, /* dest */ - NULL /* close */ + FALSE, /* Non-indexed chunking don't current support SWMR access */ + NULL, /* init */ + H5D__none_idx_create, /* create */ + H5D__none_idx_is_space_alloc, /* is_space_alloc */ + NULL, /* insert */ + H5D__none_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__none_idx_iterate, /* iterate */ + H5D__none_idx_remove, /* remove */ + H5D__none_idx_delete, /* delete */ + H5D__none_idx_copy_setup, /* copy_setup */ + NULL, /* copy_shutdown */ + H5D__none_idx_size, /* size */ + H5D__none_idx_reset, /* reset */ + H5D__none_idx_dump, /* dump */ + NULL, /* dest */ + NULL /* close */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5D__none_idx_create * @@ -126,9 +114,9 @@ const H5D_chunk_ops_t H5D_COPS_NONE[1] = {{ static herr_t H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info) { - hsize_t nbytes; /* Total size of dataset chunks */ - haddr_t addr; /* The address of dataset chunks */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nbytes; /* Total size of dataset chunks */ + haddr_t addr; /* The address of dataset chunks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -140,15 +128,15 @@ H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->layout); HDassert(idx_info->storage); HDassert(idx_info->layout->max_nchunks); - HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); /* address of data shouldn't be defined */ + HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); /* address of data shouldn't be defined */ /* Calculate size of max dataset chunks */ nbytes = idx_info->layout->max_nchunks * idx_info->layout->size; /* Allocate space for max dataset chunks */ addr = H5MF_alloc(idx_info->f, H5FD_MEM_DRAW, nbytes); - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "file allocation failed") + if (!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "file allocation failed") /* This is the address of the dataset chunks */ idx_info->storage->idx_addr = addr; @@ -157,7 +145,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__none_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_is_space_alloc * @@ -180,7 +167,6 @@ H5D__none_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__none_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_get_addr * @@ -209,19 +195,19 @@ H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); /* Calculate the index of this chunk */ - udata->chunk_idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->common.scaled); + udata->chunk_idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->common.scaled); /* Calculate the address of the chunk */ udata->chunk_block.offset = idx_info->storage->idx_addr + udata->chunk_idx * idx_info->layout->size; /* Update the other (constant) information for the chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__none_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_iterate * @@ -235,15 +221,14 @@ H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata *------------------------------------------------------------------------- */ static int -H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5D_chunk_rec_t chunk_rec; /* generic chunk record */ - unsigned ndims; /* Rank of chunk */ - unsigned u; /* Local index variable */ - int curr_dim; /* Current rank */ - hsize_t idx; /* Array index of chunk */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_chunk_rec_t chunk_rec; /* generic chunk record */ + unsigned ndims; /* Rank of chunk */ + unsigned u; /* Local index variable */ + int curr_dim; /* Current rank */ + hsize_t idx; /* Array index of chunk */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -260,14 +245,14 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, /* Initialize generic chunk record */ HDmemset(&chunk_rec, 0, sizeof(chunk_rec)); - chunk_rec.nbytes = idx_info->layout->size; + chunk_rec.nbytes = idx_info->layout->size; chunk_rec.filter_mask = 0; ndims = idx_info->layout->ndims - 1; HDassert(ndims > 0); /* Iterate over all the chunks in the dataset's dataspace */ - for(u = 0; u < idx_info->layout->nchunks && ret_value == H5_ITER_CONT; u++) { + for (u = 0; u < idx_info->layout->nchunks && ret_value == H5_ITER_CONT; u++) { /* Calculate the index of this chunk */ idx = H5VM_array_offset_pre(ndims, idx_info->layout->max_down_chunks, chunk_rec.scaled); @@ -275,17 +260,18 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, chunk_rec.chunk_addr = idx_info->storage->idx_addr + idx * idx_info->layout->size; /* Make "generic chunk" callback */ - if((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, H5_ITER_ERROR, "failure in generic chunk iterator callback") + if ((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, H5_ITER_ERROR, + "failure in generic chunk iterator callback") /* Update coordinates of chunk in dataset */ curr_dim = (int)(ndims - 1); - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Increment coordinate in current dimension */ chunk_rec.scaled[curr_dim]++; /* Check if we went off the end of the current dimension */ - if(chunk_rec.scaled[curr_dim] >= idx_info->layout->chunks[curr_dim]) { + if (chunk_rec.scaled[curr_dim] >= idx_info->layout->chunks[curr_dim]) { /* Reset coordinate & move to next faster dimension */ chunk_rec.scaled[curr_dim] = 0; curr_dim--; @@ -293,13 +279,12 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, else break; } /* end while */ - } /* end for */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__none_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_remove * @@ -316,7 +301,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__none_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) +H5D__none_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, + H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) { FUNC_ENTER_STATIC_NOERR @@ -325,7 +311,6 @@ H5D__none_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, H5D_chun FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__none_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_delete * @@ -341,8 +326,8 @@ H5D__none_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, H5D_chun static herr_t H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info) { - hsize_t nbytes; /* Size of all chunks */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nbytes; /* Size of all chunks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -353,11 +338,11 @@ H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(!idx_info->pline->nused); /* Shouldn't have filter defined on entering here */ HDassert(idx_info->layout); HDassert(idx_info->storage); - HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); /* should be defined */ + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); /* should be defined */ /* chunk size * max # of chunks */ nbytes = idx_info->layout->max_nchunks * idx_info->layout->size; - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->storage->idx_addr, nbytes) < 0) + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->storage->idx_addr, nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free dataset chunks") idx_info->storage->idx_addr = HADDR_UNDEF; @@ -366,7 +351,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__none_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_copy_setup * @@ -380,9 +364,9 @@ done: */ static herr_t H5D__none_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) + const H5D_chk_idx_info_t * idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -406,7 +390,7 @@ H5D__none_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_inf H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Allocate dataset chunks in the dest. file */ - if(H5D__none_idx_create(idx_info_dst) < 0) + if (H5D__none_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") /* Reset metadata tag */ @@ -416,7 +400,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__none_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_size * @@ -442,7 +425,6 @@ H5D__none_idx_size(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, hsize_t *i FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__none_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_reset * @@ -463,13 +445,12 @@ H5D__none_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__none_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_dump * @@ -494,4 +475,3 @@ H5D__none_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__none_idx_dump() */ - diff --git a/src/H5Doh.c b/src/H5Doh.c index 017bab7..2c72a64 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -15,79 +15,70 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static void *H5O__dset_get_copy_file_udata(void); -static void H5O__dset_free_copy_file_udata(void *); -static htri_t H5O__dset_isa(const H5O_t *loc); -static void *H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); -static void *H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); +static void * H5O__dset_get_copy_file_udata(void); +static void H5O__dset_free_copy_file_udata(void *); +static htri_t H5O__dset_isa(const H5O_t *loc); +static void * H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); +static void * H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__dset_get_oloc(hid_t obj_id); -static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, - H5_ih_info_t *bh_info); -static herr_t H5O__dset_flush(void *_obj_ptr); - +static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); +static herr_t H5O__dset_flush(void *_obj_ptr); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_DATASET[1] = {{ - H5O_TYPE_DATASET, /* object type */ - "dataset", /* object name, for debugging */ - H5O__dset_get_copy_file_udata, /* get 'copy file' user data */ + H5O_TYPE_DATASET, /* object type */ + "dataset", /* object name, for debugging */ + H5O__dset_get_copy_file_udata, /* get 'copy file' user data */ H5O__dset_free_copy_file_udata, /* free 'copy file' user data */ - H5O__dset_isa, /* "isa" message */ - H5O__dset_open, /* open an object of this class */ - H5O__dset_create, /* create an object of this class */ - H5O__dset_get_oloc, /* get an object header location for an object */ - H5O__dset_bh_info, /* get the index & heap info for an object */ - H5O__dset_flush /* flush an opened object of this class */ + H5O__dset_isa, /* "isa" message */ + H5O__dset_open, /* open an object of this class */ + H5O__dset_create, /* create an object of this class */ + H5O__dset_get_oloc, /* get an object header location for an object */ + H5O__dset_bh_info, /* get the index & heap info for an object */ + H5O__dset_flush /* flush an opened object of this class */ }}; /* Declare a free list to manage the H5D_copy_file_ud_t struct */ H5FL_DEFINE(H5D_copy_file_ud_t); - /*------------------------------------------------------------------------- * Function: H5O__dset_get_copy_file_udata * @@ -106,19 +97,18 @@ H5FL_DEFINE(H5D_copy_file_ud_t); static void * H5O__dset_get_copy_file_udata(void) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space for the 'copy file' user data for copying datasets */ - if(NULL == (ret_value = H5FL_CALLOC(H5D_copy_file_ud_t))) + if (NULL == (ret_value = H5FL_CALLOC(H5D_copy_file_ud_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_get_copy_file_udata() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_free_copy_file_udata * @@ -143,15 +133,15 @@ H5O__dset_free_copy_file_udata(void *_udata) HDassert(udata); /* Release copy of dataset's dataspace extent, if it was set */ - if(udata->src_space_extent) + if (udata->src_space_extent) H5O_msg_free(H5O_SDSPACE_ID, udata->src_space_extent); /* Release copy of dataset's datatype, if it was set */ - if(udata->src_dtype) + if (udata->src_dtype) H5T_close_real(udata->src_dtype); /* Release copy of dataset's filter pipeline, if it was set */ - if(udata->common.src_pline) + if (udata->common.src_pline) H5O_msg_free(H5O_PLINE_ID, udata->common.src_pline); /* Release space for 'copy file' user data */ @@ -160,7 +150,6 @@ H5O__dset_free_copy_file_udata(void *_udata) FUNC_LEAVE_NOAPI_VOID } /* end H5O__dset_free_copy_file_udata() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_isa * @@ -181,30 +170,29 @@ H5O__dset_free_copy_file_udata(void *_udata) static htri_t H5O__dset_isa(const H5O_t *oh) { - htri_t exists; /* Flag if header message of interest exists */ - htri_t ret_value = TRUE; /* Return value */ + htri_t exists; /* Flag if header message of interest exists */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC HDassert(oh); /* Datatype */ - if((exists = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") - else if(!exists) + else if (!exists) HGOTO_DONE(FALSE) /* Layout */ - if((exists = H5O_msg_exists_oh(oh, H5O_SDSPACE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_SDSPACE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") - else if(!exists) + else if (!exists) HGOTO_DONE(FALSE) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_isa() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_open * @@ -221,9 +209,9 @@ done: static void * H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - H5D_t *dset = NULL; /* Dataset opened */ - hid_t dapl_id; /* dapl to use to open this dataset */ - void *ret_value = NULL; /* Return value */ + H5D_t *dset = NULL; /* Dataset opened */ + hid_t dapl_id; /* dapl to use to open this dataset */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -238,37 +226,36 @@ H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) * additional properties that DAPLs have) */ dapl_id = H5CX_get_lapl(); - if(dapl_id == H5P_LINK_ACCESS_DEFAULT) + if (dapl_id == H5P_LINK_ACCESS_DEFAULT) dapl_id = H5P_DATASET_ACCESS_DEFAULT; else { - htri_t is_lapl, is_dapl; /* Class of LAPL from API context */ + htri_t is_lapl, is_dapl; /* Class of LAPL from API context */ /* Check class of LAPL from API context */ - if((is_lapl = H5P_isa_class(dapl_id, H5P_LINK_ACCESS)) < 0) + if ((is_lapl = H5P_isa_class(dapl_id, H5P_LINK_ACCESS)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get LAPL status") - if((is_dapl = H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) < 0) + if ((is_dapl = H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get DAPL status") /* Switch to default DAPL if not an actual DAPL in the API context */ - if(!is_dapl && is_lapl) + if (!is_dapl && is_lapl) dapl_id = H5P_DATASET_ACCESS_DEFAULT; } /* end else */ /* Open the dataset */ - if(NULL == (dset = H5D_open(obj_loc, dapl_id))) + if (NULL == (dset = H5D_open(obj_loc, dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") ret_value = (void *)dset; done: - if(NULL == ret_value) - if(dset && H5D_close(dset) < 0) + if (NULL == ret_value) + if (dset && H5D_close(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_open() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_create * @@ -285,9 +272,9 @@ done: static void * H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) { - H5D_obj_create_t *crt_info = (H5D_obj_create_t *)_crt_info; /* Dataset creation parameters */ - H5D_t *dset = NULL; /* New dataset created */ - void *ret_value = NULL; /* Return value */ + H5D_obj_create_t *crt_info = (H5D_obj_create_t *)_crt_info; /* Dataset creation parameters */ + H5D_t * dset = NULL; /* New dataset created */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -297,27 +284,27 @@ H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) HDassert(obj_loc); /* Create the the dataset */ - if(NULL == (dset = H5D__create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, crt_info->dapl_id))) + if (NULL == + (dset = H5D__create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, crt_info->dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") /* Set up the new dataset's location */ - if(NULL == (obj_loc->oloc = H5D_oloc(dset))) + if (NULL == (obj_loc->oloc = H5D_oloc(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of dataset") - if(NULL == (obj_loc->path = H5D_nameof(dset))) + if (NULL == (obj_loc->path = H5D_nameof(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of dataset") /* Set the return value */ ret_value = dset; done: - if(ret_value == NULL) - if(dset && H5D_close(dset) < 0) + if (ret_value == NULL) + if (dset && H5D_close(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_create() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_get_oloc * @@ -334,24 +321,23 @@ done: static H5O_loc_t * H5O__dset_get_oloc(hid_t obj_id) { - H5D_t *dset; /* Dataset opened */ - H5O_loc_t *ret_value = NULL; /* Return value */ + H5D_t * dset; /* Dataset opened */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Get the dataset */ - if(NULL == (dset = (H5D_t *)H5VL_object(obj_id))) + if (NULL == (dset = (H5D_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* Get the dataset's object header location */ - if(NULL == (ret_value = H5D_oloc(dset))) + if (NULL == (ret_value = H5D_oloc(dset))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_get_oloc() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_bh_info * @@ -369,12 +355,12 @@ done: static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) { - H5O_layout_t layout; /* Data storage layout message */ - H5O_efl_t efl; /* External File List message */ - hbool_t layout_read = FALSE; /* Whether the layout message was read */ - hbool_t efl_read = FALSE; /* Whether the external file list message was read */ - htri_t exists; /* Flag if header message of interest exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t layout; /* Data storage layout message */ + H5O_efl_t efl; /* External File List message */ + hbool_t layout_read = FALSE; /* Whether the layout message was read */ + hbool_t efl_read = FALSE; /* Whether the external file list message was read */ + htri_t exists; /* Flag if header message of interest exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -386,57 +372,56 @@ H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) HDassert(bh_info); /* Get the layout message from the object header */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_LAYOUT_ID, &layout)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message") + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_LAYOUT_ID, &layout)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message") layout_read = TRUE; /* Check for chunked dataset storage */ - if(layout.type == H5D_CHUNKED && H5D__chunk_is_space_alloc(&layout.storage)) { + if (layout.type == H5D_CHUNKED && H5D__chunk_is_space_alloc(&layout.storage)) { /* Get size of chunk index */ - if(H5D__chunk_bh_info(loc, oh, &layout, &(bh_info->index_size)) < 0) + if (H5D__chunk_bh_info(loc, oh, &layout, &(bh_info->index_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine chunked dataset btree info") } /* end if */ - else if(layout.type == H5D_VIRTUAL - && (layout.storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF)) { + else if (layout.type == H5D_VIRTUAL && (layout.storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF)) { size_t virtual_heap_size; /* Get size of global heap object for virtual dataset */ - if(H5HG_get_obj_size(loc->file, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get global heap size for virtual dataset mapping") + if (H5HG_get_obj_size(loc->file, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't get global heap size for virtual dataset mapping") /* Return heap size */ bh_info->heap_size = (hsize_t)virtual_heap_size; } /* end if */ /* Check for External File List message in the object header */ - if((exists = H5O_msg_exists_oh(oh, H5O_EFL_ID)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for EFL message") + if ((exists = H5O_msg_exists_oh(oh, H5O_EFL_ID)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for EFL message") - if(exists && H5D__efl_is_space_alloc(&layout.storage)) { + if (exists && H5D__efl_is_space_alloc(&layout.storage)) { /* Start with clean EFL info */ HDmemset(&efl, 0, sizeof(efl)); - /* Get External File List message from the object header */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_EFL_ID, &efl)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find EFL message") + /* Get External File List message from the object header */ + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_EFL_ID, &efl)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find EFL message") efl_read = TRUE; - /* Get size of local heap for EFL message's file list */ - if(H5D__efl_bh_info(loc->file, &efl, &(bh_info->heap_size)) < 0) + /* Get size of local heap for EFL message's file list */ + if (H5D__efl_bh_info(loc->file, &efl, &(bh_info->heap_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine EFL heap info") } /* end if */ done: /* Free messages, if they've been read in */ - if(layout_read && H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) + if (layout_read && H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset data storage layout message") - if(efl_read && H5O_msg_reset(H5O_EFL_ID, &efl) < 0) + if (efl_read && H5O_msg_reset(H5O_EFL_ID, &efl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_bh_info() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_flush * @@ -453,9 +438,9 @@ done: static herr_t H5O__dset_flush(void *_obj_ptr) { - H5D_t *dset = (H5D_t *)_obj_ptr; /* Pointer to dataset object */ - H5O_type_t obj_type; /* Type of object at location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t * dset = (H5D_t *)_obj_ptr; /* Pointer to dataset object */ + H5O_type_t obj_type; /* Type of object at location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -463,15 +448,14 @@ H5O__dset_flush(void *_obj_ptr) HDassert(&dset->oloc); /* Check that the object found is the correct type */ - if(H5O_obj_type(&dset->oloc, &obj_type) < 0) + if (H5O_obj_type(&dset->oloc, &obj_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_DATASET) + if (obj_type != H5O_TYPE_DATASET) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(H5D__flush_real(dset) < 0) + if (H5D__flush_real(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_flush() */ - diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 7f2f18a..3eea03b 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -30,12 +30,12 @@ #include "H5Dprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5B2private.h" /* v2 B-trees */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5SLprivate.h" /* Skip lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5B2private.h" /* v2 B-trees */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatypes */ /**************************/ /* Package Private Macros */ @@ -45,44 +45,43 @@ #define H5D_MINHDR_SIZE 256 /* [Simple] Macro to construct a H5D_io_info_t from it's components */ -#define H5D_BUILD_IO_INFO_WRT(io_info, ds, str, buf) \ - (io_info)->dset = ds; \ - (io_info)->f_sh = H5F_SHARED((ds)->oloc.file); \ - (io_info)->store = str; \ - (io_info)->op_type = H5D_IO_OP_WRITE; \ - (io_info)->u.wbuf = buf -#define H5D_BUILD_IO_INFO_RD(io_info, ds, str, buf) \ - (io_info)->dset = ds; \ - (io_info)->f_sh = H5F_SHARED((ds)->oloc.file); \ - (io_info)->store = str; \ - (io_info)->op_type = H5D_IO_OP_READ; \ - (io_info)->u.rbuf = buf +#define H5D_BUILD_IO_INFO_WRT(io_info, ds, str, buf) \ + (io_info)->dset = ds; \ + (io_info)->f_sh = H5F_SHARED((ds)->oloc.file); \ + (io_info)->store = str; \ + (io_info)->op_type = H5D_IO_OP_WRITE; \ + (io_info)->u.wbuf = buf +#define H5D_BUILD_IO_INFO_RD(io_info, ds, str, buf) \ + (io_info)->dset = ds; \ + (io_info)->f_sh = H5F_SHARED((ds)->oloc.file); \ + (io_info)->store = str; \ + (io_info)->op_type = H5D_IO_OP_READ; \ + (io_info)->u.rbuf = buf /* Flags for marking aspects of a dataset dirty */ #define H5D_MARK_SPACE 0x01 -#define H5D_MARK_LAYOUT 0x02 +#define H5D_MARK_LAYOUT 0x02 /* Default creation parameters for chunk index data structures */ /* See H5O_layout_chunk_t */ /* Fixed array creation values */ -#define H5D_FARRAY_CREATE_PARAM_SIZE 1 /* Size of the creation parameters in bytes */ -#define H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ +#define H5D_FARRAY_CREATE_PARAM_SIZE 1 /* Size of the creation parameters in bytes */ +#define H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ /* Extensible array creation values */ -#define H5D_EARRAY_CREATE_PARAM_SIZE 5 /* Size of the creation parameters in bytes */ -#define H5D_EARRAY_MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */ +#define H5D_EARRAY_CREATE_PARAM_SIZE 5 /* Size of the creation parameters in bytes */ +#define H5D_EARRAY_MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */ #define H5D_EARRAY_IDX_BLK_ELMTS 4 #define H5D_EARRAY_SUP_BLK_MIN_DATA_PTRS 4 #define H5D_EARRAY_DATA_BLK_MIN_ELMTS 16 -#define H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ +#define H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ /* v2 B-tree creation values for raw meta_size */ -#define H5D_BT2_CREATE_PARAM_SIZE 6 /* Size of the creation parameters in bytes */ -#define H5D_BT2_NODE_SIZE 2048 -#define H5D_BT2_SPLIT_PERC 100 -#define H5D_BT2_MERGE_PERC 40 - +#define H5D_BT2_CREATE_PARAM_SIZE 6 /* Size of the creation parameters in bytes */ +#define H5D_BT2_NODE_SIZE 2048 +#define H5D_BT2_SPLIT_PERC 100 +#define H5D_BT2_MERGE_PERC 40 /****************************/ /* Package Private Typedefs */ @@ -91,25 +90,25 @@ /* Typedef for datatype information for raw data I/O operation */ typedef struct H5D_type_info_t { /* Initial values */ - const H5T_t *mem_type; /* Pointer to memory datatype */ - const H5T_t *dset_type; /* Pointer to dataset datatype */ - H5T_path_t *tpath; /* Datatype conversion path */ - hid_t src_type_id; /* Source datatype ID */ - hid_t dst_type_id; /* Destination datatype ID */ + const H5T_t *mem_type; /* Pointer to memory datatype */ + const H5T_t *dset_type; /* Pointer to dataset datatype */ + H5T_path_t * tpath; /* Datatype conversion path */ + hid_t src_type_id; /* Source datatype ID */ + hid_t dst_type_id; /* Destination datatype ID */ /* Computed/derived values */ - size_t src_type_size; /* Size of source type */ - size_t dst_type_size; /* Size of destination type */ - size_t max_type_size; /* Size of largest source/destination type */ - hbool_t is_conv_noop; /* Whether the type conversion is a NOOP */ - hbool_t is_xform_noop; /* Whether the data transform is a NOOP */ - const H5T_subset_info_t *cmpd_subset; /* Info related to the compound subset conversion functions */ - H5T_bkg_t need_bkg; /* Type of background buf needed */ - size_t request_nelmts; /* Requested strip mine */ - uint8_t *tconv_buf; /* Datatype conv buffer */ - hbool_t tconv_buf_allocated; /* Whether the type conversion buffer was allocated */ - uint8_t *bkg_buf; /* Background buffer */ - hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ + size_t src_type_size; /* Size of source type */ + size_t dst_type_size; /* Size of destination type */ + size_t max_type_size; /* Size of largest source/destination type */ + hbool_t is_conv_noop; /* Whether the type conversion is a NOOP */ + hbool_t is_xform_noop; /* Whether the data transform is a NOOP */ + const H5T_subset_info_t *cmpd_subset; /* Info related to the compound subset conversion functions */ + H5T_bkg_t need_bkg; /* Type of background buf needed */ + size_t request_nelmts; /* Requested strip mine */ + uint8_t * tconv_buf; /* Datatype conv buffer */ + hbool_t tconv_buf_allocated; /* Whether the type conversion buffer was allocated */ + uint8_t * bkg_buf; /* Background buffer */ + hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ } H5D_type_info_t; /* Forward declaration of structs used below */ @@ -119,123 +118,127 @@ typedef struct H5D_shared_t H5D_shared_t; /* Function pointers for I/O on particular types of dataset layouts */ typedef herr_t (*H5D_layout_construct_func_t)(H5F_t *f, H5D_t *dset); -typedef herr_t (*H5D_layout_init_func_t)(H5F_t *f, const H5D_t *dset, - hid_t dapl_id); +typedef herr_t (*H5D_layout_init_func_t)(H5F_t *f, const H5D_t *dset, hid_t dapl_id); typedef hbool_t (*H5D_layout_is_space_alloc_func_t)(const H5O_storage_t *storage); typedef hbool_t (*H5D_layout_is_data_cached_func_t)(const H5D_shared_t *shared_dset); typedef herr_t (*H5D_layout_io_init_func_t)(const struct H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - struct H5D_chunk_map_t *cm); -typedef herr_t (*H5D_layout_read_func_t)(struct H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, struct H5D_chunk_map_t *fm); -typedef herr_t (*H5D_layout_write_func_t)(struct H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, struct H5D_chunk_map_t *fm); -typedef ssize_t (*H5D_layout_readvv_func_t)(const struct H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); -typedef ssize_t (*H5D_layout_writevv_func_t)(const struct H5D_io_info_t *io_info, - size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); + const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, + struct H5D_chunk_map_t *cm); +typedef herr_t (*H5D_layout_read_func_t)(struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + struct H5D_chunk_map_t *fm); +typedef herr_t (*H5D_layout_write_func_t)(struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + struct H5D_chunk_map_t *fm); +typedef ssize_t (*H5D_layout_readvv_func_t)(const struct H5D_io_info_t *io_info, size_t dset_max_nseq, + size_t *dset_curr_seq, size_t dset_len_arr[], + hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_len_arr[], + hsize_t mem_offset_arr[]); +typedef ssize_t (*H5D_layout_writevv_func_t)(const struct H5D_io_info_t *io_info, size_t dset_max_nseq, + size_t *dset_curr_seq, size_t dset_len_arr[], + hsize_t dset_offset_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_len_arr[], + hsize_t mem_offset_arr[]); typedef herr_t (*H5D_layout_flush_func_t)(H5D_t *dataset); typedef herr_t (*H5D_layout_io_term_func_t)(const struct H5D_chunk_map_t *cm); typedef herr_t (*H5D_layout_dest_func_t)(H5D_t *dataset); /* Typedef for grouping layout I/O routines */ typedef struct H5D_layout_ops_t { - H5D_layout_construct_func_t construct; /* Layout constructor for new datasets */ - H5D_layout_init_func_t init; /* Layout initializer for dataset */ - H5D_layout_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage is allocated */ - H5D_layout_is_data_cached_func_t is_data_cached; /* Query routine to determine if any raw data is cached. If routine is not present then the layout type never caches raw data. */ - H5D_layout_io_init_func_t io_init; /* I/O initialization routine */ - H5D_layout_read_func_t ser_read; /* High-level I/O routine for reading data in serial */ - H5D_layout_write_func_t ser_write; /* High-level I/O routine for writing data in serial */ + H5D_layout_construct_func_t construct; /* Layout constructor for new datasets */ + H5D_layout_init_func_t init; /* Layout initializer for dataset */ + H5D_layout_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage is allocated */ + H5D_layout_is_data_cached_func_t + is_data_cached; /* Query routine to determine if any raw data is cached. If routine is not present + then the layout type never caches raw data. */ + H5D_layout_io_init_func_t io_init; /* I/O initialization routine */ + H5D_layout_read_func_t ser_read; /* High-level I/O routine for reading data in serial */ + H5D_layout_write_func_t ser_write; /* High-level I/O routine for writing data in serial */ #ifdef H5_HAVE_PARALLEL - H5D_layout_read_func_t par_read; /* High-level I/O routine for reading data in parallel */ - H5D_layout_write_func_t par_write; /* High-level I/O routine for writing data in parallel */ -#endif /* H5_HAVE_PARALLEL */ - H5D_layout_readvv_func_t readvv; /* Low-level I/O routine for reading data */ - H5D_layout_writevv_func_t writevv; /* Low-level I/O routine for writing data */ - H5D_layout_flush_func_t flush; /* Low-level I/O routine for flushing raw data */ - H5D_layout_io_term_func_t io_term; /* I/O shutdown routine */ - H5D_layout_dest_func_t dest; /* Destroy layout info */ + H5D_layout_read_func_t par_read; /* High-level I/O routine for reading data in parallel */ + H5D_layout_write_func_t par_write; /* High-level I/O routine for writing data in parallel */ +#endif /* H5_HAVE_PARALLEL */ + H5D_layout_readvv_func_t readvv; /* Low-level I/O routine for reading data */ + H5D_layout_writevv_func_t writevv; /* Low-level I/O routine for writing data */ + H5D_layout_flush_func_t flush; /* Low-level I/O routine for flushing raw data */ + H5D_layout_io_term_func_t io_term; /* I/O shutdown routine */ + H5D_layout_dest_func_t dest; /* Destroy layout info */ } H5D_layout_ops_t; /* Function pointers for either multiple or single block I/O access */ typedef herr_t (*H5D_io_single_read_func_t)(const struct H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); + const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space); typedef herr_t (*H5D_io_single_write_func_t)(const struct H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); + const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space); /* Typedef for raw data I/O framework info */ typedef struct H5D_io_ops_t { - H5D_layout_read_func_t multi_read; /* High-level I/O routine for reading data */ - H5D_layout_write_func_t multi_write; /* High-level I/O routine for writing data */ - H5D_io_single_read_func_t single_read; /* I/O routine for reading single block */ - H5D_io_single_write_func_t single_write; /* I/O routine for writing single block */ + H5D_layout_read_func_t multi_read; /* High-level I/O routine for reading data */ + H5D_layout_write_func_t multi_write; /* High-level I/O routine for writing data */ + H5D_io_single_read_func_t single_read; /* I/O routine for reading single block */ + H5D_io_single_write_func_t single_write; /* I/O routine for writing single block */ } H5D_io_ops_t; /* Typedefs for dataset storage information */ typedef struct { - haddr_t dset_addr; /* Address of dataset in file */ - hsize_t dset_size; /* Total size of dataset in file */ + haddr_t dset_addr; /* Address of dataset in file */ + hsize_t dset_size; /* Total size of dataset in file */ } H5D_contig_storage_t; typedef struct { - hsize_t *scaled; /* Scaled coordinates for a chunk */ + hsize_t *scaled; /* Scaled coordinates for a chunk */ } H5D_chunk_storage_t; typedef struct { - void *buf; /* Buffer for compact dataset */ - hbool_t *dirty; /* Pointer to dirty flag to mark */ + void * buf; /* Buffer for compact dataset */ + hbool_t *dirty; /* Pointer to dirty flag to mark */ } H5D_compact_storage_t; typedef union H5D_storage_t { - H5D_contig_storage_t contig; /* Contiguous information for dataset */ - H5D_chunk_storage_t chunk; /* Chunk information for dataset */ + H5D_contig_storage_t contig; /* Contiguous information for dataset */ + H5D_chunk_storage_t chunk; /* Chunk information for dataset */ H5D_compact_storage_t compact; /* Compact information for dataset */ - H5O_efl_t efl; /* External file list information for dataset */ + H5O_efl_t efl; /* External file list information for dataset */ } H5D_storage_t; /* Typedef for raw data I/O operation info */ typedef enum H5D_io_op_type_t { - H5D_IO_OP_READ, /* Read operation */ - H5D_IO_OP_WRITE /* Write operation */ + H5D_IO_OP_READ, /* Read operation */ + H5D_IO_OP_WRITE /* Write operation */ } H5D_io_op_type_t; typedef struct H5D_io_info_t { - const H5D_t *dset; /* Pointer to dataset being operated on */ -/* QAK: Delete the f_sh field when oloc has a shared file pointer? */ - H5F_shared_t *f_sh; /* Pointer to shared file struct that dataset is within */ + const H5D_t *dset; /* Pointer to dataset being operated on */ + /* QAK: Delete the f_sh field when oloc has a shared file pointer? */ + H5F_shared_t *f_sh; /* Pointer to shared file struct that dataset is within */ #ifdef H5_HAVE_PARALLEL - MPI_Comm comm; /* MPI communicator for file */ - hbool_t using_mpi_vfd; /* Whether the file is using an MPI-based VFD */ -#endif /* H5_HAVE_PARALLEL */ - H5D_storage_t *store; /* Dataset storage info */ - H5D_layout_ops_t layout_ops; /* Dataset layout I/O operation function pointers */ - H5D_io_ops_t io_ops; /* I/O operation function pointers */ + MPI_Comm comm; /* MPI communicator for file */ + hbool_t using_mpi_vfd; /* Whether the file is using an MPI-based VFD */ +#endif /* H5_HAVE_PARALLEL */ + H5D_storage_t * store; /* Dataset storage info */ + H5D_layout_ops_t layout_ops; /* Dataset layout I/O operation function pointers */ + H5D_io_ops_t io_ops; /* I/O operation function pointers */ H5D_io_op_type_t op_type; union { - void *rbuf; /* Pointer to buffer for read */ - const void *wbuf; /* Pointer to buffer to write */ + void * rbuf; /* Pointer to buffer for read */ + const void *wbuf; /* Pointer to buffer to write */ } u; } H5D_io_info_t; - /******************/ /* Chunk typedefs */ /******************/ /* Typedef for chunked dataset index operation info */ typedef struct H5D_chk_idx_info_t { - H5F_t *f; /* File pointer for operation */ - const H5O_pline_t *pline; /* I/O pipeline info */ - H5O_layout_chunk_t *layout; /* Chunk layout description */ - H5O_storage_chunk_t *storage; /* Chunk storage description */ + H5F_t * f; /* File pointer for operation */ + const H5O_pline_t * pline; /* I/O pipeline info */ + H5O_layout_chunk_t * layout; /* Chunk layout description */ + H5O_storage_chunk_t *storage; /* Chunk storage description */ } H5D_chk_idx_info_t; /* @@ -250,10 +253,10 @@ typedef struct H5D_chk_idx_info_t { * The chunk's file address, filter mask and size on disk are not key values. */ typedef struct H5D_chunk_rec_t { - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ - uint32_t nbytes; /* Size of stored data */ - uint32_t filter_mask; /* Excluded filters */ - haddr_t chunk_addr; /* Address of chunk in file */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ + uint32_t nbytes; /* Size of stored data */ + uint32_t filter_mask; /* Excluded filters */ + haddr_t chunk_addr; /* Address of chunk in file */ } H5D_chunk_rec_t; /* @@ -262,125 +265,122 @@ typedef struct H5D_chunk_rec_t { * to which the index points. */ typedef struct H5D_chunk_common_ud_t { - const H5O_layout_chunk_t *layout; /* Chunk layout description */ - const H5O_storage_chunk_t *storage; /* Chunk storage description */ - const hsize_t *scaled; /* Scaled coordinates for a chunk */ + const H5O_layout_chunk_t * layout; /* Chunk layout description */ + const H5O_storage_chunk_t *storage; /* Chunk storage description */ + const hsize_t * scaled; /* Scaled coordinates for a chunk */ } H5D_chunk_common_ud_t; /* B-tree callback info for various operations */ typedef struct H5D_chunk_ud_t { /* Downward */ - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ /* Upward */ - unsigned idx_hint; /* Index of chunk in cache, if present */ - H5F_block_t chunk_block; /* Offset/length of chunk in file */ - unsigned filter_mask; /* Excluded filters */ - hbool_t new_unfilt_chunk; /* Whether the chunk just became unfiltered */ - hsize_t chunk_idx; /* Chunk index for EA, FA indexing */ + unsigned idx_hint; /* Index of chunk in cache, if present */ + H5F_block_t chunk_block; /* Offset/length of chunk in file */ + unsigned filter_mask; /* Excluded filters */ + hbool_t new_unfilt_chunk; /* Whether the chunk just became unfiltered */ + hsize_t chunk_idx; /* Chunk index for EA, FA indexing */ } H5D_chunk_ud_t; /* Typedef for "generic" chunk callbacks */ -typedef int (*H5D_chunk_cb_func_t)(const H5D_chunk_rec_t *chunk_rec, - void *udata); +typedef int (*H5D_chunk_cb_func_t)(const H5D_chunk_rec_t *chunk_rec, void *udata); /* Typedefs for chunk operations */ -typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); +typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); typedef herr_t (*H5D_chunk_create_func_t)(const H5D_chk_idx_info_t *idx_info); typedef hbool_t (*H5D_chunk_is_space_alloc_func_t)(const H5O_storage_chunk_t *storage); -typedef herr_t (*H5D_chunk_insert_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -typedef herr_t (*H5D_chunk_get_addr_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); +typedef herr_t (*H5D_chunk_insert_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +typedef herr_t (*H5D_chunk_get_addr_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); typedef herr_t (*H5D_chunk_resize_func_t)(H5O_layout_chunk_t *layout); -typedef int (*H5D_chunk_iterate_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -typedef herr_t (*H5D_chunk_remove_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); +typedef int (*H5D_chunk_iterate_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +typedef herr_t (*H5D_chunk_remove_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); typedef herr_t (*H5D_chunk_delete_func_t)(const H5D_chk_idx_info_t *idx_info); typedef herr_t (*H5D_chunk_copy_setup_func_t)(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); + const H5D_chk_idx_info_t *idx_info_dst); typedef herr_t (*H5D_chunk_copy_shutdown_func_t)(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -typedef herr_t (*H5D_chunk_size_func_t)(const H5D_chk_idx_info_t *idx_info, - hsize_t *idx_size); + H5O_storage_chunk_t *storage_dst); +typedef herr_t (*H5D_chunk_size_func_t)(const H5D_chk_idx_info_t *idx_info, hsize_t *idx_size); typedef herr_t (*H5D_chunk_reset_func_t)(H5O_storage_chunk_t *storage, hbool_t reset_addr); -typedef herr_t (*H5D_chunk_dump_func_t)(const H5O_storage_chunk_t *storage, - FILE *stream); +typedef herr_t (*H5D_chunk_dump_func_t)(const H5O_storage_chunk_t *storage, FILE *stream); typedef herr_t (*H5D_chunk_close_func_t)(const H5D_chk_idx_info_t *idx_info); /* Typedef for grouping chunk I/O routines */ typedef struct H5D_chunk_ops_t { - hbool_t can_swim; /* Flag to indicate that the index supports SWMR access */ - H5D_chunk_init_func_t init; /* Routine to initialize indexing information in memory */ - H5D_chunk_create_func_t create; /* Routine to create chunk index */ - H5D_chunk_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage/index is allocated */ - H5D_chunk_insert_func_t insert; /* Routine to insert a chunk into an index */ - H5D_chunk_get_addr_func_t get_addr; /* Routine to retrieve address of chunk in file */ - H5D_chunk_resize_func_t resize; /* Routine to update chunk index info after resizing dataset */ - H5D_chunk_iterate_func_t iterate; /* Routine to iterate over chunks */ - H5D_chunk_remove_func_t remove; /* Routine to remove a chunk from an index */ - H5D_chunk_delete_func_t idx_delete; /* Routine to delete index & all chunks from file*/ + hbool_t can_swim; /* Flag to indicate that the index supports SWMR access */ + H5D_chunk_init_func_t init; /* Routine to initialize indexing information in memory */ + H5D_chunk_create_func_t create; /* Routine to create chunk index */ + H5D_chunk_is_space_alloc_func_t + is_space_alloc; /* Query routine to determine if storage/index is allocated */ + H5D_chunk_insert_func_t insert; /* Routine to insert a chunk into an index */ + H5D_chunk_get_addr_func_t get_addr; /* Routine to retrieve address of chunk in file */ + H5D_chunk_resize_func_t resize; /* Routine to update chunk index info after resizing dataset */ + H5D_chunk_iterate_func_t iterate; /* Routine to iterate over chunks */ + H5D_chunk_remove_func_t remove; /* Routine to remove a chunk from an index */ + H5D_chunk_delete_func_t idx_delete; /* Routine to delete index & all chunks from file*/ H5D_chunk_copy_setup_func_t copy_setup; /* Routine to perform any necessary setup for copying chunks */ - H5D_chunk_copy_shutdown_func_t copy_shutdown; /* Routine to perform any necessary shutdown for copying chunks */ - H5D_chunk_size_func_t size; /* Routine to get size of indexing information */ - H5D_chunk_reset_func_t reset; /* Routine to reset indexing information */ - H5D_chunk_dump_func_t dump; /* Routine to dump indexing information */ - H5D_chunk_close_func_t dest; /* Routine to destroy indexing information in memory */ - H5D_chunk_close_func_t close; /* Routine to destroy indexing information in memory */ + H5D_chunk_copy_shutdown_func_t + copy_shutdown; /* Routine to perform any necessary shutdown for copying chunks */ + H5D_chunk_size_func_t size; /* Routine to get size of indexing information */ + H5D_chunk_reset_func_t reset; /* Routine to reset indexing information */ + H5D_chunk_dump_func_t dump; /* Routine to dump indexing information */ + H5D_chunk_close_func_t dest; /* Routine to destroy indexing information in memory */ + H5D_chunk_close_func_t close; /* Routine to destroy indexing information in memory */ } H5D_chunk_ops_t; /* Structure holding information about a chunk's selection for mapping */ typedef struct H5D_chunk_info_t { - hsize_t index; /* "Index" of chunk in dataset */ - uint32_t chunk_points; /* Number of elements selected in chunk */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Scaled coordinates of chunk (in file dataset's dataspace) */ - H5S_t *fspace; /* Dataspace describing chunk & selection in it */ - hbool_t fspace_shared; /* Indicate that the file space for a chunk is shared and shouldn't be freed */ - H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ - hbool_t mspace_shared; /* Indicate that the memory space for a chunk is shared and shouldn't be freed */ + hsize_t index; /* "Index" of chunk in dataset */ + uint32_t chunk_points; /* Number of elements selected in chunk */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Scaled coordinates of chunk (in file dataset's dataspace) */ + H5S_t * fspace; /* Dataspace describing chunk & selection in it */ + hbool_t fspace_shared; /* Indicate that the file space for a chunk is shared and shouldn't be freed */ + H5S_t * mspace; /* Dataspace describing selection in memory corresponding to this chunk */ + hbool_t mspace_shared; /* Indicate that the memory space for a chunk is shared and shouldn't be freed */ } H5D_chunk_info_t; /* Main structure holding the mapping between file chunks and memory */ typedef struct H5D_chunk_map_t { - H5O_layout_t *layout; /* Dataset layout information*/ - hsize_t nelmts; /* Number of elements selected in file & memory dataspaces */ + H5O_layout_t *layout; /* Dataset layout information*/ + hsize_t nelmts; /* Number of elements selected in file & memory dataspaces */ - const H5S_t *file_space; /* Pointer to the file dataspace */ - unsigned f_ndims; /* Number of dimensions for file dataspace */ + const H5S_t *file_space; /* Pointer to the file dataspace */ + unsigned f_ndims; /* Number of dimensions for file dataspace */ - const H5S_t *mem_space; /* Pointer to the memory dataspace */ - H5S_t *mchunk_tmpl; /* Dataspace template for new memory chunks */ + const H5S_t * mem_space; /* Pointer to the memory dataspace */ + H5S_t * mchunk_tmpl; /* Dataspace template for new memory chunks */ H5S_sel_iter_t mem_iter; /* Iterator for elements in memory selection */ - unsigned m_ndims; /* Number of dimensions for memory dataspace */ - H5S_sel_type msel_type; /* Selection type in memory */ - H5S_sel_type fsel_type; /* Selection type in file */ + unsigned m_ndims; /* Number of dimensions for memory dataspace */ + H5S_sel_type msel_type; /* Selection type in memory */ + H5S_sel_type fsel_type; /* Selection type in file */ - H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ + H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ - H5S_t *single_space; /* Dataspace for single chunk */ - H5D_chunk_info_t *single_chunk_info; /* Pointer to single chunk's info */ - hbool_t use_single; /* Whether I/O is on a single element */ + H5S_t * single_space; /* Dataspace for single chunk */ + H5D_chunk_info_t *single_chunk_info; /* Pointer to single chunk's info */ + hbool_t use_single; /* Whether I/O is on a single element */ - hsize_t last_index; /* Index of last chunk operated on */ - H5D_chunk_info_t *last_chunk_info; /* Pointer to last chunk's info */ + hsize_t last_index; /* Index of last chunk operated on */ + H5D_chunk_info_t *last_chunk_info; /* Pointer to last chunk's info */ - hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in each dimension */ + hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in each dimension */ #ifdef H5_HAVE_PARALLEL - H5D_chunk_info_t **select_chunk; /* Store the information about whether this chunk is selected or not */ -#endif /* H5_HAVE_PARALLEL */ + H5D_chunk_info_t **select_chunk; /* Store the information about whether this chunk is selected or not */ +#endif /* H5_HAVE_PARALLEL */ } H5D_chunk_map_t; /* Cached information about a particular chunk */ typedef struct H5D_chunk_cached_t { - hbool_t valid; /*whether cache info is valid*/ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled offset of chunk*/ - haddr_t addr; /*file address of chunk */ - uint32_t nbytes; /*size of stored data */ - hsize_t chunk_idx; /*index of chunk in dataset */ - unsigned filter_mask; /*excluded filters */ + hbool_t valid; /*whether cache info is valid*/ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled offset of chunk*/ + haddr_t addr; /*file address of chunk */ + uint32_t nbytes; /*size of stored data */ + hsize_t chunk_idx; /*index of chunk in dataset */ + unsigned filter_mask; /*excluded filters */ } H5D_chunk_cached_t; /****************************/ @@ -389,46 +389,48 @@ typedef struct H5D_chunk_cached_t { /* List of files held open during refresh operations */ typedef struct H5D_virtual_held_file_t { - H5F_t *file; /* Pointer to file held open */ - struct H5D_virtual_held_file_t *next; /* Pointer to next node in list */ + H5F_t * file; /* Pointer to file held open */ + struct H5D_virtual_held_file_t *next; /* Pointer to next node in list */ } H5D_virtual_held_file_t; /* The raw data chunk cache */ -struct H5D_rdcc_ent_t; /* Forward declaration of struct used below */ +struct H5D_rdcc_ent_t; /* Forward declaration of struct used below */ typedef struct H5D_rdcc_t { struct { - unsigned ninits; /* Number of chunk creations */ - unsigned nhits; /* Number of cache hits */ - unsigned nmisses; /* Number of cache misses */ - unsigned nflushes; /* Number of cache flushes */ + unsigned ninits; /* Number of chunk creations */ + unsigned nhits; /* Number of cache hits */ + unsigned nmisses; /* Number of cache misses */ + unsigned nflushes; /* Number of cache flushes */ } stats; - size_t nbytes_max; /* Maximum cached raw data in bytes */ - size_t nslots; /* Number of chunk slots allocated */ - double w0; /* Chunk preemption policy */ - struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ - struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ - struct H5D_rdcc_ent_t *tmp_head; /* Head of temporary doubly linked list. Chunks on this list are not in the hash table (slot). The head entry is a sentinel (does not refer to an actual chunk). */ - size_t nbytes_used; /* Current cached raw data in bytes */ - int nused; /* Number of chunk slots in use */ - H5D_chunk_cached_t last; /* Cached copy of last chunk information */ - struct H5D_rdcc_ent_t **slot; /* Chunk slots, each points to a chunk*/ - H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ - H5S_t *single_space; /* Dataspace for single element I/O on chunks */ - H5D_chunk_info_t *single_chunk_info; /* Pointer to single chunk's info */ + size_t nbytes_max; /* Maximum cached raw data in bytes */ + size_t nslots; /* Number of chunk slots allocated */ + double w0; /* Chunk preemption policy */ + struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ + struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ + struct H5D_rdcc_ent_t + *tmp_head; /* Head of temporary doubly linked list. Chunks on this list are not in the hash table + (slot). The head entry is a sentinel (does not refer to an actual chunk). */ + size_t nbytes_used; /* Current cached raw data in bytes */ + int nused; /* Number of chunk slots in use */ + H5D_chunk_cached_t last; /* Cached copy of last chunk information */ + struct H5D_rdcc_ent_t **slot; /* Chunk slots, each points to a chunk*/ + H5SL_t * sel_chunks; /* Skip list containing information for each chunk selected */ + H5S_t * single_space; /* Dataspace for single element I/O on chunks */ + H5D_chunk_info_t * single_chunk_info; /* Pointer to single chunk's info */ /* Cached information about scaled dataspace dimensions */ - hsize_t scaled_dims[H5S_MAX_RANK]; /* The scaled dim sizes */ - hsize_t scaled_power2up[H5S_MAX_RANK]; /* The scaled dim sizes, rounded up to next power of 2 */ - unsigned scaled_encode_bits[H5S_MAX_RANK]; /* The number of bits needed to encode the scaled dim sizes */ + hsize_t scaled_dims[H5S_MAX_RANK]; /* The scaled dim sizes */ + hsize_t scaled_power2up[H5S_MAX_RANK]; /* The scaled dim sizes, rounded up to next power of 2 */ + unsigned scaled_encode_bits[H5S_MAX_RANK]; /* The number of bits needed to encode the scaled dim sizes */ } H5D_rdcc_t; /* The raw data contiguous data cache */ typedef struct H5D_rdcdc_t { - unsigned char *sieve_buf; /* Buffer to hold data sieve buffer */ - haddr_t sieve_loc; /* File location (offset) of the data sieve buffer */ - size_t sieve_size; /* Size of the data sieve buffer used (in bytes) */ - size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ - hbool_t sieve_dirty; /* Flag to indicate that the data sieve buffer is dirty */ + unsigned char *sieve_buf; /* Buffer to hold data sieve buffer */ + haddr_t sieve_loc; /* File location (offset) of the data sieve buffer */ + size_t sieve_size; /* Size of the data sieve buffer used (in bytes) */ + size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ + hbool_t sieve_dirty; /* Flag to indicate that the data sieve buffer is dirty */ } H5D_rdcdc_t; /* @@ -438,86 +440,86 @@ typedef struct H5D_rdcdc_t { * there will be two IDs and two H5D_t structs, both sharing one H5D_shared_t. */ struct H5D_shared_t { - size_t fo_count; /* Reference count */ - hbool_t closing; /* Flag to indicate dataset is closing */ - hid_t type_id; /* ID for dataset's datatype */ - H5T_t *type; /* Datatype for this dataset */ - H5S_t *space; /* Dataspace of this dataset */ - hid_t dcpl_id; /* Dataset creation property id */ - hid_t dapl_id; /* Dataset access property id */ - H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */ - H5O_layout_t layout; /* Data layout */ - hbool_t checked_filters;/* TRUE if dataset passes can_apply check */ + size_t fo_count; /* Reference count */ + hbool_t closing; /* Flag to indicate dataset is closing */ + hid_t type_id; /* ID for dataset's datatype */ + H5T_t * type; /* Datatype for this dataset */ + H5S_t * space; /* Dataspace of this dataset */ + hid_t dcpl_id; /* Dataset creation property id */ + hid_t dapl_id; /* Dataset access property id */ + H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */ + H5O_layout_t layout; /* Data layout */ + hbool_t checked_filters; /* TRUE if dataset passes can_apply check */ /* Cached dataspace info */ - unsigned ndims; /* The dataset's dataspace rank */ - hsize_t curr_dims[H5S_MAX_RANK]; /* The curr. size of dataset dimensions */ - hsize_t curr_power2up[H5S_MAX_RANK]; /* The curr. dim sizes, rounded up to next power of 2 */ - hsize_t max_dims[H5S_MAX_RANK]; /* The max. size of dataset dimensions */ + unsigned ndims; /* The dataset's dataspace rank */ + hsize_t curr_dims[H5S_MAX_RANK]; /* The curr. size of dataset dimensions */ + hsize_t curr_power2up[H5S_MAX_RANK]; /* The curr. dim sizes, rounded up to next power of 2 */ + hsize_t max_dims[H5S_MAX_RANK]; /* The max. size of dataset dimensions */ /* Buffered/cached information for types of raw data storage*/ struct { - H5D_rdcdc_t contig; /* Information about contiguous data */ - /* (Note that the "contig" cache - * information can be used by a chunked - * dataset in certain circumstances) - */ - H5D_rdcc_t chunk; /* Information about chunked data */ + H5D_rdcdc_t contig; /* Information about contiguous data */ + /* (Note that the "contig" cache + * information can be used by a chunked + * dataset in certain circumstances) + */ + H5D_rdcc_t chunk; /* Information about chunked data */ } cache; - H5D_append_flush_t append_flush; /* Append flush property information */ - char *extfile_prefix; /* expanded external file prefix */ - char *vds_prefix; /* expanded vds prefix */ + H5D_append_flush_t append_flush; /* Append flush property information */ + char * extfile_prefix; /* expanded external file prefix */ + char * vds_prefix; /* expanded vds prefix */ }; struct H5D_t { - H5O_loc_t oloc; /* Object header location */ - H5G_name_t path; /* Group hierarchy path */ - H5D_shared_t *shared; /* cached information from file */ + H5O_loc_t oloc; /* Object header location */ + H5G_name_t path; /* Group hierarchy path */ + H5D_shared_t *shared; /* cached information from file */ }; /* Enumerated type for allocating dataset's storage */ typedef enum { - H5D_ALLOC_CREATE, /* Dataset is being created */ - H5D_ALLOC_OPEN, /* Dataset is being opened */ - H5D_ALLOC_EXTEND, /* Dataset's dataspace is being extended */ - H5D_ALLOC_WRITE /* Dataset is being extended */ + H5D_ALLOC_CREATE, /* Dataset is being created */ + H5D_ALLOC_OPEN, /* Dataset is being opened */ + H5D_ALLOC_EXTEND, /* Dataset's dataspace is being extended */ + H5D_ALLOC_WRITE /* Dataset is being extended */ } H5D_time_alloc_t; - /* Typedef for dataset creation operation */ typedef struct { - hid_t type_id; /* Datatype for dataset */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t dcpl_id; /* Dataset creation property list */ - hid_t dapl_id; /* Dataset access property list */ + hid_t type_id; /* Datatype for dataset */ + const H5S_t *space; /* Dataspace for dataset */ + hid_t dcpl_id; /* Dataset creation property list */ + hid_t dapl_id; /* Dataset access property list */ } H5D_obj_create_t; /* Typedef for filling a buffer with a fill value */ typedef struct H5D_fill_buf_info_t { - H5MM_allocate_t fill_alloc_func; /* Routine to call for allocating fill buffer */ - void *fill_alloc_info; /* Extra info for allocation routine */ - H5MM_free_t fill_free_func; /* Routine to call for freeing fill buffer */ - void *fill_free_info; /* Extra info for free routine */ - H5T_path_t *fill_to_mem_tpath; /* Datatype conversion path for converting the fill value to the memory buffer */ - H5T_path_t *mem_to_dset_tpath; /* Datatype conversion path for converting the memory buffer to the dataset elements */ - const H5O_fill_t *fill; /* Pointer to fill value */ - void *fill_buf; /* Fill buffer */ - size_t fill_buf_size; /* Size of fill buffer */ - hbool_t use_caller_fill_buf; /* Whether the caller provided the fill buffer */ - void *bkg_buf; /* Background conversion buffer */ - size_t bkg_buf_size; /* Size of background buffer */ - H5T_t *mem_type; /* Pointer to memory datatype */ - const H5T_t *file_type; /* Pointer to file datatype */ - hid_t mem_tid; /* ID for memory version of disk datatype */ - hid_t file_tid; /* ID for disk datatype */ - size_t mem_elmt_size, file_elmt_size; /* Size of element in memory and on disk */ - size_t max_elmt_size; /* Max. size of memory or file datatype */ - size_t elmts_per_buf; /* # of elements that fit into a buffer */ - hbool_t has_vlen_fill_type; /* Whether the datatype for the fill value has a variable-length component */ + H5MM_allocate_t fill_alloc_func; /* Routine to call for allocating fill buffer */ + void * fill_alloc_info; /* Extra info for allocation routine */ + H5MM_free_t fill_free_func; /* Routine to call for freeing fill buffer */ + void * fill_free_info; /* Extra info for free routine */ + H5T_path_t + *fill_to_mem_tpath; /* Datatype conversion path for converting the fill value to the memory buffer */ + H5T_path_t *mem_to_dset_tpath; /* Datatype conversion path for converting the memory buffer to the dataset + elements */ + const H5O_fill_t *fill; /* Pointer to fill value */ + void * fill_buf; /* Fill buffer */ + size_t fill_buf_size; /* Size of fill buffer */ + hbool_t use_caller_fill_buf; /* Whether the caller provided the fill buffer */ + void * bkg_buf; /* Background conversion buffer */ + size_t bkg_buf_size; /* Size of background buffer */ + H5T_t * mem_type; /* Pointer to memory datatype */ + const H5T_t * file_type; /* Pointer to file datatype */ + hid_t mem_tid; /* ID for memory version of disk datatype */ + hid_t file_tid; /* ID for disk datatype */ + size_t mem_elmt_size, file_elmt_size; /* Size of element in memory and on disk */ + size_t max_elmt_size; /* Max. size of memory or file datatype */ + size_t elmts_per_buf; /* # of elements that fit into a buffer */ + hbool_t has_vlen_fill_type; /* Whether the datatype for the fill value has a variable-length component */ } H5D_fill_buf_info_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -544,167 +546,150 @@ H5_DLLVAR const H5B2_class_t H5D_BT2_FILT[1]; /* Array of versions for Layout */ H5_DLLVAR const unsigned H5O_layout_ver_bounds[H5F_LIBVER_NBOUNDS]; - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL H5D_t *H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, - hid_t dcpl_id, hid_t dapl_id); -H5_DLL H5D_t *H5D__create_named(const H5G_loc_t *loc, const char *name, - hid_t type_id, const H5S_t *space, hid_t lcpl_id, hid_t dcpl_id, - hid_t dapl_id); -H5_DLL H5D_t *H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id); -H5_DLL hid_t H5D__get_space(const H5D_t *dset); -H5_DLL hid_t H5D__get_type(const H5D_t *dset); -H5_DLL herr_t H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation); -H5_DLL herr_t H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, hbool_t full_overwrite, hsize_t old_dim[]); -H5_DLL herr_t H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size); -H5_DLL herr_t H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage_size); -H5_DLL herr_t H5D__get_num_chunks(const H5D_t *dset, const H5S_t *space, hsize_t *nchunks); -H5_DLL herr_t H5D__get_chunk_info(const H5D_t *dset, const H5S_t *space, hsize_t chk_idx, hsize_t *coord, unsigned *filter_mask, haddr_t *offset, hsize_t *size); -H5_DLL herr_t H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); +H5_DLL H5D_t *H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id); +H5_DLL H5D_t *H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, const H5S_t *space, + hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); +H5_DLL H5D_t * H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id); +H5_DLL hid_t H5D__get_space(const H5D_t *dset); +H5_DLL hid_t H5D__get_type(const H5D_t *dset); +H5_DLL herr_t H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation); +H5_DLL herr_t H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, + hbool_t full_overwrite, hsize_t old_dim[]); +H5_DLL herr_t H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size); +H5_DLL herr_t H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage_size); +H5_DLL herr_t H5D__get_num_chunks(const H5D_t *dset, const H5S_t *space, hsize_t *nchunks); +H5_DLL herr_t H5D__get_chunk_info(const H5D_t *dset, const H5S_t *space, hsize_t chk_idx, hsize_t *coord, + unsigned *filter_mask, haddr_t *offset, hsize_t *size); +H5_DLL herr_t H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *coord, unsigned *filter_mask, + haddr_t *addr, hsize_t *size); H5_DLL haddr_t H5D__get_offset(const H5D_t *dset); -H5_DLL herr_t H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, hsize_t *size); -H5_DLL herr_t H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id, hsize_t *size); -H5_DLL herr_t H5D__check_filters(H5D_t *dataset); -H5_DLL herr_t H5D__set_extent(H5D_t *dataset, const hsize_t *size); -H5_DLL herr_t H5D__flush_sieve_buf(H5D_t *dataset); -H5_DLL herr_t H5D__flush_real(H5D_t *dataset); -H5_DLL herr_t H5D__flush(H5D_t *dset, hid_t dset_id); -H5_DLL herr_t H5D__mark(const H5D_t *dataset, unsigned flags); -H5_DLL herr_t H5D__refresh(hid_t dset_id, H5D_t *dataset); +H5_DLL herr_t H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, hsize_t *size); +H5_DLL herr_t H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id, + hsize_t *size); +H5_DLL herr_t H5D__check_filters(H5D_t *dataset); +H5_DLL herr_t H5D__set_extent(H5D_t *dataset, const hsize_t *size); +H5_DLL herr_t H5D__flush_sieve_buf(H5D_t *dataset); +H5_DLL herr_t H5D__flush_real(H5D_t *dataset); +H5_DLL herr_t H5D__flush(H5D_t *dset, hid_t dset_id); +H5_DLL herr_t H5D__mark(const H5D_t *dataset, unsigned flags); +H5_DLL herr_t H5D__refresh(hid_t dset_id, H5D_t *dataset); /* To convert a dataset's chunk indexing type to v1 B-tree */ H5_DLL herr_t H5D__format_convert(H5D_t *dataset); /* Internal I/O routines */ -H5_DLL herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, void *buf/*out*/); -H5_DLL herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, const void *buf); +H5_DLL herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, + void *buf /*out*/); +H5_DLL herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, + const void *buf); /* Functions that perform direct serial I/O operations */ -H5_DLL herr_t H5D__select_read(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); -H5_DLL herr_t H5D__select_write(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); +H5_DLL herr_t H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space); +H5_DLL herr_t H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); /* Functions that perform scatter-gather serial I/O operations */ -H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, - size_t nelmts, void *_buf); -H5_DLL size_t H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, - size_t nelmts, void *_tgath_buf/*out*/); -H5_DLL herr_t H5D__scatgath_read(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); -H5_DLL herr_t H5D__scatgath_write(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); +H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_buf); +H5_DLL size_t H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, + void *_tgath_buf /*out*/); +H5_DLL herr_t H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); +H5_DLL herr_t H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); /* Functions that operate on dataset's layout information */ H5_DLL herr_t H5D__layout_set_io_ops(const H5D_t *dataset); -H5_DLL size_t H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, - hbool_t include_compact_data); +H5_DLL size_t H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data); H5_DLL herr_t H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout); -H5_DLL herr_t H5D__layout_set_latest_indexing(H5O_layout_t *layout, - const H5S_t *space, const H5D_dcpl_cache_t *dcpl_cache); -H5_DLL herr_t H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, - hid_t dapl_id); -H5_DLL herr_t H5D__layout_oh_read(H5D_t *dset, hid_t dapl_id, - H5P_genplist_t *plist); +H5_DLL herr_t H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, + const H5D_dcpl_cache_t *dcpl_cache); +H5_DLL herr_t H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id); +H5_DLL herr_t H5D__layout_oh_read(H5D_t *dset, hid_t dapl_id, H5P_genplist_t *plist); H5_DLL herr_t H5D__layout_oh_write(const H5D_t *dataset, H5O_t *oh, unsigned update_flags); /* Functions that operate on contiguous storage */ -H5_DLL herr_t H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage); +H5_DLL herr_t H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage); H5_DLL hbool_t H5D__contig_is_space_alloc(const H5O_storage_t *storage); H5_DLL hbool_t H5D__contig_is_data_cached(const H5D_shared_t *shared_dset); -H5_DLL herr_t H5D__contig_fill(const H5D_io_info_t *io_info); -H5_DLL herr_t H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *fm); -H5_DLL herr_t H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *fm); -H5_DLL herr_t H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, - H5F_t *f_dst, H5O_storage_contig_t *storage_dst, H5T_t *src_dtype, - H5O_copy_t *cpy_info); -H5_DLL herr_t H5D__contig_delete(H5F_t *f, const H5O_storage_t *store); +H5_DLL herr_t H5D__contig_fill(const H5D_io_info_t *io_info); +H5_DLL herr_t H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); +H5_DLL herr_t H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); +H5_DLL herr_t H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f_dst, + H5O_storage_contig_t *storage_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info); +H5_DLL herr_t H5D__contig_delete(H5F_t *f, const H5O_storage_t *store); /* Functions that operate on chunked dataset storage */ -H5_DLL htri_t H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, - hbool_t write_op); -H5_DLL herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/); -H5_DLL herr_t H5D__chunk_set_info(const H5D_t *dset); +H5_DLL htri_t H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_op); +H5_DLL herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/); +H5_DLL herr_t H5D__chunk_set_info(const H5D_t *dset); H5_DLL hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage); H5_DLL hbool_t H5D__chunk_is_data_cached(const H5D_shared_t *shared_dset); -H5_DLL herr_t H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, - H5D_chunk_ud_t *udata); -H5_DLL herr_t H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes); -H5_DLL herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); -H5_DLL herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk, - H5F_block_t *new_chunk, hbool_t *need_insert, const hsize_t *scaled); -H5_DLL herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]); -H5_DLL herr_t H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim); -H5_DLL herr_t H5D__chunk_set_sizes(H5D_t *dset); +H5_DLL herr_t H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udata); +H5_DLL herr_t H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes); +H5_DLL herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); +H5_DLL herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk, + H5F_block_t *new_chunk, hbool_t *need_insert, const hsize_t *scaled); +H5_DLL herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]); +H5_DLL herr_t H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim); +H5_DLL herr_t H5D__chunk_set_sizes(H5D_t *dset); #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]); #endif /* H5_HAVE_PARALLEL */ H5_DLL herr_t H5D__chunk_update_cache(H5D_t *dset); -H5_DLL herr_t H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, - H5O_layout_chunk_t *layout_src, H5F_t *f_dst, H5O_storage_chunk_t *storage_dst, - const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, - const H5O_pline_t *pline_src, H5O_copy_t *cpy_info); -H5_DLL herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, - H5O_layout_t *layout, hsize_t *btree_size); +H5_DLL herr_t H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk_t *layout_src, + H5F_t *f_dst, H5O_storage_chunk_t *storage_dst, + const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, + const H5O_pline_t *pline_src, H5O_copy_t *cpy_info); +H5_DLL herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, hsize_t *btree_size); H5_DLL herr_t H5D__chunk_dump_index(H5D_t *dset, FILE *stream); H5_DLL herr_t H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *store); H5_DLL herr_t H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy); -H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, - hsize_t *offset, uint32_t data_size, const void *buf); -H5_DLL herr_t H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, - uint32_t *filters, void *buf); +H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, + uint32_t data_size, const void *buf); +H5_DLL herr_t H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t *filters, void *buf); #ifdef H5D_CHUNK_DEBUG H5_DLL herr_t H5D__chunk_stats(const H5D_t *dset, hbool_t headers); #endif /* H5D_CHUNK_DEBUG */ /* format convert */ -H5_DLL herr_t H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx_info_t *new_idx_info); +H5_DLL herr_t H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, + H5D_chk_idx_info_t *new_idx_info); /* Functions that operate on compact dataset storage */ H5_DLL herr_t H5D__compact_fill(const H5D_t *dset); -H5_DLL herr_t H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, - H5F_t *f_dst, H5O_storage_compact_t *storage_dst, H5T_t *src_dtype, - H5O_copy_t *cpy_info); +H5_DLL herr_t H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst, + H5O_storage_compact_t *storage_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info); /* Functions that operate on virtual dataset storage */ -H5_DLL herr_t H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout); -H5_DLL herr_t H5D__virtual_copy_layout(H5O_layout_t *layout); -H5_DLL herr_t H5D__virtual_set_extent_unlim(const H5D_t *dset); -H5_DLL herr_t H5D__virtual_reset_layout(H5O_layout_t *layout); -H5_DLL herr_t H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage); -H5_DLL herr_t H5D__virtual_copy(H5F_t *f_src, H5O_layout_t *layout_dst); -H5_DLL herr_t H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); +H5_DLL herr_t H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout); +H5_DLL herr_t H5D__virtual_copy_layout(H5O_layout_t *layout); +H5_DLL herr_t H5D__virtual_set_extent_unlim(const H5D_t *dset); +H5_DLL herr_t H5D__virtual_reset_layout(H5O_layout_t *layout); +H5_DLL herr_t H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage); +H5_DLL herr_t H5D__virtual_copy(H5F_t *f_src, H5O_layout_t *layout_dst); +H5_DLL herr_t H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); H5_DLL hbool_t H5D__virtual_is_space_alloc(const H5O_storage_t *storage); -H5_DLL herr_t H5D__virtual_hold_source_dset_files(const H5D_t *dset, - H5D_virtual_held_file_t **head); -H5_DLL herr_t H5D__virtual_refresh_source_dsets(H5D_t *dset); -H5_DLL herr_t H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head); +H5_DLL herr_t H5D__virtual_hold_source_dset_files(const H5D_t *dset, H5D_virtual_held_file_t **head); +H5_DLL herr_t H5D__virtual_refresh_source_dsets(H5D_t *dset); +H5_DLL herr_t H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head); /* Functions that operate on EFL (External File List)*/ H5_DLL hbool_t H5D__efl_is_space_alloc(const H5O_storage_t *storage); -H5_DLL herr_t H5D__efl_bh_info(H5F_t *f, H5O_efl_t *efl, hsize_t *heap_size); +H5_DLL herr_t H5D__efl_bh_info(H5F_t *f, H5O_efl_t *efl, hsize_t *heap_size); /* Functions that perform fill value operations on datasets */ -H5_DLL herr_t H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, - const H5T_t *buf_type, const H5S_t *space); -H5_DLL herr_t H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, - H5MM_allocate_t alloc_func, void *alloc_info, - H5MM_free_t free_func, void *free_info, - const H5O_fill_t *fill, const H5T_t *dset_type, hid_t dset_type_id, - size_t nelmts, size_t min_buf_size); +H5_DLL herr_t H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_type, + const H5S_t *space); +H5_DLL herr_t H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, H5MM_allocate_t alloc_func, + void *alloc_info, H5MM_free_t free_func, void *free_info, const H5O_fill_t *fill, + const H5T_t *dset_type, hid_t dset_type_id, size_t nelmts, size_t min_buf_size); H5_DLL herr_t H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts); H5_DLL herr_t H5D__fill_term(H5D_fill_buf_info_t *fb_info); @@ -714,38 +699,35 @@ H5_DLL herr_t H5D__fill_term(H5D_fill_buf_info_t *fb_info); #ifndef H5Dmpio_DEBUG #define H5Dmpio_DEBUG #endif /*H5Dmpio_DEBUG*/ -#endif/*H5S_DEBUG*/ +#endif /*H5S_DEBUG*/ /* MPI-IO function to read, it will select either regular or irregular read */ -H5_DLL herr_t H5D__mpio_select_read(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); +H5_DLL herr_t H5D__mpio_select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); /* MPI-IO function to write, it will select either regular or irregular read */ -H5_DLL herr_t H5D__mpio_select_write(const H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); +H5_DLL herr_t H5D__mpio_select_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); /* MPI-IO functions to handle contiguous collective IO */ -H5_DLL herr_t H5D__contig_collective_read(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, H5D_chunk_map_t *fm); -H5_DLL herr_t H5D__contig_collective_write(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, H5D_chunk_map_t *fm); +H5_DLL herr_t H5D__contig_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t *fm); +H5_DLL herr_t H5D__contig_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t *fm); /* MPI-IO functions to handle chunked collective IO */ -H5_DLL herr_t H5D__chunk_collective_read(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, H5D_chunk_map_t *fm); -H5_DLL herr_t H5D__chunk_collective_write(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, H5D_chunk_map_t *fm); +H5_DLL herr_t H5D__chunk_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t *fm); +H5_DLL herr_t H5D__chunk_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + H5D_chunk_map_t *fm); /* MPI-IO function to check if a direct I/O transfer is possible between * memory and the file */ -H5_DLL htri_t H5D__mpio_opt_possible(const H5D_io_info_t *io_info, - const H5S_t *file_space, const H5S_t *mem_space, - const H5D_type_info_t *type_info); +H5_DLL htri_t H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, + const H5S_t *mem_space, const H5D_type_info_t *type_info); #endif /* H5_HAVE_PARALLEL */ @@ -760,4 +742,3 @@ H5_DLL herr_t H5D__current_cache_size_test(hid_t did, size_t *nbytes_used, int * #endif /* H5D_TESTING */ #endif /*_H5Dpkg_H*/ - diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 9a5277f..6a130b6 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -21,11 +21,10 @@ #include "H5Dpublic.h" /* Private headers needed by this file */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Zprivate.h" /* Data filters */ - +#include "H5FDprivate.h" /* File drivers */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Zprivate.h" /* Data filters */ /**************************/ /* Library Private Macros */ @@ -37,89 +36,90 @@ * to have any effect. */ #ifdef NDEBUG -# undef H5D_DEBUG +#undef H5D_DEBUG #endif /* ======== Dataset creation property names ======== */ -#define H5D_CRT_LAYOUT_NAME "layout" /* Storage layout */ -#define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ -#define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ -#define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ -#define H5D_CRT_MIN_DSET_HDR_SIZE_NAME "dset_oh_minimize"/* Minimize object header */ +#define H5D_CRT_LAYOUT_NAME "layout" /* Storage layout */ +#define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ +#define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ +#define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ +#define H5D_CRT_MIN_DSET_HDR_SIZE_NAME "dset_oh_minimize" /* Minimize object header */ /* ======== Dataset access property names ======== */ -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ -#define H5D_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ -#define H5D_ACS_VDS_VIEW_NAME "vds_view" /* VDS view option */ -#define H5D_ACS_VDS_PRINTF_GAP_NAME "vds_printf_gap" /* VDS printf gap size */ -#define H5D_ACS_VDS_PREFIX_NAME "vds_prefix" /* VDS file prefix */ -#define H5D_ACS_APPEND_FLUSH_NAME "append_flush" /* Append flush actions */ -#define H5D_ACS_EFILE_PREFIX_NAME "external file prefix" /* External file prefix */ +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ +#define H5D_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ +#define H5D_ACS_VDS_VIEW_NAME "vds_view" /* VDS view option */ +#define H5D_ACS_VDS_PRINTF_GAP_NAME "vds_printf_gap" /* VDS printf gap size */ +#define H5D_ACS_VDS_PREFIX_NAME "vds_prefix" /* VDS file prefix */ +#define H5D_ACS_APPEND_FLUSH_NAME "append_flush" /* Append flush actions */ +#define H5D_ACS_EFILE_PREFIX_NAME "external file prefix" /* External file prefix */ /* ======== Data transfer properties ======== */ -#define H5D_XFER_MAX_TEMP_BUF_NAME "max_temp_buf" /* Maximum temp buffer size */ -#define H5D_XFER_TCONV_BUF_NAME "tconv_buf" /* Type conversion buffer */ -#define H5D_XFER_BKGR_BUF_NAME "bkgr_buf" /* Background buffer */ -#define H5D_XFER_BKGR_BUF_TYPE_NAME "bkgr_buf_type" /* Background buffer type */ -#define H5D_XFER_BTREE_SPLIT_RATIO_NAME "btree_split_ratio" /* B-tree node splitting ratio */ -#define H5D_XFER_VLEN_ALLOC_NAME "vlen_alloc" /* Vlen allocation function */ -#define H5D_XFER_VLEN_ALLOC_INFO_NAME "vlen_alloc_info" /* Vlen allocation info */ -#define H5D_XFER_VLEN_FREE_NAME "vlen_free" /* Vlen free function */ -#define H5D_XFER_VLEN_FREE_INFO_NAME "vlen_free_info" /* Vlen free info */ -#define H5D_XFER_VFL_ID_NAME "vfl_id" /* File driver ID */ -#define H5D_XFER_VFL_INFO_NAME "vfl_info" /* File driver info */ -#define H5D_XFER_HYPER_VECTOR_SIZE_NAME "vec_size" /* Hyperslab vector size */ -#define H5D_XFER_IO_XFER_MODE_NAME "io_xfer_mode" /* I/O transfer mode */ -#define H5D_XFER_MPIO_COLLECTIVE_OPT_NAME "mpio_collective_opt" /* Optimization of MPI-IO transfer mode */ -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME "mpio_chunk_opt_hard" -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME "mpio_chunk_opt_num" -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME "mpio_chunk_opt_ratio" +#define H5D_XFER_MAX_TEMP_BUF_NAME "max_temp_buf" /* Maximum temp buffer size */ +#define H5D_XFER_TCONV_BUF_NAME "tconv_buf" /* Type conversion buffer */ +#define H5D_XFER_BKGR_BUF_NAME "bkgr_buf" /* Background buffer */ +#define H5D_XFER_BKGR_BUF_TYPE_NAME "bkgr_buf_type" /* Background buffer type */ +#define H5D_XFER_BTREE_SPLIT_RATIO_NAME "btree_split_ratio" /* B-tree node splitting ratio */ +#define H5D_XFER_VLEN_ALLOC_NAME "vlen_alloc" /* Vlen allocation function */ +#define H5D_XFER_VLEN_ALLOC_INFO_NAME "vlen_alloc_info" /* Vlen allocation info */ +#define H5D_XFER_VLEN_FREE_NAME "vlen_free" /* Vlen free function */ +#define H5D_XFER_VLEN_FREE_INFO_NAME "vlen_free_info" /* Vlen free info */ +#define H5D_XFER_VFL_ID_NAME "vfl_id" /* File driver ID */ +#define H5D_XFER_VFL_INFO_NAME "vfl_info" /* File driver info */ +#define H5D_XFER_HYPER_VECTOR_SIZE_NAME "vec_size" /* Hyperslab vector size */ +#define H5D_XFER_IO_XFER_MODE_NAME "io_xfer_mode" /* I/O transfer mode */ +#define H5D_XFER_MPIO_COLLECTIVE_OPT_NAME "mpio_collective_opt" /* Optimization of MPI-IO transfer mode */ +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME "mpio_chunk_opt_hard" +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME "mpio_chunk_opt_num" +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME "mpio_chunk_opt_ratio" #define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME "actual_chunk_opt_mode" -#define H5D_MPIO_ACTUAL_IO_MODE_NAME "actual_io_mode" -#define H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME "local_no_collective_cause" /* cause of broken collective I/O in each process */ -#define H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME "global_no_collective_cause" /* cause of broken collective I/O in all processes */ -#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ -#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ -#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ -#define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ +#define H5D_MPIO_ACTUAL_IO_MODE_NAME "actual_io_mode" +#define H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME \ + "local_no_collective_cause" /* cause of broken collective I/O in each process */ +#define H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME \ + "global_no_collective_cause" /* cause of broken collective I/O in all processes */ +#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ +#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ +#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ +#define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY /* Collective chunk instrumentation properties */ -#define H5D_XFER_COLL_CHUNK_LINK_HARD_NAME "coll_chunk_link_hard" -#define H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME "coll_chunk_multi_hard" -#define H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME "coll_chunk_link_true" -#define H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME "coll_chunk_link_false" +#define H5D_XFER_COLL_CHUNK_LINK_HARD_NAME "coll_chunk_link_hard" +#define H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME "coll_chunk_multi_hard" +#define H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME "coll_chunk_link_true" +#define H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME "coll_chunk_link_false" #define H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME "coll_chunk_multi_coll" -#define H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME "coll_chunk_multi_ind" +#define H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME "coll_chunk_multi_ind" /* Definitions for all collective chunk instrumentation properties */ -#define H5D_XFER_COLL_CHUNK_SIZE sizeof(unsigned) -#define H5D_XFER_COLL_CHUNK_DEF 1 +#define H5D_XFER_COLL_CHUNK_SIZE sizeof(unsigned) +#define H5D_XFER_COLL_CHUNK_DEF 1 /* General collective I/O instrumentation properties */ -#define H5D_XFER_COLL_RANK0_BCAST_NAME "coll_rank0_bcast" +#define H5D_XFER_COLL_RANK0_BCAST_NAME "coll_rank0_bcast" /* Definitions for general collective I/O instrumentation properties */ -#define H5D_XFER_COLL_RANK0_BCAST_SIZE sizeof(hbool_t) -#define H5D_XFER_COLL_RANK0_BCAST_DEF FALSE +#define H5D_XFER_COLL_RANK0_BCAST_SIZE sizeof(hbool_t) +#define H5D_XFER_COLL_RANK0_BCAST_DEF FALSE #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /* Default temporary buffer size */ -#define H5D_TEMP_BUF_SIZE (1024 * 1024) +#define H5D_TEMP_BUF_SIZE (1024 * 1024) /* Default I/O vector size */ -#define H5D_IO_VECTOR_SIZE 1024 +#define H5D_IO_VECTOR_SIZE 1024 /* Default VL allocation & free info */ -#define H5D_VLEN_ALLOC NULL -#define H5D_VLEN_ALLOC_INFO NULL -#define H5D_VLEN_FREE NULL -#define H5D_VLEN_FREE_INFO NULL +#define H5D_VLEN_ALLOC NULL +#define H5D_VLEN_ALLOC_INFO NULL +#define H5D_VLEN_FREE NULL +#define H5D_VLEN_FREE_INFO NULL /* Default virtual dataset list size */ #define H5D_VIRTUAL_DEF_LIST_SIZE 8 - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -129,32 +129,30 @@ typedef struct H5D_t H5D_t; /* Typedef for cached dataset creation property list information */ typedef struct H5D_dcpl_cache_t { - H5O_fill_t fill; /* Fill value info (H5D_CRT_FILL_VALUE_NAME) */ - H5O_pline_t pline; /* I/O pipeline info (H5O_CRT_PIPELINE_NAME) */ - H5O_efl_t efl; /* External file list info (H5D_CRT_EXT_FILE_LIST_NAME) */ + H5O_fill_t fill; /* Fill value info (H5D_CRT_FILL_VALUE_NAME) */ + H5O_pline_t pline; /* I/O pipeline info (H5O_CRT_PIPELINE_NAME) */ + H5O_efl_t efl; /* External file list info (H5D_CRT_EXT_FILE_LIST_NAME) */ } H5D_dcpl_cache_t; /* Callback information for copying datasets */ typedef struct H5D_copy_file_ud_t { - H5O_copy_file_ud_common_t common; /* Shared information (must be first) */ - struct H5S_extent_t *src_space_extent; /* Copy of dataspace extent for dataset */ - H5T_t *src_dtype; /* Copy of datatype for dataset */ + H5O_copy_file_ud_common_t common; /* Shared information (must be first) */ + struct H5S_extent_t * src_space_extent; /* Copy of dataspace extent for dataset */ + H5T_t * src_dtype; /* Copy of datatype for dataset */ } H5D_copy_file_ud_t; /* Structure for dataset append flush property (H5Pset_append_flush) */ typedef struct H5D_append_flush_t { - unsigned ndims; /* The # of dimensions for "boundary" */ - hsize_t boundary[H5S_MAX_RANK]; /* The dimension sizes for determining boundary */ - H5D_append_cb_t func; /* The callback function */ - void *udata; /* User data */ + unsigned ndims; /* The # of dimensions for "boundary" */ + hsize_t boundary[H5S_MAX_RANK]; /* The dimension sizes for determining boundary */ + H5D_append_cb_t func; /* The callback function */ + void * udata; /* User data */ } H5D_append_flush_t; - /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ @@ -166,28 +164,26 @@ H5_DLL herr_t H5D_mult_refresh_close(hid_t dset_id); H5_DLL herr_t H5D_mult_refresh_reopen(H5D_t *dataset); H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset); H5_DLL H5G_name_t *H5D_nameof(const H5D_t *dataset); -H5_DLL herr_t H5D_flush_all(H5F_t *f); -H5_DLL hid_t H5D_get_create_plist(const H5D_t *dset); -H5_DLL hid_t H5D_get_access_plist(const H5D_t *dset); +H5_DLL herr_t H5D_flush_all(H5F_t *f); +H5_DLL hid_t H5D_get_create_plist(const H5D_t *dset); +H5_DLL hid_t H5D_get_access_plist(const H5D_t *dset); /* Functions that operate on chunked storage */ H5_DLL herr_t H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); /* Functions that operate on virtual storage */ -H5_DLL herr_t H5D_virtual_check_mapping_pre(const H5S_t *vspace, - const H5S_t *src_space, H5O_virtual_space_status_t space_status); -H5_DLL herr_t H5D_virtual_check_mapping_post( - const H5O_storage_virtual_ent_t *ent); +H5_DLL herr_t H5D_virtual_check_mapping_pre(const H5S_t *vspace, const H5S_t *src_space, + H5O_virtual_space_status_t space_status); +H5_DLL herr_t H5D_virtual_check_mapping_post(const H5O_storage_virtual_ent_t *ent); H5_DLL herr_t H5D_virtual_check_min_dims(const H5D_t *dset); H5_DLL herr_t H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx); -H5_DLL herr_t H5D_virtual_parse_source_name(const char *source_name, - H5O_storage_virtual_name_seg_t **parsed_name, size_t *static_strlen, - size_t *nsubs); +H5_DLL herr_t H5D_virtual_parse_source_name(const char * source_name, + H5O_storage_virtual_name_seg_t **parsed_name, + size_t *static_strlen, size_t *nsubs); H5_DLL herr_t H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg); /* Functions that operate on indexed storage */ -H5_DLL herr_t H5D_btree_debug(H5F_t *f, haddr_t addr, FILE * stream, - int indent, int fwidth, unsigned ndims, const uint32_t *dim); +H5_DLL herr_t H5D_btree_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, unsigned ndims, + const uint32_t *dim); #endif /* _H5Dprivate_H */ - diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index b6ec06d..6a85a95 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -28,12 +28,12 @@ /*****************/ /* Macros used to "unset" chunk cache configuration parameters */ -#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT ((size_t) -1) -#define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t) -1) -#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0f) +#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT ((size_t)-1) +#define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t)-1) +#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0f) /* Bit flags for the H5Pset_chunk_opts() and H5Pget_chunk_opts() */ -#define H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS (0x0002u) +#define H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS (0x0002u) /*******************/ /* Public Typedefs */ @@ -41,82 +41,80 @@ /* Values for the H5D_LAYOUT property */ typedef enum H5D_layout_t { - H5D_LAYOUT_ERROR = -1, + H5D_LAYOUT_ERROR = -1, - H5D_COMPACT = 0, /*raw data is very small */ - H5D_CONTIGUOUS = 1, /*the default */ - H5D_CHUNKED = 2, /*slow and fancy */ - H5D_VIRTUAL = 3, /*actual data is stored in other datasets */ - H5D_NLAYOUTS = 4 /*this one must be last! */ + H5D_COMPACT = 0, /*raw data is very small */ + H5D_CONTIGUOUS = 1, /*the default */ + H5D_CHUNKED = 2, /*slow and fancy */ + H5D_VIRTUAL = 3, /*actual data is stored in other datasets */ + H5D_NLAYOUTS = 4 /*this one must be last! */ } H5D_layout_t; /* Types of chunk index data structures */ typedef enum H5D_chunk_index_t { - H5D_CHUNK_IDX_BTREE = 0, /* v1 B-tree index (default) */ - H5D_CHUNK_IDX_SINGLE = 1, /* Single Chunk index (cur dims[]=max dims[]=chunk dims[]; filtered & non-filtered) */ - H5D_CHUNK_IDX_NONE = 2, /* Implicit: No Index (H5D_ALLOC_TIME_EARLY, non-filtered, fixed dims) */ - H5D_CHUNK_IDX_FARRAY = 3, /* Fixed array (for 0 unlimited dims) */ - H5D_CHUNK_IDX_EARRAY = 4, /* Extensible array (for 1 unlimited dim) */ - H5D_CHUNK_IDX_BT2 = 5, /* v2 B-tree index (for >1 unlimited dims) */ - H5D_CHUNK_IDX_NTYPES /* This one must be last! */ + H5D_CHUNK_IDX_BTREE = 0, /* v1 B-tree index (default) */ + H5D_CHUNK_IDX_SINGLE = + 1, /* Single Chunk index (cur dims[]=max dims[]=chunk dims[]; filtered & non-filtered) */ + H5D_CHUNK_IDX_NONE = 2, /* Implicit: No Index (H5D_ALLOC_TIME_EARLY, non-filtered, fixed dims) */ + H5D_CHUNK_IDX_FARRAY = 3, /* Fixed array (for 0 unlimited dims) */ + H5D_CHUNK_IDX_EARRAY = 4, /* Extensible array (for 1 unlimited dim) */ + H5D_CHUNK_IDX_BT2 = 5, /* v2 B-tree index (for >1 unlimited dims) */ + H5D_CHUNK_IDX_NTYPES /* This one must be last! */ } H5D_chunk_index_t; /* Values for the space allocation time property */ typedef enum H5D_alloc_time_t { - H5D_ALLOC_TIME_ERROR = -1, - H5D_ALLOC_TIME_DEFAULT = 0, - H5D_ALLOC_TIME_EARLY = 1, - H5D_ALLOC_TIME_LATE = 2, - H5D_ALLOC_TIME_INCR = 3 + H5D_ALLOC_TIME_ERROR = -1, + H5D_ALLOC_TIME_DEFAULT = 0, + H5D_ALLOC_TIME_EARLY = 1, + H5D_ALLOC_TIME_LATE = 2, + H5D_ALLOC_TIME_INCR = 3 } H5D_alloc_time_t; /* Values for the status of space allocation */ typedef enum H5D_space_status_t { - H5D_SPACE_STATUS_ERROR = -1, - H5D_SPACE_STATUS_NOT_ALLOCATED = 0, - H5D_SPACE_STATUS_PART_ALLOCATED = 1, - H5D_SPACE_STATUS_ALLOCATED = 2 + H5D_SPACE_STATUS_ERROR = -1, + H5D_SPACE_STATUS_NOT_ALLOCATED = 0, + H5D_SPACE_STATUS_PART_ALLOCATED = 1, + H5D_SPACE_STATUS_ALLOCATED = 2 } H5D_space_status_t; /* Values for time of writing fill value property */ typedef enum H5D_fill_time_t { - H5D_FILL_TIME_ERROR = -1, + H5D_FILL_TIME_ERROR = -1, H5D_FILL_TIME_ALLOC = 0, - H5D_FILL_TIME_NEVER = 1, - H5D_FILL_TIME_IFSET = 2 + H5D_FILL_TIME_NEVER = 1, + H5D_FILL_TIME_IFSET = 2 } H5D_fill_time_t; /* Values for fill value status */ typedef enum H5D_fill_value_t { - H5D_FILL_VALUE_ERROR =-1, - H5D_FILL_VALUE_UNDEFINED =0, - H5D_FILL_VALUE_DEFAULT =1, - H5D_FILL_VALUE_USER_DEFINED =2 + H5D_FILL_VALUE_ERROR = -1, + H5D_FILL_VALUE_UNDEFINED = 0, + H5D_FILL_VALUE_DEFAULT = 1, + H5D_FILL_VALUE_USER_DEFINED = 2 } H5D_fill_value_t; /* Values for VDS bounds option */ typedef enum H5D_vds_view_t { - H5D_VDS_ERROR = -1, - H5D_VDS_FIRST_MISSING = 0, - H5D_VDS_LAST_AVAILABLE = 1 + H5D_VDS_ERROR = -1, + H5D_VDS_FIRST_MISSING = 0, + H5D_VDS_LAST_AVAILABLE = 1 } H5D_vds_view_t; /* Callback for H5Pset_append_flush() in a dataset access property list */ typedef herr_t (*H5D_append_cb_t)(hid_t dataset_id, hsize_t *cur_dims, void *op_data); /* Define the operator function pointer for H5Diterate() */ -typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim, - const hsize_t *point, void *operator_data); +typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *operator_data); /* Define the operator function pointer for H5Dscatter() */ -typedef herr_t (*H5D_scatter_func_t)(const void **src_buf/*out*/, - size_t *src_buf_bytes_used/*out*/, +typedef herr_t (*H5D_scatter_func_t)(const void **src_buf /*out*/, size_t *src_buf_bytes_used /*out*/, void *op_data); /* Define the operator function pointer for H5Dgather() */ -typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, - size_t dst_buf_bytes_used, void *op_data); - +typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, size_t dst_buf_bytes_used, void *op_data); /********************/ /* Public Variables */ @@ -129,44 +127,43 @@ typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, extern "C" { #endif -H5_DLL hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, - hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); -H5_DLL hid_t H5Dcreate_anon(hid_t file_id, hid_t type_id, hid_t space_id, - hid_t plist_id, hid_t dapl_id); -H5_DLL hid_t H5Dopen2(hid_t file_id, const char *name, hid_t dapl_id); -H5_DLL herr_t H5Dclose(hid_t dset_id); -H5_DLL hid_t H5Dget_space(hid_t dset_id); -H5_DLL herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation); -H5_DLL hid_t H5Dget_type(hid_t dset_id); -H5_DLL hid_t H5Dget_create_plist(hid_t dset_id); -H5_DLL hid_t H5Dget_access_plist(hid_t dset_id); +H5_DLL hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, + hid_t dcpl_id, hid_t dapl_id); +H5_DLL hid_t H5Dcreate_anon(hid_t file_id, hid_t type_id, hid_t space_id, hid_t plist_id, hid_t dapl_id); +H5_DLL hid_t H5Dopen2(hid_t file_id, const char *name, hid_t dapl_id); +H5_DLL herr_t H5Dclose(hid_t dset_id); +H5_DLL hid_t H5Dget_space(hid_t dset_id); +H5_DLL herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation); +H5_DLL hid_t H5Dget_type(hid_t dset_id); +H5_DLL hid_t H5Dget_create_plist(hid_t dset_id); +H5_DLL hid_t H5Dget_access_plist(hid_t dset_id); H5_DLL hsize_t H5Dget_storage_size(hid_t dset_id); -H5_DLL herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes); -H5_DLL herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks); -H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); -H5_DLL herr_t H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_idx, hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); +H5_DLL herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes); +H5_DLL herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks); +H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *coord, unsigned *filter_mask, + haddr_t *addr, hsize_t *size); +H5_DLL herr_t H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_idx, hsize_t *coord, + unsigned *filter_mask, haddr_t *addr, hsize_t *size); H5_DLL haddr_t H5Dget_offset(hid_t dset_id); -H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, void *buf/*out*/); -H5_DLL herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, const void *buf); -H5_DLL herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, - const hsize_t *offset, size_t data_size, const void *buf); -H5_DLL herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, - const hsize_t *offset, uint32_t *filters, void *buf); -H5_DLL herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id, - H5D_operator_t op, void *operator_data); -H5_DLL herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size); -H5_DLL herr_t H5Dfill(const void *fill, hid_t fill_type, void *buf, - hid_t buf_type, hid_t space); -H5_DLL herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]); -H5_DLL herr_t H5Dflush(hid_t dset_id); -H5_DLL herr_t H5Drefresh(hid_t dset_id); -H5_DLL herr_t H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, - hid_t dst_space_id, void *dst_buf); -H5_DLL herr_t H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, - size_t dst_buf_size, void *dst_buf, H5D_gather_func_t op, void *op_data); -H5_DLL herr_t H5Ddebug(hid_t dset_id); +H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t plist_id, void *buf /*out*/); +H5_DLL herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t plist_id, const void *buf); +H5_DLL herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, + size_t data_size, const void *buf); +H5_DLL herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, + void *buf); +H5_DLL herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, void *operator_data); +H5_DLL herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size); +H5_DLL herr_t H5Dfill(const void *fill, hid_t fill_type, void *buf, hid_t buf_type, hid_t space); +H5_DLL herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]); +H5_DLL herr_t H5Dflush(hid_t dset_id); +H5_DLL herr_t H5Drefresh(hid_t dset_id); +H5_DLL herr_t H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_id, + void *dst_buf); +H5_DLL herr_t H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf_size, + void *dst_buf, H5D_gather_func_t op, void *op_data); +H5_DLL herr_t H5Ddebug(hid_t dset_id); /* Internal API routines */ H5_DLL herr_t H5Dformat_convert(hid_t dset_id); @@ -185,22 +182,20 @@ H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); * These symbols are no longer used in the library. */ /* Property names for H5DOwrite_chunk */ -#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME "direct_chunk_flag" -#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME "direct_chunk_filters" -#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME "direct_chunk_offset" -#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME "direct_chunk_datasize" +#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME "direct_chunk_flag" +#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME "direct_chunk_filters" +#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME "direct_chunk_offset" +#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME "direct_chunk_datasize" /* Property names for H5DOread_chunk */ -#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME "direct_chunk_read_flag" -#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME "direct_chunk_read_offset" -#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME "direct_chunk_read_filters" +#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME "direct_chunk_read_flag" +#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME "direct_chunk_read_offset" +#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME "direct_chunk_read_filters" /* Typedefs */ - /* Function prototypes */ -H5_DLL hid_t H5Dcreate1(hid_t file_id, const char *name, hid_t type_id, - hid_t space_id, hid_t dcpl_id); -H5_DLL hid_t H5Dopen1(hid_t file_id, const char *name); +H5_DLL hid_t H5Dcreate1(hid_t file_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id); +H5_DLL hid_t H5Dopen1(hid_t file_id, const char *name); H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t size[]); H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf); @@ -210,4 +205,3 @@ H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, voi } #endif #endif /* _H5Dpublic_H */ - diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index cdf9da2..75047f6 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -15,48 +15,42 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5D__scatter_file(const H5D_io_info_t *io_info, - H5S_sel_iter_t *file_iter, size_t nelmts, const void *buf); -static size_t H5D__gather_file(const H5D_io_info_t *io_info, - H5S_sel_iter_t *file_iter, size_t nelmts, void *buf); -static herr_t H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, - const H5D_type_info_t *type_info, void *user_buf/*out*/); +static herr_t H5D__scatter_file(const H5D_io_info_t *io_info, H5S_sel_iter_t *file_iter, size_t nelmts, + const void *buf); +static size_t H5D__gather_file(const H5D_io_info_t *io_info, H5S_sel_iter_t *file_iter, size_t nelmts, + void *buf); +static herr_t H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, const H5D_type_info_t *type_info, + void *user_buf /*out*/); static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info); - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ @@ -70,8 +64,6 @@ H5FL_SEQ_EXTERN(size_t); /* Declare extern free list to manage sequences of hsize_t */ H5FL_SEQ_EXTERN(hsize_t); - - /*------------------------------------------------------------------------- * Function: H5D__scatter_file * @@ -89,21 +81,20 @@ H5FL_SEQ_EXTERN(hsize_t); *------------------------------------------------------------------------- */ static herr_t -H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, - size_t nelmts, const void *_buf) +H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, size_t nelmts, const void *_buf) { - H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ - hsize_t *off = NULL; /* Pointer to sequence offsets */ - hsize_t mem_off; /* Offset in memory */ - size_t mem_curr_seq; /* "Current sequence" in memory */ - size_t dset_curr_seq; /* "Current sequence" in dataset */ - size_t *len = NULL; /* Array to store sequence lengths */ - size_t orig_mem_len, mem_len; /* Length of sequence in memory */ - size_t nseq; /* Number of sequences generated */ - size_t nelem; /* Number of elements used in sequences */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ + hsize_t * off = NULL; /* Pointer to sequence offsets */ + hsize_t mem_off; /* Offset in memory */ + size_t mem_curr_seq; /* "Current sequence" in memory */ + size_t dset_curr_seq; /* "Current sequence" in dataset */ + size_t * len = NULL; /* Array to store sequence lengths */ + size_t orig_mem_len, mem_len; /* Length of sequence in memory */ + size_t nseq; /* Number of sequences generated */ + size_t nelem; /* Number of elements used in sequences */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -116,36 +107,36 @@ H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, /* Set up temporary I/O info object */ H5MM_memcpy(&tmp_io_info, _io_info, sizeof(*_io_info)); tmp_io_info.op_type = H5D_IO_OP_WRITE; - tmp_io_info.u.wbuf = _buf; + tmp_io_info.u.wbuf = _buf; /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") /* Loop until all elements are written */ - while(nelmts > 0) { + while (nelmts > 0) { /* Get list of sequences for selection to write */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Reset the current sequence information */ mem_curr_seq = dset_curr_seq = 0; orig_mem_len = mem_len = nelem * iter->elmt_size; - mem_off = 0; + mem_off = 0; /* Write sequence list out */ - if((*tmp_io_info.layout_ops.writevv)(&tmp_io_info, nseq, &dset_curr_seq, - len, off, (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0) + if ((*tmp_io_info.layout_ops.writevv)(&tmp_io_info, nseq, &dset_curr_seq, len, off, (size_t)1, + &mem_curr_seq, &mem_len, &mem_off) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") /* Update buffer */ @@ -157,15 +148,14 @@ H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__scatter_file() */ - /*------------------------------------------------------------------------- * Function: H5D__gather_file * @@ -188,21 +178,20 @@ done: *------------------------------------------------------------------------- */ static size_t -H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, - size_t nelmts, void *_buf/*out*/) +H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, size_t nelmts, void *_buf /*out*/) { - H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ - hsize_t *off = NULL; /* Pointer to sequence offsets */ - hsize_t mem_off; /* Offset in memory */ - size_t mem_curr_seq; /* "Current sequence" in memory */ - size_t dset_curr_seq; /* "Current sequence" in dataset */ - size_t *len = NULL; /* Pointer to sequence lengths */ - size_t orig_mem_len, mem_len; /* Length of sequence in memory */ - size_t nseq; /* Number of sequences generated */ - size_t nelem; /* Number of elements used in sequences */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - size_t ret_value = nelmts; /* Return value */ + H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ + hsize_t * off = NULL; /* Pointer to sequence offsets */ + hsize_t mem_off; /* Offset in memory */ + size_t mem_curr_seq; /* "Current sequence" in memory */ + size_t dset_curr_seq; /* "Current sequence" in dataset */ + size_t * len = NULL; /* Pointer to sequence lengths */ + size_t orig_mem_len, mem_len; /* Length of sequence in memory */ + size_t nseq; /* Number of sequences generated */ + size_t nelem; /* Number of elements used in sequences */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + size_t ret_value = nelmts; /* Return value */ FUNC_ENTER_STATIC @@ -217,36 +206,36 @@ H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, /* Set up temporary I/O info object */ H5MM_memcpy(&tmp_io_info, _io_info, sizeof(*_io_info)); tmp_io_info.op_type = H5D_IO_OP_READ; - tmp_io_info.u.rbuf = _buf; + tmp_io_info.u.rbuf = _buf; /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O offset vector array") /* Loop until all elements are read */ - while(nelmts > 0) { + while (nelmts > 0) { /* Get list of sequences for selection to read */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") /* Reset the current sequence information */ mem_curr_seq = dset_curr_seq = 0; orig_mem_len = mem_len = nelem * iter->elmt_size; - mem_off = 0; + mem_off = 0; /* Read sequence list in */ - if((*tmp_io_info.layout_ops.readvv)(&tmp_io_info, nseq, &dset_curr_seq, - len, off, (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0) + if ((*tmp_io_info.layout_ops.readvv)(&tmp_io_info, nseq, &dset_curr_seq, len, off, (size_t)1, + &mem_curr_seq, &mem_len, &mem_off) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error") /* Update buffer */ @@ -258,15 +247,14 @@ H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__gather_file() */ - /*------------------------------------------------------------------------- * Function: H5D__scatter_mem * @@ -283,20 +271,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, - void *_buf/*out*/) +H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_buf /*out*/) { - uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */ + uint8_t * buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */ const uint8_t *tscat_buf = (const uint8_t *)_tscat_buf; - hsize_t *off = NULL; /* Pointer to sequence offsets */ - size_t *len = NULL; /* Pointer to sequence lengths */ - size_t curr_len; /* Length of bytes left to process in sequence */ - size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequence being processed */ - size_t nelem; /* Number of elements used in sequences */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - herr_t ret_value = SUCCEED; /* Number of elements scattered */ + hsize_t * off = NULL; /* Pointer to sequence offsets */ + size_t * len = NULL; /* Pointer to sequence lengths */ + size_t curr_len; /* Length of bytes left to process in sequence */ + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequence being processed */ + size_t nelem; /* Number of elements used in sequences */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + herr_t ret_value = SUCCEED; /* Number of elements scattered */ FUNC_ENTER_PACKAGE @@ -307,27 +294,27 @@ H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, HDassert(buf); /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") /* Loop until all elements are written */ - while(nelmts > 0) { + while (nelmts > 0) { /* Get list of sequences for selection to write */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) - HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { /* Get the number of bytes in sequence */ curr_len = len[curr_seq]; @@ -343,15 +330,14 @@ H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__scatter_mem() */ +} /* H5D__scatter_mem() */ - /*------------------------------------------------------------------------- * Function: H5D__gather_mem * @@ -370,20 +356,19 @@ done: *------------------------------------------------------------------------- */ size_t -H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, - void *_tgath_buf/*out*/) +H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf /*out*/) { - const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */ - uint8_t *tgath_buf = (uint8_t *)_tgath_buf; - hsize_t *off = NULL; /* Pointer to sequence offsets */ - size_t *len = NULL; /* Pointer to sequence lengths */ - size_t curr_len; /* Length of bytes left to process in sequence */ - size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequence being processed */ - size_t nelem; /* Number of elements used in sequences */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - size_t ret_value = nelmts; /* Number of elements gathered */ + const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */ + uint8_t * tgath_buf = (uint8_t *)_tgath_buf; + hsize_t * off = NULL; /* Pointer to sequence offsets */ + size_t * len = NULL; /* Pointer to sequence lengths */ + size_t curr_len; /* Length of bytes left to process in sequence */ + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequence being processed */ + size_t nelem; /* Number of elements used in sequences */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + size_t ret_value = nelmts; /* Number of elements gathered */ FUNC_ENTER_STATIC @@ -394,27 +379,27 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, HDassert(tgath_buf); /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O offset vector array") /* Loop until all elements are written */ - while(nelmts > 0) { + while (nelmts > 0) { /* Get list of sequences for selection to write */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) - HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { /* Get the number of bytes in sequence */ curr_len = len[curr_seq]; @@ -430,15 +415,14 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__gather_mem() */ +} /* H5D__gather_mem() */ - /*------------------------------------------------------------------------- * Function: H5D__scatgath_read * @@ -452,19 +436,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space) +H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space) { - void *buf = io_info->u.rbuf; /* Local pointer to application buffer */ - H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/ - hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ - H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/ - hbool_t bkg_iter_init = FALSE; /* Background iteration info has been initialized */ - H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info*/ - hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */ - hsize_t smine_start; /* Strip mine start loc */ - size_t smine_nelmts; /* Elements per strip */ - herr_t ret_value = SUCCEED; /* Return value */ + void * buf = io_info->u.rbuf; /* Local pointer to application buffer */ + H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/ + hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ + H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/ + hbool_t bkg_iter_init = FALSE; /* Background iteration info has been initialized */ + H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info*/ + hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */ + hsize_t smine_start; /* Strip mine start loc */ + size_t smine_nelmts; /* Elements per strip */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -476,31 +460,32 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HDassert(buf); /* Check for NOOP read */ - if(nelmts == 0) + if (nelmts == 0) HGOTO_DONE(SUCCEED) /* Allocate the iterators */ - if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator") - if(NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate background iterator") - if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") /* Figure out the strip mine size. */ - if(H5S_select_iter_init(file_iter, file_space, type_info->src_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) + if (H5S_select_iter_init(file_iter, file_space, type_info->src_type_size, + H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") - file_iter_init = TRUE; /*file selection iteration info has been initialized */ - if(H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size, 0) < 0) + file_iter_init = TRUE; /*file selection iteration info has been initialized */ + if (H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") - mem_iter_init = TRUE; /*file selection iteration info has been initialized */ - if(H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size, 0) < 0) + mem_iter_init = TRUE; /*file selection iteration info has been initialized */ + if (H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") - bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ + bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ /* Start strip mining... */ - for(smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) { - size_t n; /* Elements operated on */ + for (smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) { + size_t n; /* Elements operated on */ /* Go figure out how many elements to read from the file */ HDassert(H5S_SELECT_ITER_NELMTS(file_iter) == (nelmts - smine_start)); @@ -512,73 +497,72 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf * if necessary. */ - /* + /* * Gather data */ - n = H5D__gather_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf/*out*/); - if(n != smine_nelmts) + n = H5D__gather_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf /*out*/); + if (n != smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") /* If the source and destination are compound types and subset of each other * and no conversion is needed, copy the data directly into user's buffer and * bypass the rest of steps. */ - if(type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) { - if(H5D__compound_opt_read(smine_nelmts, mem_iter, type_info, buf /*out*/) < 0) + if (type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) { + if (H5D__compound_opt_read(smine_nelmts, mem_iter, type_info, buf /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ else { - if(H5T_BKG_YES == type_info->need_bkg) { - n = H5D__gather_mem(buf, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/); - if(n != smine_nelmts) + if (H5T_BKG_YES == type_info->need_bkg) { + n = H5D__gather_mem(buf, bkg_iter, smine_nelmts, type_info->bkg_buf /*out*/); + if (n != smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed") } /* end if */ /* * Perform datatype conversion. */ - if(H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, - smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf, - type_info->bkg_buf) < 0) + if (H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, smine_nelmts, + (size_t)0, (size_t)0, type_info->tconv_buf, type_info->bkg_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") /* Do the data transform after the conversion (since we're using type mem_type) */ - if(!type_info->is_xform_noop) { - H5Z_data_xform_t *data_transform; /* Data transform info */ + if (!type_info->is_xform_noop) { + H5Z_data_xform_t *data_transform; /* Data transform info */ /* Retrieve info from API context */ - if(H5CX_get_data_transform(&data_transform) < 0) + if (H5CX_get_data_transform(&data_transform) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info") - if(H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0) + if (H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Error performing data transform") } /* Scatter the data into memory */ - if(H5D__scatter_mem(type_info->tconv_buf, mem_iter, smine_nelmts, buf/*out*/) < 0) + if (H5D__scatter_mem(type_info->tconv_buf, mem_iter, smine_nelmts, buf /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") } /* end else */ - } /* end for */ + } /* end for */ done: /* Release selection iterators */ - if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) + if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(file_iter) + if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(mem_iter) + if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); - if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) + if (bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(bkg_iter) + if (bkg_iter) bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__scatgath_read() */ - /*------------------------------------------------------------------------- * Function: H5D__scatgath_write * @@ -592,19 +576,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space) +H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space) { - const void *buf = io_info->u.wbuf; /* Local pointer to application buffer */ - H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/ - hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ - H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/ - hbool_t bkg_iter_init = FALSE; /* Background iteration info has been initialized */ - H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info*/ - hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */ - hsize_t smine_start; /* Strip mine start loc */ - size_t smine_nelmts; /* Elements per strip */ - herr_t ret_value = SUCCEED; /* Return value */ + const void * buf = io_info->u.wbuf; /* Local pointer to application buffer */ + H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/ + hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ + H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/ + hbool_t bkg_iter_init = FALSE; /* Background iteration info has been initialized */ + H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info*/ + hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */ + hsize_t smine_start; /* Strip mine start loc */ + size_t smine_nelmts; /* Elements per strip */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -616,31 +600,33 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in HDassert(buf); /* Check for NOOP write */ - if(nelmts == 0) + if (nelmts == 0) HGOTO_DONE(SUCCEED) /* Allocate the iterators */ - if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator") - if(NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate background iterator") - if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") /* Figure out the strip mine size. */ - if(H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) + if (H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size, + H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") - file_iter_init = TRUE; /*file selection iteration info has been initialized */ - if(H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size, 0) < 0) + file_iter_init = TRUE; /*file selection iteration info has been initialized */ + if (H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") - mem_iter_init = TRUE; /*file selection iteration info has been initialized */ - if(H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) + mem_iter_init = TRUE; /*file selection iteration info has been initialized */ + if (H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size, + H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") - bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ + bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ /* Start strip mining... */ - for(smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) { - size_t n; /* Elements operated on */ + for (smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) { + size_t n; /* Elements operated on */ /* Go figure out how many elements to read from the file */ HDassert(H5S_SELECT_ITER_NELMTS(file_iter) == (nelmts - smine_start)); @@ -651,8 +637,8 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in * buffer. Also gather data from the file into the background buffer * if necessary. */ - n = H5D__gather_mem(buf, mem_iter, smine_nelmts, type_info->tconv_buf/*out*/); - if(n != smine_nelmts) + n = H5D__gather_mem(buf, mem_iter, smine_nelmts, type_info->tconv_buf /*out*/); + if (n != smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed") /* If the source and destination are compound types and the destination is @@ -661,66 +647,65 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in * is a subset of the destination, the optimization is done in conversion * function H5T_conv_struct_opt to protect the background data. */ - if(type_info->cmpd_subset && H5T_SUBSET_DST == type_info->cmpd_subset->subset - && type_info->dst_type_size == type_info->cmpd_subset->copy_size) { - if(H5D__compound_opt_write(smine_nelmts, type_info) < 0) + if (type_info->cmpd_subset && H5T_SUBSET_DST == type_info->cmpd_subset->subset && + type_info->dst_type_size == type_info->cmpd_subset->copy_size) { + if (H5D__compound_opt_write(smine_nelmts, type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ else { - if(H5T_BKG_YES == type_info->need_bkg) { - n = H5D__gather_file(io_info, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/); - if(n != smine_nelmts) + if (H5T_BKG_YES == type_info->need_bkg) { + n = H5D__gather_file(io_info, bkg_iter, smine_nelmts, type_info->bkg_buf /*out*/); + if (n != smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") } /* end if */ /* Do the data transform before the type conversion (since * transforms must be done in the memory type). */ - if(!type_info->is_xform_noop) { - H5Z_data_xform_t *data_transform; /* Data transform info */ + if (!type_info->is_xform_noop) { + H5Z_data_xform_t *data_transform; /* Data transform info */ /* Retrieve info from API context */ - if(H5CX_get_data_transform(&data_transform) < 0) + if (H5CX_get_data_transform(&data_transform) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info") - if(H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0) + if (H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Error performing data transform") } /* * Perform datatype conversion. */ - if(H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, - smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf, - type_info->bkg_buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") + if (H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, smine_nelmts, + (size_t)0, (size_t)0, type_info->tconv_buf, type_info->bkg_buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end else */ /* * Scatter the data out to the file. */ - if(H5D__scatter_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf) < 0) + if (H5D__scatter_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed") } /* end for */ done: /* Release selection iterators */ - if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) + if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(file_iter) + if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(mem_iter) + if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); - if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) + if (bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(bkg_iter) + if (bkg_iter) bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__scatgath_write() */ - /*------------------------------------------------------------------------- * Function: H5D__compound_opt_read * @@ -754,17 +739,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, - const H5D_type_info_t *type_info, void *user_buf/*out*/) +H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, const H5D_type_info_t *type_info, + void *user_buf /*out*/) { - uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */ - uint8_t *xdbuf; /* Pointer into dataset buffer */ - hsize_t *off = NULL; /* Pointer to sequence offsets */ - size_t *len = NULL; /* Pointer to sequence lengths */ - size_t src_stride, dst_stride, copy_size; - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */ + uint8_t *xdbuf; /* Pointer into dataset buffer */ + hsize_t *off = NULL; /* Pointer to sequence offsets */ + size_t * len = NULL; /* Pointer to sequence lengths */ + size_t src_stride, dst_stride, copy_size; + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -774,21 +759,21 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, HDassert(type_info); HDassert(type_info->cmpd_subset); HDassert(H5T_SUBSET_SRC == type_info->cmpd_subset->subset || - H5T_SUBSET_DST == type_info->cmpd_subset->subset); + H5T_SUBSET_DST == type_info->cmpd_subset->subset); HDassert(user_buf); /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") /* Get source & destination strides */ @@ -800,22 +785,22 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, /* Loop until all elements are written */ xdbuf = type_info->tconv_buf; - while(nelmts > 0) { - size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequence being processed */ - size_t elmtno; /* Element counter */ + while (nelmts > 0) { + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequence being processed */ + size_t elmtno; /* Element counter */ /* Get list of sequences for selection to write */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { - size_t curr_off; /* Offset of bytes left to process in sequence */ - size_t curr_len; /* Length of bytes left to process in sequence */ - size_t curr_nelmts; /* Number of elements to process in sequence */ - uint8_t *xubuf; - size_t i; /* Local index variable */ + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { + size_t curr_off; /* Offset of bytes left to process in sequence */ + size_t curr_len; /* Length of bytes left to process in sequence */ + size_t curr_nelmts; /* Number of elements to process in sequence */ + uint8_t *xubuf; + size_t i; /* Local index variable */ /* Get the number of bytes and offset in sequence */ curr_len = len[curr_seq]; @@ -824,17 +809,17 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, /* Decide the number of elements and position in the buffer. */ curr_nelmts = curr_len / dst_stride; - xubuf = ubuf + curr_off; + xubuf = ubuf + curr_off; /* Copy the data into the right place. */ - for(i = 0; i < curr_nelmts; i++) { + for (i = 0; i < curr_nelmts; i++) { HDmemmove(xubuf, xdbuf, copy_size); /* Update pointers */ xdbuf += src_stride; xubuf += dst_stride; } /* end for */ - } /* end for */ + } /* end for */ /* Decrement number of elements left to process */ nelmts -= elmtno; @@ -842,15 +827,14 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compound_opt_read() */ - /*------------------------------------------------------------------------- * Function: H5D__compound_opt_write * @@ -887,9 +871,9 @@ done: static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) { - uint8_t *xsbuf, *xdbuf; /* Source & destination pointers into dataset buffer */ - size_t src_stride, dst_stride; /* Strides through source & destination datatypes */ - size_t i; /* Local index variable */ + uint8_t *xsbuf, *xdbuf; /* Source & destination pointers into dataset buffer */ + size_t src_stride, dst_stride; /* Strides through source & destination datatypes */ + size_t i; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -904,7 +888,7 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) /* Loop until all elements are written */ xsbuf = (uint8_t *)type_info->tconv_buf; xdbuf = (uint8_t *)type_info->tconv_buf; - for(i = 0; i < nelmts; i++) { + for (i = 0; i < nelmts; i++) { HDmemmove(xdbuf, xsbuf, dst_stride); /* Update pointers */ @@ -915,7 +899,6 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__compound_opt_write() */ - /*------------------------------------------------------------------------- * Function: H5Dscatter * @@ -933,71 +916,70 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) *------------------------------------------------------------------------- */ herr_t -H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, - hid_t dst_space_id, void *dst_buf) +H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_id, void *dst_buf) { - H5T_t *type; /* Datatype */ - H5S_t *dst_space; /* Dataspace */ - H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ - const void *src_buf = NULL; /* Source (contiguous) data buffer */ - size_t src_buf_nbytes = 0; /* Size of src_buf */ - size_t type_size; /* Datatype element size */ - hssize_t nelmts; /* Number of remaining elements in selection */ - size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * type; /* Datatype */ + H5S_t * dst_space; /* Dataspace */ + H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ + hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ + const void * src_buf = NULL; /* Source (contiguous) data buffer */ + size_t src_buf_nbytes = 0; /* Size of src_buf */ + size_t type_size; /* Datatype element size */ + hssize_t nelmts; /* Number of remaining elements in selection */ + size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "x*xii*x", op, op_data, type_id, dst_space_id, dst_buf); /* Check args */ - if(op == NULL) + if (op == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback function pointer") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == (dst_space= (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) + if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(dst_buf == NULL) + if (dst_buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided") /* Get datatype element size */ - if(0 == (type_size = H5T_GET_SIZE(type))) + if (0 == (type_size = H5T_GET_SIZE(type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") /* Get number of elements in dataspace */ - if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0) + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") /* Allocate the selection iterator */ - if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize selection iterator */ - if(H5S_select_iter_init(iter, dst_space, type_size, 0) < 0) + if (H5S_select_iter_init(iter, dst_space, type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") iter_init = TRUE; /* Loop until all data has been scattered */ - while(nelmts > 0) { + while (nelmts > 0) { /* Make callback to retrieve data */ - if(op(&src_buf, &src_buf_nbytes, op_data) < 0) + if (op(&src_buf, &src_buf_nbytes, op_data) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") /* Calculate number of elements */ nelmts_scatter = src_buf_nbytes / type_size; /* Check callback results */ - if(!src_buf) + if (!src_buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback did not return a buffer") - if(src_buf_nbytes == 0) + if (src_buf_nbytes == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned a buffer size of 0") - if(src_buf_nbytes % type_size) + if (src_buf_nbytes % type_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size is not a multiple of datatype size") - if(nelmts_scatter > (size_t)nelmts) + if (nelmts_scatter > (size_t)nelmts) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection") /* Scatter data */ - if(H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0) + if (H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed") nelmts -= (hssize_t)nelmts_scatter; @@ -1005,15 +987,14 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, done: /* Release selection iterator */ - if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(iter) + if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_API(ret_value) -} /* H5Dscatter() */ +} /* H5Dscatter() */ - /*------------------------------------------------------------------------- * Function: H5Dgather * @@ -1031,71 +1012,73 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, - size_t dst_buf_size, void *dst_buf, H5D_gather_func_t op, void *op_data) +H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf_size, void *dst_buf, + H5D_gather_func_t op, void *op_data) { - H5T_t *type; /* Datatype */ - H5S_t *src_space; /* Dataspace */ - H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ - size_t type_size; /* Datatype element size */ - hssize_t nelmts; /* Number of remaining elements in selection */ - size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */ - size_t nelmts_gathered; /* Number of elements gathered from src_buf */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * type; /* Datatype */ + H5S_t * src_space; /* Dataspace */ + H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ + hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ + size_t type_size; /* Datatype element size */ + hssize_t nelmts; /* Number of remaining elements in selection */ + size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */ + size_t nelmts_gathered; /* Number of elements gathered from src_buf */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*xiz*xx*x", src_space_id, src_buf, type_id, dst_buf_size, dst_buf, op, op_data); /* Check args */ - if(NULL == (src_space= (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) + if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(src_buf == NULL) + if (src_buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source buffer provided") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(dst_buf_size == 0) + if (dst_buf_size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer size is 0") - if(dst_buf == NULL) + if (dst_buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided") /* Get datatype element size */ - if(0 == (type_size = H5T_GET_SIZE(type))) + if (0 == (type_size = H5T_GET_SIZE(type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") /* Get number of elements in dst_buf_size */ dst_buf_nelmts = dst_buf_size / type_size; - if(dst_buf_nelmts == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer is not large enough to hold one element") + if (dst_buf_nelmts == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "destination buffer is not large enough to hold one element") /* Get number of elements in dataspace */ - if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0) + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") /* If dst_buf is not large enough to hold all the elements, make sure there * is a callback */ - if(((size_t)nelmts > dst_buf_nelmts) && (op == NULL)) + if (((size_t)nelmts > dst_buf_nelmts) && (op == NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback supplied and destination buffer too small") /* Allocate the selection iterator */ - if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize selection iterator */ - if(H5S_select_iter_init(iter, src_space, type_size, 0) < 0) + if (H5S_select_iter_init(iter, src_space, type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") iter_init = TRUE; /* Loop until all data has been scattered */ - while(nelmts > 0) { + while (nelmts > 0) { /* Gather data */ - if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf))) + if (0 == + (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf))) HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed") HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts)); /* Make callback to process dst_buf */ - if(op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0) + if (op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") nelmts -= (hssize_t)nelmts_gathered; @@ -1104,11 +1087,10 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, done: /* Release selection iterator */ - if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(iter) + if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_API(ret_value) -} /* H5Dgather() */ - +} /* H5Dgather() */ diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 5a5c491..6c4f4e6 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -21,42 +21,36 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, - size_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); - +static herr_t H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space); /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ @@ -70,8 +64,6 @@ H5FL_SEQ_DEFINE(hsize_t); /* Declare extern free list to manage the H5S_sel_iter_t struct */ H5FL_EXTERN(H5S_sel_iter_t); - - /*------------------------------------------------------------------------- * Function: H5D__select_io * @@ -85,25 +77,25 @@ H5FL_EXTERN(H5S_sel_iter_t); *------------------------------------------------------------------------- */ static herr_t -H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, - size_t nelmts, const H5S_t *file_space, const H5S_t *mem_space) +H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, const H5S_t *file_space, + const H5S_t *mem_space) { - H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info */ - hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ - H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info */ - hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */ - hsize_t *mem_off = NULL; /* Pointer to sequence offsets in memory */ - hsize_t *file_off = NULL; /* Pointer to sequence offsets in the file */ - size_t *mem_len = NULL; /* Pointer to sequence lengths in memory */ - size_t *file_len = NULL; /* Pointer to sequence lengths in the file */ - size_t curr_mem_seq; /* Current memory sequence to operate on */ - size_t curr_file_seq; /* Current file sequence to operate on */ - size_t mem_nseq; /* Number of sequences generated in the file */ - size_t file_nseq; /* Number of sequences generated in memory */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info */ + hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ + H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info */ + hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */ + hsize_t * mem_off = NULL; /* Pointer to sequence offsets in memory */ + hsize_t * file_off = NULL; /* Pointer to sequence offsets in the file */ + size_t * mem_len = NULL; /* Pointer to sequence lengths in memory */ + size_t * file_len = NULL; /* Pointer to sequence lengths in the file */ + size_t curr_mem_seq; /* Current memory sequence to operate on */ + size_t curr_file_seq; /* Current file sequence to operate on */ + size_t mem_nseq; /* Number of sequences generated in the file */ + size_t file_nseq; /* Number of sequences generated in memory */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -114,16 +106,16 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, HDassert(io_info->u.rbuf); /* Check for only one element in selection */ - if(nelmts == 1) { - hsize_t single_mem_off; /* Offset in memory */ - hsize_t single_file_off; /* Offset in the file */ - size_t single_mem_len; /* Length in memory */ - size_t single_file_len; /* Length in the file */ + if (nelmts == 1) { + hsize_t single_mem_off; /* Offset in memory */ + hsize_t single_file_off; /* Offset in the file */ + size_t single_mem_len; /* Length in memory */ + size_t single_file_len; /* Length in the file */ /* Get offset of first element in selections */ - if(H5S_SELECT_OFFSET(file_space, &single_file_off) < 0) + if (H5S_SELECT_OFFSET(file_space, &single_file_off) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "can't retrieve file selection offset") - if(H5S_SELECT_OFFSET(mem_space, &single_mem_off) < 0) + if (H5S_SELECT_OFFSET(mem_space, &single_mem_off) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "can't retrieve memory selection offset") /* Set up necessary information for I/O operation */ @@ -134,17 +126,17 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, single_file_len = single_mem_len = elmt_size; /* Perform I/O on memory and file sequences */ - if(io_info->op_type == H5D_IO_OP_READ) { - if((tmp_file_len = (*io_info->layout_ops.readvv)(io_info, - file_nseq, &curr_file_seq, &single_file_len, &single_file_off, - mem_nseq, &curr_mem_seq, &single_mem_len, &single_mem_off)) < 0) + if (io_info->op_type == H5D_IO_OP_READ) { + if ((tmp_file_len = (*io_info->layout_ops.readvv)( + io_info, file_nseq, &curr_file_seq, &single_file_len, &single_file_off, mem_nseq, + &curr_mem_seq, &single_mem_len, &single_mem_off)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error") } /* end if */ else { HDassert(io_info->op_type == H5D_IO_OP_WRITE); - if((tmp_file_len = (*io_info->layout_ops.writevv)(io_info, - file_nseq, &curr_file_seq, &single_file_len, &single_file_off, - mem_nseq, &curr_mem_seq, &single_mem_len, &single_mem_off)) < 0) + if ((tmp_file_len = (*io_info->layout_ops.writevv)( + io_info, file_nseq, &curr_file_seq, &single_file_len, &single_file_off, mem_nseq, + &curr_mem_seq, &single_mem_len, &single_mem_off)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") } /* end else */ @@ -152,53 +144,54 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, HDassert(((size_t)tmp_file_len % elmt_size) == 0); } /* end if */ else { - size_t mem_nelem; /* Number of elements used in memory sequences */ - size_t file_nelem; /* Number of elements used in file sequences */ + size_t mem_nelem; /* Number of elements used in memory sequences */ + size_t file_nelem; /* Number of elements used in file sequences */ /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (mem_len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (mem_len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (mem_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (mem_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") - if(NULL == (file_len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (file_len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (file_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (file_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") /* Allocate the iterators */ - if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator") - if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") /* Initialize file iterator */ - if(H5S_select_iter_init(file_iter, file_space, elmt_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) + if (H5S_select_iter_init(file_iter, file_space, elmt_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - file_iter_init = 1; /* File selection iteration info has been initialized */ + file_iter_init = 1; /* File selection iteration info has been initialized */ /* Initialize memory iterator */ - if(H5S_select_iter_init(mem_iter, mem_space, elmt_size, 0) < 0) + if (H5S_select_iter_init(mem_iter, mem_space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - mem_iter_init = 1; /* Memory selection iteration info has been initialized */ + mem_iter_init = 1; /* Memory selection iteration info has been initialized */ /* Initialize sequence counts */ curr_mem_seq = curr_file_seq = 0; mem_nseq = file_nseq = 0; /* Loop, until all bytes are processed */ - while(nelmts > 0) { + while (nelmts > 0) { /* Check if more file sequences are needed */ - if(curr_file_seq >= file_nseq) { + if (curr_file_seq >= file_nseq) { /* Get sequences for file selection */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(file_iter, vec_size, nelmts, &file_nseq, &file_nelem, file_off, file_len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(file_iter, vec_size, nelmts, &file_nseq, &file_nelem, + file_off, file_len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Start at the beginning of the sequences again */ @@ -206,9 +199,10 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, } /* end if */ /* Check if more memory sequences are needed */ - if(curr_mem_seq >= mem_nseq) { + if (curr_mem_seq >= mem_nseq) { /* Get sequences for memory selection */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, mem_len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, + mem_len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Start at the beginning of the sequences again */ @@ -216,53 +210,52 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, } /* end if */ /* Perform I/O on memory and file sequences */ - if(io_info->op_type == H5D_IO_OP_READ) { - if((tmp_file_len = (*io_info->layout_ops.readvv)(io_info, - file_nseq, &curr_file_seq, file_len, file_off, - mem_nseq, &curr_mem_seq, mem_len, mem_off)) < 0) + if (io_info->op_type == H5D_IO_OP_READ) { + if ((tmp_file_len = + (*io_info->layout_ops.readvv)(io_info, file_nseq, &curr_file_seq, file_len, file_off, + mem_nseq, &curr_mem_seq, mem_len, mem_off)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error") } /* end if */ else { HDassert(io_info->op_type == H5D_IO_OP_WRITE); - if((tmp_file_len = (*io_info->layout_ops.writevv)(io_info, - file_nseq, &curr_file_seq, file_len, file_off, - mem_nseq, &curr_mem_seq, mem_len, mem_off)) < 0) + if ((tmp_file_len = (*io_info->layout_ops.writevv)(io_info, file_nseq, &curr_file_seq, + file_len, file_off, mem_nseq, + &curr_mem_seq, mem_len, mem_off)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") } /* end else */ /* Decrement number of elements left to process */ HDassert(((size_t)tmp_file_len % elmt_size) == 0); - if(elmt_size == 0) + if (elmt_size == 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "Resulted in division by zero") nelmts -= ((size_t)tmp_file_len / elmt_size); } /* end while */ - } /* end else */ + } /* end else */ done: /* Release selection iterators */ - if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) + if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(file_iter) + if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(mem_iter) + if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); /* Release vector arrays, if allocated */ - if(file_len) + if (file_len) file_len = H5FL_SEQ_FREE(size_t, file_len); - if(file_off) + if (file_off) file_off = H5FL_SEQ_FREE(hsize_t, file_off); - if(mem_len) + if (mem_len) mem_len = H5FL_SEQ_FREE(size_t, mem_len); - if(mem_off) + if (mem_off) mem_off = H5FL_SEQ_FREE(hsize_t, mem_off); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__select_io() */ - /*------------------------------------------------------------------------- * Function: H5D__select_read * @@ -276,8 +269,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space) +H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space) { herr_t ret_value = SUCCEED; /* Return value */ @@ -285,15 +278,13 @@ H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Call generic selection operation */ H5_CHECK_OVERFLOW(nelmts, hsize_t, size_t); - if(H5D__select_io(io_info, type_info->src_type_size, (size_t)nelmts, - file_space, mem_space) < 0) + if (H5D__select_io(io_info, type_info->src_type_size, (size_t)nelmts, file_space, mem_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__select_read() */ - /*------------------------------------------------------------------------- * Function: H5D__select_write * @@ -307,8 +298,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space) +H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space) { herr_t ret_value = SUCCEED; /* Return value */ @@ -316,11 +307,9 @@ H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info /* Call generic selection operation */ H5_CHECK_OVERFLOW(nelmts, hsize_t, size_t); - if(H5D__select_io(io_info, type_info->dst_type_size, (size_t)nelmts, - file_space, mem_space) < 0) + if (H5D__select_io(io_info, type_info->dst_type_size, (size_t)nelmts, file_space, mem_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__select_write() */ - diff --git a/src/H5Dsingle.c b/src/H5Dsingle.c index 3fa9bc2..7a8c3f6 100644 --- a/src/H5Dsingle.c +++ b/src/H5Dsingle.c @@ -26,55 +26,47 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Single Chunk Index chunking I/O ops */ -static herr_t H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__single_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__single_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__single_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); - +static herr_t H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__single_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__single_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__single_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); /*********************/ /* Package Variables */ @@ -82,37 +74,33 @@ static herr_t H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *str /* Non Index chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_SINGLE[1] = {{ - FALSE, /* Single Chunk indexing doesn't current support SWMR access */ - H5D__single_idx_init, /* init */ - H5D__single_idx_create, /* create */ - H5D__single_idx_is_space_alloc, /* is_space_alloc */ - H5D__single_idx_insert, /* insert */ - H5D__single_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__single_idx_iterate, /* iterate */ - H5D__single_idx_remove, /* remove */ - H5D__single_idx_delete, /* delete */ - H5D__single_idx_copy_setup, /* copy_setup */ - NULL, /* copy_shutdown */ - H5D__single_idx_size, /* size */ - H5D__single_idx_reset, /* reset */ - H5D__single_idx_dump, /* dump */ - NULL, /* destroy */ - NULL /* close */ + FALSE, /* Single Chunk indexing doesn't current support SWMR access */ + H5D__single_idx_init, /* init */ + H5D__single_idx_create, /* create */ + H5D__single_idx_is_space_alloc, /* is_space_alloc */ + H5D__single_idx_insert, /* insert */ + H5D__single_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__single_idx_iterate, /* iterate */ + H5D__single_idx_remove, /* remove */ + H5D__single_idx_delete, /* delete */ + H5D__single_idx_copy_setup, /* copy_setup */ + NULL, /* copy_shutdown */ + H5D__single_idx_size, /* size */ + H5D__single_idx_reset, /* reset */ + H5D__single_idx_dump, /* dump */ + NULL, /* destroy */ + NULL /* close */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5D__single_idx_init * @@ -126,8 +114,8 @@ const H5D_chunk_ops_t H5D_COPS_SINGLE[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t H5_ATTR_UNUSED *space, haddr_t H5_ATTR_UNUSED dset_ohdr_addr) +H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, + haddr_t H5_ATTR_UNUSED dset_ohdr_addr) { FUNC_ENTER_STATIC_NOERR @@ -138,15 +126,14 @@ H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, HDassert(idx_info->layout); HDassert(idx_info->storage); - if(idx_info->pline->nused) - idx_info->layout->flags |= H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER; + if (idx_info->pline->nused) + idx_info->layout->flags |= H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER; else - idx_info->layout->flags = 0; + idx_info->layout->flags = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_create * @@ -174,15 +161,14 @@ H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->layout->nchunks == 1); HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); - if(idx_info->pline->nused) - HDassert(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER); + if (idx_info->pline->nused) + HDassert(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER); else - HDassert(!(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER)); + HDassert(!(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER)); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_is_space_alloc * @@ -205,7 +191,6 @@ H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__single_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_insert * @@ -218,10 +203,9 @@ H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage) *------------------------------------------------------------------------- */ static herr_t -H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t *dset) +H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, const H5D_t *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -239,22 +223,21 @@ H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(H5F_addr_defined(udata->chunk_block.offset)); idx_info->storage->idx_addr = udata->chunk_block.offset; - if(idx_info->pline->nused > 0) { + if (idx_info->pline->nused > 0) { H5_CHECKED_ASSIGN(idx_info->storage->u.single.nbytes, uint32_t, udata->chunk_block.length, hsize_t); - idx_info->storage->u.single.filter_mask = udata->filter_mask; + idx_info->storage->u.single.filter_mask = udata->filter_mask; } /* end if */ - if(dset) - if(dset->shared->dcpl_cache.fill.alloc_time != H5D_ALLOC_TIME_EARLY || idx_info->pline->nused > 0) + if (dset) + if (dset->shared->dcpl_cache.fill.alloc_time != H5D_ALLOC_TIME_EARLY || idx_info->pline->nused > 0) /* Mark the layout dirty so that the address of the single chunk will be flushed later */ - if(H5D__mark(dset, H5D_MARK_LAYOUT) < 0) + if (H5D__mark(dset, H5D_MARK_LAYOUT) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark layout as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__single_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_get_addr * @@ -283,21 +266,20 @@ H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HDassert(udata); udata->chunk_block.offset = idx_info->storage->idx_addr; - if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { - udata->chunk_block.length = idx_info->storage->u.single.nbytes; - udata->filter_mask = idx_info->storage->u.single.filter_mask; + if (idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + udata->chunk_block.length = idx_info->storage->u.single.nbytes; + udata->filter_mask = idx_info->storage->u.single.filter_mask; } /* end if */ else { - udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->chunk_block.length = idx_info->layout->size; + udata->filter_mask = 0; } /* end else */ - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) udata->chunk_block.length = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__single_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_iterate * @@ -310,11 +292,10 @@ H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda *------------------------------------------------------------------------- */ static int -H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5D_chunk_rec_t chunk_rec; /* generic chunk record */ - int ret_value = -1; /* Return value */ + H5D_chunk_rec_t chunk_rec; /* generic chunk record */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -332,23 +313,22 @@ H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDmemset(&chunk_rec, 0, sizeof(chunk_rec)); chunk_rec.chunk_addr = idx_info->storage->idx_addr; - if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { - chunk_rec.nbytes = idx_info->storage->u.single.nbytes; - chunk_rec.filter_mask = idx_info->storage->u.single.filter_mask; + if (idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + chunk_rec.nbytes = idx_info->storage->u.single.nbytes; + chunk_rec.filter_mask = idx_info->storage->u.single.filter_mask; } /* end if */ else { - chunk_rec.nbytes = idx_info->layout->size; - chunk_rec.filter_mask = 0; + chunk_rec.nbytes = idx_info->layout->size; + chunk_rec.filter_mask = 0; } /* end else */ /* Make "generic chunk" callback */ - if((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) - HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); + if ((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) + HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__single_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_remove * @@ -363,8 +343,8 @@ H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, static herr_t H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) { - hsize_t nbytes; /* Size of all chunks */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nbytes; /* Size of all chunks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -376,12 +356,12 @@ H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t HDassert(idx_info->storage); HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); - if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) - nbytes = idx_info->storage->u.single.nbytes; + if (idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) + nbytes = idx_info->storage->u.single.nbytes; else - nbytes = idx_info->layout->size; + nbytes = idx_info->layout->size; - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->storage->idx_addr, nbytes) < 0) + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->storage->idx_addr, nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free dataset chunks") idx_info->storage->idx_addr = HADDR_UNDEF; @@ -390,7 +370,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__single_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_delete * @@ -406,7 +385,7 @@ done: static herr_t H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -417,15 +396,14 @@ H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->layout); HDassert(idx_info->storage); - if(H5F_addr_defined(idx_info->storage->idx_addr)) - ret_value = H5D__single_idx_remove(idx_info, NULL); + if (H5F_addr_defined(idx_info->storage->idx_addr)) + ret_value = H5D__single_idx_remove(idx_info, NULL); else - HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); + HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__single_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_copy_setup * @@ -439,9 +417,9 @@ H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) */ static herr_t H5D__single_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) + const H5D_chk_idx_info_t * idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -463,7 +441,7 @@ H5D__single_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_i H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Set up information at the destination file */ - if(H5D__single_idx_create(idx_info_dst) < 0) + if (H5D__single_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") /* Reset metadata tag */ @@ -473,7 +451,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__single_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_size * @@ -499,7 +476,6 @@ H5D__single_idx_size(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, hsize_t FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_reset * @@ -520,13 +496,12 @@ H5D__single_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_dump * @@ -551,4 +526,3 @@ H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_dump() */ - diff --git a/src/H5Dtest.c b/src/H5Dtest.c index 916ec72..43e7a82 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -21,46 +21,38 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ -#define H5D_TESTING /*suppress warning about H5D testing funcs*/ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ +#define H5D_TESTING /*suppress warning about H5D testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - - /*-------------------------------------------------------------------------- NAME H5D__layout_version_test @@ -83,23 +75,22 @@ herr_t H5D__layout_version_test(hid_t did, unsigned *version) { - H5D_t *dset; /* Pointer to dataset to query */ + H5D_t *dset; /* Pointer to dataset to query */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(version) + if (version) *version = dset->shared->layout.version; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_version_test() */ +} /* H5D__layout_version_test() */ - /*-------------------------------------------------------------------------- NAME H5D__layout_contig_size_test @@ -122,25 +113,24 @@ done: herr_t H5D__layout_contig_size_test(hid_t did, hsize_t *size) { - H5D_t *dset; /* Pointer to dataset to query */ + H5D_t *dset; /* Pointer to dataset to query */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(size) { + if (size) { HDassert(dset->shared->layout.type == H5D_CONTIGUOUS); *size = dset->shared->layout.storage.u.contig.size; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_contig_size_test() */ +} /* H5D__layout_contig_size_test() */ - /*-------------------------------------------------------------------------- NAME H5D__layout_compact_dirty_test @@ -169,19 +159,18 @@ H5D__layout_compact_dirty_test(hid_t did, hbool_t *dirty) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(dirty) { + if (dirty) { HDassert(dset->shared->layout.type == H5D_COMPACT); *dirty = dset->shared->layout.storage.u.compact.dirty; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_compact_dirty_test() */ +} /* H5D__layout_compact_dirty_test() */ - /*-------------------------------------------------------------------------- NAME H5D__layout_type_test @@ -204,25 +193,24 @@ done: herr_t H5D__layout_type_test(hid_t did, H5D_layout_t *layout_type) { - H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dset; /* Pointer to dataset to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE HDassert(layout_type); /* Check args */ - if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(layout_type) + if (layout_type) *layout_type = dset->shared->layout.type; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_type_test() */ +} /* H5D__layout_type_test() */ - /*-------------------------------------------------------------------------- NAME H5D__layout_idx_type_test @@ -245,25 +233,24 @@ done: herr_t H5D__layout_idx_type_test(hid_t did, H5D_chunk_index_t *idx_type) { - H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dset; /* Pointer to dataset to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(dset->shared->layout.type != H5D_CHUNKED) + if (dset->shared->layout.type != H5D_CHUNKED) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not chunked") - if(idx_type) + if (idx_type) *idx_type = dset->shared->layout.u.chunk.idx_type; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_idx_type_test() */ +} /* H5D__layout_idx_type_test() */ - /*-------------------------------------------------------------------------- NAME H5D__current_cache_size_test @@ -286,26 +273,25 @@ done: herr_t H5D__current_cache_size_test(hid_t did, size_t *nbytes_used, int *nused) { - H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dset; /* Pointer to dataset to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(nbytes_used) { + if (nbytes_used) { HDassert(dset->shared->layout.type == H5D_CHUNKED); *nbytes_used = dset->shared->cache.chunk.nbytes_used; } /* end if */ - if(nused) { + if (nused) { HDassert(dset->shared->layout.type == H5D_CHUNKED); *nused = dset->shared->cache.chunk.nused; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__current_cache_size_test() */ - +} /* H5D__current_cache_size_test() */ diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index e0bfb1b..767446f 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -46,26 +46,25 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property Lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property Lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -74,76 +73,56 @@ /* Default size for sub_dset array */ #define H5D_VIRTUAL_DEF_SUB_DSET_SIZE 128 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Layout operation callbacks */ static hbool_t H5D__virtual_is_data_cached(const H5D_shared_t *shared_dset); -static herr_t H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t - *type_info, hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *fm); -static herr_t H5D__virtual_write(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space, H5D_chunk_map_t *fm); -static herr_t H5D__virtual_flush(H5D_t *dset); +static herr_t H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); +static herr_t H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); +static herr_t H5D__virtual_flush(H5D_t *dset); /* Other functions */ -static herr_t H5D__virtual_open_source_dset(const H5D_t *vdset, - H5O_storage_virtual_ent_t *virtual_ent, - H5O_storage_virtual_srcdset_t *source_dset); -static herr_t H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, - H5O_storage_virtual_srcdset_t *source_dset); -static herr_t H5D__virtual_str_append(const char *src, size_t src_len, char **p, - char **buf, size_t *buf_size); -static herr_t H5D__virtual_copy_parsed_name( - H5O_storage_virtual_name_seg_t **dst, H5O_storage_virtual_name_seg_t *src); -static herr_t H5D__virtual_build_source_name(char *source_name, - const H5O_storage_virtual_name_seg_t *parsed_name, size_t static_strlen, - size_t nsubs, hsize_t blockno, char **built_name); +static herr_t H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *virtual_ent, + H5O_storage_virtual_srcdset_t *source_dset); +static herr_t H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t * virtual_ent, + H5O_storage_virtual_srcdset_t *source_dset); +static herr_t H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, + size_t *buf_size); +static herr_t H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, + H5O_storage_virtual_name_seg_t * src); +static herr_t H5D__virtual_build_source_name(char * source_name, + const H5O_storage_virtual_name_seg_t *parsed_name, + size_t static_strlen, size_t nsubs, hsize_t blockno, + char **built_name); static herr_t H5D__virtual_init_all(const H5D_t *dset); -static herr_t H5D__virtual_pre_io(H5D_io_info_t *io_info, - H5O_storage_virtual_t *storage, const H5S_t *file_space, - const H5S_t *mem_space, hsize_t *tot_nelmts); +static herr_t H5D__virtual_pre_io(H5D_io_info_t *io_info, H5O_storage_virtual_t *storage, + const H5S_t *file_space, const H5S_t *mem_space, hsize_t *tot_nelmts); static herr_t H5D__virtual_post_io(H5O_storage_virtual_t *storage); -static herr_t H5D__virtual_read_one(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, const H5S_t *file_space, - H5O_storage_virtual_srcdset_t *source_dset); -static herr_t H5D__virtual_write_one(H5D_io_info_t *io_info, - const H5D_type_info_t *type_info, const H5S_t *file_space, - H5O_storage_virtual_srcdset_t *source_dset); - +static herr_t H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + const H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset); +static herr_t H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + const H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset); /*********************/ /* Package Variables */ /*********************/ /* Contiguous storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{ - NULL, - H5D__virtual_init, - H5D__virtual_is_space_alloc, - H5D__virtual_is_data_cached, - NULL, - H5D__virtual_read, - H5D__virtual_write, +const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{NULL, H5D__virtual_init, H5D__virtual_is_space_alloc, + H5D__virtual_is_data_cached, NULL, H5D__virtual_read, + H5D__virtual_write, #ifdef H5_HAVE_PARALLEL - NULL, - NULL, + NULL, NULL, #endif /* H5_HAVE_PARALLEL */ - NULL, - NULL, - H5D__virtual_flush, - NULL, - NULL -}}; - + NULL, NULL, H5D__virtual_flush, NULL, NULL}}; /*******************/ /* Local Variables */ @@ -155,8 +134,6 @@ H5FL_DEFINE(H5O_storage_virtual_name_seg_t); /* Declare a static free list to manage H5D_virtual_file_list_t structs */ H5FL_DEFINE_STATIC(H5D_virtual_held_file_t); - - /*------------------------------------------------------------------------- * Function: H5D_virtual_check_mapping_pre * @@ -173,60 +150,66 @@ H5FL_DEFINE_STATIC(H5D_virtual_held_file_t); */ herr_t H5D_virtual_check_mapping_pre(const H5S_t *vspace, const H5S_t *src_space, - H5O_virtual_space_status_t space_status) + H5O_virtual_space_status_t space_status) { - H5S_sel_type select_type; /* Selection type */ - hsize_t nelmts_vs; /* Number of elements in virtual selection */ - hsize_t nelmts_ss; /* Number of elements in source selection */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_sel_type select_type; /* Selection type */ + hsize_t nelmts_vs; /* Number of elements in virtual selection */ + hsize_t nelmts_ss; /* Number of elements in source selection */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check for point selections (currently unsupported) */ - if(H5S_SEL_ERROR == (select_type = H5S_GET_SELECT_TYPE(vspace))) + if (H5S_SEL_ERROR == (select_type = H5S_GET_SELECT_TYPE(vspace))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get selection type") - if(select_type == H5S_SEL_POINTS) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "point selections not currently supported with virtual datasets") - if(H5S_SEL_ERROR == (select_type = H5S_GET_SELECT_TYPE(src_space))) + if (select_type == H5S_SEL_POINTS) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "point selections not currently supported with virtual datasets") + if (H5S_SEL_ERROR == (select_type = H5S_GET_SELECT_TYPE(src_space))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get selection type") - if(select_type == H5S_SEL_POINTS) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "point selections not currently supported with virtual datasets") + if (select_type == H5S_SEL_POINTS) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "point selections not currently supported with virtual datasets") /* Get number of elements in spaces */ nelmts_vs = (hsize_t)H5S_GET_SELECT_NPOINTS(vspace); nelmts_ss = (hsize_t)H5S_GET_SELECT_NPOINTS(src_space); /* Check for unlimited vspace */ - if(nelmts_vs == H5S_UNLIMITED) { + if (nelmts_vs == H5S_UNLIMITED) { /* Check for unlimited src_space */ - if(nelmts_ss == H5S_UNLIMITED) { - hsize_t nenu_vs; /* Number of elements in the non-unlimited dimensions of vspace */ - hsize_t nenu_ss; /* Number of elements in the non-unlimited dimensions of src_space */ + if (nelmts_ss == H5S_UNLIMITED) { + hsize_t nenu_vs; /* Number of elements in the non-unlimited dimensions of vspace */ + hsize_t nenu_ss; /* Number of elements in the non-unlimited dimensions of src_space */ /* Non-printf unlimited selection. Make sure both selections have * the same number of elements in the non-unlimited dimension. Note * we can always check this even if the space status is invalid * because unlimited selections are never dependent on the extent. */ - if(H5S_get_select_num_elem_non_unlim(vspace, &nenu_vs) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "can't get number of elements in non-unlimited dimension") - if(H5S_get_select_num_elem_non_unlim(src_space, &nenu_ss) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "can't get number of elements in non-unlimited dimension") - if(nenu_vs != nenu_ss) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "numbers of elemnts in the non-unlimited dimensions is different for source and virtual spaces") + if (H5S_get_select_num_elem_non_unlim(vspace, &nenu_vs) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "can't get number of elements in non-unlimited dimension") + if (H5S_get_select_num_elem_non_unlim(src_space, &nenu_ss) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "can't get number of elements in non-unlimited dimension") + if (nenu_vs != nenu_ss) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "numbers of elemnts in the non-unlimited dimensions is different for source and " + "virtual spaces") } /* end if */ /* We will handle the printf case after parsing the source names */ } /* end if */ - else if(space_status != H5O_VIRTUAL_STATUS_INVALID) + else if (space_status != H5O_VIRTUAL_STATUS_INVALID) /* Limited selections. Check number of points is the same. */ - if(nelmts_vs != nelmts_ss) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual and source space selections have different numbers of elements") + if (nelmts_vs != nelmts_ss) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual and source space selections have different numbers of elements") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_check_mapping_pre() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_check_mapping_post * @@ -243,10 +226,10 @@ done: herr_t H5D_virtual_check_mapping_post(const H5O_storage_virtual_ent_t *ent) { - hsize_t nelmts_vs; /* Number of elements in virtual selection */ - hsize_t nelmts_ss; /* Number of elements in source selection */ - H5S_t *tmp_space = NULL; /* Temporary dataspace */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nelmts_vs; /* Number of elements in virtual selection */ + hsize_t nelmts_ss; /* Number of elements in source selection */ + H5S_t * tmp_space = NULL; /* Temporary dataspace */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -255,46 +238,52 @@ H5D_virtual_check_mapping_post(const H5O_storage_virtual_ent_t *ent) nelmts_ss = (hsize_t)H5S_GET_SELECT_NPOINTS(ent->source_select); /* Check for printf selection */ - if((nelmts_vs == H5S_UNLIMITED) && (nelmts_ss != H5S_UNLIMITED)) { + if ((nelmts_vs == H5S_UNLIMITED) && (nelmts_ss != H5S_UNLIMITED)) { /* Make sure there at least one %b substitution in the source file or * dataset name */ - if((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unlimited virtual selection, limited source selection, and no printf specifiers in source names") + if ((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, + "unlimited virtual selection, limited source selection, and no printf specifiers in " + "source names") /* Make sure virtual space uses hyperslab selection */ - if(H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select) != H5S_SEL_HYPERSLABS) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "virtual selection with printf mapping must be hyperslab") + if (H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select) != H5S_SEL_HYPERSLABS) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, + "virtual selection with printf mapping must be hyperslab") /* Check that the number of elements in one block in the virtual * selection matches the total number of elements in the source * selection, if the source space status is not invalid (virtual space * status does not matter here because it is unlimited) */ - if(ent->source_space_status != H5O_VIRTUAL_STATUS_INVALID) { + if (ent->source_space_status != H5O_VIRTUAL_STATUS_INVALID) { /* Get first block in virtual selection */ - if(NULL == (tmp_space = H5S_hyper_get_unlim_block(ent->source_dset.virtual_select, (hsize_t)0))) + if (NULL == (tmp_space = H5S_hyper_get_unlim_block(ent->source_dset.virtual_select, (hsize_t)0))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get first block in virtual selection") /* Check number of points */ nelmts_vs = (hsize_t)H5S_GET_SELECT_NPOINTS(tmp_space); - if(nelmts_vs != nelmts_ss) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual (single block) and source space selections have different numbers of elements") + if (nelmts_vs != nelmts_ss) + HGOTO_ERROR( + H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual (single block) and source space selections have different numbers of elements") } /* end if */ - } /* end if */ + } /* end if */ else /* Make sure there are no printf substitutions */ - if((ent->psfn_nsubs > 0) || (ent->psdn_nsubs > 0)) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "printf specifier(s) in source name(s) without an unlimited virtual selection and limited source selection") + if ((ent->psfn_nsubs > 0) || (ent->psdn_nsubs > 0)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, + "printf specifier(s) in source name(s) without an unlimited virtual selection and " + "limited source selection") done: /* Free temporary space */ - if(tmp_space) - if(H5S_close(tmp_space) < 0) + if (tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_check_mapping_post() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_update_min_dims * @@ -313,14 +302,14 @@ done: herr_t H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) { - H5O_storage_virtual_t *virt = &layout->storage.u.virt; - H5O_storage_virtual_ent_t *ent = &virt->list[idx]; - H5S_sel_type sel_type; - int rank; - hsize_t bounds_start[H5S_MAX_RANK]; - hsize_t bounds_end[H5S_MAX_RANK]; - int i; - herr_t ret_value = SUCCEED; + H5O_storage_virtual_t * virt = &layout->storage.u.virt; + H5O_storage_virtual_ent_t *ent = &virt->list[idx]; + H5S_sel_type sel_type; + int rank; + hsize_t bounds_start[H5S_MAX_RANK]; + hsize_t bounds_end[H5S_MAX_RANK]; + int i; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -329,33 +318,31 @@ H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) HDassert(idx < virt->list_nalloc); /* Get type of selection */ - if(H5S_SEL_ERROR == (sel_type = H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select))) + if (H5S_SEL_ERROR == (sel_type = H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection type") /* Do not update min_dims for "all" or "none" selections */ - if((sel_type == H5S_SEL_ALL) || (sel_type == H5S_SEL_NONE)) + if ((sel_type == H5S_SEL_ALL) || (sel_type == H5S_SEL_NONE)) HGOTO_DONE(SUCCEED) /* Get rank of vspace */ - if((rank = H5S_GET_EXTENT_NDIMS(ent->source_dset.virtual_select)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(ent->source_dset.virtual_select)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Get selection bounds */ - if(H5S_SELECT_BOUNDS(ent->source_dset.virtual_select, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS(ent->source_dset.virtual_select, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Update min_dims */ - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) /* Don't check unlimited dimensions in the selection */ - if((i != ent->unlim_dim_virtual) - && (bounds_end[i] >= virt->min_dims[i])) + if ((i != ent->unlim_dim_virtual) && (bounds_end[i] >= virt->min_dims[i])) virt->min_dims[i] = bounds_end[i] + (hsize_t)1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_update_min_dims() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_check_min_dims * @@ -372,10 +359,10 @@ done: herr_t H5D_virtual_check_min_dims(const H5D_t *dset) { - int rank; - hsize_t dims[H5S_MAX_RANK]; - int i; - herr_t ret_value = SUCCEED; + int rank; + hsize_t dims[H5S_MAX_RANK]; + int i; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -384,23 +371,24 @@ H5D_virtual_check_min_dims(const H5D_t *dset) HDassert(dset->shared->layout.type == H5D_VIRTUAL); /* Get rank of dataspace */ - if((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Get VDS dimensions */ - if(H5S_get_simple_extent_dims(dset->shared->space, dims, NULL) < 0) + if (H5S_get_simple_extent_dims(dset->shared->space, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions") /* Verify that dimensions are larger than min_dims */ - for(i = 0; i < rank; i++) - if(dims[i] < dset->shared->layout.storage.u.virt.min_dims[i]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual dataset dimensions not large enough to contain all limited dimensions in all selections") + for (i = 0; i < rank; i++) + if (dims[i] < dset->shared->layout.storage.u.virt.min_dims[i]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual dataset dimensions not large enough to contain all limited dimensions in " + "all selections") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_check_min_dims() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_store_layout * @@ -421,15 +409,15 @@ done: herr_t H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) { - H5O_storage_virtual_t *virt = &layout->storage.u.virt; - uint8_t *heap_block = NULL; /* Block to add to heap */ - size_t *str_size = NULL; /* Array for VDS entry string lengths */ - uint8_t *heap_block_p; /* Pointer into the heap block, while encoding */ - size_t block_size; /* Total size of block needed */ - hsize_t tmp_nentries; /* Temp. variable for # of VDS entries */ - uint32_t chksum; /* Checksum for heap data */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *virt = &layout->storage.u.virt; + uint8_t * heap_block = NULL; /* Block to add to heap */ + size_t * str_size = NULL; /* Array for VDS entry string lengths */ + uint8_t * heap_block_p; /* Pointer into the heap block, while encoding */ + size_t block_size; /* Total size of block needed */ + hsize_t tmp_nentries; /* Temp. variable for # of VDS entries */ + uint32_t chksum; /* Checksum for heap data */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -439,13 +427,13 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) HDassert(virt->serial_list_hobjid.addr == HADDR_UNDEF); /* Create block if # of used entries > 0 */ - if(virt->list_nused > 0) { + if (virt->list_nused > 0) { /* Set the low/high bounds according to 'f' for the API context */ H5CX_set_libver_bounds(f); /* Allocate array for caching results of strlen */ - if(NULL == (str_size = (size_t *)H5MM_malloc(2 * virt->list_nused * sizeof(size_t)))) + if (NULL == (str_size = (size_t *)H5MM_malloc(2 * virt->list_nused * sizeof(size_t)))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate string length array") /* @@ -456,9 +444,9 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) block_size = (size_t)1 + H5F_SIZEOF_SIZE(f); /* Calculate size of each entry */ - for(i = 0; i < virt->list_nused; i++) { + for (i = 0; i < virt->list_nused; i++) { H5O_storage_virtual_ent_t *ent = &virt->list[i]; - hssize_t select_serial_size; /* Size of serialized selection */ + hssize_t select_serial_size; /* Size of serialized selection */ HDassert(ent->source_file_name); HDassert(ent->source_dset_name); @@ -474,12 +462,12 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) block_size += str_size[(2 * i) + 1]; /* Source selection */ - if((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_select)) < 0) + if ((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_select)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size") block_size += (size_t)select_serial_size; /* Virtual dataset selection */ - if((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_dset.virtual_select)) < 0) + if ((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_dset.virtual_select)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size") block_size += (size_t)select_serial_size; } /* end for */ @@ -487,12 +475,10 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) /* Checksum */ block_size += 4; - /* Allocate heap block */ - if(NULL == (heap_block = (uint8_t *)H5MM_malloc(block_size))) + if (NULL == (heap_block = (uint8_t *)H5MM_malloc(block_size))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate heap block") - /* * Encode heap block */ @@ -506,7 +492,7 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) H5F_ENCODE_LENGTH(f, heap_block_p, tmp_nentries) /* Encode each entry */ - for(i = 0; i < virt->list_nused; i++) { + for (i = 0; i < virt->list_nused; i++) { H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Source file name */ H5MM_memcpy((char *)heap_block_p, ent->source_file_name, str_size[2 * i]); @@ -517,11 +503,11 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) heap_block_p += str_size[(2 * i) + 1]; /* Source selection */ - if(H5S_SELECT_SERIALIZE(ent->source_select, &heap_block_p) < 0) + if (H5S_SELECT_SERIALIZE(ent->source_select, &heap_block_p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize source selection") /* Virtual selection */ - if(H5S_SELECT_SERIALIZE(ent->source_dset.virtual_select, &heap_block_p) < 0) + if (H5S_SELECT_SERIALIZE(ent->source_dset.virtual_select, &heap_block_p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize virtual selection") } /* end for */ @@ -530,18 +516,18 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) UINT32ENCODE(heap_block_p, chksum) /* Insert block into global heap */ - if(H5HG_insert(f, block_size, heap_block, &(virt->serial_list_hobjid)) < 0) /* Casting away const OK --NAF */ + if (H5HG_insert(f, block_size, heap_block, &(virt->serial_list_hobjid)) < + 0) /* Casting away const OK --NAF */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to insert virtual dataset heap block") } /* end if */ done: heap_block = (uint8_t *)H5MM_xfree(heap_block); - str_size = (size_t *)H5MM_xfree(str_size); + str_size = (size_t *)H5MM_xfree(str_size); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_store_layout() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_copy_layout * @@ -561,12 +547,12 @@ herr_t H5D__virtual_copy_layout(H5O_layout_t *layout) { H5O_storage_virtual_ent_t *orig_list = NULL; - H5O_storage_virtual_t *virt = &layout->storage.u.virt; - hid_t orig_source_fapl; - hid_t orig_source_dapl; - H5P_genplist_t *plist; - size_t i; - herr_t ret_value = SUCCEED; + H5O_storage_virtual_t * virt = &layout->storage.u.virt; + hid_t orig_source_fapl; + hid_t orig_source_dapl; + H5P_genplist_t * plist; + size_t i; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -575,124 +561,120 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) /* Save original entry list and top-level property lists and reset in layout * so the originals aren't closed on error */ - orig_source_fapl = virt->source_fapl; + orig_source_fapl = virt->source_fapl; virt->source_fapl = -1; - orig_source_dapl = virt->source_dapl; + orig_source_dapl = virt->source_dapl; virt->source_dapl = -1; - orig_list = virt->list; - virt->list = NULL; + orig_list = virt->list; + virt->list = NULL; /* Copy entry list */ - if(virt->list_nused > 0) { + if (virt->list_nused > 0) { HDassert(orig_list); /* Allocate memory for the list */ - if(NULL == (virt->list = H5MM_calloc(virt->list_nused * sizeof(virt->list[0])))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate memory for virtual dataset entry list") + if (NULL == (virt->list = H5MM_calloc(virt->list_nused * sizeof(virt->list[0])))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "unable to allocate memory for virtual dataset entry list") virt->list_nalloc = virt->list_nused; /* Copy the list entries, though set source_dset.dset and sub_dset to * NULL */ - for(i = 0; i < virt->list_nused; i++) { + for (i = 0; i < virt->list_nused; i++) { H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Copy virtual selection */ - if(NULL == (ent->source_dset.virtual_select - = H5S_copy(orig_list[i].source_dset.virtual_select, FALSE, TRUE))) + if (NULL == (ent->source_dset.virtual_select = + H5S_copy(orig_list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Copy original source names */ - if(NULL == (ent->source_file_name - = H5MM_strdup(orig_list[i].source_file_name))) + if (NULL == (ent->source_file_name = H5MM_strdup(orig_list[i].source_file_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") - if(NULL == (ent->source_dset_name - = H5MM_strdup(orig_list[i].source_dset_name))) + if (NULL == (ent->source_dset_name = H5MM_strdup(orig_list[i].source_dset_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") /* Copy source selection */ - if(NULL == (ent->source_select - = H5S_copy(orig_list[i].source_select, FALSE, TRUE))) + if (NULL == (ent->source_select = H5S_copy(orig_list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Initialize clipped selections */ - if(orig_list[i].unlim_dim_virtual < 0) { - ent->source_dset.clipped_source_select = ent->source_select; + if (orig_list[i].unlim_dim_virtual < 0) { + ent->source_dset.clipped_source_select = ent->source_select; ent->source_dset.clipped_virtual_select = ent->source_dset.virtual_select; } /* end if */ /* Copy parsed names */ - if(H5D__virtual_copy_parsed_name(&ent->parsed_source_file_name, orig_list[i].parsed_source_file_name) < 0) + if (H5D__virtual_copy_parsed_name(&ent->parsed_source_file_name, + orig_list[i].parsed_source_file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source file name") ent->psfn_static_strlen = orig_list[i].psfn_static_strlen; - ent->psfn_nsubs = orig_list[i].psfn_nsubs; - if(H5D__virtual_copy_parsed_name(&ent->parsed_source_dset_name, orig_list[i].parsed_source_dset_name) < 0) + ent->psfn_nsubs = orig_list[i].psfn_nsubs; + if (H5D__virtual_copy_parsed_name(&ent->parsed_source_dset_name, + orig_list[i].parsed_source_dset_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source dataset name") ent->psdn_static_strlen = orig_list[i].psdn_static_strlen; - ent->psdn_nsubs = orig_list[i].psdn_nsubs; + ent->psdn_nsubs = orig_list[i].psdn_nsubs; /* Copy source names in source dset or add reference as appropriate */ - if(orig_list[i].source_dset.file_name) { - if(orig_list[i].source_dset.file_name - == orig_list[i].source_file_name) + if (orig_list[i].source_dset.file_name) { + if (orig_list[i].source_dset.file_name == orig_list[i].source_file_name) ent->source_dset.file_name = ent->source_file_name; - else if(orig_list[i].parsed_source_file_name - && (orig_list[i].source_dset.file_name - != orig_list[i].parsed_source_file_name->name_segment)) { + else if (orig_list[i].parsed_source_file_name && + (orig_list[i].source_dset.file_name != + orig_list[i].parsed_source_file_name->name_segment)) { HDassert(ent->parsed_source_file_name); HDassert(ent->parsed_source_file_name->name_segment); ent->source_dset.file_name = ent->parsed_source_file_name->name_segment; } /* end if */ - else - if(NULL == (ent->source_dset.file_name - = H5MM_strdup(orig_list[i].source_dset.file_name))) - HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") + else if (NULL == + (ent->source_dset.file_name = H5MM_strdup(orig_list[i].source_dset.file_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") } /* end if */ - if(orig_list[i].source_dset.dset_name) { - if(orig_list[i].source_dset.dset_name - == orig_list[i].source_dset_name) + if (orig_list[i].source_dset.dset_name) { + if (orig_list[i].source_dset.dset_name == orig_list[i].source_dset_name) ent->source_dset.dset_name = ent->source_dset_name; - else if(orig_list[i].parsed_source_dset_name - && (orig_list[i].source_dset.dset_name - != orig_list[i].parsed_source_dset_name->name_segment)) { + else if (orig_list[i].parsed_source_dset_name && + (orig_list[i].source_dset.dset_name != + orig_list[i].parsed_source_dset_name->name_segment)) { HDassert(ent->parsed_source_dset_name); HDassert(ent->parsed_source_dset_name->name_segment); ent->source_dset.dset_name = ent->parsed_source_dset_name->name_segment; } /* end if */ - else - if(NULL == (ent->source_dset.dset_name - = H5MM_strdup(orig_list[i].source_dset.dset_name))) - HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") + else if (NULL == + (ent->source_dset.dset_name = H5MM_strdup(orig_list[i].source_dset.dset_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") } /* end if */ /* Copy other fields in entry */ - ent->unlim_dim_source = orig_list[i].unlim_dim_source; - ent->unlim_dim_virtual = orig_list[i].unlim_dim_virtual; - ent->unlim_extent_source = orig_list[i].unlim_extent_source; + ent->unlim_dim_source = orig_list[i].unlim_dim_source; + ent->unlim_dim_virtual = orig_list[i].unlim_dim_virtual; + ent->unlim_extent_source = orig_list[i].unlim_extent_source; ent->unlim_extent_virtual = orig_list[i].unlim_extent_virtual; - ent->clip_size_source = orig_list[i].clip_size_source; - ent->clip_size_virtual = orig_list[i].clip_size_virtual; - ent->source_space_status = orig_list[i].source_space_status; + ent->clip_size_source = orig_list[i].clip_size_source; + ent->clip_size_virtual = orig_list[i].clip_size_virtual; + ent->source_space_status = orig_list[i].source_space_status; ent->virtual_space_status = orig_list[i].virtual_space_status; } /* end for */ - } /* end if */ + } /* end if */ else { /* Zero out other fields related to list, just to be sure */ - virt->list = NULL; + virt->list = NULL; virt->list_nalloc = 0; } /* end else */ /* Copy property lists */ - if(orig_source_fapl >= 0) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_fapl, H5I_GENPROP_LST))) + if (orig_source_fapl >= 0) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_fapl, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if((virt->source_fapl = H5P_copy_plist(plist, FALSE)) < 0) + if ((virt->source_fapl = H5P_copy_plist(plist, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy fapl") } /* end if */ - if(orig_source_dapl >= 0) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_dapl, H5I_GENPROP_LST))) + if (orig_source_dapl >= 0) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_dapl, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if((virt->source_dapl = H5P_copy_plist(plist, FALSE)) < 0) + if ((virt->source_dapl = H5P_copy_plist(plist, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dapl") } /* end if */ @@ -701,14 +683,13 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) done: /* Release allocated resources on failure */ - if(ret_value < 0) - if(H5D__virtual_reset_layout(layout) < 0) + if (ret_value < 0) + if (H5D__virtual_reset_layout(layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset virtual layout") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_copy_layout() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_reset_layout * @@ -728,9 +709,9 @@ done: herr_t H5D__virtual_reset_layout(H5O_layout_t *layout) { - size_t i, j; - H5O_storage_virtual_t *virt = &layout->storage.u.virt; - herr_t ret_value = SUCCEED; + size_t i, j; + H5O_storage_virtual_t *virt = &layout->storage.u.virt; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -740,10 +721,10 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) /* Free the list entries. Note we always attempt to free everything even in * the case of a failure. Because of this, and because we free the list * afterwards, we do not need to zero out the memory in the list. */ - for(i = 0; i < virt->list_nused; i++) { + for (i = 0; i < virt->list_nused; i++) { H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Free source_dset */ - if(H5D__virtual_reset_source_dset(ent, &ent->source_dset) < 0) + if (H5D__virtual_reset_source_dset(ent, &ent->source_dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") /* Free original source names */ @@ -751,14 +732,14 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) (void)H5MM_xfree(ent->source_dset_name); /* Free sub_dset */ - for(j = 0; j < ent->sub_dset_nalloc; j++) - if(H5D__virtual_reset_source_dset(ent, &ent->sub_dset[j]) < 0) + for (j = 0; j < ent->sub_dset_nalloc; j++) + if (H5D__virtual_reset_source_dset(ent, &ent->sub_dset[j]) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") ent->sub_dset = H5MM_xfree(ent->sub_dset); /* Free source_select */ - if(ent->source_select) - if(H5S_close(ent->source_select) < 0) + if (ent->source_select) + if (H5S_close(ent->source_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") /* Free parsed_source_file_name */ @@ -769,19 +750,19 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) } /* Free the list */ - virt->list = H5MM_xfree(virt->list); + virt->list = H5MM_xfree(virt->list); virt->list_nalloc = (size_t)0; - virt->list_nused = (size_t)0; + virt->list_nused = (size_t)0; (void)HDmemset(virt->min_dims, 0, sizeof(virt->min_dims)); /* Close access property lists */ - if(virt->source_fapl >= 0) { - if(H5I_dec_ref(virt->source_fapl) < 0) + if (virt->source_fapl >= 0) { + if (H5I_dec_ref(virt->source_fapl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source fapl") virt->source_fapl = -1; } - if(virt->source_dapl >= 0) { - if(H5I_dec_ref(virt->source_dapl) < 0) + if (virt->source_dapl >= 0) { + if (H5I_dec_ref(virt->source_dapl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source dapl") virt->source_dapl = -1; } @@ -794,7 +775,6 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_reset_layout() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_copy * @@ -810,15 +790,15 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) herr_t H5D__virtual_copy(H5F_t *f_dst, H5O_layout_t *layout_dst) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE #ifdef NOT_YET /* Check for copy to the same file */ - if(f_dst == f_src) { + if (f_dst == f_src) { /* Increase reference count on global heap object */ - if((heap_rc = H5HG_link(f_dst, (H5HG_t *)&(layout_dst->u.virt.serial_list_hobjid), 1)) < 0) + if ((heap_rc = H5HG_link(f_dst, (H5HG_t *)&(layout_dst->u.virt.serial_list_hobjid), 1)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTMODIFY, FAIL, "unable to adjust global heap reference count") } /* end if */ else @@ -826,18 +806,17 @@ H5D__virtual_copy(H5F_t *f_dst, H5O_layout_t *layout_dst) { /* Reset global heap id */ layout_dst->storage.u.virt.serial_list_hobjid.addr = HADDR_UNDEF; - layout_dst->storage.u.virt.serial_list_hobjid.idx = (size_t)0; + layout_dst->storage.u.virt.serial_list_hobjid.idx = (size_t)0; /* Write the VDS data to destination file's heap */ - if(H5D__virtual_store_layout(f_dst, layout_dst) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to store VDS info") + if (H5D__virtual_store_layout(f_dst, layout_dst) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to store VDS info") } /* end block/else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_copy() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_delete * @@ -855,7 +834,7 @@ H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage) { #ifdef NOT_YET int heap_rc; /* Reference count of global heap object */ -#endif /* NOT_YET */ +#endif /* NOT_YET */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -866,27 +845,26 @@ H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage) HDassert(storage->type == H5D_VIRTUAL); /* Check for global heap block */ - if(storage->u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { + if (storage->u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { #ifdef NOT_YET /* Unlink the global heap block */ - if((heap_rc = H5HG_link(f, (H5HG_t *)&(storage->u.virt.serial_list_hobjid), -1)) < 0) + if ((heap_rc = H5HG_link(f, (H5HG_t *)&(storage->u.virt.serial_list_hobjid), -1)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTMODIFY, FAIL, "unable to adjust global heap reference count") - if(heap_rc == 0) + if (heap_rc == 0) #endif /* NOT_YET */ /* Delete the global heap block */ - if(H5HG_remove(f, (H5HG_t *)&(storage->u.virt.serial_list_hobjid)) < 0) + if (H5HG_remove(f, (H5HG_t *)&(storage->u.virt.serial_list_hobjid)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to remove heap object") } /* end if */ /* Clear global heap ID in storage */ storage->u.virt.serial_list_hobjid.addr = HADDR_UNDEF; - storage->u.virt.serial_list_hobjid.idx = 0; + storage->u.virt.serial_list_hobjid.idx = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_delete */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_open_source_dset * @@ -900,13 +878,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_open_source_dset(const H5D_t *vdset, - H5O_storage_virtual_ent_t *virtual_ent, - H5O_storage_virtual_srcdset_t *source_dset) +H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *virtual_ent, + H5O_storage_virtual_srcdset_t *source_dset) { - H5F_t *src_file = NULL; /* Source file */ - hbool_t src_file_open = FALSE; /* Whether we have opened and need to close src_file */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * src_file = NULL; /* Source file */ + hbool_t src_file_open = FALSE; /* Whether we have opened and need to close src_file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -918,8 +895,8 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, HDassert(source_dset->dset_name); /* Check if we need to open the source file */ - if(HDstrcmp(source_dset->file_name, ".")) { - unsigned intent; /* File access permissions */ + if (HDstrcmp(source_dset->file_name, ".")) { + unsigned intent; /* File access permissions */ /* Get the virtual dataset's file open flags ("intent") */ intent = H5F_INTENT(vdset->oloc.file); @@ -932,10 +909,11 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, * the default file-access properties and the already-open file's * VFD SWMR properties. */ - src_file = H5F_prefix_open_file(vdset->oloc.file, H5F_PREFIX_VDS, vdset->shared->vds_prefix, source_dset->file_name, intent, H5P_FILE_ACCESS_ANY_VFD); + src_file = H5F_prefix_open_file(vdset->oloc.file, H5F_PREFIX_VDS, vdset->shared->vds_prefix, + source_dset->file_name, intent, H5P_FILE_ACCESS_ANY_VFD); /* If we opened the source file here, we should close it when leaving */ - if(src_file) + if (src_file) src_file_open = TRUE; else /* Reset the error stack */ @@ -945,20 +923,21 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, /* Source file is ".", use the virtual dataset's file */ src_file = vdset->oloc.file; - if(src_file) { - H5G_loc_t src_root_loc; /* Object location of source file root group */ + if (src_file) { + H5G_loc_t src_root_loc; /* Object location of source file root group */ /* Set up the root group in the destination file */ - if(NULL == (src_root_loc.oloc = H5G_oloc(H5G_rootof(src_file)))) + if (NULL == (src_root_loc.oloc = H5G_oloc(H5G_rootof(src_file)))) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (src_root_loc.path = H5G_nameof(H5G_rootof(src_file)))) + if (NULL == (src_root_loc.path = H5G_nameof(H5G_rootof(src_file)))) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Try opening the source dataset */ - source_dset->dset = H5D__open_name(&src_root_loc, source_dset->dset_name, vdset->shared->layout.storage.u.virt.source_dapl); + source_dset->dset = H5D__open_name(&src_root_loc, source_dset->dset_name, + vdset->shared->layout.storage.u.virt.source_dapl); /* Dataset does not exist */ - if(NULL == source_dset->dset) { + if (NULL == source_dset->dset) { /* Reset the error stack */ H5E_clear_stack(NULL); @@ -969,24 +948,23 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, source_dset->dset_exists = TRUE; /* Patch the source selection if necessary */ - if(virtual_ent->source_space_status != H5O_VIRTUAL_STATUS_CORRECT) { - if(H5S_extent_copy(virtual_ent->source_select, source_dset->dset->shared->space) < 0) + if (virtual_ent->source_space_status != H5O_VIRTUAL_STATUS_CORRECT) { + if (H5S_extent_copy(virtual_ent->source_select, source_dset->dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy source dataspace extent") virtual_ent->source_space_status = H5O_VIRTUAL_STATUS_CORRECT; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ done: /* Release resources */ - if(src_file_open) - if(H5F_efc_close(vdset->oloc.file, src_file) < 0) + if (src_file_open) + if (H5F_efc_close(vdset->oloc.file, src_file) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "can't close source file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_open_source_dset() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_reset_source_dset * @@ -1000,10 +978,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, - H5O_storage_virtual_srcdset_t *source_dset) +H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t * virtual_ent, + H5O_storage_virtual_srcdset_t *source_dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1011,55 +989,51 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, HDassert(source_dset); /* Free dataset */ - if(source_dset->dset) { - if(H5D_close(source_dset->dset) < 0) + if (source_dset->dset) { + if (H5D_close(source_dset->dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") source_dset->dset = NULL; } /* end if */ /* Free file name */ - if(virtual_ent->parsed_source_file_name - && (source_dset->file_name - != virtual_ent->parsed_source_file_name->name_segment)) + if (virtual_ent->parsed_source_file_name && + (source_dset->file_name != virtual_ent->parsed_source_file_name->name_segment)) source_dset->file_name = (char *)H5MM_xfree(source_dset->file_name); else - HDassert((source_dset->file_name == virtual_ent->source_file_name) - || (virtual_ent->parsed_source_file_name - && (source_dset->file_name - == virtual_ent->parsed_source_file_name->name_segment)) - || !source_dset->file_name); + HDassert((source_dset->file_name == virtual_ent->source_file_name) || + (virtual_ent->parsed_source_file_name && + (source_dset->file_name == virtual_ent->parsed_source_file_name->name_segment)) || + !source_dset->file_name); /* Free dataset name */ - if(virtual_ent->parsed_source_dset_name - && (source_dset->dset_name - != virtual_ent->parsed_source_dset_name->name_segment)) + if (virtual_ent->parsed_source_dset_name && + (source_dset->dset_name != virtual_ent->parsed_source_dset_name->name_segment)) source_dset->dset_name = (char *)H5MM_xfree(source_dset->dset_name); else - HDassert((source_dset->dset_name == virtual_ent->source_dset_name) - || (virtual_ent->parsed_source_dset_name - && (source_dset->dset_name - == virtual_ent->parsed_source_dset_name->name_segment)) - || !source_dset->dset_name); + HDassert((source_dset->dset_name == virtual_ent->source_dset_name) || + (virtual_ent->parsed_source_dset_name && + (source_dset->dset_name == virtual_ent->parsed_source_dset_name->name_segment)) || + !source_dset->dset_name); /* Free clipped virtual selection */ - if(source_dset->clipped_virtual_select) { - if(source_dset->clipped_virtual_select != source_dset->virtual_select) - if(H5S_close(source_dset->clipped_virtual_select) < 0) + if (source_dset->clipped_virtual_select) { + if (source_dset->clipped_virtual_select != source_dset->virtual_select) + if (H5S_close(source_dset->clipped_virtual_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual selection") source_dset->clipped_virtual_select = NULL; } /* end if */ /* Free virtual selection */ - if(source_dset->virtual_select) { - if(H5S_close(source_dset->virtual_select) < 0) + if (source_dset->virtual_select) { + if (H5S_close(source_dset->virtual_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection") source_dset->virtual_select = NULL; } /* end if */ /* Free clipped source selection */ - if(source_dset->clipped_source_select) { - if(source_dset->clipped_source_select != virtual_ent->source_select) - if(H5S_close(source_dset->clipped_source_select) < 0) + if (source_dset->clipped_source_select) { + if (source_dset->clipped_source_select != virtual_ent->source_select) + if (H5S_close(source_dset->clipped_source_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source selection") source_dset->clipped_source_select = NULL; } /* end if */ @@ -1073,7 +1047,6 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_reset_source_dset() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_str_append * @@ -1088,10 +1061,9 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, - size_t *buf_size) +H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, size_t *buf_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1104,36 +1076,35 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, HDassert(buf_size); /* Allocate or extend buffer if necessary */ - if(!*buf) { + if (!*buf) { HDassert(!*p); HDassert(*buf_size == 0); /* Allocate buffer */ - if(NULL == (*buf = (char *)H5MM_malloc(src_len + (size_t)1))) + if (NULL == (*buf = (char *)H5MM_malloc(src_len + (size_t)1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") *buf_size = src_len + (size_t)1; - *p = *buf; + *p = *buf; } /* end if */ else { size_t p_offset = (size_t)(*p - *buf); /* Offset of p within buf */ /* Extend buffer if necessary */ - if((p_offset + src_len + (size_t)1) > *buf_size) { - char *tmp_buf; + if ((p_offset + src_len + (size_t)1) > *buf_size) { + char * tmp_buf; size_t tmp_buf_size; /* Calculate new size of buffer */ - tmp_buf_size = MAX(p_offset + src_len + (size_t)1, - *buf_size * (size_t)2); + tmp_buf_size = MAX(p_offset + src_len + (size_t)1, *buf_size * (size_t)2); /* Reallocate buffer */ - if(NULL == (tmp_buf = (char *)H5MM_realloc(*buf, tmp_buf_size))) + if (NULL == (tmp_buf = (char *)H5MM_realloc(*buf, tmp_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to reallocate name segment buffer") - *buf = tmp_buf; + *buf = tmp_buf; *buf_size = tmp_buf_size; - *p = *buf + p_offset; + *p = *buf + p_offset; } /* end if */ - } /* end else */ + } /* end else */ /* Copy string to *p. Note that since src in not NULL terminated, we must * use memcpy */ @@ -1149,7 +1120,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5D__virtual_str_append() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_parse_source_name * @@ -1163,20 +1133,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_virtual_parse_source_name(const char *source_name, - H5O_storage_virtual_name_seg_t **parsed_name, size_t *static_strlen, - size_t *nsubs) +H5D_virtual_parse_source_name(const char *source_name, H5O_storage_virtual_name_seg_t **parsed_name, + size_t *static_strlen, size_t *nsubs) { - H5O_storage_virtual_name_seg_t *tmp_parsed_name = NULL; + H5O_storage_virtual_name_seg_t * tmp_parsed_name = NULL; H5O_storage_virtual_name_seg_t **tmp_parsed_name_p = &tmp_parsed_name; - size_t tmp_static_strlen; - size_t tmp_strlen; - size_t tmp_nsubs = 0; - const char *p; - const char *pct; - char *name_seg_p = NULL; - size_t name_seg_size = 0; - herr_t ret_value = SUCCEED; /* Return value */ + size_t tmp_static_strlen; + size_t tmp_strlen; + size_t tmp_nsubs = 0; + const char * p; + const char * pct; + char * name_seg_p = NULL; + size_t name_seg_size = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1187,38 +1156,40 @@ H5D_virtual_parse_source_name(const char *source_name, HDassert(nsubs); /* Initialize p and tmp_static_strlen */ - p = source_name; + p = source_name; tmp_static_strlen = tmp_strlen = HDstrlen(source_name); /* Iterate over name */ /* Note this will not work with UTF-8! We should support this eventually * -NAF 5/18/2015 */ - while((pct = HDstrchr(p, '%'))) { + while ((pct = HDstrchr(p, '%'))) { HDassert(pct >= p); /* Allocate name segment struct if necessary */ - if(!*tmp_parsed_name_p) - if(NULL == (*tmp_parsed_name_p = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) + if (!*tmp_parsed_name_p) + if (NULL == (*tmp_parsed_name_p = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") /* Check for type of format specifier */ - if(pct[1] == 'b') { + if (pct[1] == 'b') { /* Check for blank string before specifier */ - if(pct != p) + if (pct != p) /* Append string to name segment */ - if(H5D__virtual_str_append(p, (size_t)(pct - p), &name_seg_p, &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) + if (H5D__virtual_str_append(p, (size_t)(pct - p), &name_seg_p, + &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to append name segment") /* Update other variables */ tmp_parsed_name_p = &(*tmp_parsed_name_p)->next; tmp_static_strlen -= 2; tmp_nsubs++; - name_seg_p = NULL; + name_seg_p = NULL; name_seg_size = 0; } /* end if */ - else if(pct[1] == '%') { + else if (pct[1] == '%') { /* Append string to name segment (include first '%') */ - if(H5D__virtual_str_append(p, (size_t)(pct - p) + (size_t)1, &name_seg_p, &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) + if (H5D__virtual_str_append(p, (size_t)(pct - p) + (size_t)1, &name_seg_p, + &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to append name segment") /* Update other variables */ @@ -1232,32 +1203,33 @@ H5D_virtual_parse_source_name(const char *source_name, /* Copy last segment of name, if any, unless the parsed name was not * allocated */ - if(tmp_parsed_name) { + if (tmp_parsed_name) { HDassert(p >= source_name); - if(*p == '\0') + if (*p == '\0') HDassert((size_t)(p - source_name) == tmp_strlen); else { HDassert((size_t)(p - source_name) < tmp_strlen); /* Allocate name segment struct if necessary */ - if(!*tmp_parsed_name_p) - if(NULL == (*tmp_parsed_name_p = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) + if (!*tmp_parsed_name_p) + if (NULL == (*tmp_parsed_name_p = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") /* Append string to name segment */ - if(H5D__virtual_str_append(p, tmp_strlen - (size_t)(p - source_name), &name_seg_p, &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) + if (H5D__virtual_str_append(p, tmp_strlen - (size_t)(p - source_name), &name_seg_p, + &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to append name segment") } /* end else */ - } /* end if */ + } /* end if */ /* Set return values */ - *parsed_name = tmp_parsed_name; + *parsed_name = tmp_parsed_name; tmp_parsed_name = NULL; - *static_strlen = tmp_static_strlen; - *nsubs = tmp_nsubs; + *static_strlen = tmp_static_strlen; + *nsubs = tmp_nsubs; done: - if(tmp_parsed_name) { + if (tmp_parsed_name) { HDassert(ret_value < 0); H5D_virtual_free_parsed_name(tmp_parsed_name); } /* end if */ @@ -1265,7 +1237,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_parse_source_name() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_copy_parsed_name * @@ -1279,13 +1250,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, - H5O_storage_virtual_name_seg_t *src) +H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, H5O_storage_virtual_name_seg_t *src) { - H5O_storage_virtual_name_seg_t *tmp_dst = NULL; - H5O_storage_virtual_name_seg_t *p_src = src; - H5O_storage_virtual_name_seg_t **p_dst = &tmp_dst; - herr_t ret_value = SUCCEED; + H5O_storage_virtual_name_seg_t * tmp_dst = NULL; + H5O_storage_virtual_name_seg_t * p_src = src; + H5O_storage_virtual_name_seg_t **p_dst = &tmp_dst; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1293,14 +1263,14 @@ H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, HDassert(dst); /* Walk over parsed name, duplicating it */ - while(p_src) { + while (p_src) { /* Allocate name segment struct */ - if(NULL == (*p_dst = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) + if (NULL == (*p_dst = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") /* Duplicate name segment */ - if(p_src->name_segment) { - if(NULL == ((*p_dst)->name_segment = H5MM_strdup(p_src->name_segment))) + if (p_src->name_segment) { + if (NULL == ((*p_dst)->name_segment = H5MM_strdup(p_src->name_segment))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to duplicate name segment") } /* end if */ @@ -1310,11 +1280,11 @@ H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, } /* end while */ /* Set dst */ - *dst = tmp_dst; + *dst = tmp_dst; tmp_dst = NULL; done: - if(tmp_dst) { + if (tmp_dst) { HDassert(ret_value < 0); H5D_virtual_free_parsed_name(tmp_dst); } /* end if */ @@ -1322,7 +1292,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_copy_parsed_name() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_free_parsed_name * @@ -1339,12 +1308,12 @@ herr_t H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg) { H5O_storage_virtual_name_seg_t *next_seg; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Walk name segments, freeing them */ - while(name_seg) { + while (name_seg) { (void)H5MM_xfree(name_seg->name_segment); next_seg = name_seg->next; (void)H5FL_FREE(H5O_storage_virtual_name_seg_t, name_seg); @@ -1355,7 +1324,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_free_parsed_name() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_build_source_name * @@ -1369,12 +1337,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_build_source_name(char *source_name, - const H5O_storage_virtual_name_seg_t *parsed_name, size_t static_strlen, - size_t nsubs, hsize_t blockno, char **built_name) +H5D__virtual_build_source_name(char *source_name, const H5O_storage_virtual_name_seg_t *parsed_name, + size_t static_strlen, size_t nsubs, hsize_t blockno, char **built_name) { - char *tmp_name = NULL; /* Name buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + char * tmp_name = NULL; /* Name buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1383,44 +1350,44 @@ H5D__virtual_build_source_name(char *source_name, HDassert(built_name); /* Check for static name */ - if(nsubs == 0) { - if(parsed_name) + if (nsubs == 0) { + if (parsed_name) *built_name = parsed_name->name_segment; else *built_name = source_name; } /* end if */ else { const H5O_storage_virtual_name_seg_t *name_seg = parsed_name; - char *p; - hsize_t blockno_down = blockno; - size_t blockno_len = 1; - size_t name_len; - size_t name_len_rem; - size_t seg_len; - size_t nsubs_rem = nsubs; + char * p; + hsize_t blockno_down = blockno; + size_t blockno_len = 1; + size_t name_len; + size_t name_len_rem; + size_t seg_len; + size_t nsubs_rem = nsubs; HDassert(parsed_name); /* Calculate length of printed block number */ do { blockno_down /= (hsize_t)10; - if(blockno_down == 0) + if (blockno_down == 0) break; blockno_len++; - } while(1); + } while (1); /* Calculate length of name buffer */ name_len_rem = name_len = static_strlen + (nsubs * blockno_len) + (size_t)1; /* Allocate name buffer */ - if(NULL == (tmp_name = (char *)H5MM_malloc(name_len))) + if (NULL == (tmp_name = (char *)H5MM_malloc(name_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name buffer") p = tmp_name; /* Build name */ do { /* Add name segment */ - if(name_seg->name_segment) { + if (name_seg->name_segment) { seg_len = HDstrlen(name_seg->name_segment); HDassert(seg_len > 0); HDassert(seg_len < name_len_rem); @@ -1430,9 +1397,9 @@ H5D__virtual_build_source_name(char *source_name, } /* end if */ /* Add block number */ - if(nsubs_rem > 0) { + if (nsubs_rem > 0) { HDassert(blockno_len < name_len_rem); - if(HDsnprintf(p, name_len_rem, "%llu", (long long unsigned)blockno) < 0) + if (HDsnprintf(p, name_len_rem, "%llu", (long long unsigned)blockno) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write block number to string") name_len_rem -= blockno_len; p += blockno_len; @@ -1441,15 +1408,15 @@ H5D__virtual_build_source_name(char *source_name, /* Advance name_seg */ name_seg = name_seg->next; - } while(name_seg); + } while (name_seg); /* Assign built_name */ *built_name = tmp_name; - tmp_name = NULL; + tmp_name = NULL; } /* end else */ done: - if(tmp_name) { + if (tmp_name) { HDassert(ret_value < 0); H5MM_free(tmp_name); } /* end if */ @@ -1457,7 +1424,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_build_source_name() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_set_extent_unlim * @@ -1477,13 +1443,13 @@ herr_t H5D__virtual_set_extent_unlim(const H5D_t *dset) { H5O_storage_virtual_t *storage; - hsize_t new_dims[H5S_MAX_RANK]; - hsize_t curr_dims[H5S_MAX_RANK]; - hsize_t clip_size; - int rank; - hbool_t changed = FALSE; /* Whether the VDS extent changed */ - size_t i, j; - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t new_dims[H5S_MAX_RANK]; + hsize_t curr_dims[H5S_MAX_RANK]; + hsize_t clip_size; + int rank; + hbool_t changed = FALSE; /* Whether the VDS extent changed */ + size_t i, j; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1494,48 +1460,52 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) HDassert((storage->view == H5D_VDS_FIRST_MISSING) || (storage->view == H5D_VDS_LAST_AVAILABLE)); /* Get rank of VDS */ - if((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Initialize new_dims to HSIZE_UNDEF */ - for(i = 0; i < (size_t)rank; i++) + for (i = 0; i < (size_t)rank; i++) new_dims[i] = HSIZE_UNDEF; /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for unlimited dimension */ - if(storage->list[i].unlim_dim_virtual >= 0) { + if (storage->list[i].unlim_dim_virtual >= 0) { /* Check for "printf" source dataset resolution */ - if(storage->list[i].unlim_dim_source >= 0 ) { + if (storage->list[i].unlim_dim_source >= 0) { /* Non-printf mapping */ /* Open source dataset */ - if(!storage->list[i].source_dset.dset) - if(H5D__virtual_open_source_dset(dset, &storage->list[i], &storage->list[i].source_dset) < 0) + if (!storage->list[i].source_dset.dset) + if (H5D__virtual_open_source_dset(dset, &storage->list[i], + &storage->list[i].source_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") /* Check if source dataset is open */ - if(storage->list[i].source_dset.dset) { + if (storage->list[i].source_dset.dset) { /* Retrieve current source dataset extent and patch mapping */ - if(H5S_extent_copy(storage->list[i].source_select, storage->list[i].source_dset.dset->shared->space) < 0) + if (H5S_extent_copy(storage->list[i].source_select, + storage->list[i].source_dset.dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy source dataspace extent") /* Get source space dimenstions */ - if(H5S_get_simple_extent_dims(storage->list[i].source_select, curr_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(storage->list[i].source_select, curr_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get source space dimensions") /* Check if the source extent in the unlimited dimension * changed since the last time the VDS extent/mapping * was updated */ - if(curr_dims[storage->list[i].unlim_dim_source] - == storage->list[i].unlim_extent_source) + if (curr_dims[storage->list[i].unlim_dim_source] == storage->list[i].unlim_extent_source) /* Use cached result for clip size */ clip_size = storage->list[i].clip_size_virtual; else { /* Get size that virtual selection would be clipped to * to match size of source selection within source * extent */ - clip_size = H5S_hyper_get_clip_extent_match(storage->list[i].source_dset.virtual_select, storage->list[i].source_select, curr_dims[storage->list[i].unlim_dim_source], storage->view == H5D_VDS_FIRST_MISSING); + clip_size = H5S_hyper_get_clip_extent_match( + storage->list[i].source_dset.virtual_select, storage->list[i].source_select, + curr_dims[storage->list[i].unlim_dim_source], + storage->view == H5D_VDS_FIRST_MISSING); /* If we are setting the extent by the last available * data, clip virtual_select and source_select. Note @@ -1544,144 +1514,183 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) * already be clipped to the correct size. Likewise, * if we used the cached clip_size the source selection * will already be correct. */ - if(storage->view == H5D_VDS_LAST_AVAILABLE) { - if(clip_size != storage->list[i].clip_size_virtual) { + if (storage->view == H5D_VDS_LAST_AVAILABLE) { + if (clip_size != storage->list[i].clip_size_virtual) { /* Close previous clipped virtual selection, if * any */ - if(storage->list[i].source_dset.clipped_virtual_select) { - HDassert(storage->list[i].source_dset.clipped_virtual_select - != storage->list[i].source_dset.virtual_select); - if(H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].source_dset.clipped_virtual_select) { + HDassert(storage->list[i].source_dset.clipped_virtual_select != + storage->list[i].source_dset.virtual_select); + if (H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") } /* end if */ /* Copy virtual selection */ - if(NULL == (storage->list[i].source_dset.clipped_virtual_select = H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") + if (NULL == (storage->list[i].source_dset.clipped_virtual_select = H5S_copy( + storage->list[i].source_dset.virtual_select, FALSE, TRUE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, + "unable to copy virtual selection") /* Clip virtual selection */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, clip_size)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, + clip_size)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "failed to clip unlimited selection") } /* end if */ /* Close previous clipped source selection, if any */ - if(storage->list[i].source_dset.clipped_source_select) { - HDassert(storage->list[i].source_dset.clipped_source_select - != storage->list[i].source_select); - if(H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].source_dset.clipped_source_select) { + HDassert(storage->list[i].source_dset.clipped_source_select != + storage->list[i].source_select); + if (H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") } /* end if */ /* Copy source selection */ - if(NULL == (storage->list[i].source_dset.clipped_source_select = H5S_copy(storage->list[i].source_select, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") + if (NULL == (storage->list[i].source_dset.clipped_source_select = + H5S_copy(storage->list[i].source_select, FALSE, TRUE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, + "unable to copy source selection") /* Clip source selection */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, curr_dims[storage->list[i].unlim_dim_source])) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, + curr_dims[storage->list[i].unlim_dim_source])) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "failed to clip unlimited selection") } /* end if */ /* Update cached values unlim_extent_source and * clip_size_virtual */ storage->list[i].unlim_extent_source = curr_dims[storage->list[i].unlim_dim_source]; - storage->list[i].clip_size_virtual = clip_size; + storage->list[i].clip_size_virtual = clip_size; } /* end else */ - } /* end if */ + } /* end if */ else clip_size = 0; } /* end if */ else { /* printf mapping */ - hsize_t first_missing = 0; /* First missing dataset in the current block of missing datasets */ + hsize_t first_missing = + 0; /* First missing dataset in the current block of missing datasets */ /* Search for source datasets */ HDassert(storage->printf_gap != HSIZE_UNDEF); - for(j = 0; j <= (storage->printf_gap + first_missing); j++) { + for (j = 0; j <= (storage->printf_gap + first_missing); j++) { /* Check for running out of space in sub_dset array */ - if(j >= (hsize_t)storage->list[i].sub_dset_nalloc) { - if(storage->list[i].sub_dset_nalloc == 0) { + if (j >= (hsize_t)storage->list[i].sub_dset_nalloc) { + if (storage->list[i].sub_dset_nalloc == 0) { /* Allocate sub_dset */ - if(NULL == (storage->list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_calloc(H5D_VIRTUAL_DEF_SUB_DSET_SIZE * sizeof(H5O_storage_virtual_srcdset_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate sub dataset array") + if (NULL == + (storage->list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_calloc( + H5D_VIRTUAL_DEF_SUB_DSET_SIZE * sizeof(H5O_storage_virtual_srcdset_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to allocate sub dataset array") storage->list[i].sub_dset_nalloc = H5D_VIRTUAL_DEF_SUB_DSET_SIZE; } /* end if */ else { H5O_storage_virtual_srcdset_t *tmp_sub_dset; /* Extend sub_dset */ - if(NULL == (tmp_sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_realloc(storage->list[i].sub_dset, 2 * storage->list[i].sub_dset_nalloc * sizeof(H5O_storage_virtual_srcdset_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend sub dataset array") + if (NULL == + (tmp_sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_realloc( + storage->list[i].sub_dset, 2 * storage->list[i].sub_dset_nalloc * + sizeof(H5O_storage_virtual_srcdset_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to extend sub dataset array") storage->list[i].sub_dset = tmp_sub_dset; /* Clear new space in sub_dset */ - (void)HDmemset(&storage->list[i].sub_dset[storage->list[i].sub_dset_nalloc], 0, storage->list[i].sub_dset_nalloc * sizeof(H5O_storage_virtual_srcdset_t)); + (void)HDmemset(&storage->list[i].sub_dset[storage->list[i].sub_dset_nalloc], 0, + storage->list[i].sub_dset_nalloc * + sizeof(H5O_storage_virtual_srcdset_t)); /* Update sub_dset_nalloc */ storage->list[i].sub_dset_nalloc *= 2; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the dataset was already opened */ - if(storage->list[i].sub_dset[j].dset_exists) + if (storage->list[i].sub_dset[j].dset_exists) first_missing = j + 1; else { /* Resolve file name */ - if(!storage->list[i].sub_dset[j].file_name) - if(H5D__virtual_build_source_name(storage->list[i].source_file_name, storage->list[i].parsed_source_file_name, storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, &storage->list[i].sub_dset[j].file_name) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source file name") + if (!storage->list[i].sub_dset[j].file_name) + if (H5D__virtual_build_source_name(storage->list[i].source_file_name, + storage->list[i].parsed_source_file_name, + storage->list[i].psfn_static_strlen, + storage->list[i].psfn_nsubs, j, + &storage->list[i].sub_dset[j].file_name) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to build source file name") /* Resolve dset name */ - if(!storage->list[i].sub_dset[j].dset_name) - if(H5D__virtual_build_source_name(storage->list[i].source_dset_name, storage->list[i].parsed_source_dset_name, storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, &storage->list[i].sub_dset[j].dset_name) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source dataset name") + if (!storage->list[i].sub_dset[j].dset_name) + if (H5D__virtual_build_source_name(storage->list[i].source_dset_name, + storage->list[i].parsed_source_dset_name, + storage->list[i].psdn_static_strlen, + storage->list[i].psdn_nsubs, j, + &storage->list[i].sub_dset[j].dset_name) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to build source dataset name") /* Resolve virtual selection for block */ - if(!storage->list[i].sub_dset[j].virtual_select) - if(NULL == (storage->list[i].sub_dset[j].virtual_select = H5S_hyper_get_unlim_block(storage->list[i].source_dset.virtual_select, j))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get block in unlimited selection") + if (!storage->list[i].sub_dset[j].virtual_select) + if (NULL == + (storage->list[i].sub_dset[j].virtual_select = H5S_hyper_get_unlim_block( + storage->list[i].source_dset.virtual_select, j))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to get block in unlimited selection") /* Initialize clipped selections */ - if(!storage->list[i].sub_dset[j].clipped_source_select) - storage->list[i].sub_dset[j].clipped_source_select = storage->list[i].source_select; - if(!storage->list[i].sub_dset[j].clipped_virtual_select) - storage->list[i].sub_dset[j].clipped_virtual_select = storage->list[i].sub_dset[j].virtual_select; + if (!storage->list[i].sub_dset[j].clipped_source_select) + storage->list[i].sub_dset[j].clipped_source_select = + storage->list[i].source_select; + if (!storage->list[i].sub_dset[j].clipped_virtual_select) + storage->list[i].sub_dset[j].clipped_virtual_select = + storage->list[i].sub_dset[j].virtual_select; /* Open source dataset */ - if(H5D__virtual_open_source_dset(dset, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) + if (H5D__virtual_open_source_dset(dset, &storage->list[i], + &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") - if(storage->list[i].sub_dset[j].dset) { + if (storage->list[i].sub_dset[j].dset) { /* Update first_missing */ first_missing = j + 1; /* Close source dataset so we don't have huge * numbers of datasets open */ - if(H5D_close(storage->list[i].sub_dset[j].dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") + if (H5D_close(storage->list[i].sub_dset[j].dset) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to close source dataset") storage->list[i].sub_dset[j].dset = NULL; } /* end if */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ /* Check if the size changed */ - if((first_missing == (hsize_t)storage->list[i].sub_dset_nused) - && (storage->list[i].clip_size_virtual != HSIZE_UNDEF)) + if ((first_missing == (hsize_t)storage->list[i].sub_dset_nused) && + (storage->list[i].clip_size_virtual != HSIZE_UNDEF)) /* Use cached clip_size */ clip_size = storage->list[i].clip_size_virtual; else { /* Check for no datasets */ - if(first_missing == 0) + if (first_missing == 0) /* Set clip size to 0 */ clip_size = (hsize_t)0; else { - hsize_t bounds_start[H5S_MAX_RANK]; - hsize_t bounds_end[H5S_MAX_RANK]; + hsize_t bounds_start[H5S_MAX_RANK]; + hsize_t bounds_end[H5S_MAX_RANK]; /* Get clip size from selection */ - if(storage->view == H5D_VDS_LAST_AVAILABLE) { + if (storage->view == H5D_VDS_LAST_AVAILABLE) { /* Get bounds from last valid virtual selection */ - if(H5S_SELECT_BOUNDS(storage->list[i].sub_dset[first_missing - (hsize_t)1].virtual_select, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS( + storage->list[i].sub_dset[first_missing - (hsize_t)1].virtual_select, + bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Set clip_size to bounds_end in unlimited @@ -1691,113 +1700,121 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) else { /* Get bounds from first missing virtual selection */ - if(H5S_SELECT_BOUNDS(storage->list[i].sub_dset[first_missing].virtual_select, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS(storage->list[i].sub_dset[first_missing].virtual_select, + bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Set clip_size to bounds_start in unlimited * dimension */ clip_size = bounds_start[storage->list[i].unlim_dim_virtual]; } /* end else */ - } /* end else */ + } /* end else */ /* Set sub_dset_nused and clip_size_virtual */ - storage->list[i].sub_dset_nused = (size_t)first_missing; + storage->list[i].sub_dset_nused = (size_t)first_missing; storage->list[i].clip_size_virtual = clip_size; } /* end else */ - } /* end else */ + } /* end else */ /* Update new_dims */ - if((new_dims[storage->list[i].unlim_dim_virtual] == HSIZE_UNDEF) - || (storage->view == H5D_VDS_FIRST_MISSING ? (clip_size < (hsize_t)new_dims[storage->list[i].unlim_dim_virtual]) - : (clip_size > (hsize_t)new_dims[storage->list[i].unlim_dim_virtual]))) + if ((new_dims[storage->list[i].unlim_dim_virtual] == HSIZE_UNDEF) || + (storage->view == H5D_VDS_FIRST_MISSING + ? (clip_size < (hsize_t)new_dims[storage->list[i].unlim_dim_virtual]) + : (clip_size > (hsize_t)new_dims[storage->list[i].unlim_dim_virtual]))) new_dims[storage->list[i].unlim_dim_virtual] = clip_size; } /* end if */ /* Get current VDS dimensions */ - if(H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions") /* Calculate new extent */ - for(i = 0; i < (size_t)rank; i++) { - if(new_dims[i] == HSIZE_UNDEF) + for (i = 0; i < (size_t)rank; i++) { + if (new_dims[i] == HSIZE_UNDEF) new_dims[i] = curr_dims[i]; - else if(new_dims[i] < storage->min_dims[i]) + else if (new_dims[i] < storage->min_dims[i]) new_dims[i] = storage->min_dims[i]; - if(new_dims[i] != curr_dims[i]) + if (new_dims[i] != curr_dims[i]) changed = TRUE; } /* end for */ /* Update extent if it changed */ - if(changed) { + if (changed) { /* Update VDS extent */ - if(H5S_set_extent(dset->shared->space, new_dims) < 0) + if (H5S_set_extent(dset->shared->space, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") /* Mark the space as dirty, for later writing to the file */ - if(H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR) - if(H5D__mark(dset, H5D_MARK_SPACE) < 0) + if (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR) + if (H5D__mark(dset, H5D_MARK_SPACE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark dataspace as dirty") } /* end if */ /* If we did not change the VDS dimensions, there is nothing more to update */ - if(changed || (!storage->init && (storage->view == H5D_VDS_FIRST_MISSING))) { + if (changed || (!storage->init && (storage->view == H5D_VDS_FIRST_MISSING))) { /* Iterate over mappings again to update source selections and virtual * mapping extents */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { /* If there is an unlimited dimension, we are setting extent by the * minimum of mappings, and the virtual extent in the unlimited * dimension has changed since the last time the VDS extent/mapping * was updated, we must adjust the selections */ - if((storage->list[i].unlim_dim_virtual >= 0) - && (storage->view == H5D_VDS_FIRST_MISSING) - && (new_dims[storage->list[i].unlim_dim_virtual] - != storage->list[i].unlim_extent_virtual)) { + if ((storage->list[i].unlim_dim_virtual >= 0) && (storage->view == H5D_VDS_FIRST_MISSING) && + (new_dims[storage->list[i].unlim_dim_virtual] != storage->list[i].unlim_extent_virtual)) { /* Check for "printf" style mapping */ - if(storage->list[i].unlim_dim_source >= 0) { + if (storage->list[i].unlim_dim_source >= 0) { /* Non-printf mapping */ /* Close previous clipped virtual selection, if any */ - if(storage->list[i].source_dset.clipped_virtual_select) { - HDassert(storage->list[i].source_dset.clipped_virtual_select - != storage->list[i].source_dset.virtual_select); - if(H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].source_dset.clipped_virtual_select) { + HDassert(storage->list[i].source_dset.clipped_virtual_select != + storage->list[i].source_dset.virtual_select); + if (H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") } /* end if */ /* Copy virtual selection */ - if(NULL == (storage->list[i].source_dset.clipped_virtual_select = H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) + if (NULL == (storage->list[i].source_dset.clipped_virtual_select = + H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Clip space to virtual extent */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, new_dims[storage->list[i].unlim_dim_source])) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, + new_dims[storage->list[i].unlim_dim_source])) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* Get size that source selection will be clipped to to * match size of virtual selection */ - clip_size = H5S_hyper_get_clip_extent(storage->list[i].source_select, storage->list[i].source_dset.clipped_virtual_select, FALSE); + clip_size = + H5S_hyper_get_clip_extent(storage->list[i].source_select, + storage->list[i].source_dset.clipped_virtual_select, FALSE); /* Check if the clip size changed */ - if(clip_size != storage->list[i].clip_size_source) { + if (clip_size != storage->list[i].clip_size_source) { /* Close previous clipped source selection, if any */ - if(storage->list[i].source_dset.clipped_source_select) { - HDassert(storage->list[i].source_dset.clipped_source_select - != storage->list[i].source_select); - if(H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].source_dset.clipped_source_select) { + HDassert(storage->list[i].source_dset.clipped_source_select != + storage->list[i].source_select); + if (H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") } /* end if */ /* Copy source selection */ - if(NULL == (storage->list[i].source_dset.clipped_source_select = H5S_copy(storage->list[i].source_select, FALSE, TRUE))) + if (NULL == (storage->list[i].source_dset.clipped_source_select = + H5S_copy(storage->list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Clip source selection */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, clip_size)) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, + clip_size)) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* Update cached value clip_size_source */ storage->list[i].clip_size_source = clip_size; } /* end if */ - } /* end if */ + } /* end if */ else { /* printf mapping */ hsize_t first_inc_block; @@ -1805,32 +1822,38 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) /* Get index of first incomplete block in virtual * selection */ - first_inc_block = H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, new_dims[storage->list[i].unlim_dim_virtual], &partial_block); + first_inc_block = H5S_hyper_get_first_inc_block( + storage->list[i].source_dset.virtual_select, + new_dims[storage->list[i].unlim_dim_virtual], &partial_block); /* Iterate over sub datasets */ - for(j = 0; j < storage->list[i].sub_dset_nalloc; j++) { + for (j = 0; j < storage->list[i].sub_dset_nalloc; j++) { /* Close previous clipped source selection, if any */ - if(storage->list[i].sub_dset[j].clipped_source_select - != storage->list[i].source_select) { - if(storage->list[i].sub_dset[j].clipped_source_select) - if(H5S_close(storage->list[i].sub_dset[j].clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].sub_dset[j].clipped_source_select != + storage->list[i].source_select) { + if (storage->list[i].sub_dset[j].clipped_source_select) + if (H5S_close(storage->list[i].sub_dset[j].clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") /* Initialize clipped source selection to point to * base source selection */ - storage->list[i].sub_dset[j].clipped_source_select = storage->list[i].source_select; + storage->list[i].sub_dset[j].clipped_source_select = + storage->list[i].source_select; } /* end if */ /* Close previous clipped virtual selection, if any */ - if(storage->list[i].sub_dset[j].clipped_virtual_select - != storage->list[i].sub_dset[j].virtual_select) { - if(storage->list[i].sub_dset[j].clipped_virtual_select) - if(H5S_close(storage->list[i].sub_dset[j].clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].sub_dset[j].clipped_virtual_select != + storage->list[i].sub_dset[j].virtual_select) { + if (storage->list[i].sub_dset[j].clipped_virtual_select) + if (H5S_close(storage->list[i].sub_dset[j].clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") /* Initialize clipped virtual selection to point to * unclipped virtual selection */ - storage->list[i].sub_dset[j].clipped_virtual_select = storage->list[i].sub_dset[j].virtual_select; + storage->list[i].sub_dset[j].clipped_virtual_select = + storage->list[i].sub_dset[j].virtual_select; } /* end if */ /* Only initialize clipped selections if it is a @@ -1839,13 +1862,13 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) * source extent here. For unused blocks we will never * need clipped selections (until the extent is * recalculated in this function). */ - if(j >= (size_t)first_inc_block) { + if (j >= (size_t)first_inc_block) { /* Clear clipped source and virtual selections */ - storage->list[i].sub_dset[j].clipped_source_select = NULL; + storage->list[i].sub_dset[j].clipped_source_select = NULL; storage->list[i].sub_dset[j].clipped_virtual_select = NULL; } /* end if */ - } /* end for */ - } /* end else */ + } /* end for */ + } /* end else */ /* Update cached value unlim_extent_virtual */ storage->list[i].unlim_extent_virtual = new_dims[storage->list[i].unlim_dim_virtual]; @@ -1853,30 +1876,30 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) /* Update top level virtual_select and clipped_virtual_select * extents */ - if(H5S_set_extent(storage->list[i].source_dset.virtual_select, new_dims) < 0) + if (H5S_set_extent(storage->list[i].source_dset.virtual_select, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") - if((storage->list[i].source_dset.clipped_virtual_select - != storage->list[i].source_dset.virtual_select) - && storage->list[i].source_dset.clipped_virtual_select) - if(H5S_set_extent(storage->list[i].source_dset.clipped_virtual_select, new_dims) < 0) + if ((storage->list[i].source_dset.clipped_virtual_select != + storage->list[i].source_dset.virtual_select) && + storage->list[i].source_dset.clipped_virtual_select) + if (H5S_set_extent(storage->list[i].source_dset.clipped_virtual_select, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") /* Update sub dataset virtual_select and clipped_virtual_select * extents */ - for(j = 0; j < storage->list[i].sub_dset_nalloc; j++) - if(storage->list[i].sub_dset[j].virtual_select) { - if(H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, new_dims) < 0) + for (j = 0; j < storage->list[i].sub_dset_nalloc; j++) + if (storage->list[i].sub_dset[j].virtual_select) { + if (H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") - if((storage->list[i].sub_dset[j].clipped_virtual_select - != storage->list[i].sub_dset[j].virtual_select) - && storage->list[i].sub_dset[j].clipped_virtual_select) - if(H5S_set_extent(storage->list[i].sub_dset[j].clipped_virtual_select, new_dims) < 0) + if ((storage->list[i].sub_dset[j].clipped_virtual_select != + storage->list[i].sub_dset[j].virtual_select) && + storage->list[i].sub_dset[j].clipped_virtual_select) + if (H5S_set_extent(storage->list[i].sub_dset[j].clipped_virtual_select, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") } /* end if */ else HDassert(!storage->list[i].sub_dset[j].clipped_virtual_select); } /* end for */ - } /* end if */ + } /* end if */ /* Mark layout as fully initialized */ storage->init = TRUE; @@ -1885,7 +1908,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_set_extent_unlim() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_init_all * @@ -1905,11 +1927,11 @@ static herr_t H5D__virtual_init_all(const H5D_t *dset) { H5O_storage_virtual_t *storage; - hsize_t virtual_dims[H5S_MAX_RANK]; - hsize_t source_dims[H5S_MAX_RANK]; - hsize_t clip_size; - size_t i, j; - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t virtual_dims[H5S_MAX_RANK]; + hsize_t source_dims[H5S_MAX_RANK]; + hsize_t clip_size; + size_t i, j; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1920,147 +1942,178 @@ H5D__virtual_init_all(const H5D_t *dset) HDassert((storage->view == H5D_VDS_FIRST_MISSING) || (storage->view == H5D_VDS_LAST_AVAILABLE)); /* Get current VDS dimensions */ - if(H5S_get_simple_extent_dims(dset->shared->space, virtual_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(dset->shared->space, virtual_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions") /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for unlimited dimension */ - if(storage->list[i].unlim_dim_virtual >= 0) { + if (storage->list[i].unlim_dim_virtual >= 0) { /* Check for "printf" source dataset resolution */ - if(storage->list[i].unlim_dim_source >= 0 ) { + if (storage->list[i].unlim_dim_source >= 0) { /* Non-printf mapping */ /* Open source dataset */ - if(!storage->list[i].source_dset.dset) - if(H5D__virtual_open_source_dset(dset, &storage->list[i], &storage->list[i].source_dset) < 0) + if (!storage->list[i].source_dset.dset) + if (H5D__virtual_open_source_dset(dset, &storage->list[i], + &storage->list[i].source_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") /* Check if source dataset is open */ - if(storage->list[i].source_dset.dset) { + if (storage->list[i].source_dset.dset) { /* Retrieve current source dataset extent and patch mapping */ - if(H5S_extent_copy(storage->list[i].source_select, storage->list[i].source_dset.dset->shared->space) < 0) + if (H5S_extent_copy(storage->list[i].source_select, + storage->list[i].source_dset.dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy source dataspace extent") /* Get source space dimenstions */ - if(H5S_get_simple_extent_dims(storage->list[i].source_select, source_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(storage->list[i].source_select, source_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get source space dimensions") /* Get size that source selection would be clipped to to * match size of virtual selection */ - clip_size = H5S_hyper_get_clip_extent_match(storage->list[i].source_select, storage->list[i].source_dset.virtual_select, virtual_dims[storage->list[i].unlim_dim_virtual], FALSE); + clip_size = H5S_hyper_get_clip_extent_match( + storage->list[i].source_select, storage->list[i].source_dset.virtual_select, + virtual_dims[storage->list[i].unlim_dim_virtual], FALSE); /* Close previous clipped virtual selection, if any */ - if(storage->list[i].source_dset.clipped_virtual_select) { - HDassert(storage->list[i].source_dset.clipped_virtual_select - != storage->list[i].source_dset.virtual_select); - if(H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].source_dset.clipped_virtual_select) { + HDassert(storage->list[i].source_dset.clipped_virtual_select != + storage->list[i].source_dset.virtual_select); + if (H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") } /* end if */ /* Copy virtual selection */ - if(NULL == (storage->list[i].source_dset.clipped_virtual_select = H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) + if (NULL == (storage->list[i].source_dset.clipped_virtual_select = + H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Close previous clipped source selection, if any */ - if(storage->list[i].source_dset.clipped_source_select) { - HDassert(storage->list[i].source_dset.clipped_source_select - != storage->list[i].source_select); - if(H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].source_dset.clipped_source_select) { + HDassert(storage->list[i].source_dset.clipped_source_select != + storage->list[i].source_select); + if (H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") } /* end if */ /* Copy source selection */ - if(NULL == (storage->list[i].source_dset.clipped_source_select = H5S_copy(storage->list[i].source_select, FALSE, TRUE))) + if (NULL == (storage->list[i].source_dset.clipped_source_select = + H5S_copy(storage->list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Check if the clip size is within the current extent of * the source dataset */ - if(clip_size <= source_dims[storage->list[i].unlim_dim_source]) { + if (clip_size <= source_dims[storage->list[i].unlim_dim_source]) { /* Clip virtual selection to extent */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, virtual_dims[storage->list[i].unlim_dim_virtual])) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, + virtual_dims[storage->list[i].unlim_dim_virtual])) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* Clip source selection to clip_size */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, clip_size)) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, + clip_size)) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") } /* end if */ else { /* Get size that virtual selection will be clipped to to * match size of source selection within source extent */ - clip_size = H5S_hyper_get_clip_extent_match(storage->list[i].source_dset.virtual_select, storage->list[i].source_select, source_dims[storage->list[i].unlim_dim_source], FALSE); + clip_size = H5S_hyper_get_clip_extent_match( + storage->list[i].source_dset.virtual_select, storage->list[i].source_select, + source_dims[storage->list[i].unlim_dim_source], FALSE); /* Clip virtual selection to clip_size */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, clip_size)) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, + clip_size)) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* Clip source selection to extent */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, source_dims[storage->list[i].unlim_dim_source])) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, + source_dims[storage->list[i].unlim_dim_source])) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") } /* end else */ - } /* end if */ + } /* end if */ else { HDassert(!storage->list[i].source_dset.clipped_virtual_select); HDassert(!storage->list[i].source_dset.clipped_source_select); } /* end else */ - } /* end if */ + } /* end if */ else { /* printf mapping */ - size_t sub_dset_max; + size_t sub_dset_max; hbool_t partial_block; /* Get number of sub-source datasets in current extent */ - sub_dset_max = (size_t)H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, virtual_dims[storage->list[i].unlim_dim_virtual], &partial_block); - if(partial_block) + sub_dset_max = (size_t)H5S_hyper_get_first_inc_block( + storage->list[i].source_dset.virtual_select, + virtual_dims[storage->list[i].unlim_dim_virtual], &partial_block); + if (partial_block) sub_dset_max++; /* Allocate or grow the sub_dset array if necessary */ - if(!storage->list[i].sub_dset) { + if (!storage->list[i].sub_dset) { /* Allocate sub_dset array */ - if(NULL == (storage->list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_calloc(sub_dset_max * sizeof(H5O_storage_virtual_srcdset_t)))) + if (NULL == (storage->list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_calloc( + sub_dset_max * sizeof(H5O_storage_virtual_srcdset_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate sub dataset array") /* Update sub_dset_nalloc */ storage->list[i].sub_dset_nalloc = sub_dset_max; } /* end if */ - else if(sub_dset_max > storage->list[i].sub_dset_nalloc) { + else if (sub_dset_max > storage->list[i].sub_dset_nalloc) { H5O_storage_virtual_srcdset_t *tmp_sub_dset; /* Extend sub_dset array */ - if(NULL == (tmp_sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_realloc(storage->list[i].sub_dset, sub_dset_max * sizeof(H5O_storage_virtual_srcdset_t)))) + if (NULL == (tmp_sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_realloc( + storage->list[i].sub_dset, + sub_dset_max * sizeof(H5O_storage_virtual_srcdset_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend sub dataset array") storage->list[i].sub_dset = tmp_sub_dset; /* Clear new space in sub_dset */ - (void)HDmemset(&storage->list[i].sub_dset[storage->list[i].sub_dset_nalloc], 0, (sub_dset_max - storage->list[i].sub_dset_nalloc) * sizeof(H5O_storage_virtual_srcdset_t)); + (void)HDmemset(&storage->list[i].sub_dset[storage->list[i].sub_dset_nalloc], 0, + (sub_dset_max - storage->list[i].sub_dset_nalloc) * + sizeof(H5O_storage_virtual_srcdset_t)); /* Update sub_dset_nalloc */ storage->list[i].sub_dset_nalloc = sub_dset_max; } /* end if */ /* Iterate over sub dsets */ - for(j = 0; j < sub_dset_max; j++) { + for (j = 0; j < sub_dset_max; j++) { /* Resolve file name */ - if(!storage->list[i].sub_dset[j].file_name) - if(H5D__virtual_build_source_name(storage->list[i].source_file_name, storage->list[i].parsed_source_file_name, storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, &storage->list[i].sub_dset[j].file_name) < 0) + if (!storage->list[i].sub_dset[j].file_name) + if (H5D__virtual_build_source_name( + storage->list[i].source_file_name, storage->list[i].parsed_source_file_name, + storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, + &storage->list[i].sub_dset[j].file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source file name") /* Resolve dset name */ - if(!storage->list[i].sub_dset[j].dset_name) - if(H5D__virtual_build_source_name(storage->list[i].source_dset_name, storage->list[i].parsed_source_dset_name, storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, &storage->list[i].sub_dset[j].dset_name) < 0) + if (!storage->list[i].sub_dset[j].dset_name) + if (H5D__virtual_build_source_name( + storage->list[i].source_dset_name, storage->list[i].parsed_source_dset_name, + storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, + &storage->list[i].sub_dset[j].dset_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source dataset name") /* Resolve virtual selection for block */ - if(!storage->list[i].sub_dset[j].virtual_select) - if(NULL == (storage->list[i].sub_dset[j].virtual_select = H5S_hyper_get_unlim_block(storage->list[i].source_dset.virtual_select, j))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get block in unlimited selection") + if (!storage->list[i].sub_dset[j].virtual_select) + if (NULL == (storage->list[i].sub_dset[j].virtual_select = H5S_hyper_get_unlim_block( + storage->list[i].source_dset.virtual_select, j))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to get block in unlimited selection") /* Close previous clipped source selection, if any */ - if(storage->list[i].sub_dset[j].clipped_source_select != storage->list[i].source_select) { - if(storage->list[i].sub_dset[j].clipped_source_select) - if(H5S_close(storage->list[i].sub_dset[j].clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].sub_dset[j].clipped_source_select != + storage->list[i].source_select) { + if (storage->list[i].sub_dset[j].clipped_source_select) + if (H5S_close(storage->list[i].sub_dset[j].clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") /* Initialize clipped source selection to point to base * source selection */ @@ -2068,23 +2121,26 @@ H5D__virtual_init_all(const H5D_t *dset) } /* end if */ /* Close previous clipped virtual selection, if any */ - if(storage->list[i].sub_dset[j].clipped_virtual_select != storage->list[i].sub_dset[j].virtual_select) { - if(storage->list[i].sub_dset[j].clipped_virtual_select) - if(H5S_close(storage->list[i].sub_dset[j].clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].sub_dset[j].clipped_virtual_select != + storage->list[i].sub_dset[j].virtual_select) { + if (storage->list[i].sub_dset[j].clipped_virtual_select) + if (H5S_close(storage->list[i].sub_dset[j].clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") /* Initialize clipped virtual selection to point to * unclipped virtual selection */ - storage->list[i].sub_dset[j].clipped_virtual_select = storage->list[i].sub_dset[j].virtual_select; + storage->list[i].sub_dset[j].clipped_virtual_select = + storage->list[i].sub_dset[j].virtual_select; } /* end if */ /* Clear clipped selections if this is a partial block, * defer calculation of real clipped selections to * H5D__virtual_pre_io() as we may not have a valid source * extent here */ - if((j == (sub_dset_max - 1)) && partial_block) { + if ((j == (sub_dset_max - 1)) && partial_block) { /* Clear clipped source and virtual selections */ - storage->list[i].sub_dset[j].clipped_source_select = NULL; + storage->list[i].sub_dset[j].clipped_source_select = NULL; storage->list[i].sub_dset[j].clipped_virtual_select = NULL; } /* end else */ /* Note we do not need to open the source file, this will @@ -2094,7 +2150,7 @@ H5D__virtual_init_all(const H5D_t *dset) /* Update sub_dset_nused */ storage->list[i].sub_dset_nused = sub_dset_max; } /* end else */ - } /* end if */ + } /* end if */ else { /* Limited mapping, just make sure the clipped selections were * already set. Again, no need to open the source file. */ @@ -2109,7 +2165,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_init_all() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_init * @@ -2126,11 +2181,11 @@ done: herr_t H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) { - H5O_storage_virtual_t *storage; /* Convenience pointer */ - H5P_genplist_t *dapl; /* Data access property list object pointer */ - hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset (unused) */ - size_t i; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenience pointer */ + H5P_genplist_t * dapl; /* Data access property list object pointer */ + hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset (unused) */ + size_t i; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2140,8 +2195,10 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) HDassert(storage->list || (storage->list_nused == 0)); /* Check that the dimensions of the VDS are large enough */ - if(H5D_virtual_check_min_dims(dset) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual dataset dimensions not large enough to contain all limited dimensions in all selections") + if (H5D_virtual_check_min_dims(dset) < 0) + HGOTO_ERROR( + H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual dataset dimensions not large enough to contain all limited dimensions in all selections") /* Patch the virtual selection dataspaces. Note we always patch the space * status because this layout could be from an old version held in the @@ -2151,11 +2208,11 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) * remove offset from selections. We only have to update * source_space_status and virtual_space_status because others will be based * on these and should therefore already have been normalized. */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { HDassert(storage->list[i].sub_dset_nalloc == 0); /* Patch extent */ - if(H5S_extent_copy(storage->list[i].source_dset.virtual_select, dset->shared->space) < 0) + if (H5S_extent_copy(storage->list[i].source_dset.virtual_select, dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy virtual dataspace extent") storage->list[i].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT; @@ -2163,36 +2220,36 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) storage->list[i].source_space_status = H5O_VIRTUAL_STATUS_INVALID; /* Normalize offsets, toss out old offset values */ - if(H5S_hyper_normalize_offset(storage->list[i].source_dset.virtual_select, old_offset) < 0) + if (H5S_hyper_normalize_offset(storage->list[i].source_dset.virtual_select, old_offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") - if(H5S_hyper_normalize_offset(storage->list[i].source_select, old_offset) < 0) + if (H5S_hyper_normalize_offset(storage->list[i].source_select, old_offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") } /* end for */ /* Get dataset access property list */ - if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + if (NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for dapl ID") /* Get view option */ - if(H5P_get(dapl, H5D_ACS_VDS_VIEW_NAME, &storage->view) < 0) + if (H5P_get(dapl, H5D_ACS_VDS_VIEW_NAME, &storage->view) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get virtual view option") /* Get printf gap if view is H5D_VDS_LAST_AVAILABLE, otherwise set to 0 */ - if(storage->view == H5D_VDS_LAST_AVAILABLE) { - if(H5P_get(dapl, H5D_ACS_VDS_PRINTF_GAP_NAME, &storage->printf_gap) < 0) + if (storage->view == H5D_VDS_LAST_AVAILABLE) { + if (H5P_get(dapl, H5D_ACS_VDS_PRINTF_GAP_NAME, &storage->printf_gap) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get virtual printf gap") } /* end if */ else storage->printf_gap = (hsize_t)0; /* Retrieve VDS file FAPL to layout */ - if(storage->source_fapl <= 0) - if((storage->source_fapl = H5F_get_access_plist(f, FALSE)) < 0) + if (storage->source_fapl <= 0) + if ((storage->source_fapl = H5F_get_access_plist(f, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fapl") /* Copy DAPL to layout */ - if(storage->source_dapl <= 0) - if((storage->source_dapl = H5P_copy_plist(dapl, FALSE)) < 0) + if (storage->source_dapl <= 0) + if ((storage->source_dapl = H5P_copy_plist(dapl, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dapl") /* Mark layout as not fully initialized (must be done prior to I/O for @@ -2203,7 +2260,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_init() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_is_space_alloc * @@ -2221,7 +2277,7 @@ done: hbool_t H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -2235,7 +2291,6 @@ H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_is_data_cached * @@ -2251,9 +2306,9 @@ H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) static hbool_t H5D__virtual_is_data_cached(const H5D_shared_t *shared_dset) { - const H5O_storage_virtual_t *storage; /* Convenience pointer */ - size_t i, j; /* Local index variables */ - hbool_t ret_value = FALSE; /* Return value */ + const H5O_storage_virtual_t *storage; /* Convenience pointer */ + size_t i, j; /* Local index variables */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -2262,28 +2317,28 @@ H5D__virtual_is_data_cached(const H5D_shared_t *shared_dset) storage = &shared_dset->layout.storage.u.virt; /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ - for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) /* Check for cahced data in source dset */ - if(storage->list[i].sub_dset[j].dset - && storage->list[i].sub_dset[j].dset->shared->layout.ops->is_data_cached - && storage->list[i].sub_dset[j].dset->shared->layout.ops->is_data_cached(storage->list[i].sub_dset[j].dset->shared)) + if (storage->list[i].sub_dset[j].dset && + storage->list[i].sub_dset[j].dset->shared->layout.ops->is_data_cached && + storage->list[i].sub_dset[j].dset->shared->layout.ops->is_data_cached( + storage->list[i].sub_dset[j].dset->shared)) HGOTO_DONE(TRUE); } /* end if */ - else - if(storage->list[i].source_dset.dset - && storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached - && storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached(storage->list[i].source_dset.dset->shared)) - HGOTO_DONE(TRUE); + else if (storage->list[i].source_dset.dset && + storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached && + storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached( + storage->list[i].source_dset.dset->shared)) + HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_is_data_cached() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_pre_io * @@ -2300,17 +2355,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_pre_io(H5D_io_info_t *io_info, - H5O_storage_virtual_t *storage, const H5S_t *file_space, - const H5S_t *mem_space, hsize_t *tot_nelmts) +H5D__virtual_pre_io(H5D_io_info_t *io_info, H5O_storage_virtual_t *storage, const H5S_t *file_space, + const H5S_t *mem_space, hsize_t *tot_nelmts) { - hssize_t select_nelmts; /* Number of elements in selection */ - hsize_t bounds_start[H5S_MAX_RANK]; /* Selection bounds start */ - hsize_t bounds_end[H5S_MAX_RANK]; /* Selection bounds end */ - int rank; - hbool_t bounds_init = FALSE; /* Whether bounds_start, bounds_end, and rank are valid */ - size_t i, j, k; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + hssize_t select_nelmts; /* Number of elements in selection */ + hsize_t bounds_start[H5S_MAX_RANK]; /* Selection bounds start */ + hsize_t bounds_end[H5S_MAX_RANK]; /* Selection bounds end */ + int rank; + hbool_t bounds_init = FALSE; /* Whether bounds_start, bounds_end, and rank are valid */ + size_t i, j, k; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2321,37 +2375,37 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, HDassert(tot_nelmts); /* Initialize layout if necessary */ - if(!storage->init) - if(H5D__virtual_init_all(io_info->dset) < 0) + if (!storage->init) + if (H5D__virtual_init_all(io_info->dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize virtual layout") /* Initialize tot_nelmts */ *tot_nelmts = 0; /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { /* Sanity check that the virtual space has been patched by now */ HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { hbool_t partial_block; HDassert(storage->list[i].unlim_dim_virtual >= 0); /* Get selection bounds if necessary */ - if(!bounds_init) { + if (!bounds_init) { /* Get rank of VDS */ - if((rank = H5S_GET_EXTENT_NDIMS(io_info->dset->shared->space)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(io_info->dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Get selection bounds */ - if(H5S_SELECT_BOUNDS(file_space, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS(file_space, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Adjust bounds_end to represent the extent just enclosing them * (add 1) */ - for(j = 0; j < (size_t)rank; j++) + for (j = 0; j < (size_t)rank; j++) bounds_end[j]++; /* Bounds are now initialized */ @@ -2359,28 +2413,33 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, } /* end if */ /* Get index of first block in virtual selection */ - storage->list[i].sub_dset_io_start = (size_t)H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, bounds_start[storage->list[i].unlim_dim_virtual], NULL); + storage->list[i].sub_dset_io_start = + (size_t)H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, + bounds_start[storage->list[i].unlim_dim_virtual], NULL); /* Get index of first block outside of virtual selection */ - storage->list[i].sub_dset_io_end = (size_t)H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, bounds_end[storage->list[i].unlim_dim_virtual], &partial_block); - if(partial_block) + storage->list[i].sub_dset_io_end = (size_t)H5S_hyper_get_first_inc_block( + storage->list[i].source_dset.virtual_select, bounds_end[storage->list[i].unlim_dim_virtual], + &partial_block); + if (partial_block) storage->list[i].sub_dset_io_end++; - if(storage->list[i].sub_dset_io_end > storage->list[i].sub_dset_nused) + if (storage->list[i].sub_dset_io_end > storage->list[i].sub_dset_nused) storage->list[i].sub_dset_io_end = storage->list[i].sub_dset_nused; /* Iterate over sub-source dsets */ - for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) { + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) { /* Check for clipped virtual selection */ - if(!storage->list[i].sub_dset[j].clipped_virtual_select) { + if (!storage->list[i].sub_dset[j].clipped_virtual_select) { hsize_t start[H5S_MAX_RANK]; /* This should only be NULL if this is a partial block */ HDassert((j == (storage->list[i].sub_dset_io_end - 1)) && partial_block); /* If the source space status is not correct, we must try to * open the source dataset to patch it */ - if(storage->list[i].source_space_status != H5O_VIRTUAL_STATUS_CORRECT) { + if (storage->list[i].source_space_status != H5O_VIRTUAL_STATUS_CORRECT) { HDassert(!storage->list[i].sub_dset[j].dset); - if(H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) + if (H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], + &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") } /* end if */ @@ -2389,119 +2448,140 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, * cannot do this and we will leave them NULL. This doesn't * hurt anything because we can't do I/O because the dataset * must not have been found. */ - if(storage->list[i].source_space_status == H5O_VIRTUAL_STATUS_CORRECT) { + if (storage->list[i].source_space_status == H5O_VIRTUAL_STATUS_CORRECT) { hsize_t tmp_dims[H5S_MAX_RANK]; hsize_t vbounds_end[H5S_MAX_RANK]; /* Get bounds of virtual selection */ - if(H5S_SELECT_BOUNDS(storage->list[i].sub_dset[j].virtual_select, tmp_dims, vbounds_end) < 0) + if (H5S_SELECT_BOUNDS(storage->list[i].sub_dset[j].virtual_select, tmp_dims, + vbounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") HDassert(bounds_init); /* Convert bounds to extent (add 1) */ - for(k = 0; k < (size_t)rank; k++) + for (k = 0; k < (size_t)rank; k++) vbounds_end[k]++; /* Temporarily set extent of virtual selection to bounds */ - if(H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, vbounds_end) < 0) + if (H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, vbounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") /* Get current VDS dimensions */ - if(H5S_get_simple_extent_dims(io_info->dset->shared->space, tmp_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(io_info->dset->shared->space, tmp_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions") /* Copy virtual selection */ - if(NULL == (storage->list[i].sub_dset[j].clipped_virtual_select = H5S_copy(storage->list[i].sub_dset[j].virtual_select, FALSE, TRUE))) + if (NULL == (storage->list[i].sub_dset[j].clipped_virtual_select = + H5S_copy(storage->list[i].sub_dset[j].virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Clip virtual selection to real virtual extent */ (void)HDmemset(start, 0, sizeof(start)); - if(H5S_select_hyperslab(storage->list[i].sub_dset[j].clipped_virtual_select, H5S_SELECT_AND, start, NULL, tmp_dims, NULL) < 0) + if (H5S_select_hyperslab(storage->list[i].sub_dset[j].clipped_virtual_select, + H5S_SELECT_AND, start, NULL, tmp_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "unable to clip hyperslab") /* Project intersection of virtual space and clipped * virtual space onto source space (create * clipped_source_select) */ - if(H5S_select_project_intersection(storage->list[i].sub_dset[j].virtual_select, storage->list[i].source_select, storage->list[i].sub_dset[j].clipped_virtual_select, &storage->list[i].sub_dset[j].clipped_source_select, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + if (H5S_select_project_intersection( + storage->list[i].sub_dset[j].virtual_select, storage->list[i].source_select, + storage->list[i].sub_dset[j].clipped_virtual_select, + &storage->list[i].sub_dset[j].clipped_source_select, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto memory space") /* Set extents of virtual_select and * clipped_virtual_select to virtual extent */ - if(H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, tmp_dims) < 0) + if (H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, tmp_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") - if(H5S_set_extent(storage->list[i].sub_dset[j].clipped_virtual_select, tmp_dims) < 0) + if (H5S_set_extent(storage->list[i].sub_dset[j].clipped_virtual_select, tmp_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") } /* end if */ - } /* end if */ + } /* end if */ /* Only continue if we managed to obtain a * clipped_virtual_select */ - if(storage->list[i].sub_dset[j].clipped_virtual_select) { + if (storage->list[i].sub_dset[j].clipped_virtual_select) { /* Project intersection of file space and mapping virtual space * onto memory space */ - if(H5S_select_project_intersection(file_space, mem_space, storage->list[i].sub_dset[j].clipped_virtual_select, &storage->list[i].sub_dset[j].projected_mem_space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + if (H5S_select_project_intersection( + file_space, mem_space, storage->list[i].sub_dset[j].clipped_virtual_select, + &storage->list[i].sub_dset[j].projected_mem_space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto memory space") /* Check number of elements selected */ - if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(storage->list[i].sub_dset[j].projected_mem_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + if ((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS( + storage->list[i].sub_dset[j].projected_mem_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "unable to get number of elements in selection") /* Check if anything is selected */ - if(select_nelmts > (hssize_t)0) { + if (select_nelmts > (hssize_t)0) { /* Open source dataset */ - if(!storage->list[i].sub_dset[j].dset) + if (!storage->list[i].sub_dset[j].dset) /* Try to open dataset */ - if(H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") + if (H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], + &storage->list[i].sub_dset[j]) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, + "unable to open source dataset") /* If the source dataset is not open, mark the selected * elements as zero so projected_mem_space is freed */ - if(!storage->list[i].sub_dset[j].dset) + if (!storage->list[i].sub_dset[j].dset) select_nelmts = (hssize_t)0; } /* end if */ /* If there are not elements selected in this mapping, free * projected_mem_space, otherwise update tot_nelmts */ - if(select_nelmts == (hssize_t)0) { - if(H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") + if (select_nelmts == (hssize_t)0) { + if (H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "can't close projected memory space") storage->list[i].sub_dset[j].projected_mem_space = NULL; } /* end if */ else *tot_nelmts += (hsize_t)select_nelmts; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { - if(storage->list[i].source_dset.clipped_virtual_select) { + if (storage->list[i].source_dset.clipped_virtual_select) { /* Project intersection of file space and mapping virtual space onto * memory space */ - if(H5S_select_project_intersection(file_space, mem_space, storage->list[i].source_dset.clipped_virtual_select, &storage->list[i].source_dset.projected_mem_space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + if (H5S_select_project_intersection( + file_space, mem_space, storage->list[i].source_dset.clipped_virtual_select, + &storage->list[i].source_dset.projected_mem_space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto memory space") /* Check number of elements selected, add to tot_nelmts */ - if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(storage->list[i].source_dset.projected_mem_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + if ((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS( + storage->list[i].source_dset.projected_mem_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "unable to get number of elements in selection") /* Check if anything is selected */ - if(select_nelmts > (hssize_t)0) { + if (select_nelmts > (hssize_t)0) { /* Open source dataset */ - if(!storage->list[i].source_dset.dset) + if (!storage->list[i].source_dset.dset) /* Try to open dataset */ - if(H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], &storage->list[i].source_dset) < 0) + if (H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], + &storage->list[i].source_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") /* If the source dataset is not open, mark the selected elements * as zero so projected_mem_space is freed */ - if(!storage->list[i].source_dset.dset) + if (!storage->list[i].source_dset.dset) select_nelmts = (hssize_t)0; } /* end if */ /* If there are not elements selected in this mapping, free * projected_mem_space, otherwise update tot_nelmts */ - if(select_nelmts == (hssize_t)0) { - if(H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) + if (select_nelmts == (hssize_t)0) { + if (H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") storage->list[i].source_dset.projected_mem_space = NULL; } /* end if */ @@ -2517,14 +2597,13 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, HDassert(storage->list[i].unlim_dim_virtual >= 0); HDassert(!storage->list[i].source_dset.dset); } /* end else */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_pre_io() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_post_io * @@ -2540,8 +2619,8 @@ done: static herr_t H5D__virtual_post_io(H5O_storage_virtual_t *storage) { - size_t i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2549,32 +2628,31 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) HDassert(storage); /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ - for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) /* Close projected memory space */ - if(storage->list[i].sub_dset[j].projected_mem_space) { - if(H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) + if (storage->list[i].sub_dset[j].projected_mem_space) { + if (H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") storage->list[i].sub_dset[j].projected_mem_space = NULL; } /* end if */ - } /* end if */ + } /* end if */ else /* Close projected memory space */ - if(storage->list[i].source_dset.projected_mem_space) { - if(H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") - storage->list[i].source_dset.projected_mem_space = NULL; - } /* end if */ + if (storage->list[i].source_dset.projected_mem_space) { + if (H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + storage->list[i].source_dset.projected_mem_space = NULL; + } /* end if */ /* Note the lack of a done: label. This is because there are no HGOTO_ERROR * calls. If one is added, a done: label must also be added */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_post_io() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_read_one * @@ -2588,11 +2666,11 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset) +H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space, + H5O_storage_virtual_srcdset_t *source_dset) { - H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2601,37 +2679,40 @@ H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Only perform I/O if there is a projected memory space, otherwise there * were no elements in the projection or the source dataset could not be * opened */ - if(source_dset->projected_mem_space) { + if (source_dset->projected_mem_space) { HDassert(source_dset->dset); HDassert(source_dset->clipped_source_select); /* Project intersection of file space and mapping virtual space onto * mapping source space */ - if(H5S_select_project_intersection(source_dset->clipped_virtual_select, source_dset->clipped_source_select, file_space, &projected_src_space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto source space") + if (H5S_select_project_intersection(source_dset->clipped_virtual_select, + source_dset->clipped_source_select, file_space, + &projected_src_space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto source space") /* Perform read on source dataset */ - if(H5D__read(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, projected_src_space, io_info->u.rbuf) < 0) + if (H5D__read(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, + projected_src_space, io_info->u.rbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read source dataset") /* Close projected_src_space */ - if(H5S_close(projected_src_space) < 0) + if (H5S_close(projected_src_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") projected_src_space = NULL; } /* end if */ done: /* Release allocated resources on failure */ - if(projected_src_space) { + if (projected_src_space) { HDassert(ret_value < 0); - if(H5S_close(projected_src_space) < 0) + if (H5S_close(projected_src_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_read_one() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_read * @@ -2645,15 +2726,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *fm) +H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { - H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ - hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ - H5S_t *fill_space = NULL; /* Space to fill with fill value */ - size_t i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ + H5S_t * fill_space = NULL; /* Space to fill with fill value */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2669,101 +2749,100 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, #ifdef H5_HAVE_PARALLEL /* Parallel reads are not supported (yet) */ - if(H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_HAS_MPI)) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "parallel reads not supported on virtual datasets") #endif /* H5_HAVE_PARALLEL */ /* Prepare for I/O operation */ - if(H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) + if (H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to prepare for I/O operation") /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { /* Sanity check that the virtual space has been patched by now */ HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ - for(j = storage->list[i].sub_dset_io_start; - j < storage->list[i].sub_dset_io_end; j++) - if(H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i].sub_dset[j]) < 0) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) + if (H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read source dataset") } /* end if */ else /* Read from source dataset */ - if(H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i].source_dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read source dataset") + if (H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i].source_dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read source dataset") } /* end for */ /* Fill unmapped part of buffer with fill value */ - if(tot_nelmts < nelmts) { - H5D_fill_value_t fill_status; /* Fill value status */ + if (tot_nelmts < nelmts) { + H5D_fill_value_t fill_status; /* Fill value status */ /* Check the fill value status */ - if(H5P_is_fill_value_defined(&io_info->dset->shared->dcpl_cache.fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(&io_info->dset->shared->dcpl_cache.fill, &fill_status) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Always write fill value to memory buffer unless it is undefined */ - if(fill_status != H5D_FILL_VALUE_UNDEFINED) { + if (fill_status != H5D_FILL_VALUE_UNDEFINED) { /* Start with fill space equal to memory space */ - if(NULL == (fill_space = H5S_copy(mem_space, FALSE, TRUE))) + if (NULL == (fill_space = H5S_copy(mem_space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy memory selection") /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ - for(j = storage->list[i].sub_dset_io_start; - j < storage->list[i].sub_dset_io_end; j++) - if(storage->list[i].sub_dset[j].projected_mem_space) - if(H5S_select_subtract(fill_space, storage->list[i].sub_dset[j].projected_mem_space) < 0) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) + if (storage->list[i].sub_dset[j].projected_mem_space) + if (H5S_select_subtract(fill_space, + storage->list[i].sub_dset[j].projected_mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to clip fill selection") } /* end if */ - else - if(storage->list[i].source_dset.projected_mem_space) - /* Subtract projected memory space from fill space */ - if(H5S_select_subtract(fill_space, storage->list[i].source_dset.projected_mem_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to clip fill selection") + else if (storage->list[i].source_dset.projected_mem_space) + /* Subtract projected memory space from fill space */ + if (H5S_select_subtract(fill_space, storage->list[i].source_dset.projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to clip fill selection") /* Write fill values to memory buffer */ - if(H5D__fill(io_info->dset->shared->dcpl_cache.fill.buf, io_info->dset->shared->type, io_info->u.rbuf, type_info->mem_type, fill_space) < 0) + if (H5D__fill(io_info->dset->shared->dcpl_cache.fill.buf, io_info->dset->shared->type, + io_info->u.rbuf, type_info->mem_type, fill_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "filling buf failed") #ifndef NDEBUG /* Make sure the total number of elements written (including fill * values) >= nelmts */ { - hssize_t select_nelmts; /* Number of elements in selection */ + hssize_t select_nelmts; /* Number of elements in selection */ /* Get number of elements in fill dataspace */ - if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(fill_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + if ((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(fill_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "unable to get number of elements in selection") /* Verify number of elements is correct. Note that since we * don't check for overlap we can't assert that these are equal */ HDassert((tot_nelmts + (hsize_t)select_nelmts) >= nelmts); } /* end block */ -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ +#endif /* NDEBUG */ + } /* end if */ + } /* end if */ done: /* Cleanup I/O operation */ - if(H5D__virtual_post_io(storage) < 0) + if (H5D__virtual_post_io(storage) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation") /* Close fill space */ - if(fill_space) - if(H5S_close(fill_space) < 0) + if (fill_space) + if (H5S_close(fill_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_read() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_write_one * @@ -2777,11 +2856,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset) +H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space, + H5O_storage_virtual_srcdset_t *source_dset) { - H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2789,7 +2868,7 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Only perform I/O if there is a projected memory space, otherwise there * were no elements in the projection */ - if(source_dset->projected_mem_space) { + if (source_dset->projected_mem_space) { HDassert(source_dset->dset); HDassert(source_dset->clipped_source_select); @@ -2798,31 +2877,34 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, * extent in the unlimited dimension. -NAF */ /* Project intersection of file space and mapping virtual space onto * mapping source space */ - if(H5S_select_project_intersection(source_dset->clipped_virtual_select, source_dset->clipped_source_select, file_space, &projected_src_space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto source space") + if (H5S_select_project_intersection(source_dset->clipped_virtual_select, + source_dset->clipped_source_select, file_space, + &projected_src_space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto source space") /* Perform write on source dataset */ - if(H5D__write(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, projected_src_space, io_info->u.wbuf) < 0) + if (H5D__write(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, + projected_src_space, io_info->u.wbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write to source dataset") /* Close projected_src_space */ - if(H5S_close(projected_src_space) < 0) + if (H5S_close(projected_src_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") projected_src_space = NULL; } /* end if */ done: /* Release allocated resources on failure */ - if(projected_src_space) { + if (projected_src_space) { HDassert(ret_value < 0); - if(H5S_close(projected_src_space) < 0) + if (H5S_close(projected_src_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_write_one() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_write * @@ -2836,14 +2918,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t H5_ATTR_UNUSED *fm) +H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { - H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ - hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ - size_t i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2859,47 +2940,46 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, #ifdef H5_HAVE_PARALLEL /* Parallel writes are not supported (yet) */ - if(H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_HAS_MPI)) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "parallel writes not supported on virtual datasets") #endif /* H5_HAVE_PARALLEL */ /* Prepare for I/O operation */ - if(H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) + if (H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to prepare for I/O operation") /* Fail if there are unmapped parts of the selection as they would not be * written */ - if(tot_nelmts != nelmts) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "write requested to unmapped portion of virtual dataset") + if (tot_nelmts != nelmts) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "write requested to unmapped portion of virtual dataset") /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { /* Sanity check that virtual space has been patched by now */ HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ - for(j = storage->list[i].sub_dset_io_start; - j < storage->list[i].sub_dset_io_end; j++) - if(H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i].sub_dset[j]) < 0) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) + if (H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write to source dataset") } /* end if */ else /* Write to source dataset */ - if(H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i].source_dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write to source dataset") + if (H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i].source_dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write to source dataset") } /* end for */ done: /* Cleanup I/O operation */ - if(H5D__virtual_post_io(storage) < 0) + if (H5D__virtual_post_io(storage) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_write() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_flush * @@ -2915,9 +2995,9 @@ done: static herr_t H5D__virtual_flush(H5D_t *dset) { - H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ - size_t i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2927,27 +3007,25 @@ H5D__virtual_flush(H5D_t *dset) storage = &dset->shared->layout.storage.u.virt; /* Flush only open datasets */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ - for(j = 0; j < storage->list[i].sub_dset_nused; j++) - if(storage->list[i].sub_dset[j].dset) + for (j = 0; j < storage->list[i].sub_dset_nused; j++) + if (storage->list[i].sub_dset[j].dset) /* Flush source dataset */ - if(H5D__flush_real(storage->list[i].sub_dset[j].dset) < 0) + if (H5D__flush_real(storage->list[i].sub_dset[j].dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush source dataset") } /* end if */ - else - if(storage->list[i].source_dset.dset) - /* Flush source dataset */ - if(H5D__flush_real(storage->list[i].source_dset.dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to flush source dataset") + else if (storage->list[i].source_dset.dset) + /* Flush source dataset */ + if (H5D__flush_real(storage->list[i].source_dset.dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to flush source dataset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_flush() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_hold_source_dset_files * @@ -2963,10 +3041,10 @@ done: herr_t H5D__virtual_hold_source_dset_files(const H5D_t *dset, H5D_virtual_held_file_t **head) { - H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ - H5D_virtual_held_file_t *tmp; /* Temporary held file node */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t * storage; /* Convenient pointer into layout struct */ + H5D_virtual_held_file_t *tmp; /* Temporary held file node */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2978,52 +3056,50 @@ H5D__virtual_hold_source_dset_files(const H5D_t *dset, H5D_virtual_held_file_t * storage = &dset->shared->layout.storage.u.virt; /* Hold only files for open datasets */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { - size_t j; /* Local index variable */ + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + size_t j; /* Local index variable */ /* Iterate over sub-source dsets */ - for(j = 0; j < storage->list[i].sub_dset_nused; j++) - if(storage->list[i].sub_dset[j].dset) { + for (j = 0; j < storage->list[i].sub_dset_nused; j++) + if (storage->list[i].sub_dset[j].dset) { /* Hold open the file */ H5F_INCR_NOPEN_OBJS(storage->list[i].sub_dset[j].dset->oloc.file); /* Allocate a node for this file */ - if(NULL == (tmp = H5FL_MALLOC(H5D_virtual_held_file_t))) + if (NULL == (tmp = H5FL_MALLOC(H5D_virtual_held_file_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate held file node") /* Set up node & connect to list */ tmp->file = storage->list[i].sub_dset[j].dset->oloc.file; tmp->next = *head; - *head = tmp; + *head = tmp; } /* end if */ + } /* end if */ + else if (storage->list[i].source_dset.dset) { + /* Hold open the file */ + H5F_INCR_NOPEN_OBJS(storage->list[i].source_dset.dset->oloc.file); + + /* Allocate a node for this file */ + if (NULL == (tmp = H5FL_MALLOC(H5D_virtual_held_file_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate held file node") + + /* Set up node & connect to list */ + tmp->file = storage->list[i].source_dset.dset->oloc.file; + tmp->next = *head; + *head = tmp; } /* end if */ - else - if(storage->list[i].source_dset.dset) { - /* Hold open the file */ - H5F_INCR_NOPEN_OBJS(storage->list[i].source_dset.dset->oloc.file); - - /* Allocate a node for this file */ - if(NULL == (tmp = H5FL_MALLOC(H5D_virtual_held_file_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate held file node") - - /* Set up node & connect to list */ - tmp->file = storage->list[i].source_dset.dset->oloc.file; - tmp->next = *head; - *head = tmp; - } /* end if */ done: - if(ret_value < 0) + if (ret_value < 0) /* Release hold on files and delete list on error */ - if(*head && H5D__virtual_release_source_dset_files(*head) < 0) + if (*head && H5D__virtual_release_source_dset_files(*head) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release source datasets' files held open") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_hold_source_dset_files() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_refresh_source_dset * @@ -3039,9 +3115,9 @@ done: static herr_t H5D__virtual_refresh_source_dset(H5D_t **dset) { - hid_t temp_id = H5I_INVALID_HID; /* Temporary dataset identifier */ - H5VL_object_t *vol_obj = NULL; /* VOL object stored with the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t temp_id = H5I_INVALID_HID; /* Temporary dataset identifier */ + H5VL_object_t *vol_obj = NULL; /* VOL object stored with the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3049,28 +3125,27 @@ H5D__virtual_refresh_source_dset(H5D_t **dset) HDassert(dset && *dset); /* Get a temporary identifier for this source dataset */ - if((temp_id = H5VL_wrap_register(H5I_DATASET, *dset, FALSE)) < 0) + if ((temp_id = H5VL_wrap_register(H5I_DATASET, *dset, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register (temporary) source dataset ID") /* Refresh source dataset */ - if(H5D__refresh(temp_id, *dset) < 0) + if (H5D__refresh(temp_id, *dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") /* Discard the identifier & replace the dataset */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_remove(temp_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_remove(temp_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't unregister source dataset ID") - if(NULL == (*dset = (H5D_t *)H5VL_object_unwrap(vol_obj))) + if (NULL == (*dset = (H5D_t *)H5VL_object_unwrap(vol_obj))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve library object from VOL object") vol_obj->data = NULL; done: - if(vol_obj && H5VL_free_object(vol_obj) < 0) + if (vol_obj && H5VL_free_object(vol_obj) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_refresh_source_dset() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_refresh_source_dsets * @@ -3086,9 +3161,9 @@ done: herr_t H5D__virtual_refresh_source_dsets(H5D_t *dset) { - H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3099,31 +3174,30 @@ H5D__virtual_refresh_source_dsets(H5D_t *dset) storage = &dset->shared->layout.storage.u.virt; /* Refresh only open datasets */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { - size_t j; /* Local index variable */ + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + size_t j; /* Local index variable */ /* Iterate over sub-source datasets */ - for(j = 0; j < storage->list[i].sub_dset_nused; j++) + for (j = 0; j < storage->list[i].sub_dset_nused; j++) /* Check if sub-source dataset is open */ - if(storage->list[i].sub_dset[j].dset) + if (storage->list[i].sub_dset[j].dset) /* Refresh sub-source dataset */ - if(H5D__virtual_refresh_source_dset(&storage->list[i].sub_dset[j].dset) < 0) + if (H5D__virtual_refresh_source_dset(&storage->list[i].sub_dset[j].dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") } /* end if */ else /* Check if source dataset is open */ - if(storage->list[i].source_dset.dset) - /* Refresh source dataset */ - if(H5D__virtual_refresh_source_dset(&storage->list[i].source_dset.dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") + if (storage->list[i].source_dset.dset) + /* Refresh source dataset */ + if (H5D__virtual_refresh_source_dset(&storage->list[i].source_dset.dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_refresh_source_dsets() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_release_source_dset_files * @@ -3139,13 +3213,13 @@ done: herr_t H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Release hold on files and delete list */ - while(head) { - H5D_virtual_held_file_t *tmp = head->next; /* Temporary pointer to next node */ + while (head) { + H5D_virtual_held_file_t *tmp = head->next; /* Temporary pointer to next node */ /* Release hold on file */ H5F_DECR_NOPEN_OBJS(head->file); @@ -3155,7 +3229,7 @@ H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head) * essentially "private" to the virtual dataset, since it wasn't * opened through an API routine -QAK) */ - if(H5F_try_close(head->file, NULL) < 0) + if (H5F_try_close(head->file, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") /* Delete node */ @@ -3168,4 +3242,3 @@ H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_release_source_dset_files() */ - diff --git a/src/H5E.c b/src/H5E.c index f204864..a9e0733 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -43,54 +43,49 @@ /* Module Setup */ /****************/ -#include "H5Emodule.h" /* This source code file is part of the H5E module */ - +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Epkg.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Epkg.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ /* HDF5 error class */ -#define H5E_CLS_NAME "HDF5" -#define H5E_CLS_LIB_NAME "HDF5" - +#define H5E_CLS_NAME "HDF5" +#define H5E_CLS_LIB_NAME "HDF5" /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Static function declarations */ -static herr_t H5E__set_default_auto(H5E_t *stk); +static herr_t H5E__set_default_auto(H5E_t *stk); static H5E_cls_t *H5E__register_class(const char *cls_name, const char *lib_name, const char *version); -static herr_t H5E__unregister_class(H5E_cls_t *cls); -static ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size); -static int H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata); -static herr_t H5E__close_msg(H5E_msg_t *err); +static herr_t H5E__unregister_class(H5E_cls_t *cls); +static ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size); +static int H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata); +static herr_t H5E__close_msg(H5E_msg_t *err); static H5E_msg_t *H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg); -static H5E_t *H5E__get_current_stack(void); -static herr_t H5E__set_current_stack(H5E_t *estack); -static herr_t H5E__close_stack(H5E_t *err_stack); -static ssize_t H5E__get_num(const H5E_t *err_stack); - +static H5E_t * H5E__get_current_stack(void); +static herr_t H5E__set_current_stack(H5E_t *estack); +static herr_t H5E__close_stack(H5E_t *err_stack); +static ssize_t H5E__get_num(const H5E_t *err_stack); /*********************/ /* Package Variables */ @@ -99,12 +94,10 @@ static ssize_t H5E__get_num(const H5E_t *err_stack); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -120,30 +113,28 @@ H5FL_DEFINE_STATIC(H5E_msg_t); /* Error class ID class */ static const H5I_class_t H5I_ERRCLS_CLS[1] = {{ - H5I_ERROR_CLASS, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ + H5I_ERROR_CLASS, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ (H5I_free_t)H5E__unregister_class /* Callback routine for closing objects of this class */ }}; /* Error message ID class */ static const H5I_class_t H5I_ERRMSG_CLS[1] = {{ - H5I_ERROR_MSG, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5E__close_msg /* Callback routine for closing objects of this class */ + H5I_ERROR_MSG, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5E__close_msg /* Callback routine for closing objects of this class */ }}; /* Error stack ID class */ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ - H5I_ERROR_STACK, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ + H5I_ERROR_STACK, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ (H5I_free_t)H5E__close_stack /* Callback routine for closing objects of this class */ }}; - - /*------------------------------------------------------------------------- * Function: H5E_init * @@ -159,7 +150,7 @@ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ herr_t H5E_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -168,7 +159,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_init() */ - /*-------------------------------------------------------------------------- * Function: H5E__init_package * @@ -184,23 +174,23 @@ done: herr_t H5E__init_package(void) { - H5E_cls_t *cls; /* Pointer to error class */ - H5E_msg_t *msg; /* Pointer to new error message */ - char lib_vers[128]; /* Buffer to constructu library version within */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + H5E_msg_t *msg; /* Pointer to new error message */ + char lib_vers[128]; /* Buffer to constructu library version within */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the error class IDs */ - if(H5I_register_type(H5I_ERRCLS_CLS) < 0) + if (H5I_register_type(H5I_ERRCLS_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") /* Initialize the atom group for the major error IDs */ - if(H5I_register_type(H5I_ERRMSG_CLS) < 0) + if (H5I_register_type(H5I_ERRMSG_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") /* Initialize the atom group for the error stacks */ - if(H5I_register_type(H5I_ERRSTK_CLS) < 0) + if (H5I_register_type(H5I_ERRSTK_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") #ifndef H5_HAVE_THREADSAFE @@ -210,20 +200,20 @@ H5E__init_package(void) /* Allocate the HDF5 error class */ HDassert(H5E_ERR_CLS_g == (-1)); - HDsnprintf(lib_vers, sizeof(lib_vers), "%u.%u.%u%s", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, (HDstrlen(H5_VERS_SUBRELEASE) > 0 ? "-"H5_VERS_SUBRELEASE : "")); - if(NULL == (cls = H5E__register_class(H5E_CLS_NAME, H5E_CLS_LIB_NAME, lib_vers))) + HDsnprintf(lib_vers, sizeof(lib_vers), "%u.%u.%u%s", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, + (HDstrlen(H5_VERS_SUBRELEASE) > 0 ? "-" H5_VERS_SUBRELEASE : "")); + if (NULL == (cls = H5E__register_class(H5E_CLS_NAME, H5E_CLS_LIB_NAME, lib_vers))) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "class initialization failed") - if((H5E_ERR_CLS_g = H5I_register(H5I_ERROR_CLASS, cls, FALSE)) < 0) + if ((H5E_ERR_CLS_g = H5I_register(H5I_ERROR_CLASS, cls, FALSE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error class") - /* Include the automatically generated error code initialization */ - #include "H5Einit.h" +/* Include the automatically generated error code initialization */ +#include "H5Einit.h" done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__init_package() */ - /*------------------------------------------------------------------------- * Function: H5E_term_package * @@ -242,11 +232,11 @@ done: int H5E_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { int64_t ncls, nmsg, nstk; /* Check if there are any open error stacks, classes or messages */ @@ -254,33 +244,33 @@ H5E_term_package(void) nmsg = H5I_nmembers(H5I_ERROR_MSG); nstk = H5I_nmembers(H5I_ERROR_STACK); - if((ncls + nmsg + nstk) > 0) { + if ((ncls + nmsg + nstk) > 0) { /* Clear any outstanding error stacks */ - if(nstk > 0) - (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); + if (nstk > 0) + (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); /* Clear all the error classes */ - if(ncls > 0) { + if (ncls > 0) { (void)H5I_clear_type(H5I_ERROR_CLASS, FALSE, FALSE); /* Reset the HDF5 error class, if its been closed */ - if(H5I_nmembers(H5I_ERROR_CLASS) == 0) + if (H5I_nmembers(H5I_ERROR_CLASS) == 0) H5E_ERR_CLS_g = -1; } /* end if */ /* Clear all the error messages */ - if(nmsg > 0) { + if (nmsg > 0) { (void)H5I_clear_type(H5I_ERROR_MSG, FALSE, FALSE); /* Reset the HDF5 error messages, if they've been closed */ - if(H5I_nmembers(H5I_ERROR_MSG) == 0) { - /* Include the automatically generated error code termination */ - #include "H5Eterm.h" + if (H5I_nmembers(H5I_ERROR_MSG) == 0) { +/* Include the automatically generated error code termination */ +#include "H5Eterm.h" } /* end if */ - } /* end if */ + } /* end if */ n++; /*H5I*/ - } /* end if */ + } /* end if */ else { /* Destroy the error class, message, and stack id groups */ n += (H5I_dec_type_ref(H5I_ERROR_STACK) > 0); @@ -288,15 +278,14 @@ H5E_term_package(void) n += (H5I_dec_type_ref(H5I_ERROR_MSG) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5E_term_package() */ - /*-------------------------------------------------------------------------- * Function: H5E__set_default_auto * @@ -318,14 +307,14 @@ H5E__set_default_auto(H5E_t *stk) #ifndef H5_NO_DEPRECATED_SYMBOLS #ifdef H5_USE_16_API_DEFAULT stk->auto_op.vers = 1; -#else /* H5_USE_16_API */ +#else /* H5_USE_16_API */ stk->auto_op.vers = 2; #endif /* H5_USE_16_API_DEFAULT */ stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1; stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5Eprint2; - stk->auto_op.is_default = TRUE; -#else /* H5_NO_DEPRECATED_SYMBOLS */ + stk->auto_op.is_default = TRUE; +#else /* H5_NO_DEPRECATED_SYMBOLS */ stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -334,7 +323,6 @@ H5E__set_default_auto(H5E_t *stk) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__set_default_auto() */ - #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- * Function: H5E__get_stack @@ -360,7 +348,7 @@ H5E__get_stack(void) estack = (H5E_t *)H5TS_get_thread_local_value(H5TS_errstk_key_g); - if(!estack) { + if (!estack) { /* No associated value with current thread - create one */ #ifdef H5_HAVE_WIN_THREADS /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ @@ -387,9 +375,8 @@ H5E__get_stack(void) /* Set return value */ FUNC_LEAVE_NOAPI(estack) } /* end H5E__get_stack() */ -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ - /*------------------------------------------------------------------------- * Function: H5E_free_class * @@ -411,15 +398,14 @@ H5E_free_class(H5E_cls_t *cls) HDassert(cls); /* Free error class structure */ - cls->cls_name = (char *)H5MM_xfree((void*)cls->cls_name); - cls->lib_name = (char *)H5MM_xfree((void*)cls->lib_name); - cls->lib_vers = (char *)H5MM_xfree((void*)cls->lib_vers); - cls = H5FL_FREE(H5E_cls_t, cls); + cls->cls_name = (char *)H5MM_xfree((void *)cls->cls_name); + cls->lib_name = (char *)H5MM_xfree((void *)cls->lib_name); + cls->lib_vers = (char *)H5MM_xfree((void *)cls->lib_vers); + cls = H5FL_FREE(H5E_cls_t, cls); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E_free_class() */ - /*------------------------------------------------------------------------- * Function: H5Eregister_class * @@ -436,29 +422,28 @@ H5E_free_class(H5E_cls_t *cls) hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version) { - H5E_cls_t *cls; /* Pointer to error class */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*s*s*s", cls_name, lib_name, version); /* Check arguments */ - if(cls_name == NULL || lib_name == NULL || version == NULL) + if (cls_name == NULL || lib_name == NULL || version == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid string") /* Create the new error class object */ - if(NULL == (cls = H5E__register_class(cls_name, lib_name, version))) + if (NULL == (cls = H5E__register_class(cls_name, lib_name, version))) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error class") /* Register the new error class to get an ID for it */ - if((ret_value = H5I_register(H5I_ERROR_CLASS, cls, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_ERROR_CLASS, cls, TRUE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register error class") done: FUNC_LEAVE_API(ret_value) } /* end H5Eregister_class() */ - /*------------------------------------------------------------------------- * Function: H5E__register_class * @@ -475,8 +460,8 @@ done: static H5E_cls_t * H5E__register_class(const char *cls_name, const char *lib_name, const char *version) { - H5E_cls_t *cls = NULL; /* Pointer to error class */ - H5E_cls_t *ret_value = NULL; /* Return value */ + H5E_cls_t *cls = NULL; /* Pointer to error class */ + H5E_cls_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -486,29 +471,28 @@ H5E__register_class(const char *cls_name, const char *lib_name, const char *vers HDassert(version); /* Allocate space for new error class */ - if(NULL == (cls = H5FL_CALLOC(H5E_cls_t))) + if (NULL == (cls = H5FL_CALLOC(H5E_cls_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Duplicate string information */ - if(NULL == (cls->cls_name = H5MM_xstrdup(cls_name))) + if (NULL == (cls->cls_name = H5MM_xstrdup(cls_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (cls->lib_name = H5MM_xstrdup(lib_name))) + if (NULL == (cls->lib_name = H5MM_xstrdup(lib_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (cls->lib_vers = H5MM_xstrdup(version))) + if (NULL == (cls->lib_vers = H5MM_xstrdup(version))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the return value */ ret_value = cls; done: - if(!ret_value) - if(cls && H5E_free_class(cls) < 0) + if (!ret_value) + if (cls && H5E_free_class(cls) < 0) HDONE_ERROR(H5E_ERROR, H5E_CANTRELEASE, NULL, "unable to free error class") FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__register_class() */ - /*------------------------------------------------------------------------- * Function: H5Eunregister_class * @@ -524,27 +508,26 @@ done: herr_t H5Eunregister_class(hid_t class_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", class_id); /* Check arguments */ - if(H5I_ERROR_CLASS != H5I_get_type(class_id)) + if (H5I_ERROR_CLASS != H5I_get_type(class_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error class") /* * Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref(class_id) < 0) + if (H5I_dec_app_ref(class_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") done: FUNC_LEAVE_API(ret_value) } /* end H5Eunregister_class() */ - /*------------------------------------------------------------------------- * Function: H5E__unregister_class * @@ -560,7 +543,7 @@ done: static herr_t H5E__unregister_class(H5E_cls_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -568,18 +551,17 @@ H5E__unregister_class(H5E_cls_t *cls) HDassert(cls); /* Iterate over all the messages and delete those in this error class */ - if(H5I_iterate(H5I_ERROR_MSG, H5E__close_msg_cb, cls, FALSE) < 0) + if (H5I_iterate(H5I_ERROR_MSG, H5E__close_msg_cb, cls, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_BADITER, FAIL, "unable to free all messages in this error class") /* Free error class structure */ - if(H5E_free_class(cls) < 0) + if (H5E_free_class(cls) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "unable to free error class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__unregister_class() */ - /*------------------------------------------------------------------------- * Function: H5Eget_class_name * @@ -596,25 +578,24 @@ done: ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size) { - H5E_cls_t *cls; /* Pointer to error class */ - ssize_t ret_value = -1; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*sz", class_id, name, size); /* Get the error class */ - if(NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) + if (NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a error class ID") /* Retrieve the class name */ - if((ret_value = H5E__get_class_name(cls, name, size)) < 0) + if ((ret_value = H5E__get_class_name(cls, name, size)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get error class name") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_class_name() */ - /*------------------------------------------------------------------------- * Function: H5E__get_class_name * @@ -631,7 +612,7 @@ done: static ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) { - ssize_t len = -1; /* Length of error class's name */ + ssize_t len = -1; /* Length of error class's name */ FUNC_ENTER_STATIC_NOERR @@ -642,17 +623,16 @@ H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) len = (ssize_t)HDstrlen(cls->cls_name); /* Set the user's buffer, if provided */ - if(name) { - HDstrncpy(name, cls->cls_name, MIN((size_t)(len + 1), size)); - if((size_t)len >= size) - name[size - 1] = '\0'; + if (name) { + HDstrncpy(name, cls->cls_name, MIN((size_t)(len + 1), size)); + if ((size_t)len >= size) + name[size - 1] = '\0'; } /* end if */ /* Return the full length */ FUNC_LEAVE_NOAPI(len) } /* end H5E__get_class_name() */ - /*------------------------------------------------------------------------- * Function: H5E__close_msg_cb * @@ -670,9 +650,9 @@ H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) static int H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata) { - H5E_msg_t *err_msg = (H5E_msg_t*)obj_ptr; - H5E_cls_t *cls = (H5E_cls_t*)udata; - int ret_value = H5_ITER_CONT; /* Return value */ + H5E_msg_t *err_msg = (H5E_msg_t *)obj_ptr; + H5E_cls_t *cls = (H5E_cls_t *)udata; + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -680,10 +660,10 @@ H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata) HDassert(err_msg); /* Close the message if it is in the class being closed */ - if(err_msg->cls == cls) { - if(H5E__close_msg(err_msg) < 0) + if (err_msg->cls == cls) { + if (H5E__close_msg(err_msg) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "unable to close error message") - if(NULL == H5I_remove(obj_id)) + if (NULL == H5I_remove(obj_id)) HGOTO_ERROR(H5E_ERROR, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove error message") } /* end if */ @@ -691,7 +671,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__close_msg_cb() */ - /*------------------------------------------------------------------------- * Function: H5Eclose_msg * @@ -707,24 +686,23 @@ done: herr_t H5Eclose_msg(hid_t err_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", err_id); /* Check arguments */ - if(H5I_ERROR_MSG != H5I_get_type(err_id)) + if (H5I_ERROR_MSG != H5I_get_type(err_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error class") /* Decrement the counter. It will be freed if the count reaches zero. */ - if(H5I_dec_app_ref(err_id) < 0) + if (H5I_dec_app_ref(err_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") done: FUNC_LEAVE_API(ret_value) } /* end H5Eclose_msg() */ - /*------------------------------------------------------------------------- * Function: H5E__close_msg * @@ -753,7 +731,6 @@ H5E__close_msg(H5E_msg_t *err) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__close_msg() */ - /*------------------------------------------------------------------------- * Function: H5Ecreate_msg * @@ -770,29 +747,29 @@ H5E__close_msg(H5E_msg_t *err) hid_t H5Ecreate_msg(hid_t class_id, H5E_type_t msg_type, const char *msg_str) { - H5E_cls_t *cls; /* Pointer to error class */ - H5E_msg_t *msg; /* Pointer to new error message */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + H5E_msg_t *msg; /* Pointer to new error message */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iEt*s", class_id, msg_type, msg_str); /* Check arguments */ - if(msg_type != H5E_MAJOR && msg_type != H5E_MINOR) + if (msg_type != H5E_MAJOR && msg_type != H5E_MINOR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "not a valid message type") - if(msg_str == NULL) + if (msg_str == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "message is NULL") /* Get the error class */ - if(NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) + if (NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an error class ID") /* Create the new error message object */ - if(NULL == (msg = H5E__create_msg(cls, msg_type, msg_str))) + if (NULL == (msg = H5E__create_msg(cls, msg_type, msg_str))) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error message") /* Register the new error class to get an ID for it */ - if((ret_value = H5I_register(H5I_ERROR_MSG, msg, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_ERROR_MSG, msg, TRUE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register error message") done: @@ -815,8 +792,8 @@ done: static H5E_msg_t * H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) { - H5E_msg_t *msg = NULL; /* Pointer to new error message */ - H5E_msg_t *ret_value = NULL; /* Return value */ + H5E_msg_t *msg = NULL; /* Pointer to new error message */ + H5E_msg_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -826,27 +803,26 @@ H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) HDassert(msg_str); /* Allocate new message object */ - if(NULL == (msg = H5FL_MALLOC(H5E_msg_t))) + if (NULL == (msg = H5FL_MALLOC(H5E_msg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Fill new message object */ - msg->cls = cls; + msg->cls = cls; msg->type = msg_type; - if(NULL == (msg->msg = H5MM_xstrdup(msg_str))) + if (NULL == (msg->msg = H5MM_xstrdup(msg_str))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set return value */ ret_value = msg; done: - if(!ret_value) - if(msg && H5E__close_msg(msg) < 0) + if (!ret_value) + if (msg && H5E__close_msg(msg) < 0) HDONE_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, NULL, "unable to close error message") FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__create_msg() */ - /*------------------------------------------------------------------------- * Function: H5Eget_msg * @@ -863,25 +839,24 @@ done: ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg_str, size_t size) { - H5E_msg_t *msg; /* Pointer to error message */ - ssize_t ret_value = -1; /* Return value */ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API_NOCLEAR((-1)) H5TRACE4("Zs", "i*Et*sz", msg_id, type, msg_str, size); /* Get the message object */ - if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(msg_id, H5I_ERROR_MSG))) + if (NULL == (msg = (H5E_msg_t *)H5I_object_verify(msg_id, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a error message ID") /* Get the message's text */ - if((ret_value = H5E__get_msg(msg, type, msg_str, size)) < 0) + if ((ret_value = H5E__get_msg(msg, type, msg_str, size)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get error message text") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_msg() */ - /*------------------------------------------------------------------------- * Function: H5Ecreate_stack * @@ -898,28 +873,27 @@ done: hid_t H5Ecreate_stack(void) { - H5E_t *stk; /* Error stack */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5E_t *stk; /* Error stack */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE0("i",""); /* Allocate a new error stack */ - if(NULL == (stk = H5FL_CALLOC(H5E_t))) + if (NULL == (stk = H5FL_CALLOC(H5E_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Set the "automatic" error reporting info to the library default */ H5E__set_default_auto(stk); /* Register the stack */ - if((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't create error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Ecreate_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eget_current_stack * @@ -937,26 +911,25 @@ done: hid_t H5Eget_current_stack(void) { - H5E_t *stk; /* Error stack */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5E_t *stk; /* Error stack */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(H5I_INVALID_HID) H5TRACE0("i",""); /* Get the current stack */ - if(NULL == (stk = H5E__get_current_stack())) + if (NULL == (stk = H5E__get_current_stack())) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error stack") /* Register the stack */ - if((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't create error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__get_current_stack * @@ -973,51 +946,52 @@ done: static H5E_t * H5E__get_current_stack(void) { - H5E_t *current_stack; /* Pointer to the current error stack */ - H5E_t *estack_copy = NULL; /* Pointer to new error stack to return */ - unsigned u; /* Local index variable */ - H5E_t *ret_value = NULL; /* Return value */ + H5E_t * current_stack; /* Pointer to the current error stack */ + H5E_t * estack_copy = NULL; /* Pointer to new error stack to return */ + unsigned u; /* Local index variable */ + H5E_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Get a pointer to the current error stack */ - if(NULL == (current_stack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get current error stack") + if (NULL == (current_stack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' + in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get current error stack") /* Allocate a new error stack */ - if(NULL == (estack_copy = H5FL_CALLOC(H5E_t))) + if (NULL == (estack_copy = H5FL_CALLOC(H5E_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Make a copy of current error stack */ estack_copy->nused = current_stack->nused; - for(u = 0; u < current_stack->nused; u++) { + for (u = 0; u < current_stack->nused; u++) { H5E_error2_t *current_error, *new_error; /* Pointers to errors on each stack */ /* Get pointers into the current error stack location */ current_error = &(current_stack->slot[u]); - new_error = &(estack_copy->slot[u]); + new_error = &(estack_copy->slot[u]); /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(current_error->cls_id, FALSE) < 0) + if (H5I_inc_ref(current_error->cls_id, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error class") new_error->cls_id = current_error->cls_id; - if(H5I_inc_ref(current_error->maj_num, FALSE) < 0) + if (H5I_inc_ref(current_error->maj_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") new_error->maj_num = current_error->maj_num; - if(H5I_inc_ref(current_error->min_num, FALSE) < 0) + if (H5I_inc_ref(current_error->min_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") new_error->min_num = current_error->min_num; - if(NULL == (new_error->func_name = H5MM_xstrdup(current_error->func_name))) + if (NULL == (new_error->func_name = H5MM_xstrdup(current_error->func_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (new_error->file_name = H5MM_xstrdup(current_error->file_name))) + if (NULL == (new_error->file_name = H5MM_xstrdup(current_error->file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") new_error->line = current_error->line; - if(NULL == (new_error->desc = H5MM_xstrdup(current_error->desc))) + if (NULL == (new_error->desc = H5MM_xstrdup(current_error->desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end for */ /* Copy the "automatic" error reporting information */ - estack_copy->auto_op = current_stack->auto_op; + estack_copy->auto_op = current_stack->auto_op; estack_copy->auto_data = current_stack->auto_data; /* Empty current error stack */ @@ -1027,14 +1001,13 @@ H5E__get_current_stack(void) ret_value = estack_copy; done: - if(ret_value == NULL) - if(estack_copy) + if (ret_value == NULL) + if (estack_copy) estack_copy = H5FL_FREE(H5E_t, estack_copy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__get_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eset_current_stack * @@ -1052,24 +1025,24 @@ herr_t H5Eset_current_stack(hid_t err_stack) { H5E_t *estack; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", err_stack); - if(err_stack != H5E_DEFAULT) { - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (err_stack != H5E_DEFAULT) { + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Set the current error stack */ - if(H5E__set_current_stack(estack) < 0) + if (H5E__set_current_stack(estack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "unable to set error stack") /* * Decrement the counter on the error stack. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref(err_stack) < 0) + if (H5I_dec_app_ref(err_stack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack") } /* end if */ @@ -1077,7 +1050,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Eset_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__set_current_stack * @@ -1093,9 +1065,9 @@ done: static herr_t H5E__set_current_stack(H5E_t *estack) { - H5E_t *current_stack; /* Default error stack */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * current_stack; /* Default error stack */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1103,37 +1075,38 @@ H5E__set_current_stack(H5E_t *estack) HDassert(estack); /* Get a pointer to the current error stack */ - if(NULL == (current_stack = H5E__get_my_stack ())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + if (NULL == (current_stack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' + in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Empty current error stack */ H5E_clear_stack(current_stack); /* Copy new stack to current error stack */ current_stack->nused = estack->nused; - for(u = 0; u < current_stack->nused; u++) { + for (u = 0; u < current_stack->nused; u++) { H5E_error2_t *current_error, *new_error; /* Pointers to errors on each stack */ /* Get pointers into the current error stack location */ current_error = &(current_stack->slot[u]); - new_error = &(estack->slot[u]); + new_error = &(estack->slot[u]); /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(new_error->cls_id, FALSE) < 0) + if (H5I_inc_ref(new_error->cls_id, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error class") current_error->cls_id = new_error->cls_id; - if(H5I_inc_ref(new_error->maj_num, FALSE) < 0) + if (H5I_inc_ref(new_error->maj_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error class") current_error->maj_num = new_error->maj_num; - if(H5I_inc_ref(new_error->min_num, FALSE) < 0) + if (H5I_inc_ref(new_error->min_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error class") current_error->min_num = new_error->min_num; - if(NULL == (current_error->func_name = H5MM_xstrdup(new_error->func_name))) + if (NULL == (current_error->func_name = H5MM_xstrdup(new_error->func_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (current_error->file_name = H5MM_xstrdup(new_error->file_name))) + if (NULL == (current_error->file_name = H5MM_xstrdup(new_error->file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") current_error->line = new_error->line; - if(NULL == (current_error->desc = H5MM_xstrdup(new_error->desc))) + if (NULL == (current_error->desc = H5MM_xstrdup(new_error->desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end for */ @@ -1141,7 +1114,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__set_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eclose_stack * @@ -1157,21 +1129,21 @@ done: herr_t H5Eclose_stack(hid_t stack_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", stack_id); - if(H5E_DEFAULT != stack_id) { + if (H5E_DEFAULT != stack_id) { /* Check arguments */ - if(H5I_ERROR_STACK != H5I_get_type(stack_id)) + if (H5I_ERROR_STACK != H5I_get_type(stack_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* * Decrement the counter on the error stack. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref(stack_id) < 0) + if (H5I_dec_app_ref(stack_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack") } /* end if */ @@ -1179,7 +1151,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Eclose_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__close_stack * @@ -1209,7 +1180,6 @@ H5E__close_stack(H5E_t *estack) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__close_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eget_num * @@ -1226,16 +1196,17 @@ H5E__close_stack(H5E_t *estack) ssize_t H5Eget_num(hid_t error_stack_id) { - H5E_t *estack; /* Error stack to operate on */ - ssize_t ret_value; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + ssize_t ret_value; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR((-1)) H5TRACE1("Zs", "i", error_stack_id); /* Need to check for errors */ - if(error_stack_id == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (error_stack_id == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get current error stack") } /* end if */ else { @@ -1243,19 +1214,18 @@ H5Eget_num(hid_t error_stack_id) H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if(NULL == (estack = (H5E_t *)H5I_object_verify(error_stack_id, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(error_stack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an error stack ID") } /* end else */ /* Get the number of errors on stack */ - if((ret_value = H5E__get_num(estack)) < 0) + if ((ret_value = H5E__get_num(estack)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get number of errors") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_num() */ - /*------------------------------------------------------------------------- * Function: H5E__get_num * @@ -1279,7 +1249,6 @@ H5E__get_num(const H5E_t *estack) FUNC_LEAVE_NOAPI((ssize_t)estack->nused) } /* end H5E__get_num() */ - /*------------------------------------------------------------------------- * Function: H5Epop * @@ -1296,15 +1265,16 @@ herr_t H5Epop(hid_t err_stack, size_t count) { H5E_t *estack; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE2("e", "iz", err_stack, count); /* Need to check for errors */ - if(err_stack == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (err_stack == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { @@ -1312,23 +1282,22 @@ H5Epop(hid_t err_stack, size_t count) H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Range limit the number of errors to pop off stack */ - if(count > estack->nused) + if (count > estack->nused) count = estack->nused; /* Pop the errors off the stack */ - if(H5E__pop(estack, count) < 0) + if (H5E__pop(estack, count) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "can't pop errors from stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Epop() */ - /*------------------------------------------------------------------------- * Function: H5Epush2 * @@ -1351,39 +1320,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) +H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, + hid_t min_id, const char *fmt, ...) { - va_list ap; /* Varargs info */ - H5E_t *estack; /* Pointer to error stack to modify */ + va_list ap; /* Varargs info */ + H5E_t * estack; /* Pointer to error stack to modify */ #ifndef H5_HAVE_VASPRINTF - int tmp_len; /* Current size of description buffer */ - int desc_len; /* Actual length of description when formatted */ -#endif /* H5_HAVE_VASPRINTF */ - char *tmp = NULL; /* Buffer to place formatted description in */ - hbool_t va_started = FALSE; /* Whether the variable argument list is open */ - herr_t ret_value=SUCCEED; /* Return value */ + int tmp_len; /* Current size of description buffer */ + int desc_len; /* Actual length of description when formatted */ +#endif /* H5_HAVE_VASPRINTF */ + char * tmp = NULL; /* Buffer to place formatted description in */ + hbool_t va_started = FALSE; /* Whether the variable argument list is open */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE8("e", "i*s*sIuiii*s", err_stack, file, func, line, cls_id, maj_id, min_id, fmt); - if(err_stack == H5E_DEFAULT) - estack = NULL; + if (err_stack == H5E_DEFAULT) + estack = NULL; else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ -/* Note that the variable-argument parsing for the format is identical in - * the H5E_printf_stack() routine - correct errors and make changes in both - * places. -QAK - */ + /* Note that the variable-argument parsing for the format is identical in + * the H5E_printf_stack() routine - correct errors and make changes in both + * places. -QAK + */ /* Format the description */ HDva_start(ap, fmt); @@ -1391,16 +1360,16 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, #ifdef H5_HAVE_VASPRINTF /* Use the vasprintf() routine, since it does what we're trying to do below */ - if(HDvasprintf(&tmp, fmt, ap) < 0) + if (HDvasprintf(&tmp, fmt, ap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") -#else /* H5_HAVE_VASPRINTF */ +#else /* H5_HAVE_VASPRINTF */ /* Allocate space for the formatted description buffer */ tmp_len = 128; - if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) + if (NULL == (tmp = H5MM_malloc((size_t)tmp_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ - while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { + while ((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { /* shutdown & restart the va_list */ HDva_end(ap); HDva_start(ap, fmt); @@ -1410,33 +1379,32 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, /* Allocate a description of the appropriate length */ tmp_len = desc_len + 1; - if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) + if (NULL == (tmp = H5MM_malloc((size_t)tmp_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end while */ #endif /* H5_HAVE_VASPRINTF */ /* Push the error on the stack */ - if(H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) + if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") done: - if(va_started) + if (va_started) HDva_end(ap); #ifdef H5_HAVE_VASPRINTF /* Memory was allocated with HDvasprintf so it needs to be freed * with HDfree */ - if(tmp) + if (tmp) HDfree(tmp); -#else /* H5_HAVE_VASPRINTF */ - if(tmp) +#else /* H5_HAVE_VASPRINTF */ + if (tmp) H5MM_xfree(tmp); #endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_API(ret_value) } /* end H5Epush2() */ - /*------------------------------------------------------------------------- * Function: H5Eclear2 * @@ -1452,33 +1420,32 @@ done: herr_t H5Eclear2(hid_t err_stack) { - H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE1("e", "i", err_stack); /* Need to check for errors */ - if(err_stack == H5E_DEFAULT) - estack = NULL; + if (err_stack == H5E_DEFAULT) + estack = NULL; else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Clear the error stack */ - if(H5E_clear_stack(estack) < 0) + if (H5E_clear_stack(estack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eclear2() */ - /*------------------------------------------------------------------------- * Function: H5Eprint2 * @@ -1497,35 +1464,35 @@ done: herr_t H5Eprint2(hid_t err_stack, FILE *stream) { - H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) /*NO TRACE*/ /* Need to check for errors */ - if(err_stack == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (err_stack == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Print error stack */ - if(H5E__print(estack, stream, FALSE) < 0) + if (H5E__print(estack, stream, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eprint2() */ - /*------------------------------------------------------------------------- * Function: H5Ewalk2 * @@ -1542,38 +1509,38 @@ done: herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t stack_func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ - H5E_walk_op_t op; /* Operator for walking error stack */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_walk_op_t op; /* Operator for walking error stack */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) /*NO TRACE*/ /* Need to check for errors */ - if(err_stack == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (err_stack == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Walk the error stack */ - op.vers = 2; + op.vers = 2; op.u.func2 = stack_func; - if((ret_value = H5E__walk(estack, direction, &op, client_data)) < 0) + if ((ret_value = H5E__walk(estack, direction, &op, client_data)) < 0) HERROR(H5E_ERROR, H5E_CANTLIST, "can't walk error stack"); done: FUNC_LEAVE_API(ret_value) } /* end H5Ewalk2() */ - /*------------------------------------------------------------------------- * Function: H5Eget_auto2 * @@ -1592,39 +1559,38 @@ done: herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) { - H5E_t *estack; /* Error stack to operate on */ - H5E_auto_op_t op; /* Error stack function */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_auto_op_t op; /* Error stack function */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", estack_id, func, client_data); - if(estack_id == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack_id == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else - if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Get the automatic error reporting information */ - if(H5E__get_auto(estack, &op, client_data) < 0) + if (H5E__get_auto(estack, &op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") #ifndef H5_NO_DEPRECATED_SYMBOLS /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto1 */ - if(!op.is_default && op.vers == 1) + if (!op.is_default && op.vers == 1) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto1 has been called") #endif /* H5_NO_DEPRECATED_SYMBOLS */ - if(func) + if (func) *func = op.func2; done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_auto2() */ - /*------------------------------------------------------------------------- * Function: H5Eset_auto2 * @@ -1650,29 +1616,29 @@ done: herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ - H5E_auto_op_t op; /* Error stack operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_auto_op_t op; /* Error stack operator */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE3("e", "ix*x", estack_id, func, client_data); - if(estack_id == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack_id == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else - if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") #ifndef H5_NO_DEPRECATED_SYMBOLS /* Get the automatic error reporting information */ - if(H5E__get_auto(estack, &op, NULL) < 0) + if (H5E__get_auto(estack, &op, NULL) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") /* Set the automatic error reporting information */ - if(func != op.func2_default) + if (func != op.func2_default) op.is_default = FALSE; else op.is_default = TRUE; @@ -1683,14 +1649,13 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) /* Set the automatic error reporting function */ op.func2 = func; - if(H5E__set_auto(estack, &op, client_data) < 0) + if (H5E__set_auto(estack, &op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") done: FUNC_LEAVE_API(ret_value) } /* end H5Eset_auto2() */ - /*------------------------------------------------------------------------- * Function: H5Eauto_is_v2 * @@ -1709,22 +1674,22 @@ done: herr_t H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) { - H5E_t *estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", estack_id, is_stack); - if(estack_id == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack_id == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else - if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Check if the error stack reporting function is the "newer" stack type */ - if(is_stack) + if (is_stack) #ifndef H5_NO_DEPRECATED_SYMBOLS *is_stack = estack->auto_op.vers > 1; #else @@ -1734,4 +1699,3 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) done: FUNC_LEAVE_API(ret_value) } /* end H5Eauto_is_v2() */ - diff --git a/src/H5EA.c b/src/H5EA.c index 56663dc..45572e9 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -31,30 +31,26 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -62,23 +58,18 @@ /* Typedef for generically unprotecting an object */ typedef herr_t (*H5EA__unprotect_func_t)(void *thing, unsigned cache_flags); - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t -H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, - unsigned thing_acc, void **thing, uint8_t **thing_elmt_buf, - hsize_t *thing_elmt_idx, H5EA__unprotect_func_t *thing_unprot_func); -static H5EA_t *H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, - void *ctx_udata); - +static herr_t H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned thing_acc, + void **thing, uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, + H5EA__unprotect_func_t *thing_unprot_func); +static H5EA_t *H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata); /*********************/ /* Package Variables */ @@ -93,17 +84,15 @@ hbool_t H5_PKG_INIT_VAR = FALSE; * client class.. */ const H5EA_class_t *const H5EA_client_class_g[] = { - H5EA_CLS_CHUNK, /* 0 - H5EA_CLS_CHUNK_ID */ - H5EA_CLS_FILT_CHUNK, /* 1 - H5EA_CLS_FILT_CHUNK_ID */ - H5EA_CLS_TEST, /* ? - H5EA_CLS_TEST_ID */ + H5EA_CLS_CHUNK, /* 0 - H5EA_CLS_CHUNK_ID */ + H5EA_CLS_FILT_CHUNK, /* 1 - H5EA_CLS_FILT_CHUNK_ID */ + H5EA_CLS_TEST, /* ? - H5EA_CLS_TEST_ID */ }; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -114,7 +103,6 @@ H5FL_DEFINE_STATIC(H5EA_t); /* Declare a PQ free list to manage the element */ H5FL_BLK_DEFINE(ea_native_elmt); - /*------------------------------------------------------------------------- * Function: H5EA__new * @@ -129,13 +117,12 @@ H5FL_BLK_DEFINE(ea_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -H5EA_t *, NULL, NULL, -H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) +BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, + H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) /* Local variables */ - H5EA_t *ea = NULL; /* Pointer to new extensible array */ - H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ + H5EA_t * ea = NULL; /* Pointer to new extensible array */ + H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ /* * Check arguments. @@ -144,25 +131,25 @@ H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) HDassert(H5F_addr_defined(ea_addr)); /* Allocate extensible array wrapper */ - if(NULL == (ea = H5FL_CALLOC(H5EA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array info") + if (NULL == (ea = H5FL_CALLOC(H5EA_t))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array info") /* Lock the array header into memory */ - if(NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + if (NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Check for pending array deletion */ - if(from_open && hdr->pending_delete) + if (from_open && hdr->pending_delete) H5E_THROW(H5E_CANTOPENOBJ, "can't open extensible array pending deletion") /* Point extensible array wrapper at header and bump it's ref count */ ea->hdr = hdr; - if(H5EA__hdr_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + if (H5EA__hdr_incr(ea->hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") /* Increment # of files using this array header */ - if(H5EA__hdr_fuse_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + if (H5EA__hdr_fuse_incr(ea->hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ ea->f = f; @@ -170,17 +157,16 @@ H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) /* Set the return value */ ret_value = ea; -CATCH + CATCH - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") - if(!ret_value) - if(ea && H5EA_close(ea) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + if (!ret_value) + if (ea && H5EA_close(ea) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") -END_FUNC(STATIC) /* end H5EA__new() */ +END_FUNC(STATIC) /* end H5EA__new() */ - /*------------------------------------------------------------------------- * Function: H5EA_create * @@ -195,13 +181,12 @@ END_FUNC(STATIC) /* end H5EA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -H5EA_t *, NULL, NULL, -H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) +BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, + H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) /* Local variables */ - H5EA_t *ea = NULL; /* Pointer to new extensible array */ - haddr_t ea_addr; /* Array header address */ + H5EA_t *ea = NULL; /* Pointer to new extensible array */ + haddr_t ea_addr; /* Array header address */ /* * Check arguments. @@ -213,25 +198,24 @@ H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) HDcompile_assert(H5EA_NUM_CLS_ID == NELMTS(H5EA_client_class_g)); /* Create extensible array header */ - if(HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create extensible array header") + if (HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, cparam, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "can't create extensible array header") /* Allocate and initialize new extensible array wrapper */ - if(NULL == (ea = H5EA__new(f, ea_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + if (NULL == (ea = H5EA__new(f, ea_addr, FALSE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; -CATCH + CATCH - if(!ret_value) - if(ea && H5EA_close(ea) < 0) + if (!ret_value) + if (ea && H5EA_close(ea) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_create() */ +END_FUNC(PRIV) /* end H5EA_create() */ - /*------------------------------------------------------------------------- * Function: H5EA_open * @@ -246,12 +230,10 @@ END_FUNC(PRIV) /* end H5EA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -H5EA_t *, NULL, NULL, -H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) +BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) /* Local variables */ - H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ + H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ /* * Check arguments. @@ -260,21 +242,20 @@ H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) HDassert(H5F_addr_defined(ea_addr)); /* Allocate and initialize new extensible array wrapper */ - if(NULL == (ea = H5EA__new(f, ea_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + if (NULL == (ea = H5EA__new(f, ea_addr, TRUE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; -CATCH + CATCH - if(!ret_value) - if(ea && H5EA_close(ea) < 0) + if (!ret_value) + if (ea && H5EA_close(ea) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_open() */ +END_FUNC(PRIV) /* end H5EA_open() */ - /*------------------------------------------------------------------------- * Function: H5EA_get_nelmts * @@ -288,9 +269,7 @@ END_FUNC(PRIV) /* end H5EA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) /* Local variables */ @@ -303,9 +282,8 @@ H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) /* Retrieve the max. index set */ *nelmts = ea->hdr->stats.stored.max_idx_set; -END_FUNC(PRIV) /* end H5EA_get_nelmts() */ +END_FUNC(PRIV) /* end H5EA_get_nelmts() */ - /*------------------------------------------------------------------------- * Function: H5EA_get_addr * @@ -319,9 +297,7 @@ END_FUNC(PRIV) /* end H5EA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) /* Local variables */ @@ -335,9 +311,8 @@ H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) /* Retrieve the address of the extensible array's header */ *addr = ea->hdr->addr; -END_FUNC(PRIV) /* end H5EA_get_addr() */ +END_FUNC(PRIV) /* end H5EA_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5EA__lookup_elmt * @@ -352,22 +327,21 @@ END_FUNC(PRIV) /* end H5EA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, - unsigned thing_acc, void **thing, uint8_t **thing_elmt_buf, - hsize_t *thing_elmt_idx, H5EA__unprotect_func_t *thing_unprot_func)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned thing_acc, + void **thing, uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, + H5EA__unprotect_func_t *thing_unprot_func)) /* Local variables */ - H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block for EA */ - H5EA_sblock_t *sblock = NULL; /* Pointer to super block for EA */ - H5EA_dblock_t *dblock = NULL; /* Pointer to data block for EA */ - H5EA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for EA */ - unsigned iblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting index block */ - unsigned sblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting super block */ - hbool_t stats_changed = FALSE; /* Whether array statistics changed */ - hbool_t hdr_dirty = FALSE; /* Whether the array header changed */ + H5EA_hdr_t * hdr = ea->hdr; /* Header for EA */ + H5EA_iblock_t * iblock = NULL; /* Pointer to index block for EA */ + H5EA_sblock_t * sblock = NULL; /* Pointer to super block for EA */ + H5EA_dblock_t * dblock = NULL; /* Pointer to data block for EA */ + H5EA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for EA */ + unsigned iblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting index block */ + unsigned sblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting super block */ + hbool_t stats_changed = FALSE; /* Whether array statistics changed */ + hbool_t hdr_dirty = FALSE; /* Whether the array header changed */ /* * Check arguments. @@ -385,18 +359,18 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, hdr->f = ea->f; /* Reset the pointers to the 'thing' info */ - *thing = NULL; - *thing_elmt_buf = NULL; - *thing_elmt_idx = 0; + *thing = NULL; + *thing_elmt_buf = NULL; + *thing_elmt_idx = 0; *thing_unprot_func = (H5EA__unprotect_func_t)NULL; /* Check if we should create the index block */ - if(!H5F_addr_defined(hdr->idx_blk_addr)) { + if (!H5F_addr_defined(hdr->idx_blk_addr)) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ /* Create the index block */ hdr->idx_blk_addr = H5EA__iblock_create(hdr, &stats_changed); - if(!H5F_addr_defined(hdr->idx_blk_addr)) + if (!H5F_addr_defined(hdr->idx_blk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create index block") hdr_dirty = TRUE; } /* end if */ @@ -405,21 +379,22 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, } /* end if */ /* Protect index block */ - if(NULL == (iblock = H5EA__iblock_protect(hdr, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", (unsigned long long)hdr->idx_blk_addr) + if (NULL == (iblock = H5EA__iblock_protect(hdr, thing_acc))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Check if element is in index block */ - if(idx < hdr->cparam.idx_blk_elmts) { + if (idx < hdr->cparam.idx_blk_elmts) { /* Set 'thing' info to refer to the index block */ - *thing = iblock; - *thing_elmt_buf = (uint8_t *)iblock->elmts; - *thing_elmt_idx = idx; + *thing = iblock; + *thing_elmt_buf = (uint8_t *)iblock->elmts; + *thing_elmt_idx = idx; *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__iblock_unprotect; } /* end if */ else { - unsigned sblk_idx; /* Which superblock does this index fall in? */ - size_t dblk_idx; /* Data block index */ - hsize_t elmt_idx; /* Offset of element in super block */ + unsigned sblk_idx; /* Which superblock does this index fall in? */ + size_t dblk_idx; /* Data block index */ + hsize_t elmt_idx; /* Offset of element in super block */ /* Get super block index where element is located */ sblk_idx = H5EA__dblock_sblk_idx(hdr, idx); @@ -428,22 +403,25 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, elmt_idx = idx - (hdr->cparam.idx_blk_elmts + hdr->sblk_info[sblk_idx].start_idx); /* Check for data block containing element address in the index block */ - if(sblk_idx < iblock->nsblks) { + if (sblk_idx < iblock->nsblks) { /* Compute the data block index in index block */ - dblk_idx = (size_t)(hdr->sblk_info[sblk_idx].start_dblk + (elmt_idx / hdr->sblk_info[sblk_idx].dblk_nelmts)); + dblk_idx = (size_t)(hdr->sblk_info[sblk_idx].start_dblk + + (elmt_idx / hdr->sblk_info[sblk_idx].dblk_nelmts)); HDassert(dblk_idx < iblock->ndblk_addrs); /* Check if the data block has been allocated on disk yet */ - if(!H5F_addr_defined(iblock->dblk_addrs[dblk_idx])) { + if (!H5F_addr_defined(iblock->dblk_addrs[dblk_idx])) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ - haddr_t dblk_addr; /* Address of data block created */ - hsize_t dblk_off; /* Offset of data block in array */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + haddr_t dblk_addr; /* Address of data block created */ + hsize_t dblk_off; /* Offset of data block in array */ /* Create data block */ - dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); - dblk_addr = H5EA__dblock_create(hdr, iblock, &stats_changed, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts); - if(!H5F_addr_defined(dblk_addr)) + dblk_off = hdr->sblk_info[sblk_idx].start_idx + + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); + dblk_addr = H5EA__dblock_create(hdr, iblock, &stats_changed, dblk_off, + hdr->sblk_info[sblk_idx].dblk_nelmts); + if (!H5F_addr_defined(dblk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") /* Set data block address in index block */ @@ -455,40 +433,44 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, } /* end if */ /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, iblock, iblock->dblk_addrs[dblk_idx], hdr->sblk_info[sblk_idx].dblk_nelmts, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)iblock->dblk_addrs[dblk_idx]) + if (NULL == (dblock = H5EA__dblock_protect(hdr, iblock, iblock->dblk_addrs[dblk_idx], + hdr->sblk_info[sblk_idx].dblk_nelmts, thing_acc))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", + (unsigned long long)iblock->dblk_addrs[dblk_idx]) /* Adjust index to offset in data block */ elmt_idx %= hdr->sblk_info[sblk_idx].dblk_nelmts; /* Check if there is already a dependency on the header */ - if(will_extend && !dblock->has_hdr_depend) { - if(H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block and header, index = %llu", (unsigned long long)idx) + if (will_extend && !dblock->has_hdr_depend) { + if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) + H5E_THROW(H5E_CANTDEPEND, + "unable to create flush dependency between data block and header, index = %llu", + (unsigned long long)idx) dblock->has_hdr_depend = TRUE; } /* end if */ /* Set 'thing' info to refer to the data block */ - *thing = dblock; - *thing_elmt_buf = (uint8_t *)dblock->elmts; - *thing_elmt_idx = elmt_idx; + *thing = dblock; + *thing_elmt_buf = (uint8_t *)dblock->elmts; + *thing_elmt_idx = elmt_idx; *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblock_unprotect; } /* end if */ else { - size_t sblk_off; /* Offset of super block in index block array of super blocks */ + size_t sblk_off; /* Offset of super block in index block array of super blocks */ /* Calculate offset of super block in index block's array */ sblk_off = sblk_idx - iblock->nsblks; /* Check if the super block has been allocated on disk yet */ - if(!H5F_addr_defined(iblock->sblk_addrs[sblk_off])) { + if (!H5F_addr_defined(iblock->sblk_addrs[sblk_off])) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ - haddr_t sblk_addr; /* Address of data block created */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + haddr_t sblk_addr; /* Address of data block created */ /* Create super block */ sblk_addr = H5EA__sblock_create(hdr, iblock, &stats_changed, sblk_idx); - if(!H5F_addr_defined(sblk_addr)) + if (!H5F_addr_defined(sblk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create extensible array super block") /* Set super block address in index block */ @@ -500,37 +482,45 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, } /* end if */ /* Protect super block */ - if(NULL == (sblock = H5EA__sblock_protect(hdr, iblock, iblock->sblk_addrs[sblk_off], sblk_idx, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)iblock->sblk_addrs[sblk_off]) + if (NULL == (sblock = H5EA__sblock_protect(hdr, iblock, iblock->sblk_addrs[sblk_off], sblk_idx, + thing_acc))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", + (unsigned long long)iblock->sblk_addrs[sblk_off]) /* Compute the data block index in super block */ dblk_idx = (size_t)(elmt_idx / sblock->dblk_nelmts); HDassert(dblk_idx < sblock->ndblks); /* Check if the data block has been allocated on disk yet */ - if(!H5F_addr_defined(sblock->dblk_addrs[dblk_idx])) { + if (!H5F_addr_defined(sblock->dblk_addrs[dblk_idx])) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ - haddr_t dblk_addr; /* Address of data block created */ - hsize_t dblk_off; /* Offset of data block in array */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + haddr_t dblk_addr; /* Address of data block created */ + hsize_t dblk_off; /* Offset of data block in array */ /* Create data block */ - dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); - dblk_addr = H5EA__dblock_create(hdr, sblock, &stats_changed, dblk_off, sblock->dblk_nelmts); - if(!H5F_addr_defined(dblk_addr)) + dblk_off = hdr->sblk_info[sblk_idx].start_idx + + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); + dblk_addr = + H5EA__dblock_create(hdr, sblock, &stats_changed, dblk_off, sblock->dblk_nelmts); + if (!H5F_addr_defined(dblk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") /* Set data block address in index block */ sblock->dblk_addrs[dblk_idx] = dblk_addr; sblock_cache_flags |= H5AC__DIRTIED_FLAG; - /* Create flush dependency on header, if extending the array and one doesn't already exist */ - if(will_extend && !sblock->has_hdr_depend) { - if(H5EA__create_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) + /* Create flush dependency on header, if extending the array and one doesn't already exist + */ + if (will_extend && !sblock->has_hdr_depend) { + if (H5EA__create_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) + H5E_THROW(H5E_CANTDEPEND, + "unable to create flush dependency between super block and header, " + "address = %llu", + (unsigned long long)sblock->addr) sblock->has_hdr_depend = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else H5_LEAVE(SUCCEED) } /* end if */ @@ -539,10 +529,10 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, elmt_idx %= sblock->dblk_nelmts; /* Check if the data block is paged */ - if(sblock->dblk_npages) { - haddr_t dblk_page_addr; /* Address of data block page */ - size_t page_idx; /* Index of page within data block */ - size_t page_init_idx; /* Index of 'page init' bit */ + if (sblock->dblk_npages) { + haddr_t dblk_page_addr; /* Address of data block page */ + size_t page_idx; /* Index of page within data block */ + size_t page_init_idx; /* Index of 'page init' bit */ /* Compute page index */ page_idx = (size_t)elmt_idx / hdr->dblk_page_nelmts; @@ -554,16 +544,15 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, elmt_idx %= hdr->dblk_page_nelmts; /* Compute data block page address */ - dblk_page_addr = sblock->dblk_addrs[dblk_idx] + - H5EA_DBLOCK_PREFIX_SIZE(sblock) + - (page_idx * sblock->dblk_page_size); + dblk_page_addr = sblock->dblk_addrs[dblk_idx] + H5EA_DBLOCK_PREFIX_SIZE(sblock) + + (page_idx * sblock->dblk_page_size); /* Check if page has been initialized yet */ - if(!H5VM_bit_get(sblock->page_init, page_init_idx)) { + if (!H5VM_bit_get(sblock->page_init, page_init_idx)) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ /* Create the data block page */ - if(H5EA__dblk_page_create(hdr, sblock, dblk_page_addr) < 0) + if (H5EA__dblk_page_create(hdr, sblock, dblk_page_addr) < 0) H5E_THROW(H5E_CANTCREATE, "unable to create data block page") /* Mark data block page as initialized in super block */ @@ -575,79 +564,89 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, } /* end if */ /* Protect data block page */ - if(NULL == (dblk_page = H5EA__dblk_page_protect(hdr, sblock, dblk_page_addr, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", (unsigned long long)dblk_page_addr) + if (NULL == (dblk_page = H5EA__dblk_page_protect(hdr, sblock, dblk_page_addr, thing_acc))) + H5E_THROW(H5E_CANTPROTECT, + "unable to protect extensible array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Check if there is already a dependency on the header */ - if(will_extend && !dblk_page->has_hdr_depend) { - if(H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block page and header, index = %llu", (unsigned long long)idx) + if (will_extend && !dblk_page->has_hdr_depend) { + if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW(H5E_CANTDEPEND, + "unable to create flush dependency between data block page and header, " + "index = %llu", + (unsigned long long)idx) dblk_page->has_hdr_depend = TRUE; } /* end if */ /* Set 'thing' info to refer to the data block page */ - *thing = dblk_page; - *thing_elmt_buf = (uint8_t *)dblk_page->elmts; - *thing_elmt_idx = elmt_idx; + *thing = dblk_page; + *thing_elmt_buf = (uint8_t *)dblk_page->elmts; + *thing_elmt_idx = elmt_idx; *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblk_page_unprotect; } /* end if */ else { /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, sblock, sblock->dblk_addrs[dblk_idx], sblock->dblk_nelmts, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)sblock->dblk_addrs[dblk_idx]) + if (NULL == (dblock = H5EA__dblock_protect(hdr, sblock, sblock->dblk_addrs[dblk_idx], + sblock->dblk_nelmts, thing_acc))) + H5E_THROW(H5E_CANTPROTECT, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)sblock->dblk_addrs[dblk_idx]) /* Check if there is already a dependency on the header */ - if(will_extend && !dblock->has_hdr_depend) { - if(H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block and header, index = %llu", (unsigned long long)idx) + if (will_extend && !dblock->has_hdr_depend) { + if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) + H5E_THROW( + H5E_CANTDEPEND, + "unable to create flush dependency between data block and header, index = %llu", + (unsigned long long)idx) dblock->has_hdr_depend = TRUE; } /* end if */ /* Set 'thing' info to refer to the data block */ - *thing = dblock; - *thing_elmt_buf = (uint8_t *)dblock->elmts; - *thing_elmt_idx = elmt_idx; + *thing = dblock; + *thing_elmt_buf = (uint8_t *)dblock->elmts; + *thing_elmt_idx = elmt_idx; *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblock_unprotect; } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Sanity checks */ HDassert(*thing != NULL); HDassert(*thing_unprot_func != NULL); -CATCH + CATCH /* Reset 'thing' info on error */ - if(ret_value < 0) { - *thing = NULL; - *thing_elmt_buf = NULL; - *thing_elmt_idx = 0; + if (ret_value < 0) { + *thing = NULL; + *thing_elmt_buf = NULL; + *thing_elmt_idx = 0; *thing_unprot_func = (H5EA__unprotect_func_t)NULL; } /* end if */ /* Check for updating array statistics */ - if(stats_changed) + if (stats_changed) hdr_dirty = TRUE; /* Check for header modified */ - if(hdr_dirty) - if(H5EA__hdr_modified(hdr) < 0) + if (hdr_dirty) + if (H5EA__hdr_modified(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") /* Release resources */ - if(iblock && *thing != iblock && H5EA__iblock_unprotect(iblock, iblock_cache_flags) < 0) + if (iblock && *thing != iblock && H5EA__iblock_unprotect(iblock, iblock_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") /* (Note: super blocks don't contain elements, so don't have a '*thing != sblock' check) */ - if(sblock && H5EA__sblock_unprotect(sblock, sblock_cache_flags) < 0) + if (sblock && H5EA__sblock_unprotect(sblock, sblock_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") - if(dblock && *thing != dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && *thing != dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") - if(dblk_page && *thing != dblk_page && H5EA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) + if (dblk_page && *thing != dblk_page && H5EA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block page") -END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ +END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ - /*------------------------------------------------------------------------- * Function: H5EA_set * @@ -661,18 +660,16 @@ END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) /* Local variables */ - H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ - void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ - uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ - hsize_t thing_elmt_idx; /* Index of the element in the element buffer for the array metadata */ - H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ - hbool_t will_extend; /* Flag indicating if setting the element will extend the array */ - unsigned thing_cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting array metadata */ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + void * thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ + uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ + hsize_t thing_elmt_idx; /* Index of the element in the element buffer for the array metadata */ + H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ + hbool_t will_extend; /* Flag indicating if setting the element will extend the array */ + unsigned thing_cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting array metadata */ /* * Check arguments. @@ -685,7 +682,8 @@ H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) /* Look up the array metadata containing the element we want to set */ will_extend = (idx >= hdr->stats.stored.max_idx_set); - if(H5EA__lookup_elmt(ea, idx, will_extend, H5AC__NO_FLAGS_SET, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) + if (H5EA__lookup_elmt(ea, idx, will_extend, H5AC__NO_FLAGS_SET, &thing, &thing_elmt_buf, &thing_elmt_idx, + &thing_unprot_func) < 0) H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") /* Sanity check */ @@ -694,25 +692,25 @@ H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) HDassert(thing_unprot_func); /* Set element in thing's element buffer */ - H5MM_memcpy(thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), elmt, + hdr->cparam.cls->nat_elmt_size); thing_cache_flags |= H5AC__DIRTIED_FLAG; /* Update max. element set in array, if appropriate */ - if(will_extend) { + if (will_extend) { /* Update the max index for the array */ hdr->stats.stored.max_idx_set = idx + 1; - if(H5EA__hdr_modified(hdr) < 0) + if (H5EA__hdr_modified(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") } /* end if */ -CATCH + CATCH /* Release resources */ - if(thing && (thing_unprot_func)(thing, thing_cache_flags) < 0) + if (thing && (thing_unprot_func)(thing, thing_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_set() */ +END_FUNC(PRIV) /* end H5EA_set() */ - /*------------------------------------------------------------------------- * Function: H5EA_get * @@ -726,14 +724,12 @@ END_FUNC(PRIV) /* end H5EA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt)) /* Local variables */ - H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ - void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ - H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ + H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ /* * Check arguments. @@ -742,41 +738,42 @@ H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt)) HDassert(hdr); /* Check for element beyond max. element in array */ - if(idx >= hdr->stats.stored.max_idx_set) { + if (idx >= hdr->stats.stored.max_idx_set) { /* Call the class's 'fill' callback */ - if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) + if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") } /* end if */ else { - uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ - hsize_t thing_elmt_idx; /* Index of the element in the element buffer for the array metadata */ + uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ + hsize_t thing_elmt_idx; /* Index of the element in the element buffer for the array metadata */ /* Set the shared array header's file context for this operation */ hdr->f = ea->f; /* Look up the array metadata containing the element we want to set */ - if(H5EA__lookup_elmt(ea, idx, FALSE, H5AC__READ_ONLY_FLAG, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) + if (H5EA__lookup_elmt(ea, idx, FALSE, H5AC__READ_ONLY_FLAG, &thing, &thing_elmt_buf, &thing_elmt_idx, + &thing_unprot_func) < 0) H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") /* Check if the thing holding the element has been created yet */ - if(NULL == thing) { + if (NULL == thing) { /* Call the class's 'fill' callback */ - if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) + if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") } /* end if */ else /* Get element from thing's element buffer */ - H5MM_memcpy(elmt, thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(elmt, thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), + hdr->cparam.cls->nat_elmt_size); } /* end else */ -CATCH + CATCH /* Release thing */ - if(thing && (thing_unprot_func)(thing, H5AC__NO_FLAGS_SET) < 0) + if (thing && (thing_unprot_func)(thing, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_get() */ +END_FUNC(PRIV) /* end H5EA_get() */ - /*------------------------------------------------------------------------- * Function: H5EA_depend * @@ -791,12 +788,10 @@ END_FUNC(PRIV) /* end H5EA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) /* Local variables */ - H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ /* * Check arguments. @@ -810,7 +805,7 @@ H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) * and another data structure in the file has already been set up. * If it hasn't, do so now. */ - if(NULL == hdr->parent) { + if (NULL == hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); @@ -818,16 +813,15 @@ H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) hdr->f = ea->f; /* Add the extensible array as a child of the parent (proxy) */ - if(H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) + if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array as child of proxy") hdr->parent = parent; } /* end if */ -CATCH + CATCH -END_FUNC(PRIV) /* end H5EA_depend() */ +END_FUNC(PRIV) /* end H5EA_depend() */ - /*------------------------------------------------------------------------- * Function: H5EA_close * @@ -841,13 +835,11 @@ END_FUNC(PRIV) /* end H5EA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5EA_close(H5EA_t *ea)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) /* Local variables */ - hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ - haddr_t ea_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ + haddr_t ea_addr = HADDR_UNDEF; /* Address of array (for deletion) */ /* * Check arguments. @@ -855,46 +847,48 @@ H5EA_close(H5EA_t *ea)) HDassert(ea); /* Close the header, if it was set */ - if(ea->hdr) { - /* Decrement file reference & check if this is the last open extensible array using the shared array header */ - if(0 == H5EA__hdr_fuse_decr(ea->hdr)) { + if (ea->hdr) { + /* Decrement file reference & check if this is the last open extensible array using the shared array + * header */ + if (0 == H5EA__hdr_fuse_decr(ea->hdr)) { /* Set the shared array header's file context for this operation */ ea->hdr->f = ea->f; /* Shut down anything that can't be put in the header's 'flush' callback */ /* Check for pending array deletion */ - if(ea->hdr->pending_delete) { + if (ea->hdr->pending_delete) { /* Set local info, so array deletion can occur after decrementing the * header's ref count */ pending_delete = TRUE; - ea_addr = ea->hdr->addr; + ea_addr = ea->hdr->addr; } /* end if */ - } /* end if */ + } /* end if */ /* Check for pending array deletion */ - if(pending_delete) { - H5EA_hdr_t *hdr; /* Another pointer to extensible array header */ + if (pending_delete) { + H5EA_hdr_t *hdr; /* Another pointer to extensible array header */ #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Header's status in the metadata cache */ - - /* Check the header's status in the metadata cache */ - if(H5AC_get_entry_status(ea->f, ea_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for extensible array header") - - /* Sanity checks on header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PINNED); - HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); -} + { + unsigned hdr_status = 0; /* Header's status in the metadata cache */ + + /* Check the header's status in the metadata cache */ + if (H5AC_get_entry_status(ea->f, ea_addr, &hdr_status) < 0) + H5E_THROW(H5E_CANTGET, + "unable to check metadata cache status for extensible array header") + + /* Sanity checks on header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PINNED); + HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); + } #endif /* NDEBUG */ /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = H5EA__hdr_protect(ea->f, ea_addr, NULL, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5EA__hdr_protect(ea->f, ea_addr, NULL, H5AC__NO_FLAGS_SET))) H5E_THROW(H5E_CANTLOAD, "unable to load extensible array header") /* Set the shared array header's file context for this operation */ @@ -904,11 +898,11 @@ H5EA_close(H5EA_t *ea)) /* (don't put in H5EA_hdr_fuse_decr() as the array header may be evicted * immediately -QAK) */ - if(H5EA__hdr_decr(ea->hdr) < 0) + if (H5EA__hdr_decr(ea->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ - if(H5EA__hdr_delete(hdr) < 0) + if (H5EA__hdr_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") } /* end if */ else { @@ -916,19 +910,18 @@ H5EA_close(H5EA_t *ea)) /* (don't put in H5EA_hdr_fuse_decr() as the array header may be evicted * immediately -QAK) */ - if(H5EA__hdr_decr(ea->hdr) < 0) + if (H5EA__hdr_decr(ea->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") } /* end else */ - } /* end if */ + } /* end if */ /* Release the extensible array wrapper */ ea = (H5EA_t *)H5FL_FREE(H5EA_t, ea); -CATCH + CATCH -END_FUNC(PRIV) /* end H5EA_close() */ +END_FUNC(PRIV) /* end H5EA_close() */ - /*------------------------------------------------------------------------- * Function: H5EA_delete * @@ -942,12 +935,10 @@ END_FUNC(PRIV) /* end H5EA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ + H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ /* * Check arguments. @@ -956,31 +947,31 @@ H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) HDassert(H5F_addr_defined(ea_addr)); /* Lock the array header into memory */ - if(NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) + if (NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", + (unsigned long long)ea_addr) /* Check for files using shared array header */ - if(hdr->file_rc) + if (hdr->file_rc) hdr->pending_delete = TRUE; else { /* Set the shared array header's file context for this operation */ hdr->f = f; /* Delete array now, starting with header (unprotects header) */ - if(H5EA__hdr_delete(hdr) < 0) + if (H5EA__hdr_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") hdr = NULL; } /* end if */ -CATCH + CATCH /* Unprotect the header, if an error occurred */ - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PRIV) /* end H5EA_delete() */ +END_FUNC(PRIV) /* end H5EA_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA_iterate * @@ -993,14 +984,13 @@ END_FUNC(PRIV) /* end H5EA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -int, H5_ITER_CONT, H5_ITER_ERROR, -H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) +BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, + H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) /* Local variables */ - uint8_t *elmt = NULL; - hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + uint8_t *elmt = NULL; + hsize_t u; + int cb_ret = H5_ITER_CONT; /* Return value from callback */ /* Check arguments */ HDassert(ea); @@ -1008,30 +998,29 @@ H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) HDassert(udata); /* Allocate space for a native array element */ - if(NULL == (elmt = H5FL_BLK_MALLOC(ea_native_elmt, ea->hdr->cparam.cls->nat_elmt_size))) + if (NULL == (elmt = H5FL_BLK_MALLOC(ea_native_elmt, ea->hdr->cparam.cls->nat_elmt_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array element") /* Iterate over all elements in array */ - for(u = 0; u < ea->hdr->stats.stored.max_idx_set && cb_ret == H5_ITER_CONT; u++) { + for (u = 0; u < ea->hdr->stats.stored.max_idx_set && cb_ret == H5_ITER_CONT; u++) { /* Get array element */ - if(H5EA_get(ea, u, elmt) < 0) + if (H5EA_get(ea, u, elmt) < 0) H5E_THROW(H5E_CANTGET, "unable to delete fixed array") /* Make callback */ - if((cb_ret = (*op)(u, elmt, udata)) < 0) { + if ((cb_ret = (*op)(u, elmt, udata)) < 0) { H5E_PRINTF(H5E_BADITER, "iterator function failed"); H5_LEAVE(cb_ret) } /* end if */ - } /* end for */ + } /* end for */ -CATCH + CATCH - if(elmt) + if (elmt) elmt = H5FL_BLK_FREE(ea_native_elmt, elmt); -END_FUNC(PRIV) /* end H5EA_iterate() */ +END_FUNC(PRIV) /* end H5EA_iterate() */ - /*------------------------------------------------------------------------- * Function: H5EA_patch_file * @@ -1044,9 +1033,7 @@ END_FUNC(PRIV) /* end H5EA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5EA_patch_file(H5EA_t *ea, H5F_t *f)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_patch_file(H5EA_t *ea, H5F_t *f)) /* Local variables */ @@ -1056,8 +1043,7 @@ H5EA_patch_file(H5EA_t *ea, H5F_t *f)) HDassert(ea); HDassert(f); - if(ea->f != f || ea->hdr->f != f) + if (ea->f != f || ea->hdr->f != f) ea->f = ea->hdr->f = f; -END_FUNC(PRIV) /* end H5EA_patch_file() */ - +END_FUNC(PRIV) /* end H5EA_patch_file() */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 2ae4f84..876ef34 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -26,47 +26,41 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* Fractal heap format version #'s */ -#define H5EA_HDR_VERSION 0 /* Header */ -#define H5EA_IBLOCK_VERSION 0 /* Index block */ -#define H5EA_SBLOCK_VERSION 0 /* Super block */ -#define H5EA_DBLOCK_VERSION 0 /* Data block */ - +#define H5EA_HDR_VERSION 0 /* Header */ +#define H5EA_IBLOCK_VERSION 0 /* Index block */ +#define H5EA_SBLOCK_VERSION 0 /* Super block */ +#define H5EA_DBLOCK_VERSION 0 /* Data block */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -74,168 +68,152 @@ /* Metadata cache (H5AC) callbacks */ static herr_t H5EA__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5EA__cache_hdr_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5EA__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_hdr_image_len(const void *thing, size_t *image_len); -static herr_t H5EA__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5EA__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *thing); static herr_t H5EA__cache_hdr_free_icr(void *thing); static herr_t H5EA__cache_iblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_iblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5EA__cache_iblock_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5EA__cache_iblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_iblock_image_len(const void *thing, size_t *image_len); -static herr_t H5EA__cache_iblock_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5EA__cache_iblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *thing); static herr_t H5EA__cache_iblock_free_icr(void *thing); static herr_t H5EA__cache_sblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_sblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5EA__cache_sblock_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5EA__cache_sblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_sblock_image_len(const void *thing, size_t *image_len); -static herr_t H5EA__cache_sblock_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5EA__cache_sblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *thing); static herr_t H5EA__cache_sblock_free_icr(void *thing); static herr_t H5EA__cache_dblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_dblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5EA__cache_dblock_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5EA__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_dblock_image_len(const void *thing, size_t *image_len); -static herr_t H5EA__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5EA__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *thing); static herr_t H5EA__cache_dblock_free_icr(void *thing); static herr_t H5EA__cache_dblock_fsf_size(const void *thing, hsize_t *fsf_size); static herr_t H5EA__cache_dblk_page_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_dblk_page_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5EA__cache_dblk_page_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); -static herr_t H5EA__cache_dblk_page_image_len(const void *thing, - size_t *image_len); -static herr_t H5EA__cache_dblk_page_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static void * H5EA__cache_dblk_page_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static herr_t H5EA__cache_dblk_page_image_len(const void *thing, size_t *image_len); +static herr_t H5EA__cache_dblk_page_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *thing); static herr_t H5EA__cache_dblk_page_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5EA header inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_HDR[1] = {{ - H5AC_EARRAY_HDR_ID, /* Metadata client ID */ - "Extensible Array Header", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_HDR, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5EA__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_hdr_deserialize, /* 'deserialize' callback */ - H5EA__cache_hdr_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_hdr_serialize, /* 'serialize' callback */ - H5EA__cache_hdr_notify, /* 'notify' callback */ - H5EA__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_EARRAY_HDR_ID, /* Metadata client ID */ + "Extensible Array Header", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_HDR, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5EA__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_hdr_deserialize, /* 'deserialize' callback */ + H5EA__cache_hdr_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_hdr_serialize, /* 'serialize' callback */ + H5EA__cache_hdr_notify, /* 'notify' callback */ + H5EA__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5EA index block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_IBLOCK[1] = {{ - H5AC_EARRAY_IBLOCK_ID, /* Metadata client ID */ - "Extensible Array Index Block", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_IBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5EA__cache_iblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_iblock_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_iblock_deserialize, /* 'deserialize' callback */ - H5EA__cache_iblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_iblock_serialize, /* 'serialize' callback */ - H5EA__cache_iblock_notify, /* 'notify' callback */ - H5EA__cache_iblock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_EARRAY_IBLOCK_ID, /* Metadata client ID */ + "Extensible Array Index Block", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_IBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5EA__cache_iblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_iblock_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_iblock_deserialize, /* 'deserialize' callback */ + H5EA__cache_iblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_iblock_serialize, /* 'serialize' callback */ + H5EA__cache_iblock_notify, /* 'notify' callback */ + H5EA__cache_iblock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5EA super block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_SBLOCK[1] = {{ - H5AC_EARRAY_SBLOCK_ID, /* Metadata client ID */ - "Extensible Array Super Block", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_SBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5EA__cache_sblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_sblock_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_sblock_deserialize, /* 'deserialize' callback */ - H5EA__cache_sblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_sblock_serialize, /* 'serialize' callback */ - H5EA__cache_sblock_notify, /* 'notify' callback */ - H5EA__cache_sblock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_EARRAY_SBLOCK_ID, /* Metadata client ID */ + "Extensible Array Super Block", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_SBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5EA__cache_sblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_sblock_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_sblock_deserialize, /* 'deserialize' callback */ + H5EA__cache_sblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_sblock_serialize, /* 'serialize' callback */ + H5EA__cache_sblock_notify, /* 'notify' callback */ + H5EA__cache_sblock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5EA data block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_DBLOCK[1] = {{ - H5AC_EARRAY_DBLOCK_ID, /* Metadata client ID */ - "Extensible Array Data Block", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_DBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5EA__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_dblock_deserialize, /* 'deserialize' callback */ - H5EA__cache_dblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_dblock_serialize, /* 'serialize' callback */ - H5EA__cache_dblock_notify, /* 'notify' callback */ - H5EA__cache_dblock_free_icr, /* 'free_icr' callback */ - H5EA__cache_dblock_fsf_size, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_EARRAY_DBLOCK_ID, /* Metadata client ID */ + "Extensible Array Data Block", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_DBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5EA__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_dblock_deserialize, /* 'deserialize' callback */ + H5EA__cache_dblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_dblock_serialize, /* 'serialize' callback */ + H5EA__cache_dblock_notify, /* 'notify' callback */ + H5EA__cache_dblock_free_icr, /* 'free_icr' callback */ + H5EA__cache_dblock_fsf_size, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5EA data block page inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ - H5AC_EARRAY_DBLK_PAGE_ID, /* Metadata client ID */ - "Extensible Array Data Block Page", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_DBLK_PAGE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_EARRAY_DBLK_PAGE_ID, /* Metadata client ID */ + "Extensible Array Data Block Page", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_DBLK_PAGE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5EA__cache_dblk_page_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_dblk_page_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_dblk_page_deserialize, /* 'deserialize' callback */ - H5EA__cache_dblk_page_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_dblk_page_serialize, /* 'serialize' callback */ - H5EA__cache_dblk_page_notify, /* 'notify' callback */ - H5EA__cache_dblk_page_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_dblk_page_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_dblk_page_deserialize, /* 'deserialize' callback */ + H5EA__cache_dblk_page_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_dblk_page_serialize, /* 'serialize' callback */ + H5EA__cache_dblk_page_notify, /* 'notify' callback */ + H5EA__cache_dblk_page_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_get_initial_load_size * @@ -249,9 +227,8 @@ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; /* User data for callback */ @@ -264,9 +241,8 @@ H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) /* Set the image length size */ *image_len = (size_t)H5EA_HEADER_SIZE_FILE(udata->f); -END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_verify_chksum * @@ -280,14 +256,13 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -htri_t, TRUE, -, -H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) +BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, + H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) /* Local variables */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(image); @@ -295,12 +270,11 @@ H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_deserialize * @@ -315,17 +289,16 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ - H5EA_cls_id_t id; /* ID of extensible array class, as found in file */ - H5EA_hdr_t *hdr = NULL; /* Extensible array info */ + H5EA_cls_id_t id; /* ID of extensible array class, as found in file */ + H5EA_hdr_t * hdr = NULL; /* Extensible array info */ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ /* Check arguments */ HDassert(image); @@ -334,37 +307,40 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert(H5F_addr_defined(udata->addr)); /* Allocate space for the extensible array data structure */ - if(NULL == (hdr = H5EA__hdr_alloc(udata->f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + if (NULL == (hdr = H5EA__hdr_alloc(udata->f))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set the extensible array header's address */ hdr->addr = udata->addr; /* Magic number */ - if(HDmemcmp(image, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header signature") + if (HDmemcmp(image, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + H5E_THROW(H5E_BADVALUE, "wrong extensible array header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5EA_HDR_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array header version") + if (*image++ != H5EA_HDR_VERSION) + H5E_THROW(H5E_VERSION, "wrong extensible array header version") /* Extensible array class */ id = (H5EA_cls_id_t)*image++; - if(id >= H5EA_NUM_CLS_ID) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + if (id >= H5EA_NUM_CLS_ID) + H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") hdr->cparam.cls = H5EA_client_class_g[id]; /* General array creation/configuration information */ - hdr->cparam.raw_elmt_size = *image++; /* Element size in file (in bytes) */ - hdr->cparam.max_nelmts_bits = *image++; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ - hdr->cparam.idx_blk_elmts = *image++; /* # of elements to store in index block */ - hdr->cparam.data_blk_min_elmts = *image++; /* Min. # of elements per data block */ - hdr->cparam.sup_blk_min_data_ptrs = *image++; /* Min. # of data block pointers for a super block */ - hdr->cparam.max_dblk_page_nelmts_bits = *image++; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + hdr->cparam.raw_elmt_size = *image++; /* Element size in file (in bytes) */ + hdr->cparam.max_nelmts_bits = + *image++; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ + hdr->cparam.idx_blk_elmts = *image++; /* # of elements to store in index block */ + hdr->cparam.data_blk_min_elmts = *image++; /* Min. # of elements per data block */ + hdr->cparam.sup_blk_min_data_ptrs = *image++; /* Min. # of data block pointers for a super block */ + hdr->cparam.max_dblk_page_nelmts_bits = + *image++; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of + elements in data block page */ /* Array statistics */ - hdr->stats.computed.hdr_size = len; /* Size of header in file */ + hdr->stats.computed.hdr_size = len; /* Size of header in file */ H5F_DECODE_LENGTH(udata->f, image, hdr->stats.stored.nsuper_blks); /* Number of super blocks created */ H5F_DECODE_LENGTH(udata->f, image, hdr->stats.stored.super_blk_size); /* Size of super blocks created */ H5F_DECODE_LENGTH(udata->f, image, hdr->stats.stored.ndata_blks); /* Number of data blocks created */ @@ -376,15 +352,15 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, H5F_addr_decode(udata->f, &image, &hdr->idx_blk_addr); /* Address of index block */ /* Index block statistics */ - if(H5F_addr_defined(hdr->idx_blk_addr)) { - H5EA_iblock_t iblock; /* Fake index block for computing size */ + if (H5F_addr_defined(hdr->idx_blk_addr)) { + H5EA_iblock_t iblock; /* Fake index block for computing size */ /* Set index block count for file */ hdr->stats.computed.nindex_blks = 1; /* Set up fake index block for computing size on disk */ - iblock.hdr = hdr; - iblock.nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); + iblock.hdr = hdr; + iblock.nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); iblock.ndblk_addrs = 2 * ((size_t)hdr->cparam.sup_blk_min_data_ptrs - 1); iblock.nsblk_addrs = hdr->nsblks - iblock.nsblks; @@ -392,9 +368,9 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hdr->stats.computed.index_blk_size = H5EA_IBLOCK_SIZE(&iblock); } /* end if */ else { - hdr->stats.computed.nindex_blks = 0; /* Number of index blocks in file */ - hdr->stats.computed.index_blk_size = 0; /* Size of index blocks in file */ - } /* end else */ + hdr->stats.computed.nindex_blks = 0; /* Number of index blocks in file */ + hdr->stats.computed.index_blk_size = 0; /* Size of index blocks in file */ + } /* end else */ /* Sanity check */ /* (allow for checksum not decoded yet) */ @@ -409,23 +385,22 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert((size_t)(image - (const uint8_t *)_image) == len); /* Finish initializing extensible array header */ - if(H5EA__hdr_init(hdr, udata->ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + if (H5EA__hdr_init(hdr, udata->ctx_udata) < 0) + H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(hdr && H5EA__hdr_dest(hdr) < 0) + if (!ret_value) + if (hdr && H5EA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") -END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_image_len * @@ -439,12 +414,11 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_hdr_t *hdr = (const H5EA_hdr_t *)_thing; /* Pointer to the object */ + const H5EA_hdr_t *hdr = (const H5EA_hdr_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(hdr); @@ -453,9 +427,8 @@ H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_serialize * @@ -469,15 +442,13 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) /* Local variables */ - H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the extensible array header */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the extensible array header */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* check arguments */ HDassert(f); @@ -496,12 +467,15 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = (uint8_t)hdr->cparam.cls->id; /* General array creation/configuration information */ - *image++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */ - *image++ = hdr->cparam.max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ - *image++ = hdr->cparam.idx_blk_elmts; /* # of elements to store in index block */ - *image++ = hdr->cparam.data_blk_min_elmts; /* Min. # of elements per data block */ - *image++ = hdr->cparam.sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ - *image++ = hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + *image++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */ + *image++ = hdr->cparam.max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to + store max. # of elements */ + *image++ = hdr->cparam.idx_blk_elmts; /* # of elements to store in index block */ + *image++ = hdr->cparam.data_blk_min_elmts; /* Min. # of elements per data block */ + *image++ = hdr->cparam.sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ + *image++ = + hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits + needed to store max. # of elements in data block page */ /* Array statistics */ H5F_ENCODE_LENGTH(f, image, hdr->stats.stored.nsuper_blks); /* Number of super blocks created */ @@ -512,7 +486,7 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le H5F_ENCODE_LENGTH(f, image, hdr->stats.stored.nelmts); /* Number of elements 'realized' */ /* Internal information */ - H5F_addr_encode(f, &image, hdr->idx_blk_addr); /* Address of index block */ + H5F_addr_encode(f, &image, hdr->idx_blk_addr); /* Address of index block */ /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -523,9 +497,8 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_notify * @@ -538,70 +511,71 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ + H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(hdr); /* Check if the file was opened with SWMR-write access */ - if(hdr->swmr_write) { + if (hdr->swmr_write) { /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; - case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* If hdr->parent != NULL, hdr->parent is used to destroy * the flush dependency before the header is evicted. */ - if(hdr->parent) { + if (hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); - /* Destroy flush dependency on object header proxy */ - if(H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between extensible array and proxy") + /* Destroy flush dependency on object header proxy */ + if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, + (void *)hdr->top_proxy) < 0) + H5E_THROW(H5E_CANTUNDEPEND, + "unable to destroy flush dependency between extensible array and proxy") hdr->parent = NULL; - } /* end if */ + } /* end if */ /* Detach from 'top' proxy for extensible array */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between header and extensible array 'top' proxy") + if (hdr->top_proxy) { + if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between header and " + "extensible array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ - break; + break; default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == hdr->parent); -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_free_icr * @@ -616,22 +590,19 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_hdr_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_hdr_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array header */ - if(H5EA__hdr_dest((H5EA_hdr_t *)thing) < 0) + if (H5EA__hdr_dest((H5EA_hdr_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array header") -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_get_initial_load_size * @@ -645,13 +616,12 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5EA_hdr_t *hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ - H5EA_iblock_t iblock; /* Fake index block for computing size */ + H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ + H5EA_iblock_t iblock; /* Fake index block for computing size */ /* Check arguments */ HDassert(hdr); @@ -659,17 +629,16 @@ H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Set up fake index block for computing size on disk */ HDmemset(&iblock, 0, sizeof(iblock)); - iblock.hdr = (H5EA_hdr_t *)hdr; /* Casting away 'const' OK - QAK */ - iblock.nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); + iblock.hdr = (H5EA_hdr_t *)hdr; /* Casting away 'const' OK - QAK */ + iblock.nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); iblock.ndblk_addrs = 2 * ((size_t)hdr->cparam.sup_blk_min_data_ptrs - 1); iblock.nsblk_addrs = hdr->nsblks - iblock.nsblks; /* Set the image length size */ *image_len = (size_t)H5EA_IBLOCK_SIZE(&iblock); -END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_verify_chksum * @@ -683,14 +652,13 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -htri_t, TRUE, -, -H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) +BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, + H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) /* Local variables */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(image); @@ -698,12 +666,11 @@ H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_deserialize * @@ -718,69 +685,69 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5EA__cache_iblock_deserialize(const void *_image, size_t len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Index block info */ - H5EA_hdr_t *hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - haddr_t arr_addr; /* Address of array header in the file */ - size_t u; /* Local index variable */ + H5EA_iblock_t *iblock = NULL; /* Index block info */ + H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + haddr_t arr_addr; /* Address of array header in the file */ + size_t u; /* Local index variable */ /* Check arguments */ HDassert(image); HDassert(hdr); /* Allocate the extensible array index block */ - if(NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + if (NULL == (iblock = H5EA__iblock_alloc(hdr))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") /* Set the extensible array index block's address */ iblock->addr = hdr->idx_blk_addr; /* Magic number */ - if(HDmemcmp(image, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array index block signature") + if (HDmemcmp(image, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + H5E_THROW(H5E_BADVALUE, "wrong extensible array index block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5EA_IBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array index block version") + if (*image++ != H5EA_IBLOCK_VERSION) + H5E_THROW(H5E_VERSION, "wrong extensible array index block version") /* Extensible array type */ - if(*image++ != (uint8_t)hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + if (*image++ != (uint8_t)hdr->cparam.cls->id) + H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(hdr->f, &image, &arr_addr); - if(H5F_addr_ne(arr_addr, hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + if (H5F_addr_ne(arr_addr, hdr->addr)) + H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") /* Internal information */ /* Decode elements in index block */ - if(hdr->cparam.idx_blk_elmts > 0) { + if (hdr->cparam.idx_blk_elmts > 0) { /* Convert from raw elements on disk into native elements in memory */ - if((hdr->cparam.cls->decode)(image, iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts, hdr->cb_ctx) < 0) + if ((hdr->cparam.cls->decode)(image, iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts, hdr->cb_ctx) < + 0) H5E_THROW(H5E_CANTDECODE, "can't decode extensible array index elements") image += (hdr->cparam.idx_blk_elmts * hdr->cparam.raw_elmt_size); } /* end if */ /* Decode data block addresses in index block */ - if(iblock->ndblk_addrs > 0) { + if (iblock->ndblk_addrs > 0) { /* Decode addresses of data blocks in index block */ - for(u = 0; u < iblock->ndblk_addrs; u++) + for (u = 0; u < iblock->ndblk_addrs; u++) H5F_addr_decode(hdr->f, &image, &iblock->dblk_addrs[u]); } /* end if */ /* Decode super block addresses in index block */ - if(iblock->nsblk_addrs > 0) { + if (iblock->nsblk_addrs > 0) { /* Decode addresses of super blocks in index block */ - for(u = 0; u < iblock->nsblk_addrs; u++) + for (u = 0; u < iblock->nsblk_addrs; u++) H5F_addr_decode(hdr->f, &image, &iblock->sblk_addrs[u]); } /* end if */ @@ -802,16 +769,15 @@ H5EA__cache_iblock_deserialize(const void *_image, size_t len, /* Set return value */ ret_value = iblock; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(iblock && H5EA__iblock_dest(iblock) < 0) + if (!ret_value) + if (iblock && H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") -END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_image_len * @@ -825,12 +791,11 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_iblock_t *iblock = (const H5EA_iblock_t *)_thing; /* Pointer to the object */ + const H5EA_iblock_t *iblock = (const H5EA_iblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(iblock); @@ -839,9 +804,8 @@ H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = iblock->size; -END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_serialize * @@ -855,15 +819,14 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing)) /* Local variables */ - H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object to serialize */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object to serialize */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* check arguments */ HDassert(f); @@ -890,28 +853,29 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Internal information */ /* Encode elements in index block */ - if(iblock->hdr->cparam.idx_blk_elmts > 0) { + if (iblock->hdr->cparam.idx_blk_elmts > 0) { /* Convert from native elements in memory into raw elements on disk */ - if((iblock->hdr->cparam.cls->encode)(image, iblock->elmts, (size_t)iblock->hdr->cparam.idx_blk_elmts, iblock->hdr->cb_ctx) < 0) + if ((iblock->hdr->cparam.cls->encode)(image, iblock->elmts, (size_t)iblock->hdr->cparam.idx_blk_elmts, + iblock->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTENCODE, "can't encode extensible array index elements") image += (iblock->hdr->cparam.idx_blk_elmts * iblock->hdr->cparam.raw_elmt_size); } /* end if */ /* Encode data block addresses in index block */ - if(iblock->ndblk_addrs > 0) { - size_t u; /* Local index variable */ + if (iblock->ndblk_addrs > 0) { + size_t u; /* Local index variable */ /* Encode addresses of data blocks in index block */ - for(u = 0; u < iblock->ndblk_addrs; u++) + for (u = 0; u < iblock->ndblk_addrs; u++) H5F_addr_encode(f, &image, iblock->dblk_addrs[u]); } /* end if */ /* Encode data block addresses in index block */ - if(iblock->nsblk_addrs > 0) { - size_t u; /* Local index variable */ + if (iblock->nsblk_addrs > 0) { + size_t u; /* Local index variable */ /* Encode addresses of super blocks in index block */ - for(u = 0; u < iblock->nsblk_addrs; u++) + for (u = 0; u < iblock->nsblk_addrs; u++) H5F_addr_encode(f, &image, iblock->sblk_addrs[u]); } /* end if */ @@ -924,11 +888,10 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_notify * @@ -942,23 +905,24 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ + H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(iblock); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on extensible array header */ - if(H5EA__create_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between index block and header, address = %llu", (unsigned long long)iblock->addr) + if (H5EA__create_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) + H5E_THROW(H5E_CANTDEPEND, + "unable to create flush dependency between index block and header, address = %llu", + (unsigned long long)iblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -973,13 +937,16 @@ H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on extensible array header */ - if(H5EA__destroy_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between index block and header, address = %llu", (unsigned long long)iblock->addr) + if (H5EA__destroy_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, + "unable to destroy flush dependency between index block and header, address = %llu", + (unsigned long long)iblock->addr) /* Detach from 'top' proxy for extensible array */ - if(iblock->top_proxy) { - if(H5AC_proxy_entry_remove_child(iblock->top_proxy, iblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between index block and extensible array 'top' proxy") + if (iblock->top_proxy) { + if (H5AC_proxy_entry_remove_child(iblock->top_proxy, iblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between index block and " + "extensible array 'top' proxy") iblock->top_proxy = NULL; } /* end if */ break; @@ -987,16 +954,15 @@ H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_free_icr * @@ -1011,22 +977,19 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_iblock_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_iblock_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array index block */ - if(H5EA__iblock_dest((H5EA_iblock_t *)thing) < 0) + if (H5EA__iblock_dest((H5EA_iblock_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array index block") -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_get_initial_load_size * @@ -1040,13 +1003,12 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ - H5EA_sblock_t sblock; /* Fake super block for computing size */ + H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ + H5EA_sblock_t sblock; /* Fake super block for computing size */ /* Check arguments */ HDassert(udata); @@ -1058,12 +1020,12 @@ H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Set up fake super block for computing size on disk */ /* (Note: extracted from H5EA__sblock_alloc) */ HDmemset(&sblock, 0, sizeof(sblock)); - sblock.hdr = udata->hdr; - sblock.ndblks = udata->hdr->sblk_info[udata->sblk_idx].ndblks; + sblock.hdr = udata->hdr; + sblock.ndblks = udata->hdr->sblk_info[udata->sblk_idx].ndblks; sblock.dblk_nelmts = udata->hdr->sblk_info[udata->sblk_idx].dblk_nelmts; /* Check if # of elements in data blocks requires paging */ - if(sblock.dblk_nelmts > udata->hdr->dblk_page_nelmts) { + if (sblock.dblk_nelmts > udata->hdr->dblk_page_nelmts) { /* Compute # of pages in each data block from this super block */ sblock.dblk_npages = sblock.dblk_nelmts / udata->hdr->dblk_page_nelmts; @@ -1081,9 +1043,8 @@ H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Set the image length size */ *image_len = (size_t)H5EA_SBLOCK_SIZE(&sblock); -END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_verify_chksum * @@ -1097,14 +1058,13 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -htri_t, TRUE, -, -H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) +BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, + H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) /* Local variables */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(image); @@ -1112,12 +1072,11 @@ H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_deserialize * @@ -1132,18 +1091,17 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5EA__cache_sblock_deserialize(const void *_image, size_t len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Super block info */ - H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - haddr_t arr_addr; /* Address of array header in the file */ - size_t u; /* Local index variable */ + H5EA_sblock_t * sblock = NULL; /* Super block info */ + H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + haddr_t arr_addr; /* Address of array header in the file */ + size_t u; /* Local index variable */ /* Sanity check */ HDassert(udata); @@ -1153,29 +1111,29 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, HDassert(H5F_addr_defined(udata->sblk_addr)); /* Allocate the extensible array super block */ - if(NULL == (sblock = H5EA__sblock_alloc(udata->hdr, udata->parent, udata->sblk_idx))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + if (NULL == (sblock = H5EA__sblock_alloc(udata->hdr, udata->parent, udata->sblk_idx))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") /* Set the extensible array super block's address */ sblock->addr = udata->sblk_addr; /* Magic number */ - if(HDmemcmp(image, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array super block signature") + if (HDmemcmp(image, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + H5E_THROW(H5E_BADVALUE, "wrong extensible array super block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5EA_SBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array super block version") + if (*image++ != H5EA_SBLOCK_VERSION) + H5E_THROW(H5E_VERSION, "wrong extensible array super block version") /* Extensible array type */ - if(*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) + H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); - if(H5F_addr_ne(arr_addr, udata->hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + if (H5F_addr_ne(arr_addr, udata->hdr->addr)) + H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") /* Offset of block within the array's address space */ UINT64DECODE_VAR(image, sblock->block_off, udata->hdr->arr_off_size); @@ -1183,8 +1141,9 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, /* Internal information */ /* Check for 'page init' bitmasks for this super block */ - if(sblock->dblk_npages > 0) { - size_t tot_page_init_size = sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */ + if (sblock->dblk_npages > 0) { + size_t tot_page_init_size = + sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */ /* Retrieve the 'page init' bitmasks */ H5MM_memcpy(sblock->page_init, image, tot_page_init_size); @@ -1192,7 +1151,7 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, } /* end if */ /* Decode data block addresses */ - for(u = 0; u < sblock->ndblks; u++) + for (u = 0; u < sblock->ndblks; u++) H5F_addr_decode(udata->hdr->f, &image, &sblock->dblk_addrs[u]); /* Sanity check */ @@ -1213,16 +1172,15 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, /* Set return value */ ret_value = sblock; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(sblock && H5EA__sblock_dest(sblock) < 0) + if (!ret_value) + if (sblock && H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") -END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_image_len * @@ -1236,12 +1194,11 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_sblock_t *sblock = (const H5EA_sblock_t *)_thing; /* Pointer to the object */ + const H5EA_sblock_t *sblock = (const H5EA_sblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(sblock); @@ -1250,9 +1207,8 @@ H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = sblock->size; -END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_serialize * @@ -1266,16 +1222,15 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing)) /* Local variables */ - H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object to serialize */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - size_t u; /* Local index variable */ + H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object to serialize */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + size_t u; /* Local index variable */ /* check arguments */ HDassert(f); @@ -1303,8 +1258,9 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Internal information */ /* Check for 'page init' bitmasks for this super block */ - if(sblock->dblk_npages > 0) { - size_t tot_page_init_size = sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */ + if (sblock->dblk_npages > 0) { + size_t tot_page_init_size = + sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */ /* Store the 'page init' bitmasks */ H5MM_memcpy(image, sblock->page_init, tot_page_init_size); @@ -1312,7 +1268,7 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED } /* end if */ /* Encode addresses of data blocks in super block */ - for(u = 0; u < sblock->ndblks; u++) + for (u = 0; u < sblock->ndblks; u++) H5F_addr_encode(f, &image, sblock->dblk_addrs[u]); /* Compute metadata checksum */ @@ -1324,9 +1280,8 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_notify * @@ -1340,50 +1295,62 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ + H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(sblock); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on index block */ - if(H5EA__create_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) + if (H5EA__create_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) + H5E_THROW( + H5E_CANTDEPEND, + "unable to create flush dependency between super block and index block, address = %llu", + (unsigned long long)sblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Destroy flush dependency on extensible array header, if set */ - if(sblock->has_hdr_depend) { - if(H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) + if (sblock->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between super block and header, address = %llu", + (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; } /* end if */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on index block */ - if(H5EA__destroy_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) + if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between super block and index block, address = %llu", + (unsigned long long)sblock->addr) /* Destroy flush dependency on extensible array header, if set */ - if(sblock->has_hdr_depend) { - if(H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) + if (sblock->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between super block and header, address = %llu", + (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; } /* end if */ /* Detach from 'top' proxy for extensible array */ - if(sblock->top_proxy) { - if(H5AC_proxy_entry_remove_child(sblock->top_proxy, sblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and extensible array 'top' proxy") + if (sblock->top_proxy) { + if (H5AC_proxy_entry_remove_child(sblock->top_proxy, sblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and " + "extensible array 'top' proxy") sblock->top_proxy = NULL; } /* end if */ break; @@ -1400,16 +1367,15 @@ H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_free_icr * @@ -1424,22 +1390,19 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_sblock_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_sblock_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array super block */ - if(H5EA__sblock_dest((H5EA_sblock_t *)thing) < 0) + if (H5EA__sblock_dest((H5EA_sblock_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array super block") -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_get_initial_load_size * @@ -1453,13 +1416,12 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ - H5EA_dblock_t dblock; /* Fake data block for computing size */ + H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ + H5EA_dblock_t dblock; /* Fake data block for computing size */ /* Check arguments */ HDassert(udata); @@ -1480,24 +1442,23 @@ H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) * before we invoke either H5EA_DBLOCK_PREFIX_SIZE() or * H5EA_DBLOCK_SIZE(). */ - dblock.hdr = udata->hdr; + dblock.hdr = udata->hdr; dblock.nelmts = udata->nelmts; - if(udata->nelmts > udata->hdr->dblk_page_nelmts) { + if (udata->nelmts > udata->hdr->dblk_page_nelmts) { /* Set the # of pages in the direct block */ dblock.npages = udata->nelmts / udata->hdr->dblk_page_nelmts; - HDassert(udata->nelmts==(dblock.npages * udata->hdr->dblk_page_nelmts)); + HDassert(udata->nelmts == (dblock.npages * udata->hdr->dblk_page_nelmts)); } /* end if */ /* Set the image length size */ - if(!dblock.npages) + if (!dblock.npages) *image_len = H5EA_DBLOCK_SIZE(&dblock); else *image_len = H5EA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_verify_chksum * @@ -1511,14 +1472,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -htri_t, TRUE, -, -H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) +BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, + H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) /* Local variables */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(image); @@ -1526,12 +1486,11 @@ H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_deserialize * @@ -1546,17 +1505,16 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Data block info */ - H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - haddr_t arr_addr; /* Address of array header in the file */ + H5EA_dblock_t * dblock = NULL; /* Data block info */ + H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + haddr_t arr_addr; /* Address of array header in the file */ /* Check arguments */ HDassert(udata); @@ -1566,8 +1524,8 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert(H5F_addr_defined(udata->dblk_addr)); /* Allocate the extensible array data block */ - if(NULL == (dblock = H5EA__dblock_alloc(udata->hdr, udata->parent, udata->nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + if (NULL == (dblock = H5EA__dblock_alloc(udata->hdr, udata->parent, udata->nelmts))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") HDassert(((!dblock->npages) && (len == H5EA_DBLOCK_SIZE(dblock))) || (len == H5EA_DBLOCK_PREFIX_SIZE(dblock))); @@ -1576,22 +1534,22 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED dblock->addr = udata->dblk_addr; /* Magic number */ - if(HDmemcmp(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array data block signature") + if (HDmemcmp(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + H5E_THROW(H5E_BADVALUE, "wrong extensible array data block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5EA_DBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array data block version") + if (*image++ != H5EA_DBLOCK_VERSION) + H5E_THROW(H5E_VERSION, "wrong extensible array data block version") /* Extensible array type */ - if(*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) + H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); - if(H5F_addr_ne(arr_addr, udata->hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + if (H5F_addr_ne(arr_addr, udata->hdr->addr)) + H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") /* Offset of block within the array's address space */ UINT64DECODE_VAR(image, dblock->block_off, udata->hdr->arr_off_size); @@ -1599,10 +1557,10 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Internal information */ /* Only decode elements if the data block is not paged */ - if(!dblock->npages) { + if (!dblock->npages) { /* Decode elements in data block */ /* Convert from raw elements on disk into native elements in memory */ - if((udata->hdr->cparam.cls->decode)(image, dblock->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cparam.cls->decode)(image, dblock->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1626,16 +1584,15 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Set return value */ ret_value = dblock; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(dblock && H5EA__dblock_dest(dblock) < 0) + if (!ret_value) + if (dblock && H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") -END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_image_len * @@ -1649,26 +1606,24 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); HDassert(image_len); /* Set the image length size */ - if(!dblock->npages) + if (!dblock->npages) *image_len = dblock->size; else *image_len = (size_t)H5EA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_serialize * @@ -1682,15 +1637,14 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing)) /* Local variables */ - H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object to serialize */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object to serialize */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* check arguments */ HDassert(f); @@ -1718,11 +1672,11 @@ H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Internal information */ /* Only encode elements if the data block is not paged */ - if(!dblock->npages) { + if (!dblock->npages) { /* Encode elements in data block */ /* Convert from native elements in memory into raw elements on disk */ - if((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, dblock->nelmts, dblock->hdr->cb_ctx) < 0) + if ((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, dblock->nelmts, dblock->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements") image += (dblock->nelmts * dblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1736,11 +1690,10 @@ H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_notify * @@ -1754,50 +1707,60 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ + H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5EA__create_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block and parent, address = %llu", (unsigned long long)dblock->addr) + if (H5EA__create_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) + H5E_THROW(H5E_CANTDEPEND, + "unable to create flush dependency between data block and parent, address = %llu", + (unsigned long long)dblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Destroy flush dependency on extensible array header, if set */ - if(dblock->has_hdr_depend) { - if(H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between direct block and header, address = %llu", (unsigned long long)dblock->addr) + if (dblock->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between direct block and header, address = %llu", + (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; } /* end if */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ - if(H5EA__destroy_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and parent, address = %llu", (unsigned long long)dblock->addr) + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, + "unable to destroy flush dependency between data block and parent, address = %llu", + (unsigned long long)dblock->addr) /* Destroy flush dependency on extensible array header, if set */ - if(dblock->has_hdr_depend) { - if(H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) + if (dblock->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between data block and header, address = %llu", + (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; } /* end if */ /* Detach from 'top' proxy for extensible array */ - if(dblock->top_proxy) { - if(H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and extensible array 'top' proxy") + if (dblock->top_proxy) { + if (H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and " + "extensible array 'top' proxy") dblock->top_proxy = NULL; } /* end if */ break; @@ -1814,16 +1777,15 @@ H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_free_icr * @@ -1838,22 +1800,19 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_dblock_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblock_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array data block */ - if(H5EA__dblock_dest((H5EA_dblock_t *)thing) < 0) + if (H5EA__dblock_dest((H5EA_dblock_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array data block") -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_fsf_size * @@ -1883,12 +1842,11 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) /* Local variables */ - const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); @@ -1898,9 +1856,8 @@ H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_get_initial_load_size * @@ -1914,12 +1871,11 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data */ + H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data */ /* Check arguments */ HDassert(udata); @@ -1929,9 +1885,8 @@ H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* Set the image length size */ *image_len = (size_t)H5EA_DBLK_PAGE_SIZE(udata->hdr); -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_verify_chksum * @@ -1945,14 +1900,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -htri_t, TRUE, -, -H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) +BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, + H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) /* Local variables */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(image); @@ -1960,12 +1914,11 @@ H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_deserialize * @@ -1980,16 +1933,16 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ - H5EA_dblk_page_t *dblk_page = NULL; /* Data block page info */ - H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ + H5EA_dblk_page_t * dblk_page = NULL; /* Data block page info */ + H5EA_dblk_page_cache_ud_t *udata = + (H5EA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ /* Sanity check */ HDassert(udata); @@ -1998,8 +1951,8 @@ H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, HDassert(H5F_addr_defined(udata->dblk_page_addr)); /* Allocate the extensible array data block page */ - if(NULL == (dblk_page = H5EA__dblk_page_alloc(udata->hdr, udata->parent))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + if (NULL == (dblk_page = H5EA__dblk_page_alloc(udata->hdr, udata->parent))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") /* Set the extensible array data block page's information */ dblk_page->addr = udata->dblk_page_addr; @@ -2008,7 +1961,8 @@ H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, /* Decode elements in data block page */ /* Convert from raw elements on disk into native elements in memory */ - if((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->hdr->dblk_page_nelmts, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->hdr->dblk_page_nelmts, + udata->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") image += (udata->hdr->dblk_page_nelmts * udata->hdr->cparam.raw_elmt_size); @@ -2030,16 +1984,15 @@ H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, /* Set return value */ ret_value = dblk_page; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) + if (!ret_value) + if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_image_len * @@ -2053,12 +2006,11 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_dblk_page_t *dblk_page = (const H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + const H5EA_dblk_page_t *dblk_page = (const H5EA_dblk_page_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblk_page); @@ -2067,9 +2019,8 @@ H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_serialize * @@ -2083,15 +2034,14 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, + size_t H5_ATTR_UNUSED len, void *_thing)) /* Local variables */ - H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(f); @@ -2104,7 +2054,8 @@ H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_ima /* Encode elements in data block page */ /* Convert from native elements in memory into raw elements on disk */ - if((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->hdr->dblk_page_nelmts, dblk_page->hdr->cb_ctx) < 0) + if ((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->hdr->dblk_page_nelmts, + dblk_page->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements") image += (dblk_page->hdr->dblk_page_nelmts * dblk_page->hdr->cparam.raw_elmt_size); @@ -2117,11 +2068,10 @@ H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_ima /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_notify * @@ -2135,50 +2085,62 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(dblk_page); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5EA__create_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) + if (H5EA__create_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW( + H5E_CANTDEPEND, + "unable to create flush dependency between data block page and parent, address = %llu", + (unsigned long long)dblk_page->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Destroy flush dependency on extensible array header, if set */ - if(dblk_page->has_hdr_depend) { - if(H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page and header, address = %llu", (unsigned long long)dblk_page->addr) + if (dblk_page->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW(H5E_CANTUNDEPEND, + "unable to destroy flush dependency between data block page and header, " + "address = %llu", + (unsigned long long)dblk_page->addr) dblk_page->has_hdr_depend = FALSE; } /* end if */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ - if(H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between data block page and parent, address = %llu", + (unsigned long long)dblk_page->addr) /* Destroy flush dependency on extensible array header, if set */ - if(dblk_page->has_hdr_depend) { - if(H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page and header, address = %llu", (unsigned long long)dblk_page->addr) + if (dblk_page->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW(H5E_CANTUNDEPEND, + "unable to destroy flush dependency between data block page and header, " + "address = %llu", + (unsigned long long)dblk_page->addr) dblk_page->has_hdr_depend = FALSE; } /* end if */ /* Detach from 'top' proxy for extensible array */ - if(dblk_page->top_proxy) { - if(H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page and extensible array 'top' proxy") + if (dblk_page->top_proxy) { + if (H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page " + "and extensible array 'top' proxy") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -2195,16 +2157,15 @@ H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_free_icr * @@ -2219,18 +2180,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_dblk_page_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblk_page_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array data block page */ - if(H5EA__dblk_page_dest((H5EA_dblk_page_t *)thing) < 0) + if (H5EA__dblk_page_dest((H5EA_dblk_page_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array data block page") -CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_free_icr() */ + CATCH +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_free_icr() */ diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index e5b68be..2ff1e9a 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -26,58 +26,47 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5EA__hdr_debug * @@ -90,14 +79,13 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, const H5EA_class_t *cls, haddr_t obj_addr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t obj_addr)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ - void *dbg_ctx = NULL; /* Extensible array debugging context */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + void * dbg_ctx = NULL; /* Extensible array debugging context */ /* Check arguments */ HDassert(f); @@ -109,70 +97,53 @@ H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(cls); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") /* Load the extensible array header */ - if(NULL == (hdr = H5EA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5EA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Header...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Header size:", - hdr->size); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Header size:", hdr->size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Raw Element Size:", - (unsigned)hdr->cparam.raw_elmt_size); + "Raw Element Size:", (unsigned)hdr->cparam.raw_elmt_size); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Native Element Size (on this platform):", - hdr->cparam.cls->nat_elmt_size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Log2(Max. # of elements in array):", - (unsigned)hdr->cparam.max_nelmts_bits); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "# of elements in index block:", - (unsigned)hdr->cparam.idx_blk_elmts); + "Native Element Size (on this platform):", hdr->cparam.cls->nat_elmt_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. # of elements per data block:", - (unsigned)hdr->cparam.data_blk_min_elmts); + "Log2(Max. # of elements in array):", (unsigned)hdr->cparam.max_nelmts_bits); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. # of data block pointers for a super block:", - (unsigned)hdr->cparam.sup_blk_min_data_ptrs); + "# of elements in index block:", (unsigned)hdr->cparam.idx_blk_elmts); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Log2(Max. # of elements in data block page):", - (unsigned)hdr->cparam.max_dblk_page_nelmts_bits); + "Min. # of elements per data block:", (unsigned)hdr->cparam.data_blk_min_elmts); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Min. # of data block pointers for a super block:", + (unsigned)hdr->cparam.sup_blk_min_data_ptrs); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Log2(Max. # of elements in data block page):", + (unsigned)hdr->cparam.max_dblk_page_nelmts_bits); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Highest element index stored (+1):", - hdr->stats.stored.max_idx_set); + "Highest element index stored (+1):", hdr->stats.stored.max_idx_set); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of super blocks created:", - hdr->stats.stored.nsuper_blks); + "Number of super blocks created:", hdr->stats.stored.nsuper_blks); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of data blocks created:", - hdr->stats.stored.ndata_blks); + "Number of data blocks created:", hdr->stats.stored.ndata_blks); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements 'realized':", - hdr->stats.stored.nelmts); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Index Block Address:", - hdr->idx_blk_addr); - -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + "Number of elements 'realized':", hdr->stats.stored.nelmts); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Index Block Address:", hdr->idx_blk_addr); + + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_debug() */ +END_FUNC(PKG) /* end H5EA__hdr_debug() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_debug * @@ -185,15 +156,14 @@ END_FUNC(PKG) /* end H5EA__hdr_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, - int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ - void *dbg_ctx = NULL; /* Extensible array context */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + void * dbg_ctx = NULL; /* Extensible array context */ /* Check arguments */ HDassert(f); @@ -206,96 +176,89 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde HDassert(H5F_addr_defined(obj_addr)); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") /* Load the extensible array header */ - if(NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Sanity check */ HDassert(H5F_addr_eq(hdr->idx_blk_addr, addr)); /* Protect index block */ - if(NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", (unsigned long long)hdr->idx_blk_addr) + if (NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Index Block...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Index Block size:", - iblock->size); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Index Block size:", iblock->size); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of data block addresses in index block:", - iblock->ndblk_addrs); + "# of data block addresses in index block:", iblock->ndblk_addrs); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of super block addresses in index block:", - iblock->nsblk_addrs); + "# of super block addresses in index block:", iblock->nsblk_addrs); /* Check if there are any elements in index block */ - if(hdr->cparam.idx_blk_elmts > 0) { - unsigned u; /* Local index variable */ + if (hdr->cparam.idx_blk_elmts > 0) { + unsigned u; /* Local index variable */ /* Print the elements in the index block */ HDfprintf(stream, "%*sElements in Index Block:\n", indent, ""); - for(u = 0; u < hdr->cparam.idx_blk_elmts; u++) { + for (u = 0; u < hdr->cparam.idx_blk_elmts; u++) { /* Call the class's 'debug' callback */ - if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), - (hsize_t)u, - ((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) + if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, + ((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < + 0) H5E_THROW(H5E_CANTGET, "can't get element for debugging") } /* end for */ - } /* end if */ + } /* end if */ /* Check if there are any data block addresses in index block */ - if(iblock->ndblk_addrs > 0) { - char temp_str[128]; /* Temporary string, for formatting */ + if (iblock->ndblk_addrs > 0) { + char temp_str[128]; /* Temporary string, for formatting */ unsigned u; /* Local index variable */ /* Print the data block addresses in the index block */ HDfprintf(stream, "%*sData Block Addresses in Index Block:\n", indent, ""); - for(u = 0; u < iblock->ndblk_addrs; u++) { + for (u = 0; u < iblock->ndblk_addrs; u++) { /* Print address */ HDsprintf(temp_str, "Address #%u:", u); - HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), - temp_str, - iblock->dblk_addrs[u]); + HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, + iblock->dblk_addrs[u]); } /* end for */ - } /* end if */ + } /* end if */ /* Check if there are any super block addresses in index block */ - if(iblock->nsblk_addrs > 0) { - char temp_str[128]; /* Temporary string, for formatting */ + if (iblock->nsblk_addrs > 0) { + char temp_str[128]; /* Temporary string, for formatting */ unsigned u; /* Local index variable */ /* Print the super block addresses in the index block */ HDfprintf(stream, "%*sSuper Block Addresses in Index Block:\n", indent, ""); - for(u = 0; u < iblock->nsblk_addrs; u++) { + for (u = 0; u < iblock->nsblk_addrs; u++) { /* Print address */ HDsprintf(temp_str, "Address #%u:", u); - HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), - temp_str, - iblock->sblk_addrs[u]); + HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, + iblock->sblk_addrs[u]); } /* end for */ - } /* end if */ + } /* end if */ -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") - if(iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) + if (iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__iblock_debug() */ +END_FUNC(PKG) /* end H5EA__iblock_debug() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_debug * @@ -308,15 +271,14 @@ END_FUNC(PKG) /* end H5EA__iblock_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ - void *dbg_ctx = NULL; /* Extensible array context */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + void * dbg_ctx = NULL; /* Extensible array context */ /* Check arguments */ HDassert(f); @@ -329,63 +291,58 @@ H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(H5F_addr_defined(obj_addr)); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") /* Load the extensible array header */ - if(NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Protect super block */ /* (Note: setting parent of super block to 'hdr' for this operation should be OK -QAK) */ - if(NULL == (sblock = H5EA__sblock_protect(hdr, (H5EA_iblock_t *)hdr, addr, sblk_idx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)addr) + if (NULL == + (sblock = H5EA__sblock_protect(hdr, (H5EA_iblock_t *)hdr, addr, sblk_idx, H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", + (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Super Block...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Super Block size:", - sblock->size); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Super Block size:", sblock->size); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of data block addresses in super block:", - sblock->ndblks); + "# of data block addresses in super block:", sblock->ndblks); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of elements in data blocks from this super block:", - sblock->dblk_nelmts); + "# of elements in data blocks from this super block:", sblock->dblk_nelmts); /* Check if there are any data block addresses in super block */ - if(sblock->ndblks > 0) { - char temp_str[128]; /* Temporary string, for formatting */ + if (sblock->ndblks > 0) { + char temp_str[128]; /* Temporary string, for formatting */ unsigned u; /* Local index variable */ /* Print the data block addresses in the super block */ HDfprintf(stream, "%*sData Block Addresses in Super Block:\n", indent, ""); - for(u = 0; u < sblock->ndblks; u++) { + for (u = 0; u < sblock->ndblks; u++) { /* Print address */ HDsprintf(temp_str, "Address #%u:", u); - HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), - temp_str, - sblock->dblk_addrs[u]); + HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, + sblock->dblk_addrs[u]); } /* end for */ - } /* end if */ + } /* end if */ -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") - if(sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) + if (sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__sblock_debug() */ +END_FUNC(PKG) /* end H5EA__sblock_debug() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_debug * @@ -398,16 +355,16 @@ END_FUNC(PKG) /* end H5EA__sblock_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr, size_t dblk_nelmts, haddr_t obj_addr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, size_t dblk_nelmts, + haddr_t obj_addr)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ - void *dbg_ctx = NULL; /* Extensible array context */ - size_t u; /* Local index variable */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + void * dbg_ctx = NULL; /* Extensible array context */ + size_t u; /* Local index variable */ /* Check arguments */ HDassert(f); @@ -421,48 +378,43 @@ H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(dblk_nelmts > 0); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") /* Load the extensible array header */ - if(NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Protect data block */ /* (Note: setting parent of data block to 'hdr' for this operation should be OK -QAK) */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, hdr, addr, dblk_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)addr) + if (NULL == (dblock = H5EA__dblock_protect(hdr, hdr, addr, dblk_nelmts, H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", + (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array data Block...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Data Block size:", - dblock->size); - + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data Block size:", dblock->size); /* Print the elements in the index block */ HDfprintf(stream, "%*sElements:\n", indent, ""); - for(u = 0; u < dblk_nelmts; u++) { + for (u = 0; u < dblk_nelmts; u++) { /* Call the class's 'debug' callback */ - if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), - (hsize_t)u, - ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) + if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, + ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) H5E_THROW(H5E_CANTGET, "can't get element for debugging") } /* end for */ -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") - if(dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__dblock_debug() */ - +END_FUNC(PKG) /* end H5EA__dblock_debug() */ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index 6dd2e98..a1a6449 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -26,54 +26,45 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -81,8 +72,6 @@ /* Declare a free list to manage the H5EA_dblk_page_t struct */ H5FL_DEFINE_STATIC(H5EA_dblk_page_t); - - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_alloc * @@ -96,43 +85,41 @@ H5FL_DEFINE_STATIC(H5EA_dblk_page_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_dblk_page_t *, NULL, NULL, -H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent)) +BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, + H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent)) /* Local variables */ - H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ + H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ /* Check arguments */ HDassert(hdr); /* Allocate memory for the data block */ - if(NULL == (dblk_page = H5FL_CALLOC(H5EA_dblk_page_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + if (NULL == (dblk_page = H5FL_CALLOC(H5EA_dblk_page_t))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") /* Share common array information */ - if(H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + if (H5EA__hdr_incr(hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") dblk_page->hdr = hdr; /* Set non-zero internal fields */ dblk_page->parent = parent; /* Allocate buffer for elements in data block page */ - if(NULL == (dblk_page->elmts = H5EA__hdr_alloc_elmts(hdr, hdr->dblk_page_nelmts))) + if (NULL == (dblk_page->elmts = H5EA__hdr_alloc_elmts(hdr, hdr->dblk_page_nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block page element buffer") /* Set the return value */ ret_value = dblk_page; -CATCH - if(!ret_value) - if(dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) + CATCH + if (!ret_value) + if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") -END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ +END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_create * @@ -146,57 +133,55 @@ END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr)) /* Local variables */ - H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* Sanity check */ HDassert(hdr); /* Allocate the data block page */ - if(NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, parent))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + if (NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, parent))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; dblk_page->size = H5EA_DBLK_PAGE_SIZE(hdr); /* Clear any elements in data block page to fill value */ - if((hdr->cparam.cls->fill)(dblk_page->elmts, (size_t)hdr->dblk_page_nelmts) < 0) + if ((hdr->cparam.cls->fill)(dblk_page->elmts, (size_t)hdr->dblk_page_nelmts) < 0) H5E_THROW(H5E_CANTSET, "can't set extensible array data block page elements to class's fill value") /* Cache the new extensible array data block page */ - if(H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block page to cache") + if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block page to cache") inserted = TRUE; /* Add data block page as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ -CATCH - if(ret_value < 0) - if(dblk_page) { + CATCH + if (ret_value < 0) + if (dblk_page) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(dblk_page) < 0) + if (inserted) + if (H5AC_remove_entry(dblk_page) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block page from cache") /* Destroy data block page */ - if(H5EA__dblk_page_dest(dblk_page) < 0) + if (H5EA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblk_page_create() */ +END_FUNC(PKG) /* end H5EA__dblk_page_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_protect * @@ -211,14 +196,13 @@ END_FUNC(PKG) /* end H5EA__dblk_page_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_dblk_page_t *, NULL, NULL, -H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, - haddr_t dblk_page_addr, unsigned flags)) +BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, + H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t dblk_page_addr, + unsigned flags)) /* Local variables */ - H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ - H5EA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ + H5EA_dblk_page_t * dblk_page = NULL; /* Extensible array data block page */ + H5EA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ /* Sanity check */ HDassert(hdr); @@ -228,18 +212,20 @@ H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; - udata.parent = parent; + udata.hdr = hdr; + udata.parent = parent; udata.dblk_page_addr = dblk_page_addr; /* Protect the data block page */ - if(NULL == (dblk_page = (H5EA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", (unsigned long long)dblk_page_addr) + if (NULL == (dblk_page = (H5EA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, + &udata, flags))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == dblk_page->top_proxy) { + if (hdr->top_proxy && NULL == dblk_page->top_proxy) { /* Add data block page as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ @@ -247,17 +233,19 @@ H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, /* Set return value */ ret_value = dblk_page; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the data block page, if it was protected */ - if(dblk_page && H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block page, address = %llu", (unsigned long long)dblk_page->addr) + if (dblk_page && + H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, + "unable to unprotect extensible array data block page, address = %llu", + (unsigned long long)dblk_page->addr) } /* end if */ -END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ +END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_unprotect * @@ -272,9 +260,8 @@ END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)) /* Local variables */ @@ -282,14 +269,14 @@ H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)) HDassert(dblk_page); /* Unprotect the data block page */ - if(H5AC_unprotect(dblk_page->hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block page, address = %llu", (unsigned long long)dblk_page->addr) + if (H5AC_unprotect(dblk_page->hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block page, address = %llu", + (unsigned long long)dblk_page->addr) -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ +END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_dest * @@ -303,26 +290,24 @@ END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) /* Sanity check */ HDassert(dblk_page); HDassert(!dblk_page->has_hdr_depend); /* Check if header field has been initialized */ - if(dblk_page->hdr) { + if (dblk_page->hdr) { /* Check if buffer for data block page elements has been initialized */ - if(dblk_page->elmts) { + if (dblk_page->elmts) { /* Free buffer for data block page elements */ - if(H5EA__hdr_free_elmts(dblk_page->hdr, dblk_page->hdr->dblk_page_nelmts, dblk_page->elmts) < 0) + if (H5EA__hdr_free_elmts(dblk_page->hdr, dblk_page->hdr->dblk_page_nelmts, dblk_page->elmts) < 0) H5E_THROW(H5E_CANTFREE, "unable to free extensible array data block element buffer") dblk_page->elmts = NULL; } /* end if */ /* Decrement reference count on shared info */ - if(H5EA__hdr_decr(dblk_page->hdr) < 0) + if (H5EA__hdr_decr(dblk_page->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -333,7 +318,6 @@ H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) /* Free the data block page itself */ dblk_page = H5FL_FREE(H5EA_dblk_page_t, dblk_page); -CATCH - -END_FUNC(PKG) /* end H5EA__dblk_page_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__dblk_page_dest() */ diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index d926fd5..b3c8bff 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -26,55 +26,46 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -82,8 +73,6 @@ /* Declare a free list to manage the H5EA_dblock_t struct */ H5FL_DEFINE_STATIC(H5EA_dblock_t); - - /*------------------------------------------------------------------------- * Function: H5EA__dblock_alloc * @@ -97,12 +86,11 @@ H5FL_DEFINE_STATIC(H5EA_dblock_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_dblock_t *, NULL, NULL, -H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) +BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, + H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ /* Check arguments */ HDassert(hdr); @@ -110,12 +98,12 @@ H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) HDassert(nelmts > 0); /* Allocate memory for the data block */ - if(NULL == (dblock = H5FL_CALLOC(H5EA_dblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + if (NULL == (dblock = H5FL_CALLOC(H5EA_dblock_t))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") /* Share common array information */ - if(H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + if (H5EA__hdr_incr(hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") dblock->hdr = hdr; /* Set non-zero internal fields */ @@ -123,28 +111,27 @@ H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) dblock->nelmts = nelmts; /* Check if the data block is not going to be paged */ - if(nelmts > hdr->dblk_page_nelmts) { + if (nelmts > hdr->dblk_page_nelmts) { /* Set the # of pages in the direct block */ dblock->npages = nelmts / hdr->dblk_page_nelmts; HDassert(nelmts == (dblock->npages * hdr->dblk_page_nelmts)); } /* end if */ else { /* Allocate buffer for elements in data block */ - if(NULL == (dblock->elmts = H5EA__hdr_alloc_elmts(hdr, nelmts))) + if (NULL == (dblock->elmts = H5EA__hdr_alloc_elmts(hdr, nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; -CATCH - if(!ret_value) - if(dblock && H5EA__dblock_dest(dblock) < 0) + CATCH + if (!ret_value) + if (dblock && H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_alloc() */ +END_FUNC(PKG) /* end H5EA__dblock_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_create * @@ -158,15 +145,14 @@ END_FUNC(PKG) /* end H5EA__dblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, - hsize_t dblk_off, size_t nelmts)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, + size_t nelmts)) /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ - haddr_t dblock_addr; /* Extensible array data block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + haddr_t dblock_addr; /* Extensible array data block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* Sanity check */ HDassert(hdr); @@ -174,8 +160,8 @@ H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, HDassert(nelmts > 0); /* Allocate the data block */ - if(NULL == (dblock = H5EA__dblock_alloc(hdr, parent, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + if (NULL == (dblock = H5EA__dblock_alloc(hdr, parent, nelmts))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") /* Set size of data block on disk */ dblock->size = H5EA_DBLOCK_SIZE(dblock); @@ -184,24 +170,24 @@ H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, dblock->block_off = dblk_off; /* Allocate space for the data block on disk */ - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_DBLOCK, (hsize_t)dblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array data block") + if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_DBLOCK, (hsize_t)dblock->size))) + H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array data block") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ - if(!dblock->npages) + if (!dblock->npages) /* Clear any elements in data block to fill value */ - if((hdr->cparam.cls->fill)(dblock->elmts, (size_t)dblock->nelmts) < 0) + if ((hdr->cparam.cls->fill)(dblock->elmts, (size_t)dblock->nelmts) < 0) H5E_THROW(H5E_CANTSET, "can't set extensible array data block elements to class's fill value") /* Cache the new extensible array data block */ - if(H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block to cache") + if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block to cache") inserted = TRUE; /* Add data block as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -219,26 +205,26 @@ H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, /* Set address of data block to return */ ret_value = dblock_addr; -CATCH - if(!H5F_addr_defined(ret_value)) - if(dblock) { + CATCH + if (!H5F_addr_defined(ret_value)) + if (dblock) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(dblock) < 0) + if (inserted) + if (H5AC_remove_entry(dblock) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block from cache") /* Release data block's disk space */ - if(H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) + if (H5F_addr_defined(dblock->addr) && + H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) H5E_THROW(H5E_CANTFREE, "unable to release extensible array data block") /* Destroy data block */ - if(H5EA__dblock_dest(dblock) < 0) + if (H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblock_create() */ +END_FUNC(PKG) /* end H5EA__dblock_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_sblk_idx * @@ -253,12 +239,10 @@ END_FUNC(PKG) /* end H5EA__dblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -unsigned, 0, -, -H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx)) +BEGIN_FUNC(PKG, NOERR, unsigned, 0, -, H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx)) /* Local variables */ - unsigned sblk_idx; /* Which superblock does this index fall in? */ + unsigned sblk_idx; /* Which superblock does this index fall in? */ /* Sanity check */ HDassert(hdr); @@ -268,15 +252,14 @@ H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx)) idx -= hdr->cparam.idx_blk_elmts; /* Determine the superblock information for the index */ - H5_CHECK_OVERFLOW(idx, /*From:*/hsize_t, /*To:*/uint64_t); + H5_CHECK_OVERFLOW(idx, /*From:*/ hsize_t, /*To:*/ uint64_t); sblk_idx = H5VM_log2_gen((uint64_t)((idx / hdr->cparam.data_blk_min_elmts) + 1)); /* Set return value */ ret_value = sblk_idx; -END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ +END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_protect * @@ -290,14 +273,13 @@ END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_dblock_t *, NULL, NULL, -H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, - size_t dblk_nelmts, unsigned flags)) +BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, + H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts, + unsigned flags)) /* Local variables */ - H5EA_dblock_t *dblock; /* Extensible array data block */ - H5EA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5EA_dblock_t * dblock; /* Extensible array data block */ + H5EA_dblock_cache_ud_t udata; /* Information needed for loading data block */ /* Sanity check */ HDassert(hdr); @@ -308,19 +290,21 @@ H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; - udata.parent = parent; - udata.nelmts = dblk_nelmts; + udata.hdr = hdr; + udata.parent = parent; + udata.nelmts = dblk_nelmts; udata.dblk_addr = dblk_addr; /* Protect the data block */ - if(NULL == (dblock = (H5EA_dblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLOCK, dblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)dblk_addr) + if (NULL == + (dblock = (H5EA_dblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLOCK, dblk_addr, &udata, flags))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", + (unsigned long long)dblk_addr) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == dblock->top_proxy) { + if (hdr->top_proxy && NULL == dblock->top_proxy) { /* Add data block as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -328,18 +312,19 @@ H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, /* Set return value */ ret_value = dblock; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the data block, if it was protected */ - if(dblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", (unsigned long long)dblock->addr) + if (dblock && + H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", + (unsigned long long)dblock->addr) } /* end if */ -END_FUNC(PKG) /* end H5EA__dblock_protect() */ +END_FUNC(PKG) /* end H5EA__dblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_unprotect * @@ -353,9 +338,8 @@ END_FUNC(PKG) /* end H5EA__dblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)) /* Local variables */ @@ -363,14 +347,14 @@ H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)) HDassert(dblock); /* Unprotect the data block */ - if(H5AC_unprotect(dblock->hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", (unsigned long long)dblock->addr) + if (H5AC_unprotect(dblock->hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", + (unsigned long long)dblock->addr) -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ +END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_delete * @@ -384,13 +368,11 @@ END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, - size_t dblk_nelmts)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts)) /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ + H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ /* Sanity check */ HDassert(hdr); @@ -399,41 +381,41 @@ H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, HDassert(dblk_nelmts > 0); /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, parent, dblk_addr, dblk_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)dblk_addr) + if (NULL == (dblock = H5EA__dblock_protect(hdr, parent, dblk_addr, dblk_nelmts, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", + (unsigned long long)dblk_addr) /* Check if this is a paged data block */ - if(dblk_nelmts > hdr->dblk_page_nelmts) { - size_t npages = dblk_nelmts / hdr->dblk_page_nelmts; /* Number of pages in data block */ - haddr_t dblk_page_addr; /* Address of each data block page */ - size_t dblk_page_size; /* Size of each data block page */ - size_t u; /* Local index variable */ + if (dblk_nelmts > hdr->dblk_page_nelmts) { + size_t npages = dblk_nelmts / hdr->dblk_page_nelmts; /* Number of pages in data block */ + haddr_t dblk_page_addr; /* Address of each data block page */ + size_t dblk_page_size; /* Size of each data block page */ + size_t u; /* Local index variable */ /* Set up initial state */ dblk_page_addr = dblk_addr + H5EA_DBLOCK_PREFIX_SIZE(dblock); - dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) - + H5EA_SIZEOF_CHKSUM; + dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5EA_SIZEOF_CHKSUM; /* Iterate over pages in data block */ - for(u = 0; u < npages; u++) { + for (u = 0; u < npages; u++) { /* Evict the data block page from the metadata cache */ /* (OK to call if it doesn't exist in the cache) */ - if(H5AC_expunge_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTEXPUNGE, "unable to remove array data block page from metadata cache") /* Advance to next page address */ dblk_page_addr += dblk_page_size; } /* end for */ - } /* end if */ + } /* end if */ -CATCH + CATCH /* Finished deleting data block in metadata cache */ - if(dblock && H5EA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (dblock && H5EA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | + H5AC__FREE_FILE_SPACE_FLAG) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_delete() */ +END_FUNC(PKG) /* end H5EA__dblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_dest * @@ -447,28 +429,26 @@ END_FUNC(PKG) /* end H5EA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__dblock_dest(H5EA_dblock_t *dblock)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dblock)) /* Sanity check */ HDassert(dblock); HDassert(!dblock->has_hdr_depend); /* Check if shared header field has been initialized */ - if(dblock->hdr) { + if (dblock->hdr) { /* Check if we've got elements in the data block */ - if(dblock->elmts && !dblock->npages) { + if (dblock->elmts && !dblock->npages) { /* Free buffer for data block elements */ HDassert(dblock->nelmts > 0); - if(H5EA__hdr_free_elmts(dblock->hdr, dblock->nelmts, dblock->elmts) < 0) + if (H5EA__hdr_free_elmts(dblock->hdr, dblock->nelmts, dblock->elmts) < 0) H5E_THROW(H5E_CANTFREE, "unable to free extensible array data block element buffer") - dblock->elmts = NULL; + dblock->elmts = NULL; dblock->nelmts = 0; } /* end if */ /* Decrement reference count on shared info */ - if(H5EA__hdr_decr(dblock->hdr) < 0) + if (H5EA__hdr_decr(dblock->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -479,7 +459,6 @@ H5EA__dblock_dest(H5EA_dblock_t *dblock)) /* Free the data block itself */ dblock = H5FL_FREE(H5EA_dblock_t, dblock); -CATCH - -END_FUNC(PKG) /* end H5EA__dblock_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__dblock_dest() */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index ec40298..83cc085 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -26,24 +26,21 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ @@ -55,9 +52,7 @@ #endif /* NDEBUG */ /* # of elements in a data block for a particular super block */ -#define H5EA_SBLK_DBLK_NELMTS(s, m) \ - (size_t)H5_EXP2(((s) + 1) / 2) * (m) - +#define H5EA_SBLK_DBLK_NELMTS(s, m) (size_t) H5_EXP2(((s) + 1) / 2) * (m) /******************/ /* Local Typedefs */ @@ -66,27 +61,22 @@ /* Alias for pointer to factory, for use when allocating sequences of them */ typedef H5FL_fac_head_t *H5FL_fac_head_ptr_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -100,8 +90,6 @@ H5FL_SEQ_DEFINE_STATIC(H5FL_fac_head_ptr_t); /* Declare a free list to manage the H5EA_sblk_info_t sequence information */ H5FL_SEQ_DEFINE_STATIC(H5EA_sblk_info_t); - - /*------------------------------------------------------------------------- * Function: H5EA__hdr_alloc * @@ -115,40 +103,37 @@ H5FL_SEQ_DEFINE_STATIC(H5EA_sblk_info_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_hdr_t *, NULL, NULL, -H5EA__hdr_alloc(H5F_t *f)) +BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__hdr_alloc(H5F_t *f)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ - if(NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) + if (NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; /* Set the internal parameters for the array */ - hdr->f = f; - hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; + hdr->f = f; + hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); hdr->sizeof_size = H5F_SIZEOF_SIZE(f); /* Set the return value */ ret_value = hdr; -CATCH - if(!ret_value) - if(hdr && H5EA__hdr_dest(hdr) < 0) + CATCH + if (!ret_value) + if (hdr && H5EA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_alloc() */ +END_FUNC(PKG) /* end H5EA__hdr_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_init * @@ -185,14 +170,12 @@ END_FUNC(PKG) /* end H5EA__hdr_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) /* Local variables */ - hsize_t start_idx; /* First element index for each super block */ - hsize_t start_dblk; /* First data block index for each super block */ - size_t u; /* Local index variable */ + hsize_t start_idx; /* First element index for each super block */ + hsize_t start_dblk; /* First data block index for each super block */ + size_t u; /* Local index variable */ /* Sanity check */ HDassert(hdr); @@ -201,22 +184,22 @@ H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) HDassert(hdr->cparam.sup_blk_min_data_ptrs); /* Compute general information */ - hdr->nsblks = 1 + (hdr->cparam.max_nelmts_bits - H5VM_log2_of2(hdr->cparam.data_blk_min_elmts)); + hdr->nsblks = 1 + (hdr->cparam.max_nelmts_bits - H5VM_log2_of2(hdr->cparam.data_blk_min_elmts)); hdr->dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits; - hdr->arr_off_size = (unsigned char)H5EA_SIZEOF_OFFSET_BITS(hdr->cparam.max_nelmts_bits); + hdr->arr_off_size = (unsigned char)H5EA_SIZEOF_OFFSET_BITS(hdr->cparam.max_nelmts_bits); /* Allocate information for each super block */ - if(NULL == (hdr->sblk_info = H5FL_SEQ_MALLOC(H5EA_sblk_info_t, hdr->nsblks))) + if (NULL == (hdr->sblk_info = H5FL_SEQ_MALLOC(H5EA_sblk_info_t, hdr->nsblks))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block info array") /* Compute information about each super block */ - start_idx = 0; + start_idx = 0; start_dblk = 0; - for(u = 0; u < hdr->nsblks; u++) { - hdr->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2); + for (u = 0; u < hdr->nsblks; u++) { + hdr->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2); hdr->sblk_info[u].dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(u, hdr->cparam.data_blk_min_elmts); - hdr->sblk_info[u].start_idx = start_idx; - hdr->sblk_info[u].start_dblk = start_dblk; + hdr->sblk_info[u].start_idx = start_idx; + hdr->sblk_info[u].start_dblk = start_dblk; /* Advance starting indices for next super block */ start_idx += (hsize_t)hdr->sblk_info[u].ndblks * (hsize_t)hdr->sblk_info[u].dblk_nelmts; @@ -227,16 +210,15 @@ H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) hdr->stats.computed.hdr_size = hdr->size = H5EA_HEADER_SIZE_HDR(hdr); /* Create the callback context, if there's one */ - if(hdr->cparam.cls->crt_context) { - if(NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) + if (hdr->cparam.cls->crt_context) { + if (NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) H5E_THROW(H5E_CANTCREATE, "unable to create extensible array client callback context") } /* end if */ -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_init() */ +END_FUNC(PKG) /* end H5EA__hdr_init() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_alloc_elmts * @@ -250,60 +232,60 @@ END_FUNC(PKG) /* end H5EA__hdr_init() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -void *, NULL, NULL, -H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts)) +BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts)) /* Local variables */ - void *elmts = NULL; /* Element buffer allocated */ - unsigned idx; /* Index of element buffer factory in header */ + void * elmts = NULL; /* Element buffer allocated */ + unsigned idx; /* Index of element buffer factory in header */ /* Check arguments */ HDassert(hdr); HDassert(nelmts > 0); /* Compute the index of the element buffer factory */ - H5_CHECK_OVERFLOW(nelmts, /*From:*/size_t, /*To:*/uint32_t); + H5_CHECK_OVERFLOW(nelmts, /*From:*/ size_t, /*To:*/ uint32_t); idx = H5VM_log2_of2((uint32_t)nelmts) - H5VM_log2_of2((uint32_t)hdr->cparam.data_blk_min_elmts); /* Check for needing to increase size of array of factories */ - if(idx >= hdr->elmt_fac.nalloc) { - H5FL_fac_head_t **new_fac; /* New array of element factories */ - size_t new_nalloc = MAX3(1, (idx + 1), (2 * hdr->elmt_fac.nalloc)); /* New number of factories allocated */ + if (idx >= hdr->elmt_fac.nalloc) { + H5FL_fac_head_t **new_fac; /* New array of element factories */ + size_t new_nalloc = + MAX3(1, (idx + 1), (2 * hdr->elmt_fac.nalloc)); /* New number of factories allocated */ /* Re-allocate array of element factories */ - if(NULL == (new_fac = H5FL_SEQ_REALLOC(H5FL_fac_head_ptr_t, hdr->elmt_fac.fac, new_nalloc))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block data element buffer factory array") + if (NULL == (new_fac = H5FL_SEQ_REALLOC(H5FL_fac_head_ptr_t, hdr->elmt_fac.fac, new_nalloc))) + H5E_THROW(H5E_CANTALLOC, + "memory allocation failed for data block data element buffer factory array") /* Zero out new elements allocated */ - HDmemset(new_fac + hdr->elmt_fac.nalloc, 0, (new_nalloc - hdr->elmt_fac.nalloc) * sizeof(H5FL_fac_head_ptr_t)); + HDmemset(new_fac + hdr->elmt_fac.nalloc, 0, + (new_nalloc - hdr->elmt_fac.nalloc) * sizeof(H5FL_fac_head_ptr_t)); /* Update information about element factories in header */ hdr->elmt_fac.nalloc = new_nalloc; - hdr->elmt_fac.fac = new_fac; + hdr->elmt_fac.fac = new_fac; } /* end if */ /* Check for un-initialized factory at index */ - if(NULL == hdr->elmt_fac.fac[idx]) { - if(NULL == (hdr->elmt_fac.fac[idx] = H5FL_fac_init(nelmts * (size_t)hdr->cparam.cls->nat_elmt_size))) + if (NULL == hdr->elmt_fac.fac[idx]) { + if (NULL == (hdr->elmt_fac.fac[idx] = H5FL_fac_init(nelmts * (size_t)hdr->cparam.cls->nat_elmt_size))) H5E_THROW(H5E_CANTINIT, "can't create data block data element buffer factory") } /* end if */ /* Allocate buffer for elements in index block */ - if(NULL == (elmts = H5FL_FAC_MALLOC(hdr->elmt_fac.fac[idx]))) + if (NULL == (elmts = H5FL_FAC_MALLOC(hdr->elmt_fac.fac[idx]))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block data element buffer") /* Set the return value */ ret_value = elmts; -CATCH - if(!ret_value) - if(elmts) + CATCH + if (!ret_value) + if (elmts) elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ +END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_free_elmts * @@ -317,12 +299,10 @@ END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) /* Local variables */ - unsigned idx; /* Index of element buffer factory in header */ + unsigned idx; /* Index of element buffer factory in header */ /* Check arguments */ HDassert(hdr); @@ -330,7 +310,7 @@ H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) HDassert(elmts); /* Compute the index of the element buffer factory */ - H5_CHECK_OVERFLOW(nelmts, /*From:*/size_t, /*To:*/uint32_t); + H5_CHECK_OVERFLOW(nelmts, /*From:*/ size_t, /*To:*/ uint32_t); idx = H5VM_log2_of2((uint32_t)nelmts) - H5VM_log2_of2((uint32_t)hdr->cparam.data_blk_min_elmts); /* Free buffer for elements in index block */ @@ -338,9 +318,8 @@ H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) HDassert(hdr->elmt_fac.fac[idx]); elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ +END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_create * @@ -354,54 +333,57 @@ END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Extensible array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5EA_hdr_t *hdr = NULL; /* Extensible array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* Check arguments */ HDassert(f); HDassert(cparam); #ifndef NDEBUG -{ - unsigned sblk_idx; /* Super block index for first "actual" super block */ - size_t dblk_nelmts; /* Number of data block elements */ - size_t dblk_page_nelmts; /* Number of elements in a data block page */ - - /* Check for valid parameters */ - if(cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") - if(cparam->max_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") - if(cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", (unsigned)H5EA_MAX_NELMTS_IDX_MAX) - if(cparam->sup_blk_min_data_ptrs < 2) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") - if(!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs)) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") - if(!POWER_OF_TWO(cparam->data_blk_min_elmts)) - H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") - dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; - if(dblk_page_nelmts < cparam->idx_blk_elmts) - H5E_THROW(H5E_BADVALUE, "# of elements per data block page must be greater than # of elements in index block") - - /* Compute the number of elements in data blocks for first actual super block */ - sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs); - dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts); - if(dblk_page_nelmts < dblk_nelmts) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in first data block from super block") - - if(cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be <= max. # of elements bits") -} + { + unsigned sblk_idx; /* Super block index for first "actual" super block */ + size_t dblk_nelmts; /* Number of data block elements */ + size_t dblk_page_nelmts; /* Number of elements in a data block page */ + + /* Check for valid parameters */ + if (cparam->raw_elmt_size == 0) + H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + if (cparam->max_nelmts_bits == 0) + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + if (cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX) + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", + (unsigned)H5EA_MAX_NELMTS_IDX_MAX) + if (cparam->sup_blk_min_data_ptrs < 2) + H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") + if (!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs)) + H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") + if (!POWER_OF_TWO(cparam->data_blk_min_elmts)) + H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") + dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; + if (dblk_page_nelmts < cparam->idx_blk_elmts) + H5E_THROW(H5E_BADVALUE, + "# of elements per data block page must be greater than # of elements in index block") + + /* Compute the number of elements in data blocks for first actual super block */ + sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs); + dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts); + if (dblk_page_nelmts < dblk_nelmts) + H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in " + "first data block from super block") + + if (cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits) + H5E_THROW(H5E_BADVALUE, + "max. # of elements per data block page bits must be <= max. # of elements bits") + } #endif /* NDEBUG */ /* Allocate space for the shared information */ - if(NULL == (hdr = H5EA__hdr_alloc(f))) + if (NULL == (hdr = H5EA__hdr_alloc(f))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ @@ -411,51 +393,51 @@ H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) H5MM_memcpy(&hdr->cparam, cparam, sizeof(hdr->cparam)); /* Finish initializing extensible array header */ - if(H5EA__hdr_init(hdr, ctx_udata) < 0) + if (H5EA__hdr_init(hdr, ctx_udata) < 0) H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") /* Allocate space for the header on disk */ - if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, (hsize_t)hdr->size))) + if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, (hsize_t)hdr->size))) H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") /* Create 'top' proxy for extensible array entries */ - if(hdr->swmr_write) - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (hdr->swmr_write) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) H5E_THROW(H5E_CANTCREATE, "can't create extensible array entry proxy") /* Cache the new extensible array header */ - if(H5AC_insert_entry(f, H5AC_EARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_EARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ - if(hdr->top_proxy) - if(H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) + if (hdr->top_proxy) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") /* Set address of array header to return */ ret_value = hdr->addr; -CATCH - if(!H5F_addr_defined(ret_value)) - if(hdr) { + CATCH + if (!H5F_addr_defined(ret_value)) + if (hdr) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(hdr) < 0) + if (inserted) + if (H5AC_remove_entry(hdr) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array header from cache") /* Release header's disk space */ - if(H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_EARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) + if (H5F_addr_defined(hdr->addr) && + H5MF_xfree(f, H5FD_MEM_EARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) H5E_THROW(H5E_CANTFREE, "unable to free extensible array header") /* Destroy header */ - if(H5EA__hdr_dest(hdr) < 0) + if (H5EA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") } /* end if */ -END_FUNC(PKG) /* end H5EA__hdr_create() */ +END_FUNC(PKG) /* end H5EA__hdr_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_incr * @@ -469,26 +451,23 @@ END_FUNC(PKG) /* end H5EA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_incr(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_incr(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); /* Mark header as un-evictable when something is depending on it */ - if(hdr->rc == 0) - if(H5AC_pin_protected_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_pin_protected_entry(hdr) < 0) H5E_THROW(H5E_CANTPIN, "unable to pin extensible array header") /* Increment reference count on shared header */ hdr->rc++; -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_incr() */ +END_FUNC(PKG) /* end H5EA__hdr_incr() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_decr * @@ -502,9 +481,7 @@ END_FUNC(PKG) /* end H5EA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_decr(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_decr(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -514,17 +491,16 @@ H5EA__hdr_decr(H5EA_hdr_t *hdr)) hdr->rc--; /* Mark header as evictable again when nothing depend on it */ - if(hdr->rc == 0) { + if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); - if(H5AC_unpin_entry(hdr) < 0) + if (H5AC_unpin_entry(hdr) < 0) H5E_THROW(H5E_CANTUNPIN, "unable to unpin extensible array header") } /* end if */ -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_decr() */ +END_FUNC(PKG) /* end H5EA__hdr_decr() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_incr * @@ -538,9 +514,7 @@ END_FUNC(PKG) /* end H5EA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -548,9 +522,8 @@ H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) /* Increment file reference count on shared header */ hdr->file_rc++; -END_FUNC(PKG) /* end H5EA__hdr_fuse_incr() */ +END_FUNC(PKG) /* end H5EA__hdr_fuse_incr() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_decr * @@ -564,9 +537,7 @@ END_FUNC(PKG) /* end H5EA__hdr_fuse_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -size_t, 0, -, -H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -578,9 +549,8 @@ H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ +END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_modified * @@ -594,23 +564,20 @@ END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_modified(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_modified(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); HDassert(hdr->f); /* Mark header as dirty in cache */ - if(H5AC_mark_entry_dirty(hdr) < 0) + if (H5AC_mark_entry_dirty(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as dirty") -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_modified() */ +END_FUNC(PKG) /* end H5EA__hdr_modified() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_protect * @@ -624,14 +591,12 @@ END_FUNC(PKG) /* end H5EA__hdr_modified() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_hdr_t *, NULL, NULL, -H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, - unsigned flags)) +BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, + H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags)) /* Local variables */ - H5EA_hdr_t *hdr; /* Extensible array header */ - H5EA_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5EA_hdr_t * hdr; /* Extensible array header */ + H5EA_hdr_cache_ud_t udata; /* User data for cache callbacks */ /* Sanity check */ HDassert(f); @@ -641,34 +606,34 @@ H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for cache callbacks */ - udata.f = f; - udata.addr = ea_addr; + udata.f = f; + udata.addr = ea_addr; udata.ctx_udata = ctx_udata; /* Protect the header */ - if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) - hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + if (NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", + (unsigned long long)ea_addr) + hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ - if(hdr->swmr_write && NULL == hdr->top_proxy) { + if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for extensible array entries */ - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) H5E_THROW(H5E_CANTCREATE, "can't create extensible array entry proxy") /* Add header as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") } /* end if */ /* Set return value */ ret_value = hdr; -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_protect() */ +END_FUNC(PKG) /* end H5EA__hdr_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_unprotect * @@ -682,9 +647,7 @@ END_FUNC(PKG) /* end H5EA__hdr_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags)) /* Local variables */ @@ -692,14 +655,14 @@ H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags)) HDassert(hdr); /* Unprotect the header */ - if(H5AC_unprotect(hdr->f, H5AC_EARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array hdr, address = %llu", (unsigned long long)hdr->addr) + if (H5AC_unprotect(hdr->f, H5AC_EARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array hdr, address = %llu", + (unsigned long long)hdr->addr) -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ +END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_delete * @@ -713,50 +676,47 @@ END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_delete(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_delete(H5EA_hdr_t *hdr)) /* Local variables */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ /* Sanity check */ HDassert(hdr); HDassert(!hdr->file_rc); #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Array header's status in the metadata cache */ + { + unsigned hdr_status = 0; /* Array header's status in the metadata cache */ - /* Check the array header's status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") + /* Check the array header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") - /* Sanity checks on array header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); -} /* end block */ + /* Sanity checks on array header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); + } /* end block */ #endif /* NDEBUG */ /* Check for index block */ - if(H5F_addr_defined(hdr->idx_blk_addr)) { + if (H5F_addr_defined(hdr->idx_blk_addr)) { /* Delete index block */ - if(H5EA__iblock_delete(hdr) < 0) + if (H5EA__iblock_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array index block") } /* end if */ /* Set flags to finish deleting header on unprotect */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; -CATCH + CATCH /* Unprotect the header, deleting it if an error hasn't occurred */ - if(H5EA__hdr_unprotect(hdr, cache_flags) < 0) + if (H5EA__hdr_unprotect(hdr, cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_delete() */ +END_FUNC(PKG) /* end H5EA__hdr_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_dest * @@ -770,49 +730,47 @@ END_FUNC(PKG) /* end H5EA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_dest(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Check arguments */ HDassert(hdr); HDassert(hdr->rc == 0); /* Destroy the callback context */ - if(hdr->cb_ctx) { - if((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) + if (hdr->cb_ctx) { + if ((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array client callback context") } /* end if */ hdr->cb_ctx = NULL; /* Check for data block element buffer factory info to free */ - if(hdr->elmt_fac.fac) { - unsigned u; /* Local index variable */ + if (hdr->elmt_fac.fac) { + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(hdr->elmt_fac.nalloc > 0); /* Iterate over factories, shutting them down */ - for(u = 0; u < hdr->elmt_fac.nalloc; u++) { + for (u = 0; u < hdr->elmt_fac.nalloc; u++) { /* Check if this factory has been initialized */ - if(hdr->elmt_fac.fac[u]) { - if(H5FL_fac_term(hdr->elmt_fac.fac[u]) < 0) + if (hdr->elmt_fac.fac[u]) { + if (H5FL_fac_term(hdr->elmt_fac.fac[u]) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array header factory") hdr->elmt_fac.fac[u] = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* Free factory array */ hdr->elmt_fac.fac = (H5FL_fac_head_t **)H5FL_SEQ_FREE(H5FL_fac_head_ptr_t, hdr->elmt_fac.fac); } /* end if */ /* Free the super block info array */ - if(hdr->sblk_info) + if (hdr->sblk_info) hdr->sblk_info = (H5EA_sblk_info_t *)H5FL_SEQ_FREE(H5EA_sblk_info_t, hdr->sblk_info); /* Destroy the 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_dest(hdr->top_proxy) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array 'top' proxy") hdr->top_proxy = NULL; } /* end if */ @@ -820,7 +778,6 @@ H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Free the shared info itself */ hdr = H5FL_FREE(H5EA_hdr_t, hdr); -CATCH - -END_FUNC(PKG) /* end H5EA__hdr_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__hdr_dest() */ diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index 1b5957a..fea020b 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -26,55 +26,46 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -88,8 +79,6 @@ H5FL_BLK_DEFINE_STATIC(idx_blk_elmt_buf); /* Declare a free list to manage the haddr_t sequence information */ H5FL_SEQ_DEFINE_STATIC(haddr_t); - - /*------------------------------------------------------------------------- * Function: H5EA__iblock_alloc * @@ -103,64 +92,63 @@ H5FL_SEQ_DEFINE_STATIC(haddr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_iblock_t *, NULL, NULL, -H5EA__iblock_alloc(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_alloc(H5EA_hdr_t *hdr)) /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ /* Check arguments */ HDassert(hdr); /* Allocate memory for the index block */ - if(NULL == (iblock = H5FL_CALLOC(H5EA_iblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + if (NULL == (iblock = H5FL_CALLOC(H5EA_iblock_t))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") /* Share common array information */ - if(H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + if (H5EA__hdr_incr(hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") iblock->hdr = hdr; /* Set non-zero internal fields */ iblock->addr = HADDR_UNDEF; /* Compute information */ - iblock->nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); + iblock->nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); iblock->ndblk_addrs = 2 * ((size_t)hdr->cparam.sup_blk_min_data_ptrs - 1); iblock->nsblk_addrs = hdr->nsblks - iblock->nsblks; #ifdef QAK -HDfprintf(stderr, "%s: iblock->nsblks = %u\n", FUNC, iblock->nsblks); -HDfprintf(stderr, "%s: iblock->ndblk_addrs = %Zu\n", FUNC, iblock->ndblk_addrs); -HDfprintf(stderr, "%s: iblock->nsblk_addrs = %Zu\n", FUNC, iblock->nsblk_addrs); + HDfprintf(stderr, "%s: iblock->nsblks = %u\n", FUNC, iblock->nsblks); + HDfprintf(stderr, "%s: iblock->ndblk_addrs = %Zu\n", FUNC, iblock->ndblk_addrs); + HDfprintf(stderr, "%s: iblock->nsblk_addrs = %Zu\n", FUNC, iblock->nsblk_addrs); #endif /* QAK */ /* Allocate buffer for elements in index block */ - if(hdr->cparam.idx_blk_elmts > 0) - if(NULL == (iblock->elmts = H5FL_BLK_MALLOC(idx_blk_elmt_buf, (size_t)(hdr->cparam.idx_blk_elmts * hdr->cparam.cls->nat_elmt_size)))) + if (hdr->cparam.idx_blk_elmts > 0) + if (NULL == + (iblock->elmts = H5FL_BLK_MALLOC( + idx_blk_elmt_buf, (size_t)(hdr->cparam.idx_blk_elmts * hdr->cparam.cls->nat_elmt_size)))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data element buffer") /* Allocate buffer for data block addresses in index block */ - if(iblock->ndblk_addrs > 0) - if(NULL == (iblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->ndblk_addrs))) + if (iblock->ndblk_addrs > 0) + if (NULL == (iblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->ndblk_addrs))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data block addresses") /* Allocate buffer for super block addresses in index block */ - if(iblock->nsblk_addrs > 0) - if(NULL == (iblock->sblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->nsblk_addrs))) + if (iblock->nsblk_addrs > 0) + if (NULL == (iblock->sblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->nsblk_addrs))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block super block addresses") /* Set the return value */ ret_value = iblock; -CATCH - if(!ret_value) - if(iblock && H5EA__iblock_dest(iblock) < 0) + CATCH + if (!ret_value) + if (iblock && H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") -END_FUNC(PKG) /* end H5EA__iblock_alloc() */ +END_FUNC(PKG) /* end H5EA__iblock_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_create * @@ -174,17 +162,16 @@ END_FUNC(PKG) /* end H5EA__iblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed)) /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ - haddr_t iblock_addr; /* Extensible array index block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + haddr_t iblock_addr; /* Extensible array index block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ #ifdef QAK -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* QAK */ /* Sanity check */ @@ -192,51 +179,51 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(stats_changed); /* Allocate the index block */ - if(NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + if (NULL == (iblock = H5EA__iblock_alloc(hdr))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") /* Set size of index block on disk */ iblock->size = H5EA_IBLOCK_SIZE(iblock); #ifdef QAK -HDfprintf(stderr, "%s: iblock->size = %Zu\n", FUNC, iblock->size); + HDfprintf(stderr, "%s: iblock->size = %Zu\n", FUNC, iblock->size); #endif /* QAK */ /* Allocate space for the index block on disk */ - if(HADDR_UNDEF == (iblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_IBLOCK, (hsize_t)iblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array index block") + if (HADDR_UNDEF == (iblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_IBLOCK, (hsize_t)iblock->size))) + H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array index block") iblock->addr = iblock_addr; /* Clear any elements in index block to fill value */ - if(hdr->cparam.idx_blk_elmts > 0) { + if (hdr->cparam.idx_blk_elmts > 0) { /* Call the class's 'fill' callback */ - if((hdr->cparam.cls->fill)(iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts) < 0) + if ((hdr->cparam.cls->fill)(iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts) < 0) H5E_THROW(H5E_CANTSET, "can't set extensible array index block elements to class's fill value") } /* end if */ /* Reset any data block addresses in the index block */ - if(iblock->ndblk_addrs > 0) { - haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ + if (iblock->ndblk_addrs > 0) { + haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ /* Set all the data block addresses to "undefined" address value */ H5VM_array_fill(iblock->dblk_addrs, &tmp_addr, sizeof(haddr_t), iblock->ndblk_addrs); } /* end if */ /* Reset any super block addresses in the index block */ - if(iblock->nsblk_addrs > 0) { - haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill super block addresses with */ + if (iblock->nsblk_addrs > 0) { + haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill super block addresses with */ /* Set all the super block addresses to "undefined" address value */ H5VM_array_fill(iblock->sblk_addrs, &tmp_addr, sizeof(haddr_t), iblock->nsblk_addrs); } /* end if */ /* Cache the new extensible array index block */ - if(H5AC_insert_entry(hdr->f, H5AC_EARRAY_IBLOCK, iblock_addr, iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array index block to cache") + if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_IBLOCK, iblock_addr, iblock, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTINSERT, "can't add extensible array index block to cache") inserted = TRUE; /* Add index block as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") iblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -244,7 +231,7 @@ HDfprintf(stderr, "%s: iblock->size = %Zu\n", FUNC, iblock->size); /* Update extensible array index block statistics */ HDassert(0 == hdr->stats.computed.nindex_blks); HDassert(0 == hdr->stats.computed.index_blk_size); - hdr->stats.computed.nindex_blks = 1; + hdr->stats.computed.nindex_blks = 1; hdr->stats.computed.index_blk_size = iblock->size; /* Increment count of elements "realized" */ @@ -256,26 +243,26 @@ HDfprintf(stderr, "%s: iblock->size = %Zu\n", FUNC, iblock->size); /* Set address of index block to return */ ret_value = iblock_addr; -CATCH - if(!H5F_addr_defined(ret_value)) - if(iblock) { + CATCH + if (!H5F_addr_defined(ret_value)) + if (iblock) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(iblock) < 0) + if (inserted) + if (H5AC_remove_entry(iblock) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array index block from cache") /* Release index block's disk space */ - if(H5F_addr_defined(iblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) + if (H5F_addr_defined(iblock->addr) && + H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) H5E_THROW(H5E_CANTFREE, "unable to release file space for extensible array index block") /* Destroy index block */ - if(H5EA__iblock_dest(iblock) < 0) + if (H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_create() */ +END_FUNC(PKG) /* end H5EA__iblock_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_protect * @@ -289,15 +276,13 @@ END_FUNC(PKG) /* end H5EA__iblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_iblock_t *, NULL, NULL, -H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags)) +BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags)) /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ #ifdef QAK -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* QAK */ /* Sanity check */ @@ -307,13 +292,15 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Protect the index block */ - if(NULL == (iblock = (H5EA_iblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_IBLOCK, hdr->idx_blk_addr, hdr, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", (unsigned long long)hdr->idx_blk_addr) + if (NULL == + (iblock = (H5EA_iblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_IBLOCK, hdr->idx_blk_addr, hdr, flags))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == iblock->top_proxy) { + if (hdr->top_proxy && NULL == iblock->top_proxy) { /* Add index block as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") iblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -321,17 +308,18 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Set return value */ ret_value = iblock; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the index block, if it was protected */ - if(iblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", (unsigned long long)iblock->addr) + if (iblock && + H5AC_unprotect(hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", + (unsigned long long)iblock->addr) } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_protect() */ +END_FUNC(PKG) /* end H5EA__iblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_unprotect * @@ -345,28 +333,27 @@ END_FUNC(PKG) /* end H5EA__iblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags)) - /* Local variables */ +/* Local variables */ #ifdef QAK -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* QAK */ /* Sanity check */ HDassert(iblock); /* Unprotect the index block */ - if(H5AC_unprotect(iblock->hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", (unsigned long long)iblock->addr) + if (H5AC_unprotect(iblock->hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, cache_flags) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", + (unsigned long long)iblock->addr) -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ +END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_delete * @@ -380,15 +367,13 @@ END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__iblock_delete(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr)) /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ #ifdef QAK -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* QAK */ /* Sanity check */ @@ -396,22 +381,24 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(H5F_addr_defined(hdr->idx_blk_addr)); /* Protect index block */ - if(NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", (unsigned long long)hdr->idx_blk_addr) + if (NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Check for index block having data block pointers */ - if(iblock->ndblk_addrs > 0) { - unsigned sblk_idx; /* Current super block index */ - unsigned dblk_idx; /* Current data block index w/in super block */ - size_t u; /* Local index variable */ + if (iblock->ndblk_addrs > 0) { + unsigned sblk_idx; /* Current super block index */ + unsigned dblk_idx; /* Current data block index w/in super block */ + size_t u; /* Local index variable */ /* Iterate over data blocks */ sblk_idx = dblk_idx = 0; - for(u = 0; u < iblock->ndblk_addrs; u++) { + for (u = 0; u < iblock->ndblk_addrs; u++) { /* Check for data block existing */ - if(H5F_addr_defined(iblock->dblk_addrs[u])) { + if (H5F_addr_defined(iblock->dblk_addrs[u])) { /* Delete data block */ - if(H5EA__dblock_delete(hdr, iblock, iblock->dblk_addrs[u], hdr->sblk_info[sblk_idx].dblk_nelmts) < 0) + if (H5EA__dblock_delete(hdr, iblock, iblock->dblk_addrs[u], + hdr->sblk_info[sblk_idx].dblk_nelmts) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") iblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ @@ -420,37 +407,38 @@ HDfprintf(stderr, "%s: Called\n", FUNC); dblk_idx++; /* Check for moving to next super block */ - if(dblk_idx >= hdr->sblk_info[sblk_idx].ndblks) { + if (dblk_idx >= hdr->sblk_info[sblk_idx].ndblks) { sblk_idx++; dblk_idx = 0; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* Check for index block having data block pointers (not yet) */ - if(iblock->nsblk_addrs > 0) { - size_t u; /* Local index variable */ + if (iblock->nsblk_addrs > 0) { + size_t u; /* Local index variable */ /* Iterate over super blocks */ - for(u = 0; u < iblock->nsblk_addrs; u++) { + for (u = 0; u < iblock->nsblk_addrs; u++) { /* Check for data block existing */ - if(H5F_addr_defined(iblock->sblk_addrs[u])) { + if (H5F_addr_defined(iblock->sblk_addrs[u])) { /* Delete super block */ - if(H5EA__sblock_delete(hdr, iblock, iblock->sblk_addrs[u], (unsigned)(u + iblock->nsblks)) < 0) + if (H5EA__sblock_delete(hdr, iblock, iblock->sblk_addrs[u], (unsigned)(u + iblock->nsblks)) < + 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array super block") iblock->sblk_addrs[u] = HADDR_UNDEF; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ -CATCH + CATCH /* Finished deleting index block in metadata cache */ - if(iblock && H5EA__iblock_unprotect(iblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (iblock && H5EA__iblock_unprotect(iblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | + H5AC__FREE_FILE_SPACE_FLAG) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") -END_FUNC(PKG) /* end H5EA__iblock_delete() */ +END_FUNC(PKG) /* end H5EA__iblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_dest * @@ -464,40 +452,38 @@ END_FUNC(PKG) /* end H5EA__iblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__iblock_dest(H5EA_iblock_t *iblock)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *iblock)) /* Sanity check */ HDassert(iblock); /* Check if shared header field has been initialized */ - if(iblock->hdr) { + if (iblock->hdr) { /* Check if we've got elements in the index block */ - if(iblock->elmts) { + if (iblock->elmts) { /* Free buffer for index block elements */ HDassert(iblock->hdr->cparam.idx_blk_elmts > 0); iblock->elmts = H5FL_BLK_FREE(idx_blk_elmt_buf, iblock->elmts); } /* end if */ /* Check if we've got data block addresses in the index block */ - if(iblock->dblk_addrs) { + if (iblock->dblk_addrs) { /* Free buffer for index block data block addresses */ HDassert(iblock->ndblk_addrs > 0); - iblock->dblk_addrs = H5FL_SEQ_FREE(haddr_t, iblock->dblk_addrs); + iblock->dblk_addrs = H5FL_SEQ_FREE(haddr_t, iblock->dblk_addrs); iblock->ndblk_addrs = 0; } /* end if */ /* Check if we've got super block addresses in the index block */ - if(iblock->sblk_addrs) { + if (iblock->sblk_addrs) { /* Free buffer for index block super block addresses */ HDassert(iblock->nsblk_addrs > 0); - iblock->sblk_addrs = H5FL_SEQ_FREE(haddr_t, iblock->sblk_addrs); + iblock->sblk_addrs = H5FL_SEQ_FREE(haddr_t, iblock->sblk_addrs); iblock->nsblk_addrs = 0; } /* end if */ /* Decrement reference count on shared info */ - if(H5EA__hdr_decr(iblock->hdr) < 0) + if (H5EA__hdr_decr(iblock->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") iblock->hdr = NULL; } /* end if */ @@ -508,7 +494,6 @@ H5EA__iblock_dest(H5EA_iblock_t *iblock)) /* Free the index block itself */ iblock = H5FL_FREE(H5EA_iblock_t, iblock); -CATCH - -END_FUNC(PKG) /* end H5EA__iblock_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__iblock_dest() */ diff --git a/src/H5EAint.c b/src/H5EAint.c index 2baf1f4..6be3478 100644 --- a/src/H5EAint.c +++ b/src/H5EAint.c @@ -26,58 +26,47 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5EA__create_flush_depend * @@ -91,23 +80,21 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) /* Sanity check */ HDassert(parent_entry); HDassert(child_entry); /* Create a flush dependency between parent and child entry */ - if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__create_flush_depend() */ +END_FUNC(PKG) /* end H5EA__create_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5EA__destroy_flush_depend * @@ -121,19 +108,17 @@ END_FUNC(PKG) /* end H5EA__create_flush_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) /* Sanity check */ HDassert(parent_entry); HDassert(child_entry); /* Destroy a flush dependency between parent and child entry */ - if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") -CATCH - -END_FUNC(PKG) /* end H5EA__destroy_flush_depend() */ + CATCH +END_FUNC(PKG) /* end H5EA__destroy_flush_depend() */ diff --git a/src/H5EAmodule.h b/src/H5EAmodule.h index c3a4c7c..d9d5cfa 100644 --- a/src/H5EAmodule.h +++ b/src/H5EAmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5EA_MODULE -#define H5_MY_PKG H5EA -#define H5_MY_PKG_ERR H5E_EARRAY -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5EA +#define H5_MY_PKG_ERR H5E_EARRAY +#define H5_MY_PKG_INIT NO #endif /* _H5EAmodule_H */ - diff --git a/src/H5EApkg.h b/src/H5EApkg.h index b70231d..d21736a 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -30,8 +30,7 @@ #include "H5EAprivate.h" /* Other private headers needed by this file */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ @@ -39,114 +38,114 @@ /* Fill value for extensible array test class */ #ifdef H5EA_TESTING -#define H5EA_TEST_FILL ((uint64_t)ULLONG_MAX) +#define H5EA_TEST_FILL ((uint64_t)ULLONG_MAX) #endif /* H5EA_TESTING */ /* Size of checksum information (on disk) */ -#define H5EA_SIZEOF_CHKSUM 4 +#define H5EA_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for extensible array metadata */ -#define H5EA_METADATA_PREFIX_SIZE(c) ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + 1 /* Version */ \ - + 1 /* Array type */ \ - + ((c) ? H5EA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ +#define H5EA_METADATA_PREFIX_SIZE(c) \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + 1 /* Version */ \ + + 1 /* Array type */ \ + + ((c) ? H5EA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ ) /* Size of the extensible array header on disk */ -#define H5EA_HEADER_SIZE(sizeof_addr, sizeof_size) ( \ - /* General metadata fields */ \ - H5EA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* General array information */ \ - + 1 /* Element Size */ \ - + 1 /* Max. # of elements bits */ \ - + 1 /* # of elements to store in index block */ \ - + 1 /* Min. # elements per data block */ \ - + 1 /* Min. # of data block pointers for a super block */ \ - + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ \ - \ - /* Extensible Array statistics fields */ \ - + (sizeof_size) /* Number of super blocks created */ \ - + (sizeof_size) /* Size of super blocks created */ \ - + (sizeof_size) /* Number of data blocks created */ \ - + (sizeof_size) /* Size of data blocks created */ \ - + (sizeof_size) /* Max. index set */ \ - + (sizeof_size) /* Number of elements 'realized' */ \ - \ - /* Extensible Array Header specific fields */ \ - + (sizeof_addr) /* File address of index block */ \ +#define H5EA_HEADER_SIZE(sizeof_addr, sizeof_size) \ + (/* General metadata fields */ \ + H5EA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* General array information */ \ + + 1 /* Element Size */ \ + + 1 /* Max. # of elements bits */ \ + + 1 /* # of elements to store in index block */ \ + + 1 /* Min. # elements per data block */ \ + + 1 /* Min. # of data block pointers for a super block */ \ + + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements \ + in data block page */ \ + \ + /* Extensible Array statistics fields */ \ + + (sizeof_size) /* Number of super blocks created */ \ + + (sizeof_size) /* Size of super blocks created */ \ + + (sizeof_size) /* Number of data blocks created */ \ + + (sizeof_size) /* Size of data blocks created */ \ + + (sizeof_size) /* Max. index set */ \ + + (sizeof_size) /* Number of elements 'realized' */ \ + \ + /* Extensible Array Header specific fields */ \ + + (sizeof_addr) /* File address of index block */ \ ) /* Size of the extensible array header on disk (via file pointer) */ -#define H5EA_HEADER_SIZE_FILE(f) ( \ - H5EA_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f)) \ - ) +#define H5EA_HEADER_SIZE_FILE(f) (H5EA_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f))) /* Size of the extensible array header on disk (via extensible array header) */ -#define H5EA_HEADER_SIZE_HDR(h) ( \ - H5EA_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size) \ - ) +#define H5EA_HEADER_SIZE_HDR(h) (H5EA_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size)) /* Size of the extensible array index block on disk */ -#define H5EA_IBLOCK_SIZE(i) ( \ - /* General metadata fields */ \ - H5EA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Sanity-checking fields */ \ - + (i)->hdr->sizeof_addr /* File address of array owning the block */ \ - \ - /* Extensible Array Index Block specific fields */ \ - + ((size_t)(i)->hdr->cparam.idx_blk_elmts * (size_t)(i)->hdr->cparam.raw_elmt_size) /* Elements in index block */ \ - + ((i)->ndblk_addrs * (i)->hdr->sizeof_addr) /* Data block addresses in index block */ \ - + ((i)->nsblk_addrs * (i)->hdr->sizeof_addr) /* Super block addresses in index block */ \ +#define H5EA_IBLOCK_SIZE(i) \ + (/* General metadata fields */ \ + H5EA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Sanity-checking fields */ \ + + (i)->hdr->sizeof_addr /* File address of array owning the block */ \ + \ + /* Extensible Array Index Block specific fields */ \ + + ((size_t)(i)->hdr->cparam.idx_blk_elmts * \ + (size_t)(i)->hdr->cparam.raw_elmt_size) /* Elements in index block */ \ + + ((i)->ndblk_addrs * (i)->hdr->sizeof_addr) /* Data block addresses in index block */ \ + + ((i)->nsblk_addrs * (i)->hdr->sizeof_addr) /* Super block addresses in index block */ \ ) /* Size of the extensible array super block on disk */ -#define H5EA_SBLOCK_SIZE(s) ( \ - /* General metadata fields */ \ - H5EA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Sanity-checking fields */ \ - + (s)->hdr->sizeof_addr /* File address of array owning the block */ \ - + (s)->hdr->arr_off_size /* Offset of the block in the array */ \ - \ - /* Extensible Array Super Block specific fields */ \ - + ((s)->ndblks * (s)->dblk_page_init_size) /* Data block 'page init' bitmasks in super block (can be 0 if no pages) */ \ - + ((s)->ndblks * (s)->hdr->sizeof_addr) /* Data block addresses in super block */ \ +#define H5EA_SBLOCK_SIZE(s) \ + (/* General metadata fields */ \ + H5EA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Sanity-checking fields */ \ + + (s)->hdr->sizeof_addr /* File address of array owning the block */ \ + + (s)->hdr->arr_off_size /* Offset of the block in the array */ \ + \ + /* Extensible Array Super Block specific fields */ \ + + \ + ((s)->ndblks * \ + (s)->dblk_page_init_size) /* Data block 'page init' bitmasks in super block (can be 0 if no pages) */ \ + + ((s)->ndblks * (s)->hdr->sizeof_addr) /* Data block addresses in super block */ \ ) /* Size of the extensible array data block prefix on disk */ -#define H5EA_DBLOCK_PREFIX_SIZE(d) ( \ - /* General metadata fields */ \ - H5EA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Sanity-checking fields */ \ - + (d)->hdr->sizeof_addr /* File address of array owning the block */ \ - + (d)->hdr->arr_off_size /* Offset of the block in the array */ \ +#define H5EA_DBLOCK_PREFIX_SIZE(d) \ + (/* General metadata fields */ \ + H5EA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Sanity-checking fields */ \ + + (d)->hdr->sizeof_addr /* File address of array owning the block */ \ + + (d)->hdr->arr_off_size /* Offset of the block in the array */ \ ) /* Size of the extensible array data block on disk */ -#define H5EA_DBLOCK_SIZE(d) ( \ - /* Data block prefix size */ \ - H5EA_DBLOCK_PREFIX_SIZE(d) \ - \ - /* Extensible Array Data Block specific fields */ \ - + ((d)->nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) /* Elements in data block */ \ - + ((d)->npages * H5EA_SIZEOF_CHKSUM) /* Checksum for each page */ \ +#define H5EA_DBLOCK_SIZE(d) \ + (/* Data block prefix size */ \ + H5EA_DBLOCK_PREFIX_SIZE(d) \ + \ + /* Extensible Array Data Block specific fields */ \ + + ((d)->nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) /* Elements in data block */ \ + + ((d)->npages * H5EA_SIZEOF_CHKSUM) /* Checksum for each page */ \ ) /* Size of the extensible array data block page on disk */ -#define H5EA_DBLK_PAGE_SIZE(h) ( \ - + ((h)->dblk_page_nelmts * (size_t)(h)->cparam.raw_elmt_size) /* Elements in data block page */ \ - + H5EA_SIZEOF_CHKSUM /* Checksum for each page */ \ +#define H5EA_DBLK_PAGE_SIZE(h) \ + (+((h)->dblk_page_nelmts * (size_t)(h)->cparam.raw_elmt_size) /* Elements in data block page */ \ + + H5EA_SIZEOF_CHKSUM /* Checksum for each page */ \ ) /* Compute the # of bytes required to store an offset into a given buffer size */ -#define H5EA_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) +#define H5EA_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) /* Compute the first super block index that will hold a certain # of data block pointers */ -#define H5EA_SBLK_FIRST_IDX(m) (2 * H5VM_log2_of2((uint32_t)m)) +#define H5EA_SBLK_FIRST_IDX(m) (2 * H5VM_log2_of2((uint32_t)m)) /****************************/ /* Package Private Typedefs */ @@ -154,10 +153,10 @@ /* Information for each super block in extensible array */ typedef struct H5EA_sblk_info_t { - size_t ndblks; /* Number of data blocks for a super block */ - size_t dblk_nelmts; /* Number of elements in each data block for super block */ - hsize_t start_idx; /* Index of first element in super block */ - hsize_t start_dblk; /* Index of first data block in super block */ + size_t ndblks; /* Number of data blocks for a super block */ + size_t dblk_nelmts; /* Number of elements in each data block for super block */ + hsize_t start_idx; /* Index of first element in super block */ + hsize_t start_dblk; /* Index of first data block in super block */ } H5EA_sblk_info_t; /* The extensible array header information */ @@ -169,63 +168,63 @@ typedef struct H5EA_hdr_t { H5AC_info_t cache_info; /* Extensible array configuration/creation parameters (stored in header) */ - H5EA_create_t cparam; /* Creation parameters for extensible array */ + H5EA_create_t cparam; /* Creation parameters for extensible array */ /* Index block information (stored in header) */ - haddr_t idx_blk_addr; /* Address of index block in header */ + haddr_t idx_blk_addr; /* Address of index block in header */ /* Statistics for array (stored in index block, actually) */ /* (header and index number/size fields not stored) */ - H5EA_stat_t stats; /* Statistics for extensible array */ + H5EA_stat_t stats; /* Statistics for extensible array */ /* Data block element buffer factory info (not stored in header) */ struct { - size_t nalloc; /* Number of factories allocated */ - H5FL_fac_head_t **fac; /* Array of factories for data block element buffers */ + size_t nalloc; /* Number of factories allocated */ + H5FL_fac_head_t **fac; /* Array of factories for data block element buffers */ } elmt_fac; /* Computed/cached values (not stored in header) */ - size_t rc; /* Reference count of heap's components using heap header */ - haddr_t addr; /* Address of header in file */ - size_t size; /* Size of header in file */ - H5F_t *f; /* Pointer to file for extensible array */ - size_t file_rc; /* Reference count of files using array header */ - hbool_t pending_delete; /* Array is pending deletion */ - size_t sizeof_addr; /* Size of file addresses */ - size_t sizeof_size; /* Size of file sizes */ - unsigned char arr_off_size; /* Size of array offsets (in bytes) */ + size_t rc; /* Reference count of heap's components using heap header */ + haddr_t addr; /* Address of header in file */ + size_t size; /* Size of header in file */ + H5F_t * f; /* Pointer to file for extensible array */ + size_t file_rc; /* Reference count of files using array header */ + hbool_t pending_delete; /* Array is pending deletion */ + size_t sizeof_addr; /* Size of file addresses */ + size_t sizeof_size; /* Size of file sizes */ + unsigned char arr_off_size; /* Size of array offsets (in bytes) */ /* Super block information (not stored) */ - size_t nsblks; /* Number of superblocks needed for array */ - H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */ + size_t nsblks; /* Number of superblocks needed for array */ + H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */ /* Data block information (not stored) */ - size_t dblk_page_nelmts; /* # of elements per data block page */ + size_t dblk_page_nelmts; /* # of elements per data block page */ /* Client information (not stored) */ - void *cb_ctx; /* Callback context */ + void *cb_ctx; /* Callback context */ /* SWMR / Flush dependency information (not stored) */ - hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ - H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ - void *parent; /* Pointer to 'top' proxy flush dependency - * parent, if it exists, otherwise NULL. - * If the extensible array is being used - * to index a chunked dataset and the - * dataset metadata is modified by a - * SWMR writer, this field will be set - * equal to the object header proxy - * that is the flush dependency parent - * of the extensible array header. - * - * The field is used to avoid duplicate - * setups of the flush dependency - * relationship, and to allow the - * extensible array header to destroy - * the flush dependency on receipt of - * an eviction notification from the - * metadata cache. - */ + hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ + void * parent; /* Pointer to 'top' proxy flush dependency + * parent, if it exists, otherwise NULL. + * If the extensible array is being used + * to index a chunked dataset and the + * dataset metadata is modified by a + * SWMR writer, this field will be set + * equal to the object header proxy + * that is the flush dependency parent + * of the extensible array header. + * + * The field is used to avoid duplicate + * setups of the flush dependency + * relationship, and to allow the + * extensible array header to destroy + * the flush dependency on receipt of + * an eviction notification from the + * metadata cache. + */ } H5EA_hdr_t; /* The extensible array index block information */ @@ -234,22 +233,22 @@ typedef struct H5EA_iblock_t { H5AC_info_t cache_info; /* Extensible array information (stored) */ - void *elmts; /* Buffer for elements stored in index block */ - haddr_t *dblk_addrs; /* Buffer for addresses of data blocks in index block */ - haddr_t *sblk_addrs; /* Buffer for addresses of super blocks in index block */ + void * elmts; /* Buffer for elements stored in index block */ + haddr_t *dblk_addrs; /* Buffer for addresses of data blocks in index block */ + haddr_t *sblk_addrs; /* Buffer for addresses of super blocks in index block */ /* Internal array information (not stored) */ - H5EA_hdr_t *hdr; /* Shared array header info */ - haddr_t addr; /* Address of this index block on disk */ - size_t size; /* Size of index block on disk */ + H5EA_hdr_t *hdr; /* Shared array header info */ + haddr_t addr; /* Address of this index block on disk */ + size_t size; /* Size of index block on disk */ /* SWMR / Flush dependency information (not stored) */ - H5AC_proxy_entry_t *top_proxy; /* "Top" proxy cache entry for all array entries */ + H5AC_proxy_entry_t *top_proxy; /* "Top" proxy cache entry for all array entries */ /* Computed/cached values (not stored) */ - size_t nsblks; /* # of super blocks whose data block addresses are in index block */ - size_t ndblk_addrs; /* Number of pointers to data blocks in index block */ - size_t nsblk_addrs; /* Number of pointers to super blocks in index block */ + size_t nsblks; /* # of super blocks whose data block addresses are in index block */ + size_t ndblk_addrs; /* Number of pointers to data blocks in index block */ + size_t nsblk_addrs; /* Number of pointers to super blocks in index block */ } H5EA_iblock_t; /* The extensible array super block information */ @@ -258,27 +257,27 @@ typedef struct H5EA_sblock_t { H5AC_info_t cache_info; /* Extensible array information (stored) */ - hsize_t block_off; /* Offset of the block within the array's address space */ - haddr_t *dblk_addrs; /* Addresses of data blocks in super block */ - uint8_t *page_init; /* Bitmap of whether a data block page is initialized */ + hsize_t block_off; /* Offset of the block within the array's address space */ + haddr_t *dblk_addrs; /* Addresses of data blocks in super block */ + uint8_t *page_init; /* Bitmap of whether a data block page is initialized */ /* Internal array information (not stored) */ - H5EA_hdr_t *hdr; /* Shared array header info */ - haddr_t addr; /* Address of this index block on disk */ - size_t size; /* Size of index block on disk */ + H5EA_hdr_t *hdr; /* Shared array header info */ + haddr_t addr; /* Address of this index block on disk */ + size_t size; /* Size of index block on disk */ /* SWMR / Flush dependency information (not stored) */ - hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ + hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ H5AC_proxy_entry_t *top_proxy; /* "Top" proxy cache entry for all array entries */ - H5EA_iblock_t *parent; /* Parent object for super block (index block) */ + H5EA_iblock_t * parent; /* Parent object for super block (index block) */ /* Computed/cached values (not stored) */ - unsigned idx; /* Super block index within the extensible array */ - size_t ndblks; /* # of data block addresses that are in super block */ - size_t dblk_nelmts; /* # of elements for data blocks reachable through this super block */ - size_t dblk_npages; /* # of pages in each data block */ - size_t dblk_page_init_size; /* Size of 'page init' bitmask for each data block */ - size_t dblk_page_size; /* Size of a data block page */ + unsigned idx; /* Super block index within the extensible array */ + size_t ndblks; /* # of data block addresses that are in super block */ + size_t dblk_nelmts; /* # of elements for data blocks reachable through this super block */ + size_t dblk_npages; /* # of pages in each data block */ + size_t dblk_page_init_size; /* Size of 'page init' bitmask for each data block */ + size_t dblk_page_size; /* Size of a data block page */ } H5EA_sblock_t; /* The extensible array data block information */ @@ -287,22 +286,22 @@ typedef struct H5EA_dblock_t { H5AC_info_t cache_info; /* Extensible array information (stored) */ - hsize_t block_off; /* Offset of the block within the array's address space */ - void *elmts; /* Buffer for elements stored in data block */ + hsize_t block_off; /* Offset of the block within the array's address space */ + void * elmts; /* Buffer for elements stored in data block */ /* Internal array information (not stored) */ - H5EA_hdr_t *hdr; /* Shared array header info */ - haddr_t addr; /* Address of this data block on disk */ - size_t size; /* Size of data block on disk */ + H5EA_hdr_t *hdr; /* Shared array header info */ + haddr_t addr; /* Address of this data block on disk */ + size_t size; /* Size of data block on disk */ /* SWMR / Flush dependency information (not stored) */ - hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ + hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ - void *parent; /* Parent object for data block (index or super block) */ + void * parent; /* Parent object for data block (index or super block) */ /* Computed/cached values (not stored) */ - size_t nelmts; /* Number of elements in block */ - size_t npages; /* Nummber of pages in a block (zero if not paged) */ + size_t nelmts; /* Number of elements in block */ + size_t npages; /* Nummber of pages in a block (zero if not paged) */ } H5EA_dblock_t; /* The extensible array data block page information */ @@ -311,17 +310,17 @@ typedef struct H5EA_dbk_page_t { H5AC_info_t cache_info; /* Extensible array information (stored) */ - void *elmts; /* Buffer for elements stored in data block page */ + void *elmts; /* Buffer for elements stored in data block page */ /* Internal array information (not stored) */ - H5EA_hdr_t *hdr; /* Shared array header info */ - haddr_t addr; /* Address of this data block page on disk */ - size_t size; /* Size of data block page on disk */ + H5EA_hdr_t *hdr; /* Shared array header info */ + haddr_t addr; /* Address of this data block page on disk */ + size_t size; /* Size of data block page on disk */ /* SWMR / Flush dependency information (not stored) */ - hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ + hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ H5AC_proxy_entry_t *top_proxy; /* "Top" proxy cache entry for all array entries */ - H5EA_sblock_t *parent; /* Parent object for data block page (super block) */ + H5EA_sblock_t * parent; /* Parent object for data block page (super block) */ /* Computed/cached values (not stored) */ /* */ @@ -329,46 +328,46 @@ typedef struct H5EA_dbk_page_t { /* Extensible array */ struct H5EA_t { - H5EA_hdr_t *hdr; /* Pointer to internal extensible array header info */ - H5F_t *f; /* Pointer to file for extensible array */ + H5EA_hdr_t *hdr; /* Pointer to internal extensible array header info */ + H5F_t * f; /* Pointer to file for extensible array */ }; /* Metadata cache callback user data types */ /* Info needed for loading header */ typedef struct H5EA_hdr_cache_ud_t { - H5F_t *f; /* Pointer to file for extensible array */ - haddr_t addr; /* Address of header on disk */ - void *ctx_udata; /* User context for class */ + H5F_t * f; /* Pointer to file for extensible array */ + haddr_t addr; /* Address of header on disk */ + void * ctx_udata; /* User context for class */ } H5EA_hdr_cache_ud_t; /* Info needed for loading super block */ typedef struct H5EA_sblock_cache_ud_t { - H5EA_hdr_t *hdr; /* Shared extensible array information */ - H5EA_iblock_t *parent; /* Pointer to parent object for super block (index block) */ - unsigned sblk_idx; /* Index of super block */ - haddr_t sblk_addr; /* Address of super block */ + H5EA_hdr_t * hdr; /* Shared extensible array information */ + H5EA_iblock_t *parent; /* Pointer to parent object for super block (index block) */ + unsigned sblk_idx; /* Index of super block */ + haddr_t sblk_addr; /* Address of super block */ } H5EA_sblock_cache_ud_t; /* Info needed for loading data block */ typedef struct H5EA_dblock_cache_ud_t { - H5EA_hdr_t *hdr; /* Shared extensible array information */ - void *parent; /* Pointer to parent object for data block (index or super block) */ - size_t nelmts; /* Number of elements in data block */ - haddr_t dblk_addr; /* Address of data block */ + H5EA_hdr_t *hdr; /* Shared extensible array information */ + void * parent; /* Pointer to parent object for data block (index or super block) */ + size_t nelmts; /* Number of elements in data block */ + haddr_t dblk_addr; /* Address of data block */ } H5EA_dblock_cache_ud_t; /* Info needed for loading data block page */ typedef struct H5EA_dblk_page_cache_ud_t { - H5EA_hdr_t *hdr; /* Shared extensible array information */ - H5EA_sblock_t *parent; /* Pointer to parent object for data block page (super block) */ - haddr_t dblk_page_addr; /* Address of data block page */ + H5EA_hdr_t * hdr; /* Shared extensible array information */ + H5EA_sblock_t *parent; /* Pointer to parent object for data block page (super block) */ + haddr_t dblk_page_addr; /* Address of data block page */ } H5EA_dblk_page_cache_ud_t; #ifdef H5EA_TESTING typedef struct H5EA__ctx_cb_t { - herr_t (*encode)(const void *elmt, size_t nelmts, void *udata); /* Perform action during encode step */ - void *udata; /* User data for encode action */ + herr_t (*encode)(const void *elmt, size_t nelmts, void *udata); /* Perform action during encode step */ + void *udata; /* User data for encode action */ } H5EA__ctx_cb_t; #endif /* H5EA_TESTING */ @@ -382,96 +381,84 @@ H5_DLLVAR const H5EA_class_t H5EA_CLS_TEST[1]; /* Array of extensible array client ID -> client class mappings */ H5_DLLVAR const H5EA_class_t *const H5EA_client_class_g[H5EA_NUM_CLS_ID]; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Generic routines */ -H5_DLL herr_t H5EA__create_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); -H5_DLL herr_t H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); +H5_DLL herr_t H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); +H5_DLL herr_t H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Header routines */ H5_DLL H5EA_hdr_t *H5EA__hdr_alloc(H5F_t *f); -H5_DLL herr_t H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata); -H5_DLL haddr_t H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, - void *ctx_udata); -H5_DLL void *H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts); -H5_DLL herr_t H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts); -H5_DLL herr_t H5EA__hdr_incr(H5EA_hdr_t *hdr); -H5_DLL herr_t H5EA__hdr_decr(H5EA_hdr_t *hdr); -H5_DLL herr_t H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr); -H5_DLL size_t H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr); -H5_DLL herr_t H5EA__hdr_modified(H5EA_hdr_t *hdr); -H5_DLL H5EA_hdr_t *H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, - void *ctx_udata, unsigned flags); -H5_DLL herr_t H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags); -H5_DLL herr_t H5EA__hdr_delete(H5EA_hdr_t *hdr); -H5_DLL herr_t H5EA__hdr_dest(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata); +H5_DLL haddr_t H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata); +H5_DLL void * H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts); +H5_DLL herr_t H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts); +H5_DLL herr_t H5EA__hdr_incr(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__hdr_decr(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr); +H5_DLL size_t H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__hdr_modified(H5EA_hdr_t *hdr); +H5_DLL H5EA_hdr_t *H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags); +H5_DLL herr_t H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags); +H5_DLL herr_t H5EA__hdr_delete(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__hdr_dest(H5EA_hdr_t *hdr); /* Index block routines */ H5_DLL H5EA_iblock_t *H5EA__iblock_alloc(H5EA_hdr_t *hdr); -H5_DLL haddr_t H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed); +H5_DLL haddr_t H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed); H5_DLL H5EA_iblock_t *H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags); -H5_DLL herr_t H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags); -H5_DLL herr_t H5EA__iblock_delete(H5EA_hdr_t *hdr); -H5_DLL herr_t H5EA__iblock_dest(H5EA_iblock_t *iblock); +H5_DLL herr_t H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags); +H5_DLL herr_t H5EA__iblock_delete(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__iblock_dest(H5EA_iblock_t *iblock); /* Super block routines */ -H5_DLL H5EA_sblock_t *H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - unsigned sblk_idx); -H5_DLL haddr_t H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - hbool_t *stats_changed, unsigned sblk_idx); -H5_DLL H5EA_sblock_t *H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - haddr_t sblk_addr, unsigned sblk_idx, unsigned flags); -H5_DLL herr_t H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags); -H5_DLL herr_t H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - haddr_t sblk_addr, unsigned sblk_idx); -H5_DLL herr_t H5EA__sblock_dest(H5EA_sblock_t *sblock); +H5_DLL H5EA_sblock_t *H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx); +H5_DLL haddr_t H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, + unsigned sblk_idx); +H5_DLL H5EA_sblock_t *H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, + unsigned sblk_idx, unsigned flags); +H5_DLL herr_t H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags); +H5_DLL herr_t H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, + unsigned sblk_idx); +H5_DLL herr_t H5EA__sblock_dest(H5EA_sblock_t *sblock); /* Data block routines */ -H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, - size_t nelmts); -H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, - hbool_t *stats_changed, hsize_t dblk_off, size_t nelmts); +H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts); +H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, + size_t nelmts); H5_DLL unsigned H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx); -H5_DLL H5EA_dblock_t *H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, - haddr_t dblk_addr, size_t dblk_nelmts, unsigned flags); -H5_DLL herr_t H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags); -H5_DLL herr_t H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, - haddr_t dblk_addr, size_t dblk_nelmts); +H5_DLL H5EA_dblock_t *H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, + size_t dblk_nelmts, unsigned flags); +H5_DLL herr_t H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags); +H5_DLL herr_t H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts); H5_DLL herr_t H5EA__dblock_dest(H5EA_dblock_t *dblock); /* Data block page routines */ H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent); -H5_DLL herr_t H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, - haddr_t addr); -H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_protect(H5EA_hdr_t *hdr, - H5EA_sblock_t *parent, haddr_t dblk_page_addr, unsigned flags); -H5_DLL herr_t H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, - unsigned cache_flags); -H5_DLL herr_t H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page); +H5_DLL herr_t H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr); +H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, + haddr_t dblk_page_addr, unsigned flags); +H5_DLL herr_t H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags); +H5_DLL herr_t H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page); /* Debugging routines for dumping file structures */ -H5_DLL herr_t H5EA__hdr_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, haddr_t obj_addr); -H5_DLL herr_t H5EA__iblock_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, - haddr_t hdr_addr, haddr_t obj_addr); -H5_DLL herr_t H5EA__sblock_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, - haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr); -H5_DLL herr_t H5EA__dblock_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, - haddr_t hdr_addr, size_t dblk_nelmts, haddr_t obj_addr); +H5_DLL herr_t H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t obj_addr); +H5_DLL herr_t H5EA__iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr); +H5_DLL herr_t H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, unsigned sblk_idx, + haddr_t obj_addr); +H5_DLL herr_t H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, size_t dblk_nelmts, + haddr_t obj_addr); /* Testing routines */ #ifdef H5EA_TESTING H5_DLL herr_t H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam); -H5_DLL int H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2); +H5_DLL int H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2); #endif /* H5EA_TESTING */ #endif /* _H5EApkg_H */ - diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index af0ef3a..5ead26c 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -32,28 +32,26 @@ #endif /* NOT_YET */ /* Private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* Extensible array class IDs */ typedef enum H5EA_cls_id_t { - H5EA_CLS_CHUNK_ID = 0, /* Extensible array is for indexing dataset chunks w/o filters */ - H5EA_CLS_FILT_CHUNK_ID, /* Extensible array is for indexing dataset chunks w/filters */ + H5EA_CLS_CHUNK_ID = 0, /* Extensible array is for indexing dataset chunks w/o filters */ + H5EA_CLS_FILT_CHUNK_ID, /* Extensible array is for indexing dataset chunks w/filters */ /* Start real class IDs at 0 -QAK */ /* (keep these last) */ - H5EA_CLS_TEST_ID, /* Extensible array is for testing (do not use for actual data) */ - H5EA_NUM_CLS_ID /* Number of Extensible Array class IDs (must be last) */ + H5EA_CLS_TEST_ID, /* Extensible array is for testing (do not use for actual data) */ + H5EA_NUM_CLS_ID /* Number of Extensible Array class IDs (must be last) */ } H5EA_cls_id_t; /* @@ -61,30 +59,36 @@ typedef enum H5EA_cls_id_t { * variable of this type that contains class variables and methods. */ typedef struct H5EA_class_t { - H5EA_cls_id_t id; /* ID of Extensible Array class, as found in file */ - const char *name; /* Name of class (for debugging) */ - size_t nat_elmt_size; /* Size of native (memory) element */ + H5EA_cls_id_t id; /* ID of Extensible Array class, as found in file */ + const char * name; /* Name of class (for debugging) */ + size_t nat_elmt_size; /* Size of native (memory) element */ /* Extensible array client callback methods */ - void *(*crt_context)(void *udata); /* Create context for other callbacks */ - herr_t (*dst_context)(void *ctx); /* Destroy context */ - herr_t (*fill)(void *nat_blk, size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ - herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, void *ctx); /* Encode elements from native form to disk storage form */ - herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, void *ctx); /* Decode elements from disk storage form to native form */ - herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Print an element for debugging */ + void *(*crt_context)(void *udata); /* Create context for other callbacks */ + herr_t (*dst_context)(void *ctx); /* Destroy context */ + herr_t (*fill)(void * nat_blk, + size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ + herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, + void *ctx); /* Encode elements from native form to disk storage form */ + herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, + void *ctx); /* Decode elements from disk storage form to native form */ + herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, + const void *elmt); /* Print an element for debugging */ void *(*crt_dbg_ctx)(H5F_t *f, haddr_t obj_addr); /* Create debugging context */ - herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ + herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ } H5EA_class_t; /* Extensible array creation parameters */ typedef struct H5EA_create_t { - const H5EA_class_t *cls; /* Class of extensible array to create */ - uint8_t raw_elmt_size; /* Element size in file (in bytes) */ - uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ - uint8_t idx_blk_elmts; /* # of elements to store in index block */ - uint8_t data_blk_min_elmts; /* Min. # of elements per data block */ - uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ - uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + const H5EA_class_t *cls; /* Class of extensible array to create */ + uint8_t raw_elmt_size; /* Element size in file (in bytes) */ + uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of + elements */ + uint8_t idx_blk_elmts; /* # of elements to store in index block */ + uint8_t data_blk_min_elmts; /* Min. # of elements per data block */ + uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ + uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed + to store max. # of elements in data block page */ } H5EA_create_t; /* Extensible array metadata statistics info */ @@ -94,19 +98,20 @@ typedef struct H5EA_create_t { typedef struct H5EA_stat_t { /* Non-stored (i.e. computed) fields */ struct { - hsize_t hdr_size; /* Size of header */ - hsize_t nindex_blks; /* # of index blocks (should be 0 or 1) */ - hsize_t index_blk_size; /* Size of index blocks allocated */ + hsize_t hdr_size; /* Size of header */ + hsize_t nindex_blks; /* # of index blocks (should be 0 or 1) */ + hsize_t index_blk_size; /* Size of index blocks allocated */ } computed; /* Stored fields */ struct { - hsize_t nsuper_blks; /* # of super blocks */ - hsize_t super_blk_size; /* Size of super blocks allocated */ - hsize_t ndata_blks; /* # of data blocks */ - hsize_t data_blk_size; /* Size of data blocks allocated */ - hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */ - hsize_t nelmts; /* # of elements "realized" */ + hsize_t nsuper_blks; /* # of super blocks */ + hsize_t super_blk_size; /* Size of super blocks allocated */ + hsize_t ndata_blks; /* # of data blocks */ + hsize_t data_blk_size; /* Size of data blocks allocated */ + hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value + with be '1', if no elements have been stored, this value will be '0') */ + hsize_t nelmts; /* # of elements "realized" */ } stored; } H5EA_stat_t; @@ -116,7 +121,6 @@ typedef struct H5EA_t H5EA_t; /* Define the operator callback function pointer for H5EA_iterate() */ typedef int (*H5EA_operator_t)(hsize_t idx, const void *_elmt, void *_udata); - /*****************************/ /* Library-private Variables */ /*****************************/ @@ -127,24 +131,22 @@ H5_DLLVAR const H5EA_class_t H5EA_CLS_CHUNK[1]; /* The Extensible Array class for dataset chunks w/ filters*/ H5_DLLVAR const H5EA_class_t H5EA_CLS_FILT_CHUNK[1]; - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General routines */ -H5_DLL H5EA_t *H5EA_create(H5F_t *f, const H5EA_create_t *cparam, - void *ctx_udata); +H5_DLL H5EA_t *H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata); H5_DLL H5EA_t *H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata); -H5_DLL herr_t H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts); -H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr); -H5_DLL herr_t H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt); -H5_DLL herr_t H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt); -H5_DLL herr_t H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent); -H5_DLL herr_t H5EA_iterate(H5EA_t *fa, H5EA_operator_t op, void *udata); -H5_DLL herr_t H5EA_close(H5EA_t *ea); -H5_DLL herr_t H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata); -H5_DLL herr_t H5EA_patch_file(H5EA_t *fa, H5F_t *f); +H5_DLL herr_t H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts); +H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr); +H5_DLL herr_t H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt); +H5_DLL herr_t H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt); +H5_DLL herr_t H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent); +H5_DLL herr_t H5EA_iterate(H5EA_t *fa, H5EA_operator_t op, void *udata); +H5_DLL herr_t H5EA_close(H5EA_t *ea); +H5_DLL herr_t H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata); +H5_DLL herr_t H5EA_patch_file(H5EA_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats); @@ -154,4 +156,3 @@ H5_DLL herr_t H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats); #endif /* H5EA_DEBUGGING */ #endif /* _H5EAprivate_H */ - diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index fb7c458..304947b 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -26,55 +26,46 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -88,8 +79,6 @@ H5FL_SEQ_DEFINE_STATIC(haddr_t); /* Declare a free list to manage blocks of 'page init' bitmasks */ H5FL_BLK_DEFINE(page_init); - - /*------------------------------------------------------------------------- * Function: H5EA__sblock_alloc * @@ -102,41 +91,40 @@ H5FL_BLK_DEFINE(page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_sblock_t *, NULL, NULL, -H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) +BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, + H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ /* Check arguments */ HDassert(hdr); /* Allocate memory for the index block */ - if(NULL == (sblock = H5FL_CALLOC(H5EA_sblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + if (NULL == (sblock = H5FL_CALLOC(H5EA_sblock_t))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") /* Share common array information */ - if(H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + if (H5EA__hdr_incr(hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") sblock->hdr = hdr; /* Set non-zero internal fields */ sblock->parent = parent; - sblock->addr = HADDR_UNDEF; + sblock->addr = HADDR_UNDEF; /* Compute/cache information */ - sblock->idx = sblk_idx; + sblock->idx = sblk_idx; sblock->ndblks = hdr->sblk_info[sblk_idx].ndblks; HDassert(sblock->ndblks); sblock->dblk_nelmts = hdr->sblk_info[sblk_idx].dblk_nelmts; /* Allocate buffer for data block addresses in super block */ - if(NULL == (sblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, sblock->ndblks))) + if (NULL == (sblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, sblock->ndblks))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block data block addresses") /* Check if # of elements in data blocks requires paging */ - if(sblock->dblk_nelmts > hdr->dblk_page_nelmts) { + if (sblock->dblk_nelmts > hdr->dblk_page_nelmts) { /* Compute # of pages in each data block from this super block */ sblock->dblk_npages = sblock->dblk_nelmts / hdr->dblk_page_nelmts; @@ -151,25 +139,24 @@ H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) HDassert(sblock->dblk_page_init_size > 0); /* Allocate buffer for all 'page init' bitmasks in super block */ - if(NULL == (sblock->page_init = H5FL_BLK_CALLOC(page_init, sblock->ndblks * sblock->dblk_page_init_size))) + if (NULL == + (sblock->page_init = H5FL_BLK_CALLOC(page_init, sblock->ndblks * sblock->dblk_page_init_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block page init bitmask") /* Compute data block page size */ - sblock->dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) - + H5EA_SIZEOF_CHKSUM; + sblock->dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5EA_SIZEOF_CHKSUM; } /* end if */ /* Set the return value */ ret_value = sblock; -CATCH - if(!ret_value) - if(sblock && H5EA__sblock_dest(sblock) < 0) + CATCH + if (!ret_value) + if (sblock && H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_alloc() */ +END_FUNC(PKG) /* end H5EA__sblock_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_create * @@ -182,24 +169,23 @@ END_FUNC(PKG) /* end H5EA__sblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, - unsigned sblk_idx)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, + unsigned sblk_idx)) /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ - haddr_t sblock_addr; /* Extensible array super block address */ - haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + haddr_t sblock_addr; /* Extensible array super block address */ + haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* Sanity check */ HDassert(hdr); HDassert(stats_changed); /* Allocate the super block */ - if(NULL == (sblock = H5EA__sblock_alloc(hdr, parent, sblk_idx))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + if (NULL == (sblock = H5EA__sblock_alloc(hdr, parent, sblk_idx))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") /* Set size of super block on disk */ sblock->size = H5EA_SBLOCK_SIZE(sblock); @@ -208,21 +194,21 @@ H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_chang sblock->block_off = hdr->sblk_info[sblk_idx].start_idx; /* Allocate space for the super block on disk */ - if(HADDR_UNDEF == (sblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_SBLOCK, (hsize_t)sblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array super block") + if (HADDR_UNDEF == (sblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_SBLOCK, (hsize_t)sblock->size))) + H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array super block") sblock->addr = sblock_addr; /* Reset data block addresses to "undefined" address value */ H5VM_array_fill(sblock->dblk_addrs, &tmp_addr, sizeof(haddr_t), sblock->ndblks); /* Cache the new extensible array super block */ - if(H5AC_insert_entry(hdr->f, H5AC_EARRAY_SBLOCK, sblock_addr, sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array super block to cache") + if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_SBLOCK, sblock_addr, sblock, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTINSERT, "can't add extensible array super block to cache") inserted = TRUE; /* Add super block as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") sblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -237,26 +223,26 @@ H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_chang /* Set address of super block to return */ ret_value = sblock_addr; -CATCH - if(!H5F_addr_defined(ret_value)) - if(sblock) { + CATCH + if (!H5F_addr_defined(ret_value)) + if (sblock) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(sblock) < 0) + if (inserted) + if (H5AC_remove_entry(sblock) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array super block from cache") /* Release super block's disk space */ - if(H5F_addr_defined(sblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_SBLOCK, sblock->addr, (hsize_t)sblock->size) < 0) + if (H5F_addr_defined(sblock->addr) && + H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_SBLOCK, sblock->addr, (hsize_t)sblock->size) < 0) H5E_THROW(H5E_CANTFREE, "unable to release extensible array super block") /* Destroy super block */ - if(H5EA__sblock_dest(sblock) < 0) + if (H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") } /* end if */ -END_FUNC(PKG) /* end H5EA__sblock_create() */ +END_FUNC(PKG) /* end H5EA__sblock_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_protect * @@ -269,14 +255,13 @@ END_FUNC(PKG) /* end H5EA__sblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_sblock_t *, NULL, NULL, -H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - haddr_t sblk_addr, unsigned sblk_idx, unsigned flags)) +BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, + H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx, + unsigned flags)) /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ - H5EA_sblock_cache_ud_t udata; /* Information needed for loading super block */ + H5EA_sblock_t * sblock = NULL; /* Pointer to super block */ + H5EA_sblock_cache_ud_t udata; /* Information needed for loading super block */ /* Sanity check */ HDassert(hdr); @@ -286,19 +271,21 @@ H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; - udata.parent = parent; - udata.sblk_idx = sblk_idx; + udata.hdr = hdr; + udata.parent = parent; + udata.sblk_idx = sblk_idx; udata.sblk_addr = sblk_addr; /* Protect the super block */ - if(NULL == (sblock = (H5EA_sblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_SBLOCK, sblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)sblk_addr) + if (NULL == + (sblock = (H5EA_sblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_SBLOCK, sblk_addr, &udata, flags))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", + (unsigned long long)sblk_addr) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == sblock->top_proxy) { + if (hdr->top_proxy && NULL == sblock->top_proxy) { /* Add super block as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") sblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -306,17 +293,18 @@ H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, /* Set return value */ ret_value = sblock; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the super block, if it was protected */ - if(sblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", (unsigned long long)sblock->addr) + if (sblock && + H5AC_unprotect(hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", + (unsigned long long)sblock->addr) } /* end if */ -END_FUNC(PKG) /* end H5EA__sblock_protect() */ +END_FUNC(PKG) /* end H5EA__sblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_unprotect * @@ -329,9 +317,8 @@ END_FUNC(PKG) /* end H5EA__sblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags)) /* Local variables */ @@ -339,14 +326,14 @@ H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags)) HDassert(sblock); /* Unprotect the super block */ - if(H5AC_unprotect(sblock->hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", (unsigned long long)sblock->addr) + if (H5AC_unprotect(sblock->hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, cache_flags) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", + (unsigned long long)sblock->addr) -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ +END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_delete * @@ -359,42 +346,41 @@ END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - haddr_t sblk_addr, unsigned sblk_idx)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx)) /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ - size_t u; /* Local index variable */ + H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ + size_t u; /* Local index variable */ /* Sanity check */ HDassert(hdr); HDassert(H5F_addr_defined(sblk_addr)); /* Protect super block */ - if(NULL == (sblock = H5EA__sblock_protect(hdr, parent, sblk_addr, sblk_idx, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)sblk_addr) + if (NULL == (sblock = H5EA__sblock_protect(hdr, parent, sblk_addr, sblk_idx, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", + (unsigned long long)sblk_addr) /* Iterate over data blocks */ - for(u = 0; u < sblock->ndblks; u++) { + for (u = 0; u < sblock->ndblks; u++) { /* Check for data block existing */ - if(H5F_addr_defined(sblock->dblk_addrs[u])) { + if (H5F_addr_defined(sblock->dblk_addrs[u])) { /* Delete data block */ - if(H5EA__dblock_delete(hdr, sblock, sblock->dblk_addrs[u], sblock->dblk_nelmts) < 0) + if (H5EA__dblock_delete(hdr, sblock, sblock->dblk_addrs[u], sblock->dblk_nelmts) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") sblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ - } /* end for */ + } /* end for */ -CATCH + CATCH /* Finished deleting super block in metadata cache */ - if(sblock && H5EA__sblock_unprotect(sblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (sblock && H5EA__sblock_unprotect(sblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | + H5AC__FREE_FILE_SPACE_FLAG) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_delete() */ +END_FUNC(PKG) /* end H5EA__sblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_dest * @@ -407,28 +393,26 @@ END_FUNC(PKG) /* end H5EA__sblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__sblock_dest(H5EA_sblock_t *sblock)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sblock)) /* Sanity check */ HDassert(sblock); HDassert(!sblock->has_hdr_depend); /* Check if shared header field has been initialized */ - if(sblock->hdr) { + if (sblock->hdr) { /* Free buffer for super block data block addresses, if there are any */ - if(sblock->dblk_addrs) + if (sblock->dblk_addrs) sblock->dblk_addrs = H5FL_SEQ_FREE(haddr_t, sblock->dblk_addrs); /* Free buffer for super block 'page init' bitmask, if there is one */ - if(sblock->page_init) { + if (sblock->page_init) { HDassert(sblock->dblk_npages > 0); sblock->page_init = H5FL_BLK_FREE(page_init, sblock->page_init); } /* end if */ /* Decrement reference count on shared info */ - if(H5EA__hdr_decr(sblock->hdr) < 0) + if (H5EA__hdr_decr(sblock->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") sblock->hdr = NULL; } /* end if */ @@ -439,7 +423,6 @@ H5EA__sblock_dest(H5EA_sblock_t *sblock)) /* Free the super block itself */ sblock = H5FL_FREE(H5EA_sblock_t, sblock); -CATCH - -END_FUNC(PKG) /* end H5EA__sblock_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__sblock_dest() */ diff --git a/src/H5EAstat.c b/src/H5EAstat.c index 509d3f8..fd70b99 100644 --- a/src/H5EAstat.c +++ b/src/H5EAstat.c @@ -26,59 +26,48 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5EA_get_stats * @@ -92,14 +81,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats)) - /* Local variables */ +/* Local variables */ #ifdef QAK -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* QAK */ /* @@ -111,5 +98,4 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Copy extensible array statistics */ H5MM_memcpy(stats, &ea->hdr->stats, sizeof(ea->hdr->stats)); -END_FUNC(PRIV) /* end H5EA_get_stats() */ - +END_FUNC(PRIV) /* end H5EA_get_stats() */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index 8926d6a..9e60374 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -22,32 +22,28 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ #define H5EA_TESTING - /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Sanity checking value for callback contexts */ -#define H5EA__TEST_BOGUS_VAL 42 - +#define H5EA__TEST_BOGUS_VAL 42 /******************/ /* Local Typedefs */ @@ -55,28 +51,26 @@ /* Callback context */ typedef struct H5EA__test_ctx_t { - uint32_t bogus; /* Placeholder field to verify that context is working */ - H5EA__ctx_cb_t *cb; /* Pointer to context's callback action */ + uint32_t bogus; /* Placeholder field to verify that context is working */ + H5EA__ctx_cb_t *cb; /* Pointer to context's callback action */ } H5EA__test_ctx_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Extensible array class callbacks */ -static void *H5EA__test_crt_context(void *udata); +static void * H5EA__test_crt_context(void *udata); static herr_t H5EA__test_dst_context(void *ctx); static herr_t H5EA__test_fill(void *nat_blk, size_t nelmts); static herr_t H5EA__test_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); static herr_t H5EA__test_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); static herr_t H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); -static void *H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr); +static void * H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr); static herr_t H5EA__test_dst_dbg_context(void *_ctx); /*********************/ @@ -84,7 +78,7 @@ static herr_t H5EA__test_dst_dbg_context(void *_ctx); /*********************/ /* Extensible array testing class information */ -const H5EA_class_t H5EA_CLS_TEST[1]={{ +const H5EA_class_t H5EA_CLS_TEST[1] = {{ H5EA_CLS_TEST_ID, /* Type of Extensible array */ "Testing", /* Name of Extensible Array class */ sizeof(uint64_t), /* Size of native element */ @@ -98,12 +92,10 @@ const H5EA_class_t H5EA_CLS_TEST[1]={{ H5EA__test_dst_dbg_context /* Destroy debugging context */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -114,8 +106,6 @@ H5FL_DEFINE_STATIC(H5EA__test_ctx_t); /* Declare a free list to manage the H5EA__ctx_cb_t struct */ H5FL_DEFINE_STATIC(H5EA__ctx_cb_t); - - /*------------------------------------------------------------------------- * Function: H5EA__test_crt_context * @@ -129,32 +119,29 @@ H5FL_DEFINE_STATIC(H5EA__ctx_cb_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5EA__test_crt_context(void *_udata)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5EA__test_crt_context(void *_udata)) /* Local variables */ - H5EA__test_ctx_t *ctx; /* Context for callbacks */ - H5EA__ctx_cb_t *udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ + H5EA__test_ctx_t *ctx; /* Context for callbacks */ + H5EA__ctx_cb_t * udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ /* Sanity checks */ /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5EA__test_ctx_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") + if (NULL == (ctx = H5FL_MALLOC(H5EA__test_ctx_t))) + H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") /* Initialize the context */ ctx->bogus = H5EA__TEST_BOGUS_VAL; - ctx->cb = udata; + ctx->cb = udata; /* Set return value */ ret_value = ctx; -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__test_crt_context() */ +END_FUNC(STATIC) /* end H5EA__test_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_dst_context * @@ -168,12 +155,10 @@ END_FUNC(STATIC) /* end H5EA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__test_dst_context(void *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_context(void *_ctx)) /* Local variables */ - H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ /* Sanity checks */ HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); @@ -181,9 +166,8 @@ H5EA__test_dst_context(void *_ctx)) /* Release context structure */ ctx = H5FL_FREE(H5EA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_context() */ +END_FUNC(STATIC) /* end H5EA__test_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_fill * @@ -197,12 +181,10 @@ END_FUNC(STATIC) /* end H5EA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__test_fill(void *nat_blk, size_t nelmts)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_fill(void *nat_blk, size_t nelmts)) /* Local variables */ - uint64_t fill_val = H5EA_TEST_FILL; /* Value to fill elements with */ + uint64_t fill_val = H5EA_TEST_FILL; /* Value to fill elements with */ /* Sanity checks */ HDassert(nat_blk); @@ -210,9 +192,8 @@ H5EA__test_fill(void *nat_blk, size_t nelmts)) H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5EA__test_fill() */ +END_FUNC(STATIC) /* end H5EA__test_fill() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_encode * @@ -226,13 +207,12 @@ END_FUNC(STATIC) /* end H5EA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) /* Local variables */ - H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ - const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + const uint64_t * elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ /* Sanity checks */ HDassert(raw); @@ -241,13 +221,13 @@ H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); /* Check for callback action */ - if(ctx->cb) { - if((*ctx->cb->encode)(elmt, nelmts, ctx->cb->udata) < 0) + if (ctx->cb) { + if ((*ctx->cb->encode)(elmt, nelmts, ctx->cb->udata) < 0) H5E_THROW(H5E_BADVALUE, "extensible array testing callback action failed") } /* end if */ /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ UINT64ENCODE(raw, *elmt); @@ -259,11 +239,10 @@ H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) nelmts--; } /* end while */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__test_encode() */ +END_FUNC(STATIC) /* end H5EA__test_encode() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_decode * @@ -277,16 +256,15 @@ END_FUNC(STATIC) /* end H5EA__test_encode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx)) - /* Local variables */ +/* Local variables */ #ifndef NDEBUG - H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - uint64_t *elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ +#endif /* NDEBUG */ + uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ /* Sanity checks */ HDassert(raw); @@ -295,7 +273,7 @@ H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDE HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ UINT64DECODE(raw, *elmt); @@ -307,9 +285,8 @@ H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDE nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5EA__test_decode() */ +END_FUNC(STATIC) /* end H5EA__test_decode() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_debug * @@ -323,13 +300,11 @@ END_FUNC(STATIC) /* end H5EA__test_decode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, - const void *elmt)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) /* Local variables */ - char temp_str[128]; /* Temporary string, for formatting */ + char temp_str[128]; /* Temporary string, for formatting */ /* Sanity checks */ HDassert(stream); @@ -338,9 +313,9 @@ H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /* Print element */ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, - (unsigned long long)*(const uint64_t *)elmt); + (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5EA__test_debug() */ +END_FUNC(STATIC) /* end H5EA__test_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__test_crt_dbg_context @@ -354,25 +329,23 @@ END_FUNC(STATIC) /* end H5EA__test_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) /* Local variables */ - H5EA__ctx_cb_t *ctx; /* Context for callbacks */ + H5EA__ctx_cb_t *ctx; /* Context for callbacks */ /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5EA__ctx_cb_t))) + if (NULL == (ctx = H5FL_MALLOC(H5EA__ctx_cb_t))) H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") /* Set return value */ ret_value = ctx; -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ +END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_dst_dbg_context * @@ -385,21 +358,18 @@ END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__test_dst_dbg_context(void *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_dbg_context(void *_ctx)) /* Local variables */ - H5EA__ctx_cb_t *ctx = (H5EA__ctx_cb_t *)_ctx; /* Callback context to destroy */ + H5EA__ctx_cb_t *ctx = (H5EA__ctx_cb_t *)_ctx; /* Callback context to destroy */ HDassert(_ctx); /* Release context structure */ ctx = H5FL_FREE(H5EA__ctx_cb_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ +END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5EA__get_cparam_test * @@ -413,25 +383,22 @@ END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam)) /* Check arguments. */ HDassert(ea); HDassert(cparam); /* Get extensible array creation parameters */ - cparam->raw_elmt_size = ea->hdr->cparam.raw_elmt_size; - cparam->max_nelmts_bits = ea->hdr->cparam.max_nelmts_bits; - cparam->idx_blk_elmts = ea->hdr->cparam.idx_blk_elmts; - cparam->sup_blk_min_data_ptrs = ea->hdr->cparam.sup_blk_min_data_ptrs; - cparam->data_blk_min_elmts = ea->hdr->cparam.data_blk_min_elmts; + cparam->raw_elmt_size = ea->hdr->cparam.raw_elmt_size; + cparam->max_nelmts_bits = ea->hdr->cparam.max_nelmts_bits; + cparam->idx_blk_elmts = ea->hdr->cparam.idx_blk_elmts; + cparam->sup_blk_min_data_ptrs = ea->hdr->cparam.sup_blk_min_data_ptrs; + cparam->data_blk_min_elmts = ea->hdr->cparam.data_blk_min_elmts; cparam->max_dblk_page_nelmts_bits = ea->hdr->cparam.max_dblk_page_nelmts_bits; -END_FUNC(PKG) /* end H5EA__get_cparam_test() */ +END_FUNC(PKG) /* end H5EA__get_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5EA__cmp_cparam_test * @@ -445,41 +412,39 @@ END_FUNC(PKG) /* end H5EA__get_cparam_test() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, -int, 0, -, -H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2)) +BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, + H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2)) /* Check arguments. */ HDassert(cparam1); HDassert(cparam2); /* Compare creation parameters for array */ - if(cparam1->raw_elmt_size < cparam2->raw_elmt_size) + if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) H5_LEAVE(-1) - else if(cparam1->raw_elmt_size > cparam2->raw_elmt_size) + else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) H5_LEAVE(1) - if(cparam1->max_nelmts_bits < cparam2->max_nelmts_bits) + if (cparam1->max_nelmts_bits < cparam2->max_nelmts_bits) H5_LEAVE(-1) - else if(cparam1->max_nelmts_bits > cparam2->max_nelmts_bits) + else if (cparam1->max_nelmts_bits > cparam2->max_nelmts_bits) H5_LEAVE(1) - if(cparam1->idx_blk_elmts < cparam2->idx_blk_elmts) + if (cparam1->idx_blk_elmts < cparam2->idx_blk_elmts) H5_LEAVE(-1) - else if(cparam1->idx_blk_elmts > cparam2->idx_blk_elmts) + else if (cparam1->idx_blk_elmts > cparam2->idx_blk_elmts) H5_LEAVE(1) - if(cparam1->sup_blk_min_data_ptrs < cparam2->sup_blk_min_data_ptrs) + if (cparam1->sup_blk_min_data_ptrs < cparam2->sup_blk_min_data_ptrs) H5_LEAVE(-1) - else if(cparam1->sup_blk_min_data_ptrs > cparam2->sup_blk_min_data_ptrs) + else if (cparam1->sup_blk_min_data_ptrs > cparam2->sup_blk_min_data_ptrs) H5_LEAVE(1) - if(cparam1->data_blk_min_elmts < cparam2->data_blk_min_elmts) + if (cparam1->data_blk_min_elmts < cparam2->data_blk_min_elmts) H5_LEAVE(-1) - else if(cparam1->data_blk_min_elmts > cparam2->data_blk_min_elmts) + else if (cparam1->data_blk_min_elmts > cparam2->data_blk_min_elmts) H5_LEAVE(1) - if(cparam1->max_dblk_page_nelmts_bits < cparam2->max_dblk_page_nelmts_bits) + if (cparam1->max_dblk_page_nelmts_bits < cparam2->max_dblk_page_nelmts_bits) H5_LEAVE(-1) - else if(cparam1->max_dblk_page_nelmts_bits > cparam2->max_dblk_page_nelmts_bits) + else if (cparam1->max_dblk_page_nelmts_bits > cparam2->max_dblk_page_nelmts_bits) H5_LEAVE(1) -CATCH - -END_FUNC(PKG) /* end H5EA__cmp_cparam_test() */ + CATCH +END_FUNC(PKG) /* end H5EA__cmp_cparam_test() */ diff --git a/src/H5ESpublic.h b/src/H5ESpublic.h index e3b1b56..63f2379 100644 --- a/src/H5ESpublic.h +++ b/src/H5ESpublic.h @@ -14,7 +14,7 @@ #define _H5ESpublic_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ +#include "H5public.h" /* Generic Functions */ /*****************/ /* Public Macros */ @@ -26,13 +26,12 @@ /* Asynchronous operation status */ typedef enum H5ES_status_t { - H5ES_STATUS_IN_PROGRESS, /* Operation has not yet completed */ - H5ES_STATUS_SUCCEED, /* Operation has completed, successfully */ - H5ES_STATUS_FAIL, /* Operation has completed, but failed */ - H5ES_STATUS_CANCELED /* Operation has not completed and was canceled */ + H5ES_STATUS_IN_PROGRESS, /* Operation has not yet completed */ + H5ES_STATUS_SUCCEED, /* Operation has completed, successfully */ + H5ES_STATUS_FAIL, /* Operation has completed, but failed */ + H5ES_STATUS_CANCELED /* Operation has not completed and was canceled */ } H5ES_status_t; - /********************/ /* Public Variables */ /********************/ @@ -50,4 +49,3 @@ extern "C" { #endif #endif /* _H5ESpublic_H */ - diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index 4462303..6a2357c 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -29,56 +29,47 @@ /* Module Setup */ /****************/ -#include "H5Emodule.h" /* This source code file is part of the H5E module */ - +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Epkg.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Epkg.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Eget_major * @@ -95,23 +86,23 @@ char * H5Eget_major(H5E_major_t maj) { - H5E_msg_t *msg; /* Pointer to error message */ - ssize_t size; - H5E_type_t type; - char *msg_str = NULL; - char *ret_value; /* Return value */ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size; + H5E_type_t type; + char * msg_str = NULL; + char * ret_value; /* Return value */ FUNC_ENTER_API_NOCLEAR(NULL) H5TRACE1("*s", "i", maj); /* Get the message object */ - if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(maj, H5I_ERROR_MSG))) + if (NULL == (msg = (H5E_msg_t *)H5I_object_verify(maj, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") /* Get the size & type of the message's text */ - if((size = H5E__get_msg(msg, &type, NULL, (size_t)0)) < 0) + if ((size = H5E__get_msg(msg, &type, NULL, (size_t)0)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") - if(type != H5E_MAJOR) + if (type != H5E_MAJOR) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a major one") /* Application will free this */ @@ -119,19 +110,18 @@ H5Eget_major(H5E_major_t maj) msg_str = (char *)H5MM_malloc((size_t)size); /* Get the text for the message */ - if(H5E__get_msg(msg, NULL, msg_str, (size_t)size) < 0) + if (H5E__get_msg(msg, NULL, msg_str, (size_t)size) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") ret_value = msg_str; done: - if(!ret_value) + if (!ret_value) msg_str = (char *)H5MM_xfree(msg_str); FUNC_LEAVE_API(ret_value) } /* end H5Eget_major() */ - /*------------------------------------------------------------------------- * Function: H5Eget_minor * @@ -148,23 +138,23 @@ done: char * H5Eget_minor(H5E_minor_t min) { - H5E_msg_t *msg; /* Pointer to error message */ - ssize_t size; - H5E_type_t type; - char *msg_str = NULL; - char *ret_value; /* Return value */ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size; + H5E_type_t type; + char * msg_str = NULL; + char * ret_value; /* Return value */ FUNC_ENTER_API_NOCLEAR(NULL) H5TRACE1("*s", "i", min); /* Get the message object */ - if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(min, H5I_ERROR_MSG))) + if (NULL == (msg = (H5E_msg_t *)H5I_object_verify(min, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") /* Get the size & type of the message's text */ - if((size = H5E__get_msg(msg, &type, NULL, (size_t)0)) < 0) + if ((size = H5E__get_msg(msg, &type, NULL, (size_t)0)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") - if(type != H5E_MINOR) + if (type != H5E_MINOR) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a minor one") /* Application will free this */ @@ -172,19 +162,18 @@ H5Eget_minor(H5E_minor_t min) msg_str = (char *)H5MM_malloc((size_t)size); /* Get the text for the message */ - if(H5E__get_msg(msg, NULL, msg_str, (size_t)size) < 0) + if (H5E__get_msg(msg, NULL, msg_str, (size_t)size) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") ret_value = msg_str; done: - if(!ret_value) + if (!ret_value) msg_str = (char *)H5MM_xfree(msg_str); FUNC_LEAVE_API(ret_value) } /* end H5Eget_minor() */ - /*------------------------------------------------------------------------- * Function: H5Epush1 * @@ -206,24 +195,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Epush1(const char *file, const char *func, unsigned line, - H5E_major_t maj, H5E_minor_t min, const char *str) +H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, const char *str) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE6("e", "*s*sIuii*s", file, func, line, maj, min, str); /* Push the error on the default error stack */ - if(H5E__push_stack(NULL, file, func, line, H5E_ERR_CLS_g, maj, min, str) < 0) + if (H5E__push_stack(NULL, file, func, line, H5E_ERR_CLS_g, maj, min, str) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Epush1() */ - /*------------------------------------------------------------------------- * Function: H5Eclear1 * @@ -247,14 +234,13 @@ H5Eclear1(void) H5TRACE0("e",""); /* Clear the default error stack */ - if(H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack(NULL) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eclear1() */ - /*------------------------------------------------------------------------- * Function: H5Eprint1 * @@ -274,25 +260,25 @@ done: herr_t H5Eprint1(FILE *stream) { - H5E_t *estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) /*NO TRACE*/ - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Print error stack */ - if(H5E__print(estack, stream, TRUE) < 0) + if (H5E__print(estack, stream, TRUE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eprint1() */ - /*------------------------------------------------------------------------- * Function: H5Ewalk1 * @@ -310,28 +296,28 @@ done: herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ - H5E_walk_op_t walk_op; /* Error stack walking callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_walk_op_t walk_op; /* Error stack walking callback */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) /*NO TRACE*/ - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Walk the error stack */ - walk_op.vers = 1; + walk_op.vers = 1; walk_op.u.func1 = func; - if(H5E__walk(estack, direction, &walk_op, client_data) < 0) + if (H5E__walk(estack, direction, &walk_op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Ewalk1() */ - /*------------------------------------------------------------------------- * Function: H5Eget_auto1 * @@ -351,33 +337,33 @@ done: herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data) { - H5E_t *estack; /* Error stack to operate on */ - H5E_auto_op_t auto_op; /* Error stack operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_auto_op_t auto_op; /* Error stack operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "*x**x", func, client_data); /* Retrieve default error stack */ - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Get the automatic error reporting information */ - if(H5E__get_auto(estack, &auto_op, client_data) < 0) + if (H5E__get_auto(estack, &auto_op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto2 */ - if(!auto_op.is_default && auto_op.vers == 2) + if (!auto_op.is_default && auto_op.vers == 2) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto2 has been called") - if(func) + if (func) *func = auto_op.func1; done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_auto1() */ - /*------------------------------------------------------------------------- * Function: H5Eset_auto1 * @@ -404,34 +390,34 @@ done: herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ - H5E_auto_op_t auto_op; /* Error stack operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_auto_op_t auto_op; /* Error stack operator */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE2("e", "x*x", func, client_data); - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Get the automatic error reporting information */ - if(H5E__get_auto(estack, &auto_op, NULL) < 0) + if (H5E__get_auto(estack, &auto_op, NULL) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") /* Set the automatic error reporting information */ auto_op.vers = 1; - if(func != auto_op.func1_default) + if (func != auto_op.func1_default) auto_op.is_default = FALSE; else auto_op.is_default = TRUE; auto_op.func1 = func; - if(H5E__set_auto(estack, &auto_op, client_data) < 0) + if (H5E__set_auto(estack, &auto_op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") done: FUNC_LEAVE_API(ret_value) } /* end H5Eset_auto1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Eint.c b/src/H5Eint.c index 2371a5f..0be05f7 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -26,52 +26,44 @@ /* Module Setup */ /****************/ -#include "H5Emodule.h" /* This source code file is part of the H5E module */ - +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Epkg.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5TSprivate.h" /* Thread stuff */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Epkg.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5TSprivate.h" /* Thread stuff */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Printing information */ typedef struct H5E_print_t { - FILE *stream; - H5E_cls_t cls; + FILE * stream; + H5E_cls_t cls; } H5E_print_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ #ifndef H5_NO_DEPRECATED_SYMBOLS -static herr_t H5E__walk1_cb(int n, H5E_error1_t *err_desc, - void *client_data); +static herr_t H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ -static herr_t H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, - void *client_data); +static herr_t H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data); static herr_t H5E__clear_entries(H5E_t *estack, size_t nentries); - /*********************/ /* Package Variables */ /*********************/ @@ -83,7 +75,6 @@ static herr_t H5E__clear_entries(H5E_t *estack, size_t nentries); H5E_t H5E_stack_g[1]; #endif /* H5_HAVE_THREADSAFE */ - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -98,7 +89,6 @@ hid_t H5E_ERR_CLS_g = FAIL; /* Include the automatically generated error code definitions */ #include "H5Edefin.h" - /*******************/ /* Local Variables */ /*******************/ @@ -107,12 +97,10 @@ hid_t H5E_ERR_CLS_g = FAIL; /* * variables used for MPI error reporting */ -char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; -int H5E_mpi_error_str_len; +char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; +int H5E_mpi_error_str_len; #endif /* H5_HAVE_PARALLEL */ - - /*------------------------------------------------------------------------- * Function: H5E__get_msg * @@ -129,7 +117,7 @@ int H5E_mpi_error_str_len; ssize_t H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) { - ssize_t len = -1; /* Length of error message */ + ssize_t len = -1; /* Length of error message */ FUNC_ENTER_PACKAGE_NOERR @@ -140,14 +128,14 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) len = (ssize_t)HDstrlen(msg->msg); /* Copy the message into the user's buffer, if given */ - if(msg_str) { - HDstrncpy(msg_str, msg->msg, MIN((size_t)(len+1), size)); - if((size_t)len >= size) - msg_str[size - 1] = '\0'; + if (msg_str) { + HDstrncpy(msg_str, msg->msg, MIN((size_t)(len + 1), size)); + if ((size_t)len >= size) + msg_str[size - 1] = '\0'; } /* end if */ /* Give the message type, if asked */ - if(type) + if (type) *type = msg->type; /* Set the return value to the full length of the message */ @@ -155,7 +143,7 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) } /* end H5E__get_msg() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5E__walk1_cb * @@ -192,15 +180,15 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) static herr_t H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) { - H5E_print_t *eprint = (H5E_print_t *)client_data; - FILE *stream; /* I/O stream to print output to */ - H5E_cls_t *cls_ptr; /* Pointer to error class */ - H5E_msg_t *maj_ptr; /* Pointer to major error info */ - H5E_msg_t *min_ptr; /* Pointer to minor error info */ - const char *maj_str = "No major description"; /* Major error description */ - const char *min_str = "No minor description"; /* Minor error description */ - unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ - herr_t ret_value = SUCCEED; + H5E_print_t *eprint = (H5E_print_t *)client_data; + FILE * stream; /* I/O stream to print output to */ + H5E_cls_t * cls_ptr; /* Pointer to error class */ + H5E_msg_t * maj_ptr; /* Pointer to major error info */ + H5E_msg_t * min_ptr; /* Pointer to minor error info */ + const char * maj_str = "No major description"; /* Major error description */ + const char * min_str = "No minor description"; /* Minor error description */ + unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_NOERR @@ -208,7 +196,7 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) HDassert(err_desc); /* If no client data was passed, output to stderr */ - if(!client_data) + if (!client_data) stream = stderr; else stream = eprint->stream; @@ -218,31 +206,31 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) min_ptr = (H5E_msg_t *)H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); /* Check for bad pointer(s), but can't issue error, just leave */ - if(!maj_ptr || !min_ptr) + if (!maj_ptr || !min_ptr) HGOTO_DONE(FAIL) - if(maj_ptr->msg) + if (maj_ptr->msg) maj_str = maj_ptr->msg; - if(min_ptr->msg) + if (min_ptr->msg) min_str = min_ptr->msg; /* Get error class info */ cls_ptr = maj_ptr->cls; /* Print error class header if new class */ - if(eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { + if (eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { /* update to the new class information */ - if(cls_ptr->cls_name) + if (cls_ptr->cls_name) eprint->cls.cls_name = cls_ptr->cls_name; - if(cls_ptr->lib_name) + if (cls_ptr->lib_name) eprint->cls.lib_name = cls_ptr->lib_name; - if(cls_ptr->lib_vers) + if (cls_ptr->lib_vers) eprint->cls.lib_vers = cls_ptr->lib_vers; HDfprintf(stream, "%s-DIAG: Error detected in %s (%s) ", - (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), - (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), - (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); + (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), + (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), + (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL @@ -252,7 +240,7 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) MPI_Initialized(&mpi_initialized); MPI_Finalized(&mpi_finalized); - if(mpi_initialized && !mpi_finalized) { + if (mpi_initialized && !mpi_finalized) { MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); HDfprintf(stream, "MPI-process %d", mpi_rank); } /* end if */ @@ -266,14 +254,13 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) } /* end if */ /* Check for "real" error description - used to format output more nicely */ - if(err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) - have_desc=0; + if (err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) + have_desc = 0; /* Print error message */ - HDfprintf(stream, "%*s#%03d: %s line %u in %s()%s%s\n", - H5E_INDENT, "", n, err_desc->file_name, err_desc->line, - err_desc->func_name, (have_desc ? ": " : ""), - (have_desc ? err_desc->desc : "")); + HDfprintf(stream, "%*s#%03d: %s line %u in %s()%s%s\n", H5E_INDENT, "", n, err_desc->file_name, + err_desc->line, err_desc->func_name, (have_desc ? ": " : ""), + (have_desc ? err_desc->desc : "")); HDfprintf(stream, "%*smajor: %s\n", (H5E_INDENT * 2), "", maj_str); HDfprintf(stream, "%*sminor: %s\n", (H5E_INDENT * 2), "", min_str); @@ -282,7 +269,6 @@ done: } /* end H5E__walk1_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: H5E__walk2_cb * @@ -317,15 +303,15 @@ done: static herr_t H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) { - H5E_print_t *eprint = (H5E_print_t *)client_data; - FILE *stream; /* I/O stream to print output to */ - H5E_cls_t *cls_ptr; /* Pointer to error class */ - H5E_msg_t *maj_ptr; /* Pointer to major error info */ - H5E_msg_t *min_ptr; /* Pointer to minor error info */ - const char *maj_str = "No major description"; /* Major error description */ - const char *min_str = "No minor description"; /* Minor error description */ - unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ - herr_t ret_value = SUCCEED; + H5E_print_t *eprint = (H5E_print_t *)client_data; + FILE * stream; /* I/O stream to print output to */ + H5E_cls_t * cls_ptr; /* Pointer to error class */ + H5E_msg_t * maj_ptr; /* Pointer to major error info */ + H5E_msg_t * min_ptr; /* Pointer to minor error info */ + const char * maj_str = "No major description"; /* Major error description */ + const char * min_str = "No minor description"; /* Minor error description */ + unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_NOERR @@ -333,7 +319,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) HDassert(err_desc); /* If no client data was passed, output to stderr */ - if(!client_data) + if (!client_data) stream = stderr; else stream = eprint->stream; @@ -343,12 +329,12 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) min_ptr = (H5E_msg_t *)H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); /* Check for bad pointer(s), but can't issue error, just leave */ - if(!maj_ptr || !min_ptr) + if (!maj_ptr || !min_ptr) HGOTO_DONE(FAIL) - if(maj_ptr->msg) + if (maj_ptr->msg) maj_str = maj_ptr->msg; - if(min_ptr->msg) + if (min_ptr->msg) min_str = min_ptr->msg; /* Get error class info. Don't use the class of the major or minor error because @@ -356,23 +342,23 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) cls_ptr = (H5E_cls_t *)H5I_object_verify(err_desc->cls_id, H5I_ERROR_CLASS); /* Check for bad pointer(s), but can't issue error, just leave */ - if(!cls_ptr) + if (!cls_ptr) HGOTO_DONE(FAIL) /* Print error class header if new class */ - if(eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { + if (eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { /* update to the new class information */ - if(cls_ptr->cls_name) + if (cls_ptr->cls_name) eprint->cls.cls_name = cls_ptr->cls_name; - if(cls_ptr->lib_name) + if (cls_ptr->lib_name) eprint->cls.lib_name = cls_ptr->lib_name; - if(cls_ptr->lib_vers) + if (cls_ptr->lib_vers) eprint->cls.lib_vers = cls_ptr->lib_vers; HDfprintf(stream, "%s-DIAG: Error detected in %s (%s) ", - (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), - (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), - (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); + (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), + (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), + (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL @@ -382,7 +368,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) MPI_Initialized(&mpi_initialized); MPI_Finalized(&mpi_finalized); - if(mpi_initialized && !mpi_finalized) { + if (mpi_initialized && !mpi_finalized) { MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); HDfprintf(stream, "MPI-process %d", mpi_rank); } /* end if */ @@ -396,14 +382,13 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) } /* end if */ /* Check for "real" error description - used to format output more nicely */ - if(err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) + if (err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) have_desc = 0; /* Print error message */ - HDfprintf(stream, "%*s#%03u: %s line %u in %s()%s%s\n", - H5E_INDENT, "", n, err_desc->file_name, err_desc->line, - err_desc->func_name, (have_desc ? ": " : ""), - (have_desc ? err_desc->desc : "")); + HDfprintf(stream, "%*s#%03u: %s line %u in %s()%s%s\n", H5E_INDENT, "", n, err_desc->file_name, + err_desc->line, err_desc->func_name, (have_desc ? ": " : ""), + (have_desc ? err_desc->desc : "")); HDfprintf(stream, "%*smajor: %s\n", (H5E_INDENT * 2), "", maj_str); HDfprintf(stream, "%*sminor: %s\n", (H5E_INDENT * 2), "", min_str); @@ -411,7 +396,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__walk2_cb() */ - /*------------------------------------------------------------------------- * Function: H5E__print * @@ -431,9 +415,9 @@ done: herr_t H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) { - H5E_print_t eprint; /* Callback information to pass to H5E_walk() */ - H5E_walk_op_t walk_op; /* Error stack walking callback */ - herr_t ret_value = SUCCEED; + H5E_print_t eprint; /* Callback information to pass to H5E_walk() */ + H5E_walk_op_t walk_op; /* Error stack walking callback */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -441,7 +425,7 @@ H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) HDassert(estack); /* If no stream was given, use stderr */ - if(!stream) + if (!stream) eprint.stream = stderr; else eprint.stream = stream; @@ -450,20 +434,20 @@ H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) HDmemset(&eprint.cls, 0, sizeof(H5E_cls_t)); /* Walk the error stack */ - if(bk_compatible) { + if (bk_compatible) { #ifndef H5_NO_DEPRECATED_SYMBOLS - walk_op.vers = 1; + walk_op.vers = 1; walk_op.u.func1 = H5E__walk1_cb; - if(H5E__walk(estack, H5E_WALK_DOWNWARD, &walk_op, (void*)&eprint) < 0) + if (H5E__walk(estack, H5E_WALK_DOWNWARD, &walk_op, (void *)&eprint) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ HDassert(0 && "version 1 error stack print without deprecated symbols!"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ + } /* end if */ else { - walk_op.vers = 2; + walk_op.vers = 2; walk_op.u.func2 = H5E__walk2_cb; - if(H5E__walk(estack, H5E_WALK_DOWNWARD, &walk_op, (void*)&eprint) < 0) + if (H5E__walk(estack, H5E_WALK_DOWNWARD, &walk_op, (void *)&eprint) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") } /* end else */ @@ -471,7 +455,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__print() */ - /*------------------------------------------------------------------------- * Function: H5E__walk * @@ -503,11 +486,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, - void *client_data) +H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, void *client_data) { - int i; /* Local index variable */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + int i; /* Local index variable */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -516,74 +498,74 @@ H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *o HDassert(op); /* check args, but rather than failing use some default value */ - if(direction != H5E_WALK_UPWARD && direction != H5E_WALK_DOWNWARD) - direction = H5E_WALK_UPWARD; + if (direction != H5E_WALK_UPWARD && direction != H5E_WALK_DOWNWARD) + direction = H5E_WALK_UPWARD; /* Walk the stack if a callback function was given */ - if(op->vers == 1) { + if (op->vers == 1) { #ifndef H5_NO_DEPRECATED_SYMBOLS - if(op->u.func1) { + if (op->u.func1) { H5E_error1_t old_err; ret_value = SUCCEED; - if(H5E_WALK_UPWARD == direction) { - for(i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) { + if (H5E_WALK_UPWARD == direction) { + for (i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) { /* Point to each error record on the stack and pass it to callback function.*/ - old_err.maj_num = estack->slot[i].maj_num; - old_err.min_num = estack->slot[i].min_num; + old_err.maj_num = estack->slot[i].maj_num; + old_err.min_num = estack->slot[i].min_num; old_err.func_name = estack->slot[i].func_name; old_err.file_name = estack->slot[i].file_name; - old_err.desc = estack->slot[i].desc; - old_err.line = estack->slot[i].line; + old_err.desc = estack->slot[i].desc; + old_err.line = estack->slot[i].line; ret_value = (op->u.func1)(i, &old_err, client_data); } /* end for */ - } /* end if */ + } /* end if */ else { H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); - for(i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) { + for (i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) { /* Point to each error record on the stack and pass it to callback function.*/ - old_err.maj_num = estack->slot[i].maj_num; - old_err.min_num = estack->slot[i].min_num; + old_err.maj_num = estack->slot[i].maj_num; + old_err.min_num = estack->slot[i].min_num; old_err.func_name = estack->slot[i].func_name; old_err.file_name = estack->slot[i].file_name; - old_err.desc = estack->slot[i].desc; - old_err.line = estack->slot[i].line; + old_err.desc = estack->slot[i].desc; + old_err.line = estack->slot[i].line; ret_value = (op->u.func1)((int)(estack->nused - (size_t)(i + 1)), &old_err, client_data); } /* end for */ - } /* end else */ + } /* end else */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_ERROR, H5E_CANTLIST, "can't walk error stack"); } /* end if */ -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ HDassert(0 && "version 1 error stack walk without deprecated symbols!"); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + } /* end if */ else { HDassert(op->vers == 2); - if(op->u.func2) { + if (op->u.func2) { ret_value = SUCCEED; - if(H5E_WALK_UPWARD == direction) { - for(i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) + if (H5E_WALK_UPWARD == direction) { + for (i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) ret_value = (op->u.func2)((unsigned)i, estack->slot + i, client_data); } /* end if */ else { H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); - for(i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) - ret_value = (op->u.func2)((unsigned)(estack->nused - (size_t)(i + 1)), estack->slot + i, client_data); + for (i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) + ret_value = (op->u.func2)((unsigned)(estack->nused - (size_t)(i + 1)), estack->slot + i, + client_data); } /* end else */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_ERROR, H5E_CANTLIST, "can't walk error stack"); } /* end if */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__walk() */ - /*------------------------------------------------------------------------- * Function: H5E__get_auto * @@ -607,15 +589,14 @@ H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data) HDassert(estack); /* Retrieve the requested information */ - if(op) + if (op) *op = estack->auto_op; - if(client_data) + if (client_data) *client_data = estack->auto_data; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__get_auto() */ - /*------------------------------------------------------------------------- * Function: H5E__set_auto * @@ -647,13 +628,12 @@ H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data) HDassert(estack); /* Set the automatic error reporting info */ - estack->auto_op = *op; + estack->auto_op = *op; estack->auto_data = client_data; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__set_auto() */ - /*------------------------------------------------------------------------- * Function: H5E_printf_stack * @@ -667,17 +647,17 @@ H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data) *------------------------------------------------------------------------- */ herr_t -H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) +H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, + hid_t min_id, const char *fmt, ...) { - va_list ap; /* Varargs info */ + va_list ap; /* Varargs info */ #ifndef H5_HAVE_VASPRINTF - int tmp_len; /* Current size of description buffer */ - int desc_len; /* Actual length of description when formatted */ -#endif /* H5_HAVE_VASPRINTF */ - char *tmp = NULL; /* Buffer to place formatted description in */ - hbool_t va_started = FALSE; /* Whether the variable argument list is open */ - herr_t ret_value = SUCCEED; /* Return value */ + int tmp_len; /* Current size of description buffer */ + int desc_len; /* Actual length of description when formatted */ +#endif /* H5_HAVE_VASPRINTF */ + char * tmp = NULL; /* Buffer to place formatted description in */ + hbool_t va_started = FALSE; /* Whether the variable argument list is open */ + herr_t ret_value = SUCCEED; /* Return value */ /* * WARNING: We cannot call HERROR() from within this function or else we @@ -694,10 +674,10 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin HDassert(min_id > 0); HDassert(fmt); -/* Note that the variable-argument parsing for the format is identical in - * the H5Epush2() routine - correct errors and make changes in both - * places. -QAK - */ + /* Note that the variable-argument parsing for the format is identical in + * the H5Epush2() routine - correct errors and make changes in both + * places. -QAK + */ /* Start the variable-argument parsing */ HDva_start(ap, fmt); @@ -705,16 +685,16 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin #ifdef H5_HAVE_VASPRINTF /* Use the vasprintf() routine, since it does what we're trying to do below */ - if(HDvasprintf(&tmp, fmt, ap) < 0) + if (HDvasprintf(&tmp, fmt, ap) < 0) HGOTO_DONE(FAIL) -#else /* H5_HAVE_VASPRINTF */ +#else /* H5_HAVE_VASPRINTF */ /* Allocate space for the formatted description buffer */ tmp_len = 128; - if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) + if (NULL == (tmp = H5MM_malloc((size_t)tmp_len))) HGOTO_DONE(FAIL) /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ - while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { + while ((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { /* shutdown & restart the va_list */ HDva_end(ap); HDva_start(ap, fmt); @@ -724,33 +704,32 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin /* Allocate a description of the appropriate length */ tmp_len = desc_len + 1; - if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) + if (NULL == (tmp = H5MM_malloc((size_t)tmp_len))) HGOTO_DONE(FAIL) } /* end while */ #endif /* H5_HAVE_VASPRINTF */ /* Push the error on the stack */ - if(H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) + if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) HGOTO_DONE(FAIL) done: - if(va_started) + if (va_started) HDva_end(ap); #ifdef H5_HAVE_VASPRINTF /* Memory was allocated with HDvasprintf so it needs to be freed * with HDfree */ - if(tmp) + if (tmp) HDfree(tmp); -#else /* H5_HAVE_VASPRINTF */ - if(tmp) +#else /* H5_HAVE_VASPRINTF */ + if (tmp) H5MM_xfree(tmp); #endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_printf_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__push_stack * @@ -772,10 +751,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc) +H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, + hid_t min_id, const char *desc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* * WARNING: We cannot call HERROR() from within this function or else we @@ -792,19 +771,20 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line HDassert(min_id > 0); /* Check for 'default' error stack */ - if(estack == NULL) - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack == NULL) + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_DONE(FAIL) /* * Don't fail if arguments are bad. Instead, substitute some default * value. */ - if(!func) + if (!func) func = "Unknown_Function"; - if(!file) + if (!file) file = "Unknown_File"; - if(!desc) + if (!desc) desc = "No description given"; /* @@ -812,32 +792,31 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line */ HDassert(estack); - if(estack->nused < H5E_NSLOTS) { + if (estack->nused < H5E_NSLOTS) { /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(cls_id, FALSE) < 0) + if (H5I_inc_ref(cls_id, FALSE) < 0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].cls_id = cls_id; - if(H5I_inc_ref(maj_id, FALSE) < 0) + estack->slot[estack->nused].cls_id = cls_id; + if (H5I_inc_ref(maj_id, FALSE) < 0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].maj_num = maj_id; - if(H5I_inc_ref(min_id, FALSE) < 0) + estack->slot[estack->nused].maj_num = maj_id; + if (H5I_inc_ref(min_id, FALSE) < 0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].min_num = min_id; - if(NULL == (estack->slot[estack->nused].func_name = H5MM_xstrdup(func))) + estack->slot[estack->nused].min_num = min_id; + if (NULL == (estack->slot[estack->nused].func_name = H5MM_xstrdup(func))) HGOTO_DONE(FAIL) - if(NULL == (estack->slot[estack->nused].file_name = H5MM_xstrdup(file))) + if (NULL == (estack->slot[estack->nused].file_name = H5MM_xstrdup(file))) HGOTO_DONE(FAIL) - estack->slot[estack->nused].line = line; - if(NULL == (estack->slot[estack->nused].desc = H5MM_xstrdup(desc))) + estack->slot[estack->nused].line = line; + if (NULL == (estack->slot[estack->nused].desc = H5MM_xstrdup(desc))) HGOTO_DONE(FAIL) - estack->nused++; + estack->nused++; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__push_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__clear_entries * @@ -854,9 +833,9 @@ done: static herr_t H5E__clear_entries(H5E_t *estack, size_t nentries) { - H5E_error2_t *error; /* Pointer to error stack entry to clear */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_error2_t *error; /* Pointer to error stack entry to clear */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -865,25 +844,25 @@ H5E__clear_entries(H5E_t *estack, size_t nentries) HDassert(estack->nused >= nentries); /* Empty the error stack from the top down */ - for(u = 0; nentries > 0; nentries--, u++) { + for (u = 0; nentries > 0; nentries--, u++) { error = &(estack->slot[estack->nused - (u + 1)]); /* Decrement the IDs to indicate that they are no longer used by this stack */ /* (In reverse order that they were incremented, so that reference counts work well) */ - if(H5I_dec_ref(error->min_num) < 0) + if (H5I_dec_ref(error->min_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->maj_num) < 0) + if (H5I_dec_ref(error->maj_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->cls_id) < 0) + if (H5I_dec_ref(error->cls_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") /* Release strings */ - if(error->func_name) - error->func_name = (const char *) H5MM_xfree_const(error->func_name); - if(error->file_name) - error->file_name = (const char *) H5MM_xfree_const(error->file_name); - if(error->desc) - error->desc = (const char *) H5MM_xfree_const(error->desc); + if (error->func_name) + error->func_name = (const char *)H5MM_xfree_const(error->func_name); + if (error->file_name) + error->file_name = (const char *)H5MM_xfree_const(error->file_name); + if (error->desc) + error->desc = (const char *)H5MM_xfree_const(error->desc); } /* Decrement number of errors on stack */ @@ -893,7 +872,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__clear_entries() */ - /*------------------------------------------------------------------------- * Function: H5E_clear_stack * @@ -910,26 +888,26 @@ done: herr_t H5E_clear_stack(H5E_t *estack) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check for 'default' error stack */ - if(estack == NULL) - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack == NULL) + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Empty the error stack */ HDassert(estack); - if(estack->nused) - if(H5E__clear_entries(estack, estack->nused) < 0) + if (estack->nused) + if (H5E__clear_entries(estack, estack->nused) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_clear_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__pop * @@ -946,7 +924,7 @@ done: herr_t H5E__pop(H5E_t *estack, size_t count) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -955,14 +933,13 @@ H5E__pop(H5E_t *estack, size_t count) HDassert(estack->nused >= count); /* Remove the entries from the error stack */ - if(H5E__clear_entries(estack, count) < 0) + if (H5E__clear_entries(estack, count) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "can't remove errors from stack") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__pop() */ - /*------------------------------------------------------------------------- * Function: H5E_dump_api_stack * @@ -980,32 +957,31 @@ done: herr_t H5E_dump_api_stack(hbool_t is_api) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Only dump the error stack during an API call */ - if(is_api) { + if (is_api) { H5E_t *estack = H5E__get_my_stack(); HDassert(estack); #ifdef H5_NO_DEPRECATED_SYMBOLS - if(estack->auto_op.func2) - (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data)); -#else /* H5_NO_DEPRECATED_SYMBOLS */ - if(estack->auto_op.vers == 1) { - if(estack->auto_op.func1) + if (estack->auto_op.func2) + (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data)); +#else /* H5_NO_DEPRECATED_SYMBOLS */ + if (estack->auto_op.vers == 1) { + if (estack->auto_op.func1) (void)((estack->auto_op.func1)(estack->auto_data)); } /* end if */ else { - if(estack->auto_op.func2) + if (estack->auto_op.func2) (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data)); } /* end else */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_dump_api_stack() */ - diff --git a/src/H5Emodule.h b/src/H5Emodule.h index 2d1bcd0..8137673 100644 --- a/src/H5Emodule.h +++ b/src/H5Emodule.h @@ -25,10 +25,8 @@ * reporting macros. */ #define H5E_MODULE -#define H5_MY_PKG H5E -#define H5_MY_PKG_ERR H5E_ERROR -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5E +#define H5_MY_PKG_ERR H5E_ERROR +#define H5_MY_PKG_INIT YES #endif /* _H5Emodule_H */ - - diff --git a/src/H5Epkg.h b/src/H5Epkg.h index 83f3816..260b8da 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -31,16 +31,15 @@ /* Other private headers needed by this file */ - /**************************/ /* Package Private Macros */ /**************************/ /* Amount to indent each error */ -#define H5E_INDENT 2 +#define H5E_INDENT 2 /* Number of slots in an error stack */ -#define H5E_NSLOTS 32 +#define H5E_NSLOTS 32 #ifdef H5_HAVE_THREADSAFE /* @@ -52,7 +51,7 @@ * In order for this macro to work, H5E__get_my_stack() must be preceeded * by "H5E_t *estack =". */ -#define H5E__get_my_stack() H5E__get_stack() +#define H5E__get_my_stack() H5E__get_stack() #else /* H5_HAVE_THREADSAFE */ /* * The current error stack. @@ -60,7 +59,6 @@ #define H5E__get_my_stack() (H5E_stack_g + 0) #endif /* H5_HAVE_THREADSAFE */ - /****************************/ /* Package Private Typedefs */ /****************************/ @@ -68,53 +66,52 @@ /* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ #ifndef H5_NO_DEPRECATED_SYMBOLS typedef struct { - unsigned vers; /* Which version callback to use */ - hbool_t is_default; /* If the printing function is the library's own. */ - H5E_auto1_t func1; /* Old-style callback, NO error stack param. */ - H5E_auto2_t func2; /* New-style callback, with error stack param. */ - H5E_auto1_t func1_default; /* The saved library's default function - old style. */ - H5E_auto2_t func2_default; /* The saved library's default function - new style. */ + unsigned vers; /* Which version callback to use */ + hbool_t is_default; /* If the printing function is the library's own. */ + H5E_auto1_t func1; /* Old-style callback, NO error stack param. */ + H5E_auto2_t func2; /* New-style callback, with error stack param. */ + H5E_auto1_t func1_default; /* The saved library's default function - old style. */ + H5E_auto2_t func2_default; /* The saved library's default function - new style. */ } H5E_auto_op_t; -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ typedef struct { - H5E_auto2_t func2; /* Only the new style callback function is available. */ + H5E_auto2_t func2; /* Only the new style callback function is available. */ } H5E_auto_op_t; #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ typedef struct { - unsigned vers; /* Which version callback to use */ + unsigned vers; /* Which version callback to use */ union { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5E_walk1_t func1; /* Old-style callback, NO error stack param. */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5E_walk2_t func2; /* New-style callback, with error stack param. */ - }u; + H5E_walk1_t func1; /* Old-style callback, NO error stack param. */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5E_walk2_t func2; /* New-style callback, with error stack param. */ + } u; } H5E_walk_op_t; /* Error class */ typedef struct H5E_cls_t { - char *cls_name; /* Name of error class */ - char *lib_name; /* Name of library within class */ - char *lib_vers; /* Version of library */ + char *cls_name; /* Name of error class */ + char *lib_name; /* Name of library within class */ + char *lib_vers; /* Version of library */ } H5E_cls_t; /* Major or minor message */ typedef struct H5E_msg_t { - char *msg; /* Message for error */ - H5E_type_t type; /* Type of error (major or minor) */ - H5E_cls_t *cls; /* Which error class this message belongs to */ + char * msg; /* Message for error */ + H5E_type_t type; /* Type of error (major or minor) */ + H5E_cls_t *cls; /* Which error class this message belongs to */ } H5E_msg_t; /* Error stack */ struct H5E_t { - size_t nused; /* Num slots currently used in stack */ - H5E_error2_t slot[H5E_NSLOTS]; /* Array of error records */ - H5E_auto_op_t auto_op; /* Operator for 'automatic' error reporting */ - void *auto_data; /* Callback data for 'automatic error reporting */ + size_t nused; /* Num slots currently used in stack */ + H5E_error2_t slot[H5E_NSLOTS]; /* Array of error records */ + H5E_auto_op_t auto_op; /* Operator for 'automatic' error reporting */ + void * auto_data; /* Callback data for 'automatic error reporting */ }; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -123,10 +120,9 @@ struct H5E_t { /* * The current error stack. */ -H5_DLLVAR H5E_t H5E_stack_g[1]; +H5_DLLVAR H5E_t H5E_stack_g[1]; #endif /* H5_HAVE_THREADSAFE */ - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -134,18 +130,14 @@ H5_DLL herr_t H5E__term_deprec_interface(void); #ifdef H5_HAVE_THREADSAFE H5_DLL H5E_t *H5E__get_stack(void); #endif /* H5_HAVE_THREADSAFE */ -H5_DLL herr_t H5E__push_stack(H5E_t *estack, const char *file, const char *func, - unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc); -H5_DLL ssize_t H5E__get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, - char *msg, size_t size); -H5_DLL herr_t H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compat); -H5_DLL herr_t H5E__walk(const H5E_t *estack, H5E_direction_t direction, - const H5E_walk_op_t *op, void *client_data); -H5_DLL herr_t H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, - void **client_data); -H5_DLL herr_t H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, - void *client_data); -H5_DLL herr_t H5E__pop(H5E_t *err_stack, size_t count); +H5_DLL herr_t H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, + hid_t maj_id, hid_t min_id, const char *desc); +H5_DLL ssize_t H5E__get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, char *msg, size_t size); +H5_DLL herr_t H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compat); +H5_DLL herr_t H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, + void *client_data); +H5_DLL herr_t H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data); +H5_DLL herr_t H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data); +H5_DLL herr_t H5E__pop(H5E_t *err_stack, size_t count); #endif /* _H5Epkg_H */ - diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 9deb695..7a1014e 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -30,16 +30,17 @@ typedef struct H5E_t H5E_t; * and a FUNC_LEAVE() within a function body. The arguments are the major * error number, the minor error number, and a description of the error. */ -#define HERROR(maj_id, min_id, ...) H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__) +#define HERROR(maj_id, min_id, ...) \ + H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__) /* * HCOMMON_ERROR macro, used by HDONE_ERROR and HGOTO_ERROR * (Shouldn't need to be used outside this header file) */ -#define HCOMMON_ERROR(maj, min, ...) \ - HERROR(maj, min, __VA_ARGS__); \ - err_occurred = TRUE; \ - err_occurred = err_occurred; /* Shut GCC warnings up! */ +#define HCOMMON_ERROR(maj, min, ...) \ + HERROR(maj, min, __VA_ARGS__); \ + err_occurred = TRUE; \ + err_occurred = err_occurred; /* Shut GCC warnings up! */ /* * HDONE_ERROR macro, used to facilitate error reporting between a @@ -50,10 +51,11 @@ typedef struct H5E_t H5E_t; * (This macro can also be used to push an error and set the return value * without jumping to any labels) */ -#define HDONE_ERROR(maj, min, ret_val, ...) { \ - HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - ret_value = ret_val; \ -} +#define HDONE_ERROR(maj, min, ret_val, ...) \ + { \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + ret_value = ret_val; \ + } /* * HGOTO_ERROR macro, used to facilitate error reporting between a @@ -62,20 +64,22 @@ typedef struct H5E_t H5E_t; * error string. The return value is assigned to a variable `ret_value' and * control branches to the `done' label. */ -#define HGOTO_ERROR(maj, min, ret_val, ...) { \ - HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - HGOTO_DONE(ret_val) \ -} +#define HGOTO_ERROR(maj, min, ret_val, ...) \ + { \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + HGOTO_DONE(ret_val) \ + } /* * HGOTO_ERROR_TAG macro, used like HGOTO_ERROR between H5_BEGIN_TAG and * H5_END_TAG statements. Resets the metadata tag before leaving the function. */ -#define HGOTO_ERROR_TAG(maj, min, ret_val, ...) { \ - H5AC_tag(prv_tag, NULL); \ - HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - HGOTO_DONE(ret_val) \ -} +#define HGOTO_ERROR_TAG(maj, min, ret_val, ...) \ + { \ + H5AC_tag(prv_tag, NULL); \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + HGOTO_DONE(ret_val) \ + } /* * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER() @@ -83,16 +87,21 @@ typedef struct H5E_t H5E_t; * value which is assigned to the `ret_value' variable. Control branches to * the `done' label. */ -#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} +#define HGOTO_DONE(ret_val) \ + { \ + ret_value = ret_val; \ + goto done; \ + } /* * HGOTO_DONE_TAG macro, used like HGOTO_DONE between H5_BEGIN_TAG and * H5_END_TAG statements. Resets the metadata tag before leaving the function. */ -#define HGOTO_DONE_TAG(ret_val) { \ - H5AC_tag(prv_tag, NULL); \ - HGOTO_DONE(ret_val) \ -} +#define HGOTO_DONE_TAG(ret_val) \ + { \ + H5AC_tag(prv_tag, NULL); \ + HGOTO_DONE(ret_val) \ + } /* * Macros handling system error messages as described in C standard. @@ -122,11 +131,11 @@ typedef struct H5E_t H5E_t; HDstrerror(myerrno)); \ } #else /* H5_HAVE_WIN32_API */ - /* On Windows we also emit the result of GetLastError(). This call returns a DWORD, which is always a - * 32-bit unsigned type. Note that on Windows, either errno or GetLastError() (but probably not both) will - * be useful depending on whether a C/POSIX or Win32 call failed. The other value will likely be zero, - * though I wouldn't count on that. - */ +/* On Windows we also emit the result of GetLastError(). This call returns a DWORD, which is always a + * 32-bit unsigned type. Note that on Windows, either errno or GetLastError() (but probably not both) will + * be useful depending on whether a C/POSIX or Win32 call failed. The other value will likely be zero, + * though I wouldn't count on that. + */ #define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) \ { \ int myerrno = errno; \ @@ -156,23 +165,25 @@ typedef struct H5E_t H5E_t; * MPI error handling macros. */ -extern char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; -extern int H5E_mpi_error_str_len; - -#define HMPI_ERROR(mpierr){ \ - MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ - HERROR(H5E_INTERNAL, H5E_MPIERRSTR, "%s", H5E_mpi_error_str); \ -} -#define HMPI_DONE_ERROR(retcode, str, mpierr){ \ - HMPI_ERROR(mpierr); \ - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ -} -#define HMPI_GOTO_ERROR(retcode, str, mpierr){ \ - HMPI_ERROR(mpierr); \ - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ -} -#endif /* H5_HAVE_PARALLEL */ +extern char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; +extern int H5E_mpi_error_str_len; +#define HMPI_ERROR(mpierr) \ + { \ + MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ + HERROR(H5E_INTERNAL, H5E_MPIERRSTR, "%s", H5E_mpi_error_str); \ + } +#define HMPI_DONE_ERROR(retcode, str, mpierr) \ + { \ + HMPI_ERROR(mpierr); \ + HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ + } +#define HMPI_GOTO_ERROR(retcode, str, mpierr) \ + { \ + HMPI_ERROR(mpierr); \ + HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ + } +#endif /* H5_HAVE_PARALLEL */ /******************************************************************************/ /* Revisions to Error Macros, to go with Revisions to FUNC_ENTER/LEAVE Macros */ @@ -184,7 +195,8 @@ extern int H5E_mpi_error_str_len; * error number, a description of the error (as a printf-like format string), * and an optional set of arguments for the printf format arguments. */ -#define H5E_PRINTF(...) H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__) +#define H5E_PRINTF(...) \ + H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__) /* * H5_LEAVE macro, used to facilitate control flow between a @@ -193,11 +205,12 @@ extern int H5E_mpi_error_str_len; * The return value is assigned to a variable `ret_value' and control branches * to the `catch_except' label, if we're not already past it. */ -#define H5_LEAVE(v) { \ - ret_value = v; \ - if(!past_catch) \ - goto catch_except; \ -} +#define H5_LEAVE(v) \ + { \ + ret_value = v; \ + if (!past_catch) \ + goto catch_except; \ + } /* * H5E_THROW macro, used to facilitate error reporting between a @@ -206,23 +219,24 @@ extern int H5E_mpi_error_str_len; * The return value is assigned to a variable `ret_value' and control branches * to the `catch_except' label, if we're not already past it. */ -#define H5E_THROW(...) { \ - H5E_PRINTF(__VA_ARGS__); \ - H5_LEAVE(fail_value) \ -} +#define H5E_THROW(...) \ + { \ + H5E_PRINTF(__VA_ARGS__); \ + H5_LEAVE(fail_value) \ + } /* Macro for "catching" flow of control when an error occurs. Note that the * H5_LEAVE macro won't jump back here once it's past this point. */ -#define CATCH catch_except:; past_catch = TRUE; - +#define CATCH \ +catch_except:; \ + past_catch = TRUE; /* Library-private functions defined in H5E package */ H5_DLL herr_t H5E_init(void); -H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, - unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) H5_ATTR_FORMAT(printf, 8, 9); +H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, + hid_t maj_id, hid_t min_id, const char *fmt, ...) H5_ATTR_FORMAT(printf, 8, 9); H5_DLL herr_t H5E_clear_stack(H5E_t *estack); H5_DLL herr_t H5E_dump_api_stack(hbool_t is_api); #endif /* _H5Eprivate_H */ - diff --git a/src/H5Epublic.h b/src/H5Epublic.h index ed14217..8f9b473 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -17,42 +17,39 @@ #ifndef _H5Epublic_H #define _H5Epublic_H -#include /*FILE arg of H5Eprint() */ +#include /*FILE arg of H5Eprint() */ /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" /* Value for the default error stack */ -#define H5E_DEFAULT (hid_t)0 +#define H5E_DEFAULT (hid_t)0 /* Different kinds of error information */ -typedef enum H5E_type_t { - H5E_MAJOR, - H5E_MINOR -} H5E_type_t; +typedef enum H5E_type_t { H5E_MAJOR, H5E_MINOR } H5E_type_t; /* Information about an error; element of error stack */ typedef struct H5E_error2_t { - hid_t cls_id; /*class ID */ - hid_t maj_num; /*major error ID */ - hid_t min_num; /*minor error number */ - unsigned line; /*line in file where error occurs */ - const char *func_name; /*function in which error occurred */ - const char *file_name; /*file in which error occurred */ - const char *desc; /*optional supplied description */ + hid_t cls_id; /*class ID */ + hid_t maj_num; /*major error ID */ + hid_t min_num; /*minor error number */ + unsigned line; /*line in file where error occurs */ + const char *func_name; /*function in which error occurred */ + const char *file_name; /*file in which error occurred */ + const char *desc; /*optional supplied description */ } H5E_error2_t; /* When this header is included from a private header, don't make calls to H5open() */ #undef H5OPEN #ifndef _H5private_H -#define H5OPEN H5open(), -#else /* _H5private_H */ +#define H5OPEN H5open(), +#else /* _H5private_H */ #define H5OPEN -#endif /* _H5private_H */ +#endif /* _H5private_H */ /* HDF5 error class */ -#define H5E_ERR_CLS (H5OPEN H5E_ERR_CLS_g) +#define H5E_ERR_CLS (H5OPEN H5E_ERR_CLS_g) H5_DLLVAR hid_t H5E_ERR_CLS_g; /* Include the automatically generated public header information */ @@ -75,108 +72,108 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; * purpose. */ #ifndef H5_NO_DEPRECATED_SYMBOLS -#define H5E_BEGIN_TRY { \ - unsigned H5E_saved_is_v2; \ - union { \ - H5E_auto1_t efunc1; \ - H5E_auto2_t efunc2; \ - } H5E_saved; \ - void *H5E_saved_edata; \ - \ - (void)H5Eauto_is_v2(H5E_DEFAULT, &H5E_saved_is_v2); \ - if(H5E_saved_is_v2) { \ - (void)H5Eget_auto2(H5E_DEFAULT, &H5E_saved.efunc2, &H5E_saved_edata); \ - (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); \ - } else { \ - (void)H5Eget_auto1(&H5E_saved.efunc1, &H5E_saved_edata); \ - (void)H5Eset_auto1(NULL, NULL); \ +#define H5E_BEGIN_TRY \ + { \ + unsigned H5E_saved_is_v2; \ + union { \ + H5E_auto1_t efunc1; \ + H5E_auto2_t efunc2; \ + } H5E_saved; \ + void *H5E_saved_edata; \ + \ + (void)H5Eauto_is_v2(H5E_DEFAULT, &H5E_saved_is_v2); \ + if (H5E_saved_is_v2) { \ + (void)H5Eget_auto2(H5E_DEFAULT, &H5E_saved.efunc2, &H5E_saved_edata); \ + (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); \ + } \ + else { \ + (void)H5Eget_auto1(&H5E_saved.efunc1, &H5E_saved_edata); \ + (void)H5Eset_auto1(NULL, NULL); \ + } + +#define H5E_END_TRY \ + if (H5E_saved_is_v2) \ + (void)H5Eset_auto2(H5E_DEFAULT, H5E_saved.efunc2, H5E_saved_edata); \ + else \ + (void)H5Eset_auto1(H5E_saved.efunc1, H5E_saved_edata); \ } - -#define H5E_END_TRY \ - if(H5E_saved_is_v2) \ - (void)H5Eset_auto2(H5E_DEFAULT, H5E_saved.efunc2, H5E_saved_edata); \ - else \ - (void)H5Eset_auto1(H5E_saved.efunc1, H5E_saved_edata); \ -} #else /* H5_NO_DEPRECATED_SYMBOLS */ -#define H5E_BEGIN_TRY { \ - H5E_auto2_t saved_efunc; \ - void *H5E_saved_edata; \ - \ - (void)H5Eget_auto2(H5E_DEFAULT, &saved_efunc, &H5E_saved_edata); \ - (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - -#define H5E_END_TRY \ - (void)H5Eset_auto2(H5E_DEFAULT, saved_efunc, H5E_saved_edata); \ -} +#define H5E_BEGIN_TRY \ + { \ + H5E_auto2_t saved_efunc; \ + void * H5E_saved_edata; \ + \ + (void)H5Eget_auto2(H5E_DEFAULT, &saved_efunc, &H5E_saved_edata); \ + (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + +#define H5E_END_TRY \ + (void)H5Eset_auto2(H5E_DEFAULT, saved_efunc, H5E_saved_edata); \ + } #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* * Public API Convenience Macros for Error reporting - Documented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ -#define H5Epush_sim(func, cls, maj, min, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str) +#define H5Epush_sim(func, cls, maj, min, str) \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str) /* * Public API Convenience Macros for Error reporting - Undocumented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And return after pushing error onto stack */ -#define H5Epush_ret(func, cls, maj, min, str, ret) { \ - H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ - return(ret); \ -} +#define H5Epush_ret(func, cls, maj, min, str, ret) \ + { \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ + return (ret); \ + } /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in * And goto a label after pushing error onto stack. */ -#define H5Epush_goto(func, cls, maj, min, str, label) { \ - H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ - goto label; \ -} +#define H5Epush_goto(func, cls, maj, min, str, label) \ + { \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ + goto label; \ + } /* Error stack traversal direction */ typedef enum H5E_direction_t { - H5E_WALK_UPWARD = 0, /*begin deep, end at API function */ - H5E_WALK_DOWNWARD = 1 /*begin at API function, end deep */ + H5E_WALK_UPWARD = 0, /*begin deep, end at API function */ + H5E_WALK_DOWNWARD = 1 /*begin at API function, end deep */ } H5E_direction_t; - #ifdef __cplusplus extern "C" { #endif /* Error stack traversal callback function pointers */ -typedef herr_t (*H5E_walk2_t)(unsigned n, const H5E_error2_t *err_desc, - void *client_data); +typedef herr_t (*H5E_walk2_t)(unsigned n, const H5E_error2_t *err_desc, void *client_data); typedef herr_t (*H5E_auto2_t)(hid_t estack, void *client_data); /* Public API functions */ -H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, - const char *version); -H5_DLL herr_t H5Eunregister_class(hid_t class_id); -H5_DLL herr_t H5Eclose_msg(hid_t err_id); -H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg); -H5_DLL hid_t H5Ecreate_stack(void); -H5_DLL hid_t H5Eget_current_stack(void); -H5_DLL herr_t H5Eclose_stack(hid_t stack_id); +H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version); +H5_DLL herr_t H5Eunregister_class(hid_t class_id); +H5_DLL herr_t H5Eclose_msg(hid_t err_id); +H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg); +H5_DLL hid_t H5Ecreate_stack(void); +H5_DLL hid_t H5Eget_current_stack(void); +H5_DLL herr_t H5Eclose_stack(hid_t stack_id); H5_DLL ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size); -H5_DLL herr_t H5Eset_current_stack(hid_t err_stack_id); -H5_DLL herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...); -H5_DLL herr_t H5Epop(hid_t err_stack, size_t count); -H5_DLL herr_t H5Eprint2(hid_t err_stack, FILE *stream); -H5_DLL herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t func, - void *client_data); -H5_DLL herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data); -H5_DLL herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data); -H5_DLL herr_t H5Eclear2(hid_t err_stack); -H5_DLL herr_t H5Eauto_is_v2(hid_t err_stack, unsigned *is_stack); -H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, - size_t size); +H5_DLL herr_t H5Eset_current_stack(hid_t err_stack_id); +H5_DLL herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id, + hid_t maj_id, hid_t min_id, const char *msg, ...); +H5_DLL herr_t H5Epop(hid_t err_stack, size_t count); +H5_DLL herr_t H5Eprint2(hid_t err_stack, FILE *stream); +H5_DLL herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t func, void *client_data); +H5_DLL herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data); +H5_DLL herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data); +H5_DLL herr_t H5Eclear2(hid_t err_stack); +H5_DLL herr_t H5Eauto_is_v2(hid_t err_stack, unsigned *is_stack); +H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size); H5_DLL ssize_t H5Eget_num(hid_t error_stack_id); - /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. @@ -188,17 +185,17 @@ H5_DLL ssize_t H5Eget_num(hid_t error_stack_id); /* Alias major & minor error types to hid_t's, for compatibility with new * error API in v1.8 */ -typedef hid_t H5E_major_t; -typedef hid_t H5E_minor_t; +typedef hid_t H5E_major_t; +typedef hid_t H5E_minor_t; /* Information about an error element of error stack. */ typedef struct H5E_error1_t { - H5E_major_t maj_num; /*major error number */ - H5E_minor_t min_num; /*minor error number */ - const char *func_name; /*function in which error occurred */ - const char *file_name; /*file in which error occurred */ - unsigned line; /*line in file where error occurs */ - const char *desc; /*optional supplied description */ + H5E_major_t maj_num; /*major error number */ + H5E_minor_t min_num; /*minor error number */ + const char *func_name; /*function in which error occurred */ + const char *file_name; /*file in which error occurred */ + unsigned line; /*line in file where error occurs */ + const char *desc; /*optional supplied description */ } H5E_error1_t; /* Error stack traversal callback function pointers */ @@ -208,14 +205,13 @@ typedef herr_t (*H5E_auto1_t)(void *client_data); /* Function prototypes */ H5_DLL herr_t H5Eclear1(void); H5_DLL herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data); -H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, - H5E_major_t maj, H5E_minor_t min, const char *str); +H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, + const char *str); H5_DLL herr_t H5Eprint1(FILE *stream); H5_DLL herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data); -H5_DLL herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, - void *client_data); -H5_DLL char *H5Eget_major(H5E_major_t maj); -H5_DLL char *H5Eget_minor(H5E_minor_t min); +H5_DLL herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data); +H5_DLL char * H5Eget_major(H5E_major_t maj); +H5_DLL char * H5Eget_minor(H5E_minor_t min); #endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus @@ -223,4 +219,3 @@ H5_DLL char *H5Eget_minor(H5E_minor_t min); #endif #endif /* end _H5Epublic_H */ - diff --git a/src/H5F.c b/src/H5F.c index 054c547..1e929bb 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -15,60 +15,55 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for traversal routine to get ID counts */ typedef struct { - size_t obj_count; /* Number of objects counted so far */ - unsigned types; /* Types of objects to be counted */ + size_t obj_count; /* Number of objects counted so far */ + unsigned types; /* Types of objects to be counted */ } H5F_trav_obj_cnt_t; /* User data for traversal routine to get ID lists */ typedef struct { - size_t max_objs; /* Maximum # of IDs to record */ - hid_t *oid_list; /* Array of recorded IDs*/ - size_t obj_count; /* Number of objects counted so far */ + size_t max_objs; /* Maximum # of IDs to record */ + hid_t *oid_list; /* Array of recorded IDs*/ + size_t obj_count; /* Number of objects counted so far */ } H5F_trav_obj_ids_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -81,7 +76,6 @@ static int H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNU /* Callback for getting IDs for open objects in a file */ static int H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key); - /*********************/ /* Package Variables */ /*********************/ @@ -89,12 +83,10 @@ static int H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -107,14 +99,12 @@ H5FL_EXTERN(H5VL_object_t); /* File ID class */ static const H5I_class_t H5I_FILE_CLS[1] = {{ - H5I_FILE, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */ + H5I_FILE, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */ }}; - - /*------------------------------------------------------------------------- * Function: H5F_init * @@ -128,7 +118,7 @@ static const H5I_class_t H5I_FILE_CLS[1] = {{ herr_t H5F_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -137,7 +127,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_init() */ - /*-------------------------------------------------------------------------- NAME H5F__init_package -- Initialize interface-specific information @@ -152,21 +141,20 @@ DESCRIPTION herr_t H5F__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* * Initialize the atom group for the file IDs. */ - if(H5I_register_type(H5I_FILE_CLS) < 0) + if (H5I_register_type(H5I_FILE_CLS) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__init_package() */ - /*------------------------------------------------------------------------- * Function: H5F_term_package * @@ -185,15 +173,15 @@ done: int H5F_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - if(H5I_nmembers(H5I_FILE) > 0) { + if (H5_PKG_INIT_VAR) { + if (H5I_nmembers(H5I_FILE) > 0) { (void)H5I_clear_type(H5I_FILE, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ else { /* Make certain we've cleaned up all the shared file objects */ H5F_sfile_assert_num(0); @@ -202,15 +190,14 @@ H5F_term_package(void) n += (H5I_dec_type_ref(H5I_FILE) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5F_term_package() */ - /*------------------------------------------------------------------------- * Function: H5F__close_cb * @@ -231,7 +218,7 @@ H5F_term_package(void) static herr_t H5F__close_cb(H5VL_object_t *file_vol_obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -239,18 +226,17 @@ H5F__close_cb(H5VL_object_t *file_vol_obj) HDassert(file_vol_obj); /* Close the file */ - if(H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* Free the VOL object */ - if(H5VL_free_object(file_vol_obj) < 0) + if (H5VL_free_object(file_vol_obj) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__close_cb() */ - /*------------------------------------------------------------------------- * Function: H5Fget_create_plist * @@ -268,25 +254,24 @@ done: hid_t H5Fget_create_plist(hid_t file_id) { - H5VL_object_t *vol_obj; /* File info */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Retrieve the file creation property list */ - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_FCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_FCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, H5I_INVALID_HID, "unable to retrieve file creation properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Fget_access_plist * @@ -308,25 +293,24 @@ done: hid_t H5Fget_access_plist(hid_t file_id) { - H5VL_object_t *vol_obj; /* File info */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Retrieve the file's access property list */ - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_FAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_FAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get file access property list") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_access_plist() */ - /*------------------------------------------------------------------------- * Function: H5F__get_all_count_cb * @@ -341,8 +325,8 @@ done: static int H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) { - H5F_trav_obj_cnt_t *udata = (H5F_trav_obj_cnt_t *)key; - int ret_value = H5_ITER_CONT; /* Return value */ + H5F_trav_obj_cnt_t *udata = (H5F_trav_obj_cnt_t *)key; + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -351,7 +335,6 @@ H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, FUNC_LEAVE_NOAPI(ret_value) } /* H5F_get_all_count_cb */ - /*------------------------------------------------------------------------- * Function: H5Fget_obj_count * @@ -367,28 +350,29 @@ H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, ssize_t H5Fget_obj_count(hid_t file_id, unsigned types) { - ssize_t ret_value = 0; /* Return value */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE2("Zs", "iIu", file_id, types); /* Check arguments */ - if(0 == (types & H5F_OBJ_ALL)) + if (0 == (types & H5F_OBJ_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not an object type") /* Perform the query */ /* If the 'special' ID wasn't passed in, just make a normal call to * count the IDs in the file. */ - if(file_id != (hid_t)H5F_OBJ_ALL) { + if (file_id != (hid_t)H5F_OBJ_ALL) { H5VL_object_t *vol_obj; /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file id") /* Get the count */ - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, &ret_value) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, + &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object count in file(s)") } /* If we passed in the 'special' ID, get the count for everything open in the @@ -398,23 +382,23 @@ H5Fget_obj_count(hid_t file_id, unsigned types) H5F_trav_obj_cnt_t udata; /* Set up callback context */ - udata.types = types | H5F_OBJ_LOCAL; + udata.types = types | H5F_OBJ_LOCAL; udata.obj_count = 0; - if(types & H5F_OBJ_FILE) - if(H5I_iterate(H5I_FILE, H5F__get_all_count_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_FILE) + if (H5I_iterate(H5I_FILE, H5F__get_all_count_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over file IDs failed") - if(types & H5F_OBJ_DATASET) - if(H5I_iterate(H5I_DATASET, H5F__get_all_count_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_DATASET) + if (H5I_iterate(H5I_DATASET, H5F__get_all_count_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over dataset IDs failed") - if(types & H5F_OBJ_GROUP) - if(H5I_iterate(H5I_GROUP, H5F__get_all_count_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_GROUP) + if (H5I_iterate(H5I_GROUP, H5F__get_all_count_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over group IDs failed") - if(types & H5F_OBJ_DATATYPE) - if(H5I_iterate(H5I_DATATYPE, H5F__get_all_count_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_DATATYPE) + if (H5I_iterate(H5I_DATATYPE, H5F__get_all_count_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over datatype IDs failed") - if(types & H5F_OBJ_ATTR) - if(H5I_iterate(H5I_ATTR, H5F__get_all_count_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_ATTR) + if (H5I_iterate(H5I_ATTR, H5F__get_all_count_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over attribute IDs failed") /* Set return value */ @@ -425,7 +409,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_obj_count() */ - /*------------------------------------------------------------------------- * Function: H5F__get_all_ids_cb * @@ -440,12 +423,12 @@ done: static int H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key) { - H5F_trav_obj_ids_t *udata = (H5F_trav_obj_ids_t *)key; - int ret_value = H5_ITER_CONT; /* Return value */ + H5F_trav_obj_ids_t *udata = (H5F_trav_obj_ids_t *)key; + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR - if(udata->obj_count >= udata->max_objs) + if (udata->obj_count >= udata->max_objs) HGOTO_DONE(H5_ITER_STOP); /* Add the ID to the array */ @@ -456,7 +439,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__get_all_ids_cb */ - /*------------------------------------------------------------------------- * Function: H5Fget_object_ids * @@ -477,30 +459,31 @@ done: ssize_t H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) { - ssize_t ret_value = 0; /* Return value */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "iIuz*i", file_id, types, max_objs, oid_list); /* Check arguments */ - if(0 == (types & H5F_OBJ_ALL)) + if (0 == (types & H5F_OBJ_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not an object type") - if(!oid_list) + if (!oid_list) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "object ID list cannot be NULL") /* Perform the query */ /* If the 'special' ID wasn't passed in, just make a normal VOL call to * get the IDs from the file. */ - if(file_id != (hid_t)H5F_OBJ_ALL) { + if (file_id != (hid_t)H5F_OBJ_ALL) { H5VL_object_t *vol_obj; /* get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the IDs */ - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_IDS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, max_objs, oid_list, &ret_value) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_IDS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, + max_objs, oid_list, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object ids in file(s)") } /* end if */ /* If we passed in the 'special' ID, get the count for everything open in the @@ -514,24 +497,24 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) H5F_trav_obj_ids_t udata; /* Set up callback context */ - udata.max_objs = max_objs; - udata.oid_list = oid_list; + udata.max_objs = max_objs; + udata.oid_list = oid_list; udata.obj_count = 0; - if(types & H5F_OBJ_FILE) - if(H5I_iterate(H5I_FILE, H5F__get_all_ids_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_FILE) + if (H5I_iterate(H5I_FILE, H5F__get_all_ids_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over file IDs failed") - if(types & H5F_OBJ_DATASET) - if(H5I_iterate(H5I_DATASET, H5F__get_all_ids_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_DATASET) + if (H5I_iterate(H5I_DATASET, H5F__get_all_ids_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over dataset IDs failed") - if(types & H5F_OBJ_GROUP) - if(H5I_iterate(H5I_GROUP, H5F__get_all_ids_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_GROUP) + if (H5I_iterate(H5I_GROUP, H5F__get_all_ids_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over group IDs failed") - if(types & H5F_OBJ_DATATYPE) - if(H5I_iterate(H5I_DATATYPE, H5F__get_all_ids_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_DATATYPE) + if (H5I_iterate(H5I_DATATYPE, H5F__get_all_ids_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over datatype IDs failed") - if(types & H5F_OBJ_ATTR) - if(H5I_iterate(H5I_ATTR, H5F__get_all_ids_cb, &udata, TRUE) < 0) + if (types & H5F_OBJ_ATTR) + if (H5I_iterate(H5I_ATTR, H5F__get_all_ids_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over attribute IDs failed") /* Set return value */ @@ -542,7 +525,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_obj_ids() */ - /*------------------------------------------------------------------------- * Function: H5Fget_vfd_handle * @@ -556,29 +538,29 @@ done: herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii**x", file_id, fapl_id, file_handle); /* Check args */ - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer") /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Retrieve the VFD handle for the file */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_VFD_HANDLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, file_handle, fapl_id) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_VFD_HANDLE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, file_handle, fapl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get VFD handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_vfd_handle() */ - /*------------------------------------------------------------------------- * Function: H5Fis_accessible * @@ -592,31 +574,30 @@ done: htri_t H5Fis_accessible(const char *filename, hid_t fapl_id) { - htri_t ret_value; /* Return value */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "*si", filename, fapl_id); /* Check args */ - if(!filename || !*filename) + if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") /* Check the file access property list */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* Check if file is accessible */ - if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &ret_value) < 0) + if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, + filename, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5") done: FUNC_LEAVE_API(ret_value) } /* end H5Fis_accessible() */ - /*------------------------------------------------------------------------- * Function: H5Fcreate * @@ -643,86 +624,86 @@ done: hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_t *new_file = NULL; /* File struct for new file */ - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_object_t *vol_obj = NULL; /* VOL object for file */ - hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ - hid_t ret_value; /* return value */ + H5F_t * new_file = NULL; /* File struct for new file */ + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_object_t * vol_obj = NULL; /* VOL object for file */ + hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE4("i", "*sIuii", filename, flags, fcpl_id, fapl_id); /* Check/fix arguments */ - if(!filename || !*filename) + if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file name") /* In this routine, we only accept the following flags: * H5F_ACC_EXCL, H5F_ACC_TRUNC and H5F_ACC_SWMR_WRITE */ - if(flags & ~(H5F_ACC_EXCL | H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE)) + if (flags & ~(H5F_ACC_EXCL | H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid flags") /* The H5F_ACC_EXCL and H5F_ACC_TRUNC flags are mutually exclusive */ - if((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC)) + if ((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "mutually exclusive flags for file creation") /* Check file creation property list */ - if(H5P_DEFAULT == fcpl_id) + if (H5P_DEFAULT == fcpl_id) fcpl_id = H5P_FILE_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not file create property list") + else if (TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not file create property list") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") /* Stash a copy of the "top-level" connector property, before any pass-through * connectors modify or unwrap it. */ - if(H5CX_set_vol_connector_prop(&connector_prop) < 0) + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") /* Adjust bit flags by turning on the creation bit and making sure that * the EXCL or TRUNC bit is set. All newly-created files are opened for * reading and writing. */ - if(0 == (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ + if (0 == (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* Create a new file or truncate an existing file through the VOL */ - if(NULL == (new_file = (H5F_t *)H5VL_file_create(&connector_prop, filename, flags, fcpl_id, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (new_file = (H5F_t *)H5VL_file_create(&connector_prop, filename, flags, fcpl_id, fapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to create file") /* Get an atom for the file */ - if((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) + if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") /* Get the file object */ - if(NULL == (vol_obj = H5VL_vol_object(ret_value))) + if (NULL == (vol_obj = H5VL_vol_object(ret_value))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier") /* Make the 'post open' callback */ supported = FALSE; - if(H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") - if(supported) - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (supported) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") done: FUNC_LEAVE_API(ret_value) } /* end H5Fcreate() */ - /*------------------------------------------------------------------------- * Function: H5Fopen * @@ -743,72 +724,74 @@ done: hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - H5F_t *new_file = NULL; /* File struct for new file */ - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_object_t *vol_obj = NULL; /* VOL object for file */ - hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ - hid_t ret_value; /* Return value */ + H5F_t * new_file = NULL; /* File struct for new file */ + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_object_t * vol_obj = NULL; /* VOL object for file */ + hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*sIui", filename, flags, fapl_id); /* Check arguments */ - if(!filename || !*filename) + if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file name") /* Reject undefined flags (~H5F_ACC_PUBLIC_FLAGS) and the H5F_ACC_TRUNC & H5F_ACC_EXCL flags */ - if((flags & ~H5F_ACC_PUBLIC_FLAGS) || - (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) + if ((flags & ~H5F_ACC_PUBLIC_FLAGS) || (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file open flags") /* XXX (VOL MERGE): Might want to move SWMR flag checks to H5F_open() */ /* Asking for SWMR write access on a read-only file is invalid */ - if((flags & H5F_ACC_SWMR_WRITE) && 0 == (flags & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "SWMR write access on a file open for read-only access is not allowed") + if ((flags & H5F_ACC_SWMR_WRITE) && 0 == (flags & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, + "SWMR write access on a file open for read-only access is not allowed") /* Asking for SWMR read access on a non-read-only file is invalid */ - if((flags & H5F_ACC_SWMR_READ) && (flags & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "SWMR read access on a file open for read-write access is not allowed") + if ((flags & H5F_ACC_SWMR_READ) && (flags & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, + "SWMR read access on a file open for read-write access is not allowed") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") /* Stash a copy of the "top-level" connector property, before any pass-through * connectors modify or unwrap it. */ - if(H5CX_set_vol_connector_prop(&connector_prop) < 0) + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") /* Open the file through the VOL layer */ - if(NULL == (new_file = (H5F_t *)H5VL_file_open(&connector_prop, filename, flags, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (new_file = (H5F_t *)H5VL_file_open(&connector_prop, filename, flags, fapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") /* Get an ID for the file */ - if((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) + if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") /* Get the file object */ - if(NULL == (vol_obj = H5VL_vol_object(ret_value))) + if (NULL == (vol_obj = H5VL_vol_object(ret_value))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier") /* Make the 'post open' callback */ supported = FALSE; - if(H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") - if(supported) - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (supported) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") done: FUNC_LEAVE_API(ret_value) } /* end H5Fopen() */ - /*------------------------------------------------------------------------- * Function: H5Fflush * @@ -823,32 +806,32 @@ done: herr_t H5Fflush(hid_t object_id, H5F_scope_t scope) { - H5VL_object_t *vol_obj = NULL; /* Object info */ - H5I_type_t obj_type; /* Type of object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object info */ + H5I_type_t obj_type; /* Type of object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iFs", object_id, scope); /* Get the type of object we're flushing + sanity check */ obj_type = H5I_get_type(object_id); - if(H5I_FILE != obj_type && H5I_GROUP != obj_type && H5I_DATATYPE != obj_type && - H5I_DATASET != obj_type && H5I_ATTR != obj_type) + if (H5I_FILE != obj_type && H5I_GROUP != obj_type && H5I_DATATYPE != obj_type && + H5I_DATASET != obj_type && H5I_ATTR != obj_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* get the file object */ - if(NULL == (vol_obj = H5VL_vol_object(object_id))) + if (NULL == (vol_obj = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Flush the object */ - if(H5VL_file_specific(vol_obj, H5VL_FILE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)obj_type, (int)scope) < 0) + if (H5VL_file_specific(vol_obj, H5VL_FILE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)obj_type, + (int)scope) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file") done: FUNC_LEAVE_API(ret_value) } /* end H5Fflush() */ - /*------------------------------------------------------------------------- * Function: H5Fclose * @@ -866,24 +849,23 @@ done: herr_t H5Fclose(hid_t file_id) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check arguments */ - if(H5I_FILE != H5I_get_type(file_id)) + if (H5I_FILE != H5I_get_type(file_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID") /* Close the file */ - if(H5I_dec_app_ref(file_id) < 0) + if (H5I_dec_app_ref(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "closing file ID failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Fclose() */ - /*------------------------------------------------------------------------- * Function: H5Fdelete * @@ -896,49 +878,50 @@ done: herr_t H5Fdelete(const char *filename, hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - htri_t is_hdf5 = FAIL; - herr_t ret_value = SUCCEED; + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + htri_t is_hdf5 = FAIL; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "*si", filename, fapl_id); /* Check args */ - if(!filename || !*filename) + if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") /* Stash a copy of the "top-level" connector property, before any pass-through * connectors modify or unwrap it. */ - if(H5CX_set_vol_connector_prop(&connector_prop) < 0) + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") /* Make sure this is HDF5 storage for this VOL connector */ - if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &is_hdf5) < 0) + if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, + filename, &is_hdf5) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5") - if(!is_hdf5) + if (!is_hdf5) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "not an HDF5 file") /* Delete the file */ - if(H5VL_file_specific(NULL, H5VL_FILE_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, filename, &ret_value) < 0) + if (H5VL_file_specific(NULL, H5VL_FILE_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, + filename, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDELETEFILE, FAIL, "unable to delete the file") done: FUNC_LEAVE_API(ret_value) } /* end H5Fdelete() */ - /*------------------------------------------------------------------------- * Function: H5Freopen * @@ -957,40 +940,41 @@ done: hid_t H5Freopen(hid_t file_id) { - void *file = NULL; /* File struct for new file */ - H5VL_object_t *vol_obj = NULL; /* VOL object for file */ - hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * file = NULL; /* File struct for new file */ + H5VL_object_t *vol_obj = NULL; /* VOL object for file */ + hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Reopen the file */ - if(H5VL_file_specific(vol_obj, H5VL_FILE_REOPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &file) < 0) + if (H5VL_file_specific(vol_obj, H5VL_FILE_REOPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file via the VOL connector") /* Make sure that worked */ - if(NULL == file) + if (NULL == file) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file") /* Get an atom for the file */ - if((ret_value = H5VL_register(H5I_FILE, file, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_FILE, file, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") /* Get the file object */ - if(NULL == (vol_obj = H5VL_vol_object(ret_value))) + if (NULL == (vol_obj = H5VL_vol_object(ret_value))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier") /* Make the 'post open' callback */ supported = FALSE; - if(H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") - if(supported) - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (supported) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") done: @@ -998,7 +982,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Freopen() */ - /*------------------------------------------------------------------------- * Function: H5Fget_intent * @@ -1018,15 +1001,16 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags) H5TRACE2("e", "i*Iu", file_id, intent_flags); /* If no intent flags were passed in, exit quietly */ - if(intent_flags) { - H5VL_object_t *vol_obj; /* File info */ + if (intent_flags) { + H5VL_object_t *vol_obj; /* File info */ /* Get the internal file structure */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the flags */ - if((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_INTENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, intent_flags)) < 0) + if ((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_INTENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, intent_flags)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's intent flags") } /* end if */ @@ -1034,7 +1018,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_intent() */ - /*------------------------------------------------------------------------- * Function: H5Fget_fileno * @@ -1054,15 +1037,16 @@ H5Fget_fileno(hid_t file_id, unsigned long *fnumber) H5TRACE2("e", "i*Ul", file_id, fnumber); /* If no fnumber pointer was passed in, exit quietly */ - if(fnumber) { - H5VL_object_t *vol_obj; /* File info */ + if (fnumber) { + H5VL_object_t *vol_obj; /* File info */ /* Get the internal file structure */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the flags */ - if((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_FILENO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fnumber)) < 0) + if ((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_FILENO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fnumber)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's 'file number'") } /* end if */ @@ -1070,7 +1054,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_fileno() */ - /*------------------------------------------------------------------------- * Function: H5Fget_freespace * @@ -1084,24 +1067,24 @@ hssize_t H5Fget_freespace(hid_t file_id) { H5VL_object_t *vol_obj = NULL; - hssize_t ret_value; /* Return value */ + hssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Hs", "i", file_id); /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the amount of free space in the file */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FREE_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FREE_SPACE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free space") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_freespace() */ - /*------------------------------------------------------------------------- * Function: H5Fget_filesize * @@ -1116,27 +1099,27 @@ done: herr_t H5Fget_filesize(hid_t file_id, hsize_t *size) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", file_id, size); /* Check args */ - if(!size) + if (!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size parameter cannot be NULL") - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the file size */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, size) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_filesize() */ - /*------------------------------------------------------------------------- * Function: H5Fget_file_image * @@ -1177,25 +1160,25 @@ done: ssize_t H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) { - H5VL_object_t *vol_obj; /* File object for file ID */ - ssize_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* File object for file ID */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file ID") /* Get the file image */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FILE_IMAGE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf_ptr, &ret_value, buf_len) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FILE_IMAGE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, buf_ptr, &ret_value, buf_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file image") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_file_image() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_config * @@ -1213,29 +1196,29 @@ done: herr_t H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, config_ptr); /* Check args */ - if((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) + if ((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad config_ptr") /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the metadata cache configuration */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_CONF, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, config_ptr) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_CONF, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache configuration") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_config() */ - /*------------------------------------------------------------------------- * Function: H5Fset_mdc_config * @@ -1250,25 +1233,25 @@ done: herr_t H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, config_ptr); /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Set the metadata cache configuration */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MDC_CONFIG, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, config_ptr) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MDC_CONFIG, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set metadata cache configuration") done: FUNC_LEAVE_API(ret_value) } /* H5Fset_mdc_config() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_hit_rate * @@ -1284,27 +1267,27 @@ done: herr_t H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) { - H5VL_object_t *vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*d", file_id, hit_rate_ptr); /* Check args */ - if(NULL == hit_rate_ptr) + if (NULL == hit_rate_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer") - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the current hit rate */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_HR, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, hit_rate_ptr) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_HR, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + hit_rate_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_hit_rate() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_size * @@ -1319,29 +1302,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, - size_t *cur_size_ptr, int *cur_num_entries_ptr) +H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, + int *cur_num_entries_ptr) { - H5VL_object_t *vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*z*z*z*Is", file_id, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the size data */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC size") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_size() */ - /*------------------------------------------------------------------------- * Function: H5Freset_mdc_hit_rate_stats * @@ -1361,25 +1344,25 @@ done: herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Reset the hit rate statistic */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset cache hit rate") done: FUNC_LEAVE_API(ret_value) } /* H5Freset_mdc_hit_rate_stats() */ - /*------------------------------------------------------------------------- * Function: H5Fget_name * @@ -1400,33 +1383,34 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) +H5Fget_name(hid_t obj_id, char *name /*out*/, size_t size) { - H5VL_object_t *vol_obj = NULL; - H5I_type_t type; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", obj_id, name, size); /* Check the type */ type = H5I_get_type(obj_id); - if(H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && H5I_ATTR != type) + if (H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && + H5I_ATTR != type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file or file object") /* Get the file object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the filename via the VOL */ - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)type, size, name, &ret_value) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)type, size, + name, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file name") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_name() */ - /*------------------------------------------------------------------------- * Function: H5Fget_info2 * @@ -1443,35 +1427,36 @@ done: herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) { - H5VL_object_t *vol_obj = NULL; - H5I_type_t type; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", obj_id, finfo); /* Check args */ - if(!finfo) + if (!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file info pointer can't be NULL") /* Check the type */ type = H5I_get_type(obj_id); - if(H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && H5I_ATTR != type) + if (H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && + H5I_ATTR != type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Get the file object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the file information */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)type, finfo) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)type, finfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info2() */ - /*------------------------------------------------------------------------- * Function: H5Fget_metadata_read_retry_info * @@ -1485,29 +1470,29 @@ done: herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) { - H5VL_object_t *vol_obj = NULL; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File object for file ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, info); /* Check args */ - if(!info) + if (!info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* Get the file pointer */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the retry info */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, info) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't get metadata read retry info") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_metadata_read_retry_info() */ - /*------------------------------------------------------------------------- * Function: H5Fget_free_sections * @@ -1521,30 +1506,29 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, - H5F_sect_info_t *sect_info/*out*/) +H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info /*out*/) { - H5VL_object_t *vol_obj = NULL; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t *vol_obj = NULL; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") - if(sect_info && nsects == 0) + if (sect_info && nsects == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "nsects must be > 0") /* Get the free-space section information in the file */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FREE_SECTIONS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, sect_info, &ret_value, (int)type, nsects) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FREE_SECTIONS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, sect_info, &ret_value, (int)type, nsects) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free sections") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_free_sections() */ - /*------------------------------------------------------------------------- * Function: H5Fclear_elink_file_cache * @@ -1559,25 +1543,25 @@ done: herr_t H5Fclear_elink_file_cache(hid_t file_id) { - H5VL_object_t *vol_obj; /* File */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Release the EFC */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") done: FUNC_LEAVE_API(ret_value) } /* end H5Fclear_elink_file_cache() */ - /*------------------------------------------------------------------------- * Function: H5Fstart_swmr_write * @@ -1615,29 +1599,29 @@ done: herr_t H5Fstart_swmr_write(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Start SWMR writing */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_START_SWMR_WRITE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_START_SWMR_WRITE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to start SWMR writing") done: FUNC_LEAVE_API(ret_value) } /* end H5Fstart_swmr_write() */ - /*------------------------------------------------------------------------- * Function: H5Fstart_mdc_logging * @@ -1651,25 +1635,25 @@ done: herr_t H5Fstart_mdc_logging(hid_t file_id) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Sanity check */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_START_MDC_LOGGING, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_START_MDC_LOGGING, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") done: FUNC_LEAVE_API(ret_value) } /* H5Fstart_mdc_logging() */ - /*------------------------------------------------------------------------- * Function: H5Fstop_mdc_logging * @@ -1684,25 +1668,25 @@ done: herr_t H5Fstop_mdc_logging(hid_t file_id) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Sanity check */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_STOP_MDC_LOGGING, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_STOP_MDC_LOGGING, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") done: FUNC_LEAVE_API(ret_value) } /* H5Fstop_mdc_logging() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_logging_status * @@ -1715,28 +1699,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, - hbool_t *is_currently_logging) +H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, hbool_t *is_currently_logging) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*b*b", file_id, is_enabled, is_currently_logging); /* Sanity check */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, is_enabled, is_currently_logging) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, is_enabled, is_currently_logging) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_logging_status() */ - /*------------------------------------------------------------------------- * Function: H5Fset_libver_bounds * @@ -1752,29 +1735,29 @@ done: herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) { - H5VL_object_t *vol_obj; /* File as VOL object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File as VOL object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iFvFv", file_id, low, high); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Set the library's version bounds */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, low, high) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, low, high) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: FUNC_LEAVE_API(ret_value) } /* end H5Fset_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5Fformat_convert (Internal) * @@ -1789,29 +1772,29 @@ done: herr_t H5Fformat_convert(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; /* File */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "file_id parameter is not a valid file identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Convert the format */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_FORMAT_CONVERT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_FORMAT_CONVERT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") done: FUNC_LEAVE_API(ret_value) } /* end H5Fformat_convert() */ - /*------------------------------------------------------------------------- * Function: H5Freset_page_buffering_stats * @@ -1824,25 +1807,25 @@ done: herr_t H5Freset_page_buffering_stats(hid_t file_id) { - H5VL_object_t *vol_obj; /* File to reset stats on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File to reset stats on */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Reset the statistics */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset stats for page buffering") done: FUNC_LEAVE_API(ret_value) -} /* H5Freset_page_buffering_stats() */ +} /* H5Freset_page_buffering_stats() */ - /*------------------------------------------------------------------------- * Function: H5Fget_page_buffering_stats * @@ -1853,31 +1836,31 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], - unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]) +H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], unsigned misses[2], + unsigned evictions[2], unsigned bypasses[2]) { - H5VL_object_t *vol_obj; /* File object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*Iu*Iu*Iu*Iu*Iu", file_id, accesses, hits, misses, evictions, bypasses); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - if(NULL == accesses || NULL == hits || NULL == misses || NULL == evictions || NULL == bypasses) + if (NULL == accesses || NULL == hits || NULL == misses || NULL == evictions || NULL == bypasses) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL input parameters for stats") /* Get the statistics */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, accesses, hits, misses, evictions, bypasses) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, accesses, hits, misses, evictions, bypasses) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_page_buffering_stats() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_image_info * @@ -1894,25 +1877,25 @@ done: herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_len) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*a*h", file_id, image_addr, image_len); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Go get the address and size of the cache image */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, image_addr, image_len) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, image_addr, image_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_image_info() */ - /*------------------------------------------------------------------------- * Function: H5Fget_eoa * @@ -1927,20 +1910,21 @@ done: herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*a", file_id, eoa); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Only do work if valid pointer to fill in */ - if(eoa) { + if (eoa) { /* Retrieve the EOA for the file */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_EOA, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, eoa) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_EOA, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + eoa) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") } /* end if */ @@ -1948,7 +1932,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Fget_eoa() */ - /*------------------------------------------------------------------------- * Function: H5Fincrement_filesize * @@ -1961,25 +1944,25 @@ done: herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment) { - H5VL_object_t *vol_obj; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", file_id, increment); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Increment the file size */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_INCR_FILESIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, increment) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_INCR_FILESIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + increment) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to increment file size") done: FUNC_LEAVE_API(ret_value) } /* H5Fincrement_filesize() */ - /*------------------------------------------------------------------------- * Function: H5Fget_dset_no_attrs_hint * @@ -1993,27 +1976,27 @@ done: herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", file_id, minimize); - if(NULL == minimize) + if (NULL == minimize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "out pointer 'minimize' cannot be NULL") vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); - if(NULL == vol_obj) + if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, minimize) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, minimize) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_dset_no_attrs_hint */ - /*------------------------------------------------------------------------- * Function: H5Fset_dset_no_attrs_hint * @@ -2034,17 +2017,17 @@ H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize) H5TRACE2("e", "ib", file_id, minimize); vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); - if(NULL == vol_obj) + if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, minimize) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, minimize) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") done: FUNC_LEAVE_API(ret_value) } /* H5Fset_dset_no_attrs_hint */ - /*------------------------------------------------------------------------- * Function: H5Fvfd_swmr_end_tick() * @@ -2056,23 +2039,24 @@ done: herr_t H5Fvfd_swmr_end_tick(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ /* Note: use the version of FUNC_ENTER_API without EOT processing */ FUNC_ENTER_API_NO_EOT(FAIL) H5TRACE1("e", "i", file_id); vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); - if(NULL == vol_obj) + if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Check on this when go parallel for VFD SWMR */ /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_VFD_SWMR_END_TICK, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_VFD_SWMR_END_TICK, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to trigger end of tick processing for VFD SWMR") done: @@ -2080,7 +2064,6 @@ done: FUNC_LEAVE_API_NO_EOT(ret_value) } /* H5Fvfd_swmr_end_tick() */ - /*------------------------------------------------------------------------- * Function: H5Fvfd_swmr_disable_end_of_tick() * @@ -2093,29 +2076,29 @@ herr_t H5Fvfd_swmr_disable_end_of_tick(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); - if(NULL == vol_obj) + if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Check on this when go parallel for VFD SWMR */ /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_VFD_SWMR_DISABLE_EOT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_VFD_SWMR_DISABLE_EOT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to disable EOT for VFD SWMR") done: FUNC_LEAVE_API(ret_value) } /* H5Fvfd_swmr_disable_end_of_tick() */ - /*------------------------------------------------------------------------- * Function: H5Fvfd_swmr_enable_end_of_tick() * @@ -2128,22 +2111,23 @@ herr_t H5Fvfd_swmr_enable_end_of_tick(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); - if(NULL == vol_obj) + if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Check on this when go parallel for VFD SWMR */ /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_VFD_SWMR_ENABLE_EOT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_VFD_SWMR_ENABLE_EOT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to enable EOT for VFD SWMR") done: diff --git a/src/H5FA.c b/src/H5FA.c index f8bb094..f1b690c 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -27,45 +27,38 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static H5FA_t *H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, - void *ctx_udata); - +static H5FA_t *H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata); /*********************/ /* Package Variables */ @@ -80,17 +73,15 @@ hbool_t H5_PKG_INIT_VAR = FALSE; * client class.. */ const H5FA_class_t *const H5FA_client_class_g[] = { - H5FA_CLS_CHUNK, /* 0 - H5FA_CLS_CHUNK_ID */ - H5FA_CLS_FILT_CHUNK, /* 1 - H5FA_CLS_FILT_CHUNK_ID */ - H5FA_CLS_TEST, /* ? - H5FA_CLS_TEST_ID */ + H5FA_CLS_CHUNK, /* 0 - H5FA_CLS_CHUNK_ID */ + H5FA_CLS_FILT_CHUNK, /* 1 - H5FA_CLS_FILT_CHUNK_ID */ + H5FA_CLS_TEST, /* ? - H5FA_CLS_TEST_ID */ }; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -101,8 +92,6 @@ H5FL_DEFINE_STATIC(H5FA_t); /* Declare a PQ free list to manage the element */ H5FL_BLK_DEFINE(fa_native_elmt); - - /*------------------------------------------------------------------------- * Function: H5FA__new * @@ -117,13 +106,12 @@ H5FL_BLK_DEFINE(fa_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -H5FA_t *, NULL, NULL, -H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) +BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, + H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + H5FA_t * fa = NULL; /* Pointer to new fixed array */ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ /* * Check arguments. @@ -132,25 +120,25 @@ H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) HDassert(H5F_addr_defined(fa_addr)); /* Allocate fixed array wrapper */ - if(NULL == (fa = H5FL_CALLOC(H5FA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") + if (NULL == (fa = H5FL_CALLOC(H5FA_t))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") /* Lock the array header into memory */ - if(NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") /* Check for pending array deletion */ - if(from_open && hdr->pending_delete) + if (from_open && hdr->pending_delete) H5E_THROW(H5E_CANTOPENOBJ, "can't open fixed array pending deletion") /* Point fixed array wrapper at header and bump it's ref count */ fa->hdr = hdr; - if(H5FA__hdr_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + if (H5FA__hdr_incr(fa->hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") /* Increment # of files using this array header */ - if(H5FA__hdr_fuse_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + if (H5FA__hdr_fuse_incr(fa->hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ fa->f = f; @@ -158,17 +146,16 @@ H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) /* Set the return value */ ret_value = fa; -CATCH + CATCH - if(hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") - if(!ret_value) - if(fa && H5FA_close(fa) < 0) + if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + if (!ret_value) + if (fa && H5FA_close(fa) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") -END_FUNC(STATIC) /* end H5FA__new() */ +END_FUNC(STATIC) /* end H5FA__new() */ - /*------------------------------------------------------------------------- * Function: H5FA_create * @@ -182,13 +169,12 @@ END_FUNC(STATIC) /* end H5FA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -H5FA_t *, NULL, NULL, -H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) +BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, + H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array */ - haddr_t fa_addr; /* Fixed array header address */ + H5FA_t *fa = NULL; /* Pointer to new fixed array */ + haddr_t fa_addr; /* Fixed array header address */ /* * Check arguments. @@ -200,25 +186,24 @@ H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) HDcompile_assert(H5FA_NUM_CLS_ID == NELMTS(H5FA_client_class_g)); /* Create fixed array header */ - if(HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, cparam, ctx_udata))) + if (HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, cparam, ctx_udata))) H5E_THROW(H5E_CANTINIT, "can't create fixed array header") /* Allocate and initialize new fixed array wrapper */ - if(NULL == (fa = H5FA__new(f, fa_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + if (NULL == (fa = H5FA__new(f, fa_addr, FALSE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; -CATCH + CATCH - if(!ret_value) - if(fa && H5FA_close(fa) < 0) + if (!ret_value) + if (fa && H5FA_close(fa) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_create() */ +END_FUNC(PRIV) /* end H5FA_create() */ - /*------------------------------------------------------------------------- * Function: H5FA_open * @@ -232,12 +217,10 @@ END_FUNC(PRIV) /* end H5FA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -H5FA_t *, NULL, NULL, -H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ /* * Check arguments. @@ -246,21 +229,20 @@ H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) HDassert(H5F_addr_defined(fa_addr)); /* Allocate and initialize new fixed array wrapper */ - if(NULL == (fa = H5FA__new(f, fa_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + if (NULL == (fa = H5FA__new(f, fa_addr, TRUE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; -CATCH + CATCH - if(!ret_value) - if(fa && H5FA_close(fa) < 0) + if (!ret_value) + if (fa && H5FA_close(fa) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_open() */ +END_FUNC(PRIV) /* end H5FA_open() */ - /*------------------------------------------------------------------------- * Function: H5FA_get_nelmts * @@ -273,9 +255,7 @@ END_FUNC(PRIV) /* end H5FA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) /* Local variables */ @@ -288,9 +268,8 @@ H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) /* Retrieve the current number of elements in the fixed array */ *nelmts = fa->hdr->stats.nelmts; -END_FUNC(PRIV) /* end H5FA_get_nelmts() */ +END_FUNC(PRIV) /* end H5FA_get_nelmts() */ - /*------------------------------------------------------------------------- * Function: H5FA_get_addr * @@ -303,9 +282,7 @@ END_FUNC(PRIV) /* end H5FA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) /* Local variables */ @@ -319,9 +296,8 @@ H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) /* Retrieve the address of the fixed array's header */ *addr = fa->hdr->addr; -END_FUNC(PRIV) /* end H5FA_get_addr() */ +END_FUNC(PRIV) /* end H5FA_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5FA_set * @@ -334,17 +310,16 @@ END_FUNC(PRIV) /* end H5FA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt)) /* Local variables */ - H5FA_hdr_t *hdr = fa->hdr; /* Header for fixed array */ - H5FA_dblock_t *dblock = NULL; /* Pointer to fixed array Data block */ - H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to fixed array Data block page */ - unsigned dblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting fixed array Data block */ - unsigned dblk_page_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting FIxed Array Data block page */ - hbool_t hdr_dirty = FALSE; /* Whether header information changed */ + H5FA_hdr_t * hdr = fa->hdr; /* Header for fixed array */ + H5FA_dblock_t * dblock = NULL; /* Pointer to fixed array Data block */ + H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to fixed array Data block page */ + unsigned dblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting fixed array Data block */ + unsigned dblk_page_cache_flags = + H5AC__NO_FLAGS_SET; /* Flags to unprotecting FIxed Array Data block page */ + hbool_t hdr_dirty = FALSE; /* Whether header information changed */ /* * Check arguments. @@ -356,80 +331,84 @@ H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt)) hdr->f = fa->f; /* Check if we need to create the fixed array data block */ - if(!H5F_addr_defined(hdr->dblk_addr)) { + if (!H5F_addr_defined(hdr->dblk_addr)) { /* Create the data block */ hdr->dblk_addr = H5FA__dblock_create(hdr, &hdr_dirty); - if(!H5F_addr_defined(hdr->dblk_addr)) + if (!H5F_addr_defined(hdr->dblk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create fixed array data block") } /* end if */ HDassert(idx < hdr->cparam.nelmts); /* Protect data block */ - if(NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)hdr->dblk_addr) + if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paging data block */ - if(!dblock->npages) { + if (!dblock->npages) { /* Set element in data block */ - H5MM_memcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, + hdr->cparam.cls->nat_elmt_size); dblock_cache_flags |= H5AC__DIRTIED_FLAG; - } /* end if */ - else { /* paging */ - size_t page_idx; /* Index of page within data block */ - size_t dblk_page_nelmts; /* # of elements in a data block page */ - size_t elmt_idx; /* Element index within the page */ - haddr_t dblk_page_addr; /* Address of data block page */ + } /* end if */ + else { /* paging */ + size_t page_idx; /* Index of page within data block */ + size_t dblk_page_nelmts; /* # of elements in a data block page */ + size_t elmt_idx; /* Element index within the page */ + haddr_t dblk_page_addr; /* Address of data block page */ /* Compute the page & element index */ page_idx = (size_t)(idx / dblock->dblk_page_nelmts); elmt_idx = (size_t)(idx % dblock->dblk_page_nelmts); /* Get the address of the data block page */ - dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + - ((hsize_t)page_idx * dblock->dblk_page_size); + dblk_page_addr = + dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + ((hsize_t)page_idx * dblock->dblk_page_size); /* Check for using last page, to set the number of elements on the page */ - if((page_idx + 1) == dblock->npages) + if ((page_idx + 1) == dblock->npages) dblk_page_nelmts = dblock->last_page_nelmts; else dblk_page_nelmts = dblock->dblk_page_nelmts; /* Check if the page has been created yet */ - if(!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { + if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Create the data block page */ - if(H5FA__dblk_page_create(hdr, dblk_page_addr, dblk_page_nelmts) < 0) + if (H5FA__dblk_page_create(hdr, dblk_page_addr, dblk_page_nelmts) < 0) H5E_THROW(H5E_CANTCREATE, "unable to create data block page") - /* Mark data block page as initialized in data block */ - H5VM_bit_set(dblock->dblk_page_init, page_idx, TRUE); - dblock_cache_flags |= H5AC__DIRTIED_FLAG; - } /* end if */ + /* Mark data block page as initialized in data block */ + H5VM_bit_set(dblock->dblk_page_init, page_idx, TRUE); + dblock_cache_flags |= H5AC__DIRTIED_FLAG; + } /* end if */ /* Protect the data block page */ - if(NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr) + if (NULL == + (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Set the element in the data block page */ - H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, + hdr->cparam.cls->nat_elmt_size); dblk_page_cache_flags |= H5AC__DIRTIED_FLAG; } /* end else */ -CATCH + CATCH /* Check for header modified */ - if(hdr_dirty) - if(H5FA__hdr_modified(hdr) < 0) + if (hdr_dirty) + if (H5FA__hdr_modified(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as modified") /* Release resources */ - if(dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) + if (dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") - if(dblk_page && H5FA__dblk_page_unprotect(dblk_page, dblk_page_cache_flags) < 0) + if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, dblk_page_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_set() */ +END_FUNC(PRIV) /* end H5FA_set() */ - /*------------------------------------------------------------------------- * Function: H5FA_get * @@ -442,14 +421,12 @@ END_FUNC(PRIV) /* end H5FA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt)) /* Local variables */ - H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ - H5FA_dblock_t *dblock = NULL; /* Pointer to data block for FA */ - H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for FA */ + H5FA_hdr_t * hdr = fa->hdr; /* Header for FA */ + H5FA_dblock_t * dblock = NULL; /* Pointer to data block for FA */ + H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for FA */ /* * Check arguments. @@ -461,72 +438,78 @@ H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt)) hdr->f = fa->f; /* Check if the fixed array data block has been allocated on disk yet */ - if(!H5F_addr_defined(hdr->dblk_addr)) { + if (!H5F_addr_defined(hdr->dblk_addr)) { /* Call the class's 'fill' callback */ - if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) + if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") } /* end if */ else { /* Get the data block */ HDassert(H5F_addr_defined(hdr->dblk_addr)); - if(NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)hdr->dblk_addr) + if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paged data block */ - if(!dblock->npages) + if (!dblock->npages) /* Retrieve element from data block */ - H5MM_memcpy(elmt, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), hdr->cparam.cls->nat_elmt_size); - else { /* paging */ - size_t page_idx; /* Index of page within data block */ + H5MM_memcpy(elmt, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), + hdr->cparam.cls->nat_elmt_size); + else { /* paging */ + size_t page_idx; /* Index of page within data block */ /* Compute the page index */ page_idx = (size_t)(idx / dblock->dblk_page_nelmts); /* Check if the page is defined yet */ - if(!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { + if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Call the class's 'fill' callback */ - if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) + if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") /* We've retrieved the value, leave now */ H5_LEAVE(SUCCEED) - } /* end if */ - else { /* get the page */ - size_t dblk_page_nelmts; /* # of elements in a data block page */ - size_t elmt_idx; /* Element index within the page */ - haddr_t dblk_page_addr; /* Address of data block page */ + } /* end if */ + else { /* get the page */ + size_t dblk_page_nelmts; /* # of elements in a data block page */ + size_t elmt_idx; /* Element index within the page */ + haddr_t dblk_page_addr; /* Address of data block page */ /* Compute the element index */ elmt_idx = (size_t)(idx % dblock->dblk_page_nelmts); /* Compute the address of the data block */ - dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + ((hsize_t)page_idx * dblock->dblk_page_size); + dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + + ((hsize_t)page_idx * dblock->dblk_page_size); /* Check for using last page, to set the number of elements on the page */ - if((page_idx + 1) == dblock->npages) + if ((page_idx + 1) == dblock->npages) dblk_page_nelmts = dblock->last_page_nelmts; else dblk_page_nelmts = dblock->dblk_page_nelmts; /* Protect the data block page */ - if(NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr) + if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, + H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Retrieve element from data block */ - H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), + hdr->cparam.cls->nat_elmt_size); } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ -CATCH - if(dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) + CATCH + if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") - if(dblk_page && H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) + if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_get() */ +END_FUNC(PRIV) /* end H5FA_get() */ - /*------------------------------------------------------------------------- * Function: H5FA_close * @@ -539,13 +522,11 @@ END_FUNC(PRIV) /* end H5FA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5FA_close(H5FA_t *fa)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Local variables */ - hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ - haddr_t fa_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ + haddr_t fa_addr = HADDR_UNDEF; /* Address of array (for deletion) */ /* * Check arguments. @@ -553,46 +534,47 @@ H5FA_close(H5FA_t *fa)) HDassert(fa); /* Close the header, if it was set */ - if(fa->hdr) { - /* Decrement file reference & check if this is the last open fixed array using the shared array header */ - if(0 == H5FA__hdr_fuse_decr(fa->hdr)) { + if (fa->hdr) { + /* Decrement file reference & check if this is the last open fixed array using the shared array header + */ + if (0 == H5FA__hdr_fuse_decr(fa->hdr)) { /* Set the shared array header's file context for this operation */ fa->hdr->f = fa->f; /* Shut down anything that can't be put in the header's 'flush' callback */ /* Check for pending array deletion */ - if(fa->hdr->pending_delete) { + if (fa->hdr->pending_delete) { /* Set local info, so array deletion can occur after decrementing the * header's ref count */ pending_delete = TRUE; - fa_addr = fa->hdr->addr; + fa_addr = fa->hdr->addr; } /* end if */ - } /* end if */ + } /* end if */ /* Check for pending array deletion */ - if(pending_delete) { - H5FA_hdr_t *hdr; /* Another pointer to fixed array header */ + if (pending_delete) { + H5FA_hdr_t *hdr; /* Another pointer to fixed array header */ #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Header's status in the metadata cache */ - - /* Check the header's status in the metadata cache */ - if(H5AC_get_entry_status(fa->f, fa_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for fixed array header") - - /* Sanity checks on header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PINNED); - HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); -} + { + unsigned hdr_status = 0; /* Header's status in the metadata cache */ + + /* Check the header's status in the metadata cache */ + if (H5AC_get_entry_status(fa->f, fa_addr, &hdr_status) < 0) + H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for fixed array header") + + /* Sanity checks on header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PINNED); + HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); + } #endif /* NDEBUG */ /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = H5FA__hdr_protect(fa->f, fa_addr, NULL, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5FA__hdr_protect(fa->f, fa_addr, NULL, H5AC__NO_FLAGS_SET))) H5E_THROW(H5E_CANTLOAD, "unable to load fixed array header") /* Set the shared array header's file context for this operation */ @@ -602,11 +584,11 @@ H5FA_close(H5FA_t *fa)) /* (don't put in H5FA_hdr_fuse_decr() as the array header may be evicted * immediately -QAK) */ - if(H5FA__hdr_decr(fa->hdr) < 0) + if (H5FA__hdr_decr(fa->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ - if(H5FA__hdr_delete(hdr) < 0) + if (H5FA__hdr_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") } /* end if */ else { @@ -614,19 +596,18 @@ H5FA_close(H5FA_t *fa)) /* (don't put in H5FA_hdr_fuse_decr() as the array header may be evicted * immediately -QAK) */ - if(H5FA__hdr_decr(fa->hdr) < 0) + if (H5FA__hdr_decr(fa->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") } /* end else */ - } /* end if */ + } /* end if */ /* Release the fixed array wrapper */ fa = H5FL_FREE(H5FA_t, fa); -CATCH + CATCH -END_FUNC(PRIV) /* end H5FA_close() */ +END_FUNC(PRIV) /* end H5FA_close() */ - /*------------------------------------------------------------------------- * Function: H5FA_delete * @@ -639,12 +620,10 @@ END_FUNC(PRIV) /* end H5FA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ /* * Check arguments. @@ -653,31 +632,31 @@ H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) HDassert(H5F_addr_defined(fa_addr)); /* Lock the array header into memory */ - if(NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", (unsigned long long)fa_addr) + if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) /* Check for files using shared array header */ - if(hdr->file_rc) + if (hdr->file_rc) hdr->pending_delete = TRUE; else { /* Set the shared array header's file context for this operation */ hdr->f = f; /* Delete array now, starting with header (unprotects header) */ - if(H5FA__hdr_delete(hdr) < 0) + if (H5FA__hdr_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") hdr = NULL; } /* end if */ -CATCH + CATCH /* Unprotect the header, if an error occurred */ - if(hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") -END_FUNC(PRIV) /* end H5FA_delete() */ +END_FUNC(PRIV) /* end H5FA_delete() */ - /*------------------------------------------------------------------------- * Function: H5FA_iterate * @@ -693,14 +672,13 @@ END_FUNC(PRIV) /* end H5FA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -int, H5_ITER_CONT, H5_ITER_ERROR, -H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) +BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, + H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) /* Local variables */ - uint8_t *elmt = NULL; - hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + uint8_t *elmt = NULL; + hsize_t u; + int cb_ret = H5_ITER_CONT; /* Return value from callback */ /* * Check arguments. @@ -710,30 +688,29 @@ H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) HDassert(udata); /* Allocate space for a native array element */ - if(NULL == (elmt = H5FL_BLK_MALLOC(fa_native_elmt, fa->hdr->cparam.cls->nat_elmt_size))) + if (NULL == (elmt = H5FL_BLK_MALLOC(fa_native_elmt, fa->hdr->cparam.cls->nat_elmt_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element") /* Iterate over all elements in array */ - for(u = 0; u < fa->hdr->stats.nelmts && cb_ret == H5_ITER_CONT; u++) { + for (u = 0; u < fa->hdr->stats.nelmts && cb_ret == H5_ITER_CONT; u++) { /* Get array element */ - if(H5FA_get(fa, u, elmt) < 0) + if (H5FA_get(fa, u, elmt) < 0) H5E_THROW(H5E_CANTGET, "unable to delete fixed array") /* Make callback */ - if((cb_ret = (*op)(u, elmt, udata)) < 0) { + if ((cb_ret = (*op)(u, elmt, udata)) < 0) { H5E_PRINTF(H5E_BADITER, "iterator function failed"); H5_LEAVE(cb_ret) } /* end if */ - } /* end for */ + } /* end for */ -CATCH + CATCH - if(elmt) + if (elmt) elmt = H5FL_BLK_FREE(fa_native_elmt, elmt); -END_FUNC(PRIV) /* end H5FA_iterate() */ +END_FUNC(PRIV) /* end H5FA_iterate() */ - /*------------------------------------------------------------------------- * Function: H5FA_depend * @@ -747,12 +724,10 @@ END_FUNC(PRIV) /* end H5FA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) /* Local variables */ - H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ /* * Check arguments. @@ -766,7 +741,7 @@ H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) * and another data structure in the file has already been set up. * If it hasn't, do so now. */ - if(NULL == hdr->parent) { + if (NULL == hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); @@ -774,16 +749,15 @@ H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) hdr->f = fa->f; /* Add the fixed array as a child of the parent (proxy) */ - if(H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) + if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) H5E_THROW(H5E_CANTSET, "unable to add fixed array as child of proxy") hdr->parent = parent; } /* end if */ -CATCH + CATCH -END_FUNC(PRIV) /* end H5FA_depend() */ +END_FUNC(PRIV) /* end H5FA_depend() */ - /*------------------------------------------------------------------------- * Function: H5FA_patch_file * @@ -796,9 +770,7 @@ END_FUNC(PRIV) /* end H5FA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5FA_patch_file(H5FA_t *fa, H5F_t *f)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_patch_file(H5FA_t *fa, H5F_t *f)) /* Local variables */ @@ -808,7 +780,7 @@ H5FA_patch_file(H5FA_t *fa, H5F_t *f)) HDassert(fa); HDassert(f); - if(fa->f != f || fa->hdr->f != f) + if (fa->f != f || fa->hdr->f != f) fa->f = fa->hdr->f = f; -END_FUNC(PRIV) /* end H5FA_patch_file() */ +END_FUNC(PRIV) /* end H5FA_patch_file() */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index f2f6990..de8ae52 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -26,45 +26,39 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* Fixed Array format version #'s */ -#define H5FA_HDR_VERSION 0 /* Header */ -#define H5FA_DBLOCK_VERSION 0 /* Data block */ - +#define H5FA_HDR_VERSION 0 /* Header */ +#define H5FA_DBLOCK_VERSION 0 /* Data block */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -72,109 +66,98 @@ /* Metadata cache (H5AC) callbacks */ static herr_t H5FA__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FA__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5FA__cache_hdr_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5FA__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FA__cache_hdr_image_len(const void *thing, size_t *image_len); -static herr_t H5FA__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5FA__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *thing); static herr_t H5FA__cache_hdr_free_icr(void *thing); static herr_t H5FA__cache_dblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FA__cache_dblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5FA__cache_dblock_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5FA__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FA__cache_dblock_image_len(const void *thing, size_t *image_len); -static herr_t H5FA__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5FA__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *thing); static herr_t H5FA__cache_dblock_free_icr(void *thing); static herr_t H5FA__cache_dblock_fsf_size(const void *thing, hsize_t *fsf_size); static herr_t H5FA__cache_dblk_page_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FA__cache_dblk_page_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5FA__cache_dblk_page_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5FA__cache_dblk_page_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FA__cache_dblk_page_image_len(const void *thing, size_t *image_len); -static herr_t H5FA__cache_dblk_page_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5FA__cache_dblk_page_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *thing); static herr_t H5FA__cache_dblk_page_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5FA header inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FARRAY_HDR[1] = {{ - H5AC_FARRAY_HDR_ID, /* Metadata client ID */ - "Fixed-array Header", /* Metadata client name (for debugging) */ - H5FD_MEM_FARRAY_HDR, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5FA__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FA__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5FA__cache_hdr_deserialize, /* 'deserialize' callback */ - H5FA__cache_hdr_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5FA__cache_hdr_serialize, /* 'serialize' callback */ - H5FA__cache_hdr_notify, /* 'notify' callback */ - H5FA__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_FARRAY_HDR_ID, /* Metadata client ID */ + "Fixed-array Header", /* Metadata client name (for debugging) */ + H5FD_MEM_FARRAY_HDR, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5FA__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FA__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5FA__cache_hdr_deserialize, /* 'deserialize' callback */ + H5FA__cache_hdr_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5FA__cache_hdr_serialize, /* 'serialize' callback */ + H5FA__cache_hdr_notify, /* 'notify' callback */ + H5FA__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5FA data block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FARRAY_DBLOCK[1] = {{ - H5AC_FARRAY_DBLOCK_ID, /* Metadata client ID */ - "Fixed Array Data Block", /* Metadata client name (for debugging) */ - H5FD_MEM_FARRAY_DBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5FA__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FA__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ - H5FA__cache_dblock_deserialize, /* 'deserialize' callback */ - H5FA__cache_dblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5FA__cache_dblock_serialize, /* 'serialize' callback */ - H5FA__cache_dblock_notify, /* 'notify' callback */ - H5FA__cache_dblock_free_icr, /* 'free_icr' callback */ - H5FA__cache_dblock_fsf_size, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_FARRAY_DBLOCK_ID, /* Metadata client ID */ + "Fixed Array Data Block", /* Metadata client name (for debugging) */ + H5FD_MEM_FARRAY_DBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5FA__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FA__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ + H5FA__cache_dblock_deserialize, /* 'deserialize' callback */ + H5FA__cache_dblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5FA__cache_dblock_serialize, /* 'serialize' callback */ + H5FA__cache_dblock_notify, /* 'notify' callback */ + H5FA__cache_dblock_free_icr, /* 'free_icr' callback */ + H5FA__cache_dblock_fsf_size, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5FA data block page inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FARRAY_DBLK_PAGE[1] = {{ - H5AC_FARRAY_DBLK_PAGE_ID, /* Metadata client ID */ - "Fixed Array Data Block Page", /* Metadata client name (for debugging) */ - H5FD_MEM_FARRAY_DBLK_PAGE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_FARRAY_DBLK_PAGE_ID, /* Metadata client ID */ + "Fixed Array Data Block Page", /* Metadata client name (for debugging) */ + H5FD_MEM_FARRAY_DBLK_PAGE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5FA__cache_dblk_page_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FA__cache_dblk_page_verify_chksum, /* 'verify_chksum' callback */ - H5FA__cache_dblk_page_deserialize, /* 'deserialize' callback */ - H5FA__cache_dblk_page_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5FA__cache_dblk_page_serialize, /* 'serialize' callback */ - H5FA__cache_dblk_page_notify, /* 'notify' callback */ - H5FA__cache_dblk_page_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FA__cache_dblk_page_verify_chksum, /* 'verify_chksum' callback */ + H5FA__cache_dblk_page_deserialize, /* 'deserialize' callback */ + H5FA__cache_dblk_page_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5FA__cache_dblk_page_serialize, /* 'serialize' callback */ + H5FA__cache_dblk_page_notify, /* 'notify' callback */ + H5FA__cache_dblk_page_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_get_initial_load_size * @@ -188,9 +171,8 @@ const H5AC_class_t H5AC_FARRAY_DBLK_PAGE[1] = {{ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; /* User data for callback */ @@ -203,9 +185,8 @@ H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) /* Set the image length size */ *image_len = (size_t)H5FA_HEADER_SIZE_FILE(udata->f); -END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_verify_chksum * @@ -219,14 +200,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -htri_t, TRUE, -, -H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) +BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, + H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) /* Local variables */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(image); @@ -234,12 +214,11 @@ H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_deserialize * @@ -254,17 +233,16 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ - H5FA_cls_id_t id; /* ID of fixed array class, as found in file */ - H5FA_hdr_t *hdr = NULL; /* Fixed array info */ + H5FA_cls_id_t id; /* ID of fixed array class, as found in file */ + H5FA_hdr_t * hdr = NULL; /* Fixed array info */ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ /* Check arguments */ HDassert(udata); @@ -272,50 +250,50 @@ H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len HDassert(H5F_addr_defined(udata->addr)); /* Allocate space for the fixed array data structure */ - if(NULL == (hdr = H5FA__hdr_alloc(udata->f))) + if (NULL == (hdr = H5FA__hdr_alloc(udata->f))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array shared header") /* Set the fixed array header's address */ hdr->addr = udata->addr; /* Magic number */ - if(HDmemcmp(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) H5E_THROW(H5E_BADVALUE, "wrong fixed array header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5FA_HDR_VERSION) + if (*image++ != H5FA_HDR_VERSION) H5E_THROW(H5E_VERSION, "wrong fixed array header version") /* Fixed array class */ id = (H5FA_cls_id_t)*image++; - if(id >= H5FA_NUM_CLS_ID) + if (id >= H5FA_NUM_CLS_ID) H5E_THROW(H5E_BADTYPE, "incorrect fixed array class") hdr->cparam.cls = H5FA_client_class_g[id]; /* General array creation/configuration information */ - hdr->cparam.raw_elmt_size = *image++; /* Element size in file (in bytes) */ + hdr->cparam.raw_elmt_size = *image++; /* Element size in file (in bytes) */ hdr->cparam.max_dblk_page_nelmts_bits = *image++; /* Log2(Max. # of elements in data block page) - - i.e. # of bits needed to store max. # of - elements in data block page. */ + i.e. # of bits needed to store max. # of + elements in data block page. */ /* Array statistics */ - H5F_DECODE_LENGTH(udata->f, image, hdr->cparam.nelmts); /* Number of elements */ + H5F_DECODE_LENGTH(udata->f, image, hdr->cparam.nelmts); /* Number of elements */ /* Internal information */ - H5F_addr_decode(udata->f, &image, &hdr->dblk_addr); /* Address of index block */ + H5F_addr_decode(udata->f, &image, &hdr->dblk_addr); /* Address of index block */ /* Check for data block */ - if(H5F_addr_defined(hdr->dblk_addr)) { - H5FA_dblock_t dblock; /* Fake data block for computing size */ - size_t dblk_page_nelmts; /* # of elements per data block page */ + if (H5F_addr_defined(hdr->dblk_addr)) { + H5FA_dblock_t dblock; /* Fake data block for computing size */ + size_t dblk_page_nelmts; /* # of elements per data block page */ /* Set up fake data block for computing size on disk */ - dblock.hdr = hdr; + dblock.hdr = hdr; dblock.dblk_page_init_size = 0; - dblock.npages = 0; - dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits; - if(hdr->cparam.nelmts > dblk_page_nelmts) { + dblock.npages = 0; + dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits; + if (hdr->cparam.nelmts > dblk_page_nelmts) { dblock.npages = (size_t)(((hdr->cparam.nelmts + dblk_page_nelmts) - 1) / dblk_page_nelmts); dblock.dblk_page_init_size = (dblock.npages + 7) / 8; } /* end if */ @@ -337,23 +315,22 @@ H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len HDassert((size_t)(image - (const uint8_t *)_image) == len); /* Finish initializing fixed array header */ - if(H5FA__hdr_init(hdr, udata->ctx_udata) < 0) + if (H5FA__hdr_init(hdr, udata->ctx_udata) < 0) H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(hdr && H5FA__hdr_dest(hdr) < 0) + if (!ret_value) + if (hdr && H5FA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") -END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_image_len * @@ -367,12 +344,11 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5FA_hdr_t *hdr = (const H5FA_hdr_t *)_thing; /* Pointer to the object */ + const H5FA_hdr_t *hdr = (const H5FA_hdr_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(hdr); @@ -381,9 +357,8 @@ H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_serialize * @@ -397,15 +372,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) /* Local variables */ - H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the fixed array header */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the fixed array header */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* check arguments */ HDassert(f); @@ -424,14 +397,16 @@ H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = (uint8_t)hdr->cparam.cls->id; /* General array creation/configuration information */ - *image++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */ - *image++ = hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + *image++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */ + *image++ = + hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits + needed to store max. # of elements in data block page */ /* Array statistics */ - H5F_ENCODE_LENGTH(f, image, hdr->stats.nelmts); /* Number of elements for the fixed array */ + H5F_ENCODE_LENGTH(f, image, hdr->stats.nelmts); /* Number of elements for the fixed array */ /* Internal information */ - H5F_addr_encode(f, &image, hdr->dblk_addr); /* Address of fixed array data block */ + H5F_addr_encode(f, &image, hdr->dblk_addr); /* Address of fixed array data block */ /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -442,9 +417,8 @@ H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_notify * @@ -457,20 +431,19 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ + H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(hdr); /* Check if the file was opened with SWMR-write access */ - if(hdr->swmr_write) { + if (hdr->swmr_write) { /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -487,20 +460,24 @@ H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) /* If hdr->parent != NULL, hdr->parent is used to destroy * the flush dependency before the header is evicted. */ - if(hdr->parent) { + if (hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); - /* Destroy flush dependency on object header proxy */ - if(H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between fixed array and proxy") + /* Destroy flush dependency on object header proxy */ + if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, + (void *)hdr->top_proxy) < 0) + H5E_THROW(H5E_CANTUNDEPEND, + "unable to destroy flush dependency between fixed array and proxy") hdr->parent = NULL; - } /* end if */ + } /* end if */ /* Detach from 'top' proxy for fixed array */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between header and fixed array 'top' proxy") + if (hdr->top_proxy) { + if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between header and fixed array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ break; @@ -508,19 +485,18 @@ H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == hdr->parent); -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_free_icr * @@ -535,22 +511,19 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_hdr_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_hdr_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array header */ - if(H5FA__hdr_dest((H5FA_hdr_t *)thing) < 0) + if (H5FA__hdr_dest((H5FA_hdr_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free fixed array header") -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_get_initial_load_size * @@ -564,14 +537,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data */ - H5FA_dblock_t dblock; /* Fake data block for computing size */ - size_t dblk_page_nelmts; /* # of elements per data block page */ + H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data */ + H5FA_dblock_t dblock; /* Fake data block for computing size */ + size_t dblk_page_nelmts; /* # of elements per data block page */ /* Check arguments */ HDassert(udata); @@ -588,22 +560,21 @@ H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) * dblock->npages * dblock->dblk_page_init_size */ - dblock.hdr = udata->hdr; + dblock.hdr = udata->hdr; dblk_page_nelmts = (size_t)1 << udata->hdr->cparam.max_dblk_page_nelmts_bits; - if(udata->hdr->cparam.nelmts > dblk_page_nelmts) { + if (udata->hdr->cparam.nelmts > dblk_page_nelmts) { dblock.npages = (size_t)(((udata->hdr->cparam.nelmts + dblk_page_nelmts) - 1) / dblk_page_nelmts); dblock.dblk_page_init_size = (dblock.npages + 7) / 8; } /* end if */ /* Set the image length size */ - if(!dblock.npages) + if (!dblock.npages) *image_len = (size_t)H5FA_DBLOCK_SIZE(&dblock); else *image_len = (size_t)H5FA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_verify_chksum * @@ -617,14 +588,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -htri_t, TRUE, -, -H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) +BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, + H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) /* Local variables */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(image); @@ -632,12 +602,11 @@ H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_deserialize * @@ -652,61 +621,61 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Data block info */ - H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data for loading data block */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - haddr_t arr_addr; /* Address of array header in the file */ + H5FA_dblock_t * dblock = NULL; /* Data block info */ + H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data for loading data block */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + haddr_t arr_addr; /* Address of array header in the file */ /* Sanity check */ HDassert(udata); HDassert(udata->hdr); /* Allocate the fixed array data block */ - if(NULL == (dblock = H5FA__dblock_alloc(udata->hdr))) + if (NULL == (dblock = H5FA__dblock_alloc(udata->hdr))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") - HDassert(((!dblock->npages) && (len == (size_t)H5FA_DBLOCK_SIZE(dblock))) - || (len == (size_t)H5FA_DBLOCK_PREFIX_SIZE(dblock))); + HDassert(((!dblock->npages) && (len == (size_t)H5FA_DBLOCK_SIZE(dblock))) || + (len == (size_t)H5FA_DBLOCK_PREFIX_SIZE(dblock))); /* Set the fixed array data block's information */ dblock->addr = udata->dblk_addr; /* Magic number */ - if(HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) H5E_THROW(H5E_BADVALUE, "wrong fixed array data block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5FA_DBLOCK_VERSION) + if (*image++ != H5FA_DBLOCK_VERSION) H5E_THROW(H5E_VERSION, "wrong fixed array data block version") /* Fixed array type */ - if(*image++ != (uint8_t)udata->hdr->cparam.cls->id) + if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) H5E_THROW(H5E_BADTYPE, "incorrect fixed array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); - if(H5F_addr_ne(arr_addr, udata->hdr->addr)) + if (H5F_addr_ne(arr_addr, udata->hdr->addr)) H5E_THROW(H5E_BADVALUE, "wrong fixed array header address") /* Page initialization flags */ - if(dblock->npages > 0) { - H5MM_memcpy(dblock->dblk_page_init, image, dblock->dblk_page_init_size); + if (dblock->npages > 0) { + H5MM_memcpy(dblock->dblk_page_init, image, dblock->dblk_page_init_size); image += dblock->dblk_page_init_size; } /* end if */ /* Only decode elements if the data block is not paged */ - if(!dblock->npages) { + if (!dblock->npages) { /* Decode elements in data block */ /* Convert from raw elements on disk into native elements in memory */ - if((udata->hdr->cparam.cls->decode)(image, dblock->elmts, (size_t)udata->hdr->cparam.nelmts, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cparam.cls->decode)(image, dblock->elmts, (size_t)udata->hdr->cparam.nelmts, + udata->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTDECODE, "can't decode fixed array data elements") image += (udata->hdr->cparam.nelmts * udata->hdr->cparam.raw_elmt_size); } /* end if */ @@ -729,16 +698,15 @@ H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Set return value */ ret_value = dblock; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(dblock && H5FA__dblock_dest(dblock) < 0) + if (!ret_value) + if (dblock && H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") -END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_image_len * @@ -752,26 +720,24 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); HDassert(image_len); /* Set the image length size */ - if(!dblock->npages) + if (!dblock->npages) *image_len = (size_t)dblock->size; else *image_len = H5FA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_serialize * @@ -785,15 +751,14 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing)) /* Local variables */ - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object to serialize */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object to serialize */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(f); @@ -816,19 +781,20 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED H5F_addr_encode(f, &image, dblock->hdr->addr); /* Page init flags */ - if(dblock->npages > 0) { + if (dblock->npages > 0) { /* Store the 'page init' bitmasks */ H5MM_memcpy(image, dblock->dblk_page_init, dblock->dblk_page_init_size); image += dblock->dblk_page_init_size; } /* end if */ /* Only encode elements if the data block is not paged */ - if(!dblock->npages) { + if (!dblock->npages) { /* Encode elements in data block */ /* Convert from native elements in memory into raw elements on disk */ - H5_CHECK_OVERFLOW(dblock->hdr->cparam.nelmts, /* From: */hsize_t, /* To: */size_t); - if((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, (size_t)dblock->hdr->cparam.nelmts, dblock->hdr->cb_ctx) < 0) + H5_CHECK_OVERFLOW(dblock->hdr->cparam.nelmts, /* From: */ hsize_t, /* To: */ size_t); + if ((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, (size_t)dblock->hdr->cparam.nelmts, + dblock->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTENCODE, "can't encode fixed array data elements") image += (dblock->hdr->cparam.nelmts * dblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -842,11 +808,10 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_notify * @@ -859,9 +824,8 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; @@ -870,17 +834,20 @@ H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) HDassert(dblock); /* Check if the file was opened with SWMR-write access */ - if(dblock->hdr->swmr_write) { + if (dblock->hdr->swmr_write) { /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5FA__create_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) + if (H5FA__create_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) + H5E_THROW( + H5E_CANTDEPEND, + "unable to create flush dependency between data block and header, address = %llu", + (unsigned long long)dblock->addr) break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: @@ -891,14 +858,15 @@ H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5FA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) + /* Destroy flush dependency on parent */ + if (H5FA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") /* Detach from 'top' proxy for fixed array */ - if(dblock->top_proxy) { - if(H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and fixed array 'top' proxy") + if (dblock->top_proxy) { + if (H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block " + "and fixed array 'top' proxy") dblock->top_proxy = NULL; } /* end if */ break; @@ -906,18 +874,16 @@ H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ - - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_free_icr * @@ -932,24 +898,21 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_dblock_free_icr(void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblock_free_icr(void *_thing)) - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); /* Release the fixed array data block */ - if(H5FA__dblock_dest(dblock) < 0) + if (H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "can't free fixed array data block") -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_fsf_size * @@ -979,11 +942,10 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) - const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); @@ -993,9 +955,8 @@ H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_get_initial_load_size * @@ -1009,12 +970,11 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data */ + H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data */ /* Check arguments */ HDassert(udata); @@ -1025,9 +985,8 @@ H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* Set the image length size */ *image_len = (size_t)H5FA_DBLK_PAGE_SIZE(udata->hdr, udata->nelmts); -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_verify_chksum * @@ -1041,14 +1000,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -htri_t, TRUE, -, -H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) +BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, + H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) /* Local variables */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(image); @@ -1056,12 +1014,11 @@ H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_deserialize * @@ -1076,16 +1033,16 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ - H5FA_dblk_page_t *dblk_page = NULL; /* Data block page info */ - H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ + H5FA_dblk_page_t * dblk_page = NULL; /* Data block page info */ + H5FA_dblk_page_cache_ud_t *udata = + (H5FA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ /* Sanity check */ HDassert(udata); @@ -1094,7 +1051,7 @@ H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, HDassert(H5F_addr_defined(udata->dblk_page_addr)); /* Allocate the fixed array data block page */ - if(NULL == (dblk_page = H5FA__dblk_page_alloc(udata->hdr, udata->nelmts))) + if (NULL == (dblk_page = H5FA__dblk_page_alloc(udata->hdr, udata->nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") /* Set the fixed array data block's information */ @@ -1104,7 +1061,7 @@ H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, /* Decode elements in data block page */ /* Convert from raw elements on disk into native elements in memory */ - if((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTDECODE, "can't decode fixed array data elements") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); @@ -1126,16 +1083,15 @@ H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, /* Set return value */ ret_value = dblk_page; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) + if (!ret_value) + if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_image_len * @@ -1149,12 +1105,11 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5FA_dblk_page_t *dblk_page = (const H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + const H5FA_dblk_page_t *dblk_page = (const H5FA_dblk_page_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblk_page); @@ -1163,9 +1118,8 @@ H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_serialize * @@ -1179,15 +1133,14 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, + size_t H5_ATTR_UNUSED len, void *_thing)) /* Local variables */ - H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Sanity check */ HDassert(f); @@ -1200,7 +1153,8 @@ H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_ima /* Encode elements in data block page */ /* Convert from native elements in memory into raw elements on disk */ - if((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->nelmts, dblk_page->hdr->cb_ctx) < 0) + if ((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->nelmts, + dblk_page->hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTENCODE, "can't encode fixed array data elements") image += (dblk_page->nelmts * dblk_page->hdr->cparam.raw_elmt_size); @@ -1213,11 +1167,10 @@ H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_ima /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_notify * @@ -1231,18 +1184,17 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(dblk_page); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -1251,9 +1203,10 @@ H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Detach from 'top' proxy for fixed array */ - if(dblk_page->top_proxy) { - if(H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page and fixed array 'top' proxy") + if (dblk_page->top_proxy) { + if (H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page " + "and fixed array 'top' proxy") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -1270,16 +1223,15 @@ H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_free_icr * @@ -1294,18 +1246,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_dblk_page_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblk_page_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the fixed array data block page */ - if(H5FA__dblk_page_dest((H5FA_dblk_page_t *)thing) < 0) + if (H5FA__dblk_page_dest((H5FA_dblk_page_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free fixed array data block page") -CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_free_icr() */ + CATCH +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_free_icr() */ diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c index b578cf2..b50cd67 100644 --- a/src/H5FAdbg.c +++ b/src/H5FAdbg.c @@ -24,29 +24,25 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5Oprivate.h" /* Object Header */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5Oprivate.h" /* Object Header */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -55,28 +51,22 @@ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FA__hdr_debug * @@ -89,14 +79,13 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, const H5FA_class_t *cls, haddr_t obj_addr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5FA_class_t *cls, haddr_t obj_addr)) /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */ - void *dbg_ctx = NULL; /* Fixed array debugging context */ + H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */ + void * dbg_ctx = NULL; /* Fixed array debugging context */ /* Check arguments */ HDassert(f); @@ -108,52 +97,42 @@ H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(cls); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") /* Load the fixed array header */ - if(NULL == (hdr = H5FA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5FA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") /* Print opening message */ HDfprintf(stream, "%*sFixed Array Header...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Header size:", - hdr->size); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Header size:", hdr->size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Raw Element Size:", - (unsigned)hdr->cparam.raw_elmt_size); + "Raw Element Size:", (unsigned)hdr->cparam.raw_elmt_size); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Native Element Size (on this platform):", - hdr->cparam.cls->nat_elmt_size); + "Native Element Size (on this platform):", hdr->cparam.cls->nat_elmt_size); - - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. # of elements in data block page:", - (unsigned)((size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits)); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Max. # of elements in data block page:", + (unsigned)((size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits)); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements in Fixed Array:", hdr->stats.nelmts); + "Number of elements in Fixed Array:", hdr->stats.nelmts); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Fixed Array Data Block Address:", hdr->dblk_addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Fixed Array Data Block Address:", hdr->dblk_addr); -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") - if(hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_debug() */ +END_FUNC(PKG) /* end H5FA__hdr_debug() */ - - /*------------------------------------------------------------------------- * Function: H5FA__dblock_debug * @@ -166,16 +145,15 @@ END_FUNC(PKG) /* end H5FA__hdr_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, const H5FA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5FA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */ - H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ - void *dbg_ctx = NULL; /* Fixed array context */ - size_t u; /* Local index variable */ + H5FA_hdr_t * hdr = NULL; /* Shared fixed array header */ + H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ + void * dbg_ctx = NULL; /* Fixed array context */ + size_t u; /* Local index variable */ /* Check arguments */ HDassert(f); @@ -188,94 +166,99 @@ H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(H5F_addr_defined(obj_addr)); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") /* Load the fixed array header */ - if(NULL == (hdr = H5FA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5FA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") /* Protect data block */ - if(NULL == (dblock = H5FA__dblock_protect(hdr, addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)addr) + if (NULL == (dblock = H5FA__dblock_protect(hdr, addr, H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", + (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sFixed Array data Block...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of Data Block:", dblock->addr); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data Block size:", dblock->size); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements in Data Block:", hdr->cparam.nelmts); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of pages in Data Block:", dblock->npages); + "Number of elements in Data Block:", hdr->cparam.nelmts); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Number of pages in Data Block:", dblock->npages); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements per Data Block page:", dblock->dblk_page_nelmts); + "Number of elements per Data Block page:", dblock->dblk_page_nelmts); - if(dblock->npages) { /* paging */ - size_t dblk_page_nelmts; /* # of elements in a data block page */ - haddr_t dblk_page_addr; /* Address of a data block page */ - size_t page_idx; /* Page index within data block */ + if (dblock->npages) { /* paging */ + size_t dblk_page_nelmts; /* # of elements in a data block page */ + haddr_t dblk_page_addr; /* Address of a data block page */ + size_t page_idx; /* Page index within data block */ HDfprintf(stream, "%*sPaging:\n", indent, ""); /* Iterate over the pages */ - dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock); + dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock); dblk_page_nelmts = dblock->dblk_page_nelmts; - /* Read and print each page's elements in the data block */ - for(page_idx = 0; page_idx < dblock->npages; page_idx++) { - if(!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { - HDfprintf(stream, "%*s%-*s %Hu %s\n", indent, "", fwidth, - "Page %Zu:", page_idx, "empty"); + /* Read and print each page's elements in the data block */ + for (page_idx = 0; page_idx < dblock->npages; page_idx++) { + if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { + HDfprintf(stream, "%*s%-*s %Hu %s\n", indent, "", fwidth, "Page %Zu:", page_idx, "empty"); - } /* end if */ - else { /* get the page */ - H5FA_dblk_page_t *dblk_page; /* Pointer to a data block page */ - hsize_t nelmts_left; /* Remaining elements in the last data block page */ + } /* end if */ + else { /* get the page */ + H5FA_dblk_page_t *dblk_page; /* Pointer to a data block page */ + hsize_t nelmts_left; /* Remaining elements in the last data block page */ /* Check for last page */ - if(((page_idx + 1) == dblock->npages) && (nelmts_left = hdr->cparam.nelmts % dblock->dblk_page_nelmts)) + if (((page_idx + 1) == dblock->npages) && + (nelmts_left = hdr->cparam.nelmts % dblock->dblk_page_nelmts)) dblk_page_nelmts = (size_t)nelmts_left; - if(NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr) + if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, + H5AC__READ_ONLY_FLAG))) + H5E_THROW(H5E_CANTPROTECT, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) HDfprintf(stream, "%*sElements in page %Zu:\n", indent, "", page_idx); - for(u = 0; u < dblk_page_nelmts; u++) { + for (u = 0; u < dblk_page_nelmts; u++) { /* Call the class's 'debug' callback */ - if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) + if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, + ((uint8_t *)dblk_page->elmts) + + (hdr->cparam.cls->nat_elmt_size * u)) < 0) H5E_THROW(H5E_CANTGET, "can't get element for debugging") } /* end for */ - if(H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) + if (H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; } /* paging */ - } /* end for npages */ - } /* end if */ - else { /* not paging */ + } /* end for npages */ + } /* end if */ + else { /* not paging */ /* Print the elements in the data block */ HDfprintf(stream, "%*sElements:\n", indent, ""); - for(u = 0; u < hdr->cparam.nelmts; u++) { + for (u = 0; u < hdr->cparam.nelmts; u++) { /* Call the class's 'debug' callback */ - if((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) + if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, + ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < + 0) H5E_THROW(H5E_CANTGET, "can't get element for debugging") } /* end for */ - } /* end else */ + } /* end else */ -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") - if(dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") - if(hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__dblock_debug() */ - +END_FUNC(PKG) /* end H5FA__dblock_debug() */ diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c index effdeb2..61aaf0e 100644 --- a/src/H5FAdblkpage.c +++ b/src/H5FAdblkpage.c @@ -24,53 +24,44 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -81,8 +72,6 @@ H5FL_DEFINE_STATIC(H5FA_dblk_page_t); /* Declare a free list to manage the page elements */ H5FL_BLK_DEFINE(page_elmts); - - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_alloc * @@ -95,22 +84,20 @@ H5FL_BLK_DEFINE(page_elmts); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5FA_dblk_page_t *, NULL, NULL, -H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts)) +BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts)) /* Local variables */ - H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ + H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ /* Check arguments */ HDassert(hdr); /* Allocate memory for the data block */ - if(NULL == (dblk_page = H5FL_CALLOC(H5FA_dblk_page_t))) + if (NULL == (dblk_page = H5FL_CALLOC(H5FA_dblk_page_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") /* Share common array information */ - if(H5FA__hdr_incr(hdr) < 0) + if (H5FA__hdr_incr(hdr) < 0) H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") dblk_page->hdr = hdr; @@ -118,21 +105,20 @@ H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts)) dblk_page->nelmts = nelmts; /* Allocate buffer for elements in data block page */ - if(NULL == (dblk_page->elmts = H5FL_BLK_MALLOC(page_elmts, nelmts * hdr->cparam.cls->nat_elmt_size))) + if (NULL == (dblk_page->elmts = H5FL_BLK_MALLOC(page_elmts, nelmts * hdr->cparam.cls->nat_elmt_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block page element buffer") /* Set the return value */ ret_value = dblk_page; -CATCH + CATCH - if(!ret_value) - if(dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) + if (!ret_value) + if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") -END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ +END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_create * @@ -145,64 +131,62 @@ END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts)) /* Local variables */ - H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr); + HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr); #endif /* H5FA_DEBUG */ /* Sanity check */ HDassert(hdr); /* Allocate the data block page */ - if(NULL == (dblk_page = H5FA__dblk_page_alloc(hdr, nelmts))) + if (NULL == (dblk_page = H5FA__dblk_page_alloc(hdr, nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; dblk_page->size = H5FA_DBLK_PAGE_SIZE(hdr, nelmts); #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: dblk_page->size = %Zu\n", FUNC, dblk_page->size); + HDfprintf(stderr, "%s: dblk_page->size = %Zu\n", FUNC, dblk_page->size); #endif /* H5FA_DEBUG */ /* Clear any elements in data block page to fill value */ - if((hdr->cparam.cls->fill)(dblk_page->elmts, nelmts) < 0) + if ((hdr->cparam.cls->fill)(dblk_page->elmts, nelmts) < 0) H5E_THROW(H5E_CANTSET, "can't set fixed array data block page elements to class's fill value") /* Cache the new fixed array data block page */ - if(H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block page to cache") inserted = TRUE; /* Add data block page as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ -CATCH - if(ret_value < 0) - if(dblk_page) { + CATCH + if (ret_value < 0) + if (dblk_page) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(dblk_page) < 0) + if (inserted) + if (H5AC_remove_entry(dblk_page) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block page from cache") /* Destroy data block page */ - if(H5FA__dblk_page_dest(dblk_page) < 0) + if (H5FA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_create() */ +END_FUNC(PKG) /* end H5FA__dblk_page_create() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_protect * @@ -216,17 +200,16 @@ END_FUNC(PKG) /* end H5FA__dblk_page_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5FA_dblk_page_t *, NULL, NULL, -H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, - size_t dblk_page_nelmts, unsigned flags)) +BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, + H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, + unsigned flags)) /* Local variables */ - H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ - H5FA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ + H5FA_dblk_page_t * dblk_page = NULL; /* Fixed array data block page */ + H5FA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ /* Sanity check */ @@ -237,18 +220,20 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; - udata.nelmts = dblk_page_nelmts; + udata.hdr = hdr; + udata.nelmts = dblk_page_nelmts; udata.dblk_page_addr = dblk_page_addr; /* Protect the data block page */ - if(NULL == (dblk_page = (H5FA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", (unsigned long long)dblk_page_addr) + if (NULL == (dblk_page = (H5FA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, + &udata, flags))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == dblk_page->top_proxy) { + if (hdr->top_proxy && NULL == dblk_page->top_proxy) { /* Add data block page as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ @@ -256,18 +241,19 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Set return value */ ret_value = dblk_page; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the data block page, if it was protected */ - if(dblk_page && H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", (unsigned long long)dblk_page->addr) + if (dblk_page && + H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", + (unsigned long long)dblk_page->addr) } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ +END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_unprotect * @@ -281,28 +267,27 @@ END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags)) - /* Local variables */ +/* Local variables */ #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ /* Sanity check */ HDassert(dblk_page); /* Unprotect the data block page */ - if(H5AC_unprotect(dblk_page->hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", (unsigned long long)dblk_page->addr) + if (H5AC_unprotect(dblk_page->hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", + (unsigned long long)dblk_page->addr) -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ +END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_dest * @@ -315,23 +300,21 @@ END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) /* Sanity check */ HDassert(dblk_page); /* Check if header field has been initialized */ - if(dblk_page->hdr) { + if (dblk_page->hdr) { /* Check if buffer for data block page elements has been initialized */ - if(dblk_page->elmts) { + if (dblk_page->elmts) { /* Free buffer for data block page elements */ dblk_page->elmts = H5FL_BLK_FREE(page_elmts, dblk_page->elmts); } /* end if */ /* Decrement reference count on shared info */ - if(H5FA__hdr_decr(dblk_page->hdr) < 0) + if (H5FA__hdr_decr(dblk_page->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -342,7 +325,6 @@ H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) /* Free the data block page itself */ dblk_page = H5FL_FREE(H5FA_dblk_page_t, dblk_page); -CATCH - -END_FUNC(PKG) /* end H5FA__dblk_page_dest() */ + CATCH +END_FUNC(PKG) /* end H5FA__dblk_page_dest() */ diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c index a6a8ced..1c0a2d7 100644 --- a/src/H5FAdblock.c +++ b/src/H5FAdblock.c @@ -24,54 +24,45 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -85,7 +76,6 @@ H5FL_BLK_DEFINE(chunk_elmts); /* Declare a free list to manage blocks of 'page init' bitmasks */ H5FL_BLK_DEFINE(fa_page_init); - /*------------------------------------------------------------------------- * Function: H5FA__dblock_alloc * @@ -98,23 +88,21 @@ H5FL_BLK_DEFINE(fa_page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5FA_dblock_t *, NULL, NULL, -H5FA__dblock_alloc(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t *hdr)) /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* fixed array data block */ + H5FA_dblock_t *dblock = NULL; /* fixed array data block */ /* Check arguments */ HDassert(hdr); HDassert(hdr->cparam.nelmts > 0); /* Allocate memory for the data block */ - if(NULL == (dblock = H5FL_CALLOC(H5FA_dblock_t))) + if (NULL == (dblock = H5FL_CALLOC(H5FA_dblock_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") /* Share common array information */ - if(H5FA__hdr_incr(hdr) < 0) + if (H5FA__hdr_incr(hdr) < 0) H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") dblock->hdr = hdr; @@ -122,7 +110,7 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr)) dblock->dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits; /* Check if this data block should be paged */ - if(hdr->cparam.nelmts > dblock->dblk_page_nelmts) { + if (hdr->cparam.nelmts > dblock->dblk_page_nelmts) { /* Compute number of pages */ hsize_t npages = ((hdr->cparam.nelmts + dblock->dblk_page_nelmts) - 1) / dblock->dblk_page_nelmts; @@ -137,14 +125,14 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr)) HDassert(dblock->dblk_page_init_size > 0); /* Allocate space for 'page init' flags */ - if(NULL == (dblock->dblk_page_init = H5FL_BLK_CALLOC(fa_page_init, dblock->dblk_page_init_size))) + if (NULL == (dblock->dblk_page_init = H5FL_BLK_CALLOC(fa_page_init, dblock->dblk_page_init_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for page init bitmask") /* Compute data block page size */ dblock->dblk_page_size = (dblock->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5FA_SIZEOF_CHKSUM; /* Compute the # of elements on last page */ - if(0 == hdr->cparam.nelmts % dblock->dblk_page_nelmts) + if (0 == hdr->cparam.nelmts % dblock->dblk_page_nelmts) dblock->last_page_nelmts = dblock->dblk_page_nelmts; else dblock->last_page_nelmts = (size_t)(hdr->cparam.nelmts % dblock->dblk_page_nelmts); @@ -153,23 +141,22 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr)) hsize_t dblk_size = hdr->cparam.nelmts * hdr->cparam.cls->nat_elmt_size; /* Allocate buffer for elements in data block */ - H5_CHECK_OVERFLOW(dblk_size, /* From: */hsize_t, /* To: */size_t); - if(NULL == (dblock->elmts = H5FL_BLK_MALLOC(chunk_elmts, (size_t)dblk_size))) + H5_CHECK_OVERFLOW(dblk_size, /* From: */ hsize_t, /* To: */ size_t); + if (NULL == (dblock->elmts = H5FL_BLK_MALLOC(chunk_elmts, (size_t)dblk_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; -CATCH + CATCH - if(!ret_value) - if(dblock && H5FA__dblock_dest(dblock) < 0) + if (!ret_value) + if (dblock && H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_alloc() */ +END_FUNC(PKG) /* end H5FA__dblock_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_create * @@ -182,45 +169,44 @@ END_FUNC(PKG) /* end H5FA__dblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty)) /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ - haddr_t dblock_addr; /* Fixed array data block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ + haddr_t dblock_addr; /* Fixed array data block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* Sanity check */ HDassert(hdr); HDassert(hdr_dirty); /* Allocate the data block */ - if(NULL == (dblock = H5FA__dblock_alloc(hdr))) + if (NULL == (dblock = H5FA__dblock_alloc(hdr))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") /* Set size of data block on disk */ hdr->stats.dblk_size = dblock->size = H5FA_DBLOCK_SIZE(dblock); /* Allocate space for the data block on disk */ - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FARRAY_DBLOCK, (hsize_t)dblock->size))) + if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FARRAY_DBLOCK, (hsize_t)dblock->size))) H5E_THROW(H5E_CANTALLOC, "file allocation failed for fixed array data block") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ - if(!dblock->npages) + if (!dblock->npages) /* Clear any elements in data block to fill value */ - if((hdr->cparam.cls->fill)(dblock->elmts, (size_t)hdr->cparam.nelmts) < 0) + if ((hdr->cparam.cls->fill)(dblock->elmts, (size_t)hdr->cparam.nelmts) < 0) H5E_THROW(H5E_CANTSET, "can't set fixed array data block elements to class's fill value") /* Cache the new fixed array data block */ - if(H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block to cache") inserted = TRUE; /* Add data block as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -231,27 +217,27 @@ H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty)) /* Set address of data block to return */ ret_value = dblock_addr; -CATCH + CATCH - if(!H5F_addr_defined(ret_value)) - if(dblock) { + if (!H5F_addr_defined(ret_value)) + if (dblock) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(dblock) < 0) + if (inserted) + if (H5AC_remove_entry(dblock) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block from cache") /* Release data block's disk space */ - if(H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_FARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) + if (H5F_addr_defined(dblock->addr) && + H5MF_xfree(hdr->f, H5FD_MEM_FARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) H5E_THROW(H5E_CANTFREE, "unable to release fixed array data block") /* Destroy data block */ - if(H5FA__dblock_dest(dblock) < 0) + if (H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblock_create() */ +END_FUNC(PKG) /* end H5FA__dblock_create() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_protect * @@ -264,13 +250,12 @@ END_FUNC(PKG) /* end H5FA__dblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5FA_dblock_t *, NULL, NULL, -H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) +BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, + H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) /* Local variables */ - H5FA_dblock_t *dblock; /* Fixed array data block */ - H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5FA_dblock_t * dblock; /* Fixed array data block */ + H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ /* Sanity check */ HDassert(hdr); @@ -280,17 +265,19 @@ H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; + udata.hdr = hdr; udata.dblk_addr = dblk_addr; /* Protect the data block */ - if(NULL == (dblock = (H5FA_dblock_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLOCK, dblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr) + if (NULL == + (dblock = (H5FA_dblock_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLOCK, dblk_addr, &udata, flags))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", + (unsigned long long)dblk_addr) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == dblock->top_proxy) { + if (hdr->top_proxy && NULL == dblock->top_proxy) { /* Add data block as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -298,17 +285,18 @@ H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) /* Set return value */ ret_value = dblock; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) + if (!ret_value) /* Release the data block, if it was protected */ - if(dblock && H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", (unsigned long long)dblock->addr) + if (dblock && + H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", + (unsigned long long)dblock->addr) -END_FUNC(PKG) /* end H5FA__dblock_protect() */ +END_FUNC(PKG) /* end H5FA__dblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_unprotect * @@ -321,9 +309,8 @@ END_FUNC(PKG) /* end H5FA__dblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags)) /* Local variables */ @@ -331,14 +318,14 @@ H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags)) HDassert(dblock); /* Unprotect the data block */ - if(H5AC_unprotect(dblock->hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", (unsigned long long)dblock->addr) + if (H5AC_unprotect(dblock->hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", + (unsigned long long)dblock->addr) -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ +END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_delete * @@ -351,50 +338,49 @@ END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr)) /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ + H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ /* Sanity check */ HDassert(hdr); HDassert(H5F_addr_defined(dblk_addr)); /* Protect data block */ - if(NULL == (dblock = H5FA__dblock_protect(hdr, dblk_addr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr) + if (NULL == (dblock = H5FA__dblock_protect(hdr, dblk_addr, H5AC__NO_FLAGS_SET))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", + (unsigned long long)dblk_addr) /* Check if data block is paged */ - if(dblock->npages) { - haddr_t dblk_page_addr; /* Address of each data block page */ - size_t u; /* Local index variable */ + if (dblock->npages) { + haddr_t dblk_page_addr; /* Address of each data block page */ + size_t u; /* Local index variable */ /* Set up initial state */ dblk_page_addr = dblk_addr + H5FA_DBLOCK_PREFIX_SIZE(dblock); /* Iterate over pages in data block */ - for(u = 0; u < dblock->npages; u++) { + for (u = 0; u < dblock->npages; u++) { /* Evict the data block page from the metadata cache */ /* (OK to call if it doesn't exist in the cache) */ - if(H5AC_expunge_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTEXPUNGE, "unable to remove array data block page from metadata cache") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; } /* end for */ - } /* end if */ + } /* end if */ -CATCH + CATCH /* Finished deleting data block in metadata cache */ - if(dblock && H5FA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (dblock && H5FA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | + H5AC__FREE_FILE_SPACE_FLAG) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_delete() */ +END_FUNC(PKG) /* end H5FA__dblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_dest * @@ -407,32 +393,30 @@ END_FUNC(PKG) /* end H5FA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblock_dest(H5FA_dblock_t *dblock)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dblock)) /* Sanity check */ HDassert(dblock); /* Check if shared header field has been initialized */ - if(dblock->hdr) { + if (dblock->hdr) { /* Check if we've got elements in the data block */ - if(dblock->elmts && !dblock->npages) { + if (dblock->elmts && !dblock->npages) { /* Free buffer for data block elements */ HDassert(dblock->hdr->cparam.nelmts > 0); dblock->elmts = H5FL_BLK_FREE(chunk_elmts, dblock->elmts); } /* end if */ /* Check if data block is paged */ - if(dblock->npages) { + if (dblock->npages) { /* Free buffer for 'page init' bitmask, if there is one */ HDassert(dblock->dblk_page_init_size > 0); - if(dblock->dblk_page_init) + if (dblock->dblk_page_init) dblock->dblk_page_init = H5FL_BLK_FREE(fa_page_init, dblock->dblk_page_init); } /* end if */ /* Decrement reference count on shared info */ - if(H5FA__hdr_decr(dblock->hdr) < 0) + if (H5FA__hdr_decr(dblock->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -443,7 +427,6 @@ H5FA__dblock_dest(H5FA_dblock_t *dblock)) /* Free the data block itself */ dblock = H5FL_FREE(H5FA_dblock_t, dblock); -CATCH - -END_FUNC(PKG) /* end H5FA__dblock_dest() */ + CATCH +END_FUNC(PKG) /* end H5FA__dblock_dest() */ diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 506c767..376ac0b 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -24,54 +24,45 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -79,7 +70,6 @@ /* Declare a free list to manage the H5FA_hdr_t struct */ H5FL_DEFINE_STATIC(H5FA_hdr_t); - /*------------------------------------------------------------------------- * Function: H5FA__hdr_alloc * @@ -92,41 +82,38 @@ H5FL_DEFINE_STATIC(H5FA_hdr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5FA_hdr_t *, NULL, NULL, -H5FA__hdr_alloc(H5F_t *f)) +BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, H5FA__hdr_alloc(H5F_t *f)) /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ + H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ - if(NULL == (hdr = H5FL_CALLOC(H5FA_hdr_t))) + if (NULL == (hdr = H5FL_CALLOC(H5FA_hdr_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; /* Set the internal parameters for the array */ - hdr->f = f; - hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; + hdr->f = f; + hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); hdr->sizeof_size = H5F_SIZEOF_SIZE(f); /* Set the return value */ ret_value = hdr; -CATCH + CATCH - if(!ret_value) - if(hdr && H5FA__hdr_dest(hdr) < 0) + if (!ret_value) + if (hdr && H5FA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_alloc() */ +END_FUNC(PKG) /* end H5FA__hdr_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_init * @@ -139,9 +126,7 @@ END_FUNC(PKG) /* end H5FA__hdr_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata)) /* Local variables */ @@ -155,16 +140,15 @@ H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata)) hdr->stats.nelmts = hdr->cparam.nelmts; /* Create the callback context, if there's one */ - if(hdr->cparam.cls->crt_context) { - if(NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) + if (hdr->cparam.cls->crt_context) { + if (NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) H5E_THROW(H5E_CANTCREATE, "unable to create fixed array client callback context") } /* end if */ -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_init() */ +END_FUNC(PKG) /* end H5FA__hdr_init() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_create * @@ -177,32 +161,31 @@ END_FUNC(PKG) /* end H5FA__hdr_init() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Fixed array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5FA_hdr_t *hdr = NULL; /* Fixed array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* Check arguments */ HDassert(f); HDassert(cparam); #ifndef NDEBUG -{ - /* Check for valid parameters */ - if(cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") - if(cparam->max_dblk_page_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") - if(cparam->nelmts == 0) - H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero") -} + { + /* Check for valid parameters */ + if (cparam->raw_elmt_size == 0) + H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + if (cparam->max_dblk_page_nelmts_bits == 0) + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + if (cparam->nelmts == 0) + H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero") + } #endif /* NDEBUG */ /* Allocate space for the shared information */ - if(NULL == (hdr = H5FA__hdr_alloc(f))) + if (NULL == (hdr = H5FA__hdr_alloc(f))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header") hdr->dblk_addr = HADDR_UNDEF; @@ -211,52 +194,52 @@ H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) H5MM_memcpy(&hdr->cparam, cparam, sizeof(hdr->cparam)); /* Finish initializing fixed array header */ - if(H5FA__hdr_init(hdr, ctx_udata) < 0) + if (H5FA__hdr_init(hdr, ctx_udata) < 0) H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") /* Allocate space for the header on disk */ - if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_FARRAY_HDR, (hsize_t)hdr->size))) + if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_FARRAY_HDR, (hsize_t)hdr->size))) H5E_THROW(H5E_CANTALLOC, "file allocation failed for Fixed Array header") /* Create 'top' proxy for extensible array entries */ - if(hdr->swmr_write) - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (hdr->swmr_write) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) H5E_THROW(H5E_CANTCREATE, "can't create fixed array entry proxy") /* Cache the new Fixed Array header */ - if(H5AC_insert_entry(f, H5AC_FARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_FARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTINSERT, "can't add fixed array header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ - if(hdr->top_proxy) - if(H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) + if (hdr->top_proxy) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") /* Set address of array header to return */ ret_value = hdr->addr; -CATCH + CATCH - if(!H5F_addr_defined(ret_value)) - if(hdr) { + if (!H5F_addr_defined(ret_value)) + if (hdr) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(hdr) < 0) + if (inserted) + if (H5AC_remove_entry(hdr) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array header from cache") /* Release header's disk space */ - if(H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_FARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) + if (H5F_addr_defined(hdr->addr) && + H5MF_xfree(f, H5FD_MEM_FARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) H5E_THROW(H5E_CANTFREE, "unable to free Fixed Array header") /* Destroy header */ - if(H5FA__hdr_dest(hdr) < 0) + if (H5FA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy Fixed Array header") } /* end if */ -END_FUNC(PKG) /* end H5FA__hdr_create() */ +END_FUNC(PKG) /* end H5FA__hdr_create() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_incr * @@ -269,26 +252,23 @@ END_FUNC(PKG) /* end H5FA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_incr(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_incr(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); /* Mark header as un-evictable when something is depending on it */ - if(hdr->rc == 0) - if(H5AC_pin_protected_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_pin_protected_entry(hdr) < 0) H5E_THROW(H5E_CANTPIN, "unable to pin fixed array header") /* Increment reference count on shared header */ hdr->rc++; -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_incr() */ +END_FUNC(PKG) /* end H5FA__hdr_incr() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_decr * @@ -301,9 +281,7 @@ END_FUNC(PKG) /* end H5FA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_decr(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_decr(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -313,17 +291,16 @@ H5FA__hdr_decr(H5FA_hdr_t *hdr)) hdr->rc--; /* Mark header as evictable again when nothing depend on it */ - if(hdr->rc == 0) { + if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); - if(H5AC_unpin_entry(hdr) < 0) + if (H5AC_unpin_entry(hdr) < 0) H5E_THROW(H5E_CANTUNPIN, "unable to unpin fixed array header") } /* end if */ -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_decr() */ +END_FUNC(PKG) /* end H5FA__hdr_decr() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_incr * @@ -336,9 +313,7 @@ END_FUNC(PKG) /* end H5FA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -346,9 +321,8 @@ H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) /* Increment file reference count on shared header */ hdr->file_rc++; -END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */ +END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_decr * @@ -361,9 +335,7 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -size_t, 0, -, -H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -375,9 +347,8 @@ H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ +END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_modified * @@ -390,22 +361,19 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_modified(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_modified(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); /* Mark header as dirty in cache */ - if(H5AC_mark_entry_dirty(hdr) < 0) + if (H5AC_mark_entry_dirty(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as dirty") -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_modified() */ +END_FUNC(PKG) /* end H5FA__hdr_modified() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_protect * @@ -419,13 +387,12 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5FA_hdr_t *, NULL, NULL, -H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags)) +BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, + H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags)) /* Local variables */ - H5FA_hdr_t *hdr; /* Fixed array header */ - H5FA_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5FA_hdr_t * hdr; /* Fixed array header */ + H5FA_hdr_cache_ud_t udata; /* User data for cache callbacks */ /* Sanity check */ HDassert(f); @@ -435,34 +402,34 @@ H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags)) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for cache callbacks */ - udata.f = f; - udata.addr = fa_addr; + udata.f = f; + udata.addr = fa_addr; udata.ctx_udata = ctx_udata; /* Protect the header */ - if(NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", (unsigned long long)fa_addr) - hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + if (NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) + H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) + hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ - if(hdr->swmr_write && NULL == hdr->top_proxy) { + if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for fixed array entries */ - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) H5E_THROW(H5E_CANTCREATE, "can't create fixed array entry proxy") /* Add header as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") } /* end if */ /* Set return value */ ret_value = hdr; -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_protect() */ +END_FUNC(PKG) /* end H5FA__hdr_protect() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_unprotect * @@ -476,9 +443,7 @@ END_FUNC(PKG) /* end H5FA__hdr_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags)) /* Local variables */ @@ -486,14 +451,14 @@ H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags)) HDassert(hdr); /* Unprotect the header */ - if(H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array hdr, address = %llu", (unsigned long long)hdr->addr) + if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array hdr, address = %llu", + (unsigned long long)hdr->addr) -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ +END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_delete * @@ -506,50 +471,47 @@ END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_delete(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_delete(H5FA_hdr_t *hdr)) /* Local variables */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ /* Sanity check */ HDassert(hdr); HDassert(!hdr->file_rc); #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Array header's status in the metadata cache */ + { + unsigned hdr_status = 0; /* Array header's status in the metadata cache */ - /* Check the array header's status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") + /* Check the array header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") - /* Sanity checks on array header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); -} /* end block */ + /* Sanity checks on array header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); + } /* end block */ #endif /* NDEBUG */ /* Check for Fixed Array Data block */ - if(H5F_addr_defined(hdr->dblk_addr)) { + if (H5F_addr_defined(hdr->dblk_addr)) { /* Delete Fixed Array Data block */ - if(H5FA__dblock_delete(hdr, hdr->dblk_addr) < 0) + if (H5FA__dblock_delete(hdr, hdr->dblk_addr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array data block") } /* end if */ /* Set flags to finish deleting header on unprotect */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; -CATCH + CATCH /* Unprotect the header, deleting it if an error hasn't occurred */ - if(H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_delete() */ +END_FUNC(PKG) /* end H5FA__hdr_delete() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_dest * @@ -562,24 +524,22 @@ END_FUNC(PKG) /* end H5FA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_dest(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_dest(H5FA_hdr_t *hdr)) /* Check arguments */ HDassert(hdr); HDassert(hdr->rc == 0); /* Destroy the callback context */ - if(hdr->cb_ctx) { - if((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) + if (hdr->cb_ctx) { + if ((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array client callback context") } /* end if */ hdr->cb_ctx = NULL; /* Destroy the 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_dest(hdr->top_proxy) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array 'top' proxy") hdr->top_proxy = NULL; } /* end if */ @@ -587,7 +547,6 @@ H5FA__hdr_dest(H5FA_hdr_t *hdr)) /* Free the shared info itself */ hdr = H5FL_FREE(H5FA_hdr_t, hdr); -CATCH - -END_FUNC(PKG) /* end H5FA__hdr_dest() */ + CATCH +END_FUNC(PKG) /* end H5FA__hdr_dest() */ diff --git a/src/H5FAint.c b/src/H5FAint.c index 9d3bce8..63dd128 100644 --- a/src/H5FAint.c +++ b/src/H5FAint.c @@ -26,58 +26,47 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error Handling */ -#include "H5FApkg.h" /* Fixed Arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5FApkg.h" /* Fixed Arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FA__create_flush_depend * @@ -90,23 +79,21 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) /* Sanity check */ HDassert(parent_entry); HDassert(child_entry); /* Create a flush dependency between parent and child entry */ - if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__create_flush_depend() */ +END_FUNC(PKG) /* end H5FA__create_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5FA__destroy_flush_depend * @@ -119,19 +106,17 @@ END_FUNC(PKG) /* end H5FA__create_flush_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) /* Sanity check */ HDassert(parent_entry); HDassert(child_entry); /* Destroy a flush dependency between parent and child entry */ - if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") -CATCH - -END_FUNC(PKG) /* end H5FA__destroy_flush_depend() */ + CATCH +END_FUNC(PKG) /* end H5FA__destroy_flush_depend() */ diff --git a/src/H5FAmodule.h b/src/H5FAmodule.h index f675faf..c96c8df 100644 --- a/src/H5FAmodule.h +++ b/src/H5FAmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5FA_MODULE -#define H5_MY_PKG H5FA -#define H5_MY_PKG_ERR H5E_FARRAY -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5FA +#define H5_MY_PKG_ERR H5E_FARRAY +#define H5_MY_PKG_INIT NO #endif /* _H5FAmodule_H */ - diff --git a/src/H5FApkg.h b/src/H5FApkg.h index 2baee88..4e13014 100644 --- a/src/H5FApkg.h +++ b/src/H5FApkg.h @@ -29,9 +29,8 @@ #include "H5FAprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ @@ -40,76 +39,72 @@ /* Define this to display debugging information for the Fixed Array layer */ /* #define H5FA_DEBUG */ - /* Fill value for fixed array test class */ #ifdef H5FA_TESTING -#define H5FA_TEST_FILL ((uint64_t)ULLONG_MAX) +#define H5FA_TEST_FILL ((uint64_t)ULLONG_MAX) #endif /* H5FA_TESTING */ /* Size of checksum information (on disk) */ -#define H5FA_SIZEOF_CHKSUM 4 +#define H5FA_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for fixed array metadata */ -#define H5FA_METADATA_PREFIX_SIZE(c) ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + 1 /* Version */ \ - + 1 /* Array type */ \ - + ((c) ? H5FA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ +#define H5FA_METADATA_PREFIX_SIZE(c) \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + 1 /* Version */ \ + + 1 /* Array type */ \ + + ((c) ? H5FA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ ) /* Size of the Fixed Array header on disk */ -#define H5FA_HEADER_SIZE(sizeof_addr, sizeof_size) ( \ - /* General metadata fields */ \ - H5FA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* General array information */ \ - + 1 /* Element Size */ \ - + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ \ - \ - /* Fixed Array statistics fields */ \ - + (sizeof_size) /* # of elements in the fixed array */ \ - \ - /* Fixed Array Header specific fields */ \ - + (sizeof_addr) /* File address of Fixed Array data block */ \ +#define H5FA_HEADER_SIZE(sizeof_addr, sizeof_size) \ + (/* General metadata fields */ \ + H5FA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* General array information */ \ + + 1 /* Element Size */ \ + + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements \ + in data block page */ \ + \ + /* Fixed Array statistics fields */ \ + + (sizeof_size) /* # of elements in the fixed array */ \ + \ + /* Fixed Array Header specific fields */ \ + + (sizeof_addr) /* File address of Fixed Array data block */ \ ) /* Size of the fixed array header on disk (via file pointer) */ -#define H5FA_HEADER_SIZE_FILE(f) ( \ - H5FA_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f)) \ - ) +#define H5FA_HEADER_SIZE_FILE(f) (H5FA_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f))) /* Size of the fixed array header on disk (via fixed array header) */ -#define H5FA_HEADER_SIZE_HDR(h) ( \ - H5FA_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size) \ - ) +#define H5FA_HEADER_SIZE_HDR(h) (H5FA_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size)) /* Size of the Fixed Array data block prefix on disk */ -#define H5FA_DBLOCK_PREFIX_SIZE(d) ( \ - /* General metadata fields */ \ - H5FA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Sanity-checking fields */ \ - + (d)->hdr->sizeof_addr /* File address of Fixed Array header owning the data block */ \ - \ - /* Fixed Array Data Block specific fields */ \ - + (d)->dblk_page_init_size /* Fixed array data block 'page init' bitmasks (can be 0 if no pages) */ \ +#define H5FA_DBLOCK_PREFIX_SIZE(d) \ + (/* General metadata fields */ \ + H5FA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Sanity-checking fields */ \ + + (d)->hdr->sizeof_addr /* File address of Fixed Array header owning the data block */ \ + \ + /* Fixed Array Data Block specific fields */ \ + + (d)->dblk_page_init_size /* Fixed array data block 'page init' bitmasks (can be 0 if no pages) */ \ ) /* Size of the Fixed Array data block on disk */ -#define H5FA_DBLOCK_SIZE(d) ( \ - /* Data block prefix size */ \ - H5FA_DBLOCK_PREFIX_SIZE(d) \ - \ - /* Fixed Array Elements|Pages of Elements*/ \ - + ((d)->hdr->cparam.nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) \ - + ((d)->npages * H5FA_SIZEOF_CHKSUM) /* Checksum */ \ +#define H5FA_DBLOCK_SIZE(d) \ + (/* Data block prefix size */ \ + H5FA_DBLOCK_PREFIX_SIZE(d) \ + \ + /* Fixed Array Elements|Pages of Elements*/ \ + + ((d)->hdr->cparam.nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) + \ + ((d)->npages * H5FA_SIZEOF_CHKSUM) /* Checksum */ \ ) /* Size of the Fixed Array data block page on disk */ -#define H5FA_DBLK_PAGE_SIZE(h, nelmts) ( \ - /* Fixed Array Data Block Page */ \ - + (nelmts * (size_t)(h)->cparam.raw_elmt_size) /* Elements in data block page */ \ - + H5FA_SIZEOF_CHKSUM /* Checksum for each page */ \ +#define H5FA_DBLK_PAGE_SIZE(h, nelmts) \ + ( /* Fixed Array Data Block Page */ \ + +(nelmts * (size_t)(h)->cparam.raw_elmt_size) /* Elements in data block page */ \ + + H5FA_SIZEOF_CHKSUM /* Checksum for each page */ \ ) /****************************/ @@ -122,48 +117,48 @@ typedef struct H5FA_hdr_t { H5AC_info_t cache_info; /* Fixed array configuration/creation parameters (stored in header) */ - H5FA_create_t cparam; /* Creation parameters for Fixed Array */ + H5FA_create_t cparam; /* Creation parameters for Fixed Array */ /* Fixed Array data block information (stored in header) */ - haddr_t dblk_addr; /* Address of Fixed Array Data block */ + haddr_t dblk_addr; /* Address of Fixed Array Data block */ /* Statistics for Fixed Array (stored in header) */ - H5FA_stat_t stats; /* Statistcs for Fixed Array */ + H5FA_stat_t stats; /* Statistcs for Fixed Array */ /* Computed/cached values (not stored in header) */ - size_t rc; /* Reference count of the header */ - haddr_t addr; /* Address of header in file */ - size_t size; /* Size of header in file */ - H5F_t *f; /* Pointer to file for fixed array */ - size_t file_rc; /* Reference count of files using array header */ - hbool_t pending_delete; /* Array is pending deletion */ - size_t sizeof_addr; /* Size of file addresses */ - size_t sizeof_size; /* Size of file sizes */ + size_t rc; /* Reference count of the header */ + haddr_t addr; /* Address of header in file */ + size_t size; /* Size of header in file */ + H5F_t * f; /* Pointer to file for fixed array */ + size_t file_rc; /* Reference count of files using array header */ + hbool_t pending_delete; /* Array is pending deletion */ + size_t sizeof_addr; /* Size of file addresses */ + size_t sizeof_size; /* Size of file sizes */ /* Client information (not stored) */ - void *cb_ctx; /* Callback context */ + void *cb_ctx; /* Callback context */ /* SWMR / Flush dependency information (not stored) */ - hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ - H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ - void *parent; /* Pointer to 'top' proxy flush dependency - * parent, if it exists, otherwise NULL. - * If the fixed array is being used - * to index a chunked dataset and the - * dataset metadata is modified by a - * SWMR writer, this field will be set - * equal to the object header proxy - * that is the flush dependency parent - * of the fixed array header. - * - * The field is used to avoid duplicate - * setups of the flush dependency - * relationship, and to allow the - * fixed array header to destroy - * the flush dependency on receipt of - * an eviction notification from the - * metadata cache. - */ + hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ + void * parent; /* Pointer to 'top' proxy flush dependency + * parent, if it exists, otherwise NULL. + * If the fixed array is being used + * to index a chunked dataset and the + * dataset metadata is modified by a + * SWMR writer, this field will be set + * equal to the object header proxy + * that is the flush dependency parent + * of the fixed array header. + * + * The field is used to avoid duplicate + * setups of the flush dependency + * relationship, and to allow the + * fixed array header to destroy + * the flush dependency on receipt of + * an eviction notification from the + * metadata cache. + */ } H5FA_hdr_t; /* The fixed array data block information */ @@ -172,25 +167,25 @@ typedef struct H5FA_dblock_t { H5AC_info_t cache_info; /* Fixed array information (stored) */ - uint8_t *dblk_page_init;/* Bitmap of whether a data block page is initialized */ - void *elmts; /* Buffer for elements stored in data block */ + uint8_t *dblk_page_init; /* Bitmap of whether a data block page is initialized */ + void * elmts; /* Buffer for elements stored in data block */ /* Internal array information (not stored) */ - H5FA_hdr_t *hdr; /* Shared array header info */ + H5FA_hdr_t *hdr; /* Shared array header info */ /* SWMR / Flush dependency information (not stored) */ - H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ /* Computed/cached values (not stored) */ - haddr_t addr; /* Address of this data block on disk */ - hsize_t size; /* Size of data block on disk */ - size_t npages; /* Nummber of pages in data block (zero if not paged) */ - size_t last_page_nelmts; /* Nummber of elements in last page, if paged */ + haddr_t addr; /* Address of this data block on disk */ + hsize_t size; /* Size of data block on disk */ + size_t npages; /* Nummber of pages in data block (zero if not paged) */ + size_t last_page_nelmts; /* Nummber of elements in last page, if paged */ /* Fixed Array data block information (not stored) */ - size_t dblk_page_nelmts; /* # of elements per data block page */ - size_t dblk_page_size; /* Size of a data block page */ - size_t dblk_page_init_size; /* Size of 'page init' bitmask */ + size_t dblk_page_nelmts; /* # of elements per data block page */ + size_t dblk_page_size; /* Size of a data block page */ + size_t dblk_page_init_size; /* Size of 'page init' bitmask */ } H5FA_dblock_t; /* The fixed array data block page information */ @@ -199,50 +194,48 @@ typedef struct H5FA_dbk_page_t { H5AC_info_t cache_info; /* Fixed array information (stored) */ - void *elmts; /* Buffer for elements stored in data block page */ + void *elmts; /* Buffer for elements stored in data block page */ /* Internal array information (not stored) */ - H5FA_hdr_t *hdr; /* Shared array header info */ + H5FA_hdr_t *hdr; /* Shared array header info */ /* SWMR / Flush dependency information (not stored) */ - H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ /* Computed/cached values (not stored) */ - haddr_t addr; /* Address of this data block page on disk */ - size_t size; /* Size of data block page on disk */ - size_t nelmts; /* Number of elements in data block page */ + haddr_t addr; /* Address of this data block page on disk */ + size_t size; /* Size of data block page on disk */ + size_t nelmts; /* Number of elements in data block page */ } H5FA_dblk_page_t; /* Fixed array */ struct H5FA_t { - H5FA_hdr_t *hdr; /* Pointer to internal fixed array header info */ - H5F_t *f; /* Pointer to file for fixed array */ + H5FA_hdr_t *hdr; /* Pointer to internal fixed array header info */ + H5F_t * f; /* Pointer to file for fixed array */ }; - /* Metadata cache callback user data types */ /* Info needed for loading header */ typedef struct H5FA_hdr_cache_ud_t { - H5F_t *f; /* Pointer to file for fixed array */ - haddr_t addr; /* Address of header on disk */ - void *ctx_udata; /* User context for class */ + H5F_t * f; /* Pointer to file for fixed array */ + haddr_t addr; /* Address of header on disk */ + void * ctx_udata; /* User context for class */ } H5FA_hdr_cache_ud_t; /* Info needed for loading data block */ typedef struct H5FA_dblock_cache_ud_t { - H5FA_hdr_t *hdr; /* Shared fixed array information */ - haddr_t dblk_addr; /* Address of data block on disk */ + H5FA_hdr_t *hdr; /* Shared fixed array information */ + haddr_t dblk_addr; /* Address of data block on disk */ } H5FA_dblock_cache_ud_t; /* Info needed for loading data block page */ typedef struct H5FA_dblk_page_cache_ud_t { H5FA_hdr_t *hdr; /* Shared fixed array information */ - size_t nelmts; /* Number of elements in data block page */ + size_t nelmts; /* Number of elements in data block page */ haddr_t dblk_page_addr; /* Address of data block page on disk */ } H5FA_dblk_page_cache_ud_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -253,58 +246,57 @@ H5_DLLVAR const H5FA_class_t H5FA_CLS_TEST[1]; /* Array of fixed array client ID -> client class mappings */ H5_DLLVAR const H5FA_class_t *const H5FA_client_class_g[H5FA_NUM_CLS_ID]; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Generic routines */ -H5_DLL herr_t H5FA__create_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); -H5_DLL herr_t H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); +H5_DLL herr_t H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); +H5_DLL herr_t H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Header routines */ H5_DLL H5FA_hdr_t *H5FA__hdr_alloc(H5F_t *f); -H5_DLL herr_t H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata); -H5_DLL haddr_t H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata); -H5_DLL void *H5FA__hdr_alloc_elmts(H5FA_hdr_t *hdr, size_t nelmts); -H5_DLL herr_t H5FA__hdr_free_elmts(H5FA_hdr_t *hdr, size_t nelmts, void *elmts); -H5_DLL herr_t H5FA__hdr_incr(H5FA_hdr_t *hdr); -H5_DLL herr_t H5FA__hdr_decr(H5FA_hdr_t *hdr); -H5_DLL herr_t H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr); -H5_DLL size_t H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr); -H5_DLL herr_t H5FA__hdr_modified(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata); +H5_DLL haddr_t H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata); +H5_DLL void * H5FA__hdr_alloc_elmts(H5FA_hdr_t *hdr, size_t nelmts); +H5_DLL herr_t H5FA__hdr_free_elmts(H5FA_hdr_t *hdr, size_t nelmts, void *elmts); +H5_DLL herr_t H5FA__hdr_incr(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_decr(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr); +H5_DLL size_t H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_modified(H5FA_hdr_t *hdr); H5_DLL H5FA_hdr_t *H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags); -H5_DLL herr_t H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags); -H5_DLL herr_t H5FA__hdr_delete(H5FA_hdr_t *hdr); -H5_DLL herr_t H5FA__hdr_dest(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags); +H5_DLL herr_t H5FA__hdr_delete(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_dest(H5FA_hdr_t *hdr); /* Data block routines */ H5_DLL H5FA_dblock_t *H5FA__dblock_alloc(H5FA_hdr_t *hdr); -H5_DLL haddr_t H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty); -H5_DLL unsigned H5FA__dblock_sblk_idx(const H5FA_hdr_t *hdr, hsize_t idx); +H5_DLL haddr_t H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty); +H5_DLL unsigned H5FA__dblock_sblk_idx(const H5FA_hdr_t *hdr, hsize_t idx); H5_DLL H5FA_dblock_t *H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags); -H5_DLL herr_t H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags); -H5_DLL herr_t H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr); -H5_DLL herr_t H5FA__dblock_dest(H5FA_dblock_t *dblock); +H5_DLL herr_t H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags); +H5_DLL herr_t H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr); +H5_DLL herr_t H5FA__dblock_dest(H5FA_dblock_t *dblock); /* Data block page routines */ H5_DLL herr_t H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts); H5_DLL H5FA_dblk_page_t *H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts); -H5_DLL H5FA_dblk_page_t *H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, unsigned flags); -H5_DLL herr_t H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags); -H5_DLL herr_t H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page); +H5_DLL H5FA_dblk_page_t *H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, + size_t dblk_page_nelmts, unsigned flags); +H5_DLL herr_t H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags); +H5_DLL herr_t H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page); /* Debugging routines for dumping file structures */ -H5_DLL herr_t H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5FA_class_t *cls, haddr_t obj_addr); -H5_DLL herr_t H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5FA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr); +H5_DLL herr_t H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5FA_class_t *cls, haddr_t obj_addr); +H5_DLL herr_t H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5FA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr); /* Testing routines */ #ifdef H5FA_TESTING H5_DLL herr_t H5FA__get_cparam_test(const H5FA_t *ea, H5FA_create_t *cparam); -H5_DLL int H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2); +H5_DLL int H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2); #endif /* H5FA_TESTING */ #endif /* _H5FApkg_H */ - diff --git a/src/H5FAprivate.h b/src/H5FAprivate.h index 98a9af4..02d859b 100644 --- a/src/H5FAprivate.h +++ b/src/H5FAprivate.h @@ -30,28 +30,26 @@ #endif /* NOT_YET */ /* Private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* Fixed Array class IDs */ typedef enum H5FA_cls_id_t { - H5FA_CLS_CHUNK_ID = 0, /* Fixed array is for indexing dataset chunks w/o filters */ - H5FA_CLS_FILT_CHUNK_ID, /* Fixed array is for indexing dataset chunks w/filters */ + H5FA_CLS_CHUNK_ID = 0, /* Fixed array is for indexing dataset chunks w/o filters */ + H5FA_CLS_FILT_CHUNK_ID, /* Fixed array is for indexing dataset chunks w/filters */ /* Start real class IDs at 0 -QAK */ /* (keep these last) */ - H5FA_CLS_TEST_ID, /* Fixed array is for testing (do not use for actual data) */ - H5FA_NUM_CLS_ID /* Number of Fixed Array class IDs (must be last) */ + H5FA_CLS_TEST_ID, /* Fixed array is for testing (do not use for actual data) */ + H5FA_NUM_CLS_ID /* Number of Fixed Array class IDs (must be last) */ } H5FA_cls_id_t; /* @@ -59,40 +57,44 @@ typedef enum H5FA_cls_id_t { * variable of this type that contains class variables and methods. */ typedef struct H5FA_class_t { - H5FA_cls_id_t id; /* ID of Fixed Array class, as found in file */ - const char *name; /* Name of class (for debugging) */ - size_t nat_elmt_size; /* Size of native (memory) element */ + H5FA_cls_id_t id; /* ID of Fixed Array class, as found in file */ + const char * name; /* Name of class (for debugging) */ + size_t nat_elmt_size; /* Size of native (memory) element */ /* Fixed array client callback methods */ - void *(*crt_context)(void *udata); /* Create context for other callbacks */ - herr_t (*dst_context)(void *ctx); /* Destroy context */ - herr_t (*fill)(void *nat_blk, size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ - herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, void *ctx); /* Encode elements from native form to disk storage form */ - herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, void *ctx); /* Decode elements from disk storage form to native form */ - herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Print an element for debugging */ + void *(*crt_context)(void *udata); /* Create context for other callbacks */ + herr_t (*dst_context)(void *ctx); /* Destroy context */ + herr_t (*fill)(void * nat_blk, + size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ + herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, + void *ctx); /* Encode elements from native form to disk storage form */ + herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, + void *ctx); /* Decode elements from disk storage form to native form */ + herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, + const void *elmt); /* Print an element for debugging */ void *(*crt_dbg_ctx)(H5F_t *f, haddr_t obj_addr); /* Create debugging context */ - herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ + herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ } H5FA_class_t; /* Fixed array creation parameters */ typedef struct H5FA_create_t { - const H5FA_class_t *cls; /* Class of Fixed Array to create */ - uint8_t raw_elmt_size; /* Element size in file (in bytes) */ - uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) - - * i.e. # of bits needed to store max. # of elements - * in a data block page - */ - hsize_t nelmts; /* # of elements in array */ + const H5FA_class_t *cls; /* Class of Fixed Array to create */ + uint8_t raw_elmt_size; /* Element size in file (in bytes) */ + uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) - + * i.e. # of bits needed to store max. # of elements + * in a data block page + */ + hsize_t nelmts; /* # of elements in array */ } H5FA_create_t; /* Fixed array metadata statistics info */ typedef struct H5FA_stat_t { /* Non-stored (i.e. computed) fields */ - hsize_t hdr_size; /* Size of header */ - hsize_t dblk_size; /* Size of data block */ + hsize_t hdr_size; /* Size of header */ + hsize_t dblk_size; /* Size of data block */ /* Stored fields */ - hsize_t nelmts; /* # of elements */ + hsize_t nelmts; /* # of elements */ } H5FA_stat_t; /* Fixed Array info (forward decl - defined in H5FApkg.h) */ @@ -101,7 +103,6 @@ typedef struct H5FA_t H5FA_t; /* Define the operator callback function pointer for H5FA_iterate() */ typedef int (*H5FA_operator_t)(hsize_t idx, const void *_elmt, void *_udata); - /*****************************/ /* Library-private Variables */ /*****************************/ @@ -112,24 +113,22 @@ H5_DLLVAR const H5FA_class_t H5FA_CLS_CHUNK[1]; /* The Fixed Array class for dataset chunks w/ filters*/ H5_DLLVAR const H5FA_class_t H5FA_CLS_FILT_CHUNK[1]; - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General routines */ -H5_DLL H5FA_t *H5FA_create(H5F_t *f, const H5FA_create_t *cparam, - void *ctx_udata); +H5_DLL H5FA_t *H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata); H5_DLL H5FA_t *H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata); -H5_DLL herr_t H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts); -H5_DLL herr_t H5FA_get_addr(const H5FA_t *fa, haddr_t *addr); -H5_DLL herr_t H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt); -H5_DLL herr_t H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt); -H5_DLL herr_t H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent); -H5_DLL herr_t H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata); -H5_DLL herr_t H5FA_close(H5FA_t *fa); -H5_DLL herr_t H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata); -H5_DLL herr_t H5FA_patch_file(H5FA_t *fa, H5F_t *f); +H5_DLL herr_t H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts); +H5_DLL herr_t H5FA_get_addr(const H5FA_t *fa, haddr_t *addr); +H5_DLL herr_t H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt); +H5_DLL herr_t H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt); +H5_DLL herr_t H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent); +H5_DLL herr_t H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata); +H5_DLL herr_t H5FA_close(H5FA_t *fa); +H5_DLL herr_t H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata); +H5_DLL herr_t H5FA_patch_file(H5FA_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5FA_get_stats(const H5FA_t *ea, H5FA_stat_t *stats); @@ -139,4 +138,3 @@ H5_DLL herr_t H5FA_get_stats(const H5FA_t *ea, H5FA_stat_t *stats); #endif /* H5FA_DEBUGGING */ #endif /* _H5FAprivate_H */ - diff --git a/src/H5FAstat.c b/src/H5FAstat.c index 49a56a9..530cc64 100644 --- a/src/H5FAstat.c +++ b/src/H5FAstat.c @@ -24,59 +24,48 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FA_get_stats * @@ -89,14 +78,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats)) - /* Local variables */ +/* Local variables */ #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ /* @@ -108,5 +95,4 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Copy fixed array statistics */ H5MM_memcpy(stats, &fa->hdr->stats, sizeof(fa->hdr->stats)); -END_FUNC(PRIV) /* end H5FA_get_stats() */ - +END_FUNC(PRIV) /* end H5FA_get_stats() */ diff --git a/src/H5FAtest.c b/src/H5FAtest.c index e55d408..4da7d6f 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -20,32 +20,28 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ #define H5FA_TESTING - /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Sanity checking value for callback contexts */ -#define H5FA__TEST_BOGUS_VAL 42 - +#define H5FA__TEST_BOGUS_VAL 42 /******************/ /* Local Typedefs */ @@ -53,35 +49,32 @@ /* Callback context */ typedef struct H5FA__test_ctx_t { - uint32_t bogus; /* Placeholder field to verify that context is working */ + uint32_t bogus; /* Placeholder field to verify that context is working */ } H5FA__test_ctx_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Fixed array class callbacks */ -static void *H5FA__test_crt_context(void *udata); +static void * H5FA__test_crt_context(void *udata); static herr_t H5FA__test_dst_context(void *ctx); static herr_t H5FA__test_fill(void *nat_blk, size_t nelmts); static herr_t H5FA__test_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); static herr_t H5FA__test_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); static herr_t H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); -static void *H5FA__test_crt_dbg_context(H5F_t *f, haddr_t obj_addr); - +static void * H5FA__test_crt_dbg_context(H5F_t *f, haddr_t obj_addr); /*********************/ /* Package Variables */ /*********************/ /* Fixed array testing class information */ -const H5FA_class_t H5FA_CLS_TEST[1]={{ +const H5FA_class_t H5FA_CLS_TEST[1] = {{ H5FA_CLS_TEST_ID, /* Type of Fixed array */ "Testing", /* Name of fixed array class */ sizeof(uint64_t), /* Size of native element */ @@ -95,12 +88,10 @@ const H5FA_class_t H5FA_CLS_TEST[1]={{ H5FA__test_dst_context /* Destroy debugging context */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -108,8 +99,6 @@ const H5FA_class_t H5FA_CLS_TEST[1]={{ /* Declare a free list to manage the H5FA__test_ctx_t struct */ H5FL_DEFINE_STATIC(H5FA__test_ctx_t); - - /*------------------------------------------------------------------------- * Function: H5FA__test_crt_context * @@ -123,15 +112,13 @@ H5FL_DEFINE_STATIC(H5FA__test_ctx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) /* Local variables */ - H5FA__test_ctx_t *ctx; /* Context for callbacks */ + H5FA__test_ctx_t *ctx; /* Context for callbacks */ /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") /* Initialize the context */ @@ -140,11 +127,10 @@ H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) /* Set return value */ ret_value = ctx; -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__test_crt_context() */ +END_FUNC(STATIC) /* end H5FA__test_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_dst_context * @@ -157,12 +143,10 @@ END_FUNC(STATIC) /* end H5FA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__test_dst_context(void *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_dst_context(void *_ctx)) /* Local variables */ - H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ + H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ /* Sanity checks */ HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); @@ -170,9 +154,8 @@ H5FA__test_dst_context(void *_ctx)) /* Release context structure */ ctx = H5FL_FREE(H5FA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5FA__test_dst_context() */ +END_FUNC(STATIC) /* end H5FA__test_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_fill * @@ -185,12 +168,10 @@ END_FUNC(STATIC) /* end H5FA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__test_fill(void *nat_blk, size_t nelmts)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_fill(void *nat_blk, size_t nelmts)) /* Local variables */ - uint64_t fill_val = H5FA_TEST_FILL; /* Value to fill elements with */ + uint64_t fill_val = H5FA_TEST_FILL; /* Value to fill elements with */ /* Sanity checks */ HDassert(nat_blk); @@ -198,9 +179,8 @@ H5FA__test_fill(void *nat_blk, size_t nelmts)) H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5FA__test_fill() */ +END_FUNC(STATIC) /* end H5FA__test_fill() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_encode * @@ -213,15 +193,14 @@ END_FUNC(STATIC) /* end H5FA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) - /* Local variables */ +/* Local variables */ #ifndef NDEBUG - H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ +#endif /* NDEBUG */ + const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ /* Sanity checks */ HDassert(raw); @@ -230,7 +209,7 @@ H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUS HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ UINT64ENCODE(raw, *elmt); @@ -242,9 +221,8 @@ H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUS nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_encode() */ +END_FUNC(STATIC) /* end H5FA__test_encode() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_decode * @@ -257,16 +235,15 @@ END_FUNC(STATIC) /* end H5FA__test_encode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) - /* Local variables */ +/* Local variables */ #ifndef NDEBUG - H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - uint64_t *elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ +#endif /* NDEBUG */ + uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ /* Sanity checks */ HDassert(raw); @@ -275,7 +252,7 @@ H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNU HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ UINT64DECODE(raw, *elmt); @@ -287,9 +264,8 @@ H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNU nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_decode() */ +END_FUNC(STATIC) /* end H5FA__test_decode() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_debug * @@ -302,13 +278,11 @@ END_FUNC(STATIC) /* end H5FA__test_decode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, - const void *elmt)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) /* Local variables */ - char temp_str[128]; /* Temporary string, for formatting */ + char temp_str[128]; /* Temporary string, for formatting */ /* Sanity checks */ HDassert(stream); @@ -317,11 +291,10 @@ H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /* Print element */ HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, - (unsigned long long)*(const uint64_t *)elmt); + (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5FA__test_debug() */ +END_FUNC(STATIC) /* end H5FA__test_debug() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_crt_dbg_context * @@ -335,15 +308,14 @@ END_FUNC(STATIC) /* end H5FA__test_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, + H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) /* Local variables */ - H5FA__test_ctx_t *ctx; /* Context for callbacks */ + H5FA__test_ctx_t *ctx; /* Context for callbacks */ /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") /* Initialize the context */ @@ -352,11 +324,10 @@ H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_a /* Set return value */ ret_value = ctx; -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ +END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5FA__get_cparam_test * @@ -369,9 +340,7 @@ END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam)) /* Check arguments. */ HDassert(fa); @@ -379,11 +348,10 @@ H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam)) /* Get fixed array creation parameters */ cparam->raw_elmt_size = fa->hdr->cparam.raw_elmt_size; - cparam->nelmts = fa->hdr->cparam.nelmts; + cparam->nelmts = fa->hdr->cparam.nelmts; -END_FUNC(PKG) /* end H5FA__get_cparam_test() */ +END_FUNC(PKG) /* end H5FA__get_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5FA__cmp_cparam_test * @@ -396,21 +364,19 @@ END_FUNC(PKG) /* end H5FA__get_cparam_test() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, -int, 0, -, -H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2)) +BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, + H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2)) /* Check arguments. */ HDassert(cparam1); HDassert(cparam2); /* Compare creation parameters for array */ - if(cparam1->raw_elmt_size < cparam2->raw_elmt_size) + if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) H5_LEAVE(-1) - else if(cparam1->raw_elmt_size > cparam2->raw_elmt_size) + else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) H5_LEAVE(1) -CATCH - -END_FUNC(PKG) /* end H5FA__cmp_cparam_test() */ + CATCH +END_FUNC(PKG) /* end H5FA__cmp_cparam_test() */ diff --git a/src/H5FD.c b/src/H5FD.c index f34a2ec..c4e0eb7 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -23,48 +23,45 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ - +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ /* H5FD wrapper for VFD SWMR. Allows use as a BSD TAILQ element. */ typedef struct H5FD_wrap_t { - TAILQ_ENTRY(H5FD_wrap_t) link; /* Linkage for list of all VFDs. */ - H5FD_t *file; /* Pointer to wrapped VFD struct */ + TAILQ_ENTRY(H5FD_wrap_t) link; /* Linkage for list of all VFDs. */ + H5FD_t *file; /* Pointer to wrapped VFD struct */ } H5FD_wrap_t; /********************/ /* Local Prototypes */ /********************/ static herr_t H5FD__free_cls(H5FD_class_t *cls); -static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags/*out*/); +static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags /*out*/); /*********************/ /* Package Variables */ @@ -73,12 +70,10 @@ static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags/*out*/); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -101,14 +96,12 @@ static TAILQ_HEAD(_all_vfds, H5FD_wrap_t) all_vfds = TAILQ_HEAD_INITIALIZER(all_ /* File driver ID class */ static const H5I_class_t H5I_VFL_CLS[1] = {{ - H5I_VFL, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5FD__free_cls /* Callback routine for closing objects of this class */ + H5I_VFL, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5FD__free_cls /* Callback routine for closing objects of this class */ }}; - - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -121,11 +114,11 @@ static const H5I_class_t H5I_VFL_CLS[1] = {{ herr_t H5FD__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5I_register_type(H5I_VFL_CLS) < 0) + if (H5I_register_type(H5I_VFL_CLS) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Reset the file serial numbers */ @@ -135,7 +128,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_term_package * @@ -154,29 +146,28 @@ done: int H5FD_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - if(H5I_nmembers(H5I_VFL) > 0) { + if (H5_PKG_INIT_VAR) { + if (H5I_nmembers(H5I_VFL) > 0) { (void)H5I_clear_type(H5I_VFL, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ else { /* Destroy the VFL driver ID group */ n += (H5I_dec_type_ref(H5I_VFL) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5FD_term_package() */ - /*------------------------------------------------------------------------- * Function: H5FD__free_cls * @@ -202,8 +193,9 @@ H5FD__free_cls(H5FD_class_t *cls) * driver a chance to free singletons or other resources which will become * invalid once the class structure is freed. */ - if(cls->terminate && cls->terminate() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEOBJ, FAIL, "virtual file driver '%s' did not terminate cleanly", cls->name) + if (cls->terminate && cls->terminate() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEOBJ, FAIL, "virtual file driver '%s' did not terminate cleanly", + cls->name) H5MM_xfree(cls); @@ -211,7 +203,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__free_cls() */ - /*------------------------------------------------------------------------- * Function: H5FDregister * @@ -231,36 +222,38 @@ done: hid_t H5FDregister(const H5FD_class_t *cls) { - H5FD_mem_t type; - hid_t ret_value = H5I_INVALID_HID; + H5FD_mem_t type; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*x", cls); /* Check arguments */ - if(!cls) + if (!cls) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null class pointer is disallowed") - if(!cls->open || !cls->close) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'open' and/or 'close' methods are not defined") - if(!cls->get_eoa || !cls->set_eoa) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'get_eoa' and/or 'set_eoa' methods are not defined") - if(!cls->get_eof) + if (!cls->open || !cls->close) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'open' and/or 'close' methods are not defined") + if (!cls->get_eoa || !cls->set_eoa) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'get_eoa' and/or 'set_eoa' methods are not defined") + if (!cls->get_eof) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'get_eof' method is not defined") - if(!cls->read || !cls->write) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'read' and/or 'write' method is not defined") + if (!cls->read || !cls->write) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'read' and/or 'write' method is not defined") for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) - if(cls->fl_map[type] < H5FD_MEM_NOLIST || cls->fl_map[type] >= H5FD_MEM_NTYPES) + if (cls->fl_map[type] < H5FD_MEM_NOLIST || cls->fl_map[type] >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid free-list mapping") /* Create the new class ID */ - if((ret_value = H5FD_register(cls, sizeof(H5FD_class_t), TRUE)) < 0) + if ((ret_value = H5FD_register(cls, sizeof(H5FD_class_t), TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file driver ID") done: FUNC_LEAVE_API(ret_value) } /* end H5FDregister() */ - /*------------------------------------------------------------------------- * Function: H5FD_register * @@ -280,10 +273,10 @@ done: hid_t H5FD_register(const void *_cls, size_t size, hbool_t app_ref) { - const H5FD_class_t *cls = (const H5FD_class_t *)_cls; - H5FD_class_t *saved = NULL; - H5FD_mem_t type; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + const H5FD_class_t *cls = (const H5FD_class_t *)_cls; + H5FD_class_t * saved = NULL; + H5FD_mem_t type; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -293,28 +286,28 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref) HDassert(cls->get_eoa && cls->set_eoa); HDassert(cls->get_eof); HDassert(cls->read && cls->write); - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { HDassert(cls->fl_map[type] >= H5FD_MEM_NOLIST && cls->fl_map[type] < H5FD_MEM_NTYPES); } /* Copy the class structure so the caller can reuse or free it */ - if(NULL == (saved = (H5FD_class_t *)H5MM_malloc(size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed for file driver class struct") + if (NULL == (saved = (H5FD_class_t *)H5MM_malloc(size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, + "memory allocation failed for file driver class struct") H5MM_memcpy(saved, cls, size); /* Create the new class ID */ - if((ret_value = H5I_register(H5I_VFL, saved, app_ref)) < 0) + if ((ret_value = H5I_register(H5I_VFL, saved, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file driver ID") done: - if(H5I_INVALID_HID == ret_value) - if(saved) + if (H5I_INVALID_HID == ret_value) + if (saved) saved = (H5FD_class_t *)H5MM_xfree(saved); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_register() */ - /*------------------------------------------------------------------------- * Function: H5FDunregister * @@ -330,24 +323,23 @@ done: herr_t H5FDunregister(hid_t driver_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", driver_id); /* Check arguments */ - if(NULL == H5I_object_verify(driver_id, H5I_VFL)) + if (NULL == H5I_object_verify(driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver") /* The H5FD_class_t struct will be freed by this function */ - if(H5I_dec_app_ref(driver_id) < 0) + if (H5I_dec_app_ref(driver_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "unable to unregister file driver") done: FUNC_LEAVE_API(ret_value) } /* end H5FDunregister() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_class * @@ -368,23 +360,23 @@ done: H5FD_class_t * H5FD_get_class(hid_t id) { - H5FD_class_t *ret_value = NULL; + H5FD_class_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) - if(H5I_VFL == H5I_get_type(id)) + if (H5I_VFL == H5I_get_type(id)) ret_value = (H5FD_class_t *)H5I_object(id); else { - H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - if(TRUE == H5P_isa_class(id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + if (TRUE == H5P_isa_class(id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID & info") ret_value = H5FD_get_class(driver_prop.driver_id); } /* end if */ @@ -396,7 +388,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_class() */ - /*------------------------------------------------------------------------- * Function: H5FD_sb_size * @@ -413,7 +404,7 @@ done: hsize_t H5FD_sb_size(H5FD_t *file) { - hsize_t ret_value = 0; + hsize_t ret_value = 0; FUNC_ENTER_NOAPI(0) @@ -422,14 +413,13 @@ H5FD_sb_size(H5FD_t *file) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->sb_size) + if (file->cls->sb_size) ret_value = (file->cls->sb_size)(file); done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_sb_encode * @@ -445,9 +435,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf) +H5FD_sb_encode(H5FD_t *file, char *name /*out*/, uint8_t *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -456,14 +446,13 @@ H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->sb_encode && (file->cls->sb_encode)(file, name/*out*/, buf/*out*/) < 0) + if (file->cls->sb_encode && (file->cls->sb_encode)(file, name /*out*/, buf /*out*/) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_encode request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sb_encode() */ - /*------------------------------------------------------------------------- * Function: H5FD__sb_decode * @@ -476,7 +465,7 @@ done: static herr_t H5FD__sb_decode(H5FD_t *file, const char *name, const uint8_t *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -485,14 +474,13 @@ H5FD__sb_decode(H5FD_t *file, const char *name, const uint8_t *buf) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->sb_decode && (file->cls->sb_decode)(file, name, buf) < 0) + if (file->cls->sb_decode && (file->cls->sb_decode)(file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_decode request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sb_decode() */ - /*------------------------------------------------------------------------- * Function: H5FD_sb_load * @@ -505,7 +493,7 @@ done: herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -516,20 +504,19 @@ H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf) /* Check if driver matches driver information saved. Unfortunately, we can't push this * function to each specific driver because we're checking if the driver is correct. */ - if(!HDstrncmp(name, "NCSAfami", (size_t)8) && HDstrcmp(file->cls->name, "family")) + if (!HDstrncmp(name, "NCSAfami", (size_t)8) && HDstrcmp(file->cls->name, "family")) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "family driver should be used") - if(!HDstrncmp(name, "NCSAmult", (size_t)8) && HDstrcmp(file->cls->name, "multi")) + if (!HDstrncmp(name, "NCSAmult", (size_t)8) && HDstrcmp(file->cls->name, "multi")) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "multi driver should be used") /* Decode driver information */ - if(H5FD__sb_decode(file, name, buf) < 0) + if (H5FD__sb_decode(file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDECODE, FAIL, "unable to decode driver information") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sb_load() */ - /*------------------------------------------------------------------------- * Function: H5FD_fapl_get * @@ -555,7 +542,7 @@ done: void * H5FD_fapl_get(H5FD_t *file) { - void *ret_value = NULL; + void *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -564,14 +551,13 @@ H5FD_fapl_get(H5FD_t *file) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->fapl_get) + if (file->cls->fapl_get) ret_value = (file->cls->fapl_get)(file); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD_free_driver_info * @@ -584,22 +570,22 @@ done: herr_t H5FD_free_driver_info(hid_t driver_id, const void *driver_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(driver_id > 0 && driver_info) { - H5FD_class_t *driver; + if (driver_id > 0 && driver_info) { + H5FD_class_t *driver; /* Retrieve the driver for the ID */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_id))) + if (NULL == (driver = (H5FD_class_t *)H5I_object(driver_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") /* Allow driver to free info or do it ourselves */ - if(driver->fapl_free) { + if (driver->fapl_free) { /* Free the const pointer */ /* Cast through uintptr_t to de-const memory */ - if((driver->fapl_free)((void *)(uintptr_t)driver_info) < 0) + if ((driver->fapl_free)((void *)(uintptr_t)driver_info) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "driver free request failed") } else @@ -610,7 +596,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_free_driver_info() */ - /*------------------------------------------------------------------------- * Function: H5FDopen * @@ -664,20 +649,19 @@ done: H5FD_t * H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_t *ret_value = NULL; + H5FD_t *ret_value = NULL; FUNC_ENTER_API(NULL) H5TRACE4("*x", "*sIuia", name, flags, fapl_id, maxaddr); /* Check arguments */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(fapl_id,H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") /* Call private function */ - if(NULL == (ret_value = H5FD_open(name, flags, fapl_id, maxaddr))) + if (NULL == (ret_value = H5FD_open(name, flags, fapl_id, maxaddr))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to open file") done: @@ -731,10 +715,11 @@ H5FD_dedup(H5FD_t *self, H5FD_t *other, hid_t fapl) H5FD_t * H5FD_deduplicate(H5FD_t *file, hid_t fapl) { - H5FD_t *deduped = file; + H5FD_t * deduped = file; H5FD_wrap_t *item; - TAILQ_FOREACH(item, &all_vfds, link) { + TAILQ_FOREACH(item, &all_vfds, link) + { /* skip "self" */ if (item->file == file) continue; @@ -751,7 +736,8 @@ H5FD_deduplicate(H5FD_t *file, hid_t fapl) * duplicate. If any lower VFD with an exclusive owner matches `file`, * return NULL to indicate the conflict. */ - TAILQ_FOREACH(item, &all_vfds, link) { + TAILQ_FOREACH(item, &all_vfds, link) + { if (item->file == file || item->file->exc_owner == NULL) continue; @@ -769,7 +755,6 @@ finish: return deduped; } - /*------------------------------------------------------------------------- * Function: H5FD_open * @@ -784,56 +769,56 @@ finish: H5FD_t * H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_class_t *driver; /* VFD for file */ - H5FD_t *file; - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - H5P_genplist_t *plist; /* Property list pointer */ - unsigned long driver_flags = 0; /* File-inspecific driver feature flags */ + H5FD_class_t * driver; /* VFD for file */ + H5FD_t * file; + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + H5P_genplist_t * plist; /* Property list pointer */ + unsigned long driver_flags = 0; /* File-inspecific driver feature flags */ H5FD_file_image_info_t file_image_info; /* Initial file image */ - H5FD_wrap_t *swmr_wrapper = NULL; /* H5FD wrapper for SWMR queue */ - H5FD_t *ret_value = NULL; /* Return value */ + H5FD_wrap_t * swmr_wrapper = NULL; /* H5FD wrapper for SWMR queue */ + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Sanity checks */ - if(0 == maxaddr) + if (0 == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "zero format address range") /* Get file access property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") /* Get the VFD to open the file with */ - if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID & info") /* Get driver info */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_prop.driver_id))) + if (NULL == (driver = (H5FD_class_t *)H5I_object(driver_prop.driver_id))) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list") - if(NULL == driver->open) + if (NULL == driver->open) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method") /* Query driver flag */ - if(H5FD_driver_query(driver, &driver_flags) < 0) + if (H5FD_driver_query(driver, &driver_flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't query VFD flags") /* Get initial file image info */ - if(H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file image info") /* If an image is provided, make sure the driver supports this feature */ HDassert(((file_image_info.buffer != NULL) && (file_image_info.size > 0)) || ((file_image_info.buffer == NULL) && (file_image_info.size == 0))); - if((file_image_info.buffer != NULL) && !(driver_flags & H5FD_FEAT_ALLOW_FILE_IMAGE)) + if ((file_image_info.buffer != NULL) && !(driver_flags & H5FD_FEAT_ALLOW_FILE_IMAGE)) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file image set, but not supported.") /* Dispatch to file driver */ - if(HADDR_UNDEF == maxaddr) + if (HADDR_UNDEF == maxaddr) maxaddr = driver->maxaddr; -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "H5FD_open(): calling %s.open().\n", driver->name); #endif /* JRM */ - if(NULL == (file = (driver->open)(name, flags, fapl_id, maxaddr))) + if (NULL == (file = (driver->open)(name, flags, fapl_id, maxaddr))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "open failed") file->exc_owner = NULL; @@ -845,21 +830,21 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) * driver ID to prevent it from being freed while this file is open. */ file->driver_id = driver_prop.driver_id; - if(H5I_inc_ref(file->driver_id, FALSE) < 0) + if (H5I_inc_ref(file->driver_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") - file->cls = driver; + file->cls = driver; file->maxaddr = maxaddr; - if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(file->threshold)) < 0) + if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(file->threshold)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold") - if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(file->alignment)) < 0) + if (H5P_get(plist, H5F_ACS_ALIGN_NAME, &(file->alignment)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment") /* Retrieve the VFL driver feature flags */ - if(H5FD__query(file, &(file->feature_flags)) < 0) + if (H5FD__query(file, &(file->feature_flags)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to query file driver") /* Increment the global serial number & assign it to this H5FD_t object */ - if(++H5FD_file_serial_no_g == 0) { + if (++H5FD_file_serial_no_g == 0) { /* (Just error out if we wrap around for now...) */ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to get file serial number") } /* end if */ @@ -870,7 +855,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) file->base_addr = 0; /* Create and insert a SWMR wrapper for the file */ - if(NULL == (swmr_wrapper = H5MM_calloc(sizeof(H5FD_wrap_t)))) + if (NULL == (swmr_wrapper = H5MM_calloc(sizeof(H5FD_wrap_t)))) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, NULL, "unable to allocate file wrap struct") swmr_wrapper->file = file; TAILQ_INSERT_TAIL(&all_vfds, swmr_wrapper, link); @@ -884,7 +869,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_open() */ - /*------------------------------------------------------------------------- * Function: H5FDclose * @@ -901,26 +885,25 @@ done: herr_t H5FDclose(H5FD_t *file) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", file); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") /* Call private function */ - if(H5FD_close(file) < 0) + if (H5FD_close(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") done: FUNC_LEAVE_API(ret_value) } /* end H5FDclose() */ - /*------------------------------------------------------------------------- * Function: H5FD_close * @@ -934,8 +917,8 @@ herr_t H5FD_close(H5FD_t *file) { const H5FD_class_t *driver; - H5FD_wrap_t *item; - H5FD_wrap_t *delete_me = NULL; + H5FD_wrap_t * item; + H5FD_wrap_t * delete_me = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -946,10 +929,11 @@ H5FD_close(H5FD_t *file) /* Prepare to close file by clearing all public fields */ driver = file->cls; - if(H5I_dec_ref(file->driver_id) < 0) + if (H5I_dec_ref(file->driver_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") - TAILQ_FOREACH(item, &all_vfds, link) { + TAILQ_FOREACH(item, &all_vfds, link) + { if (item->file->exc_owner == file) item->file->exc_owner = NULL; if (item->file == file) @@ -963,14 +947,13 @@ H5FD_close(H5FD_t *file) * close the file then the file will be in an unusable state. */ HDassert(driver->close); - if((driver->close)(file) < 0) + if ((driver->close)(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_close() */ - /*------------------------------------------------------------------------- * Function: H5FDcmp * @@ -993,7 +976,7 @@ done: int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2) { - int ret_value = -1; + int ret_value = -1; FUNC_ENTER_API(-1) /* return value is arbitrary */ H5TRACE2("Is", "*x*x", f1, f2); @@ -1005,7 +988,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5FDcmp() */ - /*------------------------------------------------------------------------- * Function: H5FD_cmp * @@ -1020,26 +1002,26 @@ done: int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) /* return value is arbitrary */ - if((!f1 || !f1->cls) && (!f2 || !f2->cls)) + if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) HGOTO_DONE(0) - if(!f1 || !f1->cls) + if (!f1 || !f1->cls) HGOTO_DONE(-1) - if(!f2 || !f2->cls) + if (!f2 || !f2->cls) HGOTO_DONE(1) - if(f1->cls < f2->cls) + if (f1->cls < f2->cls) HGOTO_DONE(-1) - if(f1->cls > f2->cls) + if (f1->cls > f2->cls) HGOTO_DONE(1) /* Files are same driver; no cmp callback */ - if(!f1->cls->cmp) { - if(f1 < f2) + if (!f1->cls->cmp) { + if (f1 < f2) HGOTO_DONE(-1) - if(f1 > f2) + if (f1 > f2) HGOTO_DONE(1) HGOTO_DONE(0) } @@ -1051,7 +1033,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FDquery * @@ -1063,30 +1044,29 @@ done: *------------------------------------------------------------------------- */ int -H5FDquery(const H5FD_t *file, unsigned long *flags/*out*/) +H5FDquery(const H5FD_t *file, unsigned long *flags /*out*/) { - int ret_value = 0; + int ret_value = 0; FUNC_ENTER_API((-1)) H5TRACE2("Is", "*xx", file, flags); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "file class pointer cannot be NULL") - if(!flags) + if (!flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "flags parameter cannot be NULL") /* Call private function */ - if(H5FD__query(file, flags) < 0) + if (H5FD__query(file, flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, (-1), "unable to query feature flags") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_query * @@ -1097,9 +1077,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD__query(const H5FD_t *file, unsigned long *flags/*out*/) +H5FD__query(const H5FD_t *file, unsigned long *flags /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1109,18 +1089,17 @@ H5FD__query(const H5FD_t *file, unsigned long *flags/*out*/) HDassert(flags); /* Dispatch to driver (if available) */ - if(file->cls->query) { - if((file->cls->query)(file, flags) < 0) + if (file->cls->query) { + if ((file->cls->query)(file, flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to query feature flags") } else - *flags=0; + *flags = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_query() */ - /*------------------------------------------------------------------------- * Function: H5FDalloc * @@ -1160,31 +1139,30 @@ done: haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { - haddr_t ret_value = HADDR_UNDEF; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_API(HADDR_UNDEF) H5TRACE4("a", "*xMtih", file, type, dxpl_id, size); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") - if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid request type") - if(size == 0) + if (size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "zero-size request") - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ - if(HADDR_UNDEF == (ret_value = H5FD__alloc_real(file, type, size, NULL, NULL))) + if (HADDR_UNDEF == (ret_value = H5FD__alloc_real(file, type, size, NULL, NULL))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory") /* (Note compensating for base address subtraction in internal routine) */ @@ -1194,7 +1172,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5FDalloc() */ - /*------------------------------------------------------------------------- * Function: H5FDfree * @@ -1212,37 +1189,35 @@ done: herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*xMtiah", file, type, dxpl_id, addr, size); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid request type") - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD__free_real(file, type, addr - file->base_addr, size) < 0) + if (H5FD__free_real(file, type, addr - file->base_addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "file deallocation request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDfree() */ - /*------------------------------------------------------------------------- * Function: H5FDget_eoa * @@ -1257,21 +1232,21 @@ done: haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value; + haddr_t ret_value; FUNC_ENTER_API(HADDR_UNDEF) H5TRACE2("a", "*xMt", file, type); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") - if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file type") /* Call private function */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(file, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eoa(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eoa request failed") /* (Note compensating for base address subtraction in internal routine) */ @@ -1281,7 +1256,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5FDget_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FDset_eoa * @@ -1306,31 +1280,30 @@ done: herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xMta", file, type, addr); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file type") - if(!H5F_addr_defined(addr) || addr > file->maxaddr) + if (!H5F_addr_defined(addr) || addr > file->maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid end-of-address value") /* Call private function */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_set_eoa(file, type, addr - file->base_addr) < 0) + if (H5FD_set_eoa(file, type, addr - file->base_addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file set eoa request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDset_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FDget_eof * @@ -1355,19 +1328,19 @@ done: haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value; + haddr_t ret_value; FUNC_ENTER_API(HADDR_UNDEF) H5TRACE2("a", "*xMt", file, type); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") /* Call private function */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eof(file, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eof(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eof request failed") /* (Note compensating for base address subtraction in internal routine) */ @@ -1377,7 +1350,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5FDget_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_maxaddr * @@ -1391,7 +1363,7 @@ done: haddr_t H5FD_get_maxaddr(const H5FD_t *file) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -1405,7 +1377,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_maxaddr() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_feature_flags * @@ -1430,7 +1401,6 @@ H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_get_feature_flags() */ - /*------------------------------------------------------------------------- * Function: H5FD_set_feature_flags * @@ -1454,7 +1424,6 @@ H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_set_feature_flags() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_fs_type_map * @@ -1467,7 +1436,7 @@ H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags) herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1477,9 +1446,9 @@ H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map) HDassert(type_map); /* Check for VFD class providing a type map retrieval rouine */ - if(file->cls->get_type_map) { + if (file->cls->get_type_map) { /* Retrieve type mapping for this file */ - if((file->cls->get_type_map)(file, type_map) < 0) + if ((file->cls->get_type_map)(file, type_map) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get type map failed") } /* end if */ else @@ -1490,7 +1459,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_fs_type_map() */ - /*------------------------------------------------------------------------- * Function: H5FDread * @@ -1509,42 +1477,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - void *buf/*out*/) +H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "*xMtiazx", file, type, dxpl_id, addr, size, buf); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(!buf) + if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL") /* Get the default dataset transfer property list if the user didn't provide one */ - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_read(file, type, addr - file->base_addr, size, buf) < 0) + if (H5FD_read(file, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDread() */ - /*------------------------------------------------------------------------- * Function: H5FDwrite * @@ -1558,42 +1523,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - const void *buf) +H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "*xMtiaz*x", file, type, dxpl_id, addr, size, buf); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(!buf) + if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL") /* Get the default dataset transfer property list if the user didn't provide one */ - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_write(file, type, addr - file->base_addr, size, buf) < 0) + if (H5FD_write(file, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDwrite() */ - /*------------------------------------------------------------------------- * Function: H5FDflush * @@ -1607,35 +1569,33 @@ done: herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xib", file, dxpl_id, closing); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ - if(H5FD_flush(file, closing) < 0) + if (H5FD_flush(file, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "file flush request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDflush() */ - /*------------------------------------------------------------------------- * Function: H5FD_flush * @@ -1648,7 +1608,7 @@ done: herr_t H5FD_flush(H5FD_t *file, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1657,14 +1617,13 @@ H5FD_flush(H5FD_t *file, hbool_t closing) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->flush && (file->cls->flush)(file, H5CX_get_dxpl(), closing) < 0) + if (file->cls->flush && (file->cls->flush)(file, H5CX_get_dxpl(), closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_flush() */ - /*------------------------------------------------------------------------- * Function: H5FDtruncate * @@ -1677,34 +1636,32 @@ done: herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xib", file, dxpl_id, closing); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ - if(H5FD_truncate(file, closing) < 0) + if (H5FD_truncate(file, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "file flush request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDtruncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_truncate * @@ -1717,7 +1674,7 @@ done: herr_t H5FD_truncate(H5FD_t *file, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1726,14 +1683,13 @@ H5FD_truncate(H5FD_t *file, hbool_t closing) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->truncate && (file->cls->truncate)(file, H5CX_get_dxpl(), closing) < 0) + if (file->cls->truncate && (file->cls->truncate)(file, H5CX_get_dxpl(), closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver truncate request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FDlock * @@ -1746,27 +1702,25 @@ done: herr_t H5FDlock(H5FD_t *file, hbool_t rw) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "*xb", file, rw); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") /* Call private function */ - if(H5FD_lock(file, rw) < 0) + if (H5FD_lock(file, rw) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file lock request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDlock() */ - - /*------------------------------------------------------------------------- * Function: H5FD_lock * @@ -1779,7 +1733,7 @@ done: herr_t H5FD_lock(H5FD_t *file, hbool_t rw) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1788,14 +1742,13 @@ H5FD_lock(H5FD_t *file, hbool_t rw) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->lock && (file->cls->lock)(file, rw) < 0) + if (file->cls->lock && (file->cls->lock)(file, rw) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver lock request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_lock() */ - /*------------------------------------------------------------------------- * Function: H5FDunlock * @@ -1808,26 +1761,25 @@ done: herr_t H5FDunlock(H5FD_t *file) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", file); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") /* Call private function */ - if(H5FD_unlock(file) < 0) + if (H5FD_unlock(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file unlock request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDunlock() */ - /*------------------------------------------------------------------------- * Function: H5FD_unlock * @@ -1840,7 +1792,7 @@ done: herr_t H5FD_unlock(H5FD_t *file) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1849,14 +1801,13 @@ H5FD_unlock(H5FD_t *file) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->unlock && (file->cls->unlock)(file) < 0) + if (file->cls->unlock && (file->cls->unlock)(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver unlock request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_unlock() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_fileno * @@ -1883,7 +1834,6 @@ H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_get_fileno() */ - /*-------------------------------------------------------------------------- * Function: H5FDget_vfd_handle * @@ -1903,27 +1853,26 @@ H5FDget_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle) H5TRACE3("e", "*xi**x", file, fapl_id, file_handle); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fapl_id parameter is not a file access property list") - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle parameter cannot be NULL") /* Call private function */ - if(H5FD_get_vfd_handle(file, fapl_id, file_handle) < 0) + if (H5FD_get_vfd_handle(file, fapl_id, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: - if(FAIL == ret_value) + if (FAIL == ret_value) *file_handle = NULL; FUNC_LEAVE_API(ret_value) } /* end H5FDget_vfd_handle() */ - /*-------------------------------------------------------------------------- * Function: H5FD_get_vfd_handle * @@ -1946,16 +1895,15 @@ H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle) HDassert(file_handle); /* Dispatch to driver */ - if(NULL == file->cls->get_handle) + if (NULL == file->cls->get_handle) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "file driver has no `get_vfd_handle' method") - if((file->cls->get_handle)(file, fapl_id, file_handle) < 0) + if ((file->cls->get_handle)(file, fapl_id, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_vfd_handle() */ - /*-------------------------------------------------------------------------- * Function: H5FD_set_base_addr * @@ -1980,7 +1928,6 @@ H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_set_base_addr() */ - /*-------------------------------------------------------------------------- * Function: H5FD_get_base_addr * @@ -2003,7 +1950,6 @@ H5FD_get_base_addr(const H5FD_t *file) FUNC_LEAVE_NOAPI(file->base_addr) } /* end H5FD_get_base_addr() */ - /*-------------------------------------------------------------------------- * Function: H5FD_set_paged_aggr * @@ -2027,30 +1973,29 @@ H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_set_paged_aggr() */ - /*------------------------------------------------------------------------- -* Function: H5FDdriver_query -* -* Purpose: Similar to H5FD_query(), but intended for cases when we don't -* have a file available (e.g. before one is opened). Since we -* can't use the file to get the driver, the driver ID is passed -* in as a parameter. -* -* Return: Non-negative on success/Negative on failure -* -*------------------------------------------------------------------------- -*/ + * Function: H5FDdriver_query + * + * Purpose: Similar to H5FD_query(), but intended for cases when we don't + * have a file available (e.g. before one is opened). Since we + * can't use the file to get the driver, the driver ID is passed + * in as a parameter. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ herr_t -H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/) +H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/) { - H5FD_class_t *driver = NULL; /* Pointer to VFD class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_class_t *driver = NULL; /* Pointer to VFD class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", driver_id, flags); /* Check arguments */ - if(NULL == flags) + if (NULL == flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "flags parameter cannot be NULL") /* Check for the driver to query and then query it */ @@ -2062,4 +2007,3 @@ H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/) done: FUNC_LEAVE_API(ret_value) } /* end H5FDdriver_query() */ - diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 394380b..c62b26b 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -22,24 +22,24 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDcore.h" /* Core file driver */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDcore.h" /* Core file driver */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_CORE_g = 0; /* The skip list node type. Represents a region in the file. */ typedef struct H5FD_core_region_t { - haddr_t start; /* Start address of the region */ - haddr_t end; /* End address of the region */ + haddr_t start; /* Start address of the region */ + haddr_t end; /* End address of the region */ } H5FD_core_region_t; /* The description of a file belonging to this driver. The 'eoa' and 'eof' @@ -47,23 +47,23 @@ typedef struct H5FD_core_region_t { * of the file (the current size of the underlying memory). */ typedef struct H5FD_core_t { - H5FD_t pub; /* public stuff, must be first */ - char *name; /* for equivalence testing */ - unsigned char *mem; /* the underlying memory */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* current allocated size */ - size_t increment; /* multiples for mem allocation */ - hbool_t backing_store; /* write to file name on flush */ - hbool_t write_tracking; /* Whether to track writes */ - size_t bstore_page_size; /* backing store page size */ - int fd; /* backing store file descriptor */ + H5FD_t pub; /* public stuff, must be first */ + char * name; /* for equivalence testing */ + unsigned char *mem; /* the underlying memory */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* current allocated size */ + size_t increment; /* multiples for mem allocation */ + hbool_t backing_store; /* write to file name on flush */ + hbool_t write_tracking; /* Whether to track writes */ + size_t bstore_page_size; /* backing store page size */ + int fd; /* backing store file descriptor */ /* Information for determining uniqueness of a file with a backing store */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ - ino_t inode; /*file i-node number */ + dev_t device; /*file device number */ + ino_t inode; /*file i-node number */ #else /* Files in windows are uniquely identified by the volume serial * number and the file index (both low and high parts). @@ -79,29 +79,29 @@ typedef struct H5FD_core_t { * * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx */ - DWORD nFileIndexLow; - DWORD nFileIndexHigh; - DWORD dwVolumeSerialNumber; - - HANDLE hFile; /* Native windows file handle */ -#endif /* H5_HAVE_WIN32_API */ - hbool_t dirty; /* changes not saved? */ - H5FD_file_image_callbacks_t fi_callbacks; /* file image callbacks */ - H5SL_t *dirty_list; /* dirty parts of the file */ + DWORD nFileIndexLow; + DWORD nFileIndexHigh; + DWORD dwVolumeSerialNumber; + + HANDLE hFile; /* Native windows file handle */ +#endif /* H5_HAVE_WIN32_API */ + hbool_t dirty; /* changes not saved? */ + H5FD_file_image_callbacks_t fi_callbacks; /* file image callbacks */ + H5SL_t * dirty_list; /* dirty parts of the file */ } H5FD_core_t; /* Driver-specific file access properties */ typedef struct H5FD_core_fapl_t { - size_t increment; /* how much to grow memory */ - hbool_t backing_store; /* write to file name on flush */ - hbool_t write_tracking; /* Whether to track writes */ - size_t page_size; /* Page size for tracked writes */ + size_t increment; /* how much to grow memory */ + hbool_t backing_store; /* write to file name on flush */ + hbool_t write_tracking; /* Whether to track writes */ + size_t page_size; /* Page size for tracked writes */ } H5FD_core_fapl_t; /* Allocate memory in multiples of this size by default */ -#define H5FD_CORE_INCREMENT 8192 -#define H5FD_CORE_WRITE_TRACKING_FLAG FALSE -#define H5FD_CORE_WRITE_TRACKING_PAGE_SIZE 524288 +#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_WRITE_TRACKING_FLAG FALSE +#define H5FD_CORE_WRITE_TRACKING_PAGE_SIZE 524288 /* These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. @@ -116,77 +116,74 @@ typedef struct H5FD_core_fapl_t { * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely in memory. */ -#define MAXADDR ((haddr_t)((~(size_t)0)-1)) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || (A) > (haddr_t)MAXADDR) -#define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (size_t)((A)+(Z))<(size_t)(A)) +#define MAXADDR ((haddr_t)((~(size_t)0) - 1)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || (A) > (haddr_t)MAXADDR) +#define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (size_t)((A) + (Z)) < (size_t)(A)) /* Prototypes */ -static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end); -static herr_t H5FD__core_destroy_dirty_list(H5FD_core_t *file); -static herr_t H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size); -static herr_t H5FD__core_term(void); -static void *H5FD__core_fapl_get(H5FD_t *_file); -static H5FD_t *H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); -static herr_t H5FD__core_close(H5FD_t *_file); -static int H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD__core_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end); +static herr_t H5FD__core_destroy_dirty_list(H5FD_core_t *file); +static herr_t H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size); +static herr_t H5FD__core_term(void); +static void * H5FD__core_fapl_get(H5FD_t *_file); +static H5FD_t *H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__core_close(H5FD_t *_file); +static int H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__core_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD__core_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD__core_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD__core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_core_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_core_unlock(H5FD_t *_file); +static herr_t H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_core_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_core_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_core_g = { - "core", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__core_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - sizeof(H5FD_core_fapl_t), /* fapl_size */ - H5FD__core_fapl_get, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__core_open, /* open */ - H5FD__core_close, /* close */ - H5FD__core_cmp, /* cmp */ - H5FD__core_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD__core_get_eoa, /* get_eoa */ - H5FD__core_set_eoa, /* set_eoa */ - H5FD__core_get_eof, /* get_eof */ - H5FD__core_get_handle, /* get_handle */ - H5FD__core_read, /* read */ - H5FD__core_write, /* write */ - H5FD__core_flush, /* flush */ - H5FD__core_truncate, /* truncate */ - H5FD_core_lock, /* lock */ - H5FD_core_unlock, /* unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "core", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__core_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_core_fapl_t), /* fapl_size */ + H5FD__core_fapl_get, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__core_open, /* open */ + H5FD__core_close, /* close */ + H5FD__core_cmp, /* cmp */ + H5FD__core_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__core_get_eoa, /* get_eoa */ + H5FD__core_set_eoa, /* set_eoa */ + H5FD__core_get_eof, /* get_eof */ + H5FD__core_get_handle, /* get_handle */ + H5FD__core_read, /* read */ + H5FD__core_write, /* write */ + H5FD__core_flush, /* flush */ + H5FD__core_truncate, /* truncate */ + H5FD_core_lock, /* lock */ + H5FD_core_unlock, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Define a free list to manage the region type */ H5FL_DEFINE(H5FD_core_region_t); - /*------------------------------------------------------------------------- * Function: H5FD__core_add_dirty_region * @@ -200,13 +197,13 @@ H5FL_DEFINE(H5FD_core_region_t); static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) { - H5FD_core_region_t *b_item = NULL; - H5FD_core_region_t *a_item = NULL; - H5FD_core_region_t *item = NULL; - haddr_t b_addr = 0; - haddr_t a_addr = 0; - hbool_t create_new_node = TRUE; - herr_t ret_value = SUCCEED; + H5FD_core_region_t *b_item = NULL; + H5FD_core_region_t *a_item = NULL; + H5FD_core_region_t *item = NULL; + haddr_t b_addr = 0; + haddr_t a_addr = 0; + hbool_t create_new_node = TRUE; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -215,30 +212,30 @@ H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) HDassert(start <= end); /* Adjust the dirty region to the nearest block boundaries */ - if(start % file->bstore_page_size != 0) + if (start % file->bstore_page_size != 0) start = (start / file->bstore_page_size) * file->bstore_page_size; - if(end % file->bstore_page_size != (file->bstore_page_size - 1)) { + if (end % file->bstore_page_size != (file->bstore_page_size - 1)) { end = (((end / file->bstore_page_size) + 1) * file->bstore_page_size) - 1; - if(end > file->eof) + if (end > file->eof) end = file->eof - 1; } /* end if */ /* Get the regions before and after the intended insertion point */ - b_addr = start +1; + b_addr = start + 1; a_addr = end + 2; b_item = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &b_addr); a_item = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &a_addr); /* Check to see if we need to extend the upper end of the NEW region */ - if(a_item) - if(start < a_item->start && end < a_item->end) { + if (a_item) + if (start < a_item->start && end < a_item->end) { /* Extend the end of the NEW region to match the existing AFTER region */ end = a_item->end; } /* end if */ /* Attempt to extend the PREV region */ - if(b_item) - if(start <= b_item->end + 1) { + if (b_item) + if (start <= b_item->end + 1) { /* Need to set this for the delete algorithm */ start = b_item->start; @@ -250,10 +247,10 @@ H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) } /* end if */ /* Remove any old nodes that are no longer needed */ - while(a_item && a_item->start > start) { + while (a_item && a_item->start > start) { H5FD_core_region_t *less; - haddr_t key = a_item->start - 1; + haddr_t key = a_item->start - 1; /* Save the previous node before we trash this one */ less = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &key); @@ -263,28 +260,29 @@ H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) a_item = H5FL_FREE(H5FD_core_region_t, a_item); /* Set up to check the next node */ - if(less) + if (less) a_item = less; } /* end while */ /* Insert the new node */ - if(create_new_node) { - if(NULL == (item = (H5FD_core_region_t *)H5SL_search(file->dirty_list, &start))) { + if (create_new_node) { + if (NULL == (item = (H5FD_core_region_t *)H5SL_search(file->dirty_list, &start))) { /* Ok to insert. No pre-existing node with that key. */ - item = (H5FD_core_region_t *)H5FL_CALLOC(H5FD_core_region_t); + item = (H5FD_core_region_t *)H5FL_CALLOC(H5FD_core_region_t); item->start = start; - item->end = end; - if(H5SL_insert(file->dirty_list, item, &item->start) < 0) - HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, FAIL, "can't insert new dirty region: (%llu, %llu)\n", (unsigned long long)start, (unsigned long long)end) + item->end = end; + if (H5SL_insert(file->dirty_list, item, &item->start) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, FAIL, "can't insert new dirty region: (%llu, %llu)\n", + (unsigned long long)start, (unsigned long long)end) } /* end if */ else { /* Store the new item endpoint if it's bigger */ item->end = (item->end < end) ? end : item->end; } /* end else */ - } /* end if */ + } /* end if */ else { /* Update the size of the before region */ - if(b_item->end < end) + if (b_item->end < end) b_item->end = end; } /* end else */ @@ -292,7 +290,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_add_dirty_region() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_destroy_dirty_list * @@ -312,13 +309,13 @@ H5FD__core_destroy_dirty_list(H5FD_core_t *file) HDassert(file); /* Destroy the list, including any remaining list elements */ - if(file->dirty_list) { + if (file->dirty_list) { H5FD_core_region_t *region = NULL; - while(NULL != (region = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) + while (NULL != (region = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) region = H5FL_FREE(H5FD_core_region_t, region); - if(H5SL_close(file->dirty_list) < 0) + if (H5SL_close(file->dirty_list) < 0) HGOTO_ERROR(H5E_SLIST, H5E_CLOSEERROR, FAIL, "can't close core vfd dirty list") file->dirty_list = NULL; } /* end if */ @@ -327,7 +324,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_destroy_dirty_list() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_write_to_bstore * @@ -340,11 +336,11 @@ done: static herr_t H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) { - unsigned char *ptr = file->mem + addr; /* mutable pointer into the - * buffer (can't change mem) - */ - HDoff_t offset = (HDoff_t)addr; /* Offset to write at */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned char *ptr = file->mem + addr; /* mutable pointer into the + * buffer (can't change mem) + */ + HDoff_t offset = (HDoff_t)addr; /* Offset to write at */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -352,19 +348,19 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ - if((HDoff_t)addr != HDlseek(file->fd, (off_t)addr, SEEK_SET)) + if ((HDoff_t)addr != HDlseek(file->fd, (off_t)addr, SEEK_SET)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store") #endif /* H5_HAVE_PREADWRITE */ while (size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -372,20 +368,26 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, ptr, bytes_in, offset); - if(bytes_wrote > 0) + if (bytes_wrote > 0) offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, ptr, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_wrote && EINTR == errno); + } while (-1 == bytes_wrote && EINTR == errno); - if(-1 == bytes_wrote) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_wrote) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, " + "errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this " + "sub-write = %llu, bytes actually written = %llu, offset = %llu", + HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ HDassert(bytes_wrote > 0); @@ -400,7 +402,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_write_to_bstore() */ - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -417,14 +418,13 @@ H5FD__init_package(void) FUNC_ENTER_NOAPI_NOINIT - if(H5FD_core_init() < 0) + if (H5FD_core_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize core VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_core_init * @@ -442,11 +442,11 @@ done: hid_t H5FD_core_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if(H5I_VFL != H5I_get_type(H5FD_CORE_g)) + if (H5I_VFL != H5I_get_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -456,7 +456,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_core_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__core_term * @@ -480,7 +479,6 @@ H5FD__core_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__core_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_core_write_tracking * @@ -497,42 +495,41 @@ H5FD__core_term(void) herr_t H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) { - H5P_genplist_t *plist; /* Property list pointer */ - H5FD_core_fapl_t fa; /* Core VFD info */ - const H5FD_core_fapl_t *old_fa; /* Old core VFD info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5FD_core_fapl_t fa; /* Core VFD info */ + const H5FD_core_fapl_t *old_fa; /* Old core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ibz", plist_id, is_enabled, page_size); /* The page size cannot be zero */ - if(page_size == 0) + if (page_size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page_size cannot be zero") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5FD_CORE != H5P_peek_driver(plist)) + if (H5FD_CORE != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (old_fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (old_fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Set VFD info values */ HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); - fa.increment = old_fa->increment; - fa.backing_store = old_fa->backing_store; + fa.increment = old_fa->increment; + fa.backing_store = old_fa->backing_store; fa.write_tracking = is_enabled; - fa.page_size = page_size; + fa.page_size = page_size; /* Set the property values & the driver for the FAPL */ - if(H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + if (H5P_set_driver(plist, H5FD_CORE, &fa) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_core_write_tracking() */ - /*------------------------------------------------------------------------- * Function: H5Pget_core_write_tracking * @@ -549,32 +546,31 @@ done: herr_t H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_size) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5FD_core_fapl_t *fa; /* Core VFD info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + const H5FD_core_fapl_t *fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*b*z", plist_id, is_enabled, page_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5FD_CORE != H5P_peek_driver(plist)) + if (H5FD_CORE != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Get values */ - if(is_enabled) + if (is_enabled) *is_enabled = fa->write_tracking; - if(page_size) + if (page_size) *page_size = fa->page_size; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_core_write_tracking() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_core * @@ -592,33 +588,32 @@ done: herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) { - H5P_genplist_t *plist; /* Property list pointer */ - H5FD_core_fapl_t fa; /* Core VFD info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5FD_core_fapl_t fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "izb", fapl_id, increment, backing_store); /* Check argument */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /* Set VFD info values */ HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); - fa.increment = increment; - fa.backing_store = backing_store; + fa.increment = increment; + fa.backing_store = backing_store; fa.write_tracking = H5FD_CORE_WRITE_TRACKING_FLAG; - fa.page_size = H5FD_CORE_WRITE_TRACKING_PAGE_SIZE; + fa.page_size = H5FD_CORE_WRITE_TRACKING_PAGE_SIZE; /* Set the property values & the driver for the FAPL */ - if(H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + if (H5P_set_driver(plist, H5FD_CORE, &fa) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_core() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_core * @@ -634,30 +629,29 @@ done: herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5FD_core_fapl_t *fa; /* Core VFD info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + const H5FD_core_fapl_t *fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, increment, backing_store); - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5FD_CORE != H5P_peek_driver(plist)) + if (H5FD_CORE != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - if(increment) + if (increment) *increment = fa->increment; - if(backing_store) + if (backing_store) *backing_store = fa->backing_store; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_core() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_fapl_get * @@ -674,19 +668,19 @@ done: static void * H5FD__core_fapl_get(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; - H5FD_core_fapl_t *fa; /* Core VFD info */ - void *ret_value = NULL; /* Return value */ + H5FD_core_t * file = (H5FD_core_t *)_file; + H5FD_core_fapl_t *fa; /* Core VFD info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - if(NULL == (fa = (H5FD_core_fapl_t *)H5MM_calloc(sizeof(H5FD_core_fapl_t)))) + if (NULL == (fa = (H5FD_core_fapl_t *)H5MM_calloc(sizeof(H5FD_core_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - fa->increment = file->increment; - fa->backing_store = (hbool_t)(file->fd >= 0); + fa->increment = file->increment; + fa->backing_store = (hbool_t)(file->fd >= 0); fa->write_tracking = file->write_tracking; - fa->page_size = file->bstore_page_size; + fa->page_size = file->bstore_page_size; /* Set return value */ ret_value = fa; @@ -695,7 +689,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD___core_open * @@ -714,77 +707,80 @@ done: static H5FD_t * H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - int o_flags; - H5FD_core_t *file = NULL; - const H5FD_core_fapl_t *fa = NULL; - H5P_genplist_t *plist; /* Property list pointer */ + int o_flags; + H5FD_core_t * file = NULL; + const H5FD_core_fapl_t *fa = NULL; + H5P_genplist_t * plist; /* Property list pointer */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - h5_stat_t sb; - int fd = -1; - H5FD_file_image_info_t file_image_info; - H5FD_t *ret_value = NULL; /* Return value */ + h5_stat_t sb; + int fd = -1; + H5FD_file_image_info_t file_image_info; + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow") HDassert(H5P_DEFAULT != fapl_id); - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if(H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if(H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if(H5F_ACC_EXCL & flags) o_flags |= O_EXCL; + if (H5F_ACC_TRUNC & flags) + o_flags |= O_TRUNC; + if (H5F_ACC_CREAT & flags) + o_flags |= O_CREAT; + if (H5F_ACC_EXCL & flags) + o_flags |= O_EXCL; /* Retrieve initial file image info */ - if(H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial file image info") /* If the file image exists and this is an open, make sure the file doesn't exist */ HDassert(((file_image_info.buffer != NULL) && (file_image_info.size > 0)) || ((file_image_info.buffer == NULL) && (file_image_info.size == 0))); HDmemset(&sb, 0, sizeof(sb)); - if((file_image_info.buffer != NULL) && !(H5F_ACC_CREAT & flags)) { - if(HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW) >= 0) + if ((file_image_info.buffer != NULL) && !(H5F_ACC_CREAT & flags)) { + if (HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW) >= 0) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file already exists") /* If backing store is requested, create and stat the file * Note: We are forcing the O_CREAT flag here, even though this is * technically an open. */ - if(fa->backing_store) { - if((fd = HDopen(name, o_flags | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) + if (fa->backing_store) { + if ((fd = HDopen(name, o_flags | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") } /* end if */ - } /* end if */ + } /* end if */ /* Open backing store, and get stat() from file. The only case that backing * store is off is when the backing_store flag is off and H5F_ACC_CREAT is * on. */ - else if(fa->backing_store || !(H5F_ACC_CREAT & flags)) { - if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) + else if (fa->backing_store || !(H5F_ACC_CREAT & flags)) { + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") } /* end if */ /* Create the new file struct */ - if(NULL == (file = (H5FD_core_t *)H5MM_calloc(sizeof(H5FD_core_t)))) + if (NULL == (file = (H5FD_core_t *)H5MM_calloc(sizeof(H5FD_core_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; - if(name && *name) + if (name && *name) file->name = H5MM_xstrdup(name); /* The increment comes from either the file access property list or the @@ -799,44 +795,45 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr /* Save file image callbacks */ file->fi_callbacks = file_image_info.callbacks; - if(fd >= 0) { + if (fd >= 0) { /* Retrieve information for determining uniqueness of file */ #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); - if(INVALID_HANDLE_VALUE == file->hFile) + if (INVALID_HANDLE_VALUE == file->hFile) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file handle") - if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) + if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file information") - file->nFileIndexHigh = fileinfo.nFileIndexHigh; - file->nFileIndexLow = fileinfo.nFileIndexLow; + file->nFileIndexHigh = fileinfo.nFileIndexHigh; + file->nFileIndexLow = fileinfo.nFileIndexLow; file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber; -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /* H5_HAVE_WIN32_API */ - } /* end if */ + } /* end if */ /* If an existing file is opened, load the whole file into memory. */ - if(!(H5F_ACC_CREAT & flags)) { + if (!(H5F_ACC_CREAT & flags)) { size_t size; /* Retrieve file size */ - if(file_image_info.buffer && file_image_info.size > 0) + if (file_image_info.buffer && file_image_info.size > 0) size = file_image_info.size; else size = (size_t)sb.st_size; /* Check if we should allocate the memory buffer and read in existing data */ - if(size) { + if (size) { /* Allocate memory for the file's data, using the file image callback if available. */ - if(file->fi_callbacks.image_malloc) { - if(NULL == (file->mem = (unsigned char*)file->fi_callbacks.image_malloc(size, H5FD_FILE_IMAGE_OP_FILE_OPEN, file->fi_callbacks.udata))) + if (file->fi_callbacks.image_malloc) { + if (NULL == (file->mem = (unsigned char *)file->fi_callbacks.image_malloc( + size, H5FD_FILE_IMAGE_OP_FILE_OPEN, file->fi_callbacks.udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "image malloc callback failed") } /* end if */ else { - if(NULL == (file->mem = (unsigned char*)H5MM_malloc(size))) + if (NULL == (file->mem = (unsigned char *)H5MM_malloc(size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "unable to allocate memory block") } /* end else */ @@ -844,9 +841,11 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->eof = size; /* If there is an initial file image, copy it, using the callback if possible */ - if(file_image_info.buffer && file_image_info.size > 0) { - if(file->fi_callbacks.image_memcpy) { - if(file->mem != file->fi_callbacks.image_memcpy(file->mem, file_image_info.buffer, size, H5FD_FILE_IMAGE_OP_FILE_OPEN, file->fi_callbacks.udata)) + if (file_image_info.buffer && file_image_info.size > 0) { + if (file->fi_callbacks.image_memcpy) { + if (file->mem != file->fi_callbacks.image_memcpy(file->mem, file_image_info.buffer, size, + H5FD_FILE_IMAGE_OP_FILE_OPEN, + file->fi_callbacks.udata)) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, NULL, "image_memcpy callback failed") } /* end if */ else @@ -858,17 +857,17 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr * partial results, and the end of the file. */ - uint8_t *mem = file->mem; /* memory pointer for writes */ - HDoff_t offset = (HDoff_t)0; /* offset for reading */ + uint8_t *mem = file->mem; /* memory pointer for writes */ + HDoff_t offset = (HDoff_t)0; /* offset for reading */ - while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to read */ - h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ + while (size > 0) { + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -876,20 +875,27 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, mem, bytes_in, offset); - if(bytes_read > 0) + if (bytes_read > 0) offset += bytes_read; #else bytes_read = HDread(file->fd, mem, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_read && EINTR == errno); + } while (-1 == bytes_read && EINTR == errno); - if(-1 == bytes_read) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_read) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', file->mem = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), file->mem, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); + HGOTO_ERROR( + H5E_IO, H5E_READERROR, NULL, + "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', file->mem = %p, total read size = %llu, bytes this " + "sub-read = %llu, bytes actually read = %llu, offset = %llu", + HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), file->mem, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_read, (unsigned long long)offset); } /* end if */ HDassert(bytes_read >= 0); @@ -898,31 +904,31 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr mem += bytes_read; size -= (size_t)bytes_read; } /* end while */ - } /* end else */ - } /* end if */ - } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ /* Get the write tracking & page size */ - file->write_tracking = fa->write_tracking; + file->write_tracking = fa->write_tracking; file->bstore_page_size = fa->page_size; /* Set up write tracking if the backing store is on */ file->dirty_list = NULL; - if(fa->backing_store) { - hbool_t use_write_tracking = FALSE; /* what we're actually doing */ + if (fa->backing_store) { + hbool_t use_write_tracking = FALSE; /* what we're actually doing */ /* default is to have write tracking OFF for create (hence the check to see * if the user explicitly set a page size) and ON with the default page size * on open (when not read-only). */ /* Only use write tracking if the file is open for writing */ - use_write_tracking = (TRUE == fa->write_tracking) /* user asked for write tracking */ - && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ - && (file->bstore_page_size != 0); /* page size is not zero */ + use_write_tracking = (TRUE == fa->write_tracking) /* user asked for write tracking */ + && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ + && (file->bstore_page_size != 0); /* page size is not zero */ /* initialize the dirty list */ - if(use_write_tracking) - if(NULL == (file->dirty_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (use_write_tracking) + if (NULL == (file->dirty_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, NULL, "can't create core vfd dirty region list"); } /* end if */ @@ -930,8 +936,8 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr ret_value = (H5FD_t *)file; done: - if(!ret_value && file) { - if(file->fd >= 0) + if (!ret_value && file) { + if (file->fd >= 0) HDclose(file->fd); H5MM_xfree(file->name); H5MM_xfree(file->mem); @@ -941,7 +947,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_open() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_close * @@ -957,29 +962,30 @@ done: static herr_t H5FD__core_close(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Flush any changed buffers */ - if(H5FD__core_flush(_file, (hid_t)-1, TRUE) < 0) + if (H5FD__core_flush(_file, (hid_t)-1, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush core vfd backing store") /* Destroy the dirty region list */ - if(file->dirty_list) - if(H5FD__core_destroy_dirty_list(file) != SUCCEED) + if (file->dirty_list) + if (H5FD__core_destroy_dirty_list(file) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free core vfd dirty region list") /* Release resources */ - if(file->fd >= 0) + if (file->fd >= 0) HDclose(file->fd); - if(file->name) + if (file->name) H5MM_xfree(file->name); - if(file->mem) { + if (file->mem) { /* Use image callback if available */ - if(file->fi_callbacks.image_free) { - if(file->fi_callbacks.image_free(file->mem, H5FD_FILE_IMAGE_OP_FILE_CLOSE, file->fi_callbacks.udata) < 0) + if (file->fi_callbacks.image_free) { + if (file->fi_callbacks.image_free(file->mem, H5FD_FILE_IMAGE_OP_FILE_CLOSE, + file->fi_callbacks.udata) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else @@ -992,7 +998,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_close() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_cmp * @@ -1013,54 +1018,66 @@ done: static int H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_core_t *f1 = (const H5FD_core_t*)_f1; - const H5FD_core_t *f2 = (const H5FD_core_t*)_f2; - int ret_value = 0; + const H5FD_core_t *f1 = (const H5FD_core_t *)_f1; + const H5FD_core_t *f2 = (const H5FD_core_t *)_f2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - if(f1->fd >= 0 && f2->fd >= 0) { + if (f1->fd >= 0 && f2->fd >= 0) { /* Compare low level file information for backing store */ #ifdef H5_HAVE_WIN32_API - if(f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) HGOTO_DONE(-1) - if(f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) HGOTO_DONE(1) + if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) + HGOTO_DONE(-1) + if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) + HGOTO_DONE(1) - if(f1->nFileIndexHigh < f2->nFileIndexHigh) HGOTO_DONE(-1) - if(f1->nFileIndexHigh > f2->nFileIndexHigh) HGOTO_DONE(1) + if (f1->nFileIndexHigh < f2->nFileIndexHigh) + HGOTO_DONE(-1) + if (f1->nFileIndexHigh > f2->nFileIndexHigh) + HGOTO_DONE(1) - if(f1->nFileIndexLow < f2->nFileIndexLow) HGOTO_DONE(-1) - if(f1->nFileIndexLow > f2->nFileIndexLow) HGOTO_DONE(1) + if (f1->nFileIndexLow < f2->nFileIndexLow) + HGOTO_DONE(-1) + if (f1->nFileIndexLow > f2->nFileIndexLow) + HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if (f1->device < f2->device) HGOTO_DONE(-1) - if (f1->device > f2->device) HGOTO_DONE(1) -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + HGOTO_DONE(-1) + if (f1->device > f2->device) + HGOTO_DONE(1) +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + HGOTO_DONE(-1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if (f1->inode < f2->inode) HGOTO_DONE(-1) - if (f1->inode > f2->inode) HGOTO_DONE(1) + if (f1->inode < f2->inode) + HGOTO_DONE(-1) + if (f1->inode > f2->inode) + HGOTO_DONE(1) #endif /*H5_HAVE_WIN32_API*/ - } /* end if */ + } /* end if */ else { - if (NULL==f1->name && NULL==f2->name) { - if (f1name && NULL == f2->name) { + if (f1 < f2) HGOTO_DONE(-1) - if (f1>f2) + if (f1 > f2) HGOTO_DONE(1) HGOTO_DONE(0) } /* end if */ - if (NULL==f1->name) + if (NULL == f1->name) HGOTO_DONE(-1) - if (NULL==f2->name) + if (NULL == f2->name) HGOTO_DONE(1) ret_value = HDstrcmp(f1->name, f2->name); @@ -1070,7 +1087,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_query * @@ -1085,33 +1101,34 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD__core_query(const H5FD_t * _file, unsigned long *flags /* out */) +H5FD__core_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t *)_file; FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_ALLOW_FILE_IMAGE; /* OK to use file image feature with this VFD */ - *flags |= H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS; /* OK to use file image callbacks with this VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_ALLOW_FILE_IMAGE; /* OK to use file image feature with this VFD */ + *flags |= H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS; /* OK to use file image callbacks with this VFD */ /* These feature flags are only applicable if the backing store is enabled */ - if(file && file->fd >= 0 && file->backing_store) { - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + if (file && file->fd >= 0 && file->backing_store) { + *flags |= + H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the + default VFD */ } } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__core_query() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_get_eoa * @@ -1129,14 +1146,13 @@ H5FD__core_query(const H5FD_t * _file, unsigned long *flags /* out */) static haddr_t H5FD__core_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD__core_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_set_eoa * @@ -1154,12 +1170,12 @@ H5FD__core_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(ADDR_OVERFLOW(addr)) + if (ADDR_OVERFLOW(addr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow") file->eoa = addr; @@ -1168,7 +1184,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_get_eof * @@ -1188,14 +1203,13 @@ done: static haddr_t H5FD__core_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD__core_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_get_handle * @@ -1209,38 +1223,38 @@ H5FD__core_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) +H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - H5FD_core_t *file = (H5FD_core_t *)_file; /* core VFD info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; /* core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ - if(!file_handle) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") + if (!file_handle) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") /* Check for non-default FAPL */ - if(H5P_FILE_ACCESS_DEFAULT != fapl && H5P_DEFAULT != fapl) { - H5P_genplist_t *plist; /* Property list pointer */ + if (H5P_FILE_ACCESS_DEFAULT != fapl && H5P_DEFAULT != fapl) { + H5P_genplist_t *plist; /* Property list pointer */ /* Get the FAPL */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl))) HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, FAIL, "not a file access property list") /* Check if private property for retrieving the backing store POSIX * file descriptor is set. (This should not be set except within the * library) QAK - 2009/12/04 */ - if(H5P_exist_plist(plist, H5F_ACS_WANT_POSIX_FD_NAME) > 0) { - hbool_t want_posix_fd; /* Setting for retrieving file descriptor from core VFD */ + if (H5P_exist_plist(plist, H5F_ACS_WANT_POSIX_FD_NAME) > 0) { + hbool_t want_posix_fd; /* Setting for retrieving file descriptor from core VFD */ /* Get property */ - if(H5P_get(plist, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0) + if (H5P_get(plist, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get property of retrieving file descriptor") /* If property is set, pass back the file descriptor instead of the memory address */ - if(want_posix_fd) + if (want_posix_fd) *file_handle = &(file->fd); else *file_handle = &(file->mem); @@ -1255,7 +1269,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_read * @@ -1274,10 +1287,10 @@ done: */ static herr_t H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf /*out*/) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1296,11 +1309,11 @@ H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU #ifndef NDEBUG hsize_t temp_nbytes; - temp_nbytes = file->eof-addr; - H5_CHECK_OVERFLOW(temp_nbytes,hsize_t,size_t); - nbytes = MIN(size,(size_t)temp_nbytes); -#else /* NDEBUG */ - nbytes = MIN(size,(size_t)(file->eof-addr)); + temp_nbytes = file->eof - addr; + H5_CHECK_OVERFLOW(temp_nbytes, hsize_t, size_t); + nbytes = MIN(size, (size_t)temp_nbytes); +#else /* NDEBUG */ + nbytes = MIN(size, (size_t)(file->eof - addr)); #endif /* NDEBUG */ H5MM_memcpy(buf, file->mem + addr, nbytes); @@ -1317,7 +1330,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_read() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_write * @@ -1334,10 +1346,10 @@ done: */ static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1345,7 +1357,7 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN HDassert(buf); /* Check for overflow conditions */ - if(REGION_OVERFLOW(addr, size)) + if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") /* @@ -1354,23 +1366,27 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN * careful of non-Posix realloc() that doesn't understand what to do when * the first argument is null. */ - if(addr + size > file->eof) { + if (addr + size > file->eof) { unsigned char *x; - size_t new_eof; + size_t new_eof; /* Determine new size of memory buffer */ H5_CHECKED_ASSIGN(new_eof, size_t, file->increment * ((addr + size) / file->increment), hsize_t); - if((addr + size) % file->increment) + if ((addr + size) % file->increment) new_eof += file->increment; /* (Re)allocate memory for the file buffer, using callbacks if available */ - if(file->fi_callbacks.image_realloc) { - if(NULL == (x = (unsigned char *)file->fi_callbacks.image_realloc(file->mem, new_eof, H5FD_FILE_IMAGE_OP_FILE_RESIZE, file->fi_callbacks.udata))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate memory block of %llu bytes with callback", (unsigned long long)new_eof) + if (file->fi_callbacks.image_realloc) { + if (NULL == (x = (unsigned char *)file->fi_callbacks.image_realloc( + file->mem, new_eof, H5FD_FILE_IMAGE_OP_FILE_RESIZE, file->fi_callbacks.udata))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to allocate memory block of %llu bytes with callback", + (unsigned long long)new_eof) } /* end if */ else { - if(NULL == (x = (unsigned char *)H5MM_realloc(file->mem, new_eof))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate memory block of %llu bytes", (unsigned long long)new_eof) + if (NULL == (x = (unsigned char *)H5MM_realloc(file->mem, new_eof))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to allocate memory block of %llu bytes", (unsigned long long)new_eof) } /* end else */ HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof)); @@ -1380,12 +1396,15 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN } /* end if */ /* Add the buffer region to the dirty list if using that optimization */ - if(file->dirty_list) { + if (file->dirty_list) { haddr_t start = addr; - haddr_t end = addr + (haddr_t)size - 1; + haddr_t end = addr + (haddr_t)size - 1; - if(H5FD__core_add_dirty_region(file, start, end) != SUCCEED) - HGOTO_ERROR(H5E_VFL, H5E_CANTINSERT, FAIL, "unable to add core VFD dirty region during write call - addresses: start=%llu end=%llu", (unsigned long long)start, (unsigned long long)end) + if (H5FD__core_add_dirty_region(file, start, end) != SUCCEED) + HGOTO_ERROR( + H5E_VFL, H5E_CANTINSERT, FAIL, + "unable to add core VFD dirty region during write call - addresses: start=%llu end=%llu", + (unsigned long long)start, (unsigned long long)end) } /* Write from BUF to memory */ @@ -1398,7 +1417,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_write() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_flush * @@ -1415,8 +1433,8 @@ done: static herr_t H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1424,32 +1442,32 @@ H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UN if (file->dirty && file->fd >= 0 && file->backing_store) { /* Use the dirty list, if available */ - if(file->dirty_list) { + if (file->dirty_list) { H5FD_core_region_t *item = NULL; - size_t size; + size_t size; - while(NULL != (item = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) { + while (NULL != (item = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) { /* The file may have been truncated, so check for that * and skip or adjust as necessary. */ - if(item->start < file->eof) { - if(item->end >= file->eof) + if (item->start < file->eof) { + if (item->end >= file->eof) item->end = file->eof - 1; size = (size_t)((item->end - item->start) + 1); - if(H5FD__core_write_to_bstore(file, item->start, size) != SUCCEED) + if (H5FD__core_write_to_bstore(file, item->start, size) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") } /* end if */ item = H5FL_FREE(H5FD_core_region_t, item); - } /* end while */ + } /* end while */ } /* end if */ /* Otherwise, write the entire file out at once */ else { - if(H5FD__core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) + if (H5FD__core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") } /* end else */ @@ -1460,7 +1478,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_flush() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_truncate * @@ -1499,52 +1516,55 @@ done: static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_core_t *file = (H5FD_core_t*)_file; - size_t new_eof; /* New size of memory buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + size_t new_eof; /* New size of memory buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file); /* if we are closing and not using backing store, do nothing */ - if(!closing || file->backing_store) { - if(closing) /* set eof to eoa */ + if (!closing || file->backing_store) { + if (closing) /* set eof to eoa */ new_eof = file->eoa; else { /* set eof to smallest multiple of increment that exceeds eoa */ /* Determine new size of memory buffer */ H5_CHECKED_ASSIGN(new_eof, size_t, file->increment * (file->eoa / file->increment), hsize_t); - if(file->eoa % file->increment) + if (file->eoa % file->increment) new_eof += file->increment; } /* end else */ /* Extend the file to make sure it's large enough */ - if(!H5F_addr_eq(file->eof, (haddr_t)new_eof)) { - unsigned char *x; /* Pointer to new buffer for file data */ + if (!H5F_addr_eq(file->eof, (haddr_t)new_eof)) { + unsigned char *x; /* Pointer to new buffer for file data */ /* (Re)allocate memory for the file buffer, using callback if available */ - if(file->fi_callbacks.image_realloc) { - if(NULL == (x = (unsigned char *)file->fi_callbacks.image_realloc(file->mem, new_eof, H5FD_FILE_IMAGE_OP_FILE_RESIZE, file->fi_callbacks.udata))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate memory block with callback") + if (file->fi_callbacks.image_realloc) { + if (NULL == + (x = (unsigned char *)file->fi_callbacks.image_realloc( + file->mem, new_eof, H5FD_FILE_IMAGE_OP_FILE_RESIZE, file->fi_callbacks.udata))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to allocate memory block with callback") } /* end if */ else { - if(NULL == (x = (unsigned char *)H5MM_realloc(file->mem, new_eof))) + if (NULL == (x = (unsigned char *)H5MM_realloc(file->mem, new_eof))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate memory block") } /* end else */ - if(file->eof < new_eof) + if (file->eof < new_eof) HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof)); file->mem = x; /* Update backing store, if using it and if closing */ - if(closing && (file->fd >= 0) && file->backing_store) { + if (closing && (file->fd >= 0) && file->backing_store) { #ifdef H5_HAVE_WIN32_API - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() - * Only used as an error code here. - */ - DWORD dwError; /* DWORD error code from GetLastError() */ - BOOL bError; /* Boolean error flag */ + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + * Only used as an error code here. + */ + DWORD dwError; /* DWORD error code from GetLastError() */ + BOOL bError; /* Boolean error flag */ /* Windows uses this odd QuadPart union for 32/64-bit portability */ li.QuadPart = (__int64)file->eoa; @@ -1555,17 +1575,17 @@ H5FD__core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing * from SetFilePointer(), we also need to check GetLastError(). */ dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); - if(INVALID_SET_FILE_POINTER == dwPtrLow) { + if (INVALID_SET_FILE_POINTER == dwPtrLow) { dwError = GetLastError(); - if(dwError != NO_ERROR ) + if (dwError != NO_ERROR) HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") } bError = SetEndOfFile(file->hFile); - if(0 == bError) + if (0 == bError) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* H5_HAVE_WIN32_API */ - if(-1 == HDftruncate(file->fd, (HDoff_t)new_eof)) +#else /* H5_HAVE_WIN32_API */ + if (-1 == HDftruncate(file->fd, (HDoff_t)new_eof)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ @@ -1574,13 +1594,12 @@ H5FD__core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing /* Update the eof value */ file->eof = new_eof; } /* end if */ - } /* end if(file->eof < file->eoa) */ + } /* end if(file->eof < file->eoa) */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_core_lock * @@ -1598,9 +1617,9 @@ done: static herr_t H5FD_core_lock(H5FD_t *_file, hbool_t rw) { - H5FD_core_t *file = (H5FD_core_t*)_file; /* VFD file struct */ - int lock_flags; /* file locking flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1609,15 +1628,17 @@ H5FD_core_lock(H5FD_t *_file, hbool_t rw) /* Only set the lock if there is a file descriptor. If no file * descriptor, this is a no-op. */ - if(file->fd >= 0) { + if (file->fd >= 0) { /* Set exclusive or shared lock based on rw status */ lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { - if(ENOSYS == errno) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + if (HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if (ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, + "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING " + "environment variable to override)") else HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file") } /* end if */ @@ -1628,7 +1649,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_core_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD_core_unlock * @@ -1643,18 +1663,20 @@ done: static herr_t H5FD_core_unlock(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(file->fd >= 0) { + if (file->fd >= 0) { - if(HDflock(file->fd, LOCK_UN) < 0) { - if(ENOSYS == errno) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + if (HDflock(file->fd, LOCK_UN) < 0) { + if (ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, + "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING " + "environment variable to override)") else HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file") } /* end if */ @@ -1664,4 +1686,3 @@ H5FD_core_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_core_unlock() */ - diff --git a/src/H5FDcore.h b/src/H5FDcore.h index 5fe2912..d8fc366 100644 --- a/src/H5FDcore.h +++ b/src/H5FDcore.h @@ -20,19 +20,16 @@ #ifndef H5FDcore_H #define H5FDcore_H -#define H5FD_CORE (H5FD_core_init()) +#define H5FD_CORE (H5FD_core_init()) #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_core_init(void); -H5_DLL herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, - hbool_t backing_store); -H5_DLL herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/, - hbool_t *backing_store/*out*/); +H5_DLL hid_t H5FD_core_init(void); +H5_DLL herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store); +H5_DLL herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/); #ifdef __cplusplus } #endif #endif - diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 498d5f8..213a48b 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -22,16 +22,15 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDdirect.h" /* Direct file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDdirect.h" /* Direct file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_DIRECT @@ -39,16 +38,16 @@ static hid_t H5FD_DIRECT_g = 0; /* File operations */ -#define OP_UNKNOWN 0 +#define OP_UNKNOWN 0 #define OP_READ 1 -#define OP_WRITE 2 +#define OP_WRITE 2 /* Driver-specific file access properties */ typedef struct H5FD_direct_fapl_t { size_t mboundary; /* Memory boundary for alignment */ - size_t fbsize; /* File system block size */ - size_t cbsize; /* Maximal buffer size for copying user data */ - hbool_t must_align; /* Decides if data alignment is required */ + size_t fbsize; /* File system block size */ + size_t cbsize; /* Maximal buffer size for copying user data */ + hbool_t must_align; /* Decides if data alignment is required */ } H5FD_direct_fapl_t; /* @@ -64,20 +63,20 @@ typedef struct H5FD_direct_fapl_t { * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_direct_t { - H5FD_t pub; /*public stuff, must be first */ - int fd; /*the unix file */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*end of file; current file size*/ - haddr_t pos; /*current file I/O position */ - int op; /*last operation */ - H5FD_direct_fapl_t fa; /*file access properties */ + H5FD_t pub; /*public stuff, must be first */ + int fd; /*the unix file */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*end of file; current file size*/ + haddr_t pos; /*current file I/O position */ + int op; /*last operation */ + H5FD_direct_fapl_t fa; /*file access properties */ #ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ - ino_t inode; /*file i-node number */ + dev_t device; /*file device number */ + ino_t inode; /*file i-node number */ #else /* * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the @@ -109,76 +108,71 @@ typedef struct H5FD_direct_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* Prototypes */ -static herr_t H5FD_direct_term(void); -static void *H5FD_direct_fapl_get(H5FD_t *file); -static void *H5FD_direct_fapl_copy(const void *_old_fa); -static H5FD_t *H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); -static herr_t H5FD_direct_close(H5FD_t *_file); -static int H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_direct_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD_direct_term(void); +static void * H5FD_direct_fapl_get(H5FD_t *file); +static void * H5FD_direct_fapl_copy(const void *_old_fa); +static H5FD_t *H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_direct_close(H5FD_t *_file); +static int H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_direct_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_direct_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_direct_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_direct_unlock(H5FD_t *_file); - +static herr_t H5FD_direct_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_direct_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_direct_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_direct_g = { - "direct", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_direct_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_direct_fapl_t), /*fapl_size */ - H5FD_direct_fapl_get, /*fapl_get */ - H5FD_direct_fapl_copy, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_direct_open, /*open */ - H5FD_direct_close, /*close */ - H5FD_direct_cmp, /*cmp */ - H5FD_direct_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_direct_get_eoa, /*get_eoa */ - H5FD_direct_set_eoa, /*set_eoa */ - H5FD_direct_get_eof, /*get_eof */ - H5FD_direct_get_handle, /*get_handle */ - H5FD_direct_read, /*read */ - H5FD_direct_write, /*write */ - NULL, /*flush */ - H5FD_direct_truncate, /*truncate */ - H5FD_direct_lock, /*lock */ - H5FD_direct_unlock, /*unlock */ + "direct", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_direct_term, /*terminate */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + sizeof(H5FD_direct_fapl_t), /*fapl_size */ + H5FD_direct_fapl_get, /*fapl_get */ + H5FD_direct_fapl_copy, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_direct_open, /*open */ + H5FD_direct_close, /*close */ + H5FD_direct_cmp, /*cmp */ + H5FD_direct_query, /*query */ + NULL, /*get_type_map */ + NULL, /*alloc */ + NULL, /*free */ + H5FD_direct_get_eoa, /*get_eoa */ + H5FD_direct_set_eoa, /*set_eoa */ + H5FD_direct_get_eof, /*get_eof */ + H5FD_direct_get_handle, /*get_handle */ + H5FD_direct_read, /*read */ + H5FD_direct_write, /*write */ + NULL, /*flush */ + H5FD_direct_truncate, /*truncate */ + H5FD_direct_lock, /*lock */ + H5FD_direct_unlock, /*unlock */ NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + H5FD_FLMAP_DICHOTOMY /*fl_map */ }; /* Declare a free list to manage the H5FD_direct_t struct */ H5FL_DEFINE_STATIC(H5FD_direct_t); - /*-------------------------------------------------------------------------- NAME H5FD__init_package -- Initialize interface-specific information @@ -198,14 +192,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_direct_init() < 0) + if (H5FD_direct_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize direct VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_init * @@ -223,12 +216,12 @@ done: hid_t H5FD_direct_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g)) - H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g,sizeof(H5FD_class_t),FALSE); + H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ ret_value = H5FD_DIRECT_g; @@ -237,7 +230,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_direct_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_direct_term * @@ -256,12 +248,11 @@ H5FD_direct_term(void) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Reset VFL ID */ - H5FD_DIRECT_g=0; + H5FD_DIRECT_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_direct_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_direct * @@ -279,26 +270,26 @@ H5FD_direct_term(void) herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbuf_size) { - H5P_genplist_t *plist; /* Property list pointer */ - H5FD_direct_fapl_t fa; - herr_t ret_value; + H5P_genplist_t * plist; /* Property list pointer */ + H5FD_direct_fapl_t fa; + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE4("e", "izzz", fapl_id, boundary, block_size, cbuf_size); - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") HDmemset(&fa, 0, sizeof(H5FD_direct_fapl_t)); - if(boundary != 0) + if (boundary != 0) fa.mboundary = boundary; else fa.mboundary = MBOUNDARY_DEF; - if(block_size != 0) + if (block_size != 0) fa.fbsize = block_size; else fa.fbsize = FBSIZE_DEF; - if(cbuf_size != 0) + if (cbuf_size != 0) fa.cbsize = cbuf_size; else fa.cbsize = CBSIZE_DEF; @@ -307,7 +298,7 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu fa.must_align = TRUE; /* Copy buffer size must be a multiple of file block size */ - if(fa.cbsize % fa.fbsize != 0) + if (fa.cbsize % fa.fbsize != 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "copy buffer size must be a multiple of block size") ret_value = H5P_set_driver(plist, H5FD_DIRECT, &fa); @@ -316,7 +307,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_direct * @@ -333,25 +323,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*out*/, - size_t *cbuf_size/*out*/) +H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary /*out*/, size_t *block_size /*out*/, + size_t *cbuf_size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5FD_direct_fapl_t *fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + const H5FD_direct_fapl_t *fa; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ixxx", fapl_id, boundary, block_size, cbuf_size); - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_DIRECT != H5P_peek_driver(plist)) + if (H5FD_DIRECT != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = H5P_peek_driver_info(plist))) + if (NULL == (fa = H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - if(boundary) + if (boundary) *boundary = fa->mboundary; - if(block_size) + if (block_size) *block_size = fa->fbsize; if (cbuf_size) *cbuf_size = fa->cbsize; @@ -360,7 +350,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_direct() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_fapl_get * @@ -383,19 +372,18 @@ done: static void * H5FD_direct_fapl_get(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - void *ret_value; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + void * ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Set return value */ - ret_value= H5FD_direct_fapl_copy(&(file->fa)); + ret_value = H5FD_direct_fapl_copy(&(file->fa)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_direct_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_fapl_copy * @@ -415,8 +403,8 @@ done: static void * H5FD_direct_fapl_copy(const void *_old_fa) { - const H5FD_direct_fapl_t *old_fa = (const H5FD_direct_fapl_t*)_old_fa; - H5FD_direct_fapl_t *new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t)); + const H5FD_direct_fapl_t *old_fa = (const H5FD_direct_fapl_t *)_old_fa; + H5FD_direct_fapl_t * new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t)); FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -428,7 +416,6 @@ H5FD_direct_fapl_copy(const void *_old_fa) FUNC_LEAVE_NOAPI(new_fa) } /* end H5FD_direct_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_open * @@ -450,62 +437,65 @@ H5FD_direct_fapl_copy(const void *_old_fa) static H5FD_t * H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - int o_flags; - int fd=(-1); - H5FD_direct_t *file=NULL; - H5FD_direct_fapl_t *fa; + int o_flags; + int fd = (-1); + H5FD_direct_t * file = NULL; + H5FD_direct_fapl_t *fa; #ifdef H5_HAVE_WIN32_API - HFILE filehandle; + HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - h5_stat_t sb; - H5P_genplist_t *plist; /* Property list */ - void *buf1, *buf2; - H5FD_t *ret_value = NULL; + h5_stat_t sb; + H5P_genplist_t *plist; /* Property list */ + void * buf1, *buf2; + H5FD_t * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT /* Sanity check on file offsets */ - HDassert(sizeof(HDoff_t)>=sizeof(size_t)); + HDassert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if (0==maxaddr || HADDR_UNDEF==maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; + if (H5F_ACC_TRUNC & flags) + o_flags |= O_TRUNC; + if (H5F_ACC_CREAT & flags) + o_flags |= O_CREAT; + if (H5F_ACC_EXCL & flags) + o_flags |= O_EXCL; /* Flag for Direct I/O */ o_flags |= O_DIRECT; /* Open the file */ - if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW))<0) + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - if (HDfstat(fd, &sb)<0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Create the new file struct */ - if (NULL==(file=H5FL_CALLOC(H5FD_direct_t))) + if (NULL == (file = H5FL_CALLOC(H5FD_direct_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") /* Get the driver specific information */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (H5FD_direct_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (H5FD_direct_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; #ifdef H5_HAVE_WIN32_API filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); @@ -513,11 +503,11 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd file->fileindexlo = fileinfo.nFileIndexLow; #else file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /*H5_HAVE_WIN32_API*/ file->fa.mboundary = fa->mboundary; - file->fa.fbsize = fa->fbsize; - file->fa.cbsize = fa->cbsize; + file->fa.fbsize = fa->fbsize; + file->fa.cbsize = fa->cbsize; /* Try to decide if data alignment is required. The reason to check it here * is to handle correctly the case that the file is in a different file system @@ -527,56 +517,59 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd * HDposix_memalign. */ buf1 = HDmalloc(sizeof(int)); - if(HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0) + if (HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed") - if(o_flags & O_CREAT) { - if(HDwrite(file->fd, buf1, sizeof(int))<0) { - if(HDwrite(file->fd, buf2, file->fa.fbsize)<0) + if (o_flags & O_CREAT) { + if (HDwrite(file->fd, buf1, sizeof(int)) < 0) { + if (HDwrite(file->fd, buf2, file->fa.fbsize) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, NULL, "file system may not support Direct I/O") else file->fa.must_align = TRUE; - } else { + } + else { file->fa.must_align = FALSE; HDftruncate(file->fd, (HDoff_t)0); } - } else { - if(HDread(file->fd, buf1, sizeof(int))<0) { - if(HDread(file->fd, buf2, file->fa.fbsize)<0) + } + else { + if (HDread(file->fd, buf1, sizeof(int)) < 0) { + if (HDread(file->fd, buf2, file->fa.fbsize) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "file system may not support Direct I/O") else file->fa.must_align = TRUE; - } else { - if(o_flags & O_RDWR) { - if(HDlseek(file->fd, (HDoff_t)0, SEEK_SET) < 0) + } + else { + if (o_flags & O_RDWR) { + if (HDlseek(file->fd, (HDoff_t)0, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, NULL, "unable to seek to proper position") - if(HDwrite(file->fd, buf1, sizeof(int))<0) + if (HDwrite(file->fd, buf1, sizeof(int)) < 0) file->fa.must_align = TRUE; else file->fa.must_align = FALSE; - } else + } + else file->fa.must_align = FALSE; } } - if(buf1) + if (buf1) HDfree(buf1); - if(buf2) + if (buf2) HDfree(buf2); /* Set return value */ - ret_value=(H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(ret_value==NULL) { - if(fd>=0) + if (ret_value == NULL) { + if (fd >= 0) HDclose(fd); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_close * @@ -596,21 +589,20 @@ done: static herr_t H5FD_direct_close(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if (HDclose(file->fd)<0) + if (HDclose(file->fd) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") - H5FL_FREE(H5FD_direct_t,file); + H5FL_FREE(H5FD_direct_t, file); done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_cmp * @@ -632,34 +624,44 @@ done: static int H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_direct_t *f1 = (const H5FD_direct_t*)_f1; - const H5FD_direct_t *f2 = (const H5FD_direct_t*)_f2; - int ret_value=0; + const H5FD_direct_t *f1 = (const H5FD_direct_t *)_f1; + const H5FD_direct_t *f2 = (const H5FD_direct_t *)_f2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR #ifdef H5_HAVE_WIN32_API - if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) - if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) + if (f1->fileindexhi < f2->fileindexhi) + HGOTO_DONE(-1) + if (f1->fileindexhi > f2->fileindexhi) + HGOTO_DONE(1) - if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) - if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) + if (f1->fileindexlo < f2->fileindexlo) + HGOTO_DONE(-1) + if (f1->fileindexlo > f2->fileindexlo) + HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if (f1->device < f2->device) HGOTO_DONE(-1) - if (f1->device > f2->device) HGOTO_DONE(1) -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + HGOTO_DONE(-1) + if (f1->device > f2->device) + HGOTO_DONE(1) +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + HGOTO_DONE(-1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if (f1->inode < f2->inode) HGOTO_DONE(-1) - if (f1->inode > f2->inode) HGOTO_DONE(1) + if (f1->inode < f2->inode) + HGOTO_DONE(-1) + if (f1->inode > f2->inode) + HGOTO_DONE(1) #endif @@ -667,7 +669,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_query * @@ -686,24 +687,24 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED * _f, unsigned long *flags /* out */) +H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED *_f, unsigned long *flags /* out */) { FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ } FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_get_eoa * @@ -728,14 +729,13 @@ H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED * _f, unsigned long *flags /* out static haddr_t H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_direct_t *file = (const H5FD_direct_t*)_file; + const H5FD_direct_t *file = (const H5FD_direct_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(file->eoa) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_set_eoa * @@ -760,7 +760,7 @@ H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; + H5FD_direct_t *file = (H5FD_direct_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -769,7 +769,6 @@ H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_get_eof * @@ -793,14 +792,13 @@ H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) static haddr_t H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_direct_t *file = (const H5FD_direct_t*)_file; + const H5FD_direct_t *file = (const H5FD_direct_t *)_file; FUNC_ENTER_NOAPI_NOINIT FUNC_LEAVE_NOAPI(file->eof) } - /*------------------------------------------------------------------------- * Function: H5FD_diect_get_handle * @@ -816,14 +814,14 @@ H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle) +H5FD_direct_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_direct_t *file = (H5FD_direct_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_direct_t *file = (H5FD_direct_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); @@ -831,7 +829,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_read * @@ -853,20 +850,20 @@ done: */ static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf /*out*/) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - ssize_t nbytes; - hbool_t _must_align = TRUE; - herr_t ret_value=SUCCEED; /* Return value */ - size_t alloc_size; - void *copy_buf = NULL, *p2; - size_t _boundary; - size_t _fbsize; - size_t _cbsize; - haddr_t read_size; /* Size to read into copy buffer */ - size_t copy_size = size; /* Size remaining to read when using copy buffer */ - size_t copy_offset; /* Offset into copy buffer of the requested data */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + ssize_t nbytes; + hbool_t _must_align = TRUE; + herr_t ret_value = SUCCEED; /* Return value */ + size_t alloc_size; + void * copy_buf = NULL, *p2; + size_t _boundary; + size_t _fbsize; + size_t _cbsize; + haddr_t read_size; /* Size to read into copy buffer */ + size_t copy_size = size; /* Size remaining to read when using copy buffer */ + size_t copy_offset; /* Offset into copy buffer of the requested data */ FUNC_ENTER_NOAPI_NOINIT @@ -874,7 +871,7 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN HDassert(buf); /* Check for overflow conditions */ - if (HADDR_UNDEF==addr) + if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") @@ -888,136 +885,133 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN * copy buffer size. */ _boundary = file->fa.mboundary; - _fbsize = file->fa.fbsize; - _cbsize = file->fa.cbsize; + _fbsize = file->fa.fbsize; + _cbsize = file->fa.cbsize; /* if the data is aligned or the system doesn't require data to be aligned, * read it directly from the file. If not, read a bigger * and aligned data first, then copy the data into memory buffer. */ - if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) { - /* Seek to the correct location */ - if ((addr!=file->pos || OP_READ!=file->op) && - HDlseek(file->fd, (HDoff_t)addr, SEEK_SET)<0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - /* Read the aligned data in file first, being careful of interrupted - * system calls and partial results. */ - while (size>0) { - do { - nbytes = HDread(file->fd, buf, size); - } while (-1==nbytes && EINTR==errno); - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - if (0==nbytes) { - /* end of file but not end of format address space */ - HDmemset(buf, 0, size); - break; + if (!_must_align || ((addr % _fbsize == 0) && (size % _fbsize == 0) && ((size_t)buf % _boundary == 0))) { + /* Seek to the correct location */ + if ((addr != file->pos || OP_READ != file->op) && HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + /* Read the aligned data in file first, being careful of interrupted + * system calls and partial results. */ + while (size > 0) { + do { + nbytes = HDread(file->fd, buf, size); + } while (-1 == nbytes && EINTR == errno); + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + if (0 == nbytes) { + /* end of file but not end of format address space */ + HDmemset(buf, 0, size); + break; + } + HDassert(nbytes >= 0); + HDassert((size_t)nbytes <= size); + H5_CHECK_OVERFLOW(nbytes, ssize_t, size_t); + size -= (size_t)nbytes; + H5_CHECK_OVERFLOW(nbytes, ssize_t, haddr_t); + addr += (haddr_t)nbytes; + buf = (char *)buf + nbytes; + } } - HDassert(nbytes>=0); - HDassert((size_t)nbytes<=size); - H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); - size -= (size_t)nbytes; - H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); - addr += (haddr_t)nbytes; - buf = (char*)buf + nbytes; - } - } else { - /* Calculate where we will begin copying from the copy buffer */ - copy_offset = (size_t)(addr % _fbsize); - - /* allocate memory needed for the Direct IO option up to the maximal - * copy buffer size. Make a bigger buffer for aligned I/O if size is - * smaller than maximal copy buffer. */ - alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; - if(alloc_size > _cbsize) - alloc_size = _cbsize; - HDassert(!(alloc_size % _fbsize)); - if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") - - /* look for the aligned position for reading the data */ - HDassert(!(((addr / _fbsize) * _fbsize) % _fbsize)); - if(HDlseek(file->fd, (HDoff_t)((addr / _fbsize) * _fbsize), - SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - - /* - * Read the aligned data in file into aligned buffer first, then copy the data - * into the final buffer. If the data size is bigger than maximal copy buffer - * size, do the reading by segment (the outer while loop). If not, do one step - * reading. - */ - do { - /* Read the aligned data in file first. Not able to handle interrupted - * system calls and partial results like sec2 driver does because the - * data may no longer be aligned. It's especially true when the data in - * file is smaller than ALLOC_SIZE. */ - HDmemset(copy_buf, 0, alloc_size); - - /* Calculate how much data we have to read in this iteration - * (including unused parts of blocks) */ - if((copy_size + copy_offset) < alloc_size) - read_size = ((copy_size + copy_offset - 1) / _fbsize + 1) - * _fbsize; - else - read_size = alloc_size; + else { + /* Calculate where we will begin copying from the copy buffer */ + copy_offset = (size_t)(addr % _fbsize); + + /* allocate memory needed for the Direct IO option up to the maximal + * copy buffer size. Make a bigger buffer for aligned I/O if size is + * smaller than maximal copy buffer. */ + alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; + if (alloc_size > _cbsize) + alloc_size = _cbsize; + HDassert(!(alloc_size % _fbsize)); + if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") + + /* look for the aligned position for reading the data */ + HDassert(!(((addr / _fbsize) * _fbsize) % _fbsize)); + if (HDlseek(file->fd, (HDoff_t)((addr / _fbsize) * _fbsize), SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - HDassert(!(read_size % _fbsize)); + /* + * Read the aligned data in file into aligned buffer first, then copy the data + * into the final buffer. If the data size is bigger than maximal copy buffer + * size, do the reading by segment (the outer while loop). If not, do one step + * reading. + */ do { - nbytes = HDread(file->fd, copy_buf, read_size); - } while(-1==nbytes && EINTR==errno); - - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - - /* Copy the needed data from the copy buffer to the output - * buffer, and update copy_size. If the copy buffer does not - * contain the rest of the data, just copy what's in the copy - * buffer and also update read_addr and copy_offset to read the - * next section of data. */ - p2 = (unsigned char*)copy_buf + copy_offset; - if((copy_size + copy_offset) <= alloc_size) { - H5MM_memcpy(buf, p2, copy_size); - buf = (unsigned char *)buf + copy_size; - copy_size = 0; - } /* end if */ - else { - H5MM_memcpy(buf, p2, alloc_size - copy_offset); - buf = (unsigned char*)buf + alloc_size - copy_offset; - copy_size -= alloc_size - copy_offset; - copy_offset = 0; - } /* end else */ - } while (copy_size > 0); - - /*Final step: update address*/ - addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize); - - if(copy_buf) { - /* Free with HDfree since it came from posix_memalign */ - HDfree(copy_buf); - copy_buf = NULL; + /* Read the aligned data in file first. Not able to handle interrupted + * system calls and partial results like sec2 driver does because the + * data may no longer be aligned. It's especially true when the data in + * file is smaller than ALLOC_SIZE. */ + HDmemset(copy_buf, 0, alloc_size); + + /* Calculate how much data we have to read in this iteration + * (including unused parts of blocks) */ + if ((copy_size + copy_offset) < alloc_size) + read_size = ((copy_size + copy_offset - 1) / _fbsize + 1) * _fbsize; + else + read_size = alloc_size; + + HDassert(!(read_size % _fbsize)); + do { + nbytes = HDread(file->fd, copy_buf, read_size); + } while (-1 == nbytes && EINTR == errno); + + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + + /* Copy the needed data from the copy buffer to the output + * buffer, and update copy_size. If the copy buffer does not + * contain the rest of the data, just copy what's in the copy + * buffer and also update read_addr and copy_offset to read the + * next section of data. */ + p2 = (unsigned char *)copy_buf + copy_offset; + if ((copy_size + copy_offset) <= alloc_size) { + H5MM_memcpy(buf, p2, copy_size); + buf = (unsigned char *)buf + copy_size; + copy_size = 0; } /* end if */ + else { + H5MM_memcpy(buf, p2, alloc_size - copy_offset); + buf = (unsigned char *)buf + alloc_size - copy_offset; + copy_size -= alloc_size - copy_offset; + copy_offset = 0; + } /* end else */ + } while (copy_size > 0); + + /*Final step: update address*/ + addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize); + + if (copy_buf) { + /* Free with HDfree since it came from posix_memalign */ + HDfree(copy_buf); + copy_buf = NULL; + } /* end if */ } /* Update current position */ file->pos = addr; - file->op = OP_READ; + file->op = OP_READ; done: - if(ret_value<0) { + if (ret_value < 0) { /* Free with HDfree since it came from posix_memalign */ - if(copy_buf) + if (copy_buf) HDfree(copy_buf); /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_write * @@ -1038,23 +1032,23 @@ done: */ static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - ssize_t nbytes; - hbool_t _must_align = TRUE; - herr_t ret_value=SUCCEED; /* Return value */ - size_t alloc_size; - void *copy_buf = NULL, *p1; - const void *p3; - size_t _boundary; - size_t _fbsize; - size_t _cbsize; - haddr_t write_addr; /* Address to write copy buffer */ - haddr_t write_size; /* Size to write from copy buffer */ - haddr_t read_size; /* Size to read into copy buffer */ - size_t copy_size = size; /* Size remaining to write when using copy buffer */ - size_t copy_offset; /* Offset into copy buffer of the data to write */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + ssize_t nbytes; + hbool_t _must_align = TRUE; + herr_t ret_value = SUCCEED; /* Return value */ + size_t alloc_size; + void * copy_buf = NULL, *p1; + const void * p3; + size_t _boundary; + size_t _fbsize; + size_t _cbsize; + haddr_t write_addr; /* Address to write copy buffer */ + haddr_t write_size; /* Size to write from copy buffer */ + haddr_t read_size; /* Size to read into copy buffer */ + size_t copy_size = size; /* Size remaining to write when using copy buffer */ + size_t copy_offset; /* Offset into copy buffer of the data to write */ FUNC_ENTER_NOAPI_NOINIT @@ -1062,7 +1056,7 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U HDassert(buf); /* Check for overflow conditions */ - if (HADDR_UNDEF==addr) + if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") @@ -1076,183 +1070,179 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U * copy buffer size. */ _boundary = file->fa.mboundary; - _fbsize = file->fa.fbsize; - _cbsize = file->fa.cbsize; + _fbsize = file->fa.fbsize; + _cbsize = file->fa.cbsize; /* if the data is aligned or the system doesn't require data to be aligned, * write it directly to the file. If not, read a bigger and aligned data * first, update buffer with user data, then write the data out. */ - if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) { - /* Seek to the correct location */ - if ((addr!=file->pos || OP_WRITE!=file->op) && - HDlseek(file->fd, (HDoff_t)addr, SEEK_SET)<0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - - while (size>0) { - do { - nbytes = HDwrite(file->fd, buf, size); - } while (-1==nbytes && EINTR==errno); - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") - HDassert(nbytes>0); - HDassert((size_t)nbytes<=size); - H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); - size -= (size_t)nbytes; - H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); - addr += (haddr_t)nbytes; - buf = (const char*)buf + nbytes; - } - } else { - /* Calculate where we will begin reading from (on disk) and where we - * will begin copying from the copy buffer */ - write_addr = (addr / _fbsize) * _fbsize; - copy_offset = (size_t)(addr % _fbsize); - - /* allocate memory needed for the Direct IO option up to the maximal - * copy buffer size. Make a bigger buffer for aligned I/O if size is - * smaller than maximal copy buffer. - */ - alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; - if(alloc_size > _cbsize) - alloc_size = _cbsize; - HDassert(!(alloc_size % _fbsize)); - - if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") - - /* look for the right position for reading or writing the data */ - if(HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - - p3 = buf; - do { - /* Calculate how much data we have to write in this iteration - * (including unused parts of blocks) */ - if((copy_size + copy_offset) < alloc_size) - write_size = ((copy_size + copy_offset - 1) / _fbsize + 1) - * _fbsize; - else - write_size = alloc_size; - - /* - * Read the aligned data first if the aligned region doesn't fall - * entirely in the range to be written. Not able to handle interrupted - * system calls and partial results like sec2 driver does because the - * data may no longer be aligned. It's especially true when the data in - * file is smaller than ALLOC_SIZE. Only read the entire section if - * both ends are misaligned, otherwise only read the block on the - * misaligned end. + if (!_must_align || ((addr % _fbsize == 0) && (size % _fbsize == 0) && ((size_t)buf % _boundary == 0))) { + /* Seek to the correct location */ + if ((addr != file->pos || OP_WRITE != file->op) && HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + + while (size > 0) { + do { + nbytes = HDwrite(file->fd, buf, size); + } while (-1 == nbytes && EINTR == errno); + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + HDassert(nbytes > 0); + HDassert((size_t)nbytes <= size); + H5_CHECK_OVERFLOW(nbytes, ssize_t, size_t); + size -= (size_t)nbytes; + H5_CHECK_OVERFLOW(nbytes, ssize_t, haddr_t); + addr += (haddr_t)nbytes; + buf = (const char *)buf + nbytes; + } + } + else { + /* Calculate where we will begin reading from (on disk) and where we + * will begin copying from the copy buffer */ + write_addr = (addr / _fbsize) * _fbsize; + copy_offset = (size_t)(addr % _fbsize); + + /* allocate memory needed for the Direct IO option up to the maximal + * copy buffer size. Make a bigger buffer for aligned I/O if size is + * smaller than maximal copy buffer. */ - HDmemset(copy_buf, 0, _fbsize); - - if(copy_offset > 0) { - if((write_addr + write_size) > (addr + size)) { - HDassert((write_addr + write_size) - (addr + size) < _fbsize); - read_size = write_size; - p1 = copy_buf; - } /* end if */ - else { - read_size = _fbsize; - p1 = copy_buf; - } /* end else */ - } /* end if */ - else if((write_addr + write_size) > (addr + size)) { - HDassert((write_addr + write_size) - (addr + size) < _fbsize); - read_size = _fbsize; - p1 = (unsigned char *)copy_buf + write_size - _fbsize; - - /* Seek to the last block, for reading */ - HDassert(!((write_addr + write_size - _fbsize) % _fbsize)); - if(HDlseek(file->fd, - (HDoff_t)(write_addr + write_size - _fbsize), - SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } /* end if */ - else - p1 = NULL; + alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; + if (alloc_size > _cbsize) + alloc_size = _cbsize; + HDassert(!(alloc_size % _fbsize)); - if(p1) { - HDassert(!(read_size % _fbsize)); - do { - nbytes = HDread(file->fd, p1, read_size); - } while (-1==nbytes && EINTR==errno); + if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - } /* end if */ + /* look for the right position for reading or writing the data */ + if (HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - /* look for the right position and append or copy the data to be written to - * the aligned buffer. - * Consider all possible situations here: file address is not aligned on - * file block size; the end of data address is not aligned; the end of data - * address is aligned; data size is smaller or bigger than maximal copy size. - */ - p1 = (unsigned char *)copy_buf + copy_offset; - if((copy_size + copy_offset) <= alloc_size) { - H5MM_memcpy(p1, p3, copy_size); - copy_size = 0; + p3 = buf; + do { + /* Calculate how much data we have to write in this iteration + * (including unused parts of blocks) */ + if ((copy_size + copy_offset) < alloc_size) + write_size = ((copy_size + copy_offset - 1) / _fbsize + 1) * _fbsize; + else + write_size = alloc_size; + + /* + * Read the aligned data first if the aligned region doesn't fall + * entirely in the range to be written. Not able to handle interrupted + * system calls and partial results like sec2 driver does because the + * data may no longer be aligned. It's especially true when the data in + * file is smaller than ALLOC_SIZE. Only read the entire section if + * both ends are misaligned, otherwise only read the block on the + * misaligned end. + */ + HDmemset(copy_buf, 0, _fbsize); + + if (copy_offset > 0) { + if ((write_addr + write_size) > (addr + size)) { + HDassert((write_addr + write_size) - (addr + size) < _fbsize); + read_size = write_size; + p1 = copy_buf; } /* end if */ else { - H5MM_memcpy(p1, p3, alloc_size - copy_offset); - p3 = (const unsigned char *)p3 + (alloc_size - copy_offset); - copy_size -= alloc_size - copy_offset; - copy_offset = 0; + read_size = _fbsize; + p1 = copy_buf; } /* end else */ + } /* end if */ + else if ((write_addr + write_size) > (addr + size)) { + HDassert((write_addr + write_size) - (addr + size) < _fbsize); + read_size = _fbsize; + p1 = (unsigned char *)copy_buf + write_size - _fbsize; + + /* Seek to the last block, for reading */ + HDassert(!((write_addr + write_size - _fbsize) % _fbsize)); + if (HDlseek(file->fd, (HDoff_t)(write_addr + write_size - _fbsize), SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + } /* end if */ + else + p1 = NULL; + + if (p1) { + HDassert(!(read_size % _fbsize)); + do { + nbytes = HDread(file->fd, p1, read_size); + } while (-1 == nbytes && EINTR == errno); - /*look for the aligned position for writing the data*/ - HDassert(!(write_addr % _fbsize)); - if(HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + } /* end if */ - /* - * Write the data. It doesn't truncate the extra data introduced by - * alignment because that step is done in H5FD_direct_flush. - */ - HDassert(!(write_size % _fbsize)); - do { - nbytes = HDwrite(file->fd, copy_buf, write_size); - } while (-1==nbytes && EINTR==errno); - - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") - - /* update the write address */ - write_addr += write_size; - } while (copy_size > 0); - - /*Update the address and size*/ - addr = write_addr; - buf = (const char*)buf + size; - - if(copy_buf) { - /* Free with HDfree since it came from posix_memalign */ - HDfree(copy_buf); - copy_buf = NULL; + /* look for the right position and append or copy the data to be written to + * the aligned buffer. + * Consider all possible situations here: file address is not aligned on + * file block size; the end of data address is not aligned; the end of data + * address is aligned; data size is smaller or bigger than maximal copy size. + */ + p1 = (unsigned char *)copy_buf + copy_offset; + if ((copy_size + copy_offset) <= alloc_size) { + H5MM_memcpy(p1, p3, copy_size); + copy_size = 0; + } /* end if */ + else { + H5MM_memcpy(p1, p3, alloc_size - copy_offset); + p3 = (const unsigned char *)p3 + (alloc_size - copy_offset); + copy_size -= alloc_size - copy_offset; + copy_offset = 0; + } /* end else */ + + /*look for the aligned position for writing the data*/ + HDassert(!(write_addr % _fbsize)); + if (HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + + /* + * Write the data. It doesn't truncate the extra data introduced by + * alignment because that step is done in H5FD_direct_flush. + */ + HDassert(!(write_size % _fbsize)); + do { + nbytes = HDwrite(file->fd, copy_buf, write_size); + } while (-1 == nbytes && EINTR == errno); + + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + + /* update the write address */ + write_addr += write_size; + } while (copy_size > 0); + + /*Update the address and size*/ + addr = write_addr; + buf = (const char *)buf + size; + + if (copy_buf) { + /* Free with HDfree since it came from posix_memalign */ + HDfree(copy_buf); + copy_buf = NULL; } /* end if */ } /* Update current position and eof */ file->pos = addr; - file->op = OP_WRITE; - if (file->pos>file->eof) + file->op = OP_WRITE; + if (file->pos > file->eof) file->eof = file->pos; done: - if(ret_value<0) { + if (ret_value < 0) { /* Free with HDfree since it came from posix_memalign */ - if(copy_buf) + if (copy_buf) HDfree(copy_buf); /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_direct_truncate * @@ -1271,18 +1261,18 @@ done: static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); /* Extend the file to make sure it's large enough */ - if (file->eoa!=file->eof) { + if (file->eoa != file->eof) { #ifdef H5_HAVE_WIN32_API - HFILE filehandle; /* Windows file handle */ - LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ + HFILE filehandle; /* Windows file handle */ + LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ /* Map the posix file handle to a Windows file handle */ filehandle = _get_osfhandle(file->fd); @@ -1290,11 +1280,11 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATT /* Translate 64-bit integers into form Windows wants */ /* [This algorithm is from the Windows documentation for SetFilePointer()] */ li.QuadPart = (LONGLONG)file->eoa; - (void)SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN); - if(SetEndOfFile((HANDLE)filehandle)==0) + (void)SetFilePointer((HANDLE)filehandle, li.LowPart, &li.HighPart, FILE_BEGIN); + if (SetEndOfFile((HANDLE)filehandle) == 0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* H5_HAVE_WIN32_API */ - if (-1==HDftruncate(file->fd, (HDoff_t)file->eoa)) +#else /* H5_HAVE_WIN32_API */ + if (-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ @@ -1303,13 +1293,13 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATT /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } - else if (file->fa.must_align){ - /*Even though eof is equal to eoa, file is still truncated because Direct I/O - *write introduces some extra data for alignment. - */ - if (-1==HDftruncate(file->fd, (HDoff_t)file->eof)) + else if (file->fa.must_align) { + /*Even though eof is equal to eoa, file is still truncated because Direct I/O + *write introduces some extra data for alignment. + */ + if (-1 == HDftruncate(file->fd, (HDoff_t)file->eof)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") } @@ -1317,7 +1307,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_direct_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_lock * @@ -1335,23 +1324,22 @@ done: static herr_t H5FD_direct_lock(H5FD_t *_file, hbool_t rw) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */ - const int lock = rw ? LOCK_EX : LOCK_SH; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; /* VFD file struct */ + const int lock = rw ? LOCK_EX : LOCK_SH; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); /* Place the lock with non-blocking */ - if(HDflock(file->fd, lock | LOCK_NB) < 0) + if (HDflock(file->fd, lock | LOCK_NB) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_direct_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_unlock * @@ -1366,14 +1354,14 @@ done: static herr_t H5FD_direct_unlock(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) + if (HDflock(file->fd, LOCK_UN) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file") done: @@ -1381,4 +1369,3 @@ done: } /* end H5FD_direct_unlock() */ #endif /* H5_HAVE_DIRECT */ - diff --git a/src/H5FDdirect.h b/src/H5FDdirect.h index 805f3be..0b51a1b 100644 --- a/src/H5FDdirect.h +++ b/src/H5FDdirect.h @@ -21,9 +21,9 @@ #define H5FDdirect_H #ifdef H5_HAVE_DIRECT -# define H5FD_DIRECT (H5FD_direct_init()) +#define H5FD_DIRECT (H5FD_direct_init()) #else -# define H5FD_DIRECT (-1) +#define H5FD_DIRECT (-1) #endif /* H5_HAVE_DIRECT */ #ifdef H5_HAVE_DIRECT @@ -33,15 +33,14 @@ extern "C" { /* Default values for memory boundary, file block size, and maximal copy buffer size. * Application can set these values through the function H5Pset_fapl_direct. */ -#define MBOUNDARY_DEF 4096 -#define FBSIZE_DEF 4096 -#define CBSIZE_DEF 16*1024*1024 +#define MBOUNDARY_DEF 4096 +#define FBSIZE_DEF 4096 +#define CBSIZE_DEF 16 * 1024 * 1024 -H5_DLL hid_t H5FD_direct_init(void); -H5_DLL herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t alignment, size_t block_size, - size_t cbuf_size); -H5_DLL herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, - size_t *block_size/*out*/, size_t *cbuf_size/*out*/); +H5_DLL hid_t H5FD_direct_init(void); +H5_DLL herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t alignment, size_t block_size, size_t cbuf_size); +H5_DLL herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary /*out*/, size_t *block_size /*out*/, + size_t *cbuf_size /*out*/); #ifdef __cplusplus } @@ -50,4 +49,3 @@ H5_DLL herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, #endif /* H5_HAVE_DIRECT */ #endif - diff --git a/src/H5FDdrvr_module.h b/src/H5FDdrvr_module.h index 59a419e..e3df47f 100644 --- a/src/H5FDdrvr_module.h +++ b/src/H5FDdrvr_module.h @@ -24,10 +24,9 @@ /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ -#define H5_MY_PKG H5FD -#define H5_MY_PKG_ERR H5E_FILE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5FD +#define H5_MY_PKG_ERR H5E_FILE +#define H5_MY_PKG_INIT YES #define H5_PKG_SINGLE_SOURCE #endif /* _H5FDdrvr_module_H */ - diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index cc97a0f..19f7ad4 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -34,16 +34,15 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDfamily.h" /* Family file driver */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDfamily.h" /* Family file driver */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The size of the member name buffers */ #define H5FD_FAM_MEMB_NAME_BUF_SIZE 4096 @@ -53,97 +52,93 @@ static hid_t H5FD_FAMILY_g = 0; /* The description of a file belonging to this driver. */ typedef struct H5FD_family_t { - H5FD_t pub; /*public stuff, must be first */ - hid_t memb_fapl_id; /*file access property list for members */ - hsize_t memb_size; /*actual size of each member file */ - hsize_t pmem_size; /*member size passed in from property */ - unsigned nmembs; /*number of family members */ - unsigned amembs; /*number of member slots allocated */ - H5FD_t **memb; /*dynamic array of member pointers */ - haddr_t eoa; /*end of allocated addresses */ - char *name; /*name generator printf format */ - unsigned flags; /*flags for opening additional members */ + H5FD_t pub; /*public stuff, must be first */ + hid_t memb_fapl_id; /*file access property list for members */ + hsize_t memb_size; /*actual size of each member file */ + hsize_t pmem_size; /*member size passed in from property */ + unsigned nmembs; /*number of family members */ + unsigned amembs; /*number of member slots allocated */ + H5FD_t **memb; /*dynamic array of member pointers */ + haddr_t eoa; /*end of allocated addresses */ + char * name; /*name generator printf format */ + unsigned flags; /*flags for opening additional members */ /* Information from properties set by 'h5repart' tool */ - hsize_t mem_newsize; /*new member size passed in as private - * property. It's used only by h5repart */ - hbool_t repart_members; /* Whether to mark the superblock dirty - * when it is loaded, so that the family - * member sizes can be re-encoded */ + hsize_t mem_newsize; /*new member size passed in as private + * property. It's used only by h5repart */ + hbool_t repart_members; /* Whether to mark the superblock dirty + * when it is loaded, so that the family + * member sizes can be re-encoded */ } H5FD_family_t; /* Driver-specific file access properties */ typedef struct H5FD_family_fapl_t { - hsize_t memb_size; /*size of each member */ - hid_t memb_fapl_id; /*file access property list of each memb*/ + hsize_t memb_size; /*size of each member */ + hid_t memb_fapl_id; /*file access property list of each memb*/ } H5FD_family_fapl_t; /* Callback prototypes */ -static herr_t H5FD_family_term(void); -static void *H5FD_family_fapl_get(H5FD_t *_file); -static void *H5FD_family_fapl_copy(const void *_old_fa); -static herr_t H5FD_family_fapl_free(void *_fa); +static herr_t H5FD_family_term(void); +static void * H5FD_family_fapl_get(H5FD_t *_file); +static void * H5FD_family_fapl_copy(const void *_old_fa); +static herr_t H5FD_family_fapl_free(void *_fa); static hsize_t H5FD_family_sb_size(H5FD_t *_file); -static herr_t H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, - unsigned char *buf/*out*/); -static herr_t H5FD_family_sb_decode(H5FD_t *_file, const char *name, - const unsigned char *buf); -static H5FD_t *H5FD_family_open(const char *name, unsigned flags, - hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_family_close(H5FD_t *_file); -static int H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_family_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD_family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); +static herr_t H5FD_family_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); +static H5FD_t *H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_family_close(H5FD_t *_file); +static int H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_family_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa); +static herr_t H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa); static haddr_t H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, void *_buf/*out*/); -static herr_t H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *_buf); -static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_family_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_family_unlock(H5FD_t *_file); +static herr_t H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *_buf /*out*/); +static herr_t H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *_buf); +static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_family_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_family_unlock(H5FD_t *_file); /* The class struct */ static const H5FD_class_t H5FD_family_g = { - "family", /*name */ - HADDR_MAX, /*maxaddr */ - H5F_CLOSE_WEAK, /*fc_degree */ - H5FD_family_term, /*terminate */ - H5FD_family_sb_size, /*sb_size */ - H5FD_family_sb_encode, /*sb_encode */ - H5FD_family_sb_decode, /*sb_decode */ - sizeof(H5FD_family_fapl_t), /*fapl_size */ - H5FD_family_fapl_get, /*fapl_get */ - H5FD_family_fapl_copy, /*fapl_copy */ - H5FD_family_fapl_free, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_family_open, /*open */ - H5FD_family_close, /*close */ - H5FD_family_cmp, /*cmp */ - H5FD_family_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_family_get_eoa, /*get_eoa */ - H5FD_family_set_eoa, /*set_eoa */ - H5FD_family_get_eof, /*get_eof */ - H5FD_family_get_handle, /*get_handle */ - H5FD_family_read, /*read */ - H5FD_family_write, /*write */ - H5FD_family_flush, /*flush */ - H5FD_family_truncate, /*truncate */ - H5FD_family_lock, /*lock */ - H5FD_family_unlock, /*unlock */ - NULL, /*dedup */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + "family", /*name */ + HADDR_MAX, /*maxaddr */ + H5F_CLOSE_WEAK, /*fc_degree */ + H5FD_family_term, /*terminate */ + H5FD_family_sb_size, /*sb_size */ + H5FD_family_sb_encode, /*sb_encode */ + H5FD_family_sb_decode, /*sb_decode */ + sizeof(H5FD_family_fapl_t), /*fapl_size */ + H5FD_family_fapl_get, /*fapl_get */ + H5FD_family_fapl_copy, /*fapl_copy */ + H5FD_family_fapl_free, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_family_open, /*open */ + H5FD_family_close, /*close */ + H5FD_family_cmp, /*cmp */ + H5FD_family_query, /*query */ + NULL, /*get_type_map */ + NULL, /*alloc */ + NULL, /*free */ + H5FD_family_get_eoa, /*get_eoa */ + H5FD_family_set_eoa, /*set_eoa */ + H5FD_family_get_eof, /*get_eof */ + H5FD_family_get_handle, /*get_handle */ + H5FD_family_read, /*read */ + H5FD_family_write, /*write */ + H5FD_family_flush, /*flush */ + H5FD_family_truncate, /*truncate */ + H5FD_family_lock, /*lock */ + H5FD_family_unlock, /*unlock */ + NULL, /*dedup */ + H5FD_FLMAP_DICHOTOMY /*fl_map */ }; - /*-------------------------------------------------------------------------- NAME H5FD__init_package -- Initialize interface-specific information @@ -163,14 +158,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_family_init() < 0) + if (H5FD_family_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize family VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_init * @@ -188,11 +182,11 @@ done: hid_t H5FD_family_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if(H5I_VFL != H5I_get_type(H5FD_FAMILY_g)) + if (H5I_VFL != H5I_get_type(H5FD_FAMILY_g)) H5FD_FAMILY_g = H5FD_register(&H5FD_family_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -202,7 +196,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_family_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_family_term * @@ -221,12 +214,11 @@ H5FD_family_term(void) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Reset VFL ID */ - H5FD_FAMILY_g=0; + H5FD_FAMILY_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_family_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_family * @@ -243,39 +235,31 @@ H5FD_family_term(void) * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * - * Raymond Lu - * Tuesday, Oct 23, 2001 - * Changed the file access list to the new generic property - * list. - * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_family(hid_t fapl_id, hsize_t msize, hid_t memb_fapl_id) { - herr_t ret_value; - H5FD_family_fapl_t fa={0, -1}; - H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; + H5FD_family_fapl_t fa = {0, -1}; + H5P_genplist_t * plist; /* Property list pointer */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ihi", fapl_id, msize, memb_fapl_id); /* Check arguments */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5P_DEFAULT == memb_fapl_id) + if (H5P_DEFAULT == memb_fapl_id) memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(memb_fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + else if (TRUE != H5P_isa_class(memb_fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") /* Initialize driver specific information. */ - fa.memb_size = msize; + fa.memb_size = msize; fa.memb_fapl_id = memb_fapl_id; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value = H5P_set_driver(plist, H5FD_FAMILY, &fa); @@ -283,7 +267,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_family * @@ -297,35 +280,28 @@ done: * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * - * Raymond Lu - * Tuesday, Oct 23, 2001 - * Changed the file access list to the new generic property - * list. - * *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize/*out*/, hid_t *memb_fapl_id/*out*/) +H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize /*out*/, hid_t *memb_fapl_id /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5FD_family_fapl_t *fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + const H5FD_family_fapl_t *fa; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, msize, memb_fapl_id); - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_FAMILY != H5P_peek_driver(plist)) + if (H5FD_FAMILY != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - if(msize) + if (msize) *msize = fa->memb_size; - if(memb_fapl_id) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fa->memb_fapl_id))) + if (memb_fapl_id) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") *memb_fapl_id = H5P_copy_plist(plist, TRUE); } /* end if */ @@ -334,7 +310,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_family_fapl_get * @@ -348,40 +323,37 @@ done: * Programmer: Robb Matzke * Friday, August 13, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * H5FD_family_fapl_get(H5FD_t *_file) { - H5FD_family_t *file = (H5FD_family_t*)_file; - H5FD_family_fapl_t *fa = NULL; - H5P_genplist_t *plist; /* Property list pointer */ - void *ret_value = NULL; /* Return value */ + H5FD_family_t * file = (H5FD_family_t *)_file; + H5FD_family_fapl_t *fa = NULL; + H5P_genplist_t * plist; /* Property list pointer */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if(NULL == (fa = (H5FD_family_fapl_t *)H5MM_calloc(sizeof(H5FD_family_fapl_t)))) + if (NULL == (fa = (H5FD_family_fapl_t *)H5MM_calloc(sizeof(H5FD_family_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") fa->memb_size = file->memb_size; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(file->memb_fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(file->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fa->memb_fapl_id = H5P_copy_plist(plist, FALSE); /* Set return value */ - ret_value=fa; + ret_value = fa; done: - if(ret_value==NULL) { - if(fa!=NULL) + if (ret_value == NULL) { + if (fa != NULL) H5MM_xfree(fa); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_family_fapl_copy * @@ -394,49 +366,46 @@ done: * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * H5FD_family_fapl_copy(const void *_old_fa) { - const H5FD_family_fapl_t *old_fa = (const H5FD_family_fapl_t*)_old_fa; - H5FD_family_fapl_t *new_fa = NULL; - H5P_genplist_t *plist; /* Property list pointer */ - void *ret_value = NULL; /* Return value */ + const H5FD_family_fapl_t *old_fa = (const H5FD_family_fapl_t *)_old_fa; + H5FD_family_fapl_t * new_fa = NULL; + H5P_genplist_t * plist; /* Property list pointer */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if(NULL == (new_fa = (H5FD_family_fapl_t *)H5MM_malloc(sizeof(H5FD_family_fapl_t)))) + if (NULL == (new_fa = (H5FD_family_fapl_t *)H5MM_malloc(sizeof(H5FD_family_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the fields of the structure */ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t)); /* Deep copy the property list objects in the structure */ - if(old_fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) { - if(H5I_inc_ref(new_fa->memb_fapl_id, FALSE)<0) + if (old_fa->memb_fapl_id == H5P_FILE_ACCESS_DEFAULT) { + if (H5I_inc_ref(new_fa->memb_fapl_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") } /* end if */ else { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(old_fa->memb_fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(old_fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") new_fa->memb_fapl_id = H5P_copy_plist(plist, FALSE); } /* end else */ /* Set return value */ - ret_value=new_fa; + ret_value = new_fa; done: - if(ret_value==NULL) { - if(new_fa!=NULL) + if (ret_value == NULL) { + if (new_fa != NULL) H5MM_xfree(new_fa); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_family_fapl_free * @@ -449,19 +418,17 @@ done: * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t H5FD_family_fapl_free(void *_fa) { - H5FD_family_fapl_t *fa = (H5FD_family_fapl_t*)_fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_fapl_t *fa = (H5FD_family_fapl_t *)_fa; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if(H5I_dec_ref(fa->memb_fapl_id) < 0) + if (H5I_dec_ref(fa->memb_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(fa); @@ -469,7 +436,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_family_sb_size * @@ -483,8 +449,6 @@ done: * Programmer: Raymond Lu * Tuesday, May 10, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static hsize_t @@ -497,7 +461,6 @@ H5FD_family_sb_size(H5FD_t H5_ATTR_UNUSED *_file) FUNC_LEAVE_NOAPI(8) } - /*------------------------------------------------------------------------- * Function: H5FD_family_sb_encode * @@ -514,14 +477,12 @@ H5FD_family_sb_size(H5FD_t H5_ATTR_UNUSED *_file) * Programmer: Raymond Lu * Tuesday, May 10, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/) +H5FD_family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { - H5FD_family_t *file = (H5FD_family_t*)_file; + H5FD_family_t *file = (H5FD_family_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -542,7 +503,6 @@ H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out* FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_family_sb_encode() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_sb_decode * @@ -564,9 +524,9 @@ H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out* static herr_t H5FD_family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const unsigned char *buf) { - H5FD_family_t *file = (H5FD_family_t*)_file; - uint64_t msize; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + uint64_t msize; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -577,16 +537,18 @@ H5FD_family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const unsi * h5repart is being used to change member file size. h5repart will open * files for read and write. When the files are closed, metadata will be * flushed to the files and updated to this new size */ - if(file->mem_newsize) + if (file->mem_newsize) file->memb_size = file->pmem_size = file->mem_newsize; else { /* Default - use the saved member size */ - if(file->pmem_size == H5F_FAMILY_DEFAULT) - file->pmem_size = msize; + if (file->pmem_size == H5F_FAMILY_DEFAULT) + file->pmem_size = msize; /* Check if member size from file access property is correct */ - if(msize != file->pmem_size) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size) + if (msize != file->pmem_size) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "Family member size should be %lu. But the size from file access property is %lu", + (unsigned long)msize, (unsigned long)file->pmem_size) /* Update member file size to the size saved in the superblock. * That's the size intended to be. */ @@ -597,7 +559,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_sb_decode() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_open * @@ -620,97 +581,96 @@ done: * memb_name & temp in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static H5FD_t * -H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr) +H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_family_t *file = NULL; - char *memb_name = NULL, *temp = NULL; - hsize_t eof = HADDR_UNDEF; - unsigned t_flags = flags & ~H5F_ACC_CREAT; - H5FD_t *ret_value = NULL; + H5FD_family_t *file = NULL; + char * memb_name = NULL, *temp = NULL; + hsize_t eof = HADDR_UNDEF; + unsigned t_flags = flags & ~H5F_ACC_CREAT; + H5FD_t * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") /* Initialize file from file access properties */ - if(NULL == (file = (H5FD_family_t *)H5MM_calloc(sizeof(H5FD_family_t)))) + if (NULL == (file = (H5FD_family_t *)H5MM_calloc(sizeof(H5FD_family_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") - if(H5P_FILE_ACCESS_DEFAULT == fapl_id) { + if (H5P_FILE_ACCESS_DEFAULT == fapl_id) { file->memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; - if(H5I_inc_ref(file->memb_fapl_id, FALSE) < 0) + if (H5I_inc_ref(file->memb_fapl_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") - file->memb_size = 1024 * 1024 * 1024; /*1GB. Actual member size to be updated later */ - file->pmem_size = 1024 * 1024 * 1024; /*1GB. Member size passed in through property */ - file->mem_newsize = 0; /*New member size used by h5repart only */ - } /* end if */ + file->memb_size = 1024 * 1024 * 1024; /*1GB. Actual member size to be updated later */ + file->pmem_size = 1024 * 1024 * 1024; /*1GB. Member size passed in through property */ + file->mem_newsize = 0; /*New member size used by h5repart only */ + } /* end if */ else { - H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t * plist; /* Property list pointer */ const H5FD_family_fapl_t *fa; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Check for new family file size. It's used by h5repart only. */ - if(H5P_exist_plist(plist, H5F_ACS_FAMILY_NEWSIZE_NAME) > 0) { + if (H5P_exist_plist(plist, H5F_ACS_FAMILY_NEWSIZE_NAME) > 0) { /* Get the new family file size */ - if(H5P_get(plist, H5F_ACS_FAMILY_NEWSIZE_NAME, &file->mem_newsize) < 0) + if (H5P_get(plist, H5F_ACS_FAMILY_NEWSIZE_NAME, &file->mem_newsize) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get new family member size") /* Set flag for later */ file->repart_members = TRUE; } /* end if */ - if(fa->memb_fapl_id == H5P_FILE_ACCESS_DEFAULT) { - if(H5I_inc_ref(fa->memb_fapl_id, FALSE) < 0) + if (fa->memb_fapl_id == H5P_FILE_ACCESS_DEFAULT) { + if (H5I_inc_ref(fa->memb_fapl_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") file->memb_fapl_id = fa->memb_fapl_id; } /* end if */ else { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fa->memb_fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") file->memb_fapl_id = H5P_copy_plist(plist, FALSE); - } /* end else */ + } /* end else */ file->memb_size = fa->memb_size; /* Actual member size to be updated later */ file->pmem_size = fa->memb_size; /* Member size passed in through property */ - } /* end else */ - file->name = H5MM_strdup(name); + } /* end else */ + file->name = H5MM_strdup(name); file->flags = flags; /* Allocate space for the string buffers */ - if(NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) + if (NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate member name") - if(NULL == (temp = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) + if (NULL == (temp = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate temporary member name") /* Check that names are unique */ HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, 0); HDsnprintf(temp, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, 1); - if(!HDstrcmp(memb_name, temp)) + if (!HDstrcmp(memb_name, temp)) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique") /* Open all the family members */ - while(1) { + while (1) { HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, file->nmembs); /* Enlarge member array */ - if(file->nmembs >= file->amembs) { + if (file->nmembs >= file->amembs) { unsigned n = MAX(64, 2 * file->amembs); H5FD_t **x; HDassert(n > 0); - if(NULL == (x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)))) + if (NULL == (x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to reallocate members") file->amembs = n; - file->memb = x; + file->memb = x; } /* end if */ /* @@ -718,10 +678,12 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, * otherwise an open failure means that we've reached the last member. * Allow H5F_ACC_CREAT only on the first family member. */ - H5E_BEGIN_TRY { - file->memb[file->nmembs] = H5FDopen(memb_name, - (0==file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + file->memb[file->nmembs] = + H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); + } + H5E_END_TRY; if (!file->memb[file->nmembs]) { if (0 == file->nmembs) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open member file") @@ -735,45 +697,45 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, * smaller than the size specified through H5Pset_fapl_family(). Update the actual * member size. */ - if ((eof=H5FDget_eof(file->memb[0], H5FD_MEM_DEFAULT))) file->memb_size = eof; + if ((eof = H5FDget_eof(file->memb[0], H5FD_MEM_DEFAULT))) + file->memb_size = eof; - ret_value=(H5FD_t *)file; + ret_value = (H5FD_t *)file; done: /* Release resources */ - if(memb_name) + if (memb_name) H5MM_xfree(memb_name); - if(temp) + if (temp) H5MM_xfree(temp); /* Cleanup and fail */ - if(ret_value == NULL && file != NULL) { - unsigned nerrors = 0; /* Number of errors closing member files */ - unsigned u; /* Local index variable */ + if (ret_value == NULL && file != NULL) { + unsigned nerrors = 0; /* Number of errors closing member files */ + unsigned u; /* Local index variable */ /* Close as many members as possible. Use private function here to avoid clearing * the error stack. We need the error message to indicate wrong member file size. */ - for(u = 0; u < file->nmembs; u++) - if(file->memb[u]) - if(H5FD_close(file->memb[u]) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u]) + if (H5FD_close(file->memb[u]) < 0) nerrors++; - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close member files") - if(file->memb) + if (file->memb) H5MM_xfree(file->memb); - if(H5I_dec_ref(file->memb_fapl_id) < 0) + if (H5I_dec_ref(file->memb_fapl_id) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID") - if(file->name) + if (file->name) H5MM_xfree(file->name); H5MM_xfree(file); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_open() */ -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - /*------------------------------------------------------------------------- * Function: H5FD_family_close * @@ -793,29 +755,29 @@ H5_GCC_DIAG_ON(format-nonliteral) static herr_t H5FD_family_close(H5FD_t *_file) { - H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned nerrors = 0; /* Number of errors while closing member files */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + unsigned nerrors = 0; /* Number of errors while closing member files */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Close as many members as possible. Use private function here to avoid clearing * the error stack. We need the error message to indicate wrong member file size. */ - for(u = 0; u < file->nmembs; u++) { - if(file->memb[u]) { - if(H5FD_close(file->memb[u]) < 0) + for (u = 0; u < file->nmembs; u++) { + if (file->memb[u]) { + if (H5FD_close(file->memb[u]) < 0) nerrors++; else file->memb[u] = NULL; } /* end if */ - } /* end for */ - if(nerrors) + } /* end for */ + if (nerrors) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close member files") /* Clean up other stuff */ - if(H5I_dec_ref(file->memb_fapl_id) < 0) + if (H5I_dec_ref(file->memb_fapl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(file->memb); @@ -825,7 +787,6 @@ H5FD_family_close(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_close() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_cmp * @@ -840,16 +801,14 @@ H5FD_family_close(H5FD_t *_file) * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static int H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_family_t *f1 = (const H5FD_family_t*)_f1; - const H5FD_family_t *f2 = (const H5FD_family_t*)_f2; - int ret_value = 0; + const H5FD_family_t *f1 = (const H5FD_family_t *)_f1; + const H5FD_family_t *f2 = (const H5FD_family_t *)_f2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -861,7 +820,6 @@ H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_query * @@ -877,29 +835,29 @@ H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) *------------------------------------------------------------------------- */ static herr_t -H5FD_family_query(const H5FD_t * _file, unsigned long *flags /* out */) +H5FD_family_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_family_t *file = (const H5FD_family_t*)_file; /* Family VFD info */ + const H5FD_family_t *file = (const H5FD_family_t *)_file; /* Family VFD info */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes. */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ /* Check for flags that are set by h5repart */ - if(file && file->repart_members) - *flags |= H5FD_FEAT_DIRTY_DRVRINFO_LOAD; /* Mark the superblock dirty when it is loaded (so the family member sizes are rewritten) */ - } /* end if */ + if (file && file->repart_members) + *flags |= H5FD_FEAT_DIRTY_DRVRINFO_LOAD; /* Mark the superblock dirty when it is loaded (so the + family member sizes are rewritten) */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_family_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_get_eoa * @@ -914,24 +872,18 @@ H5FD_family_query(const H5FD_t * _file, unsigned long *flags /* out */) * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static haddr_t H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_family_t *file = (const H5FD_family_t*)_file; + const H5FD_family_t *file = (const H5FD_family_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(file->eoa) } - /*------------------------------------------------------------------------- * Function: H5FD_family_set_eoa * @@ -944,11 +896,6 @@ H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ /* Disable warning for "format not a string literal" here -QAK */ @@ -957,76 +904,77 @@ H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) * memb_name in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static herr_t H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) { - H5FD_family_t *file = (H5FD_family_t*)_file; - haddr_t addr = abs_eoa; - char *memb_name = NULL; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + haddr_t addr = abs_eoa; + char * memb_name = NULL; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Allocate space for the member name buffer */ - if(NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) + if (NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate member name") - for(u = 0; addr || u < file->nmembs; u++) { + for (u = 0; addr || u < file->nmembs; u++) { /* Enlarge member array */ - if(u >= file->amembs) { + if (u >= file->amembs) { unsigned n = MAX(64, 2 * file->amembs); H5FD_t **x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)); - if(!x) + if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") file->amembs = n; - file->memb = x; + file->memb = x; file->nmembs = u; } /* end if */ /* Create another file if necessary */ - if(u >= file->nmembs || !file->memb[u]) { - file->nmembs = MAX(file->nmembs, u+1); + if (u >= file->nmembs || !file->memb[u]) { + file->nmembs = MAX(file->nmembs, u + 1); HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, file->name, u); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); - file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, - file->memb_fapl_id, (haddr_t)file->memb_size); - } H5E_END_TRY; - if(NULL == file->memb[u]) + file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, file->memb_fapl_id, + (haddr_t)file->memb_size); + } + H5E_END_TRY; + if (NULL == file->memb[u]) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open member file") } /* end if */ /* Set the EOA marker for the member */ /* (Note compensating for base address addition in internal routine) */ H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); - if(addr > (haddr_t)file->memb_size) { - if(H5FD_set_eoa(file->memb[u], type, ((haddr_t)file->memb_size - file->pub.base_addr)) < 0) + if (addr > (haddr_t)file->memb_size) { + if (H5FD_set_eoa(file->memb[u], type, ((haddr_t)file->memb_size - file->pub.base_addr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set file eoa") addr -= file->memb_size; } /* end if */ else { - if(H5FD_set_eoa(file->memb[u], type, (addr - file->pub.base_addr)) < 0) + if (H5FD_set_eoa(file->memb[u], type, (addr - file->pub.base_addr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set file eoa") addr = 0; } /* end else */ - } /* end for */ + } /* end for */ file->eoa = abs_eoa; done: /* Release resources */ - if(memb_name) + if (memb_name) H5MM_xfree(memb_name); FUNC_LEAVE_NOAPI(ret_value) } -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - /*------------------------------------------------------------------------- * Function: H5FD_family_get_eof * @@ -1042,17 +990,15 @@ H5_GCC_DIAG_ON(format-nonliteral) * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static haddr_t H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) { - const H5FD_family_t *file = (const H5FD_family_t*)_file; - haddr_t eof=0; - int i; /* Local index variable */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + const H5FD_family_t *file = (const H5FD_family_t *)_file; + haddr_t eof = 0; + int i; /* Local index variable */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1062,10 +1008,10 @@ H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) * loop with i==0. */ HDassert(file->nmembs > 0); - for(i = (int)file->nmembs - 1; i >= 0; --i) { - if((eof = H5FD_get_eof(file->memb[i], type)) != 0) + for (i = (int)file->nmembs - 1; i >= 0; --i) { + if ((eof = H5FD_get_eof(file->memb[i], type)) != 0) break; - if(0 == i) + if (0 == i) break; } /* end for */ @@ -1076,7 +1022,7 @@ H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) * The file size is the number of members before the i'th member plus the * size of the i'th member. */ - eof += ((unsigned)i)*file->memb_size; + eof += ((unsigned)i) * file->memb_size; /* Set return value */ ret_value = eof; @@ -1084,7 +1030,6 @@ H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_family_get_handle * @@ -1095,30 +1040,28 @@ H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type) * Programmer: Raymond Lu * Sept. 16, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) +H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - H5FD_family_t *file = (H5FD_family_t *)_file; - H5P_genplist_t *plist; - hsize_t offset; - int memb; - herr_t ret_value = FAIL; /* Return value */ + H5FD_family_t * file = (H5FD_family_t *)_file; + H5P_genplist_t *plist; + hsize_t offset; + int memb; + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get the plist structure and family offset */ - if(NULL == (plist = H5P_object_verify(fapl, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) + if (H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get offset for family driver") - if(offset > (file->memb_size * file->nmembs)) + if (offset > (file->memb_size * file->nmembs)) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "offset is bigger than file size") - memb = (int)(offset/file->memb_size); + memb = (int)(offset / file->memb_size); ret_value = H5FD_get_vfd_handle(file->memb[memb], fapl, file_handle); @@ -1126,7 +1069,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_family_read * @@ -1142,22 +1084,19 @@ done: * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - void *_buf/*out*/) +H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *_buf /*out*/) { - H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned char *buf = (unsigned char*)_buf; - haddr_t sub; - size_t req; - hsize_t tempreq; - unsigned u; /* Local index variable */ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_family_t * file = (H5FD_family_t *)_file; + unsigned char * buf = (unsigned char *)_buf; + haddr_t sub; + size_t req; + hsize_t tempreq; + unsigned u; /* Local index variable */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1165,26 +1104,26 @@ H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si * Get the member data transfer property list. If the transfer property * list does not belong to this driver then assume defaults */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /* Read from each member */ - while(size > 0) { + while (size > 0) { H5_CHECKED_ASSIGN(u, unsigned, addr / file->memb_size, hsize_t); sub = addr % file->memb_size; - /* This check is for mainly for IA32 architecture whose size_t's size - * is 4 bytes, to prevent overflow when user application is trying to - * write files bigger than 4GB. */ - tempreq = file->memb_size-sub; - if(tempreq > SIZET_MAX) - tempreq = SIZET_MAX; + /* This check is for mainly for IA32 architecture whose size_t's size + * is 4 bytes, to prevent overflow when user application is trying to + * write files bigger than 4GB. */ + tempreq = file->memb_size - sub; + if (tempreq > SIZET_MAX) + tempreq = SIZET_MAX; req = MIN(size, (size_t)tempreq); - HDassert(unmembs); + HDassert(u < file->nmembs); - if (H5FDread(file->memb[u], type, dxpl_id, sub, req, buf)<0) + if (H5FDread(file->memb[u], type, dxpl_id, sub, req, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "member file read failed") addr += req; @@ -1196,7 +1135,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_family_write * @@ -1211,22 +1149,19 @@ done: * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - const void *_buf) +H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf) { - H5FD_family_t *file = (H5FD_family_t*)_file; - const unsigned char *buf = (const unsigned char*)_buf; - haddr_t sub; - size_t req; - hsize_t tempreq; - unsigned u; /* Local index variable */ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t * file = (H5FD_family_t *)_file; + const unsigned char *buf = (const unsigned char *)_buf; + haddr_t sub; + size_t req; + hsize_t tempreq; + unsigned u; /* Local index variable */ + H5P_genplist_t * plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1234,11 +1169,11 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s * Get the member data transfer property list. If the transfer property * list does not belong to this driver then assume defaults. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /* Write to each member */ - while (size>0) { + while (size > 0) { H5_CHECKED_ASSIGN(u, unsigned, addr / file->memb_size, hsize_t); sub = addr % file->memb_size; @@ -1246,14 +1181,14 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s /* This check is for mainly for IA32 architecture whose size_t's size * is 4 bytes, to prevent overflow when user application is trying to * write files bigger than 4GB. */ - tempreq = file->memb_size-sub; - if(tempreq > SIZET_MAX) - tempreq = SIZET_MAX; + tempreq = file->memb_size - sub; + if (tempreq > SIZET_MAX) + tempreq = SIZET_MAX; req = MIN(size, (size_t)tempreq); - HDassert(unmembs); + HDassert(u < file->nmembs); - if (H5FDwrite(file->memb[u], type, dxpl_id, sub, req, buf)<0) + if (H5FDwrite(file->memb[u], type, dxpl_id, sub, req, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "member file write failed") addr += req; @@ -1265,7 +1200,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_family_flush * @@ -1282,24 +1216,23 @@ done: static herr_t H5FD_family_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned u, nerrors = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + unsigned u, nerrors = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - for(u = 0; u < file->nmembs; u++) - if(file->memb[u] && H5FD_flush(file->memb[u], closing) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u] && H5FD_flush(file->memb[u], closing) < 0) nerrors++; - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "unable to flush member files") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_flush() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_truncate * @@ -1317,24 +1250,23 @@ done: static herr_t H5FD_family_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned u, nerrors = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + unsigned u, nerrors = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - for(u = 0; u < file->nmembs; u++) - if(file->memb[u] && H5FD_truncate(file->memb[u], closing) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u] && H5FD_truncate(file->memb[u], closing) < 0) nerrors++; - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "unable to flush member files") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_lock * @@ -1352,26 +1284,26 @@ done: static herr_t H5FD_family_lock(H5FD_t *_file, hbool_t rw) { - H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Place the lock on all the member files */ - for(u = 0; u < file->nmembs; u++) - if(file->memb[u]) - if(H5FD_lock(file->memb[u], rw) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u]) + if (H5FD_lock(file->memb[u], rw) < 0) break; /* If one of the locks failed, try to unlock the locked member files * in an attempt to return to a fully unlocked state. */ - if(u < file->nmembs) { - unsigned v; /* Local index variable */ + if (u < file->nmembs) { + unsigned v; /* Local index variable */ - for(v = 0; v < u; v++) { - if(H5FD_unlock(file->memb[v]) < 0) + for (v = 0; v < u; v++) { + if (H5FD_unlock(file->memb[v]) < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files") } /* end for */ @@ -1382,7 +1314,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_unlock * @@ -1397,19 +1328,18 @@ done: static herr_t H5FD_family_unlock(H5FD_t *_file) { - H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Remove the lock on the member files */ - for(u = 0; u < file->nmembs; u++) - if(file->memb[u]) - if(H5FD_unlock(file->memb[u]) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u]) + if (H5FD_unlock(file->memb[u]) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_family_unlock() */ - diff --git a/src/H5FDfamily.h b/src/H5FDfamily.h index 1584cf6..acf6180 100644 --- a/src/H5FDfamily.h +++ b/src/H5FDfamily.h @@ -20,21 +20,18 @@ #ifndef H5FDfamily_H #define H5FDfamily_H -#define H5FD_FAMILY (H5FD_family_init()) +#define H5FD_FAMILY (H5FD_family_init()) #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_family_init(void); -H5_DLL herr_t H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, - hid_t memb_fapl_id); -H5_DLL herr_t H5Pget_fapl_family(hid_t fapl_id, hsize_t *memb_size/*out*/, - hid_t *memb_fapl_id/*out*/); +H5_DLL hid_t H5FD_family_init(void); +H5_DLL herr_t H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id); +H5_DLL herr_t H5Pget_fapl_family(hid_t fapl_id, hsize_t *memb_size /*out*/, hid_t *memb_fapl_id /*out*/); #ifdef __cplusplus } #endif #endif - diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index 2c06420..6599b9b 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -23,13 +23,13 @@ /* This source code file is part of the H5FD driver module */ #include "H5FDdrvr_module.h" -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDhdfs.h" /* hdfs file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDhdfs.h" /* hdfs file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_LIBHDFS #include "hdfs.h" @@ -59,35 +59,32 @@ static hid_t H5FD_HDFS_g = 0; * 2^(10+(1*16)) = 2^26 = 64MB * Reads of 64MB or greater fall in "overflow" bin[BIN_COUNT] */ -#define HDFS_STATS_BASE 2 -#define HDFS_STATS_INTERVAL 1 +#define HDFS_STATS_BASE 2 +#define HDFS_STATS_INTERVAL 1 #define HDFS_STATS_START_POWER 10 #define HDFS_STATS_BIN_COUNT 16 /* MUST BE GREATER THAN 0 */ - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Calculate `BASE ^ (START_POWER + (INTERVAL * bin_i))` * Stores result at `(unsigned long long *) out_ptr`. * Used in computing boundaries between stats bins. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define HDFS_STATS_POW(bin_i, out_ptr) { \ - unsigned long long donotshadowresult = 1; \ - unsigned donotshadowindex = 0; \ - for (donotshadowindex = 0; \ - donotshadowindex < (((bin_i) * HDFS_STATS_INTERVAL) + \ - HDFS_STATS_START_POWER); \ - donotshadowindex++) \ - { \ - donotshadowresult *= HDFS_STATS_BASE; \ - } \ - *(out_ptr) = donotshadowresult; \ -} +#define HDFS_STATS_POW(bin_i, out_ptr) \ + { \ + unsigned long long donotshadowresult = 1; \ + unsigned donotshadowindex = 0; \ + for (donotshadowindex = 0; \ + donotshadowindex < (((bin_i)*HDFS_STATS_INTERVAL) + HDFS_STATS_START_POWER); \ + donotshadowindex++) { \ + donotshadowresult *= HDFS_STATS_BASE; \ + } \ + *(out_ptr) = donotshadowresult; \ + } /* array to hold pre-computed boundaries for stats bins */ static unsigned long long hdfs_stats_boundaries[HDFS_STATS_BIN_COUNT]; - /*************************************************************************** * * Structure: hdfs_statsbin @@ -137,7 +134,6 @@ typedef struct { */ #define HDFS_HDFST_MAGIC 0x1AD5DE84 - /*************************************************************************** * * Structure: hdfs_t @@ -180,13 +176,12 @@ typedef struct { *************************************************************************** */ typedef struct { - unsigned long magic; - hdfsFS filesystem; - hdfsFileInfo *fileinfo; - hdfsFile file; + unsigned long magic; + hdfsFS filesystem; + hdfsFileInfo *fileinfo; + hdfsFile file; } hdfs_t; - /*-------------------------------------------------------------------------- * Function: H5FD_hdfs_handle_open * @@ -202,17 +197,13 @@ typedef struct { *-------------------------------------------------------------------------- */ static hdfs_t * -H5FD_hdfs_handle_open( - const char *path, - const char *namenode_name, - const int32_t namenode_port, - const char *user_name, - const char *kerberos_ticket_cache, - const int32_t stream_buffer_size) +H5FD_hdfs_handle_open(const char *path, const char *namenode_name, const int32_t namenode_port, + const char *user_name, const char *kerberos_ticket_cache, + const int32_t stream_buffer_size) { struct hdfsBuilder *builder = NULL; - hdfs_t *handle = NULL; - hdfs_t *ret_value = NULL; + hdfs_t * handle = NULL; + hdfs_t * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -221,26 +212,21 @@ H5FD_hdfs_handle_open( #endif if (path == NULL || path[0] == '\0') { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "path cannot be null.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "path cannot be null.\n") } - if (namenode_name == NULL /* || namenode_name[0] == '\0' */ ) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "namenode name cannot be null.\n") + if (namenode_name == NULL /* || namenode_name[0] == '\0' */) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "namenode name cannot be null.\n") } if (namenode_port < 0 || namenode_port > 65535) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "namenode port must be non-negative and <= 65535.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "namenode port must be non-negative and <= 65535.\n") } if (stream_buffer_size < 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "buffer size must non-negative.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "buffer size must non-negative.\n") } handle = (hdfs_t *)H5MM_malloc(sizeof(hdfs_t)); if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, - "could not malloc space for handle.\n") + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "could not malloc space for handle.\n") } handle->magic = (unsigned long)HDFS_HDFST_MAGIC; @@ -250,8 +236,7 @@ H5FD_hdfs_handle_open( builder = hdfsNewBuilder(); if (!builder) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "(hdfs) failed to create builder") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "(hdfs) failed to create builder") } hdfsBuilderSetNameNode(builder, namenode_name); hdfsBuilderSetNameNodePort(builder, (tPort)namenode_port); @@ -264,24 +249,15 @@ H5FD_hdfs_handle_open( /* Call to `hdfsBuilderConnect` releases builder, regardless of success. */ handle->filesystem = hdfsBuilderConnect(builder); if (!handle->filesystem) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "(hdfs) could not connect to default namenode") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "(hdfs) could not connect to default namenode") } handle->fileinfo = hdfsGetPathInfo(handle->filesystem, path); if (!handle->fileinfo) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "hdfsGetPathInfo failed") - } - handle->file = hdfsOpenFile( - handle->filesystem, - path, - O_RDONLY, - stream_buffer_size, - 0, - 0); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "hdfsGetPathInfo failed") + } + handle->file = hdfsOpenFile(handle->filesystem, path, O_RDONLY, stream_buffer_size, 0, 0); if (!handle->file) { - HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, - "(hdfs) could not open") + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "(hdfs) could not open") } ret_value = handle; @@ -293,8 +269,7 @@ done: handle->magic++; if (handle->file != NULL) { if (FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, - "unable to close hdfs file handle") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close hdfs file handle") } } if (handle->fileinfo != NULL) { @@ -302,8 +277,7 @@ done: } if (handle->filesystem != NULL) { if (FAIL == (hdfsDisconnect(handle->filesystem))) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, - "unable to disconnect from hdfs") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to disconnect from hdfs") } } H5MM_xfree(handle); @@ -313,7 +287,6 @@ done: } /* H5FD_hdfs_handle_open() */ - /*-------------------------------------------------------------------------- * Function: H5FD_hdfs_handle_close * @@ -341,19 +314,16 @@ H5FD_hdfs_handle_close(hdfs_t *handle) #endif if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle cannot be null.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null.\n") } if (handle->magic != HDFS_HDFST_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle has invalid magic.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic.\n") } handle->magic++; if (handle->file != NULL) { if (FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "unable to close hdfs file handle") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close hdfs file handle") } } if (handle->fileinfo != NULL) { @@ -361,8 +331,7 @@ H5FD_hdfs_handle_close(hdfs_t *handle) } if (handle->filesystem != NULL) { if (FAIL == (hdfsDisconnect(handle->filesystem))) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "unable to disconnect hdfs file system") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to disconnect hdfs file system") } } @@ -375,7 +344,6 @@ done: #endif /* H5_HAVE_LIBHDFS */ - /*************************************************************************** * * Structure: H5FD_hdfs_t @@ -437,15 +405,15 @@ done: *************************************************************************** */ typedef struct H5FD_hdfs_t { - H5FD_t pub; - H5FD_hdfs_fapl_t fa; - haddr_t eoa; + H5FD_t pub; + H5FD_hdfs_fapl_t fa; + haddr_t eoa; #ifdef H5_HAVE_LIBHDFS - hdfs_t *hdfs_handle; + hdfs_t *hdfs_handle; #endif #if HDFS_STATS - hdfs_statsbin meta[HDFS_STATS_BIN_COUNT + 1]; - hdfs_statsbin raw[HDFS_STATS_BIN_COUNT + 1]; + hdfs_statsbin meta[HDFS_STATS_BIN_COUNT + 1]; + hdfs_statsbin raw[HDFS_STATS_BIN_COUNT + 1]; #endif } H5FD_hdfs_t; @@ -459,70 +427,67 @@ typedef struct H5FD_hdfs_t { * Only included if HDFS code should compile. * */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) #ifdef H5_HAVE_LIBHDFS -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) #endif /* H5_HAVE_LIBHDFS */ /* Prototypes */ static herr_t H5FD_hdfs_term(void); -static void *H5FD_hdfs_fapl_get(H5FD_t *_file); -static void *H5FD_hdfs_fapl_copy(const void *_old_fa); +static void * H5FD_hdfs_fapl_get(H5FD_t *_file); +static void * H5FD_hdfs_fapl_copy(const void *_old_fa); static herr_t H5FD_hdfs_fapl_free(void *_fa); -static H5FD_t *H5FD_hdfs_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); +static H5FD_t *H5FD_hdfs_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_hdfs_close(H5FD_t *_file); static int H5FD_hdfs_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_hdfs_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_hdfs_get_eoa(const H5FD_t *_file, H5FD_mem_t type); static herr_t H5FD_hdfs_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_hdfs_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_hdfs_get_handle(H5FD_t *_file, hid_t fapl, - void** file_handle); -static herr_t H5FD_hdfs_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, void *buf); -static herr_t H5FD_hdfs_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, const void *buf); -static herr_t H5FD_hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, - hbool_t closing); +static herr_t H5FD_hdfs_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_hdfs_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_hdfs_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static herr_t H5FD_hdfs_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD_hdfs_unlock(H5FD_t *_file); -static herr_t H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t * fa); +static herr_t H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t *fa); static const H5FD_class_t H5FD_hdfs_g = { - "hdfs", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_hdfs_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - sizeof(H5FD_hdfs_fapl_t), /* fapl_size */ - H5FD_hdfs_fapl_get, /* fapl_get */ - H5FD_hdfs_fapl_copy, /* fapl_copy */ - H5FD_hdfs_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_hdfs_open, /* open */ - H5FD_hdfs_close, /* close */ - H5FD_hdfs_cmp, /* cmp */ - H5FD_hdfs_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD_hdfs_get_eoa, /* get_eoa */ - H5FD_hdfs_set_eoa, /* set_eoa */ - H5FD_hdfs_get_eof, /* get_eof */ - H5FD_hdfs_get_handle, /* get_handle */ - H5FD_hdfs_read, /* read */ - H5FD_hdfs_write, /* write */ - NULL, /* flush */ - H5FD_hdfs_truncate, /* truncate */ - H5FD_hdfs_lock, /* lock */ - H5FD_hdfs_unlock, /* unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "hdfs", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_hdfs_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_hdfs_fapl_t), /* fapl_size */ + H5FD_hdfs_fapl_get, /* fapl_get */ + H5FD_hdfs_fapl_copy, /* fapl_copy */ + H5FD_hdfs_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_hdfs_open, /* open */ + H5FD_hdfs_close, /* close */ + H5FD_hdfs_cmp, /* cmp */ + H5FD_hdfs_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_hdfs_get_eoa, /* get_eoa */ + H5FD_hdfs_set_eoa, /* set_eoa */ + H5FD_hdfs_get_eof, /* get_eof */ + H5FD_hdfs_get_handle, /* get_handle */ + H5FD_hdfs_read, /* read */ + H5FD_hdfs_write, /* write */ + NULL, /* flush */ + H5FD_hdfs_truncate, /* truncate */ + H5FD_hdfs_lock, /* lock */ + H5FD_hdfs_unlock, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; #ifdef H5_HAVE_LIBHDFS @@ -530,7 +495,6 @@ static const H5FD_class_t H5FD_hdfs_g = { H5FL_DEFINE_STATIC(H5FD_hdfs_t); #endif /* H5_HAVE_LIBHDFS */ - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -551,8 +515,7 @@ H5FD__init_package(void) FUNC_ENTER_STATIC if (H5FD_hdfs_init() < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, - "unable to initialize hdfs VFD") + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize hdfs VFD") } done: @@ -560,7 +523,6 @@ done: } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_hdfs_init * @@ -588,13 +550,13 @@ H5FD_hdfs_init(void) HDfprintf(stdout, "H5FD_hdfs_init() called.\n"); #endif - if(H5I_VFL != H5I_get_type(H5FD_HDFS_g)) - H5FD_HDFS_g = H5FD_register( &H5FD_hdfs_g, sizeof(H5FD_class_t), FALSE); + if (H5I_VFL != H5I_get_type(H5FD_HDFS_g)) + H5FD_HDFS_g = H5FD_register(&H5FD_hdfs_g, sizeof(H5FD_class_t), FALSE); #if HDFS_STATS /* pre-compute statsbin boundaries */ - for(bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) { + for (bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) { unsigned long long value = 0; HDFS_STATS_POW(bin_i, &value) @@ -608,7 +570,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_hdfs_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_hdfs_term * @@ -639,7 +600,6 @@ H5FD_hdfs_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_hdfs_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_hdfs * @@ -659,8 +619,7 @@ H5FD_hdfs_term(void) *------------------------------------------------------------------------- */ herr_t -H5Pset_fapl_hdfs(hid_t fapl_id, - H5FD_hdfs_fapl_t *fa) +H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa) { H5P_genplist_t *plist = NULL; /* Property list pointer */ herr_t ret_value = FAIL; @@ -676,13 +635,11 @@ H5Pset_fapl_hdfs(hid_t fapl_id, plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); if (plist == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, \ - "not a file access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") } if (FAIL == H5FD_hdfs_validate_config(fa)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "invalid hdfs config") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid hdfs config") } ret_value = H5P_set_driver(plist, H5FD_HDFS, (void *)fa); @@ -692,7 +649,6 @@ done: } /* H5Pset_fapl_hdfs() */ - /*------------------------------------------------------------------------- * Function: H5FD_hdfs_validate_config() * @@ -716,7 +672,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t * fa) +H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t *fa) { herr_t ret_value = SUCCEED; @@ -724,18 +680,15 @@ H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t * fa) HDassert(fa != NULL); - if ( fa->version != H5FD__CURR_HDFS_FAPL_T_VERSION ) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Unknown H5FD_hdfs_fapl_t version"); + if (fa->version != H5FD__CURR_HDFS_FAPL_T_VERSION) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown H5FD_hdfs_fapl_t version"); } - if ( fa->namenode_port > 65535 ) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Invalid namenode port number"); + if (fa->namenode_port > 65535) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid namenode port number"); } - if ( fa->namenode_port < 0 ) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Invalid namenode port number"); + if (fa->namenode_port < 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid namenode port number"); } done: @@ -743,7 +696,6 @@ done: } /* H5FD_hdfs_validate_config() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_hdfs * @@ -762,11 +714,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_hdfs(hid_t fapl_id, - H5FD_hdfs_fapl_t *fa_out) +H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out) { const H5FD_hdfs_fapl_t *fa = NULL; - H5P_genplist_t *plist = NULL; + H5P_genplist_t * plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -777,23 +728,19 @@ H5Pget_fapl_hdfs(hid_t fapl_id, #endif if (fa_out == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "fa_out is NULL") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_out is NULL") } plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); if (plist == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") } if (H5FD_HDFS != H5P_peek_driver(plist)) { - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, - "incorrect VFL driver") + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") } fa = (const H5FD_hdfs_fapl_t *)H5P_peek_driver_info(plist); if (fa == NULL) { - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, - "bad VFL driver info") + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") } /* Copy the hdfs fapl data out */ @@ -804,7 +751,6 @@ done: } /* H5Pget_fapl_hdfs() */ - /*------------------------------------------------------------------------- * Function: H5FD_hdfs_fapl_get * @@ -825,16 +771,15 @@ done: static void * H5FD_hdfs_fapl_get(H5FD_t *_file) { - H5FD_hdfs_t *file = (H5FD_hdfs_t*)_file; + H5FD_hdfs_t * file = (H5FD_hdfs_t *)_file; H5FD_hdfs_fapl_t *fa = NULL; - void *ret_value = NULL; + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT fa = (H5FD_hdfs_fapl_t *)H5MM_calloc(sizeof(H5FD_hdfs_fapl_t)); if (fa == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* Copy the fields of the structure */ @@ -851,7 +796,6 @@ done: } /* H5FD_hdfs_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD_hdfs_fapl_copy * @@ -871,16 +815,15 @@ done: static void * H5FD_hdfs_fapl_copy(const void *_old_fa) { - const H5FD_hdfs_fapl_t *old_fa = (const H5FD_hdfs_fapl_t*)_old_fa; - H5FD_hdfs_fapl_t *new_fa = NULL; - void *ret_value = NULL; + const H5FD_hdfs_fapl_t *old_fa = (const H5FD_hdfs_fapl_t *)_old_fa; + H5FD_hdfs_fapl_t * new_fa = NULL; + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT new_fa = (H5FD_hdfs_fapl_t *)H5MM_malloc(sizeof(H5FD_hdfs_fapl_t)); if (new_fa == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } HDmemcpy(new_fa, old_fa, sizeof(H5FD_hdfs_fapl_t)); @@ -895,7 +838,6 @@ done: } /* H5FD_hdfs_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD_hdfs_fapl_free * @@ -913,7 +855,7 @@ done: static herr_t H5FD_hdfs_fapl_free(void *_fa) { - H5FD_hdfs_fapl_t *fa = (H5FD_hdfs_fapl_t*)_fa; + H5FD_hdfs_fapl_t *fa = (H5FD_hdfs_fapl_t *)_fa; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -963,15 +905,14 @@ hdfs_reset_stats(H5FD_hdfs_t *file) #endif if (file == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file was null") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file was null") } for (i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { - file->raw[i].bytes = 0; - file->raw[i].count = 0; - file->raw[i].min = (unsigned long long)HDFS_STATS_STARTING_MIN; - file->raw[i].max = 0; + file->raw[i].bytes = 0; + file->raw[i].count = 0; + file->raw[i].min = (unsigned long long)HDFS_STATS_STARTING_MIN; + file->raw[i].max = 0; file->meta[i].bytes = 0; file->meta[i].count = 0; @@ -985,7 +926,6 @@ done: } /* hdfs_reset_stats */ #endif /* HDFS_STATS */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_open() @@ -1013,16 +953,12 @@ done: */ #ifdef H5_HAVE_LIBHDFS static H5FD_t * -H5FD_hdfs_open( - const char *path, - unsigned flags, - hid_t fapl_id, - haddr_t maxaddr) +H5FD_hdfs_open(const char *path, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_t *ret_value = NULL; - H5FD_hdfs_t *file = NULL; - hdfs_t *handle = NULL; - H5FD_hdfs_fapl_t fa; + H5FD_t * ret_value = NULL; + H5FD_hdfs_t * file = NULL; + hdfs_t * handle = NULL; + H5FD_hdfs_fapl_t fa; FUNC_ENTER_NOAPI_NOINIT @@ -1035,41 +971,29 @@ H5FD_hdfs_open( /* Check arguments */ if (!path || !*path) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "invalid file name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") } if (0 == maxaddr || HADDR_UNDEF == maxaddr) { - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, - "bogus maxaddr") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") } if (ADDR_OVERFLOW(maxaddr)) { - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, - "bogus maxaddr") + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") } if (flags != H5F_ACC_RDONLY) { - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, - "only Read-Only access allowed") + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, "only Read-Only access allowed") } if (fapl_id == H5P_DEFAULT || fapl_id == H5P_FILE_ACCESS_DEFAULT) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "fapl cannot be H5P_DEFAULT") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "fapl cannot be H5P_DEFAULT") } if (FAIL == H5Pget_fapl_hdfs(fapl_id, &fa)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "can't get property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get property list") } - handle = H5FD_hdfs_handle_open( - path, - fa.namenode_name, - fa.namenode_port, - fa.user_name, - fa.kerberos_ticket_cache, - fa.stream_buffer_size); + handle = H5FD_hdfs_handle_open(path, fa.namenode_name, fa.namenode_port, fa.user_name, + fa.kerberos_ticket_cache, fa.stream_buffer_size); if (handle == NULL) { - HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, - "could not open") + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "could not open") } HDassert(handle->magic == HDFS_HDFST_MAGIC); @@ -1078,27 +1002,24 @@ H5FD_hdfs_open( */ file = H5FL_CALLOC(H5FD_hdfs_t); if (file == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "unable to allocate file struct") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") } file->hdfs_handle = handle; HDmemcpy(&(file->fa), &fa, sizeof(H5FD_hdfs_fapl_t)); #if HDFS_STATS if (FAIL == hdfs_reset_stats(file)) { - HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, - "unable to reset file statistics") + HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, "unable to reset file statistics") } #endif /* HDFS_STATS */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: if (ret_value == NULL) { if (handle != NULL) { if (FAIL == H5FD_hdfs_handle_close(handle)) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, - "unable to close HDFS file handle") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close HDFS file handle") } } if (file != NULL) { @@ -1113,18 +1034,14 @@ done: #else /* H5_HAVE_LIBHDFS not defined */ static H5FD_t * -H5FD_hdfs_open( - const char H5_ATTR_UNUSED *path, - unsigned H5_ATTR_UNUSED flags, - hid_t H5_ATTR_UNUSED fapl_id, - haddr_t H5_ATTR_UNUSED maxaddr) +H5FD_hdfs_open(const char H5_ATTR_UNUSED *path, unsigned H5_ATTR_UNUSED flags, hid_t H5_ATTR_UNUSED fapl_id, + haddr_t H5_ATTR_UNUSED maxaddr) { - H5FD_t *ret_value = NULL; + H5FD_t *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, - "Illegal open of unsupported virtual file (hdfs)"); + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "Illegal open of unsupported virtual file (hdfs)"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1192,44 +1109,38 @@ done: *---------------------------------------------------------------------------- */ static herr_t -hdfs_fprint_stats( - FILE *stream, - const H5FD_hdfs_t *file) +hdfs_fprint_stats(FILE *stream, const H5FD_hdfs_t *file) { herr_t ret_value = SUCCEED; - parsed_url_t *purl = NULL; + parsed_url_t * purl = NULL; unsigned i = 0; unsigned long count_meta = 0; unsigned long count_raw = 0; double average_meta = 0.0; double average_raw = 0.0; - unsigned long long min_meta = (unsigned long long)HDFS_STATS_STARTING_MIN; - unsigned long long min_raw = (unsigned long long)HDFS_STATS_STARTING_MIN; + unsigned long long min_meta = (unsigned long long)HDFS_STATS_STARTING_MIN; + unsigned long long min_raw = (unsigned long long)HDFS_STATS_STARTING_MIN; unsigned long long max_meta = 0; unsigned long long max_raw = 0; unsigned long long bytes_raw = 0; unsigned long long bytes_meta = 0; double re_dub = 0.0; /* re-usable double variable */ unsigned suffix_i = 0; - const char suffixes[] = { ' ', 'K', 'M', 'G', 'T', 'P' }; + const char suffixes[] = {' ', 'K', 'M', 'G', 'T', 'P'}; FUNC_ENTER_NOAPI_NOINIT if (stream == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file stream cannot be null" ) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file stream cannot be null") } if (file == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file cannot be null") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file cannot be null") } if (file->hdfs_handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "hdfs handle cannot be null") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hdfs handle cannot be null") } if (file->hdfs_handle->magic != HDFS_HDFST_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "hdfs handle has invalid magic") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hdfs handle has invalid magic") } /******************* @@ -1240,18 +1151,26 @@ hdfs_fprint_stats( const hdfs_statsbin *r = &file->raw[i]; const hdfs_statsbin *m = &file->meta[i]; - if (m->min < min_meta) { min_meta = m->min; } - if (r->min < min_raw) { min_raw = r->min; } - if (m->max > max_meta) { max_meta = m->max; } - if (r->max > max_raw) { max_raw = r->max; } + if (m->min < min_meta) { + min_meta = m->min; + } + if (r->min < min_raw) { + min_raw = r->min; + } + if (m->max > max_meta) { + max_meta = m->max; + } + if (r->max > max_raw) { + max_raw = r->max; + } - count_raw += r->count; + count_raw += r->count; count_meta += m->count; - bytes_raw += r->bytes; + bytes_raw += r->bytes; bytes_meta += m->bytes; } - if (count_raw > 0) { - average_raw = (double)bytes_raw / (double)count_raw; + if (count_raw > 0) { + average_raw = (double)bytes_raw / (double)count_raw; } if (count_meta > 0) { average_meta = (double)bytes_meta / (double)count_meta; @@ -1261,10 +1180,10 @@ hdfs_fprint_stats( * PRINT OVERVIEW * ******************/ - HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", - count_raw + count_meta, count_meta, count_raw); - HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", - bytes_raw + bytes_meta, bytes_meta, bytes_raw); + HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", count_raw + count_meta, count_meta, + count_raw); + HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", bytes_raw + bytes_meta, bytes_meta, + bytes_raw); if (count_raw + count_meta == 0) { goto done; @@ -1278,7 +1197,8 @@ hdfs_fprint_stats( HDfprintf(stream, " min "); if (count_meta == 0) { HDfprintf(stream, " 0.000 "); - } else { + } + else { re_dub = (double)min_meta; for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { re_dub /= 1024.0; @@ -1289,7 +1209,8 @@ hdfs_fprint_stats( if (count_raw == 0) { HDfprintf(stream, " 0.000 \n"); - } else { + } + else { re_dub = (double)min_raw; for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) { re_dub /= 1024.0; @@ -1332,10 +1253,8 @@ hdfs_fprint_stats( * PRINT INDIVIDUAL BIN STATS * ******************************/ - HDfprintf(stream, - "BINS # of reads total bytes average size\n"); - HDfprintf(stream, - " up-to meta raw meta raw meta raw\n"); + HDfprintf(stream, "BINS # of reads total bytes average size\n"); + HDfprintf(stream, " up-to meta raw meta raw meta raw\n"); for (i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { const hdfs_statsbin *m; @@ -1359,9 +1278,10 @@ hdfs_fprint_stats( range_end = hdfs_stats_boundaries[i]; if (i == HDFS_STATS_BIN_COUNT) { - range_end = hdfs_stats_boundaries[i-1]; + range_end = hdfs_stats_boundaries[i - 1]; HDfprintf(stream, ">"); - } else { + } + else { HDfprintf(stream, " "); } @@ -1403,16 +1323,14 @@ hdfs_fprint_stats( } HDassert(suffix_i < sizeof(suffixes)); - HDfprintf( - stream, - " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", - re_dub, suffixes[suffix_i], /* bin ceiling */ - m->count, /* metadata reads */ - r->count, /* rawdata reads */ - bm_val, bm_suffix, /* metadata bytes */ - br_val, br_suffix, /* rawdata bytes */ - am_val, am_suffix, /* metadata average */ - ar_val, ar_suffix); /* rawdata average */ + HDfprintf(stream, " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", re_dub, + suffixes[suffix_i], /* bin ceiling */ + m->count, /* metadata reads */ + r->count, /* rawdata reads */ + bm_val, bm_suffix, /* metadata bytes */ + br_val, br_suffix, /* rawdata bytes */ + am_val, am_suffix, /* metadata average */ + ar_val, ar_suffix); /* rawdata average */ fflush(stream); } @@ -1421,7 +1339,6 @@ done: } /* hdfs_fprint_stats */ #endif /* HDFS_STATS */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_close() @@ -1465,16 +1382,14 @@ H5FD_hdfs_close(H5FD_t *_file) */ if (file->hdfs_handle != NULL) { if (FAIL == H5FD_hdfs_handle_close(file->hdfs_handle)) { - HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "unable to close HDFS file handle") + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close HDFS file handle") } } #if HDFS_STATS /* TODO: mechanism to re-target stats printout */ if (FAIL == hdfs_fprint_stats(stdout, file)) { - HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, - "problem while writing file statistics") + HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, "problem while writing file statistics") } #endif /* HDFS_STATS */ @@ -1491,12 +1406,11 @@ done: static herr_t H5FD_hdfs_close(H5FD_t H5_ATTR_UNUSED *_file) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "Illegal close of unsupported Virtual File (hdfs)") + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "Illegal close of unsupported Virtual File (hdfs)") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1504,7 +1418,6 @@ done: #endif /* H5_HAVE_LIBHDFS */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_cmp() @@ -1531,15 +1444,13 @@ done: #ifdef H5_HAVE_LIBHDFS static int -H5FD_hdfs_cmp( - const H5FD_t *_f1, - const H5FD_t *_f2) +H5FD_hdfs_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { int ret_value = 0; const H5FD_hdfs_t *f1 = (const H5FD_hdfs_t *)_f1; const H5FD_hdfs_t *f2 = (const H5FD_hdfs_t *)_f2; - hdfsFileInfo *finfo1 = NULL; - hdfsFileInfo *finfo2 = NULL; + hdfsFileInfo * finfo1 = NULL; + hdfsFileInfo * finfo2 = NULL; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1557,16 +1468,36 @@ H5FD_hdfs_cmp( HDassert(finfo1 != NULL); HDassert(finfo2 != NULL); - if (finfo1->mKind != finfo2->mKind) { HGOTO_DONE(-1); } - if (finfo1->mName != finfo2->mName) { HGOTO_DONE(-1); } - if (finfo1->mLastMod != finfo2->mLastMod) { HGOTO_DONE(-1); } - if (finfo1->mSize != finfo2->mSize) { HGOTO_DONE(-1); } - if (finfo1->mReplication != finfo2->mReplication) { HGOTO_DONE(-1); } - if (finfo1->mBlockSize != finfo2->mBlockSize) { HGOTO_DONE(-1); } - if (strcmp(finfo1->mOwner, finfo2->mOwner)) { HGOTO_DONE(-1); } - if (strcmp(finfo1->mGroup, finfo2->mGroup)) { HGOTO_DONE(-1); } - if (finfo1->mPermissions != finfo2->mPermissions) { HGOTO_DONE(-1); } - if (finfo1->mLastAccess != finfo2->mLastAccess) { HGOTO_DONE(-1); } + if (finfo1->mKind != finfo2->mKind) { + HGOTO_DONE(-1); + } + if (finfo1->mName != finfo2->mName) { + HGOTO_DONE(-1); + } + if (finfo1->mLastMod != finfo2->mLastMod) { + HGOTO_DONE(-1); + } + if (finfo1->mSize != finfo2->mSize) { + HGOTO_DONE(-1); + } + if (finfo1->mReplication != finfo2->mReplication) { + HGOTO_DONE(-1); + } + if (finfo1->mBlockSize != finfo2->mBlockSize) { + HGOTO_DONE(-1); + } + if (strcmp(finfo1->mOwner, finfo2->mOwner)) { + HGOTO_DONE(-1); + } + if (strcmp(finfo1->mGroup, finfo2->mGroup)) { + HGOTO_DONE(-1); + } + if (finfo1->mPermissions != finfo2->mPermissions) { + HGOTO_DONE(-1); + } + if (finfo1->mLastAccess != finfo2->mLastAccess) { + HGOTO_DONE(-1); + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1575,11 +1506,9 @@ done: #else /* H5_HAVE_LIBHDFS not defined */ static int -H5FD_hdfs_cmp( - const H5FD_t H5_ATTR_UNUSED *_f1, - const H5FD_t H5_ATTR_UNUSED *_f2) +H5FD_hdfs_cmp(const H5FD_t H5_ATTR_UNUSED *_f1, const H5FD_t H5_ATTR_UNUSED *_f2) { - int ret_value = 0; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1588,7 +1517,6 @@ H5FD_hdfs_cmp( #endif /* H5_HAVE_LIBHDFS */ - /*------------------------------------------------------------------------- * Function: H5FD_hdfs_query * @@ -1609,9 +1537,7 @@ H5FD_hdfs_cmp( *------------------------------------------------------------------------- */ static herr_t -H5FD_hdfs_query( - const H5FD_t H5_ATTR_UNUSED *_file, - unsigned long *flags) /* out variable */ +H5FD_hdfs_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) /* out variable */ { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1627,7 +1553,6 @@ H5FD_hdfs_query( FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FD_hdfs_query() */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_get_eoa() @@ -1652,9 +1577,7 @@ H5FD_hdfs_query( #ifdef H5_HAVE_LIBHDFS static haddr_t -H5FD_hdfs_get_eoa( - const H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type) +H5FD_hdfs_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_hdfs_t *file = (const H5FD_hdfs_t *)_file; @@ -1670,9 +1593,7 @@ H5FD_hdfs_get_eoa( #else /* H5_HAVE_LIBHDFS not defined */ static haddr_t -H5FD_hdfs_get_eoa( - const H5FD_t H5_ATTR_UNUSED *_file, - H5FD_mem_t H5_ATTR_UNUSED type) +H5FD_hdfs_get_eoa(const H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1685,7 +1606,6 @@ H5FD_hdfs_get_eoa( #endif /* H5_HAVE_LIBHDFS */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_set_eoa() @@ -1708,10 +1628,7 @@ H5FD_hdfs_get_eoa( #ifdef H5_HAVE_LIBHDFS static herr_t -H5FD_hdfs_set_eoa( - H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - haddr_t addr) +H5FD_hdfs_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; @@ -1729,10 +1646,7 @@ H5FD_hdfs_set_eoa( #else /* H5_HAVE_LIBHDFS not defined */ static herr_t -H5FD_hdfs_set_eoa( - H5FD_t H5_ATTR_UNUSED *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - haddr_t H5_ATTR_UNUSED addr) +H5FD_hdfs_set_eoa(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t H5_ATTR_UNUSED addr) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1745,7 +1659,6 @@ H5FD_hdfs_set_eoa( #endif /* H5_HAVE_LIBHDFS */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_get_eof() @@ -1767,9 +1680,7 @@ H5FD_hdfs_set_eoa( #ifdef H5_HAVE_LIBHDFS static haddr_t -H5FD_hdfs_get_eof( - const H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type) +H5FD_hdfs_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_hdfs_t *file = (const H5FD_hdfs_t *)_file; @@ -1782,15 +1693,13 @@ H5FD_hdfs_get_eof( HDassert(file->hdfs_handle != NULL); HDassert(file->hdfs_handle->magic == HDFS_HDFST_MAGIC); - FUNC_LEAVE_NOAPI((size_t) file->hdfs_handle->fileinfo->mSize) + FUNC_LEAVE_NOAPI((size_t)file->hdfs_handle->fileinfo->mSize) } /* end H5FD_hdfs_get_eof() */ #else /* H5_HAVE_LIBHDFS not defined */ static haddr_t -H5FD_hdfs_get_eof( - const H5FD_t H5_ATTR_UNUSED *_file, - H5FD_mem_t H5_ATTR_UNUSED type) +H5FD_hdfs_get_eof(const H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1803,7 +1712,6 @@ H5FD_hdfs_get_eof( #endif /* H5_HAVE_LIBHDFS */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_get_handle() @@ -1826,10 +1734,7 @@ H5FD_hdfs_get_eof( #ifdef H5_HAVE_LIBHDFS static herr_t -H5FD_hdfs_get_handle( - H5FD_t *_file, - hid_t H5_ATTR_UNUSED fapl, - void **file_handle) +H5FD_hdfs_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { herr_t ret_value = SUCCEED; H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; @@ -1841,8 +1746,7 @@ H5FD_hdfs_get_handle( #endif /* HDFS_DEBUG */ if (!file_handle) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file handle not valid") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") } *file_handle = file->hdfs_handle; @@ -1854,12 +1758,10 @@ done: #else /* H5_HAVE_LIBHDFS not defined */ static herr_t -H5FD_hdfs_get_handle( - H5FD_t H5_ATTR_UNUSED *_file, - hid_t H5_ATTR_UNUSED fapl, - void H5_ATTR_UNUSED **file_handle) +H5FD_hdfs_get_handle(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED fapl, + void H5_ATTR_UNUSED **file_handle) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1867,8 +1769,7 @@ H5FD_hdfs_get_handle( HDfprintf(stdout, "H5FD_hdfs_get_handle() called.\n"); #endif /* HDFS_DEBUG */ - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, - "Illegal get-handle of unsupported virtual file (hdfs)"); + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "Illegal get-handle of unsupported virtual file (hdfs)"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1876,7 +1777,6 @@ done: #endif /* H5_HAVE_LIBHDFS */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_read() @@ -1904,13 +1804,10 @@ done: #ifdef H5_HAVE_LIBHDFS static herr_t -H5FD_hdfs_read( - H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, /* start offset */ - size_t size, /* length of read */ - void *buf) /* out */ +H5FD_hdfs_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t addr, /* start offset */ + size_t size, /* length of read */ + void * buf) /* out */ { herr_t ret_value = SUCCEED; H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; @@ -1932,22 +1829,15 @@ H5FD_hdfs_read( HDassert(file->hdfs_handle->magic == HDFS_HDFST_MAGIC); HDassert(buf != NULL); - filesize = (size_t) file->hdfs_handle->fileinfo->mSize; + filesize = (size_t)file->hdfs_handle->fileinfo->mSize; if ((addr > filesize) || ((addr + size) > filesize)) { - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, - "range exceeds file address") + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "range exceeds file address") } - if (FAIL == hdfsPread( - file->hdfs_handle->filesystem, - file->hdfs_handle->file, - (tOffset)addr, - buf, - (tSize)size)) - { - HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, - "unable to execute read") + if (FAIL == + hdfsPread(file->hdfs_handle->filesystem, file->hdfs_handle->file, (tOffset)addr, buf, (tSize)size)) { + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unable to execute read") } #if HDFS_STATS @@ -1959,9 +1849,7 @@ H5FD_hdfs_read( break; } } - bin = (type == H5FD_MEM_DRAW) - ? &file->raw[bin_i] - : &file->meta[bin_i]; + bin = (type == H5FD_MEM_DRAW) ? &file->raw[bin_i] : &file->meta[bin_i]; /* Store collected stats in appropriate bin */ @@ -1970,8 +1858,12 @@ H5FD_hdfs_read( bin->max = size; } else { - if (size < bin->min) { bin->min = size; } - if (size > bin->max) { bin->max = size; } + if (size < bin->min) { + bin->min = size; + } + if (size > bin->max) { + bin->max = size; + } } bin->count++; bin->bytes += (unsigned long long)size; @@ -1985,15 +1877,10 @@ done: #else /* H5_HAVE_LIBHDFS not defined */ static herr_t -H5FD_hdfs_read( - H5FD_t H5_ATTR_UNUSED *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t H5_ATTR_UNUSED addr, - size_t H5_ATTR_UNUSED size, - void H5_ATTR_UNUSED *buf) +H5FD_hdfs_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -2001,8 +1888,7 @@ H5FD_hdfs_read( HDfprintf(stdout, "H5FD_hdfs_read() called.\n"); #endif /* HDFS_DEBUG */ - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, - "Illegal get-handle of unsupported virtual file (hdfs)"); + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "Illegal get-handle of unsupported virtual file (hdfs)"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -2010,7 +1896,6 @@ done: #endif /* H5_HAVE_LIBHDFS */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_write() @@ -2032,13 +1917,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_hdfs_write( - H5FD_t H5_ATTR_UNUSED *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t H5_ATTR_UNUSED addr, - size_t H5_ATTR_UNUSED size, - const void H5_ATTR_UNUSED *buf) +H5FD_hdfs_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) { herr_t ret_value = FAIL; @@ -2048,14 +1928,12 @@ H5FD_hdfs_write( HDfprintf(stdout, "H5FD_hdfs_write() called.\n"); #endif - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, - "cannot write to read-only file.") + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot write to read-only file.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_hdfs_write() */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_truncate() @@ -2079,10 +1957,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_hdfs_truncate( - H5FD_t H5_ATTR_UNUSED *_file, - hid_t H5_ATTR_UNUSED dxpl_id, - hbool_t H5_ATTR_UNUSED closing) +H5FD_hdfs_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { herr_t ret_value = SUCCEED; @@ -2092,14 +1967,12 @@ H5FD_hdfs_truncate( HDfprintf(stdout, "H5FD_hdfs_truncate() called.\n"); #endif - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, - "cannot truncate read-only file.") + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot truncate read-only file.") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_hdfs_truncate() */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_lock() @@ -2124,15 +1997,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_hdfs_lock( - H5FD_t H5_ATTR_UNUSED *_file, - hbool_t H5_ATTR_UNUSED rw) +H5FD_hdfs_lock(H5FD_t H5_ATTR_UNUSED *_file, hbool_t H5_ATTR_UNUSED rw) { FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_hdfs_lock() */ - /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_unlock() @@ -2159,4 +2029,3 @@ H5FD_hdfs_unlock(H5FD_t H5_ATTR_UNUSED *_file) FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_hdfs_unlock() */ - diff --git a/src/H5FDhdfs.h b/src/H5FDhdfs.h index 37252f0..2f1085a 100644 --- a/src/H5FDhdfs.h +++ b/src/H5FDhdfs.h @@ -96,8 +96,8 @@ extern "C" { #define H5FD__CURR_HDFS_FAPL_T_VERSION 1 -#define H5FD__HDFS_NODE_NAME_SPACE 128 -#define H5FD__HDFS_USER_NAME_SPACE 128 +#define H5FD__HDFS_NODE_NAME_SPACE 128 +#define H5FD__HDFS_USER_NAME_SPACE 128 #define H5FD__HDFS_KERB_CACHE_PATH_SPACE 128 typedef struct H5FD_hdfs_fapl_t { @@ -109,7 +109,7 @@ typedef struct H5FD_hdfs_fapl_t { int32_t stream_buffer_size; } H5FD_hdfs_fapl_t; -H5_DLL hid_t H5FD_hdfs_init(void); +H5_DLL hid_t H5FD_hdfs_init(void); H5_DLL herr_t H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out); H5_DLL herr_t H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa); @@ -118,5 +118,3 @@ H5_DLL herr_t H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa); #endif #endif /* ifndef H5FDhdfs_H */ - - diff --git a/src/H5FDint.c b/src/H5FDint.c index 97c81ab..e5e832b 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -24,56 +24,46 @@ /* Module Setup */ /****************/ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ - +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FD_locate_signature * @@ -88,13 +78,13 @@ herr_t H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr) { - haddr_t addr = HADDR_UNDEF; - haddr_t eoa = HADDR_UNDEF; - haddr_t eof = HADDR_UNDEF; - uint8_t buf[H5F_SIGNATURE_LEN]; - unsigned n; - unsigned maxpow; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t addr = HADDR_UNDEF; + haddr_t eoa = HADDR_UNDEF; + haddr_t eof = HADDR_UNDEF; + uint8_t buf[H5F_SIGNATURE_LEN]; + unsigned n; + unsigned maxpow; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -103,33 +93,33 @@ H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr) HDassert(sig_addr); /* Find the least N such that 2^N is larger than the file size */ - eof = H5FD_get_eof(file, H5FD_MEM_SUPER); - eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER); + eof = H5FD_get_eof(file, H5FD_MEM_SUPER); + eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER); addr = MAX(eof, eoa); - if(HADDR_UNDEF == addr) + if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to obtain EOF/EOA value") - for(maxpow = 0; addr; maxpow++) + for (maxpow = 0; addr; maxpow++) addr >>= 1; maxpow = MAX(maxpow, 9); /* Search for the file signature at format address zero followed by * powers of two larger than 9. */ - for(n = 8; n < maxpow; n++) { + for (n = 8; n < maxpow; n++) { addr = (8 == n) ? 0 : (haddr_t)1 << n; - if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) + if (H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to set EOA value for file signature") - if(H5FD_read(file, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) + if (H5FD_read(file, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to read file signature") - if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) + if (!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) break; } /* If the signature was not found then reset the EOA value and return * HADDR_UNDEF. */ - if(n >= maxpow) { - if(H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0) + if (n >= maxpow) { + if (H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to reset EOA value") *sig_addr = HADDR_UNDEF; } @@ -141,7 +131,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_locate_signature() */ - /*------------------------------------------------------------------------- * Function: H5FD_read * @@ -152,10 +141,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) +H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - hid_t dxpl_id = H5I_INVALID_HID; /* DXPL for operation */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t dxpl_id = H5I_INVALID_HID; /* DXPL for operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -173,17 +162,17 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*o * Do not return early for Parallel mode since the I/O could be a * collective transfer. */ - if(0 == size) + if (0 == size) HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ - /* If the file is open for SWMR read access, allow access to data past - * the end of the allocated space (the 'eoa'). This is done because the - * eoa stored in the file's superblock might be out of sync with the - * objects being written within the file by the application performing - * SWMR write operations. - */ -#if 0 /* JRM */ + /* If the file is open for SWMR read access, allow access to data past + * the end of the allocated space (the 'eoa'). This is done because the + * eoa stored in the file's superblock might be out of sync with the + * objects being written within the file by the application performing + * SWMR write operations. + */ +#if 0 /* JRM */ if(!(file->access_flags & H5F_ACC_SWMR_READ)) { haddr_t eoa; @@ -196,14 +185,13 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*o #endif /* JRM */ /* Dispatch to driver */ - if((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) + if ((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_read() */ - /*------------------------------------------------------------------------- * Function: H5FD_write * @@ -216,9 +204,9 @@ done: herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { - hid_t dxpl_id; /* DXPL for operation */ - haddr_t eoa = HADDR_UNDEF; /* EOA for file */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t dxpl_id; /* DXPL for operation */ + haddr_t eoa = HADDR_UNDEF; /* EOA for file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -236,25 +224,25 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void * Do not return early for Parallel mode since the I/O could be a * collective transfer. */ - if(0 == size) + if (0 == size) HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ - if(HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) + if (HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed") - if((addr + file->base_addr + size) > eoa) + if ((addr + file->base_addr + size) > eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size=%llu, eoa=%llu", - (unsigned long long)(addr+ file->base_addr), (unsigned long long)size, (unsigned long long)eoa) + (unsigned long long)(addr + file->base_addr), (unsigned long long)size, + (unsigned long long)eoa) /* Dispatch to driver */ - if((file->cls->write)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) + if ((file->cls->write)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_write() */ - /*------------------------------------------------------------------------- * Function: H5FD_set_eoa * @@ -272,7 +260,7 @@ done: herr_t H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -280,14 +268,13 @@ H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) HDassert(H5F_addr_defined(addr) && addr <= file->maxaddr); /* Dispatch to driver, convert to absolute address */ - if((file->cls->set_eoa)(file, type, addr + file->base_addr) < 0) + if ((file->cls->set_eoa)(file, type, addr + file->base_addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver set_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_eoa * @@ -307,14 +294,14 @@ done: haddr_t H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(file && file->cls); /* Dispatch to driver */ - if(HADDR_UNDEF == (ret_value = (file->cls->get_eoa)(file, type))) + if (HADDR_UNDEF == (ret_value = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") /* Adjust for base address in file (convert to relative address) */ @@ -324,7 +311,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_eof * @@ -344,15 +330,15 @@ done: haddr_t H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(file && file->cls); /* Dispatch to driver */ - if(file->cls->get_eof) { - if(HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type))) + if (file->cls->get_eof) { + if (HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "driver get_eof request failed") } else @@ -365,23 +351,22 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_eof() */ - /*------------------------------------------------------------------------- -* Function: H5FD_driver_query -* -* Purpose: Similar to H5FD_query(), but intended for cases when we don't -* have a file available (e.g. before one is opened). Since we -* can't use the file to get the driver, the driver is passed in -* as a parameter. -* -* Return: SUCCEED/FAIL -* -*------------------------------------------------------------------------- -*/ + * Function: H5FD_driver_query + * + * Purpose: Similar to H5FD_query(), but intended for cases when we don't + * have a file available (e.g. before one is opened). Since we + * can't use the file to get the driver, the driver is passed in + * as a parameter. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ herr_t -H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) +H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -389,7 +374,7 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) HDassert(flags); /* Check for the driver to query and then query it */ - if(driver->query) + if (driver->query) ret_value = (driver->query)(NULL, flags); else *flags = 0; diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 0d37260..fb9ce26 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -26,25 +26,24 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDlog.h" /* Logging file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDlog.h" /* Logging file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_LOG_g = 0; /* Driver-specific file access properties */ typedef struct H5FD_log_fapl_t { - char *logfile; /* Allocated log file name */ + char * logfile; /* Allocated log file name */ unsigned long long flags; /* Flags for logging behavior */ - size_t buf_size; /* Size of buffers for track flavor and number of times each byte is accessed */ + size_t buf_size; /* Size of buffers for track flavor and number of times each byte is accessed */ } H5FD_log_fapl_t; /* Define strings for the different file memory types @@ -52,14 +51,9 @@ typedef struct H5FD_log_fapl_t { * Note that H5FD_MEM_NOLIST is not listed here since it has * a negative value. */ -static const char *flavors[]={ - "H5FD_MEM_DEFAULT", - "H5FD_MEM_SUPER", - "H5FD_MEM_BTREE", - "H5FD_MEM_DRAW", - "H5FD_MEM_GHEAP", - "H5FD_MEM_LHEAP", - "H5FD_MEM_OHDR", +static const char *flavors[] = { + "H5FD_MEM_DEFAULT", "H5FD_MEM_SUPER", "H5FD_MEM_BTREE", "H5FD_MEM_DRAW", + "H5FD_MEM_GHEAP", "H5FD_MEM_LHEAP", "H5FD_MEM_OHDR", }; /* The description of a file belonging to this driver. The `eoa' and `eof' @@ -74,13 +68,13 @@ static const char *flavors[]={ * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_log_t { - H5FD_t pub; /* public stuff, must be first */ - int fd; /* the unix file */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* end of file; current file size */ - haddr_t pos; /* current file I/O position */ - H5FD_file_op_t op; /* last operation */ - char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ + H5FD_t pub; /* public stuff, must be first */ + int fd; /* the unix file */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* end of file; current file size */ + haddr_t pos; /* current file I/O position */ + H5FD_file_op_t op; /* last operation */ + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. Note that Cygwin, MinGW and other Windows POSIX @@ -88,8 +82,8 @@ typedef struct H5FD_log_t { * and will use the 'device + inodes' scheme as opposed to the * Windows code further below. */ - dev_t device; /* file device number */ - ino_t inode; /* file i-node number */ + dev_t device; /* file device number */ + ino_t inode; /* file i-node number */ #else /* Files in windows are uniquely identified by the volume serial * number and the file index (both low and high parts). @@ -105,35 +99,35 @@ typedef struct H5FD_log_t { * * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx */ - DWORD nFileIndexLow; - DWORD nFileIndexHigh; - DWORD dwVolumeSerialNumber; + DWORD nFileIndexLow; + DWORD nFileIndexHigh; + DWORD dwVolumeSerialNumber; - HANDLE hFile; /* Native windows file handle */ -#endif /* H5_HAVE_WIN32_API */ + HANDLE hFile; /* Native windows file handle */ +#endif /* H5_HAVE_WIN32_API */ /* Information from properties set by 'h5repart' tool * * Whether to eliminate the family driver info and convert this file to * a single file */ - hbool_t fam_to_single; + hbool_t fam_to_single; /* Fields for tracking I/O operations */ - unsigned char *nread; /* Number of reads from a file location */ - unsigned char *nwrite; /* Number of write to a file location */ - unsigned char *flavor; /* Flavor of information written to file location */ - unsigned long long total_read_ops; /* Total number of read operations */ - unsigned long long total_write_ops; /* Total number of write operations */ - unsigned long long total_seek_ops; /* Total number of seek operations */ - unsigned long long total_truncate_ops; /* Total number of truncate operations */ - double total_read_time; /* Total time spent in read operations */ - double total_write_time; /* Total time spent in write operations */ - double total_seek_time; /* Total time spent in seek operations */ - double total_truncate_time; /* Total time spent in truncate operations */ - size_t iosize; /* Size of I/O information buffers */ - FILE *logfp; /* Log file pointer */ - H5FD_log_fapl_t fa; /* Driver-specific file access properties */ + unsigned char * nread; /* Number of reads from a file location */ + unsigned char * nwrite; /* Number of write to a file location */ + unsigned char * flavor; /* Flavor of information written to file location */ + unsigned long long total_read_ops; /* Total number of read operations */ + unsigned long long total_write_ops; /* Total number of write operations */ + unsigned long long total_seek_ops; /* Total number of seek operations */ + unsigned long long total_truncate_ops; /* Total number of truncate operations */ + double total_read_time; /* Total time spent in read operations */ + double total_write_time; /* Total time spent in write operations */ + double total_seek_time; /* Total time spent in seek operations */ + double total_truncate_time; /* Total time spent in truncate operations */ + size_t iosize; /* Size of I/O information buffers */ + FILE * logfp; /* Log file pointer */ + H5FD_log_fapl_t fa; /* Driver-specific file access properties */ } H5FD_log_t; /* @@ -151,78 +145,74 @@ typedef struct H5FD_log_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* Prototypes */ -static herr_t H5FD_log_term(void); -static void *H5FD_log_fapl_get(H5FD_t *file); -static void *H5FD_log_fapl_copy(const void *_old_fa); -static herr_t H5FD_log_fapl_free(void *_fa); -static H5FD_t *H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); -static herr_t H5FD_log_close(H5FD_t *_file); -static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_log_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD_log_term(void); +static void * H5FD_log_fapl_get(H5FD_t *file); +static void * H5FD_log_fapl_copy(const void *_old_fa); +static herr_t H5FD_log_fapl_free(void *_fa); +static H5FD_t *H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_log_close(H5FD_t *_file); +static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_log_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -static herr_t H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - hsize_t size); +static herr_t H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); static haddr_t H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_log_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_log_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_log_unlock(H5FD_t *_file); +static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_log_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_log_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_log_g = { - "log", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_log_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_log_fapl_t), /*fapl_size */ - H5FD_log_fapl_get, /*fapl_get */ - H5FD_log_fapl_copy, /*fapl_copy */ - H5FD_log_fapl_free, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_log_open, /*open */ - H5FD_log_close, /*close */ - H5FD_log_cmp, /*cmp */ - H5FD_log_query, /*query */ - NULL, /*get_type_map */ - H5FD_log_alloc, /*alloc */ - H5FD__log_free, /*free */ - H5FD_log_get_eoa, /*get_eoa */ - H5FD_log_set_eoa, /*set_eoa */ - H5FD_log_get_eof, /*get_eof */ - H5FD_log_get_handle, /*get_handle */ - H5FD_log_read, /*read */ - H5FD_log_write, /*write */ - NULL, /*flush */ - H5FD_log_truncate, /*truncate */ - H5FD_log_lock, /*lock */ - H5FD_log_unlock, /*unlock */ - NULL, /*dedup */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + "log", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_log_term, /*terminate */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + sizeof(H5FD_log_fapl_t), /*fapl_size */ + H5FD_log_fapl_get, /*fapl_get */ + H5FD_log_fapl_copy, /*fapl_copy */ + H5FD_log_fapl_free, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_log_open, /*open */ + H5FD_log_close, /*close */ + H5FD_log_cmp, /*cmp */ + H5FD_log_query, /*query */ + NULL, /*get_type_map */ + H5FD_log_alloc, /*alloc */ + H5FD__log_free, /*free */ + H5FD_log_get_eoa, /*get_eoa */ + H5FD_log_set_eoa, /*set_eoa */ + H5FD_log_get_eof, /*get_eof */ + H5FD_log_get_handle, /*get_handle */ + H5FD_log_read, /*read */ + H5FD_log_write, /*write */ + NULL, /*flush */ + H5FD_log_truncate, /*truncate */ + H5FD_log_lock, /*lock */ + H5FD_log_unlock, /*unlock */ + NULL, /*dedup */ + H5FD_FLMAP_DICHOTOMY /*fl_map */ }; /* Declare a free list to manage the H5FD_log_t struct */ H5FL_DEFINE_STATIC(H5FD_log_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -239,14 +229,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_log_init() < 0) + if (H5FD_log_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize log VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_init * @@ -264,11 +253,11 @@ done: hid_t H5FD_log_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if(H5I_VFL != H5I_get_type(H5FD_LOG_g)) + if (H5I_VFL != H5I_get_type(H5FD_LOG_g)) H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -278,7 +267,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_log_term * @@ -302,7 +290,6 @@ H5FD_log_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_log_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_log * @@ -319,15 +306,15 @@ H5FD_log_term(void) herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, size_t buf_size) { - H5FD_log_fapl_t fa; /* File access property list information */ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; /* Return value */ + H5FD_log_fapl_t fa; /* File access property list information */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sULz", fapl_id, logfile, flags, buf_size); /* Check arguments */ - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); @@ -337,21 +324,20 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si * passing it in as a pointer sets off a chain of impossible-to-resolve * const cast warnings. */ - if(logfile != NULL && NULL == (fa.logfile = H5MM_xstrdup(logfile))) + if (logfile != NULL && NULL == (fa.logfile = H5MM_xstrdup(logfile))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to copy log file name") - fa.flags = flags; + fa.flags = flags; fa.buf_size = buf_size; - ret_value = H5P_set_driver(plist, H5FD_LOG, &fa); + ret_value = H5P_set_driver(plist, H5FD_LOG, &fa); done: - if(fa.logfile) + if (fa.logfile) H5MM_free(fa.logfile); FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_log() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_fapl_get * @@ -371,8 +357,8 @@ done: static void * H5FD_log_fapl_get(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; - void *ret_value = NULL; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -382,7 +368,6 @@ H5FD_log_fapl_get(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_fapl_copy * @@ -399,33 +384,33 @@ H5FD_log_fapl_get(H5FD_t *_file) static void * H5FD_log_fapl_copy(const void *_old_fa) { - const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t*)_old_fa; - H5FD_log_fapl_t *new_fa = NULL; /* New FAPL info */ - void *ret_value = NULL; /* Return value */ + const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t *)_old_fa; + H5FD_log_fapl_t * new_fa = NULL; /* New FAPL info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(old_fa); /* Allocate the new FAPL info */ - if(NULL == (new_fa = (H5FD_log_fapl_t *)H5MM_calloc(sizeof(H5FD_log_fapl_t)))) + if (NULL == (new_fa = (H5FD_log_fapl_t *)H5MM_calloc(sizeof(H5FD_log_fapl_t)))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate log file FAPL") /* Copy the general information */ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_log_fapl_t)); /* Deep copy the log file name */ - if(old_fa->logfile != NULL) - if(NULL == (new_fa->logfile = H5MM_strdup(old_fa->logfile))) + if (old_fa->logfile != NULL) + if (NULL == (new_fa->logfile = H5MM_strdup(old_fa->logfile))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate log file name") /* Set return value */ ret_value = new_fa; done: - if(NULL == ret_value) - if(new_fa) { - if(new_fa->logfile) + if (NULL == ret_value) + if (new_fa) { + if (new_fa->logfile) new_fa->logfile = (char *)H5MM_xfree(new_fa->logfile); H5MM_free(new_fa); } /* end if */ @@ -433,7 +418,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_fapl_free * @@ -449,19 +433,18 @@ done: static herr_t H5FD_log_fapl_free(void *_fa) { - H5FD_log_fapl_t *fa = (H5FD_log_fapl_t*)_fa; + H5FD_log_fapl_t *fa = (H5FD_log_fapl_t *)_fa; FUNC_ENTER_NOAPI_NOINIT_NOERR /* Free the fapl information */ - if(fa->logfile) + if (fa->logfile) fa->logfile = (char *)H5MM_xfree(fa->logfile); H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_log_fapl_free() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_open * @@ -480,18 +463,18 @@ H5FD_log_fapl_free(void *_fa) static H5FD_t * H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_log_t *file = NULL; - H5P_genplist_t *plist; /* Property list */ - const H5FD_log_fapl_t *fa; /* File access property list information */ - int fd = -1; /* File descriptor */ - int o_flags; /* Flags for open() call */ + H5FD_log_t * file = NULL; + H5P_genplist_t * plist; /* Property list */ + const H5FD_log_fapl_t *fa; /* File access property list information */ + int fd = -1; /* File descriptor */ + int o_flags; /* Flags for open() call */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - H5_timer_t open_timer; /* Timer for open() call */ - H5_timer_t stat_timer; /* Timer for stat() call */ - h5_stat_t sb; - H5FD_t *ret_value = NULL; /* Return value */ + H5_timer_t open_timer; /* Timer for open() call */ + H5_timer_t stat_timer; /* Timer for stat() call */ + h5_stat_t sb; + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -499,81 +482,84 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if(H5F_ACC_TRUNC & flags) + if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if(H5F_ACC_CREAT & flags) + if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if(H5F_ACC_EXCL & flags) + if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; /* Get the driver specific information */ - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (const H5FD_log_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_log_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Start timer for open() call */ - if(fa->flags & H5FD_LOG_TIME_OPEN) { + if (fa->flags & H5FD_LOG_TIME_OPEN) { H5_timer_init(&open_timer); H5_timer_start(&open_timer); } /* end if */ /* Open the file */ - if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { int myerrno = errno; - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); + HGOTO_ERROR( + H5E_FILE, H5E_CANTOPENFILE, NULL, + "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", + name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); } /* end if */ /* Stop timer for open() call */ - if(fa->flags & H5FD_LOG_TIME_OPEN) + if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_stop(&open_timer); /* Start timer for stat() call */ - if(fa->flags & H5FD_LOG_TIME_STAT) { + if (fa->flags & H5FD_LOG_TIME_STAT) { H5_timer_init(&stat_timer); H5_timer_start(&stat_timer); } /* end if */ /* Get the file stats */ - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Stop timer for stat() call */ - if(fa->flags & H5FD_LOG_TIME_STAT) + if (fa->flags & H5FD_LOG_TIME_STAT) H5_timer_stop(&stat_timer); /* Create the new file struct */ - if(NULL == (file = H5FL_CALLOC(H5FD_log_t))) + if (NULL == (file = H5FL_CALLOC(H5FD_log_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); - if(INVALID_HANDLE_VALUE == file->hFile) + if (INVALID_HANDLE_VALUE == file->hFile) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file handle") - if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) + if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file information") - file->nFileIndexHigh = fileinfo.nFileIndexHigh; - file->nFileIndexLow = fileinfo.nFileIndexLow; + file->nFileIndexHigh = fileinfo.nFileIndexHigh; + file->nFileIndexLow = fileinfo.nFileIndexLow; file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber; -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /* H5_HAVE_WIN32_API */ /* Retain a copy of the name used to open the file, for possible error reporting */ @@ -582,77 +568,76 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* Get the flags for logging */ file->fa.flags = fa->flags; - if(fa->logfile) + if (fa->logfile) file->fa.logfile = H5MM_strdup(fa->logfile); else file->fa.logfile = NULL; file->fa.buf_size = fa->buf_size; /* Check if we are doing any logging at all */ - if(file->fa.flags != 0) { + if (file->fa.flags != 0) { /* Allocate buffers for tracking file accesses and data "flavor" */ file->iosize = fa->buf_size; - if(file->fa.flags & H5FD_LOG_FILE_READ) { + if (file->fa.flags & H5FD_LOG_FILE_READ) { file->nread = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nread); } /* end if */ - if(file->fa.flags & H5FD_LOG_FILE_WRITE) { + if (file->fa.flags & H5FD_LOG_FILE_WRITE) { file->nwrite = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nwrite); } /* end if */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { file->flavor = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->flavor); } /* end if */ /* Set the log file pointer */ - if(fa->logfile) + if (fa->logfile) file->logfp = HDfopen(fa->logfile, "w"); else file->logfp = stderr; /* Log the timer values */ - if(file->fa.flags & H5FD_LOG_TIME_OPEN) { - H5_timevals_t open_times; /* Elapsed time for open() call */ + if (file->fa.flags & H5FD_LOG_TIME_OPEN) { + H5_timevals_t open_times; /* Elapsed time for open() call */ H5_timer_get_times(open_timer, &open_times); HDfprintf(file->logfp, "Open took: (%f s)\n", open_times.elapsed); } /* end if */ - if(file->fa.flags & H5FD_LOG_TIME_STAT) { - H5_timevals_t stat_times; /* Elapsed time for stat() call */ + if (file->fa.flags & H5FD_LOG_TIME_STAT) { + H5_timevals_t stat_times; /* Elapsed time for stat() call */ H5_timer_get_times(stat_timer, &stat_times); HDfprintf(file->logfp, "Stat took: (%f s)\n", stat_times.elapsed); } /* end if */ - } /* end if */ + } /* end if */ /* Check for non-default FAPL */ - if(H5P_FILE_ACCESS_DEFAULT != fapl_id) { + if (H5P_FILE_ACCESS_DEFAULT != fapl_id) { /* This step is for h5repart tool only. If user wants to change file driver from * family to one that uses single files (sec2, etc.) while using h5repart, this * private property should be set so that in the later step, the library can ignore * the family driver information saved in the superblock. */ - if(H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) - if(H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) + if (H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) + if (H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to single") } /* end if */ /* Set return value */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(NULL == ret_value) { - if(fd >= 0) + if (NULL == ret_value) { + if (fd >= 0) HDclose(fd); - if(file) + if (file) file = H5FL_FREE(H5FD_log_t, file); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_open() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_close * @@ -669,9 +654,9 @@ done: static herr_t H5FD_log_close(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; - H5_timer_t close_timer; /* Timer for close() call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + H5_timer_t close_timer; /* Timer for close() call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -679,115 +664,121 @@ H5FD_log_close(H5FD_t *_file) HDassert(file); /* Start timer for close() call */ - if(file->fa.flags & H5FD_LOG_TIME_CLOSE) { + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) { H5_timer_init(&close_timer); H5_timer_start(&close_timer); } /* end if */ /* Close the underlying file */ - if(HDclose(file->fd) < 0) + if (HDclose(file->fd) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* Stop timer for close() call */ - if(file->fa.flags&H5FD_LOG_TIME_CLOSE) + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) H5_timer_stop(&close_timer); /* Dump I/O information */ - if(file->fa.flags != 0) { - haddr_t addr; - haddr_t last_addr; + if (file->fa.flags != 0) { + haddr_t addr; + haddr_t last_addr; unsigned char last_val; - if(file->fa.flags & H5FD_LOG_TIME_CLOSE) { - H5_timevals_t close_times; /* Elapsed time for close() call */ + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) { + H5_timevals_t close_times; /* Elapsed time for close() call */ H5_timer_get_times(close_timer, &close_times); HDfprintf(file->logfp, "Close took: (%f s)\n", close_times.elapsed); } /* end if */ /* Dump the total number of seek/read/write operations */ - if(file->fa.flags & H5FD_LOG_NUM_READ) + if (file->fa.flags & H5FD_LOG_NUM_READ) HDfprintf(file->logfp, "Total number of read operations: %llu\n", file->total_read_ops); - if(file->fa.flags & H5FD_LOG_NUM_WRITE) + if (file->fa.flags & H5FD_LOG_NUM_WRITE) HDfprintf(file->logfp, "Total number of write operations: %llu\n", file->total_write_ops); - if(file->fa.flags & H5FD_LOG_NUM_SEEK) + if (file->fa.flags & H5FD_LOG_NUM_SEEK) HDfprintf(file->logfp, "Total number of seek operations: %llu\n", file->total_seek_ops); - if(file->fa.flags & H5FD_LOG_NUM_TRUNCATE) + if (file->fa.flags & H5FD_LOG_NUM_TRUNCATE) HDfprintf(file->logfp, "Total number of truncate operations: %llu\n", file->total_truncate_ops); /* Dump the total time in seek/read/write */ - if(file->fa.flags & H5FD_LOG_TIME_READ) + if (file->fa.flags & H5FD_LOG_TIME_READ) HDfprintf(file->logfp, "Total time in read operations: %f s\n", file->total_read_time); - if(file->fa.flags & H5FD_LOG_TIME_WRITE) + if (file->fa.flags & H5FD_LOG_TIME_WRITE) HDfprintf(file->logfp, "Total time in write operations: %f s\n", file->total_write_time); - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) HDfprintf(file->logfp, "Total time in seek operations: %f s\n", file->total_seek_time); - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) HDfprintf(file->logfp, "Total time in truncate operations: %f s\n", file->total_truncate_time); /* Dump the write I/O information */ - if(file->fa.flags & H5FD_LOG_FILE_WRITE) { + if (file->fa.flags & H5FD_LOG_FILE_WRITE) { HDfprintf(file->logfp, "Dumping write I/O information:\n"); - last_val = file->nwrite[0]; + last_val = file->nwrite[0]; last_addr = 0; - addr = 1; - while(addr < file->eoa) { - if(file->nwrite[addr] != last_val) { - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) written to %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - last_val = file->nwrite[addr]; + addr = 1; + while (addr < file->eoa) { + if (file->nwrite[addr] != last_val) { + HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) written to %3d times\n", last_addr, + (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); + last_val = file->nwrite[addr]; last_addr = addr; } /* end if */ addr++; } /* end while */ - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) written to %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); + HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) written to %3d times\n", last_addr, + (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); } /* end if */ /* Dump the read I/O information */ - if(file->fa.flags & H5FD_LOG_FILE_READ) { + if (file->fa.flags & H5FD_LOG_FILE_READ) { HDfprintf(file->logfp, "Dumping read I/O information:\n"); - last_val = file->nread[0]; + last_val = file->nread[0]; last_addr = 0; - addr = 1; - while(addr < file->eoa) { - if(file->nread[addr] != last_val) { - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) read from %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - last_val = file->nread[addr]; + addr = 1; + while (addr < file->eoa) { + if (file->nread[addr] != last_val) { + HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) read from %3d times\n", last_addr, + (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); + last_val = file->nread[addr]; last_addr = addr; } /* end if */ addr++; } /* end while */ - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) read from %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); + HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) read from %3d times\n", last_addr, + (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); } /* end if */ /* Dump the I/O flavor information */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDfprintf(file->logfp, "Dumping I/O flavor information:\n"); - last_val = file->flavor[0]; + last_val = file->flavor[0]; last_addr = 0; - addr = 1; - while(addr < file->eoa) { - if(file->flavor[addr] != last_val) { - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) flavor is %s\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); - last_val = file->flavor[addr]; + addr = 1; + while (addr < file->eoa) { + if (file->flavor[addr] != last_val) { + HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) flavor is %s\n", last_addr, + (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); + last_val = file->flavor[addr]; last_addr = addr; } /* end if */ addr++; } /* end while */ - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) flavor is %s\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); + HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) flavor is %s\n", last_addr, (addr - 1), + (unsigned long)(addr - last_addr), flavors[last_val]); } /* end if */ /* Free the logging information */ - if(file->fa.flags & H5FD_LOG_FILE_WRITE) + if (file->fa.flags & H5FD_LOG_FILE_WRITE) file->nwrite = (unsigned char *)H5MM_xfree(file->nwrite); - if(file->fa.flags & H5FD_LOG_FILE_READ) + if (file->fa.flags & H5FD_LOG_FILE_READ) file->nread = (unsigned char *)H5MM_xfree(file->nread); - if(file->fa.flags & H5FD_LOG_FLAVOR) + if (file->fa.flags & H5FD_LOG_FLAVOR) file->flavor = (unsigned char *)H5MM_xfree(file->flavor); - if(file->logfp != stderr) + if (file->logfp != stderr) HDfclose(file->logfp); } /* end if */ - if(file->fa.logfile) + if (file->fa.logfile) file->fa.logfile = (char *)H5MM_xfree(file->fa.logfile); /* Release the file info */ @@ -797,7 +788,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_close() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_cmp * @@ -816,36 +806,48 @@ done: static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; - const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; - int ret_value = 0; + const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; + const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR #ifdef H5_HAVE_WIN32_API - if(f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) HGOTO_DONE(-1) - if(f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) HGOTO_DONE(1) - - if(f1->nFileIndexHigh < f2->nFileIndexHigh) HGOTO_DONE(-1) - if(f1->nFileIndexHigh > f2->nFileIndexHigh) HGOTO_DONE(1) - - if(f1->nFileIndexLow < f2->nFileIndexLow) HGOTO_DONE(-1) - if(f1->nFileIndexLow > f2->nFileIndexLow) HGOTO_DONE(1) + if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) + HGOTO_DONE(-1) + if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) + HGOTO_DONE(1) + + if (f1->nFileIndexHigh < f2->nFileIndexHigh) + HGOTO_DONE(-1) + if (f1->nFileIndexHigh > f2->nFileIndexHigh) + HGOTO_DONE(1) + + if (f1->nFileIndexLow < f2->nFileIndexLow) + HGOTO_DONE(-1) + if (f1->nFileIndexLow > f2->nFileIndexLow) + HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if(f1->device < f2->device) HGOTO_DONE(-1) - if(f1->device > f2->device) HGOTO_DONE(1) -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + HGOTO_DONE(-1) + if (f1->device > f2->device) + HGOTO_DONE(1) +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) < 0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) > 0) HGOTO_DONE(1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + HGOTO_DONE(-1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if(f1->inode < f2->inode) HGOTO_DONE(-1) - if(f1->inode > f2->inode) HGOTO_DONE(1) + if (f1->inode < f2->inode) + HGOTO_DONE(-1) + if (f1->inode > f2->inode) + HGOTO_DONE(1) #endif @@ -853,7 +855,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_query * @@ -870,30 +871,32 @@ done: static herr_t H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ - *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ + *flags |= + H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ /* Check for flags that are set by h5repart */ - if(file && file->fam_to_single) - *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ - } /* end if */ + if (file && file->fam_to_single) + *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which + eliminates it) */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_log_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_alloc * @@ -910,9 +913,9 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) static haddr_t H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsize_t size) { - H5FD_log_t *file = (H5FD_log_t *)_file; - haddr_t addr; - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + haddr_t addr; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -923,15 +926,16 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsi file->eoa = addr + size; /* Retain the (first) flavor of the information written to the file */ - if(file->fa.flags != 0) { - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags != 0) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], (int)type, (size_t)size); } /* end if */ - if(file->fa.flags & H5FD_LOG_ALLOC) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", addr, (addr + size) - 1, size, flavors[type]); + if (file->fa.flags & H5FD_LOG_ALLOC) + HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", addr, (addr + size) - 1, size, + flavors[type]); } /* end if */ /* Set return value */ @@ -940,7 +944,6 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsi FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_free * @@ -954,30 +957,29 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsi *------------------------------------------------------------------------- */ static herr_t -H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, hsize_t size) +H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, hsize_t size) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; FUNC_ENTER_STATIC_NOERR - if(file->fa.flags != 0) { + if (file->fa.flags != 0) { /* Reset the flavor of the information in the file */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); } /* end if */ /* Log the file memory freed */ - if(file->fa.flags & H5FD_LOG_FREE) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Freed\n", addr, (addr + size) - 1, size, flavors[type]); + if (file->fa.flags & H5FD_LOG_FREE) + HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Freed\n", addr, (addr + size) - 1, size, + flavors[type]); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_free() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_get_eoa * @@ -996,14 +998,13 @@ H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, static haddr_t H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD_log_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_set_eoa * @@ -1021,50 +1022,51 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(file->fa.flags != 0) { + if (file->fa.flags != 0) { /* Check for increasing file size */ - if(H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { + if (H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { hsize_t size = addr - file->eoa; /* Retain the flavor of the space allocated by the extension */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size); } /* end if */ /* Log the extension like an allocation */ - if(file->fa.flags & H5FD_LOG_ALLOC) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]); + if (file->fa.flags & H5FD_LOG_ALLOC) + HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, + flavors[type]); } /* end if */ /* Check for decreasing file size */ - if(H5F_addr_lt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { + if (H5F_addr_lt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { hsize_t size = file->eoa - addr; /* Reset the flavor of the space freed by the shrink */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDassert((addr + size) < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); } /* end if */ /* Log the shrink like a free */ - if(file->fa.flags & H5FD_LOG_FREE) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Freed\n", file->eoa, addr, size, flavors[type]); + if (file->fa.flags & H5FD_LOG_FREE) + HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Freed\n", file->eoa, addr, size, + flavors[type]); } /* end if */ - } /* end if */ + } /* end if */ file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_log_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_get_eof * @@ -1085,14 +1087,13 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) static haddr_t H5FD_log_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD_log_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_get_handle * @@ -1108,12 +1109,12 @@ H5FD_log_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_log_t *file = (H5FD_log_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_log_t *file = (H5FD_log_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); @@ -1122,7 +1123,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_read * @@ -1140,20 +1140,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) +H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, + void *buf /*out*/) { - H5FD_log_t *file = (H5FD_log_t *)_file; - size_t orig_size = size; /* Save the original size for later */ - haddr_t orig_addr = addr; - H5_timer_t read_timer; /* Timer for read operation */ - H5_timevals_t read_times; /* Elapsed time for read operation */ + H5FD_log_t * file = (H5FD_log_t *)_file; + size_t orig_size = size; /* Save the original size for later */ + haddr_t orig_addr = addr; + H5_timer_t read_timer; /* Timer for read operation */ + H5_timevals_t read_times; /* Elapsed time for read operation */ #ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ +#endif /* H5_HAVE_PREADWRITE */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1161,68 +1161,68 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd HDassert(buf); /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) + if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) /* Log the I/O information about the read */ - if(file->fa.flags != 0) { - size_t tmp_size = size; + if (file->fa.flags != 0) { + size_t tmp_size = size; haddr_t tmp_addr = addr; /* Log information about the number of times these locations are read */ - if(file->fa.flags & H5FD_LOG_FILE_READ) { + if (file->fa.flags & H5FD_LOG_FILE_READ) { HDassert((addr + size) < file->iosize); - while(tmp_size-- > 0) + while (tmp_size-- > 0) file->nread[tmp_addr++]++; } /* end if */ - } /* end if */ + } /* end if */ #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ - if(addr != file->pos || OP_READ != file->op) { + if (addr != file->pos || OP_READ != file->op) { /* Start timer for seek() call */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_init(&seek_timer); H5_timer_start(&seek_timer); } /* end if */ - if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* Stop timer for seek() call */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_stop(&seek_timer); /* Add to the number of seeks, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_SEEK) + if (file->fa.flags & H5FD_LOG_NUM_SEEK) file->total_seek_ops++; /* Add to the total seek time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; } /* end if */ /* Emit log string if we're tracking individual seek events. */ - if(file->fa.flags & H5FD_LOG_LOC_SEEK) { + if (file->fa.flags & H5FD_LOG_LOC_SEEK) { HDfprintf(file->logfp, "Seek: From %10a To %10a", file->pos, addr); /* Add the seek time, if we're tracking that. * Note that the seek time is NOT emitted for when just H5FD_LOG_TIME_SEEK * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); - else - HDfprintf(file->logfp, "\n"); + else + HDfprintf(file->logfp, "\n"); } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PREADWRITE */ + } /* end if */ +#endif /* H5_HAVE_PREADWRITE */ /* Start timer for read operation */ - if(file->fa.flags & H5FD_LOG_TIME_READ) { + if (file->fa.flags & H5FD_LOG_TIME_READ) { H5_timer_init(&read_timer); H5_timer_start(&read_timer); } /* end if */ @@ -1231,14 +1231,14 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd * Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ - while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to read */ - h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ + while (size > 0) { + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -1246,26 +1246,33 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, buf, bytes_in, offset); - if(bytes_read > 0) + if (bytes_read > 0) offset += bytes_read; #else - bytes_read = HDread(file->fd, buf, bytes_in); + bytes_read = HDread(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_read && EINTR == errno); + } while (-1 == bytes_read && EINTR == errno); - if(-1 == bytes_read) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_read) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - if(file->fa.flags & H5FD_LOG_LOC_READ) - HDfprintf(file->logfp, "Error! Reading: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); - - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); + if (file->fa.flags & H5FD_LOG_LOC_READ) + HDfprintf(file->logfp, "Error! Reading: %10a-%10a (%10Zu bytes)\n", orig_addr, + (orig_addr + orig_size) - 1, orig_size); + + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, + "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, " + "bytes actually read = %llu, offset = %llu", + HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_read, (unsigned long long)offset); } /* end if */ - if(0 == bytes_read) { + if (0 == bytes_read) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); break; @@ -1281,34 +1288,38 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd } /* end while */ /* Stop timer for read operation */ - if(file->fa.flags & H5FD_LOG_TIME_READ) + if (file->fa.flags & H5FD_LOG_TIME_READ) H5_timer_stop(&read_timer); /* Add to the number of reads, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_READ) + if (file->fa.flags & H5FD_LOG_NUM_READ) file->total_read_ops++; /* Add to the total read time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_READ) { + if (file->fa.flags & H5FD_LOG_TIME_READ) { H5_timer_get_times(read_timer, &read_times); file->total_read_time += read_times.elapsed; } /* end if */ /* Log information about the read */ - if(file->fa.flags & H5FD_LOG_LOC_READ) { - HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Read", orig_addr, (orig_addr + orig_size) - 1, orig_size, flavors[type]); + if (file->fa.flags & H5FD_LOG_LOC_READ) { + HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Read", orig_addr, (orig_addr + orig_size) - 1, + orig_size, flavors[type]); /* Verify that we are reading in the type of data we allocated in this location */ - if(file->flavor) { - HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[orig_addr] || (H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT); - HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] || (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] == H5FD_MEM_DEFAULT); + if (file->flavor) { + HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[orig_addr] || + (H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT); + HDassert(type == H5FD_MEM_DEFAULT || + type == (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] || + (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] == H5FD_MEM_DEFAULT); } /* end if */ /* Add the read time, if we're tracking that. * Note that the read time is NOT emitted for when just H5FD_LOG_TIME_READ * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_READ) + if (file->fa.flags & H5FD_LOG_TIME_READ) HDfprintf(file->logfp, " (%fs @ %f)\n", read_times.elapsed, read_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); @@ -1316,19 +1327,18 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd /* Update current position */ file->pos = addr; - file->op = OP_READ; + file->op = OP_READ; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_read() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_write * @@ -1344,20 +1354,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) +H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, + const void *buf) { - H5FD_log_t *file = (H5FD_log_t *)_file; - size_t orig_size = size; /* Save the original size for later */ - haddr_t orig_addr = addr; - H5_timer_t write_timer; /* Timer for write operation */ - H5_timevals_t write_times; /* Elapsed time for write operation */ + H5FD_log_t * file = (H5FD_log_t *)_file; + size_t orig_size = size; /* Save the original size for later */ + haddr_t orig_addr = addr; + H5_timer_t write_timer; /* Timer for write operation */ + H5_timevals_t write_times; /* Elapsed time for write operation */ #ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ +#endif /* H5_HAVE_PREADWRITE */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1366,72 +1376,75 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert(buf); /* Verify that we are writing out the type of data we allocated in this location */ - if(file->flavor) { - HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[addr] || (H5FD_mem_t)file->flavor[addr] == H5FD_MEM_DEFAULT); - HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(addr + size) - 1] || (H5FD_mem_t)file->flavor[(addr + size) - 1] == H5FD_MEM_DEFAULT); + if (file->flavor) { + HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[addr] || + (H5FD_mem_t)file->flavor[addr] == H5FD_MEM_DEFAULT); + HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(addr + size) - 1] || + (H5FD_mem_t)file->flavor[(addr + size) - 1] == H5FD_MEM_DEFAULT); } /* end if */ /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", (unsigned long long)addr, (unsigned long long)size) + if (REGION_OVERFLOW(addr, size)) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", + (unsigned long long)addr, (unsigned long long)size) /* Log the I/O information about the write */ - if(file->fa.flags & H5FD_LOG_FILE_WRITE) { - size_t tmp_size = size; + if (file->fa.flags & H5FD_LOG_FILE_WRITE) { + size_t tmp_size = size; haddr_t tmp_addr = addr; /* Log information about the number of times these locations are read */ HDassert((addr + size) < file->iosize); - while(tmp_size-- > 0) + while (tmp_size-- > 0) file->nwrite[tmp_addr++]++; } /* end if */ #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ - if(addr != file->pos || OP_WRITE != file->op) { + if (addr != file->pos || OP_WRITE != file->op) { /* Start timer for seek() call */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_init(&seek_timer); H5_timer_start(&seek_timer); } /* end if */ - if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* Stop timer for seek() call */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_stop(&seek_timer); /* Add to the number of seeks, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_SEEK) + if (file->fa.flags & H5FD_LOG_NUM_SEEK) file->total_seek_ops++; /* Add to the total seek time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; } /* end if */ /* Emit log string if we're tracking individual seek events. */ - if(file->fa.flags & H5FD_LOG_LOC_SEEK) { + if (file->fa.flags & H5FD_LOG_LOC_SEEK) { HDfprintf(file->logfp, "Seek: From %10a To %10a", file->pos, addr); /* Add the seek time, if we're tracking that. * Note that the seek time is NOT emitted for when just H5FD_LOG_TIME_SEEK * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); - else - HDfprintf(file->logfp, "\n"); + else + HDfprintf(file->logfp, "\n"); } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PREADWRITE */ + } /* end if */ +#endif /* H5_HAVE_PREADWRITE */ /* Start timer for write operation */ - if(file->fa.flags&H5FD_LOG_TIME_WRITE) { + if (file->fa.flags & H5FD_LOG_TIME_WRITE) { H5_timer_init(&write_timer); H5_timer_start(&write_timer); } /* end if */ @@ -1440,14 +1453,14 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had * Write the data, being careful of interrupted system calls and partial * results */ - while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ + while (size > 0) { + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -1455,23 +1468,30 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset); - if(bytes_wrote > 0) + if (bytes_wrote > 0) offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_wrote && EINTR == errno); + } while (-1 == bytes_wrote && EINTR == errno); - if(-1 == bytes_wrote) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_wrote) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - if(file->fa.flags & H5FD_LOG_LOC_WRITE) - HDfprintf(file->logfp, "Error! Writing: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); - - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); + if (file->fa.flags & H5FD_LOG_LOC_WRITE) + HDfprintf(file->logfp, "Error! Writing: %10a-%10a (%10Zu bytes)\n", orig_addr, + (orig_addr + orig_size) - 1, orig_size); + + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = " + "%llu, bytes actually written = %llu, offset = %llu", + HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ HDassert(bytes_wrote > 0); @@ -1483,58 +1503,59 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had } /* end while */ /* Stop timer for write operation */ - if(file->fa.flags & H5FD_LOG_TIME_WRITE) + if (file->fa.flags & H5FD_LOG_TIME_WRITE) H5_timer_stop(&write_timer); /* Add to the number of writes, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_WRITE) + if (file->fa.flags & H5FD_LOG_NUM_WRITE) file->total_write_ops++; /* Add to the total write time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_WRITE) { + if (file->fa.flags & H5FD_LOG_TIME_WRITE) { H5_timer_get_times(write_timer, &write_times); file->total_write_time += write_times.elapsed; } /* end if */ /* Log information about the write */ - if(file->fa.flags & H5FD_LOG_LOC_WRITE) { - HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Written", orig_addr, (orig_addr + orig_size) - 1, orig_size, flavors[type]); - - /* Check if this is the first write into a "default" section, grabbed by the metadata agregation algorithm */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { - if((H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT) { + if (file->fa.flags & H5FD_LOG_LOC_WRITE) { + HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Written", orig_addr, (orig_addr + orig_size) - 1, + orig_size, flavors[type]); + + /* Check if this is the first write into a "default" section, grabbed by the metadata agregation + * algorithm */ + if (file->fa.flags & H5FD_LOG_FLAVOR) { + if ((H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT) { HDmemset(&file->flavor[orig_addr], (int)type, orig_size); HDfprintf(file->logfp, " (fresh)"); } /* end if */ - } /* end if */ + } /* end if */ /* Add the write time, if we're tracking that. * Note that the write time is NOT emitted for when just H5FD_LOG_TIME_WRITE * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_WRITE) + if (file->fa.flags & H5FD_LOG_TIME_WRITE) HDfprintf(file->logfp, " (%fs @ %f)\n", write_times.elapsed, write_timer.initial.elapsed); - else - HDfprintf(file->logfp, "\n"); + else + HDfprintf(file->logfp, "\n"); } /* end if */ /* Update current position and eof */ file->pos = addr; - file->op = OP_WRITE; - if(file->pos > file->eof) + file->op = OP_WRITE; + if (file->pos > file->eof) file->eof = file->pos; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_write() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_truncate * @@ -1551,83 +1572,83 @@ done: static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_log_t *file = (H5FD_log_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); /* Extend the file to make sure it's large enough */ - if(!H5F_addr_eq(file->eoa, file->eof)) { - H5_timer_t trunc_timer; /* Timer for truncate operation */ - H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + if (!H5F_addr_eq(file->eoa, file->eof)) { + H5_timer_t trunc_timer; /* Timer for truncate operation */ + H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ /* Start timer for truncate operation */ - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { H5_timer_init(&trunc_timer); H5_timer_start(&trunc_timer); } /* end if */ #ifdef H5_HAVE_WIN32_API -{ - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + { + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() * Only used as an error code here. */ - /* Windows uses this odd QuadPart union for 32/64-bit portability */ - li.QuadPart = (__int64)file->eoa; + /* Windows uses this odd QuadPart union for 32/64-bit portability */ + li.QuadPart = (__int64)file->eoa; - /* Extend the file to make sure it's large enough. - * - * Since INVALID_SET_FILE_POINTER can technically be a valid return value - * from SetFilePointer(), we also need to check GetLastError(). - */ - dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); - if(INVALID_SET_FILE_POINTER == dwPtrLow) { - DWORD dwError; /* DWORD error code from GetLastError() */ + /* Extend the file to make sure it's large enough. + * + * Since INVALID_SET_FILE_POINTER can technically be a valid return value + * from SetFilePointer(), we also need to check GetLastError(). + */ + dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); + if (INVALID_SET_FILE_POINTER == dwPtrLow) { + DWORD dwError; /* DWORD error code from GetLastError() */ - dwError = GetLastError(); - if(dwError != NO_ERROR ) - HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") - } /* end if */ + dwError = GetLastError(); + if (dwError != NO_ERROR) + HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") + } /* end if */ - if(0 == SetEndOfFile(file->hFile)) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -} -#else /* H5_HAVE_WIN32_API */ + if (0 == SetEndOfFile(file->hFile)) + HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") + } +#else /* H5_HAVE_WIN32_API */ /* Truncate/extend the file */ - if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) + if (-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ /* Stop timer for truncate operation */ - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) H5_timer_stop(&trunc_timer); /* Add to the number of truncates, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_TRUNCATE) + if (file->fa.flags & H5FD_LOG_NUM_TRUNCATE) file->total_truncate_ops++; /* Add to the total truncate time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { H5_timer_get_times(trunc_timer, &trunc_times); file->total_truncate_time += trunc_times.elapsed; } /* end if */ /* Emit log string if we're tracking individual truncate events. */ - if(file->fa.flags & H5FD_LOG_TRUNCATE) { + if (file->fa.flags & H5FD_LOG_TRUNCATE) { HDfprintf(file->logfp, "Truncate: To %10a", file->eoa); /* Add the truncate time, if we're tracking that. * Note that the truncate time is NOT emitted for when just H5FD_LOG_TIME_TRUNCATE * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) HDfprintf(file->logfp, " (%fs @ %f)\n", trunc_times.elapsed, trunc_timer.initial.elapsed); - else - HDfprintf(file->logfp, "\n"); + else + HDfprintf(file->logfp, "\n"); } /* end if */ /* Update the eof value */ @@ -1635,14 +1656,13 @@ H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_U /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_lock * @@ -1658,9 +1678,9 @@ done: static herr_t H5FD_log_lock(H5FD_t *_file, hbool_t rw) { - H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ - int lock_flags; /* file locking flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1671,9 +1691,11 @@ H5FD_log_lock(H5FD_t *_file, hbool_t rw) lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { - if(ENOSYS == errno) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + if (HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if (ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, + "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING " + "environment variable to override)") else HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file") } /* end if */ @@ -1682,7 +1704,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_unlock * @@ -1697,16 +1718,18 @@ done: static herr_t H5FD_log_unlock(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) { - if(ENOSYS == errno) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + if (HDflock(file->fd, LOCK_UN) < 0) { + if (ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, + "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING " + "environment variable to override)") else HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file") } /* end if */ @@ -1714,4 +1737,3 @@ H5FD_log_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_unlock() */ - diff --git a/src/H5FDlog.h b/src/H5FDlog.h index a69bb18..42de705 100644 --- a/src/H5FDlog.h +++ b/src/H5FDlog.h @@ -20,48 +20,52 @@ #ifndef H5FDlog_H #define H5FDlog_H -#define H5FD_LOG (H5FD_log_init()) +#define H5FD_LOG (H5FD_log_init()) /* Flags for H5Pset_fapl_log() */ /* Flags for tracking 'meta' operations (truncate) */ -#define H5FD_LOG_TRUNCATE 0x00000001 -#define H5FD_LOG_META_IO (H5FD_LOG_TRUNCATE) +#define H5FD_LOG_TRUNCATE 0x00000001 +#define H5FD_LOG_META_IO (H5FD_LOG_TRUNCATE) /* Flags for tracking where reads/writes/seeks occur */ -#define H5FD_LOG_LOC_READ 0x00000002 -#define H5FD_LOG_LOC_WRITE 0x00000004 -#define H5FD_LOG_LOC_SEEK 0x00000008 -#define H5FD_LOG_LOC_IO (H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE|H5FD_LOG_LOC_SEEK) +#define H5FD_LOG_LOC_READ 0x00000002 +#define H5FD_LOG_LOC_WRITE 0x00000004 +#define H5FD_LOG_LOC_SEEK 0x00000008 +#define H5FD_LOG_LOC_IO (H5FD_LOG_LOC_READ | H5FD_LOG_LOC_WRITE | H5FD_LOG_LOC_SEEK) /* Flags for tracking number of times each byte is read/written */ #define H5FD_LOG_FILE_READ 0x00000010 #define H5FD_LOG_FILE_WRITE 0x00000020 -#define H5FD_LOG_FILE_IO (H5FD_LOG_FILE_READ|H5FD_LOG_FILE_WRITE) +#define H5FD_LOG_FILE_IO (H5FD_LOG_FILE_READ | H5FD_LOG_FILE_WRITE) /* Flag for tracking "flavor" (type) of information stored at each byte */ -#define H5FD_LOG_FLAVOR 0x00000040 +#define H5FD_LOG_FLAVOR 0x00000040 /* Flags for tracking total number of reads/writes/seeks/truncates */ -#define H5FD_LOG_NUM_READ 0x00000080 -#define H5FD_LOG_NUM_WRITE 0x00000100 -#define H5FD_LOG_NUM_SEEK 0x00000200 +#define H5FD_LOG_NUM_READ 0x00000080 +#define H5FD_LOG_NUM_WRITE 0x00000100 +#define H5FD_LOG_NUM_SEEK 0x00000200 #define H5FD_LOG_NUM_TRUNCATE 0x00000400 -#define H5FD_LOG_NUM_IO (H5FD_LOG_NUM_READ|H5FD_LOG_NUM_WRITE|H5FD_LOG_NUM_SEEK|H5FD_LOG_NUM_TRUNCATE) +#define H5FD_LOG_NUM_IO (H5FD_LOG_NUM_READ | H5FD_LOG_NUM_WRITE | H5FD_LOG_NUM_SEEK | H5FD_LOG_NUM_TRUNCATE) /* Flags for tracking time spent in open/stat/read/write/seek/truncate/close */ -#define H5FD_LOG_TIME_OPEN 0x00000800 -#define H5FD_LOG_TIME_STAT 0x00001000 -#define H5FD_LOG_TIME_READ 0x00002000 -#define H5FD_LOG_TIME_WRITE 0x00004000 -#define H5FD_LOG_TIME_SEEK 0x00008000 +#define H5FD_LOG_TIME_OPEN 0x00000800 +#define H5FD_LOG_TIME_STAT 0x00001000 +#define H5FD_LOG_TIME_READ 0x00002000 +#define H5FD_LOG_TIME_WRITE 0x00004000 +#define H5FD_LOG_TIME_SEEK 0x00008000 #define H5FD_LOG_TIME_TRUNCATE 0x00010000 -#define H5FD_LOG_TIME_CLOSE 0x00020000 -#define H5FD_LOG_TIME_IO (H5FD_LOG_TIME_OPEN|H5FD_LOG_TIME_STAT|H5FD_LOG_TIME_READ|H5FD_LOG_TIME_WRITE|H5FD_LOG_TIME_SEEK|H5FD_LOG_TIME_TRUNCATE|H5FD_LOG_TIME_CLOSE) +#define H5FD_LOG_TIME_CLOSE 0x00020000 +#define H5FD_LOG_TIME_IO \ + (H5FD_LOG_TIME_OPEN | H5FD_LOG_TIME_STAT | H5FD_LOG_TIME_READ | H5FD_LOG_TIME_WRITE | \ + H5FD_LOG_TIME_SEEK | H5FD_LOG_TIME_TRUNCATE | H5FD_LOG_TIME_CLOSE) /* Flags for tracking allocation/release of space in file */ -#define H5FD_LOG_ALLOC 0x00040000 -#define H5FD_LOG_FREE 0x00080000 -#define H5FD_LOG_ALL (H5FD_LOG_FREE|H5FD_LOG_ALLOC|H5FD_LOG_TIME_IO|H5FD_LOG_NUM_IO|H5FD_LOG_FLAVOR|H5FD_LOG_FILE_IO|H5FD_LOG_LOC_IO|H5FD_LOG_META_IO) +#define H5FD_LOG_ALLOC 0x00040000 +#define H5FD_LOG_FREE 0x00080000 +#define H5FD_LOG_ALL \ + (H5FD_LOG_FREE | H5FD_LOG_ALLOC | H5FD_LOG_TIME_IO | H5FD_LOG_NUM_IO | H5FD_LOG_FLAVOR | \ + H5FD_LOG_FILE_IO | H5FD_LOG_LOC_IO | H5FD_LOG_META_IO) #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_log_init(void); +H5_DLL hid_t H5FD_log_init(void); H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, size_t buf_size); #ifdef __cplusplus @@ -69,4 +73,3 @@ H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long #endif #endif - diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index 9f47806..91b5a12 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -17,18 +17,18 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_MIRROR_VFD -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmirror.h" /* "Mirror" definitions */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmirror.h" /* "Mirror" definitions */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_MIRROR_g = 0; @@ -59,152 +59,144 @@ typedef struct H5FD_mirror_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) #ifndef BSWAP_64 -#define BSWAP_64(X) \ - (uint64_t)( (((X) & 0x00000000000000FF) << 56) \ - | (((X) & 0x000000000000FF00) << 40) \ - | (((X) & 0x0000000000FF0000) << 24) \ - | (((X) & 0x00000000FF000000) << 8) \ - | (((X) & 0x000000FF00000000) >> 8) \ - | (((X) & 0x0000FF0000000000) >> 24) \ - | (((X) & 0x00FF000000000000) >> 40) \ - | (((X) & 0xFF00000000000000) >> 56)) +#define BSWAP_64(X) \ + (uint64_t)((((X)&0x00000000000000FF) << 56) | (((X)&0x000000000000FF00) << 40) | \ + (((X)&0x0000000000FF0000) << 24) | (((X)&0x00000000FF000000) << 8) | \ + (((X)&0x000000FF00000000) >> 8) | (((X)&0x0000FF0000000000) >> 24) | \ + (((X)&0x00FF000000000000) >> 40) | (((X)&0xFF00000000000000) >> 56)) #endif /* BSWAP_64 */ /* Debugging flabs for verbose tracing -- nonzero to enable */ -#define MIRROR_DEBUG_OP_CALLS 0 +#define MIRROR_DEBUG_OP_CALLS 0 #define MIRROR_DEBUG_XMIT_BYTES 0 #if MIRROR_DEBUG_XMIT_BYTES -#define LOG_XMIT_BYTES(label, buf, len) do { \ - ssize_t bytes_written = 0; \ - const unsigned char *b = NULL; \ - \ - HDfprintf(stdout, "%s bytes:\n```\n", (label)); \ - \ - /* print whole lines */ \ - while ((len - bytes_written) >= 32) { \ - b = (const unsigned char *)(buf) + bytes_written; \ - HDfprintf(stdout, \ - "%04zX %02X%02X%02X%02X %02X%02X%02X%02X" \ - " %02X%02X%02X%02X %02X%02X%02X%02X" \ - " %02X%02X%02X%02X %02X%02X%02X%02X" \ - " %02X%02X%02X%02X %02X%02X%02X%02X\n", \ - bytes_written, \ - b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], \ - b[8], b[9], b[10],b[11], b[12],b[13],b[14],b[15], \ - b[16],b[17],b[18],b[19], b[20],b[21],b[22],b[23], \ - b[24],b[25],b[26],b[27], b[28],b[29],b[30],b[31]); \ - bytes_written += 32; \ - } \ - \ - /* start partial line */ \ - if (len > bytes_written) { \ - HDfprintf(stdout, "%04zX ", bytes_written); \ - } \ - \ - /* partial line blocks */ \ - while ((len - bytes_written) >= 4) { \ - HDfprintf(stdout, " %02X%02X%02X%02X", \ - (buf)[bytes_written], (buf)[bytes_written+1], \ - (buf)[bytes_written+2], (buf)[bytes_written+3]); \ - bytes_written += 4; \ - } \ - \ - /* block separator before partial block */ \ - if (len > bytes_written) { \ - HDfprintf(stdout, " "); \ - } \ - \ - /* partial block individual bytes */ \ - while (len > bytes_written) { \ - HDfprintf(stdout, "%02X", (buf)[bytes_written++]); \ - } \ - \ - /* end partial line */ \ - HDfprintf(stdout, "\n"); \ - HDfprintf(stdout, "```\n"); \ - HDfflush(stdout); \ -} while (0) +#define LOG_XMIT_BYTES(label, buf, len) \ + do { \ + ssize_t bytes_written = 0; \ + const unsigned char *b = NULL; \ + \ + HDfprintf(stdout, "%s bytes:\n```\n", (label)); \ + \ + /* print whole lines */ \ + while ((len - bytes_written) >= 32) { \ + b = (const unsigned char *)(buf) + bytes_written; \ + HDfprintf(stdout, \ + "%04zX %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X\n", \ + bytes_written, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10], \ + b[11], b[12], b[13], b[14], b[15], b[16], b[17], b[18], b[19], b[20], b[21], b[22], \ + b[23], b[24], b[25], b[26], b[27], b[28], b[29], b[30], b[31]); \ + bytes_written += 32; \ + } \ + \ + /* start partial line */ \ + if (len > bytes_written) { \ + HDfprintf(stdout, "%04zX ", bytes_written); \ + } \ + \ + /* partial line blocks */ \ + while ((len - bytes_written) >= 4) { \ + HDfprintf(stdout, " %02X%02X%02X%02X", (buf)[bytes_written], (buf)[bytes_written + 1], \ + (buf)[bytes_written + 2], (buf)[bytes_written + 3]); \ + bytes_written += 4; \ + } \ + \ + /* block separator before partial block */ \ + if (len > bytes_written) { \ + HDfprintf(stdout, " "); \ + } \ + \ + /* partial block individual bytes */ \ + while (len > bytes_written) { \ + HDfprintf(stdout, "%02X", (buf)[bytes_written++]); \ + } \ + \ + /* end partial line */ \ + HDfprintf(stdout, "\n"); \ + HDfprintf(stdout, "```\n"); \ + HDfflush(stdout); \ + } while (0) #else #define LOG_XMIT_BYTES(label, buf, len) /* no-op */ -#endif /* MIRROR_DEBUG_XMIT_BYTE */ +#endif /* MIRROR_DEBUG_XMIT_BYTE */ #if MIRROR_DEBUG_OP_CALLS -#define LOG_OP_CALL(name) do { \ - HDprintf("called %s()\n", (name)); \ - fflush(stdout); \ -} while (0) +#define LOG_OP_CALL(name) \ + do { \ + HDprintf("called %s()\n", (name)); \ + fflush(stdout); \ + } while (0) #else #define LOG_OP_CALL(name) /* no-op */ -#endif /* MIRROR_DEBUG_OP_CALLS */ +#endif /* MIRROR_DEBUG_OP_CALLS */ /* Prototypes */ -static herr_t H5FD_mirror_term(void); -static void *H5FD_mirror_fapl_get(H5FD_t *_file); -static void *H5FD_mirror_fapl_copy(const void *_old_fa); -static herr_t H5FD_mirror_fapl_free(void *_fa); +static herr_t H5FD_mirror_term(void); +static void * H5FD_mirror_fapl_get(H5FD_t *_file); +static void * H5FD_mirror_fapl_copy(const void *_old_fa); +static herr_t H5FD_mirror_fapl_free(void *_fa); static haddr_t H5FD_mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_mirror_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static H5FD_t *H5FD_mirror_open(const char *name, unsigned flags, \ - hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_mirror_close(H5FD_t *_file); -static herr_t H5FD_mirror_query(const H5FD_t *_file, unsigned long *flags); -static herr_t H5FD_mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, \ - haddr_t addr, size_t size, const void *buf); -static herr_t H5FD_mirror_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, void *buf); -static herr_t H5FD_mirror_truncate(H5FD_t *_file, hid_t dxpl_id, \ - hbool_t closing); -static herr_t H5FD_mirror_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_mirror_unlock(H5FD_t *_file); +static H5FD_t *H5FD_mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_mirror_close(H5FD_t *_file); +static herr_t H5FD_mirror_query(const H5FD_t *_file, unsigned long *flags); +static herr_t H5FD_mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_mirror_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_mirror_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_mirror_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_mirror_unlock(H5FD_t *_file); static herr_t H5FD__mirror_verify_reply(H5FD_mirror_t *file); static const H5FD_class_t H5FD_mirror_g = { - "mirror", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_mirror_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - H5FD_mirror_fapl_get, /* fapl_get */ - H5FD_mirror_fapl_copy, /* fapl_copy */ - H5FD_mirror_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_mirror_open, /* open */ - H5FD_mirror_close, /* close */ - NULL, /* cmp */ - H5FD_mirror_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD_mirror_get_eoa, /* get_eoa */ - H5FD_mirror_set_eoa, /* set_eoa */ - H5FD_mirror_get_eof, /* get_eof */ - NULL, /* get_handle */ - H5FD_mirror_read, /* read */ - H5FD_mirror_write, /* write */ - NULL, /* flush */ - H5FD_mirror_truncate, /* truncate */ - H5FD_mirror_lock, /* lock */ - H5FD_mirror_unlock, /* unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "mirror", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_mirror_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + H5FD_mirror_fapl_get, /* fapl_get */ + H5FD_mirror_fapl_copy, /* fapl_copy */ + H5FD_mirror_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_mirror_open, /* open */ + H5FD_mirror_close, /* close */ + NULL, /* cmp */ + H5FD_mirror_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_mirror_get_eoa, /* get_eoa */ + H5FD_mirror_set_eoa, /* set_eoa */ + H5FD_mirror_get_eof, /* get_eof */ + NULL, /* get_handle */ + H5FD_mirror_read, /* read */ + H5FD_mirror_write, /* write */ + NULL, /* flush */ + H5FD_mirror_truncate, /* truncate */ + H5FD_mirror_lock, /* lock */ + H5FD_mirror_unlock, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_mirror_t struct */ H5FL_DEFINE_STATIC(H5FD_mirror_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -223,15 +215,13 @@ H5FD__init_package(void) LOG_OP_CALL("H5FD__init_package"); if (H5FD_mirror_init() < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, - "unable to initialize mirror VFD"); + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mirror VFD"); } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /* ------------------------------------------------------------------------- * Function: H5FD_mirror_init * @@ -252,8 +242,7 @@ H5FD_mirror_init(void) LOG_OP_CALL("H5FD_mirror_init"); if (H5I_VFL != H5I_get_type(H5FD_MIRROR_g)) { - H5FD_MIRROR_g = H5FD_register(&H5FD_mirror_g, sizeof(H5FD_class_t), - FALSE); + H5FD_MIRROR_g = H5FD_register(&H5FD_mirror_g, sizeof(H5FD_class_t), FALSE); } ret_value = H5FD_MIRROR_g; @@ -262,7 +251,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_init() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_term * @@ -284,7 +272,6 @@ H5FD_mirror_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_mirror_term() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint16 * @@ -309,7 +296,6 @@ H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *_buf) return 2; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint16() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint32 * @@ -334,8 +320,6 @@ H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *_buf) return 4; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint32() */ - - /* --------------------------------------------------------------------------- * Function: is_host_little_endian * @@ -366,7 +350,6 @@ is_host_little_endian(void) } } /* end is_host_little_endian() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint64 * @@ -398,7 +381,6 @@ H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *_buf) return 8; } /* end H5FD__mirror_xmit_decode_uint64() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint8 * @@ -419,7 +401,6 @@ H5FD__mirror_xmit_decode_uint8(uint8_t *out, const unsigned char *_buf) return 1; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint8() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_encode_uint16 * @@ -443,7 +424,6 @@ H5FD__mirror_xmit_encode_uint16(unsigned char *_dest, uint16_t v) return 2; } /* end H5FD__mirror_xmit_encode_uint16() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_encode_uint32 * @@ -467,7 +447,6 @@ H5FD__mirror_xmit_encode_uint32(unsigned char *_dest, uint32_t v) return 4; } /* end H5FD__mirror_xmit_encode_uint32() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_encode_uint64 * @@ -493,7 +472,6 @@ H5FD__mirror_xmit_encode_uint64(unsigned char *_dest, uint64_t v) return 8; } /* H5FD__mirror_xmit_encode_uint64() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_encode_uint8 * @@ -516,7 +494,6 @@ H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v) return 1; } /* end H5FD__mirror_xmit_encode_uint8() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_header * @@ -537,24 +514,20 @@ H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v) * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, const unsigned char *buf) { size_t n_eaten = 0; LOG_OP_CALL("H5FD_mirror_xmit_decode_header"); HDassert(out && buf); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->magic), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->version), &buf[n_eaten]); - n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->session_token), - &buf[n_eaten]); - n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->xmit_count), - &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->session_token), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->xmit_count), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->op), &buf[n_eaten]); HDassert(n_eaten == H5FD_MIRROR_XMIT_HEADER_SIZE); return n_eaten; } /* end H5FD_mirror_xmit_decode_header() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_lock * @@ -575,8 +548,7 @@ H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, const unsigned char *buf) { size_t n_eaten = 0; LOG_OP_CALL("H5FD_mirror_xmit_decode_lock"); @@ -587,7 +559,6 @@ H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, return n_eaten; } /* end H5FD_mirror_xmit_decode_lock() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_open * @@ -609,8 +580,7 @@ H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, const unsigned char *buf) { size_t n_eaten = 0; LOG_OP_CALL("H5FD_mirror_xmit_decode_open"); @@ -618,17 +588,13 @@ H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->flags), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->maxaddr), &buf[n_eaten]); - n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->size_t_blob), - &buf[n_eaten]); - HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) - == n_eaten); - HDstrncpy(out->filename, (const char *)&buf[n_eaten], - H5FD_MIRROR_XMIT_FILEPATH_MAX-1); - out->filename[H5FD_MIRROR_XMIT_FILEPATH_MAX-1] = 0; /* force final NULL */ + n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->size_t_blob), &buf[n_eaten]); + HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) == n_eaten); + HDstrncpy(out->filename, (const char *)&buf[n_eaten], H5FD_MIRROR_XMIT_FILEPATH_MAX - 1); + out->filename[H5FD_MIRROR_XMIT_FILEPATH_MAX - 1] = 0; /* force final NULL */ return H5FD_MIRROR_XMIT_OPEN_SIZE; } /* end H5FD_mirror_xmit_decode_open() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_reply * @@ -650,23 +616,19 @@ H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, const unsigned char *buf) { size_t n_eaten = 0; LOG_OP_CALL("H5FD_mirror_xmit_decode_reply"); HDassert(out && buf); n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->status), &buf[n_eaten]); - HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) - == n_eaten); - HDstrncpy(out->message, (const char *)&buf[n_eaten], - H5FD_MIRROR_STATUS_MESSAGE_MAX-1); - out->message[H5FD_MIRROR_STATUS_MESSAGE_MAX-1] = 0; /* force NULL term */ + HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) == n_eaten); + HDstrncpy(out->message, (const char *)&buf[n_eaten], H5FD_MIRROR_STATUS_MESSAGE_MAX - 1); + out->message[H5FD_MIRROR_STATUS_MESSAGE_MAX - 1] = 0; /* force NULL term */ return H5FD_MIRROR_XMIT_REPLY_SIZE; } /* end H5FD_mirror_xmit_decode_reply() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_set_eoa * @@ -687,8 +649,7 @@ H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, const unsigned char *buf) { size_t n_eaten = 0; LOG_OP_CALL("H5FD_mirror_xmit_decode_set_eoa"); @@ -700,7 +661,6 @@ H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, return n_eaten; } /* end H5FD_mirror_xmit_decode_set_eoa() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_write * @@ -721,8 +681,7 @@ H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, const unsigned char *buf) { size_t n_eaten = 0; LOG_OP_CALL("H5FD_mirror_xmit_decode_write"); @@ -735,7 +694,6 @@ H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, return n_eaten; } /* end H5FD_mirror_xmit_decode_write() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_header * @@ -751,22 +709,20 @@ H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_header(unsigned char *dest, - const H5FD_mirror_xmit_t *x) +H5FD_mirror_xmit_encode_header(unsigned char *dest, const H5FD_mirror_xmit_t *x) { size_t n_writ = 0; LOG_OP_CALL("H5FD_mirror_xmit_encode_header"); HDassert(dest && x); - n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->magic); - n_writ += H5FD__mirror_xmit_encode_uint8((dest+n_writ), x->version); - n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->session_token); - n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->xmit_count); - n_writ += H5FD__mirror_xmit_encode_uint8((dest+n_writ), x->op); + n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->magic); + n_writ += H5FD__mirror_xmit_encode_uint8((dest + n_writ), x->version); + n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->session_token); + n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->xmit_count); + n_writ += H5FD__mirror_xmit_encode_uint8((dest + n_writ), x->op); HDassert(n_writ == H5FD_MIRROR_XMIT_HEADER_SIZE); return n_writ; } /* end H5FD_mirror_xmit_encode_header() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_lock * @@ -781,20 +737,17 @@ H5FD_mirror_xmit_encode_header(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_lock(unsigned char *dest, - const H5FD_mirror_xmit_lock_t *x) +H5FD_mirror_xmit_encode_lock(unsigned char *dest, const H5FD_mirror_xmit_lock_t *x) { size_t n_writ = 0; LOG_OP_CALL("H5FD_mirror_xmit_encode_lock"); HDassert(dest && x); - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->rw); HDassert(n_writ == H5FD_MIRROR_XMIT_LOCK_SIZE); return n_writ; } /* end H5FD_mirror_xmit_encode_lock() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_open * @@ -810,30 +763,25 @@ H5FD_mirror_xmit_encode_lock(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_open(unsigned char *dest, - const H5FD_mirror_xmit_open_t *x) +H5FD_mirror_xmit_encode_open(unsigned char *dest, const H5FD_mirror_xmit_open_t *x) { size_t n_writ = 0; LOG_OP_CALL("H5FD_mirror_xmit_encode_open"); HDassert(dest && x); /* clear entire structure, but especially its filepath string area */ for (n_writ = 0; n_writ < H5FD_MIRROR_XMIT_OPEN_SIZE; n_writ++) { - *(dest+n_writ) = 0; + *(dest + n_writ) = 0; } n_writ = 0; - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint32(&dest[n_writ], x->flags); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->maxaddr); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->size_t_blob); - HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) - == n_writ); - HDstrncpy((char *)&dest[n_writ], x->filename, - H5FD_MIRROR_XMIT_FILEPATH_MAX); + HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) == n_writ); + HDstrncpy((char *)&dest[n_writ], x->filename, H5FD_MIRROR_XMIT_FILEPATH_MAX); return H5FD_MIRROR_XMIT_OPEN_SIZE; } /* end H5FD_mirror_xmit_encode_open() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_reply * @@ -850,28 +798,23 @@ H5FD_mirror_xmit_encode_open(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_reply(unsigned char *dest, - const H5FD_mirror_xmit_reply_t *x) +H5FD_mirror_xmit_encode_reply(unsigned char *dest, const H5FD_mirror_xmit_reply_t *x) { size_t n_writ = 0; LOG_OP_CALL("H5FD_mirror_xmit_encode_reply"); HDassert(dest && x); /* clear entire structure, but especially its message string area */ for (n_writ = 0; n_writ < H5FD_MIRROR_XMIT_REPLY_SIZE; n_writ++) { - *(dest+n_writ) = 0; + *(dest + n_writ) = 0; } n_writ = 0; - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint32(&dest[n_writ], x->status); - HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) - == n_writ); - HDstrncpy((char *)&dest[n_writ], x->message, - H5FD_MIRROR_STATUS_MESSAGE_MAX); + HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) == n_writ); + HDstrncpy((char *)&dest[n_writ], x->message, H5FD_MIRROR_STATUS_MESSAGE_MAX); return H5FD_MIRROR_XMIT_REPLY_SIZE; } /* end H5FD_mirror_xmit_encode_reply() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_set_eoa * @@ -887,21 +830,18 @@ H5FD_mirror_xmit_encode_reply(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, - const H5FD_mirror_xmit_eoa_t *x) +H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, const H5FD_mirror_xmit_eoa_t *x) { size_t n_writ = 0; LOG_OP_CALL("H5FD_mirror_xmit_encode_set_eoa"); HDassert(dest && x); - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint8(&dest[n_writ], x->type); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->eoa_addr); HDassert(n_writ == H5FD_MIRROR_XMIT_EOA_SIZE); return n_writ; } /* end H5FD_mirror_xmit_encode_set_eoa() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_write * @@ -917,14 +857,12 @@ H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_write(unsigned char *dest, - const H5FD_mirror_xmit_write_t *x) +H5FD_mirror_xmit_encode_write(unsigned char *dest, const H5FD_mirror_xmit_write_t *x) { size_t n_writ = 0; LOG_OP_CALL("H5FD_mirror_xmit_encode_write"); HDassert(dest && x); - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint8(&dest[n_writ], x->type); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->offset); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->size); @@ -932,7 +870,6 @@ H5FD_mirror_xmit_encode_write(unsigned char *dest, return n_writ; } /* end H5FD_mirror_xmit_encode_write() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_close * @@ -948,15 +885,12 @@ H5FD_mirror_xmit_is_close(const H5FD_mirror_xmit_t *xmit) { LOG_OP_CALL("H5FD_mirror_xmit_is_close"); HDassert(xmit); - if ( (TRUE == H5FD_mirror_xmit_is_xmit(xmit)) && - (H5FD_MIRROR_OP_CLOSE == xmit->op) ) - { + if ((TRUE == H5FD_mirror_xmit_is_xmit(xmit)) && (H5FD_MIRROR_OP_CLOSE == xmit->op)) { return TRUE; } return FALSE; } /* end H5FD_mirror_xmit_is_close() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_lock * @@ -972,15 +906,12 @@ H5FD_mirror_xmit_is_lock(const H5FD_mirror_xmit_lock_t *xmit) { LOG_OP_CALL("H5FD_mirror_xmit_is_lock"); HDassert(xmit); - if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && - (H5FD_MIRROR_OP_LOCK == xmit->pub.op) ) - { + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_LOCK == xmit->pub.op)) { return TRUE; } return FALSE; } /* end H5FD_mirror_xmit_is_lock() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_open * @@ -996,15 +927,12 @@ H5FD_mirror_xmit_is_open(const H5FD_mirror_xmit_open_t *xmit) { LOG_OP_CALL("H5FD_mirror_xmit_is_open"); HDassert(xmit); - if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && - (H5FD_MIRROR_OP_OPEN == xmit->pub.op) ) - { + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_OPEN == xmit->pub.op)) { return TRUE; } return FALSE; } /* end H5FD_mirror_xmit_is_open() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_eoa * @@ -1020,15 +948,12 @@ H5FD_mirror_xmit_is_set_eoa(const H5FD_mirror_xmit_eoa_t *xmit) { LOG_OP_CALL("H5FD_mirror_xmit_is_set_eoa"); HDassert(xmit); - if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && - (H5FD_MIRROR_OP_SET_EOA == xmit->pub.op) ) - { + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_SET_EOA == xmit->pub.op)) { return TRUE; } return FALSE; } /* end H5FD_mirror_xmit_is_eoa() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_reply * @@ -1044,15 +969,12 @@ H5FD_mirror_xmit_is_reply(const H5FD_mirror_xmit_reply_t *xmit) { LOG_OP_CALL("H5FD_mirror_xmit_is_reply"); HDassert(xmit); - if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && - (H5FD_MIRROR_OP_REPLY == xmit->pub.op) ) - { + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_REPLY == xmit->pub.op)) { return TRUE; } return FALSE; } /* end H5FD_mirror_xmit_is_reply() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_write * @@ -1068,15 +990,12 @@ H5FD_mirror_xmit_is_write(const H5FD_mirror_xmit_write_t *xmit) { LOG_OP_CALL("H5FD_mirror_xmit_is_write"); HDassert(xmit); - if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && - (H5FD_MIRROR_OP_WRITE == xmit->pub.op) ) - { + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_WRITE == xmit->pub.op)) { return TRUE; } return FALSE; } /* end H5FD_mirror_xmit_is_write() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_xmit * @@ -1092,15 +1011,12 @@ H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit) { LOG_OP_CALL("H5FD_mirror_xmit_is_xmit"); HDassert(xmit); - if ( (H5FD_MIRROR_XMIT_MAGIC != xmit->magic) || - (H5FD_MIRROR_XMIT_CURR_VERSION != xmit->version) ) - { + if ((H5FD_MIRROR_XMIT_MAGIC != xmit->magic) || (H5FD_MIRROR_XMIT_CURR_VERSION != xmit->version)) { return FALSE; } return TRUE; } /* end H5FD_mirror_xmit_is_xmit() */ - /* ---------------------------------------------------------------------------- * Function: H5FD__mirror_verify_reply * @@ -1115,10 +1031,10 @@ H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit) herr_t H5FD__mirror_verify_reply(H5FD_mirror_t *file) { - char xmit_buf[H5FD_MIRROR_XMIT_REPLY_SIZE]; - struct H5FD_mirror_xmit_reply_t reply; - ssize_t read_ret = 0; - herr_t ret_value = SUCCEED; + char xmit_buf[H5FD_MIRROR_XMIT_REPLY_SIZE]; + struct H5FD_mirror_xmit_reply_t reply; + ssize_t read_ret = 0; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT; @@ -1136,9 +1052,8 @@ H5FD__mirror_verify_reply(H5FD_mirror_t *file) LOG_XMIT_BYTES("reply", xmit_buf, read_ret); - if (H5FD_mirror_xmit_decode_reply(&reply, (const unsigned char *)xmit_buf) - != H5FD_MIRROR_XMIT_REPLY_SIZE) - { + if (H5FD_mirror_xmit_decode_reply(&reply, (const unsigned char *)xmit_buf) != + H5FD_MIRROR_XMIT_REPLY_SIZE) { HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unable to decode reply xmit"); } @@ -1155,15 +1070,13 @@ H5FD__mirror_verify_reply(H5FD_mirror_t *file) } if (reply.status != H5FD_MIRROR_STATUS_OK) { - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, - "%s", (const char *)(reply.message)); + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "%s", (const char *)(reply.message)); } done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__mirror_verify_reply() */ - /* ------------------------------------------------------------------------- * Function: H5FD_mirror_fapl_get * @@ -1177,9 +1090,9 @@ done: static void * H5FD_mirror_fapl_get(H5FD_t *_file) { - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + H5FD_mirror_t * file = (H5FD_mirror_t *)_file; H5FD_mirror_fapl_t *fa = NULL; - void *ret_value = NULL; + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -1203,7 +1116,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_fapl_get() */ - /* ------------------------------------------------------------------------- * Function: H5FD_mirror_fapl_copy * @@ -1217,8 +1129,8 @@ static void * H5FD_mirror_fapl_copy(const void *_old_fa) { const H5FD_mirror_fapl_t *old_fa = (const H5FD_mirror_fapl_t *)_old_fa; - H5FD_mirror_fapl_t *new_fa = NULL; - void *ret_value = NULL; + H5FD_mirror_fapl_t * new_fa = NULL; + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -1226,8 +1138,7 @@ H5FD_mirror_fapl_copy(const void *_old_fa) new_fa = (H5FD_mirror_fapl_t *)H5MM_malloc(sizeof(H5FD_mirror_fapl_t)); if (new_fa == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } HDmemcpy(new_fa, old_fa, sizeof(H5FD_mirror_fapl_t)); @@ -1242,7 +1153,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_fapl_free * @@ -1254,7 +1164,7 @@ done: static herr_t H5FD_mirror_fapl_free(void *_fa) { - H5FD_mirror_fapl_t *fa = (H5FD_mirror_fapl_t*)_fa; + H5FD_mirror_fapl_t *fa = (H5FD_mirror_fapl_t *)_fa; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1270,7 +1180,6 @@ H5FD_mirror_fapl_free(void *_fa) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_mirror_fapl_free() */ - /* ------------------------------------------------------------------------- * Function: H5Pget_fapl_mirror * @@ -1284,7 +1193,7 @@ herr_t H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out) { const H5FD_mirror_fapl_t *fa = NULL; - H5P_genplist_t *plist = NULL; + H5P_genplist_t * plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -1298,8 +1207,7 @@ H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out) plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); if (NULL == plist) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); } if (H5P_peek_driver(plist) != H5FD_MIRROR) { @@ -1319,7 +1227,6 @@ done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_fapl_mirror() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_mirror * @@ -1332,8 +1239,8 @@ done: herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) { - H5P_genplist_t *plist = NULL; - herr_t ret_value = FAIL; + H5P_genplist_t *plist = NULL; + herr_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", fapl_id, fa); @@ -1342,8 +1249,7 @@ H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); if (NULL == plist) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); } if (NULL == fa) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null fapl_t pointer"); @@ -1361,7 +1267,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_mirror() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_open * @@ -1377,22 +1282,19 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_mirror_open(const char *name, - unsigned flags, - hid_t fapl_id, - haddr_t maxaddr) +H5FD_mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { #define MIRR_OPEN_MAXBUF 16 /* local symbol to give meaning to magic number */ /* #defined because it is needed at compile time */ /* Large enough to hold a port number string */ - int live_socket = -1; - struct sockaddr_in target_addr; - socklen_t addr_size; - char xmit_buf[H5FD_MIRROR_XMIT_OPEN_SIZE]; - H5FD_mirror_fapl_t fa; - H5FD_mirror_t *file = NULL; - H5FD_mirror_xmit_open_t open_xmit; - H5FD_t *ret_value = NULL; + int live_socket = -1; + struct sockaddr_in target_addr; + socklen_t addr_size; + char xmit_buf[H5FD_MIRROR_XMIT_OPEN_SIZE]; + H5FD_mirror_fapl_t fa; + H5FD_mirror_t * file = NULL; + H5FD_mirror_xmit_open_t open_xmit; + H5FD_t * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -1436,16 +1338,14 @@ H5FD_mirror_open(const char *name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't create socket"); } - target_addr.sin_family = AF_INET; - target_addr.sin_port = HDhtons((uint16_t)fa.handshake_port); + target_addr.sin_family = AF_INET; + target_addr.sin_port = HDhtons((uint16_t)fa.handshake_port); target_addr.sin_addr.s_addr = HDinet_addr(fa.remote_ip); HDmemset(target_addr.sin_zero, '\0', sizeof target_addr.sin_zero); addr_size = sizeof(target_addr); - if (HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "can't connect to remote server"); + if (HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't connect to remote server"); } /* ------------- */ @@ -1454,30 +1354,28 @@ H5FD_mirror_open(const char *name, file = (H5FD_mirror_t *)H5FL_CALLOC(H5FD_mirror_t); if (NULL == file) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "unable to allocate file struct"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct"); } file->sock_fd = live_socket; - file->xmit_i = 0; + file->xmit_i = 0; - file->xmit.magic = H5FD_MIRROR_XMIT_MAGIC; - file->xmit.version = H5FD_MIRROR_XMIT_CURR_VERSION; - file->xmit.xmit_count = file->xmit_i++; + file->xmit.magic = H5FD_MIRROR_XMIT_MAGIC; + file->xmit.version = H5FD_MIRROR_XMIT_CURR_VERSION; + file->xmit.xmit_count = file->xmit_i++; file->xmit.session_token = (uint32_t)(0x01020304 ^ file->sock_fd); /* TODO: hashing? */ /* int --> uint32_t may truncate on some systems... shouldn't matter? */ - file->xmit.op = H5FD_MIRROR_OP_OPEN; - open_xmit.pub = file->xmit; - open_xmit.flags = (uint32_t)flags; - open_xmit.maxaddr = (uint64_t)maxaddr; + file->xmit.op = H5FD_MIRROR_OP_OPEN; + open_xmit.pub = file->xmit; + open_xmit.flags = (uint32_t)flags; + open_xmit.maxaddr = (uint64_t)maxaddr; open_xmit.size_t_blob = (uint64_t)((size_t)(-1)); - HDsnprintf(open_xmit.filename, H5FD_MIRROR_XMIT_FILEPATH_MAX-1, "%s", name); + HDsnprintf(open_xmit.filename, H5FD_MIRROR_XMIT_FILEPATH_MAX - 1, "%s", name); if (H5FD_mirror_xmit_encode_open((unsigned char *)xmit_buf, - (const H5FD_mirror_xmit_open_t *)&open_xmit) - != H5FD_MIRROR_XMIT_OPEN_SIZE) - { + (const H5FD_mirror_xmit_open_t *)&open_xmit) != + H5FD_MIRROR_XMIT_OPEN_SIZE) { HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, NULL, "unable to encode open"); } @@ -1499,15 +1397,13 @@ done: file = H5FL_FREE(H5FD_mirror_t, file); } if (live_socket >= 0 && HDclose(live_socket) < 0) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, - "can't close socket"); + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "can't close socket"); } } FUNC_LEAVE_NOAPI(ret_value) #undef MIRR_OPEN_MAXBUF } /* end H5FD_mirror_open() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_close * @@ -1528,8 +1424,8 @@ H5FD_mirror_close(H5FD_t *_file) { H5FD_mirror_t *file = (H5FD_mirror_t *)_file; unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; - int xmit_encoded = 0; /* monitor point of failure */ - herr_t ret_value = SUCCEED; + int xmit_encoded = 0; /* monitor point of failure */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1540,12 +1436,10 @@ H5FD_mirror_close(H5FD_t *_file) HDassert(file->sock_fd >= 0); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_CLOSE; + file->xmit.op = H5FD_MIRROR_OP_CLOSE; - if (H5FD_mirror_xmit_encode_header(xmit_buf, - (const H5FD_mirror_xmit_t *)&(file->xmit)) - != H5FD_MIRROR_XMIT_HEADER_SIZE) - { + if (H5FD_mirror_xmit_encode_header(xmit_buf, (const H5FD_mirror_xmit_t *)&(file->xmit)) != + H5FD_MIRROR_XMIT_HEADER_SIZE) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to encode close"); } xmit_encoded = 1; @@ -1572,36 +1466,30 @@ done: * any reply at all. */ if (HDwrite(file->sock_fd, "GOODBYE", HDstrlen("GOODBYE")) < 0) { - HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to transmit close"); + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to transmit close"); if (HDclose(file->sock_fd) < 0) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "can't close socket"); + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); } file->sock_fd = -1; /* invalidate for later */ - } /* end if problem writing goodbye; go down hard */ - else - if (HDshutdown(file->sock_fd, SHUT_WR) < 0) { - HDONE_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, - "can't shutdown socket write: %s", + } /* end if problem writing goodbye; go down hard */ + else if (HDshutdown(file->sock_fd, SHUT_WR) < 0) { + HDONE_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't shutdown socket write: %s", HDstrerror(errno)); } /* end else-if problem shutting down socket */ - } /* end if xmit encode failed */ + } /* end if xmit encode failed */ if (file->sock_fd >= 0) { if (HDclose(file->sock_fd) < 0) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "can't close socket"); + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); } } /* end if socket not closed by going down hard */ - } /* end if error */ + } /* end if error */ file = H5FL_FREE(H5FD_mirror_t, file); /* always release resources */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_close() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_query * @@ -1626,20 +1514,14 @@ H5FD_mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) * -- JOS 2020-01-13 */ if (flags) { - *flags = 0 \ - | H5FD_FEAT_AGGREGATE_METADATA \ - | H5FD_FEAT_ACCUMULATE_METADATA \ - | H5FD_FEAT_DATA_SIEVE \ - | H5FD_FEAT_AGGREGATE_SMALLDATA \ - | H5FD_FEAT_POSIX_COMPAT_HANDLE \ - | H5FD_FEAT_SUPPORTS_SWMR_IO \ - | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; + *flags = 0 | H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | H5FD_FEAT_SUPPORTS_SWMR_IO | + H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; } FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5FD_mirror_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_get_eoa * @@ -1666,7 +1548,6 @@ H5FD_mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD_mirror_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_set_eoa * @@ -1680,10 +1561,10 @@ H5FD_mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { - H5FD_mirror_xmit_eoa_t xmit_eoa; - unsigned char xmit_buf[H5FD_MIRROR_XMIT_EOA_SIZE]; - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_mirror_xmit_eoa_t xmit_eoa; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_EOA_SIZE]; + H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1694,24 +1575,21 @@ H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) file->eoa = addr; /* local copy */ file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_SET_EOA; + file->xmit.op = H5FD_MIRROR_OP_SET_EOA; - xmit_eoa.pub = file->xmit; - xmit_eoa.type = (uint8_t)type; + xmit_eoa.pub = file->xmit; + xmit_eoa.type = (uint8_t)type; xmit_eoa.eoa_addr = (uint64_t)addr; - if (H5FD_mirror_xmit_encode_set_eoa(xmit_buf, - (const H5FD_mirror_xmit_eoa_t *)&xmit_eoa) - != H5FD_MIRROR_XMIT_EOA_SIZE) - { + if (H5FD_mirror_xmit_encode_set_eoa(xmit_buf, (const H5FD_mirror_xmit_eoa_t *)&xmit_eoa) != + H5FD_MIRROR_XMIT_EOA_SIZE) { HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode set-eoa"); } LOG_XMIT_BYTES("set-eoa", xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE); if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, - "unable to transmit set-eoa"); + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit set-eoa"); } if (H5FD__mirror_verify_reply(file) == FAIL) { @@ -1722,7 +1600,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_get_eof * @@ -1750,7 +1627,6 @@ H5FD_mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD_mirror_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_read * @@ -1761,12 +1637,8 @@ H5FD_mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_read(H5FD_t H5_ATTR_UNUSED *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED fapl_id, - haddr_t H5_ATTR_UNUSED addr, - size_t H5_ATTR_UNUSED size, - void H5_ATTR_UNUSED *buf) +H5FD_mirror_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf) { herr_t ret_value = FAIL; @@ -1777,7 +1649,6 @@ H5FD_mirror_read(H5FD_t H5_ATTR_UNUSED *_file, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_read() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_write * @@ -1796,17 +1667,13 @@ H5FD_mirror_read(H5FD_t H5_ATTR_UNUSED *_file, *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_write(H5FD_t *_file, - H5FD_mem_t type, - hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, - size_t size, - const void *buf) +H5FD_mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, + const void *buf) { - H5FD_mirror_xmit_write_t xmit_write; - unsigned char xmit_buf[H5FD_MIRROR_XMIT_WRITE_SIZE]; - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_mirror_xmit_write_t xmit_write; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_WRITE_SIZE]; + H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1816,19 +1683,16 @@ H5FD_mirror_write(H5FD_t *_file, HDassert(buf); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_WRITE; + file->xmit.op = H5FD_MIRROR_OP_WRITE; - xmit_write.pub = file->xmit; - xmit_write.size = (uint64_t)size; + xmit_write.pub = file->xmit; + xmit_write.size = (uint64_t)size; xmit_write.offset = (uint64_t)addr; - xmit_write.type = (uint8_t)type; - + xmit_write.type = (uint8_t)type; /* Notify Writer of incoming data to write. */ - if (H5FD_mirror_xmit_encode_write(xmit_buf, - (const H5FD_mirror_xmit_write_t *)&xmit_write) - != H5FD_MIRROR_XMIT_WRITE_SIZE) - { + if (H5FD_mirror_xmit_encode_write(xmit_buf, (const H5FD_mirror_xmit_write_t *)&xmit_write) != + H5FD_MIRROR_XMIT_WRITE_SIZE) { HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode write"); } @@ -1857,7 +1721,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_write() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_truncate * @@ -1868,32 +1731,27 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_mirror_truncate(H5FD_t *_file, - hid_t H5_ATTR_UNUSED dxpl_id, - hbool_t H5_ATTR_UNUSED closing) +H5FD_mirror_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - herr_t ret_value = SUCCEED; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT LOG_OP_CALL("H5FD_mirror_truncate"); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_TRUNCATE; + file->xmit.op = H5FD_MIRROR_OP_TRUNCATE; - if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) - != H5FD_MIRROR_XMIT_HEADER_SIZE) - { + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) { HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode truncate"); } LOG_XMIT_BYTES("truncate", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, - "unable to transmit truncate"); + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit truncate"); } if (H5FD__mirror_verify_reply(file) == FAIL) { @@ -1904,7 +1762,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_lock * @@ -1920,24 +1777,22 @@ static herr_t H5FD_mirror_lock(H5FD_t *_file, hbool_t rw) { H5FD_mirror_xmit_lock_t xmit_lock; - unsigned char xmit_buf[H5FD_MIRROR_XMIT_LOCK_SIZE]; - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - herr_t ret_value = SUCCEED; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_LOCK_SIZE]; + H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT; LOG_OP_CALL("H5FD_mirror_lock"); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_LOCK; + file->xmit.op = H5FD_MIRROR_OP_LOCK; xmit_lock.pub = file->xmit; - xmit_lock.rw = (uint64_t)rw; + xmit_lock.rw = (uint64_t)rw; - if (H5FD_mirror_xmit_encode_lock(xmit_buf, - (const H5FD_mirror_xmit_lock_t *)&xmit_lock) - != H5FD_MIRROR_XMIT_LOCK_SIZE) - { + if (H5FD_mirror_xmit_encode_lock(xmit_buf, (const H5FD_mirror_xmit_lock_t *)&xmit_lock) != + H5FD_MIRROR_XMIT_LOCK_SIZE) { HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode lock"); } @@ -1955,7 +1810,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_mirror_lock */ - /*------------------------------------------------------------------------- * Function: H5FD_mirror_unlock * @@ -1967,20 +1821,18 @@ done: static herr_t H5FD_mirror_unlock(H5FD_t *_file) { - unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - herr_t ret_value = SUCCEED; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT; LOG_OP_CALL("H5FD_mirror_unlock"); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_UNLOCK; + file->xmit.op = H5FD_MIRROR_OP_UNLOCK; - if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) - != H5FD_MIRROR_XMIT_HEADER_SIZE) - { + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) { HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode unlock"); } @@ -1999,4 +1851,3 @@ done: } /* end H5FD_mirror_unlock */ #endif /* H5_HAVE_MIRROR_VFD */ - diff --git a/src/H5FDmirror.h b/src/H5FDmirror.h index fb66b7b..28a501f 100644 --- a/src/H5FDmirror.h +++ b/src/H5FDmirror.h @@ -51,14 +51,14 @@ extern "C" { * IP address string of "Mirror Server" remote host. * --------------------------------------------------------------------------- */ -#define H5FD_MIRROR_FAPL_MAGIC 0xF8DD514C +#define H5FD_MIRROR_FAPL_MAGIC 0xF8DD514C #define H5FD_MIRROR_CURR_FAPL_T_VERSION 1 -#define H5FD_MIRROR_MAX_IP_LEN 32 +#define H5FD_MIRROR_MAX_IP_LEN 32 typedef struct H5FD_mirror_fapl_t { uint32_t magic; uint32_t version; - int handshake_port; - char remote_ip[H5FD_MIRROR_MAX_IP_LEN + 1]; + int handshake_port; + char remote_ip[H5FD_MIRROR_MAX_IP_LEN + 1]; } H5FD_mirror_fapl_t; H5_DLL hid_t H5FD_mirror_init(void); @@ -70,14 +70,13 @@ H5_DLL herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa); * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ - /* The maximum allowed size for a receiving buffer when accepting bytes to * write. Writes larger than this size are performed by multiple accept-write * steps by the Writer. */ #define H5FD_MIRROR_DATA_BUFFER_MAX H5_GB /* 1 Gigabyte */ #define H5FD_MIRROR_XMIT_CURR_VERSION 1 -#define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B +#define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B #define H5FD_MIRROR_OP_OPEN 1 #define H5FD_MIRROR_OP_CLOSE 2 @@ -88,8 +87,8 @@ H5_DLL herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa); #define H5FD_MIRROR_OP_LOCK 7 #define H5FD_MIRROR_OP_UNLOCK 8 -#define H5FD_MIRROR_STATUS_OK 0 -#define H5FD_MIRROR_STATUS_ERROR 1 +#define H5FD_MIRROR_STATUS_OK 0 +#define H5FD_MIRROR_STATUS_ERROR 1 #define H5FD_MIRROR_STATUS_MESSAGE_MAX 256 /* Dedicated error message size */ /* Maximum length of a path/filename string, including the NULL-terminator. @@ -103,19 +102,16 @@ H5_DLL herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa); * must be reflected here. * */ #define H5FD_MIRROR_XMIT_HEADER_SIZE 14 -#define H5FD_MIRROR_XMIT_EOA_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 9) -#define H5FD_MIRROR_XMIT_LOCK_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 8) -#define H5FD_MIRROR_XMIT_OPEN_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 20 + H5FD_MIRROR_XMIT_FILEPATH_MAX) -#define H5FD_MIRROR_XMIT_REPLY_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 4 + H5FD_MIRROR_STATUS_MESSAGE_MAX) -#define H5FD_MIRROR_XMIT_WRITE_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 17) +#define H5FD_MIRROR_XMIT_EOA_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 9) +#define H5FD_MIRROR_XMIT_LOCK_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 8) +#define H5FD_MIRROR_XMIT_OPEN_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 20 + H5FD_MIRROR_XMIT_FILEPATH_MAX) +#define H5FD_MIRROR_XMIT_REPLY_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 4 + H5FD_MIRROR_STATUS_MESSAGE_MAX) +#define H5FD_MIRROR_XMIT_WRITE_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 17) /* Maximum length of any xmit. */ -#define H5FD_MIRROR_XMIT_BUFFER_MAX MAX2( MAX3(H5FD_MIRROR_XMIT_HEADER_SIZE, \ - H5FD_MIRROR_XMIT_EOA_SIZE, \ - H5FD_MIRROR_XMIT_LOCK_SIZE), \ - MAX3(H5FD_MIRROR_XMIT_OPEN_SIZE, \ - H5FD_MIRROR_XMIT_REPLY_SIZE, \ - H5FD_MIRROR_XMIT_WRITE_SIZE) ) \ +#define H5FD_MIRROR_XMIT_BUFFER_MAX \ + MAX2(MAX3(H5FD_MIRROR_XMIT_HEADER_SIZE, H5FD_MIRROR_XMIT_EOA_SIZE, H5FD_MIRROR_XMIT_LOCK_SIZE), \ + MAX3(H5FD_MIRROR_XMIT_OPEN_SIZE, H5FD_MIRROR_XMIT_REPLY_SIZE, H5FD_MIRROR_XMIT_WRITE_SIZE)) /* --------------------------------------------------------------------------- * Structure: H5FD_mirror_xmit_t @@ -307,14 +303,12 @@ typedef struct H5FD_mirror_xmit_reply_t { * --------------------------------------------------------------------------- */ typedef struct H5FD_mirror_xmit_write_t { - H5FD_mirror_xmit_t pub; - uint8_t type; - uint64_t offset; - uint64_t size; + H5FD_mirror_xmit_t pub; + uint8_t type; + uint64_t offset; + uint64_t size; } H5FD_mirror_xmit_write_t; - - /* Encode/decode routines are required to "pack" the xmit data into a known * byte format for transmission over the wire. * @@ -367,5 +361,3 @@ H5_DLL hbool_t H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit); #endif /* H5_HAVE_MIRROR_VFD */ #endif /* H5FDmirror_H */ - - diff --git a/src/H5FDmodule.h b/src/H5FDmodule.h index ea1a9fd..794b175 100644 --- a/src/H5FDmodule.h +++ b/src/H5FDmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5FD_MODULE -#define H5_MY_PKG H5FD -#define H5_MY_PKG_ERR H5E_VFL -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5FD +#define H5_MY_PKG_ERR H5E_VFL +#define H5_MY_PKG_INIT YES #endif /* _H5FDmodule_H */ - diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index b2959a5..0c528df 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -19,18 +19,16 @@ * */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmpi.h" /* Common MPI file driver */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmpi.h" /* Common MPI file driver */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_PARALLEL - /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_rank * @@ -52,24 +50,23 @@ H5FD_mpi_get_rank(const H5FD_t *file) { const H5FD_class_mpi_t *cls; - int ret_value; + int ret_value; FUNC_ENTER_NOAPI(FAIL) HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); HDassert(cls); - HDassert(cls->get_rank); /* All MPI drivers must implement this */ + HDassert(cls->get_rank); /* All MPI drivers must implement this */ /* Dispatch to driver */ - if ((ret_value=(cls->get_rank)(file))<0) + if ((ret_value = (cls->get_rank)(file)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_rank request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_rank() */ - /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_size * @@ -90,24 +87,23 @@ int H5FD_mpi_get_size(const H5FD_t *file) { const H5FD_class_mpi_t *cls; - int ret_value; + int ret_value; FUNC_ENTER_NOAPI(FAIL) HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); HDassert(cls); - HDassert(cls->get_size); /* All MPI drivers must implement this */ + HDassert(cls->get_size); /* All MPI drivers must implement this */ /* Dispatch to driver */ - if ((ret_value=(cls->get_size)(file))<0) + if ((ret_value = (cls->get_size)(file)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_size request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_size() */ - /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_comm * @@ -128,24 +124,23 @@ MPI_Comm H5FD_mpi_get_comm(const H5FD_t *file) { const H5FD_class_mpi_t *cls; - MPI_Comm ret_value; + MPI_Comm ret_value; FUNC_ENTER_NOAPI(MPI_COMM_NULL) HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); HDassert(cls); - HDassert(cls->get_comm); /* All MPI drivers must implement this */ + HDassert(cls->get_comm); /* All MPI drivers must implement this */ /* Dispatch to driver */ - if ((ret_value=(cls->get_comm)(file))==MPI_COMM_NULL) + if ((ret_value = (cls->get_comm)(file)) == MPI_COMM_NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_comm() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_mpi_info * @@ -163,27 +158,26 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_get_mpi_info(H5FD_t *file, void** mpi_info) +H5FD_get_mpi_info(H5FD_t *file, void **mpi_info) { const H5FD_class_mpi_t *cls; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); HDassert(cls); - HDassert(cls->get_mpi_info); /* All MPI drivers must implement this */ + HDassert(cls->get_mpi_info); /* All MPI drivers must implement this */ /* Dispatch to driver */ - if((ret_value = (cls->get_mpi_info)(file, mpi_info)) < 0) + if ((ret_value = (cls->get_mpi_info)(file, mpi_info)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_mpi_info request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_mpi_info() */ - /*------------------------------------------------------------------------- * Function: H5FD_mpi_MPIOff_to_haddr * @@ -209,19 +203,18 @@ done: haddr_t H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off) { - haddr_t ret_value=HADDR_UNDEF; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI_NOINIT_NOERR if (mpi_off != (MPI_Offset)(haddr_t)mpi_off) - ret_value=HADDR_UNDEF; + ret_value = HADDR_UNDEF; else - ret_value=(haddr_t)mpi_off; + ret_value = (haddr_t)mpi_off; FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_mpi_haddr_to_MPIOff * @@ -248,9 +241,9 @@ H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off) *------------------------------------------------------------------------- */ herr_t -H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/) +H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off /*out*/) { - herr_t ret_value=FAIL; + herr_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -260,15 +253,15 @@ H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/) *mpi_off = (MPI_Offset)addr; if (addr != (haddr_t)((MPI_Offset)addr)) - ret_value=FAIL; + ret_value = FAIL; else - ret_value=SUCCEED; + ret_value = SUCCEED; FUNC_LEAVE_NOAPI(ret_value) } #ifdef NOT_YET - + /*------------------------------------------------------------------------- * Function: H5FD_mpio_wait_for_left_neighbor * @@ -298,24 +291,24 @@ H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/) herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - char msgbuf[1]; - MPI_Status rcvstat; - int mpi_code; /* mpi return code */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + char msgbuf[1]; + MPI_Status rcvstat; + int mpi_code; /* mpi return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); /* Portably initialize MPI status variable */ - HDmemset(&rcvstat,0,sizeof(MPI_Status)); + HDmemset(&rcvstat, 0, sizeof(MPI_Status)); /* p0 has no left neighbor; all other procs wait for msg */ if (file->mpi_rank != 0) { - if (MPI_SUCCESS != (mpi_code=MPI_Recv( &msgbuf, 1, MPI_CHAR, - file->mpi_rank-1, MPI_ANY_TAG, file->comm, &rcvstat ))) + if (MPI_SUCCESS != (mpi_code = MPI_Recv(&msgbuf, 1, MPI_CHAR, file->mpi_rank - 1, MPI_ANY_TAG, + file->comm, &rcvstat))) HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mpi_code) } @@ -323,7 +316,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_mpio_signal_right_neighbor * @@ -353,18 +345,19 @@ done: herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *_file) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - char msgbuf[1]; - int mpi_code; /* mpi return code */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + char msgbuf[1]; + int mpi_code; /* mpi return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); - if(file->mpi_rank != (file->mpi_size - 1)) - if(MPI_SUCCESS != (mpi_code=MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR, file->mpi_rank + 1, 0, file->comm))) + if (file->mpi_rank != (file->mpi_size - 1)) + if (MPI_SUCCESS != + (mpi_code = MPI_Send(&msgbuf, 0 /*empty msg*/, MPI_CHAR, file->mpi_rank + 1, 0, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mpi_code) done: @@ -372,4 +365,3 @@ done: } #endif /* NOT_YET */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5FDmpi.h b/src/H5FDmpi.h index 2d62c79..d33105e 100644 --- a/src/H5FDmpi.h +++ b/src/H5FDmpi.h @@ -36,25 +36,24 @@ #define H5D_MULTI_CHUNK_IO_COL_THRESHOLD 60 /* Type of I/O for data transfer properties */ typedef enum H5FD_mpio_xfer_t { - H5FD_MPIO_INDEPENDENT = 0, /*zero is the default*/ + H5FD_MPIO_INDEPENDENT = 0, /*zero is the default*/ H5FD_MPIO_COLLECTIVE } H5FD_mpio_xfer_t; /* Type of chunked dataset I/O */ typedef enum H5FD_mpio_chunk_opt_t { H5FD_MPIO_CHUNK_DEFAULT = 0, - H5FD_MPIO_CHUNK_ONE_IO, /*zero is the default*/ + H5FD_MPIO_CHUNK_ONE_IO, /*zero is the default*/ H5FD_MPIO_CHUNK_MULTI_IO } H5FD_mpio_chunk_opt_t; /* Type of collective I/O */ typedef enum H5FD_mpio_collective_opt_t { H5FD_MPIO_COLLECTIVE_IO = 0, - H5FD_MPIO_INDIVIDUAL_IO /*zero is the default*/ + H5FD_MPIO_INDIVIDUAL_IO /*zero is the default*/ } H5FD_mpio_collective_opt_t; /* Include all the MPI VFL headers */ -#include "H5FDmpio.h" /* MPI I/O file driver */ +#include "H5FDmpio.h" /* MPI I/O file driver */ #endif /* H5FDmpi_H */ - diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 4fce560..b0ba36f 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -21,17 +21,16 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmpi.h" /* MPI-based file drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_PARALLEL @@ -58,82 +57,82 @@ static char H5FD_mpi_native_g[] = "native"; * driver doesn't bother to keep it updated since it's an expensive operation. */ typedef struct H5FD_mpio_t { - H5FD_t pub; /* Public stuff, must be first */ - MPI_File f; /* MPIO file handle */ - MPI_Comm comm; /* MPI Communicator */ - MPI_Info info; /* MPI info object */ - int mpi_rank; /* This process's rank */ - int mpi_size; /* Total number of processes */ - haddr_t eof; /* End-of-file marker */ - haddr_t eoa; /* End-of-address marker */ - haddr_t last_eoa; /* Last known end-of-address marker */ - haddr_t local_eof; /* Local end-of-file address for each process */ + H5FD_t pub; /* Public stuff, must be first */ + MPI_File f; /* MPIO file handle */ + MPI_Comm comm; /* MPI Communicator */ + MPI_Info info; /* MPI info object */ + int mpi_rank; /* This process's rank */ + int mpi_size; /* Total number of processes */ + haddr_t eof; /* End-of-file marker */ + haddr_t eoa; /* End-of-address marker */ + haddr_t last_eoa; /* Last known end-of-address marker */ + haddr_t local_eof; /* Local end-of-file address for each process */ } H5FD_mpio_t; /* Private Prototypes */ /* Callbacks */ -static herr_t H5FD__mpio_term(void); -static H5FD_t *H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); -static herr_t H5FD__mpio_close(H5FD_t *_file); -static herr_t H5FD__mpio_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__mpio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD__mpio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__mpio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static int H5FD__mpio_mpi_rank(const H5FD_t *_file); -static int H5FD__mpio_mpi_size(const H5FD_t *_file); +static herr_t H5FD__mpio_term(void); +static H5FD_t * H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__mpio_close(H5FD_t *_file); +static herr_t H5FD__mpio_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__mpio_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__mpio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__mpio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static int H5FD__mpio_mpi_rank(const H5FD_t *_file); +static int H5FD__mpio_mpi_size(const H5FD_t *_file); static MPI_Comm H5FD__mpio_communicator(const H5FD_t *_file); -static herr_t H5FD__mpio_get_info(H5FD_t *_file, void** mpi_info); +static herr_t H5FD__mpio_get_info(H5FD_t *_file, void **mpi_info); /* The MPIO file driver information */ static const H5FD_class_mpi_t H5FD_mpio_g = { - { /* Start of superclass information */ - "mpio", /*name */ - HADDR_MAX, /*maxaddr */ - H5F_CLOSE_SEMI, /*fc_degree */ - H5FD__mpio_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - 0, /*fapl_size */ - NULL, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD__mpio_open, /*open */ - H5FD__mpio_close, /*close */ - NULL, /*cmp */ - H5FD__mpio_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD__mpio_get_eoa, /*get_eoa */ - H5FD__mpio_set_eoa, /*set_eoa */ - H5FD__mpio_get_eof, /*get_eof */ - H5FD__mpio_get_handle, /*get_handle */ - H5FD__mpio_read, /*read */ - H5FD__mpio_write, /*write */ - H5FD__mpio_flush, /*flush */ - H5FD__mpio_truncate, /*truncate */ - NULL, /*lock */ - NULL, /*unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ - }, /* End of superclass information */ - H5FD__mpio_mpi_rank, /*get_rank */ - H5FD__mpio_mpi_size, /*get_size */ - H5FD__mpio_communicator, /*get_comm */ - H5FD__mpio_get_info /*get_info */ + { + /* Start of superclass information */ + "mpio", /*name */ + HADDR_MAX, /*maxaddr */ + H5F_CLOSE_SEMI, /*fc_degree */ + H5FD__mpio_term, /*terminate */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + 0, /*fapl_size */ + NULL, /*fapl_get */ + NULL, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD__mpio_open, /*open */ + H5FD__mpio_close, /*close */ + NULL, /*cmp */ + H5FD__mpio_query, /*query */ + NULL, /*get_type_map */ + NULL, /*alloc */ + NULL, /*free */ + H5FD__mpio_get_eoa, /*get_eoa */ + H5FD__mpio_set_eoa, /*set_eoa */ + H5FD__mpio_get_eof, /*get_eof */ + H5FD__mpio_get_handle, /*get_handle */ + H5FD__mpio_read, /*read */ + H5FD__mpio_write, /*write */ + H5FD__mpio_flush, /*flush */ + H5FD__mpio_truncate, /*truncate */ + NULL, /*lock */ + NULL, /*unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /*fl_map */ + }, /* End of superclass information */ + H5FD__mpio_mpi_rank, /*get_rank */ + H5FD__mpio_mpi_size, /*get_size */ + H5FD__mpio_communicator, /*get_comm */ + H5FD__mpio_get_info /*get_info */ }; #ifdef H5FDmpio_DEBUG @@ -145,18 +144,17 @@ static const H5FD_class_mpi_t H5FD_mpio_g = { * 't' trace function entry and exit * 'w' show write offset and size */ -static int H5FD_mpio_Debug[256] = - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; +static int H5FD_mpio_Debug[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif - /*-------------------------------------------------------------------------- NAME H5FD__init_package -- Initialize interface-specific information @@ -179,14 +177,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_mpio_init() < 0) + if (H5FD_mpio_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mpio VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_mpio_init * @@ -206,36 +203,36 @@ H5FD_mpio_init(void) { #ifdef H5FDmpio_DEBUG static int H5FD_mpio_Debug_inited = 0; -#endif /* H5FDmpio_DEBUG */ - const char *s; /* String for environment variables */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ +#endif /* H5FDmpio_DEBUG */ + const char *s; /* String for environment variables */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Register the MPI-IO VFD, if it isn't already */ - if(H5I_VFL != H5I_get_type(H5FD_MPIO_g)) + if (H5I_VFL != H5I_get_type(H5FD_MPIO_g)) H5FD_MPIO_g = H5FD_register((const H5FD_class_t *)&H5FD_mpio_g, sizeof(H5FD_class_mpi_t), FALSE); /* Allow MPI buf-and-file-type optimizations? */ s = HDgetenv("HDF5_MPI_OPT_TYPES"); - if(s && HDisdigit(*s)) { - long env_val = HDstrtol(s, NULL, 0); + if (s && HDisdigit(*s)) { + long env_val = HDstrtol(s, NULL, 0); H5FD_mpi_opt_types_g = (0 == env_val) ? FALSE : TRUE; } #ifdef H5FDmpio_DEBUG - if(!H5FD_mpio_Debug_inited) { + if (!H5FD_mpio_Debug_inited) { /* Retrieve MPI-IO debugging environment variable */ s = HDgetenv("H5FD_mpio_Debug"); - if(s) { + if (s) { /* Set debug mask */ - while(*s) { + while (*s) { H5FD_mpio_Debug[(int)*s]++; s++; } /* end while */ - } /* end if */ + } /* end if */ H5FD_mpio_Debug_inited++; - } /* end if */ + } /* end if */ #endif /* H5FDmpio_DEBUG */ /* Set return value */ @@ -245,7 +242,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpio_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__mpio_term * @@ -269,7 +265,6 @@ H5FD__mpio_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__mpio_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_mpio * @@ -304,24 +299,24 @@ H5FD__mpio_term(void) herr_t H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("e", "iMcMi", fapl_id, comm, info); /* Check arguments */ - if(fapl_id == H5P_DEFAULT) + if (fapl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") - if(MPI_COMM_NULL == comm) + if (MPI_COMM_NULL == comm) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "MPI_COMM_NULL is not a valid communicator") /* Set the MPI communicator and info object */ - if(H5P_set(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + if (H5P_set(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI communicator") - if(H5P_set(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) + if (H5P_set(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI info object") /* duplication is done during driver setting. */ @@ -331,7 +326,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Pset_fapl_mpio() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_mpio * @@ -356,51 +350,50 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/) +H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm /*out*/, MPI_Info *info /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, comm, info); /* Set comm and info in case we have problems */ - if(comm) + if (comm) *comm = MPI_COMM_NULL; - if(info) + if (info) *info = MPI_INFO_NULL; /* Check arguments */ - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_MPIO != H5P_peek_driver(plist)) + if (H5FD_MPIO != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "VFL driver is not MPI-I/O") /* Get the MPI communicator and info object */ - if(comm) - if(H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, comm) < 0) + if (comm) + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, comm) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI communicator") - if(info) - if(H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, info) < 0) + if (info) + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI info object") done: /* Clean up anything duplicated on errors. The free calls will set * the output values to MPI_COMM|INFO_NULL. */ - if(ret_value != SUCCEED) { - if(comm) - if(H5_mpi_comm_free(comm) < 0) + if (ret_value != SUCCEED) { + if (comm) + if (H5_mpi_comm_free(comm) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator") - if(info) - if(H5_mpi_info_free(info) < 0) + if (info) + if (H5_mpi_info_free(info) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object") } FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_mpio() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio * @@ -426,29 +419,28 @@ done: herr_t H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDt", dxpl_id, xfer_mode); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") - if(H5FD_MPIO_INDEPENDENT != xfer_mode && H5FD_MPIO_COLLECTIVE != xfer_mode) + if (H5FD_MPIO_INDEPENDENT != xfer_mode && H5FD_MPIO_COLLECTIVE != xfer_mode) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_IO_XFER_MODE_NAME, &xfer_mode) < 0) + if (H5P_set(plist, H5D_XFER_IO_XFER_MODE_NAME, &xfer_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio() */ - /*------------------------------------------------------------------------- * Function: H5Pget_dxpl_mpio * @@ -466,28 +458,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/) +H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", dxpl_id, xfer_mode); /* Check arguments */ - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Get the transfer mode */ - if(xfer_mode) - if(H5P_get(plist, H5D_XFER_IO_XFER_MODE_NAME, xfer_mode) < 0) + if (xfer_mode) + if (H5P_get(plist, H5D_XFER_IO_XFER_MODE_NAME, xfer_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_dxpl_mpio() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio_collective_opt * @@ -509,27 +500,26 @@ done: herr_t H5Pset_dxpl_mpio_collective_opt(hid_t dxpl_id, H5FD_mpio_collective_opt_t opt_mode) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDc", dxpl_id, opt_mode); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &opt_mode) < 0) + if (H5P_set(plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &opt_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio_collective_opt() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio_chunk_opt * @@ -551,27 +541,26 @@ done: herr_t H5Pset_dxpl_mpio_chunk_opt(hid_t dxpl_id, H5FD_mpio_chunk_opt_t opt_mode) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDh", dxpl_id, opt_mode); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &opt_mode) < 0) + if (H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &opt_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio_chunk_opt() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio_chunk_opt_num * @@ -591,27 +580,26 @@ done: herr_t H5Pset_dxpl_mpio_chunk_opt_num(hid_t dxpl_id, unsigned num_chunk_per_proc) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", dxpl_id, num_chunk_per_proc); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &num_chunk_per_proc) < 0) + if (H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &num_chunk_per_proc) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio_chunk_opt_num() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio_chunk_opt_ratio * @@ -634,27 +622,26 @@ done: herr_t H5Pset_dxpl_mpio_chunk_opt_ratio(hid_t dxpl_id, unsigned percent_num_proc_per_chunk) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", dxpl_id, percent_num_proc_per_chunk); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &percent_num_proc_per_chunk) < 0) + if (H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &percent_num_proc_per_chunk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio_chunk_opt_ratio() */ - /*------------------------------------------------------------------------- * Function: H5FD_set_mpio_atomicity * @@ -670,37 +657,36 @@ done: herr_t H5FD_set_mpio_atomicity(H5FD_t *_file, hbool_t flag) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - int mpi_code; /* MPI return code */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + int mpi_code; /* MPI return code */ int temp_flag; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Entering\n", FUNC); #endif - if(FALSE == flag) + if (FALSE == flag) temp_flag = 0; else temp_flag = 1; /* set atomicity value */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_atomicity(file->f, temp_flag))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_atomicity(file->f, temp_flag))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_atomicity", mpi_code) done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_set_mpio_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_mpio_atomicity * @@ -716,37 +702,36 @@ done: herr_t H5FD_get_mpio_atomicity(H5FD_t *_file, hbool_t *flag) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - int mpi_code; /* MPI return code */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + int mpi_code; /* MPI return code */ int temp_flag; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Entering\n", FUNC); #endif /* Get atomicity value */ - if(MPI_SUCCESS != (mpi_code = MPI_File_get_atomicity(file->f, &temp_flag))) + if (MPI_SUCCESS != (mpi_code = MPI_File_get_atomicity(file->f, &temp_flag))) HMPI_GOTO_ERROR(FAIL, "MPI_File_get_atomicity", mpi_code) - if(0 != temp_flag) + if (0 != temp_flag) *flag = TRUE; else *flag = FALSE; done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_mpio_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_open * @@ -766,96 +751,96 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t H5_ATTR_UNUSED maxaddr) +H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR_UNUSED maxaddr) { - H5FD_mpio_t *file = NULL; + H5FD_mpio_t * file = NULL; MPI_File fh; hbool_t file_opened = FALSE; /* Flag to indicate that the file was successfully opened */ int mpi_amode; - int mpi_rank; /* MPI rank of this process */ - int mpi_size; /* Total number of MPI processes */ - int mpi_code; /* MPI return code */ + int mpi_rank; /* MPI rank of this process */ + int mpi_size; /* Total number of MPI processes */ + int mpi_code; /* MPI return code */ MPI_Offset size; - H5P_genplist_t *plist; /* Property list pointer */ - MPI_Comm comm = MPI_COMM_NULL; - MPI_Info info = MPI_INFO_NULL; - H5FD_t *ret_value = NULL; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + MPI_Comm comm = MPI_COMM_NULL; + MPI_Info info = MPI_INFO_NULL; + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering - name = \"%s\", flags = 0x%x, fapl_id = %d, maxaddr = %lu\n", FUNC, name, flags, (int)fapl_id, (unsigned long)maxaddr); + if (H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Entering - name = \"%s\", flags = 0x%x, fapl_id = %d, maxaddr = %lu\n", FUNC, + name, flags, (int)fapl_id, (unsigned long)maxaddr); #endif /* Get a pointer to the fapl */ - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") /* Get the MPI communicator and info object from the property list */ - if(H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get MPI communicator") - if(H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get MPI info object") /* Convert HDF5 flags to MPI-IO flags */ /* Some combinations are illegal; let MPI-IO figure it out */ - mpi_amode = (flags & H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; - if(flags & H5F_ACC_CREAT) + mpi_amode = (flags & H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; + if (flags & H5F_ACC_CREAT) mpi_amode |= MPI_MODE_CREATE; - if(flags & H5F_ACC_EXCL) + if (flags & H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL; #ifdef H5FDmpio_DEBUG /* Check for debug commands in the info parameter */ - if(MPI_INFO_NULL != info) { + if (MPI_INFO_NULL != info) { char debug_str[128]; - int flag; + int flag; MPI_Info_get(info, H5F_MPIO_DEBUG_KEY, sizeof(debug_str) - 1, debug_str, &flag); - if(flag) { + if (flag) { int i; HDfprintf(stdout, "H5FD_mpio debug flags = '%s'\n", debug_str); - for(i = 0; debug_str[i]/*end of string*/ && i < 128/*just in case*/; ++i) + for (i = 0; debug_str[i] /*end of string*/ && i < 128 /*just in case*/; ++i) H5FD_mpio_Debug[(int)debug_str[i]] = 1; } /* end if */ - } /* end if */ + } /* end if */ #endif - if(MPI_SUCCESS != (mpi_code = MPI_File_open(comm, name, mpi_amode, info, &fh))) + if (MPI_SUCCESS != (mpi_code = MPI_File_open(comm, name, mpi_amode, info, &fh))) HMPI_GOTO_ERROR(NULL, "MPI_File_open failed", mpi_code) file_opened = TRUE; /* Get the MPI rank of this process and the total number of processes */ - if (MPI_SUCCESS != (mpi_code = MPI_Comm_rank (comm, &mpi_rank))) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_rank(comm, &mpi_rank))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mpi_code) - if (MPI_SUCCESS != (mpi_code = MPI_Comm_size (comm, &mpi_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_size(comm, &mpi_size))) HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code) /* Build the return value and initialize it */ - if(NULL == (file = (H5FD_mpio_t *)H5MM_calloc(sizeof(H5FD_mpio_t)))) + if (NULL == (file = (H5FD_mpio_t *)H5MM_calloc(sizeof(H5FD_mpio_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - file->f = fh; - file->comm = comm; - file->info = info; + file->f = fh; + file->comm = comm; + file->info = info; file->mpi_rank = mpi_rank; file->mpi_size = mpi_size; /* Only processor p0 will get the filesize and broadcast it. */ if (mpi_rank == 0) { - if (MPI_SUCCESS != (mpi_code=MPI_File_get_size(fh, &size))) + if (MPI_SUCCESS != (mpi_code = MPI_File_get_size(fh, &size))) HMPI_GOTO_ERROR(NULL, "MPI_File_get_size failed", mpi_code) } /* end if */ /* Broadcast file size */ - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(&size, (int)sizeof(MPI_Offset), MPI_BYTE, 0, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(&size, (int)sizeof(MPI_Offset), MPI_BYTE, 0, comm))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) /* Determine if the file should be truncated */ - if(size && (flags & H5F_ACC_TRUNC)) { - if (MPI_SUCCESS != (mpi_code=MPI_File_set_size(fh, (MPI_Offset)0))) + if (size && (flags & H5F_ACC_TRUNC)) { + if (MPI_SUCCESS != (mpi_code = MPI_File_set_size(fh, (MPI_Offset)0))) HMPI_GOTO_ERROR(NULL, "MPI_File_set_size failed", mpi_code) /* Don't let any proc return until all have truncated the file. */ @@ -867,33 +852,32 @@ H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, } /* end if */ /* Set the size of the file (from library's perspective) */ - file->eof = H5FD_mpi_MPIOff_to_haddr(size); + file->eof = H5FD_mpi_MPIOff_to_haddr(size); file->local_eof = file->eof; /* Set return value */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(ret_value == NULL) { - if(file_opened) + if (ret_value == NULL) { + if (file_opened) MPI_File_close(&fh); - if(H5_mpi_comm_free(&comm) < 0) + if (H5_mpi_comm_free(&comm) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTFREE, NULL, "unable to free MPI communicator") - if(H5_mpi_info_free(&info) < 0) + if (H5_mpi_info_free(&info) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTFREE, NULL, "unable to free MPI info object") - if(file) + if (file) H5MM_xfree(file); } /* end if */ #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_open() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_close * @@ -909,14 +893,14 @@ done: static herr_t H5FD__mpio_close(H5FD_t *_file) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Entering\n", FUNC); #endif @@ -925,7 +909,7 @@ H5FD__mpio_close(H5FD_t *_file) HDassert(H5FD_MPIO == file->pub.driver_id); /* MPI_File_close sets argument to MPI_FILE_NULL */ - if(MPI_SUCCESS != (mpi_code = MPI_File_close(&(file->f)/*in,out*/))) + if (MPI_SUCCESS != (mpi_code = MPI_File_close(&(file->f) /*in,out*/))) HMPI_GOTO_ERROR(FAIL, "MPI_File_close failed", mpi_code) /* Clean up other stuff */ @@ -935,14 +919,13 @@ H5FD__mpio_close(H5FD_t *_file) done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_close() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_query * @@ -962,19 +945,19 @@ H5FD__mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ - *flags |= H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ - } /* end if */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ + *flags |= H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__mpio_query() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_get_eoa * @@ -993,7 +976,7 @@ H5FD__mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out static haddr_t H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; FUNC_ENTER_STATIC_NOERR @@ -1004,7 +987,6 @@ H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD__mpio_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_set_eoa * @@ -1022,7 +1004,7 @@ H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; FUNC_ENTER_STATIC_NOERR @@ -1035,7 +1017,6 @@ H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__mpio_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_get_eof * @@ -1065,7 +1046,7 @@ H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) static haddr_t H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; FUNC_ENTER_STATIC_NOERR @@ -1076,7 +1057,6 @@ H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD__mpio_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_get_handle * @@ -1088,16 +1068,16 @@ H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) * Sept. 16, 2002 * *------------------------------------------------------------------------- -*/ + */ static herr_t -H5FD__mpio_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle) +H5FD__mpio_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->f); @@ -1106,7 +1086,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_read * @@ -1129,63 +1108,63 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) +H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf /*out*/) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - MPI_Offset mpi_off; - MPI_Status mpi_stat; /* Status from I/O operation */ - int mpi_code; /* mpi return code */ - MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ - int size_i; /* Integer copy of 'size' to read */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + MPI_Offset mpi_off; + MPI_Status mpi_stat; /* Status from I/O operation */ + int mpi_code; /* mpi return code */ + MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ + int size_i; /* Integer copy of 'size' to read */ #if MPI_VERSION >= 3 - MPI_Count bytes_read = 0; /* Number of bytes read in */ - MPI_Count type_size; /* MPI datatype used for I/O's size */ - MPI_Count io_size; /* Actual number of bytes requested */ - MPI_Count n; + MPI_Count bytes_read = 0; /* Number of bytes read in */ + MPI_Count type_size; /* MPI datatype used for I/O's size */ + MPI_Count io_size; /* Actual number of bytes requested */ + MPI_Count n; #else - int bytes_read = 0; /* Number of bytes read in */ - int type_size; /* MPI datatype used for I/O's size */ - int io_size; /* Actual number of bytes requested */ - int n; + int bytes_read = 0; /* Number of bytes read in */ + int type_size; /* MPI datatype used for I/O's size */ + int io_size; /* Actual number of bytes requested */ + int n; #endif - hbool_t use_view_this_time = FALSE; - hbool_t rank0_bcast = FALSE; /* If read-with-rank0-and-bcast flag was used */ - herr_t ret_value = SUCCEED; + hbool_t use_view_this_time = FALSE; + hbool_t rank0_bcast = FALSE; /* If read-with-rank0-and-bcast flag was used */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Entering\n", FUNC); #endif /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); HDassert(buf); /* Portably initialize MPI status variable */ - HDmemset(&mpi_stat,0,sizeof(MPI_Status)); + HDmemset(&mpi_stat, 0, sizeof(MPI_Status)); /* some numeric conversions */ - if(H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off/*out*/) < 0) + if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off /*out*/) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off") size_i = (int)size; - if((hsize_t)size_i != size) + if ((hsize_t)size_i != size) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i") #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) + if (H5FD_mpio_Debug[(int)'r']) HDfprintf(stdout, "%s: mpi_off = %ld size_i = %d\n", FUNC, (long)mpi_off, size_i); #endif /* Only look for MPI views for raw data transfers */ - if(type == H5FD_MEM_DRAW) { - H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ + if (type == H5FD_MEM_DRAW) { + H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ /* Get the transfer mode from the API context */ - if(H5CX_get_io_xfer_mode(&xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* @@ -1194,20 +1173,21 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, * us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which * could mean "use MPI_BYTE" by convention). */ - if(xfer_mode == H5FD_MPIO_COLLECTIVE) { + if (xfer_mode == H5FD_MPIO_COLLECTIVE) { MPI_Datatype file_type; /* Remember that views are used */ use_view_this_time = TRUE; /* Prepare for a full-blown xfer using btype, ftype, and disp */ - if(H5CX_get_mpi_coll_datatypes(&buf_type, &file_type) < 0) + if (H5CX_get_mpi_coll_datatypes(&buf_type, &file_type) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O datatypes") /* * Set the file view when we are using MPI derived types */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, + H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) /* When using types, use the address as the displacement for @@ -1215,72 +1195,74 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, */ mpi_off = 0; } /* end if */ - } /* end if */ + } /* end if */ /* Read the data. */ - if(use_view_this_time) { + if (use_view_this_time) { H5FD_mpio_collective_opt_t coll_opt_mode; #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) + if (H5FD_mpio_Debug[(int)'r']) HDfprintf(stdout, "%s: using MPIO collective mode\n", FUNC); #endif /* Get the collective_opt property to check whether the application wants to do IO individually. */ - if(H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) + if (H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O collective_op property") - if(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { + if (coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) + if (H5FD_mpio_Debug[(int)'r']) HDfprintf(stdout, "%s: doing MPI collective IO\n", FUNC); #endif /* Check whether we should read from rank 0 and broadcast to other ranks */ - if(H5CX_get_mpio_rank0_bcast()) { + if (H5CX_get_mpio_rank0_bcast()) { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) + if (H5FD_mpio_Debug[(int)'r']) HDfprintf(stdout, "%s: doing read-rank0-and-MPI_Bcast\n", FUNC); #endif /* Indicate path we've taken */ rank0_bcast = TRUE; /* Read on rank 0 Bcast to other ranks */ - if(file->mpi_rank == 0) - if(MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + if (file->mpi_rank == 0) + if (MPI_SUCCESS != + (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(buf, size_i, buf_type, 0, file->comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(buf, size_i, buf_type, 0, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mpi_code) } /* end if */ else { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) + if (H5FD_mpio_Debug[(int)'r']) HDfprintf(stdout, "%s: doing MPI independent IO\n", FUNC); #endif - if(MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + if (MPI_SUCCESS != + (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) } /* end else */ /* * Reset the file view when we used MPI derived types */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, + H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) + else if (MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) /* Only retrieve bytes read if this rank _actually_ participated in I/O */ - if(!rank0_bcast || (rank0_bcast && file->mpi_rank == 0) ) { + if (!rank0_bcast || (rank0_bcast && file->mpi_rank == 0)) { /* How many bytes were actually read? */ #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_read))) + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_read))) #else - if(MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read))) + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read))) #endif HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) } /* end if */ @@ -1291,15 +1273,15 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, /* NOTE: This could be optimized further to be combined with the broadcast * of the data. (QAK - 2019/1/2) */ - if(rank0_bcast) - if(MPI_SUCCESS != MPI_Bcast(&bytes_read, 1, MPI_LONG_LONG, 0, file->comm)) + if (rank0_bcast) + if (MPI_SUCCESS != MPI_Bcast(&bytes_read, 1, MPI_LONG_LONG, 0, file->comm)) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", 0) - /* Get the type's size */ + /* Get the type's size */ #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size))) #else - if(MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size))) #endif HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mpi_code) @@ -1307,26 +1289,24 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, io_size = type_size * size_i; /* Check for read failure */ - if(bytes_read < 0 || bytes_read > io_size) + if (bytes_read < 0 || bytes_read > io_size) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") /* * This gives us zeroes beyond end of physical MPI file. */ - if((n = (io_size - bytes_read)) > 0) - HDmemset((char*)buf+bytes_read, 0, (size_t)n); + if ((n = (io_size - bytes_read)) > 0) + HDmemset((char *)buf + bytes_read, 0, (size_t)n); done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_read() */ - - /*------------------------------------------------------------------------- * Function: H5FD__mpio_write * @@ -1349,39 +1329,39 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, size_t size, const void *buf) +H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, + const void *buf) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - MPI_Offset mpi_off; - MPI_Status mpi_stat; /* Status from I/O operation */ - MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ - int mpi_code; /* MPI return code */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + MPI_Offset mpi_off; + MPI_Status mpi_stat; /* Status from I/O operation */ + MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ + int mpi_code; /* MPI return code */ #if MPI_VERSION >= 3 - MPI_Count bytes_written; - MPI_Count type_size; /* MPI datatype used for I/O's size */ - MPI_Count io_size; /* Actual number of bytes requested */ + MPI_Count bytes_written; + MPI_Count type_size; /* MPI datatype used for I/O's size */ + MPI_Count io_size; /* Actual number of bytes requested */ #else - int bytes_written; - int type_size; /* MPI datatype used for I/O's size */ - int io_size; /* Actual number of bytes requested */ + int bytes_written; + int type_size; /* MPI datatype used for I/O's size */ + int io_size; /* Actual number of bytes requested */ #endif - int size_i; - hbool_t use_view_this_time = FALSE; - hbool_t derived_type = FALSE; - H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ - herr_t ret_value = SUCCEED; + int size_i; + hbool_t use_view_this_time = FALSE; + hbool_t derived_type = FALSE; + H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Entering\n", FUNC); #endif /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); HDassert(buf); /* Verify that no data is written when between MPI_Barrier()s during file flush */ @@ -1391,17 +1371,17 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, HDmemset(&mpi_stat, 0, sizeof(MPI_Status)); /* some numeric conversions */ - if(H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off) < 0) + if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off") size_i = (int)size; #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'w']) + if (H5FD_mpio_Debug[(int)'w']) HDfprintf(stdout, "%s: mpi_off = %ld size_i = %d\n", FUNC, (long)mpi_off, size_i); #endif /* Get the transfer mode from the API context */ - if(H5CX_get_io_xfer_mode(&xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* @@ -1410,20 +1390,21 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, * us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which * could mean "use MPI_BYTE" by convention). */ - if(xfer_mode == H5FD_MPIO_COLLECTIVE) { - MPI_Datatype file_type; + if (xfer_mode == H5FD_MPIO_COLLECTIVE) { + MPI_Datatype file_type; /* Remember that views are used */ use_view_this_time = TRUE; /* Prepare for a full-blown xfer using btype, ftype, and disp */ - if(H5CX_get_mpi_coll_datatypes(&buf_type, &file_type) < 0) + if (H5CX_get_mpi_coll_datatypes(&buf_type, &file_type) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O datatypes") /* * Set the file view when we are using MPI derived types */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, + H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) /* When using types, use the address as the displacement for @@ -1431,7 +1412,7 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, */ mpi_off = 0; } /* end if */ - else if(size != (hsize_t)size_i) { + else if (size != (hsize_t)size_i) { /* If HERE, then we need to work around the integer size limit * of 2GB. The input size_t size variable cannot fit into an integer, * but we can get around that limitation by creating a different datatype @@ -1439,66 +1420,70 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, * the derived_type. */ - if (H5_mpio_create_large_type(size, 0, MPI_BYTE, &buf_type) < 0) + if (H5_mpio_create_large_type(size, 0, MPI_BYTE, &buf_type) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "can't create MPI-I/O datatype") derived_type = TRUE; - size_i = 1; + size_i = 1; } /* Write the data. */ - if(use_view_this_time) { + if (use_view_this_time) { H5FD_mpio_collective_opt_t coll_opt_mode; #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'w']) + if (H5FD_mpio_Debug[(int)'w']) HDfprintf(stdout, "%s: using MPIO collective mode\n", FUNC); #endif /* Get the collective_opt property to check whether the application wants to do IO individually. */ - if(H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) + if (H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O collective_op property") - if(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { + if (coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'w']) + if (H5FD_mpio_Debug[(int)'w']) HDfprintf(stdout, "%s: doing MPI collective IO\n", FUNC); #endif - if(MPI_SUCCESS != (mpi_code = MPI_File_write_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + if (MPI_SUCCESS != + (mpi_code = MPI_File_write_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mpi_code) } /* end if */ else { - if(type != H5FD_MEM_DRAW) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "Metadata Coll opt property should be collective at this point") + if (type != H5FD_MEM_DRAW) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, + "Metadata Coll opt property should be collective at this point") #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'w']) + if (H5FD_mpio_Debug[(int)'w']) HDfprintf(stdout, "%s: doing MPI independent IO\n", FUNC); #endif - if(MPI_SUCCESS != (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + if (MPI_SUCCESS != + (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) } /* end else */ /* Reset the file view when we used MPI derived types */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, + H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) - /* How many bytes were actually written? */ + /* How many bytes were actually written? */ #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_written))) + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_written))) #else - if(MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_written))) + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_written))) #endif HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) - /* Get the type's size */ + /* Get the type's size */ #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size))) #else - if(MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size))) #endif HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mpi_code) @@ -1506,7 +1491,7 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, io_size = type_size * size_i; /* Check for write failure */ - if(bytes_written != io_size || bytes_written < 0) + if (bytes_written != io_size || bytes_written < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Each process will keep track of its perceived EOF value locally, and @@ -1517,22 +1502,21 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, * potentially be wrong.) */ file->eof = HADDR_UNDEF; - if(bytes_written && (((haddr_t)bytes_written + addr) > file->local_eof)) + if (bytes_written && (((haddr_t)bytes_written + addr) > file->local_eof)) file->local_eof = addr + (haddr_t)bytes_written; done: - if(derived_type) { + if (derived_type) { MPI_Type_free(&buf_type); } #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving, proc %d: ret_value = %d\n", FUNC, file->mpi_rank, ret_value ); + if (H5FD_mpio_Debug[(int)'t']) + HDfprintf(stdout, "%s: Leaving, proc %d: ret_value = %d\n", FUNC, file->mpi_rank, ret_value); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_write() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_flush * @@ -1548,14 +1532,14 @@ done: static herr_t H5FD__mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - int mpi_code; /* mpi return code */ - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + int mpi_code; /* mpi return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Entering\n", FUNC); #endif @@ -1564,20 +1548,19 @@ H5FD__mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) HDassert(H5FD_MPIO == file->pub.driver_id); /* Only sync the file if we are not going to immediately close it */ - if(!closing) - if(MPI_SUCCESS != (mpi_code = MPI_File_sync(file->f))) + if (!closing) + if (MPI_SUCCESS != (mpi_code = MPI_File_sync(file->f))) HMPI_GOTO_ERROR(FAIL, "MPI_File_sync failed", mpi_code) done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_flush() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_truncate * @@ -1603,13 +1586,13 @@ done: static herr_t H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Entering\n", FUNC); #endif @@ -1617,10 +1600,10 @@ H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); - if(!H5F_addr_eq(file->eoa, file->last_eoa)) { - int mpi_code; /* mpi return code */ - MPI_Offset size; - MPI_Offset needed_eof; + if (!H5F_addr_eq(file->eoa, file->last_eoa)) { + int mpi_code; /* mpi return code */ + MPI_Offset size; + MPI_Offset needed_eof; /* In principle, it is possible for the size returned by the * call to MPI_File_get_size() to depend on whether writes from @@ -1634,29 +1617,29 @@ H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR * Check the "MPI file closing" flag in the API context to determine * if we can skip the barrier. */ - if(!H5CX_get_mpi_file_flushing()) - if(MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm))) + if (!H5CX_get_mpi_file_flushing()) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) /* Only processor p0 will get the filesize and broadcast it. */ /* (Note that throwing an error here will cause non-rank 0 processes * to hang in following Bcast. -QAK, 3/17/2018) */ - if(0 == file->mpi_rank) - if(MPI_SUCCESS != (mpi_code = MPI_File_get_size(file->f, &size))) + if (0 == file->mpi_rank) + if (MPI_SUCCESS != (mpi_code = MPI_File_get_size(file->f, &size))) HMPI_GOTO_ERROR(FAIL, "MPI_File_get_size failed", mpi_code) /* Broadcast file size */ - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(&size, (int)sizeof(MPI_Offset), MPI_BYTE, 0, file->comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(&size, (int)sizeof(MPI_Offset), MPI_BYTE, 0, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code) - if(H5FD_mpi_haddr_to_MPIOff(file->eoa, &needed_eof) < 0) + if (H5FD_mpi_haddr_to_MPIOff(file->eoa, &needed_eof) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset") /* eoa != eof. Set eof to eoa */ - if(size != needed_eof) { + if (size != needed_eof) { /* Extend the file's size */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_size(file->f, needed_eof))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_size(file->f, needed_eof))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code) /* In general, we must wait until all processes have finished @@ -1668,7 +1651,7 @@ H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR * not be an issue at file close. If so, we may be able to * optimize out the following barrier in that case. */ - if(MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) } /* end if */ @@ -1678,14 +1661,13 @@ H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) + if (H5FD_mpio_Debug[(int)'t']) HDfprintf(stdout, "%s: Leaving\n", FUNC); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_mpi_rank * @@ -1702,7 +1684,7 @@ done: static int H5FD__mpio_mpi_rank(const H5FD_t *_file) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; FUNC_ENTER_STATIC_NOERR @@ -1713,7 +1695,6 @@ H5FD__mpio_mpi_rank(const H5FD_t *_file) FUNC_LEAVE_NOAPI(file->mpi_rank) } /* end H5FD__mpio_mpi_rank() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_mpi_size * @@ -1730,7 +1711,7 @@ H5FD__mpio_mpi_rank(const H5FD_t *_file) static int H5FD__mpio_mpi_size(const H5FD_t *_file) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; FUNC_ENTER_STATIC_NOERR @@ -1741,7 +1722,6 @@ H5FD__mpio_mpi_size(const H5FD_t *_file) FUNC_LEAVE_NOAPI(file->mpi_size) } /* end H5FD__mpio_mpi_size() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_communicator * @@ -1758,7 +1738,7 @@ H5FD__mpio_mpi_size(const H5FD_t *_file) static MPI_Comm H5FD__mpio_communicator(const H5FD_t *_file) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; FUNC_ENTER_STATIC_NOERR @@ -1769,7 +1749,6 @@ H5FD__mpio_communicator(const H5FD_t *_file) FUNC_LEAVE_NOAPI(file->comm) } /* end H5FD__mpio_communicator() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_get_info * @@ -1781,16 +1760,16 @@ H5FD__mpio_communicator(const H5FD_t *_file) * April 4, 2017 * *------------------------------------------------------------------------- -*/ + */ static herr_t H5FD__mpio_get_info(H5FD_t *_file, void **mpi_info) { - H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC - if(!mpi_info) + if (!mpi_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mpi info not valid") *mpi_info = &(file->info); @@ -1800,4 +1779,3 @@ done: } /* H5FD__mpio_get_info() */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index 6ee0a1a..289cfde 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -23,9 +23,9 @@ /* Macros */ #ifdef H5_HAVE_PARALLEL -# define H5FD_MPIO (H5FD_mpio_init()) +#define H5FD_MPIO (H5FD_mpio_init()) #else -# define H5FD_MPIO (-1) +#define H5FD_MPIO (-1) #endif /* H5_HAVE_PARALLEL */ #ifdef H5_HAVE_PARALLEL @@ -44,12 +44,11 @@ H5_DLLVAR hbool_t H5FD_mpi_opt_types_g; #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_mpio_init(void); +H5_DLL hid_t H5FD_mpio_init(void); H5_DLL herr_t H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info); -H5_DLL herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, - MPI_Info *info/*out*/); +H5_DLL herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm /*out*/, MPI_Info *info /*out*/); H5_DLL herr_t H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode); -H5_DLL herr_t H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/); +H5_DLL herr_t H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode /*out*/); H5_DLL herr_t H5Pset_dxpl_mpio_collective_opt(hid_t dxpl_id, H5FD_mpio_collective_opt_t opt_mode); H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt(hid_t dxpl_id, H5FD_mpio_chunk_opt_t opt_mode); H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt_num(hid_t dxpl_id, unsigned num_chunk_per_proc); @@ -61,4 +60,3 @@ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt_ratio(hid_t dxpl_id, unsigned percent_n #endif /* H5_HAVE_PARALLEL */ #endif - diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 132c2c3..683be6a 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -28,51 +28,53 @@ #include "hdf5.h" - #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif /* Loop through all mapped files */ -#define UNIQUE_MEMBERS_CORE(MAP, ITER, SEEN, LOOPVAR) { \ - H5FD_mem_t ITER, LOOPVAR; \ - unsigned SEEN[H5FD_MEM_NTYPES]; \ - \ - memset(SEEN, 0, sizeof SEEN); \ - for (ITER=H5FD_MEM_SUPER; ITER0 && LOOPVAR 0 && LOOPVAR < H5FD_MEM_NTYPES); \ + if (SEEN[LOOPVAR]++) \ + continue; /* Need two front-ends, since they are nested sometimes */ -#define UNIQUE_MEMBERS(MAP, LOOPVAR) \ - UNIQUE_MEMBERS_CORE(MAP, _unmapped, _seen, LOOPVAR) -#define UNIQUE_MEMBERS2(MAP, LOOPVAR) \ - UNIQUE_MEMBERS_CORE(MAP, _unmapped2, _seen2, LOOPVAR) - -#define ALL_MEMBERS(LOOPVAR) { \ - H5FD_mem_t LOOPVAR; \ - for (LOOPVAR=H5FD_MEM_DEFAULT; LOOPVARsizeof(meta_name) - QK & JK - 2013/01/17 */ - strncpy(meta_name, meta_ext, sizeof(meta_name)); + strncpy(meta_name, meta_ext, sizeof(meta_name)); meta_name[sizeof(meta_name) - 1] = '\0'; } - else - sprintf(meta_name, "%%s%s", meta_ext); + else + sprintf(meta_name, "%%s%s", meta_ext); } else { - strncpy(meta_name, "%s.meta", sizeof(meta_name)); + strncpy(meta_name, "%s.meta", sizeof(meta_name)); meta_name[sizeof(meta_name) - 1] = '\0'; } memb_name[H5FD_MEM_SUPER] = meta_name; /* process raw filename */ - if(raw_ext) { - if(strstr(raw_ext, "%s")) { + if (raw_ext) { + if (strstr(raw_ext, "%s")) { /* Note: this doesn't accommodate for when the '%s' in the user's * string is at a position >sizeof(raw_name) - QK & JK - 2013/01/17 */ - strncpy(raw_name, raw_ext, sizeof(raw_name)); + strncpy(raw_name, raw_ext, sizeof(raw_name)); raw_name[sizeof(raw_name) - 1] = '\0'; } - else - sprintf(raw_name, "%%s%s", raw_ext); + else + sprintf(raw_name, "%%s%s", raw_ext); } else { - strncpy(raw_name, "%s.raw", sizeof(raw_name)); + strncpy(raw_name, "%s.raw", sizeof(raw_name)); raw_name[sizeof(raw_name) - 1] = '\0'; } memb_name[H5FD_MEM_DRAW] = raw_name; /* The sizes */ memb_addr[H5FD_MEM_SUPER] = 0; - memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/2; + memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 2; return H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE); } - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_multi * @@ -422,19 +416,18 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, *------------------------------------------------------------------------- */ herr_t -H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, - const hid_t *memb_fapl, const char * const *memb_name, - const haddr_t *memb_addr, hbool_t relax) +H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_fapl, + const char *const *memb_name, const haddr_t *memb_addr, hbool_t relax) { - H5FD_multi_fapl_t fa; - H5FD_mem_t mt, mmt; - H5FD_mem_t _memb_map[H5FD_MEM_NTYPES]; - hid_t _memb_fapl[H5FD_MEM_NTYPES]; - char _memb_name[H5FD_MEM_NTYPES][16]; - const char *_memb_name_ptrs[H5FD_MEM_NTYPES]; - haddr_t _memb_addr[H5FD_MEM_NTYPES]; - static const char *letters = "Xsbrglo"; - static const char *func="H5FDset_fapl_multi"; /* Function Name for error reporting */ + H5FD_multi_fapl_t fa; + H5FD_mem_t mt, mmt; + H5FD_mem_t _memb_map[H5FD_MEM_NTYPES]; + hid_t _memb_fapl[H5FD_MEM_NTYPES]; + char _memb_name[H5FD_MEM_NTYPES][16]; + const char * _memb_name_ptrs[H5FD_MEM_NTYPES]; + haddr_t _memb_addr[H5FD_MEM_NTYPES]; + static const char *letters = "Xsbrglo"; + static const char *func = "H5FDset_fapl_multi"; /* Function Name for error reporting */ /*NO TRACE*/ @@ -442,50 +435,49 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, H5Eclear2(H5E_DEFAULT); /* Check arguments and supply default values */ - if(H5I_GENPROP_LST != H5Iget_type(fapl_id) || - TRUE != H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "not an access list", -1) - if (!memb_map) { - for (mt=H5FD_MEM_DEFAULT; mt=H5FD_MEM_NTYPES) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1) - if (H5FD_MEM_DEFAULT==mmt) mmt = mt; + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + /* Map usage type */ + mmt = memb_map[mt]; + if (mmt < 0 || mmt >= H5FD_MEM_NTYPES) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", + -1) if (H5FD_MEM_DEFAULT == mmt) mmt = mt; - /* - * All members of MEMB_FAPL must be either defaults or actual file - * access property lists. - */ - if (H5P_DEFAULT!=memb_fapl[mmt] && TRUE!=H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) + /* + * All members of MEMB_FAPL must be either defaults or actual file + * access property lists. + */ + if (H5P_DEFAULT != memb_fapl[mmt] && TRUE != H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1) - /* All names must be defined */ - if (!memb_name[mmt] || !memb_name[mmt][0]) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1) + /* All names must be defined */ + if (!memb_name[mmt] || !memb_name[mmt][0]) H5Epush_ret( + func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1) } /* @@ -493,21 +485,20 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, * struct since all members will be copied by H5Pset_driver(). */ memset(&fa, 0, sizeof(H5FD_multi_fapl_t)); - memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); - memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES*sizeof(hid_t)); - memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES*sizeof(char*)); - memcpy(fa.memb_addr, memb_addr, H5FD_MEM_NTYPES*sizeof(haddr_t)); + memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); + memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES * sizeof(hid_t)); + memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES * sizeof(char *)); + memcpy(fa.memb_addr, memb_addr, H5FD_MEM_NTYPES * sizeof(haddr_t)); fa.relax = relax; /* Patch up H5P_DEFAULT property lists for members */ - for (mt=H5FD_MEM_DEFAULT; mtmemb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); + if (memb_map) memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); if (memb_fapl) { - for (mt=H5FD_MEM_DEFAULT; mtmemb_fapl[mt]>=0) - memb_fapl[mt] = H5Pcopy(fa->memb_fapl[mt]); - else - memb_fapl[mt] = fa->memb_fapl[mt]; /*default or bad ID*/ - } + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (fa->memb_fapl[mt] >= 0) + memb_fapl[mt] = H5Pcopy(fa->memb_fapl[mt]); + else + memb_fapl[mt] = fa->memb_fapl[mt]; /*default or bad ID*/ + } } - if(memb_name) { - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - if(fa->memb_name[mt]) - memb_name[mt] = my_strdup(fa->memb_name[mt]); - else - memb_name[mt] = NULL; - } + if (memb_name) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (fa->memb_name[mt]) + memb_name[mt] = my_strdup(fa->memb_name[mt]); + else + memb_name[mt] = NULL; + } } if (memb_addr) - memcpy(memb_addr, fa->memb_addr, H5FD_MEM_NTYPES*sizeof(haddr_t)); + memcpy(memb_addr, fa->memb_addr, H5FD_MEM_NTYPES * sizeof(haddr_t)); if (relax) - *relax = fa->relax; + *relax = fa->relax; return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_sb_size * @@ -591,31 +578,32 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, static hsize_t H5FD_multi_sb_size(H5FD_t *_file) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - unsigned nseen = 0; - hsize_t nbytes = 8; /*size of header*/ + H5FD_multi_t *file = (H5FD_multi_t *)_file; + unsigned nseen = 0; + hsize_t nbytes = 8; /*size of header*/ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* How many unique files? */ - UNIQUE_MEMBERS(file->fa.memb_map, mt) { - nseen++; - } END_MEMBERS; + UNIQUE_MEMBERS (file->fa.memb_map, mt) { + nseen++; + } + END_MEMBERS; /* Addresses and EOA markers */ nbytes += nseen * 2 * 8; /* Name templates */ - UNIQUE_MEMBERS(file->fa.memb_map, mt) { - size_t n = strlen(file->fa.memb_name[mt])+1; - nbytes += (n+7) & ~((size_t)0x0007); - } END_MEMBERS; + UNIQUE_MEMBERS (file->fa.memb_map, mt) { + size_t n = strlen(file->fa.memb_name[mt]) + 1; + nbytes += (n + 7) & ~((size_t)0x0007); + } + END_MEMBERS; return nbytes; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_sb_encode * @@ -640,16 +628,15 @@ H5FD_multi_sb_size(H5FD_t *_file) *------------------------------------------------------------------------- */ static herr_t -H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, - unsigned char *buf/*out*/) +H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - haddr_t memb_eoa; - unsigned char *p; - size_t nseen; - size_t i; - H5FD_mem_t m; - static const char *func="H5FD_multi_sb_encode"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + haddr_t memb_eoa; + unsigned char * p; + size_t nseen; + size_t i; + H5FD_mem_t m; + static const char *func = "H5FD_multi_sb_encode"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -658,10 +645,10 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, strncpy(name, "NCSAmulti", (size_t)8); name[8] = '\0'; - assert(7==H5FD_MEM_NTYPES); + assert(7 == H5FD_MEM_NTYPES); - for (m=H5FD_MEM_SUPER; mfa.memb_map[m]; + for (m = H5FD_MEM_SUPER; m < H5FD_MEM_NTYPES; m = (H5FD_mem_t)(m + 1)) { + buf[m - 1] = (unsigned char)file->fa.memb_map[m]; } buf[6] = 0; buf[7] = 0; @@ -673,33 +660,34 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, /* Encode all starting addresses and EOA values */ nseen = 0; - p = buf+8; - assert(sizeof(haddr_t)<=8); - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + p = buf + 8; + assert(sizeof(haddr_t) <= 8); + UNIQUE_MEMBERS (file->fa.memb_map, mt) { memcpy(p, &(file->fa.memb_addr[mt]), sizeof(haddr_t)); p += sizeof(haddr_t); memb_eoa = H5FDget_eoa(file->memb[mt], mt); memcpy(p, &memb_eoa, sizeof(haddr_t)); p += sizeof(haddr_t); nseen++; - } END_MEMBERS; - if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen*2, buf+8, NULL, H5P_DEFAULT)<0) + } + END_MEMBERS; + if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen * 2, buf + 8, NULL, H5P_DEFAULT) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1) - /* Encode all name templates */ - p = buf + 8 + nseen*2*8; - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + /* Encode all name templates */ + p = buf + 8 + nseen * 2 * 8; + UNIQUE_MEMBERS (file->fa.memb_map, mt) { size_t n = strlen(file->fa.memb_name[mt]) + 1; strncpy((char *)p, file->fa.memb_name[mt], n); p += n; - for (i=n; i%8; i++) + for (i = n; i % 8; i++) *p++ = '\0'; - } END_MEMBERS; + } + END_MEMBERS; return 0; } /* end H5FD_multi_sb_encode() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_sb_decode * @@ -723,18 +711,18 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, static herr_t H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - char x[2*H5FD_MEM_NTYPES*8]; - H5FD_mem_t map[H5FD_MEM_NTYPES]; - int i; - size_t nseen=0; - hbool_t map_changed=FALSE; - hbool_t in_use[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - haddr_t memb_eoa[H5FD_MEM_NTYPES]; - haddr_t *ap; - static const char *func="H5FD_multi_sb_decode"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + char x[2 * H5FD_MEM_NTYPES * 8]; + H5FD_mem_t map[H5FD_MEM_NTYPES]; + int i; + size_t nseen = 0; + hbool_t map_changed = FALSE; + hbool_t in_use[H5FD_MEM_NTYPES]; + const char * memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + haddr_t memb_eoa[H5FD_MEM_NTYPES]; + haddr_t * ap; + static const char *func = "H5FD_multi_sb_decode"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -743,47 +731,53 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) if (strcmp(name, "NCSAmult")) H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "invalid multi superblock", -1) - /* Set default values */ - ALL_MEMBERS(mt) { - memb_addr[mt] = HADDR_UNDEF; - memb_eoa[mt] = HADDR_UNDEF; - memb_name[mt] = NULL; - } END_MEMBERS; + /* Set default values */ + ALL_MEMBERS (mt) + { + memb_addr[mt] = HADDR_UNDEF; + memb_eoa[mt] = HADDR_UNDEF; + memb_name[mt] = NULL; + } + END_MEMBERS; /* * Read the map and count the unique members. */ memset(map, 0, sizeof map); - for (i=0; i<6; i++) { - map[i+1] = (H5FD_mem_t)buf[i]; - if (file->fa.memb_map[i+1]!=map[i+1]) - map_changed=TRUE; + for (i = 0; i < 6; i++) { + map[i + 1] = (H5FD_mem_t)buf[i]; + if (file->fa.memb_map[i + 1] != map[i + 1]) + map_changed = TRUE; } - UNIQUE_MEMBERS(map, mt) { + UNIQUE_MEMBERS (map, mt) { nseen++; - } END_MEMBERS; + } + END_MEMBERS; buf += 8; /* Decode Address and EOA values */ - assert(sizeof(haddr_t)<=8); - memcpy(x, buf, (nseen*2*8)); - buf += nseen*2*8; - if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen*2, x, NULL, H5P_DEFAULT)<0) + assert(sizeof(haddr_t) <= 8); + memcpy(x, buf, (nseen * 2 * 8)); + buf += nseen * 2 * 8; + if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen * 2, x, NULL, H5P_DEFAULT) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1) - ap = (haddr_t*)((void *)x); /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */ - UNIQUE_MEMBERS(map, mt) { + ap = (haddr_t *)((void *)x); /* Extra (void *) cast to quiet "cast to create alignment" warning - + 2019/07/05, QAK */ + UNIQUE_MEMBERS (map, mt) { memb_addr[_unmapped] = *ap++; - memb_eoa[_unmapped] = *ap++; - } END_MEMBERS; + memb_eoa[_unmapped] = *ap++; + } + END_MEMBERS; /* Decode name templates */ - UNIQUE_MEMBERS(map, mt) { - size_t n = strlen((const char *)buf)+1; + UNIQUE_MEMBERS (map, mt) { + size_t n = strlen((const char *)buf) + 1; memb_name[_unmapped] = (const char *)buf; - buf += (n+7) & ~((unsigned)0x0007); - } END_MEMBERS; + buf += (n + 7) & ~((unsigned)0x0007); + } + END_MEMBERS; /* * Use the mapping saved in the superblock in preference to the one @@ -793,54 +787,60 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) */ if (map_changed) { /* Commit map */ - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { file->fa.memb_map[mt] = map[mt]; - } END_MEMBERS; + } + END_MEMBERS; /* Close files which are unused now */ memset(in_use, 0, sizeof in_use); - UNIQUE_MEMBERS(map, mt) { + UNIQUE_MEMBERS (map, mt) { in_use[mt] = TRUE; - } END_MEMBERS; - ALL_MEMBERS(mt) { + } + END_MEMBERS; + ALL_MEMBERS (mt) { if (!in_use[mt] && file->memb[mt]) { (void)H5FDclose(file->memb[mt]); file->memb[mt] = NULL; } file->fa.memb_map[mt] = map[mt]; - } END_MEMBERS; + } + END_MEMBERS; } /* Commit member starting addresses and name templates */ - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { file->fa.memb_addr[mt] = memb_addr[mt]; if (memb_name[mt]) { if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); file->fa.memb_name[mt] = my_strdup(memb_name[mt]); } - } END_MEMBERS; - if (compute_next(file)<0) + } + END_MEMBERS; + if (compute_next(file) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1) - /* Open all necessary files */ - if (open_members(file)<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", -1) + /* Open all necessary files */ + if (open_members(file) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", -1) - /* Set the EOA marker for all open files */ - UNIQUE_MEMBERS(file->fa.memb_map, mt) { - if (file->memb[mt]) - if(H5FDset_eoa(file->memb[mt], mt, memb_eoa[mt])<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "set_eoa() failed", -1) + /* Set the EOA marker for all open files */ + UNIQUE_MEMBERS (file->fa.memb_map, mt) + { + if (file->memb[mt]) + if (H5FDset_eoa(file->memb[mt], mt, memb_eoa[mt]) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "set_eoa() failed", -1) - /* Save the individual EOAs in one place for later comparison (in H5FD_multi_set_eoa) */ - file->memb_eoa[mt] = memb_eoa[mt]; - } END_MEMBERS; + /* Save the individual EOAs in one place for later comparison (in H5FD_multi_set_eoa) + */ + file->memb_eoa[mt] = memb_eoa[mt]; + } + END_MEMBERS; return 0; } /* end H5FD_multi_sb_decode() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_fapl_get * @@ -861,7 +861,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) static void * H5FD_multi_fapl_get(H5FD_t *_file) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -869,7 +869,6 @@ H5FD_multi_fapl_get(H5FD_t *_file) return H5FD_multi_fapl_copy(&(file->fa)); } - /*------------------------------------------------------------------------- * Function: H5FD_multi_fapl_copy * @@ -887,10 +886,10 @@ H5FD_multi_fapl_get(H5FD_t *_file) static void * H5FD_multi_fapl_copy(const void *_old_fa) { - const H5FD_multi_fapl_t *old_fa = (const H5FD_multi_fapl_t*)_old_fa; - H5FD_multi_fapl_t *new_fa = (H5FD_multi_fapl_t *)calloc(1, sizeof(H5FD_multi_fapl_t)); - int nerrors = 0; - static const char *func="H5FD_multi_fapl_copy"; /* Function Name for error reporting */ + const H5FD_multi_fapl_t *old_fa = (const H5FD_multi_fapl_t *)_old_fa; + H5FD_multi_fapl_t * new_fa = (H5FD_multi_fapl_t *)calloc(1, sizeof(H5FD_multi_fapl_t)); + int nerrors = 0; + static const char * func = "H5FD_multi_fapl_copy"; /* Function Name for error reporting */ assert(new_fa); @@ -898,37 +897,38 @@ H5FD_multi_fapl_copy(const void *_old_fa) H5Eclear2(H5E_DEFAULT); memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t)); - ALL_MEMBERS(mt) { - if (old_fa->memb_fapl[mt]>=0) { - if (H5Iinc_ref(old_fa->memb_fapl[mt]) < 0) { + ALL_MEMBERS (mt) { + if (old_fa->memb_fapl[mt] >= 0) { + if (H5Iinc_ref(old_fa->memb_fapl[mt]) < 0) { nerrors++; break; } - new_fa->memb_fapl[mt] = old_fa->memb_fapl[mt]; - } - if (old_fa->memb_name[mt]) { - new_fa->memb_name[mt] = my_strdup(old_fa->memb_name[mt]); + new_fa->memb_fapl[mt] = old_fa->memb_fapl[mt]; + } + if (old_fa->memb_name[mt]) { + new_fa->memb_name[mt] = my_strdup(old_fa->memb_name[mt]); if (NULL == new_fa->memb_name[mt]) { nerrors++; break; } - } - } END_MEMBERS; + } + } + END_MEMBERS; if (nerrors) { - ALL_MEMBERS(mt) { - if (new_fa->memb_fapl[mt]>=0) + ALL_MEMBERS (mt) { + if (new_fa->memb_fapl[mt] >= 0) (void)H5Idec_ref(new_fa->memb_fapl[mt]); if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]); - } END_MEMBERS; + } + END_MEMBERS; free(new_fa); H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't release object on error", NULL) } return new_fa; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_fapl_free * @@ -946,25 +946,24 @@ H5FD_multi_fapl_copy(const void *_old_fa) static herr_t H5FD_multi_fapl_free(void *_fa) { - H5FD_multi_fapl_t *fa = (H5FD_multi_fapl_t*)_fa; - static const char *func="H5FD_multi_fapl_free"; /* Function Name for error reporting */ + H5FD_multi_fapl_t *fa = (H5FD_multi_fapl_t *)_fa; + static const char *func = "H5FD_multi_fapl_free"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - ALL_MEMBERS(mt) { - if (fa->memb_fapl[mt]>=0) - if(H5Idec_ref(fa->memb_fapl[mt])<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", -1) - if (fa->memb_name[mt]) - free(fa->memb_name[mt]); - } END_MEMBERS; + ALL_MEMBERS (mt) { + if (fa->memb_fapl[mt] >= 0) + if (H5Idec_ref(fa->memb_fapl[mt]) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", + -1) if (fa->memb_name[mt]) free(fa->memb_name[mt]); + } + END_MEMBERS; free(fa); return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_open * @@ -984,38 +983,39 @@ H5FD_multi_fapl_free(void *_fa) static H5FD_t * H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_multi_t *file=NULL; - hid_t close_fapl=-1; + H5FD_multi_t * file = NULL; + hid_t close_fapl = -1; const H5FD_multi_fapl_t *fa; - H5FD_mem_t m; - static const char *func="H5FD_multi_open"; /* Function Name for error reporting */ + H5FD_mem_t m; + static const char * func = "H5FD_multi_open"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check arguments */ if (!name || !*name) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL) - if (0 == maxaddr || HADDR_UNDEF == maxaddr) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL) - - /* - * Initialize the file from the file access properties, using default - * values if necessary. Make sure to use CALLOC here because the code - * in H5FD_multi_set_eoa depends on the proper initialization of memb_eoa - * in H5FD_multi_t. - */ - if(NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t)))) - H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL) - if(H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) { - close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if(H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) - H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error) - } + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", + NULL) if (0 == maxaddr || HADDR_UNDEF == maxaddr) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL) + + /* + * Initialize the file from the file access properties, using default + * values if necessary. Make sure to use CALLOC here because the code + * in H5FD_multi_set_eoa depends on the proper initialization of memb_eoa + * in H5FD_multi_t. + */ + if (NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t)))) H5Epush_ret( + func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", + NULL) if (H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) + { + close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) + H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error) + } fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); assert(fa); - ALL_MEMBERS(mt) { - file->fa.memb_map[mt] = fa->memb_map[mt]; + ALL_MEMBERS (mt) { + file->fa.memb_map[mt] = fa->memb_map[mt]; file->fa.memb_addr[mt] = fa->memb_addr[mt]; if (fa->memb_fapl[mt] >= 0) H5Iinc_ref(fa->memb_fapl[mt]); @@ -1024,17 +1024,18 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->fa.memb_name[mt] = my_strdup(fa->memb_name[mt]); else file->fa.memb_name[mt] = NULL; - } END_MEMBERS; + } + END_MEMBERS; file->fa.relax = fa->relax; - file->flags = flags; - file->name = my_strdup(name); + file->flags = flags; + file->name = my_strdup(name); if (close_fapl >= 0) - if(H5Pclose(close_fapl) < 0) + if (H5Pclose(close_fapl) < 0) H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", error) - /* Compute derived properties and open member files */ - if (compute_next(file) < 0) - H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", error); + /* Compute derived properties and open member files */ + if (compute_next(file) < 0) H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, + "compute_next() failed", error); if (open_members(file) < 0) H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", error); @@ -1044,16 +1045,20 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr if (NULL == file->memb[m]) goto error; - return (H5FD_t*)file; + return (H5FD_t *)file; error: /* Cleanup and fail */ if (file) { - ALL_MEMBERS(mt) { - if (file->memb[mt]) (void)H5FDclose(file->memb[mt]); - if (file->fa.memb_fapl[mt] >= 0) (void)H5Idec_ref(file->fa.memb_fapl[mt]); - if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); - } END_MEMBERS; + ALL_MEMBERS (mt) { + if (file->memb[mt]) + (void)H5FDclose(file->memb[mt]); + if (file->fa.memb_fapl[mt] >= 0) + (void)H5Idec_ref(file->fa.memb_fapl[mt]); + if (file->fa.memb_name[mt]) + free(file->fa.memb_name[mt]); + } + END_MEMBERS; if (file->name) free(file->name); free(file); @@ -1061,7 +1066,6 @@ error: return NULL; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_close * @@ -1081,38 +1085,43 @@ error: static herr_t H5FD_multi_close(H5FD_t *_file) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - int nerrors=0; - static const char *func="H5FD_multi_close"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + int nerrors = 0; + static const char *func = "H5FD_multi_close"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Close as many members as possible */ - ALL_MEMBERS(mt) { - if (file->memb[mt]) { - if (H5FDclose(file->memb[mt])<0) { - nerrors++; - } else { - file->memb[mt] = NULL; - } - } - } END_MEMBERS; + ALL_MEMBERS (mt) { + if (file->memb[mt]) { + if (H5FDclose(file->memb[mt]) < 0) { + nerrors++; + } + else { + file->memb[mt] = NULL; + } + } + } + END_MEMBERS; if (nerrors) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1) - /* Clean up other stuff */ - ALL_MEMBERS(mt) { - if (file->fa.memb_fapl[mt]>=0) (void)H5Idec_ref(file->fa.memb_fapl[mt]); - if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); - } END_MEMBERS; + /* Clean up other stuff */ + ALL_MEMBERS (mt) + { + if (file->fa.memb_fapl[mt] >= 0) + (void)H5Idec_ref(file->fa.memb_fapl[mt]); + if (file->fa.memb_name[mt]) + free(file->fa.memb_name[mt]); + } + END_MEMBERS; free(file->name); free(file); return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_cmp * @@ -1135,33 +1144,33 @@ H5FD_multi_close(H5FD_t *_file) static int H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_multi_t *f1 = (const H5FD_multi_t*)_f1; - const H5FD_multi_t *f2 = (const H5FD_multi_t*)_f2; - H5FD_mem_t out_mt = H5FD_MEM_DEFAULT; - int cmp=0; + const H5FD_multi_t *f1 = (const H5FD_multi_t *)_f1; + const H5FD_multi_t *f2 = (const H5FD_multi_t *)_f2; + H5FD_mem_t out_mt = H5FD_MEM_DEFAULT; + int cmp = 0; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { out_mt = mt; - if(f1->memb[mt] && f2->memb[mt]) + if (f1->memb[mt] && f2->memb[mt]) break; - if(!cmp) { - if(f1->memb[mt]) + if (!cmp) { + if (f1->memb[mt]) cmp = -1; - else if(f2->memb[mt]) + else if (f2->memb[mt]) cmp = 1; - } - } END_MEMBERS; - assert(cmp || out_mt=H5FD_MEM_NTYPES) + } + } + END_MEMBERS; + assert(cmp || out_mt < H5FD_MEM_NTYPES); + if (out_mt >= H5FD_MEM_NTYPES) return cmp; return H5FDcmp(f1->memb[out_mt], f2->memb[out_mt]); } - /*------------------------------------------------------------------------- * Function: H5FD_multi_query * @@ -1181,21 +1190,20 @@ static herr_t H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) { /* Shut compiler up */ - _f=_f; + _f = _f; /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_USE_ALLOC_SIZE; /* OK just pass the allocation size to the alloc callback */ - *flags |= H5FD_FEAT_PAGED_AGGR; /* OK special file space mapping for paged aggregation */ - } /* end if */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_USE_ALLOC_SIZE; /* OK just pass the allocation size to the alloc callback */ + *flags |= H5FD_FEAT_PAGED_AGGR; /* OK special file space mapping for paged aggregation */ + } /* end if */ - return(0); + return (0); } /* end H5FD_multi_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_get_type_map * @@ -1212,15 +1220,14 @@ H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) static herr_t H5FD_multi_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) { - const H5FD_multi_t *file = (const H5FD_multi_t*)_file; + const H5FD_multi_t *file = (const H5FD_multi_t *)_file; /* Copy file's free space type mapping */ memcpy(type_map, file->fa.memb_map, sizeof(file->fa.memb_map)); - return(0); + return (0); } /* end H5FD_multi_get_type_map() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_get_eoa * @@ -1235,22 +1242,14 @@ H5FD_multi_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * If the TYPE is H5FD_MEM_DEFAULT, simply find the biggest - * EOA of individual file because the EOA for the whole file - * is meaningless. - * *------------------------------------------------------------------------- */ static haddr_t H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) { - const H5FD_multi_t *file = (const H5FD_multi_t*)_file; - haddr_t eoa = 0; - static const char *func="H5FD_multi_get_eoa"; /* Function Name for error reporting */ + const H5FD_multi_t *file = (const H5FD_multi_t *)_file; + haddr_t eoa = 0; + static const char * func = "H5FD_multi_get_eoa"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1261,65 +1260,72 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) * Here the code finds the biggest EOA for individual file if * the query is for TYPE == H5FD_MEM_DEFAULT. */ - if(H5FD_MEM_DEFAULT == type) { - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + if (H5FD_MEM_DEFAULT == type) { + UNIQUE_MEMBERS (file->fa.memb_map, mt) { haddr_t memb_eoa; - if (file->memb[mt]) { + if (file->memb[mt]) { /* Retrieve EOA */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { memb_eoa = H5FDget_eoa(file->memb[mt], mt); - } H5E_END_TRY; - - if(HADDR_UNDEF == memb_eoa) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", HADDR_UNDEF) - if(memb_eoa>0) - memb_eoa += file->fa.memb_addr[mt]; - } else if(file->fa.relax) { - /* - * The member is not open yet (maybe it doesn't exist). Make the - * best guess about the end-of-file. - */ - memb_eoa = file->memb_next[mt]; - assert(HADDR_UNDEF != memb_eoa); - } else { + } + H5E_END_TRY; + + if (HADDR_UNDEF == memb_eoa) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", + HADDR_UNDEF) if (memb_eoa > 0) memb_eoa += file->fa.memb_addr[mt]; + } + else if (file->fa.relax) { + /* + * The member is not open yet (maybe it doesn't exist). Make the + * best guess about the end-of-file. + */ + memb_eoa = file->memb_next[mt]; + assert(HADDR_UNDEF != memb_eoa); + } + else { H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF) - } + } - if(memb_eoa > eoa) + if (memb_eoa > eoa) eoa = memb_eoa; - } END_MEMBERS; - } else { + } + END_MEMBERS; + } + else { H5FD_mem_t mmt = file->fa.memb_map[type]; - if(H5FD_MEM_DEFAULT == mmt) + if (H5FD_MEM_DEFAULT == mmt) mmt = type; - if(file->memb[mmt]) { - H5E_BEGIN_TRY { - eoa = H5FDget_eoa(file->memb[mmt], mmt); - } H5E_END_TRY; - - if(HADDR_UNDEF == eoa) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", HADDR_UNDEF) - if(eoa > 0) - eoa += file->fa.memb_addr[mmt]; - } else if(file->fa.relax) { - /* - * The member is not open yet (maybe it doesn't exist). Make the - * best guess about the end-of-file. - */ - eoa = file->memb_next[mmt]; - assert(HADDR_UNDEF != eoa); - } else { + if (file->memb[mmt]) { + H5E_BEGIN_TRY + { + eoa = H5FDget_eoa(file->memb[mmt], mmt); + } + H5E_END_TRY; + + if (HADDR_UNDEF == eoa) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", + HADDR_UNDEF) if (eoa > 0) eoa += file->fa.memb_addr[mmt]; + } + else if (file->fa.relax) { + /* + * The member is not open yet (maybe it doesn't exist). Make the + * best guess about the end-of-file. + */ + eoa = file->memb_next[mmt]; + assert(HADDR_UNDEF != eoa); + } + else { H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF) - } + } } return eoa; } /* end H5FD_multi_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_set_eoa * @@ -1335,33 +1341,22 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * Raymond Lu - * 10 January 2007 - * EOA for the whole file is discarded because it's meaningless - * for MULTI file. This function only sets eoa for individual - * file. - * - * Raymond Lu - * 21 June 2011 - * Backward compatibility of EOA. Please the comment in the - * code. *------------------------------------------------------------------------- */ static herr_t H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mmt; - herr_t status; - static const char *func="H5FD_multi_set_eoa"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_mem_t mmt; + herr_t status; + static const char *func = "H5FD_multi_set_eoa"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); mmt = file->fa.memb_map[type]; - if(H5FD_MEM_DEFAULT == mmt) { - if(H5FD_MEM_DEFAULT == type) + if (H5FD_MEM_DEFAULT == mmt) { + if (H5FD_MEM_DEFAULT == type) mmt = H5FD_MEM_SUPER; else mmt = type; @@ -1377,22 +1372,24 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) * address, the EOAs of v1.6 and v1.8 files are the same. It won't cause * any trouble. (Please see Issue 2598 in Jira) SLU - 2011/6/21 */ - if(H5FD_MEM_SUPER == mmt && file->memb_eoa[H5FD_MEM_SUPER] > 0 && eoa > (file->memb_next[H5FD_MEM_SUPER] / 2)) + if (H5FD_MEM_SUPER == mmt && file->memb_eoa[H5FD_MEM_SUPER] > 0 && + eoa > (file->memb_next[H5FD_MEM_SUPER] / 2)) return 0; assert(eoa >= file->fa.memb_addr[mmt]); assert(eoa < file->memb_next[mmt]); - H5E_BEGIN_TRY { - status = H5FDset_eoa(file->memb[mmt], mmt, (eoa - file->fa.memb_addr[mmt])); - } H5E_END_TRY; - if(status < 0) + H5E_BEGIN_TRY + { + status = H5FDset_eoa(file->memb[mmt], mmt, (eoa - file->fa.memb_addr[mmt])); + } + H5E_END_TRY; + if (status < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1) - return 0; + return 0; } /* end H5FD_multi_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_get_eof * @@ -1413,71 +1410,78 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) static haddr_t H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) { - const H5FD_multi_t *file = (const H5FD_multi_t*)_file; - haddr_t eof = 0; - static const char *func="H5FD_multi_get_eof"; /* Function Name for error reporting */ + const H5FD_multi_t *file = (const H5FD_multi_t *)_file; + haddr_t eof = 0; + static const char * func = "H5FD_multi_get_eof"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - if(H5FD_MEM_DEFAULT == type) { - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + if (H5FD_MEM_DEFAULT == type) { + UNIQUE_MEMBERS (file->fa.memb_map, mt) { haddr_t tmp_eof; - if(file->memb[mt]) { + if (file->memb[mt]) { /* Retrieve EOF */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_eof = H5FDget_eof(file->memb[mt], type); - } H5E_END_TRY; + } + H5E_END_TRY; - if(HADDR_UNDEF == tmp_eof) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF) - if(tmp_eof > 0) - tmp_eof += file->fa.memb_addr[mt]; - } else if(file->fa.relax) { + if (HADDR_UNDEF == tmp_eof) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", + HADDR_UNDEF) if (tmp_eof > 0) tmp_eof += file->fa.memb_addr[mt]; + } + else if (file->fa.relax) { /* * The member is not open yet (maybe it doesn't exist). Make the * best guess about the end-of-file. */ tmp_eof = file->memb_next[mt]; assert(HADDR_UNDEF != tmp_eof); - } else { + } + else { H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF) } - if(tmp_eof > eof) + if (tmp_eof > eof) eof = tmp_eof; - } END_MEMBERS; - } else { + } + END_MEMBERS; + } + else { H5FD_mem_t mmt = file->fa.memb_map[type]; - if(H5FD_MEM_DEFAULT == mmt) + if (H5FD_MEM_DEFAULT == mmt) mmt = type; - if(file->memb[mmt]) { + if (file->memb[mmt]) { /* Retrieve EOF */ - H5E_BEGIN_TRY { - eof = H5FDget_eof(file->memb[mmt], mmt); - } H5E_END_TRY; - - if(HADDR_UNDEF == eof) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF) - if(eof > 0) - eof += file->fa.memb_addr[mmt]; - } else if(file->fa.relax) { - /* - * The member is not open yet (maybe it doesn't exist). Make the - * best guess about the end-of-file. - */ - eof = file->memb_next[mmt]; - assert(HADDR_UNDEF != eof); - } else { + H5E_BEGIN_TRY + { + eof = H5FDget_eof(file->memb[mmt], mmt); + } + H5E_END_TRY; + + if (HADDR_UNDEF == eof) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", + HADDR_UNDEF) if (eof > 0) eof += file->fa.memb_addr[mmt]; + } + else if (file->fa.relax) { + /* + * The member is not open yet (maybe it doesn't exist). Make the + * best guess about the end-of-file. + */ + eof = file->memb_next[mmt]; + assert(HADDR_UNDEF != eof); + } + else { H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF) - } + } } return eof; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_get_handle * @@ -1491,24 +1495,24 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) *------------------------------------------------------------------------- */ static herr_t -H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) +H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - H5FD_multi_t *file = (H5FD_multi_t *)_file; - H5FD_mem_t type, mmt; - static const char *func="H5FD_multi_get_handle"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_mem_t type, mmt; + static const char *func = "H5FD_multi_get_handle"; /* Function Name for error reporting */ /* Get data type for multi driver */ - if(H5Pget_multi_type(fapl, &type) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't get data type for multi driver", -1) - if(type=H5FD_MEM_NTYPES) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "data type is out of range", -1) - mmt = file->fa.memb_map[type]; - if(H5FD_MEM_DEFAULT==mmt) mmt = type; + if (H5Pget_multi_type(fapl, &type) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't get data type for multi driver", + -1) if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "data type is out of range", -1) mmt = + file->fa.memb_map[type]; + if (H5FD_MEM_DEFAULT == mmt) + mmt = type; return (H5FDget_vfd_handle(file->memb[mmt], fapl, file_handle)); } - /*------------------------------------------------------------------------- * Function: H5FD_multi_alloc * @@ -1526,44 +1530,45 @@ H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) static haddr_t H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mmt; - haddr_t addr; - static const char *func="H5FD_multi_alloc"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_mem_t mmt; + haddr_t addr; + static const char *func = "H5FD_multi_alloc"; /* Function Name for error reporting */ mmt = file->fa.memb_map[type]; - if (H5FD_MEM_DEFAULT==mmt) mmt = type; + if (H5FD_MEM_DEFAULT == mmt) + mmt = type; /* XXX: NEED to work on this again */ - if(file->pub.paged_aggr) { - ALL_MEMBERS(mt) { - if(file->memb[mt]) + if (file->pub.paged_aggr) { + ALL_MEMBERS (mt) { + if (file->memb[mt]) file->memb[mt]->paged_aggr = file->pub.paged_aggr; - } END_MEMBERS; + } + END_MEMBERS; } - if (HADDR_UNDEF==(addr=H5FDalloc(file->memb[mmt], mmt, dxpl_id, size))) + if (HADDR_UNDEF == (addr = H5FDalloc(file->memb[mmt], mmt, dxpl_id, size))) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF) - addr += file->fa.memb_addr[mmt]; + addr += file->fa.memb_addr[mmt]; -/*#ifdef TMP - if ( addr + size > file->eoa ) { + /*#ifdef TMP + if ( addr + size > file->eoa ) { - if ( H5FD_multi_set_eoa(_file, addr + size) < 0 ) { + if ( H5FD_multi_set_eoa(_file, addr + size) < 0 ) { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, \ - "can't set eoa", HADDR_UNDEF) - } - } -#else - if ( addr + size > file->eoa ) - file->eoa = addr + size; -#endif */ + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, \ + "can't set eoa", HADDR_UNDEF) + } + } + #else + if ( addr + size > file->eoa ) + file->eoa = addr + size; + #endif */ return addr; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_free * @@ -1581,21 +1586,21 @@ H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) static herr_t H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mmt; + H5FD_multi_t *file = (H5FD_multi_t *)_file; + H5FD_mem_t mmt; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); mmt = file->fa.memb_map[type]; - if (H5FD_MEM_DEFAULT==mmt) mmt = type; + if (H5FD_MEM_DEFAULT == mmt) + mmt = type; - assert(addr>=file->fa.memb_addr[mmt]); - assert(addr+size<=file->memb_next[mmt]); - return H5FDfree(file->memb[mmt], mmt, dxpl_id, addr-file->fa.memb_addr[mmt], size); + assert(addr >= file->fa.memb_addr[mmt]); + assert(addr + size <= file->memb_next[mmt]); + return H5FDfree(file->memb[mmt], mmt, dxpl_id, addr - file->fa.memb_addr[mmt], size); } - /*------------------------------------------------------------------------- * Function: H5FD_multi_read * @@ -1614,37 +1619,35 @@ H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi *------------------------------------------------------------------------- */ static herr_t -H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, void *_buf/*out*/) +H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *_buf /*out*/) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mt, mmt, hi = H5FD_MEM_DEFAULT; - haddr_t start_addr = 0; + H5FD_multi_t *file = (H5FD_multi_t *)_file; + H5FD_mem_t mt, mmt, hi = H5FD_MEM_DEFAULT; + haddr_t start_addr = 0; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Find the file to which this address belongs */ - for(mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - mmt = file->fa.memb_map[mt]; - if(H5FD_MEM_DEFAULT == mmt) + for (mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + mmt = file->fa.memb_map[mt]; + if (H5FD_MEM_DEFAULT == mmt) mmt = mt; - assert(mmt > 0 && mmt < H5FD_MEM_NTYPES); + assert(mmt > 0 && mmt < H5FD_MEM_NTYPES); - if(file->fa.memb_addr[mmt] > addr) + if (file->fa.memb_addr[mmt] > addr) continue; - if(file->fa.memb_addr[mmt] >= start_addr) { - start_addr = file->fa.memb_addr[mmt]; - hi = mmt; - } /* end if */ - } /* end for */ + if (file->fa.memb_addr[mmt] >= start_addr) { + start_addr = file->fa.memb_addr[mmt]; + hi = mmt; + } /* end if */ + } /* end for */ assert(hi > 0); /* Read from that member */ return H5FDread(file->memb[hi], type, dxpl_id, addr - start_addr, size, _buf); } /* end H5FD_multi_read() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_write * @@ -1662,37 +1665,35 @@ H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, *------------------------------------------------------------------------- */ static herr_t -H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *_buf) +H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mt, mmt, hi = H5FD_MEM_DEFAULT; - haddr_t start_addr = 0; + H5FD_multi_t *file = (H5FD_multi_t *)_file; + H5FD_mem_t mt, mmt, hi = H5FD_MEM_DEFAULT; + haddr_t start_addr = 0; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Find the file to which this address belongs */ - for(mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - mmt = file->fa.memb_map[mt]; - if(H5FD_MEM_DEFAULT == mmt) + for (mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + mmt = file->fa.memb_map[mt]; + if (H5FD_MEM_DEFAULT == mmt) mmt = mt; - assert(mmt > 0 && mmt 0 && mmt < H5FD_MEM_NTYPES); - if(file->fa.memb_addr[mmt] > addr) + if (file->fa.memb_addr[mmt] > addr) continue; - if(file->fa.memb_addr[mmt] >= start_addr) { - start_addr = file->fa.memb_addr[mmt]; - hi = mmt; - } /* end if */ - } /* end for */ + if (file->fa.memb_addr[mmt] >= start_addr) { + start_addr = file->fa.memb_addr[mmt]; + hi = mmt; + } /* end if */ + } /* end for */ assert(hi > 0); /* Write to that member */ return H5FDwrite(file->memb[hi], type, dxpl_id, addr - start_addr, size, _buf); } /* end H5FD_multi_write() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_flush * @@ -1710,10 +1711,10 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, static herr_t H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mt; - int nerrors=0; - static const char *func="H5FD_multi_flush"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_mem_t mt; + int nerrors = 0; + static const char *func = "H5FD_multi_flush"; /* Function Name for error reporting */ #if 0 H5FD_mem_t mmt; @@ -1751,20 +1752,22 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) H5Eclear2(H5E_DEFAULT); /* Flush each file */ - for (mt=H5FD_MEM_SUPER; mtmemb[mt]) { - H5E_BEGIN_TRY { - if (H5FDflush(file->memb[mt],dxpl_id,closing)<0) nerrors++; - } H5E_END_TRY; - } + for (mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (file->memb[mt]) { + H5E_BEGIN_TRY + { + if (H5FDflush(file->memb[mt], dxpl_id, closing) < 0) + nerrors++; + } + H5E_END_TRY; + } } if (nerrors) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1) - return 0; + return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_truncate * @@ -1781,30 +1784,31 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) static herr_t H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mt; - int nerrors=0; - static const char *func="H5FD_multi_truncate"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_mem_t mt; + int nerrors = 0; + static const char *func = "H5FD_multi_truncate"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Truncate each file */ - for(mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - if(file->memb[mt]) { - H5E_BEGIN_TRY { - if(H5FDtruncate(file->memb[mt], dxpl_id, closing) < 0) + for (mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (file->memb[mt]) { + H5E_BEGIN_TRY + { + if (H5FDtruncate(file->memb[mt], dxpl_id, closing) < 0) nerrors++; - } H5E_END_TRY; - } + } + H5E_END_TRY; + } } - if(nerrors) + if (nerrors) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error truncating member files", -1) - return 0; + return 0; } /* end H5FD_multi_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_lock * @@ -1823,46 +1827,49 @@ H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) static herr_t H5FD_multi_lock(H5FD_t *_file, hbool_t rw) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - int nerrors = 0; - H5FD_mem_t out_mt; - static const char *func="H5FD_multi_unlock"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + int nerrors = 0; + H5FD_mem_t out_mt; + static const char *func = "H5FD_multi_unlock"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Lock all member files */ - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { out_mt = mt; - if(file->memb[mt]) { - H5E_BEGIN_TRY { - if(H5FDlock(file->memb[mt], rw) < 0) { + if (file->memb[mt]) { + H5E_BEGIN_TRY + { + if (H5FDlock(file->memb[mt], rw) < 0) { nerrors++; break; } /* end if */ - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ - } END_MEMBERS; + } + END_MEMBERS; /* Try to unlock the member files that are locked before error is encountered */ - if(nerrors) { + if (nerrors) { H5FD_mem_t k; - for(k = H5FD_MEM_DEFAULT; k < out_mt; k = (H5FD_mem_t)(k + 1)) { - H5E_BEGIN_TRY { - if(H5FDunlock(file->memb[k]) < 0) + for (k = H5FD_MEM_DEFAULT; k < out_mt; k = (H5FD_mem_t)(k + 1)) { + H5E_BEGIN_TRY + { + if (H5FDunlock(file->memb[k]) < 0) nerrors++; - } H5E_END_TRY; + } + H5E_END_TRY; } /* end for */ - } /* end if */ + } /* end if */ - if(nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error locking member files", -1) - return 0; + if (nerrors) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error locking member files", -1) return 0; } /* H5FD_multi_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD_multi_unlock * @@ -1880,26 +1887,26 @@ H5FD_multi_lock(H5FD_t *_file, hbool_t rw) static herr_t H5FD_multi_unlock(H5FD_t *_file) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - int nerrors=0; - static const char *func="H5FD_multi_unlock"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + int nerrors = 0; + static const char *func = "H5FD_multi_unlock"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - ALL_MEMBERS(mt) { - if(file->memb[mt]) - if(H5FDunlock(file->memb[mt]) < 0) - nerrors++; - } END_MEMBERS; + ALL_MEMBERS (mt) { + if (file->memb[mt]) + if (H5FDunlock(file->memb[mt]) < 0) + nerrors++; + } + END_MEMBERS; - if(nerrors) + if (nerrors) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error unlocking member files", -1) - return 0; + return 0; } /* H5FD_multi_unlock() */ - /*------------------------------------------------------------------------- * Function: compute_next * @@ -1921,27 +1928,29 @@ compute_next(H5FD_multi_t *file) /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - ALL_MEMBERS(mt) { - file->memb_next[mt] = HADDR_UNDEF; - } END_MEMBERS; - - UNIQUE_MEMBERS(file->fa.memb_map, mt1) { - UNIQUE_MEMBERS2(file->fa.memb_map, mt2) { - if (file->fa.memb_addr[mt1]fa.memb_addr[mt2] && - (HADDR_UNDEF==file->memb_next[mt1] || - file->memb_next[mt1]>file->fa.memb_addr[mt2])) { - file->memb_next[mt1] = file->fa.memb_addr[mt2]; - } - } END_MEMBERS; - if (HADDR_UNDEF==file->memb_next[mt1]) { - file->memb_next[mt1] = HADDR_MAX; /*last member*/ - } - } END_MEMBERS; + ALL_MEMBERS (mt) { + file->memb_next[mt] = HADDR_UNDEF; + } + END_MEMBERS; + + UNIQUE_MEMBERS (file->fa.memb_map, mt1) { + UNIQUE_MEMBERS2(file->fa.memb_map, mt2) + { + if (file->fa.memb_addr[mt1] < file->fa.memb_addr[mt2] && + (HADDR_UNDEF == file->memb_next[mt1] || file->memb_next[mt1] > file->fa.memb_addr[mt2])) { + file->memb_next[mt1] = file->fa.memb_addr[mt2]; + } + } + END_MEMBERS; + if (HADDR_UNDEF == file->memb_next[mt1]) { + file->memb_next[mt1] = HADDR_MAX; /*last member*/ + } + } + END_MEMBERS; return 0; } - /*------------------------------------------------------------------------- * Function: open_members * @@ -1962,19 +1971,19 @@ compute_next(H5FD_multi_t *file) * tmp in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static int open_members(H5FD_multi_t *file) { - char tmp[H5FD_MULT_MAX_FILE_NAME_LEN]; - int nerrors = 0; - static const char *func="(H5FD_multi)open_members"; /* Function Name for error reporting */ + char tmp[H5FD_MULT_MAX_FILE_NAME_LEN]; + int nerrors = 0; + static const char *func = "(H5FD_multi)open_members"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - UNIQUE_MEMBERS(file->fa.memb_map, mt) { - if(file->memb[mt]) + UNIQUE_MEMBERS (file->fa.memb_map, mt) { + if (file->memb[mt]) continue; /*already open*/ assert(file->fa.memb_name[mt]); /* Note: This truncates the user's filename down to only sizeof(tmp) @@ -1983,22 +1992,24 @@ open_members(H5FD_multi_t *file) sprintf(tmp, file->fa.memb_name[mt], file->name); tmp[sizeof(tmp) - 1] = '\0'; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file->memb[mt] = H5FDopen(tmp, file->flags, file->fa.memb_fapl[mt], HADDR_UNDEF); - } H5E_END_TRY; - if(!file->memb[mt]) { - if(!file->fa.relax || (file->flags & H5F_ACC_RDWR)) - nerrors++; } - } END_MEMBERS; + H5E_END_TRY; + if (!file->memb[mt]) { + if (!file->fa.relax || (file->flags & H5F_ACC_RDWR)) + nerrors++; + } + } + END_MEMBERS; if (nerrors) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1) - return 0; + return 0; } -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - #ifdef _H5private_H /* * This is not related to the functionality of the driver code. diff --git a/src/H5FDmulti.h b/src/H5FDmulti.h index 0bd5718..7385a69 100644 --- a/src/H5FDmulti.h +++ b/src/H5FDmulti.h @@ -20,24 +20,20 @@ #ifndef H5FDmulti_H #define H5FDmulti_H -#define H5FD_MULTI (H5FD_multi_init()) +#define H5FD_MULTI (H5FD_multi_init()) #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_multi_init(void); -H5_DLL herr_t H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, - const hid_t *memb_fapl, const char * const *memb_name, - const haddr_t *memb_addr, hbool_t relax); -H5_DLL herr_t H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, - hid_t *memb_fapl/*out*/, char **memb_name/*out*/, - haddr_t *memb_addr/*out*/, hbool_t *relax/*out*/); -H5_DLL herr_t H5Pset_fapl_split(hid_t fapl, const char *meta_ext, - hid_t meta_plist_id, const char *raw_ext, - hid_t raw_plist_id); +H5_DLL hid_t H5FD_multi_init(void); +H5_DLL herr_t H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_fapl, + const char *const *memb_name, const haddr_t *memb_addr, hbool_t relax); +H5_DLL herr_t H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl /*out*/, + char **memb_name /*out*/, haddr_t *memb_addr /*out*/, hbool_t *relax /*out*/); +H5_DLL herr_t H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, const char *raw_ext, + hid_t raw_plist_id); #ifdef __cplusplus } #endif #endif - diff --git a/src/H5FDpkg.h b/src/H5FDpkg.h index 903ce06..a7bc6c6 100644 --- a/src/H5FDpkg.h +++ b/src/H5FDpkg.h @@ -27,7 +27,7 @@ #define _H5FDpkg_H /* Get package's private header */ -#include "H5FDprivate.h" /* File drivers */ +#include "H5FDprivate.h" /* File drivers */ /* Other private headers needed by this file */ @@ -35,28 +35,26 @@ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL haddr_t H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *align_addr, hsize_t *align_size); -H5_DLL herr_t H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size); +H5_DLL haddr_t H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *align_addr, + hsize_t *align_size); +H5_DLL herr_t H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size); /* Testing functions */ #ifdef H5FD_TESTING H5_DLL hbool_t H5FD__supports_swmr_test(const char *vfd_name); -H5_DLL herr_t H5FD__vfd_swmr_reader_md_test(H5FD_t *file, unsigned num_entries, H5FD_vfd_swmr_idx_entry_t index[]); +H5_DLL herr_t H5FD__vfd_swmr_reader_md_test(H5FD_t *file, unsigned num_entries, + H5FD_vfd_swmr_idx_entry_t index[]); #endif /* H5FD_TESTING */ #endif /* _H5FDpkg_H */ - diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index b1d8708..b11f585 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -22,69 +22,64 @@ #include "H5FDpublic.h" /* Private headers needed by this file */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5Pprivate.h" /* Property lists */ /* * The MPI drivers are needed because there are * places where we check for things that aren't handled by these drivers. */ -#include "H5FDmpi.h" /* MPI-based file drivers */ - +#include "H5FDmpi.h" /* MPI-based file drivers */ /**************************/ /* Library Private Macros */ /**************************/ /* Length of filename buffer */ -#define H5FD_MAX_FILENAME_LEN 1024 +#define H5FD_MAX_FILENAME_LEN 1024 -/* - * VFD SWMR +/* + * VFD SWMR */ /* Metadata file header */ -#define H5FD_MD_HEADER_OFF 0 /* Header offset in the metadata file */ -#define H5FD_MD_HEADER_MAGIC "VHDR" /* Header magic */ -#define H5FD_SIZEOF_CHKSUM 4 /* Size of checksum */ +#define H5FD_MD_HEADER_OFF 0 /* Header offset in the metadata file */ +#define H5FD_MD_HEADER_MAGIC "VHDR" /* Header magic */ +#define H5FD_SIZEOF_CHKSUM 4 /* Size of checksum */ /* Size of the header in the metadata file */ -#define H5FD_MD_HEADER_SIZE \ - ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + 4 /* Page size */ \ - + 8 /* Tick number */ \ - + 8 /* Index offset */ \ - + 8 /* Index length number */ \ - + H5FD_SIZEOF_CHKSUM /* Metadata header checksum */ \ +#define H5FD_MD_HEADER_SIZE \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + 4 /* Page size */ \ + + 8 /* Tick number */ \ + + 8 /* Index offset */ \ + + 8 /* Index length number */ \ + + H5FD_SIZEOF_CHKSUM /* Metadata header checksum */ \ ) /* Size of an index entry in the metadata file */ -#define H5FD_MD_INDEX_ENTRY_SIZE \ - ( \ - 4 /* HDF5 file page offset */ \ - + 4 /* Metadata file page offset */ \ - + 4 /* Length */ \ - + H5FD_SIZEOF_CHKSUM /* Index entry checksum */ \ +#define H5FD_MD_INDEX_ENTRY_SIZE \ + (4 /* HDF5 file page offset */ \ + + 4 /* Metadata file page offset */ \ + + 4 /* Length */ \ + + H5FD_SIZEOF_CHKSUM /* Index entry checksum */ \ ) /* Metadata file index magic */ -#define H5FD_MD_INDEX_MAGIC "VIDX" /* Index magic */ +#define H5FD_MD_INDEX_MAGIC "VIDX" /* Index magic */ /* Size of the metadata file index */ -#define H5FD_MD_INDEX_SIZE(N) /* N is number of entries in index */ \ - ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + 8 /* Tick num */ \ - + 4 /* Number of entries */ \ - + (N * H5FD_MD_INDEX_ENTRY_SIZE) /* Index entries */ \ - + H5FD_SIZEOF_CHKSUM /* Metadata index checksum */ \ +#define H5FD_MD_INDEX_SIZE(N) /* N is number of entries in index */ \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + 8 /* Tick num */ \ + + 4 /* Number of entries */ \ + + (N * H5FD_MD_INDEX_ENTRY_SIZE) /* Index entries */ \ + + H5FD_SIZEOF_CHKSUM /* Metadata index checksum */ \ ) /* Retries for metadata file */ -#define H5FD_VFD_SWMR_MD_FILE_RETRY_MAX 50 /* Maximum retries when opening the MD file */ -#define H5FD_VFD_SWMR_MD_LOAD_RETRY_MAX 120 /* Maximum retries when trying to load the MD file header and index */ -#define H5FD_VFD_SWMR_MD_INDEX_RETRY_MAX 5 /* Maximum retries when deserializing the MD file index */ - - +#define H5FD_VFD_SWMR_MD_FILE_RETRY_MAX 50 /* Maximum retries when opening the MD file */ +#define H5FD_VFD_SWMR_MD_LOAD_RETRY_MAX \ + 120 /* Maximum retries when trying to load the MD file header and index */ +#define H5FD_VFD_SWMR_MD_INDEX_RETRY_MAX 5 /* Maximum retries when deserializing the MD file index */ /* Internal representation of metadata file index entry */ @@ -92,18 +87,18 @@ * * struct H5FD_vfd_swmr_idx_entry_t * - * Indicies into the VFD SWMR metadata file are maintained in arrays of + * Indicies into the VFD SWMR metadata file are maintained in arrays of * instances of H5FD_vfd_swmr_index_t. * * The fields of H5FD_vfd_swmr_idx_entry_t are discussed below. - * + * * hdf5_page_offset: Unsigned 64-bit value containing the base address of the * metadata page, or multi page metadata entry in the HDF5 * file IN PAGES. * * To obtain byte offset, multiply this value by the page size. * - * md_file_page_offset: Unsigned 64-bit value containing the base address of + * md_file_page_offset: Unsigned 64-bit value containing the base address of * the metadata page, or multi page metadata entry in the metadata * file IN PAGES. * @@ -115,19 +110,19 @@ * chksum: Checksum for the metadata page or multi-page metadata entry. * For the VFD SWMR writer, this value is undefined until the * referenced entry has been written to the metadata file. - * + * * entry_ptr: Used by the VFD SWMR writer only. * * For the VFD SWMR reader, this field should always be NULL. - * If the referenced metadata page or multi-page metadata - * entry was modified in the current tick, this field points to + * If the referenced metadata page or multi-page metadata + * entry was modified in the current tick, this field points to * a buffer in the page buffer containing its value. - * This field is used by the metadata file creation/update code + * This field is used by the metadata file creation/update code * to access the metadata pages or multi-page metadata entries * so that their current values can be copied into the metadata * file. After this copy, this field should be set to NULL. * - * tick_of_last_change: Number of the last tick in which this index entry + * tick_of_last_change: Number of the last tick in which this index entry * was changed. * * Used by the VFD SWMR writer only. @@ -136,19 +131,19 @@ * * clean: Used by the VFD SWMR writer only. * - * Set to TRUE whenever the referenced metadata page or + * Set to TRUE whenever the referenced metadata page or * multi-page metadata entry is written to the HDF5 file. * Set to FALSE whenever it is marked dirty in the page buffer. * - * tick_of_last_flush: Number of the tick in which this entry was last + * tick_of_last_flush: Number of the tick in which this entry was last * written to the lower file or zero if it has never been flushed. * * Used by the VFD SWMR writer only. * * For the VFD SWMR reader, this field should always be 0. - * + * * delayed_flush: If the flush of the referenced metadata page or multi-page - * metadata entry must be delayed, the earliest tick in which + * metadata entry must be delayed, the earliest tick in which * it may be flushed, or zero if there is no such constraint. * * Used by the VFD SWMR writer only. @@ -169,17 +164,17 @@ *---------------------------------------------------------------------------- */ typedef struct H5FD_vfd_swmr_idx_entry_t { - uint64_t hdf5_page_offset; - uint64_t md_file_page_offset; - uint32_t length; + uint64_t hdf5_page_offset; + uint64_t md_file_page_offset; + uint32_t length; uint32_t chksum; - void *entry_ptr; - uint64_t tick_of_last_change; - hbool_t clean; - uint64_t tick_of_last_flush; - uint64_t delayed_flush; - bool moved_to_lower_file; - bool garbage; + void * entry_ptr; + uint64_t tick_of_last_change; + hbool_t clean; + uint64_t tick_of_last_flush; + uint64_t delayed_flush; + bool moved_to_lower_file; + bool garbage; } H5FD_vfd_swmr_idx_entry_t; /* @@ -190,26 +185,25 @@ typedef struct H5FD_vfd_swmr_idx_entry_t { * entries: The array of index entries */ typedef struct H5FD_vfd_swmr_md_index { - uint64_t tick_num; - uint32_t num_entries; - H5FD_vfd_swmr_idx_entry_t *entries; + uint64_t tick_num; + uint32_t num_entries; + H5FD_vfd_swmr_idx_entry_t *entries; } H5FD_vfd_swmr_md_index; - /* * fs_page_size: Size of pages in both the HDF5 file and the metadata file IN BYTES * tick_num: Sequence number of the current tick. - * Initialized to zero on file creation/open, and incremented by the + * Initialized to zero on file creation/open, and incremented by the * VFD SWMR writer at the end of each tick. * index_offset: The offset of the current metadata file index in the metadata file * IN BYTES. * index_length: The length of the current metadata file index IN BYTES. */ typedef struct H5FD_vfd_swmr_md_header { - uint32_t fs_page_size; - uint64_t tick_num; - uint64_t index_offset; - size_t index_length; + uint32_t fs_page_size; + uint64_t tick_num; + uint64_t index_offset; + size_t index_length; } H5FD_vfd_swmr_md_header; /* Lookup the shadow-index entry corresponding to page number `target_page` @@ -225,8 +219,8 @@ typedef struct H5FD_vfd_swmr_md_header { * is false. */ static inline H5FD_vfd_swmr_idx_entry_t * -vfd_swmr_pageno_to_mdf_idx_entry(H5FD_vfd_swmr_idx_entry_t *idx, - uint32_t nentries, uint64_t target_page, bool reuse_garbage) +vfd_swmr_pageno_to_mdf_idx_entry(H5FD_vfd_swmr_idx_entry_t *idx, uint32_t nentries, uint64_t target_page, + bool reuse_garbage) { uint32_t top; uint32_t bottom; @@ -236,7 +230,7 @@ vfd_swmr_pageno_to_mdf_idx_entry(H5FD_vfd_swmr_idx_entry_t *idx, return NULL; bottom = 0; - top = nentries; + top = nentries; do { probe = (top + bottom) / 2; @@ -260,17 +254,17 @@ vfd_swmr_pageno_to_mdf_idx_entry(H5FD_vfd_swmr_idx_entry_t *idx, #ifdef H5_HAVE_PARALLEL /* ======== Temporary data transfer properties ======== */ /* Definitions for memory MPI type property */ -#define H5FD_MPI_XFER_MEM_MPI_TYPE_NAME "H5FD_mpi_mem_mpi_type" +#define H5FD_MPI_XFER_MEM_MPI_TYPE_NAME "H5FD_mpi_mem_mpi_type" /* Definitions for file MPI type property */ -#define H5FD_MPI_XFER_FILE_MPI_TYPE_NAME "H5FD_mpi_file_mpi_type" +#define H5FD_MPI_XFER_FILE_MPI_TYPE_NAME "H5FD_mpi_file_mpi_type" /* Sub-class the H5FD_class_t to add more specific functions for MPI-based VFDs */ typedef struct H5FD_class_mpi_t { - H5FD_class_t super; /* Superclass information & methods */ - int (*get_rank)(const H5FD_t *file); /* Get the MPI rank of a process */ - int (*get_size)(const H5FD_t *file); /* Get the MPI size of a communicator */ - MPI_Comm (*get_comm)(const H5FD_t *file); /* Get the communicator for a file */ - herr_t (*get_mpi_info)(H5FD_t *file, void** mpi_info); /* get MPI_Info for a file */ + H5FD_class_t super; /* Superclass information & methods */ + int (*get_rank)(const H5FD_t *file); /* Get the MPI rank of a process */ + int (*get_size)(const H5FD_t *file); /* Get the MPI size of a communicator */ + MPI_Comm (*get_comm)(const H5FD_t *file); /* Get the communicator for a file */ + herr_t (*get_mpi_info)(H5FD_t *file, void **mpi_info); /* get MPI_Info for a file */ } H5FD_class_mpi_t; #endif @@ -280,46 +274,38 @@ typedef struct H5FD_class_mpi_t { /* File operations */ typedef enum { - OP_UNKNOWN = 0, /* Unknown last file operation */ - OP_READ = 1, /* Last file I/O operation was a read */ - OP_WRITE = 2 /* Last file I/O operation was a write */ + OP_UNKNOWN = 0, /* Unknown last file operation */ + OP_READ = 1, /* Last file I/O operation was a read */ + OP_WRITE = 2 /* Last file I/O operation was a write */ } H5FD_file_op_t; - /* Define structure to hold initial file image and other relevant information */ typedef struct { - void *buffer; - size_t size; + void * buffer; + size_t size; H5FD_file_image_callbacks_t callbacks; } H5FD_file_image_info_t; /* Define default file image info */ -#define H5FD_DEFAULT_FILE_IMAGE_INFO { \ - /* file image buffer */ NULL, \ - /* buffer size */ 0, \ - { /* Callbacks */ \ - /* image_malloc */ NULL, \ - /* image_memcpy */ NULL, \ - /* image_realloc */ NULL, \ - /* image_free */ NULL, \ - /* udata_copy */ NULL, \ - /* udata_free */ NULL, \ - /* udata */ NULL, \ - } \ -} +#define H5FD_DEFAULT_FILE_IMAGE_INFO \ + { \ + /* file image buffer */ NULL, /* buffer size */ 0, \ + { /* Callbacks */ \ + /* image_malloc */ NULL, /* image_memcpy */ NULL, /* image_realloc */ NULL, \ + /* image_free */ NULL, /* udata_copy */ NULL, /* udata_free */ NULL, /* udata */ NULL, \ + } \ + } /* Define structure to hold driver ID & info for FAPLs */ typedef struct { - hid_t driver_id; /* Driver's ID */ - const void *driver_info; /* Driver info, for open callbacks */ + hid_t driver_id; /* Driver's ID */ + const void *driver_info; /* Driver info, for open callbacks */ } H5FD_driver_prop_t; - /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ @@ -327,63 +313,59 @@ typedef struct { /* Forward declarations for prototype arguments */ struct H5F_t; -H5_DLL int H5FD_term_interface(void); +H5_DLL int H5FD_term_interface(void); H5_DLL herr_t H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr); H5_DLL H5FD_class_t *H5FD_get_class(hid_t id); -H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); -H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf); -H5_DLL herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf); -H5_DLL void *H5FD_fapl_get(H5FD_t *file); -H5_DLL herr_t H5FD_free_driver_info(hid_t driver_id, const void *driver_info); -H5_DLL hid_t H5FD_register(const void *cls, size_t size, hbool_t app_ref); -H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); -H5FD_t *H5FD_deduplicate(H5FD_t *, hid_t); -H5_DLL herr_t H5FD_close(H5FD_t *file); -H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); -H5_DLL herr_t H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/); -H5_DLL haddr_t H5FD_alloc(H5FD_t *file, H5FD_mem_t type, - struct H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); -H5_DLL herr_t H5FD_free(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, - haddr_t addr, hsize_t size); -H5_DLL htri_t H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, - haddr_t blk_end, hsize_t extra_requested); +H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); +H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name /*out*/, uint8_t *buf); +H5_DLL herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf); +H5_DLL void * H5FD_fapl_get(H5FD_t *file); +H5_DLL herr_t H5FD_free_driver_info(hid_t driver_id, const void *driver_info); +H5_DLL hid_t H5FD_register(const void *cls, size_t size, hbool_t app_ref); +H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +H5FD_t * H5FD_deduplicate(H5FD_t *, hid_t); +H5_DLL herr_t H5FD_close(H5FD_t *file); +H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); +H5_DLL herr_t H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/); +H5_DLL haddr_t H5FD_alloc(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, hsize_t size, haddr_t *frag_addr, + hsize_t *frag_size); +H5_DLL herr_t H5FD_free(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, haddr_t addr, hsize_t size); +H5_DLL htri_t H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, haddr_t blk_end, + hsize_t extra_requested); H5_DLL haddr_t H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type); -H5_DLL herr_t H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr); +H5_DLL herr_t H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr); H5_DLL haddr_t H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type); H5_DLL haddr_t H5FD_get_maxaddr(const H5FD_t *file); -H5_DLL herr_t H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags); -H5_DLL herr_t H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags); -H5_DLL herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map); -H5_DLL herr_t H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); -H5_DLL herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); -H5_DLL herr_t H5FD_flush(H5FD_t *file, hbool_t closing); -H5_DLL herr_t H5FD_truncate(H5FD_t *file, hbool_t closing); -H5_DLL herr_t H5FD_lock(H5FD_t *file, hbool_t rw); -H5_DLL herr_t H5FD_unlock(H5FD_t *file); -H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum); -H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle); -H5_DLL herr_t H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr); +H5_DLL herr_t H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags); +H5_DLL herr_t H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags); +H5_DLL herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map); +H5_DLL herr_t H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/); +H5_DLL herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); +H5_DLL herr_t H5FD_flush(H5FD_t *file, hbool_t closing); +H5_DLL herr_t H5FD_truncate(H5FD_t *file, hbool_t closing); +H5_DLL herr_t H5FD_lock(H5FD_t *file, hbool_t rw); +H5_DLL herr_t H5FD_unlock(H5FD_t *file); +H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum); +H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle); +H5_DLL herr_t H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr); H5_DLL haddr_t H5FD_get_base_addr(const H5FD_t *file); -H5_DLL herr_t H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged); -H5_DLL herr_t H5FD_get_driver_name(const H5FD_t *file, char **driver_name); +H5_DLL herr_t H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged); +H5_DLL herr_t H5FD_get_driver_name(const H5FD_t *file, char **driver_name); /* Function prototypes for VFD SWMR */ -H5_DLL int shadow_image_defer_free(struct H5F_shared_t *, - const H5FD_vfd_swmr_idx_entry_t *); -H5_DLL herr_t H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t read_index, - uint64_t *tick_ptr, uint32_t *num_entries_ptr, - H5FD_vfd_swmr_idx_entry_t index[]); +H5_DLL int shadow_image_defer_free(struct H5F_shared_t *, const H5FD_vfd_swmr_idx_entry_t *); +H5_DLL herr_t H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t read_index, uint64_t *tick_ptr, + uint32_t *num_entries_ptr, H5FD_vfd_swmr_idx_entry_t index[]); H5_DLL H5FD_vfd_swmr_idx_entry_t *vfd_swmr_enlarge_shadow_index(struct H5F_t *); -H5_DLL void H5FD_vfd_swmr_dump_status(H5FD_t *, uint64_t); -H5_DLL void H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file); -H5_DLL void H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *, uint64_t); +H5_DLL void H5FD_vfd_swmr_dump_status(H5FD_t *, uint64_t); +H5_DLL void H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file); +H5_DLL void H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *, uint64_t); /* Function prototypes for MPI based VFDs*/ #ifdef H5_HAVE_PARALLEL /* General routines */ H5_DLL haddr_t H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off); -H5_DLL herr_t H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/); +H5_DLL herr_t H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off /*out*/); #ifdef NOT_YET H5_DLL herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *file); H5_DLL herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *file); @@ -392,11 +374,10 @@ H5_DLL herr_t H5FD_set_mpio_atomicity(H5FD_t *file, hbool_t flag); H5_DLL herr_t H5FD_get_mpio_atomicity(H5FD_t *file, hbool_t *flag); /* Driver specific methods */ -H5_DLL int H5FD_mpi_get_rank(const H5FD_t *file); -H5_DLL int H5FD_mpi_get_size(const H5FD_t *file); +H5_DLL int H5FD_mpi_get_rank(const H5FD_t *file); +H5_DLL int H5FD_mpi_get_size(const H5FD_t *file); H5_DLL MPI_Comm H5FD_mpi_get_comm(const H5FD_t *_file); -H5_DLL herr_t H5FD_get_mpi_info(H5FD_t *file, void** file_info); +H5_DLL herr_t H5FD_get_mpi_info(H5FD_t *file, void **file_info); #endif /* H5_HAVE_PARALLEL */ #endif /* !_H5FDprivate_H */ - diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 520668b..996ae9b 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -19,13 +19,13 @@ #define _H5FDpublic_H #include "H5public.h" -#include "H5Fpublic.h" /*for H5F_close_degree_t */ +#include "H5Fpublic.h" /*for H5F_close_degree_t */ -#define H5_HAVE_VFL 1 /*define a convenient app feature test*/ -#define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ +#define H5_HAVE_VFL 1 /*define a convenient app feature test*/ +#define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ /* Types of allocation requests: see H5Fpublic.h */ -typedef enum H5F_mem_t H5FD_mem_t; +typedef enum H5F_mem_t H5FD_mem_t; /* Map "fractal heap" header blocks to 'ohdr' type file memory, since its * a fair amount of work to add a new kind of file memory and they are similar @@ -56,8 +56,8 @@ typedef enum H5F_mem_t H5FD_mem_t; * * -QAK */ -#define H5FD_MEM_FSPACE_HDR H5FD_MEM_OHDR -#define H5FD_MEM_FSPACE_SINFO H5FD_MEM_LHEAP +#define H5FD_MEM_FSPACE_HDR H5FD_MEM_OHDR +#define H5FD_MEM_FSPACE_SINFO H5FD_MEM_LHEAP /* Map "shared object header message" master table to 'ohdr' type file memory, * since its a fair amount of work to add a new kind of file memory and they are @@ -69,8 +69,8 @@ typedef enum H5F_mem_t H5FD_mem_t; * * -QAK */ -#define H5FD_MEM_SOHM_TABLE H5FD_MEM_OHDR -#define H5FD_MEM_SOHM_INDEX H5FD_MEM_BTREE +#define H5FD_MEM_SOHM_TABLE H5FD_MEM_OHDR +#define H5FD_MEM_SOHM_INDEX H5FD_MEM_BTREE /* Map "extensible array" header blocks to 'ohdr' type file memory, since its * a fair amount of work to add a new kind of file memory and they are similar @@ -87,11 +87,11 @@ typedef enum H5F_mem_t H5FD_mem_t; * * -QAK */ -#define H5FD_MEM_EARRAY_HDR H5FD_MEM_OHDR -#define H5FD_MEM_EARRAY_IBLOCK H5FD_MEM_OHDR -#define H5FD_MEM_EARRAY_SBLOCK H5FD_MEM_BTREE -#define H5FD_MEM_EARRAY_DBLOCK H5FD_MEM_LHEAP -#define H5FD_MEM_EARRAY_DBLK_PAGE H5FD_MEM_LHEAP +#define H5FD_MEM_EARRAY_HDR H5FD_MEM_OHDR +#define H5FD_MEM_EARRAY_IBLOCK H5FD_MEM_OHDR +#define H5FD_MEM_EARRAY_SBLOCK H5FD_MEM_BTREE +#define H5FD_MEM_EARRAY_DBLOCK H5FD_MEM_LHEAP +#define H5FD_MEM_EARRAY_DBLK_PAGE H5FD_MEM_LHEAP /* Map "fixed array" header blocks to 'ohdr' type file memory, since its * a fair amount of work to add a new kind of file memory and they are similar @@ -101,9 +101,9 @@ typedef enum H5F_mem_t H5FD_mem_t; * they are similar enough to local heap info. * */ -#define H5FD_MEM_FARRAY_HDR H5FD_MEM_OHDR -#define H5FD_MEM_FARRAY_DBLOCK H5FD_MEM_LHEAP -#define H5FD_MEM_FARRAY_DBLK_PAGE H5FD_MEM_LHEAP +#define H5FD_MEM_FARRAY_HDR H5FD_MEM_OHDR +#define H5FD_MEM_FARRAY_DBLOCK H5FD_MEM_LHEAP +#define H5FD_MEM_FARRAY_DBLK_PAGE H5FD_MEM_LHEAP /* * A free-list map which maps all types of allocation requests to a single @@ -112,205 +112,202 @@ typedef enum H5F_mem_t H5FD_mem_t; * want to make most efficient reuse of freed memory. The use of the * H5FD_MEM_SUPER free list is arbitrary. */ -#define H5FD_FLMAP_SINGLE { \ - H5FD_MEM_SUPER, /*default*/ \ - H5FD_MEM_SUPER, /*super*/ \ - H5FD_MEM_SUPER, /*btree*/ \ - H5FD_MEM_SUPER, /*draw*/ \ - H5FD_MEM_SUPER, /*gheap*/ \ - H5FD_MEM_SUPER, /*lheap*/ \ - H5FD_MEM_SUPER /*ohdr*/ \ -} +#define H5FD_FLMAP_SINGLE \ + { \ + H5FD_MEM_SUPER, /*default*/ \ + H5FD_MEM_SUPER, /*super*/ \ + H5FD_MEM_SUPER, /*btree*/ \ + H5FD_MEM_SUPER, /*draw*/ \ + H5FD_MEM_SUPER, /*gheap*/ \ + H5FD_MEM_SUPER, /*lheap*/ \ + H5FD_MEM_SUPER /*ohdr*/ \ + } /* * A free-list map which segregates requests into `raw' or `meta' data * pools. */ -#define H5FD_FLMAP_DICHOTOMY { \ - H5FD_MEM_SUPER, /*default*/ \ - H5FD_MEM_SUPER, /*super*/ \ - H5FD_MEM_SUPER, /*btree*/ \ - H5FD_MEM_DRAW, /*draw*/ \ - H5FD_MEM_DRAW, /*gheap*/ \ - H5FD_MEM_SUPER, /*lheap*/ \ - H5FD_MEM_SUPER /*ohdr*/ \ -} +#define H5FD_FLMAP_DICHOTOMY \ + { \ + H5FD_MEM_SUPER, /*default*/ \ + H5FD_MEM_SUPER, /*super*/ \ + H5FD_MEM_SUPER, /*btree*/ \ + H5FD_MEM_DRAW, /*draw*/ \ + H5FD_MEM_DRAW, /*gheap*/ \ + H5FD_MEM_SUPER, /*lheap*/ \ + H5FD_MEM_SUPER /*ohdr*/ \ + } /* * The default free list map which causes each request type to use it's own * free-list. */ -#define H5FD_FLMAP_DEFAULT { \ - H5FD_MEM_DEFAULT, /*default*/ \ - H5FD_MEM_DEFAULT, /*super*/ \ - H5FD_MEM_DEFAULT, /*btree*/ \ - H5FD_MEM_DEFAULT, /*draw*/ \ - H5FD_MEM_DEFAULT, /*gheap*/ \ - H5FD_MEM_DEFAULT, /*lheap*/ \ - H5FD_MEM_DEFAULT /*ohdr*/ \ -} - +#define H5FD_FLMAP_DEFAULT \ + { \ + H5FD_MEM_DEFAULT, /*default*/ \ + H5FD_MEM_DEFAULT, /*super*/ \ + H5FD_MEM_DEFAULT, /*btree*/ \ + H5FD_MEM_DEFAULT, /*draw*/ \ + H5FD_MEM_DEFAULT, /*gheap*/ \ + H5FD_MEM_DEFAULT, /*lheap*/ \ + H5FD_MEM_DEFAULT /*ohdr*/ \ + } /* Define VFL driver features that can be enabled on a per-driver basis */ /* These are returned with the 'query' function pointer in H5FD_class_t */ - /* - * Defining H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that - * the library will attempt to allocate a larger block for metadata and - * then sub-allocate each metadata request from that larger block. - */ -#define H5FD_FEAT_AGGREGATE_METADATA 0x00000001 - /* - * Defining H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that - * the library will attempt to cache metadata as it is written to the file - * and build up a larger block of metadata to eventually pass to the VFL - * 'write' routine. - * - * Distinguish between updating the metadata accumulator on writes and - * reads. This is particularly (perhaps only, even) important for MPI-I/O - * where we guarantee that writes are collective, but reads may not be. - * If we were to allow the metadata accumulator to be written during a - * read operation, the application would hang. - */ -#define H5FD_FEAT_ACCUMULATE_METADATA_WRITE 0x00000002 -#define H5FD_FEAT_ACCUMULATE_METADATA_READ 0x00000004 -#define H5FD_FEAT_ACCUMULATE_METADATA (H5FD_FEAT_ACCUMULATE_METADATA_WRITE|H5FD_FEAT_ACCUMULATE_METADATA_READ) - /* - * Defining H5FD_FEAT_DATA_SIEVE for a VFL driver means that - * the library will attempt to cache raw data as it is read from/written to - * a file in a "data seive" buffer. See Rajeev Thakur's papers: - * http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz - * http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz - */ -#define H5FD_FEAT_DATA_SIEVE 0x00000008 - /* - * Defining H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that - * the library will attempt to allocate a larger block for "small" raw data - * and then sub-allocate "small" raw data requests from that larger block. - */ -#define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010 - /* - * Defining H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that - * the library will ignore the driver info that is encoded in the file - * for the VFL driver. (This will cause the driver info to be eliminated - * from the file when it is flushed/closed, if the file is opened R/W). - */ -#define H5FD_FEAT_IGNORE_DRVRINFO 0x00000020 - /* - * Defining the H5FD_FEAT_DIRTY_DRVRINFO_LOAD for a VFL driver means that - * the library will mark the driver info dirty when the file is opened - * R/W. This will cause the driver info to be re-encoded when the file - * is flushed/closed. - */ -#define H5FD_FEAT_DIRTY_DRVRINFO_LOAD 0x00000040 - /* - * Defining H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that - * the handle for the VFD (returned with the 'get_handle' callback) is - * of type 'int' and is compatible with POSIX I/O calls. - */ -#define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080 - /* - * Defining H5FD_FEAT_HAS_MPI for a VFL driver means that - * the driver makes use of MPI communication and code may retrieve - * communicator/rank information from it - */ -#define H5FD_FEAT_HAS_MPI 0x00000100 - /* - * Defining the H5FD_FEAT_ALLOCATE_EARLY for a VFL driver will force - * the library to use the H5D_ALLOC_TIME_EARLY on dataset create - * instead of the default H5D_ALLOC_TIME_LATE - */ -#define H5FD_FEAT_ALLOCATE_EARLY 0x00000200 - /* - * Defining H5FD_FEAT_ALLOW_FILE_IMAGE for a VFL driver means that - * the driver is able to use a file image in the fapl as the initial - * contents of a file. - */ -#define H5FD_FEAT_ALLOW_FILE_IMAGE 0x00000400 - /* - * Defining H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS for a VFL driver - * means that the driver is able to use callbacks to make a copy of the - * image to store in memory. - */ +/* + * Defining H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that + * the library will attempt to allocate a larger block for metadata and + * then sub-allocate each metadata request from that larger block. + */ +#define H5FD_FEAT_AGGREGATE_METADATA 0x00000001 +/* + * Defining H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that + * the library will attempt to cache metadata as it is written to the file + * and build up a larger block of metadata to eventually pass to the VFL + * 'write' routine. + * + * Distinguish between updating the metadata accumulator on writes and + * reads. This is particularly (perhaps only, even) important for MPI-I/O + * where we guarantee that writes are collective, but reads may not be. + * If we were to allow the metadata accumulator to be written during a + * read operation, the application would hang. + */ +#define H5FD_FEAT_ACCUMULATE_METADATA_WRITE 0x00000002 +#define H5FD_FEAT_ACCUMULATE_METADATA_READ 0x00000004 +#define H5FD_FEAT_ACCUMULATE_METADATA \ + (H5FD_FEAT_ACCUMULATE_METADATA_WRITE | H5FD_FEAT_ACCUMULATE_METADATA_READ) +/* + * Defining H5FD_FEAT_DATA_SIEVE for a VFL driver means that + * the library will attempt to cache raw data as it is read from/written to + * a file in a "data seive" buffer. See Rajeev Thakur's papers: + * http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz + * http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz + */ +#define H5FD_FEAT_DATA_SIEVE 0x00000008 +/* + * Defining H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that + * the library will attempt to allocate a larger block for "small" raw data + * and then sub-allocate "small" raw data requests from that larger block. + */ +#define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010 +/* + * Defining H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that + * the library will ignore the driver info that is encoded in the file + * for the VFL driver. (This will cause the driver info to be eliminated + * from the file when it is flushed/closed, if the file is opened R/W). + */ +#define H5FD_FEAT_IGNORE_DRVRINFO 0x00000020 +/* + * Defining the H5FD_FEAT_DIRTY_DRVRINFO_LOAD for a VFL driver means that + * the library will mark the driver info dirty when the file is opened + * R/W. This will cause the driver info to be re-encoded when the file + * is flushed/closed. + */ +#define H5FD_FEAT_DIRTY_DRVRINFO_LOAD 0x00000040 +/* + * Defining H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that + * the handle for the VFD (returned with the 'get_handle' callback) is + * of type 'int' and is compatible with POSIX I/O calls. + */ +#define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080 +/* + * Defining H5FD_FEAT_HAS_MPI for a VFL driver means that + * the driver makes use of MPI communication and code may retrieve + * communicator/rank information from it + */ +#define H5FD_FEAT_HAS_MPI 0x00000100 +/* + * Defining the H5FD_FEAT_ALLOCATE_EARLY for a VFL driver will force + * the library to use the H5D_ALLOC_TIME_EARLY on dataset create + * instead of the default H5D_ALLOC_TIME_LATE + */ +#define H5FD_FEAT_ALLOCATE_EARLY 0x00000200 +/* + * Defining H5FD_FEAT_ALLOW_FILE_IMAGE for a VFL driver means that + * the driver is able to use a file image in the fapl as the initial + * contents of a file. + */ +#define H5FD_FEAT_ALLOW_FILE_IMAGE 0x00000400 +/* + * Defining H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS for a VFL driver + * means that the driver is able to use callbacks to make a copy of the + * image to store in memory. + */ #define H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS 0x00000800 - /* - * Defining H5FD_FEAT_SUPPORTS_SWMR_IO for a VFL driver means that the - * driver supports the single-writer/multiple-readers I/O pattern. - */ -#define H5FD_FEAT_SUPPORTS_SWMR_IO 0x00001000 - /* - * Defining H5FD_FEAT_USE_ALLOC_SIZE for a VFL driver - * means that the library will just pass the allocation size to the - * the driver's allocation callback which will eventually handle alignment. - * This is specifically used for the multi/split driver. - */ -#define H5FD_FEAT_USE_ALLOC_SIZE 0x00002000 - /* - * Defining H5FD_FEAT_PAGED_AGGR for a VFL driver - * means that the driver needs special file space mapping for paged aggregation. - * This is specifically used for the multi/split driver. - */ -#define H5FD_FEAT_PAGED_AGGR 0x00004000 - /* - * Defining H5FD_FEAT_DEFAULT_VFD_COMPATIBLE for a VFL driver - * that creates a file which is compatible with the default VFD. - * Generally, this means that the VFD creates a single file that follows - * the canonical HDF5 file format. - * Regarding the Splitter VFD specifically, only drivers with this flag - * enabled may be used as the Write-Only (W/O) channel driver. - */ -#define H5FD_FEAT_DEFAULT_VFD_COMPATIBLE 0x00008000 - +/* + * Defining H5FD_FEAT_SUPPORTS_SWMR_IO for a VFL driver means that the + * driver supports the single-writer/multiple-readers I/O pattern. + */ +#define H5FD_FEAT_SUPPORTS_SWMR_IO 0x00001000 +/* + * Defining H5FD_FEAT_USE_ALLOC_SIZE for a VFL driver + * means that the library will just pass the allocation size to the + * the driver's allocation callback which will eventually handle alignment. + * This is specifically used for the multi/split driver. + */ +#define H5FD_FEAT_USE_ALLOC_SIZE 0x00002000 +/* + * Defining H5FD_FEAT_PAGED_AGGR for a VFL driver + * means that the driver needs special file space mapping for paged aggregation. + * This is specifically used for the multi/split driver. + */ +#define H5FD_FEAT_PAGED_AGGR 0x00004000 +/* + * Defining H5FD_FEAT_DEFAULT_VFD_COMPATIBLE for a VFL driver + * that creates a file which is compatible with the default VFD. + * Generally, this means that the VFD creates a single file that follows + * the canonical HDF5 file format. + * Regarding the Splitter VFD specifically, only drivers with this flag + * enabled may be used as the Write-Only (W/O) channel driver. + */ +#define H5FD_FEAT_DEFAULT_VFD_COMPATIBLE 0x00008000 /* Forward declaration */ typedef struct H5FD_t H5FD_t; /* Class information for each file driver */ typedef struct H5FD_class_t { - const char *name; - haddr_t maxaddr; + const char * name; + haddr_t maxaddr; H5F_close_degree_t fc_degree; - herr_t (*terminate)(void); + herr_t (*terminate)(void); hsize_t (*sb_size)(H5FD_t *file); - herr_t (*sb_encode)(H5FD_t *file, char *name/*out*/, - unsigned char *p/*out*/); - herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p); - size_t fapl_size; - void * (*fapl_get)(H5FD_t *file); - void * (*fapl_copy)(const void *fapl); - herr_t (*fapl_free)(void *fapl); - size_t dxpl_size; - void * (*dxpl_copy)(const void *dxpl); - herr_t (*dxpl_free)(void *dxpl); - H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, - haddr_t maxaddr); - herr_t (*close)(H5FD_t *file); - int (*cmp)(const H5FD_t *f1, const H5FD_t *f2); - herr_t (*query)(const H5FD_t *f1, unsigned long *flags); - herr_t (*get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map); + herr_t (*sb_encode)(H5FD_t *file, char *name /*out*/, unsigned char *p /*out*/); + herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p); + size_t fapl_size; + void *(*fapl_get)(H5FD_t *file); + void *(*fapl_copy)(const void *fapl); + herr_t (*fapl_free)(void *fapl); + size_t dxpl_size; + void *(*dxpl_copy)(const void *dxpl); + herr_t (*dxpl_free)(void *dxpl); + H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, haddr_t maxaddr); + herr_t (*close)(H5FD_t *file); + int (*cmp)(const H5FD_t *f1, const H5FD_t *f2); + herr_t (*query)(const H5FD_t *f1, unsigned long *flags); + herr_t (*get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map); haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); - herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, hsize_t size); + herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); haddr_t (*get_eoa)(const H5FD_t *file, H5FD_mem_t type); - herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr); + herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr); haddr_t (*get_eof)(const H5FD_t *file, H5FD_mem_t type); - herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void**file_handle); - herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, - haddr_t addr, size_t size, void *buffer); - herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, - haddr_t addr, size_t size, const void *buffer); - herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); - herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); - herr_t (*lock)(H5FD_t *file, hbool_t rw); - herr_t (*unlock)(H5FD_t *file); - H5FD_t *(*dedup)(H5FD_t *, H5FD_t *, hid_t); + herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void **file_handle); + herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, void *buffer); + herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, const void *buffer); + herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); + herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); + herr_t (*lock)(H5FD_t *file, hbool_t rw); + herr_t (*unlock)(H5FD_t *file); + H5FD_t *(*dedup)(H5FD_t *, H5FD_t *, hid_t); H5FD_mem_t fl_map[H5FD_MEM_NTYPES]; } H5FD_class_t; /* A free list is a singly-linked list of address/size pairs. */ typedef struct H5FD_free_t { - haddr_t addr; - hsize_t size; - struct H5FD_free_t *next; + haddr_t addr; + hsize_t size; + struct H5FD_free_t *next; } H5FD_free_t; /* @@ -318,22 +315,22 @@ typedef struct H5FD_free_t { * are declared here and the driver appends private fields in memory. */ struct H5FD_t { - hid_t driver_id; /* Driver ID for this file */ - const H5FD_class_t *cls; /* Constant class info */ - unsigned long fileno; /* File 'serial' number */ - unsigned access_flags; /* File access flags (from create or open) */ - unsigned long feature_flags; /* VFL Driver feature Flags */ - haddr_t maxaddr; /* For this file, overrides class */ - haddr_t base_addr; /* Base address for HDF5 data w/in file */ + hid_t driver_id; /* Driver ID for this file */ + const H5FD_class_t *cls; /* Constant class info */ + unsigned long fileno; /* File 'serial' number */ + unsigned access_flags; /* File access flags (from create or open) */ + unsigned long feature_flags; /* VFL Driver feature Flags */ + haddr_t maxaddr; /* For this file, overrides class */ + haddr_t base_addr; /* Base address for HDF5 data w/in file */ - H5FD_t *exc_owner; /* Pointer to an exclusive owner - * or NULL if none. - */ + H5FD_t *exc_owner; /* Pointer to an exclusive owner + * or NULL if none. + */ /* Space allocation management fields */ - hsize_t threshold; /* Threshold for alignment */ - hsize_t alignment; /* Allocation alignment */ - hbool_t paged_aggr; /* Paged aggregation for file space is enabled or not */ + hsize_t threshold; /* Threshold for alignment */ + hsize_t alignment; /* Allocation alignment */ + hbool_t paged_aggr; /* Paged aggregation for file space is enabled or not */ }; /* Define enum for the source of file image callbacks */ @@ -350,16 +347,13 @@ typedef enum { /* Define structure to hold file image callbacks */ typedef struct { - void *(*image_malloc)(size_t size, H5FD_file_image_op_t file_image_op, - void *udata); - void *(*image_memcpy)(void *dest, const void *src, size_t size, - H5FD_file_image_op_t file_image_op, void *udata); - void *(*image_realloc)(void *ptr, size_t size, - H5FD_file_image_op_t file_image_op, void *udata); - herr_t (*image_free)(void *ptr, H5FD_file_image_op_t file_image_op, + void *(*image_malloc)(size_t size, H5FD_file_image_op_t file_image_op, void *udata); + void *(*image_memcpy)(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *udata); - void *(*udata_copy)(void *udata); - herr_t (*udata_free)(void *udata); + void *(*image_realloc)(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); + herr_t (*image_free)(void *ptr, H5FD_file_image_op_t file_image_op, void *udata); + void *(*udata_copy)(void *udata); + herr_t (*udata_free)(void *udata); void *udata; } H5FD_file_image_callbacks_t; @@ -368,34 +362,31 @@ extern "C" { #endif /* Function prototypes */ -H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); +H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); H5_DLL herr_t H5FDunregister(hid_t driver_id); -H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); -H5_DLL herr_t H5FDclose(H5FD_t *file); -H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); -H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); +H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +H5_DLL herr_t H5FDclose(H5FD_t *file); +H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); +H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, hsize_t size); +H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); -H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); +H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); -H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle); -H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, size_t size, void *buf/*out*/); -H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, size_t size, const void *buf); -H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); -H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); -H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); -H5_DLL herr_t H5FDunlock(H5FD_t *file); +H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle); +H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf /*out*/); +H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); +H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); +H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); +H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); +H5_DLL herr_t H5FDunlock(H5FD_t *file); /* Allows querying a VFD ID for features before the file is opened */ -H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/); +H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/); #ifdef __cplusplus } #endif #endif - diff --git a/src/H5FDros3.c b/src/H5FDros3.c index a936f55..ca18025 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -25,14 +25,14 @@ /* This source code file is part of the H5FD driver module */ #include "H5FDdrvr_module.h" -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDros3.h" /* ros3 file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5FDs3comms.h" /* S3 Communications */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDros3.h" /* ros3 file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5FDs3comms.h" /* S3 Communications */ #ifdef H5_HAVE_ROS3_VFD @@ -63,29 +63,27 @@ static hid_t H5FD_ROS3_g = 0; * 2^(10+(1*16)) = 2^26 = 64MB * Reads of 64MB or greater fall in "overflow" bin[BIN_COUNT] */ -#define ROS3_STATS_BASE 2 -#define ROS3_STATS_INTERVAL 1 +#define ROS3_STATS_BASE 2 +#define ROS3_STATS_INTERVAL 1 #define ROS3_STATS_START_POWER 10 #define ROS3_STATS_BIN_COUNT 16 /* MUST BE GREATER THAN 0 */ - /* * Calculate `BASE ^ (START_POWER + (INTERVAL * bin_i))` * Stores result at `(unsigned long long *) out_ptr`. * Used in computing boundaries between stats bins. */ -#define ROS3_STATS_POW(bin_i, out_ptr) { \ - unsigned long long donotshadowresult = 1; \ - unsigned donotshadowindex = 0; \ - for (donotshadowindex = 0; \ - donotshadowindex < (((bin_i) * ROS3_STATS_INTERVAL) + \ - ROS3_STATS_START_POWER); \ - donotshadowindex++) \ - { \ - donotshadowresult *= ROS3_STATS_BASE; \ - } \ - *(out_ptr) = donotshadowresult; \ -} +#define ROS3_STATS_POW(bin_i, out_ptr) \ + { \ + unsigned long long donotshadowresult = 1; \ + unsigned donotshadowindex = 0; \ + for (donotshadowindex = 0; \ + donotshadowindex < (((bin_i)*ROS3_STATS_INTERVAL) + ROS3_STATS_START_POWER); \ + donotshadowindex++) { \ + donotshadowresult *= ROS3_STATS_BASE; \ + } \ + *(out_ptr) = donotshadowresult; \ + } /* array to hold pre-computed boundaries for stats bins */ @@ -192,13 +190,13 @@ typedef struct { * ***************************************************************************/ typedef struct H5FD_ros3_t { - H5FD_t pub; - H5FD_ros3_fapl_t fa; - haddr_t eoa; - s3r_t *s3r_handle; + H5FD_t pub; + H5FD_ros3_fapl_t fa; + haddr_t eoa; + s3r_t * s3r_handle; #if ROS3_STATS - ros3_statsbin meta[ROS3_STATS_BIN_COUNT + 1]; - ros3_statsbin raw[ROS3_STATS_BIN_COUNT + 1]; + ros3_statsbin meta[ROS3_STATS_BIN_COUNT + 1]; + ros3_statsbin raw[ROS3_STATS_BIN_COUNT + 1]; #endif } H5FD_ros3_t; @@ -212,74 +210,70 @@ typedef struct H5FD_ros3_t { * Only included if it may be used -- ROS3 VFD is enabled. * */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) /* Prototypes */ static herr_t H5FD_ros3_term(void); -static void *H5FD_ros3_fapl_get(H5FD_t *_file); -static void *H5FD_ros3_fapl_copy(const void *_old_fa); +static void * H5FD_ros3_fapl_get(H5FD_t *_file); +static void * H5FD_ros3_fapl_copy(const void *_old_fa); static herr_t H5FD_ros3_fapl_free(void *_fa); -static H5FD_t *H5FD_ros3_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); +static H5FD_t *H5FD_ros3_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_ros3_close(H5FD_t *_file); static int H5FD_ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_ros3_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t type); static herr_t H5FD_ros3_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_ros3_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_ros3_get_handle(H5FD_t *_file, hid_t fapl, - void** file_handle); -static herr_t H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, void *buf); -static herr_t H5FD_ros3_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, const void *buf); -static herr_t H5FD_ros3_truncate(H5FD_t *_file, hid_t dxpl_id, - hbool_t closing); +static herr_t H5FD_ros3_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_ros3_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_ros3_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static herr_t H5FD_ros3_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD_ros3_unlock(H5FD_t *_file); -static herr_t H5FD_ros3_validate_config(const H5FD_ros3_fapl_t * fa); +static herr_t H5FD_ros3_validate_config(const H5FD_ros3_fapl_t *fa); static const H5FD_class_t H5FD_ros3_g = { - "ros3", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_ros3_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - sizeof(H5FD_ros3_fapl_t), /* fapl_size */ - H5FD_ros3_fapl_get, /* fapl_get */ - H5FD_ros3_fapl_copy, /* fapl_copy */ - H5FD_ros3_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_ros3_open, /* open */ - H5FD_ros3_close, /* close */ - H5FD_ros3_cmp, /* cmp */ - H5FD_ros3_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD_ros3_get_eoa, /* get_eoa */ - H5FD_ros3_set_eoa, /* set_eoa */ - H5FD_ros3_get_eof, /* get_eof */ - H5FD_ros3_get_handle, /* get_handle */ - H5FD_ros3_read, /* read */ - H5FD_ros3_write, /* write */ - NULL, /* flush */ - H5FD_ros3_truncate, /* truncate */ - H5FD_ros3_lock, /* lock */ - H5FD_ros3_unlock, /* unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "ros3", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_ros3_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_ros3_fapl_t), /* fapl_size */ + H5FD_ros3_fapl_get, /* fapl_get */ + H5FD_ros3_fapl_copy, /* fapl_copy */ + H5FD_ros3_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_ros3_open, /* open */ + H5FD_ros3_close, /* close */ + H5FD_ros3_cmp, /* cmp */ + H5FD_ros3_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_ros3_get_eoa, /* get_eoa */ + H5FD_ros3_set_eoa, /* set_eoa */ + H5FD_ros3_get_eof, /* get_eof */ + H5FD_ros3_get_handle, /* get_handle */ + H5FD_ros3_read, /* read */ + H5FD_ros3_write, /* write */ + NULL, /* flush */ + H5FD_ros3_truncate, /* truncate */ + H5FD_ros3_lock, /* lock */ + H5FD_ros3_unlock, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_ros3_t struct */ H5FL_DEFINE_STATIC(H5FD_ros3_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -299,8 +293,7 @@ H5FD__init_package(void) FUNC_ENTER_STATIC if (H5FD_ros3_init() < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, - "unable to initialize ros3 VFD") + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize ros3 VFD") } done: @@ -308,7 +301,6 @@ done: } /* end H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_ros3_init * @@ -357,7 +349,6 @@ done: } /* end H5FD_ros3_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_ros3_term * @@ -385,7 +376,6 @@ H5FD_ros3_term(void) } /* end H5FD_ros3_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_ros3 * @@ -402,8 +392,7 @@ H5FD_ros3_term(void) *------------------------------------------------------------------------- */ herr_t -H5Pset_fapl_ros3(hid_t fapl_id, - H5FD_ros3_fapl_t *fa) +H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa) { H5P_genplist_t *plist = NULL; /* Property list pointer */ herr_t ret_value = FAIL; @@ -419,8 +408,7 @@ H5Pset_fapl_ros3(hid_t fapl_id, plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); if (plist == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, \ - "not a file access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") } if (FAIL == H5FD_ros3_validate_config(fa)) { @@ -434,7 +422,6 @@ done: } /* end H5Pset_fapl_ros3() */ - /*------------------------------------------------------------------------- * Function: H5FD_ros3_validate_config() * @@ -456,7 +443,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_validate_config(const H5FD_ros3_fapl_t * fa) +H5FD_ros3_validate_config(const H5FD_ros3_fapl_t *fa) { herr_t ret_value = SUCCEED; @@ -464,19 +451,15 @@ H5FD_ros3_validate_config(const H5FD_ros3_fapl_t * fa) HDassert(fa != NULL); - if ( fa->version != H5FD_CURR_ROS3_FAPL_T_VERSION ) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Unknown H5FD_ros3_fapl_t version"); + if (fa->version != H5FD_CURR_ROS3_FAPL_T_VERSION) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown H5FD_ros3_fapl_t version"); } /* if set to authenticate, region and id cannot be empty strings */ if (fa->authenticate == TRUE) { - if ((fa->aws_region[0] == '\0') || - (fa->secret_id[0] == '\0')) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Inconsistent authentication information"); + if ((fa->aws_region[0] == '\0') || (fa->secret_id[0] == '\0')) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Inconsistent authentication information"); } } @@ -485,7 +468,6 @@ done: } /* end H5FD_ros3_validate_config() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_ros3 * @@ -504,11 +486,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_ros3(hid_t fapl_id, - H5FD_ros3_fapl_t *fa_out) +H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_out) { const H5FD_ros3_fapl_t *fa = NULL; - H5P_genplist_t *plist = NULL; + H5P_genplist_t * plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -544,7 +525,6 @@ done: } /* end H5Pget_fapl_ros3() */ - /*------------------------------------------------------------------------- * Function: H5FD_ros3_fapl_get * @@ -565,16 +545,15 @@ done: static void * H5FD_ros3_fapl_get(H5FD_t *_file) { - H5FD_ros3_t *file = (H5FD_ros3_t*)_file; + H5FD_ros3_t * file = (H5FD_ros3_t *)_file; H5FD_ros3_fapl_t *fa = NULL; - void *ret_value = NULL; + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT fa = (H5FD_ros3_fapl_t *)H5MM_calloc(sizeof(H5FD_ros3_fapl_t)); if (fa == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* Copy the fields of the structure */ @@ -593,7 +572,6 @@ done: } /* end H5FD_ros3_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD_ros3_fapl_copy * @@ -613,16 +591,15 @@ done: static void * H5FD_ros3_fapl_copy(const void *_old_fa) { - const H5FD_ros3_fapl_t *old_fa = (const H5FD_ros3_fapl_t*)_old_fa; - H5FD_ros3_fapl_t *new_fa = NULL; - void *ret_value = NULL; + const H5FD_ros3_fapl_t *old_fa = (const H5FD_ros3_fapl_t *)_old_fa; + H5FD_ros3_fapl_t * new_fa = NULL; + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT new_fa = (H5FD_ros3_fapl_t *)H5MM_malloc(sizeof(H5FD_ros3_fapl_t)); if (new_fa == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } HDmemcpy(new_fa, old_fa, sizeof(H5FD_ros3_fapl_t)); @@ -638,7 +615,6 @@ done: } /* end H5FD_ros3_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD_ros3_fapl_free * @@ -656,7 +632,7 @@ done: static herr_t H5FD_ros3_fapl_free(void *_fa) { - H5FD_ros3_fapl_t *fa = (H5FD_ros3_fapl_t*)_fa; + H5FD_ros3_fapl_t *fa = (H5FD_ros3_fapl_t *)_fa; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -704,15 +680,14 @@ ros3_reset_stats(H5FD_ros3_t *file) #endif if (file == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file was null"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file was null"); } for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { - file->raw[i].bytes = 0; - file->raw[i].count = 0; - file->raw[i].min = (unsigned long long)ROS3_STATS_STARTING_MIN; - file->raw[i].max = 0; + file->raw[i].bytes = 0; + file->raw[i].count = 0; + file->raw[i].min = (unsigned long long)ROS3_STATS_STARTING_MIN; + file->raw[i].max = 0; file->meta[i].bytes = 0; file->meta[i].count = 0; @@ -727,7 +702,6 @@ done: #endif /* ROS3_STATS */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_open() @@ -760,21 +734,15 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_ros3_open( - const char *url, - unsigned flags, - hid_t fapl_id, - haddr_t maxaddr) +H5FD_ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_ros3_t *file = NULL; - struct tm *now = NULL; - char iso8601now[ISO8601_SIZE]; - unsigned char signing_key[SHA256_DIGEST_LENGTH]; - s3r_t *handle = NULL; - H5FD_ros3_fapl_t fa; - H5FD_t *ret_value = NULL; - - + H5FD_ros3_t * file = NULL; + struct tm * now = NULL; + char iso8601now[ISO8601_SIZE]; + unsigned char signing_key[SHA256_DIGEST_LENGTH]; + s3r_t * handle = NULL; + H5FD_ros3_fapl_t fa; + H5FD_t * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -793,16 +761,14 @@ H5FD_ros3_open( if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") if (flags != H5F_ACC_RDONLY) - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, - "only Read-Only access allowed") + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, "only Read-Only access allowed") if (FAIL == H5Pget_fapl_ros3(fapl_id, &fa)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get property list") } if (CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "unable to initialize curl global (placeholder flags)") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to initialize curl global (placeholder flags)") } /* open file; procedure depends on whether or not the fapl instructs to @@ -814,26 +780,19 @@ H5FD_ros3_open( * find way to re-use/share */ now = gmnow(); - HDassert( now != NULL ); + HDassert(now != NULL); if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "problem while writing iso8601 timestamp") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem while writing iso8601 timestamp") } - if (FAIL == H5FD_s3comms_signing_key(signing_key, - (const char *)fa.secret_key, - (const char *)fa.aws_region, - (const char *)iso8601now) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "problem while computing signing key") + if (FAIL == H5FD_s3comms_signing_key(signing_key, (const char *)fa.secret_key, + (const char *)fa.aws_region, (const char *)iso8601now)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem while computing signing key") } - handle = H5FD_s3comms_s3r_open( - url, - (const char *)fa.aws_region, - (const char *)fa.secret_id, - (const unsigned char *)signing_key); - } else { + handle = H5FD_s3comms_s3r_open(url, (const char *)fa.aws_region, (const char *)fa.secret_id, + (const unsigned char *)signing_key); + } + else { handle = H5FD_s3comms_s3r_open(url, NULL, NULL, NULL); } /* if/else should authenticate */ @@ -849,8 +808,7 @@ H5FD_ros3_open( */ file = H5FL_CALLOC(H5FD_ros3_t); if (file == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "unable to allocate file struct") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") } file->s3r_handle = handle; @@ -858,26 +816,24 @@ H5FD_ros3_open( #if ROS3_STATS if (FAIL == ros3_reset_stats(file)) { - HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, - "unable to reset file statistics") + HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, "unable to reset file statistics") } #endif /* ROS3_STATS */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: if (ret_value == NULL) { if (handle != NULL) { if (FAIL == H5FD_s3comms_s3r_close(handle)) { - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, - "unable to close s3 file handle") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close s3 file handle") } } if (file != NULL) { file = H5FL_FREE(H5FD_ros3_t, file); } curl_global_cleanup(); /* early cleanup because open failed */ - } /* end if null return value (error) */ + } /* end if null return value (error) */ FUNC_LEAVE_NOAPI(ret_value) @@ -940,45 +896,38 @@ done: *---------------------------------------------------------------------------- */ static herr_t -ros3_fprint_stats(FILE *stream, - const H5FD_ros3_t *file) +ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) { herr_t ret_value = SUCCEED; - parsed_url_t *purl = NULL; + parsed_url_t * purl = NULL; unsigned i = 0; unsigned long count_meta = 0; unsigned long count_raw = 0; double average_meta = 0.0; double average_raw = 0.0; - unsigned long long min_meta = (unsigned long long)ROS3_STATS_STARTING_MIN; - unsigned long long min_raw = (unsigned long long)ROS3_STATS_STARTING_MIN; + unsigned long long min_meta = (unsigned long long)ROS3_STATS_STARTING_MIN; + unsigned long long min_raw = (unsigned long long)ROS3_STATS_STARTING_MIN; unsigned long long max_meta = 0; unsigned long long max_raw = 0; unsigned long long bytes_raw = 0; unsigned long long bytes_meta = 0; double re_dub = 0.0; /* re-usable double variable */ unsigned suffix_i = 0; - const char suffixes[] = { ' ', 'K', 'M', 'G', 'T', 'P' }; - - + const char suffixes[] = {' ', 'K', 'M', 'G', 'T', 'P'}; FUNC_ENTER_NOAPI_NOINIT if (stream == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file stream cannot be null" ); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file stream cannot be null"); } if (file == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file cannot be null"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file cannot be null"); } if (file->s3r_handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "s3 request handle cannot be null"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "s3 request handle cannot be null"); } if (file->s3r_handle->purl == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "parsed url structure cannot be null"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parsed url structure cannot be null"); } purl = file->s3r_handle->purl; @@ -995,7 +944,8 @@ ros3_fprint_stats(FILE *stream, else HDfprintf(stream, "/"); HDfprintf(stream, "?%s", purl->query); - } else if (purl->path != NULL && purl->path[0] != '\0') { + } + else if (purl->path != NULL && purl->path[0] != '\0') { HDfprintf(stream, "/%s", purl->path); } HDfprintf(stream, "\n"); @@ -1008,14 +958,18 @@ ros3_fprint_stats(FILE *stream, const ros3_statsbin *r = &file->raw[i]; const ros3_statsbin *m = &file->meta[i]; - if (m->min < min_meta) min_meta = m->min; - if (r->min < min_raw) min_raw = r->min; - if (m->max > max_meta) max_meta = m->max; - if (r->max > max_raw) max_raw = r->max; + if (m->min < min_meta) + min_meta = m->min; + if (r->min < min_raw) + min_raw = r->min; + if (m->max > max_meta) + max_meta = m->max; + if (r->max > max_raw) + max_raw = r->max; - count_raw += r->count; + count_raw += r->count; count_meta += m->count; - bytes_raw += r->bytes; + bytes_raw += r->bytes; bytes_meta += m->bytes; } if (count_raw > 0) @@ -1027,10 +981,10 @@ ros3_fprint_stats(FILE *stream, * PRINT OVERVIEW * ******************/ - HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", - count_raw + count_meta, count_meta, count_raw); - HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", - bytes_raw + bytes_meta, bytes_meta, bytes_raw); + HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", count_raw + count_meta, count_meta, + count_raw); + HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", bytes_raw + bytes_meta, bytes_meta, + bytes_raw); if (count_raw + count_meta == 0) goto done; @@ -1043,7 +997,8 @@ ros3_fprint_stats(FILE *stream, HDfprintf(stream, " min "); if (count_meta == 0) { HDfprintf(stream, " 0.000 "); - } else { + } + else { re_dub = (double)min_meta; for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; @@ -1053,7 +1008,8 @@ ros3_fprint_stats(FILE *stream, if (count_raw == 0) { HDfprintf(stream, " 0.000 \n"); - } else { + } + else { re_dub = (double)min_raw; for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; @@ -1091,10 +1047,8 @@ ros3_fprint_stats(FILE *stream, * PRINT INDIVIDUAL BIN STATS * ******************************/ - HDfprintf(stream, - "BINS # of reads total bytes average size\n"); - HDfprintf(stream, - " up-to meta raw meta raw meta raw\n"); + HDfprintf(stream, "BINS # of reads total bytes average size\n"); + HDfprintf(stream, " up-to meta raw meta raw meta raw\n"); for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { const ros3_statsbin *m; @@ -1117,9 +1071,10 @@ ros3_fprint_stats(FILE *stream, range_end = ros3_stats_boundaries[i]; if (i == ROS3_STATS_BIN_COUNT) { - range_end = ros3_stats_boundaries[i-1]; + range_end = ros3_stats_boundaries[i - 1]; HDfprintf(stream, ">"); - } else { + } + else { HDfprintf(stream, " "); } @@ -1154,15 +1109,14 @@ ros3_fprint_stats(FILE *stream, re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); - HDfprintf(stream, - " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", - re_dub, suffixes[suffix_i], /* bin ceiling */ - m->count, /* metadata reads */ - r->count, /* rawdata reads */ - bm_val, bm_suffix, /* metadata bytes */ - br_val, br_suffix, /* rawdata bytes */ - am_val, am_suffix, /* metadata average */ - ar_val, ar_suffix); /* rawdata average */ + HDfprintf(stream, " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", re_dub, + suffixes[suffix_i], /* bin ceiling */ + m->count, /* metadata reads */ + r->count, /* rawdata reads */ + bm_val, bm_suffix, /* metadata bytes */ + br_val, br_suffix, /* rawdata bytes */ + am_val, am_suffix, /* metadata average */ + ar_val, ar_suffix); /* rawdata average */ fflush(stream); } @@ -1173,7 +1127,6 @@ done: } /* ros3_fprint_stats */ #endif /* ROS3_STATS */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_close() @@ -1211,15 +1164,13 @@ H5FD_ros3_close(H5FD_t H5_ATTR_UNUSED *_file) /* Close the underlying request handle */ if (FAIL == H5FD_s3comms_s3r_close(file->s3r_handle)) { - HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "unable to close S3 request handle") + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close S3 request handle") } #if ROS3_STATS /* TODO: mechanism to re-target stats printout */ if (ros3_fprint_stats(stdout, file) == FAIL) { - HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, - "problem while writing file statistics") + HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, "problem while writing file statistics") } #endif /* ROS3_STATS */ @@ -1234,7 +1185,6 @@ done: } /* end H5FD_ros3_close() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_cmp() @@ -1266,12 +1216,10 @@ done: *------------------------------------------------------------------------- */ static int -H5FD_ros3_cmp( - const H5FD_t *_f1, - const H5FD_t *_f2) +H5FD_ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_ros3_t *f1 = (const H5FD_ros3_t *)_f1; - const H5FD_ros3_t *f2 = (const H5FD_ros3_t *)_f2; + const H5FD_ros3_t * f1 = (const H5FD_ros3_t *)_f1; + const H5FD_ros3_t * f2 = (const H5FD_ros3_t *)_f2; const parsed_url_t *purl1 = NULL; const parsed_url_t *purl2 = NULL; int ret_value = 0; @@ -1310,12 +1258,10 @@ H5FD_ros3_cmp( HGOTO_DONE(-1); } } - else - if (purl1->port) { + else if (purl1->port) { HGOTO_DONE(-1); } - else - if (purl2->port) { + else if (purl2->port) { HGOTO_DONE(-1); } @@ -1325,12 +1271,10 @@ H5FD_ros3_cmp( HGOTO_DONE(-1); } } - else - if (purl1->path && !purl2->path) { + else if (purl1->path && !purl2->path) { HGOTO_DONE(-1); } - else - if (purl2->path && !purl1->path) { + else if (purl2->path && !purl1->path) { HGOTO_DONE(-1); } @@ -1340,12 +1284,10 @@ H5FD_ros3_cmp( HGOTO_DONE(-1); } } - else - if (purl1->query && !purl2->query) { + else if (purl1->query && !purl2->query) { HGOTO_DONE(-1); } - else - if (purl2->query && !purl1->query) { + else if (purl2->query && !purl1->query) { HGOTO_DONE(-1); } @@ -1355,12 +1297,10 @@ H5FD_ros3_cmp( HGOTO_DONE(-1); } } - else - if (f1->fa.aws_region[0] != '\0') { + else if (f1->fa.aws_region[0] != '\0') { HGOTO_DONE(-1); } - else - if (f2->fa.aws_region[0] != '\0') { + else if (f2->fa.aws_region[0] != '\0') { HGOTO_DONE(-1); } @@ -1370,12 +1310,10 @@ H5FD_ros3_cmp( HGOTO_DONE(-1); } } - else - if (f1->fa.secret_id[0] != '\0') { + else if (f1->fa.secret_id[0] != '\0') { HGOTO_DONE(-1); } - else - if (f2->fa.secret_id[0] != '\0') { + else if (f2->fa.secret_id[0] != '\0') { HGOTO_DONE(-1); } @@ -1385,12 +1323,10 @@ H5FD_ros3_cmp( HGOTO_DONE(-1); } } - else - if (f1->fa.secret_key[0] != '\0') { + else if (f1->fa.secret_key[0] != '\0') { HGOTO_DONE(-1); } - else - if (f2->fa.secret_key[0] != '\0') { + else if (f2->fa.secret_key[0] != '\0') { HGOTO_DONE(-1); } @@ -1399,7 +1335,6 @@ done: } /* H5FD_ros3_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD_ros3_query * @@ -1420,8 +1355,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, - unsigned long *flags /* out */) +H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out */) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1440,7 +1374,6 @@ H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, } /* H5FD_ros3_query() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_get_eoa() @@ -1461,8 +1394,7 @@ H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, *------------------------------------------------------------------------- */ static haddr_t -H5FD_ros3_get_eoa(const H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type) +H5FD_ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_ros3_t *file = (const H5FD_ros3_t *)_file; @@ -1476,7 +1408,6 @@ H5FD_ros3_get_eoa(const H5FD_t *_file, } /* end H5FD_ros3_get_eoa() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_set_eoa() @@ -1495,9 +1426,7 @@ H5FD_ros3_get_eoa(const H5FD_t *_file, *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_set_eoa(H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - haddr_t addr) +H5FD_ros3_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; @@ -1513,7 +1442,6 @@ H5FD_ros3_set_eoa(H5FD_t *_file, } /* H5FD_ros3_set_eoa() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_get_eof() @@ -1533,8 +1461,7 @@ H5FD_ros3_set_eoa(H5FD_t *_file, *------------------------------------------------------------------------- */ static haddr_t -H5FD_ros3_get_eof(const H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type) +H5FD_ros3_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_ros3_t *file = (const H5FD_ros3_t *)_file; @@ -1548,7 +1475,6 @@ H5FD_ros3_get_eof(const H5FD_t *_file, } /* end H5FD_ros3_get_eof() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_get_handle() @@ -1567,9 +1493,7 @@ H5FD_ros3_get_eof(const H5FD_t *_file, *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_get_handle(H5FD_t *_file, - hid_t H5_ATTR_UNUSED fapl, - void **file_handle) +H5FD_ros3_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; herr_t ret_value = SUCCEED; @@ -1591,7 +1515,6 @@ done: } /* end H5FD_ros3_get_handle() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_read() @@ -1615,12 +1538,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_read(H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, /* start offset */ - size_t size, /* length of read */ - void *buf) /* out */ +H5FD_ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t addr, /* start offset */ + size_t size, /* length of read */ + void * buf) /* out */ { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; size_t filesize = 0; @@ -1631,7 +1552,6 @@ H5FD_ros3_read(H5FD_t *_file, unsigned bin_i = 0; #endif /* ROS3_STATS */ - FUNC_ENTER_NOAPI_NOINIT #if ROS3_DEBUG @@ -1661,9 +1581,7 @@ H5FD_ros3_read(H5FD_t *_file, break; } } - bin = (type == H5FD_MEM_DRAW) - ? &file->raw[bin_i] - : &file->meta[bin_i]; + bin = (type == H5FD_MEM_DRAW) ? &file->raw[bin_i] : &file->meta[bin_i]; /* Store collected stats in appropriate bin */ @@ -1689,7 +1607,6 @@ done: } /* end H5FD_ros3_read() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_write() @@ -1709,12 +1626,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_write(H5FD_t H5_ATTR_UNUSED *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t H5_ATTR_UNUSED addr, - size_t H5_ATTR_UNUSED size, - const void H5_ATTR_UNUSED *buf) +H5FD_ros3_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) { herr_t ret_value = FAIL; @@ -1724,15 +1637,13 @@ H5FD_ros3_write(H5FD_t H5_ATTR_UNUSED *_file, HDfprintf(stdout, "H5FD_ros3_write() called.\n"); #endif - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, - "cannot write to read-only file.") + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot write to read-only file.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_ros3_write() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_truncate() @@ -1754,9 +1665,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, - hid_t H5_ATTR_UNUSED dxpl_id, - hbool_t H5_ATTR_UNUSED closing) +H5FD_ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { herr_t ret_value = SUCCEED; @@ -1766,15 +1675,13 @@ H5FD_ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, HDfprintf(stdout, "H5FD_ros3_truncate() called.\n"); #endif - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, - "cannot truncate read-only file.") + HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot truncate read-only file.") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_ros3_truncate() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_lock() @@ -1797,15 +1704,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_ros3_lock(H5FD_t H5_ATTR_UNUSED *_file, - hbool_t H5_ATTR_UNUSED rw) +H5FD_ros3_lock(H5FD_t H5_ATTR_UNUSED *_file, hbool_t H5_ATTR_UNUSED rw) { FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_ros3_lock() */ - /*------------------------------------------------------------------------- * * Function: H5FD_ros3_unlock() @@ -1833,4 +1738,3 @@ H5FD_ros3_unlock(H5FD_t H5_ATTR_UNUSED *_file) } /* end H5FD_ros3_unlock() */ #endif /* H5_HAVE_ROS3_VFD */ - diff --git a/src/H5FDros3.h b/src/H5FDros3.h index 457326e..4290a63 100644 --- a/src/H5FDros3.h +++ b/src/H5FDros3.h @@ -22,9 +22,9 @@ #define H5FDros3_H #ifdef H5_HAVE_ROS3_VFD -#define H5FD_ROS3 (H5FD_ros3_init()) +#define H5FD_ROS3 (H5FD_ros3_init()) #else -#define H5FD_ROS3 (H5I_INVALID_HID) +#define H5FD_ROS3 (H5I_INVALID_HID) #endif /* H5_HAVE_ROS3_VFD */ #ifdef H5_HAVE_ROS3_VFD @@ -71,11 +71,11 @@ * ****************************************************************************/ -#define H5FD_CURR_ROS3_FAPL_T_VERSION 1 +#define H5FD_CURR_ROS3_FAPL_T_VERSION 1 -#define H5FD_ROS3_MAX_REGION_LEN 32 -#define H5FD_ROS3_MAX_SECRET_ID_LEN 128 -#define H5FD_ROS3_MAX_SECRET_KEY_LEN 128 +#define H5FD_ROS3_MAX_REGION_LEN 32 +#define H5FD_ROS3_MAX_SECRET_ID_LEN 128 +#define H5FD_ROS3_MAX_SECRET_KEY_LEN 128 typedef struct H5FD_ros3_fapl_t { int32_t version; @@ -85,12 +85,11 @@ typedef struct H5FD_ros3_fapl_t { char secret_key[H5FD_ROS3_MAX_SECRET_KEY_LEN + 1]; } H5FD_ros3_fapl_t; - #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_ros3_init(void); +H5_DLL hid_t H5FD_ros3_init(void); H5_DLL herr_t H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_out); H5_DLL herr_t H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa); @@ -101,5 +100,3 @@ H5_DLL herr_t H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa); #endif /* H5_HAVE_ROS3_VFD */ #endif /* ifndef H5FDros3_H */ - - diff --git a/src/H5FDs3comms.c b/src/H5FDs3comms.c index d9d4c88..19900e1 100644 --- a/src/H5FDs3comms.c +++ b/src/H5FDs3comms.c @@ -67,7 +67,6 @@ */ #define S3COMMS_MAX_RANGE_STRING_SIZE 128 - /******************/ /* Local Typedefs */ /******************/ @@ -81,9 +80,9 @@ * pointer to data region and record of bytes written (offset) */ struct s3r_datastruct { - unsigned long magic; - char *data; - size_t size; + unsigned long magic; + char * data; + size_t size; }; #define S3COMMS_CALLBACK_DATASTRUCT_MAGIC 0x28c2b2ul @@ -91,10 +90,7 @@ struct s3r_datastruct { /* Local Prototypes */ /********************/ -size_t curlwritecallback(char *ptr, - size_t size, - size_t nmemb, - void *userdata); +size_t curlwritecallback(char *ptr, size_t size, size_t nmemb, void *userdata); herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle); @@ -114,7 +110,6 @@ herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle); /* Functions */ /*************/ - /*---------------------------------------------------------------------------- * * Function: curlwritecallback() @@ -139,10 +134,7 @@ herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle); *---------------------------------------------------------------------------- */ size_t -curlwritecallback(char *ptr, - size_t size, - size_t nmemb, - void *userdata) +curlwritecallback(char *ptr, size_t size, size_t nmemb, void *userdata) { struct s3r_datastruct *sds = (struct s3r_datastruct *)userdata; size_t product = (size * nmemb); @@ -162,7 +154,6 @@ curlwritecallback(char *ptr, } /* end curlwritecallback() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_hrb_node_set() @@ -217,17 +208,14 @@ curlwritecallback(char *ptr, *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_hrb_node_set( - hrb_node_t **L, - const char *name, - const char *value) +H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) { size_t i = 0; - char *valuecpy = NULL; - char *namecpy = NULL; + char * valuecpy = NULL; + char * namecpy = NULL; size_t namelen = 0; - char *lowername = NULL; - char *nvcat = NULL; + char * lowername = NULL; + char * nvcat = NULL; hrb_node_t *node_ptr = NULL; hrb_node_t *new_node = NULL; hbool_t is_looking = TRUE; @@ -249,8 +237,7 @@ H5FD_s3comms_hrb_node_set( #endif if (name == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to operate on null name.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to operate on null name.\n"); } namelen = HDstrlen(name); @@ -262,8 +249,7 @@ H5FD_s3comms_hrb_node_set( */ lowername = (char *)H5MM_malloc(sizeof(char) * (namelen + 1)); if (lowername == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "cannot make space for lowercase name copy.\n"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for lowercase name copy.\n"); } for (i = 0; i < namelen; i++) { lowername[i] = (char)tolower((int)name[i]); @@ -278,41 +264,35 @@ H5FD_s3comms_hrb_node_set( int ret = 0; size_t valuelen = HDstrlen(value); size_t catlen = namelen + valuelen + 2; /* +2 from ": " */ - size_t catwrite = catlen + 3; /* 3 not 1 to quiet compiler warning */ - + size_t catwrite = catlen + 3; /* 3 not 1 to quiet compiler warning */ namecpy = (char *)H5MM_malloc(sizeof(char) * (namelen + 1)); if (namecpy == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "cannot make space for name copy.\n"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for name copy.\n"); } HDmemcpy(namecpy, name, (namelen + 1)); valuecpy = (char *)H5MM_malloc(sizeof(char) * (valuelen + 1)); if (valuecpy == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "cannot make space for value copy.\n"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for value copy.\n"); } HDmemcpy(valuecpy, value, (valuelen + 1)); nvcat = (char *)H5MM_malloc(sizeof(char) * catwrite); if (nvcat == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "cannot make space for concatenated string.\n"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for concatenated string.\n"); } ret = HDsnprintf(nvcat, catwrite, "%s: %s", name, value); if (ret < 0 || (size_t)ret > catlen) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "cannot concatenate `%s: %s", name, value); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot concatenate `%s: %s", name, value); } - HDassert( catlen == HDstrlen(nvcat) ); + HDassert(catlen == HDstrlen(nvcat)); /* create new_node, should we need it */ new_node = (hrb_node_t *)H5MM_malloc(sizeof(hrb_node_t)); if (new_node == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "cannot make space for new set.\n"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for new set.\n"); } new_node->magic = S3COMMS_HRB_NODE_MAGIC; @@ -327,14 +307,14 @@ H5FD_s3comms_hrb_node_set( * ACT ON LIST * ***************/ - if (*L == NULL) { + if (*L == NULL) { if (value == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "trying to remove node from empty list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove node from empty list"); } else { #if S3COMMS_DEBUG -HDprintf("CREATE NEW\n"); fflush(stdout); + HDprintf("CREATE NEW\n"); + fflush(stdout); #endif /******************* * CREATE NEW LIST * @@ -352,8 +332,8 @@ HDprintf("CREATE NEW\n"); fflush(stdout); /* sanity-check pointer passed in */ - HDassert( (*L) != NULL ); - HDassert( (*L)->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert((*L) != NULL); + HDassert((*L)->magic == S3COMMS_HRB_NODE_MAGIC); node_ptr = (*L); /* Check whether to modify/remove first node in list @@ -364,7 +344,8 @@ HDprintf("CREATE NEW\n"); fflush(stdout); if (value == NULL) { #if S3COMMS_DEBUG -HDprintf("REMOVE HEAD\n"); fflush(stdout); + HDprintf("REMOVE HEAD\n"); + fflush(stdout); #endif /*************** * REMOVE HEAD * @@ -373,41 +354,48 @@ HDprintf("REMOVE HEAD\n"); fflush(stdout); *L = node_ptr->next; #if S3COMMS_DEBUG -HDprintf("FREEING CAT (node)\n"); fflush(stdout); + HDprintf("FREEING CAT (node)\n"); + fflush(stdout); #endif H5MM_xfree(node_ptr->cat); #if S3COMMS_DEBUG -HDprintf("FREEING LOWERNAME (node)\n"); fflush(stdout); + HDprintf("FREEING LOWERNAME (node)\n"); + fflush(stdout); #endif H5MM_xfree(node_ptr->lowername); #if S3COMMS_DEBUG -HDprintf("FREEING NAME (node)\n"); fflush(stdout); + HDprintf("FREEING NAME (node)\n"); + fflush(stdout); #endif H5MM_xfree(node_ptr->name); #if S3COMMS_DEBUG -HDprintf("FREEING VALUE (node)\n"); fflush(stdout); + HDprintf("FREEING VALUE (node)\n"); + fflush(stdout); #endif H5MM_xfree(node_ptr->value); #if S3COMMS_DEBUG -HDprintf("MAGIC OK? %s\n", - (node_ptr->magic == S3COMMS_HRB_NODE_MAGIC) ? "YES" : "NO"); -fflush(stdout); + HDprintf("MAGIC OK? %s\n", (node_ptr->magic == S3COMMS_HRB_NODE_MAGIC) ? "YES" : "NO"); + fflush(stdout); #endif - HDassert( node_ptr->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(node_ptr->magic == S3COMMS_HRB_NODE_MAGIC); node_ptr->magic += 1ul; #if S3COMMS_DEBUG -HDprintf("FREEING POINTER\n"); fflush(stdout); + HDprintf("FREEING POINTER\n"); + fflush(stdout); #endif H5MM_xfree(node_ptr); #if S3COMMS_DEBUG -HDprintf("FREEING WORKING LOWERNAME\n"); fflush(stdout); + HDprintf("FREEING WORKING LOWERNAME\n"); + fflush(stdout); #endif - H5MM_xfree(lowername); lowername = NULL; + H5MM_xfree(lowername); + lowername = NULL; } else { #if S3COMMS_DEBUG -HDprintf("MODIFY HEAD\n"); fflush(stdout); + HDprintf("MODIFY HEAD\n"); + fflush(stdout); #endif /*************** * MODIFY HEAD * @@ -417,29 +405,28 @@ HDprintf("MODIFY HEAD\n"); fflush(stdout); H5MM_xfree(node_ptr->name); H5MM_xfree(node_ptr->value); - node_ptr->name = namecpy; + node_ptr->name = namecpy; node_ptr->value = valuecpy; - node_ptr->cat = nvcat; + node_ptr->cat = nvcat; H5MM_xfree(lowername); lowername = NULL; new_node->magic += 1ul; H5MM_xfree(new_node); - new_node = NULL; + new_node = NULL; } } - else - if (strcmp(lowername, node_ptr->lowername) < 0) { + else if (strcmp(lowername, node_ptr->lowername) < 0) { is_looking = FALSE; if (value == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "trying to remove a node 'before' head"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove a node 'before' head"); } else { #if S3COMMS_DEBUG -HDprintf("PREPEND NEW HEAD\n"); fflush(stdout); + HDprintf("PREPEND NEW HEAD\n"); + fflush(stdout); #endif /******************* * INSERT NEW HEAD * @@ -450,7 +437,7 @@ HDprintf("PREPEND NEW HEAD\n"); fflush(stdout); new_node->lowername = lowername; new_node->cat = nvcat; new_node->next = node_ptr; - *L = new_node; + *L = new_node; } } @@ -464,18 +451,18 @@ HDprintf("PREPEND NEW HEAD\n"); fflush(stdout); is_looking = FALSE; if (value == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "trying to remove absent node"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove absent node"); } else { #if S3COMMS_DEBUG -HDprintf("APPEND A NODE\n"); fflush(stdout); + HDprintf("APPEND A NODE\n"); + fflush(stdout); #endif /******************* * APPEND NEW NODE * *******************/ - HDassert( strcmp(lowername, node_ptr->lowername) > 0 ); + HDassert(strcmp(lowername, node_ptr->lowername) > 0); new_node->name = namecpy; new_node->value = valuecpy; new_node->lowername = lowername; @@ -483,24 +470,23 @@ HDprintf("APPEND A NODE\n"); fflush(stdout); node_ptr->next = new_node; } } - else - if (strcmp(lowername, node_ptr->next->lowername) < 0) { + else if (strcmp(lowername, node_ptr->next->lowername) < 0) { is_looking = FALSE; if (value == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "trying to remove absent node"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove absent node"); } else { #if S3COMMS_DEBUG -HDprintf("INSERT A NODE\n"); fflush(stdout); + HDprintf("INSERT A NODE\n"); + fflush(stdout); #endif /******************* * INSERT NEW NODE * *******************/ - HDassert( strcmp(lowername, node_ptr->lowername) > 0 ); + HDassert(strcmp(lowername, node_ptr->lowername) > 0); new_node->name = namecpy; new_node->value = valuecpy; new_node->lowername = lowername; @@ -509,8 +495,7 @@ HDprintf("INSERT A NODE\n"); fflush(stdout); node_ptr->next = new_node; } } - else - if (strcmp(lowername, node_ptr->next->lowername) == 0) { + else if (strcmp(lowername, node_ptr->next->lowername) == 0) { is_looking = FALSE; @@ -520,17 +505,18 @@ HDprintf("INSERT A NODE\n"); fflush(stdout); *****************/ hrb_node_t *tmp = node_ptr->next; - node_ptr->next = tmp->next; + node_ptr->next = tmp->next; #if S3COMMS_DEBUG -HDprintf("REMOVE A NODE\n"); fflush(stdout); + HDprintf("REMOVE A NODE\n"); + fflush(stdout); #endif H5MM_xfree(tmp->cat); H5MM_xfree(tmp->lowername); H5MM_xfree(tmp->name); H5MM_xfree(tmp->value); - HDassert( tmp->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(tmp->magic == S3COMMS_HRB_NODE_MAGIC); tmp->magic += 1ul; H5MM_xfree(tmp); @@ -539,7 +525,8 @@ HDprintf("REMOVE A NODE\n"); fflush(stdout); } else { #if S3COMMS_DEBUG -HDprintf("MODIFY A NODE\n"); fflush(stdout); + HDprintf("MODIFY A NODE\n"); + fflush(stdout); #endif /***************** * MODIFY A NODE * @@ -550,7 +537,7 @@ HDprintf("MODIFY A NODE\n"); fflush(stdout); H5MM_xfree(node_ptr->value); H5MM_xfree(node_ptr->cat); - HDassert( new_node->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(new_node->magic == S3COMMS_HRB_NODE_MAGIC); new_node->magic += 1ul; H5MM_xfree(new_node); H5MM_xfree(lowername); @@ -567,7 +554,7 @@ HDprintf("MODIFY A NODE\n"); fflush(stdout); * KEEP LOOKING * ****************/ - node_ptr = node_ptr->next; + node_ptr = node_ptr->next; } } /* end while is_looking */ @@ -575,12 +562,20 @@ done: if (ret_value == FAIL) { /* clean up */ - if (nvcat != NULL) { H5MM_xfree(nvcat); } - if (namecpy != NULL) { H5MM_xfree(namecpy); } - if (lowername != NULL) { H5MM_xfree(lowername); } - if (valuecpy != NULL) { H5MM_xfree(valuecpy); } - if (new_node != NULL) { - HDassert( new_node->magic == S3COMMS_HRB_NODE_MAGIC ); + if (nvcat != NULL) { + H5MM_xfree(nvcat); + } + if (namecpy != NULL) { + H5MM_xfree(namecpy); + } + if (lowername != NULL) { + H5MM_xfree(lowername); + } + if (valuecpy != NULL) { + H5MM_xfree(valuecpy); + } + if (new_node != NULL) { + HDassert(new_node->magic == S3COMMS_HRB_NODE_MAGIC); new_node->magic += 1ul; H5MM_xfree(new_node); } @@ -589,7 +584,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_hrb_node_set() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_hrb_destroy() @@ -629,8 +623,8 @@ done: herr_t H5FD_s3comms_hrb_destroy(hrb_t **_buf) { - hrb_t *buf = NULL; - herr_t ret_value = SUCCEED; + hrb_t *buf = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -641,8 +635,7 @@ H5FD_s3comms_hrb_destroy(hrb_t **_buf) if (_buf != NULL && *_buf != NULL) { buf = *_buf; if (buf->magic != S3COMMS_HRB_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "pointer's magic does not match.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pointer's magic does not match.\n"); } H5MM_xfree(buf->verb); @@ -657,7 +650,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_s3comms_hrb_destroy() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_hrb_init_request() @@ -688,18 +680,16 @@ done: *---------------------------------------------------------------------------- */ hrb_t * -H5FD_s3comms_hrb_init_request(const char *_verb, - const char *_resource, - const char *_http_version) +H5FD_s3comms_hrb_init_request(const char *_verb, const char *_resource, const char *_http_version) { - hrb_t *request = NULL; - char *res = NULL; - size_t reslen = 0; - hrb_t *ret_value = NULL; - char *verb = NULL; - size_t verblen = 0; - char *vrsn = NULL; - size_t vrsnlen = 0; + hrb_t *request = NULL; + char * res = NULL; + size_t reslen = 0; + hrb_t *ret_value = NULL; + char * verb = NULL; + size_t verblen = 0; + char * vrsn = NULL; + size_t vrsnlen = 0; FUNC_ENTER_NOAPI_NOINIT @@ -708,8 +698,7 @@ H5FD_s3comms_hrb_init_request(const char *_verb, #endif if (_resource == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "resource string cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "resource string cannot be null.\n"); } /* populate valid NULLs with defaults @@ -726,57 +715,48 @@ H5FD_s3comms_hrb_init_request(const char *_verb, */ request = (hrb_t *)H5MM_malloc(sizeof(hrb_t)); if (request == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, - "no space for request structure"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for request structure"); } request->magic = S3COMMS_HRB_MAGIC; request->body = NULL; request->body_len = 0; request->first_header = NULL; - - /* malloc and copy strings for the structure */ reslen = HDstrlen(_resource); if (_resource[0] == '/') { - res = (char *)H5MM_malloc(sizeof(char) * (reslen+1)); + res = (char *)H5MM_malloc(sizeof(char) * (reslen + 1)); if (res == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, - "no space for resource string"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for resource string"); } - HDmemcpy(res, _resource, (reslen+1)); + HDmemcpy(res, _resource, (reslen + 1)); } else { - res = (char *)H5MM_malloc(sizeof(char) * (reslen+2)); + res = (char *)H5MM_malloc(sizeof(char) * (reslen + 2)); if (res == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, - "no space for resource string"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for resource string"); } *res = '/'; - HDmemcpy((&res[1]), _resource, (reslen+1)); - HDassert( (reslen+1) == HDstrlen(res) ); + HDmemcpy((&res[1]), _resource, (reslen + 1)); + HDassert((reslen + 1) == HDstrlen(res)); } /* end if (else resource string not starting with '/') */ verblen = HDstrlen(_verb) + 1; - verb = (char *)H5MM_malloc(sizeof(char) * verblen); + verb = (char *)H5MM_malloc(sizeof(char) * verblen); if (verb == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "no space for verb string"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no space for verb string"); } HDstrncpy(verb, _verb, verblen); vrsnlen = HDstrlen(_http_version) + 1; - vrsn = (char *)H5MM_malloc(sizeof(char) * vrsnlen); + vrsn = (char *)H5MM_malloc(sizeof(char) * vrsnlen); if (vrsn == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "no space for http-version string"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no space for http-version string"); } HDstrncpy(vrsn, _http_version, vrsnlen); - - /* place new copies into structure */ request->resource = res; @@ -789,21 +769,23 @@ done: /* if there is an error, clean up after ourselves */ if (ret_value == NULL) { - if (request != NULL) H5MM_xfree(request); - if (vrsn != NULL) H5MM_xfree(vrsn); - if (verb != NULL) H5MM_xfree(verb); - if (res != NULL) H5MM_xfree(res); + if (request != NULL) + H5MM_xfree(request); + if (vrsn != NULL) + H5MM_xfree(vrsn); + if (verb != NULL) + H5MM_xfree(verb); + if (res != NULL) + H5MM_xfree(res); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_s3comms_hrb_init_request() */ - /**************************************************************************** * S3R FUNCTIONS ****************************************************************************/ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_close() @@ -837,12 +819,10 @@ H5FD_s3comms_s3r_close(s3r_t *handle) #endif if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null.\n"); } if (handle->magic != S3COMMS_S3R_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle has invalid magic.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic.\n"); } curl_easy_cleanup(handle->curlhandle); @@ -851,12 +831,11 @@ H5FD_s3comms_s3r_close(s3r_t *handle) H5MM_xfree(handle->region); H5MM_xfree(handle->signing_key); - HDassert( handle->httpverb != NULL ); + HDassert(handle->httpverb != NULL); H5MM_xfree(handle->httpverb); if (FAIL == H5FD_s3comms_free_purl(handle->purl)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to release parsed url structure") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to release parsed url structure") } H5MM_xfree(handle); @@ -865,7 +844,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_s3comms_s3r_close */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_get_filesize() @@ -900,7 +878,6 @@ H5FD_s3comms_s3r_get_filesize(s3r_t *handle) FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_s3comms_s3r_get_filesize */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_getsize() @@ -937,15 +914,12 @@ herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle) { uintmax_t content_length = 0; - CURL *curlh = NULL; - char *end = NULL; - char *headerresponse = NULL; - struct s3r_datastruct sds = { - S3COMMS_CALLBACK_DATASTRUCT_MAGIC, - NULL, - 0 }; - char *start = NULL; - herr_t ret_value = SUCCEED; + CURL * curlh = NULL; + char * end = NULL; + char * headerresponse = NULL; + struct s3r_datastruct sds = {S3COMMS_CALLBACK_DATASTRUCT_MAGIC, NULL, 0}; + char * start = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -954,16 +928,13 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) #endif if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null.\n"); } if (handle->magic != S3COMMS_S3R_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle has invalid magic.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic.\n"); } if (handle->curlhandle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle has bad (null) curlhandle.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) curlhandle.\n") } /******************** @@ -972,38 +943,28 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) curlh = handle->curlhandle; - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_NOBODY, - 1L) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, 1L)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_NOBODY). " "(placeholder flags)"); } - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_HEADERDATA, - &sds) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, &sds)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_HEADERDATA). " "(placeholder flags)"); } - HDassert( handle->httpverb == NULL ); + HDassert(handle->httpverb == NULL); handle->httpverb = (char *)H5MM_malloc(sizeof(char) * 16); if (handle->httpverb == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "unable to allocate space for S3 request HTTP verb"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "unable to allocate space for S3 request HTTP verb"); } HDmemcpy(handle->httpverb, "HEAD", 5); headerresponse = (char *)H5MM_malloc(sizeof(char) * CURL_MAX_HTTP_HEADER); if (headerresponse == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "unable to allocate space for curl header response"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "unable to allocate space for curl header response"); } sds.data = headerresponse; @@ -1015,64 +976,54 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) * but, with a NULL destination and NOBODY and HEADERDATA supplied above, * only http metadata will be sent by server and recorded by s3comms */ - if (FAIL == - H5FD_s3comms_s3r_read(handle, 0, 0, NULL) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem in reading during getsize.\n"); + if (FAIL == H5FD_s3comms_s3r_read(handle, 0, 0, NULL)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem in reading during getsize.\n"); } if (sds.size > CURL_MAX_HTTP_HEADER) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "HTTP metadata buffer overrun\n"); - } else if (sds.size == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "No HTTP metadata\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HTTP metadata buffer overrun\n"); + } + else if (sds.size == 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "No HTTP metadata\n"); #if S3COMMS_DEBUG - } else { + } + else { HDfprintf(stderr, "GETSIZE: OK\n"); #endif } - /****************** * PARSE RESPONSE * ******************/ - start = strstr(headerresponse, - "\r\nContent-Length: "); + start = strstr(headerresponse, "\r\nContent-Length: "); if (start == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "could not find \"Content-Length\" in response.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not find \"Content-Length\" in response.\n"); } /* move "start" to beginning of value in line; find end of line */ start = start + HDstrlen("\r\nContent-Length: "); - end = strstr(start, "\r\n"); + end = strstr(start, "\r\n"); if (end == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "could not find end of content length line"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not find end of content length line"); } /* place null terminator at end of numbers */ *end = '\0'; - content_length = strtoumax((const char *)start, - NULL, - 0); + content_length = strtoumax((const char *)start, NULL, 0); if (UINTMAX_MAX > SIZE_MAX && content_length > SIZE_MAX) { HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "content_length overflows size_t\n"); } - if (content_length == 0 || - errno == ERANGE) /* errno set by strtoumax*/ + if (content_length == 0 || errno == ERANGE) /* errno set by strtoumax*/ { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "could not convert found \"Content-Length\" response (\"%s\")", - start); /* range is null-terminated, remember */ + "could not convert found \"Content-Length\" response (\"%s\")", + start); /* range is null-terminated, remember */ } handle->filesize = (size_t)content_length; @@ -1081,21 +1032,13 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) * UNDO HEAD SETTINGS * **********************/ - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_NOBODY, - NULL) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, NULL)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_NOBODY). " "(placeholder flags)"); } - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_HEADERDATA, - NULL) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, NULL)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_HEADERDATA). " "(placeholder flags)"); @@ -1109,7 +1052,6 @@ done: } /* H5FD_s3comms_s3r_getsize */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_open() @@ -1150,16 +1092,13 @@ done: *---------------------------------------------------------------------------- */ s3r_t * -H5FD_s3comms_s3r_open(const char *url, - const char *region, - const char *id, - const unsigned char *signing_key) +H5FD_s3comms_s3r_open(const char *url, const char *region, const char *id, const unsigned char *signing_key) { size_t tmplen = 0; - CURL *curlh = NULL; - s3r_t *handle = NULL; + CURL * curlh = NULL; + s3r_t * handle = NULL; parsed_url_t *purl = NULL; - s3r_t *ret_value = NULL; + s3r_t * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -1167,82 +1106,67 @@ H5FD_s3comms_s3r_open(const char *url, HDfprintf(stdout, "called H5FD_s3comms_s3r_open.\n"); #endif - - if (url == NULL || url[0] == '\0') { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "url cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "url cannot be null.\n"); } if (FAIL == H5FD_s3comms_parse_url(url, &purl)) { /* probably a malformed url, but could be internal error */ - HGOTO_ERROR(H5E_ARGS, H5E_CANTCREATE, NULL, - "unable to create parsed url structure"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTCREATE, NULL, "unable to create parsed url structure"); } - HDassert( purl != NULL ); /* if above passes, this must be true */ - HDassert( purl->magic == S3COMMS_PARSED_URL_MAGIC ); + HDassert(purl != NULL); /* if above passes, this must be true */ + HDassert(purl->magic == S3COMMS_PARSED_URL_MAGIC); handle = (s3r_t *)H5MM_malloc(sizeof(s3r_t)); if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, - "could not malloc space for handle.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "could not malloc space for handle.\n"); } - handle->magic = S3COMMS_S3R_MAGIC; - handle->purl = purl; - handle->filesize = 0; - handle->region = NULL; - handle->secret_id = NULL; - handle->signing_key = NULL; - handle->httpverb = NULL; + handle->magic = S3COMMS_S3R_MAGIC; + handle->purl = purl; + handle->filesize = 0; + handle->region = NULL; + handle->secret_id = NULL; + handle->signing_key = NULL; + handle->httpverb = NULL; /************************************* * RECORD AUTHENTICATION INFORMATION * *************************************/ - if ((region != NULL && *region != '\0') || - (id != NULL && *id != '\0') || - (signing_key != NULL)) - { + if ((region != NULL && *region != '\0') || (id != NULL && *id != '\0') || (signing_key != NULL)) { /* if one exists, all three must exist */ if (region == NULL || region[0] == '\0') { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "region cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "region cannot be null.\n"); } if (id == NULL || id[0] == '\0') { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "secret id cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "secret id cannot be null.\n"); } if (signing_key == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "signing key cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "signing key cannot be null.\n"); } /* copy strings */ - tmplen = HDstrlen(region) + 1; + tmplen = HDstrlen(region) + 1; handle->region = (char *)H5MM_malloc(sizeof(char) * tmplen); if (handle->region == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "could not malloc space for handle region copy.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle region copy.\n"); } HDmemcpy(handle->region, region, tmplen); - tmplen = HDstrlen(id) + 1; + tmplen = HDstrlen(id) + 1; handle->secret_id = (char *)H5MM_malloc(sizeof(char) * tmplen); if (handle->secret_id == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "could not malloc space for handle ID copy.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle ID copy.\n"); } HDmemcpy(handle->secret_id, id, tmplen); - tmplen = SHA256_DIGEST_LENGTH; - handle->signing_key = - (unsigned char *)H5MM_malloc(sizeof(unsigned char) * tmplen); + tmplen = SHA256_DIGEST_LENGTH; + handle->signing_key = (unsigned char *)H5MM_malloc(sizeof(unsigned char) * tmplen); if (handle->signing_key == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "could not malloc space for handle key copy.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle key copy.\n"); } HDmemcpy(handle->signing_key, signing_key, tmplen); } /* if authentication information provided */ @@ -1254,55 +1178,34 @@ H5FD_s3comms_s3r_open(const char *url, curlh = curl_easy_init(); if (curlh == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "problem creating curl easy handle!\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem creating curl easy handle!\n"); } - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_HTTPGET, - 1L) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPGET, 1L)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_HTTPGET). " "(placeholder flags)"); } - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_HTTP_VERSION, - CURL_HTTP_VERSION_1_1) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_HTTP_VERSION). " "(placeholder flags)"); } - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_FAILONERROR, - 1L) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_FAILONERROR, 1L)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_FAILONERROR). " "(placeholder flags)"); } - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_WRITEFUNCTION, - curlwritecallback) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEFUNCTION, curlwritecallback)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_WRITEFUNCTION). " "(placeholder flags)"); } - if ( CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_URL, - url) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_URL, url)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_URL). " "(placeholder flags)"); @@ -1322,18 +1225,15 @@ H5FD_s3comms_s3r_open(const char *url, * GET FILE SIZE * *******************/ - if (FAIL == - H5FD_s3comms_s3r_getsize(handle) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "problem in H5FD_s3comms_s3r_getsize.\n"); + if (FAIL == H5FD_s3comms_s3r_getsize(handle)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem in H5FD_s3comms_s3r_getsize.\n"); } /********************* * FINAL PREPARATION * *********************/ - HDassert( handle->httpverb != NULL ); + HDassert(handle->httpverb != NULL); HDmemcpy(handle->httpverb, "GET", 4); ret_value = handle; @@ -1344,8 +1244,7 @@ done: curl_easy_cleanup(curlh); } if (FAIL == H5FD_s3comms_free_purl(purl)) { - HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, - "unable to free parsed url structure") + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to free parsed url structure") } if (handle != NULL) { H5MM_xfree(handle->region); @@ -1362,7 +1261,6 @@ done: } /* H5FD_s3comms_s3r_open */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_read() @@ -1405,23 +1303,20 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_s3r_read(s3r_t *handle, - haddr_t offset, - size_t len, - void *dest) +H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) { - CURL *curlh = NULL; - CURLcode p_status = CURLE_OK; - struct curl_slist *curlheaders = NULL; - hrb_node_t *headers = NULL; - hrb_node_t *node = NULL; - struct tm *now = NULL; - char *rangebytesstr = NULL; - hrb_t *request = NULL; - int ret = 0; /* working variable to check */ - /* return value of HDsnprintf */ - struct s3r_datastruct *sds = NULL; - herr_t ret_value = SUCCEED; + CURL * curlh = NULL; + CURLcode p_status = CURLE_OK; + struct curl_slist *curlheaders = NULL; + hrb_node_t * headers = NULL; + hrb_node_t * node = NULL; + struct tm * now = NULL; + char * rangebytesstr = NULL; + hrb_t * request = NULL; + int ret = 0; /* working variable to check */ + /* return value of HDsnprintf */ + struct s3r_datastruct *sds = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1434,25 +1329,20 @@ H5FD_s3comms_s3r_read(s3r_t *handle, **************************************/ if (handle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null.\n"); } if (handle->magic != S3COMMS_S3R_MAGIC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle has invalid magic.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic.\n"); } if (handle->curlhandle == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle has bad (null) curlhandle.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) curlhandle.\n") } if (handle->purl == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle has bad (null) url.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) url.\n") } - HDassert( handle->purl->magic == S3COMMS_PARSED_URL_MAGIC ); + HDassert(handle->purl->magic == S3COMMS_PARSED_URL_MAGIC); if (offset > handle->filesize || (len + offset) > handle->filesize) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to read past EoF") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to read past EoF") } curlh = handle->curlhandle; @@ -1462,21 +1352,15 @@ H5FD_s3comms_s3r_read(s3r_t *handle, *********************/ if (dest != NULL) { - sds = (struct s3r_datastruct *)H5MM_malloc( - sizeof(struct s3r_datastruct)); + sds = (struct s3r_datastruct *)H5MM_malloc(sizeof(struct s3r_datastruct)); if (sds == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "could not malloc destination datastructure.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc destination datastructure.\n"); } sds->magic = S3COMMS_CALLBACK_DATASTRUCT_MAGIC; - sds->data = (char *)dest; - sds->size = 0; - if (CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_WRITEDATA, - sds) ) - { + sds->data = (char *)dest; + sds->size = 0; + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEDATA, sds)) { HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "error while setting CURL option (CURLOPT_WRITEDATA). " "(placeholder flags)"); @@ -1488,34 +1372,24 @@ H5FD_s3comms_s3r_read(s3r_t *handle, *********************/ if (len > 0) { - rangebytesstr = (char *)H5MM_malloc(sizeof(char) * \ - (S3COMMS_MAX_RANGE_STRING_SIZE+1) ); + rangebytesstr = (char *)H5MM_malloc(sizeof(char) * (S3COMMS_MAX_RANGE_STRING_SIZE + 1)); if (rangebytesstr == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "could not malloc range format string.\n"); - } - ret = HDsnprintf(rangebytesstr, - (S3COMMS_MAX_RANGE_STRING_SIZE), - "bytes="H5_PRINTF_HADDR_FMT"-"H5_PRINTF_HADDR_FMT, - offset, - offset + len - 1); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc range format string.\n"); + } + ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), + "bytes=" H5_PRINTF_HADDR_FMT "-" H5_PRINTF_HADDR_FMT, offset, offset + len - 1); if (ret <= 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to format HTTP Range value"); - } else if (offset > 0) { - rangebytesstr = (char *)H5MM_malloc(sizeof(char) * \ - (S3COMMS_MAX_RANGE_STRING_SIZE+1)); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format HTTP Range value"); + } + else if (offset > 0) { + rangebytesstr = (char *)H5MM_malloc(sizeof(char) * (S3COMMS_MAX_RANGE_STRING_SIZE + 1)); if (rangebytesstr == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "could not malloc range format string.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc range format string.\n"); } - ret = HDsnprintf(rangebytesstr, - (S3COMMS_MAX_RANGE_STRING_SIZE), - "bytes="H5_PRINTF_HADDR_FMT"-", - offset); + ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), "bytes=" H5_PRINTF_HADDR_FMT "-", + offset); if (ret <= 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to format HTTP Range value"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format HTTP Range value"); } /******************* @@ -1531,40 +1405,37 @@ H5FD_s3comms_s3r_read(s3r_t *handle, char *bytesrange_ptr = NULL; /* pointer past "bytes=" portion */ bytesrange_ptr = strchr(rangebytesstr, '='); - HDassert( bytesrange_ptr != NULL ); + HDassert(bytesrange_ptr != NULL); bytesrange_ptr++; /* move to first char past '=' */ - HDassert( *bytesrange_ptr != '\0' ); + HDassert(*bytesrange_ptr != '\0'); - if (CURLE_OK != - curl_easy_setopt(curlh, - CURLOPT_RANGE, - bytesrange_ptr) ) - { + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, bytesrange_ptr)) { HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, - "error while setting CURL option (CURLOPT_RANGE). "); + "error while setting CURL option (CURLOPT_RANGE). "); } } - } else { + } + else { /* authenticate request */ - char authorization[512+1]; - /* 512 := approximate max length... - * 67 - * + 8 - * + 64 - * + 128 - * + 20 - * + 128 - */ - char buffer1[512+1]; /* -> Canonical Request -> Signature */ - char buffer2[256+1]; /* -> String To Sign -> Credential */ + char authorization[512 + 1]; + /* 512 := approximate max length... + * 67 + * + 8 + * + 64 + * + 128 + * + 20 + * + 128 + */ + char buffer1[512 + 1]; /* -> Canonical Request -> Signature */ + char buffer2[256 + 1]; /* -> String To Sign -> Credential */ char iso8601now[ISO8601_SIZE]; - char signed_headers[48+1]; - /* should be large enough for nominal listing: - * "host;range;x-amz-content-sha256;x-amz-date" - * + '\0', with "range;" possibly absent - */ + char signed_headers[48 + 1]; + /* should be large enough for nominal listing: + * "host;range;x-amz-content-sha256;x-amz-date" + * + '\0', with "range;" possibly absent + */ /* zero start of strings */ authorization[0] = 0; @@ -1576,181 +1447,113 @@ H5FD_s3comms_s3r_read(s3r_t *handle, /**** VERIFY INFORMATION EXISTS ****/ if (handle->region == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle must have non-null region.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null region.\n"); } if (handle->secret_id == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle must have non-null secret_id.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null secret_id.\n"); } if (handle->signing_key == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle must have non-null signing_key.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null signing_key.\n"); } if (handle->httpverb == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle must have non-null httpverb.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null httpverb.\n"); } if (handle->purl->host == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle must have non-null host.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null host.\n"); } if (handle->purl->path == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "handle must have non-null resource.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null resource.\n"); } /**** CREATE HTTP REQUEST STRUCTURE (hrb_t) ****/ - request = H5FD_s3comms_hrb_init_request( - (const char *)handle->httpverb, - (const char *)handle->purl->path, - "HTTP/1.1"); + request = H5FD_s3comms_hrb_init_request((const char *)handle->httpverb, + (const char *)handle->purl->path, "HTTP/1.1"); if (request == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "could not allocate hrb_t request.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not allocate hrb_t request.\n"); } - HDassert( request->magic == S3COMMS_HRB_MAGIC ); + HDassert(request->magic == S3COMMS_HRB_MAGIC); now = gmnow(); if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "could not format ISO8601 time.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not format ISO8601 time.\n"); } - if (FAIL == - H5FD_s3comms_hrb_node_set( - &headers, - "x-amz-date", - (const char *)iso8601now) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to set x-amz-date header") + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-date", (const char *)iso8601now)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set x-amz-date header") } if (headers == NULL) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list. " "(placeholder flags)\n"); } - HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); - if (FAIL == - H5FD_s3comms_hrb_node_set( - &headers, - "x-amz-content-sha256", - (const char *)EMPTY_SHA256) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to set x-amz-content-sha256 header") + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-content-sha256", (const char *)EMPTY_SHA256)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set x-amz-content-sha256 header") } if (headers == NULL) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list. " "(placeholder flags)\n"); } - HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); if (rangebytesstr != NULL) { - if (FAIL == - H5FD_s3comms_hrb_node_set( - &headers, - "Range", - (const char *)rangebytesstr) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to set range header") + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "Range", (const char *)rangebytesstr)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set range header") } if (headers == NULL) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list. " "(placeholder flags)\n"); } - HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); } - if (FAIL == - H5FD_s3comms_hrb_node_set( - &headers, - "Host", - (const char *)handle->purl->host) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to set host header") - } - if (headers == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem building headers list. " - "(placeholder flags)\n"); - } - HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "Host", (const char *)handle->purl->host)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set host header") + } + if (headers == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "problem building headers list. " + "(placeholder flags)\n"); + } + HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); request->first_header = headers; /**** COMPUTE AUTHORIZATION ****/ - if (FAIL == /* buffer1 -> canonical request */ - H5FD_s3comms_aws_canonical_request( - buffer1, - 512, - signed_headers, - 48, - request) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "(placeholder flags)\n"); + if (FAIL == /* buffer1 -> canonical request */ + H5FD_s3comms_aws_canonical_request(buffer1, 512, signed_headers, 48, request)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "(placeholder flags)\n"); } - if ( FAIL == /* buffer2->string-to-sign */ - H5FD_s3comms_tostringtosign(buffer2, - buffer1, - iso8601now, - handle->region) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "(placeholder flags)\n"); + if (FAIL == /* buffer2->string-to-sign */ + H5FD_s3comms_tostringtosign(buffer2, buffer1, iso8601now, handle->region)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "(placeholder flags)\n"); } - if (FAIL == /* buffer1 -> signature */ - H5FD_s3comms_HMAC_SHA256(handle->signing_key, - SHA256_DIGEST_LENGTH, - buffer2, - HDstrlen(buffer2), - buffer1) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "(placeholder flags)\n"); + if (FAIL == /* buffer1 -> signature */ + H5FD_s3comms_HMAC_SHA256(handle->signing_key, SHA256_DIGEST_LENGTH, buffer2, HDstrlen(buffer2), + buffer1)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "(placeholder flags)\n"); } iso8601now[8] = 0; /* trim to yyyyMMDD */ - ret = S3COMMS_FORMAT_CREDENTIAL(buffer2, - handle->secret_id, - iso8601now, - handle->region, - "s3"); + ret = S3COMMS_FORMAT_CREDENTIAL(buffer2, handle->secret_id, iso8601now, handle->region, "s3"); if (ret == 0 || ret >= S3COMMS_MAX_CREDENTIAL_SIZE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to format aws4 credential string"); - - ret = HDsnprintf( - authorization, - 512, - "AWS4-HMAC-SHA256 Credential=%s,SignedHeaders=%s,Signature=%s", - buffer2, - signed_headers, - buffer1); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format aws4 credential string"); + + ret = HDsnprintf(authorization, 512, "AWS4-HMAC-SHA256 Credential=%s,SignedHeaders=%s,Signature=%s", + buffer2, signed_headers, buffer1); if (ret <= 0 || ret >= 512) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to format aws4 authorization string"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format aws4 authorization string"); } /* append authorization header to http request buffer */ - if (H5FD_s3comms_hrb_node_set( - &headers, - "Authorization", - (const char *)authorization) - == FAIL) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to set Authorization header") + if (H5FD_s3comms_hrb_node_set(&headers, "Authorization", (const char *)authorization) == FAIL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set Authorization header") } if (headers == NULL) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, @@ -1766,9 +1569,8 @@ H5FD_s3comms_s3r_read(s3r_t *handle, node = request->first_header; while (node != NULL) { - HDassert( node->magic == S3COMMS_HRB_NODE_MAGIC ); - curlheaders = curl_slist_append(curlheaders, - (const char *)node->cat); + HDassert(node->magic == S3COMMS_HRB_NODE_MAGIC); + curlheaders = curl_slist_append(curlheaders, (const char *)node->cat); if (curlheaders == NULL) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not append header to curl slist. " @@ -1781,18 +1583,12 @@ H5FD_s3comms_s3r_read(s3r_t *handle, */ if (curlheaders == NULL) { /* above loop was probably never run */ - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "curlheaders was never populated.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "curlheaders was never populated.\n"); } /* finally, set http headers in curl handle */ - if (curl_easy_setopt( - curlh, - CURLOPT_HTTPHEADER, - curlheaders) - != CURLE_OK) - { + if (curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, curlheaders) != CURLE_OK) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option " "(CURLOPT_HTTPHEADER). (placeholder flags)"); @@ -1813,41 +1609,29 @@ H5FD_s3comms_s3r_read(s3r_t *handle, char curlerrbuf[CURL_ERROR_SIZE]; curlerrbuf[0] = '\0'; - if (CURLE_OK != - curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, curlerrbuf) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem setting error buffer") + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, curlerrbuf)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem setting error buffer") } p_status = curl_easy_perform(curlh); if (p_status != CURLE_OK) { - if (CURLE_OK != - curl_easy_getinfo(curlh, CURLINFO_RESPONSE_CODE, &httpcode) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem getting response code") + if (CURLE_OK != curl_easy_getinfo(curlh, CURLINFO_RESPONSE_CODE, &httpcode)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem getting response code") } - HDfprintf(stderr, "CURL ERROR CODE: %d\nHTTP CODE: %d\n", - p_status, httpcode); + HDfprintf(stderr, "CURL ERROR CODE: %d\nHTTP CODE: %d\n", p_status, httpcode); HDfprintf(stderr, "%s\n", curl_easy_strerror(p_status)); - HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, - "problem while performing request.\n"); + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "problem while performing request.\n"); } - if (CURLE_OK != - curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, NULL) ) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem unsetting error buffer") + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, NULL)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem unsetting error buffer") } } /* verbose error reporting */ #else p_status = curl_easy_perform(curlh); if (p_status != CURLE_OK) { - HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, - "curl cannot perform request\n") + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "curl cannot perform request\n") } #endif @@ -1888,43 +1672,35 @@ done: } if (request != NULL) { while (headers != NULL) - if (FAIL == - H5FD_s3comms_hrb_node_set(&headers, headers->name, NULL)) - { - HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "cannot release header node") + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, headers->name, NULL)) { + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot release header node") } - HDassert( NULL == headers ); + HDassert(NULL == headers); if (FAIL == H5FD_s3comms_hrb_destroy(&request)) { - HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "cannot release header request structure") + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot release header request structure") } - HDassert( NULL == request ); + HDassert(NULL == request); } if (curlh != NULL) { /* clear any Range */ - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, NULL) ) { - HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "cannot unset CURLOPT_RANGE") + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, NULL)) { + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot unset CURLOPT_RANGE") } /* clear headers */ - if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, NULL) ) { - HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "cannot unset CURLOPT_HTTPHEADER") + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, NULL)) { + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot unset CURLOPT_HTTPHEADER") } } FUNC_LEAVE_NOAPI(ret_value); } /* H5FD_s3comms_s3r_read */ - /**************************************************************************** * MISCELLANEOUS FUNCTIONS ****************************************************************************/ - /*---------------------------------------------------------------------------- * * Function: gmnow() @@ -1947,20 +1723,19 @@ struct tm * gmnow(void) { time_t now; - time_t *now_ptr = &now; + time_t * now_ptr = &now; struct tm *ret_value = NULL; /* Doctor assert, checks against error in time() */ - if ( (time_t)(-1) != time(now_ptr) ) { + if ((time_t)(-1) != time(now_ptr)) { ret_value = gmtime(now_ptr); } - HDassert( ret_value != NULL ); + HDassert(ret_value != NULL); return ret_value; } /* end gmnow() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_aws_canonical_request() @@ -2001,12 +1776,8 @@ gmnow(void) *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_aws_canonical_request( - char *canonical_request_dest, - int _cr_size, - char *signed_headers_dest, - int _sh_size, - hrb_t *http_request) +H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int _cr_size, char *signed_headers_dest, + int _sh_size, hrb_t *http_request) { hrb_node_t *node = NULL; const char *query_params = ""; /* unused at present */ @@ -2016,8 +1787,8 @@ H5FD_s3comms_aws_canonical_request( size_t sh_size = (size_t)_sh_size; size_t cr_len = 0; /* working length of canonical request str */ size_t sh_len = 0; /* working length of signed headers str */ - char tmpstr[256+1]; - tmpstr[256] = 0; /* terminating NULL */ + char tmpstr[256 + 1]; + tmpstr[256] = 0; /* terminating NULL */ /* "query params" refers to the optional element in the URL, e.g. * http://bucket.aws.com/myfile.txt?max-keys=2&prefix=J @@ -2036,41 +1807,30 @@ H5FD_s3comms_aws_canonical_request( #endif if (http_request == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "hrb object cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hrb object cannot be null.\n"); } - HDassert( http_request->magic == S3COMMS_HRB_MAGIC ); + HDassert(http_request->magic == S3COMMS_HRB_MAGIC); if (canonical_request_dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "canonical request destination cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "canonical request destination cannot be null.\n"); } if (signed_headers_dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "signed headers destination cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "signed headers destination cannot be null.\n"); } /* HTTP verb, resource path, and query string lines */ - cr_len = (HDstrlen(http_request->verb) + - HDstrlen(http_request->resource) + - HDstrlen(query_params) + - (size_t)3); /* three newline chars */ + cr_len = (HDstrlen(http_request->verb) + HDstrlen(http_request->resource) + HDstrlen(query_params) + + (size_t)3); /* three newline chars */ if (cr_len >= cr_size) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "not enough space in canonical request"); - } - ret = HDsnprintf( /* TODO: compiler warning */ - canonical_request_dest, - (cr_size-1), - "%s\n%s\n%s\n", - http_request->verb, - http_request->resource, - query_params); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in canonical request"); + } + ret = HDsnprintf(/* TODO: compiler warning */ + canonical_request_dest, (cr_size - 1), "%s\n%s\n%s\n", http_request->verb, + http_request->resource, query_params); if (ret < 0 || (size_t)ret >= cr_size) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to compose canonical request first line"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to compose canonical request first line"); } /* write in canonical headers, building signed headers concurrently @@ -2080,39 +1840,25 @@ H5FD_s3comms_aws_canonical_request( HDassert(node->magic == S3COMMS_HRB_NODE_MAGIC); - ret = HDsnprintf( - tmpstr, - 256, - "%s:%s\n", - node->lowername, - node->value); + ret = HDsnprintf(tmpstr, 256, "%s:%s\n", node->lowername, node->value); if (ret < 0 || ret >= 256) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to concatenate HTTP header %s:%s", - node->lowername, - node->value); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to concatenate HTTP header %s:%s", + node->lowername, node->value); } cr_len += HDstrlen(tmpstr); if (cr_len + 1 > cr_size) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "not enough space in canonical request"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in canonical request"); } strcat(canonical_request_dest, tmpstr); - ret = HDsnprintf( - tmpstr, - 256, - "%s;", - node->lowername); + ret = HDsnprintf(tmpstr, 256, "%s;", node->lowername); if (ret < 0 || ret >= 256) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to append semicolon to lowername %s", + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to append semicolon to lowername %s", node->lowername); } sh_len += HDstrlen(tmpstr); if (sh_len + 1 > sh_size) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "not enough space in signed headers"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in signed headers"); } strcat(signed_headers_dest, tmpstr); @@ -2136,7 +1882,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_aws_canonical_request() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_bytes_to_hex() @@ -2169,11 +1914,7 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_bytes_to_hex( - char *dest, - const unsigned char *msg, - size_t msg_len, - hbool_t lowercase) +H5FD_s3comms_bytes_to_hex(char *dest, const unsigned char *msg, size_t msg_len, hbool_t lowercase) { size_t i = 0; herr_t ret_value = SUCCEED; @@ -2185,23 +1926,17 @@ H5FD_s3comms_bytes_to_hex( #endif if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "hex destination cannot be null.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hex destination cannot be null.\n") } if (msg == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "bytes sequence cannot be null.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bytes sequence cannot be null.\n") } for (i = 0; i < msg_len; i++) { - int chars_written = HDsnprintf(&(dest[i * 2]), - 3, /* 'X', 'X', '\n' */ - (lowercase == TRUE) ? "%02x" : "%02X", - msg[i]); + int chars_written = HDsnprintf(&(dest[i * 2]), 3, /* 'X', 'X', '\n' */ + (lowercase == TRUE) ? "%02x" : "%02X", msg[i]); if (chars_written != 2) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem while writing hex chars for %c", - msg[i]); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem while writing hex chars for %c", msg[i]); } } @@ -2210,7 +1945,6 @@ done: } /* end H5FD_s3comms_bytes_to_hex() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_free_purl() @@ -2240,12 +1974,22 @@ H5FD_s3comms_free_purl(parsed_url_t *purl) #endif if (purl != NULL) { - HDassert( purl->magic == S3COMMS_PARSED_URL_MAGIC ); - if (purl->scheme != NULL) { H5MM_xfree(purl->scheme); } - if (purl->host != NULL) { H5MM_xfree(purl->host); } - if (purl->port != NULL) { H5MM_xfree(purl->port); } - if (purl->path != NULL) { H5MM_xfree(purl->path); } - if (purl->query != NULL) { H5MM_xfree(purl->query); } + HDassert(purl->magic == S3COMMS_PARSED_URL_MAGIC); + if (purl->scheme != NULL) { + H5MM_xfree(purl->scheme); + } + if (purl->host != NULL) { + H5MM_xfree(purl->host); + } + if (purl->port != NULL) { + H5MM_xfree(purl->port); + } + if (purl->path != NULL) { + H5MM_xfree(purl->path); + } + if (purl->query != NULL) { + H5MM_xfree(purl->query); + } purl->magic += 1ul; H5MM_xfree(purl); } @@ -2253,7 +1997,6 @@ H5FD_s3comms_free_purl(parsed_url_t *purl) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_s3comms_free_purl() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_HMAC_SHA256() @@ -2285,12 +2028,8 @@ H5FD_s3comms_free_purl(parsed_url_t *purl) *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_HMAC_SHA256( - const unsigned char *key, - size_t key_len, - const char *msg, - size_t msg_len, - char *dest) +H5FD_s3comms_HMAC_SHA256(const unsigned char *key, size_t key_len, const char *msg, size_t msg_len, + char *dest) { unsigned char md[SHA256_DIGEST_LENGTH]; unsigned int md_len = SHA256_DIGEST_LENGTH; @@ -2303,34 +2042,19 @@ H5FD_s3comms_HMAC_SHA256( #endif if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "destination cannot be null."); - } - - HMAC(EVP_sha256(), - key, - (int)key_len, - (const unsigned char *)msg, - msg_len, - md, - &md_len); - - if (H5FD_s3comms_bytes_to_hex( - dest, - (const unsigned char *)md, - (size_t)md_len, - true) - == FAIL) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "could not convert to hex string."); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null."); + } + + HMAC(EVP_sha256(), key, (int)key_len, (const unsigned char *)msg, msg_len, md, &md_len); + + if (H5FD_s3comms_bytes_to_hex(dest, (const unsigned char *)md, (size_t)md_len, true) == FAIL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not convert to hex string."); } done: FUNC_LEAVE_NOAPI(ret_value); } /* H5FD_s3comms_HMAC_SHA256 */ - /*----------------------------------------------------------------------------- * * Function: H5FD__s3comms_load_aws_creds_from_file() @@ -2381,12 +2105,8 @@ done: *----------------------------------------------------------------------------- */ static herr_t -H5FD__s3comms_load_aws_creds_from_file( - FILE *file, - const char *profile_name, - char *key_id, - char *access_key, - char *aws_region) +H5FD__s3comms_load_aws_creds_from_file(FILE *file, const char *profile_name, char *key_id, char *access_key, + char *aws_region) { char profile_line[32]; char buffer[128]; @@ -2395,17 +2115,17 @@ H5FD__s3comms_load_aws_creds_from_file( "aws_access_key_id", "aws_secret_access_key", }; - char * const setting_pointers[] = { + char *const setting_pointers[] = { aws_region, key_id, access_key, }; - unsigned setting_count = 3; - herr_t ret_value = SUCCEED; - unsigned buffer_i = 0; - unsigned setting_i = 0; - int found_setting = 0; - char *line_buffer = &(buffer[0]); + unsigned setting_count = 3; + herr_t ret_value = SUCCEED; + unsigned buffer_i = 0; + unsigned setting_i = 0; + int found_setting = 0; + char * line_buffer = &(buffer[0]); FUNC_ENTER_NOAPI_NOINIT @@ -2415,14 +2135,13 @@ H5FD__s3comms_load_aws_creds_from_file( /* format target line for start of profile */ if (32 < HDsnprintf(profile_line, 32, "[%s]", profile_name)) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, - "unable to format profile label") + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format profile label") } /* look for start of profile */ do { /* clear buffer */ - for (buffer_i=0; buffer_i < 128; buffer_i++) { + for (buffer_i = 0; buffer_i < 128; buffer_i++) { buffer[buffer_i] = 0; } @@ -2435,8 +2154,8 @@ H5FD__s3comms_load_aws_creds_from_file( /* extract credentials from lines */ do { /* clear buffer */ - for (buffer_i=0; buffer_i < 128; buffer_i++) { - buffer[buffer_i] = 0; + for (buffer_i = 0; buffer_i < 128; buffer_i++) { + buffer[buffer_i] = 0; } /* collect a line from file */ @@ -2451,11 +2170,10 @@ H5FD__s3comms_load_aws_creds_from_file( const char *setting_name = NULL; char line_prefix[128]; - setting_name = setting_names[setting_i]; + setting_name = setting_names[setting_i]; setting_name_len = HDstrlen(setting_name); if (HDsnprintf(line_prefix, 128, "%s=", setting_name) < 0) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, - "unable to format line prefix") + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format line prefix") } /* found a matching name? */ @@ -2464,7 +2182,7 @@ H5FD__s3comms_load_aws_creds_from_file( /* skip NULL destination buffer */ if (setting_pointers[setting_i] == NULL) { - break; + break; } /* advance to end of name in string */ @@ -2472,21 +2190,15 @@ H5FD__s3comms_load_aws_creds_from_file( line_buffer++; } while (*line_buffer != 0 && *line_buffer != '='); - if (*line_buffer == 0 || *(line_buffer+1) == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "incomplete assignment in file") + if (*line_buffer == 0 || *(line_buffer + 1) == 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incomplete assignment in file") } line_buffer++; /* was pointing at '='; advance */ /* copy line buffer into out pointer */ - if (HDstrncpy( - setting_pointers[setting_i], - (const char *)line_buffer, - HDstrlen(line_buffer)) - == NULL) - { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, - "unable to copy line into pointer") + if (HDstrncpy(setting_pointers[setting_i], (const char *)line_buffer, + HDstrlen(line_buffer)) == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to copy line into pointer") } /* "trim" tailing whitespace by replacing with null terminator*/ @@ -2497,15 +2209,14 @@ H5FD__s3comms_load_aws_creds_from_file( setting_pointers[setting_i][buffer_i] = '\0'; break; /* have read setting; don't compare with others */ - } /* end if possible name match */ - } /* end for each setting name */ + } /* end if possible name match */ + } /* end for each setting name */ } while (found_setting); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__s3comms_load_aws_creds_from_file() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_load_aws_profile() @@ -2539,16 +2250,14 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_load_aws_profile(const char *profile_name, - char *key_id_out, - char *secret_access_key_out, - char *aws_region_out) +H5FD_s3comms_load_aws_profile(const char *profile_name, char *key_id_out, char *secret_access_key_out, + char *aws_region_out) { herr_t ret_value = SUCCEED; - FILE *credfile = NULL; - char awspath[117]; - char filepath[128]; - int ret = 0; + FILE * credfile = NULL; + char awspath[117]; + char filepath[128]; + int ret = 0; FUNC_ENTER_NOAPI_NOINIT @@ -2557,84 +2266,62 @@ H5FD_s3comms_load_aws_profile(const char *profile_name, #endif #ifdef H5_HAVE_WIN32_API - ret = HDsnprintf(awspath, 117, "%s/.aws/", getenv("USERPROFILE")) ; + ret = HDsnprintf(awspath, 117, "%s/.aws/", getenv("USERPROFILE")); #else - ret = HDsnprintf(awspath, 117, "%s/.aws/", getenv("HOME")) ; + ret = HDsnprintf(awspath, 117, "%s/.aws/", getenv("HOME")); #endif - if (ret < 0 || (size_t)ret >= 117) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, - "unable to format home-aws path") + if (ret < 0 || (size_t)ret >= 117) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format home-aws path") } ret = HDsnprintf(filepath, 128, "%s%s", awspath, "credentials"); if (ret < 0 || (size_t)ret >= 128) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, - "unable to format credentials path") + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format credentials path") } credfile = fopen(filepath, "r"); if (credfile != NULL) { - if (H5FD__s3comms_load_aws_creds_from_file( - credfile, - profile_name, - key_id_out, - secret_access_key_out, - aws_region_out) - == FAIL) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to load from aws credentials") + if (H5FD__s3comms_load_aws_creds_from_file(credfile, profile_name, key_id_out, secret_access_key_out, + aws_region_out) == FAIL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to load from aws credentials") } if (fclose(credfile) == EOF) { - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, - "unable to close credentials file") + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close credentials file") } credfile = NULL; } /* end if credential file opened */ ret = HDsnprintf(filepath, 128, "%s%s", awspath, "config"); if (ret < 0 || (size_t)ret >= 128) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, - "unable to format config path") + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format config path") } credfile = fopen(filepath, "r"); if (credfile != NULL) { if (H5FD__s3comms_load_aws_creds_from_file( - credfile, - profile_name, - (*key_id_out == 0) ? key_id_out : NULL, + credfile, profile_name, (*key_id_out == 0) ? key_id_out : NULL, (*secret_access_key_out == 0) ? secret_access_key_out : NULL, - (*aws_region_out == 0) ? aws_region_out : NULL) - == FAIL) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unable to load from aws config") + (*aws_region_out == 0) ? aws_region_out : NULL) == FAIL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to load from aws config") } if (fclose(credfile) == EOF) { - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, - "unable to close config file") + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close config file") } credfile = NULL; } /* end if credential file opened */ /* fail if not all three settings were loaded */ - if (*key_id_out == 0 || - *secret_access_key_out == 0 || - *aws_region_out == 0) - { + if (*key_id_out == 0 || *secret_access_key_out == 0 || *aws_region_out == 0) { ret_value = FAIL; } done: if (credfile != NULL) { if (fclose(credfile) == EOF) { - HDONE_ERROR(H5E_ARGS, H5E_ARGS, FAIL, - "problem error-closing aws configuration file") + HDONE_ERROR(H5E_ARGS, H5E_ARGS, FAIL, "problem error-closing aws configuration file") } } FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_load_aws_profile() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_nlowercase() @@ -2662,10 +2349,7 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_nlowercase( - char *dest, - const char *s, - size_t len) +H5FD_s3comms_nlowercase(char *dest, const char *s, size_t len) { herr_t ret_value = SUCCEED; @@ -2676,15 +2360,14 @@ H5FD_s3comms_nlowercase( #endif if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "destination cannot be null.\n"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null.\n"); } if (len > 0) { HDmemcpy(dest, s, len); do { len--; - dest[len] = (char)tolower( (int)dest[len] ); + dest[len] = (char)tolower((int)dest[len]); } while (len > 0); } @@ -2692,7 +2375,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_nlowercase() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_parse_url() @@ -2725,17 +2407,15 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_parse_url( - const char *str, - parsed_url_t **_purl) +H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) { - parsed_url_t *purl = NULL; /* pointer to new structure */ - const char *tmpstr = NULL; /* working pointer in string */ - const char *curstr = str; /* "start" pointer in string */ - long int len = 0; /* substring length */ - long int urllen = 0; /* length of passed-in url string */ - unsigned int i = 0; - herr_t ret_value = FAIL; + parsed_url_t *purl = NULL; /* pointer to new structure */ + const char * tmpstr = NULL; /* working pointer in string */ + const char * curstr = str; /* "start" pointer in string */ + long int len = 0; /* substring length */ + long int urllen = 0; /* length of passed-in url string */ + unsigned int i = 0; + herr_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT; @@ -2744,16 +2424,14 @@ H5FD_s3comms_parse_url( #endif if (str == NULL || *str == '\0') { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "invalid url string"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid url string"); } urllen = (long int)HDstrlen(str); purl = (parsed_url_t *)H5MM_malloc(sizeof(parsed_url_t)); if (purl == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "can't allocate space for parsed_url_t"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for parsed_url_t"); } purl->magic = S3COMMS_PARSED_URL_MAGIC; purl->scheme = NULL; @@ -2768,35 +2446,28 @@ H5FD_s3comms_parse_url( tmpstr = HDstrchr(curstr, ':'); if (tmpstr == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "invalid SCHEME construction: probably not URL"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid SCHEME construction: probably not URL"); } len = tmpstr - curstr; - HDassert( (0 <= len) && (len < urllen) ); + HDassert((0 <= len) && (len < urllen)); /* check for restrictions */ for (i = 0; i < len; i++) { /* scheme = [a-zA-Z+-.]+ (terminated by ":") */ - if (!isalpha(curstr[i]) && - '+' != curstr[i] && - '-' != curstr[i] && - '.' != curstr[i]) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "invalid SCHEME construction"); + if (!isalpha(curstr[i]) && '+' != curstr[i] && '-' != curstr[i] && '.' != curstr[i]) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid SCHEME construction"); } } /* copy lowercased scheme to structure */ purl->scheme = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); if (purl->scheme == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "can't allocate space for SCHEME"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for SCHEME"); } (void)HDstrncpy(purl->scheme, curstr, (size_t)len); purl->scheme[len] = '\0'; - for ( i = 0; i < len; i++ ) { + for (i = 0; i < len; i++) { purl->scheme[i] = (char)tolower(purl->scheme[i]); } @@ -2812,8 +2483,7 @@ H5FD_s3comms_parse_url( /* IPv6 */ while (']' != *tmpstr) { if (tmpstr == 0) { /* end of string reached! */ - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "reached end of URL: incomplete IPv6 HOST"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reached end of URL: incomplete IPv6 HOST"); } tmpstr++; } @@ -2821,10 +2491,7 @@ H5FD_s3comms_parse_url( } /* end if (IPv6) */ else { while (0 != *tmpstr) { - if (':' == *tmpstr || - '/' == *tmpstr || - '?' == *tmpstr) - { + if (':' == *tmpstr || '/' == *tmpstr || '?' == *tmpstr) { break; } tmpstr++; @@ -2832,21 +2499,17 @@ H5FD_s3comms_parse_url( } /* end else (IPv4) */ len = tmpstr - curstr; if (len == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "HOST substring cannot be empty"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HOST substring cannot be empty"); } - else - if (len > urllen) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem with length of HOST substring"); + else if (len > urllen) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of HOST substring"); } /* copy host */ purl->host = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); if (purl->host == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "can't allocate space for HOST"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for HOST"); } (void)HDstrncpy(purl->host, curstr, (size_t)len); purl->host[len] = 0; @@ -2863,18 +2526,14 @@ H5FD_s3comms_parse_url( } len = tmpstr - curstr; if (len == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "PORT element cannot be empty"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "PORT element cannot be empty"); } - else - if (len > urllen) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem with length of PORT substring"); + else if (len > urllen) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of PORT substring"); } - for (i = 0; i < len; i ++) { + for (i = 0; i < len; i++) { if (!isdigit(curstr[i])) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "PORT is not a decimal string"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "PORT is not a decimal string"); } } @@ -2882,8 +2541,7 @@ H5FD_s3comms_parse_url( */ purl->port = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); if (purl->port == NULL) { /* cannot malloc */ - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "can't allocate space for PORT"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for PORT"); } (void)HDstrncpy(purl->port, curstr, (size_t)len); purl->port[len] = 0; @@ -2905,14 +2563,12 @@ H5FD_s3comms_parse_url( } len = tmpstr - curstr; if (len > urllen) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem with length of PATH substring"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of PATH substring"); } if (len > 0) { purl->path = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); if (purl->path == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "can't allocate space for PATH"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for PATH"); } /* cannot malloc path pointer */ (void)HDstrncpy(purl->path, curstr, (size_t)len); purl->path[len] = 0; @@ -2931,23 +2587,21 @@ H5FD_s3comms_parse_url( } len = tmpstr - curstr; if (len == 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "QUERY cannot be empty"); - } else if (len > urllen) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem with length of QUERY substring"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "QUERY cannot be empty"); + } + else if (len > urllen) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of QUERY substring"); } purl->query = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); if (purl->query == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, - "can't allocate space for QUERY"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for QUERY"); } /* cannot malloc path pointer */ (void)HDstrncpy(purl->query, curstr, (size_t)len); purl->query[len] = 0; } /* end if QUERY exists */ - *_purl = purl; - ret_value = SUCCEED; + *_purl = purl; + ret_value = SUCCEED; done: if (ret_value == FAIL) { @@ -2956,7 +2610,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_parse_url() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_percent_encode_char() @@ -2997,17 +2650,14 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_percent_encode_char( - char *repr, - const unsigned char c, - size_t *repr_len) +H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr_len) { - unsigned int i = 0; - int chars_written = 0; - herr_t ret_value = SUCCEED; + unsigned int i = 0; + int chars_written = 0; + herr_t ret_value = SUCCEED; #if S3COMMS_DEBUG - unsigned char s[2] = {c, 0}; - unsigned char hex[3] = {0, 0, 0}; + unsigned char s[2] = {c, 0}; + unsigned char hex[3] = {0, 0, 0}; #endif FUNC_ENTER_NOAPI_NOINIT @@ -3017,7 +2667,7 @@ H5FD_s3comms_percent_encode_char( #endif if (repr == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination `repr`.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination `repr`.\n") } #if S3COMMS_DEBUG @@ -3033,27 +2683,25 @@ H5FD_s3comms_percent_encode_char( #if S3COMMS_DEBUG HDfprintf(stdout, " SINGLE-BYTE\n"); #endif - *repr_len = 3; + *repr_len = 3; chars_written = HDsnprintf(repr, 4, "%%%02X", c); if (chars_written < 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "cannot write char %c", - c); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); } } /* end if single-byte unicode char */ else { /* multi-byte, multi-percent representation */ - unsigned int acc = 0; /* byte accumulator */ - unsigned int k = 0; /* uint character representation */ - unsigned int stack_size = 0; - unsigned char stack[4] = {0, 0, 0, 0}; + unsigned int acc = 0; /* byte accumulator */ + unsigned int k = 0; /* uint character representation */ + unsigned int stack_size = 0; + unsigned char stack[4] = {0, 0, 0, 0}; #if S3COMMS_DEBUG HDfprintf(stdout, " MULTI-BYTE\n"); #endif stack_size = 0; - k = (unsigned int)c; - *repr_len = 0; + k = (unsigned int)c; + *repr_len = 0; do { /* push number onto stack in six-bit slices */ @@ -3061,7 +2709,7 @@ H5FD_s3comms_percent_encode_char( acc >>= 6; /* cull least */ acc <<= 6; /* six bits */ stack[stack_size++] = (unsigned char)(k - acc); - k = acc >> 6; + k = acc >> 6; } while (k > 0); /* `stack` now has two to four six-bit 'numbers' to be put into @@ -3071,11 +2719,7 @@ H5FD_s3comms_percent_encode_char( #if S3COMMS_DEBUG HDfprintf(stdout, " STACK:\n {\n"); for (i = 0; i < stack_size; i++) { - H5FD_s3comms_bytes_to_hex( - (char *)hex, - (&stack[i]), - 1, - FALSE); + H5FD_s3comms_bytes_to_hex((char *)hex, (&stack[i]), 1, FALSE); hex[2] = 0; HDfprintf(stdout, " %s,\n", hex); } @@ -3092,15 +2736,9 @@ H5FD_s3comms_percent_encode_char( acc += (stack_size > 2) ? 0x20 : 0; /* 0x00100000 */ acc += (stack_size > 3) ? 0x10 : 0; /* 0x00010000 */ stack_size--; - chars_written = HDsnprintf( - repr, - 4, - "%%%02X", - (unsigned char)(acc + stack[stack_size])); + chars_written = HDsnprintf(repr, 4, "%%%02X", (unsigned char)(acc + stack[stack_size])); if (chars_written < 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "cannot write char %c", - c); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); } *repr_len += 3; @@ -3110,19 +2748,14 @@ H5FD_s3comms_percent_encode_char( /* 10xxxxxx */ for (i = 0; i < stack_size; i++) { - chars_written = HDsnprintf( - &repr[i*3 + 3], - 4, - "%%%02X", - (unsigned char)(0x80 + stack[stack_size - 1 - i])); + chars_written = + HDsnprintf(&repr[i * 3 + 3], 4, "%%%02X", (unsigned char)(0x80 + stack[stack_size - 1 - i])); if (chars_written < 0) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "cannot write char %c", - c); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); } *repr_len += 3; } /* end for each continuation byte */ - } /* end else (multi-byte) */ + } /* end else (multi-byte) */ *(repr + *repr_len) = '\0'; @@ -3130,7 +2763,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5FD_s3comms_percent_encode_char */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_signing_key() @@ -3170,19 +2802,15 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_signing_key( - unsigned char *md, - const char *secret, - const char *region, - const char *iso8601now) +H5FD_s3comms_signing_key(unsigned char *md, const char *secret, const char *region, const char *iso8601now) { - char *AWS4_secret = NULL; - size_t AWS4_secret_len = 0; - unsigned char datekey[SHA256_DIGEST_LENGTH]; - unsigned char dateregionkey[SHA256_DIGEST_LENGTH]; - unsigned char dateregionservicekey[SHA256_DIGEST_LENGTH]; - int ret = 0; /* return value of HDsnprintf */ - herr_t ret_value = SUCCEED; + char * AWS4_secret = NULL; + size_t AWS4_secret_len = 0; + unsigned char datekey[SHA256_DIGEST_LENGTH]; + unsigned char dateregionkey[SHA256_DIGEST_LENGTH]; + unsigned char dateregionservicekey[SHA256_DIGEST_LENGTH]; + int ret = 0; /* return value of HDsnprintf */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -3191,69 +2819,43 @@ H5FD_s3comms_signing_key( #endif if (md == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Destination `md` cannot be NULL.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Destination `md` cannot be NULL.\n") } if (secret == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "`secret` cannot be NULL.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`secret` cannot be NULL.\n") } if (region == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "`region` cannot be NULL.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`region` cannot be NULL.\n") } if (iso8601now == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "`iso8601now` cannot be NULL.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`iso8601now` cannot be NULL.\n") } AWS4_secret_len = 4 + HDstrlen(secret) + 1; - AWS4_secret = (char*)H5MM_malloc(sizeof(char *) * AWS4_secret_len); + AWS4_secret = (char *)H5MM_malloc(sizeof(char *) * AWS4_secret_len); if (AWS4_secret == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Could not allocate space.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Could not allocate space.\n") } /* prepend "AWS4" to start of the secret key */ - ret = HDsnprintf(AWS4_secret, AWS4_secret_len,"%s%s", "AWS4", secret); + ret = HDsnprintf(AWS4_secret, AWS4_secret_len, "%s%s", "AWS4", secret); if ((size_t)ret != (AWS4_secret_len - 1)) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem writing AWS4+secret `%s`", - secret); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem writing AWS4+secret `%s`", secret); } /* hash_func, key, len(key), msg, len(msg), digest_dest, digest_len_dest * we know digest length, so ignore via NULL */ - HMAC(EVP_sha256(), - (const unsigned char *)AWS4_secret, - (int)HDstrlen(AWS4_secret), - (const unsigned char*)iso8601now, - 8, /* 8 --> length of 8 --> "yyyyMMDD" */ - datekey, - NULL); - HMAC(EVP_sha256(), - (const unsigned char *)datekey, - SHA256_DIGEST_LENGTH, - (const unsigned char *)region, - HDstrlen(region), - dateregionkey, - NULL); - HMAC(EVP_sha256(), - (const unsigned char *)dateregionkey, - SHA256_DIGEST_LENGTH, - (const unsigned char *)"s3", - 2, - dateregionservicekey, - NULL); - HMAC(EVP_sha256(), - (const unsigned char *)dateregionservicekey, - SHA256_DIGEST_LENGTH, - (const unsigned char *)"aws4_request", - 12, - md, - NULL); + HMAC(EVP_sha256(), (const unsigned char *)AWS4_secret, (int)HDstrlen(AWS4_secret), + (const unsigned char *)iso8601now, 8, /* 8 --> length of 8 --> "yyyyMMDD" */ + datekey, NULL); + HMAC(EVP_sha256(), (const unsigned char *)datekey, SHA256_DIGEST_LENGTH, (const unsigned char *)region, + HDstrlen(region), dateregionkey, NULL); + HMAC(EVP_sha256(), (const unsigned char *)dateregionkey, SHA256_DIGEST_LENGTH, + (const unsigned char *)"s3", 2, dateregionservicekey, NULL); + HMAC(EVP_sha256(), (const unsigned char *)dateregionservicekey, SHA256_DIGEST_LENGTH, + (const unsigned char *)"aws4_request", 12, md, NULL); done: H5MM_xfree(AWS4_secret); @@ -3261,7 +2863,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_signing_key() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_tostringtosign() @@ -3299,14 +2900,10 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_tostringtosign( - char *dest, - const char *req, - const char *now, - const char *region) +H5FD_s3comms_tostringtosign(char *dest, const char *req, const char *now, const char *region) { unsigned char checksum[SHA256_DIGEST_LENGTH * 2 + 1]; - size_t d = 0; + size_t d = 0; char day[9]; char hexsum[SHA256_DIGEST_LENGTH * 2 + 1]; size_t i = 0; @@ -3320,21 +2917,17 @@ H5FD_s3comms_tostringtosign( HDfprintf(stdout, "called H5FD_s3comms_tostringtosign.\n"); #endif - if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "destination buffer cannot be null.\n") + if (dest == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer cannot be null.\n") } - if (req == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "canonical request cannot be null.\n") + if (req == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "canonical request cannot be null.\n") } if (now == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Timestring cannot be NULL.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Timestring cannot be NULL.\n") } if (region == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Region cannot be NULL.\n") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Region cannot be NULL.\n") } for (i = 0; i < 128; i++) { @@ -3342,20 +2935,19 @@ H5FD_s3comms_tostringtosign( } for (i = 0; i < SHA256_DIGEST_LENGTH * 2 + 1; i++) { checksum[i] = '\0'; - hexsum[i] = '\0'; + hexsum[i] = '\0'; } HDstrncpy(day, now, 8); day[8] = '\0'; - ret = HDsnprintf(tmp, 127, "%s/%s/s3/aws4_request", day, region); + ret = HDsnprintf(tmp, 127, "%s/%s/s3/aws4_request", day, region); if (ret <= 0 || ret >= 127) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "problem adding day and region to string") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem adding day and region to string") } HDmemcpy((dest + d), "AWS4-HMAC-SHA256\n", 17); d = 17; - HDmemcpy((dest+d), now, HDstrlen(now)); + HDmemcpy((dest + d), now, HDstrlen(now)); d += HDstrlen(now); dest[d++] = '\n'; @@ -3363,19 +2955,11 @@ H5FD_s3comms_tostringtosign( d += HDstrlen(tmp); dest[d++] = '\n'; - SHA256((const unsigned char *)req, - HDstrlen(req), - checksum); + SHA256((const unsigned char *)req, HDstrlen(req), checksum); - if (H5FD_s3comms_bytes_to_hex( - hexsum, - (const unsigned char *)checksum, - SHA256_DIGEST_LENGTH, - true) - == FAIL) - { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "could not create hex string"); + if (H5FD_s3comms_bytes_to_hex(hexsum, (const unsigned char *)checksum, SHA256_DIGEST_LENGTH, true) == + FAIL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not create hex string"); } for (i = 0; i < SHA256_DIGEST_LENGTH * 2; i++) { @@ -3388,7 +2972,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ros3_tostringtosign() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_trim() @@ -3419,10 +3002,7 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_trim(char *dest, - char *s, - size_t s_len, - size_t *n_written) +H5FD_s3comms_trim(char *dest, char *s, size_t s_len, size_t *n_written) { herr_t ret_value = SUCCEED; @@ -3433,8 +3013,7 @@ H5FD_s3comms_trim(char *dest, #endif if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "destination cannot be null.") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null.") } if (s == NULL) { s_len = 0; @@ -3444,11 +3023,9 @@ H5FD_s3comms_trim(char *dest, /* Find first non-whitespace character from start; * reduce total length per character. */ - while ((s_len > 0) && - isspace((unsigned char)s[0]) && s_len > 0) - { - s++; - s_len--; + while ((s_len > 0) && isspace((unsigned char)s[0]) && s_len > 0) { + s++; + s_len--; } /* Find first non-whitespace character from tail; @@ -3458,7 +3035,7 @@ H5FD_s3comms_trim(char *dest, if (s_len > 0) { do { s_len--; - } while( isspace((unsigned char)s[s_len]) ); + } while (isspace((unsigned char)s[s_len])); s_len++; /* write output into dest @@ -3473,7 +3050,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_s3comms_trim() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_uriencode() @@ -3513,15 +3089,10 @@ done: *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_uriencode( - char *dest, - const char *s, - size_t s_len, - hbool_t encode_slash, - size_t *n_written) +H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, hbool_t encode_slash, size_t *n_written) { - char c = 0; - size_t dest_off = 0; + char c = 0; + size_t dest_off = 0; char hex_buffer[13]; size_t hex_off = 0; size_t hex_len = 0; @@ -3535,12 +3106,10 @@ H5FD_s3comms_uriencode( #endif if (s == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "source string cannot be NULL"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source string cannot be NULL"); } if (dest == NULL) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "destination cannot be NULL"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be NULL"); } /* Write characters to destination, converting to percent-encoded @@ -3549,39 +3118,29 @@ H5FD_s3comms_uriencode( */ for (s_off = 0; s_off < s_len; s_off++) { c = s[s_off]; - if (isalnum(c) || - c == '.' || - c == '-' || - c == '_' || - c == '~' || - (c == '/' && encode_slash == FALSE)) - { + if (isalnum(c) || c == '.' || c == '-' || c == '_' || c == '~' || + (c == '/' && encode_slash == FALSE)) { dest[dest_off++] = c; } else { hex_off = 0; - if (H5FD_s3comms_percent_encode_char( - hex_buffer, - (const unsigned char)c, - &hex_len) - == FAIL) - { + if (H5FD_s3comms_percent_encode_char(hex_buffer, (const unsigned char)c, &hex_len) == FAIL) { hex_buffer[0] = c; hex_buffer[1] = 0; HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to percent-encode character \'%s\' " - "at %d in \"%s\"", hex_buffer, (int)s_off, s); + "at %d in \"%s\"", + hex_buffer, (int)s_off, s); } for (hex_off = 0; hex_off < hex_len; hex_off++) { dest[dest_off++] = hex_buffer[hex_off]; } } /* end else (not a regular character) */ - } /* end for each character */ + } /* end for each character */ if (dest_off < s_len) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "buffer overflow"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer overflow"); *n_written = dest_off; @@ -3590,4 +3149,3 @@ done: } /* H5FD_s3comms_uriencode */ #endif /* H5_HAVE_ROS3_VFD */ - diff --git a/src/H5FDs3comms.h b/src/H5FDs3comms.h index 90c6650..5d939f8 100644 --- a/src/H5FDs3comms.h +++ b/src/H5FDs3comms.h @@ -52,7 +52,7 @@ * *****************************************************************************/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_ROS3_VFD @@ -69,8 +69,7 @@ /* hexadecimal string of pre-computed sha256 checksum of the empty string * hex(sha256sum("")) */ -#define EMPTY_SHA256 \ -"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" +#define EMPTY_SHA256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" /* string length (plus null terminator) * example ISO8601-format string: "20170713T145903Z" (YYYYmmdd'T'HHMMSS'_') @@ -98,8 +97,7 @@ * *--------------------------------------------------------------------------- */ -#define ISO8601NOW(dest, now_gm) \ -strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) +#define ISO8601NOW(dest, now_gm) strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) /*--------------------------------------------------------------------------- * @@ -117,9 +115,7 @@ strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) * *--------------------------------------------------------------------------- */ -#define RFC7231NOW(dest, now_gm) \ -strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) - +#define RFC7231NOW(dest, now_gm) strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) /* Reasonable maximum length of a credential string. * Provided for error-checking S3COMMS_FORMAT_CREDENTIAL (below). @@ -131,7 +127,6 @@ strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) */ #define S3COMMS_MAX_CREDENTIAL_SIZE 155 - /*--------------------------------------------------------------------------- * * Macro: H5FD_S3COMMS_FORMAT_CREDENTIAL() @@ -162,16 +157,14 @@ strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) * *--------------------------------------------------------------------------- */ -#define S3COMMS_FORMAT_CREDENTIAL(dest, access, iso8601_date, region, service) \ -HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, \ - "%s/%s/%s/%s/aws4_request", \ - (access), (iso8601_date), (region), (service)) +#define S3COMMS_FORMAT_CREDENTIAL(dest, access, iso8601_date, region, service) \ + HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, "%s/%s/%s/%s/aws4_request", (access), (iso8601_date), \ + (region), (service)) /********************* * PUBLIC STRUCTURES * *********************/ - /*---------------------------------------------------------------------------- * * Structure: hrb_node_t @@ -256,15 +249,14 @@ HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, */ typedef struct hrb_node_t { unsigned long magic; - char *name; - char *value; - char *cat; - char *lowername; + char * name; + char * value; + char * cat; + char * lowername; struct hrb_node_t *next; } hrb_node_t; #define S3COMMS_HRB_NODE_MAGIC 0x7F5757UL - /*---------------------------------------------------------------------------- * * Structure: hrb_t @@ -332,17 +324,16 @@ typedef struct hrb_node_t { *---------------------------------------------------------------------------- */ typedef struct { - unsigned long magic; - char *body; - size_t body_len; - hrb_node_t *first_header; - char *resource; - char *verb; - char *version; + unsigned long magic; + char * body; + size_t body_len; + hrb_node_t * first_header; + char * resource; + char * verb; + char * version; } hrb_t; #define S3COMMS_HRB_MAGIC 0x6DCC84UL - /*---------------------------------------------------------------------------- * * Structure: parsed_url_t @@ -396,16 +387,15 @@ typedef struct { *---------------------------------------------------------------------------- */ typedef struct { - unsigned long magic; - char *scheme; /* required */ - char *host; /* required */ - char *port; - char *path; - char *query; + unsigned long magic; + char * scheme; /* required */ + char * host; /* required */ + char * port; + char * path; + char * query; } parsed_url_t; #define S3COMMS_PARSED_URL_MAGIC 0x21D0DFUL - /*---------------------------------------------------------------------------- * * Structure: s3r_t @@ -486,12 +476,12 @@ typedef struct { */ typedef struct { unsigned long magic; - CURL *curlhandle; + CURL * curlhandle; size_t filesize; - char *httpverb; - parsed_url_t *purl; - char *region; - char *secret_id; + char * httpverb; + parsed_url_t * purl; + char * region; + char * secret_id; unsigned char *signing_key; } s3r_t; @@ -505,9 +495,7 @@ extern "C" { * DECLARATION OF HTTP FIELD LIST ROUTINES * *******************************************/ -H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, - const char *name, - const char *value); +H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value); /*********************************************** * DECLARATION OF HTTP REQUEST BUFFER ROUTINES * @@ -515,9 +503,7 @@ H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, H5_DLL herr_t H5FD_s3comms_hrb_destroy(hrb_t **buf); -H5_DLL hrb_t * H5FD_s3comms_hrb_init_request(const char *verb, - const char *resource, - const char *host); +H5_DLL hrb_t *H5FD_s3comms_hrb_init_request(const char *verb, const char *resource, const char *host); /************************************* * DECLARATION OF S3REQUEST ROUTINES * @@ -527,78 +513,50 @@ H5_DLL herr_t H5FD_s3comms_s3r_close(s3r_t *handle); H5_DLL size_t H5FD_s3comms_s3r_get_filesize(s3r_t *handle); -H5_DLL s3r_t * H5FD_s3comms_s3r_open(const char url[], - const char region[], - const char id[], - const unsigned char signing_key[]); +H5_DLL s3r_t *H5FD_s3comms_s3r_open(const char url[], const char region[], const char id[], + const unsigned char signing_key[]); -H5_DLL herr_t H5FD_s3comms_s3r_read(s3r_t *handle, - haddr_t offset, - size_t len, - void *dest); +H5_DLL herr_t H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest); /********************************* * DECLARATION OF OTHER ROUTINES * *********************************/ -H5_DLL struct tm * gmnow(void); +H5_DLL struct tm *gmnow(void); -H5_DLL herr_t H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, - int cr_size, - char *signed_headers_dest, - int sh_size, - hrb_t *http_request); +H5_DLL herr_t H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int cr_size, + char *signed_headers_dest, int sh_size, hrb_t *http_request); -H5_DLL herr_t H5FD_s3comms_bytes_to_hex(char *dest, - const unsigned char *msg, - size_t msg_len, - hbool_t lowercase); +H5_DLL herr_t H5FD_s3comms_bytes_to_hex(char *dest, const unsigned char *msg, size_t msg_len, + hbool_t lowercase); H5_DLL herr_t H5FD_s3comms_free_purl(parsed_url_t *purl); -H5_DLL herr_t H5FD_s3comms_HMAC_SHA256(const unsigned char *key, - size_t key_len, - const char *msg, - size_t msg_len, - char *dest); +H5_DLL herr_t H5FD_s3comms_HMAC_SHA256(const unsigned char *key, size_t key_len, const char *msg, + size_t msg_len, char *dest); -H5_DLL herr_t H5FD_s3comms_load_aws_profile(const char *name, - char *key_id_out, - char *secret_access_key_out, - char *aws_region_out); +H5_DLL herr_t H5FD_s3comms_load_aws_profile(const char *name, char *key_id_out, char *secret_access_key_out, + char *aws_region_out); -H5_DLL herr_t H5FD_s3comms_nlowercase(char *dest, - const char *s, - size_t len); +H5_DLL herr_t H5FD_s3comms_nlowercase(char *dest, const char *s, size_t len); -H5_DLL herr_t H5FD_s3comms_parse_url(const char *str, - parsed_url_t **purl); +H5_DLL herr_t H5FD_s3comms_parse_url(const char *str, parsed_url_t **purl); -H5_DLL herr_t H5FD_s3comms_percent_encode_char(char *repr, - const unsigned char c, - size_t *repr_len); +H5_DLL herr_t H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr_len); -H5_DLL herr_t H5FD_s3comms_signing_key(unsigned char *md, - const char *secret, - const char *region, - const char *iso8601now); +H5_DLL herr_t H5FD_s3comms_signing_key(unsigned char *md, const char *secret, const char *region, + const char *iso8601now); -H5_DLL herr_t H5FD_s3comms_tostringtosign(char *dest, - const char *req_str, - const char *now, - const char *region); +H5_DLL herr_t H5FD_s3comms_tostringtosign(char *dest, const char *req_str, const char *now, + const char *region); -H5_DLL herr_t H5FD_s3comms_trim(char *dest, - char *s, - size_t s_len, - size_t *n_written); +H5_DLL herr_t H5FD_s3comms_trim(char *dest, char *s, size_t s_len, size_t *n_written); -H5_DLL herr_t H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, - hbool_t encode_slash, size_t *n_written); +H5_DLL herr_t H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, hbool_t encode_slash, + size_t *n_written); #ifdef __cplusplus } #endif #endif /* H5_HAVE_ROS3_VFD */ - diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 37a6ae9..1d4a6d2 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -25,16 +25,15 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDsec2.h" /* Sec2 file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDsec2.h" /* Sec2 file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_SEC2_g = 0; @@ -51,13 +50,13 @@ static hid_t H5FD_SEC2_g = 0; * occurs), and 'op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_sec2_t { - H5FD_t pub; /* public stuff, must be first */ - int fd; /* the filesystem file descriptor */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* end of file; current file size */ - haddr_t pos; /* current file I/O position */ - H5FD_file_op_t op; /* last operation */ - char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ + H5FD_t pub; /* public stuff, must be first */ + int fd; /* the filesystem file descriptor */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* end of file; current file size */ + haddr_t pos; /* current file I/O position */ + H5FD_file_op_t op; /* last operation */ + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. Note that Cygwin, MinGW and other Windows POSIX @@ -65,8 +64,8 @@ typedef struct H5FD_sec2_t { * and will use the 'device + inodes' scheme as opposed to the * Windows code further below. */ - dev_t device; /* file device number */ - ino_t inode; /* file i-node number */ + dev_t device; /* file device number */ + ino_t inode; /* file i-node number */ #else /* Files in windows are uniquely identified by the volume serial * number and the file index (both low and high parts). @@ -82,19 +81,19 @@ typedef struct H5FD_sec2_t { * * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx */ - DWORD nFileIndexLow; - DWORD nFileIndexHigh; - DWORD dwVolumeSerialNumber; + DWORD nFileIndexLow; + DWORD nFileIndexHigh; + DWORD dwVolumeSerialNumber; - HANDLE hFile; /* Native windows file handle */ -#endif /* H5_HAVE_WIN32_API */ + HANDLE hFile; /* Native windows file handle */ +#endif /* H5_HAVE_WIN32_API */ /* Information from properties set by 'h5repart' tool * * Whether to eliminate the family driver info and convert this file to * a single file. */ - hbool_t fam_to_single; + hbool_t fam_to_single; } H5FD_sec2_t; @@ -113,72 +112,69 @@ typedef struct H5FD_sec2_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* Prototypes */ -static herr_t H5FD_sec2_term(void); -static H5FD_t *H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); -static herr_t H5FD_sec2_close(H5FD_t *_file); -static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_sec2_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD_sec2_term(void); +static H5FD_t *H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_sec2_close(H5FD_t *_file); +static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_sec2_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_sec2_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_sec2_unlock(H5FD_t *_file); +static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_sec2_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_sec2_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_sec2_g = { - "sec2", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_sec2_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - NULL, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_sec2_open, /* open */ - H5FD_sec2_close, /* close */ - H5FD_sec2_cmp, /* cmp */ - H5FD_sec2_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD_sec2_get_eoa, /* get_eoa */ - H5FD_sec2_set_eoa, /* set_eoa */ - H5FD_sec2_get_eof, /* get_eof */ - H5FD_sec2_get_handle, /* get_handle */ - H5FD_sec2_read, /* read */ - H5FD_sec2_write, /* write */ - NULL, /* flush */ - H5FD_sec2_truncate, /* truncate */ - H5FD_sec2_lock, /* lock */ - H5FD_sec2_unlock, /* unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "sec2", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_sec2_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_sec2_open, /* open */ + H5FD_sec2_close, /* close */ + H5FD_sec2_cmp, /* cmp */ + H5FD_sec2_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_sec2_get_eoa, /* get_eoa */ + H5FD_sec2_set_eoa, /* set_eoa */ + H5FD_sec2_get_eof, /* get_eof */ + H5FD_sec2_get_handle, /* get_handle */ + H5FD_sec2_read, /* read */ + H5FD_sec2_write, /* write */ + NULL, /* flush */ + H5FD_sec2_truncate, /* truncate */ + H5FD_sec2_lock, /* lock */ + H5FD_sec2_unlock, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_sec2_t struct */ H5FL_DEFINE_STATIC(H5FD_sec2_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -195,14 +191,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_sec2_init() < 0) + if (H5FD_sec2_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize sec2 VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_init * @@ -220,11 +215,11 @@ done: hid_t H5FD_sec2_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if(H5I_VFL != H5I_get_type(H5FD_SEC2_g)) + if (H5I_VFL != H5I_get_type(H5FD_SEC2_g)) H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -234,7 +229,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_sec2_term * @@ -258,7 +252,6 @@ H5FD_sec2_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_sec2_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_sec2 * @@ -276,13 +269,13 @@ H5FD_sec2_term(void) herr_t H5Pset_fapl_sec2(hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", fapl_id); - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value = H5P_set_driver(plist, H5FD_SEC2, NULL); @@ -291,7 +284,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_sec2() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_open * @@ -310,14 +302,14 @@ done: static H5FD_t * H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_sec2_t *file = NULL; /* sec2 VFD info */ - int fd = -1; /* File descriptor */ - int o_flags; /* Flags for open() call */ + H5FD_sec2_t *file = NULL; /* sec2 VFD info */ + int fd = -1; /* File descriptor */ + int o_flags; /* Flags for open() call */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - h5_stat_t sb; - H5FD_t *ret_value = NULL; /* Return value */ + h5_stat_t sb; + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -325,53 +317,56 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if(H5F_ACC_TRUNC & flags) + if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if(H5F_ACC_CREAT & flags) + if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if(H5F_ACC_EXCL & flags) + if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; /* Open the file */ - if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { int myerrno = errno; - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); + HGOTO_ERROR( + H5E_FILE, H5E_CANTOPENFILE, NULL, + "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", + name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); } /* end if */ - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Create the new file struct */ - if(NULL == (file = H5FL_CALLOC(H5FD_sec2_t))) + if (NULL == (file = H5FL_CALLOC(H5FD_sec2_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); - if(INVALID_HANDLE_VALUE == file->hFile) + if (INVALID_HANDLE_VALUE == file->hFile) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file handle") - if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) + if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file information") - file->nFileIndexHigh = fileinfo.nFileIndexHigh; - file->nFileIndexLow = fileinfo.nFileIndexLow; + file->nFileIndexHigh = fileinfo.nFileIndexHigh; + file->nFileIndexLow = fileinfo.nFileIndexLow; file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber; -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /* H5_HAVE_WIN32_API */ /* Retain a copy of the name used to open the file, for possible error reporting */ @@ -379,11 +374,11 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) file->filename[sizeof(file->filename) - 1] = '\0'; /* Check for non-default FAPL */ - if(H5P_FILE_ACCESS_DEFAULT != fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ + if (H5P_FILE_ACCESS_DEFAULT != fapl_id) { + H5P_genplist_t *plist; /* Property list pointer */ /* Get the FAPL */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, NULL, "not a file access property list") /* This step is for h5repart tool only. If user wants to change file driver from @@ -391,26 +386,25 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) * private property should be set so that in the later step, the library can ignore * the family driver information saved in the superblock. */ - if(H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) - if(H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) + if (H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) + if (H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to single") } /* end if */ /* Set return value */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(NULL == ret_value) { - if(fd >= 0) + if (NULL == ret_value) { + if (fd >= 0) HDclose(fd); - if(file) + if (file) file = H5FL_FREE(H5FD_sec2_t, file); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_open() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_close * @@ -427,8 +421,8 @@ done: static herr_t H5FD_sec2_close(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -436,7 +430,7 @@ H5FD_sec2_close(H5FD_t *_file) HDassert(file); /* Close the underlying file */ - if(HDclose(file->fd) < 0) + if (HDclose(file->fd) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* Release the file info */ @@ -446,7 +440,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_close() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_cmp * @@ -465,42 +458,53 @@ done: static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; - const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; - int ret_value = 0; + const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; + const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR #ifdef H5_HAVE_WIN32_API - if(f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) HGOTO_DONE(-1) - if(f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) HGOTO_DONE(1) - - if(f1->nFileIndexHigh < f2->nFileIndexHigh) HGOTO_DONE(-1) - if(f1->nFileIndexHigh > f2->nFileIndexHigh) HGOTO_DONE(1) - - if(f1->nFileIndexLow < f2->nFileIndexLow) HGOTO_DONE(-1) - if(f1->nFileIndexLow > f2->nFileIndexLow) HGOTO_DONE(1) + if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) + HGOTO_DONE(-1) + if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) + HGOTO_DONE(1) + + if (f1->nFileIndexHigh < f2->nFileIndexHigh) + HGOTO_DONE(-1) + if (f1->nFileIndexHigh > f2->nFileIndexHigh) + HGOTO_DONE(1) + + if (f1->nFileIndexLow < f2->nFileIndexLow) + HGOTO_DONE(-1) + if (f1->nFileIndexLow > f2->nFileIndexLow) + HGOTO_DONE(1) #else /* H5_HAVE_WIN32_API */ #ifdef H5_DEV_T_IS_SCALAR - if(f1->device < f2->device) HGOTO_DONE(-1) - if(f1->device > f2->device) HGOTO_DONE(1) -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + HGOTO_DONE(-1) + if (f1->device > f2->device) + HGOTO_DONE(1) +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) < 0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) > 0) HGOTO_DONE(1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + HGOTO_DONE(-1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if(f1->inode < f2->inode) HGOTO_DONE(-1) - if(f1->inode > f2->inode) HGOTO_DONE(1) + if (f1->inode < f2->inode) + HGOTO_DONE(-1) + if (f1->inode > f2->inode) + HGOTO_DONE(1) #endif /* H5_HAVE_WIN32_API */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_query * @@ -517,7 +521,7 @@ done: static herr_t H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */ + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -528,25 +532,27 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) * reflected in H5FDmirror.c * -- JOS 2020-01-13 */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ - *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ + *flags |= + H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ /* Check for flags that are set by h5repart */ - if(file && file->fam_to_single) - *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ - } /* end if */ + if (file && file->fam_to_single) + *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which + eliminates it) */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_sec2_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_get_eoa * @@ -564,14 +570,13 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) static haddr_t H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD_sec2_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_set_eoa * @@ -589,7 +594,7 @@ H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -598,7 +603,6 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_sec2_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_get_eof * @@ -617,14 +621,13 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD_sec2_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_get_handle * @@ -640,12 +643,12 @@ H5FD_sec2_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); @@ -654,7 +657,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_read * @@ -672,12 +674,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, size_t size, void *buf /*out*/) +H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf /*out*/) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -685,15 +687,15 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS HDassert(buf); /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) + if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ - if(addr != file->pos || OP_READ != file->op) { - if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + if (addr != file->pos || OP_READ != file->op) { + if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") } #endif /* H5_HAVE_PREADWRITE */ @@ -701,15 +703,15 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS /* Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ - while(size > 0) { + while (size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to read */ - h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -717,23 +719,29 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, buf, bytes_in, offset); - if(bytes_read > 0) + if (bytes_read > 0) offset += bytes_read; #else - bytes_read = HDread(file->fd, buf, bytes_in); + bytes_read = HDread(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_read && EINTR == errno); + } while (-1 == bytes_read && EINTR == errno); - if(-1 == bytes_read) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_read) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, + "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, " + "bytes actually read = %llu, offset = %llu", + HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_read, (unsigned long long)offset); } /* end if */ - if(0 == bytes_read) { + if (0 == bytes_read) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); break; @@ -749,19 +757,18 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS /* Update current position */ file->pos = addr; - file->op = OP_READ; + file->op = OP_READ; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_read() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_write * @@ -777,12 +784,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, size_t size, const void *buf) +H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, const void *buf) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -790,15 +797,16 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU HDassert(buf); /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", (unsigned long long)addr, (unsigned long long)size) + if (REGION_OVERFLOW(addr, size)) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", + (unsigned long long)addr, (unsigned long long)size) #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ - if(addr != file->pos || OP_WRITE != file->op) { - if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + if (addr != file->pos || OP_WRITE != file->op) { + if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") } #endif /* H5_HAVE_PREADWRITE */ @@ -806,15 +814,15 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU /* Write the data, being careful of interrupted system calls and partial * results */ - while(size > 0) { + while (size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -822,20 +830,26 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset); - if(bytes_wrote > 0) + if (bytes_wrote > 0) offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_wrote && EINTR == errno); + } while (-1 == bytes_wrote && EINTR == errno); - if(-1 == bytes_wrote) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_wrote) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = " + "%llu, bytes actually written = %llu, offset = %llu", + HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ HDassert(bytes_wrote > 0); @@ -848,21 +862,20 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU /* Update current position and eof */ file->pos = addr; - file->op = OP_WRITE; - if(file->pos > file->eof) + file->op = OP_WRITE; + if (file->pos > file->eof) file->eof = file->pos; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_write() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_truncate * @@ -879,22 +892,22 @@ done: static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); /* Extend the file to make sure it's large enough */ - if(!H5F_addr_eq(file->eoa, file->eof)) { + if (!H5F_addr_eq(file->eoa, file->eof)) { #ifdef H5_HAVE_WIN32_API - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() - * Only used as an error code here. - */ - DWORD dwError; /* DWORD error code from GetLastError() */ - BOOL bError; /* Boolean error flag */ + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + * Only used as an error code here. + */ + DWORD dwError; /* DWORD error code from GetLastError() */ + BOOL bError; /* Boolean error flag */ /* Windows uses this odd QuadPart union for 32/64-bit portability */ li.QuadPart = (__int64)file->eoa; @@ -905,17 +918,17 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ * from SetFilePointer(), we also need to check GetLastError(). */ dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); - if(INVALID_SET_FILE_POINTER == dwPtrLow) { + if (INVALID_SET_FILE_POINTER == dwPtrLow) { dwError = GetLastError(); - if(dwError != NO_ERROR ) + if (dwError != NO_ERROR) HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") } bError = SetEndOfFile(file->hFile); - if(0 == bError) + if (0 == bError) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* H5_HAVE_WIN32_API */ - if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) +#else /* H5_HAVE_WIN32_API */ + if (-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ @@ -924,14 +937,13 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_lock * @@ -949,9 +961,9 @@ done: static herr_t H5FD_sec2_lock(H5FD_t *_file, hbool_t rw) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ - int lock_flags; /* file locking flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -961,9 +973,11 @@ H5FD_sec2_lock(H5FD_t *_file, hbool_t rw) lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { - if(ENOSYS == errno) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + if (HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if (ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, + "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING " + "environment variable to override)") else HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file") } /* end if */ @@ -972,7 +986,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_unlock * @@ -987,16 +1000,18 @@ done: static herr_t H5FD_sec2_unlock(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) { - if(ENOSYS == errno) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + if (HDflock(file->fd, LOCK_UN) < 0) { + if (ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, + "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING " + "environment variable to override)") else HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file") } /* end if */ @@ -1004,4 +1019,3 @@ H5FD_sec2_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_unlock() */ - diff --git a/src/H5FDsec2.h b/src/H5FDsec2.h index a4ade0b..656b0fd 100644 --- a/src/H5FDsec2.h +++ b/src/H5FDsec2.h @@ -20,13 +20,13 @@ #ifndef H5FDsec2_H #define H5FDsec2_H -#define H5FD_SEC2 (H5FD_sec2_init()) +#define H5FD_SEC2 (H5FD_sec2_init()) #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_sec2_init(void); +H5_DLL hid_t H5FD_sec2_init(void); H5_DLL herr_t H5Pset_fapl_sec2(hid_t fapl_id); #ifdef __cplusplus @@ -34,4 +34,3 @@ H5_DLL herr_t H5Pset_fapl_sec2(hid_t fapl_id); #endif #endif - diff --git a/src/H5FDspace.c b/src/H5FDspace.c index e1f0cb2..cd67f15 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -26,20 +26,18 @@ /* Module Setup */ /****************/ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ - +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5FDmulti.h" /* Usage-partitioned file family */ -#include "H5FLprivate.h" /* Free lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5FDmulti.h" /* Usage-partitioned file family */ +#include "H5FLprivate.h" /* Free lists */ /****************/ /* Local Macros */ @@ -48,32 +46,26 @@ /* Define this to display information about file allocations */ /* #define H5FD_ALLOC_DEBUG */ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -81,8 +73,6 @@ /* Declare a free list to manage the H5FD_free_t struct */ H5FL_DEFINE(H5FD_free_t); - - /*------------------------------------------------------------------------- * Function: H5FD_extend * @@ -101,8 +91,8 @@ H5FL_DEFINE(H5FD_free_t); static haddr_t H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) { - haddr_t eoa; /* Address of end-of-allocated space */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t eoa; /* Address of end-of-allocated space */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -116,7 +106,7 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) eoa = file->cls->get_eoa(file, type); /* Check for overflow when extending */ - if(H5F_addr_overflow(eoa, size) || (eoa + size) > file->maxaddr) + if (H5F_addr_overflow(eoa, size) || (eoa + size) > file->maxaddr) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") /* Set the [NOT aligned] address to return */ @@ -124,14 +114,13 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) /* Extend the end-of-allocated space address */ eoa += size; - if(file->cls->set_eoa(file, type, eoa) < 0) + if (file->cls->set_eoa(file, type, eoa) < 0) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_extend() */ - /*------------------------------------------------------------------------- * Function: H5FD__alloc_real * @@ -148,19 +137,18 @@ done: *------------------------------------------------------------------------- */ haddr_t -H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, - hsize_t *frag_size) +H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - hsize_t orig_size = size; /* Original allocation size */ - haddr_t eoa; /* Address of end-of-allocated space */ - hsize_t extra; /* Extra space to allocate, to align request */ - unsigned long flags = 0; /* Driver feature flags */ - hbool_t use_alloc_size; /* Just pass alloc size to the driver */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + hsize_t orig_size = size; /* Original allocation size */ + haddr_t eoa; /* Address of end-of-allocated space */ + hsize_t extra; /* Extra space to allocate, to align request */ + unsigned long flags = 0; /* Driver feature flags */ + hbool_t use_alloc_size; /* Just pass alloc size to the driver */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_PACKAGE #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); + HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); #endif /* H5FD_ALLOC_DEBUG */ /* check args */ @@ -170,7 +158,7 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); HDassert(size > 0); /* Check for query driver and call it */ - if(file->cls->query) + if (file->cls->query) (file->cls->query)(file, &flags); /* Check for the driver feature flag */ @@ -181,39 +169,41 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); /* Compute extra space to allocate, if this should be aligned */ extra = 0; - if(!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) { - hsize_t mis_align; /* Amount EOA is misaligned */ + if (!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) { + hsize_t mis_align; /* Amount EOA is misaligned */ /* Check for EOA already aligned */ - if((mis_align = (eoa % file->alignment)) > 0) { + if ((mis_align = (eoa % file->alignment)) > 0) { extra = file->alignment - mis_align; - if(frag_addr) - *frag_addr = eoa - file->base_addr; /* adjust for file's base address */ - if(frag_size) + if (frag_addr) + *frag_addr = eoa - file->base_addr; /* adjust for file's base address */ + if (frag_size) *frag_size = extra; } /* end if */ - } /* end if */ + } /* end if */ /* Dispatch to driver `alloc' callback or extend the end-of-address marker */ - /* For the multi/split driver: the size passed down to the alloc callback is the original size from H5FD_alloc() */ - /* For all other drivers: the size passed down to the alloc callback is the size + [possibly] alignment size */ - if(file->cls->alloc) { + /* For the multi/split driver: the size passed down to the alloc callback is the original size from + * H5FD_alloc() */ + /* For all other drivers: the size passed down to the alloc callback is the size + [possibly] alignment + * size */ + if (file->cls->alloc) { ret_value = (file->cls->alloc)(file, type, H5CX_get_dxpl(), use_alloc_size ? size : size + extra); - if(!H5F_addr_defined(ret_value)) + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver allocation request failed") } /* end if */ else { ret_value = H5FD_extend(file, type, size + extra); - if(!H5F_addr_defined(ret_value)) + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver eoa update request failed") } /* end else */ /* Set the [possibly aligned] address to return */ - if(!use_alloc_size) + if (!use_alloc_size) ret_value += extra; /* Post-condition sanity check */ - if(!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) + if (!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) HDassert(!(ret_value % file->alignment)); /* Convert absolute file offset to relative address */ @@ -221,12 +211,11 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); done: #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); + HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5FD_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__alloc_real() */ - /*------------------------------------------------------------------------- * Function: H5FD_alloc * @@ -246,10 +235,9 @@ HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); *------------------------------------------------------------------------- */ haddr_t -H5FD_alloc(H5FD_t *file, H5FD_mem_t type, H5F_t *f, hsize_t size, - haddr_t *frag_addr, hsize_t *frag_size) +H5FD_alloc(H5FD_t *file, H5FD_mem_t type, H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -261,18 +249,17 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, H5F_t *f, hsize_t size, /* Call the real 'alloc' routine */ ret_value = H5FD__alloc_real(file, type, size, frag_addr, frag_size); - if(!H5F_addr_defined(ret_value)) + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "real 'alloc' request failed") /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, HADDR_UNDEF, "unable to mark EOA info as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FD__free_real * @@ -289,7 +276,7 @@ done: herr_t H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -300,58 +287,58 @@ H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size) HDassert(size > 0); #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)type, addr, size); + HDfprintf(stderr, "%s: type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)type, addr, size); #endif /* H5FD_ALLOC_DEBUG */ /* Sanity checking */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid file offset") /* Convert address to absolute file offset */ addr += file->base_addr; /* More sanity checking */ - if(addr > file->maxaddr || H5F_addr_overflow(addr, size) || (addr + size) > file->maxaddr) + if (addr > file->maxaddr || H5F_addr_overflow(addr, size) || (addr + size) > file->maxaddr) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid file free space region to free") /* Check for file driver 'free' callback and call it if available */ - if(file->cls->free) { + if (file->cls->free) { #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: Letting VFD free space\n", FUNC); + HDfprintf(stderr, "%s: Letting VFD free space\n", FUNC); #endif /* H5FD_ALLOC_DEBUG */ - if((file->cls->free)(file, type, H5CX_get_dxpl(), addr, size) < 0) + if ((file->cls->free)(file, type, H5CX_get_dxpl(), addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "driver free request failed") } /* end if */ /* Check if this free block is at the end of file allocated space. * Truncate it if this is true. */ - else if(file->cls->get_eoa) { - haddr_t eoa; + else if (file->cls->get_eoa) { + haddr_t eoa; eoa = file->cls->get_eoa(file, type); #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: eoa = %a\n", FUNC, eoa); + HDfprintf(stderr, "%s: eoa = %a\n", FUNC, eoa); #endif /* H5FD_ALLOC_DEBUG */ - if(eoa == (addr + size)) { + if (eoa == (addr + size)) { #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: Reducing file size to = %a\n", FUNC, addr); + HDfprintf(stderr, "%s: Reducing file size to = %a\n", FUNC, addr); #endif /* H5FD_ALLOC_DEBUG */ - if(file->cls->set_eoa(file, type, addr) < 0) + if (file->cls->set_eoa(file, type, addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "set end of space allocation request failed") } /* end if */ - } /* end else-if */ + } /* end else-if */ else { /* leak memory */ #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: LEAKED MEMORY!!! type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)type, addr, size); + HDfprintf(stderr, "%s: LEAKED MEMORY!!! type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)type, + addr, size); #endif /* H5FD_ALLOC_DEBUG */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__free_real() */ - /*------------------------------------------------------------------------- * Function: H5FD_free * @@ -373,7 +360,7 @@ done: herr_t H5FD_free(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -384,18 +371,17 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t addr, hsize_t size) HDassert(size > 0); /* Call the real 'free' routine */ - if(H5FD__free_real(file, type, addr, size) < 0) + if (H5FD__free_real(file, type, addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "real 'free' request failed") /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark EOA info as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_free() */ - /*------------------------------------------------------------------------- * Function: H5FD_try_extend * @@ -417,8 +403,8 @@ done: htri_t H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_t extra_requested) { - haddr_t eoa; /* End of allocated space in file */ - htri_t ret_value = FALSE; /* Return value */ + haddr_t eoa; /* End of allocated space in file */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -430,20 +416,20 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_ HDassert(f); /* Retrieve the end of the address space */ - if(HADDR_UNDEF == (eoa = file->cls->get_eoa(file, type))) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_eoa request failed") + if (HADDR_UNDEF == (eoa = file->cls->get_eoa(file, type))) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* Adjust block end by base address of the file, to create absolute address */ blk_end += file->base_addr; /* Check if the block is exactly at the end of the file */ - if(H5F_addr_eq(blk_end, eoa)) { + if (H5F_addr_eq(blk_end, eoa)) { /* Extend the object by extending the underlying file */ - if(HADDR_UNDEF == H5FD_extend(file, type, extra_requested)) + if (HADDR_UNDEF == H5FD_extend(file, type, extra_requested)) HGOTO_ERROR(H5E_VFL, H5E_CANTEXTEND, FAIL, "driver extend request failed") /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark EOA info as dirty") /* Indicate success */ @@ -453,4 +439,3 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_try_extend() */ - diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index fae4bb4..1b4595d 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -19,38 +19,38 @@ /* This source code file is part of the H5FD driver module */ #include "H5FDdrvr_module.h" -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDsplitter.h" /* Splitter file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5FDsec2.h" /* Generic Functions */ -#include "H5FDstdio.h" /* Generic Functions */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDsplitter.h" /* Splitter file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5FDsec2.h" /* Generic Functions */ +#include "H5FDstdio.h" /* Generic Functions */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_SPLITTER_g = 0; /* Driver-specific file access properties */ typedef struct H5FD_splitter_fapl_t { - hid_t rw_fapl_id; /* fapl for the R/W channel */ - hid_t wo_fapl_id; /* fapl for the W/O channel */ - char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file name for the W/O channel */ - char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file to record errors reported by the W/O channel */ - hbool_t ignore_wo_errs; /* TRUE to ignore errors on the W/O channel */ + hid_t rw_fapl_id; /* fapl for the R/W channel */ + hid_t wo_fapl_id; /* fapl for the W/O channel */ + char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file name for the W/O channel */ + char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file to record errors reported by the W/O channel */ + hbool_t ignore_wo_errs; /* TRUE to ignore errors on the W/O channel */ } H5FD_splitter_fapl_t; /* The information of this splitter */ typedef struct H5FD_splitter_t { - H5FD_t pub; /* public stuff, must be first */ - unsigned version; /* version of the H5FD_splitter_vfd_config_t structure used */ - H5FD_splitter_fapl_t fa; /* driver-specific file access properties */ - H5FD_t *rw_file; /* pointer of R/W channel */ - H5FD_t *wo_file; /* pointer of W/O channel */ - FILE *logfp; /* Log file pointer */ + H5FD_t pub; /* public stuff, must be first */ + unsigned version; /* version of the H5FD_splitter_vfd_config_t structure used */ + H5FD_splitter_fapl_t fa; /* driver-specific file access properties */ + H5FD_t * rw_file; /* pointer of R/W channel */ + H5FD_t * wo_file; /* pointer of W/O channel */ + FILE * logfp; /* Log file pointer */ } H5FD_splitter_t; /* @@ -68,36 +68,36 @@ typedef struct H5FD_splitter_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* This macro provides a wrapper for shared fail-log-ignore behavior * for errors arising in the splitter's W/O channel. * Logs an error entry in a log file, if the file exists. * If not set to ignore errors, registers an error with the library. */ -#define H5FD_SPLITTER_WO_ERROR(file, funcname, errmajor, errminor, ret, mesg) \ -{ \ - H5FD__splitter_log_error((file), (funcname), (mesg)); \ - if (FALSE == (file)->fa.ignore_wo_errs) { \ - HGOTO_ERROR((errmajor), (errminor), (ret), (mesg)) \ - } \ -} +#define H5FD_SPLITTER_WO_ERROR(file, funcname, errmajor, errminor, ret, mesg) \ + { \ + H5FD__splitter_log_error((file), (funcname), (mesg)); \ + if (FALSE == (file)->fa.ignore_wo_errs) { \ + HGOTO_ERROR((errmajor), (errminor), (ret), (mesg)) \ + } \ + } #define H5FD_SPLITTER_DEBUG_OP_CALLS 0 /* debugging print toggle; 0 disables */ #if H5FD_SPLITTER_DEBUG_OP_CALLS -#define H5FD_SPLITTER_LOG_CALL(name) do { \ - HDprintf("called %s()\n", (name)); \ - fflush(stdout); \ -} while (0) +#define H5FD_SPLITTER_LOG_CALL(name) \ + do { \ + HDprintf("called %s()\n", (name)); \ + fflush(stdout); \ + } while (0) #else #define H5FD_SPLITTER_LOG_CALL(name) /* no-op */ -#endif /* H5FD_SPLITTER_DEBUG_OP_CALLS */ +#endif /* H5FD_SPLITTER_DEBUG_OP_CALLS */ /* Private functions */ @@ -107,71 +107,72 @@ static herr_t H5FD__splitter_log_error(const H5FD_splitter_t *file, const char * static int H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr); /* Prototypes */ -static herr_t H5FD_splitter_term(void); +static herr_t H5FD_splitter_term(void); static hsize_t H5FD_splitter_sb_size(H5FD_t *_file); -static herr_t H5FD_splitter_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/); -static herr_t H5FD_splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); -static void *H5FD_splitter_fapl_get(H5FD_t *_file); -static void *H5FD_splitter_fapl_copy(const void *_old_fa); -static herr_t H5FD_splitter_fapl_free(void *_fapl); +static herr_t H5FD_splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); +static herr_t H5FD_splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); +static void * H5FD_splitter_fapl_get(H5FD_t *_file); +static void * H5FD_splitter_fapl_copy(const void *_old_fa); +static herr_t H5FD_splitter_fapl_free(void *_fapl); static H5FD_t *H5FD_splitter_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_splitter_close(H5FD_t *_file); -static int H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_splitter_query(const H5FD_t *_file, unsigned long *flags /* out */); -static herr_t H5FD_splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map); +static herr_t H5FD_splitter_close(H5FD_t *_file); +static int H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_splitter_query(const H5FD_t *_file, unsigned long *flags /* out */); +static herr_t H5FD_splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map); static haddr_t H5FD_splitter_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -static herr_t H5FD_splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); +static herr_t H5FD_splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); static haddr_t H5FD_splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); -static herr_t H5FD_splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr); +static herr_t H5FD_splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr); static haddr_t H5FD_splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); -static herr_t H5FD_splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle); -static herr_t H5FD_splitter_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf); -static herr_t H5FD_splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); -static herr_t H5FD_splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_splitter_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_splitter_unlock(H5FD_t *_file); +static herr_t H5FD_splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle); +static herr_t H5FD_splitter_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_splitter_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_splitter_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_splitter_g = { - "splitter", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_splitter_term, /* terminate */ - H5FD_splitter_sb_size, /* sb_size */ - H5FD_splitter_sb_encode, /* sb_encode */ - H5FD_splitter_sb_decode, /* sb_decode */ + "splitter", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_splitter_term, /* terminate */ + H5FD_splitter_sb_size, /* sb_size */ + H5FD_splitter_sb_encode, /* sb_encode */ + H5FD_splitter_sb_decode, /* sb_decode */ sizeof(H5FD_splitter_fapl_t), /* fapl_size */ - H5FD_splitter_fapl_get, /* fapl_get */ - H5FD_splitter_fapl_copy, /* fapl_copy */ - H5FD_splitter_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_splitter_open, /* open */ - H5FD_splitter_close, /* close */ - H5FD_splitter_cmp, /* cmp */ - H5FD_splitter_query, /* query */ - H5FD_splitter_get_type_map, /* get_type_map */ - H5FD_splitter_alloc, /* alloc */ - H5FD_splitter_free, /* free */ - H5FD_splitter_get_eoa, /* get_eoa */ - H5FD_splitter_set_eoa, /* set_eoa */ - H5FD_splitter_get_eof, /* get_eof */ - H5FD_splitter_get_handle, /* get_handle */ - H5FD_splitter_read, /* read */ - H5FD_splitter_write, /* write */ - H5FD_splitter_flush, /* flush */ - H5FD_splitter_truncate, /* truncate */ - H5FD_splitter_lock, /* lock */ - H5FD_splitter_unlock, /* unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + H5FD_splitter_fapl_get, /* fapl_get */ + H5FD_splitter_fapl_copy, /* fapl_copy */ + H5FD_splitter_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_splitter_open, /* open */ + H5FD_splitter_close, /* close */ + H5FD_splitter_cmp, /* cmp */ + H5FD_splitter_query, /* query */ + H5FD_splitter_get_type_map, /* get_type_map */ + H5FD_splitter_alloc, /* alloc */ + H5FD_splitter_free, /* free */ + H5FD_splitter_get_eoa, /* get_eoa */ + H5FD_splitter_set_eoa, /* set_eoa */ + H5FD_splitter_get_eof, /* get_eof */ + H5FD_splitter_get_handle, /* get_handle */ + H5FD_splitter_read, /* read */ + H5FD_splitter_write, /* write */ + H5FD_splitter_flush, /* flush */ + H5FD_splitter_truncate, /* truncate */ + H5FD_splitter_lock, /* lock */ + H5FD_splitter_unlock, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_splitter_t struct */ H5FL_DEFINE_STATIC(H5FD_splitter_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -197,7 +198,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_init * @@ -227,7 +227,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_splitter_term * @@ -249,8 +248,7 @@ H5FD_splitter_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_splitter_term() */ - - /*------------------------------------------------------------------------- +/*------------------------------------------------------------------------- * Function: H5FD__copy_plist * * Purpose: Sanity-wrapped H5P_copy_plist() for each channel. @@ -260,11 +258,10 @@ H5FD_splitter_term(void) *------------------------------------------------------------------------- */ static int -H5FD__copy_plist(hid_t fapl_id, - hid_t *id_out_ptr) +H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr) { - int ret_value = 0; - H5P_genplist_t *plist_ptr = NULL; + int ret_value = 0; + H5P_genplist_t *plist_ptr = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -290,7 +287,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__copy_plist() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_splitter * @@ -303,9 +299,9 @@ done: herr_t H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) { - H5FD_splitter_fapl_t info; - H5P_genplist_t *plist_ptr = NULL; - herr_t ret_value = SUCCEED; + H5FD_splitter_fapl_t info; + H5P_genplist_t * plist_ptr = NULL; + herr_t ret_value = SUCCEED; H5Eclear2(H5E_DEFAULT); @@ -325,7 +321,6 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid property list") } - /* Make sure that the W/O channel supports write-only capability. * Some drivers (e.g. family or multi) do revision of the superblock * in-memory, causing problems in that channel. @@ -333,10 +328,10 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) * determining attribute. */ if (H5P_DEFAULT != vfd_config->wo_fapl_id) { - H5FD_class_t *wo_driver = NULL; - H5FD_driver_prop_t wo_driver_prop; - H5P_genplist_t *wo_plist_ptr = NULL; - unsigned long wo_driver_flags = 0; + H5FD_class_t * wo_driver = NULL; + H5FD_driver_prop_t wo_driver_prop; + H5P_genplist_t * wo_plist_ptr = NULL; + unsigned long wo_driver_flags = 0; wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id); if (NULL == wo_plist_ptr) { @@ -357,7 +352,6 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) } } /* end if W/O VFD is non-default */ - info.ignore_wo_errs = vfd_config->ignore_wo_errs; HDstrncpy(info.wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); HDstrncpy(info.log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); @@ -384,7 +378,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_splitter() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_splitter * @@ -401,7 +394,7 @@ herr_t H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_out) { const H5FD_splitter_fapl_t *fapl_ptr = NULL; - H5P_genplist_t *plist_ptr = NULL; + H5P_genplist_t * plist_ptr = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -454,7 +447,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_splitter() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_flush * @@ -466,8 +458,8 @@ done: static herr_t H5FD_splitter_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -478,16 +470,14 @@ H5FD_splitter_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "unable to flush R/W file") } if (H5FDflush(file->wo_file, dxpl_id, closing) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_flush", - H5E_VFL, H5E_CANTFLUSH, FAIL, - "unable to flush W/O file") + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_flush", H5E_VFL, H5E_CANTFLUSH, FAIL, + "unable to flush W/O file") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_flush() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_read * @@ -503,16 +493,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_read( - H5FD_t *_file, - H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, - size_t size, - void *buf /*out*/) +H5FD_splitter_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf /*out*/) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -539,7 +524,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_read() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_write * @@ -554,7 +538,7 @@ static herr_t H5FD_splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - H5P_genplist_t *plist_ptr = NULL; + H5P_genplist_t * plist_ptr = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -571,16 +555,14 @@ H5FD_splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "R/W file write failed") } if (H5FDwrite(file->wo_file, type, dxpl_id, addr, size, buf) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_write", - H5E_VFL, H5E_WRITEERROR, FAIL, - "unable to write W/O file") + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_write", H5E_VFL, H5E_WRITEERROR, FAIL, + "unable to write W/O file") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_write() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_fapl_get * @@ -597,7 +579,7 @@ static void * H5FD_splitter_fapl_get(H5FD_t *_file) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - void *ret_value = NULL; + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -608,7 +590,6 @@ H5FD_splitter_fapl_get(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_splitter_fapl_copy * @@ -622,8 +603,8 @@ static void * H5FD_splitter_fapl_copy(const void *_old_fa) { const H5FD_splitter_fapl_t *old_fa_ptr = (const H5FD_splitter_fapl_t *)_old_fa; - H5FD_splitter_fapl_t *new_fa_ptr = NULL; - void *ret_value = NULL; + H5FD_splitter_fapl_t * new_fa_ptr = NULL; + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -666,7 +647,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_fapl_copy() */ - /*-------------------------------------------------------------------------- * Function: H5FD_splitter_fapl_free * @@ -678,7 +658,7 @@ done: static herr_t H5FD_splitter_fapl_free(void *_fapl) { - H5FD_splitter_fapl_t *fapl = (H5FD_splitter_fapl_t*)_fapl; + H5FD_splitter_fapl_t *fapl = (H5FD_splitter_fapl_t *)_fapl; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -702,7 +682,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_fapl_free() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_open * @@ -717,10 +696,10 @@ done: static H5FD_t * H5FD_splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, haddr_t maxaddr) { - H5FD_splitter_t *file_ptr = NULL; /* Splitter VFD info */ + H5FD_splitter_t * file_ptr = NULL; /* Splitter VFD info */ const H5FD_splitter_fapl_t *fapl_ptr = NULL; /* Driver-specific property list */ - H5P_genplist_t *plist_ptr = NULL; - H5FD_t *ret_value = NULL; + H5P_genplist_t * plist_ptr = NULL; + H5FD_t * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -736,9 +715,7 @@ H5FD_splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, had if (ADDR_OVERFLOW(maxaddr)) { HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") } - if ( (H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || - (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id)) ) - { + if ((H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id))) { /* presupposes that H5P_FILE_ACCESS_DEFAULT is not a splitter */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "driver is not splitter") } @@ -788,7 +765,7 @@ H5FD_splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, had HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open log file") } } /* end if logfile path given */ - } /* end if logfile pointer/handle does not exist */ + } /* end if logfile pointer/handle does not exist */ file_ptr->rw_file = H5FD_open(name, flags, fapl_ptr->rw_fapl_id, HADDR_UNDEF); if (!file_ptr->rw_file) { @@ -797,12 +774,11 @@ H5FD_splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, had file_ptr->wo_file = H5FD_open(fapl_ptr->wo_path, flags, fapl_ptr->wo_fapl_id, HADDR_UNDEF); if (!file_ptr->wo_file) { - H5FD_SPLITTER_WO_ERROR(file_ptr, "H5FD_splitter_open", - H5E_VFL, H5E_CANTOPENFILE, NULL, - "unable to open W/O file") + H5FD_SPLITTER_WO_ERROR(file_ptr, "H5FD_splitter_open", H5E_VFL, H5E_CANTOPENFILE, NULL, + "unable to open W/O file") } - ret_value = (H5FD_t*)file_ptr; + ret_value = (H5FD_t *)file_ptr; done: if (NULL == ret_value) { @@ -829,7 +805,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_open() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_close * @@ -866,9 +841,8 @@ H5FD_splitter_close(H5FD_t *_file) } if (file->wo_file) { if (H5FD_close(file->wo_file) == FAIL) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_close", - H5E_VFL, H5E_CANTCLOSEFILE, FAIL, - "unable to close W/O file") + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_close", H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "unable to close W/O file") } } @@ -885,7 +859,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_close() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_get_eoa * @@ -920,7 +893,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_get_eoa */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_set_eoa * @@ -934,8 +906,8 @@ done: static herr_t H5FD_splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -951,16 +923,14 @@ H5FD_splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t add } if (H5FD_set_eoa(file->wo_file, type, addr) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_set_eoa", - H5E_VFL, H5E_CANTSET, FAIL, - "unable to set EOA for W/O file") + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_set_eoa", H5E_VFL, H5E_CANTSET, FAIL, + "unable to set EOA for W/O file") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_get_eof * @@ -976,8 +946,8 @@ done: static haddr_t H5FD_splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -995,7 +965,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_get_eof */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_truncate * @@ -1007,8 +976,8 @@ done: static herr_t H5FD_splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1023,16 +992,14 @@ H5FD_splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) } if (H5FDtruncate(file->wo_file, dxpl_id, closing) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_truncate", - H5E_VFL, H5E_CANTUPDATE, FAIL, - "unable to truncate W/O file") + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_truncate", H5E_VFL, H5E_CANTUPDATE, FAIL, + "unable to truncate W/O file") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_truncate */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_sb_size * @@ -1068,7 +1035,6 @@ H5FD_splitter_sb_size(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_sb_size */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_sb_encode * @@ -1078,10 +1044,10 @@ H5FD_splitter_sb_size(H5FD_t *_file) *------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/) +H5FD_splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1099,7 +1065,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_sb_encode */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_sb_decode * @@ -1113,8 +1078,8 @@ done: static herr_t H5FD_splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1132,7 +1097,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_sb_decode */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_cmp * @@ -1145,9 +1109,9 @@ done: static int H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_splitter_t *f1 = (const H5FD_splitter_t *)_f1; - const H5FD_splitter_t *f2 = (const H5FD_splitter_t *)_f2; - herr_t ret_value = 0; /* Return value */ + const H5FD_splitter_t *f1 = (const H5FD_splitter_t *)_f1; + const H5FD_splitter_t *f2 = (const H5FD_splitter_t *)_f2; + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1161,7 +1125,6 @@ H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_cmp */ - /*-------------------------------------------------------------------------- * Function: H5FD_splitter_get_handle * @@ -1172,13 +1135,10 @@ H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) *-------------------------------------------------------------------------- */ static herr_t -H5FD_splitter_get_handle( - H5FD_t *_file, - hid_t H5_ATTR_UNUSED fapl, - void **file_handle) +H5FD_splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_splitter_t *file = (H5FD_splitter_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1190,8 +1150,7 @@ H5FD_splitter_get_handle( HDassert(file_handle); /* Only do for R/W channel */ - if (H5FD_get_vfd_handle(file->rw_file, file->fa.rw_fapl_id, file_handle) < 0) - { + if (H5FD_get_vfd_handle(file->rw_file, file->fa.rw_fapl_id, file_handle) < 0) { HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to get handle of R/W file") } @@ -1199,7 +1158,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_get_handle */ - /*-------------------------------------------------------------------------- * Function: H5FD_splitter_lock * @@ -1211,8 +1169,8 @@ done: static herr_t H5FD_splitter_lock(H5FD_t *_file, hbool_t rw) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1227,9 +1185,8 @@ H5FD_splitter_lock(H5FD_t *_file, hbool_t rw) } if (file->wo_file != NULL) { if (H5FD_lock(file->wo_file, rw) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_lock", - H5E_VFL, H5E_CANTLOCK, FAIL, - "unable to lock W/O file") + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_lock", H5E_VFL, H5E_CANTLOCK, FAIL, + "unable to lock W/O file") } } @@ -1237,7 +1194,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_lock */ - /*-------------------------------------------------------------------------- * Function: H5FD_splitter_unlock * @@ -1249,8 +1205,8 @@ done: static herr_t H5FD_splitter_unlock(H5FD_t *_file) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1266,8 +1222,7 @@ H5FD_splitter_unlock(H5FD_t *_file) } if (file->wo_file != NULL) { if (H5FD_unlock(file->wo_file) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL, - "unable to unlock W/O file") + HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL, "unable to unlock W/O file") } } @@ -1275,7 +1230,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_unlock */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_query * @@ -1300,8 +1254,7 @@ H5FD_splitter_query(const H5FD_t *_file, unsigned long *flags /* out */) HDassert(file->rw_file); if (H5FDquery(file->rw_file, flags) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, - "unable to query R/W file"); + HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, "unable to query R/W file"); } } else { @@ -1317,7 +1270,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_alloc * @@ -1329,8 +1281,8 @@ done: static haddr_t H5FD_splitter_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1346,16 +1298,14 @@ H5FD_splitter_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) } if (H5FDalloc(file->wo_file, type, dxpl_id, size) == HADDR_UNDEF) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_alloc", - H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, - "unable to alloc for W/O file") + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_alloc", H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, + "unable to alloc for W/O file") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_get_type_map * @@ -1387,7 +1337,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_get_type_map() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_free * @@ -1399,8 +1348,8 @@ done: static herr_t H5FD_splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1415,16 +1364,14 @@ H5FD_splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, } if (H5FDfree(file->wo_file, type, dxpl_id, addr, size) < 0) { - H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_free", - H5E_VFL, H5E_CANTINIT, FAIL, - "unable to free for W/O file") + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_free", H5E_VFL, H5E_CANTINIT, FAIL, + "unable to free for W/O file") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_free() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_log_error * @@ -1436,8 +1383,8 @@ done: static herr_t H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const char *msg) { - size_t size = 0; - char *s = NULL; + size_t size = 0; + char * s = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_NOERR @@ -1451,16 +1398,14 @@ H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const if (file->logfp != NULL) { size = strlen(atfunc) + strlen(msg) + 3; /* ':', ' ', '\n' */ - s = (char *)malloc(sizeof(char) * (size+1)); + s = (char *)malloc(sizeof(char) * (size + 1)); if (NULL == s) { ret_value = FAIL; } - else - if (size < (size_t)HDsnprintf(s, size+1, "%s: %s\n", atfunc, msg)) { + else if (size < (size_t)HDsnprintf(s, size + 1, "%s: %s\n", atfunc, msg)) { ret_value = FAIL; } - else - if (size != HDfwrite(s, 1, size, file->logfp)) { + else if (size != HDfwrite(s, 1, size, file->logfp)) { ret_value = FAIL; } HDfree(s); @@ -1468,4 +1413,3 @@ H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_log_error() */ - diff --git a/src/H5FDsplitter.h b/src/H5FDsplitter.h index 5a5ef29..1f091b0 100644 --- a/src/H5FDsplitter.h +++ b/src/H5FDsplitter.h @@ -75,19 +75,19 @@ * ---------------------------------------------------------------------------- */ typedef struct H5FD_splitter_vfd_config_t { - int32_t magic; + int32_t magic; unsigned int version; - hid_t rw_fapl_id; - hid_t wo_fapl_id; - char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; - char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; - hbool_t ignore_wo_errs; + hid_t rw_fapl_id; + hid_t wo_fapl_id; + char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; + char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; + hbool_t ignore_wo_errs; } H5FD_splitter_vfd_config_t; #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_splitter_init(void); +H5_DLL hid_t H5FD_splitter_init(void); H5_DLL herr_t H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_ptr); H5_DLL herr_t H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_ptr); @@ -96,4 +96,3 @@ H5_DLL herr_t H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *co #endif #endif - diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 3135709..63d2730 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -41,8 +41,8 @@ #ifdef H5_HAVE_WIN32_API /* The following two defines must be before any windows headers are included */ -#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ -#define NOGDI /* Exclude Graphic Display Interface macros */ +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#define NOGDI /* Exclude Graphic Display Interface macros */ #include #include @@ -57,10 +57,10 @@ static size_t H5_STDIO_MAX_IO_BYTES_g = (size_t)-1; /* File operations */ typedef enum { - H5FD_STDIO_OP_UNKNOWN=0, - H5FD_STDIO_OP_READ=1, - H5FD_STDIO_OP_WRITE=2, - H5FD_STDIO_OP_SEEK=3 + H5FD_STDIO_OP_UNKNOWN = 0, + H5FD_STDIO_OP_READ = 1, + H5FD_STDIO_OP_WRITE = 2, + H5FD_STDIO_OP_SEEK = 3 } H5FD_stdio_file_op; /* The description of a file belonging to this driver. The 'eoa' and 'eof' @@ -75,14 +75,14 @@ typedef enum { * occurs), and 'op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_stdio_t { - H5FD_t pub; /* public stuff, must be first */ - FILE *fp; /* the file handle */ - int fd; /* file descriptor (for truncate) */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* end of file; current file size */ - haddr_t pos; /* current file I/O position */ - unsigned write_access; /* Flag to indicate the file was opened with write access */ - H5FD_stdio_file_op op; /* last operation */ + H5FD_t pub; /* public stuff, must be first */ + FILE * fp; /* the file handle */ + int fd; /* file descriptor (for truncate) */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* end of file; current file size */ + haddr_t pos; /* current file I/O position */ + unsigned write_access; /* Flag to indicate the file was opened with write access */ + H5FD_stdio_file_op op; /* last operation */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. Note that Cygwin, MinGW and other Windows POSIX @@ -90,8 +90,8 @@ typedef struct H5FD_stdio_t { * and will use the 'device + inodes' scheme as opposed to the * Windows code further below. */ - dev_t device; /* file device number */ - ino_t inode; /* file i-node number */ + dev_t device; /* file device number */ + ino_t inode; /* file i-node number */ #else /* Files in windows are uniquely identified by the volume serial * number and the file index (both low and high parts). @@ -107,21 +107,21 @@ typedef struct H5FD_stdio_t { * * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx */ - DWORD nFileIndexLow; - DWORD nFileIndexHigh; - DWORD dwVolumeSerialNumber; + DWORD nFileIndexLow; + DWORD nFileIndexHigh; + DWORD dwVolumeSerialNumber; - HANDLE hFile; /* Native windows file handle */ -#endif /* H5_HAVE_WIN32_API */ + HANDLE hFile; /* Native windows file handle */ +#endif /* H5_HAVE_WIN32_API */ } H5FD_stdio_t; /* Use similar structure as in H5private.h by defining Windows stuff first. */ #ifdef H5_HAVE_WIN32_API #ifndef H5_HAVE_MINGW - #define file_fseek _fseeki64 - #define file_offset_t __int64 - #define file_ftruncate _chsize_s /* Supported in VS 2005 or newer */ - #define file_ftell _ftelli64 +#define file_fseek _fseeki64 +#define file_offset_t __int64 +#define file_ftruncate _chsize_s /* Supported in VS 2005 or newer */ +#define file_ftell _ftelli64 #endif /* H5_HAVE_MINGW */ #endif /* H5_HAVE_WIN32_API */ @@ -129,10 +129,10 @@ typedef struct H5FD_stdio_t { * more platform-independent names. */ #ifndef file_fseek - #define file_fseek fseeko - #define file_offset_t off_t - #define file_ftruncate ftruncate - #define file_ftell ftello +#define file_fseek fseeko +#define file_offset_t off_t +#define file_ftruncate ftruncate +#define file_ftell ftello #endif /* file_fseek */ /* These macros check for overflow of various quantities. These macros @@ -150,70 +150,69 @@ typedef struct H5FD_stdio_t { * argument of the file seek function. */ /* adding for windows NT filesystem support. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || (file_offset_t)((A)+(Z))<(file_offset_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(file_offset_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || \ + (file_offset_t)((A) + (Z)) < (file_offset_t)(A)) /* Prototypes */ -static herr_t H5FD_stdio_term(void); -static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, - hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_stdio_close(H5FD_t *lf); -static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_stdio_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD_stdio_term(void); +static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_stdio_close(H5FD_t *lf); +static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_stdio_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); static haddr_t H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_stdio_read(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD_stdio_write(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_stdio_unlock(H5FD_t *_file); +static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_stdio_read(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_stdio_write(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_stdio_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_stdio_g = { - "stdio", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_stdio_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - NULL, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_stdio_open, /* open */ - H5FD_stdio_close, /* close */ - H5FD_stdio_cmp, /* cmp */ - H5FD_stdio_query, /* query */ - NULL, /* get_type_map */ - H5FD_stdio_alloc, /* alloc */ - NULL, /* free */ - H5FD_stdio_get_eoa, /* get_eoa */ - H5FD_stdio_set_eoa, /* set_eoa */ - H5FD_stdio_get_eof, /* get_eof */ - H5FD_stdio_get_handle, /* get_handle */ - H5FD_stdio_read, /* read */ - H5FD_stdio_write, /* write */ - H5FD_stdio_flush, /* flush */ - H5FD_stdio_truncate, /* truncate */ - H5FD_stdio_lock, /* lock */ - H5FD_stdio_unlock, /* unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "stdio", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_stdio_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_stdio_open, /* open */ + H5FD_stdio_close, /* close */ + H5FD_stdio_cmp, /* cmp */ + H5FD_stdio_query, /* query */ + NULL, /* get_type_map */ + H5FD_stdio_alloc, /* alloc */ + NULL, /* free */ + H5FD_stdio_get_eoa, /* get_eoa */ + H5FD_stdio_set_eoa, /* set_eoa */ + H5FD_stdio_get_eof, /* get_eof */ + H5FD_stdio_get_handle, /* get_handle */ + H5FD_stdio_read, /* read */ + H5FD_stdio_write, /* write */ + H5FD_stdio_flush, /* flush */ + H5FD_stdio_truncate, /* truncate */ + H5FD_stdio_lock, /* lock */ + H5FD_stdio_unlock, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; - /*------------------------------------------------------------------------- * Function: H5FD_stdio_init * @@ -235,12 +234,11 @@ H5FD_stdio_init(void) /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - if (H5I_VFL!=H5Iget_type(H5FD_STDIO_g)) + if (H5I_VFL != H5Iget_type(H5FD_STDIO_g)) H5FD_STDIO_g = H5FDregister(&H5FD_stdio_g); return H5FD_STDIO_g; } /* end H5FD_stdio_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_stdio_term * @@ -262,7 +260,6 @@ H5FD_stdio_term(void) return 0; } /* end H5FD_stdio_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_stdio * @@ -280,20 +277,19 @@ H5FD_stdio_term(void) herr_t H5Pset_fapl_stdio(hid_t fapl_id) { - static const char *func = "H5FDset_fapl_stdio"; /*for error reporting*/ + static const char *func = "H5FDset_fapl_stdio"; /*for error reporting*/ /*NO TRACE*/ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - if(0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) + if (0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) - return H5Pset_driver(fapl_id, H5FD_STDIO, NULL); + return H5Pset_driver(fapl_id, H5FD_STDIO, NULL); } /* end H5Pset_fapl_stdio() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_open * @@ -319,18 +315,17 @@ H5Pset_fapl_stdio(hid_t fapl_id) *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_stdio_open( const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, - haddr_t maxaddr) +H5FD_stdio_open(const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, haddr_t maxaddr) { - FILE *f = NULL; - unsigned write_access = 0; /* File opened with write access? */ - H5FD_stdio_t *file = NULL; - static const char *func = "H5FD_stdio_open"; /* Function Name for error reporting */ + FILE * f = NULL; + unsigned write_access = 0; /* File opened with write access? */ + H5FD_stdio_t * file = NULL; + static const char *func = "H5FD_stdio_open"; /* Function Name for error reporting */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; -#else /* H5_HAVE_WIN32_API */ - struct stat sb; -#endif /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ + struct stat sb; +#endif /* H5_HAVE_WIN32_API */ /* Sanity check on file offsets */ assert(sizeof(file_offset_t) >= sizeof(size_t)); @@ -343,104 +338,108 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, /* Check arguments */ if (!name || !*name) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL) - if (0 == maxaddr || HADDR_UNDEF == maxaddr) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL) - if (ADDR_OVERFLOW(maxaddr)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL) - - /* Tentatively open file in read-only mode, to check for existence */ - if(flags & H5F_ACC_RDWR) - f = fopen(name, "rb+"); + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", + NULL) if (0 == maxaddr || HADDR_UNDEF == maxaddr) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", + NULL) if (ADDR_OVERFLOW(maxaddr)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL) + + /* Tentatively open file in read-only mode, to check for existence */ + if (flags & H5F_ACC_RDWR) f = fopen(name, "rb+"); else f = fopen(name, "rb"); - if(!f) { + if (!f) { /* File doesn't exist */ - if(flags & H5F_ACC_CREAT) { + if (flags & H5F_ACC_CREAT) { assert(flags & H5F_ACC_RDWR); - f = fopen(name, "wb+"); - write_access = 1; /* Note the write access */ + f = fopen(name, "wb+"); + write_access = 1; /* Note the write access */ } else - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, "file doesn't exist and CREAT wasn't specified", NULL) - } else if(flags & H5F_ACC_EXCL) { + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, + "file doesn't exist and CREAT wasn't specified", NULL) + } + else if (flags & H5F_ACC_EXCL) { /* File exists, but EXCL is passed. Fail. */ assert(flags & H5F_ACC_CREAT); fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FILEEXISTS, "file exists but CREAT and EXCL were specified", NULL) - } else if(flags & H5F_ACC_RDWR) { - if(flags & H5F_ACC_TRUNC) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FILEEXISTS, + "file exists but CREAT and EXCL were specified", NULL) + } + else if (flags & H5F_ACC_RDWR) { + if (flags & H5F_ACC_TRUNC) f = freopen(name, "wb+", f); - write_access = 1; /* Note the write access */ - } /* end if */ + write_access = 1; /* Note the write access */ + } /* end if */ /* Note there is no need to reopen if neither TRUNC nor EXCL are specified, * as the tentative open will work */ - if(!f) + if (!f) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL) - /* Build the return value */ - if(NULL == (file = (H5FD_stdio_t *)calloc((size_t)1, sizeof(H5FD_stdio_t)))) { - fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL) - } /* end if */ - file->fp = f; - file->op = H5FD_STDIO_OP_SEEK; - file->pos = HADDR_UNDEF; - file->write_access = write_access; /* Note the write_access for later */ - if(file_fseek(file->fp, (file_offset_t)0, SEEK_END) < 0) { + /* Build the return value */ + if (NULL == (file = (H5FD_stdio_t *)calloc((size_t)1, sizeof(H5FD_stdio_t)))) + { + fclose(f); + H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL) + } /* end if */ + file->fp = f; + file->op = H5FD_STDIO_OP_SEEK; + file->pos = HADDR_UNDEF; + file->write_access = write_access; /* Note the write_access for later */ + if (file_fseek(file->fp, (file_offset_t)0, SEEK_END) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; - } else { + } + else { file_offset_t x = file_ftell(file->fp); - assert (x >= 0); + assert(x >= 0); file->eof = (haddr_t)x; } /* Get the file descriptor (needed for truncate and some Windows information) */ #ifdef H5_HAVE_WIN32_API file->fd = _fileno(file->fp); -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ file->fd = fileno(file->fp); #endif /* H5_HAVE_WIN32_API */ - if(file->fd < 0) { + if (file->fd < 0) { free(file); fclose(f); H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get file descriptor", NULL); } /* end if */ - #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(file->fd); - if(INVALID_HANDLE_VALUE == file->hFile) { + if (INVALID_HANDLE_VALUE == file->hFile) { free(file); fclose(f); H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get Windows file handle", NULL); } /* end if */ - if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) { + if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) { free(file); fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get Windows file descriptor information", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, + "unable to get Windows file descriptor information", NULL); } /* end if */ - file->nFileIndexHigh = fileinfo.nFileIndexHigh; - file->nFileIndexLow = fileinfo.nFileIndexLow; + file->nFileIndexHigh = fileinfo.nFileIndexHigh; + file->nFileIndexLow = fileinfo.nFileIndexLow; file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber; -#else /* H5_HAVE_WIN32_API */ - if(fstat(file->fd, &sb) < 0) { +#else /* H5_HAVE_WIN32_API */ + if (fstat(file->fd, &sb) < 0) { free(file); fclose(f); H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADFILE, "unable to fstat file", NULL) } /* end if */ file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /* H5_HAVE_WIN32_API */ - return((H5FD_t*)file); + return ((H5FD_t *)file); } /* end H5FD_stdio_open() */ - /*------------------------------------------------------------------------- * Function: H5F_stdio_close * @@ -459,8 +458,8 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id, static herr_t H5FD_stdio_close(H5FD_t *_file) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - static const char *func = "H5FD_stdio_close"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -468,12 +467,11 @@ H5FD_stdio_close(H5FD_t *_file) if (fclose(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1) - free(file); + free(file); return 0; } /* end H5FD_stdio_close() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_cmp * @@ -493,41 +491,52 @@ H5FD_stdio_close(H5FD_t *_file) static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_stdio_t *f1 = (const H5FD_stdio_t*)_f1; - const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; + const H5FD_stdio_t *f1 = (const H5FD_stdio_t *)_f1; + const H5FD_stdio_t *f2 = (const H5FD_stdio_t *)_f2; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); #ifdef H5_HAVE_WIN32_API - if(f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) return -1; - if(f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) return 1; - - if(f1->nFileIndexHigh < f2->nFileIndexHigh) return -1; - if(f1->nFileIndexHigh > f2->nFileIndexHigh) return 1; - - if(f1->nFileIndexLow < f2->nFileIndexLow) return -1; - if(f1->nFileIndexLow > f2->nFileIndexLow) return 1; + if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) + return -1; + if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) + return 1; + + if (f1->nFileIndexHigh < f2->nFileIndexHigh) + return -1; + if (f1->nFileIndexHigh > f2->nFileIndexHigh) + return 1; + + if (f1->nFileIndexLow < f2->nFileIndexLow) + return -1; + if (f1->nFileIndexLow > f2->nFileIndexLow) + return 1; #else /* H5_HAVE_WIN32_API */ #ifdef H5_DEV_T_IS_SCALAR - if(f1->device < f2->device) return -1; - if(f1->device > f2->device) return 1; -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + return -1; + if (f1->device > f2->device) + return 1; +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(memcmp(&(f1->device),&(f2->device),sizeof(dev_t)) < 0) return -1; - if(memcmp(&(f1->device),&(f2->device),sizeof(dev_t)) > 0) return 1; + if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + return -1; + if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + return 1; #endif /* H5_DEV_T_IS_SCALAR */ - if(f1->inode < f2->inode) return -1; - if(f1->inode > f2->inode) return 1; + if (f1->inode < f2->inode) + return -1; + if (f1->inode > f2->inode) + return 1; #endif /* H5_HAVE_WIN32_API */ return 0; } /* H5FD_stdio_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_query * @@ -547,26 +556,26 @@ static herr_t H5FD_stdio_query(const H5FD_t *_f, unsigned long /*OUT*/ *flags) { /* Quiet the compiler */ - _f=_f; + _f = _f; /* Set the VFL feature flags that this driver supports. * * Note that this VFD does not support SWMR due to the unpredictable * nature of the buffering layer. */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ } return 0; } /* end H5FD_stdio_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_alloc * @@ -588,11 +597,11 @@ H5FD_stdio_query(const H5FD_t *_f, unsigned long /*OUT*/ *flags) static haddr_t H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, hsize_t size) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - haddr_t addr; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; + haddr_t addr; /* Quiet compiler */ - type = type; + type = type; dxpl_id = dxpl_id; /* Clear the error stack */ @@ -606,7 +615,6 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp return addr; } /* end H5FD_stdio_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_eoa * @@ -637,7 +645,6 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) return file->eoa; } /* end H5FD_stdio_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_set_eoa * @@ -657,7 +664,7 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, haddr_t addr) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -670,7 +677,6 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, haddr_t addr) return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_eof * @@ -692,7 +698,7 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, haddr_t addr) static haddr_t H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) { - const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; + const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Quiet the compiler */ type = type; @@ -703,10 +709,9 @@ H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) /* Quiet the compiler */ type = type; - return(file->eof); + return (file->eof); } /* end H5FD_stdio_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_handle * @@ -722,8 +727,8 @@ H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t /*UNUSED*/ fapl, void **file_handle) { - H5FD_stdio_t *file = (H5FD_stdio_t *)_file; - static const char *func = "H5FD_stdio_get_handle"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_get_handle"; /* Function Name for error reporting */ /* Quiet the compiler */ fapl = fapl; @@ -732,13 +737,12 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t /*UNUSED*/ fapl, void **file_handle) H5Eclear2(H5E_DEFAULT); *file_handle = &(file->fp); - if(*file_handle == NULL) + if (*file_handle == NULL) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "get handle failed", -1) - return 0; + return 0; } /* end H5FD_stdio_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_read * @@ -758,38 +762,36 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t /*UNUSED*/ fapl, void **file_handle) *------------------------------------------------------------------------- */ static herr_t -H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, - haddr_t addr, size_t size, void /*OUT*/ *buf) +H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, haddr_t addr, + size_t size, void /*OUT*/ *buf) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - static const char *func = "H5FD_stdio_read"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_read"; /* Function Name for error reporting */ /* Quiet the compiler */ - type = type; + type = type; dxpl_id = dxpl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check for overflow */ - if (HADDR_UNDEF==addr) - H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) - if (REGION_OVERFLOW(addr, size)) - H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) + if (HADDR_UNDEF == addr) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", + -1) if (REGION_OVERFLOW(addr, size)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) - /* Check easy cases */ - if (0 == size) - return 0; + /* Check easy cases */ + if (0 == size) return 0; if ((haddr_t)addr >= file->eof) { memset(buf, 0, size); return 0; } /* Seek to the correct file position. */ - if (!(file->op == H5FD_STDIO_OP_READ || file->op == H5FD_STDIO_OP_SEEK) || - file->pos != addr) { + if (!(file->op == H5FD_STDIO_OP_READ || file->op == H5FD_STDIO_OP_SEEK) || file->pos != addr) { if (file_fseek(file->fp, (file_offset_t)addr, SEEK_SET) < 0) { - file->op = H5FD_STDIO_OP_UNKNOWN; + file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) } @@ -798,7 +800,7 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl /* Read zeros past the logical end of file (physical is handled below) */ if (addr + size > file->eof) { - size_t nbytes = (size_t) (addr + size - file->eof); + size_t nbytes = (size_t)(addr + size - file->eof); memset((unsigned char *)buf + size - nbytes, 0, nbytes); size -= nbytes; } @@ -807,26 +809,26 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl * will advance the file position by N. If N is zero or an error * occurs then the file position is undefined. */ - while(size > 0) { + while (size > 0) { - size_t bytes_in = 0; /* # of bytes to read */ - size_t bytes_read = 0; /* # of bytes actually read */ - size_t item_size = 1; /* size of items in bytes */ + size_t bytes_in = 0; /* # of bytes to read */ + size_t bytes_read = 0; /* # of bytes actually read */ + size_t item_size = 1; /* size of items in bytes */ - if(size > H5_STDIO_MAX_IO_BYTES_g) + if (size > H5_STDIO_MAX_IO_BYTES_g) bytes_in = H5_STDIO_MAX_IO_BYTES_g; else bytes_in = size; bytes_read = fread(buf, item_size, bytes_in, file->fp); - if(0 == bytes_read && ferror(file->fp)) { /* error */ - file->op = H5FD_STDIO_OP_UNKNOWN; + if (0 == bytes_read && ferror(file->fp)) { /* error */ + file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_READERROR, "fread failed", -1) } /* end if */ - if(0 == bytes_read && feof(file->fp)) { + if (0 == bytes_read && feof(file->fp)) { /* end of file but not end of format address space */ memset((unsigned char *)buf, 0, size); break; @@ -838,13 +840,12 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl } /* end while */ /* Update the file position data. */ - file->op = H5FD_STDIO_OP_READ; + file->op = H5FD_STDIO_OP_READ; file->pos = addr; return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_stdio_write * @@ -863,55 +864,55 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl *------------------------------------------------------------------------- */ static herr_t -H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, - haddr_t addr, size_t size, const void *buf) +H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, haddr_t addr, + size_t size, const void *buf) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - static const char *func = "H5FD_stdio_write"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_write"; /* Function Name for error reporting */ /* Quiet the compiler */ dxpl_id = dxpl_id; - type = type; + type = type; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check for overflow conditions */ if (HADDR_UNDEF == addr) - H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) - if (REGION_OVERFLOW(addr, size)) - H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) - - /* Seek to the correct file position. */ - if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) || - file->pos != addr) { - if (file_fseek(file->fp, (file_offset_t)addr, SEEK_SET) < 0) { - file->op = H5FD_STDIO_OP_UNKNOWN; - file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", + -1) if (REGION_OVERFLOW(addr, size)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) + + /* Seek to the correct file position. */ + if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) || file->pos != addr) + { + if (file_fseek(file->fp, (file_offset_t)addr, SEEK_SET) < 0) { + file->op = H5FD_STDIO_OP_UNKNOWN; + file->pos = HADDR_UNDEF; + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) + } + file->pos = addr; } - file->pos = addr; - } /* Write the buffer. On successful return, the file position will be * advanced by the number of bytes read. On failure, the file position is * undefined. */ - while(size > 0) { + while (size > 0) { - size_t bytes_in = 0; /* # of bytes to write */ - size_t bytes_wrote = 0; /* # of bytes written */ - size_t item_size = 1; /* size of items in bytes */ + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ + size_t item_size = 1; /* size of items in bytes */ - if(size > H5_STDIO_MAX_IO_BYTES_g) + if (size > H5_STDIO_MAX_IO_BYTES_g) bytes_in = H5_STDIO_MAX_IO_BYTES_g; else bytes_in = size; bytes_wrote = fwrite(buf, item_size, bytes_in, file->fp); - if(bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(file->fp))) { /* error */ - file->op = H5FD_STDIO_OP_UNKNOWN; + if (bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(file->fp))) { /* error */ + file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1) } /* end if */ @@ -925,7 +926,7 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp } /* Update seek optimizing data. */ - file->op = H5FD_STDIO_OP_WRITE; + file->op = H5FD_STDIO_OP_WRITE; file->pos = addr; /* Update EOF if necessary */ @@ -935,7 +936,6 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_stdio_flush * @@ -955,8 +955,8 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t closing) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */ /* Quiet the compiler */ dxpl_id = dxpl_id; @@ -965,21 +965,20 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t closing) H5Eclear2(H5E_DEFAULT); /* Only try to flush the file if we have write access */ - if(file->write_access) { - if(!closing) { - if(fflush(file->fp) < 0) + if (file->write_access) { + if (!closing) { + if (fflush(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) - /* Reset last file I/O information */ - file->pos = HADDR_UNDEF; + /* Reset last file I/O information */ + file->pos = HADDR_UNDEF; file->op = H5FD_STDIO_OP_UNKNOWN; } /* end if */ - } /* end if */ + } /* end if */ return 0; } /* end H5FD_stdio_flush() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_truncate * @@ -998,11 +997,10 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t closing) *------------------------------------------------------------------------- */ static herr_t -H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, - hbool_t /*UNUSED*/ closing) +H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t /*UNUSED*/ closing) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - static const char *func = "H5FD_stdio_truncate"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_truncate"; /* Function Name for error reporting */ /* Quiet the compiler */ dxpl_id = dxpl_id; @@ -1012,17 +1010,17 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, H5Eclear2(H5E_DEFAULT); /* Only try to flush the file if we have write access */ - if(file->write_access) { + if (file->write_access) { /* Makes sure that the true file size is the same as the end-of-address. */ - if(file->eoa != file->eof) { + if (file->eoa != file->eof) { #ifdef H5_HAVE_WIN32_API - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() - * Only used as an error code here. - */ - DWORD dwError; /* DWORD error code from GetLastError() */ - BOOL bError; /* Boolean error flag */ + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + * Only used as an error code here. + */ + DWORD dwError; /* DWORD error code from GetLastError() */ + BOOL bError; /* Boolean error flag */ /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); @@ -1036,42 +1034,43 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, * from SetFilePointer(), we also need to check GetLastError(). */ dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); - if(INVALID_SET_FILE_POINTER == dwPtrLow) { + if (INVALID_SET_FILE_POINTER == dwPtrLow) { dwError = GetLastError(); - if(dwError != NO_ERROR ) + if (dwError != NO_ERROR) H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_FILEOPEN, "unable to set file pointer", -1) } bError = SetEndOfFile(file->hFile); - if(0 == bError) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1) -#else /* H5_HAVE_WIN32_API */ + if (0 == bError) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, + "unable to truncate/extend file properly", -1) +#else /* H5_HAVE_WIN32_API */ /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); /* Truncate file to proper length */ - if(-1 == file_ftruncate(file->fd, (file_offset_t)file->eoa)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1) + if (-1 == file_ftruncate(file->fd, (file_offset_t)file->eoa)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, + "unable to truncate/extend file properly", -1) #endif /* H5_HAVE_WIN32_API */ - /* Update the eof value */ - file->eof = file->eoa; + /* Update the eof value */ + file->eof = file->eoa; /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = H5FD_STDIO_OP_UNKNOWN; + file->op = H5FD_STDIO_OP_UNKNOWN; } /* end if */ - } /* end if */ + } /* end if */ else { /* Double-check for problems */ - if(file->eoa > file->eof) + if (file->eoa > file->eof) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_TRUNCATED, "eoa > eof!", -1) } /* end else */ return 0; } /* end H5FD_stdio_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_lock * @@ -1091,9 +1090,9 @@ static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw) { #ifdef H5_HAVE_FLOCK - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* VFD file struct */ - int lock_flags; /* file locking flags */ - static const char *func = "H5FD_stdio_lock"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + static const char *func = "H5FD_stdio_lock"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1104,20 +1103,21 @@ H5FD_stdio_lock(H5FD_t *_file, hbool_t rw) lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(flock(file->fd, lock_flags | LOCK_NB) < 0) { - if(ENOSYS == errno) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)", -1) - else - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file lock failed", -1) + if (flock(file->fd, lock_flags | LOCK_NB) < 0) { + if (ENOSYS == errno) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, + "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment " + "variable to override)", + -1) else H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file lock failed", -1) } /* end if */ /* Flush the stream */ - if(fflush(file->fp) < 0) + if (fflush(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) #endif /* H5_HAVE_FLOCK */ - return 0; + return 0; } /* end H5FD_stdio_lock() */ /*------------------------------------------------------------------------- @@ -1139,8 +1139,8 @@ static herr_t H5FD_stdio_unlock(H5FD_t *_file) { #ifdef H5_HAVE_FLOCK - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* VFD file struct */ - static const char *func = "H5FD_stdio_unlock"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; /* VFD file struct */ + static const char *func = "H5FD_stdio_unlock"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1148,23 +1148,25 @@ H5FD_stdio_unlock(H5FD_t *_file) assert(file); /* Flush the stream */ - if(fflush(file->fp) < 0) + if (fflush(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) - /* Place a non-blocking lock on the file */ - if(flock(file->fd, LOCK_UN) < 0) { - if(ENOSYS == errno) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)", -1) - else - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file unlock failed", -1) - } /* end if */ + /* Place a non-blocking lock on the file */ + if (flock(file->fd, LOCK_UN) < 0) + { + if (ENOSYS == errno) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, + "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING " + "environment variable to override)", + -1) else H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file unlock failed", + -1) + } /* end if */ #endif /* H5_HAVE_FLOCK */ return 0; } /* end H5FD_stdio_unlock() */ - #ifdef _H5private_H /* * This is not related to the functionality of the driver code. @@ -1173,4 +1175,3 @@ H5FD_stdio_unlock(H5FD_t *_file) */ #error "Do not use HDF5 private definitions" #endif - diff --git a/src/H5FDstdio.h b/src/H5FDstdio.h index f99aacf..2c3ef07 100644 --- a/src/H5FDstdio.h +++ b/src/H5FDstdio.h @@ -22,13 +22,13 @@ #include "H5Ipublic.h" -#define H5FD_STDIO (H5FD_stdio_init()) +#define H5FD_STDIO (H5FD_stdio_init()) #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_stdio_init(void); +H5_DLL hid_t H5FD_stdio_init(void); H5_DLL herr_t H5Pset_fapl_stdio(hid_t fapl_id); #ifdef __cplusplus diff --git a/src/H5FDtest.c b/src/H5FDtest.c index 53e31c7..4687d96 100644 --- a/src/H5FDtest.c +++ b/src/H5FDtest.c @@ -25,55 +25,47 @@ /* Module Setup */ /****************/ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ -#define H5FD_TESTING /* Suppress warning about H5FD testing funcs */ - +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ +#define H5FD_TESTING /* Suppress warning about H5FD testing funcs */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Eprivate.h" /* Error handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ /* Declare external the free list for H5FD_vfd_swmr_idx_entry_t */ H5FL_SEQ_EXTERN(H5FD_vfd_swmr_idx_entry_t); - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5FD__supports_swmr_test() * @@ -108,7 +100,7 @@ H5FD__supports_swmr_test(const char *vfd_name) FUNC_ENTER_NOAPI_NOINIT_NOERR - if(!vfd_name || !HDstrcmp(vfd_name, "") || !HDstrcmp(vfd_name, "nomatch")) + if (!vfd_name || !HDstrcmp(vfd_name, "") || !HDstrcmp(vfd_name, "nomatch")) ret_value = TRUE; else ret_value = !HDstrcmp(vfd_name, "log") || !HDstrcmp(vfd_name, "sec2"); @@ -133,50 +125,52 @@ H5FD__supports_swmr_test(const char *vfd_name) herr_t H5FD__vfd_swmr_reader_md_test(H5FD_t *file, unsigned num_entries, H5FD_vfd_swmr_idx_entry_t index[]) { - unsigned vfd_num_entries = 0; - H5FD_vfd_swmr_idx_entry_t *vfd_index = NULL; - unsigned i; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned vfd_num_entries = 0; + H5FD_vfd_swmr_idx_entry_t *vfd_index = NULL; + unsigned i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Retrieve index from VFD SWMR driver */ /* Initial call to get # of entries */ - if(H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, NULL, &vfd_num_entries, vfd_index) < 0) + if (H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, NULL, &vfd_num_entries, vfd_index) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Error in retrieving index from driver") /* Verify number of index entries */ - if(vfd_num_entries != num_entries) + if (vfd_num_entries != num_entries) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Error in retrieving index from driver") - if(vfd_num_entries) { + if (vfd_num_entries) { /* Allocate memory for index entries */ - if(NULL == (vfd_index = H5FL_SEQ_MALLOC(H5FD_vfd_swmr_idx_entry_t, vfd_num_entries))) + if (NULL == (vfd_index = H5FL_SEQ_MALLOC(H5FD_vfd_swmr_idx_entry_t, vfd_num_entries))) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "memory allocation failed for index entries") /* Second call to retrieve the index */ - if(H5FD_vfd_swmr_get_tick_and_idx(file, FALSE, NULL, &vfd_num_entries, vfd_index) < 0) + if (H5FD_vfd_swmr_get_tick_and_idx(file, FALSE, NULL, &vfd_num_entries, vfd_index) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Error in retrieving index from driver") - /* Verify index entries */ - for(i = 0; i < vfd_num_entries; i++) { - if(vfd_index[i].length != index[i].length) + /* Verify index entries */ + for (i = 0; i < vfd_num_entries; i++) { + if (vfd_index[i].length != index[i].length) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect length read from metadata file") - if(vfd_index[i].hdf5_page_offset != index[i].hdf5_page_offset) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect hdf5_page_offset read from metadata file") + if (vfd_index[i].hdf5_page_offset != index[i].hdf5_page_offset) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect hdf5_page_offset read from metadata file") - if(vfd_index[i].md_file_page_offset != index[i].md_file_page_offset) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect md_file_page_offset read from metadata file") + if (vfd_index[i].md_file_page_offset != index[i].md_file_page_offset) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect md_file_page_offset read from metadata file") - if(vfd_index[i].chksum != index[i].chksum) + if (vfd_index[i].chksum != index[i].chksum) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect chksum read from metadata file") } } done: /* Free local copy of index entries */ - if(vfd_num_entries && vfd_index) + if (vfd_num_entries && vfd_index) vfd_index = (H5FD_vfd_swmr_idx_entry_t *)H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, vfd_index); FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c index 405bcd7..90c06b6 100644 --- a/src/H5FDvfd_swmr.c +++ b/src/H5FDvfd_swmr.c @@ -17,126 +17,120 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDvfd_swmr.h" /* VFD SWMR file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5retry_private.h"/* Retry loops. */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDvfd_swmr.h" /* VFD SWMR file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5retry_private.h" /* Retry loops. */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_VFD_SWMR_g = 0; typedef struct H5FD_vfd_swmr_t { - H5FD_t pub; /* public stuff, must be */ - /* first */ + H5FD_t pub; /* public stuff, must be */ + /* first */ /* HDF5 file */ - char hdf5_filename[H5FD_MAX_FILENAME_LEN]; /* Name of the HDF5 file from */ - /* open */ - H5FD_t *hdf5_file_lf; /* Driver info for the HDF5 */ - /* file */ + char hdf5_filename[H5FD_MAX_FILENAME_LEN]; /* Name of the HDF5 file from */ + /* open */ + H5FD_t *hdf5_file_lf; /* Driver info for the HDF5 */ + /* file */ /* Metadata file */ - int md_fd; /* File descriptor for the */ - /* metadata file */ - uint32_t md_pages_reserved; /* # of pages reserved at the */ - /* head of the metadata file */ - char md_file_path[H5FD_MAX_FILENAME_LEN]; /* Name of the metadate file */ - H5FD_vfd_swmr_md_header md_header; /* Metadata file header */ - H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ - - uint64_t *api_elapsed_ticks; /* Histogram of ticks elapsed - * inside the API (reader only). - * api_elapsed_ticks[elapsed] is - * the number of times `elapsed` - * ticks passed in an API call - * during the program lifetime. - */ - uint32_t api_elapsed_nbuckets; /* Number of histogram buckets. */ - - hbool_t pb_configured; /* boolean flag set to TRUE */ - /* when the page buffer is */ - /* and to FALSE otherwise. */ - /* Used for sanity checking. */ + int md_fd; /* File descriptor for the */ + /* metadata file */ + uint32_t md_pages_reserved; /* # of pages reserved at the */ + /* head of the metadata file */ + char md_file_path[H5FD_MAX_FILENAME_LEN]; /* Name of the metadate file */ + H5FD_vfd_swmr_md_header md_header; /* Metadata file header */ + H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ + + uint64_t *api_elapsed_ticks; /* Histogram of ticks elapsed + * inside the API (reader only). + * api_elapsed_ticks[elapsed] is + * the number of times `elapsed` + * ticks passed in an API call + * during the program lifetime. + */ + uint32_t api_elapsed_nbuckets; /* Number of histogram buckets. */ + + hbool_t pb_configured; /* boolean flag set to TRUE */ + /* when the page buffer is */ + /* and to FALSE otherwise. */ + /* Used for sanity checking. */ H5F_vfd_swmr_config_t config; - hbool_t writer; /* True iff configured to write. - * All methods on a write-mode - * SWMR VFD instance are passed - * to the lower VFD instance. - */ + hbool_t writer; /* True iff configured to write. + * All methods on a write-mode + * SWMR VFD instance are passed + * to the lower VFD instance. + */ } H5FD_vfd_swmr_t; -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) /* Prototypes */ -static herr_t H5FD_vfd_swmr_term(void); -static H5FD_t *H5FD_vfd_swmr_open(const char *name, unsigned flags, - hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_vfd_swmr_close(H5FD_t *_file); -static int H5FD_vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_vfd_swmr_term(void); +static H5FD_t *H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_vfd_swmr_close(H5FD_t *_file); +static int H5FD_vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static H5FD_t *H5FD_vfd_swmr_dedup(H5FD_t *, H5FD_t *, hid_t); -static herr_t H5FD_vfd_swmr_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD_vfd_swmr_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_vfd_swmr_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_vfd_swmr_set_eoa(H5FD_t *_file, H5FD_mem_t type, - haddr_t addr); +static herr_t H5FD_vfd_swmr_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_vfd_swmr_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_vfd_swmr_get_handle(H5FD_t *_file, hid_t fapl, - void** file_handle); -static herr_t H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, - hid_t fapl_id, haddr_t addr, size_t size, void *buf); -static herr_t H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, - hid_t fapl_id, haddr_t addr, size_t size, const void *buf); -static herr_t H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t dxpl_id, - hbool_t closing); -static herr_t H5FD_vfd_swmr_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_vfd_swmr_unlock(H5FD_t *_file); +static herr_t H5FD_vfd_swmr_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_vfd_swmr_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_vfd_swmr_unlock(H5FD_t *_file); /* VFD SWMR */ -static htri_t H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *, - H5FD_vfd_swmr_md_header *); -static htri_t H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, - H5FD_vfd_swmr_md_index *md_index, const H5FD_vfd_swmr_md_header *md_header); +static htri_t H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *, H5FD_vfd_swmr_md_header *); +static htri_t H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_index *md_index, + const H5FD_vfd_swmr_md_header *md_header); static herr_t H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *, hbool_t); static const H5FD_class_t H5FD_vfd_swmr_g = { - "vfd_swmr", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_vfd_swmr_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - NULL, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_vfd_swmr_open, /* open */ - H5FD_vfd_swmr_close, /* close */ - H5FD_vfd_swmr_cmp, /* cmp */ - H5FD_vfd_swmr_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD_vfd_swmr_get_eoa, /* get_eoa */ - H5FD_vfd_swmr_set_eoa, /* set_eoa */ - H5FD_vfd_swmr_get_eof, /* get_eof */ - H5FD_vfd_swmr_get_handle, /* get_handle */ - H5FD_vfd_swmr_read, /* read */ - H5FD_vfd_swmr_write, /* write */ - NULL, /* flush */ - H5FD_vfd_swmr_truncate, /* truncate */ - H5FD_vfd_swmr_lock, /* lock */ - H5FD_vfd_swmr_unlock, /* unlock */ - H5FD_vfd_swmr_dedup, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "vfd_swmr", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_vfd_swmr_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_vfd_swmr_open, /* open */ + H5FD_vfd_swmr_close, /* close */ + H5FD_vfd_swmr_cmp, /* cmp */ + H5FD_vfd_swmr_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_vfd_swmr_get_eoa, /* get_eoa */ + H5FD_vfd_swmr_set_eoa, /* set_eoa */ + H5FD_vfd_swmr_get_eof, /* get_eof */ + H5FD_vfd_swmr_get_handle, /* get_handle */ + H5FD_vfd_swmr_read, /* read */ + H5FD_vfd_swmr_write, /* write */ + NULL, /* flush */ + H5FD_vfd_swmr_truncate, /* truncate */ + H5FD_vfd_swmr_lock, /* lock */ + H5FD_vfd_swmr_unlock, /* unlock */ + H5FD_vfd_swmr_dedup, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_vfd_swmr_t struct */ @@ -145,7 +139,6 @@ H5FL_DEFINE_STATIC(H5FD_vfd_swmr_t); /* Declare a free list to manage the H5FD_vfd_swmr_idx_entry_t sequence information */ H5FL_SEQ_DEFINE(H5FD_vfd_swmr_idx_entry_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -163,14 +156,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_vfd_swmr_init() < 0) + if (H5FD_vfd_swmr_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize swmr VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_init * @@ -188,11 +180,11 @@ done: hid_t H5FD_vfd_swmr_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5I_VFL != H5I_get_type(H5FD_VFD_SWMR_g)) + if (H5I_VFL != H5I_get_type(H5FD_VFD_SWMR_g)) H5FD_VFD_SWMR_g = H5FD_register(&H5FD_vfd_swmr_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -202,7 +194,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_vfd_swmr_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_term * @@ -226,7 +217,6 @@ H5FD_vfd_swmr_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_vfd_swmr_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_vfd_swmr (Not yet) * @@ -240,13 +230,13 @@ H5FD_vfd_swmr_term(void) herr_t H5Pset_fapl_vfd_swmr(hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", fapl_id); - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value = H5P_set_driver(plist, H5FD_VFD_SWMR, NULL); @@ -263,47 +253,41 @@ static herr_t H5FD__swmr_reader_open(H5FD_vfd_swmr_t *file) { h5_retry_t retry; - hbool_t do_try; /* more tries remain */ - herr_t ret_value = SUCCEED; + hbool_t do_try; /* more tries remain */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC file->api_elapsed_nbuckets = file->config.max_lag + 1; - file->api_elapsed_ticks = - H5MM_calloc(file->api_elapsed_nbuckets * sizeof(*file->api_elapsed_ticks)); + file->api_elapsed_ticks = H5MM_calloc(file->api_elapsed_nbuckets * sizeof(*file->api_elapsed_ticks)); if (file->api_elapsed_ticks == NULL) { - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, - "could not allocate API elapsed ticks"); + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "could not allocate API elapsed ticks"); } /* Retry on opening the metadata file */ - for (do_try = h5_retry_init(&retry, H5FD_VFD_SWMR_MD_FILE_RETRY_MAX, - H5_RETRY_DEFAULT_MINIVAL, - H5_RETRY_DEFAULT_MAXIVAL); - do_try; - do_try = h5_retry_next(&retry)) { - if((file->md_fd = HDopen(file->md_file_path, O_RDONLY)) >= 0) + for (do_try = h5_retry_init(&retry, H5FD_VFD_SWMR_MD_FILE_RETRY_MAX, H5_RETRY_DEFAULT_MINIVAL, + H5_RETRY_DEFAULT_MAXIVAL); + do_try; do_try = h5_retry_next(&retry)) { + if ((file->md_fd = HDopen(file->md_file_path, O_RDONLY)) >= 0) break; } /* Exhaust all retries for opening the md file */ - if(!do_try) + if (!do_try) HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, FAIL, - "unable to open the metadata file after all retry attempts"); + "unable to open the metadata file after all retry attempts"); /* Retry on loading and decoding the header and index in the * metadata file */ - if(H5FD__vfd_swmr_load_hdr_and_idx(file, TRUE) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, - "unable to load/decode the md file header/index"); + if (H5FD__vfd_swmr_load_hdr_and_idx(file, TRUE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to load/decode the md file header/index"); done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_open * @@ -317,21 +301,19 @@ done: *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr) +H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_vfd_swmr_t *file = NULL; - size_t page_buf_size; - H5P_genplist_t *plist; + H5FD_vfd_swmr_t * file = NULL; + size_t page_buf_size; + H5P_genplist_t * plist; H5F_vfd_swmr_config_t *vfd_swmr_config; - H5FD_t *ret_value = NULL; /* Return value */ + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get file access property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, - "not a file access property list"); + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list"); } if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0) @@ -342,26 +324,23 @@ H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, * and return an error. */ if (page_buf_size == 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, - "page buffering must be enabled"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "page buffering must be enabled"); } /* Create the new driver struct */ - if(NULL == (file = H5FL_CALLOC(H5FD_vfd_swmr_t))) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "unable to allocate file struct"); + if (NULL == (file = H5FL_CALLOC(H5FD_vfd_swmr_t))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct"); } vfd_swmr_config = &file->config; /* Get VFD SWMR configuration */ - if(H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, vfd_swmr_config) < 0) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, - "can't get VFD SWMR config info"); + if (H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, vfd_swmr_config) < 0) { + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VFD SWMR config info"); } - file->md_fd = -1; - file->hdf5_file_lf = NULL; + file->md_fd = -1; + file->hdf5_file_lf = NULL; file->md_pages_reserved = vfd_swmr_config->md_pages_reserved; /* Retain a copy of the name used to open the HDF5 file */ @@ -369,21 +348,18 @@ H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, file->hdf5_filename[sizeof(file->hdf5_filename) - 1] = '\0'; /* Retain a copy of the metadata file name */ - HDstrncpy(file->md_file_path, vfd_swmr_config->md_file_path, - sizeof(file->md_file_path)); + HDstrncpy(file->md_file_path, vfd_swmr_config->md_file_path, sizeof(file->md_file_path)); file->md_file_path[sizeof(file->md_file_path) - 1] = '\0'; file->writer = vfd_swmr_config->writer; /* Ensure that this is the reader */ if (!vfd_swmr_config->writer && H5FD__swmr_reader_open(file) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, NULL, - "perform reader-specific opening steps failed"); + HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, NULL, "perform reader-specific opening steps failed"); } /* Hard-wired to open the underlying HDF5 file with SEC2 */ - if((file->hdf5_file_lf = H5FD_open(name, flags, H5P_FILE_ACCESS_DEFAULT, - maxaddr)) == NULL) + if ((file->hdf5_file_lf = H5FD_open(name, flags, H5P_FILE_ACCESS_DEFAULT, maxaddr)) == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "can't set driver info"); file->hdf5_file_lf->exc_owner = &file->pub; @@ -404,9 +380,9 @@ H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, done: /* Handle closing if error */ - if(NULL == ret_value && file) { + if (NULL == ret_value && file) { - if(H5FD_vfd_swmr_close(&file->pub) < 0) + if (H5FD_vfd_swmr_close(&file->pub) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "error from closing") @@ -428,19 +404,16 @@ swmr_reader_close(H5FD_vfd_swmr_t *file) H5MM_xfree(file->api_elapsed_ticks); /* Close the metadata file */ - if(file->md_fd >= 0 && HDclose(file->md_fd) < 0) { + if (file->md_fd >= 0 && HDclose(file->md_fd) < 0) { /* Push error, but keep going */ - HERROR(H5E_FILE, H5E_CANTCLOSEFILE, - "unable to close the metadata file"); + HERROR(H5E_FILE, H5E_CANTCLOSEFILE, "unable to close the metadata file"); } /* Free the index entries */ - if(file->md_index.num_entries && file->md_index.entries) - file->md_index.entries = H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, - file->md_index.entries); + if (file->md_index.num_entries && file->md_index.entries) + file->md_index.entries = H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, file->md_index.entries); } - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_close * @@ -457,8 +430,8 @@ swmr_reader_close(H5FD_vfd_swmr_t *file) static herr_t H5FD_vfd_swmr_close(H5FD_t *_file) { - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -470,9 +443,8 @@ H5FD_vfd_swmr_close(H5FD_t *_file) /* Close the underlying file */ if (H5FD_close(file->hdf5_file_lf) < 0) - /* Push error, but keep going */ - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, \ - "unable to close the HDF5 file") + /* Push error, but keep going */ + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close the HDF5 file") } if (!file->writer) @@ -485,7 +457,6 @@ H5FD_vfd_swmr_close(H5FD_t *_file) } /* end H5FD_vfd_swmr_close() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_cmp * @@ -501,9 +472,9 @@ H5FD_vfd_swmr_close(H5FD_t *_file) static int H5FD_vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_vfd_swmr_t *f1 = (const H5FD_vfd_swmr_t *)_f1; - const H5FD_vfd_swmr_t *f2 = (const H5FD_vfd_swmr_t *)_f2; - int ret_value = 0; + const H5FD_vfd_swmr_t *f1 = (const H5FD_vfd_swmr_t *)_f1; + const H5FD_vfd_swmr_t *f2 = (const H5FD_vfd_swmr_t *)_f2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -552,10 +523,10 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) HDassert(_self->driver_id == H5FD_VFD_SWMR_g); if (_self->cls == _other->cls) { - H5FD_vfd_swmr_t *other = (H5FD_vfd_swmr_t *)_other; - H5P_genplist_t *plist; + H5FD_vfd_swmr_t * other = (H5FD_vfd_swmr_t *)_other; + H5P_genplist_t * plist; H5F_vfd_swmr_config_t *config; - hbool_t equal_configs; + hbool_t equal_configs; if (H5FD_cmp(self->hdf5_file_lf, other->hdf5_file_lf) != 0) return _other; @@ -581,8 +552,8 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) return NULL; } if (H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config) < 0) { - HERROR(H5E_PLIST, H5E_CANTGET, "cannot get VFD SWMR config"); - return NULL; + HERROR(H5E_PLIST, H5E_CANTGET, "cannot get VFD SWMR config"); + return NULL; } equal_configs = HDmemcmp(&self->config, config, sizeof(*config)) == 0; @@ -594,14 +565,15 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl) HERROR(H5E_PLIST, H5E_CANTGET, "inconsistent VFD SWMR config"); return NULL; - } else if (H5FD_cmp(self->hdf5_file_lf, _other) == 0) { + } + else if (H5FD_cmp(self->hdf5_file_lf, _other) == 0) { return (fapl == H5P_FILE_ACCESS_ANY_VFD) ? _self : NULL; - } else { + } + else { return _other; } } - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_query * @@ -618,32 +590,32 @@ H5FD_vfd_swmr_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate */ - /* metadata allocations */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate */ + /* metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate */ - /* metadata for faster */ - /* writes */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate */ + /* metadata for faster */ + /* writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data */ - /* sieving for faster */ - /* raw data reads & */ - /* writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data */ + /* sieving for faster */ + /* raw data reads & */ + /* writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate */ - /* "small" raw data */ - /* allocations */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate */ + /* "small" raw data */ + /* allocations */ - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback */ - /* returns a POSIX file */ - /* descriptor */ + *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback */ + /* returns a POSIX file */ + /* descriptor */ - *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the */ - /* single-writer/ */ - /* multiple-readers */ - /* (SWMR) pattern */ + *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the */ + /* single-writer/ */ + /* multiple-readers */ + /* (SWMR) pattern */ *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file */ /* which can be opened */ @@ -654,7 +626,6 @@ H5FD_vfd_swmr_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_vfd_swmr_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_get_eoa * @@ -669,21 +640,19 @@ H5FD_vfd_swmr_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* static haddr_t H5FD_vfd_swmr_get_eoa(const H5FD_t *_file, H5FD_mem_t type) { - const H5FD_vfd_swmr_t *file = (const H5FD_vfd_swmr_t *)_file; - haddr_t ret_value = HADDR_UNDEF; + const H5FD_vfd_swmr_t *file = (const H5FD_vfd_swmr_t *)_file; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI_NOINIT - if((ret_value = H5FD_get_eoa(file->hdf5_file_lf, type)) == HADDR_UNDEF) + if ((ret_value = H5FD_get_eoa(file->hdf5_file_lf, type)) == HADDR_UNDEF) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HADDR_UNDEF, \ - "unable to get HDF5 file eoa") + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HADDR_UNDEF, "unable to get HDF5 file eoa") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_vfd_swmr_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_set_eoa * @@ -699,12 +668,12 @@ done: static herr_t H5FD_vfd_swmr_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - if(H5FD_set_eoa(file->hdf5_file_lf, type, addr) < 0) + if (H5FD_set_eoa(file->hdf5_file_lf, type, addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set HDF5 file eoa") @@ -712,7 +681,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_vfd_swmr_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_get_eof * @@ -728,22 +696,20 @@ done: static haddr_t H5FD_vfd_swmr_get_eof(const H5FD_t *_file, H5FD_mem_t type) { - const H5FD_vfd_swmr_t *file = (const H5FD_vfd_swmr_t *)_file; - haddr_t ret_value = HADDR_UNDEF; + const H5FD_vfd_swmr_t *file = (const H5FD_vfd_swmr_t *)_file; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI_NOINIT /* LATER: need to determine the metadata file or underlying HDF5 file ? */ - if((ret_value = H5FD_get_eof(file->hdf5_file_lf, type)) == HADDR_UNDEF) + if ((ret_value = H5FD_get_eof(file->hdf5_file_lf, type)) == HADDR_UNDEF) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HADDR_UNDEF, \ - "unable to set file eoa") + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, HADDR_UNDEF, "unable to set file eoa") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_vfd_swmr_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_get_handle * @@ -756,27 +722,24 @@ done: static herr_t H5FD_vfd_swmr_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") /* LATER? H5P_get(plist, H5F_ACS_SWMR_FILE_NAME, &type) */ - if((ret_value = H5FD_get_vfd_handle(file->hdf5_file_lf, - fapl, file_handle)) < 0) + if ((ret_value = H5FD_get_vfd_handle(file->hdf5_file_lf, fapl, file_handle)) < 0) - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, \ - "unable to get handle for HDF5 file") + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unable to get handle for HDF5 file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_vfd_swmr_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_read * @@ -813,19 +776,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, - hid_t H5_ATTR_UNUSED dxpl_id, - const haddr_t addr, size_t size, void * const buf /*out*/) +H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, const haddr_t addr, + size_t size, void *const buf /*out*/) { - const size_t init_size = size; - haddr_t target_page; - haddr_t page_offset; - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + const size_t init_size = size; + haddr_t target_page; + haddr_t page_offset; + H5FD_vfd_swmr_t * file = (H5FD_vfd_swmr_t *)_file; H5FD_vfd_swmr_idx_entry_t *index, *entry; - uint32_t num_entries = 0; - uint32_t fs_page_size; - herr_t ret_value = SUCCEED; - char *p = buf; + uint32_t num_entries = 0; + uint32_t fs_page_size; + herr_t ret_value = SUCCEED; + char * p = buf; if (file->writer) return H5FD_read(file->hdf5_file_lf, type, addr, size, buf); @@ -842,14 +804,12 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, /* Try finding the addr from the index */ target_page = addr / fs_page_size; - entry = vfd_swmr_pageno_to_mdf_idx_entry(index, num_entries, target_page, - FALSE); + entry = vfd_swmr_pageno_to_mdf_idx_entry(index, num_entries, target_page, FALSE); if (entry == NULL) { - /* Cannot find addr in index, read from the underlying hdf5 file */ - if(H5FD_read(file->hdf5_file_lf, type, addr, size, buf) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, \ - "file read request failed"); + /* Cannot find addr in index, read from the underlying hdf5 file */ + if (H5FD_read(file->hdf5_file_lf, type, addr, size, buf) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed"); } HGOTO_DONE(SUCCEED); } @@ -859,29 +819,26 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, page_offset = addr - (target_page * fs_page_size); - HDassert( ( page_offset == 0 ) || - ( ( ! file->pb_configured ) && - ( page_offset + size <= fs_page_size ) ) ); + HDassert((page_offset == 0) || ((!file->pb_configured) && (page_offset + size <= fs_page_size))); HDassert(entry->hdf5_page_offset * fs_page_size <= addr); HDassert(addr < (entry->hdf5_page_offset + 1) * fs_page_size); HDassert(page_offset + init_size <= entry->length); - if(HDlseek(file->md_fd, (HDoff_t) - ((entry->md_file_page_offset * fs_page_size) - + page_offset), SEEK_SET) < 0) + if (HDlseek(file->md_fd, (HDoff_t)((entry->md_file_page_offset * fs_page_size) + page_offset), SEEK_SET) < + 0) HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file") /* Coding borrowed from sec2 read */ - while(size > 0) { + while (size > 0) { - h5_posix_io_t bytes_in; /* # of bytes to read */ - h5_posix_io_ret_t bytes_read; /* # of bytes actually read */ + h5_posix_io_t bytes_in; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = MIN(H5_POSIX_MAX_IO_BYTES, size); else bytes_in = (h5_posix_io_t)size; @@ -890,8 +847,9 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, bytes_read = HDread(file->md_fd, p, bytes_in); } while (-1 == bytes_read && EINTR == errno); - if(-1 == bytes_read) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "error reading the page/multi-page entry from the md file") + if (-1 == bytes_read) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, + "error reading the page/multi-page entry from the md file") HDassert(0 <= bytes_read && (size_t)bytes_read <= size); @@ -909,24 +867,22 @@ H5FD_vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, * is John's hack to allow the library to find the superblock * signature. */ - if (file->pb_configured && entry->length == init_size - && H5_checksum_metadata(buf, entry->length, 0) != entry->chksum) { + if (file->pb_configured && entry->length == init_size && + H5_checksum_metadata(buf, entry->length, 0) != entry->chksum) { H5FD_vfd_swmr_md_header tmp_header; if (H5FD__vfd_swmr_header_deserialize(file, &tmp_header) != TRUE) { HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, - "checksum error in shadow file entry; could not load header"); + "checksum error in shadow file entry; could not load header"); } - HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, - "checksum error in shadow file entry"); + HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "checksum error in shadow file entry"); } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_vfd_swmr_read() */ - /* * Function: H5FD_vfd_swmr_write * @@ -937,10 +893,10 @@ done: * Return: SUCCEED/FAIL */ static herr_t -H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, - hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) +H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, + const void *buf) { - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* This routine should only be called if the VFD instance is opened * for writing. @@ -950,7 +906,6 @@ H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, return H5FD_write(file->hdf5_file_lf, type, addr, size, buf); } - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_truncate * @@ -962,8 +917,7 @@ H5FD_vfd_swmr_write(H5FD_t *_file, H5FD_mem_t type, *------------------------------------------------------------------------- */ static herr_t -H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, - hbool_t closing) +H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ @@ -975,7 +929,6 @@ H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, return H5FD_truncate(file->hdf5_file_lf, closing); } - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_lock * @@ -988,23 +941,21 @@ H5FD_vfd_swmr_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, static herr_t H5FD_vfd_swmr_lock(H5FD_t *_file, hbool_t rw) { - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(H5FD_lock(file->hdf5_file_lf, rw) < 0) + if (H5FD_lock(file->hdf5_file_lf, rw) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTLOCK, FAIL, \ - "unable to lock the HDF5 file") + HGOTO_ERROR(H5E_IO, H5E_CANTLOCK, FAIL, "unable to lock the HDF5 file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_vfd_swmr_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_unlock * @@ -1017,17 +968,16 @@ done: static herr_t H5FD_vfd_swmr_unlock(H5FD_t *_file) { - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(H5FD_unlock(file->hdf5_file_lf) < 0) + if (H5FD_unlock(file->hdf5_file_lf) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, \ - "unable to unlock the HDF5 file") + HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock the HDF5 file") done: @@ -1035,7 +985,6 @@ done: } /* end H5FD_vfd_swmr_unlock() */ - /* * Function: H5FD__vfd_swmr_load_hdr_and_idx() * @@ -1084,21 +1033,20 @@ done: static herr_t H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) { - hbool_t do_try; - h5_retry_t retry; - H5FD_vfd_swmr_md_header md_header; /* Metadata file header, take 1 */ - H5FD_vfd_swmr_md_header md_header_two; /* Metadata file header, take 2 */ - H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ - herr_t ret_value = SUCCEED; /* Return value */ - htri_t rc; - static uint64_t last_index_offset = 0; + hbool_t do_try; + h5_retry_t retry; + H5FD_vfd_swmr_md_header md_header; /* Metadata file header, take 1 */ + H5FD_vfd_swmr_md_header md_header_two; /* Metadata file header, take 2 */ + H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ + herr_t ret_value = SUCCEED; /* Return value */ + htri_t rc; + static uint64_t last_index_offset = 0; FUNC_ENTER_STATIC - for (do_try = h5_retry_init(&retry, H5FD_VFD_SWMR_MD_LOAD_RETRY_MAX, - H5_RETRY_ONE_SECOND / 10, H5_RETRY_ONE_SECOND); - do_try; - do_try = h5_retry_next(&retry)) { + for (do_try = h5_retry_init(&retry, H5FD_VFD_SWMR_MD_LOAD_RETRY_MAX, H5_RETRY_ONE_SECOND / 10, + H5_RETRY_ONE_SECOND); + do_try; do_try = h5_retry_next(&retry)) { /* Load and decode the header. Go around again on a temporary * failure (FALSE). Bail on an irrecoverable failure (FAIL). @@ -1123,10 +1071,10 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) * get out. */ HGOTO_DONE(SUCCEED); - } else if (md_header.tick_num < file->md_header.tick_num) { + } + else if (md_header.tick_num < file->md_header.tick_num) { /* The tick number must not move backward. */ - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, - "tick number in header moved backwards"); + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "tick number in header moved backwards"); } HDassert(md_header.tick_num > file->md_header.tick_num || open); @@ -1147,8 +1095,7 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) * then we should have a consistent picture of the index. */ if (md_header.tick_num == md_index.tick_num && - (rc = H5FD__vfd_swmr_header_deserialize(file, - &md_header_two)) == TRUE && + (rc = H5FD__vfd_swmr_header_deserialize(file, &md_header_two)) == TRUE && md_header.tick_num == md_header_two.tick_num && md_header.index_length == md_header_two.index_length && md_header.index_offset == md_header_two.index_offset) @@ -1157,14 +1104,12 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) if (md_index.entries != NULL) { HDassert(md_index.num_entries); - md_index.entries = (H5FD_vfd_swmr_idx_entry_t *) - H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, - md_index.entries); + md_index.entries = + (H5FD_vfd_swmr_idx_entry_t *)H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, md_index.entries); } if (rc == FAIL) { - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, - "could not re-read header"); + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "could not re-read header"); } } @@ -1172,8 +1117,8 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) * and index */ if (!do_try) { - HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, \ - "error in loading/decoding the metadata file header and index") + HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, + "error in loading/decoding the metadata file header and index") } /* Free VFD local entries */ @@ -1181,22 +1126,21 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) HDassert(file->md_index.num_entries); - file->md_index.entries = (H5FD_vfd_swmr_idx_entry_t *) - H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, file->md_index.entries); + file->md_index.entries = + (H5FD_vfd_swmr_idx_entry_t *)H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, file->md_index.entries); } /* Copy header and index to VFD */ - file->md_header = md_header; - file->md_index = md_index; + file->md_header = md_header; + file->md_index = md_index; md_index.entries = NULL; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__vfd_swmr_load_hdr_and_idx() */ +} /* H5FD__vfd_swmr_load_hdr_and_idx() */ - /*------------------------------------------------------------------------- * Function: H5FD__vfd_swmr_header_deserialize() * @@ -1213,23 +1157,21 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, - H5FD_vfd_swmr_md_header *md_header) +H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_header *md_header) { - uint8_t image[H5FD_MD_HEADER_SIZE]; /* Buffer for element data */ - uint32_t stored_chksum; /* Stored metadata checksum */ - uint32_t computed_chksum; /* Computed metadata checksum */ + uint8_t image[H5FD_MD_HEADER_SIZE]; /* Buffer for element data */ + uint32_t stored_chksum; /* Stored metadata checksum */ + uint32_t computed_chksum; /* Computed metadata checksum */ uint8_t *p; - htri_t ret_value = FAIL; + htri_t ret_value = FAIL; uint64_t index_length; - ssize_t nread; + ssize_t nread; FUNC_ENTER_STATIC /* Set file pointer to the beginning the file */ if (HDlseek(file->md_fd, H5FD_MD_HEADER_OFF, SEEK_SET) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, \ - "unable to seek in metadata file"); + HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file"); } /* Read the header */ @@ -1243,8 +1185,7 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, * so bail out. */ if (nread == -1) { - HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, - "error in reading the shadow header"); + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "error in reading the shadow header"); } if ((uint64_t)nread < H5FD_MD_HEADER_SIZE) @@ -1255,8 +1196,7 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, HGOTO_DONE(FALSE); /* Verify stored and computed checksums are equal */ - H5F_get_checksums(image, H5FD_MD_HEADER_SIZE, &stored_chksum, - &computed_chksum); + H5F_get_checksums(image, H5FD_MD_HEADER_SIZE, &stored_chksum, &computed_chksum); if (stored_chksum != computed_chksum) HGOTO_DONE(FALSE); @@ -1269,8 +1209,7 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, UINT64DECODE(p, md_header->tick_num); UINT64DECODE(p, md_header->index_offset); if ((index_length = uint64_decode(&p)) > SIZE_MAX) { - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, - "index is too large to hold in core"); + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "index is too large to hold in core"); } md_header->index_length = (size_t)index_length; @@ -1281,7 +1220,7 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, /* Sanity check */ HDassert((size_t)(p - image) <= H5FD_MD_HEADER_SIZE); -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "---read header ps/tick/idx_off/idx_len = %d / %lld / %lld / %lld\n", md_header->fs_page_size, md_header->tick_num, @@ -1296,8 +1235,6 @@ done: } /* H5FD__vfd_swmr_header_deserialize() */ - - /* * Function: H5FD__vfd_swmr_index_deserialize() * @@ -1315,29 +1252,28 @@ done: * */ static htri_t -H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, - H5FD_vfd_swmr_md_index *md_index, const H5FD_vfd_swmr_md_header *md_header) +H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_index *md_index, + const H5FD_vfd_swmr_md_header *md_header) { - uint8_t *image; /* Buffer */ - uint8_t *p = NULL; /* Pointer to buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - unsigned i; /* Local index variable */ - htri_t ret_value = TRUE; - ssize_t nread; + uint8_t *image; /* Buffer */ + uint8_t *p = NULL; /* Pointer to buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + unsigned i; /* Local index variable */ + htri_t ret_value = TRUE; + ssize_t nread; FUNC_ENTER_STATIC /* Allocate buffer for reading index */ if (NULL == (image = H5MM_malloc(md_header->index_length))) { HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, - "memory allocation failed for index's on disk image buffer"); + "memory allocation failed for index's on disk image buffer"); } /* We may seek past EOF. That's ok, the read(2) will catch that. */ - if (HDlseek(file->md_fd, (HDoff_t)md_header->index_offset, SEEK_SET) < 0){ - HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, - "unable to seek in metadata file"); + if (HDlseek(file->md_fd, (HDoff_t)md_header->index_offset, SEEK_SET) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file"); } nread = HDread(file->md_fd, image, md_header->index_length); @@ -1350,8 +1286,7 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, * so bail out. */ if (nread == -1) { - HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, - "error in reading the header in metadata file"); + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "error in reading the header in metadata file"); } /* Try again if the read was not full. @@ -1391,8 +1326,7 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, HGOTO_DONE(FALSE); /* Verify stored and computed checksums are equal */ - H5F_get_checksums(image, md_header->index_length, &stored_chksum, - &computed_chksum); + H5F_get_checksums(image, md_header->index_length, &stored_chksum, &computed_chksum); if (stored_chksum != computed_chksum) HGOTO_DONE(FALSE); @@ -1406,13 +1340,11 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, UINT32DECODE(p, md_index->num_entries); /* Read index entries */ - if(md_index->num_entries) { + if (md_index->num_entries) { /* Allocate memory for index entries */ - md_index->entries = H5FL_SEQ_CALLOC(H5FD_vfd_swmr_idx_entry_t, - md_index->num_entries); + md_index->entries = H5FL_SEQ_CALLOC(H5FD_vfd_swmr_idx_entry_t, md_index->num_entries); if (NULL == md_index->entries) { - HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, - "memory allocation failed for index entries"); + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "memory allocation failed for index entries"); } /* Decode index entries */ @@ -1421,23 +1353,23 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, UINT32DECODE(p, md_index->entries[i].md_file_page_offset); UINT32DECODE(p, md_index->entries[i].length); UINT32DECODE(p, md_index->entries[i].chksum); - } - } else + } + } + else md_index->entries = NULL; - /* Checksum is already valid */ - UINT32DECODE(p, stored_chksum); + /* Checksum is already valid */ + UINT32DECODE(p, stored_chksum); - /* Sanity check */ - HDassert((size_t)(p - image) <= md_header->index_length); + /* Sanity check */ + HDassert((size_t)(p - image) <= md_header->index_length); -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, " ---- read index tick/num_entries = %lld / %d \n", md_index->tick_num, md_index->num_entries); #endif /* JRM */ - done: if (image != NULL) image = H5MM_xfree(image); @@ -1446,15 +1378,13 @@ done: HDassert(md_index->num_entries != 0); - md_index->entries = - H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, md_index->entries); + md_index->entries = H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t, md_index->entries); } FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__vfd_swmr_index_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_get_tick_and_idx() * @@ -1478,50 +1408,44 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t reload_hdr_and_index, - uint64_t *tick_ptr, uint32_t *num_entries_ptr, - H5FD_vfd_swmr_idx_entry_t index[]) +H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t reload_hdr_and_index, uint64_t *tick_ptr, + uint32_t *num_entries_ptr, H5FD_vfd_swmr_idx_entry_t index[]) { - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ + herr_t ret_value = SUCCEED; /* Return value */ HDassert(index == NULL || num_entries_ptr != NULL); FUNC_ENTER_NOAPI(FAIL) /* Load and decode the header and index as indicated */ - if (reload_hdr_and_index && - H5FD__vfd_swmr_load_hdr_and_idx(file, FALSE) < 0) { - HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, - "unable to load/decode md header and index") + if (reload_hdr_and_index && H5FD__vfd_swmr_load_hdr_and_idx(file, FALSE) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "unable to load/decode md header and index") } /* Return tick_num */ - if(tick_ptr != NULL) + if (tick_ptr != NULL) *tick_ptr = file->md_header.tick_num; if (index != NULL) { if (*num_entries_ptr < file->md_index.num_entries) { - HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, - "not enough space to copy index"); + HGOTO_ERROR(H5E_VFL, H5E_CANTLOAD, FAIL, "not enough space to copy index"); } HDmemcpy(index, file->md_index.entries, - (file->md_index.num_entries * - sizeof(file->md_index.entries[0]))); + (file->md_index.num_entries * sizeof(file->md_index.entries[0]))); } - if(num_entries_ptr != NULL) + if (num_entries_ptr != NULL) *num_entries_ptr = file->md_index.num_entries; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD_vfd_swmr_get_tick_and_idx() */ +} /* H5FD_vfd_swmr_get_tick_and_idx() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_dump_status * @@ -1536,43 +1460,38 @@ done: void H5FD_vfd_swmr_dump_status(H5FD_t *_file, uint64_t page) { - hbool_t in_index = FALSE; - int i = 0; - uint32_t num_entries; + hbool_t in_index = FALSE; + int i = 0; + uint32_t num_entries; H5FD_vfd_swmr_idx_entry_t *index; - H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ + H5FD_vfd_swmr_t * file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(file); - index = file->md_index.entries; - num_entries = file->md_index.num_entries; + index = file->md_index.entries; + num_entries = file->md_index.num_entries; - while ( ( ! in_index ) && ( i < (int)num_entries ) ) { + while ((!in_index) && (i < (int)num_entries)) { - if ( index[i].hdf5_page_offset == page ) { + if (index[i].hdf5_page_offset == page) { in_index = TRUE; } - HDassert( ( i == 0 ) || - ( index[i-1].hdf5_page_offset < index[i].hdf5_page_offset ) ); + HDassert((i == 0) || (index[i - 1].hdf5_page_offset < index[i].hdf5_page_offset)); i++; } - HDfprintf(stderr, - "fd: tick = %" PRIu64 ", index_len = %" PRIu32 ", page %" PRIu64 - " in index = %s.\n", - file->md_index.tick_num, num_entries, page, - in_index ? "true" : "false"); + HDfprintf(stderr, "fd: tick = %" PRIu64 ", index_len = %" PRIu32 ", page %" PRIu64 " in index = %s.\n", + file->md_index.tick_num, num_entries, page, in_index ? "true" : "false"); FUNC_LEAVE_NOAPI_VOID -} /* H5FD_vfd_swmr_dump_status() */ +} /* H5FD_vfd_swmr_dump_status() */ - /*------------------------------------------------------------------------- * Function: H5FD_vfd_swmr_set_pb_configured * @@ -1606,7 +1525,7 @@ H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file) FUNC_LEAVE_NOAPI_VOID -} /* H5FD_vfd_swmr_set_pb_configured() */ +} /* H5FD_vfd_swmr_set_pb_configured() */ /* In the histogram of ticks spent in API calls, increase the bucket * for `elapsed` ticks by one. diff --git a/src/H5FDvfd_swmr.h b/src/H5FDvfd_swmr.h index 7d3b966..3572194 100644 --- a/src/H5FDvfd_swmr.h +++ b/src/H5FDvfd_swmr.h @@ -21,13 +21,13 @@ #include "H5public.h" /* uint64_t *ahem* */ #include "H5Ipublic.h" /* hid_t */ -#define H5FD_VFD_SWMR (H5FD_vfd_swmr_init()) +#define H5FD_VFD_SWMR (H5FD_vfd_swmr_init()) #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_vfd_swmr_init(void); +H5_DLL hid_t H5FD_vfd_swmr_init(void); H5_DLL herr_t H5Pset_fapl_vfd_swmr(hid_t fapl_id); #ifdef __cplusplus diff --git a/src/H5FDvfd_swmr_instr.c b/src/H5FDvfd_swmr_instr.c index da62351..9f28557 100644 --- a/src/H5FDvfd_swmr_instr.c +++ b/src/H5FDvfd_swmr_instr.c @@ -10,7 +10,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5private.h" /* H5_ATTR_UNUSED */ +#include "H5private.h" /* H5_ATTR_UNUSED */ #include "H5Fpublic.h" #include "H5FDvfd_swmr.h" @@ -29,7 +29,7 @@ * vfd_swmr_writer_may_increase_tick_to() should * block until the reader is finished using the shadow-file content * from ticks `tick_num - max_lag` and before, returning `true`. - * If `false`, then + * If `false`, then * vfd_swmr_writer_may_increase_tick_to() immediately return `true` if * the new tick number does permissible, otherwise `false`. * @@ -46,8 +46,7 @@ * rate without outrunning the reader. */ bool -vfd_swmr_writer_may_increase_tick_to(uint64_t H5_ATTR_UNUSED tick_num, - bool H5_ATTR_UNUSED wait_for_reader) +vfd_swmr_writer_may_increase_tick_to(uint64_t H5_ATTR_UNUSED tick_num, bool H5_ATTR_UNUSED wait_for_reader) { return true; } diff --git a/src/H5FDvfd_swmr_private.h b/src/H5FDvfd_swmr_private.h index da10f94..1925682 100644 --- a/src/H5FDvfd_swmr_private.h +++ b/src/H5FDvfd_swmr_private.h @@ -12,20 +12,20 @@ #ifndef H5FDvfd_swmr_private_H #define H5FDvfd_swmr_private_H -#include "H5queue.h" /* for TAILQ_* */ +#include "H5queue.h" /* for TAILQ_* */ /* Forward declaration */ struct H5F_t; struct H5F_shared_t; struct H5FD_vfd_swmr_idx_entry_t; -/* +/* * struct eot_queue_entry_t - * + * * This is the structure for an entry on the end-of-tick queue (EOT queue) of files * opened in either VFD SWMR write or VFD SWMR read mode. This queue is maintained * in increasing end of tick time order. - * The structure contains all information required to determine whether the end + * The structure contains all information required to determine whether the end * of tick has arrived for the specified file, and to initiate end of tick processing * if it has. * @@ -33,10 +33,10 @@ struct H5FD_vfd_swmr_idx_entry_t; * * vfd_swmr_file: Pointer to the instance of H5F_file_t containing the shared * fields of the associated file that has been opened in VFD SWMR mode - * NOTE: for the time being use H5F_t instead of H5F_file_t + * NOTE: for the time being use H5F_t instead of H5F_file_t * - * vfd_swmr_writer: Boolean flag that is set to TRUE if the associated file - * has been opened in VFD SWMR writer mode, and FALSE if it has been + * vfd_swmr_writer: Boolean flag that is set to TRUE if the associated file + * has been opened in VFD SWMR writer mode, and FALSE if it has been * opened in VFD SWMR reader mode. * * tick_num: Number of the current tick of the target file. @@ -49,10 +49,10 @@ struct H5FD_vfd_swmr_idx_entry_t; * `end_of_tick`. */ typedef struct eot_queue_entry { - hbool_t vfd_swmr_writer; - uint64_t tick_num; + hbool_t vfd_swmr_writer; + uint64_t tick_num; struct timespec end_of_tick; - struct H5F_t *vfd_swmr_file; /* NOTE: for the time being use H5F_t instead H5F_shared_t */ + struct H5F_t * vfd_swmr_file; /* NOTE: for the time being use H5F_t instead H5F_shared_t */ TAILQ_ENTRY(eot_queue_entry) link; } eot_queue_entry_t; @@ -69,19 +69,18 @@ H5_DLLVAR eot_queue_t eot_queue_g; H5_DLL herr_t H5F_vfd_swmr_init(struct H5F_t *f, hbool_t file_create); H5_DLL herr_t H5F_vfd_swmr_close_or_flush(struct H5F_t *f, hbool_t closing); -H5_DLL herr_t H5F_update_vfd_swmr_metadata_file(struct H5F_t *f, - uint32_t index_len, struct H5FD_vfd_swmr_idx_entry_t *index); -H5_DLL herr_t H5F_vfd_swmr_writer__delay_write(struct H5F_shared_t *, uint64_t, - uint64_t *); +H5_DLL herr_t H5F_update_vfd_swmr_metadata_file(struct H5F_t *f, uint32_t index_len, + struct H5FD_vfd_swmr_idx_entry_t *index); +H5_DLL herr_t H5F_vfd_swmr_writer__delay_write(struct H5F_shared_t *, uint64_t, uint64_t *); H5_DLL herr_t H5F_vfd_swmr_writer__prep_for_flush_or_close(struct H5F_t *f); -herr_t H5F_vfd_swmr_process_eot_queue(hbool_t); +herr_t H5F_vfd_swmr_process_eot_queue(hbool_t); H5_DLL herr_t H5F_vfd_swmr_writer_end_of_tick(struct H5F_t *f, hbool_t); H5_DLL herr_t H5F_vfd_swmr_writer__dump_index(struct H5F_shared_t *); H5_DLL herr_t H5F_vfd_swmr_reader_end_of_tick(struct H5F_t *f, hbool_t); H5_DLL herr_t H5F_vfd_swmr_remove_entry_eot(struct H5F_t *f); H5_DLL herr_t H5F_vfd_swmr_insert_entry_eot(struct H5F_t *f); -H5_DLL void H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *); +H5_DLL void H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *); H5_DLL herr_t H5F_dump_eot_queue(void); #endif /* H5FDvfd_swmr_private_H */ diff --git a/src/H5FDwindows.c b/src/H5FDwindows.c index 76c4f18..a5b98f0 100644 --- a/src/H5FDwindows.c +++ b/src/H5FDwindows.c @@ -11,20 +11,19 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDwindows.h" /* Windows file driver */ -#include "H5FDsec2.h" /* Windows file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDwindows.h" /* Windows file driver */ +#include "H5FDsec2.h" /* Windows file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_WINDOWS - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_windows * @@ -48,13 +47,13 @@ herr_t H5Pset_fapl_windows(hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", fapl_id); - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value = H5P_set_driver(plist, H5FD_WINDOWS, NULL); @@ -64,4 +63,3 @@ done: } /* end H5Pset_fapl_windows() */ #endif /* H5_HAVE_WINDOWS */ - diff --git a/src/H5FDwindows.h b/src/H5FDwindows.h index 5cf68a1..77521b3 100644 --- a/src/H5FDwindows.h +++ b/src/H5FDwindows.h @@ -21,7 +21,7 @@ #ifndef H5FDwindows_H #define H5FDwindows_H -#define H5FD_WINDOWS (H5FD_sec2_init()) +#define H5FD_WINDOWS (H5FD_sec2_init()) #ifdef __cplusplus extern "C" { @@ -34,4 +34,3 @@ H5_DLL herr_t H5Pset_fapl_windows(hid_t fapl_id); #endif /* __cplusplus */ #endif /* H5FDwindows_H */ - diff --git a/src/H5FL.c b/src/H5FL.c index 66d27fb..4f71bc0 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -25,15 +25,14 @@ * move frequently accessed free lists to the head of the queue. */ -#include "H5FLmodule.h" /* This source code file is part of the H5FL module */ - +#include "H5FLmodule.h" /* This source code file is part of the H5FL module */ /* #define H5FL_DEBUG */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ /* * Private type definitions @@ -43,111 +42,112 @@ Default limits on how much memory can accumulate on each free list before it is garbage collected. */ -static size_t H5FL_reg_glb_mem_lim=1*1024*1024; /* Default to 1MB limit on all regular free lists */ -static size_t H5FL_reg_lst_mem_lim=1*65536; /* Default to 64KB limit on each regular free list */ -static size_t H5FL_arr_glb_mem_lim=4*1024*1024; /* Default to 4MB limit on all array free lists */ -static size_t H5FL_arr_lst_mem_lim=4*65536; /* Default to 256KB limit on each array free list */ -static size_t H5FL_blk_glb_mem_lim=16*1024*1024; /* Default to 16MB limit on all block free lists */ -static size_t H5FL_blk_lst_mem_lim=1024*1024; /* Default to 1024KB (1MB) limit on each block free list */ -static size_t H5FL_fac_glb_mem_lim=16*1024*1024; /* Default to 16MB limit on all factory free lists */ -static size_t H5FL_fac_lst_mem_lim=1024*1024; /* Default to 1024KB (1MB) limit on each factory free list */ +static size_t H5FL_reg_glb_mem_lim = 1 * 1024 * 1024; /* Default to 1MB limit on all regular free lists */ +static size_t H5FL_reg_lst_mem_lim = 1 * 65536; /* Default to 64KB limit on each regular free list */ +static size_t H5FL_arr_glb_mem_lim = 4 * 1024 * 1024; /* Default to 4MB limit on all array free lists */ +static size_t H5FL_arr_lst_mem_lim = 4 * 65536; /* Default to 256KB limit on each array free list */ +static size_t H5FL_blk_glb_mem_lim = 16 * 1024 * 1024; /* Default to 16MB limit on all block free lists */ +static size_t H5FL_blk_lst_mem_lim = 1024 * 1024; /* Default to 1024KB (1MB) limit on each block free list */ +static size_t H5FL_fac_glb_mem_lim = 16 * 1024 * 1024; /* Default to 16MB limit on all factory free lists */ +static size_t H5FL_fac_lst_mem_lim = + 1024 * 1024; /* Default to 1024KB (1MB) limit on each factory free list */ /* A garbage collection node for regular free lists */ typedef struct H5FL_reg_gc_node_t { - H5FL_reg_head_t *list; /* Pointer to the head of the list to garbage collect */ - struct H5FL_reg_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ + H5FL_reg_head_t * list; /* Pointer to the head of the list to garbage collect */ + struct H5FL_reg_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_reg_gc_node_t; /* The garbage collection head for regular free lists */ typedef struct H5FL_reg_gc_list_t { - size_t mem_freed; /* Amount of free memory on list */ - struct H5FL_reg_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_reg_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_reg_gc_list_t; /* The head of the list of things to garbage collect */ -static H5FL_reg_gc_list_t H5FL_reg_gc_head={0,NULL}; +static H5FL_reg_gc_list_t H5FL_reg_gc_head = {0, NULL}; /* A garbage collection node for array free lists */ typedef struct H5FL_gc_arr_node_t { - H5FL_arr_head_t *list; /* Pointer to the head of the list to garbage collect */ - struct H5FL_gc_arr_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ + H5FL_arr_head_t * list; /* Pointer to the head of the list to garbage collect */ + struct H5FL_gc_arr_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_gc_arr_node_t; /* The garbage collection head for array free lists */ typedef struct H5FL_gc_arr_list_t { - size_t mem_freed; /* Amount of free memory on list */ - struct H5FL_gc_arr_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_gc_arr_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_gc_arr_list_t; /* The head of the list of array things to garbage collect */ -static H5FL_gc_arr_list_t H5FL_arr_gc_head={0,NULL}; +static H5FL_gc_arr_list_t H5FL_arr_gc_head = {0, NULL}; /* A garbage collection node for blocks */ typedef struct H5FL_blk_gc_node_t { - H5FL_blk_head_t *pq; /* Pointer to the head of the PQ to garbage collect */ - struct H5FL_blk_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ + H5FL_blk_head_t * pq; /* Pointer to the head of the PQ to garbage collect */ + struct H5FL_blk_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_blk_gc_node_t; /* The garbage collection head for blocks */ typedef struct H5FL_blk_gc_list_t { - size_t mem_freed; /* Amount of free memory on list */ - struct H5FL_blk_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_blk_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_blk_gc_list_t; /* The head of the list of PQs to garbage collect */ -static H5FL_blk_gc_list_t H5FL_blk_gc_head={0,NULL}; +static H5FL_blk_gc_list_t H5FL_blk_gc_head = {0, NULL}; /* A garbage collection node for factory free lists */ struct H5FL_fac_gc_node_t { - H5FL_fac_head_t *list; /* Pointer to the head of the list to garbage collect */ - struct H5FL_fac_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ + H5FL_fac_head_t * list; /* Pointer to the head of the list to garbage collect */ + struct H5FL_fac_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ }; /* The garbage collection head for factory free lists */ typedef struct H5FL_fac_gc_list_t { - size_t mem_freed; /* Amount of free memory on list */ - struct H5FL_fac_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_fac_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_fac_gc_list_t; /* Data structure to store each block in factory free list */ struct H5FL_fac_node_t { - struct H5FL_fac_node_t *next; /* Pointer to next block in free list */ + struct H5FL_fac_node_t *next; /* Pointer to next block in free list */ }; /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; /* The head of the list of factory things to garbage collect */ -static H5FL_fac_gc_list_t H5FL_fac_gc_head={0,NULL}; +static H5FL_fac_gc_list_t H5FL_fac_gc_head = {0, NULL}; #ifdef H5FL_TRACK /* Extra headers needed */ -#include "H5CSprivate.h" /* Function stack */ +#include "H5CSprivate.h" /* Function stack */ /* Head of "outstanding allocations" list */ static H5FL_track_t *H5FL_out_head_g = NULL; #endif /* H5FL_TRACK */ /* Forward declarations of local static functions */ -static void * H5FL__malloc(size_t mem_size); -static herr_t H5FL__reg_init(H5FL_reg_head_t *head); -static herr_t H5FL__reg_gc(void); -static herr_t H5FL__reg_gc_list(H5FL_reg_head_t *head); -static int H5FL__reg_term(void); +static void * H5FL__malloc(size_t mem_size); +static herr_t H5FL__reg_init(H5FL_reg_head_t *head); +static herr_t H5FL__reg_gc(void); +static herr_t H5FL__reg_gc_list(H5FL_reg_head_t *head); +static int H5FL__reg_term(void); static H5FL_blk_node_t *H5FL__blk_find_list(H5FL_blk_node_t **head, size_t size); static H5FL_blk_node_t *H5FL__blk_create_list(H5FL_blk_node_t **head, size_t size); -static herr_t H5FL__blk_init(H5FL_blk_head_t *head); -static herr_t H5FL__blk_gc_list(H5FL_blk_head_t *head); -static herr_t H5FL__blk_gc(void); -static int H5FL__blk_term(void); -static herr_t H5FL__arr_init(H5FL_arr_head_t *head); -static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head); -static herr_t H5FL__arr_gc(void); -static int H5FL__arr_term(void); -static herr_t H5FL__fac_gc_list(H5FL_fac_head_t *head); -static herr_t H5FL__fac_gc(void); -static int H5FL__fac_term_all(void); +static herr_t H5FL__blk_init(H5FL_blk_head_t *head); +static herr_t H5FL__blk_gc_list(H5FL_blk_head_t *head); +static herr_t H5FL__blk_gc(void); +static int H5FL__blk_term(void); +static herr_t H5FL__arr_init(H5FL_arr_head_t *head); +static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head); +static herr_t H5FL__arr_gc(void); +static int H5FL__arr_term(void); +static herr_t H5FL__fac_gc_list(H5FL_fac_head_t *head); +static herr_t H5FL__fac_gc(void); +static int H5FL__fac_term_all(void); /* Declare a free list to manage the H5FL_blk_node_t struct */ H5FL_DEFINE(H5FL_blk_node_t); @@ -158,7 +158,6 @@ H5FL_DEFINE(H5FL_fac_gc_node_t); /* Declare a free list to manage the H5FL_fac_head_t struct */ H5FL_DEFINE(H5FL_fac_head_t); - /*-------------------------------------------------------------------------- NAME H5FL_term_package @@ -169,7 +168,7 @@ H5FL_DEFINE(H5FL_fac_head_t); RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -181,11 +180,11 @@ H5FL_DEFINE(H5FL_fac_head_t); int H5FL_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Garbage collect any nodes on the free lists */ (void)H5FL_garbage_coll(); @@ -196,32 +195,32 @@ H5FL_term_package(void) n += H5FL__blk_term(); /* Mark interface closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ #ifdef H5FL_TRACK /* If we haven't freed all the allocated memory, dump out the list now */ - if(n > 0 && H5FL_out_head_g) { + if (n > 0 && H5FL_out_head_g) { H5FL_track_t *trk = H5FL_out_head_g; /* Dump information about all the outstanding allocations */ - while(trk != NULL) { + while (trk != NULL) { /* Print information about the outstanding block */ - HDfprintf(stderr,"%s: Outstanding allocation:\n", FUNC); - HDfprintf(stderr,"\tPtr: %p, File: %s, Function: %s, Line: %d\n", (((unsigned char *)trk) + sizeof(H5FL_track_t)), trk->file, trk->func, trk->line); + HDfprintf(stderr, "%s: Outstanding allocation:\n", FUNC); + HDfprintf(stderr, "\tPtr: %p, File: %s, Function: %s, Line: %d\n", + (((unsigned char *)trk) + sizeof(H5FL_track_t)), trk->file, trk->func, trk->line); H5CS_print_stack(trk->stack, stderr); /* Advance to next node */ trk = trk->next; } /* end while */ - } /* end if */ -#endif /* H5FL_TRACK */ + } /* end if */ +#endif /* H5FL_TRACK */ FUNC_LEAVE_NOAPI(n) } /* end H5FL_term_package() */ - /*------------------------------------------------------------------------- * Function: H5FL__malloc * @@ -239,26 +238,25 @@ H5FL_term_package(void) static void * H5FL__malloc(size_t mem_size) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Attempt to allocate the memory requested */ - if(NULL==(ret_value=H5MM_malloc(mem_size))) { + if (NULL == (ret_value = H5MM_malloc(mem_size))) { /* If we can't allocate the memory now, try garbage collecting first */ - if(H5FL_garbage_coll()<0) + if (H5FL_garbage_coll() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during allocation") /* Now try allocating the memory again */ - if(NULL==(ret_value=H5MM_malloc(mem_size))) + if (NULL == (ret_value = H5MM_malloc(mem_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__malloc() */ +} /* end H5FL__malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__reg_init * @@ -276,30 +274,30 @@ done: static herr_t H5FL__reg_init(H5FL_reg_head_t *head) { - H5FL_reg_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ - herr_t ret_value=SUCCEED; /* return value*/ + H5FL_reg_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Allocate a new garbage collection node */ - if(NULL == (new_node = (H5FL_reg_gc_node_t *)H5MM_malloc(sizeof(H5FL_reg_gc_node_t)))) + if (NULL == (new_node = (H5FL_reg_gc_node_t *)H5MM_malloc(sizeof(H5FL_reg_gc_node_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->list = head; /* Link in to the garbage collection list */ - new_node->next=H5FL_reg_gc_head.first; - H5FL_reg_gc_head.first=new_node; + new_node->next = H5FL_reg_gc_head.first; + H5FL_reg_gc_head.first = new_node; /* Indicate that the free list is initialized */ head->init = TRUE; /* Make certain that the space allocated is large enough to store a free list pointer (eventually) */ - if(head->sizesize=sizeof(H5FL_reg_node_t); + if (head->size < sizeof(H5FL_reg_node_t)) + head->size = sizeof(H5FL_reg_node_t); - /* Make certain there's room for tracking information, if any */ + /* Make certain there's room for tracking information, if any */ #ifdef H5FL_TRACK head->size += sizeof(H5FL_track_t); #endif /* H5FL_TRACK */ @@ -308,7 +306,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL__reg_init() */ - /*------------------------------------------------------------------------- * Function: H5FL_reg_free * @@ -324,7 +321,7 @@ done: void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj) { - void *ret_value=NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_reg_malloc/calloc * -NAF */ @@ -344,54 +341,53 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) trk->func = H5MM_xfree(trk->func); /* Remove from "outstanding allocations" list */ - if(trk == H5FL_out_head_g) { + if (trk == H5FL_out_head_g) { H5FL_out_head_g = H5FL_out_head_g->next; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = NULL; } /* end if */ else { trk->prev->next = trk->next; - if(trk->next) + if (trk->next) trk->next->prev = trk->prev; } /* end else */ } #endif /* H5FL_TRACK */ #ifdef H5FL_DEBUG - HDmemset(obj,255,head->size); + HDmemset(obj, 255, head->size); #endif /* H5FL_DEBUG */ /* Make certain that the free list is initialized */ HDassert(head->init); /* Link into the free list */ - ((H5FL_reg_node_t *)obj)->next=head->list; + ((H5FL_reg_node_t *)obj)->next = head->list; /* Point free list at the node freed */ - head->list=(H5FL_reg_node_t *)obj; + head->list = (H5FL_reg_node_t *)obj; /* Increment the number of blocks on free list */ head->onlist++; /* Increment the amount of "regular" freed memory globally */ - H5FL_reg_gc_head.mem_freed+=head->size; + H5FL_reg_gc_head.mem_freed += head->size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->onlist * head->size > H5FL_reg_lst_mem_lim) - if(H5FL__reg_gc_list(head) < 0) + if (head->onlist * head->size > H5FL_reg_lst_mem_lim) + if (H5FL__reg_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on regular free lists */ - if(H5FL_reg_gc_head.mem_freed>H5FL_reg_glb_mem_lim) - if(H5FL__reg_gc() < 0) + if (H5FL_reg_gc_head.mem_freed > H5FL_reg_glb_mem_lim) + if (H5FL__reg_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_reg_free() */ +} /* end H5FL_reg_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_reg_malloc * @@ -408,7 +404,7 @@ done: void * H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to object to return */ FUNC_ENTER_NOAPI(NULL) @@ -416,27 +412,27 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) HDassert(head); /* Make certain the list is initialized first */ - if(!head->init) - if(H5FL__reg_init(head) < 0) + if (!head->init) + if (H5FL__reg_init(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'regular' blocks") /* Check for nodes available on the free list first */ - if(head->list!=NULL) { + if (head->list != NULL) { /* Get a pointer to the block on the free list */ - ret_value=(void *)(head->list); + ret_value = (void *)(head->list); /* Remove node from free list */ - head->list=head->list->next; + head->list = head->list->next; /* Decrement the number of blocks & memory on free list */ head->onlist--; /* Decrement the amount of global "regular" free list memory in use */ - H5FL_reg_gc_head.mem_freed-=(head->size); + H5FL_reg_gc_head.mem_freed -= (head->size); } /* end if */ /* Otherwise allocate a node */ else { - if(NULL == (ret_value = H5FL__malloc(head->size))) + if (NULL == (ret_value = H5FL__malloc(head->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks allocated in list */ @@ -454,7 +450,7 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) /* Add to "outstanding allocations" list */ ((H5FL_track_t *)ret_value)->prev = NULL; ((H5FL_track_t *)ret_value)->next = H5FL_out_head_g; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = (H5FL_track_t *)ret_value; H5FL_out_head_g = (H5FL_track_t *)ret_value; @@ -464,9 +460,8 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_reg_malloc() */ +} /* end H5FL_reg_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_reg_calloc * @@ -483,7 +478,7 @@ done: void * H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to object to return */ FUNC_ENTER_NOAPI(NULL) @@ -491,18 +486,17 @@ H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) HDassert(head); /* Allocate the block */ - if (NULL==(ret_value = H5FL_reg_malloc(head H5FL_TRACK_INFO_INT))) + if (NULL == (ret_value = H5FL_reg_malloc(head H5FL_TRACK_INFO_INT))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ /* (Accommodate tracking information, if present) */ - HDmemset(ret_value,0,head->size - H5FL_TRACK_SIZE); + HDmemset(ret_value, 0, head->size - H5FL_TRACK_SIZE); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_reg_calloc() */ +} /* end H5FL_reg_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__reg_gc_list * @@ -525,8 +519,8 @@ H5FL__reg_gc_list(H5FL_reg_head_t *head) /* For each free list being garbage collected, walk through the nodes and free them */ free_list = head->list; - while(free_list != NULL) { - H5FL_reg_node_t *tmp; /* Temporary node pointer */ + while (free_list != NULL) { + H5FL_reg_node_t *tmp; /* Temporary node pointer */ /* Get the pointer to the next node */ tmp = free_list->next; @@ -545,13 +539,12 @@ H5FL__reg_gc_list(H5FL_reg_head_t *head) H5FL_reg_gc_head.mem_freed -= (head->onlist * head->size); /* Indicate no free nodes on the free list */ - head->list = NULL; + head->list = NULL; head->onlist = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL__reg_gc_list() */ +} /* end H5FL__reg_gc_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__reg_gc * @@ -568,16 +561,16 @@ H5FL__reg_gc_list(H5FL_reg_head_t *head) static herr_t H5FL__reg_gc(void) { - H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value = SUCCEED; /* return value*/ + H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Walk through all the free lists, free()'ing the nodes */ gc_node = H5FL_reg_gc_head.first; - while(gc_node != NULL) { + while (gc_node != NULL) { /* Release the free nodes on the list */ - if(H5FL__reg_gc_list(gc_node->list) < 0) + if (H5FL__reg_gc_list(gc_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ @@ -589,9 +582,8 @@ H5FL__reg_gc(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__reg_gc() */ +} /* end H5FL__reg_gc() */ - /*-------------------------------------------------------------------------- NAME H5FL_reg_term @@ -602,7 +594,7 @@ done: RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -620,26 +612,27 @@ done: static int H5FL__reg_term(void) { - H5FL_reg_gc_node_t *left; /* pointer to garbage collection lists with work left */ + H5FL_reg_gc_node_t *left; /* pointer to garbage collection lists with work left */ FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left = NULL; - while(H5FL_reg_gc_head.first != NULL) { - H5FL_reg_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + while (H5FL_reg_gc_head.first != NULL) { + H5FL_reg_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ /* Get a copy of the next node */ tmp = H5FL_reg_gc_head.first->next; #ifdef H5FL_DEBUG -HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.first->list->name, (int)H5FL_reg_gc_head.first->list->allocated); + HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.first->list->name, + (int)H5FL_reg_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ /* Check if the list has allocations outstanding */ - if(H5FL_reg_gc_head.first->list->allocated > 0) { + if (H5FL_reg_gc_head.first->list->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ H5FL_reg_gc_head.first->next = left; - left = H5FL_reg_gc_head.first; + left = H5FL_reg_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { @@ -657,9 +650,8 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.f H5FL_reg_gc_head.first = left; FUNC_LEAVE_NOAPI(H5FL_reg_gc_head.first != NULL ? 1 : 0) -} /* end H5FL__reg_term() */ +} /* end H5FL__reg_term() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_find_list * @@ -680,47 +672,46 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.f static H5FL_blk_node_t * H5FL__blk_find_list(H5FL_blk_node_t **head, size_t size) { - H5FL_blk_node_t *temp = NULL; /* Temp. pointer to node in the native list */ + H5FL_blk_node_t *temp = NULL; /* Temp. pointer to node in the native list */ FUNC_ENTER_STATIC_NOERR /* Find the correct free list */ - temp=*head; + temp = *head; /* Check if the node is at the head of the list */ - if(temp && temp->size!=size) { - temp=temp->next; + if (temp && temp->size != size) { + temp = temp->next; - while(temp!=NULL) { + while (temp != NULL) { /* Check if we found the correct node */ - if(temp->size==size) { + if (temp->size == size) { /* Take the node found out of it's current position */ - if(temp->next==NULL) { - temp->prev->next=NULL; + if (temp->next == NULL) { + temp->prev->next = NULL; } /* end if */ else { - temp->prev->next=temp->next; - temp->next->prev=temp->prev; + temp->prev->next = temp->next; + temp->next->prev = temp->prev; } /* end else */ /* Move the found node to the head of the list */ - temp->prev=NULL; - temp->next=*head; - (*head)->prev=temp; - *head=temp; + temp->prev = NULL; + temp->next = *head; + (*head)->prev = temp; + *head = temp; /* Get out */ break; } /* end if */ - temp=temp->next; + temp = temp->next; } /* end while */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(temp) } /* end H5FL__blk_find_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_create_list * @@ -739,31 +730,30 @@ H5FL__blk_find_list(H5FL_blk_node_t **head, size_t size) static H5FL_blk_node_t * H5FL__blk_create_list(H5FL_blk_node_t **head, size_t size) { - H5FL_blk_node_t *ret_value = NULL; /* Return value */ + H5FL_blk_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate room for the new free list node */ - if(NULL == (ret_value = H5FL_CALLOC(H5FL_blk_node_t))) + if (NULL == (ret_value = H5FL_CALLOC(H5FL_blk_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed for chunk info") /* Set the correct values for the new free list */ ret_value->size = size; /* Attach to head of priority queue */ - if(NULL == *head) + if (NULL == *head) *head = ret_value; else { ret_value->next = *head; - (*head)->prev = ret_value; - *head = ret_value; + (*head)->prev = ret_value; + *head = ret_value; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL__blk_create_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_init * @@ -781,30 +771,29 @@ done: static herr_t H5FL__blk_init(H5FL_blk_head_t *head) { - H5FL_blk_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ - herr_t ret_value=SUCCEED; /* return value*/ + H5FL_blk_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Allocate a new garbage collection node */ - if(NULL == (new_node = (H5FL_blk_gc_node_t *)H5MM_malloc(sizeof(H5FL_blk_gc_node_t)))) + if (NULL == (new_node = (H5FL_blk_gc_node_t *)H5MM_malloc(sizeof(H5FL_blk_gc_node_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->pq = head; /* Link in to the garbage collection list */ - new_node->next=H5FL_blk_gc_head.first; - H5FL_blk_gc_head.first=new_node; + new_node->next = H5FL_blk_gc_head.first; + H5FL_blk_gc_head.first = new_node; /* Indicate that the PQ is initialized */ head->init = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__blk_init() */ +} /* end H5FL__blk_init() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_free_block_avail * @@ -822,8 +811,8 @@ done: htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) { - H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ - htri_t ret_value = FAIL; /* Return value */ + H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -832,7 +821,7 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) /* check if there is a free list for blocks of this size */ /* and if there are any blocks available on the list */ - if((free_list = H5FL__blk_find_list(&(head->head), size)) != NULL && free_list->list != NULL) + if ((free_list = H5FL__blk_find_list(&(head->head), size)) != NULL && free_list->list != NULL) ret_value = TRUE; else ret_value = FALSE; @@ -840,7 +829,6 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_free_block_avail() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_malloc * @@ -860,9 +848,9 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) { - H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ - H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ - void *ret_value = NULL; /* Pointer to the block to return to the user */ + H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ + H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ + void * ret_value = NULL; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(NULL) @@ -871,35 +859,36 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) HDassert(size); /* Make certain the list is initialized first */ - if(!head->init) - if(H5FL__blk_init(head) < 0) + if (!head->init) + if (H5FL__blk_init(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'block' list") /* check if there is a free list for blocks of this size */ /* and if there are any blocks available on the list */ - if(NULL != (free_list = H5FL__blk_find_list(&(head->head), size)) && NULL != free_list->list) { + if (NULL != (free_list = H5FL__blk_find_list(&(head->head), size)) && NULL != free_list->list) { /* Remove the first node from the free list */ - temp=free_list->list; - free_list->list=free_list->list->next; + temp = free_list->list; + free_list->list = free_list->list->next; /* Decrement the number of blocks & memory used on free list */ free_list->onlist--; head->onlist--; - head->list_mem-=size; + head->list_mem -= size; /* Decrement the amount of global "block" free list memory in use */ - H5FL_blk_gc_head.mem_freed-=size; + H5FL_blk_gc_head.mem_freed -= size; } /* end if */ /* No free list available, or there are no nodes on the list, allocate a new node to give to the user */ else { /* Check if there was no free list for native blocks of this size */ - if(NULL == free_list) + if (NULL == free_list) /* Create a new list node and insert it to the queue */ free_list = H5FL__blk_create_list(&(head->head), size); HDassert(free_list); /* Allocate new node, with room for the page info header and the actual page data */ - if(NULL == (temp = (H5FL_blk_list_t *)H5FL__malloc(sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE + size))) + if (NULL == + (temp = (H5FL_blk_list_t *)H5FL__malloc(sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE + size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk") /* Increment the number of blocks of this size */ @@ -910,10 +899,10 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) } /* end else */ /* Initialize the block allocated */ - temp->size=size; + temp->size = size; /* Set the return value to the block itself */ - ret_value=((char *)temp)+sizeof(H5FL_blk_list_t); + ret_value = ((char *)temp) + sizeof(H5FL_blk_list_t); #ifdef H5FL_TRACK /* Copy allocation location information */ @@ -926,7 +915,7 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) /* Add to "outstanding allocations" list */ ((H5FL_track_t *)ret_value)->prev = NULL; ((H5FL_track_t *)ret_value)->next = H5FL_out_head_g; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = (H5FL_track_t *)ret_value; H5FL_out_head_g = (H5FL_track_t *)ret_value; @@ -938,7 +927,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_calloc * @@ -959,7 +947,7 @@ done: void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return to the user */ + void *ret_value = NULL; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(NULL) @@ -968,17 +956,16 @@ H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) HDassert(size); /* Allocate the block */ - if (NULL==(ret_value = H5FL_blk_malloc(head,size H5FL_TRACK_INFO_INT))) + if (NULL == (ret_value = H5FL_blk_malloc(head, size H5FL_TRACK_INFO_INT))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear the block to zeros */ - HDmemset(ret_value,0,size); + HDmemset(ret_value, 0, size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_free * @@ -998,10 +985,10 @@ done: void * H5FL_blk_free(H5FL_blk_head_t *head, void *block) { - H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ - H5FL_blk_list_t *temp; /* Temp. ptr to the new free list node allocated */ - size_t free_size; /* Size of the block freed */ - void *ret_value=NULL; /* Return value */ + H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ + H5FL_blk_list_t *temp; /* Temp. ptr to the new free list node allocated */ + size_t free_size; /* Size of the block freed */ + void * ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_blk_malloc/calloc * -NAF */ @@ -1021,37 +1008,40 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) trk->func = H5MM_xfree(trk->func); /* Remove from "outstanding allocations" list */ - if(trk == H5FL_out_head_g) { + if (trk == H5FL_out_head_g) { H5FL_out_head_g = H5FL_out_head_g->next; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = NULL; } /* end if */ else { trk->prev->next = trk->next; - if(trk->next) + if (trk->next) trk->next->prev = trk->prev; } /* end else */ } #endif /* H5FL_TRACK */ /* Get the pointer to the native block info header in front of the native block to free */ - temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block - (sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + temp = (H5FL_blk_list_t *)(( + void *)((unsigned char *)block - + (sizeof(H5FL_blk_list_t) + + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Save the block's size for later */ - free_size=temp->size; + free_size = temp->size; #ifdef H5FL_DEBUG - HDmemset(temp,255,free_size + sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE); + HDmemset(temp, 255, free_size + sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE); #endif /* H5FL_DEBUG */ /* Check if there is a free list for native blocks of this size */ - if(NULL == (free_list = H5FL__blk_find_list(&(head->head), free_size))) + if (NULL == (free_list = H5FL__blk_find_list(&(head->head), free_size))) /* No free list available, create a new list node and insert it to the queue */ free_list = H5FL__blk_create_list(&(head->head), free_size); HDassert(free_list); /* Prepend the free'd native block to the front of the free list */ - temp->next = free_list->list; /* Note: Overwrites the size field in union */ + temp->next = free_list->list; /* Note: Overwrites the size field in union */ free_list->list = temp; /* Increment the number of blocks on free list */ @@ -1064,20 +1054,19 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->list_mem > H5FL_blk_lst_mem_lim) - if(H5FL__blk_gc_list(head) < 0) + if (head->list_mem > H5FL_blk_lst_mem_lim) + if (H5FL__blk_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on block free lists */ - if(H5FL_blk_gc_head.mem_freed > H5FL_blk_glb_mem_lim) - if(H5FL__blk_gc() < 0) + if (H5FL_blk_gc_head.mem_freed > H5FL_blk_glb_mem_lim) + if (H5FL__blk_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_realloc * @@ -1096,7 +1085,7 @@ done: void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_PARAMS) { - void *ret_value=NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1105,21 +1094,24 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ HDassert(new_size); /* Check if we are actually re-allocating a block */ - if(block!=NULL) { - H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ + if (block != NULL) { + H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ /* Get the pointer to the chunk info header in front of the chunk to free */ - temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block - (sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + temp = (H5FL_blk_list_t *)(( + void *)((unsigned char *)block - + (sizeof(H5FL_blk_list_t) + + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* check if we are actually changing the size of the buffer */ - if(new_size!=temp->size) { - size_t blk_size; /* Temporary block size */ + if (new_size != temp->size) { + size_t blk_size; /* Temporary block size */ - if((ret_value=H5FL_blk_malloc(head,new_size H5FL_TRACK_INFO_INT))==NULL) + if ((ret_value = H5FL_blk_malloc(head, new_size H5FL_TRACK_INFO_INT)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block") - blk_size=MIN(new_size,temp->size); - H5MM_memcpy(ret_value,block,blk_size); - H5FL_blk_free(head,block); + blk_size = MIN(new_size, temp->size); + H5MM_memcpy(ret_value, block, blk_size); + H5FL_blk_free(head, block); } /* end if */ else { #ifdef H5FL_TRACK @@ -1139,18 +1131,17 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ trk->line = call_line; } #endif /* H5FL_TRACK */ - ret_value=block; + ret_value = block; } /* end if */ - } /* end if */ + } /* end if */ /* Not re-allocating, just allocate a fresh block */ else - ret_value=H5FL_blk_malloc(head,new_size H5FL_TRACK_INFO_INT); + ret_value = H5FL_blk_malloc(head, new_size H5FL_TRACK_INFO_INT); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_realloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_gc_list * @@ -1167,23 +1158,23 @@ done: static herr_t H5FL__blk_gc_list(H5FL_blk_head_t *head) { - H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list page node */ + H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list page node */ FUNC_ENTER_STATIC_NOERR /* Loop through all the nodes in the block free list queue */ blk_head = head->head; - while(blk_head != NULL) { - H5FL_blk_node_t *blk_next; /* Temp. ptr to the next free list node */ - H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */ + while (blk_head != NULL) { + H5FL_blk_node_t *blk_next; /* Temp. ptr to the next free list node */ + H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */ /* Sanity check */ HDassert((blk_head->onlist && blk_head->list) || (0 == blk_head->onlist && NULL == blk_head->list)); /* Loop through all the blocks in the free list, freeing them */ list = blk_head->list; - while(list != NULL) { - H5FL_blk_list_t *next; /* Temp. ptr to the free list list node */ + while (list != NULL) { + H5FL_blk_list_t *next; /* Temp. ptr to the free list list node */ /* Get the pointer to the next node */ next = list->next; @@ -1206,20 +1197,20 @@ H5FL__blk_gc_list(H5FL_blk_head_t *head) H5FL_blk_gc_head.mem_freed -= (blk_head->onlist * blk_head->size); /* Indicate no free nodes on the free list */ - blk_head->list = NULL; + blk_head->list = NULL; blk_head->onlist = 0; /* Get pointer to next node */ blk_next = blk_head->next; /* Check for list completely unused now */ - if(0 == blk_head->allocated) { + if (0 == blk_head->allocated) { /* Patch this node out of the PQ */ - if(head->head == blk_head) + if (head->head == blk_head) head->head = blk_head->next; - if(blk_head->prev) + if (blk_head->prev) blk_head->prev->next = blk_head->next; - if(blk_head->next) + if (blk_head->next) blk_head->next->prev = blk_head->prev; /* Free the free list node */ @@ -1237,9 +1228,8 @@ H5FL__blk_gc_list(H5FL_blk_head_t *head) HDassert(0 == head->list_mem); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL__blk_gc_list() */ +} /* end H5FL__blk_gc_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_gc * @@ -1256,16 +1246,16 @@ H5FL__blk_gc_list(H5FL_blk_head_t *head) static herr_t H5FL__blk_gc(void) { - H5FL_blk_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value = SUCCEED; /* return value*/ + H5FL_blk_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Walk through all the free lists, free()'ing the nodes */ gc_node = H5FL_blk_gc_head.first; - while(gc_node != NULL) { + while (gc_node != NULL) { /* For each free list being garbage collected, walk through the nodes and free them */ - if(H5FL__blk_gc_list(gc_node->pq) < 0) + if (H5FL__blk_gc_list(gc_node->pq) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ @@ -1277,9 +1267,8 @@ H5FL__blk_gc(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__blk_gc() */ +} /* end H5FL__blk_gc() */ - /*-------------------------------------------------------------------------- NAME H5FL__blk_term @@ -1290,7 +1279,7 @@ done: RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -1302,26 +1291,27 @@ done: static int H5FL__blk_term(void) { - H5FL_blk_gc_node_t *left; /* pointer to garbage collection lists with work left */ + H5FL_blk_gc_node_t *left; /* pointer to garbage collection lists with work left */ FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left = NULL; - while(H5FL_blk_gc_head.first != NULL) { - H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + while (H5FL_blk_gc_head.first != NULL) { + H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ tmp = H5FL_blk_gc_head.first->next; #ifdef H5FL_DEBUG -HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.first->pq->name, (int)H5FL_blk_gc_head.first->pq->allocated); + HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.first->pq->name, + (int)H5FL_blk_gc_head.first->pq->allocated); #endif /* H5FL_DEBUG */ /* Check if the list has allocations outstanding */ - if(H5FL_blk_gc_head.first->pq->allocated > 0) { + if (H5FL_blk_gc_head.first->pq->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ H5FL_blk_gc_head.first->next = left; - left = H5FL_blk_gc_head.first; + left = H5FL_blk_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { @@ -1339,9 +1329,8 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.f H5FL_blk_gc_head.first = left; FUNC_LEAVE_NOAPI(H5FL_blk_gc_head.first != NULL ? 1 : 0) -} /* end H5FL__blk_term() */ +} /* end H5FL__blk_term() */ - /*------------------------------------------------------------------------- * Function: H5FL__arr_init * @@ -1359,29 +1348,30 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.f static herr_t H5FL__arr_init(H5FL_arr_head_t *head) { - H5FL_gc_arr_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ - size_t u; /* Local index variable */ - herr_t ret_value=SUCCEED; /* return value*/ + H5FL_gc_arr_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Allocate a new garbage collection node */ - if(NULL == (new_node = (H5FL_gc_arr_node_t *)H5MM_malloc(sizeof(H5FL_gc_arr_node_t)))) + if (NULL == (new_node = (H5FL_gc_arr_node_t *)H5MM_malloc(sizeof(H5FL_gc_arr_node_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->list = head; /* Link in to the garbage collection list */ - new_node->next=H5FL_arr_gc_head.first; - H5FL_arr_gc_head.first=new_node; + new_node->next = H5FL_arr_gc_head.first; + H5FL_arr_gc_head.first = new_node; /* Allocate room for the free lists */ - if(NULL == (head->list_arr = (H5FL_arr_node_t *)H5MM_calloc((size_t)head->maxelem * sizeof(H5FL_arr_node_t)))) + if (NULL == + (head->list_arr = (H5FL_arr_node_t *)H5MM_calloc((size_t)head->maxelem * sizeof(H5FL_arr_node_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the size of each array */ - for(u = 0; u < (size_t)head->maxelem; u++) + for (u = 0; u < (size_t)head->maxelem; u++) head->list_arr[u].size = head->base_size + (head->elem_size * u); /* Indicate that the free list is initialized */ @@ -1391,7 +1381,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL__arr_init() */ - /*------------------------------------------------------------------------- * Function: H5FL_arr_free * @@ -1408,10 +1397,10 @@ done: void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj) { - H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ - size_t mem_size; /* Size of memory being freed */ - size_t free_nelem; /* Number of elements in node being free'd */ - void *ret_value=NULL; /* Return value */ + H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ + size_t mem_size; /* Size of memory being freed */ + size_t free_nelem; /* Number of elements in node being free'd */ + void * ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_arr_malloc/calloc * -NAF */ @@ -1419,7 +1408,7 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) /* The H5MM_xfree code allows obj to null */ if (!obj) - HGOTO_DONE (NULL) + HGOTO_DONE(NULL) /* Double check parameters */ HDassert(head); @@ -1428,46 +1417,47 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) HDassert(head->init); /* Get the pointer to the info header in front of the block to free */ - temp = (H5FL_arr_list_t *)((void *)((unsigned char *)obj - sizeof(H5FL_arr_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + temp = (H5FL_arr_list_t *)(( + void *)((unsigned char *)obj - + sizeof(H5FL_arr_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Get the number of elements */ - free_nelem=temp->nelem; + free_nelem = temp->nelem; /* Double-check that there is enough room for arrays of this size */ - HDassert((int)free_nelem<=head->maxelem); + HDassert((int)free_nelem <= head->maxelem); /* Link into the free list */ - temp->next=head->list_arr[free_nelem].list; + temp->next = head->list_arr[free_nelem].list; /* Point free list at the node freed */ - head->list_arr[free_nelem].list=temp; + head->list_arr[free_nelem].list = temp; /* Get the size of arrays with this many elements */ - mem_size=head->list_arr[free_nelem].size; + mem_size = head->list_arr[free_nelem].size; /* Increment the number of blocks & memory used on free list */ head->list_arr[free_nelem].onlist++; - head->list_mem+=mem_size; + head->list_mem += mem_size; /* Increment the amount of "array" freed memory globally */ - H5FL_arr_gc_head.mem_freed+=mem_size; + H5FL_arr_gc_head.mem_freed += mem_size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->list_mem > H5FL_arr_lst_mem_lim) - if(H5FL__arr_gc_list(head) < 0) + if (head->list_mem > H5FL_arr_lst_mem_lim) + if (H5FL__arr_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on array free lists */ - if(H5FL_arr_gc_head.mem_freed > H5FL_arr_glb_mem_lim) - if(H5FL__arr_gc() < 0) + if (H5FL_arr_gc_head.mem_freed > H5FL_arr_glb_mem_lim) + if (H5FL__arr_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_free() */ +} /* end H5FL_arr_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_arr_malloc * @@ -1484,9 +1474,9 @@ done: void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) { - H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */ - size_t mem_size; /* Size of memory block being recycled */ - void *ret_value = NULL; /* Pointer to the block to return */ + H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */ + size_t mem_size; /* Size of memory block being recycled */ + void * ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1495,35 +1485,35 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) HDassert(elem); /* Make certain the list is initialized first */ - if(!head->init) - if(H5FL__arr_init(head) < 0) + if (!head->init) + if (H5FL__arr_init(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'array' blocks") /* Sanity check that the number of elements is supported */ - HDassert(elem<=(unsigned) head->maxelem); + HDassert(elem <= (unsigned)head->maxelem); /* Get the set of the memory block */ - mem_size=head->list_arr[elem].size; + mem_size = head->list_arr[elem].size; /* Check for nodes available on the free list first */ - if(head->list_arr[elem].list!=NULL) { + if (head->list_arr[elem].list != NULL) { /* Get a pointer to the block on the free list */ - new_obj=head->list_arr[elem].list; + new_obj = head->list_arr[elem].list; /* Remove node from free list */ - head->list_arr[elem].list=head->list_arr[elem].list->next; + head->list_arr[elem].list = head->list_arr[elem].list->next; /* Decrement the number of blocks & memory used on free list */ head->list_arr[elem].onlist--; - head->list_mem-=mem_size; + head->list_mem -= mem_size; /* Decrement the amount of global "array" free list memory in use */ - H5FL_arr_gc_head.mem_freed-=mem_size; + H5FL_arr_gc_head.mem_freed -= mem_size; } /* end if */ /* Otherwise allocate a node */ else { - if(NULL == (new_obj = (H5FL_arr_list_t *)H5FL__malloc(sizeof(H5FL_arr_list_t)+mem_size))) + if (NULL == (new_obj = (H5FL_arr_list_t *)H5FL__malloc(sizeof(H5FL_arr_list_t) + mem_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks of this size */ @@ -1534,16 +1524,15 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) } /* end else */ /* Initialize the new object */ - new_obj->nelem=elem; + new_obj->nelem = elem; /* Get a pointer to the new block */ - ret_value=((char *)new_obj)+sizeof(H5FL_arr_list_t); + ret_value = ((char *)new_obj) + sizeof(H5FL_arr_list_t); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_malloc() */ +} /* end H5FL_arr_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_arr_calloc * @@ -1560,7 +1549,7 @@ done: void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1569,7 +1558,7 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) HDassert(elem); /* Allocate the array */ - if(NULL == (ret_value = H5FL_arr_malloc(head, elem))) + if (NULL == (ret_value = H5FL_arr_malloc(head, elem))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ @@ -1577,9 +1566,8 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_calloc() */ +} /* end H5FL_arr_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_arr_realloc * @@ -1594,9 +1582,9 @@ done: *------------------------------------------------------------------------- */ void * -H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) +H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI_NOERR @@ -1605,20 +1593,22 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) HDassert(new_elem); /* Check if we are really allocating the object */ - if(obj == NULL) + if (obj == NULL) ret_value = H5FL_arr_malloc(head, new_elem); else { - H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ + H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ /* Sanity check that the number of elements is supported */ HDassert((int)new_elem <= head->maxelem); /* Get the pointer to the info header in front of the block to free */ - temp = (H5FL_arr_list_t *)((void *)((unsigned char *)obj - sizeof(H5FL_arr_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + temp = (H5FL_arr_list_t *)(( + void *)((unsigned char *)obj - + sizeof(H5FL_arr_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Check if the size is really changing */ - if(temp->nelem != new_elem) { - size_t blk_size; /* Size of block */ + if (temp->nelem != new_elem) { + size_t blk_size; /* Size of block */ /* Get the new array of objects */ ret_value = H5FL_arr_malloc(head, new_elem); @@ -1635,9 +1625,8 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) } /* end else */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_realloc() */ +} /* end H5FL_arr_realloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__arr_gc_list * @@ -1654,19 +1643,19 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head) { - unsigned u; /* Counter for array of free lists */ + unsigned u; /* Counter for array of free lists */ FUNC_ENTER_STATIC_NOERR /* Walk through the array of free lists */ - for(u = 0; u < (unsigned)head->maxelem; u++) { - if(head->list_arr[u].onlist > 0) { + for (u = 0; u < (unsigned)head->maxelem; u++) { + if (head->list_arr[u].onlist > 0) { H5FL_arr_list_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */ /* For each free list being garbage collected, walk through the nodes and free them */ arr_free_list = head->list_arr[u].list; - while(arr_free_list != NULL) { - H5FL_arr_list_t *tmp; /* Temporary node pointer */ + while (arr_free_list != NULL) { + H5FL_arr_list_t *tmp; /* Temporary node pointer */ /* Get the pointer to the next node */ tmp = arr_free_list->next; @@ -1689,18 +1678,17 @@ H5FL__arr_gc_list(H5FL_arr_head_t *head) H5FL_arr_gc_head.mem_freed -= (head->list_arr[u].onlist * head->list_arr[u].size); /* Indicate no free nodes on the free list */ - head->list_arr[u].list = NULL; + head->list_arr[u].list = NULL; head->list_arr[u].onlist = 0; } /* end if */ - } /* end for */ + } /* end for */ /* Double check that all the memory on this list is recycled */ HDassert(head->list_mem == 0); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL__arr_gc_list() */ +} /* end H5FL__arr_gc_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__arr_gc * @@ -1717,16 +1705,16 @@ H5FL__arr_gc_list(H5FL_arr_head_t *head) static herr_t H5FL__arr_gc(void) { - H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value = SUCCEED; /* return value*/ + H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Walk through all the free lists, free()'ing the nodes */ gc_arr_node = H5FL_arr_gc_head.first; - while(gc_arr_node != NULL) { + while (gc_arr_node != NULL) { /* Release the free nodes on the list */ - if(H5FL__arr_gc_list(gc_arr_node->list) < 0) + if (H5FL__arr_gc_list(gc_arr_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ @@ -1738,9 +1726,8 @@ H5FL__arr_gc(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__arr_gc() */ +} /* end H5FL__arr_gc() */ - /*-------------------------------------------------------------------------- NAME H5FL__arr_term @@ -1751,7 +1738,7 @@ done: RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -1763,25 +1750,26 @@ done: static int H5FL__arr_term(void) { - H5FL_gc_arr_node_t *left; /* pointer to garbage collection lists with work left */ + H5FL_gc_arr_node_t *left; /* pointer to garbage collection lists with work left */ FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left = NULL; - while(H5FL_arr_gc_head.first != NULL) { - H5FL_gc_arr_node_t *tmp; /* Temporary pointer to a garbage collection node */ + while (H5FL_arr_gc_head.first != NULL) { + H5FL_gc_arr_node_t *tmp; /* Temporary pointer to a garbage collection node */ tmp = H5FL_arr_gc_head.first->next; /* Check if the list has allocations outstanding */ #ifdef H5FL_DEBUG -HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.first->list->name, (int)H5FL_arr_gc_head.first->list->allocated); + HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.first->list->name, + (int)H5FL_arr_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ - if(H5FL_arr_gc_head.first->list->allocated > 0) { + if (H5FL_arr_gc_head.first->list->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ H5FL_arr_gc_head.first->next = left; - left = H5FL_arr_gc_head.first; + left = H5FL_arr_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { @@ -1802,9 +1790,8 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.f H5FL_arr_gc_head.first = left; FUNC_LEAVE_NOAPI(H5FL_arr_gc_head.first != NULL ? 1 : 0) -} /* end H5FL__arr_term() */ +} /* end H5FL__arr_term() */ - /*------------------------------------------------------------------------- * Function: H5FL_seq_free * @@ -1833,12 +1820,11 @@ H5FL_seq_free(H5FL_seq_head_t *head, void *obj) HDassert(head->queue.init); /* Use block routine */ - H5FL_blk_free(&(head->queue),obj); + H5FL_blk_free(&(head->queue), obj); FUNC_LEAVE_NOAPI(NULL) -} /* end H5FL_seq_free() */ +} /* end H5FL_seq_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_seq_malloc * @@ -1855,7 +1841,7 @@ H5FL_seq_free(H5FL_seq_head_t *head, void *obj) void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI_NOERR @@ -1867,9 +1853,8 @@ H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) ret_value = H5FL_blk_malloc(&(head->queue), head->size * elem H5FL_TRACK_INFO_INT); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_seq_malloc() */ +} /* end H5FL_seq_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_seq_calloc * @@ -1886,7 +1871,7 @@ H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI_NOERR @@ -1898,9 +1883,8 @@ H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) ret_value = H5FL_blk_calloc(&(head->queue), head->size * elem H5FL_TRACK_INFO_INT); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_seq_calloc() */ +} /* end H5FL_seq_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_seq_realloc * @@ -1915,9 +1899,9 @@ H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) *------------------------------------------------------------------------- */ void * -H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_PARAMS) +H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI_NOERR @@ -1929,9 +1913,8 @@ H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_P ret_value = H5FL_blk_realloc(&(head->queue), obj, head->size * new_elem H5FL_TRACK_INFO_INT); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_seq_realloc() */ +} /* end H5FL_seq_realloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_init * @@ -1948,9 +1931,9 @@ H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_P H5FL_fac_head_t * H5FL_fac_init(size_t size) { - H5FL_fac_gc_node_t *new_node = NULL; /* Pointer to the node for the new list to garbage collect */ - H5FL_fac_head_t *factory = NULL; /* Pointer to new block factory */ - H5FL_fac_head_t *ret_value = NULL; /* Return value */ + H5FL_fac_gc_node_t *new_node = NULL; /* Pointer to the node for the new list to garbage collect */ + H5FL_fac_head_t * factory = NULL; /* Pointer to new block factory */ + H5FL_fac_head_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1958,31 +1941,31 @@ H5FL_fac_init(size_t size) HDassert(size > 0); /* Allocate room for the new factory */ - if(NULL == (factory = (H5FL_fac_head_t *)H5FL_CALLOC(H5FL_fac_head_t))) + if (NULL == (factory = (H5FL_fac_head_t *)H5FL_CALLOC(H5FL_fac_head_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for factory object") /* Set size of blocks for factory */ factory->size = size; /* Allocate a new garbage collection node */ - if(NULL == (new_node = (H5FL_fac_gc_node_t *)H5FL_MALLOC(H5FL_fac_gc_node_t))) + if (NULL == (new_node = (H5FL_fac_gc_node_t *)H5FL_MALLOC(H5FL_fac_gc_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->list = factory; /* Link in to the garbage collection list */ - new_node->next = H5FL_fac_gc_head.first; + new_node->next = H5FL_fac_gc_head.first; H5FL_fac_gc_head.first = new_node; - if(new_node->next) - new_node->next->list->prev_gc=new_node; + if (new_node->next) + new_node->next->list->prev_gc = new_node; /* The new factory's prev_gc field will be set to NULL */ /* Make certain that the space allocated is large enough to store a free list pointer (eventually) */ - if(factory->size < sizeof(H5FL_fac_node_t)) + if (factory->size < sizeof(H5FL_fac_node_t)) factory->size = sizeof(H5FL_fac_node_t); - /* Make certain there's room for tracking information, if any */ + /* Make certain there's room for tracking information, if any */ #ifdef H5FL_TRACK factory->size += sizeof(H5FL_track_t); #endif /* H5FL_TRACK */ @@ -1994,17 +1977,16 @@ H5FL_fac_init(size_t size) ret_value = factory; done: - if(!ret_value) { - if(factory) + if (!ret_value) { + if (factory) factory = H5FL_FREE(H5FL_fac_head_t, factory); - if(new_node) + if (new_node) new_node = H5FL_FREE(H5FL_fac_gc_node_t, new_node); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_init() */ +} /* end H5FL_fac_init() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_free * @@ -2020,7 +2002,7 @@ done: void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2039,21 +2021,21 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) trk->func = H5MM_xfree(trk->func); /* Remove from "outstanding allocations" list */ - if(trk == H5FL_out_head_g) { + if (trk == H5FL_out_head_g) { H5FL_out_head_g = H5FL_out_head_g->next; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = NULL; } /* end if */ else { trk->prev->next = trk->next; - if(trk->next) + if (trk->next) trk->next->prev = trk->prev; } /* end else */ } #endif /* H5FL_TRACK */ #ifdef H5FL_DEBUG - HDmemset(obj,255,head->size); + HDmemset(obj, 255, head->size); #endif /* H5FL_DEBUG */ /* Make certain that the free list is initialized */ @@ -2073,20 +2055,19 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->onlist * head->size > H5FL_fac_lst_mem_lim) - if(H5FL__fac_gc_list(head) < 0) + if (head->onlist * head->size > H5FL_fac_lst_mem_lim) + if (H5FL__fac_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on factory free lists */ - if(H5FL_fac_gc_head.mem_freed > H5FL_fac_glb_mem_lim) - if(H5FL__fac_gc() < 0) + if (H5FL_fac_gc_head.mem_freed > H5FL_fac_glb_mem_lim) + if (H5FL__fac_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_free() */ +} /* end H5FL_fac_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_malloc * @@ -2103,7 +2084,7 @@ done: void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2113,22 +2094,22 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) HDassert(head->init); /* Check for nodes available on the free list first */ - if(head->list!=NULL) { + if (head->list != NULL) { /* Get a pointer to the block on the free list */ - ret_value=(void *)(head->list); + ret_value = (void *)(head->list); /* Remove node from free list */ - head->list=head->list->next; + head->list = head->list->next; /* Decrement the number of blocks & memory on free list */ head->onlist--; /* Decrement the amount of global "factory" free list memory in use */ - H5FL_fac_gc_head.mem_freed-=(head->size); + H5FL_fac_gc_head.mem_freed -= (head->size); } /* end if */ /* Otherwise allocate a node */ else { - if(NULL == (ret_value = H5FL__malloc(head->size))) + if (NULL == (ret_value = H5FL__malloc(head->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks allocated in list */ @@ -2146,7 +2127,7 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) /* Add to "outstanding allocations" list */ ((H5FL_track_t *)ret_value)->prev = NULL; ((H5FL_track_t *)ret_value)->next = H5FL_out_head_g; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = (H5FL_track_t *)ret_value; H5FL_out_head_g = (H5FL_track_t *)ret_value; @@ -2156,9 +2137,8 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_malloc() */ +} /* end H5FL_fac_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_calloc * @@ -2175,7 +2155,7 @@ done: void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2184,18 +2164,17 @@ H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) HDassert(head); /* Allocate the block */ - if (NULL==(ret_value = H5FL_fac_malloc(head H5FL_TRACK_INFO_INT))) + if (NULL == (ret_value = H5FL_fac_malloc(head H5FL_TRACK_INFO_INT))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ /* (Accommodate tracking information, if present) */ - HDmemset(ret_value,0,head->size - H5FL_TRACK_SIZE); + HDmemset(ret_value, 0, head->size - H5FL_TRACK_SIZE); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_calloc() */ +} /* end H5FL_fac_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__fac_gc_list * @@ -2218,8 +2197,8 @@ H5FL__fac_gc_list(H5FL_fac_head_t *head) /* For each free list being garbage collected, walk through the nodes and free them */ free_list = head->list; - while(free_list != NULL) { - H5FL_fac_node_t *tmp; /* Temporary node pointer */ + while (free_list != NULL) { + H5FL_fac_node_t *tmp; /* Temporary node pointer */ /* Get the pointer to the next node */ tmp = free_list->next; @@ -2238,13 +2217,12 @@ H5FL__fac_gc_list(H5FL_fac_head_t *head) H5FL_fac_gc_head.mem_freed -= (head->onlist * head->size); /* Indicate no free nodes on the free list */ - head->list = NULL; + head->list = NULL; head->onlist = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL__fac_gc_list() */ +} /* end H5FL__fac_gc_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__fac_gc * @@ -2261,16 +2239,16 @@ H5FL__fac_gc_list(H5FL_fac_head_t *head) static herr_t H5FL__fac_gc(void) { - H5FL_fac_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value = SUCCEED; /* return value*/ + H5FL_fac_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT /* Walk through all the free lists, free()'ing the nodes */ gc_node = H5FL_fac_gc_head.first; - while(gc_node != NULL) { + while (gc_node != NULL) { /* Release the free nodes on the list */ - if(H5FL__fac_gc_list(gc_node->list) < 0) + if (H5FL__fac_gc_list(gc_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ @@ -2282,9 +2260,8 @@ H5FL__fac_gc(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__fac_gc() */ +} /* end H5FL__fac_gc() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_term * @@ -2301,8 +2278,8 @@ done: herr_t H5FL_fac_term(H5FL_fac_head_t *factory) { - H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + herr_t ret_value = SUCCEED; /* Return value */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2311,29 +2288,31 @@ H5FL_fac_term(H5FL_fac_head_t *factory) HDassert(factory); /* Garbage collect all the blocks in the factory's free list */ - if(H5FL__fac_gc_list(factory) < 0) + if (H5FL__fac_gc_list(factory) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of factory failed") /* Verify that all the blocks have been freed */ - if(factory->allocated > 0) + if (factory->allocated > 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "factory still has objects allocated") /* Unlink block free list for factory from global free list */ - if(factory->prev_gc) { - H5FL_fac_gc_node_t *last = factory->prev_gc; /* Garbage collection node before the one being removed */ + if (factory->prev_gc) { + H5FL_fac_gc_node_t *last = + factory->prev_gc; /* Garbage collection node before the one being removed */ HDassert(last->next->list == factory); - tmp = last->next->next; + tmp = last->next->next; last->next = H5FL_FREE(H5FL_fac_gc_node_t, last->next); last->next = tmp; - if(tmp) + if (tmp) tmp->list->prev_gc = last; - } else { + } + else { HDassert(H5FL_fac_gc_head.first->list == factory); - tmp = H5FL_fac_gc_head.first->next; + tmp = H5FL_fac_gc_head.first->next; H5FL_fac_gc_head.first = H5FL_FREE(H5FL_fac_gc_node_t, H5FL_fac_gc_head.first); H5FL_fac_gc_head.first = tmp; - if(tmp) + if (tmp) tmp->list->prev_gc = NULL; } /* end else */ @@ -2342,9 +2321,8 @@ H5FL_fac_term(H5FL_fac_head_t *factory) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_term() */ +} /* end H5FL_fac_term() */ - /*------------------------------------------------------------------------- * Function: H5FL__fac_term_all * @@ -2364,13 +2342,14 @@ H5FL__fac_term_all(void) FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list */ - while(H5FL_fac_gc_head.first != NULL) { - H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + while (H5FL_fac_gc_head.first != NULL) { + H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ tmp = H5FL_fac_gc_head.first->next; #ifdef H5FL_DEBUG -HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_head.first->list->size, (int)H5FL_fac_gc_head.first->list->allocated); + HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_head.first->list->size, + (int)H5FL_fac_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ /* The list cannot have any allocations outstanding */ @@ -2386,9 +2365,8 @@ HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_h } /* end while */ FUNC_LEAVE_NOAPI(0) -} /* end H5FL__fac_term_all() */ +} /* end H5FL__fac_term_all() */ - /*------------------------------------------------------------------------- * Function: H5FL_garbage_coll * @@ -2405,31 +2383,30 @@ HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_h herr_t H5FL_garbage_coll(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Garbage collect the free lists for array objects */ - if(H5FL__arr_gc() < 0) + if (H5FL__arr_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect array objects") /* Garbage collect free lists for blocks */ - if(H5FL__blk_gc() < 0) + if (H5FL__blk_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect block objects") /* Garbage collect the free lists for regular objects */ - if(H5FL__reg_gc() < 0) + if (H5FL__reg_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect regular objects") /* Garbage collect the free lists for factory objects */ - if(H5FL__fac_gc() < 0) + if (H5FL__fac_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect factory objects") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_garbage_coll() */ +} /* end H5FL_garbage_coll() */ - /*------------------------------------------------------------------------- * Function: H5FL_set_free_list_limits * @@ -2458,11 +2435,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, - int arr_list_lim, int blk_global_lim, int blk_list_lim, int fac_global_lim, - int fac_list_lim) +H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim, int fac_global_lim, int fac_list_lim) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -2485,9 +2461,8 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l H5FL_fac_lst_mem_lim = (fac_list_lim == -1 ? UINT_MAX : (size_t)fac_list_lim); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_set_free_list_limits() */ +} /* end H5FL_set_free_list_limits() */ - /*------------------------------------------------------------------------- * Function: H5FL_get_free_list_sizes * @@ -2511,20 +2486,19 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l *------------------------------------------------------------------------- */ herr_t -H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, - size_t *fac_size) +H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size) { FUNC_ENTER_NOAPI_NOERR /* Retrieve the amount of "regular" memory used */ - if(reg_size) { - H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of lists */ + if (reg_size) { + H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of lists */ /* Walk through all the free lists, counting the amount of memory */ *reg_size = 0; - gc_node = H5FL_reg_gc_head.first; - while(gc_node != NULL) { - H5FL_reg_head_t *reg_list = gc_node->list; /* Head of list */ + gc_node = H5FL_reg_gc_head.first; + while (gc_node != NULL) { + H5FL_reg_head_t *reg_list = gc_node->list; /* Head of list */ /* Sanity check */ HDassert(reg_list->init); @@ -2535,27 +2509,27 @@ H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, /* Go on to the next free list */ gc_node = gc_node->next; } /* end while */ - } /* end if */ + } /* end if */ /* Retrieve the amount of "array" memory used */ - if(arr_size) { - H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ + if (arr_size) { + H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ /* Walk through all the free lists, counting the amount of memory */ - *arr_size = 0; + *arr_size = 0; gc_arr_node = H5FL_arr_gc_head.first; - while(gc_arr_node != NULL) { - H5FL_arr_head_t *head = gc_arr_node->list; /* Head of array list elements */ + while (gc_arr_node != NULL) { + H5FL_arr_head_t *head = gc_arr_node->list; /* Head of array list elements */ /* Sanity check */ HDassert(head->init); /* Check for any allocated elements in this list */ - if(head->allocated > 0) { + if (head->allocated > 0) { unsigned u; /* Walk through the free lists for array sizes */ - for(u = 0; u < (unsigned)head->maxelem; u++) + for (u = 0; u < (unsigned)head->maxelem; u++) /* Add the amount of memory for this size */ *arr_size += head->list_arr[u].allocated * head->list_arr[u].size; } /* end if */ @@ -2563,21 +2537,21 @@ H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, /* Go on to the next free list */ gc_arr_node = gc_arr_node->next; } /* end while */ - } /* end if */ + } /* end if */ /* Retrieve the amount of "block" memory used */ - if(blk_size) { - H5FL_blk_gc_node_t *gc_blk_node; /* Pointer into the list of things */ + if (blk_size) { + H5FL_blk_gc_node_t *gc_blk_node; /* Pointer into the list of things */ /* Walk through all the free lists */ gc_blk_node = H5FL_blk_gc_head.first; - *blk_size = 0; - while(gc_blk_node != NULL) { - H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list block node */ + *blk_size = 0; + while (gc_blk_node != NULL) { + H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list block node */ /* Loop through all the nodes in the block free list queue */ blk_head = gc_blk_node->pq->head; - while(blk_head != NULL) { + while (blk_head != NULL) { /* Add size of blocks on this list */ *blk_size += (blk_head->allocated * blk_head->size); @@ -2588,17 +2562,17 @@ H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, /* Go on to the next free list */ gc_blk_node = gc_blk_node->next; } /* end while */ - } /* end if */ + } /* end if */ /* Retrieve the amount of "factory" memory used */ - if(fac_size) { - H5FL_fac_gc_node_t *gc_fac_node; /* Pointer into the list of things to garbage collect */ + if (fac_size) { + H5FL_fac_gc_node_t *gc_fac_node; /* Pointer into the list of things to garbage collect */ /* Walk through all the free lists */ gc_fac_node = H5FL_fac_gc_head.first; - *fac_size = 0; - while(gc_fac_node != NULL) { - H5FL_fac_head_t *fac_head = gc_fac_node->list; /* Head node for factory list */ + *fac_size = 0; + while (gc_fac_node != NULL) { + H5FL_fac_head_t *fac_head = gc_fac_node->list; /* Head node for factory list */ /* Add size of blocks on this list */ *fac_size += (fac_head->allocated * fac_head->size); @@ -2606,8 +2580,7 @@ H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, /* Go on to the next free list to garbage collect */ gc_fac_node = gc_fac_node->next; } /* end while */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FL_get_free_list_sizes() */ - diff --git a/src/H5FLmodule.h b/src/H5FLmodule.h index 48b8d2b..0945608 100644 --- a/src/H5FLmodule.h +++ b/src/H5FLmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5FL_MODULE -#define H5_MY_PKG H5FL -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5FL +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO #endif /* _H5FLmodule_H */ - diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index 94a51e5..6425aca 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -28,8 +28,8 @@ /* Public headers needed by this file */ #ifdef LATER -#include "H5FLpublic.h" /*API prototypes */ -#endif /* LATER */ +#include "H5FLpublic.h" /*API prototypes */ +#endif /* LATER */ /* Private headers needed by this file */ @@ -53,23 +53,23 @@ /* #define H5FL_TRACK */ #ifdef H5FL_TRACK /* Macro for inclusion in the free list allocation calls */ -#define H5FL_TRACK_INFO ,__FILE__, FUNC, __LINE__ +#define H5FL_TRACK_INFO , __FILE__, FUNC, __LINE__ /* Macro for inclusion in internal free list allocation calls */ -#define H5FL_TRACK_INFO_INT ,call_file, call_func, call_line +#define H5FL_TRACK_INFO_INT , call_file, call_func, call_line /* Macro for inclusion in the free list allocation parameters */ -#define H5FL_TRACK_PARAMS ,const char *call_file, const char *call_func, int call_line +#define H5FL_TRACK_PARAMS , const char *call_file, const char *call_func, int call_line /* Forward declarations for structure fields */ struct H5CS_t; /* Tracking information for each block */ typedef struct H5FL_track_t { - struct H5CS_t *stack; /* Function stack */ - char *file; /* Name of file containing calling function */ - char *func; /* Name of calling function */ - int line; /* Line # within calling function */ + struct H5CS_t * stack; /* Function stack */ + char * file; /* Name of file containing calling function */ + char * func; /* Name of calling function */ + int line; /* Line # within calling function */ struct H5FL_track_t *next; /* Pointer to next tracking block */ struct H5FL_track_t *prev; /* Pointer to previous tracking block */ } H5FL_track_t; @@ -81,7 +81,7 @@ typedef struct H5FL_track_t { #define H5FL_TRACK_INFO #define H5FL_TRACK_INFO_INT #define H5FL_TRACK_PARAMS -#define H5FL_TRACK_SIZE 0 +#define H5FL_TRACK_SIZE 0 #endif /* H5FL_TRACK */ /* @@ -90,44 +90,44 @@ typedef struct H5FL_track_t { /* Data structure to store each block in free list */ typedef struct H5FL_reg_node_t { - struct H5FL_reg_node_t *next; /* Pointer to next block in free list */ + struct H5FL_reg_node_t *next; /* Pointer to next block in free list */ } H5FL_reg_node_t; /* Data structure for free list of blocks */ typedef struct H5FL_reg_head_t { - hbool_t init; /* Whether the free list has been initialized */ - unsigned allocated; /* Number of blocks allocated */ - unsigned onlist; /* Number of blocks on free list */ - const char *name; /* Name of the type */ - size_t size; /* Size of the blocks in the list */ - H5FL_reg_node_t *list; /* List of free blocks */ + hbool_t init; /* Whether the free list has been initialized */ + unsigned allocated; /* Number of blocks allocated */ + unsigned onlist; /* Number of blocks on free list */ + const char * name; /* Name of the type */ + size_t size; /* Size of the blocks in the list */ + H5FL_reg_node_t *list; /* List of free blocks */ } H5FL_reg_head_t; /* * Macros for defining & using free lists for a type */ -#define H5FL_REG_NAME(t) H5_##t##_reg_free_list +#define H5FL_REG_NAME(t) H5_##t##_reg_free_list #ifndef H5_NO_REG_FREE_LISTS /* Common macros for H5FL_DEFINE & H5FL_DEFINE_STATIC */ -#define H5FL_DEFINE_COMMON(t) H5FL_reg_head_t H5FL_REG_NAME(t)={0,0,0,#t,sizeof(t),NULL} +#define H5FL_DEFINE_COMMON(t) H5FL_reg_head_t H5FL_REG_NAME(t) = {0, 0, 0, #t, sizeof(t), NULL} /* Declare a free list to manage objects of type 't' */ #define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) /* Reference a free list for type 't' defined in another file */ -#define H5FL_EXTERN(t) H5_DLLVAR H5FL_reg_head_t H5FL_REG_NAME(t) +#define H5FL_EXTERN(t) H5_DLLVAR H5FL_reg_head_t H5FL_REG_NAME(t) /* Declare a static free list to manage objects of type 't' */ -#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) +#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) /* Allocate an object of type 't' */ -#define H5FL_MALLOC(t) (t *)H5FL_reg_malloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO) +#define H5FL_MALLOC(t) (t *)H5FL_reg_malloc(&(H5FL_REG_NAME(t))H5FL_TRACK_INFO) /* Allocate an object of type 't' and clear it to all zeros */ -#define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO) +#define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t))H5FL_TRACK_INFO) /* Free an object of type 't' */ -#define H5FL_FREE(t,obj) (t *)H5FL_reg_free(&(H5FL_REG_NAME(t)),obj) +#define H5FL_FREE(t, obj) (t *)H5FL_reg_free(&(H5FL_REG_NAME(t)), obj) /* Re-allocating an object of type 't' is not defined, because these free-lists * only support fixed sized types, like structs, etc.. @@ -138,171 +138,173 @@ typedef struct H5FL_reg_head_t { /* Common macro for H5FL_DEFINE & H5FL_DEFINE_STATIC */ #define H5FL_DEFINE_COMMON(t) int H5_ATTR_UNUSED H5FL_REG_NAME(t) -#define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) -#define H5FL_EXTERN(t) H5_DLLVAR H5FL_DEFINE_COMMON(t) -#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) -#define H5FL_MALLOC(t) (t *)H5MM_malloc(sizeof(t)) -#define H5FL_CALLOC(t) (t *)H5MM_calloc(sizeof(t)) -#define H5FL_FREE(t,obj) (t *)H5MM_xfree(obj) +#define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) +#define H5FL_EXTERN(t) H5_DLLVAR H5FL_DEFINE_COMMON(t) +#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) +#define H5FL_MALLOC(t) (t *)H5MM_malloc(sizeof(t)) +#define H5FL_CALLOC(t) (t *)H5MM_calloc(sizeof(t)) +#define H5FL_FREE(t, obj) (t *)H5MM_xfree(obj) #endif /* H5_NO_REG_FREE_LISTS */ /* Data structure to store information about each block allocated */ typedef union H5FL_blk_list_t { - size_t size; /* Size of the page */ - union H5FL_blk_list_t *next; /* Pointer to next block in free list */ - double unused1; /* Unused normally, just here for aligment */ - haddr_t unused2; /* Unused normally, just here for aligment */ + size_t size; /* Size of the page */ + union H5FL_blk_list_t *next; /* Pointer to next block in free list */ + double unused1; /* Unused normally, just here for aligment */ + haddr_t unused2; /* Unused normally, just here for aligment */ } H5FL_blk_list_t; /* Data structure for priority queue node of block free lists */ typedef struct H5FL_blk_node_t { - size_t size; /* Size of the blocks in the list */ - unsigned allocated; /* Number of blocks of this size allocated */ - unsigned onlist; /* Number of blocks on free list */ - H5FL_blk_list_t *list; /* List of free blocks */ - struct H5FL_blk_node_t *next; /* Pointer to next free list in queue */ - struct H5FL_blk_node_t *prev; /* Pointer to previous free list in queue */ + size_t size; /* Size of the blocks in the list */ + unsigned allocated; /* Number of blocks of this size allocated */ + unsigned onlist; /* Number of blocks on free list */ + H5FL_blk_list_t * list; /* List of free blocks */ + struct H5FL_blk_node_t *next; /* Pointer to next free list in queue */ + struct H5FL_blk_node_t *prev; /* Pointer to previous free list in queue */ } H5FL_blk_node_t; /* Data structure for priority queue of native block free lists */ typedef struct H5FL_blk_head_t { - hbool_t init; /* Whether the free list has been initialized */ - unsigned allocated; /* Total number of blocks allocated */ - unsigned onlist; /* Total number of blocks on free list */ - size_t list_mem; /* Total amount of memory in blocks on free list */ - const char *name; /* Name of the type */ - H5FL_blk_node_t *head; /* Pointer to first free list in queue */ + hbool_t init; /* Whether the free list has been initialized */ + unsigned allocated; /* Total number of blocks allocated */ + unsigned onlist; /* Total number of blocks on free list */ + size_t list_mem; /* Total amount of memory in blocks on free list */ + const char * name; /* Name of the type */ + H5FL_blk_node_t *head; /* Pointer to first free list in queue */ } H5FL_blk_head_t; /* * Macros for defining & using priority queues */ -#define H5FL_BLK_NAME(t) H5_##t##_blk_free_list +#define H5FL_BLK_NAME(t) H5_##t##_blk_free_list #ifndef H5_NO_BLK_FREE_LISTS /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ -#define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t)={0,0,0,0,#t"_blk",NULL} +#define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t) = {0, 0, 0, 0, #t "_blk", NULL} /* Declare a free list to manage objects of type 't' */ -#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) /* Reference a free list for type 't' defined in another file */ -#define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_blk_head_t H5FL_BLK_NAME(t) +#define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_blk_head_t H5FL_BLK_NAME(t) /* Declare a static free list to manage objects of type 't' */ -#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) /* Allocate a block of type 't' */ -#define H5FL_BLK_MALLOC(t,size) (uint8_t *)H5FL_blk_malloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO) +#define H5FL_BLK_MALLOC(t, size) (uint8_t *)H5FL_blk_malloc(&(H5FL_BLK_NAME(t)), size H5FL_TRACK_INFO) /* Allocate a block of type 't' and clear it to zeros */ -#define H5FL_BLK_CALLOC(t,size) (uint8_t *)H5FL_blk_calloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO) +#define H5FL_BLK_CALLOC(t, size) (uint8_t *)H5FL_blk_calloc(&(H5FL_BLK_NAME(t)), size H5FL_TRACK_INFO) /* Free a block of type 't' */ -#define H5FL_BLK_FREE(t,blk) (uint8_t *)H5FL_blk_free(&(H5FL_BLK_NAME(t)),blk) +#define H5FL_BLK_FREE(t, blk) (uint8_t *)H5FL_blk_free(&(H5FL_BLK_NAME(t)), blk) /* Re-allocate a block of type 't' */ -#define H5FL_BLK_REALLOC(t,blk,new_size) (uint8_t *)H5FL_blk_realloc(&(H5FL_BLK_NAME(t)),blk,new_size H5FL_TRACK_INFO) +#define H5FL_BLK_REALLOC(t, blk, new_size) \ + (uint8_t *)H5FL_blk_realloc(&(H5FL_BLK_NAME(t)), blk, new_size H5FL_TRACK_INFO) /* Check if there is a free block available to re-use */ -#define H5FL_BLK_AVAIL(t,size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)),size) +#define H5FL_BLK_AVAIL(t, size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)), size) #else /* H5_NO_BLK_FREE_LISTS */ /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ #define H5FL_BLK_DEFINE_COMMON(t) int H5_ATTR_UNUSED H5FL_BLK_NAME(t) -#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) -#define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_BLK_DEFINE_COMMON(t) -#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) -#define H5FL_BLK_MALLOC(t,size) (uint8_t *)H5MM_malloc(size) -#define H5FL_BLK_CALLOC(t,size) (uint8_t *)H5MM_calloc(size) -#define H5FL_BLK_FREE(t,blk) (uint8_t *)H5MM_xfree(blk) -#define H5FL_BLK_REALLOC(t,blk,new_size) (uint8_t *)H5MM_realloc(blk,new_size) -#define H5FL_BLK_AVAIL(t,size) (FALSE) +#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_MALLOC(t, size) (uint8_t *)H5MM_malloc(size) +#define H5FL_BLK_CALLOC(t, size) (uint8_t *)H5MM_calloc(size) +#define H5FL_BLK_FREE(t, blk) (uint8_t *)H5MM_xfree(blk) +#define H5FL_BLK_REALLOC(t, blk, new_size) (uint8_t *)H5MM_realloc(blk, new_size) +#define H5FL_BLK_AVAIL(t, size) (FALSE) #endif /* H5_NO_BLK_FREE_LISTS */ /* Data structure to store each array in free list */ typedef union H5FL_arr_list_t { - union H5FL_arr_list_t *next; /* Pointer to next block in free list */ - size_t nelem; /* Number of elements in this array */ - double unused1; /* Unused normally, just here for aligment */ - haddr_t unused2; /* Unused normally, just here for aligment */ + union H5FL_arr_list_t *next; /* Pointer to next block in free list */ + size_t nelem; /* Number of elements in this array */ + double unused1; /* Unused normally, just here for aligment */ + haddr_t unused2; /* Unused normally, just here for aligment */ } H5FL_arr_list_t; /* Data structure for each size of array element */ typedef struct H5FL_arr_node_t { size_t size; /* Size of the blocks in the list (in bytes) */ /* (Note: base_size + <# of elem> * elem_size) */ - unsigned allocated; /* Number of blocks allocated of this element size */ - unsigned onlist; /* Number of blocks on free list */ + unsigned allocated; /* Number of blocks allocated of this element size */ + unsigned onlist; /* Number of blocks on free list */ H5FL_arr_list_t *list; /* List of free blocks */ } H5FL_arr_node_t; /* Data structure for free list of array blocks */ typedef struct H5FL_arr_head_t { - hbool_t init; /* Whether the free list has been initialized */ - unsigned allocated; /* Total number of blocks allocated */ - size_t list_mem; /* Amount of memory in block on free list */ - const char *name; /* Name of the type */ - int maxelem; /* Maximum number of elements in an array */ - size_t base_size; /* Size of the "base" object in the list */ - size_t elem_size; /* Size of the array elements in the list */ + hbool_t init; /* Whether the free list has been initialized */ + unsigned allocated; /* Total number of blocks allocated */ + size_t list_mem; /* Amount of memory in block on free list */ + const char * name; /* Name of the type */ + int maxelem; /* Maximum number of elements in an array */ + size_t base_size; /* Size of the "base" object in the list */ + size_t elem_size; /* Size of the array elements in the list */ H5FL_arr_node_t *list_arr; /* Array of lists of free blocks */ } H5FL_arr_head_t; /* * Macros for defining & using free lists for an array of a type */ -#define H5FL_ARR_NAME(t) H5_##t##_arr_free_list +#define H5FL_ARR_NAME(t) H5_##t##_arr_free_list #ifndef H5_NO_ARR_FREE_LISTS /* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC (and H5FL_BARR variants) */ -#define H5FL_ARR_DEFINE_COMMON(b,t,m) H5FL_arr_head_t H5FL_ARR_NAME(t)={0,0,0,#t"_arr",m+1,b,sizeof(t),NULL} +#define H5FL_ARR_DEFINE_COMMON(b, t, m) \ + H5FL_arr_head_t H5FL_ARR_NAME(t) = {0, 0, 0, #t "_arr", m + 1, b, sizeof(t), NULL} /* Declare a free list to manage arrays of type 't' */ -#define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(0,t,m) +#define H5FL_ARR_DEFINE(t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(0, t, m) /* Declare a free list to manage base 'b' + arrays of type 't' */ -#define H5FL_BARR_DEFINE(b,t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(sizeof(b),t,m) +#define H5FL_BARR_DEFINE(b, t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(sizeof(b), t, m) /* Reference a free list for arrays of type 't' defined in another file */ -#define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_arr_head_t H5FL_ARR_NAME(t) +#define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_arr_head_t H5FL_ARR_NAME(t) /* Declare a static free list to manage arrays of type 't' */ -#define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE_COMMON(0,t,m) +#define H5FL_ARR_DEFINE_STATIC(t, m) static H5FL_ARR_DEFINE_COMMON(0, t, m) /* Declare a static free list to manage base 'b' + arrays of type 't' */ -#define H5FL_BARR_DEFINE_STATIC(b,t,m) static H5FL_ARR_DEFINE_COMMON(sizeof(b),t,m) +#define H5FL_BARR_DEFINE_STATIC(b, t, m) static H5FL_ARR_DEFINE_COMMON(sizeof(b), t, m) /* Allocate an array of type 't' */ -#define H5FL_ARR_MALLOC(t,elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)),elem) +#define H5FL_ARR_MALLOC(t, elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)), elem) /* Allocate an array of type 't' and clear it to all zeros */ -#define H5FL_ARR_CALLOC(t,elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)),elem) +#define H5FL_ARR_CALLOC(t, elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)), elem) /* Free an array of type 't' */ -#define H5FL_ARR_FREE(t,obj) (t *)H5FL_arr_free(&(H5FL_ARR_NAME(t)),obj) +#define H5FL_ARR_FREE(t, obj) (t *)H5FL_arr_free(&(H5FL_ARR_NAME(t)), obj) /* Re-allocate an array of type 't' */ -#define H5FL_ARR_REALLOC(t,obj,new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)),obj,new_elem) +#define H5FL_ARR_REALLOC(t, obj, new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)), obj, new_elem) #else /* H5_NO_ARR_FREE_LISTS */ /* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC (and H5FL_BARR variants) */ -#define H5FL_ARR_DEFINE_COMMON(t,m) size_t H5FL_ARR_NAME(t) - -#define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) = 0 -#define H5FL_BARR_DEFINE(b,t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) = sizeof(b) -#define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_ARR_DEFINE_COMMON(t,m) -#define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE_COMMON(t,m) = 0 -#define H5FL_BARR_DEFINE_STATIC(b,t,m) static H5FL_ARR_DEFINE_COMMON(t,m) = sizeof(b) -#define H5FL_ARR_MALLOC(t,elem) H5MM_malloc(H5FL_ARR_NAME(t) + ((elem)*sizeof(t))) -#define H5FL_ARR_CALLOC(t,elem) H5MM_calloc(H5FL_ARR_NAME(t) + ((elem)*sizeof(t))) -#define H5FL_ARR_FREE(t,obj) (t *)H5MM_xfree(obj) -#define H5FL_ARR_REALLOC(t,obj,new_elem) H5MM_realloc(obj,H5FL_ARR_NAME(t) + ((new_elem)*sizeof(t))) +#define H5FL_ARR_DEFINE_COMMON(t, m) size_t H5FL_ARR_NAME(t) + +#define H5FL_ARR_DEFINE(t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(t, m) = 0 +#define H5FL_BARR_DEFINE(b, t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(t, m) = sizeof(b) +#define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_ARR_DEFINE_COMMON(t, m) +#define H5FL_ARR_DEFINE_STATIC(t, m) static H5FL_ARR_DEFINE_COMMON(t, m) = 0 +#define H5FL_BARR_DEFINE_STATIC(b, t, m) static H5FL_ARR_DEFINE_COMMON(t, m) = sizeof(b) +#define H5FL_ARR_MALLOC(t, elem) H5MM_malloc(H5FL_ARR_NAME(t) + ((elem) * sizeof(t))) +#define H5FL_ARR_CALLOC(t, elem) H5MM_calloc(H5FL_ARR_NAME(t) + ((elem) * sizeof(t))) +#define H5FL_ARR_FREE(t, obj) (t *)H5MM_xfree(obj) +#define H5FL_ARR_REALLOC(t, obj, new_elem) H5MM_realloc(obj, H5FL_ARR_NAME(t) + ((new_elem) * sizeof(t))) #endif /* H5_NO_ARR_FREE_LISTS */ /* Data structure for free list of sequence blocks */ typedef struct H5FL_seq_head_t { - H5FL_blk_head_t queue; /* Priority queue of sequence blocks */ - size_t size; /* Size of the sequence elements in the list */ + H5FL_blk_head_t queue; /* Priority queue of sequence blocks */ + size_t size; /* Size of the sequence elements in the list */ } H5FL_seq_head_t; /* @@ -311,60 +313,61 @@ typedef struct H5FL_seq_head_t { * Sequences are like arrays, except they have no upper limit. * */ -#define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list +#define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list #ifndef H5_NO_SEQ_FREE_LISTS /* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */ -#define H5FL_SEQ_DEFINE_COMMON(t) H5FL_seq_head_t H5FL_SEQ_NAME(t)={{0,0,0,0,#t"_seq",NULL},sizeof(t)} +#define H5FL_SEQ_DEFINE_COMMON(t) \ + H5FL_seq_head_t H5FL_SEQ_NAME(t) = {{0, 0, 0, 0, #t "_seq", NULL}, sizeof(t)} /* Declare a free list to manage sequences of type 't' */ -#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) /* Reference a free list for sequences of type 't' defined in another file */ -#define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_seq_head_t H5FL_SEQ_NAME(t) +#define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_seq_head_t H5FL_SEQ_NAME(t) /* Declare a static free list to manage sequences of type 't' */ -#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) /* Allocate a sequence of type 't' */ -#define H5FL_SEQ_MALLOC(t,elem) (t *)H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO) +#define H5FL_SEQ_MALLOC(t, elem) (t *)H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)), elem H5FL_TRACK_INFO) /* Allocate a sequence of type 't' and clear it to all zeros */ -#define H5FL_SEQ_CALLOC(t,elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO) +#define H5FL_SEQ_CALLOC(t, elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)), elem H5FL_TRACK_INFO) /* Free a sequence of type 't' */ -#define H5FL_SEQ_FREE(t,obj) (t *)H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj) +#define H5FL_SEQ_FREE(t, obj) (t *)H5FL_seq_free(&(H5FL_SEQ_NAME(t)), obj) /* Re-allocate a sequence of type 't' */ -#define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem H5FL_TRACK_INFO) +#define H5FL_SEQ_REALLOC(t, obj, new_elem) \ + (t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)), obj, new_elem H5FL_TRACK_INFO) #else /* H5_NO_SEQ_FREE_LISTS */ /* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */ #define H5FL_SEQ_DEFINE_COMMON(t) int H5_ATTR_UNUSED H5FL_SEQ_NAME(t) -#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) -#define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_SEQ_DEFINE_COMMON(t) -#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) -#define H5FL_SEQ_MALLOC(t,elem) (t *)H5MM_malloc((elem)*sizeof(t)) -#define H5FL_SEQ_CALLOC(t,elem) (t *)H5MM_calloc((elem)*sizeof(t)) -#define H5FL_SEQ_FREE(t,obj) (t *)H5MM_xfree(obj) -#define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5MM_realloc(obj,(new_elem)*sizeof(t)) +#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_MALLOC(t, elem) (t *)H5MM_malloc((elem) * sizeof(t)) +#define H5FL_SEQ_CALLOC(t, elem) (t *)H5MM_calloc((elem) * sizeof(t)) +#define H5FL_SEQ_FREE(t, obj) (t *)H5MM_xfree(obj) +#define H5FL_SEQ_REALLOC(t, obj, new_elem) (t *)H5MM_realloc(obj, (new_elem) * sizeof(t)) #endif /* H5_NO_SEQ_FREE_LISTS */ /* Forward declarations of the data structures for free list block factory */ typedef struct H5FL_fac_gc_node_t H5FL_fac_gc_node_t; -typedef struct H5FL_fac_node_t H5FL_fac_node_t; +typedef struct H5FL_fac_node_t H5FL_fac_node_t; /* Data structure for free list block factory */ typedef struct H5FL_fac_head_t { - hbool_t init; /* Whether the free list has been initialized */ - unsigned allocated; /* Number of blocks allocated */ - unsigned onlist; /* Number of blocks on free list */ - size_t size; /* Size of the blocks in the list */ - H5FL_fac_node_t *list; /* List of free blocks */ - H5FL_fac_gc_node_t *prev_gc; /* Previous garbage collection node in list */ + hbool_t init; /* Whether the free list has been initialized */ + unsigned allocated; /* Number of blocks allocated */ + unsigned onlist; /* Number of blocks on free list */ + size_t size; /* Size of the blocks in the list */ + H5FL_fac_node_t * list; /* List of free blocks */ + H5FL_fac_gc_node_t *prev_gc; /* Previous garbage collection node in list */ } H5FL_fac_head_t; - /* * Macros for defining & using free list factories * @@ -383,15 +386,15 @@ typedef struct H5FL_fac_head_t { #define H5FL_FAC_FREE(f, obj) H5FL_fac_free(f, obj) #else /* H5_NO_FAC_FREE_LISTS */ -#define H5FL_FAC_MALLOC(f) H5MM_malloc(f->size) -#define H5FL_FAC_CALLOC(f) H5MM_calloc(f->size) +#define H5FL_FAC_MALLOC(f) H5MM_malloc(f->size) +#define H5FL_FAC_CALLOC(f) H5MM_calloc(f->size) #define H5FL_FAC_FREE(f, obj) H5MM_xfree(obj) #endif /* H5_NO_FAC_FREE_LISTS */ /* * Library prototypes. */ - /* Block free lists */ +/* Block free lists */ H5_DLL void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS); H5_DLL void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS); H5_DLL void * H5FL_blk_free(H5FL_blk_head_t *head, void *block); @@ -399,36 +402,36 @@ H5_DLL void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_si H5_DLL htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size); /* Regular free lists */ -H5_DLL void * H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj); +H5_DLL void *H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_reg_free(H5FL_reg_head_t *head, void *obj); /* Array free lists */ -H5_DLL void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem); -H5_DLL void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem); -H5_DLL void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj); -H5_DLL void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); +H5_DLL void *H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem); +H5_DLL void *H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem); +H5_DLL void *H5FL_arr_free(H5FL_arr_head_t *head, void *obj); +H5_DLL void *H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); /* Sequence free lists */ -H5_DLL void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj); -H5_DLL void * H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_seq_free(H5FL_seq_head_t *head, void *obj); +H5_DLL void *H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS); /* Factory free lists */ H5_DLL H5FL_fac_head_t *H5FL_fac_init(size_t size); -H5_DLL void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj); -H5_DLL herr_t H5FL_fac_term(H5FL_fac_head_t *head); +H5_DLL void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj); +H5_DLL herr_t H5FL_fac_term(H5FL_fac_head_t *head); /* General free list routines */ H5_DLL herr_t H5FL_garbage_coll(void); -H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim, - int fac_global_lim, int fac_list_lim); -H5_DLL herr_t H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, - size_t *blk_size, size_t *fac_size); -H5_DLL int H5FL_term_interface(void); +H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, + int arr_list_lim, int blk_global_lim, int blk_list_lim, + int fac_global_lim, int fac_list_lim); +H5_DLL herr_t H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, + size_t *fac_size); +H5_DLL int H5FL_term_interface(void); #endif diff --git a/src/H5FO.c b/src/H5FO.c index 7bbf7fa..cca5aa3 100644 --- a/src/H5FO.c +++ b/src/H5FO.c @@ -19,28 +19,27 @@ * */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Oprivate.h" /* Object headers */ /* Private typedefs */ /* Information about open objects in a file */ typedef struct H5FO_open_obj_t { - haddr_t addr; /* Address of object header for object */ - void *obj; /* Pointer to the object */ - hbool_t deleted; /* Flag to indicate that the object was deleted from the file */ + haddr_t addr; /* Address of object header for object */ + void * obj; /* Pointer to the object */ + hbool_t deleted; /* Flag to indicate that the object was deleted from the file */ } H5FO_open_obj_t; /* Information about counted objects in a file */ typedef struct H5FO_obj_count_t { - haddr_t addr; /* Address of object header for object */ - hsize_t count; /* Number of times object is opened */ + haddr_t addr; /* Address of object header for object */ + hsize_t count; /* Number of times object is opened */ } H5FO_obj_count_t; /* Declare a free list to manage the H5FO_open_obj_t struct */ @@ -49,7 +48,6 @@ H5FL_DEFINE_STATIC(H5FO_open_obj_t); /* Declare a free list to manage the H5FO_obj_count_t struct */ H5FL_DEFINE_STATIC(H5FO_obj_count_t); - /*-------------------------------------------------------------------------- NAME H5FO_create @@ -71,7 +69,7 @@ H5FL_DEFINE_STATIC(H5FO_obj_count_t); herr_t H5FO_create(const H5F_t *f) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -80,14 +78,13 @@ H5FO_create(const H5F_t *f) HDassert(f->shared); /* Create container used to store open object info */ - if((f->shared->open_objs = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) + if ((f->shared->open_objs = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create open object container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_create() */ - /*-------------------------------------------------------------------------- NAME H5FO_opened @@ -112,7 +109,7 @@ void * H5FO_opened(const H5F_t *f, haddr_t addr) { H5FO_open_obj_t *open_obj; /* Information about open object */ - void *ret_value; /* Return value */ + void * ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -123,7 +120,7 @@ H5FO_opened(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs,&addr))) { + if (NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) { ret_value = open_obj->obj; HDassert(ret_value != NULL); } /* end if */ @@ -133,7 +130,6 @@ H5FO_opened(const H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_opened() */ - /*-------------------------------------------------------------------------- NAME H5FO_insert @@ -158,8 +154,8 @@ H5FO_opened(const H5F_t *f, haddr_t addr) herr_t H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag) { - H5FO_open_obj_t *open_obj; /* Information about open object */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FO_open_obj_t *open_obj; /* Information about open object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -171,23 +167,22 @@ H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag) HDassert(obj); /* Allocate new opened object information structure */ - if((open_obj=H5FL_MALLOC(H5FO_open_obj_t))==NULL) - HGOTO_ERROR(H5E_CACHE,H5E_NOSPACE,FAIL,"memory allocation failed") + if ((open_obj = H5FL_MALLOC(H5FO_open_obj_t)) == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Assign information */ - open_obj->addr=addr; - open_obj->obj=obj; - open_obj->deleted=delete_flag; + open_obj->addr = addr; + open_obj->obj = obj; + open_obj->deleted = delete_flag; /* Insert into container */ - if(H5SL_insert(f->shared->open_objs,&open_obj->addr,open_obj)<0) - HGOTO_ERROR(H5E_CACHE,H5E_CANTINSERT,FAIL,"can't insert object into container") + if (H5SL_insert(f->shared->open_objs, &open_obj->addr, open_obj) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert object into container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_insert() */ - /*-------------------------------------------------------------------------- NAME H5FO_delete @@ -210,8 +205,8 @@ done: herr_t H5FO_delete(H5F_t *f, haddr_t addr) { - H5FO_open_obj_t *open_obj; /* Information about open object */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FO_open_obj_t *open_obj; /* Information about open object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -222,12 +217,12 @@ H5FO_delete(H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Remove from container */ - if(NULL == (open_obj = (H5FO_open_obj_t *)H5SL_remove(f->shared->open_objs, &addr))) - HGOTO_ERROR(H5E_CACHE,H5E_CANTRELEASE,FAIL,"can't remove object from container") + if (NULL == (open_obj = (H5FO_open_obj_t *)H5SL_remove(f->shared->open_objs, &addr))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "can't remove object from container") /* Check if the object was deleted from the file */ - if(open_obj->deleted) { - if(H5O_delete(f, addr) < 0) + if (open_obj->deleted) { + if (H5O_delete(f, addr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") } /* end if */ @@ -238,7 +233,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_delete() */ - /*-------------------------------------------------------------------------- NAME H5FO_mark @@ -261,8 +255,8 @@ done: herr_t H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) { - H5FO_open_obj_t *open_obj; /* Information about open object */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FO_open_obj_t *open_obj; /* Information about open object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -273,7 +267,7 @@ H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) + if (NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) open_obj->deleted = deleted; else ret_value = FAIL; @@ -281,7 +275,6 @@ H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_mark() */ - /*-------------------------------------------------------------------------- NAME H5FO_marked @@ -305,8 +298,8 @@ H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) hbool_t H5FO_marked(const H5F_t *f, haddr_t addr) { - H5FO_open_obj_t *open_obj; /* Information about open object */ - hbool_t ret_value = FALSE; /* Return value */ + H5FO_open_obj_t *open_obj; /* Information about open object */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -317,13 +310,12 @@ H5FO_marked(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) + if (NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) ret_value = open_obj->deleted; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_marked() */ - /*-------------------------------------------------------------------------- NAME H5FO_dest @@ -345,7 +337,7 @@ H5FO_marked(const H5F_t *f, haddr_t addr) herr_t H5FO_dest(const H5F_t *f) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -355,20 +347,19 @@ H5FO_dest(const H5F_t *f) HDassert(f->shared->open_objs); /* Check if the object info set is empty */ - if(H5SL_count(f->shared->open_objs)!=0) + if (H5SL_count(f->shared->open_objs) != 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "objects still in open object info set") /* Release the open object info set container */ - if(H5SL_close(f->shared->open_objs)<0) + if (H5SL_close(f->shared->open_objs) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLOSEOBJ, FAIL, "can't close open object info set") - f->shared->open_objs=NULL; + f->shared->open_objs = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_dest() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_create @@ -390,7 +381,7 @@ done: herr_t H5FO_top_create(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -398,14 +389,13 @@ H5FO_top_create(H5F_t *f) HDassert(f); /* Create container used to store open object info */ - if((f->obj_count = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) + if ((f->obj_count = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create open object container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_create() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_incr @@ -428,8 +418,8 @@ done: herr_t H5FO_top_incr(const H5F_t *f, haddr_t addr) { - H5FO_obj_count_t *obj_count; /* Ref. count for object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FO_obj_count_t *obj_count; /* Ref. count for object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -439,28 +429,27 @@ H5FO_top_incr(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) { + if (NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) { (obj_count->count)++; } /* end if */ else { /* Allocate new opened object information structure */ - if(NULL == (obj_count = H5FL_MALLOC(H5FO_obj_count_t))) - HGOTO_ERROR(H5E_CACHE,H5E_NOSPACE,FAIL,"memory allocation failed") + if (NULL == (obj_count = H5FL_MALLOC(H5FO_obj_count_t))) + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Assign information */ - obj_count->addr = addr; + obj_count->addr = addr; obj_count->count = 1; /* Insert into container */ - if(H5SL_insert(f->obj_count, &obj_count->addr, obj_count) < 0) - HGOTO_ERROR(H5E_CACHE,H5E_CANTINSERT,FAIL,"can't insert object into container") + if (H5SL_insert(f->obj_count, &obj_count->addr, obj_count) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert object into container") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_incr() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_decr @@ -483,8 +472,8 @@ done: herr_t H5FO_top_decr(const H5F_t *f, haddr_t addr) { - H5FO_obj_count_t *obj_count; /* Ref. count for object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FO_obj_count_t *obj_count; /* Ref. count for object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -494,19 +483,19 @@ H5FO_top_decr(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) { + if (NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) { /* Decrement the reference count for the object */ (obj_count->count)--; - if(obj_count->count == 0) { + if (obj_count->count == 0) { /* Remove from container */ - if(NULL == (obj_count = (H5FO_obj_count_t *)H5SL_remove(f->obj_count, &addr))) + if (NULL == (obj_count = (H5FO_obj_count_t *)H5SL_remove(f->obj_count, &addr))) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "can't remove object from container") /* Release the object information */ obj_count = H5FL_FREE(H5FO_obj_count_t, obj_count); } /* end if */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't decrement ref. count") @@ -514,7 +503,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_decr() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_count @@ -537,8 +525,8 @@ done: hsize_t H5FO_top_count(const H5F_t *f, haddr_t addr) { - H5FO_obj_count_t *obj_count; /* Ref. count for object */ - hsize_t ret_value; /* Return value */ + H5FO_obj_count_t *obj_count; /* Ref. count for object */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -548,7 +536,7 @@ H5FO_top_count(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) + if (NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) ret_value = obj_count->count; else ret_value = 0; @@ -556,7 +544,6 @@ H5FO_top_count(const H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_count() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_dest @@ -578,7 +565,7 @@ H5FO_top_count(const H5F_t *f, haddr_t addr) herr_t H5FO_top_dest(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -587,11 +574,11 @@ H5FO_top_dest(H5F_t *f) HDassert(f->obj_count); /* Check if the object count set is empty */ - if(H5SL_count(f->obj_count) != 0) + if (H5SL_count(f->obj_count) != 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "objects still in open object info set") /* Release the open object count set container */ - if(H5SL_close(f->obj_count) < 0) + if (H5SL_close(f->obj_count) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLOSEOBJ, FAIL, "can't close open object info set") f->obj_count = NULL; @@ -599,4 +586,3 @@ H5FO_top_dest(H5F_t *f) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_dest() */ - diff --git a/src/H5FOprivate.h b/src/H5FOprivate.h index 49e8126..e733356 100644 --- a/src/H5FOprivate.h +++ b/src/H5FOprivate.h @@ -22,30 +22,29 @@ #endif /* LATER */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File access */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ +#include "H5SLprivate.h" /* Skip lists */ /* Typedefs */ /* Typedef for open object cache */ -typedef H5SL_t H5FO_t; /* Currently, all open objects are stored in skip list */ +typedef H5SL_t H5FO_t; /* Currently, all open objects are stored in skip list */ /* Macros */ /* Private routines */ -H5_DLL herr_t H5FO_create(const H5F_t *f); -H5_DLL void *H5FO_opened(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag); -H5_DLL herr_t H5FO_delete(H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted); +H5_DLL herr_t H5FO_create(const H5F_t *f); +H5_DLL void * H5FO_opened(const H5F_t *f, haddr_t addr); +H5_DLL herr_t H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag); +H5_DLL herr_t H5FO_delete(H5F_t *f, haddr_t addr); +H5_DLL herr_t H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted); H5_DLL hbool_t H5FO_marked(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_dest(const H5F_t *f); -H5_DLL herr_t H5FO_top_create(H5F_t *f); -H5_DLL herr_t H5FO_top_incr(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_top_decr(const H5F_t *f, haddr_t addr); +H5_DLL herr_t H5FO_dest(const H5F_t *f); +H5_DLL herr_t H5FO_top_create(H5F_t *f); +H5_DLL herr_t H5FO_top_incr(const H5F_t *f, haddr_t addr); +H5_DLL herr_t H5FO_top_decr(const H5F_t *f, haddr_t addr); H5_DLL hsize_t H5FO_top_count(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_top_dest(H5F_t *f); +H5_DLL herr_t H5FO_top_dest(H5F_t *f); #endif /* _H5FOprivate_H */ - diff --git a/src/H5FS.c b/src/H5FS.c index 6d574c0..945eb95 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -25,35 +25,30 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* File free space */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* File free space */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -62,7 +57,6 @@ static herr_t H5FS__sinfo_free_sect_cb(void *item, void *key, void *op_data); static herr_t H5FS__sinfo_free_node_cb(void *item, void *key, void *op_data); - /*********************/ /* Package Variables */ /*********************/ @@ -76,18 +70,14 @@ H5FL_SEQ_DEFINE(H5FS_section_class_t); /* Declare a free list to manage the H5FS_t struct */ H5FL_DEFINE(H5FS_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS_create * @@ -102,15 +92,15 @@ H5FL_DEFINE(H5FS_t); *------------------------------------------------------------------------- */ H5FS_t * -H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, - uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) +H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t nclasses, + const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) { - H5FS_t *fspace = NULL; /* New free space structure */ - H5FS_t *ret_value = NULL; /* Return value */ + H5FS_t *fspace = NULL; /* New free space structure */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, nclasses); + HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, nclasses); #endif /* H5FS_DEBUG */ /* Check arguments. */ @@ -122,28 +112,28 @@ HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, ncl /* * Allocate free space structure */ - if(NULL == (fspace = H5FS__new(f, nclasses, classes, cls_init_udata))) + if (NULL == (fspace = H5FS__new(f, nclasses, classes, cls_init_udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space free list") /* Initialize creation information for free space manager */ - fspace->client = fs_create->client; + fspace->client = fs_create->client; fspace->shrink_percent = fs_create->shrink_percent; fspace->expand_percent = fs_create->expand_percent; - fspace->max_sect_addr = fs_create->max_sect_addr; - fspace->max_sect_size = fs_create->max_sect_size; - fspace->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; + fspace->max_sect_addr = fs_create->max_sect_addr; + fspace->max_sect_size = fs_create->max_sect_size; + fspace->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; - fspace->alignment = alignment; + fspace->alignment = alignment; fspace->align_thres = threshold; /* Check if the free space tracker is supposed to be persistent */ - if(fs_addr) { + if (fs_addr) { /* Allocate space for the free space header */ - if(HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, (hsize_t)fspace->hdr_size))) + if (HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, (hsize_t)fspace->hdr_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "file allocation failed for free space header") /* Cache the new free space header (pinned) */ - if(H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, NULL, "can't add free space header to cache") /* Return free space header address to caller, if desired */ @@ -156,21 +146,20 @@ HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, ncl /* Set the return value */ ret_value = fspace; #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: fspace = %p, fspace->addr = %a\n", FUNC, fspace, fspace->addr); + HDfprintf(stderr, "%s: fspace = %p, fspace->addr = %a\n", FUNC, fspace, fspace->addr); #endif /* H5FS_DEBUG */ done: - if(!ret_value && fspace) - if(H5FS__hdr_dest(fspace) < 0) + if (!ret_value && fspace) + if (H5FS__hdr_dest(fspace) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* H5FS_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_create() */ - /*------------------------------------------------------------------------- * Function: H5FS_open * @@ -185,16 +174,17 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); *------------------------------------------------------------------------- */ H5FS_t * -H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, - const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) +H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, const H5FS_section_class_t *classes[], + void *cls_init_udata, hsize_t alignment, hsize_t threshold) { - H5FS_t *fspace = NULL; /* New free space structure */ - H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - H5FS_t *ret_value = NULL; /* Return value */ + H5FS_t * fspace = NULL; /* New free space structure */ + H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + H5FS_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Opening free space manager, fs_addr = %a, nclasses = %Zu\n", FUNC, fs_addr, nclasses); + HDfprintf(stderr, "%s: Opening free space manager, fs_addr = %a, nclasses = %Zu\n", FUNC, fs_addr, + nclasses); #endif /* H5FS_DEBUG */ /* Check arguments. */ @@ -203,33 +193,34 @@ HDfprintf(stderr, "%s: Opening free space manager, fs_addr = %a, nclasses = %Zu\ HDassert(classes); /* Initialize user data for protecting the free space manager */ - cache_udata.f = f; - cache_udata.nclasses = nclasses; - cache_udata.classes = classes; + cache_udata.f = f; + cache_udata.nclasses = nclasses; + cache_udata.classes = classes; cache_udata.cls_init_udata = cls_init_udata; - cache_udata.addr = fs_addr; + cache_udata.addr = fs_addr; /* Protect the free space header */ - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == + (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, NULL, "unable to load free space header") #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); -HDfprintf(stderr, "%s: fspace->sect_size = %Hu\n", FUNC, fspace->sect_size); -HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu\n", FUNC, fspace->alloc_sect_size); -HDfprintf(stderr, "%s: fspace->sinfo = %p\n", FUNC, fspace->sinfo); -HDfprintf(stderr, "%s: fspace->rc = %u\n", FUNC, fspace->rc); + HDfprintf(stderr, "%s: fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); + HDfprintf(stderr, "%s: fspace->sect_size = %Hu\n", FUNC, fspace->sect_size); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu\n", FUNC, fspace->alloc_sect_size); + HDfprintf(stderr, "%s: fspace->sinfo = %p\n", FUNC, fspace->sinfo); + HDfprintf(stderr, "%s: fspace->rc = %u\n", FUNC, fspace->rc); #endif /* H5FS_DEBUG */ /* Increment the reference count on the free space manager header */ HDassert(fspace->rc <= 1); - if(H5FS__incr(fspace) < 0) + if (H5FS__incr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINC, NULL, "unable to increment ref. count on free space header") - fspace->alignment = alignment; + fspace->alignment = alignment; fspace->align_thres = threshold; /* Unlock free space header */ - if(H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, NULL, "unable to release free space header") /* Set return value */ @@ -239,7 +230,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_open() */ - /*------------------------------------------------------------------------- * Function: H5FS_delete * @@ -255,13 +245,13 @@ done: herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr) { - H5FS_t *fspace = NULL; /* Free space header loaded from file */ - H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t * fspace = NULL; /* Free space header loaded from file */ + H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Deleting free space manager, fs_addr = %a\n", FUNC, fs_addr); + HDfprintf(stderr, "%s: Deleting free space manager, fs_addr = %a\n", FUNC, fs_addr); #endif /* H5FS_DEBUG */ /* Check arguments. */ @@ -270,58 +260,60 @@ HDfprintf(stderr, "%s: Deleting free space manager, fs_addr = %a\n", FUNC, fs_ad /* Initialize user data for protecting the free space manager */ /* (no class information necessary for delete) */ - cache_udata.f = f; - cache_udata.nclasses = 0; - cache_udata.classes = NULL; + cache_udata.f = f; + cache_udata.nclasses = 0; + cache_udata.classes = NULL; cache_udata.cls_init_udata = NULL; - cache_udata.addr = fs_addr; + cache_udata.addr = fs_addr; #ifdef H5FS_DEBUG -{ - unsigned fspace_status = 0; /* Free space section info's status in the metadata cache */ + { + unsigned fspace_status = 0; /* Free space section info's status in the metadata cache */ - /* Sanity check */ - HDassert(H5F_addr_defined(fs_addr)); + /* Sanity check */ + HDassert(H5F_addr_defined(fs_addr)); - /* Check the free space section info's status in the metadata cache */ - if(H5AC_get_entry_status(f, fs_addr, &fspace_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for free space section info") + /* Check the free space section info's status in the metadata cache */ + if (H5AC_get_entry_status(f, fs_addr, &fspace_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to check metadata cache status for free space section info") - HDfprintf(stderr, "%s: fspace_status = %0x: ", FUNC, fspace_status); - if(fspace_status) { - hbool_t printed = FALSE; + HDfprintf(stderr, "%s: fspace_status = %0x: ", FUNC, fspace_status); + if (fspace_status) { + hbool_t printed = FALSE; - if(fspace_status & H5AC_ES__IN_CACHE) { - HDfprintf(stderr, "H5AC_ES__IN_CACHE"); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_DIRTY) { - HDfprintf(stderr, "%sH5AC_ES__IS_DIRTY", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_PROTECTED) { - HDfprintf(stderr, "%sH5AC_ES__IS_PROTECTED", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_PINNED) { - HDfprintf(stderr, "%sH5AC_ES__IS_PINNED", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_FLUSH_DEP_PARENT) { - HDfprintf(stderr, "%sH5AC_ES__IS_FLUSH_DEP_PARENT", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_FLUSH_DEP_CHILD) { - HDfprintf(stderr, "%sH5AC_ES__IS_FLUSH_DEP_CHILD", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - } /* end if */ - HDfprintf(stderr, "\n"); -} + if (fspace_status & H5AC_ES__IN_CACHE) { + HDfprintf(stderr, "H5AC_ES__IN_CACHE"); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_DIRTY) { + HDfprintf(stderr, "%sH5AC_ES__IS_DIRTY", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_PROTECTED) { + HDfprintf(stderr, "%sH5AC_ES__IS_PROTECTED", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_PINNED) { + HDfprintf(stderr, "%sH5AC_ES__IS_PINNED", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_FLUSH_DEP_PARENT) { + HDfprintf(stderr, "%sH5AC_ES__IS_FLUSH_DEP_PARENT", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_FLUSH_DEP_CHILD) { + HDfprintf(stderr, "%sH5AC_ES__IS_FLUSH_DEP_CHILD", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + } /* end if */ + HDfprintf(stderr, "\n"); + } #endif /* H5FS_DEBUG */ /* Protect the free space header */ - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == + (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space header") /* Sanity check */ @@ -329,27 +321,28 @@ HDfprintf(stderr, "%s: Deleting free space manager, fs_addr = %a\n", FUNC, fs_ad /* Delete serialized section storage, if there are any */ #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); + HDfprintf(stderr, "%s: fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); #endif /* H5FS_DEBUG */ - if(fspace->serial_sect_count > 0) { - unsigned sinfo_status = 0; /* Free space section info's status in the metadata cache */ + if (fspace->serial_sect_count > 0) { + unsigned sinfo_status = 0; /* Free space section info's status in the metadata cache */ /* Sanity check */ HDassert(H5F_addr_defined(fspace->sect_addr)); HDassert(fspace->alloc_sect_size > 0); /* Check the free space section info's status in the metadata cache */ - if(H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for free space section info") + if (H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to check metadata cache status for free space section info") /* If the free space section info is in the cache, expunge it now */ - if(sinfo_status & H5AC_ES__IN_CACHE) { + if (sinfo_status & H5AC_ES__IN_CACHE) { /* Sanity checks on direct block */ HDassert(!(sinfo_status & H5AC_ES__IS_PINNED)); HDassert(!(sinfo_status & H5AC_ES__IS_PROTECTED)); #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Expunging free space section info from cache\n", FUNC); + HDfprintf(stderr, "%s: Expunging free space section info from cache\n", FUNC); #endif /* H5FS_DEBUG */ /* Evict the free space section info from the metadata cache */ /* (Free file space) */ @@ -362,33 +355,34 @@ HDfprintf(stderr, "%s: Expunging free space section info from cache\n", FUNC); if (!H5F_IS_TMP_ADDR(f, fspace->sect_addr)) cache_flags |= H5AC__FREE_FILE_SPACE_FLAG; - if(H5AC_expunge_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, cache_flags) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "unable to remove free space section info from cache") + if (H5AC_expunge_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, cache_flags) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, + "unable to remove free space section info from cache") } /* end block */ #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Done expunging free space section info from cache\n", FUNC); -#endif /* H5FS_DEBUG */ + HDfprintf(stderr, "%s: Done expunging free space section info from cache\n", FUNC); +#endif /* H5FS_DEBUG */ } /* end if */ else { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Deleting free space section info from file\n", FUNC); + HDfprintf(stderr, "%s: Deleting free space section info from file\n", FUNC); #endif /* H5FS_DEBUG */ /* Release the space in the file */ - if(!H5F_IS_TMP_ADDR(f, fspace->sect_addr)) - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, fspace->alloc_sect_size) < 0) + if (!H5F_IS_TMP_ADDR(f, fspace->sect_addr)) + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, fspace->alloc_sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to release free space sections") } /* end else */ - } /* end if */ + } /* end if */ done: - if(fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, + H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space header") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_delete() */ - /*------------------------------------------------------------------------- * Function: H5FS_close * @@ -405,7 +399,7 @@ done: herr_t H5FS_close(H5F_t *f, H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -413,64 +407,74 @@ H5FS_close(H5F_t *f, H5FS_t *fspace) HDassert(f); HDassert(fspace); #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Entering, fspace = %p, fspace->addr = %a, fspace->sinfo = %p\n", FUNC, fspace, fspace->addr, fspace->sinfo); + HDfprintf(stderr, "%s: Entering, fspace = %p, fspace->addr = %a, fspace->sinfo = %p\n", FUNC, fspace, + fspace->addr, fspace->sinfo); #endif /* H5FS_DEBUG */ /* Check if section info is valid */ /* (i.e. the header "owns" the section info and it's not in the cache) */ - if(fspace->sinfo) { + if (fspace->sinfo) { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu, fspace->serial_sect_count = %Hu, fspace->sect_addr = %a, fspace->rc = %u\n", FUNC, fspace->tot_sect_count, fspace->serial_sect_count, fspace->sect_addr, fspace->rc); -HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, fspace->alloc_sect_size, fspace->sect_size); + HDfprintf(stderr, + "%s: fspace->tot_sect_count = %Hu, fspace->serial_sect_count = %Hu, fspace->sect_addr = " + "%a, fspace->rc = %u\n", + FUNC, fspace->tot_sect_count, fspace->serial_sect_count, fspace->sect_addr, fspace->rc); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, + fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_DEBUG */ /* If there are sections to serialize, update them */ /* (if the free space manager is persistent) */ - if(fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { + if (fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Real sections to store in file\n", FUNC); + HDfprintf(stderr, "%s: Real sections to store in file\n", FUNC); #endif /* H5FS_DEBUG */ - if(fspace->sinfo->dirty) { + if (fspace->sinfo->dirty) { /* Check if the section info is "floating" */ - if(!H5F_addr_defined(fspace->sect_addr)) { + if (!H5F_addr_defined(fspace->sect_addr)) { /* Sanity check */ HDassert(fspace->sect_size > 0); /* Allocate space for the section info in file */ - if(H5F_USE_TMP_SPACE(f)) { - if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc_tmp(f, fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") + if (H5F_USE_TMP_SPACE(f)) { + if (HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc_tmp(f, fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") } /* end if */ else { - if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") + if (HADDR_UNDEF == + (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") } /* end if */ fspace->alloc_sect_size = (size_t)fspace->sect_size; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") } /* end if */ - } /* end if */ + } /* end if */ else /* Sanity check that section info has address */ HDassert(H5F_addr_defined(fspace->sect_addr)); /* Cache the free space section info */ - if(H5AC_insert_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache") } /* end if */ else { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: NOT storing section info in file\n", FUNC); + HDfprintf(stderr, "%s: NOT storing section info in file\n", FUNC); #endif /* H5FS_DEBUG */ /* Check if space for the section info is allocated */ - if(H5F_addr_defined(fspace->sect_addr)) { + if (H5F_addr_defined(fspace->sect_addr)) { /* Sanity check */ /* (section info should only be in the file if the header is */ HDassert(H5F_addr_defined(fspace->addr)); #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Section info allocated though\n", FUNC); + HDfprintf(stderr, "%s: Section info allocated though\n", FUNC); #endif /* H5FS_DEBUG */ /* Check if the section info is for the free space in the file */ /* (NOTE: This is the "bootstrapping" special case for the @@ -478,75 +482,81 @@ HDfprintf(stderr, "%s: Section info allocated though\n", FUNC); * section info and re-creating it as a section in the * manager. -QAK) */ - if(fspace->client == H5FS_CLIENT_FILE_ID) { - htri_t status; /* "can absorb" status for section into */ + if (fspace->client == H5FS_CLIENT_FILE_ID) { + htri_t status; /* "can absorb" status for section into */ #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Section info is for file free space\n", FUNC); + HDfprintf(stderr, "%s: Section info is for file free space\n", FUNC); #endif /* H5FS_DEBUG */ /* Try to shrink the file or absorb the section info into a block aggregator */ - if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { + if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Section info in temp. address space went 'go away'\n", FUNC); + HDfprintf(stderr, "%s: Section info in temp. address space went 'go away'\n", FUNC); #endif /* H5FS_DEBUG */ /* Reset section info in header */ - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") } /* end if */ else { - if((status = H5MF_try_shrink(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, fspace->alloc_sect_size)) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't check for absorbing section info") - else if(status == FALSE) { + if ((status = H5MF_try_shrink(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, + fspace->alloc_sect_size)) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, + "can't check for absorbing section info") + else if (status == FALSE) { /* Section info can't "go away", but it's free. Allow * header to record it */ #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Section info can't 'go away', header will own it\n", FUNC); -#endif /* H5FS_DEBUG */ + HDfprintf(stderr, "%s: Section info can't 'go away', header will own it\n", FUNC); +#endif /* H5FS_DEBUG */ } /* end if */ else { #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Section info went 'go away'\n", FUNC); + HDfprintf(stderr, "%s: Section info went 'go away'\n", FUNC); #endif /* H5FS_DEBUG */ /* Reset section info in header */ - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { - haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */ - hsize_t old_alloc_sect_size = fspace->alloc_sect_size; /* Previous size of section info in file */ + haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */ + hsize_t old_alloc_sect_size = + fspace->alloc_sect_size; /* Previous size of section info in file */ #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Section info is NOT for file free space\n", FUNC); + HDfprintf(stderr, "%s: Section info is NOT for file free space\n", FUNC); #endif /* H5FS_DEBUG */ /* Reset section info in header */ - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") /* Free previous serialized sections disk space */ - if(!H5F_IS_TMP_ADDR(f, old_sect_addr)) { - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, old_sect_addr, old_alloc_sect_size) < 0) + if (!H5F_IS_TMP_ADDR(f, old_sect_addr)) { + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, old_sect_addr, old_alloc_sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Destroy section info */ - if(H5FS__sinfo_dest(fspace->sinfo) < 0) + if (H5FS__sinfo_dest(fspace->sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "unable to destroy free space section info") } /* end else */ @@ -555,23 +565,22 @@ HDfprintf(stderr, "%s: Section info is NOT for file free space\n", FUNC); } /* end if */ else { /* Just sanity checks... */ - if(fspace->serial_sect_count > 0) + if (fspace->serial_sect_count > 0) /* Sanity check that section info has address */ HDassert(H5F_addr_defined(fspace->sect_addr)); } /* end else */ /* Decrement the reference count on the free space manager header */ - if(H5FS__decr(fspace) < 0) + if (H5FS__decr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEC, FAIL, "unable to decrement ref. count on free space header") done: #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d, fspace->rc = %u\n", FUNC, ret_value, fspace->rc); + HDfprintf(stderr, "%s: Leaving, ret_value = %d, fspace->rc = %u\n", FUNC, ret_value, fspace->rc); #endif /* H5FS_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_close() */ - /*------------------------------------------------------------------------- * Function: H5FS__new * @@ -586,12 +595,11 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d, fspace->rc = %u\n", FUNC, ret_va *------------------------------------------------------------------------- */ H5FS_t * -H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], - void *cls_init_udata) +H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata) { - H5FS_t *fspace = NULL; /* Free space manager */ - size_t u; /* Local index variable */ - H5FS_t *ret_value = NULL; /* Return value */ + H5FS_t *fspace = NULL; /* Free space manager */ + size_t u; /* Local index variable */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -601,17 +609,18 @@ H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes /* * Allocate free space structure */ - if(NULL == (fspace = H5FL_CALLOC(H5FS_t))) + if (NULL == (fspace = H5FL_CALLOC(H5FS_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space free list") /* Set immutable free list parameters */ H5_CHECKED_ASSIGN(fspace->nclasses, uint16_t, nclasses, size_t); - if(nclasses > 0) { - if(NULL == (fspace->sect_cls = H5FL_SEQ_MALLOC(H5FS_section_class_t, nclasses))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space section class array") + if (nclasses > 0) { + if (NULL == (fspace->sect_cls = H5FL_SEQ_MALLOC(H5FS_section_class_t, nclasses))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for free space section class array") /* Initialize the section classes for this free space list */ - for(u = 0; u < nclasses; u++) { + for (u = 0; u < nclasses; u++) { /* Make certain that section class type can be used as an array index into this array */ HDassert(u == classes[u]->type); @@ -619,39 +628,39 @@ H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes H5MM_memcpy(&fspace->sect_cls[u], classes[u], sizeof(H5FS_section_class_t)); /* Call the class initialization routine, if there is one */ - if(fspace->sect_cls[u].init_cls) - if((fspace->sect_cls[u].init_cls)(&fspace->sect_cls[u], cls_init_udata) < 0) + if (fspace->sect_cls[u].init_cls) + if ((fspace->sect_cls[u].init_cls)(&fspace->sect_cls[u], cls_init_udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "unable to initialize section class") /* Determine maximum class-specific serialization size for each section */ - if(fspace->sect_cls[u].serial_size > fspace->max_cls_serial_size) + if (fspace->sect_cls[u].serial_size > fspace->max_cls_serial_size) fspace->max_cls_serial_size = fspace->sect_cls[u].serial_size; } /* end for */ - } /* end if */ + } /* end if */ /* Initialize non-zero information for new free space manager */ - fspace->addr = HADDR_UNDEF; - fspace->hdr_size = (size_t)H5FS_HEADER_SIZE(f); + fspace->addr = HADDR_UNDEF; + fspace->hdr_size = (size_t)H5FS_HEADER_SIZE(f); fspace->sect_addr = HADDR_UNDEF; /* Set return value */ ret_value = fspace; done: - if(!ret_value) - if(fspace) { + if (!ret_value) + if (fspace) { /* Should probably call the class 'term' callback for all classes * that have had their 'init' callback called... -QAK */ - if(fspace->sect_cls) - fspace->sect_cls = (H5FS_section_class_t *)H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); + if (fspace->sect_cls) + fspace->sect_cls = + (H5FS_section_class_t *)H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); fspace = H5FL_FREE(H5FS_t, fspace); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__new() */ - /*------------------------------------------------------------------------- * Function: H5FS_size * @@ -681,7 +690,6 @@ H5FS_size(const H5FS_t *fspace, hsize_t *meta_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__incr * @@ -697,11 +705,11 @@ H5FS_size(const H5FS_t *fspace, hsize_t *meta_size) herr_t H5FS__incr(H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fspace->addr, fspace->rc); + HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fspace->addr, fspace->rc); #endif /* H5FS_DEBUG */ /* @@ -710,8 +718,8 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp HDassert(fspace); /* Check if we should pin the header in the cache */ - if(fspace->rc == 0 && H5F_addr_defined(fspace->addr)) - if(H5AC_pin_protected_entry(fspace) < 0) + if (fspace->rc == 0 && H5F_addr_defined(fspace->addr)) + if (H5AC_pin_protected_entry(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPIN, FAIL, "unable to pin free space header") /* Increment reference count on header */ @@ -721,7 +729,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__incr() */ - /*------------------------------------------------------------------------- * Function: H5FS__decr * @@ -737,11 +744,11 @@ done: herr_t H5FS__decr(H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fspace->addr, fspace->rc); + HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fspace->addr, fspace->rc); #endif /* H5FS_DEBUG */ /* @@ -753,22 +760,21 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp fspace->rc--; /* Check if we should unpin the header in the cache */ - if(fspace->rc == 0) { - if(H5F_addr_defined(fspace->addr)) { - if(H5AC_unpin_entry(fspace) < 0) + if (fspace->rc == 0) { + if (H5F_addr_defined(fspace->addr)) { + if (H5AC_unpin_entry(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin free space header") } /* end if */ else { - if(H5FS__hdr_dest(fspace) < 0) + if (H5FS__hdr_dest(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "unable to destroy free space header") } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__decr() */ - /*------------------------------------------------------------------------- * Function: H5FS__dirty * @@ -784,27 +790,26 @@ done: herr_t H5FS__dirty(H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE #ifdef QAK -HDfprintf(stderr, "%s: Marking free space header as dirty\n", FUNC); + HDfprintf(stderr, "%s: Marking free space header as dirty\n", FUNC); #endif /* QAK */ /* Sanity check */ HDassert(fspace); /* Check if the free space manager is persistent */ - if(H5F_addr_defined(fspace->addr)) + if (H5F_addr_defined(fspace->addr)) /* Mark header as dirty in cache */ - if(H5AC_mark_entry_dirty(fspace) < 0) + if (H5AC_mark_entry_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__dirty() */ - /*------------------------------------------------------------------------- * Function: H5FS_alloc_hdr() * @@ -820,7 +825,7 @@ done: herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -828,24 +833,23 @@ H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr) HDassert(f); HDassert(fspace); - if(!H5F_addr_defined(fspace->addr)) { + if (!H5F_addr_defined(fspace->addr)) { /* Allocate space for the free space header */ - if(HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, (hsize_t)H5FS_HEADER_SIZE(f)))) + if (HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, (hsize_t)H5FS_HEADER_SIZE(f)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for free space header") /* Cache the new free space header (pinned) */ - if(H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space header to cache") } /* end if */ - if(fs_addr) + if (fs_addr) *fs_addr = fspace->addr; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_alloc_hdr() */ - /*------------------------------------------------------------------------- * Function: H5FS_alloc_sect() * @@ -861,7 +865,7 @@ done: herr_t H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -869,17 +873,17 @@ H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace) HDassert(f); HDassert(fspace); - if(!H5F_addr_defined(fspace->sect_addr) && fspace->sinfo && fspace->serial_sect_count > 0) { - if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + if (!H5F_addr_defined(fspace->sect_addr) && fspace->sinfo && fspace->serial_sect_count > 0) { + if (HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for section info") fspace->alloc_sect_size = fspace->sect_size; /* Mark free-space header as dirty */ - if(H5FS__dirty(fspace) < 0) + if (H5FS__dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") /* Cache the free-space section info */ - if(H5AC_insert_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache") /* Since space has been allocated for the section info and the sinfo @@ -893,7 +897,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_alloc_sect() */ - /*------------------------------------------------------------------------- * Function: H5FS_free() * @@ -909,9 +912,9 @@ done: herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space) { - haddr_t saved_addr; /* Previous address of item */ - unsigned cache_flags; /* Flags for unprotecting cache entries */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t saved_addr; /* Previous address of item */ + unsigned cache_flags; /* Flags for unprotecting cache entries */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -919,85 +922,89 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space) HDassert(f); HDassert(fspace); - cache_flags = H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG;; + cache_flags = H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; + ; /* Free space for section info */ - if(H5F_addr_defined(fspace->sect_addr)) { - hsize_t saved_size; /* Size of previous section info */ - unsigned sinfo_status = 0; /* Section info cache status */ + if (H5F_addr_defined(fspace->sect_addr)) { + hsize_t saved_size; /* Size of previous section info */ + unsigned sinfo_status = 0; /* Section info cache status */ /* Check whether free-space manager section info is in cache or not */ - if(H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to check metadata cache status for free-space section info") + if (H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, + "unable to check metadata cache status for free-space section info") /* Load free-space manager section info */ - if(sinfo_status & H5AC_ES__IN_CACHE || !fspace->sinfo) { - H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */ + if (sinfo_status & H5AC_ES__IN_CACHE || !fspace->sinfo) { + H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */ /* Protect the free space sections */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.fspace = fspace; - if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info") + if (NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, + &cache_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info") /* Unload and release ownership of the free-space manager section info */ - if(H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") } /* end if */ saved_addr = fspace->sect_addr; saved_size = fspace->alloc_sect_size; - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* Free space for the free-space manager section info */ - if(!H5F_IS_TMP_ADDR(f, saved_addr)) { - if(free_file_space && - H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, saved_addr, saved_size) < 0) + if (!H5F_IS_TMP_ADDR(f, saved_addr)) { + if (free_file_space && H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, saved_addr, saved_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to release free space sections") } /* end if */ /* Mark free-space manager header as dirty */ - if(H5FS__dirty(fspace) < 0) + if (H5FS__dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } /* end if */ /* Free space for header */ - if(H5F_addr_defined(fspace->addr)) { - unsigned hdr_status = 0; /* Header entry status */ + if (H5F_addr_defined(fspace->addr)) { + unsigned hdr_status = 0; /* Header entry status */ /* Check whether free-space manager header is in cache or not */ - if(H5AC_get_entry_status(f, fspace->addr, &hdr_status) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to check metadata cache status for free-space section info") + if (H5AC_get_entry_status(f, fspace->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, + "unable to check metadata cache status for free-space section info") - if(hdr_status & H5AC_ES__IN_CACHE) { + if (hdr_status & H5AC_ES__IN_CACHE) { H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ /* Protect the free-space manager header */ /* (no class information necessary since it's in the cache) */ - cache_udata.f = f; - cache_udata.nclasses = 0; - cache_udata.classes = NULL; + cache_udata.f = f; + cache_udata.nclasses = 0; + cache_udata.classes = NULL; cache_udata.cls_init_udata = NULL; - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fspace->addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info") + if (NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fspace->addr, &cache_udata, + H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info") /* Unpin the free-space manager header */ - if(H5AC_unpin_entry(fspace) < 0) + if (H5AC_unpin_entry(fspace) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap header") /* Unload and release ownership of the free-space header */ - if(H5AC_unprotect(f, H5AC_FSPACE_HDR, fspace->addr, fspace, cache_flags) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_HDR, fspace->addr, fspace, cache_flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") } /* end if */ - saved_addr = fspace->addr; + saved_addr = fspace->addr; fspace->addr = HADDR_UNDEF; /* Free space for the free-space manager header */ - if(free_file_space && - H5MF_xfree(f, H5FD_MEM_FSPACE_HDR, saved_addr, (hsize_t)H5FS_HEADER_SIZE(f)) < 0) + if (free_file_space && + H5MF_xfree(f, H5FD_MEM_FSPACE_HDR, saved_addr, (hsize_t)H5FS_HEADER_SIZE(f)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space header") } /* end if */ @@ -1005,7 +1012,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_free() */ - /*------------------------------------------------------------------------- * Function: H5FS__hdr_dest * @@ -1021,8 +1027,8 @@ done: herr_t H5FS__hdr_dest(H5FS_t *fspace) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1032,15 +1038,15 @@ H5FS__hdr_dest(H5FS_t *fspace) HDassert(fspace); /* Terminate the section classes for this free space list */ - for(u = 0; u < fspace->nclasses ; u++) { + for (u = 0; u < fspace->nclasses; u++) { /* Call the class termination routine, if there is one */ - if(fspace->sect_cls[u].term_cls) - if((fspace->sect_cls[u].term_cls)(&fspace->sect_cls[u]) < 0) + if (fspace->sect_cls[u].term_cls) + if ((fspace->sect_cls[u].term_cls)(&fspace->sect_cls[u]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "unable to finalize section class") } /* end for */ /* Release the memory for the free space section classes */ - if(fspace->sect_cls) + if (fspace->sect_cls) fspace->sect_cls = (H5FS_section_class_t *)H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); /* Free free space info */ @@ -1050,7 +1056,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__hdr_dest() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_free_sect_cb * @@ -1066,8 +1071,8 @@ done: static herr_t H5FS__sinfo_free_sect_cb(void *_sect, void H5_ATTR_UNUSED *key, void *op_data) { - H5FS_section_info_t *sect = (H5FS_section_info_t *)_sect; /* Section to free */ - const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)op_data; /* Free space manager for section */ + H5FS_section_info_t *sect = (H5FS_section_info_t *)_sect; /* Section to free */ + const H5FS_sinfo_t * sinfo = (const H5FS_sinfo_t *)op_data; /* Free space manager for section */ FUNC_ENTER_STATIC_NOERR @@ -1078,9 +1083,8 @@ H5FS__sinfo_free_sect_cb(void *_sect, void H5_ATTR_UNUSED *key, void *op_data) (*sinfo->fspace->sect_cls[sect->type].free)(sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5FS__sinfo_free_sect_cb() */ +} /* H5FS__sinfo_free_sect_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_free_node_cb * @@ -1096,7 +1100,7 @@ H5FS__sinfo_free_sect_cb(void *_sect, void H5_ATTR_UNUSED *key, void *op_data) static herr_t H5FS__sinfo_free_node_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) { - H5FS_node_t *fspace_node = (H5FS_node_t *)item; /* Temporary pointer to free space list node */ + H5FS_node_t *fspace_node = (H5FS_node_t *)item; /* Temporary pointer to free space list node */ FUNC_ENTER_STATIC_NOERR @@ -1110,9 +1114,8 @@ H5FS__sinfo_free_node_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) fspace_node = H5FL_FREE(H5FS_node_t, fspace_node); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5FS__sinfo_free_node_cb() */ +} /* H5FS__sinfo_free_node_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_dest * @@ -1128,8 +1131,8 @@ H5FS__sinfo_free_node_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) herr_t H5FS__sinfo_dest(H5FS_sinfo_t *sinfo) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1141,8 +1144,8 @@ H5FS__sinfo_dest(H5FS_sinfo_t *sinfo) HDassert(sinfo->bins); /* Clear out lists of nodes */ - for(u = 0; u < sinfo->nbins; u++) - if(sinfo->bins[u].bin_list) { + for (u = 0; u < sinfo->nbins; u++) + if (sinfo->bins[u].bin_list) { H5SL_destroy(sinfo->bins[u].bin_list, H5FS__sinfo_free_node_cb, sinfo); sinfo->bins[u].bin_list = NULL; } /* end if */ @@ -1151,8 +1154,8 @@ H5FS__sinfo_dest(H5FS_sinfo_t *sinfo) sinfo->bins = H5FL_SEQ_FREE(H5FS_bin_t, sinfo->bins); /* Release skip list for merging sections */ - if(sinfo->merge_list) - if(H5SL_close(sinfo->merge_list) < 0) + if (sinfo->merge_list) + if (H5SL_close(sinfo->merge_list) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy section merging skip list") /* Decrement the reference count on free space header */ @@ -1160,7 +1163,7 @@ H5FS__sinfo_dest(H5FS_sinfo_t *sinfo) * disappearing immediately) */ sinfo->fspace->sinfo = NULL; - if(H5FS__decr(sinfo->fspace) < 0) + if (H5FS__decr(sinfo->fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEC, FAIL, "unable to decrement ref. count on free space header") sinfo->fspace = NULL; @@ -1189,7 +1192,7 @@ H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count) } #ifdef H5FS_DEBUG_ASSERT - + /*------------------------------------------------------------------------- * Function: H5FS__assert * @@ -1207,11 +1210,11 @@ H5FS__assert(const H5FS_t *fspace) { FUNC_ENTER_PACKAGE_NOERR #ifdef QAK -HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__assert", fspace->tot_sect_count); + HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__assert", fspace->tot_sect_count); #endif /* QAK */ /* Checks for section info, if it's available */ - if(fspace->sinfo) { + if (fspace->sinfo) { /* Sanity check sections */ H5FS__sect_assert(fspace); @@ -1231,4 +1234,3 @@ HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__assert", fspace-> FUNC_LEAVE_NOAPI_VOID } /* end H5FS__assert() */ #endif /* H5FS_DEBUG_ASSERT */ - diff --git a/src/H5FScache.c b/src/H5FScache.c index 214e6aa..4f10001 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -26,31 +26,28 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File */ -#include "H5FSpkg.h" /* File free space */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File */ +#include "H5FSpkg.h" /* File free space */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* File free space format version #'s */ -#define H5FS_HDR_VERSION 0 /* Header */ -#define H5FS_SINFO_VERSION 0 /* Serialized sections */ - +#define H5FS_HDR_VERSION 0 /* Header */ +#define H5FS_SINFO_VERSION 0 /* Serialized sections */ /******************/ /* Local Typedefs */ @@ -58,17 +55,15 @@ /* User data for skip list iterator callback for iterating over section size nodes when syncing */ typedef struct { - H5FS_sinfo_t *sinfo; /* Free space section info */ - uint8_t **image; /* Pointer to address of buffer pointer to serialize with */ - unsigned sect_cnt_size; /* # of bytes to encode section size counts in */ + H5FS_sinfo_t *sinfo; /* Free space section info */ + uint8_t ** image; /* Pointer to address of buffer pointer to serialize with */ + unsigned sect_cnt_size; /* # of bytes to encode section size counts in */ } H5FS_iter_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -80,83 +75,74 @@ static herr_t H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *ke /* Metadata cache callbacks */ static herr_t H5FS__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FS__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5FS__cache_hdr_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5FS__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FS__cache_hdr_image_len(const void *thing, size_t *image_len); -static herr_t H5FS__cache_hdr_pre_serialize(H5F_t *f, void *thing, haddr_t addr, - size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); -static herr_t H5FS__cache_hdr_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5FS__cache_hdr_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr, size_t *new_len, unsigned *flags); +static herr_t H5FS__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *thing); static herr_t H5FS__cache_hdr_free_icr(void *thing); static herr_t H5FS__cache_sinfo_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FS__cache_sinfo_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5FS__cache_sinfo_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5FS__cache_sinfo_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FS__cache_sinfo_image_len(const void *thing, size_t *image_len); -static herr_t H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); -static herr_t H5FS__cache_sinfo_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr, size_t *new_len, unsigned *flags); +static herr_t H5FS__cache_sinfo_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *thing); static herr_t H5FS__cache_sinfo_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5FS header inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FSPACE_HDR[1] = {{ - H5AC_FSPACE_HDR_ID, /* Metadata client ID */ - "Free Space Header", /* Metadata client name (for debugging) */ - H5FD_MEM_FSPACE_HDR, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5FS__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FS__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5FS__cache_hdr_deserialize, /* 'deserialize' callback */ - H5FS__cache_hdr_image_len, /* 'image_len' callback */ - H5FS__cache_hdr_pre_serialize, /* 'pre_serialize' callback */ - H5FS__cache_hdr_serialize, /* 'serialize' callback */ - H5FS__cache_hdr_notify, /* 'notify' callback */ - H5FS__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_FSPACE_HDR_ID, /* Metadata client ID */ + "Free Space Header", /* Metadata client name (for debugging) */ + H5FD_MEM_FSPACE_HDR, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5FS__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FS__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5FS__cache_hdr_deserialize, /* 'deserialize' callback */ + H5FS__cache_hdr_image_len, /* 'image_len' callback */ + H5FS__cache_hdr_pre_serialize, /* 'pre_serialize' callback */ + H5FS__cache_hdr_serialize, /* 'serialize' callback */ + H5FS__cache_hdr_notify, /* 'notify' callback */ + H5FS__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5FS section info inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FSPACE_SINFO[1] = {{ - H5AC_FSPACE_SINFO_ID, /* Metadata client ID */ - "Free Space Section Info", /* Metadata client name (for debugging) */ - H5FD_MEM_FSPACE_SINFO, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5FS__cache_sinfo_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FS__cache_sinfo_verify_chksum, /* 'verify_chksum' callback */ - H5FS__cache_sinfo_deserialize, /* 'deserialize' callback */ - H5FS__cache_sinfo_image_len, /* 'image_len' callback */ - H5FS__cache_sinfo_pre_serialize, /* 'pre_serialize' callback */ - H5FS__cache_sinfo_serialize, /* 'serialize' callback */ - H5FS__cache_sinfo_notify, /* 'notify' callback */ - H5FS__cache_sinfo_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_FSPACE_SINFO_ID, /* Metadata client ID */ + "Free Space Section Info", /* Metadata client name (for debugging) */ + H5FD_MEM_FSPACE_SINFO, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5FS__cache_sinfo_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FS__cache_sinfo_verify_chksum, /* 'verify_chksum' callback */ + H5FS__cache_sinfo_deserialize, /* 'deserialize' callback */ + H5FS__cache_sinfo_image_len, /* 'image_len' callback */ + H5FS__cache_sinfo_pre_serialize, /* 'pre_serialize' callback */ + H5FS__cache_sinfo_serialize, /* 'serialize' callback */ + H5FS__cache_sinfo_notify, /* 'notify' callback */ + H5FS__cache_sinfo_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_get_initial_load_size * @@ -188,7 +174,6 @@ H5FS__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_verify_chksum * @@ -205,10 +190,10 @@ H5FS__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) htri_t H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -218,13 +203,12 @@ H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_deserialize * @@ -244,14 +228,14 @@ H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE */ static void * H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) + hbool_t H5_ATTR_UNUSED *dirty) { - H5FS_t *fspace = NULL; /* Free space header info */ - H5FS_hdr_cache_ud_t *udata = (H5FS_hdr_cache_ud_t *)_udata; /* User data for callback */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned nclasses; /* Number of section classes */ - H5FS_t *ret_value = NULL; /* Return value */ + H5FS_t * fspace = NULL; /* Free space header info */ + H5FS_hdr_cache_ud_t *udata = (H5FS_hdr_cache_ud_t *)_udata; /* User data for callback */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + unsigned nclasses; /* Number of section classes */ + H5FS_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -261,24 +245,24 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len HDassert(udata->f); /* Allocate a new free space manager */ - if(NULL == (fspace = H5FS__new(udata->f, udata->nclasses, udata->classes, udata->cls_init_udata))) + if (NULL == (fspace = H5FS__new(udata->f, udata->nclasses, udata->classes, udata->cls_init_udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set free space manager's internal information */ fspace->addr = udata->addr; /* Magic number */ - if(HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5FS_HDR_VERSION) + if (*image++ != H5FS_HDR_VERSION) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header version") /* Client ID */ fspace->client = (H5FS_client_t)*image++; - if(fspace->client >= H5FS_NUM_CLIENT_ID) + if (fspace->client >= H5FS_NUM_CLIENT_ID) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "unknown client ID in free space header") /* Total space tracked */ @@ -296,7 +280,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len /* # of section classes */ /* (only check if we actually have some classes) */ UINT16DECODE(image, nclasses); - if(fspace->nclasses > 0 && nclasses > fspace->nclasses) + if (fspace->nclasses > 0 && nclasses > fspace->nclasses) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "section class count mismatch") /* Shrink percent */ @@ -335,14 +319,13 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len done: /* Release resources */ - if(!ret_value && fspace) - if(H5FS__hdr_dest(fspace) < 0) + if (!ret_value && fspace) + if (H5FS__hdr_dest(fspace) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_image_len * @@ -360,7 +343,7 @@ done: static herr_t H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len) { - const H5FS_t *fspace = (const H5FS_t *)_thing; /* Pointer to the object */ + const H5FS_t *fspace = (const H5FS_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -376,7 +359,6 @@ H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_pre_serialize * @@ -405,13 +387,13 @@ H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, - haddr_t addr, size_t H5_ATTR_UNUSED len, haddr_t H5_ATTR_NDEBUG_UNUSED *new_addr, - size_t H5_ATTR_NDEBUG_UNUSED *new_len, unsigned *flags) +H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ATTR_UNUSED len, + haddr_t H5_ATTR_NDEBUG_UNUSED *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len, + unsigned *flags) { - H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t * fspace = (H5FS_t *)_thing; /* Pointer to the object */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -425,11 +407,11 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert(new_len); HDassert(flags); - if(fspace->sinfo) { + if (fspace->sinfo) { H5AC_ring_t ring; /* Retrieve the ring type for the header */ - if(H5AC_get_entry_ring(f, addr, &ring) < 0) + if (H5AC_get_entry_ring(f, addr, &ring) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to get property value"); /* Set the ring type for the section info in the API context */ @@ -513,11 +495,11 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * as dirty, as the metadata cache would not be attempting to * serialize the header if it thought it was clean. */ - if(fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { + if (fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { /* Sanity check */ HDassert(fspace->sect_size > 0); - if(!H5F_addr_defined(fspace->sect_addr)) { /* case 1 */ + if (!H5F_addr_defined(fspace->sect_addr)) { /* case 1 */ haddr_t tag = HADDR_UNDEF; haddr_t sect_addr; hsize_t saved_sect_size, new_sect_size; @@ -526,35 +508,41 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * into the metadata cache. */ saved_sect_size = fspace->sect_size; - if(HADDR_UNDEF == (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") + if (HADDR_UNDEF == + (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") /* fspace->sect_size may change in size after H5MF_alloc(). * If increased in size, free the previous allocation and * allocate again with the bigger fspace->sect_size. */ - if(fspace->sect_size > saved_sect_size) { + if (fspace->sect_size > saved_sect_size) { new_sect_size = fspace->sect_size; - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, sect_addr, saved_sect_size) < 0) + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, sect_addr, saved_sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections") - if(HADDR_UNDEF == (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, new_sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") - fspace->sect_size = new_sect_size; + if (HADDR_UNDEF == + (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, new_sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") + fspace->sect_size = new_sect_size; fspace->alloc_sect_size = new_sect_size; - } else { + } + else { fspace->alloc_sect_size = saved_sect_size; - fspace->sect_size = saved_sect_size; + fspace->sect_size = saved_sect_size; } fspace->sect_addr = sect_addr; /* Get the tag for this free space manager and use it to insert the entry */ - if(H5AC_get_tag((const void *)fspace, &tag) < 0) + if (H5AC_get_tag((const void *)fspace, &tag) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTTAG, FAIL, "can't get tag for metadata cache object") H5_BEGIN_TAG(tag) - if(H5AC_insert_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR_TAG(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache") H5_END_TAG @@ -564,8 +552,8 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * so set fspace->sinfo to NULL. */ fspace->sinfo = NULL; - } /* end if */ - else if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { /* case 2 */ + } /* end if */ + else if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { /* case 2 */ haddr_t new_sect_addr; /* move the section info from temporary (AKA imaginary) file @@ -580,18 +568,20 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size); /* Allocate space for the section info in file */ - if(HADDR_UNDEF == (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") + if (HADDR_UNDEF == + (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") fspace->alloc_sect_size = (size_t)fspace->sect_size; HDassert(fspace->sinfo->cache_info.size == fspace->alloc_sect_size); /* Let the metadata cache know the section info moved */ - if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0) + if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move section info") fspace->sect_addr = new_sect_addr; - } /* end else-if */ + } /* end else-if */ else { /* case 3 -- nothing to do but sanity checking */ /* if my reading of the code is correct, this should always * be the case. If not, we will have to add code to resize @@ -600,15 +590,15 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert(fspace->sect_size > 0); HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size); } /* end else */ - } /* end else */ + } /* end else */ else { /* for one reason or another (see comment above) there should * not be any file space allocated for the section info. */ - HDassert(!H5F_addr_defined(fspace->sect_addr)); + HDassert(!H5F_addr_defined(fspace->sect_addr)); } /* end else */ - } /* end if */ - else if(H5F_addr_defined(fspace->sect_addr)) { + } /* end if */ + else if (H5F_addr_defined(fspace->sect_addr)) { /* Here the metadata cache is managing the section info. * * Do some sanity checks, and then test to see if the section @@ -616,14 +606,14 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * real file space lest the header be written to file with * a nonsense section info address. */ - if(!H5F_POINT_OF_NO_RETURN(f)) { + if (!H5F_POINT_OF_NO_RETURN(f)) { HDassert(fspace->sect_size > 0); HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size); } /* end if */ - if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { + if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { unsigned sect_status = 0; - haddr_t new_sect_addr; + haddr_t new_sect_addr; /* we have work to do -- must relocate section info into * real file space. @@ -633,7 +623,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * cache. Further, since fspace->sinfo is NULL, it must be * unprotected and un-pinned. Start by verifying this. */ - if(H5AC_get_entry_status(f, fspace->sect_addr, §_status) < 0) + if (H5AC_get_entry_status(f, fspace->sect_addr, §_status) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info status") HDassert(sect_status & H5AC_ES__IN_CACHE); @@ -641,7 +631,8 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert((sect_status & H5AC_ES__IS_PINNED) == 0); /* Allocate space for the section info in file */ - if(HADDR_UNDEF == (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + if (HADDR_UNDEF == + (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") fspace->alloc_sect_size = (size_t)fspace->sect_size; @@ -650,7 +641,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert(!H5F_addr_eq(fspace->sect_addr, new_sect_addr)); /* Let the metadata cache know the section info moved */ - if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0) + if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMOVE, FAIL, "unable to move section info") /* Update the internal address for the section info */ @@ -659,9 +650,9 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, /* No need to mark the header dirty, as we are about to * serialize it. */ - } /* end if */ - } /* end else-if */ - else { /* there is no section info at present */ + } /* end if */ + } /* end else-if */ + else { /* there is no section info at present */ /* do some sanity checks */ HDassert(fspace->serial_sect_count == 0); HDassert(fspace->tot_sect_count == fspace->ghost_sect_count); @@ -672,13 +663,12 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_serialize * @@ -696,13 +686,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t * fspace = (H5FS_t *)_thing; /* Pointer to the object */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -722,12 +711,11 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN * into real file space if necessary before this function was called. * The following asserts are a cursory check on this. */ - HDassert((! H5F_addr_defined(fspace->sect_addr)) || (! H5F_IS_TMP_ADDR(f, fspace->sect_addr))); + HDassert((!H5F_addr_defined(fspace->sect_addr)) || (!H5F_IS_TMP_ADDR(f, fspace->sect_addr))); - if(!H5F_POINT_OF_NO_RETURN(f)) - HDassert((! H5F_addr_defined(fspace->sect_addr)) || - ((fspace->sect_size > 0) && - (fspace->alloc_sect_size == (size_t)fspace->sect_size))); + if (!H5F_POINT_OF_NO_RETURN(f)) + HDassert((!H5F_addr_defined(fspace->sect_addr)) || + ((fspace->sect_size > 0) && (fspace->alloc_sect_size == (size_t)fspace->sect_size))); /* Magic number */ H5MM_memcpy(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); @@ -789,7 +777,6 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_notify * @@ -806,8 +793,8 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN herr_t H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) { - H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -815,7 +802,7 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) HDassert(fspace); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -823,7 +810,7 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) break; case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: - if(H5AC_unsettle_entry_ring(fspace) < 0) + if (H5AC_unsettle_entry_ring(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFLUSH, FAIL, "unable to mark FSM ring as unsettled") break; @@ -839,16 +826,15 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) default: #ifdef NDEBUG HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS__cache_hdr_notify() */ +} /* end H5FS__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_free_icr * @@ -870,8 +856,8 @@ done: static herr_t H5FS__cache_hdr_free_icr(void *_thing) { - H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -884,14 +870,13 @@ H5FS__cache_hdr_free_icr(void *_thing) HDassert(!fspace->sinfo); /* Destroy free space header */ - if(H5FS__hdr_dest(fspace) < 0) + if (H5FS__hdr_dest(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_get_initial_load_size() * @@ -907,9 +892,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len) +H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len) { - const H5FS_t *fspace; /* free space manager */ + const H5FS_t * fspace; /* free space manager */ H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -927,7 +912,6 @@ H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS__cache_sinfo_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_verify_chksum * @@ -944,10 +928,10 @@ H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len) htri_t H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -957,13 +941,12 @@ H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_deserialize * @@ -982,17 +965,17 @@ H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU */ static void * H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_NDEBUG_UNUSED *dirty) + hbool_t H5_ATTR_NDEBUG_UNUSED *dirty) { - H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */ - H5FS_t *fspace; /* free space manager */ - H5FS_sinfo_t *sinfo = NULL; /* Free space section info */ - haddr_t fs_addr; /* Free space header address */ - size_t old_sect_size; /* Old section size */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - const uint8_t *chksum_image; /* Points to chksum location */ - uint32_t stored_chksum; /* Stored metadata checksum */ - void * ret_value = NULL; /* Return value */ + H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */ + H5FS_t * fspace; /* free space manager */ + H5FS_sinfo_t * sinfo = NULL; /* Free space section info */ + haddr_t fs_addr; /* Free space header address */ + size_t old_sect_size; /* Old section size */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t * chksum_image; /* Points to chksum location */ + uint32_t stored_chksum; /* Stored metadata checksum */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1005,52 +988,53 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HDassert(dirty); /* Allocate a new free space section info */ - if(NULL == (sinfo = H5FS__sinfo_new(udata->f, fspace))) + if (NULL == (sinfo = H5FS__sinfo_new(udata->f, fspace))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* initialize old_sect_size */ H5_CHECKED_ASSIGN(old_sect_size, size_t, fspace->sect_size, hsize_t); /* Magic number */ - if(HDmemcmp(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5FS_SINFO_VERSION) + if (*image++ != H5FS_SINFO_VERSION) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections version") /* Address of free space header for these sections */ H5F_addr_decode(udata->f, &image, &fs_addr); - if(H5F_addr_ne(fs_addr, fspace->addr)) + if (H5F_addr_ne(fs_addr, fspace->addr)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "incorrect header address for free space sections") /* Check for any serialized sections */ - if(fspace->serial_sect_count > 0) { - hsize_t old_tot_sect_count; /* Total section count from header */ - hsize_t H5_ATTR_NDEBUG_UNUSED old_serial_sect_count; /* Total serializable section count from header */ + if (fspace->serial_sect_count > 0) { + hsize_t old_tot_sect_count; /* Total section count from header */ + hsize_t H5_ATTR_NDEBUG_UNUSED + old_serial_sect_count; /* Total serializable section count from header */ hsize_t H5_ATTR_NDEBUG_UNUSED old_ghost_sect_count; /* Total ghost section count from header */ hsize_t H5_ATTR_NDEBUG_UNUSED old_tot_space; /* Total space managed from header */ - unsigned sect_cnt_size; /* The size of the section size counts */ + unsigned sect_cnt_size; /* The size of the section size counts */ /* Compute the size of the section counts */ sect_cnt_size = H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count); /* Reset the section count, the "add" routine will update it */ - old_tot_sect_count = fspace->tot_sect_count; - old_serial_sect_count = fspace->serial_sect_count; - old_ghost_sect_count = fspace->ghost_sect_count; - old_tot_space = fspace->tot_space; - fspace->tot_sect_count = 0; + old_tot_sect_count = fspace->tot_sect_count; + old_serial_sect_count = fspace->serial_sect_count; + old_ghost_sect_count = fspace->ghost_sect_count; + old_tot_space = fspace->tot_space; + fspace->tot_sect_count = 0; fspace->serial_sect_count = 0; - fspace->ghost_sect_count = 0; - fspace->tot_space = 0; + fspace->ghost_sect_count = 0; + fspace->tot_space = 0; /* Walk through the image, deserializing sections */ do { - hsize_t sect_size = 0; /* Current section size */ - size_t node_count = 0; /* # of sections of this size */ - size_t u; /* Local index variable */ + hsize_t sect_size = 0; /* Current section size */ + size_t node_count = 0; /* # of sections of this size */ + size_t u; /* Local index variable */ /* The number of sections of this node's size */ UINT64DECODE_VAR(image, node_count, sect_cnt_size); @@ -1061,11 +1045,11 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HDassert(sect_size); /* Loop over nodes of this size */ - for(u = 0; u < node_count; u++) { - H5FS_section_info_t *new_sect; /* Section that was deserialized */ - haddr_t sect_addr = 0; /* Address of free space section in the address space */ - unsigned sect_type; /* Type of free space section */ - unsigned des_flags; /* Flags from deserialize callback */ + for (u = 0; u < node_count; u++) { + H5FS_section_info_t *new_sect; /* Section that was deserialized */ + haddr_t sect_addr = 0; /* Address of free space section in the address space */ + unsigned sect_type; /* Type of free space section */ + unsigned des_flags; /* Flags from deserialize callback */ /* The address of the section */ UINT64DECODE_VAR(image, sect_addr, sinfo->sect_off_size); @@ -1076,22 +1060,24 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l /* Call 'deserialize' callback for this section */ des_flags = 0; HDassert(fspace->sect_cls[sect_type].deserialize); - if(NULL == (new_sect = (*fspace->sect_cls[sect_type].deserialize) (&fspace->sect_cls[sect_type], image, sect_addr, sect_size, &des_flags))) + if (NULL == (new_sect = (*fspace->sect_cls[sect_type].deserialize)( + &fspace->sect_cls[sect_type], image, sect_addr, sect_size, &des_flags))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDECODE, NULL, "can't deserialize section") /* Update offset in serialization image */ image += fspace->sect_cls[sect_type].serial_size; /* Insert section in free space manager, unless requested not to */ - if(!(des_flags & H5FS_DESERIALIZE_NO_ADD)) - if(H5FS_sect_add(udata->f, fspace, new_sect, H5FS_ADD_DESERIALIZING, udata) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, NULL, "can't add section to free space manager") + if (!(des_flags & H5FS_DESERIALIZE_NO_ADD)) + if (H5FS_sect_add(udata->f, fspace, new_sect, H5FS_ADD_DESERIALIZING, udata) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, NULL, + "can't add section to free space manager") } /* end for */ - if(fspace->tot_sect_count == old_tot_sect_count) + if (fspace->tot_sect_count == old_tot_sect_count) break; - } while(image < (((const uint8_t *)_image + old_sect_size) - H5FS_SIZEOF_CHKSUM)); + } while (image < (((const uint8_t *)_image + old_sect_size) - H5FS_SIZEOF_CHKSUM)); /* Sanity check */ HDassert((size_t)(image - (const uint8_t *)_image) <= (old_sect_size - H5FS_SIZEOF_CHKSUM)); @@ -1111,20 +1097,19 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l /* Sanity check */ HDassert((image == chksum_image) || - ((size_t)((image - (const uint8_t *)_image) + (chksum_image - image)) == old_sect_size)); + ((size_t)((image - (const uint8_t *)_image) + (chksum_image - image)) == old_sect_size)); /* Set return value */ ret_value = sinfo; done: - if(!ret_value && sinfo) - if(H5FS__sinfo_dest(sinfo) < 0) + if (!ret_value && sinfo) + if (H5FS__sinfo_dest(sinfo) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_image_len * @@ -1142,7 +1127,7 @@ done: static herr_t H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) { - const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)_thing; /* Pointer to the object */ + const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -1161,7 +1146,6 @@ H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS__cache_sinfo_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_pre_serialize * @@ -1179,14 +1163,13 @@ H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, - size_t H5_ATTR_NDEBUG_UNUSED len, haddr_t *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len, - unsigned *flags) +H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ATTR_NDEBUG_UNUSED len, + haddr_t *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len, unsigned *flags) { - H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ - H5FS_t *fspace; /* Free space header */ - haddr_t sinfo_addr; /* Address for section info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ + H5FS_t * fspace; /* Free space header */ + haddr_t sinfo_addr; /* Address for section info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1209,13 +1192,13 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, sinfo_addr = addr; /* this will change if we relocate the section data */ /* Check for section info at temporary address */ - if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { + if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { /* Sanity check */ HDassert(fspace->sect_size > 0); HDassert(H5F_addr_eq(fspace->sect_addr, addr)); /* Allocate space for the section info in file */ - if(HADDR_UNDEF == (sinfo_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + if (HADDR_UNDEF == (sinfo_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") fspace->alloc_sect_size = (size_t)fspace->sect_size; @@ -1224,20 +1207,20 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, HDassert(!H5F_addr_eq(sinfo->fspace->sect_addr, sinfo_addr)); /* Let the metadata cache know the section info moved */ - if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, sinfo->fspace->sect_addr, sinfo_addr) < 0) + if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, sinfo->fspace->sect_addr, sinfo_addr) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMOVE, FAIL, "unable to move section info") /* Update the internal address for the section info */ sinfo->fspace->sect_addr = sinfo_addr; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) + if (H5AC_mark_entry_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } /* end if */ - if(!H5F_addr_eq(addr, sinfo_addr)) { + if (!H5F_addr_eq(addr, sinfo_addr)) { *new_addr = sinfo_addr; - *flags = H5C__SERIALIZE_MOVED_FLAG; + *flags = H5C__SERIALIZE_MOVED_FLAG; } /* end if */ else *flags = 0; @@ -1246,7 +1229,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_serialize * @@ -1264,16 +1246,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, - void *_thing) +H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, void *_thing) { - H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ - H5FS_iter_ud_t udata; /* User data for callbacks */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t *chksum_image = NULL; /* Points to chksum location */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - unsigned bin; /* Current bin we are on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_t * sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ + H5FS_iter_ud_t udata; /* User data for callbacks */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t * chksum_image = NULL; /* Points to chksum location */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + unsigned bin; /* Current bin we are on */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1300,23 +1281,22 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, H5F_addr_encode(f, &image, sinfo->fspace->addr); /* Set up user data for iterator */ - udata.sinfo = sinfo; - udata.image = ℑ + udata.sinfo = sinfo; + udata.image = ℑ udata.sect_cnt_size = H5VM_limit_enc_size((uint64_t)sinfo->fspace->serial_sect_count); /* Iterate over all the bins */ - for(bin = 0; bin < sinfo->nbins; bin++) + for (bin = 0; bin < sinfo->nbins; bin++) /* Check if there are any sections in this bin */ - if(sinfo->bins[bin].bin_list) + if (sinfo->bins[bin].bin_list) /* Iterate over list of section size nodes for bin */ - if(H5SL_iterate(sinfo->bins[bin].bin_list, H5FS__sinfo_serialize_node_cb, &udata) < 0) + if (H5SL_iterate(sinfo->bins[bin].bin_list, H5FS__sinfo_serialize_node_cb, &udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section size nodes") - /* Compute checksum */ /* There may be empty space between entries and chksum */ - chksum_image = (uint8_t *)(_image) + len - H5FS_SIZEOF_CHKSUM; + chksum_image = (uint8_t *)(_image) + len - H5FS_SIZEOF_CHKSUM; metadata_chksum = H5_checksum_metadata(_image, (size_t)(chksum_image - (uint8_t *)_image), 0); /* Metadata checksum */ UINT32ENCODE(chksum_image, metadata_chksum); @@ -1330,7 +1310,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_notify * @@ -1346,8 +1325,8 @@ done: herr_t H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing) { - H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1355,17 +1334,20 @@ H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing) HDassert(sinfo); /* Check if the file was opened with SWMR-write access */ - if(sinfo->fspace->swmr_write) { + if (sinfo->fspace->swmr_write) { /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5FS__create_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)sinfo->fspace->sect_addr) + if (H5FS__create_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0) + HGOTO_ERROR( + H5E_FSPACE, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block and header, address = %llu", + (unsigned long long)sinfo->fspace->sect_addr) break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: @@ -1376,25 +1358,24 @@ H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing) break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5FS__destroy_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0) + /* Destroy flush dependency on parent */ + if (H5FS__destroy_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS__cache_sinfo_notify() */ +} /* end H5FS__cache_sinfo_notify() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_free_icr * @@ -1416,8 +1397,8 @@ done: static herr_t H5FS__cache_sinfo_free_icr(void *_thing) { - H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1430,14 +1411,13 @@ H5FS__cache_sinfo_free_icr(void *_thing) HDassert(sinfo->fspace->cache_info.is_pinned); /* Destroy free space info */ - if(H5FS__sinfo_dest(sinfo) < 0) + if (H5FS__sinfo_dest(sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_serialize_sect_cb * @@ -1454,10 +1434,10 @@ done: static herr_t H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { - H5FS_section_class_t *sect_cls; /* Class of section */ - H5FS_section_info_t *sect= (H5FS_section_info_t *)_item; /* Free space section to work on */ - H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_section_class_t *sect_cls; /* Class of section */ + H5FS_section_info_t * sect = (H5FS_section_info_t *)_item; /* Free space section to work on */ + H5FS_iter_ud_t * udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1470,7 +1450,7 @@ H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat sect_cls = &udata->sinfo->fspace->sect_cls[sect->type]; /* Check if this section should be serialized (i.e. is not a ghost section) */ - if(!(sect_cls->flags & H5FS_CLS_GHOST_OBJ)) { + if (!(sect_cls->flags & H5FS_CLS_GHOST_OBJ)) { /* The address of the section */ UINT64ENCODE_VAR(*udata->image, sect->addr, udata->sinfo->sect_off_size); @@ -1478,8 +1458,8 @@ H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat *(*udata->image)++ = (uint8_t)sect->type; /* Call 'serialize' callback for this section */ - if(sect_cls->serialize) { - if((*sect_cls->serialize)(sect_cls, sect, *udata->image) < 0) + if (sect_cls->serialize) { + if ((*sect_cls->serialize)(sect_cls, sect, *udata->image) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTSERIALIZE, FAIL, "can't synchronize section") /* Update offset in serialization buffer */ @@ -1493,7 +1473,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_serialize_sect_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_serialize_node_cb * @@ -1510,9 +1489,9 @@ done: static herr_t H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { - H5FS_node_t *fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ - H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_node_t * fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ + H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1522,7 +1501,7 @@ H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat HDassert(udata->image); /* Check if this node has any serializable sections */ - if(fspace_node->serial_count > 0) { + if (fspace_node->serial_count > 0) { /* The number of serializable sections of this node's size */ UINT64ENCODE_VAR(*udata->image, fspace_node->serial_count, udata->sect_cnt_size); @@ -1531,11 +1510,10 @@ H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat /* Iterate through all the sections of this size */ HDassert(fspace_node->sect_list); - if(H5SL_iterate(fspace_node->sect_list, H5FS__sinfo_serialize_sect_cb, udata) < 0) + if (H5SL_iterate(fspace_node->sect_list, H5FS__sinfo_serialize_sect_cb, udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section nodes") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_serialize_node_cb() */ - diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c index c615b68..d7a986a 100644 --- a/src/H5FSdbg.c +++ b/src/H5FSdbg.c @@ -26,56 +26,47 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ -#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ -#define H5MF_DEBUGGING /* Need access to file space debugging routines */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ +#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ +#define H5MF_DEBUGGING /* Need access to file space debugging routines */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* File free space */ -#include "H5HFprivate.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* File free space */ +#include "H5HFprivate.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5FS_debug * @@ -91,9 +82,9 @@ herr_t H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) { - H5FS_t *fspace = NULL; /* Free space header info */ - H5FS_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t * fspace = NULL; /* Free space header info */ + H5FS_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -107,16 +98,17 @@ H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) HDassert(fwidth >= 0); /* Initialize user data for protecting the free space manager */ - cache_udata.f = f; - cache_udata.nclasses = 0; - cache_udata.classes = NULL; + cache_udata.f = f; + cache_udata.nclasses = 0; + cache_udata.classes = NULL; cache_udata.cls_init_udata = NULL; - cache_udata.addr = addr; + cache_udata.addr = addr; /* * Load the free space header. */ - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == + (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header") /* Print opening message */ @@ -125,55 +117,37 @@ H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Free space client:", - (fspace->client == H5FS_CLIENT_FHEAP_ID ? "Fractal heap" : - (fspace->client == H5FS_CLIENT_FILE_ID ? "File" : "Unknown"))); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Total free space tracked:", - fspace->tot_space); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Free space client:", + (fspace->client == H5FS_CLIENT_FHEAP_ID + ? "Fractal heap" + : (fspace->client == H5FS_CLIENT_FILE_ID ? "File" : "Unknown"))); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Total free space tracked:", fspace->tot_space); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Total number of free space sections tracked:", - fspace->tot_sect_count); + "Total number of free space sections tracked:", fspace->tot_sect_count); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of serializable free space sections tracked:", - fspace->serial_sect_count); + "Number of serializable free space sections tracked:", fspace->serial_sect_count); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of ghost free space sections tracked:", - fspace->ghost_sect_count); + "Number of ghost free space sections tracked:", fspace->ghost_sect_count); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of free space section classes:", - (unsigned)fspace->nclasses); - HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, - "Shrink percent:", - fspace->shrink_percent); - HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, - "Expand percent:", - fspace->expand_percent); + "Number of free space section classes:", (unsigned)fspace->nclasses); + HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, "Shrink percent:", fspace->shrink_percent); + HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, "Expand percent:", fspace->expand_percent); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "# of bits for section address space:", - fspace->max_sect_addr); + "# of bits for section address space:", fspace->max_sect_addr); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Maximum section size:", fspace->max_sect_size); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Serialized sections address:", fspace->sect_addr); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Maximum section size:", - fspace->max_sect_size); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Serialized sections address:", - fspace->sect_addr); + "Serialized sections size used:", fspace->sect_size); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Serialized sections size used:", - fspace->sect_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Serialized sections size allocated:", - fspace->alloc_sect_size); + "Serialized sections size allocated:", fspace->alloc_sect_size); done: - if(fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, addr, fspace, H5AC__NO_FLAGS_SET) < 0) + if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, addr, fspace, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_debug() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_debug * @@ -189,7 +163,7 @@ done: herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *stream, int indent, int fwidth) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -203,15 +177,14 @@ H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *str HDassert(fwidth >= 0); /* Call the section's debugging routine */ - if(fspace->sect_cls[sect->type].debug) - if((fspace->sect_cls[sect->type].debug)(sect, stream, indent, fwidth) < 0) + if (fspace->sect_cls[sect->type].debug) + if ((fspace->sect_cls[sect->type].debug)(sect, stream, indent, fwidth) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't dump section's debugging info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_sect_debug() */ - /*------------------------------------------------------------------------- * Function: H5FS_sects_debug * @@ -225,13 +198,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, - haddr_t fs_addr, haddr_t client_addr) +H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, haddr_t fs_addr, + haddr_t client_addr) { - H5FS_t *fspace = NULL; /* Free space header info */ - H5FS_client_t client; /* The client of the free space */ - H5FS_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t * fspace = NULL; /* Free space header info */ + H5FS_client_t client; /* The client of the free space */ + H5FS_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -247,16 +220,17 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent HDassert(H5F_addr_defined(client_addr)); /* Initialize user data for protecting the free space manager */ - cache_udata.f = f; - cache_udata.nclasses = 0; - cache_udata.classes = NULL; + cache_udata.f = f; + cache_udata.nclasses = 0; + cache_udata.classes = NULL; cache_udata.cls_init_udata = NULL; - cache_udata.addr = fs_addr; + cache_udata.addr = fs_addr; /* * Load the free space header. */ - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == + (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header") /* Retrieve the client id */ @@ -266,7 +240,7 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent /* (set the "deleted" flag for the unprotect, so the cache entry is removed * and reloaded later, with the correct client information -QAK) */ - if(H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__DELETED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__DELETED_FLAG) < 0) HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") fspace = NULL; @@ -276,14 +250,14 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent /* * Print the values. */ - switch(client) { + switch (client) { case H5FS_CLIENT_FHEAP_ID: - if(H5HF_sects_debug(f, client_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0) + if (H5HF_sects_debug(f, client_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_SYSTEM, FAIL, "unable to dump fractal heap free space sections") break; case H5FS_CLIENT_FILE_ID: - if(H5MF_sects_debug(f, fs_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0) + if (H5MF_sects_debug(f, fs_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_SYSTEM, FAIL, "unable to dump file free space sections") break; @@ -294,9 +268,8 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent } /* end switch */ done: - if(fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) + if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_sects_debug() */ - diff --git a/src/H5FSint.c b/src/H5FSint.c index 6ba5748..41c8176 100644 --- a/src/H5FSint.c +++ b/src/H5FSint.c @@ -26,57 +26,47 @@ /* Module Declaration */ /**********************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error Handling */ -#include "H5FSpkg.h" /* Free Space Managers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5FSpkg.h" /* Free Space Managers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5FS_init * @@ -94,7 +84,7 @@ herr_t H5FS_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR /* FUNC_ENTER() does all the work */ @@ -102,7 +92,6 @@ H5FS_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_init() */ - /*------------------------------------------------------------------------- * Function: H5FS__create_flush_depend * @@ -118,7 +107,7 @@ H5FS_init(void) herr_t H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -127,14 +116,13 @@ H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) HDassert(child_entry); /* Create a flush dependency between parent and child entry */ - if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS__create_flush_depend() */ +} /* end H5FS__create_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5FS__destroy_flush_depend * @@ -150,7 +138,7 @@ done: herr_t H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -159,10 +147,9 @@ H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) HDassert(child_entry); /* Destroy a flush dependency between parent and child entry */ - if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS__destroy_flush_depend() */ - +} /* end H5FS__destroy_flush_depend() */ diff --git a/src/H5FSmodule.h b/src/H5FSmodule.h index b2869dd..434e30c 100644 --- a/src/H5FSmodule.h +++ b/src/H5FSmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5FS_MODULE -#define H5_MY_PKG H5FS -#define H5_MY_PKG_ERR H5E_FSPACE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5FS +#define H5_MY_PKG_ERR H5E_FSPACE +#define H5_MY_PKG_INIT NO #endif /* _H5FSmodule_H */ - diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 2c56ab6..09e2c7c 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -36,90 +36,89 @@ /* #define H5FS_DEBUG_ASSERT */ /* Get package's private header */ -#include "H5FSprivate.h" /* File free space */ +#include "H5FSprivate.h" /* File free space */ /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Size of checksum information (on disk) */ -#define H5FS_SIZEOF_CHKSUM 4 +#define H5FS_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for free space metadata */ -#define H5FS_METADATA_PREFIX_SIZE ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + 1 /* Version */ \ - + H5FS_SIZEOF_CHKSUM /* Metadata checksum */ \ +#define H5FS_METADATA_PREFIX_SIZE \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + 1 /* Version */ \ + + H5FS_SIZEOF_CHKSUM /* Metadata checksum */ \ ) /* Size of the fractal heap header on disk */ -#define H5FS_HEADER_SIZE(f) ( \ - /* General metadata fields */ \ - H5FS_METADATA_PREFIX_SIZE \ - \ - /* Free space header specific fields */ \ - + 1 /* Client ID */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Total free space tracked */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Total # of sections tracked */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* # of serializable sections tracked */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* # of ghost sections tracked */ \ - + 2 /* Number of section classes */ \ - + 2 /* Shrink percent */ \ - + 2 /* Expand percent */ \ - + 2 /* Size of address space for sections (log2 of value) */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Max. size of section to track */ \ - + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of serialized free space sections */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Size of serialized free space sections used */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Allocated size of serialized free space sections */ \ +#define H5FS_HEADER_SIZE(f) \ + (/* General metadata fields */ \ + H5FS_METADATA_PREFIX_SIZE \ + \ + /* Free space header specific fields */ \ + + 1 /* Client ID */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Total free space tracked */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Total # of sections tracked */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* # of serializable sections tracked */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* # of ghost sections tracked */ \ + + 2 /* Number of section classes */ \ + + 2 /* Shrink percent */ \ + + 2 /* Expand percent */ \ + + 2 /* Size of address space for sections (log2 of value) */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Max. size of section to track */ \ + + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of serialized free space sections */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Size of serialized free space sections used */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Allocated size of serialized free space sections */ \ ) /* Size of the free space serialized sections on disk */ -#define H5FS_SINFO_PREFIX_SIZE(f) ( \ - /* General metadata fields */ \ - H5FS_METADATA_PREFIX_SIZE \ - \ - /* Free space serialized sections specific fields */ \ - + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of free space header for these sections */ \ +#define H5FS_SINFO_PREFIX_SIZE(f) \ + (/* General metadata fields */ \ + H5FS_METADATA_PREFIX_SIZE \ + \ + /* Free space serialized sections specific fields */ \ + + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of free space header for these sections */ \ ) - /****************************/ /* Package Private Typedefs */ /****************************/ /* Callback info for loading a free space header into the cache */ typedef struct H5FS_hdr_cache_ud_t { - H5F_t *f; /* File that free space header is within */ - uint16_t nclasses; /* Number of section classes */ - const H5FS_section_class_t **classes; /* Array of section class info */ - void *cls_init_udata; /* Pointer to class init user data */ - haddr_t addr; /* Address of header */ + H5F_t * f; /* File that free space header is within */ + uint16_t nclasses; /* Number of section classes */ + const H5FS_section_class_t **classes; /* Array of section class info */ + void * cls_init_udata; /* Pointer to class init user data */ + haddr_t addr; /* Address of header */ } H5FS_hdr_cache_ud_t; /* Callback info for loading free space section info into the cache */ typedef struct H5FS_sinfo_cache_ud_t { - H5F_t *f; /* File that free space section info is within */ - H5FS_t *fspace; /* free space manager */ + H5F_t * f; /* File that free space section info is within */ + H5FS_t *fspace; /* free space manager */ } H5FS_sinfo_cache_ud_t; /* Free space section bin info */ typedef struct H5FS_bin_t { - size_t tot_sect_count; /* Total # of sections in this bin */ - size_t serial_sect_count; /* # of serializable sections in this bin */ - size_t ghost_sect_count; /* # of un-serializable sections in this bin */ - H5SL_t *bin_list; /* Skip list of differently sized sections */ + size_t tot_sect_count; /* Total # of sections in this bin */ + size_t serial_sect_count; /* # of serializable sections in this bin */ + size_t ghost_sect_count; /* # of un-serializable sections in this bin */ + H5SL_t *bin_list; /* Skip list of differently sized sections */ } H5FS_bin_t; /* Free space node for free space sections of the same size */ typedef struct H5FS_node_t { - hsize_t sect_size; /* Size of all sections on list */ - size_t serial_count; /* # of serializable sections on list */ - size_t ghost_count; /* # of un-serializable sections on list */ - H5SL_t *sect_list; /* Skip list to hold pointers to actual free list section node */ + hsize_t sect_size; /* Size of all sections on list */ + size_t serial_count; /* # of serializable sections on list */ + size_t ghost_count; /* # of un-serializable sections on list */ + H5SL_t *sect_list; /* Skip list to hold pointers to actual free list section node */ } H5FS_node_t; /* Free space section info */ @@ -127,23 +126,23 @@ typedef struct H5FS_sinfo_t { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; -/* Stored information */ - H5FS_bin_t *bins; /* Array of lists of lists of free sections */ + /* Stored information */ + H5FS_bin_t *bins; /* Array of lists of lists of free sections */ -/* Computed/cached values */ - hbool_t dirty; /* Whether this info in memory is out of sync w/info in file */ + /* Computed/cached values */ + hbool_t dirty; /* Whether this info in memory is out of sync w/info in file */ unsigned nbins; /* Number of bins */ - size_t serial_size; /* Total size of all serializable sections */ - size_t tot_size_count; /* Total number of differently sized sections */ - size_t serial_size_count; /* Total number of differently sized serializable sections */ - size_t ghost_size_count; /* Total number of differently sized un-serializable sections */ + size_t serial_size; /* Total size of all serializable sections */ + size_t tot_size_count; /* Total number of differently sized sections */ + size_t serial_size_count; /* Total number of differently sized serializable sections */ + size_t ghost_size_count; /* Total number of differently sized un-serializable sections */ unsigned sect_prefix_size; /* Size of the section serialization prefix (in bytes) */ unsigned sect_off_size; /* Size of a section offset (in bytes) */ unsigned sect_len_size; /* Size of a section length (in bytes) */ - H5FS_t *fspace; /* Pointer to free space manager that owns sections */ + H5FS_t * fspace; /* Pointer to free space manager that owns sections */ -/* Memory data structures (not stored directly) */ - H5SL_t *merge_list; /* Skip list to hold sections for detecting merges */ + /* Memory data structures (not stored directly) */ + H5SL_t *merge_list; /* Skip list to hold sections for detecting merges */ } H5FS_sinfo_t; /* Free space header info */ @@ -151,48 +150,46 @@ struct H5FS_t { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; -/* Stored information */ + /* Stored information */ /* Statistics about sections managed */ - hsize_t tot_space; /* Total amount of space tracked */ - hsize_t tot_sect_count; /* Total # of sections tracked */ - hsize_t serial_sect_count; /* # of serializable sections tracked */ - hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ + hsize_t tot_space; /* Total amount of space tracked */ + hsize_t tot_sect_count; /* Total # of sections tracked */ + hsize_t serial_sect_count; /* # of serializable sections tracked */ + hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ /* Creation parameters */ - H5FS_client_t client; /* Type of user of this free space manager */ - uint16_t nclasses; /* Number of section classes handled */ - unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ - unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ - unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ - hsize_t max_sect_size; /* Maximum size of section to track */ + H5FS_client_t client; /* Type of user of this free space manager */ + uint16_t nclasses; /* Number of section classes handled */ + unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ + unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ + unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ + hsize_t max_sect_size; /* Maximum size of section to track */ /* Serialized section information */ - haddr_t sect_addr; /* Address of the section info in the file */ - hsize_t sect_size; /* Size of the section info in the file */ - hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ - -/* Computed/cached values */ - unsigned rc; /* Count of outstanding references to struct */ - haddr_t addr; /* Address of free space header on disk */ - size_t hdr_size; /* Size of free space header on disk */ - H5FS_sinfo_t *sinfo; /* Section information */ - hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ - unsigned sinfo_lock_count; /* # of times the section info has been locked */ - hbool_t sinfo_protected; /* Whether the section info was protected when locked */ - hbool_t sinfo_modified; /* Whether the section info has been modified while locked */ - unsigned sinfo_accmode; /* Access mode for protecting the section info */ - /* must be either H5C__NO_FLAGS_SET (i.e r/w) */ - /* or H5AC__READ_ONLY_FLAG (i.e. r/o). */ - size_t max_cls_serial_size; /* Max. additional size of serialized form of section */ - hsize_t alignment; /* Alignment */ - hsize_t align_thres; /* Threshold for alignment */ - - -/* Memory data structures (not stored directly) */ + haddr_t sect_addr; /* Address of the section info in the file */ + hsize_t sect_size; /* Size of the section info in the file */ + hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ + + /* Computed/cached values */ + unsigned rc; /* Count of outstanding references to struct */ + haddr_t addr; /* Address of free space header on disk */ + size_t hdr_size; /* Size of free space header on disk */ + H5FS_sinfo_t *sinfo; /* Section information */ + hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ + unsigned sinfo_lock_count; /* # of times the section info has been locked */ + hbool_t sinfo_protected; /* Whether the section info was protected when locked */ + hbool_t sinfo_modified; /* Whether the section info has been modified while locked */ + unsigned sinfo_accmode; /* Access mode for protecting the section info */ + /* must be either H5C__NO_FLAGS_SET (i.e r/w) */ + /* or H5AC__READ_ONLY_FLAG (i.e. r/o). */ + size_t max_cls_serial_size; /* Max. additional size of serialized form of section */ + hsize_t alignment; /* Alignment */ + hsize_t align_thres; /* Threshold for alignment */ + + /* Memory data structures (not stored directly) */ H5FS_section_class_t *sect_cls; /* Array of section classes for this free list */ }; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -209,7 +206,6 @@ H5FL_EXTERN(H5FS_sinfo_t); /* Declare a free list to manage the H5FS_t struct */ H5FL_EXTERN(H5FS_t); - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -219,11 +215,11 @@ H5_DLL herr_t H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t * H5_DLL herr_t H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Free space manager header routines */ -H5_DLL H5FS_t *H5FS__new(const H5F_t *f, uint16_t nclasses, - const H5FS_section_class_t *classes[], void *cls_init_udata); -H5_DLL herr_t H5FS__incr(H5FS_t *fspace); -H5_DLL herr_t H5FS__decr(H5FS_t *fspace); -H5_DLL herr_t H5FS__dirty(H5FS_t *fspace); +H5_DLL H5FS_t *H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], + void *cls_init_udata); +H5_DLL herr_t H5FS__incr(H5FS_t *fspace); +H5_DLL herr_t H5FS__decr(H5FS_t *fspace); +H5_DLL herr_t H5FS__dirty(H5FS_t *fspace); /* Free space section routines */ H5_DLL H5FS_sinfo_t *H5FS__sinfo_new(H5F_t *f, H5FS_t *fspace); @@ -241,8 +237,7 @@ H5_DLL void H5FS__sect_assert(const H5FS_t *fspace); /* Testing routines */ #ifdef H5FS_TESTING H5_DLL herr_t H5FS__get_cparam_test(const H5FS_t *fh, H5FS_create_t *cparam); -H5_DLL int H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2); +H5_DLL int H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2); #endif /* H5FS_TESTING */ #endif /* _H5FSpkg_H */ - diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index 07152ba..1c8d45b 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -26,55 +26,63 @@ #define _H5FSprivate_H /* Private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Library Private Macros */ /**************************/ /* Flags for H5FS_section_class_t 'flags' field */ -#define H5FS_CLS_GHOST_OBJ 0x01 /* Objects in this class shouldn't be - * serialized to the file. - */ -#define H5FS_CLS_SEPAR_OBJ 0x02 /* Objects in this class shouldn't - * participate in merge operations. - */ -#define H5FS_CLS_MERGE_SYM 0x04 /* Objects in this class only merge - * with other objects in this class. - */ -#define H5FS_CLS_ADJUST_OK 0x08 /* Objects in this class can be merged - * without requiring a can_adjust/adjust - * callback pair. - */ +#define H5FS_CLS_GHOST_OBJ \ + 0x01 /* Objects in this class shouldn't be \ + * serialized to the file. \ + */ +#define H5FS_CLS_SEPAR_OBJ \ + 0x02 /* Objects in this class shouldn't \ + * participate in merge operations. \ + */ +#define H5FS_CLS_MERGE_SYM \ + 0x04 /* Objects in this class only merge \ + * with other objects in this class. \ + */ +#define H5FS_CLS_ADJUST_OK \ + 0x08 /* Objects in this class can be merged \ + * without requiring a can_adjust/adjust \ + * callback pair. \ + */ /* Flags for H5FS_add() */ -#define H5FS_ADD_DESERIALIZING 0x01 /* Free space is being deserialized - */ -#define H5FS_ADD_RETURNED_SPACE 0x02 /* Section was previously allocated - * and is being returned to the - * free space manager (usually - * as a result of freeing an - * object) - */ -#define H5FS_ADD_SKIP_VALID 0x04 /* Don't check validity after adding - * this section. (state of the - * managed sections is in flux) - */ - -#define H5FS_PAGE_END_NO_ADD 0x08 /* For "small" page fs: - * Don't add section to free space: - * when the section is at page end and - * when the section size is <= "small" - */ +#define H5FS_ADD_DESERIALIZING \ + 0x01 /* Free space is being deserialized \ + */ +#define H5FS_ADD_RETURNED_SPACE \ + 0x02 /* Section was previously allocated \ + * and is being returned to the \ + * free space manager (usually \ + * as a result of freeing an \ + * object) \ + */ +#define H5FS_ADD_SKIP_VALID \ + 0x04 /* Don't check validity after adding \ + * this section. (state of the \ + * managed sections is in flux) \ + */ + +#define H5FS_PAGE_END_NO_ADD \ + 0x08 /* For "small" page fs: \ + * Don't add section to free space: \ + * when the section is at page end and \ + * when the section size is <= "small" \ + */ /* Flags for deserialize callback */ -#define H5FS_DESERIALIZE_NO_ADD 0x01 /* Don't add section to free space - * manager after it's deserialized - * (its only here for it's side- - * effects). - */ - +#define H5FS_DESERIALIZE_NO_ADD \ + 0x01 /* Don't add section to free space \ + * manager after it's deserialized \ + * (its only here for it's side- \ + * effects). \ + */ /****************************/ /* Library Private Typedefs */ @@ -89,77 +97,84 @@ typedef struct H5FS_section_info_t H5FS_section_info_t; /* Free space section class info */ typedef struct H5FS_section_class_t { /* Class variables */ - const unsigned type; /* Type of free space section */ - size_t serial_size; /* Size of serialized form of section */ - unsigned flags; /* Class flags */ - void *cls_private; /* Class private information */ + const unsigned type; /* Type of free space section */ + size_t serial_size; /* Size of serialized form of section */ + unsigned flags; /* Class flags */ + void * cls_private; /* Class private information */ /* Class methods */ - herr_t (*init_cls)(struct H5FS_section_class_t *, void *); /* Routine to initialize class-specific settings */ - herr_t (*term_cls)(struct H5FS_section_class_t *); /* Routine to terminate class-specific settings */ + herr_t (*init_cls)(struct H5FS_section_class_t *, + void *); /* Routine to initialize class-specific settings */ + herr_t (*term_cls)(struct H5FS_section_class_t *); /* Routine to terminate class-specific settings */ /* Object methods */ - herr_t (*add)(H5FS_section_info_t **, unsigned *, void *); /* Routine called when section is about to be added to manager */ - herr_t (*serialize)(const struct H5FS_section_class_t *, const H5FS_section_info_t *, uint8_t *); /* Routine to serialize a "live" section into a buffer */ - H5FS_section_info_t *(*deserialize)(const struct H5FS_section_class_t *, const uint8_t *, haddr_t, hsize_t, unsigned *); /* Routine to deserialize a buffer into a "live" section */ - htri_t (*can_merge)(const H5FS_section_info_t *, const H5FS_section_info_t *, void *); /* Routine to determine if two nodes are mergable */ - herr_t (*merge)(H5FS_section_info_t **, H5FS_section_info_t *, void *); /* Routine to merge two nodes */ - htri_t (*can_shrink)(const H5FS_section_info_t *, void *); /* Routine to determine if node can shrink container */ - herr_t (*shrink)(H5FS_section_info_t **, void *); /* Routine to shrink container */ - herr_t (*free)(H5FS_section_info_t *); /* Routine to free node */ - herr_t (*valid)(const struct H5FS_section_class_t *, const H5FS_section_info_t *); /* Routine to check if a section is valid */ - H5FS_section_info_t *(*split)(H5FS_section_info_t *, hsize_t); /* Routine to create the split section */ - herr_t (*debug)(const H5FS_section_info_t *, FILE *, int , int ); /* Routine to dump debugging information about a section */ + herr_t (*add)(H5FS_section_info_t **, unsigned *, + void *); /* Routine called when section is about to be added to manager */ + herr_t (*serialize)(const struct H5FS_section_class_t *, const H5FS_section_info_t *, + uint8_t *); /* Routine to serialize a "live" section into a buffer */ + H5FS_section_info_t *(*deserialize)( + const struct H5FS_section_class_t *, const uint8_t *, haddr_t, hsize_t, + unsigned *); /* Routine to deserialize a buffer into a "live" section */ + htri_t (*can_merge)(const H5FS_section_info_t *, const H5FS_section_info_t *, + void *); /* Routine to determine if two nodes are mergable */ + herr_t (*merge)(H5FS_section_info_t **, H5FS_section_info_t *, void *); /* Routine to merge two nodes */ + htri_t (*can_shrink)(const H5FS_section_info_t *, + void *); /* Routine to determine if node can shrink container */ + herr_t (*shrink)(H5FS_section_info_t **, void *); /* Routine to shrink container */ + herr_t (*free)(H5FS_section_info_t *); /* Routine to free node */ + herr_t (*valid)(const struct H5FS_section_class_t *, + const H5FS_section_info_t *); /* Routine to check if a section is valid */ + H5FS_section_info_t *(*split)(H5FS_section_info_t *, hsize_t); /* Routine to create the split section */ + herr_t (*debug)(const H5FS_section_info_t *, FILE *, int, + int); /* Routine to dump debugging information about a section */ } H5FS_section_class_t; /* State of section ("live" or "serialized") */ typedef enum H5FS_section_state_t { - H5FS_SECT_LIVE, /* Section has "live" memory references */ - H5FS_SECT_SERIALIZED /* Section is in "serialized" form */ + H5FS_SECT_LIVE, /* Section has "live" memory references */ + H5FS_SECT_SERIALIZED /* Section is in "serialized" form */ } H5FS_section_state_t; /* Free space section info */ struct H5FS_section_info_t { - haddr_t addr; /* Offset of free space section in the address space */ - hsize_t size; /* Size of free space section */ - unsigned type; /* Type of free space section (i.e. class) */ - H5FS_section_state_t state; /* Whether the section is in "serialized" or "live" form */ + haddr_t addr; /* Offset of free space section in the address space */ + hsize_t size; /* Size of free space section */ + unsigned type; /* Type of free space section (i.e. class) */ + H5FS_section_state_t state; /* Whether the section is in "serialized" or "live" form */ }; /* Free space client IDs for identifying user of free space */ typedef enum H5FS_client_t { - H5FS_CLIENT_FHEAP_ID = 0, /* Free space is used by fractal heap */ - H5FS_CLIENT_FILE_ID, /* Free space is used by file */ - H5FS_CLIENT_MD_VFD_ID, /* Free space is used by the metadata file for VFD SWMR */ - H5FS_NUM_CLIENT_ID /* Number of free space client IDs (must be last) */ + H5FS_CLIENT_FHEAP_ID = 0, /* Free space is used by fractal heap */ + H5FS_CLIENT_FILE_ID, /* Free space is used by file */ + H5FS_CLIENT_MD_VFD_ID, /* Free space is used by the metadata file for VFD SWMR */ + H5FS_NUM_CLIENT_ID /* Number of free space client IDs (must be last) */ } H5FS_client_t; /* Free space creation parameters */ typedef struct H5FS_create_t { - H5FS_client_t client; /* Client's ID */ - unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ - unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ - unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ - hsize_t max_sect_size; /* Maximum size of section to track */ + H5FS_client_t client; /* Client's ID */ + unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ + unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ + unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ + hsize_t max_sect_size; /* Maximum size of section to track */ } H5FS_create_t; /* Free space statistics info */ typedef struct H5FS_stat_t { - hsize_t tot_space; /* Total amount of space tracked */ - hsize_t tot_sect_count; /* Total # of sections tracked */ - hsize_t serial_sect_count; /* # of serializable sections tracked */ - hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ - haddr_t addr; /* Address of free space header on disk */ - hsize_t hdr_size; /* Size of the free-space header on disk */ - haddr_t sect_addr; /* Address of the section info in the file */ - hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ - hsize_t sect_size; /* Size of the section info in the file */ + hsize_t tot_space; /* Total amount of space tracked */ + hsize_t tot_sect_count; /* Total # of sections tracked */ + hsize_t serial_sect_count; /* # of serializable sections tracked */ + hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ + haddr_t addr; /* Address of free space header on disk */ + hsize_t hdr_size; /* Size of the free-space header on disk */ + haddr_t sect_addr; /* Address of the section info in the file */ + hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ + hsize_t sect_size; /* Size of the section info in the file */ } H5FS_stat_t; /* Typedef for iteration operations */ -typedef herr_t (*H5FS_operator_t)(H5FS_section_info_t *sect, - void *operator_data/*in,out*/); - +typedef herr_t (*H5FS_operator_t)(H5FS_section_info_t *sect, void *operator_data /*in,out*/); /*****************************/ /* Library-private Variables */ @@ -168,7 +183,6 @@ typedef herr_t (*H5FS_operator_t)(H5FS_section_info_t *sect, /* Declare a free list to manage the H5FS_section_class_t sequence information */ H5FL_SEQ_EXTERN(H5FS_section_class_t); - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -177,52 +191,44 @@ H5FL_SEQ_EXTERN(H5FS_section_class_t); H5_DLL herr_t H5FS_init(void); /* Free space manager routines */ -H5_DLL H5FS_t *H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, - uint16_t nclasses, const H5FS_section_class_t *classes[], - void *cls_init_udata, hsize_t alignment, hsize_t threshold); -H5_DLL H5FS_t *H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, - const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, - hsize_t threshold); -H5_DLL herr_t H5FS_size(const H5FS_t *fspace, hsize_t *meta_size); -H5_DLL herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr); -H5_DLL herr_t H5FS_close(H5F_t *f, H5FS_t *fspace); -H5_DLL herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr); -H5_DLL herr_t H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace); -H5_DLL herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space); +H5_DLL H5FS_t *H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t nclasses, + const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, + hsize_t threshold); +H5_DLL H5FS_t *H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, const H5FS_section_class_t *classes[], + void *cls_init_udata, hsize_t alignment, hsize_t threshold); +H5_DLL herr_t H5FS_size(const H5FS_t *fspace, hsize_t *meta_size); +H5_DLL herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr); +H5_DLL herr_t H5FS_close(H5F_t *f, H5FS_t *fspace); +H5_DLL herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr); +H5_DLL herr_t H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace); +H5_DLL herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space); /* Free space section routines */ -H5_DLL herr_t H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *node, - unsigned flags, void *op_data); -H5_DLL htri_t H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, - H5FS_section_info_t *sect, unsigned flags, void *op_data); -H5_DLL htri_t H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, - hsize_t size, hsize_t extra_requested, unsigned flags, void *op_data); +H5_DLL herr_t H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *node, unsigned flags, + void *op_data); +H5_DLL htri_t H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, + void *op_data); +H5_DLL htri_t H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, hsize_t size, + hsize_t extra_requested, unsigned flags, void *op_data); H5_DLL herr_t H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *node); -H5_DLL htri_t H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, - H5FS_section_info_t **node); +H5_DLL htri_t H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node); H5_DLL herr_t H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data); -H5_DLL herr_t H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, - hsize_t *nsects); -H5_DLL herr_t H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, - H5FS_section_info_t *sect, uint16_t new_class); -H5_DLL htri_t H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, - void *op_data); +H5_DLL herr_t H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects); +H5_DLL herr_t H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint16_t new_class); +H5_DLL htri_t H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, void *op_data); /* Statistics routine */ H5_DLL herr_t H5FS_stat_info(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *stats); H5_DLL herr_t H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count); /* free space manager settling routines */ -H5_DLL herr_t H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, - haddr_t *fs_addr_ptr); +H5_DLL herr_t H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr_ptr); /* Debugging routines for dumping file structures */ -H5_DLL herr_t H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth); -H5_DLL herr_t H5FS_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, haddr_t fs_addr, haddr_t client_addr); -H5_DLL herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, - FILE *stream, int indent, int fwidth); +H5_DLL herr_t H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); +H5_DLL herr_t H5FS_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t fs_addr, + haddr_t client_addr); +H5_DLL herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *stream, int indent, + int fwidth); #endif /* _H5FSprivate_H */ - diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 77e7a89..de2e628 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -23,69 +23,60 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FSpkg.h" /* File free space */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FSpkg.h" /* File free space */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for skip list iterator callback for iterating over section size nodes */ typedef struct { - H5FS_t *fspace; /* Free space manager info */ - H5FS_operator_t op; /* Operator for the iteration */ - void *op_data; /* Information to pass to the operator */ + H5FS_t * fspace; /* Free space manager info */ + H5FS_operator_t op; /* Operator for the iteration */ + void * op_data; /* Information to pass to the operator */ } H5FS_iter_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, - unsigned flags); +static herr_t H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, unsigned flags); static herr_t H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls); static herr_t H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node, - const H5FS_section_class_t *cls); + const H5FS_section_class_t *cls); static herr_t H5FS__sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect); -static herr_t H5FS__sect_unlink_rest(H5FS_t *fspace, - const H5FS_section_class_t *cls, H5FS_section_info_t *sect); + H5FS_section_info_t *sect); +static herr_t H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, + H5FS_section_info_t *sect); static herr_t H5FS__sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect); static herr_t H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect); -static herr_t H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect, unsigned flags); -static herr_t H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, - unsigned flags); -static herr_t H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, - void *op_data); + H5FS_section_info_t *sect); +static herr_t H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect, + unsigned flags); +static herr_t H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags); +static herr_t H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data); static htri_t H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node); static herr_t H5FS__sect_serialize_size(H5FS_t *fspace); - /*********************/ /* Package Variables */ /*********************/ @@ -99,18 +90,14 @@ H5FL_SEQ_DEFINE(H5FS_bin_t); /* Declare a free list to manage the H5FS_sinfo_t struct */ H5FL_DEFINE(H5FS_sinfo_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_new * @@ -127,8 +114,8 @@ H5FL_DEFINE(H5FS_sinfo_t); H5FS_sinfo_t * H5FS__sinfo_new(H5F_t *f, H5FS_t *fspace) { - H5FS_sinfo_t *sinfo = NULL; /* Section information struct created */ - H5FS_sinfo_t *ret_value = NULL; /* Return value */ + H5FS_sinfo_t *sinfo = NULL; /* Section information struct created */ + H5FS_sinfo_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -136,31 +123,33 @@ H5FS__sinfo_new(H5F_t *f, H5FS_t *fspace) HDassert(f); HDassert(fspace); #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: fspace->addr = %a\n", FUNC, fspace->addr); + HDfprintf(stderr, "%s: fspace->addr = %a\n", FUNC, fspace->addr); #endif /* H5FS_SINFO_DEBUG */ /* Allocate the free space header */ - if(NULL == (sinfo = H5FL_CALLOC(H5FS_sinfo_t))) + if (NULL == (sinfo = H5FL_CALLOC(H5FS_sinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set non-zero values */ - sinfo->nbins = H5VM_log2_gen(fspace->max_sect_size); + sinfo->nbins = H5VM_log2_gen(fspace->max_sect_size); sinfo->sect_prefix_size = H5FS_SINFO_PREFIX_SIZE(f); - sinfo->sect_off_size = (fspace->max_sect_addr + 7) / 8; - sinfo->sect_len_size = H5VM_limit_enc_size((uint64_t)fspace->max_sect_size); + sinfo->sect_off_size = (fspace->max_sect_addr + 7) / 8; + sinfo->sect_len_size = H5VM_limit_enc_size((uint64_t)fspace->max_sect_size); #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: fspace->max_sect_size = %Hu\n", FUNC, fspace->max_sect_size); -HDfprintf(stderr, "%s: fspace->max_sect_addr = %u\n", FUNC, fspace->max_sect_addr); -HDfprintf(stderr, "%s: sinfo->nbins = %u\n", FUNC, sinfo->nbins); -HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", FUNC, sinfo->sect_off_size, sinfo->sect_len_size); + HDfprintf(stderr, "%s: fspace->max_sect_size = %Hu\n", FUNC, fspace->max_sect_size); + HDfprintf(stderr, "%s: fspace->max_sect_addr = %u\n", FUNC, fspace->max_sect_addr); + HDfprintf(stderr, "%s: sinfo->nbins = %u\n", FUNC, sinfo->nbins); + HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", FUNC, + sinfo->sect_off_size, sinfo->sect_len_size); #endif /* H5FS_SINFO_DEBUG */ /* Allocate space for the section size bins */ - if(NULL == (sinfo->bins = H5FL_SEQ_CALLOC(H5FS_bin_t, (size_t)sinfo->nbins))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space section bin array") + if (NULL == (sinfo->bins = H5FL_SEQ_CALLOC(H5FS_bin_t, (size_t)sinfo->nbins))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for free space section bin array") /* Increment the reference count on the free space manager header */ - if(H5FS__incr(fspace) < 0) + if (H5FS__incr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINC, NULL, "unable to increment ref. count on free space header") sinfo->fspace = fspace; @@ -173,9 +162,9 @@ HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", ret_value = sinfo; done: - if(ret_value == NULL && sinfo) { + if (ret_value == NULL && sinfo) { /* Release bins for skip lists */ - if(sinfo->bins) + if (sinfo->bins) sinfo->bins = H5FL_SEQ_FREE(H5FS_bin_t, sinfo->bins); /* Release free space section info */ @@ -185,7 +174,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_new() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_lock * @@ -206,14 +194,16 @@ done: static herr_t H5FS__sinfo_lock(H5F_t *f, H5FS_t *fspace, unsigned accmode) { - H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Called, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC, fspace->addr, fspace->sinfo, fspace->sect_addr); -HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, fspace->alloc_sect_size, fspace->sect_size); + HDfprintf(stderr, "%s: Called, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC, + fspace->addr, fspace->sinfo, fspace->sect_addr); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, + fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -226,53 +216,58 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* If the free space header doesn't already "own" the section info, load * section info or create it */ - if(fspace->sinfo) { + if (fspace->sinfo) { /* Check if the section info was protected & we want a different access mode */ /* only H5AC__READ_ONLY_FLAG may appear in fspace->sinfo_accmode */ HDassert(((fspace->sinfo_accmode) & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); - if(fspace->sinfo_protected && accmode != fspace->sinfo_accmode) { + if (fspace->sinfo_protected && accmode != fspace->sinfo_accmode) { /* Check if we need to switch from read-only access to read-write */ - if(0 == (accmode & (unsigned)(~H5AC__READ_ONLY_FLAG))) { + if (0 == (accmode & (unsigned)(~H5AC__READ_ONLY_FLAG))) { /* Unprotect the read-only section info */ - if(H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") + if (H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, + H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, + "unable to release free space section info") /* Re-protect the section info with read-write access */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.fspace = fspace; - if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect( + f, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to load free space sections") /* Switch the access mode we have */ fspace->sinfo_accmode = H5AC__NO_FLAGS_SET; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* If the section address is defined, load it from the file */ - if(H5F_addr_defined(fspace->sect_addr)) { + if (H5F_addr_defined(fspace->sect_addr)) { /* Sanity check */ HDassert(fspace->sinfo_protected == FALSE); HDassert(H5F_addr_defined(fspace->addr)); #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); + HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %a\n", FUNC, + fspace->sect_addr); #endif /* H5FS_SINFO_DEBUG */ /* Protect the free space sections */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.fspace = fspace; - if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, accmode))) + if (NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, + &cache_udata, accmode))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to load free space sections") /* Remember that we protected the section info & the access mode */ fspace->sinfo_protected = TRUE; - fspace->sinfo_accmode = accmode; + fspace->sinfo_accmode = accmode; } /* end if */ else { #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Creating new section info\n", FUNC); + HDfprintf(stderr, "%s: Creating new section info\n", FUNC); #endif /* H5FS_SINFO_DEBUG */ /* Sanity check */ HDassert(fspace->tot_sect_count == 0); @@ -280,13 +275,13 @@ HDfprintf(stderr, "%s: Creating new section info\n", FUNC); HDassert(fspace->ghost_sect_count == 0); /* Allocate and initialize free space section info */ - if(NULL == (fspace->sinfo = H5FS__sinfo_new(f, fspace))) + if (NULL == (fspace->sinfo = H5FS__sinfo_new(f, fspace))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create section info") /* Set initial size of section info to 0 */ fspace->sect_size = fspace->alloc_sect_size = 0; } /* end if */ - } /* end if */ + } /* end if */ HDassert(fspace->rc == 2); /* Increment the section info lock count */ @@ -294,13 +289,14 @@ HDfprintf(stderr, "%s: Creating new section info\n", FUNC); done: #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Leaving, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC, fspace->addr, fspace->sinfo, fspace->sect_addr); -HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, fspace->alloc_sect_size, fspace->sect_size); + HDfprintf(stderr, "%s: Leaving, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC, + fspace->addr, fspace->sinfo, fspace->sect_addr); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, + fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_SINFO_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_lock() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_unlock * @@ -331,13 +327,18 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" static herr_t H5FS__sinfo_unlock(H5F_t *f, H5FS_t *fspace, hbool_t modified) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Called, modified = %t, fspace->addr = %a, fspace->sect_addr = %a\n", FUNC, modified, fspace->addr, fspace->sect_addr); -HDfprintf(stderr, "%s: fspace->sinfo_lock_count = %u, fspace->sinfo_modified = %t, fspace->sinfo_protected = %t\n", FUNC, fspace->sinfo_lock_count, fspace->sinfo_modified, fspace->sinfo_protected); -HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, fspace->alloc_sect_size, fspace->sect_size); + HDfprintf(stderr, "%s: Called, modified = %t, fspace->addr = %a, fspace->sect_addr = %a\n", FUNC, + modified, fspace->addr, fspace->sect_addr); + HDfprintf( + stderr, + "%s: fspace->sinfo_lock_count = %u, fspace->sinfo_modified = %t, fspace->sinfo_protected = %t\n", + FUNC, fspace->sinfo_lock_count, fspace->sinfo_modified, fspace->sinfo_protected); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, + fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -347,9 +348,9 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" HDassert(fspace->sinfo); /* Check if we modified any section */ - if(modified) { + if (modified) { /* Check if the section info was protected with a different access mode */ - if(fspace->sinfo_protected && (0 != ((fspace->sinfo_accmode) & H5AC__READ_ONLY_FLAG))) + if (fspace->sinfo_protected && (0 != ((fspace->sinfo_accmode) & H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDIRTY, FAIL, "attempt to modify read-only section info") /* If we modified the section info, mark it dirty */ @@ -361,7 +362,7 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* Assume that the modification will affect the statistics in the header * and mark that dirty also */ - if(H5FS__dirty(fspace) < 0) + if (H5FS__dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } /* end if */ @@ -369,35 +370,38 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" fspace->sinfo_lock_count--; /* Check if section info lock count dropped to zero */ - if(fspace->sinfo_lock_count == 0) { - hbool_t release_sinfo_space = FALSE; /* Flag to indicate section info space in file should be released */ - hbool_t closing_or_flushing = f->shared->closing; /* Is closing or flushing in progress */ + if (fspace->sinfo_lock_count == 0) { + hbool_t release_sinfo_space = + FALSE; /* Flag to indicate section info space in file should be released */ + hbool_t closing_or_flushing = f->shared->closing; /* Is closing or flushing in progress */ /* Check whether cache-flush is in progress if closing is not. */ - if(!closing_or_flushing && H5AC_get_cache_flush_in_progress(f->shared->cache, &closing_or_flushing) < 0) + if (!closing_or_flushing && + H5AC_get_cache_flush_in_progress(f->shared->cache, &closing_or_flushing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get flush_in_progress") /* Check if we actually protected the section info */ - if(fspace->sinfo_protected) { - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ + if (fspace->sinfo_protected) { + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ /* Sanity check */ HDassert(H5F_addr_defined(fspace->addr)); /* Check if we've made new changes to the section info while locked */ - if(fspace->sinfo_modified) { + if (fspace->sinfo_modified) { /* Note that we've modified the section info */ cache_flags |= H5AC__DIRTIED_FLAG; /* On file close or flushing, does not allow section info to shrink in size */ - if(closing_or_flushing) { - if(fspace->sect_size > fspace->alloc_sect_size) + if (closing_or_flushing) { + if (fspace->sect_size > fspace->alloc_sect_size) cache_flags |= H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; else fspace->sect_size = fspace->alloc_sect_size; - /* Check if the section info size in the file has changed */ - } else if(fspace->sect_size != fspace->alloc_sect_size) + /* Check if the section info size in the file has changed */ + } + else if (fspace->sect_size != fspace->alloc_sect_size) cache_flags |= H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; } /* end if */ @@ -409,96 +413,100 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* (Possibly dirty) */ /* (Possibly taking ownership from the cache) */ #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Unprotecting section info, cache_flags = %u\n", FUNC, cache_flags); + HDfprintf(stderr, "%s: Unprotecting section info, cache_flags = %u\n", FUNC, cache_flags); #endif /* H5FS_SINFO_DEBUG */ - if(H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") /* Reset the protected flag on the section info */ fspace->sinfo_protected = FALSE; /* Check if header is taking ownership of section info */ - if((cache_flags & H5AC__TAKE_OWNERSHIP_FLAG)) { + if ((cache_flags & H5AC__TAKE_OWNERSHIP_FLAG)) { #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Taking ownership of section info\n", FUNC); + HDfprintf(stderr, "%s: Taking ownership of section info\n", FUNC); #endif /* H5FS_SINFO_DEBUG */ /* Set flag to release section info space in file */ release_sinfo_space = TRUE; } /* end if */ else { #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC); + HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC); #endif /* H5FS_SINFO_DEBUG */ /* Free space header relinquished ownership of section info */ fspace->sinfo = NULL; } /* end else */ - } /* end if */ + } /* end if */ else { /* Check if the section info was modified */ - if(fspace->sinfo_modified) { + if (fspace->sinfo_modified) { /* Check if we need to release section info in the file */ - if(H5F_addr_defined(fspace->sect_addr)) { + if (H5F_addr_defined(fspace->sect_addr)) { /* Set flag to release section info space in file */ /* On file close or flushing, only need to release section info with size bigger than previous section */ - if(closing_or_flushing) { - if(fspace->sect_size > fspace->alloc_sect_size) + if (closing_or_flushing) { + if (fspace->sect_size > fspace->alloc_sect_size) release_sinfo_space = TRUE; else fspace->sect_size = fspace->alloc_sect_size; - } else + } + else release_sinfo_space = TRUE; - } else + } + else HDassert(fspace->alloc_sect_size == 0); } /* end if */ else { /* Sanity checks... */ - if(H5F_addr_defined(fspace->sect_addr)) + if (H5F_addr_defined(fspace->sect_addr)) HDassert(fspace->alloc_sect_size == fspace->sect_size); else HDassert(fspace->alloc_sect_size == 0); } /* end else */ - } /* end else */ + } /* end else */ /* Reset the "section info modified" flag */ fspace->sinfo_modified = FALSE; /* Check if header needs to release section info in the file */ - if(release_sinfo_space) { - haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */ - hsize_t old_alloc_sect_size = fspace->alloc_sect_size; /* Previous size of section info in file */ + if (release_sinfo_space) { + haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */ + hsize_t old_alloc_sect_size = fspace->alloc_sect_size; /* Previous size of section info in file */ /* Sanity check */ HDassert(H5F_addr_defined(fspace->addr)); /* Reset section info in header */ - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* If we haven't already marked the header dirty, do so now */ - if(!modified) - if(H5FS__dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (!modified) + if (H5FS__dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Freeing section info on disk, old_sect_addr = %a, old_alloc_sect_size = %Hu\n", FUNC, old_sect_addr, old_alloc_sect_size); + HDfprintf(stderr, + "%s: Freeing section info on disk, old_sect_addr = %a, old_alloc_sect_size = %Hu\n", + FUNC, old_sect_addr, old_alloc_sect_size); #endif /* H5FS_SINFO_DEBUG */ /* Release space for section info in file */ - if(!H5F_IS_TMP_ADDR(f, old_sect_addr)) - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, old_sect_addr, old_alloc_sect_size) < 0) + if (!H5F_IS_TMP_ADDR(f, old_sect_addr)) + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, old_sect_addr, old_alloc_sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections") } /* end if */ - } /* end if */ + } /* end if */ done: #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* H5FS_SINFO_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_unlock() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_serialize_size * @@ -519,25 +527,32 @@ H5FS__sect_serialize_size(H5FS_t *fspace) /* Check arguments. */ HDassert(fspace); #ifdef QAK -HDfprintf(stderr, "%s: Check 1.0 - fspace->sect_size = %Hu\n", "H5FS__sect_serialize_size", fspace->sect_size); -HDfprintf(stderr, "%s: fspace->serial_sect_count = %Zu\n", "H5FS__sect_serialize_size", fspace->serial_sect_count); -HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu\n", "H5FS__sect_serialize_size", fspace->alloc_sect_size); -HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS__sect_serialize_size", fspace->sinfo->serial_size_count); + HDfprintf(stderr, "%s: Check 1.0 - fspace->sect_size = %Hu\n", "H5FS__sect_serialize_size", + fspace->sect_size); + HDfprintf(stderr, "%s: fspace->serial_sect_count = %Zu\n", "H5FS__sect_serialize_size", + fspace->serial_sect_count); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu\n", "H5FS__sect_serialize_size", + fspace->alloc_sect_size); + HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS__sect_serialize_size", + fspace->sinfo->serial_size_count); #endif /* QAK */ /* Compute the size of the buffer required to serialize all the sections */ - if(fspace->serial_sect_count > 0) { - size_t sect_buf_size; /* Section buffer size */ + if (fspace->serial_sect_count > 0) { + size_t sect_buf_size; /* Section buffer size */ /* Serialized sections prefix */ sect_buf_size = fspace->sinfo->sect_prefix_size; /* Count for each differently sized serializable section */ #ifdef QAK -HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS__sect_serialize_size", fspace->sinfo->serial_size_count); -HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS__sect_serialize_size", fspace->serial_sect_count); + HDfprintf(stderr, "%s: fspace->sinfo->serial_size_count = %Zu\n", "H5FS__sect_serialize_size", + fspace->sinfo->serial_size_count); + HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS__sect_serialize_size", + fspace->serial_sect_count); #endif /* QAK */ - sect_buf_size += fspace->sinfo->serial_size_count * H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count); + sect_buf_size += + fspace->sinfo->serial_size_count * H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count); /* Size for each differently sized serializable section */ sect_buf_size += fspace->sinfo->serial_size_count * fspace->sinfo->sect_len_size; @@ -561,7 +576,6 @@ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS__sect_serialize FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FS__sect_serialize_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_increase * @@ -576,10 +590,9 @@ HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", "H5FS__sect_serialize *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, - unsigned flags) +H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, unsigned flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -592,7 +605,7 @@ H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, fspace->tot_sect_count++; /* Check for serializable or 'ghost' section */ - if(cls->flags & H5FS_CLS_GHOST_OBJ) { + if (cls->flags & H5FS_CLS_GHOST_OBJ) { /* Sanity check */ HDassert(cls->serial_size == 0); @@ -605,24 +618,23 @@ H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, /* Increment amount of space required to serialize all sections */ #ifdef QAK -HDfprintf(stderr, "%s: sinfo->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size); -HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size); + HDfprintf(stderr, "%s: sinfo->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size); + HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size); #endif /* QAK */ fspace->sinfo->serial_size += cls->serial_size; /* Update the free space sections' serialized size */ /* (if we're not deserializing the sections from disk) */ - if(!(flags & H5FS_ADD_DESERIALIZING)) { - if(H5FS__sect_serialize_size(fspace) < 0) + if (!(flags & H5FS_ADD_DESERIALIZING)) { + if (H5FS__sect_serialize_size(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk") } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_increase() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_decrease * @@ -639,7 +651,7 @@ done: static herr_t H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -652,7 +664,7 @@ H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) fspace->tot_sect_count--; /* Check for serializable or 'ghost' section */ - if(cls->flags & H5FS_CLS_GHOST_OBJ) { + if (cls->flags & H5FS_CLS_GHOST_OBJ) { /* Sanity check */ HDassert(cls->serial_size == 0); @@ -665,13 +677,13 @@ H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) /* Decrement amount of space required to serialize all sections */ #ifdef QAK -HDfprintf(stderr, "%s: fspace->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size); -HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size); + HDfprintf(stderr, "%s: fspace->serial_size = %Zu\n", FUNC, fspace->sinfo->serial_size); + HDfprintf(stderr, "%s: cls->serial_size = %Zu\n", FUNC, cls->serial_size); #endif /* QAK */ fspace->sinfo->serial_size -= cls->serial_size; /* Update the free space sections' serialized size */ - if(H5FS__sect_serialize_size(fspace) < 0) + if (H5FS__sect_serialize_size(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk") } /* end else */ @@ -679,7 +691,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_decrease() */ - /*------------------------------------------------------------------------- * Function: H5FS__size_node_decr * @@ -694,9 +705,9 @@ done: */ static herr_t H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node, - const H5FS_section_class_t *cls) + const H5FS_section_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -711,11 +722,11 @@ H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node */ sinfo->bins[bin].tot_sect_count--; #ifdef QAK -HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count); + HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count); #endif /* QAK */ /* Check for 'ghost' or 'serializable' section */ - if(cls->flags & H5FS_CLS_GHOST_OBJ) { + if (cls->flags & H5FS_CLS_GHOST_OBJ) { /* Decrement node's ghost section count */ fspace_node->ghost_count--; @@ -723,7 +734,7 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi sinfo->bins[bin].ghost_sect_count--; /* If the node has no more ghost sections, decrement number of ghost section sizes managed */ - if(fspace_node->ghost_count == 0) + if (fspace_node->ghost_count == 0) sinfo->ghost_size_count--; } /* end if */ else { @@ -733,14 +744,15 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi /* Decrement bin's serializable section count */ sinfo->bins[bin].serial_sect_count--; - /* If the node has no more serializable sections, decrement number of serializable section sizes managed */ - if(fspace_node->serial_count == 0) + /* If the node has no more serializable sections, decrement number of serializable section sizes + * managed */ + if (fspace_node->serial_count == 0) sinfo->serial_size_count--; } /* end else */ /* Check for no more nodes on list of that size */ - if(H5SL_count(fspace_node->sect_list) == 0) { - H5FS_node_t *tmp_fspace_node; /* Free space list size node */ + if (H5SL_count(fspace_node->sect_list) == 0) { + H5FS_node_t *tmp_fspace_node; /* Free space list size node */ /* Sanity checks */ HDassert(fspace_node->ghost_count == 0); @@ -748,11 +760,11 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi /* Remove size tracking list from bin */ tmp_fspace_node = (H5FS_node_t *)H5SL_remove(sinfo->bins[bin].bin_list, &fspace_node->sect_size); - if(tmp_fspace_node == NULL || tmp_fspace_node != fspace_node) + if (tmp_fspace_node == NULL || tmp_fspace_node != fspace_node) HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list") /* Destroy skip list for size tracking node */ - if(H5SL_close(fspace_node->sect_list) < 0) + if (H5SL_close(fspace_node->sect_list) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy size tracking node's skip list") /* Release free space list node */ @@ -766,7 +778,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__size_node_decr() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_unlink_size * @@ -781,13 +792,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect) +H5FS__sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_section_info_t *sect) { - H5FS_node_t *fspace_node; /* Free list size node */ - H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ - unsigned bin; /* Bin to put the free space section in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_node_t * fspace_node; /* Free list size node */ + H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ + unsigned bin; /* Bin to put the free space section in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -800,27 +810,26 @@ H5FS__sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, /* Determine correct bin which holds items of at least the section's size */ bin = H5VM_log2_gen(sect->size); HDassert(bin < sinfo->nbins); - if(sinfo->bins[bin].bin_list == NULL) + if (sinfo->bins[bin].bin_list == NULL) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "node's bin is empty?") /* Find space node for section's size */ - if((fspace_node = (H5FS_node_t *)H5SL_search(sinfo->bins[bin].bin_list, §->size)) == NULL) + if ((fspace_node = (H5FS_node_t *)H5SL_search(sinfo->bins[bin].bin_list, §->size)) == NULL) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section size node") /* Remove the section's node from the list */ tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace_node->sect_list, §->addr); - if(tmp_sect_node == NULL || tmp_sect_node != sect) + if (tmp_sect_node == NULL || tmp_sect_node != sect) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list") /* Decrement # of sections in section size node */ - if(H5FS__size_node_decr(sinfo, bin, fspace_node, cls) < 0) + if (H5FS__size_node_decr(sinfo, bin, fspace_node, cls) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_unlink_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_unlink_rest * @@ -836,10 +845,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect) +H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -850,24 +858,25 @@ H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, HDassert(sect); /* Remove node from merge list, if it was entered there */ - if(!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { + if (!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ #ifdef QAK -HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC, (unsigned)sect->type); + HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC, + (unsigned)sect->type); #endif /* QAK */ tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace->sinfo->merge_list, §->addr); - if(tmp_sect_node == NULL || tmp_sect_node != sect) + if (tmp_sect_node == NULL || tmp_sect_node != sect) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list") } /* end if */ /* Update section info & check if we need less room for the serialized free space sections */ - if(H5FS__sect_decrease(fspace, cls) < 0) + if (H5FS__sect_decrease(fspace, cls) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't increase free space section size on disk") - /* Decrement amount of free space managed */ + /* Decrement amount of free space managed */ #ifdef QAK -HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); + HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); #endif /* QAK */ fspace->tot_space -= sect->size; @@ -875,7 +884,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_unlink_rest() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_remove_real * @@ -891,8 +899,8 @@ done: static herr_t H5FS__sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect) { - const H5FS_section_class_t *cls; /* Class of section */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *cls; /* Class of section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -905,18 +913,18 @@ H5FS__sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect) cls = &fspace->sect_cls[sect->type]; /* Remove node from size tracked data structures */ - if(H5FS__sect_unlink_size(fspace->sinfo, cls, sect) < 0) + if (H5FS__sect_unlink_size(fspace->sinfo, cls, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from size tracking data structures") /* Update rest of free space manager data structures for node removal */ - if(H5FS__sect_unlink_rest(fspace, cls, sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures") + if (H5FS__sect_unlink_rest(fspace, cls, sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, + "can't remove section from non-size tracking data structures") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_remove_real() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_remove * @@ -932,8 +940,8 @@ done: herr_t H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -943,23 +951,22 @@ H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect) HDassert(sect); /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Perform actual section removal */ - if(H5FS__sect_remove_real(fspace, sect) < 0) + if (H5FS__sect_remove_real(fspace, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove section") done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_remove() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_link_size * @@ -973,17 +980,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect) +H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_section_info_t *sect) { - H5FS_node_t *fspace_node = NULL; /* Pointer to free space node of the correct size */ - hbool_t fspace_node_alloc = FALSE; /* Whether the free space node was allocated */ - unsigned bin; /* Bin to put the free space section in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_node_t *fspace_node = NULL; /* Pointer to free space node of the correct size */ + hbool_t fspace_node_alloc = FALSE; /* Whether the free space node was allocated */ + unsigned bin; /* Bin to put the free space section in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC #ifdef QAK -HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, sect->addr); + HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, sect->addr); #endif /* QAK */ /* Check arguments. */ @@ -995,8 +1001,8 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s /* Determine correct bin which holds items of the section's size */ bin = H5VM_log2_gen(sect->size); HDassert(bin < sinfo->nbins); - if(sinfo->bins[bin].bin_list == NULL) { - if(NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE, NULL))) + if (sinfo->bins[bin].bin_list == NULL) { + if (NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE, NULL))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes") } /* end if */ else { @@ -1005,20 +1011,20 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s } /* end else */ /* Check if we need to create a new skip list for nodes of this size */ - if(fspace_node == NULL) { + if (fspace_node == NULL) { /* Allocate new free list size node */ - if(NULL == (fspace_node = H5FL_MALLOC(H5FS_node_t))) + if (NULL == (fspace_node = H5FL_MALLOC(H5FS_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for free space node") fspace_node_alloc = TRUE; /* Initialize the free list size node */ - fspace_node->sect_size = sect->size; + fspace_node->sect_size = sect->size; fspace_node->serial_count = fspace_node->ghost_count = 0; - if(NULL == (fspace_node->sect_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (fspace_node->sect_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes") /* Insert new free space size node into bin's list */ - if(H5SL_insert(sinfo->bins[bin].bin_list, fspace_node, &fspace_node->sect_size) < 0) + if (H5SL_insert(sinfo->bins[bin].bin_list, fspace_node, &fspace_node->sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into skip list") fspace_node_alloc = FALSE; /* (owned by the bin skip list now, don't need to free on error) */ @@ -1031,15 +1037,15 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s * the bin's skiplist is also a skiplist...) */ #ifdef QAK -HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count); + HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bins[bin].sect_count); #endif /* QAK */ sinfo->bins[bin].tot_sect_count++; - if(cls->flags & H5FS_CLS_GHOST_OBJ) { + if (cls->flags & H5FS_CLS_GHOST_OBJ) { sinfo->bins[bin].ghost_sect_count++; fspace_node->ghost_count++; /* Check for first ghost section in node */ - if(fspace_node->ghost_count == 1) + if (fspace_node->ghost_count == 1) sinfo->ghost_size_count++; } /* end if */ else { @@ -1047,26 +1053,26 @@ HDfprintf(stderr, "%s: sinfo->bins[%u].sect_count = %Zu\n", FUNC, bin, sinfo->bi fspace_node->serial_count++; /* Check for first serializable section in node */ - if(fspace_node->serial_count == 1) + if (fspace_node->serial_count == 1) sinfo->serial_size_count++; } /* end else */ /* Insert free space node into correct skip list */ - if(H5SL_insert(fspace_node->sect_list, sect, §->addr) < 0) + if (H5SL_insert(fspace_node->sect_list, sect, §->addr) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into skip list") done: - if(ret_value < 0) - if(fspace_node && fspace_node_alloc) { - if(fspace_node->sect_list && H5SL_close(fspace_node->sect_list) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy size free space node's skip list") + if (ret_value < 0) + if (fspace_node && fspace_node_alloc) { + if (fspace_node->sect_list && H5SL_close(fspace_node->sect_list) < 0) + HDONE_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, + "can't destroy size free space node's skip list") fspace_node = H5FL_FREE(H5FS_node_t, fspace_node); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_link_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_link_rest * @@ -1081,10 +1087,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect, unsigned flags) +H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect, + unsigned flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1094,19 +1100,22 @@ H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, HDassert(sect); /* Add section to the address-ordered list of sections, if allowed */ - if(!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { + if (!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { #ifdef QAK -HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, (unsigned)sect->type); + HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, + (unsigned)sect->type); #endif /* QAK */ - if(fspace->sinfo->merge_list == NULL) - if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for merging free space sections") - if(H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into merging skip list") + if (fspace->sinfo->merge_list == NULL) + if (NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, + "can't create skip list for merging free space sections") + if (H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space node into merging skip list") } /* end if */ /* Update section info & check if we need more room for the serialized free space sections */ - if(H5FS__sect_increase(fspace, cls, flags) < 0) + if (H5FS__sect_increase(fspace, cls, flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't increase free space section size on disk") /* Increment amount of free space managed */ @@ -1116,7 +1125,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_link_rest() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_link * @@ -1132,8 +1140,8 @@ done: static herr_t H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags) { - const H5FS_section_class_t *cls; /* Class of section */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *cls; /* Class of section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1147,26 +1155,26 @@ H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags) /* Add section to size tracked data structures */ #ifdef QAK -HDfprintf(stderr, "%s: Check 1.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); + HDfprintf(stderr, "%s: Check 1.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); #endif /* QAK */ - if(H5FS__sect_link_size(fspace->sinfo, cls, sect) < 0) + if (H5FS__sect_link_size(fspace->sinfo, cls, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add section to size tracking data structures") #ifdef QAK -HDfprintf(stderr, "%s: Check 2.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); + HDfprintf(stderr, "%s: Check 2.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); #endif /* QAK */ /* Update rest of free space manager data structures for section addition */ - if(H5FS__sect_link_rest(fspace, cls, sect, flags) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add section to non-size tracking data structures") + if (H5FS__sect_link_rest(fspace, cls, sect, flags) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't add section to non-size tracking data structures") #ifdef QAK -HDfprintf(stderr, "%s: Check 3.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); + HDfprintf(stderr, "%s: Check 3.0 - fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); #endif /* QAK */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_link() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_merge * @@ -1183,11 +1191,11 @@ done: static herr_t H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) { - H5FS_section_class_t *sect_cls; /* Section's class */ - hbool_t modified; /* Flag to indicate merge or shrink occurred */ - hbool_t remove_sect = FALSE; /* Whether a section should be removed before shrinking */ - htri_t status; /* Status value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_section_class_t *sect_cls; /* Section's class */ + hbool_t modified; /* Flag to indicate merge or shrink occurred */ + hbool_t remove_sect = FALSE; /* Whether a section should be removed before shrinking */ + htri_t status; /* Status value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1198,13 +1206,13 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) HDassert((*sect)->size); /* Loop until no more merging */ - if(fspace->sinfo->merge_list) { + if (fspace->sinfo->merge_list) { do { - H5SL_node_t *less_sect_node; /* Skip list node for section less than new section */ - H5SL_node_t *greater_sect_node; /* Skip list node for section greater than new section */ - H5FS_section_info_t *tmp_sect; /* Temporary free space section */ - H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */ - hbool_t greater_sect_node_valid = FALSE; /* Indicate if 'greater than' section node is valid */ + H5SL_node_t * less_sect_node; /* Skip list node for section less than new section */ + H5SL_node_t * greater_sect_node; /* Skip list node for section greater than new section */ + H5FS_section_info_t * tmp_sect; /* Temporary free space section */ + H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */ + hbool_t greater_sect_node_valid = FALSE; /* Indicate if 'greater than' section node is valid */ /* Reset 'modification occurred' flag */ modified = FALSE; @@ -1213,9 +1221,9 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) less_sect_node = H5SL_below(fspace->sinfo->merge_list, &(*sect)->addr); /* Check for node before new node able to merge with new node */ - if(less_sect_node) { + if (less_sect_node) { /* Check for node greater than section */ - greater_sect_node = H5SL_next(less_sect_node); + greater_sect_node = H5SL_next(less_sect_node); greater_sect_node_valid = TRUE; /* Get section for 'less than' skip list node */ @@ -1223,89 +1231,93 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) /* Get classes for right & left sections */ tmp_sect_cls = &fspace->sect_cls[tmp_sect->type]; - sect_cls = &fspace->sect_cls[(*sect)->type]; + sect_cls = &fspace->sect_cls[(*sect)->type]; /* Check if sections of the left most class can merge with sections * of another class & whether the sections are the same type, * then check for 'can merge' callback */ - if((!(tmp_sect_cls->flags & H5FS_CLS_MERGE_SYM) || (tmp_sect->type == (*sect)->type)) - && tmp_sect_cls->can_merge) { + if ((!(tmp_sect_cls->flags & H5FS_CLS_MERGE_SYM) || (tmp_sect->type == (*sect)->type)) && + tmp_sect_cls->can_merge) { /* Determine if the sections can merge */ - if((status = (*tmp_sect_cls->can_merge)(tmp_sect, *sect, op_data)) < 0) + if ((status = (*tmp_sect_cls->can_merge)(tmp_sect, *sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't check for merging sections") - if(status > 0) { + if (status > 0) { /* Sanity check */ HDassert(tmp_sect_cls->merge); /* Remove 'less than' node from data structures */ - if(H5FS__sect_remove_real(fspace, tmp_sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (H5FS__sect_remove_real(fspace, tmp_sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") /* Merge the two sections together */ - if((*tmp_sect_cls->merge)(&tmp_sect, *sect, op_data) < 0) + if ((*tmp_sect_cls->merge)(&tmp_sect, *sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't merge two sections") /* Retarget section pointer to 'less than' node that was merged into */ *sect = tmp_sect; - if(*sect == NULL) - HGOTO_DONE(ret_value); + if (*sect == NULL) + HGOTO_DONE(ret_value); /* Indicate successful merge occurred */ modified = TRUE; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Look for section after new (or merged) section, if not already determined */ - if(!greater_sect_node_valid) + if (!greater_sect_node_valid) greater_sect_node = H5SL_above(fspace->sinfo->merge_list, &(*sect)->addr); /* Check for node after new node able to merge with new node */ - if(greater_sect_node) { + if (greater_sect_node) { /* Get section for 'greater than' skip list node */ tmp_sect = (H5FS_section_info_t *)H5SL_item(greater_sect_node); /* Get classes for right & left sections */ - sect_cls = &fspace->sect_cls[(*sect)->type]; + sect_cls = &fspace->sect_cls[(*sect)->type]; tmp_sect_cls = &fspace->sect_cls[tmp_sect->type]; /* Check if sections of the left most class can merge with sections * of another class & whether the sections are the same type, * then check for 'can merge' callback */ - if((!(sect_cls->flags & H5FS_CLS_MERGE_SYM) || ((*sect)->type == tmp_sect->type)) - && sect_cls->can_merge) { + if ((!(sect_cls->flags & H5FS_CLS_MERGE_SYM) || ((*sect)->type == tmp_sect->type)) && + sect_cls->can_merge) { /* Determine if the sections can merge */ - if((status = (*sect_cls->can_merge)(*sect, tmp_sect, op_data)) < 0) + if ((status = (*sect_cls->can_merge)(*sect, tmp_sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't check for merging sections") - if(status > 0) { + if (status > 0) { /* Sanity check */ HDassert(sect_cls->merge); /* Remove 'greater than' node from data structures */ - if(H5FS__sect_remove_real(fspace, tmp_sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (H5FS__sect_remove_real(fspace, tmp_sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") /* Merge the two sections together */ - if((*sect_cls->merge)(sect, tmp_sect, op_data) < 0) + if ((*sect_cls->merge)(sect, tmp_sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't merge two sections") - /* It's possible that the merge caused the section to be deleted (particularly in the paged allocation case) */ - if(*sect == NULL) + /* It's possible that the merge caused the section to be deleted (particularly in the + * paged allocation case) */ + if (*sect == NULL) HGOTO_DONE(ret_value); /* Indicate successful merge occurred */ modified = TRUE; } /* end if */ - } /* end if */ - } /* end if */ - } while(modified); + } /* end if */ + } /* end if */ + } while (modified); } /* end if */ HDassert(*sect); #ifdef QAK -HDfprintf(stderr, "%s: Done merging, (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size, (*sect)->type, ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); + HDfprintf(stderr, "%s: Done merging, (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size, + (*sect)->type, ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); #endif /* QAK */ /* Loop until no more shrinking */ @@ -1315,36 +1327,37 @@ HDfprintf(stderr, "%s: Done merging, (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sec /* Check for (possibly merged) section able to shrink the size of the container */ sect_cls = &fspace->sect_cls[(*sect)->type]; - if(sect_cls->can_shrink) { - if((status = (*sect_cls->can_shrink)(*sect, op_data)) < 0) + if (sect_cls->can_shrink) { + if ((status = (*sect_cls->can_shrink)(*sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTSHRINK, FAIL, "can't check for shrinking container") - if(status > 0) { + if (status > 0) { #ifdef QAK -HDfprintf(stderr, "%s: Can shrink!\n", FUNC); + HDfprintf(stderr, "%s: Can shrink!\n", FUNC); #endif /* QAK */ /* Remove SECT from free-space manager */ /* (only possible to happen on second+ pass through loop) */ - if(remove_sect) { - if(H5FS__sect_remove_real(fspace, *sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (remove_sect) { + if (H5FS__sect_remove_real(fspace, *sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") remove_sect = FALSE; } /* end if */ /* Shrink the container */ /* (callback can indicate that it has discarded the section by setting *sect to NULL) */ HDassert(sect_cls->shrink); - if((*sect_cls->shrink)(sect, op_data) < 0) + if ((*sect_cls->shrink)(sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't shrink free space container") /* If this section was shrunk away, we may need to shrink another section */ - if(*sect == NULL) { + if (*sect == NULL) { /* Check for sections on merge list */ - if(fspace->sinfo->merge_list) { - H5SL_node_t *last_node; /* Last node in merge list */ + if (fspace->sinfo->merge_list) { + H5SL_node_t *last_node; /* Last node in merge list */ /* Check for last node in the merge list */ - if(NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { + if (NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { /* Get the pointer to the last section, from the last node */ *sect = (H5FS_section_info_t *)H5SL_item(last_node); HDassert(*sect); @@ -1352,35 +1365,36 @@ HDfprintf(stderr, "%s: Can shrink!\n", FUNC); /* Indicate that this section needs to be removed if it causes a shrink */ remove_sect = TRUE; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Indicate successful merge occurred */ modified = TRUE; } /* end if */ - } /* end if */ - } while(modified && *sect); + } /* end if */ + } while (modified && *sect); /* Check for section that was shrunk away and next section not shrinking */ - if(remove_sect && (*sect != NULL)) + if (remove_sect && (*sect != NULL)) *sect = NULL; #ifdef QAK -HDfprintf(stderr, "%s: Done shrinking\n", FUNC); -if(*sect) - HDfprintf(stderr, "%s: (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size, (*sect)->type, ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); -else - HDfprintf(stderr, "%s: *sect = %p\n", FUNC, *sect); + HDfprintf(stderr, "%s: Done shrinking\n", FUNC); + if (*sect) + HDfprintf(stderr, "%s: (*sect) = {%a, %Hu, %u, %s}\n", FUNC, (*sect)->addr, (*sect)->size, + (*sect)->type, + ((*sect)->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); + else + HDfprintf(stderr, "%s: *sect = %p\n", FUNC, *sect); #endif /* QAK */ done: #ifdef QAK -HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* QAK */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_merge() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_add * @@ -1394,18 +1408,18 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); *------------------------------------------------------------------------- */ herr_t -H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, - void *op_data) +H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, void *op_data) { - H5FS_section_class_t *cls; /* Section's class */ - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_section_class_t *cls; /* Section's class */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->size, sect->type, (sect->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); + HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->size, sect->type, + (sect->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -1415,24 +1429,24 @@ HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->siz HDassert(sect->size); /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Call "add" section class callback, if there is one */ cls = &fspace->sect_cls[sect->type]; - if(cls->add) - if((*cls->add)(§, &flags, op_data) < 0) + if (cls->add) + if ((*cls->add)(§, &flags, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "'add' section class callback failed") /* Check for merging returned space with existing section node */ - if(flags & H5FS_ADD_RETURNED_SPACE) { + if (flags & H5FS_ADD_RETURNED_SPACE) { #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Returning space\n", FUNC); + HDfprintf(stderr, "%s: Returning space\n", FUNC); #endif /* H5FS_SINFO_DEBUG */ /* Attempt to merge returned section with existing sections */ - if(H5FS__sect_merge(fspace, §, op_data) < 0) + if (H5FS__sect_merge(fspace, §, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't merge sections") } /* end if */ @@ -1440,34 +1454,33 @@ HDfprintf(stderr, "%s: Returning space\n", FUNC); /* (If section has been completely merged or shrunk away, 'sect' will * be NULL at this point - QAK) */ - if(sect) - if(H5FS__sect_link(fspace, sect, flags) < 0) + if (sect) + if (H5FS__sect_link(fspace, sect, flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); + HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); #endif /* H5FS_SINFO_DEBUG */ /* Mark free space sections as changed */ /* (if adding sections while deserializing sections, don't set the flag) */ - if(!(flags & (H5FS_ADD_DESERIALIZING | H5FS_PAGE_END_NO_ADD))) + if (!(flags & (H5FS_ADD_DESERIALIZING | H5FS_PAGE_END_NO_ADD))) sinfo_modified = TRUE; done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") #ifdef H5FS_DEBUG_ASSERT -if(!(flags & (H5FS_ADD_DESERIALIZING | H5FS_ADD_SKIP_VALID))) - H5FS__assert(fspace); + if (!(flags & (H5FS_ADD_DESERIALIZING | H5FS_ADD_SKIP_VALID))) + H5FS__assert(fspace); #endif /* H5FS_DEBUG_ASSERT */ #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* H5FS_SINFO_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_add() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_try_extend * @@ -1481,17 +1494,18 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); *------------------------------------------------------------------------- */ htri_t -H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, - hsize_t size, hsize_t extra_requested, unsigned flags, void *op_data) +H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, hsize_t size, hsize_t extra_requested, + unsigned flags, void *op_data) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: addr = %a, size = %Hu, extra_requested = %hu\n", FUNC, addr, size, extra_requested); + HDfprintf(stderr, "%s: addr = %a, size = %Hu, extra_requested = %hu\n", FUNC, addr, size, + extra_requested); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -1503,39 +1517,38 @@ HDfprintf(stderr, "%s: addr = %a, size = %Hu, extra_requested = %hu\n", FUNC, ad /* Check for any sections on free space list */ #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); -HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count); -HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count); + HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); + HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count); + HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count); #endif /* H5FS_SINFO_DEBUG */ - if(fspace->tot_sect_count > 0) { - H5FS_section_info_t *sect; /* Temporary free space section */ + if (fspace->tot_sect_count > 0) { + H5FS_section_info_t *sect; /* Temporary free space section */ /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; + /* -/* + Pseudo-code for algorithm: -Pseudo-code for algorithm: - -_section_ = _region.addr_> -if(_section_) - if(_section_ adjoins _region_ && _section.size_ >= _extra_requested_) - - if(_section.size_ > _extra_requested_) - if() - - - else - - - - -*/ + _section_ = _region.addr_> + if(_section_) + if(_section_ adjoins _region_ && _section.size_ >= _extra_requested_) + + if(_section.size_ > _extra_requested_) + if() + + + else + + + + + */ /* Look for a section after block to extend */ - if((sect = (H5FS_section_info_t *)H5SL_greater(fspace->sinfo->merge_list, &addr))) { + if ((sect = (H5FS_section_info_t *)H5SL_greater(fspace->sinfo->merge_list, &addr))) { /* Check if this section adjoins the block and is large enough to * fulfill extension request. * @@ -1543,12 +1556,13 @@ if(_section_) * possible neighboring nodes and is not at the end of the file * (or it would have been eliminated), etc) */ - if(sect->size >= extra_requested && (addr + size) == sect->addr) { - H5FS_section_class_t *cls; /* Section's class */ + if (sect->size >= extra_requested && (addr + size) == sect->addr) { + H5FS_section_class_t *cls; /* Section's class */ /* Remove section from data structures */ - if(H5FS__sect_remove_real(fspace, sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (H5FS__sect_remove_real(fspace, sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") /* Get class for section */ cls = &fspace->sect_cls[sect->type]; @@ -1559,30 +1573,32 @@ if(_section_) * for the current usage, so I've deferred messing with * it. - QAK - 2008/01/08) */ - if(sect->size > extra_requested) { + if (sect->size > extra_requested) { /* Sanity check (for now) */ HDassert(cls->flags & H5FS_CLS_ADJUST_OK); /* Adjust section by amount requested */ sect->addr += extra_requested; sect->size -= extra_requested; - if(cls->add) - if((*cls->add)(§, &flags, op_data) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "'add' section class callback failed") + if (cls->add) + if ((*cls->add)(§, &flags, op_data) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "'add' section class callback failed") /* Re-adding the section could cause it to disappear (particularly when paging) */ - if(sect) { + if (sect) { /* Re-add adjusted section to free sections data structures */ - if(H5FS__sect_link(fspace, sect, 0) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") + if (H5FS__sect_link(fspace, sect, 0) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space section into skip list") } /* end if */ - } /* end if */ + } /* end if */ else { /* Sanity check */ HDassert(sect->size == extra_requested); /* Exact match, so just free section */ - if((*cls->free)(sect) < 0) + if ((*cls->free)(sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't free section") } /* end else */ @@ -1592,18 +1608,17 @@ if(_section_) /* Indicate success */ HGOTO_DONE(TRUE); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_extend() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_try_merge * @@ -1619,13 +1634,12 @@ done: *------------------------------------------------------------------------- */ htri_t -H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, - unsigned flags, void *op_data) +H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, void *op_data) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ - hsize_t saved_fs_size; /* Copy of the free-space section size */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ + hsize_t saved_fs_size; /* Copy of the free-space section size */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1637,39 +1651,39 @@ H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, HDassert(sect->size); /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") - sinfo_valid = TRUE; + sinfo_valid = TRUE; saved_fs_size = sect->size; /* Attempt to merge/shrink section with existing sections */ - if(H5FS__sect_merge(fspace, §, op_data) < 0) + if (H5FS__sect_merge(fspace, §, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't merge sections") /* Check if section is shrunk and/or merged away completely */ - if(!sect) { + if (!sect) { sinfo_modified = TRUE; HGOTO_DONE(TRUE) } /* end if */ else { /* Check if section is merged */ - if(sect->size != saved_fs_size) { - if(H5FS__sect_link(fspace, sect, flags) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") + if (sect->size != saved_fs_size) { + if (H5FS__sect_link(fspace, sect, flags) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space section into skip list") sinfo_modified = TRUE; HGOTO_DONE(TRUE) } /* end if */ - } /* end else */ + } /* end else */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_merge() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_find_node * @@ -1686,13 +1700,13 @@ done: static htri_t H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node) { - H5FS_node_t *fspace_node; /* Free list size node */ - unsigned bin; /* Bin to put the free space section in */ - htri_t ret_value = FALSE; /* Return value */ + H5FS_node_t *fspace_node; /* Free list size node */ + unsigned bin; /* Bin to put the free space section in */ + htri_t ret_value = FALSE; /* Return value */ - H5SL_node_t *curr_size_node=NULL; - const H5FS_section_class_t *cls; /* Class of section */ - hsize_t alignment; + H5SL_node_t * curr_size_node = NULL; + const H5FS_section_class_t *cls; /* Class of section */ + hsize_t alignment; FUNC_ENTER_STATIC @@ -1707,16 +1721,16 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node bin = H5VM_log2_gen(request); HDassert(bin < fspace->sinfo->nbins); #ifdef QAK -HDfprintf(stderr, "%s: fspace->sinfo->nbins = %u\n", FUNC, fspace->sinfo->nbins); -HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); + HDfprintf(stderr, "%s: fspace->sinfo->nbins = %u\n", FUNC, fspace->sinfo->nbins); + HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); #endif /* QAK */ alignment = fspace->alignment; - if(!((alignment > 1) && (request >= fspace->align_thres))) + if (!((alignment > 1) && (request >= fspace->align_thres))) alignment = 0; /* no alignment */ do { /* Check if there's any sections in this bin */ - if(fspace->sinfo->bins[bin].bin_list) { + if (fspace->sinfo->bins[bin].bin_list) { if (!alignment) { /* no alignment */ /* Find the first free space section that is large enough to fulfill request */ @@ -1724,28 +1738,32 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); * lists, this is actually a "best fit" algorithm) */ /* Look for large enough free space section in this bin */ - if((fspace_node = (H5FS_node_t *)H5SL_greater(fspace->sinfo->bins[bin].bin_list, &request))) { + if ((fspace_node = + (H5FS_node_t *)H5SL_greater(fspace->sinfo->bins[bin].bin_list, &request))) { /* Take first node off of the list (ie. node w/lowest address) */ - if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove_first(fspace_node->sect_list))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list") + if (NULL == (*node = (H5FS_section_info_t *)H5SL_remove_first(fspace_node->sect_list))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, + "can't remove free space node from skip list") /* Get section's class */ cls = &fspace->sect_cls[(*node)->type]; /* Decrement # of sections in section size node */ - if(H5FS__size_node_decr(fspace->sinfo, bin, fspace_node, cls) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list") - if(H5FS__sect_unlink_rest(fspace, cls, *node) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures") + if (H5FS__size_node_decr(fspace->sinfo, bin, fspace_node, cls) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, + "can't remove free space size node from skip list") + if (H5FS__sect_unlink_rest(fspace, cls, *node) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, + "can't remove section from non-size tracking data structures") /* Indicate that we found a node for the request */ HGOTO_DONE(TRUE) - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* alignment is set */ /* get the first node of a certain size in this bin */ curr_size_node = H5SL_first(fspace->sinfo->bins[bin].bin_list); while (curr_size_node != NULL) { - H5FS_node_t *curr_fspace_node=NULL; - H5SL_node_t *curr_sect_node=NULL; + H5FS_node_t *curr_fspace_node = NULL; + H5SL_node_t *curr_sect_node = NULL; /* Get the free space node for free space sections of the same size */ curr_fspace_node = (H5FS_node_t *)H5SL_item(curr_size_node); @@ -1753,10 +1771,10 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); /* Get the Skip list which holds pointers to actual free list sections */ curr_sect_node = (H5SL_node_t *)H5SL_first(curr_fspace_node->sect_list); - while(curr_sect_node != NULL) { - H5FS_section_info_t *curr_sect=NULL; - hsize_t mis_align=0, frag_size=0; - H5FS_section_info_t *split_sect=NULL; + while (curr_sect_node != NULL) { + H5FS_section_info_t *curr_sect = NULL; + hsize_t mis_align = 0, frag_size = 0; + H5FS_section_info_t *split_sect = NULL; /* Get section node */ curr_sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node); @@ -1769,19 +1787,23 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); HDassert(alignment); HDassert(cls); - if((mis_align = curr_sect->addr % alignment)) + if ((mis_align = curr_sect->addr % alignment)) frag_size = alignment - mis_align; - if((curr_sect->size >= (request + frag_size)) && (cls->split)) { + if ((curr_sect->size >= (request + frag_size)) && (cls->split)) { /* remove the section with aligned address */ - if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove(curr_fspace_node->sect_list, &curr_sect->addr))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list") + if (NULL == (*node = (H5FS_section_info_t *)H5SL_remove( + curr_fspace_node->sect_list, &curr_sect->addr))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, + "can't remove free space node from skip list") /* Decrement # of sections in section size node */ - if(H5FS__size_node_decr(fspace->sinfo, bin, curr_fspace_node, cls) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list") + if (H5FS__size_node_decr(fspace->sinfo, bin, curr_fspace_node, cls) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, + "can't remove free space size node from skip list") - if(H5FS__sect_unlink_rest(fspace, cls, *node) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures") + if (H5FS__sect_unlink_rest(fspace, cls, *node) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, + "can't remove section from non-size tracking data structures") /* * The split() callback splits NODE into 2 sections: @@ -1789,10 +1811,11 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); * NODE's addr & size are updated to point to the remaining aligned section * split_sect is re-added to free-space */ - if(mis_align) { + if (mis_align) { split_sect = cls->split(*node, frag_size); - if((H5FS__sect_link(fspace, split_sect, 0) < 0)) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") + if ((H5FS__sect_link(fspace, split_sect, 0) < 0)) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space section into skip list") /* sanity check */ HDassert(split_sect->addr < (*node)->addr); HDassert(request <= (*node)->size); @@ -1808,17 +1831,16 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); /* Get the next size node in the bin */ curr_size_node = H5SL_next(curr_size_node); } /* end while of curr_size_node */ - } /* else of alignment */ - } /* if bin_list */ + } /* else of alignment */ + } /* if bin_list */ /* Advance to next larger bin */ bin++; - } while(bin < fspace->sinfo->nbins); + } while (bin < fspace->sinfo->nbins); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_find_node() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_find * @@ -1835,14 +1857,14 @@ done: htri_t H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef QAK -HDfprintf(stderr, "%s: request = %Hu\n", FUNC, request); + HDfprintf(stderr, "%s: request = %Hu\n", FUNC, request); #endif /* QAK */ /* Check arguments. */ @@ -1853,33 +1875,34 @@ HDfprintf(stderr, "%s: request = %Hu\n", FUNC, request); /* Check for any sections on free space list */ #ifdef QAK -HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); -HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count); -HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count); + HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); + HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count); + HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count); #endif /* QAK */ - if(fspace->tot_sect_count > 0) { + if (fspace->tot_sect_count > 0) { /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Look for node in bins */ - if((ret_value = H5FS__sect_find_node(fspace, request, node)) < 0) + if ((ret_value = H5FS__sect_find_node(fspace, request, node)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from bins") /* Decrement # of sections on free list, if we found an object */ - if(ret_value > 0) { + if (ret_value > 0) { /* Note that we've modified the section info */ sinfo_modified = TRUE; #ifdef QAK -HDfprintf(stderr, "%s: (*node)->size = %Hu, (*node)->addr = %a, (*node)->type = %u\n", FUNC, (*node)->size, (*node)->addr, (*node)->type); -#endif /* QAK */ + HDfprintf(stderr, "%s: (*node)->size = %Hu, (*node)->addr = %a, (*node)->type = %u\n", FUNC, + (*node)->size, (*node)->addr, (*node)->type); +#endif /* QAK */ } /* end if */ - } /* end if */ + } /* end if */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") #ifdef H5FS_DEBUG_ASSERT @@ -1888,7 +1911,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_find() */ - /*------------------------------------------------------------------------- * Function: H5FS_iterate_sect_cb * @@ -1905,9 +1927,9 @@ done: static herr_t H5FS_iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { - H5FS_section_info_t *sect_info = (H5FS_section_info_t *)_item; /* Free space section to work on */ - H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_section_info_t *sect_info = (H5FS_section_info_t *)_item; /* Free space section to work on */ + H5FS_iter_ud_t * udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1917,14 +1939,13 @@ H5FS_iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) HDassert(udata->op); /* Make callback for this section */ - if((*udata->op)(sect_info, udata->op_data) < 0) + if ((*udata->op)(sect_info, udata->op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "iteration callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_iterate_sect_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS_iterate_node_cb * @@ -1941,9 +1962,9 @@ done: static herr_t H5FS_iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { - H5FS_node_t *fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ - H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_node_t * fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ + H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1954,14 +1975,13 @@ H5FS_iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) /* Iterate through all the sections of this size */ HDassert(fspace_node->sect_list); - if(H5SL_iterate(fspace_node->sect_list, H5FS_iterate_sect_cb, udata) < 0) + if (H5SL_iterate(fspace_node->sect_list, H5FS_iterate_sect_cb, udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section nodes") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_iterate_node_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_iterate * @@ -1977,9 +1997,9 @@ done: herr_t H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data) { - H5FS_iter_ud_t udata; /* User data for callbacks */ - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_iter_ud_t udata; /* User data for callbacks */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1988,46 +2008,45 @@ H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data) HDassert(op); #ifdef QAK -HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); + HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); #endif /* QAK */ /* Set up user data for iterator */ - udata.fspace = fspace; - udata.op = op; + udata.fspace = fspace; + udata.op = op; udata.op_data = op_data; /* Iterate over sections, if there are any */ - if(fspace->tot_sect_count) { - unsigned bin; /* Current bin we are on */ + if (fspace->tot_sect_count) { + unsigned bin; /* Current bin we are on */ /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__READ_ONLY_FLAG) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__READ_ONLY_FLAG) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Iterate over all the bins */ #ifdef QAK -HDfprintf(stderr, "%s: Iterate over section bins\n", FUNC); + HDfprintf(stderr, "%s: Iterate over section bins\n", FUNC); #endif /* QAK */ - for(bin = 0; bin < fspace->sinfo->nbins; bin++) { + for (bin = 0; bin < fspace->sinfo->nbins; bin++) { /* Check if there are any sections in this bin */ - if(fspace->sinfo->bins[bin].bin_list) { + if (fspace->sinfo->bins[bin].bin_list) { /* Iterate over list of section size nodes for bin */ - if(H5SL_iterate(fspace->sinfo->bins[bin].bin_list, H5FS_iterate_node_cb, &udata) < 0) + if (H5SL_iterate(fspace->sinfo->bins[bin].bin_list, H5FS_iterate_node_cb, &udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section size nodes") } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, FALSE) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, FALSE) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_iterate() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_stats * @@ -2049,15 +2068,14 @@ H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects) HDassert(fspace); /* Get the stats desired */ - if(tot_space) + if (tot_space) *tot_space = fspace->tot_space; - if(nsects) + if (nsects) *nsects = fspace->tot_sect_count; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FS_sect_stats() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_change_class * @@ -2072,14 +2090,13 @@ H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects) *------------------------------------------------------------------------- */ herr_t -H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, - uint16_t new_class) +H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint16_t new_class) { - const H5FS_section_class_t *old_cls; /* Old class of section */ - const H5FS_section_class_t *new_cls; /* New class of section */ - unsigned old_class; /* Old class ID of section */ - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *old_cls; /* Old class of section */ + const H5FS_section_class_t *new_cls; /* New class of section */ + unsigned old_class; /* Old class ID of section */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2090,32 +2107,32 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, HDassert(new_class < fspace->nclasses); /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Get class info */ old_class = sect->type; - old_cls = &fspace->sect_cls[sect->type]; - new_cls = &fspace->sect_cls[new_class]; + old_cls = &fspace->sect_cls[sect->type]; + new_cls = &fspace->sect_cls[new_class]; #ifdef QAK -HDfprintf(stderr, "%s: old_cls->flags = %x\n", FUNC, old_cls->flags); -HDfprintf(stderr, "%s: new_cls->flags = %x\n", FUNC, new_cls->flags); + HDfprintf(stderr, "%s: old_cls->flags = %x\n", FUNC, old_cls->flags); + HDfprintf(stderr, "%s: new_cls->flags = %x\n", FUNC, new_cls->flags); #endif /* QAK */ /* Check if the section's class change will affect the # of serializable or ghost sections */ - if((old_cls->flags & H5FS_CLS_GHOST_OBJ) != (new_cls->flags & H5FS_CLS_GHOST_OBJ)) { - H5FS_node_t *fspace_node; /* Free list size node */ - unsigned bin; /* Bin to put the free space section in */ - hbool_t to_ghost; /* Flag if the section is changing to a ghost section */ + if ((old_cls->flags & H5FS_CLS_GHOST_OBJ) != (new_cls->flags & H5FS_CLS_GHOST_OBJ)) { + H5FS_node_t *fspace_node; /* Free list size node */ + unsigned bin; /* Bin to put the free space section in */ + hbool_t to_ghost; /* Flag if the section is changing to a ghost section */ /* Determine if this section is becoming a ghost or is becoming serializable */ - if(old_cls->flags & H5FS_CLS_GHOST_OBJ) + if (old_cls->flags & H5FS_CLS_GHOST_OBJ) to_ghost = FALSE; else to_ghost = TRUE; #ifdef QAK -HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost); + HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost); #endif /* QAK */ /* Sanity check */ @@ -2131,7 +2148,7 @@ HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost); HDassert(fspace_node); /* Adjust serializable/ghost counts */ - if(to_ghost) { + if (to_ghost) { /* Adjust global section count totals */ fspace->serial_sect_count--; fspace->ghost_sect_count++; @@ -2145,9 +2162,9 @@ HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost); fspace_node->ghost_count++; /* Check if we switched a section size node's status */ - if(fspace_node->serial_count == 0) + if (fspace_node->serial_count == 0) fspace->sinfo->serial_size_count--; - if(fspace_node->ghost_count == 1) + if (fspace_node->ghost_count == 1) fspace->sinfo->ghost_size_count++; } /* end if */ else { @@ -2164,48 +2181,52 @@ HDfprintf(stderr, "%s: to_ghost = %u\n", FUNC, to_ghost); fspace_node->ghost_count--; /* Check if we switched a section size node's status */ - if(fspace_node->serial_count == 1) + if (fspace_node->serial_count == 1) fspace->sinfo->serial_size_count++; - if(fspace_node->ghost_count == 0) + if (fspace_node->ghost_count == 0) fspace->sinfo->ghost_size_count--; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the section's class change will affect the mergable list */ - if((old_cls->flags & H5FS_CLS_SEPAR_OBJ) != (new_cls->flags & H5FS_CLS_SEPAR_OBJ)) { - hbool_t to_mergable; /* Flag if the section is changing to a mergable section */ + if ((old_cls->flags & H5FS_CLS_SEPAR_OBJ) != (new_cls->flags & H5FS_CLS_SEPAR_OBJ)) { + hbool_t to_mergable; /* Flag if the section is changing to a mergable section */ /* Determine if this section is becoming mergable or is becoming separate */ - if(old_cls->flags & H5FS_CLS_SEPAR_OBJ) + if (old_cls->flags & H5FS_CLS_SEPAR_OBJ) to_mergable = TRUE; else to_mergable = FALSE; #ifdef QAK -HDfprintf(stderr, "%s: to_mergable = %u\n", FUNC, to_mergable); + HDfprintf(stderr, "%s: to_mergable = %u\n", FUNC, to_mergable); #endif /* QAK */ /* Add or remove section from merge list, as appropriate */ - if(to_mergable) { + if (to_mergable) { #ifdef QAK -HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, (unsigned)sect->type); + HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, + (unsigned)sect->type); #endif /* QAK */ - if(fspace->sinfo->merge_list == NULL) - if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for merging free space sections") - if(H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into merging skip list") + if (fspace->sinfo->merge_list == NULL) + if (NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, + "can't create skip list for merging free space sections") + if (H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space node into merging skip list") } /* end if */ else { H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ #ifdef QAK -HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC, (unsigned)sect->type); + HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC, + (unsigned)sect->type); #endif /* QAK */ tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace->sinfo->merge_list, §->addr); - if(tmp_sect_node == NULL || tmp_sect_node != sect) + if (tmp_sect_node == NULL || tmp_sect_node != sect) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list") } /* end else */ - } /* end if */ + } /* end if */ /* Change the section's class */ sect->type = new_class; @@ -2215,19 +2236,19 @@ HDfprintf(stderr, "%s: removing object from merge list, sect->type = %u\n", FUNC fspace->sinfo->serial_size += fspace->sect_cls[new_class].serial_size; /* Update current space used for free space sections */ - if(H5FS__sect_serialize_size(fspace) < 0) + if (H5FS__sect_serialize_size(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk") done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_change_class() */ #ifdef H5FS_DEBUG_ASSERT - + /*------------------------------------------------------------------------- * Function: H5FS__sect_assert * @@ -2243,86 +2264,87 @@ done: void H5FS__sect_assert(const H5FS_t *fspace) { - hsize_t separate_obj; /* The number of separate objects managed */ + hsize_t separate_obj; /* The number of separate objects managed */ FUNC_ENTER_PACKAGE_NOERR #ifdef QAK -HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__sect_assert", fspace->tot_sect_count); + HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__sect_assert", fspace->tot_sect_count); #endif /* QAK */ /* Initialize state */ separate_obj = 0; /* Check for bins to work on */ - if(fspace->sinfo->bins) { - hsize_t acc_tot_sect_count; /* Accumulated total section count from bins */ - hsize_t acc_serial_sect_count; /* Accumulated serializable section count from bins */ - hsize_t acc_ghost_sect_count; /* Accumulated ghost section count from bins */ - size_t acc_tot_size_count; /* Accumulated total section size count from bins */ - size_t acc_serial_size_count; /* Accumulated serializable section size count from bins */ - size_t acc_ghost_size_count; /* Accumulated ghost section size count from bins */ - unsigned u; /* Local index variable */ + if (fspace->sinfo->bins) { + hsize_t acc_tot_sect_count; /* Accumulated total section count from bins */ + hsize_t acc_serial_sect_count; /* Accumulated serializable section count from bins */ + hsize_t acc_ghost_sect_count; /* Accumulated ghost section count from bins */ + size_t acc_tot_size_count; /* Accumulated total section size count from bins */ + size_t acc_serial_size_count; /* Accumulated serializable section size count from bins */ + size_t acc_ghost_size_count; /* Accumulated ghost section size count from bins */ + unsigned u; /* Local index variable */ /* Walk through all sections in bins */ - acc_tot_sect_count = 0; + acc_tot_sect_count = 0; acc_serial_sect_count = 0; - acc_ghost_sect_count = 0; - acc_tot_size_count = 0; + acc_ghost_sect_count = 0; + acc_tot_size_count = 0; acc_serial_size_count = 0; - acc_ghost_size_count = 0; - for(u = 0; u < fspace->sinfo->nbins; u++) { + acc_ghost_size_count = 0; + for (u = 0; u < fspace->sinfo->nbins; u++) { acc_tot_sect_count += fspace->sinfo->bins[u].tot_sect_count; acc_serial_sect_count += fspace->sinfo->bins[u].serial_sect_count; acc_ghost_sect_count += fspace->sinfo->bins[u].ghost_sect_count; - if(fspace->sinfo->bins[u].bin_list) { - H5SL_node_t *curr_size_node; /* Current section size node in skip list */ - size_t bin_serial_count; /* # of serializable sections in this bin */ - size_t bin_ghost_count; /* # of ghost sections in this bin */ + if (fspace->sinfo->bins[u].bin_list) { + H5SL_node_t *curr_size_node; /* Current section size node in skip list */ + size_t bin_serial_count; /* # of serializable sections in this bin */ + size_t bin_ghost_count; /* # of ghost sections in this bin */ acc_tot_size_count += H5SL_count(fspace->sinfo->bins[u].bin_list); /* Walk through the sections in this bin */ - curr_size_node = H5SL_first(fspace->sinfo->bins[u].bin_list); + curr_size_node = H5SL_first(fspace->sinfo->bins[u].bin_list); bin_serial_count = 0; - bin_ghost_count = 0; - while(curr_size_node != NULL) { + bin_ghost_count = 0; + while (curr_size_node != NULL) { H5FS_node_t *fspace_node; /* Section size node */ H5SL_node_t *curr_sect_node; /* Current section node in skip list */ - size_t size_serial_count; /* # of serializable sections of this size */ - size_t size_ghost_count; /* # of ghost sections of this size */ + size_t size_serial_count; /* # of serializable sections of this size */ + size_t size_ghost_count; /* # of ghost sections of this size */ /* Get section size node */ fspace_node = (H5FS_node_t *)H5SL_item(curr_size_node); /* Check sections on list */ - curr_sect_node = H5SL_first(fspace_node->sect_list); + curr_sect_node = H5SL_first(fspace_node->sect_list); size_serial_count = 0; - size_ghost_count = 0; - while(curr_sect_node != NULL) { - H5FS_section_class_t *cls; /* Class of section */ - H5FS_section_info_t *sect; /* Section */ + size_ghost_count = 0; + while (curr_sect_node != NULL) { + H5FS_section_class_t *cls; /* Class of section */ + H5FS_section_info_t * sect; /* Section */ /* Get section node & it's class */ sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node); - cls = &fspace->sect_cls[sect->type]; + cls = &fspace->sect_cls[sect->type]; #ifdef QAK -HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H5FS__sect_assert", sect->size, sect->addr, sect->type); + HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", + "H5FS__sect_assert", sect->size, sect->addr, sect->type); #endif /* QAK */ /* Sanity check section */ HDassert(H5F_addr_defined(sect->addr)); HDassert(fspace_node->sect_size == sect->size); - if(cls->valid) + if (cls->valid) (*cls->valid)(cls, sect); /* Add to correct count */ - if(cls->flags & H5FS_CLS_GHOST_OBJ) + if (cls->flags & H5FS_CLS_GHOST_OBJ) size_ghost_count++; else size_serial_count++; /* Count node, if separate */ - if(cls->flags & H5FS_CLS_SEPAR_OBJ) + if (cls->flags & H5FS_CLS_SEPAR_OBJ) separate_obj++; /* Get the next section node in the list */ @@ -2334,9 +2356,9 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H HDassert(fspace_node->ghost_count == size_ghost_count); /* Add to global count of serializable & ghost section sizes */ - if(fspace_node->serial_count > 0) + if (fspace_node->serial_count > 0) acc_serial_size_count++; - if(fspace_node->ghost_count > 0) + if (fspace_node->ghost_count > 0) acc_ghost_size_count++; /* Add to bin's serializable & ghost counts */ @@ -2352,7 +2374,7 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H HDassert(fspace->sinfo->bins[u].serial_sect_count == bin_serial_count); HDassert(fspace->sinfo->bins[u].ghost_sect_count == bin_ghost_count); } /* end if */ - } /* end for */ + } /* end for */ /* Check counts from bins vs. global counts */ HDassert(fspace->sinfo->tot_size_count == acc_tot_size_count); @@ -2370,14 +2392,13 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H } /* end else */ /* Make certain that the number of sections on the address list is correct */ - if(fspace->sinfo->merge_list) + if (fspace->sinfo->merge_list) HDassert(fspace->tot_sect_count == (separate_obj + H5SL_count(fspace->sinfo->merge_list))); FUNC_LEAVE_NOAPI_VOID } /* end H5FS__sect_assert() */ #endif /* H5FS_DEBUG_ASSERT */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_try_shrink_eoa * @@ -2393,60 +2414,60 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H htri_t H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, void *op_data) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t section_removed = FALSE; /* Whether a section was removed */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t section_removed = FALSE; /* Whether a section was removed */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments. */ HDassert(fspace); - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; - if(fspace->sinfo && fspace->sinfo->merge_list) { - H5SL_node_t *last_node; /* Last node in merge list */ + if (fspace->sinfo && fspace->sinfo->merge_list) { + H5SL_node_t *last_node; /* Last node in merge list */ /* Check for last node in the merge list */ - if(NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { - H5FS_section_info_t *tmp_sect; /* Temporary free space section */ - H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */ + if (NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { + H5FS_section_info_t * tmp_sect; /* Temporary free space section */ + H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */ /* Get the pointer to the last section, from the last node */ tmp_sect = (H5FS_section_info_t *)H5SL_item(last_node); HDassert(tmp_sect); tmp_sect_cls = &fspace->sect_cls[tmp_sect->type]; - if(tmp_sect_cls->can_shrink) { + if (tmp_sect_cls->can_shrink) { /* Check if the section can be shrunk away */ - if((ret_value = (*tmp_sect_cls->can_shrink)(tmp_sect, op_data)) < 0) + if ((ret_value = (*tmp_sect_cls->can_shrink)(tmp_sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTSHRINK, FAIL, "can't check for shrinking container") - if(ret_value > 0) { + if (ret_value > 0) { HDassert(tmp_sect_cls->shrink); /* Remove section from free space manager */ - if(H5FS__sect_remove_real(fspace, tmp_sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (H5FS__sect_remove_real(fspace, tmp_sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") section_removed = TRUE; /* Shrink away section */ - if((*tmp_sect_cls->shrink)(&tmp_sect, op_data) < 0) + if ((*tmp_sect_cls->shrink)(&tmp_sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't shrink free space container") } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, section_removed) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, section_removed) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_shrink_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FS_vfd_alloc_hdr_and_section_info_if_needed * @@ -2485,14 +2506,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, - haddr_t *fs_addr_ptr) +H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr_ptr) { - hsize_t hdr_alloc_size; - hsize_t sinfo_alloc_size; - haddr_t sect_addr = HADDR_UNDEF; /* address of sinfo */ - haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t hdr_alloc_size; + hsize_t sinfo_alloc_size; + haddr_t sect_addr = HADDR_UNDEF; /* address of sinfo */ + haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2517,71 +2537,74 @@ H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, HDassert((f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) || (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE)); - if(fspace->serial_sect_count > 0 && fspace->sinfo) { + if (fspace->serial_sect_count > 0 && fspace->sinfo) { /* the section info is floating, so space->sinfo should be defined */ - if(!H5F_addr_defined(fspace->addr)) { + if (!H5F_addr_defined(fspace->addr)) { /* start by allocating file space for the header */ /* Get the EOA for the file -- need for sanity check below */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_HDR))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_HDR))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") /* check for overlap into temporary allocation space */ - if(H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "hdr file space alloc will overlap into 'temporary' file space") + if (H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, + "hdr file space alloc will overlap into 'temporary' file space") hdr_alloc_size = H5FS_HEADER_SIZE(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(0 == (eoa % f->shared->fs_page_size)); /* Allocate space for the free space header */ - if(HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, hdr_alloc_size))) + if (HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, hdr_alloc_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for free space header") /* Cache the new free space header (pinned) */ - if(H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space header to cache") *fs_addr_ptr = fspace->addr; } - if(!H5F_addr_defined(fspace->sect_addr)) { + if (!H5F_addr_defined(fspace->sect_addr)) { /* now allocate file space for the section info */ /* Get the EOA for the file -- need for sanity check below */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_SINFO))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_SINFO))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "Unable to get eoa") /* check for overlap into temporary allocation space */ - if(H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_BADRANGE, FAIL, "sinfo file space alloc will overlap into 'temporary' file space") + if (H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_BADRANGE, FAIL, + "sinfo file space alloc will overlap into 'temporary' file space") sinfo_alloc_size = fspace->sect_size; - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(0 == (eoa % f->shared->fs_page_size)); /* allocate space for the section info */ - if(HADDR_UNDEF == (sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, sinfo_alloc_size))) + if (HADDR_UNDEF == (sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, sinfo_alloc_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for section info") /* update fspace->alloc_sect_size and fspace->sect_addr to reflect * the allocation */ - if(fspace->sect_size > sinfo_alloc_size) { + if (fspace->sect_size > sinfo_alloc_size) { hsize_t saved_sect_size = fspace->sect_size; - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, sect_addr, sinfo_alloc_size) < 0) + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, sect_addr, sinfo_alloc_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections") fspace->sect_size = saved_sect_size; - } else { + } + else { fspace->alloc_sect_size = sinfo_alloc_size; - fspace->sect_size = sinfo_alloc_size; - fspace->sect_addr = sect_addr; + fspace->sect_size = sinfo_alloc_size; + fspace->sect_addr = sect_addr; /* insert the new section info into the metadata cache. */ @@ -2606,18 +2629,19 @@ H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, * * JRM -- 11/4/16 */ - if(H5AC_insert_entry(f, H5AC_FSPACE_SINFO, sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_SINFO, sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sinfo to cache") /* We have changed the sinfo address -- Mark free space header dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") /* since space has been allocated for the section info and the sinfo * has been inserted into the cache, relinquish ownership (i.e. float) * the section info. */ - fspace->sinfo = NULL; + fspace->sinfo = NULL; } } } /* end if */ @@ -2625,4 +2649,3 @@ H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_vfd_alloc_hdr_and_section_info_if_needed() */ - diff --git a/src/H5FSstat.c b/src/H5FSstat.c index e2ad5bb..6c15dd5 100644 --- a/src/H5FSstat.c +++ b/src/H5FSstat.c @@ -20,53 +20,43 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* Free-space manager */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* Free-space manager */ /****************/ /* Local Macros */ /****************/ - /********************/ /* Package Typedefs */ /********************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS_stat_info * @@ -89,16 +79,15 @@ H5FS_stat_info(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *stats) HDassert(stats); /* Report statistics for free space */ - stats->tot_space = frsp->tot_space; - stats->tot_sect_count = frsp->tot_sect_count; + stats->tot_space = frsp->tot_space; + stats->tot_sect_count = frsp->tot_sect_count; stats->serial_sect_count = frsp->serial_sect_count; - stats->ghost_sect_count = frsp->ghost_sect_count; - stats->addr = frsp->addr; - stats->hdr_size = (hsize_t)H5FS_HEADER_SIZE(f); - stats->sect_addr = frsp->sect_addr; - stats->alloc_sect_size = frsp->alloc_sect_size; - stats->sect_size = frsp->sect_size; + stats->ghost_sect_count = frsp->ghost_sect_count; + stats->addr = frsp->addr; + stats->hdr_size = (hsize_t)H5FS_HEADER_SIZE(f); + stats->sect_addr = frsp->sect_addr; + stats->alloc_sect_size = frsp->alloc_sect_size; + stats->sect_size = frsp->sect_size; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FS_stat_info() */ - diff --git a/src/H5FStest.c b/src/H5FStest.c index 120a9a8..4a778bd 100644 --- a/src/H5FStest.c +++ b/src/H5FStest.c @@ -20,54 +20,44 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ -#define H5FS_TESTING /* Suppress warning about H5FS testing funcs */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ +#define H5FS_TESTING /* Suppress warning about H5FS testing funcs */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* Free-space manager */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* Free-space manager */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS__get_cparam_test * @@ -90,16 +80,15 @@ H5FS__get_cparam_test(const H5FS_t *frsp, H5FS_create_t *cparam) HDassert(frsp); HDassert(cparam); - cparam->client = frsp->client; + cparam->client = frsp->client; cparam->shrink_percent = frsp->shrink_percent; cparam->expand_percent = frsp->expand_percent; - cparam->max_sect_addr = frsp->max_sect_addr; - cparam->max_sect_size = frsp->max_sect_size; + cparam->max_sect_addr = frsp->max_sect_addr; + cparam->max_sect_size = frsp->max_sect_size; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FS__get_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5FS__cmp_cparam_test * @@ -116,7 +105,7 @@ H5FS__get_cparam_test(const H5FS_t *frsp, H5FS_create_t *cparam) int H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -124,32 +113,31 @@ H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2 HDassert(cparam1); HDassert(cparam2); - if(cparam1->client < cparam2->client) + if (cparam1->client < cparam2->client) HGOTO_DONE(-1) - else if(cparam1->client > cparam2->client) + else if (cparam1->client > cparam2->client) HGOTO_DONE(1) - if(cparam1->shrink_percent < cparam2->shrink_percent) + if (cparam1->shrink_percent < cparam2->shrink_percent) HGOTO_DONE(-1) - else if(cparam1->shrink_percent > cparam2->shrink_percent) + else if (cparam1->shrink_percent > cparam2->shrink_percent) HGOTO_DONE(1) - if(cparam1->expand_percent < cparam2->expand_percent) + if (cparam1->expand_percent < cparam2->expand_percent) HGOTO_DONE(-1) - else if(cparam1->expand_percent > cparam2->expand_percent) + else if (cparam1->expand_percent > cparam2->expand_percent) HGOTO_DONE(1) - if(cparam1->max_sect_size < cparam2->max_sect_size) + if (cparam1->max_sect_size < cparam2->max_sect_size) HGOTO_DONE(-1) - else if(cparam1->max_sect_size > cparam2->max_sect_size) + else if (cparam1->max_sect_size > cparam2->max_sect_size) HGOTO_DONE(1) - if(cparam1->max_sect_addr < cparam2->max_sect_addr) + if (cparam1->max_sect_addr < cparam2->max_sect_addr) HGOTO_DONE(-1) - else if(cparam1->max_sect_addr > cparam2->max_sect_addr) + else if (cparam1->max_sect_addr > cparam2->max_sect_addr) HGOTO_DONE(1) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__cmp_cparam_test */ - diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 74a170b..dd6bba3 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -28,29 +28,26 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ /* Metadata accumulator controls */ -#define H5F_ACCUM_THROTTLE 8 -#define H5F_ACCUM_THRESHOLD 2048 -#define H5F_ACCUM_MAX_SIZE (1024 *1024) /* Max. accum. buf size (max. I/Os will be 1/2 this size) */ - +#define H5F_ACCUM_THROTTLE 8 +#define H5F_ACCUM_THRESHOLD 2048 +#define H5F_ACCUM_MAX_SIZE (1024 * 1024) /* Max. accum. buf size (max. I/Os will be 1/2 this size) */ /******************/ /* Local Typedefs */ @@ -58,31 +55,26 @@ /* Enumerated type to indicate how data will be added to accumulator */ typedef enum { - H5F_ACCUM_PREPEND, /* Data will be prepended to accumulator */ - H5F_ACCUM_APPEND /* Data will be appended to accumulator */ + H5F_ACCUM_PREPEND, /* Data will be prepended to accumulator */ + H5F_ACCUM_APPEND /* Data will be appended to accumulator */ } H5F_accum_adjust_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -90,8 +82,6 @@ typedef enum { /* Declare a PQ free list to manage the metadata accumulator buffer */ H5FL_BLK_DEFINE_STATIC(meta_accum); - - /*------------------------------------------------------------------------- * Function: H5F__accum_read * @@ -111,11 +101,10 @@ H5FL_BLK_DEFINE_STATIC(meta_accum); *------------------------------------------------------------------------- */ herr_t -H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, - size_t size, void *buf/*out*/) +H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t size, void *buf /*out*/) { - H5FD_t *file; /* File driver pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_t *file; /* File driver pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -127,38 +116,38 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, file = f_sh->lf; /* Check if this information is in the metadata accumulator */ - if((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { - H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ /* Set up alias for file's metadata accumulator info */ accum = &f_sh->accum; - if(size < H5F_ACCUM_MAX_SIZE) { + if (size < H5F_ACCUM_MAX_SIZE) { /* Sanity check */ HDassert(!accum->buf || (accum->alloc_size >= accum->size)); /* Current read adjoins or overlaps with metadata accumulator */ - if(H5F_addr_overlap(addr, size, accum->loc, accum->size) - || ((addr + size) == accum->loc) - || (accum->loc + accum->size) == addr) { - size_t amount_before; /* Amount to read before current accumulator */ - haddr_t new_addr; /* New address of the accumulator buffer */ - size_t new_size; /* New size of the accumulator buffer */ + if (H5F_addr_overlap(addr, size, accum->loc, accum->size) || ((addr + size) == accum->loc) || + (accum->loc + accum->size) == addr) { + size_t amount_before; /* Amount to read before current accumulator */ + haddr_t new_addr; /* New address of the accumulator buffer */ + size_t new_size; /* New size of the accumulator buffer */ /* Compute new values for accumulator */ new_addr = MIN(addr, accum->loc); new_size = (size_t)(MAX((addr + size), (accum->loc + accum->size)) - new_addr); /* Check if we need more buffer space */ - if(new_size > accum->alloc_size) { - size_t new_alloc_size; /* New size of accumulator */ + if (new_size > accum->alloc_size) { + size_t new_alloc_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_alloc_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(new_size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = new_alloc_size; @@ -168,7 +157,7 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, } /* end if */ /* Read the part before the metadata accumulator */ - if(addr < accum->loc) { + if (addr < accum->loc) { /* Set the amount to read */ H5_CHECKED_ASSIGN(amount_before, size_t, (accum->loc - addr), hsize_t); @@ -176,25 +165,27 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, HDmemmove(accum->buf + amount_before, accum->buf, accum->size); /* Adjust dirty region tracking info, if present */ - if(accum->dirty) + if (accum->dirty) accum->dirty_off += amount_before; /* Dispatch to driver */ - if(H5FD_read(file, map_type, addr, amount_before, accum->buf) < 0) + if (H5FD_read(file, map_type, addr, amount_before, accum->buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ else amount_before = 0; /* Read the part after the metadata accumulator */ - if((addr + size) > (accum->loc + accum->size)) { - size_t amount_after; /* Amount to read at a time */ + if ((addr + size) > (accum->loc + accum->size)) { + size_t amount_after; /* Amount to read at a time */ /* Set the amount to read */ - H5_CHECKED_ASSIGN(amount_after, size_t, ((addr + size) - (accum->loc + accum->size)), hsize_t); + H5_CHECKED_ASSIGN(amount_after, size_t, ((addr + size) - (accum->loc + accum->size)), + hsize_t); /* Dispatch to driver */ - if(H5FD_read(file, map_type, (accum->loc + accum->size), amount_after, (accum->buf + accum->size + amount_before)) < 0) + if (H5FD_read(file, map_type, (accum->loc + accum->size), amount_after, + (accum->buf + accum->size + amount_before)) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ @@ -202,19 +193,19 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, H5MM_memcpy(buf, accum->buf + (addr - new_addr), size); /* Adjust the accumulator address & size */ - accum->loc = new_addr; + accum->loc = new_addr; accum->size = new_size; } /* end if */ /* Current read doesn't overlap with metadata accumulator, read it from file */ else { /* Dispatch to driver */ - if(H5FD_read(file, map_type, addr, size, buf) < 0) + if (H5FD_read(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ - } /* end if */ + } /* end if */ else { /* Read the data */ - if(H5FD_read(file, map_type, addr, size, buf) < 0) + if (H5FD_read(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") /* Check for overlap w/dirty accumulator */ @@ -222,15 +213,15 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, * information in the accumulator with [some of] the information * just read in. -QAK) */ - if(accum->dirty && - H5F_addr_overlap(addr, size, accum->loc + accum->dirty_off, accum->dirty_len)) { - haddr_t dirty_loc = accum->loc + accum->dirty_off; /* File offset of dirty information */ - size_t buf_off; /* Offset of dirty region in buffer */ - size_t dirty_off; /* Offset within dirty region */ - size_t overlap_size; /* Size of overlap with dirty region */ + if (accum->dirty && + H5F_addr_overlap(addr, size, accum->loc + accum->dirty_off, accum->dirty_len)) { + haddr_t dirty_loc = accum->loc + accum->dirty_off; /* File offset of dirty information */ + size_t buf_off; /* Offset of dirty region in buffer */ + size_t dirty_off; /* Offset within dirty region */ + size_t overlap_size; /* Size of overlap with dirty region */ /* Check for read starting before beginning dirty region */ - if(H5F_addr_le(addr, dirty_loc)) { + if (H5F_addr_le(addr, dirty_loc)) { /* Compute offset of dirty region within buffer */ buf_off = (size_t)(dirty_loc - addr); @@ -238,26 +229,27 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, dirty_off = 0; /* Check for read ending within dirty region */ - if(H5F_addr_lt(addr + size, dirty_loc + accum->dirty_len)) + if (H5F_addr_lt(addr + size, dirty_loc + accum->dirty_len)) overlap_size = (size_t)((addr + size) - buf_off); - else /* Access covers whole dirty region */ + else /* Access covers whole dirty region */ overlap_size = accum->dirty_len; - } /* end if */ + } /* end if */ else { /* Read starts after beginning of dirty region */ /* Compute dirty offset within buffer and overlap size */ - buf_off = 0; - dirty_off = (size_t)(addr - dirty_loc); + buf_off = 0; + dirty_off = (size_t)(addr - dirty_loc); overlap_size = (size_t)((dirty_loc + accum->dirty_len) - addr); } /* end else */ /* Copy the dirty region to buffer */ - H5MM_memcpy((unsigned char *)buf + buf_off, (unsigned char *)accum->buf + accum->dirty_off + dirty_off, overlap_size); + H5MM_memcpy((unsigned char *)buf + buf_off, + (unsigned char *)accum->buf + accum->dirty_off + dirty_off, overlap_size); } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Read the data */ - if(H5FD_read(file, map_type, addr, size, buf) < 0) + if (H5FD_read(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ @@ -265,7 +257,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_read() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_adjust * @@ -280,10 +271,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, - H5F_accum_adjust_t adjust, size_t size) +H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, H5F_accum_adjust_t adjust, size_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -294,70 +284,75 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, HDassert(size <= H5F_ACCUM_MAX_SIZE); /* Check if we need more buffer space */ - if((size + accum->size) > accum->alloc_size) { - size_t new_size; /* New size of accumulator */ + if ((size + accum->size) > accum->alloc_size) { + size_t new_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)((size + accum->size) - 1))); /* Check for accumulator getting too big */ - if(new_size > H5F_ACCUM_MAX_SIZE) { - size_t shrink_size; /* Amount to shrink accumulator by */ - size_t remnant_size; /* Amount left in accumulator */ + if (new_size > H5F_ACCUM_MAX_SIZE) { + size_t shrink_size; /* Amount to shrink accumulator by */ + size_t remnant_size; /* Amount left in accumulator */ /* Cap the accumulator's growth, leaving some room */ /* Determine the amounts to work with */ - if(size > (H5F_ACCUM_MAX_SIZE / 2)) { - new_size = H5F_ACCUM_MAX_SIZE; - shrink_size = accum->size; + if (size > (H5F_ACCUM_MAX_SIZE / 2)) { + new_size = H5F_ACCUM_MAX_SIZE; + shrink_size = accum->size; remnant_size = 0; } /* end if */ else { - if(H5F_ACCUM_PREPEND == adjust) { - new_size = (H5F_ACCUM_MAX_SIZE / 2); - shrink_size = (H5F_ACCUM_MAX_SIZE / 2); + if (H5F_ACCUM_PREPEND == adjust) { + new_size = (H5F_ACCUM_MAX_SIZE / 2); + shrink_size = (H5F_ACCUM_MAX_SIZE / 2); remnant_size = accum->size - shrink_size; } /* end if */ else { size_t adjust_size = size + accum->dirty_len; /* Check if we can slide the dirty region down, to accommodate the request */ - if(accum->dirty && (adjust_size <= H5F_ACCUM_MAX_SIZE)) { - if((ssize_t)(H5F_ACCUM_MAX_SIZE - (accum->dirty_off + adjust_size)) >= (ssize_t)(2 * size)) + if (accum->dirty && (adjust_size <= H5F_ACCUM_MAX_SIZE)) { + if ((ssize_t)(H5F_ACCUM_MAX_SIZE - (accum->dirty_off + adjust_size)) >= + (ssize_t)(2 * size)) shrink_size = accum->dirty_off / 2; else shrink_size = accum->dirty_off; remnant_size = accum->size - shrink_size; - new_size = remnant_size + size; + new_size = remnant_size + size; } /* end if */ else { - new_size = (H5F_ACCUM_MAX_SIZE / 2); - shrink_size = (H5F_ACCUM_MAX_SIZE / 2); + new_size = (H5F_ACCUM_MAX_SIZE / 2); + shrink_size = (H5F_ACCUM_MAX_SIZE / 2); remnant_size = accum->size - shrink_size; } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Check if we need to flush accumulator data to file */ - if(accum->dirty) { + if (accum->dirty) { /* Check whether to accumulator will be prepended or appended */ - if(H5F_ACCUM_PREPEND == adjust) { + if (H5F_ACCUM_PREPEND == adjust) { /* Check if the dirty region overlaps the region to eliminate from the accumulator */ - if((accum->size - shrink_size) < (accum->dirty_off + accum->dirty_len)) { - /* Write out the dirty region from the metadata accumulator, with dispatch to driver */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) + if ((accum->size - shrink_size) < (accum->dirty_off + accum->dirty_len)) { + /* Write out the dirty region from the metadata accumulator, with dispatch to driver + */ + if (H5FD_write(file, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), + accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ accum->dirty = FALSE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Check if the dirty region overlaps the region to eliminate from the accumulator */ - if(shrink_size > accum->dirty_off) { - /* Write out the dirty region from the metadata accumulator, with dispatch to driver */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) + if (shrink_size > accum->dirty_off) { + /* Write out the dirty region from the metadata accumulator, with dispatch to driver + */ + if (H5FD_write(file, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), + accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -367,43 +362,42 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, /* Adjust dirty region tracking info */ accum->dirty_off -= shrink_size; } /* end else */ - } /* end if */ + } /* end if */ /* Trim the accumulator's use of its buffer */ accum->size = remnant_size; /* When appending, need to adjust location of accumulator */ - if(H5F_ACCUM_APPEND == adjust) { + if (H5F_ACCUM_APPEND == adjust) { /* Move remnant of accumulator down */ HDmemmove(accum->buf, (accum->buf + shrink_size), remnant_size); /* Adjust accumulator's location */ accum->loc += shrink_size; } /* end if */ - } /* end if */ + } /* end if */ /* Check for accumulator needing to be reallocated */ - if(new_size > accum->alloc_size) { - unsigned char *new_buf; /* New buffer to hold the accumulated metadata */ + if (new_size > accum->alloc_size) { + unsigned char *new_buf; /* New buffer to hold the accumulated metadata */ /* Reallocate the metadata accumulator buffer */ - if(NULL == (new_buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) + if (NULL == (new_buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate metadata accumulator buffer") /* Update accumulator info */ - accum->buf = new_buf; + accum->buf = new_buf; accum->alloc_size = new_size; /* Clear the memory */ HDmemset(accum->buf + accum->size, 0, (accum->alloc_size - (accum->size + size))); } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_adjust() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_write * @@ -419,11 +413,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, - size_t size, const void *buf) +H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t size, const void *buf) { - H5FD_t *file; /* File driver pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_t *file; /* File driver pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -436,22 +429,22 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, file = f_sh->lf; /* Check for accumulating metadata */ - if((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { - H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ /* Set up alias for file's metadata accumulator info */ accum = &f_sh->accum; - if(size < H5F_ACCUM_MAX_SIZE) { + if (size < H5F_ACCUM_MAX_SIZE) { /* Sanity check */ HDassert(!accum->buf || (accum->alloc_size >= accum->size)); /* Check if there is already metadata in the accumulator */ - if(accum->size > 0) { + if (accum->size > 0) { /* Check if the new metadata adjoins the beginning of the current accumulator */ - if((addr + size) == accum->loc) { + if ((addr + size) == accum->loc) { /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, file, H5F_ACCUM_PREPEND, size) < 0) + if (H5F__accum_adjust(accum, file, H5F_ACCUM_PREPEND, size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Move the existing metadata to the proper location */ @@ -465,78 +458,79 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, accum->size += size; /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) + if (accum->dirty) accum->dirty_len = size + accum->dirty_off + accum->dirty_len; else { accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ accum->dirty_off = 0; } /* end if */ /* Check if the new metadata adjoins the end of the current accumulator */ - else if(addr == (accum->loc + accum->size)) { + else if (addr == (accum->loc + accum->size)) { /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, file, H5F_ACCUM_APPEND, size) < 0) + if (H5F__accum_adjust(accum, file, H5F_ACCUM_APPEND, size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Copy the new metadata to the end */ H5MM_memcpy(accum->buf + accum->size, buf, size); /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) + if (accum->dirty) accum->dirty_len = size + (accum->size - accum->dirty_off); else { accum->dirty_off = accum->size; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ /* Set the new size of the metadata accumulator */ accum->size += size; } /* end if */ /* Check if the piece of metadata being written overlaps the metadata accumulator */ - else if(H5F_addr_overlap(addr, size, accum->loc, accum->size)) { - size_t add_size; /* New size of the accumulator buffer */ + else if (H5F_addr_overlap(addr, size, accum->loc, accum->size)) { + size_t add_size; /* New size of the accumulator buffer */ /* Check if the new metadata is entirely within the current accumulator */ - if(addr >= accum->loc && (addr + size) <= (accum->loc + accum->size)) { + if (addr >= accum->loc && (addr + size) <= (accum->loc + accum->size)) { size_t dirty_off = (size_t)(addr - accum->loc); /* Copy the new metadata to the proper location within the accumulator */ H5MM_memcpy(accum->buf + dirty_off, buf, size); /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) { + if (accum->dirty) { /* Check for new metadata starting before current dirty region */ - if(dirty_off <= accum->dirty_off) { - if((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) + if (dirty_off <= accum->dirty_off) { + if ((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) accum->dirty_len = (accum->dirty_off + accum->dirty_len) - dirty_off; else accum->dirty_len = size; accum->dirty_off = dirty_off; } /* end if */ else { - if((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) + if ((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) ; /* accum->dirty_len doesn't change */ else accum->dirty_len = (dirty_off + size) - accum->dirty_off; } /* end else */ - } /* end if */ + } /* end if */ else { accum->dirty_off = dirty_off; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the new metadata overlaps the beginning of the current accumulator */ - else if(addr < accum->loc && (addr + size) <= (accum->loc + accum->size)) { - size_t old_offset; /* Offset of old data within the accumulator buffer */ + else if (addr < accum->loc && (addr + size) <= (accum->loc + accum->size)) { + size_t old_offset; /* Offset of old data within the accumulator buffer */ - /* Calculate the amount we will need to add to the accumulator size, based on the amount of overlap */ + /* Calculate the amount we will need to add to the accumulator size, based on the + * amount of overlap */ H5_CHECKED_ASSIGN(add_size, size_t, (accum->loc - addr), hsize_t); /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, file, H5F_ACCUM_PREPEND, add_size) < 0) + if (H5F__accum_adjust(accum, file, H5F_ACCUM_PREPEND, add_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Calculate the proper offset of the existing metadata */ @@ -553,11 +547,11 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, accum->size += add_size; /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) { + if (accum->dirty) { size_t curr_dirty_end = add_size + accum->dirty_off + accum->dirty_len; accum->dirty_off = 0; - if(size <= curr_dirty_end) + if (size <= curr_dirty_end) accum->dirty_len = curr_dirty_end; else accum->dirty_len = size; @@ -565,18 +559,20 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, else { accum->dirty_off = 0; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the new metadata overlaps the end of the current accumulator */ - else if(addr >= accum->loc && (addr + size) > (accum->loc + accum->size)) { - size_t dirty_off; /* Offset of dirty region */ + else if (addr >= accum->loc && (addr + size) > (accum->loc + accum->size)) { + size_t dirty_off; /* Offset of dirty region */ - /* Calculate the amount we will need to add to the accumulator size, based on the amount of overlap */ - H5_CHECKED_ASSIGN(add_size, size_t, (addr + size) - (accum->loc + accum->size), hsize_t); + /* Calculate the amount we will need to add to the accumulator size, based on the + * amount of overlap */ + H5_CHECKED_ASSIGN(add_size, size_t, (addr + size) - (accum->loc + accum->size), + hsize_t); /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, file, H5F_ACCUM_APPEND, add_size) < 0) + if (H5F__accum_adjust(accum, file, H5F_ACCUM_APPEND, add_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Compute offset of dirty region (after adjusting accumulator) */ @@ -589,34 +585,36 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, accum->size += add_size; /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) { + if (accum->dirty) { /* Check for new metadata starting before current dirty region */ - if(dirty_off <= accum->dirty_off) { + if (dirty_off <= accum->dirty_off) { accum->dirty_off = dirty_off; accum->dirty_len = size; } /* end if */ else { accum->dirty_len = (dirty_off + size) - accum->dirty_off; } /* end else */ - } /* end if */ + } /* end if */ else { accum->dirty_off = dirty_off; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* New metadata overlaps both ends of the current accumulator */ else { /* Check if we need more buffer space */ - if(size > accum->alloc_size) { - size_t new_alloc_size; /* New size of accumulator */ + if (size > accum->alloc_size) { + size_t new_alloc_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_alloc_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == + (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = new_alloc_size; @@ -629,20 +627,21 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, H5MM_memcpy(accum->buf, buf, size); /* Set the new size & location of the metadata accumulator */ - accum->loc = addr; + accum->loc = addr; accum->size = size; /* Adjust the dirty region and mark accumulator dirty */ accum->dirty_off = 0; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* New piece of metadata doesn't adjoin or overlap the existing accumulator */ else { /* Write out the existing metadata accumulator, with dispatch to driver */ - if(accum->dirty) { - if(H5FD_write(file, H5FD_MEM_DEFAULT, accum->loc + accum->dirty_off, accum->dirty_len, accum->buf + accum->dirty_off) < 0) + if (accum->dirty) { + if (H5FD_write(file, H5FD_MEM_DEFAULT, accum->loc + accum->dirty_off, + accum->dirty_len, accum->buf + accum->dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -651,16 +650,17 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, /* Cache the new piece of metadata */ /* Check if we need to resize the buffer */ - if(size > accum->alloc_size) { - size_t new_size; /* New size of accumulator */ - size_t clear_size; /* Size of memory that needs clearing */ + if (size > accum->alloc_size) { + size_t new_size; /* New size of accumulator */ + size_t clear_size; /* Size of memory that needs clearing */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Grow the metadata accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = new_size; @@ -671,21 +671,23 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, } /* end if */ else { /* Check if we should shrink the accumulator buffer */ - if(size < (accum->alloc_size / H5F_ACCUM_THROTTLE) && - accum->alloc_size > H5F_ACCUM_THRESHOLD) { - size_t tmp_size = (accum->alloc_size / H5F_ACCUM_THROTTLE); /* New size of accumulator buffer */ + if (size < (accum->alloc_size / H5F_ACCUM_THROTTLE) && + accum->alloc_size > H5F_ACCUM_THRESHOLD) { + size_t tmp_size = + (accum->alloc_size / H5F_ACCUM_THROTTLE); /* New size of accumulator buffer */ /* Shrink the accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, tmp_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, tmp_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = tmp_size; } /* end if */ - } /* end else */ + } /* end else */ /* Update the metadata accumulator information */ - accum->loc = addr; + accum->loc = addr; accum->size = size; /* Store the piece of metadata in the accumulator */ @@ -694,21 +696,22 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, /* Adjust the dirty region and mark accumulator dirty */ accum->dirty_off = 0; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* No metadata in the accumulator, grab this piece and keep it */ else { /* Check if we need to reallocate the buffer */ - if(size > accum->alloc_size) { - size_t new_size; /* New size of accumulator */ + if (size > accum->alloc_size) { + size_t new_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = new_size; @@ -718,7 +721,7 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, } /* end if */ /* Update the metadata accumulator information */ - accum->loc = addr; + accum->loc = addr; accum->size = size; /* Store the piece of metadata in the accumulator */ @@ -727,68 +730,70 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, /* Adjust the dirty region and mark accumulator dirty */ accum->dirty_off = 0; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ else { /* Make certain that data in accumulator is visible before new write */ - if((H5F_SHARED_INTENT(f_sh) & H5F_ACC_SWMR_WRITE) > 0) + if ((H5F_SHARED_INTENT(f_sh) & H5F_ACC_SWMR_WRITE) > 0) /* Flush if dirty and reset accumulator */ - if(H5F__accum_reset(f_sh, TRUE) < 0) + if (H5F__accum_reset(f_sh, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") /* Write the data */ - if(H5FD_write(file, map_type, addr, size, buf) < 0) + if (H5FD_write(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Check for overlap w/accumulator */ /* (Note that this could be improved by updating the accumulator * with [some of] the information just read in. -QAK) */ - if(H5F_addr_overlap(addr, size, accum->loc, accum->size)) { + if (H5F_addr_overlap(addr, size, accum->loc, accum->size)) { /* Check for write starting before beginning of accumulator */ - if(H5F_addr_le(addr, accum->loc)) { + if (H5F_addr_le(addr, accum->loc)) { /* Check for write ending within accumulator */ - if(H5F_addr_le(addr + size, accum->loc + accum->size)) { - size_t overlap_size; /* Size of overlapping region */ + if (H5F_addr_le(addr + size, accum->loc + accum->size)) { + size_t overlap_size; /* Size of overlapping region */ /* Compute overlap size */ overlap_size = (size_t)((addr + size) - accum->loc); /* Check for dirty region */ - if(accum->dirty) { - haddr_t dirty_start = accum->loc + accum->dirty_off; /* File address of start of dirty region */ - haddr_t dirty_end = dirty_start + accum->dirty_len; /* File address of end of dirty region */ + if (accum->dirty) { + haddr_t dirty_start = + accum->loc + accum->dirty_off; /* File address of start of dirty region */ + haddr_t dirty_end = + dirty_start + accum->dirty_len; /* File address of end of dirty region */ /* Check if entire dirty region is overwritten */ - if(H5F_addr_le(dirty_end, addr + size)) { - accum->dirty = FALSE; + if (H5F_addr_le(dirty_end, addr + size)) { + accum->dirty = FALSE; accum->dirty_len = 0; } /* end if */ else { /* Check for dirty region falling after write */ - if(H5F_addr_le(addr + size, dirty_start)) + if (H5F_addr_le(addr + size, dirty_start)) accum->dirty_off = overlap_size; - else { /* Dirty region overlaps w/written region */ + else { /* Dirty region overlaps w/written region */ accum->dirty_off = 0; accum->dirty_len -= (size_t)((addr + size) - dirty_start); } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Trim bottom of accumulator off */ accum->loc += overlap_size; accum->size -= overlap_size; HDmemmove(accum->buf, accum->buf + overlap_size, accum->size); - } /* end if */ - else { /* Access covers whole accumulator */ + } /* end if */ + else { /* Access covers whole accumulator */ /* Reset accumulator, but don't flush */ - if(H5F__accum_reset(f_sh, FALSE) < 0) + if (H5F__accum_reset(f_sh, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") - } /* end else */ - } /* end if */ - else { /* Write starts after beginning of accumulator */ - size_t overlap_size; /* Size of overlapping region */ + } /* end else */ + } /* end if */ + else { /* Write starts after beginning of accumulator */ + size_t overlap_size; /* Size of overlapping region */ /* Sanity check */ HDassert(H5F_addr_gt(addr + size, accum->loc + accum->size)); @@ -797,33 +802,35 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, overlap_size = (size_t)((accum->loc + accum->size) - addr); /* Check for dirty region */ - if(accum->dirty) { - haddr_t dirty_start = accum->loc + accum->dirty_off; /* File address of start of dirty region */ - haddr_t dirty_end = dirty_start + accum->dirty_len; /* File address of end of dirty region */ + if (accum->dirty) { + haddr_t dirty_start = + accum->loc + accum->dirty_off; /* File address of start of dirty region */ + haddr_t dirty_end = + dirty_start + accum->dirty_len; /* File address of end of dirty region */ /* Check if entire dirty region is overwritten */ - if(H5F_addr_ge(dirty_start, addr)) { - accum->dirty = FALSE; + if (H5F_addr_ge(dirty_start, addr)) { + accum->dirty = FALSE; accum->dirty_len = 0; } /* end if */ else { /* Check for dirty region falling before write */ - if(H5F_addr_le(dirty_end, addr)) + if (H5F_addr_le(dirty_end, addr)) ; /* noop */ - else /* Dirty region overlaps w/written region */ + else /* Dirty region overlaps w/written region */ accum->dirty_len = (size_t)(addr - dirty_start); } /* end if */ - } /* end if */ + } /* end if */ /* Trim top of accumulator off */ accum->size -= overlap_size; } /* end else */ - } /* end if */ - } /* end else */ - } /* end if */ + } /* end if */ + } /* end else */ + } /* end if */ else { /* Write the data */ - if(H5FD_write(file, map_type, addr, size, buf) < 0) + if (H5FD_write(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end else */ @@ -831,7 +838,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_write() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_free * @@ -847,12 +853,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr, - hsize_t size) +H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr, hsize_t size) { - H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ - H5FD_t *file; /* File driver pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + H5FD_t * file; /* File driver pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -866,9 +871,9 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr file = f_sh->lf; /* Adjust the metadata accumulator to remove the freed block, if it overlaps */ - if((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) - && H5F_addr_overlap(addr, size, accum->loc, accum->size)) { - size_t overlap_size; /* Size of overlap with accumulator */ + if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && + H5F_addr_overlap(addr, size, accum->loc, accum->size)) { + size_t overlap_size; /* Size of overlap with accumulator */ /* Sanity check */ /* (The metadata accumulator should not intersect w/raw data */ @@ -876,17 +881,17 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr HDassert(H5FD_MEM_GHEAP != type); /* (global heap data is being treated as raw data currently) */ /* Check for overlapping the beginning of the accumulator */ - if(H5F_addr_le(addr, accum->loc)) { + if (H5F_addr_le(addr, accum->loc)) { /* Check for completely overlapping the accumulator */ - if(H5F_addr_ge(addr + size, accum->loc + accum->size)) { + if (H5F_addr_ge(addr + size, accum->loc + accum->size)) { /* Reset the accumulator, but don't free buffer */ - accum->loc = HADDR_UNDEF; - accum->size = 0; + accum->loc = HADDR_UNDEF; + accum->size = 0; accum->dirty = FALSE; } /* end if */ /* Block to free must end within the accumulator */ else { - size_t new_accum_size; /* Size of new accumulator buffer */ + size_t new_accum_size; /* Size of new accumulator buffer */ /* Calculate the size of the overlap with the accumulator, etc. */ H5_CHECKED_ASSIGN(overlap_size, size_t, (addr + size) - accum->loc, haddr_t); @@ -900,13 +905,13 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr accum->size = new_accum_size; /* Adjust the dirty region and possibly mark accumulator clean */ - if(accum->dirty) { + if (accum->dirty) { /* Check if block freed is entirely before dirty region */ - if(overlap_size < accum->dirty_off) + if (overlap_size < accum->dirty_off) accum->dirty_off -= overlap_size; else { /* Check if block freed ends within dirty region */ - if(overlap_size < (accum->dirty_off + accum->dirty_len)) { + if (overlap_size < (accum->dirty_off + accum->dirty_len)) { accum->dirty_len = (accum->dirty_off + accum->dirty_len) - overlap_size; accum->dirty_off = 0; } /* end if */ @@ -914,45 +919,47 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr else accum->dirty = FALSE; } /* end else */ - } /* end if */ - } /* end else */ - } /* end if */ + } /* end if */ + } /* end else */ + } /* end if */ /* Block to free must start within the accumulator */ else { - haddr_t dirty_end = accum->loc + accum->dirty_off + accum->dirty_len; + haddr_t dirty_end = accum->loc + accum->dirty_off + accum->dirty_len; haddr_t dirty_start = accum->loc + accum->dirty_off; /* Calculate the size of the overlap with the accumulator */ H5_CHECKED_ASSIGN(overlap_size, size_t, (accum->loc + accum->size) - addr, haddr_t); /* Check if block to free begins before end of dirty region */ - if(accum->dirty && H5F_addr_lt(addr, dirty_end)) { + if (accum->dirty && H5F_addr_lt(addr, dirty_end)) { haddr_t tail_addr; /* Calculate the address of the tail to write */ tail_addr = addr + size; /* Check if the block to free begins before dirty region */ - if(H5F_addr_lt(addr, dirty_start)) { + if (H5F_addr_lt(addr, dirty_start)) { /* Check if block to free is entirely before dirty region */ - if(H5F_addr_le(tail_addr, dirty_start)) { + if (H5F_addr_le(tail_addr, dirty_start)) { /* Write out the entire dirty region of the accumulator */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start, accum->dirty_len, accum->buf + accum->dirty_off) < 0) + if (H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start, accum->dirty_len, + accum->buf + accum->dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ /* Block to free overlaps with some/all of dirty region */ /* Check for unfreed dirty region to write */ - else if(H5F_addr_lt(tail_addr, dirty_end)) { + else if (H5F_addr_lt(tail_addr, dirty_end)) { size_t write_size; size_t dirty_delta; - write_size = (size_t)(dirty_end - tail_addr); + write_size = (size_t)(dirty_end - tail_addr); dirty_delta = accum->dirty_len - write_size; HDassert(write_size > 0); /* Write out the unfreed dirty region of the accumulator */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) + if (H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, + accum->buf + accum->dirty_off + dirty_delta) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ @@ -962,22 +969,23 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr /* Block to free begins at beginning of or in middle of dirty region */ else { /* Check if block to free ends before end of dirty region */ - if(H5F_addr_lt(tail_addr, dirty_end)) { + if (H5F_addr_lt(tail_addr, dirty_end)) { size_t write_size; size_t dirty_delta; - write_size = (size_t)(dirty_end - tail_addr); + write_size = (size_t)(dirty_end - tail_addr); dirty_delta = accum->dirty_len - write_size; HDassert(write_size > 0); /* Write out the unfreed end of the dirty region of the accumulator */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) + if (H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, + accum->buf + accum->dirty_off + dirty_delta) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ /* Check for block to free beginning at same location as dirty region */ - if(H5F_addr_eq(addr, dirty_start)) { + if (H5F_addr_eq(addr, dirty_start)) { /* Reset dirty flag */ accum->dirty = FALSE; } /* end if */ @@ -985,20 +993,19 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr else { accum->dirty_len = (size_t)(addr - dirty_start); } /* end else */ - } /* end else */ + } /* end else */ } /* end if */ /* Adjust the accumulator information */ accum->size = accum->size - overlap_size; } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_free() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_flush * @@ -1015,7 +1022,7 @@ done: herr_t H5F__accum_flush(H5F_shared_t *f_sh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1023,14 +1030,15 @@ H5F__accum_flush(H5F_shared_t *f_sh) HDassert(f_sh); /* Check if we need to flush out the metadata accumulator */ - if((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && f_sh->accum.dirty) { - H5FD_t *file; /* File driver pointer */ + if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && f_sh->accum.dirty) { + H5FD_t *file; /* File driver pointer */ /* Translate to file driver pointer */ file = f_sh->lf; /* Flush the metadata contents */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, f_sh->accum.loc + f_sh->accum.dirty_off, f_sh->accum.dirty_len, f_sh->accum.buf + f_sh->accum.dirty_off) < 0) + if (H5FD_write(file, H5FD_MEM_DEFAULT, f_sh->accum.loc + f_sh->accum.dirty_off, f_sh->accum.dirty_len, + f_sh->accum.buf + f_sh->accum.dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Reset the dirty flag */ @@ -1041,7 +1049,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_flush() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_reset * @@ -1058,7 +1065,7 @@ done: herr_t H5F__accum_reset(H5F_shared_t *f_sh, hbool_t flush) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1066,24 +1073,23 @@ H5F__accum_reset(H5F_shared_t *f_sh, hbool_t flush) HDassert(f_sh); /* Flush any dirty data in accumulator, if requested */ - if(flush) - if(H5F__accum_flush(f_sh) < 0) + if (flush) + if (H5F__accum_flush(f_sh) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "can't flush metadata accumulator") /* Check if we need to reset the metadata accumulator information */ - if(f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) { + if (f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) { /* Free the buffer */ - if(f_sh->accum.buf) + if (f_sh->accum.buf) f_sh->accum.buf = H5FL_BLK_FREE(meta_accum, f_sh->accum.buf); /* Reset the buffer sizes & location */ f_sh->accum.alloc_size = f_sh->accum.size = 0; - f_sh->accum.loc = HADDR_UNDEF; - f_sh->accum.dirty = FALSE; - f_sh->accum.dirty_len = 0; + f_sh->accum.loc = HADDR_UNDEF; + f_sh->accum.dirty = FALSE; + f_sh->accum.dirty_len = 0; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_reset() */ - diff --git a/src/H5Fcwfs.c b/src/H5Fcwfs.c index 26452b6..a1039ec 100644 --- a/src/H5Fcwfs.c +++ b/src/H5Fcwfs.c @@ -33,19 +33,17 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5HGprivate.h" /* Global heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5HGprivate.h" /* Global heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -55,40 +53,32 @@ * Maximum length of the CWFS list, the list of remembered collections that * have free space. */ -#define H5F_NCWFS 16 - +#define H5F_NCWFS 16 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F_cwfs_add * @@ -105,7 +95,7 @@ herr_t H5F_cwfs_add(H5F_t *f, H5HG_heap_t *heap) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -119,23 +109,25 @@ H5F_cwfs_add(H5F_t *f, H5HG_heap_t *heap) * necessary to make room. We remove the right-most entry that has less * free space than this heap. */ - if(NULL == f->shared->cwfs) { - if(NULL == (f->shared->cwfs = (H5HG_heap_t **)H5MM_malloc(H5F_NCWFS * sizeof(H5HG_heap_t *)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate CWFS for file") - f->shared->cwfs[0] = heap; - f->shared->ncwfs = 1; - } else if(H5F_NCWFS == f->shared->ncwfs) { - int i; /* Local index variable */ - - for(i = H5F_NCWFS - 1; i >= 0; --i) - if(H5HG_FREE_SIZE(f->shared->cwfs[i]) < H5HG_FREE_SIZE(heap)) { + if (NULL == f->shared->cwfs) { + if (NULL == (f->shared->cwfs = (H5HG_heap_t **)H5MM_malloc(H5F_NCWFS * sizeof(H5HG_heap_t *)))) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate CWFS for file") + f->shared->cwfs[0] = heap; + f->shared->ncwfs = 1; + } + else if (H5F_NCWFS == f->shared->ncwfs) { + int i; /* Local index variable */ + + for (i = H5F_NCWFS - 1; i >= 0; --i) + if (H5HG_FREE_SIZE(f->shared->cwfs[i]) < H5HG_FREE_SIZE(heap)) { HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, (size_t)i * sizeof(H5HG_heap_t *)); f->shared->cwfs[0] = heap; break; } /* end if */ - } else { + } + else { HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, f->shared->ncwfs * sizeof(H5HG_heap_t *)); - f->shared->cwfs[0] = heap; + f->shared->cwfs[0] = heap; f->shared->ncwfs += 1; } /* end else */ @@ -143,7 +135,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_add() */ - /*------------------------------------------------------------------------- * Function: H5F_cwfs_find_free_heap * @@ -161,9 +152,9 @@ done: herr_t H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr) { - unsigned cwfsno; /* Local index for iterating over collections */ - hbool_t found = FALSE; /* Flag to indicate a heap with enough space was found */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned cwfsno; /* Local index for iterating over collections */ + hbool_t found = FALSE; /* Flag to indicate a heap with enough space was found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -188,59 +179,60 @@ H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr) * * JRM - 5/24/04 */ - for(cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) - if(H5HG_FREE_SIZE(f->shared->cwfs[cwfsno]) >= need) { - *addr = H5HG_ADDR(f->shared->cwfs[cwfsno]); + for (cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) + if (H5HG_FREE_SIZE(f->shared->cwfs[cwfsno]) >= need) { + *addr = H5HG_ADDR(f->shared->cwfs[cwfsno]); found = TRUE; - break; - } /* end if */ + break; + } /* end if */ /* * If we didn't find any collection with enough free space the check if * we can extend any of the collections to make enough room. */ - if(!found) { + if (!found) { size_t new_need; - for(cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) { + for (cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) { new_need = need; new_need -= H5HG_FREE_SIZE(f->shared->cwfs[cwfsno]); new_need = MAX(H5HG_SIZE(f->shared->cwfs[cwfsno]), new_need); - if((H5HG_SIZE(f->shared->cwfs[cwfsno]) + new_need) <= H5HG_MAXSIZE) { - htri_t was_extended; /* Whether the heap was extended */ + if ((H5HG_SIZE(f->shared->cwfs[cwfsno]) + new_need) <= H5HG_MAXSIZE) { + htri_t was_extended; /* Whether the heap was extended */ - was_extended = H5MF_try_extend(f, H5FD_MEM_GHEAP, H5HG_ADDR(f->shared->cwfs[cwfsno]), (hsize_t)H5HG_SIZE(f->shared->cwfs[cwfsno]), (hsize_t)new_need); - if(was_extended < 0) + was_extended = + H5MF_try_extend(f, H5FD_MEM_GHEAP, H5HG_ADDR(f->shared->cwfs[cwfsno]), + (hsize_t)H5HG_SIZE(f->shared->cwfs[cwfsno]), (hsize_t)new_need); + if (was_extended < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "error trying to extend heap") - else if(was_extended == TRUE) { - if(H5HG_extend(f, H5HG_ADDR(f->shared->cwfs[cwfsno]), new_need) < 0) + else if (was_extended == TRUE) { + if (H5HG_extend(f, H5HG_ADDR(f->shared->cwfs[cwfsno]), new_need) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to extend global heap collection") *addr = H5HG_ADDR(f->shared->cwfs[cwfsno]); found = TRUE; break; } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ - if(found) { + if (found) { /* Move the collection forward in the CWFS list, if it's not * already at the front */ - if(cwfsno > 0) { + if (cwfsno > 0) { H5HG_heap_t *tmp = f->shared->cwfs[cwfsno]; - f->shared->cwfs[cwfsno] = f->shared->cwfs[cwfsno - 1]; + f->shared->cwfs[cwfsno] = f->shared->cwfs[cwfsno - 1]; f->shared->cwfs[cwfsno - 1] = tmp; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_find_free_heap() */ - /*------------------------------------------------------------------------- * Function: H5F_cwfs_advance_heap * @@ -257,8 +249,8 @@ done: herr_t H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -267,16 +259,16 @@ H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) HDassert(f->shared); HDassert(heap); - for(u = 0; u < f->shared->ncwfs; u++) - if(f->shared->cwfs[u] == heap) { - if(u) { - f->shared->cwfs[u] = f->shared->cwfs[u - 1]; + for (u = 0; u < f->shared->ncwfs; u++) + if (f->shared->cwfs[u] == heap) { + if (u) { + f->shared->cwfs[u] = f->shared->cwfs[u - 1]; f->shared->cwfs[u - 1] = heap; } /* end if */ break; } /* end if */ - if(add_heap && u >= f->shared->ncwfs) { - f->shared->ncwfs = MIN(f->shared->ncwfs + 1, H5F_NCWFS); + if (add_heap && u >= f->shared->ncwfs) { + f->shared->ncwfs = MIN(f->shared->ncwfs + 1, H5F_NCWFS); f->shared->cwfs[f->shared->ncwfs - 1] = heap; } /* end if */ @@ -284,7 +276,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_advance_heap() */ - /*------------------------------------------------------------------------- * Function: H5F_cwfs_remove_heap * @@ -301,8 +292,8 @@ done: herr_t H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -311,15 +302,14 @@ H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) HDassert(heap); /* Remove the heap from the CWFS list */ - for(u = 0; u < shared->ncwfs; u++) { - if(shared->cwfs[u] == heap) { + for (u = 0; u < shared->ncwfs; u++) { + if (shared->cwfs[u] == heap) { shared->ncwfs -= 1; HDmemmove(shared->cwfs + u, shared->cwfs + u + 1, (shared->ncwfs - u) * sizeof(H5HG_heap_t *)); break; } /* end if */ - } /* end for */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_remove_heap() */ - diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index 535b43d..8bad2ee 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -17,18 +17,16 @@ * Purpose: File object debugging functions. */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Pprivate.h" /* Property lists */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Pprivate.h" /* Property lists */ - - /*------------------------------------------------------------------------- * Function: H5F_debug * @@ -47,9 +45,9 @@ herr_t H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) { - H5P_genplist_t *plist; /* File creation property list */ - hsize_t userblock_size; /* Userblock size */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* File creation property list */ + hsize_t userblock_size; /* Userblock size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -60,73 +58,68 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) HDassert(fwidth >= 0); /* Get property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve file creation properties */ - if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) + if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get userblock size") /* debug */ HDfprintf(stream, "%*sFile Super Block...\n", indent, ""); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "File name (as opened):", H5F_OPEN_NAME(f)); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "File name (as opened):", H5F_OPEN_NAME(f)); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "File name (after resolving symlinks):", H5F_ACTUAL_NAME(f)); - HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, - "File access flags", f->shared->flags); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "File open reference count:", f->shared->nrefs); + "File name (after resolving symlinks):", H5F_ACTUAL_NAME(f)); + HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "File access flags", f->shared->flags); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "File open reference count:", f->shared->nrefs); HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth, - "Address of super block:", f->shared->sblock->base_addr); - HDfprintf(stream, "%*s%-*s %Hu bytes\n", indent, "", fwidth, - "Size of userblock:", userblock_size); + "Address of super block:", f->shared->sblock->base_addr); + HDfprintf(stream, "%*s%-*s %Hu bytes\n", indent, "", fwidth, "Size of userblock:", userblock_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Superblock version number:", f->shared->sblock->super_vers); + "Superblock version number:", f->shared->sblock->super_vers); /* Hard-wired versions */ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Free list version number:", (unsigned)HDF5_FREESPACE_VERSION); + "Free list version number:", (unsigned)HDF5_FREESPACE_VERSION); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Root group symbol table entry version number:", (unsigned)HDF5_OBJECTDIR_VERSION); + "Root group symbol table entry version number:", (unsigned)HDF5_OBJECTDIR_VERSION); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Shared header version number:", (unsigned)HDF5_SHAREDHEADER_VERSION); + "Shared header version number:", (unsigned)HDF5_SHAREDHEADER_VERSION); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, - "Size of file offsets (haddr_t type):", (unsigned) f->shared->sizeof_addr); + "Size of file offsets (haddr_t type):", (unsigned)f->shared->sizeof_addr); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, - "Size of file lengths (hsize_t type):", (unsigned) f->shared->sizeof_size); + "Size of file lengths (hsize_t type):", (unsigned)f->shared->sizeof_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table leaf node 1/2 rank:", f->shared->sblock->sym_leaf_k); + "Symbol table leaf node 1/2 rank:", f->shared->sblock->sym_leaf_k); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_SNODE_ID]); + "Symbol table internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_SNODE_ID]); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Indexed storage internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_CHUNK_ID]); + "Indexed storage internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_CHUNK_ID]); HDfprintf(stream, "%*s%-*s 0x%02x\n", indent, "", fwidth, - "File status flags:", (unsigned)(f->shared->sblock->status_flags)); + "File status flags:", (unsigned)(f->shared->sblock->status_flags)); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Superblock extension address:", f->shared->sblock->ext_addr); + "Superblock extension address:", f->shared->sblock->ext_addr); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Shared object header message table address:", f->shared->sohm_addr); + "Shared object header message table address:", f->shared->sohm_addr); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Shared object header message version number:", (unsigned) f->shared->sohm_vers); + "Shared object header message version number:", (unsigned)f->shared->sohm_vers); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of shared object header message indexes:", (unsigned) f->shared->sohm_nindexes); + "Number of shared object header message indexes:", (unsigned)f->shared->sohm_nindexes); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Address of driver information block:", f->shared->sblock->driver_addr); + "Address of driver information block:", f->shared->sblock->driver_addr); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Root group symbol table entry:", - f->shared->root_grp ? "" : "(none)"); - if(f->shared->root_grp) { - if(f->shared->sblock->root_ent) /* Use real root group symbol table entry */ + "Root group symbol table entry:", f->shared->root_grp ? "" : "(none)"); + if (f->shared->root_grp) { + if (f->shared->sblock->root_ent) /* Use real root group symbol table entry */ H5G__ent_debug(f->shared->sblock->root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); else { - H5O_loc_t *root_oloc; /* Root object location */ - H5G_entry_t root_ent; /* Constructed root symbol table entry */ + H5O_loc_t * root_oloc; /* Root object location */ + H5G_entry_t root_ent; /* Constructed root symbol table entry */ /* Reset the root group entry */ H5G__ent_reset(&root_ent); @@ -134,15 +127,14 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) /* Build up a simulated root group symbol table entry */ root_oloc = H5G_oloc(f->shared->root_grp); HDassert(root_oloc); - root_ent.type = H5G_NOTHING_CACHED; + root_ent.type = H5G_NOTHING_CACHED; root_ent.header = root_oloc->addr; /* Display root group symbol table entry info */ H5G__ent_debug(&root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_debug() */ - diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index a047161..edfbf46 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -29,59 +29,50 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5SMprivate.h" /* Shared object header messages */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Fget_info1 * @@ -98,41 +89,42 @@ herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) { - H5VL_object_t *vol_obj = NULL; - H5I_type_t type; - H5F_info2_t finfo2; /* Current file info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; + H5F_info2_t finfo2; /* Current file info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", obj_id, finfo); /* Check args */ - if(!finfo) + if (!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* Check the type */ type = H5I_get_type(obj_id); - if(H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && H5I_ATTR != type) + if (H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && + H5I_ATTR != type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Get the file object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the file information */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type, &finfo2) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + type, &finfo2) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") /* Copy the compatible fields into the older struct */ finfo->super_ext_size = finfo2.super.super_ext_size; - finfo->sohm.hdr_size = finfo2.sohm.hdr_size; + finfo->sohm.hdr_size = finfo2.sohm.hdr_size; finfo->sohm.msgs_info = finfo2.sohm.msgs_info; done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info1() */ - /*------------------------------------------------------------------------- * Function: H5Fis_hdf5 * @@ -149,24 +141,24 @@ done: htri_t H5Fis_hdf5(const char *name) { - htri_t ret_value; /* Return value */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("t", "*s", name); /* Check args and all the boring stuff. */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "no file name specified") /* Check if file is accessible */ - if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5P_FILE_ACCESS_DEFAULT, name, &ret_value) < 0) + if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5P_FILE_ACCESS_DEFAULT, name, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, (-1), "unable to determine if file is accessible as HDF5") done: FUNC_LEAVE_API(ret_value) } /* end H5Fis_hdf5() */ - /*------------------------------------------------------------------------- * Function: H5Fset_latest_format * @@ -204,34 +196,34 @@ done: herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format) { - H5VL_object_t *vol_obj; /* File as VOL object */ - H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ - H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File as VOL object */ + H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ + H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, latest_format); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* 'low' and 'high' are both initialized to LATEST. * If latest format is not expected, set 'low' to EARLIEST */ - if(!latest_format) + if (!latest_format) low = H5F_LIBVER_EARLIEST; /* Set the library's version bounds */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)low, (int)high) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)low, (int)high) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: FUNC_LEAVE_API(ret_value) } /* end H5Fset_latest_format() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 77d29f5..05f1696 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -24,56 +24,54 @@ *------------------------------------------------------------------------- */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* Special values for the "tag" field below */ -#define H5F_EFC_TAG_DEFAULT -1 -#define H5F_EFC_TAG_LOCK -2 -#define H5F_EFC_TAG_CLOSE -3 -#define H5F_EFC_TAG_DONTCLOSE -4 +#define H5F_EFC_TAG_DEFAULT -1 +#define H5F_EFC_TAG_LOCK -2 +#define H5F_EFC_TAG_CLOSE -3 +#define H5F_EFC_TAG_DONTCLOSE -4 /* Structure for each entry in a file's external file cache */ typedef struct H5F_efc_ent_t { - char *name; /* Name of the file */ - H5F_t *file; /* File object */ - struct H5F_efc_ent_t *LRU_next; /* Next item in LRU list */ - struct H5F_efc_ent_t *LRU_prev; /* Previous item in LRU list */ - unsigned nopen; /* Number of times this file is currently opened by an EFC client */ + char * name; /* Name of the file */ + H5F_t * file; /* File object */ + struct H5F_efc_ent_t *LRU_next; /* Next item in LRU list */ + struct H5F_efc_ent_t *LRU_prev; /* Previous item in LRU list */ + unsigned nopen; /* Number of times this file is currently opened by an EFC client */ } H5F_efc_ent_t; /* Structure for a shared file struct's external file cache */ struct H5F_efc_t { - H5SL_t *slist; /* Skip list of cached external files */ - H5F_efc_ent_t *LRU_head; /* Head of LRU list. This is the least recently used file */ - H5F_efc_ent_t *LRU_tail; /* Tail of LRU list. This is the most recently used file */ - unsigned nfiles; /* Size of the external file cache */ - unsigned max_nfiles; /* Maximum size of the external file cache */ - unsigned nrefs; /* Number of times this file appears in another file's EFC */ - int tag; /* Temporary variable used by H5F__efc_try_close() */ - H5F_shared_t *tmp_next; /* Next file in temporary list used by H5F__efc_try_close() */ + H5SL_t * slist; /* Skip list of cached external files */ + H5F_efc_ent_t *LRU_head; /* Head of LRU list. This is the least recently used file */ + H5F_efc_ent_t *LRU_tail; /* Tail of LRU list. This is the most recently used file */ + unsigned nfiles; /* Size of the external file cache */ + unsigned max_nfiles; /* Maximum size of the external file cache */ + unsigned nrefs; /* Number of times this file appears in another file's EFC */ + int tag; /* Temporary variable used by H5F__efc_try_close() */ + H5F_shared_t * tmp_next; /* Next file in temporary list used by H5F__efc_try_close() */ }; /* Private prototypes */ static herr_t H5F__efc_release_real(H5F_efc_t *efc); static herr_t H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent); -static void H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail); -static void H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail); +static void H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail); +static void H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail); /* Free lists */ H5FL_DEFINE_STATIC(H5F_efc_ent_t); H5FL_DEFINE_STATIC(H5F_efc_t); - /*------------------------------------------------------------------------- * Function: H5F__efc_create * @@ -92,8 +90,8 @@ H5FL_DEFINE_STATIC(H5F_efc_t); H5F_efc_t * H5F__efc_create(unsigned max_nfiles) { - H5F_efc_t *efc = NULL; /* EFC object */ - H5F_efc_t *ret_value = NULL; /* Return value */ + H5F_efc_t *efc = NULL; /* EFC object */ + H5F_efc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -101,7 +99,7 @@ H5F__efc_create(unsigned max_nfiles) HDassert(max_nfiles > 0); /* Allocate EFC struct */ - if(NULL == (efc = H5FL_CALLOC(H5F_efc_t))) + if (NULL == (efc = H5FL_CALLOC(H5F_efc_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Initialize maximum number of files */ @@ -114,13 +112,12 @@ H5F__efc_create(unsigned max_nfiles) ret_value = efc; done: - if(ret_value == NULL && efc) + if (ret_value == NULL && efc) efc = H5FL_FREE(H5F_efc_t, efc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_create() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_open * @@ -143,12 +140,12 @@ done: H5F_t * H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_efc_t *efc = NULL; /* External file cache for parent file */ - H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ - hbool_t open_file = FALSE; /* Whether ent->file needs to be closed in case of error */ - H5P_genplist_t *plist; /* Property list pointer for FAPL */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5F_t *ret_value = NULL; /* Return value */ + H5F_efc_t * efc = NULL; /* External file cache for parent file */ + H5F_efc_ent_t * ent = NULL; /* Entry for target file in efc */ + hbool_t open_file = FALSE; /* Whether ent->file needs to be closed in case of error */ + H5P_genplist_t * plist; /* Property list pointer for FAPL */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5F_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -158,15 +155,15 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi HDassert(name); /* Get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, NULL, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get VOL connector info") /* Stash a copy of the "top-level" connector property, before any pass-through * connectors modify or unwrap it. */ - if(H5CX_set_vol_connector_prop(&connector_prop) < 0) + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set VOL connector info in API context") /* Get external file cache */ @@ -175,12 +172,12 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi /* Check if the EFC exists. If it does not, just call H5F_open(). We * support this so clients do not have to make 2 different calls depending * on the state of the efc. */ - if(!efc) { - if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) + if (!efc) { + if (NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") /* Make file post open call */ - if(H5F__post_open(ret_value) < 0) + if (H5F__post_open(ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") /* Increment the number of open objects to prevent the file from being @@ -194,31 +191,31 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi /* Search the skip list for name if the skip list exists, create the skip * list otherwise */ - if(efc->slist) { - if(efc->nfiles > 0) + if (efc->slist) { + if (efc->nfiles > 0) ent = (H5F_efc_ent_t *)H5SL_search(efc->slist, name); } /* end if */ else { HDassert(efc->nfiles == 0); - if(NULL == (efc->slist = H5SL_create(H5SL_TYPE_STR, NULL))) + if (NULL == (efc->slist = H5SL_create(H5SL_TYPE_STR, NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, NULL, "can't create skip list") } /* end else */ /* If we found the file update the LRU list and return the cached file, * otherwise open the file and cache it */ - if(ent) { + if (ent) { HDassert(efc->LRU_head); HDassert(efc->LRU_tail); /* Move ent to the head of the LRU list, if it is not already there */ - if(ent->LRU_prev) { + if (ent->LRU_prev) { HDassert(efc->LRU_head != ent); /* Remove from current position. Note that once we touch the LRU * list we cannot revert to the previous state. Make sure there can * be no errors between when we first touch the LRU list and when * the cache is in a consistent state! */ - if(ent->LRU_next) + if (ent->LRU_next) ent->LRU_next->LRU_prev = ent->LRU_prev; else { HDassert(efc->LRU_tail == ent); @@ -227,10 +224,10 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi ent->LRU_prev->LRU_next = ent->LRU_next; /* Add to head of LRU list */ - ent->LRU_next = efc->LRU_head; + ent->LRU_next = efc->LRU_head; ent->LRU_next->LRU_prev = ent; - ent->LRU_prev = NULL; - efc->LRU_head = ent; + ent->LRU_prev = NULL; + efc->LRU_head = ent; } /* end if */ /* Mark the file as open */ @@ -238,25 +235,26 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi } /* end if */ else { /* Check if we need to evict something */ - if(efc->nfiles == efc->max_nfiles) { + if (efc->nfiles == efc->max_nfiles) { /* Search for an unopened file from the tail */ - for(ent = efc->LRU_tail; ent && ent->nopen; ent = ent->LRU_prev); + for (ent = efc->LRU_tail; ent && ent->nopen; ent = ent->LRU_prev) + ; /* Evict the file if found, otherwise just open the target file and * do not add it to cache */ - if(ent) { - if(H5F__efc_remove_ent(efc, ent) < 0) + if (ent) { + if (H5F__efc_remove_ent(efc, ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, NULL, "can't remove entry from external file cache") /* Do not free ent, we will recycle it below */ } /* end if */ else { /* Cannot cache file, just open file and return */ - if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) + if (NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") /* Make file post open call */ - if(H5F__post_open(ret_value) < 0) + if (H5F__post_open(ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") /* Increment the number of open objects to prevent the file from @@ -266,23 +264,23 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi HGOTO_DONE(ret_value) } /* end else */ - } /* end if */ + } /* end if */ else /* Allocate new entry */ - if(NULL == (ent = H5FL_MALLOC(H5F_efc_ent_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (ent = H5FL_MALLOC(H5F_efc_ent_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Build new entry */ - if(NULL == (ent->name = H5MM_strdup(name))) + if (NULL == (ent->name = H5MM_strdup(name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Open the file */ - if(NULL == (ent->file = H5F_open(name, flags, fcpl_id, fapl_id))) + if (NULL == (ent->file = H5F_open(name, flags, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") open_file = TRUE; /* Make file post open call */ - if(H5F__post_open(ent->file) < 0) + if (H5F__post_open(ent->file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") /* Increment the number of open objects to prevent the file from being @@ -291,16 +289,16 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi /* Add the file to the cache */ /* Skip list */ - if(H5SL_insert(efc->slist, ent, ent->name) < 0) + if (H5SL_insert(efc->slist, ent, ent->name) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, NULL, "can't insert entry into skip list") /* Add to head of LRU list and update tail if necessary */ ent->LRU_next = efc->LRU_head; - if(ent->LRU_next) + if (ent->LRU_next) ent->LRU_next->LRU_prev = ent; ent->LRU_prev = NULL; efc->LRU_head = ent; - if(!efc->LRU_tail) { + if (!efc->LRU_tail) { HDassert(!ent->LRU_next); efc->LRU_tail = ent; } /* end if */ @@ -310,7 +308,7 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi /* Update nfiles and nrefs */ efc->nfiles++; - if(ent->file->shared->efc) + if (ent->file->shared->efc) ent->file->shared->efc->nrefs++; } /* end else */ @@ -323,21 +321,20 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi ret_value = ent->file; done: - if(!ret_value) - if(ent) { - if(open_file) { + if (!ret_value) + if (ent) { + if (open_file) { ent->file->nopen_objs--; - if(H5F_try_close(ent->file, NULL) < 0) + if (H5F_try_close(ent->file, NULL) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close external file") } /* end if */ ent->name = (char *)H5MM_xfree(ent->name); - ent = H5FL_FREE(H5F_efc_ent_t, ent); + ent = H5FL_FREE(H5F_efc_ent_t, ent); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_open() */ - /*------------------------------------------------------------------------- * Function: H5F_efc_close * @@ -356,9 +353,9 @@ done: herr_t H5F_efc_close(H5F_t *parent, H5F_t *file) { - H5F_efc_t *efc = NULL; /* External file cache for parent file */ - H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_efc_t * efc = NULL; /* External file cache for parent file */ + H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -374,9 +371,9 @@ H5F_efc_close(H5F_t *parent, H5F_t *file) /* Check if the EFC exists. If it does not, just call H5F_try_close(). We * support this so clients do not have to make 2 different calls depending * on the state of the efc. */ - if(!efc) { + if (!efc) { file->nopen_objs--; - if(H5F_try_close(file, NULL) < 0) + if (H5F_try_close(file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") HGOTO_DONE(SUCCEED) @@ -387,10 +384,11 @@ H5F_efc_close(H5F_t *parent, H5F_t *file) * the head. In the unlikely case that the file is not found, just call * H5F_try_close(). This could happen if the EFC was full of open files * when the file was opened. */ - for(ent = efc->LRU_head; ent && ent->file != file; ent = ent->LRU_next); - if(!ent) { + for (ent = efc->LRU_head; ent && ent->file != file; ent = ent->LRU_next) + ; + if (!ent) { file->nopen_objs--; - if(H5F_try_close(file, NULL) < 0) + if (H5F_try_close(file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") } /* end if */ else @@ -401,7 +399,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_efc_close() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_max_nfiles * @@ -426,7 +423,6 @@ H5F__efc_max_nfiles(H5F_efc_t *efc) FUNC_LEAVE_NOAPI(efc->max_nfiles) } /* end H5F__efc_max_nfiles */ - /*------------------------------------------------------------------------- * Function: H5F__efc_release_real * @@ -445,9 +441,9 @@ H5F__efc_max_nfiles(H5F_efc_t *efc) static herr_t H5F__efc_release_real(H5F_efc_t *efc) { - H5F_efc_ent_t *ent = NULL; /* EFC entry */ - H5F_efc_ent_t *prev_ent = NULL; /* Previous EFC entry */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_efc_ent_t *ent = NULL; /* EFC entry */ + H5F_efc_ent_t *prev_ent = NULL; /* Previous EFC entry */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -459,21 +455,20 @@ H5F__efc_release_real(H5F_efc_t *efc) * would require a cycle, a cycle would necessarily invoke * H5F__efc_try_close(), and that function checks the status of the lock * before calling this one. */ - HDassert((efc->tag == H5F_EFC_TAG_DEFAULT) - || (efc->tag == H5F_EFC_TAG_CLOSE)); + HDassert((efc->tag == H5F_EFC_TAG_DEFAULT) || (efc->tag == H5F_EFC_TAG_CLOSE)); efc->tag = H5F_EFC_TAG_LOCK; /* Walk down the LRU list, releasing any files that are not opened by an EFC * client */ ent = efc->LRU_head; - while(ent) - if(!ent->nopen) { - if(H5F__efc_remove_ent(efc, ent) < 0) + while (ent) + if (!ent->nopen) { + if (H5F__efc_remove_ent(efc, ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, "can't remove entry from external file cache") /* Free the entry and move to next entry in LRU list */ prev_ent = ent; - ent = ent->LRU_next; + ent = ent->LRU_next; prev_ent = H5FL_FREE(H5F_efc_ent_t, prev_ent); } /* end if */ else @@ -488,7 +483,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F__efc_release_real() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_release * @@ -507,7 +501,7 @@ done: herr_t H5F__efc_release(H5F_efc_t *efc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -515,14 +509,13 @@ H5F__efc_release(H5F_efc_t *efc) HDassert(efc); /* Call 'real' routine */ - if(H5F__efc_release_real(efc) < 0) + if (H5F__efc_release_real(efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't remove entry from external file cache") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_efc_release() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_destroy * @@ -541,20 +534,20 @@ done: herr_t H5F__efc_destroy(H5F_efc_t *efc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(efc); - if(efc->nfiles > 0) { + if (efc->nfiles > 0) { /* Release (clear) the efc */ - if(H5F__efc_release_real(efc) < 0) + if (H5F__efc_release_real(efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") /* If there are still cached files, return an error */ - if(efc->nfiles > 0) + if (efc->nfiles > 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't destroy EFC after incomplete release") } /* end if */ @@ -563,8 +556,8 @@ H5F__efc_destroy(H5F_efc_t *efc) HDassert(efc->LRU_tail == NULL); /* Close skip list */ - if(efc->slist) - if(H5SL_close(efc->slist) < 0) + if (efc->slist) + if (H5SL_close(efc->slist) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close skip list") /* Free EFC object */ @@ -574,7 +567,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F__efc_destroy() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_remove_ent * @@ -592,7 +584,7 @@ done: static herr_t H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -602,17 +594,17 @@ H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) HDassert(ent); /* Remove from skip list */ - if(ent != H5SL_remove(efc->slist, ent->name)) + if (ent != H5SL_remove(efc->slist, ent->name)) HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "can't delete entry from skip list") /* Remove from LRU list */ - if(ent->LRU_next) + if (ent->LRU_next) ent->LRU_next->LRU_prev = ent->LRU_prev; else { HDassert(efc->LRU_tail == ent); efc->LRU_tail = ent->LRU_prev; } /* end else */ - if(ent->LRU_prev) + if (ent->LRU_prev) ent->LRU_prev->LRU_next = ent->LRU_next; else { HDassert(efc->LRU_head == ent); @@ -621,7 +613,7 @@ H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) /* Update nfiles and nrefs */ efc->nfiles--; - if(ent->file->shared->efc) + if (ent->file->shared->efc) ent->file->shared->efc->nrefs--; /* Free the name */ @@ -632,7 +624,7 @@ H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) * However we must still manipulate the nopen_objs field to prevent the file * from being closed out from under us. */ ent->file->nopen_objs--; - if(H5F_try_close(ent->file, NULL) < 0) + if (H5F_try_close(ent->file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") ent->file = NULL; @@ -640,7 +632,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_remove_ent() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_try_close_tag1 * @@ -658,8 +649,8 @@ done: static void H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) { - H5F_efc_ent_t *ent = NULL; /* EFC entry */ - H5F_shared_t *esf; /* Convenience pointer to ent->file->shared */ + H5F_efc_ent_t *ent = NULL; /* EFC entry */ + H5F_shared_t * esf; /* Convenience pointer to ent->file->shared */ FUNC_ENTER_STATIC_NOERR @@ -672,17 +663,17 @@ H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) HDassert(*tail); /* Recurse into this file's cached files */ - for(ent = sf->efc->LRU_head; ent; ent = ent->LRU_next) { + for (ent = sf->efc->LRU_head; ent; ent = ent->LRU_next) { esf = ent->file->shared; - if(esf->efc) { + if (esf->efc) { /* If tag were 0, that would mean there are more actual references * than are counted by nrefs */ HDassert(esf->efc->tag != 0); /* If tag has been set, we have already visited this file so just * decrement tag and continue */ - if(esf->efc->tag > 0) + if (esf->efc->tag > 0) esf->efc->tag--; /* If there are references that are not from an EFC, it will never * be possible to close the file. Just continue. Also continue if @@ -690,8 +681,8 @@ H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) * that the reference counts will never match for the root file, but * that's ok because the root file will always have a tag and enter * the branch above. */ - else if((esf->nrefs == esf->efc->nrefs) - && (esf->efc->tag != H5F_EFC_TAG_LOCK) && !(ent->nopen)) { + else if ((esf->nrefs == esf->efc->nrefs) && (esf->efc->tag != H5F_EFC_TAG_LOCK) && + !(ent->nopen)) { /* If we get here, this file's "tmp_next" pointer must be NULL */ HDassert(esf->efc->tmp_next == NULL); @@ -699,22 +690,21 @@ H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) /* If nrefs > 1, Add this file to the list of files with nrefs > * 1 and initialize tag to the number of references (except this * one) */ - if(esf->nrefs > 1) { + if (esf->nrefs > 1) { (*tail)->efc->tmp_next = esf; - *tail = esf; - esf->efc->tag = (int)esf->nrefs - 1; + *tail = esf; + esf->efc->tag = (int)esf->nrefs - 1; } /* end if */ /* Recurse into the entry */ H5F__efc_try_close_tag1(ent->file->shared, tail); } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ FUNC_LEAVE_NOAPI_VOID } /* end H5F__efc_try_close_tag1() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_try_close_tag2 * @@ -732,8 +722,8 @@ H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) static void H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail) { - H5F_efc_ent_t *ent = NULL; /* EFC entry */ - H5F_shared_t *esf; /* Convenience pointer to ent->file->shared */ + H5F_efc_ent_t *ent = NULL; /* EFC entry */ + H5F_shared_t * esf; /* Convenience pointer to ent->file->shared */ FUNC_ENTER_STATIC_NOERR @@ -742,7 +732,7 @@ H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail) HDassert(sf->efc); /* Recurse into this file's cached files */ - for(ent = sf->efc->LRU_head; ent; ent = ent->LRU_next) { + for (ent = sf->efc->LRU_head; ent; ent = ent->LRU_next) { esf = ent->file->shared; /* Only recurse if the file is tagged CLOSE or DEFAULT. If it is tagged @@ -753,39 +743,36 @@ H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail) * make sure we do not go off into somewhere cb1 didn't touch. The * root file should never be tagged DEFAULT here, so the reference check * is still appropriate. */ - if((esf->efc) && ((esf->efc->tag == H5F_EFC_TAG_CLOSE) - || ((esf->efc->tag == H5F_EFC_TAG_DEFAULT) - && (esf->nrefs == esf->efc->nrefs) && !(ent->nopen)))) { + if ((esf->efc) && + ((esf->efc->tag == H5F_EFC_TAG_CLOSE) || + ((esf->efc->tag == H5F_EFC_TAG_DEFAULT) && (esf->nrefs == esf->efc->nrefs) && !(ent->nopen)))) { /* tag should always be CLOSE is nrefs > 1 or DEFAULT if nrefs == 1 * here */ - HDassert(((esf->nrefs > 1) - && ((esf->efc->tag == H5F_EFC_TAG_CLOSE))) - || ((esf->nrefs == 1) - && (esf->efc->tag == H5F_EFC_TAG_DEFAULT))); + HDassert(((esf->nrefs > 1) && ((esf->efc->tag == H5F_EFC_TAG_CLOSE))) || + ((esf->nrefs == 1) && (esf->efc->tag == H5F_EFC_TAG_DEFAULT))); /* If tag is set to DONTCLOSE, we have already visited this file * *or* it will be the start point of another iteration so just * continue */ - if(esf->efc->tag != H5F_EFC_TAG_DONTCLOSE) { + if (esf->efc->tag != H5F_EFC_TAG_DONTCLOSE) { /* If tag is CLOSE, set to DONTCLOSE and add to the list of * uncloseable files. */ - if(esf->efc->tag == H5F_EFC_TAG_CLOSE) { - esf->efc->tag = H5F_EFC_TAG_DONTCLOSE; - esf->efc->tmp_next = NULL; + if (esf->efc->tag == H5F_EFC_TAG_CLOSE) { + esf->efc->tag = H5F_EFC_TAG_DONTCLOSE; + esf->efc->tmp_next = NULL; (*tail)->efc->tmp_next = esf; - *tail = esf; + *tail = esf; } /* end if */ /* Recurse into the entry */ H5F__efc_try_close_tag2(esf, tail); } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ FUNC_LEAVE_NOAPI_VOID } /* end H5F__efc_try_close_tag2() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_try_close * @@ -839,12 +826,14 @@ H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail) herr_t H5F__efc_try_close(H5F_t *f) { - H5F_shared_t *tail; /* Tail of linked list of found files. Head will be f->shared. */ - H5F_shared_t *uncloseable_head = NULL; /* Head of linked list of files found to be uncloseable by the first pass */ - H5F_shared_t *uncloseable_tail = NULL; /* Tail of linked list of files found to be uncloseable by the first pass */ - H5F_shared_t *sf; /* Temporary file pointer */ - H5F_shared_t *next; /* Temporary file pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_shared_t *tail; /* Tail of linked list of found files. Head will be f->shared. */ + H5F_shared_t *uncloseable_head = + NULL; /* Head of linked list of files found to be uncloseable by the first pass */ + H5F_shared_t *uncloseable_tail = + NULL; /* Tail of linked list of files found to be uncloseable by the first pass */ + H5F_shared_t *sf; /* Temporary file pointer */ + H5F_shared_t *next; /* Temporary file pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -856,12 +845,12 @@ H5F__efc_try_close(H5F_t *f) HDassert(f->shared->nrefs > 1); HDassert(f->shared->efc->tag < 0); - if(f->shared->efc->tag == H5F_EFC_TAG_CLOSE) { + if (f->shared->efc->tag == H5F_EFC_TAG_CLOSE) { /* We must have reentered this function, and we should close this file. * In actuality, we just release the EFC, the recursion should * eventually reduce this file's reference count to 1 (though possibly * not from this call to H5F__efc_release_real()). */ - if(H5F__efc_release_real(f->shared->efc) < 0) + if (H5F__efc_release_real(f->shared->efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") /* If we marked the file as closeable, there must be no open files in @@ -887,9 +876,8 @@ H5F__efc_try_close(H5F_t *f) * not close/release it */ /* If nfiles is 0, then there is nothing to do. Just return. This may also * occur on reentry (for example if this file was previously released). */ - if((f->shared->nrefs != f->shared->efc->nrefs + 1) - || (f->shared->efc->tag == H5F_EFC_TAG_DONTCLOSE) - || (f->shared->efc->nfiles == 0)) + if ((f->shared->nrefs != f->shared->efc->nrefs + 1) || (f->shared->efc->tag == H5F_EFC_TAG_DONTCLOSE) || + (f->shared->efc->nfiles == 0)) /* We must have reentered this function, and we should not close this * file. Just return. */ HGOTO_DONE(SUCCEED) @@ -917,13 +905,13 @@ H5F__efc_try_close(H5F_t *f) /* Check if f->shared->efc->tag dropped to 0. If it did not, * we cannot close anything. Just reset temporary values and return. */ - if(f->shared->efc->tag > 0) { + if (f->shared->efc->tag > 0) { sf = f->shared; - while(sf) { - next = sf->efc->tmp_next; - sf->efc->tag = H5F_EFC_TAG_DEFAULT; + while (sf) { + next = sf->efc->tmp_next; + sf->efc->tag = H5F_EFC_TAG_DEFAULT; sf->efc->tmp_next = NULL; - sf = next; + sf = next; } /* end while */ HGOTO_DONE(SUCCEED) } /* end if */ @@ -931,19 +919,19 @@ H5F__efc_try_close(H5F_t *f) /* Run through the linked list , separating into two lists, one with tag == * 0 and one with tag > 0. Mark them as either H5F_EFC_TAG_CLOSE or * H5F_EFC_TAG_DONTCLOSE as appropriate. */ - sf = f->shared; + sf = f->shared; tail = NULL; - while(sf) { + while (sf) { HDassert(sf->efc->tag >= 0); next = sf->efc->tmp_next; - if(sf->efc->tag > 0) { + if (sf->efc->tag > 0) { /* Remove from main list */ HDassert(tail); tail->efc->tmp_next = sf->efc->tmp_next; - sf->efc->tmp_next = NULL; + sf->efc->tmp_next = NULL; /* Add to uncloseable list */ - if(!uncloseable_head) + if (!uncloseable_head) uncloseable_head = sf; else uncloseable_tail->efc->tmp_next = sf; @@ -954,7 +942,7 @@ H5F__efc_try_close(H5F_t *f) } /* end if */ else { sf->efc->tag = H5F_EFC_TAG_CLOSE; - tail = sf; + tail = sf; } /* end else */ sf = next; } /* end while */ @@ -967,20 +955,20 @@ H5F__efc_try_close(H5F_t *f) * so we know when to stop. We do not need to keep track of the closeable * list any more. */ sf = uncloseable_head; - if(sf) { + if (sf) { tail = uncloseable_tail; HDassert(tail); - while(sf != tail->efc->tmp_next) { + while (sf != tail->efc->tmp_next) { H5F__efc_try_close_tag2(sf, &uncloseable_tail); sf = sf->efc->tmp_next; } /* end while */ - } /* end if */ + } /* end if */ /* If the root file's tag is still H5F_EFC_TAG_CLOSE, release its EFC. This * should start the recursive release that should close all closeable files. * Also, see the top of this function. */ - if(f->shared->efc->tag == H5F_EFC_TAG_CLOSE) { - if(H5F__efc_release_real(f->shared->efc) < 0) + if (f->shared->efc->tag == H5F_EFC_TAG_CLOSE) { + if (H5F__efc_release_real(f->shared->efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") /* Make sure the file's reference count is now 1 and will be closed by @@ -990,18 +978,17 @@ H5F__efc_try_close(H5F_t *f) /* Clean up uncloseable files (reset tag and tmp_next). All closeable files * should have been closed, and therefore do not need to be cleaned up. */ - if(uncloseable_head) { + if (uncloseable_head) { sf = uncloseable_head; - while(sf) { + while (sf) { next = sf->efc->tmp_next; HDassert(sf->efc->tag == H5F_EFC_TAG_DONTCLOSE); - sf->efc->tag = H5F_EFC_TAG_DEFAULT; + sf->efc->tag = H5F_EFC_TAG_DEFAULT; sf->efc->tmp_next = NULL; - sf = next; + sf = next; } /* end while */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_try_close() */ - diff --git a/src/H5Ffake.c b/src/H5Ffake.c index 67bd180..01a0056 100644 --- a/src/H5Ffake.c +++ b/src/H5Ffake.c @@ -11,17 +11,15 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ /* PRIVATE PROTOTYPES */ - /*------------------------------------------------------------------------- * Function: H5F_fake_alloc * @@ -42,19 +40,19 @@ H5F_t * H5F_fake_alloc(uint8_t sizeof_size) { - H5F_t *f = NULL; /* Pointer to fake file struct */ - H5F_t *ret_value = NULL; /* Return value */ + H5F_t *f = NULL; /* Pointer to fake file struct */ + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate faked file struct */ - if(NULL == (f = H5FL_CALLOC(H5F_t))) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - if(NULL == (f->shared = H5FL_CALLOC(H5F_shared_t))) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") + if (NULL == (f = H5FL_CALLOC(H5F_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") + if (NULL == (f->shared = H5FL_CALLOC(H5F_shared_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") /* Only set fields necessary for clients */ - if(sizeof_size == 0) + if (sizeof_size == 0) f->shared->sizeof_size = H5F_OBJ_SIZE_SIZE; else f->shared->sizeof_size = sizeof_size; @@ -63,13 +61,12 @@ H5F_fake_alloc(uint8_t sizeof_size) ret_value = f; done: - if(!ret_value) + if (!ret_value) H5F_fake_free(f); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_fake_alloc() */ - /*------------------------------------------------------------------------- * Function: H5F_fake_free * @@ -90,13 +87,12 @@ H5F_fake_free(H5F_t *f) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Free faked file struct */ - if(f) { + if (f) { /* Destroy shared file struct */ - if(f->shared) + if (f->shared) f->shared = H5FL_FREE(H5F_shared_t, f->shared); f = H5FL_FREE(H5F_t, f); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F_fake_free() */ - diff --git a/src/H5Fint.c b/src/H5Fint.c index e3040d4..de3cb01 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -15,34 +15,32 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MVprivate.h" /* File memory management for VFD SWMR */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MVprivate.h" /* File memory management for VFD SWMR */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ @@ -53,37 +51,37 @@ /* Struct only used by functions H5F__get_objects and H5F__get_objects_cb */ typedef struct H5F_olist_t { - H5I_type_t obj_type; /* Type of object to look for */ - hid_t *obj_id_list; /* Pointer to the list of open IDs to return */ - size_t *obj_id_count; /* Number of open IDs */ + H5I_type_t obj_type; /* Type of object to look for */ + hid_t * obj_id_list; /* Pointer to the list of open IDs to return */ + size_t * obj_id_count; /* Number of open IDs */ struct { - hbool_t local; /* Set flag for "local" file searches */ + hbool_t local; /* Set flag for "local" file searches */ union { H5F_shared_t *shared; /* Pointer to shared file to look inside */ - const H5F_t *file; /* Pointer to file to look inside */ + const H5F_t * file; /* Pointer to file to look inside */ } ptr; } file_info; - size_t list_index; /* Current index in open ID array */ - size_t max_nobjs; /* Maximum # of IDs to put into array */ + size_t list_index; /* Current index in open ID array */ + size_t max_nobjs; /* Maximum # of IDs to put into array */ } H5F_olist_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5F__set_vol_conn(H5F_t *file); -static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr); -static int H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); -static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/); -static char *H5F__getenv_prefix_name(char **env_prefix/*in,out*/); +static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, + hbool_t app_ref, size_t *obj_id_count_ptr); +static int H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); +static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name /*out*/); +static char * H5F__getenv_prefix_name(char **env_prefix /*in,out*/); static H5F_t *H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); -static herr_t H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); +static herr_t H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, + char ** /*out*/ actual_name); static herr_t H5F__flush_phase1(H5F_t *f); static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); @@ -95,7 +93,6 @@ static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -106,8 +103,6 @@ H5FL_DEFINE(H5F_t); /* Declare a free list to manage the H5F_shared_t struct */ H5FL_DEFINE(H5F_shared_t); - - /*------------------------------------------------------------------------- * Function: H5F__set_vol_conn * @@ -120,9 +115,9 @@ H5FL_DEFINE(H5F_shared_t); static herr_t H5F__set_vol_conn(H5F_t *file) { - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - void *new_connector_info = NULL; /* Copy of connector info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + void * new_connector_info = NULL; /* Copy of connector info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -132,32 +127,32 @@ H5F__set_vol_conn(H5F_t *file) /* Retrieve a copy of the "top-level" connector property, before any pass-through * connectors modified or unwrapped it. */ - if(H5CX_get_vol_connector_prop(&connector_prop) < 0) + if (H5CX_get_vol_connector_prop(&connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL connector info from API context") /* Sanity check */ HDassert(0 != connector_prop.connector_id); /* Retrieve the connector for the ID */ - if(NULL == (file->shared->vol_cls = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) + if (NULL == (file->shared->vol_cls = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Allocate and copy connector info, if it exists */ - if(connector_prop.connector_info) - if(H5VL_copy_connector_info(file->shared->vol_cls, &new_connector_info, connector_prop.connector_info) < 0) + if (connector_prop.connector_info) + if (H5VL_copy_connector_info(file->shared->vol_cls, &new_connector_info, + connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "connector info copy failed") /* Cache the connector ID & info for the container */ - file->shared->vol_id = connector_prop.connector_id; + file->shared->vol_id = connector_prop.connector_id; file->shared->vol_info = new_connector_info; - if(H5I_inc_ref(file->shared->vol_id, FALSE) < 0) + if (H5I_inc_ref(file->shared->vol_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_vol_conn() */ - /*------------------------------------------------------------------------- * Function: H5F_get_access_plist * @@ -177,13 +172,13 @@ done: hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref) { - H5P_genplist_t *new_plist; /* New property list */ - H5P_genplist_t *old_plist; /* Old property list */ - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - unsigned efc_size = 0; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t * new_plist; /* New property list */ + H5P_genplist_t * old_plist; /* Old property list */ + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + unsigned efc_size = 0; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -191,98 +186,105 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HDassert(f); /* Make a copy of the default file access property list */ - if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) + if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") - if((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0) + if ((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "can't copy file access property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Copy properties of the file access property list */ - if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) + if (H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") - if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) + if (H5P_set(new_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache number of slots") - if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) + if (H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache byte size") - if(H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) + if (H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set preempt read chunks") - if(H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) + if (H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment threshold") - if(H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) + if (H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment") - if(H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) + if (H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set garbage collect reference") - if(H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) + if (H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set metadata cache size") - if(H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) + if (H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't sieve buffer size") - if(H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) + if (H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'small data' cache size") - if(H5P_set(new_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &f->shared->low_bound) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'low' bound for library format versions") - if(H5P_set(new_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &f->shared->high_bound) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'high' bound for library format versions") - if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0) + if (H5P_set(new_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &f->shared->low_bound) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, + "can't set 'low' bound for library format versions") + if (H5P_set(new_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &f->shared->high_bound) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, + "can't set 'high' bound for library format versions") + if (H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'read attempts ' flag") - if(H5P_set(new_plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) + if (H5P_set(new_plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set object flush callback") - if(f->shared->efc) + if (f->shared->efc) efc_size = H5F__efc_max_nfiles(f->shared->efc); - if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) + if (H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set elink file cache size") - if(f->shared->pb_ptr != NULL) { - if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &(f->shared->pb_ptr->max_size)) < 0) + if (f->shared->pb_ptr != NULL) { + if (H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &(f->shared->pb_ptr->max_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set page buffer size") - if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &(f->shared->pb_ptr->min_meta_perc)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum metadata fraction of page buffer") - if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &(f->shared->pb_ptr->min_raw_perc)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum raw data fraction of page buffer") + if (H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &(f->shared->pb_ptr->min_meta_perc)) < + 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, + "can't set minimum metadata fraction of page buffer") + if (H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &(f->shared->pb_ptr->min_raw_perc)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, + "can't set minimum raw data fraction of page buffer") } /* end if */ - if(H5P_set(new_plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, &(f->shared->vfd_swmr_config)) < 0) + if (H5P_set(new_plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, &(f->shared->vfd_swmr_config)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set initial metadata cache resize config.") #ifdef H5_HAVE_PARALLEL - if(H5P_set(new_plist, H5_COLL_MD_READ_FLAG_NAME, &(f->shared->coll_md_read)) < 0) + if (H5P_set(new_plist, H5_COLL_MD_READ_FLAG_NAME, &(f->shared->coll_md_read)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag") - if(H5P_set(new_plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->shared->coll_md_write)) < 0) + if (H5P_set(new_plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->shared->coll_md_write)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag") #endif /* H5_HAVE_PARALLEL */ - if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < 0) + if (H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < + 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") /* Prepare the driver property */ - driver_prop.driver_id = f->shared->lf->driver_id; + driver_prop.driver_id = f->shared->lf->driver_id; driver_prop.driver_info = H5FD_fapl_get(f->shared->lf); - driver_prop_copied = TRUE; + driver_prop_copied = TRUE; /* Set the driver property */ - if(H5P_set(new_plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_set(new_plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file driver ID & info") /* Set the VOL connector property */ - connector_prop.connector_id = f->shared->vol_id; + connector_prop.connector_id = f->shared->vol_id; connector_prop.connector_info = f->shared->vol_info; - if(H5P_set(new_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_set(new_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector ID & info") /* Set the file close degree appropriately */ - if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) + if (f->shared->fc_degree == H5F_CLOSE_DEFAULT && + H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") - else if(f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) + else if (f->shared->fc_degree != H5F_CLOSE_DEFAULT && + H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") done: /* Release the copy of the driver info, if it was set up */ - if(driver_prop_copied && H5FD_free_driver_info(driver_prop.driver_id, driver_prop.driver_info) < 0) + if (driver_prop_copied && H5FD_free_driver_info(driver_prop.driver_id, driver_prop.driver_info) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close copy of driver info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_access_plist() */ - /*------------------------------------------------------------------------- * Function: H5F_get_obj_count * @@ -295,7 +297,7 @@ done: herr_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -303,14 +305,13 @@ H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_i HDassert(obj_id_count_ptr); /* Perform the query */ - if((ret_value = H5F__get_objects(f, types, 0, NULL, app_ref, obj_id_count_ptr)) < 0) + if ((ret_value = H5F__get_objects(f, types, 0, NULL, app_ref, obj_id_count_ptr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F__get_objects failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_obj_count() */ - /*------------------------------------------------------------------------- * Function: H5F_get_obj_ids * @@ -320,9 +321,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list, hbool_t app_ref, size_t *obj_id_count_ptr) +H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list, hbool_t app_ref, + size_t *obj_id_count_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -330,14 +332,13 @@ H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list HDassert(obj_id_count_ptr); /* Perform the query */ - if((ret_value = H5F__get_objects(f, types, max_objs, oid_list, app_ref, obj_id_count_ptr)) < 0) + if ((ret_value = H5F__get_objects(f, types, max_objs, oid_list, app_ref, obj_id_count_ptr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F__get_objects failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_obj_ids() */ - /*--------------------------------------------------------------------------- * Function: H5F__get_objects * @@ -349,11 +350,12 @@ done: *--------------------------------------------------------------------------- */ static herr_t -H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr) +H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, hbool_t app_ref, + size_t *obj_id_count_ptr) { - size_t obj_id_count = 0; /* Number of open IDs */ - H5F_olist_t olist; /* Structure to hold search results */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t obj_id_count = 0; /* Number of open IDs */ + H5F_olist_t olist; /* Structure to hold search results */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -361,26 +363,26 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id HDassert(obj_id_count_ptr); /* Set up search information */ - olist.obj_id_list = (max_nobjs==0 ? NULL : obj_id_list); + olist.obj_id_list = (max_nobjs == 0 ? NULL : obj_id_list); olist.obj_id_count = &obj_id_count; olist.list_index = 0; olist.max_nobjs = max_nobjs; /* Determine if we are searching for local or global objects */ - if(types & H5F_OBJ_LOCAL) { - olist.file_info.local = TRUE; + if (types & H5F_OBJ_LOCAL) { + olist.file_info.local = TRUE; olist.file_info.ptr.file = f; } /* end if */ else { - olist.file_info.local = FALSE; + olist.file_info.local = FALSE; olist.file_info.ptr.shared = f ? f->shared : NULL; } /* end else */ /* Iterate through file IDs to count the number, and put their * IDs on the object list. */ - if(types & H5F_OBJ_FILE) { + if (types & H5F_OBJ_FILE) { olist.obj_type = H5I_FILE; - if(H5I_iterate(H5I_FILE, H5F__get_objects_cb, &olist, app_ref) < 0) + if (H5I_iterate(H5I_FILE, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)") } /* end if */ @@ -388,10 +390,10 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id * or the caller wants to get the list of IDs and the list isn't full, * search through dataset IDs to count number of datasets, and put their * IDs on the object list */ - if(!olist.max_nobjs || (olist.max_nobjs && olist.list_indexobj_type == H5I_FILE) { - if((olist->file_info.local && - (!olist->file_info.ptr.file || - (olist->file_info.ptr.file && (H5F_t*)obj_ptr == olist->file_info.ptr.file))) || - (!olist->file_info.local && - (!olist->file_info.ptr.shared || - (olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.shared)))) { + if (olist->obj_type == H5I_FILE) { + if ((olist->file_info.local && + (!olist->file_info.ptr.file || + (olist->file_info.ptr.file && (H5F_t *)obj_ptr == olist->file_info.ptr.file))) || + (!olist->file_info.local && + (!olist->file_info.ptr.shared || + (olist->file_info.ptr.shared && ((H5F_t *)obj_ptr)->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; - } /* end if */ - } /* end if */ - else { /* Either count opened object IDs or put the IDs on the list */ - H5O_loc_t *oloc; /* Group entry info for object */ + } /* end if */ + } /* end if */ + else { /* Either count opened object IDs or put the IDs on the list */ + H5O_loc_t *oloc; /* Group entry info for object */ - switch(olist->obj_type) { + switch (olist->obj_type) { case H5I_ATTR: oloc = H5A_oloc((H5A_t *)obj_ptr); break; @@ -491,14 +492,15 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) break; case H5I_DATATYPE: - if(H5T_is_named((H5T_t*)obj_ptr)==TRUE) - oloc = H5T_oloc((H5T_t*)obj_ptr); + if (H5T_is_named((H5T_t *)obj_ptr) == TRUE) + oloc = H5T_oloc((H5T_t *)obj_ptr); else oloc = NULL; break; case H5I_MAP: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "maps not supported in native VOL connector") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, + "maps not supported in native VOL connector") case H5I_UNINIT: case H5I_BADID: @@ -517,27 +519,28 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "unknown or invalid data object") } /* end switch */ - if((olist->file_info.local && - ((!olist->file_info.ptr.file && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || - (!olist->file_info.ptr.file && olist->obj_type != H5I_DATATYPE) || - (oloc && oloc->file == olist->file_info.ptr.file))) || - (!olist->file_info.local && - ((!olist->file_info.ptr.shared && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || - (!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) || - (oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.shared)))) { + if ((olist->file_info.local && ((!olist->file_info.ptr.file && olist->obj_type == H5I_DATATYPE && + H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || + (!olist->file_info.ptr.file && olist->obj_type != H5I_DATATYPE) || + (oloc && oloc->file == olist->file_info.ptr.file))) || + (!olist->file_info.local && + ((!olist->file_info.ptr.shared && olist->obj_type == H5I_DATATYPE && + H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || + (!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) || + (oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; } /* end if */ - } /* end else */ + } /* end else */ - if(add_obj) { + if (add_obj) { /* Add the object's ID to the ID list, if appropriate */ - if(olist->obj_id_list) { + if (olist->obj_id_list) { olist->obj_id_list[olist->list_index] = obj_id; olist->list_index++; } /* end if */ /* Increment the number of open objects */ - if(olist->obj_id_count) + if (olist->obj_id_count) (*olist->obj_id_count)++; /* Check if we've filled up the array. Return H5_ITER_STOP only if @@ -545,15 +548,14 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) * preset to H5_ITER_CONT) because H5I_iterate needs the return value of * H5_ITER_CONT to continue the iteration. */ - if(olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs) - HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ - } /* end if */ + if (olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs) + HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_objects_cb() */ - /*-------------------------------------------------------------------------- * Function: H5F__build_name * @@ -562,30 +564,32 @@ done: * Return: SUCCEED/FAIL *--------------------------------------------------------------------------*/ static herr_t -H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/) +H5F__build_name(const char *prefix, const char *file_name, char **full_name /*out*/) { - size_t prefix_len; /* length of prefix */ - size_t fname_len; /* Length of external link file name */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t prefix_len; /* length of prefix */ + size_t fname_len; /* Length of external link file name */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC prefix_len = HDstrlen(prefix); - fname_len = HDstrlen(file_name); + fname_len = HDstrlen(file_name); /* Allocate a buffer to hold the filename + prefix + possibly the delimiter + terminating null byte */ - if(NULL == (*full_name = (char *)H5MM_malloc(prefix_len + fname_len + 2 + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ + if (NULL == (*full_name = (char *)H5MM_malloc(prefix_len + fname_len + 2 + + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate filename buffer") /* Compose the full file name */ - HDsnprintf(*full_name, (prefix_len + fname_len + 2 + 2), "%s%s%s", prefix, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ - ((prefix_len == 0 || H5_CHECK_DELIMITER(prefix[prefix_len - 1])) ? "" : H5_DIR_SEPS), file_name); + HDsnprintf(*full_name, (prefix_len + fname_len + 2 + 2), "%s%s%s", + prefix, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ + ((prefix_len == 0 || H5_CHECK_DELIMITER(prefix[prefix_len - 1])) ? "" : H5_DIR_SEPS), + file_name); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__build_name() */ - /*-------------------------------------------------------------------------- * Function: H5F__getenv_prefix_name * @@ -597,10 +601,10 @@ done: * Return: A pointer to a pathname (can't fail but can return NULL) --------------------------------------------------------------------------*/ static char * -H5F__getenv_prefix_name(char **env_prefix/*in,out*/) +H5F__getenv_prefix_name(char **env_prefix /*in,out*/) { - char *strret; /* Pointer to next separator */ - char *ret_value = NULL; /* Return value */ + char *strret; /* Pointer to next separator */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -609,7 +613,7 @@ H5F__getenv_prefix_name(char **env_prefix/*in,out*/) /* Advance to next component, if possible */ strret = HDstrchr(*env_prefix, H5_COLON_SEPC); - if(strret == NULL) + if (strret == NULL) *env_prefix = NULL; else { /* Advance to next component */ @@ -622,7 +626,6 @@ H5F__getenv_prefix_name(char **env_prefix/*in,out*/) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__getenv_prefix_name() */ - /*------------------------------------------------------------------------- * Function: H5F_prefix_open_file * @@ -632,16 +635,15 @@ H5F__getenv_prefix_name(char **env_prefix/*in,out*/) *------------------------------------------------------------------------- */ H5F_t * -H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, - const char *prop_prefix, const char *file_name, unsigned file_intent, - hid_t fapl_id) +H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const char *prop_prefix, + const char *file_name, unsigned file_intent, hid_t fapl_id) { - H5F_t *src_file = NULL; /* Source file */ - char *full_name = NULL; /* File name with prefix */ - char *actual_file_name = NULL; /* File's actual name */ - char *temp_file_name = NULL; /* Temporary pointer to file name */ - size_t temp_file_name_len; /* Length of temporary file name */ - H5F_t *ret_value = NULL; /* Return value */ + H5F_t *src_file = NULL; /* Source file */ + char * full_name = NULL; /* File name with prefix */ + char * actual_file_name = NULL; /* File's actual name */ + char * temp_file_name = NULL; /* Temporary pointer to file name */ + size_t temp_file_name_len; /* Length of temporary file name */ + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -649,17 +651,17 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, file_intent &= (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ); /* Copy the file name to use */ - if(NULL == (temp_file_name = H5MM_strdup(file_name))) + if (NULL == (temp_file_name = H5MM_strdup(file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") temp_file_name_len = HDstrlen(temp_file_name); /* Target file_name is an absolute pathname: see RM for detailed description */ - if(H5_CHECK_ABSOLUTE(file_name) || H5_CHECK_ABS_PATH(file_name)) { + if (H5_CHECK_ABSOLUTE(file_name) || H5_CHECK_ABS_PATH(file_name)) { /* Try opening file */ - src_file = H5F__efc_open(primary_file, file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); /* Adjust temporary file name if file not opened */ - if(NULL == src_file) { + if (NULL == src_file) { char *ptr; /* Reset the error stack */ @@ -676,13 +678,13 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, HDstrncpy(temp_file_name, ptr, temp_file_name_len); temp_file_name[temp_file_name_len - 1] = '\0'; } /* end if */ - } /* end if */ - else if(H5_CHECK_ABS_DRIVE(file_name)) { + } /* end if */ + else if (H5_CHECK_ABS_DRIVE(file_name)) { /* Try opening file */ src_file = H5F__efc_open(primary_file, file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); /* Adjust temporary file name if file not opened */ - if(NULL == src_file) { + if (NULL == src_file) { /* Reset the error stack */ H5E_clear_stack(NULL); @@ -690,47 +692,48 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, HDstrncpy(temp_file_name, &file_name[2], temp_file_name_len); temp_file_name[temp_file_name_len - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ /* Try searching from paths set in the environment variable */ - if(src_file == NULL) { + if (src_file == NULL) { char *env_prefix; /* Get the appropriate environment variable */ - if(H5F_PREFIX_VDS == prefix_type) + if (H5F_PREFIX_VDS == prefix_type) env_prefix = HDgetenv("HDF5_VDS_PREFIX"); - else if(H5F_PREFIX_ELINK == prefix_type) + else if (H5F_PREFIX_ELINK == prefix_type) env_prefix = HDgetenv("HDF5_EXT_PREFIX"); else HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, NULL, "prefix type is not sensible") /* If environment variable is defined, iterate through prefixes it defines */ - if(NULL != env_prefix) { + if (NULL != env_prefix) { char *tmp_env_prefix, *saved_env; /* Make a copy of the environment variable string */ - if(NULL == (saved_env = tmp_env_prefix = H5MM_strdup(env_prefix))) + if (NULL == (saved_env = tmp_env_prefix = H5MM_strdup(env_prefix))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Loop over prefixes in environment variable */ - while((tmp_env_prefix) && (*tmp_env_prefix)) { + while ((tmp_env_prefix) && (*tmp_env_prefix)) { char *out_prefix_name; - out_prefix_name = H5F__getenv_prefix_name(&tmp_env_prefix/*in,out*/); - if(out_prefix_name && (*out_prefix_name)) { - if(H5F__build_name(out_prefix_name, temp_file_name, &full_name/*out*/) < 0) { + out_prefix_name = H5F__getenv_prefix_name(&tmp_env_prefix /*in,out*/); + if (out_prefix_name && (*out_prefix_name)) { + if (H5F__build_name(out_prefix_name, temp_file_name, &full_name /*out*/) < 0) { saved_env = (char *)H5MM_xfree(saved_env); HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") } /* end if */ /* Try opening file */ - src_file = H5F__efc_open(primary_file, full_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = + H5F__efc_open(primary_file, full_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); /* Release copy of file name */ full_name = (char *)H5MM_xfree(full_name); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); /* Leave if file was opened */ @@ -738,16 +741,16 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, break; H5E_clear_stack(NULL); } /* end if */ - } /* end while */ + } /* end while */ saved_env = (char *)H5MM_xfree(saved_env); } /* end if */ - } /* end if */ + } /* end if */ /* Try searching from property list */ - if(src_file == NULL && prop_prefix) { + if (src_file == NULL && prop_prefix) { /* Construct name to open */ - if(H5F__build_name(prop_prefix, temp_file_name, &full_name/*out*/) < 0) + if (H5F__build_name(prop_prefix, temp_file_name, &full_name /*out*/) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") /* Try opening file */ @@ -757,18 +760,18 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, full_name = (char *)H5MM_xfree(full_name); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); } /* end if */ /* Try searching from main file's "extpath": see description in H5F_open() & H5_build_extpath() */ - if(src_file == NULL) { + if (src_file == NULL) { char *dspath; - if(NULL != (dspath = H5F_EXTPATH(primary_file))) { + if (NULL != (dspath = H5F_EXTPATH(primary_file))) { /* Construct name to open */ - if(H5F__build_name(dspath, temp_file_name, &full_name/*out*/) < 0) + if (H5F__build_name(dspath, temp_file_name, &full_name /*out*/) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") /* Try opening file */ @@ -778,39 +781,39 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, full_name = (char *)H5MM_xfree(full_name); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); } /* end if */ - } /* end if */ + } /* end if */ /* Try the relative file_name stored in temp_file_name */ - if(src_file == NULL) { + if (src_file == NULL) { /* Try opening file */ src_file = H5F__efc_open(primary_file, temp_file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); } /* end if */ /* try the 'resolved' name for the virtual file */ - if(src_file == NULL) { + if (src_file == NULL) { char *ptr = NULL; /* Copy resolved file name */ - if(NULL == (actual_file_name = H5MM_strdup(H5F_ACTUAL_NAME(primary_file)))) + if (NULL == (actual_file_name = H5MM_strdup(H5F_ACTUAL_NAME(primary_file)))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "can't duplicate resolved file name string") /* get last component of file_name */ H5_GET_LAST_DELIMITER(actual_file_name, ptr) - if(ptr) + if (ptr) /* Truncate filename portion from actual file name path */ *ptr = '\0'; /* Build new file name for the external file */ - if(H5F__build_name((ptr ? actual_file_name : ""), temp_file_name, &full_name/*out*/) < 0) + if (H5F__build_name((ptr ? actual_file_name : ""), temp_file_name, &full_name /*out*/) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") actual_file_name = (char *)H5MM_xfree(actual_file_name); @@ -821,7 +824,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, full_name = (char *)H5MM_xfree(full_name); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); } /* end if */ @@ -830,20 +833,19 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, ret_value = src_file; done: - if((NULL == ret_value) && src_file) - if(H5F_efc_close(primary_file, src_file) < 0) + if ((NULL == ret_value) && src_file) + if (H5F_efc_close(primary_file, src_file) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close source file") - if(full_name) + if (full_name) full_name = (char *)H5MM_xfree(full_name); - if(temp_file_name) + if (temp_file_name) temp_file_name = (char *)H5MM_xfree(temp_file_name); - if(actual_file_name) + if (actual_file_name) actual_file_name = (char *)H5MM_xfree(actual_file_name); FUNC_LEAVE_NOAPI(ret_value) } /* H5F_prefix_open_file() */ - /*------------------------------------------------------------------------- * Function: H5F__is_hdf5 * @@ -855,9 +857,9 @@ done: htri_t H5F__is_hdf5(const char *name, hid_t fapl_id) { - H5FD_t *file = NULL; /* Low-level file struct */ - haddr_t sig_addr = HADDR_UNDEF; /* Addess of hdf5 file signature */ - htri_t ret_value = FAIL; /* Return value */ + H5FD_t *file = NULL; /* Low-level file struct */ + haddr_t sig_addr = HADDR_UNDEF; /* Addess of hdf5 file signature */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -865,24 +867,23 @@ H5F__is_hdf5(const char *name, hid_t fapl_id) /* NOTE: This now uses the fapl_id that was passed in, so H5Fis_accessible() * should work with arbitrary VFDs, unlike H5Fis_hdf5(). */ - if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF))) + if (NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to open file") /* The file is an hdf5 file if the hdf5 file signature can be found */ - if(H5FD_locate_signature(file, &sig_addr) < 0) + if (H5FD_locate_signature(file, &sig_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "error while trying to locate file signature") ret_value = (HADDR_UNDEF != sig_addr); done: /* Close the file */ - if(file) - if(H5FD_close(file) < 0 && TRUE == ret_value) + if (file) + if (H5FD_close(file) < 0 && TRUE == ret_value) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__is_hdf5() */ - /*------------------------------------------------------------------------- * Function: H5F__new * @@ -902,43 +903,43 @@ done: static H5F_t * H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL; - H5F_t *ret_value = NULL; + H5F_t *f = NULL; + H5F_t *ret_value = NULL; FUNC_ENTER_STATIC - if(NULL == (f = H5FL_CALLOC(H5F_t))) + if (NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") f->id_exists = FALSE; - if(shared) { + if (shared) { HDassert(lf == NULL); f->shared = shared; } else { - H5P_genplist_t *plist; /* Property list */ - unsigned efc_size; /* External file cache size */ - size_t u; /* Local index variable */ + H5P_genplist_t *plist; /* Property list */ + unsigned efc_size; /* External file cache size */ + size_t u; /* Local index variable */ HDassert(lf != NULL); - if(NULL == (f->shared = H5FL_CALLOC(H5F_shared_t))) + if (NULL == (f->shared = H5FL_CALLOC(H5F_shared_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") - f->shared->flags = flags; + f->shared->flags = flags; f->shared->sohm_addr = HADDR_UNDEF; f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION; f->shared->accum.loc = HADDR_UNDEF; - f->shared->lf = lf; + f->shared->lf = lf; /* Initialization for handling file space */ - for(u = 0; u < NELMTS(f->shared->fs_addr); u++) { + for (u = 0; u < NELMTS(f->shared->fs_addr); u++) { f->shared->fs_state[u] = H5F_FS_STATE_CLOSED; - f->shared->fs_addr[u] = HADDR_UNDEF; - f->shared->fs_man[u] = NULL; + f->shared->fs_addr[u] = HADDR_UNDEF; + f->shared->fs_man[u] = NULL; } /* This will be stored as eoa_pre_fsm_fsalloc in the fsinfo message */ /* This is done to be backward compatible with 1.10 library that has the FSM hack */ - f->shared->eoa_fsm_fsalloc = HADDR_UNDEF; + f->shared->eoa_fsm_fsalloc = HADDR_UNDEF; f->shared->eoa_post_mdci_fsalloc = HADDR_UNDEF; /* Initialization for handling file space (for paged aggregation) */ @@ -951,96 +952,98 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F * new file handle. We do this early because some values might need * to change as the file is being opened. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list") f->shared->fcpl_id = H5P_copy_plist(plist, FALSE); /* Get the FCPL values to cache */ - if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &f->shared->sizeof_addr) < 0) + if (H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &f->shared->sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for address") - if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &f->shared->sizeof_size) < 0) + if (H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &f->shared->sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size") - if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &f->shared->sohm_nindexes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &f->shared->sohm_nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get number of SOHM indexes") HDassert(f->shared->sohm_nindexes < 255); - if(H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &f->shared->fs_strategy) < 0) + if (H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &f->shared->fs_strategy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space strategy") - if(H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &f->shared->fs_persist) < 0) + if (H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &f->shared->fs_persist) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space persisting status") - if(H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &f->shared->fs_threshold) < 0) + if (H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &f->shared->fs_threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get free-space section threshold") - if(H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &f->shared->fs_page_size) < 0) + if (H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &f->shared->fs_page_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space page size") HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); /* Temporary for multi/split drivers: fail file creation * when persisting free-space or using paged aggregation strategy. */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) - if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) + if (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't open with this strategy or persistent fs") /* Get the FAPL values to cache */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") - if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) + if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial metadata cache resize config") - if(H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) + if (H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache number of slots") - if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) + if (H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache byte size") - if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) + if (H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get preempt read chunk") - if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) + if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold") - if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) + if (H5P_get(plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment") - if(H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME,&(f->shared->gc_ref)) < 0) + if (H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get garbage collect reference") - if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) + if (H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size") - if(H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &(f->shared->low_bound)) < 0) + if (H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &(f->shared->low_bound)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'low' bound for library format versions") - if(H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &(f->shared->high_bound)) < 0) + if (H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &(f->shared->high_bound)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'high' bound for library format versions") - if(H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &(f->shared->use_mdc_logging)) < 0) + if (H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &(f->shared->use_mdc_logging)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'use mdc logging' flag") - if(H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &(f->shared->start_mdc_log_on_access)) < 0) + if (H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &(f->shared->start_mdc_log_on_access)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'start mdc log on access' flag") - if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) + if (H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get metadata cache size") f->shared->meta_aggr.feature_flag = H5FD_FEAT_AGGREGATE_METADATA; - if(H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) + if (H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'small data' cache size") f->shared->sdata_aggr.feature_flag = H5FD_FEAT_AGGREGATE_SMALLDATA; - if(H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) + if (H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get elink file cache size") - if(efc_size > 0) - if(NULL == (f->shared->efc = H5F__efc_create(efc_size))) + if (efc_size > 0) + if (NULL == (f->shared->efc = H5F__efc_create(efc_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't create external file cache") #ifdef H5_HAVE_PARALLEL - if(H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &(f->shared->coll_md_read)) < 0) + if (H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &(f->shared->coll_md_read)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get collective metadata read flag") - if(H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->shared->coll_md_write)) < 0) + if (H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->shared->coll_md_write)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get collective metadata write flag") #endif /* H5_HAVE_PARALLEL */ - if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < 0) + if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < + 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial metadata cache resize config") /* Get the VFD values to cache */ f->shared->maxaddr = H5FD_get_maxaddr(lf); - if(!H5F_addr_defined(f->shared->maxaddr)) + if (!H5F_addr_defined(f->shared->maxaddr)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad maximum address from VFD") - if(H5FD_get_feature_flags(lf, &f->shared->feature_flags) < 0) + if (H5FD_get_feature_flags(lf, &f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get feature flags from VFD") /* Require the SWMR feature flag if SWMR I/O is desired */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO) && (H5F_INTENT(f) & (H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ))) + if (!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO) && + (H5F_INTENT(f) & (H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "must use a SWMR-compatible VFD when SWMR is specified") - if(H5FD_get_fs_type_map(lf, f->shared->fs_type_map) < 0) + if (H5FD_get_fs_type_map(lf, f->shared->fs_type_map) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get free space type mapping from VFD") - if(H5MF_init_merge_flags(f->shared) < 0) + if (H5MF_init_merge_flags(f->shared) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "problem initializing free space merge flags") f->shared->tmp_addr = f->shared->maxaddr; /* Disable temp. space allocation for parallel I/O (for now) */ @@ -1054,42 +1057,46 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F */ f->shared->use_tmp_space = !H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI); - /* Retrieve the # of read attempts here so that sohm in superblock will get the correct # of attempts */ - if(H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &f->shared->read_attempts) < 0) + /* Retrieve the # of read attempts here so that sohm in superblock will get the correct # of attempts + */ + if (H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &f->shared->read_attempts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get the # of read attempts") - /* When opening file with SWMR access, the # of read attempts is H5F_SWMR_METADATA_READ_ATTEMPTS if not set */ - /* When opening file without SWMR access, the # of read attempts is always H5F_METADATA_READ_ATTEMPTS (set or not set) */ - if(H5F_INTENT(f) & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE)) { + /* When opening file with SWMR access, the # of read attempts is H5F_SWMR_METADATA_READ_ATTEMPTS if + * not set */ + /* When opening file without SWMR access, the # of read attempts is always H5F_METADATA_READ_ATTEMPTS + * (set or not set) */ + if (H5F_INTENT(f) & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE)) { /* If no value for read attempts has been set, use the default */ - if(!f->shared->read_attempts) + if (!f->shared->read_attempts) f->shared->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS; /* Turn off accumulator with SWMR */ f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; - if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") + if (H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") } else { /* If no value for read attempts has been set, use the default */ - if(!f->shared->read_attempts) + if (!f->shared->read_attempts) f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; } /* Determine the # of bins for metdata read retries */ - if(H5F_set_retries(f) < 0) + if (H5F_set_retries(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't set retries and retries_nbins") /* Get the metadata cache log location (if we're logging) */ { - char *mdc_log_location = NULL; /* location of metadata cache log location */ + char *mdc_log_location = NULL; /* location of metadata cache log location */ - if(H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &mdc_log_location) < 0) + if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &mdc_log_location) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get mdc log location") - if(mdc_log_location != NULL) { + if (mdc_log_location != NULL) { size_t len = HDstrlen(mdc_log_location); - if(NULL == (f->shared->mdc_log_location = (char *)H5MM_calloc((len + 1) * sizeof(char)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate memory for mdc log file name") + if (NULL == (f->shared->mdc_log_location = (char *)H5MM_calloc((len + 1) * sizeof(char)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, + "can't allocate memory for mdc log file name") HDstrncpy(f->shared->mdc_log_location, mdc_log_location, len); } else @@ -1097,11 +1104,11 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F } /* end block */ /* Get object flush callback information */ - if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) + if (H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get object flush cb info") /* Get VFD SWMR configuration */ - if(H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, &(f->shared->vfd_swmr_config)) < 0) + if (H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, &(f->shared->vfd_swmr_config)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VFD SWMR config info") /* Initialization for VFD SWMR */ @@ -1115,56 +1122,56 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F f->shared->old_mdf_idx_len = 0; f->shared->old_mdf_idx_entries_used = 0; - f->shared->vfd_swmr_md_fd = -1; - f->shared->fs_man_md = NULL; + f->shared->vfd_swmr_md_fd = -1; + f->shared->fs_man_md = NULL; TAILQ_INIT(&f->shared->shadow_defrees); /* Get the VOL connector info */ - if(H5F__set_vol_conn(f) < 0) + if (H5F__set_vol_conn(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't cache VOL connector info") /* Create a metadata cache with the specified number of elements. * The cache might be created with a different number of elements and * the access property list should be updated to reflect that. */ - if(H5AC_create(f, &(f->shared->mdc_initCacheCfg), &(f->shared->mdc_initCacheImageCfg)) < 0) + if (H5AC_create(f, &(f->shared->mdc_initCacheCfg), &(f->shared->mdc_initCacheImageCfg)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create metadata cache") /* Create the file's "open object" information */ - if(H5FO_create(f) < 0) + if (H5FO_create(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure") /* Add new "shared" struct to list of open files */ - if(H5F__sfile_add(f->shared) < 0) + if (H5F__sfile_add(f->shared) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to append to list of open files") } /* end else */ f->shared->nrefs++; /* Create the file's "top open object" information */ - if(H5FO_top_create(f) < 0) + if (H5FO_top_create(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure") /* Set return value */ ret_value = f; done: - if(!ret_value && f) { - if(!shared) { + if (!ret_value && f) { + if (!shared) { /* Attempt to clean up some of the shared file structures */ - if(f->shared->efc) - if(H5F__efc_destroy(f->shared->efc) < 0) + if (f->shared->efc) + if (H5F__efc_destroy(f->shared->efc) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "can't destroy external file cache") - if(f->shared->fcpl_id > 0) - if(H5I_dec_ref(f->shared->fcpl_id) < 0) + if (f->shared->fcpl_id > 0) + if (H5I_dec_ref(f->shared->fcpl_id) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") f->shared = H5FL_FREE(H5F_shared_t, f->shared); } /* Free VOL object */ - if(f->vol_obj) - if(H5VL_free_object(f->vol_obj) < 0) + if (f->vol_obj) + if (H5VL_free_object(f->vol_obj) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "unable to free VOL object") f = H5FL_FREE(H5F_t, f); @@ -1173,7 +1180,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__new() */ - /*------------------------------------------------------------------------- * Function: H5F__dest * @@ -1188,7 +1194,7 @@ done: herr_t H5F__dest(H5F_t *f, hbool_t flush) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1196,8 +1202,8 @@ H5F__dest(H5F_t *f, hbool_t flush) HDassert(f); HDassert(f->shared); - if(1 == f->shared->nrefs) { - int actype; /* metadata cache type (enum value) */ + if (1 == f->shared->nrefs) { + int actype; /* metadata cache type (enum value) */ /* Mark this file as closing */ f->shared->closing = TRUE; @@ -1206,8 +1212,8 @@ H5F__dest(H5F_t *f, hbool_t flush) * Only try to flush the file if it was opened with write access, and if * the caller requested a flush. */ - if((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) - if(H5F__flush_phase1(f) < 0) + if ((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) + if (H5F__flush_phase1(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 1)") @@ -1215,7 +1221,7 @@ H5F__dest(H5F_t *f, hbool_t flush) * This allows the cache to set up for creating a metadata cache * image if this has been requested. */ - if(H5AC_prep_for_file_close(f) < 0) + if (H5AC_prep_for_file_close(f) < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "metadata cache prep for close failed") @@ -1223,8 +1229,8 @@ H5F__dest(H5F_t *f, hbool_t flush) * Only try to flush the file if it was opened with write access, and if * the caller requested a flush. */ - if((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) - if(H5F__flush_phase2(f, TRUE) < 0) + if ((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) + if (H5F__flush_phase2(f, TRUE) < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 2)") @@ -1237,8 +1243,8 @@ H5F__dest(H5F_t *f, hbool_t flush) HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); /* Release the external file cache */ - if(f->shared->efc) { - if(H5F__efc_destroy(f->shared->efc) < 0) + if (f->shared->efc) { + if (H5F__efc_destroy(f->shared->efc) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't destroy external file cache") f->shared->efc = NULL; @@ -1253,7 +1259,7 @@ H5F__dest(H5F_t *f, hbool_t flush) HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); /* Release objects that depend on the superblock being initialized */ - if(f->shared->sblock) { + if (f->shared->sblock) { /* Shutdown file free space manager(s) */ /* (We should release the free space information now (before * truncating the file and before the metadata cache is shut @@ -1270,8 +1276,8 @@ H5F__dest(H5F_t *f, hbool_t flush) * * -- JRM */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { - if(H5MF_close(f) < 0) + if (H5F_ACC_RDWR & H5F_INTENT(f)) { + if (H5MF_close(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info") @@ -1283,13 +1289,13 @@ H5F__dest(H5F_t *f, hbool_t flush) /* Flush the file again (if requested), as shutting down the * free space manager may dirty some data structures again. */ - if(flush) { + if (flush) { /* Clear status_flags */ f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_WRITE_ACCESS); f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_SWMR_WRITE_ACCESS); /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") @@ -1300,12 +1306,12 @@ H5F__dest(H5F_t *f, hbool_t flush) * At most, this should change the superblock or the * superblock extension messages. */ - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") /* Truncate the file to the current allocated size */ - if(H5FD_truncate(f->shared->lf, TRUE) < 0) + if (H5FD_truncate(f->shared->lf, TRUE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") @@ -1314,18 +1320,18 @@ H5F__dest(H5F_t *f, hbool_t flush) */ HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); } /* end if */ - } /* end if */ + } /* end if */ /* if it exists, unpin the driver information block cache entry, * since we're about to destroy the cache */ - if(f->shared->drvinfo) - if(H5AC_unpin_entry(f->shared->drvinfo) < 0) + if (f->shared->drvinfo) + if (H5AC_unpin_entry(f->shared->drvinfo) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin drvinfo") /* Unpin the superblock, since we're about to destroy the cache */ - if(H5AC_unpin_entry(f->shared->sblock) < 0) + if (H5AC_unpin_entry(f->shared->sblock) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") f->shared->sblock = NULL; @@ -1339,7 +1345,7 @@ H5F__dest(H5F_t *f, hbool_t flush) HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); /* Remove shared file struct from list of open files */ - if(H5F__sfile_remove(f->shared) < 0) + if (H5F__sfile_remove(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") @@ -1347,81 +1353,81 @@ H5F__dest(H5F_t *f, hbool_t flush) /* (Flushes any remaining dirty entries, which should only be the * superblock and / or driver info at this point) */ - if(H5AC_dest(f)) + if (H5AC_dest(f)) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") /* If this is a VFD SWMR writer, prep for flush or close */ - if((f->shared->vfd_swmr) && (f->shared->vfd_swmr_writer) && - (H5F_vfd_swmr_writer__prep_for_flush_or_close(f) < 0)) + if ((f->shared->vfd_swmr) && (f->shared->vfd_swmr_writer) && + (H5F_vfd_swmr_writer__prep_for_flush_or_close(f) < 0)) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "vfd swmr prep for flush or close failed") /* Shutdown the page buffer cache */ - if(H5PB_dest(f->shared) < 0) + if (H5PB_dest(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing page buffer cache") /* Clean up the metadata cache log location string */ - if(f->shared->mdc_log_location) + if (f->shared->mdc_log_location) f->shared->mdc_log_location = (char *)H5MM_xfree(f->shared->mdc_log_location); /* * Do not close the root group since we didn't count it, but free * the memory associated with it. */ - if(f->shared->root_grp) { + if (f->shared->root_grp) { /* Free the root group */ - if(H5G_root_free(f->shared->root_grp) < 0) + if (H5G_root_free(f->shared->root_grp) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") f->shared->root_grp = NULL; } /* end if */ /* Destroy other components of the file */ - if(H5F__accum_reset(f->shared, TRUE) < 0) + if (H5F__accum_reset(f->shared, TRUE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") - if(H5FO_dest(f) < 0) + if (H5FO_dest(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") f->shared->cwfs = (struct H5HG_heap_t **)H5MM_xfree(f->shared->cwfs); - if(H5G_node_close(f) < 0) + if (H5G_node_close(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") /* Destroy file creation properties */ - if(H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id)) + if (H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id)) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a property list") - if(H5I_dec_ref(f->shared->fcpl_id) < 0) + if (H5I_dec_ref(f->shared->fcpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list") /* VFD SWMR: closing down */ - if(H5F_ACC_RDWR & H5F_INTENT(f) && f->shared->vfd_swmr_md_fd >= 0) { - if(H5F_vfd_swmr_close_or_flush(f, TRUE) < 0) + if (H5F_ACC_RDWR & H5F_INTENT(f) && f->shared->vfd_swmr_md_fd >= 0) { + if (H5F_vfd_swmr_close_or_flush(f, TRUE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close the metadata file") } - if(f->shared->vfd_swmr) { - if(H5F_vfd_swmr_remove_entry_eot(f) < 0) + if (f->shared->vfd_swmr) { + if (H5F_vfd_swmr_remove_entry_eot(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") } /* Clean up the cached VOL connector ID & info */ - if(f->shared->vol_info) - if(H5VL_free_connector_info(f->shared->vol_id, f->shared->vol_info) < 0) + if (f->shared->vol_info) + if (H5VL_free_connector_info(f->shared->vol_id, f->shared->vol_info) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") - if(f->shared->vol_id > 0) - if(H5I_dec_ref(f->shared->vol_id) < 0) + if (f->shared->vol_id > 0) + if (H5I_dec_ref(f->shared->vol_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector ID") f->shared->vol_cls = NULL; /* Close the file */ - if(H5FD_close(f->shared->lf) < 0) + if (H5FD_close(f->shared->lf) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") @@ -1431,61 +1437,58 @@ H5F__dest(H5F_t *f, hbool_t flush) if (f->shared->vfd_swmr) { if (f->shared->mdf_idx != NULL) { H5MM_xfree(f->shared->mdf_idx); - f->shared->mdf_idx = NULL; + f->shared->mdf_idx = NULL; f->shared->mdf_idx_len = 0; } if (f->shared->old_mdf_idx != NULL) { H5MM_xfree(f->shared->old_mdf_idx); - f->shared->old_mdf_idx = NULL; + f->shared->old_mdf_idx = NULL; f->shared->old_mdf_idx_len = 0; } } - /* Free mount table */ - f->shared->mtab.child = (H5F_mount_t *)H5MM_xfree(f->shared->mtab.child); + f->shared->mtab.child = (H5F_mount_t *)H5MM_xfree(f->shared->mtab.child); f->shared->mtab.nalloc = 0; /* Free the external link file */ f->shared->extpath = (char *)H5MM_xfree(f->shared->extpath); /* Clean up the metadata retries array */ - for(actype = 0; actype < (int)H5AC_NTYPES; actype++) - if(f->shared->retries[actype]) + for (actype = 0; actype < (int)H5AC_NTYPES; actype++) + if (f->shared->retries[actype]) f->shared->retries[actype] = (uint32_t *)H5MM_xfree(f->shared->retries[actype]); /* Destroy shared file struct */ f->shared = (H5F_shared_t *)H5FL_FREE(H5F_shared_t, f->shared); - } - else if(f->shared->nrefs > 0) { + else if (f->shared->nrefs > 0) { /* * There are other references to the shared part of the file. * Only decrement the reference count. */ --f->shared->nrefs; - if(f->shared->vfd_swmr) { - if(H5F_vfd_swmr_remove_entry_eot(f) < 0) + if (f->shared->vfd_swmr) { + if (H5F_vfd_swmr_remove_entry_eot(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") } } /* Free the non-shared part of the file */ - f->open_name = (char *)H5MM_xfree(f->open_name); + f->open_name = (char *)H5MM_xfree(f->open_name); f->actual_name = (char *)H5MM_xfree(f->actual_name); - if(f->vol_obj && H5VL_free_object(f->vol_obj) < 0) + if (f->vol_obj && H5VL_free_object(f->vol_obj) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") f->vol_obj = NULL; - if(H5FO_top_dest(f) < 0) + if (H5FO_top_dest(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "problems closing file") f->shared = NULL; - f = H5FL_FREE(H5F_t, f); + f = H5FL_FREE(H5F_t, f); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__dest() */ - /*------------------------------------------------------------------------- * Function: H5F_open * @@ -1562,47 +1565,47 @@ H5F__dest(H5F_t *f, hbool_t flush) H5F_t * H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_t *file = NULL; /*the success return value */ - H5F_shared_t *shared = NULL; /*shared part of `file' */ - H5FD_t *lf = NULL; /*file driver part of `shared' */ - unsigned tent_flags; /*tentative flags */ - H5FD_class_t *drvr; /*file driver class info */ - H5P_genplist_t *a_plist; /*file access property list */ - H5F_close_degree_t fc_degree; /*file close degree */ - size_t page_buf_size; - unsigned page_buf_min_meta_perc = 0; - unsigned page_buf_min_raw_perc = 0; - hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ - hbool_t clear = FALSE; /*clear the status_flags */ - hbool_t evict_on_close; /* evict on close value from plist */ - char *lock_env_var = NULL;/*env var pointer */ - hbool_t use_file_locking; /*read from env var */ - hbool_t ci_load = FALSE; /* whether MDC ci load requested */ - hbool_t ci_write = FALSE; /* whether MDC CI write requested */ - hbool_t file_create = FALSE; /* creating a new file or not */ - H5F_vfd_swmr_config_t *vfd_swmr_config_ptr = NULL; /* Points to VFD SMWR config info */ - H5F_t *ret_value = NULL; /*actual return value */ + H5F_t * file = NULL; /*the success return value */ + H5F_shared_t * shared = NULL; /*shared part of `file' */ + H5FD_t * lf = NULL; /*file driver part of `shared' */ + unsigned tent_flags; /*tentative flags */ + H5FD_class_t * drvr; /*file driver class info */ + H5P_genplist_t * a_plist; /*file access property list */ + H5F_close_degree_t fc_degree; /*file close degree */ + size_t page_buf_size; + unsigned page_buf_min_meta_perc = 0; + unsigned page_buf_min_raw_perc = 0; + hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ + hbool_t clear = FALSE; /*clear the status_flags */ + hbool_t evict_on_close; /* evict on close value from plist */ + char * lock_env_var = NULL; /*env var pointer */ + hbool_t use_file_locking; /*read from env var */ + hbool_t ci_load = FALSE; /* whether MDC ci load requested */ + hbool_t ci_write = FALSE; /* whether MDC CI write requested */ + hbool_t file_create = FALSE; /* creating a new file or not */ + H5F_vfd_swmr_config_t *vfd_swmr_config_ptr = NULL; /* Points to VFD SMWR config info */ + H5F_t * ret_value = NULL; /*actual return value */ FUNC_ENTER_NOAPI(NULL) /* Get the file access property list, for future queries */ - if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") /* Allocate space for VFD SWMR configuration info */ - if(NULL == (vfd_swmr_config_ptr = H5MM_calloc(sizeof(H5F_vfd_swmr_config_t)))) + if (NULL == (vfd_swmr_config_ptr = H5MM_calloc(sizeof(H5F_vfd_swmr_config_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate memory for mdc log file name") /* Get VFD SWMR configuration */ - if(H5P_get(a_plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, vfd_swmr_config_ptr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VFD SWMR config info") + if (H5P_get(a_plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, vfd_swmr_config_ptr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VFD SWMR config info") /* When configured with VFD SWMR */ - if(vfd_swmr_config_ptr->version) { + if (vfd_swmr_config_ptr->version) { /* Verify that file access flags are consistent with VFD SWMR configuartion */ - if((flags & H5F_ACC_RDWR) && !vfd_swmr_config_ptr->writer) + if ((flags & H5F_ACC_RDWR) && !vfd_swmr_config_ptr->writer) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "file access is writer but VFD SWMR config is reader") - if((flags & H5F_ACC_RDWR) == 0 && vfd_swmr_config_ptr->writer) + if ((flags & H5F_ACC_RDWR) == 0 && vfd_swmr_config_ptr->writer) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "file access is reader but VFD SWMR config is writer") } @@ -1614,7 +1617,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * Otherwise it is the application's responsibility to never open the * same file more than once at a time. */ - if(NULL == (drvr = H5FD_get_class(fapl_id))) + if (NULL == (drvr = H5FD_get_class(fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to retrieve VFL class") /* Check the environment variable that determines if we care @@ -1622,7 +1625,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * disabled. */ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) + if (lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) use_file_locking = FALSE; else use_file_locking = TRUE; @@ -1638,30 +1641,31 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * application's responsibility to prevent this situation (there's no * way for us to detect it here anyway). */ - if(drvr->cmp) - tent_flags = flags & ~(H5F_ACC_CREAT|H5F_ACC_TRUNC|H5F_ACC_EXCL); + if (drvr->cmp) + tent_flags = flags & ~(H5F_ACC_CREAT | H5F_ACC_TRUNC | H5F_ACC_EXCL); else tent_flags = flags; - if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { - if(tent_flags == flags) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) + if (NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { + if (tent_flags == flags) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", + name, tent_flags) H5E_clear_stack(NULL); tent_flags = flags; - if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) + if (NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", + name, tent_flags) } /* end if */ /* Avoid reusing a virtual file opened exclusively by a second virtual * file, or opening the same file twice with different parameters. */ if ((lf = H5FD_deduplicate(lf, fapl_id)) == NULL) { - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, - "an already-open file conflicts with '%s'", name); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "an already-open file conflicts with '%s'", name); } /* Is the file already open? */ - if((shared = H5F__sfile_search(lf)) != NULL) { + if ((shared = H5F__sfile_search(lf)) != NULL) { /* * The file is already open, so use the corresponding H5F_shared_t. * We only allow one H5FD_t* per file so one doesn't @@ -1672,66 +1676,70 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * readers don't expect the file to change under them), or if the * SWMR write/read access flags don't agree. */ - if(flags & H5F_ACC_TRUNC) + if (flags & H5F_ACC_TRUNC) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to truncate a file which is already open") - if(flags & H5F_ACC_EXCL) + if (flags & H5F_ACC_EXCL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file exists") - if((flags & H5F_ACC_RDWR) && 0 == (shared->flags & H5F_ACC_RDWR)) + if ((flags & H5F_ACC_RDWR) && 0 == (shared->flags & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only") - if((flags & H5F_ACC_SWMR_WRITE) && 0 == (shared->flags & H5F_ACC_SWMR_WRITE)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR write access flag not the same for file that is already open") - if((flags & H5F_ACC_SWMR_READ) && !((shared->flags & H5F_ACC_SWMR_WRITE) || (shared->flags & H5F_ACC_SWMR_READ) || (shared->flags & H5F_ACC_RDWR))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR read access flag not the same for file that is already open") + if ((flags & H5F_ACC_SWMR_WRITE) && 0 == (shared->flags & H5F_ACC_SWMR_WRITE)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "SWMR write access flag not the same for file that is already open") + if ((flags & H5F_ACC_SWMR_READ) && + !((shared->flags & H5F_ACC_SWMR_WRITE) || (shared->flags & H5F_ACC_SWMR_READ) || + (shared->flags & H5F_ACC_RDWR))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "SWMR read access flag not the same for file that is already open") /* Allocate new "high-level" file struct */ - if((file = H5F__new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) + if ((file = H5F__new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") } /* end if */ else { /* Check if tentative open was good enough */ - if(flags != tent_flags) { + if (flags != tent_flags) { /* * This file is not yet open by the library and the flags we used to * open it are different than the desired flags. Close the tentative * file and open it for real. */ - if(H5FD_close(lf) < 0) + if (H5FD_close(lf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") - if(NULL == (lf = H5FD_open(name, flags, fapl_id, HADDR_UNDEF))) + if (NULL == (lf = H5FD_open(name, flags, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } /* end if */ /* Place an advisory lock on the file */ - if(use_file_locking) - if(H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) { + if (use_file_locking) + if (H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) { /* Locking failed - Closing will remove the lock */ - if(H5FD_close(lf) < 0) + if (H5FD_close(lf) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to lock the file") } /* end if */ /* Create the 'top' file structure */ - if(NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { + if (NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { /* If this is the only time the file has been opened and the struct * returned is NULL, H5FD_close() will never be called via H5F__dest() * so we have to close lf here before heading to the error handling. */ - if(H5FD_close(lf) < 0) + if (H5FD_close(lf) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to initialize file structure") } /* end if */ /* Need to set status_flags in the superblock if the driver has a 'lock' method */ - if(drvr->lock) + if (drvr->lock) set_flag = TRUE; } /* end else */ /* Check to see if both SWMR and cache image are requested. Fail if so */ - if(H5C_cache_image_status(file, &ci_load, &ci_write) < 0) + if (H5C_cache_image_status(file, &ci_load, &ci_write) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get MDC cache image status") - if((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) + if ((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, NULL, "can't have both SWMR and cache image") /* Retain the name the file was opened with */ @@ -1739,84 +1747,85 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* Short cuts */ shared = file->shared; - lf = shared->lf; + lf = shared->lf; /* Check if page buffering is enabled */ - if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0) + if (H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get page buffer size") - if(page_buf_size) { + if (page_buf_size) { #ifdef H5_HAVE_PARALLEL /* Collective metadata writes are not supported with page buffering */ - if(file->shared->coll_md_write) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "collective metadata writes are not supported with page buffering") + if (file->shared->coll_md_write) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "collective metadata writes are not supported with page buffering") /* Temporary: fail file create when page buffering feature is enabled for parallel */ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "page buffering is disabled for parallel") #endif /* H5_HAVE_PARALLEL */ /* Query for other page buffer cache properties */ - if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &page_buf_min_meta_perc) < 0) + if (H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &page_buf_min_meta_perc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get minimum metadata fraction of page buffer") - if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &page_buf_min_raw_perc) < 0) + if (H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &page_buf_min_raw_perc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get minimum raw data fraction of page buffer") } /* end if */ - /* * Read or write the file superblock, depending on whether the file is * empty or not. */ - if(0 == (MAX(H5FD_get_eof(lf, H5FD_MEM_SUPER), H5FD_get_eoa(lf, H5FD_MEM_SUPER))) && (flags & H5F_ACC_RDWR)) { + if (0 == (MAX(H5FD_get_eof(lf, H5FD_MEM_SUPER), H5FD_get_eoa(lf, H5FD_MEM_SUPER))) && + (flags & H5F_ACC_RDWR)) { /* * We've just opened a fresh new file (or truncated one). We need * to create & write the superblock. */ /* Create the page buffer before initializing the superblock */ - if(page_buf_size) - if(H5PB_create(shared, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) + if (page_buf_size) + if (H5PB_create(shared, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create page buffer") /* Initialize information about the superblock and allocate space for it */ /* (Writes superblock extension messages, if there are any) */ - if(H5F__super_init(file) < 0) + if (H5F__super_init(file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to allocate file superblock") /* Create and open the root group */ /* (This must be after the space for the superblock is allocated in * the file, since the superblock must be at offset 0) */ - if(H5G_mkroot(file, TRUE) < 0) + if (H5G_mkroot(file, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") file_create = TRUE; } /* end if */ - else if(1 == shared->nrefs) { + else if (1 == shared->nrefs) { /* Read the superblock if it hasn't been read before. */ - if(H5F__super_read(file, a_plist, TRUE) < 0) + if (H5F__super_read(file, a_plist, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") /* Create the page buffer before initializing the superblock */ - if(page_buf_size) - if(H5PB_create(shared, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) + if (page_buf_size) + if (H5PB_create(shared, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create page buffer") /* Open the root group */ - if(H5G_mkroot(file, FALSE) < 0) + if (H5G_mkroot(file, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") } /* end if */ /* Checked if configured for VFD SWMR */ - if(H5F_VFD_SWMR_CONFIG(file)) { + if (H5F_VFD_SWMR_CONFIG(file)) { /* Initialization for VFD SWMR writer and reader */ - if(1 == shared->nrefs) { - if(H5F_vfd_swmr_init(file, file_create) < 0) + if (1 == shared->nrefs) { + if (H5F_vfd_swmr_init(file, file_create) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "file open fail with initialization for VFD SWMR") } /* Insert the entry that corresponds to file onto the EOT queue */ - if(H5F_vfd_swmr_insert_entry_eot(file) < 0) + if (H5F_vfd_swmr_insert_entry_eot(file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "unable to insert entry into the EOT queue") } @@ -1826,27 +1835,27 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * second time or later, verify the access property list value matches * the degree in shared file structure. */ - if(H5P_get(a_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) + if (H5P_get(a_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree") - if(shared->nrefs == 1) { - if(fc_degree == H5F_CLOSE_DEFAULT) + if (shared->nrefs == 1) { + if (fc_degree == H5F_CLOSE_DEFAULT) shared->fc_degree = lf->cls->fc_degree; else shared->fc_degree = fc_degree; } /* end if */ - else if(shared->nrefs > 1) { - if(fc_degree == H5F_CLOSE_DEFAULT && shared->fc_degree != lf->cls->fc_degree) + else if (shared->nrefs > 1) { + if (fc_degree == H5F_CLOSE_DEFAULT && shared->fc_degree != lf->cls->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") - if(fc_degree != H5F_CLOSE_DEFAULT && fc_degree != shared->fc_degree) + if (fc_degree != H5F_CLOSE_DEFAULT && fc_degree != shared->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") } /* end if */ /* This is a private property to clear the status_flags in the super block */ /* Use by h5clear and a routine in test/flush2.c to clear the test file's status_flags */ - if(H5P_exist_plist(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME) > 0) { - if(H5P_get(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) + if (H5P_exist_plist(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME) > 0) { + if (H5P_get(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get clearance for status_flags") - else if(clear) + else if (clear) file->shared->sblock->status_flags = 0; } /* end if */ @@ -1855,91 +1864,95 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * or later, verify that the access property list value matches the value * in shared file structure. */ - if(H5P_get(a_plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) + if (H5P_get(a_plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get evict on close value") - if(shared->nrefs == 1) + if (shared->nrefs == 1) shared->evict_on_close = evict_on_close; - else if(shared->nrefs > 1) { - if(shared->evict_on_close != evict_on_close) + else if (shared->nrefs > 1) { + if (shared->evict_on_close != evict_on_close) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "file evict-on-close value doesn't match") } /* end if */ /* Formulate the absolute path for later search of target file for external links */ - if(shared->nrefs == 1) { - if(H5_build_extpath(name, &file->shared->extpath) < 0) + if (shared->nrefs == 1) { + if (H5_build_extpath(name, &file->shared->extpath) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath") } /* Formulate the actual file name, after following symlinks, etc. */ - if(H5F__build_actual_name(file, a_plist, name, &file->actual_name) < 0) + if (H5F__build_actual_name(file, a_plist, name, &file->actual_name) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build actual name") - if(set_flag) { - if(H5F_INTENT(file) & H5F_ACC_RDWR) { /* Set and check consistency of status_flags */ + if (set_flag) { + if (H5F_INTENT(file) & H5F_ACC_RDWR) { /* Set and check consistency of status_flags */ /* Skip check of status_flags for file with < superblock version 3 */ - if(file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { + if (file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { - if(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS || - file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for write/SWMR write (may use to clear file consistency flags)") + if (file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS || + file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "file is already open for write/SWMR write (may use to clear " + "file consistency flags)") } /* version 3 superblock */ file->shared->sblock->status_flags |= H5F_SUPER_WRITE_ACCESS; - if(H5F_INTENT(file) & H5F_ACC_SWMR_WRITE || H5F_USE_VFD_SWMR(file)) + if (H5F_INTENT(file) & H5F_ACC_SWMR_WRITE || H5F_USE_VFD_SWMR(file)) file->shared->sblock->status_flags |= H5F_SUPER_SWMR_WRITE_ACCESS; /* Flush the superblock & superblock extension */ - if(H5F_super_dirty(file) < 0) + if (H5F_super_dirty(file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, NULL, "unable to mark superblock as dirty") - if(H5F_flush_tagged_metadata(file, H5AC__SUPERBLOCK_TAG) < 0) + if (H5F_flush_tagged_metadata(file, H5AC__SUPERBLOCK_TAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, NULL, "unable to flush superblock") - if(H5F_flush_tagged_metadata(file, file->shared->sblock->ext_addr) < 0) + if (H5F_flush_tagged_metadata(file, file->shared->sblock->ext_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, NULL, "unable to flush superblock extension") /* Remove the file lock for SWMR_WRITE */ - if(use_file_locking && ((H5F_INTENT(file) & H5F_ACC_SWMR_WRITE) || H5F_USE_VFD_SWMR(file))) { - if(H5FD_unlock(file->shared->lf) < 0) + if (use_file_locking && ((H5F_INTENT(file) & H5F_ACC_SWMR_WRITE) || H5F_USE_VFD_SWMR(file))) { + if (H5FD_unlock(file->shared->lf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to unlock the file") - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* H5F_ACC_RDONLY: check consistency of status_flags */ /* Skip check of status_flags for file with < superblock version 3 */ - if(file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { - if(H5F_INTENT(file) & H5F_ACC_SWMR_READ || H5F_USE_VFD_SWMR(file)) { - if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS && - !(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) - || - (!(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && - file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is not already open for SWMR writing") + if (file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { + if (H5F_INTENT(file) & H5F_ACC_SWMR_READ || H5F_USE_VFD_SWMR(file)) { + if ((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS && + !(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) || + (!(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && + file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "file is not already open for SWMR writing") } /* end if */ - else if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) || - (file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for write (may use to clear file consistency flags)") + else if ((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) || + (file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "file is already open for write (may use to clear file " + "consistency flags)") } /* version 3 superblock */ - } /* end else */ - } /* end if set_flag */ + } /* end else */ + } /* end if set_flag */ /* Success */ ret_value = file; done: - if((NULL == ret_value) && file) { - if(file->shared->root_grp && file->shared->nrefs == 1) { - if(H5AC_expunge_tag_type_metadata(file, H5G_oloc(file->shared->root_grp)->addr, H5AC_OHDR_ID, H5AC__NO_FLAGS_SET, FALSE) < 0) + if ((NULL == ret_value) && file) { + if (file->shared->root_grp && file->shared->nrefs == 1) { + if (H5AC_expunge_tag_type_metadata(file, H5G_oloc(file->shared->root_grp)->addr, H5AC_OHDR_ID, + H5AC__NO_FLAGS_SET, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, NULL, "unable to expunge root group tagged entries") } - if(H5F__dest(file, FALSE) < 0) + if (H5F__dest(file, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") } - if(vfd_swmr_config_ptr) + if (vfd_swmr_config_ptr) H5MM_free(vfd_swmr_config_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_open() */ - /*------------------------------------------------------------------------- * Function: H5F__post_open * @@ -1953,7 +1966,7 @@ done: herr_t H5F__post_open(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1961,14 +1974,13 @@ H5F__post_open(H5F_t *f) HDassert(f); /* Store a vol object in the file struct */ - if(NULL == (f->vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, f, f->shared->vol_id))) + if (NULL == (f->vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, f, f->shared->vol_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't create VOL object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush() */ - /*------------------------------------------------------------------------- * Function: H5F_flush_phase1 * @@ -1981,7 +1993,7 @@ done: static herr_t H5F__flush_phase1(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1989,7 +2001,7 @@ H5F__flush_phase1(H5F_t *f) HDassert(f); /* Flush any cached dataset storage raw data */ - if(H5D_flush_all(f) < 0) + if (H5D_flush_all(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") @@ -1999,14 +2011,13 @@ H5F__flush_phase1(H5F_t *f) /* (needs to happen before cache flush, with superblock write, since the * 'eoa' value is written in superblock -QAK) */ - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush_phase1() */ - /*------------------------------------------------------------------------- * Function: H5F__flush_phase2 * @@ -2019,7 +2030,7 @@ H5F__flush_phase1(H5F_t *f) static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2027,12 +2038,12 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) HDassert(f); /* Flush the entire metadata cache */ - if(H5AC_flush(f) < 0) + if (H5AC_flush(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { /* Since we just returned from a call to H5AC_flush(), we just * passed through a barrier. Hence we can skip the barrier on * entry to the mpio file driver truncate call below, and the first @@ -2043,46 +2054,45 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) #endif /* H5_HAVE_PARALLEL */ /* Truncate the file to the current allocated size */ - if(H5FD_truncate(f->shared->lf, closing) < 0) + if (H5FD_truncate(f->shared->lf, closing) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") /* Flush the entire metadata cache again since the EOA could have changed in the truncate call. */ - if(H5AC_flush(f) < 0) + if (H5AC_flush(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) /* Reset the "flushing the file" flag */ H5CX_set_mpi_file_flushing(FALSE); #endif /* H5_HAVE_PARALLEL */ /* Flush out the metadata accumulator */ - if(H5F__accum_flush(f->shared) < 0) + if (H5F__accum_flush(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator") /* If this is a VFD SWMR writer, prep for flush or close */ - if((f->shared->vfd_swmr) && (f->shared->vfd_swmr_writer) && - (H5F_vfd_swmr_writer__prep_for_flush_or_close(f) < 0)) + if ((f->shared->vfd_swmr) && (f->shared->vfd_swmr_writer) && + (H5F_vfd_swmr_writer__prep_for_flush_or_close(f) < 0)) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "vfd swmr prep for flush or close failed") /* Flush the page buffer */ - if(H5PB_flush(f->shared) < 0) + if (H5PB_flush(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "page buffer flush failed") /* Flush file buffers to disk. */ - if(H5FD_flush(f->shared->lf, closing) < 0) + if (H5FD_flush(f->shared->lf, closing) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "low level flush failed") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush_phase2() */ - /*------------------------------------------------------------------------- * Function: H5F__flush * @@ -2095,7 +2105,7 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) herr_t H5F__flush(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2103,27 +2113,26 @@ H5F__flush(H5F_t *f) HDassert(f); /* First phase of flushing data */ - if(H5F__flush_phase1(f) < 0) + if (H5F__flush_phase1(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data") /* Second phase of flushing data */ - if(H5F__flush_phase2(f, FALSE) < 0) + if (H5F__flush_phase2(f, FALSE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data") /* VFD SWMR when flushing the HDF5 file */ - if(f->shared->nrefs == 1 && f->shared->vfd_swmr_writer && f->shared->vfd_swmr_md_fd >= 0) { + if (f->shared->nrefs == 1 && f->shared->vfd_swmr_writer && f->shared->vfd_swmr_md_fd >= 0) { HDassert(H5F_ACC_RDWR & H5F_INTENT(f)); - if(H5F_vfd_swmr_close_or_flush(f, FALSE) < 0) + if (H5F_vfd_swmr_close_or_flush(f, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to encode and write to the metadata file") } FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush() */ - /*------------------------------------------------------------------------- * Function: H5F__close * @@ -2148,7 +2157,7 @@ H5F__flush(H5F_t *f) herr_t H5F__close(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2158,12 +2167,12 @@ H5F__close(H5F_t *f) /* Perform checks for "semi" file close degree here, since closing the * file is not allowed if there are objects still open. */ - if(f->shared->fc_degree == H5F_CLOSE_SEMI) { - unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ - unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ + if (f->shared->fc_degree == H5F_CLOSE_SEMI) { + unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ + unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if (H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* If there are no other file IDs open on this file/mount hier., but @@ -2171,7 +2180,7 @@ H5F__close(H5F_t *f) * without decrementing the file ID's reference count and triggering * a "real" attempt at closing the file. */ - if(nopen_files == 1 && nopen_objs > 0) + if (nopen_files == 1 && nopen_objs > 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open") } @@ -2179,14 +2188,13 @@ H5F__close(H5F_t *f) f->id_exists = FALSE; /* Attempt to close the file/mount hierarchy */ - if(H5F_try_close(f, NULL) < 0) + if (H5F_try_close(f, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__close() */ - /*------------------------------------------------------------------------- * Function: H5F_try_close * @@ -2202,9 +2210,9 @@ done: herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) { - unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ - unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ + unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2218,18 +2226,18 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * It's needed by the evict-on-close code. Clients can ignore * this value by passing in NULL. */ - if(was_closed) + if (was_closed) *was_closed = FALSE; /* Check if this file is already in the process of closing */ - if(f->closing) { - if(was_closed) + if (f->closing) { + if (was_closed) *was_closed = TRUE; HGOTO_DONE(SUCCEED) } /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if (H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* @@ -2242,7 +2250,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * H5F_CLOSE_STRONG: if there are still objects open, close them * first, then close file. */ - switch(f->shared->fc_degree) { + switch (f->shared->fc_degree) { case H5F_CLOSE_WEAK: /* * If file or object IDS are still open then delay deletion of @@ -2250,13 +2258,13 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * caches and update the object header anyway so that failing to * close all objects isn't a major problem. */ - if((nopen_files + nopen_objs) > 0) + if ((nopen_files + nopen_objs) > 0) HGOTO_DONE(SUCCEED) break; case H5F_CLOSE_SEMI: /* Can leave safely if file IDs are still open on this file */ - if(nopen_files > 0) + if (nopen_files > 0) HGOTO_DONE(SUCCEED) /* Sanity check: If close degree if "semi" and we have gotten this @@ -2264,15 +2272,17 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) */ HDassert(nopen_files == 0 && nopen_objs == 0); - /* If we've gotten this far (ie. there are no open objects in the file), fall through to flush & close */ + /* If we've gotten this far (ie. there are no open objects in the file), fall through to flush & + * close */ break; case H5F_CLOSE_STRONG: /* If there are other open files in the hierarchy, we can leave now */ - if(nopen_files > 0) + if (nopen_files > 0) HGOTO_DONE(SUCCEED) - /* If we've gotten this far (ie. there are no open file IDs in the file/mount hierarchy), fall through to flush & close */ + /* If we've gotten this far (ie. there are no open file IDs in the file/mount hierarchy), fall + * through to flush & close */ break; case H5F_CLOSE_DEFAULT: @@ -2284,26 +2294,28 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) f->closing = TRUE; /* If the file close degree is "strong", close all the open objects in this file */ - if(f->shared->fc_degree == H5F_CLOSE_STRONG) { - HDassert(nopen_files == 0); + if (f->shared->fc_degree == H5F_CLOSE_STRONG) { + HDassert(nopen_files == 0); /* Forced close of all opened objects in this file */ - if(f->nopen_objs > 0) { - size_t obj_count; /* # of open objects */ - hid_t objs[128]; /* Array of objects to close */ - herr_t result; /* Local result from obj ID query */ - size_t u; /* Local index variable */ + if (f->nopen_objs > 0) { + size_t obj_count; /* # of open objects */ + hid_t objs[128]; /* Array of objects to close */ + herr_t result; /* Local result from obj ID query */ + size_t u; /* Local index variable */ /* Get the list of IDs of open dataset, group, & attribute objects */ - while((result = H5F_get_obj_ids(f, H5F_OBJ_LOCAL | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_ATTR, (int)(sizeof(objs) / sizeof(objs[0])), objs, FALSE, &obj_count)) <= 0 - && obj_count != 0 ) { + while ((result = H5F_get_obj_ids( + f, H5F_OBJ_LOCAL | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_ATTR, + (int)(sizeof(objs) / sizeof(objs[0])), objs, FALSE, &obj_count)) <= 0 && + obj_count != 0) { /* Try to close all the open objects in this file */ - for(u = 0; u < obj_count; u++) - if(H5I_dec_ref(objs[u]) < 0) + for (u = 0; u < obj_count; u++) + if (H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(1)") /* Get the list of IDs of open named datatype objects */ @@ -2311,36 +2323,38 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * they could be using one of the named datatypes and then the * open named datatype ID will get closed twice) */ - while((result = H5F_get_obj_ids(f, H5F_OBJ_LOCAL | H5F_OBJ_DATATYPE, (int)(sizeof(objs) / sizeof(objs[0])), objs, FALSE, &obj_count)) <= 0 - && obj_count != 0) { + while ((result = H5F_get_obj_ids(f, H5F_OBJ_LOCAL | H5F_OBJ_DATATYPE, + (int)(sizeof(objs) / sizeof(objs[0])), objs, FALSE, + &obj_count)) <= 0 && + obj_count != 0) { /* Try to close all the open objects in this file */ - for(u = 0; u < obj_count; u++) - if(H5I_dec_ref(objs[u]) < 0) + for (u = 0; u < obj_count; u++) + if (H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(2)") } /* end if */ - } /* end if */ + } /* end if */ /* Check if this is a child file in a mounting hierarchy & proceed up the * hierarchy if so. */ - if(f->parent) - if(H5F_try_close(f->parent, NULL) < 0) + if (f->parent) + if (H5F_try_close(f->parent, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close parent file") /* Unmount and close each child before closing the current file. */ - if(H5F__close_mounts(f) < 0) + if (H5F__close_mounts(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't unmount child files") /* If there is more than one reference to the shared file struct and the * file has an external file cache, we should see if it can be closed. This * can happen if a cycle is formed with external file caches. */ - if(f->shared->efc && (f->shared->nrefs > 1)) - if(H5F__efc_try_close(f) < 0) + if (f->shared->efc && (f->shared->nrefs > 1)) + if (H5F__efc_try_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't attempt to close EFC") /* Delay flush until the shared file struct is closed, in H5F__dest. If the @@ -2352,17 +2366,16 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * shared H5F_shared_t struct. If the reference count for the H5F_shared_t * struct reaches zero then destroy it also. */ - if(H5F__dest(f, TRUE) < 0) + if (H5F__dest(f, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") /* Since we closed the file, this should be set to TRUE */ - if(was_closed) + if (was_closed) *was_closed = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_try_close() */ - /*------------------------------------------------------------------------- * Function: H5F__reopen * @@ -2381,23 +2394,22 @@ done: H5F_t * H5F__reopen(H5F_t *f) { - H5F_t *ret_value = NULL; /* Return value */ + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if(NULL == (ret_value = H5F__new(f->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) + if (NULL == (ret_value = H5F__new(f->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to reopen file") /* Duplicate old file's names */ - ret_value->open_name = H5MM_xstrdup(f->open_name); - ret_value->actual_name = H5MM_xstrdup(f->actual_name); + ret_value->open_name = H5MM_xstrdup(f->open_name); + ret_value->actual_name = H5MM_xstrdup(f->actual_name); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__reopen() */ - /*------------------------------------------------------------------------- * Function: H5F_get_id * @@ -2413,21 +2425,21 @@ done: hid_t H5F_get_id(H5F_t *file) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(H5I_find_id(file, H5I_FILE, &ret_value) < 0 || H5I_INVALID_HID == ret_value) { + if (H5I_find_id(file, H5I_FILE, &ret_value) < 0 || H5I_INVALID_HID == ret_value) { /* resurrect the ID - Register an ID with the native connector */ - if((ret_value = H5VL_wrap_register(H5I_FILE, file, FALSE)) < 0) + if ((ret_value = H5VL_wrap_register(H5I_FILE, file, FALSE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") file->id_exists = TRUE; } else { /* Increment reference count on existing ID */ - if(H5I_inc_ref(ret_value, FALSE) < 0) + if (H5I_inc_ref(ret_value, FALSE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "incrementing file ID failed") } /* end else */ @@ -2435,7 +2447,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_id() */ - /*------------------------------------------------------------------------- * Function: H5F_incr_nopen_objs * @@ -2456,7 +2467,6 @@ H5F_incr_nopen_objs(H5F_t *f) FUNC_LEAVE_NOAPI(++f->nopen_objs) } /* end H5F_incr_nopen_objs() */ - /*------------------------------------------------------------------------- * Function: H5F_decr_nopen_objs * @@ -2477,7 +2487,6 @@ H5F_decr_nopen_objs(H5F_t *f) FUNC_LEAVE_NOAPI(--f->nopen_objs) } /* end H5F_decr_nopen_objs() */ - /*------------------------------------------------------------------------- * Function: H5F__build_actual_name * @@ -2490,14 +2499,14 @@ H5F_decr_nopen_objs(H5F_t *f) */ static herr_t H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, - char **actual_name/*out*/) + char **actual_name /*out*/) { - hid_t new_fapl_id = H5I_INVALID_HID; /* ID for duplicated FAPL */ + hid_t new_fapl_id = H5I_INVALID_HID; /* ID for duplicated FAPL */ #ifdef H5_HAVE_SYMLINK /* This has to be declared here to avoid unfreed resources on errors */ - char *realname = NULL; /* Fully resolved path name of file */ -#endif /* H5_HAVE_SYMLINK */ - herr_t ret_value = SUCCEED; /* Return value */ + char *realname = NULL; /* Fully resolved path name of file */ +#endif /* H5_HAVE_SYMLINK */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2515,90 +2524,90 @@ H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *n */ #ifdef H5_HAVE_SYMLINK /* Check for POSIX I/O compatible file handle */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_POSIX_COMPAT_HANDLE)) { - h5_stat_t lst; /* Stat info from lstat() call */ + if (H5F_HAS_FEATURE(f, H5FD_FEAT_POSIX_COMPAT_HANDLE)) { + h5_stat_t lst; /* Stat info from lstat() call */ /* Call lstat() on the file's name */ - if(HDlstat(name, &lst) < 0) + if (HDlstat(name, &lst) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stat info for file") /* Check for symbolic link */ - if(S_IFLNK == (lst.st_mode & S_IFMT)) { - H5P_genplist_t *new_fapl; /* Duplicated FAPL */ - int *fd; /* POSIX I/O file descriptor */ - h5_stat_t st; /* Stat info from stat() call */ - h5_stat_t fst; /* Stat info from fstat() call */ - hbool_t want_posix_fd; /* Flag for retrieving file descriptor from VFD */ + if (S_IFLNK == (lst.st_mode & S_IFMT)) { + H5P_genplist_t *new_fapl; /* Duplicated FAPL */ + int * fd; /* POSIX I/O file descriptor */ + h5_stat_t st; /* Stat info from stat() call */ + h5_stat_t fst; /* Stat info from fstat() call */ + hbool_t want_posix_fd; /* Flag for retrieving file descriptor from VFD */ /* Allocate realname buffer */ - if(NULL == (realname = (char *)H5MM_calloc((size_t)PATH_MAX * sizeof(char)))) + if (NULL == (realname = (char *)H5MM_calloc((size_t)PATH_MAX * sizeof(char)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Perform a sanity check that the file or link wasn't switched * between when we opened it and when we called lstat(). This is * according to the security best practices for lstat() documented - * here: https://www.securecoding.cert.org/confluence/display/seccode/POS35-C.+Avoid+race+conditions+while+checking+for+the+existence+of+a+symbolic+link + * here: + * https://www.securecoding.cert.org/confluence/display/seccode/POS35-C.+Avoid+race+conditions+while+checking+for+the+existence+of+a+symbolic+link */ /* Copy the FAPL object to modify */ - if((new_fapl_id = H5P_copy_plist(fapl, FALSE)) < 0) + if ((new_fapl_id = H5P_copy_plist(fapl, FALSE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy file access property list") - if(NULL == (new_fapl = (H5P_genplist_t *)H5I_object(new_fapl_id))) + if (NULL == (new_fapl = (H5P_genplist_t *)H5I_object(new_fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "can't get property list") /* Set the character encoding on the new property list */ want_posix_fd = TRUE; - if(H5P_set(new_fapl, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0) + if (H5P_set(new_fapl, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set character encoding") /* Retrieve the file handle */ - if(H5F_get_vfd_handle(f, new_fapl_id, (void **)&fd) < 0) + if (H5F_get_vfd_handle(f, new_fapl_id, (void **)&fd) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve POSIX file descriptor") /* Stat the filename we're resolving */ - if(HDstat(name, &st) < 0) + if (HDstat(name, &st) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to stat file") /* Stat the file we opened */ - if(HDfstat(*fd, &fst) < 0) + if (HDfstat(*fd, &fst) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to fstat file") /* Verify that the files are really the same */ - if(st.st_mode != fst.st_mode || st.st_ino != fst.st_ino || st.st_dev != fst.st_dev) + if (st.st_mode != fst.st_mode || st.st_ino != fst.st_ino || st.st_dev != fst.st_dev) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "files' st_ino or st_dev fields changed!") /* Get the resolved path for the file name */ - if(NULL == HDrealpath(name, realname)) + if (NULL == HDrealpath(name, realname)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve real path for file") /* Duplicate the resolved path for the file name */ - if(NULL == (*actual_name = (char *)H5MM_strdup(realname))) + if (NULL == (*actual_name = (char *)H5MM_strdup(realname))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't duplicate real path") } /* end if */ - } /* end if */ -#endif /* H5_HAVE_SYMLINK */ + } /* end if */ +#endif /* H5_HAVE_SYMLINK */ /* Check if we've resolved the file's name */ - if(NULL == *actual_name) { + if (NULL == *actual_name) { /* Just duplicate the name used to open the file */ - if(NULL == (*actual_name = (char *)H5MM_strdup(name))) + if (NULL == (*actual_name = (char *)H5MM_strdup(name))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't duplicate open name") } /* end else */ done: /* Close the property list */ - if(new_fapl_id > 0) - if(H5I_dec_app_ref(new_fapl_id) < 0) + if (new_fapl_id > 0) + if (H5I_dec_app_ref(new_fapl_id) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL") #ifdef H5_HAVE_SYMLINK - if(realname) + if (realname) realname = (char *)H5MM_xfree(realname); #endif /* H5_HAVE_SYMLINK */ FUNC_LEAVE_NOAPI(ret_value) } /* H5F__build_actual_name() */ - /*------------------------------------------------------------------------- * Function: H5F_addr_encode_len * @@ -2610,9 +2619,9 @@ done: *------------------------------------------------------------------------- */ void -H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr) +H5F_addr_encode_len(size_t addr_len, uint8_t **pp /*in,out*/, haddr_t addr) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2620,22 +2629,21 @@ H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr) HDassert(addr_len); HDassert(pp && *pp); - if(H5F_addr_defined(addr)) { - for(u = 0; u < addr_len; u++) { + if (H5F_addr_defined(addr)) { + for (u = 0; u < addr_len; u++) { *(*pp)++ = (uint8_t)(addr & 0xff); addr >>= 8; } /* end for */ HDassert("overflow" && 0 == addr); } /* end if */ else { - for(u = 0; u < addr_len; u++) + for (u = 0; u < addr_len; u++) *(*pp)++ = 0xff; } /* end else */ FUNC_LEAVE_NOAPI_VOID } /* end H5F_addr_encode_len() */ - /*------------------------------------------------------------------------- * Function: H5F_addr_encode * @@ -2647,7 +2655,7 @@ H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr) *------------------------------------------------------------------------- */ void -H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) +H5F_addr_encode(const H5F_t *f, uint8_t **pp /*in,out*/, haddr_t addr) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2659,7 +2667,6 @@ H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) FUNC_LEAVE_NOAPI_VOID } /* end H5F_addr_encode() */ - /*------------------------------------------------------------------------- * Function: H5F_addr_decode_len * @@ -2674,10 +2681,10 @@ H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) *------------------------------------------------------------------------- */ void -H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/) +H5F_addr_decode_len(size_t addr_len, const uint8_t **pp /*in,out*/, haddr_t *addr_p /*out*/) { - hbool_t all_zero = TRUE; /* True if address was all zeroes */ - unsigned u; /* Local index variable */ + hbool_t all_zero = TRUE; /* True if address was all zeroes */ + unsigned u; /* Local index variable */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2690,40 +2697,38 @@ H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr *addr_p = 0; /* Decode bytes from address */ - for(u = 0; u < addr_len; u++) { - uint8_t c; /* Local decoded byte */ + for (u = 0; u < addr_len; u++) { + uint8_t c; /* Local decoded byte */ /* Get decoded byte (and advance pointer) */ c = *(*pp)++; /* Check for non-undefined address byte value */ - if(c != 0xff) + if (c != 0xff) all_zero = FALSE; - if(u < sizeof(*addr_p)) { - haddr_t tmp = c; /* Local copy of address, for casting */ + if (u < sizeof(*addr_p)) { + haddr_t tmp = c; /* Local copy of address, for casting */ /* Shift decoded byte to correct position */ - tmp <<= (u * 8); /*use tmp to get casting right */ + tmp <<= (u * 8); /*use tmp to get casting right */ /* Merge into already decoded bytes */ *addr_p |= tmp; } /* end if */ - else - if(!all_zero) - HDassert(0 == **pp); /*overflow */ - } /* end for */ + else if (!all_zero) + HDassert(0 == **pp); /*overflow */ + } /* end for */ /* If 'all_zero' is still TRUE, the address was entirely composed of '0xff' * bytes, which is the encoded form of 'HADDR_UNDEF', so set the destination * to that value */ - if(all_zero) + if (all_zero) *addr_p = HADDR_UNDEF; FUNC_LEAVE_NOAPI_VOID } /* end H5F_addr_decode_len() */ - /*------------------------------------------------------------------------- * Function: H5F_addr_decode * @@ -2738,7 +2743,7 @@ H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr *------------------------------------------------------------------------- */ void -H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/) +H5F_addr_decode(const H5F_t *f, const uint8_t **pp /*in,out*/, haddr_t *addr_p /*out*/) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2750,7 +2755,6 @@ H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*o FUNC_LEAVE_NOAPI_VOID } /* end H5F_addr_decode() */ - /*------------------------------------------------------------------------- * Function: H5F_set_grp_btree_shared * @@ -2775,7 +2779,6 @@ H5F_set_grp_btree_shared(H5F_t *f, H5UC_t *rc) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_grp_btree_shared() */ - /*------------------------------------------------------------------------- * Function: H5F_set_sohm_addr * @@ -2799,7 +2802,6 @@ H5F_set_sohm_addr(H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_sohm_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_set_sohm_vers * @@ -2823,7 +2825,6 @@ H5F_set_sohm_vers(H5F_t *f, unsigned vers) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_sohm_vers() */ - /*------------------------------------------------------------------------- * Function: H5F_set_sohm_nindexes * @@ -2847,7 +2848,6 @@ H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_sohm_nindexes() */ - /*------------------------------------------------------------------------- * Function: H5F_set_store_msg_crt_idx * @@ -2871,7 +2871,6 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_store_msg_crt_idx() */ - /*------------------------------------------------------------------------- * Function: H5F__set_libver_bounds() * @@ -2889,7 +2888,7 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2898,7 +2897,7 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) HDassert(f->shared); /* Set the bounds only if the existing setting is different from the inputs */ - if(f->shared->low_bound != low || f->shared->high_bound != high) { + if (f->shared->low_bound != low || f->shared->high_bound != high) { /* Call the flush routine, for this file */ /* Note: This is done in case the binary format for representing a * metadata entry class changes when the file format low / high @@ -2919,11 +2918,11 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) * * QAK - April, 2018 */ - if(H5F__flush(f) < 0) + if (H5F__flush(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Set the new bounds */ - f->shared->low_bound = low; + f->shared->low_bound = low; f->shared->high_bound = high; } @@ -2931,7 +2930,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__set_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5F__get_file_image * @@ -2944,17 +2942,17 @@ done: ssize_t H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) { - H5FD_t *fd_ptr; /* file driver */ - haddr_t eoa; /* End of file address */ - ssize_t ret_value = -1; /* Return value */ + H5FD_t *fd_ptr; /* file driver */ + haddr_t eoa; /* End of file address */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(!file || !file->shared || !file->shared->lf) + if (!file || !file->shared || !file->shared->lf) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "file_id yields invalid file pointer") fd_ptr = file->shared->lf; - if(!fd_ptr->cls) + if (!fd_ptr->cls) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "fd_ptr yields invalid class pointer") /* the address space used by the split and multi file drivers is not @@ -2975,7 +2973,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * * JRM -- 11/11/22 */ - if(HDstrcmp(fd_ptr->cls->name, "multi") == 0) + if (HDstrcmp(fd_ptr->cls->name, "multi") == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "Not supported for multi file driver.") /* While the family file driver is conceptually fully compatible @@ -2997,30 +2995,30 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * in the future. * JRM -- 12/21/11 */ - if(HDstrcmp(fd_ptr->cls->name, "family") == 0) + if (HDstrcmp(fd_ptr->cls->name, "family") == 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "Not supported for family file driver.") /* Go get the actual file size */ - if(HADDR_UNDEF == (eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT))) + if (HADDR_UNDEF == (eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file size") /* set ret_value = to eoa -- will overwrite this if appropriate */ ret_value = (ssize_t)eoa; /* test to see if a buffer was provided -- if not, we are done */ - if(buf_ptr != NULL) { - size_t space_needed; /* size of file image */ + if (buf_ptr != NULL) { + size_t space_needed; /* size of file image */ unsigned tmp, tmp_size; /* Check for buffer too small */ - if((haddr_t)buf_len < eoa) + if ((haddr_t)buf_len < eoa) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "supplied buffer too small") space_needed = (size_t)eoa; /* read in the file image */ /* (Note compensation for base address addition in internal routine) */ - if(H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) + if (H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, (-1), "file image read request failed") /* Offset to "status_flags" in the superblock */ @@ -3037,7 +3035,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__get_file_image() */ - /*------------------------------------------------------------------------- * Function: H5F__get_info * @@ -3050,7 +3047,7 @@ done: herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3063,28 +3060,27 @@ H5F__get_info(H5F_t *f, H5F_info2_t *finfo) HDmemset(finfo, 0, sizeof(*finfo)); /* Get the size of the superblock and any superblock extensions */ - if(H5F__super_size(f, &finfo->super.super_size, &finfo->super.super_ext_size) < 0) + if (H5F__super_size(f, &finfo->super.super_size, &finfo->super.super_ext_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock sizes") /* Get the size of any persistent free space */ - if(H5MF_get_freespace(f, &finfo->free.tot_space, &finfo->free.meta_size) < 0) + if (H5MF_get_freespace(f, &finfo->free.tot_space, &finfo->free.meta_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve free space information") /* Check for SOHM info */ - if(H5F_addr_defined(f->shared->sohm_addr)) - if(H5SM_ih_size(f, &finfo->sohm.hdr_size, &finfo->sohm.msgs_info) < 0) + if (H5F_addr_defined(f->shared->sohm_addr)) + if (H5SM_ih_size(f, &finfo->sohm.hdr_size, &finfo->sohm.msgs_info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve SOHM index & heap storage info") /* Set version # fields */ finfo->super.version = f->shared->sblock->super_vers; - finfo->sohm.version = f->shared->sohm_vers; - finfo->free.version = HDF5_FREESPACE_VERSION; + finfo->sohm.version = f->shared->sohm_vers; + finfo->free.version = HDF5_FREESPACE_VERSION; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__get_info() */ - /*------------------------------------------------------------------------- * Function: H5F_track_metadata_read_retries * @@ -3100,9 +3096,9 @@ done: herr_t H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries) { - unsigned log_ind; /* Index to the array of retries based on log10 of retries */ - double tmp; /* Temporary value, to keep compiler quiet */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned log_ind; /* Index to the array of retries based on log10 of retries */ + double tmp; /* Temporary value, to keep compiler quiet */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3115,12 +3111,13 @@ H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries) HDassert(actype < H5AC_NTYPES); /* Allocate memory for retries */ - if(NULL == f->shared->retries[actype]) - if(NULL == (f->shared->retries[actype] = (uint32_t *)H5MM_calloc((size_t)f->shared->retries_nbins * sizeof(uint32_t)))) + if (NULL == f->shared->retries[actype]) + if (NULL == (f->shared->retries[actype] = + (uint32_t *)H5MM_calloc((size_t)f->shared->retries_nbins * sizeof(uint32_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Index to retries based on log10 */ - tmp = HDlog10((double)retries); + tmp = HDlog10((double)retries); log_ind = (unsigned)tmp; HDassert(log_ind < f->shared->retries_nbins); @@ -3131,7 +3128,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_track_metadata_read_retries() */ - /*------------------------------------------------------------------------- * Function: H5F_set_retries * @@ -3145,7 +3141,7 @@ done: herr_t H5F_set_retries(H5F_t *f) { - double tmp; /* Temporary variable */ + double tmp; /* Temporary variable */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3158,17 +3154,16 @@ H5F_set_retries(H5F_t *f) /* Initialize the # of bins for retries */ f->shared->retries_nbins = 0; - if(f->shared->read_attempts > 1) { + if (f->shared->read_attempts > 1) { /* Use HDceil to ensure that the log10 value is rounded up to the nearest integer before casting to unsigned */ - tmp = HDceil(HDlog10((double)f->shared->read_attempts)); + tmp = HDceil(HDlog10((double)f->shared->read_attempts)); f->shared->retries_nbins = (unsigned)tmp; } FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_retries() */ - /*------------------------------------------------------------------------- * Function: H5F_object_flush_cb * @@ -3182,7 +3177,7 @@ H5F_set_retries(H5F_t *f) herr_t H5F_object_flush_cb(H5F_t *f, hid_t obj_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3191,14 +3186,14 @@ H5F_object_flush_cb(H5F_t *f, hid_t obj_id) HDassert(f->shared); /* Invoke object flush callback if there is one */ - if(f->shared->object_flush.func && f->shared->object_flush.func(obj_id, f->shared->object_flush.udata) < 0) + if (f->shared->object_flush.func && + f->shared->object_flush.func(obj_id, f->shared->object_flush.udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "object flush callback returns error") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_object_flush_cb() */ - /*------------------------------------------------------------------------- * Function: H5F__set_base_addr * @@ -3210,7 +3205,7 @@ done: herr_t H5F__set_base_addr(const H5F_t *f, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3218,14 +3213,13 @@ H5F__set_base_addr(const H5F_t *f, haddr_t addr) HDassert(f->shared); /* Dispatch to driver */ - if(H5FD_set_base_addr(f->shared->lf, addr) < 0) + if (H5FD_set_base_addr(f->shared->lf, addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_base_addr request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_base_addr() */ - /*------------------------------------------------------------------------- * Function: H5F__set_eoa * @@ -3237,7 +3231,7 @@ done: herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3246,14 +3240,13 @@ H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr) /* Dispatch to driver */ /* (H5FD_set_eoa() will add base_addr to addr) */ - if(H5FD_set_eoa(f->shared->lf, type, addr) < 0) + if (H5FD_set_eoa(f->shared->lf, type, addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5F__set_paged_aggr * @@ -3265,7 +3258,7 @@ done: herr_t H5F__set_paged_aggr(const H5F_t *f, hbool_t paged) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3274,14 +3267,13 @@ H5F__set_paged_aggr(const H5F_t *f, hbool_t paged) HDassert(f->shared); /* Dispatch to driver */ - if(H5FD_set_paged_aggr(f->shared->lf, paged) < 0) + if (H5FD_set_paged_aggr(f->shared->lf, paged) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set paged aggr mode failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_paged_aggr() */ - /*------------------------------------------------------------------------- * Function: H5F__get_max_eof_eoa * @@ -3293,10 +3285,10 @@ done: herr_t H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa) { - haddr_t eof; /* Relative address for EOF */ - haddr_t eoa; /* Relative address for EOA */ + haddr_t eof; /* Relative address for EOF */ + haddr_t eoa; /* Relative address for EOA */ haddr_t tmp_max; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3310,7 +3302,7 @@ H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa) /* Determine the maximum */ tmp_max = MAX(eof, eoa); - if(HADDR_UNDEF == tmp_max) + if (HADDR_UNDEF == tmp_max) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file get eof/eoa requests failed") *max_eof_eoa = tmp_max; @@ -3319,7 +3311,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_max_eof_eoa() */ - /*------------------------------------------------------------------------- * Function: H5F_get_metadata_read_retry_info * @@ -3333,9 +3324,9 @@ done: herr_t H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) { - unsigned i, j; /* Local index variable */ - size_t tot_size; /* Size of each retries[i] */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned i, j; /* Local index variable */ + size_t tot_size; /* Size of each retries[i] */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3350,7 +3341,7 @@ H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) HDmemset(info->retries, 0, sizeof(info->retries)); /* Return if there are no bins -- no retries */ - if(!info->nbins) + if (!info->nbins) HGOTO_DONE(SUCCEED); /* Calculate size for each retries[i] */ @@ -3358,7 +3349,7 @@ H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) /* Map and copy information to info's retries for metadata items with tracking for read retries */ j = 0; - for(i = 0; i < H5AC_NTYPES; i++) { + for (i = 0; i < H5AC_NTYPES; i++) { switch (i) { case H5AC_OHDR_ID: case H5AC_OHDR_CHK_ID: @@ -3382,13 +3373,13 @@ H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) case H5AC_FARRAY_DBLK_PAGE_ID: case H5AC_SUPERBLOCK_ID: HDassert(j < H5F_NUM_METADATA_READ_RETRY_TYPES); - if(file->shared->retries[i] != NULL) { + if (file->shared->retries[i] != NULL) { /* Allocate memory for retries[i] * * This memory should be released by the user with * the H5free_memory() call. */ - if(NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size))) + if (NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the information */ @@ -3408,7 +3399,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_metadata_read_retry_info() */ - /*------------------------------------------------------------------------- * Function: H5F__start_swmr_write * @@ -3446,18 +3436,18 @@ done: herr_t H5F__start_swmr_write(H5F_t *f) { - hbool_t ci_load = FALSE; /* whether MDC ci load requested */ - hbool_t ci_write = FALSE; /* whether MDC CI write requested */ - size_t grp_dset_count = 0; /* # of open objects: groups & datasets */ - size_t nt_attr_count = 0; /* # of opened named datatypes + opened attributes */ - hid_t *obj_ids = NULL; /* List of ids */ - H5G_loc_t *obj_glocs = NULL; /* Group location of the object */ - H5O_loc_t *obj_olocs = NULL; /* Object location */ - H5G_name_t *obj_paths = NULL; /* Group hierarchy path */ - size_t u; /* Local index variable */ - hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ - H5VL_t *vol_connector = NULL; /* VOL connector for the file */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t ci_load = FALSE; /* whether MDC ci load requested */ + hbool_t ci_write = FALSE; /* whether MDC CI write requested */ + size_t grp_dset_count = 0; /* # of open objects: groups & datasets */ + size_t nt_attr_count = 0; /* # of opened named datatypes + opened attributes */ + hid_t * obj_ids = NULL; /* List of ids */ + H5G_loc_t * obj_glocs = NULL; /* Group location of the object */ + H5O_loc_t * obj_olocs = NULL; /* Object location */ + H5G_name_t *obj_paths = NULL; /* Group hierarchy path */ + size_t u; /* Local index variable */ + hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ + H5VL_t * vol_connector = NULL; /* VOL connector for the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3466,66 +3456,68 @@ H5F__start_swmr_write(H5F_t *f) HDassert(f->shared); /* Should have write permission */ - if((H5F_INTENT(f) & H5F_ACC_RDWR) == 0) + if ((H5F_INTENT(f) & H5F_ACC_RDWR) == 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "no write intent on file") /* Check superblock version */ - if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) + if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file superblock version - should be at least 3") /* Check for correct file format version */ - if((f->shared->low_bound < H5F_LIBVER_V110) || (f->shared->high_bound < H5F_LIBVER_V110)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file format version does not support SWMR - needs to be 1.10 or greater") + if ((f->shared->low_bound < H5F_LIBVER_V110) || (f->shared->high_bound < H5F_LIBVER_V110)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "file format version does not support SWMR - needs to be 1.10 or greater") /* Should not be marked for SWMR writing mode already */ - if(f->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) + if (f->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file already in SWMR writing mode") /* Check to see if cache image is enabled. Fail if so */ - if(H5C_cache_image_status(f, &ci_load, &ci_write) < 0) + if (H5C_cache_image_status(f, &ci_load, &ci_write) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MDC cache image status") - if(ci_load || ci_write ) + if (ci_load || ci_write) HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "can't have both SWMR and MDC cache image") /* Flush the superblock extension */ - if(H5F_flush_tagged_metadata(f, f->shared->sblock->ext_addr) < 0) + if (H5F_flush_tagged_metadata(f, f->shared->sblock->ext_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock extension") /* Flush data buffers */ - if(H5F__flush(f) < 0) + if (H5F__flush(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Get the # of opened named datatypes and attributes */ - if(H5F_get_obj_count(f, H5F_OBJ_DATATYPE | H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0) + if (H5F_get_obj_count(f, H5F_OBJ_DATATYPE | H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - if(nt_attr_count > 0) + if (nt_attr_count > 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "named datatypes and/or attributes opened in the file") /* Get the # of opened datasets and groups */ - if(H5F_get_obj_count(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0) + if (H5F_get_obj_count(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - if(grp_dset_count > 0) { + if (grp_dset_count > 0) { /* Allocate space for group and object locations */ - if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL) + if ((obj_ids = (hid_t *)H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t") - if((obj_glocs = (H5G_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL) + if ((obj_glocs = (H5G_loc_t *)H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_loc_t") - if((obj_olocs = (H5O_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL) + if ((obj_olocs = (H5O_loc_t *)H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5O_loc_t") - if((obj_paths = (H5G_name_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL) + if ((obj_paths = (H5G_name_t *)H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_name_t") /* Get the list of opened object ids (groups & datasets) */ - if(H5F_get_obj_ids(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0) + if (H5F_get_obj_ids(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, + &grp_dset_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed") /* Save the VOL connector and the object wrapping context for the refresh step */ - if(grp_dset_count > 0) { + if (grp_dset_count > 0) { H5VL_object_t *vol_obj; /* Get the VOL object for one of the IDs */ - if(NULL == (vol_obj = H5VL_vol_object(obj_ids[0]))) + if (NULL == (vol_obj = H5VL_vol_object(obj_ids[0]))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the (top) connector for the ID */ @@ -3534,9 +3526,9 @@ H5F__start_swmr_write(H5F_t *f) /* Gather information about opened objects (groups, datasets) in the file */ /* (For refresh later on) */ - for(u = 0; u < grp_dset_count; u++) { - H5O_loc_t *oloc; /* object location */ - H5G_loc_t tmp_loc; + for (u = 0; u < grp_dset_count; u++) { + H5O_loc_t *oloc; /* object location */ + H5G_loc_t tmp_loc; /* Set up the id's group location */ obj_glocs[u].oloc = &obj_olocs[u]; @@ -3544,7 +3536,7 @@ H5F__start_swmr_write(H5F_t *f) H5G_loc_reset(&obj_glocs[u]); /* get the id's object location */ - if((oloc = H5O_get_loc(obj_ids[u])) == NULL) + if ((oloc = H5O_get_loc(obj_ids[u])) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object") /* Make deep local copy of object's location information */ @@ -3552,13 +3544,13 @@ H5F__start_swmr_write(H5F_t *f) H5G_loc_copy(&obj_glocs[u], &tmp_loc, H5_COPY_DEEP); /* Close the object */ - if(H5I_dec_ref(obj_ids[u]) < 0) + if (H5I_dec_ref(obj_ids[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEOBJ, FAIL, "decrementing object ID failed") } /* end for */ - } /* end if */ + } /* end if */ /* Flush and reset the accumulator */ - if(H5F__accum_reset(f->shared, TRUE) < 0) + if (H5F__accum_reset(f->shared, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") /* Turn on SWMR write in shared file open flags */ @@ -3571,30 +3563,30 @@ H5F__start_swmr_write(H5F_t *f) f->shared->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS; /* Initialize "retries" and "retries_nbins" */ - if(H5F_set_retries(f) < 0) + if (H5F_set_retries(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't set retries and retries_nbins") /* Turn off usage of accumulator */ f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; - if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) + if (H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set feature_flags in VFD") setup = TRUE; /* Mark superblock as dirty */ - if(H5F_super_dirty(f) < 0) + if (H5F_super_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") /* Flush the superblock */ - if(H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) + if (H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock") /* Evict all flushed entries in the cache except the pinned superblock */ - if(H5F__evict_cache_entries(f) < 0) + if (H5F__evict_cache_entries(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to evict file's cached information") /* Refresh (reopen) the objects (groups & datasets) in the file */ - for(u = 0; u < grp_dset_count; u++) + for (u = 0; u < grp_dset_count; u++) /* XXX This routine probably should prepare legitimate * H5O_refresh_state_t's, above, and pass those instead of NULL, so * that non-persistent object properties---e.g., dataset access @@ -3604,24 +3596,24 @@ H5F__start_swmr_write(H5F_t *f) * however, and it lets VFD SWMR development proceed, so I'm not * going to sweat it, now. */ - if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], NULL, vol_connector, TRUE) < 0) + if (H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], NULL, vol_connector, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object") /* Unlock the file */ - if(H5FD_unlock(f->shared->lf) < 0) + if (H5FD_unlock(f->shared->lf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to unlock the file") done: - if(ret_value < 0 && setup) { + if (ret_value < 0 && setup) { /* Re-enable accumulator */ f->shared->feature_flags |= (unsigned)H5FD_FEAT_ACCUMULATE_METADATA; - if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) + if (H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set feature_flags in VFD") /* Reset the # of read attempts */ f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; - if(H5F_set_retries(f) < 0) + if (H5F_set_retries(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't set retries and retries_nbins") /* Un-set H5F_ACC_SWMR_WRITE in shared open flags */ @@ -3631,28 +3623,27 @@ done: f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_SWMR_WRITE_ACCESS); /* Mark superblock as dirty */ - if(H5F_super_dirty(f) < 0) + if (H5F_super_dirty(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") /* Flush the superblock */ - if(H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) + if (H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock") } /* end if */ /* Free memory */ - if(obj_ids) + if (obj_ids) H5MM_xfree(obj_ids); - if(obj_glocs) + if (obj_glocs) H5MM_xfree(obj_glocs); - if(obj_olocs) + if (obj_olocs) H5MM_xfree(obj_olocs); - if(obj_paths) + if (obj_paths) H5MM_xfree(obj_paths); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__start_swmr_write() */ - /*------------------------------------------------------------------------- * Function: H5F__format_convert * @@ -3665,8 +3656,8 @@ done: herr_t H5F__format_convert(H5F_t *f) { - hbool_t mark_dirty = FALSE; /* Whether to mark the file's superblock dirty */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t mark_dirty = FALSE; /* Whether to mark the file's superblock dirty */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3675,29 +3666,30 @@ H5F__format_convert(H5F_t *f) HDassert(f->shared); /* Check if the superblock should be downgraded */ - if(f->shared->sblock->super_vers > HDF5_SUPERBLOCK_VERSION_V18_LATEST) { + if (f->shared->sblock->super_vers > HDF5_SUPERBLOCK_VERSION_V18_LATEST) { f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_V18_LATEST; - mark_dirty = TRUE; + mark_dirty = TRUE; } /* Check for persistent freespace manager, which needs to be downgraded */ - if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && - f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { + if (!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { /* Check to remove free-space manager info message from superblock extension */ - if(H5F_addr_defined(f->shared->sblock->ext_addr)) - if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") + if (H5F_addr_defined(f->shared->sblock->ext_addr)) + if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, + "error in removing message from superblock extension") /* Close freespace manager */ - if(H5MF_try_close(f) < 0) + if (H5MF_try_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to free free-space address") /* Set non-persistent freespace manager */ - f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; - f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; + f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; + f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; f->shared->fs_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; f->shared->fs_page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; @@ -3706,16 +3698,15 @@ H5F__format_convert(H5F_t *f) } /* end if */ /* Check if we should mark the superblock dirty */ - if(mark_dirty) + if (mark_dirty) /* Mark superblock as dirty */ - if(H5F_super_dirty(f) < 0) + if (H5F_super_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__format_convert() */ - /*------------------------------------------------------------------------- * Function: H5F_get_file_id * @@ -3730,39 +3721,40 @@ done: hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref) { - void *vol_obj_file = NULL; /* File object pointer */ - H5VL_loc_params_t loc_params; /* Location parameters */ - hid_t file_id = H5I_INVALID_HID; /* File ID for object */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * vol_obj_file = NULL; /* File object pointer */ + H5VL_loc_params_t loc_params; /* Location parameters */ + hid_t file_id = H5I_INVALID_HID; /* File ID for object */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = obj_type; /* Retrieve VOL file from object */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_FILE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &vol_obj_file) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_FILE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &vol_obj_file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file from object") /* Check if the file's ID already exists */ - if(H5I_find_id(vol_obj_file, H5I_FILE, &file_id) < 0) + if (H5I_find_id(vol_obj_file, H5I_FILE, &file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "getting file ID failed") /* If the ID does not exist, register it with the VOL connector */ - if(H5I_INVALID_HID == file_id) { + if (H5I_INVALID_HID == file_id) { /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL wrapper info") vol_wrapper_set = TRUE; - if((file_id = H5VL_wrap_register(H5I_FILE, vol_obj_file, app_ref)) < 0) + if ((file_id = H5VL_wrap_register(H5I_FILE, vol_obj_file, app_ref)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") } /* end if */ else { /* Increment ref count on existing ID */ - if(H5I_inc_ref(file_id, app_ref) < 0) + if (H5I_inc_ref(file_id, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") } /* end else */ @@ -3771,13 +3763,12 @@ H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref) done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRESET, H5I_INVALID_HID, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_file_id() */ - /*------------------------------------------------------------------------- * Function: H5F_set_min_dset_ohdr * @@ -3801,7 +3792,6 @@ H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_min_dset_ohdr() */ - /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_end_tick() * @@ -3814,7 +3804,7 @@ herr_t H5F__vfd_swmr_end_tick(H5F_t *f) { eot_queue_entry_t *curr; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3823,33 +3813,32 @@ H5F__vfd_swmr_end_tick(H5F_t *f) HDassert(f->shared); /* The file should be opened with VFD SWMR configured.*/ - if(!(H5F_USE_VFD_SWMR(f))) + if (!(H5F_USE_VFD_SWMR(f))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") /* Search EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { + TAILQ_FOREACH(curr, &eot_queue_g, link) + { if (curr->vfd_swmr_file == f) break; } /* If the file does not exist on the EOT queue, flag an error */ - if(curr == NULL) + if (curr == NULL) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has been disabled") if (f->shared->vfd_swmr_writer) { if (H5F_vfd_swmr_writer_end_of_tick(f, true) < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, - "end of tick error for VFD SWMR writer"); - } else if (H5F_vfd_swmr_reader_end_of_tick(f, true) < 0) { - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, - "end of tick error for VFD SWMR reader"); + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR writer"); + } + else if (H5F_vfd_swmr_reader_end_of_tick(f, true) < 0) { + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR reader"); } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__vfd_swmr_end_tick() */ - /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_disable_end_of_tick() * @@ -3862,7 +3851,7 @@ herr_t H5F__vfd_swmr_disable_end_of_tick(H5F_t *f) { eot_queue_entry_t *curr; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3871,28 +3860,28 @@ H5F__vfd_swmr_disable_end_of_tick(H5F_t *f) HDassert(f->shared); /* The file should be opened with VFD SWMR configured.*/ - if(!(H5F_USE_VFD_SWMR(f))) + if (!(H5F_USE_VFD_SWMR(f))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") /* Search EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { + TAILQ_FOREACH(curr, &eot_queue_g, link) + { if (curr->vfd_swmr_file == f) break; } /* If the file does not exist on the EOT queue, flag an error */ - if(curr == NULL) + if (curr == NULL) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has already been disabled") /* Remove the entry that corresponds to "f" from the EOT queue */ - if(H5F_vfd_swmr_remove_entry_eot(f) < 0) + if (H5F_vfd_swmr_remove_entry_eot(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__vfd_swmr_disable_end_of_tick() */ - /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_enable_end_of_tick() * @@ -3905,7 +3894,7 @@ herr_t H5F__vfd_swmr_enable_end_of_tick(H5F_t *f) { eot_queue_entry_t *curr; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3914,25 +3903,26 @@ H5F__vfd_swmr_enable_end_of_tick(H5F_t *f) HDassert(f->shared); /* The file should be opened with VFD SWMR configured.*/ - if(!(H5F_USE_VFD_SWMR(f))) + if (!(H5F_USE_VFD_SWMR(f))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") /* Search EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { + TAILQ_FOREACH(curr, &eot_queue_g, link) + { if (curr->vfd_swmr_file == f) break; } /* If the file already exists on the EOT queue, flag an error */ - if(curr != NULL) + if (curr != NULL) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has already been enabled") /* Insert the entry that corresponds to "f" onto the EOT queue */ - if(H5F_vfd_swmr_insert_entry_eot(f) < 0) + if (H5F_vfd_swmr_insert_entry_eot(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue") /* Check if the tick has expired, if so call end of tick processing */ - if(H5F_vfd_swmr_process_eot_queue(true) < 0) + if (H5F_vfd_swmr_process_eot_queue(true) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "error processing EOT queue") /* FUNC_LEAVE_API could do the check, but not so for reader_end_of_tick() */ diff --git a/src/H5Fio.c b/src/H5Fio.c index 592d5f1..187b63c 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -26,56 +26,46 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5PBprivate.h" /* Page Buffer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5PBprivate.h" /* Page Buffer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F_shared_block_read * @@ -87,9 +77,9 @@ *------------------------------------------------------------------------- */ herr_t -H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) +H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -99,18 +89,17 @@ H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t HDassert(H5F_addr_defined(addr)); /* Check for attempting I/O on 'temporary' file address */ - if(H5F_addr_le(f_sh->tmp_addr, (addr + size))) + if (H5F_addr_le(f_sh->tmp_addr, (addr + size))) HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") /* Pass through page buffer layer */ - if(H5PB_read(f_sh, type, addr, size, buf) < 0) + if (H5PB_read(f_sh, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through page buffer failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_shared_block_read() */ - /*------------------------------------------------------------------------- * Function: H5F_block_read * @@ -122,12 +111,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) +H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { return H5F_shared_block_read(f->shared, type, addr, size, buf); } /* end H5F_block_read() */ - /*------------------------------------------------------------------------- * Function: H5F_shared_block_write * @@ -141,7 +129,7 @@ H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/* herr_t H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -152,18 +140,17 @@ H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t HDassert(H5F_addr_defined(addr)); /* Check for attempting I/O on 'temporary' file address */ - if(H5F_addr_le(f_sh->tmp_addr, (addr + size))) + if (H5F_addr_le(f_sh->tmp_addr, (addr + size))) HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") /* Pass through page buffer layer */ - if(H5PB_write(f_sh, type, addr, size, buf) < 0) + if (H5PB_write(f_sh, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through page buffer failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_shared_block_write() */ - /*------------------------------------------------------------------------- * Function: H5F_block_write * @@ -180,7 +167,6 @@ H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void return H5F_shared_block_write(f->shared, type, addr, size, buf); } /* end H5F_block_write() */ - /*------------------------------------------------------------------------- * Function: H5F_flush_tagged_metadata * @@ -202,22 +188,21 @@ H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag) FUNC_ENTER_NOAPI(FAIL) /* Use tag to search for and flush associated metadata */ - if(H5AC_flush_tagged_metadata(f, tag) < 0) + if (H5AC_flush_tagged_metadata(f, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") /* Flush and reset the accumulator */ - if(H5F__accum_reset(f->shared, TRUE) < 0) + if (H5F__accum_reset(f->shared, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") /* Flush file buffers to disk. */ - if(H5FD_flush(f->shared->lf, FALSE) < 0) + if (H5FD_flush(f->shared->lf, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F_flush_tagged_metadata */ - /*------------------------------------------------------------------------- * Function: H5F_evict_tagged_metadata * @@ -238,14 +223,13 @@ H5F_evict_tagged_metadata(H5F_t *f, haddr_t tag) FUNC_ENTER_NOAPI(FAIL) /* Evict the object's metadata */ - if(H5AC_evict_tagged_metadata(f, tag, TRUE) < 0) + if (H5AC_evict_tagged_metadata(f, tag, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict tagged metadata") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F_evict_tagged_metadata */ - /*------------------------------------------------------------------------- * Function: H5F__evict_cache_entries * @@ -269,37 +253,36 @@ H5F__evict_cache_entries(H5F_t *f) HDassert(f->shared); /* Evict all except pinned entries in the cache */ - if(H5AC_evict(f) < 0) + if (H5AC_evict(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict all except pinned entries") #ifndef NDEBUG -{ - unsigned status = 0; - uint32_t cur_num_entries; - - /* Retrieve status of the superblock */ - if(H5AC_get_entry_status(f, (haddr_t)0, &status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status") - - /* Verify status of the superblock entry in the cache */ - if(!(status & H5AC_ES__IN_CACHE) || !(status & H5AC_ES__IS_PINNED)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status") - - /* Get the number of cache entries */ - if(H5AC_get_cache_size(f->shared->cache, NULL, NULL, NULL, &cur_num_entries) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") - - /* Should be the only one left in the cache (the superblock) */ - if(cur_num_entries != 1) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "number of cache entries is not correct") -} + { + unsigned status = 0; + uint32_t cur_num_entries; + + /* Retrieve status of the superblock */ + if (H5AC_get_entry_status(f, (haddr_t)0, &status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status") + + /* Verify status of the superblock entry in the cache */ + if (!(status & H5AC_ES__IN_CACHE) || !(status & H5AC_ES__IS_PINNED)) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status") + + /* Get the number of cache entries */ + if (H5AC_get_cache_size(f->shared->cache, NULL, NULL, NULL, &cur_num_entries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + + /* Should be the only one left in the cache (the superblock) */ + if (cur_num_entries != 1) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "number of cache entries is not correct") + } #endif /* NDEBUG */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F__evict_cache_entries() */ - /*------------------------------------------------------------------------- * Function: H5F_get_checksums * @@ -316,7 +299,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/, uint32_t *c_chksum/*out*/) +H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum /*out*/, uint32_t *c_chksum /*out*/) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -325,8 +308,8 @@ H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/ HDassert(buf_size); /* Return the stored checksum */ - if(s_chksum) { - const uint8_t *chk_p; /* Pointer into raw data buffer */ + if (s_chksum) { + const uint8_t *chk_p; /* Pointer into raw data buffer */ /* Offset to the checksum in the buffer */ chk_p = buf + buf_size - H5_SIZEOF_CHKSUM; @@ -336,9 +319,8 @@ H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/ } /* end if */ /* Return the computed checksum for the buffer */ - if(c_chksum) - *c_chksum = H5_checksum_metadata(buf, buf_size - H5_SIZEOF_CHKSUM, 0); + if (c_chksum) + *c_chksum = H5_checksum_metadata(buf, buf_size - H5_SIZEOF_CHKSUM, 0); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F_get_chksums() */ - diff --git a/src/H5Fmodule.h b/src/H5Fmodule.h index 0481512..ce892e0 100644 --- a/src/H5Fmodule.h +++ b/src/H5Fmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5F_MODULE -#define H5_MY_PKG H5F -#define H5_MY_PKG_ERR H5E_FILE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5F +#define H5_MY_PKG_ERR H5E_FILE +#define H5_MY_PKG_INIT YES #endif /* _H5Fmodule_H */ - diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 5e6b899..8adf46b 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -11,25 +11,23 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* PRIVATE PROTOTYPES */ static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); - /*------------------------------------------------------------------------- * Function: H5F__close_mounts * @@ -45,8 +43,8 @@ static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsign herr_t H5F__close_mounts(H5F_t *f) { - unsigned u; /* Local index */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -58,21 +56,21 @@ H5F__close_mounts(H5F_t *f) */ for (u = f->shared->mtab.nmounts - 1; u < f->shared->mtab.nmounts; u--) { /* Only unmount children mounted to this top level file structure */ - if(f->shared->mtab.child[u].file->parent == f) { + if (f->shared->mtab.child[u].file->parent == f) { /* Detach the child file from the parent file */ f->shared->mtab.child[u].file->parent = NULL; /* Close the internal group maintaining the mount point */ - if(H5G_close(f->shared->mtab.child[u].group) < 0) + if (H5G_close(f->shared->mtab.child[u].group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close child group") /* Close the child file */ - if(H5F_try_close(f->shared->mtab.child[u].file, NULL) < 0) + if (H5F_try_close(f->shared->mtab.child[u].file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close child file") /* Eliminate the mount point from the table */ HDmemmove(f->shared->mtab.child + u, f->shared->mtab.child + u + 1, - (f->shared->mtab.nmounts - u - 1) * sizeof(f->shared->mtab.child[0])); + (f->shared->mtab.nmounts - u - 1) * sizeof(f->shared->mtab.child[0])); f->shared->mtab.nmounts--; f->nmounts--; } @@ -84,7 +82,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__close_mounts() */ - /*------------------------------------------------------------------------- * Function: H5F__mount * @@ -102,16 +99,16 @@ done: herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED plist_id) { - H5G_t *mount_point = NULL; /*mount point group */ - H5F_t *ancestor = NULL; /*ancestor files */ - H5F_t *parent = NULL; /*file containing mount point */ - unsigned lt, rt, md; /*binary search indices */ - int cmp; /*binary search comparison value*/ - H5G_loc_t mp_loc; /* entry of moint point to be opened */ - H5G_name_t mp_path; /* Mount point group hier. path */ - H5O_loc_t mp_oloc; /* Mount point object location */ - H5G_loc_t root_loc; /* Group location of root of file to mount */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_t * mount_point = NULL; /*mount point group */ + H5F_t * ancestor = NULL; /*ancestor files */ + H5F_t * parent = NULL; /*file containing mount point */ + unsigned lt, rt, md; /*binary search indices */ + int cmp; /*binary search comparison value*/ + H5G_loc_t mp_loc; /* entry of moint point to be opened */ + H5G_name_t mp_path; /* Mount point group hier. path */ + H5O_loc_t mp_oloc; /* Mount point object location */ + H5G_loc_t root_loc; /* Group location of root of file to mount */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -131,24 +128,24 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED * the parent & child files have the same file close degree, and * that the mount wouldn't introduce a cycle in the mount tree. */ - if(child->parent) + if (child->parent) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted") - if(H5G_loc_find(loc, name, &mp_loc) < 0) + if (H5G_loc_find(loc, name, &mp_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") /* If the mount location is holding its file open, that file will close * and remove the mount as soon as we exit this function. Prevent the * user from doing this. */ - if(mp_loc.oloc->holding_file != FALSE) + if (mp_loc.oloc->holding_file != FALSE) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount path cannot contain links to external files") /* Open the mount point group */ - if(NULL == (mount_point = H5G_open(&mp_loc))) + if (NULL == (mount_point = H5G_open(&mp_loc))) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") /* Check if the proposed mount point group is already a mount point */ - if(H5G_MOUNTED(mount_point)) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") + if (H5G_MOUNTED(mount_point)) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Retrieve information from the mount point group */ /* (Some of which we had before but was reset in mp_loc when the group @@ -160,13 +157,13 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED HDassert(mp_loc.oloc); mp_loc.path = H5G_nameof(mount_point); HDassert(mp_loc.path); - for(ancestor = parent; ancestor; ancestor = ancestor->parent) { - if(ancestor->shared == child->shared) + for (ancestor = parent; ancestor; ancestor = ancestor->parent) { + if (ancestor->shared == child->shared) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") } /* Make certain that the parent & child files have the same "file close degree" */ - if(parent->shared->fc_degree != child->shared->fc_degree) + if (parent->shared->fc_degree != child->shared->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mounted file has different file close degree than parent") /* @@ -175,68 +172,69 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED * `md' will be the index where the child should be inserted. */ lt = md = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - H5O_loc_t *oloc; /*temporary symbol table entry */ + rt = parent->shared->mtab.nmounts; + cmp = -1; + while (lt < rt && cmp) { + H5O_loc_t *oloc; /*temporary symbol table entry */ - md = (lt + rt) / 2; + md = (lt + rt) / 2; oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); - if(cmp < 0) + cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); + if (cmp < 0) rt = md; - else if(cmp > 0) + else if (cmp > 0) lt = md + 1; } - if(cmp > 0) + if (cmp > 0) md++; - if(!cmp) + if (!cmp) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ - if(parent->shared->mtab.nmounts >= parent->shared->mtab.nalloc) { - unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); - H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0])); + if (parent->shared->mtab.nmounts >= parent->shared->mtab.nalloc) { + unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); + H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, + n * sizeof(parent->shared->mtab.child[0])); - if(!x) + if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") - parent->shared->mtab.child = x; + parent->shared->mtab.child = x; parent->shared->mtab.nalloc = n; } /* Insert into table */ HDmemmove(parent->shared->mtab.child + md + 1, parent->shared->mtab.child + md, - (parent->shared->mtab.nmounts-md) * sizeof(parent->shared->mtab.child[0])); + (parent->shared->mtab.nmounts - md) * sizeof(parent->shared->mtab.child[0])); parent->shared->mtab.nmounts++; parent->nmounts++; parent->shared->mtab.child[md].group = mount_point; - parent->shared->mtab.child[md].file = child; - child->parent = parent; + parent->shared->mtab.child[md].file = child; + child->parent = parent; /* Set the group's mountpoint flag */ - if(H5G_mount(parent->shared->mtab.child[md].group) < 0) + if (H5G_mount(parent->shared->mtab.child[md].group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to set group mounted flag") /* Get the group location for the root group in the file to unmount */ - if(NULL == (root_loc.oloc = H5G_oloc(child->shared->root_grp))) + if (NULL == (root_loc.oloc = H5G_oloc(child->shared->root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (root_loc.path = H5G_nameof(child->shared->root_grp))) + if (NULL == (root_loc.path = H5G_nameof(child->shared->root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Search the open IDs and replace names for mount operation */ /* We pass H5G_UNKNOWN as object type; search all IDs */ - if(H5G_name_replace(NULL, H5G_NAME_MOUNT, mp_loc.oloc->file, - mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r) < 0) + if (H5G_name_replace(NULL, H5G_NAME_MOUNT, mp_loc.oloc->file, mp_loc.path->full_path_r, + root_loc.oloc->file, root_loc.path->full_path_r) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") done: - if(ret_value < 0) { - if(mount_point) { - if(H5G_close(mount_point) < 0) + if (ret_value < 0) { + if (mount_point) { + if (H5G_close(mount_point) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group") } else { - if(H5G_loc_free(&mp_loc) < 0) + if (H5G_loc_free(&mp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location") } } @@ -244,7 +242,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__mount() */ - /*------------------------------------------------------------------------- * Function: H5F__unmount * @@ -266,17 +263,17 @@ done: herr_t H5F__unmount(H5G_loc_t *loc, const char *name) { - H5G_t *child_group = NULL; /* Child's group in parent mtab */ - H5F_t *child = NULL; /*mounted file */ - H5F_t *parent = NULL; /*file where mounted */ - H5O_loc_t *mnt_oloc; /* symbol table entry for root of mounted file */ - H5G_name_t mp_path; /* Mount point group hier. path */ - H5O_loc_t mp_oloc; /* Mount point object location */ - H5G_loc_t mp_loc; /* entry used to open mount point*/ - hbool_t mp_loc_setup = FALSE; /* Whether mount point location is set up */ - H5G_loc_t root_loc; /* Group location of root of file to unmount */ - int child_idx; /* Index of child in parent's mtab */ - herr_t ret_value = SUCCEED; /*return value */ + H5G_t * child_group = NULL; /* Child's group in parent mtab */ + H5F_t * child = NULL; /*mounted file */ + H5F_t * parent = NULL; /*file where mounted */ + H5O_loc_t *mnt_oloc; /* symbol table entry for root of mounted file */ + H5G_name_t mp_path; /* Mount point group hier. path */ + H5O_loc_t mp_oloc; /* Mount point object location */ + H5G_loc_t mp_loc; /* entry used to open mount point*/ + hbool_t mp_loc_setup = FALSE; /* Whether mount point location is set up */ + H5G_loc_t root_loc; /* Group location of root of file to unmount */ + int child_idx; /* Index of child in parent's mtab */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_PACKAGE @@ -293,23 +290,23 @@ H5F__unmount(H5G_loc_t *loc, const char *name) * If we get the root group and the file has a parent in the mount tree, * then we must have found the mount point. */ - if(H5G_loc_find(loc, name, &mp_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &mp_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") mp_loc_setup = TRUE; - child = mp_loc.oloc->file; - mnt_oloc = H5G_oloc(child->shared->root_grp); - child_idx = -1; + child = mp_loc.oloc->file; + mnt_oloc = H5G_oloc(child->shared->root_grp); + child_idx = -1; - if(child->parent && H5F_addr_eq(mp_oloc.addr, mnt_oloc->addr)) { - unsigned u; /*counters */ + if (child->parent && H5F_addr_eq(mp_oloc.addr, mnt_oloc->addr)) { + unsigned u; /*counters */ /* * We've been given the root group of the child. We do a reverse * lookup in the parent's mount table to find the correct entry. */ parent = child->parent; - for(u = 0; u < parent->shared->mtab.nmounts; u++) { - if(parent->shared->mtab.child[u].file->shared == child->shared) { + for (u = 0; u < parent->shared->mtab.nmounts; u++) { + if (parent->shared->mtab.child[u].file->shared == child->shared) { /* Found the correct index */ child_idx = (int)u; break; @@ -317,37 +314,37 @@ H5F__unmount(H5G_loc_t *loc, const char *name) } } else { - unsigned lt, rt, md = 0; /*binary search indices */ - int cmp; /*binary search comparison value*/ + unsigned lt, rt, md = 0; /*binary search indices */ + int cmp; /*binary search comparison value*/ /* We've been given the mount point in the parent. We use a binary * search in the parent to locate the mounted file, if any. */ parent = child; /*we guessed wrong*/ - lt = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; + lt = 0; + rt = parent->shared->mtab.nmounts; + cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; + while (lt < rt && cmp) { + md = (lt + rt) / 2; mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); - if (cmp<0) + cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); + if (cmp < 0) rt = md; else lt = md + 1; } - if(cmp) + if (cmp) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Found the correct index, set the info about the child */ child_idx = (int)md; H5G_loc_free(&mp_loc); mp_loc_setup = FALSE; - mp_loc.oloc = mnt_oloc; - mp_loc.path = H5G_nameof(parent->shared->mtab.child[md].group); - child = parent->shared->mtab.child[child_idx].file; + mp_loc.oloc = mnt_oloc; + mp_loc.path = H5G_nameof(parent->shared->mtab.child[md].group); + child = parent->shared->mtab.child[child_idx].file; /* Set the parent to be the actual parent of the discovered child. * Could be different due to the shared mount table. */ @@ -359,42 +356,43 @@ H5F__unmount(H5G_loc_t *loc, const char *name) child_group = parent->shared->mtab.child[child_idx].group; /* Get the group location for the root group in the file to unmount */ - if(NULL == (root_loc.oloc = H5G_oloc(child->shared->root_grp))) + if (NULL == (root_loc.oloc = H5G_oloc(child->shared->root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (root_loc.path = H5G_nameof(child->shared->root_grp))) + if (NULL == (root_loc.path = H5G_nameof(child->shared->root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Search the open IDs replace names to reflect unmount operation */ - if(H5G_name_replace(NULL, H5G_NAME_UNMOUNT, mp_loc.oloc->file, - mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r) < 0) + if (H5G_name_replace(NULL, H5G_NAME_UNMOUNT, mp_loc.oloc->file, mp_loc.path->full_path_r, + root_loc.oloc->file, root_loc.path->full_path_r) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ - HDmemmove(parent->shared->mtab.child + (unsigned)child_idx, (parent->shared->mtab.child + (unsigned)child_idx) + 1, - ((parent->shared->mtab.nmounts - (unsigned)child_idx) - 1) * sizeof(parent->shared->mtab.child[0])); + HDmemmove(parent->shared->mtab.child + (unsigned)child_idx, + (parent->shared->mtab.child + (unsigned)child_idx) + 1, + ((parent->shared->mtab.nmounts - (unsigned)child_idx) - 1) * + sizeof(parent->shared->mtab.child[0])); parent->shared->mtab.nmounts -= 1; parent->nmounts -= 1; /* Unmount the child file from the parent file */ - if(H5G_unmount(child_group) < 0) + if (H5G_unmount(child_group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to reset group mounted flag") - if(H5G_close(child_group) < 0) + if (H5G_close(child_group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close unmounted group") /* Detach child file from parent & see if it should close */ child->parent = NULL; - if(H5F_try_close(child, NULL) < 0) + if (H5F_try_close(child, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted file") done: /* Free the mount point location's information, if it's been set up */ - if(mp_loc_setup) + if (mp_loc_setup) H5G_loc_free(&mp_loc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__unmount() */ - /*------------------------------------------------------------------------- * Function: H5F_is_mount * @@ -411,13 +409,13 @@ done: hbool_t H5F_is_mount(const H5F_t *file) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(file); - if(file->parent != NULL) + if (file->parent != NULL) ret_value = TRUE; else ret_value = FALSE; @@ -425,7 +423,6 @@ H5F_is_mount(const H5F_t *file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_is_mount() */ - /*------------------------------------------------------------------------- * Function: H5Fmount * @@ -439,57 +436,56 @@ H5F_is_mount(const H5F_t *file) herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5VL_object_t *loc_vol_obj = NULL; /* Parent object */ - H5VL_object_t *child_vol_obj = NULL; /* Child object */ - H5I_type_t loc_type; /* ID type of location */ - H5I_type_t child_type; /* ID type of child */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *loc_vol_obj = NULL; /* Parent object */ + H5VL_object_t *child_vol_obj = NULL; /* Child object */ + H5I_type_t loc_type; /* ID type of location */ + H5I_type_t child_type; /* ID type of child */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); /* Check arguments */ loc_type = H5I_get_type(loc_id); - if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + if (H5I_FILE != loc_type && H5I_GROUP != loc_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") child_type = H5I_get_type(child_id); - if(H5I_FILE != child_type) + if (H5I_FILE != child_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") - if(H5P_DEFAULT == plist_id) + if (H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; - else - if(TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a file mount property list ID") + else if (TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a file mount property list ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Get the location object */ - if(NULL == (loc_vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (loc_vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") /* Get the child object */ - if(NULL == (child_vol_obj = (H5VL_object_t *)H5I_object(child_id))) + if (NULL == (child_vol_obj = (H5VL_object_t *)H5I_object(child_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") /* Check if both objects are associated with the same VOL connector */ - if(loc_vol_obj->connector->cls->value != child_vol_obj->connector->cls->value) + if (loc_vol_obj->connector->cls->value != child_vol_obj->connector->cls->value) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL connector") /* Perform the mount operation */ - if(H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)loc_type, name, child_vol_obj->data, plist_id) < 0) + if (H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)loc_type, name, child_vol_obj->data, plist_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: FUNC_LEAVE_API(ret_value) } /* end H5Fmount() */ - /*------------------------------------------------------------------------- * Function: H5Funmount * @@ -509,39 +505,39 @@ done: herr_t H5Funmount(hid_t loc_id, const char *name) { - H5VL_object_t *vol_obj = NULL; /* Parent object */ - H5I_type_t loc_type; /* ID type of location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Parent object */ + H5I_type_t loc_type; /* ID type of location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check arguments */ loc_type = H5I_get_type(loc_id); - if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + if (H5I_FILE != loc_type && H5I_GROUP != loc_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") /* Perform the unmount operation */ - if(H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)loc_type, name) < 0) + if (H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)loc_type, name) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: FUNC_LEAVE_API(ret_value) } /* end H5Funmount() */ - /*------------------------------------------------------------------------- * Function: H5F__mount_count_ids_recurse * @@ -558,7 +554,7 @@ done: static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { - unsigned u; /* Local index value */ + unsigned u; /* Local index value */ FUNC_ENTER_STATIC_NOERR @@ -568,7 +564,7 @@ H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_ob HDassert(nopen_objs); /* If this file is still open, increment number of file IDs open */ - if(H5F_ID_EXISTS(f)) + if (H5F_ID_EXISTS(f)) *nopen_files += 1; /* Increment number of open objects in file @@ -578,11 +574,11 @@ H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_ob *nopen_objs += (f->nopen_objs - f->nmounts); /* Iterate over files mounted in this file and add in their open ID counts also */ - for(u = 0; u < f->shared->mtab.nmounts; u++) { + for (u = 0; u < f->shared->mtab.nmounts; u++) { /* Only recurse on children mounted to this top level file structure */ - if(f->shared->mtab.child[u].file->parent == f) { + if (f->shared->mtab.child[u].file->parent == f) { /* Increment the open object count if the mount point group has an open ID */ - if(H5G_get_shared_count(f->shared->mtab.child[u].group) > 1) + if (H5G_get_shared_count(f->shared->mtab.child[u].group) > 1) *nopen_objs += 1; H5F__mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs); @@ -592,7 +588,6 @@ H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_ob FUNC_LEAVE_NOAPI_VOID } /* end H5F__mount_count_ids_recurse() */ - /*------------------------------------------------------------------------- * Function: H5F__mount_count_ids * @@ -616,7 +611,7 @@ H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) HDassert(nopen_objs); /* Find the top file in the mounting hierarchy */ - while(f->parent) + while (f->parent) f = f->parent; /* Count open IDs in the hierarchy */ @@ -625,7 +620,6 @@ H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__mount_count_ids() */ - /*------------------------------------------------------------------------- * Function: H5F_flush_mounts_recurse * @@ -641,9 +635,9 @@ H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) static herr_t H5F_flush_mounts_recurse(H5F_t *f) { - unsigned nerrors = 0; /* Errors from recursive flushes */ - unsigned u; /* Index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nerrors = 0; /* Errors from recursive flushes */ + unsigned u; /* Index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -651,23 +645,22 @@ H5F_flush_mounts_recurse(H5F_t *f) HDassert(f); /* Flush all child files, not stopping for errors */ - for(u = 0; u < f->shared->mtab.nmounts; u++) - if(H5F_flush_mounts_recurse(f->shared->mtab.child[u].file) < 0) + for (u = 0; u < f->shared->mtab.nmounts; u++) + if (H5F_flush_mounts_recurse(f->shared->mtab.child[u].file) < 0) nerrors++; /* Call the "real" flush routine, for this file */ - if(H5F__flush(f) < 0) + if (H5F__flush(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Check flush errors for children - errors are already on the stack */ - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's child mounts") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_flush_mounts_recurse() */ - /*------------------------------------------------------------------------- * Function: H5F_flush_mounts * @@ -683,7 +676,7 @@ done: herr_t H5F_flush_mounts(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -691,18 +684,17 @@ H5F_flush_mounts(H5F_t *f) HDassert(f); /* Find the top file in the mount hierarchy */ - while(f->parent) + while (f->parent) f = f->parent; /* Flush the mounted file hierarchy */ - if(H5F_flush_mounts_recurse(f) < 0) + if (H5F_flush_mounts_recurse(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_flush_mounts() */ - /*------------------------------------------------------------------------- * Function: H5F_traverse_mount * @@ -717,14 +709,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) +H5F_traverse_mount(H5O_loc_t *oloc /*in,out*/) { - H5F_t *parent = oloc->file, /* File of object */ - *child = NULL; /* Child file */ - unsigned lt, rt, md = 0; /* Binary search indices */ - int cmp; - H5O_loc_t *mnt_oloc = NULL; /* Object location for mount points */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *parent = oloc->file, /* File of object */ + *child = NULL; /* Child file */ + unsigned lt, rt, md = 0; /* Binary search indices */ + int cmp; + H5O_loc_t *mnt_oloc = NULL; /* Object location for mount points */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -740,21 +732,21 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) * Use a binary search to find the potential mount point in the mount * table for the parent */ - lt = 0; - rt = parent->shared->mtab.nmounts; + lt = 0; + rt = parent->shared->mtab.nmounts; cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; + while (lt < rt && cmp) { + md = (lt + rt) / 2; mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); - if(cmp < 0) + cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); + if (cmp < 0) rt = md; else lt = md + 1; } /* Copy root info over to ENT */ - if(0 == cmp) { + if (0 == cmp) { /* Get the child file */ child = parent->shared->mtab.child[md].file; @@ -762,11 +754,11 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) mnt_oloc = H5G_oloc(child->shared->root_grp); /* Release the mount point */ - if(H5O_loc_free(oloc) < 0) + if (H5O_loc_free(oloc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to free object location") /* Copy the entry for the root group */ - if(H5O_loc_copy_deep(oloc, mnt_oloc) < 0) + if (H5O_loc_copy_deep(oloc, mnt_oloc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy object location") /* In case the shared root group info points to a different file handle @@ -776,9 +768,8 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) /* Switch to child's file */ parent = child; } /* end if */ - } while(!cmp); + } while (!cmp); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_traverse_mount() */ - diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 0c46f59..0871ce7 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -26,56 +26,47 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- @@ -92,7 +83,7 @@ herr_t H5F_get_mpi_handle(const H5F_t *f, MPI_File **f_handle) { herr_t ret_value = SUCCEED; - hid_t fapl_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; FUNC_ENTER_NOAPI(FAIL) @@ -106,7 +97,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_mpi_handle() */ - /*------------------------------------------------------------------------- * Function: H5F_mpi_get_rank * @@ -138,7 +128,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_get_rank() */ - /*------------------------------------------------------------------------- * Function: H5F_mpi_get_comm * @@ -156,7 +145,7 @@ done: MPI_Comm H5F_mpi_get_comm(const H5F_t *f) { - MPI_Comm ret_value = MPI_COMM_NULL; + MPI_Comm ret_value = MPI_COMM_NULL; FUNC_ENTER_NOAPI(MPI_COMM_NULL) @@ -170,7 +159,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_get_comm() */ - /*------------------------------------------------------------------------- * Function: H5F_shared_mpi_get_size * @@ -195,14 +183,13 @@ H5F_shared_mpi_get_size(const H5F_shared_t *f_sh) HDassert(f_sh); /* Dispatch to driver */ - if((ret_value = H5FD_mpi_get_size(f_sh->lf)) < 0) + if ((ret_value = H5FD_mpi_get_size(f_sh->lf)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "driver get_size request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_shared_mpi_get_size() */ - /*------------------------------------------------------------------------- * Function: H5F_mpi_get_size * @@ -234,7 +221,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_get_size() */ - /*------------------------------------------------------------------------- * Function: H5F_set_mpi_atomicity * @@ -247,7 +233,7 @@ done: herr_t H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL); @@ -256,7 +242,8 @@ H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag) /* Check VFD */ if (!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode"); + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect VFL driver, does not support MPI atomicity mode"); /* Set atomicity value */ if (H5FD_set_mpio_atomicity(file->shared->lf, flag) < 0) @@ -266,7 +253,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F_set_mpi_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5Fset_mpi_atomicity * @@ -283,26 +269,26 @@ done: herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) { - H5VL_object_t *vol_obj = NULL; - int va_flag = (int)flag; /* C is grumpy about passing hbool_t via va_arg */ - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + int va_flag = (int)flag; /* C is grumpy about passing hbool_t via va_arg */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL); H5TRACE2("e", "ib", file_id, flag); /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); /* Set atomicity value */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MPI_ATOMICITY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, va_flag) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MPI_ATOMICITY, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, va_flag) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set MPI atomicity"); done: FUNC_LEAVE_API(ret_value); } /* end H5Fset_mpi_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5F_get_mpi_atomicity * @@ -315,7 +301,7 @@ done: herr_t H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL); @@ -325,7 +311,8 @@ H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag) /* Check VFD */ if (!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode"); + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect VFL driver, does not support MPI atomicity mode"); /* Get atomicity value */ if (H5FD_get_mpio_atomicity(file->shared->lf, flag) < 0) @@ -335,7 +322,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F_get_mpi_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mpi_atomicity * @@ -352,25 +338,25 @@ done: herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL); H5TRACE2("e", "i*b", file_id, flag); /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); /* Get atomicity value */ - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MPI_ATOMICITY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, flag) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MPI_ATOMICITY, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, flag) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MPI atomicity"); done: FUNC_LEAVE_API(ret_value); } /* end H5Fget_mpi_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5F_mpi_retrieve_comm * @@ -390,7 +376,7 @@ done: herr_t H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -402,32 +388,32 @@ H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm) /* if the loc_id is valid, then get the comm from the file attached to the loc_id */ - if(H5I_INVALID_HID != loc_id) { + if (H5I_INVALID_HID != loc_id) { H5G_loc_t loc; - H5F_t *f = NULL; + H5F_t * f = NULL; /* Retrieve the file structure */ - if(H5G_loc(loc_id, &loc) < 0) + if (H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") f = loc.oloc->file; HDassert(f); /* Check if MPIO driver is used */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { /* retrieve the file communicator */ - if(MPI_COMM_NULL == (*mpi_comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (*mpi_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") } } /* otherwise, this is from H5Fopen or H5Fcreate and has to be collective */ else { - H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ - if(NULL == (plist = H5P_object_verify(acspl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(acspl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_MPIO == H5P_peek_driver(plist)) - if(H5P_peek(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, mpi_comm) < 0) + if (H5FD_MPIO == H5P_peek_driver(plist)) + if (H5P_peek(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, mpi_comm) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") } @@ -435,7 +421,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_retrieve_comm */ - /*------------------------------------------------------------------------- * Function: H5F_get_mpi_info * @@ -463,4 +448,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_mpi_info() */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 260a25c..9f9a702 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -30,55 +30,53 @@ #include "H5Fprivate.h" /* Other private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FDprivate.h" /* VFD -- for VFD SWMR */ -#include "H5Bprivate.h" /* B-trees */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5FSprivate.h" /* File free space */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object header messages */ -#include "H5PBprivate.h" /* Page buffer */ -#include "H5UCprivate.h" /* Reference counted object functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FDprivate.h" /* VFD -- for VFD SWMR */ +#include "H5Bprivate.h" /* B-trees */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5FSprivate.h" /* File free space */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object header messages */ +#include "H5PBprivate.h" /* Page buffer */ +#include "H5UCprivate.h" /* Reference counted object functions */ /* * Feature: Define this constant on the compiler command-line if you want to * see some debugging messages on the debug stream. */ #ifdef NDEBUG -# undef H5F_DEBUG +#undef H5F_DEBUG #endif /* Superblock status flags */ -#define H5F_SUPER_WRITE_ACCESS 0x01 -#define H5F_SUPER_FILE_OK 0x02 -#define H5F_SUPER_SWMR_WRITE_ACCESS 0x04 -#define H5F_SUPER_ALL_FLAGS (H5F_SUPER_WRITE_ACCESS | H5F_SUPER_FILE_OK | H5F_SUPER_SWMR_WRITE_ACCESS) +#define H5F_SUPER_WRITE_ACCESS 0x01 +#define H5F_SUPER_FILE_OK 0x02 +#define H5F_SUPER_SWMR_WRITE_ACCESS 0x04 +#define H5F_SUPER_ALL_FLAGS (H5F_SUPER_WRITE_ACCESS | H5F_SUPER_FILE_OK | H5F_SUPER_SWMR_WRITE_ACCESS) /* Mask for removing private file access flags */ -#define H5F_ACC_PUBLIC_FLAGS 0x007fu +#define H5F_ACC_PUBLIC_FLAGS 0x007fu /* Free space section+aggregator merge flags */ -#define H5F_FS_MERGE_METADATA 0x01 /* Section can merge with metadata aggregator */ -#define H5F_FS_MERGE_RAWDATA 0x02 /* Section can merge with small 'raw' data aggregator */ +#define H5F_FS_MERGE_METADATA 0x01 /* Section can merge with metadata aggregator */ +#define H5F_FS_MERGE_RAWDATA 0x02 /* Section can merge with small 'raw' data aggregator */ /* Macro to abstract checking whether file is using a free space manager */ -#define H5F_HAVE_FREE_SPACE_MANAGER(F) \ - ((F)->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || \ +#define H5F_HAVE_FREE_SPACE_MANAGER(F) \ + ((F)->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || \ (F)->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) /* Macros for encoding/decoding superblock */ -#define H5F_MAX_DRVINFOBLOCK_SIZE 1024 /* Maximum size of superblock driver info buffer */ -#define H5F_DRVINFOBLOCK_HDR_SIZE 16 /* Size of superblock driver info header */ +#define H5F_MAX_DRVINFOBLOCK_SIZE 1024 /* Maximum size of superblock driver info buffer */ +#define H5F_DRVINFOBLOCK_HDR_SIZE 16 /* Size of superblock driver info header */ /* Superblock sizes for various versions */ -#define H5F_SIZEOF_CHKSUM 4 /* Checksum size in the file */ +#define H5F_SIZEOF_CHKSUM 4 /* Checksum size in the file */ /* Fixed-size portion at the beginning of all superblocks */ -#define H5F_SUPERBLOCK_FIXED_SIZE ( H5F_SIGNATURE_LEN \ - + 1) /* superblock version */ +#define H5F_SUPERBLOCK_FIXED_SIZE (H5F_SIGNATURE_LEN + 1) /* superblock version */ /* The H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE is the minimal amount of super block * variable length data guarnateed to load the sizeof offsets and the sizeof @@ -93,65 +91,67 @@ * of the super block. Note that the current value is one byte larger * than it needs to be. */ -#define H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE 7 +#define H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE 7 /* Macros for computing variable-size superblock size */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_COMMON \ - (2 /* freespace, and root group versions */ \ - + 1 /* reserved */ \ - + 3 /* shared header vers, size of address, size of lengths */ \ - + 1 /* reserved */ \ - + 4 /* group leaf k, group internal k */ \ - + 4) /* consistency flags */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V0(sizeof_addr, sizeof_size) \ - ( H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ - + (sizeof_addr) /* base address */ \ - + (sizeof_addr) /* */ \ - + (sizeof_addr) /* EOF address */ \ - + (sizeof_addr) /* driver block address */ \ - + H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)) /* root group ptr */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V1(sizeof_addr, sizeof_size) \ - ( H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ - + 2 /* indexed B-tree internal k */ \ - + 2 /* reserved */ \ - + (sizeof_addr) /* base address */ \ - + (sizeof_addr) /* */ \ - + (sizeof_addr) /* EOF address */ \ - + (sizeof_addr) /* driver block address */ \ - + H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)) /* root group ptr */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V2(sizeof_addr) \ - ( 2 /* size of address, size of lengths */ \ - + 1 /* consistency flags */ \ - + (sizeof_addr) /* base address */ \ - + (sizeof_addr) /* superblock extension address */ \ - + (sizeof_addr) /* EOF address */ \ - + (sizeof_addr) /* root group object header address */ \ - + H5F_SIZEOF_CHKSUM) /* superblock checksum (keep this last) */ -#define H5F_SUPERBLOCK_VARLEN_SIZE(v, sizeof_addr, sizeof_size) ( \ - (v == 0 ? H5F_SUPERBLOCK_VARLEN_SIZE_V0(sizeof_addr, sizeof_size) : 0) \ - + (v == 1 ? H5F_SUPERBLOCK_VARLEN_SIZE_V1(sizeof_addr, sizeof_size) : 0) \ - + (v >= 2 ? H5F_SUPERBLOCK_VARLEN_SIZE_V2(sizeof_addr) : 0)) +#define H5F_SUPERBLOCK_VARLEN_SIZE_COMMON \ + (2 /* freespace, and root group versions */ \ + + 1 /* reserved */ \ + + 3 /* shared header vers, size of address, size of lengths */ \ + + 1 /* reserved */ \ + + 4 /* group leaf k, group internal k */ \ + + 4) /* consistency flags */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V0(sizeof_addr, sizeof_size) \ + (H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ + + (sizeof_addr) /* base address */ \ + + (sizeof_addr) /* */ \ + + (sizeof_addr) /* EOF address */ \ + + (sizeof_addr) /* driver block address */ \ + + H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)) /* root group ptr */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V1(sizeof_addr, sizeof_size) \ + (H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ + + 2 /* indexed B-tree internal k */ \ + + 2 /* reserved */ \ + + (sizeof_addr) /* base address */ \ + + (sizeof_addr) /* */ \ + + (sizeof_addr) /* EOF address */ \ + + (sizeof_addr) /* driver block address */ \ + + H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)) /* root group ptr */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V2(sizeof_addr) \ + (2 /* size of address, size of lengths */ \ + + 1 /* consistency flags */ \ + + (sizeof_addr) /* base address */ \ + + (sizeof_addr) /* superblock extension address */ \ + + (sizeof_addr) /* EOF address */ \ + + (sizeof_addr) /* root group object header address */ \ + + H5F_SIZEOF_CHKSUM) /* superblock checksum (keep this last) */ +#define H5F_SUPERBLOCK_VARLEN_SIZE(v, sizeof_addr, sizeof_size) \ + ((v == 0 ? H5F_SUPERBLOCK_VARLEN_SIZE_V0(sizeof_addr, sizeof_size) : 0) + \ + (v == 1 ? H5F_SUPERBLOCK_VARLEN_SIZE_V1(sizeof_addr, sizeof_size) : 0) + \ + (v >= 2 ? H5F_SUPERBLOCK_VARLEN_SIZE_V2(sizeof_addr) : 0)) /* Total size of superblock, depends on superblock version */ -#define H5F_SUPERBLOCK_SIZE(s) ( H5F_SUPERBLOCK_FIXED_SIZE \ - + H5F_SUPERBLOCK_VARLEN_SIZE((s)->super_vers, (s)->sizeof_addr, (s)->sizeof_size)) +#define H5F_SUPERBLOCK_SIZE(s) \ + (H5F_SUPERBLOCK_FIXED_SIZE + \ + H5F_SUPERBLOCK_VARLEN_SIZE((s)->super_vers, (s)->sizeof_addr, (s)->sizeof_size)) /* For superblock version 0 & 1: - Offset to the file consistency flags (status_flags) in the superblock (excluding H5F_SUPERBLOCK_FIXED_SIZE) */ -#define H5F_SUPER_STATUS_OFF_V01 \ - (unsigned)(2 /* freespace, and root group versions */ \ - + 1 /* reserved */ \ - + 3 /* shared header vers, size of address, size of lengths */ \ - + 1 /* reserved */ \ - + 4) /* group leaf k, group internal k */ + Offset to the file consistency flags (status_flags) in the superblock (excluding H5F_SUPERBLOCK_FIXED_SIZE) + */ +#define H5F_SUPER_STATUS_OFF_V01 \ + (unsigned)(2 /* freespace, and root group versions */ \ + + 1 /* reserved */ \ + + 3 /* shared header vers, size of address, size of lengths */ \ + + 1 /* reserved */ \ + + 4) /* group leaf k, group internal k */ -#define H5F_SUPER_STATUS_OFF(v) (v >= 2 ? (unsigned)2 : H5F_SUPER_STATUS_OFF_V01) +#define H5F_SUPER_STATUS_OFF(v) (v >= 2 ? (unsigned)2 : H5F_SUPER_STATUS_OFF_V01) /* Offset to the file consistency flags (status_flags) in the superblock */ #define H5F_SUPER_STATUS_FLAGS_OFF(v) (H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPER_STATUS_OFF(v)) /* Size of file consistency flags (status_flags) in the superblock */ -#define H5F_SUPER_STATUS_FLAGS_SIZE(v) (v >= 2 ? 1 : 4) +#define H5F_SUPER_STATUS_FLAGS_SIZE(v) (v >= 2 ? 1 : 4) /* Forward declaration external file cache struct used below (defined in * H5Fefc.c) */ @@ -159,49 +159,49 @@ typedef struct H5F_efc_t H5F_efc_t; /* Structure for passing 'user data' to superblock cache callbacks */ typedef struct H5F_superblock_cache_ud_t { -/* IN: */ - H5F_t *f; /* Pointer to file */ - hbool_t ignore_drvrinfo; /* Indicate if the driver info should be ignored */ -/* OUT: */ - unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ + /* IN: */ + H5F_t * f; /* Pointer to file */ + hbool_t ignore_drvrinfo; /* Indicate if the driver info should be ignored */ + /* OUT: */ + unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ - haddr_t stored_eof; /* End-of-file in file */ - hbool_t drvrinfo_removed; /* Indicate if the driver info was removed */ - unsigned super_vers; /* Superblock version obtained in get_load_size callback. - * It will be used later in verify_chksum callback - */ + haddr_t stored_eof; /* End-of-file in file */ + hbool_t drvrinfo_removed; /* Indicate if the driver info was removed */ + unsigned super_vers; /* Superblock version obtained in get_load_size callback. + * It will be used later in verify_chksum callback + */ } H5F_superblock_cache_ud_t; /* Structure for passing 'user data' to driver info block cache callbacks */ typedef struct H5F_drvrinfo_cache_ud_t { - H5F_t *f; /* Pointer to file */ - haddr_t driver_addr; /* address of driver info block */ + H5F_t * f; /* Pointer to file */ + haddr_t driver_addr; /* address of driver info block */ } H5F_drvrinfo_cache_ud_t; /* Structure for metadata & "small [raw] data" block aggregation fields */ struct H5F_blk_aggr_t { - unsigned long feature_flag; /* Feature flag type */ - hsize_t alloc_size; /* Size for allocating new blocks */ - hsize_t tot_size; /* Total amount of bytes aggregated into block */ - hsize_t size; /* Current size of block left */ - haddr_t addr; /* Location of block left */ + unsigned long feature_flag; /* Feature flag type */ + hsize_t alloc_size; /* Size for allocating new blocks */ + hsize_t tot_size; /* Total amount of bytes aggregated into block */ + hsize_t size; /* Current size of block left */ + haddr_t addr; /* Location of block left */ }; /* Structure for metadata accumulator fields */ typedef struct H5F_meta_accum_t { - unsigned char *buf; /* Buffer to hold the accumulated metadata */ - haddr_t loc; /* File location (offset) of the accumulated metadata */ - size_t size; /* Size of the accumulated metadata buffer used (in bytes) */ - size_t alloc_size; /* Size of the accumulated metadata buffer allocated (in bytes) */ - size_t dirty_off; /* Offset of the dirty region in the accumulator buffer */ - size_t dirty_len; /* Length of the dirty region in the accumulator buffer */ - hbool_t dirty; /* Flag to indicate that the accumulated metadata is dirty */ + unsigned char *buf; /* Buffer to hold the accumulated metadata */ + haddr_t loc; /* File location (offset) of the accumulated metadata */ + size_t size; /* Size of the accumulated metadata buffer used (in bytes) */ + size_t alloc_size; /* Size of the accumulated metadata buffer allocated (in bytes) */ + size_t dirty_off; /* Offset of the dirty region in the accumulator buffer */ + size_t dirty_len; /* Length of the dirty region in the accumulator buffer */ + hbool_t dirty; /* Flag to indicate that the accumulated metadata is dirty */ } H5F_meta_accum_t; /* A record of the mount table */ typedef struct H5F_mount_t { - struct H5G_t *group; /* Mount point group held open */ - struct H5F_t *file; /* File mounted at that point */ + struct H5G_t *group; /* Mount point group held open */ + struct H5F_t *file; /* File mounted at that point */ } H5F_mount_t; /* @@ -209,51 +209,51 @@ typedef struct H5F_mount_t { * to which this table belongs. */ typedef struct H5F_mtab_t { - unsigned nmounts;/* Number of children which are mounted */ - unsigned nalloc; /* Number of mount slots allocated */ - H5F_mount_t *child; /* An array of mount records */ + unsigned nmounts; /* Number of children which are mounted */ + unsigned nalloc; /* Number of mount slots allocated */ + H5F_mount_t *child; /* An array of mount records */ } H5F_mtab_t; /* Deferred-free record for the shadow file: records a region of bytes in * the shadow file to release after max_lag ticks. */ typedef struct shadow_defree { - uint64_t offset; // offset of the region in *bytes* - uint32_t length; // length of the region in *bytes* - uint64_t tick_num; // tick number when the free was deferred - TAILQ_ENTRY(shadow_defree) link; // deferred-free queue linkage + uint64_t offset; // offset of the region in *bytes* + uint32_t length; // length of the region in *bytes* + uint64_t tick_num; // tick number when the free was deferred + TAILQ_ENTRY(shadow_defree) link; // deferred-free queue linkage } shadow_defree_t; /* Structure specifically to store superblock. This was originally * maintained entirely within H5F_shared_t, but is now extracted * here because the superblock is now handled by the cache */ typedef struct H5F_super_t { - H5AC_info_t cache_info; /* Cache entry information structure */ - unsigned super_vers; /* Superblock version */ - uint8_t sizeof_addr; /* Size of addresses in file */ - uint8_t sizeof_size; /* Size of offsets in file */ - uint8_t status_flags; /* File status flags */ - unsigned sym_leaf_k; /* Size of leaves in symbol tables */ + H5AC_info_t cache_info; /* Cache entry information structure */ + unsigned super_vers; /* Superblock version */ + uint8_t sizeof_addr; /* Size of addresses in file */ + uint8_t sizeof_size; /* Size of offsets in file */ + uint8_t status_flags; /* File status flags */ + unsigned sym_leaf_k; /* Size of leaves in symbol tables */ unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ - haddr_t base_addr; /* Absolute base address for rel.addrs. */ - /* (superblock for file is at this offset) */ - haddr_t ext_addr; /* Relative address of superblock extension */ - haddr_t driver_addr; /* File driver information block address */ - haddr_t root_addr; /* Root group address */ - H5G_entry_t *root_ent; /* Root group symbol table entry */ + haddr_t base_addr; /* Absolute base address for rel.addrs. */ + /* (superblock for file is at this offset) */ + haddr_t ext_addr; /* Relative address of superblock extension */ + haddr_t driver_addr; /* File driver information block address */ + haddr_t root_addr; /* Root group address */ + H5G_entry_t *root_ent; /* Root group symbol table entry */ } H5F_super_t; /* Deferred-free record for the lower file: records a region of bytes in * the file below the SWMR VFD to release after a delay. */ typedef struct lower_defree { - SIMPLEQ_ENTRY(lower_defree) link; // deferred-free queue linkage - H5FD_mem_t alloc_type; // type with which the region was allocated - haddr_t addr; // start of the region *in bytes* - hsize_t size; // length of the region *in bytes* - uint64_t free_after_tick; /* the region may be reused on tick - * free_after_tick + 1 at the earliest - */ + SIMPLEQ_ENTRY(lower_defree) link; // deferred-free queue linkage + H5FD_mem_t alloc_type; // type with which the region was allocated + haddr_t addr; // start of the region *in bytes* + hsize_t size; // length of the region *in bytes* + uint64_t free_after_tick; /* the region may be reused on tick + * free_after_tick + 1 at the earliest + */ } lower_defree_t; /* Queue of deferred-free records (lower_defree_t) for the lower file, sorted @@ -274,230 +274,227 @@ typedef TAILQ_HEAD(shadow_defree_queue, shadow_defree) shadow_defree_queue_t; * pointing to this struct. */ struct H5F_shared_t { - H5FD_t *lf; /* Lower level file handle for I/O */ - H5F_super_t *sblock; /* Pointer to (pinned) superblock for file */ - H5O_drvinfo_t *drvinfo; /* Pointer to the (pinned) driver info - * cache entry. This field is only defined - * for older versions of the super block, - * and then only when a driver information - * block is present. At all other times - * it should be NULL. - */ - hbool_t drvinfo_sb_msg_exists; /* Convenience field used to track - * whether the driver info superblock - * extension message has been created - * yet. This field should be TRUE iff the - * superblock extension exists and contains - * a driver info message. Under all other - * circumstances, it must be set to FALSE. - */ - unsigned nrefs; /* Ref count for times file is opened */ - unsigned flags; /* Access Permissions for file */ - H5F_mtab_t mtab; /* File mount table */ - H5F_efc_t *efc; /* External file cache */ + H5FD_t * lf; /* Lower level file handle for I/O */ + H5F_super_t * sblock; /* Pointer to (pinned) superblock for file */ + H5O_drvinfo_t *drvinfo; /* Pointer to the (pinned) driver info + * cache entry. This field is only defined + * for older versions of the super block, + * and then only when a driver information + * block is present. At all other times + * it should be NULL. + */ + hbool_t drvinfo_sb_msg_exists; /* Convenience field used to track + * whether the driver info superblock + * extension message has been created + * yet. This field should be TRUE iff the + * superblock extension exists and contains + * a driver info message. Under all other + * circumstances, it must be set to FALSE. + */ + unsigned nrefs; /* Ref count for times file is opened */ + unsigned flags; /* Access Permissions for file */ + H5F_mtab_t mtab; /* File mount table */ + H5F_efc_t *efc; /* External file cache */ /* Cached values from FCPL/superblock */ - uint8_t sizeof_addr; /* Size of addresses in file */ - uint8_t sizeof_size; /* Size of offsets in file */ - haddr_t sohm_addr; /* Relative address of shared object header message table */ - unsigned sohm_vers; /* Version of shared message table on disk */ - unsigned sohm_nindexes; /* Number of shared messages indexes in the table */ + uint8_t sizeof_addr; /* Size of addresses in file */ + uint8_t sizeof_size; /* Size of offsets in file */ + haddr_t sohm_addr; /* Relative address of shared object header message table */ + unsigned sohm_vers; /* Version of shared message table on disk */ + unsigned sohm_nindexes; /* Number of shared messages indexes in the table */ unsigned long feature_flags; /* VFL Driver feature Flags */ - haddr_t maxaddr; /* Maximum address for file */ - - H5PB_t *pb_ptr; /* pointer to the page buffer, or NULL */ - /* if the page buffer is disabled. */ - - H5AC_t *cache; /* The object cache */ - H5AC_cache_config_t - mdc_initCacheCfg; /* initial configuration for the */ - /* metadata cache. This structure is */ - /* fixed at creation time and should */ - /* not change thereafter. */ - H5AC_cache_image_config_t - mdc_initCacheImageCfg; /* initial configuration for the */ - /* generate metadata cache image on */ - /* close option. This structure is */ - /* fixed at creation time and should */ - /* not change thereafter. */ - hbool_t use_mdc_logging; /* Set when metadata logging is desired */ - hbool_t start_mdc_log_on_access; /* set when mdc logging should */ - /* begin on file access/create */ - char *mdc_log_location; /* location of mdc log */ - hid_t fcpl_id; /* File creation property list ID */ - H5F_close_degree_t fc_degree; /* File close behavior degree */ - hbool_t evict_on_close; /* If the file's objects should be evicted from the metadata cache on close */ - size_t rdcc_nslots; /* Size of raw data chunk cache (slots) */ - size_t rdcc_nbytes; /* Size of raw data chunk cache (bytes) */ - double rdcc_w0; /* Preempt read chunks first? [0.0..1.0]*/ - size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ - hsize_t threshold; /* Threshold for alignment */ - hsize_t alignment; /* Alignment */ - unsigned gc_ref; /* Garbage-collect references? */ - H5F_libver_t low_bound; /* The 'low' bound of library format versions */ - H5F_libver_t high_bound; /* The 'high' bound of library format versions */ - hbool_t store_msg_crt_idx; /* Store creation index for object header messages? */ - unsigned ncwfs; /* Num entries on cwfs list */ - struct H5HG_heap_t **cwfs; /* Global heap cache */ - struct H5G_t *root_grp; /* Open root group */ - H5FO_t *open_objs; /* Open objects in file */ - H5UC_t *grp_btree_shared; /* Ref-counted group B-tree node info */ - hbool_t closing; /* File is in the process of being closed */ + haddr_t maxaddr; /* Maximum address for file */ + + H5PB_t *pb_ptr; /* pointer to the page buffer, or NULL */ + /* if the page buffer is disabled. */ + + H5AC_t * cache; /* The object cache */ + H5AC_cache_config_t mdc_initCacheCfg; /* initial configuration for the */ + /* metadata cache. This structure is */ + /* fixed at creation time and should */ + /* not change thereafter. */ + H5AC_cache_image_config_t mdc_initCacheImageCfg; /* initial configuration for the */ + /* generate metadata cache image on */ + /* close option. This structure is */ + /* fixed at creation time and should */ + /* not change thereafter. */ + hbool_t use_mdc_logging; /* Set when metadata logging is desired */ + hbool_t start_mdc_log_on_access; /* set when mdc logging should */ + /* begin on file access/create */ + char * mdc_log_location; /* location of mdc log */ + hid_t fcpl_id; /* File creation property list ID */ + H5F_close_degree_t fc_degree; /* File close behavior degree */ + hbool_t evict_on_close; /* If the file's objects should be evicted from the metadata cache on close */ + size_t rdcc_nslots; /* Size of raw data chunk cache (slots) */ + size_t rdcc_nbytes; /* Size of raw data chunk cache (bytes) */ + double rdcc_w0; /* Preempt read chunks first? [0.0..1.0]*/ + size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ + hsize_t threshold; /* Threshold for alignment */ + hsize_t alignment; /* Alignment */ + unsigned gc_ref; /* Garbage-collect references? */ + H5F_libver_t low_bound; /* The 'low' bound of library format versions */ + H5F_libver_t high_bound; /* The 'high' bound of library format versions */ + hbool_t store_msg_crt_idx; /* Store creation index for object header messages? */ + unsigned ncwfs; /* Num entries on cwfs list */ + struct H5HG_heap_t **cwfs; /* Global heap cache */ + struct H5G_t * root_grp; /* Open root group */ + H5FO_t * open_objs; /* Open objects in file */ + H5UC_t * grp_btree_shared; /* Ref-counted group B-tree node info */ + hbool_t closing; /* File is in the process of being closed */ /* Cached VOL connector ID & info */ - hid_t vol_id; /* ID of VOL connector for the container */ - const H5VL_class_t *vol_cls; /* Pointer to VOL connector class for the container */ - void *vol_info; /* Copy of VOL connector info for container */ + hid_t vol_id; /* ID of VOL connector for the container */ + const H5VL_class_t *vol_cls; /* Pointer to VOL connector class for the container */ + void * vol_info; /* Copy of VOL connector info for container */ /* File space allocation information */ - H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ - hsize_t fs_threshold; /* Free space section threshold */ - hbool_t fs_persist; /* Free-space persist or not */ - unsigned fs_version; /* Free-space version: */ - /* It is used to update fsinfo message in the superblock - extension when closing down the free-space managers */ - hbool_t use_tmp_space; /* Whether temp. file space allocation is allowed */ - haddr_t tmp_addr; /* Next address to use for temp. space in the file */ - hbool_t point_of_no_return; /* Flag to indicate that we can't go back and delete a freespace header when it's used up */ - - H5F_fs_state_t fs_state[H5F_MEM_PAGE_NTYPES]; /* State of free space manager for each type */ - haddr_t fs_addr[H5F_MEM_PAGE_NTYPES]; /* Address of free space manager info for each type */ - H5FS_t *fs_man[H5F_MEM_PAGE_NTYPES]; /* Free space manager for each file space type */ - hbool_t null_fsm_addr; /* Used by h5clear tool to tell the library */ - /* to drop free-space to the floor */ - haddr_t eoa_fsm_fsalloc; /* eoa after file space allocation */ - /* for self referential FSMs */ - haddr_t eoa_post_mdci_fsalloc; /* eoa past file space allocation */ - /* for metadata cache image, or */ - /* HADDR_UNDEF if no cache image. */ + H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ + hsize_t fs_threshold; /* Free space section threshold */ + hbool_t fs_persist; /* Free-space persist or not */ + unsigned fs_version; /* Free-space version: */ + /* It is used to update fsinfo message in the superblock + extension when closing down the free-space managers */ + hbool_t use_tmp_space; /* Whether temp. file space allocation is allowed */ + haddr_t tmp_addr; /* Next address to use for temp. space in the file */ + hbool_t point_of_no_return; /* Flag to indicate that we can't go back and delete a freespace header when + it's used up */ + + H5F_fs_state_t fs_state[H5F_MEM_PAGE_NTYPES]; /* State of free space manager for each type */ + haddr_t fs_addr[H5F_MEM_PAGE_NTYPES]; /* Address of free space manager info for each type */ + H5FS_t * fs_man[H5F_MEM_PAGE_NTYPES]; /* Free space manager for each file space type */ + hbool_t null_fsm_addr; /* Used by h5clear tool to tell the library */ + /* to drop free-space to the floor */ + haddr_t eoa_fsm_fsalloc; /* eoa after file space allocation */ + /* for self referential FSMs */ + haddr_t eoa_post_mdci_fsalloc; /* eoa past file space allocation */ + /* for metadata cache image, or */ + /* HADDR_UNDEF if no cache image. */ /* Free-space aggregation info */ - unsigned fs_aggr_merge[H5FD_MEM_NTYPES]; /* Flags for whether free space can merge with aggregator(s) */ - H5FD_mem_t fs_type_map[H5FD_MEM_NTYPES]; /* Mapping of "real" file space type into tracked type */ - H5F_blk_aggr_t meta_aggr; /* Metadata aggregation info (if aggregating metadata allocations) */ - H5F_blk_aggr_t sdata_aggr; /* "Small data" aggregation info (if aggregating "small data" allocations) */ + unsigned fs_aggr_merge[H5FD_MEM_NTYPES]; /* Flags for whether free space can merge with aggregator(s) */ + H5FD_mem_t fs_type_map[H5FD_MEM_NTYPES]; /* Mapping of "real" file space type into tracked type */ + H5F_blk_aggr_t meta_aggr; /* Metadata aggregation info (if aggregating metadata allocations) */ + H5F_blk_aggr_t sdata_aggr; /* "Small data" aggregation info (if aggregating "small data" allocations) */ /* Paged aggregation info */ - hsize_t fs_page_size; /* File space page size */ - size_t pgend_meta_thres; /* Do not track page end meta section <= this threshold */ + hsize_t fs_page_size; /* File space page size */ + size_t pgend_meta_thres; /* Do not track page end meta section <= this threshold */ /* Metadata accumulator information */ - H5F_meta_accum_t accum; /* Metadata accumulator info */ + H5F_meta_accum_t accum; /* Metadata accumulator info */ /* Metadata retry info */ - unsigned read_attempts; /* The # of reads to try when reading metadata with checksum */ - unsigned retries_nbins; /* # of bins for each retries[] */ - uint32_t *retries[H5AC_NTYPES]; /* Track # of read retries for metdata items with checksum */ + unsigned read_attempts; /* The # of reads to try when reading metadata with checksum */ + unsigned retries_nbins; /* # of bins for each retries[] */ + uint32_t *retries[H5AC_NTYPES]; /* Track # of read retries for metdata items with checksum */ /* Object flush info */ - H5F_object_flush_t object_flush; /* Information for object flush callback */ - hbool_t crt_dset_min_ohdr_flag; /* flag to minimize created dataset object header */ + H5F_object_flush_t object_flush; /* Information for object flush callback */ + hbool_t crt_dset_min_ohdr_flag; /* flag to minimize created dataset object header */ /* VFD SWMR */ /* Configuration info */ - H5F_vfd_swmr_config_t vfd_swmr_config; /* Copy of the VFD SWMR - * configuration from the - * FAPL used to open the file - */ - haddr_t writer_index_offset; /* Current byte offset of the - * shadow index in the shadow file. - */ - hbool_t vfd_swmr; /* The file is opened with VFD - * SWMR configured or not - */ - hbool_t vfd_swmr_writer; /* This is the VFD SWMR writer or - * not - */ - uint64_t tick_num; /* Number of the current tick */ - struct timespec end_of_tick; /* End time of the current tick */ - - lower_defree_queue_t lower_defrees; /* Records of lower-file space - * awaiting reclamation. + H5F_vfd_swmr_config_t vfd_swmr_config; /* Copy of the VFD SWMR + * configuration from the + * FAPL used to open the file + */ + haddr_t writer_index_offset; /* Current byte offset of the + * shadow index in the shadow file. + */ + hbool_t vfd_swmr; /* The file is opened with VFD + * SWMR configured or not + */ + hbool_t vfd_swmr_writer; /* This is the VFD SWMR writer or + * not */ + uint64_t tick_num; /* Number of the current tick */ + struct timespec end_of_tick; /* End time of the current tick */ + + lower_defree_queue_t lower_defrees; /* Records of lower-file space + * awaiting reclamation. + */ /* VFD SWMR metadata file index */ - H5FD_vfd_swmr_idx_entry_t * mdf_idx; /* pointer to an array of instance - * of H5FD_vfd_swmr_idx_entry_t of - * length mdf_idx_len. This array - * is used by the vfd swmr writer - * to assemble the metadata file - * index at the end of each tick, - * and by the vfd swmr readers to - * track changes in the index. - * With one brief exception during - * writer end of tick processing, - * this index will always be sorted - * in increasing HDF5 file page - * offset order. - * - * This field should be NULL unless - * the index is defined. - */ - uint32_t mdf_idx_len; /* number of entries in the array - * of instances of - * H5FD_vfd_swmr_idx_entry_t pointed - * to by mdf_idx above. Note that - * not all entries in the index - * need be used. - */ - uint32_t mdf_idx_entries_used; /* Number of entries in *mdf_idx - * that are in use -- these will - * be contiguous at indicies 0 - * through mdf_idx_entries_used - 1. - */ + H5FD_vfd_swmr_idx_entry_t *mdf_idx; /* pointer to an array of instance + * of H5FD_vfd_swmr_idx_entry_t of + * length mdf_idx_len. This array + * is used by the vfd swmr writer + * to assemble the metadata file + * index at the end of each tick, + * and by the vfd swmr readers to + * track changes in the index. + * With one brief exception during + * writer end of tick processing, + * this index will always be sorted + * in increasing HDF5 file page + * offset order. + * + * This field should be NULL unless + * the index is defined. + */ + uint32_t mdf_idx_len; /* number of entries in the array + * of instances of + * H5FD_vfd_swmr_idx_entry_t pointed + * to by mdf_idx above. Note that + * not all entries in the index + * need be used. + */ + uint32_t mdf_idx_entries_used; /* Number of entries in *mdf_idx + * that are in use -- these will + * be contiguous at indicies 0 + * through mdf_idx_entries_used - 1. + */ /* Old VFD SWMMR metadata file index. These fields are used only - * by the VFD SWMR reader to store the previous version of the - * metadata file index so that it can be compared with the current - * version to identify page buffer and metadata cache entries that + * by the VFD SWMR reader to store the previous version of the + * metadata file index so that it can be compared with the current + * version to identify page buffer and metadata cache entries that * must be evicted or refreshed to avoid message from the past bugs. */ - H5FD_vfd_swmr_idx_entry_t * old_mdf_idx; - uint32_t old_mdf_idx_len; - uint32_t old_mdf_idx_entries_used; + H5FD_vfd_swmr_idx_entry_t *old_mdf_idx; + uint32_t old_mdf_idx_len; + uint32_t old_mdf_idx_entries_used; /* Metadata file for VFD SWMR writer */ - int vfd_swmr_md_fd; /* POSIX: file descriptor for the - * metadata file - */ - haddr_t vfd_swmr_md_eoa; /* POSIX: eoa for the metadata - * file - */ + int vfd_swmr_md_fd; /* POSIX: file descriptor for the + * metadata file + */ + haddr_t vfd_swmr_md_eoa; /* POSIX: eoa for the metadata + * file + */ /* Free space manager for the metadata file */ - H5FS_t *fs_man_md; /* Free-space manager */ - H5F_fs_state_t fs_state_md; /* State of the free space - * manager - */ + H5FS_t * fs_man_md; /* Free-space manager */ + H5F_fs_state_t fs_state_md; /* State of the free space + * manager + */ /* Delayed free space release doubly linked list */ shadow_defree_queue_t shadow_defrees; - char *extpath; /* Path for searching target external link file */ + char * extpath; /* Path for searching target external link file */ #ifdef H5_HAVE_PARALLEL H5P_coll_md_read_flag_t coll_md_read; /* Do all metadata reads collectively */ - hbool_t coll_md_write; /* Do all metadata writes collectively */ -#endif /* H5_HAVE_PARALLEL */ - + hbool_t coll_md_write; /* Do all metadata writes collectively */ +#endif /* H5_HAVE_PARALLEL */ }; - /* * This is the top-level file descriptor. One of these structures is * allocated every time H5Fopen() is called although they may contain pointers * to shared H5F_shared_t structs. */ struct H5F_t { - char *open_name; /* Name used to open file */ - char *actual_name; /* Actual name of the file, after resolving symlinks, etc. */ - H5F_shared_t *shared; /* The shared file info */ - H5VL_object_t *vol_obj; /* VOL object */ - unsigned nopen_objs; /* Number of open object headers */ - H5FO_t *obj_count; /* # of time each object is opened through top file structure */ - hbool_t id_exists; /* Whether an ID for this struct exists */ - hbool_t closing; /* File is in the process of being closed */ - struct H5F_t *parent; /* Parent file that this file is mounted to */ - unsigned nmounts; /* Number of children mounted to this file */ + char * open_name; /* Name used to open file */ + char * actual_name; /* Actual name of the file, after resolving symlinks, etc. */ + H5F_shared_t * shared; /* The shared file info */ + H5VL_object_t *vol_obj; /* VOL object */ + unsigned nopen_objs; /* Number of open object headers */ + H5FO_t * obj_count; /* # of time each object is opened through top file structure */ + hbool_t id_exists; /* Whether an ID for this struct exists */ + hbool_t closing; /* File is in the process of being closed */ + struct H5F_t * parent; /* Parent file that this file is mounted to */ + unsigned nmounts; /* Number of children mounted to this file */ }; /*****************************/ @@ -510,27 +507,26 @@ H5FL_EXTERN(H5F_t); /* Declare a free list to manage the H5F_shared_t struct */ H5FL_EXTERN(H5F_shared_t); - /******************************/ /* Package Private Prototypes */ /******************************/ /* General routines */ H5_DLL herr_t H5F__post_open(H5F_t *f); -H5_DLL H5F_t *H5F__reopen(H5F_t *f); -H5_DLL herr_t H5F__dest(H5F_t *f, hbool_t flush); -H5_DLL herr_t H5F__flush(H5F_t *f); -H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t fapl_id); +H5_DLL H5F_t * H5F__reopen(H5F_t *f); +H5_DLL herr_t H5F__dest(H5F_t *f, hbool_t flush); +H5_DLL herr_t H5F__flush(H5F_t *f); +H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t fapl_id); H5_DLL ssize_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); -H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); -H5_DLL herr_t H5F__format_convert(H5F_t *f); -H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); -H5_DLL herr_t H5F__close(H5F_t *f); -H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); -H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info); -H5_DLL herr_t H5F__vfd_swmr_end_tick(H5F_t *f); -H5_DLL herr_t H5F__vfd_swmr_disable_end_of_tick(H5F_t *f); -H5_DLL herr_t H5F__vfd_swmr_enable_end_of_tick(H5F_t *f); +H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); +H5_DLL herr_t H5F__format_convert(H5F_t *f); +H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); +H5_DLL herr_t H5F__close(H5F_t *f); +H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); +H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info); +H5_DLL herr_t H5F__vfd_swmr_end_tick(H5F_t *f); +H5_DLL herr_t H5F__vfd_swmr_disable_end_of_tick(H5F_t *f); +H5_DLL herr_t H5F__vfd_swmr_enable_end_of_tick(H5F_t *f); /* File mount related routines */ H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); @@ -546,13 +542,15 @@ H5_DLL herr_t H5F__super_free(H5F_super_t *sblock); /* Superblock extension related routines */ H5_DLL herr_t H5F__super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr); -H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, unsigned mesg_flags); +H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, + unsigned mesg_flags); H5_DLL herr_t H5F__super_ext_remove_msg(H5F_t *f, unsigned id); H5_DLL herr_t H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created); /* Metadata accumulator routines */ H5_DLL herr_t H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf); -H5_DLL herr_t H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); +H5_DLL herr_t H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, + const void *buf); H5_DLL herr_t H5F__accum_free(H5F_shared_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size); H5_DLL herr_t H5F__accum_flush(H5F_shared_t *f_sh); H5_DLL herr_t H5F__accum_reset(H5F_shared_t *f_sh, hbool_t flush); @@ -560,20 +558,20 @@ H5_DLL herr_t H5F__accum_reset(H5F_shared_t *f_sh, hbool_t flush); /* Shared file list related routines */ H5_DLL herr_t H5F__sfile_add(H5F_shared_t *shared); H5_DLL H5F_shared_t *H5F__sfile_search(H5FD_t *lf); -H5_DLL herr_t H5F__sfile_remove(H5F_shared_t *shared); +H5_DLL herr_t H5F__sfile_remove(H5F_shared_t *shared); /* External file cache routines */ H5_DLL H5F_efc_t *H5F__efc_create(unsigned max_nfiles); -H5_DLL H5F_t *H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL H5F_t * H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL unsigned H5F__efc_max_nfiles(H5F_efc_t *efc); -H5_DLL herr_t H5F__efc_release(H5F_efc_t *efc); -H5_DLL herr_t H5F__efc_destroy(H5F_efc_t *efc); -H5_DLL herr_t H5F__efc_try_close(H5F_t *f); +H5_DLL herr_t H5F__efc_release(H5F_efc_t *efc); +H5_DLL herr_t H5F__efc_destroy(H5F_efc_t *efc); +H5_DLL herr_t H5F__efc_try_close(H5F_t *f); /* Space allocation routines */ H5_DLL haddr_t H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); -H5_DLL herr_t H5F__free(H5F_t *f, H5F_mem_t type, haddr_t addr, hsize_t size); -H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested); +H5_DLL herr_t H5F__free(H5F_t *f, H5F_mem_t type, haddr_t addr, hsize_t size); +H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested); /* Functions that get/retrieve values from VFD layer */ H5_DLL herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr); @@ -593,11 +591,9 @@ H5_DLL herr_t H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr); /* VFD SWMR testing routines */ H5_DLL herr_t H5F__vfd_swmr_writer_create_open_flush_test(hid_t file_id, hbool_t create); -H5_DLL herr_t H5F__vfd_swmr_writer_md_test(hid_t, unsigned, - struct H5FD_vfd_swmr_idx_entry_t *, unsigned); +H5_DLL herr_t H5F__vfd_swmr_writer_md_test(hid_t, unsigned, struct H5FD_vfd_swmr_idx_entry_t *, unsigned); H5_DLL htri_t H5F__same_file_test(hid_t file_id1, hid_t file_id2); #endif /* H5F_TESTING */ #endif /* _H5Fpkg_H */ - diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index fdacecd..d738603 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -25,16 +25,15 @@ typedef struct H5F_t H5F_t; #include "H5Fpublic.h" /* Public headers needed by this file */ -#include "H5FDpublic.h" /* File drivers */ +#include "H5FDpublic.h" /* File drivers */ /* Private headers needed by this file */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_PARALLEL -#include "H5Pprivate.h" /* Property lists */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5Pprivate.h" /* Property lists */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ /* Library Private Macros */ @@ -45,102 +44,124 @@ typedef struct H5F_t H5F_t; * Currently, all file meta-data is little-endian. */ -# define INT16ENCODE(p, i) { \ - *(p) = (uint8_t)( (unsigned)(i) & 0xff); (p)++; \ - *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); (p)++; \ -} +#define INT16ENCODE(p, i) \ + { \ + *(p) = (uint8_t)((unsigned)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); \ + (p)++; \ + } -# define UINT16ENCODE(p, i) { \ - *(p) = (uint8_t)( (unsigned)(i) & 0xff); (p)++; \ - *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); (p)++; \ -} +#define UINT16ENCODE(p, i) \ + { \ + *(p) = (uint8_t)((unsigned)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); \ + (p)++; \ + } -# define INT32ENCODE(p, i) { \ - *(p) = (uint8_t)( (uint32_t)(i) & 0xff); (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 8) & 0xff); (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 16) & 0xff); (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 24) & 0xff); (p)++; \ -} +#define INT32ENCODE(p, i) \ + { \ + *(p) = (uint8_t)((uint32_t)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 8) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 16) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 24) & 0xff); \ + (p)++; \ + } -# define UINT32ENCODE(p, i) { \ - *(p) = (uint8_t)( (i) & 0xff); (p)++; \ - *(p) = (uint8_t)(((i) >> 8) & 0xff); (p)++; \ - *(p) = (uint8_t)(((i) >> 16) & 0xff); (p)++; \ - *(p) = (uint8_t)(((i) >> 24) & 0xff); (p)++; \ -} +#define UINT32ENCODE(p, i) \ + { \ + *(p) = (uint8_t)((i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 8) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 16) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 24) & 0xff); \ + (p)++; \ + } /* Encode an unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define ENCODE_VAR(p, typ, n, l) { \ - typ _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for(_i = 0; _i < l; _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t*)(p) + l; \ -} +#define ENCODE_VAR(p, typ, n, l) \ + { \ + typ _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < l; _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + (p) = (uint8_t *)(p) + l; \ + } /* Encode a 32-bit unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) - -# define INT64ENCODE(p, n) { \ - int64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for (_i = 0; _i < sizeof(int64_t); _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - for (/*void*/; _i < 8; _i++) \ - *_p++ = (uint8_t)((n) < 0 ? 0xff : 0); \ - (p) = (uint8_t*)(p)+8; \ -} +#define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) + +#define INT64ENCODE(p, n) \ + { \ + int64_t _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < sizeof(int64_t); _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + for (/*void*/; _i < 8; _i++) \ + *_p++ = (uint8_t)((n) < 0 ? 0xff : 0); \ + (p) = (uint8_t *)(p) + 8; \ + } -# define UINT64ENCODE(p, n) { \ - uint64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for (_i = 0; _i < sizeof(uint64_t); _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - for (/*void*/; _i < 8; _i++) \ - *_p++ = 0; \ - (p) = (uint8_t*)(p) + 8; \ -} +#define UINT64ENCODE(p, n) \ + { \ + uint64_t _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < sizeof(uint64_t); _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + for (/*void*/; _i < 8; _i++) \ + *_p++ = 0; \ + (p) = (uint8_t *)(p) + 8; \ + } /* Encode a 64-bit unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) +#define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) /* Encode a 64-bit unsigned integer and its length into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT64ENCODE_VARLEN(p, n) { \ - uint64_t __n = (uint64_t)(n); \ - unsigned _s = H5VM_limit_enc_size(__n); \ - \ - *(p)++ = (uint8_t)_s; \ - UINT64ENCODE_VAR(p, __n, _s); \ -} +#define UINT64ENCODE_VARLEN(p, n) \ + { \ + uint64_t __n = (uint64_t)(n); \ + unsigned _s = H5VM_limit_enc_size(__n); \ + \ + *(p)++ = (uint8_t)_s; \ + UINT64ENCODE_VAR(p, __n, _s); \ + } -# define H5_ENCODE_UNSIGNED(p, n) { \ - HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ - UINT32ENCODE(p, n) \ -} +#define H5_ENCODE_UNSIGNED(p, n) \ + { \ + HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ + UINT32ENCODE(p, n) \ + } /* Assumes the endianness of uint64_t is the same as double */ -# define H5_ENCODE_DOUBLE(p, n) { \ - uint64_t _n; \ - size_t _u; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - HDcompile_assert(sizeof(double) == 8); \ - HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ - H5MM_memcpy(&_n, &n, sizeof(double)); \ - for(_u = 0; _u < sizeof(uint64_t); _u++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t *)(p) + 8; \ -} +#define H5_ENCODE_DOUBLE(p, n) \ + { \ + uint64_t _n; \ + size_t _u; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + HDcompile_assert(sizeof(double) == 8); \ + HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ + H5MM_memcpy(&_n, &n, sizeof(double)); \ + for (_u = 0; _u < sizeof(uint64_t); _u++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + (p) = (uint8_t *)(p) + 8; \ + } /* DECODE converts little endian bytes pointed by p to integer values and store * it in i. For signed values, need to do sign-extension when converting @@ -150,63 +171,79 @@ typedef struct H5F_t H5F_t; * correctly even if i is actually a 64bit int like in a Cray. */ -# define INT16DECODE(p, i) { \ - (i) = (int16_t)((*(p) & 0xff)); (p)++; \ - (i) |= (int16_t)(((*(p) & 0xff) << 8) | \ - ((*(p) & 0x80) ? ~0xffff : 0x0)); (p)++; \ -} +#define INT16DECODE(p, i) \ + { \ + (i) = (int16_t)((*(p)&0xff)); \ + (p)++; \ + (i) |= (int16_t)(((*(p)&0xff) << 8) | ((*(p)&0x80) ? ~0xffff : 0x0)); \ + (p)++; \ + } -# define UINT16DECODE(p, i) { \ - (i) = (uint16_t) (*(p) & 0xff); (p)++; \ - (i) |= (uint16_t)((*(p) & 0xff) << 8); (p)++; \ -} +#define UINT16DECODE(p, i) \ + { \ + (i) = (uint16_t)(*(p)&0xff); \ + (p)++; \ + (i) |= (uint16_t)((*(p)&0xff) << 8); \ + (p)++; \ + } -# define INT32DECODE(p, i) { \ - (i) = ((int32_t)(*(p) & 0xff)); (p)++; \ - (i) |= ((int32_t)(*(p) & 0xff) << 8); (p)++; \ - (i) |= ((int32_t)(*(p) & 0xff) << 16); (p)++; \ - (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | \ - ((*(p) & 0x80) ? ~0xffffffffULL : 0x0ULL))); (p)++; \ -} +#define INT32DECODE(p, i) \ + { \ + (i) = ((int32_t)(*(p)&0xff)); \ + (p)++; \ + (i) |= ((int32_t)(*(p)&0xff) << 8); \ + (p)++; \ + (i) |= ((int32_t)(*(p)&0xff) << 16); \ + (p)++; \ + (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | ((*(p)&0x80) ? ~0xffffffffULL : 0x0ULL))); \ + (p)++; \ + } -# define UINT32DECODE(p, i) { \ - (i) = (uint32_t)(*(p) & 0xff); (p)++; \ - (i) |= ((uint32_t)(*(p) & 0xff) << 8); (p)++; \ - (i) |= ((uint32_t)(*(p) & 0xff) << 16); (p)++; \ - (i) |= ((uint32_t)(*(p) & 0xff) << 24); (p)++; \ -} +#define UINT32DECODE(p, i) \ + { \ + (i) = (uint32_t)(*(p)&0xff); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 8); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 16); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 24); \ + (p)++; \ + } /* Decode a variable-sized buffer */ /* (Assumes that the high bits of the integer will be zero) */ -# define DECODE_VAR(p, n, l) { \ - size_t _i; \ - \ - n = 0; \ - (p) += l; \ - for (_i = 0; _i < l; _i++) \ - n = (n << 8) | *(--p); \ - (p) += l; \ -} +#define DECODE_VAR(p, n, l) \ + { \ + size_t _i; \ + \ + n = 0; \ + (p) += l; \ + for (_i = 0; _i < l; _i++) \ + n = (n << 8) | *(--p); \ + (p) += l; \ + } /* Decode a variable-sized buffer into a 32-bit unsigned integer */ /* (Assumes that the high bits of the integer will be zero) */ -# define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) - -# define INT64DECODE(p, n) { \ - /* WE DON'T CHECK FOR OVERFLOW! */ \ - size_t _i; \ - \ - n = 0; \ - (p) += 8; \ - for (_i = 0; _i < sizeof(int64_t); _i++) \ - n = (n << 8) | *(--p); \ - (p) += 8; \ -} +#define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) + +#define INT64DECODE(p, n) \ + { \ + /* WE DON'T CHECK FOR OVERFLOW! */ \ + size_t _i; \ + \ + n = 0; \ + (p) += 8; \ + for (_i = 0; _i < sizeof(int64_t); _i++) \ + n = (n << 8) | *(--p); \ + (p) += 8; \ + } static inline uint64_t uint64_decode(uint8_t **pp) { - int i; + int i; uint8_t *p = *pp; uint64_t v = 0; @@ -217,351 +254,385 @@ uint64_decode(uint8_t **pp) return v; } -# define UINT64DECODE(p, n) { \ - /* WE DON'T CHECK FOR OVERFLOW! */ \ - size_t _i; \ - \ - n = 0; \ - (p) += 8; \ - for (_i = 0; _i < sizeof(uint64_t); _i++) \ - n = (n << 8) | *(--p); \ - (p) += 8; \ -} +#define UINT64DECODE(p, n) \ + { \ + /* WE DON'T CHECK FOR OVERFLOW! */ \ + size_t _i; \ + \ + n = 0; \ + (p) += 8; \ + for (_i = 0; _i < sizeof(uint64_t); _i++) \ + n = (n << 8) | *(--p); \ + (p) += 8; \ + } /* Decode a variable-sized buffer into a 64-bit unsigned integer */ /* (Assumes that the high bits of the integer will be zero) */ -# define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) +#define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) /* Decode a 64-bit unsigned integer and its length from a variable-sized buffer */ /* (Assumes that the high bits of the integer will be zero) */ -# define UINT64DECODE_VARLEN(p, n) { \ - unsigned _s = *(p)++; \ - \ - UINT64DECODE_VAR(p, n, _s); \ -} +#define UINT64DECODE_VARLEN(p, n) \ + { \ + unsigned _s = *(p)++; \ + \ + UINT64DECODE_VAR(p, n, _s); \ + } -# define H5_DECODE_UNSIGNED(p, n) { \ - HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ - UINT32DECODE(p, n) \ -} +#define H5_DECODE_UNSIGNED(p, n) \ + { \ + HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ + UINT32DECODE(p, n) \ + } /* Assumes the endianness of uint64_t is the same as double */ -# define H5_DECODE_DOUBLE(p, n) { \ - uint64_t _n; \ - size_t _u; \ - \ - HDcompile_assert(sizeof(double) == 8); \ - HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ - _n = 0; \ - (p) += 8; \ - for(_u = 0; _u < sizeof(uint64_t); _u++) \ - _n = (_n << 8) | *(--p); \ - H5MM_memcpy(&(n), &_n, sizeof(double)); \ - (p) += 8; \ -} +#define H5_DECODE_DOUBLE(p, n) \ + { \ + uint64_t _n; \ + size_t _u; \ + \ + HDcompile_assert(sizeof(double) == 8); \ + HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ + _n = 0; \ + (p) += 8; \ + for (_u = 0; _u < sizeof(uint64_t); _u++) \ + _n = (_n << 8) | *(--p); \ + H5MM_memcpy(&(n), &_n, sizeof(double)); \ + (p) += 8; \ + } /* Address-related macros */ -#define H5F_addr_overflow(X,Z) (HADDR_UNDEF==(X) || \ - HADDR_UNDEF==(X)+(haddr_t)(Z) || \ - (X)+(haddr_t)(Z)<(X)) -#define H5F_addr_defined(X) ((X)!=HADDR_UNDEF) +#define H5F_addr_overflow(X, Z) \ + (HADDR_UNDEF == (X) || HADDR_UNDEF == (X) + (haddr_t)(Z) || (X) + (haddr_t)(Z) < (X)) +#define H5F_addr_defined(X) ((X) != HADDR_UNDEF) /* The H5F_addr_eq() macro guarantees that Y is not HADDR_UNDEF by making * certain that X is not HADDR_UNDEF and then checking that X equals Y */ -#define H5F_addr_eq(X,Y) ((X)!=HADDR_UNDEF && \ - (X)==(Y)) -#define H5F_addr_ne(X,Y) (!H5F_addr_eq((X),(Y))) -#define H5F_addr_lt(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ - (X)<(Y)) -#define H5F_addr_le(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ - (X)<=(Y)) -#define H5F_addr_gt(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ - (X)>(Y)) -#define H5F_addr_ge(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ - (X)>=(Y)) -#define H5F_addr_cmp(X,Y) (H5F_addr_eq((X), (Y)) ? 0 : \ - (H5F_addr_lt((X), (Y)) ? -1 : 1)) -#define H5F_addr_pow2(N) ((haddr_t)1<<(N)) -#define H5F_addr_overlap(O1,L1,O2,L2) (((O1) < (O2) && ((O1) + (L1)) > (O2)) || \ - ((O1) >= (O2) && (O1) < ((O2) + (L2)))) +#define H5F_addr_eq(X, Y) ((X) != HADDR_UNDEF && (X) == (Y)) +#define H5F_addr_ne(X, Y) (!H5F_addr_eq((X), (Y))) +#define H5F_addr_lt(X, Y) ((X) != HADDR_UNDEF && (Y) != HADDR_UNDEF && (X) < (Y)) +#define H5F_addr_le(X, Y) ((X) != HADDR_UNDEF && (Y) != HADDR_UNDEF && (X) <= (Y)) +#define H5F_addr_gt(X, Y) ((X) != HADDR_UNDEF && (Y) != HADDR_UNDEF && (X) > (Y)) +#define H5F_addr_ge(X, Y) ((X) != HADDR_UNDEF && (Y) != HADDR_UNDEF && (X) >= (Y)) +#define H5F_addr_cmp(X, Y) (H5F_addr_eq((X), (Y)) ? 0 : (H5F_addr_lt((X), (Y)) ? -1 : 1)) +#define H5F_addr_pow2(N) ((haddr_t)1 << (N)) +#define H5F_addr_overlap(O1, L1, O2, L2) \ + (((O1) < (O2) && ((O1) + (L1)) > (O2)) || ((O1) >= (O2) && (O1) < ((O2) + (L2)))) /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5F_MODULE -#define H5F_LOW_BOUND(F) ((F)->shared->low_bound) -#define H5F_HIGH_BOUND(F) ((F)->shared->high_bound) -#define H5F_SHARED_INTENT(F_SH) ((F_SH)->flags) -#define H5F_INTENT(F) ((F)->shared->flags) -#define H5F_OPEN_NAME(F) ((F)->open_name) -#define H5F_ACTUAL_NAME(F) ((F)->actual_name) -#define H5F_EXTPATH(F) ((F)->shared->extpath) -#define H5F_SHARED(F) ((F)->shared) -#define H5F_SAME_SHARED(F1, F2) ((F1)->shared == (F2)->shared) -#define H5F_NOPEN_OBJS(F) ((F)->nopen_objs) -#define H5F_INCR_NOPEN_OBJS(F) ((F)->nopen_objs++) -#define H5F_DECR_NOPEN_OBJS(F) ((F)->nopen_objs--) -#define H5F_ID_EXISTS(F) ((F)->id_exists) -#define H5F_PARENT(F) ((F)->parent) -#define H5F_NMOUNTS(F) ((F)->nmounts) -#define H5F_GET_READ_ATTEMPTS(F) ((F)->shared->read_attempts) -#define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id) -#define H5F_GET_FILENO(F,FILENUM) ((FILENUM) = (F)->shared->lf->fileno) -#define H5F_SHARED_HAS_FEATURE(F_SH,FL) ((F_SH)->lf->feature_flags & (FL)) -#define H5F_HAS_FEATURE(F,FL) ((F)->shared->lf->feature_flags & (FL)) -#define H5F_BASE_ADDR(F) ((F)->shared->sblock->base_addr) -#define H5F_SYM_LEAF_K(F) ((F)->shared->sblock->sym_leaf_k) -#define H5F_KVALUE(F,T) ((F)->shared->sblock->btree_k[(T)->id]) -#define H5F_NREFS(F) ((F)->shared->nrefs) -#define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) -#define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) -#define H5F_SOHM_ADDR(F) ((F)->shared->sohm_addr) -#define H5F_SET_SOHM_ADDR(F, A) ((F)->shared->sohm_addr = (A)) -#define H5F_SOHM_VERS(F) ((F)->shared->sohm_vers) -#define H5F_SET_SOHM_VERS(F, V) ((F)->shared->sohm_vers = (V)) -#define H5F_SOHM_NINDEXES(F) ((F)->shared->sohm_nindexes) -#define H5F_SET_SOHM_NINDEXES(F, N) ((F)->shared->sohm_nindexes = (N)) -#define H5F_FCPL(F) ((F)->shared->fcpl_id) -#define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree) -#define H5F_EVICT_ON_CLOSE(F) ((F)->shared->evict_on_close) -#define H5F_RDCC_NSLOTS(F) ((F)->shared->rdcc_nslots) -#define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes) -#define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0) -#define H5F_SIEVE_BUF_SIZE(F) ((F)->shared->sieve_buf_size) -#define H5F_GC_REF(F) ((F)->shared->gc_ref) -#define H5F_STORE_MSG_CRT_IDX(F) ((F)->shared->store_msg_crt_idx) -#define H5F_SET_STORE_MSG_CRT_IDX(F, FL) ((F)->shared->store_msg_crt_idx = (FL)) -#define H5F_GRP_BTREE_SHARED(F) ((F)->shared->grp_btree_shared) -#define H5F_SET_GRP_BTREE_SHARED(F, RC) (((F)->shared->grp_btree_shared = (RC)) ? SUCCEED : FAIL) -#define H5F_USE_TMP_SPACE(F) ((F)->shared->fs.use_tmp_space) -#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_addr_le((F)->shared->fs.tmp_addr, (ADDR))) +#define H5F_LOW_BOUND(F) ((F)->shared->low_bound) +#define H5F_HIGH_BOUND(F) ((F)->shared->high_bound) +#define H5F_SHARED_INTENT(F_SH) ((F_SH)->flags) +#define H5F_INTENT(F) ((F)->shared->flags) +#define H5F_OPEN_NAME(F) ((F)->open_name) +#define H5F_ACTUAL_NAME(F) ((F)->actual_name) +#define H5F_EXTPATH(F) ((F)->shared->extpath) +#define H5F_SHARED(F) ((F)->shared) +#define H5F_SAME_SHARED(F1, F2) ((F1)->shared == (F2)->shared) +#define H5F_NOPEN_OBJS(F) ((F)->nopen_objs) +#define H5F_INCR_NOPEN_OBJS(F) ((F)->nopen_objs++) +#define H5F_DECR_NOPEN_OBJS(F) ((F)->nopen_objs--) +#define H5F_ID_EXISTS(F) ((F)->id_exists) +#define H5F_PARENT(F) ((F)->parent) +#define H5F_NMOUNTS(F) ((F)->nmounts) +#define H5F_GET_READ_ATTEMPTS(F) ((F)->shared->read_attempts) +#define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id) +#define H5F_GET_FILENO(F, FILENUM) ((FILENUM) = (F)->shared->lf->fileno) +#define H5F_SHARED_HAS_FEATURE(F_SH, FL) ((F_SH)->lf->feature_flags & (FL)) +#define H5F_HAS_FEATURE(F, FL) ((F)->shared->lf->feature_flags & (FL)) +#define H5F_BASE_ADDR(F) ((F)->shared->sblock->base_addr) +#define H5F_SYM_LEAF_K(F) ((F)->shared->sblock->sym_leaf_k) +#define H5F_KVALUE(F, T) ((F)->shared->sblock->btree_k[(T)->id]) +#define H5F_NREFS(F) ((F)->shared->nrefs) +#define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) +#define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) +#define H5F_SOHM_ADDR(F) ((F)->shared->sohm_addr) +#define H5F_SET_SOHM_ADDR(F, A) ((F)->shared->sohm_addr = (A)) +#define H5F_SOHM_VERS(F) ((F)->shared->sohm_vers) +#define H5F_SET_SOHM_VERS(F, V) ((F)->shared->sohm_vers = (V)) +#define H5F_SOHM_NINDEXES(F) ((F)->shared->sohm_nindexes) +#define H5F_SET_SOHM_NINDEXES(F, N) ((F)->shared->sohm_nindexes = (N)) +#define H5F_FCPL(F) ((F)->shared->fcpl_id) +#define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree) +#define H5F_EVICT_ON_CLOSE(F) ((F)->shared->evict_on_close) +#define H5F_RDCC_NSLOTS(F) ((F)->shared->rdcc_nslots) +#define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes) +#define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0) +#define H5F_SIEVE_BUF_SIZE(F) ((F)->shared->sieve_buf_size) +#define H5F_GC_REF(F) ((F)->shared->gc_ref) +#define H5F_STORE_MSG_CRT_IDX(F) ((F)->shared->store_msg_crt_idx) +#define H5F_SET_STORE_MSG_CRT_IDX(F, FL) ((F)->shared->store_msg_crt_idx = (FL)) +#define H5F_GRP_BTREE_SHARED(F) ((F)->shared->grp_btree_shared) +#define H5F_SET_GRP_BTREE_SHARED(F, RC) (((F)->shared->grp_btree_shared = (RC)) ? SUCCEED : FAIL) +#define H5F_USE_TMP_SPACE(F) ((F)->shared->fs.use_tmp_space) +#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_addr_le((F)->shared->fs.tmp_addr, (ADDR))) #ifdef H5_HAVE_PARALLEL -#define H5F_COLL_MD_READ(F) ((F)->shared->coll_md_read) +#define H5F_COLL_MD_READ(F) ((F)->shared->coll_md_read) #endif /* H5_HAVE_PARALLEL */ -#define H5F_USE_MDC_LOGGING(F) ((F)->shared->use_mdc_logging) -#define H5F_START_MDC_LOG_ON_ACCESS(F) ((F)->shared->start_mdc_log_on_access) -#define H5F_MDC_LOG_LOCATION(F) ((F)->shared->mdc_log_location) -#define H5F_ALIGNMENT(F) ((F)->shared->alignment) -#define H5F_THRESHOLD(F) ((F)->shared->threshold) -#define H5F_PGEND_META_THRES(F) ((F)->shared->fs.pgend_meta_thres) -#define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) -#define H5F_FIRST_ALLOC_DEALLOC(F) ((F)->shared->first_alloc_dealloc) -#define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) -#define H5F_USE_VFD_SWMR(F) ((F)->shared->vfd_swmr) -#define H5F_VFD_SWMR_MD_EOA(F) ((F)->shared->vfd_swmr_md_eoa) -#define H5F_NULL_FSM_ADDR(F) ((F)->shared->null_fsm_addr) -#define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) -#define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) -#define H5F_VOL_CLS(F) ((F)->shared->vol_cls) -#define H5F_VOL_OBJ(F) ((F)->vol_obj) +#define H5F_USE_MDC_LOGGING(F) ((F)->shared->use_mdc_logging) +#define H5F_START_MDC_LOG_ON_ACCESS(F) ((F)->shared->start_mdc_log_on_access) +#define H5F_MDC_LOG_LOCATION(F) ((F)->shared->mdc_log_location) +#define H5F_ALIGNMENT(F) ((F)->shared->alignment) +#define H5F_THRESHOLD(F) ((F)->shared->threshold) +#define H5F_PGEND_META_THRES(F) ((F)->shared->fs.pgend_meta_thres) +#define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) +#define H5F_FIRST_ALLOC_DEALLOC(F) ((F)->shared->first_alloc_dealloc) +#define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) +#define H5F_USE_VFD_SWMR(F) ((F)->shared->vfd_swmr) +#define H5F_VFD_SWMR_MD_EOA(F) ((F)->shared->vfd_swmr_md_eoa) +#define H5F_NULL_FSM_ADDR(F) ((F)->shared->null_fsm_addr) +#define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) +#define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) +#define H5F_VOL_CLS(F) ((F)->shared->vol_cls) +#define H5F_VOL_OBJ(F) ((F)->vol_obj) #else /* H5F_MODULE */ -#define H5F_LOW_BOUND(F) (H5F_get_low_bound(F)) -#define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F)) -#define H5F_SHARED_INTENT(F_SH) (H5F_shared_get_intent(F_SH)) -#define H5F_INTENT(F) (H5F_get_intent(F)) -#define H5F_OPEN_NAME(F) (H5F_get_open_name(F)) -#define H5F_ACTUAL_NAME(F) (H5F_get_actual_name(F)) -#define H5F_EXTPATH(F) (H5F_get_extpath(F)) -#define H5F_SHARED(F) (H5F_get_shared(F)) -#define H5F_SAME_SHARED(F1, F2) (H5F_same_shared((F1), (F2))) -#define H5F_NOPEN_OBJS(F) (H5F_get_nopen_objs(F)) -#define H5F_INCR_NOPEN_OBJS(F) (H5F_incr_nopen_objs(F)) -#define H5F_DECR_NOPEN_OBJS(F) (H5F_decr_nopen_objs(F)) -#define H5F_ID_EXISTS(F) (H5F_file_id_exists(F)) -#define H5F_PARENT(F) (H5F_get_parent(F)) -#define H5F_NMOUNTS(F) (H5F_get_nmounts(F)) -#define H5F_GET_READ_ATTEMPTS(F) (H5F_get_read_attempts(F)) -#define H5F_DRIVER_ID(F) (H5F_get_driver_id(F)) -#define H5F_GET_FILENO(F,FILENUM) (H5F_get_fileno((F), &(FILENUM))) -#define H5F_SHARED_HAS_FEATURE(F_SH,FL) (H5F_shared_has_feature(F_SH,FL)) -#define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL)) -#define H5F_BASE_ADDR(F) (H5F_get_base_addr(F)) -#define H5F_SYM_LEAF_K(F) (H5F_sym_leaf_k(F)) -#define H5F_KVALUE(F,T) (H5F_Kvalue(F,T)) -#define H5F_NREFS(F) (H5F_get_nrefs(F)) -#define H5F_SIZEOF_ADDR(F) (H5F_sizeof_addr(F)) -#define H5F_SIZEOF_SIZE(F) (H5F_sizeof_size(F)) -#define H5F_SOHM_ADDR(F) (H5F_get_sohm_addr(F)) -#define H5F_SET_SOHM_ADDR(F, A) (H5F_set_sohm_addr((F), (A))) -#define H5F_SOHM_VERS(F) (H5F_get_sohm_vers(F)) -#define H5F_SET_SOHM_VERS(F, V) (H5F_set_sohm_vers((F), (V))) -#define H5F_SOHM_NINDEXES(F) (H5F_get_sohm_nindexes(F)) -#define H5F_SET_SOHM_NINDEXES(F, N) (H5F_set_sohm_nindexes((F), (N))) -#define H5F_FCPL(F) (H5F_get_fcpl(F)) -#define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F)) -#define H5F_EVICT_ON_CLOSE(F) (H5F_get_evict_on_close(F)) -#define H5F_RDCC_NSLOTS(F) (H5F_rdcc_nslots(F)) -#define H5F_RDCC_NBYTES(F) (H5F_rdcc_nbytes(F)) -#define H5F_RDCC_W0(F) (H5F_rdcc_w0(F)) -#define H5F_SIEVE_BUF_SIZE(F) (H5F_sieve_buf_size(F)) -#define H5F_GC_REF(F) (H5F_gc_ref(F)) -#define H5F_STORE_MSG_CRT_IDX(F) (H5F_store_msg_crt_idx(F)) -#define H5F_SET_STORE_MSG_CRT_IDX(F, FL) (H5F_set_store_msg_crt_idx((F), (FL))) -#define H5F_GRP_BTREE_SHARED(F) (H5F_grp_btree_shared(F)) -#define H5F_SET_GRP_BTREE_SHARED(F, RC) (H5F_set_grp_btree_shared((F), (RC))) -#define H5F_USE_TMP_SPACE(F) (H5F_use_tmp_space(F)) -#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_is_tmp_addr((F), (ADDR))) +#define H5F_LOW_BOUND(F) (H5F_get_low_bound(F)) +#define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F)) +#define H5F_SHARED_INTENT(F_SH) (H5F_shared_get_intent(F_SH)) +#define H5F_INTENT(F) (H5F_get_intent(F)) +#define H5F_OPEN_NAME(F) (H5F_get_open_name(F)) +#define H5F_ACTUAL_NAME(F) (H5F_get_actual_name(F)) +#define H5F_EXTPATH(F) (H5F_get_extpath(F)) +#define H5F_SHARED(F) (H5F_get_shared(F)) +#define H5F_SAME_SHARED(F1, F2) (H5F_same_shared((F1), (F2))) +#define H5F_NOPEN_OBJS(F) (H5F_get_nopen_objs(F)) +#define H5F_INCR_NOPEN_OBJS(F) (H5F_incr_nopen_objs(F)) +#define H5F_DECR_NOPEN_OBJS(F) (H5F_decr_nopen_objs(F)) +#define H5F_ID_EXISTS(F) (H5F_file_id_exists(F)) +#define H5F_PARENT(F) (H5F_get_parent(F)) +#define H5F_NMOUNTS(F) (H5F_get_nmounts(F)) +#define H5F_GET_READ_ATTEMPTS(F) (H5F_get_read_attempts(F)) +#define H5F_DRIVER_ID(F) (H5F_get_driver_id(F)) +#define H5F_GET_FILENO(F, FILENUM) (H5F_get_fileno((F), &(FILENUM))) +#define H5F_SHARED_HAS_FEATURE(F_SH, FL) (H5F_shared_has_feature(F_SH, FL)) +#define H5F_HAS_FEATURE(F, FL) (H5F_has_feature(F, FL)) +#define H5F_BASE_ADDR(F) (H5F_get_base_addr(F)) +#define H5F_SYM_LEAF_K(F) (H5F_sym_leaf_k(F)) +#define H5F_KVALUE(F, T) (H5F_Kvalue(F, T)) +#define H5F_NREFS(F) (H5F_get_nrefs(F)) +#define H5F_SIZEOF_ADDR(F) (H5F_sizeof_addr(F)) +#define H5F_SIZEOF_SIZE(F) (H5F_sizeof_size(F)) +#define H5F_SOHM_ADDR(F) (H5F_get_sohm_addr(F)) +#define H5F_SET_SOHM_ADDR(F, A) (H5F_set_sohm_addr((F), (A))) +#define H5F_SOHM_VERS(F) (H5F_get_sohm_vers(F)) +#define H5F_SET_SOHM_VERS(F, V) (H5F_set_sohm_vers((F), (V))) +#define H5F_SOHM_NINDEXES(F) (H5F_get_sohm_nindexes(F)) +#define H5F_SET_SOHM_NINDEXES(F, N) (H5F_set_sohm_nindexes((F), (N))) +#define H5F_FCPL(F) (H5F_get_fcpl(F)) +#define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F)) +#define H5F_EVICT_ON_CLOSE(F) (H5F_get_evict_on_close(F)) +#define H5F_RDCC_NSLOTS(F) (H5F_rdcc_nslots(F)) +#define H5F_RDCC_NBYTES(F) (H5F_rdcc_nbytes(F)) +#define H5F_RDCC_W0(F) (H5F_rdcc_w0(F)) +#define H5F_SIEVE_BUF_SIZE(F) (H5F_sieve_buf_size(F)) +#define H5F_GC_REF(F) (H5F_gc_ref(F)) +#define H5F_STORE_MSG_CRT_IDX(F) (H5F_store_msg_crt_idx(F)) +#define H5F_SET_STORE_MSG_CRT_IDX(F, FL) (H5F_set_store_msg_crt_idx((F), (FL))) +#define H5F_GRP_BTREE_SHARED(F) (H5F_grp_btree_shared(F)) +#define H5F_SET_GRP_BTREE_SHARED(F, RC) (H5F_set_grp_btree_shared((F), (RC))) +#define H5F_USE_TMP_SPACE(F) (H5F_use_tmp_space(F)) +#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_is_tmp_addr((F), (ADDR))) #ifdef H5_HAVE_PARALLEL -#define H5F_COLL_MD_READ(F) (H5F_coll_md_read(F)) +#define H5F_COLL_MD_READ(F) (H5F_coll_md_read(F)) #endif /* H5_HAVE_PARALLEL */ -#define H5F_USE_MDC_LOGGING(F) (H5F_use_mdc_logging(F)) -#define H5F_START_MDC_LOG_ON_ACCESS(F) (H5F_start_mdc_log_on_access(F)) -#define H5F_MDC_LOG_LOCATION(F) (H5F_mdc_log_location(F)) -#define H5F_ALIGNMENT(F) (H5F_get_alignment(F)) -#define H5F_THRESHOLD(F) (H5F_get_threshold(F)) -#define H5F_PGEND_META_THRES(F) (H5F_get_pgend_meta_thres(F)) -#define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) -#define H5F_FIRST_ALLOC_DEALLOC(F) (H5F_get_first_alloc_dealloc(F)) -#define H5F_EOA_PRE_FSM_FSALLOC(F) (H5F_get_eoa_pre_fsm_fsalloc(F)) -#define H5F_USE_VFD_SWMR(F) (H5F_use_vfd_swmr(F)) -#define H5F_NULL_FSM_ADDR(F) (H5F_get_null_fsm_addr(F)) -#define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) -#define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) -#define H5F_VOL_CLS(F) (H5F_get_vol_cls(F)) -#define H5F_VOL_OBJ(F) (H5F_get_vol_obj(F)) +#define H5F_USE_MDC_LOGGING(F) (H5F_use_mdc_logging(F)) +#define H5F_START_MDC_LOG_ON_ACCESS(F) (H5F_start_mdc_log_on_access(F)) +#define H5F_MDC_LOG_LOCATION(F) (H5F_mdc_log_location(F)) +#define H5F_ALIGNMENT(F) (H5F_get_alignment(F)) +#define H5F_THRESHOLD(F) (H5F_get_threshold(F)) +#define H5F_PGEND_META_THRES(F) (H5F_get_pgend_meta_thres(F)) +#define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) +#define H5F_FIRST_ALLOC_DEALLOC(F) (H5F_get_first_alloc_dealloc(F)) +#define H5F_EOA_PRE_FSM_FSALLOC(F) (H5F_get_eoa_pre_fsm_fsalloc(F)) +#define H5F_USE_VFD_SWMR(F) (H5F_use_vfd_swmr(F)) +#define H5F_NULL_FSM_ADDR(F) (H5F_get_null_fsm_addr(F)) +#define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) +#define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) +#define H5F_VOL_CLS(F) (H5F_get_vol_cls(F)) +#define H5F_VOL_OBJ(F) (H5F_get_vol_obj(F)) #endif /* H5F_MODULE */ - /* Macros to encode/decode offset/length's for storing in the file */ -#define H5F_ENCODE_OFFSET(f,p,o) switch(H5F_SIZEOF_ADDR(f)) { \ - case 4: UINT32ENCODE(p,o); break; \ - case 8: UINT64ENCODE(p,o); break; \ - case 2: UINT16ENCODE(p,o); break; \ -} - -#define H5F_DECODE_OFFSET(f,p,o) switch (H5F_SIZEOF_ADDR (f)) { \ - case 4: UINT32DECODE(p, o); break; \ - case 8: UINT64DECODE(p, o); break; \ - case 2: UINT16DECODE(p, o); break; \ -} +#define H5F_ENCODE_OFFSET(f, p, o) \ + switch (H5F_SIZEOF_ADDR(f)) { \ + case 4: \ + UINT32ENCODE(p, o); \ + break; \ + case 8: \ + UINT64ENCODE(p, o); \ + break; \ + case 2: \ + UINT16ENCODE(p, o); \ + break; \ + } -#define H5F_ENCODE_LENGTH_LEN(p,l,s) switch(s) { \ - case 4: UINT32ENCODE(p,l); break; \ - case 8: UINT64ENCODE(p,l); break; \ - case 2: UINT16ENCODE(p,l); break; \ - default: HDassert("bad sizeof size" && 0); \ -} +#define H5F_DECODE_OFFSET(f, p, o) \ + switch (H5F_SIZEOF_ADDR(f)) { \ + case 4: \ + UINT32DECODE(p, o); \ + break; \ + case 8: \ + UINT64DECODE(p, o); \ + break; \ + case 2: \ + UINT16DECODE(p, o); \ + break; \ + } -#define H5F_ENCODE_LENGTH(f,p,l) H5F_ENCODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f)) +#define H5F_ENCODE_LENGTH_LEN(p, l, s) \ + switch (s) { \ + case 4: \ + UINT32ENCODE(p, l); \ + break; \ + case 8: \ + UINT64ENCODE(p, l); \ + break; \ + case 2: \ + UINT16ENCODE(p, l); \ + break; \ + default: \ + HDassert("bad sizeof size" && 0); \ + } -#define H5F_DECODE_LENGTH_LEN(p,l,s) switch(s) { \ - case 4: UINT32DECODE(p,l); break; \ - case 8: UINT64DECODE(p,l); break; \ - case 2: UINT16DECODE(p,l); break; \ - default: HDassert("bad sizeof size" && 0); \ -} +#define H5F_ENCODE_LENGTH(f, p, l) H5F_ENCODE_LENGTH_LEN(p, l, H5F_SIZEOF_SIZE(f)) + +#define H5F_DECODE_LENGTH_LEN(p, l, s) \ + switch (s) { \ + case 4: \ + UINT32DECODE(p, l); \ + break; \ + case 8: \ + UINT64DECODE(p, l); \ + break; \ + case 2: \ + UINT16DECODE(p, l); \ + break; \ + default: \ + HDassert("bad sizeof size" && 0); \ + } -#define H5F_DECODE_LENGTH(f,p,l) DECODE_VAR(p,l,H5F_SIZEOF_SIZE(f)) +#define H5F_DECODE_LENGTH(f, p, l) DECODE_VAR(p, l, H5F_SIZEOF_SIZE(f)) /* * Macros that check for overflows. These are somewhat dangerous to fiddle * with. */ #if (H5_SIZEOF_SIZE_T >= H5_SIZEOF_OFF_T) -# define H5F_OVERFLOW_SIZET2OFFT(X) \ - ((size_t)(X)>=(size_t)((size_t)1<<(8*sizeof(HDoff_t)-1))) +#define H5F_OVERFLOW_SIZET2OFFT(X) ((size_t)(X) >= (size_t)((size_t)1 << (8 * sizeof(HDoff_t) - 1))) #else -# define H5F_OVERFLOW_SIZET2OFFT(X) 0 +#define H5F_OVERFLOW_SIZET2OFFT(X) 0 #endif #if (H5_SIZEOF_HSIZE_T >= H5_SIZEOF_OFF_T) -# define H5F_OVERFLOW_HSIZET2OFFT(X) \ - ((hsize_t)(X) >= (hsize_t)((hsize_t)1 << (8 * sizeof(HDoff_t) - 1))) +#define H5F_OVERFLOW_HSIZET2OFFT(X) ((hsize_t)(X) >= (hsize_t)((hsize_t)1 << (8 * sizeof(HDoff_t) - 1))) #else -# define H5F_OVERFLOW_HSIZET2OFFT(X) 0 +#define H5F_OVERFLOW_HSIZET2OFFT(X) 0 #endif /* Sizes of object addresses & sizes in the file (in bytes) */ -#define H5F_OBJ_ADDR_SIZE sizeof(haddr_t) -#define H5F_OBJ_SIZE_SIZE sizeof(hsize_t) +#define H5F_OBJ_ADDR_SIZE sizeof(haddr_t) +#define H5F_OBJ_SIZE_SIZE sizeof(hsize_t) /* File-wide default character encoding can not yet be set via the file * creation property list and is always ASCII. */ #define H5F_DEFAULT_CSET H5T_CSET_ASCII /* ========= File Creation properties ============ */ -#define H5F_CRT_USER_BLOCK_NAME "block_size" /* Size of the file user block in bytes */ -#define H5F_CRT_SYM_LEAF_NAME "symbol_leaf" /* 1/2 rank for symbol table leaf nodes */ -#define H5F_CRT_SYM_LEAF_DEF 4 -#define H5F_CRT_BTREE_RANK_NAME "btree_rank" /* 1/2 rank for btree internal nodes */ -#define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" /* Byte number in an address */ -#define H5F_CRT_OBJ_BYTE_NUM_NAME "obj_byte_num" /* Byte number for object size */ -#define H5F_CRT_SUPER_VERS_NAME "super_version" /* Version number of the superblock */ -#define H5F_CRT_SHMSG_NINDEXES_NAME "num_shmsg_indexes" /* Number of shared object header message indexes */ -#define H5F_CRT_SHMSG_INDEX_TYPES_NAME "shmsg_message_types" /* Types of message in each index */ -#define H5F_CRT_SHMSG_INDEX_MINSIZE_NAME "shmsg_message_minsize" /* Minimum size of messages in each index */ -#define H5F_CRT_SHMSG_LIST_MAX_NAME "shmsg_list_max" /* Shared message list maximum size */ -#define H5F_CRT_SHMSG_BTREE_MIN_NAME "shmsg_btree_min" /* Shared message B-tree minimum size */ -#define H5F_CRT_FILE_SPACE_STRATEGY_NAME "file_space_strategy" /* File space handling strategy */ -#define H5F_CRT_FREE_SPACE_PERSIST_NAME "free_space_persist" /* Free-space persisting status */ -#define H5F_CRT_FREE_SPACE_THRESHOLD_NAME "free_space_threshold" /* Free space section threshold */ -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME "file_space_page_size" /* File space page size */ - - +#define H5F_CRT_USER_BLOCK_NAME "block_size" /* Size of the file user block in bytes */ +#define H5F_CRT_SYM_LEAF_NAME "symbol_leaf" /* 1/2 rank for symbol table leaf nodes */ +#define H5F_CRT_SYM_LEAF_DEF 4 +#define H5F_CRT_BTREE_RANK_NAME "btree_rank" /* 1/2 rank for btree internal nodes */ +#define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" /* Byte number in an address */ +#define H5F_CRT_OBJ_BYTE_NUM_NAME "obj_byte_num" /* Byte number for object size */ +#define H5F_CRT_SUPER_VERS_NAME "super_version" /* Version number of the superblock */ +#define H5F_CRT_SHMSG_NINDEXES_NAME "num_shmsg_indexes" /* Number of shared object header message indexes */ +#define H5F_CRT_SHMSG_INDEX_TYPES_NAME "shmsg_message_types" /* Types of message in each index */ +#define H5F_CRT_SHMSG_INDEX_MINSIZE_NAME "shmsg_message_minsize" /* Minimum size of messages in each index \ + */ +#define H5F_CRT_SHMSG_LIST_MAX_NAME "shmsg_list_max" /* Shared message list maximum size */ +#define H5F_CRT_SHMSG_BTREE_MIN_NAME "shmsg_btree_min" /* Shared message B-tree minimum size */ +#define H5F_CRT_FILE_SPACE_STRATEGY_NAME "file_space_strategy" /* File space handling strategy */ +#define H5F_CRT_FREE_SPACE_PERSIST_NAME "free_space_persist" /* Free-space persisting status */ +#define H5F_CRT_FREE_SPACE_THRESHOLD_NAME "free_space_threshold" /* Free space section threshold */ +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME "file_space_page_size" /* File space page size */ /* ========= File Access properties ============ */ -#define H5F_ACS_META_CACHE_INIT_CONFIG_NAME "mdc_initCacheCfg" /* Initial metadata cache resize configuration */ -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ -#define H5F_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ -#define H5F_ACS_ALIGN_THRHD_NAME "threshold" /* Threshold for alignment */ -#define H5F_ACS_ALIGN_NAME "align" /* Alignment */ -#define H5F_ACS_META_BLOCK_SIZE_NAME "meta_block_size" /* Minimum metadata allocation block size (when aggregating metadata allocations) */ -#define H5F_ACS_SIEVE_BUF_SIZE_NAME "sieve_buf_size" /* Maximum sieve buffer size (when data sieving is allowed by file driver) */ -#define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */ -#define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ -#define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ -#define H5F_ACS_VOL_CONN_NAME "vol_connector_info" /* VOL connector ID & info */ -#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ -#define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ -#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ -#define H5F_ACS_FAMILY_TO_SINGLE_NAME "family_to_single" /* Whether to convert family to a single-file driver. (private property only used by h5repart) */ -#define H5F_ACS_MULTI_TYPE_NAME "multi_type" /* Data type in multi file driver */ -#define H5F_ACS_LIBVER_LOW_BOUND_NAME "libver_low_bound" /* 'low' bound of library format versions */ -#define H5F_ACS_LIBVER_HIGH_BOUND_NAME "libver_high_bound" /* 'high' bound of library format versions */ -#define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */ -#define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */ -#define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */ -#define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */ -#define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */ -#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) */ -#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" /* Nullify addresses of free-space managers */ - /* Private property used only by h5clear */ -#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" /* Skip EOF check */ - /* Private property used only by h5clear */ -#define H5F_ACS_USE_MDC_LOGGING_NAME "use_mdc_logging" /* Whether to use metadata cache logging */ -#define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */ -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME "start_mdc_log_on_access" /* Whether logging starts on file create/open */ -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME "evict_on_close_flag" /* Whether or not the metadata cache will evict objects on close */ -#define H5F_ACS_COLL_MD_WRITE_FLAG_NAME "collective_metadata_write" /* property indicating whether metadata writes are done collectively or not */ -#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME "mdc_initCacheImageCfg" /* Initial metadata cache image creation configuration */ -#define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */ -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME "page_buffer_min_meta_perc" /* the min metadata percentage for the page buffer cache */ -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME "page_buffer_min_raw_perc" /* the min raw data percentage for the page buffer cache */ +#define H5F_ACS_META_CACHE_INIT_CONFIG_NAME \ + "mdc_initCacheCfg" /* Initial metadata cache resize configuration */ +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ +#define H5F_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ +#define H5F_ACS_ALIGN_THRHD_NAME "threshold" /* Threshold for alignment */ +#define H5F_ACS_ALIGN_NAME "align" /* Alignment */ +#define H5F_ACS_META_BLOCK_SIZE_NAME \ + "meta_block_size" /* Minimum metadata allocation block size (when aggregating metadata allocations) */ +#define H5F_ACS_SIEVE_BUF_SIZE_NAME \ + "sieve_buf_size" /* Maximum sieve buffer size (when data sieving is allowed by file driver) */ +#define H5F_ACS_SDATA_BLOCK_SIZE_NAME \ + "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data \ + allocations) */ +#define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ +#define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ +#define H5F_ACS_VOL_CONN_NAME "vol_connector_info" /* VOL connector ID & info */ +#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ +#define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ +#define H5F_ACS_FAMILY_NEWSIZE_NAME \ + "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ +#define H5F_ACS_FAMILY_TO_SINGLE_NAME \ + "family_to_single" /* Whether to convert family to a single-file driver. (private property only used by \ + h5repart) */ +#define H5F_ACS_MULTI_TYPE_NAME "multi_type" /* Data type in multi file driver */ +#define H5F_ACS_LIBVER_LOW_BOUND_NAME "libver_low_bound" /* 'low' bound of library format versions */ +#define H5F_ACS_LIBVER_HIGH_BOUND_NAME "libver_high_bound" /* 'high' bound of library format versions */ +#define H5F_ACS_WANT_POSIX_FD_NAME \ + "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address \ + */ +#define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */ +#define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */ +#define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */ +#define H5F_ACS_FILE_IMAGE_INFO_NAME \ + "file_image_info" /* struct containing initial file image and callback info */ +#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME \ + "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) \ + */ +#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" /* Nullify addresses of free-space managers */ + /* Private property used only by h5clear */ +#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" /* Skip EOF check */ + /* Private property used only by h5clear */ +#define H5F_ACS_USE_MDC_LOGGING_NAME "use_mdc_logging" /* Whether to use metadata cache logging */ +#define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */ +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME \ + "start_mdc_log_on_access" /* Whether logging starts on file create/open */ +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME \ + "evict_on_close_flag" /* Whether or not the metadata cache will evict objects on close */ +#define H5F_ACS_COLL_MD_WRITE_FLAG_NAME \ + "collective_metadata_write" /* property indicating whether metadata writes are done collectively or not \ + */ +#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME \ + "mdc_initCacheImageCfg" /* Initial metadata cache image creation configuration */ +#define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */ +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME \ + "page_buffer_min_meta_perc" /* the min metadata percentage for the page buffer cache */ +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME \ + "page_buffer_min_raw_perc" /* the min raw data percentage for the page buffer cache */ #ifdef H5_HAVE_PARALLEL -#define H5F_ACS_MPI_PARAMS_COMM_NAME "mpi_params_comm" /* the MPI communicator */ -#define H5F_ACS_MPI_PARAMS_INFO_NAME "mpi_params_info" /* the MPI info struct */ -#endif /* H5_HAVE_PARALLEL */ +#define H5F_ACS_MPI_PARAMS_COMM_NAME "mpi_params_comm" /* the MPI communicator */ +#define H5F_ACS_MPI_PARAMS_INFO_NAME "mpi_params_info" /* the MPI info struct */ +#endif /* H5_HAVE_PARALLEL */ /* Default configuration for VFD SWMR: not configured */ -#define H5F_ACS_VFD_SWMR_CONFIG_NAME "vfd_swmr_config" -#define H5F__DEFAULT_VFD_SWMR_CONFIG \ -{ \ - /* int32_t version = */ 0, \ - /* int32_t tick_len = */ 0, \ - /* int32_t max_lag = */ 0, \ - /* hbool_t vfd_swmr_writer = */ FALSE, \ - /* hbool_t flush_raw_data = */ FALSE, \ - /* int32_t md_pages_reserved = */ 0, \ - /* int32_t pb_expansion_threshold = */ 0, \ - /* char md_file_path[] = */ "", \ - /* char log_file_path[] = */ "" \ -} +#define H5F_ACS_VFD_SWMR_CONFIG_NAME "vfd_swmr_config" +#define H5F__DEFAULT_VFD_SWMR_CONFIG \ + { \ + /* int32_t version = */ 0, /* int32_t tick_len = */ 0, \ + /* int32_t max_lag = */ 0, /* hbool_t vfd_swmr_writer = */ FALSE, \ + /* hbool_t flush_raw_data = */ FALSE, /* int32_t md_pages_reserved = */ 0, \ + /* int32_t pb_expansion_threshold = */ 0, /* char md_file_path[] = */ "", \ + /* char log_file_path[] = */ "" \ + } /* ======================== File Mount properties ====================*/ -#define H5F_MNT_SYM_LOCAL_NAME "local" /* Whether absolute symlinks local to file. */ - +#define H5F_MNT_SYM_LOCAL_NAME "local" /* Whether absolute symlinks local to file. */ #ifdef H5_HAVE_PARALLEL /* Which process writes metadata */ @@ -569,126 +640,128 @@ uint64_decode(uint8_t **pp) #endif /* H5_HAVE_PARALLEL */ /* Define the HDF5 file signature */ -#define H5F_SIGNATURE "\211HDF\r\n\032\n" +#define H5F_SIGNATURE "\211HDF\r\n\032\n" #define H5F_SIGNATURE_LEN 8 /* Version #'s of the major components of the file format */ -#define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */ -#define HDF5_SUPERBLOCK_VERSION_1 1 /* Version with non-default B-tree 'K' value */ -#define HDF5_SUPERBLOCK_VERSION_2 2 /* Revised version with superblock extension and checksum */ -#define HDF5_SUPERBLOCK_VERSION_3 3 /* With file locking and consistency flags (at least this version for SWMR support) */ -#define HDF5_SUPERBLOCK_VERSION_LATEST HDF5_SUPERBLOCK_VERSION_3 /* The maximum super block format */ -#define HDF5_SUPERBLOCK_VERSION_V18_LATEST HDF5_SUPERBLOCK_VERSION_2 /* The latest superblock version for v18 */ -#define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */ -#define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */ -#define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */ -#define HDF5_DRIVERINFO_VERSION_0 0 /* of the Driver Information Block*/ +#define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */ +#define HDF5_SUPERBLOCK_VERSION_1 1 /* Version with non-default B-tree 'K' value */ +#define HDF5_SUPERBLOCK_VERSION_2 2 /* Revised version with superblock extension and checksum */ +#define HDF5_SUPERBLOCK_VERSION_3 \ + 3 /* With file locking and consistency flags (at least this version for SWMR support) */ +#define HDF5_SUPERBLOCK_VERSION_LATEST HDF5_SUPERBLOCK_VERSION_3 /* The maximum super block format */ +#define HDF5_SUPERBLOCK_VERSION_V18_LATEST \ + HDF5_SUPERBLOCK_VERSION_2 /* The latest superblock version for v18 */ +#define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */ +#define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */ +#define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */ +#define HDF5_DRIVERINFO_VERSION_0 0 /* of the Driver Information Block*/ /* B-tree internal 'K' values */ -#define HDF5_BTREE_SNODE_IK_DEF 16 -#define HDF5_BTREE_CHUNK_IK_DEF 32 /* Note! this value is assumed - to be 32 for version 0 - of the superblock and - if it is changed, the code - must compensate. -QAK - */ -#define HDF5_BTREE_IK_MAX_ENTRIES 65536 /* 2^16 - 2 bytes for storing entries (children) */ - /* See format specification on version 1 B-trees */ +#define HDF5_BTREE_SNODE_IK_DEF 16 +#define HDF5_BTREE_CHUNK_IK_DEF \ + 32 /* Note! this value is assumed \ + to be 32 for version 0 \ + of the superblock and \ + if it is changed, the code \ + must compensate. -QAK \ + */ +#define HDF5_BTREE_IK_MAX_ENTRIES 65536 /* 2^16 - 2 bytes for storing entries (children) */ + /* See format specification on version 1 B-trees */ /* Default file space handling strategy */ -#define H5F_FILE_SPACE_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR +#define H5F_FILE_SPACE_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR /* Default free space section threshold used by free-space managers */ -#define H5F_FREE_SPACE_PERSIST_DEF FALSE +#define H5F_FREE_SPACE_PERSIST_DEF FALSE /* Default free space section threshold used by free-space managers */ -#define H5F_FREE_SPACE_THRESHOLD_DEF 1 +#define H5F_FREE_SPACE_THRESHOLD_DEF 1 /* For paged aggregation: default file space page size when not set */ -#define H5F_FILE_SPACE_PAGE_SIZE_DEF 4096 +#define H5F_FILE_SPACE_PAGE_SIZE_DEF 4096 /* For paged aggregation: minimum value for file space page size */ -#define H5F_FILE_SPACE_PAGE_SIZE_MIN 512 +#define H5F_FILE_SPACE_PAGE_SIZE_MIN 512 /* For paged aggregation: maximum value for file space page size: 1 gigabyte */ -#define H5F_FILE_SPACE_PAGE_SIZE_MAX 1024*1024*1024 +#define H5F_FILE_SPACE_PAGE_SIZE_MAX 1024 * 1024 * 1024 /* For paged aggregation: drop free-space with size <= this threshold for small meta section */ -#define H5F_FILE_SPACE_PGEND_META_THRES 0 +#define H5F_FILE_SPACE_PGEND_META_THRES 0 /* Default for threshold for alignment (can be set via H5Pset_alignment()) */ -#define H5F_ALIGN_DEF 1 +#define H5F_ALIGN_DEF 1 /* Default for alignment (can be set via H5Pset_alignment()) */ -#define H5F_ALIGN_THRHD_DEF 1 +#define H5F_ALIGN_THRHD_DEF 1 /* Default size for meta data aggregation block (can be set via H5Pset_meta_block_size()) */ -#define H5F_META_BLOCK_SIZE_DEF 2048 +#define H5F_META_BLOCK_SIZE_DEF 2048 /* Default size for small data aggregation block (can be set via H5Pset_small_data_block_size()) */ -#define H5F_SDATA_BLOCK_SIZE_DEF 2048 +#define H5F_SDATA_BLOCK_SIZE_DEF 2048 /* Check for file using paged aggregation */ #define H5F_SHARED_PAGED_AGGR(F_SH) ((F_SH)->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && (F_SH)->fs_page_size) -#define H5F_PAGED_AGGR(F) (F->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && F->shared->fs_page_size) +#define H5F_PAGED_AGGR(F) (F->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && F->shared->fs_page_size) /* Check for file configured with VFD SWMR */ -#define H5F_SHARED_VFD_SWMR_CONFIG(S) (S->vfd_swmr_config.version >= H5F__CURR_VFD_SWMR_CONFIG_VERSION) -#define H5F_VFD_SWMR_CONFIG(F) H5F_SHARED_VFD_SWMR_CONFIG(F->shared) +#define H5F_SHARED_VFD_SWMR_CONFIG(S) (S->vfd_swmr_config.version >= H5F__CURR_VFD_SWMR_CONFIG_VERSION) +#define H5F_VFD_SWMR_CONFIG(F) H5F_SHARED_VFD_SWMR_CONFIG(F->shared) /* Metadata read attempt values */ -#define H5F_METADATA_READ_ATTEMPTS 1 /* Default # of read attempts for non-SWMR access */ -#define H5F_SWMR_METADATA_READ_ATTEMPTS 100 /* Default # of read attempts for SWMR access */ - +#define H5F_METADATA_READ_ATTEMPTS 1 /* Default # of read attempts for non-SWMR access */ +#define H5F_SWMR_METADATA_READ_ATTEMPTS 100 /* Default # of read attempts for SWMR access */ /* Macros to define signatures of all objects in the file */ /* Size of signature information (on disk) */ /* (all on-disk signatures should be this length) */ -#define H5_SIZEOF_MAGIC 4 +#define H5_SIZEOF_MAGIC 4 /* Size of checksum information (on disk) */ /* (all on-disk checksums should be this length) */ -#define H5_SIZEOF_CHKSUM 4 +#define H5_SIZEOF_CHKSUM 4 /* v1 B-tree node signature */ -#define H5B_MAGIC "TREE" +#define H5B_MAGIC "TREE" /* v2 B-tree signatures */ -#define H5B2_HDR_MAGIC "BTHD" /* Header */ -#define H5B2_INT_MAGIC "BTIN" /* Internal node */ -#define H5B2_LEAF_MAGIC "BTLF" /* Leaf node */ +#define H5B2_HDR_MAGIC "BTHD" /* Header */ +#define H5B2_INT_MAGIC "BTIN" /* Internal node */ +#define H5B2_LEAF_MAGIC "BTLF" /* Leaf node */ /* Extensible array signatures */ -#define H5EA_HDR_MAGIC "EAHD" /* Header */ -#define H5EA_IBLOCK_MAGIC "EAIB" /* Index block */ -#define H5EA_SBLOCK_MAGIC "EASB" /* Super block */ -#define H5EA_DBLOCK_MAGIC "EADB" /* Data block */ +#define H5EA_HDR_MAGIC "EAHD" /* Header */ +#define H5EA_IBLOCK_MAGIC "EAIB" /* Index block */ +#define H5EA_SBLOCK_MAGIC "EASB" /* Super block */ +#define H5EA_DBLOCK_MAGIC "EADB" /* Data block */ /* Fixed array signatures */ -#define H5FA_HDR_MAGIC "FAHD" /* Header */ -#define H5FA_DBLOCK_MAGIC "FADB" /* Data block */ +#define H5FA_HDR_MAGIC "FAHD" /* Header */ +#define H5FA_DBLOCK_MAGIC "FADB" /* Data block */ /* Free space signatures */ -#define H5FS_HDR_MAGIC "FSHD" /* Header */ -#define H5FS_SINFO_MAGIC "FSSE" /* Serialized sections */ +#define H5FS_HDR_MAGIC "FSHD" /* Header */ +#define H5FS_SINFO_MAGIC "FSSE" /* Serialized sections */ /* Symbol table node signature */ -#define H5G_NODE_MAGIC "SNOD" +#define H5G_NODE_MAGIC "SNOD" /* Fractal heap signatures */ -#define H5HF_HDR_MAGIC "FRHP" /* Header */ -#define H5HF_IBLOCK_MAGIC "FHIB" /* Indirect block */ -#define H5HF_DBLOCK_MAGIC "FHDB" /* Direct block */ +#define H5HF_HDR_MAGIC "FRHP" /* Header */ +#define H5HF_IBLOCK_MAGIC "FHIB" /* Indirect block */ +#define H5HF_DBLOCK_MAGIC "FHDB" /* Direct block */ /* Global heap signature */ -#define H5HG_MAGIC "GCOL" +#define H5HG_MAGIC "GCOL" /* Local heap signature */ -#define H5HL_MAGIC "HEAP" +#define H5HL_MAGIC "HEAP" /* Object header signatures */ -#define H5O_HDR_MAGIC "OHDR" /* Header */ -#define H5O_CHK_MAGIC "OCHK" /* Continuation chunk */ +#define H5O_HDR_MAGIC "OHDR" /* Header */ +#define H5O_CHK_MAGIC "OCHK" /* Continuation chunk */ /* Shared Message signatures */ -#define H5SM_TABLE_MAGIC "SMTB" /* Shared Message Table */ -#define H5SM_LIST_MAGIC "SMLI" /* Shared Message List */ +#define H5SM_TABLE_MAGIC "SMTB" /* Shared Message Table */ +#define H5SM_LIST_MAGIC "SMLI" /* Shared Message List */ /****************************/ /* Library Private Typedefs */ @@ -712,59 +785,57 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; /* Structure for object flush callback property (H5Pset_object_flush_cb)*/ typedef struct H5F_object_flush_t { - H5F_flush_cb_t func; /* The callback function */ - void *udata; /* User data */ + H5F_flush_cb_t func; /* The callback function */ + void * udata; /* User data */ } H5F_object_flush_t; /* Concise info about a block of bytes in a file */ typedef struct H5F_block_t { - haddr_t offset; /* Offset of the block in the file */ - hsize_t length; /* Length of the block in the file */ + haddr_t offset; /* Offset of the block in the file */ + hsize_t length; /* Length of the block in the file */ } H5F_block_t; /* Enum for free space manager state */ typedef enum H5F_fs_state_t { - H5F_FS_STATE_CLOSED = 0, /* Free space manager is closed */ - H5F_FS_STATE_OPEN = 1, /* Free space manager has been opened */ - H5F_FS_STATE_DELETING = 2 /* Free space manager is being deleted */ + H5F_FS_STATE_CLOSED = 0, /* Free space manager is closed */ + H5F_FS_STATE_OPEN = 1, /* Free space manager has been opened */ + H5F_FS_STATE_DELETING = 2 /* Free space manager is being deleted */ } H5F_fs_state_t; /* For paged aggregation */ /* The values 0 to 6 is the same as H5F_mem_t */ typedef enum H5F_mem_page_t { - H5F_MEM_PAGE_DEFAULT = 0, /* Not used */ - H5F_MEM_PAGE_SUPER = 1, - H5F_MEM_PAGE_BTREE = 2, - H5F_MEM_PAGE_DRAW = 3, - H5F_MEM_PAGE_GHEAP = 4, - H5F_MEM_PAGE_LHEAP = 5, - H5F_MEM_PAGE_OHDR = 6, + H5F_MEM_PAGE_DEFAULT = 0, /* Not used */ + H5F_MEM_PAGE_SUPER = 1, + H5F_MEM_PAGE_BTREE = 2, + H5F_MEM_PAGE_DRAW = 3, + H5F_MEM_PAGE_GHEAP = 4, + H5F_MEM_PAGE_LHEAP = 5, + H5F_MEM_PAGE_OHDR = 6, H5F_MEM_PAGE_LARGE_SUPER = 7, H5F_MEM_PAGE_LARGE_BTREE = 8, - H5F_MEM_PAGE_LARGE_DRAW = 9, + H5F_MEM_PAGE_LARGE_DRAW = 9, H5F_MEM_PAGE_LARGE_GHEAP = 10, H5F_MEM_PAGE_LARGE_LHEAP = 11, - H5F_MEM_PAGE_LARGE_OHDR = 12, - H5F_MEM_PAGE_NTYPES = 13 /* Sentinel value - must be last */ + H5F_MEM_PAGE_LARGE_OHDR = 12, + H5F_MEM_PAGE_NTYPES = 13 /* Sentinel value - must be last */ } H5F_mem_page_t; /* Aliases for H5F_mem_page_t enum values */ -#define H5F_MEM_PAGE_META H5F_MEM_PAGE_SUPER /* Small-sized meta data */ -#define H5F_MEM_PAGE_GENERIC H5F_MEM_PAGE_LARGE_SUPER /* Large-sized generic: meta and raw */ +#define H5F_MEM_PAGE_META H5F_MEM_PAGE_SUPER /* Small-sized meta data */ +#define H5F_MEM_PAGE_GENERIC H5F_MEM_PAGE_LARGE_SUPER /* Large-sized generic: meta and raw */ /* Type of prefix for opening prefixed files */ typedef enum H5F_prefix_open_t { - H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ - H5F_PREFIX_ELINK = 1, /* External link prefix */ - H5F_PREFIX_EFILE = 2 /* External file prefix */ + H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ + H5F_PREFIX_ELINK = 1, /* External link prefix */ + H5F_PREFIX_EFILE = 2 /* External file prefix */ } H5F_prefix_open_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -772,93 +843,96 @@ typedef enum H5F_prefix_open_t { /* Private functions */ H5_DLL herr_t H5F_init(void); H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); -H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); -H5_DLL hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref); +H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/); +H5_DLL hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref); /* Functions that retrieve values from the file struct */ H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f); H5_DLL H5F_libver_t H5F_get_high_bound(const H5F_t *f); -H5_DLL unsigned H5F_shared_get_intent(const H5F_shared_t *f); -H5_DLL unsigned H5F_get_intent(const H5F_t *f); -H5_DLL char *H5F_get_open_name(const H5F_t *f); -H5_DLL char *H5F_get_actual_name(const H5F_t *f); -H5_DLL char *H5F_get_extpath(const H5F_t *f); +H5_DLL unsigned H5F_shared_get_intent(const H5F_shared_t *f); +H5_DLL unsigned H5F_get_intent(const H5F_t *f); +H5_DLL char * H5F_get_open_name(const H5F_t *f); +H5_DLL char * H5F_get_actual_name(const H5F_t *f); +H5_DLL char * H5F_get_extpath(const H5F_t *f); H5_DLL H5F_shared_t *H5F_get_shared(const H5F_t *f); -H5_DLL hbool_t H5F_same_shared(const H5F_t *f1, const H5F_t *f2); -H5_DLL unsigned H5F_get_nopen_objs(const H5F_t *f); -H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f); -H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f); -H5_DLL hbool_t H5F_file_id_exists(const H5F_t *f); -H5_DLL H5F_t *H5F_get_parent(const H5F_t *f); +H5_DLL hbool_t H5F_same_shared(const H5F_t *f1, const H5F_t *f2); +H5_DLL unsigned H5F_get_nopen_objs(const H5F_t *f); +H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f); +H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f); +H5_DLL hbool_t H5F_file_id_exists(const H5F_t *f); +H5_DLL H5F_t * H5F_get_parent(const H5F_t *f); H5_DLL unsigned H5F_get_nmounts(const H5F_t *f); H5_DLL unsigned H5F_get_read_attempts(const H5F_t *f); -H5_DLL hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref); -H5_DLL hid_t H5F_get_id(H5F_t *file); -H5_DLL herr_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr); -H5_DLL herr_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list, hbool_t app_ref, size_t *obj_id_count_ptr); -H5_DLL hsize_t H5F_get_pgend_meta_thres(const H5F_t *f); -H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f); -H5_DLL hbool_t H5F_get_null_fsm_addr(const H5F_t *f); -H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f); -H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize); +H5_DLL hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref); +H5_DLL hid_t H5F_get_id(H5F_t *file); +H5_DLL herr_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr); +H5_DLL herr_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list, + hbool_t app_ref, size_t *obj_id_count_ptr); +H5_DLL hsize_t H5F_get_pgend_meta_thres(const H5F_t *f); +H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f); +H5_DLL hbool_t H5F_get_null_fsm_addr(const H5F_t *f); +H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f); +H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize); H5_DLL const H5VL_class_t *H5F_get_vol_cls(const H5F_t *f); H5_DLL H5VL_object_t *H5F_get_vol_obj(const H5F_t *f); /* Functions than retrieve values set/cached from the superblock/FCPL */ -H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); -H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); -H5_DLL unsigned H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); -H5_DLL unsigned H5F_get_nrefs(const H5F_t *f); -H5_DLL uint8_t H5F_sizeof_addr(const H5F_t *f); -H5_DLL uint8_t H5F_sizeof_size(const H5F_t *f); -H5_DLL haddr_t H5F_get_sohm_addr(const H5F_t *f); -H5_DLL herr_t H5F_set_sohm_addr(H5F_t *f, haddr_t addr); -H5_DLL unsigned H5F_get_sohm_vers(const H5F_t *f); -H5_DLL herr_t H5F_set_sohm_vers(H5F_t *f, unsigned vers); -H5_DLL unsigned H5F_get_sohm_nindexes(const H5F_t *f); -H5_DLL herr_t H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes); -H5_DLL hid_t H5F_get_fcpl(const H5F_t *f); +H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); +H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); +H5_DLL unsigned H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); +H5_DLL unsigned H5F_get_nrefs(const H5F_t *f); +H5_DLL uint8_t H5F_sizeof_addr(const H5F_t *f); +H5_DLL uint8_t H5F_sizeof_size(const H5F_t *f); +H5_DLL haddr_t H5F_get_sohm_addr(const H5F_t *f); +H5_DLL herr_t H5F_set_sohm_addr(H5F_t *f, haddr_t addr); +H5_DLL unsigned H5F_get_sohm_vers(const H5F_t *f); +H5_DLL herr_t H5F_set_sohm_vers(H5F_t *f, unsigned vers); +H5_DLL unsigned H5F_get_sohm_nindexes(const H5F_t *f); +H5_DLL herr_t H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes); +H5_DLL hid_t H5F_get_fcpl(const H5F_t *f); H5_DLL H5F_close_degree_t H5F_get_fc_degree(const H5F_t *f); -H5_DLL hbool_t H5F_get_evict_on_close(const H5F_t *f); -H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f); -H5_DLL size_t H5F_rdcc_nslots(const H5F_t *f); -H5_DLL double H5F_rdcc_w0(const H5F_t *f); -H5_DLL size_t H5F_sieve_buf_size(const H5F_t *f); -H5_DLL unsigned H5F_gc_ref(const H5F_t *f); -H5_DLL hbool_t H5F_store_msg_crt_idx(const H5F_t *f); -H5_DLL herr_t H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag); -H5_DLL struct H5UC_t *H5F_grp_btree_shared(const H5F_t *f); -H5_DLL herr_t H5F_set_grp_btree_shared(H5F_t *f, struct H5UC_t *rc); -H5_DLL hbool_t H5F_use_tmp_space(const H5F_t *f); -H5_DLL hbool_t H5F_is_tmp_addr(const H5F_t *f, haddr_t addr); -H5_DLL hsize_t H5F_get_alignment(const H5F_t *f); -H5_DLL hsize_t H5F_get_threshold(const H5F_t *f); +H5_DLL hbool_t H5F_get_evict_on_close(const H5F_t *f); +H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f); +H5_DLL size_t H5F_rdcc_nslots(const H5F_t *f); +H5_DLL double H5F_rdcc_w0(const H5F_t *f); +H5_DLL size_t H5F_sieve_buf_size(const H5F_t *f); +H5_DLL unsigned H5F_gc_ref(const H5F_t *f); +H5_DLL hbool_t H5F_store_msg_crt_idx(const H5F_t *f); +H5_DLL herr_t H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag); +H5_DLL struct H5UC_t * H5F_grp_btree_shared(const H5F_t *f); +H5_DLL herr_t H5F_set_grp_btree_shared(H5F_t *f, struct H5UC_t *rc); +H5_DLL hbool_t H5F_use_tmp_space(const H5F_t *f); +H5_DLL hbool_t H5F_is_tmp_addr(const H5F_t *f, haddr_t addr); +H5_DLL hsize_t H5F_get_alignment(const H5F_t *f); +H5_DLL hsize_t H5F_get_threshold(const H5F_t *f); #ifdef H5_HAVE_PARALLEL H5_DLL H5P_coll_md_read_flag_t H5F_coll_md_read(const H5F_t *f); #endif /* H5_HAVE_PARALLEL */ H5_DLL hbool_t H5F_use_mdc_logging(const H5F_t *f); H5_DLL hbool_t H5F_start_mdc_log_on_access(const H5F_t *f); -H5_DLL char *H5F_mdc_log_location(const H5F_t *f); +H5_DLL char * H5F_mdc_log_location(const H5F_t *f); /* Functions that retrieve values from VFD layer */ -H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); -H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); +H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); +H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); H5_DLL hbool_t H5F_shared_has_feature(const H5F_shared_t *f, unsigned feature); H5_DLL hbool_t H5F_has_feature(const H5F_t *f, unsigned feature); H5_DLL haddr_t H5F_shared_get_eoa(const H5F_shared_t *f_sh, H5FD_mem_t type); H5_DLL haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type); -H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle); +H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle); /* Functions that check file mounting information */ H5_DLL hbool_t H5F_is_mount(const H5F_t *file); H5_DLL hbool_t H5F_has_mount(const H5F_t *file); -H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc/*in,out*/); -H5_DLL herr_t H5F_flush_mounts(H5F_t *f); +H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc /*in,out*/); +H5_DLL herr_t H5F_flush_mounts(H5F_t *f); /* Functions that operate on blocks of bytes wrt super block */ -H5_DLL herr_t H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); -H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); -H5_DLL herr_t H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); +H5_DLL herr_t H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, + void *buf /*out*/); +H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/); +H5_DLL herr_t H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, + const void *buf); H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); /* Functions that flush or evict */ @@ -895,15 +969,15 @@ H5_DLL herr_t H5F_eoa_dirty(H5F_t *f); /* Parallel I/O (i.e. MPI) related routines */ #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5F_get_mpi_handle(const H5F_t *f, MPI_File **f_handle); -H5_DLL int H5F_mpi_get_rank(const H5F_t *f); +H5_DLL herr_t H5F_get_mpi_handle(const H5F_t *f, MPI_File **f_handle); +H5_DLL int H5F_mpi_get_rank(const H5F_t *f); H5_DLL MPI_Comm H5F_mpi_get_comm(const H5F_t *f); -H5_DLL int H5F_shared_mpi_get_size(const H5F_shared_t *f_sh); -H5_DLL int H5F_mpi_get_size(const H5F_t *f); -H5_DLL herr_t H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm); -H5_DLL herr_t H5F_get_mpi_info(const H5F_t *f, MPI_Info **f_info); -H5_DLL herr_t H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag); -H5_DLL herr_t H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag); +H5_DLL int H5F_shared_mpi_get_size(const H5F_shared_t *f_sh); +H5_DLL int H5F_mpi_get_size(const H5F_t *f); +H5_DLL herr_t H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm); +H5_DLL herr_t H5F_get_mpi_info(const H5F_t *f, MPI_Info **f_info); +H5_DLL herr_t H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag); +H5_DLL herr_t H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag); #endif /* H5_HAVE_PARALLEL */ /* External file cache routines */ @@ -911,7 +985,8 @@ H5_DLL herr_t H5F_efc_close(H5F_t *parent, H5F_t *file); /* File prefix routines */ H5_DLL H5F_t *H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, - const char *prop_prefix, const char *file_name, unsigned file_intent, hid_t fapl_id); + const char *prop_prefix, const char *file_name, unsigned file_intent, + hid_t fapl_id); /* Global heap CWFS routines */ H5_DLL herr_t H5F_cwfs_add(H5F_t *f, struct H5HG_heap_t *heap); @@ -920,9 +995,8 @@ H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, hbool_t H5_DLL herr_t H5F_cwfs_remove_heap(H5F_shared_t *shared, struct H5HG_heap_t *heap); /* Debugging functions */ -H5_DLL herr_t H5F_debug(H5F_t *f, FILE * stream, int indent, int fwidth); +H5_DLL herr_t H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth); H5_DLL hbool_t H5F_use_vfd_swmr(const H5F_t *f); #endif /* _H5Fprivate_H */ - diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 17d8ce1..6eedea3 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -25,18 +25,18 @@ /* When this header is included from a private header, don't make calls to H5check() */ #undef H5CHECK #ifndef _H5private_H -#define H5CHECK H5check(), -#else /* _H5private_H */ +#define H5CHECK H5check(), +#else /* _H5private_H */ #define H5CHECK -#endif /* _H5private_H */ +#endif /* _H5private_H */ /* When this header is included from a private HDF5 header, don't make calls to H5open() */ #undef H5OPEN #ifndef _H5private_H -#define H5OPEN H5open(), -#else /* _H5private_H */ +#define H5OPEN H5open(), +#else /* _H5private_H */ #define H5OPEN -#endif /* _H5private_H */ +#endif /* _H5private_H */ /* * These are the bits that can be passed to the `flags' argument of @@ -47,43 +47,45 @@ * We're assuming that these constants are used rather early in the hdf5 * session. */ -#define H5F_ACC_RDONLY (H5CHECK H5OPEN 0x0000u) /*absence of rdwr => rd-only */ -#define H5F_ACC_RDWR (H5CHECK H5OPEN 0x0001u) /*open for read and write */ -#define H5F_ACC_TRUNC (H5CHECK H5OPEN 0x0002u) /*overwrite existing files */ -#define H5F_ACC_EXCL (H5CHECK H5OPEN 0x0004u) /*fail if file already exists*/ +#define H5F_ACC_RDONLY (H5CHECK H5OPEN 0x0000u) /*absence of rdwr => rd-only */ +#define H5F_ACC_RDWR (H5CHECK H5OPEN 0x0001u) /*open for read and write */ +#define H5F_ACC_TRUNC (H5CHECK H5OPEN 0x0002u) /*overwrite existing files */ +#define H5F_ACC_EXCL (H5CHECK H5OPEN 0x0004u) /*fail if file already exists*/ /* NOTE: 0x0008u was H5F_ACC_DEBUG, now deprecated */ -#define H5F_ACC_CREAT (H5CHECK H5OPEN 0x0010u) /*create non-existing files */ -#define H5F_ACC_SWMR_WRITE (H5CHECK 0x0020u) /*indicate that this file is - * open for writing in a - * single-writer/multi-reader (SWMR) - * scenario. Note that the - * process(es) opening the file - * for reading must open the file - * with RDONLY access, and use - * the special "SWMR_READ" access - * flag. */ -#define H5F_ACC_SWMR_READ (H5CHECK 0x0040u) /*indicate that this file is - * open for reading in a - * single-writer/multi-reader (SWMR) - * scenario. Note that the - * process(es) opening the file - * for SWMR reading must also - * open the file with the RDONLY - * flag. */ +#define H5F_ACC_CREAT (H5CHECK H5OPEN 0x0010u) /*create non-existing files */ +#define H5F_ACC_SWMR_WRITE \ + (H5CHECK 0x0020u) /*indicate that this file is \ + * open for writing in a \ + * single-writer/multi-reader (SWMR) \ + * scenario. Note that the \ + * process(es) opening the file \ + * for reading must open the file \ + * with RDONLY access, and use \ + * the special "SWMR_READ" access \ + * flag. */ +#define H5F_ACC_SWMR_READ \ + (H5CHECK 0x0040u) /*indicate that this file is \ + * open for reading in a \ + * single-writer/multi-reader (SWMR) \ + * scenario. Note that the \ + * process(es) opening the file \ + * for SWMR reading must also \ + * open the file with the RDONLY \ + * flag. */ /* Value passed to H5Pset_elink_acc_flags to cause flags to be taken from the * parent file. */ -#define H5F_ACC_DEFAULT (H5CHECK H5OPEN 0xffffu) /*ignore setting on lapl */ +#define H5F_ACC_DEFAULT (H5CHECK H5OPEN 0xffffu) /*ignore setting on lapl */ /* Flags for H5Fget_obj_count() & H5Fget_obj_ids() calls */ -#define H5F_OBJ_FILE (0x0001u) /* File objects */ -#define H5F_OBJ_DATASET (0x0002u) /* Dataset objects */ -#define H5F_OBJ_GROUP (0x0004u) /* Group objects */ -#define H5F_OBJ_DATATYPE (0x0008u) /* Named datatype objects */ -#define H5F_OBJ_ATTR (0x0010u) /* Attribute objects */ -#define H5F_OBJ_ALL (H5F_OBJ_FILE|H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR) -#define H5F_OBJ_LOCAL (0x0020u) /* Restrict search to objects opened through current file ID */ - /* (as opposed to objects opened through any file ID accessing this file) */ +#define H5F_OBJ_FILE (0x0001u) /* File objects */ +#define H5F_OBJ_DATASET (0x0002u) /* Dataset objects */ +#define H5F_OBJ_GROUP (0x0004u) /* Group objects */ +#define H5F_OBJ_DATATYPE (0x0008u) /* Named datatype objects */ +#define H5F_OBJ_ATTR (0x0010u) /* Attribute objects */ +#define H5F_OBJ_ALL (H5F_OBJ_FILE | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR) +#define H5F_OBJ_LOCAL (0x0020u) /* Restrict search to objects opened through current file ID */ +/* (as opposed to objects opened through any file ID accessing this file) */ #define H5F_FAMILY_DEFAULT (hsize_t)0 @@ -99,12 +101,12 @@ /* The difference between a single file and a set of mounted files */ typedef enum H5F_scope_t { - H5F_SCOPE_LOCAL = 0, /*specified file handle only */ - H5F_SCOPE_GLOBAL = 1 /*entire virtual file */ + H5F_SCOPE_LOCAL = 0, /*specified file handle only */ + H5F_SCOPE_GLOBAL = 1 /*entire virtual file */ } H5F_scope_t; /* Unlimited file size for H5Pset_external() */ -#define H5F_UNLIMITED ((hsize_t)(-1L)) +#define H5F_UNLIMITED ((hsize_t)(-1L)) /* How does file close behave? * H5F_CLOSE_DEFAULT - Use the degree pre-defined by underlining VFL @@ -115,28 +117,28 @@ typedef enum H5F_scope_t { close file */ typedef enum H5F_close_degree_t { - H5F_CLOSE_DEFAULT = 0, - H5F_CLOSE_WEAK = 1, - H5F_CLOSE_SEMI = 2, - H5F_CLOSE_STRONG = 3 + H5F_CLOSE_DEFAULT = 0, + H5F_CLOSE_WEAK = 1, + H5F_CLOSE_SEMI = 2, + H5F_CLOSE_STRONG = 3 } H5F_close_degree_t; /* Current "global" information about file */ typedef struct H5F_info2_t { struct { - unsigned version; /* Superblock version # */ - hsize_t super_size; /* Superblock size */ - hsize_t super_ext_size; /* Superblock extension size */ + unsigned version; /* Superblock version # */ + hsize_t super_size; /* Superblock size */ + hsize_t super_ext_size; /* Superblock extension size */ } super; struct { - unsigned version; /* Version # of file free space management */ - hsize_t meta_size; /* Free space manager metadata size */ - hsize_t tot_space; /* Amount of free space in the file */ + unsigned version; /* Version # of file free space management */ + hsize_t meta_size; /* Free space manager metadata size */ + hsize_t tot_space; /* Amount of free space in the file */ } free; struct { - unsigned version; /* Version # of shared object header info */ - hsize_t hdr_size; /* Shared object header message header size */ - H5_ih_info_t msgs_info; /* Shared object header message index & heap size */ + unsigned version; /* Version # of shared object header info */ + hsize_t hdr_size; /* Shared object header message header size */ + H5_ih_info_t msgs_info; /* Shared object header message index & heap size */ } sohm; } H5F_info2_t; @@ -149,70 +151,72 @@ typedef struct H5F_info2_t { * enumeration. */ typedef enum H5F_mem_t { - H5FD_MEM_NOLIST = -1, /* Data should not appear in the free list. - * Must be negative. - */ - H5FD_MEM_DEFAULT = 0, /* Value not yet set. Can also be the - * datatype set in a larger allocation - * that will be suballocated by the library. - * Must be zero. - */ - H5FD_MEM_SUPER = 1, /* Superblock data */ - H5FD_MEM_BTREE = 2, /* B-tree data */ - H5FD_MEM_DRAW = 3, /* Raw data (content of datasets, etc.) */ - H5FD_MEM_GHEAP = 4, /* Global heap data */ - H5FD_MEM_LHEAP = 5, /* Local heap data */ - H5FD_MEM_OHDR = 6, /* Object header data */ - - H5FD_MEM_NTYPES /* Sentinel value - must be last */ + H5FD_MEM_NOLIST = -1, /* Data should not appear in the free list. + * Must be negative. + */ + H5FD_MEM_DEFAULT = 0, /* Value not yet set. Can also be the + * datatype set in a larger allocation + * that will be suballocated by the library. + * Must be zero. + */ + H5FD_MEM_SUPER = 1, /* Superblock data */ + H5FD_MEM_BTREE = 2, /* B-tree data */ + H5FD_MEM_DRAW = 3, /* Raw data (content of datasets, etc.) */ + H5FD_MEM_GHEAP = 4, /* Global heap data */ + H5FD_MEM_LHEAP = 5, /* Local heap data */ + H5FD_MEM_OHDR = 6, /* Object header data */ + + H5FD_MEM_NTYPES /* Sentinel value - must be last */ } H5F_mem_t; /* Free space section information */ typedef struct H5F_sect_info_t { - haddr_t addr; /* Address of free space section */ - hsize_t size; /* Size of free space section */ + haddr_t addr; /* Address of free space section */ + hsize_t size; /* Size of free space section */ } H5F_sect_info_t; /* Library's format versions */ typedef enum H5F_libver_t { - H5F_LIBVER_ERROR = -1, - H5F_LIBVER_EARLIEST = 0, /* Use the earliest possible format for storing objects */ - H5F_LIBVER_V18 = 1, /* Use the latest v18 format for storing objects */ - H5F_LIBVER_V110 = 2, /* Use the latest v110 format for storing objects */ - H5F_LIBVER_V112 = 3, /* Use the latest v112 format for storing objects */ - H5F_LIBVER_V114 = 4, /* Use the latest v114 format for storing objects */ + H5F_LIBVER_ERROR = -1, + H5F_LIBVER_EARLIEST = 0, /* Use the earliest possible format for storing objects */ + H5F_LIBVER_V18 = 1, /* Use the latest v18 format for storing objects */ + H5F_LIBVER_V110 = 2, /* Use the latest v110 format for storing objects */ + H5F_LIBVER_V112 = 3, /* Use the latest v112 format for storing objects */ + H5F_LIBVER_V114 = 4, /* Use the latest v114 format for storing objects */ H5F_LIBVER_NBOUNDS } H5F_libver_t; -#define H5F_LIBVER_LATEST H5F_LIBVER_V114 +#define H5F_LIBVER_LATEST H5F_LIBVER_V114 /* File space handling strategy */ typedef enum H5F_fspace_strategy_t { - H5F_FSPACE_STRATEGY_FSM_AGGR = 0, /* Mechanisms: free-space managers, aggregators, and virtual file drivers */ - /* This is the library default when not set */ - H5F_FSPACE_STRATEGY_PAGE = 1, /* Mechanisms: free-space managers with embedded paged aggregation and virtual file drivers */ - H5F_FSPACE_STRATEGY_AGGR = 2, /* Mechanisms: aggregators and virtual file drivers */ - H5F_FSPACE_STRATEGY_NONE = 3, /* Mechanisms: virtual file drivers */ - H5F_FSPACE_STRATEGY_NTYPES /* must be last */ + H5F_FSPACE_STRATEGY_FSM_AGGR = + 0, /* Mechanisms: free-space managers, aggregators, and virtual file drivers */ + /* This is the library default when not set */ + H5F_FSPACE_STRATEGY_PAGE = + 1, /* Mechanisms: free-space managers with embedded paged aggregation and virtual file drivers */ + H5F_FSPACE_STRATEGY_AGGR = 2, /* Mechanisms: aggregators and virtual file drivers */ + H5F_FSPACE_STRATEGY_NONE = 3, /* Mechanisms: virtual file drivers */ + H5F_FSPACE_STRATEGY_NTYPES /* must be last */ } H5F_fspace_strategy_t; /* Deprecated: File space handling strategy for release 1.10.0 */ /* They are mapped to H5F_fspace_strategy_t as defined above from release 1.10.1 onwards */ typedef enum H5F_file_space_type_t { - H5F_FILE_SPACE_DEFAULT = 0, /* Default (or current) free space strategy setting */ + H5F_FILE_SPACE_DEFAULT = 0, /* Default (or current) free space strategy setting */ H5F_FILE_SPACE_ALL_PERSIST = 1, /* Persistent free space managers, aggregators, virtual file driver */ - H5F_FILE_SPACE_ALL = 2, /* Non-persistent free space managers, aggregators, virtual file driver */ - /* This is the library default */ + H5F_FILE_SPACE_ALL = 2, /* Non-persistent free space managers, aggregators, virtual file driver */ + /* This is the library default */ H5F_FILE_SPACE_AGGR_VFD = 3, /* Aggregators, Virtual file driver */ - H5F_FILE_SPACE_VFD = 4, /* Virtual file driver */ - H5F_FILE_SPACE_NTYPES /* must be last */ + H5F_FILE_SPACE_VFD = 4, /* Virtual file driver */ + H5F_FILE_SPACE_NTYPES /* must be last */ } H5F_file_space_type_t; /* Data structure to report the collection of read retries for metadata items with checksum */ /* Used by public routine H5Fget_metadata_read_retry_info() */ -#define H5F_NUM_METADATA_READ_RETRY_TYPES 21 +#define H5F_NUM_METADATA_READ_RETRY_TYPES 21 typedef struct H5F_retry_info_t { - unsigned nbins; + unsigned nbins; uint32_t *retries[H5F_NUM_METADATA_READ_RETRY_TYPES]; } H5F_retry_info_t; @@ -226,37 +230,37 @@ typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); /* * struct H5F_vfd_swmr_config_t * - * Instances of H5F_vfd_swmr_config_t are used by VFD SWMR writers and readers - * to pass necessary configuration data to the HDF5 library on file open (or + * Instances of H5F_vfd_swmr_config_t are used by VFD SWMR writers and readers + * to pass necessary configuration data to the HDF5 library on file open (or * creation, in the case of writers). * * The fields of the structure are discussed below: * version: - * An integer field indicating the version of the H5F_vfd_swmr_config - * structure used. This field must always be set to a known version - * number. The most recent version of the structure will always be + * An integer field indicating the version of the H5F_vfd_swmr_config + * structure used. This field must always be set to a known version + * number. The most recent version of the structure will always be * H5F__CURR_VFD_SWMR_CONFIG_VERSION. - * + * * tick_len: - * An integer field containing the length of a tick in tenths of - * a second. If tick_len is zero, end of tick processing may only be + * An integer field containing the length of a tick in tenths of + * a second. If tick_len is zero, end of tick processing may only be * triggered manually via the H5Fvfd_swmr_end_tick() function. * * max_lag: * An integer field indicating the maximum expected lag (in ticks) - * between the writer and the readers. This value must be at least 3, + * between the writer and the readers. This value must be at least 3, * with 10 being the recommended minimum value. - * + * * writer: * A boolean flag indicating whether the file opened with this FAPL entry * will be opened R/W. (i.e. as a VFD SWMR writer) * * flush_raw_data: - * A boolean flag indicating whether raw data should be flushed - * as part of the end of tick processing. If set to TRUE, raw + * A boolean flag indicating whether raw data should be flushed + * as part of the end of tick processing. If set to TRUE, raw * data will be flushed and thus be consistent with the metadata file. * However, this will also greatly increase end of tick I/O, and will - * likely break any real time guarantees unless a very large tick_len + * likely break any real time guarantees unless a very large tick_len * is selected. * * md_pages_reserved: @@ -271,40 +275,40 @@ typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); * * pb_expansion_threshold: * An integer field indicating the threshold for the page buffer size. - * During a tick, the page buffer must expand as necessary to retain copies - * of all modified metadata pages and multi-page metadata entries. - * If the page buffer size exceeds this thresold, an early end of tick + * During a tick, the page buffer must expand as necessary to retain copies + * of all modified metadata pages and multi-page metadata entries. + * If the page buffer size exceeds this thresold, an early end of tick * will be triggered. - * Note that this is not a limit on the maximum page buffer size, as the + * Note that this is not a limit on the maximum page buffer size, as the * metadata cache is flushed as part of end of tick processing. - * This threshold must be in the range [0, 100]. If the threshold is 0, - * the feature is disabled. For all other values, the page buffer size is - * multiplied by this threshold. If this value is exceeded, an early end - * of tick is triggered. + * This threshold must be in the range [0, 100]. If the threshold is 0, + * the feature is disabled. For all other values, the page buffer size is + * multiplied by this threshold. If this value is exceeded, an early end + * of tick is triggered. * * md_file_path: - * POSIX: this field contains the path of the metadata file. - * NFS: it contains the path and base name of the metadata file + * POSIX: this field contains the path of the metadata file. + * NFS: it contains the path and base name of the metadata file * updater files. * Object store: it contains the base URL for the objects used * to store metadata file updater objects. * * log_file_path: - * This field contains the path to the log file. If defined, this path should - * be unique to each process. If this field contains the empty string, a log + * This field contains the path to the log file. If defined, this path should + * be unique to each process. If this field contains the empty string, a log * file will not be created. * */ typedef struct H5F_vfd_swmr_config_t { - int32_t version; - uint32_t tick_len; - uint32_t max_lag; - hbool_t writer; - hbool_t flush_raw_data; - uint32_t md_pages_reserved; - uint32_t pb_expansion_threshold; - char md_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1]; - char log_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1]; + int32_t version; + uint32_t tick_len; + uint32_t max_lag; + hbool_t writer; + hbool_t flush_raw_data; + uint32_t md_pages_reserved; + uint32_t pb_expansion_threshold; + char md_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1]; + char log_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1]; } H5F_vfd_swmr_config_t; /*********************/ @@ -314,67 +318,60 @@ typedef struct H5F_vfd_swmr_config_t { extern "C" { #endif -H5_DLL htri_t H5Fis_accessible(const char *container_name, hid_t fapl_id); -H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags, - hid_t create_plist, hid_t access_plist); -H5_DLL hid_t H5Fopen(const char *filename, unsigned flags, - hid_t access_plist); -H5_DLL hid_t H5Freopen(hid_t file_id); -H5_DLL herr_t H5Fflush(hid_t object_id, H5F_scope_t scope); -H5_DLL herr_t H5Fclose(hid_t file_id); -H5_DLL herr_t H5Fdelete(const char *filename, hid_t fapl_id); -H5_DLL hid_t H5Fget_create_plist(hid_t file_id); -H5_DLL hid_t H5Fget_access_plist(hid_t file_id); -H5_DLL herr_t H5Fget_intent(hid_t file_id, unsigned *intent); -H5_DLL herr_t H5Fget_fileno(hid_t file_id, unsigned long *fileno); -H5_DLL ssize_t H5Fget_obj_count(hid_t file_id, unsigned types); -H5_DLL ssize_t H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *obj_id_list); -H5_DLL herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle); -H5_DLL herr_t H5Fmount(hid_t loc, const char *name, hid_t child, hid_t plist); -H5_DLL herr_t H5Funmount(hid_t loc, const char *name); +H5_DLL htri_t H5Fis_accessible(const char *container_name, hid_t fapl_id); +H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags, hid_t create_plist, hid_t access_plist); +H5_DLL hid_t H5Fopen(const char *filename, unsigned flags, hid_t access_plist); +H5_DLL hid_t H5Freopen(hid_t file_id); +H5_DLL herr_t H5Fflush(hid_t object_id, H5F_scope_t scope); +H5_DLL herr_t H5Fclose(hid_t file_id); +H5_DLL herr_t H5Fdelete(const char *filename, hid_t fapl_id); +H5_DLL hid_t H5Fget_create_plist(hid_t file_id); +H5_DLL hid_t H5Fget_access_plist(hid_t file_id); +H5_DLL herr_t H5Fget_intent(hid_t file_id, unsigned *intent); +H5_DLL herr_t H5Fget_fileno(hid_t file_id, unsigned long *fileno); +H5_DLL ssize_t H5Fget_obj_count(hid_t file_id, unsigned types); +H5_DLL ssize_t H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *obj_id_list); +H5_DLL herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle); +H5_DLL herr_t H5Fmount(hid_t loc, const char *name, hid_t child, hid_t plist); +H5_DLL herr_t H5Funmount(hid_t loc, const char *name); H5_DLL hssize_t H5Fget_freespace(hid_t file_id); -H5_DLL herr_t H5Fget_filesize(hid_t file_id, hsize_t *size); -H5_DLL herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa); -H5_DLL herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment); -H5_DLL ssize_t H5Fget_file_image(hid_t file_id, void * buf_ptr, size_t buf_len); -H5_DLL herr_t H5Fget_mdc_config(hid_t file_id, - H5AC_cache_config_t * config_ptr); -H5_DLL herr_t H5Fset_mdc_config(hid_t file_id, - H5AC_cache_config_t * config_ptr); -H5_DLL herr_t H5Fget_mdc_hit_rate(hid_t file_id, double * hit_rate_ptr); -H5_DLL herr_t H5Fget_mdc_size(hid_t file_id, - size_t * max_size_ptr, - size_t * min_clean_size_ptr, - size_t * cur_size_ptr, - int * cur_num_entries_ptr); -H5_DLL herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id); -H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size); -H5_DLL herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo); -H5_DLL herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info); -H5_DLL herr_t H5Fstart_swmr_write(hid_t file_id); -H5_DLL ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, - size_t nsects, H5F_sect_info_t *sect_info/*out*/); -H5_DLL herr_t H5Fclear_elink_file_cache(hid_t file_id); -H5_DLL herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); -H5_DLL herr_t H5Fstart_mdc_logging(hid_t file_id); -H5_DLL herr_t H5Fstop_mdc_logging(hid_t file_id); -H5_DLL herr_t H5Fget_mdc_logging_status(hid_t file_id, - /*OUT*/ hbool_t *is_enabled, - /*OUT*/ hbool_t *is_currently_logging); -H5_DLL herr_t H5Fformat_convert(hid_t fid); -H5_DLL herr_t H5Freset_page_buffering_stats(hid_t file_id); -H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], - unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); -H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); -H5_DLL herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize); -H5_DLL herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize); +H5_DLL herr_t H5Fget_filesize(hid_t file_id, hsize_t *size); +H5_DLL herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa); +H5_DLL herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment); +H5_DLL ssize_t H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len); +H5_DLL herr_t H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr); +H5_DLL herr_t H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, int *cur_num_entries_ptr); +H5_DLL herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id); +H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size); +H5_DLL herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo); +H5_DLL herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info); +H5_DLL herr_t H5Fstart_swmr_write(hid_t file_id); +H5_DLL ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, + H5F_sect_info_t *sect_info /*out*/); +H5_DLL herr_t H5Fclear_elink_file_cache(hid_t file_id); +H5_DLL herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); +H5_DLL herr_t H5Fstart_mdc_logging(hid_t file_id); +H5_DLL herr_t H5Fstop_mdc_logging(hid_t file_id); +H5_DLL herr_t H5Fget_mdc_logging_status(hid_t file_id, + /*OUT*/ hbool_t *is_enabled, + /*OUT*/ hbool_t *is_currently_logging); +H5_DLL herr_t H5Fformat_convert(hid_t fid); +H5_DLL herr_t H5Freset_page_buffering_stats(hid_t file_id); +H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], + unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); +H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); +H5_DLL herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize); +H5_DLL herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize); /* VFD SWMR */ H5_DLL herr_t H5Fvfd_swmr_end_tick(hid_t file_id); H5_DLL herr_t H5Fvfd_swmr_disable_end_of_tick(hid_t file_id); H5_DLL herr_t H5Fvfd_swmr_enable_end_of_tick(hid_t file_id); -H5_DLL bool vfd_swmr_writer_may_increase_tick_to(uint64_t, bool); -H5_DLL void vfd_swmr_reader_did_increase_tick_to(uint64_t); +H5_DLL bool vfd_swmr_writer_may_increase_tick_to(uint64_t, bool); +H5_DLL void vfd_swmr_reader_did_increase_tick_to(uint64_t); #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); @@ -388,20 +385,19 @@ H5_DLL herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); #ifndef H5_NO_DEPRECATED_SYMBOLS /* Macros */ -#define H5F_ACC_DEBUG (H5CHECK H5OPEN 0x0000u) /*print debug info (deprecated)*/ +#define H5F_ACC_DEBUG (H5CHECK H5OPEN 0x0000u) /*print debug info (deprecated)*/ /* Typedefs */ /* Current "global" information about file */ typedef struct H5F_info1_t { - hsize_t super_ext_size; /* Superblock extension size */ + hsize_t super_ext_size; /* Superblock extension size */ struct { - hsize_t hdr_size; /* Shared object header message header size */ - H5_ih_info_t msgs_info; /* Shared object header message index & heap size */ + hsize_t hdr_size; /* Shared object header message header size */ + H5_ih_info_t msgs_info; /* Shared object header message index & heap size */ } sohm; } H5F_info1_t; - /* Function prototypes */ H5_DLL herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo); H5_DLL herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format); @@ -413,4 +409,3 @@ H5_DLL htri_t H5Fis_hdf5(const char *filename); } #endif #endif /* _H5Fpublic_H */ - diff --git a/src/H5Fquery.c b/src/H5Fquery.c index b565f22..d319283 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -26,54 +26,44 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F_shared_get_intent * @@ -95,7 +85,6 @@ H5F_shared_get_intent(const H5F_shared_t *f_sh) FUNC_LEAVE_NOAPI(f_sh->flags) } /* end H5F_shared_get_intent() */ - /*------------------------------------------------------------------------- * Function: H5F_get_intent * @@ -117,7 +106,6 @@ H5F_get_intent(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->flags) } /* end H5F_get_intent() */ - /*------------------------------------------------------------------------- * Function: H5F_get_low_bound * @@ -142,7 +130,6 @@ H5F_get_low_bound(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->low_bound) } /* end H5F_get_low_bound() */ - /*------------------------------------------------------------------------- * Function: H5F_get_high_bound * @@ -167,7 +154,6 @@ H5F_get_high_bound(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->high_bound) } /* end H5F_get_high_bound() */ - /*------------------------------------------------------------------------- * Function: H5F_get_open_name * @@ -189,7 +175,6 @@ H5F_get_open_name(const H5F_t *f) FUNC_LEAVE_NOAPI(f->open_name) } /* end H5F_get_open_name() */ - /*------------------------------------------------------------------------- * Function: H5F_get_actual_name * @@ -211,13 +196,12 @@ H5F_get_actual_name(const H5F_t *f) FUNC_LEAVE_NOAPI(f->actual_name) } /* end H5F_get_actual_name() */ - /*------------------------------------------------------------------------- * Function: H5F_get_extpath * * Purpose: Retrieve the file's 'extpath' flags - * This is used by H5L_extern_traverse() and H5D_build_file_prefix() to retrieve the main file's location - * when searching the target file. + * This is used by H5L_extern_traverse() and H5D_build_file_prefix() to retrieve the main file's + *location when searching the target file. * * Return: 'extpath' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- @@ -235,7 +219,6 @@ H5F_get_extpath(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->extpath) } /* end H5F_get_extpath() */ - /*------------------------------------------------------------------------- * Function: H5F_get_shared * @@ -255,7 +238,6 @@ H5F_get_shared(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared) } /* end H5F_get_shared() */ - /*------------------------------------------------------------------------- * Function: H5F_same_shared * @@ -278,7 +260,6 @@ H5F_same_shared(const H5F_t *f1, const H5F_t *f2) FUNC_LEAVE_NOAPI(f1->shared == f2->shared) } /* end H5F_same_shared() */ - /*------------------------------------------------------------------------- * Function: H5F_get_nopen_objs * @@ -298,7 +279,6 @@ H5F_get_nopen_objs(const H5F_t *f) FUNC_LEAVE_NOAPI(f->nopen_objs) } /* end H5F_get_nopen_objs() */ - /*------------------------------------------------------------------------- * Function: H5F_file_id_exists * @@ -318,7 +298,6 @@ H5F_file_id_exists(const H5F_t *f) FUNC_LEAVE_NOAPI(f->id_exists) } /* end H5F_file_id_exists() */ - /*------------------------------------------------------------------------- * Function: H5F_get_parent * @@ -338,7 +317,6 @@ H5F_get_parent(const H5F_t *f) FUNC_LEAVE_NOAPI(f->parent) } /* end H5F_get_parent() */ - /*------------------------------------------------------------------------- * Function: H5F_get_nmounts * @@ -358,7 +336,6 @@ H5F_get_nmounts(const H5F_t *f) FUNC_LEAVE_NOAPI(f->nmounts) } /* end H5F_get_nmounts() */ - /*------------------------------------------------------------------------- * Function: H5F_get_read_attempts * @@ -378,7 +355,6 @@ H5F_get_read_attempts(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->read_attempts) } /* end H5F_get_read_attempts() */ - /*------------------------------------------------------------------------- * Function: H5F_get_fcpl * @@ -400,7 +376,6 @@ H5F_get_fcpl(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->fcpl_id) } /* end H5F_get_fcpl() */ - /*------------------------------------------------------------------------- * Function: H5F_sizeof_addr * @@ -423,7 +398,6 @@ H5F_sizeof_addr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sizeof_addr) } /* end H5F_sizeof_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_sizeof_size * @@ -446,7 +420,6 @@ H5F_sizeof_size(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sizeof_size) } /* H5F_sizeof_size() */ - /*------------------------------------------------------------------------- * Function: H5F_get_sohm_addr * @@ -467,7 +440,6 @@ H5F_get_sohm_addr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sohm_addr) } /* end H5F_get_sohm_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_get_sohm_vers * @@ -488,7 +460,6 @@ H5F_get_sohm_vers(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sohm_vers) } /* end H5F_get_sohm_vers() */ - /*------------------------------------------------------------------------- * Function: H5F_get_sohm_nindexes * @@ -509,7 +480,6 @@ H5F_get_sohm_nindexes(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sohm_nindexes) } /* end H5F_get_sohm_nindexes() */ - /*------------------------------------------------------------------------- * Function: H5F_sym_leaf_k * @@ -535,7 +505,6 @@ H5F_sym_leaf_k(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sblock->sym_leaf_k) } /* end H5F_sym_leaf_k() */ - /*------------------------------------------------------------------------- * Function: H5F_get_min_dset_ohdr * @@ -554,7 +523,6 @@ H5F_get_min_dset_ohdr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->crt_dset_min_ohdr_flag) } /* end H5F_get_min_dset_ohdr */ - /*------------------------------------------------------------------------- * Function: H5F_Kvalue * @@ -581,7 +549,6 @@ H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) FUNC_LEAVE_NOAPI(f->shared->sblock->btree_k[type->id]) } /* end H5F_Kvalue() */ - /*------------------------------------------------------------------------- * Function: H5F_get_nrefs * @@ -602,7 +569,6 @@ H5F_get_nrefs(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->nrefs) } /* end H5F_get_nrefs() */ - /*------------------------------------------------------------------------- * Function: H5F_rdcc_nslots * @@ -627,7 +593,6 @@ H5F_rdcc_nslots(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->rdcc_nslots) } /* end H5F_rdcc_nelmts() */ - /*------------------------------------------------------------------------- * Function: H5F_rdcc_nbytes * @@ -652,7 +617,6 @@ H5F_rdcc_nbytes(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->rdcc_nbytes) } /* end H5F_rdcc_nbytes() */ - /*------------------------------------------------------------------------- * Function: H5F_rdcc_w0 * @@ -677,7 +641,6 @@ H5F_rdcc_w0(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->rdcc_w0) } /* end H5F_rdcc_w0() */ - /*------------------------------------------------------------------------- * Function: H5F_get_base_addr * @@ -701,7 +664,6 @@ H5F_get_base_addr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sblock->base_addr) } /* end H5F_get_base_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_grp_btree_shared * @@ -726,7 +688,6 @@ H5F_grp_btree_shared(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->grp_btree_shared) } /* end H5F_grp_btree_shared() */ - /*------------------------------------------------------------------------- * Function: H5F_sieve_buf_size * @@ -751,7 +712,6 @@ H5F_sieve_buf_size(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sieve_buf_size) } /* end H5F_sieve_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5F_gc_ref * @@ -780,7 +740,6 @@ H5F_gc_ref(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->gc_ref) } /* end H5F_gc_ref() */ - /*------------------------------------------------------------------------- * Function: H5F_get_fc_degree * @@ -802,7 +761,6 @@ H5F_get_fc_degree(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->fc_degree) } /* end H5F_get_fc_degree() */ - /*------------------------------------------------------------------------- * Function: H5F_get_evict_on_close * @@ -826,7 +784,6 @@ H5F_get_evict_on_close(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->evict_on_close) } /* end H5F_get_evict_on_close() */ - /*------------------------------------------------------------------------- * Function: H5F_store_msg_crt_idx * @@ -848,7 +805,6 @@ H5F_store_msg_crt_idx(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->store_msg_crt_idx) } /* end H5F_store_msg_crt_idx() */ - /*------------------------------------------------------------------------- * Function: H5F_shared_has_feature * @@ -869,7 +825,6 @@ H5F_shared_has_feature(const H5F_shared_t *f_sh, unsigned feature) FUNC_LEAVE_NOAPI((hbool_t)(f_sh->lf->feature_flags & feature)) } /* end H5F_shared_has_feature() */ - /*------------------------------------------------------------------------- * Function: H5F_has_feature * @@ -888,10 +843,9 @@ H5F_has_feature(const H5F_t *f, unsigned feature) HDassert(f); HDassert(f->shared); - FUNC_LEAVE_NOAPI((hbool_t)(f->shared->lf->feature_flags&feature)) + FUNC_LEAVE_NOAPI((hbool_t)(f->shared->lf->feature_flags & feature)) } /* end H5F_has_feature() */ - /*------------------------------------------------------------------------- * Function: H5F_get_driver_id * @@ -915,7 +869,6 @@ H5F_get_driver_id(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->lf->driver_id) } /* end H5F_get_driver_id() */ - /*------------------------------------------------------------------------- * Function: H5F_get_fileno * @@ -929,7 +882,7 @@ H5F_get_driver_id(const H5F_t *f) herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -939,14 +892,13 @@ H5F_get_fileno(const H5F_t *f, unsigned long *filenum) HDassert(filenum); /* Retrieve the file's serial number */ - if(H5FD_get_fileno(f->shared->lf, filenum) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno") + if (H5FD_get_fileno(f->shared->lf, filenum) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_fileno() */ - /*------------------------------------------------------------------------- * Function: H5F_shared_get_eoa * @@ -958,21 +910,20 @@ done: haddr_t H5F_shared_get_eoa(const H5F_shared_t *f_sh, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(f_sh); /* Dispatch to driver */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f_sh->lf, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eoa(f_sh->lf, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_shared_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5F_get_eoa * @@ -984,7 +935,7 @@ done: haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -992,14 +943,13 @@ H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) HDassert(f->shared); /* Dispatch to driver */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5F_get_vfd_handle * @@ -1013,7 +963,7 @@ done: herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1022,14 +972,13 @@ H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle) HDassert(file_handle); /* Get the VFD handle */ - if(H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle) < 0) + if (H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_vfd_handle() */ - /*------------------------------------------------------------------------- * Function: H5F_is_tmp_addr * @@ -1053,7 +1002,6 @@ H5F_is_tmp_addr(const H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(H5F_addr_le(f->shared->tmp_addr, addr)) } /* end H5F_is_tmp_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_use_tmp_space * @@ -1078,7 +1026,7 @@ H5F_use_tmp_space(const H5F_t *f) } /* end H5F_use_tmp_space() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5F_coll_md_read * @@ -1100,7 +1048,6 @@ H5F_coll_md_read(const H5F_t *f) } /* end H5F_coll_md_read() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5F_use_mdc_logging * @@ -1124,7 +1071,6 @@ H5F_use_mdc_logging(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->use_mdc_logging) } /* end H5F_use_mdc_logging() */ - /*------------------------------------------------------------------------- * Function: H5F_start_mdc_log_on_access * @@ -1148,7 +1094,6 @@ H5F_start_mdc_log_on_access(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->start_mdc_log_on_access) } /* end H5F_start_mdc_log_on_access() */ - /*------------------------------------------------------------------------- * Function: H5F_mdc_log_location * @@ -1172,7 +1117,6 @@ H5F_mdc_log_location(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->mdc_log_location) } /* end H5F_mdc_log_location() */ - /*------------------------------------------------------------------------- * Function: H5F_get_alignment * @@ -1194,7 +1138,6 @@ H5F_get_alignment(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->alignment) } /* end H5F_get_alignment() */ - /*------------------------------------------------------------------------- * Function: H5F_get_threshold * @@ -1216,7 +1159,6 @@ H5F_get_threshold(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->threshold) } /* end H5F_get_threshold() */ - /*------------------------------------------------------------------------- * Function: H5F_get_pgend_meta_thres * @@ -1238,7 +1180,6 @@ H5F_get_pgend_meta_thres(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->pgend_meta_thres) } /* end H5F_get_pgend_meta_thres() */ - /*------------------------------------------------------------------------- * Function: H5F_get_point_of_no_return * @@ -1260,7 +1201,6 @@ H5F_get_point_of_no_return(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->point_of_no_return) } /* end H5F_get_point_of_no_return() */ - /*------------------------------------------------------------------------- * Function: H5F_get_null_fsm_addr * @@ -1282,7 +1222,6 @@ H5F_get_null_fsm_addr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->null_fsm_addr) } /* end H5F_get_null_fsm_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_get_vol_cls * @@ -1306,7 +1245,6 @@ H5F_get_vol_cls(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->vol_cls) } /* end H5F_get_vol_cls */ - /*------------------------------------------------------------------------- * Function: H5F_get_vol_obj * @@ -1326,7 +1264,6 @@ H5F_get_vol_obj(const H5F_t *f) FUNC_LEAVE_NOAPI(f->vol_obj) } /* end H5F_get_vol_obj */ - /*------------------------------------------------------------------------- * Function: H5F_get_cont_info * @@ -1343,7 +1280,7 @@ H5F_get_vol_obj(const H5F_t *f) herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1352,19 +1289,18 @@ H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info) HDassert(f->shared); /* Verify structure version */ - if(info->version != H5VL_CONTAINER_INFO_VERSION) + if (info->version != H5VL_CONTAINER_INFO_VERSION) HGOTO_ERROR(H5E_FILE, H5E_VERSION, FAIL, "wrong container info version #") /* Set the container info fields */ - info->feature_flags = 0; /* None currently defined */ - info->token_size = H5F_SIZEOF_ADDR(f); - info->blob_id_size = H5HG_HEAP_ID_SIZE(f); + info->feature_flags = 0; /* None currently defined */ + info->token_size = H5F_SIZEOF_ADDR(f); + info->blob_id_size = H5HG_HEAP_ID_SIZE(f); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_cont_info */ - /*------------------------------------------------------------------------- * Function: H5F_use_vfd_swmr * diff --git a/src/H5Fsfile.c b/src/H5Fsfile.c index 3cbd490..3dedbcf 100644 --- a/src/H5Fsfile.c +++ b/src/H5Fsfile.c @@ -11,21 +11,21 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free lists */ /* PRIVATE TYPEDEFS */ /* Struct for tracking "shared" file structs */ typedef struct H5F_sfile_node_t { - H5F_shared_t *shared; /* Pointer to "shared" file struct */ - struct H5F_sfile_node_t *next; /* Pointer to next node */ + H5F_shared_t * shared; /* Pointer to "shared" file struct */ + struct H5F_sfile_node_t *next; /* Pointer to next node */ } H5F_sfile_node_t; /* PRIVATE PROTOTYPES */ @@ -38,7 +38,6 @@ H5FL_DEFINE_STATIC(H5F_sfile_node_t); /* Declare a local variable to track the shared file information */ H5F_sfile_node_t *H5F_sfile_head_g = NULL; - /*------------------------------------------------------------------------- * Function: H5F_sfile_assert_num * @@ -56,18 +55,18 @@ H5F_sfile_assert_num(unsigned n) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(n == 0) { + if (n == 0) { /* Sanity checking */ HDassert(H5F_sfile_head_g == NULL); } /* end if */ else { - unsigned count; /* Number of open shared files */ - H5F_sfile_node_t *curr; /* Current shared file node */ + unsigned count; /* Number of open shared files */ + H5F_sfile_node_t *curr; /* Current shared file node */ /* Iterate through low-level files for matching low-level file info */ - curr = H5F_sfile_head_g; + curr = H5F_sfile_head_g; count = 0; - while(curr) { + while (curr) { /* Increment # of open shared file structs */ count++; @@ -82,7 +81,6 @@ H5F_sfile_assert_num(unsigned n) FUNC_LEAVE_NOAPI_VOID } /* H5F_sfile_assert_num() */ - /*------------------------------------------------------------------------- * Function: H5F__sfile_add * @@ -98,8 +96,8 @@ H5F_sfile_assert_num(unsigned n) herr_t H5F__sfile_add(H5F_shared_t *shared) { - H5F_sfile_node_t *new_shared; /* New shared file node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_sfile_node_t *new_shared; /* New shared file node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -121,7 +119,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__sfile_add() */ - /*------------------------------------------------------------------------- * Function: H5F__sfile_search * @@ -141,13 +138,12 @@ H5F__sfile_search(H5FD_t *lf) H5F_sfile_node_t *curr; for (curr = H5F_sfile_head_g; curr != NULL; curr = curr->next) { - if(curr->shared->lf == lf) + if (curr->shared->lf == lf) return curr->shared; } return NULL; } - /*------------------------------------------------------------------------- * Function: H5F__sfile_remove * @@ -163,9 +159,9 @@ H5F__sfile_search(H5FD_t *lf) herr_t H5F__sfile_remove(H5F_shared_t *shared) { - H5F_sfile_node_t *curr; /* Current shared file node */ - H5F_sfile_node_t *last; /* Last shared file node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_sfile_node_t *curr; /* Current shared file node */ + H5F_sfile_node_t *last; /* Last shared file node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -175,18 +171,18 @@ H5F__sfile_remove(H5F_shared_t *shared) /* Locate shared file node with correct shared file */ last = NULL; curr = H5F_sfile_head_g; - while(curr && curr->shared != shared) { + while (curr && curr->shared != shared) { /* Advance to next node */ last = curr; curr = curr->next; } /* end while */ /* Indicate error if the node wasn't found */ - if(curr == NULL) + if (curr == NULL) HGOTO_ERROR(H5E_FILE, H5E_NOTFOUND, FAIL, "can't find shared file info") /* Remove node found from list */ - if(last != NULL) + if (last != NULL) /* Removing middle or tail node in list */ last->next = curr->next; else @@ -200,4 +196,3 @@ H5F__sfile_remove(H5F_shared_t *shared) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__sfile_remove() */ - diff --git a/src/H5Fspace.c b/src/H5Fspace.c index 7de8b20..33e4439 100644 --- a/src/H5Fspace.c +++ b/src/H5Fspace.c @@ -26,55 +26,44 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ /****************/ /* Local Macros */ /****************/ - - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F__alloc * @@ -96,7 +85,7 @@ haddr_t H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - haddr_t ret_value = 0; /* Return value */ + haddr_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE @@ -108,32 +97,32 @@ H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t * HDassert(size > 0); /* Check whether the file can use temporary addresses */ - if(f->shared->use_tmp_space) { - haddr_t eoa; /* Current EOA for the file */ + if (f->shared->use_tmp_space) { + haddr_t eoa; /* Current EOA for the file */ /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((eoa + size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") + if (H5F_addr_gt((eoa + size), f->shared->tmp_addr)) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, HADDR_UNDEF, + "'normal' file space allocation request will overlap into 'temporary' file space") } /* end if */ /* Call the file driver 'alloc' routine */ ret_value = H5FD_alloc(f->shared->lf, type, f, size, frag_addr, frag_size); - if(!H5F_addr_defined(ret_value)) + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, HADDR_UNDEF, "file driver 'alloc' request failed") /* Mark EOA dirty */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, HADDR_UNDEF, "unable to mark EOA as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__alloc() */ - /*------------------------------------------------------------------------- * Function: H5F__free * @@ -155,7 +144,7 @@ done: herr_t H5F__free(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -167,18 +156,17 @@ H5F__free(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size) HDassert(size > 0); /* Call the file driver 'free' routine */ - if(H5FD_free(f->shared->lf, type, f, addr, size) < 0) + if (H5FD_free(f->shared->lf, type, f, addr, size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "file driver 'free' request failed") /* Mark EOA dirty */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark EOA as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__free() */ - /*------------------------------------------------------------------------- * Function: H5F__try_extend * @@ -200,7 +188,7 @@ done: htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested) { - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE @@ -212,7 +200,7 @@ H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_reques HDassert(extra_requested > 0); /* Extend the object by extending the underlying file */ - if((ret_value = H5FD_try_extend(f->shared->lf, type, f, blk_end, extra_requested)) < 0) + if ((ret_value = H5FD_try_extend(f->shared->lf, type, f, blk_end, extra_requested)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTEXTEND, FAIL, "driver try extend request failed") /* H5FD_try_extend() updates driver message and marks the superblock @@ -222,4 +210,3 @@ H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_reques done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__try_extend() */ - diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 9fd2831..afcd7f3 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -15,47 +15,41 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr); static herr_t H5F__update_super_ext_driver_msg(H5F_t *f); - /*********************/ /* Package Variables */ /*********************/ @@ -67,21 +61,19 @@ static herr_t H5F__update_super_ext_driver_msg(H5F_t *f); /* Declare a free list to manage the H5F_super_t struct */ H5FL_DEFINE(H5F_super_t); - /*******************/ /* Local Variables */ /*******************/ /* Format version bounds for superblock */ static const unsigned HDF5_superblock_ver_bounds[] = { - HDF5_SUPERBLOCK_VERSION_DEF, /* H5F_LIBVER_EARLIEST */ - HDF5_SUPERBLOCK_VERSION_2, /* H5F_LIBVER_V18 */ - HDF5_SUPERBLOCK_VERSION_3, /* H5F_LIBVER_V110 */ - HDF5_SUPERBLOCK_VERSION_3, /* H5F_LIBVER_V112 */ - HDF5_SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */ + HDF5_SUPERBLOCK_VERSION_DEF, /* H5F_LIBVER_EARLIEST */ + HDF5_SUPERBLOCK_VERSION_2, /* H5F_LIBVER_V18 */ + HDF5_SUPERBLOCK_VERSION_3, /* H5F_LIBVER_V110 */ + HDF5_SUPERBLOCK_VERSION_3, /* H5F_LIBVER_V112 */ + HDF5_SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; - /*------------------------------------------------------------------------- * Function: H5F__super_ext_create * @@ -97,7 +89,7 @@ static const unsigned HDF5_superblock_ver_bounds[] = { static herr_t H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -109,9 +101,11 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) HDassert(ext_ptr); /* Check for older version of superblock format that can't support superblock extensions */ - if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) - HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension not permitted with version %u of superblock", f->shared->sblock->super_vers) - else if(H5F_addr_defined(f->shared->sblock->ext_addr)) + if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, + "superblock extension not permitted with version %u of superblock", + f->shared->sblock->super_vers) + else if (H5F_addr_defined(f->shared->sblock->ext_addr)) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension already exists?!?!") else { /* The superblock extension isn't actually a group, but the @@ -123,7 +117,7 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) * extension. */ H5O_loc_reset(ext_ptr); - if(H5O_create(f, (size_t)0, (size_t)1, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0) + if (H5O_create(f, (size_t)0, (size_t)1, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension") /* Record the address of the superblock extension */ @@ -134,7 +128,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_create() */ - /*------------------------------------------------------------------------- * Function: H5F__super_ext_open * @@ -150,7 +143,7 @@ done: herr_t H5F__super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -165,14 +158,13 @@ H5F__super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr) ext_ptr->addr = ext_addr; /* Open the superblock extension object header */ - if(H5O_open(ext_ptr) < 0) + if (H5O_open(ext_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open superblock extension") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_open() */ - /*------------------------------------------------------------------------- * Function: H5F__super_ext_close * @@ -188,8 +180,8 @@ done: herr_t H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -198,34 +190,33 @@ H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created) HDassert(ext_ptr); /* Check if extension was created */ - if(was_created) { + if (was_created) { /* Set the ring type in the API context */ H5AC_set_ring(H5AC_RING_SBE, &orig_ring); /* Increment link count on superblock extension's object header */ - if(H5O_link(ext_ptr, 1) < 0) + if (H5O_link(ext_ptr, 1) < 0) HGOTO_ERROR(H5E_FILE, H5E_LINKCOUNT, FAIL, "unable to increment hard link count") /* Decrement refcount on superblock extension's object header in memory */ - if(H5O_dec_rc_by_loc(ext_ptr) < 0) + if (H5O_dec_rc_by_loc(ext_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement refcount on superblock extension"); } /* end if */ /* Twiddle the number of open objects to avoid closing the file. */ f->nopen_objs++; - if(H5O_close(ext_ptr, NULL) < 0) + if (H5O_close(ext_ptr, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close superblock extension") f->nopen_objs--; done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_close() */ - /*------------------------------------------------------------------------- * Function: H5F__update_super_ext_driver_msg * @@ -247,8 +238,8 @@ done: static herr_t H5F__update_super_ext_driver_msg(H5F_t *f) { - H5F_super_t *sblock; /* Pointer to the super block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_super_t *sblock; /* Pointer to the super block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -263,11 +254,11 @@ H5F__update_super_ext_driver_msg(H5F_t *f) /* Update the driver information message in the superblock extension * if appropriate. */ - if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2) { - if(H5F_addr_defined(sblock->ext_addr)) { + if (sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2) { + if (H5F_addr_defined(sblock->ext_addr)) { /* Check for ignoring the driver info for this file */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { - size_t driver_size; /* Size of driver info block (bytes)*/ + if (!H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { + size_t driver_size; /* Size of driver info block (bytes)*/ /* Check for driver info */ H5_CHECKED_ASSIGN(driver_size, size_t, H5FD_sb_size(f->shared->lf), hsize_t); @@ -276,15 +267,15 @@ H5F__update_super_ext_driver_msg(H5F_t *f) * the driver info superblock extension message has * already been created. */ - if(driver_size > 0) { - H5O_drvinfo_t drvinfo; /* Driver info */ - uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ + if (driver_size > 0) { + H5O_drvinfo_t drvinfo; /* Driver info */ + uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ /* Sanity check */ HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); /* Encode driver-specific data */ - if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) + if (H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Write the message to the superblock extension. @@ -294,18 +285,19 @@ H5F__update_super_ext_driver_msg(H5F_t *f) */ drvinfo.len = driver_size; drvinfo.buf = dbuf; - if(H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message") + if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < + 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "unable to update driver info header message") } /* end if driver_size > 0 */ - } /* end if !H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO) */ - } /* end if superblock extension exists */ - } /* end if sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 */ + } /* end if !H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO) */ + } /* end if superblock extension exists */ + } /* end if sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__update_super_ext_driver_msg() */ - /*------------------------------------------------------------------------- * Function: H5F__super_read * @@ -326,20 +318,20 @@ done: herr_t H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) { - H5AC_ring_t orig_ring = H5AC_RING_INV; - H5F_super_t * sblock = NULL; /* Superblock structure */ - H5F_superblock_cache_ud_t udata; /* User data for cache callbacks */ - H5P_genplist_t *c_plist; /* File creation property list */ - H5FD_t *file; /* File driver pointer */ - unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ - haddr_t super_addr; /* Absolute address of superblock */ - haddr_t eof; /* End of file address */ - unsigned rw_flags; /* Read/write permissions for file */ - hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; + H5F_super_t * sblock = NULL; /* Superblock structure */ + H5F_superblock_cache_ud_t udata; /* User data for cache callbacks */ + H5P_genplist_t * c_plist; /* File creation property list */ + H5FD_t * file; /* File driver pointer */ + unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ + haddr_t super_addr; /* Absolute address of superblock */ + haddr_t eof; /* End of file address */ + unsigned rw_flags; /* Read/write permissions for file */ + hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */ #ifdef H5_HAVE_PARALLEL - int mpi_size = 1; -#endif /* H5_HAVE_PARALLEL */ - herr_t ret_value = SUCCEED; /* Return value */ + int mpi_size = 1; +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__SUPERBLOCK_TAG) @@ -353,8 +345,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* Find the superblock */ #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) - if((mpi_size = H5F_mpi_get_size(f)) < 0) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + if ((mpi_size = H5F_mpi_get_size(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve MPI communicator size") /* If we are an MPI application with at least two processes, the @@ -366,56 +358,58 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * fact that we have skipped actually calling MPI functions to determine * our MPI rank and size. */ - if(mpi_size > 1) { + if (mpi_size > 1) { MPI_Comm this_comm; - int mpi_rank; - int mpi_result; + int mpi_rank; + int mpi_result; /* Sanity check */ HDassert(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)); /* Set up MPI info */ - if((mpi_rank = H5F_mpi_get_rank(f)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Can't get MPI rank") - if(MPI_COMM_NULL == (this_comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (this_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") /* Search for the file's signature only with rank 0 process */ - if(0 == mpi_rank) { + if (0 == mpi_rank) { herr_t status; /* Try detecting file's siganture */ /* (Don't leave before Bcast, to avoid hang on error) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5FD_locate_signature(file, &super_addr); - } H5E_END_TRY; + } + H5E_END_TRY; /* Set superblock address to undefined on error */ - if(status < 0) + if (status < 0) super_addr = HADDR_UNDEF; } /* end if */ /* Broadcast superblock address to other processes */ - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&super_addr, sizeof(super_addr), MPI_BYTE, 0, this_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(&super_addr, sizeof(super_addr), MPI_BYTE, 0, this_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) } /* end if */ else { /* Locate the signature as per per the serial library */ #endif /* H5_HAVE_PARALLEL */ - if(H5FD_locate_signature(file, &super_addr) < 0) + if (H5FD_locate_signature(file, &super_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") #ifdef H5_HAVE_PARALLEL - } /* end else */ + } /* end else */ #endif /* H5_HAVE_PARALLEL */ - if(!H5F_addr_defined(super_addr)) + if (!H5F_addr_defined(super_addr)) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "file signature not found") /* Check for userblock present */ - if(H5F_addr_gt(super_addr, 0)) { + if (H5F_addr_gt(super_addr, 0)) { /* Set the base address for the file in the VFD now */ - if(H5F__set_base_addr(f, super_addr) < 0) + if (H5F__set_base_addr(f, super_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set base address for file driver") } /* end if */ @@ -428,32 +422,32 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) #ifdef H5_HAVE_PARALLEL rw_flags |= H5C__FLUSH_COLLECTIVELY_FLAG; #endif /* H5_HAVE_PARALLEL */ - if(!(H5F_INTENT(f) & H5F_ACC_RDWR)) + if (!(H5F_INTENT(f) & H5F_ACC_RDWR)) rw_flags |= H5AC__READ_ONLY_FLAG; /* Get the shared file creation property list */ - if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + if (NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "can't get property list") /* Make certain we can read the fixed-size portion of the superblock */ - if(H5F__set_eoa(f, H5FD_MEM_SUPER, - (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE)) < 0) + if (H5F__set_eoa(f, H5FD_MEM_SUPER, + (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "set end of space allocation request failed") /* Set up the user data for cache callbacks */ - udata.f = f; + udata.f = f; udata.ignore_drvrinfo = H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO); - udata.sym_leaf_k = 0; - if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0) + udata.sym_leaf_k = 0; + if (H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") - udata.stored_eof = HADDR_UNDEF; + udata.stored_eof = HADDR_UNDEF; udata.drvrinfo_removed = FALSE; /* Set the ring type in the API context */ H5AC_set_ring(H5AC_RING_SB, &orig_ring); /* Look up the superblock */ - if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags))) + if (NULL == (sblock = (H5F_super_t *)H5AC_protect(f, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load superblock") /* @@ -480,29 +474,29 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) */ /* Check to ensure that superblock version 3 is used for SWMR-write access */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) + if (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version for SWMR is less than 3") } /* Upgrade low_bound to at least V18 when encountering version 2 superblock */ - if(sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2) + if (sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2) f->shared->low_bound = MAX(H5F_LIBVER_V18, f->shared->low_bound); /* Upgrade low_bound to at least V110 when encountering version 3 superblock */ - if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) + if (sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) f->shared->low_bound = MAX(H5F_LIBVER_V110, f->shared->low_bound); /* Version bounds check */ - if(sblock->super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) + if (sblock->super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version exceeds high bound") /* Pin the superblock in the cache */ - if(H5AC_pin_protected_entry(sblock) < 0) + if (H5AC_pin_protected_entry(sblock) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTPIN, FAIL, "unable to pin superblock") /* Mark the superblock dirty if it was modified during loading */ - if(((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && udata.ignore_drvrinfo && udata.drvrinfo_removed) { + if (((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && udata.ignore_drvrinfo && udata.drvrinfo_removed) { HDassert(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2); sblock_flags |= H5AC__DIRTIED_FLAG; } /* end if */ @@ -516,7 +510,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* Check if superblock address is different from base address and adjust * base address and "end of file" address if so. */ - if(!H5F_addr_eq(super_addr, sblock->base_addr)) { + if (!H5F_addr_eq(super_addr, sblock->base_addr)) { /* If the superblock moved in the file, adjust the EOF */ /* (Handles moving earlier & later) */ udata.stored_eof -= (sblock->base_addr - super_addr); @@ -525,43 +519,43 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) sblock->base_addr = super_addr; /* Set the base address for the file in the VFD now */ - if(H5F__set_base_addr(f, sblock->base_addr) < 0) + if (H5F__set_base_addr(f, sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set base address for file driver") /* Indicate that the superblock should be marked dirty */ - if((rw_flags & H5AC__READ_ONLY_FLAG) == 0) + if ((rw_flags & H5AC__READ_ONLY_FLAG) == 0) sblock_flags |= H5AC__DIRTIED_FLAG; } /* end if */ /* Set information in the file's creation property list */ - if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &sblock->super_vers) < 0) + if (H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &sblock->super_vers) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set superblock version") - if(H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sblock->sizeof_addr) < 0) + if (H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sblock->sizeof_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set byte number in an address") - if(H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sblock->sizeof_size) < 0) + if (H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sblock->sizeof_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set byte number for object size") /* Handle the B-tree 'K' values */ - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { /* Sanity check */ HDassert(udata.sym_leaf_k != 0); /* Set the symbol table internal node 'K' value */ - if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &udata.sym_leaf_k) < 0) + if (H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &udata.sym_leaf_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for symbol table leaf nodes") sblock->sym_leaf_k = udata.sym_leaf_k; /* Set the B-tree internal node values, etc */ - if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0) + if (H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes") H5MM_memcpy(sblock->btree_k, udata.btree_k, sizeof(unsigned) * (size_t)H5B_NUM_BTREE_ID); } /* end if */ else { /* Get the (default) B-tree internal node values, etc */ /* (Note: these may be reset in a superblock extension) */ - if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, sblock->btree_k) < 0) + if (H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, sblock->btree_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") - if(H5P_get(c_plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) + if (H5P_get(c_plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") } /* end else */ @@ -569,7 +563,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * The user-defined data is the area of the file before the base * address. */ - if(H5P_set(c_plist, H5F_CRT_USER_BLOCK_NAME, &sblock->base_addr) < 0) + if (H5P_set(c_plist, H5F_CRT_USER_BLOCK_NAME, &sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set userblock size") /* @@ -598,28 +592,31 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) */ /* Check if this private property exists in fapl */ - if(H5P_exist_plist(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME) > 0) - if(H5P_get(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME, &skip_eof_check) < 0) + if (H5P_exist_plist(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME) > 0) + if (H5P_get(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME, &skip_eof_check) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get skip EOF check value") - if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) { + if (H5F_INTENT(f) & H5F_ACC_SWMR_READ) { /* * When the file is opened for SWMR read access, skip the check if: * --the file is already marked for SWMR writing and * --the file has version 3 superblock for SWMR support */ - if((sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) && - (sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && - sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) + if ((sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) && + (sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && + sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) skip_eof_check = TRUE; } /* end if */ - if(!skip_eof_check && initial_read) { - if(HADDR_UNDEF == (eof = H5FD_get_eof(f->shared->lf, H5FD_MEM_DEFAULT))) + if (!skip_eof_check && initial_read) { + if (HADDR_UNDEF == (eof = H5FD_get_eof(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to determine file size") /* (Account for the stored EOA being absolute offset -QAK) */ - if((eof + sblock->base_addr) < udata.stored_eof) - HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", (unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)udata.stored_eof) + if ((eof + sblock->base_addr) < udata.stored_eof) + HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, + "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", + (unsigned long long)eof, (unsigned long long)sblock->base_addr, + (unsigned long long)udata.stored_eof) } /* end if */ /* @@ -631,10 +628,10 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) H5AC_set_ring(H5AC_RING_SBE, NULL); /* Decode the optional driver information block */ - if(H5F_addr_defined(sblock->driver_addr)) { - H5O_drvinfo_t *drvinfo; /* Driver info */ - H5F_drvrinfo_cache_ud_t drvrinfo_udata; /* User data for metadata callbacks */ - unsigned drvinfo_flags = H5AC__NO_FLAGS_SET; /* Flags used in driver info block unprotect call */ + if (H5F_addr_defined(sblock->driver_addr)) { + H5O_drvinfo_t * drvinfo; /* Driver info */ + H5F_drvrinfo_cache_ud_t drvrinfo_udata; /* User data for metadata callbacks */ + unsigned drvinfo_flags = H5AC__NO_FLAGS_SET; /* Flags used in driver info block unprotect call */ /* Sanity check - driver info block should only be defined for * superblock version < 2. @@ -648,17 +645,19 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* extend EOA so we can read at least the fixed sized * portion of the driver info block */ - if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) /* will extend eoa later if required */ + if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < + 0) /* will extend eoa later if required */ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") /* Look up the driver info block */ - if(NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, H5AC_DRVRINFO, sblock->driver_addr, &drvrinfo_udata, rw_flags))) + if (NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, H5AC_DRVRINFO, sblock->driver_addr, + &drvrinfo_udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load driver info block") /* Loading the driver info block is enough to set up the right info */ /* Check if we need to rewrite the driver info block info */ - if(((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_DRVRINFO_LOAD)) + if (((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_DRVRINFO_LOAD)) drvinfo_flags |= H5AC__DIRTIED_FLAG; /* set the pin entry flag so that the driver information block @@ -667,7 +666,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) drvinfo_flags |= H5AC__PIN_ENTRY_FLAG; /* Release the driver info block */ - if(H5AC_unprotect(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, drvinfo_flags) < 0) + if (H5AC_unprotect(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, drvinfo_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTUNPROTECT, FAIL, "unable to release driver info block") /* save a pointer to the driver information cache entry */ @@ -675,16 +674,16 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) } /* end if */ /* (Account for the stored EOA being absolute offset -NAF) */ - if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, udata.stored_eof - sblock->base_addr) < 0) + if (H5F__set_eoa(f, H5FD_MEM_DEFAULT, udata.stored_eof - sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set end-of-address marker for file") /* Decode the optional superblock extension info */ - if(H5F_addr_defined(sblock->ext_addr)) { - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - H5O_btreek_t btreek; /* v1 B-tree 'K' value message from superblock extension */ - H5O_drvinfo_t drvinfo; /* Driver info message from superblock extension */ - size_t u; /* Local index variable */ - htri_t status; /* Status for message existing */ + if (H5F_addr_defined(sblock->ext_addr)) { + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + H5O_btreek_t btreek; /* v1 B-tree 'K' value message from superblock extension */ + H5O_drvinfo_t drvinfo; /* Driver info message from superblock extension */ + size_t u; /* Local index variable */ + htri_t status; /* Status for message existing */ /* Sanity check - superblock extension should only be defined for * superblock version >= 2. @@ -694,32 +693,32 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* Check for superblock extension being located "outside" the stored * 'eoa' value, which can occur with the split/multi VFD. */ - if(H5F_addr_gt(sblock->ext_addr, udata.stored_eof)) { + if (H5F_addr_gt(sblock->ext_addr, udata.stored_eof)) { /* Set the 'eoa' for the object header memory type large enough * to give some room for a reasonably sized superblock extension. * (This is _rather_ a kludge -QAK) */ - if(H5F__set_eoa(f, H5FD_MEM_OHDR, (haddr_t)(sblock->ext_addr + 1024)) < 0) + if (H5F__set_eoa(f, H5FD_MEM_OHDR, (haddr_t)(sblock->ext_addr + 1024)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set end-of-address marker for file") } /* end if */ /* Open the superblock extension */ - if(H5F__super_ext_open(f, sblock->ext_addr, &ext_loc) < 0) + if (H5F__super_ext_open(f, sblock->ext_addr, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension") /* Check for the extension having a 'driver info' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID)) < 0) + if ((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") - if(status) { + if (status) { /* Check for ignoring the driver info for this file */ - if(!udata.ignore_drvrinfo) { + if (!udata.ignore_drvrinfo) { /* Retrieve the 'driver info' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo)) + if (NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver info message not present") /* Validate and decode driver information */ - if(H5FD_sb_load(f->shared->lf, drvinfo.name, drvinfo.buf) < 0) { + if (H5FD_sb_load(f->shared->lf, drvinfo.name, drvinfo.buf) < 0) { H5O_msg_reset(H5O_DRVINFO_ID, &drvinfo); HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "unable to decode driver information") } /* end if */ @@ -730,101 +729,104 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) HDassert(FALSE == f->shared->drvinfo_sb_msg_exists); f->shared->drvinfo_sb_msg_exists = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Read in the shared OH message information if there is any */ - if(H5SM_get_info(&ext_loc, c_plist) < 0) + if (H5SM_get_info(&ext_loc, c_plist) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to read SOHM table information") /* Check for the extension having a 'v1 B-tree "K"' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_BTREEK_ID)) < 0) + if ((status = H5O_msg_exists(&ext_loc, H5O_BTREEK_ID)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") - if(status) { + if (status) { /* Retrieve the 'v1 B-tree "K"' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_BTREEK_ID, &btreek)) + if (NULL == H5O_msg_read(&ext_loc, H5O_BTREEK_ID, &btreek)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "v1 B-tree 'K' info message not present") /* Set non-default v1 B-tree 'K' value info from file */ sblock->btree_k[H5B_CHUNK_ID] = btreek.btree_k[H5B_CHUNK_ID]; sblock->btree_k[H5B_SNODE_ID] = btreek.btree_k[H5B_SNODE_ID]; - sblock->sym_leaf_k = btreek.sym_leaf_k; + sblock->sym_leaf_k = btreek.sym_leaf_k; /* Set non-default v1 B-tree 'K' values in the property list */ - if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btreek.btree_k) < 0) + if (H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btreek.btree_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes") - if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &btreek.sym_leaf_k) < 0) + if (H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &btreek.sym_leaf_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for symbol table leaf nodes") } /* end if */ /* Check for the extension having a 'free-space manager info' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_FSINFO_ID)) < 0) + if ((status = H5O_msg_exists(&ext_loc, H5O_FSINFO_ID)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") - if(status) { - uint8_t flags; /* Message flags */ + if (status) { + uint8_t flags; /* Message flags */ /* Get message flags */ - if(H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, &flags) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to message flags for free-space manager info message") + if (H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, &flags) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, + "unable to message flags for free-space manager info message") /* If message is NOT marked "unknown"--set up file space info */ - if(!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) { - H5O_fsinfo_t fsinfo; /* File space info message from superblock extension */ + if (!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) { + H5O_fsinfo_t fsinfo; /* File space info message from superblock extension */ /* f->shared->null_fsm_addr: Whether to drop free-space to the floor */ /* The h5clear tool uses this property to tell the library * to drop free-space to the floor */ - if(H5P_exist_plist(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME) > 0) - if(H5P_get(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME, &f->shared->null_fsm_addr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get clearance for persisting fsm addr") + if (H5P_exist_plist(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME) > 0) + if (H5P_get(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME, &f->shared->null_fsm_addr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, + "can't get clearance for persisting fsm addr") /* Retrieve the 'file space info' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo)) + if (NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message") /* Version bounds check */ - if(H5O_fsinfo_check_version(H5F_HIGH_BOUND(f), &fsinfo) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") + if (H5O_fsinfo_check_version(H5F_HIGH_BOUND(f), &fsinfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, + "File space info message's version out of bounds") /* Update changed values */ - if(f->shared->fs_version != fsinfo.version) + if (f->shared->fs_version != fsinfo.version) f->shared->fs_version = fsinfo.version; - if(f->shared->fs_strategy != fsinfo.strategy) { + if (f->shared->fs_strategy != fsinfo.strategy) { f->shared->fs_strategy = fsinfo.strategy; /* Set non-default strategy in the property list */ - if(H5P_set(c_plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &fsinfo.strategy) < 0) + if (H5P_set(c_plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &fsinfo.strategy) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") } /* end if */ - if(f->shared->fs_persist != fsinfo.persist) { + if (f->shared->fs_persist != fsinfo.persist) { f->shared->fs_persist = fsinfo.persist; /* Set non-default strategy in the property list */ - if(H5P_set(c_plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &fsinfo.persist) < 0) + if (H5P_set(c_plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &fsinfo.persist) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") } /* end if */ - if(f->shared->fs_threshold != fsinfo.threshold) { + if (f->shared->fs_threshold != fsinfo.threshold) { f->shared->fs_threshold = fsinfo.threshold; /* Set non-default threshold in the property list */ - if(H5P_set(c_plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &fsinfo.threshold) < 0) + if (H5P_set(c_plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &fsinfo.threshold) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") } /* end if */ HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); HDassert(fsinfo.page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); - if(f->shared->fs_page_size != fsinfo.page_size) { + if (f->shared->fs_page_size != fsinfo.page_size) { f->shared->fs_page_size = fsinfo.page_size; /* Set file space page size in the property list */ - if(H5P_set(c_plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsinfo.page_size) < 0) + if (H5P_set(c_plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsinfo.page_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space page size") } /* end if */ - if(f->shared->pgend_meta_thres != fsinfo.pgend_meta_thres) + if (f->shared->pgend_meta_thres != fsinfo.pgend_meta_thres) /* Initialize page end meta threshold */ f->shared->pgend_meta_thres = fsinfo.pgend_meta_thres; - if(f->shared->eoa_fsm_fsalloc != fsinfo.eoa_pre_fsm_fsalloc) + if (f->shared->eoa_fsm_fsalloc != fsinfo.eoa_pre_fsm_fsalloc) f->shared->eoa_fsm_fsalloc = fsinfo.eoa_pre_fsm_fsalloc; /* @@ -836,8 +838,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * The above two conditions are enabled when the tool h5clear --increment * option is used. */ - if(!skip_eof_check && !f->shared->null_fsm_addr) - HDassert((!f->shared->fs_persist) || (f->shared->eoa_fsm_fsalloc != HADDR_UNDEF)); + if (!skip_eof_check && !f->shared->null_fsm_addr) + HDassert((!f->shared->fs_persist) || (f->shared->eoa_fsm_fsalloc != HADDR_UNDEF)); /* * A crashed file with persistent free-space managers may have @@ -862,7 +864,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) */ f->shared->fs_addr[0] = HADDR_UNDEF; - for(u = 1; u < NELMTS(f->shared->fs_addr); u++) + for (u = 1; u < NELMTS(f->shared->fs_addr); u++) f->shared->fs_addr[u] = fsinfo.fs_addr[u - 1]; /* If the following two conditions are true: @@ -870,58 +872,62 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * (2) dropping free-space to the floor (f->shared->null_fsm_addr) * nullify the addresses of the FSMs */ - if(f->shared->fs_persist && f->shared->null_fsm_addr) - for(u = 0; u < NELMTS(fsinfo.fs_addr); u++) + if (f->shared->fs_persist && f->shared->null_fsm_addr) + for (u = 0; u < NELMTS(fsinfo.fs_addr); u++) f->shared->fs_addr[u] = fsinfo.fs_addr[u] = HADDR_UNDEF; /* For fsinfo.mapped: remove the FSINFO message from the superblock extension and write a new message to the extension */ /* For f->shared->null_fsm_addr: just update FSINFO message in the superblock extension */ - if(((fsinfo.mapped || f->shared->null_fsm_addr) && (rw_flags & H5AC__READ_ONLY_FLAG) == 0)) { + if (((fsinfo.mapped || f->shared->null_fsm_addr) && (rw_flags & H5AC__READ_ONLY_FLAG) == 0)) { /* Do the same kluge until we know for sure. VC */ #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ - /* KLUGE ALERT!! - * - * H5F__super_ext_write_msg() expects f->shared->sblock to - * be set -- verify that it is NULL, and then set it. - * Set it back to NULL when we are done. - */ - HDassert(f->shared->sblock == NULL); - f->shared->sblock = sblock; + /* KLUGE ALERT!! + * + * H5F__super_ext_write_msg() expects f->shared->sblock to + * be set -- verify that it is NULL, and then set it. + * Set it back to NULL when we are done. + */ + HDassert(f->shared->sblock == NULL); + f->shared->sblock = sblock; #endif /* JRM */ - if(f->shared->null_fsm_addr) { - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension") + if (f->shared->null_fsm_addr) { + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, + H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing fsinfo message to superblock extension") } else { - if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) - { + if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) { #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; #endif /* JRM */ - HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension") + HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, + "error in removing message from superblock extension") } - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, + H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing fsinfo message to superblock extension") } #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; #endif /* JRM */ } /* end if */ - } /* end if not marked "unknown" */ - } /* end if */ + } /* end if not marked "unknown" */ + } /* end if */ /* Check for the extension having a 'metadata cache image' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_MDCI_MSG_ID)) < 0) + if ((status = H5O_msg_exists(&ext_loc, H5O_MDCI_MSG_ID)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") - if(status) { - hbool_t rw = ((rw_flags & H5AC__READ_ONLY_FLAG) == 0); - H5O_mdci_t mdci_msg; + if (status) { + hbool_t rw = ((rw_flags & H5AC__READ_ONLY_FLAG) == 0); + H5O_mdci_t mdci_msg; /* if the metadata cache image superblock extension message exists, * read its contents and pass the data on to the metadata cache. @@ -936,16 +942,17 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) */ /* Retrieve the 'metadata cache image message' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_MDCI_MSG_ID, &mdci_msg)) + if (NULL == H5O_msg_read(&ext_loc, H5O_MDCI_MSG_ID, &mdci_msg)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache image message") /* Indicate to the cache that there's an image to load on first protect call */ - if(H5AC_load_cache_image_on_next_protect(f, mdci_msg.addr, mdci_msg.size, rw) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, "call to H5AC_load_cache_image_on_next_protect failed"); + if (H5AC_load_cache_image_on_next_protect(f, mdci_msg.addr, mdci_msg.size, rw) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, + "call to H5AC_load_cache_image_on_next_protect failed"); } /* end if */ /* Close superblock extension */ - if(H5F__super_ext_close(f, &ext_loc, FALSE) < 0) + if (H5F__super_ext_close(f, &ext_loc, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close file's superblock extension") } /* end if */ @@ -953,24 +960,23 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* (NOTE: only for later versions of superblock, earlier versions are handled * earlier in this routine. */ - if(((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && - sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 && - H5F_addr_defined(sblock->ext_addr)) { + if (((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 && + H5F_addr_defined(sblock->ext_addr)) { /* Check for modifying the driver info when opening the file */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_DRVRINFO_LOAD)) { - size_t driver_size; /* Size of driver info block (bytes) */ + if (H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_DRVRINFO_LOAD)) { + size_t driver_size; /* Size of driver info block (bytes) */ /* Check for driver info message */ H5_CHECKED_ASSIGN(driver_size, size_t, H5FD_sb_size(f->shared->lf), hsize_t); - if(driver_size > 0) { - H5O_drvinfo_t drvinfo; /* Driver info */ - uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ + if (driver_size > 0) { + H5O_drvinfo_t drvinfo; /* Driver info */ + uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ /* Sanity check */ HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); /* Encode driver-specific data */ - if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) + if (H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Set the driver info information for the superblock extension */ @@ -989,73 +995,74 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) HDassert(f->shared->sblock == NULL); f->shared->sblock = sblock; #endif /* JRM */ - if(H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension") #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; #endif /* JRM */ } /* end if */ - } /* end if */ + } /* end if */ /* Check for eliminating the driver info block */ - else if(H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { + else if (H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { /* Remove the driver info message from the superblock extension */ - if(H5F__super_ext_remove_msg(f, H5O_DRVINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") + if (H5F__super_ext_remove_msg(f, H5O_DRVINFO_ID) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, + "error in removing message from superblock extension") /* Check if the superblock extension was removed */ - if(!H5F_addr_defined(sblock->ext_addr)) + if (!H5F_addr_defined(sblock->ext_addr)) sblock_flags |= H5AC__DIRTIED_FLAG; } /* end if */ - } /* end if */ + } /* end if */ /* Set the pointer to the pinned superblock */ f->shared->sblock = sblock; /* Set the page aggregation mode */ - if(H5F__set_paged_aggr(f, (hbool_t)H5F_PAGED_AGGR(f)) < 0) + if (H5F__set_paged_aggr(f, (hbool_t)H5F_PAGED_AGGR(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set paged_aggr status for file driver") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Release the superblock */ - if(sblock && H5AC_unprotect(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0) + if (sblock && H5AC_unprotect(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock") /* If we have failed, make sure no entries are left in the * metadata cache, so that it can be shut down and discarded. */ - if(ret_value < 0) { + if (ret_value < 0) { /* Unpin and discard drvinfo cache entry */ - if(f->shared->drvinfo) { - if(H5AC_unpin_entry(f->shared->drvinfo) < 0) + if (f->shared->drvinfo) { + if (H5AC_unpin_entry(f->shared->drvinfo) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info") /* Evict the driver info block from the cache */ - if(H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block") } /* end if */ /* Unpin & discard superblock */ - if(sblock) { + if (sblock) { /* Unpin superblock in cache */ - if(H5AC_unpin_entry(sblock) < 0) + if (H5AC_unpin_entry(sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") /* Evict the superblock from the cache */ - if(H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5F__super_read() */ - /*------------------------------------------------------------------------- * Function: H5F__super_init * @@ -1075,51 +1082,52 @@ done: herr_t H5F__super_init(H5F_t *f) { - H5F_super_t *sblock = NULL; /* Superblock cache structure */ - hbool_t sblock_in_cache = FALSE; /* Whether the superblock has been inserted into the metadata cache */ - H5O_drvinfo_t *drvinfo = NULL; /* Driver info */ - hbool_t drvinfo_in_cache = FALSE; /* Whether the driver info block has been inserted into the metadata cache */ - H5P_genplist_t *plist; /* File creation property list */ - H5AC_ring_t orig_ring = H5AC_RING_INV; - hsize_t userblock_size; /* Size of userblock, in bytes */ - hsize_t superblock_size; /* Size of superblock, in bytes */ - size_t driver_size; /* Size of driver info block (bytes) */ - unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */ - H5O_loc_t ext_loc; /* Superblock extension object location */ - hbool_t need_ext; /* Whether the superblock extension is needed */ - hbool_t ext_created = FALSE; /* Whether the extension has been created */ - hbool_t non_default_fs_settings = FALSE; /* Whether the file has non-default free-space settings */ - herr_t ret_value = SUCCEED; /* Return Value */ + H5F_super_t *sblock = NULL; /* Superblock cache structure */ + hbool_t sblock_in_cache = FALSE; /* Whether the superblock has been inserted into the metadata cache */ + H5O_drvinfo_t *drvinfo = NULL; /* Driver info */ + hbool_t drvinfo_in_cache = + FALSE; /* Whether the driver info block has been inserted into the metadata cache */ + H5P_genplist_t *plist; /* File creation property list */ + H5AC_ring_t orig_ring = H5AC_RING_INV; + hsize_t userblock_size; /* Size of userblock, in bytes */ + hsize_t superblock_size; /* Size of superblock, in bytes */ + size_t driver_size; /* Size of driver info block (bytes) */ + unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */ + H5O_loc_t ext_loc; /* Superblock extension object location */ + hbool_t need_ext; /* Whether the superblock extension is needed */ + hbool_t ext_created = FALSE; /* Whether the extension has been created */ + hbool_t non_default_fs_settings = FALSE; /* Whether the file has non-default free-space settings */ + herr_t ret_value = SUCCEED; /* Return Value */ FUNC_ENTER_PACKAGE_TAG(H5AC__SUPERBLOCK_TAG) /* Allocate space for the superblock */ - if(NULL == (sblock = H5FL_CALLOC(H5F_super_t))) + if (NULL == (sblock = H5FL_CALLOC(H5F_super_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize various address information */ - sblock->base_addr = HADDR_UNDEF; - sblock->ext_addr = HADDR_UNDEF; + sblock->base_addr = HADDR_UNDEF; + sblock->ext_addr = HADDR_UNDEF; sblock->driver_addr = HADDR_UNDEF; - sblock->root_addr = HADDR_UNDEF; + sblock->root_addr = HADDR_UNDEF; /* Get the shared file creation property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Initialize sym_leaf_k */ - if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) + if (H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object size") /* Initialize btree_k */ - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &sblock->btree_k[0]) < 0) + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &sblock->btree_k[0]) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") /* Check for non-default free-space settings */ - if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && - f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) + if (!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) non_default_fs_settings = TRUE; /* @@ -1152,12 +1160,13 @@ H5F__super_init(H5F_t *f) * Creating a file with SWMR-write access will * upgrade superblock version and low_bound */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { - super_vers = HDF5_SUPERBLOCK_VERSION_3; + if (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { + super_vers = HDF5_SUPERBLOCK_VERSION_3; f->shared->low_bound = MAX(H5F_LIBVER_V110, f->shared->low_bound); - /* Bump superblock version to create superblock extension for SOHM info */ - } else if(f->shared->sohm_nindexes > 0) + /* Bump superblock version to create superblock extension for SOHM info */ + } + else if (f->shared->sohm_nindexes > 0) super_vers = HDF5_SUPERBLOCK_VERSION_2; /* * Bump superblock version to create superblock extension for: @@ -1166,33 +1175,33 @@ H5F__super_init(H5F_t *f) * -- non-default free-space threshold or * -- non-default page_size */ - else if(non_default_fs_settings) + else if (non_default_fs_settings) super_vers = HDF5_SUPERBLOCK_VERSION_2; /* Check for non-default indexed storage B-tree internal 'K' value * and set the version # of the superblock to 1 if it is a non-default * value. */ - else if(sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF) + else if (sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF) super_vers = HDF5_SUPERBLOCK_VERSION_1; /* Finalize superblock version to that allowed by the file's low bound if higher */ super_vers = MAX(super_vers, HDF5_superblock_ver_bounds[f->shared->low_bound]); /* Version bounds check */ - if(super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) + if (super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version out of bounds") /* If a newer superblock version is required, set it here */ - if(super_vers != HDF5_SUPERBLOCK_VERSION_DEF) { - H5P_genplist_t *c_plist; /* Property list */ + if (super_vers != HDF5_SUPERBLOCK_VERSION_DEF) { + H5P_genplist_t *c_plist; /* Property list */ - if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + if (NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") - if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) + if (H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version") } /* end if */ - if(H5FD_set_paged_aggr(f->shared->lf, (hbool_t)H5F_PAGED_AGGR(f)) < 0) + if (H5FD_set_paged_aggr(f->shared->lf, (hbool_t)H5F_PAGED_AGGR(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set paged_aggr status for file driver") /* @@ -1201,35 +1210,36 @@ H5F__super_init(H5F_t *f) * base address is set to the same thing as the superblock for * now. */ - if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) + if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get userblock size") /* Sanity check the userblock size vs. the file's allocation alignment */ - if(userblock_size > 0) { + if (userblock_size > 0) { /* Set up the alignment to use for page or aggr fs */ hsize_t alignment = H5F_PAGED_AGGR(f) ? f->shared->fs_page_size : f->shared->alignment; - if(userblock_size < alignment) + if (userblock_size < alignment) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be > file object alignment") - if(0 != (userblock_size % alignment)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be an integral multiple of file object alignment") + if (0 != (userblock_size % alignment)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "userblock size must be an integral multiple of file object alignment") } /* end if */ - sblock->base_addr = userblock_size; + sblock->base_addr = userblock_size; sblock->status_flags = 0; /* Reserve space for the userblock */ - if(H5F__set_eoa(f, H5FD_MEM_SUPER, userblock_size) < 0) + if (H5F__set_eoa(f, H5FD_MEM_SUPER, userblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set EOA value for userblock") /* Set the base address for the file in the VFD now, after allocating * space for userblock. */ - if(H5F__set_base_addr(f, sblock->base_addr) < 0) + if (H5F__set_base_addr(f, sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set base address for file driver") /* Save a local copy of the superblock version number, size of addresses & offsets */ - sblock->super_vers = super_vers; + sblock->super_vers = super_vers; sblock->sizeof_addr = f->shared->sizeof_addr; sblock->sizeof_size = f->shared->sizeof_size; @@ -1243,12 +1253,12 @@ H5F__super_init(H5F_t *f) * for the driver info block, and sets the driver info block * address regardless of the version of the superblock. */ - if(driver_size > 0) { + if (driver_size > 0) { /* Add in the driver info header, for older superblocks */ /* Superblock versions >= 2 will put the driver info in a message * and don't need the header -QAK, 1/4/2017 */ - if(super_vers < HDF5_SUPERBLOCK_VERSION_2) + if (super_vers < HDF5_SUPERBLOCK_VERSION_2) driver_size += H5F_DRVINFOBLOCK_HDR_SIZE; /* @@ -1264,14 +1274,15 @@ H5F__super_init(H5F_t *f) * at the beginning of the file and only the first allocation request is * required to return memory at format address zero. */ - if(super_vers < HDF5_SUPERBLOCK_VERSION_2) + if (super_vers < HDF5_SUPERBLOCK_VERSION_2) superblock_size += driver_size; /* Set the ring type in the API context */ H5AC_set_ring(H5AC_RING_SB, &orig_ring); /* Insert superblock into cache, pinned */ - if(H5AC_insert_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, + H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "can't add superblock to cache") sblock_in_cache = TRUE; @@ -1279,8 +1290,8 @@ H5F__super_init(H5F_t *f) f->shared->sblock = sblock; /* Allocate space for the superblock */ - if(HADDR_UNDEF == H5MF_alloc(f, H5FD_MEM_SUPER, superblock_size)) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for superblock") + if (HADDR_UNDEF == H5MF_alloc(f, H5FD_MEM_SUPER, superblock_size)) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for superblock") /* set the drvinfo filed to NULL -- will overwrite this later if needed */ f->shared->drvinfo = NULL; @@ -1290,12 +1301,12 @@ H5F__super_init(H5F_t *f) */ /* Files with SOHM indices always need the superblock extension */ - if(f->shared->sohm_nindexes > 0) { + if (f->shared->sohm_nindexes > 0) { HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2); need_ext = TRUE; } /* end if */ /* Files with non-default free space settings always need the superblock extension */ - else if(non_default_fs_settings) { + else if (non_default_fs_settings) { HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2); need_ext = TRUE; } /* end if */ @@ -1303,14 +1314,14 @@ H5F__super_init(H5F_t *f) * for the superblock extension, check for non-default values to store * in it. */ - else if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) { + else if (super_vers >= HDF5_SUPERBLOCK_VERSION_2) { /* Check for non-default v1 B-tree 'K' values to store */ - if(sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || - sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || - sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) + if (sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || + sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || + sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) need_ext = TRUE; /* Check for driver info to store */ - else if(driver_size > 0) + else if (driver_size > 0) need_ext = TRUE; else need_ext = FALSE; @@ -1322,7 +1333,7 @@ H5F__super_init(H5F_t *f) H5AC_set_ring(H5AC_RING_SBE, NULL); /* Create the superblock extension for "extra" superblock data, if necessary. */ - if(need_ext) { + if (need_ext) { /* The superblock extension isn't actually a group, but the * default group creation list should work fine. * If we don't supply a size for the object header, HDF5 will @@ -1331,50 +1342,52 @@ H5F__super_init(H5F_t *f) * be tuned if more information is added to the superblock * extension. */ - if(H5F__super_ext_create(f, &ext_loc) < 0) + if (H5F__super_ext_create(f, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension") ext_created = TRUE; /* Create the Shared Object Header Message table and register it with * the metadata cache, if this file supports shared messages. */ - if(f->shared->sohm_nindexes > 0) { + if (f->shared->sohm_nindexes > 0) { /* Initialize the shared message code & write the SOHM message to the extension */ - if(H5SM_init(f, plist, &ext_loc) < 0) + if (H5SM_init(f, plist, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create SOHM table") } /* Check for non-default v1 B-tree 'K' values to store */ - if(sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || - sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || - sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) { - H5O_btreek_t btreek; /* v1 B-tree 'K' value message for superblock extension */ + if (sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || + sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || + sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) { + H5O_btreek_t btreek; /* v1 B-tree 'K' value message for superblock extension */ /* Write v1 B-tree 'K' value information to the superblock extension */ btreek.btree_k[H5B_CHUNK_ID] = sblock->btree_k[H5B_CHUNK_ID]; btreek.btree_k[H5B_SNODE_ID] = sblock->btree_k[H5B_SNODE_ID]; - btreek.sym_leaf_k = sblock->sym_leaf_k; - if(H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &btreek) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update v1 B-tree 'K' value header message") + btreek.sym_leaf_k = sblock->sym_leaf_k; + if (H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, + H5O_UPDATE_TIME, &btreek) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, + "unable to update v1 B-tree 'K' value header message") } /* end if */ /* Check for driver info to store */ - if(driver_size > 0) { - H5O_drvinfo_t info; /* Driver info */ - uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ + if (driver_size > 0) { + H5O_drvinfo_t info; /* Driver info */ + uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ /* Sanity check */ HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); /* Encode driver-specific data */ HDmemset(dbuf, 0, sizeof(dbuf)); - if(H5FD_sb_encode(f->shared->lf, info.name, dbuf) < 0) + if (H5FD_sb_encode(f->shared->lf, info.name, dbuf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Write driver info information to the superblock extension */ info.len = driver_size; info.buf = dbuf; - if(H5O_msg_create(&ext_loc, H5O_DRVINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &info) < 0) + if (H5O_msg_create(&ext_loc, H5O_DRVINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update driver info header message") HDassert(FALSE == f->shared->drvinfo_sb_msg_exists); @@ -1382,39 +1395,40 @@ H5F__super_init(H5F_t *f) } /* end if */ /* Check for non-default free-space info settings */ - if(non_default_fs_settings) { + if (non_default_fs_settings) { H5F_mem_page_t ptype; - H5O_fsinfo_t fsinfo; /* Free space manager info message */ + H5O_fsinfo_t fsinfo; /* Free space manager info message */ /* Write free-space manager info message to superblock extension object header if needed */ - fsinfo.strategy = f->shared->fs_strategy; - fsinfo.persist = f->shared->fs_persist; - fsinfo.threshold = f->shared->fs_threshold; - fsinfo.page_size = f->shared->fs_page_size; - fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; + fsinfo.threshold = f->shared->fs_threshold; + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; - fsinfo.mapped = FALSE; + fsinfo.mapped = FALSE; /* Set the version for the fsinfo message */ - if(H5O_fsinfo_set_version(H5F_LOW_BOUND(f), H5F_HIGH_BOUND(f), &fsinfo) < 0) + if (H5O_fsinfo_set_version(H5F_LOW_BOUND(f), H5F_HIGH_BOUND(f), &fsinfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set version of fsinfo") f->shared->fs_version = fsinfo.version; - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; - if(H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, H5O_UPDATE_TIME, &fsinfo) < 0) + if (H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, + H5O_UPDATE_TIME, &fsinfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update free-space info header message") - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* Check for creating an "old-style" driver info block */ - if(driver_size > 0) { + if (driver_size > 0) { /* Sanity check */ HDassert(H5F_addr_defined(sblock->driver_addr)); /* Allocate space for the driver info */ - if(NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) + if (NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "memory allocation failed for driver info message") /* Set up driver info message */ @@ -1426,9 +1440,11 @@ H5F__super_init(H5F_t *f) H5_CHECKED_ASSIGN(drvinfo->len, size_t, H5FD_sb_size(f->shared->lf), hsize_t); /* Insert driver info block into cache */ - if(H5AC_insert_entry(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, + H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | + H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINS, FAIL, "can't add driver info block to cache") - drvinfo_in_cache = TRUE; + drvinfo_in_cache = TRUE; f->shared->drvinfo = drvinfo; } /* end if */ else @@ -1437,25 +1453,25 @@ H5F__super_init(H5F_t *f) done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Close superblock extension, if it was created */ - if(ext_created && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) + if (ext_created && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") /* Cleanup on failure */ - if(ret_value < 0) { + if (ret_value < 0) { /* Check if the driver info block has been allocated yet */ - if(drvinfo) { + if (drvinfo) { /* Check if we've cached it already */ - if(drvinfo_in_cache) { + if (drvinfo_in_cache) { /* Unpin drvinfo in cache */ - if(H5AC_unpin_entry(drvinfo) < 0) + if (H5AC_unpin_entry(drvinfo) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info") /* Evict the driver info block from the cache */ - if(H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block") } /* end if */ else @@ -1464,31 +1480,30 @@ done: } /* end if */ /* Check if the superblock has been allocated yet */ - if(sblock) { + if (sblock) { /* Check if we've cached it already */ - if(sblock_in_cache) { + if (sblock_in_cache) { /* Unpin superblock in cache */ - if(H5AC_unpin_entry(sblock) < 0) + if (H5AC_unpin_entry(sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") /* Evict the superblock from the cache */ - if(H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") } /* end if */ else /* Free superblock */ - if(H5F__super_free(sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") + if (H5F__super_free(sblock) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") /* Reset variables in file structure */ f->shared->sblock = NULL; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5F__super_init() */ - /*------------------------------------------------------------------------- * Function: H5F_eoa_dirty * @@ -1505,7 +1520,7 @@ done: herr_t H5F_eoa_dirty(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1515,20 +1530,20 @@ H5F_eoa_dirty(H5F_t *f) HDassert(f->shared->sblock); /* Mark superblock dirty in cache, so change to EOA will get encoded */ - if(H5F_super_dirty(f) < 0) + if (H5F_super_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") /* If the driver information block exists, mark it dirty as well * so that the change in eoa will be reflected there as well if * appropriate. */ - if(f->shared->drvinfo) { - if(H5AC_mark_entry_dirty(f->shared->drvinfo) < 0) + if (f->shared->drvinfo) { + if (H5AC_mark_entry_dirty(f->shared->drvinfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark drvinfo as dirty") } /* end if */ /* If the driver info is stored as a message, update that instead */ - else if(f->shared->drvinfo_sb_msg_exists) { - if(H5F__update_super_ext_driver_msg(f) < 0) + else if (f->shared->drvinfo_sb_msg_exists) { + if (H5F__update_super_ext_driver_msg(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark drvinfo message as dirty") } @@ -1536,7 +1551,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_eoa_dirty() */ - /*------------------------------------------------------------------------- * Function: H5F_super_dirty * @@ -1553,7 +1567,7 @@ done: herr_t H5F_super_dirty(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1563,14 +1577,13 @@ H5F_super_dirty(H5F_t *f) HDassert(f->shared->sblock); /* Mark superblock dirty in cache, so change to EOA will get encoded */ - if(H5AC_mark_entry_dirty(f->shared->sblock) < 0) + if (H5AC_mark_entry_dirty(f->shared->sblock) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_super_dirty() */ - /*------------------------------------------------------------------------- * Function: H5F__super_free * @@ -1601,7 +1614,6 @@ H5F__super_free(H5F_super_t *sblock) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F__super_free() */ - /*------------------------------------------------------------------------- * Function: H5F__super_size * @@ -1618,8 +1630,8 @@ H5F__super_free(H5F_super_t *sblock) herr_t H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1629,14 +1641,14 @@ H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) HDassert(f->shared->sblock); /* Set the superblock size */ - if(super_size) - *super_size = (hsize_t)H5F_SUPERBLOCK_SIZE(f->shared->sblock); + if (super_size) + *super_size = (hsize_t)H5F_SUPERBLOCK_SIZE(f->shared->sblock); /* Set the superblock extension size */ - if(super_ext_size) { - if(H5F_addr_defined(f->shared->sblock->ext_addr)) { - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - H5O_hdr_info_t hdr_info; /* Object info for superblock extension */ + if (super_ext_size) { + if (H5F_addr_defined(f->shared->sblock->ext_addr)) { + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + H5O_hdr_info_t hdr_info; /* Object info for superblock extension */ /* Set up "fake" object location for superblock extension */ H5O_loc_reset(&ext_loc); @@ -1647,7 +1659,7 @@ H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) H5AC_set_ring(H5AC_RING_SBE, &orig_ring); /* Get object header info for superblock extension */ - if(H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) + if (H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info") /* Set the superblock extension size */ @@ -1660,13 +1672,12 @@ H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_size() */ - /*------------------------------------------------------------------------- * Function: H5F__super_ext_write_msg() * @@ -1679,15 +1690,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, - hbool_t may_create, unsigned mesg_flags) +H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, unsigned mesg_flags) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - hbool_t ext_created = FALSE; /* Whether superblock extension was created */ - hbool_t ext_opened = FALSE; /* Whether superblock extension was opened */ - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - htri_t status; /* Indicate whether the message exists or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + hbool_t ext_created = FALSE; /* Whether superblock extension was created */ + hbool_t ext_opened = FALSE; /* Whether superblock extension was opened */ + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + htri_t status; /* Indicate whether the message exists or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1700,13 +1710,13 @@ H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, H5AC_set_ring(H5AC_RING_SBE, &orig_ring); /* Open/create the superblock extension object header */ - if(H5F_addr_defined(f->shared->sblock->ext_addr)) { - if(H5F__super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) + if (H5F_addr_defined(f->shared->sblock->ext_addr)) { + if (H5F__super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension") } /* end if */ else { HDassert(may_create); - if(H5F__super_ext_create(f, &ext_loc) < 0) + if (H5F__super_ext_create(f, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension") ext_created = TRUE; } /* end else */ @@ -1714,44 +1724,44 @@ H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, ext_opened = TRUE; /* Check if message with ID does not exist in the object header */ - if((status = H5O_msg_exists(&ext_loc, id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check object header for message or message exists") + if ((status = H5O_msg_exists(&ext_loc, id)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, + "unable to check object header for message or message exists") /* Check for creating vs. writing */ - if(may_create) { - if(status) + if (may_create) { + if (status) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist") /* Create the message with ID in the superblock extension */ - if(H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) + if (H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to create the message in object header") } /* end if */ else { - if(!status) + if (!status) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist") /* Update the message with ID in the superblock extension */ - if(H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) + if (H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to write the message in object header") } /* end else */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Close the superblock extension, if it was opened */ - if(ext_opened && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) + if (ext_opened && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") /* Mark superblock dirty in cache, if superblock extension was created */ - if(ext_created && H5AC_mark_entry_dirty(f->shared->sblock) < 0) + if (ext_created && H5AC_mark_entry_dirty(f->shared->sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_write_msg() */ - /*------------------------------------------------------------------------- * Function: H5F__super_ext_remove_msg * @@ -1766,12 +1776,12 @@ done: herr_t H5F__super_ext_remove_msg(H5F_t *f, unsigned id) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - hbool_t ext_opened = FALSE; /* Whether the superblock extension was opened */ - int null_count = 0; /* # of null messages */ - htri_t status; /* Indicate whether the message exists or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + hbool_t ext_opened = FALSE; /* Whether the superblock extension was opened */ + int null_count = 0; /* # of null messages */ + htri_t status; /* Indicate whether the message exists or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1782,47 +1792,46 @@ H5F__super_ext_remove_msg(H5F_t *f, unsigned id) H5AC_set_ring(H5AC_RING_SBE, &orig_ring); /* Open superblock extension object header */ - if(H5F__super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) + if (H5F__super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in starting file's superblock extension") ext_opened = TRUE; /* Check if message with ID exists in the object header */ - if((status = H5O_msg_exists(&ext_loc, id)) < 0) + if ((status = H5O_msg_exists(&ext_loc, id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message") - else if(status) { + else if (status) { /* message exists */ - H5O_hdr_info_t hdr_info; /* Object header info for superblock extension */ + H5O_hdr_info_t hdr_info; /* Object header info for superblock extension */ /* Remove the message */ - if(H5O_msg_remove(&ext_loc, id, H5O_ALL, TRUE) < 0) + if (H5O_msg_remove(&ext_loc, id, H5O_ALL, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete free-space manager info message") /* Get info for the superblock extension's object header */ - if(H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) + if (H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info") /* If the object header is an empty base chunk, remove superblock extension */ - if(hdr_info.nchunks == 1) { - if((null_count = H5O_msg_count(&ext_loc, H5O_NULL_ID)) < 0) + if (hdr_info.nchunks == 1) { + if ((null_count = H5O_msg_count(&ext_loc, H5O_NULL_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count messages") - else if((unsigned)null_count == hdr_info.nmesgs) { + else if ((unsigned)null_count == hdr_info.nmesgs) { HDassert(H5F_addr_defined(ext_loc.addr)); - if(H5O_delete(f, ext_loc.addr) < 0) + if (H5O_delete(f, ext_loc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count messages") f->shared->sblock->ext_addr = HADDR_UNDEF; } /* end else-if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Close superblock extension object header, if opened */ - if(ext_opened && H5F__super_ext_close(f, &ext_loc, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") + if (ext_opened && H5F__super_ext_close(f, &ext_loc, FALSE) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_remove_msg() */ - diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 8af3932..a614eef 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -26,75 +26,62 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache (H5AC) callbacks */ static herr_t H5F__cache_superblock_get_initial_load_size(void *udata, size_t *image_len); -static herr_t H5F__cache_superblock_get_final_load_size(const void *image_ptr, - size_t image_len, void *udata, size_t *actual_len); +static herr_t H5F__cache_superblock_get_final_load_size(const void *image_ptr, size_t image_len, void *udata, + size_t *actual_len); static htri_t H5F__cache_superblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5F__cache_superblock_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5F__cache_superblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5F__cache_superblock_image_len(const void *thing, size_t *image_len); -static herr_t H5F__cache_superblock_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5F__cache_superblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5F__cache_superblock_free_icr(void *thing); static herr_t H5F__cache_drvrinfo_get_initial_load_size(void *udata, size_t *image_len); -static herr_t H5F__cache_drvrinfo_get_final_load_size(const void *image_ptr, - size_t image_len, void *udata, size_t *actual_len); -static void *H5F__cache_drvrinfo_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static herr_t H5F__cache_drvrinfo_get_final_load_size(const void *image_ptr, size_t image_len, void *udata, + size_t *actual_len); +static void * H5F__cache_drvrinfo_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5F__cache_drvrinfo_image_len(const void *thing, size_t *image_len); -static herr_t H5F__cache_drvrinfo_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5F__cache_drvrinfo_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5F__cache_drvrinfo_free_icr(void *thing); -static herr_t H5F__cache_superblock_refresh(H5F_t *f, void * _thing, const void * _image, - size_t * len_ptr); +static herr_t H5F__cache_superblock_refresh(H5F_t *f, void *_thing, const void *_image, size_t *len_ptr); /* Local encode/decode routines */ -static herr_t H5F__superblock_prefix_decode(H5F_super_t *sblock, - const uint8_t **image_ref, const H5F_superblock_cache_ud_t *udata, - hbool_t extend_eoa); -static herr_t H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvinfo, char *drv_name, - const uint8_t **image_ref, H5F_drvrinfo_cache_ud_t *udata, - hbool_t extend_eoa); - +static herr_t H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, + const H5F_superblock_cache_ud_t *udata, hbool_t extend_eoa); +static herr_t H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvinfo, char *drv_name, const uint8_t **image_ref, + H5F_drvrinfo_cache_ud_t *udata, hbool_t extend_eoa); /*********************/ /* Package Variables */ @@ -102,43 +89,42 @@ static herr_t H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvinfo, char *drv_name /* H5F superblock inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_SUPERBLOCK[1] = {{ - H5AC_SUPERBLOCK_ID, /* Metadata client ID */ - "Superblock", /* Metadata client name (for debugging) */ - H5FD_MEM_SUPER, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5F__cache_superblock_get_initial_load_size,/* 'get_initial_load_size' callback */ - H5F__cache_superblock_get_final_load_size, /* 'get_final_load_size' callback */ - H5F__cache_superblock_verify_chksum, /* 'verify_chksum' callback */ - H5F__cache_superblock_deserialize, /* 'deserialize' callback */ - H5F__cache_superblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5F__cache_superblock_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5F__cache_superblock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - H5F__cache_superblock_refresh, /* VFD SWMR 'refresh' callback */ + H5AC_SUPERBLOCK_ID, /* Metadata client ID */ + "Superblock", /* Metadata client name (for debugging) */ + H5FD_MEM_SUPER, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5F__cache_superblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5F__cache_superblock_get_final_load_size, /* 'get_final_load_size' callback */ + H5F__cache_superblock_verify_chksum, /* 'verify_chksum' callback */ + H5F__cache_superblock_deserialize, /* 'deserialize' callback */ + H5F__cache_superblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5F__cache_superblock_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5F__cache_superblock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + H5F__cache_superblock_refresh, /* VFD SWMR 'refresh' callback */ }}; /* H5F driver info block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_DRVRINFO[1] = {{ - H5AC_DRVRINFO_ID, /* Metadata client ID */ - "Driver info block", /* Metadata client name (for debugging) */ - H5FD_MEM_SUPER, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5F__cache_drvrinfo_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5F__cache_drvrinfo_get_final_load_size, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5F__cache_drvrinfo_deserialize, /* 'deserialize' callback */ - H5F__cache_drvrinfo_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5F__cache_drvrinfo_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5F__cache_drvrinfo_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_DRVRINFO_ID, /* Metadata client ID */ + "Driver info block", /* Metadata client name (for debugging) */ + H5FD_MEM_SUPER, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5F__cache_drvrinfo_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5F__cache_drvrinfo_get_final_load_size, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5F__cache_drvrinfo_deserialize, /* 'deserialize' callback */ + H5F__cache_drvrinfo_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5F__cache_drvrinfo_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5F__cache_drvrinfo_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -146,13 +132,10 @@ const H5AC_class_t H5AC_DRVRINFO[1] = {{ /* Declare extern the free list to manage the H5F_super_t struct */ H5FL_EXTERN(H5F_super_t); - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F__superblock_prefix_decode * @@ -167,10 +150,10 @@ H5FL_EXTERN(H5F_super_t); */ static herr_t H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, - const H5F_superblock_cache_ud_t *udata, hbool_t extend_eoa) + const H5F_superblock_cache_ud_t *udata, hbool_t extend_eoa) { - const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */ - htri_t ret_value = SUCCEED; /* Return value */ + const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -186,7 +169,7 @@ H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, /* Superblock version */ sblock->super_vers = *image++; - if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_LATEST) + if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_LATEST) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number") /* Sanity check */ @@ -195,7 +178,7 @@ H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, /* Determine the size of addresses & size of offsets, for computing the * variable-sized portion of the superblock. */ - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { sblock->sizeof_addr = image[4]; sblock->sizeof_size = image[5]; } /* end if */ @@ -203,23 +186,24 @@ H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, sblock->sizeof_addr = image[0]; sblock->sizeof_size = image[1]; } /* end else */ - if(sblock->sizeof_addr != 2 && sblock->sizeof_addr != 4 && - sblock->sizeof_addr != 8 && sblock->sizeof_addr != 16 && sblock->sizeof_addr != 32) + if (sblock->sizeof_addr != 2 && sblock->sizeof_addr != 4 && sblock->sizeof_addr != 8 && + sblock->sizeof_addr != 16 && sblock->sizeof_addr != 32) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address") - if(sblock->sizeof_size != 2 && sblock->sizeof_size != 4 && - sblock->sizeof_size != 8 && sblock->sizeof_size != 16 && sblock->sizeof_size != 32) + if (sblock->sizeof_size != 2 && sblock->sizeof_size != 4 && sblock->sizeof_size != 8 && + sblock->sizeof_size != 16 && sblock->sizeof_size != 32) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size") /* Check for extending the EOA for the file */ - if(extend_eoa) { - size_t variable_size; /* Variable size of superblock */ + if (extend_eoa) { + size_t variable_size; /* Variable size of superblock */ /* Determine the size of the variable-length part of the superblock */ - variable_size = (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock->super_vers, sblock->sizeof_addr, sblock->sizeof_size); + variable_size = + (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock->super_vers, sblock->sizeof_addr, sblock->sizeof_size); HDassert(variable_size > 0); /* Make certain we can read the variable-sized portion of the superblock */ - if(H5F__set_eoa(udata->f, H5FD_MEM_SUPER, (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + variable_size)) < 0) + if (H5F__set_eoa(udata->f, H5FD_MEM_SUPER, (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + variable_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") } /* end if */ @@ -230,7 +214,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__superblock_prefix_decode() */ - /*------------------------------------------------------------------------- * Function: H5F__drvrinfo_prefix_decode * @@ -244,13 +227,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, - const uint8_t **image_ref, H5F_drvrinfo_cache_ud_t *udata, - hbool_t extend_eoa) +H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, const uint8_t **image_ref, + H5F_drvrinfo_cache_ud_t *udata, hbool_t extend_eoa) { - const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */ - unsigned drv_vers; /* Version of driver info block */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */ + unsigned drv_vers; /* Version of driver info block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -263,7 +245,7 @@ H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, /* Version number */ drv_vers = *image++; - if(drv_vers != HDF5_DRIVERINFO_VERSION_0) + if (drv_vers != HDF5_DRIVERINFO_VERSION_0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad driver information block version number") image += 3; /* reserved bytes */ @@ -272,28 +254,28 @@ H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, UINT32DECODE(image, drvrinfo->len); /* Driver name and/or version */ - if(drv_name) { + if (drv_name) { H5MM_memcpy(drv_name, (const char *)image, (size_t)8); drv_name[8] = '\0'; image += 8; /* advance past name/version */ - } /* end if */ + } /* end if */ /* Extend the EOA if required so that we can read the complete driver info block */ - if(extend_eoa) { - haddr_t eoa; /* Current EOA for the file */ - haddr_t min_eoa; /* Minimum EOA needed for reading the driver info */ + if (extend_eoa) { + haddr_t eoa; /* Current EOA for the file */ + haddr_t min_eoa; /* Minimum EOA needed for reading the driver info */ /* Get current EOA... */ eoa = H5FD_get_eoa(udata->f->shared->lf, H5FD_MEM_SUPER); - if(!H5F_addr_defined(eoa)) + if (!H5F_addr_defined(eoa)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* ... if it is too small, extend it. */ min_eoa = udata->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drvrinfo->len; /* If it grew, set it */ - if(H5F_addr_gt(min_eoa, eoa)) - if(H5FD_set_eoa(udata->f->shared->lf, H5FD_MEM_SUPER, min_eoa) < 0) + if (H5F_addr_gt(min_eoa, eoa)) + if (H5FD_set_eoa(udata->f->shared->lf, H5FD_MEM_SUPER, min_eoa) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") } /* end if */ @@ -304,7 +286,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__drvrinfo_prefix_decode() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_get_initial_load_size * @@ -327,13 +308,12 @@ H5F__cache_superblock_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t HDassert(image_len); /* Set the initial image length size */ - *image_len = H5F_SUPERBLOCK_FIXED_SIZE + /* Fixed size of superblock */ + *image_len = H5F_SUPERBLOCK_FIXED_SIZE + /* Fixed size of superblock */ H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_superblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_get_final_load_size * @@ -349,12 +329,12 @@ H5F__cache_superblock_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t */ static herr_t H5F__cache_superblock_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *_udata, size_t *actual_len) + void *_udata, size_t *actual_len) { - const uint8_t *image = _image; /* Pointer into raw data buffer */ + const uint8_t * image = _image; /* Pointer into raw data buffer */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ - H5F_super_t sblock; /* Temporary file superblock */ - htri_t ret_value = SUCCEED; /* Return value */ + H5F_super_t sblock; /* Temporary file superblock */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -366,21 +346,20 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t H5_ATTR_NDE HDassert(image_len >= H5F_SUPERBLOCK_FIXED_SIZE + 6); /* Deserialize the file superblock's prefix */ - if(H5F__superblock_prefix_decode(&sblock, &image, udata, TRUE) < 0) + if (H5F__superblock_prefix_decode(&sblock, &image, udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file superblock prefix") /* Save the version to be used in verify_chksum callback */ udata->super_vers = sblock.super_vers; /* Set the final size for the cache image */ - *actual_len = H5F_SUPERBLOCK_FIXED_SIZE + - (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock.super_vers, sblock.sizeof_addr, sblock.sizeof_size); + *actual_len = H5F_SUPERBLOCK_FIXED_SIZE + (size_t)H5F_SUPERBLOCK_VARLEN_SIZE( + sblock.super_vers, sblock.sizeof_addr, sblock.sizeof_size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_superblock_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_verify_chksum * @@ -397,11 +376,11 @@ done: static htri_t H5F__cache_superblock_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t *image = _image; /* Pointer into raw data buffer */ + const uint8_t * image = _image; /* Pointer into raw data buffer */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -410,19 +389,18 @@ H5F__cache_superblock_verify_chksum(const void *_image, size_t len, void *_udata HDassert(udata); /* No checksum for version 0 & 1 */ - if(udata->super_vers >= HDF5_SUPERBLOCK_VERSION_2) { + if (udata->super_vers >= HDF5_SUPERBLOCK_VERSION_2) { - /* Get stored and computed checksums */ - H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); + /* Get stored and computed checksums */ + H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_superblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_deserialize * @@ -439,12 +417,12 @@ H5F__cache_superblock_verify_chksum(const void *_image, size_t len, void *_udata */ static void * H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) + hbool_t H5_ATTR_UNUSED *dirty) { - H5F_super_t *sblock = NULL; /* File's superblock */ - H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ - const uint8_t *image = _image; /* Pointer into raw data buffer */ - H5F_super_t *ret_value = NULL; /* Return value */ + H5F_super_t * sblock = NULL; /* File's superblock */ + H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ + const uint8_t * image = _image; /* Pointer into raw data buffer */ + H5F_super_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -455,59 +433,59 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS HDassert(len >= H5F_SUPERBLOCK_FIXED_SIZE + 6); /* Allocate space for the superblock */ - if(NULL == (sblock = H5FL_CALLOC(H5F_super_t))) + if (NULL == (sblock = H5FL_CALLOC(H5F_super_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Deserialize the file superblock's prefix */ - if(H5F__superblock_prefix_decode(sblock, &image, udata, FALSE) < 0) + if (H5F__superblock_prefix_decode(sblock, &image, udata, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file superblock prefix") /* Check for older version of superblock format */ - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { - uint32_t status_flags; /* File status flags */ - unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ - unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */ - unsigned chunk_btree_k; /* B-tree chunk internal node 'K' value */ + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + uint32_t status_flags; /* File status flags */ + unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ + unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */ + unsigned chunk_btree_k; /* B-tree chunk internal node 'K' value */ - /* Freespace version (hard-wired) */ - if(HDF5_FREESPACE_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad free space version number") + /* Freespace version (hard-wired) */ + if (HDF5_FREESPACE_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad free space version number") - /* Root group version number (hard-wired) */ - if(HDF5_OBJECTDIR_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad object directory version number") + /* Root group version number (hard-wired) */ + if (HDF5_OBJECTDIR_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad object directory version number") - /* Skip over reserved byte */ - image++; + /* Skip over reserved byte */ + image++; - /* Shared header version number (hard-wired) */ - if(HDF5_SHAREDHEADER_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number") + /* Shared header version number (hard-wired) */ + if (HDF5_SHAREDHEADER_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number") - /* Skip over size of file addresses (already decoded) */ - image++; - udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */ + /* Skip over size of file addresses (already decoded) */ + image++; + udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */ - /* Skip over size of file sizes (already decoded) */ - image++; - udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ + /* Skip over size of file sizes (already decoded) */ + image++; + udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ - /* Skip over reserved byte */ - image++; + /* Skip over reserved byte */ + image++; - /* Various B-tree sizes */ - UINT16DECODE(image, sym_leaf_k); - if(sym_leaf_k == 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad symbol table leaf node 1/2 rank") - udata->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ + /* Various B-tree sizes */ + UINT16DECODE(image, sym_leaf_k); + if (sym_leaf_k == 0) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad symbol table leaf node 1/2 rank") + udata->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ /* Need 'get' call to set other array values */ UINT16DECODE(image, snode_btree_k); - if(snode_btree_k == 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad 1/2 rank for btree internal nodes") - udata->btree_k[H5B_SNODE_ID] = snode_btree_k; + if (snode_btree_k == 0) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad 1/2 rank for btree internal nodes") + udata->btree_k[H5B_SNODE_ID] = snode_btree_k; - /* + /* * Delay setting the value in the property list until we've checked * for the indexed storage B-tree internal 'K' value later. */ @@ -516,89 +494,90 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS UINT32DECODE(image, status_flags); HDassert(status_flags <= 255); sblock->status_flags = (uint8_t)status_flags; - if(sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") + if (sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") - /* + /* * If the superblock version # is greater than 0, read in the indexed * storage B-tree internal 'K' value */ - if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { - UINT16DECODE(image, chunk_btree_k); - - /* Reserved bytes are present only in version 1 */ - if(sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1) - image += 2; /* reserved */ - } /* end if */ - else - chunk_btree_k = HDF5_BTREE_CHUNK_IK_DEF; - udata->btree_k[H5B_CHUNK_ID] = chunk_btree_k; - - /* Remainder of "variable-sized" portion of superblock */ - H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr/*out*/); - H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr/*out*/); - H5F_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof/*out*/); - H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->driver_addr/*out*/); - - /* Allocate space for the root group symbol table entry */ - HDassert(!sblock->root_ent); - if(NULL == (sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "can't allocate space for root group symbol table entry") - - /* decode the root group symbol table entry */ - if(H5G_ent_decode(udata->f, (const uint8_t **)&image, sblock->root_ent) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode root group symbol table entry") - - /* Set the root group address to the correct value */ - sblock->root_addr = sblock->root_ent->header; - - /* This step is for h5repart tool only. If user wants to change file driver + if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + UINT16DECODE(image, chunk_btree_k); + + /* Reserved bytes are present only in version 1 */ + if (sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1) + image += 2; /* reserved */ + } /* end if */ + else + chunk_btree_k = HDF5_BTREE_CHUNK_IK_DEF; + udata->btree_k[H5B_CHUNK_ID] = chunk_btree_k; + + /* Remainder of "variable-sized" portion of superblock */ + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->driver_addr /*out*/); + + /* Allocate space for the root group symbol table entry */ + HDassert(!sblock->root_ent); + if (NULL == (sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, + "can't allocate space for root group symbol table entry") + + /* decode the root group symbol table entry */ + if (H5G_ent_decode(udata->f, (const uint8_t **)&image, sblock->root_ent) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode root group symbol table entry") + + /* Set the root group address to the correct value */ + sblock->root_addr = sblock->root_ent->header; + + /* This step is for h5repart tool only. If user wants to change file driver * from family to sec2 while using h5repart, set the driver address to * undefined to let the library ignore the family driver information saved * in the superblock. */ - if(udata->ignore_drvrinfo && H5F_addr_defined(sblock->driver_addr)) { - /* Eliminate the driver info */ - sblock->driver_addr = HADDR_UNDEF; + if (udata->ignore_drvrinfo && H5F_addr_defined(sblock->driver_addr)) { + /* Eliminate the driver info */ + sblock->driver_addr = HADDR_UNDEF; udata->drvrinfo_removed = TRUE; - } /* end if */ + } /* end if */ - /* NOTE: Driver info block is decoded separately, later */ + /* NOTE: Driver info block is decoded separately, later */ } /* end if */ else { - uint32_t read_chksum; /* Checksum read from file */ + uint32_t read_chksum; /* Checksum read from file */ /* Skip over size of file addresses (already decoded) */ image++; - udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */ + udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */ - /* Skip over size of file sizes (already decoded) */ - image++; - udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ + /* Skip over size of file sizes (already decoded) */ + image++; + udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ - /* File status flags (not really used yet) */ - sblock->status_flags = *image++; - if(sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") + /* File status flags (not really used yet) */ + sblock->status_flags = *image++; + if (sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") - /* Base, superblock extension, end of file & root group object header addresses */ - H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr/*out*/); - H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr/*out*/); - H5F_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof/*out*/); - H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->root_addr/*out*/); + /* Base, superblock extension, end of file & root group object header addresses */ + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->root_addr /*out*/); - /* checksum verification already done in verify_chksum cb */ + /* checksum verification already done in verify_chksum cb */ - /* Decode checksum */ - UINT32DECODE(image, read_chksum); + /* Decode checksum */ + UINT32DECODE(image, read_chksum); - /* The Driver Information Block may not appear with the version - * 2 super block. Thus we set the driver_addr field of the in + /* The Driver Information Block may not appear with the version + * 2 super block. Thus we set the driver_addr field of the in * core representation of the super block HADDR_UNDEF to prevent * any attempt to load the Driver Information Block. - */ - sblock->driver_addr = HADDR_UNDEF; + */ + sblock->driver_addr = HADDR_UNDEF; } /* end else */ /* Sanity check */ @@ -609,14 +588,13 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS done: /* Release the [possibly partially initialized] superblock on error */ - if(!ret_value && sblock) - if(H5F__super_free(sblock) < 0) + if (!ret_value && sblock) + if (H5F__super_free(sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_superblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_image_len * @@ -633,7 +611,7 @@ done: static herr_t H5F__cache_superblock_image_len(const void *_thing, size_t *image_len) { - const H5F_super_t *sblock = (const H5F_super_t *)_thing; /* Pointer to the object */ + const H5F_super_t *sblock = (const H5F_super_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -649,7 +627,6 @@ H5F__cache_superblock_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_superblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_serialize * @@ -664,13 +641,12 @@ H5F__cache_superblock_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) +H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { - H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ - uint8_t *image = _image; /* Pointer into raw data buffer */ - haddr_t rel_eof; /* Relative EOF for file */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ + uint8_t * image = _image; /* Pointer into raw data buffer */ + haddr_t rel_eof; /* Relative EOF for file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -691,15 +667,15 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU *image++ = (uint8_t)sblock->super_vers; /* Check for older version of superblock format */ - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { - *image++ = (uint8_t)HDF5_FREESPACE_VERSION; /* (hard-wired) */ - *image++ = (uint8_t)HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ - *image++ = 0; /* reserved*/ + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + *image++ = (uint8_t)HDF5_FREESPACE_VERSION; /* (hard-wired) */ + *image++ = (uint8_t)HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ + *image++ = 0; /* reserved*/ - *image++ = (uint8_t)HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ + *image++ = (uint8_t)HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ *image++ = sblock->sizeof_addr; *image++ = sblock->sizeof_size; - *image++ = 0; /* reserved */ + *image++ = 0; /* reserved */ UINT16ENCODE(image, sblock->sym_leaf_k); UINT16ENCODE(image, sblock->btree_k[H5B_SNODE_ID]); @@ -709,11 +685,11 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU * Versions of the superblock >0 have the indexed storage B-tree * internal 'K' value stored */ - if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { UINT16ENCODE(image, sblock->btree_k[H5B_CHUNK_ID]); - *image++ = 0; /*reserved */ - *image++ = 0; /*reserved */ - } /* end if */ + *image++ = 0; /*reserved */ + *image++ = 0; /*reserved */ + } /* end if */ /* Encode the base address */ H5F_addr_encode(f, &image, sblock->base_addr); @@ -734,15 +710,15 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU H5F_addr_encode(f, &image, sblock->driver_addr); /* Encode the root group object entry, including the cached stab info */ - if(H5G_ent_encode(f, &image, sblock->root_ent) < 0) + if (H5G_ent_encode(f, &image, sblock->root_ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTENCODE, FAIL, "can't encode root group symbol table entry") /* NOTE: Driver info block is handled separately */ - } /* end if */ - else { /* sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 */ - uint32_t chksum; /* Checksum temporary variable */ - H5O_loc_t *root_oloc; /* Pointer to root group's object location */ + } /* end if */ + else { /* sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 */ + uint32_t chksum; /* Checksum temporary variable */ + H5O_loc_t *root_oloc; /* Pointer to root group's object location */ /* Size of file addresses & offsets, and status flags */ *image++ = sblock->sizeof_addr; @@ -765,7 +741,7 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU H5F_addr_encode(f, &image, (rel_eof + sblock->base_addr)); /* Retrieve information for root group */ - if(NULL == (root_oloc = H5G_oloc(f->shared->root_grp))) + if (NULL == (root_oloc = H5G_oloc(f->shared->root_grp))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to retrieve root group information") /* Encode address of root group's object header */ @@ -788,7 +764,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__cache_superblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_free_icr * @@ -810,8 +785,8 @@ done: static herr_t H5F__cache_superblock_free_icr(void *_thing) { - H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -821,14 +796,13 @@ H5F__cache_superblock_free_icr(void *_thing) HDassert(sblock->cache_info.type == H5AC_SUPERBLOCK); /* Destroy superblock */ - if(H5F__super_free(sblock) < 0) + if (H5F__super_free(sblock) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free superblock") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__cache_superblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_get_initial_load_size * @@ -851,12 +825,11 @@ H5F__cache_drvrinfo_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *i HDassert(image_len); /* Set the initial image length size */ - *image_len = H5F_DRVINFOBLOCK_HDR_SIZE; /* Fixed size portion of driver info block */ + *image_len = H5F_DRVINFOBLOCK_HDR_SIZE; /* Fixed size portion of driver info block */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_drvrinfo_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_get_final_load_size * @@ -872,12 +845,12 @@ H5F__cache_drvrinfo_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *i */ static herr_t H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *_udata, size_t *actual_len) + void *_udata, size_t *actual_len) { - const uint8_t *image = _image; /* Pointer into raw data buffer */ - H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ - H5O_drvinfo_t drvrinfo; /* Driver info */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t * image = _image; /* Pointer into raw data buffer */ + H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ + H5O_drvinfo_t drvrinfo; /* Driver info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -889,7 +862,7 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBU HDassert(image_len == H5F_DRVINFOBLOCK_HDR_SIZE); /* Deserialize the file driver info's prefix */ - if(H5F__drvrinfo_prefix_decode(&drvrinfo, NULL, &image, udata, TRUE) < 0) + if (H5F__drvrinfo_prefix_decode(&drvrinfo, NULL, &image, udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file driver info prefix") /* Set the final size for the cache image */ @@ -899,7 +872,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_drvrinfo_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_deserialize * @@ -916,13 +888,13 @@ done: */ static void * H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) + hbool_t H5_ATTR_UNUSED *dirty) { - H5O_drvinfo_t *drvinfo = NULL; /* Driver info */ - H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ - const uint8_t *image = _image; /* Pointer into raw data buffer */ - char drv_name[9]; /* Name of driver */ - H5O_drvinfo_t *ret_value = NULL; /* Return value */ + H5O_drvinfo_t * drvinfo = NULL; /* Driver info */ + H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ + const uint8_t * image = _image; /* Pointer into raw data buffer */ + char drv_name[9]; /* Name of driver */ + H5O_drvinfo_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -933,19 +905,19 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert(udata->f); /* Allocate space for the driver info */ - if(NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "memory allocation failed for driver info message") + if (NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "memory allocation failed for driver info message") /* Deserialize the file driver info's prefix */ - if(H5F__drvrinfo_prefix_decode(drvinfo, drv_name, &image, udata, FALSE) < 0) + if (H5F__drvrinfo_prefix_decode(drvinfo, drv_name, &image, udata, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file driver info prefix") /* Sanity check */ HDassert(len == (H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo->len)); /* Validate and decode driver information */ - if(H5FD_sb_load(udata->f->shared->lf, drv_name, image) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "unable to decode driver information") + if (H5FD_sb_load(udata->f->shared->lf, drv_name, image) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "unable to decode driver information") /* Sanity check */ HDassert((size_t)(image - (const uint8_t *)_image) <= len); @@ -955,13 +927,12 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED done: /* Release the [possibly partially initialized] driver info message on error */ - if(!ret_value && drvinfo) + if (!ret_value && drvinfo) H5MM_xfree(drvinfo); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_drvrinfo_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_image_len * @@ -978,7 +949,7 @@ done: static herr_t H5F__cache_drvrinfo_image_len(const void *_thing, size_t *image_len) { - const H5O_drvinfo_t *drvinfo = (const H5O_drvinfo_t *)_thing; /* Pointer to the object */ + const H5O_drvinfo_t *drvinfo = (const H5O_drvinfo_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -989,13 +960,12 @@ H5F__cache_drvrinfo_image_len(const void *_thing, size_t *image_len) HDassert(image_len); /* Set the image length size */ - *image_len = (size_t)(H5F_DRVINFOBLOCK_HDR_SIZE + /* Fixed-size portion of driver info block */ - drvinfo->len); /* Variable-size portion of driver info block */ + *image_len = (size_t)(H5F_DRVINFOBLOCK_HDR_SIZE + /* Fixed-size portion of driver info block */ + drvinfo->len); /* Variable-size portion of driver info block */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_drvrinfo_image_len() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_serialize * @@ -1010,13 +980,12 @@ H5F__cache_drvrinfo_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ - uint8_t *image = _image; /* Pointer into raw data buffer */ - uint8_t *dbuf; /* Pointer to beginning of driver info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ + uint8_t * image = _image; /* Pointer into raw data buffer */ + uint8_t * dbuf; /* Pointer to beginning of driver info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1033,15 +1002,15 @@ H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBU /* Encode the driver information block */ *image++ = HDF5_DRIVERINFO_VERSION_0; /* Version */ - *image++ = 0; /* reserved */ - *image++ = 0; /* reserved */ - *image++ = 0; /* reserved */ + *image++ = 0; /* reserved */ + *image++ = 0; /* reserved */ + *image++ = 0; /* reserved */ /* Driver info size, excluding header */ UINT32ENCODE(image, drvinfo->len); /* Encode driver-specific data */ - if(H5FD_sb_encode(f->shared->lf, (char *)image, dbuf + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) + if (H5FD_sb_encode(f->shared->lf, (char *)image, dbuf + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Advance buffer pointer past name & variable-sized portion of driver info */ @@ -1054,7 +1023,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__cache_drvrinfo_serialize() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_free_icr * @@ -1076,7 +1044,7 @@ done: static herr_t H5F__cache_drvrinfo_free_icr(void *_thing) { - H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ + H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -1091,21 +1059,20 @@ H5F__cache_drvrinfo_free_icr(void *_thing) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F__cache_drvrinfo_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_refresh * - * Purpose: Examine the supplied image buffer, and update the + * Purpose: Examine the supplied image buffer, and update the * superblock accordingly. * - * This function is only called when the file is opened in - * VFD SWMR reader mode -- which implies that the file has - * been opened R/O. Thus the internal representation of - * the superblock must be clean, and may be modified without + * This function is only called when the file is opened in + * VFD SWMR reader mode -- which implies that the file has + * been opened R/O. Thus the internal representation of + * the superblock must be clean, and may be modified without * concern for local changes. * * Further, most of the superblock is fixed once the file - * is created, for the most part, this function simply + * is created, for the most part, this function simply * verifies the expected values. * * Return: Success: SUCCEED @@ -1118,26 +1085,25 @@ H5F__cache_drvrinfo_free_icr(void *_thing) * *------------------------------------------------------------------------- */ -static herr_t -H5F__cache_superblock_refresh(H5F_t *f, void * _thing, const void * _image, - size_t * len_ptr) +static herr_t +H5F__cache_superblock_refresh(H5F_t *f, void *_thing, const void *_image, size_t *len_ptr) { - H5F_super_t *sblock = (H5F_super_t *)_thing; - const uint8_t *image = (const uint8_t *)_image; - size_t expected_image_len; - unsigned super_vers; /* Superblock version */ - uint8_t sizeof_addr; /* Size of addresses in file */ - uint8_t sizeof_size; /* Size of offsets in file */ - uint32_t status_flags; /* File status flags */ - unsigned sym_leaf_k; /* Size of leaves in symbol tables */ - haddr_t base_addr; /* Absolute base address for rel.addrs. */ - /* (superblock for file is at this offset) */ + H5F_super_t * sblock = (H5F_super_t *)_thing; + const uint8_t *image = (const uint8_t *)_image; + size_t expected_image_len; + unsigned super_vers; /* Superblock version */ + uint8_t sizeof_addr; /* Size of addresses in file */ + uint8_t sizeof_size; /* Size of offsets in file */ + uint32_t status_flags; /* File status flags */ + unsigned sym_leaf_k; /* Size of leaves in symbol tables */ + haddr_t base_addr; /* Absolute base address for rel.addrs. */ + /* (superblock for file is at this offset) */ haddr_t stored_eof; - haddr_t ext_addr; /* Relative address of superblock extension */ - haddr_t driver_addr; /* File driver information block address */ - haddr_t root_addr; /* Root group address */ - H5G_entry_t root_ent; /* Root group symbol table entry */ - herr_t ret_value = SUCCEED; + haddr_t ext_addr; /* Relative address of superblock extension */ + haddr_t driver_addr; /* File driver information block address */ + haddr_t root_addr; /* Root group address */ + H5G_entry_t root_ent; /* Root group symbol table entry */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1154,12 +1120,12 @@ H5F__cache_superblock_refresh(H5F_t *f, void * _thing, const void * _image, /* get the superblock version */ super_vers = *image++; - - if ( sblock->super_vers != super_vers ) + + if (sblock->super_vers != super_vers) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected superblock vers") /* verify sizes of addresses and offsets */ - if(super_vers < HDF5_SUPERBLOCK_VERSION_2) { + if (super_vers < HDF5_SUPERBLOCK_VERSION_2) { sizeof_addr = image[4]; sizeof_size = image[5]; } /* end if */ @@ -1168,64 +1134,64 @@ H5F__cache_superblock_refresh(H5F_t *f, void * _thing, const void * _image, sizeof_size = image[1]; } /* end else */ - if ( sblock->sizeof_addr != sizeof_addr ) + if (sblock->sizeof_addr != sizeof_addr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected sizeof_addr") - if ( sblock->sizeof_size != sizeof_size ) + if (sblock->sizeof_size != sizeof_size) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected sizeof_size") /* compute expected image len */ - expected_image_len = H5F_SUPERBLOCK_FIXED_SIZE + - (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, sizeof_addr, sizeof_size); + expected_image_len = + H5F_SUPERBLOCK_FIXED_SIZE + (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, sizeof_addr, sizeof_size); - if ( expected_image_len != *len_ptr ) { + if (expected_image_len != *len_ptr) { *len_ptr = expected_image_len; HGOTO_DONE(SUCCEED) } - /* at this point, we know that the supplied image is of + /* at this point, we know that the supplied image is of * the correct length. */ /* validate the older version of the superblock */ - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { - unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */ - unsigned chunk_btree_k; /* B-tree chunk internal node 'K' value */ + unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */ + unsigned chunk_btree_k; /* B-tree chunk internal node 'K' value */ - /* Freespace version (hard-wired) */ - if(HDF5_FREESPACE_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad free space version number") + /* Freespace version (hard-wired) */ + if (HDF5_FREESPACE_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad free space version number") - /* Root group version number (hard-wired) */ - if(HDF5_OBJECTDIR_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad object directory version number") + /* Root group version number (hard-wired) */ + if (HDF5_OBJECTDIR_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad object directory version number") - /* Skip over reserved byte */ - image++; + /* Skip over reserved byte */ + image++; - /* Shared header version number (hard-wired) */ - if(HDF5_SHAREDHEADER_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad shared-header format version number") + /* Shared header version number (hard-wired) */ + if (HDF5_SHAREDHEADER_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad shared-header format version number") - /* Skip over size of file addresses (already decoded and checked) */ - image++; + /* Skip over size of file addresses (already decoded and checked) */ + image++; - /* Skip over size of file sizes (already decoded and checked) */ - image++; + /* Skip over size of file sizes (already decoded and checked) */ + image++; - /* Skip over reserved byte */ - image++; + /* Skip over reserved byte */ + image++; - /* Various B-tree sizes */ - UINT16DECODE(image, sym_leaf_k); - if ( sym_leaf_k != sblock->sym_leaf_k ) + /* Various B-tree sizes */ + UINT16DECODE(image, sym_leaf_k); + if (sym_leaf_k != sblock->sym_leaf_k) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected sym_leaf_k") /* Need 'get' call to set other array values */ UINT16DECODE(image, snode_btree_k); - if ( snode_btree_k != sblock->btree_k[H5B_SNODE_ID] ) + if (snode_btree_k != sblock->btree_k[H5B_SNODE_ID]) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected snode_btree_k") /* File status flags (not really used yet) @@ -1238,80 +1204,76 @@ H5F__cache_superblock_refresh(H5F_t *f, void * _thing, const void * _image, */ UINT32DECODE(image, status_flags); if (status_flags != sblock->status_flags && status_flags != 0 && - status_flags != - (H5F_SUPER_WRITE_ACCESS|H5F_SUPER_SWMR_WRITE_ACCESS)) { + status_flags != (H5F_SUPER_WRITE_ACCESS | H5F_SUPER_SWMR_WRITE_ACCESS)) { HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, - "status_flags %" PRIx32 " unexpectedly changed to %" PRIx32, - sblock->status_flags, status_flags) + "status_flags %" PRIx32 " unexpectedly changed to %" PRIx32, sblock->status_flags, + status_flags) } - /* + /* * If the superblock version # is greater than 0, read in the indexed * storage B-tree internal 'K' value */ - if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { - UINT16DECODE(image, chunk_btree_k); + if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + UINT16DECODE(image, chunk_btree_k); - if ( chunk_btree_k != sblock->btree_k[H5B_CHUNK_ID] ) + if (chunk_btree_k != sblock->btree_k[H5B_CHUNK_ID]) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected chunk_btree_k") - /* Reserved bytes are present only in version 1 */ - if(sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1) - image += 2; /* reserved */ - } /* end if */ + /* Reserved bytes are present only in version 1 */ + if (sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1) + image += 2; /* reserved */ + } /* end if */ - /* Remainder of "variable-sized" portion of superblock */ - H5F_addr_decode(f, (const uint8_t **)&image, &base_addr/*out*/); - H5F_addr_decode(f, (const uint8_t **)&image, &ext_addr/*out*/); - H5F_addr_decode(f, (const uint8_t **)&image, &stored_eof/*out*/); - H5F_addr_decode(f, (const uint8_t **)&image, &driver_addr/*out*/); + /* Remainder of "variable-sized" portion of superblock */ + H5F_addr_decode(f, (const uint8_t **)&image, &base_addr /*out*/); + H5F_addr_decode(f, (const uint8_t **)&image, &ext_addr /*out*/); + H5F_addr_decode(f, (const uint8_t **)&image, &stored_eof /*out*/); + H5F_addr_decode(f, (const uint8_t **)&image, &driver_addr /*out*/); - if ( base_addr != sblock->base_addr ) + if (base_addr != sblock->base_addr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected base_addr") - if ( ext_addr != sblock->ext_addr ) + if (ext_addr != sblock->ext_addr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected ext_addr") /* use stored_eof to update EOA below */ - if ( driver_addr != sblock->driver_addr ) + if (driver_addr != sblock->driver_addr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected driver_addr") - /* decode the root group symbol table entry */ - if(H5G_ent_decode(f, (const uint8_t **)&image, &root_ent) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode root group symbol table entry") + /* decode the root group symbol table entry */ + if (H5G_ent_decode(f, (const uint8_t **)&image, &root_ent) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode root group symbol table entry") - /* Set the root group address to the correct value */ - root_addr = root_ent.header; + /* Set the root group address to the correct value */ + root_addr = root_ent.header; - if ( root_addr != sblock->root_addr ) + if (root_addr != sblock->root_addr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected root_addr") HDassert(root_ent.type == H5G_CACHED_STAB); - if ( ( root_ent.type != sblock->root_ent->type ) || - ( root_ent.cache.stab.btree_addr != - sblock->root_ent->cache.stab.btree_addr ) || - ( root_ent.cache.stab.heap_addr != - sblock->root_ent->cache.stab.heap_addr ) ) + if ((root_ent.type != sblock->root_ent->type) || + (root_ent.cache.stab.btree_addr != sblock->root_ent->cache.stab.btree_addr) || + (root_ent.cache.stab.heap_addr != sblock->root_ent->cache.stab.heap_addr)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected root_ent data") - - /* NOTE: Driver info block is decoded separately, later */ + /* NOTE: Driver info block is decoded separately, later */ } /* end if */ else { - uint32_t read_chksum; - uint32_t computed_chksum; + uint32_t read_chksum; + uint32_t computed_chksum; /* Skip over size of file addresses (already decoded and checked) */ image++; - /* Skip over size of file sizes (already decoded and checked) */ - image++; + /* Skip over size of file sizes (already decoded and checked) */ + image++; /* File status flags (not really used yet) */ - status_flags = *image++; + status_flags = *image++; /* If the file has closed by the writer, then the status flags will * change to zero. If the file was opened by the writer, then the @@ -1320,41 +1282,39 @@ H5F__cache_superblock_refresh(H5F_t *f, void * _thing, const void * _image, * two transitions are allowed. */ if (status_flags != sblock->status_flags && status_flags != 0 && - status_flags != - (H5F_SUPER_WRITE_ACCESS|H5F_SUPER_SWMR_WRITE_ACCESS)) { + status_flags != (H5F_SUPER_WRITE_ACCESS | H5F_SUPER_SWMR_WRITE_ACCESS)) { HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, - "status_flags %" PRIx32 " unexpectedly changed to %" PRIx32, - sblock->status_flags, status_flags) + "status_flags %" PRIx32 " unexpectedly changed to %" PRIx32, sblock->status_flags, + status_flags) } - /* Base, superblock extension, end of file & root group object - * header addresses + /* Base, superblock extension, end of file & root group object + * header addresses */ - H5F_addr_decode(f, (const uint8_t **)&image, &base_addr/*out*/); - H5F_addr_decode(f, (const uint8_t **)&image, &ext_addr/*out*/); - H5F_addr_decode(f, (const uint8_t **)&image, &stored_eof/*out*/); - H5F_addr_decode(f, (const uint8_t **)&image, &root_addr/*out*/); + H5F_addr_decode(f, (const uint8_t **)&image, &base_addr /*out*/); + H5F_addr_decode(f, (const uint8_t **)&image, &ext_addr /*out*/); + H5F_addr_decode(f, (const uint8_t **)&image, &stored_eof /*out*/); + H5F_addr_decode(f, (const uint8_t **)&image, &root_addr /*out*/); - if ( base_addr != sblock->base_addr ) + if (base_addr != sblock->base_addr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected base_addr") - if ( ext_addr != sblock->ext_addr ) + if (ext_addr != sblock->ext_addr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected ext_addr") - if ( root_addr != sblock->root_addr ) + if (root_addr != sblock->root_addr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected root_addr") /* use stored_eof to update EOA below */ - /* Decode checksum */ - UINT32DECODE(image, read_chksum); + /* Decode checksum */ + UINT32DECODE(image, read_chksum); - if ( H5F_get_checksums((const uint8_t *)_image, - (size_t)(image - (const uint8_t *)_image), - NULL, &computed_chksum) < 0 ) + if (H5F_get_checksums((const uint8_t *)_image, (size_t)(image - (const uint8_t *)_image), NULL, + &computed_chksum) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't compute chksum") - if ( read_chksum != computed_chksum ) + if (read_chksum != computed_chksum) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unexpected checksum") } /* end else */ @@ -1363,7 +1323,7 @@ H5F__cache_superblock_refresh(H5F_t *f, void * _thing, const void * _image, HDassert((size_t)(image - (const uint8_t *)_image) <= *len_ptr); /* update the EOA */ - if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, stored_eof - base_addr) < 0) + if (H5F__set_eoa(f, H5FD_MEM_DEFAULT, stored_eof - base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update EOA") done: diff --git a/src/H5Ftest.c b/src/H5Ftest.c index f249d45..7ff3427 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -26,71 +26,63 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ -#define H5F_TESTING /* Suppress warning about H5F testing funcs */ -#define H5G_FRIEND /* Suppress error about including H5Gpkg.h */ -#define H5G_TESTING /* Suppress warning about H5G testing funcs */ -#define H5SM_FRIEND /* Suppress error about including H5SMpkg.h */ -#define H5SM_TESTING /* Suppress warning about H5SM testing funcs */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#define H5F_TESTING /* Suppress warning about H5F testing funcs */ +#define H5G_FRIEND /* Suppress error about including H5Gpkg.h */ +#define H5G_TESTING /* Suppress warning about H5G testing funcs */ +#define H5SM_FRIEND /* Suppress error about including H5SMpkg.h */ +#define H5SM_TESTING /* Suppress warning about H5SM testing funcs */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5FDprivate.h" /* File Drivers */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5SMpkg.h" /* Shared object header messages */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5FDprivate.h" /* File Drivers */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5SMpkg.h" /* Shared object header messages */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5F__vfd_swmr_decode_md_hdr(int md_fd, H5FD_vfd_swmr_md_header *md_hdr); -static herr_t H5F__vfd_swmr_decode_md_idx(int md_fd, H5FD_vfd_swmr_md_header *md_hdr, H5FD_vfd_swmr_md_index *md_idx); -static herr_t H5F__vfd_swmr_verify_md_hdr_and_idx(H5F_t *f, - H5FD_vfd_swmr_md_header *md_hdr, H5FD_vfd_swmr_md_index *md_idx, - unsigned num_entries, H5FD_vfd_swmr_idx_entry_t *index); - +static herr_t H5F__vfd_swmr_decode_md_idx(int md_fd, H5FD_vfd_swmr_md_header *md_hdr, + H5FD_vfd_swmr_md_index *md_idx); +static herr_t H5F__vfd_swmr_verify_md_hdr_and_idx(H5F_t *f, H5FD_vfd_swmr_md_header *md_hdr, + H5FD_vfd_swmr_md_index *md_idx, unsigned num_entries, + H5FD_vfd_swmr_idx_entry_t *index); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ /* Declare external the free list for H5FD_vfd_swmr_idx_entry_t */ H5FL_SEQ_EXTERN(H5FD_vfd_swmr_idx_entry_t); - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5F__get_sohm_mesg_count_test * @@ -106,33 +98,32 @@ H5FL_SEQ_EXTERN(H5FD_vfd_swmr_idx_entry_t); herr_t H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_count) { - H5F_t *file; /* File info */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * file; /* File info */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) + if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Push API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Retrieve count for message type */ - if(H5SM__get_mesg_count_test(file, type_id, mesg_count) < 0) + if (H5SM__get_mesg_count_test(file, type_id, mesg_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve shared message count") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_sohm_mesg_count_test() */ - /*------------------------------------------------------------------------- * Function: H5F__check_cached_stab_test * @@ -151,33 +142,32 @@ done: herr_t H5F__check_cached_stab_test(hid_t file_id) { - H5F_t *file; /* File info */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * file; /* File info */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) + if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Push API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Verify the cached stab info */ - if(H5G__verify_cached_stab_test(H5G_oloc(file->shared->root_grp), file->shared->sblock->root_ent) < 0) + if (H5G__verify_cached_stab_test(H5G_oloc(file->shared->root_grp), file->shared->sblock->root_ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to verify cached symbol table info") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__check_cached_stab_test() */ - /*------------------------------------------------------------------------- * Function: H5F__get_maxaddr_test * @@ -193,13 +183,13 @@ done: herr_t H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) + if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Retrieve maxaddr for file */ @@ -209,7 +199,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_maxaddr_test() */ - /*------------------------------------------------------------------------- * Function: H5F__get_sbe_addr_test * @@ -226,13 +215,13 @@ done: herr_t H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) + if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Retrieve maxaddr for file */ @@ -242,10 +231,10 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_sbe_addr_test() */ -/* - * VFD SWMR tests +/* + * VFD SWMR tests */ - + /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_writer_create_open_flush_test * @@ -270,73 +259,73 @@ done: herr_t H5F__vfd_swmr_writer_create_open_flush_test(hid_t file_id, hbool_t file_create) { - H5F_t *f; /* File pointer */ - h5_stat_t stat_buf; /* Buffer for stat info */ - H5FD_vfd_swmr_md_header md_hdr; /* Header for the metadata file */ - H5FD_vfd_swmr_md_index md_idx; /* Indedx for the metadata file */ - int md_fd = -1; /* The metadata file descriptor */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * f; /* File pointer */ + h5_stat_t stat_buf; /* Buffer for stat info */ + H5FD_vfd_swmr_md_header md_hdr; /* Header for the metadata file */ + H5FD_vfd_swmr_md_index md_idx; /* Indedx for the metadata file */ + int md_fd = -1; /* The metadata file descriptor */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (f = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) + if (NULL == (f = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Open the metadata file */ - if((md_fd = HDopen(f->shared->vfd_swmr_config.md_file_path, O_RDONLY)) < 0) + if ((md_fd = HDopen(f->shared->vfd_swmr_config.md_file_path, O_RDONLY)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "error opening metadata file") /* Verify the minimum size for the metadata file */ - if(HDstat(f->shared->vfd_swmr_config.md_file_path, &stat_buf) < 0) + if (HDstat(f->shared->vfd_swmr_config.md_file_path, &stat_buf) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to stat the metadata file") - if(stat_buf.st_size < (HDoff_t)((hsize_t)f->shared->vfd_swmr_config.md_pages_reserved * f->shared->fs_page_size)) + if (stat_buf.st_size < + (HDoff_t)((hsize_t)f->shared->vfd_swmr_config.md_pages_reserved * f->shared->fs_page_size)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect metadata file size") - if(file_create) { /* Creating file */ + if (file_create) { /* Creating file */ uint32_t hdr_magic; /* Seek to the beginning of the file */ - if(HDlseek(md_fd, (HDoff_t)H5FD_MD_HEADER_OFF, SEEK_SET) < 0) + if (HDlseek(md_fd, (HDoff_t)H5FD_MD_HEADER_OFF, SEEK_SET) < 0) HGOTO_ERROR(H5E_FILE, H5E_SEEKERROR, FAIL, "error seeking metadata file") /* Try to read the magic for header */ - if(HDread(md_fd, &hdr_magic, H5_SIZEOF_MAGIC) < 0) + if (HDread(md_fd, &hdr_magic, H5_SIZEOF_MAGIC) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "error reading metadata file") /* Verify that there is no header magic in the metadata file */ - if(HDmemcmp(&hdr_magic, H5FD_MD_HEADER_MAGIC, (size_t)H5_SIZEOF_MAGIC) == 0) + if (HDmemcmp(&hdr_magic, H5FD_MD_HEADER_MAGIC, (size_t)H5_SIZEOF_MAGIC) == 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "error finding header magic in the metadata file") + } + else { /* Opening or flushing the file */ - } else { /* Opening or flushing the file */ - HDmemset(&md_hdr, 0, sizeof(H5FD_vfd_swmr_md_header)); HDmemset(&md_idx, 0, sizeof(H5FD_vfd_swmr_md_index)); /* Decode the header */ - if(H5F__vfd_swmr_decode_md_hdr(md_fd, &md_hdr) < 0) + if (H5F__vfd_swmr_decode_md_hdr(md_fd, &md_hdr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "error decoding header in the metadata file") /* Decode the index */ - if(H5F__vfd_swmr_decode_md_idx(md_fd, &md_hdr, &md_idx) < 0) + if (H5F__vfd_swmr_decode_md_idx(md_fd, &md_hdr, &md_idx) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "error decoding index in the metadata file") /* Verify info in header and index read from the metadata file */ - if(H5F__vfd_swmr_verify_md_hdr_and_idx(f, &md_hdr, &md_idx, 0, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect info found in header and index of the metadata file") + if (H5F__vfd_swmr_verify_md_hdr_and_idx(f, &md_hdr, &md_idx, 0, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect info found in header and index of the metadata file") } done: /* Free the index entries */ - if(!file_create && md_idx.entries) { + if (!file_create && md_idx.entries) { HDassert(md_idx.num_entries); H5MM_free(md_idx.entries); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__vfd_swmr_writer_create_open_flush_test() */ - - /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_decode_md_hdr * @@ -350,24 +339,24 @@ static herr_t H5F__vfd_swmr_decode_md_hdr(int md_fd, H5FD_vfd_swmr_md_header *md_hdr) { uint64_t index_length; - uint8_t image[H5FD_MD_HEADER_SIZE]; /* Buffer for the header image */ - uint8_t *p = NULL; /* Points to the image */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t image[H5FD_MD_HEADER_SIZE]; /* Buffer for the header image */ + uint8_t *p = NULL; /* Points to the image */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE p = image; /* Seek to the beginning of the file */ - if(HDlseek(md_fd, (HDoff_t)H5FD_MD_HEADER_OFF, SEEK_SET) < 0) + if (HDlseek(md_fd, (HDoff_t)H5FD_MD_HEADER_OFF, SEEK_SET) < 0) HGOTO_ERROR(H5E_FILE, H5E_SEEKERROR, FAIL, "error seeking metadata file") /* Read the header */ - if(HDread(md_fd, image, H5FD_MD_HEADER_SIZE) < 0) + if (HDread(md_fd, image, H5FD_MD_HEADER_SIZE) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "error reading metadata file") /* Verify magic for header */ - if(HDmemcmp(p, H5FD_MD_HEADER_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) + if (HDmemcmp(p, H5FD_MD_HEADER_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "does not find header magic in the metadata file") p += H5_SIZEOF_MAGIC; @@ -385,7 +374,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__vfd_swmr_decode_md_hdr() */ - /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_decode_md_idx * @@ -398,29 +386,29 @@ done: static herr_t H5F__vfd_swmr_decode_md_idx(int md_fd, H5FD_vfd_swmr_md_header *md_hdr, H5FD_vfd_swmr_md_index *md_idx) { - uint8_t *image = NULL; /* Points to the buffer for the index image */ - uint8_t *p = NULL; /* Points to the image */ - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *image = NULL; /* Points to the buffer for the index image */ + uint8_t *p = NULL; /* Points to the image */ + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Allocate buffer for the index image */ - if(NULL == (image = H5MM_malloc(md_hdr->index_length))) + if (NULL == (image = H5MM_malloc(md_hdr->index_length))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "memory allocation failed for index on disk buffer") p = image; /* Seek to the position of the index */ - if(HDlseek(md_fd, (HDoff_t)md_hdr->index_offset, SEEK_SET) < 0) + if (HDlseek(md_fd, (HDoff_t)md_hdr->index_offset, SEEK_SET) < 0) HGOTO_ERROR(H5E_FILE, H5E_SEEKERROR, FAIL, "unable to seek in metadata file") /* Read the index */ - if(HDread(md_fd, image, md_hdr->index_length) < (int64_t)md_hdr->index_length) + if (HDread(md_fd, image, md_hdr->index_length) < (int64_t)md_hdr->index_length) HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "error in reading the header in metadata file") /* Verify magic for index */ - if(HDmemcmp(p, H5FD_MD_INDEX_MAGIC, H5_SIZEOF_MAGIC) != 0) + if (HDmemcmp(p, H5FD_MD_INDEX_MAGIC, H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "no header magic in the metadata file") p += H5_SIZEOF_MAGIC; @@ -430,30 +418,29 @@ H5F__vfd_swmr_decode_md_idx(int md_fd, H5FD_vfd_swmr_md_header *md_hdr, H5FD_vfd UINT32DECODE(p, md_idx->num_entries); /* Deserialize index entries */ - if(md_idx->num_entries) { - md_idx->entries = - H5MM_calloc(md_idx->num_entries * sizeof(md_idx->entries[0])); + if (md_idx->num_entries) { + md_idx->entries = H5MM_calloc(md_idx->num_entries * sizeof(md_idx->entries[0])); /* Allocate memory for the index entries */ - if(NULL == md_idx->entries) + if (NULL == md_idx->entries) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "memory allocation failed for index entries") - /* Decode index entries */ - for(i = 0; i < md_idx->num_entries; i++) { + /* Decode index entries */ + for (i = 0; i < md_idx->num_entries; i++) { UINT32DECODE(p, md_idx->entries[i].hdf5_page_offset); UINT32DECODE(p, md_idx->entries[i].md_file_page_offset); UINT32DECODE(p, md_idx->entries[i].length); UINT32DECODE(p, md_idx->entries[i].chksum); - } /* end for */ + } /* end for */ - } /* end if */ + } /* end if */ done: /* Free the buffer */ - if(image) + if (image) H5MM_free(image); - if(ret_value < 0) { + if (ret_value < 0) { /* Free the index entries */ - if(md_idx->entries) { + if (md_idx->entries) { HDassert(md_idx->num_entries); H5MM_free(md_idx->entries); } @@ -462,15 +449,13 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__vfd_swmr_decode_md_idx() */ - - /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_verify_md_hdr_idx_test * * Purpose: Verify the header and index in the metadata file: * --fs_page_size in md header is the same as that stored in "f" * --index_length in md header is as indicated by num_entries - * --index_offset in md header is right after the header + * --index_offset in md header is right after the header * --number of entries in md index is num_entries * --entries in md index is as indicated by num_entries and index * @@ -479,49 +464,51 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5F__vfd_swmr_verify_md_hdr_and_idx(H5F_t *f, - H5FD_vfd_swmr_md_header *md_hdr, H5FD_vfd_swmr_md_index *md_idx, - unsigned num_entries, H5FD_vfd_swmr_idx_entry_t *index) +H5F__vfd_swmr_verify_md_hdr_and_idx(H5F_t *f, H5FD_vfd_swmr_md_header *md_hdr, H5FD_vfd_swmr_md_index *md_idx, + unsigned num_entries, H5FD_vfd_swmr_idx_entry_t *index) { - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Verify fs_page_size read from header in the metadata file is fs_page_size in f */ - if(md_hdr->fs_page_size != f->shared->fs_page_size) + if (md_hdr->fs_page_size != f->shared->fs_page_size) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect fs_page_size read from metadata file") /* Verify index_length read from header in the metadata file is the size of num_entries index */ - if(md_hdr->index_length != H5FD_MD_INDEX_SIZE(num_entries)) + if (md_hdr->index_length != H5FD_MD_INDEX_SIZE(num_entries)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect index_length read from metadata file") /* Verify index_offset read from header in the metadata file is the size of md header */ - if(md_hdr->index_offset != f->shared->fs_page_size) + if (md_hdr->index_offset != f->shared->fs_page_size) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect index_offset read from metadata file") /* Verify num_entries read from index in the metadata file is num_entries */ - if(md_idx->num_entries != num_entries) + if (md_idx->num_entries != num_entries) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect num_entries read from metadata file") /* Verify empty/non-empty index entries */ - if(num_entries == 0) { + if (num_entries == 0) { /* Verify the index is empty */ - if(md_idx->entries != NULL) + if (md_idx->entries != NULL) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect entries in index") - } else { + } + else { /* Verify entries */ - for(i = 0; i < num_entries; i++) { - if(md_idx->entries[i].length != index[i].length) + for (i = 0; i < num_entries; i++) { + if (md_idx->entries[i].length != index[i].length) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect length read from metadata file") - if(md_idx->entries[i].hdf5_page_offset != index[i].hdf5_page_offset) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect hdf5_page_offset read from metadata file") + if (md_idx->entries[i].hdf5_page_offset != index[i].hdf5_page_offset) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect hdf5_page_offset read from metadata file") - if(md_idx->entries[i].md_file_page_offset != index[i].md_file_page_offset) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect md_file_page_offset read from metadata file") + if (md_idx->entries[i].md_file_page_offset != index[i].md_file_page_offset) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect md_file_page_offset read from metadata file") - if(md_idx->entries[i].chksum != index[i].chksum) + if (md_idx->entries[i].chksum != index[i].chksum) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect chksum read from metadata file") } } @@ -534,15 +521,14 @@ static unsigned count_shadow_defrees(shadow_defree_queue_t *shadow_defrees) { shadow_defree_t *shadow_defree; - unsigned count = 0; + unsigned count = 0; TAILQ_FOREACH(shadow_defree, shadow_defrees, link) - count++; + count++; return count; } - /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_writer_md_test * @@ -550,7 +536,7 @@ count_shadow_defrees(shadow_defree_queue_t *shadow_defrees) * the following: * --info read from the metadata file is as indicated by * the input: num_entries, index - * --# of entries on the delayed list is as indicated by + * --# of entries on the delayed list is as indicated by * the input: nshadow_defrees * * Return: SUCCEED/FAIL @@ -558,14 +544,14 @@ count_shadow_defrees(shadow_defree_queue_t *shadow_defrees) *------------------------------------------------------------------------- */ herr_t -H5F__vfd_swmr_writer_md_test(hid_t file_id, unsigned num_entries, - H5FD_vfd_swmr_idx_entry_t *index, unsigned nshadow_defrees) +H5F__vfd_swmr_writer_md_test(hid_t file_id, unsigned num_entries, H5FD_vfd_swmr_idx_entry_t *index, + unsigned nshadow_defrees) { - H5F_t *f; /* File pointer */ - int md_fd = -1; /* The metadata file descriptor */ - H5FD_vfd_swmr_md_header md_hdr; /* Header for the metadata file */ - H5FD_vfd_swmr_md_index md_idx; /* Index for the metadata file */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * f; /* File pointer */ + int md_fd = -1; /* The metadata file descriptor */ + H5FD_vfd_swmr_md_header md_hdr; /* Header for the metadata file */ + H5FD_vfd_swmr_md_index md_idx; /* Index for the metadata file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -573,43 +559,43 @@ H5F__vfd_swmr_writer_md_test(hid_t file_id, unsigned num_entries, HDmemset(&md_idx, 0, sizeof(H5FD_vfd_swmr_md_index)); /* Check arguments */ - if(NULL == (f = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) + if (NULL == (f = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Update the metadata file with the input index */ - if(H5F_update_vfd_swmr_metadata_file(f, num_entries, index) < 0) + if (H5F_update_vfd_swmr_metadata_file(f, num_entries, index) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "error updating the md file with the index") /* Verify the number of entries in the delayed list is as expected */ - if(count_shadow_defrees(&f->shared->shadow_defrees) == nshadow_defrees) + if (count_shadow_defrees(&f->shared->shadow_defrees) == nshadow_defrees) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect # of entries in the delayed list") /* Open the metadata file */ - if((md_fd = HDopen(f->shared->vfd_swmr_config.md_file_path, O_RDONLY)) < 0) + if ((md_fd = HDopen(f->shared->vfd_swmr_config.md_file_path, O_RDONLY)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "error opening metadata file") /* Decode the header in the metadata file */ - if(H5F__vfd_swmr_decode_md_hdr(md_fd, &md_hdr) < 0) + if (H5F__vfd_swmr_decode_md_hdr(md_fd, &md_hdr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "error decoding header in the metadata file") /* Decode the index in the metadata file */ - if(H5F__vfd_swmr_decode_md_idx(md_fd, &md_hdr, &md_idx) < 0) + if (H5F__vfd_swmr_decode_md_idx(md_fd, &md_hdr, &md_idx) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "error decoding index in the metadata file") /* Verify info read from the metadata file is the same as the input index */ - if(H5F__vfd_swmr_verify_md_hdr_and_idx(f, &md_hdr, &md_idx, num_entries, index) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect info found in header and index of the metadata file") + if (H5F__vfd_swmr_verify_md_hdr_and_idx(f, &md_hdr, &md_idx, num_entries, index) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect info found in header and index of the metadata file") done: /* Free the index entries */ - if(md_idx.entries) { + if (md_idx.entries) { HDassert(md_idx.num_entries); H5MM_free(md_idx.entries); } FUNC_LEAVE_NOAPI(ret_value) } /* H5F__vfd_swmr_writer_md_test() */ - /*------------------------------------------------------------------------- * Function: H5F__same_file_test * @@ -625,15 +611,15 @@ done: htri_t H5F__same_file_test(hid_t file_id1, hid_t file_id2) { - H5F_t *file1, *file2; /* File info */ - htri_t ret_value = FAIL; /* Return value */ + H5F_t *file1, *file2; /* File info */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file1 = (H5F_t *)H5VL_object_verify(file_id1, H5I_FILE))) + if (NULL == (file1 = (H5F_t *)H5VL_object_verify(file_id1, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - if(NULL == (file2 = (H5F_t *)H5VL_object_verify(file_id2, H5I_FILE))) + if (NULL == (file2 = (H5F_t *)H5VL_object_verify(file_id2, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* If they are using the same underlying "shared" file struct, they are the same file */ @@ -642,4 +628,3 @@ H5F__same_file_test(hid_t file_id1, hid_t file_id2) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__same_file_test() */ - diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index b55f157..7369ac1 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -25,46 +25,44 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MVprivate.h" /* File memory management for VFD SWMR */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MVprivate.h" /* File memory management for VFD SWMR */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ -#define nanosecs_per_second 1000000000 /* nanoseconds per second */ -#define nanosecs_per_tenth_sec 100000000 /* nanoseconds per 0.1 second */ +#define nanosecs_per_second 1000000000 /* nanoseconds per second */ +#define nanosecs_per_tenth_sec 100000000 /* nanoseconds per 0.1 second */ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *, - hbool_t); +static herr_t H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *, hbool_t); static herr_t H5F__vfd_swmr_construct_write_md_hdr(H5F_shared_t *, uint32_t); static herr_t H5F__vfd_swmr_construct_write_md_idx(H5F_shared_t *, uint32_t, - struct H5FD_vfd_swmr_idx_entry_t[]); + struct H5FD_vfd_swmr_idx_entry_t[]); static herr_t H5F__idx_entry_cmp(const void *_entry1, const void *_entry2); static herr_t H5F__vfd_swmr_create_index(H5F_shared_t *); static herr_t H5F__vfd_swmr_writer__wait_a_tick(H5F_t *); @@ -73,17 +71,17 @@ static herr_t H5F__vfd_swmr_writer__wait_a_tick(H5F_t *); /* Package Variables */ /*********************/ -/* - * Globals for VFD SWMR +/* + * Globals for VFD SWMR */ -unsigned int vfd_swmr_api_entries_g = 0;/* Times the library was entered - * and re-entered minus the times - * it was exited. We only perform - * the end-of-tick processing - * on the 0->1 and 1->0 - * transitions. - */ +unsigned int vfd_swmr_api_entries_g = 0; /* Times the library was entered + * and re-entered minus the times + * it was exited. We only perform + * the end-of-tick processing + * on the 0->1 and 1->0 + * transitions. + */ /* * The head of the end of tick queue (EOT queue) for files opened in either * VFD SWMR write or VFD SWMR read mode @@ -100,12 +98,11 @@ H5FL_DEFINE(shadow_defree_t); /* Declare a free list to manage the eot_queue_entry_t struct */ H5FL_DEFINE(eot_queue_entry_t); - /*------------------------------------------------------------------------- * * Function: H5F_vfd_swmr_init * - * Purpose: Initialize globals and the corresponding fields in + * Purpose: Initialize globals and the corresponding fields in * file pointer. * * For both VFD SWMR writer and reader: @@ -116,12 +113,12 @@ H5FL_DEFINE(eot_queue_entry_t); * * --set f->shared->tick_num to 1 * --create the metadata file - * --when opening an existing HDF5 file, write header and + * --when opening an existing HDF5 file, write header and * empty index in the metadata file * * For VFD SWMR reader: * - * --set f->shared->tick_num to the current tick read from the + * --set f->shared->tick_num to the current tick read from the * metadata file * * Return: Success: SUCCEED @@ -136,10 +133,10 @@ H5FL_DEFINE(eot_queue_entry_t); herr_t H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) { - hsize_t md_size; /* Size of the metadata file */ - haddr_t hdr_addr, idx_addr; /* Addresses returned from H5MV_alloc() */ - herr_t ret_value = SUCCEED; /* Return value */ - H5F_shared_t *shared = f->shared; + hsize_t md_size; /* Size of the metadata file */ + haddr_t hdr_addr, idx_addr; /* Addresses returned from H5MV_alloc() */ + herr_t ret_value = SUCCEED; /* Return value */ + H5F_shared_t *shared = f->shared; FUNC_ENTER_NOAPI(FAIL) @@ -147,42 +144,36 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) shared->vfd_swmr = TRUE; - if(H5F_SHARED_INTENT(shared) & H5F_ACC_RDWR) { + if (H5F_SHARED_INTENT(shared) & H5F_ACC_RDWR) { HDassert(shared->vfd_swmr_config.writer); SIMPLEQ_INIT(&shared->lower_defrees); shared->vfd_swmr_writer = TRUE; - shared->tick_num = 1; + shared->tick_num = 1; - if ( H5PB_vfd_swmr__set_tick(shared) < 0 ) - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \ - "Can't update page buffer current tick") + if (H5PB_vfd_swmr__set_tick(shared) < 0) + HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "Can't update page buffer current tick") /* Create the metadata file */ - if ( ((shared->vfd_swmr_md_fd = - HDopen(shared->vfd_swmr_config.md_file_path, O_CREAT|O_RDWR, - H5_POSIX_CREATE_MODE_RW))) < 0 ) + if (((shared->vfd_swmr_md_fd = HDopen(shared->vfd_swmr_config.md_file_path, O_CREAT | O_RDWR, + H5_POSIX_CREATE_MODE_RW))) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, \ - "unable to create the metadata file") + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create the metadata file") - md_size = (hsize_t)shared->vfd_swmr_config.md_pages_reserved * - shared->fs_page_size; + md_size = (hsize_t)shared->vfd_swmr_config.md_pages_reserved * shared->fs_page_size; HDassert(shared->fs_page_size >= H5FD_MD_HEADER_SIZE); /* Allocate an entire page from the shadow file for the header. */ - if ((hdr_addr = H5MV_alloc(f, shared->fs_page_size)) == HADDR_UNDEF){ - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, - "error allocating shadow-file header"); + if ((hdr_addr = H5MV_alloc(f, shared->fs_page_size)) == HADDR_UNDEF) { + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error allocating shadow-file header"); } HDassert(H5F_addr_eq(hdr_addr, H5FD_MD_HEADER_OFF)); idx_addr = H5MV_alloc(f, md_size - shared->fs_page_size); if (idx_addr == HADDR_UNDEF) { - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, - "error allocating shadow-file index"); + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error allocating shadow-file index"); } HDassert(H5F_addr_eq(idx_addr, shared->fs_page_size)); @@ -190,28 +181,25 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) shared->writer_index_offset = idx_addr; /* Set the metadata file size to md_pages_reserved */ - if ( -1 == HDftruncate(shared->vfd_swmr_md_fd, (HDoff_t)md_size) ) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, - "truncate fail for the metadata file"); + if (-1 == HDftruncate(shared->vfd_swmr_md_fd, (HDoff_t)md_size)) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "truncate fail for the metadata file"); /* Set eof for metadata file to md_pages_reserved */ shared->vfd_swmr_md_eoa = (haddr_t)md_size; - /* When opening an existing HDF5 file, create header and empty - * index in the metadata file + /* When opening an existing HDF5 file, create header and empty + * index in the metadata file */ if (!file_create) { if (H5F__vfd_swmr_construct_write_md_idx(shared, 0, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, - "fail to create index in md"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create index in md"); if (H5F__vfd_swmr_construct_write_md_hdr(shared, 0) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, - "fail to create header in md"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create header in md"); } - - } else { /* VFD SWMR reader */ + } + else { /* VFD SWMR reader */ HDassert(!shared->vfd_swmr_config.writer); @@ -221,22 +209,18 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) /* allocate an index to save the initial index */ if (H5F__vfd_swmr_create_index(shared) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, - "unable to allocate metadata file index"); + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate metadata file index"); /* Set tick_num to the current tick read from the metadata file */ shared->mdf_idx_entries_used = shared->mdf_idx_len; - if (H5FD_vfd_swmr_get_tick_and_idx(shared->lf, FALSE, - &shared->tick_num, - &(shared->mdf_idx_entries_used), - shared->mdf_idx) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, - "unable to load/decode metadata file"); + if (H5FD_vfd_swmr_get_tick_and_idx(shared->lf, FALSE, &shared->tick_num, + &(shared->mdf_idx_entries_used), shared->mdf_idx) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, "unable to load/decode metadata file"); HDassert(shared->tick_num != 0); vfd_swmr_reader_did_increase_tick_to(shared->tick_num); -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "##### initialized index: tick/used/len = %lld/%d/%d #####\n", shared->tick_num, shared->mdf_idx_entries_used, @@ -246,8 +230,7 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) /* Update end_of_tick */ if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, FALSE) < 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, - "unable to update end of tick"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick"); } done: @@ -256,12 +239,11 @@ done: } /* H5F_vfd_swmr_init() */ - /*------------------------------------------------------------------------- * * Function: H5F_vfd_swmr_close_or_flush * - * Purpose: Used by the VFD SWMR writer when the HDF5 file is closed + * Purpose: Used by the VFD SWMR writer when the HDF5 file is closed * or flushed: * * 1) For file close: @@ -273,7 +255,7 @@ done: * * 2) For file flush: * --write header and an empty index to the metadata file - * --increment tick_num + * --increment tick_num * --start a new tick (??check with JM for sure) * ??update end_of_tick * @@ -289,9 +271,9 @@ done: herr_t H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing) { - H5F_shared_t *shared = f->shared; + H5F_shared_t * shared = f->shared; shadow_defree_t *curr; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -306,38 +288,36 @@ H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing) if (H5F__vfd_swmr_construct_write_md_hdr(shared, 0) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create header in md"); - if ( closing ) { /* For file close */ + if (closing) { /* For file close */ ++shared->tick_num; /* Close the md file */ - if(HDclose(shared->vfd_swmr_md_fd) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, - "unable to close the metadata file"); + if (HDclose(shared->vfd_swmr_md_fd) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close the metadata file"); shared->vfd_swmr_md_fd = -1; /* Unlink the md file */ - if ( HDunlink(shared->vfd_swmr_config.md_file_path) < 0 ) - HGOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, - "unable to unlink the metadata file"); + if (HDunlink(shared->vfd_swmr_config.md_file_path) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, "unable to unlink the metadata file"); /* Close the free-space manager for the metadata file */ - if ( H5MV_close(f) < 0 ) + if (H5MV_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, - "unable to close the free-space manager for the metadata file"); + "unable to close the free-space manager for the metadata file"); - /* Free the delayed list */ + /* Free the delayed list */ while ((curr = TAILQ_FIRST(&shared->shadow_defrees)) != NULL) { TAILQ_REMOVE(&shared->shadow_defrees, curr, link); H5FL_FREE(shadow_defree_t, curr); } HDassert(TAILQ_EMPTY(&shared->shadow_defrees)); - } else { /* For file flush */ + } + else { /* For file flush */ /* Update end_of_tick */ if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, TRUE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, - "unable to update end of tick"); + HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick"); } done: FUNC_LEAVE_NOAPI(ret_value) @@ -351,8 +331,8 @@ shadow_range_defer_free(H5F_shared_t *shared, uint64_t offset, uint32_t length) if (NULL == (shadow_defree = H5FL_CALLOC(shadow_defree_t))) return -1; - shadow_defree->offset = offset; - shadow_defree->length = length; + shadow_defree->offset = offset; + shadow_defree->length = length; shadow_defree->tick_num = shared->tick_num; TAILQ_INSERT_HEAD(&shared->shadow_defrees, shadow_defree, link); @@ -360,14 +340,11 @@ shadow_range_defer_free(H5F_shared_t *shared, uint64_t offset, uint32_t length) } int -shadow_image_defer_free(H5F_shared_t *shared, - const H5FD_vfd_swmr_idx_entry_t *entry) +shadow_image_defer_free(H5F_shared_t *shared, const H5FD_vfd_swmr_idx_entry_t *entry) { - return shadow_range_defer_free(shared, - entry->md_file_page_offset * shared->fs_page_size, entry->length); + return shadow_range_defer_free(shared, entry->md_file_page_offset * shared->fs_page_size, entry->length); } - /*------------------------------------------------------------------------- * * Function: H5F_update_vfd_swmr_metadata_file() @@ -384,13 +361,13 @@ shadow_image_defer_free(H5F_shared_t *shared, * --Write the entry to the metadata file * --Set entry_ptr to NULL * - * --Construct on disk image of the index and write index to the + * --Construct on disk image of the index and write index to the * metadata file * - * --Construct on disk image of the header and write header to + * --Construct on disk image of the header and write header to * the metadata file * - * --Release time out entries from the delayed list to the + * --Release time out entries from the delayed list to the * free-space manager * * Return: SUCCEED/FAIL @@ -403,16 +380,15 @@ shadow_image_defer_free(H5F_shared_t *shared, *------------------------------------------------------------------------- */ herr_t -H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, - H5FD_vfd_swmr_idx_entry_t *index) +H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, H5FD_vfd_swmr_idx_entry_t *index) { - H5F_shared_t *shared = f->shared; + H5F_shared_t * shared = f->shared; shadow_defree_t *prev; shadow_defree_t *shadow_defree; - haddr_t md_addr; /* Address in the metadata file */ - uint32_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - hbool_t queue_was_nonempty; + haddr_t md_addr; /* Address in the metadata file */ + uint32_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + hbool_t queue_was_nonempty; FUNC_ENTER_NOAPI(FAIL) @@ -426,12 +402,12 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, /* For each non-null entry_ptr in the index: * - * --Insert previous image of the entry (if exists) to the + * --Insert previous image of the entry (if exists) to the * beginning of the delayed list * - * --Allocate space for the entry in the metadata file + * --Allocate space for the entry in the metadata file * - * --Compute checksum, update the index entry, write entry to + * --Compute checksum, update the index entry, write entry to * the metadata file * * --Set entry_ptr to NULL @@ -442,26 +418,23 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, continue; /* Prepend previous image of the entry to the delayed list */ - if ( index[i].md_file_page_offset ) { + if (index[i].md_file_page_offset) { if (shadow_image_defer_free(shared, &index[i]) == -1) { - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, \ - "unable to allocate the delayed entry") + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate the delayed entry") } } /* Allocate space for the entry in the metadata file */ - if((md_addr = H5MV_alloc(f, index[i].length)) == HADDR_UNDEF) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, \ - "error in allocating space from the metadata file") + if ((md_addr = H5MV_alloc(f, index[i].length)) == HADDR_UNDEF) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in allocating space from the metadata file") HDassert(md_addr % shared->fs_page_size == 0); /* Compute checksum and update the index entry */ index[i].md_file_page_offset = md_addr / shared->fs_page_size; - index[i].chksum = H5_checksum_metadata(index[i].entry_ptr, - index[i].length, 0); + index[i].chksum = H5_checksum_metadata(index[i].entry_ptr, index[i].length, 0); -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "writing index[%d] fo/mdfo/l/chksum/fc/lc = %lld/%lld/%ld/%lx/%lx/%lx\n", i, @@ -478,17 +451,14 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, #endif /* JRM */ /* Seek and write the entry to the metadata file */ - if ( HDlseek(shared->vfd_swmr_md_fd, (HDoff_t)md_addr, - SEEK_SET) < 0) + if (HDlseek(shared->vfd_swmr_md_fd, (HDoff_t)md_addr, SEEK_SET) < 0) - HGOTO_ERROR(H5E_FILE, H5E_SEEKERROR, FAIL, \ - "unable to seek in the metadata file") + HGOTO_ERROR(H5E_FILE, H5E_SEEKERROR, FAIL, "unable to seek in the metadata file") - if ( HDwrite(shared->vfd_swmr_md_fd, index[i].entry_ptr, - index[i].length) != (ssize_t)index[i].length ) + if (HDwrite(shared->vfd_swmr_md_fd, index[i].entry_ptr, index[i].length) != (ssize_t)index[i].length) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, \ - "error in writing the page/multi-page entry to metadata file") + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing the page/multi-page entry to metadata file") index[i].entry_ptr = NULL; } @@ -496,23 +466,21 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, /* Construct and write index to the metadata file */ if (H5F__vfd_swmr_construct_write_md_idx(shared, num_entries, index) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, \ - "fail to construct & write index to md") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to construct & write index to md") /* Construct and write header to the md file */ if (H5F__vfd_swmr_construct_write_md_hdr(shared, num_entries) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, \ - "fail to construct & write header to md") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to construct & write header to md") queue_was_nonempty = !TAILQ_EMPTY(&shared->shadow_defrees); - /* - * Release time out entries from the delayed list by scanning the + /* + * Release time out entries from the delayed list by scanning the * list from the bottom up: * - * --release to the metadata file free space manager all index - * entries that have resided on the list for more than + * --release to the metadata file free space manager all index + * entries that have resided on the list for more than * max_lag ticks * * --remove the associated entries from the list @@ -521,17 +489,15 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, if (shared->tick_num <= shared->vfd_swmr_config.max_lag) goto done; // It is too early for any reclamations to be due. - TAILQ_FOREACH_REVERSE_SAFE(shadow_defree, &shared->shadow_defrees, - shadow_defree_queue, link, prev) { + TAILQ_FOREACH_REVERSE_SAFE(shadow_defree, &shared->shadow_defrees, shadow_defree_queue, link, prev) + { - if (shadow_defree->tick_num + shared->vfd_swmr_config.max_lag > - shared->tick_num) { - break; // No more entries are due for reclamation. + if (shadow_defree->tick_num + shared->vfd_swmr_config.max_lag > shared->tick_num) { + break; // No more entries are due for reclamation. } if (H5MV_free(f, shadow_defree->offset, shadow_defree->length) < 0) { - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, - "unable to flush clean entry"); + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry"); } TAILQ_REMOVE(&shared->shadow_defrees, shadow_defree, link); @@ -544,33 +510,32 @@ done: } /* end H5F_update_vfd_swmr_metadata_file() */ - /*------------------------------------------------------------------------- * * Function: H5F_vfd_swmr_writer__delay_write * * Purpose: Given the base address of a page of metadata, or of a multi- - * page metadata entry, determine whether the write must be + * page metadata entry, determine whether the write must be * delayed. * - * At the conceptual level, the VFD SWMR writer must delay the - * write of any metadata page or multi-page metadata that - * overwrites an existing metadata page or multi-page metadata - * entry until it has appeared in the metadata file index for - * at least max_lag ticks. Since the VFD SWMR reader goes - * to the HDF5 file for any piece of metadata not listed in - * the metadata file index, failure to delay such writes can + * At the conceptual level, the VFD SWMR writer must delay the + * write of any metadata page or multi-page metadata that + * overwrites an existing metadata page or multi-page metadata + * entry until it has appeared in the metadata file index for + * at least max_lag ticks. Since the VFD SWMR reader goes + * to the HDF5 file for any piece of metadata not listed in + * the metadata file index, failure to delay such writes can * result in message from the future bugs. * * The easy case is pages or multi-page metadata entries - * have just been allocated. Obviously, these can be written - * immediately. This case is tracked and tested by the page + * have just been allocated. Obviously, these can be written + * immediately. This case is tracked and tested by the page * buffer proper. * - * This routine looks up the supplied page in the metadata file + * This routine looks up the supplied page in the metadata file * index. * - * If the entry doesn't exist, the function sets + * If the entry doesn't exist, the function sets * *untilp to the current tick plus max_lag. * * If the entry exists, the function sets *untilp @@ -586,13 +551,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_vfd_swmr_writer__delay_write(H5F_shared_t *shared, uint64_t page, - uint64_t *untilp) +H5F_vfd_swmr_writer__delay_write(H5F_shared_t *shared, uint64_t page, uint64_t *untilp) { - uint64_t until; + uint64_t until; H5FD_vfd_swmr_idx_entry_t *ie_ptr; H5FD_vfd_swmr_idx_entry_t *idx; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -610,9 +574,9 @@ H5F_vfd_swmr_writer__delay_write(H5F_shared_t *shared, uint64_t page, if (idx == NULL) { ie_ptr = NULL; - } else { - ie_ptr = vfd_swmr_pageno_to_mdf_idx_entry(idx, - shared->mdf_idx_entries_used, page, FALSE); + } + else { + ie_ptr = vfd_swmr_pageno_to_mdf_idx_entry(idx, shared->mdf_idx_entries_used, page, FALSE); } if (ie_ptr == NULL) @@ -623,10 +587,8 @@ H5F_vfd_swmr_writer__delay_write(H5F_shared_t *shared, uint64_t page, until = 0; if (until != 0 && - (until < shared->tick_num || - shared->tick_num + shared->vfd_swmr_config.max_lag < until)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "VFD SWMR write delay out of range") + (until < shared->tick_num || shared->tick_num + shared->vfd_swmr_config.max_lag < until)) + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "VFD SWMR write delay out of range") *untilp = until; @@ -636,20 +598,19 @@ done: } /* H5F_vfd_swmr_writer__delay_write() */ - /*------------------------------------------------------------------------- * * Function: H5F_vfd_swmr_writer__prep_for_flush_or_close * - * Purpose: In the context of the VFD SWMR writer, two issues must be - * addressed before the page buffer can be flushed -- as is + * Purpose: In the context of the VFD SWMR writer, two issues must be + * addressed before the page buffer can be flushed -- as is * necessary on both HDF5 file flush or close: * * 1) We must force an end of tick so as to clean the tick list * in the page buffer. - * - * 2) If the page buffer delayed write list is not empty, we - * must repeatedly wait a tick and then run the writer end + * + * 2) If the page buffer delayed write list is not empty, we + * must repeatedly wait a tick and then run the writer end * of tick function until the delayed write list drains. * * This function manages these details. @@ -665,8 +626,8 @@ done: herr_t H5F_vfd_swmr_writer__prep_for_flush_or_close(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ - H5F_shared_t *shared = f->shared; + herr_t ret_value = SUCCEED; /* Return value */ + H5F_shared_t *shared = f->shared; FUNC_ENTER_NOAPI(FAIL) @@ -675,17 +636,16 @@ H5F_vfd_swmr_writer__prep_for_flush_or_close(H5F_t *f) HDassert(shared->pb_ptr); /* since we are about to flush the page buffer, force and end of - * tick so as to avoid attempts to flush entries on the page buffer + * tick so as to avoid attempts to flush entries on the page buffer * tick list that were modified during the current tick. */ - if ( H5F_vfd_swmr_writer_end_of_tick(f, TRUE) < 0 ) + if (H5F_vfd_swmr_writer_end_of_tick(f, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \ - "H5F_vfd_swmr_writer_end_of_tick() failed.") + HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "H5F_vfd_swmr_writer_end_of_tick() failed.") - while(shared->pb_ptr->dwl_len > 0) { + while (shared->pb_ptr->dwl_len > 0) { - if(H5F__vfd_swmr_writer__wait_a_tick(f) < 0) + if (H5F__vfd_swmr_writer__wait_a_tick(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "wait a tick failed.") } @@ -697,12 +657,11 @@ done: } /* H5F_vfd_swmr_writer__prep_for_flush_or_close() */ static int -clean_shadow_index(H5F_t *f, uint32_t nentries, - H5FD_vfd_swmr_idx_entry_t *idx, uint32_t *ndeletedp) +clean_shadow_index(H5F_t *f, uint32_t nentries, H5FD_vfd_swmr_idx_entry_t *idx, uint32_t *ndeletedp) { - H5F_shared_t *shared = f->shared; - uint32_t i, j, ndeleted, max_lag = shared->vfd_swmr_config.max_lag; - uint64_t tick_num = shared->tick_num; + H5F_shared_t * shared = f->shared; + uint32_t i, j, ndeleted, max_lag = shared->vfd_swmr_config.max_lag; + uint64_t tick_num = shared->tick_num; H5FD_vfd_swmr_idx_entry_t *ie; for (i = j = ndeleted = 0; i < nentries; i++) { @@ -729,47 +688,46 @@ clean_shadow_index(H5F_t *f, uint32_t nentries, return 0; } - /*------------------------------------------------------------------------- * * Function: H5F_vfd_swmr_writer_end_of_tick * - * Purpose: Main routine for managing the end of tick for the VFD - * SWMR writer. + * Purpose: Main routine for managing the end of tick for the VFD + * SWMR writer. * - * This function performs all end of tick operations for the + * This function performs all end of tick operations for the * writer -- specifically: - * + * * 1) If requested, flush all raw data to the HDF5 file. * * (Not for first cut.) * * 2) Flush the metadata cache to the page buffer. * - * Note that we must run a tick after the destruction + * Note that we must run a tick after the destruction * of the metadata cache, since this operation will usually - * dirty the first page in the HDF5 file. However, the + * dirty the first page in the HDF5 file. However, the * metadata cache will no longer exist at this point. * - * Thus, we must check for the existance of the metadata + * Thus, we must check for the existance of the metadata * cache, and only attempt to flush it if it exists. * * 3) If this is the first tick (i.e. tick == 1), create the * in memory version of the metadata file index. * - * 4) Scan the page buffer tick list, and use it to update - * the metadata file index, adding or modifying entries as + * 4) Scan the page buffer tick list, and use it to update + * the metadata file index, adding or modifying entries as * appropriate. * - * 5) Scan the metadata file index for entries that can be - * removed -- specifically entries that have been written + * 5) Scan the metadata file index for entries that can be + * removed -- specifically entries that have been written * to the HDF5 file more than max_lag ticks ago, and haven't - * been modified since. + * been modified since. * * (This is an optimization -- address it later) * - * 6) Update the metadata file. Must do this before we - * release the tick list, as otherwise the page buffer + * 6) Update the metadata file. Must do this before we + * release the tick list, as otherwise the page buffer * entry images may not be available. * * 7) Release the page buffer tick list. @@ -791,14 +749,14 @@ clean_shadow_index(H5F_t *f, uint32_t nentries, herr_t H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) { - H5F_shared_t *shared = f->shared; - uint32_t idx_entries_added = 0; - uint32_t idx_entries_modified = 0; - uint32_t idx_entries_removed = 0; - uint32_t idx_ent_not_in_tl = 0; - uint32_t idx_ent_not_in_tl_flushed = 0; - herr_t ret_value = SUCCEED; /* Return value */ - hbool_t incr_tick = FALSE; + H5F_shared_t *shared = f->shared; + uint32_t idx_entries_added = 0; + uint32_t idx_entries_modified = 0; + uint32_t idx_entries_removed = 0; + uint32_t idx_ent_not_in_tl = 0; + uint32_t idx_ent_not_in_tl_flushed = 0; + herr_t ret_value = SUCCEED; /* Return value */ + hbool_t incr_tick = FALSE; FUNC_ENTER_NOAPI(FAIL) @@ -806,8 +764,7 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) HDassert(shared->pb_ptr); HDassert(shared->vfd_swmr_writer); - if (!vfd_swmr_writer_may_increase_tick_to(shared->tick_num + 1, - wait_for_reader)) + if (!vfd_swmr_writer_may_increase_tick_to(shared->tick_num + 1, wait_for_reader)) goto update_eot; incr_tick = TRUE; @@ -819,92 +776,75 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) HDassert(!shared->vfd_swmr_config.flush_raw_data); #if 1 - /* Test to see if b-tree corruption seen in VFD SWMR tests - * is caused by client hiding data from the metadata cache. Do - * this by calling H5D_flush_all(), which flushes any cached - * dataset storage. Eventually, we will do this regardless + /* Test to see if b-tree corruption seen in VFD SWMR tests + * is caused by client hiding data from the metadata cache. Do + * this by calling H5D_flush_all(), which flushes any cached + * dataset storage. Eventually, we will do this regardless * when the above flush_raw_data flag is set. */ - if ( H5D_flush_all(f) < 0 ) + if (H5D_flush_all(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "unable to flush dataset cache") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") - - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") + if (shared->cache) { - if ( shared->cache ) { - - if ( H5AC_flush(f) < 0 ) + if (H5AC_flush(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't flush metadata cache to the page buffer") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush metadata cache to the page buffer") } - - - if ( H5FD_truncate(shared->lf, FALSE) < 0 ) + if (H5FD_truncate(shared->lf, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") #endif /* 2) If it exists, flush the metadata cache to the page buffer. */ - if ( shared->cache ) { + if (shared->cache) { - if ( H5AC_flush(f) < 0 ) + if (H5AC_flush(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't flush metadata cache to the page buffer") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush metadata cache to the page buffer") } - /* 3) If this is the first tick (i.e. tick == 1), create the * in memory version of the metadata file index. */ - if ( ( shared->tick_num == 1 ) && - ( H5F__vfd_swmr_create_index(shared) < 0 ) ) - - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, \ - "unable to allocate metadata file index") + if ((shared->tick_num == 1) && (H5F__vfd_swmr_create_index(shared) < 0)) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate metadata file index") - /* 4) Scan the page buffer tick list, and use it to update - * the metadata file index, adding or modifying entries as + /* 4) Scan the page buffer tick list, and use it to update + * the metadata file index, adding or modifying entries as * appropriate. */ - if ( H5PB_vfd_swmr__update_index(f, &idx_entries_added, - &idx_entries_modified, - &idx_ent_not_in_tl, - &idx_ent_not_in_tl_flushed) < 0 ) + if (H5PB_vfd_swmr__update_index(f, &idx_entries_added, &idx_entries_modified, &idx_ent_not_in_tl, + &idx_ent_not_in_tl_flushed) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't update MD file index") - - /* 5) Scan the metadata file index for entries that can be - * removed -- specifically entries that have been written + /* 5) Scan the metadata file index for entries that can be + * removed -- specifically entries that have been written * to the HDF5 file more than max_lag ticks ago, and haven't - * been modified since. + * been modified since. */ - if (clean_shadow_index(f, - shared->mdf_idx_entries_used + idx_entries_added, - shared->mdf_idx, &idx_entries_removed) < 0) + if (clean_shadow_index(f, shared->mdf_idx_entries_used + idx_entries_added, shared->mdf_idx, + &idx_entries_removed) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't clean shadow file index") - /* 6) Update the metadata file. Must do this before we - * release the tick list, as otherwise the page buffer + /* 6) Update the metadata file. Must do this before we + * release the tick list, as otherwise the page buffer * entry images may not be available. * - * Note that this operation will restore the index to + * Note that this operation will restore the index to * sorted order. */ - if (H5F_update_vfd_swmr_metadata_file(f, - shared->mdf_idx_entries_used + idx_entries_added - - idx_entries_removed, - shared->mdf_idx) < 0) + if (H5F_update_vfd_swmr_metadata_file( + f, shared->mdf_idx_entries_used + idx_entries_added - idx_entries_removed, shared->mdf_idx) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't update MD file") /* at this point the metadata file index should be sorted -- update @@ -915,21 +855,19 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) HDassert(shared->mdf_idx_entries_used <= shared->mdf_idx_len); -#if 0 /* JRM */ +#if 0 /* JRM */ H5F__vfd_swmr_writer__dump_index(f); #endif /* JRM */ /* 7) Release the page buffer tick list. */ - if ( H5PB_vfd_swmr__release_tick_list(shared) < 0 ) + if (H5PB_vfd_swmr__release_tick_list(shared) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't release tick list") - /* 8) Release any delayed writes whose delay has expired */ - if ( H5PB_vfd_swmr__release_delayed_writes(shared) < 0 ) + if (H5PB_vfd_swmr__release_delayed_writes(shared) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't release delayed writes") - update_eot: @@ -938,22 +876,20 @@ update_eot: /* Update end_of_tick */ if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, incr_tick) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, \ - "unable to update end of tick") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick") /* Remove the entry from the EOT queue */ - if(H5F_vfd_swmr_remove_entry_eot(f) < 0) + if (H5F_vfd_swmr_remove_entry_eot(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") - /* Re-insert the entry that corresponds to f onto the EOT queue */ - if(H5F_vfd_swmr_insert_entry_eot(f) < 0) + /* Re-insert the entry that corresponds to f onto the EOT queue */ + if (H5F_vfd_swmr_insert_entry_eot(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue") done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * * Function: H5F_vfd_swmr_writer__dump_index @@ -971,11 +907,11 @@ done: herr_t H5F_vfd_swmr_writer__dump_index(H5F_shared_t *shared) { - unsigned int i; - uint32_t mdf_idx_len; - uint32_t mdf_idx_entries_used; - H5FD_vfd_swmr_idx_entry_t * index = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned int i; + uint32_t mdf_idx_len; + uint32_t mdf_idx_entries_used; + H5FD_vfd_swmr_idx_entry_t *index = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -983,21 +919,18 @@ H5F_vfd_swmr_writer__dump_index(H5F_shared_t *shared) HDassert(shared->vfd_swmr); HDassert(shared->mdf_idx); - index = shared->mdf_idx; mdf_idx_len = shared->mdf_idx_len; mdf_idx_entries_used = shared->mdf_idx_entries_used; HDfprintf(stderr, "\n\nDumping Index:\n\n"); - HDfprintf(stderr, - "index len / entries used = %" PRIu32 " / %" PRIu32 "\n\n", - mdf_idx_len, mdf_idx_entries_used); + HDfprintf(stderr, "index len / entries used = %" PRIu32 " / %" PRIu32 "\n\n", mdf_idx_len, + mdf_idx_entries_used); - for ( i = 0; i < mdf_idx_entries_used; i++ ) { + for (i = 0; i < mdf_idx_entries_used; i++) { - HDfprintf(stderr, "%u: %" PRIu64 " %" PRIu64 " %" PRIu32 "\n", - i, index[i].hdf5_page_offset, index[i].md_file_page_offset, - index[i].length); + HDfprintf(stderr, "%u: %" PRIu64 " %" PRIu64 " %" PRIu32 "\n", i, index[i].hdf5_page_offset, + index[i].md_file_page_offset, index[i].length); } done: @@ -1006,7 +939,6 @@ done: } /* end H5F_vfd_swmr_writer__dump_index() */ - /*------------------------------------------------------------------------- * Function: H5F_vfd_swmr_reader_end_of_tick * @@ -1016,24 +948,24 @@ done: * 1) Direct the VFD SWMR reader VFD to load the current header * from the metadata file, and report the current tick. * - * If the tick reported has not increased since the last + * If the tick reported has not increased since the last * call, do nothing and exit. * * 2) If the tick has increased, obtain a copy of the new * index from the VFD SWMR reader VFD, and compare it with * the old index to identify all pages that have been updated - * in the previous tick. + * in the previous tick. * * If any such pages or multi-page metadata entries are found: * * a) direct the page buffer to evict any such superceeded - * pages, and + * pages, and * * b) direct the metadata cache to either evict or refresh * any entries residing in the superceeded pages. * * Note that this operation MUST be performed in this order, - * as the metadata cache will refer to the page buffer + * as the metadata cache will refer to the page buffer * when refreshing entries. * * 9) Increment the tick, and update the end of tick. @@ -1049,22 +981,22 @@ done: herr_t H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) { - uint64_t tmp_tick_num = 0; - H5FD_vfd_swmr_idx_entry_t * tmp_mdf_idx; - uint32_t entries_added = 0; - uint32_t entries_removed = 0; - uint32_t entries_moved = 0; - uint32_t tmp_mdf_idx_len; - uint32_t tmp_mdf_idx_entries_used; - uint32_t mdf_idx_entries_used; - H5F_shared_t *shared = f->shared; + uint64_t tmp_tick_num = 0; + H5FD_vfd_swmr_idx_entry_t *tmp_mdf_idx; + uint32_t entries_added = 0; + uint32_t entries_removed = 0; + uint32_t entries_moved = 0; + uint32_t tmp_mdf_idx_len; + uint32_t tmp_mdf_idx_entries_used; + uint32_t mdf_idx_entries_used; + H5F_shared_t * shared = f->shared; struct { uint64_t pgno; uint32_t length; - } *change = NULL; - herr_t ret_value = SUCCEED; + } *change = NULL; + herr_t ret_value = SUCCEED; uint32_t i, j, nchanges; - H5FD_t *file = shared->lf; + H5FD_t * file = shared->lf; FUNC_ENTER_NOAPI(FAIL) @@ -1079,28 +1011,24 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) * If the tick reported has not increased since the last * call, do nothing and exit. */ - if ( H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, &tmp_tick_num, - NULL, NULL) < 0 ) + if (H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, &tmp_tick_num, NULL, NULL) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, \ - "error in retrieving tick_num from driver") + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver") /* This is ok if we're entering the API, but it should * not happen if we're exiting the API. */ - HDassert(entering_api || tmp_tick_num < - shared->tick_num + shared->vfd_swmr_config.max_lag); + HDassert(entering_api || tmp_tick_num < shared->tick_num + shared->vfd_swmr_config.max_lag); if (!entering_api) { - H5FD_vfd_swmr_record_elapsed_ticks(shared->lf, - tmp_tick_num - shared->tick_num); + H5FD_vfd_swmr_record_elapsed_ticks(shared->lf, tmp_tick_num - shared->tick_num); } - if ( tmp_tick_num != shared->tick_num ) { + if (tmp_tick_num != shared->tick_num) { const H5FD_vfd_swmr_idx_entry_t *new_mdf_idx; const H5FD_vfd_swmr_idx_entry_t *old_mdf_idx; - uint32_t new_mdf_idx_entries_used; - uint32_t old_mdf_idx_entries_used; + uint32_t new_mdf_idx_entries_used; + uint32_t old_mdf_idx_entries_used; /* swap the old and new metadata file indexes */ @@ -1117,69 +1045,57 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) shared->mdf_idx_entries_used = tmp_mdf_idx_entries_used; /* if shared->mdf_idx is NULL, allocate an index */ - if (shared->mdf_idx == NULL && - H5F__vfd_swmr_create_index(shared) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, - "unable to allocate metadata file index"); + if (shared->mdf_idx == NULL && H5F__vfd_swmr_create_index(shared) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate metadata file index"); mdf_idx_entries_used = shared->mdf_idx_len; -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "--- reader EOT mdf_idx_entries_used = %d ---\n", mdf_idx_entries_used); #endif /* JRM */ - if (H5FD_vfd_swmr_get_tick_and_idx(file, FALSE, NULL, - &mdf_idx_entries_used, - shared->mdf_idx) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, - "error in retrieving tick_num from driver"); + if (H5FD_vfd_swmr_get_tick_and_idx(file, FALSE, NULL, &mdf_idx_entries_used, shared->mdf_idx) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver"); HDassert(mdf_idx_entries_used <= shared->mdf_idx_len); shared->mdf_idx_entries_used = mdf_idx_entries_used; -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "--- reader EOT index used / len = %" PRIu32 "/%" PRIu32 " ---\n", shared->mdf_idx_entries_used, shared->mdf_idx_len); #endif /* JRM */ - new_mdf_idx = shared->mdf_idx; - old_mdf_idx = shared->old_mdf_idx; + new_mdf_idx = shared->mdf_idx; + old_mdf_idx = shared->old_mdf_idx; new_mdf_idx_entries_used = shared->mdf_idx_entries_used; old_mdf_idx_entries_used = shared->old_mdf_idx_entries_used; - change = malloc(sizeof(change[0]) * - (old_mdf_idx_entries_used + new_mdf_idx_entries_used)); + change = malloc(sizeof(change[0]) * (old_mdf_idx_entries_used + new_mdf_idx_entries_used)); if (change == NULL) { - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, - "unable to allocate removed pages list"); + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate removed pages list"); } - /* If an old metadata file index exists, compare it with the + /* If an old metadata file index exists, compare it with the * new index and evict any modified, new, or deleted pages * and any associated metadata cache entries. * * Note that we must evict in two passes---page buffer first, - * and then metadata cache. This is necessary as the metadata + * and then metadata cache. This is necessary as the metadata * cache may attempt to refresh entries rather than evict them, - * in which case it may access an entry in the page buffer. + * in which case it may access an entry in the page buffer. */ - for (i = j = nchanges = 0; - i < old_mdf_idx_entries_used && - j < new_mdf_idx_entries_used; ) { - const H5FD_vfd_swmr_idx_entry_t *oent = &old_mdf_idx[i], - *nent = &new_mdf_idx[j]; + for (i = j = nchanges = 0; i < old_mdf_idx_entries_used && j < new_mdf_idx_entries_used;) { + const H5FD_vfd_swmr_idx_entry_t *oent = &old_mdf_idx[i], *nent = &new_mdf_idx[j]; /* Verify that the old and new indices are sorted as expected. */ - HDassert(i == 0 || - oent[-1].hdf5_page_offset < oent[0].hdf5_page_offset); + HDassert(i == 0 || oent[-1].hdf5_page_offset < oent[0].hdf5_page_offset); - HDassert(j == 0 || - nent[-1].hdf5_page_offset < nent[0].hdf5_page_offset); + HDassert(j == 0 || nent[-1].hdf5_page_offset < nent[0].hdf5_page_offset); if (oent->hdf5_page_offset == nent->hdf5_page_offset) { @@ -1192,39 +1108,39 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) */ HDassert(oent->length == nent->length); - /* the page has been altered -- evict it and + /* the page has been altered -- evict it and * any contained metadata cache entries. */ - change[nchanges].pgno = oent->hdf5_page_offset; + change[nchanges].pgno = oent->hdf5_page_offset; change[nchanges].length = oent->length; nchanges++; entries_moved++; } i++; j++; - - } else if (oent->hdf5_page_offset < nent->hdf5_page_offset) { - /* the page has been removed from the new version - * of the index. Evict it and any contained metadata - * cache entries. - * - * If we are careful about removing entries from the - * the index so as to ensure that they haven't changed - * for several ticks, we can probably omit this. However, - * lets not worry about this for the first cut. - */ - change[nchanges].pgno = oent->hdf5_page_offset; + } + else if (oent->hdf5_page_offset < nent->hdf5_page_offset) { + /* the page has been removed from the new version + * of the index. Evict it and any contained metadata + * cache entries. + * + * If we are careful about removing entries from the + * the index so as to ensure that they haven't changed + * for several ticks, we can probably omit this. However, + * lets not worry about this for the first cut. + */ + change[nchanges].pgno = oent->hdf5_page_offset; change[nchanges].length = oent->length; nchanges++; entries_removed++; i++; - - } else { /* oent->hdf5_page_offset > - * nent->hdf5_page_offset - */ + } + else { /* oent->hdf5_page_offset > + * nent->hdf5_page_offset + */ /* The page has been added to the index. */ - change[nchanges].pgno = nent->hdf5_page_offset; + change[nchanges].pgno = nent->hdf5_page_offset; change[nchanges].length = nent->length; nchanges++; entries_added++; @@ -1234,8 +1150,8 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) for (; j < new_mdf_idx_entries_used; j++) { const H5FD_vfd_swmr_idx_entry_t *nent = &new_mdf_idx[j]; - change[nchanges].pgno = nent->hdf5_page_offset; - change[nchanges].length = nent->length; + change[nchanges].pgno = nent->hdf5_page_offset; + change[nchanges].length = nent->length; nchanges++; entries_added++; } @@ -1244,39 +1160,35 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) for (; i < old_mdf_idx_entries_used; i++) { const H5FD_vfd_swmr_idx_entry_t *oent = &old_mdf_idx[i]; - /* the page has been removed from the new version of the - * index. Evict it from the page buffer and also evict any + /* the page has been removed from the new version of the + * index. Evict it from the page buffer and also evict any * contained metadata cache entries */ - change[nchanges].pgno = oent->hdf5_page_offset; + change[nchanges].pgno = oent->hdf5_page_offset; change[nchanges].length = oent->length; nchanges++; entries_removed++; } for (i = 0; i < nchanges; i++) { - haddr_t page_addr = - (haddr_t)(change[i].pgno * shared->pb_ptr->page_size); + haddr_t page_addr = (haddr_t)(change[i].pgno * shared->pb_ptr->page_size); if (H5PB_remove_entry(shared, page_addr) < 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, - "remove page buffer entry failed"); + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "remove page buffer entry failed"); } } for (i = 0; i < nchanges; i++) { - if (H5C_evict_or_refresh_all_entries_in_page(f, - change[i].pgno, change[i].length, - tmp_tick_num) < 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, - "evict or refresh stale MDC entries failed"); + if (H5C_evict_or_refresh_all_entries_in_page(f, change[i].pgno, change[i].length, tmp_tick_num) < + 0) { + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "evict or refresh stale MDC entries failed"); } } -#if 0 /* JRM */ +#if 0 /* JRM */ HDfprintf(stderr, "--- reader EOT pre new tick index " "used/len = %" PRIu32 "/ %" PRIu32 " ---\n", shared->mdf_idx_entries_used, shared->mdf_idx_len); #endif /* JRM */ - /* At this point, we should have evicted or refreshed all stale - * page buffer and metadata cache entries. + /* At this point, we should have evicted or refreshed all stale + * page buffer and metadata cache entries. * * Start the next tick. */ @@ -1285,23 +1197,19 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) vfd_swmr_reader_did_increase_tick_to(tmp_tick_num); /* Update end_of_tick */ - if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, - FALSE) < 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, - "unable to update end of tick"); + if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, FALSE) < 0) { + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick"); } } /* Remove the entry from the EOT queue */ - if(H5F_vfd_swmr_remove_entry_eot(f) < 0) { - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, - "unable to remove entry from EOT queue") + if (H5F_vfd_swmr_remove_entry_eot(f) < 0) { + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") } - /* Re-insert the entry that corresponds to f onto the EOT queue */ - if(H5F_vfd_swmr_insert_entry_eot(f) < 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, - "unable to insert entry into the EOT queue") + /* Re-insert the entry that corresponds to f onto the EOT queue */ + if (H5F_vfd_swmr_insert_entry_eot(f) < 0) { + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue") } done: @@ -1316,10 +1224,11 @@ done: static void insert_eot_entry(eot_queue_entry_t *entry_ptr) { - eot_queue_entry_t *prec_ptr; /* The predecessor entry on the EOT end of tick queue */ + eot_queue_entry_t *prec_ptr; /* The predecessor entry on the EOT end of tick queue */ /* Find the insertion point for the entry on the EOT queue */ - TAILQ_FOREACH_REVERSE(prec_ptr, &eot_queue_g, eot_queue, link) { + TAILQ_FOREACH_REVERSE(prec_ptr, &eot_queue_g, eot_queue, link) + { if (HDtimespeccmp(&prec_ptr->end_of_tick, &entry_ptr->end_of_tick, <=)) break; } @@ -1331,13 +1240,12 @@ insert_eot_entry(eot_queue_entry_t *entry_ptr) TAILQ_INSERT_HEAD(&eot_queue_g, entry_ptr, link); } - /* Update an entry on the EOT queue and move it to its proper place. */ void H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *entry) { - H5F_t *f = entry->vfd_swmr_file; + H5F_t * f = entry->vfd_swmr_file; H5F_shared_t *shared = f->shared; /* Free the entry on the EOT queue that corresponds to f */ @@ -1345,13 +1253,12 @@ H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *entry) TAILQ_REMOVE(&eot_queue_g, entry, link); HDassert(entry->vfd_swmr_writer == shared->vfd_swmr_writer); - entry->tick_num = shared->tick_num; + entry->tick_num = shared->tick_num; entry->end_of_tick = shared->end_of_tick; insert_eot_entry(entry); } - /*------------------------------------------------------------------------- * * Function: H5F__vfd_swmr_remove_entry_eot @@ -1373,8 +1280,9 @@ H5F_vfd_swmr_remove_entry_eot(H5F_t *f) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Free the entry on the EOT queue that corresponds to f */ - - TAILQ_FOREACH(curr, &eot_queue_g, link) { + + TAILQ_FOREACH(curr, &eot_queue_g, link) + { if (curr->vfd_swmr_file == f) break; } @@ -1387,7 +1295,6 @@ H5F_vfd_swmr_remove_entry_eot(H5F_t *f) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_vfd_swmr_remove_entry_eot() */ - /*------------------------------------------------------------------------- * * Function: H5F_vfd_swmr_insert_entry_eot @@ -1404,9 +1311,9 @@ H5F_vfd_swmr_remove_entry_eot(H5F_t *f) herr_t H5F_vfd_swmr_insert_entry_eot(H5F_t *f) { - H5F_shared_t *shared = f->shared; - eot_queue_entry_t *entry_ptr; /* An entry on the EOT end of tick queue */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_shared_t * shared = f->shared; + eot_queue_entry_t *entry_ptr; /* An entry on the EOT end of tick queue */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1416,9 +1323,9 @@ H5F_vfd_swmr_insert_entry_eot(H5F_t *f) /* Initialize the entry */ entry_ptr->vfd_swmr_writer = shared->vfd_swmr_writer; - entry_ptr->tick_num = shared->tick_num; - entry_ptr->end_of_tick = shared->end_of_tick; - entry_ptr->vfd_swmr_file = f; + entry_ptr->tick_num = shared->tick_num; + entry_ptr->end_of_tick = shared->end_of_tick; + entry_ptr->vfd_swmr_file = f; insert_eot_entry(entry_ptr); @@ -1427,7 +1334,6 @@ done: } /* H5F_vfd_swmr_insert_entry_eot() */ - /*------------------------------------------------------------------------- * * Function: H5F_dump_eot_queue() @@ -1444,23 +1350,18 @@ done: herr_t H5F_dump_eot_queue(void) { - int i; + int i; eot_queue_entry_t *curr; FUNC_ENTER_NOAPI_NOINIT_NOERR - for (curr = TAILQ_FIRST(&eot_queue_g), i = 0; - curr != NULL; - curr = TAILQ_NEXT(curr, link), i++) { - HDfprintf(stderr, "%d: %s tick_num %" PRIu64 - ", end_of_tick %jd.%09ld, vfd_swmr_file %p\n", - i, curr->vfd_swmr_writer ? "writer" : "not writer", - curr->tick_num, - curr->end_of_tick.tv_sec, curr->end_of_tick.tv_nsec, - curr->vfd_swmr_file); + for (curr = TAILQ_FIRST(&eot_queue_g), i = 0; curr != NULL; curr = TAILQ_NEXT(curr, link), i++) { + HDfprintf(stderr, "%d: %s tick_num %" PRIu64 ", end_of_tick %jd.%09ld, vfd_swmr_file %p\n", i, + curr->vfd_swmr_writer ? "writer" : "not writer", curr->tick_num, curr->end_of_tick.tv_sec, + curr->end_of_tick.tv_nsec, curr->vfd_swmr_file); } - if(i == 0) + if (i == 0) HDfprintf(stderr, "EOT head is null\n"); FUNC_LEAVE_NOAPI(SUCCEED) @@ -1471,7 +1372,6 @@ H5F_dump_eot_queue(void) * Beginning of static functions */ - /*------------------------------------------------------------------------- * * Function: H5F__vfd_swmr_update_end_of_tick_and_tick_num @@ -1489,26 +1389,25 @@ H5F_dump_eot_queue(void) *------------------------------------------------------------------------- */ static herr_t -H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *shared, - hbool_t incr_tick_num) +H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *shared, hbool_t incr_tick_num) { - struct timespec curr; /* Current time in struct timespec */ - struct timespec new_end_of_tick; /* new end_of_tick in struct timespec */ - int64_t curr_nsecs; /* current time in nanoseconds */ - int64_t tlen_nsecs; /* tick_len in nanoseconds */ - int64_t new_end_nsecs; /* new end_of_tick in nanoseconds */ - herr_t ret_value = SUCCEED; /* Return value */ + struct timespec curr; /* Current time in struct timespec */ + struct timespec new_end_of_tick; /* new end_of_tick in struct timespec */ + int64_t curr_nsecs; /* current time in nanoseconds */ + int64_t tlen_nsecs; /* tick_len in nanoseconds */ + int64_t new_end_nsecs; /* new end_of_tick in nanoseconds */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get current time in struct timespec */ #ifdef H5_HAVE_WIN32_API - if (timespec_get(&curr, TIME_UTC) != TIME_UTC) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via timespec_get"); + if (timespec_get(&curr, TIME_UTC) != TIME_UTC) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via timespec_get"); #else - if (HDclock_gettime(CLOCK_MONOTONIC, &curr) < 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via clock_gettime"); - } + if (HDclock_gettime(CLOCK_MONOTONIC, &curr) < 0) { + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via clock_gettime"); + } #endif /* Convert curr to nsecs */ @@ -1517,33 +1416,32 @@ H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *shared, /* Convert tick_len to nanosecs */ tlen_nsecs = shared->vfd_swmr_config.tick_len * nanosecs_per_tenth_sec; - /* - * Update shared->tick_num + /* + * Update shared->tick_num */ - if ( incr_tick_num ) { + if (incr_tick_num) { shared->tick_num++; - if ( H5PB_vfd_swmr__set_tick(shared) < 0 ) + if (H5PB_vfd_swmr__set_tick(shared) < 0) - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \ - "Can't update page buffer current tick") + HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "Can't update page buffer current tick") } - /* + /* * Update shared->end_of_tick */ /* Calculate new end_of_tick */ - /* TODO: The modulo operation is very expensive on most machines -- + /* TODO: The modulo operation is very expensive on most machines -- * re-work this code so as to avoid it. * * JRM -- 11/12/18 */ - new_end_nsecs = curr_nsecs + tlen_nsecs; + new_end_nsecs = curr_nsecs + tlen_nsecs; new_end_of_tick.tv_nsec = (long)(new_end_nsecs % nanosecs_per_second); - new_end_of_tick.tv_sec = new_end_nsecs / nanosecs_per_second; + new_end_of_tick.tv_sec = new_end_nsecs / nanosecs_per_second; shared->end_of_tick = new_end_of_tick; @@ -1553,7 +1451,6 @@ done: } /* H5F__vfd_swmr_update_end_of_tick_and_tick_num() */ - /*------------------------------------------------------------------------- * * Function: H5F__vfd_swmr_construct_write_md_hdr @@ -1579,13 +1476,13 @@ done: static herr_t H5F__vfd_swmr_construct_write_md_hdr(H5F_shared_t *shared, uint32_t num_entries) { - uint8_t image[H5FD_MD_HEADER_SIZE]; /* Buffer for header */ - uint8_t *p = NULL; /* Pointer to buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + uint8_t image[H5FD_MD_HEADER_SIZE]; /* Buffer for header */ + uint8_t *p = NULL; /* Pointer to buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Size of header and index */ const size_t hdr_size = H5FD_MD_HEADER_SIZE; - ssize_t nwritten; - herr_t ret_value = SUCCEED; /* Return value */ + ssize_t nwritten; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1614,16 +1511,14 @@ H5F__vfd_swmr_construct_write_md_hdr(H5F_shared_t *shared, uint32_t num_entries) HDassert(p - image == (ptrdiff_t)hdr_size); /* Set to beginning of the file */ - if ( HDlseek(shared->vfd_swmr_md_fd, H5FD_MD_HEADER_OFF, SEEK_SET) < 0 ) + if (HDlseek(shared->vfd_swmr_md_fd, H5FD_MD_HEADER_OFF, SEEK_SET) < 0) - HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, \ - "unable to seek in metadata file") + HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file") nwritten = HDwrite(shared->vfd_swmr_md_fd, image, hdr_size); /* Write header to the metadata file */ if (nwritten != (ssize_t)hdr_size) { - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, \ - "error in writing header to metadata file") + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing header to metadata file") } done: @@ -1632,7 +1527,6 @@ done: } /* H5F__vfd_swmr_construct_write_md_hdr() */ - /*------------------------------------------------------------------------- * Function: H5F__vfd_swmr_construct_write_md_idx @@ -1656,27 +1550,26 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5F__vfd_swmr_construct_write_md_idx(H5F_shared_t *shared, - uint32_t num_entries, struct H5FD_vfd_swmr_idx_entry_t index[]) +H5F__vfd_swmr_construct_write_md_idx(H5F_shared_t *shared, uint32_t num_entries, + struct H5FD_vfd_swmr_idx_entry_t index[]) { - uint8_t *image = NULL; /* Pointer to buffer */ - uint8_t *p = NULL; /* Pointer to buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + uint8_t *image = NULL; /* Pointer to buffer */ + uint8_t *p = NULL; /* Pointer to buffer */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Size of index */ const size_t idx_size = H5FD_MD_INDEX_SIZE(num_entries); - ssize_t nwritten; - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + ssize_t nwritten; + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(num_entries == 0 || index != NULL); /* Allocate space for the buffer to hold the index */ - if ( (image = HDmalloc(idx_size)) == NULL ) + if ((image = HDmalloc(idx_size)) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, \ - "memory allocation failed for md index") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for md index") /* * Encode metadata file index @@ -1694,11 +1587,11 @@ H5F__vfd_swmr_construct_write_md_idx(H5F_shared_t *shared, UINT32ENCODE(p, num_entries); /* Encode the index entries */ - for(i = 0; i < num_entries; i++) { - UINT32ENCODE(p, index[i].hdf5_page_offset); + for (i = 0; i < num_entries; i++) { + UINT32ENCODE(p, index[i].hdf5_page_offset); UINT32ENCODE(p, index[i].md_file_page_offset); - UINT32ENCODE(p, index[i].length); - UINT32ENCODE(p, index[i].chksum); + UINT32ENCODE(p, index[i].length); + UINT32ENCODE(p, index[i].chksum); } /* Calculate checksum for index */ @@ -1713,21 +1606,18 @@ H5F__vfd_swmr_construct_write_md_idx(H5F_shared_t *shared, /* Verify the md file descriptor exists */ HDassert(shared->vfd_swmr_md_fd >= 0); - if (HDlseek(shared->vfd_swmr_md_fd, - (HDoff_t)shared->writer_index_offset, SEEK_SET) < 0) - HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, \ - "unable to seek in metadata file") - + if (HDlseek(shared->vfd_swmr_md_fd, (HDoff_t)shared->writer_index_offset, SEEK_SET) < 0) + HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file") + nwritten = HDwrite(shared->vfd_swmr_md_fd, image, idx_size); /* Write index to the metadata file */ if (nwritten != (ssize_t)idx_size) { - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, \ - "error in writing index to metadata file") + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing index to metadata file") } done: - if ( image ) { + if (image) { HDfree(image); } @@ -1736,7 +1626,6 @@ done: } /* H5F__vfd_swmr_construct_write_idx() */ - /*------------------------------------------------------------------------- * Function: H5F__idx_entry_cmp() * @@ -1754,7 +1643,7 @@ H5F__idx_entry_cmp(const void *_entry1, const void *_entry2) const H5FD_vfd_swmr_idx_entry_t *entry1 = _entry1; const H5FD_vfd_swmr_idx_entry_t *entry2 = _entry2; - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1762,20 +1651,19 @@ H5F__idx_entry_cmp(const void *_entry1, const void *_entry2) HDassert(entry1); HDassert(entry2); - if(entry1->hdf5_page_offset < entry2->hdf5_page_offset) + if (entry1->hdf5_page_offset < entry2->hdf5_page_offset) ret_value = -1; - else if(entry1->hdf5_page_offset > entry2->hdf5_page_offset) + else if (entry1->hdf5_page_offset > entry2->hdf5_page_offset) ret_value = 1; FUNC_LEAVE_NOAPI(ret_value) } /* H5F__idx_entry_cmp() */ - /*------------------------------------------------------------------------- * * Function: H5F__vfd_swmr_create_index * - * Purpose: Allocate and initialize the index for the VFD SWMR metadata + * Purpose: Allocate and initialize the index for the VFD SWMR metadata * file. * * Return: SUCCEED/FAIL @@ -1789,10 +1677,10 @@ H5F__idx_entry_cmp(const void *_entry1, const void *_entry2) static herr_t H5F__vfd_swmr_create_index(H5F_shared_t *shared) { - size_t bytes_available; - size_t entries_in_index; - H5FD_vfd_swmr_idx_entry_t * index; - herr_t ret_value = SUCCEED; + size_t bytes_available; + size_t entries_in_index; + H5FD_vfd_swmr_idx_entry_t *index; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1801,22 +1689,18 @@ H5F__vfd_swmr_create_index(H5F_shared_t *shared) HDassert(shared->mdf_idx_len == 0); HDassert(shared->mdf_idx_entries_used == 0); - bytes_available = - (size_t)shared->fs_page_size * - (size_t)(shared->vfd_swmr_config.md_pages_reserved - 1); + bytes_available = (size_t)shared->fs_page_size * (size_t)(shared->vfd_swmr_config.md_pages_reserved - 1); HDassert(bytes_available > 0); - entries_in_index = - (bytes_available - H5FD_MD_INDEX_SIZE(0)) / H5FD_MD_INDEX_ENTRY_SIZE; + entries_in_index = (bytes_available - H5FD_MD_INDEX_SIZE(0)) / H5FD_MD_INDEX_ENTRY_SIZE; HDassert(entries_in_index > 0); index = H5MM_calloc(entries_in_index * sizeof(index[0])); if (index == NULL) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for md index") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for md index") } HDassert(entries_in_index <= UINT32_MAX); @@ -1831,16 +1715,16 @@ done: H5FD_vfd_swmr_idx_entry_t * vfd_swmr_enlarge_shadow_index(H5F_t *f) { - H5F_shared_t *shared = f->shared; + H5F_shared_t * shared = f->shared; H5FD_vfd_swmr_idx_entry_t *ret_value = NULL; - haddr_t idx_addr; - hsize_t idx_size; + haddr_t idx_addr; + hsize_t idx_size; H5FD_vfd_swmr_idx_entry_t *new_mdf_idx = NULL, *old_mdf_idx; - uint32_t new_mdf_idx_len, old_mdf_idx_len; + uint32_t new_mdf_idx_len, old_mdf_idx_len; FUNC_ENTER_NOAPI(NULL) - old_mdf_idx = shared->mdf_idx; + old_mdf_idx = shared->mdf_idx; old_mdf_idx_len = shared->mdf_idx_len; /* New length is double previous or UINT32_MAX, whichever is smaller. */ @@ -1854,28 +1738,26 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) idx_addr = H5MV_alloc(f, idx_size); if (idx_addr == HADDR_UNDEF) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "shadow-file allocation failed for index") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "shadow-file allocation failed for index") } new_mdf_idx = HDmalloc(new_mdf_idx_len * sizeof(new_mdf_idx[0])); if (new_mdf_idx == NULL) { (void)H5MV_free(f, idx_addr, idx_size); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed for md index") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for md index") } /* Copy the old index in its entirety to the new, instead of copying * just the _entries_used, because the caller may have been in the * process of adding entries, and some callers may not update * _entries_used immediately. - */ + */ H5MM_memcpy(new_mdf_idx, old_mdf_idx, sizeof(new_mdf_idx[0]) * old_mdf_idx_len); shared->writer_index_offset = idx_addr; ret_value = shared->mdf_idx = new_mdf_idx; - shared->mdf_idx_len = new_mdf_idx_len; + shared->mdf_idx_len = new_mdf_idx_len; /* Postpone reclamation of the old index until max_lag ticks from now. * It's only necessary to wait until after the new index is in place, @@ -1883,16 +1765,14 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) * past what is strictly necessary, but it seems like a reasonable * trade-off for simplicity. */ - if (shadow_range_defer_free(shared, shared->writer_index_offset, - H5FD_MD_INDEX_SIZE(old_mdf_idx_len)) == -1) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "could not schedule index reclamation"); + if (shadow_range_defer_free(shared, shared->writer_index_offset, H5FD_MD_INDEX_SIZE(old_mdf_idx_len)) == + -1) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "could not schedule index reclamation"); } done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * * Function: H5F__vfd_swmr_writer__wait_a_tick @@ -1916,12 +1796,12 @@ done: static herr_t H5F__vfd_swmr_writer__wait_a_tick(H5F_t *f) { - int result; + int result; struct timespec req; struct timespec rem; - uint64_t tick_in_nsec; - H5F_shared_t *shared; - herr_t ret_value = SUCCEED; /* Return value */ + uint64_t tick_in_nsec; + H5F_shared_t * shared; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1936,7 +1816,7 @@ H5F__vfd_swmr_writer__wait_a_tick(H5F_t *f) if (H5F_vfd_swmr_writer_end_of_tick(f, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "H5F_vfd_swmr_writer_end_of_tick() failed") - + done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__vfd_swmr_writer__wait_a_tick() */ @@ -1944,27 +1824,27 @@ done: herr_t H5F_vfd_swmr_process_eot_queue(hbool_t entering_api) { - struct timespec now; + struct timespec now; eot_queue_entry_t *first_head, *head; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) first_head = head = TAILQ_FIRST(&eot_queue_g); do { - H5F_t *f = head->vfd_swmr_file; + H5F_t * f = head->vfd_swmr_file; H5F_shared_t *shared = f->shared; #ifdef H5_HAVE_WIN32_API - if(timespec_get(&now, TIME_UTC) != TIME_UTC) + if (timespec_get(&now, TIME_UTC) != TIME_UTC) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via timespec_get"); #else - if(HDclock_gettime(CLOCK_MONOTONIC, &now) < 0) { + if (HDclock_gettime(CLOCK_MONOTONIC, &now) < 0) { HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via clock_gettime"); } #endif - if(HDtimespeccmp(&now, &head->end_of_tick, <)) + if (HDtimespeccmp(&now, &head->end_of_tick, <)) break; /* If the H5F_shared_t is labeled with a later EOT time than * the queue entry is, then we have already performed the @@ -1974,13 +1854,13 @@ H5F_vfd_swmr_process_eot_queue(hbool_t entering_api) */ if (HDtimespeccmp(&head->end_of_tick, &shared->end_of_tick, <)) { H5F_vfd_swmr_update_entry_eot(head); - } else if (shared->vfd_swmr_writer) { + } + else if (shared->vfd_swmr_writer) { if (H5F_vfd_swmr_writer_end_of_tick(f, FALSE) < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, - "end of tick error for VFD SWMR writer"); - } else if (H5F_vfd_swmr_reader_end_of_tick(f, entering_api) < 0) { - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, - "end of tick error for VFD SWMR reader"); + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR writer"); + } + else if (H5F_vfd_swmr_reader_end_of_tick(f, entering_api) < 0) { + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR reader"); } } while ((head = TAILQ_FIRST(&eot_queue_g)) != NULL && head != first_head); diff --git a/src/H5G.c b/src/H5G.c index bcc33bb..fae401c 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -75,36 +75,31 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -112,7 +107,6 @@ /* Group close callback */ static herr_t H5G__close_cb(H5VL_object_t *grp_vol_obj); - /*********************/ /* Package Variables */ /*********************/ @@ -120,29 +114,25 @@ static herr_t H5G__close_cb(H5VL_object_t *grp_vol_obj); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Group ID class */ static const H5I_class_t H5I_GROUP_CLS[1] = {{ - H5I_GROUP, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5G__close_cb /* Callback routine for closing objects of this class */ + H5I_GROUP, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5G__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ static hbool_t H5G_top_package_initialize_s = FALSE; - - /*------------------------------------------------------------------------- * Function: H5G_init * @@ -156,7 +146,7 @@ static hbool_t H5G_top_package_initialize_s = FALSE; herr_t H5G_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -165,7 +155,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_init() */ - /*------------------------------------------------------------------------- * Function: H5G__init_package * @@ -188,13 +177,13 @@ done: herr_t H5G__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the group IDs */ - if(H5I_register_type(H5I_GROUP_CLS) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface") + if (H5I_register_type(H5I_GROUP_CLS) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Mark "top" of interface as initialized, too */ H5G_top_package_initialize_s = TRUE; @@ -203,7 +192,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__init_package() */ - /*------------------------------------------------------------------------- * Function: H5G_top_term_package * @@ -221,25 +209,24 @@ done: int H5G_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5G_top_package_initialize_s) { - if(H5I_nmembers(H5I_GROUP) > 0) { + if (H5G_top_package_initialize_s) { + if (H5I_nmembers(H5I_GROUP) > 0) { (void)H5I_clear_type(H5I_GROUP, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark closed */ - if(0 == n) + if (0 == n) H5G_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5G_top_term_package() */ - /*------------------------------------------------------------------------- * Function: H5G_term_package * @@ -260,11 +247,11 @@ H5G_top_term_package(void) int H5G_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_GROUP)); HDassert(FALSE == H5G_top_package_initialize_s); @@ -273,14 +260,13 @@ H5G_term_package(void) n += (H5I_dec_type_ref(H5I_GROUP) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5G_term_package() */ - /*------------------------------------------------------------------------- * Function: H5G__close_cb * @@ -293,7 +279,7 @@ H5G_term_package(void) static herr_t H5G__close_cb(H5VL_object_t *grp_vol_obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -301,18 +287,17 @@ H5G__close_cb(H5VL_object_t *grp_vol_obj) HDassert(grp_vol_obj); /* Close the group */ - if(H5VL_group_close(grp_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_group_close(grp_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group") /* Free the VOL object */ - if(H5VL_free_object(grp_vol_obj) < 0) + if (H5VL_free_object(grp_vol_obj) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to free VOL object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__close_cb() */ - /*------------------------------------------------------------------------- * Function: H5Gcreate2 * @@ -337,69 +322,66 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, - hid_t gapl_id) +H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - void *grp = NULL; /* Structure for new group */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * grp = NULL; /* Structure for new group */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, lcpl_id, gcpl_id, gapl_id); /* Check arguments */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Check link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a link creation property list") + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a link creation property list") /* Check group creation property list */ - if(H5P_DEFAULT == gcpl_id) + if (H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group creation property list") + else if (TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group creation property list") /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set the location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Create the group */ - if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, lcpl_id, gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, lcpl_id, gcpl_id, gapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle") done: - if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate2() */ - /*------------------------------------------------------------------------- * Function: H5Gcreate_anon * @@ -435,51 +417,50 @@ done: hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) { - void *grp = NULL; /* Structure for new group */ - H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * grp = NULL; /* Structure for new group */ + H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id); /* Check group creation property list */ - if(H5P_DEFAULT == gcpl_id) + if (H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list") + else if (TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the group */ - if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, gcpl_id, + gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate_anon() */ - /*------------------------------------------------------------------------- * Function: H5Gopen2 * @@ -498,48 +479,48 @@ done: hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { - void *grp = NULL; /* Group opened */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * grp = NULL; /* Group opened */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, gapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the group */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - if(NULL == (grp = H5VL_group_open(vol_obj, &loc_params, name, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (grp = H5VL_group_open(vol_obj, &loc_params, name, gapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") /* Register an ID for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: - if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gopen2() */ - /*------------------------------------------------------------------------- * Function: H5Gget_create_plist * @@ -556,25 +537,25 @@ done: hid_t H5Gget_create_plist(hid_t group_id) { - H5VL_object_t *vol_obj = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5VL_object_t *vol_obj = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", group_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group ID") /* Get the group creation property list for the group */ - if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_GCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_GCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < + 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get group's creation property list") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Gget_info * @@ -587,36 +568,36 @@ done: herr_t H5Gget_info(hid_t loc_id, H5G_info_t *group_info) { - H5VL_object_t *vol_obj; - H5I_type_t id_type; /* Type of ID */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5I_type_t id_type; /* Type of ID */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", loc_id, group_info); /* Check args */ id_type = H5I_get_type(loc_id); - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group (or file) ID") - if(!group_info) + if (!group_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") /* Get group location */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the group's information */ loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = id_type; - if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, group_info) < 0) + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + group_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_info() */ - /*------------------------------------------------------------------------- * Function: H5Gget_info_by_name * @@ -628,47 +609,46 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info, - hid_t lapl_id) +H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info, hid_t lapl_id) { - H5VL_object_t *vol_obj; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, group_info, lapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") - if(!group_info) + if (!group_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up location parameters */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; - loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* Retrieve the group's information */ - if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, group_info) < 0) + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + group_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Gget_info_by_idx * @@ -680,35 +660,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5G_info_t *group_info, hid_t lapl_id) +H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5G_info_t *group_info, hid_t lapl_id) { - H5VL_object_t *vol_obj; + H5VL_object_t * vol_obj; H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIoh*xi", loc_id, group_name, idx_type, order, n, group_info, lapl_id); /* Check args */ - if(!group_name) + if (!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") - if(!*group_name) + if (!*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!group_info) + if (!group_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location parameters */ @@ -721,14 +701,14 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Retrieve the group's information */ - if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, group_info) < 0) + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + group_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Gclose * @@ -742,26 +722,25 @@ done: herr_t H5Gclose(hid_t group_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); /* Check args */ - if(NULL == H5I_object_verify(group_id, H5I_GROUP)) + if (NULL == H5I_object_verify(group_id, H5I_GROUP)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Decrement the counter on the group atom. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref(group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") + if (H5I_dec_app_ref(group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") done: FUNC_LEAVE_API(ret_value) } /* end H5Gclose() */ - /*------------------------------------------------------------------------- * Function: H5Gflush * @@ -777,29 +756,29 @@ done: herr_t H5Gflush(hid_t group_id) { - H5VL_object_t *vol_obj; /* Group for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Group for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(group_id) < 0) + if (H5CX_set_loc(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Flush group's metadata to file */ - if(H5VL_group_specific(vol_obj, H5VL_GROUP_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id) < 0) + if (H5VL_group_specific(vol_obj, H5VL_GROUP_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id) < + 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") done: FUNC_LEAVE_API(ret_value) } /* H5Gflush */ - /*------------------------------------------------------------------------- * Function: H5Grefresh * @@ -815,25 +794,25 @@ done: herr_t H5Grefresh(hid_t group_id) { - H5VL_object_t *vol_obj; /* Group for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Group for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(group_id) < 0) + if (H5CX_set_loc(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Refresh group's metadata */ - if(H5VL_group_specific(vol_obj, H5VL_GROUP_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id) < 0) + if (H5VL_group_specific(vol_obj, H5VL_GROUP_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") done: FUNC_LEAVE_API(ret_value) } /* H5Grefresh */ - diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index 71e0b2d..ee0b26e 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -26,23 +26,20 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -53,21 +50,19 @@ */ typedef struct H5G_fh_ud_cmp_t { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - const char *name; /* Name of link to compare */ - H5B2_found_t found_op; /* Callback when correct link is found */ - void *found_op_data; /* Callback data when correct link is found */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + const char * name; /* Name of link to compare */ + H5B2_found_t found_op; /* Callback when correct link is found */ + void * found_op_data; /* Callback data when correct link is found */ /* upward */ - int cmp; /* Comparison of two link names */ + int cmp; /* Comparison of two link names */ } H5G_fh_ud_cmp_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -77,46 +72,43 @@ typedef struct H5G_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5G_dense_btree2_corder_store(void *native, const void *udata); static herr_t H5G_dense_btree2_corder_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5G_dense_btree2_corder_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5G_dense_btree2_corder_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5G_dense_btree2_corder_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5G_dense_btree2_corder_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5G_dense_btree2_name_store(void *native, const void *udata); static herr_t H5G__dense_btree2_name_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5G_dense_btree2_name_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5G_dense_btree2_name_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5G_dense_btree2_name_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5G_dense_btree2_name_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Fractal heap function callbacks */ static herr_t H5G_dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data); - /*********************/ /* Package Variables */ /*********************/ /* v2 B-tree class for indexing 'name' field of links */ -const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */ - H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */ - "H5B2_GRP_DENSE_NAME_ID", /* Name of B-tree class */ - sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */ - NULL, /* Create client callback context */ - NULL, /* Destroy client callback context */ - H5G_dense_btree2_name_store, /* Record storage callback */ - H5G__dense_btree2_name_compare, /* Record comparison callback */ - H5G_dense_btree2_name_encode, /* Record encoding callback */ - H5G_dense_btree2_name_decode, /* Record decoding callback */ - H5G_dense_btree2_name_debug /* Record debugging callback */ +const H5B2_class_t H5G_BT2_NAME[1] = {{ + /* B-tree class information */ + H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */ + "H5B2_GRP_DENSE_NAME_ID", /* Name of B-tree class */ + sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ + H5G_dense_btree2_name_store, /* Record storage callback */ + H5G__dense_btree2_name_compare, /* Record comparison callback */ + H5G_dense_btree2_name_encode, /* Record encoding callback */ + H5G_dense_btree2_name_decode, /* Record decoding callback */ + H5G_dense_btree2_name_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing 'creation order' field of links */ -const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ +const H5B2_class_t H5G_BT2_CORDER[1] = {{ + /* B-tree class information */ H5B2_GRP_DENSE_CORDER_ID, /* Type of B-tree */ "H5B2_GRP_DENSE_CORDER_ID", /* Name of B-tree class */ sizeof(H5G_dense_bt2_corder_rec_t), /* Size of native record */ @@ -133,13 +125,10 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G_dense_fh_name_cmp * @@ -157,22 +146,23 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ static herr_t H5G_dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata) { - H5G_fh_ud_cmp_t *udata = (H5G_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */ - H5O_link_t *lnk; /* Pointer to link created from heap object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_fh_ud_cmp_t *udata = (H5G_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */ + H5O_link_t * lnk; /* Pointer to link created from heap object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Decode link information */ - if(NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Compare the string values */ udata->cmp = HDstrcmp(udata->name, lnk->name); /* Check for correct link & callback to make */ - if(udata->cmp == 0 && udata->found_op) { - if((udata->found_op)(lnk, udata->found_op_data) < 0) + if (udata->cmp == 0 && udata->found_op) { + if ((udata->found_op)(lnk, udata->found_op_data) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link found callback failed") } /* end if */ @@ -183,7 +173,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_fh_name_cmp() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_name_store * @@ -200,7 +189,7 @@ done: static herr_t H5G_dense_btree2_name_store(void *_nrecord, const void *_udata) { - const H5G_bt2_ud_ins_t *udata = (const H5G_bt2_ud_ins_t *)_udata; + const H5G_bt2_ud_ins_t * udata = (const H5G_bt2_ud_ins_t *)_udata; H5G_dense_bt2_name_rec_t *nrecord = (H5G_dense_bt2_name_rec_t *)_nrecord; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -212,7 +201,6 @@ H5G_dense_btree2_name_store(void *_nrecord, const void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_name_store() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_name_compare * @@ -230,9 +218,9 @@ H5G_dense_btree2_name_store(void *_nrecord, const void *_udata) static herr_t H5G__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { - const H5G_bt2_ud_common_t *bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; - const H5G_dense_bt2_name_rec_t *bt2_rec = (const H5G_dense_bt2_name_rec_t *)_bt2_rec; - herr_t ret_value = SUCCEED; /* Return value */ + const H5G_bt2_ud_common_t * bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; + const H5G_dense_bt2_name_rec_t *bt2_rec = (const H5G_dense_bt2_name_rec_t *)_bt2_rec; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -241,38 +229,39 @@ H5G__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int HDassert(bt2_rec); #ifdef QAK -{ -unsigned u; - -HDfprintf(stderr, "%s: bt2_udata = {'%s', %x}\n", "H5G__dense_btree2_name_compare", bt2_udata->name, (unsigned)bt2_udata->name_hash); -HDfprintf(stderr, "%s: bt2_rec = {%x, ", "H5G__dense_btree2_name_compare", (unsigned)bt2_rec->hash); -for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) - HDfprintf(stderr, "%02x%s", bt2_rec->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); -} + { + unsigned u; + + HDfprintf(stderr, "%s: bt2_udata = {'%s', %x}\n", "H5G__dense_btree2_name_compare", bt2_udata->name, + (unsigned)bt2_udata->name_hash); + HDfprintf(stderr, "%s: bt2_rec = {%x, ", "H5G__dense_btree2_name_compare", (unsigned)bt2_rec->hash); + for (u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) + HDfprintf(stderr, "%02x%s", bt2_rec->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); + } #endif /* QAK */ /* Check hash value */ - if(bt2_udata->name_hash < bt2_rec->hash) + if (bt2_udata->name_hash < bt2_rec->hash) *result = (-1); - else if(bt2_udata->name_hash > bt2_rec->hash) + else if (bt2_udata->name_hash > bt2_rec->hash) *result = 1; else { - H5G_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5G_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */ /* Sanity check */ HDassert(bt2_udata->name_hash == bt2_rec->hash); /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; - fh_udata.name = bt2_udata->name; - fh_udata.found_op = bt2_udata->found_op; + fh_udata.f = bt2_udata->f; + fh_udata.name = bt2_udata->name; + fh_udata.found_op = bt2_udata->found_op; fh_udata.found_op_data = bt2_udata->found_op_data; /* up */ fh_udata.cmp = 0; /* Check if the user's link and the B-tree's link have the same name */ - if(H5HF_op(bt2_udata->fheap, bt2_rec->id, H5G_dense_fh_name_cmp, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, bt2_rec->id, H5G_dense_fh_name_cmp, &fh_udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Callback will set comparison value */ @@ -283,7 +272,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5G__dense_btree2_name_compare() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_name_encode * @@ -311,7 +299,6 @@ H5G_dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_UN FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_name_encode() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_name_decode * @@ -339,7 +326,6 @@ H5G_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_UN FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_name_decode() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_name_debug * @@ -354,23 +340,21 @@ H5G_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_UN *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5G_dense_bt2_name_rec_t *nrecord = (const H5G_dense_bt2_name_rec_t *)_nrecord; - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR - HDfprintf(stream, "%*s%-*s {%x, ", indent, "", fwidth, "Record:", - (unsigned)nrecord->hash); - for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) + HDfprintf(stream, "%*s%-*s {%x, ", indent, "", fwidth, "Record:", (unsigned)nrecord->hash); + for (u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) HDfprintf(stderr, "%02x%s", nrecord->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_name_debug() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_corder_store * @@ -387,7 +371,7 @@ H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, static herr_t H5G_dense_btree2_corder_store(void *_nrecord, const void *_udata) { - const H5G_bt2_ud_ins_t *udata = (const H5G_bt2_ud_ins_t *)_udata; + const H5G_bt2_ud_ins_t * udata = (const H5G_bt2_ud_ins_t *)_udata; H5G_dense_bt2_corder_rec_t *nrecord = (H5G_dense_bt2_corder_rec_t *)_nrecord; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -399,7 +383,6 @@ H5G_dense_btree2_corder_store(void *_nrecord, const void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_corder_store() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_corder_compare * @@ -417,8 +400,8 @@ H5G_dense_btree2_corder_store(void *_nrecord, const void *_udata) static herr_t H5G_dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { - const H5G_bt2_ud_common_t *bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; - const H5G_dense_bt2_corder_rec_t *bt2_rec = (const H5G_dense_bt2_corder_rec_t *)_bt2_rec; + const H5G_bt2_ud_common_t * bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; + const H5G_dense_bt2_corder_rec_t *bt2_rec = (const H5G_dense_bt2_corder_rec_t *)_bt2_rec; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -427,19 +410,21 @@ H5G_dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, in HDassert(bt2_rec); #ifdef QAK -{ -unsigned u; - -HDfprintf(stderr, "%s: bt2_udata->corder = %Hd\n", "H5G_dense_btree2_corder_compare", (hsize_t)bt2_udata->corder); -HDfprintf(stderr, "%s: bt2_rec = {%Hu, ", "H5G_dense_btree2_corder_compare", (hsize_t)bt2_rec->corder); -for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) - HDfprintf(stderr, "%02x%s", bt2_rec->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); -} + { + unsigned u; + + HDfprintf(stderr, "%s: bt2_udata->corder = %Hd\n", "H5G_dense_btree2_corder_compare", + (hsize_t)bt2_udata->corder); + HDfprintf(stderr, "%s: bt2_rec = {%Hu, ", "H5G_dense_btree2_corder_compare", + (hsize_t)bt2_rec->corder); + for (u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) + HDfprintf(stderr, "%02x%s", bt2_rec->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); + } #endif /* QAK */ /* Check creation order value */ - if(bt2_udata->corder < bt2_rec->corder) + if (bt2_udata->corder < bt2_rec->corder) *result = -1; - else if(bt2_udata->corder > bt2_rec->corder) + else if (bt2_udata->corder > bt2_rec->corder) *result = 1; else *result = 0; @@ -447,7 +432,6 @@ for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_corder_compare() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_corder_encode * @@ -475,7 +459,6 @@ H5G_dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_corder_encode() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_corder_decode * @@ -503,7 +486,6 @@ H5G_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_corder_decode() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_btree2_corder_debug * @@ -518,19 +500,17 @@ H5G_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_ *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5G_dense_bt2_corder_rec_t *nrecord = (const H5G_dense_bt2_corder_rec_t *)_nrecord; - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR - HDfprintf(stream, "%*s%-*s {%llu, ", indent, "", fwidth, "Record:", - (unsigned long long)nrecord->corder); - for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) + HDfprintf(stream, "%*s%-*s {%llu, ", indent, "", fwidth, "Record:", (unsigned long long)nrecord->corder); + for (u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) HDfprintf(stderr, "%02x%s", nrecord->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G_dense_btree2_corder_debug() */ - diff --git a/src/H5Gcache.c b/src/H5Gcache.c index ca67d56..23ca7ca 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -26,92 +26,80 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ -#define H5G_NODE_VERS 1 /* Symbol table node version number */ - +#define H5G_NODE_VERS 1 /* Symbol table node version number */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache (H5AC) callbacks */ static herr_t H5G__cache_node_get_initial_load_size(void *udata, size_t *image_len); -static void *H5G__cache_node_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5G__cache_node_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5G__cache_node_image_len(const void *thing, size_t *image_len); -static herr_t H5G__cache_node_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5G__cache_node_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5G__cache_node_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Symbol table nodes inherit cache-like properties from H5AC */ const H5AC_class_t H5AC_SNODE[1] = {{ - H5AC_SNODE_ID, /* Metadata client ID */ - "Symbol table node", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5G__cache_node_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5G__cache_node_deserialize, /* 'deserialize' callback */ - H5G__cache_node_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5G__cache_node_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5G__cache_node_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_SNODE_ID, /* Metadata client ID */ + "Symbol table node", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5G__cache_node_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5G__cache_node_deserialize, /* 'deserialize' callback */ + H5G__cache_node_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5G__cache_node_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5G__cache_node_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /* Declare extern the free list to manage the H5G_node_t struct */ H5FL_EXTERN(H5G_node_t); /* Declare extern the free list to manage sequences of H5G_entry_t's */ H5FL_SEQ_EXTERN(H5G_entry_t); - /*------------------------------------------------------------------------- * Function: H5G__cache_node_get_initial_load_size() * @@ -129,7 +117,7 @@ H5FL_SEQ_EXTERN(H5G_entry_t); static herr_t H5G__cache_node_get_initial_load_size(void *_udata, size_t *image_len) { - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -143,7 +131,6 @@ H5G__cache_node_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__cache_node_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5G__cache_node_deserialize * @@ -166,14 +153,13 @@ H5G__cache_node_get_initial_load_size(void *_udata, size_t *image_len) *------------------------------------------------------------------------- */ static void * -H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ - H5G_node_t *sym = NULL; /* Symbol table node created */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer to image to deserialize */ - const uint8_t *image_end = image + len - 1; /* Pointer to end of image buffer */ - void *ret_value = NULL; /* Return value */ + H5F_t * f = (H5F_t *)_udata; /* User data for callback */ + H5G_node_t * sym = NULL; /* Symbol table node created */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer to image to deserialize */ + const uint8_t *image_end = image + len - 1; /* Pointer to end of image buffer */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -184,19 +170,19 @@ H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, HDassert(dirty); /* Allocate symbol table data structures */ - if(NULL == (sym = H5FL_CALLOC(H5G_node_t))) + if (NULL == (sym = H5FL_CALLOC(H5G_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") sym->node_size = (size_t)(H5G_NODE_SIZE(f)); - if(NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f))))) + if (NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f))))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* magic */ - if(HDmemcmp(image, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "bad symbol table node signature") image += H5_SIZEOF_MAGIC; /* version */ - if(H5G_NODE_VERS != *image++) + if (H5G_NODE_VERS != *image++) HGOTO_ERROR(H5E_SYM, H5E_VERSION, NULL, "bad symbol table node version") /* reserved */ @@ -206,21 +192,20 @@ H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, UINT16DECODE(image, sym->nsyms); /* entries */ - if(H5G__ent_decode_vec(f, &image, image_end, sym->entry, sym->nsyms) < 0) + if (H5G__ent_decode_vec(f, &image, image_end, sym->entry, sym->nsyms) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "unable to decode symbol table entries") /* Set return value */ ret_value = sym; done: - if(!ret_value) - if(sym && H5G__node_free(sym) < 0) + if (!ret_value) + if (sym && H5G__node_free(sym) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, NULL, "unable to destroy symbol table node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__cache_node_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5G__cache_node_image_len * @@ -253,7 +238,6 @@ H5G__cache_node_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__cache_node_image_len() */ - /*------------------------------------------------------------------------- * Function: H5G__cache_node_serialize * @@ -271,12 +255,11 @@ H5G__cache_node_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len, - void *_thing) +H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len, void *_thing) { - H5G_node_t *sym = (H5G_node_t *)_thing; /* Pointer to object */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_node_t *sym = (H5G_node_t *)_thing; /* Pointer to object */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -302,7 +285,7 @@ H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len, UINT16ENCODE(image, sym->nsyms); /* entries */ - if(H5G__ent_encode_vec(f, &image, sym->entry, sym->nsyms) < 0) + if (H5G__ent_encode_vec(f, &image, sym->entry, sym->nsyms) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't serialize") /* Clear rest of symbol table node */ @@ -312,7 +295,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__cache_node_serialize() */ - /*------------------------------------------------------------------------- * Function: H5G__cache_node_free_icr * @@ -333,8 +315,8 @@ done: static herr_t H5G__cache_node_free_icr(void *_thing) { - H5G_node_t *sym = (H5G_node_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_node_t *sym = (H5G_node_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -344,10 +326,9 @@ H5G__cache_node_free_icr(void *_thing) HDassert(sym->cache_info.type == H5AC_SNODE); /* Destroy symbol table node */ - if(H5G__node_free(sym) < 0) + if (H5G__node_free(sym) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to destroy symbol table node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__cache_node_free_icr() */ - diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index 1a76012..5bd2243 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -21,51 +21,48 @@ * *------------------------------------------------------------------------- */ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ /* Private typedefs */ /* User data for link message iteration when building link table */ typedef struct { H5G_link_table_t *ltable; /* Pointer to link table to build */ - size_t curr_lnk; /* Current link to operate on */ + size_t curr_lnk; /* Current link to operate on */ } H5G_iter_bt_t; /* User data for deleting a link in the link messages */ typedef struct { /* downward */ - H5F_t *file; /* File that object header is located within */ - H5RS_str_t *grp_full_path_r;/* Full path for group of link */ - const char *name; /* Link name to search for */ + H5F_t * file; /* File that object header is located within */ + H5RS_str_t *grp_full_path_r; /* Full path for group of link */ + const char *name; /* Link name to search for */ } H5G_iter_rm_t; /* User data for link message iteration when querying link info */ typedef struct { /* downward */ - const char *name; /* Name to search for */ + const char *name; /* Name to search for */ /* upward */ - H5O_link_t *lnk; /* Link struct to fill in */ - hbool_t found; /* Flag to indicate that the object was found */ + H5O_link_t *lnk; /* Link struct to fill in */ + hbool_t found; /* Flag to indicate that the object was found */ } H5G_iter_lkp_t; /* Private macros */ /* PRIVATE PROTOTYPES */ static herr_t H5G__compact_build_table_cb(const void *_mesg, unsigned idx, void *_udata); -static herr_t H5G__compact_build_table(const H5O_loc_t *oloc, - const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, - H5G_link_table_t *ltable); +static herr_t H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, H5G_link_table_t *ltable); static herr_t H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata); - /*------------------------------------------------------------------------- * Function: H5G__compact_build_table_cb * @@ -83,9 +80,9 @@ static herr_t H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED static herr_t H5G__compact_build_table_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata) { - const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_iter_bt_t *udata = (H5G_iter_bt_t *)_udata; /* 'User data' passed in */ - herr_t ret_value=H5_ITER_CONT; /* Return value */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ + H5G_iter_bt_t * udata = (H5G_iter_bt_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -95,7 +92,7 @@ H5G__compact_build_table_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void HDassert(udata->curr_lnk < udata->ltable->nlinks); /* Copy link message into table */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk]))) + if (NULL == H5O_msg_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk]))) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") /* Increment current link entry to operate on */ @@ -105,7 +102,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_build_table_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_build_table * @@ -121,10 +117,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable) +H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, H5G_link_table_t *ltable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -138,26 +134,26 @@ H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, ltable->nlinks = (size_t)linfo->nlinks; /* Allocate space for the table entries */ - if(ltable->nlinks > 0) { - H5G_iter_bt_t udata; /* User data for iteration callback */ - H5O_mesg_operator_t op; /* Message operator */ + if (ltable->nlinks > 0) { + H5G_iter_bt_t udata; /* User data for iteration callback */ + H5O_mesg_operator_t op; /* Message operator */ /* Allocate the link table */ - if((ltable->lnks = (H5O_link_t *)H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) + if ((ltable->lnks = (H5O_link_t *)H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set up user data for iteration */ - udata.ltable = ltable; + udata.ltable = ltable; udata.curr_lnk = 0; /* Iterate through the link messages, adding them to the table */ - op.op_type = H5O_MESG_OP_APP; + op.op_type = H5O_MESG_OP_APP; op.u.app_op = H5G__compact_build_table_cb; - if(H5O_msg_iterate(oloc, H5O_LINK_ID, &op, &udata) < 0) + if (H5O_msg_iterate(oloc, H5O_LINK_ID, &op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") /* Sort link table in correct iteration order */ - if(H5G__link_sort_table(ltable, idx_type, order) < 0) + if (H5G__link_sort_table(ltable, idx_type, order) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") } /* end if */ else @@ -167,7 +163,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_build_table() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_insert * @@ -186,7 +181,7 @@ done: herr_t H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -195,14 +190,13 @@ H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk) HDassert(obj_lnk); /* Insert link message into group */ - if(H5O_msg_create(grp_oloc, H5O_LINK_ID, 0, H5O_UPDATE_TIME, obj_lnk) < 0) + if (H5O_msg_create(grp_oloc, H5O_LINK_ID, 0, H5O_UPDATE_TIME, obj_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_insert() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_get_name_by_idx * @@ -217,12 +211,11 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, char* name, - size_t size) +H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t idx, char *name, size_t size) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - ssize_t ret_value = -1; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -230,32 +223,31 @@ H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, HDassert(oloc); /* Build table of all link messages */ - if(H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) + if (H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") /* Check for going out of bounds */ - if(idx >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") + if (idx >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Get the length of the name */ ret_value = (ssize_t)HDstrlen(ltable.lnks[idx].name); /* Copy the name into the user's buffer, if given */ - if(name) { + if (name) { HDstrncpy(name, ltable.lnks[idx].name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; + if ((size_t)ret_value >= size) + name[size - 1] = '\0'; } /* end if */ done: /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_get_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G_compact_remove_common_cb * @@ -273,9 +265,9 @@ done: static herr_t H5G_compact_remove_common_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata) { - const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_iter_rm_t *udata = (H5G_iter_rm_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ + H5G_iter_rm_t * udata = (H5G_iter_rm_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -284,9 +276,9 @@ H5G_compact_remove_common_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, voi HDassert(udata); /* If we've found the right link, get the object type */ - if(HDstrcmp(lnk->name, udata->name) == 0) { + if (HDstrcmp(lnk->name, udata->name) == 0) { /* Replace path names for link being removed */ - if(H5G__link_name_replace(udata->file, udata->grp_full_path_r, lnk) < 0) + if (H5G__link_name_replace(udata->file, udata->grp_full_path_r, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get object type") /* Stop the iteration, we found the correct link */ @@ -297,7 +289,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_compact_remove_common_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_remove * @@ -311,11 +302,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - const char *name) +H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name) { H5G_iter_rm_t udata; /* Data to pass through OH iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -323,19 +313,18 @@ H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, HDassert(name && *name); /* Initialize data to pass through object header iteration */ - udata.file = oloc->file; + udata.file = oloc->file; udata.grp_full_path_r = grp_full_path_r; - udata.name = name; + udata.name = name; /* Iterate over the link messages to delete the right one */ - if(H5O_msg_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G_compact_remove_common_cb, &udata, TRUE) < 0) + if (H5O_msg_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G_compact_remove_common_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_remove_by_idx * @@ -349,13 +338,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5RS_str_t *grp_full_path_r, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n) +H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { - H5G_link_table_t ltable = {0, NULL};/* Link table */ - H5G_iter_rm_t udata; /* Data to pass through OH iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + H5G_iter_rm_t udata; /* Data to pass through OH iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -363,31 +351,30 @@ H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, HDassert(linfo); /* Build table of all link messages, sorted according to desired order */ - if(H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) + if (H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") /* Check for going out of bounds */ - if(n >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") + if (n >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") /* Initialize data to pass through object header iteration */ - udata.file = oloc->file; + udata.file = oloc->file; udata.grp_full_path_r = grp_full_path_r; - udata.name = ltable.lnks[n].name; + udata.name = ltable.lnks[n].name; /* Iterate over the link messages to delete the right one */ - if(H5O_msg_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G_compact_remove_common_cb, &udata, TRUE) < 0) + if (H5O_msg_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G_compact_remove_common_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link message") done: /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_iterate * @@ -401,12 +388,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - H5G_lib_iterate_t op, void *op_data) +H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, + void *op_data) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - herr_t ret_value = FAIL; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -416,22 +403,21 @@ H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, HDassert(op); /* Build table of all link messages */ - if(H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) + if (H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") /* Iterate over links in table */ - if((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); done: /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_lookup_cb * @@ -449,9 +435,9 @@ done: static herr_t H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata) { - const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_iter_lkp_t *udata = (H5G_iter_lkp_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ + H5G_iter_lkp_t * udata = (H5G_iter_lkp_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -460,10 +446,10 @@ H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_ud HDassert(udata); /* Check for name to get information */ - if(HDstrcmp(lnk->name, udata->name) == 0) { - if(udata->lnk) { + if (HDstrcmp(lnk->name, udata->name) == 0) { + if (udata->lnk) { /* Copy link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, lnk, udata->lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, lnk, udata->lnk)) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") } /* end if */ @@ -478,7 +464,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_lookup_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_lookup * @@ -495,9 +480,9 @@ done: htri_t H5G__compact_lookup(const H5O_loc_t *oloc, const char *name, H5O_link_t *lnk) { - H5G_iter_lkp_t udata; /* User data for iteration callback */ - H5O_mesg_operator_t op; /* Message operator */ - htri_t ret_value = FAIL; /* Return value */ + H5G_iter_lkp_t udata; /* User data for iteration callback */ + H5O_mesg_operator_t op; /* Message operator */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -506,14 +491,14 @@ H5G__compact_lookup(const H5O_loc_t *oloc, const char *name, H5O_link_t *lnk) HDassert(name && *name); /* Set up user data for iteration */ - udata.name = name; - udata.lnk = lnk; + udata.name = name; + udata.lnk = lnk; udata.found = FALSE; /* Iterate through the link messages, adding them to the table */ - op.op_type = H5O_MESG_OP_APP; + op.op_type = H5O_MESG_OP_APP; op.u.app_op = H5G__compact_lookup_cb; - if(H5O_msg_iterate(oloc, H5O_LINK_ID, &op, &udata) < 0) + if (H5O_msg_iterate(oloc, H5O_LINK_ID, &op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") /* Determine if we found the link we were looking for */ @@ -523,7 +508,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_lookup() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_lookup_by_idx * @@ -539,11 +523,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) +H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) { - H5G_link_table_t ltable = {0, NULL};/* Link table */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -553,22 +537,21 @@ H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, HDassert(lnk); /* Build table of all link messages, sorted according to desired order */ - if(H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) + if (H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") /* Check for going out of bounds */ - if(n >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") + if (n >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") /* Copy link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, <able.lnks[n], lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, <able.lnks[n], lnk)) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") done: /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_lookup_by_idx() */ - diff --git a/src/H5Gdense.c b/src/H5Gdense.c index a2ef55c..0b3f428 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -27,44 +27,42 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* Fractal heap creation parameters for "dense" link storage */ -#define H5G_FHEAP_MAN_WIDTH 4 -#define H5G_FHEAP_MAN_START_BLOCK_SIZE 512 -#define H5G_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024) -#define H5G_FHEAP_MAN_MAX_INDEX 32 -#define H5G_FHEAP_MAN_START_ROOT_ROWS 1 -#define H5G_FHEAP_CHECKSUM_DBLOCKS TRUE -#define H5G_FHEAP_MAX_MAN_SIZE (4 * 1024) +#define H5G_FHEAP_MAN_WIDTH 4 +#define H5G_FHEAP_MAN_START_BLOCK_SIZE 512 +#define H5G_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024) +#define H5G_FHEAP_MAN_MAX_INDEX 32 +#define H5G_FHEAP_MAN_START_ROOT_ROWS 1 +#define H5G_FHEAP_CHECKSUM_DBLOCKS TRUE +#define H5G_FHEAP_MAX_MAN_SIZE (4 * 1024) /* v2 B-tree creation macros for 'name' field index */ -#define H5G_NAME_BT2_NODE_SIZE 512 -#define H5G_NAME_BT2_MERGE_PERC 40 -#define H5G_NAME_BT2_SPLIT_PERC 100 +#define H5G_NAME_BT2_NODE_SIZE 512 +#define H5G_NAME_BT2_MERGE_PERC 40 +#define H5G_NAME_BT2_SPLIT_PERC 100 /* v2 B-tree creation macros for 'corder' field index */ -#define H5G_CORDER_BT2_NODE_SIZE 512 -#define H5G_CORDER_BT2_MERGE_PERC 40 -#define H5G_CORDER_BT2_SPLIT_PERC 100 +#define H5G_CORDER_BT2_NODE_SIZE 512 +#define H5G_CORDER_BT2_MERGE_PERC 40 +#define H5G_CORDER_BT2_SPLIT_PERC 100 /* Size of stack buffer for serialized link */ -#define H5G_LINK_BUF_SIZE 128 - +#define H5G_LINK_BUF_SIZE 128 /******************/ /* Local Typedefs */ @@ -73,7 +71,7 @@ /* Data exchange structure to use when building table of links in group */ typedef struct { H5G_link_table_t *ltable; /* Pointer to link table to build */ - size_t curr_lnk; /* Current link to operate on */ + size_t curr_lnk; /* Current link to operate on */ } H5G_dense_bt_ud_t; /* @@ -82,17 +80,17 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ - hsize_t count; /* # of links examined */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle */ + hsize_t count; /* # of links examined */ /* downward (from application) */ - hsize_t skip; /* Number of links to skip */ - H5G_lib_iterate_t op; /* Callback for each link */ - void *op_data; /* Callback data for each link */ + hsize_t skip; /* Number of links to skip */ + H5G_lib_iterate_t op; /* Callback for each link */ + void * op_data; /* Callback data for each link */ /* upward */ - int op_ret; /* Return value from callback */ + int op_ret; /* Return value from callback */ } H5G_bt2_ud_it_t; /* @@ -101,10 +99,10 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ /* upward */ - H5O_link_t *lnk; /* Copy of link */ + H5O_link_t *lnk; /* Copy of link */ } H5G_fh_ud_it_t; /* @@ -113,11 +111,11 @@ typedef struct { */ typedef struct { /* downward */ - H5G_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ - hbool_t rem_from_fheap; /* Whether to remove the link from the fractal heap */ - haddr_t corder_bt2_addr; /* Address of v2 B-tree indexing creation order */ - H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ - hbool_t replace_names; /* Whether to replace the names of open objects */ + H5G_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ + hbool_t rem_from_fheap; /* Whether to remove the link from the fractal heap */ + haddr_t corder_bt2_addr; /* Address of v2 B-tree indexing creation order */ + H5RS_str_t * grp_full_path_r; /* Full path of group where link is removed */ + hbool_t replace_names; /* Whether to replace the names of open objects */ } H5G_bt2_ud_rm_t; /* @@ -126,10 +124,10 @@ typedef struct { */ typedef struct { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - haddr_t corder_bt2_addr; /* Address of v2 B-tree indexing creation order */ - H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ - hbool_t replace_names; /* Whether to replace the names of open objects */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + haddr_t corder_bt2_addr; /* Address of v2 B-tree indexing creation order */ + H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ + hbool_t replace_names; /* Whether to replace the names of open objects */ } H5G_fh_ud_rm_t; /* @@ -138,11 +136,11 @@ typedef struct { */ typedef struct { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ - H5_index_t idx_type; /* Primary index for removing link */ - haddr_t other_bt2_addr; /* Address of "other" v2 B-tree indexing link */ - H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t * fheap; /* Fractal heap handle */ + H5_index_t idx_type; /* Primary index for removing link */ + haddr_t other_bt2_addr; /* Address of "other" v2 B-tree indexing link */ + H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ } H5G_bt2_ud_rmbi_t; /* @@ -151,10 +149,10 @@ typedef struct { */ typedef struct { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ /* upward */ - H5O_link_t *lnk; /* Pointer to link to remove */ + H5O_link_t *lnk; /* Pointer to link to remove */ } H5G_fh_ud_rmbi_t; /* @@ -163,15 +161,15 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle */ /* downward (from application) */ - char *name; /* Name buffer to fill */ - size_t name_size; /* Size of name buffer to fill */ + char * name; /* Name buffer to fill */ + size_t name_size; /* Size of name buffer to fill */ /* upward */ - ssize_t name_len; /* Full length of name */ + ssize_t name_len; /* Full length of name */ } H5G_bt2_ud_gnbi_t; /* @@ -180,14 +178,14 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ /* downward (from application) */ - char *name; /* Name buffer to fill */ - size_t name_size; /* Size of name buffer to fill */ + char * name; /* Name buffer to fill */ + size_t name_size; /* Size of name buffer to fill */ /* upward */ - ssize_t name_len; /* Full length of name */ + ssize_t name_len; /* Full length of name */ } H5G_fh_ud_gnbi_t; /* @@ -196,11 +194,11 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle */ /* upward */ - H5O_link_t *lnk; /* Pointer to link */ + H5O_link_t *lnk; /* Pointer to link */ } H5G_bt2_ud_lbi_t; /* @@ -209,39 +207,32 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ /* upward */ - H5O_link_t *lnk; /* Pointer to link */ + H5O_link_t *lnk; /* Pointer to link */ } H5G_fh_ud_lbi_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__dense_create * @@ -258,13 +249,13 @@ typedef struct { herr_t H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline) { - H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for names */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order */ - size_t fheap_id_len; /* Fractal heap ID length */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for names */ + H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order */ + size_t fheap_id_len; /* Fractal heap ID length */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -275,91 +266,90 @@ H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline) HDassert(linfo); /* Set fractal heap creation parameters */ -/* XXX: Give some control of these to applications? */ + /* XXX: Give some control of these to applications? */ HDmemset(&fheap_cparam, 0, sizeof(fheap_cparam)); - fheap_cparam.managed.width = H5G_FHEAP_MAN_WIDTH; + fheap_cparam.managed.width = H5G_FHEAP_MAN_WIDTH; fheap_cparam.managed.start_block_size = H5G_FHEAP_MAN_START_BLOCK_SIZE; - fheap_cparam.managed.max_direct_size = H5G_FHEAP_MAN_MAX_DIRECT_SIZE; - fheap_cparam.managed.max_index = H5G_FHEAP_MAN_MAX_INDEX; - fheap_cparam.managed.start_root_rows = H5G_FHEAP_MAN_START_ROOT_ROWS; - fheap_cparam.checksum_dblocks = H5G_FHEAP_CHECKSUM_DBLOCKS; - fheap_cparam.max_man_size = H5G_FHEAP_MAX_MAN_SIZE; - if(pline) + fheap_cparam.managed.max_direct_size = H5G_FHEAP_MAN_MAX_DIRECT_SIZE; + fheap_cparam.managed.max_index = H5G_FHEAP_MAN_MAX_INDEX; + fheap_cparam.managed.start_root_rows = H5G_FHEAP_MAN_START_ROOT_ROWS; + fheap_cparam.checksum_dblocks = H5G_FHEAP_CHECKSUM_DBLOCKS; + fheap_cparam.max_man_size = H5G_FHEAP_MAX_MAN_SIZE; + if (pline) fheap_cparam.pline = *pline; /* Create fractal heap for storing links */ - if(NULL == (fheap = H5HF_create(f, &fheap_cparam))) + if (NULL == (fheap = H5HF_create(f, &fheap_cparam))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create fractal heap") /* Retrieve the heap's address in the file */ - if(H5HF_get_heap_addr(fheap, &(linfo->fheap_addr)) < 0) + if (H5HF_get_heap_addr(fheap, &(linfo->fheap_addr)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get fractal heap address") #ifdef QAK -HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr); + HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr); #endif /* QAK */ /* Retrieve the heap's ID length in the file */ - if(H5HF_get_id_len(fheap, &fheap_id_len) < 0) + if (H5HF_get_id_len(fheap, &fheap_id_len) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") HDassert(fheap_id_len == H5G_DENSE_FHEAP_ID_LEN); #ifdef QAK -HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); + HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); #endif /* QAK */ /* Create the name index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); - bt2_cparam.cls = H5G_BT2_NAME; + bt2_cparam.cls = H5G_BT2_NAME; bt2_cparam.node_size = (size_t)H5G_NAME_BT2_NODE_SIZE; H5_CHECK_OVERFLOW(fheap_id_len, /* From: */ hsize_t, /* To: */ uint32_t); - bt2_cparam.rrec_size = 4 + /* Name's hash value */ - (uint32_t)fheap_id_len; /* Fractal heap ID */ + bt2_cparam.rrec_size = 4 + /* Name's hash value */ + (uint32_t)fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) + if (NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2_name, &(linfo->name_bt2_addr)) < 0) + if (H5B2_get_addr(bt2_name, &(linfo->name_bt2_addr)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for name index") #ifdef QAK -HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr); + HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr); #endif /* QAK */ /* Check if we should create a creation order index v2 B-tree */ - if(linfo->index_corder) { + if (linfo->index_corder) { /* Create the creation order index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); - bt2_cparam.cls = H5G_BT2_CORDER; + bt2_cparam.cls = H5G_BT2_CORDER; bt2_cparam.node_size = (size_t)H5G_CORDER_BT2_NODE_SIZE; H5_CHECK_OVERFLOW(fheap_id_len, /* From: */ hsize_t, /* To: */ uint32_t); - bt2_cparam.rrec_size = 8 + /* Creation order value */ - (uint32_t)fheap_id_len; /* Fractal heap ID */ + bt2_cparam.rrec_size = 8 + /* Creation order value */ + (uint32_t)fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) + if (NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2_corder, &(linfo->corder_bt2_addr)) < 0) + if (H5B2_get_addr(bt2_corder, &(linfo->corder_bt2_addr)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for creation order index") #ifdef QAK -HDfprintf(stderr, "%s: linfo->corder_bt2_addr = %a\n", FUNC, linfo->corder_bt2_addr); + HDfprintf(stderr, "%s: linfo->corder_bt2_addr = %a\n", FUNC, linfo->corder_bt2_addr); #endif /* QAK */ - } /* end if */ + } /* end if */ done: /* Close the open objects */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_create() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_insert * @@ -376,15 +366,15 @@ done: herr_t H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk) { - H5G_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - size_t link_size; /* Size of serialized link in the heap */ - H5WB_t *wb = NULL; /* Wrapped buffer for link data */ - uint8_t link_buf[H5G_LINK_BUF_SIZE]; /* Buffer for serializing link */ - void *link_ptr = NULL; /* Pointer to serialized link */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + size_t link_size; /* Size of serialized link in the heap */ + H5WB_t * wb = NULL; /* Wrapped buffer for link data */ + uint8_t link_buf[H5G_LINK_BUF_SIZE]; /* Buffer for serializing link */ + void * link_ptr = NULL; /* Pointer to serialized link */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -395,82 +385,82 @@ H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk) HDassert(linfo); HDassert(lnk); #ifdef QAK -HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr); -HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr); + HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr); + HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr); #endif /* QAK */ /* Find out the size of buffer needed for serialized link */ - if((link_size = H5O_msg_raw_size(f, H5O_LINK_ID, FALSE, lnk)) == 0) + if ((link_size = H5O_msg_raw_size(f, H5O_LINK_ID, FALSE, lnk)) == 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get link size") #ifdef QAK -HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDstrlen(lnk->name), link_size); + HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDstrlen(lnk->name), + link_size); #endif /* QAK */ /* Wrap the local buffer for serialized link */ - if(NULL == (wb = H5WB_wrap(link_buf, sizeof(link_buf)))) + if (NULL == (wb = H5WB_wrap(link_buf, sizeof(link_buf)))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for link */ - if(NULL == (link_ptr = H5WB_actual(wb, link_size))) + if (NULL == (link_ptr = H5WB_actual(wb, link_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Create serialized form of link */ - if(H5O_msg_encode(f, H5O_LINK_ID, FALSE, (unsigned char *)link_ptr, lnk) < 0) + if (H5O_msg_encode(f, H5O_LINK_ID, FALSE, (unsigned char *)link_ptr, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode link") /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Insert the serialized link into the fractal heap */ - if(H5HF_insert(fheap, link_size, link_ptr, udata.id) < 0) + if (H5HF_insert(fheap, link_size, link_ptr, udata.id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, linfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ - udata.common.f = f; - udata.common.fheap = fheap; - udata.common.name = lnk->name; - udata.common.name_hash = H5_checksum_lookup3(lnk->name, HDstrlen(lnk->name), 0); - udata.common.corder = lnk->corder; - udata.common.found_op = NULL; + udata.common.f = f; + udata.common.fheap = fheap; + udata.common.name = lnk->name; + udata.common.name_hash = H5_checksum_lookup3(lnk->name, HDstrlen(lnk->name), 0); + udata.common.corder = lnk->corder; + udata.common.found_op = NULL; udata.common.found_op_data = NULL; /* udata.id already set in H5HF_insert() call */ /* Insert link into 'name' tracking v2 B-tree */ - if(H5B2_insert(bt2_name, &udata) < 0) + if (H5B2_insert(bt2_name, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") /* Check if we should create a creation order index v2 B-tree record */ - if(linfo->index_corder) { + if (linfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, linfo->corder_bt2_addr, NULL))) + if (NULL == (bt2_corder = H5B2_open(f, linfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ - if(H5B2_insert(bt2_corder, &udata) < 0) + if (H5B2_insert(bt2_corder, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") } /* end if */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_insert() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_lookup_cb * @@ -487,9 +477,9 @@ done: static herr_t H5G_dense_lookup_cb(const void *_lnk, void *_user_lnk) { - const H5O_link_t *lnk = (const H5O_link_t *)_lnk; /* Record from B-tree */ - H5O_link_t *user_lnk = (H5O_link_t *)_user_lnk; /* User data from v2 B-tree link lookup */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_link_t *lnk = (const H5O_link_t *)_lnk; /* Record from B-tree */ + H5O_link_t * user_lnk = (H5O_link_t *)_user_lnk; /* User data from v2 B-tree link lookup */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -500,14 +490,13 @@ H5G_dense_lookup_cb(const void *_lnk, void *_user_lnk) HDassert(user_lnk); /* Copy link information */ - if(H5O_msg_copy(H5O_LINK_ID, lnk, user_lnk) == NULL) + if (H5O_msg_copy(H5O_LINK_ID, lnk, user_lnk) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_lookup_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_lookup * @@ -522,13 +511,12 @@ done: *------------------------------------------------------------------------- */ htri_t -H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, - H5O_link_t *lnk) +H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, H5O_link_t *lnk) { - H5G_bt2_ud_common_t udata; /* User data for v2 B-tree link lookup */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value = FAIL; /* Return value */ + H5G_bt2_ud_common_t udata; /* User data for v2 B-tree link lookup */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -541,36 +529,35 @@ H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, HDassert(lnk); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, linfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Construct the user data for v2 B-tree callback */ - udata.f = f; - udata.fheap = fheap; - udata.name = name; - udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.found_op = H5G_dense_lookup_cb; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.name = name; + udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.found_op = H5G_dense_lookup_cb; /* v2 B-tree comparison callback */ udata.found_op_data = lnk; /* Find & copy the named link in the 'name' index */ - if((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) + if ((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to locate link in name index") done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_lookup_by_idx_fh_cb * @@ -588,29 +575,29 @@ done: static herr_t H5G_dense_lookup_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5G_fh_ud_lbi_t *udata = (H5G_fh_ud_lbi_t *)_udata; /* User data for fractal heap 'op' callback */ - H5O_link_t *tmp_lnk = NULL; /* Temporary pointer to link */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_fh_ud_lbi_t *udata = (H5G_fh_ud_lbi_t *)_udata; /* User data for fractal heap 'op' callback */ + H5O_link_t * tmp_lnk = NULL; /* Temporary pointer to link */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Decode link information & keep a copy */ - if(NULL == (tmp_lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (tmp_lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Copy link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, tmp_lnk, udata->lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, tmp_lnk, udata->lnk)) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") done: /* Release the space allocated for the link */ - if(tmp_lnk) + if (tmp_lnk) H5O_msg_free(H5O_LINK_ID, tmp_lnk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_lookup_by_idx_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_lookup_by_idx_bt2_cb * @@ -627,27 +614,26 @@ done: static herr_t H5G_dense_lookup_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { - const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; - H5G_bt2_ud_lbi_t *bt2_udata = (H5G_bt2_ud_lbi_t *)_bt2_udata; /* User data for callback */ - H5G_fh_ud_lbi_t fh_udata; /* User data for fractal heap 'op' callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; + H5G_bt2_ud_lbi_t * bt2_udata = (H5G_bt2_ud_lbi_t *)_bt2_udata; /* User data for callback */ + H5G_fh_ud_lbi_t fh_udata; /* User data for fractal heap 'op' callback */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.lnk = bt2_udata->lnk; /* Call fractal heap 'op' routine, to copy the link information */ - if(H5HF_op(bt2_udata->fheap, record->id, H5G_dense_lookup_by_idx_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, record->id, H5G_dense_lookup_by_idx_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, H5_ITER_ERROR, "link found callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_lookup_by_idx_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_lookup_by_idx * @@ -663,14 +649,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) +H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5O_link_t *lnk) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5G_link_table_t ltable = {0, NULL}; /* Table of links */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -682,7 +668,7 @@ H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, HDassert(lnk); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Since names are hashed, getting them in strictly increasing or * decreasing order requires building a table and sorting it. * If the order is native, use the B-tree for names. @@ -704,59 +690,58 @@ H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, * use the B-tree for names instead of building a table to speed up the * process. */ - if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { + if (order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { bt2_addr = linfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ /* If there is an index defined for the field, use it */ - if(H5F_addr_defined(bt2_addr)) { - H5G_bt2_ud_lbi_t udata; /* User data for v2 B-tree link lookup */ + if (H5F_addr_defined(bt2_addr)) { + H5G_bt2_ud_lbi_t udata; /* User data for v2 B-tree link lookup */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree callback */ - udata.f = f; + udata.f = f; udata.fheap = fheap; - udata.lnk = lnk; + udata.lnk = lnk; /* Find & copy the link in the appropriate index */ - if(H5B2_index(bt2, order, n, H5G_dense_lookup_by_idx_bt2_cb, &udata) < 0) + if (H5B2_index(bt2, order, n, H5G_dense_lookup_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to locate link in index") - } /* end if */ - else { /* Otherwise, we need to build a table of the links and sort it */ + } /* end if */ + else { /* Otherwise, we need to build a table of the links and sort it */ /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) + if (H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") /* Check for going out of bounds */ - if(n >= ltable.nlinks) + if (n >= ltable.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Copy link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, <able.lnks[n], lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, <able.lnks[n], lnk)) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_build_table_cb * @@ -775,8 +760,8 @@ done: static herr_t H5G_dense_build_table_cb(const H5O_link_t *lnk, void *_udata) { - H5G_dense_bt_ud_t *udata = (H5G_dense_bt_ud_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5G_dense_bt_ud_t *udata = (H5G_dense_bt_ud_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -786,7 +771,7 @@ H5G_dense_build_table_cb(const H5O_link_t *lnk, void *_udata) HDassert(udata->curr_lnk < udata->ltable->nlinks); /* Copy link information */ - if(H5O_msg_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk])) == NULL) + if (H5O_msg_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk])) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") /* Increment number of links stored */ @@ -796,7 +781,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_build_table_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_build_table * @@ -814,10 +798,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, H5G_link_table_t *ltable) +H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, + H5G_link_table_t *ltable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -831,23 +815,24 @@ H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, ltable->nlinks = (size_t)linfo->nlinks; /* Allocate space for the table entries */ - if(ltable->nlinks > 0) { - H5G_dense_bt_ud_t udata; /* User data for iteration callback */ + if (ltable->nlinks > 0) { + H5G_dense_bt_ud_t udata; /* User data for iteration callback */ /* Allocate the table to store the links */ - if((ltable->lnks = (H5O_link_t *)H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) + if ((ltable->lnks = (H5O_link_t *)H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set up user data for iteration */ - udata.ltable = ltable; + udata.ltable = ltable; udata.curr_lnk = 0; /* Iterate over the links in the group, building a table of the link messages */ - if(H5G__dense_iterate(f, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, H5G_dense_build_table_cb, &udata) < 0) + if (H5G__dense_iterate(f, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, + H5G_dense_build_table_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") /* Sort link table in correct iteration order */ - if(H5G__link_sort_table(ltable, idx_type, order) < 0) + if (H5G__link_sort_table(ltable, idx_type, order) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") } /* end if */ else @@ -857,7 +842,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_build_table() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_iterate_fh_cb * @@ -875,8 +859,8 @@ done: static herr_t H5G_dense_iterate_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5G_fh_ud_it_t *udata = (H5G_fh_ud_it_t *)_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_fh_ud_it_t *udata = (H5G_fh_ud_it_t *)_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -887,14 +871,14 @@ H5G_dense_iterate_fh_cb(const void *obj, size_t obj_len, void *_udata) * HDF5 routine, it could attempt to re-protect that direct block for the * heap, causing the HDF5 routine called to fail - QAK) */ - if(NULL == (udata->lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (udata->lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_iterate_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_iterate_bt2_cb * @@ -911,24 +895,24 @@ done: static herr_t H5G_dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) { - const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; - H5G_bt2_ud_it_t *bt2_udata = (H5G_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; + H5G_bt2_ud_it_t * bt2_udata = (H5G_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check for skipping links */ - if(bt2_udata->skip > 0) + if (bt2_udata->skip > 0) --bt2_udata->skip; else { - H5G_fh_ud_it_t fh_udata; /* User data for fractal heap 'op' callback */ + H5G_fh_ud_it_t fh_udata; /* User data for fractal heap 'op' callback */ /* Prepare user data for callback */ /* down */ fh_udata.f = bt2_udata->f; /* Call fractal heap 'op' routine, to copy the link information */ - if(H5HF_op(bt2_udata->fheap, record->id, H5G_dense_iterate_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, record->id, H5G_dense_iterate_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, H5_ITER_ERROR, "heap op callback failed") /* Make the callback */ @@ -943,14 +927,13 @@ H5G_dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) bt2_udata->count++; /* Check for callback failure and pass along return value */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_iterate_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_iterate * @@ -965,14 +948,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data) +H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, + hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - herr_t ret_value = FAIL; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5G_link_table_t ltable = {0, NULL}; /* Table of links */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -984,7 +967,7 @@ H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, HDassert(op); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Since names are hashed, getting them in strictly increasing or * decreasing order requires building a table and sorting it. If * the order is native, use the B-tree for names. @@ -1006,66 +989,65 @@ H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, * use the B-tree for names instead of building a table to speed up the * process. */ - if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { + if (order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { HDassert(H5F_addr_defined(linfo->name_bt2_addr)); bt2_addr = linfo->name_bt2_addr; } /* end if */ /* Check on iteration order */ - if(order == H5_ITER_NATIVE) { - H5G_bt2_ud_it_t udata; /* User data for iterator callback */ + if (order == H5_ITER_NATIVE) { + H5G_bt2_ud_it_t udata; /* User data for iterator callback */ /* Sanity check */ HDassert(H5F_addr_defined(bt2_addr)); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ - udata.f = f; - udata.fheap = fheap; - udata.skip = skip; - udata.count = 0; - udata.op = op; + udata.f = f; + udata.fheap = fheap; + udata.skip = skip; + udata.count = 0; + udata.op = op; udata.op_data = op_data; /* Iterate over the records in the v2 B-tree's "native" order */ /* (by hash of name) */ - if((ret_value = H5B2_iterate(bt2, H5G_dense_iterate_bt2_cb, &udata)) < 0) + if ((ret_value = H5B2_iterate(bt2, H5G_dense_iterate_bt2_cb, &udata)) < 0) HERROR(H5E_SYM, H5E_BADITER, "link iteration failed"); /* Update the last link examined, if requested */ - if(last_lnk) + if (last_lnk) *last_lnk = udata.count; } /* end if */ else { /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) + if (H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") /* Iterate over links in table */ - if((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_get_name_by_idx_fh_cb * @@ -1083,23 +1065,24 @@ done: static herr_t H5G_dense_get_name_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5G_fh_ud_gnbi_t *udata = (H5G_fh_ud_gnbi_t *)_udata; /* User data for fractal heap 'op' callback */ - H5O_link_t *lnk; /* Pointer to link created from heap object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_fh_ud_gnbi_t *udata = (H5G_fh_ud_gnbi_t *)_udata; /* User data for fractal heap 'op' callback */ + H5O_link_t * lnk; /* Pointer to link created from heap object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Decode link information */ - if(NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Get the length of the name */ udata->name_len = (ssize_t)HDstrlen(lnk->name); /* Copy the name into the user's buffer, if given */ - if(udata->name) { + if (udata->name) { HDstrncpy(udata->name, lnk->name, MIN((size_t)(udata->name_len + 1), udata->name_size)); - if((size_t)udata->name_len >= udata->name_size) + if ((size_t)udata->name_len >= udata->name_size) udata->name[udata->name_size - 1] = '\0'; } /* end if */ @@ -1110,7 +1093,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_get_name_by_idx_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_get_name_by_idx_bt2_cb * @@ -1127,21 +1109,21 @@ done: static herr_t H5G_dense_get_name_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { - const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; - H5G_bt2_ud_gnbi_t *bt2_udata = (H5G_bt2_ud_gnbi_t *)_bt2_udata; /* User data for callback */ - H5G_fh_ud_gnbi_t fh_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; + H5G_bt2_ud_gnbi_t * bt2_udata = (H5G_bt2_ud_gnbi_t *)_bt2_udata; /* User data for callback */ + H5G_fh_ud_gnbi_t fh_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; - fh_udata.name = bt2_udata->name; + fh_udata.f = bt2_udata->f; + fh_udata.name = bt2_udata->name; fh_udata.name_size = bt2_udata->name_size; /* Call fractal heap 'op' routine, to perform user callback */ - if(H5HF_op(bt2_udata->fheap, record->id, H5G_dense_get_name_by_idx_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, record->id, H5G_dense_get_name_by_idx_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link found callback failed") /* Set the name's full length to return */ @@ -1151,7 +1133,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_get_name_by_idx_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_get_name_by_idx * @@ -1167,14 +1148,14 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char *name, size_t size) +H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, char *name, size_t size) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - ssize_t ret_value = -1; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5G_link_table_t ltable = {0, NULL}; /* Table of links */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -1185,7 +1166,7 @@ H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, HDassert(linfo); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Since names are hashed, getting them in strictly increasing or * decreasing order requires building a table and sorting it. If * the order is native, use the B-tree for names. @@ -1207,69 +1188,68 @@ H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, * use the B-tree for names instead of building a table to speed up the * process. */ - if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { + if (order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { bt2_addr = linfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ /* If there is an index defined for the field, use it */ - if(H5F_addr_defined(bt2_addr)) { - H5G_bt2_ud_gnbi_t udata; /* User data for v2 B-tree callback */ + if (H5F_addr_defined(bt2_addr)) { + H5G_bt2_ud_gnbi_t udata; /* User data for v2 B-tree callback */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.f = f; - udata.fheap = fheap; - udata.name = name; + udata.f = f; + udata.fheap = fheap; + udata.name = name; udata.name_size = size; /* Retrieve the name according to the v2 B-tree's index order */ - if(H5B2_index(bt2, order, n, H5G_dense_get_name_by_idx_bt2_cb, &udata) < 0) + if (H5B2_index(bt2, order, n, H5G_dense_get_name_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLIST, FAIL, "can't locate object in v2 B-tree") /* Set return value */ ret_value = udata.name_len; - } /* end if */ - else { /* Otherwise, we need to build a table of the links and sort it */ + } /* end if */ + else { /* Otherwise, we need to build a table of the links and sort it */ /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) + if (H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") /* Check for going out of bounds */ - if(n >= ltable.nlinks) + if (n >= ltable.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Get the length of the name */ ret_value = (ssize_t)HDstrlen(ltable.lnks[n].name); /* Copy the name into the user's buffer, if given */ - if(name) { + if (name) { HDstrncpy(name, ltable.lnks[n].name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; + if ((size_t)ret_value >= size) + name[size - 1] = '\0'; } /* end if */ - } /* end else */ + } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_get_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_remove_fh_cb * @@ -1286,23 +1266,24 @@ done: static herr_t H5G_dense_remove_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5G_fh_ud_rm_t *udata = (H5G_fh_ud_rm_t *)_udata; /* User data for fractal heap 'op' callback */ - H5O_link_t *lnk = NULL; /* Pointer to link created from heap object */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_fh_ud_rm_t *udata = (H5G_fh_ud_rm_t *)_udata; /* User data for fractal heap 'op' callback */ + H5O_link_t * lnk = NULL; /* Pointer to link created from heap object */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Decode link information */ - if(NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Check for removing the link from the creation order index */ - if(H5F_addr_defined(udata->corder_bt2_addr)) { - H5G_bt2_ud_common_t bt2_udata; /* Info for B-tree callbacks */ + if (H5F_addr_defined(udata->corder_bt2_addr)) { + H5G_bt2_ud_common_t bt2_udata; /* Info for B-tree callbacks */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(udata->f, udata->corder_bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(udata->f, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1310,31 +1291,31 @@ H5G_dense_remove_fh_cb(const void *obj, size_t obj_len, void *_udata) bt2_udata.corder = lnk->corder; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove(bt2, &bt2_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from creation order index v2 B-tree") + if (H5B2_remove(bt2, &bt2_udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, + "unable to remove link from creation order index v2 B-tree") } /* end if */ /* Replace open objects' names, if requested */ - if(udata->replace_names) - if(H5G__link_name_replace(udata->f, udata->grp_full_path_r, lnk) < 0) + if (udata->replace_names) + if (H5G__link_name_replace(udata->f, udata->grp_full_path_r, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRENAME, FAIL, "unable to rename open objects") /* Perform the deletion action on the link, if requested */ /* (call message "delete" callback directly: *ick* - QAK) */ - if(H5O_link_delete(udata->f, NULL, lnk) < 0) + if (H5O_link_delete(udata->f, NULL, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(lnk) + if (lnk) H5O_msg_free(H5O_LINK_ID, lnk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_remove_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_remove_bt2_cb * @@ -1351,33 +1332,32 @@ done: static herr_t H5G_dense_remove_bt2_cb(const void *_record, void *_bt2_udata) { - const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; - H5G_bt2_ud_rm_t *bt2_udata = (H5G_bt2_ud_rm_t *)_bt2_udata; /* User data for callback */ - H5G_fh_ud_rm_t fh_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; + H5G_bt2_ud_rm_t * bt2_udata = (H5G_bt2_ud_rm_t *)_bt2_udata; /* User data for callback */ + H5G_fh_ud_rm_t fh_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Set up the user data for fractal heap 'op' callback */ - fh_udata.f = bt2_udata->common.f; + fh_udata.f = bt2_udata->common.f; fh_udata.corder_bt2_addr = bt2_udata->corder_bt2_addr; fh_udata.grp_full_path_r = bt2_udata->grp_full_path_r; - fh_udata.replace_names = bt2_udata->replace_names; + fh_udata.replace_names = bt2_udata->replace_names; /* Call fractal heap 'op' routine, to perform user callback */ - if(H5HF_op(bt2_udata->common.fheap, record->id, H5G_dense_remove_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->common.fheap, record->id, H5G_dense_remove_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link removal callback failed") /* Remove record from fractal heap, if requested */ - if(bt2_udata->rem_from_fheap) - if(H5HF_remove(bt2_udata->common.fheap, record->id) < 0) + if (bt2_udata->rem_from_fheap) + if (H5HF_remove(bt2_udata->common.fheap, record->id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from fractal heap") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_remove_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_remove * @@ -1392,13 +1372,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, - const char *name) +H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, const char *name) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1410,40 +1389,39 @@ H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_ HDassert(name && *name); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, linfo->name_bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.common.f = f; - udata.common.fheap = fheap; - udata.common.name = name; - udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.common.found_op = NULL; + udata.common.f = f; + udata.common.fheap = fheap; + udata.common.name = name; + udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.common.found_op = NULL; udata.common.found_op_data = NULL; - udata.rem_from_fheap = TRUE; - udata.corder_bt2_addr = linfo->corder_bt2_addr; - udata.grp_full_path_r = grp_full_path_r; - udata.replace_names = TRUE; + udata.rem_from_fheap = TRUE; + udata.corder_bt2_addr = linfo->corder_bt2_addr; + udata.grp_full_path_r = grp_full_path_r; + udata.replace_names = TRUE; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove(bt2, &udata, H5G_dense_remove_bt2_cb, &udata) < 0) + if (H5B2_remove(bt2, &udata, H5G_dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from name index v2 B-tree") done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_remove_by_idx_fh_cb * @@ -1460,13 +1438,14 @@ done: static herr_t H5G_dense_remove_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5G_fh_ud_rmbi_t *udata = (H5G_fh_ud_rmbi_t *)_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_fh_ud_rmbi_t *udata = (H5G_fh_ud_rmbi_t *)_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Decode link information */ - if(NULL == (udata->lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (udata->lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, H5_ITER_ERROR, "can't decode link") /* Can't operate on link here because the fractal heap block is locked */ @@ -1475,7 +1454,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_remove_by_idx_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_dense_remove_by_idx_bt2_cb * @@ -1492,16 +1470,16 @@ done: static herr_t H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { - H5G_bt2_ud_rmbi_t *bt2_udata = (H5G_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */ - H5G_fh_ud_rmbi_t fh_udata; /* User data for fractal heap 'op' callback */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - const uint8_t *heap_id; /* Heap ID for link */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_bt2_ud_rmbi_t *bt2_udata = (H5G_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */ + H5G_fh_ud_rmbi_t fh_udata; /* User data for fractal heap 'op' callback */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + const uint8_t * heap_id; /* Heap ID for link */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Determine the index being used */ - if(bt2_udata->idx_type == H5_INDEX_NAME) { + if (bt2_udata->idx_type == H5_INDEX_NAME) { const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; /* Set the heap ID to operate on */ @@ -1517,20 +1495,20 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Set up the user data for fractal heap 'op' callback */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.lnk = NULL; /* Call fractal heap 'op' routine, to perform user callback */ - if(H5HF_op(bt2_udata->fheap, heap_id, H5G_dense_remove_by_idx_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, heap_id, H5G_dense_remove_by_idx_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link removal callback failed") HDassert(fh_udata.lnk); /* Check for removing the link from the "other" index (creation order, when name used and vice versa) */ - if(H5F_addr_defined(bt2_udata->other_bt2_addr)) { - H5G_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ + if (H5F_addr_defined(bt2_udata->other_bt2_addr)) { + H5G_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ /* Determine the index being used */ - if(bt2_udata->idx_type == H5_INDEX_NAME) { + if (bt2_udata->idx_type == H5_INDEX_NAME) { /* Set up the user data for the v2 B-tree 'record remove' callback */ other_bt2_udata.corder = fh_udata.lnk->corder; } /* end if */ @@ -1538,50 +1516,51 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) HDassert(bt2_udata->idx_type == H5_INDEX_CRT_ORDER); /* Set up the user data for the v2 B-tree 'record remove' callback */ - other_bt2_udata.f = bt2_udata->f; + other_bt2_udata.f = bt2_udata->f; other_bt2_udata.fheap = bt2_udata->fheap; - other_bt2_udata.name = fh_udata.lnk->name; - other_bt2_udata.name_hash = H5_checksum_lookup3(fh_udata.lnk->name, HDstrlen(fh_udata.lnk->name), 0); - other_bt2_udata.found_op = NULL; + other_bt2_udata.name = fh_udata.lnk->name; + other_bt2_udata.name_hash = + H5_checksum_lookup3(fh_udata.lnk->name, HDstrlen(fh_udata.lnk->name), 0); + other_bt2_udata.found_op = NULL; other_bt2_udata.found_op_data = NULL; } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for 'other' index") /* Set the common information for the v2 B-tree remove operation */ /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove link from 'other' index v2 B-tree") + if (H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, + "unable to remove link from 'other' index v2 B-tree") } /* end if */ /* Replace open objects' names */ - if(H5G__link_name_replace(bt2_udata->f, bt2_udata->grp_full_path_r, fh_udata.lnk) < 0) + if (H5G__link_name_replace(bt2_udata->f, bt2_udata->grp_full_path_r, fh_udata.lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRENAME, FAIL, "unable to rename open objects") /* Perform the deletion action on the link */ /* (call link message "delete" callback directly: *ick* - QAK) */ - if(H5O_link_delete(bt2_udata->f, NULL, fh_udata.lnk) < 0) + if (H5O_link_delete(bt2_udata->f, NULL, fh_udata.lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") /* Release the space allocated for the link */ H5O_msg_free(H5O_LINK_ID, fh_udata.lnk); /* Remove record from fractal heap */ - if(H5HF_remove(bt2_udata->fheap, heap_id) < 0) + if (H5HF_remove(bt2_udata->fheap, heap_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from fractal heap") done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for 'other' index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_remove_by_idx_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_remove_by_idx * @@ -1597,14 +1576,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n) +H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5G_link_table_t ltable = {0, NULL}; /* Table of links */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1615,7 +1594,7 @@ H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_ful HDassert(linfo); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Since names are hashed, getting them in strictly increasing or * decreasing order requires building a table and sorting it. If * the order is native, use the B-tree for names. @@ -1637,61 +1616,60 @@ H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_ful * use the B-tree for names instead of building a table to speed up the * process. */ - if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { + if (order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { bt2_addr = linfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ /* If there is an index defined for the field, use it */ - if(H5F_addr_defined(bt2_addr)) { - H5G_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */ + if (H5F_addr_defined(bt2_addr)) { + H5G_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'remove by index' callback */ - udata.f = f; - udata.fheap = fheap; - udata.idx_type = idx_type; - udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? linfo->corder_bt2_addr : linfo->name_bt2_addr; + udata.f = f; + udata.fheap = fheap; + udata.idx_type = idx_type; + udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? linfo->corder_bt2_addr : linfo->name_bt2_addr; udata.grp_full_path_r = grp_full_path_r; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove_by_idx(bt2, order, n, H5G_dense_remove_by_idx_bt2_cb, &udata) < 0) + if (H5B2_remove_by_idx(bt2, order, n, H5G_dense_remove_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from indexed v2 B-tree") - } /* end if */ - else { /* Otherwise, we need to build a table of the links and sort it */ + } /* end if */ + else { /* Otherwise, we need to build a table of the links and sort it */ /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) + if (H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") /* Check for going out of bounds */ - if(n >= ltable.nlinks) + if (n >= ltable.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Remove the appropriate link from the dense storage */ - if(H5G__dense_remove(f, linfo, grp_full_path_r, ltable.lnks[n].name) < 0) + if (H5G__dense_remove(f, linfo, grp_full_path_r, ltable.lnks[n].name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from dense storage") } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_delete * @@ -1708,7 +1686,7 @@ done: herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1721,47 +1699,47 @@ H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link) /* Check if we are to adjust the ref. count for all the links */ /* (we adjust the ref. count when deleting a group and we _don't_ adjust * the ref. count when transitioning back to compact storage) - */ - if(adj_link) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ + */ + if (adj_link) { + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.common.f = f; - udata.common.fheap = fheap; - udata.common.name = NULL; - udata.common.name_hash = 0; - udata.common.found_op = NULL; + udata.common.f = f; + udata.common.fheap = fheap; + udata.common.name = NULL; + udata.common.name_hash = 0; + udata.common.found_op = NULL; udata.common.found_op_data = NULL; - udata.rem_from_fheap = FALSE; /* handled in "bulk" below by deleting entire heap */ - udata.corder_bt2_addr = linfo->corder_bt2_addr; - udata.grp_full_path_r = NULL; - udata.replace_names = FALSE; + udata.rem_from_fheap = FALSE; /* handled in "bulk" below by deleting entire heap */ + udata.corder_bt2_addr = linfo->corder_bt2_addr; + udata.grp_full_path_r = NULL; + udata.replace_names = FALSE; /* Delete the name index, adjusting the ref. count on links removed */ - if(H5B2_delete(f, linfo->name_bt2_addr, NULL, H5G_dense_remove_bt2_cb, &udata) < 0) + if (H5B2_delete(f, linfo->name_bt2_addr, NULL, H5G_dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") /* Close the fractal heap */ - if(H5HF_close(fheap) < 0) + if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") } /* end if */ else { /* Delete the name index, without adjusting the ref. count on the links */ - if(H5B2_delete(f, linfo->name_bt2_addr, NULL, NULL, NULL) < 0) + if (H5B2_delete(f, linfo->name_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") } /* end else */ linfo->name_bt2_addr = HADDR_UNDEF; /* Check if we should delete the creation order index v2 B-tree */ - if(linfo->index_corder) { + if (linfo->index_corder) { /* Delete the creation order index, without adjusting the ref. count on the links */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(H5B2_delete(f, linfo->corder_bt2_addr, NULL, NULL, NULL) < 0) + if (H5B2_delete(f, linfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") linfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ @@ -1769,11 +1747,10 @@ H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link) HDassert(!H5F_addr_defined(linfo->corder_bt2_addr)); /* Delete the fractal heap */ - if(H5HF_delete(f, linfo->fheap_addr) < 0) + if (H5HF_delete(f, linfo->fheap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") linfo->fheap_addr = HADDR_UNDEF; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_delete() */ - diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 126456b..b5bfbf6 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -29,30 +29,27 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -60,43 +57,37 @@ #ifndef H5_NO_DEPRECATED_SYMBOLS /* User data for path traversal routine for getting object info */ typedef struct { - H5G_stat_t *statbuf; /* Stat buffer about object */ - hbool_t follow_link; /* Whether we are following a link or not */ - H5F_t *loc_file; /* Pointer to the file the location is in */ + H5G_stat_t *statbuf; /* Stat buffer about object */ + hbool_t follow_link; /* Whether we are following a link or not */ + H5F_t * loc_file; /* Pointer to the file the location is in */ } H5G_trav_goi_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5G__get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); +static herr_t H5G__get_objinfo_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5G_map_obj_type * @@ -112,13 +103,13 @@ static herr_t H5G__get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name, H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type) { - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Map object type to older "group" object type */ - switch(obj_type) { + switch (obj_type) { case H5O_TYPE_GROUP: ret_value = H5G_GROUP; break; @@ -143,7 +134,6 @@ H5G_map_obj_type(H5O_type_t obj_type) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_map_obj_type() */ - /*------------------------------------------------------------------------- * Function: H5Gcreate1 * @@ -172,82 +162,82 @@ H5G_map_obj_type(H5O_type_t obj_type) hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { - void *grp = NULL; /* New group created */ - H5VL_object_t *vol_obj; /* Object of loc_id */ + void * grp = NULL; /* New group created */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - hid_t tmp_gcpl = H5I_INVALID_HID; /* Temporary group creation property list */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t tmp_gcpl = H5I_INVALID_HID; /* Temporary group creation property list */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*sz", loc_id, name, size_hint); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name given") /* Check if we need to create a non-standard GCPL */ - if(size_hint > 0) { - H5O_ginfo_t ginfo; /* Group info property */ - H5P_genplist_t *gc_plist; /* Property list created */ + if (size_hint > 0) { + H5O_ginfo_t ginfo; /* Group info property */ + H5P_genplist_t *gc_plist; /* Property list created */ /* Get the default property list */ - if(NULL == (gc_plist = (H5P_genplist_t *)H5I_object(H5P_GROUP_CREATE_DEFAULT))) + if (NULL == (gc_plist = (H5P_genplist_t *)H5I_object(H5P_GROUP_CREATE_DEFAULT))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Make a copy of the default property list */ - if((tmp_gcpl = H5P_copy_plist(gc_plist, FALSE)) < 0) + if ((tmp_gcpl = H5P_copy_plist(gc_plist, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") /* Get pointer to the copied property list */ - if(NULL == (gc_plist = (H5P_genplist_t *)H5I_object(tmp_gcpl))) + if (NULL == (gc_plist = (H5P_genplist_t *)H5I_object(tmp_gcpl))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Get the group info property */ - if(H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get group info") /* Set the non-default local heap size hint */ H5_CHECKED_ASSIGN(ginfo.lheap_size_hint, uint32_t, size_hint, size_t); - if(H5P_set(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set group info") } else tmp_gcpl = H5P_GROUP_CREATE_DEFAULT; /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read info") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the group */ - if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, H5P_LINK_CREATE_DEFAULT, tmp_gcpl, - H5P_GROUP_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == + (grp = H5VL_group_create(vol_obj, &loc_params, name, H5P_LINK_CREATE_DEFAULT, tmp_gcpl, + H5P_GROUP_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: - if(H5I_INVALID_HID != tmp_gcpl && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) - if(H5I_dec_ref(tmp_gcpl) < 0) + if (H5I_INVALID_HID != tmp_gcpl && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) + if (H5I_dec_ref(tmp_gcpl) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release property list") - if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate1() */ - /*------------------------------------------------------------------------- * Function: H5Gopen1 * @@ -268,44 +258,43 @@ done: hid_t H5Gopen1(hid_t loc_id, const char *name) { - void *grp = NULL; /* Group opened */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + void * grp = NULL; /* Group opened */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the group */ - if(NULL == (grp = H5VL_group_open(vol_obj, &loc_params, name, H5P_GROUP_ACCESS_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (grp = H5VL_group_open(vol_obj, &loc_params, name, H5P_GROUP_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") /* Get an atom for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: - if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gopen1() */ - /*------------------------------------------------------------------------- * Function: H5Glink * @@ -317,66 +306,68 @@ done: herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new_name) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iLl*s*s", cur_loc_id, type, cur_name, new_name); /* Check arguments */ - if(!cur_name || !*cur_name) + if (!cur_name || !*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!new_name || !*new_name) + if (!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(cur_loc_id) < 0) + if (H5CX_set_loc(cur_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Create link */ - if(type == H5L_TYPE_HARD) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + if (type == H5L_TYPE_HARD) { + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; - H5VL_object_t tmp_vol_obj; /* Temporary object */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.obj_type = H5I_get_type(cur_loc_id); - loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = new_name; loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Construct a temporary VOL object */ - tmp_vol_obj.data = NULL; + tmp_vol_obj.data = NULL; tmp_vol_obj.connector = vol_obj->connector; /* Create the link through the VOL */ - if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj->data, &loc_params1) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + vol_obj->data, &loc_params1) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ - else if(type == H5L_TYPE_SOFT) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + else if (type == H5L_TYPE_SOFT) { + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = new_name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = new_name; loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = H5I_get_type(cur_loc_id); + loc_params.obj_type = H5I_get_type(cur_loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Create the link through the VOL */ - if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, cur_name) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + cur_name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end else-if */ else @@ -386,7 +377,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Glink() */ - /*------------------------------------------------------------------------- * Function: H5Glink2 * @@ -396,73 +386,74 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name) +H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_id, const char *new_name) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sLli*s", cur_loc_id, cur_name, type, new_loc_id, new_name); /* Check arguments */ - if(!cur_name || !*cur_name) + if (!cur_name || !*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!new_name || !*new_name) + if (!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(cur_loc_id) < 0) + if (H5CX_set_loc(cur_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Create the appropriate kind of link */ - if(type == H5L_TYPE_HARD) { - H5VL_object_t *vol_obj1; /* Object of loc_id */ - H5VL_object_t *vol_obj2; /* Object of loc_id */ + if (type == H5L_TYPE_HARD) { + H5VL_object_t * vol_obj1; /* Object of loc_id */ + H5VL_object_t * vol_obj2; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.obj_type = H5I_get_type(cur_loc_id); - loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.obj_type = H5I_get_type(new_loc_id); - loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; /* get the location object */ - if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(cur_loc_id))) + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(new_loc_id))) + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Create the link through the VOL */ - if(H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2, &loc_params2, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj1->data, &loc_params1) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2, &loc_params2, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + vol_obj1->data, &loc_params1) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ - else if(type == H5L_TYPE_SOFT) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + else if (type == H5L_TYPE_SOFT) { + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Soft links only need one location, the new_loc_id, but it's possible that * new_loc_id is H5L_SAME_LOC */ - if(new_loc_id == H5L_SAME_LOC) + if (new_loc_id == H5L_SAME_LOC) new_loc_id = cur_loc_id; - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = new_name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = new_name; loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = H5I_get_type(new_loc_id); + loc_params.obj_type = H5I_get_type(new_loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(new_loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Create the link through the VOL */ - if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, cur_name) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + cur_name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end else-if */ else @@ -472,7 +463,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Glink2() */ - /*------------------------------------------------------------------------- * Function: H5Gmove * @@ -483,41 +473,40 @@ done: herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", src_loc_id, src_name, dst_name); /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(src_loc_id) < 0) + if (H5CX_set_loc(src_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.obj_type = H5I_get_type(src_loc_id); - loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(src_loc_id); + loc_params1.loc_data.loc_by_name.name = src_name; loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(src_loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Move the link */ - if(H5VL_link_move(vol_obj, &loc_params1, NULL, &loc_params2, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_link_move(vol_obj, &loc_params1, NULL, &loc_params2, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "couldn't move link") done: FUNC_LEAVE_API(ret_value) } /* end H5Gmove() */ - /*------------------------------------------------------------------------- * Function: H5Gmove2 * @@ -526,53 +515,51 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name) +H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { - H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ + H5VL_object_t * vol_obj1 = NULL; /* Object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ + H5VL_object_t * vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params2; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*si*s", src_loc_id, src_name, dst_loc_id, dst_name); /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dst_loc_id) < 0) + if (H5CX_set_loc(dst_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Set location parameter for source object */ - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params1.obj_type = H5I_get_type(src_loc_id); + loc_params1.obj_type = H5I_get_type(src_loc_id); /* Set location parameter for destination object */ - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params2.obj_type = H5I_get_type(dst_loc_id); + loc_params2.obj_type = H5I_get_type(dst_loc_id); - if(H5L_SAME_LOC != src_loc_id) + if (H5L_SAME_LOC != src_loc_id) /* get the location object */ - if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(H5L_SAME_LOC != dst_loc_id) + if (H5L_SAME_LOC != dst_loc_id) /* get the location object */ - if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Move the link */ - if(H5VL_link_move(vol_obj1, &loc_params1, vol_obj2, &loc_params2, H5P_LINK_CREATE_DEFAULT, - H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_link_move(vol_obj1, &loc_params1, vol_obj2, &loc_params2, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "unable to move link") done: FUNC_LEAVE_API(ret_value) } /* end H5Gmove2() */ - /*------------------------------------------------------------------------- * Function: H5Gunlink * @@ -583,39 +570,39 @@ done: herr_t H5Gunlink(hid_t loc_id, const char *name) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.obj_type = H5I_get_type(loc_id); - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Delete the link */ - if(H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "couldn't delete link") done: FUNC_LEAVE_API(ret_value) } /* end H5Gunlink() */ - /*------------------------------------------------------------------------- * Function: H5Gget_linkval * @@ -625,41 +612,41 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) +H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*szx", loc_id, name, size, buf); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.obj_type = H5I_get_type(loc_id); - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link value */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, + size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_linkval() */ - /*------------------------------------------------------------------------- * Function: H5Gset_comment * @@ -680,18 +667,18 @@ done: herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", loc_id, name, comment); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Fill in location struct fields */ @@ -701,18 +688,18 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment) loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set the comment */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, comment) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "unable to set comment value") done: FUNC_LEAVE_API(ret_value) } /* end H5Gset_comment() */ - /*------------------------------------------------------------------------- * Function: H5Gget_comment * @@ -739,21 +726,21 @@ done: int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - ssize_t op_ret; /* Return value from operation */ - int ret_value; /* Return value */ + ssize_t op_ret; /* Return value from operation */ + int ret_value; /* Return value */ FUNC_ENTER_API(-1) H5TRACE4("Is", "i*sz*s", loc_id, name, bufsize, buf); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no name specified") - if(bufsize > 0 && !buf) + if (bufsize > 0 && !buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no buffer specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, -1, "can't set collective metadata read info") /* Fill in location struct fields */ @@ -763,11 +750,12 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "invalid location identifier") /* Get the comment */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, buf, bufsize, &op_ret) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, buf, bufsize, &op_ret) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, -1, "unable to get comment value") /* Set return value */ @@ -777,7 +765,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_comment() */ - /*------------------------------------------------------------------------- * Function: H5Giterate * @@ -803,33 +790,32 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, - void *op_data) +H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *op_data) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_obj; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_obj; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*Isx*x", loc_id, name, idx_p, op, op_data); /* Check args */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_p && *idx_p < 0) + if (idx_p && *idx_p < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") /* Set number of objects looked at to zero */ last_obj = 0; - idx = (hsize_t)(idx_p == NULL ? 0 : *idx_p); + idx = (hsize_t)(idx_p == NULL ? 0 : *idx_p); /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_OLD; + lnk_op.op_type = H5G_LINK_OP_OLD; lnk_op.op_func.op_old = op; /* Fill out location struct */ @@ -839,22 +825,22 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, loc_params.obj_type = H5I_get_type(loc_id); /* Get the object pointer */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") /* Call private iteration function, through VOL callback */ - if((ret_value = H5VL_group_optional(vol_obj, H5VL_NATIVE_GROUP_ITERATE_OLD, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, idx, &last_obj, &lnk_op, op_data)) < 0) + if ((ret_value = H5VL_group_optional(vol_obj, H5VL_NATIVE_GROUP_ITERATE_OLD, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, idx, &last_obj, &lnk_op, op_data)) < 0) HERROR(H5E_SYM, H5E_BADITER, "error iterating over group's links"); /* Set the index we stopped at */ - if(idx_p) + if (idx_p) *idx_p = (int)last_obj; done: FUNC_LEAVE_API(ret_value) } /* end H5Giterate() */ - /*------------------------------------------------------------------------- * Function: H5Gget_num_objs * @@ -874,20 +860,20 @@ done: herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5I_type_t id_type; /* Type of ID */ - H5VL_loc_params_t loc_params; - H5G_info_t grp_info; /* Group information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5I_type_t id_type; /* Type of ID */ + H5VL_loc_params_t loc_params; + H5G_info_t grp_info; /* Group information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", loc_id, num_objs); /* Check args */ id_type = H5I_get_type(loc_id); - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group (or file) ID") - if(!num_objs) + if (!num_objs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") /* Fill in location struct fields */ @@ -895,11 +881,12 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) loc_params.obj_type = id_type; /* Get group location */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the group's information */ - if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, &grp_info) < 0) + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + &grp_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") /* Set the number of objects [i.e. links] in the group */ @@ -909,7 +896,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_num_objs() */ - /*------------------------------------------------------------------------- * Function: H5Gget_objinfo * @@ -928,22 +914,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, - H5G_stat_t *statbuf/*out*/) +H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf /*out*/) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE4("e", "i*sbx", loc_id, name, follow_link, statbuf); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info"); /* Retrieve object info */ @@ -954,18 +939,18 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); /* Retrieve the object's information */ - if(H5VL_group_optional(vol_obj, H5VL_NATIVE_GROUP_GET_OBJINFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, (unsigned)follow_link, statbuf) < 0) + if (H5VL_group_optional(vol_obj, H5VL_NATIVE_GROUP_GET_OBJINFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &loc_params, (unsigned)follow_link, statbuf) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name); done: FUNC_LEAVE_API(ret_value); } /* end H5Gget_objinfo() */ - /*------------------------------------------------------------------------- * Function: H5G__get_objinfo_cb * @@ -980,48 +965,49 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5G_trav_goi_t *udata = (H5G_trav_goi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_trav_goi_t *udata = (H5G_trav_goi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC; /* Check if the name in this group resolved to a valid link */ - if(lnk == NULL && obj_loc == NULL) + if (lnk == NULL && obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name); /* Only modify user's buffer if it's available */ - if(udata->statbuf) { - H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ + if (udata->statbuf) { + H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ /* Common code to retrieve the file's fileno */ - if(H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) + if (H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno"); /* Info for soft and UD links is gotten by H5L_get_info. If we have * a hard link, follow it and get info on the object */ - if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { - H5O_info2_t dm_info; /* Data model information */ - H5O_native_info_t nat_info; /* Native information */ - haddr_t obj_addr; /* Address of object */ + if (udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { + H5O_info2_t dm_info; /* Data model information */ + H5O_native_info_t nat_info; /* Native information */ + haddr_t obj_addr; /* Address of object */ /* Go retrieve the data model & native object information */ /* (don't need index & heap info) */ HDassert(obj_loc); - if(H5O_get_info(obj_loc->oloc, &dm_info, H5O_INFO_BASIC | H5O_INFO_TIME) < 0) + if (H5O_get_info(obj_loc->oloc, &dm_info, H5O_INFO_BASIC | H5O_INFO_TIME) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get data model object info") - if(H5O_get_native_info(obj_loc->oloc, &nat_info, H5O_INFO_HDR) < 0) + if (H5O_get_native_info(obj_loc->oloc, &nat_info, H5O_INFO_HDR) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get native object info") /* Get mapped object type */ statbuf->type = H5G_map_obj_type(dm_info.type); /* Get object number (i.e. address) for object */ - if(H5VL_native_token_to_addr(obj_loc->oloc->file, H5I_FILE, dm_info.token, &obj_addr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + if (H5VL_native_token_to_addr(obj_loc->oloc->file, H5I_FILE, dm_info.token, &obj_addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") statbuf->objno[0] = (unsigned long)(obj_addr); #if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG @@ -1036,12 +1022,12 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c statbuf->mtime = dm_info.ctime; /* Retrieve the object header information */ - statbuf->ohdr.size = nat_info.hdr.space.total; - statbuf->ohdr.free = nat_info.hdr.space.free; - statbuf->ohdr.nmesgs = nat_info.hdr.nmesgs; + statbuf->ohdr.size = nat_info.hdr.space.total; + statbuf->ohdr.free = nat_info.hdr.space.free; + statbuf->ohdr.nmesgs = nat_info.hdr.nmesgs; statbuf->ohdr.nchunks = nat_info.hdr.nchunks; } /* end if */ - } /* end if */ + } /* end if */ done: /* Indicate that this callback didn't take ownership of the group * @@ -1051,7 +1037,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5G__get_objinfo_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__get_objinfo * @@ -1069,11 +1054,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, - H5G_stat_t *statbuf/*out*/) +H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5G_stat_t *statbuf /*out*/) { - H5G_trav_goi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_trav_goi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE; @@ -1086,24 +1070,28 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, HDmemset(statbuf, 0, sizeof(H5G_stat_t)); /* Set up user data for retrieving information */ - udata.statbuf = statbuf; + udata.statbuf = statbuf; udata.follow_link = follow_link; - udata.loc_file = loc->oloc->file; + udata.loc_file = loc->oloc->file; /* Traverse the group hierarchy to locate the object to get info about */ - if (H5G_traverse(loc, name, (unsigned)(follow_link ? H5G_TARGET_NORMAL : (H5G_TARGET_SLINK | H5G_TARGET_UDLINK)), H5G__get_objinfo_cb, &udata) < 0) + if (H5G_traverse(loc, name, + (unsigned)(follow_link ? H5G_TARGET_NORMAL : (H5G_TARGET_SLINK | H5G_TARGET_UDLINK)), + H5G__get_objinfo_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist"); /* If we're pointing at a soft or UD link, get the real link length and type */ if (statbuf && follow_link == 0) { - H5L_info2_t linfo; /* Link information buffer */ - herr_t ret; + H5L_info2_t linfo; /* Link information buffer */ + herr_t ret; /* Get information about link to the object. If this fails, e.g. * because the object is ".", just treat the object as a hard link. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5L_get_info(loc, name, &linfo); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret >= 0 && linfo.type != H5L_TYPE_HARD) { statbuf->linklen = linfo.u.val_size; @@ -1122,7 +1110,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5G__get_objinfo() */ - /*------------------------------------------------------------------------- * Function: H5Gget_objname_by_idx * @@ -1149,15 +1136,15 @@ done: ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - ssize_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "ih*sz", loc_id, idx, name, size); /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set collective metadata read info") /* Fill in location struct fields */ @@ -1170,18 +1157,18 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Call internal function */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name, size, &ret_value) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + name, size, &ret_value) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get object name") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_objname_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Gget_objtype_by_idx * @@ -1200,37 +1187,37 @@ done: H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - H5O_info2_t oinfo; /* Object info (contains object type) */ - H5G_obj_t ret_value; /* Return value */ + H5O_info2_t oinfo; /* Object info (contains object type) */ + H5G_obj_t ret_value; /* Return value */ FUNC_ENTER_API(H5G_UNKNOWN) H5TRACE2("Go", "ih", loc_id, idx); /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = "."; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_NAME; - loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; - loc_params.loc_data.loc_by_idx.n = idx; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = idx; loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") /* Retrieve the object's basic information (which includes its type) */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &oinfo, H5O_INFO_BASIC) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &oinfo, H5O_INFO_BASIC) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object info") /* Map to group object type */ - if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(oinfo.type))) + if (H5G_UNKNOWN == (ret_value = H5G_map_obj_type(oinfo.type))) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_objtype_by_idx() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Gent.c b/src/H5Gent.c index 19aef10..7d1c06d 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -20,41 +20,35 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -62,18 +56,14 @@ /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__ent_decode_vec * @@ -94,8 +84,8 @@ H5FL_BLK_EXTERN(str_buf); herr_t H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5G_entry_t *ent, unsigned n) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -105,10 +95,10 @@ H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5 HDassert(ent); /* decode entries */ - for(u = 0; u < n; u++) { - if(*pp > p_end) + for (u = 0; u < n; u++) { + if (*pp > p_end) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "ran off the end of the image buffer") - if(H5G_ent_decode(f, pp, ent + u) < 0) + if (H5G_ent_decode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode") } @@ -116,7 +106,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_decode_vec() */ - /*------------------------------------------------------------------------- * Function: H5G_ent_decode * @@ -136,9 +125,9 @@ done: herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) { - const uint8_t *p_ret = *pp; - uint32_t tmp; - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *p_ret = *pp; + uint32_t tmp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -155,7 +144,7 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) ent->type = (H5G_cache_type_t)tmp; /* decode scratch-pad */ - switch(ent->type) { + switch (ent->type) { case H5G_NOTHING_CACHED: break; @@ -181,7 +170,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_decode() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_encode_vec * @@ -202,8 +190,8 @@ done: herr_t H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -213,15 +201,14 @@ H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsign HDassert(ent); /* encode entries */ - for(u = 0; u < n; u++) - if(H5G_ent_encode(f, pp, ent + u) < 0) + for (u = 0; u < n; u++) + if (H5G_ent_encode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5G__ent_encode_vec() */ - /*------------------------------------------------------------------------- * Function: H5G_ent_encode * @@ -242,8 +229,8 @@ done: herr_t H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) { - uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY_FILE(f); - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY_FILE(f); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -252,15 +239,15 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) HDassert(pp); /* Check for actual entry to encode */ - if(ent) { + if (ent) { /* encode header */ H5F_ENCODE_LENGTH(f, *pp, ent->name_off); H5F_addr_encode(f, pp, ent->header); UINT32ENCODE(*pp, ent->type); - UINT32ENCODE(*pp, 0); /*reserved*/ + UINT32ENCODE(*pp, 0); /*reserved*/ /* encode scratch-pad */ - switch(ent->type) { + switch (ent->type) { case H5G_NOTHING_CACHED: break; @@ -279,16 +266,16 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) default: HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown symbol table entry cache type") } /* end switch */ - } /* end if */ + } /* end if */ else { H5F_ENCODE_LENGTH(f, *pp, 0); H5F_addr_encode(f, pp, HADDR_UNDEF); UINT32ENCODE(*pp, H5G_NOTHING_CACHED); - UINT32ENCODE(*pp, 0); /*reserved*/ - } /* end else */ + UINT32ENCODE(*pp, 0); /*reserved*/ + } /* end else */ /* fill with zero */ - if(*pp < p_ret) + if (*pp < p_ret) HDmemset(*pp, 0, (size_t)(p_ret - *pp)); *pp = p_ret; @@ -296,7 +283,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_encode() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_copy * @@ -335,10 +321,11 @@ H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) H5MM_memcpy(dst, src, sizeof(H5G_entry_t)); /* Deep copy the names */ - if(depth == H5_COPY_DEEP) { + if (depth == H5_COPY_DEEP) { /* Nothing currently */ ; - } else if(depth == H5_COPY_SHALLOW) { + } + else if (depth == H5_COPY_SHALLOW) { /* Discarding 'const' qualifier OK - QAK */ H5G__ent_reset((H5G_entry_t *)src); } /* end if */ @@ -346,7 +333,6 @@ H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) FUNC_LEAVE_NOAPI_VOID } /* end H5G__ent_copy() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_reset * @@ -375,7 +361,6 @@ H5G__ent_reset(H5G_entry_t *ent) FUNC_LEAVE_NOAPI_VOID } /* end H5G__ent_reset() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_convert * @@ -391,11 +376,11 @@ H5G__ent_reset(H5G_entry_t *ent) *------------------------------------------------------------------------- */ herr_t -H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk, - H5O_type_t obj_type, const void *crt_info, H5G_entry_t *ent) +H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk, H5O_type_t obj_type, + const void *crt_info, H5G_entry_t *ent) { - size_t name_offset; /* Offset of name in heap */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t name_offset; /* Offset of name in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -412,82 +397,82 @@ H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk * Add the new name to the heap. */ name_offset = H5HL_insert(f, heap, HDstrlen(name) + 1, name); - if(0 == name_offset || UFAIL == name_offset) + if (0 == name_offset || UFAIL == name_offset) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert symbol name into heap") ent->name_off = name_offset; /* Build correct information for symbol table entry based on link type */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: - if(obj_type == H5O_TYPE_GROUP) { + if (obj_type == H5O_TYPE_GROUP) { const H5G_obj_create_t *gcrt_info = (const H5G_obj_create_t *)crt_info; ent->type = gcrt_info->cache_type; - if(ent->type != H5G_NOTHING_CACHED) + if (ent->type != H5G_NOTHING_CACHED) ent->cache = gcrt_info->cache; #ifndef NDEBUG else { /* Make sure there is no stab message in the target object */ - H5O_loc_t targ_oloc; /* Location of link target */ - htri_t stab_exists; /* Whether the target symbol table exists */ + H5O_loc_t targ_oloc; /* Location of link target */ + htri_t stab_exists; /* Whether the target symbol table exists */ /* Build target object location */ - if(H5O_loc_reset(&targ_oloc) < 0) + if (H5O_loc_reset(&targ_oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") targ_oloc.file = f; targ_oloc.addr = lnk->u.hard.addr; /* Check if a symbol table message exists */ - if((stab_exists = H5O_msg_exists(&targ_oloc, H5O_STAB_ID)) < 0) + if ((stab_exists = H5O_msg_exists(&targ_oloc, H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to check for STAB message") HDassert(!stab_exists); } /* end else */ -#endif /* NDEBUG */ - } /* end if */ - else if(obj_type == H5O_TYPE_UNKNOWN){ +#endif /* NDEBUG */ + } /* end if */ + else if (obj_type == H5O_TYPE_UNKNOWN) { /* Try to retrieve symbol table information for caching */ - H5O_loc_t targ_oloc; /* Location of link target */ - H5O_t *oh; /* Link target object header */ - H5O_stab_t stab; /* Link target symbol table */ - htri_t stab_exists; /* Whether the target symbol table exists */ + H5O_loc_t targ_oloc; /* Location of link target */ + H5O_t * oh; /* Link target object header */ + H5O_stab_t stab; /* Link target symbol table */ + htri_t stab_exists; /* Whether the target symbol table exists */ /* Build target object location */ - if(H5O_loc_reset(&targ_oloc) < 0) + if (H5O_loc_reset(&targ_oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") targ_oloc.file = f; targ_oloc.addr = lnk->u.hard.addr; /* Get the object header */ - if(NULL == (oh = H5O_protect(&targ_oloc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(&targ_oloc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_SYM, H5E_CANTPROTECT, FAIL, "unable to protect target object header") /* Check if a symbol table message exists */ - if((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) { - if(H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if ((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) { + if (H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) HERROR(H5E_SYM, H5E_CANTUNPROTECT, "unable to release object header"); HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to check for STAB message") } /* end if */ - if(stab_exists) { + if (stab_exists) { /* Read symbol table message */ - if(NULL == H5O_msg_read_oh(f, oh, H5O_STAB_ID, &stab)) { - if(H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (NULL == H5O_msg_read_oh(f, oh, H5O_STAB_ID, &stab)) { + if (H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) HERROR(H5E_SYM, H5E_CANTUNPROTECT, "unable to release object header"); HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read STAB message") } /* end if */ /* Cache symbol table message */ - ent->type = H5G_CACHED_STAB; + ent->type = H5G_CACHED_STAB; ent->cache.stab.btree_addr = stab.btree_addr; - ent->cache.stab.heap_addr = stab.heap_addr; + ent->cache.stab.heap_addr = stab.heap_addr; } /* end if */ else /* No symbol table message, don't cache anything */ ent->type = H5G_NOTHING_CACHED; - if(H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNPROTECT, FAIL, "unable to release object header") } /* end else */ else @@ -496,32 +481,30 @@ H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk ent->header = lnk->u.hard.addr; break; - case H5L_TYPE_SOFT: - { - size_t lnk_offset; /* Offset to sym-link value */ + case H5L_TYPE_SOFT: { + size_t lnk_offset; /* Offset to sym-link value */ - /* Insert link value into local heap */ - if(UFAIL == (lnk_offset = H5HL_insert(f, heap, - HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap") + /* Insert link value into local heap */ + if (UFAIL == + (lnk_offset = H5HL_insert(f, heap, HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap") - ent->type = H5G_CACHED_SLINK; - ent->cache.slink.lval_offset = lnk_offset; - } /* end case */ - break; + ent->type = H5G_CACHED_SLINK; + ent->cache.slink.lval_offset = lnk_offset; + } /* end case */ + break; case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: default: - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type") + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type") } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_convert() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_debug * @@ -536,10 +519,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, - const H5HL_t *heap) +H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, const H5HL_t *heap) { - const char *lval = NULL; + const char *lval = NULL; int nested_indent, nested_fwidth; FUNC_ENTER_PACKAGE_NOERR @@ -549,15 +531,12 @@ H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, nested_fwidth = MAX(0, fwidth - 3); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Name offset into private heap:", - (unsigned long) (ent->name_off)); + "Name offset into private heap:", (unsigned long)(ent->name_off)); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Object header address:", ent->header); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Object header address:", ent->header); - HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, - "Cache info type:"); - switch(ent->type) { + HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Cache info type:"); + switch (ent->type) { case H5G_NOTHING_CACHED: HDfprintf(stream, "Nothing Cached\n"); break; @@ -565,8 +544,7 @@ H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, case H5G_CACHED_STAB: HDfprintf(stream, "Symbol Table\n"); - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, - "Cached entry information:"); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Cached entry information:"); HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth, "B-tree address:", ent->cache.stab.btree_addr); @@ -576,19 +554,17 @@ H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, case H5G_CACHED_SLINK: HDfprintf(stream, "Symbolic Link\n"); - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, - "Cached information:"); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Cached information:"); HDfprintf(stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth, - "Link value offset:", - (unsigned long)(ent->cache.slink.lval_offset)); - if(heap) { + "Link value offset:", (unsigned long)(ent->cache.slink.lval_offset)); + if (heap) { lval = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset); HDfprintf(stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth, - "Link value:", - (lval == NULL) ? "" : lval); + "Link value:", (lval == NULL) ? "" : lval); } /* end if */ else - HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, "Warning: Invalid heap address given, name not displayed!"); + HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, + "Warning: Invalid heap address given, name not displayed!"); break; case H5G_CACHED_ERROR: @@ -600,4 +576,3 @@ H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__ent_debug() */ - diff --git a/src/H5Gint.c b/src/H5Gint.c index 0f9f9cb..2b6be10 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -26,70 +26,64 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for path traversal routine for "insertion file" routine */ typedef struct { - H5G_loc_t *loc; /* Pointer to the location for insertion */ + H5G_loc_t *loc; /* Pointer to the location for insertion */ } H5G_trav_ins_t; /* User data for application-style iteration over links in a group */ typedef struct { - hid_t gid; /* The group ID for the application callback */ - H5O_loc_t *link_loc; /* The object location for the link */ - H5G_link_iterate_t lnk_op; /* Application callback */ - void *op_data; /* Application's op data */ + hid_t gid; /* The group ID for the application callback */ + H5O_loc_t * link_loc; /* The object location for the link */ + H5G_link_iterate_t lnk_op; /* Application callback */ + void * op_data; /* Application's op data */ } H5G_iter_appcall_ud_t; /* User data for recursive traversal over links from a group */ typedef struct { - hid_t gid; /* The group ID for the starting group */ - H5G_loc_t *curr_loc; /* Location of starting group */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Iteration order within index */ - H5SL_t *visited; /* Skip list for tracking visited nodes */ - char *path; /* Path name of the link */ - size_t curr_path_len; /* Current length of the path in the buffer */ - size_t path_buf_size; /* Size of path buffer */ - H5L_iterate2_t op; /* Application callback */ - void *op_data; /* Application's op data */ + hid_t gid; /* The group ID for the starting group */ + H5G_loc_t * curr_loc; /* Location of starting group */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Iteration order within index */ + H5SL_t * visited; /* Skip list for tracking visited nodes */ + char * path; /* Path name of the link */ + size_t curr_path_len; /* Current length of the path in the buffer */ + size_t path_buf_size; /* Size of path buffer */ + H5L_iterate2_t op; /* Application callback */ + void * op_data; /* Application's op data */ } H5G_iter_visit_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5G__open_oid(H5G_t *grp); - /*********************/ /* Package Variables */ /*********************/ @@ -101,18 +95,14 @@ H5FL_DEFINE(H5G_shared_t); /* Declare the free list to manage H5_obj_t's */ H5FL_DEFINE(H5_obj_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__create_named * @@ -128,12 +118,11 @@ H5FL_DEFINE(H5_obj_t); *------------------------------------------------------------------------- */ H5G_t * -H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, - hid_t gcpl_id) +H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, hid_t gcpl_id) { - H5O_obj_create_t ocrt_info; /* Information for object creation */ - H5G_obj_create_t gcrt_info; /* Information for group creation */ - H5G_t *ret_value = NULL; /* Return value */ + H5O_obj_create_t ocrt_info; /* Information for object creation */ + H5G_obj_create_t gcrt_info; /* Information for group creation */ + H5G_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -144,17 +133,17 @@ H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, HDassert(gcpl_id != H5P_DEFAULT); /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; + gcrt_info.gcpl_id = gcpl_id; gcrt_info.cache_type = H5G_NOTHING_CACHED; HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); /* Set up object creation information */ ocrt_info.obj_type = H5O_TYPE_GROUP; ocrt_info.crt_info = &gcrt_info; - ocrt_info.new_obj = NULL; + ocrt_info.new_obj = NULL; /* Create the new group and link it to its parent group */ - if(H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) + if (H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create and link to group") HDassert(ocrt_info.new_obj); @@ -165,7 +154,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__create_named() */ - /*------------------------------------------------------------------------- * Function: H5G__create * @@ -187,9 +175,9 @@ done: H5G_t * H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info) { - H5G_t *grp = NULL; /*new group */ - unsigned oloc_init = 0; /* Flag to indicate that the group object location was created successfully */ - H5G_t *ret_value = NULL; /* Return value */ + H5G_t * grp = NULL; /*new group */ + unsigned oloc_init = 0; /* Flag to indicate that the group object location was created successfully */ + H5G_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -198,20 +186,20 @@ H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info) HDassert(gcrt_info->gcpl_id != H5P_DEFAULT); /* create an open group */ - if(NULL == (grp = H5FL_CALLOC(H5G_t))) + if (NULL == (grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t))) + if (NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Create the group object header */ - if(H5G__obj_create(file, gcrt_info, &(grp->oloc)/*out*/) < 0) + if (H5G__obj_create(file, gcrt_info, &(grp->oloc) /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group object header") - oloc_init = 1; /* Indicate that the object location information is valid */ + oloc_init = 1; /* Indicate that the object location information is valid */ /* Add group to list of open objects in file */ - if(H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't incr object ref. count") - if(H5FO_insert(grp->oloc.file, grp->oloc.addr, grp->shared, TRUE) < 0) + if (H5FO_insert(grp->oloc.file, grp->oloc.addr, grp->shared, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects") /* Set the count of times the object is opened */ @@ -221,27 +209,27 @@ H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info) ret_value = grp; done: - if(ret_value == NULL) { + if (ret_value == NULL) { /* Check if we need to release the file-oriented symbol table info */ - if(oloc_init) { - if(H5O_dec_rc_by_loc(&(grp->oloc)) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - if(H5O_close(&(grp->oloc), NULL) < 0) + if (oloc_init) { + if (H5O_dec_rc_by_loc(&(grp->oloc)) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, + "unable to decrement refcount on newly created object") + if (H5O_close(&(grp->oloc), NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header") - if(H5O_delete(file, grp->oloc.addr) < 0) + if (H5O_delete(file, grp->oloc.addr) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header") } /* end if */ - if(grp != NULL) { - if(grp->shared != NULL) + if (grp != NULL) { + if (grp->shared != NULL) grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); grp = H5FL_FREE(H5G_t, grp); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__create() */ - /*------------------------------------------------------------------------- * Function: H5G__open_name * @@ -258,13 +246,13 @@ done: H5G_t * H5G__open_name(const H5G_loc_t *loc, const char *name) { - H5G_t *grp = NULL; /* Group to open */ - H5G_loc_t grp_loc; /* Location used to open group */ - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ - H5O_type_t obj_type; /* Type of object at location */ - H5G_t *ret_value = NULL; /* Return value */ + H5G_t * grp = NULL; /* Group to open */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + H5O_type_t obj_type; /* Type of object at location */ + H5G_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -278,32 +266,31 @@ H5G__open_name(const H5G_loc_t *loc, const char *name) H5G_loc_reset(&grp_loc); /* Find the group object */ - if(H5G_loc_find(loc, name, &grp_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &grp_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found") loc_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&grp_oloc, &obj_type) < 0) + if (H5O_obj_type(&grp_oloc, &obj_type) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) + if (obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, NULL, "not a group") /* Open the group */ - if(NULL == (grp = H5G_open(&grp_loc))) + if (NULL == (grp = H5G_open(&grp_loc))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") /* Set return value */ ret_value = grp; done: - if(!ret_value) - if(loc_found && H5G_loc_free(&grp_loc) < 0) + if (!ret_value) + if (loc_found && H5G_loc_free(&grp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__open_name() */ - /*------------------------------------------------------------------------- * Function: H5G_open * @@ -322,9 +309,9 @@ done: H5G_t * H5G_open(const H5G_loc_t *loc) { - H5G_t *grp = NULL; /* Group opened */ - H5G_shared_t *shared_fo; /* Shared group object */ - H5G_t *ret_value = NULL; /* Return value */ + H5G_t * grp = NULL; /* Group opened */ + H5G_shared_t *shared_fo; /* Shared group object */ + H5G_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -332,33 +319,33 @@ H5G_open(const H5G_loc_t *loc) HDassert(loc); /* Allocate the group structure */ - if(NULL == (grp = H5FL_CALLOC(H5G_t))) + if (NULL == (grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for group") /* Shallow copy (take ownership) of the group location object */ - if(H5O_loc_copy_shallow(&(grp->oloc), loc->oloc) < 0) + if (H5O_loc_copy_shallow(&(grp->oloc), loc->oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "can't copy object location") - if(H5G_name_copy(&(grp->path), loc->path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(grp->path), loc->path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "can't copy path") /* Check if group was already open */ - if((shared_fo = (H5G_shared_t *)H5FO_opened(grp->oloc.file, grp->oloc.addr)) == NULL) { + if ((shared_fo = (H5G_shared_t *)H5FO_opened(grp->oloc.file, grp->oloc.addr)) == NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open the group object */ - if(H5G__open_oid(grp) < 0) + if (H5G__open_oid(grp) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found") /* Add group to list of open objects in file */ - if(H5FO_insert(grp->oloc.file, grp->oloc.addr, grp->shared, FALSE) < 0) { + if (H5FO_insert(grp->oloc.file, grp->oloc.addr, grp->shared, FALSE) < 0) { grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't increment object count") /* Set open object count */ @@ -372,14 +359,14 @@ H5G_open(const H5G_loc_t *loc) shared_fo->fo_count++; /* Check if the object has been opened through the top file yet */ - if(H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) { + if (H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) { /* Open the object through this top file */ - if(H5O_open(&(grp->oloc)) < 0) + if (H5O_open(&(grp->oloc)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ @@ -387,7 +374,7 @@ H5G_open(const H5G_loc_t *loc) ret_value = grp; done: - if(!ret_value && grp) { + if (!ret_value && grp) { H5O_loc_free(&(grp->oloc)); H5G_name_free(&(grp->path)); grp = H5FL_FREE(H5G_t, grp); @@ -396,7 +383,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_open() */ - /*------------------------------------------------------------------------- * Function: H5G__open_oid * @@ -415,8 +401,8 @@ done: static herr_t H5G__open_oid(H5G_t *grp) { - hbool_t obj_opened = FALSE; - herr_t ret_value = SUCCEED; + hbool_t obj_opened = FALSE; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -424,31 +410,29 @@ H5G__open_oid(H5G_t *grp) HDassert(grp); /* Allocate the shared information for the group */ - if(NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t))) + if (NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Grab the object header */ - if(H5O_open(&(grp->oloc)) < 0) + if (H5O_open(&(grp->oloc)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") obj_opened = TRUE; /* Check if this object has the right message(s) to be treated as a group */ - if((H5O_msg_exists(&(grp->oloc), H5O_STAB_ID) <= 0) - && (H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID) <= 0)) + if ((H5O_msg_exists(&(grp->oloc), H5O_STAB_ID) <= 0) && (H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID) <= 0)) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "not a group") done: - if(ret_value < 0) { - if(obj_opened) + if (ret_value < 0) { + if (obj_opened) H5O_close(&(grp->oloc), NULL); - if(grp->shared) + if (grp->shared) grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__open_oid() */ - /*------------------------------------------------------------------------- * Function: H5G_close * @@ -464,9 +448,9 @@ done: herr_t H5G_close(H5G_t *grp) { - hbool_t corked; /* Whether the group is corked or not */ - hbool_t file_closed = TRUE; /* H5O_close also closed the file? */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t corked; /* Whether the group is corked or not */ + hbool_t file_closed = TRUE; /* H5O_close also closed the file? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -476,61 +460,62 @@ H5G_close(H5G_t *grp) --grp->shared->fo_count; - if(0 == grp->shared->fo_count) { + if (0 == grp->shared->fo_count) { HDassert(grp != H5G_rootof(H5G_fileof(grp))); /* Uncork cache entries with object address tag */ - if(H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__UNCORK, NULL) < 0) + if (corked) + if (H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__UNCORK, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* Remove the group from the list of opened objects in the file */ - if(H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't decrement count for object") - if(H5FO_delete(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_delete(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't remove group from list of open objects") - if(H5O_close(&(grp->oloc), &file_closed) < 0) + if (H5O_close(&(grp->oloc), &file_closed) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") /* Evict group metadata if evicting on close */ - if(!file_closed && H5F_SHARED(grp->oloc.file) && H5F_EVICT_ON_CLOSE(grp->oloc.file)) { - if(H5AC_flush_tagged_metadata(grp->oloc.file, grp->oloc.addr) < 0) + if (!file_closed && H5F_SHARED(grp->oloc.file) && H5F_EVICT_ON_CLOSE(grp->oloc.file)) { + if (H5AC_flush_tagged_metadata(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") - if(H5AC_evict_tagged_metadata(grp->oloc.file, grp->oloc.addr, FALSE) < 0) + if (H5AC_evict_tagged_metadata(grp->oloc.file, grp->oloc.addr, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict tagged metadata") } /* end if */ /* Free memory */ grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); - } else { + } + else { /* Decrement the ref. count for this object in the top file */ - if(H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Check reference count for this object in the top file */ - if(H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) { - if(H5O_close(&(grp->oloc), NULL) < 0) + if (H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) { + if (H5O_close(&(grp->oloc), NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") } /* end if */ else /* Free object location (i.e. "unhold" the file if appropriate) */ - if(H5O_loc_free(&(grp->oloc)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "problem attempting to free location") + if (H5O_loc_free(&(grp->oloc)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "problem attempting to free location") /* If this group is a mount point and the mount point is the last open * reference to the group (i.e. fo_count == 1 now), then attempt to * close down the file hierarchy */ - if(grp->shared->mounted && grp->shared->fo_count == 1) { + if (grp->shared->mounted && grp->shared->fo_count == 1) { /* Attempt to close down the file hierarchy */ - if(H5F_try_close(grp->oloc.file, NULL) < 0) + if (H5F_try_close(grp->oloc.file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") } /* end if */ - } /* end else */ + } /* end else */ - if(H5G_name_free(&(grp->path)) < 0) { + if (H5G_name_free(&(grp->path)) < 0) { grp = H5FL_FREE(H5G_t, grp); HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't free group entry name") } /* end if */ @@ -541,7 +526,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_close() */ - /*------------------------------------------------------------------------- * Function: H5G_oloc * @@ -564,7 +548,6 @@ H5G_oloc(H5G_t *grp) FUNC_LEAVE_NOAPI(grp ? &(grp->oloc) : NULL) } /* end H5G_oloc() */ - /*------------------------------------------------------------------------- * Function: H5G_nameof * @@ -587,7 +570,6 @@ H5G_nameof(const H5G_t *grp) FUNC_LEAVE_NOAPI(grp ? &(grp->path) : NULL) } /* end H5G_nameof() */ - /*------------------------------------------------------------------------- * Function: H5G_fileof * @@ -613,7 +595,6 @@ H5G_fileof(H5G_t *grp) FUNC_LEAVE_NOAPI(grp->oloc.file) } /* end H5G_fileof() */ - /*------------------------------------------------------------------------- * Function: H5G_get_shared_count * @@ -637,7 +618,6 @@ H5G_get_shared_count(H5G_t *grp) FUNC_LEAVE_NOAPI(grp->shared->fo_count) } /* end H5G_get_shared_count() */ - /*------------------------------------------------------------------------- * Function: H5G_mount * @@ -665,7 +645,6 @@ H5G_mount(H5G_t *grp) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_mount() */ - /*------------------------------------------------------------------------- * Function: H5G_mounted * @@ -689,7 +668,6 @@ H5G_mounted(H5G_t *grp) FUNC_LEAVE_NOAPI(grp->shared->mounted) } /* end H5G_mounted() */ - /*------------------------------------------------------------------------- * Function: H5G_unmount * @@ -717,7 +695,6 @@ H5G_unmount(H5G_t *grp) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_unmount() */ - /*------------------------------------------------------------------------- * Function: H5G_iterate_cb * @@ -734,8 +711,8 @@ H5G_unmount(H5G_t *grp) static herr_t H5G_iterate_cb(const H5O_link_t *lnk, void *_udata) { - H5G_iter_appcall_ud_t *udata = (H5G_iter_appcall_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = H5_ITER_ERROR; /* Return value */ + H5G_iter_appcall_ud_t *udata = (H5G_iter_appcall_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = H5_ITER_ERROR; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -743,7 +720,7 @@ H5G_iterate_cb(const H5O_link_t *lnk, void *_udata) HDassert(lnk); HDassert(udata); - switch(udata->lnk_op.op_type) { + switch (udata->lnk_op.op_type) { #ifndef H5_NO_DEPRECATED_SYMBOLS case H5G_LINK_OP_OLD: /* Make the old-type application callback */ @@ -751,18 +728,16 @@ H5G_iterate_cb(const H5O_link_t *lnk, void *_udata) break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - case H5G_LINK_OP_NEW: - { - H5L_info2_t info; /* Link info */ + case H5G_LINK_OP_NEW: { + H5L_info2_t info; /* Link info */ - /* Retrieve the info for the link */ - if(H5G_link_to_info(udata->link_loc, lnk, &info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link") + /* Retrieve the info for the link */ + if (H5G_link_to_info(udata->link_loc, lnk, &info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link") - /* Make the application callback */ - ret_value = (udata->lnk_op.op_func.op_new)(udata->gid, lnk->name, &info, udata->op_data); - } - break; + /* Make the application callback */ + ret_value = (udata->lnk_op.op_func.op_new)(udata->gid, lnk->name, &info, udata->op_data); + } break; default: HDassert(0 && "Unknown link op type?!?"); @@ -772,7 +747,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_iterate * @@ -786,14 +760,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_iterate(H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - const H5G_link_iterate_t *lnk_op, void *op_data) +H5G_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, + hsize_t *last_lnk, const H5G_link_iterate_t *lnk_op, void *op_data) { - hid_t gid = H5I_INVALID_HID; /* ID of group to iterate over */ - H5G_t *grp = NULL; /* Pointer to group data structure to iterate over */ - H5G_iter_appcall_ud_t udata; /* User data for callback */ - herr_t ret_value = FAIL; /* Return value */ + hid_t gid = H5I_INVALID_HID; /* ID of group to iterate over */ + H5G_t * grp = NULL; /* Pointer to group data structure to iterate over */ + H5G_iter_appcall_ud_t udata; /* User data for callback */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -806,34 +779,34 @@ H5G_iterate(H5G_loc_t *loc, const char *group_name, /* Open the group on which to operate. We also create a group ID which * we can pass to the application-defined operator. */ - if(NULL == (grp = H5G__open_name(loc, group_name))) + if (NULL == (grp = H5G__open_name(loc, group_name))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((gid = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) + if ((gid = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Set up user data for callback */ - udata.gid = gid; + udata.gid = gid; udata.link_loc = &grp->oloc; - udata.lnk_op = *lnk_op; - udata.op_data = op_data; + udata.lnk_op = *lnk_op; + udata.op_data = op_data; /* Call the real group iteration routine */ - if((ret_value = H5G__obj_iterate(&(grp->oloc), idx_type, order, skip, last_lnk, H5G_iterate_cb, &udata)) < 0) + if ((ret_value = + H5G__obj_iterate(&(grp->oloc), idx_type, order, skip, last_lnk, H5G_iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "error iterating over links") done: /* Release the group opened */ - if(gid != H5I_INVALID_HID) { - if(H5I_dec_app_ref(gid) < 0) + if (gid != H5I_INVALID_HID) { + if (H5I_dec_app_ref(gid) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") } - else if(grp && H5G_close(grp) < 0) + else if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G_free_visit_visited * @@ -847,7 +820,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/) +H5G_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data /*in,out*/) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -856,7 +829,6 @@ H5G_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_free_visit_visited() */ - /*------------------------------------------------------------------------- * Function: H5G_visit_cb * @@ -873,16 +845,16 @@ H5G_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED static herr_t H5G_visit_cb(const H5O_link_t *lnk, void *_udata) { - H5G_iter_visit_ud_t *udata = (H5G_iter_visit_ud_t *)_udata; /* User data for callback */ - H5L_info2_t info; /* Link info */ - H5G_loc_t obj_loc; /* Location of object */ - H5G_name_t obj_path; /* Object's group hier. path */ - H5O_loc_t obj_oloc; /* Object's object location */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ + H5G_iter_visit_ud_t *udata = (H5G_iter_visit_ud_t *)_udata; /* User data for callback */ + H5L_info2_t info; /* Link info */ + H5G_loc_t obj_loc; /* Location of object */ + H5G_name_t obj_path; /* Object's group hier. path */ + H5O_loc_t obj_oloc; /* Object's object location */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ size_t old_path_len = udata->curr_path_len; /* Length of path before appending this link's name */ - size_t link_name_len; /* Length of link's name */ - size_t len_needed; /* Length of path string needed */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + size_t link_name_len; /* Length of link's name */ + size_t len_needed; /* Length of path string needed */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -893,14 +865,14 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) /* Check if we will need more space to store this link's relative path */ /* ("+2" is for string terminator and possible '/' for group separator later) */ link_name_len = HDstrlen(lnk->name); - len_needed = udata->curr_path_len + link_name_len + 2; - if(len_needed > udata->path_buf_size) { - void *new_path; /* Pointer to new path buffer */ + len_needed = udata->curr_path_len + link_name_len + 2; + if (len_needed > udata->path_buf_size) { + void *new_path; /* Pointer to new path buffer */ /* Attempt to allocate larger buffer for path */ - if(NULL == (new_path = H5MM_realloc(udata->path, len_needed))) + if (NULL == (new_path = H5MM_realloc(udata->path, len_needed))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate path string") - udata->path = (char *)new_path; + udata->path = (char *)new_path; udata->path_buf_size = len_needed; } /* end if */ @@ -910,15 +882,15 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) udata->curr_path_len += link_name_len; /* Construct the link info from the link message */ - if(H5G_link_to_info(udata->curr_loc->oloc, lnk, &info) < 0) + if (H5G_link_to_info(udata->curr_loc->oloc, lnk, &info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link") /* Make the application callback */ ret_value = (udata->op)(udata->gid, udata->path, &info, udata->op_data); /* Check for doing more work */ - if(ret_value == H5_ITER_CONT && lnk->type == H5L_TYPE_HARD) { - H5_obj_t obj_pos; /* Object "position" for this object */ + if (ret_value == H5_ITER_CONT && lnk->type == H5L_TYPE_HARD) { + H5_obj_t obj_pos; /* Object "position" for this object */ /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -927,7 +899,7 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) /* Find the object using the LAPL passed in */ /* (Correctly handles mounted files) */ - if(H5G_loc_find(udata->curr_loc, lnk->name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(udata->curr_loc, lnk->name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") obj_found = TRUE; @@ -936,37 +908,38 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) obj_pos.addr = obj_oloc.addr; /* Check if we've seen the object the link references before */ - if(NULL == H5SL_search(udata->visited, &obj_pos)) { - H5O_type_t otype; /* Basic object type (group, dataset, etc.) */ - unsigned rc; /* Reference count of object */ + if (NULL == H5SL_search(udata->visited, &obj_pos)) { + H5O_type_t otype; /* Basic object type (group, dataset, etc.) */ + unsigned rc; /* Reference count of object */ /* Get the object's reference count and type */ - if(H5O_get_rc_and_type(&obj_oloc, &rc, &otype) < 0) + if (H5O_get_rc_and_type(&obj_oloc, &rc, &otype) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info") /* If its ref count is > 1, we add it to the list of visited objects */ /* (because it could come up again during traversal) */ - if(rc > 1) { - H5_obj_t *new_node; /* New object node for visited list */ + if (rc > 1) { + H5_obj_t *new_node; /* New object node for visited list */ /* Allocate new object "position" node */ - if((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) + if ((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate object node") /* Set node information */ *new_node = obj_pos; /* Add to list of visited objects */ - if(H5SL_insert(udata->visited, new_node, new_node) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert object node into visited list") + if (H5SL_insert(udata->visited, new_node, new_node) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5_ITER_ERROR, + "can't insert object node into visited list") } /* end if */ /* If it's a group, we recurse into it */ - if(otype == H5O_TYPE_GROUP) { - H5G_loc_t *old_loc = udata->curr_loc; /* Pointer to previous group location info */ - H5_index_t idx_type = udata->idx_type; /* Type of index to use */ - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ + if (otype == H5O_TYPE_GROUP) { + H5G_loc_t * old_loc = udata->curr_loc; /* Pointer to previous group location info */ + H5_index_t idx_type = udata->idx_type; /* Type of index to use */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ /* Add the path separator to the current path */ HDassert(udata->path[udata->curr_path_len] == '\0'); @@ -974,13 +947,13 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) udata->curr_path_len++; /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(&obj_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(&obj_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) /* Switch to name order for this group */ idx_type = H5_INDEX_NAME; } /* end if */ @@ -989,7 +962,7 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) /* Switch to name order for this group */ idx_type = H5_INDEX_NAME; } /* end if */ @@ -998,27 +971,27 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) udata->curr_loc = &obj_loc; /* Iterate over links in group */ - ret_value = H5G__obj_iterate(&obj_oloc, idx_type, udata->order, (hsize_t)0, NULL, H5G_visit_cb, udata); + ret_value = H5G__obj_iterate(&obj_oloc, idx_type, udata->order, (hsize_t)0, NULL, + H5G_visit_cb, udata); /* Restore location */ udata->curr_loc = old_loc; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Reset path back to incoming path */ udata->path[old_path_len] = '\0'; - udata->curr_path_len = old_path_len; + udata->curr_path_len = old_path_len; /* Release resources */ - if(obj_found && H5G_loc_free(&obj_loc) < 0) + if (obj_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_visit_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_visit * @@ -1045,17 +1018,17 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, H5L_iterate2_t op, void *op_data) +H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate2_t op, void *op_data) { - H5G_iter_visit_ud_t udata; /* User data for callback */ - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t start_loc; /* Location of starting group */ - unsigned rc; /* Reference count of object */ - herr_t ret_value = FAIL; /* Return value */ + H5G_iter_visit_ud_t udata; /* User data for callback */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + H5G_t * grp = NULL; /* Group opened */ + H5G_loc_t start_loc; /* Location of starting group */ + unsigned rc; /* Reference count of object */ + herr_t ret_value = FAIL; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); @@ -1063,50 +1036,50 @@ H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(!loc) + if (!loc) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc parameter cannot be NULL") /* Open the group to begin visiting within */ - if(NULL == (grp = H5G__open_name(loc, group_name))) + if (NULL == (grp = H5G__open_name(loc, group_name))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an ID for the starting group */ - if((gid = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) + if ((gid = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Get the location of the starting group */ - if(H5G_loc(gid, &start_loc) < 0) + if (H5G_loc(gid, &start_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Set up user data */ - udata.gid = gid; + udata.gid = gid; udata.curr_loc = &start_loc; udata.idx_type = idx_type; - udata.order = order; - udata.op = op; - udata.op_data = op_data; + udata.order = order; + udata.op = op; + udata.op_data = op_data; /* Allocate space for the path name */ - if(NULL == (udata.path = H5MM_strdup(""))) + if (NULL == (udata.path = H5MM_strdup(""))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate path name buffer") udata.path_buf_size = 1; udata.curr_path_len = 0; /* Create skip list to store visited object information */ - if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) + if ((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects") /* Get the group's reference count */ - if(H5O_get_rc_and_type(&grp->oloc, &rc, NULL) < 0) + if (H5O_get_rc_and_type(&grp->oloc, &rc, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object info") /* If its ref count is > 1, we add it to the list of visited objects */ /* (because it could come up again during traversal) */ - if(rc > 1) { - H5_obj_t *obj_pos; /* New object node for visited list */ + if (rc > 1) { + H5_obj_t *obj_pos; /* New object node for visited list */ /* Allocate new object "position" node */ - if((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) + if ((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate object node") /* Construct unique "position" for this object */ @@ -1114,18 +1087,18 @@ H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, obj_pos->addr = grp->oloc.addr; /* Add to list of visited objects */ - if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) + if (H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") } /* end if */ /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) /* Switch to name order for this group */ idx_type = H5_INDEX_NAME; } /* end if */ @@ -1134,33 +1107,33 @@ H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) /* Switch to name order for this group */ idx_type = H5_INDEX_NAME; } /* end if */ /* Call the link iteration routine */ - if((ret_value = H5G__obj_iterate(&(grp->oloc), idx_type, order, (hsize_t)0, NULL, H5G_visit_cb, &udata)) < 0) + if ((ret_value = + H5G__obj_iterate(&(grp->oloc), idx_type, order, (hsize_t)0, NULL, H5G_visit_cb, &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't visit links") done: /* Release user data resources */ H5MM_xfree(udata.path); - if(udata.visited) + if (udata.visited) H5SL_destroy(udata.visited, H5G_free_visit_visited, NULL); /* Release the group opened */ - if(gid != H5I_INVALID_HID) { - if(H5I_dec_app_ref(gid) < 0) + if (gid != H5I_INVALID_HID) { + if (H5I_dec_app_ref(gid) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") } - else if(grp && H5G_close(grp) < 0) + else if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_visit() */ - /*------------------------------------------------------------------------- * Function: H5G_get_create_plist * @@ -1180,65 +1153,65 @@ done: hid_t H5G_get_create_plist(const H5G_t *grp) { - H5O_linfo_t linfo; /* Link info message */ - htri_t ginfo_exists; - htri_t linfo_exists; - htri_t pline_exists; - H5P_genplist_t *gcpl_plist; - H5P_genplist_t *new_plist; - hid_t new_gcpl_id = H5I_INVALID_HID; - hid_t ret_value = H5I_INVALID_HID; + H5O_linfo_t linfo; /* Link info message */ + htri_t ginfo_exists; + htri_t linfo_exists; + htri_t pline_exists; + H5P_genplist_t *gcpl_plist; + H5P_genplist_t *new_plist; + hid_t new_gcpl_id = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Copy the default group creation property list */ - if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default group creation property list") - if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) + if (NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default group creation property list") + if ((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get property list") /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&grp->oloc, new_plist) < 0) + if (H5O_get_create_plist(&grp->oloc, new_plist) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") /* Check for the group having a group info message */ - if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to read object header") - if(ginfo_exists) { - H5O_ginfo_t ginfo; /* Group info message */ + if ((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to read object header") + if (ginfo_exists) { + H5O_ginfo_t ginfo; /* Group info message */ /* Read the group info */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, H5I_INVALID_HID, "can't get group info") /* Set the group info for the property list */ - if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set group info") } /* end if */ /* Check for the group having a link info message */ - if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to read object header") - if(linfo_exists) { + if (linfo_exists) { /* Set the link info for the property list */ - if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set link info") } /* end if */ /* Check for the group having a pipeline message */ - if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID)) < 0) + if ((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to read object header") - if(pline_exists) { - H5O_pline_t pline; /* Pipeline message */ + if (pline_exists) { + H5O_pline_t pline; /* Pipeline message */ /* Read the pipeline */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, H5I_INVALID_HID, "can't get link pipeline") /* Set the pipeline for the property list */ - if(H5P_poke(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set link pipeline") } /* end if */ @@ -1246,16 +1219,15 @@ H5G_get_create_plist(const H5G_t *grp) ret_value = new_gcpl_id; done: - if(ret_value < 0) { - if(new_gcpl_id > 0) - if(H5I_dec_app_ref(new_gcpl_id) < 0) + if (ret_value < 0) { + if (new_gcpl_id > 0) + if (H5I_dec_app_ref(new_gcpl_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't free") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5G__get_info_by_name * @@ -1271,11 +1243,11 @@ done: herr_t H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, H5G_info_t *grp_info) { - H5G_loc_t grp_loc; /* Location used to open group */ - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1289,23 +1261,22 @@ H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, H5G_info_t *grp_in H5G_loc_reset(&grp_loc); /* Find the group object */ - if(H5G_loc_find(loc, name, &grp_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &grp_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/) < 0) + if (H5G__obj_info(grp_loc.oloc, grp_info /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: /* Clean up */ - if(loc_found && H5G_loc_free(&grp_loc) < 0) + if (loc_found && H5G_loc_free(&grp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_info_by_name() */ - /*------------------------------------------------------------------------- * Function: H5G__get_info_by_idx * @@ -1319,14 +1290,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info) +H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5G_info_t *grp_info) { - H5G_loc_t grp_loc; /* Location used to open group */ - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1340,19 +1311,18 @@ H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5G_loc_reset(&grp_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(loc, group_name, idx_type, order, n, &grp_loc/*out*/) < 0) + if (H5G_loc_find_by_idx(loc, group_name, idx_type, order, n, &grp_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/) < 0) + if (H5G__obj_info(grp_loc.oloc, grp_info /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: /* Clean up */ - if(loc_found && H5G_loc_free(&grp_loc) < 0) + if (loc_found && H5G_loc_free(&grp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_info_by_idx() */ - diff --git a/src/H5Glink.c b/src/H5Glink.c index cbe5307..f6f504d 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -26,39 +26,34 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property Lists */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -68,23 +63,18 @@ static int H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2); static int H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2); static int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G_link_cmp_name_inc * @@ -110,7 +100,6 @@ H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2) FUNC_LEAVE_NOAPI(HDstrcmp(((const H5O_link_t *)lnk1)->name, ((const H5O_link_t *)lnk2)->name)) } /* end H5G_link_cmp_name_inc() */ - /*------------------------------------------------------------------------- * Function: H5G_link_cmp_name_dec * @@ -136,7 +125,6 @@ H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2) FUNC_LEAVE_NOAPI(HDstrcmp(((const H5O_link_t *)lnk2)->name, ((const H5O_link_t *)lnk1)->name)) } /* end H5G_link_cmp_name_dec() */ - /*------------------------------------------------------------------------- * Function: H5G_link_cmp_corder_inc * @@ -156,13 +144,13 @@ H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2) static int H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) + if (((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) ret_value = -1; - else if(((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) + else if (((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) ret_value = 1; else ret_value = 0; @@ -170,7 +158,6 @@ H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_link_cmp_corder_inc() */ - /*------------------------------------------------------------------------- * Function: H5G_link_cmp_corder_dec * @@ -190,13 +177,13 @@ H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) static int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) + if (((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) ret_value = 1; - else if(((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) + else if (((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) ret_value = -1; else ret_value = 0; @@ -204,7 +191,6 @@ H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_link_cmp_corder_dec() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_to_link * @@ -218,11 +204,10 @@ H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) *------------------------------------------------------------------------- */ herr_t -H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, - const H5G_entry_t *ent, const char *name) +H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, const H5G_entry_t *ent, const char *name) { - hbool_t dup_soft = FALSE; /* xstrdup the symbolic link name or not */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t dup_soft = FALSE; /* xstrdup the symbolic link name or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -233,21 +218,21 @@ H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, HDassert(name); /* Set (default) common info for link */ - lnk->cset = H5F_DEFAULT_CSET; - lnk->corder = 0; - lnk->corder_valid = FALSE; /* Creation order not valid for this link */ - if((lnk->name = H5MM_xstrdup(name)) == NULL) + lnk->cset = H5F_DEFAULT_CSET; + lnk->corder = 0; + lnk->corder_valid = FALSE; /* Creation order not valid for this link */ + if ((lnk->name = H5MM_xstrdup(name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to duplicate link name") /* Object is a symbolic or hard link */ - if(ent->type == H5G_CACHED_SLINK) { - const char *s; /* Pointer to link value */ + if (ent->type == H5G_CACHED_SLINK) { + const char *s; /* Pointer to link value */ - if((s = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset)) == NULL) + if ((s = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get symbolic link name") /* Copy the link value */ - if((lnk->u.soft.name = H5MM_xstrdup(s)) == NULL) + if ((lnk->u.soft.name = H5MM_xstrdup(s)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to duplicate symbolic link name") dup_soft = TRUE; @@ -264,16 +249,15 @@ H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, } /* end else */ done: - if(ret_value < 0) { - if(lnk->name) + if (ret_value < 0) { + if (lnk->name) H5MM_xfree(lnk->name); - if(ent->type == H5G_CACHED_SLINK && dup_soft) + if (ent->type == H5G_CACHED_SLINK && dup_soft) H5MM_xfree(lnk->u.soft.name); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_to_link() */ - /*------------------------------------------------------------------------- * Function: H5G_link_to_info * @@ -289,7 +273,7 @@ done: herr_t H5G_link_to_info(const H5O_loc_t *link_loc, const H5O_link_t *lnk, H5L_info2_t *info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -298,17 +282,18 @@ H5G_link_to_info(const H5O_loc_t *link_loc, const H5O_link_t *lnk, H5L_info2_t * HDassert(lnk); /* Get information from the link */ - if(info) { - info->cset = lnk->cset; - info->corder = lnk->corder; + if (info) { + info->cset = lnk->cset; + info->corder = lnk->corder; info->corder_valid = lnk->corder_valid; - info->type = lnk->type; + info->type = lnk->type; - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: /* Serialize the address into a VOL token */ - if(H5VL_native_addr_to_token(link_loc->file, H5I_FILE, lnk->u.hard.addr, &info->u.token) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") + if (H5VL_native_addr_to_token(link_loc->file, H5I_FILE, lnk->u.hard.addr, &info->u.token) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSERIALIZE, FAIL, + "can't serialize address into object token") break; case H5L_TYPE_SOFT: @@ -318,11 +303,10 @@ H5G_link_to_info(const H5O_loc_t *link_loc, const H5O_link_t *lnk, H5L_info2_t * case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: - default: - { - const H5L_class_t *link_class; /* User-defined link class */ + default: { + const H5L_class_t *link_class; /* User-defined link class */ - if(lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) + if (lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_LINK, H5E_BADTYPE, FAIL, "unknown link class") /* User-defined link; call its query function to get the link udata size. */ @@ -332,27 +316,29 @@ H5G_link_to_info(const H5O_loc_t *link_loc, const H5O_link_t *lnk, H5L_info2_t * */ link_class = H5L_find_class(lnk->type); - if(link_class != NULL && link_class->query_func != NULL) { - ssize_t cb_ret; /* Return value from UD callback */ + if (link_class != NULL && link_class->query_func != NULL) { + ssize_t cb_ret; /* Return value from UD callback */ /* Call the link's query routine to retrieve the user-defined link's value size */ - /* (in case the query routine packs/unpacks the link value in some way that changes its size) */ - if((cb_ret = (link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, NULL, (size_t)0)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "query buffer size callback returned failure") + /* (in case the query routine packs/unpacks the link value in some way that changes its + * size) */ + if ((cb_ret = (link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, NULL, + (size_t)0)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, + "query buffer size callback returned failure") info->u.val_size = (size_t)cb_ret; } /* end if */ else info->u.val_size = 0; } /* end case */ - } /* end switch */ - } /* end if */ + } /* end switch */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_link_to_info() */ - /*------------------------------------------------------------------------- * Function: H5G__link_to_loc * @@ -366,10 +352,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc) +H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -383,24 +368,23 @@ H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, */ /* Check for unknown library-internal link */ - if(lnk->type > H5L_TYPE_BUILTIN_MAX && lnk->type < H5L_TYPE_UD_MIN) + if (lnk->type > H5L_TYPE_BUILTIN_MAX && lnk->type < H5L_TYPE_UD_MIN) HGOTO_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL, "unknown link type") /* Build object's group hier. location */ - if(H5G_name_set(grp_loc->path, obj_loc->path, lnk->name) < 0) + if (H5G_name_set(grp_loc->path, obj_loc->path, lnk->name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot set name") /* Set the object location, if it's a hard link set the address also */ - obj_loc->oloc->file = grp_loc->oloc->file; + obj_loc->oloc->file = grp_loc->oloc->file; obj_loc->oloc->holding_file = FALSE; - if(lnk->type == H5L_TYPE_HARD) + if (lnk->type == H5L_TYPE_HARD) obj_loc->oloc->addr = lnk->u.hard.addr; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__link_to_loc() */ - /*------------------------------------------------------------------------- * Function: H5G__link_sort_table * @@ -414,10 +398,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, - H5_iter_order_t order) +H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_order_t order) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_NOERR @@ -425,26 +408,26 @@ H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, HDassert(ltable); /* Can't sort when empty since the links table will be NULL */ - if(0 == ltable->nlinks) + if (0 == ltable->nlinks) HGOTO_DONE(ret_value); /* This should never be NULL if the number of links is non-zero */ HDassert(ltable->lnks); /* Pick appropriate sorting routine */ - if(idx_type == H5_INDEX_NAME) { - if(order == H5_ITER_INC) + if (idx_type == H5_INDEX_NAME) { + if (order == H5_ITER_INC) HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_inc); - else if(order == H5_ITER_DEC) + else if (order == H5_ITER_DEC) HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_dec); else HDassert(order == H5_ITER_NATIVE); } /* end if */ else { HDassert(idx_type == H5_INDEX_CRT_ORDER); - if(order == H5_ITER_INC) + if (order == H5_ITER_INC) HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_inc); - else if(order == H5_ITER_DEC) + else if (order == H5_ITER_DEC) HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_dec); else HDassert(order == H5_ITER_NATIVE); @@ -454,7 +437,6 @@ done: FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__link_sort_table() */ - /*------------------------------------------------------------------------- * Function: H5G__link_iterate_table * @@ -470,11 +452,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, - hsize_t *last_lnk, const H5G_lib_iterate_t op, void *op_data) +H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, hsize_t *last_lnk, + const H5G_lib_iterate_t op, void *op_data) { - size_t u; /* Local index variable */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + size_t u; /* Local index variable */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -483,28 +465,27 @@ H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, HDassert(op); /* Skip over links, if requested */ - if(last_lnk) + if (last_lnk) *last_lnk += skip; /* Iterate over link messages */ H5_CHECKED_ASSIGN(u, size_t, skip, hsize_t) - for(; u < ltable->nlinks && !ret_value; u++) { + for (; u < ltable->nlinks && !ret_value; u++) { /* Make the callback */ ret_value = (op)(&(ltable->lnks[u]), op_data); /* Increment the number of entries passed through */ - if(last_lnk) + if (last_lnk) (*last_lnk)++; } /* end for */ /* Check for callback failure and pass along return value */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__link_iterate_table() */ - /*------------------------------------------------------------------------- * Function: H5G__link_release_table * @@ -521,8 +502,8 @@ H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, herr_t H5G__link_release_table(H5G_link_table_t *ltable) { - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -530,10 +511,10 @@ H5G__link_release_table(H5G_link_table_t *ltable) HDassert(ltable); /* Release link info, if any */ - if(ltable->nlinks > 0) { + if (ltable->nlinks > 0) { /* Free link message information */ - for(u = 0; u < ltable->nlinks; u++) - if(H5O_msg_reset(H5O_LINK_ID, &(ltable->lnks[u])) < 0) + for (u = 0; u < ltable->nlinks; u++) + if (H5O_msg_reset(H5O_LINK_ID, &(ltable->lnks[u])) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link message") /* Free table of links */ @@ -546,7 +527,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__link_release_table() */ - /*------------------------------------------------------------------------- * Function: H5G__link_name_replace * @@ -563,8 +543,8 @@ done: herr_t H5G__link_name_replace(H5F_t *file, H5RS_str_t *grp_full_path_r, const H5O_link_t *lnk) { - H5RS_str_t *obj_path_r = NULL; /* Full path for link being removed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5RS_str_t *obj_path_r = NULL; /* Full path for link being removed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -572,16 +552,15 @@ H5G__link_name_replace(H5F_t *file, H5RS_str_t *grp_full_path_r, const H5O_link_ HDassert(file); /* Search the open IDs and replace names for unlinked object */ - if(grp_full_path_r) { + if (grp_full_path_r) { obj_path_r = H5G_build_fullpath_refstr_str(grp_full_path_r, lnk->name); - if(H5G_name_replace(lnk, H5G_NAME_DELETE, file, obj_path_r, NULL, NULL) < 0) + if (H5G_name_replace(lnk, H5G_NAME_DELETE, file, obj_path_r, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name") } done: - if(obj_path_r) + if (obj_path_r) H5RS_decr(obj_path_r); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__link_name_replace() */ - diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 2461c51..3b697ae 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -26,26 +26,23 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -53,48 +50,48 @@ /* User data for looking up an object in a group */ typedef struct { /* upward */ - H5G_loc_t *loc; /* Group location to set */ + H5G_loc_t *loc; /* Group location to set */ } H5G_loc_fnd_t; /* User data for checking if an object exists */ typedef struct { /* upward */ - htri_t exists; /* Whether the object exists */ + htri_t exists; /* Whether the object exists */ } H5G_loc_exists_t; /* User data for looking up an object in a group by index */ typedef struct { /* downward */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Iteration order within index */ - hsize_t n; /* Offset within index */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Iteration order within index */ + hsize_t n; /* Offset within index */ /* upward */ - H5G_loc_t *loc; /* Group location to set */ + H5G_loc_t *loc; /* Group location to set */ } H5G_loc_fbi_t; /* User data for getting an object's data model info in a group */ typedef struct { /* downward */ - unsigned fields; /* which fields in H5O_info2_t struct to fill in */ + unsigned fields; /* which fields in H5O_info2_t struct to fill in */ /* upward */ - H5O_info2_t *oinfo; /* Object information to retrieve */ + H5O_info2_t *oinfo; /* Object information to retrieve */ } H5G_loc_info_t; /* User data for getting an object's native info in a group */ typedef struct { /* downward */ - unsigned fields; /* which fields in H5O_native_info_t struct to fill in */ + unsigned fields; /* which fields in H5O_native_info_t struct to fill in */ /* upward */ - H5O_native_info_t *oinfo; /* Object information to retrieve */ + H5O_native_info_t *oinfo; /* Object information to retrieve */ } H5G_loc_native_info_t; /* User data for setting an object's comment in a group */ typedef struct { /* downward */ - const char *comment; /* Object comment buffer */ + const char *comment; /* Object comment buffer */ /* upward */ } H5G_loc_sc_t; @@ -102,55 +99,45 @@ typedef struct { /* User data for getting an object's comment in a group */ typedef struct { /* downward */ - char *comment; /* Object comment buffer */ - size_t bufsize; /* Size of object comment buffer */ + char * comment; /* Object comment buffer */ + size_t bufsize; /* Size of object comment buffer */ /* upward */ - ssize_t comment_size; /* Actual size of object comment */ + ssize_t comment_size; /* Actual size of object comment */ } H5G_loc_gc_t; - /********************/ /* Local Prototypes */ /********************/ /* Group traversal callbacks */ -static herr_t H5G__loc_find_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, - H5G_own_loc_t *own_loc); -static herr_t H5G__loc_find_by_idx_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, - H5G_own_loc_t *own_loc); -static herr_t H5G__loc_addr_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); -static herr_t H5G__loc_info_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); -static herr_t H5G__loc_native_info_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); -static herr_t H5G__loc_set_comment_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, - H5G_own_loc_t *own_loc); -static herr_t H5G__loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, - H5G_own_loc_t *own_loc); - +static herr_t H5G__loc_find_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_find_by_idx_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_addr_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_info_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_native_info_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_set_comment_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G_loc_real * @@ -163,64 +150,59 @@ static herr_t H5G__loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - switch(type) { - case H5I_FILE: - { - H5F_t *f = (H5F_t *)obj; + switch (type) { + case H5I_FILE: { + H5F_t *f = (H5F_t *)obj; /* Construct a group location for root group of the file */ - if(H5G_root_loc(f, loc) < 0) + if (H5G_root_loc(f, loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") break; } - case H5I_GROUP: - { - H5G_t *group = (H5G_t *)obj; + case H5I_GROUP: { + H5G_t *group = (H5G_t *)obj; - if(NULL == (loc->oloc = H5G_oloc(group))) + if (NULL == (loc->oloc = H5G_oloc(group))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group") - if(NULL == (loc->path = H5G_nameof(group))) + if (NULL == (loc->path = H5G_nameof(group))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group") break; } - case H5I_DATATYPE: - { - H5T_t *dt = NULL; + case H5I_DATATYPE: { + H5T_t *dt = NULL; /* Get the actual datatype object if the VOL object is set */ dt = H5T_get_actual_type((H5T_t *)obj); - if(NULL == (loc->oloc = H5T_oloc(dt))) + if (NULL == (loc->oloc = H5T_oloc(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") - if(NULL == (loc->path = H5T_nameof(dt))) + if (NULL == (loc->path = H5T_nameof(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") break; } - case H5I_DATASET: - { - H5D_t *dset = (H5D_t *)obj; + case H5I_DATASET: { + H5D_t *dset = (H5D_t *)obj; - if(NULL == (loc->oloc = H5D_oloc(dset))) + if (NULL == (loc->oloc = H5D_oloc(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") - if(NULL == (loc->path = H5D_nameof(dset))) + if (NULL == (loc->path = H5D_nameof(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of dataset") break; } - case H5I_ATTR: - { - H5A_t *attr = (H5A_t *)obj; + case H5I_ATTR: { + H5A_t *attr = (H5A_t *)obj; - if(NULL == (loc->oloc = H5A_oloc(attr))) + if (NULL == (loc->oloc = H5A_oloc(attr))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute") - if(NULL == (loc->path = H5A_nameof(attr))) + if (NULL == (loc->path = H5A_nameof(attr))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of attribute") break; } @@ -238,16 +220,20 @@ H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) case H5I_ERROR_CLASS: case H5I_ERROR_MSG: case H5I_ERROR_STACK: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of error class, message or stack") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get group location of error class, message or stack") case H5I_VFL: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a virtual file driver (VFD)") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get group location of a virtual file driver (VFD)") case H5I_VOL: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a virtual object layer (VOL) connector") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get group location of a virtual object layer (VOL) connector") case H5I_SPACE_SEL_ITER: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a dataspace selection iterator") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get group location of a dataspace selection iterator") case H5I_UNINIT: case H5I_BADID: @@ -260,7 +246,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_real() */ - /*------------------------------------------------------------------------- * Function: H5G_loc * @@ -273,24 +258,23 @@ done: herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc) { - void *obj = NULL; /* VOL object */ - herr_t ret_value = SUCCEED; /* Return value */ + void * obj = NULL; /* VOL object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the object from the VOL */ - if(NULL == (obj = H5VL_object(loc_id))) + if (NULL == (obj = H5VL_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Fill in the struct */ - if(H5G_loc_real(obj, H5I_get_type(loc_id), loc) < 0) + if (H5G_loc_real(obj, H5I_get_type(loc_id), loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to fill in location struct") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_copy * @@ -306,7 +290,7 @@ done: herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -315,16 +299,15 @@ H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth) HDassert(src); /* Copy components of the location */ - if(H5O_loc_copy(dst->oloc, src->oloc, depth) < 0) + if (H5O_loc_copy(dst->oloc, src->oloc, depth) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") - if(H5G_name_copy(dst->path, src->path, depth) < 0) + if (H5G_name_copy(dst->path, src->path, depth) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to copy path") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_copy() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_reset * @@ -340,7 +323,7 @@ done: herr_t H5G_loc_reset(H5G_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -348,16 +331,15 @@ H5G_loc_reset(H5G_loc_t *loc) HDassert(loc); /* Reset components of the location */ - if(H5O_loc_reset(loc->oloc) < 0) + if (H5O_loc_reset(loc->oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset entry") - if(H5G_name_reset(loc->path) < 0) + if (H5G_name_reset(loc->path) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset path") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_reset() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_free * @@ -373,7 +355,7 @@ done: herr_t H5G_loc_free(H5G_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -381,16 +363,15 @@ H5G_loc_free(H5G_loc_t *loc) HDassert(loc); /* Reset components of the location */ - if(H5G_name_free(loc->path) < 0) + if (H5G_name_free(loc->path) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free path") - if(H5O_loc_free(loc->oloc) < 0) + if (H5O_loc_free(loc->oloc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to free object header location") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_free() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_find_cb * @@ -404,17 +385,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__loc_find_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5G__loc_find_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_fnd_t *udata = (H5G_loc_fnd_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_fnd_t *udata = (H5G_loc_fnd_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object '%s' doesn't exist", name) /* Take ownership of the object's group location */ @@ -428,7 +409,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_find_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_find * @@ -442,10 +422,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc/*out*/) +H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc /*out*/) { - H5G_loc_fnd_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_fnd_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -458,14 +438,13 @@ H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc/*out*/) udata.loc = obj_loc; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_find_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_find_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_find() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_find_by_idx_cb * @@ -480,47 +459,47 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__loc_find_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5G__loc_find_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_fbi_t *udata = (H5G_loc_fbi_t *)_udata; /* User data passed in */ - H5O_link_t fnd_lnk; /* Link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ - hbool_t obj_exists = FALSE; /* Whether the object exists (unused) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_fbi_t *udata = (H5G_loc_fbi_t *)_udata; /* User data passed in */ + H5O_link_t fnd_lnk; /* Link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ + hbool_t obj_exists = FALSE; /* Whether the object exists (unused) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if(H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) + if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "link not found") lnk_copied = TRUE; /* Build the initial object location for the link */ - if(H5G__link_to_loc(obj_loc, &fnd_lnk, udata->loc) < 0) + if (H5G__link_to_loc(obj_loc, &fnd_lnk, udata->loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot initialize object location") obj_loc_valid = TRUE; /* Perform any special traversals that the link needs */ /* (soft links, user-defined links, file mounting, etc.) */ /* (may modify the object location) */ - if(H5G__traverse_special(obj_loc, &fnd_lnk, H5G_TARGET_NORMAL, TRUE, udata->loc, &obj_exists) < 0) + if (H5G__traverse_special(obj_loc, &fnd_lnk, H5G_TARGET_NORMAL, TRUE, udata->loc, &obj_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "special link traversal failed") done: /* Reset the link information, if we have a copy */ - if(lnk_copied) + if (lnk_copied) H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); /* Release the object location if we failed after copying it */ - if(ret_value < 0 && obj_loc_valid) - if(H5G_loc_free(udata->loc) < 0) + if (ret_value < 0 && obj_loc_valid) + if (H5G_loc_free(udata->loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") /* Indicate that this callback didn't take ownership of the group * @@ -530,7 +509,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_find_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_find_by_idx * @@ -544,11 +522,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5G_loc_t *obj_loc/*out*/) +H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5G_loc_t *obj_loc /*out*/) { - H5G_loc_fbi_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_fbi_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -559,19 +537,18 @@ H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx /* Set up user data for locating object */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.loc = obj_loc; + udata.order = order; + udata.n = n; + udata.loc = obj_loc; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, group_name, H5G_TARGET_NORMAL, H5G__loc_find_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, group_name, H5G_TARGET_NORMAL, H5G__loc_find_by_idx_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_find_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_insert * @@ -585,11 +562,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, - H5O_type_t obj_type, const void *crt_info) +H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, + const void *crt_info) { - H5O_link_t lnk; /* Link for object to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t lnk; /* Link for object to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -599,27 +576,26 @@ H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, HDassert(obj_loc); /* Create link object for the object location */ - lnk.type = H5L_TYPE_HARD; - lnk.cset = H5F_DEFAULT_CSET; - lnk.corder = 0; /* Will be reset if the group is tracking creation order */ - lnk.corder_valid = FALSE; /* Indicate that the creation order isn't valid (yet) */ + lnk.type = H5L_TYPE_HARD; + lnk.cset = H5F_DEFAULT_CSET; + lnk.corder = 0; /* Will be reset if the group is tracking creation order */ + lnk.corder_valid = FALSE; /* Indicate that the creation order isn't valid (yet) */ /* Casting away const OK -QAK */ - lnk.name = (char *)name; + lnk.name = (char *)name; lnk.u.hard.addr = obj_loc->oloc->addr; /* Insert new group into current group's symbol table */ - if(H5G_obj_insert(grp_loc->oloc, name, &lnk, TRUE, obj_type, crt_info) < 0) + if (H5G_obj_insert(grp_loc->oloc, name, &lnk, TRUE, obj_type, crt_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert object") /* Set the name of the object location */ - if(H5G_name_set(grp_loc->path, obj_loc->path, name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot set name") + if (H5G_name_set(grp_loc->path, obj_loc->path, name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot set name") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_insert() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_exists_cb * @@ -633,17 +609,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5G_loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_exists_t *udata = (H5G_loc_exists_t *)_udata; /* User data passed in */ + H5G_loc_exists_t *udata = (H5G_loc_exists_t *)_udata; /* User data passed in */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check if the name in this group resolved to a valid object */ - if(obj_loc == NULL) - if(lnk) + if (obj_loc == NULL) + if (lnk) udata->exists = FALSE; else udata->exists = FAIL; @@ -657,7 +633,6 @@ H5G_loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UN FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_loc_exists_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_exists * @@ -674,8 +649,8 @@ H5G_loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UN htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name) { - H5G_loc_exists_t udata; /* User data for traversal callback */ - htri_t ret_value = FAIL; /* Return value */ + H5G_loc_exists_t udata; /* User data for traversal callback */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -687,7 +662,7 @@ H5G_loc_exists(const H5G_loc_t *loc, const char *name) udata.exists = FALSE; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_EXISTS, H5G_loc_exists_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_EXISTS, H5G_loc_exists_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't check if object exists") /* Set return value */ @@ -697,7 +672,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_exists() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_addr_cb * @@ -711,17 +685,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__loc_addr_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, - void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5G__loc_addr_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - haddr_t *udata = (haddr_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t *udata = (haddr_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Set address of object */ @@ -735,7 +709,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_addr_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_addr * @@ -750,9 +723,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr/*out*/) +H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -762,14 +735,13 @@ H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr/*out*/) HDassert(addr); /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_addr_cb, addr) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_addr_cb, addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_addr() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_info_cb * @@ -783,20 +755,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__loc_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t H5_ATTR_UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5G__loc_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_info_t *udata = (H5G_loc_info_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_info_t *udata = (H5G_loc_info_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Query object information */ - if(H5O_get_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) + if (H5O_get_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object info") done: @@ -807,7 +780,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_info_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_info * @@ -822,10 +794,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo/*out*/, unsigned fields) +H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo /*out*/, unsigned fields) { H5G_loc_info_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -836,17 +808,16 @@ H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo/*out*/, /* Set up user data for locating object */ udata.fields = fields; - udata.oinfo = oinfo; + udata.oinfo = oinfo; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_info_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_info_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_info() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_native_info_cb * @@ -860,20 +831,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__loc_native_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t H5_ATTR_UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5G__loc_native_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_native_info_t *udata = (H5G_loc_native_info_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_native_info_t *udata = (H5G_loc_native_info_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Query object information */ - if(H5O_get_native_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) + if (H5O_get_native_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object info") done: @@ -884,7 +856,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_native_info_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_native_info * @@ -899,11 +870,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *oinfo/*out*/, - unsigned fields) +H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *oinfo /*out*/, unsigned fields) { - H5G_loc_native_info_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_native_info_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -914,17 +884,16 @@ H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *o /* Set up user data for locating object */ udata.fields = fields; - udata.oinfo = oinfo; + udata.oinfo = oinfo; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_native_info_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_native_info_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_native_info() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_set_comment_cb * @@ -938,34 +907,36 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t H5_ATTR_UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */ - H5O_name_t comment; /* Object header "comment" message */ - htri_t exists; /* Whether a "comment" message already exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */ + H5O_name_t comment; /* Object header "comment" message */ + htri_t exists; /* Whether a "comment" message already exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Check for existing comment message */ - if((exists = H5O_msg_exists(obj_loc->oloc, H5O_NAME_ID)) < 0) + if ((exists = H5O_msg_exists(obj_loc->oloc, H5O_NAME_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") /* Remove the previous comment message if any */ - if(exists) - if(H5O_msg_remove(obj_loc->oloc, H5O_NAME_ID, 0, TRUE) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete existing comment object header message") + if (exists) + if (H5O_msg_remove(obj_loc->oloc, H5O_NAME_ID, 0, TRUE) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, + "unable to delete existing comment object header message") /* Add the new message */ - if(udata->comment && *udata->comment) { + if (udata->comment && *udata->comment) { /* Casting away const OK -QAK */ comment.s = (char *)udata->comment; - if(H5O_msg_create(obj_loc->oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment) < 0) + if (H5O_msg_create(obj_loc->oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message") } /* end if */ @@ -977,7 +948,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_set_comment_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_set_comment * @@ -994,8 +964,8 @@ done: herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment) { - H5G_loc_sc_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_sc_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1007,14 +977,13 @@ H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment) udata.comment = comment; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_set_comment_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_set_comment_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_set_comment() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_get_comment_cb * @@ -1028,28 +997,29 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__loc_get_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t H5_ATTR_UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5G__loc_get_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_gc_t *udata = (H5G_loc_gc_t *)_udata; /* User data passed in */ - H5O_name_t comment; /* Object header "comment" message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_gc_t *udata = (H5G_loc_gc_t *)_udata; /* User data passed in */ + H5O_name_t comment; /* Object header "comment" message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Query object comment */ comment.s = NULL; - if(NULL == H5O_msg_read(obj_loc->oloc, H5O_NAME_ID, &comment)) { - if(udata->comment && udata->bufsize > 0) + if (NULL == H5O_msg_read(obj_loc->oloc, H5O_NAME_ID, &comment)) { + if (udata->comment && udata->bufsize > 0) udata->comment[0] = '\0'; udata->comment_size = 0; } else { - if(udata->comment && udata->bufsize) + if (udata->comment && udata->bufsize) HDstrncpy(udata->comment, comment.s, udata->bufsize); udata->comment_size = (ssize_t)HDstrlen(comment.s); H5O_msg_reset(H5O_NAME_ID, &comment); @@ -1064,7 +1034,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_get_comment_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_get_comment * @@ -1083,11 +1052,10 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment/*out*/, - size_t bufsize) +H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out*/, size_t bufsize) { - H5G_loc_gc_t udata; /* User data for traversal callback */ - ssize_t ret_value = -1; /* Return value */ + H5G_loc_gc_t udata; /* User data for traversal callback */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1096,12 +1064,12 @@ H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment/*out*/ HDassert(name && *name); /* Set up user data for locating object */ - udata.comment = comment; - udata.bufsize = bufsize; + udata.comment = comment; + udata.bufsize = bufsize; udata.comment_size = (-1); /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_get_comment_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_get_comment_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") /* Set the return value */ @@ -1110,4 +1078,3 @@ H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment/*out*/ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_get_comment() */ - diff --git a/src/H5Gmodule.h b/src/H5Gmodule.h index 19ea982..1711863 100644 --- a/src/H5Gmodule.h +++ b/src/H5Gmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5G_MODULE -#define H5_MY_PKG H5G -#define H5_MY_PKG_ERR H5E_SYM -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5G +#define H5_MY_PKG_ERR H5E_SYM +#define H5_MY_PKG_INIT YES #endif /* _H5Gmodule_H */ - diff --git a/src/H5Gname.c b/src/H5Gname.c index e1004de..6bbaf16 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -26,70 +26,65 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory wrappers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory wrappers */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Struct used by change name callback function */ typedef struct H5G_names_t { - H5G_names_op_t op; /* Operation performed on file */ - H5F_t *src_file; /* Top file in src location's mounted file hier. */ - H5RS_str_t *src_full_path_r; /* Source location's full path */ - H5F_t *dst_file; /* Destination location's file */ - H5RS_str_t *dst_full_path_r; /* Destination location's full path */ + H5G_names_op_t op; /* Operation performed on file */ + H5F_t * src_file; /* Top file in src location's mounted file hier. */ + H5RS_str_t * src_full_path_r; /* Source location's full path */ + H5F_t * dst_file; /* Destination location's file */ + H5RS_str_t * dst_full_path_r; /* Destination location's full path */ } H5G_names_t; /* Info to pass to the iteration function when building name */ typedef struct H5G_gnba_iter_t { /* In */ - const H5O_loc_t *loc; /* The location of the object we're looking for */ + const H5O_loc_t *loc; /* The location of the object we're looking for */ /* Out */ - char *path; /* Name of the object */ + char *path; /* Name of the object */ } H5G_gnba_iter_t; /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static htri_t H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r); +static htri_t H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r); static H5RS_str_t *H5G_build_fullpath(const char *prefix, const char *name); #ifdef NOT_YET static H5RS_str_t *H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r); #endif /* NOT_YET */ -static herr_t H5G_name_move_path(H5RS_str_t **path_r_ptr, - const char *full_suffix, const char *src_path, const char *dst_path); -static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key); - +static herr_t H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path, + const char *dst_path); +static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key); /*********************/ /* Package Variables */ @@ -98,18 +93,14 @@ static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key); /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__component * @@ -142,7 +133,6 @@ H5G__component(const char *name, size_t *size_p) FUNC_LEAVE_NOAPI(name) } /* end H5G__component() */ - /*------------------------------------------------------------------------- * Function: H5G_normalize * @@ -160,10 +150,10 @@ H5G__component(const char *name, size_t *size_p) char * H5G_normalize(const char *name) { - char *norm; /* Pointer to the normalized string */ - size_t s,d; /* Positions within the strings */ - unsigned last_slash; /* Flag to indicate last character was a slash */ - char *ret_value = NULL; /* Return value */ + char * norm; /* Pointer to the normalized string */ + size_t s, d; /* Positions within the strings */ + unsigned last_slash; /* Flag to indicate last character was a slash */ + char * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -171,22 +161,22 @@ H5G_normalize(const char *name) HDassert(name); /* Duplicate the name, to return */ - if(NULL == (norm = H5MM_strdup(name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string") + if (NULL == (norm = H5MM_strdup(name))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string") /* Walk through the characters, omitting duplicated '/'s */ - s = d = 0; + s = d = 0; last_slash = 0; - while(name[s] != '\0') { - if(name[s] == '/') - if(last_slash) + while (name[s] != '\0') { + if (name[s] == '/') + if (last_slash) ; else { - norm[d++] = name[s]; + norm[d++] = name[s]; last_slash = 1; } /* end else */ else { - norm[d++] = name[s]; + norm[d++] = name[s]; last_slash = 0; } /* end else */ s++; @@ -196,7 +186,7 @@ H5G_normalize(const char *name) norm[d] = '\0'; /* Check for final '/' on normalized name & eliminate it */ - if(d > 1 && last_slash) + if (d > 1 && last_slash) norm[d - 1] = '\0'; /* Set return value */ @@ -206,7 +196,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_normalize() */ - /*------------------------------------------------------------------------- * Function: H5G_common_path * @@ -224,37 +213,37 @@ done: static htri_t H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) { - const char *fullpath; /* Pointer to actual fullpath string */ - const char *prefix; /* Pointer to actual prefix string */ - size_t nchars1,nchars2; /* Number of characters in components */ - htri_t ret_value=FALSE; /* Return value */ + const char *fullpath; /* Pointer to actual fullpath string */ + const char *prefix; /* Pointer to actual prefix string */ + size_t nchars1, nchars2; /* Number of characters in components */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Get component of each name */ - fullpath=H5RS_get_str(fullpath_r); + fullpath = H5RS_get_str(fullpath_r); HDassert(fullpath); - fullpath=H5G__component(fullpath,&nchars1); + fullpath = H5G__component(fullpath, &nchars1); HDassert(fullpath); - prefix=H5RS_get_str(prefix_r); + prefix = H5RS_get_str(prefix_r); HDassert(prefix); - prefix=H5G__component(prefix,&nchars2); + prefix = H5G__component(prefix, &nchars2); HDassert(prefix); /* Check if we have a real string for each component */ - while(*fullpath && *prefix) { + while (*fullpath && *prefix) { /* Check that the components we found are the same length */ - if(nchars1==nchars2) { + if (nchars1 == nchars2) { /* Check that the two components are equal */ - if(HDstrncmp(fullpath,prefix,nchars1)==0) { + if (HDstrncmp(fullpath, prefix, nchars1) == 0) { /* Advance the pointers in the names */ - fullpath+=nchars1; - prefix+=nchars2; + fullpath += nchars1; + prefix += nchars2; /* Get next component of each name */ - fullpath=H5G__component(fullpath,&nchars1); + fullpath = H5G__component(fullpath, &nchars1); HDassert(fullpath); - prefix=H5G__component(prefix,&nchars2); + prefix = H5G__component(prefix, &nchars2); HDassert(prefix); } /* end if */ else @@ -265,14 +254,13 @@ H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) } /* end while */ /* If we reached the end of the prefix path to check, it must be a valid prefix */ - if(*prefix=='\0') - ret_value=TRUE; + if (*prefix == '\0') + ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_common_path() */ - /*------------------------------------------------------------------------- * Function: H5G_build_fullpath * @@ -289,12 +277,12 @@ done: static H5RS_str_t * H5G_build_fullpath(const char *prefix, const char *name) { - char *full_path; /* Full user path built */ - size_t orig_path_len; /* Original length of the path */ - size_t path_len; /* Length of the path */ - size_t name_len; /* Length of the name */ - unsigned need_sep; /* Flag to indicate if separator is needed */ - H5RS_str_t *ret_value = NULL; /* Return value */ + char * full_path; /* Full user path built */ + size_t orig_path_len; /* Original length of the path */ + size_t path_len; /* Length of the path */ + size_t name_len; /* Length of the name */ + unsigned need_sep; /* Flag to indicate if separator is needed */ + H5RS_str_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -306,7 +294,7 @@ H5G_build_fullpath(const char *prefix, const char *name) orig_path_len = path_len = HDstrlen(prefix); /* Determine if there is a trailing separator in the name */ - if(prefix[path_len - 1] == '/') + if (prefix[path_len - 1] == '/') need_sep = 0; else need_sep = 1; @@ -316,24 +304,23 @@ H5G_build_fullpath(const char *prefix, const char *name) path_len += name_len + need_sep; /* Allocate space for the path */ - if(NULL == (full_path = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) + if (NULL == (full_path = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Build full path */ HDstrncpy(full_path, prefix, orig_path_len + 1); - if(need_sep) + if (need_sep) HDstrncat(full_path, "/", (size_t)1); HDstrncat(full_path, name, name_len); /* Create reference counted string for path */ - if(NULL == (ret_value = H5RS_own(full_path))) + if (NULL == (ret_value = H5RS_own(full_path))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_build_fullpath() */ - /*------------------------------------------------------------------------- * Function: H5G_build_fullpath_refstr_str * @@ -350,8 +337,8 @@ done: H5RS_str_t * H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) { - const char *prefix; /* Pointer to raw string for path */ - H5RS_str_t *ret_value = NULL; /* Return value */ + const char *prefix; /* Pointer to raw string for path */ + H5RS_str_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -369,7 +356,7 @@ H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) } /* end H5G_build_fullpath_refstr_str() */ #ifdef NOT_YET - + /*------------------------------------------------------------------------- * Function: H5G_name_build_refstr_refstr * @@ -387,9 +374,9 @@ H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) static H5RS_str_t * H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r) { - const char *prefix; /* Pointer to raw string of prefix */ - const char *name; /* Pointer to raw string of name */ - H5RS_str_t *ret_value; /* Return value */ + const char *prefix; /* Pointer to raw string of prefix */ + const char *name; /* Pointer to raw string of name */ + H5RS_str_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -406,7 +393,6 @@ H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *n } /* end H5G_build_fullpath_refstr_refstr() */ #endif /* NOT_YET */ - /*------------------------------------------------------------------------- * Function: H5G__name_init * @@ -438,7 +424,6 @@ H5G__name_init(H5G_name_t *name, const char *path) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__name_init() */ - /*------------------------------------------------------------------------- * Function: H5G_name_set * @@ -455,7 +440,7 @@ H5G__name_init(H5G_name_t *name, const char *path) herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -467,16 +452,16 @@ H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name) H5G_name_free(obj); /* Create the object's full path, if a full path exists in the location */ - if(loc->full_path_r) { + if (loc->full_path_r) { /* Go build the new full path */ - if((obj->full_path_r = H5G_build_fullpath_refstr_str(loc->full_path_r, name)) == NULL) + if ((obj->full_path_r = H5G_build_fullpath_refstr_str(loc->full_path_r, name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name") } /* end if */ /* Create the object's user path, if a user path exists in the location */ - if(loc->user_path_r) { + if (loc->user_path_r) { /* Go build the new user path */ - if((obj->user_path_r = H5G_build_fullpath_refstr_str(loc->user_path_r, name)) == NULL) + if ((obj->user_path_r = H5G_build_fullpath_refstr_str(loc->user_path_r, name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name") } /* end if */ @@ -484,7 +469,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_name_set() */ - /*------------------------------------------------------------------------- * Function: H5G_name_copy * @@ -526,10 +510,11 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) H5MM_memcpy(dst, src, sizeof(H5G_name_t)); /* Deep copy the names */ - if(depth == H5_COPY_DEEP) { + if (depth == H5_COPY_DEEP) { dst->full_path_r = H5RS_dup(src->full_path_r); dst->user_path_r = H5RS_dup(src->user_path_r); - } else { + } + else { /* Discarding 'const' qualifier OK - QAK */ H5G_name_reset((H5G_name_t *)src); } /* end if */ @@ -537,7 +522,6 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_name_copy() */ - /*------------------------------------------------------------------------- * Function: H5G_get_name * @@ -554,11 +538,10 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) *------------------------------------------------------------------------- */ ssize_t -H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, - hbool_t *cached) +H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cached) { - ssize_t len = 0; /* Length of object's name */ - ssize_t ret_value = -1; /* Return value */ + ssize_t len = 0; /* Length of object's name */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -566,28 +549,28 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, HDassert(loc); /* If the user path is available and it's not "hidden", use it */ - if(loc->path->user_path_r != NULL && loc->path->obj_hidden == 0) { + if (loc->path->user_path_r != NULL && loc->path->obj_hidden == 0) { len = H5RS_len(loc->path->user_path_r); - if(name) { + if (name) { HDstrncpy(name, H5RS_get_str(loc->path->user_path_r), MIN((size_t)(len + 1), size)); - if((size_t)len >= size) + if ((size_t)len >= size) name[size - 1] = '\0'; } /* end if */ /* Indicate that the name is cached, if requested */ /* (Currently only used for testing - QAK, 2010/07/26) */ - if(cached) + if (cached) *cached = TRUE; } /* end if */ - else if(!loc->path->obj_hidden) { + else if (!loc->path->obj_hidden) { /* Search for name of object */ - if((len = H5G_get_name_by_addr(loc->oloc->file, loc->oloc, name, size)) < 0) + if ((len = H5G_get_name_by_addr(loc->oloc->file, loc->oloc, name, size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name") /* Indicate that the name is _not_ cached, if requested */ /* (Currently only used for testing - QAK, 2010/07/26) */ - if(cached) + if (cached) *cached = FALSE; } /* end else */ @@ -598,7 +581,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_name() */ - /*------------------------------------------------------------------------- * Function: H5G_name_reset * @@ -626,7 +608,6 @@ H5G_name_reset(H5G_name_t *name) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_name_reset() */ - /*------------------------------------------------------------------------- * Function: H5G_name_free * @@ -648,11 +629,11 @@ H5G_name_free(H5G_name_t *name) /* Check args */ HDassert(name); - if(name->full_path_r) { + if (name->full_path_r) { H5RS_decr(name->full_path_r); name->full_path_r = NULL; } /* end if */ - if(name->user_path_r) { + if (name->user_path_r) { H5RS_decr(name->user_path_r); name->user_path_r = NULL; } /* end if */ @@ -661,7 +642,6 @@ H5G_name_free(H5G_name_t *name) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_name_free() */ - /*------------------------------------------------------------------------- * Function: H5G_name_move_path * @@ -677,12 +657,12 @@ H5G_name_free(H5G_name_t *name) */ static herr_t H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path, - const char *dst_path) + const char *dst_path) { - const char *path; /* Path to update */ - size_t path_len; /* Length of path */ - size_t full_suffix_len; /* Length of full suffix */ - herr_t ret_value = SUCCEED; /* Return value */ + const char *path; /* Path to update */ + size_t path_len; /* Length of path */ + size_t full_suffix_len; /* Length of full suffix */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -698,31 +678,30 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char /* Check if path needs to be updated */ full_suffix_len = HDstrlen(full_suffix); - path_len = HDstrlen(path); - if(full_suffix_len < path_len) { - const char *dst_suffix; /* Destination suffix that changes */ - size_t dst_suffix_len; /* Length of destination suffix */ - const char *src_suffix; /* Source suffix that changes */ - size_t path_prefix_len; /* Length of path prefix */ - const char *path_prefix2; /* 2nd prefix for path */ - size_t path_prefix2_len; /* Length of 2nd path prefix */ - const char *common_prefix; /* Common prefix for src & dst paths */ - size_t common_prefix_len; /* Length of common prefix */ - char *new_path; /* Pointer to new path */ - size_t new_path_len; /* Length of new path */ - + path_len = HDstrlen(path); + if (full_suffix_len < path_len) { + const char *dst_suffix; /* Destination suffix that changes */ + size_t dst_suffix_len; /* Length of destination suffix */ + const char *src_suffix; /* Source suffix that changes */ + size_t path_prefix_len; /* Length of path prefix */ + const char *path_prefix2; /* 2nd prefix for path */ + size_t path_prefix2_len; /* Length of 2nd path prefix */ + const char *common_prefix; /* Common prefix for src & dst paths */ + size_t common_prefix_len; /* Length of common prefix */ + char * new_path; /* Pointer to new path */ + size_t new_path_len; /* Length of new path */ /* Compute path prefix before full suffix*/ path_prefix_len = path_len - full_suffix_len; /* Determine the common prefix for src & dst paths */ - common_prefix = src_path; + common_prefix = src_path; common_prefix_len = 0; /* Find first character that is different */ - while(*(src_path + common_prefix_len) == *(dst_path + common_prefix_len)) + while (*(src_path + common_prefix_len) == *(dst_path + common_prefix_len)) common_prefix_len++; /* Back up to previous '/' */ - while(*(common_prefix + common_prefix_len) != '/') + while (*(common_prefix + common_prefix_len) != '/') common_prefix_len--; /* Include '/' */ common_prefix_len++; @@ -731,26 +710,26 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char src_suffix = src_path + (common_prefix_len - 1); /* Determine destination suffix */ - dst_suffix = dst_path + (common_prefix_len - 1); + dst_suffix = dst_path + (common_prefix_len - 1); dst_suffix_len = HDstrlen(dst_suffix); /* Compute path prefix before src suffix*/ - path_prefix2 = path; + path_prefix2 = path; path_prefix2_len = path_prefix_len - HDstrlen(src_suffix); /* Allocate space for the new path */ new_path_len = path_prefix2_len + dst_suffix_len + full_suffix_len; - if(NULL == (new_path = (char *)H5FL_BLK_MALLOC(str_buf, new_path_len + 1))) + if (NULL == (new_path = (char *)H5FL_BLK_MALLOC(str_buf, new_path_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new path */ - if(path_prefix2_len > 0) { + if (path_prefix2_len > 0) { HDstrncpy(new_path, path_prefix2, path_prefix2_len + 1); HDstrncpy(new_path + path_prefix2_len, dst_suffix, dst_suffix_len + 1); } /* end if */ else HDstrncpy(new_path, dst_suffix, dst_suffix_len + 1); - if(full_suffix_len > 0) + if (full_suffix_len > 0) HDstrncat(new_path, full_suffix, full_suffix_len); /* Release previous path */ @@ -764,7 +743,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_name_move_path() */ - /*------------------------------------------------------------------------- * Function: H5G_name_replace_cb * @@ -781,35 +759,35 @@ done: static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) { - const H5G_names_t *names = (const H5G_names_t *)key; /* Get operation's information */ - H5O_loc_t *oloc; /* Object location for object that the ID refers to */ - H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ - H5F_t *top_obj_file; /* Top file in object's mounted file hier. */ - hbool_t obj_in_child = FALSE; /* Flag to indicate that the object is in the child mount hier. */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5G_names_t *names = (const H5G_names_t *)key; /* Get operation's information */ + H5O_loc_t * oloc; /* Object location for object that the ID refers to */ + H5G_name_t * obj_path; /* Pointer to group hier. path for obj */ + H5F_t * top_obj_file; /* Top file in object's mounted file hier. */ + hbool_t obj_in_child = FALSE; /* Flag to indicate that the object is in the child mount hier. */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(obj_ptr); /* Get the symbol table entry */ - switch(H5I_get_type(obj_id)) { + switch (H5I_get_type(obj_id)) { case H5I_GROUP: - oloc = H5G_oloc((H5G_t *)obj_ptr); + oloc = H5G_oloc((H5G_t *)obj_ptr); obj_path = H5G_nameof((H5G_t *)obj_ptr); break; case H5I_DATASET: - oloc = H5D_oloc((H5D_t *)obj_ptr); + oloc = H5D_oloc((H5D_t *)obj_ptr); obj_path = H5D_nameof((H5D_t *)obj_ptr); break; case H5I_DATATYPE: /* Avoid non-named datatypes */ - if(!H5T_is_named((H5T_t *)obj_ptr)) - HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */ + if (!H5T_is_named((H5T_t *)obj_ptr)) + HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */ - oloc = H5T_oloc((H5T_t *)obj_ptr); + oloc = H5T_oloc((H5T_t *)obj_ptr); obj_path = H5T_nameof((H5T_t *)obj_ptr); break; @@ -837,60 +815,60 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) HDassert(obj_path); /* Check if the object has a full path still */ - if(!obj_path->full_path_r) - HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ + if (!obj_path->full_path_r) + HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ /* Find the top file in object's mount hier. */ - if(H5F_PARENT(oloc->file)) { + if (H5F_PARENT(oloc->file)) { /* Check if object is in child file (for mount & unmount operations) */ - if(names->dst_file && H5F_SAME_SHARED(oloc->file, names->dst_file)) + if (names->dst_file && H5F_SAME_SHARED(oloc->file, names->dst_file)) obj_in_child = TRUE; /* Find the "top" file in the chain of mounted files */ top_obj_file = H5F_PARENT(oloc->file); - while(H5F_PARENT(top_obj_file) != NULL) { + while (H5F_PARENT(top_obj_file) != NULL) { /* Check if object is in child mount hier. (for mount & unmount operations) */ - if(names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file)) + if (names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file)) obj_in_child = TRUE; top_obj_file = H5F_PARENT(top_obj_file); } /* end while */ - } /* end if */ + } /* end if */ else top_obj_file = oloc->file; /* Check if object is in top of child mount hier. (for mount & unmount operations) */ - if(names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file)) + if (names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file)) obj_in_child = TRUE; /* Check if the object is in same file mount hier. */ - if(!H5F_SAME_SHARED(top_obj_file, names->src_file)) - HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ + if (!H5F_SAME_SHARED(top_obj_file, names->src_file)) + HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ - switch(names->op) { + switch (names->op) { /*------------------------------------------------------------------------- * H5G_NAME_MOUNT *------------------------------------------------------------------------- */ case H5G_NAME_MOUNT: /* Check if object is in child mount hier. */ - if(obj_in_child) { - const char *full_path; /* Full path of current object */ - const char *src_path; /* Full path of source object */ - size_t src_path_len; /* Length of source full path */ - char *new_full_path; /* New full path of object */ - size_t new_full_len; /* Length of new full path */ + if (obj_in_child) { + const char *full_path; /* Full path of current object */ + const char *src_path; /* Full path of source object */ + size_t src_path_len; /* Length of source full path */ + char * new_full_path; /* New full path of object */ + size_t new_full_len; /* Length of new full path */ /* Get pointers to paths of interest */ - full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->src_full_path_r); + full_path = H5RS_get_str(obj_path->full_path_r); + src_path = H5RS_get_str(names->src_full_path_r); src_path_len = HDstrlen(src_path); /* Build new full path */ /* Allocate space for the new full path */ new_full_len = src_path_len + HDstrlen(full_path); - if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) + if (NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new full path */ @@ -907,12 +885,12 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) else { /* Check if the source is along the entry's path */ /* (But not actually the entry itself) */ - if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r) && - H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { + if (H5G_common_path(obj_path->full_path_r, names->src_full_path_r) && + H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { /* Hide the user path */ (obj_path->obj_hidden)++; } /* end if */ - } /* end else */ + } /* end else */ break; /*------------------------------------------------------------------------- @@ -920,25 +898,25 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) *------------------------------------------------------------------------- */ case H5G_NAME_UNMOUNT: - if(obj_in_child) { - const char *full_path; /* Full path of current object */ - const char *full_suffix; /* Full path after source path */ - size_t full_suffix_len; /* Length of full path after source path */ - const char *src_path; /* Full path of source object */ - char *new_full_path; /* New full path of object */ + if (obj_in_child) { + const char *full_path; /* Full path of current object */ + const char *full_suffix; /* Full path after source path */ + size_t full_suffix_len; /* Length of full path after source path */ + const char *src_path; /* Full path of source object */ + char * new_full_path; /* New full path of object */ /* Get pointers to paths of interest */ full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->src_full_path_r); + src_path = H5RS_get_str(names->src_full_path_r); /* Construct full path suffix */ - full_suffix = full_path + HDstrlen(src_path); + full_suffix = full_path + HDstrlen(src_path); full_suffix_len = HDstrlen(full_suffix); /* Build new full path */ /* Create the new full path */ - if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, full_suffix_len + 1))) + if (NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, full_suffix_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrncpy(new_full_path, full_suffix, full_suffix_len + 1); @@ -949,20 +927,21 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) obj_path->full_path_r = H5RS_own(new_full_path); /* Check if the object's user path should be invalidated */ - if(obj_path->user_path_r && HDstrlen(new_full_path) < (size_t)H5RS_len(obj_path->user_path_r)) { + if (obj_path->user_path_r && + HDstrlen(new_full_path) < (size_t)H5RS_len(obj_path->user_path_r)) { /* Free user path */ H5RS_decr(obj_path->user_path_r); obj_path->user_path_r = NULL; } /* end if */ - } /* end if */ + } /* end if */ else { /* Check if file being unmounted was hiding the object */ - if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r) && - H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { + if (H5G_common_path(obj_path->full_path_r, names->src_full_path_r) && + H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { /* Un-hide the user path */ (obj_path->obj_hidden)--; } /* end if */ - } /* end else */ + } /* end else */ break; /*------------------------------------------------------------------------- @@ -971,7 +950,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) */ case H5G_NAME_DELETE: /* Check if the location being unlinked is in the path for the current object */ - if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) { + if (H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) { /* Free paths for object */ H5G_name_free(obj_path); } /* end if */ @@ -983,23 +962,23 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) */ case H5G_NAME_MOVE: /* Link move case, check for relative names case */ /* Check if the src object moved is in the current object's path */ - if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) { - const char *full_path; /* Full path of current object */ - const char *full_suffix; /* Suffix of full path, after src_path */ - size_t full_suffix_len; /* Length of suffix of full path after src_path*/ - char *new_full_path; /* New full path of object */ - size_t new_full_len; /* Length of new full path */ - const char *src_path; /* Full path of source object */ - const char *dst_path; /* Full path of destination object */ - size_t dst_path_len; /* Length of destination's full path */ + if (H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) { + const char *full_path; /* Full path of current object */ + const char *full_suffix; /* Suffix of full path, after src_path */ + size_t full_suffix_len; /* Length of suffix of full path after src_path*/ + char * new_full_path; /* New full path of object */ + size_t new_full_len; /* Length of new full path */ + const char *src_path; /* Full path of source object */ + const char *dst_path; /* Full path of destination object */ + size_t dst_path_len; /* Length of destination's full path */ /* Sanity check */ HDassert(names->dst_full_path_r); /* Get pointers to paths of interest */ - full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->src_full_path_r); - dst_path = H5RS_get_str(names->dst_full_path_r); + full_path = H5RS_get_str(obj_path->full_path_r); + src_path = H5RS_get_str(names->src_full_path_r); + dst_path = H5RS_get_str(names->dst_full_path_r); dst_path_len = HDstrlen(dst_path); /* Make certain that the source and destination names are full (not relative) paths */ @@ -1007,19 +986,19 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) HDassert(*dst_path == '/'); /* Get pointer to "full suffix" */ - full_suffix = full_path + HDstrlen(src_path); + full_suffix = full_path + HDstrlen(src_path); full_suffix_len = HDstrlen(full_suffix); /* Update the user path, if one exists */ - if(obj_path->user_path_r) - if(H5G_name_move_path(&(obj_path->user_path_r), full_suffix, src_path, dst_path) < 0) + if (obj_path->user_path_r) + if (H5G_name_move_path(&(obj_path->user_path_r), full_suffix, src_path, dst_path) < 0) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name") /* Build new full path */ /* Allocate space for the new full path */ new_full_len = dst_path_len + full_suffix_len; - if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) + if (NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new full path */ @@ -1042,7 +1021,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5G_name_replace_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_name_replace * @@ -1062,8 +1040,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, - H5RS_str_t *src_full_path_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r) +H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, H5RS_str_t *src_full_path_r, + H5F_t *dst_file, H5RS_str_t *dst_full_path_r) { herr_t ret_value = SUCCEED; @@ -1073,56 +1051,56 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, HDassert(src_file); /* Check if the object we are manipulating has a path */ - if(src_full_path_r) { - hbool_t search_group = FALSE; /* Flag to indicate that groups are to be searched */ - hbool_t search_dataset = FALSE; /* Flag to indicate that datasets are to be searched */ + if (src_full_path_r) { + hbool_t search_group = FALSE; /* Flag to indicate that groups are to be searched */ + hbool_t search_dataset = FALSE; /* Flag to indicate that datasets are to be searched */ hbool_t search_datatype = FALSE; /* Flag to indicate that datatypes are to be searched */ /* Check for particular link to operate on */ - if(lnk) { + if (lnk) { /* Look up the object type for each type of link */ - switch(lnk->type) { - case H5L_TYPE_HARD: - { - H5O_loc_t tmp_oloc; /* Temporary object location */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = src_file; - tmp_oloc.addr = lnk->u.hard.addr; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - - /* Determine which type of objects to operate on */ - switch(obj_type) { - case H5O_TYPE_GROUP: - /* Search and replace names through group IDs */ - search_group = TRUE; - break; - - case H5O_TYPE_DATASET: - /* Search and replace names through dataset IDs */ - search_dataset = TRUE; - break; - - case H5O_TYPE_NAMED_DATATYPE: - /* Search and replace names through datatype IDs */ - search_datatype = TRUE; - break; - - case H5O_TYPE_MAP: - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector") - - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - /* Search and replace names through datatype IDs */ - default: - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not valid object type") - } /* end switch */ - } /* end case */ - break; + switch (lnk->type) { + case H5L_TYPE_HARD: { + H5O_loc_t tmp_oloc; /* Temporary object location */ + H5O_type_t obj_type; /* Type of object at location */ + + /* Build temporary object location */ + tmp_oloc.file = src_file; + tmp_oloc.addr = lnk->u.hard.addr; + + /* Get the type of the object */ + if (H5O_obj_type(&tmp_oloc, &obj_type) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + + /* Determine which type of objects to operate on */ + switch (obj_type) { + case H5O_TYPE_GROUP: + /* Search and replace names through group IDs */ + search_group = TRUE; + break; + + case H5O_TYPE_DATASET: + /* Search and replace names through dataset IDs */ + search_dataset = TRUE; + break; + + case H5O_TYPE_NAMED_DATATYPE: + /* Search and replace names through datatype IDs */ + search_datatype = TRUE; + break; + + case H5O_TYPE_MAP: + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, + "maps not supported in native VOL connector") + + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + /* Search and replace names through datatype IDs */ + default: + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not valid object type") + } /* end switch */ + } /* end case */ + break; case H5L_TYPE_SOFT: /* Symbolic links might resolve to any object, so we need to search all IDs */ @@ -1132,10 +1110,10 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: - default: /* User-defined link */ + default: /* User-defined link */ /* Check for unknown library-defined link type */ - if(lnk->type < H5L_TYPE_UD_MIN) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") + if (lnk->type < H5L_TYPE_UD_MIN) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") /* User-defined & external links automatically wipe out * names (because it would be too much work to track them), @@ -1143,49 +1121,48 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, */ break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* We pass NULL as link pointer when we need to search all IDs */ search_group = search_dataset = search_datatype = TRUE; } /* Check if we need to operate on the objects affected */ - if(search_group || search_dataset || search_datatype) { - H5G_names_t names; /* Structure to hold operation information for callback */ + if (search_group || search_dataset || search_datatype) { + H5G_names_t names; /* Structure to hold operation information for callback */ /* Find top file in src location's mount hierarchy */ - while(H5F_PARENT(src_file)) + while (H5F_PARENT(src_file)) src_file = H5F_PARENT(src_file); /* Set up common information for callback */ - names.src_file = src_file; - names.src_full_path_r = src_full_path_r; - names.dst_file = dst_file; - names.dst_full_path_r = dst_full_path_r; - names.op = op; + names.src_file = src_file; + names.src_full_path_r = src_full_path_r; + names.dst_file = dst_file; + names.dst_full_path_r = dst_full_path_r; + names.op = op; /* Search through group IDs */ - if(search_group) - if(H5I_iterate(H5I_GROUP, H5G_name_replace_cb, &names, FALSE) < 0) + if (search_group) + if (H5I_iterate(H5I_GROUP, H5G_name_replace_cb, &names, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over groups") /* Search through dataset IDs */ - if(search_dataset) - if(H5I_iterate(H5I_DATASET, H5G_name_replace_cb, &names, FALSE) < 0) + if (search_dataset) + if (H5I_iterate(H5I_DATASET, H5G_name_replace_cb, &names, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over datasets") /* Search through datatype IDs */ - if(search_datatype) - if(H5I_iterate(H5I_DATATYPE, H5G_name_replace_cb, &names, FALSE) < 0) + if (search_datatype) + if (H5I_iterate(H5I_DATATYPE, H5G_name_replace_cb, &names, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over datatypes") } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_name_replace() */ - /*------------------------------------------------------------------------- * Function: H5G_get_name_by_addr_cb * @@ -1201,15 +1178,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info2_t *linfo, - void *_udata) +H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info2_t *linfo, void *_udata) { H5G_gnba_iter_t *udata = (H5G_gnba_iter_t *)_udata; /* User data for iteration */ - H5G_loc_t obj_loc; /* Location of object */ - H5G_name_t obj_path; /* Object's group hier. path */ - H5O_loc_t obj_oloc; /* Object's object location */ - hbool_t obj_found = FALSE; /* Object at 'path' found */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5G_loc_t obj_loc; /* Location of object */ + H5G_name_t obj_path; /* Object's group hier. path */ + H5O_loc_t obj_oloc; /* Object's object location */ + hbool_t obj_found = FALSE; /* Object at 'path' found */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1220,18 +1196,18 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info2_t *linfo, HDassert(udata->path == NULL); /* Check for hard link with correct address */ - if(linfo->type == H5L_TYPE_HARD) { + if (linfo->type == H5L_TYPE_HARD) { haddr_t link_addr; /* Retrieve hard link address from VOL token */ - if(H5VL_native_token_to_addr(udata->loc->file, H5I_FILE, linfo->u.token, &link_addr) < 0) + if (H5VL_native_token_to_addr(udata->loc->file, H5I_FILE, linfo->u.token, &link_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") - if(udata->loc->addr == link_addr) { - H5G_loc_t grp_loc; /* Location of group */ + if (udata->loc->addr == link_addr) { + H5G_loc_t grp_loc; /* Location of group */ /* Get group's location */ - if(H5G_loc(gid, &grp_loc) < 0) + if (H5G_loc(gid, &grp_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "bad group location") /* Set up opened object location to fill in */ @@ -1240,30 +1216,29 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info2_t *linfo, H5G_loc_reset(&obj_loc); /* Find the object */ - if(H5G_loc_find(&grp_loc, path, &obj_loc/*out*/) < 0) + if (H5G_loc_find(&grp_loc, path, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") obj_found = TRUE; /* Check for object in same file (handles mounted files) */ /* (re-verify address, in case we traversed a file mount) */ - if(udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) { - if(NULL == (udata->path = H5MM_strdup(path))) + if (udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) { + if (NULL == (udata->path = H5MM_strdup(path))) HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string") /* We found a match so we return immediately */ HGOTO_DONE(H5_ITER_STOP) } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: - if(obj_found && H5G_loc_free(&obj_loc) < 0) + if (obj_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_name_by_addr_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_get_name_by_addr * @@ -1283,11 +1258,11 @@ done: ssize_t H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size) { - H5G_gnba_iter_t udata; /* User data for iteration */ - H5G_loc_t root_loc; /* Root group's location */ - hbool_t found_obj = FALSE; /* If we found the object */ - herr_t status; /* Status from iteration */ - ssize_t ret_value = -1; /* Return value */ + H5G_gnba_iter_t udata; /* User data for iteration */ + H5G_loc_t root_loc; /* Root group's location */ + hbool_t found_obj = FALSE; /* If we found the object */ + herr_t status; /* Status from iteration */ + ssize_t ret_value = -1; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); @@ -1295,44 +1270,45 @@ H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size) FUNC_ENTER_NOAPI((-1)) /* Construct a group location for root group of the file */ - if(H5G_root_loc(f, &root_loc) < 0) + if (H5G_root_loc(f, &root_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get root group's location") /* Check for root group being the object looked for */ - if(root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) { - if(NULL == (udata.path = H5MM_strdup(""))) + if (root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) { + if (NULL == (udata.path = H5MM_strdup(""))) HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, (-1), "can't duplicate path string") found_obj = TRUE; } /* end if */ else { /* Set up user data for iterator */ - udata.loc = loc; + udata.loc = loc; udata.path = NULL; /* Visit all the links in the file */ - if((status = H5G_visit(&root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, &udata)) < 0) + if ((status = H5G_visit(&root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, + &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, (-1), "group traversal failed while looking for object name") - else if(status > 0) + else if (status > 0) found_obj = TRUE; } /* end else */ /* Check for finding the object */ - if(found_obj) { + if (found_obj) { /* Set the length of the full path */ - ret_value = (ssize_t)(HDstrlen(udata.path) + 1); /* Length of path + 1 (for "/") */ + ret_value = (ssize_t)(HDstrlen(udata.path) + 1); /* Length of path + 1 (for "/") */ /* If there's a buffer provided, copy into it, up to the limit of its size */ - if(name) { + if (name) { /* Copy the initial path separator */ HDstrncpy(name, "/", (size_t)2); /* Append the rest of the path */ /* (less one character, for the initial path separator) */ HDstrncat(name, udata.path, (size - 2)); - if((size_t)ret_value >= size) + if ((size_t)ret_value >= size) name[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ else ret_value = 0; @@ -1342,4 +1318,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_name_by_addr() */ - diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 2e7b367..0c56801 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -29,29 +29,26 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -61,37 +58,32 @@ * nodes consists of this structure... */ typedef struct H5G_node_key_t { - size_t offset; /*offset into heap for name */ + size_t offset; /*offset into heap for name */ } H5G_node_key_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* B-tree callbacks */ -static H5UC_t *H5G_node_get_shared(const H5F_t *f, const void *_udata); -static herr_t H5G__node_create(H5F_t *f, H5B_ins_t op, void *_lt_key, - void *_udata, void *_rt_key, haddr_t *addr_p/*out*/); -static int H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key); -static int H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key); -static htri_t H5G_node_found(H5F_t *f, haddr_t addr, const void *_lt_key, - void *_udata); -static H5B_ins_t H5G__node_insert(H5F_t *f, haddr_t addr, void *_lt_key, - hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, - hbool_t *rt_key_changed, haddr_t *new_node_p/*out*/); -static H5B_ins_t H5G_node_remove(H5F_t *f, haddr_t addr, void *lt_key, - hbool_t *lt_key_changed, void *udata, void *rt_key, hbool_t *rt_key_changed); -static herr_t H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key); -static herr_t H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key); -static herr_t H5G_node_debug_key(FILE *stream, int indent, int fwidth, - const void *key, const void *udata); - +static H5UC_t * H5G_node_get_shared(const H5F_t *f, const void *_udata); +static herr_t H5G__node_create(H5F_t *f, H5B_ins_t op, void *_lt_key, void *_udata, void *_rt_key, + haddr_t *addr_p /*out*/); +static int H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key); +static int H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key); +static htri_t H5G_node_found(H5F_t *f, haddr_t addr, const void *_lt_key, void *_udata); +static H5B_ins_t H5G__node_insert(H5F_t *f, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, + void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, + haddr_t *new_node_p /*out*/); +static H5B_ins_t H5G_node_remove(H5F_t *f, haddr_t addr, void *lt_key, hbool_t *lt_key_changed, void *udata, + void *rt_key, hbool_t *rt_key_changed); +static herr_t H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key); +static herr_t H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key); +static herr_t H5G_node_debug_key(FILE *stream, int indent, int fwidth, const void *key, const void *udata); /*********************/ /* Package Variables */ @@ -99,21 +91,21 @@ static herr_t H5G_node_debug_key(FILE *stream, int indent, int fwidth, /* H5G inherits B-tree like properties from H5B */ H5B_class_t H5B_SNODE[1] = {{ - H5B_SNODE_ID, /*id */ - sizeof(H5G_node_key_t), /*sizeof_nkey */ - H5G_node_get_shared, /*get_shared */ - H5G__node_create, /*new */ - H5G_node_cmp2, /*cmp2 */ - H5G_node_cmp3, /*cmp3 */ - H5G_node_found, /*found */ - H5G__node_insert, /*insert */ - TRUE, /*follow min branch? */ - TRUE, /*follow max branch? */ - H5B_RIGHT, /*critical key */ - H5G_node_remove, /*remove */ - H5G_node_decode_key, /*decode */ - H5G_node_encode_key, /*encode */ - H5G_node_debug_key /*debug */ + H5B_SNODE_ID, /*id */ + sizeof(H5G_node_key_t), /*sizeof_nkey */ + H5G_node_get_shared, /*get_shared */ + H5G__node_create, /*new */ + H5G_node_cmp2, /*cmp2 */ + H5G_node_cmp3, /*cmp3 */ + H5G_node_found, /*found */ + H5G__node_insert, /*insert */ + TRUE, /*follow min branch? */ + TRUE, /*follow max branch? */ + H5B_RIGHT, /*critical key */ + H5G_node_remove, /*remove */ + H5G_node_decode_key, /*decode */ + H5G_node_encode_key, /*encode */ + H5G_node_debug_key /*debug */ }}; /* Declare a free list to manage the H5G_node_t struct */ @@ -122,17 +114,14 @@ H5FL_DEFINE(H5G_node_t); /* Declare a free list to manage sequences of H5G_entry_t's */ H5FL_SEQ_DEFINE(H5G_entry_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5G_node_get_shared * @@ -158,7 +147,6 @@ H5G_node_get_shared(const H5F_t *f, const void H5_ATTR_UNUSED *_udata) FUNC_LEAVE_NOAPI(H5F_GRP_BTREE_SHARED(f)) } /* end H5G_node_get_shared() */ - /*------------------------------------------------------------------------- * Function: H5G_node_decode_key * @@ -174,7 +162,7 @@ H5G_node_get_shared(const H5F_t *f, const void H5_ATTR_UNUSED *_udata) static herr_t H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) { - H5G_node_key_t *key = (H5G_node_key_t *) _key; + H5G_node_key_t *key = (H5G_node_key_t *)_key; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -187,7 +175,6 @@ H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_node_decode_key() */ - /*------------------------------------------------------------------------- * Function: H5G_node_encode_key * @@ -203,7 +190,7 @@ H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) static herr_t H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) { - const H5G_node_key_t *key = (const H5G_node_key_t *) _key; + const H5G_node_key_t *key = (const H5G_node_key_t *)_key; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -216,7 +203,6 @@ H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_node_encode_key() */ - /*------------------------------------------------------------------------- * Function: H5G_node_debug_key * @@ -230,25 +216,23 @@ H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_debug_key(FILE *stream, int indent, int fwidth, const void *_key, - const void *_udata) +H5G_node_debug_key(FILE *stream, int indent, int fwidth, const void *_key, const void *_udata) { - const H5G_node_key_t *key = (const H5G_node_key_t *) _key; - const H5G_bt_common_t *udata = (const H5G_bt_common_t *) _udata; + const H5G_node_key_t * key = (const H5G_node_key_t *)_key; + const H5G_bt_common_t *udata = (const H5G_bt_common_t *)_udata; FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(key); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Heap offset:", - (unsigned)key->offset); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Heap offset:", (unsigned)key->offset); - if(udata->heap) { + if (udata->heap) { const char *s; HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Name:"); - if((s = (const char *)H5HL_offset_into(udata->heap, key->offset)) != NULL) + if ((s = (const char *)H5HL_offset_into(udata->heap, key->offset)) != NULL) HDfprintf(stream, "%s\n", s); } /* end if */ else @@ -257,7 +241,6 @@ H5G_node_debug_key(FILE *stream, int indent, int fwidth, const void *_key, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_node_debug_key() */ - /*------------------------------------------------------------------------- * Function: H5G__node_free * @@ -283,14 +266,13 @@ H5G__node_free(H5G_node_t *sym) /* Verify that node is clean */ HDassert(sym->cache_info.is_dirty == FALSE); - if(sym->entry) + if (sym->entry) sym->entry = H5FL_SEQ_FREE(H5G_entry_t, sym->entry); sym = H5FL_FREE(H5G_node_t, sym); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__node_free() */ - /*------------------------------------------------------------------------- * Function: H5G__node_create * @@ -310,13 +292,13 @@ H5G__node_free(H5G_node_t *sym) *------------------------------------------------------------------------- */ static herr_t -H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, - void H5_ATTR_UNUSED *_udata, void *_rt_key, haddr_t *addr_p/*out*/) +H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, void H5_ATTR_UNUSED *_udata, + void *_rt_key, haddr_t *addr_p /*out*/) { - H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; - H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; - H5G_node_t *sym = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; + H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; + H5G_node_t * sym = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -326,15 +308,15 @@ H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, HDassert(f); HDassert(H5B_INS_FIRST == op); - if(NULL == (sym = H5FL_CALLOC(H5G_node_t))) + if (NULL == (sym = H5FL_CALLOC(H5G_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") sym->node_size = H5G_NODE_SIZE(f); - if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)sym->node_size))) + if (HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)sym->node_size))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to allocate file space") - if(NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f))))) + if (NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f))))) HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, FAIL, "memory allocation failed") - if(H5AC_insert_entry(f, H5AC_SNODE, *addr_p, sym, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_SNODE, *addr_p, sym, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to cache symbol table leaf node") /* * The left and right symbols in an empty tree are both the @@ -342,24 +324,23 @@ H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, * allows the comparison functions to work correctly without knowing * that there are no symbols. */ - if(lt_key) + if (lt_key) lt_key->offset = 0; - if(rt_key) + if (rt_key) rt_key->offset = 0; done: - if(ret_value < 0) { - if(sym != NULL) { - if(sym->entry != NULL) + if (ret_value < 0) { + if (sym != NULL) { + if (sym->entry != NULL) sym->entry = H5FL_SEQ_FREE(H5G_entry_t, sym->entry); sym = H5FL_FREE(H5G_node_t, sym); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_create() */ - /*------------------------------------------------------------------------- * Function: H5G_node_cmp2 * @@ -383,11 +364,11 @@ done: static herr_t H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key) { - H5G_bt_common_t *udata = (H5G_bt_common_t *) _udata; - H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; - H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; - const char *s1, *s2; - int ret_value = SUCCEED; /* Return value */ + H5G_bt_common_t *udata = (H5G_bt_common_t *)_udata; + H5G_node_key_t * lt_key = (H5G_node_key_t *)_lt_key; + H5G_node_key_t * rt_key = (H5G_node_key_t *)_rt_key; + const char * s1, *s2; + int ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -397,9 +378,9 @@ H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key) HDassert(rt_key); /* Get pointers to string names */ - if((s1 = (const char *)H5HL_offset_into(udata->heap, lt_key->offset)) == NULL) + if ((s1 = (const char *)H5HL_offset_into(udata->heap, lt_key->offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get key name") - if((s2 = (const char *)H5HL_offset_into(udata->heap, rt_key->offset)) == NULL) + if ((s2 = (const char *)H5HL_offset_into(udata->heap, rt_key->offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get key name") /* Set return value */ @@ -409,7 +390,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5G_node_cmp2() */ - /*------------------------------------------------------------------------- * Function: H5G_node_cmp3 * @@ -437,11 +417,11 @@ done: static herr_t H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key) { - H5G_bt_common_t *udata = (H5G_bt_common_t *) _udata; - H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; - H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; - const char *s; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_bt_common_t *udata = (H5G_bt_common_t *)_udata; + H5G_node_key_t * lt_key = (H5G_node_key_t *)_lt_key; + H5G_node_key_t * rt_key = (H5G_node_key_t *)_rt_key; + const char * s; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -451,15 +431,15 @@ H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key) HDassert(rt_key); /* left side */ - if((s = (const char *)H5HL_offset_into(udata->heap, lt_key->offset)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->heap, lt_key->offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get key name") - if(HDstrcmp(udata->name, s) <= 0) + if (HDstrcmp(udata->name, s) <= 0) ret_value = (-1); else { /* right side */ - if((s = (const char *)H5HL_offset_into(udata->heap, rt_key->offset)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->heap, rt_key->offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get key name") - if(HDstrcmp(udata->name, s) > 0) + if (HDstrcmp(udata->name, s) > 0) ret_value = 1; } /* end else */ @@ -467,7 +447,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_cmp3() */ - /*------------------------------------------------------------------------- * Function: H5G_node_found * @@ -494,15 +473,14 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5G_node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, - void *_udata) +H5G_node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, void *_udata) { - H5G_bt_lkp_t *udata = (H5G_bt_lkp_t *)_udata; - H5G_node_t *sn = NULL; - unsigned lt = 0, idx = 0, rt; - int cmp = 1; - const char *s; - htri_t ret_value = TRUE; /* Return value */ + H5G_bt_lkp_t *udata = (H5G_bt_lkp_t *)_udata; + H5G_node_t * sn = NULL; + unsigned lt = 0, idx = 0, rt; + int cmp = 1; + const char * s; + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -516,17 +494,17 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, /* * Load the symbol table node for exclusive access. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node") /* * Binary search. */ rt = sn->nsyms; - while(lt < rt && cmp) { + while (lt < rt && cmp) { idx = (lt + rt) / 2; - if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table name") cmp = HDstrcmp(udata->common.name, s); @@ -536,21 +514,20 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, lt = idx + 1; } /* end while */ - if(cmp) + if (cmp) HGOTO_DONE(FALSE) /* Call user's callback operator */ - if((udata->op)(&sn->entry[idx], udata->op_data) < 0) + if ((udata->op)(&sn->entry[idx], udata->op_data) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "iterator callback failed") done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_found() */ - /*------------------------------------------------------------------------- * Function: H5G__node_insert * @@ -583,20 +560,19 @@ done: *------------------------------------------------------------------------- */ static H5B_ins_t -H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, - hbool_t H5_ATTR_UNUSED *lt_key_changed, void *_md_key, void *_udata, - void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node_p) +H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, hbool_t H5_ATTR_UNUSED *lt_key_changed, + void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node_p) { - H5G_node_key_t *md_key = (H5G_node_key_t *) _md_key; - H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; - H5G_bt_ins_t *udata = (H5G_bt_ins_t *) _udata; - H5G_node_t *sn = NULL, *snrt = NULL; + H5G_node_key_t *md_key = (H5G_node_key_t *)_md_key; + H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; + H5G_bt_ins_t * udata = (H5G_bt_ins_t *)_udata; + H5G_node_t * sn = NULL, *snrt = NULL; unsigned sn_flags = H5AC__NO_FLAGS_SET, snrt_flags = H5AC__NO_FLAGS_SET; - const char *s; - unsigned lt = 0, rt; /* Binary search cntrs */ + const char * s; + unsigned lt = 0, rt; /* Binary search cntrs */ int cmp = 1, idx = -1; - H5G_node_t *insert_into = NULL; /*node that gets new entry*/ - H5G_entry_t ent; /* Entry to insert in node */ + H5G_node_t * insert_into = NULL; /*node that gets new entry*/ + H5G_entry_t ent; /* Entry to insert in node */ H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_STATIC @@ -614,20 +590,20 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, /* * Load the symbol node. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__NO_FLAGS_SET))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* * Where does the new symbol get inserted? We use a binary search. */ rt = sn->nsyms; - while(lt < rt) { + while (lt < rt) { idx = (int)((lt + rt) / 2); - if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get symbol table name") /* Check if symbol is already present */ - if(0 == (cmp = HDstrcmp(udata->common.name, s))) + if (0 == (cmp = HDstrcmp(udata->common.name, s))) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "symbol is already present in symbol table") if (cmp < 0) @@ -638,34 +614,32 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, idx += cmp > 0 ? 1 : 0; /* Convert link information & name to symbol table entry */ - if(H5G__ent_convert(f, udata->common.heap, udata->common.name, - udata->lnk, udata->obj_type, udata->crt_info, &ent) < 0) + if (H5G__ent_convert(f, udata->common.heap, udata->common.name, udata->lnk, udata->obj_type, + udata->crt_info, &ent) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5B_INS_ERROR, "unable to convert link") /* Determine where to place entry in node */ - if(sn->nsyms >= 2 * H5F_SYM_LEAF_K(f)) { + if (sn->nsyms >= 2 * H5F_SYM_LEAF_K(f)) { /* * The node is full. Split it into a left and right * node and return the address of the new right node (the * left node is at the same address as the original node). */ - ret_value = H5B_INS_RIGHT; + ret_value = H5B_INS_RIGHT; - /* The right node */ - if(H5G__node_create(f, H5B_INS_FIRST, NULL, NULL, NULL, new_node_p/*out*/) < 0) - HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node") + /* The right node */ + if (H5G__node_create(f, H5B_INS_FIRST, NULL, NULL, NULL, new_node_p /*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node") - if(NULL == (snrt = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, *new_node_p, f, H5AC__NO_FLAGS_SET))) + if (NULL == (snrt = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, *new_node_p, f, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node") - H5MM_memcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f), - H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); + H5MM_memcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f), H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); snrt->nsyms = H5F_SYM_LEAF_K(f); snrt_flags |= H5AC__DIRTIED_FLAG; /* The left node */ - HDmemset(sn->entry + H5F_SYM_LEAF_K(f), 0, - H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); + HDmemset(sn->entry + H5F_SYM_LEAF_K(f), 0, H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); sn->nsyms = H5F_SYM_LEAF_K(f); sn_flags |= H5AC__DIRTIED_FLAG; @@ -673,35 +647,35 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, md_key->offset = sn->entry[sn->nsyms - 1].name_off; /* Where to insert the new entry? */ - if(idx <= (int)H5F_SYM_LEAF_K(f)) { + if (idx <= (int)H5F_SYM_LEAF_K(f)) { insert_into = sn; - if(idx == (int)H5F_SYM_LEAF_K(f)) + if (idx == (int)H5F_SYM_LEAF_K(f)) md_key->offset = ent.name_off; } /* end if */ else { idx -= (int)H5F_SYM_LEAF_K(f); insert_into = snrt; - if(idx == (int)H5F_SYM_LEAF_K(f)) { - rt_key->offset = ent.name_off; + if (idx == (int)H5F_SYM_LEAF_K(f)) { + rt_key->offset = ent.name_off; *rt_key_changed = TRUE; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Where to insert the new entry? */ ret_value = H5B_INS_NOOP; sn_flags |= H5AC__DIRTIED_FLAG; insert_into = sn; - if(idx == (int)sn->nsyms) { - rt_key->offset = ent.name_off; + if (idx == (int)sn->nsyms) { + rt_key->offset = ent.name_off; *rt_key_changed = TRUE; } /* end if */ - } /* end else */ + } /* end else */ /* Move entries down to make room for new entry */ HDassert(idx >= 0); HDmemmove(insert_into->entry + idx + 1, insert_into->entry + idx, - (insert_into->nsyms - (unsigned)idx) * sizeof(H5G_entry_t)); + (insert_into->nsyms - (unsigned)idx) * sizeof(H5G_entry_t)); /* Copy new entry into table */ H5G__ent_copy(&(insert_into->entry[idx]), &ent, H5_COPY_SHALLOW); @@ -710,15 +684,14 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, insert_into->nsyms += 1; done: - if(snrt && H5AC_unprotect(f, H5AC_SNODE, *new_node_p, snrt, snrt_flags) < 0) + if (snrt && H5AC_unprotect(f, H5AC_SNODE, *new_node_p, snrt, snrt_flags) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_insert() */ - /*------------------------------------------------------------------------- * Function: H5G_node_remove * @@ -748,17 +721,16 @@ done: *------------------------------------------------------------------------- */ static H5B_ins_t -H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key/*in,out*/, - hbool_t H5_ATTR_UNUSED *lt_key_changed/*out*/, - void *_udata/*in,out*/, void *_rt_key/*in,out*/, - hbool_t *rt_key_changed/*out*/) +H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key /*in,out*/, + hbool_t H5_ATTR_UNUSED *lt_key_changed /*out*/, void *_udata /*in,out*/, + void *_rt_key /*in,out*/, hbool_t *rt_key_changed /*out*/) { - H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; - H5G_bt_rm_t *udata = (H5G_bt_rm_t *)_udata; - H5G_node_t *sn = NULL; + H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; + H5G_bt_rm_t * udata = (H5G_bt_rm_t *)_udata; + H5G_node_t * sn = NULL; unsigned sn_flags = H5AC__NO_FLAGS_SET; unsigned lt = 0, rt, idx = 0; - int cmp = 1; + int cmp = 1; H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_NOAPI_NOINIT @@ -771,44 +743,45 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key/*in, HDassert(udata && udata->common.heap); /* Load the symbol table */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__NO_FLAGS_SET))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* "Normal" removal of a single entry from the symbol table node */ - if(udata->common.name != NULL) { - H5O_link_t lnk; /* Constructed link for replacement */ - size_t link_name_len; /* Length of string in local heap */ + if (udata->common.name != NULL) { + H5O_link_t lnk; /* Constructed link for replacement */ + size_t link_name_len; /* Length of string in local heap */ /* Find the name with a binary search */ rt = sn->nsyms; - while(lt < rt && cmp) { - const char *s; /* Pointer to string in local heap */ + while (lt < rt && cmp) { + const char *s; /* Pointer to string in local heap */ idx = (lt + rt) / 2; - if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get symbol table name") cmp = HDstrcmp(udata->common.name, s); - if(cmp < 0) + if (cmp < 0) rt = idx; else lt = idx + 1; } /* end while */ - if(cmp) + if (cmp) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "name not found") /* Get a pointer to the name of the link */ - if(NULL == (lnk.name = (char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off))) + if (NULL == (lnk.name = (char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get link name") link_name_len = HDstrlen(lnk.name) + 1; /* Set up rest of link structure */ lnk.corder_valid = FALSE; - lnk.corder = 0; - lnk.cset = H5T_CSET_ASCII; - if(sn->entry[idx].type == H5G_CACHED_SLINK) { + lnk.corder = 0; + lnk.cset = H5T_CSET_ASCII; + if (sn->entry[idx].type == H5G_CACHED_SLINK) { lnk.type = H5L_TYPE_SOFT; - if(NULL == (lnk.u.soft.name = (char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].cache.slink.lval_offset))) + if (NULL == (lnk.u.soft.name = (char *)H5HL_offset_into(udata->common.heap, + sn->entry[idx].cache.slink.lval_offset))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get link name") } /* end if */ else { @@ -818,37 +791,39 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key/*in, } /* end else */ /* Replace any object names */ - if(H5G__link_name_replace(f, udata->grp_full_path_r, &lnk) < 0) + if (H5G__link_name_replace(f, udata->grp_full_path_r, &lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get object type") /* Decrement the ref. count for hard links */ - if(lnk.type == H5L_TYPE_HARD) { - H5O_loc_t tmp_oloc; /* Temporary object location */ + if (lnk.type == H5L_TYPE_HARD) { + H5O_loc_t tmp_oloc; /* Temporary object location */ /* Build temporary object location */ tmp_oloc.file = f; tmp_oloc.addr = lnk.u.hard.addr; - if(H5O_link(&tmp_oloc, -1) < 0) + if (H5O_link(&tmp_oloc, -1) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ else { /* Remove the soft link's value from the local heap */ - if(lnk.u.soft.name) { - size_t soft_link_len; /* Length of string in local heap */ + if (lnk.u.soft.name) { + size_t soft_link_len; /* Length of string in local heap */ soft_link_len = HDstrlen(lnk.u.soft.name) + 1; - if(H5HL_remove(f, udata->common.heap, sn->entry[idx].cache.slink.lval_offset, soft_link_len) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove soft link from local heap") + if (H5HL_remove(f, udata->common.heap, sn->entry[idx].cache.slink.lval_offset, + soft_link_len) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, + "unable to remove soft link from local heap") } /* end if */ - } /* end else */ + } /* end else */ /* Remove the link's name from the local heap */ - if(H5HL_remove(f, udata->common.heap, sn->entry[idx].name_off, link_name_len) < 0) + if (H5HL_remove(f, udata->common.heap, sn->entry[idx].name_off, link_name_len) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove link name from local heap") /* Remove the entry from the symbol table node */ - if(1 == sn->nsyms) { + if (1 == sn->nsyms) { /* * We are about to remove the only symbol in this node. Free this * node and indicate that the pointer to this node in the B-tree @@ -858,7 +833,8 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key/*in, sn->nsyms = 0; sn_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; ret_value = H5B_INS_REMOVE; - } else if(0 == idx) { + } + else if (0 == idx) { /* * We are about to remove the left-most entry from the symbol table * node but there are other entries to the right. No key values @@ -866,10 +842,10 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key/*in, */ sn->nsyms -= 1; sn_flags |= H5AC__DIRTIED_FLAG; - HDmemmove(sn->entry + idx, sn->entry + idx + 1, - (sn->nsyms-idx) * sizeof(H5G_entry_t)); + HDmemmove(sn->entry + idx, sn->entry + idx + 1, (sn->nsyms - idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; - } else if (idx + 1 == sn->nsyms) { + } + else if (idx + 1 == sn->nsyms) { /* * We are about to remove the right-most entry from the symbol table * node but there are other entries to the left. The right key @@ -877,39 +853,40 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key/*in, */ sn->nsyms -= 1; sn_flags |= H5AC__DIRTIED_FLAG; - rt_key->offset = sn->entry[sn->nsyms - 1].name_off; + rt_key->offset = sn->entry[sn->nsyms - 1].name_off; *rt_key_changed = TRUE; - ret_value = H5B_INS_NOOP; - } else { + ret_value = H5B_INS_NOOP; + } + else { /* * We are about to remove an entry from the middle of a symbol table * node. */ sn->nsyms -= 1; sn_flags |= H5AC__DIRTIED_FLAG; - HDmemmove(sn->entry + idx, sn->entry + idx + 1, - (sn->nsyms - idx) * sizeof(H5G_entry_t)); + HDmemmove(sn->entry + idx, sn->entry + idx + 1, (sn->nsyms - idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; } /* end else */ - } /* end if */ + } /* end if */ /* Remove all entries from node, during B-tree deletion */ else { - H5O_loc_t tmp_oloc; /* Temporary object location */ + H5O_loc_t tmp_oloc; /* Temporary object location */ /* Build temporary object location */ tmp_oloc.file = f; /* Reduce the link count for all entries in this node */ - for(idx = 0; idx < sn->nsyms; idx++) { - if(!(H5G_CACHED_SLINK == sn->entry[idx].type)) { + for (idx = 0; idx < sn->nsyms; idx++) { + if (!(H5G_CACHED_SLINK == sn->entry[idx].type)) { /* Decrement the reference count */ HDassert(H5F_addr_defined(sn->entry[idx].header)); tmp_oloc.addr = sn->entry[idx].header; - if(H5O_link(&tmp_oloc, -1) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to decrement object link count") + if (H5O_link(&tmp_oloc, -1) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, + "unable to decrement object link count") } /* end if */ - } /* end for */ + } /* end for */ /* * We are about to remove all the symbols in this node. Free this @@ -922,13 +899,12 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key/*in, } /* end else */ done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release symbol table node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__node_iterate * @@ -943,12 +919,12 @@ done: */ int H5G__node_iterate(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, - const void H5_ATTR_UNUSED *_rt_key, void *_udata) + const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - H5G_bt_it_it_t *udata = (H5G_bt_it_it_t *)_udata; - H5G_node_t *sn = NULL; - H5G_entry_t *ents; /* Pointer to entries in this node */ - unsigned u; /* Local index variable */ + H5G_bt_it_it_t *udata = (H5G_bt_it_it_t *)_udata; + H5G_node_t * sn = NULL; + H5G_entry_t * ents; /* Pointer to entries in this node */ + unsigned u; /* Local index variable */ int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -961,52 +937,52 @@ H5G__node_iterate(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HDassert(udata && udata->heap); /* Protect the symbol table node & local heap while we iterate over entries */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* * Iterate over the symbol table node entries. */ - for(u = 0, ents = sn->entry; u < sn->nsyms && ret_value == H5_ITER_CONT; u++) { - if(udata->skip > 0) + for (u = 0, ents = sn->entry; u < sn->nsyms && ret_value == H5_ITER_CONT; u++) { + if (udata->skip > 0) --udata->skip; else { - H5O_link_t lnk; /* Link for entry */ - const char *name; /* Pointer to link name in heap */ + H5O_link_t lnk; /* Link for entry */ + const char *name; /* Pointer to link name in heap */ /* Get the pointer to the name of the link in the heap */ - if((name = (const char *)H5HL_offset_into(udata->heap, ents[u].name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(udata->heap, ents[u].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get symbol table node name") /* Convert the entry to a link */ - if(H5G__ent_to_link(&lnk, udata->heap, &ents[u], name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link") + if (H5G__ent_to_link(&lnk, udata->heap, &ents[u], name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, + "unable to convert symbol table entry to link") /* Make the callback */ ret_value = (udata->op)(&lnk, udata->op_data); /* Release memory for link object */ - if(H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) + if (H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, H5_ITER_ERROR, "unable to release link message") } /* end else */ /* Increment the number of entries passed through */ /* (whether we skipped them or not) */ - if(udata->final_ent) + if (udata->final_ent) (*udata->final_ent)++; } /* end for */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); done: /* Release resources */ - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__node_sumup * @@ -1022,11 +998,11 @@ done: */ int H5G__node_sumup(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, - const void H5_ATTR_UNUSED *_rt_key, void *_udata) + const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - hsize_t *num_objs = (hsize_t *)_udata; - H5G_node_t *sn = NULL; - int ret_value = H5_ITER_CONT; + hsize_t * num_objs = (hsize_t *)_udata; + H5G_node_t *sn = NULL; + int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1038,19 +1014,18 @@ H5G__node_sumup(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HDassert(num_objs); /* Find the object node and add the number of symbol entries. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") *num_objs += sn->nsyms; done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_sumup() */ - /*------------------------------------------------------------------------- * Function: H5G__node_by_idx * @@ -1067,10 +1042,10 @@ done: */ int H5G__node_by_idx(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, - const void H5_ATTR_UNUSED *_rt_key, void *_udata) + const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - H5G_bt_it_idx_common_t *udata = (H5G_bt_it_idx_common_t *)_udata; - H5G_node_t *sn = NULL; + H5G_bt_it_idx_common_t *udata = (H5G_bt_it_idx_common_t *)_udata; + H5G_node_t * sn = NULL; int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1083,19 +1058,19 @@ H5G__node_by_idx(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HDassert(udata); /* Get a pointer to the symbol table node */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node"); /* Find the node, locate the object symbol table entry and retrieve the name */ - if(udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { - hsize_t ent_idx; /* Entry index in this node */ + if (udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { + hsize_t ent_idx; /* Entry index in this node */ /* Compute index of entry */ ent_idx = udata->idx - udata->num_objs; /* Call 'by index' callback */ HDassert(udata->op); - if((udata->op)(&sn->entry[ent_idx], udata) < 0) + if ((udata->op)(&sn->entry[ent_idx], udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "'by index' callback failed") /* Indicate that we found the entry we are interested in */ @@ -1105,13 +1080,12 @@ H5G__node_by_idx(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, udata->num_objs += sn->nsyms; done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__node_init * @@ -1129,9 +1103,9 @@ done: herr_t H5G__node_init(H5F_t *f) { - H5B_shared_t *shared; /* Shared B-tree node info */ - size_t sizeof_rkey; /* Size of raw (disk) key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B_shared_t *shared; /* Shared B-tree node info */ + size_t sizeof_rkey; /* Size of raw (disk) key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1139,24 +1113,23 @@ H5G__node_init(H5F_t *f) HDassert(f); /* Set the raw key size */ - sizeof_rkey = H5F_SIZEOF_SIZE(f); /*name offset */ + sizeof_rkey = H5F_SIZEOF_SIZE(f); /*name offset */ /* Allocate & initialize global info for the shared structure */ - if(NULL == (shared = H5B_shared_new(f, H5B_SNODE, sizeof_rkey))) + if (NULL == (shared = H5B_shared_new(f, H5B_SNODE, sizeof_rkey))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed for shared B-tree info") /* Set up the "local" information for this file's groups */ /* */ /* Make shared B-tree info reference counted */ - if(H5F_SET_GRP_BTREE_SHARED(f, H5UC_create(shared, H5B_shared_free)) < 0) + if (H5F_SET_GRP_BTREE_SHARED(f, H5UC_create(shared, H5B_shared_free)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_init() */ - /*------------------------------------------------------------------------- * Function: H5G_node_close * @@ -1181,13 +1154,12 @@ H5G_node_close(const H5F_t *f) HDassert(f); /* Free the raw B-tree node buffer */ - if(H5F_GRP_BTREE_SHARED(f)) + if (H5F_GRP_BTREE_SHARED(f)) H5UC_DEC(H5F_GRP_BTREE_SHARED(f)); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_node_close */ - /*------------------------------------------------------------------------- * Function: H5G__node_copy * @@ -1202,16 +1174,16 @@ H5G_node_close(const H5F_t *f) *------------------------------------------------------------------------- */ int -H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, - const void H5_ATTR_UNUSED *_rt_key, void *_udata) +H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, + void *_udata) { - H5G_bt_it_cpy_t *udata = (H5G_bt_it_cpy_t *)_udata; - const H5O_loc_t *src_oloc = udata->src_oloc; - H5O_copy_t *cpy_info = udata->cpy_info; - H5HL_t *heap = NULL; - H5G_node_t *sn = NULL; - unsigned int i; /* Local index variable */ - int ret_value = H5_ITER_CONT; + H5G_bt_it_cpy_t *udata = (H5G_bt_it_cpy_t *)_udata; + const H5O_loc_t *src_oloc = udata->src_oloc; + H5O_copy_t * cpy_info = udata->cpy_info; + H5HL_t * heap = NULL; + H5G_node_t * sn = NULL; + unsigned int i; /* Local index variable */ + int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1221,29 +1193,30 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HDassert(udata); /* load the symbol table into memory from the source file */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* get the base address of the heap */ - if(NULL == (heap = H5HL_protect(f, udata->src_heap_addr, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to protect symbol name") + if (NULL == (heap = H5HL_protect(f, udata->src_heap_addr, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to protect symbol name") /* copy object in this node one by one */ - for(i = 0; i < sn->nsyms; i++) { - H5G_entry_t *src_ent = &(sn->entry[i]); /* Convenience variable to refer to current source group entry */ - H5O_link_t lnk; /* Link to insert */ - const char *name; /* Name of source object */ - H5G_entry_t tmp_src_ent; /* Temperary copy. Change will not affect the cache */ - H5O_type_t obj_type = H5O_TYPE_UNKNOWN; /* Target object type */ - H5G_copy_file_ud_t *cpy_udata; /* Copy file udata */ - H5G_obj_create_t gcrt_info; /* Group creation info */ + for (i = 0; i < sn->nsyms; i++) { + H5G_entry_t *src_ent = + &(sn->entry[i]); /* Convenience variable to refer to current source group entry */ + H5O_link_t lnk; /* Link to insert */ + const char * name; /* Name of source object */ + H5G_entry_t tmp_src_ent; /* Temperary copy. Change will not affect the cache */ + H5O_type_t obj_type = H5O_TYPE_UNKNOWN; /* Target object type */ + H5G_copy_file_ud_t *cpy_udata; /* Copy file udata */ + H5G_obj_create_t gcrt_info; /* Group creation info */ /* expand soft link */ - if(H5G_CACHED_SLINK == src_ent->type && cpy_info->expand_soft_link) { - haddr_t obj_addr; /* Address of object pointed to by soft link */ - H5G_loc_t grp_loc; /* Group location holding soft link */ - H5G_name_t grp_path; /* Path for group holding soft link */ - char *link_name; /* Pointer to value of soft link */ + if (H5G_CACHED_SLINK == src_ent->type && cpy_info->expand_soft_link) { + haddr_t obj_addr; /* Address of object pointed to by soft link */ + H5G_loc_t grp_loc; /* Group location holding soft link */ + H5G_name_t grp_path; /* Path for group holding soft link */ + char * link_name; /* Pointer to value of soft link */ /* Make a temporary copy, so that it will not change the info in the cache */ H5MM_memcpy(&tmp_src_ent, src_ent, sizeof(H5G_entry_t)); @@ -1254,22 +1227,22 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Get pointer to link value in local heap */ - if((link_name = (char *)H5HL_offset_into(heap, tmp_src_ent.cache.slink.lval_offset)) == NULL) + if ((link_name = (char *)H5HL_offset_into(heap, tmp_src_ent.cache.slink.lval_offset)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get link name") /* Check if the object pointed by the soft link exists in the source file */ - if(H5G__loc_addr(&grp_loc, link_name, &obj_addr) >= 0) { + if (H5G__loc_addr(&grp_loc, link_name, &obj_addr) >= 0) { tmp_src_ent.header = obj_addr; - src_ent = &tmp_src_ent; + src_ent = &tmp_src_ent; } /* end if */ else H5E_clear_stack(NULL); /* discard any errors from a dangling soft link */ - } /* if ((H5G_CACHED_SLINK == src_ent->type)... */ + } /* if ((H5G_CACHED_SLINK == src_ent->type)... */ /* Check if object in source group is a hard link */ - if(H5F_addr_defined(src_ent->header)) { - H5O_loc_t new_dst_oloc; /* Copied object location in destination */ - H5O_loc_t tmp_src_oloc; /* Temporary object location for source object */ + if (H5F_addr_defined(src_ent->header)) { + H5O_loc_t new_dst_oloc; /* Copied object location in destination */ + H5O_loc_t tmp_src_oloc; /* Temporary object location for source object */ /* Set up copied object location to fill in */ H5O_loc_reset(&new_dst_oloc); @@ -1281,43 +1254,44 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, tmp_src_oloc.addr = src_ent->header; /* Copy the shared object from source to destination */ - if(H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, &obj_type, (void **)&cpy_udata) < 0) + if (H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, &obj_type, + (void **)&cpy_udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy object") /* Set up object creation info for symbol table insertion. Only * case so far is for inserting old-style groups (for caching stab * info). */ - if(obj_type == H5O_TYPE_GROUP) { - gcrt_info.gcpl_id = H5P_DEFAULT; + if (obj_type == H5O_TYPE_GROUP) { + gcrt_info.gcpl_id = H5P_DEFAULT; gcrt_info.cache_type = cpy_udata->cache_type; - gcrt_info.cache = cpy_udata->cache; + gcrt_info.cache = cpy_udata->cache; } /* end if */ /* Construct link information for eventual insertion */ - lnk.type = H5L_TYPE_HARD; + lnk.type = H5L_TYPE_HARD; lnk.u.hard.addr = new_dst_oloc.addr; } /* ( H5F_addr_defined(src_ent->header)) */ - else if(H5G_CACHED_SLINK == src_ent->type) { + else if (H5G_CACHED_SLINK == src_ent->type) { /* it is a soft link */ /* Set object type to unknown */ obj_type = H5O_TYPE_UNKNOWN; /* Construct link information for eventual insertion */ lnk.type = H5L_TYPE_SOFT; - if((lnk.u.soft.name = (char *)H5HL_offset_into(heap, src_ent->cache.slink.lval_offset)) == NULL) + if ((lnk.u.soft.name = (char *)H5HL_offset_into(heap, src_ent->cache.slink.lval_offset)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get link name") } /* else if */ else HDassert(0 && "Unknown entry type"); /* Set up common link data */ - lnk.cset = H5F_DEFAULT_CSET; /* XXX: Allow user to set this */ - lnk.corder = 0; /* Creation order is not tracked for old-style links */ + lnk.cset = H5F_DEFAULT_CSET; /* XXX: Allow user to set this */ + lnk.corder = 0; /* Creation order is not tracked for old-style links */ lnk.corder_valid = FALSE; /* Creation order is not valid */ - /* lnk.name = name; */ /* This will be set in callback */ + /* lnk.name = name; */ /* This will be set in callback */ /* Determine name of source object */ - if((name = (const char *)H5HL_offset_into(heap, src_ent->name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(heap, src_ent->name_off)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get source object name") /* Set copied metadata tag */ @@ -1325,8 +1299,8 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, /* Insert the new object in the destination file's group */ /* (Don't increment the link count - that's already done above for hard links) */ - if(H5G__stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, - obj_type, (obj_type == H5O_TYPE_GROUP ? &gcrt_info : NULL)) < 0) + if (H5G__stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, obj_type, + (obj_type == H5O_TYPE_GROUP ? &gcrt_info : NULL)) < 0) HGOTO_ERROR_TAG(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") /* Reset metadata tag */ @@ -1335,16 +1309,15 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, } /* end of for (i=0; insyms; i++) */ done: - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name") - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_copy() */ - /*------------------------------------------------------------------------- * Function: H5G__node_build_table * @@ -1359,11 +1332,11 @@ done: */ int H5G__node_build_table(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, - const void H5_ATTR_UNUSED *_rt_key, void *_udata) + const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - H5G_bt_it_bt_t *udata = (H5G_bt_it_bt_t *)_udata; - H5G_node_t *sn = NULL; /* Symbol table node */ - unsigned u; /* Local index variable */ + H5G_bt_it_bt_t *udata = (H5G_bt_it_bt_t *)_udata; + H5G_node_t * sn = NULL; /* Symbol table node */ + unsigned u; /* Local index variable */ int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1379,46 +1352,47 @@ H5G__node_build_table(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr * Save information about the symbol table node since we can't lock it * because we're about to call an application function. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* Check if the link table needs to be extended */ - if((udata->ltable->nlinks + sn->nsyms) >= udata->alloc_nlinks) { - size_t na = MAX((udata->ltable->nlinks + sn->nsyms), (udata->alloc_nlinks * 2)); /* Double # of links allocated */ - H5O_link_t *x; /* Pointer to larger array of links */ + if ((udata->ltable->nlinks + sn->nsyms) >= udata->alloc_nlinks) { + size_t na = MAX((udata->ltable->nlinks + sn->nsyms), + (udata->alloc_nlinks * 2)); /* Double # of links allocated */ + H5O_link_t *x; /* Pointer to larger array of links */ /* Re-allocate the link table */ - if(NULL == (x = (H5O_link_t *)H5MM_realloc(udata->ltable->lnks, sizeof(H5O_link_t) * na))) + if (NULL == (x = (H5O_link_t *)H5MM_realloc(udata->ltable->lnks, sizeof(H5O_link_t) * na))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed") udata->ltable->lnks = x; } /* end if */ /* Iterate over the symbol table node entries, adding to link table */ - for(u = 0; u < sn->nsyms; u++) { - const char *name; /* Pointer to link name in heap */ - size_t linkno; /* Link allocated */ + for (u = 0; u < sn->nsyms; u++) { + const char *name; /* Pointer to link name in heap */ + size_t linkno; /* Link allocated */ /* Get pointer to link's name in the heap */ - if((name = (const char *)H5HL_offset_into(udata->heap, sn->entry[u].name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(udata->heap, sn->entry[u].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get symbol table link name") /* Determine the link to operate on in the table */ linkno = udata->ltable->nlinks++; /* Convert the entry to a link */ - if(H5G__ent_to_link(&udata->ltable->lnks[linkno], udata->heap, &sn->entry[u], name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link") + if (H5G__ent_to_link(&udata->ltable->lnks[linkno], udata->heap, &sn->entry[u], name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, + "unable to convert symbol table entry to link") } /* end for */ done: /* Release the locked items */ - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_build_table() */ - /*------------------------------------------------------------------------- * Function: H5G__node_iterate_size * @@ -1433,10 +1407,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__node_iterate_size(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, - haddr_t H5_ATTR_UNUSED addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata) +H5G__node_iterate_size(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t H5_ATTR_UNUSED addr, + const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - hsize_t *stab_size = (hsize_t *)_udata; /* User data */ + hsize_t *stab_size = (hsize_t *)_udata; /* User data */ FUNC_ENTER_PACKAGE_NOERR @@ -1449,7 +1423,6 @@ H5G__node_iterate_size(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__node_iterate_size() */ - /*------------------------------------------------------------------------- * Function: H5G_node_debug * @@ -1464,13 +1437,12 @@ H5G__node_iterate_size(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, *------------------------------------------------------------------------- */ herr_t -H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth, - haddr_t heap_addr) +H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t heap_addr) { - H5G_node_t *sn = NULL; - H5HL_t *heap = NULL; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_node_t *sn = NULL; + H5HL_t * heap = NULL; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1484,57 +1456,55 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth, HDassert(fwidth >= 0); /* Pin the heap down in memory */ - if(heap_addr > 0 && H5F_addr_defined(heap_addr)) - if(NULL == (heap = H5HL_protect(f, heap_addr, H5AC__READ_ONLY_FLAG))) + if (heap_addr > 0 && H5F_addr_defined(heap_addr)) + if (NULL == (heap = H5HL_protect(f, heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table heap") /* * If we couldn't load the symbol table node, then try loading the * B-tree node. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) { - H5G_bt_common_t udata; /*data to pass through B-tree */ + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) { + H5G_bt_common_t udata; /*data to pass through B-tree */ H5E_clear_stack(NULL); /* discard that error */ udata.heap = heap; - if(H5B_debug(f, addr, stream, indent, fwidth, H5B_SNODE, &udata) < 0) + if (H5B_debug(f, addr, stream, indent, fwidth, H5B_SNODE, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to debug B-tree node"); } /* end if */ else { HDfprintf(stream, "%*sSymbol Table Node...\n", indent, ""); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty:", - sn->cache_info.is_dirty ? "Yes" : "No"); + "Dirty:", sn->cache_info.is_dirty ? "Yes" : "No"); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of Node (in bytes):", (unsigned)sn->node_size); - HDfprintf(stream, "%*s%-*s %u of %u\n", indent, "", fwidth, - "Number of Symbols:", - sn->nsyms, (unsigned)(2 * H5F_SYM_LEAF_K(f))); + "Size of Node (in bytes):", (unsigned)sn->node_size); + HDfprintf(stream, "%*s%-*s %u of %u\n", indent, "", fwidth, "Number of Symbols:", sn->nsyms, + (unsigned)(2 * H5F_SYM_LEAF_K(f))); indent += 3; fwidth = MAX(0, fwidth - 3); - for(u = 0; u < sn->nsyms; u++) { + for (u = 0; u < sn->nsyms; u++) { HDfprintf(stream, "%*sSymbol %u:\n", indent - 3, "", u); - if(heap) { + if (heap) { const char *s = (const char *)H5HL_offset_into(heap, sn->entry[u].name_off); - if(s) + if (s) HDfprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", s); } /* end if */ else - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Warning: Invalid heap address given, name not displayed!"); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, + "Warning: Invalid heap address given, name not displayed!"); H5G__ent_debug(sn->entry + u, stream, indent, fwidth, heap); } /* end for */ - } /* end if */ + } /* end if */ done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_debug() */ - diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 1892182..ac22770 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -26,27 +26,24 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -55,57 +52,49 @@ * link storage */ typedef struct { - H5F_t *f; /* Pointer to file for insertion */ - haddr_t oh_addr; /* Address of the object header */ - H5O_linfo_t *linfo; /* Pointer to link info */ + H5F_t * f; /* Pointer to file for insertion */ + haddr_t oh_addr; /* Address of the object header */ + H5O_linfo_t *linfo; /* Pointer to link info */ } H5G_obj_oh_it_ud1_t; /* User data for link iterator when converting dense link storage to link * messages */ typedef struct { - H5O_link_t *lnk_table; /* Array of links to convert */ - size_t nlinks; /* Number of links converted */ - size_t alloc_links; /* Size of link table */ + H5O_link_t *lnk_table; /* Array of links to convert */ + size_t nlinks; /* Number of links converted */ + size_t alloc_links; /* Size of link table */ } H5G_obj_lnk_it_ud1_t; /* User data for symbol table iterator when converting old-format group to * a new-format group */ typedef struct { - const H5O_loc_t *grp_oloc; /* Pointer to group for insertion */ + const H5O_loc_t *grp_oloc; /* Pointer to group for insertion */ } H5G_obj_stab_it_ud1_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5G_obj_compact_to_dense_cb(const void *_mesg, unsigned idx, - void *_udata); +static herr_t H5G_obj_compact_to_dense_cb(const void *_mesg, unsigned idx, void *_udata); static herr_t H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__obj_create * @@ -120,13 +109,13 @@ static herr_t H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *l *------------------------------------------------------------------------- */ herr_t -H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) +H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc /*out*/) { - H5P_genplist_t *gc_plist; /* Group creation property list */ - H5O_ginfo_t ginfo; /* Group info */ - H5O_linfo_t linfo; /* Link info */ - H5O_pline_t pline; /* Pipeline */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *gc_plist; /* Group creation property list */ + H5O_ginfo_t ginfo; /* Group info */ + H5O_linfo_t linfo; /* Link info */ + H5O_pline_t pline; /* Pipeline */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -137,30 +126,29 @@ H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) HDassert(oloc); /* Get the property list */ - if(NULL == (gc_plist = (H5P_genplist_t *)H5I_object(gcrt_info->gcpl_id))) + if (NULL == (gc_plist = (H5P_genplist_t *)H5I_object(gcrt_info->gcpl_id))) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a property list") /* Get the group info property */ - if(H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get group info") /* Get the link info property */ - if(H5P_get(gc_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_get(gc_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get group info") /* Get the pipeline property */ - if(H5P_peek(gc_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(gc_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get group info") /* Call the "real" group creation routine now */ - if(H5G__obj_create_real(f, &ginfo, &linfo, &pline, gcrt_info, oloc) < 0) + if (H5G__obj_create_real(f, &ginfo, &linfo, &pline, gcrt_info, oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "unable to create group") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_create() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_create_real * @@ -175,14 +163,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, - const H5O_linfo_t *linfo, const H5O_pline_t *pline, - H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) +H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, const H5O_linfo_t *linfo, const H5O_pline_t *pline, + H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc /*out*/) { - size_t hdr_size; /* Size of object header to request */ - hbool_t use_at_least_v18; /* Flag indicating the new group format should be used */ - hid_t gcpl_id = gcrt_info->gcpl_id; /* Group creation property list ID */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t hdr_size; /* Size of object header to request */ + hbool_t use_at_least_v18; /* Flag indicating the new group format should be used */ + hid_t gcpl_id = gcrt_info->gcpl_id; /* Group creation property list ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -196,12 +183,12 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, HDassert(oloc); /* Check for invalid access request */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") /* Check for using the latest version of the group format which is introduced in v18 */ /* (add more checks for creating "new format" groups when needed) */ - if((H5F_LOW_BOUND(f) >= H5F_LIBVER_V18) || linfo->track_corder || (pline && pline->nused)) + if ((H5F_LOW_BOUND(f) >= H5F_LIBVER_V18) || linfo->track_corder || (pline && pline->nused)) use_at_least_v18 = TRUE; else use_at_least_v18 = FALSE; @@ -209,17 +196,17 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, /* Make certain that the creation order is being tracked if an index is * going to be built on it. */ - if(linfo->index_corder && !linfo->track_corder) + if (linfo->index_corder && !linfo->track_corder) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "must track creation order to create index for it") /* Check if we should be using the latest version of the group format */ - if(use_at_least_v18) { - H5O_link_t lnk; /* Temporary link message info for computing message size */ - char null_char = '\0'; /* Character for creating null string */ - size_t ginfo_size; /* Size of the group info message */ - size_t linfo_size; /* Size of the link info message */ - size_t pline_size = 0; /* Size of the pipeline message */ - size_t link_size; /* Size of a link message */ + if (use_at_least_v18) { + H5O_link_t lnk; /* Temporary link message info for computing message size */ + char null_char = '\0'; /* Character for creating null string */ + size_t ginfo_size; /* Size of the group info message */ + size_t linfo_size; /* Size of the link info message */ + size_t pline_size = 0; /* Size of the pipeline message */ + size_t link_size; /* Size of a link message */ /* Calculate message size information, for creating group's object header */ linfo_size = H5O_msg_size_f(f, gcpl_id, H5O_LINFO_ID, linfo, (size_t)0); @@ -228,24 +215,21 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, ginfo_size = H5O_msg_size_f(f, gcpl_id, H5O_GINFO_ID, ginfo, (size_t)0); HDassert(ginfo_size); - if(pline && pline->nused) { + if (pline && pline->nused) { pline_size = H5O_msg_size_f(f, gcpl_id, H5O_PLINE_ID, pline, (size_t)0); HDassert(pline_size); } /* end if */ - lnk.type = H5L_TYPE_HARD; - lnk.corder = 0; + lnk.type = H5L_TYPE_HARD; + lnk.corder = 0; lnk.corder_valid = linfo->track_corder; - lnk.cset = H5T_CSET_ASCII; - lnk.name = &null_char; - link_size = H5O_msg_size_f(f, gcpl_id, H5O_LINK_ID, &lnk, (size_t)ginfo->est_name_len); + lnk.cset = H5T_CSET_ASCII; + lnk.name = &null_char; + link_size = H5O_msg_size_f(f, gcpl_id, H5O_LINK_ID, &lnk, (size_t)ginfo->est_name_len); HDassert(link_size); /* Compute size of header to use for creation */ - hdr_size = linfo_size + - ginfo_size + - pline_size + - (ginfo->est_num_entries * link_size); + hdr_size = linfo_size + ginfo_size + pline_size + (ginfo->est_num_entries * link_size); } /* end if */ else hdr_size = (size_t)(4 + 2 * H5F_SIZEOF_ADDR(f)); @@ -255,45 +239,44 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, * since nothing refers to it yet. The link count will be * incremented if the object is added to the group directed graph. */ - if(H5O_create(f, hdr_size, (size_t)1, gcpl_id, oloc/*out*/) < 0) + if (H5O_create(f, hdr_size, (size_t)1, gcpl_id, oloc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header") /* Check for format of group to create */ - if(use_at_least_v18) { + if (use_at_least_v18) { /* Insert link info message */ /* (Casting away const OK - QAK) */ - if(H5O_msg_create(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, (void *)linfo) < 0) + if (H5O_msg_create(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, (void *)linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Insert group info message */ /* (Casting away const OK - QAK) */ - if(H5O_msg_create(oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)ginfo) < 0) + if (H5O_msg_create(oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Insert pipeline message */ - if(pline && pline->nused) + if (pline && pline->nused) /* (Casting away const OK - QAK) */ - if(H5O_msg_create(oloc, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)pline) < 0) + if (H5O_msg_create(oloc, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") } /* end if */ else { - H5O_stab_t stab; /* Symbol table message */ + H5O_stab_t stab; /* Symbol table message */ /* The group doesn't currently have a 'stab' message, go create one */ - if(H5G__stab_create(oloc, ginfo, &stab) < 0) + if (H5G__stab_create(oloc, ginfo, &stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create symbol table") /* Cache the symbol table information */ - gcrt_info->cache_type = H5G_CACHED_STAB; + gcrt_info->cache_type = H5G_CACHED_STAB; gcrt_info->cache.stab.btree_addr = stab.btree_addr; - gcrt_info->cache.stab.heap_addr = stab.heap_addr; + gcrt_info->cache.stab.heap_addr = stab.heap_addr; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_create_real() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_get_linfo * @@ -312,8 +295,8 @@ done: htri_t H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value = FAIL; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -322,43 +305,42 @@ H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo) HDassert(linfo); /* Check for the group having a link info message */ - if((ret_value = H5O_msg_exists(grp_oloc, H5O_LINFO_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(ret_value) { + if ((ret_value = H5O_msg_exists(grp_oloc, H5O_LINFO_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") + if (ret_value) { /* Retrieve the "link info" structure */ - if(NULL == H5O_msg_read(grp_oloc, H5O_LINFO_ID, linfo)) + if (NULL == H5O_msg_read(grp_oloc, H5O_LINFO_ID, linfo)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "link info message not present") /* Check if we don't know how many links there are */ - if(linfo->nlinks == HSIZET_MAX) { + if (linfo->nlinks == HSIZET_MAX) { /* Check if we are using "dense" link storage */ - if(H5F_addr_defined(linfo->fheap_addr)) { + if (H5F_addr_defined(linfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp_oloc->file, linfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(grp_oloc->file, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ /* (should be same # of records in all indices) */ - if(H5B2_get_nrec(bt2_name, &linfo->nlinks) < 0) + if (H5B2_get_nrec(bt2_name, &linfo->nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve # of records in index") } /* end if */ else { /* Retrieve # of links from object header */ - if(H5O_get_nlinks(grp_oloc, &linfo->nlinks) < 0) + if (H5O_get_nlinks(grp_oloc, &linfo->nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve # of links for object") } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__obj_get_linfo() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_compact_to_dense_cb * @@ -376,9 +358,9 @@ done: static herr_t H5G_obj_compact_to_dense_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata) { - const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_obj_oh_it_ud1_t *udata = (H5G_obj_oh_it_ud1_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + const H5O_link_t * lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ + H5G_obj_oh_it_ud1_t *udata = (H5G_obj_oh_it_ud1_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(udata->oh_addr) @@ -387,14 +369,13 @@ H5G_obj_compact_to_dense_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void HDassert(udata); /* Insert link into dense link storage */ - if(H5G__dense_insert(udata->f, udata->linfo, lnk) < 0) + if (H5G__dense_insert(udata->f, udata->linfo, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into dense storage") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_compact_to_dense_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_stab_to_new_cb * @@ -412,8 +393,8 @@ done: static herr_t H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata) { - H5G_obj_stab_it_ud1_t *udata = (H5G_obj_stab_it_ud1_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5G_obj_stab_it_ud1_t *udata = (H5G_obj_stab_it_ud1_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -423,14 +404,13 @@ H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata) /* Insert link into group */ /* (Casting away const OK - QAK) */ - if(H5G_obj_insert(udata->grp_oloc, lnk->name, (H5O_link_t *)lnk, FALSE, H5O_TYPE_UNKNOWN, NULL) < 0) + if (H5G_obj_insert(udata->grp_oloc, lnk->name, (H5O_link_t *)lnk, FALSE, H5O_TYPE_UNKNOWN, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert link into group") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_obj_stab_to_new_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_insert * @@ -449,16 +429,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, - hbool_t adj_link, H5O_type_t obj_type, const void *crt_info) +H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, hbool_t adj_link, + H5O_type_t obj_type, const void *crt_info) { - H5O_pline_t tmp_pline; /* Pipeline message */ - H5O_pline_t *pline = NULL; /* Pointer to pipeline message */ - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for insertions or not */ - hbool_t use_new_dense = FALSE; /* Whether to use "dense" form of 'new format' group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t tmp_pline; /* Pipeline message */ + H5O_pline_t *pline = NULL; /* Pointer to pipeline message */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for insertions or not */ + hbool_t use_new_dense = FALSE; /* Whether to use "dense" form of 'new format' group */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(grp_oloc->addr, FAIL) @@ -469,19 +449,19 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, /* Check if we have information about the number of objects in this group */ /* (by attempting to get the link info message for this group) */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { - H5O_ginfo_t ginfo; /* Group info message */ - size_t link_msg_size; /* Size of new link message in the file */ + if (linfo_exists) { + H5O_ginfo_t ginfo; /* Group info message */ + size_t link_msg_size; /* Size of new link message in the file */ /* Using the new format for groups */ use_old_format = FALSE; /* Check for tracking creation order on this group's links */ - if(linfo.track_corder) { + if (linfo.track_corder) { /* Set the creation order for the new link & indicate that it's valid */ - obj_lnk->corder = linfo.max_corder; + obj_lnk->corder = linfo.max_corder; obj_lnk->corder_valid = TRUE; /* Increment the max. creation order used in the group */ @@ -489,90 +469,92 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, } /* end if */ /* Get the link's message size */ - if((link_msg_size = H5O_msg_raw_size(grp_oloc->file, H5O_LINK_ID, FALSE, obj_lnk)) == 0) + if ((link_msg_size = H5O_msg_raw_size(grp_oloc->file, H5O_LINK_ID, FALSE, obj_lnk)) == 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get link size") /* Get the group info */ - if(NULL == H5O_msg_read(grp_oloc, H5O_GINFO_ID, &ginfo)) + if (NULL == H5O_msg_read(grp_oloc, H5O_GINFO_ID, &ginfo)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") /* If there's still a small enough number of links, use the 'link' message */ /* (If the encoded form of the link is too large to fit into an object * header message, convert to using dense link storage instead of link messages) */ - if(H5F_addr_defined(linfo.fheap_addr)) + if (H5F_addr_defined(linfo.fheap_addr)) use_new_dense = TRUE; - else if(linfo.nlinks < ginfo.max_compact && link_msg_size < H5O_MESG_MAX_SIZE) + else if (linfo.nlinks < ginfo.max_compact && link_msg_size < H5O_MESG_MAX_SIZE) use_new_dense = FALSE; else { - htri_t pline_exists; /* Whether the pipeline message exists */ - H5G_obj_oh_it_ud1_t udata; /* User data for iteration */ - H5O_mesg_operator_t op; /* Message operator */ + htri_t pline_exists; /* Whether the pipeline message exists */ + H5G_obj_oh_it_ud1_t udata; /* User data for iteration */ + H5O_mesg_operator_t op; /* Message operator */ /* Get the pipeline message, if it exists */ - if((pline_exists = H5O_msg_exists(grp_oloc, H5O_PLINE_ID)) < 0) + if ((pline_exists = H5O_msg_exists(grp_oloc, H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(pline_exists) { - if(NULL == H5O_msg_read(grp_oloc, H5O_PLINE_ID, &tmp_pline)) + if (pline_exists) { + if (NULL == H5O_msg_read(grp_oloc, H5O_PLINE_ID, &tmp_pline)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline") pline = &tmp_pline; } /* end if */ /* The group doesn't currently have "dense" storage for links */ - if(H5G__dense_create(grp_oloc->file, &linfo, pline) < 0) + if (H5G__dense_create(grp_oloc->file, &linfo, pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create 'dense' form of new format group") /* Set up user data for object header message iteration */ - udata.f = grp_oloc->file; + udata.f = grp_oloc->file; udata.oh_addr = grp_oloc->addr; - udata.linfo = &linfo; + udata.linfo = &linfo; /* Iterate over the 'link' messages, inserting them into the dense link storage */ - op.op_type = H5O_MESG_OP_APP; + op.op_type = H5O_MESG_OP_APP; op.u.app_op = H5G_obj_compact_to_dense_cb; - if(H5O_msg_iterate(grp_oloc, H5O_LINK_ID, &op, &udata) < 0) + if (H5O_msg_iterate(grp_oloc, H5O_LINK_ID, &op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over links") /* Remove all the 'link' messages */ - if(H5O_msg_remove(grp_oloc, H5O_LINK_ID, H5O_ALL, FALSE) < 0) + if (H5O_msg_remove(grp_oloc, H5O_LINK_ID, H5O_ALL, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link messages") use_new_dense = TRUE; } /* end else */ - } /* end if */ + } /* end if */ else { /* Check for new-style link information */ - if(obj_lnk->cset != H5T_CSET_ASCII || obj_lnk->type > H5L_TYPE_BUILTIN_MAX) { - H5O_linfo_t new_linfo = H5G_CRT_LINK_INFO_DEF; /* Link information */ - H5O_ginfo_t new_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Group information */ - H5G_obj_stab_it_ud1_t udata; /* User data for iteration */ + if (obj_lnk->cset != H5T_CSET_ASCII || obj_lnk->type > H5L_TYPE_BUILTIN_MAX) { + H5O_linfo_t new_linfo = H5G_CRT_LINK_INFO_DEF; /* Link information */ + H5O_ginfo_t new_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Group information */ + H5G_obj_stab_it_ud1_t udata; /* User data for iteration */ /* Convert group to "new format" group, in order to hold the information */ /* Insert link info message */ - if(H5O_msg_create(grp_oloc, H5O_LINFO_ID, 0, 0, &new_linfo) < 0) + if (H5O_msg_create(grp_oloc, H5O_LINFO_ID, 0, 0, &new_linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Insert group info message */ - if(H5O_msg_create(grp_oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, H5O_UPDATE_TIME, &new_ginfo) < 0) + if (H5O_msg_create(grp_oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, H5O_UPDATE_TIME, &new_ginfo) < + 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Set up user data for iteration */ udata.grp_oloc = grp_oloc; /* Iterate through all links in "old format" group and insert them into new format */ - if(H5G__stab_iterate(grp_oloc, H5_ITER_NATIVE, (hsize_t)0, NULL, H5G_obj_stab_to_new_cb, &udata) < 0) + if (H5G__stab_iterate(grp_oloc, H5_ITER_NATIVE, (hsize_t)0, NULL, H5G_obj_stab_to_new_cb, + &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over old format links") /* Remove the symbol table message from the group */ - if(H5O_msg_remove(grp_oloc, H5O_STAB_ID, 0, FALSE) < 0) + if (H5O_msg_remove(grp_oloc, H5O_STAB_ID, 0, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete old format link storage") /* Recursively call this routine to insert the new link, since the * group is in the "new format" now and the link info should be * set up, etc. */ - if(H5G_obj_insert(grp_oloc, name, obj_lnk, adj_link, obj_type, crt_info) < 0) + if (H5G_obj_insert(grp_oloc, name, obj_lnk, adj_link, obj_type, crt_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into group") /* Done with insertion now */ @@ -583,34 +565,34 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, } /* end if */ /* Insert into symbol table or "dense" storage */ - if(use_old_format) { + if (use_old_format) { /* Insert into symbol table */ - if(H5G__stab_insert(grp_oloc, name, obj_lnk, obj_type, crt_info) < 0) + if (H5G__stab_insert(grp_oloc, name, obj_lnk, obj_type, crt_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry into symbol table") } /* end if */ else { - if(use_new_dense) { + if (use_new_dense) { /* Insert into dense link storage */ - if(H5G__dense_insert(grp_oloc->file, &linfo, obj_lnk) < 0) + if (H5G__dense_insert(grp_oloc->file, &linfo, obj_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into dense storage") } /* end if */ else { /* Insert with link message */ - if(H5G__compact_insert(grp_oloc, obj_lnk) < 0) + if (H5G__compact_insert(grp_oloc, obj_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link as link message") } /* end else */ - } /* end else */ + } /* end else */ /* Increment the number of objects in this group */ - if(!use_old_format) { + if (!use_old_format) { linfo.nlinks++; - if(H5O_msg_write(grp_oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, &linfo) < 0) + if (H5O_msg_write(grp_oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, &linfo) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update link info message") } /* end if */ /* Increment link count on object, if requested and it's a hard link */ - if(adj_link && obj_lnk->type == H5L_TYPE_HARD) { - H5O_loc_t obj_oloc; /* Object location */ + if (adj_link && obj_lnk->type == H5L_TYPE_HARD) { + H5O_loc_t obj_oloc; /* Object location */ H5O_loc_reset(&obj_oloc); /* Create temporary object location */ @@ -618,19 +600,18 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, obj_oloc.addr = obj_lnk->u.hard.addr; /* Increment reference count for object */ - if(H5O_link(&obj_oloc, 1) < 0) + if (H5O_link(&obj_oloc, 1) < 0) HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "unable to increment hard link count") } /* end if */ done: /* Free any space used by the pipeline message */ - if(pline && H5O_msg_reset(H5O_PLINE_ID, pline) < 0) + if (pline && H5O_msg_reset(H5O_PLINE_ID, pline) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "can't release pipeline") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_insert() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_iterate * @@ -647,13 +628,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, - void *op_data) +H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, + hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - herr_t ret_value = FAIL; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -662,38 +642,40 @@ H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, HDassert(op); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for going out of bounds */ - if(skip > 0 && (size_t)skip >= linfo.nlinks) + if (skip > 0 && (size_t)skip >= linfo.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") } /* end if */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Iterate over the links in the group, building a table of the link messages */ - if((ret_value = H5G__dense_iterate(grp_oloc->file, &linfo, idx_type, order, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__dense_iterate(grp_oloc->file, &linfo, idx_type, order, skip, last_lnk, op, + op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over dense links") } /* end if */ else { /* Get the object's name from the link messages */ - if((ret_value = H5G__compact_iterate(grp_oloc, &linfo, idx_type, order, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__compact_iterate(grp_oloc, &linfo, idx_type, order, skip, last_lnk, op, + op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over compact links") } /* end else */ - } /* end if */ + } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Iterate over symbol table */ - if((ret_value = H5G__stab_iterate(grp_oloc, order, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__stab_iterate(grp_oloc, order, skip, last_lnk, op, op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over symbol table") } /* end else */ @@ -701,7 +683,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__obj_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_info * @@ -718,13 +699,13 @@ done: herr_t H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info) { - H5G_t *grp = NULL; /* Group to query */ - H5G_loc_t grp_loc; /* Entry of group to be queried */ - H5G_name_t grp_path; /* Group hier. path */ - H5O_loc_t grp_oloc; /* Group object location */ - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_t * grp = NULL; /* Group to query */ + H5G_loc_t grp_loc; /* Entry of group to be queried */ + H5G_name_t grp_path; /* Group hier. path */ + H5O_loc_t grp_oloc; /* Group object location */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -738,49 +719,48 @@ H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info) H5G_loc_reset(&grp_loc); /* Deep copy (duplicate) of the group location object */ - if(H5O_loc_copy_deep(&grp_oloc, oloc) < 0) + if (H5O_loc_copy_deep(&grp_oloc, oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "can't copy object location") /* Open the group */ - if(NULL == (grp = H5G_open(&grp_loc))) + if (NULL == (grp = H5G_open(&grp_loc))) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") /* Get information from the group */ grp_info->mounted = H5G_MOUNTED(grp); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Retrieve the information about the links */ - grp_info->nlinks = linfo.nlinks; + grp_info->nlinks = linfo.nlinks; grp_info->max_corder = linfo.max_corder; /* Check if the group is using compact or dense storage for its links */ - if(H5F_addr_defined(linfo.fheap_addr)) + if (H5F_addr_defined(linfo.fheap_addr)) grp_info->storage_type = H5G_STORAGE_TYPE_DENSE; else grp_info->storage_type = H5G_STORAGE_TYPE_COMPACT; } /* end if */ else { /* Get the number of objects in this group by iterating over symbol table */ - if(H5G__stab_count(oloc, &grp_info->nlinks) < 0) + if (H5G__stab_count(oloc, &grp_info->nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't count objects") /* Set the other information about the group */ grp_info->storage_type = H5G_STORAGE_TYPE_SYMBOL_TABLE; - grp_info->max_corder = 0; + grp_info->max_corder = 0; } /* end else */ done: /* Clean up resources */ - if(grp && H5G_close(grp) < 0) + if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "unable to close queried group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_info() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_get_name_by_idx * @@ -795,12 +775,12 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char* name, size_t size) +H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + char *name, size_t size) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - ssize_t ret_value = -1; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(oloc->addr, FAIL) @@ -808,35 +788,36 @@ H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, HDassert(oloc && oloc->file); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") } /* end if */ /* Check for dense link storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Get the object's name from the dense link storage */ - if((ret_value = H5G__dense_get_name_by_idx(oloc->file, &linfo, idx_type, order, n, name, size)) < 0) + if ((ret_value = H5G__dense_get_name_by_idx(oloc->file, &linfo, idx_type, order, n, name, size)) < + 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end if */ else { /* Get the object's name from the link messages */ - if((ret_value = H5G__compact_get_name_by_idx(oloc, &linfo, idx_type, order, n, name, size)) < 0) + if ((ret_value = H5G__compact_get_name_by_idx(oloc, &linfo, idx_type, order, n, name, size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end else */ - } /* end if */ + } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Get the object's name from the symbol table */ - if((ret_value = H5G__stab_get_name_by_idx(oloc, order, n, name, size)) < 0) + if ((ret_value = H5G__stab_get_name_by_idx(oloc, order, n, name, size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end else */ @@ -844,7 +825,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_get_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_remove_update_linfo * @@ -861,7 +841,7 @@ done: static herr_t H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -873,87 +853,89 @@ H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo) linfo->nlinks--; /* Reset the creation order min/max if there's no more links in group */ - if(linfo->nlinks == 0) + if (linfo->nlinks == 0) linfo->max_corder = 0; /* Check for transitioning out of dense storage, if we are using it */ - if(H5F_addr_defined(linfo->fheap_addr)) { + if (H5F_addr_defined(linfo->fheap_addr)) { /* Check if there's no more links */ - if(linfo->nlinks == 0) { + if (linfo->nlinks == 0) { /* Delete the dense storage */ - if(H5G__dense_delete(oloc->file, linfo, FALSE) < 0) + if (H5G__dense_delete(oloc->file, linfo, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete dense link storage") } /* end if */ /* Check for switching back to compact storage */ else { - H5O_ginfo_t ginfo; /* Group info message */ + H5O_ginfo_t ginfo; /* Group info message */ /* Get the group info */ - if(NULL == H5O_msg_read(oloc, H5O_GINFO_ID, &ginfo)) + if (NULL == H5O_msg_read(oloc, H5O_GINFO_ID, &ginfo)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") /* Check if we should switch from dense storage back to link messages */ - if(linfo->nlinks < ginfo.min_dense) { - struct H5O_t *oh = NULL; /* Pointer to group's object header */ - H5G_link_table_t ltable; /* Table of links */ - hbool_t can_convert = TRUE; /* Whether converting to link messages is possible */ - size_t u; /* Local index */ + if (linfo->nlinks < ginfo.min_dense) { + struct H5O_t * oh = NULL; /* Pointer to group's object header */ + H5G_link_table_t ltable; /* Table of links */ + hbool_t can_convert = TRUE; /* Whether converting to link messages is possible */ + size_t u; /* Local index */ /* Build the table of links for this group */ - if(H5G__dense_build_table(oloc->file, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, <able) < 0) + if (H5G__dense_build_table(oloc->file, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") /* Pin the object header */ - if(NULL == (oh = H5O_pin(oloc))) + if (NULL == (oh = H5O_pin(oloc))) HGOTO_ERROR(H5E_SYM, H5E_CANTPIN, FAIL, "unable to pin group object header") /* Inspect links in table for ones that can't be converted back * into link message form (currently only links which can't fit * into an object header message) */ - for(u = 0; u < linfo->nlinks; u++) - if(H5O_msg_size_oh(oloc->file, oh, H5O_LINK_ID, &(ltable.lnks[u]), (size_t)0) >= H5O_MESG_MAX_SIZE) { + for (u = 0; u < linfo->nlinks; u++) + if (H5O_msg_size_oh(oloc->file, oh, H5O_LINK_ID, &(ltable.lnks[u]), (size_t)0) >= + H5O_MESG_MAX_SIZE) { can_convert = FALSE; break; } /* end if */ /* If ok, insert links as link messages */ - if(can_convert) { + if (can_convert) { /* Insert link messages into group */ - for(u = 0; u < linfo->nlinks; u++) - if(H5O_msg_append_oh(oloc->file, oh, H5O_LINK_ID, 0, H5O_UPDATE_TIME, &(ltable.lnks[u])) < 0) { + for (u = 0; u < linfo->nlinks; u++) + if (H5O_msg_append_oh(oloc->file, oh, H5O_LINK_ID, 0, H5O_UPDATE_TIME, + &(ltable.lnks[u])) < 0) { /* Release object header */ - if(H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTUNPIN, FAIL, "unable to unpin group object header") + if (H5O_unpin(oh) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTUNPIN, FAIL, + "unable to unpin group object header") HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") } /* end if */ /* Remove the dense storage */ - if(H5G__dense_delete(oloc->file, linfo, FALSE) < 0) + if (H5G__dense_delete(oloc->file, linfo, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete dense link storage") } /* end if */ /* Release object header */ - if(H5O_unpin(oh) < 0) + if (H5O_unpin(oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNPIN, FAIL, "unable to unpin group object header") /* Free link table information */ - if(H5G__link_release_table(<able) < 0) + if (H5G__link_release_table(<able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Update link info in the object header */ - if(H5O_msg_write(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, linfo) < 0) + if (H5O_msg_write(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, linfo) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update link info message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_remove_update_linfo() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_remove * @@ -970,10 +952,10 @@ done: herr_t H5G_obj_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(oloc->addr, FAIL) @@ -982,42 +964,41 @@ H5G_obj_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *n HDassert(name && *name); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Using the new format for groups */ use_old_format = FALSE; /* Check for dense or compact storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Remove object from the dense link storage */ - if(H5G__dense_remove(oloc->file, &linfo, grp_full_path_r, name) < 0) + if (H5G__dense_remove(oloc->file, &linfo, grp_full_path_r, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end if */ else /* Remove object from the link messages */ - if(H5G__compact_remove(oloc, grp_full_path_r, name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") + if (H5G__compact_remove(oloc, grp_full_path_r, name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end if */ else { /* Using the old format for groups */ use_old_format = TRUE; /* Remove object from the symbol table */ - if(H5G__stab_remove(oloc, grp_full_path_r, name) < 0) + if (H5G__stab_remove(oloc, grp_full_path_r, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ /* Update link info for a new-style group */ - if(!use_old_format) - if(H5G__obj_remove_update_linfo(oloc, &linfo) < 0) + if (!use_old_format) + if (H5G__obj_remove_update_linfo(oloc, &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUPDATE, FAIL, "unable to update link info") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_remove() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_remove_by_idx * @@ -1032,13 +1013,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n) +H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(grp_oloc->addr, FAIL) @@ -1046,13 +1027,13 @@ H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, HDassert(grp_oloc && grp_oloc->file); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") } /* end if */ @@ -1060,40 +1041,39 @@ H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, use_old_format = FALSE; /* Check for dense or compact storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Remove object from the dense link storage */ - if(H5G__dense_remove_by_idx(grp_oloc->file, &linfo, grp_full_path_r, idx_type, order, n) < 0) + if (H5G__dense_remove_by_idx(grp_oloc->file, &linfo, grp_full_path_r, idx_type, order, n) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end if */ else { /* Remove object from compact link storage */ - if(H5G__compact_remove_by_idx(grp_oloc, &linfo, grp_full_path_r, idx_type, order, n) < 0) + if (H5G__compact_remove_by_idx(grp_oloc, &linfo, grp_full_path_r, idx_type, order, n) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ - } /* end if */ + } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Using the old format for groups */ use_old_format = TRUE; /* Remove object from the symbol table */ - if(H5G__stab_remove_by_idx(grp_oloc, grp_full_path_r, order, n) < 0) + if (H5G__stab_remove_by_idx(grp_oloc, grp_full_path_r, order, n) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ /* Update link info for a new-style group */ - if(!use_old_format) - if(H5G__obj_remove_update_linfo(grp_oloc, &linfo) < 0) + if (!use_old_format) + if (H5G__obj_remove_update_linfo(grp_oloc, &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUPDATE, FAIL, "unable to update link info") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_lookup * @@ -1110,9 +1090,9 @@ done: htri_t H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - htri_t ret_value = FALSE; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -1121,31 +1101,30 @@ H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) HDassert(name && *name); /* Attempt to get the link info message for this group */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for dense link storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Get the object's info from the dense link storage */ - if((ret_value = H5G__dense_lookup(grp_oloc->file, &linfo, name, lnk)) < 0) + if ((ret_value = H5G__dense_lookup(grp_oloc->file, &linfo, name, lnk)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end if */ else { /* Get the object's info from the link messages */ - if((ret_value = H5G__compact_lookup(grp_oloc, name, lnk)) < 0) + if ((ret_value = H5G__compact_lookup(grp_oloc, name, lnk)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ - } /* end if */ + } /* end if */ else /* Get the object's info from the symbol table */ - if((ret_value = H5G__stab_lookup(grp_oloc, name, lnk)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") + if ((ret_value = H5G__stab_lookup(grp_oloc, name, lnk)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__obj_lookup() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_lookup_by_idx * @@ -1161,12 +1140,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_obj_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) +H5G_obj_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5O_link_t *lnk) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(grp_oloc->addr, FAIL) @@ -1174,39 +1153,38 @@ H5G_obj_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_index_t idx_type, HDassert(grp_oloc && grp_oloc->file); /* Attempt to get the link info message for this group */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") } /* end if */ /* Check for dense link storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Get the link from the dense storage */ - if(H5G__dense_lookup_by_idx(grp_oloc->file, &linfo, idx_type, order, n, lnk) < 0) + if (H5G__dense_lookup_by_idx(grp_oloc->file, &linfo, idx_type, order, n, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end if */ else { /* Get the link from the link messages */ - if(H5G__compact_lookup_by_idx(grp_oloc, &linfo, idx_type, order, n, lnk) < 0) + if (H5G__compact_lookup_by_idx(grp_oloc, &linfo, idx_type, order, n, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ - } /* end if */ + } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Get the object's info from the symbol table */ - if(H5G__stab_lookup_by_idx(grp_oloc, order, n, lnk) < 0) + if (H5G__stab_lookup_by_idx(grp_oloc, order, n, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_lookup_by_idx() */ - diff --git a/src/H5Goh.c b/src/H5Goh.c index f29529b..84f59dc 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -15,77 +15,68 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static void *H5O__group_get_copy_file_udata(void); -static void H5O__group_free_copy_file_udata(void *udata); -static htri_t H5O__group_isa(const H5O_t *loc); -static void *H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); -static void *H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); +static void * H5O__group_get_copy_file_udata(void); +static void H5O__group_free_copy_file_udata(void *udata); +static htri_t H5O__group_isa(const H5O_t *loc); +static void * H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); +static void * H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__group_get_oloc(hid_t obj_id); -static herr_t H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, - H5_ih_info_t *bh_info); - +static herr_t H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_GROUP[1] = {{ - H5O_TYPE_GROUP, /* object type */ - "group", /* object name, for debugging */ - H5O__group_get_copy_file_udata, /* get 'copy file' user data */ + H5O_TYPE_GROUP, /* object type */ + "group", /* object name, for debugging */ + H5O__group_get_copy_file_udata, /* get 'copy file' user data */ H5O__group_free_copy_file_udata, /* free 'copy file' user data */ - H5O__group_isa, /* "isa" message */ - H5O__group_open, /* open an object of this class */ - H5O__group_create, /* create an object of this class */ - H5O__group_get_oloc, /* get an object header location for an object */ - H5O__group_bh_info, /* get the index & heap info for an object */ - NULL /* flush an opened object of this class */ + H5O__group_isa, /* "isa" message */ + H5O__group_open, /* open an object of this class */ + H5O__group_create, /* create an object of this class */ + H5O__group_get_oloc, /* get an object header location for an object */ + H5O__group_bh_info, /* get the index & heap info for an object */ + NULL /* flush an opened object of this class */ }}; /* Declare the external free list to manage the H5O_ginfo_t struct */ H5FL_DEFINE(H5G_copy_file_ud_t); - /*------------------------------------------------------------------------- * Function: H5O__group_get_copy_file_udata * @@ -104,21 +95,20 @@ H5FL_DEFINE(H5G_copy_file_ud_t); static void * H5O__group_get_copy_file_udata(void) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space for the 'copy file' user data for copying groups. * Currently this is only a ginfo, so there is no specific struct type for * this operation. */ - if(NULL == (ret_value = H5FL_CALLOC(H5G_copy_file_ud_t))) + if (NULL == (ret_value = H5FL_CALLOC(H5G_copy_file_ud_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_get_copy_file_udata() */ - /*------------------------------------------------------------------------- * Function: H5O__group_free_copy_file_udata * @@ -151,7 +141,6 @@ H5O__group_free_copy_file_udata(void *_udata) FUNC_LEAVE_NOAPI_VOID } /* end H5O__group_free_copy_file_udata() */ - /*------------------------------------------------------------------------- * Function: H5O__group_isa * @@ -172,19 +161,19 @@ H5O__group_free_copy_file_udata(void *_udata) static htri_t H5O__group_isa(const H5O_t *oh) { - htri_t stab_exists; /* Whether the 'stab' message is in the object header */ - htri_t linfo_exists; /* Whether the 'linfo' message is in the object header */ - htri_t ret_value = FAIL; /* Return value */ + htri_t stab_exists; /* Whether the 'stab' message is in the object header */ + htri_t linfo_exists; /* Whether the 'linfo' message is in the object header */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC HDassert(oh); /* Check for any of the messages that indicate a group */ - if((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") - if((linfo_exists = H5O_msg_exists_oh(oh, H5O_LINFO_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") + if ((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") + if ((linfo_exists = H5O_msg_exists_oh(oh, H5O_LINFO_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") ret_value = (stab_exists > 0 || linfo_exists > 0); @@ -192,7 +181,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_isa() */ - /*------------------------------------------------------------------------- * Function: H5O__group_open * @@ -209,8 +197,8 @@ done: static void * H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - H5G_t *grp = NULL; /* Group opened */ - void *ret_value = NULL; /* Return value */ + H5G_t *grp = NULL; /* Group opened */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -219,20 +207,19 @@ H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) *opened_type = H5I_GROUP; /* Open the group */ - if(NULL == (grp = H5G_open(obj_loc))) + if (NULL == (grp = H5G_open(obj_loc))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") ret_value = (void *)grp; done: - if(NULL == ret_value) - if(grp && H5G_close(grp) < 0) + if (NULL == ret_value) + if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_open() */ - /*------------------------------------------------------------------------- * Function: H5O__group_create * @@ -249,9 +236,9 @@ done: static void * H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) { - H5G_obj_create_t *crt_info = (H5G_obj_create_t *)_crt_info; /* Group creation parameters */ - H5G_t *grp = NULL; /* New group created */ - void *ret_value = NULL; /* Return value */ + H5G_obj_create_t *crt_info = (H5G_obj_create_t *)_crt_info; /* Group creation parameters */ + H5G_t * grp = NULL; /* New group created */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -261,27 +248,26 @@ H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) HDassert(obj_loc); /* Create the the group */ - if(NULL == (grp = H5G__create(f, crt_info))) + if (NULL == (grp = H5G__create(f, crt_info))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") /* Set up the new group's location */ - if(NULL == (obj_loc->oloc = H5G_oloc(grp))) + if (NULL == (obj_loc->oloc = H5G_oloc(grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of group") - if(NULL == (obj_loc->path = H5G_nameof(grp))) + if (NULL == (obj_loc->path = H5G_nameof(grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of group") /* Set the return value */ ret_value = grp; done: - if(ret_value == NULL) - if(grp && H5G_close(grp) < 0) + if (ret_value == NULL) + if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_create() */ - /*------------------------------------------------------------------------- * Function: H5O__group_get_oloc * @@ -298,24 +284,23 @@ done: static H5O_loc_t * H5O__group_get_oloc(hid_t obj_id) { - H5G_t *grp; /* Group opened */ - H5O_loc_t *ret_value = NULL; /* Return value */ + H5G_t * grp; /* Group opened */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Get the group */ - if(NULL == (grp = (H5G_t *)H5VL_object(obj_id))) + if (NULL == (grp = (H5G_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* Get the group's object header location */ - if(NULL == (ret_value = H5G_oloc(grp))) + if (NULL == (ret_value = H5G_oloc(grp))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_get_oloc() */ - /*------------------------------------------------------------------------- * Function: H5O__group_bh_info * @@ -332,11 +317,11 @@ done: static herr_t H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) { - htri_t exists; /* Flag if header message of interest exists */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t exists; /* Flag if header message of interest exists */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(oh->cache_info.addr) @@ -348,69 +333,70 @@ H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) HDassert(bh_info); /* Check for "new style" group info */ - if((exists = H5O_msg_exists_oh(oh, H5O_LINFO_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") - if(exists > 0) { - H5O_linfo_t linfo; /* Link info message */ + if ((exists = H5O_msg_exists_oh(oh, H5O_LINFO_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") + if (exists > 0) { + H5O_linfo_t linfo; /* Link info message */ /* Get "new style" group info */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_LINFO_ID, &linfo)) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't read LINFO message") + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_LINFO_ID, &linfo)) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't read LINFO message") /* Check if name index available */ - if(H5F_addr_defined(linfo.name_bt2_addr)) { + if (H5F_addr_defined(linfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, linfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(loc->file, linfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ - if(H5B2_size(bt2_name, &bh_info->index_size) < 0) + if (H5B2_size(bt2_name, &bh_info->index_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info for name index") } /* end if */ /* Check if creation order index available */ - if(H5F_addr_defined(linfo.corder_bt2_addr)) { + if (H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(loc->file, linfo.corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(loc->file, linfo.corder_bt2_addr, NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ - if(H5B2_size(bt2_corder, &bh_info->index_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info for creation order index") + if (H5B2_size(bt2_corder, &bh_info->index_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, + "can't retrieve B-tree storage info for creation order index") } /* end if */ /* Get fractal heap size, if available */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Open the fractal heap for links */ - if(NULL == (fheap = H5HF_open(loc->file, linfo.fheap_addr))) + if (NULL == (fheap = H5HF_open(loc->file, linfo.fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Get heap storage size */ - if(H5HF_size(fheap, &bh_info->heap_size) < 0) + if (H5HF_size(fheap, &bh_info->heap_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve fractal heap storage info") } /* end if */ - } /* end if */ + } /* end if */ else { - H5O_stab_t stab; /* Info about symbol table */ + H5O_stab_t stab; /* Info about symbol table */ /* Must be "old style" group, get symbol table message */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_STAB_ID, &stab)) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't find LINFO nor STAB messages") + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_STAB_ID, &stab)) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't find LINFO nor STAB messages") /* Get symbol table size info */ - if(H5G__stab_bh_size(loc->file, &stab, bh_info) < 0) + if (H5G__stab_bh_size(loc->file, &stab, bh_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve symbol table size info") } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__group_bh_info() */ - diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 8ad03d0..3df520f 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -30,32 +30,29 @@ #include "H5Gprivate.h" /* Other private headers needed by this file */ -#include "H5B2private.h" /* v2 B-trees */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5HFprivate.h" /* Fractal heaps */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5B2private.h" /* v2 B-trees */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HFprivate.h" /* Fractal heaps */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Standard length of fractal heap ID for link */ -#define H5G_DENSE_FHEAP_ID_LEN 7 +#define H5G_DENSE_FHEAP_ID_LEN 7 /* Size of a symbol table node on disk */ -#define H5G_NODE_SIZE(f) ( \ - /* General metadata fields */ \ - H5_SIZEOF_MAGIC \ - + 1 /* Version */ \ - + 1 /* Reserved */ \ - + 2 /* Number of symbols */ \ - \ - /* Entries */ \ - + ((2 * H5F_SYM_LEAF_K(f)) * (unsigned)H5G_SIZEOF_ENTRY_FILE(f)) \ - ) - +#define H5G_NODE_SIZE(f) \ + ( /* General metadata fields */ \ + H5_SIZEOF_MAGIC + 1 /* Version */ \ + + 1 /* Reserved */ \ + + 2 /* Number of symbols */ \ + \ + /* Entries */ \ + + ((2 * H5F_SYM_LEAF_K(f)) * (unsigned)H5G_SIZEOF_ENTRY_FILE(f))) /****************************/ /* Package Private Typedefs */ @@ -68,12 +65,12 @@ * symbol table entry. */ typedef enum H5G_cache_type_t { - H5G_CACHED_ERROR = -1, /*force enum to be signed */ - H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ - H5G_CACHED_STAB = 1, /*symbol table, `stab' */ - H5G_CACHED_SLINK = 2, /*symbolic link */ + H5G_CACHED_ERROR = -1, /*force enum to be signed */ + H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ + H5G_CACHED_STAB = 1, /*symbol table, `stab' */ + H5G_CACHED_SLINK = 2, /*symbolic link */ - H5G_NCACHED /*THIS MUST BE LAST */ + H5G_NCACHED /*THIS MUST BE LAST */ } H5G_cache_type_t; /* @@ -85,12 +82,12 @@ typedef enum H5G_cache_type_t { */ typedef union H5G_cache_t { struct { - haddr_t btree_addr; /*file address of symbol table B-tree*/ - haddr_t heap_addr; /*file address of stab name heap */ + haddr_t btree_addr; /*file address of symbol table B-tree*/ + haddr_t heap_addr; /*file address of stab name heap */ } stab; struct { - size_t lval_offset; /*link value offset */ + size_t lval_offset; /*link value offset */ } slink; } H5G_cache_t; @@ -101,10 +98,10 @@ typedef union H5G_cache_t { * points. */ struct H5G_entry_t { - H5G_cache_type_t type; /*type of information cached */ - H5G_cache_t cache; /*cached data from object header */ - size_t name_off; /*offset of name within name heap */ - haddr_t header; /*file address of object header */ + H5G_cache_type_t type; /*type of information cached */ + H5G_cache_t cache; /*cached data from object header */ + size_t name_off; /*offset of name within name heap */ + haddr_t header; /*file address of object header */ }; /* @@ -114,19 +111,19 @@ struct H5G_entry_t { * table or group. */ typedef struct H5G_node_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - size_t node_size; /* Size of node on disk */ - unsigned nsyms; /* Number of symbols */ - H5G_entry_t *entry; /* Array of symbol table entries */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + size_t node_size; /* Size of node on disk */ + unsigned nsyms; /* Number of symbols */ + H5G_entry_t *entry; /* Array of symbol table entries */ } H5G_node_t; /* * Shared information for all open group objects */ struct H5G_shared_t { - int fo_count; /* open file object count */ - hbool_t mounted; /* Group is mount point */ + int fo_count; /* open file object count */ + hbool_t mounted; /* Group is mount point */ }; /* @@ -134,9 +131,9 @@ struct H5G_shared_t { * above the H5G layer. */ struct H5G_t { - H5G_shared_t *shared; /* Shared file object data */ - H5O_loc_t oloc; /* Object location for group */ - H5G_name_t path; /* Group hierarchy path */ + H5G_shared_t *shared; /* Shared file object data */ + H5O_loc_t oloc; /* Object location for group */ + H5G_name_t path; /* Group hierarchy path */ }; /* Link iteration operator for internal library callbacks */ @@ -144,8 +141,8 @@ typedef herr_t (*H5G_lib_iterate_t)(const H5O_link_t *lnk, void *op_data); /* Data structure to hold table of links for a group */ typedef struct { - size_t nlinks; /* # of links in table */ - H5O_link_t *lnks; /* Pointer to array of links */ + size_t nlinks; /* # of links in table */ + H5O_link_t *lnks; /* Pointer to array of links */ } H5G_link_table_t; /* @@ -158,8 +155,8 @@ typedef struct { */ typedef struct H5G_bt_common_t { /* downward */ - const char *name; /*points to temporary memory */ - H5HL_t *heap; /*symbol table heap */ + const char *name; /*points to temporary memory */ + H5HL_t * heap; /*symbol table heap */ } H5G_bt_common_t; /* @@ -168,10 +165,10 @@ typedef struct H5G_bt_common_t { */ typedef struct H5G_bt_ins_t { /* downward */ - H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ - const H5O_link_t *lnk; /* Link to insert into table */ - H5O_type_t obj_type; /* Type of object being inserted */ - const void *crt_info; /* Creation info for object being inserted */ + H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ + const H5O_link_t *lnk; /* Link to insert into table */ + H5O_type_t obj_type; /* Type of object being inserted */ + const void * crt_info; /* Creation info for object being inserted */ } H5G_bt_ins_t; /* @@ -180,12 +177,12 @@ typedef struct H5G_bt_ins_t { */ typedef struct H5G_bt_rm_t { /* downward */ - H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ - H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ + H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ + H5RS_str_t * grp_full_path_r; /* Full path of group where link is removed */ } H5G_bt_rm_t; /* Typedef for B-tree 'find' operation */ -typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent/*in*/, void *operator_data/*in,out*/); +typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent /*in*/, void *operator_data /*in,out*/); /* * Data exchange structure for symbol table nodes. This structure is @@ -193,9 +190,9 @@ typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent/*in*/, void *operator_ */ typedef struct H5G_bt_lkp_t { /* downward */ - H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ - H5G_bt_find_op_t op; /* Operator to call when correct entry is found */ - void *op_data; /* Data to pass to operator */ + H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ + H5G_bt_find_op_t op; /* Operator to call when correct entry is found */ + void * op_data; /* Data to pass to operator */ /* upward */ } H5G_bt_lkp_t; @@ -206,40 +203,40 @@ typedef struct H5G_bt_lkp_t { */ typedef struct H5G_bt_it_it_t { /* downward */ - H5HL_t *heap; /*symbol table heap */ - hsize_t skip; /*initial entries to skip */ - H5G_lib_iterate_t op; /*iteration operator */ - void *op_data; /*user-defined operator data */ + H5HL_t * heap; /*symbol table heap */ + hsize_t skip; /*initial entries to skip */ + H5G_lib_iterate_t op; /*iteration operator */ + void * op_data; /*user-defined operator data */ /* upward */ - hsize_t *final_ent; /*final entry looked at */ + hsize_t *final_ent; /*final entry looked at */ } H5G_bt_it_it_t; /* Data passed through B-tree iteration for copying copy symbol table content */ typedef struct H5G_bt_it_cpy_t { - const H5O_loc_t *src_oloc; /* Source object location */ - haddr_t src_heap_addr; /* Heap address of the source symbol table */ - H5F_t *dst_file; /* File of destination group */ - const H5O_stab_t *dst_stab; /* Symbol table message for destination group */ - H5O_copy_t *cpy_info; /* Information for copy operation */ + const H5O_loc_t * src_oloc; /* Source object location */ + haddr_t src_heap_addr; /* Heap address of the source symbol table */ + H5F_t * dst_file; /* File of destination group */ + const H5O_stab_t *dst_stab; /* Symbol table message for destination group */ + H5O_copy_t * cpy_info; /* Information for copy operation */ } H5G_bt_it_cpy_t; /* Common information for "by index" lookups in symbol tables */ typedef struct H5G_bt_it_idx_common_t { /* downward */ - hsize_t idx; /* Index of group member to be queried */ - hsize_t num_objs; /* The number of objects having been traversed */ - H5G_bt_find_op_t op; /* Operator to call when correct entry is found */ + hsize_t idx; /* Index of group member to be queried */ + hsize_t num_objs; /* The number of objects having been traversed */ + H5G_bt_find_op_t op; /* Operator to call when correct entry is found */ } H5G_bt_it_idx_common_t; /* Data passed through B-tree iteration for building a table of the links */ typedef struct H5G_bt_it_bt_t { /* downward */ - size_t alloc_nlinks; /* Number of links allocated in table */ - H5HL_t *heap; /* Symbol table heap */ + size_t alloc_nlinks; /* Number of links allocated in table */ + H5HL_t *heap; /* Symbol table heap */ /* upward */ - H5G_link_table_t *ltable; /* Link table to add information to */ + H5G_link_table_t *ltable; /* Link table to add information to */ } H5G_bt_it_bt_t; /* Typedefs for "new format" groups */ @@ -248,8 +245,8 @@ typedef struct H5G_bt_it_bt_t { /* Typedef for native 'name' field index records in the v2 B-tree */ /* (Keep 'id' field first so generic record handling in callbacks works) */ typedef struct H5G_dense_bt2_name_rec_t { - uint8_t id[H5G_DENSE_FHEAP_ID_LEN]; /* Heap ID for link */ - uint32_t hash; /* Hash of 'name' field value */ + uint8_t id[H5G_DENSE_FHEAP_ID_LEN]; /* Heap ID for link */ + uint32_t hash; /* Hash of 'name' field value */ } H5G_dense_bt2_name_rec_t; /* Typedef for native 'creation order' field index records in the v2 B-tree */ @@ -266,13 +263,13 @@ typedef struct H5G_dense_bt2_corder_rec_t { */ typedef struct H5G_bt2_ud_common_t { /* downward */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ - const char *name; /* Name of link to compare */ - uint32_t name_hash; /* Hash of name of link to compare */ - int64_t corder; /* Creation order value of link to compare */ - H5B2_found_t found_op; /* Callback when correct link is found */ - void *found_op_data; /* Callback data when correct link is found */ + H5F_t * f; /* Pointer to file that fractal heap is in */ + H5HF_t * fheap; /* Fractal heap handle */ + const char * name; /* Name of link to compare */ + uint32_t name_hash; /* Hash of name of link to compare */ + int64_t corder; /* Creation order value of link to compare */ + H5B2_found_t found_op; /* Callback when correct link is found */ + void * found_op_data; /* Callback data when correct link is found */ } H5G_bt2_ud_common_t; /* @@ -281,25 +278,24 @@ typedef struct H5G_bt2_ud_common_t { */ typedef struct H5G_bt2_ud_ins_t { /* downward */ - H5G_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ - uint8_t id[H5G_DENSE_FHEAP_ID_LEN]; /* Heap ID of link to insert */ + H5G_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ + uint8_t id[H5G_DENSE_FHEAP_ID_LEN]; /* Heap ID of link to insert */ } H5G_bt2_ud_ins_t; /* Typedef for group creation operation */ -typedef struct H5G_obj_create_t{ - hid_t gcpl_id; /* Group creation property list */ +typedef struct H5G_obj_create_t { + hid_t gcpl_id; /* Group creation property list */ H5G_cache_type_t cache_type; /* Type of symbol table entry cache */ - H5G_cache_t cache; /* Cached data for symbol table entry */ + H5G_cache_t cache; /* Cached data for symbol table entry */ } H5G_obj_create_t; /* Callback information for copying groups */ typedef struct H5G_copy_file_ud_t { - H5O_copy_file_ud_common_t common; /* Shared information (must be first) */ - H5G_cache_type_t cache_type; /* Type of symbol table entry cache */ - H5G_cache_t cache; /* Cached data for symbol table entry */ + H5O_copy_file_ud_common_t common; /* Shared information (must be first) */ + H5G_cache_type_t cache_type; /* Type of symbol table entry cache */ + H5G_cache_t cache; /* Cached data for symbol table entry */ } H5G_copy_file_ud_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -329,20 +325,17 @@ H5FL_EXTERN(H5G_shared_t); * General group routines */ H5_DLL H5G_t *H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info); -H5_DLL H5G_t *H5G__create_named(const H5G_loc_t *loc, const char *name, - hid_t lcpl_id, hid_t gcpl_id); +H5_DLL H5G_t *H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, hid_t gcpl_id); H5_DLL H5G_t *H5G__open_name(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, - H5G_info_t *grp_info); -H5_DLL herr_t H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info); +H5_DLL herr_t H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, H5G_info_t *grp_info); +H5_DLL herr_t H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info); /* * Group hierarchy traversal routines */ -H5_DLL herr_t H5G__traverse_special(const H5G_loc_t *grp_loc, - const H5O_link_t *lnk, unsigned target, hbool_t last_comp, - H5G_loc_t *obj_loc, hbool_t *obj_exists); +H5_DLL herr_t H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, unsigned target, + hbool_t last_comp, H5G_loc_t *obj_loc, hbool_t *obj_exists); /* * Utility functions @@ -354,138 +347,111 @@ H5_DLL const char *H5G__component(const char *name, size_t *size_p); * functions that understand names are exported to the rest of * the library and appear in H5Gprivate.h. */ -H5_DLL herr_t H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, - H5O_stab_t *stab); +H5_DLL herr_t H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, H5O_stab_t *stab); H5_DLL herr_t H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint); -H5_DLL herr_t H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info); -H5_DLL herr_t H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, - const char *name, H5O_link_t *obj_lnk, H5O_type_t obj_type, - const void *crt_info); +H5_DLL herr_t H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, + H5O_type_t obj_type, const void *crt_info); +H5_DLL herr_t H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, H5O_link_t *obj_lnk, + H5O_type_t obj_type, const void *crt_info); H5_DLL herr_t H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab); -H5_DLL herr_t H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, - hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data); +H5_DLL herr_t H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + H5G_lib_iterate_t op, void *op_data); H5_DLL herr_t H5G__stab_count(const struct H5O_loc_t *oloc, hsize_t *num_objs); -H5_DLL herr_t H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, - H5_ih_info_t *bh_info); -H5_DLL ssize_t H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, - hsize_t n, char* name, size_t size); -H5_DLL herr_t H5G__stab_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - const char *name); -H5_DLL herr_t H5G__stab_remove_by_idx(const H5O_loc_t *oloc, - H5RS_str_t *grp_full_path_r, H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *lnk); -H5_DLL herr_t H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, - hsize_t n, H5O_link_t *lnk); +H5_DLL herr_t H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, H5_ih_info_t *bh_info); +H5_DLL ssize_t H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char *name, + size_t size); +H5_DLL herr_t H5G__stab_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G__stab_remove_by_idx(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk); +H5_DLL herr_t H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, + H5O_link_t *lnk); #ifndef H5_STRICT_FORMAT_CHECKS H5_DLL herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab); #endif /* H5_STRICT_FORMAT_CHECKS */ - /* * Functions that understand symbol table entries. */ -H5_DLL void H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, - H5_copy_depth_t depth); -H5_DLL void H5G__ent_reset(H5G_entry_t *ent); -H5_DLL herr_t H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, - const uint8_t *p_end, H5G_entry_t *ent, unsigned n); -H5_DLL herr_t H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, - const H5G_entry_t *ent, unsigned n); -H5_DLL herr_t H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, - const H5O_link_t *lnk, H5O_type_t obj_type, const void *crt_info, - H5G_entry_t *ent); -H5_DLL herr_t H5G__ent_debug(const H5G_entry_t *ent, FILE * stream, int indent, - int fwidth, const H5HL_t *heap); +H5_DLL void H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth); +H5_DLL void H5G__ent_reset(H5G_entry_t *ent); +H5_DLL herr_t H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5G_entry_t *ent, + unsigned n); +H5_DLL herr_t H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n); +H5_DLL herr_t H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk, + H5O_type_t obj_type, const void *crt_info, H5G_entry_t *ent); +H5_DLL herr_t H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, + const H5HL_t *heap); /* Functions that understand symbol table nodes */ H5_DLL herr_t H5G__node_init(H5F_t *f); -H5_DLL int H5G__node_iterate(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL int H5G__node_sumup(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL int H5G__node_by_idx(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL int H5G__node_copy(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL int H5G__node_build_table(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL herr_t H5G__node_iterate_size(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); +H5_DLL int H5G__node_iterate(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL int H5G__node_sumup(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL int H5G__node_by_idx(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL int H5G__node_copy(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL int H5G__node_build_table(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, + void *_udata); +H5_DLL herr_t H5G__node_iterate_size(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, + void *_udata); H5_DLL herr_t H5G__node_free(H5G_node_t *sym); /* Functions that understand links in groups */ -H5_DLL herr_t H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, - const H5G_entry_t *ent, const char *name); -H5_DLL herr_t H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc); -H5_DLL herr_t H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, - H5_iter_order_t order); -H5_DLL herr_t H5G__link_iterate_table(const H5G_link_table_t *ltable, - hsize_t skip, hsize_t *last_lnk, const H5G_lib_iterate_t op, void *op_data); +H5_DLL herr_t H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, const H5G_entry_t *ent, const char *name); +H5_DLL herr_t H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc); +H5_DLL herr_t H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_order_t order); +H5_DLL herr_t H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, hsize_t *last_lnk, + const H5G_lib_iterate_t op, void *op_data); H5_DLL herr_t H5G__link_release_table(H5G_link_table_t *ltable); H5_DLL herr_t H5G__link_name_replace(H5F_t *file, H5RS_str_t *grp_full_path_r, const H5O_link_t *lnk); /* Functions that understand "compact" link storage */ -H5_DLL herr_t H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk); -H5_DLL ssize_t H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, - const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t idx, char *name, size_t size); -H5_DLL herr_t H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - const char *name); -H5_DLL herr_t H5G__compact_remove_by_idx(const H5O_loc_t *oloc, - const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G__compact_iterate(const H5O_loc_t *oloc, - const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data); -H5_DLL htri_t H5G__compact_lookup(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *lnk); -H5_DLL herr_t H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, - const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, H5O_link_t *lnk); +H5_DLL herr_t H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk); +H5_DLL ssize_t H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, + H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + char *name, size_t size); +H5_DLL herr_t H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, + H5RS_str_t *grp_full_path_r, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + H5G_lib_iterate_t op, void *op_data); +H5_DLL htri_t H5G__compact_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk); +H5_DLL herr_t H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); /* Functions that understand "dense" link storage */ -H5_DLL herr_t H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable); -H5_DLL herr_t H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, - const H5O_pline_t *pline); -H5_DLL herr_t H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, - const H5O_link_t *lnk); -H5_DLL htri_t H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, - const char *name, H5O_link_t *lnk); -H5_DLL herr_t H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); -H5_DLL herr_t H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - H5G_lib_iterate_t op, void *op_data); -H5_DLL ssize_t H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name, - size_t size); -H5_DLL herr_t H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, - H5RS_str_t *grp_full_path_r, const char *name); -H5_DLL herr_t H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, - H5RS_str_t *grp_full_path_r, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n); -H5_DLL herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link); +H5_DLL herr_t H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, H5G_link_table_t *ltable); +H5_DLL herr_t H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline); +H5_DLL herr_t H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk); +H5_DLL htri_t H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, H5O_link_t *lnk); +H5_DLL herr_t H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); +H5_DLL herr_t H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, + void *op_data); +H5_DLL ssize_t H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, char *name, size_t size); +H5_DLL herr_t H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, + const char *name); +H5_DLL herr_t H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link); /* Functions that understand group objects */ -H5_DLL herr_t H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, - H5O_loc_t *oloc/*out*/); -H5_DLL herr_t H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, - const H5O_linfo_t *linfo, const H5O_pline_t *pline, H5G_obj_create_t *gcrt_info, - H5O_loc_t *oloc/*out*/); +H5_DLL herr_t H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc /*out*/); +H5_DLL herr_t H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, const H5O_linfo_t *linfo, + const H5O_pline_t *pline, H5G_obj_create_t *gcrt_info, + H5O_loc_t *oloc /*out*/); H5_DLL htri_t H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo); -H5_DLL herr_t H5G__obj_iterate(const H5O_loc_t *grp_oloc, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - H5G_lib_iterate_t op, void *op_data); +H5_DLL herr_t H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, H5_iter_order_t order, + hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data); H5_DLL herr_t H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info); -H5_DLL htri_t H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *lnk); +H5_DLL htri_t H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk); #ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL herr_t H5G__get_objinfo(const H5G_loc_t *loc, const char *name, - hbool_t follow_link, H5G_stat_t *statbuf/*out*/); +H5_DLL herr_t H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, + H5G_stat_t *statbuf /*out*/); #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* @@ -496,10 +462,9 @@ H5_DLL herr_t H5G__name_init(H5G_name_t *name, const char *path); /* * These functions operate on group "locations" */ -H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, - H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info); -H5_DLL herr_t H5G__loc_addr(const H5G_loc_t *loc, const char *name, - haddr_t *addr/*out*/); +H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, + const void *crt_info); +H5_DLL herr_t H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr /*out*/); /* Testing functions */ #ifdef H5G_TESTING @@ -509,10 +474,10 @@ H5_DLL htri_t H5G__has_stab_test(hid_t gid); H5_DLL htri_t H5G__is_new_dense_test(hid_t gid); H5_DLL herr_t H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count); H5_DLL herr_t H5G__lheap_size_test(hid_t gid, size_t *lheap_size); -H5_DLL herr_t H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *user_path_hidden); +H5_DLL herr_t H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, + unsigned *user_path_hidden); H5_DLL herr_t H5G__verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent); H5_DLL herr_t H5G__verify_cached_stabs_test(hid_t gid); #endif /* H5G_TESTING */ #endif /* _H5Gpkg_H */ - diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 501c883..4ce7396 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -29,73 +29,68 @@ #include "H5Gpublic.h" /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Bprivate.h" /* B-trees */ -#include "H5Fprivate.h" /* File access */ -#include "H5RSprivate.h" /* Reference-counted strings */ +#include "H5private.h" /* Generic Functions */ +#include "H5Bprivate.h" /* B-trees */ +#include "H5Fprivate.h" /* File access */ +#include "H5RSprivate.h" /* Reference-counted strings */ /* * The disk size for a symbol table entry... */ -#define H5G_SIZEOF_SCRATCH 16 -#define H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size) \ - ((sizeof_size) + /*offset of name into heap */ \ - (sizeof_addr) + /*address of object header */ \ - 4 + /*entry type */ \ - 4 + /*reserved */ \ - H5G_SIZEOF_SCRATCH) /*scratch pad space */ -#define H5G_SIZEOF_ENTRY_FILE(F) \ - H5G_SIZEOF_ENTRY(H5F_SIZEOF_ADDR(F), H5F_SIZEOF_SIZE(F)) +#define H5G_SIZEOF_SCRATCH 16 +#define H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size) \ + ((sizeof_size) + /*offset of name into heap */ \ + (sizeof_addr) + /*address of object header */ \ + 4 + /*entry type */ \ + 4 + /*reserved */ \ + H5G_SIZEOF_SCRATCH) /*scratch pad space */ +#define H5G_SIZEOF_ENTRY_FILE(F) H5G_SIZEOF_ENTRY(H5F_SIZEOF_ADDR(F), H5F_SIZEOF_SIZE(F)) /* ========= Group Creation properties ============ */ /* Defaults for link info values */ -#define H5G_CRT_LINFO_TRACK_CORDER FALSE -#define H5G_CRT_LINFO_INDEX_CORDER FALSE -#define H5G_CRT_LINFO_NLINKS 0 -#define H5G_CRT_LINFO_MAX_CORDER 0 -#define H5G_CRT_LINFO_LINK_FHEAP_ADDR HADDR_UNDEF -#define H5G_CRT_LINFO_NAME_BT2_ADDR HADDR_UNDEF -#define H5G_CRT_LINFO_CORDER_BT2_ADDR HADDR_UNDEF +#define H5G_CRT_LINFO_TRACK_CORDER FALSE +#define H5G_CRT_LINFO_INDEX_CORDER FALSE +#define H5G_CRT_LINFO_NLINKS 0 +#define H5G_CRT_LINFO_MAX_CORDER 0 +#define H5G_CRT_LINFO_LINK_FHEAP_ADDR HADDR_UNDEF +#define H5G_CRT_LINFO_NAME_BT2_ADDR HADDR_UNDEF +#define H5G_CRT_LINFO_CORDER_BT2_ADDR HADDR_UNDEF /* Definitions for link info settings */ -#define H5G_CRT_LINK_INFO_NAME "link info" -#define H5G_CRT_LINK_INFO_SIZE sizeof(H5O_linfo_t) -#define H5G_CRT_LINK_INFO_DEF {H5G_CRT_LINFO_TRACK_CORDER, \ - H5G_CRT_LINFO_INDEX_CORDER, \ - H5G_CRT_LINFO_MAX_CORDER, \ - H5G_CRT_LINFO_CORDER_BT2_ADDR, \ - H5G_CRT_LINFO_NLINKS, \ - H5G_CRT_LINFO_LINK_FHEAP_ADDR, \ - H5G_CRT_LINFO_NAME_BT2_ADDR \ - } +#define H5G_CRT_LINK_INFO_NAME "link info" +#define H5G_CRT_LINK_INFO_SIZE sizeof(H5O_linfo_t) +#define H5G_CRT_LINK_INFO_DEF \ + { \ + H5G_CRT_LINFO_TRACK_CORDER, H5G_CRT_LINFO_INDEX_CORDER, H5G_CRT_LINFO_MAX_CORDER, \ + H5G_CRT_LINFO_CORDER_BT2_ADDR, H5G_CRT_LINFO_NLINKS, H5G_CRT_LINFO_LINK_FHEAP_ADDR, \ + H5G_CRT_LINFO_NAME_BT2_ADDR \ + } /* Defaults for group info values */ -#define H5G_CRT_GINFO_LHEAP_SIZE_HINT 0 -#define H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE FALSE -#define H5G_CRT_GINFO_MAX_COMPACT 8 -#define H5G_CRT_GINFO_MIN_DENSE 6 -#define H5G_CRT_GINFO_STORE_EST_ENTRY_INFO FALSE -#define H5G_CRT_GINFO_EST_NUM_ENTRIES 4 -#define H5G_CRT_GINFO_EST_NAME_LEN 8 +#define H5G_CRT_GINFO_LHEAP_SIZE_HINT 0 +#define H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE FALSE +#define H5G_CRT_GINFO_MAX_COMPACT 8 +#define H5G_CRT_GINFO_MIN_DENSE 6 +#define H5G_CRT_GINFO_STORE_EST_ENTRY_INFO FALSE +#define H5G_CRT_GINFO_EST_NUM_ENTRIES 4 +#define H5G_CRT_GINFO_EST_NAME_LEN 8 /* Definitions for group info settings */ -#define H5G_CRT_GROUP_INFO_NAME "group info" -#define H5G_CRT_GROUP_INFO_SIZE sizeof(H5O_ginfo_t) -#define H5G_CRT_GROUP_INFO_DEF {H5G_CRT_GINFO_LHEAP_SIZE_HINT, \ - H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE, \ - H5G_CRT_GINFO_MAX_COMPACT, \ - H5G_CRT_GINFO_MIN_DENSE, \ - H5G_CRT_GINFO_STORE_EST_ENTRY_INFO, \ - H5G_CRT_GINFO_EST_NUM_ENTRIES, \ - H5G_CRT_GINFO_EST_NAME_LEN \ - } +#define H5G_CRT_GROUP_INFO_NAME "group info" +#define H5G_CRT_GROUP_INFO_SIZE sizeof(H5O_ginfo_t) +#define H5G_CRT_GROUP_INFO_DEF \ + { \ + H5G_CRT_GINFO_LHEAP_SIZE_HINT, H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE, H5G_CRT_GINFO_MAX_COMPACT, \ + H5G_CRT_GINFO_MIN_DENSE, H5G_CRT_GINFO_STORE_EST_ENTRY_INFO, H5G_CRT_GINFO_EST_NUM_ENTRIES, \ + H5G_CRT_GINFO_EST_NAME_LEN \ + } /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5G_MODULE -#define H5G_MOUNTED(G) ((G)->shared->mounted) +#define H5G_MOUNTED(G) ((G)->shared->mounted) #else /* H5G_MODULE */ -#define H5G_MOUNTED(G) (H5G_mounted(G)) +#define H5G_MOUNTED(G) (H5G_mounted(G)) #endif /* H5G_MODULE */ /* @@ -103,34 +98,34 @@ * a symbolic link or a mount point. The normal operation is to follow the * symbolic link or mount point and return information about its target. */ -#define H5G_TARGET_NORMAL 0x0000 -#define H5G_TARGET_SLINK 0x0001 -#define H5G_TARGET_MOUNT 0x0002 -#define H5G_TARGET_UDLINK 0x0004 -#define H5G_TARGET_EXISTS 0x0008 -#define H5G_CRT_INTMD_GROUP 0x0010 +#define H5G_TARGET_NORMAL 0x0000 +#define H5G_TARGET_SLINK 0x0001 +#define H5G_TARGET_MOUNT 0x0002 +#define H5G_TARGET_UDLINK 0x0004 +#define H5G_TARGET_EXISTS 0x0008 +#define H5G_CRT_INTMD_GROUP 0x0010 /* Type of operation being performed for call to H5G_name_replace() */ typedef enum { - H5G_NAME_MOVE = 0, /* H5*move call */ - H5G_NAME_DELETE, /* H5Ldelete call */ - H5G_NAME_MOUNT, /* H5Fmount call */ - H5G_NAME_UNMOUNT /* H5Funmount call */ + H5G_NAME_MOVE = 0, /* H5*move call */ + H5G_NAME_DELETE, /* H5Ldelete call */ + H5G_NAME_MOUNT, /* H5Fmount call */ + H5G_NAME_UNMOUNT /* H5Funmount call */ } H5G_names_op_t; /* Status returned from traversal callbacks; whether the object location * or group location need to be closed */ -#define H5G_OWN_NONE 0 +#define H5G_OWN_NONE 0 #define H5G_OWN_OBJ_LOC 1 #define H5G_OWN_GRP_LOC 2 -#define H5G_OWN_BOTH 3 +#define H5G_OWN_BOTH 3 typedef int H5G_own_loc_t; /* Structure to store information about the name an object was opened with */ typedef struct { - H5RS_str_t *full_path_r; /* Path to object, as seen from root of current file mounting hierarchy */ - H5RS_str_t *user_path_r; /* Path to object, as opened by user */ - unsigned obj_hidden; /* Whether the object is visible in group hier. */ + H5RS_str_t *full_path_r; /* Path to object, as seen from root of current file mounting hierarchy */ + H5RS_str_t *user_path_r; /* Path to object, as opened by user */ + unsigned obj_hidden; /* Whether the object is visible in group hier. */ } H5G_name_t; /* Forward declarations (for prototypes & struct definitions) */ @@ -142,8 +137,8 @@ struct H5O_link_t; * location and a group hierarchy path for the object. */ typedef struct { - struct H5O_loc_t *oloc; /* Object header location */ - H5G_name_t *path; /* Group hierarchy path */ + struct H5O_loc_t *oloc; /* Object header location */ + H5G_name_t * path; /* Group hierarchy path */ } H5G_loc_t; /* Typedef for path traversal operations */ @@ -156,46 +151,46 @@ typedef struct { * H5G_OWN_GRP_LOC if it takes ownership of grp_loc, and H5G_OWN_NONE if obj_loc and * grp_loc need to be deleted. */ -typedef herr_t (*H5G_traverse_t)(H5G_loc_t *grp_loc/*in*/, const char *name, - const struct H5O_link_t *lnk/*in*/, H5G_loc_t *obj_loc/*out*/, void *operator_data/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); +typedef herr_t (*H5G_traverse_t)(H5G_loc_t *grp_loc /*in*/, const char *name, + const struct H5O_link_t *lnk /*in*/, H5G_loc_t *obj_loc /*out*/, + void *operator_data /*in,out*/, H5G_own_loc_t *own_loc /*out*/); /* Describe kind of callback to make for each link */ typedef enum H5G_link_iterate_op_type_t { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5G_LINK_OP_OLD, /* "Old" application callback */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5G_LINK_OP_NEW /* "New" application callback */ + H5G_LINK_OP_OLD, /* "Old" application callback */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5G_LINK_OP_NEW /* "New" application callback */ } H5G_link_iterate_op_type_t; typedef struct { H5G_link_iterate_op_type_t op_type; union { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5G_iterate_t op_old; /* "Old" application callback for each link */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5L_iterate2_t op_new; /* "New" application callback for each link */ + H5G_iterate_t op_old; /* "Old" application callback for each link */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5L_iterate2_t op_new; /* "New" application callback for each link */ } op_func; } H5G_link_iterate_t; -typedef struct H5G_t H5G_t; +typedef struct H5G_t H5G_t; typedef struct H5G_shared_t H5G_shared_t; -typedef struct H5G_entry_t H5G_entry_t; +typedef struct H5G_entry_t H5G_entry_t; /* * Library prototypes... These are the ones that other packages routinely * call. */ -H5_DLL herr_t H5G_init(void); +H5_DLL herr_t H5G_init(void); H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp); -H5_DLL H5G_name_t * H5G_nameof(const H5G_t *grp); +H5_DLL H5G_name_t *H5G_nameof(const H5G_t *grp); H5_DLL H5F_t *H5G_fileof(H5G_t *grp); -H5_DLL H5G_t *H5G_open(const H5G_loc_t *loc); -H5_DLL herr_t H5G_close(H5G_t *grp); -H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); -H5_DLL herr_t H5G_mount(H5G_t *grp); +H5_DLL H5G_t * H5G_open(const H5G_loc_t *loc); +H5_DLL herr_t H5G_close(H5G_t *grp); +H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); +H5_DLL herr_t H5G_mount(H5G_t *grp); H5_DLL hbool_t H5G_mounted(H5G_t *grp); -H5_DLL herr_t H5G_unmount(H5G_t *grp); +H5_DLL herr_t H5G_unmount(H5G_t *grp); #ifndef H5_NO_DEPRECATED_SYMBOLS H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -208,41 +203,38 @@ H5_DLL char *H5G_normalize(const char *name); /* * Group hierarchy traversal routines */ -H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name, - unsigned target, H5G_traverse_t op, void *op_data); -H5_DLL herr_t H5G_iterate(H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - const H5G_link_iterate_t *lnk_op, void *op_data); -H5_DLL herr_t H5G_visit(H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data); +H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, + void *op_data); +H5_DLL herr_t H5G_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t skip, hsize_t *last_lnk, const H5G_link_iterate_t *lnk_op, void *op_data); +H5_DLL herr_t H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate2_t op, void *op_data); /* * Functions that understand links in groups */ -H5_DLL herr_t H5G_link_to_info(const struct H5O_loc_t *link_loc, const struct H5O_link_t *lnk, H5L_info2_t *linfo); +H5_DLL herr_t H5G_link_to_info(const struct H5O_loc_t *link_loc, const struct H5O_link_t *lnk, + H5L_info2_t *linfo); /* * Functions that understand group objects */ -H5_DLL herr_t H5G_obj_insert(const struct H5O_loc_t *grp_oloc, const char *name, - struct H5O_link_t *obj_lnk, hbool_t adj_link, H5O_type_t obj_type, - const void *crt_info); +H5_DLL herr_t H5G_obj_insert(const struct H5O_loc_t *grp_oloc, const char *name, struct H5O_link_t *obj_lnk, + hbool_t adj_link, H5O_type_t obj_type, const void *crt_info); H5_DLL ssize_t H5G_obj_get_name_by_idx(const struct H5O_loc_t *oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char* name, size_t size); -H5_DLL herr_t H5G_obj_remove(const struct H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - const char *name); -H5_DLL herr_t H5G_obj_remove_by_idx(const struct H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G_obj_lookup_by_idx(const struct H5O_loc_t *grp_oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, struct H5O_link_t *lnk); -H5_DLL hid_t H5G_get_create_plist(const H5G_t *grp); + H5_iter_order_t order, hsize_t n, char *name, size_t size); +H5_DLL herr_t H5G_obj_remove(const struct H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G_obj_remove_by_idx(const struct H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G_obj_lookup_by_idx(const struct H5O_loc_t *grp_oloc, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, struct H5O_link_t *lnk); +H5_DLL hid_t H5G_get_create_plist(const H5G_t *grp); /* * These functions operate on symbol table nodes. */ H5_DLL herr_t H5G_node_close(const H5F_t *f); -H5_DLL herr_t H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, haddr_t heap); +H5_DLL herr_t H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t heap); /* * These functions operate on group object locations. @@ -253,41 +245,35 @@ H5_DLL herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *en /* * These functions operate on group hierarchy names. */ -H5_DLL herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name); -H5_DLL herr_t H5G_name_replace(const struct H5O_link_t *lnk, H5G_names_op_t op, - H5F_t *src_file, H5RS_str_t *src_full_path_r, H5F_t *dst_file, - H5RS_str_t *dst_full_path_r); -H5_DLL herr_t H5G_name_reset(H5G_name_t *name); -H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth); -H5_DLL herr_t H5G_name_free(H5G_name_t *name); -H5_DLL ssize_t H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, - hbool_t *cached); -H5_DLL ssize_t H5G_get_name_by_addr(H5F_t *f, const struct H5O_loc_t *loc, - char* name, size_t size); +H5_DLL herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name); +H5_DLL herr_t H5G_name_replace(const struct H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, + H5RS_str_t *src_full_path_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r); +H5_DLL herr_t H5G_name_reset(H5G_name_t *name); +H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth); +H5_DLL herr_t H5G_name_free(H5G_name_t *name); +H5_DLL ssize_t H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cached); +H5_DLL ssize_t H5G_get_name_by_addr(H5F_t *f, const struct H5O_loc_t *loc, char *name, size_t size); H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char *name); /* * These functions operate on group "locations" */ -H5_DLL herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc); -H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); -H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth); -H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, - H5G_loc_t *obj_loc/*out*/); -H5_DLL herr_t H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5G_loc_t *obj_loc/*out*/); -H5_DLL htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5G_loc_info(const H5G_loc_t *loc, const char *name, - H5O_info2_t *oinfo/*out*/, unsigned fields); -H5_DLL herr_t H5G_loc_native_info(const H5G_loc_t *loc, const char *name, - H5O_native_info_t *oinfo/*out*/, unsigned fields); -H5_DLL herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, - const char *comment); -H5_DLL ssize_t H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, - char *comment/*out*/, size_t bufsize); -H5_DLL herr_t H5G_loc_reset(H5G_loc_t *loc); -H5_DLL herr_t H5G_loc_free(H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc); +H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth); +H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc /*out*/); +H5_DLL herr_t H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5G_loc_t *obj_loc /*out*/); +H5_DLL htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name); +H5_DLL herr_t H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo /*out*/, + unsigned fields); +H5_DLL herr_t H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *oinfo /*out*/, + unsigned fields); +H5_DLL herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment); +H5_DLL ssize_t H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out*/, + size_t bufsize); +H5_DLL herr_t H5G_loc_reset(H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_free(H5G_loc_t *loc); /* * These functions operate on the root group @@ -298,4 +284,3 @@ H5_DLL herr_t H5G_root_free(H5G_t *grp); H5_DLL H5G_t *H5G_rootof(H5F_t *f); #endif /* _H5Gprivate_H */ - diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 170b74d..0ee4fa6 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -28,10 +28,10 @@ #include /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Lpublic.h" /* Links */ -#include "H5Opublic.h" /* Object headers */ -#include "H5Tpublic.h" /* Datatypes */ +#include "H5public.h" /* Generic Functions */ +#include "H5Lpublic.h" /* Links */ +#include "H5Opublic.h" /* Object headers */ +#include "H5Tpublic.h" /* Datatypes */ /*****************/ /* Public Macros */ @@ -43,27 +43,25 @@ /* Types of link storage for groups */ typedef enum H5G_storage_type_t { - H5G_STORAGE_TYPE_UNKNOWN = -1, /* Unknown link storage type */ - H5G_STORAGE_TYPE_SYMBOL_TABLE, /* Links in group are stored with a "symbol table" */ - /* (this is sometimes called "old-style" groups) */ - H5G_STORAGE_TYPE_COMPACT, /* Links are stored in object header */ - H5G_STORAGE_TYPE_DENSE /* Links are stored in fractal heap & indexed with v2 B-tree */ + H5G_STORAGE_TYPE_UNKNOWN = -1, /* Unknown link storage type */ + H5G_STORAGE_TYPE_SYMBOL_TABLE, /* Links in group are stored with a "symbol table" */ + /* (this is sometimes called "old-style" groups) */ + H5G_STORAGE_TYPE_COMPACT, /* Links are stored in object header */ + H5G_STORAGE_TYPE_DENSE /* Links are stored in fractal heap & indexed with v2 B-tree */ } H5G_storage_type_t; /* Information struct for group (for H5Gget_info/H5Gget_info_by_name/H5Gget_info_by_idx) */ typedef struct H5G_info_t { - H5G_storage_type_t storage_type; /* Type of storage for links in group */ - hsize_t nlinks; /* Number of links in group */ - int64_t max_corder; /* Current max. creation order value for group */ - hbool_t mounted; /* Whether group has a file mounted on it */ + H5G_storage_type_t storage_type; /* Type of storage for links in group */ + hsize_t nlinks; /* Number of links in group */ + int64_t max_corder; /* Current max. creation order value for group */ + hbool_t mounted; /* Whether group has a file mounted on it */ } H5G_info_t; - /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -71,17 +69,14 @@ typedef struct H5G_info_t { extern "C" { #endif -H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, - hid_t gcpl_id, hid_t gapl_id); -H5_DLL hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); -H5_DLL hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id); -H5_DLL hid_t H5Gget_create_plist(hid_t group_id); +H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); +H5_DLL hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); +H5_DLL hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id); +H5_DLL hid_t H5Gget_create_plist(hid_t group_id); H5_DLL herr_t H5Gget_info(hid_t loc_id, H5G_info_t *ginfo); -H5_DLL herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *ginfo, - hid_t lapl_id); -H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *ginfo, - hid_t lapl_id); +H5_DLL herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *ginfo, hid_t lapl_id); +H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5G_info_t *ginfo, hid_t lapl_id); H5_DLL herr_t H5Gclose(hid_t group_id); H5_DLL herr_t H5Gflush(hid_t group_id); H5_DLL herr_t H5Grefresh(hid_t group_id); @@ -95,18 +90,17 @@ H5_DLL herr_t H5Grefresh(hid_t group_id); /* Macros */ /* Link definitions */ -#define H5G_SAME_LOC H5L_SAME_LOC +#define H5G_SAME_LOC H5L_SAME_LOC #define H5G_LINK_ERROR H5L_TYPE_ERROR -#define H5G_LINK_HARD H5L_TYPE_HARD -#define H5G_LINK_SOFT H5L_TYPE_SOFT -#define H5G_link_t H5L_type_t +#define H5G_LINK_HARD H5L_TYPE_HARD +#define H5G_LINK_SOFT H5L_TYPE_SOFT +#define H5G_link_t H5L_type_t /* Macros for types of objects in a group (see H5G_obj_t definition) */ -#define H5G_NTYPES 256 /* Max possible number of types */ -#define H5G_NLIBTYPES 8 /* Number of internal types */ -#define H5G_NUSERTYPES (H5G_NTYPES - H5G_NLIBTYPES) -#define H5G_USERTYPE(X) (8 + (X)) /* User defined types */ - +#define H5G_NTYPES 256 /* Max possible number of types */ +#define H5G_NLIBTYPES 8 /* Number of internal types */ +#define H5G_NUSERTYPES (H5G_NTYPES - H5G_NLIBTYPES) +#define H5G_USERTYPE(X) (8 + (X)) /* User defined types */ /* Typedefs */ @@ -118,15 +112,15 @@ H5_DLL herr_t H5Grefresh(hid_t group_id); * than one type. */ typedef enum H5G_obj_t { - H5G_UNKNOWN = -1, /* Unknown object type */ - H5G_GROUP, /* Object is a group */ - H5G_DATASET, /* Object is a dataset */ - H5G_TYPE, /* Object is a named data type */ - H5G_LINK, /* Object is a symbolic link */ - H5G_UDLINK, /* Object is a user-defined link */ - H5G_RESERVED_5, /* Reserved for future use */ - H5G_RESERVED_6, /* Reserved for future use */ - H5G_RESERVED_7 /* Reserved for future use */ + H5G_UNKNOWN = -1, /* Unknown object type */ + H5G_GROUP, /* Object is a group */ + H5G_DATASET, /* Object is a dataset */ + H5G_TYPE, /* Object is a named data type */ + H5G_LINK, /* Object is a symbolic link */ + H5G_UDLINK, /* Object is a user-defined link */ + H5G_RESERVED_5, /* Reserved for future use */ + H5G_RESERVED_6, /* Reserved for future use */ + H5G_RESERVED_7 /* Reserved for future use */ } H5G_obj_t; /* Prototype for H5Giterate() operator */ @@ -134,40 +128,32 @@ typedef herr_t (*H5G_iterate_t)(hid_t group, const char *name, void *op_data); /* Information about an object */ typedef struct H5G_stat_t { - unsigned long fileno[2]; /*file number */ - unsigned long objno[2]; /*object number */ - unsigned nlink; /*number of hard links to object*/ - H5G_obj_t type; /*basic object type */ - time_t mtime; /*modification time */ - size_t linklen; /*symbolic link value length */ - H5O_stat_t ohdr; /* Object header information */ + unsigned long fileno[2]; /*file number */ + unsigned long objno[2]; /*object number */ + unsigned nlink; /*number of hard links to object*/ + H5G_obj_t type; /*basic object type */ + time_t mtime; /*modification time */ + size_t linklen; /*symbolic link value length */ + H5O_stat_t ohdr; /* Object header information */ } H5G_stat_t; - /* Function prototypes */ -H5_DLL hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint); -H5_DLL hid_t H5Gopen1(hid_t loc_id, const char *name); -H5_DLL herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, - const char *new_name); -H5_DLL herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name); -H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name, - const char *dst_name); -H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name); -H5_DLL herr_t H5Gunlink(hid_t loc_id, const char *name); -H5_DLL herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, - char *buf/*out*/); -H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment); -H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, - char *buf); -H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, - H5G_iterate_t op, void *op_data); -H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); -H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, - hbool_t follow_link, H5G_stat_t *statbuf/*out*/); -H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name, - size_t size); +H5_DLL hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint); +H5_DLL hid_t H5Gopen1(hid_t loc_id, const char *name); +H5_DLL herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new_name); +H5_DLL herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_id, + const char *new_name); +H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name); +H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name); +H5_DLL herr_t H5Gunlink(hid_t loc_id, const char *name); +H5_DLL herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/); +H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment); +H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf); +H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, H5G_iterate_t op, void *op_data); +H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); +H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, + H5G_stat_t *statbuf /*out*/); +H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size); H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -176,4 +162,3 @@ H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); } #endif #endif /* _H5Gpublic_H */ - diff --git a/src/H5Groot.c b/src/H5Groot.c index 36aa8f6..83d8909 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -26,58 +26,48 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G_rootof * @@ -106,7 +96,7 @@ H5G_rootof(H5F_t *f) HDassert(f->shared); /* Walk to top of mounted files */ - while(f->parent) + while (f->parent) f = f->parent; /* Sanity check */ @@ -115,15 +105,14 @@ H5G_rootof(H5F_t *f) HDassert(f->shared->root_grp); /* Check to see if the root group was opened through a different - * "top" file, and switch it to point at the current "top" file. - */ - if(f->shared->root_grp->oloc.file != f) + * "top" file, and switch it to point at the current "top" file. + */ + if (f->shared->root_grp->oloc.file != f) f->shared->root_grp->oloc.file = f; FUNC_LEAVE_NOAPI(f->shared->root_grp) } /* end H5G_rootof() */ - /*------------------------------------------------------------------------- * Function: H5G_mkroot * @@ -145,12 +134,12 @@ H5G_rootof(H5F_t *f) herr_t H5G_mkroot(H5F_t *f, hbool_t create_root) { - H5G_loc_t root_loc; /* Root location information */ - H5G_obj_create_t gcrt_info; /* Root group object creation info */ - htri_t stab_exists = -1; /* Whether the symbol table exists */ - hbool_t sblock_dirty = FALSE; /* Whether superblock was dirtied */ - hbool_t path_init = FALSE; /* Whether path was initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t root_loc; /* Root location information */ + H5G_obj_create_t gcrt_info; /* Root group object creation info */ + htri_t stab_exists = -1; /* Whether the symbol table exists */ + hbool_t sblock_dirty = FALSE; /* Whether superblock was dirtied */ + hbool_t path_init = FALSE; /* Whether path was initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -160,19 +149,19 @@ H5G_mkroot(H5F_t *f, hbool_t create_root) HDassert(f->shared->sblock); /* Check if the root group is already initialized */ - if(f->shared->root_grp) + if (f->shared->root_grp) HGOTO_DONE(SUCCEED) /* Create information needed for group nodes */ - if(H5G__node_init(f) < 0) + if (H5G__node_init(f) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group node info") /* * Create the group pointer */ - if(NULL == (f->shared->root_grp = H5FL_CALLOC(H5G_t))) + if (NULL == (f->shared->root_grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (f->shared->root_grp->shared = H5FL_CALLOC(H5G_shared_t))) { + if (NULL == (f->shared->root_grp->shared = H5FL_CALLOC(H5G_shared_t))) { f->shared->root_grp = H5FL_FREE(H5G_t, f->shared->root_grp); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ @@ -187,108 +176,109 @@ H5G_mkroot(H5F_t *f, hbool_t create_root) * If there is no root object then create one. The root group always starts * with a hard link count of one since it's pointed to by the superblock. */ - if(create_root) { + if (create_root) { /* Create root group */ /* (Pass the FCPL which is a sub-class of the group creation property class) */ - gcrt_info.gcpl_id = f->shared->fcpl_id; + gcrt_info.gcpl_id = f->shared->fcpl_id; gcrt_info.cache_type = H5G_NOTHING_CACHED; - if(H5G__obj_create(f, &gcrt_info, root_loc.oloc/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") - if(1 != H5O_link(root_loc.oloc, 1)) - HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)") + if (H5G__obj_create(f, &gcrt_info, root_loc.oloc /*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") + if (1 != H5O_link(root_loc.oloc, 1)) + HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)") /* Decrement refcount on root group's object header in memory */ - if(H5O_dec_rc_by_loc(root_loc.oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on root group's object header") + if (H5O_dec_rc_by_loc(root_loc.oloc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, + "unable to decrement refcount on root group's object header") /* Mark superblock dirty, so root group info is flushed */ sblock_dirty = TRUE; /* Create the root group symbol table entry */ HDassert(!f->shared->sblock->root_ent); - if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { /* Allocate space for the root group symbol table entry */ - if(NULL == (f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) + if (NULL == (f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") /* Initialize the root group symbol table entry */ f->shared->sblock->root_ent->type = gcrt_info.cache_type; - if(gcrt_info.cache_type != H5G_NOTHING_CACHED) + if (gcrt_info.cache_type != H5G_NOTHING_CACHED) f->shared->sblock->root_ent->cache = gcrt_info.cache; - f->shared->sblock->root_ent->name_off = 0; /* No name (yet) */ - f->shared->sblock->root_ent->header = root_loc.oloc->addr; + f->shared->sblock->root_ent->name_off = 0; /* No name (yet) */ + f->shared->sblock->root_ent->header = root_loc.oloc->addr; } /* end if */ - } /* end if */ + } /* end if */ else { /* Create root group object location from f */ root_loc.oloc->addr = f->shared->sblock->root_addr; root_loc.oloc->file = f; - /* - * Open the root object as a group. - */ - if(H5O_open(root_loc.oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group") + /* + * Open the root object as a group. + */ + if (H5O_open(root_loc.oloc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group") /* Actions to take if the symbol table information is cached */ - if(f->shared->sblock->root_ent && f->shared->sblock->root_ent->type == H5G_CACHED_STAB) { + if (f->shared->sblock->root_ent && f->shared->sblock->root_ent->type == H5G_CACHED_STAB) { /* Check for the situation where the symbol table is cached but does * not exist. This can happen if, for example, an external link is * added to the root group. */ - if((stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID)) < 0) + if ((stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check if symbol table message exists") /* Remove the cache if the stab does not exist */ - if(!stab_exists) + if (!stab_exists) f->shared->sblock->root_ent->type = H5G_NOTHING_CACHED; #ifndef H5_STRICT_FORMAT_CHECKS /* If symbol table information is cached, check if we should replace the - * symbol table message with the cached symbol table information */ - else if(H5F_INTENT(f) & H5F_ACC_RDWR) { - H5O_stab_t cached_stab; + * symbol table message with the cached symbol table information */ + else if (H5F_INTENT(f) & H5F_ACC_RDWR) { + H5O_stab_t cached_stab; /* Retrieve the cached symbol table information */ cached_stab.btree_addr = f->shared->sblock->root_ent->cache.stab.btree_addr; - cached_stab.heap_addr = f->shared->sblock->root_ent->cache.stab.heap_addr; + cached_stab.heap_addr = f->shared->sblock->root_ent->cache.stab.heap_addr; /* Check if the symbol table message is valid, and replace with the - * cached symbol table if necessary */ - if(H5G__stab_valid(root_loc.oloc, &cached_stab) < 0) + * cached symbol table if necessary */ + if (H5G__stab_valid(root_loc.oloc, &cached_stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to verify symbol table") } /* end if */ -#endif /* H5_STRICT_FORMAT_CHECKS */ - } /* end if */ - } /* end else */ +#endif /* H5_STRICT_FORMAT_CHECKS */ + } /* end if */ + } /* end else */ /* Cache the root group's symbol table information in the root group symbol * table entry. It will have been allocated by now if it needs to be * present, so we don't need to check the superblock version. We do this if * we have write access, the root entry has been allocated (i.e. * super_vers < 2) and the stab info is not already cached. */ - if((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->sblock->root_ent - && f->shared->sblock->root_ent->type != H5G_CACHED_STAB) { - H5O_stab_t stab; /* Symbol table */ + if ((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->sblock->root_ent && + f->shared->sblock->root_ent->type != H5G_CACHED_STAB) { + H5O_stab_t stab; /* Symbol table */ /* Check if the stab message exists. It's possible for the root group * to use the latest version while the superblock is an old version. * If stab_exists is not -1 then we have already checked. */ - if(stab_exists == -1 && (stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID)) < 0) + if (stab_exists == -1 && (stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check if symbol table message exists") - if(stab_exists) { + if (stab_exists) { /* Read the root group's symbol table message */ - if(NULL == H5O_msg_read(root_loc.oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(root_loc.oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message") /* Update the root group symbol table entry */ - f->shared->sblock->root_ent->type = H5G_CACHED_STAB; + f->shared->sblock->root_ent->type = H5G_CACHED_STAB; f->shared->sblock->root_ent->cache.stab.btree_addr = stab.btree_addr; - f->shared->sblock->root_ent->cache.stab.heap_addr = stab.heap_addr; + f->shared->sblock->root_ent->cache.stab.heap_addr = stab.heap_addr; /* Mark superblock dirty, so root group info is flushed */ sblock_dirty = TRUE; } /* end if */ - } /* end if */ + } /* end if */ /* Create the path names for the root group's entry */ H5G__name_init(root_loc.path, "/"); @@ -299,49 +289,47 @@ H5G_mkroot(H5F_t *f, hbool_t create_root) * exists. Don't count either the superblock extension or the root group * in the number of open objects in the file. */ - HDassert((1 == f->nopen_objs) || - (2 == f->nopen_objs && HADDR_UNDEF != f->shared->sblock->ext_addr)); + HDassert((1 == f->nopen_objs) || (2 == f->nopen_objs && HADDR_UNDEF != f->shared->sblock->ext_addr)); f->nopen_objs--; done: /* In case of error, free various memory locations that may have been * allocated */ - if(ret_value < 0) { - if(f->shared->root_grp) { - if(path_init) + if (ret_value < 0) { + if (f->shared->root_grp) { + if (path_init) H5G_name_free(root_loc.path); - if(f->shared->root_grp->shared) + if (f->shared->root_grp->shared) f->shared->root_grp->shared = H5FL_FREE(H5G_shared_t, f->shared->root_grp->shared); f->shared->root_grp = H5FL_FREE(H5G_t, f->shared->root_grp); } /* end if */ - if(f->shared->sblock) + if (f->shared->sblock) f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_xfree(f->shared->sblock->root_ent); } /* end if */ /* Mark superblock dirty in cache, if necessary */ - if(sblock_dirty) - if(H5AC_mark_entry_dirty(f->shared->sblock) < 0) + if (sblock_dirty) + if (H5AC_mark_entry_dirty(f->shared->sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_mkroot() */ - /*------------------------------------------------------------------------- -* Function: H5G_root_free -* -* Purpose: Free memory used by an H5G_t struct (and its H5G_shared_t). -* Does not close the group or decrement the reference count. -* Used to free memory used by the root group. -* -* Return: Success: Non-negative -* Failure: Negative -* -* Programmer: James Laird -* Tuesday, September 7, 2004 -* -*------------------------------------------------------------------------- -*/ + * Function: H5G_root_free + * + * Purpose: Free memory used by an H5G_t struct (and its H5G_shared_t). + * Does not close the group or decrement the reference count. + * Used to free memory used by the root group. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: James Laird + * Tuesday, September 7, 2004 + * + *------------------------------------------------------------------------- + */ herr_t H5G_root_free(H5G_t *grp) { @@ -355,12 +343,11 @@ H5G_root_free(H5G_t *grp) H5G_name_free(&(grp->path)); grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); - grp = H5FL_FREE(H5G_t, grp); + grp = H5FL_FREE(H5G_t, grp); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_root_free() */ - /*------------------------------------------------------------------------- * Function: H5G_root_loc * @@ -378,8 +365,8 @@ H5G_root_free(H5G_t *grp) herr_t H5G_root_loc(H5F_t *f, H5G_loc_t *loc) { - H5G_t *root_grp; /* Pointer to root group's info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_t *root_grp; /* Pointer to root group's info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -391,9 +378,9 @@ H5G_root_loc(H5F_t *f, H5G_loc_t *loc) HDassert(root_grp); /* Build the group location for the root group */ - if(NULL == (loc->oloc = H5G_oloc(root_grp))) + if (NULL == (loc->oloc = H5G_oloc(root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (loc->path = H5G_nameof(root_grp))) + if (NULL == (loc->path = H5G_nameof(root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Patch up root group's object location to reflect this file */ @@ -401,12 +388,11 @@ H5G_root_loc(H5F_t *f, H5G_loc_t *loc) * share an underlying low-level file) */ /* (but only for non-mounted files) */ - if(!H5F_is_mount(f)) { - loc->oloc->file = f; + if (!H5F_is_mount(f)) { + loc->oloc->file = f; loc->oloc->holding_file = FALSE; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_root_loc() */ - diff --git a/src/H5Gstab.c b/src/H5Gstab.c index e8d38b9..688fed1 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -20,25 +20,22 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -46,21 +43,21 @@ /* User data for finding link information from B-tree */ typedef struct { /* downward */ - const char *name; /* Name to search for */ - H5HL_t *heap; /* Local heap for group */ + const char *name; /* Name to search for */ + H5HL_t * heap; /* Local heap for group */ /* upward */ - H5O_link_t *lnk; /* Caller's link location */ + H5O_link_t *lnk; /* Caller's link location */ } H5G_stab_fnd_ud_t; /* Data passed through B-tree iteration for looking up a name by index */ typedef struct H5G_bt_it_gnbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ - H5HL_t *heap; /*symbol table heap */ + H5HL_t * heap; /*symbol table heap */ /* upward */ - char *name; /*member name to be returned */ + char *name; /*member name to be returned */ } H5G_bt_it_gnbi_t; #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -68,10 +65,10 @@ typedef struct H5G_bt_it_gnbi_t { typedef struct H5G_bt_it_gtbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ - H5F_t *f; /* Pointer to file that symbol table is in */ + H5F_t * f; /* Pointer to file that symbol table is in */ /* upward */ - H5G_obj_t type; /*member type to be returned */ + H5G_obj_t type; /*member type to be returned */ } H5G_bt_it_gtbi_t; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -79,40 +76,33 @@ typedef struct H5G_bt_it_gtbi_t { typedef struct H5G_bt_it_lbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ - H5HL_t *heap; /*symbol table heap */ + H5HL_t * heap; /*symbol table heap */ /* upward */ - H5O_link_t *lnk; /*link to be returned */ - hbool_t found; /*whether we found the link */ + H5O_link_t *lnk; /*link to be returned */ + hbool_t found; /*whether we found the link */ } H5G_bt_it_lbi_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__stab_create_components * @@ -135,9 +125,9 @@ typedef struct H5G_bt_it_lbi_t { herr_t H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - size_t name_offset; /* Offset of "" name */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_t *heap = NULL; /* Pointer to local heap */ + size_t name_offset; /* Offset of "" name */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -149,19 +139,19 @@ H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint) HDassert(size_hint > 0); /* Create the B-tree */ - if(H5B_create(f, H5B_SNODE, NULL, &(stab->btree_addr)/*out*/) < 0) + if (H5B_create(f, H5B_SNODE, NULL, &(stab->btree_addr) /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree") /* Create symbol table private heap */ - if(H5HL_create(f, size_hint, &(stab->heap_addr)/*out*/) < 0) + if (H5HL_create(f, size_hint, &(stab->heap_addr) /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Insert name into the heap */ - if(UFAIL == (name_offset = H5HL_insert(f, heap, (size_t)1, ""))) + if (UFAIL == (name_offset = H5HL_insert(f, heap, (size_t)1, ""))) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert name into heap") /* @@ -172,13 +162,12 @@ H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint) done: /* Release resources */ - if(heap && FAIL == H5HL_unprotect(heap)) + if (heap && FAIL == H5HL_unprotect(heap)) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_create_components() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_create * @@ -202,9 +191,9 @@ done: herr_t H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, H5O_stab_t *stab) { - size_t heap_hint; /* Local heap size hint */ - size_t size_hint; /* Local heap size hint */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t heap_hint; /* Local heap size hint */ + size_t size_hint; /* Local heap size hint */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -215,30 +204,32 @@ H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, H5O_stab_t *stab HDassert(stab); /* Adjust the size hint, if necessary */ - if(ginfo->lheap_size_hint == 0) - heap_hint = 8 + /* "null" name inserted for B-tree */ - (ginfo->est_num_entries * H5HL_ALIGN(ginfo->est_name_len + 1)) + /* estimated size of names for links, aligned for inserting into local heap */ - H5HL_SIZEOF_FREE(grp_oloc->file); /* Free list entry in local heap */ + if (ginfo->lheap_size_hint == 0) + heap_hint = + 8 + /* "null" name inserted for B-tree */ + (ginfo->est_num_entries * + H5HL_ALIGN(ginfo->est_name_len + + 1)) + /* estimated size of names for links, aligned for inserting into local heap */ + H5HL_SIZEOF_FREE(grp_oloc->file); /* Free list entry in local heap */ else heap_hint = ginfo->lheap_size_hint; size_hint = MAX(heap_hint, H5HL_SIZEOF_FREE(grp_oloc->file) + 2); /* Go create the B-tree & local heap */ - if(H5G__stab_create_components(grp_oloc->file, stab, size_hint) < 0) + if (H5G__stab_create_components(grp_oloc->file, stab, size_hint) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create symbol table components") /* * Insert the symbol table message into the object header and the symbol * table entry. */ - if(H5O_msg_create(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME, stab) < 0) + if (H5O_msg_create(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME, stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_create() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_insert_real * @@ -255,12 +246,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, - H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info) +H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, H5O_link_t *obj_lnk, + H5O_type_t obj_type, const void *crt_info) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5G_bt_ins_t udata; /* Data to pass through B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + H5G_bt_ins_t udata; /* Data to pass through B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -271,29 +262,28 @@ H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, HDassert(obj_lnk); /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Initialize data to pass through B-tree */ udata.common.name = name; udata.common.heap = heap; - udata.lnk = obj_lnk; - udata.obj_type = obj_type; - udata.crt_info = crt_info; + udata.lnk = obj_lnk; + udata.obj_type = obj_type; + udata.crt_info = crt_info; /* Insert into symbol table */ - if(H5B_insert(f, H5B_SNODE, stab->btree_addr, &udata) < 0) + if (H5B_insert(f, H5B_SNODE, stab->btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_insert_real() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_insert * @@ -310,11 +300,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info) +H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, H5O_type_t obj_type, + const void *crt_info) { - H5O_stab_t stab; /* Symbol table message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_stab_t stab; /* Symbol table message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -324,17 +314,16 @@ H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, HDassert(obj_lnk); /* Retrieve symbol table message */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") - if(H5G__stab_insert_real(grp_oloc->file, &stab, name, obj_lnk, obj_type, crt_info) < 0) + if (H5G__stab_insert_real(grp_oloc->file, &stab, name, obj_lnk, obj_type, crt_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_insert() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_remove * @@ -348,13 +337,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__stab_remove(const H5O_loc_t *loc, H5RS_str_t *grp_full_path_r, - const char *name) +H5G__stab_remove(const H5O_loc_t *loc, H5RS_str_t *grp_full_path_r, const char *name) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5O_stab_t stab; /*symbol table message */ - H5G_bt_rm_t udata; /*data to pass through B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + H5O_stab_t stab; /*symbol table message */ + H5G_bt_rm_t udata; /*data to pass through B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -362,31 +350,30 @@ H5G__stab_remove(const H5O_loc_t *loc, H5RS_str_t *grp_full_path_r, HDassert(name && *name); /* Read in symbol table message */ - if(NULL == H5O_msg_read(loc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(loc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(loc->file, stab.heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(loc->file, stab.heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Initialize data to pass through B-tree */ - udata.common.name = name; - udata.common.heap = heap; + udata.common.name = name; + udata.common.heap = heap; udata.grp_full_path_r = grp_full_path_r; /* Remove from symbol table */ - if(H5B_remove(loc->file, H5B_SNODE, stab.btree_addr, &udata) < 0) + if (H5B_remove(loc->file, H5B_SNODE, stab.btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_remove_by_idx * @@ -400,55 +387,54 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__stab_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, - H5_iter_order_t order, hsize_t n) +H5G__stab_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, H5_iter_order_t order, + hsize_t n) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5O_stab_t stab; /* Symbol table message */ - H5G_bt_rm_t udata; /* Data to pass through B-tree */ - H5O_link_t obj_lnk; /* Object's link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + H5O_stab_t stab; /* Symbol table message */ + H5G_bt_rm_t udata; /* Data to pass through B-tree */ + H5O_link_t obj_lnk; /* Object's link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(grp_oloc && grp_oloc->file); /* Look up name of link to remove, by index */ - if(H5G__stab_lookup_by_idx(grp_oloc, order, n, &obj_lnk) < 0) + if (H5G__stab_lookup_by_idx(grp_oloc, order, n, &obj_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get link information") lnk_copied = TRUE; /* Read in symbol table message */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Initialize data to pass through B-tree */ - udata.common.name = obj_lnk.name; - udata.common.heap = heap; + udata.common.name = obj_lnk.name; + udata.common.heap = heap; udata.grp_full_path_r = grp_full_path_r; /* Remove link from symbol table */ - if(H5B_remove(grp_oloc->file, H5B_SNODE, stab.btree_addr, &udata) < 0) + if (H5B_remove(grp_oloc->file, H5B_SNODE, stab.btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") /* Reset the link information, if we have a copy */ - if(lnk_copied) + if (lnk_copied) H5O_msg_reset(H5O_LINK_ID, &obj_lnk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_delete * @@ -464,9 +450,9 @@ done: herr_t H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5G_bt_rm_t udata; /*data to pass through B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + H5G_bt_rm_t udata; /*data to pass through B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -476,7 +462,7 @@ H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab) HDassert(H5F_addr_defined(stab->heap_addr)); /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Set up user data for B-tree deletion */ @@ -484,27 +470,26 @@ H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab) udata.common.heap = heap; /* Delete entire B-tree */ - if(H5B_delete(f, H5B_SNODE, stab->btree_addr, &udata) < 0) + if (H5B_delete(f, H5B_SNODE, stab->btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete symbol table B-tree") /* Release resources */ - if(H5HL_unprotect(heap) < 0) + if (H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") heap = NULL; /* Delete local heap for names */ - if(H5HL_delete(f, stab->heap_addr) < 0) + if (H5HL_delete(f, stab->heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete symbol table heap") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_delete() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_iterate * @@ -518,13 +503,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, - hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data) +H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + H5G_lib_iterate_t op, void *op_data) { - H5HL_t *heap = NULL; /* Local heap for group */ - H5O_stab_t stab; /* Info about symbol table */ - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - herr_t ret_value = FAIL; /* Return value */ + H5HL_t * heap = NULL; /* Local heap for group */ + H5O_stab_t stab; /* Info about symbol table */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oloc->addr) @@ -533,70 +518,69 @@ H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, HDassert(op); /* Get the B-tree info */ - if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Check on iteration order */ /* ("native" iteration order is increasing for this link storage mechanism) */ - if(order != H5_ITER_DEC) { - H5G_bt_it_it_t udata; /* User data to pass to B-tree callback */ + if (order != H5_ITER_DEC) { + H5G_bt_it_it_t udata; /* User data to pass to B-tree callback */ /* Build udata to pass through H5B_iterate() to H5G__node_iterate() */ - udata.heap = heap; - udata.skip = skip; + udata.heap = heap; + udata.skip = skip; udata.final_ent = last_lnk; - udata.op = op; - udata.op_data = op_data; + udata.op = op; + udata.op_data = op_data; /* Iterate over the group members */ - if((ret_value = H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_iterate, &udata)) < 0) + if ((ret_value = H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_iterate, &udata)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); /* Check for too high of a starting index (ex post facto :-) */ /* (Skipping exactly as many entries as are in the group is currently an error) */ - if(skip > 0 && skip >= *last_lnk) + if (skip > 0 && skip >= *last_lnk) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") } /* end if */ else { - H5G_bt_it_bt_t udata; /* User data to pass to B-tree callback */ + H5G_bt_it_bt_t udata; /* User data to pass to B-tree callback */ /* Build udata to pass through H5B_iterate() to H5G__node_build_table() */ udata.alloc_nlinks = 0; - udata.heap = heap; - udata.ltable = <able; + udata.heap = heap; + udata.ltable = <able; /* Iterate over the group members */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_build_table, &udata) < 0) + if (H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_build_table, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to build link table") /* Check for skipping out of bounds */ - if(skip > 0 && (size_t)skip >= ltable.nlinks) + if (skip > 0 && (size_t)skip >= ltable.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Sort link table in correct iteration order */ - if(H5G__link_sort_table(<able, H5_INDEX_NAME, order) < 0) + if (H5G__link_sort_table(<able, H5_INDEX_NAME, order) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") /* Iterate over links in table */ - if((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_count * @@ -612,8 +596,8 @@ done: herr_t H5G__stab_count(const H5O_loc_t *oloc, hsize_t *num_objs) { - H5O_stab_t stab; /* Info about symbol table */ - herr_t ret_value = SUCCEED; + H5O_stab_t stab; /* Info about symbol table */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_TAG(oloc->addr) @@ -625,18 +609,17 @@ H5G__stab_count(const H5O_loc_t *oloc, hsize_t *num_objs) *num_objs = 0; /* Get the B-tree info */ - if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Iterate over the group members */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, num_objs) < 0) + if (H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, num_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_count() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_bh_size * @@ -652,9 +635,9 @@ done: herr_t H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, H5_ih_info_t *bh_info) { - hsize_t snode_size; /* Symbol table node size */ - H5B_info_t bt_info; /* B-tree node info */ - herr_t ret_value = SUCCEED; + hsize_t snode_size; /* Symbol table node size */ + H5B_info_t bt_info; /* B-tree node info */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -667,21 +650,20 @@ H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, H5_ih_info_t *bh_info) snode_size = 0; /* Get the B-tree & symbol table node size info */ - if(H5B_get_info(f, H5B_SNODE, stab->btree_addr, &bt_info, H5G__node_iterate_size, &snode_size) < 0) + if (H5B_get_info(f, H5B_SNODE, stab->btree_addr, &bt_info, H5G__node_iterate_size, &snode_size) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iteration operator failed") /* Add symbol table & B-tree node sizes to index info */ bh_info->index_size += snode_size + bt_info.size; /* Get the size of the local heap for the group */ - if(H5HL_heapsize(f, stab->heap_addr, &(bh_info->heap_size)) < 0) + if (H5HL_heapsize(f, stab->heap_addr, &(bh_info->heap_size)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "iteration operator failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_bh_size() */ - /*------------------------------------------------------------------------- * Function: H5G_stab_get_name_by_idx_cb * @@ -699,10 +681,10 @@ done: static herr_t H5G_stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) { - H5G_bt_it_gnbi_t *udata = (H5G_bt_it_gnbi_t *)_udata; - size_t name_off; /* Offset of name in heap */ - const char *name; /* Pointer to name string in heap */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_bt_it_gnbi_t *udata = (H5G_bt_it_gnbi_t *)_udata; + size_t name_off; /* Offset of name in heap */ + const char * name; /* Pointer to name string in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -713,17 +695,16 @@ H5G_stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) /* Get name offset in heap */ name_off = ent->name_off; - if((name = (const char *)H5HL_offset_into(udata->heap, name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(udata->heap, name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table link name") - if((udata->name = H5MM_strdup(name)) == NULL) + if ((udata->name = H5MM_strdup(name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to duplicate symbol table link name") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_stab_get_name_by_idx_cb */ - /*------------------------------------------------------------------------- * Function: H5G__stab_get_name_by_idx * @@ -738,14 +719,13 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, - char* name, size_t size) +H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char *name, size_t size) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5O_stab_t stab; /* Info about local heap & B-tree */ - H5G_bt_it_gnbi_t udata; /* Iteration information */ - hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ - ssize_t ret_value = -1; /* Return value */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + H5O_stab_t stab; /* Info about local heap & B-tree */ + H5G_bt_it_gnbi_t udata; /* Iteration information */ + hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ + ssize_t ret_value = -1; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); @@ -756,19 +736,19 @@ H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t HDassert(oloc); /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Remap index for decreasing iteration order */ - if(order == H5_ITER_DEC) { - hsize_t nlinks = 0; /* Number of links in group */ + if (order == H5_ITER_DEC) { + hsize_t nlinks = 0; /* Number of links in group */ /* Iterate over the symbol table nodes, to count the links */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, &nlinks) < 0) + if (H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, &nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed") /* Map decreasing iteration order index to increasing iteration order index */ @@ -776,44 +756,43 @@ H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t } /* end if */ /* Set iteration information */ - udata.common.idx = n; + udata.common.idx = n; udata.common.num_objs = 0; - udata.common.op = H5G_stab_get_name_by_idx_cb; - udata.heap = heap; - udata.name = NULL; - udata_valid = TRUE; + udata.common.op = H5G_stab_get_name_by_idx_cb; + udata.heap = heap; + udata.name = NULL; + udata_valid = TRUE; /* Iterate over the group members */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) + if (H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed") /* If we don't know the name now, we almost certainly went out of bounds */ - if(udata.name == NULL) + if (udata.name == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "index out of bound") /* Get the length of the name */ ret_value = (ssize_t)HDstrlen(udata.name); /* Copy the name into the user's buffer, if given */ - if(name) { + if (name) { HDstrncpy(name, udata.name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; + if ((size_t)ret_value >= size) + name[size - 1] = '\0'; } /* end if */ done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") /* Free the duplicated name */ - if(udata_valid && udata.name != NULL) + if (udata_valid && udata.name != NULL) H5MM_xfree(udata.name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_get_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G_stab_lookup_cb * @@ -831,22 +810,21 @@ done: static herr_t H5G_stab_lookup_cb(const H5G_entry_t *ent, void *_udata) { - H5G_stab_fnd_ud_t *udata = (H5G_stab_fnd_ud_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_stab_fnd_ud_t *udata = (H5G_stab_fnd_ud_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check for setting link info */ - if(udata->lnk) + if (udata->lnk) /* Convert the entry to a link */ - if(H5G__ent_to_link(udata->lnk, udata->heap, ent, udata->name) < 0) + if (H5G__ent_to_link(udata->lnk, udata->heap, ent, udata->name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_stab_lookup_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_lookup * @@ -863,11 +841,11 @@ done: htri_t H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5G_bt_lkp_t bt_udata; /* Data to pass through B-tree */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + H5G_bt_lkp_t bt_udata; /* Data to pass through B-tree */ H5G_stab_fnd_ud_t udata; /* 'User data' to give to callback */ - H5O_stab_t stab; /* Symbol table message */ - htri_t ret_value = FAIL; /* Return value */ + H5O_stab_t stab; /* Symbol table message */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -877,37 +855,36 @@ H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) HDassert(lnk); /* Retrieve the symbol table message for the group */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't read message") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Set up user data to pass to 'find' operation callback */ udata.name = name; - udata.lnk = lnk; + udata.lnk = lnk; udata.heap = heap; /* Set up the user data for actual B-tree find operation */ bt_udata.common.name = name; bt_udata.common.heap = heap; - bt_udata.op = H5G_stab_lookup_cb; - bt_udata.op_data = &udata; + bt_udata.op = H5G_stab_lookup_cb; + bt_udata.op_data = &udata; /* Search the B-tree */ - if((ret_value = H5B_find(grp_oloc->file, H5B_SNODE, stab.btree_addr, &bt_udata)) < 0) + if ((ret_value = H5B_find(grp_oloc->file, H5B_SNODE, stab.btree_addr, &bt_udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_lookup() */ - /*------------------------------------------------------------------------- * Function: H5G_stab_lookup_by_idx_cb * @@ -926,8 +903,8 @@ static herr_t H5G_stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata) { H5G_bt_it_lbi_t *udata = (H5G_bt_it_lbi_t *)_udata; - const char *name; /* Pointer to name string in heap */ - herr_t ret_value = SUCCEED; /* Return value */ + const char * name; /* Pointer to name string in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -936,11 +913,11 @@ H5G_stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata) HDassert(udata && udata->heap); /* Get a pointer to the link name */ - if((name = (const char *)H5HL_offset_into(udata->heap, ent->name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(udata->heap, ent->name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table link name") /* Convert the entry to a link */ - if(H5G__ent_to_link(udata->lnk, udata->heap, ent, name) < 0) + if (H5G__ent_to_link(udata->lnk, udata->heap, ent, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link") udata->found = TRUE; @@ -948,7 +925,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_stab_lookup_by_idx_cb */ - /*------------------------------------------------------------------------- * Function: H5G__stab_lookup_by_idx * @@ -963,13 +939,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, - H5O_link_t *lnk) +H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - H5G_bt_it_lbi_t udata; /* Iteration information */ - H5O_stab_t stab; /* Symbol table message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + H5G_bt_it_lbi_t udata; /* Iteration information */ + H5O_stab_t stab; /* Symbol table message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -978,19 +953,19 @@ H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_ HDassert(lnk); /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Remap index for decreasing iteration order */ - if(order == H5_ITER_DEC) { - hsize_t nlinks = 0; /* Number of links in group */ + if (order == H5_ITER_DEC) { + hsize_t nlinks = 0; /* Number of links in group */ /* Iterate over the symbol table nodes, to count the links */ - if(H5B_iterate(grp_oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, &nlinks) < 0) + if (H5B_iterate(grp_oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, &nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed") /* Map decreasing iteration order index to increasing iteration order index */ @@ -998,31 +973,31 @@ H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_ } /* end if */ /* Set iteration information */ - udata.common.idx = n; + udata.common.idx = n; udata.common.num_objs = 0; - udata.common.op = H5G_stab_lookup_by_idx_cb; - udata.heap = heap; - udata.lnk = lnk; - udata.found = FALSE; + udata.common.op = H5G_stab_lookup_by_idx_cb; + udata.heap = heap; + udata.lnk = lnk; + udata.found = FALSE; /* Iterate over the group members */ - if(H5B_iterate(grp_oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) + if (H5B_iterate(grp_oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed") /* If we didn't find the link, we almost certainly went out of bounds */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "index out of bound") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_lookup_by_idx() */ #ifndef H5_STRICT_FORMAT_CHECKS - + /*------------------------------------------------------------------------- * Function: H5G__stab_valid * @@ -1048,58 +1023,58 @@ done: herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab) { - H5O_stab_t stab; /* Current symbol table */ - H5HL_t *heap = NULL; /* Pointer to local heap */ - hbool_t changed = FALSE; /* Whether stab has been modified */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_stab_t stab; /* Current symbol table */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + hbool_t changed = FALSE; /* Whether stab has been modified */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) /* Read the symbol table message */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message"); /* Check if the symbol table message's b-tree address is valid */ - if(H5B_valid(grp_oloc->file, H5B_SNODE, stab.btree_addr) < 0) { + if (H5B_valid(grp_oloc->file, H5B_SNODE, stab.btree_addr) < 0) { /* Address is invalid, try the b-tree address in the alternate symbol * table message */ - if(!alt_stab || H5B_valid(grp_oloc->file, H5B_SNODE, alt_stab->btree_addr) < 0) + if (!alt_stab || H5B_valid(grp_oloc->file, H5B_SNODE, alt_stab->btree_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to locate b-tree") else { /* The alternate symbol table's b-tree address is valid. Adjust the * symbol table message in the group. */ stab.btree_addr = alt_stab->btree_addr; - changed = TRUE; + changed = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the symbol table message's heap address is valid */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) { + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) { /* Address is invalid, try the heap address in the alternate symbol * table message */ - if(!alt_stab || NULL == (heap = H5HL_protect(grp_oloc->file, alt_stab->heap_addr, H5AC__READ_ONLY_FLAG))) + if (!alt_stab || + NULL == (heap = H5HL_protect(grp_oloc->file, alt_stab->heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "unable to locate heap") else { /* The alternate symbol table's heap address is valid. Adjust the * symbol table message in the group. */ stab.heap_addr = alt_stab->heap_addr; - changed = TRUE; + changed = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Update the symbol table message and clear errors if necessary */ - if(changed) { + if (changed) { H5E_clear_stack(NULL); - if(H5O_msg_write(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME | H5O_UPDATE_FORCE, &stab) < 0) + if (H5O_msg_write(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME | H5O_UPDATE_FORCE, &stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to correct symbol table message") } /* end if */ done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_valid */ #endif /* H5_STRICT_FORMAT_CHECKS */ - diff --git a/src/H5Gtest.c b/src/H5Gtest.c index f9ab6f2..994ed49 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -21,58 +21,49 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ -#define H5G_TESTING /*suppress warning about H5G testing funcs*/ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ +#define H5G_TESTING /*suppress warning about H5G testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*-------------------------------------------------------------------------- NAME H5G__is_empty_test @@ -95,105 +86,104 @@ htri_t H5G__is_empty_test(hid_t gid) { - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = FALSE; /* Indicate that a header message is present */ - htri_t linfo_exists = FALSE;/* Indicate that the 'link info' message is present */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - htri_t ret_value = TRUE; /* Return value */ + H5G_t * grp = NULL; /* Pointer to group */ + htri_t msg_exists = FALSE; /* Indicate that a header message is present */ + htri_t linfo_exists = FALSE; /* Indicate that the 'link info' message is present */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* "New format" checks */ /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) { + if (msg_exists > 0) { /* Sanity check that new group format shouldn't have old messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") HGOTO_DONE(FALSE) } /* end if */ /* Check for a link info message */ - if((linfo_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) + if ((linfo_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(linfo_exists > 0) { - H5O_linfo_t linfo; /* Link info message */ + if (linfo_exists > 0) { + H5O_linfo_t linfo; /* Link info message */ /* Sanity check that new group format shouldn't have old messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link info messages found") /* Get the link info */ - if(H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) + if (H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ - if(H5F_addr_defined(linfo.fheap_addr)) + if (H5F_addr_defined(linfo.fheap_addr)) HGOTO_DONE(FALSE) - if(H5F_addr_defined(linfo.name_bt2_addr)) + if (H5F_addr_defined(linfo.name_bt2_addr)) HGOTO_DONE(FALSE) - if(H5F_addr_defined(linfo.corder_bt2_addr)) + if (H5F_addr_defined(linfo.corder_bt2_addr)) HGOTO_DONE(FALSE) /* Check for link count */ - if(linfo.nlinks > 0) + if (linfo.nlinks > 0) HGOTO_DONE(FALSE) } /* end if */ /* "Old format" checks */ /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) { - H5O_stab_t stab; /* Info about local heap & B-tree */ - hsize_t nlinks; /* Number of links in the group */ + if (msg_exists > 0) { + H5O_stab_t stab; /* Info about local heap & B-tree */ + hsize_t nlinks; /* Number of links in the group */ /* Sanity check that old group format shouldn't have new messages */ - if(linfo_exists > 0) + if (linfo_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link info messages found") - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and group info messages found") /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbol table message") /* Get the count of links in the group */ - if(H5G__stab_count(&(grp->oloc), &nlinks) < 0) + if (H5G__stab_count(&(grp->oloc), &nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to count links") /* Check for link count */ - if(nlinks > 0) + if (nlinks > 0) HGOTO_DONE(FALSE) } /* end if */ done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__is_empty_test() */ +} /* H5G__is_empty_test() */ - /*-------------------------------------------------------------------------- NAME H5G__has_links_test @@ -216,52 +206,51 @@ done: htri_t H5G__has_links_test(hid_t gid, unsigned *nmsgs) { - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - htri_t ret_value = TRUE; /* Return value */ + H5G_t * grp = NULL; /* Pointer to group */ + htri_t msg_exists = 0; /* Indicate that a header message is present */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists == 0) + if (msg_exists == 0) HGOTO_DONE(FALSE) /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") /* Check if we should retrieve the number of link messages */ - if(nmsgs) { - int msg_count; /* Number of messages of a type */ + if (nmsgs) { + int msg_count; /* Number of messages of a type */ /* Check how many link messages there are */ - if((msg_count = H5O_msg_count(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_count = H5O_msg_count(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count link messages") *nmsgs = (unsigned)msg_count; } /* end if */ done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__has_links_test() */ +} /* H5G__has_links_test() */ - /*-------------------------------------------------------------------------- NAME H5G__has_stab_test @@ -283,42 +272,41 @@ done: htri_t H5G__has_stab_test(hid_t gid) { - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - htri_t ret_value = TRUE; /* Return value */ + H5G_t * grp = NULL; /* Pointer to group */ + htri_t msg_exists = 0; /* Indicate that a header message is present */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists == 0) + if (msg_exists == 0) HGOTO_DONE(FALSE) /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__has_stab_test() */ +} /* H5G__has_stab_test() */ - /*-------------------------------------------------------------------------- NAME H5G__is_new_dense_test @@ -342,59 +330,58 @@ done: htri_t H5G__is_new_dense_test(hid_t gid) { - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - htri_t ret_value = TRUE; /* Return value */ + H5G_t * grp = NULL; /* Pointer to group */ + htri_t msg_exists = 0; /* Indicate that a header message is present */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_DONE(FALSE) /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_DONE(FALSE) /* Check if the group has link info message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) { - H5O_linfo_t linfo; /* Link info message */ + if (msg_exists > 0) { + H5O_linfo_t linfo; /* Link info message */ /* Get the link info */ - if(H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) + if (H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ - if(!H5F_addr_defined(linfo.fheap_addr)) + if (!H5F_addr_defined(linfo.fheap_addr)) HGOTO_DONE(FALSE) - if(!H5F_addr_defined(linfo.name_bt2_addr)) + if (!H5F_addr_defined(linfo.name_bt2_addr)) HGOTO_DONE(FALSE) } /* end if */ done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__is_new_dense_test() */ +} /* H5G__is_new_dense_test() */ - /*-------------------------------------------------------------------------- NAME H5G__new_dense_info_test @@ -419,21 +406,21 @@ done: herr_t H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5O_linfo_t linfo; /* Link info message */ - H5G_t *grp = NULL; /* Pointer to group */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5O_linfo_t linfo; /* Link info message */ + H5G_t * grp = NULL; /* Pointer to group */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; @@ -441,32 +428,34 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) H5_BEGIN_TAG(grp->oloc.addr); /* Get the link info */ - if(H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) + if (H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ - if(!H5F_addr_defined(linfo.fheap_addr)) + if (!H5F_addr_defined(linfo.fheap_addr)) HGOTO_DONE_TAG(FAIL) - if(!H5F_addr_defined(linfo.name_bt2_addr)) + if (!H5F_addr_defined(linfo.name_bt2_addr)) HGOTO_DONE_TAG(FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp->oloc.file, linfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(grp->oloc.file, linfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ - if(H5B2_get_nrec(bt2_name, name_count) < 0) + if (H5B2_get_nrec(bt2_name, name_count) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ - if(H5F_addr_defined(linfo.corder_bt2_addr)) { + if (H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, linfo.corder_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(grp->oloc.file, linfo.corder_bt2_addr, NULL))) + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ - if(H5B2_get_nrec(bt2_corder, corder_count) < 0) - HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") + if (H5B2_get_nrec(bt2_corder, corder_count) < 0) + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, + "unable to retrieve # of records from creation order index") } /* end if */ else *corder_count = 0; @@ -476,17 +465,16 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__new_dense_info_test() */ +} /* H5G__new_dense_info_test() */ - /*-------------------------------------------------------------------------- NAME H5G__lheap_size_test @@ -509,38 +497,37 @@ done: herr_t H5G__lheap_size_test(hid_t gid, size_t *lheap_size) { - H5G_t *grp = NULL; /* Pointer to group */ - H5O_stab_t stab; /* Symbol table message */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_t * grp = NULL; /* Pointer to group */ + H5O_stab_t stab; /* Symbol table message */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Make certain the group has a symbol table message */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbol table message") /* Check the size of the local heap for the group */ - if(H5HL_get_size(grp->oloc.file, stab.heap_addr, lheap_size) < 0) + if (H5HL_get_size(grp->oloc.file, stab.heap_addr, lheap_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't query local heap size") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__lheap_size_test() */ +} /* H5G__lheap_size_test() */ - /*-------------------------------------------------------------------------- NAME H5G__user_path_test @@ -566,10 +553,10 @@ done: herr_t H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *obj_hidden) { - void *obj_ptr; /* Pointer to object for ID */ - H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + void * obj_ptr; /* Pointer to object for ID */ + H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -578,16 +565,16 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign HDassert(obj_hidden); /* Get pointer to object for ID */ - if(NULL == (obj_ptr = H5VL_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID") + if (NULL == (obj_ptr = H5VL_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the symbol table entry */ - switch(H5I_get_type(obj_id)) { + switch (H5I_get_type(obj_id)) { case H5I_GROUP: obj_path = H5G_nameof((H5G_t *)obj_ptr); break; @@ -598,7 +585,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign case H5I_DATATYPE: /* Avoid non-named datatypes */ - if(!H5T_is_named((H5T_t *)obj_ptr)) + if (!H5T_is_named((H5T_t *)obj_ptr)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a named datatype") obj_path = H5T_nameof((H5T_t *)obj_ptr); @@ -627,11 +614,11 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign HDassert(obj_path); /* Retrieve a copy of the user path and put it into the buffer */ - if(obj_path->user_path_r) { + if (obj_path->user_path_r) { ssize_t len = H5RS_len(obj_path->user_path_r); /* Set the user path, if given */ - if(user_path) + if (user_path) HDstrncpy(user_path, H5RS_get_str(obj_path->user_path_r), (size_t)(len + 1)); /* Set the length of the path */ @@ -642,17 +629,16 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign } /* end if */ else { *user_path_len = 0; - *obj_hidden = 0; + *obj_hidden = 0; } /* end else */ done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__user_path_test() */ +} /* H5G__user_path_test() */ - /*------------------------------------------------------------------------- * Function: H5G__verify_cached_stab_test * @@ -671,44 +657,42 @@ done: herr_t H5G__verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent) { - H5O_stab_t stab; /* Symbol table */ - H5HL_t *heap = NULL; /* Pointer to local heap */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_stab_t stab; /* Symbol table */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) /* Verify that stab info is cached in ent */ - if(ent->type != H5G_CACHED_STAB) + if (ent->type != H5G_CACHED_STAB) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "symbol table information is not cached") /* Read the symbol table message from the group */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message") /* Verify that the cached symbol table info matches the symbol table message * in the object header. */ - if((ent->cache.stab.btree_addr != stab.btree_addr) - || (ent->cache.stab.heap_addr != stab.heap_addr)) + if ((ent->cache.stab.btree_addr != stab.btree_addr) || (ent->cache.stab.heap_addr != stab.heap_addr)) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "cached stab info does not match object header") /* Verify that the btree address is valid */ - if(H5B_valid(grp_oloc->file, H5B_SNODE, stab.btree_addr) < 0) + if (H5B_valid(grp_oloc->file, H5B_SNODE, stab.btree_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "b-tree address is invalid") /* Verify that the heap address is valid */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap address is invalid") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__verify_cached_stab_test() */ - /*------------------------------------------------------------------------- * Function: H5G__verify_cached_stabs_test_cb * @@ -725,16 +709,16 @@ done: *------------------------------------------------------------------------- */ static int -H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, - haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void H5_ATTR_UNUSED *udata) +H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, + const void H5_ATTR_UNUSED *_rt_key, void H5_ATTR_UNUSED *udata) { - H5G_node_t *sn = NULL; - H5O_loc_t targ_oloc; - H5O_t *targ_oh = NULL; - htri_t stab_exists; - H5O_stab_t stab; - unsigned i; - int ret_value = H5_ITER_CONT; + H5G_node_t *sn = NULL; + H5O_loc_t targ_oloc; + H5O_t * targ_oh = NULL; + htri_t stab_exists; + H5O_stab_t stab; + unsigned i; + int ret_value = H5_ITER_CONT; FUNC_ENTER_STATIC @@ -743,64 +727,64 @@ H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, HDassert(H5F_addr_defined(addr)); /* Load the node */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* Check each target object to see if its stab message (if present) matches * the cached stab (if present). If one exists, both must exist. */ /* Initialize constant fields in target oloc */ - targ_oloc.file = f; + targ_oloc.file = f; targ_oloc.holding_file = FALSE; /* Iterate over entries */ - for(i = 0; i < sn->nsyms; i++) { + for (i = 0; i < sn->nsyms; i++) { /* Update oloc address */ targ_oloc.addr = sn->entry[i].header; /* Load target object header */ - if(NULL == (targ_oh = H5O_protect(&targ_oloc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (targ_oh = H5O_protect(&targ_oloc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_SYM, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to protect target object header") /* Check if a symbol table message exists */ - if((stab_exists = H5O_msg_exists_oh(targ_oh, H5O_STAB_ID)) < 0) + if ((stab_exists = H5O_msg_exists_oh(targ_oh, H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to check for STAB message") - if(stab_exists) { + if (stab_exists) { /* Read symbol table message */ - if(NULL == H5O_msg_read_oh(f, targ_oh, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read_oh(f, targ_oh, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to read STAB message") /* Check if the stab matches the cached stab info */ - if(sn->entry[i].type != H5G_CACHED_STAB) + if (sn->entry[i].type != H5G_CACHED_STAB) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "STAB message is not cached in group node") - if((sn->entry[i].cache.stab.btree_addr != stab.btree_addr) - || (sn->entry[i].cache.stab.heap_addr != stab.heap_addr)) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "cached symbol table information is incorrect") + if ((sn->entry[i].cache.stab.btree_addr != stab.btree_addr) || + (sn->entry[i].cache.stab.heap_addr != stab.heap_addr)) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, + "cached symbol table information is incorrect") } - else if(sn->entry[i].type == H5G_CACHED_STAB) + else if (sn->entry[i].type == H5G_CACHED_STAB) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "nonexistent STAB message is cached") /* Unprotect target object */ - if(H5O_unprotect(&targ_oloc, targ_oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(&targ_oloc, targ_oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release object header"); targ_oh = NULL; } /* end for */ done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") - if(targ_oh) { + if (targ_oh) { HDassert(ret_value == H5_ITER_ERROR); - if(H5O_unprotect(&targ_oloc, targ_oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(&targ_oloc, targ_oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release object header"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__verify_cached_stabs_test_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__verify_cached_stabs_test * @@ -822,12 +806,12 @@ done: herr_t H5G__verify_cached_stabs_test(hid_t gid) { - H5G_t *grp = NULL; /* Group */ - htri_t stab_exists; - H5O_stab_t stab; /* Symbol table message */ - H5G_bt_common_t udata = {NULL, NULL}; /* Dummy udata so H5B_iterate doesn't freak out */ - haddr_t prev_tag = HADDR_UNDEF; /* Previous metadata tag */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_t * grp = NULL; /* Group */ + htri_t stab_exists; + H5O_stab_t stab; /* Symbol table message */ + H5G_bt_common_t udata = {NULL, NULL}; /* Dummy udata so H5B_iterate doesn't freak out */ + haddr_t prev_tag = HADDR_UNDEF; /* Previous metadata tag */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -835,7 +819,7 @@ H5G__verify_cached_stabs_test(hid_t gid) HDassert(gid >= 0); /* Check args */ - if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set up metadata tagging */ @@ -843,20 +827,20 @@ H5G__verify_cached_stabs_test(hid_t gid) /* Check for group having a symbol table message */ /* Check for the group having a group info message */ - if((stab_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((stab_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") /* No need to check anything if the symbol table doesn't exist */ - if(!stab_exists) + if (!stab_exists) HGOTO_DONE(SUCCEED); /* Read the stab */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get symbol table info") /* Iterate over the b-tree, checking validity of cached information */ - if((ret_value = H5B_iterate(grp->oloc.file, H5B_SNODE, stab.btree_addr, - H5G__verify_cached_stabs_test_cb, &udata)) < 0) + if ((ret_value = H5B_iterate(grp->oloc.file, H5B_SNODE, stab.btree_addr, H5G__verify_cached_stabs_test_cb, + &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "iteration operator failed"); /* Reset metadata tagging */ @@ -865,4 +849,3 @@ H5G__verify_cached_stabs_test(hid_t gid) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__verify_cached_stabs_test() */ - diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 5a4380d..7b2085a 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -26,30 +26,27 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property Lists */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property Lists */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -57,49 +54,42 @@ /* User data for path traversal routine */ typedef struct { /* down */ - hbool_t chk_exists; /* Flag to indicate we are checking if object exists */ + hbool_t chk_exists; /* Flag to indicate we are checking if object exists */ /* up */ - H5G_loc_t *obj_loc; /* Object location */ - hbool_t exists; /* Indicate if object exists */ + H5G_loc_t *obj_loc; /* Object location */ + hbool_t exists; /* Indicate if object exists */ } H5G_trav_slink_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5G__traverse_slink_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5G__traverse_ud(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, unsigned target, hbool_t *obj_exists); +static herr_t H5G__traverse_slink_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5G__traverse_ud(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc /*in,out*/, + unsigned target, hbool_t *obj_exists); static herr_t H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, unsigned target, hbool_t *obj_exists); -static herr_t H5G__traverse_real(const H5G_loc_t *loc, const char *name, - unsigned target, H5G_traverse_t op, void *op_data); - + H5G_loc_t *obj_loc /*in,out*/, unsigned target, hbool_t *obj_exists); +static herr_t H5G__traverse_real(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, + void *op_data); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__traverse_slink_cb * @@ -115,17 +105,17 @@ static herr_t H5G__traverse_real(const H5G_loc_t *loc, const char *name, */ static herr_t H5G__traverse_slink_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5G_trav_slink_t *udata = (H5G_trav_slink_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_trav_slink_t *udata = (H5G_trav_slink_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for dangling soft link */ - if(obj_loc == NULL) { - if(udata->chk_exists) + if (obj_loc == NULL) { + if (udata->chk_exists) udata->exists = FALSE; else HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found") @@ -146,7 +136,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_slink_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__traverse_ud * @@ -161,18 +150,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, unsigned target, hbool_t *obj_exists) +H5G__traverse_ud(const H5G_loc_t *grp_loc /*in,out*/, const H5O_link_t *lnk, H5G_loc_t *obj_loc /*in,out*/, + unsigned target, hbool_t *obj_exists) { - const H5L_class_t *link_class; /* User-defined link class */ - hid_t cb_return = -1; /* The ID the user-defined callback returned */ - H5G_loc_t grp_loc_copy; - H5G_name_t grp_path_copy; - H5O_loc_t grp_oloc_copy; - H5G_loc_t new_loc; /* Group location for newly opened external object */ - H5G_t *grp; - hid_t cur_grp = (-1); - herr_t ret_value = SUCCEED; /* Return value */ + const H5L_class_t *link_class; /* User-defined link class */ + hid_t cb_return = -1; /* The ID the user-defined callback returned */ + H5G_loc_t grp_loc_copy; + H5G_name_t grp_path_copy; + H5O_loc_t grp_oloc_copy; + H5G_loc_t new_loc; /* Group location for newly opened external object */ + H5G_t * grp; + hid_t cur_grp = (-1); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -183,7 +172,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, HDassert(obj_loc); /* Get the link class for this type of link. */ - if(NULL == (link_class = H5L_find_class(lnk->type))) + if (NULL == (link_class = H5L_find_class(lnk->type))) HGOTO_ERROR(H5E_SYM, H5E_NOTREGISTERED, FAIL, "unable to get UD link class") /* Set up location for user-defined callback. Use a copy of our current @@ -191,30 +180,33 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, grp_loc_copy.path = &grp_path_copy; grp_loc_copy.oloc = &grp_oloc_copy; H5G_loc_reset(&grp_loc_copy); - if(H5G_loc_copy(&grp_loc_copy, grp_loc, H5_COPY_DEEP) < 0) + if (H5G_loc_copy(&grp_loc_copy, grp_loc, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object location") /* Create a group ID to pass to the user-defined callback */ - if(NULL == (grp = H5G_open(&grp_loc_copy))) + if (NULL == (grp = H5G_open(&grp_loc_copy))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((cur_grp = H5VL_wrap_register(H5I_GROUP, grp, FALSE)) < 0) + if ((cur_grp = H5VL_wrap_register(H5I_GROUP, grp, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group") - /* User-defined callback function */ + /* User-defined callback function */ #ifndef H5_NO_DEPRECATED_SYMBOLS /* (Backwardly compatible with v0 H5L_class_t traverssal callback) */ - if(link_class->version == H5L_LINK_CLASS_T_VERS_0) - cb_return = (((const H5L_class_0_t *)link_class)->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl()); + if (link_class->version == H5L_LINK_CLASS_T_VERS_0) + cb_return = (((const H5L_class_0_t *)link_class)->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, + lnk->u.ud.size, H5CX_get_lapl()); else - cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl(), H5CX_get_dxpl()); -#else /* H5_NO_DEPRECATED_SYMBOLS */ - cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl(), H5CX_get_dxpl()); + cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, + H5CX_get_lapl(), H5CX_get_dxpl()); +#else /* H5_NO_DEPRECATED_SYMBOLS */ + cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl(), + H5CX_get_dxpl()); #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Check for failing to locate the object */ - if(cb_return < 0) { + if (cb_return < 0) { /* Check if we just needed to know if the object exists */ - if(target & H5G_TARGET_EXISTS) { + if (target & H5G_TARGET_EXISTS) { /* Clear any errors from the stack */ H5E_clear_stack(NULL); @@ -230,7 +222,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, } /* end if */ /* Get the object location information from the ID the user callback returned */ - if(H5G_loc(cb_return, &new_loc) < 0) + if (H5G_loc(cb_return, &new_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to get object location from ID") /* Release any previous location information for the object */ @@ -242,28 +234,27 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, /* Hold the file open until we free this object header (otherwise the * object location will be invalidated when the file closes). */ - if(H5O_loc_hold_file(obj_loc->oloc) < 0) + if (H5O_loc_hold_file(obj_loc->oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to hold file open") /* We have a copy of the location and we're holding the file open. * Close the open ID the user passed back. */ - if(H5I_dec_ref(cb_return) < 0) + if (H5I_dec_ref(cb_return) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") cb_return = (hid_t)(-1); done: /* Close location given to callback. */ - if(cur_grp > 0 && H5I_dec_ref(cur_grp) < 0) + if (cur_grp > 0 && H5I_dec_ref(cur_grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom for current location") - if(ret_value < 0 && cb_return > 0 && H5I_dec_ref(cb_return) < 0) + if (ret_value < 0 && cb_return > 0 && H5I_dec_ref(cb_return) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_ud() */ - /*------------------------------------------------------------------------- * Function: H5G__traverse_slink * @@ -281,17 +272,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, unsigned target, hbool_t *obj_exists) +H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc /*in,out*/, + unsigned target, hbool_t *obj_exists) { - H5G_trav_slink_t udata; /* User data to pass to link traversal callback */ - H5G_name_t tmp_obj_path; /* Temporary copy of object's path */ - hbool_t tmp_obj_path_set = FALSE; /* Flag to indicate that tmp object path is initialized */ - H5O_loc_t tmp_grp_oloc; /* Temporary copy of group entry */ - H5G_name_t tmp_grp_path; /* Temporary copy of group's path */ - H5G_loc_t tmp_grp_loc; /* Temporary copy of group's location */ - hbool_t tmp_grp_loc_set = FALSE; /* Flag to indicate that tmp group location is initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_trav_slink_t udata; /* User data to pass to link traversal callback */ + H5G_name_t tmp_obj_path; /* Temporary copy of object's path */ + hbool_t tmp_obj_path_set = FALSE; /* Flag to indicate that tmp object path is initialized */ + H5O_loc_t tmp_grp_oloc; /* Temporary copy of group entry */ + H5G_name_t tmp_grp_path; /* Temporary copy of group's path */ + H5G_loc_t tmp_grp_loc; /* Temporary copy of group's location */ + hbool_t tmp_grp_loc_set = FALSE; /* Flag to indicate that tmp group location is initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -322,11 +313,11 @@ H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, /* Set up user data for traversal callback */ udata.chk_exists = (target & H5G_TARGET_EXISTS) ? TRUE : FALSE; - udata.exists = FALSE; - udata.obj_loc = obj_loc; + udata.exists = FALSE; + udata.obj_loc = obj_loc; /* Traverse the link */ - if(H5G__traverse_real(&tmp_grp_loc, lnk->u.soft.name, target, H5G__traverse_slink_cb, &udata) < 0) + if (H5G__traverse_real(&tmp_grp_loc, lnk->u.soft.name, target, H5G__traverse_slink_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") /* Pass back information about whether the object exists */ @@ -334,19 +325,18 @@ H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, done: /* Restore object's group hier. path */ - if(tmp_obj_path_set) { + if (tmp_obj_path_set) { H5G_name_free(obj_loc->path); H5G_name_copy(obj_loc->path, &tmp_obj_path, H5_COPY_SHALLOW); } /* end if */ /* Release cloned copy of group location */ - if(tmp_grp_loc_set) + if (tmp_grp_loc_set) H5G_loc_free(&tmp_grp_loc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_slink() */ - /*------------------------------------------------------------------------- * Function: H5G__traverse_special * @@ -361,11 +351,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - unsigned target, hbool_t last_comp, H5G_loc_t *obj_loc, hbool_t *obj_exists) +H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, unsigned target, hbool_t last_comp, + H5G_loc_t *obj_loc, hbool_t *obj_exists) { - size_t nlinks; /* # of soft / UD links left to traverse */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t nlinks; /* # of soft / UD links left to traverse */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -378,23 +368,22 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, * is the last component of the name and the H5G_TARGET_SLINK bit of * TARGET is set then we don't follow it. */ - if(H5L_TYPE_SOFT == lnk->type && - (0 == (target & H5G_TARGET_SLINK) || !last_comp)) { + if (H5L_TYPE_SOFT == lnk->type && (0 == (target & H5G_TARGET_SLINK) || !last_comp)) { /* Get the # of soft / UD links left to traverse */ - if(H5CX_get_nlinks(&nlinks) < 0) + if (H5CX_get_nlinks(&nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") /* Decrement # of links and range check */ - if((nlinks)-- <= 0) + if ((nlinks)-- <= 0) HGOTO_ERROR(H5E_LINK, H5E_NLINKS, FAIL, "too many links") /* Update the # of links in the API context */ - if(H5CX_set_nlinks(nlinks) < 0) + if (H5CX_set_nlinks(nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't update # of soft / UD links to traverse") /* Traverse soft link */ - if(H5G__traverse_slink(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), obj_exists) < 0) + if (H5G__traverse_slink(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), obj_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "symbolic link traversal failed") } /* end if */ @@ -403,23 +392,22 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, * is the last component of the name and the H5G_TARGET_UDLINK bit of * TARGET is set then we don't follow it. */ - if(lnk->type >= H5L_TYPE_UD_MIN && - (0 == (target & H5G_TARGET_UDLINK) || !last_comp) ) { + if (lnk->type >= H5L_TYPE_UD_MIN && (0 == (target & H5G_TARGET_UDLINK) || !last_comp)) { /* Get the # of soft / UD links left to traverse */ - if(H5CX_get_nlinks(&nlinks) < 0) + if (H5CX_get_nlinks(&nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") /* Decrement # of links and range check */ - if((nlinks)-- <= 0) + if ((nlinks)-- <= 0) HGOTO_ERROR(H5E_LINK, H5E_NLINKS, FAIL, "too many links") /* Update the # of links in the API context */ - if(H5CX_set_nlinks(nlinks) < 0) + if (H5CX_set_nlinks(nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't update # of soft / UD links to traverse") /* Traverse user-defined link */ - if(H5G__traverse_ud(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), obj_exists) < 0) + if (H5G__traverse_ud(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), obj_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "user-defined link traversal failed") } /* end if */ @@ -434,9 +422,8 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, * the status of the object (into a hard link), so don't use an 'else' * statement here. -QAK) */ - if(H5F_addr_defined(obj_loc->oloc->addr) && - (0 == (target & H5G_TARGET_MOUNT) || !last_comp)) { - if(H5F_traverse_mount(obj_loc->oloc/*in,out*/) < 0) + if (H5F_addr_defined(obj_loc->oloc->addr) && (0 == (target & H5G_TARGET_MOUNT) || !last_comp)) { + if (H5F_traverse_mount(obj_loc->oloc /*in,out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "mount point traversal failed") } /* end if */ @@ -444,15 +431,14 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, * and obj_loc is in the same file, obj_loc should also hold the * file open so that closing the grp_loc doesn't close the file. */ - if(grp_loc->oloc->holding_file && grp_loc->oloc->file == obj_loc->oloc->file) - if(H5O_loc_hold_file(obj_loc->oloc) < 0) + if (grp_loc->oloc->holding_file && grp_loc->oloc->file == obj_loc->oloc->file) + if (H5O_loc_hold_file(obj_loc->oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to hold file open") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_special() */ - /*------------------------------------------------------------------------- * Function: H5G__traverse_real * @@ -470,27 +456,26 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, - H5G_traverse_t op, void *op_data) +H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5G_traverse_t op, void *op_data) { - H5G_loc_t loc; /* Location of start object */ - H5O_loc_t grp_oloc; /* Object loc. for current group */ - H5G_name_t grp_path; /* Path for current group */ - H5G_loc_t grp_loc; /* Location of group */ - H5O_loc_t obj_oloc; /* Object found */ - H5G_name_t obj_path; /* Path for object found */ - H5G_loc_t obj_loc; /* Location of object */ - size_t nchars; /* component name length */ - H5O_link_t lnk; /* Link information for object */ - hbool_t link_valid = FALSE; /* Flag to indicate that the link information is valid */ - hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ + H5G_loc_t loc; /* Location of start object */ + H5O_loc_t grp_oloc; /* Object loc. for current group */ + H5G_name_t grp_path; /* Path for current group */ + H5G_loc_t grp_loc; /* Location of group */ + H5O_loc_t obj_oloc; /* Object found */ + H5G_name_t obj_path; /* Path for object found */ + H5G_loc_t obj_loc; /* Location of object */ + size_t nchars; /* component name length */ + H5O_link_t lnk; /* Link information for object */ + hbool_t link_valid = FALSE; /* Flag to indicate that the link information is valid */ + hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ H5G_own_loc_t own_loc = H5G_OWN_NONE; /* Enum to indicate whether callback took ownership of locations*/ - hbool_t group_copy = FALSE; /* Flag to indicate that the group entry is copied */ - char comp_buf[1024]; /* Temporary buffer for path components */ - char *comp; /* Pointer to buffer for path components */ - H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ - hbool_t last_comp = FALSE; /* Flag to indicate that a component is the last component in the name */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t group_copy = FALSE; /* Flag to indicate that the group entry is copied */ + char comp_buf[1024]; /* Temporary buffer for path components */ + char * comp; /* Pointer to buffer for path components */ + H5WB_t * wb = NULL; /* Wrapped buffer for temporary buffer */ + hbool_t last_comp = FALSE; /* Flag to indicate that a component is the last component in the name */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -504,8 +489,8 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, * root of the file; for relative names it starts at CWG. */ /* Check if we need to get the root group's entry */ - if('/' == *name) { - H5G_t *root_grp; /* Temporary pointer to root group of file */ + if ('/' == *name) { + H5G_t *root_grp; /* Temporary pointer to root group of file */ /* Look up root group for starting location */ root_grp = H5G_rootof(_loc->oloc->file); @@ -528,72 +513,72 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, #if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG) /* Clear group location */ - if(H5G_loc_reset(&grp_loc) < 0) + if (H5G_loc_reset(&grp_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location") #endif /* H5_USING_MEMCHECKER */ /* Deep copy of the starting location to group location */ - if(H5G_loc_copy(&grp_loc, &loc, H5_COPY_DEEP) < 0) + if (H5G_loc_copy(&grp_loc, &loc, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to copy location") group_copy = TRUE; /* Clear object location */ - if(H5G_loc_reset(&obj_loc) < 0) + if (H5G_loc_reset(&obj_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location") /* Wrap the local buffer for serialized header info */ - if(NULL == (wb = H5WB_wrap(comp_buf, sizeof(comp_buf)))) + if (NULL == (wb = H5WB_wrap(comp_buf, sizeof(comp_buf)))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough */ - if(NULL == (comp = (char *)H5WB_actual(wb, (HDstrlen(name) + 1)))) + if (NULL == (comp = (char *)H5WB_actual(wb, (HDstrlen(name) + 1)))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Traverse the path */ - while((name = H5G__component(name, &nchars)) && *name) { - const char *s; /* Temporary string pointer */ - htri_t lookup_status; /* Status from object lookup */ - hbool_t obj_exists; /* Whether the object exists */ - - /* - * Copy the component name into a null-terminated buffer so - * we can pass it down to the other symbol table functions. - */ - H5MM_memcpy(comp, name, nchars); - comp[nchars] = '\0'; - - /* - * The special name `.' is a no-op. - */ - if('.' == comp[0] && !comp[1]) { - name += nchars; - continue; - } /* end if */ + while ((name = H5G__component(name, &nchars)) && *name) { + const char *s; /* Temporary string pointer */ + htri_t lookup_status; /* Status from object lookup */ + hbool_t obj_exists; /* Whether the object exists */ + + /* + * Copy the component name into a null-terminated buffer so + * we can pass it down to the other symbol table functions. + */ + H5MM_memcpy(comp, name, nchars); + comp[nchars] = '\0'; + + /* + * The special name `.' is a no-op. + */ + if ('.' == comp[0] && !comp[1]) { + name += nchars; + continue; + } /* end if */ /* Check if this is the last component of the name */ - if(!((s = H5G__component(name + nchars, NULL)) && *s)) + if (!((s = H5G__component(name + nchars, NULL)) && *s)) last_comp = TRUE; /* If there's valid information in the link, reset it */ - if(link_valid) { + if (link_valid) { H5O_msg_reset(H5O_LINK_ID, &lnk); link_valid = FALSE; } /* end if */ /* Get information for object in current group */ - if((lookup_status = H5G__obj_lookup(grp_loc.oloc, comp, &lnk/*out*/)) < 0) + if ((lookup_status = H5G__obj_lookup(grp_loc.oloc, comp, &lnk /*out*/)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't look up component") obj_exists = FALSE; /* If the lookup was OK, build object location and traverse special links, etc. */ - if(lookup_status) { + if (lookup_status) { /* Sanity check link and indicate it's valid */ HDassert(lnk.type >= H5L_TYPE_HARD); HDassert(!HDstrcmp(comp, lnk.name)); link_valid = TRUE; /* Build object location from the link */ - if(H5G__link_to_loc(&grp_loc, &lnk, &obj_loc) < 0) + if (H5G__link_to_loc(&grp_loc, &lnk, &obj_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot initialize object location") obj_loc_valid = TRUE; @@ -602,19 +587,19 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, /* Perform any special traversals that the link needs */ /* (soft links, user-defined links, file mounting, etc.) */ - if(H5G__traverse_special(&grp_loc, &lnk, target, last_comp, &obj_loc, &obj_exists) < 0) + if (H5G__traverse_special(&grp_loc, &lnk, target, last_comp, &obj_loc, &obj_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "special link traversal failed") } /* end if */ /* Check for last component in name provided */ - if(last_comp) { - H5O_link_t *cb_lnk; /* Pointer to link info for callback */ - H5G_loc_t *cb_loc; /* Pointer to object location for callback */ + if (last_comp) { + H5O_link_t *cb_lnk; /* Pointer to link info for callback */ + H5G_loc_t * cb_loc; /* Pointer to object location for callback */ /* Set callback parameters appropriately, based on link being found */ - if(lookup_status) { + if (lookup_status) { cb_lnk = &lnk; - if(obj_exists) + if (obj_exists) cb_loc = &obj_loc; else cb_loc = NULL; @@ -626,36 +611,36 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, } /* end else */ /* Call 'operator' routine */ - if((op)(&grp_loc, comp, cb_lnk, cb_loc, op_data, &own_loc) < 0) + if ((op)(&grp_loc, comp, cb_lnk, cb_loc, op_data, &own_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CALLBACK, FAIL, "traversal operator failed") HGOTO_DONE(SUCCEED) } /* end if */ /* Handle lookup failures now */ - if(!lookup_status) { + if (!lookup_status) { /* If an intermediate group doesn't exist & flag is set, create the group */ - if(target & H5G_CRT_INTMD_GROUP) { - const H5O_ginfo_t def_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ - const H5O_linfo_t def_linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ - const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default filter pipeline settings */ - H5O_ginfo_t par_ginfo; /* Group info settings for parent group */ - H5O_linfo_t par_linfo; /* Link info settings for parent group */ - H5O_pline_t par_pline; /* Filter pipeline settings for parent group */ - H5O_linfo_t tmp_linfo; /* Temporary link info settings */ - htri_t exists; /* Whether a group or link info message exists */ - const H5O_ginfo_t *ginfo; /* Group info settings for new group */ - const H5O_linfo_t *linfo; /* Link info settings for new group */ - const H5O_pline_t *pline; /* Filter pipeline settings for new group */ - H5G_obj_create_t gcrt_info; /* Group creation info */ + if (target & H5G_CRT_INTMD_GROUP) { + const H5O_ginfo_t def_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ + const H5O_linfo_t def_linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ + const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default filter pipeline settings */ + H5O_ginfo_t par_ginfo; /* Group info settings for parent group */ + H5O_linfo_t par_linfo; /* Link info settings for parent group */ + H5O_pline_t par_pline; /* Filter pipeline settings for parent group */ + H5O_linfo_t tmp_linfo; /* Temporary link info settings */ + htri_t exists; /* Whether a group or link info message exists */ + const H5O_ginfo_t *ginfo; /* Group info settings for new group */ + const H5O_linfo_t *linfo; /* Link info settings for new group */ + const H5O_pline_t *pline; /* Filter pipeline settings for new group */ + H5G_obj_create_t gcrt_info; /* Group creation info */ /* Check for the parent group having a group info message */ /* (OK if not found) */ - if((exists = H5O_msg_exists(grp_loc.oloc, H5O_GINFO_ID)) < 0) + if ((exists = H5O_msg_exists(grp_loc.oloc, H5O_GINFO_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(exists) { + if (exists) { /* Get the group info for parent group */ - if(NULL == H5O_msg_read(grp_loc.oloc, H5O_GINFO_ID, &par_ginfo)) + if (NULL == H5O_msg_read(grp_loc.oloc, H5O_GINFO_ID, &par_ginfo)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "group info message not present") /* Use parent group info settings */ @@ -668,16 +653,16 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, /* Check for the parent group having a link info message */ /* (OK if not found) */ /* Get the link info for parent group */ - if((exists = H5G__obj_get_linfo(grp_loc.oloc, &par_linfo)) < 0) + if ((exists = H5G__obj_get_linfo(grp_loc.oloc, &par_linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(exists) { + if (exists) { /* Only keep the creation order information from the parent * group's link info */ H5MM_memcpy(&tmp_linfo, &def_linfo, sizeof(H5O_linfo_t)); tmp_linfo.track_corder = par_linfo.track_corder; tmp_linfo.index_corder = par_linfo.index_corder; - linfo = &tmp_linfo; + linfo = &tmp_linfo; } /* end if */ else /* Use default link info settings */ @@ -685,11 +670,11 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, /* Check for the parent group having a filter pipeline message */ /* (OK if not found) */ - if((exists = H5O_msg_exists(grp_loc.oloc, H5O_PLINE_ID)) < 0) + if ((exists = H5O_msg_exists(grp_loc.oloc, H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(exists) { + if (exists) { /* Get the filter pipeline for parent group */ - if(NULL == H5O_msg_read(grp_loc.oloc, H5O_PLINE_ID, &par_pline)) + if (NULL == H5O_msg_read(grp_loc.oloc, H5O_PLINE_ID, &par_pline)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "filter pipeline message not present") /* Use parent filter pipeline settings */ @@ -700,53 +685,55 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, pline = &def_pline; /* Create the intermediate group */ -/* XXX: Should we allow user to control the group creation params here? -QAK */ - gcrt_info.gcpl_id = H5P_GROUP_CREATE_DEFAULT; + /* XXX: Should we allow user to control the group creation params here? -QAK */ + gcrt_info.gcpl_id = H5P_GROUP_CREATE_DEFAULT; gcrt_info.cache_type = H5G_NOTHING_CACHED; HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); - if(H5G__obj_create_real(grp_oloc.file, ginfo, linfo, pline, &gcrt_info, obj_loc.oloc/*out*/) < 0) + if (H5G__obj_create_real(grp_oloc.file, ginfo, linfo, pline, &gcrt_info, + obj_loc.oloc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") /* Insert new group into current group's symbol table */ - if(H5G__loc_insert(&grp_loc, comp, &obj_loc, H5O_TYPE_GROUP, &gcrt_info) < 0) + if (H5G__loc_insert(&grp_loc, comp, &obj_loc, H5O_TYPE_GROUP, &gcrt_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert intermediate group") /* Decrement refcount on intermediate group's object header in memory */ - if(H5O_dec_rc_by_loc(obj_loc.oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + if (H5O_dec_rc_by_loc(obj_loc.oloc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, + "unable to decrement refcount on newly created object") /* Close new group */ - if(H5O_close(obj_loc.oloc, NULL) < 0) + if (H5O_close(obj_loc.oloc, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") /* If the parent group was holding the file open, the * newly-created group should, as well. */ - if(grp_loc.oloc->holding_file) - if(H5O_loc_hold_file(obj_loc.oloc) < 0) + if (grp_loc.oloc->holding_file) + if (H5O_loc_hold_file(obj_loc.oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to hold file open") /* Reset any non-default object header messages */ - if(ginfo != &def_ginfo) + if (ginfo != &def_ginfo) /* (Casting away const OK - QAK) */ - if(H5O_msg_reset(H5O_GINFO_ID, (void *)ginfo) < 0) + if (H5O_msg_reset(H5O_GINFO_ID, (void *)ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset group info message") - if(linfo != &def_linfo) + if (linfo != &def_linfo) /* (Casting away const OK - QAK) */ - if(H5O_msg_reset(H5O_LINFO_ID, (void *)linfo) < 0) + if (H5O_msg_reset(H5O_LINFO_ID, (void *)linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link info message") - if(pline != &def_pline) + if (pline != &def_pline) /* (Casting away const OK - QAK) */ - if(H5O_msg_reset(H5O_PLINE_ID, (void *)pline) < 0) + if (H5O_msg_reset(H5O_PLINE_ID, (void *)pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset I/O pipeline message") } /* end if */ else HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found") } /* end if */ - /* - * Advance to the next component of the path. - */ + /* + * Advance to the next component of the path. + */ /* Transfer "ownership" of the object's information to the group object */ H5G_loc_free(&grp_loc); @@ -754,8 +741,8 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5G_loc_reset(&obj_loc); obj_loc_valid = FALSE; - /* Advance to next component in string */ - name += nchars; + /* Advance to next component in string */ + name += nchars; } /* end while */ /* Call 'operator' routine */ @@ -765,41 +752,40 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, * NULL. */ HDassert(group_copy); - if((op)(NULL, ".", NULL, &grp_loc, op_data, &own_loc) < 0) + if ((op)(NULL, ".", NULL, &grp_loc, op_data, &own_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "traversal operator failed") /* If the callback took ownership of the object location, it actually has * ownership of grp_loc. It shouldn't have tried to take ownership of * the "group location", which was NULL. */ - HDassert(!(own_loc & H5G_OWN_GRP_LOC)); - if(own_loc & H5G_OWN_OBJ_LOC) - own_loc |= H5G_OWN_GRP_LOC; + HDassert(!(own_loc & H5G_OWN_GRP_LOC)); + if (own_loc & H5G_OWN_OBJ_LOC) + own_loc |= H5G_OWN_GRP_LOC; done: /* If there's been an error, the callback doesn't really get ownership of * any location and we should close them both */ - if(ret_value < 0) + if (ret_value < 0) own_loc = H5G_OWN_NONE; /* Free all open locations. This also closes any open external files. */ - if(obj_loc_valid && !(own_loc & H5G_OWN_OBJ_LOC)) + if (obj_loc_valid && !(own_loc & H5G_OWN_OBJ_LOC)) H5G_loc_free(&obj_loc); - if(group_copy && !(own_loc & H5G_OWN_GRP_LOC)) + if (group_copy && !(own_loc & H5G_OWN_GRP_LOC)) H5G_loc_free(&grp_loc); /* If there's valid information in the link, reset it */ - if(link_valid) - if(H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) + if (link_valid) + if (H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link message") /* Release temporary component buffer */ - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't release wrapped buffer") - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_real() */ - /*------------------------------------------------------------------------- * Function: H5G_traverse * @@ -817,20 +803,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, - void *op_data) +H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, void *op_data) { - size_t orig_nlinks; /* Original value for # of soft / UD links able to traverse */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t orig_nlinks; /* Original value for # of soft / UD links able to traverse */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no name given") - if(!loc) + if (!loc) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no starting location") - if(!op) + if (!op) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no operation provided") /* Retrieve the original # of soft / UD links that are able to be traversed @@ -838,7 +823,7 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver * like they've traversed too many. Nested calls, like in H5L_move(), * may need their own mechanism to set & reset the # of links to traverse) */ - if(H5CX_get_nlinks(&orig_nlinks) < 0) + if (H5CX_get_nlinks(&orig_nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") /* Set up invalid tag. This is a precautionary step only. Setting an invalid @@ -851,17 +836,16 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver H5_BEGIN_TAG(H5AC__INVALID_TAG); /* Go perform "real" traversal */ - if(H5G__traverse_real(loc, name, target, op, op_data) < 0) + if (H5G__traverse_real(loc, name, target, op, op_data) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed") /* Reset tag after traversal */ H5_END_TAG /* Reset the # of soft / UD links that can be traversed */ - if(H5CX_set_nlinks(orig_nlinks) < 0) + if (H5CX_set_nlinks(orig_nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't reset # of soft / UD links to traverse") done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_traverse() */ - diff --git a/src/H5HF.c b/src/H5HF.c index 5d52ca4..5f8ca97 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -31,40 +31,34 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FOprivate.h" /* File objects */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FOprivate.h" /* File objects */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -72,12 +66,10 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -85,8 +77,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Declare a free list to manage the H5HF_t struct */ H5FL_DEFINE_STATIC(H5HF_t); - - /*------------------------------------------------------------------------- * Function: H5HF_op_read * @@ -111,7 +101,6 @@ H5HF_op_read(const void *obj, size_t obj_len, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_op_read() */ - /*------------------------------------------------------------------------- * Function: H5HF_op_write * @@ -131,12 +120,11 @@ H5HF_op_write(const void *obj, size_t obj_len, void *op_data) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Perform "write", using memcpy() */ - H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */ + H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_op_write() */ - /*------------------------------------------------------------------------- * Function: H5HF_create * @@ -154,10 +142,10 @@ H5HF_op_write(const void *obj, size_t obj_len, void *op_data) H5HF_t * H5HF_create(H5F_t *f, const H5HF_create_t *cparam) { - H5HF_t *fh = NULL; /* Pointer to new fractal heap */ - H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - haddr_t fh_addr; /* Heap header address */ - H5HF_t *ret_value = NULL; /* Return value */ + H5HF_t * fh = NULL; /* Pointer to new fractal heap */ + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + haddr_t fh_addr; /* Heap header address */ + H5HF_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -168,25 +156,25 @@ H5HF_create(H5F_t *f, const H5HF_create_t *cparam) HDassert(cparam); /* Create shared fractal heap header */ - if(HADDR_UNDEF == (fh_addr = H5HF_hdr_create(f, cparam))) + if (HADDR_UNDEF == (fh_addr = H5HF_hdr_create(f, cparam))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't create fractal heap header") /* Allocate fractal heap wrapper */ - if(NULL == (fh = H5FL_MALLOC(H5HF_t))) + if (NULL == (fh = H5FL_MALLOC(H5HF_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for fractal heap info") /* Lock the heap header into memory */ - if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header") /* Point fractal heap wrapper at header and bump it's ref count */ fh->hdr = hdr; - if(H5HF_hdr_incr(fh->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") + if (H5HF_hdr_incr(fh->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") /* Increment # of files using this heap header */ - if(H5HF_hdr_fuse_incr(fh->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header") + if (H5HF_hdr_fuse_incr(fh->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header") /* Set file pointer for this heap open context */ fh->f = f; @@ -195,16 +183,15 @@ H5HF_create(H5F_t *f, const H5HF_create_t *cparam) ret_value = fh; done: - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header") - if(!ret_value && fh) - if(H5HF_close(fh) < 0) + if (!ret_value && fh) + if (H5HF_close(fh) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_create() */ - /*------------------------------------------------------------------------- * Function: H5HF_open * @@ -222,9 +209,9 @@ done: H5HF_t * H5HF_open(H5F_t *f, haddr_t fh_addr) { - H5HF_t *fh = NULL; /* Pointer to new fractal heap */ - H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - H5HF_t *ret_value = NULL; /* Return value */ + H5HF_t * fh = NULL; /* Pointer to new fractal heap */ + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + H5HF_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -235,25 +222,25 @@ H5HF_open(H5F_t *f, haddr_t fh_addr) HDassert(H5F_addr_defined(fh_addr)); /* Load the heap header into memory */ - if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header") /* Check for pending heap deletion */ - if(hdr->pending_delete) + if (hdr->pending_delete) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, NULL, "can't open fractal heap pending deletion") /* Create fractal heap info */ - if(NULL == (fh = H5FL_MALLOC(H5HF_t))) + if (NULL == (fh = H5FL_MALLOC(H5HF_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for fractal heap info") /* Point fractal heap wrapper at header */ fh->hdr = hdr; - if(H5HF_hdr_incr(fh->hdr) < 0) + if (H5HF_hdr_incr(fh->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") /* Increment # of files using this heap header */ - if(H5HF_hdr_fuse_incr(fh->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header") + if (H5HF_hdr_fuse_incr(fh->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header") /* Set file pointer for this heap open context */ fh->f = f; @@ -262,16 +249,15 @@ H5HF_open(H5F_t *f, haddr_t fh_addr) ret_value = fh; done: - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header") - if(!ret_value && fh) - if(H5HF_close(fh) < 0) + if (!ret_value && fh) + if (H5HF_close(fh) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_open() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_id_len * @@ -302,7 +288,6 @@ H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_get_id_len() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_heap_addr * @@ -333,7 +318,6 @@ H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr_p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_get_heap_addr() */ - /*------------------------------------------------------------------------- * Function: H5HF_insert * @@ -349,10 +333,10 @@ H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr_p) *------------------------------------------------------------------------- */ herr_t -H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/) +H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id /*out*/) { - H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - herr_t ret_value = SUCCEED; + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -362,7 +346,7 @@ H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/) HDassert(id); /* Check arguments */ - if(size == 0) + if (size == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "can't insert 0-sized objects") /* Set the shared heap header's file context for this operation */ @@ -372,35 +356,34 @@ H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/) hdr = fh->hdr; /* Check for 'huge' object */ - if(size > hdr->max_man_size) { + if (size > hdr->max_man_size) { /* Store 'huge' object in heap */ /* (Casting away const OK - QAK) */ - if(H5HF__huge_insert(hdr, size, (void *)obj, id) < 0) + if (H5HF__huge_insert(hdr, size, (void *)obj, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'huge' object in fractal heap") } /* end if */ /* Check for 'tiny' object */ - else if(size <= hdr->tiny_max_len) { + else if (size <= hdr->tiny_max_len) { /* Store 'tiny' object in heap */ - if(H5HF_tiny_insert(hdr, size, obj, id) < 0) + if (H5HF_tiny_insert(hdr, size, obj, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'tiny' object in fractal heap") } /* end if */ else { /* Check if we are in "append only" mode, or if there's enough room for the object */ - if(hdr->write_once) { -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not supported yet") + if (hdr->write_once) { + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not supported yet") } /* end if */ else { /* Allocate space for object in 'managed' heap */ - if(H5HF__man_insert(hdr, size, obj, id) < 0) + if (H5HF__man_insert(hdr, size, obj, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'managed' object in fractal heap") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_insert() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_obj_len * @@ -417,9 +400,9 @@ done: herr_t H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -434,35 +417,34 @@ H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { - if(H5HF_man_get_obj_len(fh->hdr, id, obj_len_p) < 0) + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if (H5HF_man_get_obj_len(fh->hdr, id, obj_len_p) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'managed' object's length") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { - if(H5HF__huge_get_obj_len(fh->hdr, id, obj_len_p) < 0) + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + if (H5HF__huge_get_obj_len(fh->hdr, id, obj_len_p) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'huge' object's length") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { - if(H5HF_tiny_get_obj_len(fh->hdr, id, obj_len_p) < 0) + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + if (H5HF_tiny_get_obj_len(fh->hdr, id, obj_len_p) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'tiny' object's length") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_get_obj_len() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_obj_off * @@ -479,9 +461,9 @@ done: herr_t H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -496,35 +478,34 @@ H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { H5HF__man_get_obj_off(fh->hdr, id, obj_off_p); } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Huge objects are located directly in the file */ - if(H5HF__huge_get_obj_off(fh->hdr, id, obj_off_p) < 0) + if (H5HF__huge_get_obj_off(fh->hdr, id, obj_off_p) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'huge' object's offset") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Tiny objects are not stored in the heap */ *obj_off_p = (hsize_t)0; } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_get_obj_off() */ - /*------------------------------------------------------------------------- * Function: H5HF_read * @@ -539,11 +520,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_read(H5HF_t *fh, const void *_id, void *obj/*out*/) +H5HF_read(H5HF_t *fh, const void *_id, void *obj /*out*/) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -558,38 +539,37 @@ H5HF_read(H5HF_t *fh, const void *_id, void *obj/*out*/) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { /* Read object from managed heap blocks */ - if(H5HF__man_read(fh->hdr, id, obj) < 0) + if (H5HF__man_read(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Read 'huge' object from file */ - if(H5HF__huge_read(fh->hdr, id, obj) < 0) + if (H5HF__huge_read(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read 'huge' object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Read 'tiny' object from file */ - if(H5HF_tiny_read(fh->hdr, id, obj) < 0) + if (H5HF_tiny_read(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read 'tiny' object from fractal heap") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_read() */ - /*------------------------------------------------------------------------- * Function: H5HF_write * @@ -618,9 +598,9 @@ done: herr_t H5HF_write(H5HF_t *fh, void *_id, hbool_t H5_ATTR_UNUSED *id_changed, const void *obj) { - uint8_t *id = (uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *id = (uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -635,39 +615,38 @@ H5HF_write(H5HF_t *fh, void *_id, hbool_t H5_ATTR_UNUSED *id_changed, const void id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { /* Operate on object from managed heap blocks */ /* (ID can't change and modifying object is "easy" to manage) */ - if(H5HF__man_write(fh->hdr, id, obj) < 0) + if (H5HF__man_write(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "can't write to 'managed' heap object") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Operate on "huge" object */ - if(H5HF__huge_write(fh->hdr, id, obj) < 0) + if (H5HF__huge_write(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "can't write to 'huge' heap object") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Check for writing a 'tiny' object */ /* (which isn't supported yet - ID will change) */ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "modifying 'tiny' object not supported yet") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_write() */ - /*------------------------------------------------------------------------- * Function: H5HF_op * @@ -689,9 +668,9 @@ done: herr_t H5HF_op(H5HF_t *fh, const void *_id, H5HF_operator_t op, void *op_data) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -706,38 +685,37 @@ H5HF_op(H5HF_t *fh, const void *_id, H5HF_operator_t op, void *op_data) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { /* Operate on object from managed heap blocks */ - if(H5HF__man_op(fh->hdr, id, op, op_data) < 0) + if (H5HF__man_op(fh->hdr, id, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Operate on 'huge' object from file */ - if(H5HF__huge_op(fh->hdr, id, op, op_data) < 0) + if (H5HF__huge_op(fh->hdr, id, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on 'huge' object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Operate on 'tiny' object from file */ - if(H5HF_tiny_op(fh->hdr, id, op, op_data) < 0) + if (H5HF_tiny_op(fh->hdr, id, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on 'tiny' object from fractal heap") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_op() */ - /*------------------------------------------------------------------------- * Function: H5HF_remove * @@ -754,9 +732,9 @@ done: herr_t H5HF_remove(H5HF_t *fh, const void *_id) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -771,38 +749,37 @@ H5HF_remove(H5HF_t *fh, const void *_id) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { /* Remove object from managed heap blocks */ - if(H5HF__man_remove(fh->hdr, id) < 0) + if (H5HF__man_remove(fh->hdr, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Remove 'huge' object from file & v2 B-tree tracker */ - if(H5HF__huge_remove(fh->hdr, id) < 0) + if (H5HF__huge_remove(fh->hdr, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove 'huge' object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Remove 'tiny' object from heap statistics */ - if(H5HF_tiny_remove(fh->hdr, id) < 0) + if (H5HF_tiny_remove(fh->hdr, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove 'tiny' object from fractal heap") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF_close * @@ -819,9 +796,9 @@ done: herr_t H5HF_close(H5HF_t *fh) { - hbool_t pending_delete = FALSE; /* Whether the heap is pending deletion */ - haddr_t heap_addr = HADDR_UNDEF; /* Address of heap (for deletion) */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t pending_delete = FALSE; /* Whether the heap is pending deletion */ + haddr_t heap_addr = HADDR_UNDEF; /* Address of heap (for deletion) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -831,7 +808,7 @@ H5HF_close(H5HF_t *fh) HDassert(fh); /* Decrement file reference & check if this is the last open fractal heap using the shared heap header */ - if(0 == H5HF_hdr_fuse_decr(fh->hdr)) { + if (0 == H5HF_hdr_fuse_decr(fh->hdr)) { /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; @@ -841,7 +818,7 @@ H5HF_close(H5HF_t *fh) * a reference loop and the objects couldn't be removed from * the metadata cache - QAK) */ - if(H5HF__space_close(fh->hdr) < 0) + if (H5HF__space_close(fh->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") /* Reset the block iterator, if necessary */ @@ -850,8 +827,8 @@ H5HF_close(H5HF_t *fh) * a reference loop and the objects couldn't be removed from * the metadata cache - QAK) */ - if(H5HF_man_iter_ready(&fh->hdr->next_block)) - if(H5HF_man_iter_reset(&fh->hdr->next_block) < 0) + if (H5HF_man_iter_ready(&fh->hdr->next_block)) + if (H5HF_man_iter_reset(&fh->hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") /* Shut down the huge object information */ @@ -859,36 +836,36 @@ H5HF_close(H5HF_t *fh) * has the address of an object in the file, which might be * modified by the shutdown routine - QAK) */ - if(H5HF__huge_term(fh->hdr) < 0) + if (H5HF__huge_term(fh->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release 'huge' object info") /* Check for pending heap deletion */ - if(fh->hdr->pending_delete) { + if (fh->hdr->pending_delete) { /* Set local info, so heap deletion can occur after decrementing the * header's ref count */ pending_delete = TRUE; - heap_addr = fh->hdr->heap_addr; + heap_addr = fh->hdr->heap_addr; } /* end if */ - } /* end if */ + } /* end if */ /* Decrement the reference count on the heap header */ /* (don't put in H5HF_hdr_fuse_decr() as the heap header may be evicted * immediately -QAK) */ - if(H5HF_hdr_decr(fh->hdr) < 0) + if (H5HF_hdr_decr(fh->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") /* Check for pending heap deletion */ - if(pending_delete) { - H5HF_hdr_t *hdr; /* Another pointer to fractal heap header */ + if (pending_delete) { + H5HF_hdr_t *hdr; /* Another pointer to fractal heap header */ /* Lock the heap header into memory */ - if(NULL == (hdr = H5HF__hdr_protect(fh->f, heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5HF__hdr_protect(fh->f, heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* Delete heap, starting with header (unprotects header) */ - if(H5HF__hdr_delete(hdr) < 0) + if (H5HF__hdr_delete(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") } /* end if */ @@ -899,7 +876,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_close() */ - /*------------------------------------------------------------------------- * Function: H5HF_delete * @@ -916,8 +892,8 @@ done: herr_t H5HF_delete(H5F_t *f, haddr_t fh_addr) { - H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -928,24 +904,23 @@ H5HF_delete(H5F_t *f, haddr_t fh_addr) HDassert(H5F_addr_defined(fh_addr)); /* Lock the heap header into memory */ - if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* Check for files using shared heap header */ - if(hdr->file_rc) + if (hdr->file_rc) hdr->pending_delete = TRUE; else { /* Delete heap now, starting with header (unprotects header) */ - if(H5HF__hdr_delete(hdr) < 0) + if (H5HF__hdr_delete(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") hdr = NULL; } /* end if */ done: /* Unprotect the header, if an error occurred */ - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_delete() */ - diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index 479c2bd..68c97be 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -26,109 +26,97 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* v2 B-tree client callback context */ typedef struct H5HF_huge_bt2_ctx_t { - uint8_t sizeof_size; /* Size of file sizes */ - uint8_t sizeof_addr; /* Size of file addresses */ + uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_addr; /* Size of file addresses */ } H5HF_huge_bt2_ctx_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /* v2 B-tree driver callbacks */ /* Common callbacks */ -static void *H5HF__huge_bt2_crt_context(void *udata); +static void * H5HF__huge_bt2_crt_context(void *udata); static herr_t H5HF__huge_bt2_dst_context(void *ctx); /* Callbacks for indirect objects */ static herr_t H5HF__huge_bt2_indir_store(void *native, const void *udata); static herr_t H5HF__huge_bt2_indir_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Callbacks for filtered indirect objects */ static herr_t H5HF__huge_bt2_filt_indir_store(void *native, const void *udata); static herr_t H5HF__huge_bt2_filt_indir_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Callbacks for direct objects */ static herr_t H5HF__huge_bt2_dir_store(void *native, const void *udata); static herr_t H5HF__huge_bt2_dir_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Callbacks for filtered direct objects */ static herr_t H5HF__huge_bt2_filt_dir_store(void *native, const void *udata); static herr_t H5HF__huge_bt2_filt_dir_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /*********************/ /* Package Variables */ /*********************/ /* v2 B-tree class for indirectly accessed 'huge' objects */ -const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ - H5HF__huge_bt2_crt_context, /* Create client callback context */ - H5HF__huge_bt2_dst_context, /* Destroy client callback context */ - H5HF__huge_bt2_indir_store, /* Record storage callback */ - H5HF__huge_bt2_indir_compare, /* Record comparison callback */ - H5HF__huge_bt2_indir_encode, /* Record encoding callback */ - H5HF__huge_bt2_indir_decode, /* Record decoding callback */ - H5HF__huge_bt2_indir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_INDIR[1] = {{ + /* B-tree class information */ + H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ + H5HF__huge_bt2_crt_context, /* Create client callback context */ + H5HF__huge_bt2_dst_context, /* Destroy client callback context */ + H5HF__huge_bt2_indir_store, /* Record storage callback */ + H5HF__huge_bt2_indir_compare, /* Record comparison callback */ + H5HF__huge_bt2_indir_encode, /* Record encoding callback */ + H5HF__huge_bt2_indir_decode, /* Record decoding callback */ + H5HF__huge_bt2_indir_debug /* Record debugging callback */ }}; /* v2 B-tree class for indirectly accessed, filtered 'huge' objects */ -const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ +const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1] = {{ + /* B-tree class information */ H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* Type of B-tree */ "H5B2_FHEAP_HUGE_FILT_INDIR_ID", /* Name of B-tree class */ sizeof(H5HF_huge_bt2_filt_indir_rec_t), /* Size of native record */ @@ -142,38 +130,39 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ }}; /* v2 B-tree class for directly accessed 'huge' objects */ -const H5B2_class_t H5HF_HUGE_BT2_DIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ - H5HF__huge_bt2_crt_context, /* Create client callback context */ - H5HF__huge_bt2_dst_context, /* Destroy client callback context */ - H5HF__huge_bt2_dir_store, /* Record storage callback */ - H5HF__huge_bt2_dir_compare, /* Record comparison callback */ - H5HF__huge_bt2_dir_encode, /* Record encoding callback */ - H5HF__huge_bt2_dir_decode, /* Record decoding callback */ - H5HF__huge_bt2_dir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_DIR[1] = {{ + /* B-tree class information */ + H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ + H5HF__huge_bt2_crt_context, /* Create client callback context */ + H5HF__huge_bt2_dst_context, /* Destroy client callback context */ + H5HF__huge_bt2_dir_store, /* Record storage callback */ + H5HF__huge_bt2_dir_compare, /* Record comparison callback */ + H5HF__huge_bt2_dir_encode, /* Record encoding callback */ + H5HF__huge_bt2_dir_decode, /* Record decoding callback */ + H5HF__huge_bt2_dir_debug /* Record debugging callback */ }}; /* v2 B-tree class for directly accessed, filtered 'huge' objects */ -const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_filt_dir_rec_t), /* Size of native record */ - H5HF__huge_bt2_crt_context, /* Create client callback context */ - H5HF__huge_bt2_dst_context, /* Destroy client callback context */ - H5HF__huge_bt2_filt_dir_store, /* Record storage callback */ - H5HF__huge_bt2_filt_dir_compare, /* Record comparison callback */ - H5HF__huge_bt2_filt_dir_encode, /* Record encoding callback */ - H5HF__huge_bt2_filt_dir_decode, /* Record decoding callback */ - H5HF__huge_bt2_filt_dir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1] = {{ + /* B-tree class information */ + H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_filt_dir_rec_t), /* Size of native record */ + H5HF__huge_bt2_crt_context, /* Create client callback context */ + H5HF__huge_bt2_dst_context, /* Destroy client callback context */ + H5HF__huge_bt2_filt_dir_store, /* Record storage callback */ + H5HF__huge_bt2_filt_dir_compare, /* Record comparison callback */ + H5HF__huge_bt2_filt_dir_encode, /* Record encoding callback */ + H5HF__huge_bt2_filt_dir_decode, /* Record decoding callback */ + H5HF__huge_bt2_filt_dir_debug /* Record debugging callback */ }}; /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -181,8 +170,6 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ /* Declare a free list to manage the H5HF_huge_bt2_ctx_t struct */ H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t); - - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_crt_context * @@ -201,9 +188,9 @@ H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t); static void * H5HF__huge_bt2_crt_context(void *_f) { - H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ - H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ + H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ + H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -211,7 +198,7 @@ H5HF__huge_bt2_crt_context(void *_f) HDassert(f); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of addresses & lengths in the file */ @@ -225,7 +212,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dst_context * @@ -244,7 +230,7 @@ done: static herr_t H5HF__huge_bt2_dst_context(void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -257,7 +243,6 @@ H5HF__huge_bt2_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_found * @@ -282,7 +267,6 @@ H5HF__huge_bt2_indir_found(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_found() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_remove * @@ -300,13 +284,14 @@ H5HF__huge_bt2_indir_found(const void *nrecord, void *op_data) herr_t H5HF__huge_bt2_indir_remove(const void *nrecord, void *_udata) { - H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Free the space in the file for the object being removed */ - if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0) + if (H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, + ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free space for huge object on disk") /* Set the length of the object removed */ @@ -316,7 +301,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_indir_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_store * @@ -340,7 +324,6 @@ H5HF__huge_bt2_indir_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_store() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_compare * @@ -366,7 +349,6 @@ H5HF__huge_bt2_indir_compare(const void *_rec1, const void *_rec2, int *result) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_compare() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_encode * @@ -383,7 +365,7 @@ H5HF__huge_bt2_indir_compare(const void *_rec1, const void *_rec2, int *result) static herr_t H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -399,7 +381,6 @@ H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_decode * @@ -416,7 +397,7 @@ H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) static herr_t H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_indir_rec_t *nrecord = (H5HF_huge_bt2_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -432,7 +413,6 @@ H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_debug * @@ -447,20 +427,19 @@ H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%a, %Hu, %Hu}\n", indent, "", fwidth, "Record:", - nrecord->addr, nrecord->len, nrecord->id); + HDfprintf(stream, "%*s%-*s {%a, %Hu, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len, + nrecord->id); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_found * @@ -485,7 +464,6 @@ H5HF__huge_bt2_filt_indir_found(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_found() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_remove * @@ -503,13 +481,15 @@ H5HF__huge_bt2_filt_indir_found(const void *nrecord, void *op_data) herr_t H5HF__huge_bt2_filt_indir_remove(const void *nrecord, void *_udata) { - H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Free the space in the file for the object being removed */ - if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->len) < 0) + if (H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, + ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->addr, + ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free space for huge object on disk") /* Set the length of the object removed */ @@ -519,7 +499,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_filt_indir_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_store * @@ -543,7 +522,6 @@ H5HF__huge_bt2_filt_indir_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_store() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_compare * @@ -569,7 +547,6 @@ H5HF__huge_bt2_filt_indir_compare(const void *_rec1, const void *_rec2, int *res FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_compare() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_encode * @@ -586,7 +563,7 @@ H5HF__huge_bt2_filt_indir_compare(const void *_rec1, const void *_rec2, int *res static herr_t H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -604,7 +581,6 @@ H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_decode * @@ -621,7 +597,7 @@ H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) static herr_t H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_filt_indir_rec_t *nrecord = (H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -639,7 +615,6 @@ H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_debug * @@ -654,20 +629,19 @@ H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu, %Hu}\n", indent, "", fwidth, "Record:", - nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size, nrecord->id); + HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, + nrecord->len, nrecord->filter_mask, nrecord->obj_size, nrecord->id); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_remove * @@ -685,13 +659,14 @@ H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, herr_t H5HF__huge_bt2_dir_remove(const void *nrecord, void *_udata) { - H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Free the space in the file for the object being removed */ - if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0) + if (H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, + ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free space for huge object on disk") /* Set the length of the object removed */ @@ -701,7 +676,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_dir_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_store * @@ -725,7 +699,6 @@ H5HF__huge_bt2_dir_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_store() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_compare * @@ -748,13 +721,13 @@ H5HF__huge_bt2_dir_compare(const void *_rec1, const void *_rec2, int *result) FUNC_ENTER_STATIC_NOERR - if(rec1->addr < rec2->addr) + if (rec1->addr < rec2->addr) *result = -1; - else if(rec1->addr > rec2->addr) + else if (rec1->addr > rec2->addr) *result = 1; - else if(rec1->len < rec2->len) + else if (rec1->len < rec2->len) *result = -1; - else if(rec1->len > rec2->len) + else if (rec1->len > rec2->len) *result = 1; else *result = 0; @@ -762,7 +735,6 @@ H5HF__huge_bt2_dir_compare(const void *_rec1, const void *_rec2, int *result) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_compare() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_encode * @@ -779,7 +751,7 @@ H5HF__huge_bt2_dir_compare(const void *_rec1, const void *_rec2, int *result) static herr_t H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -794,7 +766,6 @@ H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_decode * @@ -811,7 +782,7 @@ H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) static herr_t H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_dir_rec_t *nrecord = (H5HF_huge_bt2_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -826,7 +797,6 @@ H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_debug * @@ -841,20 +811,18 @@ H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%a, %Hu}\n", indent, "", fwidth, "Record:", - nrecord->addr, nrecord->len); + HDfprintf(stream, "%*s%-*s {%a, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_found * @@ -879,7 +847,6 @@ H5HF__huge_bt2_filt_dir_found(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_found() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_remove * @@ -897,13 +864,15 @@ H5HF__huge_bt2_filt_dir_found(const void *nrecord, void *op_data) herr_t H5HF__huge_bt2_filt_dir_remove(const void *nrecord, void *_udata) { - H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Free the space in the file for the object being removed */ - if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->len) < 0) + if (H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, + ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->addr, + ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free space for huge object on disk") /* Set the length of the object removed */ @@ -913,7 +882,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_filt_dir_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_store * @@ -937,7 +905,6 @@ H5HF__huge_bt2_filt_dir_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_store() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_compare * @@ -960,13 +927,13 @@ H5HF__huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2, int *resul FUNC_ENTER_STATIC_NOERR - if(rec1->addr < rec2->addr) + if (rec1->addr < rec2->addr) *result = -1; - else if(rec1->addr > rec2->addr) + else if (rec1->addr > rec2->addr) *result = 1; - else if(rec1->len < rec2->len) + else if (rec1->len < rec2->len) *result = -1; - else if(rec1->len > rec2->len) + else if (rec1->len > rec2->len) *result = 1; else *result = 0; @@ -974,7 +941,6 @@ H5HF__huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2, int *resul FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_compare() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_encode * @@ -991,7 +957,7 @@ H5HF__huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2, int *resul static herr_t H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -1008,7 +974,6 @@ H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_decode * @@ -1025,7 +990,7 @@ H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) static herr_t H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_filt_dir_rec_t *nrecord = (H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -1042,7 +1007,6 @@ H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_debug * @@ -1057,16 +1021,15 @@ H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu}\n", indent, "", fwidth, "Record:", - nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size); + HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, + nrecord->len, nrecord->filter_mask, nrecord->obj_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_debug() */ - diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 22a2623..40728a5 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -26,42 +26,37 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* Fractal heap format version #'s */ -#define H5HF_HDR_VERSION 0 /* Header */ -#define H5HF_DBLOCK_VERSION 0 /* Direct block */ -#define H5HF_IBLOCK_VERSION 0 /* Indirect block */ - +#define H5HF_HDR_VERSION 0 /* Header */ +#define H5HF_DBLOCK_VERSION 0 /* Direct block */ +#define H5HF_IBLOCK_VERSION 0 /* Indirect block */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -73,126 +68,117 @@ static herr_t H5HF__dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *d /* Metadata cache (H5AC) callbacks */ static herr_t H5HF__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); -static herr_t H5HF__cache_hdr_get_final_load_size(const void *image_ptr, - size_t image_len, void *udata, size_t *actual_len); +static herr_t H5HF__cache_hdr_get_final_load_size(const void *image_ptr, size_t image_len, void *udata, + size_t *actual_len); static htri_t H5HF__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5HF__cache_hdr_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5HF__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HF__cache_hdr_image_len(const void *thing, size_t *image_len); -static herr_t H5HF__cache_hdr_pre_serialize(H5F_t *f, void *thing, haddr_t addr, - size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); -static herr_t H5HF__cache_hdr_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5HF__cache_hdr_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr, size_t *new_len, unsigned *flags); +static herr_t H5HF__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HF__cache_hdr_free_icr(void *thing); static herr_t H5HF__cache_iblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5HF__cache_iblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5HF__cache_iblock_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5HF__cache_iblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HF__cache_iblock_image_len(const void *thing, size_t *image_len); -static herr_t H5HF__cache_iblock_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); -static herr_t H5HF__cache_iblock_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5HF__cache_iblock_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr, size_t *new_len, unsigned *flags); +static herr_t H5HF__cache_iblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *thing); static herr_t H5HF__cache_iblock_free_icr(void *thing); static herr_t H5HF__cache_dblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5HF__cache_dblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5HF__cache_dblock_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5HF__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HF__cache_dblock_image_len(const void *thing, size_t *image_len); -static herr_t H5HF__cache_dblock_pre_serialize(H5F_t *f, void *thing, haddr_t addr, - size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); -static herr_t H5HF__cache_dblock_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5HF__cache_dblock_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr, size_t *new_len, unsigned *flags); +static herr_t H5HF__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *thing); static herr_t H5HF__cache_dblock_free_icr(void *thing); static herr_t H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size); /* Debugging Function Prototypes */ #ifndef NDEBUG -static herr_t H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, - hbool_t *fd_clean, hbool_t *clean); -static herr_t H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, - haddr_t fd_parent_addr, H5HF_indirect_t *iblock, unsigned *iblock_status, - hbool_t *fd_clean, hbool_t *clean); -static herr_t H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, - haddr_t fd_parent_addr, H5HF_indirect_t *iblock, hbool_t *fd_clean, - hbool_t *clean, hbool_t *has_dblocks); -static herr_t H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, - haddr_t fd_parent_addr, H5HF_indirect_t *iblock, - hbool_t *fd_clean, hbool_t *clean, hbool_t *has_iblocks); +static herr_t H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_clean, + hbool_t *clean); +static herr_t H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, + H5HF_indirect_t *iblock, unsigned *iblock_status, + hbool_t *fd_clean, hbool_t *clean); +static herr_t H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, + H5HF_indirect_t *iblock, hbool_t *fd_clean, + hbool_t *clean, hbool_t *has_dblocks); +static herr_t H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, + H5HF_indirect_t *iblock, hbool_t *fd_clean, + hbool_t *clean, hbool_t *has_iblocks); #endif /* NDEBUG */ - /*********************/ /* Package Variables */ /*********************/ /* H5HF header inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FHEAP_HDR[1] = {{ - H5AC_FHEAP_HDR_ID, /* Metadata client ID */ - "fractal heap header", /* Metadata client name (for debugging) */ - H5FD_MEM_FHEAP_HDR, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5AC_FHEAP_HDR_ID, /* Metadata client ID */ + "fractal heap header", /* Metadata client name (for debugging) */ + H5FD_MEM_FHEAP_HDR, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ H5HF__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5HF__cache_hdr_get_final_load_size, /* 'get_final_load_size' callback */ - H5HF__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5HF__cache_hdr_deserialize, /* 'deserialize' callback */ - H5HF__cache_hdr_image_len, /* 'image_len' callback */ - H5HF__cache_hdr_pre_serialize, /* 'pre_serialize' callback */ - H5HF__cache_hdr_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5HF__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5HF__cache_hdr_get_final_load_size, /* 'get_final_load_size' callback */ + H5HF__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5HF__cache_hdr_deserialize, /* 'deserialize' callback */ + H5HF__cache_hdr_image_len, /* 'image_len' callback */ + H5HF__cache_hdr_pre_serialize, /* 'pre_serialize' callback */ + H5HF__cache_hdr_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5HF__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5HF indirect block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FHEAP_IBLOCK[1] = {{ - H5AC_FHEAP_IBLOCK_ID, /* Metadata client ID */ - "fractal heap indirect block", /* Metadata client name (for debugging) */ - H5FD_MEM_FHEAP_IBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5HF__cache_iblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5HF__cache_iblock_verify_chksum, /* 'verify_chksum' callback */ - H5HF__cache_iblock_deserialize, /* 'deserialize' callback */ - H5HF__cache_iblock_image_len, /* 'image_len' callback */ - H5HF__cache_iblock_pre_serialize, /* 'pre_serialize' callback */ - H5HF__cache_iblock_serialize, /* 'serialize' callback */ - H5HF__cache_iblock_notify, /* 'notify' callback */ - H5HF__cache_iblock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_FHEAP_IBLOCK_ID, /* Metadata client ID */ + "fractal heap indirect block", /* Metadata client name (for debugging) */ + H5FD_MEM_FHEAP_IBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5HF__cache_iblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5HF__cache_iblock_verify_chksum, /* 'verify_chksum' callback */ + H5HF__cache_iblock_deserialize, /* 'deserialize' callback */ + H5HF__cache_iblock_image_len, /* 'image_len' callback */ + H5HF__cache_iblock_pre_serialize, /* 'pre_serialize' callback */ + H5HF__cache_iblock_serialize, /* 'serialize' callback */ + H5HF__cache_iblock_notify, /* 'notify' callback */ + H5HF__cache_iblock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5HF direct block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FHEAP_DBLOCK[1] = {{ - H5AC_FHEAP_DBLOCK_ID, /* Metadata client ID */ - "fractal heap direct block", /* Metadata client name (for debugging) */ - H5FD_MEM_FHEAP_DBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5HF__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5HF__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ - H5HF__cache_dblock_deserialize, /* 'deserialize' callback */ - H5HF__cache_dblock_image_len, /* 'image_len' callback */ - H5HF__cache_dblock_pre_serialize, /* 'pre_serialize' callback */ - H5HF__cache_dblock_serialize, /* 'serialize' callback */ - H5HF__cache_dblock_notify, /* 'notify' callback */ - H5HF__cache_dblock_free_icr, /* 'free_icr' callback */ - H5HF__cache_dblock_fsf_size, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_FHEAP_DBLOCK_ID, /* Metadata client ID */ + "fractal heap direct block", /* Metadata client name (for debugging) */ + H5FD_MEM_FHEAP_DBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5HF__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5HF__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ + H5HF__cache_dblock_deserialize, /* 'deserialize' callback */ + H5HF__cache_dblock_image_len, /* 'image_len' callback */ + H5HF__cache_dblock_pre_serialize, /* 'pre_serialize' callback */ + H5HF__cache_dblock_serialize, /* 'serialize' callback */ + H5HF__cache_dblock_notify, /* 'notify' callback */ + H5HF__cache_dblock_free_icr, /* 'free_icr' callback */ + H5HF__cache_dblock_fsf_size, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -200,8 +186,6 @@ const H5AC_class_t H5AC_FHEAP_DBLOCK[1] = {{ /* Declare a free list to manage heap direct block data to/from disk */ H5FL_BLK_DEFINE(direct_block); - - /*------------------------------------------------------------------------- * Function: H5HF__hdr_prefix_decode() * @@ -218,8 +202,8 @@ H5FL_BLK_DEFINE(direct_block); static herr_t H5HF__hdr_prefix_decode(H5HF_hdr_t *hdr, const uint8_t **image_ref) { - const uint8_t *image = *image_ref; /* Pointer into into supplied image */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *image = *image_ref; /* Pointer into into supplied image */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -228,17 +212,17 @@ H5HF__hdr_prefix_decode(H5HF_hdr_t *hdr, const uint8_t **image_ref) HDassert(image); /* Magic number */ - if(HDmemcmp(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "wrong fractal heap header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5HF_HDR_VERSION) + if (*image++ != H5HF_HDR_VERSION) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong fractal heap header version") /* General heap information */ - UINT16DECODE(image, hdr->id_len); /* Heap ID length */ - UINT16DECODE(image, hdr->filter_len); /* I/O filters' encoded length */ + UINT16DECODE(image, hdr->id_len); /* Heap ID length */ + UINT16DECODE(image, hdr->filter_len); /* I/O filters' encoded length */ /* Update the image buffer pointer */ *image_ref = image; @@ -247,7 +231,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_prefix_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__dtable_decode * @@ -297,7 +280,6 @@ H5HF__dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *dtable) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__dtable_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__dtable_encode * @@ -347,7 +329,6 @@ H5HF__dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__dtable_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_get_initial_load_size() * @@ -371,7 +352,7 @@ static herr_t H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) { H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* Pointer to user data */ - H5HF_hdr_t dummy_hdr; /* Dummy header -- to compute size */ + H5HF_hdr_t dummy_hdr; /* Dummy header -- to compute size */ FUNC_ENTER_STATIC_NOERR @@ -380,7 +361,7 @@ H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) HDassert(image_len); /* Set the internal parameters for the heap */ - dummy_hdr.f = udata->f; + dummy_hdr.f = udata->f; dummy_hdr.sizeof_size = H5F_SIZEOF_SIZE(udata->f); dummy_hdr.sizeof_addr = H5F_SIZEOF_ADDR(udata->f); @@ -390,7 +371,6 @@ H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_get_final_load_size() * @@ -406,13 +386,13 @@ H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *_udata, size_t *actual_len) +H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, + size_t *actual_len) { - H5HF_hdr_t hdr; /* Temporary fractal heap header */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into into supplied image */ - H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t hdr; /* Temporary fractal heap header */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into into supplied image */ + H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -423,21 +403,20 @@ H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UN HDassert(*actual_len == image_len); /* Deserialize the fractal heap header's prefix */ - if(H5HF__hdr_prefix_decode(&hdr, &image) < 0) + if (H5HF__hdr_prefix_decode(&hdr, &image) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode fractal heap header prefix") /* Check for I/O filter info on this heap */ - if(hdr.filter_len > 0) + if (hdr.filter_len > 0) /* Compute the extra heap header size */ - *actual_len += (size_t)(H5F_SIZEOF_SIZE(udata->f) /* Size of size for filtered root direct block */ - + (unsigned)4 /* Size of filter mask for filtered root direct block */ - + hdr.filter_len); /* Size of encoded I/O filter info */ + *actual_len += (size_t)(H5F_SIZEOF_SIZE(udata->f) /* Size of size for filtered root direct block */ + + (unsigned)4 /* Size of filter mask for filtered root direct block */ + + hdr.filter_len); /* Size of encoded I/O filter info */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_verify_chksum * @@ -454,10 +433,10 @@ done: static htri_t H5HF__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -467,13 +446,12 @@ H5HF__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_deserialize * @@ -491,15 +469,14 @@ H5HF__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static void * -H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5HF_hdr_t *hdr = NULL; /* Fractal heap info */ + H5HF_hdr_t * hdr = NULL; /* Fractal heap info */ H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into into supplied image */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint8_t heap_flags; /* Status flags for heap */ - void * ret_value = NULL; /* Return value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into into supplied image */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint8_t heap_flags; /* Status flags for heap */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -510,28 +487,29 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert(dirty); /* Allocate space for the fractal heap data structure */ - if(NULL == (hdr = H5HF_hdr_alloc(udata->f))) + if (NULL == (hdr = H5HF_hdr_alloc(udata->f))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Deserialize the fractal heap header's prefix */ - if(H5HF__hdr_prefix_decode(hdr, &image) < 0) + if (H5HF__hdr_prefix_decode(hdr, &image) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode fractal heap header prefix") /* Heap status flags */ /* (bit 0: "huge" object IDs have wrapped) */ /* (bit 1: checksum direct blocks) */ - heap_flags = *image++; + heap_flags = *image++; hdr->huge_ids_wrapped = heap_flags & H5HF_HDR_FLAGS_HUGE_ID_WRAPPED; hdr->checksum_dblocks = heap_flags & H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS; /* "Huge" object information */ - UINT32DECODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ - H5F_DECODE_LENGTH(udata->f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ + UINT32DECODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ + H5F_DECODE_LENGTH(udata->f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ H5F_addr_decode(udata->f, &image, &hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */ /* "Managed" object free space information */ - H5F_DECODE_LENGTH(udata->f, image, hdr->total_man_free); /* Internal free space in managed direct blocks */ - H5F_addr_decode(udata->f, &image, &hdr->fs_addr); /* Address of free section header */ + H5F_DECODE_LENGTH(udata->f, image, + hdr->total_man_free); /* Internal free space in managed direct blocks */ + H5F_addr_decode(udata->f, &image, &hdr->fs_addr); /* Address of free section header */ /* Heap statistics */ H5F_DECODE_LENGTH(udata->f, image, hdr->man_size); @@ -544,7 +522,7 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, H5F_DECODE_LENGTH(udata->f, image, hdr->tiny_nobjs); /* Managed objects' doubling-table info */ - if(H5HF__dtable_decode(hdr->f, &image, &(hdr->man_dtable)) < 0) + if (H5HF__dtable_decode(hdr->f, &image, &(hdr->man_dtable)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, NULL, "unable to encode managed obj. doubling table info") /* Set the fractal heap header's 'base' size */ @@ -555,16 +533,16 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert((size_t)(image - (const uint8_t *)_image) == (hdr->heap_size - H5HF_SIZEOF_CHKSUM)); /* Check for I/O filter information to decode */ - if(hdr->filter_len > 0) { - H5O_pline_t *pline; /* Pipeline information from the header on disk */ + if (hdr->filter_len > 0) { + H5O_pline_t *pline; /* Pipeline information from the header on disk */ /* Sanity check */ - HDassert(len > hdr->heap_size); /* A header with filter info is > than a standard header */ + HDassert(len > hdr->heap_size); /* A header with filter info is > than a standard header */ /* Compute the heap header's size */ - hdr->heap_size += (size_t)(hdr->sizeof_size /* Size of size for filtered root direct block */ - + (unsigned)4 /* Size of filter mask for filtered root direct block */ - + hdr->filter_len); /* Size of encoded I/O filter info */ + hdr->heap_size += (size_t)(hdr->sizeof_size /* Size of size for filtered root direct block */ + + (unsigned)4 /* Size of filter mask for filtered root direct block */ + + hdr->filter_len); /* Size of encoded I/O filter info */ /* Decode the size of a filtered root direct block */ H5F_DECODE_LENGTH(udata->f, image, hdr->pline_root_direct_size); @@ -573,14 +551,14 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, UINT32DECODE(image, hdr->pline_root_direct_filter_mask); /* Decode I/O filter information */ - if(NULL == (pline = (H5O_pline_t *)H5O_msg_decode(hdr->f, NULL, H5O_PLINE_ID, len, image))) + if (NULL == (pline = (H5O_pline_t *)H5O_msg_decode(hdr->f, NULL, H5O_PLINE_ID, len, image))) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode I/O pipeline filters") /* Advance past filter info to checksum */ image += hdr->filter_len; /* Copy the information into the header's I/O pipeline structure */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &(hdr->pline))) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &(hdr->pline))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOPY, NULL, "can't copy I/O filter pipeline") /* Release the space allocated for the I/O pipeline filters */ @@ -594,21 +572,20 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert((size_t)(image - (const uint8_t *)_image) == hdr->heap_size); /* Finish initialization of heap header */ - if(H5HF_hdr_finish_init(hdr) < 0) + if (H5HF_hdr_finish_init(hdr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't finish initializing shared fractal heap header") /* Set return value */ ret_value = (void *)hdr; done: - if(!ret_value && hdr) - if(H5HF_hdr_free(hdr) < 0) + if (!ret_value && hdr) + if (H5HF_hdr_free(hdr) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_image_len * @@ -629,7 +606,7 @@ done: static herr_t H5HF__cache_hdr_image_len(const void *_thing, size_t *image_len) { - const H5HF_hdr_t *hdr = (const H5HF_hdr_t *)_thing; /* Fractal heap info */ + const H5HF_hdr_t *hdr = (const H5HF_hdr_t *)_thing; /* Fractal heap info */ FUNC_ENTER_STATIC_NOERR @@ -644,7 +621,6 @@ H5HF__cache_hdr_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_pre_serialize * @@ -667,11 +643,11 @@ H5HF__cache_hdr_image_len(const void *_thing, size_t *image_len) */ static herr_t H5HF__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t len, - haddr_t H5_ATTR_UNUSED *new_addr, size_t H5_ATTR_UNUSED *new_len, - unsigned *flags) + haddr_t H5_ATTR_UNUSED *new_addr, size_t H5_ATTR_UNUSED *new_len, + unsigned *flags) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -687,46 +663,47 @@ H5HF__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t len, HDassert(flags); #ifndef NDEBUG -{ - hbool_t descendants_clean = TRUE; - hbool_t fd_children_clean = TRUE; + { + hbool_t descendants_clean = TRUE; + hbool_t fd_children_clean = TRUE; - /* Verify that flush dependencies are working correctly. Do this - * by verifying that either: - * - * 1) the header has a root iblock, and that the root iblock and all - * of its children are clean, or - * - * 2) The header has a root dblock, which is clean, or - * - * 3) The heap is empty, and thus the header has neither a root - * iblock no a root dblock. In this case, the flush ordering - * constraint is met by default. - * - * Do this with a call to H5HF__cache_verify_hdr_descendants_clean(). - * - * Note that descendants need not be clean if the pre_serialize call - * is made during a cache serialization instead of an entry or cache - * flush. - * - * Note also that with the recent change in the definition of flush - * dependency, not all descendants need be clean -- only direct flush - * dependency children. - * - * Finally, observe that the H5HF__cache_verify_hdr_descendants_clean() - * call still looks for dirty descendants. At present we do not check - * this value. - */ - if(H5HF__cache_verify_hdr_descendants_clean((H5F_t *)f, hdr, &fd_children_clean, &descendants_clean) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify hdr descendants clean.") - HDassert(fd_children_clean); -} + /* Verify that flush dependencies are working correctly. Do this + * by verifying that either: + * + * 1) the header has a root iblock, and that the root iblock and all + * of its children are clean, or + * + * 2) The header has a root dblock, which is clean, or + * + * 3) The heap is empty, and thus the header has neither a root + * iblock no a root dblock. In this case, the flush ordering + * constraint is met by default. + * + * Do this with a call to H5HF__cache_verify_hdr_descendants_clean(). + * + * Note that descendants need not be clean if the pre_serialize call + * is made during a cache serialization instead of an entry or cache + * flush. + * + * Note also that with the recent change in the definition of flush + * dependency, not all descendants need be clean -- only direct flush + * dependency children. + * + * Finally, observe that the H5HF__cache_verify_hdr_descendants_clean() + * call still looks for dirty descendants. At present we do not check + * this value. + */ + if (H5HF__cache_verify_hdr_descendants_clean((H5F_t *)f, hdr, &fd_children_clean, + &descendants_clean) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify hdr descendants clean.") + HDassert(fd_children_clean); + } #endif /* NDEBUG */ - if(H5F_IS_TMP_ADDR(f, addr)) + if (H5F_IS_TMP_ADDR(f, addr)) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "addr in temporary space?!?."); - if(len != hdr->heap_size) + if (len != hdr->heap_size) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "unexpected image len."); *flags = 0; @@ -735,7 +712,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_serialize * @@ -752,14 +728,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t heap_flags; /* Status flags for heap */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t heap_flags; /* Status flags for heap */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -782,8 +757,8 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN *image++ = H5HF_HDR_VERSION; /* General heap information */ - UINT16ENCODE(image, hdr->id_len); /* Heap ID length */ - UINT16ENCODE(image, hdr->filter_len); /* I/O filters' encoded length */ + UINT16ENCODE(image, hdr->id_len); /* Heap ID length */ + UINT16ENCODE(image, hdr->filter_len); /* I/O filters' encoded length */ /* Heap status flags */ /* (bit 0: "huge" object IDs have wrapped) */ @@ -791,16 +766,16 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN heap_flags = 0; heap_flags = (uint8_t)(heap_flags | (hdr->huge_ids_wrapped ? H5HF_HDR_FLAGS_HUGE_ID_WRAPPED : 0)); heap_flags = (uint8_t)(heap_flags | (hdr->checksum_dblocks ? H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS : 0)); - *image++ = heap_flags; + *image++ = heap_flags; /* "Huge" object information */ - UINT32ENCODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ + UINT32ENCODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ H5F_ENCODE_LENGTH(f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ H5F_addr_encode(f, &image, hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */ /* "Managed" object free space information */ H5F_ENCODE_LENGTH(f, image, hdr->total_man_free); /* Internal free space in managed direct blocks */ - H5F_addr_encode(f, &image, hdr->fs_addr); /* Address of free section header */ + H5F_addr_encode(f, &image, hdr->fs_addr); /* Address of free section header */ /* Heap statistics */ H5F_ENCODE_LENGTH(f, image, hdr->man_size); @@ -813,11 +788,11 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN H5F_ENCODE_LENGTH(f, image, hdr->tiny_nobjs); /* Managed objects' doubling-table info */ - if(H5HF__dtable_encode(hdr->f, &image, &(hdr->man_dtable)) < 0) + if (H5HF__dtable_encode(hdr->f, &image, &(hdr->man_dtable)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, FAIL, "unable to encode managed obj. doubling table info") /* Check for I/O filter information to encode */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Encode the size of a filtered root direct block */ H5F_ENCODE_LENGTH(f, image, hdr->pline_root_direct_size); @@ -825,7 +800,7 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN UINT32ENCODE(image, hdr->pline_root_direct_filter_mask); /* Encode I/O filter information */ - if(H5O_msg_encode(hdr->f, H5O_PLINE_ID, FALSE, image, &(hdr->pline)) < 0) + if (H5O_msg_encode(hdr->f, H5O_PLINE_ID, FALSE, image, &(hdr->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, FAIL, "can't encode I/O pipeline fiters") image += hdr->filter_len; } /* end if */ @@ -843,7 +818,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_free_icr * @@ -871,8 +845,8 @@ done: static herr_t H5HF__cache_hdr_free_icr(void *_thing) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -882,14 +856,13 @@ H5HF__cache_hdr_free_icr(void *_thing) HDassert(hdr->cache_info.type == H5AC_FHEAP_HDR); HDassert(hdr->rc == 0); - if(H5HF_hdr_free(hdr) < 0) + if (H5HF_hdr_free(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "unable to release fractal heap header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_get_initial_load_size() * @@ -907,7 +880,7 @@ done: static herr_t H5HF__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) { - H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* User data for callback */ + H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -923,7 +896,6 @@ H5HF__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_iblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_verify_chksum * @@ -940,10 +912,10 @@ H5HF__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5HF__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -953,14 +925,12 @@ H5HF__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_verify_chksum() */ - - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_deserialize * @@ -982,17 +952,17 @@ H5HF__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN *------------------------------------------------------------------------- */ static void * -H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { - H5HF_hdr_t *hdr; /* Shared fractal heap information */ - H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* User data for callback */ - H5HF_indirect_t *iblock = NULL; /* Indirect block info */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - haddr_t heap_addr; /* Address of heap header in the file */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned u; /* Local index variable */ - void * ret_value = NULL; /* Return value */ + H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* User data for callback */ + H5HF_indirect_t * iblock = NULL; /* Indirect block info */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + haddr_t heap_addr; /* Address of heap header in the file */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + unsigned u; /* Local index variable */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1007,17 +977,17 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED hdr->f = udata->f; /* Allocate space for the fractal heap indirect block */ - if(NULL == (iblock = H5FL_CALLOC(H5HF_indirect_t))) + if (NULL == (iblock = H5FL_CALLOC(H5HF_indirect_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Share common heap information */ iblock->hdr = hdr; - if(H5HF_hdr_incr(hdr) < 0) + if (H5HF_hdr_incr(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") /* Set block's internal information */ - iblock->rc = 0; - iblock->nrows = *udata->nrows; + iblock->rc = 0; + iblock->nrows = *udata->nrows; iblock->nchildren = 0; /* Compute size of indirect block */ @@ -1027,17 +997,17 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert(iblock->size == len); /* Magic number */ - if(HDmemcmp(image, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "wrong fractal heap indirect block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5HF_IBLOCK_VERSION) + if (*image++ != H5HF_IBLOCK_VERSION) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap direct block version") /* Address of heap that owns this block */ H5F_addr_decode(udata->f, &image, &heap_addr); - if(H5F_addr_ne(heap_addr, hdr->heap_addr)) + if (H5F_addr_ne(heap_addr, hdr->heap_addr)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block") /* Address of parent block */ @@ -1045,15 +1015,16 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* this copy of the parent pointer is needed by the notify callback so */ /* that it can take down flush dependencies on eviction even if */ /* the parent pointer has been nulled out. JRM -- 5/18/14 */ - if(udata->par_info->iblock) + if (udata->par_info->iblock) iblock->fd_parent = udata->par_info->iblock; else iblock->fd_parent = udata->par_info->hdr; iblock->par_entry = udata->par_info->entry; - if(iblock->parent) { + if (iblock->parent) { /* Share parent block */ - if(H5HF_iblock_incr(iblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") + if (H5HF_iblock_incr(iblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, + "can't increment reference count on shared indirect block") /* Set max. # of rows in this block */ iblock->max_rows = iblock->nrows; @@ -1068,33 +1039,35 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Allocate & decode child block entry tables */ HDassert(iblock->nrows > 0); - if(NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for direct entries") - if(hdr->filter_len > 0) { - unsigned dir_rows; /* Number of direct rows in this indirect block */ + if (hdr->filter_len > 0) { + unsigned dir_rows; /* Number of direct rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ dir_rows = MIN(iblock->nrows, hdr->man_dtable.max_direct_rows); /* Allocate indirect block filtered entry array */ - if(NULL == (iblock->filt_ents = H5FL_SEQ_MALLOC(H5HF_indirect_filt_ent_t, (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->filt_ents = H5FL_SEQ_MALLOC(H5HF_indirect_filt_ent_t, + (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block entries") } /* end if */ else iblock->filt_ents = NULL; - for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { + for (u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { /* Decode child block address */ H5F_addr_decode(udata->f, &image, &(iblock->ents[u].addr)); /* Check for heap with I/O filters */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Sanity check */ HDassert(iblock->filt_ents); /* Decode extra information for direct blocks */ - if(u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) { + if (u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) { /* Size of filtered direct block */ H5F_DECODE_LENGTH(udata->f, image, iblock->filt_ents[u].size); @@ -1102,23 +1075,23 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* (either both the address & size are defined or both are * not defined) */ - HDassert((H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size) - || (!H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size == 0)); + HDassert((H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size) || + (!H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size == 0)); /* I/O filter mask for filtered direct block */ UINT32DECODE(image, iblock->filt_ents[u].filter_mask); } /* end if */ - } /* end if */ + } /* end if */ /* Count child blocks */ - if(H5F_addr_defined(iblock->ents[u].addr)) { + if (H5F_addr_defined(iblock->ents[u].addr)) { iblock->nchildren++; iblock->max_child = u; } /* end if */ - } /* end for */ + } /* end for */ /* Sanity check */ - HDassert(iblock->nchildren); /* indirect blocks w/no children should have been deleted */ + HDassert(iblock->nchildren); /* indirect blocks w/no children should have been deleted */ /* checksum verification already done by verify_chksum cb */ @@ -1129,14 +1102,15 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert((size_t)(image - (const uint8_t *)_image) == iblock->size); /* Check if we have any indirect block children */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned indir_rows;/* Number of indirect rows in this indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned indir_rows; /* Number of indirect rows in this indirect block */ /* Compute the number of indirect rows for this indirect block */ indir_rows = iblock->nrows - hdr->man_dtable.max_direct_rows; /* Allocate & initialize child indirect block pointer array */ - if(NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC(H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC( + H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for block entries") } /* end if */ else @@ -1146,14 +1120,13 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED ret_value = (void *)iblock; done: - if(!ret_value && iblock) - if(H5HF_man_iblock_dest(iblock) < 0) + if (!ret_value && iblock) + if (H5HF_man_iblock_dest(iblock) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_image_len * @@ -1170,7 +1143,7 @@ done: static herr_t H5HF__cache_iblock_image_len(const void *_thing, size_t *image_len) { - const H5HF_indirect_t *iblock = (const H5HF_indirect_t *)_thing; /* Indirect block info */ + const H5HF_indirect_t *iblock = (const H5HF_indirect_t *)_thing; /* Indirect block info */ FUNC_ENTER_STATIC_NOERR @@ -1185,7 +1158,6 @@ H5HF__cache_iblock_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_iblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_pre_serialize * @@ -1207,13 +1179,12 @@ H5HF__cache_iblock_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, - size_t H5_ATTR_UNUSED len, haddr_t *new_addr, size_t H5_ATTR_UNUSED *new_len, - unsigned *flags) +H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ATTR_UNUSED len, + haddr_t *new_addr, size_t H5_ATTR_UNUSED *new_len, unsigned *flags) { - H5HF_hdr_t *hdr; /* Shared fractal heap information */ - H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1234,85 +1205,86 @@ H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, HDassert(hdr->cache_info.type == H5AC_FHEAP_HDR); #ifndef NDEBUG -{ - hbool_t descendants_clean = TRUE; - hbool_t fd_children_clean = TRUE; - unsigned iblock_status = 0; - - /* verify that flush dependencies are working correctly. Do this - * by verifying that all immediate flush dependency children of this - * iblock are clean. - */ - if(H5AC_get_entry_status(f, iblock->addr, &iblock_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get iblock status") + { + hbool_t descendants_clean = TRUE; + hbool_t fd_children_clean = TRUE; + unsigned iblock_status = 0; + + /* verify that flush dependencies are working correctly. Do this + * by verifying that all immediate flush dependency children of this + * iblock are clean. + */ + if (H5AC_get_entry_status(f, iblock->addr, &iblock_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get iblock status") - /* since the current iblock is the guest of honor in a flush, we know - * that it is locked into the cache for the duration of the call. Hence - * there is no need to check to see if it is pinned or protected, or to - * protect it if it is not. - */ - if(H5HF__cache_verify_iblock_descendants_clean((H5F_t *)f, iblock->addr, iblock, &iblock_status, &fd_children_clean, &descendants_clean) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify descendants clean.") - HDassert(fd_children_clean); -} + /* since the current iblock is the guest of honor in a flush, we know + * that it is locked into the cache for the duration of the call. Hence + * there is no need to check to see if it is pinned or protected, or to + * protect it if it is not. + */ + if (H5HF__cache_verify_iblock_descendants_clean((H5F_t *)f, iblock->addr, iblock, &iblock_status, + &fd_children_clean, &descendants_clean) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify descendants clean.") + HDassert(fd_children_clean); + } #endif /* NDEBUG */ /* Check to see if we must re-allocate the iblock from temporary to * normal (AKA real) file space. */ - if(H5F_IS_TMP_ADDR(f, addr)) { + if (H5F_IS_TMP_ADDR(f, addr)) { haddr_t iblock_addr; /* Allocate 'normal' space for the new indirect block on disk */ - if(HADDR_UNDEF == (iblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) + if (HADDR_UNDEF == + (iblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") /* Sanity check */ HDassert(!H5F_addr_eq(iblock->addr, iblock_addr)); /* Let the metadata cache know the block moved */ - if(H5AC_move_entry((H5F_t *)f, H5AC_FHEAP_IBLOCK, iblock->addr, iblock_addr) < 0) + if (H5AC_move_entry((H5F_t *)f, H5AC_FHEAP_IBLOCK, iblock->addr, iblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move indirect block") /* Update the internal address for the block */ iblock->addr = iblock_addr; /* Check for root indirect block */ - if(NULL == iblock->parent) { + if (NULL == iblock->parent) { /* Update information about indirect block's location */ hdr->man_dtable.table_addr = iblock_addr; /* Mark that heap header was modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end if */ else { - H5HF_indirect_t *par_iblock; /* Parent indirect block */ - unsigned par_entry; /* Entry in parent indirect block */ + H5HF_indirect_t *par_iblock; /* Parent indirect block */ + unsigned par_entry; /* Entry in parent indirect block */ /* Get parent information */ par_iblock = iblock->parent; - par_entry = iblock->par_entry; + par_entry = iblock->par_entry; /* Update information about indirect block's location */ par_iblock->ents[par_entry].addr = iblock_addr; /* Mark that parent was modified */ - if(H5HF_iblock_dirty(par_iblock) < 0) + if (H5HF_iblock_dirty(par_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end if */ - *new_addr = iblock_addr; - *flags = H5AC__SERIALIZE_MOVED_FLAG; + *new_addr = iblock_addr; + *flags = H5AC__SERIALIZE_MOVED_FLAG; } /* end if */ else - *flags = 0; + *flags = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_serialize * @@ -1329,19 +1301,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HF_hdr_t *hdr; /* Shared fractal heap information */ - H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ + H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ #ifndef NDEBUG - unsigned nchildren = 0; /* Track # of children */ - size_t max_child = 0; /* Track max. child entry used */ -#endif /* NDEBUG */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nchildren = 0; /* Track # of children */ + size_t max_child = 0; /* Track max. child entry used */ +#endif /* NDEBUG */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1378,23 +1349,23 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG UINT64ENCODE_VAR(image, iblock->block_off, hdr->heap_off_size); /* Encode indirect block-specific fields */ - for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { + for (u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { /* Encode child block address */ H5F_addr_encode(f, &image, iblock->ents[u].addr); /* Check for heap with I/O filters */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Sanity check */ HDassert(iblock->filt_ents); /* Encode extra information for direct blocks */ - if(u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) { + if (u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) { /* Sanity check */ /* (either both the address & size are defined or both are * not defined) */ - HDassert((H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size) - || (!H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size == 0)); + HDassert((H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size) || + (!H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size == 0)); /* Size of filtered direct block */ H5F_ENCODE_LENGTH(f, image, iblock->filt_ents[u].size); @@ -1402,17 +1373,17 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG /* I/O filter mask for filtered direct block */ UINT32ENCODE(image, iblock->filt_ents[u].filter_mask); } /* end if */ - } /* end if */ + } /* end if */ #ifndef NDEBUG /* Count child blocks */ - if(H5F_addr_defined(iblock->ents[u].addr)) { + if (H5F_addr_defined(iblock->ents[u].addr)) { nchildren++; - if(u > max_child) + if (u > max_child) max_child = u; } /* end if */ -#endif /* NDEBUG */ - } /* end for */ +#endif /* NDEBUG */ + } /* end for */ /* Compute checksum */ metadata_chksum = H5_checksum_metadata((uint8_t *)_image, (size_t)(image - (uint8_t *)_image), 0); @@ -1430,7 +1401,6 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_notify * @@ -1452,8 +1422,8 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG static herr_t H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) { - H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1464,55 +1434,58 @@ H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) HDassert(iblock->hdr); /* further sanity checks */ - if(iblock->parent == NULL) { + if (iblock->parent == NULL) { /* pointer from hdr to root iblock will not be set up unless */ /* the fractal heap has already pinned the hdr. Do what */ /* sanity checking we can. */ - if((iblock->block_off == 0) && (iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED)) - HDassert(iblock->hdr->root_iblock == iblock); + if ((iblock->block_off == 0) && (iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED)) + HDassert(iblock->hdr->root_iblock == iblock); } /* end if */ else { /* if this is a child iblock, verify that the pointers are */ /* either uninitialized or set up correctly. */ H5HF_indirect_t H5_ATTR_NDEBUG_UNUSED *par_iblock = iblock->parent; - unsigned H5_ATTR_NDEBUG_UNUSED indir_idx; /* Index in parent's child iblock pointer array */ + unsigned H5_ATTR_NDEBUG_UNUSED indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); - HDassert(iblock->par_entry >= (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width)); + HDassert(iblock->par_entry >= + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width)); /* Compute index in parent's child iblock pointer array */ - indir_idx = iblock->par_entry - (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width); + indir_idx = iblock->par_entry - + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width); /* The pointer to iblock in the parent may not be set yet -- */ /* verify that it is either NULL, or that it has been set to */ /* iblock. */ - HDassert((NULL == par_iblock->child_iblocks[indir_idx]) || (par_iblock->child_iblocks[indir_idx] == iblock)); + HDassert((NULL == par_iblock->child_iblocks[indir_idx]) || + (par_iblock->child_iblocks[indir_idx] == iblock)); } /* end else */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency with parent, if there is one */ - if(iblock->fd_parent) - if(H5AC_create_flush_dependency(iblock->fd_parent, iblock) < 0) + if (iblock->fd_parent) + if (H5AC_create_flush_dependency(iblock->fd_parent, iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if(iblock->fd_parent) { + if (iblock->fd_parent) { /* Destroy flush dependency with parent */ - if(H5AC_destroy_flush_dependency(iblock->fd_parent, iblock) < 0) + if (H5AC_destroy_flush_dependency(iblock->fd_parent, iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") iblock->fd_parent = NULL; } /* end if */ @@ -1527,7 +1500,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_free_icr * @@ -1549,8 +1521,8 @@ done: static herr_t H5HF__cache_iblock_free_icr(void *thing) { - H5HF_indirect_t *iblock = (H5HF_indirect_t *)thing; /* Fractal heap indirect block to free */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = (H5HF_indirect_t *)thing; /* Fractal heap indirect block to free */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1562,14 +1534,13 @@ H5HF__cache_iblock_free_icr(void *thing) HDassert(iblock->hdr); /* Destroy fractal heap indirect block */ - if(H5HF_man_iblock_dest(iblock) < 0) + if (H5HF_man_iblock_dest(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_get_initial_load_size() * @@ -1587,9 +1558,9 @@ done: static herr_t H5HF__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) { - const H5HF_dblock_cache_ud_t *udata = (const H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ - const H5HF_parent_t *par_info; /* Pointer to parent information */ - const H5HF_hdr_t *hdr; /* Shared fractal heap information */ + const H5HF_dblock_cache_ud_t *udata = (const H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ + const H5HF_parent_t * par_info; /* Pointer to parent information */ + const H5HF_hdr_t * hdr; /* Shared fractal heap information */ FUNC_ENTER_STATIC_NOERR @@ -1604,22 +1575,21 @@ H5HF__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) HDassert(hdr); /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Check for root direct block */ - if(par_info->iblock == NULL) + if (par_info->iblock == NULL) /* filtered root direct block */ *image_len = hdr->pline_root_direct_size; else /* filtered direct block */ *image_len = par_info->iblock->filt_ents[par_info->entry].size; - } /* end if */ + } /* end if */ else *image_len = udata->dblock_size; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_dblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_verify_chksum * @@ -1636,16 +1606,16 @@ H5HF__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5HF_dblock_cache_ud_t *udata = (H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ - void *read_buf = NULL; /* Pointer to buffer to read in */ - H5HF_hdr_t *hdr; /* Shared fractal heap information */ - H5HF_parent_t *par_info; /* Pointer to parent information */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - size_t chk_size; /* The size for validating checksum */ - uint8_t *chk_p; /* Pointer to the area for validating checksum */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5HF_dblock_cache_ud_t *udata = (H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ + void * read_buf = NULL; /* Pointer to buffer to read in */ + H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_parent_t * par_info; /* Pointer to parent information */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + size_t chk_size; /* The size for validating checksum */ + uint8_t * chk_p; /* Pointer to the area for validating checksum */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -1658,44 +1628,45 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) HDassert(hdr); /* Get out if data block is not checksummed */ - if(!(hdr->checksum_dblocks)) - HGOTO_DONE(TRUE); + if (!(hdr->checksum_dblocks)) + HGOTO_DONE(TRUE); - if(hdr->filter_len > 0) { - size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */ - unsigned filter_mask; /* Excluded filters for direct block */ - H5Z_cb_t filter_cb; /* Filter callback structure */ + if (hdr->filter_len > 0) { + size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */ + unsigned filter_mask; /* Excluded filters for direct block */ + H5Z_cb_t filter_cb; /* Filter callback structure */ /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer to perform I/O filtering on and copy image into * it. Must do this as H5Z_pipeline() may re-size the buffer * provided to it. */ - if(NULL == (read_buf = H5MM_malloc(len))) + if (NULL == (read_buf = H5MM_malloc(len))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer") /* Set up parameters for filter pipeline */ - nbytes = len; + nbytes = len; filter_mask = udata->filter_mask; H5MM_memcpy(read_buf, image, len); /* Push direct block data through I/O filter pipeline */ - if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, + &len, &read_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "output pipeline failed") /* Update info about direct block */ udata->decompressed = TRUE; - len = nbytes; + len = nbytes; } /* end if */ else - read_buf = (void *)image; /* Casting away const OK - QAK */ + read_buf = (void *)image; /* Casting away const OK - QAK */ /* Decode checksum */ chk_size = (size_t)(H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) - H5HF_SIZEOF_CHKSUM); - chk_p = (uint8_t *)read_buf + chk_size; + chk_p = (uint8_t *)read_buf + chk_size; /* Metadata checksum */ UINT32DECODE(chk_p, stored_chksum); @@ -1713,32 +1684,31 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) UINT32ENCODE(chk_p, stored_chksum) /* Verify checksum */ - if(stored_chksum != computed_chksum) - HGOTO_DONE(FALSE); + if (stored_chksum != computed_chksum) + HGOTO_DONE(FALSE); /* Save the decompressed data to be used later in deserialize callback */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Sanity check */ - HDassert(udata->decompressed); - HDassert(len == udata->dblock_size); + HDassert(udata->decompressed); + HDassert(len == udata->dblock_size); - /* Allocate block buffer */ - if(NULL == (udata->dblk = H5FL_BLK_MALLOC(direct_block, (size_t)len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + /* Allocate block buffer */ + if (NULL == (udata->dblk = H5FL_BLK_MALLOC(direct_block, (size_t)len))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - /* Copy un-filtered data into block's buffer */ - H5MM_memcpy(udata->dblk, read_buf, len); + /* Copy un-filtered data into block's buffer */ + H5MM_memcpy(udata->dblk, read_buf, len); } /* end if */ done: /* Release the read buffer */ - if(read_buf && read_buf != image) - H5MM_xfree(read_buf); + if (read_buf && read_buf != image) + H5MM_xfree(read_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_deserialize * @@ -1760,17 +1730,16 @@ done: *------------------------------------------------------------------------- */ static void * -H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5HF_hdr_t *hdr; /* Shared fractal heap information */ - H5HF_dblock_cache_ud_t *udata = (H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ - H5HF_parent_t *par_info; /* Pointer to parent information */ - H5HF_direct_t *dblock = NULL; /* Direct block info */ - const uint8_t *image = (const uint8_t *)_image;/* Pointer into raw data buffer */ - void *read_buf = NULL; /* Pointer to buffer to decompress */ - haddr_t heap_addr; /* Address of heap header in the file */ - void * ret_value = NULL; /* Return value */ + H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_dblock_cache_ud_t *udata = (H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ + H5HF_parent_t * par_info; /* Pointer to parent information */ + H5HF_direct_t * dblock = NULL; /* Direct block info */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + void * read_buf = NULL; /* Pointer to buffer to decompress */ + haddr_t heap_addr; /* Address of heap header in the file */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1786,7 +1755,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, HDassert(dirty); /* Allocate space for the fractal heap direct block */ - if(NULL == (dblock = H5FL_CALLOC(H5HF_direct_t))) + if (NULL == (dblock = H5FL_CALLOC(H5HF_direct_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemset(&dblock->cache_info, 0, sizeof(H5AC_info_t)); @@ -1795,16 +1764,16 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, /* Share common heap information */ dblock->hdr = hdr; - if(H5HF_hdr_incr(hdr) < 0) + if (H5HF_hdr_incr(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") /* Set block's internal information */ dblock->size = udata->dblock_size; /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Direct block is already decompressed in verify_chksum callback */ - if(udata->decompressed) { + if (udata->decompressed) { /* Sanity check */ HDassert(udata->dblk); @@ -1813,16 +1782,16 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, udata->dblk = NULL; } /* end if */ else { - H5Z_cb_t filter_cb; /* Filter callback structure */ - size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */ - unsigned filter_mask; /* Excluded filters for direct block */ + H5Z_cb_t filter_cb; /* Filter callback structure */ + size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */ + unsigned filter_mask; /* Excluded filters for direct block */ /* Sanity check */ HDassert(udata->dblk == NULL); /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer to perform I/O filtering on and copy image into * it. Must do this as H5Z_pipeline() may resize the buffer @@ -1835,9 +1804,10 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, H5MM_memcpy(read_buf, image, len); /* Push direct block data through I/O filter pipeline */ - nbytes = len; + nbytes = len; filter_mask = udata->filter_mask; - if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, + &nbytes, &len, &read_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, NULL, "output pipeline failed") /* Sanity check */ @@ -1846,7 +1816,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, /* Copy un-filtered data into block's buffer */ H5MM_memcpy(dblock->blk, read_buf, dblock->size); } /* end if */ - } /* end if */ + } /* end if */ else { /* Sanity checks */ HDassert(udata->dblk == NULL); @@ -1854,7 +1824,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, /* Allocate block buffer */ /* XXX: Change to using free-list factories */ - if (NULL == (dblock->blk = H5FL_BLK_MALLOC(direct_block, (size_t)dblock->size))) + if (NULL == (dblock->blk = H5FL_BLK_MALLOC(direct_block, (size_t)dblock->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy image to dblock->blk */ @@ -1866,38 +1836,39 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, image = dblock->blk; /* Magic number */ - if(HDmemcmp(image, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "wrong fractal heap direct block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5HF_DBLOCK_VERSION) + if (*image++ != H5HF_DBLOCK_VERSION) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap direct block version") /* Address of heap that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->f, &image, &heap_addr); - if(H5F_addr_ne(heap_addr, hdr->heap_addr)) + if (H5F_addr_ne(heap_addr, hdr->heap_addr)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block") /* Address of parent block */ dblock->parent = par_info->iblock; - if(par_info->iblock) + if (par_info->iblock) dblock->fd_parent = par_info->iblock; else dblock->fd_parent = par_info->hdr; dblock->par_entry = par_info->entry; - if(dblock->parent) { + if (dblock->parent) { /* Share parent block */ - if(H5HF_iblock_incr(dblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") + if (H5HF_iblock_incr(dblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, + "can't increment reference count on shared indirect block") } /* end if */ /* Offset of heap within the heap's address space */ UINT64DECODE_VAR(image, dblock->block_off, hdr->heap_off_size); /* Decode checksum on direct block, if requested */ - if(hdr->checksum_dblocks) { - uint32_t stored_chksum; /* Metadata checksum value */ + if (hdr->checksum_dblocks) { + uint32_t stored_chksum; /* Metadata checksum value */ /* checksum verification already done in verify_chksum cb */ @@ -1913,18 +1884,17 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, done: /* Release the read buffer */ - if(read_buf) + if (read_buf) H5MM_xfree(read_buf); /* Cleanup on error */ - if(!ret_value && dblock) - if(H5HF_man_dblock_dest(dblock) < 0) + if (!ret_value && dblock) + if (H5HF_man_dblock_dest(dblock) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_image_len * @@ -1943,9 +1913,9 @@ done: static herr_t H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) { - const H5HF_direct_t *dblock = (const H5HF_direct_t *)_thing; /* Direct block info */ - const H5HF_hdr_t *hdr; /* Shared fractal heap information */ - size_t size; + const H5HF_direct_t *dblock = (const H5HF_direct_t *)_thing; /* Direct block info */ + const H5HF_hdr_t * hdr; /* Shared fractal heap information */ + size_t size; FUNC_ENTER_STATIC_NOERR @@ -1960,7 +1930,7 @@ H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) HDassert(hdr); /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* * If the data is available, set to the compressed * size of the direct block -- otherwise set it equal to the @@ -1986,20 +1956,20 @@ H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) * and thus looking up the parent will likely return incorrect * data. */ - if(dblock->file_size != 0) + if (dblock->file_size != 0) size = dblock->file_size; else { - const H5HF_indirect_t *par_iblock = dblock->parent; /* Parent iblock */ + const H5HF_indirect_t *par_iblock = dblock->parent; /* Parent iblock */ - if(par_iblock) + if (par_iblock) size = par_iblock->filt_ents[dblock->par_entry].size; else size = hdr->pline_root_direct_size; - if(size == 0) + if (size == 0) size = dblock->size; } /* end else */ - } /* end if */ + } /* end if */ else size = dblock->size; @@ -2010,7 +1980,6 @@ H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_dblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_pre_serialize * @@ -2074,21 +2043,21 @@ H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, - haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags) +H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t len, haddr_t *new_addr, + size_t *new_len, unsigned *flags) { - hbool_t at_tmp_addr; /* Flag to indicate direct block is */ - /* at temporary address */ - haddr_t dblock_addr; - H5HF_hdr_t *hdr; /* Shared fractal heap information */ - H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Direct block info */ - H5HF_indirect_t *par_iblock; /* Parent indirect block */ - unsigned par_entry = 0; /* Entry in parent indirect block */ - void *write_buf; /* Pointer to buffer to write out */ - size_t write_size; /* Size of buffer to write out */ - uint8_t *image; /* Pointer into raw data buffer */ - unsigned dblock_flags = 0; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t at_tmp_addr; /* Flag to indicate direct block is */ + /* at temporary address */ + haddr_t dblock_addr; + H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_direct_t * dblock = (H5HF_direct_t *)_thing; /* Direct block info */ + H5HF_indirect_t *par_iblock; /* Parent indirect block */ + unsigned par_entry = 0; /* Entry in parent indirect block */ + void * write_buf; /* Pointer to buffer to write out */ + size_t write_size; /* Size of buffer to write out */ + uint8_t * image; /* Pointer into raw data buffer */ + unsigned dblock_flags = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2106,8 +2075,8 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(flags); /* Set up local variables */ - hdr = dblock->hdr; - dblock_addr = addr; /* will update dblock_addr if we move the block */ + hdr = dblock->hdr; + dblock_addr = addr; /* will update dblock_addr if we move the block */ /* Set the shared heap header's file context for this operation */ hdr->f = (H5F_t *)f; @@ -2116,25 +2085,25 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(hdr->cache_info.type == H5AC_FHEAP_HDR); - if(dblock->parent) { - /* this is the common case, in which the direct block is the child + if (dblock->parent) { + /* this is the common case, in which the direct block is the child * of an indirect block. Set up the convenience variables we will * need if the address and/or compressed size of the on disk image * of the direct block changes, and do some sanity checking in * passing. */ par_iblock = dblock->parent; - par_entry = dblock->par_entry; + par_entry = dblock->par_entry; - HDassert(par_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(par_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); + HDassert(par_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(par_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); HDassert(H5F_addr_eq(par_iblock->ents[par_entry].addr, addr)); } /* end if */ else { - /* the direct block is a root direct block -- just set par_iblock + /* the direct block is a root direct block -- just set par_iblock * to NULL, as the field will not be used. */ - par_iblock = NULL; + par_iblock = NULL; } /* end else */ at_tmp_addr = H5F_IS_TMP_ADDR(f, addr); @@ -2162,8 +2131,8 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, UINT64ENCODE_VAR(image, dblock->block_off, hdr->heap_off_size); /* Metadata checksum */ - if(hdr->checksum_dblocks) { - uint32_t metadata_chksum; /* Computed metadata checksum value */ + if (hdr->checksum_dblocks) { + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Clear the checksum field, to compute the checksum */ HDmemset(image, 0, (size_t)H5HF_SIZEOF_CHKSUM); @@ -2189,18 +2158,18 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, */ /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { - H5Z_cb_t filter_cb; /* Filter callback structure */ - size_t nbytes; /* Number of bytes used */ - unsigned filter_mask = 0; /* Filter mask for block */ + if (hdr->filter_len > 0) { + H5Z_cb_t filter_cb; /* Filter callback structure */ + size_t nbytes; /* Number of bytes used */ + unsigned filter_mask = 0; /* Filter mask for block */ /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer to perform I/O filtering on */ write_size = dblock->size; - if(NULL == (write_buf = H5MM_malloc(write_size))) + if (NULL == (write_buf = H5MM_malloc(write_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer") /* Copy the direct block's image into the buffer to compress */ @@ -2208,7 +2177,8 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, /* Push direct block data through I/O filter pipeline */ nbytes = write_size; - if(H5Z_pipeline(&(hdr->pline), 0, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &write_size, &write_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), 0, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &write_size, + &write_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "output pipeline failed") /* Use the compressed number of bytes as the size to write */ @@ -2223,7 +2193,7 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, */ /* Check for root direct block */ - if(dblock->parent == NULL) { + if (dblock->parent == NULL) { hbool_t hdr_changed = FALSE; /* Whether the header info changed */ /* Sanity check */ @@ -2231,9 +2201,9 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(hdr->pline_root_direct_size > 0); /* Check if the filter mask changed */ - if(hdr->pline_root_direct_filter_mask != filter_mask) { + if (hdr->pline_root_direct_filter_mask != filter_mask) { hdr->pline_root_direct_filter_mask = filter_mask; - hdr_changed = TRUE; + hdr_changed = TRUE; } /* end if */ /* verify that the cache's last record of the compressed @@ -2243,27 +2213,29 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(len == hdr->pline_root_direct_size); /* Check if we need to re-size the block on disk */ - if(hdr->pline_root_direct_size != write_size || at_tmp_addr) { + if (hdr->pline_root_direct_size != write_size || at_tmp_addr) { /* Check if the direct block is NOT currently allocated * in temp. file space * * (temp. file space does not need to be freed) */ - if(!at_tmp_addr) + if (!at_tmp_addr) /* Release direct block's current disk space */ - if(H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, addr, (hsize_t)hdr->pline_root_direct_size) < 0) + if (H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, addr, (hsize_t)hdr->pline_root_direct_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap direct block") /* Allocate space for the compressed direct block */ - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (HADDR_UNDEF == + (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") /* Update information about compressed direct block's * location & size */ HDassert(hdr->man_dtable.table_addr == addr); HDassert(hdr->pline_root_direct_size == len); - hdr->man_dtable.table_addr = dblock_addr; + hdr->man_dtable.table_addr = dblock_addr; hdr->pline_root_direct_size = write_size; /* Note that heap header was modified */ @@ -2271,21 +2243,21 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, } /* end if */ /* Check if heap header was modified */ - if(hdr_changed) - if(H5HF_hdr_dirty(hdr) < 0) + if (hdr_changed) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") - } /* end if */ - else { /* the direct block's parent is an indirect block */ - hbool_t par_changed = FALSE; /* Whether the parent's infochanged */ + } /* end if */ + else { /* the direct block's parent is an indirect block */ + hbool_t par_changed = FALSE; /* Whether the parent's infochanged */ /* Sanity check */ HDassert(par_iblock); HDassert(par_iblock->filt_ents[par_entry].size > 0); /* Check if the filter mask changed */ - if(par_iblock->filt_ents[par_entry].filter_mask != filter_mask) { + if (par_iblock->filt_ents[par_entry].filter_mask != filter_mask) { par_iblock->filt_ents[par_entry].filter_mask = filter_mask; - par_changed = TRUE; + par_changed = TRUE; } /* end if */ /* verify that the cache's last record of the compressed @@ -2295,27 +2267,30 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(len == par_iblock->filt_ents[par_entry].size); /* Check if we need to re-size the block on disk */ - if(par_iblock->filt_ents[par_entry].size != write_size || at_tmp_addr) { + if (par_iblock->filt_ents[par_entry].size != write_size || at_tmp_addr) { /* Check if the direct block is NOT currently allocated * in temp. file space * * (temp. file space does not need to be freed) */ - if(!at_tmp_addr) + if (!at_tmp_addr) /* Release direct block's current disk space */ - if(H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, addr, (hsize_t)par_iblock->filt_ents[par_entry].size) < 0) + if (H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, addr, + (hsize_t)par_iblock->filt_ents[par_entry].size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap direct block") /* Allocate space for the compressed direct block */ - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (HADDR_UNDEF == + (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") /* Update information about compressed direct block's * location & size */ HDassert(par_iblock->ents[par_entry].addr == addr); HDassert(par_iblock->filt_ents[par_entry].size == len); - par_iblock->ents[par_entry].addr = dblock_addr; + par_iblock->ents[par_entry].addr = dblock_addr; par_iblock->filt_ents[par_entry].size = write_size; /* Note that parent was modified */ @@ -2323,11 +2298,11 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, } /* end if */ /* Check if parent was modified */ - if(par_changed) - if(H5HF_iblock_dirty(par_iblock) < 0) + if (par_changed) + if (H5HF_iblock_dirty(par_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end else */ - } /* end if */ + } /* end if */ else { /* I/O filters are not enabled -- thus all we need to do is check to * see if the direct block is in temporary (AKA imaginary) file @@ -2339,19 +2314,21 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, * Recall that temporary file space need not be freed, which * simplifies matters slightly. */ - write_buf = dblock->blk; + write_buf = dblock->blk; write_size = dblock->size; /* Check to see if we must re-allocate direct block from 'temp.' * to 'normal' file space */ - if(at_tmp_addr) { + if (at_tmp_addr) { /* Allocate 'normal' space for the direct block */ - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (HADDR_UNDEF == + (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") /* Check for root direct block */ - if(NULL == dblock->parent) { + if (NULL == dblock->parent) { /* Sanity checks */ HDassert(H5F_addr_eq(hdr->man_dtable.table_addr, addr)); HDassert(!H5F_addr_eq(hdr->man_dtable.table_addr, dblock_addr)); @@ -2360,9 +2337,9 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, hdr->man_dtable.table_addr = dblock_addr; /* Mark that heap header was modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") - } /* end if */ + } /* end if */ else { /* the direct block's parent is an indirect block */ /* Sanity checks */ HDassert(par_iblock); @@ -2374,11 +2351,11 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, par_iblock->ents[par_entry].addr = dblock_addr; /* Mark that parent was modified */ - if(H5HF_iblock_dirty(par_iblock) < 0) + if (H5HF_iblock_dirty(par_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end else */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* At this point, write_buf points to a buffer containing the image * of the direct block that is ready to copy into the image buffer, @@ -2390,16 +2367,16 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, * Now, make note of the pointer and length of the above buffer for * use by the serialize function. */ - dblock->write_buf = (uint8_t *)write_buf; + dblock->write_buf = (uint8_t *)write_buf; dblock->write_size = write_size; /* finally, pass data back to the metadata cache as appropriate */ - if(!H5F_addr_eq(addr, dblock_addr)) { + if (!H5F_addr_eq(addr, dblock_addr)) { dblock_flags |= H5AC__SERIALIZE_MOVED_FLAG; *new_addr = dblock_addr; } /* end if */ - if((hdr->filter_len > 0) && (len != write_size)) { + if ((hdr->filter_len > 0) && (len != write_size)) { dblock_flags |= H5AC__SERIALIZE_RESIZED_FLAG; *new_len = write_size; } /* end if */ @@ -2412,13 +2389,12 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, done: /* discard the write buf if we have an error */ - if(write_buf && (write_buf != dblock->blk) && (dblock->write_buf == NULL)) - H5MM_xfree(write_buf); + if (write_buf && (write_buf != dblock->blk) && (dblock->write_buf == NULL)) + H5MM_xfree(write_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_serialize * @@ -2442,10 +2418,10 @@ done: */ static herr_t H5HF__cache_dblock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, - size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) + size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Direct block info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Direct block info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -2468,17 +2444,16 @@ H5HF__cache_dblock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, /* Free *(dblock->write_buf) if it was allocated by the * pre-serialize function */ - if(dblock->write_buf != dblock->blk) + if (dblock->write_buf != dblock->blk) H5MM_xfree(dblock->write_buf); /* Reset the write_buf and write_size fields */ - dblock->write_buf = NULL; + dblock->write_buf = NULL; dblock->write_size = 0; FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_notify * @@ -2496,8 +2471,8 @@ H5HF__cache_dblock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, static herr_t H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) { - H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Fractal heap direct block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Fractal heap direct block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2507,29 +2482,29 @@ H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) HDassert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); HDassert(dblock->hdr); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency with parent, if there is one */ - if(dblock->fd_parent) - if(H5AC_create_flush_dependency(dblock->fd_parent, dblock) < 0) + if (dblock->fd_parent) + if (H5AC_create_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if(dblock->fd_parent) { + if (dblock->fd_parent) { /* Destroy flush dependency with parent */ - if(H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) + if (H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") dblock->fd_parent = NULL; } /* end if */ @@ -2544,7 +2519,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_free_icr * @@ -2566,8 +2540,8 @@ done: static herr_t H5HF__cache_dblock_free_icr(void *_thing) { - H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Fractal heap direct block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Fractal heap direct block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2577,14 +2551,13 @@ H5HF__cache_dblock_free_icr(void *_thing) HDassert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); /* Destroy fractal heap direct block */ - if(H5HF_man_dblock_dest(dblock) < 0) + if (H5HF_man_dblock_dest(dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_fsf_size * @@ -2603,7 +2576,7 @@ done: static herr_t H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) { - const H5HF_direct_t *dblock = (const H5HF_direct_t *)_thing; /* Fractal heap direct block */ + const H5HF_direct_t *dblock = (const H5HF_direct_t *)_thing; /* Fractal heap direct block */ FUNC_ENTER_STATIC_NOERR @@ -2620,7 +2593,6 @@ H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_dblock_fsf_size() */ - /*------------------------------------------------------------------------ * Function: H5HF__cache_verify_hdr_descendants_clean * @@ -2686,13 +2658,12 @@ H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) */ #ifndef NDEBUG static herr_t -H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, - hbool_t *fd_clean, hbool_t *clean) +H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_clean, hbool_t *clean) { - hbool_t fd_exists = FALSE; /* whether flush dependency exists. */ - haddr_t hdr_addr; /* Address of header */ - unsigned hdr_status = 0; /* Header cache entry status */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t fd_exists = FALSE; /* whether flush dependency exists. */ + haddr_t hdr_addr; /* Address of header */ + unsigned hdr_status = 0; /* Header cache entry status */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2706,7 +2677,7 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hdr_addr = hdr->cache_info.addr; HDassert(hdr_addr == hdr->heap_addr); - if(H5AC_get_entry_status(f, hdr_addr, &hdr_status) < 0) + if (H5AC_get_entry_status(f, hdr_addr, &hdr_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get hdr status") HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -2740,52 +2711,51 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, * Since the former case is far and away the most common, we don't * worry too much about efficiency in the second case. */ - if(hdr->root_iblock || - ((hdr->man_dtable.curr_root_rows > 0) && - (HADDR_UNDEF != hdr->man_dtable.table_addr))) { + if (hdr->root_iblock || + ((hdr->man_dtable.curr_root_rows > 0) && (HADDR_UNDEF != hdr->man_dtable.table_addr))) { H5HF_indirect_t *root_iblock = hdr->root_iblock; - haddr_t root_iblock_addr; - unsigned root_iblock_status = 0; - hbool_t root_iblock_in_cache; + haddr_t root_iblock_addr; + unsigned root_iblock_status = 0; + hbool_t root_iblock_in_cache; /* make note of the on disk address of the root iblock */ - if(root_iblock == NULL) - /* hdr->man_dtable.table_addr must contain address of root + if (root_iblock == NULL) + /* hdr->man_dtable.table_addr must contain address of root * iblock. Check to see if it is in cache. If it is, * protect it and put its address in root_iblock. */ - root_iblock_addr = hdr->man_dtable.table_addr; + root_iblock_addr = hdr->man_dtable.table_addr; else - root_iblock_addr = root_iblock->addr; + root_iblock_addr = root_iblock->addr; - /* get the status of the root iblock */ - HDassert(root_iblock_addr != HADDR_UNDEF); - if(H5AC_get_entry_status(f, root_iblock_addr, &root_iblock_status) < 0) + /* get the status of the root iblock */ + HDassert(root_iblock_addr != HADDR_UNDEF); + if (H5AC_get_entry_status(f, root_iblock_addr, &root_iblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get root iblock status") - root_iblock_in_cache = ( (root_iblock_status & H5AC_ES__IN_CACHE) != 0); - HDassert(root_iblock_in_cache || (root_iblock == NULL)); + root_iblock_in_cache = ((root_iblock_status & H5AC_ES__IN_CACHE) != 0); + HDassert(root_iblock_in_cache || (root_iblock == NULL)); - if(!root_iblock_in_cache) { /* we are done */ - *clean = TRUE; + if (!root_iblock_in_cache) { /* we are done */ + *clean = TRUE; *fd_clean = TRUE; } /* end if */ - else if((root_iblock_status & H5AC_ES__IS_DIRTY) && - (((root_iblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || - (!H5AC_get_serialization_in_progress(f)))) { + else if ((root_iblock_status & H5AC_ES__IS_DIRTY) && + (((root_iblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || + (!H5AC_get_serialization_in_progress(f)))) { *clean = FALSE; /* verify that a flush dependency exists between the header and * the root inode. */ - if(H5AC_flush_dependency_exists(f, hdr->heap_addr, root_iblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, hdr->heap_addr, root_iblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") HDassert(fd_exists); *fd_clean = FALSE; - } /* end else-if */ + } /* end else-if */ else { /* must examine children */ - hbool_t unprotect_root_iblock = FALSE; + hbool_t unprotect_root_iblock = FALSE; /* At this point, the root iblock may be pinned, protected, * both, or neither, and we may or may not have a pointer @@ -2796,8 +2766,8 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, * protected or both, and that we have a pointer to it. * Do this as follows: */ - if(root_iblock == NULL) { /* we don't have ptr to root iblock */ - if(0 == (root_iblock_status & H5AC_ES__IS_PROTECTED)) { + if (root_iblock == NULL) { /* we don't have ptr to root iblock */ + if (0 == (root_iblock_status & H5AC_ES__IS_PROTECTED)) { /* just protect the root iblock -- this will give us * the pointer we need to proceed, and ensure that * it is locked into the metadata cache for the @@ -2817,7 +2787,8 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, */ H5_BEGIN_TAG(hdr->heap_addr) - if(NULL == (root_iblock = (H5HF_indirect_t *)H5AC_protect(f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) + if (NULL == (root_iblock = (H5HF_indirect_t *)H5AC_protect( + f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") H5_END_TAG @@ -2860,20 +2831,20 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, * that we will use this approach until it causes problems, * or we think of a better way. */ - if(H5AC_get_entry_ptr_from_addr(f, root_iblock_addr, (void **)(&root_iblock)) < 0) + if (H5AC_get_entry_ptr_from_addr(f, root_iblock_addr, (void **)(&root_iblock)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "H5AC_get_entry_ptr_from_addr() failed.") HDassert(root_iblock); - } /* end else */ - } /* end if */ - else { /* root_iblock != NULL */ - /* we have the pointer to the root iblock. Protect it - * if it is neither pinned nor protected -- otherwise we - * are ready to go. - */ - H5HF_indirect_t * iblock = NULL; - - if(((root_iblock_status & H5AC_ES__IS_PINNED) == 0) && - ((root_iblock_status & H5AC_ES__IS_PROTECTED) == 0)) { + } /* end else */ + } /* end if */ + else { /* root_iblock != NULL */ + /* we have the pointer to the root iblock. Protect it + * if it is neither pinned nor protected -- otherwise we + * are ready to go. + */ + H5HF_indirect_t *iblock = NULL; + + if (((root_iblock_status & H5AC_ES__IS_PINNED) == 0) && + ((root_iblock_status & H5AC_ES__IS_PROTECTED) == 0)) { /* the root iblock is neither pinned nor protected -- hence * we must protect it before we proceed * @@ -2891,7 +2862,8 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, */ H5_BEGIN_TAG(hdr->heap_addr) - if(NULL == (iblock = (H5HF_indirect_t *)H5AC_protect(f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) + if (NULL == (iblock = (H5HF_indirect_t *)H5AC_protect( + f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") H5_END_TAG @@ -2899,43 +2871,44 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, unprotect_root_iblock = TRUE; HDassert(iblock == root_iblock); } /* end if */ - } /* end else */ + } /* end else */ /* at this point, one way or another, the root iblock is locked * in memory for the duration of the call. Do some sanity checks, * and then call H5HF__cache_verify_iblock_descendants_clean(). */ - HDassert(root_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(root_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); + HDassert(root_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(root_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); - if(H5HF__cache_verify_iblock_descendants_clean(f, hdr->heap_addr, root_iblock, &root_iblock_status, fd_clean, clean) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify root iblock & descendants clean.") + if (H5HF__cache_verify_iblock_descendants_clean(f, hdr->heap_addr, root_iblock, + &root_iblock_status, fd_clean, clean) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify root iblock & descendants clean.") - /* Unprotect the root indirect block if required */ - if(unprotect_root_iblock) { + /* Unprotect the root indirect block if required */ + if (unprotect_root_iblock) { HDassert(root_iblock); - if(H5AC_unprotect(f, H5AC_FHEAP_IBLOCK, root_iblock_addr, root_iblock, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(f, H5AC_FHEAP_IBLOCK, root_iblock_addr, root_iblock, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "H5AC_unprotect() failed.") } /* end if */ - } /* end else */ - } /* end if */ - else if((hdr->man_dtable.curr_root_rows == 0) && - (HADDR_UNDEF != hdr->man_dtable.table_addr)) { - haddr_t root_dblock_addr; - unsigned root_dblock_status = 0; - hbool_t in_cache; - hbool_t type_ok; - - /* this is scenario 2 -- we have a root dblock */ - root_dblock_addr = hdr->man_dtable.table_addr; - if(H5AC_get_entry_status(f, root_dblock_addr, &root_dblock_status) < 0) + } /* end else */ + } /* end if */ + else if ((hdr->man_dtable.curr_root_rows == 0) && (HADDR_UNDEF != hdr->man_dtable.table_addr)) { + haddr_t root_dblock_addr; + unsigned root_dblock_status = 0; + hbool_t in_cache; + hbool_t type_ok; + + /* this is scenario 2 -- we have a root dblock */ + root_dblock_addr = hdr->man_dtable.table_addr; + if (H5AC_get_entry_status(f, root_dblock_addr, &root_dblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get root dblock status") - if(root_dblock_status & H5AC_ES__IN_CACHE) { - if(H5AC_verify_entry_type(f, root_dblock_addr, &H5AC_FHEAP_DBLOCK[0], &in_cache, &type_ok) < 0) + if (root_dblock_status & H5AC_ES__IN_CACHE) { + if (H5AC_verify_entry_type(f, root_dblock_addr, &H5AC_FHEAP_DBLOCK[0], &in_cache, &type_ok) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check dblock type") HDassert(in_cache); - if(!type_ok) + if (!type_ok) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "root dblock addr doesn't refer to a dblock?!?") /* If a root dblock is in cache, it must have a flush @@ -2947,32 +2920,31 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, * the root iblock is a child in a flush dependency * relationship with the header. */ - if(H5AC_flush_dependency_exists(f, hdr->heap_addr, root_dblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, hdr->heap_addr, root_dblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(!fd_exists) + if (!fd_exists) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "root dblock is not a flush dep parent of header.") - if(0 != (root_dblock_status & H5AC_ES__IS_FLUSH_DEP_PARENT)) + if (0 != (root_dblock_status & H5AC_ES__IS_FLUSH_DEP_PARENT)) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "root dblock in cache and is a flush dep parent.") *clean = !((root_dblock_status & H5AC_ES__IS_DIRTY) && - (((root_dblock_status & - H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || + (((root_dblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || (!H5AC_get_serialization_in_progress(f)))); *fd_clean = *clean; - } /* end if */ - else { /* root dblock not in cache */ + } /* end if */ + else { /* root dblock not in cache */ *fd_clean = TRUE; - *clean = TRUE; + *clean = TRUE; } /* end else */ - } /* end else-if */ + } /* end else-if */ else { /* this is scenario 3 -- the fractal heap is empty, and we * have nothing to do. */ *fd_clean = TRUE; - *clean = TRUE; + *clean = TRUE; } /* end else */ done: @@ -2980,7 +2952,6 @@ done: } /* H5HF__cache_verify_hdr_descendants_clean() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------ * Function: H5HF__cache_verify_iblock_descendants_clean * @@ -3051,13 +3022,12 @@ done: */ #ifndef NDEBUG static herr_t -H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, - H5HF_indirect_t *iblock, unsigned *iblock_status, hbool_t * fd_clean, - hbool_t *clean) +H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, H5HF_indirect_t *iblock, + unsigned *iblock_status, hbool_t *fd_clean, hbool_t *clean) { - hbool_t has_dblocks = FALSE; - hbool_t has_iblocks = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t has_dblocks = FALSE; + hbool_t has_iblocks = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3072,26 +3042,27 @@ H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, HDassert(*fd_clean); HDassert(clean); /* note that *clean need not be TRUE */ - if((*fd_clean) && H5HF__cache_verify_iblocks_dblocks_clean(f, fd_parent_addr, iblock, fd_clean, clean, &has_dblocks) < 0) + if ((*fd_clean) && H5HF__cache_verify_iblocks_dblocks_clean(f, fd_parent_addr, iblock, fd_clean, clean, + &has_dblocks) < 0) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify dblocks clean.") - if((*fd_clean) && H5HF__cache_verify_descendant_iblocks_clean(f, fd_parent_addr, iblock, fd_clean, clean, &has_iblocks) < 0) + if ((*fd_clean) && H5HF__cache_verify_descendant_iblocks_clean(f, fd_parent_addr, iblock, fd_clean, clean, + &has_iblocks) < 0) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify iblocks clean.") /* verify that flush dependency setup is plausible */ - if(0 == (*iblock_status & H5AC_ES__IS_FLUSH_DEP_CHILD)) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock is not a flush dep child.") - if(((has_dblocks || has_iblocks)) && (0 == (*iblock_status & H5AC_ES__IS_FLUSH_DEP_PARENT))) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock has children and is not a flush dep parent.") - if(((has_dblocks || has_iblocks)) && (0 == (*iblock_status & H5AC_ES__IS_PINNED))) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock has children and is not pinned.") + if (0 == (*iblock_status & H5AC_ES__IS_FLUSH_DEP_CHILD)) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock is not a flush dep child.") + if (((has_dblocks || has_iblocks)) && (0 == (*iblock_status & H5AC_ES__IS_FLUSH_DEP_PARENT))) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock has children and is not a flush dep parent.") + if (((has_dblocks || has_iblocks)) && (0 == (*iblock_status & H5AC_ES__IS_PINNED))) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock has children and is not pinned.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__cache_verify_iblock_descendants_clean() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------ * Function: H5HF__cache_verify_iblocks_dblocks_clean * @@ -3168,15 +3139,14 @@ done: */ #ifndef NDEBUG static herr_t -H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, - H5HF_indirect_t *iblock, hbool_t *fd_clean, hbool_t *clean, - hbool_t *has_dblocks) +H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5HF_indirect_t *iblock, + hbool_t *fd_clean, hbool_t *clean, hbool_t *has_dblocks) { - unsigned num_direct_rows; - unsigned max_dblock_index; - unsigned i; - haddr_t iblock_addr; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_direct_rows; + unsigned max_dblock_index; + unsigned i; + haddr_t iblock_addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3191,47 +3161,47 @@ H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, HDassert(clean); /* note that *clean need not be true */ HDassert(has_dblocks); - i = 0; + i = 0; num_direct_rows = MIN(iblock->nrows, iblock->hdr->man_dtable.max_direct_rows); HDassert(num_direct_rows <= iblock->nrows); max_dblock_index = (num_direct_rows * iblock->hdr->man_dtable.cparam.width) - 1; - iblock_addr = iblock->addr; + iblock_addr = iblock->addr; HDassert(H5F_addr_defined(iblock_addr)); - while((*fd_clean) && (i <= max_dblock_index)) { - haddr_t dblock_addr; + while ((*fd_clean) && (i <= max_dblock_index)) { + haddr_t dblock_addr; dblock_addr = iblock->ents[i].addr; - if(H5F_addr_defined(dblock_addr)) { - hbool_t in_cache; - hbool_t type_ok; + if (H5F_addr_defined(dblock_addr)) { + hbool_t in_cache; + hbool_t type_ok; - if(H5AC_verify_entry_type(f, dblock_addr, &H5AC_FHEAP_DBLOCK[0], &in_cache, &type_ok) < 0) + if (H5AC_verify_entry_type(f, dblock_addr, &H5AC_FHEAP_DBLOCK[0], &in_cache, &type_ok) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check dblock type") - if(in_cache) { /* dblock is in cache */ - hbool_t fd_exists; - unsigned dblock_status = 0; + if (in_cache) { /* dblock is in cache */ + hbool_t fd_exists; + unsigned dblock_status = 0; - if(!type_ok) + if (!type_ok) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "dblock addr doesn't refer to a dblock?!?") - if(H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) + if (H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get dblock status") HDassert(dblock_status & H5AC_ES__IN_CACHE); *has_dblocks = TRUE; - if((dblock_status & H5AC_ES__IS_DIRTY) && - (((dblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || - (!H5AC_get_serialization_in_progress(f)))) { + if ((dblock_status & H5AC_ES__IS_DIRTY) && + (((dblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || + (!H5AC_get_serialization_in_progress(f)))) { *clean = FALSE; - if(H5AC_flush_dependency_exists(f, fd_parent_addr, dblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, fd_parent_addr, dblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(fd_exists) + if (fd_exists) *fd_clean = FALSE; } /* end if */ @@ -3239,13 +3209,14 @@ H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, * dependency relationship with this iblock. Test this * here. */ - if(H5AC_flush_dependency_exists(f, iblock_addr, dblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, iblock_addr, dblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(!fd_exists) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "dblock in cache and not a flush dep child of iblock.") + if (!fd_exists) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, + "dblock in cache and not a flush dep child of iblock.") } /* end if */ - } /* end if */ + } /* end if */ i++; } /* end while */ @@ -3255,7 +3226,6 @@ done: } /* H5HF__cache_verify_iblocks_dblocks_clean() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------ * Function: H5HF__cache_verify_descendant_iblocks_clean * @@ -3333,16 +3303,15 @@ done: */ #ifndef NDEBUG static herr_t -H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, - H5HF_indirect_t *iblock, hbool_t *fd_clean, hbool_t *clean, - hbool_t *has_iblocks) +H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5HF_indirect_t *iblock, + hbool_t *fd_clean, hbool_t *clean, hbool_t *has_iblocks) { - unsigned first_iblock_index; - unsigned last_iblock_index; - unsigned num_direct_rows; - unsigned i; - haddr_t iblock_addr; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned first_iblock_index; + unsigned last_iblock_index; + unsigned num_direct_rows; + unsigned i; + haddr_t iblock_addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3359,35 +3328,35 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, num_direct_rows = MIN(iblock->nrows, iblock->hdr->man_dtable.max_direct_rows); HDassert(num_direct_rows <= iblock->nrows); - iblock_addr = iblock->addr; + iblock_addr = iblock->addr; first_iblock_index = num_direct_rows * iblock->hdr->man_dtable.cparam.width; - last_iblock_index = (iblock->nrows * iblock->hdr->man_dtable.cparam.width) - 1; + last_iblock_index = (iblock->nrows * iblock->hdr->man_dtable.cparam.width) - 1; i = first_iblock_index; - while((*fd_clean) && (i <= last_iblock_index)) { - haddr_t child_iblock_addr = iblock->ents[i].addr; + while ((*fd_clean) && (i <= last_iblock_index)) { + haddr_t child_iblock_addr = iblock->ents[i].addr; - if(H5F_addr_defined(child_iblock_addr)) { - unsigned child_iblock_status = 0; + if (H5F_addr_defined(child_iblock_addr)) { + unsigned child_iblock_status = 0; - if(H5AC_get_entry_status(f, child_iblock_addr, &child_iblock_status) < 0) + if (H5AC_get_entry_status(f, child_iblock_addr, &child_iblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get iblock status") - if(child_iblock_status & H5AC_ES__IN_CACHE) { - hbool_t fd_exists; + if (child_iblock_status & H5AC_ES__IN_CACHE) { + hbool_t fd_exists; - *has_iblocks = TRUE; + *has_iblocks = TRUE; - if((child_iblock_status & H5AC_ES__IS_DIRTY) && - (((child_iblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || - (!H5AC_get_serialization_in_progress(f)))) { + if ((child_iblock_status & H5AC_ES__IS_DIRTY) && + (((child_iblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || + (!H5AC_get_serialization_in_progress(f)))) { *clean = FALSE; - if(H5AC_flush_dependency_exists(f, fd_parent_addr, child_iblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, fd_parent_addr, child_iblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(fd_exists) + if (fd_exists) *fd_clean = FALSE; } /* end if */ @@ -3443,13 +3412,13 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, * expect that we will use this approach until it causes * problems, or we think of a better way. */ - if(*fd_clean) { - H5HF_indirect_t *child_iblock = NULL; - hbool_t unprotect_child_iblock = FALSE; + if (*fd_clean) { + H5HF_indirect_t *child_iblock = NULL; + hbool_t unprotect_child_iblock = FALSE; - if(0 == (child_iblock_status & H5AC_ES__IS_PINNED)) { + if (0 == (child_iblock_status & H5AC_ES__IS_PINNED)) { /* child iblock is not pinned */ - if(0 == (child_iblock_status & H5AC_ES__IS_PROTECTED)) { + if (0 == (child_iblock_status & H5AC_ES__IS_PROTECTED)) { /* child iblock is unprotected, and unpinned */ /* protect it. Note that the udata is only */ /* used in the load callback. While the */ @@ -3470,7 +3439,9 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5_BEGIN_TAG(iblock->hdr->heap_addr) - if(NULL == (child_iblock = (H5HF_indirect_t *) H5AC_protect(f, H5AC_FHEAP_IBLOCK, child_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) + if (NULL == + (child_iblock = (H5HF_indirect_t *)H5AC_protect( + f, H5AC_FHEAP_IBLOCK, child_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") H5_END_TAG @@ -3482,11 +3453,13 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, /* H5AC_get_entry_ptr_from_addr() to get a */ /* pointer to the entry. This is very slimy -- */ /* come up with a better solution. */ - if(H5AC_get_entry_ptr_from_addr(f, child_iblock_addr, (void **)(&child_iblock)) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "H5AC_get_entry_ptr_from_addr() failed.") + if (H5AC_get_entry_ptr_from_addr(f, child_iblock_addr, (void **)(&child_iblock)) < + 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "H5AC_get_entry_ptr_from_addr() failed.") HDassert(child_iblock); } /* end else */ - } /* end if */ + } /* end if */ else { /* child iblock is pinned -- look it up in the */ /* parent iblocks child_iblocks array. */ @@ -3504,29 +3477,32 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, HDassert(child_iblock->addr == child_iblock_addr); /* now make the recursive call */ - if(H5HF__cache_verify_iblock_descendants_clean(f, fd_parent_addr, child_iblock, &child_iblock_status, fd_clean, clean) < 0) + if (H5HF__cache_verify_iblock_descendants_clean( + f, fd_parent_addr, child_iblock, &child_iblock_status, fd_clean, clean) < 0) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify child iblock clean.") /* if iblock_addr != fd_parent_addr, verify that a flush * dependency relationship exists between iblock and * the child iblock. */ - if(fd_parent_addr != iblock_addr) { - if(H5AC_flush_dependency_exists(f, iblock_addr, child_iblock_addr, &fd_exists) < 0) + if (fd_parent_addr != iblock_addr) { + if (H5AC_flush_dependency_exists(f, iblock_addr, child_iblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(!fd_exists) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock is not a flush dep parent of child_iblock.") + if (!fd_exists) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, + "iblock is not a flush dep parent of child_iblock.") } /* end if */ /* if we protected the child iblock, unprotect it now */ - if(unprotect_child_iblock) { - if(H5AC_unprotect(f, H5AC_FHEAP_IBLOCK, child_iblock_addr, child_iblock, H5AC__NO_FLAGS_SET) < 0) + if (unprotect_child_iblock) { + if (H5AC_unprotect(f, H5AC_FHEAP_IBLOCK, child_iblock_addr, child_iblock, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "H5AC_unprotect() failed.") } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ i++; } /* end while */ @@ -3535,4 +3511,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__cache_verify_descendant_iblocks_clean() */ #endif /* NDEBUG */ - diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index 22de0c4..5c4f9df 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -26,77 +26,69 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ -#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ +#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for direct block debugging iterator callback */ typedef struct { - FILE *stream; /* Stream for output */ - int indent; /* Indention amount */ - int fwidth; /* Field width mount */ - haddr_t dblock_addr; /* Direct block's address */ - hsize_t dblock_size; /* Direct block's size */ - uint8_t *marker; /* 'Marker' array for free space */ - size_t sect_count; /* Number of free space sections in block */ - size_t amount_free; /* Amount of free space in block */ + FILE * stream; /* Stream for output */ + int indent; /* Indention amount */ + int fwidth; /* Field width mount */ + haddr_t dblock_addr; /* Direct block's address */ + hsize_t dblock_size; /* Direct block's size */ + uint8_t *marker; /* 'Marker' array for free space */ + size_t sect_count; /* Number of free space sections in block */ + size_t amount_free; /* Amount of free space in block */ } H5HF_debug_iter_ud1_t; /* User data for free space section iterator callback */ typedef struct { - H5FS_t *fspace; /* Free space manager */ - FILE *stream; /* Stream for output */ - int indent; /* Indention amount */ - int fwidth; /* Field width mount */ + H5FS_t *fspace; /* Free space manager */ + FILE * stream; /* Stream for output */ + int indent; /* Indention amount */ + int fwidth; /* Field width mount */ } H5HF_debug_iter_ud2_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, - int indent, int fwidth); - +static herr_t H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5HF_id_print * @@ -113,12 +105,12 @@ static herr_t H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, herr_t H5HF_id_print(H5HF_t *fh, const void *_id, FILE *stream, int indent, int fwidth) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - hsize_t obj_off; /* Offset of object */ - size_t obj_len; /* Length of object */ - char id_type; /* Character for the type of heap ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + hsize_t obj_off; /* Offset of object */ + size_t obj_len; /* Length of object */ + char id_type; /* Character for the type of heap ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -135,42 +127,40 @@ H5HF_id_print(H5HF_t *fh, const void *_id, FILE *stream, int indent, int fwidth) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { id_type = 'M'; } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { id_type = 'H'; } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { id_type = 'T'; } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ /* Get the length of the heap object */ - if(H5HF_get_obj_len(fh, id, &obj_len) < 0) + if (H5HF_get_obj_len(fh, id, &obj_len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve heap ID length") /* Get the offset of the heap object */ - if(H5HF_get_obj_off(fh, id, &obj_off) < 0) + if (H5HF_get_obj_off(fh, id, &obj_off) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve heap ID length") /* Display the heap ID */ - HDfprintf(stream, "%*s%-*s (%c, %Hu, %Zu)\n", indent, "", fwidth, - "Heap ID info: (type, offset, length)", + HDfprintf(stream, "%*s%-*s (%c, %Hu, %Zu)\n", indent, "", fwidth, "Heap ID info: (type, offset, length)", id_type, obj_off, obj_len); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_id_print() */ - /*------------------------------------------------------------------------- * Function: H5HF_dtable_debug * @@ -201,48 +191,34 @@ H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, int indent, int fwi * Print the values. */ /* Creation parameter values */ - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Doubling table width:", - dtable->cparam.width); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Doubling table width:", dtable->cparam.width); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Starting block size:", - dtable->cparam.start_block_size); + "Starting block size:", dtable->cparam.start_block_size); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Max. direct block size:", - dtable->cparam.max_direct_size); + "Max. direct block size:", dtable->cparam.max_direct_size); HDfprintf(stream, "%*s%-*s %u (bits)\n", indent, "", fwidth, - "Max. index size:", - dtable->cparam.max_index); + "Max. index size:", dtable->cparam.max_index); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Starting # of rows in root indirect block:", - dtable->cparam.start_root_rows); + "Starting # of rows in root indirect block:", dtable->cparam.start_root_rows); /* Run-time varying parameter values */ - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Table's root address:", - dtable->table_addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Table's root address:", dtable->table_addr); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Current # of rows in root indirect block:", - dtable->curr_root_rows); + "Current # of rows in root indirect block:", dtable->curr_root_rows); /* Computed values */ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. # of rows in root indirect block:", - dtable->max_root_rows); + "Max. # of rows in root indirect block:", dtable->max_root_rows); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. # of direct rows in any indirect block:", - dtable->max_direct_rows); + "Max. # of direct rows in any indirect block:", dtable->max_direct_rows); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "# of bits for IDs in first row:", - dtable->first_row_bits); + "# of bits for IDs in first row:", dtable->first_row_bits); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "# of IDs in first row:", - dtable->num_id_first_row); + "# of IDs in first row:", dtable->num_id_first_row); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_dtable_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_print * @@ -276,93 +252,66 @@ H5HF_hdr_print(const H5HF_hdr_t *hdr, hbool_t dump_internal, FILE *stream, int i * Print the values. */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Heap is:", - hdr->man_dtable.curr_root_rows > 0 ? "Indirect" : "Direct"); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Objects stored in 'debugging' format:", - hdr->debug_objs); + "Heap is:", hdr->man_dtable.curr_root_rows > 0 ? "Indirect" : "Direct"); HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "'Write once' flag:", - hdr->write_once); + "Objects stored in 'debugging' format:", hdr->debug_objs); + HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, "'Write once' flag:", hdr->write_once); HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "'Huge' object IDs have wrapped:", - hdr->huge_ids_wrapped); + "'Huge' object IDs have wrapped:", hdr->huge_ids_wrapped); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Free space in managed blocks:", - hdr->total_man_free); + "Free space in managed blocks:", hdr->total_man_free); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Managed space data block size:", hdr->man_size); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Managed space data block size:", - hdr->man_size); + "Total managed space allocated:", hdr->man_alloc_size); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Total managed space allocated:", - hdr->man_alloc_size); + "Offset of managed space iterator:", hdr->man_iter_off); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Offset of managed space iterator:", - hdr->man_iter_off); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of managed objects in heap:", - hdr->man_nobjs); + "Number of managed objects in heap:", hdr->man_nobjs); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of free space manager for managed blocks:", - hdr->fs_addr); + "Address of free space manager for managed blocks:", hdr->fs_addr); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Max. size of managed object:", - (unsigned long)hdr->max_man_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "'Huge' object space used:", - hdr->huge_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of 'huge' objects in heap:", - hdr->huge_nobjs); + "Max. size of managed object:", (unsigned long)hdr->max_man_size); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "'Huge' object space used:", hdr->huge_size); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "ID of next 'huge' object:", - hdr->huge_next_id); + "Number of 'huge' objects in heap:", hdr->huge_nobjs); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "ID of next 'huge' object:", hdr->huge_next_id); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of v2 B-tree for 'huge' objects:", - hdr->huge_bt2_addr); + "Address of v2 B-tree for 'huge' objects:", hdr->huge_bt2_addr); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "'Tiny' object space used:", hdr->tiny_size); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "'Tiny' object space used:", - hdr->tiny_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of 'tiny' objects in heap:", - hdr->tiny_nobjs); + "Number of 'tiny' objects in heap:", hdr->tiny_nobjs); HDfprintf(stream, "%*sManaged Objects Doubling-Table Info...\n", indent, ""); H5HF_dtable_debug(&hdr->man_dtable, stream, indent + 3, MAX(0, fwidth - 3)); /* Print information about I/O filters */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { HDfprintf(stream, "%*sI/O filter Info...\n", indent, ""); - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Compressed size of root direct block:", - hdr->pline_root_direct_size); + "Compressed size of root direct block:", hdr->pline_root_direct_size); HDfprintf(stream, "%*s%-*s %x\n", indent + 3, "", MAX(0, fwidth - 3), - "Filter mask for root direct block:", - hdr->pline_root_direct_filter_mask); + "Filter mask for root direct block:", hdr->pline_root_direct_filter_mask); } /* end if */ H5O_debug_id(H5O_PLINE_ID, hdr->f, &(hdr->pline), stream, indent + 3, MAX(0, fwidth - 3)); } /* end if */ /* Print internal (runtime) information, if requested */ - if(dump_internal) { + if (dump_internal) { HDfprintf(stream, "%*sFractal Heap Header Internal Information:\n", indent, ""); /* Dump root iblock, if there is one */ HDfprintf(stream, "%*s%-*s %x\n", indent + 3, "", MAX(0, fwidth - 3), - "Root indirect block flags:", - hdr->root_iblock_flags); + "Root indirect block flags:", hdr->root_iblock_flags); HDfprintf(stream, "%*s%-*s %p\n", indent + 3, "", MAX(0, fwidth - 3), - "Root indirect block pointer:", - hdr->root_iblock); - if(hdr->root_iblock) + "Root indirect block pointer:", hdr->root_iblock); + if (hdr->root_iblock) H5HF_iblock_print(hdr->root_iblock, dump_internal, stream, indent + 3, fwidth); } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* end H5HF_hdr_print() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_debug * @@ -379,8 +328,8 @@ H5HF_hdr_print(const H5HF_hdr_t *hdr, hbool_t dump_internal, FILE *stream, int i herr_t H5HF_hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) { - H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -394,20 +343,19 @@ H5HF_hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) HDassert(fwidth >= 0); /* Load the fractal heap header */ - if(NULL == (hdr = H5HF__hdr_protect(f, addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* Print the information about the heap's header */ H5HF_hdr_print(hdr, FALSE, stream, indent, fwidth); done: - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_dblock_debug_cb * @@ -424,10 +372,10 @@ done: static herr_t H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ - H5HF_debug_iter_ud1_t *udata = (H5HF_debug_iter_ud1_t *)_udata; /* User data for callbacks */ - haddr_t sect_start, sect_end; /* Section's beginning and ending offsets */ - haddr_t dblock_start, dblock_end; /* Direct block's beginning and ending offsets */ + H5HF_free_section_t * sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ + H5HF_debug_iter_ud1_t *udata = (H5HF_debug_iter_ud1_t *)_udata; /* User data for callbacks */ + haddr_t sect_start, sect_end; /* Section's beginning and ending offsets */ + haddr_t dblock_start, dblock_end; /* Direct block's beginning and ending offsets */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -439,27 +387,28 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) /* Set up some local variables, for convenience */ sect_start = sect->sect_info.addr; - sect_end = (sect->sect_info.addr + sect->sect_info.size) - 1; + sect_end = (sect->sect_info.addr + sect->sect_info.size) - 1; HDassert(sect_end >= sect_start); dblock_start = udata->dblock_addr; - dblock_end = (udata->dblock_addr + udata->dblock_size) - 1; + dblock_end = (udata->dblock_addr + udata->dblock_size) - 1; HDassert(dblock_end >= dblock_start); /* Check for overlap between free space section & direct block */ - if((sect_start <= dblock_end && sect_end >=dblock_start) || /* section within or overlaps w/beginning of direct block*/ - (sect_start <= dblock_end && sect_end >=dblock_end)) { /* section overlaps w/end of direct block */ - char temp_str[32]; /* Temporary string for formatting */ - size_t start, end; /* Start & end of the overlapping area */ - size_t len; /* Length of the overlapping area */ - size_t overlap; /* Track any overlaps */ - size_t u; /* Local index variable */ + if ((sect_start <= dblock_end && + sect_end >= dblock_start) || /* section within or overlaps w/beginning of direct block*/ + (sect_start <= dblock_end && sect_end >= dblock_end)) { /* section overlaps w/end of direct block */ + char temp_str[32]; /* Temporary string for formatting */ + size_t start, end; /* Start & end of the overlapping area */ + size_t len; /* Length of the overlapping area */ + size_t overlap; /* Track any overlaps */ + size_t u; /* Local index variable */ /* Calculate the starting & ending */ - if(sect_start < dblock_start) + if (sect_start < dblock_start) start = 0; else H5_CHECKED_ASSIGN(start, size_t, (sect_start - dblock_start), hsize_t) - if(sect_end > dblock_end) + if (sect_end > dblock_end) H5_CHECKED_ASSIGN(end, size_t, udata->dblock_size, hsize_t) else H5_CHECKED_ASSIGN(end, size_t, ((sect_end - dblock_start) + 1), hsize_t) @@ -468,15 +417,14 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) len = end - start; HDsnprintf(temp_str, sizeof(temp_str), "Section #%u:", (unsigned)udata->sect_count); - HDfprintf(udata->stream, "%*s%-*s %8Zu, %8Zu\n", udata->indent + 3, "", MAX(0, udata->fwidth - 9), - temp_str, - start, len); + HDfprintf(udata->stream, "%*s%-*s %8Zu, %8Zu\n", udata->indent + 3, "", MAX(0, udata->fwidth - 9), + temp_str, start, len); udata->sect_count++; /* Mark this node's free space & check for overlaps w/other sections */ overlap = 0; - for(u = start; u < end; u++) { - if(udata->marker[u]) + for (u = start; u < end; u++) { + if (udata->marker[u]) overlap++; udata->marker[u] = 1; } /* end for */ @@ -491,7 +439,6 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_dblock_debug_cb() */ - /*------------------------------------------------------------------------- * Function: H5HF_dblock_debug * @@ -506,15 +453,15 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - haddr_t hdr_addr, size_t block_size) +H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t hdr_addr, + size_t block_size) { - H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ + H5HF_hdr_t * hdr = NULL; /* Fractal heap header info */ H5HF_direct_t *dblock = NULL; /* Fractal heap direct block info */ - size_t blk_prefix_size; /* Size of prefix for block */ - size_t amount_free; /* Amount of free space in block */ - uint8_t *marker = NULL; /* Track free space for block */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t blk_prefix_size; /* Size of prefix for block */ + size_t amount_free; /* Amount of free space in block */ + uint8_t * marker = NULL; /* Track free space for block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -530,13 +477,13 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(block_size > 0); /* Load the fractal heap header */ - if(NULL == (hdr = H5HF__hdr_protect(f, hdr_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, hdr_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* * Load the heap direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, addr, block_size, NULL, 0, H5AC__READ_ONLY_FLAG))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, addr, block_size, NULL, 0, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap direct block") /* Print opening message */ @@ -546,62 +493,58 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, * Print the values. */ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of fractal heap that owns this block:", - hdr->heap_addr); + "Address of fractal heap that owns this block:", hdr->heap_addr); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Offset of direct block in heap:", - dblock->block_off); + "Offset of direct block in heap:", dblock->block_off); blk_prefix_size = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of block header:", - blk_prefix_size); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of block header:", blk_prefix_size); /* Allocate space for the free space markers */ - if(NULL == (marker = (uint8_t *)H5MM_calloc(dblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if (NULL == (marker = (uint8_t *)H5MM_calloc(dblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the free space information for the heap */ - if(H5HF__space_start(hdr, FALSE) < 0) + if (H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* If there is a free space manager for the heap, check for sections that overlap this block */ - if(hdr->fspace) { - H5HF_debug_iter_ud1_t udata; /* User data for callbacks */ + if (hdr->fspace) { + H5HF_debug_iter_ud1_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ - udata.stream = stream; - udata.indent = indent; - udata.fwidth = fwidth; + udata.stream = stream; + udata.indent = indent; + udata.fwidth = fwidth; udata.dblock_addr = dblock->block_off; udata.dblock_size = block_size; - udata.marker = marker; - udata.sect_count = 0; + udata.marker = marker; + udata.sect_count = 0; udata.amount_free = 0; /* Print header */ HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); /* Iterate over the free space sections, to detect overlaps with this block */ - if(H5FS_sect_iterate(f, hdr->fspace, H5HF_dblock_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, hdr->fspace, H5HF_dblock_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") /* Close the free space information */ - if(H5HF__space_close(hdr) < 0) + if (H5HF__space_close(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") /* Keep the amount of space free */ amount_free = udata.amount_free; /* Check for no free space */ - if(amount_free == 0) + if (amount_free == 0) HDfprintf(stream, "%*s\n", indent + 3, ""); } /* end if */ else amount_free = 0; - HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, - "Percent of available space for data used:", - ((double)100.0f * (double)((dblock->size - blk_prefix_size) - amount_free) / (double)(dblock->size - blk_prefix_size))); + HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of available space for data used:", + ((double)100.0f * (double)((dblock->size - blk_prefix_size) - amount_free) / + (double)(dblock->size - blk_prefix_size))); /* * Print the data in a VMS-style octal dump. @@ -609,16 +552,15 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, H5_buffer_dump(stream, indent, dblock->blk, marker, (size_t)0, dblock->size); done: - if(dblock && H5AC_unprotect(f, H5AC_FHEAP_DBLOCK, addr, dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && H5AC_unprotect(f, H5AC_FHEAP_DBLOCK, addr, dblock, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap direct block") - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") H5MM_xfree(marker); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_dblock_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_iblock_print * @@ -633,12 +575,11 @@ done: *------------------------------------------------------------------------- */ void -H5HF_iblock_print(const H5HF_indirect_t *iblock, - hbool_t dump_internal, FILE *stream, int indent, int fwidth) +H5HF_iblock_print(const H5HF_indirect_t *iblock, hbool_t dump_internal, FILE *stream, int indent, int fwidth) { - const H5HF_hdr_t *hdr; /* Pointer to heap's header */ - char temp_str[64]; /* Temporary string, for formatting */ - size_t u, v; /* Local index variable */ + const H5HF_hdr_t *hdr; /* Pointer to heap's header */ + char temp_str[64]; /* Temporary string, for formatting */ + size_t u, v; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -661,96 +602,79 @@ H5HF_iblock_print(const H5HF_indirect_t *iblock, * Print the values. */ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of fractal heap that owns this block:", - hdr->heap_addr); + "Address of fractal heap that owns this block:", hdr->heap_addr); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Offset of indirect block in heap:", - iblock->block_off); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of indirect block:", - iblock->size); + "Offset of indirect block in heap:", iblock->block_off); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of indirect block:", iblock->size); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Current # of rows:", iblock->nrows); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Max. # of rows:", iblock->max_rows); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Current # of rows:", - iblock->nrows); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. # of rows:", - iblock->max_rows); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max direct block rows:", - hdr->man_dtable.max_direct_rows); + "Max direct block rows:", hdr->man_dtable.max_direct_rows); /* Print the entry tables */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) HDfprintf(stream, "%*sDirect Block Entries: (address/compressed size/filter mask)\n", indent, ""); else HDfprintf(stream, "%*sDirect Block Entries: (address)\n", indent, ""); - for(u = 0; u < hdr->man_dtable.max_direct_rows && u < iblock->nrows; u++) { - HDsnprintf(temp_str, sizeof(temp_str), "Row #%u: (block size: %lu)", (unsigned)u, (unsigned long)hdr->man_dtable.row_block_size[u]); - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str); - for(v = 0; v < hdr->man_dtable.cparam.width; v++) { + for (u = 0; u < hdr->man_dtable.max_direct_rows && u < iblock->nrows; u++) { + HDsnprintf(temp_str, sizeof(temp_str), "Row #%u: (block size: %lu)", (unsigned)u, + (unsigned long)hdr->man_dtable.row_block_size[u]); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); + for (v = 0; v < hdr->man_dtable.cparam.width; v++) { size_t off = (u * hdr->man_dtable.cparam.width) + v; HDsnprintf(temp_str, sizeof(temp_str), "Col #%u:", (unsigned)v); - if(hdr->filter_len > 0) - HDfprintf(stream, "%*s%-*s %9a/%6Zu/%x\n", indent + 6, "", MAX(0, fwidth - 6), - temp_str, - iblock->ents[off].addr, - iblock->filt_ents[off].size, - iblock->filt_ents[off].filter_mask); + if (hdr->filter_len > 0) + HDfprintf(stream, "%*s%-*s %9a/%6Zu/%x\n", indent + 6, "", MAX(0, fwidth - 6), temp_str, + iblock->ents[off].addr, iblock->filt_ents[off].size, + iblock->filt_ents[off].filter_mask); else - HDfprintf(stream, "%*s%-*s %9a\n", indent + 6, "", MAX(0, fwidth - 6), - temp_str, - iblock->ents[off].addr); + HDfprintf(stream, "%*s%-*s %9a\n", indent + 6, "", MAX(0, fwidth - 6), temp_str, + iblock->ents[off].addr); } /* end for */ - } /* end for */ + } /* end for */ HDfprintf(stream, "%*sIndirect Block Entries:\n", indent, ""); - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned first_row_bits; /* Number of bits used bit addresses in first row */ - unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned first_row_bits; /* Number of bits used bit addresses in first row */ + unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ first_row_bits = H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size) + - H5VM_log2_of2(hdr->man_dtable.cparam.width); - for(u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++) { + H5VM_log2_of2(hdr->man_dtable.cparam.width); + for (u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++) { num_indirect_rows = (H5VM_log2_gen(hdr->man_dtable.row_block_size[u]) - first_row_bits) + 1; - HDsnprintf(temp_str, sizeof(temp_str), "Row #%u: (# of rows: %u)", (unsigned)u, num_indirect_rows); - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str); - for(v = 0; v < hdr->man_dtable.cparam.width; v++) { + HDsnprintf(temp_str, sizeof(temp_str), "Row #%u: (# of rows: %u)", (unsigned)u, + num_indirect_rows); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); + for (v = 0; v < hdr->man_dtable.cparam.width; v++) { size_t off = (u * hdr->man_dtable.cparam.width) + v; HDsnprintf(temp_str, sizeof(temp_str), "Col #%u:", (unsigned)v); - HDfprintf(stream, "%*s%-*s %9a\n", indent + 6, "", MAX(0, fwidth - 6), - temp_str, - iblock->ents[off].addr); + HDfprintf(stream, "%*s%-*s %9a\n", indent + 6, "", MAX(0, fwidth - 6), temp_str, + iblock->ents[off].addr); } /* end for */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - ""); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), ""); /* Print internal (runtime) information, if requested */ - if(dump_internal) { + if (dump_internal) { HDfprintf(stream, "%*sFractal Indirect Block Internal Information:\n", indent, ""); /* Print general information */ HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Reference count:", - iblock->rc); + "Reference count:", iblock->rc); /* Print parent's information */ HDfprintf(stream, "%*s%-*s %p\n", indent + 3, "", MAX(0, fwidth - 3), - "Parent indirect block address:", - iblock->parent); - if(iblock->parent) + "Parent indirect block address:", iblock->parent); + if (iblock->parent) H5HF_iblock_print(iblock->parent, TRUE, stream, indent + 6, fwidth); } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* end H5HF_iblock_print() */ - /*------------------------------------------------------------------------- * Function: H5HF_iblock_debug * @@ -765,13 +689,13 @@ H5HF_iblock_print(const H5HF_indirect_t *iblock, *------------------------------------------------------------------------- */ herr_t -H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - haddr_t hdr_addr, unsigned nrows) +H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t hdr_addr, + unsigned nrows) { - H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ - H5HF_indirect_t *iblock = NULL; /* Fractal heap direct block info */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t * hdr = NULL; /* Fractal heap header info */ + H5HF_indirect_t *iblock = NULL; /* Fractal heap direct block info */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -787,28 +711,28 @@ H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(nrows > 0); /* Load the fractal heap header */ - if(NULL == (hdr = H5HF__hdr_protect(f, hdr_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, hdr_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* * Load the heap indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, addr, nrows, NULL, 0, FALSE, H5AC__READ_ONLY_FLAG, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, addr, nrows, NULL, 0, FALSE, H5AC__READ_ONLY_FLAG, + &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap indirect block") /* Print the information about the heap's indirect block */ H5HF_iblock_print(iblock, FALSE, stream, indent, fwidth); done: - if(iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap direct block") - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_iblock_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_sects_debug_cb * @@ -825,9 +749,9 @@ done: static herr_t H5HF_sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ - H5HF_debug_iter_ud2_t *udata = (H5HF_debug_iter_ud2_t *)_udata; /* User data for callbacks */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t * sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ + H5HF_debug_iter_ud2_t *udata = (H5HF_debug_iter_ud2_t *)_udata; /* User data for callbacks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -838,32 +762,31 @@ H5HF_sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) HDassert(udata); /* Print generic section information */ - HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, - "Section type:", - (sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE ? "single" : - (sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW ? "first row" : - (sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW ? "normal row" : "unknown")))); + HDfprintf( + udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, "Section type:", + (sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE + ? "single" + : (sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW + ? "first row" + : (sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW ? "normal row" : "unknown")))); HDfprintf(udata->stream, "%*s%-*s %a\n", udata->indent, "", udata->fwidth, - "Section address:", - sect->sect_info.addr); + "Section address:", sect->sect_info.addr); HDfprintf(udata->stream, "%*s%-*s %Hu\n", udata->indent, "", udata->fwidth, - "Section size:", - sect->sect_info.size); + "Section size:", sect->sect_info.size); #ifdef QAK HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, - "Section state:", - (sect->sect_info.state == H5FS_SECT_LIVE ? "live" : "serialized")); + "Section state:", (sect->sect_info.state == H5FS_SECT_LIVE ? "live" : "serialized")); #endif /* QAK */ /* Dump section-specific debugging information */ - if(H5FS_sect_debug(udata->fspace, _sect, udata->stream, udata->indent + 3, MAX(0, udata->fwidth - 3)) < 0) + if (H5FS_sect_debug(udata->fspace, _sect, udata->stream, udata->indent + 3, MAX(0, udata->fwidth - 3)) < + 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't dump section's debugging info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sects_debug_cb() */ - /*------------------------------------------------------------------------- * Function: H5HF_sects_debug * @@ -880,8 +803,8 @@ done: herr_t H5HF_sects_debug(H5F_t *f, haddr_t fh_addr, FILE *stream, int indent, int fwidth) { - H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -895,16 +818,16 @@ H5HF_sects_debug(H5F_t *f, haddr_t fh_addr, FILE *stream, int indent, int fwidth HDassert(fwidth >= 0); /* Load the fractal heap header */ - if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* Initialize the free space information for the heap */ - if(H5HF__space_start(hdr, FALSE) < 0) + if (H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* If there is a free space manager for the heap, iterate over them */ - if(hdr->fspace) { - H5HF_debug_iter_ud2_t udata; /* User data for callbacks */ + if (hdr->fspace) { + H5HF_debug_iter_ud2_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ udata.fspace = hdr->fspace; @@ -913,18 +836,17 @@ H5HF_sects_debug(H5F_t *f, haddr_t fh_addr, FILE *stream, int indent, int fwidth udata.fwidth = fwidth; /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, hdr->fspace, H5HF_sects_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, hdr->fspace, H5HF_sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") /* Close the free space information */ - if(H5HF__space_close(hdr) < 0) + if (H5HF__space_close(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") } /* end if */ done: - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sects_debug() */ - diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index a6560e2..3a5cf08 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -26,39 +26,34 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -66,18 +61,14 @@ /* Declare a free list to manage the H5HF_direct_t struct */ H5FL_DEFINE(H5HF_direct_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_create * @@ -92,14 +83,14 @@ H5FL_DEFINE(H5HF_direct_t); *------------------------------------------------------------------------- */ herr_t -H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, - unsigned par_entry, haddr_t *addr_p, H5HF_free_section_t **ret_sec_node) +H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned par_entry, haddr_t *addr_p, + H5HF_free_section_t **ret_sec_node) { - H5HF_free_section_t *sec_node; /* Pointer to free space section for block */ - H5HF_direct_t *dblock = NULL; /* Pointer to direct block */ - haddr_t dblock_addr; /* Direct block's address */ - size_t free_space; /* Free space in new block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sec_node; /* Pointer to free space section for block */ + H5HF_direct_t * dblock = NULL; /* Pointer to direct block */ + haddr_t dblock_addr; /* Direct block's address */ + size_t free_space; /* Free space in new block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -111,58 +102,61 @@ H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, /* * Allocate file and memory data structures. */ - if(NULL == (dblock = H5FL_MALLOC(H5HF_direct_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap direct block") + if (NULL == (dblock = H5FL_MALLOC(H5HF_direct_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap direct block") /* Reset the metadata cache info for the heap header */ HDmemset(&dblock->cache_info, 0, sizeof(H5AC_info_t)); /* Share common heap information */ dblock->hdr = hdr; - if(H5HF_hdr_incr(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") + if (H5HF_hdr_incr(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") /* Set info for direct block */ - if(par_iblock) { - unsigned par_row = par_entry / hdr->man_dtable.cparam.width; /* Row for block */ + if (par_iblock) { + unsigned par_row = par_entry / hdr->man_dtable.cparam.width; /* Row for block */ /* Compute offset & size, based on parent's information */ dblock->block_off = par_iblock->block_off; dblock->block_off += hdr->man_dtable.row_block_off[par_row]; - dblock->block_off += hdr->man_dtable.row_block_size[par_row] * (par_entry % hdr->man_dtable.cparam.width); + dblock->block_off += + hdr->man_dtable.row_block_size[par_row] * (par_entry % hdr->man_dtable.cparam.width); H5_CHECKED_ASSIGN(dblock->size, size_t, hdr->man_dtable.row_block_size[par_row], hsize_t); } /* end if */ else { /* Must be the root direct block */ dblock->block_off = 0; - dblock->size = hdr->man_dtable.cparam.start_block_size; + dblock->size = hdr->man_dtable.cparam.start_block_size; } /* end else */ dblock->file_size = 0; - free_space = dblock->size - H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); + free_space = dblock->size - H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); /* Allocate buffer for block */ -/* XXX: Change to using free-list factories */ - if((dblock->blk = H5FL_BLK_MALLOC(direct_block, dblock->size)) == NULL) + /* XXX: Change to using free-list factories */ + if ((dblock->blk = H5FL_BLK_MALLOC(direct_block, dblock->size)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDmemset(dblock->blk, 0, dblock->size); - dblock->write_buf = NULL; + dblock->write_buf = NULL; dblock->write_size = 0; /* Allocate [temporary] space for the direct block on disk */ - if(H5F_USE_TMP_SPACE(hdr->f)) { - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)dblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (H5F_USE_TMP_SPACE(hdr->f)) { + if (HADDR_UNDEF == (dblock_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)dblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") } /* end if */ else { - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)dblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)dblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") } /* end else */ /* Attach to parent indirect block, if there is one */ dblock->parent = par_iblock; - if(dblock->parent) { - if(H5HF_man_iblock_attach(dblock->parent, par_entry, dblock_addr) < 0) + if (dblock->parent) { + if (H5HF_man_iblock_attach(dblock->parent, par_entry, dblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't attach direct block to parent indirect block") dblock->fd_parent = par_iblock; } /* end if */ @@ -171,42 +165,41 @@ H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, dblock->par_entry = par_entry; /* Create a new 'single' section for the free space in the block */ - if(NULL == (sec_node = H5HF_sect_single_new((dblock->block_off + H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)), - free_space, dblock->parent, dblock->par_entry))) + if (NULL == (sec_node = H5HF_sect_single_new((dblock->block_off + H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)), + free_space, dblock->parent, dblock->par_entry))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create section for new direct block's free space") /* Check what to do with section node */ - if(ret_sec_node) + if (ret_sec_node) /* Pass back the pointer to the section instead of adding it to the free list */ *ret_sec_node = sec_node; else { /* Add new free space to the heap's list of space */ - if(H5HF__space_add(hdr, sec_node, 0) < 0) + if (H5HF__space_add(hdr, sec_node, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add direct block free space to global list") } /* end else */ /* Cache the new fractal heap direct block */ - if(H5AC_insert_entry(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap direct block to cache") + if (H5AC_insert_entry(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap direct block to cache") /* Increase the allocated heap size */ - if(H5HF_hdr_inc_alloc(hdr, dblock->size) < 0) + if (H5HF_hdr_inc_alloc(hdr, dblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't increase allocated heap size") /* Set the address of of direct block, if requested */ - if(addr_p) + if (addr_p) *addr_p = dblock_addr; done: - if(ret_value < 0) - if(dblock) - if(H5HF_man_dblock_dest(dblock) < 0) + if (ret_value < 0) + if (dblock) + if (H5HF_man_dblock_dest(dblock) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_create() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_destroy * @@ -225,12 +218,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, - haddr_t dblock_addr, hbool_t *parent_removed) +H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, haddr_t dblock_addr, hbool_t *parent_removed) { - hsize_t dblock_size; /* Size of direct block on disk */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting indirect block */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t dblock_size; /* Size of direct block on disk */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting indirect block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -241,32 +233,32 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, HDassert(dblock); /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Check for root direct block */ - if(dblock->parent == NULL) + if (dblock->parent == NULL) /* Get direct block's actual size */ dblock_size = (hsize_t)hdr->pline_root_direct_size; else { - H5HF_indirect_t *par_iblock; /* Parent indirect block */ - unsigned par_entry; /* Entry in parent indirect block */ + H5HF_indirect_t *par_iblock; /* Parent indirect block */ + unsigned par_entry; /* Entry in parent indirect block */ /* Get parent information */ par_iblock = dblock->parent; - par_entry = dblock->par_entry; + par_entry = dblock->par_entry; /* Get direct block's actual size */ dblock_size = (hsize_t)par_iblock->filt_ents[par_entry].size; } /* end else */ - } /* end if */ + } /* end if */ else dblock_size = (hsize_t)dblock->size; /* Reset the parent_removed flag */ - if(parent_removed) + if (parent_removed) *parent_removed = FALSE; /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Sanity check */ HDassert(hdr->man_dtable.table_addr == dblock_addr); HDassert(hdr->man_dtable.cparam.start_block_size == dblock->size); @@ -275,7 +267,7 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, HDassert(!H5HF_man_iter_ready(&hdr->next_block)); /* Reset header information back to "empty heap" state */ - if(H5HF__hdr_empty(hdr) < 0) + if (H5HF__hdr_empty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't make heap empty") } /* end if */ else { @@ -283,30 +275,30 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, hdr->man_alloc_size -= dblock->size; /* Check for this direct block being the highest in the heap */ - if((dblock->block_off + dblock->size) == hdr->man_iter_off) + if ((dblock->block_off + dblock->size) == hdr->man_iter_off) /* Move 'next block' iterator backwards (may shrink heap) */ - if(H5HF__hdr_reverse_iter(hdr, dblock_addr) < 0) + if (H5HF__hdr_reverse_iter(hdr, dblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reverse 'next block' iterator") /* Detach from parent indirect block */ - if(dblock->parent) { + if (dblock->parent) { /* Destroy flush dependency between direct block and parent */ - if(H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) + if (H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") dblock->fd_parent = NULL; /* If this is the last direct block for the indirect block, the * indirect block will be removed when this direct block is detached */ - if(parent_removed && 1 == dblock->parent->nchildren) + if (parent_removed && 1 == dblock->parent->nchildren) *parent_removed = TRUE; - if(H5HF__man_iblock_detach(dblock->parent, dblock->par_entry) < 0) + if (H5HF__man_iblock_detach(dblock->parent, dblock->par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't detach from parent indirect block"); - dblock->parent = NULL; + dblock->parent = NULL; dblock->par_entry = 0; } /* end if */ - } /* end else */ + } /* end else */ /* Indicate that the direct block should be deleted */ dblock->file_size = dblock_size; @@ -318,13 +310,12 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, done: /* Unprotect the indirect block, with appropriate flags */ - if(H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, cache_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_destroy() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_new * @@ -340,12 +331,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__man_dblock_new(H5HF_hdr_t *hdr, size_t request, - H5HF_free_section_t **ret_sec_node) +H5HF__man_dblock_new(H5HF_hdr_t *hdr, size_t request, H5HF_free_section_t **ret_sec_node) { - haddr_t dblock_addr; /* Address of new direct block */ - size_t min_dblock_size; /* Min. size of direct block to allocate */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t dblock_addr; /* Address of new direct block */ + size_t min_dblock_size; /* Min. size of direct block to allocate */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -356,7 +346,7 @@ H5HF__man_dblock_new(H5HF_hdr_t *hdr, size_t request, HDassert(request > 0); /* Compute the min. size of the direct block needed to fulfill the request */ - if(request < hdr->man_dtable.cparam.start_block_size) + if (request < hdr->man_dtable.cparam.start_block_size) min_dblock_size = hdr->man_dtable.cparam.start_block_size; else { min_dblock_size = ((size_t)1) << (1 + H5VM_log2_gen((uint64_t)request)); @@ -364,57 +354,62 @@ H5HF__man_dblock_new(H5HF_hdr_t *hdr, size_t request, } /* end else */ /* Adjust the size of block needed to fulfill request, with overhead */ - if(min_dblock_size < H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) + request) + if (min_dblock_size < H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) + request) min_dblock_size *= 2; /* Check if this is the first block in the heap */ - if(!H5F_addr_defined(hdr->man_dtable.table_addr) && - min_dblock_size == hdr->man_dtable.cparam.start_block_size) { + if (!H5F_addr_defined(hdr->man_dtable.table_addr) && + min_dblock_size == hdr->man_dtable.cparam.start_block_size) { /* Create new direct block at starting offset */ - if(H5HF__man_dblock_create(hdr, NULL, 0, &dblock_addr, ret_sec_node) < 0) + if (H5HF__man_dblock_create(hdr, NULL, 0, &dblock_addr, ret_sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap direct block") /* Point root at new direct block */ hdr->man_dtable.curr_root_rows = 0; - hdr->man_dtable.table_addr = dblock_addr; - if(hdr->filter_len > 0) { - hdr->pline_root_direct_size = hdr->man_dtable.cparam.start_block_size; + hdr->man_dtable.table_addr = dblock_addr; + if (hdr->filter_len > 0) { + hdr->pline_root_direct_size = hdr->man_dtable.cparam.start_block_size; hdr->pline_root_direct_filter_mask = 0; } /* end if */ /* Extend heap to cover new direct block */ - if(H5HF_hdr_adjust_heap(hdr, (hsize_t)hdr->man_dtable.cparam.start_block_size, (hssize_t)hdr->man_dtable.row_tot_dblock_free[0]) < 0) + if (H5HF_hdr_adjust_heap(hdr, (hsize_t)hdr->man_dtable.cparam.start_block_size, + (hssize_t)hdr->man_dtable.row_tot_dblock_free[0]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "can't increase space to cover root direct block") } /* end if */ /* Root entry already exists, allocate direct block from root indirect block */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block to create */ - unsigned next_row; /* Iterator's next block row */ - unsigned next_entry; /* Iterator's next block entry */ - size_t next_size; /* Size of next direct block to create */ + H5HF_indirect_t *iblock; /* Pointer to indirect block to create */ + unsigned next_row; /* Iterator's next block row */ + unsigned next_entry; /* Iterator's next block entry */ + size_t next_size; /* Size of next direct block to create */ - /* Update iterator to reflect any previous increments as well as allow for requested direct block size */ - if(H5HF__hdr_update_iter(hdr, min_dblock_size) < 0) + /* Update iterator to reflect any previous increments as well as allow for requested direct block size + */ + if (H5HF__hdr_update_iter(hdr, min_dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUPDATE, FAIL, "unable to update block iterator") /* Retrieve information about current iterator position */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + if (H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") HDassert(next_row < iblock->nrows); H5_CHECKED_ASSIGN(next_size, size_t, hdr->man_dtable.row_block_size[next_row], hsize_t); /* Check for skipping over blocks */ - if(min_dblock_size > next_size) { -HDfprintf(stderr, "%s: Skipping direct block sizes not supported, min_dblock_size = %Zu, next_size = %Zu\n", FUNC, min_dblock_size, next_size); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "skipping direct block sizes not supported yet") + if (min_dblock_size > next_size) { + HDfprintf( + stderr, + "%s: Skipping direct block sizes not supported, min_dblock_size = %Zu, next_size = %Zu\n", + FUNC, min_dblock_size, next_size); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "skipping direct block sizes not supported yet") } /* end if */ /* Advance "next block" iterator to next direct block entry */ - if(H5HF_hdr_inc_iter(hdr, (hsize_t)next_size, 1) < 0) + if (H5HF_hdr_inc_iter(hdr, (hsize_t)next_size, 1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment 'next block' iterator") /* Create new direct block at current location*/ - if(H5HF__man_dblock_create(hdr, iblock, next_entry, &dblock_addr, ret_sec_node) < 0) + if (H5HF__man_dblock_create(hdr, iblock, next_entry, &dblock_addr, ret_sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap direct block") } /* end else */ @@ -422,7 +417,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_new() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_protect * @@ -438,13 +432,12 @@ done: *------------------------------------------------------------------------- */ H5HF_direct_t * -H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, - size_t dblock_size, H5HF_indirect_t *par_iblock, unsigned par_entry, - unsigned flags) +H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, size_t dblock_size, + H5HF_indirect_t *par_iblock, unsigned par_entry, unsigned flags) { - H5HF_direct_t *dblock; /* Direct block from cache */ - H5HF_dblock_cache_ud_t udata; /* parent and other infor for deserializing direct block */ - H5HF_direct_t *ret_value = NULL; /* Return value */ + H5HF_direct_t * dblock; /* Direct block from cache */ + H5HF_dblock_cache_ud_t udata; /* parent and other infor for deserializing direct block */ + H5HF_direct_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -459,9 +452,9 @@ H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up parent info */ - udata.par_info.hdr = hdr; + udata.par_info.hdr = hdr; udata.par_info.iblock = par_iblock; - udata.par_info.entry = par_entry; + udata.par_info.entry = par_entry; /* set up the file pointer in the user data */ udata.f = hdr->f; @@ -472,31 +465,32 @@ H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, /* compute the on disk image size -- observe that odi_size and * dblock_size will be identical if there is no filtering. */ - if(hdr->filter_len > 0) { - if(par_iblock == NULL) { - udata.odi_size = hdr->pline_root_direct_size; - udata.filter_mask = hdr->pline_root_direct_filter_mask; - } /* end if */ + if (hdr->filter_len > 0) { + if (par_iblock == NULL) { + udata.odi_size = hdr->pline_root_direct_size; + udata.filter_mask = hdr->pline_root_direct_filter_mask; + } /* end if */ else { - /* Sanity check */ - HDassert(H5F_addr_eq(par_iblock->ents[par_entry].addr, dblock_addr)); + /* Sanity check */ + HDassert(H5F_addr_eq(par_iblock->ents[par_entry].addr, dblock_addr)); - /* Set up parameters to read filtered direct block */ - udata.odi_size = par_iblock->filt_ents[par_entry].size; + /* Set up parameters to read filtered direct block */ + udata.odi_size = par_iblock->filt_ents[par_entry].size; udata.filter_mask = par_iblock->filt_ents[par_entry].filter_mask; - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { - udata.odi_size = dblock_size; + udata.odi_size = dblock_size; udata.filter_mask = 0; } /* end else */ /* Reset compression context info */ udata.decompressed = FALSE; - udata.dblk = NULL; + udata.dblk = NULL; /* Protect the direct block */ - if(NULL == (dblock = (H5HF_direct_t *)H5AC_protect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, &udata, flags))) + if (NULL == + (dblock = (H5HF_direct_t *)H5AC_protect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, &udata, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap direct block") /* Set the return value */ @@ -506,7 +500,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_locate * @@ -521,16 +514,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, - H5HF_indirect_t **ret_iblock, unsigned *ret_entry, hbool_t *ret_did_protect, - unsigned flags) +H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, H5HF_indirect_t **ret_iblock, unsigned *ret_entry, + hbool_t *ret_did_protect, unsigned flags) { - haddr_t iblock_addr; /* Indirect block's address */ - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - unsigned row, col; /* Row & column for object's block */ - unsigned entry; /* Entry of block */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t iblock_addr; /* Indirect block's address */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + unsigned row, col; /* Row & column for object's block */ + unsigned entry; /* Entry of block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -538,7 +530,7 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, * Check arguments. */ HDassert(hdr); - HDassert(hdr->man_dtable.curr_root_rows); /* Only works for heaps with indirect root block */ + HDassert(hdr->man_dtable.curr_root_rows); /* Only works for heaps with indirect root block */ HDassert(ret_iblock); HDassert(ret_did_protect); @@ -546,26 +538,27 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Look up row & column for object */ - if(H5HF_dtable_lookup(&hdr->man_dtable, obj_off, &row, &col) < 0) + if (H5HF_dtable_lookup(&hdr->man_dtable, obj_off, &row, &col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of object") /* Set initial indirect block info */ iblock_addr = hdr->man_dtable.table_addr; /* Lock root indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, hdr->man_dtable.curr_root_rows, NULL, 0, FALSE, flags, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, hdr->man_dtable.curr_root_rows, NULL, 0, + FALSE, flags, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Check for indirect block row */ - while(row >= hdr->man_dtable.max_direct_rows) { - H5HF_indirect_t *new_iblock; /* Pointer to new indirect block */ - hbool_t new_did_protect; /* Whether we protected the indirect block or not */ - unsigned nrows; /* Number of rows in new indirect block */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting parent indirect block */ + while (row >= hdr->man_dtable.max_direct_rows) { + H5HF_indirect_t *new_iblock; /* Pointer to new indirect block */ + hbool_t new_did_protect; /* Whether we protected the indirect block or not */ + unsigned nrows; /* Number of rows in new indirect block */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting parent indirect block */ /* Compute # of rows in child indirect block */ nrows = (H5VM_log2_gen(hdr->man_dtable.row_block_size[row]) - hdr->man_dtable.first_row_bits) + 1; - HDassert(nrows < iblock->nrows); /* child must be smaller than parent */ + HDassert(nrows < iblock->nrows); /* child must be smaller than parent */ /* Compute indirect block's entry */ entry = (row * hdr->man_dtable.cparam.width) + col; @@ -574,8 +567,8 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, iblock_addr = iblock->ents[entry].addr; /* Check if we need to (re-)create the child indirect block */ - if(!H5F_addr_defined(iblock_addr)) { - if(H5HF__man_iblock_create(hdr, iblock, entry, nrows, nrows, &iblock_addr) < 0) + if (!H5F_addr_defined(iblock_addr)) { + if (H5HF__man_iblock_create(hdr, iblock, entry, nrows, nrows, &iblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap indirect block") /* Indicate that the parent indirect block was modified */ @@ -583,34 +576,34 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, } /* end if */ /* Lock child indirect block */ - if(NULL == (new_iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, iblock, entry, FALSE, flags, &new_did_protect))) + if (NULL == (new_iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, iblock, entry, FALSE, + flags, &new_did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Release the current indirect block */ - if(H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) + if (H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") /* Switch variables to use new indirect block */ - iblock = new_iblock; + iblock = new_iblock; did_protect = new_did_protect; /* Look up row & column in new indirect block for object */ - if(H5HF_dtable_lookup(&hdr->man_dtable, (obj_off - iblock->block_off), &row, &col) < 0) + if (H5HF_dtable_lookup(&hdr->man_dtable, (obj_off - iblock->block_off), &row, &col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of object") - HDassert(row < iblock->nrows); /* child must be smaller than parent */ - } /* end while */ + HDassert(row < iblock->nrows); /* child must be smaller than parent */ + } /* end while */ /* Set return parameters */ - if(ret_entry) + if (ret_entry) *ret_entry = (row * hdr->man_dtable.cparam.width) + col; - *ret_iblock = iblock; + *ret_iblock = iblock; *ret_did_protect = did_protect; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_locate() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_delete * @@ -632,8 +625,8 @@ done: herr_t H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size) { - unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -645,23 +638,23 @@ H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size) HDassert(dblock_size > 0); /* Check the direct block's status in the metadata cache */ - if(H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) + if (H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for direct block") /* If the direct block is in the cache, expunge it now */ - if(dblock_status & H5AC_ES__IN_CACHE) { + if (dblock_status & H5AC_ES__IN_CACHE) { /* Sanity checks on direct block */ HDassert(!(dblock_status & H5AC_ES__IS_PINNED)); HDassert(!(dblock_status & H5AC_ES__IS_PROTECTED)); /* Evict the direct block from the metadata cache */ - if(H5AC_expunge_entry(f, H5AC_FHEAP_DBLOCK, dblock_addr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(f, H5AC_FHEAP_DBLOCK, dblock_addr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "unable to remove direct block from cache") } /* end if */ /* Check if the direct block is NOT currently allocated in temp. file space */ /* (temp. file space does not need to be freed) */ - if(!H5F_IS_TMP_ADDR(f, dblock_addr)) + if (!H5F_IS_TMP_ADDR(f, dblock_addr)) /* Release direct block's disk space */ /* (XXX: Under the best of circumstances, this block's space in the file * would be freed in the H5AC_expunge_entry() call above (and the @@ -673,14 +666,13 @@ H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size) * that would add a bunch of unnecessary overhead to the process, * so we just release the file space here, directly. -QAK) */ - if(H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, dblock_addr, dblock_size) < 0) + if (H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, dblock_addr, dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap direct block file space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_dblock_dest * @@ -697,7 +689,7 @@ done: herr_t H5HF_man_dblock_dest(H5HF_direct_t *dblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -708,11 +700,12 @@ H5HF_man_dblock_dest(H5HF_direct_t *dblock) /* Decrement reference count on shared fractal heap info */ HDassert(dblock->hdr != NULL); - if(H5HF_hdr_decr(dblock->hdr) < 0) + if (H5HF_hdr_decr(dblock->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") - if(dblock->parent) - if(H5HF__iblock_decr(dblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + if (dblock->parent) + if (H5HF__iblock_decr(dblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared indirect block") /* Free block's buffer */ dblock->blk = H5FL_BLK_FREE(direct_block, dblock->blk); @@ -723,4 +716,3 @@ H5HF_man_dblock_dest(H5HF_direct_t *dblock) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_dblock_dest() */ - diff --git a/src/H5HFdtable.c b/src/H5HFdtable.c index 6e9429a..217c174 100644 --- a/src/H5HFdtable.c +++ b/src/H5HFdtable.c @@ -26,54 +26,45 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF_dtable_init * @@ -90,10 +81,10 @@ herr_t H5HF_dtable_init(H5HF_dtable_t *dtable) { - hsize_t tmp_block_size; /* Temporary block size */ - hsize_t acc_block_off; /* Accumulated block offset */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t tmp_block_size; /* Temporary block size */ + hsize_t acc_block_off; /* Accumulated block offset */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -103,30 +94,33 @@ H5HF_dtable_init(H5HF_dtable_t *dtable) HDassert(dtable); /* Compute/cache some values */ - dtable->start_bits = H5VM_log2_of2((uint32_t)dtable->cparam.start_block_size); - dtable->first_row_bits = dtable->start_bits + H5VM_log2_of2(dtable->cparam.width); - dtable->max_root_rows = (dtable->cparam.max_index - dtable->first_row_bits) + 1; - dtable->max_direct_bits = H5VM_log2_of2((uint32_t)dtable->cparam.max_direct_size); - dtable->max_direct_rows = (dtable->max_direct_bits - dtable->start_bits) + 2; - dtable->num_id_first_row = dtable->cparam.start_block_size * dtable->cparam.width; + dtable->start_bits = H5VM_log2_of2((uint32_t)dtable->cparam.start_block_size); + dtable->first_row_bits = dtable->start_bits + H5VM_log2_of2(dtable->cparam.width); + dtable->max_root_rows = (dtable->cparam.max_index - dtable->first_row_bits) + 1; + dtable->max_direct_bits = H5VM_log2_of2((uint32_t)dtable->cparam.max_direct_size); + dtable->max_direct_rows = (dtable->max_direct_bits - dtable->start_bits) + 2; + dtable->num_id_first_row = dtable->cparam.start_block_size * dtable->cparam.width; dtable->max_dir_blk_off_size = H5HF_SIZEOF_OFFSET_LEN(dtable->cparam.max_direct_size); /* Build table of block sizes for each row */ - if(NULL == (dtable->row_block_size = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table block size table") - if(NULL == (dtable->row_block_off = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table block offset table") - if(NULL == (dtable->row_tot_dblock_free = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table total direct block free space table") - if(NULL == (dtable->row_max_dblock_free = (size_t *)H5MM_malloc(dtable->max_root_rows * sizeof(size_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table max. direct block free space table") - tmp_block_size = dtable->cparam.start_block_size; - acc_block_off = dtable->cparam.start_block_size * dtable->cparam.width; + if (NULL == (dtable->row_block_size = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table block size table") + if (NULL == (dtable->row_block_off = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table block offset table") + if (NULL == + (dtable->row_tot_dblock_free = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "can't create doubling table total direct block free space table") + if (NULL == (dtable->row_max_dblock_free = (size_t *)H5MM_malloc(dtable->max_root_rows * sizeof(size_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "can't create doubling table max. direct block free space table") + tmp_block_size = dtable->cparam.start_block_size; + acc_block_off = dtable->cparam.start_block_size * dtable->cparam.width; dtable->row_block_size[0] = dtable->cparam.start_block_size; - dtable->row_block_off[0] = 0; - for(u = 1; u < dtable->max_root_rows; u++) { + dtable->row_block_off[0] = 0; + for (u = 1; u < dtable->max_root_rows; u++) { dtable->row_block_size[u] = tmp_block_size; - dtable->row_block_off[u] = acc_block_off; + dtable->row_block_off[u] = acc_block_off; tmp_block_size *= 2; acc_block_off *= 2; } /* end for */ @@ -135,7 +129,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_dtable_init() */ - /*------------------------------------------------------------------------- * Function: H5HF_dtable_lookup * @@ -161,20 +154,20 @@ H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, unsigned *row, unsi HDassert(row); HDassert(col); #ifdef QAK -HDfprintf(stderr, "%s: off = %Hu\n", "H5HF_dtable_lookup", off); + HDfprintf(stderr, "%s: off = %Hu\n", "H5HF_dtable_lookup", off); #endif /* QAK */ /* Check for offset in first row */ - if(off < dtable->num_id_first_row) { + if (off < dtable->num_id_first_row) { *row = 0; H5_CHECKED_ASSIGN(*col, unsigned, (off / dtable->cparam.start_block_size), hsize_t); } /* end if */ else { - unsigned high_bit = H5VM_log2_gen(off); /* Determine the high bit in the offset */ - hsize_t off_mask = ((hsize_t)1) << high_bit; /* Compute mask for determining column */ + unsigned high_bit = H5VM_log2_gen(off); /* Determine the high bit in the offset */ + hsize_t off_mask = ((hsize_t)1) << high_bit; /* Compute mask for determining column */ #ifdef QAK -HDfprintf(stderr, "%s: high_bit = %u, off_mask = %Hu\n", "H5HF_dtable_lookup", high_bit, off_mask); + HDfprintf(stderr, "%s: high_bit = %u, off_mask = %Hu\n", "H5HF_dtable_lookup", high_bit, off_mask); #endif /* QAK */ *row = (high_bit - dtable->first_row_bits) + 1; H5_CHECKED_ASSIGN(*col, unsigned, ((off - off_mask) / dtable->row_block_size[*row]), hsize_t); @@ -183,7 +176,6 @@ HDfprintf(stderr, "%s: high_bit = %u, off_mask = %Hu\n", "H5HF_dtable_lookup", h FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_dtable_lookup() */ - /*------------------------------------------------------------------------- * Function: H5HF_dtable_dest * @@ -222,7 +214,6 @@ H5HF_dtable_dest(H5HF_dtable_t *dtable) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_dtable_dest() */ - /*------------------------------------------------------------------------- * Function: H5HF_dtable_size_to_row * @@ -239,7 +230,7 @@ H5HF_dtable_dest(H5HF_dtable_t *dtable) unsigned H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size) { - unsigned row = 0; /* Row where block will fit */ + unsigned row = 0; /* Row where block will fit */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -248,15 +239,16 @@ H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size) */ HDassert(dtable); - if(block_size == dtable->cparam.start_block_size) + if (block_size == dtable->cparam.start_block_size) row = 0; else - row = (H5VM_log2_of2((uint32_t)block_size) - H5VM_log2_of2((uint32_t)dtable->cparam.start_block_size)) + 1; + row = + (H5VM_log2_of2((uint32_t)block_size) - H5VM_log2_of2((uint32_t)dtable->cparam.start_block_size)) + + 1; FUNC_LEAVE_NOAPI(row) } /* end H5HF_dtable_size_to_row() */ - /*------------------------------------------------------------------------- * Function: H5HF_dtable_size_to_rows * @@ -273,7 +265,7 @@ H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size) unsigned H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size) { - unsigned rows = 0; /* # of rows required for indirect block */ + unsigned rows = 0; /* # of rows required for indirect block */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -287,7 +279,6 @@ H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size) FUNC_LEAVE_NOAPI(rows) } /* end H5HF_dtable_size_to_rows() */ - /*------------------------------------------------------------------------- * Function: H5HF_dtable_span_size * @@ -302,14 +293,14 @@ H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size) *------------------------------------------------------------------------- */ hsize_t -H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, - unsigned start_col, unsigned num_entries) +H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, unsigned start_col, + unsigned num_entries) { unsigned start_entry; /* Entry for first block covered */ unsigned end_row; /* Row for last block covered */ unsigned end_col; /* Column for last block covered */ unsigned end_entry; /* Entry for last block covered */ - hsize_t acc_span_size = 0; /* Accumulated span size */ + hsize_t acc_span_size = 0; /* Accumulated span size */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -324,11 +315,13 @@ H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, /* Compute ending entry, column & row */ end_entry = (start_entry + num_entries) - 1; - end_row = end_entry / dtable->cparam.width; - end_col = end_entry % dtable->cparam.width; + end_row = end_entry / dtable->cparam.width; + end_col = end_entry % dtable->cparam.width; #ifdef QAK -HDfprintf(stderr, "%s: start_row = %u, start_col = %u, start_entry = %u\n", "H5HF_sect_indirect_span_size", start_row, start_col, start_entry); -HDfprintf(stderr, "%s: end_row = %u, end_col = %u, end_entry = %u\n", "H5HF_sect_indirect_span_size", end_row, end_col, end_entry); + HDfprintf(stderr, "%s: start_row = %u, start_col = %u, start_entry = %u\n", + "H5HF_sect_indirect_span_size", start_row, start_col, start_entry); + HDfprintf(stderr, "%s: end_row = %u, end_col = %u, end_entry = %u\n", "H5HF_sect_indirect_span_size", + end_row, end_col, end_entry); #endif /* QAK */ /* Initialize accumulated span size */ @@ -337,34 +330,29 @@ HDfprintf(stderr, "%s: end_row = %u, end_col = %u, end_entry = %u\n", "H5HF_sect /* Compute span size covered */ /* Check for multi-row span */ - if(start_row != end_row) { + if (start_row != end_row) { /* Accommodate partial starting row */ - if(start_col > 0) { - acc_span_size = dtable->row_block_size[start_row] * - (dtable->cparam.width - start_col); + if (start_col > 0) { + acc_span_size = dtable->row_block_size[start_row] * (dtable->cparam.width - start_col); start_row++; } /* end if */ /* Accumulate full rows */ - while(start_row < end_row) { - acc_span_size += dtable->row_block_size[start_row] * - dtable->cparam.width; + while (start_row < end_row) { + acc_span_size += dtable->row_block_size[start_row] * dtable->cparam.width; start_row++; } /* end while */ /* Accommodate partial ending row */ - acc_span_size += dtable->row_block_size[start_row] * - (end_col + 1); + acc_span_size += dtable->row_block_size[start_row] * (end_col + 1); } /* end if */ else { /* Span is in same row */ - acc_span_size = dtable->row_block_size[start_row] * - ((end_col - start_col) + 1); + acc_span_size = dtable->row_block_size[start_row] * ((end_col - start_col) + 1); } /* end else */ #ifdef QAK -HDfprintf(stderr, "%s: acc_span_size = %Hu\n", "H5HF_dtable_span_size", acc_span_size); + HDfprintf(stderr, "%s: acc_span_size = %Hu\n", "H5HF_dtable_span_size", acc_span_size); #endif /* QAK */ FUNC_LEAVE_NOAPI(acc_span_size) } /* end H5HF_sect_indirect_span_size() */ - diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 5750a03..7a17012 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -26,18 +26,17 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ @@ -58,22 +57,18 @@ #define H5HF_WIDTH_LIMIT (64 * 1024) #endif /* NDEBUG */ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -81,18 +76,14 @@ /* Declare a free list to manage the H5HF_hdr_t struct */ H5FL_DEFINE_STATIC(H5HF_hdr_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF_hdr_alloc * @@ -109,8 +100,8 @@ H5FL_DEFINE_STATIC(H5HF_hdr_t); H5HF_hdr_t * H5HF_hdr_alloc(H5F_t *f) { - H5HF_hdr_t *hdr = NULL; /* Shared fractal heap header */ - H5HF_hdr_t *ret_value = NULL; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* Shared fractal heap header */ + H5HF_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -120,11 +111,11 @@ H5HF_hdr_alloc(H5F_t *f) HDassert(f); /* Allocate space for the shared information */ - if(NULL == (hdr = H5FL_CALLOC(H5HF_hdr_t))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "allocation failed for fractal heap shared header") + if (NULL == (hdr = H5FL_CALLOC(H5HF_hdr_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "allocation failed for fractal heap shared header") /* Set the internal parameters for the heap */ - hdr->f = f; + hdr->f = f; hdr->sizeof_size = H5F_SIZEOF_SIZE(f); hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); @@ -135,7 +126,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_alloc() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_free_space * @@ -153,12 +143,12 @@ done: static herr_t H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) { - hsize_t acc_heap_size; /* Accumumated heap space */ - hsize_t iblock_size; /* Size of indirect block to calculate for */ - hsize_t acc_dblock_free; /* Accumumated direct block free space */ - size_t max_dblock_free; /* Max. direct block free space */ - unsigned curr_row; /* Current row in block */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t acc_heap_size; /* Accumumated heap space */ + hsize_t iblock_size; /* Size of indirect block to calculate for */ + hsize_t acc_dblock_free; /* Accumumated direct block free space */ + size_t max_dblock_free; /* Max. direct block free space */ + unsigned curr_row; /* Current row in block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -169,17 +159,15 @@ H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) HDassert(iblock_row >= hdr->man_dtable.max_direct_rows); /* Set the free space in direct blocks */ - acc_heap_size = 0; + acc_heap_size = 0; acc_dblock_free = 0; max_dblock_free = 0; - iblock_size = hdr->man_dtable.row_block_size[iblock_row]; - curr_row = 0; - while(acc_heap_size < iblock_size) { - acc_heap_size += hdr->man_dtable.row_block_size[curr_row] * - hdr->man_dtable.cparam.width; - acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[curr_row] * - hdr->man_dtable.cparam.width; - if(hdr->man_dtable.row_max_dblock_free[curr_row] > max_dblock_free) + iblock_size = hdr->man_dtable.row_block_size[iblock_row]; + curr_row = 0; + while (acc_heap_size < iblock_size) { + acc_heap_size += hdr->man_dtable.row_block_size[curr_row] * hdr->man_dtable.cparam.width; + acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[curr_row] * hdr->man_dtable.cparam.width; + if (hdr->man_dtable.row_max_dblock_free[curr_row] > max_dblock_free) max_dblock_free = hdr->man_dtable.row_max_dblock_free[curr_row]; curr_row++; } /* end while */ @@ -191,7 +179,6 @@ H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_compute_free_space() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_finish_init_phase1 * @@ -208,7 +195,7 @@ H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) herr_t H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -219,18 +206,17 @@ H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr) /* Compute/cache some values */ hdr->heap_off_size = (uint8_t)H5HF_SIZEOF_OFFSET_BITS(hdr->man_dtable.cparam.max_index); - if(H5HF_dtable_init(&hdr->man_dtable) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize doubling table info") + if (H5HF_dtable_init(&hdr->man_dtable) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize doubling table info") /* Set the size of heap IDs */ - hdr->heap_len_size = (uint8_t)MIN(hdr->man_dtable.max_dir_blk_off_size, - H5VM_limit_enc_size((uint64_t)hdr->max_man_size)); + hdr->heap_len_size = + (uint8_t)MIN(hdr->man_dtable.max_dir_blk_off_size, H5VM_limit_enc_size((uint64_t)hdr->max_man_size)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_finish_init_phase1() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_finish_init_phase2 * @@ -247,8 +233,8 @@ done: herr_t H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -258,34 +244,34 @@ H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr) HDassert(hdr); /* Set the free space in direct blocks */ - for(u = 0; u < hdr->man_dtable.max_root_rows; u++) { - if(u < hdr->man_dtable.max_direct_rows) { - hdr->man_dtable.row_tot_dblock_free[u] = hdr->man_dtable.row_block_size[u] - - H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - H5_CHECKED_ASSIGN(hdr->man_dtable.row_max_dblock_free[u], size_t, hdr->man_dtable.row_tot_dblock_free[u], hsize_t); + for (u = 0; u < hdr->man_dtable.max_root_rows; u++) { + if (u < hdr->man_dtable.max_direct_rows) { + hdr->man_dtable.row_tot_dblock_free[u] = + hdr->man_dtable.row_block_size[u] - H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); + H5_CHECKED_ASSIGN(hdr->man_dtable.row_max_dblock_free[u], size_t, + hdr->man_dtable.row_tot_dblock_free[u], hsize_t); } /* end if */ - else - if(H5HF_hdr_compute_free_space(hdr, u) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize direct block free space for indirect block") + else if (H5HF_hdr_compute_free_space(hdr, u) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't initialize direct block free space for indirect block") } /* end for */ /* Initialize the block iterator for searching for free space */ - if(H5HF_man_iter_init(&hdr->next_block) < 0) + if (H5HF_man_iter_init(&hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize space search block iterator") /* Initialize the information for tracking 'huge' objects */ - if(H5HF_huge_init(hdr) < 0) + if (H5HF_huge_init(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize info for tracking huge objects") /* Initialize the information for tracking 'tiny' objects */ - if(H5HF_tiny_init(hdr) < 0) + if (H5HF_tiny_init(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize info for tracking tiny objects") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_finish_init_phase2() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_finish_init * @@ -302,7 +288,7 @@ done: herr_t H5HF_hdr_finish_init(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -312,18 +298,17 @@ H5HF_hdr_finish_init(H5HF_hdr_t *hdr) HDassert(hdr); /* First phase of header final initialization */ - if(H5HF_hdr_finish_init_phase1(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #1 of header final initialization") + if (H5HF_hdr_finish_init_phase1(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #1 of header final initialization") /* Second phase of header final initialization */ - if(H5HF_hdr_finish_init_phase2(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #2 of header final initialization") + if (H5HF_hdr_finish_init_phase2(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #2 of header final initialization") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_finish_init() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_create * @@ -340,9 +325,9 @@ done: haddr_t H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) { - H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */ - size_t dblock_overhead; /* Direct block's overhead */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */ + size_t dblock_overhead; /* Direct block's overhead */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -354,39 +339,40 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) #ifndef NDEBUG /* Check for valid parameters */ - if(cparam->managed.width == 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width must be greater than zero") - if(cparam->managed.width > H5HF_WIDTH_LIMIT) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width too large") - if(!POWER_OF_TWO(cparam->managed.width)) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width not power of two") - if(cparam->managed.start_block_size == 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "starting block size must be greater than zero") - if(!POWER_OF_TWO(cparam->managed.start_block_size)) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "starting block size not power of two") - if(cparam->managed.max_direct_size == 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size must be greater than zero") - if(cparam->managed.max_direct_size > H5HF_MAX_DIRECT_SIZE_LIMIT) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size too large") - if(!POWER_OF_TWO(cparam->managed.max_direct_size)) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not power of two") - if(cparam->managed.max_direct_size < cparam->max_man_size) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not large enough to hold all managed blocks") - if(cparam->managed.max_index == 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size must be greater than zero") + if (cparam->managed.width == 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width must be greater than zero") + if (cparam->managed.width > H5HF_WIDTH_LIMIT) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width too large") + if (!POWER_OF_TWO(cparam->managed.width)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width not power of two") + if (cparam->managed.start_block_size == 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "starting block size must be greater than zero") + if (!POWER_OF_TWO(cparam->managed.start_block_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "starting block size not power of two") + if (cparam->managed.max_direct_size == 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size must be greater than zero") + if (cparam->managed.max_direct_size > H5HF_MAX_DIRECT_SIZE_LIMIT) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size too large") + if (!POWER_OF_TWO(cparam->managed.max_direct_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not power of two") + if (cparam->managed.max_direct_size < cparam->max_man_size) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, + "max. direct block size not large enough to hold all managed blocks") + if (cparam->managed.max_index == 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size must be greater than zero") #endif /* NDEBUG */ /* Allocate & basic initialization for the shared header */ - if(NULL == (hdr = H5HF_hdr_alloc(f))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "can't allocate space for shared heap info") + if (NULL == (hdr = H5HF_hdr_alloc(f))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "can't allocate space for shared heap info") #ifndef NDEBUG - if(cparam->managed.max_index > (unsigned)(8 * hdr->sizeof_size)) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size too large for file") + if (cparam->managed.max_index > (unsigned)(8 * hdr->sizeof_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size too large for file") #endif /* NDEBUG */ /* Set the creation parameters for the heap */ - hdr->max_man_size = cparam->max_man_size; + hdr->max_man_size = cparam->max_man_size; hdr->checksum_dblocks = cparam->checksum_dblocks; H5MM_memcpy(&(hdr->man_dtable.cparam), &(cparam->managed), sizeof(H5HF_dtable_cparam_t)); @@ -401,44 +387,45 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) /* First phase of header final initialization */ /* (doesn't need ID length set up) */ - if(H5HF_hdr_finish_init_phase1(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "can't finish phase #1 of header final initialization") + if (H5HF_hdr_finish_init_phase1(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, + "can't finish phase #1 of header final initialization") /* Copy any I/O filter pipeline */ /* (This code is not in the "finish init phase" routines because those * routines are also called from the cache 'load' callback, and the filter * length is already set in that case (its stored in the header on disk)) */ - if(cparam->pline.nused > 0) { + if (cparam->pline.nused > 0) { /* Check if the filters in the DCPL can be applied to this dataset */ - if(H5Z_can_apply_direct(&(cparam->pline)) < 0) + if (H5Z_can_apply_direct(&(cparam->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "I/O filters can't operate on this heap") /* Mark the filters as checked */ hdr->checked_filters = TRUE; /* Make the "set local" filter callbacks for this dataset */ - if(H5Z_set_local_direct(&(cparam->pline)) < 0) + if (H5Z_set_local_direct(&(cparam->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to set local filter parameters") /* Copy the I/O filter pipeline from the creation parameters to the header */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, &(cparam->pline), &(hdr->pline))) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, &(cparam->pline), &(hdr->pline))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOPY, HADDR_UNDEF, "can't copy I/O filter pipeline") /* Set the version for the I/O pipeline message */ - if(H5O_pline_set_version(hdr->f, &(hdr->pline)) < 0) + if (H5O_pline_set_version(hdr->f, &(hdr->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, HADDR_UNDEF, "can't set version of I/O filter pipeline") /* Compute the I/O filters' encoded size */ - if(0 == (hdr->filter_len = (unsigned)H5O_msg_raw_size(hdr->f, H5O_PLINE_ID, FALSE, &(hdr->pline)))) + if (0 == (hdr->filter_len = (unsigned)H5O_msg_raw_size(hdr->f, H5O_PLINE_ID, FALSE, &(hdr->pline)))) HGOTO_ERROR(H5E_HEAP, H5E_CANTGETSIZE, HADDR_UNDEF, "can't get I/O filter pipeline size") /* Compute size of header on disk */ - hdr->heap_size = H5HF_HEADER_SIZE(hdr) /* Base header size */ - + hdr->sizeof_size /* Size of size for filtered root direct block */ - + 4 /* Size of filter mask for filtered root direct block */ - + hdr->filter_len; /* Size of encoded I/O filter info */ - } /* end if */ + hdr->heap_size = H5HF_HEADER_SIZE(hdr) /* Base header size */ + + hdr->sizeof_size /* Size of size for filtered root direct block */ + + 4 /* Size of filter mask for filtered root direct block */ + + hdr->filter_len; /* Size of encoded I/O filter info */ + } /* end if */ else { /* Set size of header on disk */ hdr->heap_size = H5HF_HEADER_SIZE(hdr); @@ -452,30 +439,34 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) * routines are also called from the cache 'load' callback, and the ID * length is already set in that case (its stored in the header on disk)) */ - switch(cparam->id_len) { - case 0: /* Set the length of heap IDs to just enough to hold the offset & length of 'normal' objects in the heap */ + switch (cparam->id_len) { + case 0: /* Set the length of heap IDs to just enough to hold the offset & length of 'normal' objects + in the heap */ hdr->id_len = (unsigned)1 + hdr->heap_off_size + hdr->heap_len_size; break; - case 1: /* Set the length of heap IDs to just enough to hold the information needed to directly access 'huge' objects in the heap */ - if(hdr->filter_len > 0) - hdr->id_len = (unsigned)1 /* ID flags */ - + hdr->sizeof_addr /* Address of filtered object */ - + hdr->sizeof_size /* Length of filtered object */ - + 4 /* Filter mask for filtered object */ - + hdr->sizeof_size; /* Size of de-filtered object in memory */ + case 1: /* Set the length of heap IDs to just enough to hold the information needed to directly access + 'huge' objects in the heap */ + if (hdr->filter_len > 0) + hdr->id_len = (unsigned)1 /* ID flags */ + + hdr->sizeof_addr /* Address of filtered object */ + + hdr->sizeof_size /* Length of filtered object */ + + 4 /* Filter mask for filtered object */ + + hdr->sizeof_size; /* Size of de-filtered object in memory */ else - hdr->id_len = (unsigned)1 /* ID flags */ - + hdr->sizeof_addr /* Address of object */ - + hdr->sizeof_size; /* Length of object */ + hdr->id_len = (unsigned)1 /* ID flags */ + + hdr->sizeof_addr /* Address of object */ + + hdr->sizeof_size; /* Length of object */ break; - default: /* Use the requested size for the heap ID */ + default: /* Use the requested size for the heap ID */ /* Check boundaries */ - if(cparam->id_len < (1 + hdr->heap_off_size + hdr->heap_len_size)) - HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, HADDR_UNDEF, "ID length not large enough to hold object IDs") - else if(cparam->id_len > H5HF_MAX_ID_LEN) - HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, HADDR_UNDEF, "ID length too large to store tiny object lengths") + if (cparam->id_len < (1 + hdr->heap_off_size + hdr->heap_len_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, HADDR_UNDEF, + "ID length not large enough to hold object IDs") + else if (cparam->id_len > H5HF_MAX_ID_LEN) + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, HADDR_UNDEF, + "ID length too large to store tiny object lengths") /* Use the requested size for the heap ID */ hdr->id_len = cparam->id_len; @@ -484,35 +475,36 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) /* Second phase of header final initialization */ /* (needs ID and filter lengths set up) */ - if(H5HF_hdr_finish_init_phase2(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "can't finish phase #2 of header final initialization") + if (H5HF_hdr_finish_init_phase2(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, + "can't finish phase #2 of header final initialization") /* Extra checking for possible gap between max. direct block size minus * overhead and "huge" object size */ dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - if((cparam->managed.max_direct_size - dblock_overhead) < cparam->max_man_size) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not large enough to hold all managed blocks") + if ((cparam->managed.max_direct_size - dblock_overhead) < cparam->max_man_size) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, + "max. direct block size not large enough to hold all managed blocks") /* Allocate space for the header on disk */ - if(HADDR_UNDEF == (hdr->heap_addr = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, (hsize_t)hdr->heap_size))) + if (HADDR_UNDEF == (hdr->heap_addr = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, (hsize_t)hdr->heap_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for fractal heap header") /* Cache the new fractal heap header */ - if(H5AC_insert_entry(f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, HADDR_UNDEF, "can't add fractal heap header to cache") /* Set address of heap header to return */ ret_value = hdr->heap_addr; done: - if(!H5F_addr_defined(ret_value) && hdr) - if(H5HF_hdr_free(hdr) < 0) + if (!H5F_addr_defined(ret_value) && hdr) + if (H5HF_hdr_free(hdr) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_create() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_protect * @@ -529,9 +521,9 @@ done: H5HF_hdr_t * H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags) { - H5HF_hdr_cache_ud_t cache_udata; /* User-data for callback */ - H5HF_hdr_t *hdr; /* Fractal heap header */ - H5HF_hdr_t *ret_value = NULL; /* Return value */ + H5HF_hdr_cache_ud_t cache_udata; /* User-data for callback */ + H5HF_hdr_t * hdr; /* Fractal heap header */ + H5HF_hdr_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -546,7 +538,7 @@ H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags) cache_udata.f = f; /* Lock the heap header into memory */ - if(NULL == (hdr = (H5HF_hdr_t *)H5AC_protect(f, H5AC_FHEAP_HDR, addr, &cache_udata, flags))) + if (NULL == (hdr = (H5HF_hdr_t *)H5AC_protect(f, H5AC_FHEAP_HDR, addr, &cache_udata, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header") /* Set the header's address */ @@ -562,7 +554,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_protect() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_incr * @@ -579,7 +570,7 @@ done: herr_t H5HF_hdr_incr(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -587,8 +578,8 @@ H5HF_hdr_incr(H5HF_hdr_t *hdr) HDassert(hdr); /* Mark header as un-evictable when a block is depending on it */ - if(hdr->rc == 0) - if(H5AC_pin_protected_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_pin_protected_entry(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin fractal heap header") /* Increment reference count on shared header */ @@ -598,7 +589,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_incr() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_decr * @@ -615,7 +605,7 @@ done: herr_t H5HF_hdr_decr(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -627,9 +617,9 @@ H5HF_hdr_decr(H5HF_hdr_t *hdr) hdr->rc--; /* Mark header as evictable again when no child blocks depend on it */ - if(hdr->rc == 0) { + if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); - if(H5AC_unpin_entry(hdr) < 0) + if (H5AC_unpin_entry(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap header") } /* end if */ @@ -637,7 +627,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_decr() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_fuse_incr * @@ -665,7 +654,6 @@ H5HF_hdr_fuse_incr(H5HF_hdr_t *hdr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_hdr_fuse_incr() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_fuse_decr * @@ -694,7 +682,6 @@ H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr) FUNC_LEAVE_NOAPI(hdr->file_rc) } /* end H5HF_hdr_fuse_decr() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_dirty * @@ -711,7 +698,7 @@ H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr) herr_t H5HF_hdr_dirty(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -719,20 +706,19 @@ H5HF_hdr_dirty(H5HF_hdr_t *hdr) HDassert(hdr); /* Resize pinned header in cache if I/O filter is present. */ - if(hdr->filter_len > 0) { - if(H5AC_resize_entry(hdr, (size_t)hdr->heap_size) < 0) + if (hdr->filter_len > 0) { + if (H5AC_resize_entry(hdr, (size_t)hdr->heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize fractal heap header") } /* end if */ /* Mark header as dirty in cache */ - if(H5AC_mark_entry_dirty(hdr) < 0) + if (H5AC_mark_entry_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark fractal heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_dirty() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_adj_free * @@ -749,7 +735,7 @@ done: herr_t H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -763,14 +749,13 @@ H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt) hdr->total_man_free = (hsize_t)((hssize_t)hdr->total_man_free + amt); /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_adj_free() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_adjust_heap * @@ -787,7 +772,7 @@ done: herr_t H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -804,14 +789,13 @@ H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free) hdr->total_man_free = (hsize_t)((hssize_t)hdr->total_man_free + extra_free); /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_adjust_heap() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_inc_alloc * @@ -842,7 +826,6 @@ H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_hdr_inc_alloc() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_start_iter * @@ -859,7 +842,7 @@ H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size) herr_t H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, unsigned curr_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -870,7 +853,7 @@ H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, HDassert(iblock); /* Set up "next block" iterator at correct location */ - if(H5HF_man_iter_start_entry(hdr, &hdr->next_block, iblock, curr_entry) < 0) + if (H5HF_man_iter_start_entry(hdr, &hdr->next_block, iblock, curr_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize block iterator") /* Set the offset of the iterator in the heap */ @@ -880,7 +863,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_start_iter() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_reset_iter * @@ -897,7 +879,7 @@ done: herr_t H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -907,7 +889,7 @@ H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off) HDassert(hdr); /* Reset "next block" iterator */ - if(H5HF_man_iter_reset(&hdr->next_block) < 0) + if (H5HF_man_iter_reset(&hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") /* Set the offset of the iterator in the heap */ @@ -917,7 +899,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_reset_iter() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_skip_blocks * @@ -932,12 +913,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, - unsigned start_entry, unsigned nentries) +H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, unsigned nentries) { - unsigned row, col; /* Row & column of entry */ - hsize_t sect_size; /* Size of section in heap space */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned row, col; /* Row & column of entry */ + hsize_t sect_size; /* Size of section in heap space */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -949,24 +929,24 @@ H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, HDassert(nentries); /* Compute the span within the heap to skip */ - row = start_entry / hdr->man_dtable.cparam.width; - col = start_entry % hdr->man_dtable.cparam.width; + row = start_entry / hdr->man_dtable.cparam.width; + col = start_entry % hdr->man_dtable.cparam.width; sect_size = H5HF_dtable_span_size(&hdr->man_dtable, row, col, nentries); HDassert(sect_size > 0); /* Advance the new block iterator */ - if(H5HF_hdr_inc_iter(hdr, sect_size, nentries) < 0) + if (H5HF_hdr_inc_iter(hdr, sect_size, nentries) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't increase allocated heap size") /* Add 'indirect' section for blocks skipped in this row */ - if(H5HF__sect_indirect_add(hdr, iblock, start_entry, nentries) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section for indirect block's free space") + if (H5HF__sect_indirect_add(hdr, iblock, start_entry, nentries) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't create indirect section for indirect block's free space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_skip_blocks() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_update_iter * @@ -986,7 +966,7 @@ done: herr_t H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -997,49 +977,49 @@ H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) HDassert(min_dblock_size > 0); /* Check for creating first indirect block */ - if(hdr->man_dtable.curr_root_rows == 0) { - if(H5HF__man_iblock_root_create(hdr, min_dblock_size) < 0) + if (hdr->man_dtable.curr_root_rows == 0) { + if (H5HF__man_iblock_root_create(hdr, min_dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "unable to create root indirect block") } /* end if */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - hbool_t walked_up, walked_down; /* Condition variables for finding direct block location */ - unsigned next_row; /* Iterator's next block row */ - unsigned next_entry; /* Iterator's next block entry */ - unsigned min_dblock_row; /* Minimum row for direct block size request */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + hbool_t walked_up, walked_down; /* Condition variables for finding direct block location */ + unsigned next_row; /* Iterator's next block row */ + unsigned next_entry; /* Iterator's next block entry */ + unsigned min_dblock_row; /* Minimum row for direct block size request */ /* Compute min. row for direct block requested */ min_dblock_row = H5HF_dtable_size_to_row(&hdr->man_dtable, min_dblock_size); /* Initialize block iterator, if necessary */ - if(!H5HF_man_iter_ready(&hdr->next_block)) { + if (!H5HF_man_iter_ready(&hdr->next_block)) { /* Start iterator with previous offset of iterator */ - if(H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) + if (H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to set block iterator location") } /* end if */ /* Get information about current iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + if (H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") /* Check for skipping over blocks in the current block */ - if(min_dblock_row > next_row && next_row < iblock->nrows) { - unsigned min_entry; /* Min entry for direct block requested */ - unsigned skip_entries; /* Number of entries to skip in the current block */ + if (min_dblock_row > next_row && next_row < iblock->nrows) { + unsigned min_entry; /* Min entry for direct block requested */ + unsigned skip_entries; /* Number of entries to skip in the current block */ /* Compute the number of entries to skip in the current block */ min_entry = min_dblock_row * hdr->man_dtable.cparam.width; - if(min_dblock_row >= iblock->nrows) + if (min_dblock_row >= iblock->nrows) skip_entries = (iblock->nrows * hdr->man_dtable.cparam.width) - next_entry; else skip_entries = min_entry - next_entry; /* Add skipped direct blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, iblock, next_entry, skip_entries) < 0) + if (H5HF__hdr_skip_blocks(hdr, iblock, next_entry, skip_entries) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") /* Get information about new iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + if (H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") } /* end if */ @@ -1049,25 +1029,27 @@ H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) /* Check for walking off end of indirect block */ /* (walk up iterator) */ - while(next_row >= iblock->nrows) { + while (next_row >= iblock->nrows) { /* Check for needing to expand root indirect block */ - if(iblock->parent == NULL) { - if(H5HF__man_iblock_root_double(hdr, min_dblock_size) < 0) + if (iblock->parent == NULL) { + if (H5HF__man_iblock_root_double(hdr, min_dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "unable to double root indirect block") } /* end if */ else { /* Move iterator up one level */ - if(H5HF_man_iter_up(&hdr->next_block) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location") + if (H5HF_man_iter_up(&hdr->next_block) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, + "unable to advance current block iterator location") /* Increment location of next block at this level */ - if(H5HF_man_iter_next(hdr, &hdr->next_block, 1) < 0) + if (H5HF_man_iter_next(hdr, &hdr->next_block, 1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't advance fractal heap block location") } /* end else */ /* Get information about new iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") + if (H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to retrieve current block iterator location") /* Indicate that we walked up */ walked_up = TRUE; @@ -1075,80 +1057,93 @@ H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) /* Check for walking into child indirect block */ /* (walk down iterator) */ - if(next_row >= hdr->man_dtable.max_direct_rows) { - unsigned child_nrows; /* Number of rows in new indirect block */ + if (next_row >= hdr->man_dtable.max_direct_rows) { + unsigned child_nrows; /* Number of rows in new indirect block */ HDassert(!H5F_addr_defined(iblock->ents[next_entry].addr)); /* Compute # of rows in next child indirect block to use */ - child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[next_row]); + child_nrows = + H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[next_row]); /* Check for skipping over indirect blocks */ /* (that don't have direct blocks large enough to hold direct block size requested) */ - if(hdr->man_dtable.row_block_size[child_nrows - 1] < min_dblock_size) { - unsigned child_rows_needed; /* Number of rows needed to hold direct block */ - unsigned child_entry; /* Entry of child indirect block */ + if (hdr->man_dtable.row_block_size[child_nrows - 1] < min_dblock_size) { + unsigned child_rows_needed; /* Number of rows needed to hold direct block */ + unsigned child_entry; /* Entry of child indirect block */ /* Compute # of rows needed in child indirect block */ - child_rows_needed = (H5VM_log2_of2((uint32_t)min_dblock_size) - H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size)) + 2; + child_rows_needed = (H5VM_log2_of2((uint32_t)min_dblock_size) - + H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size)) + + 2; HDassert(child_rows_needed > child_nrows); - child_entry = (next_row + (child_rows_needed - child_nrows)) * hdr->man_dtable.cparam.width; - if(child_entry > (iblock->nrows * hdr->man_dtable.cparam.width)) + child_entry = + (next_row + (child_rows_needed - child_nrows)) * hdr->man_dtable.cparam.width; + if (child_entry > (iblock->nrows * hdr->man_dtable.cparam.width)) child_entry = iblock->nrows * hdr->man_dtable.cparam.width; /* Add skipped indirect blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (child_entry - next_entry)) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") + if (H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (child_entry - next_entry)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't add skipped blocks to heap's free space") } /* end if */ else { - H5HF_indirect_t *new_iblock; /* Pointer to new indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - haddr_t new_iblock_addr; /* New indirect block's address */ + H5HF_indirect_t *new_iblock; /* Pointer to new indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + haddr_t new_iblock_addr; /* New indirect block's address */ /* Allocate new indirect block */ - if(H5HF__man_iblock_create(hdr, iblock, next_entry, child_nrows, child_nrows, &new_iblock_addr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap indirect block") + if (H5HF__man_iblock_create(hdr, iblock, next_entry, child_nrows, child_nrows, + &new_iblock_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, + "can't allocate fractal heap indirect block") /* Lock new indirect block */ - if(NULL == (new_iblock = H5HF__man_iblock_protect(hdr, new_iblock_addr, child_nrows, iblock, next_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") + if (NULL == (new_iblock = H5HF__man_iblock_protect(hdr, new_iblock_addr, child_nrows, + iblock, next_entry, FALSE, + H5AC__NO_FLAGS_SET, &did_protect))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, + "unable to protect fractal heap indirect block") /* Move iterator down one level (pins indirect block) */ - if(H5HF_man_iter_down(&hdr->next_block, new_iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location") + if (H5HF_man_iter_down(&hdr->next_block, new_iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, + "unable to advance current block iterator location") /* Check for skipping over rows and add free section for skipped rows */ - if(min_dblock_size > hdr->man_dtable.cparam.start_block_size) { - unsigned new_entry; /* Entry of direct block which is large enough */ + if (min_dblock_size > hdr->man_dtable.cparam.start_block_size) { + unsigned new_entry; /* Entry of direct block which is large enough */ /* Compute entry for direct block size requested */ new_entry = hdr->man_dtable.cparam.width * min_dblock_row; /* Add skipped blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, new_iblock, 0, new_entry) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") + if (H5HF__hdr_skip_blocks(hdr, new_iblock, 0, new_entry) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't add skipped blocks to heap's free space") } /* end if */ /* Unprotect child indirect block */ - if(H5HF__man_iblock_unprotect(new_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (H5HF__man_iblock_unprotect(new_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") } /* end else */ /* Get information about new iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") + if (H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to retrieve current block iterator location") /* Indicate that we walked down */ walked_down = TRUE; } /* end if */ - } while(walked_down || walked_up); + } while (walked_down || walked_up); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_update_iter() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_inc_iter * @@ -1165,7 +1160,7 @@ done: herr_t H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1176,8 +1171,8 @@ H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries) HDassert(nentries); /* Advance the iterator for the current location within the indirect block */ - if(hdr->next_block.curr) - if(H5HF_man_iter_next(hdr, &hdr->next_block, nentries) < 0) + if (hdr->next_block.curr) + if (H5HF_man_iter_next(hdr, &hdr->next_block, nentries) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location") /* Increment the offset of the iterator in the heap */ @@ -1187,7 +1182,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_inc_iter() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_reverse_iter * @@ -1205,11 +1199,11 @@ done: herr_t H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) { - H5HF_indirect_t *iblock; /* Indirect block where iterator is located */ - unsigned curr_entry; /* Current entry for iterator */ - hbool_t walked_down; /* Loop flag */ - hbool_t walked_up; /* Loop flag */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Indirect block where iterator is located */ + unsigned curr_entry; /* Current entry for iterator */ + hbool_t walked_down; /* Loop flag */ + hbool_t walked_up; /* Loop flag */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1219,15 +1213,15 @@ H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) HDassert(hdr); /* Initialize block iterator, if necessary */ - if(!H5HF_man_iter_ready(&hdr->next_block)) + if (!H5HF_man_iter_ready(&hdr->next_block)) /* Start iterator with previous offset of iterator */ - if(H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) + if (H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to set block iterator location") /* Walk backwards through heap, looking for direct block to place iterator after */ /* Get information about current iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, NULL, NULL, &curr_entry, &iblock) < 0) + if (H5HF_man_iter_curr(&hdr->next_block, NULL, NULL, &curr_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator information") /* Move current iterator position backwards once */ @@ -1235,30 +1229,31 @@ H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) /* Search backwards in the heap address space for direct block to latch onto */ do { - int tmp_entry; /* Temp. entry for iterator (use signed value to detect errors) */ + int tmp_entry; /* Temp. entry for iterator (use signed value to detect errors) */ /* Reset loop flags */ walked_down = FALSE; - walked_up = FALSE; + walked_up = FALSE; /* Walk backwards through entries, until we find one that has a child */ /* (Skip direct block that will be deleted, if we find it) */ tmp_entry = (int)curr_entry; - while(tmp_entry >= 0 && - (H5F_addr_eq(iblock->ents[tmp_entry].addr, dblock_addr) || - !H5F_addr_defined(iblock->ents[tmp_entry].addr))) + while (tmp_entry >= 0 && (H5F_addr_eq(iblock->ents[tmp_entry].addr, dblock_addr) || + !H5F_addr_defined(iblock->ents[tmp_entry].addr))) tmp_entry--; /* Check for no earlier blocks in this indirect block */ - if(tmp_entry < 0) { + if (tmp_entry < 0) { /* Check for parent of current indirect block */ - if(iblock->parent) { + if (iblock->parent) { /* Move iterator to parent of current block */ - if(H5HF_man_iter_up(&hdr->next_block) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to move current block iterator location up") + if (H5HF_man_iter_up(&hdr->next_block) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, + "unable to move current block iterator location up") /* Get information about current iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, NULL, NULL, &curr_entry, &iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator information") + if (H5HF_man_iter_curr(&hdr->next_block, NULL, NULL, &curr_entry, &iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to retrieve current block iterator information") /* Move current iterator position backwards once */ curr_entry--; @@ -1271,69 +1266,75 @@ H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) hdr->man_iter_off = 0; /* Reset 'next block' iterator */ - if(H5HF_man_iter_reset(&hdr->next_block) < 0) + if (H5HF_man_iter_reset(&hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") } /* end else */ - } /* end if */ + } /* end if */ else { - unsigned row; /* Row for entry */ + unsigned row; /* Row for entry */ curr_entry = (unsigned)tmp_entry; /* Check if entry is for a direct block */ row = curr_entry / hdr->man_dtable.cparam.width; - if(row < hdr->man_dtable.max_direct_rows) { + if (row < hdr->man_dtable.max_direct_rows) { /* Increment entry to empty location */ curr_entry++; /* Set the current location of the iterator to next entry after the existing direct block */ - if(H5HF_man_iter_set_entry(hdr, &hdr->next_block, curr_entry) < 0) + if (H5HF_man_iter_set_entry(hdr, &hdr->next_block, curr_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "unable to set current block iterator location") /* Update iterator offset */ hdr->man_iter_off = iblock->block_off; hdr->man_iter_off += hdr->man_dtable.row_block_off[curr_entry / hdr->man_dtable.cparam.width]; - hdr->man_iter_off += hdr->man_dtable.row_block_size[curr_entry / hdr->man_dtable.cparam.width] * (curr_entry % hdr->man_dtable.cparam.width); + hdr->man_iter_off += + hdr->man_dtable.row_block_size[curr_entry / hdr->man_dtable.cparam.width] * + (curr_entry % hdr->man_dtable.cparam.width); } /* end if */ else { - H5HF_indirect_t *child_iblock; /* Pointer to child indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - unsigned child_nrows; /* # of rows in child block */ + H5HF_indirect_t *child_iblock; /* Pointer to child indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + unsigned child_nrows; /* # of rows in child block */ /* Compute # of rows in next child indirect block to use */ child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[row]); /* Lock child indirect block */ - if(NULL == (child_iblock = H5HF__man_iblock_protect(hdr, iblock->ents[curr_entry].addr, child_nrows, iblock, curr_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") + if (NULL == (child_iblock = H5HF__man_iblock_protect(hdr, iblock->ents[curr_entry].addr, + child_nrows, iblock, curr_entry, FALSE, + H5AC__NO_FLAGS_SET, &did_protect))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, + "unable to protect fractal heap indirect block") /* Set the current location of the iterator */ - if(H5HF_man_iter_set_entry(hdr, &hdr->next_block, curr_entry) < 0) + if (H5HF_man_iter_set_entry(hdr, &hdr->next_block, curr_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "unable to set current block iterator location") /* Walk down into child indirect block (pins child block) */ - if(H5HF_man_iter_down(&hdr->next_block, child_iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location") + if (H5HF_man_iter_down(&hdr->next_block, child_iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, + "unable to advance current block iterator location") /* Update iterator location */ - iblock = child_iblock; + iblock = child_iblock; curr_entry = (child_iblock->nrows * hdr->man_dtable.cparam.width) - 1; /* Unprotect child indirect block */ - if(H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") /* Note that we walked down */ walked_down = TRUE; } /* end else */ - } /* end else */ - } while(walked_down || walked_up); + } /* end else */ + } while (walked_down || walked_up); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_reverse_iter() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_empty * @@ -1350,7 +1351,7 @@ done: herr_t H5HF__hdr_empty(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1358,18 +1359,18 @@ H5HF__hdr_empty(H5HF_hdr_t *hdr) HDassert(hdr); /* Reset block iterator, if necessary */ - if(H5HF_man_iter_ready(&hdr->next_block)) { - if(H5HF_man_iter_reset(&hdr->next_block) < 0) + if (H5HF_man_iter_ready(&hdr->next_block)) { + if (H5HF_man_iter_reset(&hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") } /* end if */ /* Shrink managed heap size */ - hdr->man_size = 0; + hdr->man_size = 0; hdr->man_alloc_size = 0; /* Reset root pointer information */ hdr->man_dtable.curr_root_rows = 0; - hdr->man_dtable.table_addr = HADDR_UNDEF; + hdr->man_dtable.table_addr = HADDR_UNDEF; /* Reset the 'next block' iterator location */ hdr->man_iter_off = 0; @@ -1378,14 +1379,13 @@ H5HF__hdr_empty(H5HF_hdr_t *hdr) hdr->total_man_free = 0; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_empty() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_free * @@ -1402,7 +1402,7 @@ done: herr_t H5HF_hdr_free(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1412,12 +1412,12 @@ H5HF_hdr_free(H5HF_hdr_t *hdr) HDassert(hdr); /* Free the block size lookup table for the doubling table */ - if(H5HF_dtable_dest(&hdr->man_dtable) < 0) + if (H5HF_dtable_dest(&hdr->man_dtable) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap doubling table") /* Release any I/O pipeline filter information */ - if(hdr->pline.nused) - if(H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)) < 0) + if (hdr->pline.nused) + if (H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to reset I/O pipeline message") /* Free the shared info itself */ @@ -1427,7 +1427,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_free() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_delete * @@ -1444,8 +1443,8 @@ done: herr_t H5HF__hdr_delete(H5HF_hdr_t *hdr) { - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1456,61 +1455,64 @@ H5HF__hdr_delete(H5HF_hdr_t *hdr) HDassert(!hdr->file_rc); #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Heap header's status in the metadata cache */ + { + unsigned hdr_status = 0; /* Heap header's status in the metadata cache */ - /* Check the heap header's status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, hdr->heap_addr, &hdr_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for heap header") + /* Check the heap header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->heap_addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for heap header") - /* Sanity checks on heap header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); -} /* end block */ + /* Sanity checks on heap header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); + } /* end block */ #endif /* NDEBUG */ /* Check for free space manager for heap */ /* (must occur before attempting to delete the heap, so indirect blocks * will get unpinned) */ - if(H5F_addr_defined(hdr->fs_addr)) + if (H5F_addr_defined(hdr->fs_addr)) /* Delete free space manager for heap */ - if(H5HF__space_delete(hdr) < 0) + if (H5HF__space_delete(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap free space manager") /* Check for root direct/indirect block */ - if(H5F_addr_defined(hdr->man_dtable.table_addr)) { - if(hdr->man_dtable.curr_root_rows == 0) { - hsize_t dblock_size; /* Size of direct block on disk */ + if (H5F_addr_defined(hdr->man_dtable.table_addr)) { + if (hdr->man_dtable.curr_root_rows == 0) { + hsize_t dblock_size; /* Size of direct block on disk */ /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Set the dblock's size */ dblock_size = hdr->pline_root_direct_size; /* Reset the header's pipeline information */ - hdr->pline_root_direct_size = 0; + hdr->pline_root_direct_size = 0; hdr->pline_root_direct_filter_mask = 0; } /* end if */ else dblock_size = hdr->man_dtable.cparam.start_block_size; /* Delete root direct block */ - if(H5HF__man_dblock_delete(hdr->f, hdr->man_dtable.table_addr, dblock_size) < 0) + if (H5HF__man_dblock_delete(hdr->f, hdr->man_dtable.table_addr, dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap root direct block") } /* end if */ else { /* Delete root indirect block */ - if(H5HF__man_iblock_delete(hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap root indirect block") + if (H5HF__man_iblock_delete(hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, + 0) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to release fractal heap root indirect block") } /* end else */ - } /* end if */ + } /* end if */ /* Check for 'huge' objects in heap */ - if(H5F_addr_defined(hdr->huge_bt2_addr)) { + if (H5F_addr_defined(hdr->huge_bt2_addr)) { /* Delete huge objects in heap and their tracker */ - if(H5HF__huge_delete(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap 'huge' objects and tracker") + if (H5HF__huge_delete(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to release fractal heap 'huge' objects and tracker") } /* end if */ /* Indicate that the heap header should be deleted & file space freed */ @@ -1518,9 +1520,8 @@ H5HF__hdr_delete(H5HF_hdr_t *hdr) done: /* Unprotect the header with appropriate flags */ - if(H5AC_unprotect(hdr->f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_delete() */ - diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index d496d62..58b231f 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -26,39 +26,34 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ /* v2 B-tree creation macros */ -#define H5HF_HUGE_BT2_NODE_SIZE 512 -#define H5HF_HUGE_BT2_SPLIT_PERC 100 -#define H5HF_HUGE_BT2_MERGE_PERC 40 - +#define H5HF_HUGE_BT2_NODE_SIZE 512 +#define H5HF_HUGE_BT2_SPLIT_PERC 100 +#define H5HF_HUGE_BT2_MERGE_PERC 40 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -68,25 +63,21 @@ static herr_t H5HF__huge_bt2_create(H5HF_hdr_t *hdr); /* Local 'huge' object support routines */ static hsize_t H5HF_huge_new_id(H5HF_hdr_t *hdr); -static herr_t H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, - hbool_t is_read, H5HF_operator_t op, void *op_data); - +static herr_t H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, H5HF_operator_t op, + void *op_data); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_create * @@ -103,8 +94,8 @@ static herr_t H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, static herr_t H5HF__huge_bt2_create(H5HF_hdr_t *hdr) { - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -120,53 +111,55 @@ H5HF__huge_bt2_create(H5HF_hdr_t *hdr) * difficult to write. "Waste" an extra byte or for small heaps (where * the 'huge_id_size' is < 'sizeof_size' in order to make this easier -QAK) */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size /* Length of object */ - + (unsigned)4 /* Filter mask for filtered object */ - + (unsigned)hdr->sizeof_size); /* Size of de-filtered object in memory */ + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) { + bt2_cparam.rrec_size = + (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size /* Length of object */ + + (unsigned)4 /* Filter mask for filtered object */ + + (unsigned)hdr->sizeof_size); /* Size of de-filtered object in memory */ bt2_cparam.cls = H5HF_HUGE_BT2_FILT_DIR; } /* end if */ else { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size); /* Length of object */ - bt2_cparam.cls = H5HF_HUGE_BT2_DIR; + bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size); /* Length of object */ + bt2_cparam.cls = H5HF_HUGE_BT2_DIR; } /* end else */ - } /* end if */ + } /* end if */ else { - if(hdr->filter_len > 0) { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of filtered object */ - + (unsigned)hdr->sizeof_size /* Length of filtered object */ - + (unsigned)4 /* Filter mask for filtered object */ - + (unsigned)hdr->sizeof_size /* Size of de-filtered object in memory */ - + (unsigned)hdr->sizeof_size); /* Unique ID for object */ + if (hdr->filter_len > 0) { + bt2_cparam.rrec_size = + (size_t)((unsigned)hdr->sizeof_addr /* Address of filtered object */ + + (unsigned)hdr->sizeof_size /* Length of filtered object */ + + (unsigned)4 /* Filter mask for filtered object */ + + (unsigned)hdr->sizeof_size /* Size of de-filtered object in memory */ + + (unsigned)hdr->sizeof_size); /* Unique ID for object */ bt2_cparam.cls = H5HF_HUGE_BT2_FILT_INDIR; } /* end if */ else { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size /* Length of object */ - + (unsigned)hdr->sizeof_size); /* Unique ID for object */ - bt2_cparam.cls = H5HF_HUGE_BT2_INDIR; + bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size /* Length of object */ + + (unsigned)hdr->sizeof_size); /* Unique ID for object */ + bt2_cparam.cls = H5HF_HUGE_BT2_INDIR; } /* end else */ - } /* end else */ - bt2_cparam.node_size = (size_t)H5HF_HUGE_BT2_NODE_SIZE; + } /* end else */ + bt2_cparam.node_size = (size_t)H5HF_HUGE_BT2_NODE_SIZE; bt2_cparam.split_percent = H5HF_HUGE_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5HF_HUGE_BT2_MERGE_PERC; /* Create v2 B-tree for tracking 'huge' objects */ - if(NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, &bt2_cparam, hdr->f))) + if (NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, &bt2_cparam, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking 'huge' heap objects") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(hdr->huge_bt2, &hdr->huge_bt2_addr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking 'huge' heap objects") + if (H5B2_get_addr(hdr->huge_bt2, &hdr->huge_bt2_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "can't get v2 B-tree address for tracking 'huge' heap objects") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_bt2_create() */ - /*------------------------------------------------------------------------- * Function: H5HF_huge_init * @@ -197,11 +190,11 @@ H5HF_huge_init(H5HF_hdr_t *hdr) * have any I/O pipeline filters. */ #ifdef QAK -HDfprintf(stderr, "%s: hdr->id_len = %u\n", "H5HF_huge_init", (unsigned)hdr->id_len); -HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr->filter_len); + HDfprintf(stderr, "%s: hdr->id_len = %u\n", "H5HF_huge_init", (unsigned)hdr->id_len); + HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr->filter_len); #endif /* QAK */ - if(hdr->filter_len > 0) { - if((hdr->id_len - 1) >= (unsigned)(hdr->sizeof_addr + hdr->sizeof_size + 4 + hdr->sizeof_size)) { + if (hdr->filter_len > 0) { + if ((hdr->id_len - 1) >= (unsigned)(hdr->sizeof_addr + hdr->sizeof_size + 4 + hdr->sizeof_size)) { /* Indicate that v2 B-tree doesn't have to be used to locate object */ hdr->huge_ids_direct = TRUE; @@ -213,7 +206,7 @@ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr- hdr->huge_ids_direct = FALSE; } /* end if */ else { - if((hdr->sizeof_addr + hdr->sizeof_size) <= (hdr->id_len - 1)) { + if ((hdr->sizeof_addr + hdr->sizeof_size) <= (hdr->id_len - 1)) { /* Indicate that v2 B-tree doesn't have to be used to locate object */ hdr->huge_ids_direct = TRUE; @@ -224,23 +217,22 @@ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr- /* Indicate that v2 B-tree must be used to locate object */ hdr->huge_ids_direct = FALSE; } /* end else */ - if(!hdr->huge_ids_direct) { + if (!hdr->huge_ids_direct) { /* Set the size and maximum value of 'huge' object ID */ - if((hdr->id_len - 1) < sizeof(hsize_t)) { + if ((hdr->id_len - 1) < sizeof(hsize_t)) { hdr->huge_id_size = (uint8_t)(hdr->id_len - 1); - hdr->huge_max_id = ((hsize_t)1 << (hdr->huge_id_size * 8)) - 1; + hdr->huge_max_id = ((hsize_t)1 << (hdr->huge_id_size * 8)) - 1; } /*end if */ else { hdr->huge_id_size = sizeof(hsize_t); - hdr->huge_max_id = HSIZET_MAX; + hdr->huge_max_id = HSIZET_MAX; } /* end else */ - } /* end if */ + } /* end if */ hdr->huge_bt2 = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_huge_init() */ - /*------------------------------------------------------------------------- * Function: H5HF_huge_new_id * @@ -258,8 +250,8 @@ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr- static hsize_t H5HF_huge_new_id(H5HF_hdr_t *hdr) { - hsize_t new_id; /* New object's ID */ - hsize_t ret_value = 0; /* Return value */ + hsize_t new_id; /* New object's ID */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -269,7 +261,7 @@ H5HF_huge_new_id(H5HF_hdr_t *hdr) HDassert(hdr); /* Check for wrapping around 'huge' object ID space */ - if(hdr->huge_ids_wrapped) + if (hdr->huge_ids_wrapped) /* Fail for now - eventually should iterate through v2 B-tree, looking for available ID */ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, 0, "wrapping 'huge' object IDs not supported yet") else { @@ -278,7 +270,7 @@ H5HF_huge_new_id(H5HF_hdr_t *hdr) new_id = ++hdr->huge_next_id; /* Check for wrapping 'huge' object IDs around */ - if(hdr->huge_next_id == hdr->huge_max_id) + if (hdr->huge_next_id == hdr->huge_max_id) hdr->huge_ids_wrapped = TRUE; } /* end else */ @@ -289,7 +281,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_huge_new_id() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_insert * @@ -306,16 +297,16 @@ done: herr_t H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) { - uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ - haddr_t obj_addr; /* Address of object in the file */ - void *write_buf; /* Pointer to buffer to write */ - size_t write_size; /* Size of [possibly filtered] object written to file */ - unsigned filter_mask = 0; /* Filter mask for object (only used for filtered objects) */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ + haddr_t obj_addr; /* Address of object in the file */ + void * write_buf; /* Pointer to buffer to write */ + size_t write_size; /* Size of [possibly filtered] object written to file */ + unsigned filter_mask = 0; /* Filter mask for object (only used for filtered objects) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE #ifdef QAK -HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); + HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); #endif /* QAK */ /* @@ -327,85 +318,90 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); HDassert(id); /* Check if the v2 B-tree for tracking 'huge' heap objects has been created yet */ - if(!H5F_addr_defined(hdr->huge_bt2_addr)) { + if (!H5F_addr_defined(hdr->huge_bt2_addr)) { /* Go create (& open) v2 B-tree */ - if(H5HF__huge_bt2_create(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking 'huge' heap objects") + if (H5HF__huge_bt2_create(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, + "can't create v2 B-tree for tracking 'huge' heap objects") } /* end if */ else { /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ - } /* end else */ + } /* end else */ HDassert(hdr->huge_bt2); /* Check for I/O pipeline filter on heap */ - if(hdr->filter_len > 0) { - H5Z_cb_t filter_cb; /* Filter callback structure */ - size_t nbytes; /* Number of bytes used */ + if (hdr->filter_len > 0) { + H5Z_cb_t filter_cb; /* Filter callback structure */ + size_t nbytes; /* Number of bytes used */ /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer to perform I/O filtering on */ write_size = obj_size; - if(NULL == (write_buf = H5MM_malloc(write_size))) + if (NULL == (write_buf = H5MM_malloc(write_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer") H5MM_memcpy(write_buf, obj, write_size); /* Push direct block data through I/O filter pipeline */ nbytes = write_size; - if(H5Z_pipeline(&(hdr->pline), 0, &filter_mask, H5Z_NO_EDC, - filter_cb, &nbytes, &write_size, &write_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), 0, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &write_size, + &write_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "output pipeline failed") #ifdef QAK -HDfprintf(stderr, "%s: nbytes = %Zu, write_size = %Zu, write_buf = %p\n", FUNC, nbytes, write_size, write_buf); -HDfprintf(stderr, "%s: obj_size = %Zu, obj = %p\n", FUNC, obj_size, obj); + HDfprintf(stderr, "%s: nbytes = %Zu, write_size = %Zu, write_buf = %p\n", FUNC, nbytes, write_size, + write_buf); + HDfprintf(stderr, "%s: obj_size = %Zu, obj = %p\n", FUNC, obj_size, obj); #endif /* QAK */ /* Update size of object on disk */ write_size = nbytes; } /* end if */ else { - write_buf = obj; + write_buf = obj; write_size = obj_size; } /* end else */ /* Allocate space in the file for storing the 'huge' object */ - if(HADDR_UNDEF == (obj_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, (hsize_t)write_size))) + if (HADDR_UNDEF == (obj_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, (hsize_t)write_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap huge object") /* Write the object's data to disk */ - if(H5F_block_write(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, write_size, write_buf) < 0) + if (H5F_block_write(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, write_size, write_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "writing 'huge' object to file failed") /* Release buffer for writing, if we had one */ - if(write_buf != obj) { + if (write_buf != obj) { HDassert(hdr->filter_len > 0); H5MM_xfree(write_buf); } /* end if */ /* Perform different actions for directly & indirectly accessed 'huge' objects */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { - H5HF_huge_bt2_filt_dir_rec_t obj_rec; /* Record for tracking object */ + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) { + H5HF_huge_bt2_filt_dir_rec_t obj_rec; /* Record for tracking object */ /* Initialize record for tracking object in v2 B-tree */ - obj_rec.addr = obj_addr; - obj_rec.len = write_size; + obj_rec.addr = obj_addr; + obj_rec.len = write_size; obj_rec.filter_mask = filter_mask; - obj_rec.obj_size = obj_size; + obj_rec.obj_size = obj_size; #ifdef QAK -HDfprintf(stderr, "%s: obj_rec = {%a, %Hu, %x, %Hu}\n", FUNC, obj_rec.addr, obj_rec.len, obj_rec.filter_mask, obj_rec.obj_size); + HDfprintf(stderr, "%s: obj_rec = {%a, %Hu, %x, %Hu}\n", FUNC, obj_rec.addr, obj_rec.len, + obj_rec.filter_mask, obj_rec.obj_size); #endif /* QAK */ /* Insert record for object in v2 B-tree */ - if(H5B2_insert(hdr->huge_bt2, &obj_rec) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") + if (H5B2_insert(hdr->huge_bt2, &obj_rec) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, + "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_HUGE; @@ -415,44 +411,47 @@ HDfprintf(stderr, "%s: obj_rec = {%a, %Hu, %x, %Hu}\n", FUNC, obj_rec.addr, obj_ H5F_ENCODE_LENGTH(hdr->f, id, (hsize_t)obj_size); } /* end if */ else { - H5HF_huge_bt2_dir_rec_t obj_rec; /* Record for tracking object */ + H5HF_huge_bt2_dir_rec_t obj_rec; /* Record for tracking object */ /* Initialize record for tracking object in v2 B-tree */ obj_rec.addr = obj_addr; - obj_rec.len = write_size; + obj_rec.len = write_size; #ifdef QAK -HDfprintf(stderr, "%s: obj_rec = {%a, %Hu}\n", FUNC, obj_rec.addr, obj_rec.len); + HDfprintf(stderr, "%s: obj_rec = {%a, %Hu}\n", FUNC, obj_rec.addr, obj_rec.len); #endif /* QAK */ /* Insert record for object in v2 B-tree */ - if(H5B2_insert(hdr->huge_bt2, &obj_rec) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") + if (H5B2_insert(hdr->huge_bt2, &obj_rec) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, + "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_HUGE; H5F_addr_encode(hdr->f, &id, obj_addr); H5F_ENCODE_LENGTH(hdr->f, id, (hsize_t)write_size); } /* end if */ - } /* end if */ + } /* end if */ else { - H5HF_huge_bt2_filt_indir_rec_t filt_indir_rec; /* Record for tracking filtered object */ - H5HF_huge_bt2_indir_rec_t indir_rec; /* Record for tracking non-filtered object */ - void *ins_rec; /* Pointer to record to insert */ - hsize_t new_id; /* New ID for object */ + H5HF_huge_bt2_filt_indir_rec_t filt_indir_rec; /* Record for tracking filtered object */ + H5HF_huge_bt2_indir_rec_t indir_rec; /* Record for tracking non-filtered object */ + void * ins_rec; /* Pointer to record to insert */ + hsize_t new_id; /* New ID for object */ /* Get new ID for object */ - if(0 == (new_id = H5HF_huge_new_id(hdr))) + if (0 == (new_id = H5HF_huge_new_id(hdr))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't generate new ID for object") - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Initialize record for object in v2 B-tree */ - filt_indir_rec.addr = obj_addr; - filt_indir_rec.len = write_size; + filt_indir_rec.addr = obj_addr; + filt_indir_rec.len = write_size; filt_indir_rec.filter_mask = filter_mask; - filt_indir_rec.obj_size = obj_size; - filt_indir_rec.id = new_id; + filt_indir_rec.obj_size = obj_size; + filt_indir_rec.id = new_id; #ifdef QAK -HDfprintf(stderr, "%s: filt_indir_rec = {%a, %Hu, %x, %Hu, %Hu}\n", FUNC, filt_indir_rec.addr, filt_indir_rec.len, filt_indir_rec.filter_mask, filt_indir_rec.obj_size, filt_indir_rec.id); + HDfprintf(stderr, "%s: filt_indir_rec = {%a, %Hu, %x, %Hu, %Hu}\n", FUNC, filt_indir_rec.addr, + filt_indir_rec.len, filt_indir_rec.filter_mask, filt_indir_rec.obj_size, + filt_indir_rec.id); #endif /* QAK */ /* Set pointer to record to insert */ @@ -461,10 +460,11 @@ HDfprintf(stderr, "%s: filt_indir_rec = {%a, %Hu, %x, %Hu, %Hu}\n", FUNC, filt_i else { /* Initialize record for object in v2 B-tree */ indir_rec.addr = obj_addr; - indir_rec.len = write_size; - indir_rec.id = new_id; + indir_rec.len = write_size; + indir_rec.id = new_id; #ifdef QAK -HDfprintf(stderr, "%s: indir_rec = {%a, %Hu, %Hu}\n", FUNC, indir_rec.addr, indir_rec.len, indir_rec.id); + HDfprintf(stderr, "%s: indir_rec = {%a, %Hu, %Hu}\n", FUNC, indir_rec.addr, indir_rec.len, + indir_rec.id); #endif /* QAK */ /* Set pointer to record to insert */ @@ -472,7 +472,7 @@ HDfprintf(stderr, "%s: indir_rec = {%a, %Hu, %Hu}\n", FUNC, indir_rec.addr, indi } /* end else */ /* Insert record for tracking object in v2 B-tree */ - if(H5B2_insert(hdr->huge_bt2, ins_rec) < 0) + if (H5B2_insert(hdr->huge_bt2, ins_rec) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ @@ -485,14 +485,13 @@ HDfprintf(stderr, "%s: indir_rec = {%a, %Hu, %Hu}\n", FUNC, indir_rec.addr, indi hdr->huge_nobjs++; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_insert() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_get_obj_len * @@ -509,7 +508,7 @@ done: herr_t H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -525,8 +524,8 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) id++; /* Check if 'huge' object ID encodes address & length directly */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) { /* Skip over filtered object info */ id += hdr->sizeof_addr + hdr->sizeof_size + 4; @@ -540,16 +539,17 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) /* Retrieve the object's length */ H5F_DECODE_LENGTH(hdr->f, id, *obj_len_p); } /* end else */ - } /* end if */ + } /* end if */ else { /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ @@ -557,7 +557,7 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's length */ @@ -571,19 +571,18 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's length */ *obj_len_p = (size_t)found_rec.len; } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_get_obj_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_get_obj_off * @@ -600,8 +599,8 @@ done: herr_t H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) { - haddr_t obj_addr; /* Object's address in the file */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t obj_addr; /* Object's address in the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -617,7 +616,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) id++; /* Check if 'huge' object ID encodes address & length directly */ - if(hdr->huge_ids_direct) { + if (hdr->huge_ids_direct) { /* Retrieve the object's address (common) */ H5F_addr_decode(hdr->f, &id, &obj_addr); } /* end if */ @@ -626,13 +625,14 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ @@ -640,7 +640,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -654,13 +654,13 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ obj_addr = found_rec.addr; } /* end else */ - } /* end else */ + } /* end else */ /* Set the value to return */ *obj_off_p = (hsize_t)obj_addr; @@ -669,7 +669,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_get_obj_off() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_op_real * @@ -684,14 +683,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, - H5HF_operator_t op, void *op_data) +H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, H5HF_operator_t op, void *op_data) { - void *read_buf = NULL; /* Pointer to buffer for reading */ - haddr_t obj_addr; /* Object's address in the file */ - size_t obj_size = 0; /* Object's size in the file */ - unsigned filter_mask = 0; /* Filter mask for object (only used for filtered objects) */ - herr_t ret_value = SUCCEED; /* Return value */ + void * read_buf = NULL; /* Pointer to buffer for reading */ + haddr_t obj_addr; /* Object's address in the file */ + size_t obj_size = 0; /* Object's size in the file */ + unsigned filter_mask = 0; /* Filter mask for object (only used for filtered objects) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -706,13 +704,13 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, id++; /* Check for 'huge' object ID that encodes address & length directly */ - if(hdr->huge_ids_direct) { + if (hdr->huge_ids_direct) { /* Retrieve the object's address and length (common) */ H5F_addr_decode(hdr->f, &id, &obj_addr); H5F_DECODE_LENGTH(hdr->f, id, obj_size); /* Retrieve extra information needed for filtered objects */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) UINT32DECODE(id, filter_mask); } /* end if */ else { @@ -720,13 +718,14 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ @@ -734,7 +733,7 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -750,18 +749,18 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ obj_addr = found_rec.addr; H5_CHECKED_ASSIGN(obj_size, size_t, found_rec.len, hsize_t); } /* end else */ - } /* end else */ + } /* end else */ /* Set up buffer for reading */ - if(hdr->filter_len > 0 || !is_read) { - if(NULL == (read_buf = H5MM_malloc((size_t)obj_size))) + if (hdr->filter_len > 0 || !is_read) { + if (NULL == (read_buf = H5MM_malloc((size_t)obj_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer") } /* end if */ else @@ -769,53 +768,53 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, /* Read the object's (possibly filtered) data from the file */ /* (reads directly into application's buffer if no filters are present) */ - if(H5F_block_read(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, (size_t)obj_size, read_buf) < 0) + if (H5F_block_read(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, (size_t)obj_size, read_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, FAIL, "can't read 'huge' object's data from the file") /* Check for I/O pipeline filter on heap */ - if(hdr->filter_len > 0) { - H5Z_cb_t filter_cb; /* Filter callback structure */ - size_t read_size; /* Object's size in the file */ - size_t nbytes; /* Number of bytes used */ + if (hdr->filter_len > 0) { + H5Z_cb_t filter_cb; /* Filter callback structure */ + size_t read_size; /* Object's size in the file */ + size_t nbytes; /* Number of bytes used */ /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* De-filter the object */ read_size = nbytes = obj_size; - if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, &read_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, + &read_size, &read_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "input filter failed") obj_size = nbytes; } /* end if */ /* Perform correct operation on buffer read in */ - if(is_read) { + if (is_read) { /* Copy object to user's buffer if there's filters on heap data */ /* (if there's no filters, the object was read directly into the user's buffer) */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) H5MM_memcpy(op_data, read_buf, (size_t)obj_size); } /* end if */ else { /* Call the user's 'op' callback */ - if(op(read_buf, (size_t)obj_size, op_data) < 0) { + if (op(read_buf, (size_t)obj_size, op_data) < 0) { /* Release buffer */ read_buf = H5MM_xfree(read_buf); /* Indicate error */ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed") } /* end if */ - } /* end if */ + } /* end if */ done: /* Release the buffer for reading */ - if(read_buf && read_buf != op_data) + if (read_buf && read_buf != op_data) read_buf = H5MM_xfree(read_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_op_real() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_write * @@ -837,9 +836,9 @@ done: herr_t H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) { - haddr_t obj_addr; /* Object's address in the file */ - size_t obj_size; /* Object's size in the file */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t obj_addr; /* Object's address in the file */ + size_t obj_size; /* Object's size in the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -851,14 +850,14 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) HDassert(obj); /* Check for filters on the heap */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "modifying 'huge' object with filters not supported yet") /* Skip over the flag byte */ id++; /* Check for 'huge' object ID that encodes address & length directly */ - if(hdr->huge_ids_direct) { + if (hdr->huge_ids_direct) { /* Retrieve the object's address and length (common) */ H5F_addr_decode(hdr->f, &id, &obj_addr); H5F_DECODE_LENGTH(hdr->f, id, obj_size); @@ -871,17 +870,18 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ /* Get ID for looking up 'huge' object in v2 B-tree */ UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -891,14 +891,13 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) /* Write the object's data to the file */ /* (writes directly from application's buffer) */ - if(H5F_block_write(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, obj_size, obj) < 0) + if (H5F_block_write(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, obj_size, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "writing 'huge' object to file failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_write() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_read * @@ -915,7 +914,7 @@ done: herr_t H5HF__huge_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -927,14 +926,13 @@ H5HF__huge_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) HDassert(obj); /* Call the internal 'op' routine */ - if(H5HF__huge_op_real(hdr, id, TRUE, NULL, obj) < 0) + if (H5HF__huge_op_real(hdr, id, TRUE, NULL, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_read() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_op * @@ -949,10 +947,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, - void *op_data) +H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -964,14 +961,13 @@ H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, HDassert(op); /* Call the internal 'op' routine routine */ - if(H5HF__huge_op_real(hdr, id, FALSE, op, op_data) < 0) + if (H5HF__huge_op_real(hdr, id, FALSE, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_op() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_remove * @@ -988,8 +984,8 @@ done: herr_t H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) { - H5HF_huge_remove_ud_t udata; /* User callback data for v2 B-tree remove call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t udata; /* User callback data for v2 B-tree remove call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1001,10 +997,11 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) HDassert(id); /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ /* Skip over the flag byte */ @@ -1014,9 +1011,9 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) udata.hdr = hdr; /* Check for 'huge' object ID that encodes address & length directly */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { - H5HF_huge_bt2_filt_dir_rec_t search_rec; /* Record for searching for object */ + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) { + H5HF_huge_bt2_filt_dir_rec_t search_rec; /* Record for searching for object */ /* Retrieve the object's address and length */ /* (used as key in v2 B-tree record) */ @@ -1025,11 +1022,11 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_dir_remove, &udata) < 0) + if (H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_dir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end if */ else { - H5HF_huge_bt2_dir_rec_t search_rec; /* Record for searching for object */ + H5HF_huge_bt2_dir_rec_t search_rec; /* Record for searching for object */ /* Retrieve the object's address and length */ /* (used as key in v2 B-tree record) */ @@ -1038,48 +1035,47 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_dir_remove, &udata) < 0) + if (H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_dir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end else */ - } /* end if */ + } /* end if */ else { - if(hdr->filter_len > 0) { - H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ + if (hdr->filter_len > 0) { + H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_remove, &udata) < 0) + if (H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end if */ else { - H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ + H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_remove, &udata) < 0) + if (H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end else */ - } /* end else */ + } /* end else */ /* Update statistics about heap */ hdr->huge_size -= udata.obj_len; hdr->huge_nobjs--; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_term * @@ -1096,7 +1092,7 @@ done: herr_t H5HF__huge_term(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1106,12 +1102,12 @@ H5HF__huge_term(H5HF_hdr_t *hdr) HDassert(hdr); /* Check if v2 B-tree index is open */ - if(hdr->huge_bt2) { + if (hdr->huge_bt2) { /* Sanity check */ HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); /* Close v2 B-tree index */ - if(H5B2_close(hdr->huge_bt2) < 0) + if (H5B2_close(hdr->huge_bt2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree") hdr->huge_bt2 = NULL; } /* end if */ @@ -1119,22 +1115,22 @@ H5HF__huge_term(H5HF_hdr_t *hdr) /* Check if there are no more 'huge' objects in the heap and delete the * v2 B-tree that tracks them, if so */ - if(H5F_addr_defined(hdr->huge_bt2_addr) && hdr->huge_nobjs == 0) { + if (H5F_addr_defined(hdr->huge_bt2_addr) && hdr->huge_nobjs == 0) { /* Sanity check */ HDassert(hdr->huge_size == 0); /* Delete the v2 B-tree */ /* (any v2 B-tree class will work here) */ - if(H5B2_delete(hdr->f, hdr->huge_bt2_addr, hdr->f, NULL, NULL) < 0) + if (H5B2_delete(hdr->f, hdr->huge_bt2_addr, hdr->f, NULL, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") /* Reset the information about 'huge' objects in the file */ - hdr->huge_bt2_addr = HADDR_UNDEF; - hdr->huge_next_id = 0; + hdr->huge_bt2_addr = HADDR_UNDEF; + hdr->huge_next_id = 0; hdr->huge_ids_wrapped = FALSE; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end if */ @@ -1142,7 +1138,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_term() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_delete * @@ -1160,9 +1155,9 @@ done: herr_t H5HF__huge_delete(H5HF_hdr_t *hdr) { - H5HF_huge_remove_ud_t udata; /* User callback data for v2 B-tree remove call */ - H5B2_remove_t op; /* Callback for v2 B-tree removal */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t udata; /* User callback data for v2 B-tree remove call */ + H5B2_remove_t op; /* Callback for v2 B-tree removal */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1178,24 +1173,23 @@ H5HF__huge_delete(H5HF_hdr_t *hdr) udata.hdr = hdr; /* Set the v2 B-tree callback operator */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) op = H5HF__huge_bt2_filt_dir_remove; else op = H5HF__huge_bt2_dir_remove; } /* end if */ else { - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) op = H5HF__huge_bt2_filt_indir_remove; else op = H5HF__huge_bt2_indir_remove; } /* end else */ /* Delete the v2 B-tree */ - if(H5B2_delete(hdr->f, hdr->huge_bt2_addr, hdr->f, op, &udata) < 0) + if (H5B2_delete(hdr->f, hdr->huge_bt2_addr, hdr->f, op, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_delete() */ - diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 07eb9cd..94d7bcb 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -26,34 +26,30 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -62,7 +58,6 @@ static herr_t H5HF__iblock_unpin(H5HF_indirect_t *iblock); static herr_t H5HF__man_iblock_root_halve(H5HF_indirect_t *root_iblock); static herr_t H5HF__man_iblock_root_revert(H5HF_indirect_t *root_iblock); - /*********************/ /* Package Variables */ /*********************/ @@ -79,18 +74,14 @@ H5FL_SEQ_DEFINE(H5HF_indirect_filt_ent_t); /* Declare a free list to manage the H5HF_indirect_t * sequence information */ H5FL_SEQ_DEFINE(H5HF_indirect_ptr_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF__iblock_pin * @@ -107,7 +98,7 @@ H5FL_SEQ_DEFINE(H5HF_indirect_ptr_t); static herr_t H5HF__iblock_pin(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -115,22 +106,22 @@ H5HF__iblock_pin(H5HF_indirect_t *iblock) HDassert(iblock); /* Mark block as un-evictable */ - if(H5AC_pin_protected_entry(iblock) < 0) + if (H5AC_pin_protected_entry(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin fractal heap indirect block") /* If this indirect block has a parent, update it's child iblock pointer */ - if(iblock->parent) { - H5HF_indirect_t *par_iblock = iblock->parent; /* Parent indirect block */ - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + if (iblock->parent) { + H5HF_indirect_t *par_iblock = iblock->parent; /* Parent indirect block */ + unsigned indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); - HDassert(iblock->par_entry >= (iblock->hdr->man_dtable.max_direct_rows - * iblock->hdr->man_dtable.cparam.width)); + HDassert(iblock->par_entry >= + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width)); /* Compute index in parent's child iblock pointer array */ - indir_idx = iblock->par_entry - (iblock->hdr->man_dtable.max_direct_rows - * iblock->hdr->man_dtable.cparam.width); + indir_idx = iblock->par_entry - + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width); /* Set pointer to pinned indirect block in parent */ HDassert(par_iblock->child_iblocks[indir_idx] == NULL); @@ -138,12 +129,12 @@ H5HF__iblock_pin(H5HF_indirect_t *iblock) } /* end if */ else { /* Check for pinning the root indirect block */ - if(iblock->block_off == 0) { + if (iblock->block_off == 0) { /* Sanity check - shouldn't be recursively pinning root indirect block */ HDassert(0 == (iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED)); /* Check if we should set the root iblock pointer */ - if(0 == iblock->hdr->root_iblock_flags) { + if (0 == iblock->hdr->root_iblock_flags) { HDassert(NULL == iblock->hdr->root_iblock); iblock->hdr->root_iblock = iblock; } /* end if */ @@ -151,13 +142,12 @@ H5HF__iblock_pin(H5HF_indirect_t *iblock) /* Indicate that the root indirect block is pinned */ iblock->hdr->root_iblock_flags |= H5HF_ROOT_IBLOCK_PINNED; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__iblock_pin() */ - /*------------------------------------------------------------------------- * Function: H5HF__iblock_unpin * @@ -174,7 +164,7 @@ done: static herr_t H5HF__iblock_unpin(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -182,14 +172,13 @@ H5HF__iblock_unpin(H5HF_indirect_t *iblock) HDassert(iblock); /* Mark block as evictable again */ - if(H5AC_unpin_entry(iblock) < 0) + if (H5AC_unpin_entry(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap indirect block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__iblock_unpin() */ - /*------------------------------------------------------------------------- * Function: H5HF_iblock_incr * @@ -206,7 +195,7 @@ done: herr_t H5HF_iblock_incr(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -215,8 +204,8 @@ H5HF_iblock_incr(H5HF_indirect_t *iblock) HDassert(iblock->block_off == 0 || iblock->parent); /* Mark block as un-evictable when a child block is depending on it */ - if(iblock->rc == 0) - if(H5HF__iblock_pin(iblock) < 0) + if (iblock->rc == 0) + if (H5HF__iblock_pin(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin fractal heap indirect block") /* Increment reference count on shared indirect block */ @@ -226,7 +215,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_iblock_incr() */ - /*------------------------------------------------------------------------- * Function: H5HF__iblock_decr * @@ -243,7 +231,7 @@ done: herr_t H5HF__iblock_decr(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -254,21 +242,21 @@ H5HF__iblock_decr(H5HF_indirect_t *iblock) iblock->rc--; /* Check for last reference to block */ - if(iblock->rc == 0) { + if (iblock->rc == 0) { /* If this indirect block has a parent, reset it's child iblock pointer */ - if(iblock->parent) { - H5HF_indirect_t *par_iblock = iblock->parent; /* Parent indirect block */ - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + if (iblock->parent) { + H5HF_indirect_t *par_iblock = iblock->parent; /* Parent indirect block */ + unsigned indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); - HDassert(iblock->par_entry >= (iblock->hdr->man_dtable.max_direct_rows - * iblock->hdr->man_dtable.cparam.width)); + HDassert(iblock->par_entry >= + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width)); /* Compute index in parent's child iblock pointer array */ - indir_idx = iblock->par_entry - (iblock->hdr->man_dtable.max_direct_rows - * iblock->hdr->man_dtable.cparam.width); + indir_idx = iblock->par_entry - + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width); /* Reset pointer to pinned child indirect block in parent */ HDassert(par_iblock->child_iblocks[indir_idx]); @@ -276,39 +264,38 @@ H5HF__iblock_decr(H5HF_indirect_t *iblock) } /* end if */ else { /* Check for root indirect block */ - if(iblock->block_off == 0) { - /* Sanity check - shouldn't be recursively unpinning root indirect block */ - HDassert(iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED); - - /* Check if we should reset the root iblock pointer */ - if(H5HF_ROOT_IBLOCK_PINNED == iblock->hdr->root_iblock_flags) { - HDassert(NULL != iblock->hdr->root_iblock); - iblock->hdr->root_iblock = NULL; - } /* end if */ + if (iblock->block_off == 0) { + /* Sanity check - shouldn't be recursively unpinning root indirect block */ + HDassert(iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED); + + /* Check if we should reset the root iblock pointer */ + if (H5HF_ROOT_IBLOCK_PINNED == iblock->hdr->root_iblock_flags) { + HDassert(NULL != iblock->hdr->root_iblock); + iblock->hdr->root_iblock = NULL; + } /* end if */ - /* Indicate that the root indirect block is unpinned */ - iblock->hdr->root_iblock_flags &= (unsigned)(~(H5HF_ROOT_IBLOCK_PINNED)); + /* Indicate that the root indirect block is unpinned */ + iblock->hdr->root_iblock_flags &= (unsigned)(~(H5HF_ROOT_IBLOCK_PINNED)); } /* end if */ - } /* end else */ + } /* end else */ /* Check if the block is still in the cache */ - if(!iblock->removed_from_cache) { + if (!iblock->removed_from_cache) { /* Unpin the indirect block, making it evictable again */ - if(H5HF__iblock_unpin(iblock) < 0) + if (H5HF__iblock_unpin(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap indirect block") } /* end if */ else { /* Destroy the indirect block */ - if(H5HF_man_iblock_dest(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") + if (H5HF_man_iblock_dest(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__iblock_decr() */ - /*------------------------------------------------------------------------- * Function: H5HF_iblock_dirty * @@ -325,7 +312,7 @@ done: herr_t H5HF_iblock_dirty(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -333,14 +320,13 @@ H5HF_iblock_dirty(H5HF_indirect_t *iblock) HDassert(iblock); /* Mark indirect block as dirty in cache */ - if(H5AC_mark_entry_dirty(iblock) < 0) + if (H5AC_mark_entry_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark fractal heap indirect block as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_iblock_dirty() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_root_create * @@ -357,19 +343,19 @@ done: herr_t H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, size_t min_dblock_size) { - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - haddr_t iblock_addr; /* Indirect block's address */ - hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ - hbool_t have_direct_block; /* Flag to indicate a direct block already exists */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - unsigned nrows; /* Number of rows for root indirect block */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + haddr_t iblock_addr; /* Indirect block's address */ + hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ + hbool_t have_direct_block; /* Flag to indicate a direct block already exists */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + unsigned nrows; /* Number of rows for root indirect block */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check for allocating entire root indirect block initially */ - if(hdr->man_dtable.cparam.start_root_rows == 0) + if (hdr->man_dtable.cparam.start_root_rows == 0) nrows = hdr->man_dtable.max_root_rows; else { unsigned rows_needed; /* Number of rows needed to get to direct block size */ @@ -377,113 +363,121 @@ H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, size_t min_dblock_size) nrows = hdr->man_dtable.cparam.start_root_rows; - block_row_off = H5VM_log2_of2((uint32_t)min_dblock_size) - H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size); - if(block_row_off > 0) - block_row_off++; /* Account for the pair of initial rows of the initial block size */ + block_row_off = H5VM_log2_of2((uint32_t)min_dblock_size) - + H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size); + if (block_row_off > 0) + block_row_off++; /* Account for the pair of initial rows of the initial block size */ rows_needed = 1 + block_row_off; - if(nrows < rows_needed) + if (nrows < rows_needed) nrows = rows_needed; } /* end else */ /* Allocate root indirect block */ - if(H5HF__man_iblock_create(hdr, NULL, 0, nrows, hdr->man_dtable.max_root_rows, &iblock_addr) < 0) + if (H5HF__man_iblock_create(hdr, NULL, 0, nrows, hdr->man_dtable.max_root_rows, &iblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap indirect block") /* Move current direct block (used as root) into new indirect block */ /* Lock new indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, NULL, 0, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, NULL, 0, FALSE, + H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Check if there's already a direct block as root) */ have_direct_block = H5F_addr_defined(hdr->man_dtable.table_addr); - if(have_direct_block) { - H5HF_direct_t *dblock; /* Pointer to direct block to query */ + if (have_direct_block) { + H5HF_direct_t *dblock; /* Pointer to direct block to query */ /* Lock first (root) direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, hdr->man_dtable.table_addr, hdr->man_dtable.cparam.start_block_size, NULL, 0, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, hdr->man_dtable.table_addr, + hdr->man_dtable.cparam.start_block_size, NULL, 0, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block") /* Attach direct block to new root indirect block */ - dblock->parent = iblock; + dblock->parent = iblock; dblock->par_entry = 0; /* Destroy flush dependency between direct block and header */ - if(H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) + if (H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") dblock->fd_parent = NULL; /* Create flush dependency between direct block and new root indirect block */ - if(H5AC_create_flush_dependency(iblock, dblock) < 0) + if (H5AC_create_flush_dependency(iblock, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") dblock->fd_parent = iblock; - if(H5HF_man_iblock_attach(iblock, 0, hdr->man_dtable.table_addr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't attach root direct block to parent indirect block") + if (H5HF_man_iblock_attach(iblock, 0, hdr->man_dtable.table_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, + "can't attach root direct block to parent indirect block") /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Set the pipeline filter information from the header */ - iblock->filt_ents[0].size = hdr->pline_root_direct_size; + iblock->filt_ents[0].size = hdr->pline_root_direct_size; iblock->filt_ents[0].filter_mask = hdr->pline_root_direct_filter_mask; /* Reset the header's pipeline information */ - hdr->pline_root_direct_size = 0; + hdr->pline_root_direct_size = 0; hdr->pline_root_direct_filter_mask = 0; } /* end if */ /* Scan free space sections to set any 'parent' pointers to new indirect block */ - if(H5HF__space_create_root(hdr, iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set free space section info to new root indirect block") + if (H5HF__space_create_root(hdr, iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, + "can't set free space section info to new root indirect block") /* Unlock first (previously the root) direct block */ - if(H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, hdr->man_dtable.table_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, hdr->man_dtable.table_addr, dblock, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") dblock = NULL; } /* end if */ /* Start iterator at correct location */ - if(H5HF_hdr_start_iter(hdr, iblock, (hsize_t)(have_direct_block ? hdr->man_dtable.cparam.start_block_size : 0), have_direct_block) < 0) + if (H5HF_hdr_start_iter(hdr, iblock, + (hsize_t)(have_direct_block ? hdr->man_dtable.cparam.start_block_size : 0), + have_direct_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize block iterator") /* Check for skipping over direct blocks, in order to get to large enough block */ - if(min_dblock_size > hdr->man_dtable.cparam.start_block_size) + if (min_dblock_size > hdr->man_dtable.cparam.start_block_size) /* Add skipped blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, iblock, have_direct_block, - ((nrows - 1) * hdr->man_dtable.cparam.width) - have_direct_block) < 0) + if (H5HF__hdr_skip_blocks(hdr, iblock, have_direct_block, + ((nrows - 1) * hdr->man_dtable.cparam.width) - have_direct_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") /* Mark indirect block as modified */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF_iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") /* Unprotect root indirect block (it's pinned by the iterator though) */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__DIRTIED_FLAG, did_protect) < 0) + if (H5HF__man_iblock_unprotect(iblock, H5AC__DIRTIED_FLAG, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; /* Point heap header at new indirect block */ hdr->man_dtable.curr_root_rows = nrows; - hdr->man_dtable.table_addr = iblock_addr; + hdr->man_dtable.table_addr = iblock_addr; /* Compute free space in direct blocks referenced from entries in root indirect block */ acc_dblock_free = 0; - for(u = 0; u < nrows; u++) + for (u = 0; u < nrows; u++) acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[u] * hdr->man_dtable.cparam.width; /* Account for potential initial direct block */ - if(have_direct_block) + if (have_direct_block) acc_dblock_free -= hdr->man_dtable.row_tot_dblock_free[0]; /* Extend heap to cover new root indirect block */ - if(H5HF_hdr_adjust_heap(hdr, hdr->man_dtable.row_block_off[nrows], (hssize_t)acc_dblock_free) < 0) + if (H5HF_hdr_adjust_heap(hdr, hdr->man_dtable.row_block_off[nrows], (hssize_t)acc_dblock_free) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "can't increase space to cover root direct block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_create() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_root_double * @@ -500,25 +494,25 @@ done: herr_t H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size) { - H5HF_indirect_t *iblock; /* Pointer to root indirect block */ - haddr_t new_addr; /* New address of indirect block */ - hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ - hsize_t next_size; /* The previous value of the "next size" for the new block iterator */ - hsize_t old_iblock_size; /* Old size of indirect block */ - unsigned next_row; /* The next row to allocate block in */ - unsigned next_entry; /* The previous value of the "next entry" for the new block iterator */ - unsigned new_next_entry = 0;/* The new value of the "next entry" for the new block iterator */ - unsigned min_nrows = 0; /* Min. # of direct rows */ - unsigned old_nrows; /* Old # of rows */ - unsigned new_nrows; /* New # of rows */ - hbool_t skip_direct_rows = FALSE; /* Whether we are skipping direct rows */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Pointer to root indirect block */ + haddr_t new_addr; /* New address of indirect block */ + hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ + hsize_t next_size; /* The previous value of the "next size" for the new block iterator */ + hsize_t old_iblock_size; /* Old size of indirect block */ + unsigned next_row; /* The next row to allocate block in */ + unsigned next_entry; /* The previous value of the "next entry" for the new block iterator */ + unsigned new_next_entry = 0; /* The new value of the "next entry" for the new block iterator */ + unsigned min_nrows = 0; /* Min. # of direct rows */ + unsigned old_nrows; /* Old # of rows */ + unsigned new_nrows; /* New # of rows */ + hbool_t skip_direct_rows = FALSE; /* Whether we are skipping direct rows */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get "new block" iterator information */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + if (H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") next_size = hdr->man_dtable.row_block_size[next_row]; @@ -530,7 +524,7 @@ H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size) old_nrows = iblock->nrows; /* Check for skipping over direct block rows */ - if(iblock->nrows < hdr->man_dtable.max_direct_rows && min_dblock_size > next_size) { + if (iblock->nrows < hdr->man_dtable.max_direct_rows && min_dblock_size > next_size) { /* Sanity check */ HDassert(min_dblock_size > hdr->man_dtable.cparam.start_block_size); @@ -549,117 +543,124 @@ H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size) /* Check if the indirect block is NOT currently allocated in temp. file space */ /* (temp. file space does not need to be freed) */ - if(!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) + if (!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) /* Free previous indirect block disk space */ - if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) + if (H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block file space") /* Compute size of buffer needed for new indirect block */ - iblock->nrows = new_nrows; + iblock->nrows = new_nrows; old_iblock_size = iblock->size; - iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); + iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); /* Allocate [temporary] space for the new indirect block on disk */ - if(H5F_USE_TMP_SPACE(hdr->f)) { - if(HADDR_UNDEF == (new_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) + if (H5F_USE_TMP_SPACE(hdr->f)) { + if (HADDR_UNDEF == (new_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") } /* end if */ else { - if(HADDR_UNDEF == (new_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) + if (HADDR_UNDEF == (new_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") } /* end else */ /* Resize pinned indirect block in the cache, if its changed size */ - if(old_iblock_size != iblock->size) { - if(H5AC_resize_entry(iblock, (size_t)iblock->size) < 0) + if (old_iblock_size != iblock->size) { + if (H5AC_resize_entry(iblock, (size_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize fractal heap indirect block") } /* end if */ /* Move object in cache, if it actually was relocated */ - if(H5F_addr_ne(iblock->addr, new_addr)) { - if(H5AC_move_entry(hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, new_addr) < 0) + if (H5F_addr_ne(iblock->addr, new_addr)) { + if (H5AC_move_entry(hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, new_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move fractal heap root indirect block") iblock->addr = new_addr; } /* end if */ /* Re-allocate child block entry array */ - if(NULL == (iblock->ents = H5FL_SEQ_REALLOC(H5HF_indirect_ent_t, iblock->ents, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->ents = H5FL_SEQ_REALLOC(H5HF_indirect_ent_t, iblock->ents, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for direct entries") /* Check for skipping over rows and add free section for skipped rows */ - if(skip_direct_rows) + if (skip_direct_rows) /* Add skipped blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (new_next_entry - next_entry)) < 0) + if (H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (new_next_entry - next_entry)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") /* Initialize new direct block entries in rows added */ acc_dblock_free = 0; - for(u = (old_nrows * hdr->man_dtable.cparam.width); u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { - unsigned row = (unsigned)(u / hdr->man_dtable.cparam.width); /* Row for current entry */ + for (u = (old_nrows * hdr->man_dtable.cparam.width); u < (iblock->nrows * hdr->man_dtable.cparam.width); + u++) { + unsigned row = (unsigned)(u / hdr->man_dtable.cparam.width); /* Row for current entry */ iblock->ents[u].addr = HADDR_UNDEF; acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[row]; } /* end for */ /* Check for needing to re-allocate filtered entry array */ - if(hdr->filter_len > 0 && old_nrows < hdr->man_dtable.max_direct_rows) { - unsigned dir_rows; /* Number of direct rows in this indirect block */ + if (hdr->filter_len > 0 && old_nrows < hdr->man_dtable.max_direct_rows) { + unsigned dir_rows; /* Number of direct rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ dir_rows = MIN(iblock->nrows, hdr->man_dtable.max_direct_rows); HDassert(dir_rows > old_nrows); /* Re-allocate filtered direct block entry array */ - if(NULL == (iblock->filt_ents = H5FL_SEQ_REALLOC(H5HF_indirect_filt_ent_t, iblock->filt_ents, (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->filt_ents = H5FL_SEQ_REALLOC(H5HF_indirect_filt_ent_t, iblock->filt_ents, + (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for filtered direct entries") /* Initialize new entries allocated */ - for(u = (old_nrows * hdr->man_dtable.cparam.width); u < (dir_rows * hdr->man_dtable.cparam.width); u++) { - iblock->filt_ents[u].size = 0; + for (u = (old_nrows * hdr->man_dtable.cparam.width); u < (dir_rows * hdr->man_dtable.cparam.width); + u++) { + iblock->filt_ents[u].size = 0; iblock->filt_ents[u].filter_mask = 0; } /* end for */ - } /* end if */ + } /* end if */ /* Check for needing to re-allocate child iblock pointer array */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned indir_rows; /* Number of indirect rows in this indirect block */ - unsigned old_indir_rows; /* Previous number of indirect rows in this indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned indir_rows; /* Number of indirect rows in this indirect block */ + unsigned old_indir_rows; /* Previous number of indirect rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ indir_rows = iblock->nrows - hdr->man_dtable.max_direct_rows; /* Re-allocate child indirect block array */ - if(NULL == (iblock->child_iblocks = H5FL_SEQ_REALLOC(H5HF_indirect_ptr_t, iblock->child_iblocks, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == + (iblock->child_iblocks = H5FL_SEQ_REALLOC(H5HF_indirect_ptr_t, iblock->child_iblocks, + (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for filtered direct entries") /* Compute the previous # of indirect rows in this block */ - if(old_nrows < hdr->man_dtable.max_direct_rows) + if (old_nrows < hdr->man_dtable.max_direct_rows) old_indir_rows = 0; else old_indir_rows = old_nrows - hdr->man_dtable.max_direct_rows; /* Initialize new entries allocated */ - for(u = (old_indir_rows * hdr->man_dtable.cparam.width); u < (indir_rows * hdr->man_dtable.cparam.width); u++) + for (u = (old_indir_rows * hdr->man_dtable.cparam.width); + u < (indir_rows * hdr->man_dtable.cparam.width); u++) iblock->child_iblocks[u] = NULL; } /* end if */ /* Mark indirect block as dirty */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF_iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") /* Update other shared header info */ hdr->man_dtable.curr_root_rows = new_nrows; - hdr->man_dtable.table_addr = new_addr; + hdr->man_dtable.table_addr = new_addr; /* Extend heap to cover new root indirect block */ - if(H5HF_hdr_adjust_heap(hdr, 2 * hdr->man_dtable.row_block_off[new_nrows - 1], (hssize_t)acc_dblock_free) < 0) + if (H5HF_hdr_adjust_heap(hdr, 2 * hdr->man_dtable.row_block_off[new_nrows - 1], + (hssize_t)acc_dblock_free) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "can't increase space to cover root direct block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_double() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_root_halve * @@ -676,15 +677,15 @@ done: static herr_t H5HF__man_iblock_root_halve(H5HF_indirect_t *iblock) { - H5HF_hdr_t *hdr = iblock->hdr; /* Pointer to heap header */ - haddr_t new_addr; /* New address of indirect block */ - hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ - hsize_t old_size; /* Old size of indirect block */ - unsigned max_child_row; /* Row for max. child entry */ - unsigned old_nrows; /* Old # of rows */ - unsigned new_nrows; /* New # of rows */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = iblock->hdr; /* Pointer to heap header */ + haddr_t new_addr; /* New address of indirect block */ + hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ + hsize_t old_size; /* Old size of indirect block */ + unsigned max_child_row; /* Row for max. child entry */ + unsigned old_nrows; /* Old # of rows */ + unsigned new_nrows; /* New # of rows */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -701,90 +702,97 @@ H5HF__man_iblock_root_halve(H5HF_indirect_t *iblock) /* Check if the indirect block is NOT currently allocated in temp. file space */ /* (temp. file space does not need to be freed) */ - if(!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) + if (!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) /* Free previous indirect block disk space */ - if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) + if (H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block file space") /* Compute free space in rows to delete */ acc_dblock_free = 0; - for(u = new_nrows; u < iblock->nrows; u++) + for (u = new_nrows; u < iblock->nrows; u++) acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[u] * hdr->man_dtable.cparam.width; /* Compute size of buffer needed for new indirect block */ - old_nrows = iblock->nrows; + old_nrows = iblock->nrows; iblock->nrows = new_nrows; - old_size = iblock->size; - iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); + old_size = iblock->size; + iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); /* Allocate [temporary] space for the new indirect block on disk */ - if(H5F_USE_TMP_SPACE(hdr->f)) { - if(HADDR_UNDEF == (new_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) + if (H5F_USE_TMP_SPACE(hdr->f)) { + if (HADDR_UNDEF == (new_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") } /* end if */ else { - if(HADDR_UNDEF == (new_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) + if (HADDR_UNDEF == (new_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") } /* end else */ /* Resize pinned indirect block in the cache, if it has changed size */ - if(old_size != iblock->size) { - if(H5AC_resize_entry(iblock, (size_t)iblock->size) < 0) + if (old_size != iblock->size) { + if (H5AC_resize_entry(iblock, (size_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize fractal heap indirect block") } /* end if */ /* Move object in cache, if it actually was relocated */ - if(H5F_addr_ne(iblock->addr, new_addr)) { - if(H5AC_move_entry(hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, new_addr) < 0) + if (H5F_addr_ne(iblock->addr, new_addr)) { + if (H5AC_move_entry(hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, new_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSPLIT, FAIL, "unable to move fractal heap root indirect block") iblock->addr = new_addr; } /* end if */ /* Re-allocate child block entry array */ - if(NULL == (iblock->ents = H5FL_SEQ_REALLOC(H5HF_indirect_ent_t, iblock->ents, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->ents = H5FL_SEQ_REALLOC(H5HF_indirect_ent_t, iblock->ents, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct entries") /* Check for needing to re-allocate filtered entry array */ - if(hdr->filter_len > 0 && new_nrows < hdr->man_dtable.max_direct_rows) { + if (hdr->filter_len > 0 && new_nrows < hdr->man_dtable.max_direct_rows) { /* Re-allocate filtered direct block entry array */ - if(NULL == (iblock->filt_ents = H5FL_SEQ_REALLOC(H5HF_indirect_filt_ent_t, iblock->filt_ents, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + if (NULL == + (iblock->filt_ents = H5FL_SEQ_REALLOC(H5HF_indirect_filt_ent_t, iblock->filt_ents, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for filtered direct entries") } /* end if */ /* Check for needing to re-allocate child iblock pointer array */ - if(old_nrows > hdr->man_dtable.max_direct_rows) { + if (old_nrows > hdr->man_dtable.max_direct_rows) { /* Check for shrinking away child iblock pointer array */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned indir_rows; /* Number of indirect rows in this indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned indir_rows; /* Number of indirect rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ indir_rows = iblock->nrows - hdr->man_dtable.max_direct_rows; /* Re-allocate child indirect block array */ - if(NULL == (iblock->child_iblocks = H5FL_SEQ_REALLOC(H5HF_indirect_ptr_t, iblock->child_iblocks, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for filtered direct entries") + if (NULL == (iblock->child_iblocks = + H5FL_SEQ_REALLOC(H5HF_indirect_ptr_t, iblock->child_iblocks, + (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, + "memory allocation failed for filtered direct entries") } /* end if */ else - iblock->child_iblocks = (H5HF_indirect_ptr_t *)H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); + iblock->child_iblocks = + (H5HF_indirect_ptr_t *)H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); } /* end if */ /* Mark indirect block as dirty */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF_iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") /* Update other shared header info */ hdr->man_dtable.curr_root_rows = new_nrows; - hdr->man_dtable.table_addr = new_addr; + hdr->man_dtable.table_addr = new_addr; /* Shrink heap to only cover new root indirect block */ - if(H5HF_hdr_adjust_heap(hdr, 2 * hdr->man_dtable.row_block_off[new_nrows - 1], -(hssize_t)acc_dblock_free) < 0) + if (H5HF_hdr_adjust_heap(hdr, 2 * hdr->man_dtable.row_block_off[new_nrows - 1], + -(hssize_t)acc_dblock_free) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce space to cover root direct block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_halve() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_root_revert * @@ -804,11 +812,11 @@ done: static herr_t H5HF__man_iblock_root_revert(H5HF_indirect_t *root_iblock) { - H5HF_hdr_t *hdr; /* Pointer to heap's header */ + H5HF_hdr_t * hdr; /* Pointer to heap's header */ H5HF_direct_t *dblock = NULL; /* Pointer to new root indirect block */ - haddr_t dblock_addr; /* Direct block's address in the file */ - size_t dblock_size; /* Direct block's size */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t dblock_addr; /* Direct block's address in the file */ + size_t dblock_size; /* Direct block's size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -818,63 +826,64 @@ H5HF__man_iblock_root_revert(H5HF_indirect_t *root_iblock) HDassert(root_iblock); /* Set up local convenience variables */ - hdr = root_iblock->hdr; + hdr = root_iblock->hdr; dblock_addr = root_iblock->ents[0].addr; dblock_size = hdr->man_dtable.cparam.start_block_size; /* Get pointer to last direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, root_iblock, 0, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, root_iblock, 0, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block") HDassert(dblock->parent == root_iblock); HDassert(dblock->par_entry == 0); /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Set the header's pipeline information from the indirect block */ - hdr->pline_root_direct_size = root_iblock->filt_ents[0].size; + hdr->pline_root_direct_size = root_iblock->filt_ents[0].size; hdr->pline_root_direct_filter_mask = root_iblock->filt_ents[0].filter_mask; } /* end if */ /* Destroy flush dependency between old root iblock and new root direct block */ - if(H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) + if (H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") dblock->fd_parent = NULL; /* Detach direct block from parent */ - if(H5HF__man_iblock_detach(dblock->parent, 0) < 0) + if (H5HF__man_iblock_detach(dblock->parent, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't detach direct block from parent indirect block") - dblock->parent = NULL; + dblock->parent = NULL; dblock->par_entry = 0; /* Create flush dependency between header and new root direct block */ - if(H5AC_create_flush_dependency(hdr, dblock) < 0) + if (H5AC_create_flush_dependency(hdr, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") dblock->fd_parent = hdr; /* Point root at direct block */ hdr->man_dtable.curr_root_rows = 0; - hdr->man_dtable.table_addr = dblock_addr; + hdr->man_dtable.table_addr = dblock_addr; /* Reset 'next block' iterator */ - if(H5HF_hdr_reset_iter(hdr, (hsize_t)dblock_size) < 0) + if (H5HF_hdr_reset_iter(hdr, (hsize_t)dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") /* Extend heap to just cover first direct block */ - if(H5HF_hdr_adjust_heap(hdr, (hsize_t)hdr->man_dtable.cparam.start_block_size, (hssize_t)hdr->man_dtable.row_tot_dblock_free[0]) < 0) + if (H5HF_hdr_adjust_heap(hdr, (hsize_t)hdr->man_dtable.cparam.start_block_size, + (hssize_t)hdr->man_dtable.row_tot_dblock_free[0]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "can't increase space to cover root direct block") /* Scan free space sections to reset any 'parent' pointers */ - if(H5HF__space_revert_root(hdr) < 0) + if (H5HF__space_revert_root(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESET, FAIL, "can't reset free space section info") done: - if(dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_revert() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_alloc_row * @@ -894,11 +903,11 @@ done: herr_t H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, H5HF_free_section_t **sec_node) { - H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ + H5HF_indirect_t * iblock = NULL; /* Pointer to indirect block */ H5HF_free_section_t *old_sec_node = *sec_node; /* Pointer to old indirect section node */ - unsigned dblock_entry; /* Entry for direct block */ - hbool_t iblock_held = FALSE; /* Flag to indicate that indirect block is held */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned dblock_entry; /* Entry for direct block */ + hbool_t iblock_held = FALSE; /* Flag to indicate that indirect block is held */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -911,40 +920,40 @@ H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, H5HF_free_section_t **sec_node) /* Check for serialized row section, or serialized / deleted indirect * section under it. */ - if(old_sec_node->sect_info.state == H5FS_SECT_SERIALIZED - || (H5FS_SECT_SERIALIZED == old_sec_node->u.row.under->sect_info.state) - || (TRUE == old_sec_node->u.row.under->u.indirect.u.iblock->removed_from_cache)) + if (old_sec_node->sect_info.state == H5FS_SECT_SERIALIZED || + (H5FS_SECT_SERIALIZED == old_sec_node->u.row.under->sect_info.state) || + (TRUE == old_sec_node->u.row.under->u.indirect.u.iblock->removed_from_cache)) /* Revive row and / or indirect section */ - if(H5HF__sect_row_revive(hdr, old_sec_node) < 0) + if (H5HF__sect_row_revive(hdr, old_sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREVIVE, FAIL, "can't revive indirect section") /* Get a pointer to the indirect block covering the section */ - if(NULL == (iblock = H5HF_sect_row_get_iblock(old_sec_node))) + if (NULL == (iblock = H5HF_sect_row_get_iblock(old_sec_node))) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve indirect block for row section") /* Hold indirect block in memory, until direct block can point to it */ - if(H5HF_iblock_incr(iblock) < 0) + if (H5HF_iblock_incr(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") iblock_held = TRUE; /* Reduce (& possibly re-add) 'row' section */ - if(H5HF__sect_row_reduce(hdr, old_sec_node, &dblock_entry) < 0) + if (H5HF__sect_row_reduce(hdr, old_sec_node, &dblock_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce row section node") /* Create direct block & single section */ - if(H5HF__man_dblock_create(hdr, iblock, dblock_entry, NULL, sec_node) < 0) + if (H5HF__man_dblock_create(hdr, iblock, dblock_entry, NULL, sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap direct block") done: /* Release hold on indirect block */ - if(iblock_held) - if(H5HF__iblock_decr(iblock) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + if (iblock_held) + if (H5HF__iblock_decr(iblock) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_alloc_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_create * @@ -959,12 +968,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, - unsigned par_entry, unsigned nrows, unsigned max_rows, haddr_t *addr_p) +H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned par_entry, unsigned nrows, + unsigned max_rows, haddr_t *addr_p) { - H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -978,92 +987,100 @@ H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, /* * Allocate file and memory data structures. */ - if(NULL == (iblock = H5FL_MALLOC(H5HF_indirect_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap indirect block") + if (NULL == (iblock = H5FL_MALLOC(H5HF_indirect_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for fractal heap indirect block") /* Reset the metadata cache info for the heap header */ HDmemset(&iblock->cache_info, 0, sizeof(H5AC_info_t)); /* Share common heap information */ iblock->hdr = hdr; - if(H5HF_hdr_incr(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") + if (H5HF_hdr_incr(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") /* Set info for indirect block */ - iblock->rc = 0; - iblock->nrows = nrows; - iblock->max_rows = max_rows; + iblock->rc = 0; + iblock->nrows = nrows; + iblock->max_rows = max_rows; iblock->removed_from_cache = FALSE; /* Compute size of buffer needed for indirect block */ iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); /* Allocate child block entry array */ - if(NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block entries") + if (NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block entries") /* Initialize indirect block entry tables */ - for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) + for (u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) iblock->ents[u].addr = HADDR_UNDEF; /* Check for I/O filters to apply to this heap */ - if(hdr->filter_len > 0) { - unsigned dir_rows; /* Number of direct rows in this indirect block */ + if (hdr->filter_len > 0) { + unsigned dir_rows; /* Number of direct rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ dir_rows = MIN(iblock->nrows, hdr->man_dtable.max_direct_rows); /* Allocate & initialize indirect block filtered entry array */ - if(NULL == (iblock->filt_ents = H5FL_SEQ_CALLOC(H5HF_indirect_filt_ent_t, (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->filt_ents = H5FL_SEQ_CALLOC(H5HF_indirect_filt_ent_t, + (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block entries") } /* end if */ else iblock->filt_ents = NULL; /* Check if we have any indirect block children */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned indir_rows; /* Number of indirect rows in this indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned indir_rows; /* Number of indirect rows in this indirect block */ /* Compute the number of indirect rows for this indirect block */ indir_rows = iblock->nrows - hdr->man_dtable.max_direct_rows; /* Allocate & initialize child indirect block pointer array */ - if(NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC(H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC( + H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block entries") } /* end if */ else iblock->child_iblocks = NULL; /* Allocate [temporary] space for the indirect block on disk */ - if(H5F_USE_TMP_SPACE(hdr->f)) { - if(HADDR_UNDEF == (*addr_p = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") + if (H5F_USE_TMP_SPACE(hdr->f)) { + if (HADDR_UNDEF == (*addr_p = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap indirect block") } /* end if */ else { - if(HADDR_UNDEF == (*addr_p = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") + if (HADDR_UNDEF == (*addr_p = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap indirect block") } /* end else */ iblock->addr = *addr_p; /* Attach to parent indirect block, if there is one */ - iblock->parent = par_iblock; + iblock->parent = par_iblock; iblock->par_entry = par_entry; - if(iblock->parent) { + if (iblock->parent) { /* Attach new block to parent */ - if(H5HF_man_iblock_attach(iblock->parent, par_entry, *addr_p) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't attach indirect block to parent indirect block") + if (H5HF_man_iblock_attach(iblock->parent, par_entry, *addr_p) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, + "can't attach indirect block to parent indirect block") /* Compute the indirect block's offset in the heap's address space */ /* (based on parent's block offset) */ iblock->block_off = par_iblock->block_off; iblock->block_off += hdr->man_dtable.row_block_off[par_entry / hdr->man_dtable.cparam.width]; - iblock->block_off += hdr->man_dtable.row_block_size[par_entry / hdr->man_dtable.cparam.width] * (par_entry % hdr->man_dtable.cparam.width); + iblock->block_off += hdr->man_dtable.row_block_size[par_entry / hdr->man_dtable.cparam.width] * + (par_entry % hdr->man_dtable.cparam.width); /* Set indirect block parent as flush dependency parent */ iblock->fd_parent = par_iblock; } /* end if */ else { - iblock->block_off = 0; /* Must be the root indirect block... */ + iblock->block_off = 0; /* Must be the root indirect block... */ /* Set heap header as flush dependency parent */ iblock->fd_parent = hdr; @@ -1074,19 +1091,18 @@ H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, iblock->max_child = 0; /* Cache the new indirect block */ - if(H5AC_insert_entry(hdr->f, H5AC_FHEAP_IBLOCK, *addr_p, iblock, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap indirect block to cache") + if (H5AC_insert_entry(hdr->f, H5AC_FHEAP_IBLOCK, *addr_p, iblock, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap indirect block to cache") done: - if(ret_value < 0) - if(iblock) - if(H5HF_man_iblock_dest(iblock) < 0) + if (ret_value < 0) + if (iblock) + if (H5HF_man_iblock_dest(iblock) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_create() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_protect * @@ -1101,14 +1117,14 @@ done: *------------------------------------------------------------------------- */ H5HF_indirect_t * -H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, - hbool_t must_protect, unsigned flags, hbool_t *did_protect) +H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry, hbool_t must_protect, + unsigned flags, hbool_t *did_protect) { - H5HF_parent_t par_info; /* Parent info for loading block */ - H5HF_indirect_t *iblock = NULL; /* Indirect block from cache */ - hbool_t should_protect = FALSE; /* Whether we should protect the indirect block or not */ - H5HF_indirect_t *ret_value = NULL; /* Return value */ + H5HF_parent_t par_info; /* Parent info for loading block */ + H5HF_indirect_t *iblock = NULL; /* Indirect block from cache */ + hbool_t should_protect = FALSE; /* Whether we should protect the indirect block or not */ + H5HF_indirect_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1124,31 +1140,29 @@ H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Check if we are allowed to use existing pinned iblock pointer */ - if(!must_protect) { + if (!must_protect) { /* Check for this block already being pinned */ - if(par_iblock) { - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + if (par_iblock) { + unsigned indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); - HDassert(par_entry >= (hdr->man_dtable.max_direct_rows - * hdr->man_dtable.cparam.width)); + HDassert(par_entry >= (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)); /* Compute index in parent's child iblock pointer array */ - indir_idx = par_entry - (hdr->man_dtable.max_direct_rows - * hdr->man_dtable.cparam.width); + indir_idx = par_entry - (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width); /* Check for pointer to pinned indirect block in parent */ - if(par_iblock->child_iblocks[indir_idx]) + if (par_iblock->child_iblocks[indir_idx]) iblock = par_iblock->child_iblocks[indir_idx]; else should_protect = TRUE; } /* end if */ else { /* Check for root indirect block */ - if(H5F_addr_eq(iblock_addr, hdr->man_dtable.table_addr)) { + if (H5F_addr_eq(iblock_addr, hdr->man_dtable.table_addr)) { /* Check for valid pointer to pinned indirect block in root */ - if(H5HF_ROOT_IBLOCK_PINNED == hdr->root_iblock_flags) { + if (H5HF_ROOT_IBLOCK_PINNED == hdr->root_iblock_flags) { /* Sanity check */ HDassert(NULL != hdr->root_iblock); @@ -1161,40 +1175,41 @@ H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, should_protect = TRUE; } /* end else */ - } /* end if */ + } /* end if */ else should_protect = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Check for protecting indirect block */ - if(must_protect || should_protect) { + if (must_protect || should_protect) { H5HF_iblock_cache_ud_t cache_udata; /* User-data for callback */ /* Set up parent info */ - par_info.hdr = hdr; + par_info.hdr = hdr; par_info.iblock = par_iblock; - par_info.entry = par_entry; + par_info.entry = par_entry; /* Set up user data for protect call */ - cache_udata.f = hdr->f; + cache_udata.f = hdr->f; cache_udata.par_info = &par_info; - cache_udata.nrows = &iblock_nrows; + cache_udata.nrows = &iblock_nrows; /* Protect the indirect block */ - if(NULL == (iblock = (H5HF_indirect_t *)H5AC_protect(hdr->f, H5AC_FHEAP_IBLOCK, iblock_addr, &cache_udata, flags))) + if (NULL == (iblock = (H5HF_indirect_t *)H5AC_protect(hdr->f, H5AC_FHEAP_IBLOCK, iblock_addr, + &cache_udata, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap indirect block") /* Set the indirect block's address */ iblock->addr = iblock_addr; /* Check for root indirect block */ - if(iblock->block_off == 0) { + if (iblock->block_off == 0) { /* Sanity check - shouldn't be recursively protecting root indirect block */ HDassert(0 == (hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PROTECTED)); /* Check if we should set the root iblock pointer */ - if(0 == hdr->root_iblock_flags) { + if (0 == hdr->root_iblock_flags) { HDassert(NULL == hdr->root_iblock); hdr->root_iblock = iblock; } /* end if */ @@ -1217,7 +1232,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_unprotect * @@ -1232,10 +1246,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, - hbool_t did_protect) +H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, hbool_t did_protect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1246,14 +1259,14 @@ H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, /* Check if we previously protected this indirect block */ /* (as opposed to using an existing pointer to a pinned child indirect block) */ - if(did_protect) { + if (did_protect) { /* Check for root indirect block */ - if(iblock->block_off == 0) { + if (iblock->block_off == 0) { /* Sanity check - shouldn't be recursively unprotecting root indirect block */ HDassert(iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PROTECTED); /* Check if we should reset the root iblock pointer */ - if(H5HF_ROOT_IBLOCK_PROTECTED == iblock->hdr->root_iblock_flags) { + if (H5HF_ROOT_IBLOCK_PROTECTED == iblock->hdr->root_iblock_flags) { HDassert(NULL != iblock->hdr->root_iblock); iblock->hdr->root_iblock = NULL; } /* end if */ @@ -1263,7 +1276,7 @@ H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, } /* end if */ /* Unprotect the indirect block */ - if(H5AC_unprotect(iblock->hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, iblock, cache_flags) < 0) + if (H5AC_unprotect(iblock->hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, iblock, cache_flags) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") } /* end if */ @@ -1271,7 +1284,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iblock_attach * @@ -1288,7 +1300,7 @@ done: herr_t H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1300,15 +1312,15 @@ H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_ad HDassert(!H5F_addr_defined(iblock->ents[entry].addr)); /* Increment the reference count on this indirect block */ - if(H5HF_iblock_incr(iblock) < 0) + if (H5HF_iblock_incr(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") /* Point at the child block */ iblock->ents[entry].addr = child_addr; /* Check for I/O filters on this heap */ - if(iblock->hdr->filter_len > 0) { - unsigned row; /* Row for entry */ + if (iblock->hdr->filter_len > 0) { + unsigned row; /* Row for entry */ /* Sanity check */ HDassert(iblock->filt_ents); @@ -1317,26 +1329,25 @@ H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_ad row = entry / iblock->hdr->man_dtable.cparam.width; /* If this is a direct block, set its initial size */ - if(row < iblock->hdr->man_dtable.max_direct_rows) + if (row < iblock->hdr->man_dtable.max_direct_rows) iblock->filt_ents[entry].size = iblock->hdr->man_dtable.row_block_size[row]; } /* end if */ /* Check for max. entry used */ - if(entry > iblock->max_child) + if (entry > iblock->max_child) iblock->max_child = entry; /* Increment the # of child blocks */ iblock->nchildren++; /* Mark indirect block as modified */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF_iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_attach() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_detach * @@ -1353,10 +1364,10 @@ done: herr_t H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) { - H5HF_hdr_t *hdr; /* Fractal heap header */ - H5HF_indirect_t *del_iblock = NULL; /* Pointer to protected indirect block, when deleting */ - unsigned row; /* Row for entry */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t * hdr; /* Fractal heap header */ + H5HF_indirect_t *del_iblock = NULL; /* Pointer to protected indirect block, when deleting */ + unsigned row; /* Row for entry */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1376,20 +1387,20 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) row = entry / hdr->man_dtable.cparam.width; /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Sanity check */ HDassert(iblock->filt_ents); /* If this is a direct block, reset its initial size */ - if(row < hdr->man_dtable.max_direct_rows) { - iblock->filt_ents[entry].size = 0; + if (row < hdr->man_dtable.max_direct_rows) { + iblock->filt_ents[entry].size = 0; iblock->filt_ents[entry].filter_mask = 0; } /* end if */ - } /* end if */ + } /* end if */ /* Check for indirect block being detached */ - if(row >= hdr->man_dtable.max_direct_rows) { - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + if (row >= hdr->man_dtable.max_direct_rows) { + unsigned indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(iblock->child_iblocks); @@ -1412,51 +1423,53 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) iblock->nchildren--; /* Reduce the max. entry used, if necessary */ - if(entry == iblock->max_child) { - if(iblock->nchildren > 0) - while(!H5F_addr_defined(iblock->ents[iblock->max_child].addr)) + if (entry == iblock->max_child) { + if (iblock->nchildren > 0) + while (!H5F_addr_defined(iblock->ents[iblock->max_child].addr)) iblock->max_child--; else iblock->max_child = 0; } /* end if */ /* If this is the root indirect block handle some special cases */ - if(iblock->block_off == 0) { + if (iblock->block_off == 0) { /* If the number of children drops to 1, and that child is the first * direct block in the heap, convert the heap back to using a root * direct block */ - if(iblock->nchildren == 1 && H5F_addr_defined(iblock->ents[0].addr)) - if(H5HF__man_iblock_root_revert(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't convert root indirect block back to root direct block") + if (iblock->nchildren == 1 && H5F_addr_defined(iblock->ents[0].addr)) + if (H5HF__man_iblock_root_revert(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, + "can't convert root indirect block back to root direct block") /* If the indirect block wasn't removed already (by reverting it) */ - if(!iblock->removed_from_cache) { + if (!iblock->removed_from_cache) { /* Check for reducing size of root indirect block */ - if(iblock->nchildren > 0 && hdr->man_dtable.cparam.start_root_rows != 0 - && entry > iblock->max_child) { - unsigned max_child_row; /* Row for max. child entry */ - - /* Compute information needed for determining whether to reduce size of root indirect block */ - max_child_row = iblock->max_child / hdr->man_dtable.cparam.width; - - /* Check if the root indirect block should be reduced */ - if(iblock->nrows > 1 && max_child_row <= (iblock->nrows / 2)) - if(H5HF__man_iblock_root_halve(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce size of root indirect block") + if (iblock->nchildren > 0 && hdr->man_dtable.cparam.start_root_rows != 0 && + entry > iblock->max_child) { + unsigned max_child_row; /* Row for max. child entry */ + + /* Compute information needed for determining whether to reduce size of root indirect block */ + max_child_row = iblock->max_child / hdr->man_dtable.cparam.width; + + /* Check if the root indirect block should be reduced */ + if (iblock->nrows > 1 && max_child_row <= (iblock->nrows / 2)) + if (H5HF__man_iblock_root_halve(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, + "can't reduce size of root indirect block") } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* If the indirect block wasn't removed already (by reverting it) */ - if(!iblock->removed_from_cache) { + if (!iblock->removed_from_cache) { /* Mark indirect block as modified */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF_iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") /* Check for last child being removed from indirect block */ - if(iblock->nchildren == 0) { - hbool_t did_protect = FALSE; /* Whether the indirect block was protected */ + if (iblock->nchildren == 0) { + hbool_t did_protect = FALSE; /* Whether the indirect block was protected */ /* If this indirect block's refcount is >1, then it's being deleted * from the fractal heap (since its nchildren == 0), but is still @@ -1469,50 +1482,52 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) * the cache's perspective). */ /* Lock indirect block for deletion */ - if(NULL == (del_iblock = H5HF__man_iblock_protect(hdr, iblock->addr, iblock->nrows, iblock->parent, iblock->par_entry, TRUE, H5AC__NO_FLAGS_SET, &did_protect))) + if (NULL == (del_iblock = H5HF__man_iblock_protect(hdr, iblock->addr, iblock->nrows, + iblock->parent, iblock->par_entry, TRUE, + H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") HDassert(did_protect == TRUE); /* Check for deleting root indirect block (and no root direct block) */ - if(iblock->block_off == 0 && hdr->man_dtable.curr_root_rows > 0) + if (iblock->block_off == 0 && hdr->man_dtable.curr_root_rows > 0) /* Reset header information back to "empty heap" state */ - if(H5HF__hdr_empty(hdr) < 0) + if (H5HF__hdr_empty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't make heap empty") /* Detach from parent indirect block */ - if(iblock->parent) { + if (iblock->parent) { /* Destroy flush dependency between indirect block and parent */ - if(H5AC_destroy_flush_dependency(iblock->fd_parent, iblock) < 0) + if (H5AC_destroy_flush_dependency(iblock->fd_parent, iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") iblock->fd_parent = NULL; /* Detach from parent indirect block */ - if(H5HF__man_iblock_detach(iblock->parent, iblock->par_entry) < 0) + if (H5HF__man_iblock_detach(iblock->parent, iblock->par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't detach from parent indirect block") - iblock->parent = NULL; + iblock->parent = NULL; iblock->par_entry = 0; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Decrement the reference count on this indirect block if we're not deleting it */ /* (should be after iblock needs to be modified, so that potential 'unpin' * on this indirect block doesn't invalidate the 'iblock' variable, if it's * not being deleted) */ - if(H5HF__iblock_decr(iblock) < 0) + if (H5HF__iblock_decr(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") iblock = NULL; /* Delete indirect block from cache, if appropriate */ - if(del_iblock) { - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotect */ - hbool_t took_ownership = FALSE; /* Flag to indicate that block ownership has transitioned */ + if (del_iblock) { + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotect */ + hbool_t took_ownership = FALSE; /* Flag to indicate that block ownership has transitioned */ /* If the refcount is still >0, unpin the block and take ownership * from the cache, otherwise let the cache destroy it. */ - if(del_iblock->rc > 0) { + if (del_iblock->rc > 0) { cache_flags |= (H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG); cache_flags |= H5AC__UNPIN_ENTRY_FLAG; took_ownership = TRUE; @@ -1524,32 +1539,33 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) /* If the indirect block is in real file space, tell * the cache to free its file space as well. */ - if(!H5F_IS_TMP_ADDR(hdr->f, del_iblock->addr)) + if (!H5F_IS_TMP_ADDR(hdr->f, del_iblock->addr)) cache_flags |= H5AC__FREE_FILE_SPACE_FLAG; } /* end else */ /* Unprotect the indirect block, with appropriate flags */ - if(H5HF__man_iblock_unprotect(del_iblock, cache_flags, TRUE) < 0) + if (H5HF__man_iblock_unprotect(del_iblock, cache_flags, TRUE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") /* if took ownership, free file space & mark block as removed from cache */ - if(took_ownership) { + if (took_ownership) { /* Free indirect block disk space, if it's in real space */ - if(!H5F_IS_TMP_ADDR(hdr->f, del_iblock->addr)) - if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, del_iblock->addr, (hsize_t)del_iblock->size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block file space") + if (!H5F_IS_TMP_ADDR(hdr->f, del_iblock->addr)) + if (H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, del_iblock->addr, (hsize_t)del_iblock->size) < + 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to free fractal heap indirect block file space") del_iblock->addr = HADDR_UNDEF; /* Mark block as removed from the cache */ del_iblock->removed_from_cache = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_detach() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iblock_entry_addr * @@ -1580,7 +1596,6 @@ H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *chi FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_man_iblock_entry_addr() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_delete * @@ -1599,15 +1614,15 @@ H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *chi *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry) +H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry) { - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - unsigned row, col; /* Current row & column in indirect block */ - unsigned entry; /* Current entry in row */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + unsigned row, col; /* Current row & column in indirect block */ + unsigned entry; /* Current entry in row */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1619,35 +1634,37 @@ H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, HDassert(iblock_nrows > 0); /* Lock indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, par_iblock, par_entry, TRUE, H5AC__NO_FLAGS_SET, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, par_iblock, par_entry, + TRUE, H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") HDassert(iblock->nchildren > 0); HDassert(did_protect == TRUE); /* Iterate over rows in this indirect block */ entry = 0; - for(row = 0; row < iblock->nrows; row++) { + for (row = 0; row < iblock->nrows; row++) { /* Iterate over entries in this row */ - for(col = 0; col < hdr->man_dtable.cparam.width; col++, entry++) { + for (col = 0; col < hdr->man_dtable.cparam.width; col++, entry++) { /* Check for child entry at this position */ - if(H5F_addr_defined(iblock->ents[entry].addr)) { + if (H5F_addr_defined(iblock->ents[entry].addr)) { /* Are we in a direct or indirect block row */ - if(row < hdr->man_dtable.max_direct_rows) { - hsize_t dblock_size; /* Size of direct block on disk */ + if (row < hdr->man_dtable.max_direct_rows) { + hsize_t dblock_size; /* Size of direct block on disk */ /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) dblock_size = iblock->filt_ents[entry].size; else dblock_size = hdr->man_dtable.row_block_size[row]; /* Delete child direct block */ - if(H5HF__man_dblock_delete(hdr->f, iblock->ents[entry].addr, dblock_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap child direct block") + if (H5HF__man_dblock_delete(hdr->f, iblock->ents[entry].addr, dblock_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to release fractal heap child direct block") } /* end if */ else { - hsize_t row_block_size; /* The size of blocks in this row */ - unsigned child_nrows; /* Number of rows in new indirect block */ + hsize_t row_block_size; /* The size of blocks in this row */ + unsigned child_nrows; /* Number of rows in new indirect block */ /* Get the row's block size */ row_block_size = (hsize_t)hdr->man_dtable.row_block_size[row]; @@ -1656,24 +1673,27 @@ H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, row_block_size); /* Delete child indirect block */ - if(H5HF__man_iblock_delete(hdr, iblock->ents[entry].addr, child_nrows, iblock, entry) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap child indirect block") + if (H5HF__man_iblock_delete(hdr, iblock->ents[entry].addr, child_nrows, iblock, entry) < + 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to release fractal heap child indirect block") } /* end else */ - } /* end if */ - } /* end for */ - } /* end row */ + } /* end if */ + } /* end for */ + } /* end row */ #ifndef NDEBUG -{ - unsigned iblock_status = 0; /* Indirect block's status in the metadata cache */ + { + unsigned iblock_status = 0; /* Indirect block's status in the metadata cache */ - /* Check the indirect block's status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, iblock_addr, &iblock_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for indirect block") + /* Check the indirect block's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, iblock_addr, &iblock_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to check metadata cache status for indirect block") - /* Check if indirect block is pinned */ - HDassert(!(iblock_status & H5AC_ES__IS_PINNED)); -} + /* Check if indirect block is pinned */ + HDassert(!(iblock_status & H5AC_ES__IS_PINNED)); + } #endif /* NDEBUG */ /* Indicate that the indirect block should be deleted */ @@ -1687,13 +1707,12 @@ H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, done: /* Unprotect the indirect block, with appropriate flags */ - if(iblock && H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) + if (iblock && H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_delete() */ - /*------------------------------------------------------------------------- * * Function: H5HF__man_iblock_size @@ -1707,12 +1726,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size) +H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size) { - H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1725,44 +1744,47 @@ H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, HDassert(heap_size); /* Protect the indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, par_iblock, par_entry, FALSE, H5AC__READ_ONLY_FLAG, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, par_iblock, par_entry, FALSE, + H5AC__READ_ONLY_FLAG, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap indirect block") /* Accumulate size of this indirect block */ *heap_size += iblock->size; /* Indirect entries in this indirect block */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned first_row_bits; /* Number of bits used bit addresses in first row */ - unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ - unsigned entry; /* Current entry in row */ - size_t u; /* Local index variable */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned first_row_bits; /* Number of bits used bit addresses in first row */ + unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ + unsigned entry; /* Current entry in row */ + size_t u; /* Local index variable */ - entry = hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width; + entry = hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width; first_row_bits = H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size) + - H5VM_log2_of2(hdr->man_dtable.cparam.width); - num_indirect_rows = - (H5VM_log2_gen(hdr->man_dtable.row_block_size[hdr->man_dtable.max_direct_rows]) - first_row_bits) + 1; - for(u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++, num_indirect_rows++) { - size_t v; /* Local index variable */ - - for(v = 0; v < hdr->man_dtable.cparam.width; v++, entry++) - if(H5F_addr_defined(iblock->ents[entry].addr)) - if(H5HF__man_iblock_size(f, hdr, iblock->ents[entry].addr, num_indirect_rows, iblock, entry, heap_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to get fractal heap storage info for indirect block") + H5VM_log2_of2(hdr->man_dtable.cparam.width); + num_indirect_rows = (H5VM_log2_gen(hdr->man_dtable.row_block_size[hdr->man_dtable.max_direct_rows]) - + first_row_bits) + + 1; + for (u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++, num_indirect_rows++) { + size_t v; /* Local index variable */ + + for (v = 0; v < hdr->man_dtable.cparam.width; v++, entry++) + if (H5F_addr_defined(iblock->ents[entry].addr)) + if (H5HF__man_iblock_size(f, hdr, iblock->ents[entry].addr, num_indirect_rows, iblock, + entry, heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, + "unable to get fractal heap storage info for indirect block") } /* end for */ - } /* end if */ + } /* end if */ done: /* Release the indirect block */ - if(iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_size() */ - /*------------------------------------------------------------------------- * * Function: H5HF_man_iblock_parent_info @@ -1780,14 +1802,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, - hsize_t *ret_par_block_off, unsigned *ret_entry) +H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, hsize_t *ret_par_block_off, + unsigned *ret_entry) { - hsize_t par_block_off; /* Offset of parent within heap */ - hsize_t prev_par_block_off; /* Offset of previous parent block within heap */ - unsigned row, col; /* Row & column for block */ - unsigned prev_row = 0, prev_col = 0;/* Previous row & column for block */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t par_block_off; /* Offset of parent within heap */ + hsize_t prev_par_block_off; /* Offset of previous parent block within heap */ + unsigned row, col; /* Row & column for block */ + unsigned prev_row = 0, prev_col = 0; /* Previous row & column for block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1799,7 +1821,7 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, HDassert(ret_entry); /* Look up row & column for object */ - if(H5HF_dtable_lookup(&hdr->man_dtable, block_off, &row, &col) < 0) + if (H5HF_dtable_lookup(&hdr->man_dtable, block_off, &row, &col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of block") /* Sanity check - first lookup must be an indirect block */ @@ -1809,7 +1831,7 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, * use previous (i.e. parent's) offset, row, and column. */ prev_par_block_off = par_block_off = 0; - while(row >= hdr->man_dtable.max_direct_rows) { + while (row >= hdr->man_dtable.max_direct_rows) { /* Retain previous parent block offset */ prev_par_block_off = par_block_off; @@ -1823,7 +1845,7 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, prev_col = col; /* Look up row & column in new indirect block for object */ - if(H5HF_dtable_lookup(&hdr->man_dtable, (block_off - par_block_off), &row, &col) < 0) + if (H5HF_dtable_lookup(&hdr->man_dtable, (block_off - par_block_off), &row, &col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of block") } /* end while */ @@ -1833,13 +1855,12 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, /* Set return parameters */ *ret_par_block_off = prev_par_block_off; - *ret_entry = (prev_row * hdr->man_dtable.cparam.width) + prev_col; + *ret_entry = (prev_row * hdr->man_dtable.cparam.width) + prev_col; done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_par_info() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iblock_dest * @@ -1856,7 +1877,7 @@ done: herr_t H5HF_man_iblock_dest(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1868,18 +1889,19 @@ H5HF_man_iblock_dest(H5HF_indirect_t *iblock) /* Decrement reference count on shared info */ HDassert(iblock->hdr); - if(H5HF_hdr_decr(iblock->hdr) < 0) + if (H5HF_hdr_decr(iblock->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") - if(iblock->parent) - if(H5HF__iblock_decr(iblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + if (iblock->parent) + if (H5HF__iblock_decr(iblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared indirect block") /* Release entry tables */ - if(iblock->ents) + if (iblock->ents) iblock->ents = H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents); - if(iblock->filt_ents) + if (iblock->filt_ents) iblock->filt_ents = H5FL_SEQ_FREE(H5HF_indirect_filt_ent_t, iblock->filt_ents); - if(iblock->child_iblocks) + if (iblock->child_iblocks) iblock->child_iblocks = H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); /* Free fractal heap indirect block info */ @@ -1888,4 +1910,3 @@ H5HF_man_iblock_dest(H5HF_indirect_t *iblock) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_dest() */ - diff --git a/src/H5HFiter.c b/src/H5HFiter.c index ceebc3b..30c4190 100644 --- a/src/H5HFiter.c +++ b/src/H5HFiter.c @@ -26,47 +26,40 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -74,8 +67,6 @@ /* Declare a free list to manage the H5HF_block_loc_t struct */ H5FL_DEFINE(H5HF_block_loc_t); - - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_init * @@ -107,7 +98,6 @@ H5HF_man_iter_init(H5HF_block_iter_t *biter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_man_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iter_start_offset * @@ -123,19 +113,18 @@ H5HF_man_iter_init(H5HF_block_iter_t *biter) *------------------------------------------------------------------------- */ herr_t -H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - hsize_t offset) +H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t offset) { - H5HF_indirect_t *iblock; /* Indirect block for location context */ - haddr_t iblock_addr; /* Address of indirect block */ - unsigned iblock_nrows; /* # of rows in indirect block */ - H5HF_indirect_t *iblock_parent; /* Parent indirect block of location context */ - unsigned iblock_par_entry; /* Entry within parent indirect block */ - hsize_t curr_offset; /* Current offset, as adjusted */ - unsigned row; /* Current row we are on */ - unsigned col; /* Column in row */ - hbool_t root_block = TRUE; /* Flag to indicate the current block is the root indirect block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Indirect block for location context */ + haddr_t iblock_addr; /* Address of indirect block */ + unsigned iblock_nrows; /* # of rows in indirect block */ + H5HF_indirect_t *iblock_parent; /* Parent indirect block of location context */ + unsigned iblock_par_entry; /* Entry within parent indirect block */ + hsize_t curr_offset; /* Current offset, as adjusted */ + unsigned row; /* Current row we are on */ + unsigned col; /* Column in row */ + hbool_t root_block = TRUE; /* Flag to indicate the current block is the root indirect block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -149,30 +138,31 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, HDassert(offset >= hdr->man_dtable.cparam.start_block_size); /* Allocate level structure */ - if(NULL == (biter->curr = H5FL_MALLOC(H5HF_block_loc_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section") - -/* -1: = offset> - - - - max_direct_rows> - - - - - - -*/ + if (NULL == (biter->curr = H5FL_MALLOC(H5HF_block_loc_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for direct block free list section") + + /* + 1: = offset> + + + + max_direct_rows> + + + + + + + */ do { - hbool_t did_protect; /* Whether we protected the indirect block or not */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ /* Walk down the rows in the doubling table until we've found the correct row for the next block */ - for(row = 0; row < hdr->man_dtable.max_root_rows; row++) - if((offset >= hdr->man_dtable.row_block_off[row]) && - (offset < hdr->man_dtable.row_block_off[row] + - (hdr->man_dtable.cparam.width * hdr->man_dtable.row_block_size[row]))) + for (row = 0; row < hdr->man_dtable.max_root_rows; row++) + if ((offset >= hdr->man_dtable.row_block_off[row]) && + (offset < hdr->man_dtable.row_block_off[row] + + (hdr->man_dtable.cparam.width * hdr->man_dtable.row_block_size[row]))) break; /* Adjust offset by row offset */ @@ -183,15 +173,15 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, col = (unsigned)(curr_offset / hdr->man_dtable.row_block_size[row]); /* Set the current level's context */ - biter->curr->row = row; - biter->curr->col = col; + biter->curr->row = row; + biter->curr->col = col; biter->curr->entry = (row * hdr->man_dtable.cparam.width) + col; /* Get the context indirect block's information */ - if(root_block) { - iblock_addr = hdr->man_dtable.table_addr; - iblock_nrows = hdr->man_dtable.curr_root_rows; - iblock_parent = NULL; + if (root_block) { + iblock_addr = hdr->man_dtable.table_addr; + iblock_nrows = hdr->man_dtable.curr_root_rows; + iblock_parent = NULL; iblock_par_entry = 0; /* The root block can't go up further... */ @@ -201,49 +191,54 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, root_block = FALSE; } /* end if */ else { - hsize_t child_size; /* Size of new indirect block to create */ + hsize_t child_size; /* Size of new indirect block to create */ /* Retrieve the parent information from the previous context location */ - iblock_parent = biter->curr->up->context; + iblock_parent = biter->curr->up->context; iblock_par_entry = biter->curr->up->entry; /* Look up the address of context indirect block */ iblock_addr = iblock_parent->ents[iblock_par_entry].addr; /* Compute # of rows in context indirect block */ - child_size = hdr->man_dtable.row_block_size[biter->curr->up->row]; + child_size = hdr->man_dtable.row_block_size[biter->curr->up->row]; iblock_nrows = (H5VM_log2_gen(child_size) - hdr->man_dtable.first_row_bits) + 1; } /* end else */ /* Load indirect block for this context location */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, iblock_parent, iblock_par_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) + if (NULL == + (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, iblock_parent, + iblock_par_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Make indirect block the context for the current location */ biter->curr->context = iblock; /* Hold the indirect block with the location */ - if(H5HF_iblock_incr(biter->curr->context) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") + if (H5HF_iblock_incr(biter->curr->context) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, + "can't increment reference count on shared indirect block") /* Release the current indirect block */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; /* See if the location falls in a direct block row */ /* Or, if the offset has just filled up a direct or indirect block */ - if(curr_offset == (col * hdr->man_dtable.row_block_size[row]) || row < hdr->man_dtable.max_direct_rows) { + if (curr_offset == (col * hdr->man_dtable.row_block_size[row]) || + row < hdr->man_dtable.max_direct_rows) { HDassert(curr_offset - (col * hdr->man_dtable.row_block_size[row]) == 0); - break; /* Done now */ - } /* end if */ + break; /* Done now */ + } /* end if */ /* Indirect block row */ else { - H5HF_block_loc_t *new_loc; /* Pointer to new block location */ + H5HF_block_loc_t *new_loc; /* Pointer to new block location */ /* Allocate level structure */ - if(NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section") + if (NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for direct block free list section") /* Link new level into iterator */ new_loc->up = biter->curr; @@ -253,8 +248,8 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, /* Make new block the current context */ biter->curr = new_loc; - } /* end else */ - } while(1); /* Breaks out in middle */ + } /* end else */ + } while (1); /* Breaks out in middle */ /* Set flag to indicate block iterator finished initializing */ biter->ready = TRUE; @@ -263,7 +258,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iter_start_offset() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_set_entry * @@ -289,13 +283,12 @@ H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigne /* Set location context */ biter->curr->entry = entry; - biter->curr->row = entry / hdr->man_dtable.cparam.width; - biter->curr->col = entry % hdr->man_dtable.cparam.width; + biter->curr->row = entry / hdr->man_dtable.cparam.width; + biter->curr->col = entry % hdr->man_dtable.cparam.width; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_man_iter_set_entry() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_start_entry * @@ -311,11 +304,11 @@ H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigne *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - H5HF_indirect_t *iblock, unsigned start_entry) +H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, H5HF_indirect_t *iblock, + unsigned start_entry) { - H5HF_block_loc_t *new_loc = NULL; /* Pointer to new block location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_block_loc_t *new_loc = NULL; /* Pointer to new block location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -328,18 +321,19 @@ H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, HDassert(iblock); /* Create new location for iterator */ - if(NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section") + if (NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for direct block free list section") /* Set up location context */ - new_loc->entry = start_entry; - new_loc->row = start_entry / hdr->man_dtable.cparam.width; - new_loc->col = start_entry % hdr->man_dtable.cparam.width; + new_loc->entry = start_entry; + new_loc->row = start_entry / hdr->man_dtable.cparam.width; + new_loc->col = start_entry % hdr->man_dtable.cparam.width; new_loc->context = iblock; - new_loc->up = NULL; + new_loc->up = NULL; /* Increment reference count on indirect block */ - if(H5HF_iblock_incr(new_loc->context) < 0) + if (H5HF_iblock_incr(new_loc->context) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") /* Make new location the current location */ @@ -349,13 +343,12 @@ H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, biter->ready = TRUE; done: - if(ret_value < 0 && new_loc) + if (ret_value < 0 && new_loc) new_loc = H5FL_FREE(H5HF_block_loc_t, new_loc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iter_start_entry() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_reset * @@ -373,7 +366,7 @@ done: herr_t H5HF_man_iter_reset(H5HF_block_iter_t *biter) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -383,20 +376,21 @@ H5HF_man_iter_reset(H5HF_block_iter_t *biter) HDassert(biter); /* Free any location contexts that exist */ - if(biter->curr) { - H5HF_block_loc_t *curr_loc; /* Pointer to current block location */ - H5HF_block_loc_t *next_loc; /* Pointer to next block location */ + if (biter->curr) { + H5HF_block_loc_t *curr_loc; /* Pointer to current block location */ + H5HF_block_loc_t *next_loc; /* Pointer to next block location */ /* Free location contexts */ curr_loc = biter->curr; - while(curr_loc) { + while (curr_loc) { /* Get pointer to next node */ next_loc = curr_loc->up; /* If this node is holding an indirect block, release the block */ - if(curr_loc->context) - if(H5HF__iblock_decr(curr_loc->context) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + if (curr_loc->context) + if (H5HF__iblock_decr(curr_loc->context) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared indirect block") /* Free the current location context */ curr_loc = H5FL_FREE(H5HF_block_loc_t, curr_loc); @@ -416,7 +410,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iter_reset() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_next * @@ -447,12 +440,11 @@ H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries) biter->curr->entry += nentries; biter->curr->row = biter->curr->entry / hdr->man_dtable.cparam.width; biter->curr->col = biter->curr->entry % hdr->man_dtable.cparam.width; -/* HDassert(biter->curr->row <= biter->curr->context->nrows); */ + /* HDassert(biter->curr->row <= biter->curr->context->nrows); */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_man_iter_next() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_up * @@ -469,8 +461,8 @@ H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries) herr_t H5HF_man_iter_up(H5HF_block_iter_t *biter) { - H5HF_block_loc_t *up_loc; /* Pointer to 'up' block location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_block_loc_t *up_loc; /* Pointer to 'up' block location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -484,7 +476,7 @@ H5HF_man_iter_up(H5HF_block_iter_t *biter) HDassert(biter->curr->context); /* Release hold on current location's indirect block */ - if(H5HF__iblock_decr(biter->curr->context) < 0) + if (H5HF__iblock_decr(biter->curr->context) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") /* Get pointer to location context above this one */ @@ -500,7 +492,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iter_up() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_down * @@ -517,8 +508,8 @@ done: herr_t H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock) { - H5HF_block_loc_t *down_loc = NULL; /* Pointer to new 'down' block location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_block_loc_t *down_loc = NULL; /* Pointer to new 'down' block location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -531,31 +522,31 @@ H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock) HDassert(biter->curr->context); /* Create new location to move down to */ - if(NULL == (down_loc = H5FL_MALLOC(H5HF_block_loc_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section") + if (NULL == (down_loc = H5FL_MALLOC(H5HF_block_loc_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for direct block free list section") /* Initialize down location */ - down_loc->row = 0; - down_loc->col = 0; - down_loc->entry = 0; + down_loc->row = 0; + down_loc->col = 0; + down_loc->entry = 0; down_loc->context = iblock; - down_loc->up = biter->curr; + down_loc->up = biter->curr; /* Increment reference count on indirect block */ - if(H5HF_iblock_incr(down_loc->context) < 0) + if (H5HF_iblock_incr(down_loc->context) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") /* Make down location the current location */ biter->curr = down_loc; done: - if(ret_value < 0 && down_loc) + if (ret_value < 0 && down_loc) down_loc = H5FL_FREE(H5HF_block_loc_t, down_loc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iter_down() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_curr * @@ -570,8 +561,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, - unsigned *entry, H5HF_indirect_t **block) +H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, unsigned *entry, + H5HF_indirect_t **block) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -582,19 +573,18 @@ H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, HDassert(biter->ready); /* Retrieve the information asked for */ - if(row) + if (row) *row = biter->curr->row; - if(col) + if (col) *col = biter->curr->col; - if(entry) + if (entry) *entry = biter->curr->entry; - if(block) + if (block) *block = biter->curr->context; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_man_iter_curr() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_offset * @@ -611,7 +601,7 @@ H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, herr_t H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t *offset) { - hsize_t curr_offset; /* For computing offset in heap */ + hsize_t curr_offset; /* For computing offset in heap */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -634,7 +624,6 @@ H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_man_iter_offset() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_iter_ready * @@ -660,4 +649,3 @@ H5HF_man_iter_ready(H5HF_block_iter_t *biter) FUNC_LEAVE_NOAPI(biter->ready) } /* end H5HF_man_iter_ready() */ - diff --git a/src/H5HFman.c b/src/H5HFman.c index ea00546..2a77dbb 100644 --- a/src/H5HFman.c +++ b/src/H5HFman.c @@ -26,18 +26,17 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ @@ -45,50 +44,43 @@ /* Macro to check if we can apply all filters in the pipeline. Use whenever * performing a modification operation */ - #define H5HF_MAN_WRITE_CHECK_PLINE(HDR) \ -{ \ - if(!((HDR)->checked_filters)) { \ - if((HDR)->pline.nused) \ - if(H5Z_can_apply_direct(&((HDR)->pline)) < 0) \ - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "I/O filters can't operate on this heap") \ - \ - (HDR)->checked_filters = TRUE; \ - } /* end if */ \ -} - +#define H5HF_MAN_WRITE_CHECK_PLINE(HDR) \ + { \ + if (!((HDR)->checked_filters)) { \ + if ((HDR)->pline.nused) \ + if (H5Z_can_apply_direct(&((HDR)->pline)) < 0) \ + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "I/O filters can't operate on this heap") \ + \ + (HDR)->checked_filters = TRUE; \ + } /* end if */ \ + } /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data, unsigned op_flags); +static herr_t H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data, + unsigned op_flags); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF__man_insert * @@ -105,14 +97,14 @@ static herr_t H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, herr_t H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) { - H5HF_free_section_t *sec_node = NULL; /* Pointer to free space section */ - H5HF_direct_t *dblock = NULL; /* Pointer to direct block to modify */ - haddr_t dblock_addr = HADDR_UNDEF; /* Direct block address */ - size_t dblock_size; /* Direct block size */ - uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ - size_t blk_off; /* Offset of object within block */ - htri_t node_found; /* Whether an existing free list node was found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sec_node = NULL; /* Pointer to free space section */ + H5HF_direct_t * dblock = NULL; /* Pointer to direct block to modify */ + haddr_t dblock_addr = HADDR_UNDEF; /* Direct block address */ + size_t dblock_size; /* Direct block size */ + uint8_t * id = (uint8_t *)_id; /* Pointer to ID buffer */ + size_t blk_off; /* Offset of object within block */ + htri_t node_found; /* Whether an existing free list node was found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -128,37 +120,38 @@ H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) H5HF_MAN_WRITE_CHECK_PLINE(hdr) /* Look for free space */ - if((node_found = H5HF__space_find(hdr, (hsize_t)obj_size, &sec_node)) < 0) + if ((node_found = H5HF__space_find(hdr, (hsize_t)obj_size, &sec_node)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap") /* If we didn't find a node, go create a direct block big enough to hold the requested block */ - if(!node_found) + if (!node_found) /* Allocate direct block big enough to hold requested size */ - if(H5HF__man_dblock_new(hdr, obj_size, &sec_node) < 0) + if (H5HF__man_dblock_new(hdr, obj_size, &sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create fractal heap direct block") /* Check for row section */ - if(sec_node->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || - sec_node->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW) { + if (sec_node->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || + sec_node->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW) { /* Allocate 'single' selection out of 'row' selection */ - if(H5HF__man_iblock_alloc_row(hdr, &sec_node) < 0) + if (H5HF__man_iblock_alloc_row(hdr, &sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't break up row section") } /* end if */ HDassert(sec_node->sect_info.type == H5HF_FSPACE_SECT_SINGLE); /* Check for 'single' section being serialized */ - if(sec_node->sect_info.state == H5FS_SECT_SERIALIZED) - if(H5HF__sect_single_revive(hdr, sec_node) < 0) + if (sec_node->sect_info.state == H5FS_SECT_SERIALIZED) + if (H5HF__sect_single_revive(hdr, sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") HDassert(sec_node->sect_info.state == H5FS_SECT_LIVE); /* Retrieve direct block address from section */ - if(H5HF_sect_single_dblock_info(hdr, sec_node, &dblock_addr, &dblock_size) < 0) + if (H5HF_sect_single_dblock_info(hdr, sec_node, &dblock_addr, &dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve direct block information") /* Lock direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, sec_node->u.single.parent, sec_node->u.single.par_entry, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, sec_node->u.single.parent, + sec_node->u.single.par_entry, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block") /* Insert object into block */ @@ -171,13 +164,13 @@ H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) HDassert(sec_node->sect_info.size >= obj_size); /* Reduce (& possibly re-add) single section */ - if(H5HF__sect_single_reduce(hdr, sec_node, obj_size) < 0) + if (H5HF__sect_single_reduce(hdr, sec_node, obj_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce single section node") sec_node = NULL; /* Encode the object in the block */ { - uint8_t *p; /* Temporary pointer to obj info in block */ + uint8_t *p; /* Temporary pointer to obj info in block */ /* Point to location for object */ p = dblock->blk + blk_off; @@ -197,23 +190,22 @@ H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) hdr->man_nobjs++; /* Reduce space available in heap (marks header dirty) */ - if(H5HF_hdr_adj_free(hdr, -(ssize_t)obj_size) < 0) + if (H5HF_hdr_adj_free(hdr, -(ssize_t)obj_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't adjust free space for heap") done: /* Release section node on error */ - if(ret_value < 0) - if(sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) + if (ret_value < 0) + if (sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release section node") /* Release the direct block (marked as dirty) */ - if(dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__DIRTIED_FLAG) < 0) + if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_insert() */ - /*------------------------------------------------------------------------- * Function: H5HF_man_get_obj_len * @@ -251,7 +243,6 @@ H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_man_get_obj_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_get_obj_off * @@ -286,7 +277,6 @@ H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off FUNC_LEAVE_NOAPI_VOID } /* end H5HF__man_get_obj_off() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_op_real * @@ -302,23 +292,22 @@ H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off *------------------------------------------------------------------------- */ static herr_t -H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data, unsigned op_flags) +H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data, unsigned op_flags) { H5HF_direct_t *dblock = NULL; /* Pointer to direct block to query */ - unsigned dblock_access_flags; /* Access method for direct block */ + unsigned dblock_access_flags; /* Access method for direct block */ /* must equal either * H5AC__NO_FLAGS_SET or * H5AC__READ_ONLY_FLAG */ - haddr_t dblock_addr; /* Direct block address */ - size_t dblock_size; /* Direct block size */ + haddr_t dblock_addr; /* Direct block address */ + size_t dblock_size; /* Direct block size */ unsigned dblock_cache_flags; /* Flags for unprotecting direct block */ - hsize_t obj_off; /* Object's offset in heap */ - size_t obj_len; /* Object's length in heap */ - size_t blk_off; /* Offset of object in block */ + hsize_t obj_off; /* Object's offset in heap */ + size_t obj_len; /* Object's length in heap */ + size_t blk_off; /* Offset of object in block */ uint8_t *p; /* Temporary pointer to obj info in block */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -330,16 +319,16 @@ H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, HDassert(op); /* Set the access mode for the direct block */ - if(op_flags & H5HF_OP_MODIFY) { + if (op_flags & H5HF_OP_MODIFY) { /* Check pipeline */ H5HF_MAN_WRITE_CHECK_PLINE(hdr) dblock_access_flags = H5AC__NO_FLAGS_SET; - dblock_cache_flags = H5AC__DIRTIED_FLAG; + dblock_cache_flags = H5AC__DIRTIED_FLAG; } /* end if */ else { dblock_access_flags = H5AC__READ_ONLY_FLAG; - dblock_cache_flags = H5AC__NO_FLAGS_SET; + dblock_cache_flags = H5AC__NO_FLAGS_SET; } /* end else */ /* Skip over the flag byte */ @@ -350,61 +339,66 @@ H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, UINT64DECODE_VAR(id, obj_len, hdr->heap_len_size); /* Check for bad offset or length */ - if(obj_off == 0) + if (obj_off == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "invalid fractal heap offset") - if(obj_off > hdr->man_size) + if (obj_off > hdr->man_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object offset too large") - if(obj_len == 0) + if (obj_len == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "invalid fractal heap object size") - if(obj_len > hdr->man_dtable.cparam.max_direct_size) + if (obj_len > hdr->man_dtable.cparam.max_direct_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object size too large for direct block") - if(obj_len > hdr->max_man_size) + if (obj_len > hdr->max_man_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object should be standalone") /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Set direct block info */ dblock_addr = hdr->man_dtable.table_addr; dblock_size = hdr->man_dtable.cparam.start_block_size; /* Lock direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, NULL, 0, dblock_access_flags))) + if (NULL == + (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, NULL, 0, dblock_access_flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block") } /* end if */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - unsigned entry; /* Entry of block */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + unsigned entry; /* Entry of block */ /* Look up indirect block containing direct block */ - if(H5HF__man_dblock_locate(hdr, obj_off, &iblock, &entry, &did_protect, H5AC__READ_ONLY_FLAG) < 0) + if (H5HF__man_dblock_locate(hdr, obj_off, &iblock, &entry, &did_protect, H5AC__READ_ONLY_FLAG) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section") /* Set direct block info */ - dblock_addr = iblock->ents[entry].addr; - H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]), hsize_t, size_t); - dblock_size = (size_t)hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]; + dblock_addr = iblock->ents[entry].addr; + H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]), hsize_t, + size_t); + dblock_size = (size_t)hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]; /* Check for offset of invalid direct block */ - if(!H5F_addr_defined(dblock_addr)) { + if (!H5F_addr_defined(dblock_addr)) { /* Unlock indirect block */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap ID not in allocated direct block") } /* end if */ /* Lock direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, iblock, entry, dblock_access_flags))) { + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, iblock, entry, + dblock_access_flags))) { /* Unlock indirect block */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block") } /* end if */ /* Unlock indirect block */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; } /* end else */ @@ -414,29 +408,28 @@ H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, blk_off = (size_t)(obj_off - dblock->block_off); /* Check for object's offset in the direct block prefix information */ - if(blk_off < (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)) + if (blk_off < (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object located in prefix of direct block") /* Check for object's length overrunning the end of the direct block */ - if((blk_off + obj_len) > dblock_size) + if ((blk_off + obj_len) > dblock_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object overruns end of direct block") /* Point to location for object */ p = dblock->blk + blk_off; /* Call the user's 'op' callback */ - if(op(p, obj_len, op_data) < 0) + if (op(p, obj_len, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed") done: /* Unlock direct block */ - if(dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, dblock_cache_flags) < 0) + if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, dblock_cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_op_real() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_read * @@ -453,7 +446,7 @@ done: herr_t H5HF__man_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -465,14 +458,13 @@ H5HF__man_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) HDassert(obj); /* Call the internal 'op' routine routine */ - if(H5HF__man_op_real(hdr, id, H5HF_op_read, obj, 0) < 0) + if (H5HF__man_op_real(hdr, id, H5HF_op_read, obj, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_read() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_write * @@ -489,7 +481,7 @@ done: herr_t H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -502,14 +494,13 @@ H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) /* Call the internal 'op' routine routine */ /* (Casting away const OK - QAK) */ - if(H5HF__man_op_real(hdr, id, H5HF_op_write, (void *)obj, H5HF_OP_MODIFY) < 0) + if (H5HF__man_op_real(hdr, id, H5HF_op_write, (void *)obj, H5HF_OP_MODIFY) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_write() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_op * @@ -526,7 +517,7 @@ done: herr_t H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -538,14 +529,13 @@ H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_da HDassert(op); /* Call the internal 'op' routine routine */ - if(H5HF__man_op_real(hdr, id, op, op_data, 0) < 0) + if (H5HF__man_op_real(hdr, id, op, op_data, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_op() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_remove * @@ -562,16 +552,16 @@ done: herr_t H5HF__man_remove(H5HF_hdr_t *hdr, const uint8_t *id) { - H5HF_free_section_t *sec_node = NULL; /* Pointer to free space section for block */ - H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - hsize_t obj_off; /* Object's offset in heap */ - size_t obj_len; /* Object's length in heap */ - size_t dblock_size; /* Direct block size */ - hsize_t dblock_block_off; /* Offset of the direct block within the heap's address space */ - unsigned dblock_entry; /* Entry of direct block in parent indirect block */ - size_t blk_off; /* Offset of object in block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sec_node = NULL; /* Pointer to free space section for block */ + H5HF_indirect_t * iblock = NULL; /* Pointer to indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + hsize_t obj_off; /* Object's offset in heap */ + size_t obj_len; /* Object's length in heap */ + size_t dblock_size; /* Direct block size */ + hsize_t dblock_block_off; /* Offset of the direct block within the heap's address space */ + unsigned dblock_entry; /* Entry of direct block in parent indirect block */ + size_t blk_off; /* Offset of object in block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -592,42 +582,45 @@ H5HF__man_remove(H5HF_hdr_t *hdr, const uint8_t *id) UINT64DECODE_VAR(id, obj_len, hdr->heap_len_size); /* Check for bad offset or length */ - if(obj_off == 0) + if (obj_off == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "invalid fractal heap offset") - if(obj_off > hdr->man_size) + if (obj_off > hdr->man_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object offset too large") - if(obj_len == 0) + if (obj_len == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "invalid fractal heap object size") - if(obj_len > hdr->man_dtable.cparam.max_direct_size) + if (obj_len > hdr->man_dtable.cparam.max_direct_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object size too large for direct block") - if(obj_len > hdr->max_man_size) + if (obj_len > hdr->max_man_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object should be standalone") /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Set direct block info */ - dblock_size = hdr->man_dtable.cparam.start_block_size; + dblock_size = hdr->man_dtable.cparam.start_block_size; dblock_block_off = 0; - dblock_entry = 0; + dblock_entry = 0; } /* end if */ else { /* Look up indirect block containing direct block */ - if(H5HF__man_dblock_locate(hdr, obj_off, &iblock, &dblock_entry, &did_protect, H5AC__NO_FLAGS_SET) < 0) + if (H5HF__man_dblock_locate(hdr, obj_off, &iblock, &dblock_entry, &did_protect, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section") /* Check for offset of invalid direct block */ - if(!H5F_addr_defined(iblock->ents[dblock_entry].addr)) + if (!H5F_addr_defined(iblock->ents[dblock_entry].addr)) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap ID not in allocated direct block") /* Set direct block info */ - H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]), hsize_t, size_t); - dblock_size = (size_t)(hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]); + H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]), + hsize_t, size_t); + dblock_size = (size_t)(hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]); /* Compute the direct block's offset in the heap's address space */ /* (based on parent indirect block's block offset) */ dblock_block_off = iblock->block_off; dblock_block_off += hdr->man_dtable.row_block_off[dblock_entry / hdr->man_dtable.cparam.width]; - dblock_block_off += hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width] * (dblock_entry % hdr->man_dtable.cparam.width); + dblock_block_off += hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width] * + (dblock_entry % hdr->man_dtable.cparam.width); } /* end else */ /* Compute offset of object within block */ @@ -635,47 +628,46 @@ H5HF__man_remove(H5HF_hdr_t *hdr, const uint8_t *id) blk_off = (size_t)(obj_off - dblock_block_off); /* Check for object's offset in the direct block prefix information */ - if(blk_off < (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)) + if (blk_off < (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object located in prefix of direct block") /* Check for object's length overrunning the end of the direct block */ - if((blk_off + obj_len) > dblock_size) + if ((blk_off + obj_len) > dblock_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object overruns end of direct block") /* Create free space section node */ - if(NULL == (sec_node = H5HF_sect_single_new(obj_off, obj_len, iblock, dblock_entry))) + if (NULL == (sec_node = H5HF_sect_single_new(obj_off, obj_len, iblock, dblock_entry))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create section for direct block's free space") /* Unlock indirect block */ - if(iblock) { - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (iblock) { + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; } /* end if */ /* Increase space available in heap (marks header dirty) */ - if(H5HF_hdr_adj_free(hdr, (ssize_t)obj_len) < 0) + if (H5HF_hdr_adj_free(hdr, (ssize_t)obj_len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't adjust free space for heap") /* Update statistics about heap */ hdr->man_nobjs--; /* Return free space to the heap's list of space */ - if(H5HF__space_add(hdr, sec_node, H5FS_ADD_RETURNED_SPACE) < 0) + if (H5HF__space_add(hdr, sec_node, H5FS_ADD_RETURNED_SPACE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add direct block free space to global list") sec_node = NULL; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Release section node */ - if(sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) + if (sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release section node") } /* end if */ /* Unlock indirect block */ - if(iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_remove() */ - diff --git a/src/H5HFmodule.h b/src/H5HFmodule.h index dd6576a..efbc622 100644 --- a/src/H5HFmodule.h +++ b/src/H5HFmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5HF_MODULE -#define H5_MY_PKG H5HF -#define H5_MY_PKG_ERR H5E_HEAP -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5HF +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO #endif /* _H5HFmodule_H */ - diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 83e46fc..73b7f0a 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -30,152 +30,153 @@ #include "H5HFprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5B2private.h" /* v2 B-trees */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FSprivate.h" /* Free space manager */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5B2private.h" /* v2 B-trees */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FSprivate.h" /* Free space manager */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Size of checksum information (on disk) */ -#define H5HF_SIZEOF_CHKSUM 4 +#define H5HF_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for fractal heap metadata */ -#define H5HF_METADATA_PREFIX_SIZE(c) ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + (unsigned)1 /* Version */ \ - + ((c) ? (unsigned)H5HF_SIZEOF_CHKSUM : (unsigned)0) /* Metadata checksum */ \ +#define H5HF_METADATA_PREFIX_SIZE(c) \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + (unsigned)1 /* Version */ \ + + ((c) ? (unsigned)H5HF_SIZEOF_CHKSUM : (unsigned)0) /* Metadata checksum */ \ ) /* Size of doubling-table information */ -#define H5HF_DTABLE_INFO_SIZE(h) ( \ - (unsigned)2 /* Width of table (i.e. # of columns) */ \ - + (unsigned)(h)->sizeof_size /* Starting block size */ \ - + (unsigned)(h)->sizeof_size /* Maximum direct block size */ \ - + (unsigned)2 /* Max. size of heap (log2 of actual value - i.e. the # of bits) */ \ - + (unsigned)2 /* Starting # of rows in root indirect block */ \ - + (unsigned)(h)->sizeof_addr /* File address of table managed */ \ - + (unsigned)2 /* Current # of rows in root indirect block */ \ +#define H5HF_DTABLE_INFO_SIZE(h) \ + ((unsigned)2 /* Width of table (i.e. # of columns) */ \ + + (unsigned)(h)->sizeof_size /* Starting block size */ \ + + (unsigned)(h)->sizeof_size /* Maximum direct block size */ \ + + (unsigned)2 /* Max. size of heap (log2 of actual value - i.e. the # of bits) */ \ + + (unsigned)2 /* Starting # of rows in root indirect block */ \ + + (unsigned)(h)->sizeof_addr /* File address of table managed */ \ + + (unsigned)2 /* Current # of rows in root indirect block */ \ ) /* Flags for status byte */ -#define H5HF_HDR_FLAGS_HUGE_ID_WRAPPED 0x01 /* "huge" object IDs have wrapped */ -#define H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS 0x02 /* checksum direct blocks */ +#define H5HF_HDR_FLAGS_HUGE_ID_WRAPPED 0x01 /* "huge" object IDs have wrapped */ +#define H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS 0x02 /* checksum direct blocks */ /* Size of the fractal heap header on disk */ /* (this is the fixed-len portion, the variable-len I/O filter information * follows this information, if there are I/O filters for the heap) */ -#define H5HF_HEADER_SIZE(h) ( \ - /* General metadata fields */ \ - H5HF_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Fractal Heap Header specific fields */ \ - \ - /* General heap information */ \ - + (unsigned)2 /* Heap ID len */ \ - + (unsigned)2 /* I/O filters' encoded len */ \ - + (unsigned)1 /* Status flags */ \ - \ - /* "Huge" object fields */ \ - + (unsigned)4 /* Max. size of "managed" object */ \ - + (unsigned)(h)->sizeof_size /* Next ID for "huge" object */ \ - + (unsigned)(h)->sizeof_addr /* File address of "huge" object tracker B-tree */ \ - \ - /* "Managed" object free space fields */ \ - + (unsigned)(h)->sizeof_size /* Total man. free space */ \ - + (unsigned)(h)->sizeof_addr /* File address of free section header */ \ - \ - /* Statistics fields */ \ - + (unsigned)(h)->sizeof_size /* Size of man. space in heap */ \ - + (unsigned)(h)->sizeof_size /* Size of man. space iterator offset in heap */ \ - + (unsigned)(h)->sizeof_size /* Size of alloacted man. space in heap */ \ - + (unsigned)(h)->sizeof_size /* Number of man. objects in heap */ \ - + (unsigned)(h)->sizeof_size /* Size of huge space in heap */ \ - + (unsigned)(h)->sizeof_size /* Number of huge objects in heap */ \ - + (unsigned)(h)->sizeof_size /* Size of tiny space in heap */ \ - + (unsigned)(h)->sizeof_size /* Number of tiny objects in heap */ \ - \ - /* "Managed" object doubling table info */ \ - + H5HF_DTABLE_INFO_SIZE(h) /* Size of managed obj. doubling-table info */ \ +#define H5HF_HEADER_SIZE(h) \ + (/* General metadata fields */ \ + H5HF_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Fractal Heap Header specific fields */ \ + \ + /* General heap information */ \ + + (unsigned)2 /* Heap ID len */ \ + + (unsigned)2 /* I/O filters' encoded len */ \ + + (unsigned)1 /* Status flags */ \ + \ + /* "Huge" object fields */ \ + + (unsigned)4 /* Max. size of "managed" object */ \ + + (unsigned)(h)->sizeof_size /* Next ID for "huge" object */ \ + + (unsigned)(h)->sizeof_addr /* File address of "huge" object tracker B-tree */ \ + \ + /* "Managed" object free space fields */ \ + + (unsigned)(h)->sizeof_size /* Total man. free space */ \ + + (unsigned)(h)->sizeof_addr /* File address of free section header */ \ + \ + /* Statistics fields */ \ + + (unsigned)(h)->sizeof_size /* Size of man. space in heap */ \ + + (unsigned)(h)->sizeof_size /* Size of man. space iterator offset in heap */ \ + + (unsigned)(h)->sizeof_size /* Size of alloacted man. space in heap */ \ + + (unsigned)(h)->sizeof_size /* Number of man. objects in heap */ \ + + (unsigned)(h)->sizeof_size /* Size of huge space in heap */ \ + + (unsigned)(h)->sizeof_size /* Number of huge objects in heap */ \ + + (unsigned)(h)->sizeof_size /* Size of tiny space in heap */ \ + + (unsigned)(h)->sizeof_size /* Number of tiny objects in heap */ \ + \ + /* "Managed" object doubling table info */ \ + + H5HF_DTABLE_INFO_SIZE(h) /* Size of managed obj. doubling-table info */ \ ) /* Size of overhead for a direct block */ -#define H5HF_MAN_ABS_DIRECT_OVERHEAD(h) ( \ - /* General metadata fields */ \ - H5HF_METADATA_PREFIX_SIZE(h->checksum_dblocks) \ - \ - /* Fractal heap managed, absolutely mapped direct block specific fields */ \ - + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \ - + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \ +#define H5HF_MAN_ABS_DIRECT_OVERHEAD(h) \ + (/* General metadata fields */ \ + H5HF_METADATA_PREFIX_SIZE(h->checksum_dblocks) \ + \ + /* Fractal heap managed, absolutely mapped direct block specific fields */ \ + + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \ + + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \ ) /* Size of managed indirect block entry for a child direct block */ -#define H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h) ( \ - ((h)->filter_len > 0 ? \ - ((unsigned)(h)->sizeof_addr + (unsigned)(h)->sizeof_size + (unsigned)4) : /* Size of entries for filtered direct blocks */ \ - (unsigned)(h)->sizeof_addr) /* Size of entries for un-filtered direct blocks */ \ +#define H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h) \ + (((h)->filter_len > 0 ? ((unsigned)(h)->sizeof_addr + (unsigned)(h)->sizeof_size + (unsigned)4) \ + : /* Size of entries for filtered direct blocks */ \ + (unsigned)(h)->sizeof_addr) /* Size of entries for un-filtered direct blocks */ \ ) /* Size of managed indirect block */ -#define H5HF_MAN_INDIRECT_SIZE(h, r) ( \ - /* General metadata fields */ \ - H5HF_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Fractal heap managed, absolutely mapped indirect block specific fields */ \ - + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \ - + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \ - + (MIN(r, (h)->man_dtable.max_direct_rows) * (h)->man_dtable.cparam.width * H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h)) /* Size of entries for direct blocks */ \ - + (((r > (h)->man_dtable.max_direct_rows) ? (r - (h)->man_dtable.max_direct_rows) : 0) * (h)->man_dtable.cparam.width * (h)->sizeof_addr) /* Size of entries for indirect blocks */ \ +#define H5HF_MAN_INDIRECT_SIZE(h, r) \ + (/* General metadata fields */ \ + H5HF_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Fractal heap managed, absolutely mapped indirect block specific fields */ \ + + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \ + + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \ + + (MIN(r, (h)->man_dtable.max_direct_rows) * (h)->man_dtable.cparam.width * \ + H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h)) /* Size of entries for direct blocks */ \ + + (((r > (h)->man_dtable.max_direct_rows) ? (r - (h)->man_dtable.max_direct_rows) : 0) * \ + (h)->man_dtable.cparam.width * (h)->sizeof_addr) /* Size of entries for indirect blocks */ \ ) /* Compute the # of bytes required to store an offset into a given buffer size */ -#define H5HF_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) -#define H5HF_SIZEOF_OFFSET_LEN(l) H5HF_SIZEOF_OFFSET_BITS(H5VM_log2_of2((unsigned)(l))) +#define H5HF_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) +#define H5HF_SIZEOF_OFFSET_LEN(l) H5HF_SIZEOF_OFFSET_BITS(H5VM_log2_of2((unsigned)(l))) /* Heap ID bit flags */ /* Heap ID version (2 bits: 6-7) */ -#define H5HF_ID_VERS_CURR 0x00 /* Current version of ID format */ -#define H5HF_ID_VERS_MASK 0xC0 /* Mask for getting the ID version from flags */ +#define H5HF_ID_VERS_CURR 0x00 /* Current version of ID format */ +#define H5HF_ID_VERS_MASK 0xC0 /* Mask for getting the ID version from flags */ /* Heap ID type (2 bits: 4-5) */ -#define H5HF_ID_TYPE_MAN 0x00 /* "Managed" object - stored in fractal heap blocks */ -#define H5HF_ID_TYPE_HUGE 0x10 /* "Huge" object - stored in file directly */ -#define H5HF_ID_TYPE_TINY 0x20 /* "Tiny" object - stored in heap ID directly */ -#define H5HF_ID_TYPE_RESERVED 0x30 /* "?" object - reserved for future use */ -#define H5HF_ID_TYPE_MASK 0x30 /* Mask for getting the ID type from flags */ +#define H5HF_ID_TYPE_MAN 0x00 /* "Managed" object - stored in fractal heap blocks */ +#define H5HF_ID_TYPE_HUGE 0x10 /* "Huge" object - stored in file directly */ +#define H5HF_ID_TYPE_TINY 0x20 /* "Tiny" object - stored in heap ID directly */ +#define H5HF_ID_TYPE_RESERVED 0x30 /* "?" object - reserved for future use */ +#define H5HF_ID_TYPE_MASK 0x30 /* Mask for getting the ID type from flags */ /* Heap ID bits 0-3 reserved for future use */ /* Encode a "managed" heap ID */ -#define H5HF_MAN_ID_ENCODE(i, h, o, l) \ - *(i) = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; \ - (i)++; \ - UINT64ENCODE_VAR((i), (o), (h)->heap_off_size); \ +#define H5HF_MAN_ID_ENCODE(i, h, o, l) \ + *(i) = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; \ + (i)++; \ + UINT64ENCODE_VAR((i), (o), (h)->heap_off_size); \ UINT64ENCODE_VAR((i), (l), (h)->heap_len_size) /* Decode a "managed" heap ID */ -#define H5HF_MAN_ID_DECODE(i, h, f, o, l) \ - f = *(uint8_t *)i++; \ - UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \ +#define H5HF_MAN_ID_DECODE(i, h, f, o, l) \ + f = *(uint8_t *)i++; \ + UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \ UINT64DECODE_VAR((i), (l), (h)->heap_len_size) /* Free space section types for fractal heap */ /* (values stored in free space data structures in file) */ -#define H5HF_FSPACE_SECT_SINGLE 0 /* Section is a range of actual bytes in a direct block */ -#define H5HF_FSPACE_SECT_FIRST_ROW 1 /* Section is first range of blocks in an indirect block row */ -#define H5HF_FSPACE_SECT_NORMAL_ROW 2 /* Section is a range of blocks in an indirect block row */ -#define H5HF_FSPACE_SECT_INDIRECT 3 /* Section is a span of blocks in an indirect block */ +#define H5HF_FSPACE_SECT_SINGLE 0 /* Section is a range of actual bytes in a direct block */ +#define H5HF_FSPACE_SECT_FIRST_ROW 1 /* Section is first range of blocks in an indirect block row */ +#define H5HF_FSPACE_SECT_NORMAL_ROW 2 /* Section is a range of blocks in an indirect block row */ +#define H5HF_FSPACE_SECT_INDIRECT 3 /* Section is a span of blocks in an indirect block */ /* Flags for 'op' operations */ -#define H5HF_OP_MODIFY 0x0001 /* Operation will modify object */ -#define H5HF_OP_FLAGS (H5HF_OP_MODIFY) /* Bit-wise OR of all op flags */ +#define H5HF_OP_MODIFY 0x0001 /* Operation will modify object */ +#define H5HF_OP_FLAGS (H5HF_OP_MODIFY) /* Bit-wise OR of all op flags */ /* Flags for 'root_iblock_flags' field in header */ -#define H5HF_ROOT_IBLOCK_PINNED 0x01 -#define H5HF_ROOT_IBLOCK_PROTECTED 0x02 - +#define H5HF_ROOT_IBLOCK_PINNED 0x01 +#define H5HF_ROOT_IBLOCK_PROTECTED 0x02 /****************************/ /* Package Private Typedefs */ @@ -184,37 +185,37 @@ /* Doubling-table info */ typedef struct H5HF_dtable_t { /* Immutable, pre-set information for table */ - H5HF_dtable_cparam_t cparam; /* Creation parameters for table */ + H5HF_dtable_cparam_t cparam; /* Creation parameters for table */ /* Derived information (stored, varies during lifetime of table) */ - haddr_t table_addr; /* Address of first block for table */ - /* Undefined if no space allocated for table */ - unsigned curr_root_rows; /* Current number of rows in the root indirect block */ - /* 0 indicates that the TABLE_ADDR field points - * to direct block (of START_BLOCK_SIZE) instead - * of indirect root block. - */ + haddr_t table_addr; /* Address of first block for table */ + /* Undefined if no space allocated for table */ + unsigned curr_root_rows; /* Current number of rows in the root indirect block */ + /* 0 indicates that the TABLE_ADDR field points + * to direct block (of START_BLOCK_SIZE) instead + * of indirect root block. + */ /* Computed information (not stored) */ - unsigned max_root_rows; /* Maximum # of rows in root indirect block */ - unsigned max_direct_rows; /* Maximum # of direct rows in any indirect block */ - unsigned start_bits; /* # of bits for starting block size (i.e. log2(start_block_size)) */ - unsigned max_direct_bits; /* # of bits for max. direct block size (i.e. log2(max_direct_size)) */ - unsigned max_dir_blk_off_size; /* Max. size of offsets in direct blocks */ - unsigned first_row_bits; /* # of bits in address of first row */ - hsize_t num_id_first_row; /* Number of IDs in first row of table */ - hsize_t *row_block_size; /* Block size per row of indirect block */ - hsize_t *row_block_off; /* Cumulative offset per row of indirect block */ - hsize_t *row_tot_dblock_free; /* Total free space in dblocks for this row */ - /* (For indirect block rows, it's the total - * free space in all direct blocks referenced - * from the indirect block) - */ - size_t *row_max_dblock_free; /* Max. free space in dblocks for this row */ - /* (For indirect block rows, it's the maximum - * free space in a direct block referenced - * from the indirect block) - */ + unsigned max_root_rows; /* Maximum # of rows in root indirect block */ + unsigned max_direct_rows; /* Maximum # of direct rows in any indirect block */ + unsigned start_bits; /* # of bits for starting block size (i.e. log2(start_block_size)) */ + unsigned max_direct_bits; /* # of bits for max. direct block size (i.e. log2(max_direct_size)) */ + unsigned max_dir_blk_off_size; /* Max. size of offsets in direct blocks */ + unsigned first_row_bits; /* # of bits in address of first row */ + hsize_t num_id_first_row; /* Number of IDs in first row of table */ + hsize_t *row_block_size; /* Block size per row of indirect block */ + hsize_t *row_block_off; /* Cumulative offset per row of indirect block */ + hsize_t *row_tot_dblock_free; /* Total free space in dblocks for this row */ + /* (For indirect block rows, it's the total + * free space in all direct blocks referenced + * from the indirect block) + */ + size_t *row_max_dblock_free; /* Max. free space in dblocks for this row */ + /* (For indirect block rows, it's the maximum + * free space in a direct block referenced + * from the indirect block) + */ } H5HF_dtable_t; /* Fractal heap free list info (forward decl - defined in H5HFflist.c) */ @@ -226,39 +227,40 @@ typedef struct H5HF_indirect_t H5HF_indirect_t; /* Fractal heap block location */ typedef struct H5HF_block_loc_t { /* Necessary table fields */ - unsigned row; /* Row of block in doubling table */ - unsigned col; /* Column of block in doubling table */ + unsigned row; /* Row of block in doubling table */ + unsigned col; /* Column of block in doubling table */ /* Derived/computed/cached table fields */ - unsigned entry; /* Entry of block in doubling table */ + unsigned entry; /* Entry of block in doubling table */ /* Infrastructure */ - H5HF_indirect_t *context; /* Pointer to the indirect block containing the block */ - struct H5HF_block_loc_t *up; /* Pointer to next level up in the stack of levels */ + H5HF_indirect_t * context; /* Pointer to the indirect block containing the block */ + struct H5HF_block_loc_t *up; /* Pointer to next level up in the stack of levels */ } H5HF_block_loc_t; /* Fractal heap block iterator info */ typedef struct H5HF_block_iter_t { - hbool_t ready; /* Set if iterator is finished initializing */ - H5HF_block_loc_t *curr; /* Pointer to the current level information for iterator */ + hbool_t ready; /* Set if iterator is finished initializing */ + H5HF_block_loc_t *curr; /* Pointer to the current level information for iterator */ } H5HF_block_iter_t; /* Fractal heap free space section info */ typedef struct H5HF_free_section_t { - H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ + H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ union { struct { - H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */ - unsigned par_entry; /* Entry of free section's direct block in parent indirect block */ + H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */ + unsigned par_entry; /* Entry of free section's direct block in parent indirect block */ } single; struct { - struct H5HF_free_section_t *under; /* Pointer to indirect block underlying row section */ - unsigned row; /* Row for range of blocks */ - unsigned col; /* Column for range of blocks */ - unsigned num_entries; /* Number of entries covered */ + struct H5HF_free_section_t *under; /* Pointer to indirect block underlying row section */ + unsigned row; /* Row for range of blocks */ + unsigned col; /* Column for range of blocks */ + unsigned num_entries; /* Number of entries covered */ /* Fields that aren't stored */ - hbool_t checked_out; /* Flag to indicate that a row section is temporarily out of the free space manager */ + hbool_t checked_out; /* Flag to indicate that a row section is temporarily out of the free space + manager */ } row; struct { /* Holds either a pointer to an indirect block (if its "live") or @@ -268,23 +270,24 @@ typedef struct H5HF_free_section_t { * or not) */ union { - H5HF_indirect_t *iblock; /* Indirect block for free section */ - hsize_t iblock_off; /* Indirect block offset in "heap space" */ + H5HF_indirect_t *iblock; /* Indirect block for free section */ + hsize_t iblock_off; /* Indirect block offset in "heap space" */ } u; - unsigned row; /* Row for range of blocks */ - unsigned col; /* Column for range of blocks */ - unsigned num_entries; /* Number of entries covered */ + unsigned row; /* Row for range of blocks */ + unsigned col; /* Column for range of blocks */ + unsigned num_entries; /* Number of entries covered */ /* Fields that aren't stored */ - struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */ - unsigned par_entry; /* Entry within parent indirect section */ - hsize_t span_size; /* Size of space tracked, in "heap space" */ - unsigned iblock_entries; /* Number of entries in indirect block where section is located */ - unsigned rc; /* Reference count of outstanding row & child indirect sections */ - unsigned dir_nrows; /* Number of direct rows in section */ - struct H5HF_free_section_t **dir_rows; /* Array of pointers to outstanding row sections */ - unsigned indir_nents; /* Number of indirect entries in section */ - struct H5HF_free_section_t **indir_ents; /* Array of pointers to outstanding child indirect sections */ + struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */ + unsigned par_entry; /* Entry within parent indirect section */ + hsize_t span_size; /* Size of space tracked, in "heap space" */ + unsigned iblock_entries; /* Number of entries in indirect block where section is located */ + unsigned rc; /* Reference count of outstanding row & child indirect sections */ + unsigned dir_nrows; /* Number of direct rows in section */ + struct H5HF_free_section_t **dir_rows; /* Array of pointers to outstanding row sections */ + unsigned indir_nents; /* Number of indirect entries in section */ + struct H5HF_free_section_t * + *indir_ents; /* Array of pointers to outstanding child indirect sections */ } indirect; } u; } H5HF_free_section_t; @@ -298,79 +301,81 @@ typedef struct H5HF_hdr_t { H5AC_info_t cache_info; /* General header information (stored in header) */ - unsigned id_len; /* Size of heap IDs (in bytes) */ - unsigned filter_len; /* Size of I/O filter information (in bytes) */ + unsigned id_len; /* Size of heap IDs (in bytes) */ + unsigned filter_len; /* Size of I/O filter information (in bytes) */ /* Flags for heap settings (stored in status byte in header) */ - hbool_t debug_objs; /* Is the heap storing objects in 'debug' format */ - hbool_t write_once; /* Is heap being written in "write once" mode? */ - hbool_t huge_ids_wrapped; /* Have "huge" object IDs wrapped around? */ - hbool_t checksum_dblocks; /* Should the direct blocks in the heap be checksummed? */ + hbool_t debug_objs; /* Is the heap storing objects in 'debug' format */ + hbool_t write_once; /* Is heap being written in "write once" mode? */ + hbool_t huge_ids_wrapped; /* Have "huge" object IDs wrapped around? */ + hbool_t checksum_dblocks; /* Should the direct blocks in the heap be checksummed? */ /* Doubling table information (partially stored in header) */ /* (Partially set by user, partially derived/updated internally) */ - H5HF_dtable_t man_dtable; /* Doubling-table info for managed objects */ + H5HF_dtable_t man_dtable; /* Doubling-table info for managed objects */ /* Free space information for managed objects (stored in header) */ - hsize_t total_man_free; /* Total amount of free space in managed blocks */ - haddr_t fs_addr; /* Address of free space header on disk */ + hsize_t total_man_free; /* Total amount of free space in managed blocks */ + haddr_t fs_addr; /* Address of free space header on disk */ /* "Huge" object support (stored in header) */ - uint32_t max_man_size; /* Max. size of object to manage in doubling table */ - hsize_t huge_next_id; /* Next ID to use for indirectly tracked 'huge' object */ - haddr_t huge_bt2_addr; /* Address of v2 B-tree for tracking "huge" object info */ + uint32_t max_man_size; /* Max. size of object to manage in doubling table */ + hsize_t huge_next_id; /* Next ID to use for indirectly tracked 'huge' object */ + haddr_t huge_bt2_addr; /* Address of v2 B-tree for tracking "huge" object info */ /* I/O filter support (stored in header, if any are used) */ - H5O_pline_t pline; /* I/O filter pipeline for heap objects */ - size_t pline_root_direct_size; /* Size of filtered root direct block */ + H5O_pline_t pline; /* I/O filter pipeline for heap objects */ + size_t pline_root_direct_size; /* Size of filtered root direct block */ unsigned pline_root_direct_filter_mask; /* I/O filter mask for filtered root direct block */ /* Statistics for heap (stored in header) */ - hsize_t man_size; /* Total amount of 'managed' space in heap */ - hsize_t man_alloc_size; /* Total amount of allocated 'managed' space in heap */ - hsize_t man_iter_off; /* Offset of iterator in 'managed' heap space */ - hsize_t man_nobjs; /* Number of 'managed' objects in heap */ - hsize_t huge_size; /* Total size of 'huge' objects in heap */ - hsize_t huge_nobjs; /* Number of 'huge' objects in heap */ - hsize_t tiny_size; /* Total size of 'tiny' objects in heap */ - hsize_t tiny_nobjs; /* Number of 'tiny' objects in heap */ + hsize_t man_size; /* Total amount of 'managed' space in heap */ + hsize_t man_alloc_size; /* Total amount of allocated 'managed' space in heap */ + hsize_t man_iter_off; /* Offset of iterator in 'managed' heap space */ + hsize_t man_nobjs; /* Number of 'managed' objects in heap */ + hsize_t huge_size; /* Total size of 'huge' objects in heap */ + hsize_t huge_nobjs; /* Number of 'huge' objects in heap */ + hsize_t tiny_size; /* Total size of 'tiny' objects in heap */ + hsize_t tiny_nobjs; /* Number of 'tiny' objects in heap */ /* Cached/computed values (not stored in header) */ - size_t rc; /* Reference count of heap's components using heap header */ - haddr_t heap_addr; /* Address of heap header in the file */ - size_t heap_size; /* Size of heap header in the file */ - unsigned mode; /* Access mode for heap */ - H5F_t *f; /* Pointer to file for heap */ - size_t file_rc; /* Reference count of files using heap header */ - hbool_t pending_delete; /* Heap is pending deletion */ - uint8_t sizeof_size; /* Size of file sizes */ - uint8_t sizeof_addr; /* Size of file addresses */ + size_t rc; /* Reference count of heap's components using heap header */ + haddr_t heap_addr; /* Address of heap header in the file */ + size_t heap_size; /* Size of heap header in the file */ + unsigned mode; /* Access mode for heap */ + H5F_t * f; /* Pointer to file for heap */ + size_t file_rc; /* Reference count of files using heap header */ + hbool_t pending_delete; /* Heap is pending deletion */ + uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_addr; /* Size of file addresses */ struct H5HF_indirect_t *root_iblock; /* Pointer to root indirect block */ - unsigned root_iblock_flags; /* Flags to indicate whether root indirect block is pinned/protected */ - H5FS_t *fspace; /* Free space list for objects in heap */ + unsigned root_iblock_flags; /* Flags to indicate whether root indirect block is pinned/protected */ + H5FS_t * fspace; /* Free space list for objects in heap */ H5HF_block_iter_t next_block; /* Block iterator for searching for next block with space */ - H5B2_t *huge_bt2; /* v2 B-tree handle for huge objects */ - hsize_t huge_max_id; /* Max. 'huge' heap ID before rolling 'huge' heap IDs over */ - uint8_t huge_id_size; /* Size of 'huge' heap IDs (in bytes) */ - hbool_t huge_ids_direct; /* Flag to indicate that 'huge' object's offset & length are stored directly in heap ID */ - size_t tiny_max_len; /* Max. size of tiny objects for this heap */ - hbool_t tiny_len_extended; /* Flag to indicate that 'tiny' object's length is stored in extended form (i.e. w/extra byte) */ - uint8_t heap_off_size; /* Size of heap offsets (in bytes) */ - uint8_t heap_len_size; /* Size of heap ID lengths (in bytes) */ - hbool_t checked_filters; /* TRUE if pipeline passes can_apply checks */ + H5B2_t * huge_bt2; /* v2 B-tree handle for huge objects */ + hsize_t huge_max_id; /* Max. 'huge' heap ID before rolling 'huge' heap IDs over */ + uint8_t huge_id_size; /* Size of 'huge' heap IDs (in bytes) */ + hbool_t huge_ids_direct; /* Flag to indicate that 'huge' object's offset & length are stored directly in + heap ID */ + size_t tiny_max_len; /* Max. size of tiny objects for this heap */ + hbool_t tiny_len_extended; /* Flag to indicate that 'tiny' object's length is stored in extended form + (i.e. w/extra byte) */ + uint8_t heap_off_size; /* Size of heap offsets (in bytes) */ + uint8_t heap_len_size; /* Size of heap ID lengths (in bytes) */ + hbool_t checked_filters; /* TRUE if pipeline passes can_apply checks */ } H5HF_hdr_t; /* Common indirect block doubling table entry */ /* (common between entries pointing to direct & indirect child blocks) */ typedef struct H5HF_indirect_ent_t { - haddr_t addr; /* Direct block's address */ + haddr_t addr; /* Direct block's address */ } H5HF_indirect_ent_t; /* Extern indirect block doubling table entry for compressed direct blocks */ /* (only exists for indirect blocks in heaps that have I/O filters) */ typedef struct H5HF_indirect_filt_ent_t { - size_t size; /* Size of child direct block, after passing though I/O filters */ - unsigned filter_mask; /* Excluded filters for child direct block */ + size_t size; /* Size of child direct block, after passing though I/O filters */ + unsigned filter_mask; /* Excluded filters for child direct block */ } H5HF_indirect_filt_ent_t; /* Fractal heap indirect block */ @@ -379,32 +384,32 @@ struct H5HF_indirect_t { H5AC_info_t cache_info; /* Internal heap information (not stored) */ - size_t rc; /* Reference count of objects using this block */ - H5HF_hdr_t *hdr; /* Shared heap header info */ - struct H5HF_indirect_t *parent; /* Shared parent indirect block info */ - void *fd_parent; /* Saved copy of the parent pointer -- this */ - /* necessary as the parent field is sometimes */ - /* nulled out before the eviction notify call */ - /* is made from the metadata cache. Since */ - /* this call cancels flush dependencies, it */ - /* needs this information. */ - unsigned par_entry; /* Entry in parent's table */ - haddr_t addr; /* Address of this indirect block on disk */ - size_t size; /* Size of indirect block on disk */ - unsigned nrows; /* Total # of rows in indirect block */ - unsigned max_rows; /* Max. # of rows in indirect block */ - unsigned nchildren; /* Number of child blocks */ - unsigned max_child; /* Max. offset used in child entries */ - struct H5HF_indirect_t **child_iblocks; /* Array of pointers to pinned child indirect blocks */ - hbool_t removed_from_cache; /* Flag that indicates the block has */ - /* been removed from the metadata cache, but */ - /* is still 'live' due to a refcount (rc) > 0 */ - /* (usually from free space sections) */ + size_t rc; /* Reference count of objects using this block */ + H5HF_hdr_t * hdr; /* Shared heap header info */ + struct H5HF_indirect_t *parent; /* Shared parent indirect block info */ + void * fd_parent; /* Saved copy of the parent pointer -- this */ + /* necessary as the parent field is sometimes */ + /* nulled out before the eviction notify call */ + /* is made from the metadata cache. Since */ + /* this call cancels flush dependencies, it */ + /* needs this information. */ + unsigned par_entry; /* Entry in parent's table */ + haddr_t addr; /* Address of this indirect block on disk */ + size_t size; /* Size of indirect block on disk */ + unsigned nrows; /* Total # of rows in indirect block */ + unsigned max_rows; /* Max. # of rows in indirect block */ + unsigned nchildren; /* Number of child blocks */ + unsigned max_child; /* Max. offset used in child entries */ + struct H5HF_indirect_t **child_iblocks; /* Array of pointers to pinned child indirect blocks */ + hbool_t removed_from_cache; /* Flag that indicates the block has */ + /* been removed from the metadata cache, but */ + /* is still 'live' due to a refcount (rc) > 0 */ + /* (usually from free space sections) */ /* Stored values */ - hsize_t block_off; /* Offset of the block within the heap's address space */ - H5HF_indirect_ent_t *ents; /* Pointer to block entry table */ - H5HF_indirect_filt_ent_t *filt_ents; /* Pointer to filtered information for direct blocks */ + hsize_t block_off; /* Offset of the block within the heap's address space */ + H5HF_indirect_ent_t * ents; /* Pointer to block entry table */ + H5HF_indirect_filt_ent_t *filt_ents; /* Pointer to filtered information for direct blocks */ }; /* A fractal heap direct block */ @@ -413,146 +418,145 @@ typedef struct H5HF_direct_t { H5AC_info_t cache_info; /* Internal heap information */ - H5HF_hdr_t *hdr; /* Shared heap header info */ - H5HF_indirect_t *parent; /* Shared parent indirect block info */ - void *fd_parent; /* Saved copy of the parent pointer -- this */ - /* necessary as the parent field is sometimes */ - /* nulled out before the eviction notify call */ - /* is made from the metadata cache. Since */ - /* this call cancels flush dependencies, it */ - /* needs this information. */ - unsigned par_entry; /* Entry in parent's table */ - size_t size; /* Size of direct block */ - hsize_t file_size; /* Size of direct block in file (only valid when block's space is being freed) */ - uint8_t *blk; /* Pointer to buffer containing block data */ - uint8_t *write_buf; /* Pointer to buffer containing the block data */ - /* in form ready to copy to the metadata */ - /* cache's image buffer. */ - /* */ - /* This field is used by */ - /* H5HF_cache_dblock_pre_serialize() to pass */ - /* the serialized image of the direct block to */ - /* H5HF_cache_dblock_serialize(). It should */ - /* NULL at all other times. */ - /* */ - /* If I/O filters are enabled, the pre- */ - /* the pre-serialize function will allocate */ - /* a buffer, copy the filtered version of the */ - /* direct block image into it, and place the */ - /* base address of the buffer in this field. */ - /* The serialize function must discard this */ - /* buffer after it copies the contents into */ - /* the image buffer provided by the metadata */ - /* cache. */ - /* */ - /* If I/O filters are not enabled, the */ - /* write_buf field is simply set equal to the */ - /* blk field by the pre-serialize function, */ - /* and back to NULL by the serialize function. */ - size_t write_size; /* size of the buffer pointed to by write_buf. */ + H5HF_hdr_t * hdr; /* Shared heap header info */ + H5HF_indirect_t *parent; /* Shared parent indirect block info */ + void * fd_parent; /* Saved copy of the parent pointer -- this */ + /* necessary as the parent field is sometimes */ + /* nulled out before the eviction notify call */ + /* is made from the metadata cache. Since */ + /* this call cancels flush dependencies, it */ + /* needs this information. */ + unsigned par_entry; /* Entry in parent's table */ + size_t size; /* Size of direct block */ + hsize_t file_size; /* Size of direct block in file (only valid when block's space is being freed) */ + uint8_t *blk; /* Pointer to buffer containing block data */ + uint8_t *write_buf; /* Pointer to buffer containing the block data */ + /* in form ready to copy to the metadata */ + /* cache's image buffer. */ + /* */ + /* This field is used by */ + /* H5HF_cache_dblock_pre_serialize() to pass */ + /* the serialized image of the direct block to */ + /* H5HF_cache_dblock_serialize(). It should */ + /* NULL at all other times. */ + /* */ + /* If I/O filters are enabled, the pre- */ + /* the pre-serialize function will allocate */ + /* a buffer, copy the filtered version of the */ + /* direct block image into it, and place the */ + /* base address of the buffer in this field. */ + /* The serialize function must discard this */ + /* buffer after it copies the contents into */ + /* the image buffer provided by the metadata */ + /* cache. */ + /* */ + /* If I/O filters are not enabled, the */ + /* write_buf field is simply set equal to the */ + /* blk field by the pre-serialize function, */ + /* and back to NULL by the serialize function. */ + size_t write_size; /* size of the buffer pointed to by write_buf. */ /* Stored values */ - hsize_t block_off; /* Offset of the block within the heap's address space */ + hsize_t block_off; /* Offset of the block within the heap's address space */ } H5HF_direct_t; /* Fractal heap */ struct H5HF_t { - H5HF_hdr_t *hdr; /* Pointer to internal fractal heap header info */ - H5F_t *f; /* Pointer to file for heap */ + H5HF_hdr_t *hdr; /* Pointer to internal fractal heap header info */ + H5F_t * f; /* Pointer to file for heap */ }; /* Fractal heap "parent info" (for loading a block) */ typedef struct H5HF_parent_t { - H5HF_hdr_t *hdr; /* Pointer to heap header info */ - H5HF_indirect_t *iblock; /* Pointer to parent indirect block */ - unsigned entry; /* Location of block in parent's entry table */ + H5HF_hdr_t * hdr; /* Pointer to heap header info */ + H5HF_indirect_t *iblock; /* Pointer to parent indirect block */ + unsigned entry; /* Location of block in parent's entry table */ } H5HF_parent_t; /* Typedef for indirectly accessed 'huge' object's records in the v2 B-tree */ typedef struct H5HF_huge_bt2_indir_rec_t { - haddr_t addr; /* Address of the object in the file */ - hsize_t len; /* Length of the object in the file */ - hsize_t id; /* ID used for object (not used for 'huge' objects directly accessed) */ + haddr_t addr; /* Address of the object in the file */ + hsize_t len; /* Length of the object in the file */ + hsize_t id; /* ID used for object (not used for 'huge' objects directly accessed) */ } H5HF_huge_bt2_indir_rec_t; /* Typedef for indirectly accessed, filtered 'huge' object's records in the v2 B-tree */ typedef struct H5HF_huge_bt2_filt_indir_rec_t { - haddr_t addr; /* Address of the filtered object in the file */ - hsize_t len; /* Length of the filtered object in the file */ - unsigned filter_mask; /* I/O pipeline filter mask for filtered object in the file */ - hsize_t obj_size; /* Size of the de-filtered object in memory */ - hsize_t id; /* ID used for object (not used for 'huge' objects directly accessed) */ + haddr_t addr; /* Address of the filtered object in the file */ + hsize_t len; /* Length of the filtered object in the file */ + unsigned filter_mask; /* I/O pipeline filter mask for filtered object in the file */ + hsize_t obj_size; /* Size of the de-filtered object in memory */ + hsize_t id; /* ID used for object (not used for 'huge' objects directly accessed) */ } H5HF_huge_bt2_filt_indir_rec_t; /* Typedef for directly accessed 'huge' object's records in the v2 B-tree */ typedef struct H5HF_huge_bt2_dir_rec_t { - haddr_t addr; /* Address of the object in the file */ - hsize_t len; /* Length of the object in the file */ + haddr_t addr; /* Address of the object in the file */ + hsize_t len; /* Length of the object in the file */ } H5HF_huge_bt2_dir_rec_t; /* Typedef for directly accessed, filtered 'huge' object's records in the v2 B-tree */ typedef struct H5HF_huge_bt2_filt_dir_rec_t { - haddr_t addr; /* Address of the filtered object in the file */ - hsize_t len; /* Length of the filtered object in the file */ - unsigned filter_mask; /* I/O pipeline filter mask for filtered object in the file */ - hsize_t obj_size; /* Size of the de-filtered object in memory */ + haddr_t addr; /* Address of the filtered object in the file */ + hsize_t len; /* Length of the filtered object in the file */ + unsigned filter_mask; /* I/O pipeline filter mask for filtered object in the file */ + hsize_t obj_size; /* Size of the de-filtered object in memory */ } H5HF_huge_bt2_filt_dir_rec_t; /* User data for free space section 'add' callback */ typedef struct { - H5HF_hdr_t *hdr; /* Fractal heap header */ + H5HF_hdr_t *hdr; /* Fractal heap header */ } H5HF_sect_add_ud_t; /* User data for v2 B-tree 'remove' callback on 'huge' objects */ typedef struct { - H5HF_hdr_t *hdr; /* Fractal heap header (in) */ - hsize_t obj_len; /* Length of object removed (out) */ + H5HF_hdr_t *hdr; /* Fractal heap header (in) */ + hsize_t obj_len; /* Length of object removed (out) */ } H5HF_huge_remove_ud_t; /* User data for fractal heap header cache client callback */ typedef struct H5HF_hdr_cache_ud_t { - H5F_t *f; /* File pointer */ + H5F_t *f; /* File pointer */ } H5HF_hdr_cache_ud_t; /* User data for fractal heap indirect block cache client callbacks */ typedef struct H5HF_iblock_cache_ud_t { - H5HF_parent_t * par_info; /* Parent info */ - H5F_t * f; /* File pointer */ - const unsigned *nrows; /* Number of rows */ + H5HF_parent_t * par_info; /* Parent info */ + H5F_t * f; /* File pointer */ + const unsigned *nrows; /* Number of rows */ } H5HF_iblock_cache_ud_t; /* User data for fractal heap direct block cache client callbacks */ typedef struct H5HF_dblock_cache_ud_t { - H5HF_parent_t par_info; /* Parent info */ - H5F_t * f; /* File pointer */ - size_t odi_size; /* On disk image size of the direct block. - * Note that there is no necessary relation - * between this value, and the actual - * direct block size, as conpression may - * reduce the size of the on disk image, - * and check sums may increase it. - */ - size_t dblock_size; /* size of the direct block, which bears - * no necessary relation to the block - * odi_size -- the size of the on disk - * image of the block. Note that the - * metadata cache is only interested - * in the odi_size, and thus it is this - * value that is passed to the cache in - * calls to it. - */ - unsigned filter_mask; /* Excluded filters for direct block */ - uint8_t *dblk; /* Pointer to the buffer containing the decompressed - * direct block data obtained in verify_chksum callback. - * It will be used later in deserialize callback. - */ + H5HF_parent_t par_info; /* Parent info */ + H5F_t * f; /* File pointer */ + size_t odi_size; /* On disk image size of the direct block. + * Note that there is no necessary relation + * between this value, and the actual + * direct block size, as conpression may + * reduce the size of the on disk image, + * and check sums may increase it. + */ + size_t dblock_size; /* size of the direct block, which bears + * no necessary relation to the block + * odi_size -- the size of the on disk + * image of the block. Note that the + * metadata cache is only interested + * in the odi_size, and thus it is this + * value that is passed to the cache in + * calls to it. + */ + unsigned filter_mask; /* Excluded filters for direct block */ + uint8_t *dblk; /* Pointer to the buffer containing the decompressed + * direct block data obtained in verify_chksum callback. + * It will be used later in deserialize callback. + */ htri_t decompressed; /* Indicate that the direct block has been * decompressed in verify_chksum callback. * It will be used later in deserialize callback. */ } H5HF_dblock_cache_ud_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -600,123 +604,103 @@ H5FL_EXTERN(H5HF_direct_t); /* Declare a free list to manage heap direct block data to/from disk */ H5FL_BLK_EXTERN(direct_block); - /******************************/ /* Package Private Prototypes */ /******************************/ /* Doubling table routines */ -H5_DLL herr_t H5HF_dtable_init(H5HF_dtable_t *dtable); -H5_DLL herr_t H5HF_dtable_dest(H5HF_dtable_t *dtable); -H5_DLL herr_t H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, - unsigned *row, unsigned *col); +H5_DLL herr_t H5HF_dtable_init(H5HF_dtable_t *dtable); +H5_DLL herr_t H5HF_dtable_dest(H5HF_dtable_t *dtable); +H5_DLL herr_t H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, unsigned *row, unsigned *col); H5_DLL unsigned H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size); H5_DLL unsigned H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size); -H5_DLL hsize_t H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, - unsigned start_col, unsigned num_entries); +H5_DLL hsize_t H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, unsigned start_col, + unsigned num_entries); /* Heap header routines */ -H5_DLL H5HF_hdr_t * H5HF_hdr_alloc(H5F_t *f); -H5_DLL haddr_t H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam); +H5_DLL H5HF_hdr_t *H5HF_hdr_alloc(H5F_t *f); +H5_DLL haddr_t H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam); H5_DLL H5HF_hdr_t *H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags); -H5_DLL herr_t H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_finish_init(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_incr(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_decr(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_fuse_incr(H5HF_hdr_t *hdr); -H5_DLL size_t H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_dirty(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt); -H5_DLL herr_t H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free); -H5_DLL herr_t H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size); -H5_DLL herr_t H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, unsigned curr_entry); -H5_DLL herr_t H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, - unsigned start_entry, unsigned nentries); -H5_DLL herr_t H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size); -H5_DLL herr_t H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries); -H5_DLL herr_t H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr); -H5_DLL herr_t H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off); -H5_DLL herr_t H5HF__hdr_empty(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_free(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF__hdr_delete(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_dest(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_finish_init(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_incr(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_decr(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_fuse_incr(H5HF_hdr_t *hdr); +H5_DLL size_t H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_dirty(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt); +H5_DLL herr_t H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free); +H5_DLL herr_t H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size); +H5_DLL herr_t H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, + unsigned curr_entry); +H5_DLL herr_t H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, + unsigned nentries); +H5_DLL herr_t H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size); +H5_DLL herr_t H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries); +H5_DLL herr_t H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr); +H5_DLL herr_t H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off); +H5_DLL herr_t H5HF__hdr_empty(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_free(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_delete(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_dest(H5HF_hdr_t *hdr); /* Indirect block routines */ H5_DLL herr_t H5HF_iblock_incr(H5HF_indirect_t *iblock); H5_DLL herr_t H5HF__iblock_decr(H5HF_indirect_t *iblock); H5_DLL herr_t H5HF_iblock_dirty(H5HF_indirect_t *iblock); -H5_DLL herr_t H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, - size_t min_dblock_size); -H5_DLL herr_t H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, - size_t min_dblock_size); -H5_DLL herr_t H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, - H5HF_free_section_t **sec_node); -H5_DLL herr_t H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, - unsigned par_entry, unsigned nrows, unsigned max_rows, haddr_t *addr_p); -H5_DLL H5HF_indirect_t *H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, - hbool_t must_protect, unsigned flags, hbool_t *did_protect); -H5_DLL herr_t H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, - hbool_t did_protect); -H5_DLL herr_t H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, - haddr_t dblock_addr); +H5_DLL herr_t H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, size_t min_dblock_size); +H5_DLL herr_t H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size); +H5_DLL herr_t H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, H5HF_free_section_t **sec_node); +H5_DLL herr_t H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned par_entry, + unsigned nrows, unsigned max_rows, haddr_t *addr_p); +H5_DLL H5HF_indirect_t *H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry, + hbool_t must_protect, unsigned flags, hbool_t *did_protect); +H5_DLL herr_t H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, hbool_t did_protect); +H5_DLL herr_t H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t dblock_addr); H5_DLL herr_t H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry); -H5_DLL herr_t H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, - haddr_t *child_addr); -H5_DLL herr_t H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry); -H5_DLL herr_t H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, - haddr_t iblock_addr, unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size/*out*/); -H5_DLL herr_t H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, - hsize_t block_off, hsize_t *ret_par_block_off, unsigned *ret_entry); +H5_DLL herr_t H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *child_addr); +H5_DLL herr_t H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry); +H5_DLL herr_t H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry, + hsize_t *heap_size /*out*/); +H5_DLL herr_t H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, + hsize_t *ret_par_block_off, unsigned *ret_entry); H5_DLL herr_t H5HF_man_iblock_dest(H5HF_indirect_t *iblock); /* Direct block routines */ -H5_DLL herr_t H5HF__man_dblock_new(H5HF_hdr_t *fh, size_t request, - H5HF_free_section_t **ret_sec_node); -H5_DLL herr_t H5HF__man_dblock_create(H5HF_hdr_t *hdr, - H5HF_indirect_t *par_iblock, unsigned par_entry, haddr_t *addr_p, - H5HF_free_section_t **ret_sec_node); -H5_DLL herr_t H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, - haddr_t dblock_addr, hbool_t *parent_removed); -H5_DLL H5HF_direct_t *H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, - size_t dblock_size, H5HF_indirect_t *par_iblock, unsigned par_entry, - unsigned flags); -H5_DLL herr_t H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, - H5HF_indirect_t **par_iblock, unsigned *par_entry, hbool_t *par_did_protect, - unsigned flags); -H5_DLL herr_t H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, - hsize_t dblock_size); -H5_DLL herr_t H5HF_man_dblock_dest(H5HF_direct_t *dblock); +H5_DLL herr_t H5HF__man_dblock_new(H5HF_hdr_t *fh, size_t request, H5HF_free_section_t **ret_sec_node); +H5_DLL herr_t H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned par_entry, + haddr_t *addr_p, H5HF_free_section_t **ret_sec_node); +H5_DLL herr_t H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, haddr_t dblock_addr, + hbool_t *parent_removed); +H5_DLL H5HF_direct_t *H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, size_t dblock_size, + H5HF_indirect_t *par_iblock, unsigned par_entry, + unsigned flags); +H5_DLL herr_t H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, H5HF_indirect_t **par_iblock, + unsigned *par_entry, hbool_t *par_did_protect, unsigned flags); +H5_DLL herr_t H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size); +H5_DLL herr_t H5HF_man_dblock_dest(H5HF_direct_t *dblock); /* Managed object routines */ -H5_DLL herr_t H5HF__man_insert(H5HF_hdr_t *fh, size_t obj_size, - const void *obj, void *id); -H5_DLL herr_t H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, - size_t *obj_len_p); -H5_DLL void H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, - hsize_t *obj_off_p); +H5_DLL herr_t H5HF__man_insert(H5HF_hdr_t *fh, size_t obj_size, const void *obj, void *id); +H5_DLL herr_t H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p); +H5_DLL void H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p); H5_DLL herr_t H5HF__man_read(H5HF_hdr_t *fh, const uint8_t *id, void *obj); H5_DLL herr_t H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj); -H5_DLL herr_t H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, - void *op_data); +H5_DLL herr_t H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); H5_DLL herr_t H5HF__man_remove(H5HF_hdr_t *hdr, const uint8_t *id); /* 'Huge' object routines */ H5_DLL herr_t H5HF_huge_init(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, - void *obj, void *id); -H5_DLL herr_t H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, - size_t *obj_len_p); -H5_DLL herr_t H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, - hsize_t *obj_off_p); -H5_DLL herr_t H5HF__huge_read(H5HF_hdr_t *fh, const uint8_t *id, - void *obj); -H5_DLL herr_t H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, - const void *obj); -H5_DLL herr_t H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data); +H5_DLL herr_t H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *id); +H5_DLL herr_t H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p); +H5_DLL herr_t H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p); +H5_DLL herr_t H5HF__huge_read(H5HF_hdr_t *fh, const uint8_t *id, void *obj); +H5_DLL herr_t H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj); +H5_DLL herr_t H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); H5_DLL herr_t H5HF__huge_remove(H5HF_hdr_t *fh, const uint8_t *id); H5_DLL herr_t H5HF__huge_term(H5HF_hdr_t *hdr); H5_DLL herr_t H5HF__huge_delete(H5HF_hdr_t *hdr); @@ -732,76 +716,62 @@ H5_DLL herr_t H5HF__huge_bt2_filt_dir_remove(const void *nrecord, void *op_data) /* 'Tiny' object routines */ H5_DLL herr_t H5HF_tiny_init(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, - void *id); -H5_DLL herr_t H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, - size_t *obj_len_p); +H5_DLL herr_t H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *id); +H5_DLL herr_t H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p); H5_DLL herr_t H5HF_tiny_read(H5HF_hdr_t *fh, const uint8_t *id, void *obj); -H5_DLL herr_t H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data); +H5_DLL herr_t H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); H5_DLL herr_t H5HF_tiny_remove(H5HF_hdr_t *fh, const uint8_t *id); /* Debugging routines for dumping file structures */ -H5_DLL void H5HF_hdr_print(const H5HF_hdr_t *hdr, hbool_t dump_internal, - FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5HF_dblock_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, haddr_t hdr_addr, size_t nrec); -H5_DLL void H5HF_iblock_print(const H5HF_indirect_t *iblock, hbool_t dump_internal, - FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5HF_iblock_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, haddr_t hdr_addr, unsigned nrows); +H5_DLL void H5HF_hdr_print(const H5HF_hdr_t *hdr, hbool_t dump_internal, FILE *stream, int indent, + int fwidth); +H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); +H5_DLL herr_t H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + haddr_t hdr_addr, size_t nrec); +H5_DLL void H5HF_iblock_print(const H5HF_indirect_t *iblock, hbool_t dump_internal, FILE *stream, int indent, + int fwidth); +H5_DLL herr_t H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + haddr_t hdr_addr, unsigned nrows); /* Block iteration routines */ -H5_DLL herr_t H5HF_man_iter_init(H5HF_block_iter_t *biter); -H5_DLL herr_t H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - hsize_t offset); -H5_DLL herr_t H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - H5HF_indirect_t *iblock, unsigned start_entry); -H5_DLL herr_t H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr, - H5HF_block_iter_t *biter, unsigned entry); -H5_DLL herr_t H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - unsigned nentries); -H5_DLL herr_t H5HF_man_iter_up(H5HF_block_iter_t *biter); -H5_DLL herr_t H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock); -H5_DLL herr_t H5HF_man_iter_reset(H5HF_block_iter_t *biter); -H5_DLL herr_t H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, - unsigned *entry, H5HF_indirect_t **block); -H5_DLL herr_t H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - hsize_t *offset); +H5_DLL herr_t H5HF_man_iter_init(H5HF_block_iter_t *biter); +H5_DLL herr_t H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t offset); +H5_DLL herr_t H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, H5HF_indirect_t *iblock, + unsigned start_entry); +H5_DLL herr_t H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned entry); +H5_DLL herr_t H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries); +H5_DLL herr_t H5HF_man_iter_up(H5HF_block_iter_t *biter); +H5_DLL herr_t H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock); +H5_DLL herr_t H5HF_man_iter_reset(H5HF_block_iter_t *biter); +H5_DLL herr_t H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, unsigned *entry, + H5HF_indirect_t **block); +H5_DLL herr_t H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t *offset); H5_DLL hbool_t H5HF_man_iter_ready(H5HF_block_iter_t *biter); /* Free space manipulation routines */ H5_DLL herr_t H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create); -H5_DLL herr_t H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, - unsigned flags); -H5_DLL htri_t H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, - H5HF_free_section_t **node); +H5_DLL herr_t H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags); +H5_DLL htri_t H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node); H5_DLL herr_t H5HF__space_revert_root(const H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF__space_create_root(const H5HF_hdr_t *hdr, - H5HF_indirect_t *root_iblock); +H5_DLL herr_t H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock); H5_DLL herr_t H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size); H5_DLL herr_t H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node); H5_DLL herr_t H5HF__space_close(H5HF_hdr_t *hdr); H5_DLL herr_t H5HF__space_delete(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF__space_sect_change_class(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect, uint16_t new_class); +H5_DLL herr_t H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, uint16_t new_class); /* Free space section routines */ -H5_DLL H5HF_free_section_t *H5HF_sect_single_new(hsize_t sect_off, - size_t sect_size, H5HF_indirect_t *parent, unsigned par_entry); -H5_DLL herr_t H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); -H5_DLL herr_t H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, - const H5HF_free_section_t *sect, haddr_t *dblock_addr, size_t *dblock_size); -H5_DLL herr_t H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - size_t amt); -H5_DLL herr_t H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); -H5_DLL herr_t H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - unsigned *entry_p); +H5_DLL H5HF_free_section_t *H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, H5HF_indirect_t *parent, + unsigned par_entry); +H5_DLL herr_t H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +H5_DLL herr_t H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, + haddr_t *dblock_addr, size_t *dblock_size); +H5_DLL herr_t H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt); +H5_DLL herr_t H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +H5_DLL herr_t H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned *entry_p); H5_DLL H5HF_indirect_t *H5HF_sect_row_get_iblock(H5HF_free_section_t *sect); -H5_DLL herr_t H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, - unsigned start_entry, unsigned nentries); +H5_DLL herr_t H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, + unsigned nentries); H5_DLL herr_t H5HF__sect_single_free(H5FS_section_info_t *sect); /* Internal operator callbacks */ @@ -810,21 +780,18 @@ H5_DLL herr_t H5HF_op_write(const void *obj, size_t obj_len, void *op_data); /* Testing routines */ #ifdef H5HF_TESTING -H5_DLL herr_t H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam); -H5_DLL int H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2); +H5_DLL herr_t H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam); +H5_DLL int H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2); H5_DLL unsigned H5HF_get_max_root_rows(const H5HF_t *fh); H5_DLL unsigned H5HF_get_dtable_width_test(const H5HF_t *fh); H5_DLL unsigned H5HF_get_dtable_max_drows_test(const H5HF_t *fh); H5_DLL unsigned H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos); -H5_DLL hsize_t H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row); -H5_DLL hsize_t H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row); -H5_DLL herr_t H5HF_get_id_off_test(const H5HF_t *fh, const void *id, hsize_t *obj_off); -H5_DLL herr_t H5HF_get_id_type_test(const void *id, unsigned char *obj_type); -H5_DLL herr_t H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, - hbool_t *len_extended); -H5_DLL herr_t H5HF_get_huge_info_test(const H5HF_t *fh, hsize_t *next_id, - hbool_t *ids_direct); +H5_DLL hsize_t H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row); +H5_DLL hsize_t H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row); +H5_DLL herr_t H5HF_get_id_off_test(const H5HF_t *fh, const void *id, hsize_t *obj_off); +H5_DLL herr_t H5HF_get_id_type_test(const void *id, unsigned char *obj_type); +H5_DLL herr_t H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, hbool_t *len_extended); +H5_DLL herr_t H5HF_get_huge_info_test(const H5HF_t *fh, hsize_t *next_id, hbool_t *ids_direct); #endif /* H5HF_TESTING */ #endif /* _H5HFpkg_H */ - diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h index 4eec1c1..6b6fd67 100644 --- a/src/H5HFprivate.h +++ b/src/H5HFprivate.h @@ -26,8 +26,8 @@ #define _H5HFprivate_H /* Private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Fprivate.h" /* File access */ +#include "H5Oprivate.h" /* Object headers */ /**************************/ /* Library Private Macros */ @@ -36,8 +36,7 @@ /* Limit heap ID length to 4096 + 1, due to # of bits required to store * length of 'tiny' objects (12 bits) */ -#define H5HF_MAX_ID_LEN (4096 + 1) - +#define H5HF_MAX_ID_LEN (4096 + 1) /****************************/ /* Library Private Typedefs */ @@ -45,59 +44,58 @@ /* Creation parameters for doubling-tables */ typedef struct H5HF_dtable_cparam_t { - unsigned width; /* Number of columns in the table (must be power of 2) */ - size_t start_block_size; /* Starting block size for table (must be power of 2) */ - size_t max_direct_size; /* Maximum size of a direct block (must be power of 2) */ - unsigned max_index; /* Maximum ID/offset for table (integer log2 of actual value, ie. the # of bits required) */ - unsigned start_root_rows; /* Starting number of rows for root indirect block */ - /* 0 indicates to create the full indirect block for the root, - * right from the start. Doesn't have to be power of 2 - */ + unsigned width; /* Number of columns in the table (must be power of 2) */ + size_t start_block_size; /* Starting block size for table (must be power of 2) */ + size_t max_direct_size; /* Maximum size of a direct block (must be power of 2) */ + unsigned max_index; /* Maximum ID/offset for table (integer log2 of actual value, ie. the # of bits + required) */ + unsigned start_root_rows; /* Starting number of rows for root indirect block */ + /* 0 indicates to create the full indirect block for the root, + * right from the start. Doesn't have to be power of 2 + */ } H5HF_dtable_cparam_t; /* Fractal heap creation parameters */ typedef struct H5HF_create_t { - H5HF_dtable_cparam_t managed;/* Mapped object doubling-table creation parameters */ - hbool_t checksum_dblocks; /* Whether the direct blocks should be checksummed */ - uint32_t max_man_size; /* Max. size of object to manage in doubling table */ - /* (i.e. min. size of object to store standalone) */ - uint16_t id_len; /* Length of IDs to use for heap objects */ - /* (0 - make ID just large enough to hold length & offset of object in the heap) */ - /* (1 - make ID just large enough to allow 'huge' objects to be accessed directly) */ - /* (n - make ID 'n' bytes in size) */ - H5O_pline_t pline; /* I/O filter pipeline to apply to direct blocks & 'huge' objects */ + H5HF_dtable_cparam_t managed; /* Mapped object doubling-table creation parameters */ + hbool_t checksum_dblocks; /* Whether the direct blocks should be checksummed */ + uint32_t max_man_size; /* Max. size of object to manage in doubling table */ + /* (i.e. min. size of object to store standalone) */ + uint16_t id_len; /* Length of IDs to use for heap objects */ + /* (0 - make ID just large enough to hold length & offset of object in the heap) */ + /* (1 - make ID just large enough to allow 'huge' objects to be accessed directly) */ + /* (n - make ID 'n' bytes in size) */ + H5O_pline_t pline; /* I/O filter pipeline to apply to direct blocks & 'huge' objects */ } H5HF_create_t; /* Fractal heap metadata statistics info */ typedef struct H5HF_stat_t { /* 'Managed' object info */ - hsize_t man_size; /* Size of 'managed' space in heap */ - hsize_t man_alloc_size; /* Size of 'managed' space allocated in heap */ - hsize_t man_iter_off; /* Offset of "new block" iterator in 'managed' heap space */ - hsize_t man_free_space; /* Free space within 'managed' heap blocks */ - hsize_t man_nobjs; /* Number of 'managed' objects in heap */ + hsize_t man_size; /* Size of 'managed' space in heap */ + hsize_t man_alloc_size; /* Size of 'managed' space allocated in heap */ + hsize_t man_iter_off; /* Offset of "new block" iterator in 'managed' heap space */ + hsize_t man_free_space; /* Free space within 'managed' heap blocks */ + hsize_t man_nobjs; /* Number of 'managed' objects in heap */ /* 'Huge' object info */ - hsize_t huge_size; /* Size of 'huge' objects in heap */ - hsize_t huge_nobjs; /* Number of 'huge' objects in heap */ + hsize_t huge_size; /* Size of 'huge' objects in heap */ + hsize_t huge_nobjs; /* Number of 'huge' objects in heap */ /* 'Tiny' object info */ - hsize_t tiny_size; /* Size of 'tiny' objects in heap */ - hsize_t tiny_nobjs; /* Number of 'tiny' objects in heap */ + hsize_t tiny_size; /* Size of 'tiny' objects in heap */ + hsize_t tiny_nobjs; /* Number of 'tiny' objects in heap */ } H5HF_stat_t; /* Fractal heap info (forward decl - defined in H5HFpkg.h) */ typedef struct H5HF_t H5HF_t; /* Typedef for 'op' operations */ -typedef herr_t (*H5HF_operator_t)(const void *obj/*in*/, size_t obj_len, - void *op_data/*in,out*/); +typedef herr_t (*H5HF_operator_t)(const void *obj /*in*/, size_t obj_len, void *op_data /*in,out*/); /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -105,22 +103,21 @@ typedef herr_t (*H5HF_operator_t)(const void *obj/*in*/, size_t obj_len, /* General routines for fractal heap operations */ H5_DLL H5HF_t *H5HF_create(H5F_t *f, const H5HF_create_t *cparam); H5_DLL H5HF_t *H5HF_open(H5F_t *f, haddr_t fh_addr); -H5_DLL herr_t H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p/*out*/); -H5_DLL herr_t H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr/*out*/); -H5_DLL herr_t H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/); -H5_DLL herr_t H5HF_get_obj_len(H5HF_t *fh, const void *id, size_t *obj_len_p/*out*/); -H5_DLL herr_t H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p/*out*/); -H5_DLL herr_t H5HF_read(H5HF_t *fh, const void *id, void *obj/*out*/); -H5_DLL herr_t H5HF_write(H5HF_t *fh, void *id, hbool_t *id_changed, - const void *obj); -H5_DLL herr_t H5HF_op(H5HF_t *fh, const void *id, H5HF_operator_t op, void *op_data); -H5_DLL herr_t H5HF_remove(H5HF_t *fh, const void *id); -H5_DLL herr_t H5HF_close(H5HF_t *fh); -H5_DLL herr_t H5HF_delete(H5F_t *f, haddr_t fh_addr); +H5_DLL herr_t H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p /*out*/); +H5_DLL herr_t H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr /*out*/); +H5_DLL herr_t H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id /*out*/); +H5_DLL herr_t H5HF_get_obj_len(H5HF_t *fh, const void *id, size_t *obj_len_p /*out*/); +H5_DLL herr_t H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p /*out*/); +H5_DLL herr_t H5HF_read(H5HF_t *fh, const void *id, void *obj /*out*/); +H5_DLL herr_t H5HF_write(H5HF_t *fh, void *id, hbool_t *id_changed, const void *obj); +H5_DLL herr_t H5HF_op(H5HF_t *fh, const void *id, H5HF_operator_t op, void *op_data); +H5_DLL herr_t H5HF_remove(H5HF_t *fh, const void *id); +H5_DLL herr_t H5HF_close(H5HF_t *fh); +H5_DLL herr_t H5HF_delete(H5F_t *f, haddr_t fh_addr); /* Statistics routines */ H5_DLL herr_t H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats); -H5_DLL herr_t H5HF_size(const H5HF_t *fh, hsize_t *heap_size/*out*/); +H5_DLL herr_t H5HF_size(const H5HF_t *fh, hsize_t *heap_size /*out*/); /* Debugging routines */ H5_DLL herr_t H5HF_id_print(H5HF_t *fh, const void *id, FILE *stream, int indent, int fwidth); @@ -129,4 +126,3 @@ H5_DLL herr_t H5HF_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, #endif /* H5HF_DEBUGGING */ #endif /* _H5HFprivate_H */ - diff --git a/src/H5HFsection.c b/src/H5HFsection.c index a0f984b..3e437a9 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -23,159 +23,133 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ /* Size of serialized indirect section information */ -#define H5HF_SECT_INDIRECT_SERIAL_SIZE(h) ( \ - (unsigned)(h)->heap_off_size /* Indirect block's offset in "heap space" */ \ - + (unsigned)2 /* Row */ \ - + (unsigned)2 /* Column */ \ - + (unsigned)2 /* # of entries */ \ +#define H5HF_SECT_INDIRECT_SERIAL_SIZE(h) \ + ((unsigned)(h)->heap_off_size /* Indirect block's offset in "heap space" */ \ + + (unsigned)2 /* Row */ \ + + (unsigned)2 /* Column */ \ + + (unsigned)2 /* # of entries */ \ ) - /******************/ /* Local Typedefs */ /******************/ /* Typedef for "class private" information for sections */ typedef struct { - H5HF_hdr_t *hdr; /* Pointer to fractal heap header */ + H5HF_hdr_t *hdr; /* Pointer to fractal heap header */ } H5HF_sect_private_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Shared routines */ -static herr_t H5HF_sect_init_cls(H5FS_section_class_t *cls, - H5HF_hdr_t *hdr); -static herr_t H5HF_sect_term_cls(H5FS_section_class_t *cls); -static H5HF_free_section_t *H5HF_sect_node_new(unsigned sect_type, - haddr_t sect_addr, hsize_t sect_size, H5FS_section_state_t state); -static herr_t H5HF_sect_node_free(H5HF_free_section_t *sect, - H5HF_indirect_t *parent); +static herr_t H5HF_sect_init_cls(H5FS_section_class_t *cls, H5HF_hdr_t *hdr); +static herr_t H5HF_sect_term_cls(H5FS_section_class_t *cls); +static H5HF_free_section_t *H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, + H5FS_section_state_t state); +static herr_t H5HF_sect_node_free(H5HF_free_section_t *sect, H5HF_indirect_t *parent); /* 'single' section routines */ -static herr_t H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, - H5HF_free_section_t *sect); +static herr_t H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, H5HF_free_section_t *sect); static herr_t H5HF__sect_single_full_dblock(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); /* 'single' section callbacks */ -static herr_t H5HF__sect_single_add(H5FS_section_info_t **sect, unsigned *flags, - void *udata); -static H5FS_section_info_t *H5HF__sect_single_deserialize(const H5FS_section_class_t *cls, - const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, - unsigned *des_flags); -static htri_t H5HF__sect_single_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5HF__sect_single_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static htri_t H5HF__sect_single_can_shrink(const H5FS_section_info_t *sect, - void *udata); -static herr_t H5HF__sect_single_shrink(H5FS_section_info_t **_sect, - void *udata); -static herr_t H5HF__sect_single_valid(const H5FS_section_class_t *cls, - const H5FS_section_info_t *sect); +static herr_t H5HF__sect_single_add(H5FS_section_info_t **sect, unsigned *flags, void *udata); +static H5FS_section_info_t *H5HF__sect_single_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, + haddr_t sect_addr, hsize_t sect_size, + unsigned *des_flags); +static htri_t H5HF__sect_single_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5HF__sect_single_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static htri_t H5HF__sect_single_can_shrink(const H5FS_section_info_t *sect, void *udata); +static herr_t H5HF__sect_single_shrink(H5FS_section_info_t **_sect, void *udata); +static herr_t H5HF__sect_single_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect); /* 'row' section routines */ -static H5HF_free_section_t *H5HF_sect_row_create(haddr_t sect_off, - hsize_t sect_size, hbool_t is_first, unsigned row, unsigned col, - unsigned nentries, H5HF_free_section_t *under_sect); -static herr_t H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); -static herr_t H5HF__sect_row_parent_removed(H5HF_free_section_t *sect); -static herr_t H5HF_sect_row_from_single(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect, H5HF_direct_t *dblock); +static H5HF_free_section_t *H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, + unsigned row, unsigned col, unsigned nentries, + H5HF_free_section_t *under_sect); +static herr_t H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +static herr_t H5HF__sect_row_parent_removed(H5HF_free_section_t *sect); +static herr_t H5HF_sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_direct_t *dblock); static herr_t H5HF__sect_row_free_real(H5HF_free_section_t *sect); /* 'row' section callbacks */ static herr_t H5HF__sect_row_init_cls(H5FS_section_class_t *cls, void *udata); static herr_t H5HF__sect_row_term_cls(H5FS_section_class_t *cls); -static herr_t H5HF__sect_row_serialize(const H5FS_section_class_t *cls, - const H5FS_section_info_t *sect, uint8_t *buf); -static H5FS_section_info_t *H5HF__sect_row_deserialize(const H5FS_section_class_t *cls, - const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, - unsigned *des_flags); -static htri_t H5HF__sect_row_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5HF__sect_row_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static htri_t H5HF__sect_row_can_shrink(const H5FS_section_info_t *sect, - void *udata); -static herr_t H5HF__sect_row_shrink(H5FS_section_info_t **sect, - void *udata); +static herr_t H5HF__sect_row_serialize(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect, + uint8_t *buf); +static H5FS_section_info_t *H5HF__sect_row_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, + haddr_t sect_addr, hsize_t sect_size, + unsigned *des_flags); +static htri_t H5HF__sect_row_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5HF__sect_row_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static htri_t H5HF__sect_row_can_shrink(const H5FS_section_info_t *sect, void *udata); +static herr_t H5HF__sect_row_shrink(H5FS_section_info_t **sect, void *udata); static herr_t H5HF__sect_row_free(H5FS_section_info_t *sect); -static herr_t H5HF__sect_row_valid(const H5FS_section_class_t *cls, - const H5FS_section_info_t *sect); -static herr_t H5HF__sect_row_debug(const H5FS_section_info_t *sect, - FILE *stream, int indent, int fwidth); +static herr_t H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect); +static herr_t H5HF__sect_row_debug(const H5FS_section_info_t *sect, FILE *stream, int indent, int fwidth); /* 'indirect' section routines */ -static H5HF_free_section_t *H5HF_sect_indirect_new(H5HF_hdr_t *hdr, - haddr_t sect_off, hsize_t sect_size, - H5HF_indirect_t *iblock, hsize_t iblock_off, - unsigned row, unsigned col, unsigned nentries); -static herr_t H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - hbool_t first_child, H5HF_free_section_t **first_row_sect, - unsigned space_flags, unsigned start_row, unsigned start_col, - unsigned end_row, unsigned end_col); -static H5HF_free_section_t *H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, - H5HF_indirect_t *iblock, H5HF_free_section_t *row_sect); -static herr_t H5HF_sect_indirect_decr(H5HF_free_section_t *sect); -static herr_t H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect); -static herr_t H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect, H5HF_indirect_t *sect_iblock); -static herr_t H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, - H5HF_free_section_t *row_sect, hbool_t *alloc_from_start); -static herr_t H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect, unsigned child_entry); -static herr_t H5HF__sect_indirect_first(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect); +static H5HF_free_section_t *H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, + H5HF_indirect_t *iblock, hsize_t iblock_off, unsigned row, + unsigned col, unsigned nentries); +static herr_t H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, hbool_t first_child, + H5HF_free_section_t **first_row_sect, unsigned space_flags, + unsigned start_row, unsigned start_col, unsigned end_row, + unsigned end_col); +static H5HF_free_section_t *H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, + H5HF_free_section_t *row_sect); +static herr_t H5HF_sect_indirect_decr(H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, + H5HF_indirect_t *sect_iblock); +static herr_t H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, + hbool_t *alloc_from_start); +static herr_t H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned child_entry); +static herr_t H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); static hbool_t H5HF_sect_indirect_is_first(H5HF_free_section_t *sect); -static H5HF_indirect_t * H5HF_sect_indirect_get_iblock(H5HF_free_section_t *sect); -static hsize_t H5HF_sect_indirect_iblock_off(const H5HF_free_section_t *sect); -static H5HF_free_section_t * H5HF_sect_indirect_top(H5HF_free_section_t *sect); -static herr_t H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect1, H5HF_free_section_t *sect2); -static herr_t H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); -static herr_t H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect); -static herr_t H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, - const H5HF_free_section_t *sect, uint8_t *buf); -static H5FS_section_info_t *H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, - const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); -static herr_t H5HF_sect_indirect_free(H5HF_free_section_t *sect); -static herr_t H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, - const H5HF_free_section_t *sect); -static herr_t H5HF_sect_indirect_debug(const H5HF_free_section_t *sect, - FILE *stream, int indent, int fwidth); +static H5HF_indirect_t * H5HF_sect_indirect_get_iblock(H5HF_free_section_t *sect); +static hsize_t H5HF_sect_indirect_iblock_off(const H5HF_free_section_t *sect); +static H5HF_free_section_t *H5HF_sect_indirect_top(H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect1, + H5HF_free_section_t *sect2); +static herr_t H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +static herr_t H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, uint8_t *buf); +static H5FS_section_info_t *H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, + haddr_t sect_addr, hsize_t sect_size, + unsigned *des_flags); +static herr_t H5HF_sect_indirect_free(H5HF_free_section_t *sect); +static herr_t H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect); +static herr_t H5HF_sect_indirect_debug(const H5HF_free_section_t *sect, FILE *stream, int indent, int fwidth); /* 'indirect' section callbacks */ static herr_t H5HF_sect_indirect_init_cls(H5FS_section_class_t *cls, void *udata); static herr_t H5HF_sect_indirect_term_cls(H5FS_section_class_t *cls); - /*********************/ /* Package Variables */ /*********************/ @@ -183,27 +157,27 @@ static herr_t H5HF_sect_indirect_term_cls(H5FS_section_class_t *cls); /* Class info for "single" free space sections */ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_SINGLE[1] = {{ /* Class variables */ - H5HF_FSPACE_SECT_SINGLE, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM, /* Class flags */ - NULL, /* Class private info */ + H5HF_FSPACE_SECT_SINGLE, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - H5HF__sect_single_add, /* Add section */ - NULL, /* Serialize section */ - H5HF__sect_single_deserialize, /* Deserialize section */ - H5HF__sect_single_can_merge, /* Can sections merge? */ - H5HF__sect_single_merge, /* Merge sections */ - H5HF__sect_single_can_shrink, /* Can section shrink container?*/ - H5HF__sect_single_shrink, /* Shrink container w/section */ - H5HF__sect_single_free, /* Free section */ - H5HF__sect_single_valid, /* Check validity of section */ - NULL, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + H5HF__sect_single_add, /* Add section */ + NULL, /* Serialize section */ + H5HF__sect_single_deserialize, /* Deserialize section */ + H5HF__sect_single_can_merge, /* Can sections merge? */ + H5HF__sect_single_merge, /* Merge sections */ + H5HF__sect_single_can_shrink, /* Can section shrink container?*/ + H5HF__sect_single_shrink, /* Shrink container w/section */ + H5HF__sect_single_free, /* Free section */ + H5HF__sect_single_valid, /* Check validity of section */ + NULL, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; /* Class info for "first row" free space sections */ @@ -212,53 +186,53 @@ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_SINGLE[1] = {{ */ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_FIRST_ROW[1] = {{ /* Class variables */ - H5HF_FSPACE_SECT_FIRST_ROW, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM, /* Class flags */ - NULL, /* Class private info */ + H5HF_FSPACE_SECT_FIRST_ROW, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - H5HF__sect_row_init_cls, /* Initialize section class */ - H5HF__sect_row_term_cls, /* Terminate section class */ + H5HF__sect_row_init_cls, /* Initialize section class */ + H5HF__sect_row_term_cls, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - H5HF__sect_row_serialize, /* Serialize section */ - H5HF__sect_row_deserialize, /* Deserialize section */ - H5HF__sect_row_can_merge, /* Can sections merge? */ - H5HF__sect_row_merge, /* Merge sections */ - H5HF__sect_row_can_shrink, /* Can section shrink container?*/ - H5HF__sect_row_shrink, /* Shrink container w/section */ - H5HF__sect_row_free, /* Free section */ - H5HF__sect_row_valid, /* Check validity of section */ - NULL, /* Split section node for alignment */ - H5HF__sect_row_debug, /* Dump debugging for section */ + NULL, /* Add section */ + H5HF__sect_row_serialize, /* Serialize section */ + H5HF__sect_row_deserialize, /* Deserialize section */ + H5HF__sect_row_can_merge, /* Can sections merge? */ + H5HF__sect_row_merge, /* Merge sections */ + H5HF__sect_row_can_shrink, /* Can section shrink container?*/ + H5HF__sect_row_shrink, /* Shrink container w/section */ + H5HF__sect_row_free, /* Free section */ + H5HF__sect_row_valid, /* Check validity of section */ + NULL, /* Split section node for alignment */ + H5HF__sect_row_debug, /* Dump debugging for section */ }}; /* Class info for "normal row" free space sections */ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_NORMAL_ROW[1] = {{ /* Class variables */ - H5HF_FSPACE_SECT_NORMAL_ROW, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM|H5FS_CLS_SEPAR_OBJ|H5FS_CLS_GHOST_OBJ, /* Class flags */ - NULL, /* Class private info */ + H5HF_FSPACE_SECT_NORMAL_ROW, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_SEPAR_OBJ | H5FS_CLS_GHOST_OBJ, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - H5HF__sect_row_init_cls, /* Initialize section class */ - H5HF__sect_row_term_cls, /* Terminate section class */ + H5HF__sect_row_init_cls, /* Initialize section class */ + H5HF__sect_row_term_cls, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - NULL, /* Deserialize section */ - NULL, /* Can sections merge? */ - NULL, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - H5HF__sect_row_free, /* Free section */ - H5HF__sect_row_valid, /* Check validity of section */ - NULL, /* Split section node for alignment */ - H5HF__sect_row_debug, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + NULL, /* Deserialize section */ + NULL, /* Can sections merge? */ + NULL, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + H5HF__sect_row_free, /* Free section */ + H5HF__sect_row_valid, /* Check validity of section */ + NULL, /* Split section node for alignment */ + H5HF__sect_row_debug, /* Dump debugging for section */ }}; /* Class info for "indirect" free space sections */ @@ -267,44 +241,40 @@ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_NORMAL_ROW[1] = {{ */ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_INDIRECT[1] = {{ /* Class variables */ - H5HF_FSPACE_SECT_INDIRECT, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM|H5FS_CLS_GHOST_OBJ, /* Class flags */ - NULL, /* Class private info */ + H5HF_FSPACE_SECT_INDIRECT, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_GHOST_OBJ, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - H5HF_sect_indirect_init_cls, /* Initialize section class */ - H5HF_sect_indirect_term_cls, /* Terminate section class */ + H5HF_sect_indirect_init_cls, /* Initialize section class */ + H5HF_sect_indirect_term_cls, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - NULL, /* Deserialize section */ - NULL, /* Can sections merge? */ - NULL, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - NULL, /* Free section */ - NULL, /* Check validity of section */ - NULL, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + NULL, /* Deserialize section */ + NULL, /* Can sections merge? */ + NULL, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + NULL, /* Free section */ + NULL, /* Check validity of section */ + NULL, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; /* Declare a free list to manage the H5HF_free_section_t struct */ H5FL_DEFINE(H5HF_free_section_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF_sect_init_cls * @@ -321,8 +291,8 @@ H5FL_DEFINE(H5HF_free_section_t); static herr_t H5HF_sect_init_cls(H5FS_section_class_t *cls, H5HF_hdr_t *hdr) { - H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -333,20 +303,19 @@ H5HF_sect_init_cls(H5FS_section_class_t *cls, H5HF_hdr_t *hdr) /* Allocate & initialize the class-private (i.e. private shared) information * for this type of section */ - if(NULL == (cls_prvt = (H5HF_sect_private_t *)H5MM_malloc(sizeof(H5HF_sect_private_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - cls_prvt->hdr = hdr; + if (NULL == (cls_prvt = (H5HF_sect_private_t *)H5MM_malloc(sizeof(H5HF_sect_private_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + cls_prvt->hdr = hdr; cls->cls_private = cls_prvt; /* Increment reference count on heap header */ - if(H5HF_hdr_incr(hdr) < 0) + if (H5HF_hdr_incr(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_sect_init_cls() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_term_cls * @@ -363,8 +332,8 @@ done: static herr_t H5HF_sect_term_cls(H5FS_section_class_t *cls) { - H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -375,7 +344,7 @@ H5HF_sect_term_cls(H5FS_section_class_t *cls) cls_prvt = (H5HF_sect_private_t *)cls->cls_private; /* Decrement reference count on heap header */ - if(H5HF_hdr_decr(cls_prvt->hdr) < 0) + if (H5HF_hdr_decr(cls_prvt->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") /* Free the class private information */ @@ -385,7 +354,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_sect_term_cls() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_node_new * @@ -401,11 +369,10 @@ done: *------------------------------------------------------------------------- */ static H5HF_free_section_t * -H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, - H5FS_section_state_t sect_state) +H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, H5FS_section_state_t sect_state) { - H5HF_free_section_t *new_sect; /* New section */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *new_sect; /* New section */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -413,15 +380,16 @@ H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, HDassert(H5F_addr_defined(sect_addr)); /* Create free list section node */ - if(NULL == (new_sect = H5FL_MALLOC(H5HF_free_section_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for direct block free list section") + if (NULL == (new_sect = H5FL_MALLOC(H5HF_free_section_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for direct block free list section") /* Set the information passed in */ new_sect->sect_info.addr = sect_addr; new_sect->sect_info.size = sect_size; /* Set the section's class & state */ - new_sect->sect_info.type = sect_type; + new_sect->sect_info.type = sect_type; new_sect->sect_info.state = sect_state; /* Set return value */ @@ -431,7 +399,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_sect_node_new() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_node_free * @@ -449,25 +416,25 @@ done: static herr_t H5HF_sect_node_free(H5HF_free_section_t *sect, H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(sect); /* Release indirect block, if there was one */ - if(iblock) - if(H5HF__iblock_decr(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on section's indirect block") + if (iblock) + if (H5HF__iblock_decr(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on section's indirect block") /* Release the section */ sect = H5FL_FREE(H5HF_free_section_t, sect); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_node_free() */ +} /* H5HF_sect_node_free() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_single_new * @@ -482,11 +449,10 @@ done: *------------------------------------------------------------------------- */ H5HF_free_section_t * -H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, - H5HF_indirect_t *parent, unsigned par_entry) +H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, H5HF_indirect_t *parent, unsigned par_entry) { - H5HF_free_section_t *sect = NULL; /* 'Single' free space section to add */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Single' free space section to add */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -496,14 +462,16 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, HDassert(sect_size); /* Create free space section node */ - if(NULL == (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_off, (hsize_t)sect_size, H5FS_SECT_LIVE))) + if (NULL == + (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_off, (hsize_t)sect_size, H5FS_SECT_LIVE))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for single section") /* Set the 'single' specific fields */ sect->u.single.parent = parent; - if(sect->u.single.parent) { - if(H5HF_iblock_incr(sect->u.single.parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") + if (sect->u.single.parent) { + if (H5HF_iblock_incr(sect->u.single.parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, + "can't increment reference count on shared indirect block") } /* end if */ sect->u.single.par_entry = par_entry; @@ -511,7 +479,7 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, ret_value = sect; done: - if(!ret_value && sect) { + if (!ret_value && sect) { /* Release the section */ sect = H5FL_FREE(H5HF_free_section_t, sect); } /* end if */ @@ -519,7 +487,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_single_new() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_locate_parent * @@ -534,13 +501,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, - H5HF_free_section_t *sect) +H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, H5HF_free_section_t *sect) { - H5HF_indirect_t *sec_iblock; /* Pointer to section indirect block */ - unsigned sec_entry; /* Entry within section indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *sec_iblock; /* Pointer to section indirect block */ + unsigned sec_entry; /* Entry within section indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -552,28 +518,30 @@ H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, HDassert(sect); /* Look up indirect block containing direct blocks for range */ - if(H5HF__man_dblock_locate(hdr, sect->sect_info.addr, &sec_iblock, &sec_entry, &did_protect, H5AC__READ_ONLY_FLAG) < 0) + if (H5HF__man_dblock_locate(hdr, sect->sect_info.addr, &sec_iblock, &sec_entry, &did_protect, + H5AC__READ_ONLY_FLAG) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section") /* Increment reference count on indirect block that free section is in */ - if(H5HF_iblock_incr(sec_iblock) < 0) + if (H5HF_iblock_incr(sec_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") /* Check for refreshing existing parent information */ - if(refresh) { - if(sect->u.single.parent) { + if (refresh) { + if (sect->u.single.parent) { /* Release hold on previous parent indirect block */ - if(H5HF__iblock_decr(sect->u.single.parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on section's indirect block") + if (H5HF__iblock_decr(sect->u.single.parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on section's indirect block") } /* end if */ - } /* end if */ + } /* end if */ /* Set the information for the section */ - sect->u.single.parent = sec_iblock; + sect->u.single.parent = sec_iblock; sect->u.single.par_entry = sec_entry; /* Unlock indirect block */ - if(H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") sec_iblock = NULL; @@ -581,7 +549,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_single_locate_parent() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_revive * @@ -598,7 +565,7 @@ done: herr_t H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -610,15 +577,15 @@ H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->sect_info.state == H5FS_SECT_SERIALIZED); /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Set the information for the section */ HDassert(H5F_addr_defined(hdr->man_dtable.table_addr)); - sect->u.single.parent = NULL; + sect->u.single.parent = NULL; sect->u.single.par_entry = 0; } /* end if */ else { /* Look up indirect block information for section */ - if(H5HF__sect_single_locate_parent(hdr, FALSE, sect) < 0) + if (H5HF__sect_single_locate_parent(hdr, FALSE, sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get section's parent info") } /* end else */ @@ -629,7 +596,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_single_revive() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_single_dblock_info * @@ -644,8 +610,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, - haddr_t *dblock_addr, size_t *dblock_size) +H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, haddr_t *dblock_addr, + size_t *dblock_size) { FUNC_ENTER_NOAPI_NOERR @@ -660,22 +626,22 @@ H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, HDassert(dblock_size); /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Retrieve direct block info from heap header */ HDassert(H5F_addr_defined(hdr->man_dtable.table_addr)); - *dblock_addr = hdr->man_dtable.table_addr; - *dblock_size = hdr->man_dtable.cparam.start_block_size; + *dblock_addr = hdr->man_dtable.table_addr; + *dblock_size = hdr->man_dtable.cparam.start_block_size; } /* end if */ else { /* Retrieve direct block info from parent indirect block */ - *dblock_addr = sect->u.single.parent->ents[sect->u.single.par_entry].addr; - *dblock_size = hdr->man_dtable.row_block_size[sect->u.single.par_entry / hdr->man_dtable.cparam.width]; + *dblock_addr = sect->u.single.parent->ents[sect->u.single.par_entry].addr; + *dblock_size = + hdr->man_dtable.row_block_size[sect->u.single.par_entry / hdr->man_dtable.cparam.width]; } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_sect_single_dblock_info() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_reduce * @@ -694,7 +660,7 @@ H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, herr_t H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -707,9 +673,9 @@ H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt) HDassert(sect->sect_info.state == H5FS_SECT_LIVE); /* Check for eliminating the section */ - if(sect->sect_info.size == amt) { + if (sect->sect_info.size == amt) { /* Free single section */ - if(H5HF__sect_single_free((H5FS_section_info_t *)sect) < 0) + if (H5HF__sect_single_free((H5FS_section_info_t *)sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free single section node") } /* end if */ else { @@ -718,7 +684,7 @@ H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt) sect->sect_info.size -= amt; /* Re-insert section node into heap's free space */ - if(H5HF__space_add(hdr, sect, 0) < 0) + if (H5HF__space_add(hdr, sect, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add single section to free space manager") } /* end else */ @@ -726,7 +692,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_single_reduce() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_full_dblock * @@ -747,10 +712,10 @@ done: static herr_t H5HF__sect_single_full_dblock(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - haddr_t dblock_addr; /* Section's direct block's address */ - size_t dblock_size; /* Section's direct block's size */ - size_t dblock_overhead; /* Direct block's overhead */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t dblock_addr; /* Section's direct block's address */ + size_t dblock_size; /* Section's direct block's size */ + size_t dblock_overhead; /* Direct block's overhead */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -760,35 +725,35 @@ H5HF__sect_single_full_dblock(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(hdr); /* Retrieve direct block address from section */ - if(H5HF_sect_single_dblock_info(hdr, sect, &dblock_addr, &dblock_size) < 0) + if (H5HF_sect_single_dblock_info(hdr, sect, &dblock_addr, &dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve direct block information") /* Check for section occupying entire direct block */ /* (and not the root direct block) */ dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - if((dblock_size - dblock_overhead) == sect->sect_info.size && - hdr->man_dtable.curr_root_rows > 0) { - H5HF_direct_t *dblock; /* Pointer to direct block for section */ - hbool_t parent_removed; /* Whether the direct block parent was removed from the file */ + if ((dblock_size - dblock_overhead) == sect->sect_info.size && hdr->man_dtable.curr_root_rows > 0) { + H5HF_direct_t *dblock; /* Pointer to direct block for section */ + hbool_t parent_removed; /* Whether the direct block parent was removed from the file */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, sect->u.single.parent, sect->u.single.par_entry, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, sect->u.single.parent, + sect->u.single.par_entry, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block") HDassert(H5F_addr_eq(dblock->block_off + dblock_overhead, sect->sect_info.addr)); /* Convert 'single' section into 'row' section */ - if(H5HF_sect_row_from_single(hdr, sect, dblock) < 0) + if (H5HF_sect_row_from_single(hdr, sect, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't convert single section into row section") /* Destroy direct block */ - if(H5HF__man_dblock_destroy(hdr, dblock, dblock_addr, &parent_removed) < 0) + if (H5HF__man_dblock_destroy(hdr, dblock, dblock_addr, &parent_removed) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release direct block") dblock = NULL; /* If the parent for this direct block was removed and the indirect * section is still "live", switch it to the "serialized" state. */ - if(parent_removed && H5FS_SECT_LIVE == sect->u.row.under->sect_info.state) - if(H5HF__sect_row_parent_removed(sect) < 0) + if (parent_removed && H5FS_SECT_LIVE == sect->u.row.under->sect_info.state) + if (H5HF__sect_row_parent_removed(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUPDATE, FAIL, "can't update section info") } /* end if */ @@ -796,7 +761,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_full_dblock() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_add * @@ -814,17 +778,17 @@ done: static herr_t H5HF__sect_single_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Don't need to check section if we are deserializing, because it should * have already been checked when it was first added */ - if(!(*flags & H5FS_ADD_DESERIALIZING)) { - H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ - H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ + if (!(*flags & H5FS_ADD_DESERIALIZING)) { + H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ + H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ /* Sanity check */ HDassert(sect); @@ -832,14 +796,14 @@ H5HF__sect_single_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata /* Check if single section covers entire direct block it's in */ /* (converts to row section possibly) */ - if(H5HF__sect_single_full_dblock(hdr, (*sect)) < 0) + if (H5HF__sect_single_full_dblock(hdr, (*sect)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't check/convert single section") /* Set the "returned space" flag if the single section was changed * into a row section, so the "merging & shrinking" algorithm * gets executed in the free space manager */ - if((*sect)->sect_info.type != H5HF_FSPACE_SECT_SINGLE) + if ((*sect)->sect_info.type != H5HF_FSPACE_SECT_SINGLE) *flags |= H5FS_ADD_RETURNED_SPACE; } /* end if */ @@ -847,7 +811,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_add() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_deserialize * @@ -863,11 +826,11 @@ done: */ static H5FS_section_info_t * H5HF__sect_single_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, - const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, - hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) + const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, hsize_t sect_size, + unsigned H5_ATTR_UNUSED *des_flags) { - H5HF_free_section_t *new_sect; /* New section */ - H5FS_section_info_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *new_sect; /* New section */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -876,7 +839,8 @@ H5HF__sect_single_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, HDassert(sect_size); /* Create free list section node */ - if(NULL == (new_sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_addr, sect_size, H5FS_SECT_SERIALIZED))) + if (NULL == + (new_sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_addr, sect_size, H5FS_SECT_SERIALIZED))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "allocation failed for direct block free list section") /* Set return value */ @@ -886,7 +850,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_can_merge * @@ -904,19 +867,19 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5HF__sect_single_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5HF__sect_single_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - const H5HF_free_section_t *sect1 = (const H5HF_free_section_t *)_sect1; /* Fractal heap free section */ - const H5HF_free_section_t *sect2 = (const H5HF_free_section_t *)_sect2; /* Fractal heap free section */ - htri_t ret_value = FALSE; /* Return value */ + const H5HF_free_section_t *sect1 = (const H5HF_free_section_t *)_sect1; /* Fractal heap free section */ + const H5HF_free_section_t *sect2 = (const H5HF_free_section_t *)_sect2; /* Fractal heap free section */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Check if second section adjoins first section */ @@ -924,14 +887,13 @@ H5HF__sect_single_can_merge(const H5FS_section_info_t *_sect1, * overhead at the beginning of a block, so no need to check if sections * are actually within the same direct block) */ - if(H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr)) + if (H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr)) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_merge * @@ -949,14 +911,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_single_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void *_udata) +H5HF__sect_single_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { - H5HF_free_section_t **sect1 = (H5HF_free_section_t **)_sect1; /* Fractal heap free section */ - H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ - H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t **sect1 = (H5HF_free_section_t **)_sect1; /* Fractal heap free section */ + H5HF_free_section_t * sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ + H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -971,24 +932,23 @@ H5HF__sect_single_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5HF__sect_single_free((H5FS_section_info_t *)sect2) < 0) + if (H5HF__sect_single_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") /* Check to see if we should revive first section */ - if((*sect1)->sect_info.state != H5FS_SECT_LIVE) - if(H5HF__sect_single_revive(hdr, (*sect1)) < 0) + if ((*sect1)->sect_info.state != H5FS_SECT_LIVE) + if (H5HF__sect_single_revive(hdr, (*sect1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") /* Check if single section covers entire direct block it's in */ /* (converts to row section possibly) */ - if(H5HF__sect_single_full_dblock(hdr, (*sect1)) < 0) + if (H5HF__sect_single_full_dblock(hdr, (*sect1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't check/convert single section") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_merge() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_can_shrink * @@ -1010,10 +970,10 @@ done: static htri_t H5HF__sect_single_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Fractal heap free section */ - H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ - htri_t ret_value = FALSE; /* Return value */ + const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Fractal heap free section */ + H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1026,13 +986,13 @@ H5HF__sect_single_can_shrink(const H5FS_section_info_t *_sect, void *_udata) * would have been converted into a row section, if there was an * indirect block that covered it) */ - if(hdr->man_dtable.curr_root_rows == 0) { - size_t dblock_size; /* Section's direct block's size */ - size_t dblock_overhead; /* Direct block's overhead */ + if (hdr->man_dtable.curr_root_rows == 0) { + size_t dblock_size; /* Section's direct block's size */ + size_t dblock_overhead; /* Direct block's overhead */ - dblock_size = hdr->man_dtable.cparam.start_block_size; + dblock_size = hdr->man_dtable.cparam.start_block_size; dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - if((dblock_size - dblock_overhead) == sect->sect_info.size) + if ((dblock_size - dblock_overhead) == sect->sect_info.size) HGOTO_DONE(TRUE) } /* end if */ else { @@ -1047,7 +1007,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_shrink * @@ -1065,13 +1024,13 @@ done: static herr_t H5HF__sect_single_shrink(H5FS_section_info_t **_sect, void *_udata) { - H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ - H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ - H5HF_direct_t *dblock; /* Pointer to direct block for section */ - haddr_t dblock_addr; /* Section's direct block's address */ - size_t dblock_size; /* Section's direct block's size */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ + H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + H5HF_direct_t * dblock; /* Pointer to direct block for section */ + haddr_t dblock_addr; /* Section's direct block's address */ + size_t dblock_size; /* Section's direct block's size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1081,27 +1040,28 @@ H5HF__sect_single_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert((*sect)->sect_info.type == H5HF_FSPACE_SECT_SINGLE); /* Check to see if we should revive section */ - if((*sect)->sect_info.state != H5FS_SECT_LIVE) - if(H5HF__sect_single_revive(hdr, (*sect)) < 0) + if ((*sect)->sect_info.state != H5FS_SECT_LIVE) + if (H5HF__sect_single_revive(hdr, (*sect)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") /* Retrieve direct block address from section */ - if(H5HF_sect_single_dblock_info(hdr, (*sect), &dblock_addr, &dblock_size) < 0) + if (H5HF_sect_single_dblock_info(hdr, (*sect), &dblock_addr, &dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve direct block information") /* Protect the direct block for the section */ /* (should be a root direct block) */ HDassert(dblock_addr == hdr->man_dtable.table_addr); - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, (*sect)->u.single.parent, (*sect)->u.single.par_entry, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, (*sect)->u.single.parent, + (*sect)->u.single.par_entry, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block") HDassert(H5F_addr_eq(dblock->block_off + dblock_size, (*sect)->sect_info.addr + (*sect)->sect_info.size)); /* Get rid of section */ - if(H5HF__sect_single_free((H5FS_section_info_t *)*sect) < 0) + if (H5HF__sect_single_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") /* Destroy direct block */ - if(H5HF__man_dblock_destroy(hdr, dblock, dblock_addr, NULL) < 0) + if (H5HF__man_dblock_destroy(hdr, dblock, dblock_addr, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release direct block") dblock = NULL; @@ -1112,7 +1072,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_free * @@ -1130,9 +1089,9 @@ done: herr_t H5HF__sect_single_free(H5FS_section_info_t *_sect) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Pointer to section to free */ - H5HF_indirect_t *parent = NULL; /* Parent indirect block for section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Pointer to section to free */ + H5HF_indirect_t * parent = NULL; /* Parent indirect block for section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1140,21 +1099,20 @@ H5HF__sect_single_free(H5FS_section_info_t *_sect) HDassert(sect); /* Check for live reference to an indirect block */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.state == H5FS_SECT_LIVE) { /* Get parent indirect block, if there was one */ - if(sect->u.single.parent) + if (sect->u.single.parent) parent = sect->u.single.parent; } /* end if */ /* Release the section */ - if(H5HF_sect_node_free(sect, parent) < 0) + if (H5HF_sect_node_free(sect, parent) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF__sect_single_free() */ +} /* H5HF__sect_single_free() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_valid * @@ -1171,30 +1129,31 @@ done: static herr_t H5HF__sect_single_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5FS_section_info_t *_sect) { - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Pointer to section to check */ + const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Pointer to section to check */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect); - if(sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.state == H5FS_SECT_LIVE) { /* Check if this section is not in a direct block that is the root direct block */ /* (not enough information to check on a single section in a root direct block) */ - if(sect->u.single.parent != NULL) { - H5HF_indirect_t *iblock; /* Indirect block that section's direct block resides in */ - haddr_t dblock_addr; /* Direct block address */ - size_t dblock_size; /* Direct block size */ - unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ - size_t H5_ATTR_NDEBUG_UNUSED dblock_overhead; /* Direct block's overhead */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Generic status value */ + if (sect->u.single.parent != NULL) { + H5HF_indirect_t * iblock; /* Indirect block that section's direct block resides in */ + haddr_t dblock_addr; /* Direct block address */ + size_t dblock_size; /* Direct block size */ + unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ + size_t H5_ATTR_NDEBUG_UNUSED dblock_overhead; /* Direct block's overhead */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Generic status value */ /* Sanity check settings for section's direct block's parent */ iblock = sect->u.single.parent; HDassert(H5F_addr_defined(iblock->ents[sect->u.single.par_entry].addr)); /* Retrieve direct block address from section */ - status = H5HF_sect_single_dblock_info(iblock->hdr, (const H5HF_free_section_t *)sect, &dblock_addr, &dblock_size); + status = H5HF_sect_single_dblock_info(iblock->hdr, (const H5HF_free_section_t *)sect, + &dblock_addr, &dblock_size); HDassert(status >= 0); HDassert(H5F_addr_eq(iblock->ents[sect->u.single.par_entry].addr, dblock_addr)); HDassert(dblock_size > 0); @@ -1214,30 +1173,32 @@ H5HF__sect_single_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5 * protect it here in order to check single section's sanity * against it. */ - if(!(dblock_status & H5AC_ES__IS_PROTECTED)) { - H5HF_direct_t *dblock; /* Direct block for section */ + if (!(dblock_status & H5AC_ES__IS_PROTECTED)) { + H5HF_direct_t *dblock; /* Direct block for section */ /* Protect the direct block for the section */ - dblock = H5HF__man_dblock_protect(iblock->hdr, dblock_addr, dblock_size, iblock, sect->u.single.par_entry, H5AC__READ_ONLY_FLAG); + dblock = H5HF__man_dblock_protect(iblock->hdr, dblock_addr, dblock_size, iblock, + sect->u.single.par_entry, H5AC__READ_ONLY_FLAG); HDassert(dblock); /* Sanity check settings for section */ HDassert(dblock_size == dblock->size); HDassert(dblock->size > sect->sect_info.size); HDassert(H5F_addr_lt(dblock->block_off, sect->sect_info.addr)); - HDassert(H5F_addr_ge((dblock->block_off + dblock->size), (sect->sect_info.addr + sect->sect_info.size))); + HDassert(H5F_addr_ge((dblock->block_off + dblock->size), + (sect->sect_info.addr + sect->sect_info.size))); /* Release direct block */ - status = H5AC_unprotect(iblock->hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET); + status = H5AC_unprotect(iblock->hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, + H5AC__NO_FLAGS_SET); HDassert(status >= 0); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF__sect_single_valid() */ +} /* H5HF__sect_single_valid() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_row_create * @@ -1253,11 +1214,11 @@ H5HF__sect_single_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5 *------------------------------------------------------------------------- */ static H5HF_free_section_t * -H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, - unsigned row, unsigned col, unsigned nentries, H5HF_free_section_t *under_sect) +H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, unsigned row, unsigned col, + unsigned nentries, H5HF_free_section_t *under_sect) { - H5HF_free_section_t *sect = NULL; /* 'Row' section created */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Row' section created */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1268,13 +1229,15 @@ H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, /* Create 'row' free space section node */ /* ("inherits" underlying indirect section's state) */ - if(NULL == (sect = H5HF_sect_node_new((unsigned)(is_first ? H5HF_FSPACE_SECT_FIRST_ROW : H5HF_FSPACE_SECT_NORMAL_ROW), sect_off, sect_size, under_sect->sect_info.state))) + if (NULL == (sect = H5HF_sect_node_new( + (unsigned)(is_first ? H5HF_FSPACE_SECT_FIRST_ROW : H5HF_FSPACE_SECT_NORMAL_ROW), + sect_off, sect_size, under_sect->sect_info.state))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for row section") /* Set the 'row' specific fields */ - sect->u.row.under = under_sect; - sect->u.row.row = row; - sect->u.row.col = col; + sect->u.row.under = under_sect; + sect->u.row.row = row; + sect->u.row.col = col; sect->u.row.num_entries = nentries; sect->u.row.checked_out = FALSE; @@ -1285,7 +1248,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_sect_row_create() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_row_from_single * @@ -1300,10 +1262,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - H5HF_direct_t *dblock) +H5HF_sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_direct_t *dblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1315,26 +1276,25 @@ H5HF_sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, HDassert(dblock); /* Convert 'single' section information to 'row' section info */ - sect->sect_info.addr = dblock->block_off; - sect->sect_info.type = H5HF_FSPACE_SECT_FIRST_ROW; - sect->u.row.row = dblock->par_entry / hdr->man_dtable.cparam.width; - sect->u.row.col = dblock->par_entry % hdr->man_dtable.cparam.width; + sect->sect_info.addr = dblock->block_off; + sect->sect_info.type = H5HF_FSPACE_SECT_FIRST_ROW; + sect->u.row.row = dblock->par_entry / hdr->man_dtable.cparam.width; + sect->u.row.col = dblock->par_entry % hdr->man_dtable.cparam.width; sect->u.row.num_entries = 1; sect->u.row.checked_out = FALSE; /* Create indirect section that underlies the row section */ - if(NULL == (sect->u.row.under = H5HF_sect_indirect_for_row(hdr, dblock->parent, sect))) + if (NULL == (sect->u.row.under = H5HF_sect_indirect_for_row(hdr, dblock->parent, sect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "serializing row section not supported yet") /* Release single section's hold on underlying indirect block */ - if(H5HF__iblock_decr(dblock->parent) < 0) + if (H5HF__iblock_decr(dblock->parent) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_row_from_single() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_revive * @@ -1351,7 +1311,7 @@ done: herr_t H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1365,14 +1325,14 @@ H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) /* If the indirect section's iblock has been removed from the cache, but the * section is still marked as "live", switch it to the "serialized" state. */ - if((H5FS_SECT_LIVE == sect->u.row.under->sect_info.state) - && (TRUE == sect->u.row.under->u.indirect.u.iblock->removed_from_cache)) - if(H5HF__sect_row_parent_removed(sect) < 0) + if ((H5FS_SECT_LIVE == sect->u.row.under->sect_info.state) && + (TRUE == sect->u.row.under->u.indirect.u.iblock->removed_from_cache)) + if (H5HF__sect_row_parent_removed(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUPDATE, FAIL, "can't update section info") /* Pass along "revive" request to underlying indirect section */ /* (which will mark this section as "live") */ - if(H5HF__sect_indirect_revive_row(hdr, sect->u.row.under) < 0) + if (H5HF__sect_indirect_revive_row(hdr, sect->u.row.under) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREVIVE, FAIL, "can't revive indirect section") HDassert(sect->sect_info.state == H5FS_SECT_LIVE); @@ -1380,7 +1340,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_row_revive() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_reduce * @@ -1397,11 +1356,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - unsigned *entry_p) +H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned *entry_p) { - hbool_t alloc_from_start; /* Whether to allocate from the end of the row */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t alloc_from_start; /* Whether to allocate from the end of the row */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1411,7 +1369,7 @@ H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, HDassert(hdr); HDassert(sect); HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || - sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); + sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); HDassert(sect->sect_info.state == H5FS_SECT_LIVE); HDassert(entry_p); @@ -1421,23 +1379,23 @@ H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Forward row section to indirect routines, to handle reducing underlying indirect section */ alloc_from_start = FALSE; - if(H5HF__sect_indirect_reduce_row(hdr, sect, &alloc_from_start) < 0) + if (H5HF__sect_indirect_reduce_row(hdr, sect, &alloc_from_start) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce underlying section") /* Determine entry allocated */ *entry_p = (sect->u.row.row * hdr->man_dtable.cparam.width) + sect->u.row.col; - if(!alloc_from_start) + if (!alloc_from_start) *entry_p += (sect->u.row.num_entries - 1); /* Check for eliminating the section */ - if(sect->u.row.num_entries == 1) { + if (sect->u.row.num_entries == 1) { /* Free row section */ - if(H5HF__sect_row_free((H5FS_section_info_t *)sect) < 0) + if (H5HF__sect_row_free((H5FS_section_info_t *)sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free row section node") } /* end if */ else { /* Check whether to allocate from the beginning or end of the row */ - if(alloc_from_start) { + if (alloc_from_start) { /* Adjust section start */ sect->sect_info.addr += hdr->man_dtable.row_block_size[sect->u.row.row]; sect->u.row.col++; @@ -1450,7 +1408,7 @@ H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, sect->u.row.checked_out = FALSE; /* Add 'row' section back to free space list */ - if(H5HF__space_add(hdr, sect, 0) < 0) + if (H5HF__space_add(hdr, sect, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add indirect section to free space manager") } /* end else */ @@ -1458,7 +1416,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_row_reduce() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_first * @@ -1475,7 +1432,7 @@ done: static herr_t H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1488,18 +1445,17 @@ H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) * change it's class directly and the free space manager will adjust when * it is checked back in. */ - if(sect->u.row.checked_out) + if (sect->u.row.checked_out) sect->sect_info.type = H5HF_FSPACE_SECT_FIRST_ROW; else /* Change row section to be the "first row" */ - if(H5HF__space_sect_change_class(hdr, sect, H5HF_FSPACE_SECT_FIRST_ROW) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set row section to be first row") + if (H5HF__space_sect_change_class(hdr, sect, H5HF_FSPACE_SECT_FIRST_ROW) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set row section to be first row") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_row_first() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_row_get_iblock * @@ -1516,7 +1472,7 @@ done: H5HF_indirect_t * H5HF_sect_row_get_iblock(H5HF_free_section_t *sect) { - H5HF_indirect_t *ret_value = NULL; /* Return value */ + H5HF_indirect_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1525,7 +1481,7 @@ H5HF_sect_row_get_iblock(H5HF_free_section_t *sect) */ HDassert(sect); HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || - sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); + sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); HDassert(sect->sect_info.state == H5FS_SECT_LIVE); ret_value = H5HF_sect_indirect_get_iblock(sect->u.row.under); @@ -1533,7 +1489,6 @@ H5HF_sect_row_get_iblock(H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_row_get_iblock() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_parent_removed * @@ -1551,9 +1506,9 @@ H5HF_sect_row_get_iblock(H5HF_free_section_t *sect) static herr_t H5HF__sect_row_parent_removed(H5HF_free_section_t *sect) { - hsize_t tmp_iblock_off; /* Indirect block offset for row */ - unsigned u; /* Local index value */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t tmp_iblock_off; /* Indirect block offset for row */ + unsigned u; /* Local index value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1564,16 +1519,16 @@ H5HF__sect_row_parent_removed(H5HF_free_section_t *sect) tmp_iblock_off = sect->u.row.under->u.indirect.u.iblock->block_off; /* Decrement the refcount on the indirect block, since serialized sections don't hold a reference */ - if(H5HF__iblock_decr(sect->u.row.under->u.indirect.u.iblock) < 0) + if (H5HF__iblock_decr(sect->u.row.under->u.indirect.u.iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") /* Switch indirect block info to serialized form */ /* (Overwrites iblock pointer in the indirect section) */ - sect->u.row.under->u.indirect.u.iblock_off = tmp_iblock_off; + sect->u.row.under->u.indirect.u.iblock_off = tmp_iblock_off; sect->u.row.under->u.indirect.iblock_entries = 0; /* Loop over derived row sections and mark them all as 'live' now */ - for(u = 0; u < sect->u.row.under->u.indirect.dir_nrows; u++) + for (u = 0; u < sect->u.row.under->u.indirect.dir_nrows; u++) sect->u.row.under->u.indirect.dir_rows[u]->sect_info.state = H5FS_SECT_SERIALIZED; /* Mark the indirect section as serialized now */ @@ -1586,7 +1541,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_row_parent_removed() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_init_cls * @@ -1607,8 +1561,8 @@ done: static herr_t H5HF__sect_row_init_cls(H5FS_section_class_t *cls, void *_udata) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_udata; /* Fractal heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_udata; /* Fractal heap header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1617,11 +1571,11 @@ H5HF__sect_row_init_cls(H5FS_section_class_t *cls, void *_udata) HDassert(hdr); /* Call common class initialization */ - if(H5HF_sect_init_cls(cls, hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize common section class") + if (H5HF_sect_init_cls(cls, hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize common section class") /* First row sections actually are proxies for indirection sections on disk */ - if(cls->type == H5HF_FSPACE_SECT_FIRST_ROW) + if (cls->type == H5HF_FSPACE_SECT_FIRST_ROW) cls->serial_size = H5HF_SECT_INDIRECT_SERIAL_SIZE(hdr); else cls->serial_size = 0; @@ -1630,7 +1584,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_init_cls() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_term_cls * @@ -1651,7 +1604,7 @@ done: static herr_t H5HF__sect_row_term_cls(H5FS_section_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1659,14 +1612,13 @@ H5HF__sect_row_term_cls(H5FS_section_class_t *cls) HDassert(cls); /* Call common class termination */ - if(H5HF_sect_term_cls(cls) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't terminate common section class") + if (H5HF_sect_term_cls(cls) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't terminate common section class") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_term_cls() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_serialize * @@ -1682,12 +1634,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_row_serialize(const H5FS_section_class_t *cls, - const H5FS_section_info_t *_sect, uint8_t *buf) +H5HF__sect_row_serialize(const H5FS_section_class_t *cls, const H5FS_section_info_t *_sect, uint8_t *buf) { - H5HF_hdr_t *hdr; /* Fractal heap header */ - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t * hdr; /* Fractal heap header */ + const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1700,14 +1651,14 @@ H5HF__sect_row_serialize(const H5FS_section_class_t *cls, /* Forward to indirect routine to serialize underlying section */ hdr = ((H5HF_sect_private_t *)(cls->cls_private))->hdr; - if(H5HF_sect_indirect_serialize(hdr, sect->u.row.under, buf) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, "can't serialize row section's underlying indirect section") + if (H5HF_sect_indirect_serialize(hdr, sect->u.row.under, buf) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, + "can't serialize row section's underlying indirect section") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_deserialize * @@ -1726,11 +1677,11 @@ done: *------------------------------------------------------------------------- */ static H5FS_section_info_t * -H5HF__sect_row_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, - haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags) +H5HF__sect_row_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, haddr_t sect_addr, + hsize_t sect_size, unsigned *des_flags) { - H5HF_hdr_t *hdr; /* Fractal heap header */ - H5FS_section_info_t *ret_value = NULL; /* Return value */ + H5HF_hdr_t * hdr; /* Fractal heap header */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1742,14 +1693,14 @@ H5HF__sect_row_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, /* Forward to indirect routine to deserialize underlying section */ hdr = ((H5HF_sect_private_t *)(cls->cls_private))->hdr; - if(NULL == (ret_value = H5HF__sect_indirect_deserialize(hdr, buf, sect_addr, sect_size, des_flags))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't deserialize row section's underlying indirect section") + if (NULL == (ret_value = H5HF__sect_indirect_deserialize(hdr, buf, sect_addr, sect_size, des_flags))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, + "can't deserialize row section's underlying indirect section") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_can_merge * @@ -1767,13 +1718,13 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - const H5HF_free_section_t *sect1 = (const H5HF_free_section_t *)_sect1; /* Fractal heap free section */ - const H5HF_free_section_t *sect2 = (const H5HF_free_section_t *)_sect2; /* Fractal heap free section */ - H5HF_free_section_t *top_indir_sect1, *top_indir_sect2; /* Top indirect section for each row */ - htri_t ret_value = FALSE; /* Return value */ + const H5HF_free_section_t *sect1 = (const H5HF_free_section_t *)_sect1; /* Fractal heap free section */ + const H5HF_free_section_t *sect2 = (const H5HF_free_section_t *)_sect2; /* Fractal heap free section */ + H5HF_free_section_t * top_indir_sect1, *top_indir_sect2; /* Top indirect section for each row */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1781,7 +1732,7 @@ H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, HDassert(sect1); HDassert(sect1->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Get the top indirect section underlying each row */ @@ -1794,19 +1745,20 @@ H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, * the first section, but doesn't already have same underlying indirect * section. */ - if(top_indir_sect1 != top_indir_sect2) { - if(H5HF_sect_indirect_iblock_off(sect1->u.row.under) == H5HF_sect_indirect_iblock_off(sect2->u.row.under)) { + if (top_indir_sect1 != top_indir_sect2) { + if (H5HF_sect_indirect_iblock_off(sect1->u.row.under) == + H5HF_sect_indirect_iblock_off(sect2->u.row.under)) { /* Check if second section adjoins first section */ - if(H5F_addr_eq((top_indir_sect1->sect_info.addr + top_indir_sect1->u.indirect.span_size), top_indir_sect2->sect_info.addr)) + if (H5F_addr_eq((top_indir_sect1->sect_info.addr + top_indir_sect1->u.indirect.span_size), + top_indir_sect2->sect_info.addr)) HGOTO_DONE(TRUE) } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_merge * @@ -1824,14 +1776,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void *_udata) +H5HF__sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { - H5HF_free_section_t **sect1 = (H5HF_free_section_t **)_sect1; /* Fractal heap free section */ - H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ - H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t **sect1 = (H5HF_free_section_t **)_sect1; /* Fractal heap free section */ + H5HF_free_section_t * sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ + H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1842,26 +1793,25 @@ H5HF__sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, HDassert(sect2->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); /* Check if second section is past end of "next block" iterator */ - if(sect2->sect_info.addr >= hdr->man_iter_off) { - H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ + if (sect2->sect_info.addr >= hdr->man_iter_off) { + H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ /* Get the top indirect section underlying second row section */ top_indir_sect = H5HF_sect_indirect_top(sect2->u.row.under); /* Shrink away underlying indirect section */ - if(H5HF__sect_indirect_shrink(hdr, top_indir_sect) < 0) + if (H5HF__sect_indirect_shrink(hdr, top_indir_sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't shrink underlying indirect section") } /* end if */ else /* Merge rows' underlying indirect sections together */ - if(H5HF__sect_indirect_merge_row(hdr, (*sect1), sect2) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTMERGE, FAIL, "can't merge underlying indirect sections") + if (H5HF__sect_indirect_merge_row(hdr, (*sect1), sect2) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTMERGE, FAIL, "can't merge underlying indirect sections") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_merge() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_can_shrink * @@ -1883,10 +1833,10 @@ done: static htri_t H5HF__sect_row_can_shrink(const H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udata) { - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Fractal heap free section */ - H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ - htri_t ret_value = FALSE; /* Return value */ + const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Fractal heap free section */ + H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1895,14 +1845,13 @@ H5HF__sect_row_can_shrink(const H5FS_section_info_t *_sect, void H5_ATTR_UNUSED HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); /* Check if section is past end of "next block" iterator */ - if(sect->sect_info.addr >= hdr->man_iter_off) + if (sect->sect_info.addr >= hdr->man_iter_off) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_shrink * @@ -1920,11 +1869,11 @@ done: static herr_t H5HF__sect_row_shrink(H5FS_section_info_t **_sect, void *_udata) { - H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ - H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ - H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ + H5HF_free_section_t * top_indir_sect; /* Top indirect section for row */ + H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1937,7 +1886,7 @@ H5HF__sect_row_shrink(H5FS_section_info_t **_sect, void *_udata) top_indir_sect = H5HF_sect_indirect_top((*sect)->u.row.under); /* Shrink away underlying indirect section */ - if(H5HF__sect_indirect_shrink(hdr, top_indir_sect) < 0) + if (H5HF__sect_indirect_shrink(hdr, top_indir_sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't shrink underlying indirect section") /* Indicate that the section has been released */ @@ -1947,7 +1896,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_free_real * @@ -1965,21 +1913,20 @@ done: static herr_t H5HF__sect_row_free_real(H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(sect); /* Release the section */ - if(H5HF_sect_node_free(sect, NULL) < 0) + if (H5HF_sect_node_free(sect, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF__sect_row_free_real() */ +} /* H5HF__sect_row_free_real() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_free * @@ -1997,8 +1944,8 @@ done: static herr_t H5HF__sect_row_free(H5FS_section_info_t *_sect) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Pointer to section to free */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Pointer to section to free */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2006,18 +1953,17 @@ H5HF__sect_row_free(H5FS_section_info_t *_sect) HDassert(sect->u.row.under); /* Decrement the ref. count on the row section's underlying indirect section */ - if(H5HF_sect_indirect_decr(sect->u.row.under) < 0) + if (H5HF_sect_indirect_decr(sect->u.row.under) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't detach section node") /* Release the section */ - if(H5HF__sect_row_free_real(sect) < 0) + if (H5HF__sect_row_free_real(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF__sect_row_free() */ +} /* H5HF__sect_row_free() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_valid * @@ -2034,10 +1980,10 @@ done: static herr_t H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *_sect) { - H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ - const H5HF_hdr_t *hdr; /* Fractal heap header */ - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Pointer to section to check */ - const H5HF_free_section_t *indir_sect; /* Pointer to underlying indirect section */ + H5HF_sect_private_t * cls_prvt; /* Pointer to class private info */ + const H5HF_hdr_t * hdr; /* Fractal heap header */ + const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Pointer to section to check */ + const H5HF_free_section_t *indir_sect; /* Pointer to underlying indirect section */ unsigned H5_ATTR_NDEBUG_UNUSED indir_idx; /* Index of row in underlying indirect section's row array */ FUNC_ENTER_STATIC_NOERR @@ -2048,22 +1994,22 @@ H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t /* Retrieve class private information */ cls_prvt = (H5HF_sect_private_t *)cls->cls_private; - hdr = cls_prvt->hdr; + hdr = cls_prvt->hdr; /* Sanity checking on the row */ HDassert(sect->u.row.under); HDassert(sect->u.row.num_entries); HDassert(sect->u.row.checked_out == FALSE); indir_sect = sect->u.row.under; - indir_idx = sect->u.row.row - indir_sect->u.indirect.row; + indir_idx = sect->u.row.row - indir_sect->u.indirect.row; HDassert(indir_sect->u.indirect.dir_rows[indir_idx] == sect); /* Check if the section is actually within the heap */ HDassert(sect->sect_info.addr < hdr->man_iter_off); /* Different checking for different kinds of rows */ - if(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) { - H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ + if (sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) { + H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ /* Some extra sanity checks on the row */ HDassert(sect->u.row.row == indir_sect->u.indirect.row); @@ -2076,9 +2022,8 @@ H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF__sect_row_valid() */ +} /* H5HF__sect_row_valid() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_debug * @@ -2095,7 +2040,7 @@ H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t static herr_t H5HF__sect_row_debug(const H5FS_section_info_t *_sect, FILE *stream, int indent, int fwidth) { - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Section to dump info */ + const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Section to dump info */ FUNC_ENTER_STATIC_NOERR @@ -2103,21 +2048,14 @@ H5HF__sect_row_debug(const H5FS_section_info_t *_sect, FILE *stream, int indent, HDassert(sect); /* Print indirect section information */ - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Row:", - sect->u.row.row); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Column:", - sect->u.row.col); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of entries:", - sect->u.row.num_entries); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Row:", sect->u.row.row); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Column:", sect->u.row.col); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of entries:", sect->u.row.num_entries); /* If this is a first row section display information about underlying indirect section */ - if(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) { + if (sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) { /* Print indirect section header */ - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, - "Underlying indirect section:"); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Underlying indirect section:"); H5HF_sect_indirect_debug(sect->u.row.under, stream, indent + 3, MAX(0, fwidth - 3)); } /* end if */ @@ -2125,7 +2063,6 @@ H5HF__sect_row_debug(const H5FS_section_info_t *_sect, FILE *stream, int indent, FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__sect_row_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_iblock_off * @@ -2142,7 +2079,7 @@ H5HF__sect_row_debug(const H5FS_section_info_t *_sect, FILE *stream, int indent, static hsize_t H5HF_sect_indirect_iblock_off(const H5HF_free_section_t *sect) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2151,12 +2088,12 @@ H5HF_sect_indirect_iblock_off(const H5HF_free_section_t *sect) */ HDassert(sect); - ret_value = sect->sect_info.state == H5FS_SECT_LIVE ? sect->u.indirect.u.iblock->block_off : sect->u.indirect.u.iblock_off; + ret_value = sect->sect_info.state == H5FS_SECT_LIVE ? sect->u.indirect.u.iblock->block_off + : sect->u.indirect.u.iblock_off; FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_indirect_iblock_off() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_top * @@ -2173,7 +2110,7 @@ H5HF_sect_indirect_iblock_off(const H5HF_free_section_t *sect) static H5HF_free_section_t * H5HF_sect_indirect_top(H5HF_free_section_t *sect) { - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2182,7 +2119,7 @@ H5HF_sect_indirect_top(H5HF_free_section_t *sect) */ HDassert(sect); - if(sect->u.indirect.parent) + if (sect->u.indirect.parent) ret_value = H5HF_sect_indirect_top(sect->u.indirect.parent); else ret_value = sect; @@ -2190,7 +2127,6 @@ H5HF_sect_indirect_top(H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_indirect_top() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_init_cls * @@ -2208,8 +2144,8 @@ H5HF_sect_indirect_top(H5HF_free_section_t *sect) static herr_t H5HF_sect_indirect_init_cls(H5FS_section_class_t *cls, void *_udata) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_udata; /* Fractal heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_udata; /* Fractal heap header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2218,8 +2154,8 @@ H5HF_sect_indirect_init_cls(H5FS_section_class_t *cls, void *_udata) HDassert(hdr); /* Call to common class initialization */ - if(H5HF_sect_init_cls(cls, hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize common section class") + if (H5HF_sect_init_cls(cls, hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize common section class") /* Set the size of all serialized objects of this class of sections */ cls->serial_size = H5HF_SECT_INDIRECT_SERIAL_SIZE(hdr); @@ -2228,7 +2164,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_sect_indirect_init_cls() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_term_cls * @@ -2246,7 +2181,7 @@ done: static herr_t H5HF_sect_indirect_term_cls(H5FS_section_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2254,14 +2189,13 @@ H5HF_sect_indirect_term_cls(H5FS_section_class_t *cls) HDassert(cls); /* Call common class termination */ - if(H5HF_sect_term_cls(cls) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't terminate common section class") + if (H5HF_sect_term_cls(cls) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't terminate common section class") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_sect_indirect_term_cls() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_new * @@ -2277,12 +2211,11 @@ done: *------------------------------------------------------------------------- */ static H5HF_free_section_t * -H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, - H5HF_indirect_t *iblock, hsize_t iblock_off, unsigned row, unsigned col, - unsigned nentries) +H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, H5HF_indirect_t *iblock, + hsize_t iblock_off, unsigned row, unsigned col, unsigned nentries) { - H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2293,40 +2226,39 @@ H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, HDassert(nentries); /* Create free space section node */ - if(NULL == (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_INDIRECT, sect_off, - sect_size, (iblock ? H5FS_SECT_LIVE : H5FS_SECT_SERIALIZED)))) + if (NULL == (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_INDIRECT, sect_off, sect_size, + (iblock ? H5FS_SECT_LIVE : H5FS_SECT_SERIALIZED)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for indirect section") /* Set the 'indirect' specific fields */ - if(iblock) { - sect->u.indirect.u.iblock = iblock; - sect->u.indirect.iblock_entries = hdr->man_dtable.cparam.width * - sect->u.indirect.u.iblock->max_rows; - if(H5HF_iblock_incr(sect->u.indirect.u.iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") + if (iblock) { + sect->u.indirect.u.iblock = iblock; + sect->u.indirect.iblock_entries = hdr->man_dtable.cparam.width * sect->u.indirect.u.iblock->max_rows; + if (H5HF_iblock_incr(sect->u.indirect.u.iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, + "can't increment reference count on shared indirect block") } /* end if */ else { - sect->u.indirect.u.iblock_off = iblock_off; + sect->u.indirect.u.iblock_off = iblock_off; sect->u.indirect.iblock_entries = 0; } /* end else */ - sect->u.indirect.row = row; - sect->u.indirect.col = col; + sect->u.indirect.row = row; + sect->u.indirect.col = col; sect->u.indirect.num_entries = nentries; /* Compute span size of indirect section */ - sect->u.indirect.span_size = H5HF_dtable_span_size(&hdr->man_dtable, - row, col, nentries); + sect->u.indirect.span_size = H5HF_dtable_span_size(&hdr->man_dtable, row, col, nentries); HDassert(sect->u.indirect.span_size > 0); /* This indirect section doesn't (currently) have a parent */ - sect->u.indirect.parent = NULL; + sect->u.indirect.parent = NULL; sect->u.indirect.par_entry = 0; /* Set return value */ ret_value = sect; done: - if(!ret_value && sect) { + if (!ret_value && sect) { /* Release the section */ sect = H5FL_FREE(H5HF_free_section_t, sect); } /* end if */ @@ -2334,7 +2266,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_indirect_new() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_for_row * @@ -2349,11 +2280,10 @@ done: *------------------------------------------------------------------------- */ static H5HF_free_section_t * -H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, - H5HF_free_section_t *row_sect) +H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, H5HF_free_section_t *row_sect) { - H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2366,38 +2296,38 @@ H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, HDassert(row_sect->u.row.row < hdr->man_dtable.max_direct_rows); /* Create free space section node */ - if(NULL == (sect = H5HF_sect_indirect_new(hdr, row_sect->sect_info.addr, - row_sect->sect_info.size, iblock, iblock->block_off, - row_sect->u.row.row, row_sect->u.row.col, row_sect->u.row.num_entries))) + if (NULL == (sect = H5HF_sect_indirect_new(hdr, row_sect->sect_info.addr, row_sect->sect_info.size, + iblock, iblock->block_off, row_sect->u.row.row, + row_sect->u.row.col, row_sect->u.row.num_entries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't create indirect section") /* Set # of direct rows covered */ sect->u.indirect.dir_nrows = 1; /* Allocate space for the derived row sections */ - if(NULL == (sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *)))) + if (NULL == + (sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "allocation failed for row section pointer array") /* Atatch the new row section to indirect section */ sect->u.indirect.dir_rows[0] = row_sect; - sect->u.indirect.rc = 1; + sect->u.indirect.rc = 1; /* No indirect rows in current section */ sect->u.indirect.indir_nents = 0; - sect->u.indirect.indir_ents = NULL; + sect->u.indirect.indir_ents = NULL; /* Set return value */ ret_value = sect; done: - if(!ret_value && sect) - if(H5HF_sect_indirect_free(sect) < 0) + if (!ret_value && sect) + if (H5HF_sect_indirect_free(sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "can't free indirect section node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_indirect_for_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_init_rows * @@ -2413,21 +2343,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - hbool_t first_child, H5HF_free_section_t **first_row_sect, - unsigned space_flags, unsigned start_row, unsigned start_col, - unsigned end_row, unsigned end_col) +H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, hbool_t first_child, + H5HF_free_section_t **first_row_sect, unsigned space_flags, unsigned start_row, + unsigned start_col, unsigned end_row, unsigned end_col) { - hsize_t curr_off; /* Offset of new section in "heap space" */ - size_t dblock_overhead; /* Direct block's overhead */ - unsigned row_entries; /* # of entries in row */ - unsigned row_col; /* Column within current row */ - unsigned curr_entry; /* Current entry within indirect section */ - unsigned curr_indir_entry; /* Current indirect entry within indirect section */ - unsigned curr_row; /* Current row within indirect section */ - unsigned dir_nrows; /* # of direct rows in indirect section */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t curr_off; /* Offset of new section in "heap space" */ + size_t dblock_overhead; /* Direct block's overhead */ + unsigned row_entries; /* # of entries in row */ + unsigned row_col; /* Column within current row */ + unsigned curr_entry; /* Current entry within indirect section */ + unsigned curr_indir_entry; /* Current indirect entry within indirect section */ + unsigned curr_row; /* Current row within indirect section */ + unsigned dir_nrows; /* # of direct rows in indirect section */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2439,13 +2368,13 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Reset reference count for indirect section */ /* (Also reset the direct & indirect row pointers */ - sect->u.indirect.rc = 0; - sect->u.indirect.dir_rows = NULL; + sect->u.indirect.rc = 0; + sect->u.indirect.dir_rows = NULL; sect->u.indirect.indir_ents = NULL; /* Set up direct block information, if necessary */ - if(start_row < hdr->man_dtable.max_direct_rows) { - unsigned max_direct_row; /* Max. direct row covered */ + if (start_row < hdr->man_dtable.max_direct_rows) { + unsigned max_direct_row; /* Max. direct row covered */ /* Compute max. direct row covered by indirect section */ max_direct_row = MIN(end_row, (hdr->man_dtable.max_direct_rows - 1)); @@ -2460,24 +2389,25 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, sect->u.indirect.dir_nrows = 0; /* Allocate space for the derived row sections */ - if(NULL == (sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * dir_nrows))) + if (NULL == (sect->u.indirect.dir_rows = + (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * dir_nrows))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for row section pointer array") } /* end if */ else { /* No rows of direct blocks covered, reset direct row information */ - dir_nrows = 0; + dir_nrows = 0; sect->u.indirect.dir_nrows = 0; } /* end else */ /* Set up indirect block information, if necessary */ - if(end_row >= hdr->man_dtable.max_direct_rows) { - unsigned indirect_start_row; /* Row to start indirect entries on */ - unsigned indirect_start_col; /* Column to start indirect entries on */ - unsigned indirect_start_entry; /* Index of starting indirect entry */ - unsigned indirect_end_entry; /* Index of ending indirect entry */ + if (end_row >= hdr->man_dtable.max_direct_rows) { + unsigned indirect_start_row; /* Row to start indirect entries on */ + unsigned indirect_start_col; /* Column to start indirect entries on */ + unsigned indirect_start_entry; /* Index of starting indirect entry */ + unsigned indirect_end_entry; /* Index of ending indirect entry */ /* Compute starting indirect entry */ - if(start_row < hdr->man_dtable.max_direct_rows) { + if (start_row < hdr->man_dtable.max_direct_rows) { indirect_start_row = hdr->man_dtable.max_direct_rows; indirect_start_col = 0; } /* end if */ @@ -2485,8 +2415,7 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, indirect_start_row = start_row; indirect_start_col = start_col; } /* end else */ - indirect_start_entry = (indirect_start_row * hdr->man_dtable.cparam.width) - + indirect_start_col; + indirect_start_entry = (indirect_start_row * hdr->man_dtable.cparam.width) + indirect_start_col; /* Compute ending indirect entry */ indirect_end_entry = (end_row * hdr->man_dtable.cparam.width) + end_col; @@ -2495,7 +2424,8 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, sect->u.indirect.indir_nents = (indirect_end_entry - indirect_start_entry) + 1; /* Allocate space for the child indirect sections */ - if(NULL == (sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * sect->u.indirect.indir_nents))) + if (NULL == (sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc( + sizeof(H5HF_free_section_t *) * sect->u.indirect.indir_nents))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for indirect section pointer array") } /* end if */ else { @@ -2504,38 +2434,38 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, } /* end else */ /* Set up initial row information */ - if(start_row == end_row) + if (start_row == end_row) row_entries = (end_col - start_col) + 1; else row_entries = hdr->man_dtable.cparam.width - start_col; row_col = start_col; /* Loop over creating the sections covered by this indirect section */ - curr_off = sect->sect_info.addr; - curr_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; - curr_row = 0; + curr_off = sect->sect_info.addr; + curr_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; + curr_row = 0; curr_indir_entry = 0; - dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - for(u = start_row; u <= end_row; u++, curr_row++) { - if(u < hdr->man_dtable.max_direct_rows) { - H5HF_free_section_t *row_sect = NULL; /* 'Row' free space section to add */ + dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); + for (u = start_row; u <= end_row; u++, curr_row++) { + if (u < hdr->man_dtable.max_direct_rows) { + H5HF_free_section_t *row_sect = NULL; /* 'Row' free space section to add */ /* Create 'row' free space section node */ - if(NULL == (row_sect = H5HF_sect_row_create(curr_off, - (hdr->man_dtable.row_block_size[u] - dblock_overhead), first_child, u, row_col, - row_entries, sect))) + if (NULL == (row_sect = H5HF_sect_row_create( + curr_off, (hdr->man_dtable.row_block_size[u] - dblock_overhead), first_child, u, + row_col, row_entries, sect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "creation failed for child row section") /* Add new row section to array for indirect section */ sect->u.indirect.dir_rows[curr_row] = row_sect; /* Check to see if we should grab the first row section instead of adding it immediately */ - if(first_row_sect) + if (first_row_sect) *first_row_sect = row_sect; else /* Add new row section to free space manager for the heap */ - if(H5HF__space_add(hdr, row_sect, space_flags) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add row section to free space") + if (H5HF__space_add(hdr, row_sect, space_flags) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add row section to free space") /* Increment reference count for underlying indirect section */ sect->u.indirect.rc++; @@ -2547,36 +2477,41 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, curr_entry += row_entries; /* Reset the 'first child' parameters */ - first_child = FALSE; + first_child = FALSE; first_row_sect = NULL; } /* end if */ else { - H5HF_indirect_t *child_iblock; /* Child indirect block */ - H5HF_free_section_t *child_sect; /* Child 'indirect' section to add */ - unsigned child_nrows; /* Number of child rows in indirect blocks for this row */ - unsigned child_nentries; /* Number of child entries in indirect blocks for this row */ - unsigned v; /* Local index variable */ + H5HF_indirect_t * child_iblock; /* Child indirect block */ + H5HF_free_section_t *child_sect; /* Child 'indirect' section to add */ + unsigned child_nrows; /* Number of child rows in indirect blocks for this row */ + unsigned child_nentries; /* Number of child entries in indirect blocks for this row */ + unsigned v; /* Local index variable */ /* Compute info about row's indirect blocks for child section */ - child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[u]); + child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[u]); child_nentries = child_nrows * hdr->man_dtable.cparam.width; /* Add an indirect section for each indirect block in the row */ - for(v = 0; v < row_entries; v++) { - hbool_t did_protect; /* Whether we protected the indirect block or not */ + for (v = 0; v < row_entries; v++) { + hbool_t did_protect; /* Whether we protected the indirect block or not */ /* Try to get the child section's indirect block, if it's available */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { - haddr_t child_iblock_addr; /* Child indirect block's address on disk */ + if (sect->sect_info.state == H5FS_SECT_LIVE) { + haddr_t child_iblock_addr; /* Child indirect block's address on disk */ /* Get the address of the child indirect block */ - if(H5HF_man_iblock_entry_addr(sect->u.indirect.u.iblock, curr_entry, &child_iblock_addr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve child indirect block's address") + if (H5HF_man_iblock_entry_addr(sect->u.indirect.u.iblock, curr_entry, + &child_iblock_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to retrieve child indirect block's address") /* If the child indirect block's address is defined, protect it */ - if(H5F_addr_defined(child_iblock_addr)) { - if(NULL == (child_iblock = H5HF__man_iblock_protect(hdr, child_iblock_addr, child_nrows, sect->u.indirect.u.iblock, curr_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") + if (H5F_addr_defined(child_iblock_addr)) { + if (NULL == (child_iblock = H5HF__man_iblock_protect( + hdr, child_iblock_addr, child_nrows, sect->u.indirect.u.iblock, + curr_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, + "unable to protect fractal heap indirect block") } /* end if */ else child_iblock = NULL; @@ -2585,25 +2520,26 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, child_iblock = NULL; /* Create free space section node */ - if(NULL == (child_sect = H5HF_sect_indirect_new(hdr, curr_off, (hsize_t)0, - child_iblock, curr_off, 0, 0, child_nentries))) + if (NULL == (child_sect = H5HF_sect_indirect_new(hdr, curr_off, (hsize_t)0, child_iblock, + curr_off, 0, 0, child_nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* Initialize rows for new indirect section */ - if(H5HF__sect_indirect_init_rows(hdr, child_sect, - first_child, first_row_sect, space_flags, 0, 0, - (child_nrows - 1), (hdr->man_dtable.cparam.width - 1)) < 0) + if (H5HF__sect_indirect_init_rows(hdr, child_sect, first_child, first_row_sect, space_flags, + 0, 0, (child_nrows - 1), + (hdr->man_dtable.cparam.width - 1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize indirect section") /* If we have a valid child indirect block, release it now */ /* (will be pinned, if rows reference it) */ - if(child_iblock) - if(H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (child_iblock) + if (H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") /* Attach child section to this section */ - child_sect->u.indirect.parent = sect; - child_sect->u.indirect.par_entry = curr_entry; + child_sect->u.indirect.parent = sect; + child_sect->u.indirect.par_entry = curr_entry; sect->u.indirect.indir_ents[curr_indir_entry] = child_sect; sect->u.indirect.rc++; @@ -2615,13 +2551,13 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, curr_indir_entry++; /* Reset the 'first child' parameters */ - first_child = FALSE; + first_child = FALSE; first_row_sect = NULL; } /* end for */ - } /* end else */ + } /* end else */ /* Compute the # of entries for the next row */ - if(u < (end_row - 1)) + if (u < (end_row - 1)) row_entries = hdr->man_dtable.cparam.width; else row_entries = end_col + 1; @@ -2634,21 +2570,19 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, sect->u.indirect.dir_nrows = dir_nrows; /* Make certain we've tracked the section's dependents correctly */ - HDassert(sect->u.indirect.rc == - (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); + HDassert(sect->u.indirect.rc == (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); done: - if(ret_value < 0) { - if(sect->u.indirect.indir_ents) + if (ret_value < 0) { + if (sect->u.indirect.indir_ents) H5MM_xfree(sect->u.indirect.indir_ents); - if(sect->u.indirect.dir_rows) + if (sect->u.indirect.dir_rows) H5MM_xfree(sect->u.indirect.dir_rows); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_init_rows() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_add * @@ -2666,16 +2600,16 @@ done: herr_t H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, unsigned nentries) { - H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *first_row_sect = NULL; /* First row section in new indirect section */ - hsize_t sect_off; /* Offset of section in heap space */ - unsigned start_row; /* Start row in indirect block */ - unsigned start_col; /* Start column in indirect block */ - unsigned end_entry; /* End entry in indirect block */ - unsigned end_row; /* End row in indirect block */ - unsigned end_col; /* End column in indirect block */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ + H5HF_free_section_t *first_row_sect = NULL; /* First row section in new indirect section */ + hsize_t sect_off; /* Offset of section in heap space */ + unsigned start_row; /* Start row in indirect block */ + unsigned start_col; /* Start column in indirect block */ + unsigned end_entry; /* End entry in indirect block */ + unsigned end_row; /* End row in indirect block */ + unsigned end_col; /* End column in indirect block */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2692,41 +2626,40 @@ H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start /* Compute end column & row */ end_entry = (start_entry + nentries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; - end_col = end_entry % hdr->man_dtable.cparam.width; + end_row = end_entry / hdr->man_dtable.cparam.width; + end_col = end_entry % hdr->man_dtable.cparam.width; /* Initialize information for rows skipped over */ sect_off = iblock->block_off; - for(u = 0; u < start_row; u++) + for (u = 0; u < start_row; u++) sect_off += hdr->man_dtable.row_block_size[u] * hdr->man_dtable.cparam.width; sect_off += hdr->man_dtable.row_block_size[start_row] * start_col; /* Create free space section node */ - if(NULL == (sect = H5HF_sect_indirect_new(hdr, sect_off, (hsize_t)0, iblock, - iblock->block_off, start_row, start_col, nentries))) + if (NULL == (sect = H5HF_sect_indirect_new(hdr, sect_off, (hsize_t)0, iblock, iblock->block_off, + start_row, start_col, nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* Initialize rows for new indirect section */ - if(H5HF__sect_indirect_init_rows(hdr, sect, TRUE, &first_row_sect, - H5FS_ADD_SKIP_VALID, start_row, start_col, end_row, end_col) < 0) + if (H5HF__sect_indirect_init_rows(hdr, sect, TRUE, &first_row_sect, H5FS_ADD_SKIP_VALID, start_row, + start_col, end_row, end_col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize indirect section") HDassert(first_row_sect); /* Now that underlying indirect section is consistent, add first row * section to free space manager for the heap */ - if(H5HF__space_add(hdr, first_row_sect, H5FS_ADD_RETURNED_SPACE) < 0) + if (H5HF__space_add(hdr, first_row_sect, H5FS_ADD_RETURNED_SPACE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add row section to free space") done: - if(ret_value < 0 && sect) - if(H5HF_sect_indirect_free(sect) < 0) + if (ret_value < 0 && sect) + if (H5HF_sect_indirect_free(sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_add() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_decr * @@ -2743,7 +2676,7 @@ done: static herr_t H5HF_sect_indirect_decr(H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2757,27 +2690,27 @@ H5HF_sect_indirect_decr(H5HF_free_section_t *sect) sect->u.indirect.rc--; /* If the indirect section's ref. count drops to zero, free the section */ - if(sect->u.indirect.rc == 0) { - H5HF_free_section_t *par_sect; /* Parent indirect section */ + if (sect->u.indirect.rc == 0) { + H5HF_free_section_t *par_sect; /* Parent indirect section */ /* Preserve pointer to parent indirect section when freeing this section */ par_sect = sect->u.indirect.parent; /* Free indirect section */ - if(H5HF_sect_indirect_free(sect) < 0) + if (H5HF_sect_indirect_free(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") /* Decrement ref. count on indirect section's parent */ - if(par_sect) - if(H5HF_sect_indirect_decr(par_sect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't decrement ref. count on parent indirect section") + if (par_sect) + if (H5HF_sect_indirect_decr(par_sect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, + "can't decrement ref. count on parent indirect section") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_indirect_decr() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_revive_row * @@ -2794,9 +2727,9 @@ done: static herr_t H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - H5HF_indirect_t *sec_iblock; /* Pointer to section indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *sec_iblock; /* Pointer to section indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2808,22 +2741,22 @@ H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->sect_info.state == H5FS_SECT_SERIALIZED); /* Look up indirect block containing indirect blocks for section */ - if(H5HF__man_dblock_locate(hdr, sect->sect_info.addr, &sec_iblock, NULL, &did_protect, H5AC__READ_ONLY_FLAG) < 0) + if (H5HF__man_dblock_locate(hdr, sect->sect_info.addr, &sec_iblock, NULL, &did_protect, + H5AC__READ_ONLY_FLAG) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section") /* Review the section */ - if(H5HF__sect_indirect_revive(hdr, sect, sec_iblock) < 0) + if (H5HF__sect_indirect_revive(hdr, sect, sec_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREVIVE, FAIL, "can't revive indirect section") done: /* Unlock indirect block */ - if(sec_iblock && H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (sec_iblock && H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_revive_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_revive * @@ -2840,8 +2773,8 @@ done: static herr_t H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_indirect_t *sect_iblock) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2854,33 +2787,31 @@ H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_indi HDassert(sect_iblock); /* Increment reference count on indirect block that free section is in */ - if(H5HF_iblock_incr(sect_iblock) < 0) + if (H5HF_iblock_incr(sect_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") /* Set the pointer to the section's indirect block */ sect->u.indirect.u.iblock = sect_iblock; /* Set the number of entries in the indirect block */ - sect->u.indirect.iblock_entries = hdr->man_dtable.cparam.width * - sect->u.indirect.u.iblock->max_rows; + sect->u.indirect.iblock_entries = hdr->man_dtable.cparam.width * sect->u.indirect.u.iblock->max_rows; /* Section is "live" now */ sect->sect_info.state = H5FS_SECT_LIVE; /* Loop over derived row sections and mark them all as 'live' now */ - for(u = 0; u < sect->u.indirect.dir_nrows; u++) + for (u = 0; u < sect->u.indirect.dir_nrows; u++) sect->u.indirect.dir_rows[u]->sect_info.state = H5FS_SECT_LIVE; /* Revive parent indirect section, if there is one */ - if(sect->u.indirect.parent && sect->u.indirect.parent->sect_info.state == H5FS_SECT_SERIALIZED) - if(H5HF__sect_indirect_revive(hdr, sect->u.indirect.parent, sect->u.indirect.u.iblock->parent) < 0) + if (sect->u.indirect.parent && sect->u.indirect.parent->sect_info.state == H5FS_SECT_SERIALIZED) + if (H5HF__sect_indirect_revive(hdr, sect->u.indirect.parent, sect->u.indirect.u.iblock->parent) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREVIVE, FAIL, "can't revive indirect section") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_revive() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_reduce_row * @@ -2897,20 +2828,19 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, - hbool_t *alloc_from_start) +H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, hbool_t *alloc_from_start) { - H5HF_free_section_t *sect; /* Indirect section underlying row section */ - unsigned row_start_entry; /* Entry for first block covered in row section */ - unsigned row_end_entry; /* Entry for last block covered in row section */ - unsigned row_entry; /* Entry to allocate in row section */ - unsigned start_entry; /* Entry for first block covered */ - unsigned start_row; /* Start row in indirect block */ - unsigned start_col; /* Start column in indirect block */ - unsigned end_entry; /* Entry for last block covered */ - unsigned end_row; /* End row in indirect block */ - H5HF_free_section_t *peer_sect = NULL; /* Peer indirect section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect; /* Indirect section underlying row section */ + unsigned row_start_entry; /* Entry for first block covered in row section */ + unsigned row_end_entry; /* Entry for last block covered in row section */ + unsigned row_entry; /* Entry to allocate in row section */ + unsigned start_entry; /* Entry for first block covered */ + unsigned start_row; /* Start row in indirect block */ + unsigned start_col; /* Start column in indirect block */ + unsigned end_entry; /* Entry for last block covered */ + unsigned end_row; /* End row in indirect block */ + H5HF_free_section_t *peer_sect = NULL; /* Peer indirect section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2922,15 +2852,15 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, /* Compute starting & ending information for row section */ row_start_entry = (row_sect->u.row.row * hdr->man_dtable.cparam.width) + row_sect->u.row.col; - row_end_entry = (row_start_entry + row_sect->u.row.num_entries) - 1; + row_end_entry = (row_start_entry + row_sect->u.row.num_entries) - 1; /* Compute starting & ending information for indirect section */ - sect = row_sect->u.row.under; - start_row = sect->u.indirect.row; - start_col = sect->u.indirect.col; + sect = row_sect->u.row.under; + start_row = sect->u.indirect.row; + start_col = sect->u.indirect.col; start_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; - end_entry = (start_entry + sect->u.indirect.num_entries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; + end_entry = (start_entry + sect->u.indirect.num_entries) - 1; + end_row = end_entry / hdr->man_dtable.cparam.width; /* Additional sanity check */ HDassert(sect->u.indirect.span_size > 0); @@ -2940,31 +2870,31 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, HDassert(sect->u.indirect.dir_rows[(row_sect->u.row.row - start_row)] == row_sect); /* Check if we should allocate from end of indirect section */ - if(row_end_entry == end_entry && start_row != end_row) { + if (row_end_entry == end_entry && start_row != end_row) { *alloc_from_start = FALSE; - row_entry = row_end_entry; + row_entry = row_end_entry; } /* end if */ else { *alloc_from_start = TRUE; - row_entry = row_start_entry; + row_entry = row_start_entry; } /* end else */ /* Check if we have a parent section to be detached from */ - if(sect->u.indirect.parent) { - hbool_t is_first; /* Flag to indicate that this section is the first section in hierarchy */ + if (sect->u.indirect.parent) { + hbool_t is_first; /* Flag to indicate that this section is the first section in hierarchy */ /* Check if this section is the first section */ is_first = H5HF_sect_indirect_is_first(sect); /* Remove this indirect section from parent indirect section */ - if(H5HF__sect_indirect_reduce(hdr, sect->u.indirect.parent, sect->u.indirect.par_entry) < 0) + if (H5HF__sect_indirect_reduce(hdr, sect->u.indirect.parent, sect->u.indirect.par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce parent indirect section") - sect->u.indirect.parent = NULL; + sect->u.indirect.parent = NULL; sect->u.indirect.par_entry = 0; /* If we weren't the first section, set "first row" for this indirect section */ - if(!is_first) - if(H5HF__sect_indirect_first(hdr, sect) < 0) + if (!is_first) + if (H5HF__sect_indirect_first(hdr, sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for indirect section") } /* end if */ @@ -2972,14 +2902,14 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, sect->u.indirect.span_size -= row_sect->sect_info.size; /* Check how to adjust section for allocated entry */ - if(sect->u.indirect.num_entries > 1) { - if(row_entry == start_entry) { + if (sect->u.indirect.num_entries > 1) { + if (row_entry == start_entry) { /* Adjust section start */ sect->sect_info.addr += hdr->man_dtable.row_block_size[sect->u.indirect.row]; /* Adjust block coordinates of span */ sect->u.indirect.col++; - if(sect->u.indirect.col == hdr->man_dtable.cparam.width) { + if (sect->u.indirect.col == hdr->man_dtable.cparam.width) { HDassert(row_sect->u.row.num_entries == 1); /* Adjust section's span information */ @@ -2990,17 +2920,17 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, sect->u.indirect.dir_nrows--; /* Adjust direct row sections for indirect section */ - if(sect->u.indirect.dir_nrows > 0) { + if (sect->u.indirect.dir_nrows > 0) { HDassert(sect->u.indirect.dir_rows); - HDmemmove(§->u.indirect.dir_rows[0], - §->u.indirect.dir_rows[1], - sect->u.indirect.dir_nrows * sizeof(H5HF_free_section_t *)); + HDmemmove(§->u.indirect.dir_rows[0], §->u.indirect.dir_rows[1], + sect->u.indirect.dir_nrows * sizeof(H5HF_free_section_t *)); HDassert(sect->u.indirect.dir_rows[0]); /* Make new "first row" in indirect section */ - if(row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) - if(H5HF__sect_row_first(hdr, sect->u.indirect.dir_rows[0]) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for indirect section") + if (row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) + if (H5HF__sect_row_first(hdr, sect->u.indirect.dir_rows[0]) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for indirect section") } /* end if */ else { /* Sanity check */ @@ -3011,17 +2941,18 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_xfree(sect->u.indirect.dir_rows); /* Make new "first row" in indirect section */ - if(row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) - if(H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for child indirect section") + if (row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) + if (H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for child indirect section") } /* end else */ - } /* end if */ + } /* end if */ /* Adjust number of entries covered */ sect->u.indirect.num_entries--; } /* end if */ - else if(row_entry == end_entry) { - unsigned new_end_row; /* New end row for entries */ + else if (row_entry == end_entry) { + unsigned new_end_row; /* New end row for entries */ /* Sanity check */ HDassert(sect->u.indirect.indir_nents == 0); @@ -3033,18 +2964,18 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, /* Check for eliminating a direct row */ new_end_row = ((start_entry + sect->u.indirect.num_entries) - 1) / hdr->man_dtable.cparam.width; HDassert(new_end_row <= end_row); - if(new_end_row < end_row) { + if (new_end_row < end_row) { HDassert(new_end_row == (end_row - 1)); sect->u.indirect.dir_nrows--; } /* end if */ - } /* end if */ + } /* end if */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block for this section */ - hsize_t iblock_off; /* Section's indirect block's offset in "heap space" */ - unsigned peer_nentries; /* Number of entries in new peer indirect section */ - unsigned peer_dir_nrows; /* Number of direct rows in new peer indirect section */ - unsigned new_start_row; /* New starting row for current indirect section */ - unsigned u; /* Local index variable */ + H5HF_indirect_t *iblock; /* Pointer to indirect block for this section */ + hsize_t iblock_off; /* Section's indirect block's offset in "heap space" */ + unsigned peer_nentries; /* Number of entries in new peer indirect section */ + unsigned peer_dir_nrows; /* Number of direct rows in new peer indirect section */ + unsigned new_start_row; /* New starting row for current indirect section */ + unsigned u; /* Local index variable */ /* Sanity checks */ HDassert(row_sect->u.row.col == 0); @@ -3054,45 +2985,44 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, HDassert(row_sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); /* Compute basic information about peer & current indirect sections */ - new_start_row = row_sect->u.row.row; - peer_nentries = row_entry - start_entry; + new_start_row = row_sect->u.row.row; + peer_nentries = row_entry - start_entry; peer_dir_nrows = new_start_row - start_row; /* Get indirect block information for peer */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { - iblock = sect->u.indirect.u.iblock; + if (sect->sect_info.state == H5FS_SECT_LIVE) { + iblock = sect->u.indirect.u.iblock; iblock_off = sect->u.indirect.u.iblock->block_off; } /* end if */ else { - iblock = NULL; + iblock = NULL; iblock_off = sect->u.indirect.u.iblock_off; } /* end else */ /* Create peer indirect section */ - if(NULL == (peer_sect = H5HF_sect_indirect_new(hdr, sect->sect_info.addr, - sect->sect_info.size, iblock, iblock_off, start_row, start_col, - peer_nentries))) + if (NULL == + (peer_sect = H5HF_sect_indirect_new(hdr, sect->sect_info.addr, sect->sect_info.size, iblock, + iblock_off, start_row, start_col, peer_nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* Set up direct row & indirect entry information for peer section */ peer_sect->u.indirect.indir_nents = 0; - peer_sect->u.indirect.indir_ents = NULL; - peer_sect->u.indirect.dir_nrows = peer_dir_nrows; - if(NULL == (peer_sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * peer_dir_nrows))) + peer_sect->u.indirect.indir_ents = NULL; + peer_sect->u.indirect.dir_nrows = peer_dir_nrows; + if (NULL == (peer_sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc( + sizeof(H5HF_free_section_t *) * peer_dir_nrows))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "allocation failed for row section pointer array") /* Transfer row sections between current & peer sections */ - H5MM_memcpy(&peer_sect->u.indirect.dir_rows[0], - §->u.indirect.dir_rows[0], - (sizeof(H5HF_free_section_t *) * peer_dir_nrows)); - HDmemmove(§->u.indirect.dir_rows[0], - §->u.indirect.dir_rows[peer_dir_nrows], - (sizeof(H5HF_free_section_t *) * (sect->u.indirect.dir_nrows - peer_dir_nrows))); + H5MM_memcpy(&peer_sect->u.indirect.dir_rows[0], §->u.indirect.dir_rows[0], + (sizeof(H5HF_free_section_t *) * peer_dir_nrows)); + HDmemmove(§->u.indirect.dir_rows[0], §->u.indirect.dir_rows[peer_dir_nrows], + (sizeof(H5HF_free_section_t *) * (sect->u.indirect.dir_nrows - peer_dir_nrows))); sect->u.indirect.dir_nrows -= peer_dir_nrows; HDassert(row_sect == sect->u.indirect.dir_rows[0]); /* Re-target transferred row sections to point to new underlying indirect section */ - for(u = 0; u < peer_dir_nrows; u++) + for (u = 0; u < peer_dir_nrows; u++) peer_sect->u.indirect.dir_rows[u]->u.row.under = peer_sect; /* Change first row section in indirect section to be the "first row" */ @@ -3108,25 +3038,27 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, /* Transfer/update cached information about indirect block */ peer_sect->u.indirect.iblock_entries = sect->u.indirect.iblock_entries; - peer_sect->u.indirect.span_size = row_sect->sect_info.addr - peer_sect->sect_info.addr; + peer_sect->u.indirect.span_size = row_sect->sect_info.addr - peer_sect->sect_info.addr; /* Update information for current section */ sect->sect_info.addr = row_sect->sect_info.addr + hdr->man_dtable.row_block_size[new_start_row]; - sect->u.indirect.span_size -= peer_sect->u.indirect.span_size; /* (span for row section has already been removed) */ + sect->u.indirect.span_size -= + peer_sect->u.indirect.span_size; /* (span for row section has already been removed) */ sect->u.indirect.row = new_start_row; sect->u.indirect.col = row_sect->u.row.col + 1; - sect->u.indirect.num_entries -= (peer_nentries + 1); /* Transferred entries, plus the entry allocated out of the row */ + sect->u.indirect.num_entries -= + (peer_nentries + 1); /* Transferred entries, plus the entry allocated out of the row */ /* Make certain we've tracked the sections' dependents correctly */ - HDassert(sect->u.indirect.rc == - (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); + HDassert(sect->u.indirect.rc == (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); HDassert(peer_sect->u.indirect.rc == - (peer_sect->u.indirect.indir_nents + peer_sect->u.indirect.dir_nrows)); + (peer_sect->u.indirect.indir_nents + peer_sect->u.indirect.dir_nrows)); - /* Reset the peer_sect variable, to indicate that it has been hooked into the data structures correctly and shouldn't be freed */ + /* Reset the peer_sect variable, to indicate that it has been hooked into the data structures + * correctly and shouldn't be freed */ peer_sect = NULL; } /* end else */ - } /* end if */ + } /* end if */ else { /* Decrement count of entries & rows */ sect->u.indirect.num_entries--; @@ -3140,18 +3072,17 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, done: /* Free allocated peer_sect. Note that this is necessary for all failures until peer_sect is linked * into the main free space structures (via the direct blocks), and the reference count is updated. */ - if(peer_sect) { + if (peer_sect) { /* Sanity check - we should only be here if an error occurred */ HDassert(ret_value < 0); - if(H5HF_sect_indirect_free(peer_sect) < 0) + if (H5HF_sect_indirect_free(peer_sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_reduce_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_reduce * @@ -3168,16 +3099,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - unsigned child_entry) +H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned child_entry) { - unsigned start_entry; /* Entry for first block covered */ - unsigned start_row; /* Start row in indirect block */ - unsigned start_col; /* Start column in indirect block */ - unsigned end_entry; /* Entry for last block covered */ - unsigned end_row; /* End row in indirect block */ - H5HF_free_section_t *peer_sect = NULL; /* Peer indirect section */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned start_entry; /* Entry for first block covered */ + unsigned start_row; /* Start row in indirect block */ + unsigned start_col; /* Start column in indirect block */ + unsigned end_entry; /* Entry for last block covered */ + unsigned end_row; /* End row in indirect block */ + H5HF_free_section_t *peer_sect = NULL; /* Peer indirect section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3190,35 +3120,36 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, HDassert(sect->u.indirect.iblock_entries > 0); /* Compute starting & ending information for indirect section */ - start_row = sect->u.indirect.row; - start_col = sect->u.indirect.col; + start_row = sect->u.indirect.row; + start_col = sect->u.indirect.col; start_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; - end_entry = (start_entry + sect->u.indirect.num_entries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; + end_entry = (start_entry + sect->u.indirect.num_entries) - 1; + end_row = end_entry / hdr->man_dtable.cparam.width; /* Check how to adjust section for allocated entry */ - if(sect->u.indirect.num_entries > 1) { + if (sect->u.indirect.num_entries > 1) { /* Check if we have a parent section to be detached from */ - if(sect->u.indirect.parent) { - hbool_t is_first; /* Flag to indicate that this section is the first section in hierarchy */ + if (sect->u.indirect.parent) { + hbool_t is_first; /* Flag to indicate that this section is the first section in hierarchy */ /* Check if this section is the first section */ is_first = H5HF_sect_indirect_is_first(sect); /* Reduce parent indirect section */ - if(H5HF__sect_indirect_reduce(hdr, sect->u.indirect.parent, sect->u.indirect.par_entry) < 0) + if (H5HF__sect_indirect_reduce(hdr, sect->u.indirect.parent, sect->u.indirect.par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce parent indirect section") - sect->u.indirect.parent = NULL; + sect->u.indirect.parent = NULL; sect->u.indirect.par_entry = 0; /* If we weren't the first section, set "first row" for this indirect section */ - if(!is_first) - if(H5HF__sect_indirect_first(hdr, sect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for indirect section") + if (!is_first) + if (H5HF__sect_indirect_first(hdr, sect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for indirect section") } /* end if */ /* Check if we can allocate from start of indirect section */ - if(child_entry == start_entry) { + if (child_entry == start_entry) { /* Sanity check */ HDassert(sect->u.indirect.dir_nrows == 0); HDassert(sect->u.indirect.dir_rows == NULL); @@ -3230,7 +3161,7 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Adjust span of blocks covered */ sect->u.indirect.col++; - if(sect->u.indirect.col == hdr->man_dtable.cparam.width) { + if (sect->u.indirect.col == hdr->man_dtable.cparam.width) { sect->u.indirect.row++; sect->u.indirect.col = 0; } /* end if */ @@ -3239,16 +3170,16 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Adjust indirect entry information */ sect->u.indirect.indir_nents--; - HDmemmove(§->u.indirect.indir_ents[0], - §->u.indirect.indir_ents[1], - sect->u.indirect.indir_nents * sizeof(H5HF_free_section_t *)); + HDmemmove(§->u.indirect.indir_ents[0], §->u.indirect.indir_ents[1], + sect->u.indirect.indir_nents * sizeof(H5HF_free_section_t *)); HDassert(sect->u.indirect.indir_ents[0]); /* Make new "first row" in new first indirect child section */ - if(H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for child indirect section") + if (H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for child indirect section") } /* end if */ - else if(child_entry == end_entry) { + else if (child_entry == end_entry) { /* Sanity check */ HDassert(sect->u.indirect.indir_nents > 0); HDassert(sect->u.indirect.indir_ents); @@ -3259,47 +3190,47 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Adjust indirect entry information */ sect->u.indirect.indir_nents--; - if(sect->u.indirect.indir_nents == 0) + if (sect->u.indirect.indir_nents == 0) sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_xfree(sect->u.indirect.indir_ents); } /* end if */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block for this section */ - hsize_t iblock_off; /* Section's indirect block's offset in "heap space" */ - haddr_t peer_sect_addr; /* Address of new peer section in "heap space" */ - unsigned peer_nentries; /* Number of entries in new peer indirect section */ - unsigned peer_start_row; /* Starting row for new peer indirect section */ - unsigned peer_start_col; /* Starting column for new peer indirect section */ - unsigned child_row; /* Row where child entry is located */ - unsigned new_nentries; /* New number of entries for current indirect section */ - unsigned u; /* Local index variable */ + H5HF_indirect_t *iblock; /* Pointer to indirect block for this section */ + hsize_t iblock_off; /* Section's indirect block's offset in "heap space" */ + haddr_t peer_sect_addr; /* Address of new peer section in "heap space" */ + unsigned peer_nentries; /* Number of entries in new peer indirect section */ + unsigned peer_start_row; /* Starting row for new peer indirect section */ + unsigned peer_start_col; /* Starting column for new peer indirect section */ + unsigned child_row; /* Row where child entry is located */ + unsigned new_nentries; /* New number of entries for current indirect section */ + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(sect->u.indirect.indir_nents > 0); HDassert(sect->u.indirect.indir_ents); /* Compute basic information about peer & current indirect sections */ - peer_nentries = end_entry - child_entry; + peer_nentries = end_entry - child_entry; peer_start_row = (child_entry + 1) / hdr->man_dtable.cparam.width; peer_start_col = (child_entry + 1) % hdr->man_dtable.cparam.width; - child_row = child_entry / hdr->man_dtable.cparam.width; - new_nentries = sect->u.indirect.num_entries - (peer_nentries + 1); + child_row = child_entry / hdr->man_dtable.cparam.width; + new_nentries = sect->u.indirect.num_entries - (peer_nentries + 1); HDassert(child_row >= hdr->man_dtable.max_direct_rows); /* Get indirect block information for peer */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { - iblock = sect->u.indirect.u.iblock; + if (sect->sect_info.state == H5FS_SECT_LIVE) { + iblock = sect->u.indirect.u.iblock; iblock_off = sect->u.indirect.u.iblock->block_off; } /* end if */ else { - iblock = NULL; + iblock = NULL; iblock_off = sect->u.indirect.u.iblock_off; } /* end else */ /* Update the number of entries in current section & calculate it's span size */ /* (Will use this to compute the section address for the peer section */ sect->u.indirect.num_entries = new_nentries; - sect->u.indirect.span_size = H5HF_dtable_span_size(&hdr->man_dtable, - sect->u.indirect.row, sect->u.indirect.col, new_nentries); + sect->u.indirect.span_size = H5HF_dtable_span_size(&hdr->man_dtable, sect->u.indirect.row, + sect->u.indirect.col, new_nentries); HDassert(sect->u.indirect.span_size > 0); /* Compute address of peer indirect section */ @@ -3308,30 +3239,32 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, peer_sect_addr += hdr->man_dtable.row_block_size[child_row]; /* Create peer indirect section */ - if(NULL == (peer_sect = H5HF_sect_indirect_new(hdr, peer_sect_addr, - sect->sect_info.size, iblock, iblock_off, peer_start_row, - peer_start_col, peer_nentries))) + if (NULL == (peer_sect = H5HF_sect_indirect_new(hdr, peer_sect_addr, sect->sect_info.size, iblock, + iblock_off, peer_start_row, peer_start_col, + peer_nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* Set up direct row & indirect entry information for peer section */ - peer_sect->u.indirect.dir_nrows = 0; - peer_sect->u.indirect.dir_rows = NULL; + peer_sect->u.indirect.dir_nrows = 0; + peer_sect->u.indirect.dir_rows = NULL; peer_sect->u.indirect.indir_nents = peer_nentries; - if(NULL == (peer_sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * peer_nentries))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "allocation failed for indirect section pointer array") + if (NULL == (peer_sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc( + sizeof(H5HF_free_section_t *) * peer_nentries))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, + "allocation failed for indirect section pointer array") /* Transfer child indirect sections between current & peer sections */ H5MM_memcpy(&peer_sect->u.indirect.indir_ents[0], - §->u.indirect.indir_ents[sect->u.indirect.indir_nents - peer_nentries], - (sizeof(H5HF_free_section_t *) * peer_nentries)); + §->u.indirect.indir_ents[sect->u.indirect.indir_nents - peer_nentries], + (sizeof(H5HF_free_section_t *) * peer_nentries)); sect->u.indirect.indir_nents -= (peer_nentries + 1); /* Transferred blocks, plus child entry */ /* Eliminate indirect entries for this section, if appropriate */ - if(sect->u.indirect.indir_nents == 0) + if (sect->u.indirect.indir_nents == 0) sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_xfree(sect->u.indirect.indir_ents); /* Re-target transferred row sections to point to new underlying indirect section */ - for(u = 0; u < peer_nentries; u++) + for (u = 0; u < peer_nentries; u++) peer_sect->u.indirect.indir_ents[u]->u.indirect.parent = peer_sect; /* Adjust reference counts for current & peer sections */ @@ -3346,18 +3279,20 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, * detached the child section yet) */ HDassert((sect->u.indirect.rc - 1) == - (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); + (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); HDassert(peer_sect->u.indirect.rc == - (peer_sect->u.indirect.indir_nents + peer_sect->u.indirect.dir_nrows)); + (peer_sect->u.indirect.indir_nents + peer_sect->u.indirect.dir_nrows)); /* Make new "first row" in peer section */ - if(H5HF__sect_indirect_first(hdr, peer_sect->u.indirect.indir_ents[0]) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for peer indirect section") + if (H5HF__sect_indirect_first(hdr, peer_sect->u.indirect.indir_ents[0]) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for peer indirect section") - /* Reset the peer_sect variable, to indicate that it has been hooked into the data structures correctly and shouldn't be freed */ + /* Reset the peer_sect variable, to indicate that it has been hooked into the data structures + * correctly and shouldn't be freed */ peer_sect = NULL; } /* end else */ - } /* end if */ + } /* end if */ else { /* Decrement count of entries & indirect entries */ sect->u.indirect.num_entries--; @@ -3370,24 +3305,23 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Decrement # of sections which depend on this row */ /* (Must be last as section can be freed) */ - if(H5HF_sect_indirect_decr(sect) < 0) + if (H5HF_sect_indirect_decr(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't decrement section's ref. count ") done: /* Free allocated peer_sect. Note that this is necessary for all failures until peer_sect is linked * into the main free space structures (via the direct blocks), and the reference count is updated. */ - if(peer_sect) { + if (peer_sect) { /* Sanity check - we should only be here if an error occurred */ HDassert(ret_value < 0); - if(H5HF_sect_indirect_free(peer_sect) < 0) + if (H5HF_sect_indirect_free(peer_sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_reduce() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_is_first * @@ -3404,7 +3338,7 @@ done: static hbool_t H5HF_sect_indirect_is_first(H5HF_free_section_t *sect) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3412,8 +3346,8 @@ H5HF_sect_indirect_is_first(H5HF_free_section_t *sect) HDassert(sect); /* Recurse to parent */ - if(sect->u.indirect.parent) { - if(sect->sect_info.addr == sect->u.indirect.parent->sect_info.addr) + if (sect->u.indirect.parent) { + if (sect->sect_info.addr == sect->u.indirect.parent->sect_info.addr) ret_value = H5HF_sect_indirect_is_first(sect->u.indirect.parent); } /* end if */ else @@ -3422,7 +3356,6 @@ H5HF_sect_indirect_is_first(H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_indirect_is_first() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_first * @@ -3439,7 +3372,7 @@ H5HF_sect_indirect_is_first(H5HF_free_section_t *sect) static herr_t H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3448,7 +3381,7 @@ H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect); /* Check if this indirect section has direct block rows */ - if(sect->u.indirect.dir_nrows > 0) { + if (sect->u.indirect.dir_nrows > 0) { /* Sanity checks */ HDassert(sect->u.indirect.row == 0); HDassert(sect->u.indirect.col == 0); @@ -3456,7 +3389,7 @@ H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->u.indirect.dir_rows[0]); /* Change first row section in indirect section to be the "first row" */ - if(H5HF__sect_row_first(hdr, sect->u.indirect.dir_rows[0]) < 0) + if (H5HF__sect_row_first(hdr, sect->u.indirect.dir_rows[0]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set row section to be first row") } /* end if */ else { @@ -3466,7 +3399,7 @@ H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->u.indirect.indir_ents[0]); /* Forward to first child indirect section */ - if(H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) + if (H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set child indirect section to be first row") } /* end else */ @@ -3474,7 +3407,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_first() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_get_iblock * @@ -3503,7 +3435,6 @@ H5HF_sect_indirect_get_iblock(H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(sect->u.indirect.u.iblock) } /* end H5HF_sect_indirect_get_iblock() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_merge_row * @@ -3521,18 +3452,17 @@ H5HF_sect_indirect_get_iblock(H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, - H5HF_free_section_t *row_sect2) +H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, H5HF_free_section_t *row_sect2) { - H5HF_free_section_t *sect1, *sect2; /* Indirect sections underlying row sections */ - unsigned start_entry1; /* Start entry for section #1 */ - unsigned start_row1, start_col1; /* Starting row & column for section #1 */ - unsigned end_entry1; /* End entry for section #1 */ - unsigned end_row1; /* Ending row for section #1 */ - unsigned start_row2; /* Starting row for section #2 */ - hbool_t merged_rows; /* Flag to indicate that rows was merged together */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect1, *sect2; /* Indirect sections underlying row sections */ + unsigned start_entry1; /* Start entry for section #1 */ + unsigned start_row1, start_col1; /* Starting row & column for section #1 */ + unsigned end_entry1; /* End entry for section #1 */ + unsigned end_row1; /* Ending row for section #1 */ + unsigned start_row2; /* Starting row for section #2 */ + hbool_t merged_rows; /* Flag to indicate that rows was merged together */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3555,22 +3485,22 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, HDassert(sect2->u.indirect.span_size > 0); /* Set up span information */ - start_row1 = sect1->u.indirect.row; - start_col1 = sect1->u.indirect.col; + start_row1 = sect1->u.indirect.row; + start_col1 = sect1->u.indirect.col; start_entry1 = (start_row1 * hdr->man_dtable.cparam.width) + start_col1; - end_entry1 = (start_entry1 + sect1->u.indirect.num_entries) - 1; - end_row1 = end_entry1 / hdr->man_dtable.cparam.width; - start_row2 = sect2->u.indirect.row; + end_entry1 = (start_entry1 + sect1->u.indirect.num_entries) - 1; + end_row1 = end_entry1 / hdr->man_dtable.cparam.width; + start_row2 = sect2->u.indirect.row; /* Check for direct sections in second section */ /* (second indirect section can be parent of indirect section for second * row, and thus have no row sections of it's own) */ - if(sect2->u.indirect.dir_nrows > 0) { - hsize_t sect1_iblock_off, sect2_iblock_off; /* Offset of indirect block underlying row section */ - unsigned new_dir_nrows1; /* New value for number of direct rows in first section */ - unsigned src_row2; /* Source row for copying from second section */ - unsigned nrows_moved2; /* Number of rows to move from second section to first */ + if (sect2->u.indirect.dir_nrows > 0) { + hsize_t sect1_iblock_off, sect2_iblock_off; /* Offset of indirect block underlying row section */ + unsigned new_dir_nrows1; /* New value for number of direct rows in first section */ + unsigned src_row2; /* Source row for copying from second section */ + unsigned nrows_moved2; /* Number of rows to move from second section to first */ /* Sanity check child row assumptions */ /* (second indirect section should be at top of equal or deeper @@ -3582,21 +3512,21 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, HDassert(sect1->u.indirect.dir_rows); /* Get the offsets for the indirect blocks under the rows */ - if(H5FS_SECT_LIVE == row_sect1->u.row.under->sect_info.state) + if (H5FS_SECT_LIVE == row_sect1->u.row.under->sect_info.state) sect1_iblock_off = row_sect1->u.row.under->u.indirect.u.iblock->block_off; else sect1_iblock_off = row_sect1->u.row.under->u.indirect.u.iblock_off; - if(H5FS_SECT_LIVE == row_sect2->u.row.under->sect_info.state) + if (H5FS_SECT_LIVE == row_sect2->u.row.under->sect_info.state) sect2_iblock_off = row_sect2->u.row.under->u.indirect.u.iblock->block_off; else sect2_iblock_off = row_sect2->u.row.under->u.indirect.u.iblock_off; /* Check for sections sharing a row in the same underlying indirect block */ - if(sect1_iblock_off == sect2_iblock_off && end_row1 == start_row2) { - H5HF_free_section_t *last_row_sect1; /* Last row in first indirect section */ + if (sect1_iblock_off == sect2_iblock_off && end_row1 == start_row2) { + H5HF_free_section_t *last_row_sect1; /* Last row in first indirect section */ /* Locate the last row section in first indirect section, if we don't already have it */ - if(row_sect1->u.row.row != end_row1) + if (row_sect1->u.row.row != end_row1) last_row_sect1 = sect1->u.indirect.dir_rows[sect1->u.indirect.dir_nrows - 1]; else last_row_sect1 = row_sect1; @@ -3608,8 +3538,8 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, last_row_sect1->u.row.num_entries += row_sect2->u.row.num_entries; /* Set up parameters for transfer of rows */ - src_row2 = 1; - nrows_moved2 = sect2->u.indirect.dir_nrows - 1; + src_row2 = 1; + nrows_moved2 = sect2->u.indirect.dir_nrows - 1; new_dir_nrows1 = (sect1->u.indirect.dir_nrows + sect2->u.indirect.dir_nrows) - 1; /* Indicate that the rows were merged */ @@ -3618,8 +3548,8 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, else { /* Set up parameters for transfer of rows */ - src_row2 = 0; - nrows_moved2 = sect2->u.indirect.dir_nrows; + src_row2 = 0; + nrows_moved2 = sect2->u.indirect.dir_nrows; new_dir_nrows1 = sect1->u.indirect.dir_nrows + sect2->u.indirect.dir_nrows; /* Indicate that the rows were _not_ merged */ @@ -3627,21 +3557,22 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, } /* end else */ /* Check if we need to move additional rows */ - if(nrows_moved2 > 0) { - H5HF_free_section_t **new_dir_rows; /* Pointer to new array of direct row pointers */ + if (nrows_moved2 > 0) { + H5HF_free_section_t **new_dir_rows; /* Pointer to new array of direct row pointers */ /* Extend the first section's row array */ - if(NULL == (new_dir_rows = (H5HF_free_section_t **)H5MM_realloc(sect1->u.indirect.dir_rows, sizeof(H5HF_free_section_t *) * new_dir_nrows1))) + if (NULL == (new_dir_rows = (H5HF_free_section_t **)H5MM_realloc( + sect1->u.indirect.dir_rows, sizeof(H5HF_free_section_t *) * new_dir_nrows1))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for row section pointer array") sect1->u.indirect.dir_rows = new_dir_rows; /* Transfer the second section's rows to first section */ H5MM_memcpy(§1->u.indirect.dir_rows[sect1->u.indirect.dir_nrows], - §2->u.indirect.dir_rows[src_row2], - (sizeof(H5HF_free_section_t *) * nrows_moved2)); + §2->u.indirect.dir_rows[src_row2], + (sizeof(H5HF_free_section_t *) * nrows_moved2)); /* Re-target the row sections moved from second section */ - for(u = sect1->u.indirect.dir_nrows; u < new_dir_nrows1; u++) + for (u = sect1->u.indirect.dir_nrows; u < new_dir_nrows1; u++) sect1->u.indirect.dir_rows[u]->u.row.under = sect1; /* Adjust reference counts to account for transferred rows */ @@ -3651,14 +3582,14 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, /* Update information for first section */ sect1->u.indirect.dir_nrows = new_dir_nrows1; } /* end if */ - } /* end if */ + } /* end if */ else /* Indicate that the rows were _not_ merged */ merged_rows = FALSE; /* Check for indirect sections in second section */ - if(sect2->u.indirect.indir_nents > 0) { - unsigned new_indir_nents1; /* New value for number of indirect entries in first section */ + if (sect2->u.indirect.indir_nents > 0) { + unsigned new_indir_nents1; /* New value for number of indirect entries in first section */ /* Some sanity checks on second indirect section */ HDassert(sect2->u.indirect.rc > 0); @@ -3669,26 +3600,27 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, new_indir_nents1 = sect1->u.indirect.indir_nents + sect2->u.indirect.indir_nents; /* Check if first section can just take over second section's memory buffer */ - if(sect1->u.indirect.indir_ents == NULL) { + if (sect1->u.indirect.indir_ents == NULL) { sect1->u.indirect.indir_ents = sect2->u.indirect.indir_ents; sect2->u.indirect.indir_ents = NULL; } /* end if */ else { - H5HF_free_section_t **new_indir_ents; /* Pointer to new array of indirect entries */ + H5HF_free_section_t **new_indir_ents; /* Pointer to new array of indirect entries */ /* Extend the first section's entry array */ - if(NULL == (new_indir_ents = (H5HF_free_section_t **)H5MM_realloc(sect1->u.indirect.indir_ents, sizeof(H5HF_free_section_t *) * new_indir_nents1))) + if (NULL == (new_indir_ents = (H5HF_free_section_t **)H5MM_realloc( + sect1->u.indirect.indir_ents, sizeof(H5HF_free_section_t *) * new_indir_nents1))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for row section pointer array") sect1->u.indirect.indir_ents = new_indir_ents; /* Transfer the second section's entries to first section */ H5MM_memcpy(§1->u.indirect.indir_ents[sect1->u.indirect.indir_nents], - §2->u.indirect.indir_ents[0], - (sizeof(H5HF_free_section_t *) * sect2->u.indirect.indir_nents)); + §2->u.indirect.indir_ents[0], + (sizeof(H5HF_free_section_t *) * sect2->u.indirect.indir_nents)); } /* end else */ /* Re-target the child indirect sections moved from second section */ - for(u = sect1->u.indirect.indir_nents; u < new_indir_nents1; u++) + for (u = sect1->u.indirect.indir_nents; u < new_indir_nents1; u++) sect1->u.indirect.indir_ents[u]->u.indirect.parent = sect1; /* Adjust reference counts for transferred child indirect sections */ @@ -3704,46 +3636,46 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, sect1->u.indirect.span_size += sect2->u.indirect.span_size; /* Make certain we've tracked the first section's dependents correctly */ - HDassert(sect1->u.indirect.rc == - (sect1->u.indirect.indir_nents + sect1->u.indirect.dir_nrows)); + HDassert(sect1->u.indirect.rc == (sect1->u.indirect.indir_nents + sect1->u.indirect.dir_nrows)); /* Wrap up, freeing or re-inserting second row section */ /* (want this to be after the first indirect section is consistent again) */ - if(merged_rows) { + if (merged_rows) { /* Release second row section */ /* (indirectly releases second indirect section, since all of it's * other dependents are gone) */ HDassert(sect2->u.indirect.rc == 1); - if(H5HF__sect_row_free((H5FS_section_info_t *)row_sect2) < 0) + if (H5HF__sect_row_free((H5FS_section_info_t *)row_sect2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free row section") } /* end if */ else { /* Decrement ref. count on second indirect section's parent */ HDassert(sect2->u.indirect.rc == 0); - if(sect2->u.indirect.parent) - if(H5HF_sect_indirect_decr(sect2->u.indirect.parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't decrement ref. count on parent indirect section") + if (sect2->u.indirect.parent) + if (H5HF_sect_indirect_decr(sect2->u.indirect.parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, + "can't decrement ref. count on parent indirect section") /* Free second indirect section */ - if(H5HF_sect_indirect_free(sect2) < 0) + if (H5HF_sect_indirect_free(sect2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") /* Re-add the second section's first row */ /* (it's already been added to first indirect section, but it's been removed * from the free space manager and needs to be re-added) - */ + */ row_sect2->sect_info.type = H5HF_FSPACE_SECT_NORMAL_ROW; - if(H5HF__space_add(hdr, row_sect2, H5FS_ADD_SKIP_VALID) < 0) + if (H5HF__space_add(hdr, row_sect2, H5FS_ADD_SKIP_VALID) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add second row section to free space") } /* end else */ /* Check if we can create parent indirect section for first section */ /* (i.e. merged indirect sections cover an entire indirect block) */ - if(sect1->u.indirect.iblock_entries == sect1->u.indirect.num_entries) { + if (sect1->u.indirect.iblock_entries == sect1->u.indirect.num_entries) { /* Build parent section for fully populated indirect section */ HDassert(sect1->u.indirect.parent == NULL); - if(H5HF__sect_indirect_build_parent(hdr, sect1) < 0) + if (H5HF__sect_indirect_build_parent(hdr, sect1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create parent for full indirect section") } /* end if */ @@ -3751,7 +3683,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_merge_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_build_parent * @@ -3768,12 +3699,12 @@ done: static herr_t H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - H5HF_indirect_t *par_iblock; /* Indirect block for parent section */ - H5HF_free_section_t *par_sect = NULL; /* Parent indirect section */ - hsize_t par_block_off; /* Offset of parent's block */ - unsigned par_row, par_col; /* Row & column in parent indirect section */ - unsigned par_entry; /* Entry within parent indirect section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t * par_iblock; /* Indirect block for parent section */ + H5HF_free_section_t *par_sect = NULL; /* Parent indirect section */ + hsize_t par_block_off; /* Offset of parent's block */ + unsigned par_row, par_col; /* Row & column in parent indirect section */ + unsigned par_entry; /* Entry within parent indirect section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3788,14 +3719,14 @@ H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->u.indirect.parent == NULL); /* Get information for creating parent indirect section */ - if(sect->u.indirect.u.iblock->parent) { - par_entry = sect->u.indirect.u.iblock->par_entry; - par_iblock = sect->u.indirect.u.iblock->parent; + if (sect->u.indirect.u.iblock->parent) { + par_entry = sect->u.indirect.u.iblock->par_entry; + par_iblock = sect->u.indirect.u.iblock->parent; par_block_off = par_iblock->block_off; } /* end if */ else { /* Retrieve the information for the parent block */ - if(H5HF__man_iblock_parent_info(hdr, sect->sect_info.addr, &par_block_off, &par_entry) < 0) + if (H5HF__man_iblock_parent_info(hdr, sect->sect_info.addr, &par_block_off, &par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get block entry") par_iblock = NULL; } /* end else */ @@ -3806,35 +3737,34 @@ H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(par_row >= hdr->man_dtable.max_direct_rows); /* Create parent indirect section */ - if(NULL == (par_sect = H5HF_sect_indirect_new(hdr, sect->sect_info.addr, - sect->sect_info.size, par_iblock, par_block_off, - par_row, par_col, 1))) + if (NULL == (par_sect = H5HF_sect_indirect_new(hdr, sect->sect_info.addr, sect->sect_info.size, + par_iblock, par_block_off, par_row, par_col, 1))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* No rows of direct blocks covered in parent, reset direct row information */ par_sect->u.indirect.dir_nrows = 0; - par_sect->u.indirect.dir_rows = NULL; + par_sect->u.indirect.dir_rows = NULL; /* Allocate space for the child indirect sections */ par_sect->u.indirect.indir_nents = 1; - if(NULL == (par_sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *)))) + if (NULL == (par_sect->u.indirect.indir_ents = + (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for indirect section pointer array") /* Attach sections together */ - sect->u.indirect.parent = par_sect; - sect->u.indirect.par_entry = par_entry; + sect->u.indirect.parent = par_sect; + sect->u.indirect.par_entry = par_entry; par_sect->u.indirect.indir_ents[0] = sect; - par_sect->u.indirect.rc = 1; + par_sect->u.indirect.rc = 1; done: - if(ret_value < 0) - if(par_sect && H5HF_sect_indirect_free(par_sect) < 0) + if (ret_value < 0) + if (par_sect && H5HF_sect_indirect_free(par_sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_build_parent() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_shrink * @@ -3851,8 +3781,8 @@ done: static herr_t H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3864,33 +3794,32 @@ H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->u.indirect.dir_nrows > 0 || sect->u.indirect.indir_nents > 0); /* Walk through direct rows, freeing them */ - for(u = 0; u < sect->u.indirect.dir_nrows; u++) { + for (u = 0; u < sect->u.indirect.dir_nrows; u++) { /* Remove the normal rows from free space manager */ - if(sect->u.indirect.dir_rows[u]->sect_info.type != H5HF_FSPACE_SECT_FIRST_ROW) { + if (sect->u.indirect.dir_rows[u]->sect_info.type != H5HF_FSPACE_SECT_FIRST_ROW) { HDassert(sect->u.indirect.dir_rows[u]->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); - if(H5HF__space_remove(hdr, sect->u.indirect.dir_rows[u]) < 0) + if (H5HF__space_remove(hdr, sect->u.indirect.dir_rows[u]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove section from heap free space") } /* end if */ /* Release the row section */ - if(H5HF__sect_row_free_real(sect->u.indirect.dir_rows[u]) < 0) + if (H5HF__sect_row_free_real(sect->u.indirect.dir_rows[u]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free child section node") } /* end for */ /* Walk through indirect entries, freeing them (recursively) */ - for(u = 0; u < sect->u.indirect.indir_nents; u++) - if(H5HF__sect_indirect_shrink(hdr, sect->u.indirect.indir_ents[u]) < 0) + for (u = 0; u < sect->u.indirect.indir_nents; u++) + if (H5HF__sect_indirect_shrink(hdr, sect->u.indirect.indir_ents[u]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free child section node") /* Free the indirect section itself */ - if(H5HF_sect_indirect_free(sect) < 0) + if (H5HF_sect_indirect_free(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_serialize * @@ -3906,10 +3835,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, - uint8_t *buf) +H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, uint8_t *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -3919,14 +3847,15 @@ H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, HDassert(buf); /* Check if this indirect section has a parent & forward if this section is first */ - if(sect->u.indirect.parent) { - if(sect->sect_info.addr == sect->u.indirect.parent->sect_info.addr) - if(H5HF_sect_indirect_serialize(hdr, sect->u.indirect.parent, buf) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, "can't serialize indirect section's parent indirect section") + if (sect->u.indirect.parent) { + if (sect->sect_info.addr == sect->u.indirect.parent->sect_info.addr) + if (H5HF_sect_indirect_serialize(hdr, sect->u.indirect.parent, buf) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, + "can't serialize indirect section's parent indirect section") } /* end if */ else { /* Indirect range's indirect block's block offset */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.state == H5FS_SECT_LIVE) { HDassert(sect->u.indirect.u.iblock); UINT64ENCODE_VAR(buf, sect->u.indirect.u.iblock->block_off, hdr->heap_off_size); } /* end if */ @@ -3947,7 +3876,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_sect_indirect_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_deserialize * @@ -3962,19 +3890,19 @@ done: *------------------------------------------------------------------------- */ static H5FS_section_info_t * -H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, - haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags) +H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, + unsigned *des_flags) { - H5HF_free_section_t *new_sect; /* New indirect section */ - hsize_t iblock_off; /* Indirect block's offset */ - unsigned start_row; /* Indirect section's start row */ - unsigned start_col; /* Indirect section's start column */ - unsigned nentries; /* Indirect section's number of entries */ - unsigned start_entry; /* Start entry in indirect block */ - unsigned end_entry; /* End entry in indirect block */ - unsigned end_row; /* End row in indirect block */ - unsigned end_col; /* End column in indirect block */ - H5FS_section_info_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *new_sect; /* New indirect section */ + hsize_t iblock_off; /* Indirect block's offset */ + unsigned start_row; /* Indirect section's start row */ + unsigned start_col; /* Indirect section's start column */ + unsigned nentries; /* Indirect section's number of entries */ + unsigned start_entry; /* Start entry in indirect block */ + unsigned end_entry; /* End entry in indirect block */ + unsigned end_row; /* End row in indirect block */ + unsigned end_col; /* End column in indirect block */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -3997,8 +3925,8 @@ H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, UINT16DECODE(buf, nentries); /* Create free space section node */ - if(NULL == (new_sect = H5HF_sect_indirect_new(hdr, sect_addr, sect_size, - NULL, iblock_off, start_row, start_col, nentries))) + if (NULL == (new_sect = H5HF_sect_indirect_new(hdr, sect_addr, sect_size, NULL, iblock_off, start_row, + start_col, nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't create indirect section") /* Compute start entry */ @@ -4006,13 +3934,13 @@ H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, /* Compute end column & row */ end_entry = (start_entry + nentries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; - end_col = end_entry % hdr->man_dtable.cparam.width; + end_row = end_entry / hdr->man_dtable.cparam.width; + end_col = end_entry % hdr->man_dtable.cparam.width; /* Initialize rows for new indirect section */ - if(H5HF__sect_indirect_init_rows(hdr, new_sect, TRUE, NULL, - H5FS_ADD_DESERIALIZING, new_sect->u.indirect.row, new_sect->u.indirect.col, - end_row, end_col) < 0) + if (H5HF__sect_indirect_init_rows(hdr, new_sect, TRUE, NULL, H5FS_ADD_DESERIALIZING, + new_sect->u.indirect.row, new_sect->u.indirect.col, end_row, + end_col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize indirect section") /* Indicate that this section shouldn't be added to free space manager's list */ @@ -4025,7 +3953,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_indirect_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_free * @@ -4043,8 +3970,8 @@ done: static herr_t H5HF_sect_indirect_free(H5HF_free_section_t *sect) { - H5HF_indirect_t *iblock = NULL; /* Indirect block for section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = NULL; /* Indirect block for section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -4057,21 +3984,20 @@ H5HF_sect_indirect_free(H5HF_free_section_t *sect) sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_xfree(sect->u.indirect.indir_ents); /* Check for live reference to an indirect block */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.state == H5FS_SECT_LIVE) { /* Get indirect block, if there was one */ - if(sect->u.indirect.u.iblock) + if (sect->u.indirect.u.iblock) iblock = sect->u.indirect.u.iblock; } /* end if */ /* Release the sections */ - if(H5HF_sect_node_free(sect, iblock) < 0) + if (H5HF_sect_node_free(sect, iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_indirect_free() */ +} /* H5HF_sect_indirect_free() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_valid * @@ -4088,12 +4014,12 @@ done: static herr_t H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) { - unsigned start_row; /* Row for first block covered */ - unsigned start_col; /* Column for first block covered */ - unsigned start_entry; /* Entry for first block covered */ - unsigned end_row; /* Row for last block covered */ - unsigned end_entry; /* Entry for last block covered */ - unsigned u; /* Local index variable */ + unsigned start_row; /* Row for first block covered */ + unsigned start_col; /* Column for first block covered */ + unsigned start_entry; /* Entry for first block covered */ + unsigned end_row; /* Row for last block covered */ + unsigned end_entry; /* Entry for last block covered */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -4102,21 +4028,21 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) HDassert(sect); /* Compute starting entry, column & row */ - start_row = sect->u.indirect.row; - start_col = sect->u.indirect.col; + start_row = sect->u.indirect.row; + start_col = sect->u.indirect.col; start_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; /* Compute ending entry, column & row */ end_entry = (start_entry + sect->u.indirect.num_entries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; + end_row = end_entry / hdr->man_dtable.cparam.width; /* Sanity check any direct rows */ - if(sect->u.indirect.dir_nrows > 0) { - unsigned dir_nrows; /* Number of direct rows in section */ - unsigned max_dir_row; /* Maximum direct row in section */ + if (sect->u.indirect.dir_nrows > 0) { + unsigned dir_nrows; /* Number of direct rows in section */ + unsigned max_dir_row; /* Maximum direct row in section */ /* Check for indirect rows in section */ - if(end_row >= hdr->man_dtable.max_direct_rows) + if (end_row >= hdr->man_dtable.max_direct_rows) max_dir_row = hdr->man_dtable.max_direct_rows - 1; else max_dir_row = end_row; @@ -4124,43 +4050,44 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) /* Iterate over direct rows, checking pointer references */ dir_nrows = (max_dir_row - start_row) + 1; HDassert(dir_nrows == sect->u.indirect.dir_nrows); - for(u = 0; u < dir_nrows; u++) { - const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect; /* Pointer to row section */ + for (u = 0; u < dir_nrows; u++) { + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect; /* Pointer to row section */ tmp_row_sect = sect->u.indirect.dir_rows[u]; - HDassert(tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW - || tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); + HDassert(tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || + tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); HDassert(tmp_row_sect->u.row.under == sect); HDassert(tmp_row_sect->u.row.row == (start_row + u)); - if(u > 0) { - const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect2; /* Pointer to row section */ + if (u > 0) { + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect2; /* Pointer to row section */ tmp_row_sect2 = sect->u.indirect.dir_rows[u - 1]; HDassert(tmp_row_sect2->u.row.row < tmp_row_sect->u.row.row); HDassert(H5F_addr_lt(tmp_row_sect2->sect_info.addr, tmp_row_sect->sect_info.addr)); HDassert(tmp_row_sect2->sect_info.size <= tmp_row_sect->sect_info.size); } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* Sanity check any indirect entries */ - if(sect->u.indirect.indir_nents > 0) { + if (sect->u.indirect.indir_nents > 0) { /* Basic sanity checks */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.state == H5FS_SECT_LIVE) { HDassert(sect->u.indirect.iblock_entries); HDassert(sect->u.indirect.indir_nents <= sect->u.indirect.iblock_entries); } /* end if */ HDassert(sect->u.indirect.indir_ents); /* Sanity check each child indirect section */ - for(u = 0; u < sect->u.indirect.indir_nents; u++) { - const H5HF_free_section_t *tmp_child_sect; /* Pointer to child indirect section */ + for (u = 0; u < sect->u.indirect.indir_nents; u++) { + const H5HF_free_section_t *tmp_child_sect; /* Pointer to child indirect section */ tmp_child_sect = sect->u.indirect.indir_ents[u]; HDassert(tmp_child_sect->sect_info.type == H5HF_FSPACE_SECT_INDIRECT); HDassert(tmp_child_sect->u.indirect.parent == sect); - if(u > 0) { - const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_child_sect2; /* Pointer to child indirect section */ + if (u > 0) { + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED + * tmp_child_sect2; /* Pointer to child indirect section */ tmp_child_sect2 = sect->u.indirect.indir_ents[u - 1]; HDassert(H5F_addr_lt(tmp_child_sect2->sect_info.addr, tmp_child_sect->sect_info.addr)); @@ -4169,12 +4096,11 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) /* Recursively check child indirect section */ H5HF_sect_indirect_valid(hdr, tmp_child_sect); } /* end for */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_sect_indirect_valid() */ +} /* H5HF_sect_indirect_valid() */ - /*------------------------------------------------------------------------- * Function: H5HF_sect_indirect_debug * @@ -4190,8 +4116,7 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_debug(const H5HF_free_section_t *sect, - FILE *stream, int indent, int fwidth) +H5HF_sect_indirect_debug(const H5HF_free_section_t *sect, FILE *stream, int indent, int fwidth) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -4199,16 +4124,9 @@ H5HF_sect_indirect_debug(const H5HF_free_section_t *sect, HDassert(sect); /* Print indirect section information */ - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Row:", - sect->u.indirect.row); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Column:", - sect->u.indirect.col); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of entries:", - sect->u.indirect.num_entries); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Row:", sect->u.indirect.row); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Column:", sect->u.indirect.col); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of entries:", sect->u.indirect.num_entries); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_sect_indirect_debug() */ - diff --git a/src/H5HFspace.c b/src/H5HFspace.c index ad5ff0f..5f0ef22 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -26,57 +26,48 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ /****************/ /* Local Macros */ /****************/ -#define H5HF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ -#define H5HF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ -#define H5HF_FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */ -#define H5HF_FSPACE_ALIGN_DEF 1 /* Default: no alignment */ +#define H5HF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ +#define H5HF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ +#define H5HF_FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */ +#define H5HF_FSPACE_ALIGN_DEF 1 /* Default: no alignment */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF__space_start * @@ -97,12 +88,10 @@ herr_t H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create) { - const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for fractal heap */ - H5HF_FSPACE_SECT_CLS_SINGLE, - H5HF_FSPACE_SECT_CLS_FIRST_ROW, - H5HF_FSPACE_SECT_CLS_NORMAL_ROW, - H5HF_FSPACE_SECT_CLS_INDIRECT}; - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *classes[] = {/* Free space section classes implemented for fractal heap */ + H5HF_FSPACE_SECT_CLS_SINGLE, H5HF_FSPACE_SECT_CLS_FIRST_ROW, + H5HF_FSPACE_SECT_CLS_NORMAL_ROW, H5HF_FSPACE_SECT_CLS_INDIRECT}; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -112,37 +101,37 @@ H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create) HDassert(hdr); /* Check for creating free space info for the heap */ - if(H5F_addr_defined(hdr->fs_addr)) { + if (H5F_addr_defined(hdr->fs_addr)) { /* Open an existing free space structure for the heap */ - if(NULL == (hdr->fspace = H5FS_open(hdr->f, hdr->fs_addr, - NELMTS(classes), classes, hdr, (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) + if (NULL == (hdr->fspace = H5FS_open(hdr->f, hdr->fs_addr, NELMTS(classes), classes, hdr, + (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info") } /* end if */ else { /* Check if we are allowed to create the free space manager */ - if(may_create) { - H5FS_create_t fs_create; /* Free space creation parameters */ + if (may_create) { + H5FS_create_t fs_create; /* Free space creation parameters */ /* Set the free space creation parameters */ - fs_create.client = H5FS_CLIENT_FHEAP_ID; + fs_create.client = H5FS_CLIENT_FHEAP_ID; fs_create.shrink_percent = H5HF_FSPACE_SHRINK; fs_create.expand_percent = H5HF_FSPACE_EXPAND; - fs_create.max_sect_size = hdr->man_dtable.cparam.max_direct_size; - fs_create.max_sect_addr = hdr->man_dtable.cparam.max_index; + fs_create.max_sect_size = hdr->man_dtable.cparam.max_direct_size; + fs_create.max_sect_addr = hdr->man_dtable.cparam.max_index; /* Create the free space structure for the heap */ - if(NULL == (hdr->fspace = H5FS_create(hdr->f, &hdr->fs_addr, - &fs_create, NELMTS(classes), classes, hdr, (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) + if (NULL == + (hdr->fspace = H5FS_create(hdr->f, &hdr->fs_addr, &fs_create, NELMTS(classes), classes, hdr, + (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info") HDassert(H5F_addr_defined(hdr->fs_addr)); } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_start() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_add * @@ -161,8 +150,8 @@ done: herr_t H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags) { - H5HF_sect_add_ud_t udata; /* User data for free space manager 'add' */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_sect_add_ud_t udata; /* User data for free space manager 'add' */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -173,22 +162,21 @@ H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags) HDassert(node); /* Check if the free space for the heap has been initialized */ - if(!hdr->fspace) - if(H5HF__space_start(hdr, TRUE) < 0) + if (!hdr->fspace) + if (H5HF__space_start(hdr, TRUE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Construct user data */ udata.hdr = hdr; /* Add to the free space for the heap */ - if(H5FS_sect_add(hdr->f, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0) + if (H5FS_sect_add(hdr->f, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't add section to heap free space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_add() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_find * @@ -206,8 +194,8 @@ done: htri_t H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node) { - htri_t node_found = FALSE; /* Whether an existing free list node was found */ - htri_t ret_value = FAIL; /* Return value */ + htri_t node_found = FALSE; /* Whether an existing free list node was found */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -219,13 +207,13 @@ H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node) HDassert(node); /* Check if the free space for the heap has been initialized */ - if(!hdr->fspace) - if(H5HF__space_start(hdr, FALSE) < 0) + if (!hdr->fspace) + if (H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Search for free space in the heap */ - if(hdr->fspace) - if((node_found = H5FS_sect_find(hdr->f, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0) + if (hdr->fspace) + if ((node_found = H5FS_sect_find(hdr->f, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap") /* Set return value */ @@ -235,7 +223,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_find() */ - /*------------------------------------------------------------------------- * Function: H5HF_space_revert_root_cb * @@ -255,8 +242,8 @@ done: static herr_t H5HF_space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udata) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -266,14 +253,15 @@ H5HF_space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udat HDassert(sect); /* Only modify "live" single blocks... */ - if(sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE && sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE && sect->sect_info.state == H5FS_SECT_LIVE) { /* Release hold on previous indirect block (we must have one) */ HDassert(sect->u.single.parent); - if(H5HF__iblock_decr(sect->u.single.parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on section's indirect block") + if (H5HF__iblock_decr(sect->u.single.parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on section's indirect block") /* Reset parent information */ - sect->u.single.parent = NULL; + sect->u.single.parent = NULL; sect->u.single.par_entry = 0; } /* end if */ @@ -281,7 +269,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_space_revert_root_cb() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_revert_root * @@ -300,7 +287,7 @@ done: herr_t H5HF__space_revert_root(const H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -310,16 +297,15 @@ H5HF__space_revert_root(const H5HF_hdr_t *hdr) HDassert(hdr); /* Only need to scan the sections if the free space has been initialized */ - if(hdr->fspace) + if (hdr->fspace) /* Iterate over all sections, resetting the parent pointers in 'single' sections */ - if(H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF_space_revert_root_cb, NULL) < 0) + if (H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF_space_revert_root_cb, NULL) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to reset parent pointers") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_revert_root() */ - /*------------------------------------------------------------------------- * Function: H5HF_space_create_root_cb * @@ -339,9 +325,9 @@ done: static herr_t H5HF_space_create_root_cb(H5FS_section_info_t *_sect, void *_udata) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ - H5HF_indirect_t *root_iblock = (H5HF_indirect_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ + H5HF_indirect_t * root_iblock = (H5HF_indirect_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -357,22 +343,22 @@ H5HF_space_create_root_cb(H5FS_section_info_t *_sect, void *_udata) HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE); /* Increment ref. count on new root indirect block */ - if(H5HF_iblock_incr(root_iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on section's indirect block") + if (H5HF_iblock_incr(root_iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, + "can't increment reference count on section's indirect block") /* Set parent info ("live" section must _NOT_ have a parent right now) */ - if(sect->sect_info.state == H5FS_SECT_SERIALIZED) - sect->sect_info.state = H5FS_SECT_LIVE; /* Mark "live" now */ + if (sect->sect_info.state == H5FS_SECT_SERIALIZED) + sect->sect_info.state = H5FS_SECT_LIVE; /* Mark "live" now */ else - HDassert(!sect->u.single.parent); - sect->u.single.parent = root_iblock; + HDassert(!sect->u.single.parent); + sect->u.single.parent = root_iblock; sect->u.single.par_entry = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_space_create_root_cb() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_create_root * @@ -392,7 +378,7 @@ done: herr_t H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -403,16 +389,16 @@ H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock) HDassert(root_iblock); /* Only need to scan the sections if the free space has been initialized */ - if(hdr->fspace) - /* Iterate over all sections, seting the parent pointers in 'single' sections to the new indirect block */ - if(H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF_space_create_root_cb, root_iblock) < 0) + if (hdr->fspace) + /* Iterate over all sections, seting the parent pointers in 'single' sections to the new indirect + * block */ + if (H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF_space_create_root_cb, root_iblock) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to set parent pointers") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_create_root() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_size * @@ -430,7 +416,7 @@ done: herr_t H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -441,13 +427,13 @@ H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size) HDassert(fs_size); /* Check if the free space for the heap has been initialized */ - if(!hdr->fspace) - if(H5HF__space_start(hdr, FALSE) < 0) + if (!hdr->fspace) + if (H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Get free space metadata size */ - if(hdr->fspace) { - if(H5FS_size(hdr->fspace, fs_size) < 0) + if (hdr->fspace) { + if (H5FS_size(hdr->fspace, fs_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info") } /* end if */ else @@ -457,7 +443,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_remove * @@ -475,7 +460,7 @@ done: herr_t H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -487,14 +472,13 @@ H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node) HDassert(node); /* Remove from the free space for the heap */ - if(H5FS_sect_remove(hdr->f, hdr->fspace, (H5FS_section_info_t *)node) < 0) + if (H5FS_sect_remove(hdr->f, hdr->fspace, (H5FS_section_info_t *)node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove section from heap free space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_close * @@ -513,7 +497,7 @@ done: herr_t H5HF__space_close(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -523,34 +507,33 @@ H5HF__space_close(H5HF_hdr_t *hdr) HDassert(hdr); /* Check if the free space was ever opened */ - if(hdr->fspace) { - hsize_t nsects; /* Number of sections for this heap */ + if (hdr->fspace) { + hsize_t nsects; /* Number of sections for this heap */ /* Retrieve the number of sections for this heap */ - if(H5FS_sect_stats(hdr->fspace, NULL, &nsects) < 0) + if (H5FS_sect_stats(hdr->fspace, NULL, &nsects) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOUNT, FAIL, "can't query free space section count") #ifdef QAK -HDfprintf(stderr, "%s: nsects = %Hu\n", FUNC, nsects); + HDfprintf(stderr, "%s: nsects = %Hu\n", FUNC, nsects); #endif /* QAK */ /* Close the free space for the heap */ - if(H5FS_close(hdr->f, hdr->fspace) < 0) + if (H5FS_close(hdr->f, hdr->fspace) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") hdr->fspace = NULL; /* Check if we can delete the free space manager for this heap */ - if(!nsects) { - if(H5FS_delete(hdr->f, hdr->fs_addr) < 0) + if (!nsects) { + if (H5FS_delete(hdr->f, hdr->fs_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete free space info") hdr->fs_addr = HADDR_UNDEF; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_close() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_delete * @@ -568,7 +551,7 @@ done: herr_t H5HF__space_delete(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -578,14 +561,13 @@ H5HF__space_delete(H5HF_hdr_t *hdr) HDassert(hdr); /* Delete the free space manager */ - if(H5FS_delete(hdr->f, hdr->fs_addr) < 0) + if (H5FS_delete(hdr->f, hdr->fs_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't delete to free space manager") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_delete() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_sect_change_class * @@ -604,11 +586,11 @@ done: herr_t H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, uint16_t new_class) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE #ifdef QAK -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* QAK */ /* @@ -619,10 +601,9 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(sect); /* Notify the free space manager that a section has changed class */ - if(H5FS_sect_change_class(hdr->f, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0) + if (H5FS_sect_change_class(hdr->f, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMODIFY, FAIL, "can't modify class of free space section") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_sect_change_class() */ - diff --git a/src/H5HFstat.c b/src/H5HFstat.c index 7d18ba6..1a8db49 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -22,52 +22,43 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ /****************/ /* Local Macros */ /****************/ - /********************/ /* Package Typedefs */ /********************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF_stat_info * @@ -92,21 +83,20 @@ H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats) HDassert(stats); /* Report statistics for fractal heap */ - stats->man_size = fh->hdr->man_size; + stats->man_size = fh->hdr->man_size; stats->man_alloc_size = fh->hdr->man_alloc_size; - stats->man_iter_off = fh->hdr->man_iter_off; - stats->man_nobjs = fh->hdr->man_nobjs; + stats->man_iter_off = fh->hdr->man_iter_off; + stats->man_nobjs = fh->hdr->man_nobjs; stats->man_free_space = fh->hdr->total_man_free; - stats->huge_size = fh->hdr->huge_size; - stats->huge_nobjs = fh->hdr->huge_nobjs; - stats->tiny_size = fh->hdr->tiny_size; - stats->tiny_nobjs = fh->hdr->tiny_nobjs; -/* XXX: Add more metadata statistics for the heap */ + stats->huge_size = fh->hdr->huge_size; + stats->huge_nobjs = fh->hdr->huge_nobjs; + stats->tiny_size = fh->hdr->tiny_size; + stats->tiny_nobjs = fh->hdr->tiny_nobjs; + /* XXX: Add more metadata statistics for the heap */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_stat_info() */ - /*------------------------------------------------------------------------- * Function: H5HF_size * @@ -125,10 +115,10 @@ H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats) herr_t H5HF_size(const H5HF_t *fh, hsize_t *heap_size) { - H5HF_hdr_t *hdr; /* Fractal heap header */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - hsize_t meta_size = 0; /* free space storage size */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr; /* Fractal heap header */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + hsize_t meta_size = 0; /* free space storage size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -142,38 +132,40 @@ H5HF_size(const H5HF_t *fh, hsize_t *heap_size) hdr = fh->hdr; /* Add in values already known */ - *heap_size += hdr->heap_size; /* Heap header */ - *heap_size += hdr->man_alloc_size; /* Direct block storage for "managed" objects */ - *heap_size += hdr->huge_size; /* "huge" object storage */ + *heap_size += hdr->heap_size; /* Heap header */ + *heap_size += hdr->man_alloc_size; /* Direct block storage for "managed" objects */ + *heap_size += hdr->huge_size; /* "huge" object storage */ /* Check for indirect blocks for managed objects */ - if(H5F_addr_defined(hdr->man_dtable.table_addr) && hdr->man_dtable.curr_root_rows != 0) - if(H5HF__man_iblock_size(hdr->f, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0, heap_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get fractal heap storage info for indirect block") + if (H5F_addr_defined(hdr->man_dtable.table_addr) && hdr->man_dtable.curr_root_rows != 0) + if (H5HF__man_iblock_size(hdr->f, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, + NULL, 0, heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to get fractal heap storage info for indirect block") /* Check for B-tree storage of huge objects in fractal heap */ - if(H5F_addr_defined(hdr->huge_bt2_addr)) { + if (H5F_addr_defined(hdr->huge_bt2_addr)) { /* Open the huge object index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' objects") + if (NULL == (bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' objects") /* Get the B-tree storage */ - if(H5B2_size(bt2, heap_size) < 0) + if (H5B2_size(bt2, heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") } /* end if */ /* Get storage for free-space tracking info */ - if(H5F_addr_defined(hdr->fs_addr)) { - if(H5HF__space_size(hdr, &meta_size) < 0) + if (H5F_addr_defined(hdr->fs_addr)) { + if (H5HF__space_size(hdr, &meta_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info") - *heap_size += meta_size; + *heap_size += meta_size; } /* end if */ done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for tracking 'huge' objects") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_size() */ - diff --git a/src/H5HFtest.c b/src/H5HFtest.c index d6eecd7..633149b 100644 --- a/src/H5HFtest.c +++ b/src/H5HFtest.c @@ -22,55 +22,45 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ -#define H5HF_TESTING /*suppress warning about H5HF testing funcs*/ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ +#define H5HF_TESTING /*suppress warning about H5HF testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF_get_cparam_test * @@ -95,9 +85,9 @@ H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam) HDassert(cparam); /* Get fractal heap creation parameters */ - if(fh->hdr->id_len == (unsigned)(1 + fh->hdr->heap_off_size + fh->hdr->heap_len_size)) + if (fh->hdr->id_len == (unsigned)(1 + fh->hdr->heap_off_size + fh->hdr->heap_len_size)) cparam->id_len = 0; - else if(fh->hdr->id_len == (unsigned)(1 + fh->hdr->sizeof_size + fh->hdr->sizeof_addr)) + else if (fh->hdr->id_len == (unsigned)(1 + fh->hdr->sizeof_size + fh->hdr->sizeof_addr)) cparam->id_len = 1; else H5_CHECKED_ASSIGN(cparam->id_len, uint16_t, fh->hdr->id_len, unsigned); @@ -108,7 +98,6 @@ H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_cmp_cparam_test * @@ -125,7 +114,7 @@ H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam) int H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -134,57 +123,57 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) HDassert(cparam2); /* Compare doubling table parameters */ - if(cparam1->managed.width < cparam2->managed.width) + if (cparam1->managed.width < cparam2->managed.width) HGOTO_DONE(-1) - else if(cparam1->managed.width > cparam2->managed.width) + else if (cparam1->managed.width > cparam2->managed.width) HGOTO_DONE(1) - if(cparam1->managed.start_block_size < cparam2->managed.start_block_size) + if (cparam1->managed.start_block_size < cparam2->managed.start_block_size) HGOTO_DONE(-1) - else if(cparam1->managed.start_block_size > cparam2->managed.start_block_size) + else if (cparam1->managed.start_block_size > cparam2->managed.start_block_size) HGOTO_DONE(1) - if(cparam1->managed.max_direct_size < cparam2->managed.max_direct_size) + if (cparam1->managed.max_direct_size < cparam2->managed.max_direct_size) HGOTO_DONE(-1) - else if(cparam1->managed.max_direct_size > cparam2->managed.max_direct_size) + else if (cparam1->managed.max_direct_size > cparam2->managed.max_direct_size) HGOTO_DONE(1) - if(cparam1->managed.max_index < cparam2->managed.max_index) + if (cparam1->managed.max_index < cparam2->managed.max_index) HGOTO_DONE(-1) - else if(cparam1->managed.max_index > cparam2->managed.max_index) + else if (cparam1->managed.max_index > cparam2->managed.max_index) HGOTO_DONE(1) - if(cparam1->managed.start_root_rows < cparam2->managed.start_root_rows) + if (cparam1->managed.start_root_rows < cparam2->managed.start_root_rows) HGOTO_DONE(-1) - else if(cparam1->managed.start_root_rows > cparam2->managed.start_root_rows) + else if (cparam1->managed.start_root_rows > cparam2->managed.start_root_rows) HGOTO_DONE(1) /* Compare other general parameters for heap */ - if(cparam1->max_man_size < cparam2->max_man_size) + if (cparam1->max_man_size < cparam2->max_man_size) HGOTO_DONE(-1) - else if(cparam1->max_man_size > cparam2->max_man_size) + else if (cparam1->max_man_size > cparam2->max_man_size) HGOTO_DONE(1) - if(cparam1->id_len < cparam2->id_len) + if (cparam1->id_len < cparam2->id_len) HGOTO_DONE(-1) - else if(cparam1->id_len > cparam2->id_len) + else if (cparam1->id_len > cparam2->id_len) HGOTO_DONE(1) /* Compare "important" parameters for any I/O pipeline filters */ - if(cparam1->pline.nused < cparam2->pline.nused) + if (cparam1->pline.nused < cparam2->pline.nused) HGOTO_DONE(-1) - else if(cparam1->pline.nused > cparam2->pline.nused) + else if (cparam1->pline.nused > cparam2->pline.nused) HGOTO_DONE(1) else { - size_t u, v; /* Local index variables */ + size_t u, v; /* Local index variables */ /* Compare each filter */ - for(u = 0; u < cparam1->pline.nused; u++) { + for (u = 0; u < cparam1->pline.nused; u++) { /* Check filter ID */ - if(cparam1->pline.filter[u].id < cparam2->pline.filter[u].id) + if (cparam1->pline.filter[u].id < cparam2->pline.filter[u].id) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].id > cparam2->pline.filter[u].id) + else if (cparam1->pline.filter[u].id > cparam2->pline.filter[u].id) HGOTO_DONE(1) /* Check filter flags */ - if(cparam1->pline.filter[u].flags < cparam2->pline.filter[u].flags) + if (cparam1->pline.filter[u].flags < cparam2->pline.filter[u].flags) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].flags > cparam2->pline.filter[u].flags) + else if (cparam1->pline.filter[u].flags > cparam2->pline.filter[u].flags) HGOTO_DONE(1) /* Don't worry about comparing the filter names right now... */ @@ -193,41 +182,42 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) */ #ifdef QAK /* Check filter name */ -HDfprintf(stderr, "%s: Check 1.0\n", "H5HF_cmp_cparam_test"); -HDfprintf(stderr, "%s: cparam1->pline.filter[%Zu].name = %s\n", "H5HF_cmp_cparam_test", u, (cparam1->pline.filter[u].name ? cparam1->pline.filter[u].name : "")); -HDfprintf(stderr, "%s: cparam2->pline.filter[%Zu].name = %s\n", "H5HF_cmp_cparam_test", u, (cparam2->pline.filter[u].name ? cparam2->pline.filter[u].name : "")); - if(!cparam1->pline.filter[u].name && cparam2->pline.filter[u].name) + HDfprintf(stderr, "%s: Check 1.0\n", "H5HF_cmp_cparam_test"); + HDfprintf(stderr, "%s: cparam1->pline.filter[%Zu].name = %s\n", "H5HF_cmp_cparam_test", u, + (cparam1->pline.filter[u].name ? cparam1->pline.filter[u].name : "")); + HDfprintf(stderr, "%s: cparam2->pline.filter[%Zu].name = %s\n", "H5HF_cmp_cparam_test", u, + (cparam2->pline.filter[u].name ? cparam2->pline.filter[u].name : "")); + if (!cparam1->pline.filter[u].name && cparam2->pline.filter[u].name) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].name && !cparam2->pline.filter[u].name) + else if (cparam1->pline.filter[u].name && !cparam2->pline.filter[u].name) HGOTO_DONE(1) - else if(cparam1->pline.filter[u].name && cparam2->pline.filter[u].name) { - if((ret_value = HDstrcmp(cparam1->pline.filter[u].name, cparam2->pline.filter[u].name))) + else if (cparam1->pline.filter[u].name && cparam2->pline.filter[u].name) { + if ((ret_value = HDstrcmp(cparam1->pline.filter[u].name, cparam2->pline.filter[u].name))) HGOTO_DONE(ret_value) } /* end if */ -#endif /* QAK */ +#endif /* QAK */ /* Check # of filter parameters */ - if(cparam1->pline.filter[u].cd_nelmts < cparam2->pline.filter[u].cd_nelmts) + if (cparam1->pline.filter[u].cd_nelmts < cparam2->pline.filter[u].cd_nelmts) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].cd_nelmts > cparam2->pline.filter[u].cd_nelmts) + else if (cparam1->pline.filter[u].cd_nelmts > cparam2->pline.filter[u].cd_nelmts) HGOTO_DONE(1) /* Check filter parameters */ - for(v = 0; v < cparam1->pline.filter[u].cd_nelmts; v++) { - if(cparam1->pline.filter[u].cd_values[v] < cparam2->pline.filter[u].cd_values[v]) + for (v = 0; v < cparam1->pline.filter[u].cd_nelmts; v++) { + if (cparam1->pline.filter[u].cd_values[v] < cparam2->pline.filter[u].cd_values[v]) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].cd_values[v] > cparam2->pline.filter[u].cd_values[v]) + else if (cparam1->pline.filter[u].cd_values[v] > cparam2->pline.filter[u].cd_values[v]) HGOTO_DONE(1) } /* end for */ } /* end for */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_cmp_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_max_root_rows * @@ -245,7 +235,7 @@ done: unsigned H5HF_get_max_root_rows(const H5HF_t *fh) { - unsigned ret_value = 0; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -258,7 +248,6 @@ H5HF_get_max_root_rows(const H5HF_t *fh) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_max_root_rows() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_dtable_width_test * @@ -276,7 +265,7 @@ H5HF_get_max_root_rows(const H5HF_t *fh) unsigned H5HF_get_dtable_width_test(const H5HF_t *fh) { - unsigned ret_value = 0; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -289,7 +278,6 @@ H5HF_get_dtable_width_test(const H5HF_t *fh) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_dtable_width_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_dtable_max_drows_test * @@ -307,7 +295,7 @@ H5HF_get_dtable_width_test(const H5HF_t *fh) unsigned H5HF_get_dtable_max_drows_test(const H5HF_t *fh) { - unsigned ret_value = 0; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -320,7 +308,6 @@ H5HF_get_dtable_max_drows_test(const H5HF_t *fh) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_dtable_max_drows_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_iblock_max_drows_test * @@ -342,7 +329,7 @@ H5HF_get_dtable_max_drows_test(const H5HF_t *fh) unsigned H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos) { - unsigned ret_value = 0; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -351,13 +338,11 @@ H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos) HDassert(pos); /* Return max. # of direct blocks in this indirect block row */ - ret_value = pos + (fh->hdr->man_dtable.max_direct_bits - - fh->hdr->man_dtable.first_row_bits) + 1; + ret_value = pos + (fh->hdr->man_dtable.max_direct_bits - fh->hdr->man_dtable.first_row_bits) + 1; FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_iblock_max_drows_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_dblock_size_test * @@ -375,7 +360,7 @@ H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos) hsize_t H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -388,7 +373,6 @@ H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_dblock_size_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_dblock_free_test * @@ -407,7 +391,7 @@ H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row) hsize_t H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -420,7 +404,6 @@ H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_dblock_free_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_id_off_test * @@ -438,7 +421,7 @@ H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row) herr_t H5HF_get_id_off_test(const H5HF_t *fh, const void *_id, hsize_t *obj_off) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -455,7 +438,6 @@ H5HF_get_id_off_test(const H5HF_t *fh, const void *_id, hsize_t *obj_off) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_id_off_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_id_type_test * @@ -472,7 +454,7 @@ H5HF_get_id_off_test(const H5HF_t *fh, const void *_id, hsize_t *obj_off) herr_t H5HF_get_id_type_test(const void *_id, unsigned char *obj_type) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -486,7 +468,6 @@ H5HF_get_id_type_test(const void *_id, unsigned char *obj_type) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_id_type_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_tiny_info_test * @@ -501,8 +482,7 @@ H5HF_get_id_type_test(const void *_id, unsigned char *obj_type) *------------------------------------------------------------------------- */ herr_t -H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, - hbool_t *len_extended) +H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, hbool_t *len_extended) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -513,13 +493,12 @@ H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, HDassert(len_extended); /* Retrieve information about tiny object's ID encoding in a heap */ - *max_len = fh->hdr->tiny_max_len; + *max_len = fh->hdr->tiny_max_len; *len_extended = fh->hdr->tiny_len_extended; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_tiny_info_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_huge_info_test * @@ -544,10 +523,9 @@ H5HF_get_huge_info_test(const H5HF_t *fh, hsize_t *next_id, hbool_t *ids_direct) HDassert(ids_direct); /* Retrieve information about tiny object's ID encoding in a heap */ - if(next_id) + if (next_id) *next_id = fh->hdr->huge_next_id; *ids_direct = fh->hdr->huge_ids_direct; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_huge_info_test() */ - diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c index 113124c..1bf255d 100644 --- a/src/H5HFtiny.c +++ b/src/H5HFtiny.c @@ -26,62 +26,52 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ /* Tiny object length information */ -#define H5HF_TINY_LEN_SHORT 16 /* Max. length able to be encoded in first heap ID byte */ -#define H5HF_TINY_MASK_SHORT 0x0F /* Mask for length in first heap ID byte */ -#define H5HF_TINY_MASK_EXT 0x0FFF /* Mask for length in two heap ID bytes */ -#define H5HF_TINY_MASK_EXT_1 0x0F00 /* Mask for length in first byte of two heap ID bytes */ -#define H5HF_TINY_MASK_EXT_2 0x00FF /* Mask for length in second byte of two heap ID bytes */ - +#define H5HF_TINY_LEN_SHORT 16 /* Max. length able to be encoded in first heap ID byte */ +#define H5HF_TINY_MASK_SHORT 0x0F /* Mask for length in first heap ID byte */ +#define H5HF_TINY_MASK_EXT 0x0FFF /* Mask for length in two heap ID bytes */ +#define H5HF_TINY_MASK_EXT_1 0x0F00 /* Mask for length in first byte of two heap ID bytes */ +#define H5HF_TINY_MASK_EXT_2 0x00FF /* Mask for length in second byte of two heap ID bytes */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data); - +static herr_t H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5HF_tiny_init * @@ -112,23 +102,22 @@ H5HF_tiny_init(H5HF_hdr_t *hdr) * extra byte, but using that byte means that the extra length byte is * unnecessary) */ - if((hdr->id_len - 1) <= H5HF_TINY_LEN_SHORT) { - hdr->tiny_max_len = hdr->id_len - 1; + if ((hdr->id_len - 1) <= H5HF_TINY_LEN_SHORT) { + hdr->tiny_max_len = hdr->id_len - 1; hdr->tiny_len_extended = FALSE; } /* end if */ - else if((hdr->id_len - 1) == (H5HF_TINY_LEN_SHORT + 1)) { - hdr->tiny_max_len = H5HF_TINY_LEN_SHORT; + else if ((hdr->id_len - 1) == (H5HF_TINY_LEN_SHORT + 1)) { + hdr->tiny_max_len = H5HF_TINY_LEN_SHORT; hdr->tiny_len_extended = FALSE; } /* end if */ else { - hdr->tiny_max_len = hdr->id_len - 2; + hdr->tiny_max_len = hdr->id_len - 2; hdr->tiny_len_extended = TRUE; } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_tiny_init() */ - /*------------------------------------------------------------------------- * Function: H5HF_tiny_insert * @@ -145,13 +134,13 @@ H5HF_tiny_init(H5HF_hdr_t *hdr) herr_t H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) { - uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ - size_t enc_obj_size; /* Encoded object size */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ + size_t enc_obj_size; /* Encoded object size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT #ifdef QAK -HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); + HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); #endif /* QAK */ /* @@ -167,13 +156,12 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); enc_obj_size = obj_size - 1; /* Encode object into ID */ - if(!hdr->tiny_len_extended) { - *id++ = (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY | - (enc_obj_size & H5HF_TINY_MASK_SHORT)); + if (!hdr->tiny_len_extended) { + *id++ = (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY | (enc_obj_size & H5HF_TINY_MASK_SHORT)); } /* end if */ else { - *id++ = (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY | - ((enc_obj_size & H5HF_TINY_MASK_EXT_1) >> 8)); + *id++ = + (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY | ((enc_obj_size & H5HF_TINY_MASK_EXT_1) >> 8)); *id++ = enc_obj_size & H5HF_TINY_MASK_EXT_2; } /* end else */ @@ -185,14 +173,13 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); hdr->tiny_nobjs++; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_tiny_insert() */ - /*------------------------------------------------------------------------- * Function: H5HF_tiny_get_obj_len * @@ -209,7 +196,7 @@ done: herr_t H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) { - size_t enc_obj_size; /* Encoded object size */ + size_t enc_obj_size; /* Encoded object size */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -221,13 +208,13 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) HDassert(obj_len_p); /* Check if 'tiny' object ID is in extended form, and retrieve encoded size */ - if(!hdr->tiny_len_extended) + if (!hdr->tiny_len_extended) enc_obj_size = *id & H5HF_TINY_MASK_SHORT; else /* (performed in this odd way to avoid compiler bug on tg-login3 with * gcc 3.2.2 - QAK) */ - enc_obj_size = (size_t)*(id + 1) | ((size_t)(*id & H5HF_TINY_MASK_EXT_1) << 8); + enc_obj_size = (size_t) * (id + 1) | ((size_t)(*id & H5HF_TINY_MASK_EXT_1) << 8); /* Set the object's length */ *obj_len_p = enc_obj_size + 1; @@ -235,7 +222,6 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_tiny_get_obj_len() */ - /*------------------------------------------------------------------------- * Function: H5HF_tiny_op_real * @@ -250,11 +236,10 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) *------------------------------------------------------------------------- */ static herr_t -H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, - void *op_data) +H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data) { - size_t enc_obj_size; /* Encoded object size */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t enc_obj_size; /* Encoded object size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -270,24 +255,24 @@ H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, ret_value = H5HF_tiny_get_obj_len(hdr, id, &enc_obj_size); /* Advance past flag byte(s) */ - if(!hdr->tiny_len_extended) + if (!hdr->tiny_len_extended) id++; else { /* (performed in two steps to avoid compiler bug on tg-login3 with * gcc 3.2.2 - QAK) */ - id++; id++; + id++; + id++; } /* Call the user's 'op' callback */ - if(op(id, enc_obj_size, op_data) < 0) + if (op(id, enc_obj_size, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_tiny_op_real() */ - /*------------------------------------------------------------------------- * Function: H5HF_tiny_read * @@ -304,7 +289,7 @@ done: herr_t H5HF_tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -316,14 +301,13 @@ H5HF_tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) HDassert(obj); /* Call the internal 'op' routine */ - if(H5HF_tiny_op_real(hdr, id, H5HF_op_read, obj) < 0) + if (H5HF_tiny_op_real(hdr, id, H5HF_op_read, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_tiny_read() */ - /*------------------------------------------------------------------------- * Function: H5HF_tiny_op * @@ -338,10 +322,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, - void *op_data) +H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -353,14 +336,13 @@ H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, HDassert(op); /* Call the internal 'op' routine routine */ - if(H5HF_tiny_op_real(hdr, id, op, op_data) < 0) + if (H5HF_tiny_op_real(hdr, id, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_tiny_op() */ - /*------------------------------------------------------------------------- * Function: H5HF_tiny_remove * @@ -377,8 +359,8 @@ done: herr_t H5HF_tiny_remove(H5HF_hdr_t *hdr, const uint8_t *id) { - size_t enc_obj_size; /* Encoded object size */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t enc_obj_size; /* Encoded object size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -397,7 +379,7 @@ H5HF_tiny_remove(H5HF_hdr_t *hdr, const uint8_t *id) hdr->tiny_nobjs--; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF_hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: diff --git a/src/H5HG.c b/src/H5HG.c index 8177dc3..ddc7be2 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -39,19 +39,17 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ - +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HGpkg.h" /* Global heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HGpkg.h" /* Global heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -60,30 +58,27 @@ /* * The maximum number of links allowed to a global heap object. */ -#define H5HG_MAXLINK 65535 +#define H5HG_MAXLINK 65535 /* * The maximum number of indices allowed in a global heap object. */ -#define H5HG_MAXIDX 65535 - +#define H5HG_MAXIDX 65535 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static haddr_t H5HG__create(H5F_t *f, size_t size); -static size_t H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr); +static size_t H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr); /*********************/ /* Package Variables */ @@ -101,18 +96,14 @@ H5FL_SEQ_DEFINE(H5HG_obj_t); /* Declare a PQ free list to manage heap chunks */ H5FL_BLK_DEFINE(gheap_chunk); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HG__create * @@ -135,41 +126,41 @@ H5FL_BLK_DEFINE(gheap_chunk); static haddr_t H5HG__create(H5F_t *f, size_t size) { - H5HG_heap_t *heap = NULL; - uint8_t *p = NULL; - haddr_t addr = HADDR_UNDEF; - size_t n; - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5HG_heap_t *heap = NULL; + uint8_t * p = NULL; + haddr_t addr = HADDR_UNDEF; + size_t n; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__GLOBALHEAP_TAG) /* Check args */ HDassert(f); - if(size < H5HG_MINSIZE) + if (size < H5HG_MINSIZE) size = H5HG_MINSIZE; size = H5HG_ALIGN(size); /* Create it */ H5_CHECK_OVERFLOW(size, size_t, hsize_t); - if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, (hsize_t)size))) + if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, (hsize_t)size))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file space for global heap") - if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) + if (NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") - heap->addr = addr; - heap->size = size; + heap->addr = addr; + heap->size = size; heap->shared = H5F_SHARED(f); - if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, size))) + if (NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") HDmemset(heap->chunk, 0, size); heap->nalloc = H5HG_NOBJS(f, size); - heap->nused = 1; /* account for index 0, which is used for the free object */ - if(NULL == (heap->obj = H5FL_SEQ_MALLOC(H5HG_obj_t, heap->nalloc))) + heap->nused = 1; /* account for index 0, which is used for the free object */ + if (NULL == (heap->obj = H5FL_SEQ_MALLOC(H5HG_obj_t, heap->nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") /* Initialize the header */ H5MM_memcpy(heap->chunk, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC); - p = heap->chunk + H5_SIZEOF_MAGIC; + p = heap->chunk + H5_SIZEOF_MAGIC; *p++ = H5HG_VERSION; *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ @@ -183,7 +174,7 @@ H5HG__create(H5F_t *f, size_t size) */ n = (size_t)H5HG_ALIGN(p - heap->chunk) - (size_t)(p - heap->chunk); #ifdef OLD_WAY -/* Don't bother zeroing out the rest of the info in the heap -QAK */ + /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset(p, 0, n); #endif /* OLD_WAY */ p += n; @@ -193,45 +184,46 @@ H5HG__create(H5F_t *f, size_t size) HDassert(H5HG_ISALIGNED(heap->obj[0].size)); heap->obj[0].nrefs = 0; heap->obj[0].begin = p; - UINT16ENCODE(p, 0); /*object ID*/ - UINT16ENCODE(p, 0); /*reference count*/ + UINT16ENCODE(p, 0); /*object ID*/ + UINT16ENCODE(p, 0); /*reference count*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); #ifdef OLD_WAY -/* Don't bother zeroing out the rest of the info in the heap -QAK */ - HDmemset (p, 0, (size_t)((heap->chunk+heap->size) - p)); + /* Don't bother zeroing out the rest of the info in the heap -QAK */ + HDmemset(p, 0, (size_t)((heap->chunk + heap->size) - p)); #endif /* OLD_WAY */ /* Add this heap to the beginning of the CWFS list */ - if(H5F_cwfs_add(f, heap) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to add global heap collection to file's CWFS") + if (H5F_cwfs_add(f, heap) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, + "unable to add global heap collection to file's CWFS") /* Add the heap to the cache */ - if(H5AC_insert_entry(f, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to cache global heap collection") ret_value = addr; done: /* Cleanup on error */ - if(!H5F_addr_defined(ret_value)) { - if(H5F_addr_defined(addr)) { + if (!H5F_addr_defined(ret_value)) { + if (H5F_addr_defined(addr)) { /* Release the space on disk */ - if(H5MF_xfree(f, H5FD_MEM_GHEAP, addr, (hsize_t)size) < 0) + if (H5MF_xfree(f, H5FD_MEM_GHEAP, addr, (hsize_t)size) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free global heap") /* Check if the heap object was allocated */ - if(heap) + if (heap) /* Destroy the heap object */ - if(H5HG__free(heap) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy global heap collection") + if (H5HG__free(heap) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy global heap collection") } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value); } /* H5HG__create() */ - /*------------------------------------------------------------------------- * Function: H5HG__protect * @@ -247,8 +239,8 @@ done: H5HG_heap_t * H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags) { - H5HG_heap_t *heap; /* Global heap */ - H5HG_heap_t *ret_value = NULL; /* Return value */ + H5HG_heap_t *heap; /* Global heap */ + H5HG_heap_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -260,7 +252,7 @@ H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Lock the heap into memory */ - if(NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, H5AC_GHEAP, addr, f, flags))) + if (NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, H5AC_GHEAP, addr, f, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect global heap") /* Set the heap's address */ @@ -273,7 +265,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HG__protect() */ - /*------------------------------------------------------------------------- * Function: H5HG__alloc * @@ -295,36 +286,36 @@ done: static size_t H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) { - size_t idx; - uint8_t *p; - size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); - size_t ret_value = 0; /* Return value */ + size_t idx; + uint8_t *p; + size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(heap); - HDassert(heap->obj[0].size>=need); + HDassert(heap->obj[0].size >= need); HDassert(heap_flags_ptr); /* * Find an ID for the new object. ID zero is reserved for the free space * object. */ - if(heap->nused <= H5HG_MAXIDX) + if (heap->nused <= H5HG_MAXIDX) idx = heap->nused++; else { - for(idx = 1; idx < heap->nused; idx++) - if(NULL == heap->obj[idx].begin) + for (idx = 1; idx < heap->nused; idx++) + if (NULL == heap->obj[idx].begin) break; } /* end else */ HDassert(idx < heap->nused); /* Check if we need more room to store heap objects */ - if(idx >= heap->nalloc) { - size_t new_alloc; /* New allocation number */ - H5HG_obj_t *new_obj; /* New array of object descriptions */ + if (idx >= heap->nalloc) { + size_t new_alloc; /* New allocation number */ + H5HG_obj_t *new_obj; /* New array of object descriptions */ /* Determine the new number of objects to index */ /* nalloc is *not* guaranteed to be a power of 2! - NAF 10/26/09 */ @@ -332,7 +323,7 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) HDassert(idx < new_alloc); /* Reallocate array of objects */ - if(NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) + if (NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, 0, "memory allocation failed") /* Clear newly allocated space */ @@ -340,29 +331,29 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) /* Update heap information */ heap->nalloc = new_alloc; - heap->obj = new_obj; + heap->obj = new_obj; HDassert(heap->nalloc > heap->nused); } /* end if */ /* Initialize the new object */ heap->obj[idx].nrefs = 0; - heap->obj[idx].size = size; + heap->obj[idx].size = size; heap->obj[idx].begin = heap->obj[0].begin; - p = heap->obj[idx].begin; + p = heap->obj[idx].begin; UINT16ENCODE(p, idx); UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, size); + H5F_ENCODE_LENGTH(f, p, size); /* Fix the free space object */ - if(need == heap->obj[0].size) { + if (need == heap->obj[0].size) { /* * All free space has been exhausted from this collection. */ - heap->obj[0].size = 0; + heap->obj[0].size = 0; heap->obj[0].begin = NULL; } /* end if */ - else if(heap->obj[0].size-need >= H5HG_SIZEOF_OBJHDR (f)) { + else if (heap->obj[0].size - need >= H5HG_SIZEOF_OBJHDR(f)) { /* * Some free space remains and it's larger than a heap object header, * so write the new free heap object header to the heap. @@ -370,10 +361,10 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) heap->obj[0].size -= need; heap->obj[0].begin += need; p = heap->obj[0].begin; - UINT16ENCODE(p, 0); /*id*/ - UINT16ENCODE(p, 0); /*nrefs*/ - UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); + UINT16ENCODE(p, 0); /*id*/ + UINT16ENCODE(p, 0); /*nrefs*/ + UINT32ENCODE(p, 0); /*reserved*/ + H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); HDassert(H5HG_ISALIGNED(heap->obj[0].size)); } /* end else-if */ else { @@ -396,7 +387,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5HG__alloc() */ - /*------------------------------------------------------------------------- * Function: H5HG_extend * @@ -417,13 +407,13 @@ done: herr_t H5HG_extend(H5F_t *f, haddr_t addr, size_t need) { - H5HG_heap_t *heap = NULL; /* Pointer to heap to extend */ - unsigned heap_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting heap */ - size_t old_size; /* Previous size of the heap's chunk */ - uint8_t *new_chunk; /* Pointer to new chunk information */ - uint8_t *p; /* Pointer to raw heap info */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_heap_t *heap = NULL; /* Pointer to heap to extend */ + unsigned heap_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting heap */ + size_t old_size; /* Previous size of the heap's chunk */ + uint8_t * new_chunk; /* Pointer to new chunk information */ + uint8_t * p; /* Pointer to raw heap info */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -432,11 +422,11 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) HDassert(H5F_addr_defined(addr)); /* Protect the heap */ - if(NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") /* Re-allocate the heap information in memory */ - if(NULL == (new_chunk = H5FL_BLK_REALLOC(gheap_chunk, heap->chunk, (heap->size + need)))) + if (NULL == (new_chunk = H5FL_BLK_REALLOC(gheap_chunk, heap->chunk, (heap->size + need)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "new heap allocation failed") HDmemset(new_chunk + heap->size, 0, need); @@ -449,8 +439,8 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) H5F_ENCODE_LENGTH(f, p, heap->size); /* Move the pointers to the existing objects to their new locations */ - for(u = 0; u < heap->nused; u++) - if(heap->obj[u].begin) + for (u = 0; u < heap->nused; u++) + if (heap->obj[u].begin) heap->obj[u].begin = new_chunk + (heap->obj[u].begin - heap->chunk); /* Update the heap chunk pointer now */ @@ -458,30 +448,29 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) /* Update the free space information for the heap */ heap->obj[0].size += need; - if(heap->obj[0].begin == NULL) - heap->obj[0].begin = heap->chunk+old_size; + if (heap->obj[0].begin == NULL) + heap->obj[0].begin = heap->chunk + old_size; p = heap->obj[0].begin; - UINT16ENCODE(p, 0); /*id*/ - UINT16ENCODE(p, 0); /*nrefs*/ - UINT32ENCODE(p, 0); /*reserved*/ + UINT16ENCODE(p, 0); /*id*/ + UINT16ENCODE(p, 0); /*nrefs*/ + UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); HDassert(H5HG_ISALIGNED(heap->obj[0].size)); /* Resize the heap in the cache */ - if(H5AC_resize_entry(heap, heap->size) < 0) + if (H5AC_resize_entry(heap, heap->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize global heap in cache") /* Mark the heap as dirty */ heap_flags |= H5AC__DIRTIED_FLAG; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG_extend() */ - /*------------------------------------------------------------------------- * Function: H5HG_insert * @@ -505,14 +494,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj/*out*/) +H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj /*out*/) { - size_t need; /*total space needed for object */ - size_t idx; - haddr_t addr; /* Address of heap to add object within */ - H5HG_heap_t *heap = NULL; - unsigned heap_flags = H5AC__NO_FLAGS_SET; - herr_t ret_value = SUCCEED; /* Return value */ + size_t need; /*total space needed for object */ + size_t idx; + haddr_t addr; /* Address of heap to add object within */ + H5HG_heap_t *heap = NULL; + unsigned heap_flags = H5AC__NO_FLAGS_SET; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL) @@ -521,7 +510,7 @@ H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj/*out*/) HDassert(0 == size || obj); HDassert(hobj); - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") /* Find a large enough collection on the CWFS list */ @@ -529,51 +518,50 @@ H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj/*out*/) /* Look for a heap in the file's CWFS that has enough space for the object */ addr = HADDR_UNDEF; - if(H5F_cwfs_find_free_heap(f, need, &addr) < 0) + if (H5F_cwfs_find_free_heap(f, need, &addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "error trying to locate heap") /* * If we didn't find any collection with enough free space then allocate a * new collection large enough for the message plus the collection header. */ - if(!H5F_addr_defined(addr)) { + if (!H5F_addr_defined(addr)) { addr = H5HG__create(f, need + H5HG_SIZEOF_HDR(f)); - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection") + if (!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection") } /* end if */ HDassert(H5F_addr_defined(addr)); - if(NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") /* Split the free space to make room for the new object */ - if(0 == (idx = H5HG__alloc(f, heap, size, &heap_flags))) + if (0 == (idx = H5HG__alloc(f, heap, size, &heap_flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate global heap object") /* Copy data into the heap */ - if(size > 0) { + if (size > 0) { H5MM_memcpy(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f), obj, size); #ifdef OLD_WAY -/* Don't bother zeroing out the rest of the info in the heap -QAK */ + /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f) + size, 0, need - (H5HG_SIZEOF_OBJHDR(f) + size)); #endif /* OLD_WAY */ - } /* end if */ + } /* end if */ heap_flags |= H5AC__DIRTIED_FLAG; /* Return value */ hobj->addr = heap->addr; - hobj->idx = idx; + hobj->idx = idx; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap.") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5HG_insert() */ - /*------------------------------------------------------------------------- * Function: H5HG_read * @@ -592,13 +580,13 @@ done: *------------------------------------------------------------------------- */ void * -H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) +H5HG_read(H5F_t *f, H5HG_t *hobj, void *object /*out*/, size_t *buf_size) { - H5HG_heap_t *heap = NULL; /* Pointer to global heap object */ - size_t size; /* Size of the heap object */ - uint8_t *p; /* Pointer to object in heap buffer */ - void *orig_object = object; /* Keep a copy of the original object pointer */ - void *ret_value = NULL; /* Return value */ + H5HG_heap_t *heap = NULL; /* Pointer to global heap object */ + size_t size; /* Size of the heap object */ + uint8_t * p; /* Pointer to object in heap buffer */ + void * orig_object = object; /* Keep a copy of the original object pointer */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, NULL) @@ -607,7 +595,7 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) HDassert(hobj); /* Load the heap */ - if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect global heap") if (hobj->idx >= heap->nused && H5HG_trap("out of bounds")) @@ -616,10 +604,10 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) HDassert(hobj->idx < heap->nused); HDassert(heap->obj[hobj->idx].begin); size = heap->obj[hobj->idx].size; - p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR(f); + p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR(f); /* Allocate a buffer for the object read in, if the user didn't give one */ - if(!object && NULL == (object = H5MM_malloc(size))) + if (!object && NULL == (object = H5MM_malloc(size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(object, p, size); @@ -627,29 +615,28 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) * Advance the heap in the CWFS list. We might have done this already * with the H5AC_protect(), but it won't hurt to do it twice. */ - if(heap->obj[0].begin) { - if(H5F_cwfs_advance_heap(f, heap, FALSE) < 0) + if (heap->obj[0].begin) { + if (H5F_cwfs_advance_heap(f, heap, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMODIFY, NULL, "can't adjust file's CWFS") } /* end if */ /* If the caller would like to know the heap object's size, set that */ - if(buf_size) + if (buf_size) *buf_size = size; /* Set return value */ ret_value = object; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release object header") - if(NULL == ret_value && NULL == orig_object && object) + if (NULL == ret_value && NULL == orig_object && object) H5MM_free(object); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_read() */ - /*------------------------------------------------------------------------- * Function: H5HG_link * @@ -671,28 +658,28 @@ done: int H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust) { - H5HG_heap_t *heap = NULL; - unsigned heap_flags = H5AC__NO_FLAGS_SET; - int ret_value = -1; /* Return value */ + H5HG_heap_t *heap = NULL; + unsigned heap_flags = H5AC__NO_FLAGS_SET; + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL) /* Check args */ HDassert(f); HDassert(hobj); - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") /* Load the heap */ - if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") - if(adjust != 0) { + if (adjust != 0) { HDassert(hobj->idx < heap->nused); HDassert(heap->obj[hobj->idx].begin); - if((heap->obj[hobj->idx].nrefs + adjust) < 0) + if ((heap->obj[hobj->idx].nrefs + adjust) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range") - if((heap->obj[hobj->idx].nrefs + adjust) > H5HG_MAXLINK) + if ((heap->obj[hobj->idx].nrefs + adjust) > H5HG_MAXLINK) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range") heap->obj[hobj->idx].nrefs += adjust; heap_flags |= H5AC__DIRTIED_FLAG; @@ -702,13 +689,12 @@ H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust) ret_value = heap->obj[hobj->idx].nrefs; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_link() */ - /*------------------------------------------------------------------------- * Function: H5HG_get_obj_size * @@ -725,8 +711,8 @@ done: herr_t H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size) { - H5HG_heap_t *heap = NULL; /* Pointer to global heap object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_heap_t *heap = NULL; /* Pointer to global heap object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL) @@ -736,7 +722,7 @@ H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size) HDassert(obj_size); /* Load the heap */ - if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") HDassert(hobj->idx < heap->nused); @@ -746,13 +732,12 @@ H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size) *obj_size = heap->obj[hobj->idx].size; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_get_obj_size() */ - /*------------------------------------------------------------------------- * Function: H5HG_remove * @@ -766,25 +751,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HG_remove (H5F_t *f, H5HG_t *hobj) +H5HG_remove(H5F_t *f, H5HG_t *hobj) { H5HG_heap_t *heap = NULL; - uint8_t *p = NULL, *obj_start = NULL; - size_t need; - unsigned u; - unsigned flags = H5AC__NO_FLAGS_SET;/* Whether the heap gets deleted */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * p = NULL, *obj_start = NULL; + size_t need; + unsigned u; + unsigned flags = H5AC__NO_FLAGS_SET; /* Whether the heap gets deleted */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL) /* Check args */ HDassert(f); HDassert(hobj); - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") /* Load the heap */ - if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") HDassert(hobj->idx < heap->nused); @@ -793,7 +778,7 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj) * it can happen that the entry has been removed by first rewrite. Here we simply skip the removal of * the entry and let the second rewrite happen (see HDFFV-10635). In the future, it'd be nice to handle * this situation in H5T_conv_vlen in H5Tconv.c instead of this level (HDFFV-10648). */ - if(heap->obj[hobj->idx].nrefs == 0 && heap->obj[hobj->idx].size == 0 && !heap->obj[hobj->idx].begin) + if (heap->obj[hobj->idx].nrefs == 0 && heap->obj[hobj->idx].size == 0 && !heap->obj[hobj->idx].begin) HGOTO_DONE(ret_value) obj_start = heap->obj[hobj->idx].begin; @@ -801,53 +786,53 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj) need = H5HG_ALIGN(heap->obj[hobj->idx].size) + H5HG_SIZEOF_OBJHDR(f); /* Move the new free space to the end of the heap */ - for(u = 0; u < heap->nused; u++) - if(heap->obj[u].begin > heap->obj[hobj->idx].begin) + for (u = 0; u < heap->nused; u++) + if (heap->obj[u].begin > heap->obj[hobj->idx].begin) heap->obj[u].begin -= need; - if(NULL == heap->obj[0].begin) { + if (NULL == heap->obj[0].begin) { heap->obj[0].begin = heap->chunk + (heap->size - need); - heap->obj[0].size = need; + heap->obj[0].size = need; heap->obj[0].nrefs = 0; } /* end if */ else heap->obj[0].size += need; - HDmemmove(obj_start, obj_start + need, - heap->size - (size_t)((obj_start + need) - heap->chunk)); - if(heap->obj[0].size >= H5HG_SIZEOF_OBJHDR(f)) { + HDmemmove(obj_start, obj_start + need, heap->size - (size_t)((obj_start + need) - heap->chunk)); + if (heap->obj[0].size >= H5HG_SIZEOF_OBJHDR(f)) { p = heap->obj[0].begin; UINT16ENCODE(p, 0); /*id*/ UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); + H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); } /* end if */ HDmemset(heap->obj + hobj->idx, 0, sizeof(H5HG_obj_t)); flags |= H5AC__DIRTIED_FLAG; - if((heap->obj[0].size + H5HG_SIZEOF_HDR(f)) == heap->size) { + if ((heap->obj[0].size + H5HG_SIZEOF_HDR(f)) == heap->size) { /* * The collection is empty. Remove it from the CWFS list and return it * to the file free list. */ - flags |= H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; /* Indicate that the object was deleted, for the unprotect call */ - } /* end if */ + flags |= + H5AC__DELETED_FLAG | + H5AC__FREE_FILE_SPACE_FLAG; /* Indicate that the object was deleted, for the unprotect call */ + } /* end if */ else { /* * If the heap is in the CWFS list then advance it one position. The * H5AC_protect() might have done that too, but that's okay. If the * heap isn't on the CWFS list then add it to the end. */ - if(H5F_cwfs_advance_heap(f, heap, TRUE) < 0) + if (H5F_cwfs_advance_heap(f, heap, TRUE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMODIFY, FAIL, "can't adjust file's CWFS") } /* end else */ done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, flags) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value); } /* end H5HG_remove() */ - /*------------------------------------------------------------------------- * Function: H5HG__free * @@ -863,7 +848,7 @@ done: herr_t H5HG__free(H5HG_heap_t *heap) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -871,16 +856,15 @@ H5HG__free(H5HG_heap_t *heap) HDassert(heap); /* Remove the heap from the CWFS list */ - if(H5F_cwfs_remove_heap(heap->shared, heap) < 0) + if (H5F_cwfs_remove_heap(heap->shared, heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove heap from file's CWFS") - if(heap->chunk) + if (heap->chunk) heap->chunk = H5FL_BLK_FREE(gheap_chunk, heap->chunk); - if(heap->obj) + if (heap->obj) heap->obj = H5FL_SEQ_FREE(H5HG_obj_t, heap->obj); heap = H5FL_FREE(H5HG_heap_t, heap); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HG__free() */ - diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 938c575..41c65a8 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -26,54 +26,45 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ - +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HGpkg.h" /* Global heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HGpkg.h" /* Global heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache callbacks */ static herr_t H5HG__cache_heap_get_initial_load_size(void *udata, size_t *image_len); -static herr_t H5HG__cache_heap_get_final_load_size(const void *_image, - size_t image_len, void *udata, size_t *actual_len); -static void *H5HG__cache_heap_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static herr_t H5HG__cache_heap_get_final_load_size(const void *_image, size_t image_len, void *udata, + size_t *actual_len); +static void * H5HG__cache_heap_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HG__cache_heap_image_len(const void *thing, size_t *image_len); -static herr_t H5HG__cache_heap_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5HG__cache_heap_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HG__cache_heap_free_icr(void *thing); /* Prefix deserialization */ -static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, - const H5F_t *f); - +static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f); /*********************/ /* Package Variables */ @@ -81,35 +72,31 @@ static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, /* H5HG inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_GHEAP[1] = {{ - H5AC_GHEAP_ID, /* Metadata client ID */ - "global heap", /* Metadata client name (for debugging) */ - H5FD_MEM_GHEAP, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5HG__cache_heap_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5HG__cache_heap_get_final_load_size, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5HG__cache_heap_deserialize, /* 'deserialize' callback */ - H5HG__cache_heap_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5HG__cache_heap_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5HG__cache_heap_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_GHEAP_ID, /* Metadata client ID */ + "global heap", /* Metadata client name (for debugging) */ + H5FD_MEM_GHEAP, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5HG__cache_heap_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5HG__cache_heap_get_final_load_size, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5HG__cache_heap_deserialize, /* 'deserialize' callback */ + H5HG__cache_heap_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5HG__cache_heap_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5HG__cache_heap_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HG__hdr_deserialize() * @@ -126,7 +113,7 @@ const H5AC_class_t H5AC_GHEAP[1] = {{ static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -136,12 +123,12 @@ H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f) HDassert(f); /* Magic number */ - if(HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad global heap collection signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(H5HG_VERSION != *image++) + if (H5HG_VERSION != *image++) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in global heap") /* Reserved */ @@ -155,7 +142,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_get_initial_load_size() * @@ -187,7 +173,6 @@ H5HG__cache_heap_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *imag FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HG__cache_heap_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_get_initial_load_size() * @@ -203,11 +188,11 @@ H5HG__cache_heap_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *imag *------------------------------------------------------------------------- */ static herr_t -H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *udata, size_t *actual_len) +H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *udata, + size_t *actual_len) { - H5HG_heap_t heap; /* Global heap */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_heap_t heap; /* Global heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -219,7 +204,7 @@ H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UN HDassert(image_len == H5HG_MINSIZE); /* Deserialize the heap's header */ - if(H5HG__hdr_deserialize(&heap, (const uint8_t *)image, (const H5F_t *)udata) < 0) + if (H5HG__hdr_deserialize(&heap, (const uint8_t *)image, (const H5F_t *)udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode global heap prefix") /* Set the final size for the cache image */ @@ -229,7 +214,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__cache_heap_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_deserialize * @@ -246,15 +230,14 @@ done: *------------------------------------------------------------------------- */ static void * -H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5F_t *f = (H5F_t *)_udata; /* File pointer -- obtained from user data */ - H5HG_heap_t *heap = NULL; /* New global heap */ - uint8_t *image; /* Pointer to image to decode */ - size_t max_idx = 0; /* Maximum heap object index seen */ - size_t nalloc; /* Number of objects allocated */ - void *ret_value = NULL; /* Return value */ + H5F_t * f = (H5F_t *)_udata; /* File pointer -- obtained from user data */ + H5HG_heap_t *heap = NULL; /* New global heap */ + uint8_t * image; /* Pointer to image to decode */ + size_t max_idx = 0; /* Maximum heap object index seen */ + size_t nalloc; /* Number of objects allocated */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -265,59 +248,59 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, HDassert(dirty); /* Allocate a new global heap */ - if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) + if (NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") heap->shared = H5F_SHARED(f); - if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, len))) + if (NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the image buffer into the newly allocate chunk */ H5MM_memcpy(heap->chunk, _image, len); /* Deserialize the heap's header */ - if(H5HG__hdr_deserialize(heap, (const uint8_t *)heap->chunk, f) < 0) + if (H5HG__hdr_deserialize(heap, (const uint8_t *)heap->chunk, f) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode global heap header") /* Decode each object */ - image = heap->chunk + H5HG_SIZEOF_HDR(f); + image = heap->chunk + H5HG_SIZEOF_HDR(f); nalloc = H5HG_NOBJS(f, heap->size); /* Calloc the obj array because the file format spec makes no guarantee * about the order of the objects, and unused slots must be set to zero. */ - if(NULL == (heap->obj = H5FL_SEQ_CALLOC(H5HG_obj_t, nalloc))) + if (NULL == (heap->obj = H5FL_SEQ_CALLOC(H5HG_obj_t, nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") heap->nalloc = nalloc; - while(image < (heap->chunk + heap->size)) { - if((image + H5HG_SIZEOF_OBJHDR(f)) > (heap->chunk + heap->size)) { + while (image < (heap->chunk + heap->size)) { + if ((image + H5HG_SIZEOF_OBJHDR(f)) > (heap->chunk + heap->size)) { /* * The last bit of space is too tiny for an object header, so * we assume that it's free space. */ HDassert(NULL == heap->obj[0].begin); - heap->obj[0].size = (size_t)(((const uint8_t *)heap->chunk + heap->size) - image); + heap->obj[0].size = (size_t)(((const uint8_t *)heap->chunk + heap->size) - image); heap->obj[0].begin = image; image += heap->obj[0].size; } /* end if */ else { - size_t need = 0; + size_t need = 0; unsigned idx; uint8_t *begin = image; UINT16DECODE(image, idx); /* Check if we need more room to store heap objects */ - if(idx >= heap->nalloc) { - size_t new_alloc; /* New allocation number */ - H5HG_obj_t *new_obj; /* New array of object descriptions */ + if (idx >= heap->nalloc) { + size_t new_alloc; /* New allocation number */ + H5HG_obj_t *new_obj; /* New array of object descriptions */ /* Determine the new number of objects to index */ new_alloc = MAX(heap->nalloc * 2, (idx + 1)); HDassert(idx < new_alloc); /* Reallocate array of objects */ - if(NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) + if (NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear newly allocated space */ @@ -325,7 +308,7 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, /* Update heap information */ heap->nalloc = new_alloc; - heap->obj = new_obj; + heap->obj = new_obj; HDassert(heap->nalloc > heap->nused); } /* end if */ @@ -342,9 +325,9 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, * is the free space object whose size is never padded and * already includes the object header. */ - if(idx > 0) { + if (idx > 0) { need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(heap->obj[idx].size); - if(idx > max_idx) + if (idx > max_idx) max_idx = idx; } /* end if */ else @@ -352,14 +335,14 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, image = begin + need; } /* end else */ - } /* end while */ + } /* end while */ /* Sanity checks */ HDassert(image == heap->chunk + heap->size); HDassert(H5HG_ISALIGNED(heap->obj[0].size)); /* Set the next index value to use */ - if(max_idx > 0) + if (max_idx > 0) heap->nused = max_idx + 1; else heap->nused = 1; @@ -368,20 +351,19 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, HDassert(max_idx < heap->nused); /* Add the new heap to the CWFS list for the file */ - if(H5F_cwfs_add(f, heap) < 0) + if (H5F_cwfs_add(f, heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "unable to add global heap collection to file's CWFS") ret_value = heap; done: - if(!ret_value && heap) - if(H5HG__free(heap) < 0) + if (!ret_value && heap) + if (H5HG__free(heap) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__cache_heap_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_image_len * @@ -415,7 +397,6 @@ H5HG__cache_heap_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HG__cache_heap_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_serialize * @@ -433,8 +414,7 @@ H5HG__cache_heap_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, size_t len, - void *_thing) +H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, size_t len, void *_thing) { H5HG_heap_t *heap = (H5HG_heap_t *)_thing; @@ -454,7 +434,6 @@ H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, si FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HG__cache_heap_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_free_icr * @@ -475,8 +454,8 @@ H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, si static herr_t H5HG__cache_heap_free_icr(void *_thing) { - H5HG_heap_t *heap = (H5HG_heap_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_heap_t *heap = (H5HG_heap_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -486,10 +465,9 @@ H5HG__cache_heap_free_icr(void *_thing) HDassert(heap->cache_info.type == H5AC_GHEAP); /* Destroy global heap collection */ - if(H5HG__free(heap) < 0) + if (H5HG__free(heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy global heap collection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__cache_heap_free_icr() */ - diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c index a5e5363..7fc3347 100644 --- a/src/H5HGdbg.c +++ b/src/H5HGdbg.c @@ -21,54 +21,45 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ - +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HGpkg.h" /* Global heaps */ -#include "H5Iprivate.h" /* ID Functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HGpkg.h" /* Global heaps */ +#include "H5Iprivate.h" /* ID Functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HG_debug * @@ -85,87 +76,76 @@ herr_t H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) { - unsigned u, nused, maxobj; - unsigned j, k; - H5HG_heap_t *h = NULL; - uint8_t *p = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u, nused, maxobj; + unsigned j, k; + H5HG_heap_t *h = NULL; + uint8_t * p = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); - HDassert(H5F_addr_defined (addr)); + HDassert(H5F_addr_defined(addr)); HDassert(stream); HDassert(indent >= 0); HDassert(fwidth >= 0); - if(NULL == (h = H5HG__protect(f, addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (h = H5HG__protect(f, addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap collection"); HDfprintf(stream, "%*sGlobal Heap Collection...\n", indent, ""); - HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, - "Dirty:", - (int)(h->cache_info.is_dirty)); + HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Dirty:", (int)(h->cache_info.is_dirty)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Total collection size in file:", - (unsigned long)(h->size)); + "Total collection size in file:", (unsigned long)(h->size)); - for(u = 1, nused = 0, maxobj = 0; u < h->nused; u++) - if(h->obj[u].begin) { - nused++; - if (u>maxobj) + for (u = 1, nused = 0, maxobj = 0; u < h->nused; u++) + if (h->obj[u].begin) { + nused++; + if (u > maxobj) maxobj = u; - } - HDfprintf(stream, "%*s%-*s %u/%lu/", indent, "", fwidth, - "Objects defined/allocated/max:", - nused, - (unsigned long)h->nalloc); - if(nused) + } + HDfprintf(stream, "%*s%-*s %u/%lu/", indent, "", fwidth, "Objects defined/allocated/max:", nused, + (unsigned long)h->nalloc); + if (nused) HDfprintf(stream, "%u\n", maxobj); else HDfprintf(stream, "NA\n"); - HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Free space:", - (unsigned long)(h->obj[0].size)); + HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Free space:", (unsigned long)(h->obj[0].size)); - for(u = 1; u < h->nused; u++) - if(h->obj[u].begin) { + for (u = 1; u < h->nused; u++) + if (h->obj[u].begin) { char buf[64]; - HDsnprintf(buf, sizeof(buf), "Object %u", u); - HDfprintf(stream, "%*s%s\n", indent, "", buf); - HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MIN(fwidth - 3, 0), - "Obffset in block:", - (unsigned long)(h->obj[u].begin - h->chunk)); - HDfprintf(stream, "%*s%-*s %d\n", indent + 3, "", MIN(fwidth - 3, 0), - "Reference count:", - h->obj[u].nrefs); - HDfprintf(stream, "%*s%-*s %lu/%lu\n", indent + 3, "", - MIN(fwidth - 3, 0), - "Size of object body:", - (unsigned long)(h->obj[u].size), - (unsigned long)H5HG_ALIGN(h->obj[u].size)); - p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR(f); - for(j = 0; j < h->obj[u].size; j += 16) { - HDfprintf(stream, "%*s%04u: ", indent + 6, "", j); - for(k = 0; k < 16; k++) { - if(8 == k) + HDsnprintf(buf, sizeof(buf), "Object %u", u); + HDfprintf(stream, "%*s%s\n", indent, "", buf); + HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MIN(fwidth - 3, 0), + "Obffset in block:", (unsigned long)(h->obj[u].begin - h->chunk)); + HDfprintf(stream, "%*s%-*s %d\n", indent + 3, "", MIN(fwidth - 3, 0), + "Reference count:", h->obj[u].nrefs); + HDfprintf(stream, "%*s%-*s %lu/%lu\n", indent + 3, "", MIN(fwidth - 3, 0), + "Size of object body:", (unsigned long)(h->obj[u].size), + (unsigned long)H5HG_ALIGN(h->obj[u].size)); + p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR(f); + for (j = 0; j < h->obj[u].size; j += 16) { + HDfprintf(stream, "%*s%04u: ", indent + 6, "", j); + for (k = 0; k < 16; k++) { + if (8 == k) HDfprintf(stream, " "); - if(j + k < h->obj[u].size) - HDfprintf(stream, "%02x ", p[j + k]); - else - HDfputs(" ", stream); - } - for(k = 0; k < 16 && j + k < h->obj[u].size; k++) { - if(8 == k) + if (j + k < h->obj[u].size) + HDfprintf(stream, "%02x ", p[j + k]); + else + HDfputs(" ", stream); + } + for (k = 0; k < 16 && j + k < h->obj[u].size; k++) { + if (8 == k) HDfprintf(stream, " "); - HDfputc(p[j + k]>' ' && p[j + k] <= '~' ? p[j + k] : '.', stream); - } - HDfprintf(stream, "\n"); - } - } + HDfputc(p[j + k] > ' ' && p[j + k] <= '~' ? p[j + k] : '.', stream); + } + HDfprintf(stream, "\n"); + } + } done: if (h && H5AC_unprotect(f, H5AC_GHEAP, addr, h, H5AC__NO_FLAGS_SET) < 0) @@ -173,4 +153,3 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5HG_debug() */ - diff --git a/src/H5HGmodule.h b/src/H5HGmodule.h index 1c68206..3698d02 100644 --- a/src/H5HGmodule.h +++ b/src/H5HGmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5HG_MODULE -#define H5_MY_PKG H5HG -#define H5_MY_PKG_ERR H5E_HEAP -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5HG +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO #endif /* _H5HGmodule_H */ - diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h index 3119de4..84a4b03 100644 --- a/src/H5HGpkg.h +++ b/src/H5HGpkg.h @@ -30,9 +30,8 @@ #include "H5HGprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free lists */ /*****************************/ /* Package Private Variables */ @@ -47,7 +46,6 @@ H5FL_SEQ_EXTERN(H5HG_obj_t); /* Declare extern the PQ free list to manage heap chunks */ H5FL_BLK_EXTERN(gheap_chunk); - /**************************/ /* Package Private Macros */ /**************************/ @@ -55,7 +53,7 @@ H5FL_BLK_EXTERN(gheap_chunk); /* * Global heap collection version. */ -#define H5HG_VERSION 1 +#define H5HG_VERSION 1 /* * All global heap collections are at least this big. This allows us to read @@ -63,7 +61,7 @@ H5FL_BLK_EXTERN(gheap_chunk); * bytes of header to figure out the size. If the heap is larger than this * then a second read gets the rest after we've decoded the header. */ -#define H5HG_MINSIZE 4096 +#define H5HG_MINSIZE 4096 /* * Pad all global heap messages to a multiple of eight bytes so we can load @@ -71,29 +69,29 @@ H5FL_BLK_EXTERN(gheap_chunk); * be sufficient for machines that have alignment constraints because our * largest data type is eight bytes. */ -#define H5HG_ALIGNMENT 8 -#define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/H5HG_ALIGNMENT)) -#define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X)) +#define H5HG_ALIGNMENT 8 +#define H5HG_ALIGN(X) (H5HG_ALIGNMENT * (((X) + H5HG_ALIGNMENT - 1) / H5HG_ALIGNMENT)) +#define H5HG_ISALIGNED(X) ((X) == H5HG_ALIGN(X)) /* * The size of the collection header, always a multiple of the alignment so * that the stuff that follows the header is aligned. */ -#define H5HG_SIZEOF_HDR(f) \ - (size_t)H5HG_ALIGN(4 + /*magic number */ \ - 1 + /*version number */ \ - 3 + /*reserved */ \ - H5F_SIZEOF_SIZE(f)) /*collection size */ +#define H5HG_SIZEOF_HDR(f) \ + (size_t) H5HG_ALIGN(4 + /*magic number */ \ + 1 + /*version number */ \ + 3 + /*reserved */ \ + H5F_SIZEOF_SIZE(f)) /*collection size */ /* * The overhead associated with each object in the heap, always a multiple of * the alignment so that the stuff that follows the header is aligned. */ -#define H5HG_SIZEOF_OBJHDR(f) \ - (size_t)H5HG_ALIGN(2 + /*object id number */ \ - 2 + /*reference count */ \ - 4 + /*reserved */ \ - H5F_SIZEOF_SIZE(f)) /*object data size */ +#define H5HG_SIZEOF_OBJHDR(f) \ + (size_t) H5HG_ALIGN(2 + /*object id number */ \ + 2 + /*reference count */ \ + 4 + /*reserved */ \ + H5F_SIZEOF_SIZE(f)) /*object data size */ /* * The initial guess for the number of messages in a collection. We assume @@ -102,36 +100,34 @@ H5FL_BLK_EXTERN(gheap_chunk); * some overhead and each message has some overhead. The `+2' accounts for * rounding and for the free space object. */ -#define H5HG_NOBJS(f,z) ((((z)-H5HG_SIZEOF_HDR(f))/ \ - H5HG_SIZEOF_OBJHDR(f)+2)) - +#define H5HG_NOBJS(f, z) ((((z)-H5HG_SIZEOF_HDR(f)) / H5HG_SIZEOF_OBJHDR(f) + 2)) /****************************/ /* Package Private Typedefs */ /****************************/ typedef struct H5HG_obj_t { - int nrefs; /* reference count */ - size_t size; /* total size of object */ - uint8_t *begin; /* ptr to object into heap->chunk */ + int nrefs; /* reference count */ + size_t size; /* total size of object */ + uint8_t *begin; /* ptr to object into heap->chunk */ } H5HG_obj_t; /* Forward declarations for fields */ struct H5F_shared_t; struct H5HG_heap_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - haddr_t addr; /*collection address */ - size_t size; /*total size of collection */ - uint8_t *chunk; /*the collection, incl. header */ - size_t nalloc; /*numb object slots allocated */ - size_t nused; /*number of slots used */ - /* If this value is >65535 then all indices */ - /* have been used at some time and the */ - /* correct new index should be searched for */ - struct H5F_shared_t *shared; /* shared file */ - H5HG_obj_t *obj; /*array of object descriptions */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + haddr_t addr; /*collection address */ + size_t size; /*total size of collection */ + uint8_t *chunk; /*the collection, incl. header */ + size_t nalloc; /*numb object slots allocated */ + size_t nused; /*number of slots used */ + /* If this value is >65535 then all indices */ + /* have been used at some time and the */ + /* correct new index should be searched for */ + struct H5F_shared_t *shared; /* shared file */ + H5HG_obj_t * obj; /*array of object descriptions */ }; /******************************/ @@ -141,4 +137,3 @@ H5_DLL herr_t H5HG__free(H5HG_heap_t *heap); H5_DLL H5HG_heap_t *H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags); #endif /* _H5HGpkg_H */ - diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h index 760c0bf..b60b6f1 100644 --- a/src/H5HGprivate.h +++ b/src/H5HGprivate.h @@ -19,45 +19,43 @@ #define _H5HGprivate_H /* Private headers needed by this file. */ -#include "H5Fprivate.h" /* File access */ +#include "H5Fprivate.h" /* File access */ /* Information to locate object in global heap */ typedef struct H5HG_t { - haddr_t addr; /*address of collection */ - size_t idx; /*object ID within collection */ + haddr_t addr; /*address of collection */ + size_t idx; /*object ID within collection */ } H5HG_t; /* Typedef for heap in memory (defined in H5HGpkg.h) */ typedef struct H5HG_heap_t H5HG_heap_t; - /* * Limit global heap collections to the some reasonable size. This is * fairly arbitrary, but needs to be small enough that no more than H5HG_MAXIDX * objects will be allocated from a single heap. */ -#define H5HG_MAXSIZE 65536 +#define H5HG_MAXSIZE 65536 /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5HG_MODULE -#define H5HG_ADDR(H) ((H)->addr) -#define H5HG_SIZE(H) ((H)->size) -#define H5HG_FREE_SIZE(H) ((H)->obj[0].size) +#define H5HG_ADDR(H) ((H)->addr) +#define H5HG_SIZE(H) ((H)->size) +#define H5HG_FREE_SIZE(H) ((H)->obj[0].size) #else /* H5HG_MODULE */ -#define H5HG_ADDR(H) (H5HG_get_addr(H)) -#define H5HG_SIZE(H) (H5HG_get_size(H)) -#define H5HG_FREE_SIZE(H) (H5HG_get_free_size(H)) +#define H5HG_ADDR(H) (H5HG_get_addr(H)) +#define H5HG_SIZE(H) (H5HG_get_size(H)) +#define H5HG_FREE_SIZE(H) (H5HG_get_free_size(H)) #endif /* H5HG_MODULE */ /* Size of encoded global heap ID */ /* (size of file address + 32-bit integer) */ -#define H5HG_HEAP_ID_SIZE(F) ((size_t)H5F_SIZEOF_ADDR(F) + H5_SIZEOF_UINT32_T) - +#define H5HG_HEAP_ID_SIZE(F) ((size_t)H5F_SIZEOF_ADDR(F) + H5_SIZEOF_UINT32_T) /* Main global heap routines */ -H5_DLL herr_t H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj/*out*/); -H5_DLL void *H5HG_read(H5F_t *f, H5HG_t *hobj, void *object, size_t *buf_size/*out*/); -H5_DLL int H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust); +H5_DLL herr_t H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj /*out*/); +H5_DLL void * H5HG_read(H5F_t *f, H5HG_t *hobj, void *object, size_t *buf_size /*out*/); +H5_DLL int H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust); H5_DLL herr_t H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size); H5_DLL herr_t H5HG_remove(H5F_t *f, H5HG_t *hobj); @@ -66,14 +64,12 @@ H5_DLL herr_t H5HG_extend(H5F_t *f, haddr_t addr, size_t need); /* Query routines */ H5_DLL haddr_t H5HG_get_addr(const H5HG_heap_t *h); -H5_DLL size_t H5HG_get_size(const H5HG_heap_t *h); -H5_DLL size_t H5HG_get_free_size(const H5HG_heap_t *h); +H5_DLL size_t H5HG_get_size(const H5HG_heap_t *h); +H5_DLL size_t H5HG_get_free_size(const H5HG_heap_t *h); /* Debugging functions */ -H5_DLL herr_t H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth); +H5_DLL herr_t H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); bool H5HG_trap(const char *); #endif /* _H5HGprivate_H */ - diff --git a/src/H5HGquery.c b/src/H5HGquery.c index 35abc2e..d9ad81a 100644 --- a/src/H5HGquery.c +++ b/src/H5HGquery.c @@ -23,53 +23,43 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ - +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HGpkg.h" /* Global heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HGpkg.h" /* Global heaps */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HG_get_addr * @@ -93,7 +83,6 @@ H5HG_get_addr(const H5HG_heap_t *heap) FUNC_LEAVE_NOAPI(heap->addr) } /* H5HG_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5HG_get_size * @@ -117,7 +106,6 @@ H5HG_get_size(const H5HG_heap_t *heap) FUNC_LEAVE_NOAPI(heap->size) } /* H5HG_get_size() */ - /*------------------------------------------------------------------------- * Function: H5HG_get_free_size * @@ -140,4 +128,3 @@ H5HG_get_free_size(const H5HG_heap_t *heap) FUNC_LEAVE_NOAPI(heap->obj[0].size) } /* H5HG_get_free_size() */ - diff --git a/src/H5HGtrap.c b/src/H5HGtrap.c index 6b52007..981b95b 100644 --- a/src/H5HGtrap.c +++ b/src/H5HGtrap.c @@ -14,14 +14,14 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /* * Headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HGpkg.h" /* Global heaps */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HGpkg.h" /* Global heaps */ /* H5HG_trap() is an instrumentation point for the global heap. * The H5HG_trap() result modifies the global heap's treatment of @@ -35,7 +35,7 @@ * their own H5HG_trap() implementation that overrides the one in the library. * * H5HG_trap() returns `true` if the caller should generate an error-stack - * entry and return an error code to the caller's caller. + * entry and return an error code to the caller's caller. * * H5HG_trap() returns `false` if the caller should blithely carry on; * if NDEBUG is not #defined, then the caller will ordinarily abort the diff --git a/src/H5HL.c b/src/H5HL.c index f290294..c5fa65a 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -27,44 +27,38 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ -#define H5HL_MIN_HEAP 128 /* Minimum size to reduce heap buffer to */ - +#define H5HL_MIN_HEAP 128 /* Minimum size to reduce heap buffer to */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static H5HL_free_t *H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl); -static herr_t H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap); -static herr_t H5HL__dirty(H5HL_t *heap); - +static herr_t H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap); +static herr_t H5HL__dirty(H5HL_t *heap); /*********************/ /* Package Variables */ @@ -79,18 +73,14 @@ H5FL_DEFINE(H5HL_free_t); /* Declare a PQ free list to manage the heap chunk information */ H5FL_BLK_DEFINE(lheap_chunk); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HL_create * @@ -108,86 +98,83 @@ H5FL_BLK_DEFINE(lheap_chunk); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p/*out*/)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p /*out*/)) - H5HL_t *heap = NULL; /* Heap created */ - H5HL_prfx_t *prfx = NULL; /* Heap prefix */ - hsize_t total_size = 0; /* Total heap size on disk */ + H5HL_t * heap = NULL; /* Heap created */ + H5HL_prfx_t *prfx = NULL; /* Heap prefix */ + hsize_t total_size = 0; /* Total heap size on disk */ /* check arguments */ HDassert(f); HDassert(addr_p); /* Adjust size hint as necessary */ - if(size_hint && size_hint < H5HL_SIZEOF_FREE(f)) + if (size_hint && size_hint < H5HL_SIZEOF_FREE(f)) size_hint = H5HL_SIZEOF_FREE(f); size_hint = H5HL_ALIGN(size_hint); /* Allocate new heap structure */ - if(NULL == (heap = H5HL__new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f)))) + if (NULL == (heap = H5HL__new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f)))) H5E_THROW(H5E_CANTALLOC, "can't allocate new heap struct"); /* Allocate file space */ total_size = heap->prfx_size + size_hint; - if(HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, total_size))) + if (HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, total_size))) H5E_THROW(H5E_CANTALLOC, "unable to allocate file memory"); /* Initialize info */ heap->single_cache_obj = TRUE; - heap->dblk_addr = heap->prfx_addr + (hsize_t)heap->prfx_size; - heap->dblk_size = size_hint; - if(size_hint) - if(NULL == (heap->dblk_image = H5FL_BLK_CALLOC(lheap_chunk, size_hint))) + heap->dblk_addr = heap->prfx_addr + (hsize_t)heap->prfx_size; + heap->dblk_size = size_hint; + if (size_hint) + if (NULL == (heap->dblk_image = H5FL_BLK_CALLOC(lheap_chunk, size_hint))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* free list */ - if(size_hint) { - if(NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t))) + if (size_hint) { + if (NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); heap->freelist->offset = 0; - heap->freelist->size = size_hint; + heap->freelist->size = size_hint; heap->freelist->prev = heap->freelist->next = NULL; - heap->free_block = 0; + heap->free_block = 0; } /* end if */ else { - heap->freelist = NULL; + heap->freelist = NULL; heap->free_block = H5HL_FREE_NULL; } /* end else */ /* Allocate the heap prefix */ - if(NULL == (prfx = H5HL__prfx_new(heap))) + if (NULL == (prfx = H5HL__prfx_new(heap))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* Add to cache */ - if(FAIL == H5AC_insert_entry(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) + if (FAIL == H5AC_insert_entry(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) H5E_THROW(H5E_CANTINIT, "unable to cache local heap prefix"); /* Set address to return */ *addr_p = heap->prfx_addr; -CATCH - if(ret_value < 0) { + CATCH + if (ret_value < 0) { *addr_p = HADDR_UNDEF; - if(prfx) { - if(FAIL == H5HL__prfx_dest(prfx)) + if (prfx) { + if (FAIL == H5HL__prfx_dest(prfx)) H5E_THROW(H5E_CANTFREE, "unable to destroy local heap prefix"); } /* end if */ else { - if(heap) { - if(H5F_addr_defined(heap->prfx_addr)) - if(FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, heap->prfx_addr, total_size)) + if (heap) { + if (H5F_addr_defined(heap->prfx_addr)) + if (FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, heap->prfx_addr, total_size)) H5E_THROW(H5E_CANTFREE, "can't release heap data?"); - if(FAIL == H5HL__dest(heap)) + if (FAIL == H5HL__dest(heap)) H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ END_FUNC(PRIV) /* end H5HL_create() */ - /*------------------------------------------------------------------------- * Function: H5HL__minimize_heap_space * @@ -201,11 +188,9 @@ END_FUNC(PRIV) /* end H5HL_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) - size_t new_heap_size = heap->dblk_size; /* New size of heap */ + size_t new_heap_size = heap->dblk_size; /* New size of heap */ /* check args */ HDassert(f); @@ -216,14 +201,14 @@ H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) * eliminating free blocks at the tail of the buffer before flushing the * buffer out. */ - if(heap->freelist) { - H5HL_free_t *tmp_fl; - H5HL_free_t *last_fl = NULL; + if (heap->freelist) { + H5HL_free_t *tmp_fl; + H5HL_free_t *last_fl = NULL; /* Search for a free block at the end of the buffer */ - for(tmp_fl = heap->freelist; tmp_fl; tmp_fl = tmp_fl->next) + for (tmp_fl = heap->freelist; tmp_fl; tmp_fl = tmp_fl->next) /* Check if the end of this free block is at the end of the buffer */ - if(tmp_fl->offset + tmp_fl->size == heap->dblk_size) { + if (tmp_fl->offset + tmp_fl->size == heap->dblk_size) { last_fl = tmp_fl; break; } /* end if */ @@ -232,28 +217,28 @@ H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) * Found free block at the end of the buffer, decide what to do * about it */ - if(last_fl) { + if (last_fl) { /* * If the last free block's size is more than half the memory * buffer size (and the memory buffer is larger than the * minimum size), reduce or eliminate it. */ - if(last_fl->size >= (heap->dblk_size / 2) && heap->dblk_size > H5HL_MIN_HEAP) { + if (last_fl->size >= (heap->dblk_size / 2) && heap->dblk_size > H5HL_MIN_HEAP) { /* * Reduce size of buffer until it's too small or would * eliminate the free block */ - while(new_heap_size > H5HL_MIN_HEAP && - new_heap_size >= (last_fl->offset + H5HL_SIZEOF_FREE(f))) + while (new_heap_size > H5HL_MIN_HEAP && + new_heap_size >= (last_fl->offset + H5HL_SIZEOF_FREE(f))) new_heap_size /= 2; /* * Check if reducing the memory buffer size would * eliminate the free block */ - if(new_heap_size < (last_fl->offset + H5HL_SIZEOF_FREE(f))) { + if (new_heap_size < (last_fl->offset + H5HL_SIZEOF_FREE(f))) { /* Check if this is the only block on the free list */ - if(last_fl->prev == NULL && last_fl->next == NULL) { + if (last_fl->prev == NULL && last_fl->next == NULL) { /* Double the new memory size */ new_heap_size *= 2; @@ -272,7 +257,7 @@ H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) /* Eliminate the free block from the list */ last_fl = H5HL__remove_free(heap, last_fl); } /* end else */ - } /* end if */ + } /* end if */ else { /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); @@ -280,33 +265,32 @@ H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); HDassert(last_fl->size == H5HL_ALIGN(last_fl->size)); } /* end else */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ /* * If the heap grew smaller than disk storage then move the * data segment of the heap to another contiguous block of disk * storage. */ - if(new_heap_size != heap->dblk_size) { + if (new_heap_size != heap->dblk_size) { HDassert(new_heap_size < heap->dblk_size); /* Resize the memory buffer */ - if(NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, new_heap_size))) + if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, new_heap_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* Reallocate data block in file */ - if(FAIL == H5HL__dblk_realloc(f, heap, new_heap_size)) + if (FAIL == H5HL__dblk_realloc(f, heap, new_heap_size)) H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); } /* end if */ -CATCH + CATCH /* No special processing on errors */ END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ - /*------------------------------------------------------------------------- * Function: H5HL_protect * @@ -320,16 +304,14 @@ END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -H5HL_t *, NULL, NULL, -H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) +BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) - H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ - H5HL_dblk_t *dblk = NULL; /* Local heap data block */ - H5HL_t *heap = NULL; /* Heap data structure */ - unsigned prfx_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting prefix entry */ - unsigned dblk_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting data block entry */ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ + H5HL_dblk_t * dblk = NULL; /* Local heap data block */ + H5HL_t * heap = NULL; /* Heap data structure */ + unsigned prfx_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting prefix entry */ + unsigned dblk_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting data block entry */ /* check arguments */ HDassert(f); @@ -341,11 +323,11 @@ H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) /* Construct the user data for protect callback */ prfx_udata.sizeof_size = H5F_SIZEOF_SIZE(f); prfx_udata.sizeof_addr = H5F_SIZEOF_ADDR(f); - prfx_udata.prfx_addr = addr; + prfx_udata.prfx_addr = addr; prfx_udata.sizeof_prfx = H5HL_SIZEOF_HDR(f); /* Protect the local heap prefix */ - if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, flags))) + if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); /* Get the pointer to the heap */ @@ -353,20 +335,21 @@ H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) /* Check if the heap is already pinned in memory */ /* (for re-entrant situation) */ - if(heap->prots == 0) { + if (heap->prots == 0) { /* Check if heap has separate data block */ - if(heap->single_cache_obj) + if (heap->single_cache_obj) /* Set the flag for pinning the prefix when unprotecting it */ prfx_cache_flags |= H5AC__PIN_ENTRY_FLAG; else { /* Protect the local heap data block */ - if(NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, flags))) + if (NULL == + (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block"); /* Set the flag for pinning the data block when unprotecting it */ dblk_cache_flags |= H5AC__PIN_ENTRY_FLAG; } /* end if */ - } /* end if */ + } /* end if */ /* Increment # of times heap is protected */ heap->prots++; @@ -374,18 +357,17 @@ H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) /* Set return value */ ret_value = heap; -CATCH + CATCH /* Release the prefix from the cache, now pinned */ - if(prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, prfx_cache_flags) < 0) + if (prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, prfx_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); /* Release the data block from the cache, now pinned */ - if(dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, dblk_cache_flags) < 0) + if (dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, dblk_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block"); END_FUNC(PRIV) /* end H5HL_protect() */ - /*------------------------------------------------------------------------- * Function: H5HL_offset_into * @@ -400,21 +382,19 @@ END_FUNC(PRIV) /* end H5HL_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -void *, NULL, NULL, -H5HL_offset_into(const H5HL_t *heap, size_t offset)) +BEGIN_FUNC(PRIV, ERR, void *, NULL, NULL, H5HL_offset_into(const H5HL_t *heap, size_t offset)) /* Sanity check */ HDassert(heap); - if(offset >= heap->dblk_size) - H5E_THROW(H5E_CANTGET, "unable to offset into local heap data block"); + if (offset >= heap->dblk_size) + H5E_THROW(H5E_CANTGET, "unable to offset into local heap data block"); ret_value = heap->dblk_image + offset; -CATCH + CATCH /* No special processing on errors */ END_FUNC(PRIV) /* end H5HL_offset_into() */ - + /*------------------------------------------------------------------------- * Function: H5HL_unprotect * @@ -427,9 +407,7 @@ END_FUNC(PRIV) /* end H5HL_offset_into() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_unprotect(H5HL_t *heap)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) /* check arguments */ HDassert(heap); @@ -438,11 +416,11 @@ H5HL_unprotect(H5HL_t *heap)) heap->prots--; /* Check for last unprotection of heap */ - if(heap->prots == 0) { + if (heap->prots == 0) { /* Check for separate heap data block */ - if(heap->single_cache_obj) { + if (heap->single_cache_obj) { /* Mark local heap prefix as evictable again */ - if(FAIL == H5AC_unpin_entry(heap->prfx)) + if (FAIL == H5AC_unpin_entry(heap->prfx)) H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); } /* end if */ else { @@ -451,17 +429,16 @@ H5HL_unprotect(H5HL_t *heap)) /* Mark local heap data block as evictable again */ /* (data block still pins prefix) */ - if(FAIL == H5AC_unpin_entry(heap->dblk)) + if (FAIL == H5AC_unpin_entry(heap->dblk)) H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); } /* end else */ - } /* end if */ + } /* end if */ -CATCH + CATCH /* No special processing on errors */ END_FUNC(PRIV) /* end H5HL_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5HL__remove_free * @@ -475,16 +452,14 @@ END_FUNC(PRIV) /* end H5HL_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -H5HL_free_t *, NULL, -, -H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) +BEGIN_FUNC(STATIC, NOERR, H5HL_free_t *, NULL, -, H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) - if(fl->prev) + if (fl->prev) fl->prev->next = fl->next; - if(fl->next) + if (fl->next) fl->next->prev = fl->prev; - if(!fl->prev) + if (!fl->prev) heap->freelist = fl->next; /* H5FL_FREE always returns NULL so we can't check for errors */ @@ -492,7 +467,6 @@ H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) END_FUNC(STATIC) /* end H5HL__remove_free() */ - /*------------------------------------------------------------------------- * Function: H5HL__dirty * @@ -505,33 +479,30 @@ END_FUNC(STATIC) /* end H5HL__remove_free() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dirty(H5HL_t *heap)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__dirty(H5HL_t *heap)) /* check arguments */ HDassert(heap); HDassert(heap->prfx); /* Mark heap data block as dirty, if there is one */ - if(!heap->single_cache_obj) { + if (!heap->single_cache_obj) { /* Sanity check */ HDassert(heap->dblk); - if(FAIL == H5AC_mark_entry_dirty(heap->dblk)) + if (FAIL == H5AC_mark_entry_dirty(heap->dblk)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap data block as dirty"); } /* end if */ /* Mark heap prefix as dirty */ - if(FAIL == H5AC_mark_entry_dirty(heap->prfx)) + if (FAIL == H5AC_mark_entry_dirty(heap->prfx)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap prefix as dirty"); -CATCH + CATCH /* No special processing on errors */ END_FUNC(STATIC) /* end H5HL__dirty() */ - /*------------------------------------------------------------------------- * Function: H5HL_insert * @@ -545,14 +516,13 @@ END_FUNC(STATIC) /* end H5HL__dirty() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -size_t, UFAIL, UFAIL, -H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) +BEGIN_FUNC(PRIV, ERR, size_t, UFAIL, UFAIL, + H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) - H5HL_free_t *fl = NULL, *last_fl = NULL; - size_t offset = 0; - size_t need_size; - hbool_t found; + H5HL_free_t *fl = NULL, *last_fl = NULL; + size_t offset = 0; + size_t need_size; + hbool_t found; /* check arguments */ HDassert(f); @@ -566,7 +536,7 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ - if(FAIL == H5HL__dirty(heap)) + if (FAIL == H5HL__dirty(heap)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); /* @@ -580,8 +550,8 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) * Look for a free slot large enough for this object and which would * leave zero or at least H5G_SIZEOF_FREE bytes left over. */ - for(fl = heap->freelist, found = FALSE; fl; fl = fl->next) { - if(fl->size > need_size && fl->size - need_size >= H5HL_SIZEOF_FREE(f)) { + for (fl = heap->freelist, found = FALSE; fl; fl = fl->next) { + if (fl->size > need_size && fl->size - need_size >= H5HL_SIZEOF_FREE(f)) { /* a big enough free block was found */ offset = fl->offset; fl->offset += need_size; @@ -590,13 +560,15 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) HDassert(fl->size == H5HL_ALIGN(fl->size)); found = TRUE; break; - } else if(fl->size == need_size) { + } + else if (fl->size == need_size) { /* free block of exact size found */ offset = fl->offset; - fl = H5HL__remove_free(heap, fl); - found = TRUE; + fl = H5HL__remove_free(heap, fl); + found = TRUE; break; - } else if(!last_fl || last_fl->offset < fl->offset) { + } + else if (!last_fl || last_fl->offset < fl->offset) { /* track free space that's closest to end of heap */ last_fl = fl; } @@ -608,11 +580,11 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) * can extend that free chunk. Otherwise we'll have to make another * free chunk. If the heap must expand, we double its size. */ - if(found == FALSE) { - size_t need_more; /* How much more space we need */ - size_t new_dblk_size; /* Final size of space allocated for heap data block */ - size_t old_dblk_size; /* Previous size of space allocated for heap data block */ - htri_t was_extended; /* Whether the local heap's data segment on disk was extended */ + if (found == FALSE) { + size_t need_more; /* How much more space we need */ + size_t new_dblk_size; /* Final size of space allocated for heap data block */ + size_t old_dblk_size; /* Previous size of space allocated for heap data block */ + htri_t was_extended; /* Whether the local heap's data segment on disk was extended */ /* At least double the heap's size, making certain there's enough room * for the new object */ @@ -624,8 +596,8 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) * space requested to just the amount of space needed. (Generally * speaking, this only occurs when the heap is small -QAK) */ - if(!(last_fl && last_fl->offset + last_fl->size == heap->dblk_size) - && (need_more < (need_size + H5HL_SIZEOF_FREE(f)))) + if (!(last_fl && last_fl->offset + last_fl->size == heap->dblk_size) && + (need_more < (need_size + H5HL_SIZEOF_FREE(f)))) need_more = need_size; new_dblk_size = heap->dblk_size + need_more; @@ -635,35 +607,36 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) H5_CHECK_OVERFLOW(new_dblk_size, size_t, hsize_t); /* Extend current heap if possible */ - was_extended = H5MF_try_extend(f, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more); - if(FAIL == was_extended) + was_extended = H5MF_try_extend(f, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), + (hsize_t)need_more); + if (FAIL == was_extended) H5E_THROW(H5E_CANTEXTEND, "error trying to extend heap"); /* Check if we extended the heap data block in file */ - if(was_extended == TRUE) { + if (was_extended == TRUE) { /* Check for prefix & data block contiguous */ - if(heap->single_cache_obj) { + if (heap->single_cache_obj) { /* Resize prefix+data block */ - if(FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_dblk_size))) + if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_dblk_size))) H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache"); } /* end if */ else { /* Resize 'standalone' data block */ - if(FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_dblk_size)) + if (FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_dblk_size)) H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache"); } /* end else */ /* Note new size */ heap->dblk_size = new_dblk_size; - } /* end if */ + } /* end if */ else { /* ...if we can't, allocate a new chunk & release the old */ /* Reallocate data block in file */ - if(FAIL == H5HL__dblk_realloc(f, heap, new_dblk_size)) + if (FAIL == H5HL__dblk_realloc(f, heap, new_dblk_size)) H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); } /* end if */ /* If the last free list in the heap is at the end of the heap, extend it */ - if(last_fl && last_fl->offset + last_fl->size == old_dblk_size) { + if (last_fl && last_fl->offset + last_fl->size == old_dblk_size) { /* * Increase the size of the last free block. */ @@ -677,7 +650,7 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) #ifdef H5HL_DEBUG if (H5DEBUG(HL) && last_fl->size) { HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes at line %d\n", - (unsigned long)(last_fl->size), __LINE__); + (unsigned long)(last_fl->size), __LINE__); } #endif last_fl = H5HL__remove_free(heap, last_fl); @@ -689,22 +662,23 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) * take some space out of it right away. */ offset = old_dblk_size; - if(need_more - need_size >= H5HL_SIZEOF_FREE(f)) { - if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) + if (need_more - need_size >= H5HL_SIZEOF_FREE(f)) { + if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); fl->offset = old_dblk_size + need_size; - fl->size = need_more - need_size; + fl->size = need_more - need_size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); fl->prev = NULL; fl->next = heap->freelist; - if(heap->freelist) + if (heap->freelist) heap->freelist->prev = fl; heap->freelist = fl; #ifdef H5HL_DEBUG - } else if (H5DEBUG(HL) && need_more > need_size) { + } + else if (H5DEBUG(HL) && need_more > need_size) { HDfprintf(H5DEBUG(HL), "H5HL_insert: lost %lu bytes at line %d\n", - (unsigned long)(need_more - need_size), __LINE__); + (unsigned long)(need_more - need_size), __LINE__); #endif } } /* end else */ @@ -712,11 +686,10 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) #ifdef H5HL_DEBUG if (H5DEBUG(HL)) { HDfprintf(H5DEBUG(HL), "H5HL: resize mem buf from %lu to %lu bytes\n", - (unsigned long)(old_dblk_size), - (unsigned long)(old_dblk_size + need_more)); + (unsigned long)(old_dblk_size), (unsigned long)(old_dblk_size + need_more)); } #endif - if(NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size))) + if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* Clear new section so junk doesn't appear in the file */ @@ -730,12 +703,11 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) /* Set return value */ ret_value = offset; -CATCH + CATCH /* No special processing on errors */ END_FUNC(PRIV) /* H5HL_insert() */ - /*------------------------------------------------------------------------- * Function: H5HL_remove * @@ -759,9 +731,7 @@ END_FUNC(PRIV) /* H5HL_insert() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) H5HL_free_t *fl = NULL; @@ -782,7 +752,7 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ - if(FAIL == H5HL__dirty(heap)) + if (FAIL == H5HL__dirty(heap)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); /* @@ -791,58 +761,55 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) * that all three chunks can be combined into one. */ fl = heap->freelist; - while(fl) { + while (fl) { H5HL_free_t *fl2 = NULL; - if((offset + size) == fl->offset) { + if ((offset + size) == fl->offset) { fl->offset = offset; fl->size += size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); fl2 = fl->next; - while(fl2) { - if((fl2->offset + fl2->size) == fl->offset) { + while (fl2) { + if ((fl2->offset + fl2->size) == fl->offset) { fl->offset = fl2->offset; fl->size += fl2->size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); fl2 = H5HL__remove_free(heap, fl2); - if(((fl->offset + fl->size) == heap->dblk_size) && - ((2 * fl->size) > heap->dblk_size)) { - if(FAIL == H5HL__minimize_heap_space(f, heap)) + if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { + if (FAIL == H5HL__minimize_heap_space(f, heap)) H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); } H5_LEAVE(SUCCEED); } fl2 = fl2->next; } - if(((fl->offset + fl->size) == heap->dblk_size) && - ((2 * fl->size) > heap->dblk_size)) { - if(FAIL == H5HL__minimize_heap_space(f, heap)) + if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { + if (FAIL == H5HL__minimize_heap_space(f, heap)) H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); } H5_LEAVE(SUCCEED); - } else if(fl->offset + fl->size == offset) { + } + else if (fl->offset + fl->size == offset) { fl->size += size; fl2 = fl->next; HDassert(fl->size == H5HL_ALIGN(fl->size)); - while(fl2) { - if(fl->offset + fl->size == fl2->offset) { + while (fl2) { + if (fl->offset + fl->size == fl2->offset) { fl->size += fl2->size; HDassert(fl->size == H5HL_ALIGN(fl->size)); fl2 = H5HL__remove_free(heap, fl2); - if(((fl->offset + fl->size) == heap->dblk_size) && - ((2 * fl->size) > heap->dblk_size)) { - if(FAIL == H5HL__minimize_heap_space(f, heap)) + if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { + if (FAIL == H5HL__minimize_heap_space(f, heap)) H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); } /* end if */ H5_LEAVE(SUCCEED); } /* end if */ fl2 = fl2->next; } /* end while */ - if(((fl->offset + fl->size) == heap->dblk_size) && - ((2 * fl->size) > heap->dblk_size)) { - if(FAIL == H5HL__minimize_heap_space(f, heap)) + if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { + if (FAIL == H5HL__minimize_heap_space(f, heap)) H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); } /* end if */ H5_LEAVE(SUCCEED); @@ -855,10 +822,10 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) * hold the free list data. If not, the freed chunk is forever * lost. */ - if(size < H5HL_SIZEOF_FREE(f)) { + if (size < H5HL_SIZEOF_FREE(f)) { #ifdef H5HL_DEBUG - if(H5DEBUG(HL)) { - HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long) size); + if (H5DEBUG(HL)) { + HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long)size); } #endif H5_LEAVE(SUCCEED); @@ -867,28 +834,27 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) /* * Add an entry to the free list. */ - if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) + if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); fl->offset = offset; - fl->size = size; + fl->size = size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); fl->prev = NULL; fl->next = heap->freelist; - if(heap->freelist) + if (heap->freelist) heap->freelist->prev = fl; heap->freelist = fl; - if(((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) - if(FAIL == H5HL__minimize_heap_space(f, heap)) + if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) + if (FAIL == H5HL__minimize_heap_space(f, heap)) H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); -CATCH + CATCH /* No special processing on exit */ END_FUNC(PRIV) /* end H5HL_remove() */ - /*------------------------------------------------------------------------- * Function: H5HL_delete * @@ -901,15 +867,13 @@ END_FUNC(PRIV) /* end H5HL_remove() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_delete(H5F_t *f, haddr_t addr)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr)) - H5HL_t *heap = NULL; /* Local heap to delete */ - H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ - H5HL_dblk_t *dblk = NULL; /* Local heap data block */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ + H5HL_t * heap = NULL; /* Local heap to delete */ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ + H5HL_dblk_t * dblk = NULL; /* Local heap data block */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ /* check arguments */ HDassert(f); @@ -918,37 +882,38 @@ H5HL_delete(H5F_t *f, haddr_t addr)) /* Construct the user data for protect callback */ prfx_udata.sizeof_size = H5F_SIZEOF_SIZE(f); prfx_udata.sizeof_addr = H5F_SIZEOF_ADDR(f); - prfx_udata.prfx_addr = addr; + prfx_udata.prfx_addr = addr; prfx_udata.sizeof_prfx = H5HL_SIZEOF_HDR(f); /* Protect the local heap prefix */ - if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__NO_FLAGS_SET))) + if (NULL == + (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__NO_FLAGS_SET))) H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; /* Check if heap has separate data block */ - if(!heap->single_cache_obj) + if (!heap->single_cache_obj) /* Protect the local heap data block */ - if(NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, H5AC__NO_FLAGS_SET))) + if (NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, + H5AC__NO_FLAGS_SET))) H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block"); /* Set the flags for releasing the prefix and data block */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; -CATCH + CATCH /* Release the data block from the cache, now deleted */ - if(dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, cache_flags) < 0) + if (dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block"); /* Release the prefix from the cache, now deleted */ - if(prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, cache_flags) < 0) + if (prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); END_FUNC(PRIV) /* end H5HL_delete() */ - /*------------------------------------------------------------------------- * Function: H5HL_get_size * @@ -961,13 +926,11 @@ END_FUNC(PRIV) /* end H5HL_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) - H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ - H5HL_t *heap; /* Heap data structure */ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ + H5HL_t * heap; /* Heap data structure */ /* check arguments */ HDassert(f); @@ -977,11 +940,12 @@ H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) /* Construct the user data for protect callback */ prfx_udata.sizeof_size = H5F_SIZEOF_SIZE(f); prfx_udata.sizeof_addr = H5F_SIZEOF_ADDR(f); - prfx_udata.prfx_addr = addr; + prfx_udata.prfx_addr = addr; prfx_udata.sizeof_prfx = H5HL_SIZEOF_HDR(f); /* Protect the local heap prefix */ - if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == + (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); /* Get the pointer to the heap */ @@ -990,13 +954,12 @@ H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) /* Set the size to return */ *size = heap->dblk_size; -CATCH - if(prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) + CATCH + if (prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); END_FUNC(PRIV) /* end H5HL_get_size() */ - /*------------------------------------------------------------------------- * Function: H5HL_heapsize * @@ -1010,13 +973,11 @@ END_FUNC(PRIV) /* end H5HL_get_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) - H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ - H5HL_t *heap; /* Heap data structure */ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ + H5HL_t * heap; /* Heap data structure */ /* check arguments */ HDassert(f); @@ -1026,11 +987,12 @@ H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) /* Construct the user data for protect callback */ prfx_udata.sizeof_size = H5F_SIZEOF_SIZE(f); prfx_udata.sizeof_addr = H5F_SIZEOF_ADDR(f); - prfx_udata.prfx_addr = addr; + prfx_udata.prfx_addr = addr; prfx_udata.sizeof_prfx = H5HL_SIZEOF_HDR(f); /* Protect the local heap prefix */ - if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == + (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); /* Get the pointer to the heap */ @@ -1039,9 +1001,8 @@ H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) /* Accumulate the size of the local heap */ *heap_size += (hsize_t)(heap->prfx_size + heap->dblk_size); -CATCH - if(prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) + CATCH + if (prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); END_FUNC(PRIV) /* end H5HL_heapsize() */ - diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 5a7321f..711fbf1 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -26,44 +26,39 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ -#define H5HL_VERSION 0 /* Local heap collection version */ +#define H5HL_VERSION 0 /* Local heap collection version */ /* Set the local heap size to speculatively read in * (needs to be more than the local heap prefix size to work at all and * should be larger than the default local heap size to save the * extra I/O operations) */ -#define H5HL_SPEC_READ_SIZE 512 - +#define H5HL_SPEC_READ_SIZE 512 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -71,32 +66,27 @@ /* Metadata cache callbacks */ /* Local heap prefix */ static herr_t H5HL__cache_prefix_get_initial_load_size(void *udata, size_t *image_len); -static herr_t H5HL__cache_prefix_get_final_load_size(const void *_image, - size_t image_len, void *udata, size_t *actual_len); -static void *H5HL__cache_prefix_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static herr_t H5HL__cache_prefix_get_final_load_size(const void *_image, size_t image_len, void *udata, + size_t *actual_len); +static void * H5HL__cache_prefix_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HL__cache_prefix_image_len(const void *thing, size_t *image_len); -static herr_t H5HL__cache_prefix_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5HL__cache_prefix_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HL__cache_prefix_free_icr(void *thing); /* Local heap data block */ static herr_t H5HL__cache_datablock_get_initial_load_size(void *udata, size_t *image_len); -static void *H5HL__cache_datablock_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5HL__cache_datablock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HL__cache_datablock_image_len(const void *thing, size_t *image_len); -static herr_t H5HL__cache_datablock_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5HL__cache_datablock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing); static herr_t H5HL__cache_datablock_free_icr(void *thing); /* Header deserialization */ -static herr_t H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, - H5HL_cache_prfx_ud_t *udata); +static herr_t H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, H5HL_cache_prfx_ud_t *udata); /* Free list de/serialization */ static herr_t H5HL__fl_deserialize(H5HL_t *heap); -static void H5HL__fl_serialize(const H5HL_t *heap); +static void H5HL__fl_serialize(const H5HL_t *heap); /*********************/ /* Package Variables */ @@ -104,53 +94,49 @@ static void H5HL__fl_serialize(const H5HL_t *heap); /* H5HL inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_LHEAP_PRFX[1] = {{ - H5AC_LHEAP_PRFX_ID, /* Metadata client ID */ - "local heap prefix", /* Metadata client name (for debugging) */ - H5FD_MEM_LHEAP, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5HL__cache_prefix_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5HL__cache_prefix_get_final_load_size, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5HL__cache_prefix_deserialize, /* 'deserialize' callback */ - H5HL__cache_prefix_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5HL__cache_prefix_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5HL__cache_prefix_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_LHEAP_PRFX_ID, /* Metadata client ID */ + "local heap prefix", /* Metadata client name (for debugging) */ + H5FD_MEM_LHEAP, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5HL__cache_prefix_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5HL__cache_prefix_get_final_load_size, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5HL__cache_prefix_deserialize, /* 'deserialize' callback */ + H5HL__cache_prefix_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5HL__cache_prefix_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5HL__cache_prefix_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{ - H5AC_LHEAP_DBLK_ID, /* Metadata client ID */ - "local heap datablock", /* Metadata client name (for debugging) */ - H5FD_MEM_LHEAP, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5HL__cache_datablock_get_initial_load_size,/* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5HL__cache_datablock_deserialize, /* 'deserialize' callback */ - H5HL__cache_datablock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5HL__cache_datablock_serialize, /* 'serialize' callback */ - H5HL__cache_datablock_notify, /* 'notify' callback */ - H5HL__cache_datablock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_LHEAP_DBLK_ID, /* Metadata client ID */ + "local heap datablock", /* Metadata client name (for debugging) */ + H5FD_MEM_LHEAP, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5HL__cache_datablock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5HL__cache_datablock_deserialize, /* 'deserialize' callback */ + H5HL__cache_datablock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5HL__cache_datablock_serialize, /* 'serialize' callback */ + H5HL__cache_datablock_notify, /* 'notify' callback */ + H5HL__cache_datablock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HL__hdr_deserialize() * @@ -165,8 +151,7 @@ const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5HL__hdr_deserialize( H5HL_t *heap, const uint8_t *image, - H5HL_cache_prfx_ud_t *udata) +H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, H5HL_cache_prfx_ud_t *udata) { herr_t ret_value = SUCCEED; /* Return value */ @@ -178,12 +163,12 @@ H5HL__hdr_deserialize( H5HL_t *heap, const uint8_t *image, HDassert(udata); /* Check magic number */ - if(HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad local heap signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(H5HL_VERSION != *image++) + if (H5HL_VERSION != *image++) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in local heap") /* Reserved */ @@ -198,7 +183,7 @@ H5HL__hdr_deserialize( H5HL_t *heap, const uint8_t *image, /* Free list head */ H5F_DECODE_LENGTH_LEN(image, heap->free_block, udata->sizeof_size); - if(heap->free_block != H5HL_FREE_NULL && heap->free_block >= heap->dblk_size) + if (heap->free_block != H5HL_FREE_NULL && heap->free_block >= heap->dblk_size) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad heap free list") /* Heap data address */ @@ -208,7 +193,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__fl_deserialize * @@ -224,9 +208,9 @@ done: static herr_t H5HL__fl_deserialize(H5HL_t *heap) { - H5HL_free_t *fl = NULL, *tail = NULL; /* Heap free block nodes */ - hsize_t free_block; /* Offset of free block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_free_t *fl = NULL, *tail = NULL; /* Heap free block nodes */ + hsize_t free_block; /* Offset of free block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -236,50 +220,49 @@ H5HL__fl_deserialize(H5HL_t *heap) /* Build free list */ free_block = heap->free_block; - while(H5HL_FREE_NULL != free_block) { - const uint8_t *image; /* Pointer into image buffer */ + while (H5HL_FREE_NULL != free_block) { + const uint8_t *image; /* Pointer into image buffer */ /* Sanity check */ - if(free_block >= heap->dblk_size) + if (free_block >= heap->dblk_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list") /* Allocate & initialize free list node */ - if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) + if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") fl->offset = (size_t)free_block; - fl->prev = tail; - fl->next = NULL; + fl->prev = tail; + fl->next = NULL; /* Decode offset of next free block */ image = heap->dblk_image + free_block; H5F_DECODE_LENGTH_LEN(image, free_block, heap->sizeof_size); - if(0 == free_block) + if (0 == free_block) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "free block size is zero?") /* Decode length of this free block */ H5F_DECODE_LENGTH_LEN(image, fl->size, heap->sizeof_size); - if((fl->offset + fl->size) > heap->dblk_size) + if ((fl->offset + fl->size) > heap->dblk_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list") /* Append node onto list */ - if(tail) + if (tail) tail->next = fl; else heap->freelist = fl; tail = fl; - fl = NULL; + fl = NULL; } /* end while */ done: - if(ret_value < 0) - if(fl) + if (ret_value < 0) + if (fl) /* H5FL_FREE always returns NULL so we can't check for errors */ fl = H5FL_FREE(H5HL_free_t, fl); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__fl_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__fl_serialize * @@ -295,7 +278,7 @@ done: static void H5HL__fl_serialize(const H5HL_t *heap) { - H5HL_free_t *fl; /* Pointer to heap free list node */ + H5HL_free_t *fl; /* Pointer to heap free list node */ FUNC_ENTER_STATIC_NOERR @@ -303,13 +286,13 @@ H5HL__fl_serialize(const H5HL_t *heap) HDassert(heap); /* Serialize the free list into the heap data's image */ - for(fl = heap->freelist; fl; fl = fl->next) { - uint8_t *image; /* Pointer into raw data buffer */ + for (fl = heap->freelist; fl; fl = fl->next) { + uint8_t *image; /* Pointer into raw data buffer */ HDassert(fl->offset == H5HL_ALIGN(fl->offset)); image = heap->dblk_image + fl->offset; - if(fl->next) + if (fl->next) H5F_ENCODE_LENGTH_LEN(image, fl->next->offset, heap->sizeof_size) else H5F_ENCODE_LENGTH_LEN(image, H5HL_FREE_NULL, heap->sizeof_size) @@ -321,7 +304,6 @@ H5HL__fl_serialize(const H5HL_t *heap) } /* end H5HL__fl_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_get_initial_load_size() * @@ -350,7 +332,6 @@ H5HL__cache_prefix_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *im FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_get_final_load_size() * @@ -367,12 +348,12 @@ H5HL__cache_prefix_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *im */ static herr_t H5HL__cache_prefix_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *_udata, size_t *actual_len) + void *_udata, size_t *actual_len) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5HL_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ - H5HL_t heap; /* Local heap */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5HL_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ + H5HL_t heap; /* Local heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -383,16 +364,16 @@ H5HL__cache_prefix_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG HDassert(*actual_len == image_len); /* Deserialize the heap's header */ - if(H5HL__hdr_deserialize(&heap, (const uint8_t *)image, udata) < 0) + if (H5HL__hdr_deserialize(&heap, (const uint8_t *)image, udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode local heap header") /* Set the final size for the cache image */ *actual_len = heap.prfx_size; /* Check if heap block exists */ - if(heap.dblk_size) + if (heap.dblk_size) /* Check if heap data block is contiguous with header */ - if(H5F_addr_eq((heap.prfx_addr + heap.prfx_size), heap.dblk_addr)) + if (H5F_addr_eq((heap.prfx_addr + heap.prfx_size), heap.dblk_addr)) /* Note that the heap should be a single object in the cache */ *actual_len += heap.dblk_size; @@ -400,7 +381,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_deserialize * @@ -417,14 +397,14 @@ done: *------------------------------------------------------------------------- */ static void * -H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { - H5HL_t *heap = NULL; /* Local heap */ - H5HL_prfx_t *prfx = NULL; /* Heap prefix deserialized */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into decoding buffer */ - H5HL_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ - void *ret_value = NULL; /* Return value */ + H5HL_t * heap = NULL; /* Local heap */ + H5HL_prfx_t * prfx = NULL; /* Heap prefix deserialized */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into decoding buffer */ + H5HL_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -439,26 +419,26 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert(dirty); /* Allocate space in memory for the heap */ - if(NULL == (heap = H5HL__new(udata->sizeof_size, udata->sizeof_addr, udata->sizeof_prfx))) + if (NULL == (heap = H5HL__new(udata->sizeof_size, udata->sizeof_addr, udata->sizeof_prfx))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap structure"); /* Deserialize the heap's header */ - if(H5HL__hdr_deserialize(heap, (const uint8_t *)image, udata) < 0) + if (H5HL__hdr_deserialize(heap, (const uint8_t *)image, udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode local heap header") /* Allocate the heap prefix */ - if(NULL == (prfx = H5HL__prfx_new(heap))) + if (NULL == (prfx = H5HL__prfx_new(heap))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap prefix"); /* Check if heap block exists */ - if(heap->dblk_size) { + if (heap->dblk_size) { /* Check if heap data block is contiguous with header */ - if(H5F_addr_eq((heap->prfx_addr + heap->prfx_size), heap->dblk_addr)) { + if (H5F_addr_eq((heap->prfx_addr + heap->prfx_size), heap->dblk_addr)) { /* Note that the heap should be a single object in the cache */ heap->single_cache_obj = TRUE; /* Allocate space for the heap data image */ - if(NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) + if (NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") /* Set image to the start of the data block. This is necessary @@ -470,7 +450,7 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED H5MM_memcpy(heap->dblk_image, image, heap->dblk_size); /* Build free list */ - if(H5HL__fl_deserialize(heap) < 0) + if (H5HL__fl_deserialize(heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") } /* end if */ else @@ -485,21 +465,20 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED done: /* Release the [possibly partially initialized] local heap on errors */ - if(!ret_value) { - if(prfx) { - if(FAIL == H5HL__prfx_dest(prfx)) + if (!ret_value) { + if (prfx) { + if (FAIL == H5HL__prfx_dest(prfx)) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix"); } /* end if */ else { - if(heap && FAIL == H5HL__dest(heap)) + if (heap && FAIL == H5HL__dest(heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap"); } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_image_len * @@ -517,7 +496,7 @@ done: static herr_t H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len) { - const H5HL_prfx_t *prfx = (const H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ + const H5HL_prfx_t *prfx = (const H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ FUNC_ENTER_STATIC_NOERR @@ -533,13 +512,12 @@ H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len) /* If the heap is stored as a single object, add in the * data block size also */ - if(prfx->heap->single_cache_obj) + if (prfx->heap->single_cache_obj) *image_len += prfx->heap->dblk_size; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_serialize * @@ -557,13 +535,13 @@ H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, + size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ - H5HL_t *heap; /* Pointer to the local heap */ - uint8_t *image = (uint8_t *)_image; /* Pointer into image buffer */ - size_t buf_size; /* expected size of the image buffer */ + H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ + H5HL_t * heap; /* Pointer to the local heap */ + uint8_t * image = (uint8_t *)_image; /* Pointer into image buffer */ + size_t buf_size; /* expected size of the image buffer */ FUNC_ENTER_STATIC_NOERR @@ -582,7 +560,7 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, /* Compute the buffer size */ buf_size = heap->prfx_size; - if(heap->single_cache_obj) + if (heap->single_cache_obj) buf_size += heap->dblk_size; HDassert(len == buf_size); @@ -593,17 +571,17 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, H5MM_memcpy(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC); image += H5_SIZEOF_MAGIC; *image++ = H5HL_VERSION; - *image++ = 0; /*reserved*/ - *image++ = 0; /*reserved*/ - *image++ = 0; /*reserved*/ + *image++ = 0; /*reserved*/ + *image++ = 0; /*reserved*/ + *image++ = 0; /*reserved*/ H5F_ENCODE_LENGTH_LEN(image, heap->dblk_size, heap->sizeof_size); H5F_ENCODE_LENGTH_LEN(image, heap->free_block, heap->sizeof_size); H5F_addr_encode_len(heap->sizeof_addr, &image, heap->dblk_addr); /* Check if the local heap is a single object in cache */ - if(heap->single_cache_obj) { - if((size_t)(image - (uint8_t *)_image) < heap->prfx_size) { - size_t gap; /* Size of gap between prefix and data block */ + if (heap->single_cache_obj) { + if ((size_t)(image - (uint8_t *)_image) < heap->prfx_size) { + size_t gap; /* Size of gap between prefix and data block */ /* Set image to the start of the data block. This is necessary * because there may be a gap between the used portion of @@ -634,7 +612,6 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_free_icr * @@ -660,8 +637,8 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, static herr_t H5HL__cache_prefix_free_icr(void *_thing) { - H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -672,14 +649,13 @@ H5HL__cache_prefix_free_icr(void *_thing) HDassert(H5F_addr_eq(prfx->cache_info.addr, prfx->heap->prfx_addr)); /* Destroy local heap prefix */ - if(H5HL__prfx_dest(prfx) < 0) + if (H5HL__prfx_dest(prfx) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't destroy local heap prefix") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_get_initial_load_size() * @@ -698,7 +674,7 @@ done: static herr_t H5HL__cache_datablock_get_initial_load_size(void *_udata, size_t *image_len) { - H5HL_t *heap = (H5HL_t *)_udata; /* User data for callback */ + H5HL_t *heap = (H5HL_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -713,7 +689,6 @@ H5HL__cache_datablock_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_datablock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_deserialize * @@ -730,12 +705,11 @@ H5HL__cache_datablock_get_initial_load_size(void *_udata, size_t *image_len) *------------------------------------------------------------------------- */ static void * -H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5HL_dblk_t *dblk = NULL; /* Local heap data block deserialized */ - H5HL_t *heap = (H5HL_t *)_udata; /* User data for callback */ - void *ret_value = NULL; /* Return value */ + H5HL_dblk_t *dblk = NULL; /* Local heap data block deserialized */ + H5HL_t * heap = (H5HL_t *)_udata; /* User data for callback */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -749,20 +723,20 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, HDassert(dirty); /* Allocate space in memory for the heap data block */ - if(NULL == (dblk = H5HL__dblk_new(heap))) + if (NULL == (dblk = H5HL__dblk_new(heap))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed"); /* Check for heap still retaining image */ - if(NULL == heap->dblk_image) { + if (NULL == heap->dblk_image) { /* Allocate space for the heap data image */ - if(NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) + if (NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate data block image buffer"); /* copy the datablock from the read buffer */ H5MM_memcpy(heap->dblk_image, image, len); /* Build free list */ - if(FAIL == H5HL__fl_deserialize(heap)) + if (FAIL == H5HL__fl_deserialize(heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list"); } /* end if */ @@ -771,14 +745,13 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, done: /* Release the [possibly partially initialized] local heap on errors */ - if(!ret_value && dblk) - if(FAIL == H5HL__dblk_dest(dblk)) + if (!ret_value && dblk) + if (FAIL == H5HL__dblk_dest(dblk)) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_datablock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_image_len * @@ -795,7 +768,7 @@ done: static herr_t H5HL__cache_datablock_image_len(const void *_thing, size_t *image_len) { - const H5HL_dblk_t *dblk = (const H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + const H5HL_dblk_t *dblk = (const H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ FUNC_ENTER_STATIC_NOERR @@ -812,7 +785,6 @@ H5HL__cache_datablock_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_datablock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_serialize * @@ -829,10 +801,10 @@ H5HL__cache_datablock_image_len(const void *_thing, size_t *image_len) */ static herr_t H5HL__cache_datablock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, - size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) + size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HL_t *heap; /* Pointer to the local heap */ - H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + H5HL_t * heap; /* Pointer to the local heap */ + H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ FUNC_ENTER_STATIC_NOERR @@ -859,7 +831,6 @@ H5HL__cache_datablock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *imag FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_datablock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_notify * @@ -877,18 +848,18 @@ H5HL__cache_datablock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *imag static herr_t H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) { - H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblk); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Sanity checks */ @@ -896,19 +867,19 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) HDassert(dblk->heap->prfx); /* Pin the heap's prefix */ - if(FAIL == H5AC_pin_protected_entry(dblk->heap->prfx)) + if (FAIL == H5AC_pin_protected_entry(dblk->heap->prfx)) HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin local heap prefix") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Sanity checks */ @@ -916,7 +887,7 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) HDassert(dblk->heap->prfx); /* Unpin the local heap prefix */ - if(FAIL == H5AC_unpin_entry(dblk->heap->prfx)) + if (FAIL == H5AC_unpin_entry(dblk->heap->prfx)) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap prefix") break; @@ -929,7 +900,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_datablock_notify() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_free_icr * @@ -950,8 +920,8 @@ done: static herr_t H5HL__cache_datablock_free_icr(void *_thing) { - H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -961,10 +931,9 @@ H5HL__cache_datablock_free_icr(void *_thing) HDassert(dblk->cache_info.type == H5AC_LHEAP_DBLK); /* Destroy the data block */ - if(H5HL__dblk_dest(dblk) < 0) + if (H5HL__dblk_dest(dblk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_datablock_free_icr() */ - diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index edb0261..5695e80 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -21,18 +21,17 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLpkg.h" /* Local heaps */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLpkg.h" /* Local heaps */ +#include "H5MMprivate.h" /* Memory management */ - /*------------------------------------------------------------------------- * Function: H5HL_debug * @@ -45,15 +44,14 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, + H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)) - H5HL_t *h = NULL; - int free_block; - H5HL_free_t *freelist; - uint8_t *marker = NULL; - size_t amount_free = 0; + H5HL_t * h = NULL; + int free_block; + H5HL_free_t *freelist; + uint8_t * marker = NULL; + size_t amount_free = 0; /* check arguments */ HDassert(f); @@ -62,64 +60,59 @@ H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth)) HDassert(indent >= 0); HDassert(fwidth >= 0); - if(NULL == (h = (H5HL_t *)H5HL_protect(f, addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (h = (H5HL_t *)H5HL_protect(f, addr, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load/protect local heap"); HDfprintf(stream, "%*sLocal Heap...\n", indent, ""); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Header size (in bytes):", - (unsigned long)h->prfx_size); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of heap data:", - h->dblk_addr); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Data bytes allocated for heap:", - h->dblk_size); + "Header size (in bytes):", (unsigned long)h->prfx_size); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of heap data:", h->dblk_addr); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data bytes allocated for heap:", h->dblk_size); /* Traverse the free list and check that all free blocks fall within * the heap and that no two free blocks point to the same region of * the heap. */ - if(NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) + if (NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); - for(free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { + for (free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { char temp_str[32]; HDsnprintf(temp_str, sizeof(temp_str), "Block #%d:", free_block); - HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent+3, "", MAX(0,fwidth-9), temp_str, freelist->offset, freelist->size); - if((freelist->offset + freelist->size) > h->dblk_size) + HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent + 3, "", MAX(0, fwidth - 9), temp_str, + freelist->offset, freelist->size); + if ((freelist->offset + freelist->size) > h->dblk_size) HDfprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n"); else { - int overlap = 0; + int overlap = 0; size_t i; - for(i = 0; i < freelist->size; i++) { - if(marker[freelist->offset + i]) + for (i = 0; i < freelist->size; i++) { + if (marker[freelist->offset + i]) overlap++; marker[freelist->offset + i] = 1; } /* end for */ - if(overlap) + if (overlap) HDfprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n"); else amount_free += freelist->size; - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ - if(h->dblk_size) + if (h->dblk_size) HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", - ((double)100.0f * (double)(h->dblk_size - amount_free) / (double)h->dblk_size)); + ((double)100.0f * (double)(h->dblk_size - amount_free) / (double)h->dblk_size)); /* Print the data in a VMS-style octal dump */ H5_buffer_dump(stream, indent, h->dblk_image, marker, (size_t)0, h->dblk_size); -CATCH - if(h && FAIL == H5HL_unprotect(h)) + CATCH + if (h && FAIL == H5HL_unprotect(h)) H5E_THROW(H5E_CANTUNPROTECT, "unable to release/unprotect local heap"); - if(marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker))) + if (marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker))) H5E_THROW(H5E_CANTFREE, "can't free marker buffer"); END_FUNC(PRIV) /* end H5HL_debug() */ - diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c index c3fcffe..2d2a539 100644 --- a/src/H5HLdblk.c +++ b/src/H5HLdblk.c @@ -26,49 +26,41 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -76,8 +68,6 @@ /* Declare a free list to manage the H5HL_dblk_t struct */ H5FL_DEFINE_STATIC(H5HL_dblk_t); - - /*------------------------------------------------------------------------- * Function: H5HL__dblk_new * @@ -91,21 +81,19 @@ H5FL_DEFINE_STATIC(H5HL_dblk_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5HL_dblk_t *, NULL, NULL, -H5HL__dblk_new(H5HL_t *heap)) +BEGIN_FUNC(PKG, ERR, H5HL_dblk_t *, NULL, NULL, H5HL__dblk_new(H5HL_t *heap)) - H5HL_dblk_t *dblk = NULL; /* New local heap data block */ + H5HL_dblk_t *dblk = NULL; /* New local heap data block */ /* check arguments */ HDassert(heap); /* Allocate new local heap data block */ - if(NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t))) + if (NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap data block") /* Increment ref. count on heap data structure */ - if(FAIL == H5HL__inc_rc(heap)) + if (FAIL == H5HL__inc_rc(heap)) H5E_THROW(H5E_CANTINC, "can't increment heap ref. count") /* Link the heap & the data block */ @@ -115,15 +103,14 @@ H5HL__dblk_new(H5HL_t *heap)) /* Set the return value */ ret_value = dblk; -CATCH + CATCH /* Ensure that the data block memory is deallocated on errors */ - if(!ret_value && dblk != NULL) + if (!ret_value && dblk != NULL) /* H5FL_FREE always returns NULL so we can't check for errors */ dblk = H5FL_FREE(H5HL_dblk_t, dblk); END_FUNC(PKG) /* end H5HL__dblk_new() */ - /*------------------------------------------------------------------------- * Function: H5HL__dblk_dest * @@ -136,34 +123,31 @@ END_FUNC(PKG) /* end H5HL__dblk_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dblk_dest(H5HL_dblk_t *dblk)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_dest(H5HL_dblk_t *dblk)) /* check arguments */ HDassert(dblk); /* Check if data block was initialized */ - if(dblk->heap) { + if (dblk->heap) { /* Unlink data block from heap */ dblk->heap->dblk = NULL; /* Decrement ref. count on heap data structure */ - if(FAIL == H5HL__dec_rc(dblk->heap)) + if (FAIL == H5HL__dec_rc(dblk->heap)) H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") /* Unlink heap from data block */ dblk->heap = NULL; } /* end if */ -CATCH + CATCH /* Free local heap data block */ /* H5FL_FREE always returns NULL so we can't check for errors */ dblk = H5FL_FREE(H5HL_dblk_t, dblk); END_FUNC(PKG) /* end H5HL__dblk_dest() */ - /*------------------------------------------------------------------------- * Function: H5HL__dblk_realloc * @@ -176,29 +160,27 @@ END_FUNC(PKG) /* end H5HL__dblk_dest() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) - H5HL_dblk_t *dblk; /* Local heap data block */ - haddr_t old_addr; /* Old location of heap data block */ - haddr_t new_addr; /* New location of heap data block */ - size_t old_heap_size; /* Old size of heap data block */ + H5HL_dblk_t *dblk; /* Local heap data block */ + haddr_t old_addr; /* Old location of heap data block */ + haddr_t new_addr; /* New location of heap data block */ + size_t old_heap_size; /* Old size of heap data block */ /* check arguments */ HDassert(heap); HDassert(new_heap_size > 0); /* Release old space on disk */ - old_addr = heap->dblk_addr; + old_addr = heap->dblk_addr; old_heap_size = heap->dblk_size; H5_CHECK_OVERFLOW(old_heap_size, size_t, hsize_t); - if(FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, old_addr, (hsize_t)old_heap_size)) + if (FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, old_addr, (hsize_t)old_heap_size)) H5E_THROW(H5E_CANTFREE, "can't free old local heap data"); /* Allocate new space on disk */ H5_CHECK_OVERFLOW(new_heap_size, size_t, hsize_t); - if(HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, (hsize_t)new_heap_size))) + if (HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, (hsize_t)new_heap_size))) H5E_THROW(H5E_CANTALLOC, "unable to allocate file space for local heap"); /* Update heap info*/ @@ -206,15 +188,15 @@ H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) heap->dblk_size = new_heap_size; /* Check if heap data block actually moved in the file */ - if(H5F_addr_eq(old_addr, new_addr)) { + if (H5F_addr_eq(old_addr, new_addr)) { /* Check if heap data block is contiguous w/prefix */ - if(heap->single_cache_obj) { + if (heap->single_cache_obj) { /* Sanity check */ HDassert(H5F_addr_eq(heap->prfx_addr + heap->prfx_size, old_addr)); HDassert(heap->prfx); /* Resize the heap prefix in the cache */ - if(FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_heap_size))) + if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_heap_size))) H5E_THROW(H5E_CANTRESIZE, "unable to resize heap in cache"); } /* end if */ else { @@ -223,24 +205,24 @@ H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) HDassert(heap->dblk); /* Resize the heap data block in the cache */ - if(H5AC_resize_entry(heap->dblk, (size_t)new_heap_size) < 0) + if (H5AC_resize_entry(heap->dblk, (size_t)new_heap_size) < 0) H5E_THROW(H5E_CANTRESIZE, "unable to resize heap (data block) in cache"); } /* end else */ - } /* end if */ + } /* end if */ else { /* Check if heap data block was contiguous w/prefix previously */ - if(heap->single_cache_obj) { + if (heap->single_cache_obj) { /* Create new heap data block */ - if(NULL == (dblk = H5HL__dblk_new(heap))) + if (NULL == (dblk = H5HL__dblk_new(heap))) H5E_THROW(H5E_CANTALLOC, "unable to allocate local heap data block"); /* Resize current heap prefix */ heap->prfx_size = H5HL_SIZEOF_HDR(f); - if(FAIL == H5AC_resize_entry(heap->prfx, (size_t)heap->prfx_size)) + if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)heap->prfx_size)) H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache"); /* Insert data block into cache (pinned) */ - if(FAIL == H5AC_insert_entry(f, H5AC_LHEAP_DBLK, new_addr, dblk, H5AC__PIN_ENTRY_FLAG)) + if (FAIL == H5AC_insert_entry(f, H5AC_LHEAP_DBLK, new_addr, dblk, H5AC__PIN_ENTRY_FLAG)) H5E_THROW(H5E_CANTINIT, "unable to cache local heap data block"); dblk = NULL; @@ -253,22 +235,21 @@ H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) /* (ignore [unlikely] case where heap data block ends up * contiguous w/heap prefix again. */ - if(FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_heap_size)) + if (FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_heap_size)) H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache"); /* Relocate the heap data block in the cache */ - if(FAIL == H5AC_move_entry(f, H5AC_LHEAP_DBLK, old_addr, new_addr)) + if (FAIL == H5AC_move_entry(f, H5AC_LHEAP_DBLK, old_addr, new_addr)) H5E_THROW(H5E_CANTMOVE, "unable to move heap data block in cache"); } /* end else */ - } /* end else */ + } /* end else */ -CATCH + CATCH /* Restore old heap address & size on errors */ - if(FAIL == ret_value) { + if (FAIL == ret_value) { heap->dblk_addr = old_addr; heap->dblk_size = old_heap_size; } /* end if */ END_FUNC(PKG) /* end H5HL__dblk_realloc() */ - diff --git a/src/H5HLint.c b/src/H5HLint.c index cc3e3ea..0bbb381 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -26,48 +26,40 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5HLpkg.h" /* Local Heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HLpkg.h" /* Local Heaps */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -75,8 +67,6 @@ /* Declare a free list to manage the H5HL_t struct */ H5FL_DEFINE_STATIC(H5HL_t); - - /*------------------------------------------------------------------------- * Function: H5HL__new * @@ -90,11 +80,10 @@ H5FL_DEFINE_STATIC(H5HL_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5HL_t *, NULL, NULL, -H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)) +BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, + H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)) - H5HL_t *heap = NULL; /* New local heap */ + H5HL_t *heap = NULL; /* New local heap */ /* check arguments */ HDassert(sizeof_size > 0); @@ -102,25 +91,24 @@ H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)) HDassert(prfx_size > 0); /* Allocate new local heap structure */ - if(NULL == (heap = H5FL_CALLOC(H5HL_t))) + if (NULL == (heap = H5FL_CALLOC(H5HL_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* Initialize non-zero fields */ heap->sizeof_size = sizeof_size; heap->sizeof_addr = sizeof_addr; - heap->prfx_size = prfx_size; + heap->prfx_size = prfx_size; /* Set the return value */ ret_value = heap; -CATCH - if(!ret_value && heap != NULL) + CATCH + if (!ret_value && heap != NULL) if (NULL == (heap = H5FL_FREE(H5HL_t, heap))) H5E_THROW(H5E_CANTFREE, "can't free heap memory"); END_FUNC(PKG) /* end H5HL__new() */ - /*------------------------------------------------------------------------- * Function: H5HL__inc_rc * @@ -133,9 +121,7 @@ END_FUNC(PKG) /* end H5HL__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5HL__inc_rc(H5HL_t *heap)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5HL__inc_rc(H5HL_t *heap)) /* check arguments */ HDassert(heap); @@ -145,7 +131,6 @@ H5HL__inc_rc(H5HL_t *heap)) END_FUNC(PKG) /* end H5HL__inc_rc() */ - /*------------------------------------------------------------------------- * Function: H5HL__dec_rc * @@ -158,9 +143,7 @@ END_FUNC(PKG) /* end H5HL__inc_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dec_rc(H5HL_t *heap)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dec_rc(H5HL_t *heap)) /* check arguments */ HDassert(heap); @@ -168,14 +151,13 @@ H5HL__dec_rc(H5HL_t *heap)) /* Decrement heap's ref. count */ heap->rc--; -CATCH + CATCH /* Check if we should destroy the heap */ - if(heap->rc == 0 && FAIL == H5HL__dest(heap)) + if (heap->rc == 0 && FAIL == H5HL__dest(heap)) H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); END_FUNC(PKG) /* end H5HL__dec_rc() */ - /*------------------------------------------------------------------------- * Function: H5HL__dest * @@ -188,9 +170,7 @@ END_FUNC(PKG) /* end H5HL__dec_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dest(H5HL_t *heap)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dest(H5HL_t *heap)) /* check arguments */ HDassert(heap); @@ -201,20 +181,20 @@ H5HL__dest(H5HL_t *heap)) HDassert(heap->prfx == NULL); HDassert(heap->dblk == NULL); -CATCH - if(heap->dblk_image) - if(NULL != (heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image))) + CATCH + if (heap->dblk_image) + if (NULL != (heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image))) H5E_THROW(H5E_CANTFREE, "unable to free local heap data block image"); - while(heap->freelist) { - H5HL_free_t *fl; + while (heap->freelist) { + H5HL_free_t *fl; - fl = heap->freelist; + fl = heap->freelist; heap->freelist = fl->next; - if(NULL != (fl = H5FL_FREE(H5HL_free_t, fl))) + if (NULL != (fl = H5FL_FREE(H5HL_free_t, fl))) H5E_THROW(H5E_CANTFREE, "unable to free local heap free list"); } /* end while */ - if(NULL != (heap = H5FL_FREE(H5HL_t, heap))) + if (NULL != (heap = H5FL_FREE(H5HL_t, heap))) H5E_THROW(H5E_CANTFREE, "unable to free local heap"); END_FUNC(PKG) /* end H5HL__dest() */ diff --git a/src/H5HLmodule.h b/src/H5HLmodule.h index 712c7c1..54fcdf4 100644 --- a/src/H5HLmodule.h +++ b/src/H5HLmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5HL_MODULE -#define H5_MY_PKG H5HL -#define H5_MY_PKG_ERR H5E_HEAP -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5HL +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO #endif /* _H5HLmodule_H */ - diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index 9891e10..717297e 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -30,8 +30,7 @@ #include "H5HLprivate.h" /* Other private headers needed by this file */ -#include "H5FLprivate.h" /* Free lists */ - +#include "H5FLprivate.h" /* Free lists */ /*****************************/ /* Package Private Variables */ @@ -43,7 +42,6 @@ H5FL_EXTERN(H5HL_free_t); /* Declare extern the PQ free list to manage the heap chunk information */ H5FL_BLK_EXTERN(lheap_chunk); - /**************************/ /* Package Private Macros */ /**************************/ @@ -53,32 +51,31 @@ H5FL_BLK_EXTERN(lheap_chunk); * error reporting macros. */ #ifdef H5HL_PACKAGE -#define H5_MY_PKG H5HL -#define H5_MY_PKG_ERR H5E_HEAP -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5HL +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO #endif /* H5HL_PACKAGE */ -#define H5HL_SIZEOF_HDR(F) \ - H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \ - 1 + /* version */ \ - 3 + /* reserved */ \ - H5F_SIZEOF_SIZE(F) + /* data size */ \ - H5F_SIZEOF_SIZE(F) + /* free list head */ \ - H5F_SIZEOF_ADDR(F)) /* data address */ +#define H5HL_SIZEOF_HDR(F) \ + H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \ + 1 + /* version */ \ + 3 + /* reserved */ \ + H5F_SIZEOF_SIZE(F) + /* data size */ \ + H5F_SIZEOF_SIZE(F) + /* free list head */ \ + H5F_SIZEOF_ADDR(F)) /* data address */ /* Value indicating end of free list on disk */ -#define H5HL_FREE_NULL 1 - +#define H5HL_FREE_NULL 1 /****************************/ /* Package Private Typedefs */ /****************************/ typedef struct H5HL_free_t { - size_t offset; /* offset of free block */ - size_t size; /* size of free block */ - struct H5HL_free_t *prev; /* previous entry in free list */ - struct H5HL_free_t *next; /* next entry in free list */ + size_t offset; /* offset of free block */ + size_t size; /* size of free block */ + struct H5HL_free_t *prev; /* previous entry in free list */ + struct H5HL_free_t *next; /* next entry in free list */ } H5HL_free_t; /* Forward declarations */ @@ -87,66 +84,65 @@ typedef struct H5HL_prfx_t H5HL_prfx_t; struct H5HL_t { /* General heap-management fields */ - size_t rc; /* Ref. count for prefix & data block using this struct */ - size_t prots; /* # of times the heap has been protected */ - size_t sizeof_size; /* Size of file sizes */ - size_t sizeof_addr; /* Size of file addresses */ - hbool_t single_cache_obj; /* Indicate if the heap is a single object in the cache */ - H5HL_free_t *freelist; /* the free list */ + size_t rc; /* Ref. count for prefix & data block using this struct */ + size_t prots; /* # of times the heap has been protected */ + size_t sizeof_size; /* Size of file sizes */ + size_t sizeof_addr; /* Size of file addresses */ + hbool_t single_cache_obj; /* Indicate if the heap is a single object in the cache */ + H5HL_free_t *freelist; /* the free list */ /* Prefix-specific fields */ - H5HL_prfx_t *prfx; /* The prefix object for the heap */ - haddr_t prfx_addr; /* address of heap prefix */ - size_t prfx_size; /* size of heap prefix */ - hsize_t free_block; /* Address of first free block */ + H5HL_prfx_t *prfx; /* The prefix object for the heap */ + haddr_t prfx_addr; /* address of heap prefix */ + size_t prfx_size; /* size of heap prefix */ + hsize_t free_block; /* Address of first free block */ /* Data block-specific fields */ - H5HL_dblk_t *dblk; /* The data block object for the heap */ - haddr_t dblk_addr; /* address of data block */ - size_t dblk_size; /* size of heap data block on disk and in mem */ - uint8_t *dblk_image; /* The data block image */ + H5HL_dblk_t *dblk; /* The data block object for the heap */ + haddr_t dblk_addr; /* address of data block */ + size_t dblk_size; /* size of heap data block on disk and in mem */ + uint8_t * dblk_image; /* The data block image */ }; /* Struct for heap data block */ struct H5HL_dblk_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - H5HL_t *heap; /* Pointer to heap for data block */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + H5HL_t *heap; /* Pointer to heap for data block */ }; /* Struct for heap prefix */ struct H5HL_prfx_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - H5HL_t *heap; /* Pointer to heap for prefix */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + H5HL_t *heap; /* Pointer to heap for prefix */ }; /* Callback information for loading local heap prefix from disk */ typedef struct H5HL_cache_prfx_ud_t { - size_t sizeof_size; /* Size of file sizes */ - size_t sizeof_addr; /* Size of file addresses */ - haddr_t prfx_addr; /* Address of prefix */ - size_t sizeof_prfx; /* Size of heap prefix */ + size_t sizeof_size; /* Size of file sizes */ + size_t sizeof_addr; /* Size of file addresses */ + haddr_t prfx_addr; /* Address of prefix */ + size_t sizeof_prfx; /* Size of heap prefix */ } H5HL_cache_prfx_ud_t; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Heap routines */ H5_DLL H5HL_t *H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size); -H5_DLL herr_t H5HL__dest(H5HL_t *heap); -H5_DLL herr_t H5HL__inc_rc(H5HL_t *heap); -H5_DLL herr_t H5HL__dec_rc(H5HL_t *heap); +H5_DLL herr_t H5HL__dest(H5HL_t *heap); +H5_DLL herr_t H5HL__inc_rc(H5HL_t *heap); +H5_DLL herr_t H5HL__dec_rc(H5HL_t *heap); /* Heap prefix routines */ H5_DLL H5HL_prfx_t *H5HL__prfx_new(H5HL_t *heap); -H5_DLL herr_t H5HL__prfx_dest(H5HL_prfx_t *prfx); +H5_DLL herr_t H5HL__prfx_dest(H5HL_prfx_t *prfx); /* Heap data block routines */ H5_DLL H5HL_dblk_t *H5HL__dblk_new(H5HL_t *heap); -H5_DLL herr_t H5HL__dblk_dest(H5HL_dblk_t *dblk); -H5_DLL herr_t H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size); +H5_DLL herr_t H5HL__dblk_dest(H5HL_dblk_t *dblk); +H5_DLL herr_t H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size); #endif /* _H5HLpkg_H */ diff --git a/src/H5HLprfx.c b/src/H5HLprfx.c index 41c254a..152f501 100644 --- a/src/H5HLprfx.c +++ b/src/H5HLprfx.c @@ -26,48 +26,40 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5HLpkg.h" /* Local Heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HLpkg.h" /* Local Heaps */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -75,8 +67,6 @@ /* Declare a free list to manage the H5HL_prfx_t struct */ H5FL_DEFINE_STATIC(H5HL_prfx_t); - - /*------------------------------------------------------------------------- * Function: H5HL__prfx_new * @@ -90,21 +80,19 @@ H5FL_DEFINE_STATIC(H5HL_prfx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5HL_prfx_t *, NULL, NULL, -H5HL__prfx_new(H5HL_t *heap)) +BEGIN_FUNC(PKG, ERR, H5HL_prfx_t *, NULL, NULL, H5HL__prfx_new(H5HL_t *heap)) - H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ /* check arguments */ HDassert(heap); /* Allocate new local heap prefix */ - if(NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t))) + if (NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap prefix") /* Increment ref. count on heap data structure */ - if(FAIL == H5HL__inc_rc(heap)) + if (FAIL == H5HL__inc_rc(heap)) H5E_THROW(H5E_CANTINC, "can't increment heap ref. count") /* Link the heap & the prefix */ @@ -114,15 +102,14 @@ H5HL__prfx_new(H5HL_t *heap)) /* Set the return value */ ret_value = prfx; -CATCH + CATCH /* Ensure that the prefix memory is deallocated on errors */ - if(!ret_value && prfx != NULL) + if (!ret_value && prfx != NULL) /* H5FL_FREE always returns NULL so we can't check for errors */ prfx = H5FL_FREE(H5HL_prfx_t, prfx); END_FUNC(PKG) /* end H5HL__prfx_new() */ - /*------------------------------------------------------------------------- * Function: H5HL__prfx_dest * @@ -135,30 +122,27 @@ END_FUNC(PKG) /* end H5HL__prfx_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__prfx_dest(H5HL_prfx_t *prfx)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__prfx_dest(H5HL_prfx_t *prfx)) /* check arguments */ HDassert(prfx); /* Check if prefix was initialized */ - if(prfx->heap) { + if (prfx->heap) { /* Unlink prefix from heap */ prfx->heap->prfx = NULL; /* Decrement ref. count on heap data structure */ - if(FAIL == H5HL__dec_rc(prfx->heap)) + if (FAIL == H5HL__dec_rc(prfx->heap)) H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") /* Unlink heap from prefix */ prfx->heap = NULL; } /* end if */ -CATCH + CATCH /* Free prefix memory */ /* H5FL_FREE always returns NULL so we can't check for errors */ prfx = H5FL_FREE(H5HL_prfx_t, prfx); END_FUNC(PKG) /* end H5HL__prfx_dest() */ - diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index 60505ee..6b4540b 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -25,23 +25,23 @@ #define _H5HLprivate_H /* Private headers needed by this file. */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /* * Feature: Define H5HL_DEBUG on the compiler command line if you want to * enable diagnostic messages from this layer. */ #ifdef NDEBUG -# undef H5HL_DEBUG +#undef H5HL_DEBUG #endif -#define H5HL_ALIGN(X) ((((unsigned)X)+7)&(unsigned)(~0x07)) /* align on 8-byte boundary */ +#define H5HL_ALIGN(X) ((((unsigned)X) + 7) & (unsigned)(~0x07)) /* align on 8-byte boundary */ -#define H5HL_SIZEOF_FREE(F) \ - H5HL_ALIGN(H5F_SIZEOF_SIZE (F) + /* ptr to next free block */ \ - H5F_SIZEOF_SIZE (F)) /* size of this free block */ +#define H5HL_SIZEOF_FREE(F) \ + H5HL_ALIGN(H5F_SIZEOF_SIZE(F) + /* ptr to next free block */ \ + H5F_SIZEOF_SIZE(F)) /* size of this free block */ /****************************/ /* Library Private Typedefs */ @@ -53,19 +53,17 @@ typedef struct H5HL_t H5HL_t; /* * Library prototypes */ -H5_DLL herr_t H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/); +H5_DLL herr_t H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr /*out*/); H5_DLL herr_t H5HL_delete(H5F_t *f, haddr_t addr); H5_DLL herr_t H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size); H5_DLL herr_t H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size); H5_DLL size_t H5HL_insert(H5F_t *f, H5HL_t *heap, size_t size, const void *buf); -H5_DLL void *H5HL_offset_into(const H5HL_t *heap, size_t offset); +H5_DLL void * H5HL_offset_into(const H5HL_t *heap, size_t offset); H5_DLL H5HL_t *H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags); -H5_DLL herr_t H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size); -H5_DLL herr_t H5HL_unprotect(H5HL_t *heap); +H5_DLL herr_t H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size); +H5_DLL herr_t H5HL_unprotect(H5HL_t *heap); /* Debugging routines for dumping file structures */ -H5_DLL herr_t H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, - int fwidth); +H5_DLL herr_t H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); #endif - diff --git a/src/H5HP.c b/src/H5HP.c index 4ef5662..15ff46c 100644 --- a/src/H5HP.c +++ b/src/H5HP.c @@ -19,29 +19,28 @@ * */ - /* Private headers needed */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HPprivate.h" /* Heap routines */ -#include "H5FLprivate.h" /* Memory management functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HPprivate.h" /* Heap routines */ +#include "H5FLprivate.h" /* Memory management functions */ /* Local Macros */ -#define H5HP_START_SIZE 16 /* Initial number of entries for heaps */ +#define H5HP_START_SIZE 16 /* Initial number of entries for heaps */ /* Private typedefs & structs */ /* Data structure for entries in the internal heap array */ typedef struct { - int val; /* Value to be used for heap condition */ - H5HP_info_t *obj; /* Pointer to object stored in heap */ -}H5HP_ent_t; + int val; /* Value to be used for heap condition */ + H5HP_info_t *obj; /* Pointer to object stored in heap */ +} H5HP_ent_t; /* Main heap data structure */ struct H5HP_t { H5HP_type_t type; /* Type of heap (minimum or maximum value at "top") */ - size_t nobjs; /* Number of active objects in heap array */ - size_t nalloc; /* Number of allocated locations in heap array */ + size_t nobjs; /* Number of active objects in heap array */ + size_t nalloc; /* Number of allocated locations in heap array */ H5HP_ent_t *heap; /* Pointer to array containing heap entries */ }; @@ -57,7 +56,6 @@ H5FL_DEFINE_STATIC(H5HP_t); /* Declare a free list to manage sequences of H5HP_ent_t */ H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); - /*-------------------------------------------------------------------------- NAME H5HP_swim_max @@ -82,40 +80,39 @@ H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); static herr_t H5HP_swim_max(H5HP_t *heap, size_t loc) { - int val; /* Temporary copy value of object to move in heap */ - H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value=SUCCEED; /* Return value */ + int val; /* Temporary copy value of object to move in heap */ + H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Get copies of the information about the object to move in the heap */ - val=heap->heap[loc].val; - obj=heap->heap[loc].obj; + val = heap->heap[loc].val; + obj = heap->heap[loc].obj; /* Move object up in heap until it's reached the maximum location possible */ - while(heap->heap[loc/2].val < val) { + while (heap->heap[loc / 2].val < val) { /* Move object "above" current location in heap down */ - heap->heap[loc].val=heap->heap[loc/2].val; - heap->heap[loc].obj=heap->heap[loc/2].obj; + heap->heap[loc].val = heap->heap[loc / 2].val; + heap->heap[loc].obj = heap->heap[loc / 2].obj; /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc=loc; + heap->heap[loc].obj->heap_loc = loc; /* Move to location "above" current location */ - loc=loc/2; + loc = loc / 2; } /* end while */ /* Put object into heap at correct location */ - heap->heap[loc].val=val; - heap->heap[loc].obj=obj; + heap->heap[loc].val = val; + heap->heap[loc].obj = obj; /* Update heap location for object */ - heap->heap[loc].obj->heap_loc=loc; + heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_swim_max() */ - /*-------------------------------------------------------------------------- NAME H5HP_swim_min @@ -140,40 +137,39 @@ H5HP_swim_max(H5HP_t *heap, size_t loc) static herr_t H5HP_swim_min(H5HP_t *heap, size_t loc) { - int val; /* Temporary copy value of object to move in heap */ - H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value=SUCCEED; /* Return value */ + int val; /* Temporary copy value of object to move in heap */ + H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Get copies of the information about the object to move in the heap */ - val=heap->heap[loc].val; - obj=heap->heap[loc].obj; + val = heap->heap[loc].val; + obj = heap->heap[loc].obj; /* Move object up in heap until it's reached the minimum location possible */ - while(heap->heap[loc/2].val > val) { + while (heap->heap[loc / 2].val > val) { /* Move object "above" current location in heap down */ - heap->heap[loc].val=heap->heap[loc/2].val; - heap->heap[loc].obj=heap->heap[loc/2].obj; + heap->heap[loc].val = heap->heap[loc / 2].val; + heap->heap[loc].obj = heap->heap[loc / 2].obj; /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc=loc; + heap->heap[loc].obj->heap_loc = loc; /* Move to location "above" current location */ - loc=loc/2; + loc = loc / 2; } /* end while */ /* Put object into heap at correct location */ - heap->heap[loc].val=val; - heap->heap[loc].obj=obj; + heap->heap[loc].val = val; + heap->heap[loc].obj = obj; /* Update heap location for object */ - heap->heap[loc].obj->heap_loc=loc; + heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_swim_min() */ - /*-------------------------------------------------------------------------- NAME H5HP_sink_max @@ -198,38 +194,38 @@ H5HP_swim_min(H5HP_t *heap, size_t loc) static herr_t H5HP_sink_max(H5HP_t *heap, size_t loc) { - int val; /* Temporary copy value of object to move in heap */ - void *obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value=SUCCEED; /* Return value */ + int val; /* Temporary copy value of object to move in heap */ + void * obj; /* Temporary pointer to object to move in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Get copies of the information about the object to move in the heap */ - val=heap->heap[loc].val; - obj=heap->heap[loc].obj; + val = heap->heap[loc].val; + obj = heap->heap[loc].obj; /* Move object up in heap until it's reached the maximum location possible */ - while((2*loc)<=heap->nobjs) { - size_t new_loc=loc*2; /* New object's potential location area */ + while ((2 * loc) <= heap->nobjs) { + size_t new_loc = loc * 2; /* New object's potential location area */ /* Get the greater of the two objects below the location in heap */ - if(new_locnobjs && (heap->heap[new_loc].val < heap->heap[new_loc+1].val)) + if (new_loc < heap->nobjs && (heap->heap[new_loc].val < heap->heap[new_loc + 1].val)) new_loc++; /* Check if the object is smaller than the larger of the objects below it */ /* If so, its in the correct location now, and we can get out */ - if(val >= heap->heap[new_loc].val) + if (val >= heap->heap[new_loc].val) break; /* Move the greater of the two objects below the current location up */ - heap->heap[loc].val=heap->heap[new_loc].val; - heap->heap[loc].obj=heap->heap[new_loc].obj; + heap->heap[loc].val = heap->heap[new_loc].val; + heap->heap[loc].obj = heap->heap[new_loc].obj; /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc=loc; + heap->heap[loc].obj->heap_loc = loc; /* Move to location "below" current location */ - loc=new_loc; + loc = new_loc; } /* end while */ /* Put object into heap at correct location */ @@ -242,7 +238,6 @@ H5HP_sink_max(H5HP_t *heap, size_t loc) FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_sink_max() */ - /*-------------------------------------------------------------------------- NAME H5HP_sink_min @@ -267,38 +262,38 @@ H5HP_sink_max(H5HP_t *heap, size_t loc) static herr_t H5HP_sink_min(H5HP_t *heap, size_t loc) { - int val; /* Temporary copy value of object to move in heap */ - void *obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value=SUCCEED; /* Return value */ + int val; /* Temporary copy value of object to move in heap */ + void * obj; /* Temporary pointer to object to move in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Get copies of the information about the object to move in the heap */ - val=heap->heap[loc].val; - obj=heap->heap[loc].obj; + val = heap->heap[loc].val; + obj = heap->heap[loc].obj; /* Move object up in heap until it's reached the maximum location possible */ - while((2*loc)<=heap->nobjs) { - size_t new_loc=loc*2; /* New object's potential location area */ + while ((2 * loc) <= heap->nobjs) { + size_t new_loc = loc * 2; /* New object's potential location area */ /* Get the lesser of the two objects below the location in heap */ - if(new_locnobjs && (heap->heap[new_loc].val > heap->heap[new_loc+1].val)) + if (new_loc < heap->nobjs && (heap->heap[new_loc].val > heap->heap[new_loc + 1].val)) new_loc++; /* Check if the object is greater than the larger of the objects below it */ /* If so, its in the correct location now, and we can get out */ - if(val <= heap->heap[new_loc].val) + if (val <= heap->heap[new_loc].val) break; /* Move the greater of the two objects below the current location up */ - heap->heap[loc].val=heap->heap[new_loc].val; - heap->heap[loc].obj=heap->heap[new_loc].obj; + heap->heap[loc].val = heap->heap[new_loc].val; + heap->heap[loc].obj = heap->heap[new_loc].obj; /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc=loc; + heap->heap[loc].obj->heap_loc = loc; /* Move to location "below" current location */ - loc=new_loc; + loc = new_loc; } /* end while */ /* Put object into heap at correct location */ @@ -311,7 +306,6 @@ H5HP_sink_min(H5HP_t *heap, size_t loc) FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_sink_min() */ - /*-------------------------------------------------------------------------- NAME H5HP_create @@ -334,60 +328,59 @@ H5HP_sink_min(H5HP_t *heap, size_t loc) H5HP_t * H5HP_create(H5HP_type_t heap_type) { - H5HP_t *new_heap=NULL; /* Pointer to new heap object created */ - H5HP_t *ret_value; /* Return value */ + H5HP_t *new_heap = NULL; /* Pointer to new heap object created */ + H5HP_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Check args */ - HDassert(heap_type==H5HP_MIN_HEAP || heap_type==H5HP_MAX_HEAP); + HDassert(heap_type == H5HP_MIN_HEAP || heap_type == H5HP_MAX_HEAP); /* Allocate ref-counted string structure */ - if((new_heap=H5FL_MALLOC(H5HP_t))==NULL) - HGOTO_ERROR(H5E_HEAP,H5E_NOSPACE,NULL,"memory allocation failed"); + if ((new_heap = H5FL_MALLOC(H5HP_t)) == NULL) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed"); /* Allocate the array to store the heap entries */ - if((new_heap->heap = H5FL_SEQ_MALLOC(H5HP_ent_t, (size_t)(H5HP_START_SIZE + 1)))==NULL) - HGOTO_ERROR(H5E_HEAP,H5E_NOSPACE,NULL,"memory allocation failed"); + if ((new_heap->heap = H5FL_SEQ_MALLOC(H5HP_ent_t, (size_t)(H5HP_START_SIZE + 1))) == NULL) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed"); /* Set the internal fields */ - new_heap->type=heap_type; - new_heap->nobjs=0; - new_heap->nalloc=H5HP_START_SIZE+1; + new_heap->type = heap_type; + new_heap->nobjs = 0; + new_heap->nalloc = H5HP_START_SIZE + 1; /* Set the information in the 0'th location based on the type of heap */ - if(heap_type==H5HP_MIN_HEAP) { + if (heap_type == H5HP_MIN_HEAP) { /* Set the value in the '0' location to be the minimum value, to * simplify the algorithms */ - new_heap->heap[0].val=INT_MIN; - new_heap->heap[0].obj=NULL; + new_heap->heap[0].val = INT_MIN; + new_heap->heap[0].obj = NULL; } /* end if */ else { /* Set the value in the '0' location to be the maximum value, to * simplify the algorithms */ - new_heap->heap[0].val=INT_MAX; - new_heap->heap[0].obj=NULL; + new_heap->heap[0].val = INT_MAX; + new_heap->heap[0].obj = NULL; } /* end else */ /* Set the return value */ - ret_value=new_heap; + ret_value = new_heap; done: /* Error cleanup */ - if(NULL ==ret_value) { - if(NULL != new_heap) { - if(NULL != new_heap->heap) + if (NULL == ret_value) { + if (NULL != new_heap) { + if (NULL != new_heap->heap) new_heap->heap = H5FL_SEQ_FREE(H5HP_ent_t, new_heap->heap); new_heap = H5FL_FREE(H5HP_t, new_heap); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_create() */ - /*-------------------------------------------------------------------------- NAME H5HP_count @@ -409,7 +402,7 @@ done: ssize_t H5HP_count(const H5HP_t *heap) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -418,21 +411,20 @@ H5HP_count(const H5HP_t *heap) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); /* Return the number of objects in the heap */ - H5_CHECK_OVERFLOW(heap->nobjs,size_t,ssize_t); - ret_value=(ssize_t)heap->nobjs; + H5_CHECK_OVERFLOW(heap->nobjs, size_t, ssize_t); + ret_value = (ssize_t)heap->nobjs; /* No post-condition check necessary, since heap is constant */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_count() */ - /*-------------------------------------------------------------------------- NAME H5HP_insert @@ -456,7 +448,7 @@ H5HP_count(const H5HP_t *heap) herr_t H5HP_insert(H5HP_t *heap, int val, void *obj) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -466,38 +458,38 @@ H5HP_insert(H5HP_t *heap, int val, void *obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); /* Increment number of objects in heap */ heap->nobjs++; /* Check if we need to allocate more room for heap array */ - if(heap->nobjs>=heap->nalloc) { - size_t n = MAX(H5HP_START_SIZE, 2*(heap->nalloc-1)) + 1; - H5HP_ent_t *new_heap = H5FL_SEQ_REALLOC(H5HP_ent_t,heap->heap, n); + if (heap->nobjs >= heap->nalloc) { + size_t n = MAX(H5HP_START_SIZE, 2 * (heap->nalloc - 1)) + 1; + H5HP_ent_t *new_heap = H5FL_SEQ_REALLOC(H5HP_ent_t, heap->heap, n); if (!new_heap) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend heap array"); - heap->heap = new_heap; + heap->heap = new_heap; heap->nalloc = n; } /* end if */ /* Insert new object at end of heap */ - heap->heap[heap->nobjs].val = val; - heap->heap[heap->nobjs].obj = (H5HP_info_t *)obj; + heap->heap[heap->nobjs].val = val; + heap->heap[heap->nobjs].obj = (H5HP_info_t *)obj; heap->heap[heap->nobjs].obj->heap_loc = heap->nobjs; /* Restore heap condition */ - if(heap->type==H5HP_MAX_HEAP) { - if(H5HP_swim_max(heap,heap->nobjs)<0) + if (heap->type == H5HP_MAX_HEAP) { + if (H5HP_swim_max(heap, heap->nobjs) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); } /* end if */ else { - if(H5HP_swim_min(heap,heap->nobjs)<0) + if (H5HP_swim_min(heap, heap->nobjs) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); } /* end else */ @@ -505,16 +497,15 @@ done: /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_insert() */ - /*-------------------------------------------------------------------------- NAME H5HP_top @@ -545,20 +536,19 @@ H5HP_top(const H5HP_t *heap, int *val) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); /* Get value of the top object in the heap */ - *val=heap->heap[1].val; + *val = heap->heap[1].val; /* No post-condition check necessary, since heap is constant */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5HP_top() */ - /*-------------------------------------------------------------------------- NAME H5HP_remove @@ -582,7 +572,7 @@ H5HP_top(const H5HP_t *heap, int *val) herr_t H5HP_remove(H5HP_t *heap, int *val, void **obj) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -593,55 +583,54 @@ H5HP_remove(H5HP_t *heap, int *val, void **obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); /* Check if there are any objects on the heap to remove */ - if(heap->nobjs==0) + if (heap->nobjs == 0) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap is empty"); /* Get the information for the top object on the heap */ - HDassert(heap->heap[1].obj->heap_loc==1); - *val=heap->heap[1].val; - *obj=heap->heap[1].obj; + HDassert(heap->heap[1].obj->heap_loc == 1); + *val = heap->heap[1].val; + *obj = heap->heap[1].obj; /* Move the last element in the heap to the top */ - heap->heap[1].val=heap->heap[heap->nobjs].val; - heap->heap[1].obj=heap->heap[heap->nobjs].obj; - heap->heap[1].obj->heap_loc=1; + heap->heap[1].val = heap->heap[heap->nobjs].val; + heap->heap[1].obj = heap->heap[heap->nobjs].obj; + heap->heap[1].obj->heap_loc = 1; /* Decrement number of objects in heap */ heap->nobjs--; /* Restore heap condition, if there are objects on the heap */ - if(heap->nobjs>0) { - if(heap->type==H5HP_MAX_HEAP) { - if(H5HP_sink_max(heap, (size_t)1) < 0) + if (heap->nobjs > 0) { + if (heap->type == H5HP_MAX_HEAP) { + if (H5HP_sink_max(heap, (size_t)1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); } /* end if */ else { - if(H5HP_sink_min(heap, (size_t)1) < 0) + if (H5HP_sink_min(heap, (size_t)1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); } /* end else */ - } /* end if */ + } /* end if */ done: /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_remove() */ - /*-------------------------------------------------------------------------- NAME H5HP_change @@ -665,10 +654,10 @@ done: herr_t H5HP_change(H5HP_t *heap, int val, void *_obj) { - H5HP_info_t *obj=(H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - int old_val; /* Object's old priority value */ - herr_t ret_value=SUCCEED; /* Return value */ + H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ + size_t obj_loc; /* Location of object in heap */ + int old_val; /* Object's old priority value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -678,56 +667,55 @@ H5HP_change(H5HP_t *heap, int val, void *_obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); /* Get the location of the object in the heap */ - obj_loc=obj->heap_loc; - HDassert(obj_loc>0 && obj_loc<=heap->nobjs); + obj_loc = obj->heap_loc; + HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); /* Change the heap object's priority */ - old_val=heap->heap[obj_loc].val; - heap->heap[obj_loc].val=val; + old_val = heap->heap[obj_loc].val; + heap->heap[obj_loc].val = val; /* Restore heap condition */ - if(valtype==H5HP_MAX_HEAP) { - if(H5HP_sink_max(heap,obj_loc)<0) + if (val < old_val) { + if (heap->type == H5HP_MAX_HEAP) { + if (H5HP_sink_max(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { - if(H5HP_swim_min(heap,obj_loc)<0) + if (H5HP_swim_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ - } /* end if */ + } /* end if */ else { - if(heap->type==H5HP_MAX_HEAP) { - if(H5HP_swim_max(heap,obj_loc)<0) + if (heap->type == H5HP_MAX_HEAP) { + if (H5HP_swim_max(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { - if(H5HP_sink_min(heap,obj_loc)<0) + if (H5HP_sink_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ - } /* end else */ + } /* end else */ done: /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_change() */ - /*-------------------------------------------------------------------------- NAME H5HP_incr @@ -751,9 +739,9 @@ done: herr_t H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) { - H5HP_info_t *obj=(H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - herr_t ret_value=SUCCEED; /* Return value */ + H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ + size_t obj_loc; /* Location of object in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -763,11 +751,11 @@ H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); /* Get the location of the object in the heap */ obj_loc = obj->heap_loc; @@ -777,12 +765,12 @@ H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) heap->heap[obj_loc].val += (int)amt; /* Restore heap condition */ - if(H5HP_MAX_HEAP == heap->type) { - if(H5HP_swim_max(heap, obj_loc) < 0) + if (H5HP_MAX_HEAP == heap->type) { + if (H5HP_swim_max(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") } /* end if */ else { - if(H5HP_sink_min(heap, obj_loc) < 0) + if (H5HP_sink_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") } /* end else */ @@ -790,16 +778,15 @@ done: /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_incr() */ - /*-------------------------------------------------------------------------- NAME H5HP_decr @@ -823,9 +810,9 @@ done: herr_t H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) { - H5HP_info_t *obj=(H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - herr_t ret_value=SUCCEED; /* Return value */ + H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ + size_t obj_loc; /* Location of object in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -835,27 +822,27 @@ H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); /* Get the location of the object in the heap */ - obj_loc=obj->heap_loc; - HDassert(obj_loc>0 && obj_loc<=heap->nobjs); + obj_loc = obj->heap_loc; + HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); /* Change the heap object's priority */ H5_CHECK_OVERFLOW(amt, unsigned, int); - heap->heap[obj_loc].val-=(int)amt; + heap->heap[obj_loc].val -= (int)amt; /* Restore heap condition */ - if(heap->type==H5HP_MAX_HEAP) { - if(H5HP_sink_max(heap,obj_loc)<0) + if (heap->type == H5HP_MAX_HEAP) { + if (H5HP_sink_max(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end if */ else { - if(H5HP_swim_min(heap,obj_loc)<0) + if (H5HP_swim_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ @@ -863,16 +850,15 @@ done: /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); - HDassert((heap->type==H5HP_MAX_HEAP && heap->heap[0].val==INT_MAX) || - (heap->type==H5HP_MIN_HEAP && heap->heap[0].val==INT_MIN)); - HDassert(heap->heap[0].obj==NULL); + HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + HDassert(heap->heap[0].obj == NULL); FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_decr() */ - /*-------------------------------------------------------------------------- NAME H5HP_close @@ -905,7 +891,7 @@ H5HP_close(H5HP_t *heap) HDassert(heap->nobjs < heap->nalloc); HDassert(heap->heap); HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); HDassert(NULL == heap->heap[0].obj); /* Free internal structures for heap */ @@ -916,4 +902,3 @@ H5HP_close(H5HP_t *heap) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HP_close() */ - diff --git a/src/H5HPprivate.h b/src/H5HPprivate.h index 041c2b9..0148ca6 100644 --- a/src/H5HPprivate.h +++ b/src/H5HPprivate.h @@ -39,13 +39,13 @@ typedef struct H5HP_t H5HP_t; /* Typedef for objects which can be inserted into heaps */ /* This _must_ be the first field in objects which can be inserted into heaps */ typedef struct H5HP_info_t { - size_t heap_loc; /* Location of object in heap */ -}H5HP_info_t; + size_t heap_loc; /* Location of object in heap */ +} H5HP_info_t; /* Typedef for type of heap to create */ typedef enum { - H5HP_MIN_HEAP, /* Minimum values in heap are at the "top" */ - H5HP_MAX_HEAP /* Maximum values in heap are at the "top" */ + H5HP_MIN_HEAP, /* Minimum values in heap are at the "top" */ + H5HP_MAX_HEAP /* Maximum values in heap are at the "top" */ } H5HP_type_t; /**********/ @@ -56,14 +56,13 @@ typedef enum { /* Private routines */ /********************/ H5_DLL H5HP_t *H5HP_create(H5HP_type_t heap_type); -H5_DLL herr_t H5HP_insert(H5HP_t *heap, int val, void *obj); +H5_DLL herr_t H5HP_insert(H5HP_t *heap, int val, void *obj); H5_DLL ssize_t H5HP_count(const H5HP_t *heap); -H5_DLL herr_t H5HP_top(const H5HP_t *heap, int *val); -H5_DLL herr_t H5HP_remove(H5HP_t *heap, int *val, void **ptr); -H5_DLL herr_t H5HP_change(H5HP_t *heap, int val, void *obj); -H5_DLL herr_t H5HP_incr(H5HP_t *heap, unsigned amt, void *obj); -H5_DLL herr_t H5HP_decr(H5HP_t *heap, unsigned amt, void *obj); -H5_DLL herr_t H5HP_close(H5HP_t *heap); +H5_DLL herr_t H5HP_top(const H5HP_t *heap, int *val); +H5_DLL herr_t H5HP_remove(H5HP_t *heap, int *val, void **ptr); +H5_DLL herr_t H5HP_change(H5HP_t *heap, int val, void *obj); +H5_DLL herr_t H5HP_incr(H5HP_t *heap, unsigned amt, void *obj); +H5_DLL herr_t H5HP_decr(H5HP_t *heap, unsigned amt, void *obj); +H5_DLL herr_t H5HP_close(H5HP_t *heap); #endif /* _H5HPprivate_H */ - diff --git a/src/H5I.c b/src/H5I.c index a739c4e..fd7fdee 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -25,83 +25,80 @@ * variables defined in H5Ipublic.h. */ -#include "H5Imodule.h" /* This source code file is part of the H5I module */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Ipkg.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5SLprivate.h" /* Skip Lists */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5Imodule.h" /* This source code file is part of the H5I module */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5SLprivate.h" /* Skip Lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Local Macros */ /* Combine a Type number and an atom index into an atom */ -#define H5I_MAKE(g,i) ((((hid_t)(g) & TYPE_MASK) << ID_BITS) | \ - ((hid_t)(i) & ID_MASK)) +#define H5I_MAKE(g, i) ((((hid_t)(g)&TYPE_MASK) << ID_BITS) | ((hid_t)(i)&ID_MASK)) /* Local typedefs */ /* Atom information structure used */ typedef struct H5I_id_info_t { - hid_t id; /* ID for this info */ - unsigned count; /* ref. count for this atom */ - unsigned app_count; /* ref. count of application visible atoms */ - const void *obj_ptr; /* pointer associated with the atom */ + hid_t id; /* ID for this info */ + unsigned count; /* ref. count for this atom */ + unsigned app_count; /* ref. count of application visible atoms */ + const void *obj_ptr; /* pointer associated with the atom */ } H5I_id_info_t; /* ID type structure used */ typedef struct { - const H5I_class_t *cls; /* Pointer to ID class */ - unsigned init_count; /* # of times this type has been initialized*/ - uint64_t id_count; /* Current number of IDs held */ - uint64_t nextid; /* ID to use for the next atom */ - H5I_id_info_t *last_info; /* Info for most recent ID looked up */ - H5SL_t *ids; /* Pointer to skip list that stores IDs */ + const H5I_class_t *cls; /* Pointer to ID class */ + unsigned init_count; /* # of times this type has been initialized*/ + uint64_t id_count; /* Current number of IDs held */ + uint64_t nextid; /* ID to use for the next atom */ + H5I_id_info_t * last_info; /* Info for most recent ID looked up */ + H5SL_t * ids; /* Pointer to skip list that stores IDs */ } H5I_id_type_t; typedef struct { - H5I_search_func_t app_cb; /* Application's callback routine */ - void *app_key; /* Application's "key" (user data) */ - void *ret_obj; /* Object to return */ + H5I_search_func_t app_cb; /* Application's callback routine */ + void * app_key; /* Application's "key" (user data) */ + void * ret_obj; /* Object to return */ } H5I_search_ud_t; typedef struct { - H5I_iterate_func_t op; /* Application's callback routine */ - void *op_data; /* Application's user data */ + H5I_iterate_func_t op; /* Application's callback routine */ + void * op_data; /* Application's user data */ } H5I_iterate_pub_ud_t; /* User data for iterator callback for retrieving an ID corresponding to an object pointer */ typedef struct { - const void *object; /* object pointer to search for */ - H5I_type_t obj_type; /* type of object we are searching for */ - hid_t ret_id; /* ID returned */ + const void *object; /* object pointer to search for */ + H5I_type_t obj_type; /* type of object we are searching for */ + hid_t ret_id; /* ID returned */ } H5I_get_id_ud_t; /* User data for iterator callback for ID iteration */ typedef struct { - H5I_search_func_t user_func; /* 'User' function to invoke */ - void *user_udata; /* User data to pass to 'user' function */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ - H5I_type_t obj_type; /* Type of object we are iterating over */ + H5I_search_func_t user_func; /* 'User' function to invoke */ + void * user_udata; /* User data to pass to 'user' function */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_type_t obj_type; /* Type of object we are iterating over */ } H5I_iterate_ud_t; /* User data for H5I__clear_type_cb */ typedef struct { - H5I_id_type_t *type_ptr; /* Pointer to the type being cleard */ - hbool_t force; /* Whether to always remove the id */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_id_type_t *type_ptr; /* Pointer to the type being cleard */ + hbool_t force; /* Whether to always remove the id */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ } H5I_clear_type_ud_t; /* Package initialization variable */ @@ -132,20 +129,19 @@ H5FL_DEFINE_STATIC(H5I_class_t); H5FL_EXTERN(H5VL_object_t); /*--------------------- Local function prototypes ---------------------------*/ -static void *H5I__unwrap(void *obj_ptr, H5I_type_t type); -static htri_t H5I__clear_type_cb(void *_id, void *key, void *udata); -static int H5I__destroy_type(H5I_type_t type); -static void *H5I__remove_verify(hid_t id, H5I_type_t id_type); -static void *H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); -static int H5I__inc_type_ref(H5I_type_t type); -static int H5I__get_type_ref(H5I_type_t type); -static int H5I__search_cb(void *obj, hid_t id, void *_udata); +static void * H5I__unwrap(void *obj_ptr, H5I_type_t type); +static htri_t H5I__clear_type_cb(void *_id, void *key, void *udata); +static int H5I__destroy_type(H5I_type_t type); +static void * H5I__remove_verify(hid_t id, H5I_type_t id_type); +static void * H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); +static int H5I__inc_type_ref(H5I_type_t type); +static int H5I__get_type_ref(H5I_type_t type); +static int H5I__search_cb(void *obj, hid_t id, void *_udata); static H5I_id_info_t *H5I__find_id(hid_t id); -static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); -static int H5I__find_id_cb(void *_item, void *_key, void *_udata); -static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); +static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); +static int H5I__find_id_cb(void *_item, void *_key, void *_udata); +static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); - /*------------------------------------------------------------------------- * Function: H5I_term_package * @@ -163,41 +159,40 @@ static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); int H5I_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - H5I_id_type_t *type_ptr; /* Pointer to ID type */ - int type; /* Type of ID */ + if (H5_PKG_INIT_VAR) { + H5I_id_type_t *type_ptr; /* Pointer to ID type */ + int type; /* Type of ID */ /* How many types are still being used? */ - for(type = 0; type < H5I_next_type; type++) - if((type_ptr = H5I_id_type_list_g[type]) && type_ptr->ids) + for (type = 0; type < H5I_next_type; type++) + if ((type_ptr = H5I_id_type_list_g[type]) && type_ptr->ids) n++; /* If no types are used then clean up */ - if(0 == n) { - for(type = 0; type < H5I_next_type; type++) { + if (0 == n) { + for (type = 0; type < H5I_next_type; type++) { type_ptr = H5I_id_type_list_g[type]; - if(type_ptr) { + if (type_ptr) { HDassert(NULL == type_ptr->ids); - type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); + type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); H5I_id_type_list_g[type] = NULL; n++; } /* end if */ - } /* end for */ + } /* end for */ /* Mark interface closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5I_term_package() */ - /*------------------------------------------------------------------------- * Function: H5Iregister_type * @@ -216,12 +211,11 @@ H5I_term_package(void) *------------------------------------------------------------------------- */ H5I_type_t -H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, - H5I_free_t free_func) +H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, H5I_free_t free_func) { H5I_class_t *cls = NULL; /* New ID class */ - H5I_type_t new_type; /* New ID type value */ - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t new_type; /* New ID type value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE3("It", "zIux", hash_size, reserved, free_func); @@ -229,41 +223,41 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, /* Generate a new H5I_type_t value */ /* Increment the number of types */ - if(H5I_next_type < H5I_MAX_NUM_TYPES) { + if (H5I_next_type < H5I_MAX_NUM_TYPES) { new_type = (H5I_type_t)H5I_next_type; H5I_next_type++; } /* end if */ else { - hbool_t done; /* Indicate that search was successful */ - int i; /* Local index variable */ + hbool_t done; /* Indicate that search was successful */ + int i; /* Local index variable */ /* Look for a free type to give out */ done = FALSE; - for(i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == FALSE; i++) { - if(NULL == H5I_id_type_list_g[i]) { + for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == FALSE; i++) { + if (NULL == H5I_id_type_list_g[i]) { /* Found a free type ID */ new_type = (H5I_type_t)i; - done = TRUE; + done = TRUE; } /* end if */ - } /* end for */ + } /* end for */ /* Verify that we found a type to give out */ - if(done == FALSE) + if (done == FALSE) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_BADID, "Maximum number of ID types exceeded") } /* end else */ /* Allocate new ID class */ - if(NULL == (cls = H5FL_CALLOC(H5I_class_t))) + if (NULL == (cls = H5FL_CALLOC(H5I_class_t))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed") /* Initialize class fields */ - cls->type_id = new_type; - cls->flags = H5I_CLASS_IS_APPLICATION; - cls->reserved = reserved; + cls->type_id = new_type; + cls->flags = H5I_CLASS_IS_APPLICATION; + cls->reserved = reserved; cls->free_func = free_func; /* Register the new ID class */ - if(H5I_register_type(cls) < 0) + if (H5I_register_type(cls) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, H5I_BADID, "can't initialize ID class") /* Set return value */ @@ -271,14 +265,13 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, done: /* Clean up on error */ - if(ret_value < 0) - if(cls) + if (ret_value < 0) + if (cls) cls = H5FL_FREE(H5I_class_t, cls); FUNC_LEAVE_API(ret_value) } /* end H5Iregister_type() */ - /*------------------------------------------------------------------------- * Function: H5I_register_type * @@ -293,8 +286,8 @@ done: herr_t H5I_register_type(const H5I_class_t *cls) { - H5I_id_type_t *type_ptr = NULL; /* Ptr to the atomic type*/ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_id_type_t *type_ptr = NULL; /* Ptr to the atomic type*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -303,9 +296,9 @@ H5I_register_type(const H5I_class_t *cls) HDassert(cls->type_id > 0 && (int)cls->type_id < H5I_MAX_NUM_TYPES); /* Initialize the type */ - if(NULL == H5I_id_type_list_g[cls->type_id]) { + if (NULL == H5I_id_type_list_g[cls->type_id]) { /* Allocate the type information for new type */ - if(NULL == (type_ptr = (H5I_id_type_t *)H5FL_CALLOC(H5I_id_type_t))) + if (NULL == (type_ptr = (H5I_id_type_t *)H5FL_CALLOC(H5I_id_type_t))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, FAIL, "ID type allocation failed") H5I_id_type_list_g[cls->type_id] = type_ptr; } /* end if */ @@ -315,12 +308,12 @@ H5I_register_type(const H5I_class_t *cls) } /* end else */ /* Initialize the ID type structure for new types */ - if(type_ptr->init_count == 0) { - type_ptr->cls = cls; - type_ptr->id_count = 0; - type_ptr->nextid = cls->reserved; + if (type_ptr->init_count == 0) { + type_ptr->cls = cls; + type_ptr->id_count = 0; + type_ptr->nextid = cls->reserved; type_ptr->last_info = NULL; - if(NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL))) + if (NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL))) HGOTO_ERROR(H5E_ATOM, H5E_CANTCREATE, FAIL, "skip list creation failed") } /* end if */ @@ -328,18 +321,17 @@ H5I_register_type(const H5I_class_t *cls) type_ptr->init_count++; done: - if(ret_value < 0) { /* Clean up on error */ - if(type_ptr) { - if(type_ptr->ids) + if (ret_value < 0) { /* Clean up on error */ + if (type_ptr) { + if (type_ptr->ids) H5SL_close(type_ptr->ids); (void)H5FL_FREE(H5I_id_type_t, type_ptr); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_register_type() */ - /*------------------------------------------------------------------------- * Function: H5Itype_exists * @@ -353,25 +345,24 @@ done: htri_t H5Itype_exists(H5I_type_t type) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "It", type); /* Validate parameter */ - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_id_type_list_g[type]) ret_value = FALSE; done: FUNC_LEAVE_API(ret_value) } /* end H5Itype_exists() */ - /*------------------------------------------------------------------------- * Function: H5Inmembers * @@ -391,27 +382,27 @@ done: herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members) { - int ret_value = SUCCEED; /* Return value */ + int ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "It*h", type, num_members); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") /* Validate parameters. This needs to be done here, instead of letting * the private interface handle it, because the public interface throws * an error when the supplied type does not exist. */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_id_type_list_g[type]) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist") - if(num_members) { + if (num_members) { int64_t members; - if((members = H5I_nmembers(type)) < 0) + if ((members = H5I_nmembers(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCOUNT, FAIL, "can't compute number of members") H5_CHECKED_ASSIGN(*num_members, hsize_t, members, int64_t); @@ -421,7 +412,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Inmembers() */ - /*------------------------------------------------------------------------- * Function: H5I_nmembers * @@ -440,15 +430,15 @@ done: int64_t H5I_nmembers(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - int64_t ret_value = 0; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the ID type */ + int64_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Validate parameter */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == (type_ptr = H5I_id_type_list_g[type]) || type_ptr->init_count <= 0) + if (NULL == (type_ptr = H5I_id_type_list_g[type]) || type_ptr->init_count <= 0) HGOTO_DONE(0); /* Set return value */ @@ -458,7 +448,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_nmembers() */ - /*------------------------------------------------------------------------- * Function: H5I__unwrap * @@ -475,7 +464,7 @@ done: static void * H5I__unwrap(void *obj_ptr, H5I_type_t type) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -485,13 +474,13 @@ H5I__unwrap(void *obj_ptr, H5I_type_t type) /* The stored object pointer might be an H5VL_object_t, in which * case we'll need to get the wrapped object struct (H5F_t *, etc.). */ - if(H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + if (H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { const H5VL_object_t *vol_obj; - vol_obj = (const H5VL_object_t *)obj_ptr; + vol_obj = (const H5VL_object_t *)obj_ptr; ret_value = H5VL_object_data(vol_obj); } /* end if */ - else if(H5I_DATATYPE == type) { + else if (H5I_DATATYPE == type) { H5T_t *dt = (H5T_t *)obj_ptr; ret_value = (void *)H5T_get_actual_type(dt); @@ -502,7 +491,6 @@ H5I__unwrap(void *obj_ptr, H5I_type_t type) FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__unwrap() */ - /*------------------------------------------------------------------------- * Function: H5Iclear_type * @@ -521,12 +509,12 @@ H5I__unwrap(void *obj_ptr, H5I_type_t type) herr_t H5Iclear_type(H5I_type_t type, hbool_t force) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "Itb", type, force); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I_clear_type(type, force, TRUE); @@ -535,7 +523,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iclear_type() */ - /*------------------------------------------------------------------------- * Function: H5I_clear_type * @@ -552,32 +539,31 @@ done: herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) { - H5I_clear_type_ud_t udata; /* udata struct for callback */ - int ret_value = SUCCEED; /* Return value */ + H5I_clear_type_ud_t udata; /* udata struct for callback */ + int ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Validate parameters */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") udata.type_ptr = H5I_id_type_list_g[type]; - if(udata.type_ptr == NULL || udata.type_ptr->init_count <= 0) + if (udata.type_ptr == NULL || udata.type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Finish constructing udata */ - udata.force = force; + udata.force = force; udata.app_ref = app_ref; /* Attempt to free all ids in the type */ - if(H5SL_try_free_safe(udata.type_ptr->ids, H5I__clear_type_cb, &udata) < 0) + if (H5SL_try_free_safe(udata.type_ptr->ids, H5I__clear_type_cb, &udata) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't free ids in type") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_clear_type() */ - /*------------------------------------------------------------------------- * Function: H5I__clear_type_cb * @@ -594,9 +580,9 @@ done: static htri_t H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) { - H5I_id_info_t *id = (H5I_id_info_t *)_id; /* Current ID being worked with */ - H5I_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ - htri_t ret_value = FALSE; /* Return value */ + H5I_id_info_t * id = (H5I_id_info_t *)_id; /* Current ID being worked with */ + H5I_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -608,42 +594,42 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) /* Do nothing to the object if the reference count is larger than * one and forcing is off. */ - if(udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { + if (udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { /* Check for a 'free' function and call it, if it exists */ - if(udata->type_ptr->cls->free_func && (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { /* (Casting away const OK -QAK) */ - if(udata->force) { + if (udata->type_ptr->cls->free_func && + (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { /* (Casting away const OK -QAK) */ + if (udata->force) { #ifdef H5I_DEBUG - if(H5DEBUG(I)) { - HDfprintf(H5DEBUG(I), "H5I: free type=%d obj=0x%08lx " - "failure ignored\n", - (int)udata->type_ptr->cls->type_id, - (unsigned long)(id->obj_ptr)); + if (H5DEBUG(I)) { + HDfprintf(H5DEBUG(I), + "H5I: free type=%d obj=0x%08lx " + "failure ignored\n", + (int)udata->type_ptr->cls->type_id, (unsigned long)(id->obj_ptr)); } /* end if */ -#endif /*H5I_DEBUG*/ +#endif /*H5I_DEBUG*/ /* Indicate node should be removed from list */ ret_value = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Indicate node should be removed from list */ ret_value = TRUE; } /* end else */ /* Remove ID if requested */ - if(ret_value) { + if (ret_value) { /* Free ID info */ id = H5FL_FREE(H5I_id_info_t, id); /* Decrement the number of IDs in the type */ udata->type_ptr->id_count--; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__clear_type_cb() */ - /*------------------------------------------------------------------------- * Function: H5Idestroy_type * @@ -663,12 +649,12 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) herr_t H5Idestroy_type(H5I_type_t type) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "It", type); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I__destroy_type(type); @@ -677,7 +663,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Idestroy_type() */ - /*------------------------------------------------------------------------- * Function: H5I__destroy_type * @@ -696,40 +681,41 @@ done: static herr_t H5I__destroy_type(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* ptr to the atomic type */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_id_type_t *type_ptr; /* ptr to the atomic type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Validate parameter */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) + if (type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Close/clear/destroy all IDs for this type */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5I_clear_type(type, TRUE, FALSE); - } H5E_END_TRY /*don't care about errors*/ + } + H5E_END_TRY /*don't care about errors*/ - /* Check if we should release the ID class */ - if(type_ptr->cls->flags & H5I_CLASS_IS_APPLICATION) - type_ptr->cls = H5FL_FREE(H5I_class_t, (void *)type_ptr->cls); + /* Check if we should release the ID class */ + if (type_ptr->cls->flags & H5I_CLASS_IS_APPLICATION) + type_ptr->cls = H5FL_FREE(H5I_class_t, (void *)type_ptr->cls); - if(H5SL_close(type_ptr->ids) < 0) + if (H5SL_close(type_ptr->ids) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEOBJ, FAIL, "can't close skip list") type_ptr->ids = NULL; - type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); + type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); H5I_id_type_list_g[type] = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__destroy_type() */ - /*------------------------------------------------------------------------- * Function: H5Iregister * @@ -743,12 +729,12 @@ done: hid_t H5Iregister(H5I_type_t type, const void *object) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "It*x", type, object); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I_register(type, object, TRUE); @@ -757,7 +743,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iregister() */ - /*------------------------------------------------------------------------- * Function: H5I_register * @@ -777,10 +762,10 @@ done: hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) { - H5I_id_type_t *type_ptr = NULL; /* ptr to the type */ - H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID information */ - hid_t new_id = -1; /* new ID */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5I_id_type_t *type_ptr = NULL; /* ptr to the type */ + H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID information */ + hid_t new_id = -1; /* new ID */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -794,11 +779,11 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Create the struct & its ID */ - new_id = H5I_MAKE(type, type_ptr->nextid); - id_ptr->id = new_id; - id_ptr->count = 1; /* initial reference count */ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; + new_id = H5I_MAKE(type, type_ptr->nextid); + id_ptr->id = new_id; + id_ptr->count = 1; /* initial reference count */ + id_ptr->app_count = !!app_ref; + id_ptr->obj_ptr = object; /* Insert into the type */ if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) @@ -819,7 +804,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_register() */ - /*------------------------------------------------------------------------- * Function: H5I_register_using_existing_id * @@ -841,9 +825,9 @@ done: herr_t H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, hid_t existing_id) { - H5I_id_type_t *type_ptr; /* ptr to the type */ - H5I_id_info_t *id_ptr; /* ptr to the new ID information */ - herr_t ret_value = SUCCEED; /* return value */ + H5I_id_type_t *type_ptr; /* ptr to the type */ + H5I_id_info_t *id_ptr; /* ptr to the new ID information */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -851,35 +835,35 @@ H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, h HDassert(object); /* Make sure ID is not already in use */ - if(NULL != (id_ptr = H5I__find_id(existing_id))) + if (NULL != (id_ptr = H5I__find_id(existing_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") /* Make sure type number is valid */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") /* Get type pointer from list of types */ type_ptr = H5I_id_type_list_g[type]; - if(NULL == type_ptr || type_ptr->init_count <= 0) + if (NULL == type_ptr || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Make sure requested ID belongs to object's type */ - if(H5I_TYPE(existing_id) != type) + if (H5I_TYPE(existing_id) != type) HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "invalid type for provided ID") /* Allocate new structure to house this ID */ - if(NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) + if (NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the struct & insert requested ID */ - id_ptr->id = existing_id; - id_ptr->count = 1; /* initial reference count*/ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; + id_ptr->id = existing_id; + id_ptr->count = 1; /* initial reference count*/ + id_ptr->app_count = !!app_ref; + id_ptr->obj_ptr = object; /* Insert into the type */ - if(H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) + if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't insert ID node into skip list") type_ptr->id_count++; @@ -890,7 +874,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_register_using_existing_id() */ - /*------------------------------------------------------------------------- * Function: H5I_subst * @@ -908,17 +891,17 @@ done: void * H5I_subst(hid_t id, const void *new_object) { - H5I_id_info_t *id_ptr; /* Pointer to the atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the atom */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) + if (NULL == (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_NOTFOUND, NULL, "can't get ID ref count") /* Get the old object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ /* Set the new object pointer for the ID */ id_ptr->obj_ptr = new_object; @@ -927,7 +910,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_subst() */ - /*------------------------------------------------------------------------- * Function: H5I_object * @@ -943,21 +925,20 @@ done: void * H5I_object(hid_t id) { - H5I_id_info_t *id_ptr; /* Pointer to the new atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new atom */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR /* General lookup of the ID */ - if(NULL != (id_ptr = H5I__find_id(id))) { + if (NULL != (id_ptr = H5I__find_id(id))) { /* Get the object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ } FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_object() */ - /*------------------------------------------------------------------------- * Function: H5Iobject_verify * @@ -974,15 +955,15 @@ H5I_object(hid_t id) void * H5Iobject_verify(hid_t id, H5I_type_t id_type) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE2("*x", "iIt", id, id_type); /* Validate parameters */ - if(H5I_IS_LIB_TYPE(id_type)) + if (H5I_IS_LIB_TYPE(id_type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") - if(id_type < 1 || (int)id_type >= H5I_next_type) + if (id_type < 1 || (int)id_type >= H5I_next_type) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "identifier has invalid type") ret_value = H5I_object_verify(id, id_type); @@ -991,7 +972,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iobject_verify() */ - /*------------------------------------------------------------------------- * Function: H5I_object_verify * @@ -1010,23 +990,22 @@ done: void * H5I_object_verify(hid_t id, H5I_type_t id_type) { - H5I_id_info_t *id_ptr = NULL; /* Pointer to the new atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *id_ptr = NULL; /* Pointer to the new atom */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR HDassert(id_type >= 1 && (int)id_type < H5I_next_type); /* Verify that the type of the ID is correct & lookup the ID */ - if(id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I__find_id(id))) { + if (id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I__find_id(id))) { /* Get the object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ } FUNC_LEAVE_NOAPI(ret_value) } /* H5I_object_verify() */ - /*------------------------------------------------------------------------- * Function: H5I_get_type * @@ -1048,11 +1027,11 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) H5I_type_t H5I_get_type(hid_t id) { - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_NOAPI_NOERR - if(id > 0) + if (id > 0) ret_value = H5I_TYPE(id); HDassert(ret_value >= H5I_BADID && (int)ret_value < H5I_next_type); @@ -1060,7 +1039,6 @@ H5I_get_type(hid_t id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_type() */ - /*------------------------------------------------------------------------- * Function: H5Iget_type * @@ -1079,21 +1057,20 @@ H5I_get_type(hid_t id) H5I_type_t H5Iget_type(hid_t id) { - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE1("It", "i", id); ret_value = H5I_get_type(id); - if(ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type || NULL == H5I_object(id)) + if (ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type || NULL == H5I_object(id)) HGOTO_DONE(H5I_BADID); done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_type() */ - /*------------------------------------------------------------------------- * Function: H5I_is_file_object * @@ -1112,8 +1089,8 @@ done: htri_t H5I_is_file_object(hid_t id) { - H5I_type_t id_type = H5I_get_type(id); - htri_t ret_value = FAIL; + H5I_type_t id_type = H5I_get_type(id); + htri_t ret_value = FAIL; FUNC_ENTER_NOAPI(FAIL); @@ -1131,7 +1108,7 @@ H5I_is_file_object(hid_t id) H5T_t *dt = NULL; - if(NULL == (dt = (H5T_t *)H5I_object(id))) + if (NULL == (dt = (H5T_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get underlying datatype struct"); ret_value = H5T_is_named(dt); @@ -1144,7 +1121,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5I_is_file_object() */ - /*------------------------------------------------------------------------- * Function: H5Iremove_verify * @@ -1165,12 +1141,12 @@ done: void * H5Iremove_verify(hid_t id, H5I_type_t id_type) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE2("*x", "iIt", id, id_type); - if(H5I_IS_LIB_TYPE(id_type)) + if (H5I_IS_LIB_TYPE(id_type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Remove the id */ @@ -1180,7 +1156,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iremove_verify() */ - /*------------------------------------------------------------------------- * Function: H5I__remove_verify * @@ -1200,20 +1175,19 @@ done: static void * H5I__remove_verify(hid_t id, H5I_type_t id_type) { - void * ret_value = NULL; /*return value */ + void *ret_value = NULL; /*return value */ FUNC_ENTER_STATIC_NOERR /* Argument checking will be performed by H5I_remove() */ /* Verify that the type of the ID is correct */ - if(id_type == H5I_TYPE(id)) + if (id_type == H5I_TYPE(id)) ret_value = H5I_remove(id); FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__remove_verify() */ - /*------------------------------------------------------------------------- * Function: H5I__remove_common * @@ -1232,8 +1206,8 @@ H5I__remove_verify(hid_t id, H5I_type_t id_type) static void * H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) { - H5I_id_info_t *curr_id; /* Pointer to the current atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *curr_id; /* Pointer to the current atom */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1241,15 +1215,15 @@ H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) HDassert(type_ptr); /* Get the ID node for the ID */ - if(NULL == (curr_id = (H5I_id_info_t *)H5SL_remove(type_ptr->ids, &id))) + if (NULL == (curr_id = (H5I_id_info_t *)H5SL_remove(type_ptr->ids, &id))) HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node from skip list") /* Check if this ID was the last one accessed */ - if(type_ptr->last_info == curr_id) + if (type_ptr->last_info == curr_id) type_ptr->last_info = NULL; - ret_value = (void *)curr_id->obj_ptr; /* (Casting away const OK -QAK) */ - curr_id = H5FL_FREE(H5I_id_info_t, curr_id); + ret_value = (void *)curr_id->obj_ptr; /* (Casting away const OK -QAK) */ + curr_id = H5FL_FREE(H5I_id_info_t, curr_id); /* Decrement the number of IDs in the type */ (type_ptr->id_count)--; @@ -1258,7 +1232,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__remove_common() */ - /*------------------------------------------------------------------------- * Function: H5I_remove * @@ -1276,29 +1249,28 @@ done: void * H5I_remove(hid_t id) { - H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ - H5I_type_t type; /* Atom's atomic type */ - void * ret_value = NULL; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ + H5I_type_t type; /* Atom's atomic type */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Check arguments */ type = H5I_TYPE(id); - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) + if (type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") /* Remove the node from the type */ - if(NULL == (ret_value = H5I__remove_common(type_ptr, id))) + if (NULL == (ret_value = H5I__remove_common(type_ptr, id))) HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_remove() */ - /*------------------------------------------------------------------------- * Function: H5Idec_ref * @@ -1317,24 +1289,23 @@ done: int H5Idec_ref(hid_t id) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ - if(id < 0) + if (id < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual decrement operation */ - if((ret_value = H5I_dec_app_ref(id)) < 0) + if ((ret_value = H5I_dec_app_ref(id)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") done: FUNC_LEAVE_API(ret_value) } /* end H5Idec_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_dec_ref * @@ -1353,8 +1324,8 @@ done: int H5I_dec_ref(hid_t id) { - H5I_id_info_t *id_ptr; /* Pointer to the new ID */ - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1362,7 +1333,7 @@ H5I_dec_ref(hid_t id) HDassert(id >= 0); /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) + if (NULL == (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* If this is the last reference to the object then invoke the type's @@ -1379,16 +1350,16 @@ H5I_dec_ref(hid_t id) * write when a dataset is closed and the chunk cache is flushed to the * file. We have to close the dataset anyway. (SLU - 2010/9/7) */ - if(1 == id_ptr->count) { - H5I_id_type_t *type_ptr; /*ptr to the type */ + if (1 == id_ptr->count) { + H5I_id_type_t *type_ptr; /*ptr to the type */ /* Get the ID's type */ type_ptr = H5I_id_type_list_g[H5I_TYPE(id)]; /* (Casting away const OK -QAK) */ - if(!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { + if (!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { /* Remove the node from the type */ - if(NULL == H5I__remove_common(type_ptr, id)) + if (NULL == H5I__remove_common(type_ptr, id)) HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") ret_value = 0; } /* end if */ @@ -1404,7 +1375,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_dec_app_ref * @@ -1422,8 +1392,8 @@ done: int H5I_dec_app_ref(hid_t id) { - H5I_id_info_t *id_ptr; /* Pointer to the new ID */ - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1431,13 +1401,13 @@ H5I_dec_app_ref(hid_t id) HDassert(id >= 0); /* Call regular decrement reference count routine */ - if((ret_value = H5I_dec_ref(id)) < 0) + if ((ret_value = H5I_dec_ref(id)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") /* Check if the ID still exists */ - if(ret_value > 0) { + if (ret_value > 0) { /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) + if (NULL == (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Adjust app_ref */ @@ -1452,7 +1422,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_app_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_dec_app_ref_always_close * @@ -1467,7 +1436,7 @@ done: int H5I_dec_app_ref_always_close(hid_t id) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1494,7 +1463,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_app_ref_always_close() */ - /*------------------------------------------------------------------------- * Function: H5Iinc_ref * @@ -1508,7 +1476,7 @@ done: int H5Iinc_ref(hid_t id) { - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); @@ -1525,7 +1493,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_inc_ref * @@ -1539,8 +1506,8 @@ done: int H5I_inc_ref(hid_t id, hbool_t app_ref) { - H5I_id_info_t *id_ptr; /* Pointer to the ID */ - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1563,7 +1530,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_inc_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iget_ref * @@ -1577,7 +1543,7 @@ done: int H5Iget_ref(hid_t id) { - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); @@ -1594,7 +1560,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_get_ref * @@ -1608,8 +1573,8 @@ done: int H5I_get_ref(hid_t id, hbool_t app_ref) { - H5I_id_info_t *id_ptr; /* Pointer to the ID */ - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1627,7 +1592,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iinc_type_ref * @@ -1641,26 +1605,25 @@ done: int H5Iinc_type_ref(H5I_type_t type) { - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ - if(type <= 0 || (int)type >= H5I_next_type) + if (type <= 0 || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual increment operation */ - if((ret_value = H5I__inc_type_ref(type)) < 0) + if ((ret_value = H5I__inc_type_ref(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID type ref count") done: FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ - /*------------------------------------------------------------------------- * Function: H5I__inc_type_ref * @@ -1674,8 +1637,8 @@ done: static int H5I__inc_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the type */ - int ret_value = -1; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1684,7 +1647,7 @@ H5I__inc_type_ref(H5I_type_t type) /* Check arguments */ type_ptr = H5I_id_type_list_g[type]; - if(NULL == type_ptr) + if (NULL == type_ptr) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Set return value */ @@ -1694,7 +1657,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__inc_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Idec_type_ref * @@ -1722,7 +1684,7 @@ done: herr_t H5Idec_type_ref(H5I_type_t type) { - herr_t ret_value = 0; /* Return value */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("e", "It", type); @@ -1736,7 +1698,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Idec_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_dec_type_ref * @@ -1759,16 +1720,16 @@ done: int H5I_dec_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - herr_t ret_value = 0; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the ID type */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) + if (type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Decrement the number of users of the atomic type. If this is the @@ -1776,7 +1737,7 @@ H5I_dec_type_ref(H5I_type_t type) * free all memory it used. The free function is invoked for each atom * being freed. */ - if(1 == type_ptr->init_count) { + if (1 == type_ptr->init_count) { H5I__destroy_type(type); ret_value = 0; } /* end if */ @@ -1789,7 +1750,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iget_type_ref * @@ -1803,26 +1763,25 @@ done: int H5Iget_type_ref(H5I_type_t type) { - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ - if(type <= 0 || (int)type >= H5I_next_type) + if (type <= 0 || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual retrieve operation */ - if((ret_value = H5I__get_type_ref(type)) < 0) + if ((ret_value = H5I__get_type_ref(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID type ref count") done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_ref() */ - /*------------------------------------------------------------------------- * Function: H5I__get_type_ref * @@ -1837,8 +1796,8 @@ done: static int H5I__get_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the type */ - int ret_value = -1; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1857,7 +1816,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__get_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iis_valid * @@ -1871,8 +1829,8 @@ done: htri_t H5Iis_valid(hid_t id) { - H5I_id_info_t *id_ptr; /* ptr to the ID */ - htri_t ret_value = TRUE; /* Return value */ + H5I_id_info_t *id_ptr; /* ptr to the ID */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", id); @@ -1887,7 +1845,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iis_valid() */ - /*------------------------------------------------------------------------- * Function: H5I__search_cb * @@ -1903,26 +1860,25 @@ done: static int H5I__search_cb(void *obj, hid_t id, void *_udata) { - H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ - herr_t cb_ret_val; /* User callback return value */ - int ret_value = H5_ITER_ERROR; /* Callback return value */ + H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ FUNC_ENTER_STATIC_NOERR cb_ret_val = (*udata->app_cb)(obj, id, udata->app_key); /* Set the return value based on the callback's return value */ - if(cb_ret_val > 0) { - ret_value = H5_ITER_STOP; /* terminate iteration early */ - udata->ret_obj = obj; /* also set out parameter */ + if (cb_ret_val > 0) { + ret_value = H5_ITER_STOP; /* terminate iteration early */ + udata->ret_obj = obj; /* also set out parameter */ } - else if(cb_ret_val < 0) - ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__search_cb() */ - /*------------------------------------------------------------------------- * Function: H5Isearch * @@ -1946,8 +1902,8 @@ H5I__search_cb(void *obj, hid_t id, void *_udata) void * H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) { - H5I_search_ud_t udata; /* Context for iteration */ - void *ret_value; /* Return value */ + H5I_search_ud_t udata; /* Context for iteration */ + void * ret_value; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE3("*x", "Itx*x", type, func, key); @@ -1957,7 +1913,7 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Set up udata struct */ - udata.app_cb = func; + udata.app_cb = func; udata.app_key = key; udata.ret_obj = NULL; @@ -1973,7 +1929,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Isearch() */ - /*------------------------------------------------------------------------- * Function: H5I__iterate_pub_cb * @@ -1993,9 +1948,9 @@ done: static int H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata) { - H5I_iterate_pub_ud_t *udata = (H5I_iterate_pub_ud_t *)_udata; /* User data for callback */ - herr_t cb_ret_val; /* User callback return value */ - int ret_value = H5_ITER_ERROR; /* Callback return value */ + H5I_iterate_pub_ud_t *udata = (H5I_iterate_pub_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -2003,17 +1958,16 @@ H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata) cb_ret_val = (*udata->op)(id, udata->op_data); /* Set the return value based on the callback's return value */ - if(cb_ret_val > 0) - ret_value = H5_ITER_STOP; /* terminate iteration early */ - else if(cb_ret_val < 0) - ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + if (cb_ret_val > 0) + ret_value = H5_ITER_STOP; /* terminate iteration early */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ else ret_value = H5_ITER_CONT; /* continue iteration */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__iterate_pub_cb() */ - /*------------------------------------------------------------------------- * Function: H5Iiterate * @@ -2040,15 +1994,15 @@ H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata) herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data) { - H5I_iterate_pub_ud_t int_udata; /* Internal user data */ - herr_t ret_value; /* Return value */ + H5I_iterate_pub_ud_t int_udata; /* Internal user data */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "Itx*x", type, op, op_data); /* Set up udata struct */ - int_udata.op = op; - int_udata.op_data = op_data; + int_udata.op = op; + int_udata.op_data = op_data; /* Note that H5I_iterate returns an error code. We ignore it * here, as we can't do anything with it without revising the API. @@ -2060,7 +2014,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iiterate() */ - /*------------------------------------------------------------------------- * Function: H5I__iterate_cb * @@ -2076,19 +2029,19 @@ done: static int H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + H5I_id_info_t * item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR /* Only invoke the callback function if this ID is visible externally and * its reference count is positive. */ - if((!udata->app_ref) || (item->app_count > 0)) { - H5I_type_t type = udata->obj_type; - void *obj_ptr; - herr_t cb_ret_val; + if ((!udata->app_ref) || (item->app_count > 0)) { + H5I_type_t type = udata->obj_type; + void * obj_ptr; + herr_t cb_ret_val; /* The stored object pointer might be an H5VL_object_t, in which * case we'll need to get the wrapped object struct (H5F_t *, etc.). @@ -2096,19 +2049,19 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) obj_ptr = H5I__unwrap((void *)item->obj_ptr, type); /* Invoke callback function */ - cb_ret_val = (*udata->user_func)((void *)obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ + cb_ret_val = + (*udata->user_func)((void *)obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ /* Set the return value based on the callback's return value */ - if(cb_ret_val > 0) - ret_value = H5_ITER_STOP; /* terminate iteration early */ - else if(cb_ret_val < 0) - ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ - } /* end if */ + if (cb_ret_val > 0) + ret_value = H5_ITER_STOP; /* terminate iteration early */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5I_iterate * @@ -2138,28 +2091,28 @@ herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref) { H5I_id_type_t *type_ptr; /* Pointer to the type */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; /* Only iterate through ID list if it is initialized and there are IDs in type */ - if(type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { - H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ - herr_t iter_status; /* Iteration status */ + if (type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { + H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ + herr_t iter_status; /* Iteration status */ /* Set up iterator user data */ - iter_udata.user_func = func; - iter_udata.user_udata = udata; - iter_udata.app_ref = app_ref; - iter_udata.obj_type = type; + iter_udata.user_func = func; + iter_udata.user_udata = udata; + iter_udata.app_ref = app_ref; + iter_udata.obj_type = type; /* Iterate over IDs */ - if((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) + if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") } /* end if */ @@ -2167,7 +2120,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_iterate() */ - /*------------------------------------------------------------------------- * Function: H5I__find_id * @@ -2183,22 +2135,22 @@ done: static H5I_id_info_t * H5I__find_id(hid_t id) { - H5I_type_t type; /*ID's type */ - H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *ret_value = NULL; /* Return value */ + H5I_type_t type; /*ID's type */ + H5I_id_type_t *type_ptr; /*ptr to the type */ + H5I_id_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments */ type = H5I_TYPE(id); - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_DONE(NULL) type_ptr = H5I_id_type_list_g[type]; - if(!type_ptr || type_ptr->init_count <= 0) + if (!type_ptr || type_ptr->init_count <= 0) HGOTO_DONE(NULL) /* Check for same ID as we have looked up last time */ - if(type_ptr->last_info && type_ptr->last_info->id == id) + if (type_ptr->last_info && type_ptr->last_info->id == id) ret_value = type_ptr->last_info; else { /* Locate the ID node for the ID */ @@ -2212,7 +2164,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__find_id() */ - /*------------------------------------------------------------------------- * Function: H5Iget_name * @@ -2238,32 +2189,32 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Iget_name(hid_t id, char *name/*out*/, size_t size) +H5Iget_name(hid_t id, char *name /*out*/, size_t size) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - ssize_t ret_value; /* Return value */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", id, name, size); /* Get the object pointer */ - if(NULL == (vol_obj = H5VL_vol_object(id))) + if (NULL == (vol_obj = H5VL_vol_object(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); /* Retrieve object's name */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value, name, size) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_name() */ - /*------------------------------------------------------------------------- * Function: H5Iget_file_id * @@ -2279,8 +2230,8 @@ done: hid_t H5Iget_file_id(hid_t obj_id) { - H5I_type_t type; /* ID type */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5I_type_t type; /* ID type */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", obj_id); @@ -2289,15 +2240,16 @@ H5Iget_file_id(hid_t obj_id) type = H5I_TYPE(obj_id); /* Call internal function */ - if(H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { - H5VL_object_t *vol_obj; /* Object of obj_id */ + if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || + H5I_ATTR == type) { + H5VL_object_t *vol_obj; /* Object of obj_id */ /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get the file ID */ - if((ret_value = H5F_get_file_id(vol_obj, type, TRUE)) < 0) + if ((ret_value = H5F_get_file_id(vol_obj, type, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") } /* end if */ else @@ -2307,7 +2259,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_file_id() */ - /*------------------------------------------------------------------------- * Function: H5I__find_id_cb * @@ -2321,11 +2272,11 @@ done: static int H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_get_id_ud_t *udata = (H5I_get_id_ud_t *)_udata; /* Pointer to user data */ - H5I_type_t type = udata->obj_type; - const void *obj_ptr = NULL; - int ret_value = H5_ITER_CONT; /* Return value */ + H5I_id_info_t * item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_get_id_ud_t *udata = (H5I_get_id_ud_t *)_udata; /* Pointer to user data */ + H5I_type_t type = udata->obj_type; + const void * obj_ptr = NULL; + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -2339,13 +2290,12 @@ H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /* Check for a match */ if (obj_ptr == udata->object) { udata->ret_id = item->id; - ret_value = H5_ITER_STOP; + ret_value = H5_ITER_STOP; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__find_id_cb() */ - /*------------------------------------------------------------------------- * Function: H5I_find_id * @@ -2360,8 +2310,8 @@ H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) herr_t H5I_find_id(const void *object, H5I_type_t type, hid_t *id) { - H5I_id_type_t *type_ptr; /* Pointer to the type */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2375,13 +2325,13 @@ H5I_find_id(const void *object, H5I_type_t type, hid_t *id) /* Only iterate through ID list if it is initialized and there are IDs in type */ if (type_ptr->init_count > 0 && type_ptr->id_count > 0) { - H5I_get_id_ud_t udata; /* User data */ - herr_t iter_status; /* Iteration status */ + H5I_get_id_ud_t udata; /* User data */ + herr_t iter_status; /* Iteration status */ /* Set up iterator user data */ - udata.object = object; - udata.obj_type = type; - udata.ret_id = H5I_INVALID_HID; + udata.object = object; + udata.obj_type = type; + udata.ret_id = H5I_INVALID_HID; /* Iterate over IDs for the ID type */ if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__find_id_cb, &udata)) < 0) @@ -2394,7 +2344,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_find_id() */ - /*------------------------------------------------------------------------- * Function: H5I__id_dump_cb * @@ -2407,10 +2356,10 @@ done: static int H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ - H5G_name_t *path = NULL; /* Path to file object */ - const void *obj_ptr = NULL; /* Pointer to VOL connector object */ + H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ + H5G_name_t * path = NULL; /* Path to file object */ + const void * obj_ptr = NULL; /* Pointer to VOL connector object */ FUNC_ENTER_STATIC_NOERR @@ -2420,32 +2369,29 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /* Get the group location, so we get get the name */ switch (type) { - case H5I_GROUP: - { + case H5I_GROUP: { const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; obj_ptr = H5VL_object_data(vol_obj); - if(H5_VOL_NATIVE == vol_obj->connector->cls->value) + if (H5_VOL_NATIVE == vol_obj->connector->cls->value) path = H5G_nameof((const H5G_t *)obj_ptr); break; } - case H5I_DATASET: - { + case H5I_DATASET: { const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; obj_ptr = H5VL_object_data(vol_obj); - if(H5_VOL_NATIVE == vol_obj->connector->cls->value) + if (H5_VOL_NATIVE == vol_obj->connector->cls->value) path = H5D_nameof((const H5D_t *)obj_ptr); break; } - case H5I_DATATYPE: - { + case H5I_DATATYPE: { const H5T_t *dt = (const H5T_t *)item->obj_ptr; obj_ptr = (void *)H5T_get_actual_type((H5T_t *)dt); /* Casting away const OK - QAK */ - path = H5T_nameof((const H5T_t *)obj_ptr); + path = H5T_nameof((const H5T_t *)obj_ptr); break; } @@ -2469,7 +2415,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) case H5I_SPACE_SEL_ITER: case H5I_NTYPES: default: - break; /* Other types of IDs are not stored in files */ + break; /* Other types of IDs are not stored in files */ } if (path) { @@ -2482,7 +2428,6 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* end H5I__id_dump_cb() */ - /*------------------------------------------------------------------------- * Function: H5I_dump_ids_for_type * @@ -2495,14 +2440,14 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) herr_t H5I_dump_ids_for_type(H5I_type_t type) { - H5I_id_type_t *type_ptr = NULL; + H5I_id_type_t *type_ptr = NULL; FUNC_ENTER_NOAPI_NOERR HDfprintf(stderr, "Dumping ID type %d\n", (int)type); type_ptr = H5I_id_type_list_g[type]; - if(type_ptr) { + if (type_ptr) { /* Header */ HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); @@ -2511,7 +2456,7 @@ H5I_dump_ids_for_type(H5I_type_t type) HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); /* List */ - if(type_ptr->id_count > 0) { + if (type_ptr->id_count > 0) { HDfprintf(stderr, " List:\n"); H5SL_iterate(type_ptr->ids, H5I__id_dump_cb, &type); } @@ -2521,4 +2466,3 @@ H5I_dump_ids_for_type(H5I_type_t type) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5I_dump_ids_for_type() */ - diff --git a/src/H5Imodule.h b/src/H5Imodule.h index 60bda5a..d26bb71 100644 --- a/src/H5Imodule.h +++ b/src/H5Imodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5I_MODULE -#define H5_MY_PKG H5I -#define H5_MY_PKG_ERR H5E_ATOM -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5I +#define H5_MY_PKG_ERR H5E_ATOM +#define H5_MY_PKG_INIT NO #endif /* _H5Imodule_H */ - diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index 2c1d81f..13ae793 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -41,8 +41,8 @@ * type). This is the only number that must be changed since all other bit * field sizes and masks are calculated from TYPE_BITS. */ -#define TYPE_BITS 7 -#define TYPE_MASK (((hid_t)1 << TYPE_BITS) - 1) +#define TYPE_BITS 7 +#define TYPE_MASK (((hid_t)1 << TYPE_BITS) - 1) #define H5I_MAX_NUM_TYPES TYPE_MASK @@ -50,12 +50,11 @@ * Number of bits to use for the Atom index in each atom (assumes 8-bit * bytes). We don't use the sign bit. */ -#define ID_BITS ((sizeof(hid_t) * 8) - (TYPE_BITS + 1)) -#define ID_MASK (((hid_t)1 << ID_BITS) - 1) +#define ID_BITS ((sizeof(hid_t) * 8) - (TYPE_BITS + 1)) +#define ID_MASK (((hid_t)1 << ID_BITS) - 1) /* Map an atom to an ID type number */ -#define H5I_TYPE(a) ((H5I_type_t)(((hid_t)(a) >> ID_BITS) & TYPE_MASK)) - +#define H5I_TYPE(a) ((H5I_type_t)(((hid_t)(a) >> ID_BITS) & TYPE_MASK)) /****************************/ /* Package Private Typedefs */ @@ -67,8 +66,7 @@ /* Testing functions */ #ifdef H5I_TESTING -H5_DLL ssize_t H5I__get_name_test(hid_t id, char *name/*out*/, size_t size, - hbool_t *cached); +H5_DLL ssize_t H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached); #endif /* H5I_TESTING */ #endif /*_H5Ipkg_H*/ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index cc1ce1f..d4d1721 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -32,50 +32,47 @@ /**************************/ /* Macro to determine if a H5I_type_t is a "library type" */ -#define H5I_IS_LIB_TYPE( type ) (type > 0 && type < H5I_NTYPES) +#define H5I_IS_LIB_TYPE(type) (type > 0 && type < H5I_NTYPES) /* Flags for ID class */ -#define H5I_CLASS_IS_APPLICATION 0x01 - +#define H5I_CLASS_IS_APPLICATION 0x01 /****************************/ /* Library Private Typedefs */ /****************************/ typedef struct H5I_class_t { - H5I_type_t type_id; /* Class ID for the type */ - unsigned flags; /* Class behavior flags */ - unsigned reserved; /* Number of reserved IDs for this type */ - /* [A specific number of type entries may be - * reserved to enable "constant" values to be - * handed out which are valid IDs in the type, - * but which do not map to any data structures - * and are not allocated dynamically later.] - */ - H5I_free_t free_func; /* Free function for object's of this type */ + H5I_type_t type_id; /* Class ID for the type */ + unsigned flags; /* Class behavior flags */ + unsigned reserved; /* Number of reserved IDs for this type */ + /* [A specific number of type entries may be + * reserved to enable "constant" values to be + * handed out which are valid IDs in the type, + * but which do not map to any data structures + * and are not allocated dynamically later.] + */ + H5I_free_t free_func; /* Free function for object's of this type */ } H5I_class_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL herr_t H5I_register_type(const H5I_class_t *cls); -H5_DLL int64_t H5I_nmembers(H5I_type_t type); -H5_DLL herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref); +H5_DLL herr_t H5I_register_type(const H5I_class_t *cls); +H5_DLL int64_t H5I_nmembers(H5I_type_t type); +H5_DLL herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref); H5_DLL H5I_type_t H5I_get_type(hid_t id); -H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); -H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); -H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); -H5_DLL int H5I_dec_ref(hid_t id); -H5_DLL int H5I_dec_app_ref(hid_t id); -H5_DLL int H5I_dec_app_ref_always_close(hid_t id); -H5_DLL int H5I_dec_type_ref(H5I_type_t type); -H5_DLL herr_t H5I_find_id(const void *object, H5I_type_t type, hid_t *id /*out*/); +H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); +H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); +H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); +H5_DLL int H5I_dec_ref(hid_t id); +H5_DLL int H5I_dec_app_ref(hid_t id); +H5_DLL int H5I_dec_app_ref_always_close(hid_t id); +H5_DLL int H5I_dec_type_ref(H5I_type_t type); +H5_DLL herr_t H5I_find_id(const void *object, H5I_type_t type, hid_t *id /*out*/); /* NOTE: The object and ID functions below deal in non-VOL objects (i.e.; * H5S_t, etc.). Similar VOL calls exist in H5VLprivate.h. Use @@ -88,18 +85,18 @@ H5_DLL herr_t H5I_find_id(const void *object, H5I_type_t type, hid_t *id /*out*/ */ /* Functions that manipulate objects */ -H5_DLL void *H5I_object(hid_t id); -H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); -H5_DLL void *H5I_remove(hid_t id); -H5_DLL void *H5I_subst(hid_t id, const void *new_object); +H5_DLL void * H5I_object(hid_t id); +H5_DLL void * H5I_object_verify(hid_t id, H5I_type_t id_type); +H5_DLL void * H5I_remove(hid_t id); +H5_DLL void * H5I_subst(hid_t id, const void *new_object); H5_DLL htri_t H5I_is_file_object(hid_t id); /* ID registration functions */ -H5_DLL hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref); -H5_DLL herr_t H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, hid_t existing_id); +H5_DLL hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref); +H5_DLL herr_t H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, + hid_t existing_id); /* Debugging functions */ H5_DLL herr_t H5I_dump_ids_for_type(H5I_type_t type); #endif /* _H5Iprivate_H */ - diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 34a408f..433671b 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -31,32 +31,32 @@ * to verify that the H5I{inc|dec|get}_ref() routines work correctly with it. */ typedef enum H5I_type_t { - H5I_UNINIT = (-2), /* uninitialized type */ - H5I_BADID = (-1), /* invalid Type */ - H5I_FILE = 1, /* type ID for File objects */ - H5I_GROUP, /* type ID for Group objects */ - H5I_DATATYPE, /* type ID for Datatype objects */ - H5I_DATASPACE, /* type ID for Dataspace objects */ - H5I_DATASET, /* type ID for Dataset objects */ - H5I_MAP, /* type ID for Map objects */ - H5I_ATTR, /* type ID for Attribute objects */ - H5I_VFL, /* type ID for virtual file layer */ - H5I_VOL, /* type ID for virtual object layer */ - H5I_GENPROP_CLS, /* type ID for generic property list classes */ - H5I_GENPROP_LST, /* type ID for generic property lists */ - H5I_ERROR_CLASS, /* type ID for error classes */ - H5I_ERROR_MSG, /* type ID for error messages */ - H5I_ERROR_STACK, /* type ID for error stacks */ - H5I_SPACE_SEL_ITER, /* type ID for dataspace selection iterator */ - H5I_NTYPES /* number of library types, MUST BE LAST! */ + H5I_UNINIT = (-2), /* uninitialized type */ + H5I_BADID = (-1), /* invalid Type */ + H5I_FILE = 1, /* type ID for File objects */ + H5I_GROUP, /* type ID for Group objects */ + H5I_DATATYPE, /* type ID for Datatype objects */ + H5I_DATASPACE, /* type ID for Dataspace objects */ + H5I_DATASET, /* type ID for Dataset objects */ + H5I_MAP, /* type ID for Map objects */ + H5I_ATTR, /* type ID for Attribute objects */ + H5I_VFL, /* type ID for virtual file layer */ + H5I_VOL, /* type ID for virtual object layer */ + H5I_GENPROP_CLS, /* type ID for generic property list classes */ + H5I_GENPROP_LST, /* type ID for generic property lists */ + H5I_ERROR_CLASS, /* type ID for error classes */ + H5I_ERROR_MSG, /* type ID for error messages */ + H5I_ERROR_STACK, /* type ID for error stacks */ + H5I_SPACE_SEL_ITER, /* type ID for dataspace selection iterator */ + H5I_NTYPES /* number of library types, MUST BE LAST! */ } H5I_type_t; /* Type of atoms to return to users */ typedef int64_t hid_t; -#define H5_SIZEOF_HID_T H5_SIZEOF_INT64_T +#define H5_SIZEOF_HID_T H5_SIZEOF_INT64_T /* An invalid object ID. This is also negative for error return. */ -#define H5I_INVALID_HID (-1) +#define H5I_INVALID_HID (-1) /* * Function for freeing objects. This function will be called with an object @@ -79,29 +79,28 @@ extern "C" { /* Public API functions */ -H5_DLL hid_t H5Iregister(H5I_type_t type, const void *object); -H5_DLL void *H5Iobject_verify(hid_t id, H5I_type_t id_type); -H5_DLL void *H5Iremove_verify(hid_t id, H5I_type_t id_type); +H5_DLL hid_t H5Iregister(H5I_type_t type, const void *object); +H5_DLL void * H5Iobject_verify(hid_t id, H5I_type_t id_type); +H5_DLL void * H5Iremove_verify(hid_t id, H5I_type_t id_type); H5_DLL H5I_type_t H5Iget_type(hid_t id); -H5_DLL hid_t H5Iget_file_id(hid_t id); -H5_DLL ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size); -H5_DLL int H5Iinc_ref(hid_t id); -H5_DLL int H5Idec_ref(hid_t id); -H5_DLL int H5Iget_ref(hid_t id); +H5_DLL hid_t H5Iget_file_id(hid_t id); +H5_DLL ssize_t H5Iget_name(hid_t id, char *name /*out*/, size_t size); +H5_DLL int H5Iinc_ref(hid_t id); +H5_DLL int H5Idec_ref(hid_t id); +H5_DLL int H5Iget_ref(hid_t id); H5_DLL H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func); -H5_DLL herr_t H5Iclear_type(H5I_type_t type, hbool_t force); -H5_DLL herr_t H5Idestroy_type(H5I_type_t type); -H5_DLL int H5Iinc_type_ref(H5I_type_t type); -H5_DLL int H5Idec_type_ref(H5I_type_t type); -H5_DLL int H5Iget_type_ref(H5I_type_t type); -H5_DLL void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); -H5_DLL herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); -H5_DLL herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members); -H5_DLL htri_t H5Itype_exists(H5I_type_t type); -H5_DLL htri_t H5Iis_valid(hid_t id); +H5_DLL herr_t H5Iclear_type(H5I_type_t type, hbool_t force); +H5_DLL herr_t H5Idestroy_type(H5I_type_t type); +H5_DLL int H5Iinc_type_ref(H5I_type_t type); +H5_DLL int H5Idec_type_ref(H5I_type_t type); +H5_DLL int H5Iget_type_ref(H5I_type_t type); +H5_DLL void * H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); +H5_DLL herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); +H5_DLL herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members); +H5_DLL htri_t H5Itype_exists(H5I_type_t type); +H5_DLL htri_t H5Iis_valid(hid_t id); #ifdef __cplusplus } #endif #endif /* _H5Ipublic_H */ - diff --git a/src/H5Itest.c b/src/H5Itest.c index 07c1965..8bd03f0 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -21,47 +21,39 @@ /* Module Setup */ /****************/ -#include "H5Imodule.h" /* This source code file is part of the H5I module */ -#define H5I_TESTING /*suppress warning about H5I testing funcs*/ - +#include "H5Imodule.h" /* This source code file is part of the H5I module */ +#define H5I_TESTING /*suppress warning about H5I testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Ipkg.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5I__get_name_test * @@ -76,46 +68,45 @@ *------------------------------------------------------------------------- */ ssize_t -H5I__get_name_test(hid_t id, char *name/*out*/, size_t size, hbool_t *cached) +H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached) { - H5VL_object_t *vol_obj; /* Object of id */ - H5G_loc_t loc; /* Object location */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - hbool_t vol_wrapper_set = FALSE;/* Whether the VOL object wrapping context was set up */ - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t *vol_obj; /* Object of id */ + H5G_loc_t loc; /* Object location */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set API context") api_ctx_pushed = TRUE; /* Get the object pointer */ - if(NULL == (vol_obj = H5VL_vol_object(id))) + if (NULL == (vol_obj = H5VL_vol_object(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Get object location */ - if(H5G_loc(id, &loc) < 0) + if (H5G_loc(id, &loc) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") /* Call internal group routine to retrieve object's name */ - if((ret_value = H5G_get_name(&loc, name, size, cached)) < 0) + if ((ret_value = H5G_get_name(&loc, name, size, cached)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, (-1), "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__get_name_test() */ - diff --git a/src/H5L.c b/src/H5L.c index 4ef045d..8838be9 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -15,8 +15,7 @@ /* Module Setup */ /****************/ -#include "H5Lmodule.h" /* This source code file is part of the H5L module */ - +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ /***********/ /* Headers */ @@ -42,103 +41,94 @@ #define H5L_MIN_TABLE_SIZE 32 /* Minimum size of the user-defined link type table if it is allocated */ - /******************/ /* Local Typedefs */ /******************/ /* User data for path traversal routine for getting link info by name */ typedef struct { - H5L_info2_t *linfo; /* Buffer to return to user */ + H5L_info2_t *linfo; /* Buffer to return to user */ } H5L_trav_gi_t; /* User data for path traversal callback to creating a link */ typedef struct { - H5F_t *file; /* Pointer to the file */ - H5P_genplist_t *lc_plist; /* Link creation property list */ - H5G_name_t *path; /* Path to object being linked */ - H5O_obj_create_t *ocrt_info; /* Pointer to object creation info */ - H5O_link_t *lnk; /* Pointer to link information to insert */ + H5F_t * file; /* Pointer to the file */ + H5P_genplist_t * lc_plist; /* Link creation property list */ + H5G_name_t * path; /* Path to object being linked */ + H5O_obj_create_t *ocrt_info; /* Pointer to object creation info */ + H5O_link_t * lnk; /* Pointer to link information to insert */ } H5L_trav_cr_t; /* User data for path traversal routine for moving and renaming a link */ typedef struct { - const char *dst_name; /* Destination name for moving object */ - H5T_cset_t cset; /* Char set for new name */ - const H5G_loc_t *dst_loc; /* Destination location for moving object */ - unsigned dst_target_flags; /* Target flags for destination object */ - hbool_t copy; /* TRUE if this is a copy operation */ - size_t orig_nlinks; /* The original value for the # of soft / UD links that can be traversed */ + const char * dst_name; /* Destination name for moving object */ + H5T_cset_t cset; /* Char set for new name */ + const H5G_loc_t *dst_loc; /* Destination location for moving object */ + unsigned dst_target_flags; /* Target flags for destination object */ + hbool_t copy; /* TRUE if this is a copy operation */ + size_t orig_nlinks; /* The original value for the # of soft / UD links that can be traversed */ } H5L_trav_mv_t; /* User data for path traversal routine for moving and renaming an object */ typedef struct { - H5F_t *file; /* Pointer to the file */ - H5O_link_t *lnk; /* Pointer to link information to insert */ - hbool_t copy; /* TRUE if this is a copy operation */ + H5F_t * file; /* Pointer to the file */ + H5O_link_t *lnk; /* Pointer to link information to insert */ + hbool_t copy; /* TRUE if this is a copy operation */ } H5L_trav_mv2_t; /* User data for path traversal routine for checking if a link exists */ typedef struct { /* Down */ - char *sep; /* Pointer to next separator in the string */ + char *sep; /* Pointer to next separator in the string */ /* Up */ - hbool_t exists; /* Whether the link exists or not */ + hbool_t exists; /* Whether the link exists or not */ } H5L_trav_le_t; /* User data for path traversal routine for getting link value */ typedef struct { - size_t size; /* Size of user buffer */ - void *buf; /* User buffer */ + size_t size; /* Size of user buffer */ + void * buf; /* User buffer */ } H5L_trav_gv_t; - /********************/ /* Local Prototypes */ /********************/ -static int H5L_find_class_idx(H5L_type_t id); -static herr_t H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, - H5G_name_t *obj_path, H5F_t *obj_file, H5O_link_t *lnk, H5O_obj_create_t *ocrt_info, - hid_t lcpl_id); +static int H5L_find_class_idx(H5L_type_t id); +static herr_t H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path, + H5F_t *obj_file, H5O_link_t *lnk, H5O_obj_create_t *ocrt_info, hid_t lcpl_id); static herr_t H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size); -static herr_t H5L__get_val_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__get_val_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__delete_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__get_info_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__get_info_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc/*in*/, - const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); +static herr_t H5L__get_val_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_val_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__delete_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_info_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_info_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); /*********************/ /* Package Variables */ @@ -147,22 +137,19 @@ static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc/*in*/, /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Information about user-defined links */ -static size_t H5L_table_alloc_g = 0; -static size_t H5L_table_used_g = 0; -static H5L_class_t *H5L_table_g = NULL; +static size_t H5L_table_alloc_g = 0; +static size_t H5L_table_used_g = 0; +static H5L_class_t *H5L_table_g = NULL; - /*------------------------------------------------------------------------- * Function: H5L_init * @@ -180,7 +167,7 @@ static H5L_class_t *H5L_table_g = NULL; herr_t H5L_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -189,7 +176,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_init() */ - /*------------------------------------------------------------------------- * Function: H5L__init_package * @@ -205,19 +191,18 @@ done: herr_t H5L__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize user-defined link classes */ - if(H5L_register_external() < 0) + if (H5L_register_external() < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register external link class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_init_package() */ - /*------------------------------------------------------------------------- * Function: H5L_term_package * @@ -233,27 +218,26 @@ done: int H5L_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Free the table of link types */ - if(H5L_table_g) { - H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); + if (H5L_table_g) { + H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); H5L_table_used_g = H5L_table_alloc_g = 0; n++; } /* end if */ /* Mark the interface as uninitialized */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5L_term_package() */ - /*------------------------------------------------------------------------- * Function: H5Lmove * @@ -272,53 +256,53 @@ H5L_term_package(void) *------------------------------------------------------------------------- */ herr_t -H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name, hid_t lcpl_id, hid_t lapl_id) +H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, + hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ - H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ - H5VL_loc_params_t loc_params2; - H5VL_object_t tmp_vol_obj; /* Temporary object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj1 = NULL; /* Object of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t * vol_obj2 = NULL; /* Object of dst_id */ + H5VL_loc_params_t loc_params2; + H5VL_object_t tmp_vol_obj; /* Temporary object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id, lapl_id); /* Check arguments */ - if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) + if (src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(!src_name || !*src_name) + if (!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!dst_name || !*dst_name) + if (!dst_name || !*dst_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Check the link create property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, - ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < + 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Set location parameter for source object */ - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.loc_data.loc_by_name.name = src_name; - loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params1.obj_type = H5I_get_type(src_loc_id); + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.obj_type = H5I_get_type(src_loc_id); /* Set location parameter for destination object */ - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.loc_data.loc_by_name.name = dst_name; - loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params2.obj_type = H5I_get_type(dst_loc_id); + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params2.obj_type = H5I_get_type(dst_loc_id); if (H5L_SAME_LOC != src_loc_id) /* Get the location object */ @@ -332,21 +316,22 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Make sure that the VOL connectors are the same */ if (vol_obj1 && vol_obj2) if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "Objects are accessed through different VOL connectors and can't be linked") /* Construct a temporary source VOL object */ - tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); + tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); tmp_vol_obj.connector = (vol_obj1 ? vol_obj1->connector : vol_obj2->connector); /* Move the link */ - if(H5VL_link_move(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_link_move(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lmove() */ - /*------------------------------------------------------------------------- * Function: H5Lcopy * @@ -362,81 +347,82 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name, hid_t lcpl_id, hid_t lapl_id) +H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, + hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ - H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ - H5VL_loc_params_t loc_params2; - H5VL_object_t tmp_vol_obj; /* Temporary object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj1 = NULL; /* Object of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t * vol_obj2 = NULL; /* Object of dst_id */ + H5VL_loc_params_t loc_params2; + H5VL_object_t tmp_vol_obj; /* Temporary object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id, lapl_id); /* Check arguments */ - if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) + if (src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(!src_name || !*src_name) + if (!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!dst_name || !*dst_name) + if (!dst_name || !*dst_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Check the link create property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, - ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < + 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Set location parameter for source object */ - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.loc_data.loc_by_name.name = src_name; - loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params1.obj_type = H5I_get_type(src_loc_id); + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.obj_type = H5I_get_type(src_loc_id); /* Set location parameter for destination object */ - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.loc_data.loc_by_name.name = dst_name; - loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params2.obj_type = H5I_get_type(dst_loc_id); + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params2.obj_type = H5I_get_type(dst_loc_id); - if(H5L_SAME_LOC != src_loc_id) + if (H5L_SAME_LOC != src_loc_id) /* Get the location object */ - if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(H5L_SAME_LOC != dst_loc_id) + if (H5L_SAME_LOC != dst_loc_id) /* Get the location object */ - if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL connectors are the same */ - if(vol_obj1 && vol_obj2) - if(vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + if (vol_obj1 && vol_obj2) + if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "Objects are accessed through different VOL connectors and can't be linked") /* Construct a temporary source VOL object */ - tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); + tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); tmp_vol_obj.connector = (vol_obj1 ? vol_obj1->connector : vol_obj2->connector); /* Copy the link */ - if(H5VL_link_copy(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_link_copy(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to copy link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcopy() */ - /*------------------------------------------------------------------------- * Function: H5Lcreate_soft * @@ -456,39 +442,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, - hid_t lcpl_id, hid_t lapl_id) +H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, + hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*si*sii", link_target, link_loc_id, link_name, lcpl_id, lapl_id); /* Check arguments */ - if(link_loc_id == H5L_SAME_LOC) + if (link_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link location id should not be H5L_SAME_LOC") - if(!link_target) + if (!link_target) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_target parameter cannot be NULL") - if(!*link_target) + if (!*link_target) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_target parameter cannot be an empty string") - if(!link_name) + if (!link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_name parameter cannot be NULL") - if(!*link_name) + if (!*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_name parameter cannot be an empty string") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Get the link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Set location fields */ @@ -498,18 +484,18 @@ H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name loc_params.obj_type = H5I_get_type(link_loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(link_loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(link_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Create the link */ - if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, link_target) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, link_target) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create soft link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_soft() */ - /*------------------------------------------------------------------------- * Function: H5Lcreate_hard * @@ -527,83 +513,85 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, - hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) +H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, + hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* Object of cur_loc_id */ - H5VL_object_t *vol_obj2 = NULL; /* Object of new_loc_id */ - H5VL_object_t tmp_vol_obj; /* Temporary object */ - H5VL_loc_params_t loc_params1; - H5VL_loc_params_t loc_params2; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj1 = NULL; /* Object of cur_loc_id */ + H5VL_object_t * vol_obj2 = NULL; /* Object of new_loc_id */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id); /* Check arguments */ - if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) + if (cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") - if(!cur_name) + if (!cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be NULL") - if(!*cur_name) + if (!*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be an empty string") - if(!new_name) + if (!new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new_name parameter cannot be NULL") - if(!*new_name) + if (!*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new_name parameter cannot be an empty string") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Check the link create property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, cur_loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, cur_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Set up current & new location structs */ - loc_params1.type = H5VL_OBJECT_BY_NAME; - loc_params1.obj_type = H5I_get_type(cur_loc_id); - loc_params1.loc_data.loc_by_name.name = cur_name; - loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.obj_type = H5I_get_type(new_loc_id); - loc_params2.loc_data.loc_by_name.name = new_name; - loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; - if(H5L_SAME_LOC != cur_loc_id) + if (H5L_SAME_LOC != cur_loc_id) /* Get the current location object */ if (NULL == (vol_obj1 = (H5VL_object_t *)H5VL_vol_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(H5L_SAME_LOC != new_loc_id) + if (H5L_SAME_LOC != new_loc_id) /* Get the new location object */ - if(NULL == (vol_obj2 = (H5VL_object_t *)H5VL_vol_object(new_loc_id))) + if (NULL == (vol_obj2 = (H5VL_object_t *)H5VL_vol_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL connectors are the same */ - if(vol_obj1 && vol_obj2) - if(vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + if (vol_obj1 && vol_obj2) + if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "Objects are accessed through different VOL connectors and can't be linked") /* Construct a temporary VOL object */ - tmp_vol_obj.data = (vol_obj2 ? (vol_obj2->data) : NULL); + tmp_vol_obj.data = (vol_obj2 ? (vol_obj2->data) : NULL); tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector); /* Create the link */ - if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (vol_obj1 ? vol_obj1->data : NULL), &loc_params1) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (vol_obj1 ? vol_obj1->data : NULL), + &loc_params1) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create hard link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_hard() */ - /*------------------------------------------------------------------------- * Function: H5Lcreate_ud * @@ -629,54 +617,54 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, - const void *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id) +H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata, + size_t udata_size, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sLl*xzii", link_loc_id, link_name, link_type, udata, udata_size, lcpl_id, lapl_id); /* Check arguments */ - if(!link_name || !*link_name) + if (!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") - if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) + if (link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") - if(!udata && udata_size) + if (!udata && udata_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata cannot be NULL if udata_size is non-zero") /* Get the link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = link_name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(link_loc_id); + loc_params.obj_type = H5I_get_type(link_loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Create external link */ - if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, udata, udata_size) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, udata, udata_size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_ud() */ - /*------------------------------------------------------------------------- * Function: H5Ldelete * @@ -697,19 +685,19 @@ done: herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*si", loc_id, name, lapl_id); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill in the location struct fields */ @@ -719,18 +707,18 @@ H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Unlink */ - if(H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: FUNC_LEAVE_API(ret_value) } /* end H5Ldelete() */ - /*------------------------------------------------------------------------- * Function: H5Ldelete_by_idx * @@ -751,49 +739,49 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, hid_t lapl_id) +H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check arguments */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Delete the link */ - if(H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: FUNC_LEAVE_API(ret_value) } /* end H5Ldelete_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Lget_val * @@ -814,42 +802,41 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, - hid_t lapl_id) +H5Lget_val(hid_t loc_id, const char *name, void *buf /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sxzi", loc_id, name, buf, size, lapl_id); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.obj_type = H5I_get_type(loc_id); - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link value */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, + size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value for '%s'", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_val() */ - /*------------------------------------------------------------------------- * Function: H5Lget_val_by_idx * @@ -869,51 +856,50 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, - hid_t lapl_id) +H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + void *buf /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, buf, size, lapl_id); /* Check arguments */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link value */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, + size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_val_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Lexists * @@ -929,21 +915,21 @@ done: htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - htri_t ret_value = FAIL; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); /* Check arguments */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Set location struct fields */ @@ -953,18 +939,18 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check for the existence of the link */ - if(H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) } /* end H5Lexists() */ - /*------------------------------------------------------------------------- * Function: H5Lget_info2 * @@ -979,42 +965,41 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, - hid_t lapl_id) +H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.obj_type = H5I_get_type(loc_id); - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link information */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, linfo) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_info2() */ - /*------------------------------------------------------------------------- * Function: H5Lget_info_by_idx2 * @@ -1030,51 +1015,50 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info2_t *linfo /*out*/, hid_t lapl_id) +H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, lapl_id); /* Check arguments */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link information */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, linfo) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_info_by_idx2() */ - /*------------------------------------------------------------------------- * Function: H5Lregister * @@ -1097,14 +1081,14 @@ done: herr_t H5Lregister(const H5L_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", cls); /* Check args */ - if(cls == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") + if (cls == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") /* Check H5L_class_t version number; this is where a function to convert * from an outdated version should be called. @@ -1113,27 +1097,29 @@ H5Lregister(const H5L_class_t *cls) * traversal callback, which is handled in H5G_traverse_ud() * (in src/H5Gtraverse.c), so it's allowed to to pass through here. - QAK, 2018/02/06 */ - if(cls->version > H5L_LINK_CLASS_T_VERS) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5L_class_t version number") + if (cls->version > H5L_LINK_CLASS_T_VERS) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5L_class_t version number") #ifdef H5_NO_DEPRECATED_SYMBOLS - if(cls->version < H5L_LINK_CLASS_T_VERS) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "deprecated H5L_class_t version number (%d) and library built without deprecated symbol support", cls->version) + if (cls->version < H5L_LINK_CLASS_T_VERS) + HGOTO_ERROR( + H5E_ARGS, H5E_BADVALUE, FAIL, + "deprecated H5L_class_t version number (%d) and library built without deprecated symbol support", + cls->version) #endif /* H5_NO_DEPRECATED_SYMBOLS */ - if(cls->id < H5L_TYPE_UD_MIN || cls->id > H5L_TYPE_MAX) + if (cls->id < H5L_TYPE_UD_MIN || cls->id > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link identification number") - if(cls->trav_func == NULL) + if (cls->trav_func == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no traversal function specified") /* Do it */ - if(H5L_register(cls) < 0) + if (H5L_register(cls) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register link type") done: FUNC_LEAVE_API(ret_value) } /* end H5Lregister() */ - /*------------------------------------------------------------------------- * Function: H5Lunregister * @@ -1152,24 +1138,23 @@ done: herr_t H5Lunregister(H5L_type_t id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Ll", id); /* Check args */ - if(id < 0 || id > H5L_TYPE_MAX) + if (id < 0 || id > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link type") /* Do it */ - if(H5L_unregister(id) < 0) + if (H5L_unregister(id) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to unregister link type") done: FUNC_LEAVE_API(ret_value) } /* end H5Lunregister() */ - /*------------------------------------------------------------------------- * Function: H5Lis_registered * @@ -1188,19 +1173,19 @@ done: htri_t H5Lis_registered(H5L_type_t id) { - size_t i; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + size_t i; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "Ll", id); /* Check args */ - if(id < 0 || id > H5L_TYPE_MAX) + if (id < 0 || id > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link type id number") /* Is the link class already registered? */ - for(i = 0; i < H5L_table_used_g; i++) - if(H5L_table_g[i].id == id) { + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) { ret_value = TRUE; break; } /* end if */ @@ -1209,7 +1194,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Lis_registered() */ - /*------------------------------------------------------------------------- * Function: H5Lget_name_by_idx * @@ -1229,28 +1213,27 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Lget_name_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - char *name /*out*/, size_t size, hid_t lapl_id) +H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE8("Zs", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, name, size, lapl_id); /* Check arguments */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, (-1), "can't set access property list info") /* Fill in location struct fields */ @@ -1263,18 +1246,18 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Get the link information */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name, size, &ret_value) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + name, size, &ret_value) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, (-1), "unable to get link name") done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Literate2 * @@ -1294,13 +1277,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx_p, H5L_iterate2_t op, void *op_data) +H5Literate2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate2_t op, + void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5I_type_t id_type; /* Type of ID */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIo*hx*x", group_id, idx_type, order, idx_p, op, op_data); @@ -1321,19 +1304,19 @@ H5Literate2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(group_id); /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, - op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, + op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Literate2() */ - /*------------------------------------------------------------------------- * Function: H5Literate_by_name2 * @@ -1357,36 +1340,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate_by_name2(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, - H5L_iterate2_t op, void *op_data, hid_t lapl_id) +H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx_p, H5L_iterate2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id); /* Check arguments */ - if(!group_name) + if (!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") - if(!*group_name) + if (!*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location struct fields */ @@ -1396,15 +1378,14 @@ H5Literate_by_name2(hid_t loc_id, const char *group_name, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, - op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Literate_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Lvisit2 * @@ -1434,26 +1415,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, - H5L_iterate2_t op, void *op_data) +H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5I_type_t id_type; /* Type of ID */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIox*x", group_id, idx_type, order, op, op_data); /* Check args */ id_type = H5I_get_type(group_id); - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Set location struct fields */ @@ -1461,19 +1441,18 @@ H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(group_id); /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, TRUE, idx_type, order, NULL, - op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Lvisit2() */ - /*------------------------------------------------------------------------- * Function: H5Lvisit_by_name2 * @@ -1503,35 +1482,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, H5L_iterate2_t op, void *op_data, hid_t lapl_id) +H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIox*xi", loc_id, group_name, idx_type, order, op, op_data, lapl_id); /* Check args */ - if(!group_name) + if (!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") - if(!*group_name) + if (!*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location struct fields */ @@ -1541,8 +1520,8 @@ H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Visit the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, TRUE, idx_type, order, NULL, - op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: @@ -1557,7 +1536,6 @@ done: *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: H5L_find_class_idx * @@ -1576,20 +1554,19 @@ done: static int H5L_find_class_idx(H5L_type_t id) { - size_t i; /* Local index variable */ - int ret_value = FAIL; /* Return value */ + size_t i; /* Local index variable */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - for(i = 0; i < H5L_table_used_g; i++) - if(H5L_table_g[i].id == id) - HGOTO_DONE((int)i) + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) + HGOTO_DONE((int)i) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_find_class_idx */ - /*------------------------------------------------------------------------- * Function: H5L_find_class * @@ -1607,23 +1584,22 @@ done: const H5L_class_t * H5L_find_class(H5L_type_t id) { - int idx; /* Filter index in global table */ - H5L_class_t *ret_value = NULL; /* Return value */ + int idx; /* Filter index in global table */ + H5L_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Get the index in the global table */ - if((idx = H5L_find_class_idx(id)) < 0) + if ((idx = H5L_find_class_idx(id)) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, NULL, "unable to find link class") /* Set return value */ - ret_value = H5L_table_g+idx; + ret_value = H5L_table_g + idx; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_find_class */ - /*------------------------------------------------------------------------- * Function: H5L_register * @@ -1642,8 +1618,8 @@ done: herr_t H5L_register(const H5L_class_t *cls) { - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1651,23 +1627,23 @@ H5L_register(const H5L_class_t *cls) HDassert(cls->id >= 0 && cls->id <= H5L_TYPE_MAX); /* Is the link type already registered? */ - for(i = 0; i < H5L_table_used_g; i++) - if(H5L_table_g[i].id == cls->id) + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == cls->id) break; /* Filter not already registered */ - if(i >= H5L_table_used_g) { - if(H5L_table_used_g >= H5L_table_alloc_g) { - size_t n = MAX(H5L_MIN_TABLE_SIZE, (2 * H5L_table_alloc_g)); - H5L_class_t *table = (H5L_class_t *)H5MM_realloc(H5L_table_g, (n * sizeof(H5L_class_t))); - if(!table) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend link type table") - H5L_table_g = table; + if (i >= H5L_table_used_g) { + if (H5L_table_used_g >= H5L_table_alloc_g) { + size_t n = MAX(H5L_MIN_TABLE_SIZE, (2 * H5L_table_alloc_g)); + H5L_class_t *table = (H5L_class_t *)H5MM_realloc(H5L_table_g, (n * sizeof(H5L_class_t))); + if (!table) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend link type table") + H5L_table_g = table; H5L_table_alloc_g = n; - } /* end if */ + } /* end if */ - /* Initialize */ - i = H5L_table_used_g++; + /* Initialize */ + i = H5L_table_used_g++; } /* end if */ /* Copy link class info into table */ @@ -1677,7 +1653,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_register */ - /*------------------------------------------------------------------------- * Function: H5L_unregister * @@ -1695,20 +1670,20 @@ done: herr_t H5L_unregister(H5L_type_t id) { - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(id >= 0 && id <= H5L_TYPE_MAX); /* Is the filter already registered? */ - for(i = 0; i < H5L_table_used_g; i++) - if(H5L_table_g[i].id == id) + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) break; /* Fail if filter not found */ - if(i >= H5L_table_used_g) + if (i >= H5L_table_used_g) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class is not registered") /* Remove filter from table */ @@ -1720,7 +1695,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_unregister() */ - /*------------------------------------------------------------------------- * Function: H5L_link * @@ -1737,8 +1711,8 @@ done: herr_t H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc, hid_t lcpl_id) { - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1753,18 +1727,17 @@ H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc, hid */ /* Construct link information for eventual insertion */ - lnk.type = H5L_TYPE_HARD; + lnk.type = H5L_TYPE_HARD; lnk.u.hard.addr = obj_loc->oloc->addr; /* Create the link */ - if(H5L__create_real(new_loc, new_name, obj_loc->path, obj_loc->oloc->file, &lnk, NULL, lcpl_id) < 0) + if (H5L__create_real(new_loc, new_name, obj_loc->path, obj_loc->oloc->file, &lnk, NULL, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_link() */ - /*------------------------------------------------------------------------- * Function: H5L_link_object * @@ -1778,11 +1751,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, - H5O_obj_create_t *ocrt_info, hid_t lcpl_id) +H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, H5O_obj_create_t *ocrt_info, hid_t lcpl_id) { - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1800,14 +1772,13 @@ H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, lnk.type = H5L_TYPE_HARD; /* Create the link */ - if(H5L__create_real(new_loc, new_name, NULL, NULL, &lnk, ocrt_info, lcpl_id) < 0) + if (H5L__create_real(new_loc, new_name, NULL, NULL, &lnk, ocrt_info, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_link_object() */ - /*------------------------------------------------------------------------- * Function: H5L__link_cb * @@ -1821,33 +1792,35 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_cr_t *udata = (H5L_trav_cr_t *)_udata; /* User data passed in */ - H5G_t *grp = NULL; /* H5G_t for this group, opened to pass to user callback */ - hid_t grp_id = FAIL; /* Id for this group (passed to user callback */ - H5G_loc_t temp_loc; /* For UD callback */ - hbool_t temp_loc_init = FALSE; /* Temporary location for UD callback (temp_loc) has been initialized */ - hbool_t obj_created = FALSE; /* Whether an object was created (through a hard link) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_cr_t *udata = (H5L_trav_cr_t *)_udata; /* User data passed in */ + H5G_t * grp = NULL; /* H5G_t for this group, opened to pass to user callback */ + hid_t grp_id = FAIL; /* Id for this group (passed to user callback */ + H5G_loc_t temp_loc; /* For UD callback */ + hbool_t temp_loc_init = FALSE; /* Temporary location for UD callback (temp_loc) has been initialized */ + hbool_t obj_created = FALSE; /* Whether an object was created (through a hard link) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid location */ /* (which is not what we want) */ - if(obj_loc != NULL) + if (obj_loc != NULL) HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name already exists") /* Check for crossing file boundaries with a new hard link */ - if(udata->lnk->type == H5L_TYPE_HARD) { + if (udata->lnk->type == H5L_TYPE_HARD) { /* Check for creating an object */ /* (only for hard links) */ - if(udata->ocrt_info) { - H5G_loc_t new_loc; /* Group location for new object */ + if (udata->ocrt_info) { + H5G_loc_t new_loc; /* Group location for new object */ /* Create new object at this location */ - if(NULL == (udata->ocrt_info->new_obj = H5O_obj_create(grp_loc->oloc->file, udata->ocrt_info->obj_type, udata->ocrt_info->crt_info, &new_loc))) + if (NULL == + (udata->ocrt_info->new_obj = H5O_obj_create(grp_loc->oloc->file, udata->ocrt_info->obj_type, + udata->ocrt_info->crt_info, &new_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create object") /* Set address for hard link */ @@ -1861,56 +1834,57 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT } /* end if */ else { /* Check that both objects are in same file */ - if(!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) + if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "interfile hard links are not allowed") } /* end else */ - } /* end if */ + } /* end if */ /* Set 'standard' aspects of link */ - udata->lnk->corder = 0; /* Will be re-written during group insertion, if the group is tracking creation order */ - udata->lnk->corder_valid = FALSE; /* Creation order not valid (yet) */ + udata->lnk->corder = + 0; /* Will be re-written during group insertion, if the group is tracking creation order */ + udata->lnk->corder_valid = FALSE; /* Creation order not valid (yet) */ /* Check for non-default link creation properties */ - if(udata->lc_plist) { + if (udata->lc_plist) { /* Get character encoding property */ - if(H5CX_get_encoding(&udata->lnk->cset) < 0) + if (H5CX_get_encoding(&udata->lnk->cset) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get 'character set' property") } /* end if */ else - udata->lnk->cset = H5F_DEFAULT_CSET; /* Default character encoding for link */ + udata->lnk->cset = H5F_DEFAULT_CSET; /* Default character encoding for link */ /* Set the link's name correctly */ /* Casting away const OK -QAK */ udata->lnk->name = (char *)name; /* Insert link into group */ - if(H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, - udata->ocrt_info ? udata->ocrt_info->obj_type : H5O_TYPE_UNKNOWN, - udata->ocrt_info ? udata->ocrt_info->crt_info : NULL) < 0) + if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, + udata->ocrt_info ? udata->ocrt_info->obj_type : H5O_TYPE_UNKNOWN, + udata->ocrt_info ? udata->ocrt_info->crt_info : NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link for object") /* Set object's path if it has been passed in and is not set */ - if(udata->path != NULL && udata->path->user_path_r == NULL) - if(H5G_name_set(grp_loc->path, udata->path, name) < 0) + if (udata->path != NULL && udata->path->user_path_r == NULL) + if (H5G_name_set(grp_loc->path, udata->path, name) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "cannot set name") /* If link is a user-defined link, trigger its creation callback if it has one */ - if(udata->lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ + if (udata->lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ /* Get the link class for this type of link. */ - if(NULL == (link_class = H5L_find_class(udata->lnk->type))) + if (NULL == (link_class = H5L_find_class(udata->lnk->type))) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to get class of UD link") - if(link_class->create_func != NULL) { - H5O_loc_t temp_oloc; - H5G_name_t temp_path; + if (link_class->create_func != NULL) { + H5O_loc_t temp_oloc; + H5G_name_t temp_path; /* Create a temporary location (or else H5G_open will do a shallow * copy and wipe out grp_loc) */ H5G_name_reset(&temp_path); - if(H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) + if (H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object location") temp_loc.oloc = &temp_oloc; @@ -1918,21 +1892,22 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT temp_loc_init = TRUE; /* Set up location for user-defined callback */ - if(NULL == (grp = H5G_open(&temp_loc))) + if (NULL == (grp = H5G_open(&temp_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) + if ((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register ID for group") /* Make callback */ - if((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, H5P_DEFAULT) < 0) + if ((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, + H5P_DEFAULT) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "link creation callback failed") } /* end if */ - } /* end if */ + } /* end if */ done: /* Check if an object was created */ - if(obj_created) { - H5O_loc_t oloc; /* Object location for created object */ + if (obj_created) { + H5O_loc_t oloc; /* Object location for created object */ /* Set up object location */ HDmemset(&oloc, 0, sizeof(oloc)); @@ -1940,20 +1915,20 @@ done: oloc.addr = udata->lnk->u.hard.addr; /* Decrement refcount on new object's object header in memory */ - if(H5O_dec_rc_by_loc(&oloc) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + if (H5O_dec_rc_by_loc(&oloc) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") } /* end if */ /* Close the location given to the user callback if it was created */ - if(grp_id >= 0) { - if(H5I_dec_app_ref(grp_id) < 0) + if (grp_id >= 0) { + if (H5I_dec_app_ref(grp_id) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") } /* end if */ - else if(grp != NULL) { - if(H5G_close(grp) < 0) + else if (grp != NULL) { + if (H5G_close(grp) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") } /* end if */ - else if(temp_loc_init) + else if (temp_loc_init) H5G_loc_free(&temp_loc); /* Indicate that this callback didn't take ownership of the group * @@ -1963,7 +1938,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__link_cb() */ - /*------------------------------------------------------------------------- * Function: H5L__create_real * @@ -1984,15 +1958,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, - H5G_name_t *obj_path, H5F_t *obj_file, H5O_link_t *lnk, - H5O_obj_create_t *ocrt_info, hid_t lcpl_id) +H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path, H5F_t *obj_file, + H5O_link_t *lnk, H5O_obj_create_t *ocrt_info, hid_t lcpl_id) { - char *norm_link_name = NULL; /* Pointer to normalized link name */ - unsigned target_flags = H5G_TARGET_NORMAL; /* Flags to pass to group traversal function */ - H5P_genplist_t *lc_plist = NULL; /* Link creation property list */ - H5L_trav_cr_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + char * norm_link_name = NULL; /* Pointer to normalized link name */ + unsigned target_flags = H5G_TARGET_NORMAL; /* Flags to pass to group traversal function */ + H5P_genplist_t *lc_plist = NULL; /* Link creation property list */ + H5L_trav_cr_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2003,22 +1976,22 @@ H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, HDassert(lnk->type >= H5L_TYPE_HARD && lnk->type <= H5L_TYPE_MAX); /* Get normalized link name */ - if((norm_link_name = H5G_normalize(link_name)) == NULL) + if ((norm_link_name = H5G_normalize(link_name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Check for flags present in creation property list */ - if(lcpl_id != H5P_DEFAULT) { + if (lcpl_id != H5P_DEFAULT) { unsigned crt_intmd_group; /* Get link creation property list */ - if(NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get intermediate group creation property */ - if(H5CX_get_intermediate_group(&crt_intmd_group) < 0) + if (H5CX_get_intermediate_group(&crt_intmd_group) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get 'create intermediate group' property") - if(crt_intmd_group > 0) + if (crt_intmd_group > 0) target_flags |= H5G_CRT_INTMD_GROUP; } /* end if */ @@ -2034,25 +2007,24 @@ H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, * of its fields should be populated except for name, which is set when * inserting it in the callback. */ - udata.file = obj_file; - udata.lc_plist = lc_plist; - udata.path = obj_path; + udata.file = obj_file; + udata.lc_plist = lc_plist; + udata.path = obj_path; udata.ocrt_info = ocrt_info; - udata.lnk = lnk; + udata.lnk = lnk; /* Traverse the destination path & create new link */ - if(H5G_traverse(link_loc, link_name, target_flags, H5L__link_cb, &udata) < 0) + if (H5G_traverse(link_loc, link_name, target_flags, H5L__link_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert link") done: /* Free the normalized path name */ - if(norm_link_name) + if (norm_link_name) H5MM_xfree(norm_link_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__create_real() */ - /*------------------------------------------------------------------------- * Function: H5L_create_hard * @@ -2066,17 +2038,17 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, - const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id) +H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, const H5G_loc_t *link_loc, const char *link_name, + hid_t lcpl_id) { - char *norm_cur_name = NULL; /* Pointer to normalized current name */ - H5F_t *link_file = NULL; /* Pointer to file to link to */ - H5O_link_t lnk; /* Link to insert */ - H5G_loc_t obj_loc; /* Location of object to link to */ - H5G_name_t path; /* obj_loc's path*/ - H5O_loc_t oloc; /* obj_loc's oloc */ - hbool_t loc_valid = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + char * norm_cur_name = NULL; /* Pointer to normalized current name */ + H5F_t * link_file = NULL; /* Pointer to file to link to */ + H5O_link_t lnk; /* Link to insert */ + H5G_loc_t obj_loc; /* Location of object to link to */ + H5G_name_t path; /* obj_loc's path*/ + H5O_loc_t oloc; /* obj_loc's oloc */ + hbool_t loc_valid = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2087,7 +2059,7 @@ H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, HDassert(link_name && *link_name); /* Get normalized copy of the current name */ - if((norm_cur_name = H5G_normalize(cur_name)) == NULL) + if ((norm_cur_name = H5G_normalize(cur_name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Set up link data specific to hard links */ @@ -2097,7 +2069,7 @@ H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, obj_loc.path = &path; obj_loc.oloc = &oloc; H5G_loc_reset(&obj_loc); - if(H5G_loc_find(cur_loc, norm_cur_name, &obj_loc) < 0) + if (H5G_loc_find(cur_loc, norm_cur_name, &obj_loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "source object not found") loc_valid = TRUE; @@ -2109,23 +2081,22 @@ H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, /* Create actual link to the object. Pass in NULL for the path, since this * function shouldn't change an object's user path. */ - if(H5L__create_real(link_loc, link_name, NULL, link_file, &lnk, NULL, lcpl_id) < 0) + if (H5L__create_real(link_loc, link_name, NULL, link_file, &lnk, NULL, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") done: /* Free the object header location */ - if(loc_valid) - if(H5G_loc_free(&obj_loc) < 0) + if (loc_valid) + if (H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to free location") /* Free the normalized path name */ - if(norm_cur_name) + if (norm_cur_name) H5MM_xfree(norm_cur_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_create_hard() */ - /*------------------------------------------------------------------------- * Function: H5L_create_soft * @@ -2139,12 +2110,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_create_soft(const char *target_path, const H5G_loc_t *link_loc, - const char *link_name, hid_t lcpl_id) +H5L_create_soft(const char *target_path, const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id) { - char *norm_target = NULL; /* Pointer to normalized current name */ - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + char * norm_target = NULL; /* Pointer to normalized current name */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2154,26 +2124,25 @@ H5L_create_soft(const char *target_path, const H5G_loc_t *link_loc, HDassert(link_name && *link_name); /* Get normalized copy of the link target */ - if((norm_target = H5G_normalize(target_path)) == NULL) + if ((norm_target = H5G_normalize(target_path)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Set up link data specific to soft links */ - lnk.type = H5L_TYPE_SOFT; + lnk.type = H5L_TYPE_SOFT; lnk.u.soft.name = norm_target; /* Create actual link to the object */ - if(H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) + if (H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") done: /* Free the normalized target name */ - if(norm_target) + if (norm_target) H5MM_xfree(norm_target); FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_create_soft() */ - /*------------------------------------------------------------------------- * Function: H5L__create_ud * @@ -2188,11 +2157,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, - const void *ud_data, size_t ud_data_size, H5L_type_t type, hid_t lcpl_id) +H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, const void *ud_data, size_t ud_data_size, + H5L_type_t type, hid_t lcpl_id) { - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2206,22 +2175,22 @@ H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, lnk.u.ud.udata = NULL; /* Make sure that this link class is registered */ - if(H5L_find_class_idx(type) < 0) + if (H5L_find_class_idx(type) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "link class has not been registered with library") /* Fill in UD link-specific information in the link struct*/ - if(ud_data_size > 0) { + if (ud_data_size > 0) { lnk.u.ud.udata = H5MM_malloc((size_t)ud_data_size); - H5MM_memcpy(lnk.u.ud.udata, ud_data, (size_t) ud_data_size); + H5MM_memcpy(lnk.u.ud.udata, ud_data, (size_t)ud_data_size); } /* end if */ else lnk.u.ud.udata = NULL; lnk.u.ud.size = ud_data_size; - lnk.type = type; + lnk.type = type; /* Create actual link to the object */ - if(H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) + if (H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to register new name for object") done: @@ -2231,7 +2200,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__create_ud() */ - /*------------------------------------------------------------------------- * Function: H5L__get_val_real * @@ -2247,7 +2215,7 @@ done: static herr_t H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2255,17 +2223,17 @@ H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) HDassert(lnk); /* Check for soft link */ - if(H5L_TYPE_SOFT == lnk->type) { + if (H5L_TYPE_SOFT == lnk->type) { /* Copy to output buffer */ - if(size > 0 && buf) { + if (size > 0 && buf) { HDstrncpy((char *)buf, lnk->u.soft.name, size); - if(HDstrlen(lnk->u.soft.name) >= size) + if (HDstrlen(lnk->u.soft.name) >= size) ((char *)buf)[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ /* Check for user-defined link */ - else if(lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ + else if (lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ /* Get the link class for this type of link. It's okay if the class * isn't registered, though--we just can't give any more information @@ -2273,11 +2241,11 @@ H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) */ link_class = H5L_find_class(lnk->type); - if(link_class != NULL && link_class->query_func != NULL) { - if((link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, buf, size) < 0) + if (link_class != NULL && link_class->query_func != NULL) { + if ((link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, buf, size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "query callback returned failure") } /* end if */ - else if(buf && size > 0) + else if (buf && size > 0) ((char *)buf)[0] = '\0'; } /* end if */ else @@ -2287,7 +2255,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_val_real() */ - /*------------------------------------------------------------------------- * Function: H5L__get_val_cb * @@ -2301,20 +2268,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__get_val_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5L__get_val_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gv_t *udata = (H5L_trav_gv_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gv_t *udata = (H5L_trav_gv_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(lnk == NULL) + if (lnk == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name) /* Retrieve the value for the link */ - if(H5L__get_val_real(lnk, udata->buf, udata->size) < 0) + if (H5L__get_val_real(lnk, udata->buf, udata->size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value") done: @@ -2325,7 +2292,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_val_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_get_val * @@ -2346,10 +2312,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf/*out*/, size_t size) +H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf /*out*/, size_t size) { - H5L_trav_gv_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gv_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2359,17 +2325,16 @@ H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf/*out*/, size_t siz /* Set up user data for retrieving information */ udata.size = size; - udata.buf = buf; + udata.buf = buf; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5L_get_val() */ - /*------------------------------------------------------------------------- * Function: H5L__get_val_by_idx_cb * @@ -2384,33 +2349,33 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__get_val_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__get_val_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ - H5O_link_t fnd_lnk; /* Link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ + H5O_link_t fnd_lnk; /* Link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name of the group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if(H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) + if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") lnk_copied = TRUE; /* Retrieve the value for the link */ - if(H5L__get_val_real(&fnd_lnk, udata->buf, udata->size) < 0) + if (H5L__get_val_real(&fnd_lnk, udata->buf, udata->size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value") done: /* Reset the link information, if we have a copy */ - if(lnk_copied) + if (lnk_copied) H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); /* Indicate that this callback didn't take ownership of the group * @@ -2420,7 +2385,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_val_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_get_val_by_idx * @@ -2435,11 +2399,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size) +H5L_get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, void *buf /*out*/, size_t size) { - H5L_trav_gvbi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gvbi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2449,20 +2413,19 @@ H5L_get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, /* Set up user data for retrieving information */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.buf = buf; - udata.size = size; + udata.order = order; + udata.n = n; + udata.buf = buf; + udata.size = size; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_by_idx_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info for index: %llu", (unsigned long long)n) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_get_val_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5L__delete_cb * @@ -2477,30 +2440,31 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t H5_ATTR_UNUSED *obj_loc, void H5_ATTR_UNUSED *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void H5_ATTR_UNUSED *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Check if the group resolved to a valid link */ - if(grp_loc == NULL) + if (grp_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Check if the name in this group resolved to a valid link */ - if(name == NULL) + if (name == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Check for non-existent (NULL) link. * Note that this can also occur when attempting to remove '.' */ - if(lnk == NULL) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "callback link pointer is NULL (specified link may be '.' or not exist)") + if (lnk == NULL) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, + "callback link pointer is NULL (specified link may be '.' or not exist)") /* Remove the link from the group */ - if(H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, name) < 0) + if (H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, name) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to remove link from group") done: @@ -2511,7 +2475,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__delete_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_delete * @@ -2527,8 +2490,8 @@ done: herr_t H5L_delete(const H5G_loc_t *loc, const char *name) { - char *norm_name = NULL; /* Pointer to normalized name */ - herr_t ret_value = SUCCEED; /* Return value */ + char * norm_name = NULL; /* Pointer to normalized name */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2537,22 +2500,22 @@ H5L_delete(const H5G_loc_t *loc, const char *name) HDassert(name && *name); /* Get normalized copy of the name */ - if((norm_name = H5G_normalize(name)) == NULL) + if ((norm_name = H5G_normalize(name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Set up user data for unlink operation */ - if(H5G_traverse(loc, norm_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, H5L__delete_cb, NULL) < 0) + if (H5G_traverse(loc, norm_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, H5L__delete_cb, + NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREMOVE, FAIL, "can't unlink object") done: /* Free the normalized path name */ - if(norm_name) + if (norm_name) H5MM_xfree(norm_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_delete() */ - /*------------------------------------------------------------------------- * Function: H5L__delete_by_idx_cb * @@ -2566,21 +2529,22 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__delete_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__delete_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG((obj_loc) ? (obj_loc->oloc->addr) : HADDR_UNDEF) /* Check if the name of the group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Delete link */ - if(H5G_obj_remove_by_idx(obj_loc->oloc, obj_loc->path->full_path_r, udata->idx_type, udata->order, udata->n) < 0) + if (H5G_obj_remove_by_idx(obj_loc->oloc, obj_loc->path->full_path_r, udata->idx_type, udata->order, + udata->n) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") done: @@ -2591,7 +2555,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5L__delete_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_delete_by_idx * @@ -2606,11 +2569,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +H5L_delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n) { - H5L_trav_rmbi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_rmbi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2620,18 +2583,18 @@ H5L_delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, /* Set up user data for unlink operation */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; + udata.order = order; + udata.n = n; /* Traverse the group hierarchy to remove the link */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, H5L__delete_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, + H5L__delete_by_idx_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "link doesn't exist") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_delete_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5L__move_dest_cb * @@ -2647,27 +2610,26 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_mv2_t *udata = (H5L_trav_mv2_t *)_udata; /* User data passed in */ - H5G_t *grp = NULL; /* H5G_t for this group, opened to pass to user callback */ - hid_t grp_id = FAIL; /* ID for this group (passed to user callback */ - H5G_loc_t temp_loc; /* For UD callback */ - hbool_t temp_loc_init = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_mv2_t *udata = (H5L_trav_mv2_t *)_udata; /* User data passed in */ + H5G_t * grp = NULL; /* H5G_t for this group, opened to pass to user callback */ + hid_t grp_id = FAIL; /* ID for this group (passed to user callback */ + H5G_loc_t temp_loc; /* For UD callback */ + hbool_t temp_loc_init = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make sure an object with this name doesn't already exist */ - if(obj_loc != NULL) + if (obj_loc != NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "an object with that name already exists") /* Check for crossing file boundaries with a new hard link */ - if(udata->lnk->type == H5L_TYPE_HARD) + if (udata->lnk->type == H5L_TYPE_HARD) /* Check that both objects are in same file */ - if(!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) + if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "moving a link across files is not allowed") /* Give the object its new name */ @@ -2676,26 +2638,26 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, udata->lnk->name = (char *)name; /* Insert the link into the group */ - if(H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, H5O_TYPE_UNKNOWN, NULL) < 0) + if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, H5O_TYPE_UNKNOWN, NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") /* If the link was a user-defined link, call its move callback if it has one */ - if(udata->lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ + if (udata->lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ /* Get the link class for this type of link. */ - if(NULL == (link_class = H5L_find_class(udata->lnk->type))) + if (NULL == (link_class = H5L_find_class(udata->lnk->type))) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class is not registered") - if((!udata->copy && link_class->move_func) || (udata->copy && link_class->copy_func)) { - H5O_loc_t temp_oloc; - H5G_name_t temp_path; + if ((!udata->copy && link_class->move_func) || (udata->copy && link_class->copy_func)) { + H5O_loc_t temp_oloc; + H5G_name_t temp_path; /* Create a temporary location (or else H5G_open will do a shallow * copy and wipe out grp_loc) */ H5G_name_reset(&temp_path); - if(H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) + if (H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object location") temp_loc.oloc = &temp_oloc; @@ -2703,33 +2665,35 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, temp_loc_init = TRUE; /* Set up location for user-defined callback */ - if(NULL == (grp = H5G_open(&temp_loc))) + if (NULL == (grp = H5G_open(&temp_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) + if ((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register group ID") - if(udata->copy) { - if((link_class->copy_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size) < 0) + if (udata->copy) { + if ((link_class->copy_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, + udata->lnk->u.ud.size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "UD copy callback returned error") } /* end if */ else { - if((link_class->move_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size) < 0) + if ((link_class->move_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, + udata->lnk->u.ud.size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "UD move callback returned error") } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Close the location given to the user callback if it was created */ - if(grp_id >= 0) { - if(H5I_dec_app_ref(grp_id) < 0) + if (grp_id >= 0) { + if (H5I_dec_app_ref(grp_id) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") } /* end if */ - else if(grp != NULL) { - if(H5G_close(grp) < 0) + else if (grp != NULL) { + if (H5G_close(grp) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") } /* end if */ - else if(temp_loc_init) + else if (temp_loc_init) H5G_loc_free(&temp_loc); /* Indicate that this callback didn't take ownership of the group * @@ -2743,7 +2707,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__move_dest_cb() */ - /*------------------------------------------------------------------------- * Function: H5L__move_cb * @@ -2759,38 +2722,38 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, + void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_mv_t *udata = (H5L_trav_mv_t *)_udata; /* User data passed in */ - H5L_trav_mv2_t udata_out; /* User data for H5L__move_dest_cb traversal */ - char * orig_name = NULL; /* The name of the link in this group */ - hbool_t link_copied = FALSE; /* Has udata_out.lnk been allocated? */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_mv_t *udata = (H5L_trav_mv_t *)_udata; /* User data passed in */ + H5L_trav_mv2_t udata_out; /* User data for H5L__move_dest_cb traversal */ + char * orig_name = NULL; /* The name of the link in this group */ + hbool_t link_copied = FALSE; /* Has udata_out.lnk been allocated? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Check for operations on '.' */ - if(lnk == NULL) + if (lnk == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "the name of a link must be supplied to move or copy") /* Set up user data for move_dest_cb */ - if(NULL == (udata_out.lnk = (H5O_link_t *)H5O_msg_copy(H5O_LINK_ID, lnk, NULL))) + if (NULL == (udata_out.lnk = (H5O_link_t *)H5O_msg_copy(H5O_LINK_ID, lnk, NULL))) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link to be moved") /* In this special case, the link's name is going to be replaced at its * destination, so we should free it here. */ udata_out.lnk->name = (char *)H5MM_xfree(udata_out.lnk->name); - link_copied = TRUE; + link_copied = TRUE; udata_out.lnk->cset = udata->cset; - udata_out.file = grp_loc->oloc->file; - udata_out.copy = udata->copy; + udata_out.file = grp_loc->oloc->file; + udata_out.copy = udata->copy; /* Keep a copy of link's name (it's "owned" by the H5G_traverse() routine) */ orig_name = H5MM_xstrdup(name); @@ -2798,24 +2761,25 @@ H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, /* Reset the # of soft / UD links that can be traversed, so that the second * (destination) traversal has the correct value */ - if(H5CX_set_nlinks(udata->orig_nlinks) < 0) + if (H5CX_set_nlinks(udata->orig_nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't reset # of soft / UD links to traverse") /* Insert the link into its new location */ - if(H5G_traverse(udata->dst_loc, udata->dst_name, udata->dst_target_flags, H5L__move_dest_cb, &udata_out) < 0) + if (H5G_traverse(udata->dst_loc, udata->dst_name, udata->dst_target_flags, H5L__move_dest_cb, + &udata_out) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") /* If this is a move and not a copy operation, change the object's name and remove the old link */ - if(!udata->copy) { - H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ + if (!udata->copy) { + H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ /* Make certain that the destination name is a full (not relative) path */ - if(*(udata->dst_name) != '/') { + if (*(udata->dst_name) != '/') { HDassert(udata->dst_loc->path->full_path_r); /* Create reference counted string for full dst path */ - if((dst_name_r = H5G_build_fullpath_refstr_str(udata->dst_loc->path->full_path_r, - udata->dst_name)) == NULL) + if ((dst_name_r = H5G_build_fullpath_refstr_str(udata->dst_loc->path->full_path_r, + udata->dst_name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_PATH, FAIL, "can't build destination path name") } /* end if */ else @@ -2823,14 +2787,14 @@ H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, HDassert(dst_name_r); /* Fix names up */ - if(H5G_name_replace(lnk, H5G_NAME_MOVE, obj_loc->oloc->file, obj_loc->path->full_path_r, - udata->dst_loc->oloc->file, dst_name_r) < 0) { + if (H5G_name_replace(lnk, H5G_NAME_MOVE, obj_loc->oloc->file, obj_loc->path->full_path_r, + udata->dst_loc->oloc->file, dst_name_r) < 0) { H5RS_decr(dst_name_r); HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to replace name") } /* end if */ /* Remove the old link */ - if(H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, orig_name) < 0) { + if (H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, orig_name) < 0) { H5RS_decr(dst_name_r); HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to remove old name") } /* end if */ @@ -2840,14 +2804,14 @@ H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, done: /* Cleanup */ - if(orig_name) + if (orig_name) H5MM_xfree(orig_name); /* If udata_out.lnk was copied, free any memory allocated * In this special case, the H5L__move_dest_cb callback resets the name * so H5O_msg_free shouldn't try to free it */ - if(link_copied) + if (link_copied) H5O_msg_free(H5O_LINK_ID, udata_out.lnk); /* Indicate that this callback didn't take ownership of the group * @@ -2857,7 +2821,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__move_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_move * @@ -2879,14 +2842,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, - const char *dst_name, hbool_t copy_flag, hid_t lcpl_id) +H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, const char *dst_name, + hbool_t copy_flag, hid_t lcpl_id) { - unsigned dst_target_flags = H5G_TARGET_NORMAL; - H5T_cset_t char_encoding = H5F_DEFAULT_CSET; /* Character encoding for link */ - H5P_genplist_t* lc_plist; /* Link creation property list */ - H5L_trav_mv_t udata; /* User data for traversal */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned dst_target_flags = H5G_TARGET_NORMAL; + H5T_cset_t char_encoding = H5F_DEFAULT_CSET; /* Character encoding for link */ + H5P_genplist_t *lc_plist; /* Link creation property list */ + H5L_trav_mv_t udata; /* User data for traversal */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2897,47 +2860,47 @@ H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_lo HDassert(dst_name && *dst_name); /* Check for flags present in creation property list */ - if(lcpl_id != H5P_DEFAULT) { + if (lcpl_id != H5P_DEFAULT) { unsigned crt_intmd_group; - if(NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get intermediate group creation property */ - if(H5CX_get_intermediate_group(&crt_intmd_group) < 0) + if (H5CX_get_intermediate_group(&crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for creating missing groups") /* Set target flags for source and destination */ - if(crt_intmd_group > 0) + if (crt_intmd_group > 0) dst_target_flags |= H5G_CRT_INTMD_GROUP; /* Get character encoding property */ - if(H5CX_get_encoding(&char_encoding) < 0) + if (H5CX_get_encoding(&char_encoding) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for character encoding") } /* end if */ /* Set up user data */ - udata.dst_loc = dst_loc; - udata.dst_name= dst_name; + udata.dst_loc = dst_loc; + udata.dst_name = dst_name; udata.dst_target_flags = dst_target_flags; - udata.cset = char_encoding; - udata.copy = copy_flag; + udata.cset = char_encoding; + udata.copy = copy_flag; /* Retrieve the original # of soft / UD links that can be traversed, so * that the countdown can be reset after the first path is traversed. */ - if(H5CX_get_nlinks(&udata.orig_nlinks) < 0) + if (H5CX_get_nlinks(&udata.orig_nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") /* Do the move */ - if(H5G_traverse(src_loc, src_name, H5G_TARGET_MOUNT | H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__move_cb, &udata) < 0) + if (H5G_traverse(src_loc, src_name, H5G_TARGET_MOUNT | H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__move_cb, + &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to find link") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_move() */ - /*------------------------------------------------------------------------- * Function: H5L__exists_final_cb * @@ -2952,11 +2915,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ FUNC_ENTER_STATIC_NOERR @@ -2970,7 +2933,6 @@ H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5L__exists_final_cb() */ - /*------------------------------------------------------------------------- * Function: H5L__exists_inter_cb * @@ -2985,35 +2947,35 @@ H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR *------------------------------------------------------------------------- */ static herr_t -H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(lnk != NULL) { + if (lnk != NULL) { /* Check for more components to the path */ - if(udata->sep) { - H5G_traverse_t cb_func; /* Callback function for tranversal */ - char *next; /* Pointer to next component name */ + if (udata->sep) { + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char * next; /* Pointer to next component name */ /* Look for another separator */ next = udata->sep; - if(NULL == (udata->sep = HDstrchr(udata->sep, '/'))) + if (NULL == (udata->sep = HDstrchr(udata->sep, '/'))) cb_func = H5L__exists_final_cb; else { /* Chew through adjacent separators, if present */ do { *udata->sep = '\0'; udata->sep++; - } while('/' == *udata->sep); + } while ('/' == *udata->sep); cb_func = H5L__exists_inter_cb; } /* end else */ - if(H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata) < 0) + if (H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if link exists") } /* end if */ else @@ -3030,7 +2992,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__exists_inter_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_exists_tolerant * @@ -3049,11 +3010,11 @@ done: htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name) { - H5L_trav_le_t udata; /* User data for traversal */ - H5G_traverse_t cb_func; /* Callback function for tranversal */ - char *name_copy = NULL; /* Duplicate of name */ - char *name_trav; /* Name to traverse */ - htri_t ret_value = FAIL; /* Return value */ + H5L_trav_le_t udata; /* User data for traversal */ + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char * name_copy = NULL; /* Duplicate of name */ + char * name_trav; /* Name to traverse */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3063,28 +3024,28 @@ H5L_exists_tolerant(const H5G_loc_t *loc, const char *name) /* Copy the name and skip leading '/'s */ name_trav = name_copy = H5MM_strdup(name); - while('/' == *name_trav) + while ('/' == *name_trav) name_trav++; /* A path of "/" will always exist in a file */ - if('\0' == *name_trav) + if ('\0' == *name_trav) HGOTO_DONE(TRUE) /* Set up user data & correct callback */ udata.exists = FALSE; - if(NULL == (udata.sep = HDstrchr(name_trav, '/'))) + if (NULL == (udata.sep = HDstrchr(name_trav, '/'))) cb_func = H5L__exists_final_cb; else { /* Chew through adjacent separators, if present */ do { *udata.sep = '\0'; udata.sep++; - } while('/' == *udata.sep); + } while ('/' == *udata.sep); cb_func = H5L__exists_inter_cb; } /* end else */ /* Traverse the group hierarchy to locate the link to check */ - if(H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata) < 0) + if (H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if link exists") /* Set return value */ @@ -3097,7 +3058,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5L_exists_tolerant() */ - /*------------------------------------------------------------------------- * Function: H5L_exists * @@ -3116,18 +3076,18 @@ done: htri_t H5L_exists(const H5G_loc_t *loc, const char *name) { - H5L_trav_le_t udata; /* User data for traversal */ - htri_t ret_value = FAIL; /* Return value */ + H5L_trav_le_t udata; /* User data for traversal */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* A path of "/" will always exist in a file */ - if(0 == HDstrcmp(name, "/")) + if (0 == HDstrcmp(name, "/")) HGOTO_DONE(TRUE) /* Traverse the group hierarchy to locate the object to get info about */ udata.exists = FALSE; - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "path doesn't exist") /* Set return value */ @@ -3137,7 +3097,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5L_exists() */ - /*------------------------------------------------------------------------- * Function: H5L__get_info_cb * @@ -3151,21 +3110,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__get_info_cb(H5G_loc_t *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__get_info_cb(H5G_loc_t *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gi_t *udata = (H5L_trav_gi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gi_t *udata = (H5L_trav_gi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(lnk == NULL) + if (lnk == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Get information from the link */ - if(H5G_link_to_info(grp_loc->oloc, lnk, udata->linfo) < 0) + if (H5G_link_to_info(grp_loc->oloc, lnk, udata->linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") done: @@ -3176,7 +3134,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_info_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_get_info * @@ -3190,24 +3147,23 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info2_t *linfo/*out*/) +H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info2_t *linfo /*out*/) { H5L_trav_gi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) udata.linfo = linfo; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name doesn't exist") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5L_get_info() */ - /*------------------------------------------------------------------------- * Function: H5L__get_info_by_idx_cb * @@ -3222,33 +3178,33 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gibi_t *udata = (H5L_trav_gibi_t *)_udata; /* User data passed in */ - H5O_link_t fnd_lnk; /* Link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gibi_t *udata = (H5L_trav_gibi_t *)_udata; /* User data passed in */ + H5O_link_t fnd_lnk; /* Link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name of the group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if(H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) + if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") lnk_copied = TRUE; /* Get information from the link */ - if(H5G_link_to_info(obj_loc->oloc, &fnd_lnk, udata->linfo) < 0) + if (H5G_link_to_info(obj_loc->oloc, &fnd_lnk, udata->linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") done: /* Reset the link information, if we have a copy */ - if(lnk_copied) + if (lnk_copied) H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); /* Indicate that this callback didn't take ownership of the group * @@ -3258,7 +3214,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_info_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_get_info_by_idx * @@ -3270,11 +3225,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/) +H5L_get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5L_info2_t *linfo /*out*/) { - H5L_trav_gibi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gibi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3285,19 +3240,18 @@ H5L_get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, /* Set up user data for callback */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.linfo = linfo; + udata.order = order; + udata.n = n; + udata.linfo = linfo; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_by_idx_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_get_info_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5L__get_name_by_idx_cb * @@ -3312,21 +3266,22 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gnbi_t *udata = (H5L_trav_gnbi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gnbi_t *udata = (H5L_trav_gnbi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name of the group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if((udata->name_len = H5G_obj_get_name_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, udata->name, udata->size)) < 0) + if ((udata->name_len = H5G_obj_get_name_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, + udata->name, udata->size)) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") done: @@ -3337,7 +3292,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_name_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_get_name_by_idx * @@ -3349,12 +3303,11 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5L_get_name_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, - size_t size) +H5L_get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, char *name /*out*/, size_t size) { - H5L_trav_gnbi_t udata; /* User data for callback */ - ssize_t ret_value = FAIL; /* Return value */ + H5L_trav_gnbi_t udata; /* User data for callback */ + ssize_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3364,14 +3317,15 @@ H5L_get_name_by_idx(const H5G_loc_t *loc, const char *group_name, /* Set up user data for callback */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.name = name; - udata.size = size; + udata.order = order; + udata.n = n; + udata.name = name; + udata.size = size; udata.name_len = -1; /* Traverse the group hierarchy to locate the link to get name of */ - if(H5G_traverse(loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_name_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_name_by_idx_cb, &udata) < + 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get name") /* Set the return value */ @@ -3381,7 +3335,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_get_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5L__link_copy_file * @@ -3397,17 +3350,17 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, - const H5O_loc_t *src_oloc, H5O_link_t *dst_lnk, H5O_copy_t *cpy_info) +H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, + H5O_link_t *dst_lnk, H5O_copy_t *cpy_info) { - H5O_link_t tmp_src_lnk; /* Temporary copy of src link, when needed */ - const H5O_link_t *src_lnk = _src_lnk; /* Source link */ - hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ - hbool_t expanded_link_open = FALSE; /* Whether the target location has been opened */ - H5G_loc_t tmp_src_loc; /* Group location holding target object */ - H5G_name_t tmp_src_path; /* Path for target object */ - H5O_loc_t tmp_src_oloc; /* Object location for target object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t tmp_src_lnk; /* Temporary copy of src link, when needed */ + const H5O_link_t *src_lnk = _src_lnk; /* Source link */ + hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ + hbool_t expanded_link_open = FALSE; /* Whether the target location has been opened */ + H5G_loc_t tmp_src_loc; /* Group location holding target object */ + H5G_name_t tmp_src_path; /* Path for target object */ + H5O_loc_t tmp_src_oloc; /* Object location for target object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3418,66 +3371,64 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, HDassert(cpy_info); /* Expand soft or external link, if requested */ - if((H5L_TYPE_SOFT == src_lnk->type && cpy_info->expand_soft_link) - || (H5L_TYPE_EXTERNAL == src_lnk->type - && cpy_info->expand_ext_link)) { - H5G_loc_t lnk_grp_loc; /* Group location holding link */ - H5G_name_t lnk_grp_path; /* Path for link */ - htri_t tar_exists; /* Whether the target object exists */ + if ((H5L_TYPE_SOFT == src_lnk->type && cpy_info->expand_soft_link) || + (H5L_TYPE_EXTERNAL == src_lnk->type && cpy_info->expand_ext_link)) { + H5G_loc_t lnk_grp_loc; /* Group location holding link */ + H5G_name_t lnk_grp_path; /* Path for link */ + htri_t tar_exists; /* Whether the target object exists */ /* Set up group location for link */ H5G_name_reset(&lnk_grp_path); lnk_grp_loc.path = &lnk_grp_path; - lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Casting away const OK -QAK */ + lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Casting away const OK -QAK */ /* Check if the target object exists */ - if((tar_exists = H5G_loc_exists(&lnk_grp_loc, src_lnk->name)) < 0) + if ((tar_exists = H5G_loc_exists(&lnk_grp_loc, src_lnk->name)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to check if target object exists") - if(tar_exists) { + if (tar_exists) { /* Make a temporary copy of the link, so that it will not change the * info in the cache when we change it to a hard link */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, &tmp_src_lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, &tmp_src_lnk)) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy message") /* Set up group location for target object. Let H5G_traverse expand * the link. */ tmp_src_loc.path = &tmp_src_path; tmp_src_loc.oloc = &tmp_src_oloc; - if(H5G_loc_reset(&tmp_src_loc) < 0) + if (H5G_loc_reset(&tmp_src_loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to reset location") /* Find the target object */ - if(H5G_loc_find(&lnk_grp_loc, src_lnk->name, &tmp_src_loc) < 0) + if (H5G_loc_find(&lnk_grp_loc, src_lnk->name, &tmp_src_loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to find target object") expanded_link_open = TRUE; /* Convert symbolic link to hard link */ - if(tmp_src_lnk.type == H5L_TYPE_SOFT) - tmp_src_lnk.u.soft.name = - (char *)H5MM_xfree(tmp_src_lnk.u.soft.name); - else if(tmp_src_lnk.u.ud.size > 0) + if (tmp_src_lnk.type == H5L_TYPE_SOFT) + tmp_src_lnk.u.soft.name = (char *)H5MM_xfree(tmp_src_lnk.u.soft.name); + else if (tmp_src_lnk.u.ud.size > 0) tmp_src_lnk.u.ud.udata = H5MM_xfree(tmp_src_lnk.u.ud.udata); - tmp_src_lnk.type = H5L_TYPE_HARD; + tmp_src_lnk.type = H5L_TYPE_HARD; tmp_src_lnk.u.hard.addr = tmp_src_oloc.addr; - src_lnk = &tmp_src_lnk; + src_lnk = &tmp_src_lnk; } /* end if */ - } /* end if */ + } /* end if */ /* Copy src link information to dst link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, dst_lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, dst_lnk)) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy message") dst_lnk_init = TRUE; /* Check if object in source group is a hard link & copy it */ - if(H5L_TYPE_HARD == src_lnk->type) { - H5O_loc_t new_dst_oloc; /* Copied object location in destination */ + if (H5L_TYPE_HARD == src_lnk->type) { + H5O_loc_t new_dst_oloc; /* Copied object location in destination */ /* Set up copied object location to fill in */ H5O_loc_reset(&new_dst_oloc); new_dst_oloc.file = dst_file; - if(!expanded_link_open) { + if (!expanded_link_open) { /* Build temporary object location for source */ H5O_loc_reset(&tmp_src_oloc); tmp_src_oloc.file = src_oloc->file; @@ -3488,7 +3439,7 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, /* Copy the shared object from source to destination */ /* Don't care about obj_type or udata because those are only important * for old style groups */ - if(H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, NULL, NULL) < 0) + if (H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, NULL, NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object") /* Copy new destination object's information for eventual insertion */ @@ -3497,22 +3448,21 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, done: /* Check if we used a temporary src link */ - if(src_lnk != _src_lnk) { + if (src_lnk != _src_lnk) { HDassert(src_lnk == &tmp_src_lnk); H5O_msg_reset(H5O_LINK_ID, &tmp_src_lnk); } /* end if */ - if(ret_value < 0) - if(dst_lnk_init) + if (ret_value < 0) + if (dst_lnk_init) H5O_msg_reset(H5O_LINK_ID, dst_lnk); /* Check if we need to free the temp source oloc */ - if(expanded_link_open) - if(H5G_loc_free(&tmp_src_loc) < 0) + if (expanded_link_open) + if (H5G_loc_free(&tmp_src_loc) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTFREE, FAIL, "unable to free object") FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__link_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5L_iterate * @@ -3523,13 +3473,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx_p, H5L_iterate2_t op, void *op_data) +H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx_p, H5L_iterate2_t op, void *op_data) { - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_lnk; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ - herr_t ret_value = FAIL; /* Return value */ + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_lnk; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -3539,22 +3489,21 @@ H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, HDassert(op); /* Set up iteration beginning/end info */ - idx = (idx_p == NULL ? 0 : *idx_p); + idx = (idx_p == NULL ? 0 : *idx_p); last_lnk = 0; /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_NEW; - lnk_op.op_func.op_new = op; + lnk_op.op_type = H5G_LINK_OP_NEW; + lnk_op.op_func.op_new = op; /* Iterate over the links */ - if((ret_value = H5G_iterate(loc, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data)) < 0) + if ((ret_value = H5G_iterate(loc, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") /* Set the index we stopped at */ - if(idx_p) + if (idx_p) *idx_p = last_lnk; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_iterate() */ - diff --git a/src/H5Ldeprec.c b/src/H5Ldeprec.c index 8b83230..da1940c 100644 --- a/src/H5Ldeprec.c +++ b/src/H5Ldeprec.c @@ -25,17 +25,16 @@ /* Module Setup */ /****************/ -#include "H5Lmodule.h" /* This source code file is part of the H5L module */ - +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ #include "H5VLnative_private.h" @@ -45,44 +44,36 @@ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Shim data for using native H5Literate/visit callbacks with the VOL */ typedef struct H5L_shim_data_t { - H5L_iterate1_t real_op; - void *real_op_data; + H5L_iterate1_t real_op; + void * real_op_data; } H5L_shim_data_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5L__iterate2_shim * @@ -99,8 +90,8 @@ static herr_t H5L__iterate2_shim(hid_t group_id, const char *name, const H5L_info2_t *linfo2, void *op_data) { H5L_shim_data_t *shim_data = (H5L_shim_data_t *)op_data; - H5L_info1_t linfo; - herr_t ret_value = H5_ITER_CONT; + H5L_info1_t linfo; + herr_t ret_value = H5_ITER_CONT; FUNC_ENTER_STATIC @@ -111,8 +102,9 @@ H5L__iterate2_shim(hid_t group_id, const char *name, const H5L_info2_t *linfo2, linfo.corder = linfo2->corder; linfo.cset = linfo2->cset; if (H5L_TYPE_HARD == linfo2->type) { - if(H5VLnative_token_to_addr(group_id, linfo2->u.token, &linfo.u.address) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, H5_ITER_ERROR, "can't deserialize object token into address") + if (H5VLnative_token_to_addr(group_id, linfo2->u.token, &linfo.u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, H5_ITER_ERROR, + "can't deserialize object token into address") } else linfo.u.val_size = linfo2->u.val_size; @@ -125,7 +117,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__iterate2_shim() */ - /*------------------------------------------------------------------------- * Function: H5Literate1 * @@ -147,15 +138,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx_p, H5L_iterate1_t op, void *op_data) +H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate1_t op, + void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5I_type_t id_type; /* Type of ID */ - H5L_shim_data_t shim_data; - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIo*hx*x", group_id, idx_type, order, idx_p, op, op_data); @@ -176,29 +167,30 @@ H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Literate1 is only meant to be used with the native VOL connector") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Literate1 is only meant to be used with the native VOL connector") /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(group_id); /* Set up shim */ - shim_data.real_op = op; + shim_data.real_op = op; shim_data.real_op_data = op_data; /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, - H5L__iterate2_shim, (void *)&shim_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, + H5L__iterate2_shim, (void *)&shim_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Literate1() */ - /*------------------------------------------------------------------------- * Function: H5Literate_by_name1 * @@ -224,45 +216,45 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate_by_name1(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, - H5L_iterate1_t op, void *op_data, hid_t lapl_id) +H5Literate_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx_p, H5L_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5L_shim_data_t shim_data; - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id); /* Check arguments */ - if(!group_name) + if (!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") - if(!*group_name) + if (!*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Literate_by_name1 is only meant to be used with the native VOL connector") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Literate_by_name1 is only meant to be used with the native VOL connector") /* Set location struct fields */ loc_params.type = H5VL_OBJECT_BY_NAME; @@ -271,19 +263,19 @@ H5Literate_by_name1(hid_t loc_id, const char *group_name, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Set up shim */ - shim_data.real_op = op; + shim_data.real_op = op; shim_data.real_op_data = op_data; /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, - H5L__iterate2_shim, (void *)&shim_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, H5L__iterate2_shim, + (void *)&shim_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Literate_by_name1() */ - /*------------------------------------------------------------------------- * Function: H5Lget_info1 * @@ -300,59 +292,62 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, - hid_t lapl_id) +H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - H5L_info2_t linfo2; /* New-style link info */ - hbool_t is_native_vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + H5L_info2_t linfo2; /* New-style link info */ + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.obj_type = H5I_get_type(loc_id); - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lget_info1 is only meant to be used with the native VOL connector") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Lget_info1 is only meant to be used with the native VOL connector") /* Get the link information */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &linfo2) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &linfo2) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") /* Copy the new-style members into the old-style struct */ - if(linfo) { + if (linfo) { linfo->type = linfo2.type; linfo->corder_valid = linfo2.corder_valid; linfo->corder = linfo2.corder; linfo->cset = linfo2.cset; - if(H5L_TYPE_HARD == linfo2.type) { + if (H5L_TYPE_HARD == linfo2.type) { void *vol_obj_data; - if(NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + if (NULL == (vol_obj_data = H5VL_object_data(vol_obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") - if(H5VL_native_token_to_addr(vol_obj_data, loc_params.obj_type, linfo2.u.token, &linfo->u.address) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + if (H5VL_native_token_to_addr(vol_obj_data, loc_params.obj_type, linfo2.u.token, + &linfo->u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") } /* end if */ else linfo->u.val_size = linfo2.u.val_size; @@ -362,7 +357,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_info1() */ - /*------------------------------------------------------------------------- * Function: H5Lget_info_by_idx1 * @@ -380,68 +374,71 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info1_t *linfo /*out*/, hid_t lapl_id) +H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5L_info1_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - H5L_info2_t linfo2; /* New-style link info */ - hbool_t is_native_vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + H5L_info2_t linfo2; /* New-style link info */ + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, lapl_id); /* Check arguments */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lget_info_by_idx1 is only meant to be used with the native VOL connector") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Lget_info_by_idx1 is only meant to be used with the native VOL connector") /* Get the link information */ - if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &linfo2) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &linfo2) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") /* Copy the new-style members into the old-style struct */ - if(linfo) { + if (linfo) { linfo->type = linfo2.type; linfo->corder_valid = linfo2.corder_valid; linfo->corder = linfo2.corder; linfo->cset = linfo2.cset; - if(H5L_TYPE_HARD == linfo2.type) { + if (H5L_TYPE_HARD == linfo2.type) { void *vol_obj_data; - if(NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + if (NULL == (vol_obj_data = H5VL_object_data(vol_obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") - if(H5VL_native_token_to_addr(vol_obj_data, loc_params.obj_type, linfo2.u.token, &linfo->u.address) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + if (H5VL_native_token_to_addr(vol_obj_data, loc_params.obj_type, linfo2.u.token, + &linfo->u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") } /* end if */ else linfo->u.val_size = linfo2.u.val_size; @@ -451,7 +448,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_info_by_idx1() */ - /*------------------------------------------------------------------------- * Function: H5Lvisit1 * @@ -483,28 +479,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, - H5L_iterate1_t op, void *op_data) +H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5I_type_t id_type; /* Type of ID */ - H5L_shim_data_t shim_data; - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIox*x", group_id, idx_type, order, op, op_data); /* Check args */ id_type = H5I_get_type(group_id); - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Set location struct fields */ @@ -512,29 +507,30 @@ H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(group_id); /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lvisit1 is only meant to be used with the native VOL connector") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Lvisit1 is only meant to be used with the native VOL connector") /* Set up shim */ - shim_data.real_op = op; + shim_data.real_op = op; shim_data.real_op_data = op_data; /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, (void *)&shim_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, + (void *)&shim_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Lvisit1() */ - /*------------------------------------------------------------------------- * Function: H5Lvisit_by_name1 * @@ -566,44 +562,45 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, H5L_iterate1_t op, void *op_data, hid_t lapl_id) +H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5L_shim_data_t shim_data; - hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIox*xi", loc_id, group_name, idx_type, order, op, op_data, lapl_id); /* Check args */ - if(!group_name) + if (!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") - if(!*group_name) + if (!*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lvisit_by_name1 is only meant to be used with the native VOL connector") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Lvisit_by_name1 is only meant to be used with the native VOL connector") /* Set location struct fields */ loc_params.type = H5VL_OBJECT_BY_NAME; @@ -612,12 +609,13 @@ H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Set up shim */ - shim_data.real_op = op; + shim_data.real_op = op; shim_data.real_op_data = op_data; /* Visit the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, (void *)&shim_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, + (void *)&shim_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: @@ -625,4 +623,3 @@ done: } /* end H5Lvisit_by_name1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 8a3e3e1..361858b 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -15,80 +15,73 @@ /* Module Setup */ /****************/ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#include "H5Lmodule.h" /* This source code file is part of the H5L module */ - +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opublic.h" /* File objects */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opublic.h" /* File objects */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ /* Version of external link format */ -#define H5L_EXT_VERSION 0 +#define H5L_EXT_VERSION 0 /* Valid flags for external links */ -#define H5L_EXT_FLAGS_ALL 0 +#define H5L_EXT_FLAGS_ALL 0 /* Size of local link name buffer for traversing external links */ -#define H5L_EXT_TRAVERSE_BUF_SIZE 256 - +#define H5L_EXT_TRAVERSE_BUF_SIZE 256 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static hid_t H5L__extern_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id); -static ssize_t H5L__extern_query(const char *link_name, const void *udata, - size_t udata_size, void * buf /*out*/, size_t buf_size); - +static hid_t H5L__extern_traverse(const char *link_name, hid_t cur_group, const void *udata, + size_t udata_size, hid_t lapl_id, hid_t dxpl_id); +static ssize_t H5L__extern_query(const char *link_name, const void *udata, size_t udata_size, + void *buf /*out*/, size_t buf_size); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Default External Link link class */ static const H5L_class_t H5L_EXTERN_LINK_CLASS[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - H5L_TYPE_EXTERNAL, /* Link type id number */ - "external", /* Link name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move callback */ - NULL, /* Copy callback */ - H5L__extern_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - H5L__extern_query /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + H5L_TYPE_EXTERNAL, /* Link type id number */ + "external", /* Link name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move callback */ + NULL, /* Copy callback */ + H5L__extern_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + H5L__extern_query /* Query callback */ }}; /*------------------------------------------------------------------------- @@ -111,30 +104,29 @@ static const H5L_class_t H5L_EXTERN_LINK_CLASS[1] = {{ *------------------------------------------------------------------------- */ static hid_t -H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, - const void *_udata, size_t H5_ATTR_UNUSED udata_size, hid_t lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id) +H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const void *_udata, + size_t H5_ATTR_UNUSED udata_size, hid_t lapl_id, hid_t H5_ATTR_UNUSED dxpl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - H5G_loc_t root_loc; /* Location of root group in external file */ - H5G_loc_t loc; /* Location of object */ - H5F_t *ext_file = NULL; /* File struct for external file */ - const uint8_t *p = (const uint8_t *)_udata; /* Pointer into external link buffer */ - const char *file_name; /* Name of file containing external link's object */ - const char *obj_name; /* Name external link's object */ - size_t fname_len; /* Length of external link file name */ - unsigned intent; /* File access permissions */ - H5L_elink_cb_t cb_info; /* Callback info struct */ - hid_t fapl_id = H5I_INVALID_HID; /* File access property list for external link's file */ - void *ext_obj = NULL; /* External link's object */ - hid_t ext_obj_id = H5I_INVALID_HID; /* ID for external link's object */ - H5I_type_t opened_type; /* ID type of external link's object */ - char *parent_group_name = NULL;/* Temporary pointer to group name */ - char local_group_name[H5L_EXT_TRAVERSE_BUF_SIZE]; /* Local buffer to hold group name */ - H5P_genplist_t *fa_plist; /* File access property list pointer */ - H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */ - char *elink_prefix = NULL; /* Pointer to elink prefix */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5G_loc_t root_loc; /* Location of root group in external file */ + H5G_loc_t loc; /* Location of object */ + H5F_t * ext_file = NULL; /* File struct for external file */ + const uint8_t * p = (const uint8_t *)_udata; /* Pointer into external link buffer */ + const char * file_name; /* Name of file containing external link's object */ + const char * obj_name; /* Name external link's object */ + size_t fname_len; /* Length of external link file name */ + unsigned intent; /* File access permissions */ + H5L_elink_cb_t cb_info; /* Callback info struct */ + hid_t fapl_id = H5I_INVALID_HID; /* File access property list for external link's file */ + void * ext_obj = NULL; /* External link's object */ + hid_t ext_obj_id = H5I_INVALID_HID; /* ID for external link's object */ + H5I_type_t opened_type; /* ID type of external link's object */ + char * parent_group_name = NULL; /* Temporary pointer to group name */ + char local_group_name[H5L_EXT_TRAVERSE_BUF_SIZE]; /* Local buffer to hold group name */ + H5P_genplist_t * fa_plist; /* File access property list pointer */ + H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */ + char * elink_prefix = NULL; /* Pointer to elink prefix */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -142,131 +134,136 @@ H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, HDassert(p); /* Check external link version & flags */ - if(((*p >> 4) & 0x0F) > H5L_EXT_VERSION) + if (((*p >> 4) & 0x0F) > H5L_EXT_VERSION) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, H5I_INVALID_HID, "bad version number for external link") - if((*p & 0x0F) & ~H5L_EXT_FLAGS_ALL) + if ((*p & 0x0F) & ~H5L_EXT_FLAGS_ALL) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, H5I_INVALID_HID, "bad flags for external link") p++; /* Gather some information from the external link's user data */ file_name = (const char *)p; fname_len = HDstrlen(file_name); - obj_name = (const char *)p + fname_len + 1; + obj_name = (const char *)p + fname_len + 1; /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* Get the fapl_id set for lapl_id if any */ - if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get fapl for links") /* Get the location for the group holding the external link */ - if(H5G_loc(cur_group, &loc) < 0) + if (H5G_loc(cur_group, &loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") /* get the access flags set for lapl_id if any */ - if(H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, &intent) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, &intent) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get elink file access flags") /* get the file access mode flags for the parent file, if they were not set * on lapl_id */ - if(intent == H5F_ACC_DEFAULT) + if (intent == H5F_ACC_DEFAULT) intent = H5F_INTENT(loc.oloc->file); - if((fapl_id == H5P_DEFAULT) && ((fapl_id = H5F_get_access_plist(loc.oloc->file, FALSE)) < 0)) + if ((fapl_id == H5P_DEFAULT) && ((fapl_id = H5F_get_access_plist(loc.oloc->file, FALSE)) < 0)) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't get parent's file access property list") /* Get callback_info */ - if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get elink callback info") /* Get file access property list */ - if(NULL == (fa_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fa_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* Make callback if it exists */ - if(cb_info.func) { - const char *parent_file_name; /* Parent file name */ - ssize_t group_name_len; /* Length of parent group name */ + if (cb_info.func) { + const char *parent_file_name; /* Parent file name */ + ssize_t group_name_len; /* Length of parent group name */ /* Get parent file name */ parent_file_name = H5F_OPEN_NAME(loc.oloc->file); /* Query length of parent group name */ - if((group_name_len = H5G_get_name(&loc, NULL, (size_t) 0, NULL)) < 0) + if ((group_name_len = H5G_get_name(&loc, NULL, (size_t)0, NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve length of group name") /* Account for null terminator */ group_name_len++; /* Check if we need to allocate larger buffer */ - if((size_t)group_name_len > sizeof(local_group_name)) { - if(NULL == (parent_group_name = (char *)H5MM_malloc((size_t)group_name_len))) - HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate buffer to hold group name, group_name_len = %zd", group_name_len) + if ((size_t)group_name_len > sizeof(local_group_name)) { + if (NULL == (parent_group_name = (char *)H5MM_malloc((size_t)group_name_len))) + HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, H5I_INVALID_HID, + "can't allocate buffer to hold group name, group_name_len = %zd", group_name_len) } /* end if */ else parent_group_name = local_group_name; /* Get parent group name */ - if(H5G_get_name(&loc, parent_group_name, (size_t) group_name_len, NULL) < 0) + if (H5G_get_name(&loc, parent_group_name, (size_t)group_name_len, NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve group name") /* Make callback */ - if((cb_info.func)(parent_file_name, parent_group_name, file_name, obj_name, &intent, fapl_id, cb_info.user_data) < 0) + if ((cb_info.func)(parent_file_name, parent_group_name, file_name, obj_name, &intent, fapl_id, + cb_info.user_data) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, H5I_INVALID_HID, "traversal operator failed") /* Check access flags */ - if((intent & H5F_ACC_TRUNC) || (intent & H5F_ACC_EXCL)) + if ((intent & H5F_ACC_TRUNC) || (intent & H5F_ACC_EXCL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file open flags") } /* end if */ /* Set file close degree for new file to "weak" */ - if(H5P_set(fa_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) + if (H5P_set(fa_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") /* Get the current elink prefix */ - if(H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &elink_prefix) < 0) + if (H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &elink_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get external link prefix") /* Search for the target file */ - if(NULL == (ext_file = H5F_prefix_open_file(loc.oloc->file, H5F_PREFIX_ELINK, elink_prefix, file_name, intent, fapl_id))) - HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open external file, external link file name = '%s'", file_name) + if (NULL == (ext_file = H5F_prefix_open_file(loc.oloc->file, H5F_PREFIX_ELINK, elink_prefix, file_name, + intent, fapl_id))) + HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, H5I_INVALID_HID, + "unable to open external file, external link file name = '%s'", file_name) /* Retrieve the "group location" for the file's root group */ - if(H5G_root_loc(ext_file, &root_loc) < 0) + if (H5G_root_loc(ext_file, &root_loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, H5I_INVALID_HID, "unable to create location for file") /* Open the object referenced in the external file */ - if(NULL == (ext_obj = H5O_open_name(&root_loc, obj_name, &opened_type))) + if (NULL == (ext_obj = H5O_open_name(&root_loc, obj_name, &opened_type))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") /* Get an ID for the external link's object */ - if((ext_obj_id = H5VL_wrap_register(opened_type, ext_obj, TRUE)) < 0) + if ((ext_obj_id = H5VL_wrap_register(opened_type, ext_obj, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register external link object") /* Set return value */ ret_value = ext_obj_id; done: -/* XXX (VOL MERGE): Probably also want to consider closing ext_obj here on failures */ + /* XXX (VOL MERGE): Probably also want to consider closing ext_obj here on failures */ /* Release resources */ - if(fapl_id > 0 && H5I_dec_ref(fapl_id) < 0) - HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to close atom for file access property list") - if(ext_file && H5F_efc_close(loc.oloc->file, ext_file) < 0) + if (fapl_id > 0 && H5I_dec_ref(fapl_id) < 0) + HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, + "unable to close atom for file access property list") + if (ext_file && H5F_efc_close(loc.oloc->file, ext_file) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problem closing external file") - if(parent_group_name && parent_group_name != local_group_name) + if (parent_group_name && parent_group_name != local_group_name) parent_group_name = (char *)H5MM_xfree(parent_group_name); - if(ret_value < 0) { + if (ret_value < 0) { /* Close object if it's open and something failed */ - if(ext_obj_id >= 0 && H5I_dec_ref(ext_obj_id) < 0) - HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to close atom for external object") + if (ext_obj_id >= 0 && H5I_dec_ref(ext_obj_id) < 0) + HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, + "unable to close atom for external object") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__extern_traverse() */ - /*------------------------------------------------------------------------- * Function: H5L__extern_query * @@ -285,24 +282,24 @@ done: *------------------------------------------------------------------------- */ static ssize_t -H5L__extern_query(const char H5_ATTR_UNUSED * link_name, const void *_udata, size_t udata_size, - void *buf /*out*/, size_t buf_size) +H5L__extern_query(const char H5_ATTR_UNUSED *link_name, const void *_udata, size_t udata_size, + void *buf /*out*/, size_t buf_size) { - const uint8_t *udata = (const uint8_t *)_udata; /* Pointer to external link buffer */ - ssize_t ret_value = SUCCEED; /* Return value */ + const uint8_t *udata = (const uint8_t *)_udata; /* Pointer to external link buffer */ + ssize_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check external link version & flags */ - if(((*udata >> 4) & 0x0F) != H5L_EXT_VERSION) + if (((*udata >> 4) & 0x0F) != H5L_EXT_VERSION) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad version number for external link") - if((*udata & 0x0F) & ~H5L_EXT_FLAGS_ALL) + if ((*udata & 0x0F) & ~H5L_EXT_FLAGS_ALL) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad flags for external link") /* If the buffer is NULL, skip writing anything in it and just return * the size needed */ - if(buf) { - if(udata_size < buf_size) + if (buf) { + if (udata_size < buf_size) buf_size = udata_size; /* Copy the udata verbatim up to buf_size */ @@ -316,7 +313,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__extern_query() */ - /*------------------------------------------------------------------------- * Function: H5Lcreate_external * @@ -338,60 +334,60 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lcreate_external(const char *file_name, const char *obj_name, - hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) +H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name, + hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - char *norm_obj_name = NULL; /* Pointer to normalized current name */ - void *ext_link_buf = NULL; /* Buffer to contain external link */ - size_t buf_size; /* Size of buffer to hold external link */ - size_t file_name_len; /* Length of file name string */ - size_t norm_obj_name_len; /* Length of normalized object name string */ - uint8_t *p; /* Pointer into external link buffer */ - H5L_type_t link_type = H5L_TYPE_EXTERNAL; - herr_t ret_value = SUCCEED; /* Return value */ + char * norm_obj_name = NULL; /* Pointer to normalized current name */ + void * ext_link_buf = NULL; /* Buffer to contain external link */ + size_t buf_size; /* Size of buffer to hold external link */ + size_t file_name_len; /* Length of file name string */ + size_t norm_obj_name_len; /* Length of normalized object name string */ + uint8_t * p; /* Pointer into external link buffer */ + H5L_type_t link_type = H5L_TYPE_EXTERNAL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "*s*si*sii", file_name, obj_name, link_loc_id, link_name, lcpl_id, lapl_id); /* Check arguments */ - if(!file_name || !*file_name) + if (!file_name || !*file_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no file name specified") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name specified") - if(!link_name || !*link_name) + if (!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") /* Get the link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Get normalized copy of the link target */ - if(NULL == (norm_obj_name = H5G_normalize(obj_name))) + if (NULL == (norm_obj_name = H5G_normalize(obj_name))) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize object name") /* Combine the filename and link name into a single buffer to give to the UD link */ - file_name_len = HDstrlen(file_name) + 1; + file_name_len = HDstrlen(file_name) + 1; norm_obj_name_len = HDstrlen(norm_obj_name) + 1; - buf_size = 1 + file_name_len + norm_obj_name_len; - if(NULL == (ext_link_buf = H5MM_malloc(buf_size))) + buf_size = 1 + file_name_len + norm_obj_name_len; + if (NULL == (ext_link_buf = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate udata buffer") /* Encode the external link information */ - p = (uint8_t *)ext_link_buf; - *p++ = (H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL; /* External link version & flags */ - HDstrncpy((char *)p, file_name, buf_size - 1); /* Name of file containing external link's object */ + p = (uint8_t *)ext_link_buf; + *p++ = (H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL; /* External link version & flags */ + HDstrncpy((char *)p, file_name, buf_size - 1); /* Name of file containing external link's object */ p += file_name_len; - HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ + HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.loc_data.loc_by_name.name = link_name; @@ -399,11 +395,13 @@ H5Lcreate_external(const char *file_name, const char *obj_name, loc_params.obj_type = H5I_get_type(link_loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Create an external link */ - if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, ext_link_buf, buf_size) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, ext_link_buf, + buf_size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link") done: @@ -413,7 +411,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_external() */ - /*------------------------------------------------------------------------- * Function: H5L_register_external * @@ -431,18 +428,17 @@ done: herr_t H5L_register_external(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5L_register(H5L_EXTERN_LINK_CLASS) < 0) + if (H5L_register(H5L_EXTERN_LINK_CLASS) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register external link class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_register_external() */ - /*------------------------------------------------------------------------- * Function: H5Lunpack_elink_val * @@ -467,35 +463,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, - unsigned *flags, const char **filename, const char **obj_path) +H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, unsigned *flags, const char **filename, + const char **obj_path) { const uint8_t *ext_linkval = (const uint8_t *)_ext_linkval; /* Pointer to the link value */ - unsigned lnk_version; /* External link format version */ - unsigned lnk_flags; /* External link flags */ - size_t len; /* Length of the filename in the linkval*/ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned lnk_version; /* External link format version */ + unsigned lnk_flags; /* External link flags */ + size_t len; /* Length of the filename in the linkval*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*xz*Iu**s**s", _ext_linkval, link_size, flags, filename, obj_path); /* Sanity check external link buffer */ - if(ext_linkval == NULL ) + if (ext_linkval == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an external link linkval buffer") lnk_version = (*ext_linkval >> 4) & 0x0F; - lnk_flags = *ext_linkval & 0x0F; - if(lnk_version > H5L_EXT_VERSION) + lnk_flags = *ext_linkval & 0x0F; + if (lnk_version > H5L_EXT_VERSION) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad version number for external link") - if(lnk_flags & (unsigned)~H5L_EXT_FLAGS_ALL) + if (lnk_flags & (unsigned)~H5L_EXT_FLAGS_ALL) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad flags for external link") - if(link_size <= 2) + if (link_size <= 2) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid external link buffer") /* Try to do some error checking. If the last character in the linkval * (the last character of obj_path) isn't NULL, then something's wrong. */ - if(ext_linkval[link_size - 1] != '\0') + if (ext_linkval[link_size - 1] != '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer is not NULL-terminated") /* We're now guaranteed that HDstrlen won't segfault, since the buffer has @@ -506,23 +502,22 @@ H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, /* If the first NULL we found was at the very end of the buffer, then * this external link value has no object name and is invalid. */ - if((len + 1) >= (link_size - 1)) + if ((len + 1) >= (link_size - 1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer doesn't contain an object path") /* If we got here then the buffer contains (at least) two strings packed * in the correct way. Assume it's correct and return pointers to the * filename and object path. */ - if(filename) + if (filename) *filename = (const char *)ext_linkval + 1; - if(obj_path) - *obj_path = ((const char *)ext_linkval + 1) + len + 1; /* Add one for NULL terminator */ + if (obj_path) + *obj_path = ((const char *)ext_linkval + 1) + len + 1; /* Add one for NULL terminator */ /* Set the flags to return */ - if(flags) + if (flags) *flags = lnk_flags; done: FUNC_LEAVE_API(ret_value) } /* end H5Lunpack_elink_val() */ - diff --git a/src/H5Lmodule.h b/src/H5Lmodule.h index cba4de4..5c2d022 100644 --- a/src/H5Lmodule.h +++ b/src/H5Lmodule.h @@ -25,10 +25,8 @@ * reporting macros. */ #define H5L_MODULE -#define H5_MY_PKG H5L -#define H5_MY_PKG_ERR H5E_LINK -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5L +#define H5_MY_PKG_ERR H5E_LINK +#define H5_MY_PKG_INIT YES #endif /* _H5Lmodule_H */ - - diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h index f0e9cfc..2e1ac61 100644 --- a/src/H5Lpkg.h +++ b/src/H5Lpkg.h @@ -31,31 +31,25 @@ /* Other private headers needed by this file */ - /**************************/ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, - const void * ud_data, size_t ud_data_size, H5L_type_t type, - hid_t lcpl_id); -H5_DLL herr_t H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, - const H5O_loc_t *src_oloc, H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); +H5_DLL herr_t H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, const void *ud_data, + size_t ud_data_size, H5L_type_t type, hid_t lcpl_id); +H5_DLL herr_t H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, + H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); #endif /* _H5Lpkg_H */ - diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index 0487557..1302ee4 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -22,27 +22,26 @@ #include "H5Lpublic.h" /* Private headers needed by this file */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ - +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ /**************************/ /* Library Private Macros */ /**************************/ /* Default number of soft links to traverse */ -#define H5L_NUM_LINKS 16 +#define H5L_NUM_LINKS 16 /* ======== Link creation property names ======== */ -#define H5L_CRT_INTERMEDIATE_GROUP_NAME "intermediate_group" /* Create intermediate groups flag */ +#define H5L_CRT_INTERMEDIATE_GROUP_NAME "intermediate_group" /* Create intermediate groups flag */ /* ======== Link access property names ======== */ -#define H5L_ACS_NLINKS_NAME "max soft links" /* Number of soft links to traverse */ -#define H5L_ACS_ELINK_PREFIX_NAME "external link prefix" /* External link prefix */ -#define H5L_ACS_ELINK_FAPL_NAME "external link fapl" /* file access property list for external link access */ -#define H5L_ACS_ELINK_FLAGS_NAME "external link flags" /* file access flags for external link traversal */ -#define H5L_ACS_ELINK_CB_NAME "external link callback" /* callback function for external link traversal */ - +#define H5L_ACS_NLINKS_NAME "max soft links" /* Number of soft links to traverse */ +#define H5L_ACS_ELINK_PREFIX_NAME "external link prefix" /* External link prefix */ +#define H5L_ACS_ELINK_FAPL_NAME "external link fapl" /* file access property list for external link access \ + */ +#define H5L_ACS_ELINK_FLAGS_NAME "external link flags" /* file access flags for external link traversal */ +#define H5L_ACS_ELINK_CB_NAME "external link callback" /* callback function for external link traversal */ /****************************/ /* Library Private Typedefs */ @@ -51,97 +50,88 @@ /* User data for path traversal routine for getting link value by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - size_t size; /* Size of user buffer */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + size_t size; /* Size of user buffer */ /* Out */ - void *buf; /* User buffer */ + void *buf; /* User buffer */ } H5L_trav_gvbi_t; /* User data for path traversal routine for getting link info by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ /* Out */ - H5L_info2_t *linfo; /* Buffer to return to user */ + H5L_info2_t *linfo; /* Buffer to return to user */ } H5L_trav_gibi_t; /* User data for path traversal routine for getting name by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - size_t size; /* Size of name buffer */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + size_t size; /* Size of name buffer */ /* Out */ - char *name; /* Buffer to return name to user */ - ssize_t name_len; /* Length of full name */ + char * name; /* Buffer to return name to user */ + ssize_t name_len; /* Length of full name */ } H5L_trav_gnbi_t; /* User data for path traversal routine for removing link by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ } H5L_trav_rmbi_t; /* Structure for external link traversal callback property */ typedef struct H5L_elink_cb_t { - H5L_elink_traverse_t func; - void *user_data; + H5L_elink_traverse_t func; + void * user_data; } H5L_elink_cb_t; /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ /* General operations on links */ -H5_DLL herr_t H5L_init(void); -H5_DLL herr_t H5L_link(const H5G_loc_t *new_loc, const char *new_name, - H5G_loc_t *obj_loc, hid_t lcpl_id); -H5_DLL herr_t H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, - H5O_obj_create_t *ocrt_info, hid_t lcpl_id); -H5_DLL herr_t H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, - const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id); -H5_DLL herr_t H5L_create_soft(const char *target_path, const H5G_loc_t *cur_loc, - const char *cur_name, hid_t lcpl_id); -H5_DLL herr_t H5L_move(const H5G_loc_t *src_loc, const char *src_name, - const H5G_loc_t *dst_loc, const char *dst_name, hbool_t copy_flag, - hid_t lcpl_id); -H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name); -H5_DLL htri_t H5L_exists(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, - H5L_info2_t *linkbuf/*out*/); -H5_DLL herr_t H5L_delete(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5L_delete_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5L_get_info_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info2_t *linfo /*out*/); -H5_DLL ssize_t H5L_get_name_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - char *name /*out*/, size_t size); -H5_DLL herr_t H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf/*out*/, - size_t size); -H5_DLL herr_t H5L_get_val_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - void *buf/*out*/, size_t size); -H5_DLL herr_t H5L_register_external(void); -H5_DLL herr_t H5L_iterate(H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, - H5L_iterate2_t op, void *op_data); +H5_DLL herr_t H5L_init(void); +H5_DLL herr_t H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc, hid_t lcpl_id); +H5_DLL herr_t H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, H5O_obj_create_t *ocrt_info, + hid_t lcpl_id); +H5_DLL herr_t H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, const H5G_loc_t *link_loc, + const char *link_name, hid_t lcpl_id); +H5_DLL herr_t H5L_create_soft(const char *target_path, const H5G_loc_t *cur_loc, const char *cur_name, + hid_t lcpl_id); +H5_DLL herr_t H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, + const char *dst_name, hbool_t copy_flag, hid_t lcpl_id); +H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name); +H5_DLL htri_t H5L_exists(const H5G_loc_t *loc, const char *name); +H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info2_t *linkbuf /*out*/); +H5_DLL herr_t H5L_delete(const H5G_loc_t *loc, const char *name); +H5_DLL herr_t H5L_delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5L_get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/); +H5_DLL ssize_t H5L_get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size); +H5_DLL herr_t H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf /*out*/, size_t size); +H5_DLL herr_t H5L_get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, void *buf /*out*/, size_t size); +H5_DLL herr_t H5L_register_external(void); +H5_DLL herr_t H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx_p, H5L_iterate2_t op, void *op_data); /* User-defined link functions */ H5_DLL herr_t H5L_register(const H5L_class_t *cls); @@ -149,4 +139,3 @@ H5_DLL herr_t H5L_unregister(H5L_type_t id); H5_DLL const H5L_class_t *H5L_find_class(H5L_type_t id); #endif /* _H5Lprivate_H */ - diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index 3bac5ac..1833bc9 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -25,10 +25,10 @@ #define _H5Lpublic_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Ipublic.h" /* IDs */ -#include "H5Opublic.h" /* Object Headers */ -#include "H5Tpublic.h" /* Datatypes */ +#include "H5public.h" /* Generic Functions */ +#include "H5Ipublic.h" /* IDs */ +#include "H5Opublic.h" /* Object Headers */ +#include "H5Tpublic.h" /* Datatypes */ /*****************/ /* Public Macros */ @@ -36,13 +36,13 @@ /* Maximum length of a link's name */ /* (encoded in a 32-bit unsigned integer) */ -#define H5L_MAX_LINK_NAME_LEN ((uint32_t)(-1)) /* (4GB - 1) */ +#define H5L_MAX_LINK_NAME_LEN ((uint32_t)(-1)) /* (4GB - 1) */ /* Macro to indicate operation occurs on same location */ #define H5L_SAME_LOC (hid_t)0 /* Current version of the H5L_class_t struct */ -#define H5L_LINK_CLASS_T_VERS 1 +#define H5L_LINK_CLASS_T_VERS 1 #ifdef __cplusplus extern "C" { @@ -61,26 +61,27 @@ extern "C" { * These values can never change because they appear in HDF5 files. */ typedef enum { - H5L_TYPE_ERROR = (-1), /* Invalid link type id */ - H5L_TYPE_HARD = 0, /* Hard link id */ - H5L_TYPE_SOFT = 1, /* Soft link id */ - H5L_TYPE_EXTERNAL = 64, /* External link id */ - H5L_TYPE_MAX = 255 /* Maximum link type id */ + H5L_TYPE_ERROR = (-1), /* Invalid link type id */ + H5L_TYPE_HARD = 0, /* Hard link id */ + H5L_TYPE_SOFT = 1, /* Soft link id */ + H5L_TYPE_EXTERNAL = 64, /* External link id */ + H5L_TYPE_MAX = 255 /* Maximum link type id */ } H5L_type_t; -#define H5L_TYPE_BUILTIN_MAX H5L_TYPE_SOFT /* Maximum value link value for "built-in" link types */ -#define H5L_TYPE_UD_MIN H5L_TYPE_EXTERNAL /* Link ids at or above this value are "user-defined" link types. */ +#define H5L_TYPE_BUILTIN_MAX H5L_TYPE_SOFT /* Maximum value link value for "built-in" link types */ +#define H5L_TYPE_UD_MIN H5L_TYPE_EXTERNAL /* Link ids at or above this value are "user-defined" link types. \ + */ /* Information struct for link (for H5Lget_info2/H5Lget_info_by_idx2) * H5O_token_t version used in VOL layer and future public API calls */ typedef struct { - H5L_type_t type; /* Type of link */ - hbool_t corder_valid; /* Indicate if creation order is valid */ - int64_t corder; /* Creation order */ - H5T_cset_t cset; /* Character set of link name */ + H5L_type_t type; /* Type of link */ + hbool_t corder_valid; /* Indicate if creation order is valid */ + int64_t corder; /* Creation order */ + H5T_cset_t cset; /* Character set of link name */ union { - H5O_token_t token; /* Token of location that hard link points to */ - size_t val_size; /* Size of a soft link or UD link value */ + H5O_token_t token; /* Token of location that hard link points to */ + size_t val_size; /* Size of a soft link or UD link value */ } u; } H5L_info2_t; @@ -90,112 +91,104 @@ typedef struct { */ /* Callback prototypes for user-defined links */ /* Link creation callback */ -typedef herr_t (*H5L_create_func_t)(const char *link_name, hid_t loc_group, - const void *lnkdata, size_t lnkdata_size, hid_t lcpl_id); +typedef herr_t (*H5L_create_func_t)(const char *link_name, hid_t loc_group, const void *lnkdata, + size_t lnkdata_size, hid_t lcpl_id); /* Callback for when the link is moved */ -typedef herr_t (*H5L_move_func_t)(const char *new_name, hid_t new_loc, - const void *lnkdata, size_t lnkdata_size); +typedef herr_t (*H5L_move_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, + size_t lnkdata_size); /* Callback for when the link is copied */ -typedef herr_t (*H5L_copy_func_t)(const char *new_name, hid_t new_loc, - const void *lnkdata, size_t lnkdata_size); +typedef herr_t (*H5L_copy_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, + size_t lnkdata_size); /* Callback during link traversal */ -typedef hid_t (*H5L_traverse_func_t)(const char *link_name, hid_t cur_group, - const void *lnkdata, size_t lnkdata_size, hid_t lapl_id, hid_t dxpl_id); +typedef hid_t (*H5L_traverse_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, + size_t lnkdata_size, hid_t lapl_id, hid_t dxpl_id); /* Callback for when the link is deleted */ -typedef herr_t (*H5L_delete_func_t)(const char *link_name, hid_t file, - const void *lnkdata, size_t lnkdata_size); +typedef herr_t (*H5L_delete_func_t)(const char *link_name, hid_t file, const void *lnkdata, + size_t lnkdata_size); /* Callback for querying the link */ /* Returns the size of the buffer needed */ -typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, - size_t lnkdata_size, void *buf /*out*/, size_t buf_size); +typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, size_t lnkdata_size, + void *buf /*out*/, size_t buf_size); typedef struct { - int version; /* Version number of this struct */ - H5L_type_t id; /* Link type ID */ - const char *comment; /* Comment for debugging */ - H5L_create_func_t create_func; /* Callback during link creation */ - H5L_move_func_t move_func; /* Callback after moving link */ - H5L_copy_func_t copy_func; /* Callback after copying link */ - H5L_traverse_func_t trav_func; /* Callback during link traversal */ - H5L_delete_func_t del_func; /* Callback for link deletion */ - H5L_query_func_t query_func; /* Callback for queries */ + int version; /* Version number of this struct */ + H5L_type_t id; /* Link type ID */ + const char * comment; /* Comment for debugging */ + H5L_create_func_t create_func; /* Callback during link creation */ + H5L_move_func_t move_func; /* Callback after moving link */ + H5L_copy_func_t copy_func; /* Callback after copying link */ + H5L_traverse_func_t trav_func; /* Callback during link traversal */ + H5L_delete_func_t del_func; /* Callback for link deletion */ + H5L_query_func_t query_func; /* Callback for queries */ } H5L_class_t; /* Prototype for H5Literate2/H5Literate_by_name2() operator * H5O_token_t version used in VOL layer and future public API calls */ -typedef herr_t (*H5L_iterate2_t)(hid_t group, const char *name, const H5L_info2_t *info, - void *op_data); +typedef herr_t (*H5L_iterate2_t)(hid_t group, const char *name, const H5L_info2_t *info, void *op_data); /* Callback for external link traversal */ -typedef herr_t (*H5L_elink_traverse_t)(const char *parent_file_name, - const char *parent_group_name, const char *child_file_name, - const char *child_object_name, unsigned *acc_flags, hid_t fapl_id, - void *op_data); - +typedef herr_t (*H5L_elink_traverse_t)(const char *parent_file_name, const char *parent_group_name, + const char *child_file_name, const char *child_object_name, + unsigned *acc_flags, hid_t fapl_id, void *op_data); /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ -H5_DLL herr_t H5Lmove(hid_t src_loc, const char *src_name, hid_t dst_loc, - const char *dst_name, hid_t lcpl_id, hid_t lapl_id); -H5_DLL herr_t H5Lcopy(hid_t src_loc, const char *src_name, hid_t dst_loc, - const char *dst_name, hid_t lcpl_id, hid_t lapl_id); -H5_DLL herr_t H5Lcreate_hard(hid_t cur_loc, const char *cur_name, - hid_t dst_loc, const char *dst_name, hid_t lcpl_id, hid_t lapl_id); -H5_DLL herr_t H5Lcreate_soft(const char *link_target, hid_t link_loc_id, - const char *link_name, hid_t lcpl_id, hid_t lapl_id); +H5_DLL herr_t H5Lmove(hid_t src_loc, const char *src_name, hid_t dst_loc, const char *dst_name, hid_t lcpl_id, + hid_t lapl_id); +H5_DLL herr_t H5Lcopy(hid_t src_loc, const char *src_name, hid_t dst_loc, const char *dst_name, hid_t lcpl_id, + hid_t lapl_id); +H5_DLL herr_t H5Lcreate_hard(hid_t cur_loc, const char *cur_name, hid_t dst_loc, const char *dst_name, + hid_t lcpl_id, hid_t lapl_id); +H5_DLL herr_t H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, + hid_t lapl_id); H5_DLL herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id); -H5_DLL herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, - size_t size, hid_t lapl_id); -H5_DLL herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - void *buf/*out*/, size_t size, hid_t lapl_id); +H5_DLL herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, hid_t lapl_id); +H5_DLL herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf /*out*/, size_t size, hid_t lapl_id); +H5_DLL herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, void *buf /*out*/, size_t size, + hid_t lapl_id); H5_DLL htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL herr_t H5Lget_info2(hid_t loc_id, const char *name, - H5L_info2_t *linfo /*out*/, hid_t lapl_id); -H5_DLL herr_t H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info2_t *linfo /*out*/, hid_t lapl_id); -H5_DLL ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - char *name /*out*/, size_t size, hid_t lapl_id); -H5_DLL herr_t H5Literate2(hid_t grp_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5L_iterate2_t op, void *op_data); -H5_DLL herr_t H5Literate_by_name2(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, - H5L_iterate2_t op, void *op_data, hid_t lapl_id); -H5_DLL herr_t H5Lvisit2(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, - H5L_iterate2_t op, void *op_data); -H5_DLL herr_t H5Lvisit_by_name2(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, - void *op_data, hid_t lapl_id); +H5_DLL herr_t H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, hid_t lapl_id); +H5_DLL herr_t H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/, + hid_t lapl_id); +H5_DLL ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, + hid_t lapl_id); +H5_DLL herr_t H5Literate2(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate2_t op, void *op_data); +H5_DLL herr_t H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5L_iterate2_t op, void *op_data, + hid_t lapl_id); +H5_DLL herr_t H5Lvisit2(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, + void *op_data); +H5_DLL herr_t H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, H5L_iterate2_t op, void *op_data, hid_t lapl_id); /* UD link functions */ -H5_DLL herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name, - H5L_type_t link_type, const void *udata, size_t udata_size, hid_t lcpl_id, - hid_t lapl_id); +H5_DLL herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata, + size_t udata_size, hid_t lcpl_id, hid_t lapl_id); H5_DLL herr_t H5Lregister(const H5L_class_t *cls); H5_DLL herr_t H5Lunregister(H5L_type_t id); H5_DLL htri_t H5Lis_registered(H5L_type_t id); /* External link functions */ -H5_DLL herr_t H5Lunpack_elink_val(const void *ext_linkval/*in*/, size_t link_size, - unsigned *flags, const char **filename/*out*/, const char **obj_path /*out*/); -H5_DLL herr_t H5Lcreate_external(const char *file_name, const char *obj_name, - hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id); +H5_DLL herr_t H5Lunpack_elink_val(const void *ext_linkval /*in*/, size_t link_size, unsigned *flags, + const char **filename /*out*/, const char **obj_path /*out*/); +H5_DLL herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, + const char *link_name, hid_t lcpl_id, hid_t lapl_id); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -206,61 +199,56 @@ H5_DLL herr_t H5Lcreate_external(const char *file_name, const char *obj_name, /* Macros */ /* Previous versions of the H5L_class_t struct */ -#define H5L_LINK_CLASS_T_VERS_0 0 - +#define H5L_LINK_CLASS_T_VERS_0 0 /* Typedefs */ /* Information struct for link (for H5Lget_info1/H5Lget_info_by_idx1) */ typedef struct { - H5L_type_t type; /* Type of link */ - hbool_t corder_valid; /* Indicate if creation order is valid */ - int64_t corder; /* Creation order */ - H5T_cset_t cset; /* Character set of link name */ + H5L_type_t type; /* Type of link */ + hbool_t corder_valid; /* Indicate if creation order is valid */ + int64_t corder; /* Creation order */ + H5T_cset_t cset; /* Character set of link name */ union { - haddr_t address; /* Address hard link points to */ - size_t val_size; /* Size of a soft link or UD link value */ + haddr_t address; /* Address hard link points to */ + size_t val_size; /* Size of a soft link or UD link value */ } u; } H5L_info1_t; /* Callback during link traversal */ -typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, - const void *lnkdata, size_t lnkdata_size, hid_t lapl_id); +typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, + size_t lnkdata_size, hid_t lapl_id); /* User-defined link types */ typedef struct { - int version; /* Version number of this struct */ - H5L_type_t id; /* Link type ID */ - const char *comment; /* Comment for debugging */ - H5L_create_func_t create_func; /* Callback during link creation */ - H5L_move_func_t move_func; /* Callback after moving link */ - H5L_copy_func_t copy_func; /* Callback after copying link */ - H5L_traverse_0_func_t trav_func; /* Callback during link traversal */ - H5L_delete_func_t del_func; /* Callback for link deletion */ - H5L_query_func_t query_func; /* Callback for queries */ + int version; /* Version number of this struct */ + H5L_type_t id; /* Link type ID */ + const char * comment; /* Comment for debugging */ + H5L_create_func_t create_func; /* Callback during link creation */ + H5L_move_func_t move_func; /* Callback after moving link */ + H5L_copy_func_t copy_func; /* Callback after copying link */ + H5L_traverse_0_func_t trav_func; /* Callback during link traversal */ + H5L_delete_func_t del_func; /* Callback for link deletion */ + H5L_query_func_t query_func; /* Callback for queries */ } H5L_class_0_t; /* Prototype for H5Literate1/H5Literate_by_name1() operator */ -typedef herr_t (*H5L_iterate1_t)(hid_t group, const char *name, const H5L_info1_t *info, - void *op_data); - +typedef herr_t (*H5L_iterate1_t)(hid_t group, const char *name, const H5L_info1_t *info, void *op_data); /* Function prototypes */ -H5_DLL herr_t H5Lget_info1(hid_t loc_id, const char *name, - H5L_info1_t *linfo /*out*/, hid_t lapl_id); -H5_DLL herr_t H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info1_t *linfo /*out*/, hid_t lapl_id); -H5_DLL herr_t H5Literate1(hid_t grp_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5L_iterate1_t op, void *op_data); -H5_DLL herr_t H5Literate_by_name1(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, - H5L_iterate1_t op, void *op_data, hid_t lapl_id); -H5_DLL herr_t H5Lvisit1(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, - H5L_iterate1_t op, void *op_data); -H5_DLL herr_t H5Lvisit_by_name1(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, - void *op_data, hid_t lapl_id); +H5_DLL herr_t H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t lapl_id); +H5_DLL herr_t H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5L_info1_t *linfo /*out*/, + hid_t lapl_id); +H5_DLL herr_t H5Literate1(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate1_t op, void *op_data); +H5_DLL herr_t H5Literate_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5L_iterate1_t op, void *op_data, + hid_t lapl_id); +H5_DLL herr_t H5Lvisit1(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, + void *op_data); +H5_DLL herr_t H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, H5L_iterate1_t op, void *op_data, hid_t lapl_id); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -268,4 +256,3 @@ H5_DLL herr_t H5Lvisit_by_name1(hid_t loc_id, const char *group_name, } #endif #endif /* _H5Lpublic_H */ - diff --git a/src/H5M.c b/src/H5M.c index 0866bb7..e3091ca 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -15,38 +15,32 @@ /* Module Setup */ /****************/ -#include "H5Mmodule.h" /* This source code file is part of the H5M module */ - +#include "H5Mmodule.h" /* This source code file is part of the H5M module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Mpkg.h" /* Maps */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Mpkg.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5M__close_cb(H5VL_object_t *map_vol_obj); - /*********************/ /* Package Variables */ /*********************/ @@ -54,29 +48,25 @@ static herr_t H5M__close_cb(H5VL_object_t *map_vol_obj); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Map ID class */ static const H5I_class_t H5I_MAP_CLS[1] = {{ - H5I_MAP, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5M__close_cb /* Callback routine for closing objects of this class */ + H5I_MAP, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5M__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ static hbool_t H5M_top_package_initialize_s = FALSE; - - /*------------------------------------------------------------------------- * Function: H5M_init * @@ -90,7 +80,7 @@ static hbool_t H5M_top_package_initialize_s = FALSE; herr_t H5M_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -99,7 +89,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5M_init() */ - /*------------------------------------------------------------------------- NAME H5M__init_package -- Initialize interface-specific information @@ -115,12 +104,12 @@ DESCRIPTION herr_t H5M__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the map IDs */ - if(H5I_register_type(H5I_MAP_CLS) < 0) + if (H5I_register_type(H5I_MAP_CLS) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Mark "top" of interface as initialized, too */ @@ -130,7 +119,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5M__init_package() */ - /*------------------------------------------------------------------------- * Function: H5M_top_term_package * @@ -144,25 +132,24 @@ done: int H5M_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5M_top_package_initialize_s) { - if(H5I_nmembers(H5I_MAP) > 0) { + if (H5M_top_package_initialize_s) { + if (H5I_nmembers(H5I_MAP) > 0) { (void)H5I_clear_type(H5I_MAP, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark closed */ - if(0 == n) + if (0 == n) H5M_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5M_top_term_package() */ - /*------------------------------------------------------------------------- * Function: H5M_term_package * @@ -179,11 +166,11 @@ H5M_top_term_package(void) int H5M_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_MAP)); HDassert(FALSE == H5M_top_package_initialize_s); @@ -192,14 +179,13 @@ H5M_term_package(void) n += (H5I_dec_type_ref(H5I_MAP) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5M_term_package() */ - /*------------------------------------------------------------------------- * Function: H5M__close_cb * @@ -212,7 +198,7 @@ H5M_term_package(void) static herr_t H5M__close_cb(H5VL_object_t *map_vol_obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -220,11 +206,11 @@ H5M__close_cb(H5VL_object_t *map_vol_obj) HDassert(map_vol_obj); /* Close the map */ - if(H5VL_optional(map_vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_optional(map_vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_MAP, H5E_CLOSEERROR, FAIL, "unable to close map"); /* Free the VOL object */ - if(H5VL_free_object(map_vol_obj) < 0) + if (H5VL_free_object(map_vol_obj) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "unable to free VOL object"); done: @@ -233,7 +219,6 @@ done: #ifdef H5_HAVE_MAP_API - /*------------------------------------------------------------------------- * Function: H5Mcreate * @@ -252,69 +237,66 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, hid_t val_type_id, - hid_t lcpl_id, hid_t mcpl_id, hid_t mapl_id) +H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, hid_t val_type_id, hid_t lcpl_id, hid_t mcpl_id, + hid_t mapl_id) { - void *map = NULL; /* New map's info */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * map = NULL; /* New map's info */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE7("i", "i*siiiii", loc_id, name, key_type_id, val_type_id, lcpl_id, mcpl_id, mapl_id); /* Check arguments */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Get link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") /* Get map creation property list */ - if(H5P_DEFAULT == mcpl_id) + if (H5P_DEFAULT == mcpl_id) mcpl_id = H5P_MAP_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "mcpl_id is not a map create property list ID") + else if (TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "mcpl_id is not a map create property list ID") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Create the map */ - if(H5VL_optional(vol_obj, H5VL_MAP_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &loc_params, name, lcpl_id, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, name, + lcpl_id, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map") /* Get an atom for the map */ - if((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize map handle") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") FUNC_LEAVE_API(ret_value) } /* end H5Mcreate() */ - /*------------------------------------------------------------------------- * Function: H5Mcreate_anon * @@ -340,30 +322,28 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, - hid_t mcpl_id, hid_t mapl_id) +H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id, hid_t mapl_id) { - void *map = NULL; /* map object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * map = NULL; /* map object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "iiiii", loc_id, key_type_id, val_type_id, mcpl_id, mapl_id); /* Check arguments */ - if(H5P_DEFAULT == mcpl_id) + if (H5P_DEFAULT == mcpl_id) mcpl_id = H5P_MAP_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not map create property list ID") + else if (TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not map create property list ID") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ @@ -371,24 +351,23 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, loc_params.obj_type = H5I_get_type(loc_id); /* Create the map */ - if(H5VL_optional(vol_obj, H5VL_MAP_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, NULL, + H5P_LINK_CREATE_DEFAULT, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map") /* Get an atom for the map */ - if((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register map") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") FUNC_LEAVE_API(ret_value) } /* end H5Mcreate_anon() */ - /*------------------------------------------------------------------------ * Function: H5Mopen * @@ -407,50 +386,50 @@ done: hid_t H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id) { - void *map = NULL; /* map object from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ - H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void * map = NULL; /* map object from VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, mapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set the location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Open the map */ - if(H5VL_optional(vol_obj, H5VL_MAP_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, name, mapl_id, &map) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, name, + mapl_id, &map) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open map") /* Register an atom for the map */ - if((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register map atom") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") FUNC_LEAVE_API(ret_value) } /* end H5Mopen() */ - /*------------------------------------------------------------------------- * Function: H5Mclose * @@ -465,26 +444,25 @@ done: herr_t H5Mclose(hid_t map_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", map_id); /* Check args */ - if(H5I_MAP != H5I_get_type(map_id)) + if (H5I_MAP != H5I_get_type(map_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a map ID") /* Decrement the counter on the map. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref_always_close(map_id) < 0) + if (H5I_dec_app_ref_always_close(map_id) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "can't decrement count on map ID") done: FUNC_LEAVE_API(ret_value) } /* end H5Mclose() */ - /*------------------------------------------------------------------------- * Function: H5Mget_key_type * @@ -501,25 +479,25 @@ done: hid_t H5Mget_key_type(hid_t map_id) { - H5VL_object_t *vol_obj; /* Map structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", map_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") /* get the datatype */ - if(H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_KEY_TYPE, &ret_value) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_KEY_TYPE, + &ret_value) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Mget_key_type() */ - /*------------------------------------------------------------------------- * Function: H5Mget_val_type * @@ -536,25 +514,25 @@ done: hid_t H5Mget_val_type(hid_t map_id) { - H5VL_object_t *vol_obj; /* Map structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", map_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") /* get the datatype */ - if(H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_VAL_TYPE, &ret_value) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_VAL_TYPE, + &ret_value) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Mget_val_type() */ - /*------------------------------------------------------------------------- * Function: H5Mget_create_plist * @@ -571,25 +549,25 @@ done: hid_t H5Mget_create_plist(hid_t map_id) { - H5VL_object_t *vol_obj; /* Map structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", map_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") /* Get the map creation property list */ - if(H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_MCPL, &ret_value) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_MCPL, + &ret_value) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map creation properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Mget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Mget_access_plist * @@ -609,25 +587,25 @@ done: hid_t H5Mget_access_plist(hid_t map_id) { - H5VL_object_t *vol_obj; /* Map structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", map_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") /* Get the map access property list */ - if(H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_MAPL, &ret_value) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_MAPL, + &ret_value) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map access properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Mget_access_plist() */ - /*------------------------------------------------------------------------- * Function: H5Mget_count * @@ -643,35 +621,33 @@ done: herr_t H5Mget_count(hid_t map_id, hsize_t *count, hid_t dxpl_id) { - H5VL_object_t *vol_obj; /* Map structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Map structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("e", "i*hi", map_id, count, dxpl_id); /* Check args */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Get the number of key-value pairs stored in the map */ - if(H5VL_optional(vol_obj, H5VL_MAP_GET, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_GET_COUNT, count) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_GET, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_GET_COUNT, count) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map access properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Mget_count() */ - /*------------------------------------------------------------------------- * Function: H5Mput * @@ -689,11 +665,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Mput(hid_t map_id, hid_t key_mem_type_id, const void *key, - hid_t val_mem_type_id, const void *value, hid_t dxpl_id) +H5Mput(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t val_mem_type_id, const void *value, + hid_t dxpl_id) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "ii*xi*xi", map_id, key_mem_type_id, key, val_mem_type_id, value, @@ -712,22 +688,21 @@ H5Mput(hid_t map_id, hid_t key_mem_type_id, const void *key, /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Set the key/value pair */ - if(H5VL_optional(vol_obj, H5VL_MAP_PUT, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, val_mem_type_id, value) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_PUT, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, val_mem_type_id, + value) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, FAIL, "unable to put key/value pair") done: FUNC_LEAVE_API(ret_value) } /* end H5Mput() */ - /*------------------------------------------------------------------------- * Function: H5Mget * @@ -748,11 +723,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, - hid_t val_mem_type_id, void *value, hid_t dxpl_id) +H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t val_mem_type_id, void *value, + hid_t dxpl_id) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "ii*xi*xi", map_id, key_mem_type_id, key, val_mem_type_id, value, @@ -771,22 +746,21 @@ H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Get the value for the key */ - if(H5VL_optional(vol_obj, H5VL_MAP_GET_VAL, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, val_mem_type_id, value) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_GET_VAL, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, + val_mem_type_id, value) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, FAIL, "unable to get value from map") done: FUNC_LEAVE_API(ret_value) } /* end H5Mget() */ - /*------------------------------------------------------------------------- * Function: H5Mexists * @@ -801,11 +775,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, - hid_t dxpl_id) +H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, hid_t dxpl_id) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*x*bi", map_id, key_mem_type_id, key, exists, dxpl_id); @@ -821,22 +794,21 @@ H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Check if key exists */ - if((ret_value = H5VL_optional(vol_obj, H5VL_MAP_EXISTS, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, exists)) < 0) + if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_EXISTS, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, + exists)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTGET, ret_value, "unable to check if key exists") done: FUNC_LEAVE_API(ret_value) } /* end H5Mexists() */ - /*------------------------------------------------------------------------- * Function: H5Miterate * @@ -869,12 +841,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, - void *op_data, hid_t dxpl_id) +H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, hid_t dxpl_id) { - H5VL_object_t *vol_obj = NULL; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*hix*xi", map_id, idx, key_mem_type_id, op, op_data, dxpl_id); @@ -892,26 +863,25 @@ H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(map_id); /* Iterate over keys */ - if((ret_value = H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) + if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, + H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) HGOTO_ERROR(H5E_MAP, H5E_BADITER, ret_value, "unable to ierate over keys") done: FUNC_LEAVE_API(ret_value) } /* end H5Miterate() */ - /*------------------------------------------------------------------------- * Function: H5Miterate_by_name * @@ -944,22 +914,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, - hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, hid_t dxpl_id, - hid_t lapl_id) +H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, + void *op_data, hid_t dxpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*s*hix*xii", loc_id, map_name, idx, key_mem_type_id, op, op_data, dxpl_id, lapl_id); /* Check arguments */ - if(!map_name) + if (!map_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "map_name parameter cannot be NULL") - if(!*map_name) + if (!*map_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "map_name parameter cannot be an empty string") if (key_mem_type_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") @@ -973,9 +942,8 @@ H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); @@ -987,14 +955,14 @@ H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Iterate over keys */ - if((ret_value = H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) + if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, + H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) HGOTO_ERROR(H5E_MAP, H5E_BADITER, ret_value, "unable to ierate over keys") done: FUNC_LEAVE_API(ret_value) } /* end H5Miterate_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Mdelete * @@ -1011,12 +979,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, - hid_t dxpl_id) +H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t dxpl_id) { - H5VL_object_t *vol_obj = NULL; - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ii*xi", map_id, key_mem_type_id, key, dxpl_id); @@ -1032,19 +999,19 @@ H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(map_id); /* Delete the key/value pair */ - if(H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, H5VL_MAP_DELETE, key_mem_type_id, key) < 0) + if (H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, H5VL_MAP_DELETE, + key_mem_type_id, key) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTSET, FAIL, "unable to delete key/value pair") done: @@ -1052,4 +1019,3 @@ done: } /* end H5Mdelete() */ #endif /* H5_HAVE_MAP_API */ - diff --git a/src/H5MF.c b/src/H5MF.c index 5ba7284..1420e5a 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -26,39 +26,37 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#define H5FS_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5FS_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FSpkg.h" /* File free space */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFpkg.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FSpkg.h" /* File free space */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFpkg.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ -#define H5MF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ -#define H5MF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ +#define H5MF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ +#define H5MF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ -#define H5MF_CHECK_FSM(FSM, CF) \ - HDassert(*CF == FALSE); \ - if(!H5F_addr_defined(FSM->addr) || !H5F_addr_defined(FSM->sect_addr)) \ +#define H5MF_CHECK_FSM(FSM, CF) \ + HDassert(*CF == FALSE); \ + if (!H5F_addr_defined(FSM->addr) || !H5F_addr_defined(FSM->sect_addr)) \ *CF = TRUE; /* For non-paged aggregation: map allocation request type to tracked free-space type */ /* F_SH -- pointer to H5F_shared_t; T -- H5FD_mem_t */ -#define H5MF_ALLOC_TO_FS_AGGR_TYPE(F_SH, T) \ - ((H5FD_MEM_DEFAULT == (F_SH)->fs_type_map[T]) ? (T) : (F_SH)->fs_type_map[T]) +#define H5MF_ALLOC_TO_FS_AGGR_TYPE(F_SH, T) \ + ((H5FD_MEM_DEFAULT == (F_SH)->fs_type_map[T]) ? (T) : (F_SH)->fs_type_map[T]) /******************/ /* Local Typedefs */ @@ -66,24 +64,22 @@ /* Enum for kind of free space section+aggregator merging allowed for a file */ typedef enum { - H5MF_AGGR_MERGE_SEPARATE, /* Everything in separate free list */ - H5MF_AGGR_MERGE_DICHOTOMY, /* Metadata in one free list and raw data in another */ - H5MF_AGGR_MERGE_TOGETHER /* Metadata & raw data in one free list */ + H5MF_AGGR_MERGE_SEPARATE, /* Everything in separate free list */ + H5MF_AGGR_MERGE_DICHOTOMY, /* Metadata in one free list and raw data in another */ + H5MF_AGGR_MERGE_TOGETHER /* Metadata & raw data in one free list */ } H5MF_aggr_merge_t; /* User data for section info iterator callback for iterating over free space sections */ typedef struct { - H5F_sect_info_t *sects; /* section info to be retrieved */ - size_t sect_count; /* # of sections requested */ - size_t sect_idx; /* the current count of sections */ + H5F_sect_info_t *sects; /* section info to be retrieved */ + size_t sect_count; /* # of sections requested */ + size_t sect_idx; /* the current count of sections */ } H5MF_sect_iter_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -98,11 +94,12 @@ static herr_t H5MF__close_pagefs(H5F_t *f); static herr_t H5MF__close_shrink_eoa(H5F_t *f); /* General routines */ -static herr_t H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums); +static herr_t H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums); static hbool_t H5MF__fsm_type_is_self_referential(H5F_shared_t *f_sh, H5F_mem_page_t fsm_type); static hbool_t H5MF__fsm_is_self_referential(H5F_shared_t *f_sh, H5FS_t *fspace); -static herr_t H5MF__continue_alloc_fsm(H5F_shared_t *f_sh, H5FS_t *sm_hdr_fspace, H5FS_t *sm_sinfo_fspace, - H5FS_t *lg_hdr_fspace, H5FS_t *lg_sinfo_fspace, hbool_t *continue_alloc_fsm); +static herr_t H5MF__continue_alloc_fsm(H5F_shared_t *f_sh, H5FS_t *sm_hdr_fspace, H5FS_t *sm_sinfo_fspace, + H5FS_t *lg_hdr_fspace, H5FS_t *lg_sinfo_fspace, + hbool_t *continue_alloc_fsm); /* Free-space type manager routines */ static herr_t H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type); @@ -114,8 +111,7 @@ static herr_t H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type); static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata); /* VFD SWMR */ -static herr_t H5MF__defer_free(H5F_shared_t *shared, H5FD_mem_t alloc_type, - haddr_t addr, hsize_t size); +static herr_t H5MF__defer_free(H5F_shared_t *shared, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size); /*********************/ /* Package Variables */ @@ -124,7 +120,6 @@ static herr_t H5MF__defer_free(H5F_shared_t *shared, H5FD_mem_t alloc_type, /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -134,20 +129,19 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /*******************/ static herr_t -H5MF__defer_free(H5F_shared_t *shared, H5FD_mem_t alloc_type, haddr_t addr, - hsize_t size) +H5MF__defer_free(H5F_shared_t *shared, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) { - lower_defree_t *df = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + lower_defree_t *df = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC if ((df = H5MM_malloc(sizeof(*df))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate buffer") - df->alloc_type = alloc_type; - df->addr = addr; - df->size = size; + df->alloc_type = alloc_type; + df->addr = addr; + df->size = size; df->free_after_tick = shared->tick_num + shared->vfd_swmr_config.max_lag; SIMPLEQ_INSERT_TAIL(&shared->lower_defrees, df, link); @@ -159,10 +153,10 @@ done: herr_t H5MF_process_deferred_frees(H5F_t *f, const uint64_t tick_num) { - lower_defree_t *df; - H5F_shared_t *shared = f->shared; - lower_defree_queue_t defrees = SIMPLEQ_HEAD_INITIALIZER(defrees); - herr_t ret_value = SUCCEED; + lower_defree_t * df; + H5F_shared_t * shared = f->shared; + lower_defree_queue_t defrees = SIMPLEQ_HEAD_INITIALIZER(defrees); + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOERR @@ -190,7 +184,6 @@ H5MF_process_deferred_frees(H5F_t *f, const uint64_t tick_num) FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_process_deferred_frees() */ - /*------------------------------------------------------------------------- * Function: H5MF_init_merge_flags * @@ -207,10 +200,10 @@ H5MF_process_deferred_frees(H5F_t *f, const uint64_t tick_num) herr_t H5MF_init_merge_flags(H5F_shared_t *f_sh) { - H5MF_aggr_merge_t mapping_type; /* Type of free list mapping */ - H5FD_mem_t type; /* Memory type for iteration */ - hbool_t all_same; /* Whether all the types map to the same value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_aggr_merge_t mapping_type; /* Type of free list mapping */ + H5FD_mem_t type; /* Memory type for iteration */ + hbool_t all_same; /* Whether all the types map to the same value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -222,62 +215,62 @@ H5MF_init_merge_flags(H5F_shared_t *f_sh) * can merge with the metadata or small 'raw' data aggregator */ all_same = TRUE; - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) /* Check for any different type mappings */ - if(f_sh->fs_type_map[type] != f_sh->fs_type_map[H5FD_MEM_DEFAULT]) { + if (f_sh->fs_type_map[type] != f_sh->fs_type_map[H5FD_MEM_DEFAULT]) { all_same = FALSE; break; } /* end if */ /* Check for all allocation types mapping to the same free list type */ - if(all_same) { - if(f_sh->fs_type_map[H5FD_MEM_DEFAULT] == H5FD_MEM_DEFAULT) + if (all_same) { + if (f_sh->fs_type_map[H5FD_MEM_DEFAULT] == H5FD_MEM_DEFAULT) mapping_type = H5MF_AGGR_MERGE_SEPARATE; else mapping_type = H5MF_AGGR_MERGE_TOGETHER; } /* end if */ else { /* Check for raw data mapping into same list as metadata */ - if(f_sh->fs_type_map[H5FD_MEM_DRAW] == f_sh->fs_type_map[H5FD_MEM_SUPER]) + if (f_sh->fs_type_map[H5FD_MEM_DRAW] == f_sh->fs_type_map[H5FD_MEM_SUPER]) mapping_type = H5MF_AGGR_MERGE_SEPARATE; else { - hbool_t all_metadata_same; /* Whether all metadata go in same free list */ + hbool_t all_metadata_same; /* Whether all metadata go in same free list */ /* One or more allocation type don't map to the same free list type */ /* Check if all the metadata allocation types map to the same type */ all_metadata_same = TRUE; - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) /* Skip checking raw data free list mapping */ /* (global heap is treated as raw data) */ - if(type != H5FD_MEM_DRAW && type != H5FD_MEM_GHEAP) { + if (type != H5FD_MEM_DRAW && type != H5FD_MEM_GHEAP) { /* Check for any different type mappings */ - if(f_sh->fs_type_map[type] != f_sh->fs_type_map[H5FD_MEM_SUPER]) { + if (f_sh->fs_type_map[type] != f_sh->fs_type_map[H5FD_MEM_SUPER]) { all_metadata_same = FALSE; break; } /* end if */ - } /* end if */ + } /* end if */ /* Check for all metadata on same free list */ - if(all_metadata_same) + if (all_metadata_same) mapping_type = H5MF_AGGR_MERGE_DICHOTOMY; else mapping_type = H5MF_AGGR_MERGE_SEPARATE; } /* end else */ - } /* end else */ + } /* end else */ /* Based on mapping type, initialize merging flags for each free list type */ - switch(mapping_type) { + switch (mapping_type) { case H5MF_AGGR_MERGE_SEPARATE: /* Don't merge any metadata together */ HDmemset(f_sh->fs_aggr_merge, 0, sizeof(f_sh->fs_aggr_merge)); /* Check if merging raw data should be allowed */ /* (treat global heaps as raw data) */ - if(H5FD_MEM_DRAW == f_sh->fs_type_map[H5FD_MEM_DRAW] || - H5FD_MEM_DEFAULT == f_sh->fs_type_map[H5FD_MEM_DRAW]) { - f_sh->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; + if (H5FD_MEM_DRAW == f_sh->fs_type_map[H5FD_MEM_DRAW] || + H5FD_MEM_DEFAULT == f_sh->fs_type_map[H5FD_MEM_DRAW]) { + f_sh->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; f_sh->fs_aggr_merge[H5FD_MEM_GHEAP] = H5F_FS_MERGE_RAWDATA; - } /* end if */ + } /* end if */ break; case H5MF_AGGR_MERGE_DICHOTOMY: @@ -286,13 +279,14 @@ H5MF_init_merge_flags(H5F_shared_t *f_sh) /* Allow merging raw data allocations together */ /* (treat global heaps as raw data) */ - f_sh->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; + f_sh->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; f_sh->fs_aggr_merge[H5FD_MEM_GHEAP] = H5F_FS_MERGE_RAWDATA; break; case H5MF_AGGR_MERGE_TOGETHER: /* Merge all allocation types together */ - HDmemset(f_sh->fs_aggr_merge, (H5F_FS_MERGE_METADATA | H5F_FS_MERGE_RAWDATA), sizeof(f_sh->fs_aggr_merge)); + HDmemset(f_sh->fs_aggr_merge, (H5F_FS_MERGE_METADATA | H5F_FS_MERGE_RAWDATA), + sizeof(f_sh->fs_aggr_merge)); break; default: @@ -303,7 +297,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_init_merge_flags() */ - /*------------------------------------------------------------------------- * Function: H5MF__alloc_to_fs_type * @@ -325,11 +318,12 @@ H5MF__alloc_to_fs_type(H5F_shared_t *f_sh, H5FD_mem_t alloc_type, hsize_t size, HDassert(f_sh); HDassert(fs_type); - if(H5F_SHARED_PAGED_AGGR(f_sh)) { /* paged aggregation */ - if(size >= f_sh->fs_page_size) { - if(H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_PAGED_AGGR)) { /* multi or split driver */ - /* For non-contiguous address space, map to large size free-space manager for each alloc_type */ - if(H5FD_MEM_DEFAULT == f_sh->fs_type_map[alloc_type]) + if (H5F_SHARED_PAGED_AGGR(f_sh)) { /* paged aggregation */ + if (size >= f_sh->fs_page_size) { + if (H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_PAGED_AGGR)) { /* multi or split driver */ + /* For non-contiguous address space, map to large size free-space manager for each alloc_type + */ + if (H5FD_MEM_DEFAULT == f_sh->fs_type_map[alloc_type]) *fs_type = (H5F_mem_page_t)(alloc_type + (H5FD_MEM_NTYPES - 1)); else *fs_type = (H5F_mem_page_t)(f_sh->fs_type_map[alloc_type] + (H5FD_MEM_NTYPES - 1)); @@ -337,17 +331,16 @@ H5MF__alloc_to_fs_type(H5F_shared_t *f_sh, H5FD_mem_t alloc_type, hsize_t size, else /* For contiguous address space, map to generic large size free-space manager */ *fs_type = H5F_MEM_PAGE_GENERIC; /* H5F_MEM_PAGE_SUPER */ - } /* end if */ + } /* end if */ else *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f_sh, alloc_type); - } /* end if */ + } /* end if */ else /* non-paged aggregation */ *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f_sh, alloc_type); FUNC_LEAVE_NOAPI_VOID } /* end H5MF__alloc_to_fs_type() */ - /*------------------------------------------------------------------------- * Function: H5MF__open_fstype * @@ -367,15 +360,14 @@ H5MF__alloc_to_fs_type(H5F_shared_t *f_sh, H5FD_mem_t alloc_type, hsize_t size, herr_t H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type) { - const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for file */ - H5MF_FSPACE_SECT_CLS_SIMPLE, - H5MF_FSPACE_SECT_CLS_SMALL, - H5MF_FSPACE_SECT_CLS_LARGE }; - hsize_t alignment; /* Alignment to use */ - hsize_t threshold; /* Threshold to use */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *classes[] = {/* Free space section classes implemented for file */ + H5MF_FSPACE_SECT_CLS_SIMPLE, H5MF_FSPACE_SECT_CLS_SMALL, + H5MF_FSPACE_SECT_CLS_LARGE}; + hsize_t alignment; /* Alignment to use */ + hsize_t threshold; /* Threshold to use */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) @@ -383,7 +375,7 @@ H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type) * Check arguments. */ HDassert(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else { HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -394,7 +386,7 @@ H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type) HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED); /* Set up the alignment and threshold to use depending on the manager type */ - if(H5F_PAGED_AGGR(f)) { + if (H5F_PAGED_AGGR(f)) { alignment = (type == H5F_MEM_PAGE_GENERIC) ? f->shared->fs_page_size : (hsize_t)H5F_ALIGN_DEF; threshold = H5F_ALIGN_THRHD_DEF; } /* end if */ @@ -404,30 +396,29 @@ H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type) } /* end else */ /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f->shared, type)) + if (H5MF__fsm_type_is_self_referential(f->shared, type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); /* Open an existing free space structure for the file */ - if(NULL == (f->shared->fs_man[type] = H5FS_open(f, f->shared->fs_addr[type], - NELMTS(classes), classes, f, alignment, threshold))) + if (NULL == (f->shared->fs_man[type] = H5FS_open(f, f->shared->fs_addr[type], NELMTS(classes), classes, f, + alignment, threshold))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space info") /* Set the state for the free space manager to "open", if it is now */ - if(f->shared->fs_man[type]) + if (f->shared->fs_man[type]) f->shared->fs_state[type] = H5F_FS_STATE_OPEN; done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__open_fstype() */ - /*------------------------------------------------------------------------- * Function: H5MF__create_fstype * @@ -447,16 +438,15 @@ done: static herr_t H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) { - const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for file */ - H5MF_FSPACE_SECT_CLS_SIMPLE, - H5MF_FSPACE_SECT_CLS_SMALL, - H5MF_FSPACE_SECT_CLS_LARGE }; - H5FS_create_t fs_create; /* Free space creation parameters */ - hsize_t alignment; /* Alignment to use */ - hsize_t threshold; /* Threshold to use */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *classes[] = {/* Free space section classes implemented for file */ + H5MF_FSPACE_SECT_CLS_SIMPLE, H5MF_FSPACE_SECT_CLS_SMALL, + H5MF_FSPACE_SECT_CLS_LARGE}; + H5FS_create_t fs_create; /* Free space creation parameters */ + hsize_t alignment; /* Alignment to use */ + hsize_t threshold; /* Threshold to use */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) @@ -464,7 +454,7 @@ H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) * Check arguments. */ HDassert(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else { HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -475,14 +465,14 @@ H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED); /* Set the free space creation parameters */ - fs_create.client = H5FS_CLIENT_FILE_ID; + fs_create.client = H5FS_CLIENT_FILE_ID; fs_create.shrink_percent = H5MF_FSPACE_SHRINK; fs_create.expand_percent = H5MF_FSPACE_EXPAND; - fs_create.max_sect_addr = 1 + H5VM_log2_gen((uint64_t)f->shared->maxaddr); - fs_create.max_sect_size = f->shared->maxaddr; + fs_create.max_sect_addr = 1 + H5VM_log2_gen((uint64_t)f->shared->maxaddr); + fs_create.max_sect_size = f->shared->maxaddr; /* Set up alignment and threshold to use depending on TYPE */ - if(H5F_PAGED_AGGR(f)) { + if (H5F_PAGED_AGGR(f)) { alignment = (type == H5F_MEM_PAGE_GENERIC) ? f->shared->fs_page_size : (hsize_t)H5F_ALIGN_DEF; threshold = H5F_ALIGN_THRHD_DEF; } /* end if */ @@ -492,29 +482,28 @@ H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) } /* end else */ /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f->shared, type)) + if (H5MF__fsm_type_is_self_referential(f->shared, type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); - if(NULL == (f->shared->fs_man[type] = H5FS_create(f, NULL, - &fs_create, NELMTS(classes), classes, f, alignment, threshold))) + if (NULL == (f->shared->fs_man[type] = + H5FS_create(f, NULL, &fs_create, NELMTS(classes), classes, f, alignment, threshold))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space info") /* Set the state for the free space manager to "open", if it is now */ - if(f->shared->fs_man[type]) + if (f->shared->fs_man[type]) f->shared->fs_state[type] = H5F_FS_STATE_OPEN; done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__create_fstype() */ - /*------------------------------------------------------------------------- * Function: H5MF__start_fstype * @@ -533,7 +522,7 @@ done: herr_t H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) @@ -542,7 +531,7 @@ H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type) */ HDassert(f); HDassert(f->shared); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else { HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -550,14 +539,14 @@ H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type) } /* end else */ /* Check if the free space manager exists already */ - if(H5F_addr_defined(f->shared->fs_addr[type])) { + if (H5F_addr_defined(f->shared->fs_addr[type])) { /* Open existing free space manager */ - if(H5MF__open_fstype(f, type) < 0) + if (H5MF__open_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTOPENOBJ, FAIL, "can't initialize file free space") } /* end if */ else { /* Create new free space manager */ - if(H5MF__create_fstype(f, type) < 0) + if (H5MF__create_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCREATE, FAIL, "can't initialize file free space") } /* end else */ @@ -565,7 +554,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__start_fstype() */ - /*------------------------------------------------------------------------- * Function: H5MF__delete_fstype * @@ -582,16 +570,16 @@ done: static herr_t H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - haddr_t tmp_fs_addr; /* Temporary holder for free space manager address */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + haddr_t tmp_fs_addr; /* Temporary holder for free space manager address */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) /* check args */ HDassert(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -599,7 +587,7 @@ H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type) /* Put address into temporary variable and reset it */ /* (Avoids loopback in file space freeing routine) */ - tmp_fs_addr = f->shared->fs_addr[type]; + tmp_fs_addr = f->shared->fs_addr[type]; f->shared->fs_addr[type] = HADDR_UNDEF; /* Shift to "deleting" state, to make certain we don't track any @@ -608,18 +596,18 @@ H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type) f->shared->fs_state[type] = H5F_FS_STATE_DELETING; /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f->shared, type)) + if (H5MF__fsm_type_is_self_referential(f->shared, type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); + HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Delete free space manager for this type */ - if(H5FS_delete(f, tmp_fs_addr) < 0) + if (H5FS_delete(f, tmp_fs_addr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't delete free space manager") /* Shift [back] to closed state */ @@ -631,13 +619,12 @@ HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__delete_fstype() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_fstype * @@ -654,7 +641,7 @@ done: static herr_t H5MF__close_fstype(H5F_t *f, H5F_mem_page_t type) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) @@ -662,7 +649,7 @@ H5MF__close_fstype(H5F_t *f, H5F_mem_page_t type) * Check arguments. */ HDassert(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -671,20 +658,19 @@ H5MF__close_fstype(H5F_t *f, H5F_mem_page_t type) HDassert(f->shared->fs_state[type] != H5F_FS_STATE_CLOSED); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Before closing free space manager\n", FUNC); + HDfprintf(stderr, "%s: Before closing free space manager\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Close an existing free space structure for the file */ - if(H5FS_close(f, f->shared->fs_man[type]) < 0) + if (H5FS_close(f, f->shared->fs_man[type]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free space info") - f->shared->fs_man[type] = NULL; + f->shared->fs_man[type] = NULL; f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__close_fstype() */ - /*------------------------------------------------------------------------- * Function: H5MF__add_sect * @@ -700,11 +686,11 @@ done: herr_t H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_section_t *node) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - H5MF_sect_ud_t udata; /* User data for callback */ - H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5MF_sect_ud_t udata; /* User data for callback */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) @@ -715,34 +701,34 @@ H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_sectio H5MF__alloc_to_fs_type(f->shared, alloc_type, node->sect_info.size, &fs_type); /* Construct user data for callbacks */ - udata.f = f; - udata.alloc_type = alloc_type; - udata.allow_sect_absorb = TRUE; + udata.f = f; + udata.alloc_type = alloc_type; + udata.allow_sect_absorb = TRUE; udata.allow_eoa_shrink_only = FALSE; /* Set the ring type in the API context */ - if(H5MF__fsm_is_self_referential(f->shared, fspace)) + if (H5MF__fsm_is_self_referential(f->shared, fspace)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: adding node, node->sect_info.addr = %a, node->sect_info.size = %Hu\n", FUNC, node->sect_info.addr, node->sect_info.size); + HDfprintf(stderr, "%s: adding node, node->sect_info.addr = %a, node->sect_info.size = %Hu\n", FUNC, + node->sect_info.addr, node->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Add the section */ - if(H5FS_sect_add(f, fspace, (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata) < 0) + if (H5FS_sect_add(f, fspace, (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__add_sect() */ - /*------------------------------------------------------------------------- * Function: H5MF__find_sect * @@ -757,13 +743,12 @@ done: *------------------------------------------------------------------------- */ htri_t -H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, - haddr_t *addr) +H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, haddr_t *addr) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - H5MF_free_section_t *node; /* Free space section pointer */ - htri_t ret_value = FAIL; /* Whether an existing free list node was found */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5MF_free_section_t *node; /* Free space section pointer */ + htri_t ret_value = FAIL; /* Whether an existing free list node was found */ FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) @@ -771,37 +756,37 @@ H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, HDassert(fspace); /* Set the ring type in the API context */ - if(H5MF__fsm_is_self_referential(f->shared, fspace)) + if (H5MF__fsm_is_self_referential(f->shared, fspace)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); /* Try to get a section from the free space manager */ - if((ret_value = H5FS_sect_find(f, fspace, size, (H5FS_section_info_t **)&node)) < 0) + if ((ret_value = H5FS_sect_find(f, fspace, size, (H5FS_section_info_t **)&node)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "error locating free space in file") #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section found = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: section found = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Check for actually finding section */ - if(ret_value) { + if (ret_value) { /* Sanity check */ HDassert(node); /* Retrieve return value */ - if(addr) + if (addr) *addr = node->sect_info.addr; /* Check for eliminating the section */ - if(node->sect_info.size == size) { + if (node->sect_info.size == size) { #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: freeing node\n", FUNC); + HDfprintf(stderr, "%s: freeing node\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Free section node */ - if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") } /* end if */ else { @@ -810,24 +795,23 @@ HDfprintf(stderr, "%s: freeing node\n", FUNC); node->sect_info.size -= size; #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: re-adding node, node->sect_info.size = %Hu\n", FUNC, node->sect_info.size); + HDfprintf(stderr, "%s: re-adding node, node->sect_info.size = %Hu\n", FUNC, node->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Re-add the section to the free-space manager */ - if(H5MF__add_sect(f, alloc_type, fspace, node) < 0) + if (H5MF__add_sect(f, alloc_type, fspace, node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") } /* end else */ - } /* end if */ + } /* end if */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__find_sect() */ - /*------------------------------------------------------------------------- * Function: H5MF_alloc * @@ -848,10 +832,10 @@ done: haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) { - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* free space manager ring */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* free space manager ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, HADDR_UNDEF) @@ -862,71 +846,71 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) HDassert(size > 0); if (!f->shared->vfd_swmr_writer) - ; // not a VFD SWMR writer, do not process deferrals + ; // not a VFD SWMR writer, do not process deferrals else if (H5MF_process_deferred_frees(f, f->shared->tick_num) < 0) { - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, HADDR_UNDEF, - "could not process deferrals") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, HADDR_UNDEF, "could not process deferrals") } H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f->shared, fs_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); /* Check if we are using the free space manager for this file */ - if(H5F_HAVE_FREE_SPACE_MANAGER(f)) { + if (H5F_HAVE_FREE_SPACE_MANAGER(f)) { /* We are about to change the contents of the free space manager -- * notify metadata cache that the associated fsm ring is * unsettled */ - if(H5AC_unsettle_ring(f, fsm_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, HADDR_UNDEF, "attempt to notify cache that ring is unsettled failed") + if (H5AC_unsettle_ring(f, fsm_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, HADDR_UNDEF, + "attempt to notify cache that ring is unsettled failed") /* Check if the free space manager for the file has been initialized */ - if(!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) { + if (!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) { /* Open the free-space manager */ - if(H5MF__open_fstype(f, fs_type) < 0) + if (H5MF__open_fstype(f, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTOPENOBJ, HADDR_UNDEF, "can't initialize file free space") HDassert(f->shared->fs_man[fs_type]); } /* end if */ /* Search for large enough space in the free space manager */ - if(f->shared->fs_man[fs_type]) - if(H5MF__find_sect(f, alloc_type, size, f->shared->fs_man[fs_type], &ret_value) < 0) + if (f->shared->fs_man[fs_type]) + if (H5MF__find_sect(f, alloc_type, size, f->shared->fs_man[fs_type], &ret_value) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "error locating a node") } /* end if */ /* If no space is found from the free-space manager, continue further action */ - if(!H5F_addr_defined(ret_value)) { + if (!H5F_addr_defined(ret_value)) { - if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { + if (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); - if(HADDR_UNDEF == (ret_value = H5MF__alloc_pagefs(f, alloc_type, size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed from paged aggregation") - } /* end if */ + if (HADDR_UNDEF == (ret_value = H5MF__alloc_pagefs(f, alloc_type, size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, + "allocation failed from paged aggregation") + } /* end if */ else { /* For non-paged aggregation, continue further action */ - if(HADDR_UNDEF == (ret_value = H5MF_aggr_vfd_alloc(f, alloc_type, size))) + if (HADDR_UNDEF == (ret_value = H5MF_aggr_vfd_alloc(f, alloc_type, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed from aggr/vfd") } /* end else */ - } /* end if */ + } /* end if */ HDassert(H5F_addr_defined(ret_value)); done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF__sects_dump(f, stderr); + H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_alloc() */ - /*------------------------------------------------------------------------- * Function: H5MF__alloc_pagefs * @@ -951,122 +935,124 @@ H5MF__sects_dump(f, stderr); static haddr_t H5MF__alloc_pagefs(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) { - H5F_mem_page_t ptype; /* Free-space manager type */ - H5MF_free_section_t *node = NULL; /* Free space section pointer */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5F_mem_page_t ptype; /* Free-space manager type */ + H5MF_free_section_t *node = NULL; /* Free space section pointer */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); + HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_ALLOC_DEBUG */ H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &ptype); - switch(ptype) { + switch (ptype) { case H5F_MEM_PAGE_GENERIC: case H5F_MEM_PAGE_LARGE_BTREE: case H5F_MEM_PAGE_LARGE_DRAW: case H5F_MEM_PAGE_LARGE_GHEAP: case H5F_MEM_PAGE_LARGE_LHEAP: - case H5F_MEM_PAGE_LARGE_OHDR: - { - haddr_t eoa; /* EOA for the file */ - hsize_t frag_size = 0; /* Fragment size */ + case H5F_MEM_PAGE_LARGE_OHDR: { + haddr_t eoa; /* EOA for the file */ + hsize_t frag_size = 0; /* Fragment size */ /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") HDassert(!(eoa % f->shared->fs_page_size)); - H5MF_EOA_MISALIGN(f, (eoa+size), f->shared->fs_page_size, frag_size); + H5MF_EOA_MISALIGN(f, (eoa + size), f->shared->fs_page_size, frag_size); /* Allocate from VFD */ - if(HADDR_UNDEF == (ret_value = H5F__alloc(f, alloc_type, size + frag_size, NULL, NULL))) + if (HADDR_UNDEF == (ret_value = H5F__alloc(f, alloc_type, size + frag_size, NULL, NULL))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") /* If there is a mis-aligned fragment at EOA */ - if(frag_size) { + if (frag_size) { /* Start up the free-space manager */ - if(!(f->shared->fs_man[ptype])) - if(H5MF__start_fstype(f, ptype) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize file free space") + if (!(f->shared->fs_man[ptype])) + if (H5MF__start_fstype(f, ptype) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, + "can't initialize file free space") /* Create free space section for the fragment */ - if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, ret_value + size, frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") + if (NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, ret_value + size, frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, + "can't initialize free space section") /* Add the fragment to the large free-space manager */ - if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[ptype], node) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't re-add section to file free space") + if (H5MF__add_sect(f, alloc_type, f->shared->fs_man[ptype], node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, + "can't re-add section to file free space") node = NULL; } /* end if */ - } - break; + } break; case H5F_MEM_PAGE_META: case H5F_MEM_PAGE_DRAW: case H5F_MEM_PAGE_BTREE: case H5F_MEM_PAGE_GHEAP: case H5F_MEM_PAGE_LHEAP: - case H5F_MEM_PAGE_OHDR: - { - haddr_t new_page; /* The address for the new file size page */ + case H5F_MEM_PAGE_OHDR: { + haddr_t new_page; /* The address for the new file size page */ /* Allocate one file space page */ - if(HADDR_UNDEF == (new_page = H5MF_alloc(f, alloc_type, f->shared->fs_page_size))) + if (HADDR_UNDEF == (new_page = H5MF_alloc(f, alloc_type, f->shared->fs_page_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") /* Start up the free-space manager */ - if(!(f->shared->fs_man[ptype])) - if(H5MF__start_fstype(f, ptype) < 0) + if (!(f->shared->fs_man[ptype])) + if (H5MF__start_fstype(f, ptype) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize file free space") HDassert(f->shared->fs_man[ptype]); - if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_SMALL, (new_page + size), (f->shared->fs_page_size - size)))) + if (NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_SMALL, (new_page + size), + (f->shared->fs_page_size - size)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") /* Add the remaining space in the page to the manager */ - if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[ptype], node) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't re-add section to file free space") + if (H5MF__add_sect(f, alloc_type, f->shared->fs_man[ptype], node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, + "can't re-add section to file free space") node = NULL; /* Insert the new page into the Page Buffer list of new pages so we don't read an empty page from disk */ - if(f->shared->pb_ptr != NULL && H5PB_add_new_page(f->shared, alloc_type, new_page) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't add new page to Page Buffer new page list") + if (f->shared->pb_ptr != NULL && H5PB_add_new_page(f->shared, alloc_type, new_page) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, + "can't add new page to Page Buffer new page list") ret_value = new_page; - } - break; + } break; case H5F_MEM_PAGE_NTYPES: case H5F_MEM_PAGE_DEFAULT: default: - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space: unrecognized type") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, + "can't allocate file space: unrecognized type") break; } /* end switch */ done: #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); + HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF__sects_dump(f, stderr); + H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ /* Release section node, if allocated and not added to section list or merged */ - if(node) - if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) + if (node) + if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, HADDR_UNDEF, "can't free section node") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__alloc_pagefs() */ - /*------------------------------------------------------------------------- * Function: H5MF_alloc_tmp * @@ -1094,12 +1080,12 @@ H5MF__sects_dump(f, stderr); haddr_t H5MF_alloc_tmp(H5F_t *f, hsize_t size) { - haddr_t eoa; /* End of allocated space in the file */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t eoa; /* End of allocated space in the file */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); + HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -1109,15 +1095,15 @@ HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); HDassert(size > 0); /* Retrieve the 'eoa' for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") /* Compute value to return */ ret_value = f->shared->tmp_addr - size; /* Check for overlap into the actual allocated space in the file */ - if(H5F_addr_le(ret_value, eoa)) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") + if (H5F_addr_le(ret_value, eoa)) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") /* Adjust temporary address allocator in the file */ f->shared->tmp_addr = ret_value; @@ -1126,7 +1112,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_alloc_tmp() */ - /*------------------------------------------------------------------------- * Function: H5MF_xfree * @@ -1144,27 +1129,26 @@ done: herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) /* Check arguments */ HDassert(f); - if(!H5F_addr_defined(addr) || 0 == size) + if (!H5F_addr_defined(addr) || 0 == size) HGOTO_DONE(SUCCEED) - HDassert(addr != 0); /* Can't deallocate the superblock :-) */ + HDassert(addr != 0); /* Can't deallocate the superblock :-) */ - if (!f->shared->vfd_swmr_writer || f->shared->closing || - alloc_type != H5FD_MEM_DRAW) { + if (!f->shared->vfd_swmr_writer || f->shared->closing || alloc_type != H5FD_MEM_DRAW) { /* VFD SWMR writers defer raw-data allocations until the * file starts to close. */ ret_value = H5MF__xfree_impl(f, alloc_type, addr, size); - } else if (H5MF__defer_free(f->shared, alloc_type, addr, size) < 0) + } + else if (H5MF__defer_free(f->shared, alloc_type, addr, size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "could not defer") else if (H5MF_process_deferred_frees(f, f->shared->tick_num) < 0) { - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, - "could not process deferrals") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "could not process deferrals") } done: @@ -1174,19 +1158,19 @@ done: static herr_t H5MF__xfree_inner_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) { - H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ - H5MF_free_section_t *node = NULL; /* Free space section pointer */ - unsigned ctype; /* section class type */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ + H5MF_free_section_t *node = NULL; /* Free space section pointer */ + unsigned ctype; /* section class type */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f->shared, fs_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; @@ -1197,39 +1181,41 @@ H5MF__xfree_inner_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t si * unsettled */ /* Only do so for strategies that use free-space managers */ - if(H5F_HAVE_FREE_SPACE_MANAGER(f)) - if(H5AC_unsettle_ring(f, fsm_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, FAIL, "attempt to notify cache that ring is unsettled failed") + if (H5F_HAVE_FREE_SPACE_MANAGER(f)) + if (H5AC_unsettle_ring(f, fsm_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, FAIL, + "attempt to notify cache that ring is unsettled failed") /* Check for attempting to free space that's a 'temporary' file address */ - if(H5F_addr_le(f->shared->tmp_addr, addr)) + if (H5F_addr_le(f->shared->tmp_addr, addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "attempting to free temporary file space") /* If it's metadata, check if the space to free intersects with the file's * metadata accumulator */ - if(H5FD_MEM_DRAW != alloc_type) { + if (H5FD_MEM_DRAW != alloc_type) { /* Check if the space to free intersects with the file's metadata accumulator */ - if(H5F__accum_free(f->shared, alloc_type, addr, size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't check free space intersection w/metadata accumulator") + if (H5F__accum_free(f->shared, alloc_type, addr, size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, + "can't check free space intersection w/metadata accumulator") } /* end if */ /* Check if the free space manager for the file has been initialized */ - if(!f->shared->fs_man[fs_type]) { + if (!f->shared->fs_man[fs_type]) { /* If there's no free space manager for objects of this type, * see if we can avoid creating one by checking if the freed * space is at the end of the file */ - if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) { - htri_t status; /* "can absorb" status for section into */ + if (!H5F_addr_defined(f->shared->fs_addr[fs_type])) { + htri_t status; /* "can absorb" status for section into */ /* Try to shrink the file or absorb the block into a block aggregator */ - if((status = H5MF_try_shrink(f, alloc_type, addr, size)) < 0) + if ((status = H5MF_try_shrink(f, alloc_type, addr, size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check for absorbing block") - else if(status > 0) + else if (status > 0) HGOTO_DONE(SUCCEED) - else if(size < f->shared->fs_threshold) + else if (size < f->shared->fs_threshold) HGOTO_DONE(SUCCEED) } @@ -1242,8 +1228,7 @@ H5MF__xfree_inner_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t si * Note: this drops the space to free on the floor... * */ - if(f->shared->fs_state[fs_type] == H5F_FS_STATE_DELETING || - !H5F_HAVE_FREE_SPACE_MANAGER(f)) { + if (f->shared->fs_state[fs_type] == H5F_FS_STATE_DELETING || !H5F_HAVE_FREE_SPACE_MANAGER(f)) { HGOTO_DONE(SUCCEED) } @@ -1251,54 +1236,55 @@ H5MF__xfree_inner_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t si * space isn't at the end of the file, so start up (or create) * the file space manager */ - if(H5MF__start_fstype(f, fs_type) < 0) + if (H5MF__start_fstype(f, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") } /* Create the free-space section for the freed section */ ctype = H5MF_SECT_CLASS_TYPE(f, size); - if(NULL == (node = H5MF__sect_new(ctype, addr, size))) + if (NULL == (node = H5MF__sect_new(ctype, addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* If size of the freed section is larger than threshold, add it to the free space manager */ - if(size >= f->shared->fs_threshold) { - HDassert(f->shared->fs_man[fs_type]); + if (size >= f->shared->fs_threshold) { + HDassert(f->shared->fs_man[fs_type]); /* Add to the free space for the file */ - if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) + if (H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't add section to file free space") node = NULL; - - } else { - htri_t merged; /* Whether node was merged */ - H5MF_sect_ud_t udata; /* User data for callback */ + } + else { + htri_t merged; /* Whether node was merged */ + H5MF_sect_ud_t udata; /* User data for callback */ /* Construct user data for callbacks */ - udata.f = f; - udata.alloc_type = alloc_type; - udata.allow_sect_absorb = TRUE; + udata.f = f; + udata.alloc_type = alloc_type; + udata.allow_sect_absorb = TRUE; udata.allow_eoa_shrink_only = FALSE; /* Try to merge the section that is smaller than threshold */ - if((merged = H5FS_sect_try_merge(f, f->shared->fs_man[fs_type], (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't merge section to file free space") - else if(merged == TRUE) /* successfully merged */ - /* Indicate that the node was used */ + if ((merged = H5FS_sect_try_merge(f, f->shared->fs_man[fs_type], (H5FS_section_info_t *)node, + H5FS_ADD_RETURNED_SPACE, &udata)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't merge section to file free space") + else if (merged == TRUE) /* successfully merged */ + /* Indicate that the node was used */ node = NULL; } done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Release section node, if allocated and not added to section list or merged */ - if(node) - if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) + if (node) + if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF__sects_dump(f, stderr); + H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) } @@ -1312,18 +1298,18 @@ H5MF__xfree_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) ret_value = H5MF__xfree_inner_impl(f, alloc_type, addr, size); - /* If the page buffer is enabled, notify it so that it can remove any - * pages that lie in the freed region. + /* If the page buffer is enabled, notify it so that it can remove any + * pages that lie in the freed region. * * This is necessary in normal (AKA non VFD SWMR mode) as if single large * metadata entry is allocated out of the freed space, writes to the - * entry will by-pass the page buffer. If a dirty intersecting - * entry is left in the page buffer, it could introduce corruption + * entry will by-pass the page buffer. If a dirty intersecting + * entry is left in the page buffer, it could introduce corruption * if it is flushed after the large metadata entry is written. * * Further, in the VFD SWMR case, the large metadata entry will typically * be buffered in the page buffer. If an intersecting entry is left - * in the page buffer, in addition to causing potential corruption in + * in the page buffer, in addition to causing potential corruption in * the HDF5 file, it may also result in overlaping entries in the page * buffer and metadata file index. * @@ -1333,28 +1319,25 @@ H5MF__xfree_impl(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) * to the reader, and any writes to the page in previous ticks are * recorded in the shadow file. * - * Note: This is not the correct place for this call, as it is + * Note: This is not the correct place for this call, as it is * sometimes bypassed by a HGOTO_DONE earlier in the function. - * This causes the assertion failure in fheap when run at + * This causes the assertion failure in fheap when run at * express test level 0. Discuss with Vailin. * * JRM -- 4/28/20 */ - if (ret_value == SUCCEED && f->shared->pb_ptr && - size >= f->shared->fs_page_size) { + if (ret_value == SUCCEED && f->shared->pb_ptr && size >= f->shared->fs_page_size) { HDassert(H5F_SHARED_PAGED_AGGR(f->shared)); if (H5PB_remove_entries(f->shared, addr, size) < 0) { - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, - "can't remove entries from page buffer") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't remove entries from page buffer") } } done: FUNC_LEAVE_NOAPI_TAG(ret_value) } - /*------------------------------------------------------------------------- * Function: H5MF_try_extend * @@ -1378,17 +1361,16 @@ done: *------------------------------------------------------------------------- */ htri_t -H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, - hsize_t extra_requested) +H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsize_t extra_requested) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - haddr_t end; /* End of block to extend */ - H5FD_mem_t map_type; /* Mapped type */ - H5F_mem_page_t fs_type; /* free space type */ - htri_t allow_extend = TRUE; /* Possible to extend the block */ - hsize_t frag_size = 0; /* Size of mis-aligned fragment */ - htri_t ret_value = FALSE; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + haddr_t end; /* End of block to extend */ + H5FD_mem_t map_type; /* Mapped type */ + H5F_mem_page_t fs_type; /* free space type */ + htri_t allow_extend = TRUE; /* Possible to extend the block */ + hsize_t frag_size = 0; /* Size of mis-aligned fragment */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -1404,103 +1386,106 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, /* For paged aggregation: * To extend a small block: can only extend if not crossing page boundary - * To extend a large block at EOA: calculate in advance mis-aligned fragment so EOA will still end at page boundary + * To extend a large block at EOA: calculate in advance mis-aligned fragment so EOA will still end at + * page boundary */ - if(H5F_PAGED_AGGR(f)) { - if(size < f->shared->fs_page_size) { + if (H5F_PAGED_AGGR(f)) { + if (size < f->shared->fs_page_size) { /* To extend a small block: cannot cross page boundary */ - if((addr / f->shared->fs_page_size) != (((end + extra_requested) - 1) / f->shared->fs_page_size)) + if ((addr / f->shared->fs_page_size) != (((end + extra_requested) - 1) / f->shared->fs_page_size)) allow_extend = FALSE; } /* end if */ else { - haddr_t eoa; /* EOA for the file */ + haddr_t eoa; /* EOA for the file */ - /* To extend a large block: calculate in advance the mis-aligned fragment so EOA will end at page boundary if extended */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) + /* To extend a large block: calculate in advance the mis-aligned fragment so EOA will end at + * page boundary if extended */ + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") HDassert(!(eoa % f->shared->fs_page_size)); - H5MF_EOA_MISALIGN(f, (eoa+extra_requested), f->shared->fs_page_size, frag_size); + H5MF_EOA_MISALIGN(f, (eoa + extra_requested), f->shared->fs_page_size, frag_size); } /* end else */ - } /* end if */ + } /* end if */ /* Get free space type from allocation type */ H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f->shared, fs_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); - if(allow_extend) { + if (allow_extend) { /* Try extending the block at EOA */ - if((ret_value = H5F__try_extend(f, map_type, end, extra_requested + frag_size)) < 0) + if ((ret_value = H5F__try_extend(f, map_type, end, extra_requested + frag_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") /* If extending at EOA succeeds: */ /* for paged aggregation, put the fragment into the large-sized free-space manager */ - if(ret_value == TRUE && H5F_PAGED_AGGR(f) && frag_size) { - H5MF_free_section_t *node = NULL; /* Free space section pointer */ + if (ret_value == TRUE && H5F_PAGED_AGGR(f) && frag_size) { + H5MF_free_section_t *node = NULL; /* Free space section pointer */ /* Should be large-sized block */ HDassert(size >= f->shared->fs_page_size); /* Start up the free-space manager */ - if(!(f->shared->fs_man[fs_type])) - if(H5MF__start_fstype(f, fs_type) < 0) + if (!(f->shared->fs_man[fs_type])) + if (H5MF__start_fstype(f, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") /* Create free space section for the fragment */ - if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, end + extra_requested, frag_size))) + if (NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, end + extra_requested, frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* Add the fragment to the large-sized free-space manager */ - if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) + if (H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") node = NULL; } /* end if */ /* For non-paged aggregation: try to extend into the aggregators */ - if(ret_value == FALSE && (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || - f->shared->fs_strategy == H5F_FSPACE_STRATEGY_AGGR) ) { - H5F_blk_aggr_t *aggr; /* Aggregator to use */ + if (ret_value == FALSE && (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || + f->shared->fs_strategy == H5F_FSPACE_STRATEGY_AGGR)) { + H5F_blk_aggr_t *aggr; /* Aggregator to use */ /* Check if the block is able to extend into aggregation block */ - aggr = (map_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); - if((ret_value = H5MF__aggr_try_extend(f, aggr, map_type, end, extra_requested)) < 0) + aggr = (map_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); + if ((ret_value = H5MF__aggr_try_extend(f, aggr, map_type, end, extra_requested)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending aggregation block") } /* If no extension so far, try to extend into a free-space section */ - if(ret_value == FALSE && ((f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) || - (H5F_PAGED_AGGR(f))) ) { - H5MF_sect_ud_t udata; /* User data */ + if (ret_value == FALSE && + ((f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) || (H5F_PAGED_AGGR(f)))) { + H5MF_sect_ud_t udata; /* User data */ /* Construct user data for callbacks */ - udata.f = f; + udata.f = f; udata.alloc_type = alloc_type; /* Check if the free space for the file has been initialized */ - if(!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) + if (!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) /* Open the free-space manager */ - if(H5MF__open_fstype(f, fs_type) < 0) + if (H5MF__open_fstype(f, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") /* Try to extend the block into a free-space section */ - if(f->shared->fs_man[fs_type]) { - if((ret_value = H5FS_sect_try_extend(f, f->shared->fs_man[fs_type], addr, size, extra_requested, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending block in free space manager") - + if (f->shared->fs_man[fs_type]) { + if ((ret_value = H5FS_sect_try_extend(f, f->shared->fs_man[fs_type], addr, size, + extra_requested, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, + "error extending block in free space manager") } /* For paged aggregation and a metadata block: try to extend into page end threshold */ - if(ret_value == FALSE && H5F_PAGED_AGGR(f) && map_type != H5FD_MEM_DRAW) { + if (ret_value == FALSE && H5F_PAGED_AGGR(f) && map_type != H5FD_MEM_DRAW) { H5MF_EOA_MISALIGN(f, end, f->shared->fs_page_size, frag_size); - if(frag_size <= H5F_PGEND_META_THRES(f) && extra_requested <= frag_size) + if (frag_size <= H5F_PGEND_META_THRES(f) && extra_requested <= frag_size) ret_value = TRUE; } } @@ -1508,17 +1493,16 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF__sects_dump(f, stderr); + H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_try_extend() */ - /*------------------------------------------------------------------------- * Function: H5MF_try_shrink * @@ -1536,13 +1520,13 @@ H5MF__sects_dump(f, stderr); htri_t H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) { - H5MF_free_section_t *node = NULL; /* Free space section pointer */ - H5MF_sect_ud_t udata; /* User data for callback */ - H5FS_section_class_t *sect_cls; /* Section class */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - H5F_mem_page_t fs_type; /* Free space type */ - htri_t ret_value = FALSE; /* Return value */ + H5MF_free_section_t * node = NULL; /* Free space section pointer */ + H5MF_sect_ud_t udata; /* User data for callback */ + H5FS_section_class_t *sect_cls; /* Section class */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5F_mem_page_t fs_type; /* Free space type */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -1561,47 +1545,46 @@ H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f->shared, fs_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); /* Create free-space section for block */ - if(NULL == (node = H5MF__sect_new(sect_cls->type, addr, size))) + if (NULL == (node = H5MF__sect_new(sect_cls->type, addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* Construct user data for callbacks */ - udata.f = f; - udata.alloc_type = alloc_type; - udata.allow_sect_absorb = FALSE; /* Force section to be absorbed into aggregator */ + udata.f = f; + udata.alloc_type = alloc_type; + udata.allow_sect_absorb = FALSE; /* Force section to be absorbed into aggregator */ udata.allow_eoa_shrink_only = FALSE; /* Check if the block can shrink the container */ - if(sect_cls->can_shrink) { - if((ret_value = (*sect_cls->can_shrink)((const H5FS_section_info_t *)node, &udata)) < 0) + if (sect_cls->can_shrink) { + if ((ret_value = (*sect_cls->can_shrink)((const H5FS_section_info_t *)node, &udata)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check if section can shrink container") - if(ret_value > 0) { + if (ret_value > 0) { HDassert(sect_cls->shrink); - if((*sect_cls->shrink)((H5FS_section_info_t **)&node, &udata) < 0) + if ((*sect_cls->shrink)((H5FS_section_info_t **)&node, &udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink container") } /* end if */ - } /* end if */ + } /* end if */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Free section node allocated */ - if(node && H5MF__sect_free((H5FS_section_info_t *)node) < 0) + if (node && H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_try_shrink() */ - /*------------------------------------------------------------------------- * Function: H5MF_close * @@ -1617,7 +1600,7 @@ done: herr_t H5MF_close(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -1625,11 +1608,12 @@ H5MF_close(H5F_t *f) HDassert(f); HDassert(f->shared); - if(H5F_PAGED_AGGR(f)) { - if((ret_value = H5MF__close_pagefs(f)) < 0) + if (H5F_PAGED_AGGR(f)) { + if ((ret_value = H5MF__close_pagefs(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'page' file space") - } else { - if((ret_value = H5MF__close_aggrfs(f)) < 0) + } + else { + if ((ret_value = H5MF__close_aggrfs(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'aggr' file space") } /* end else */ @@ -1637,7 +1621,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_close() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_delete_fstype * @@ -1655,47 +1638,48 @@ done: static herr_t H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ HDassert(f); HDassert(f->shared); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 1.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); + HDfprintf(stderr, "%s: Check 1.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, + (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* If the free space manager for this type is open, close it */ - if(f->shared->fs_man[type]) - if(H5MF__close_fstype(f, type) < 0) + if (f->shared->fs_man[type]) + if (H5MF__close_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 2.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); + HDfprintf(stderr, "%s: Check 2.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, + (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* If there is free space manager info for this type, delete it */ - if(H5F_addr_defined(f->shared->fs_addr[type])) - if(H5MF__delete_fstype(f, type) < 0) + if (H5F_addr_defined(f->shared->fs_addr[type])) + if (H5MF__delete_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't delete the free space manager") done: #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF__close_delete() */ - /*------------------------------------------------------------------------- * Function: H5MF_try_close * @@ -1713,14 +1697,14 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); herr_t H5MF_try_close(H5F_t *f) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -1748,63 +1732,62 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); H5AC_set_ring(H5AC_RING_RDFSM, &orig_ring); curr_ring = H5AC_RING_RDFSM; - if(H5F_PAGED_AGGR(f)) { - H5F_mem_page_t ptype; /* Memory type for iteration */ + if (H5F_PAGED_AGGR(f)) { + H5F_mem_page_t ptype; /* Memory type for iteration */ /* Iterate over all the free space types that have managers and * get each free list's space */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, ptype)) + if (H5MF__fsm_type_is_self_referential(f->shared, ptype)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring ) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ - if(H5MF__close_delete_fstype(f, ptype) < 0) + if (H5MF__close_delete_fstype(f, ptype) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") } /* end for */ - } /* end if */ + } /* end if */ else { - H5FD_mem_t type; /* Memory type for iteration */ + H5FD_mem_t type; /* Memory type for iteration */ /* Iterate over all the free space types that have managers and * get each free list's space */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ - if(H5MF__close_delete_fstype(f, (H5F_mem_page_t)type) < 0) + if (H5MF__close_delete_fstype(f, (H5F_mem_page_t)type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") } /* end for */ - } /* end else */ + } /* end else */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF_try_close() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_aggrfs * @@ -1820,15 +1803,15 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); static herr_t H5MF__close_aggrfs(H5F_t *f) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - H5FD_mem_t type; /* Memory type for iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5FD_mem_t type; /* Memory type for iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -1846,19 +1829,18 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Free the space in aggregators */ /* (for space not at EOA, it may be put into free space managers) */ - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Trying shrinking the EOA for the file */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* Making free-space managers persistent for superblock version >= 2 */ - if(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 - && f->shared->fs_persist) { - H5O_fsinfo_t fsinfo; /* File space info message */ - haddr_t final_eoa; /* Final eoa -- for sanity check */ - H5F_mem_page_t ptype; /* Memory type for iteration */ + if (f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 && f->shared->fs_persist) { + H5O_fsinfo_t fsinfo; /* File space info message */ + haddr_t final_eoa; /* Final eoa -- for sanity check */ + H5F_mem_page_t ptype; /* Memory type for iteration */ /* superblock extension and free space manager message should * exist at this point -- verify at least the former. @@ -1875,41 +1857,42 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); * * In passing, verify that all the free space managers are closed. */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) - fsinfo.fs_addr[type-1] = f->shared->fs_addr[type]; - fsinfo.strategy = f->shared->fs_strategy; - fsinfo.persist = f->shared->fs_persist; - fsinfo.threshold = f->shared->fs_threshold; - fsinfo.page_size = f->shared->fs_page_size; - fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) + fsinfo.fs_addr[type - 1] = f->shared->fs_addr[type]; + fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; + fsinfo.threshold = f->shared->fs_threshold; + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; fsinfo.eoa_pre_fsm_fsalloc = f->shared->eoa_fsm_fsalloc; - fsinfo.version = f->shared->fs_version; + fsinfo.version = f->shared->fs_version; /* Write the free space manager message -- message must already exist */ - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension") /* Close the free space managers */ - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { - if(f->shared->fs_man[type]) { + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { + if (f->shared->fs_man[type]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ HDassert(f->shared->fs_state[type] == H5F_FS_STATE_OPEN); - if(H5FS_close(f, f->shared->fs_man[type]) < 0) + if (H5FS_close(f, f->shared->fs_man[type]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close free space manager") - f->shared->fs_man[type] = NULL; + f->shared->fs_man[type] = NULL; f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; } /* end if */ f->shared->fs_addr[type] = HADDR_UNDEF; @@ -1931,11 +1914,11 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Trying shrinking the EOA for the file */ /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* get the eoa, and verify that it has the expected value */ - if(HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") /* f->shared->eoa_post_fsm_fsalloc is undefined if there has @@ -1943,35 +1926,34 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); * open. */ HDassert(H5F_NULL_FSM_ADDR(f) || final_eoa == f->shared->eoa_fsm_fsalloc); - } /* end if */ - else { /* super_vers can be 0, 1, 2 */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) - if(H5MF__close_delete_fstype(f, (H5F_mem_page_t)type) < 0) + } /* end if */ + else { /* super_vers can be 0, 1, 2 */ + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) + if (H5MF__close_delete_fstype(f, (H5F_mem_page_t)type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") } /* end else */ /* Free the space in aggregators (again) */ /* (in case any free space information re-started them) */ - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Trying shrinking the EOA for the file */ /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__close_aggrfs() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_pagefs * @@ -1986,16 +1968,16 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); static herr_t H5MF__close_pagefs(H5F_t *f) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - H5F_mem_page_t ptype; /* Memory type for iteration */ - H5O_fsinfo_t fsinfo; /* File space info message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5F_mem_page_t ptype; /* Memory type for iteration */ + H5O_fsinfo_t fsinfo; /* File space info message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -2014,23 +1996,23 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); curr_ring = H5AC_RING_RDFSM; /* Trying shrinking the EOA for the file */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* Set up file space info message */ - fsinfo.strategy = f->shared->fs_strategy; - fsinfo.persist = f->shared->fs_persist; - fsinfo.threshold = f->shared->fs_threshold; - fsinfo.page_size = f->shared->fs_page_size; - fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; + fsinfo.threshold = f->shared->fs_threshold; + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; - fsinfo.version = f->shared->fs_version; + fsinfo.version = f->shared->fs_version; - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; - if(f->shared->fs_persist) { - haddr_t final_eoa; /* final eoa -- for sanity check */ + if (f->shared->fs_persist) { + haddr_t final_eoa; /* final eoa -- for sanity check */ /* superblock extension and free space manager message should * exist at this point -- verify at least the former. @@ -2048,34 +2030,35 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); * file space for the self referential free space managers. Other * data was gathered above. */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) - fsinfo.fs_addr[ptype-1] = f->shared->fs_addr[ptype]; + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + fsinfo.fs_addr[ptype - 1] = f->shared->fs_addr[ptype]; fsinfo.eoa_pre_fsm_fsalloc = f->shared->eoa_fsm_fsalloc; /* Write the free space manager message -- message must already exist */ - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension") /* Close the free space managers */ /* use H5MF__close_fstype() for this? */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { - if(f->shared->fs_man[ptype]) { + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { + if (f->shared->fs_man[ptype]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, ptype)) + if (H5MF__fsm_type_is_self_referential(f->shared, ptype)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ HDassert(f->shared->fs_state[ptype] == H5F_FS_STATE_OPEN); - if(H5FS_close(f, f->shared->fs_man[ptype]) < 0) + if (H5FS_close(f, f->shared->fs_man[ptype]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close free space manager") - f->shared->fs_man[ptype] = NULL; + f->shared->fs_man[ptype] = NULL; f->shared->fs_state[ptype] = H5F_FS_STATE_CLOSED; } /* end if */ f->shared->fs_addr[ptype] = HADDR_UNDEF; @@ -2088,11 +2071,11 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Trying shrinking the EOA for the file */ /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* get the eoa, and verify that it has the expected value */ - if(HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") /* f->shared->eoa_post_fsm_fsalloc is undefined if there has @@ -2111,8 +2094,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); * the file driver layer. However, as this possibility seems remote, * it is ignored in the following assert. */ - HDassert((H5F_NULL_FSM_ADDR(f)) || - (final_eoa == f->shared->eoa_fsm_fsalloc) || + HDassert((H5F_NULL_FSM_ADDR(f)) || (final_eoa == f->shared->eoa_fsm_fsalloc) || ((H5F_addr_defined(f->shared->eoa_post_mdci_fsalloc)) && (final_eoa == f->shared->eoa_post_mdci_fsalloc))); } /* end if */ @@ -2120,33 +2102,33 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Iterate over all the free space types that have managers * and get each free list's space */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) - if(H5MF__close_delete_fstype(f, ptype) < 0) + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + if (H5MF__close_delete_fstype(f, ptype) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") /* Write file space info message to superblock extension object header */ /* Create the superblock extension object header in advance if needed */ - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension") } /* end else */ /* Trying shrinking the EOA for the file */ /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__close_pagefs() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_shrink_eoa * @@ -2162,15 +2144,15 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); static herr_t H5MF__close_shrink_eoa(H5F_t *f) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - H5F_mem_t type; - H5F_mem_page_t ptype; /* Memory type for iteration */ - hbool_t eoa_shrank; /* Whether an EOA shrink occurs */ - htri_t status; /* Status value */ - H5MF_sect_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5F_mem_t type; + H5F_mem_page_t ptype; /* Memory type for iteration */ + hbool_t eoa_shrank; /* Whether an EOA shrink occurs */ + htri_t status; /* Status value */ + H5MF_sect_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) @@ -2179,8 +2161,8 @@ H5MF__close_shrink_eoa(H5F_t *f) HDassert(f->shared); /* Construct user data for callbacks */ - udata.f = f; - udata.allow_sect_absorb = FALSE; + udata.f = f; + udata.allow_sect_absorb = FALSE; udata.allow_eoa_shrink_only = TRUE; /* Set the ring type in the API context */ @@ -2189,73 +2171,73 @@ H5MF__close_shrink_eoa(H5F_t *f) /* Iterate until no more EOA shrinking occurs */ do { - eoa_shrank = FALSE; + eoa_shrank = FALSE; - if(H5F_PAGED_AGGR(f)) { + if (H5F_PAGED_AGGR(f)) { /* Check the last section of each free-space manager */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { - if(f->shared->fs_man[ptype]) { + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { + if (f->shared->fs_man[ptype]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, ptype)) + if (H5MF__fsm_type_is_self_referential(f->shared, ptype)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ - udata.alloc_type = (H5FD_mem_t)((H5FD_mem_t)ptype < H5FD_MEM_NTYPES ? ptype : ((ptype % H5FD_MEM_NTYPES) + 1)); + udata.alloc_type = (H5FD_mem_t)( + (H5FD_mem_t)ptype < H5FD_MEM_NTYPES ? ptype : ((ptype % H5FD_MEM_NTYPES) + 1)); - if((status = H5FS_sect_try_shrink_eoa(f, f->shared->fs_man[ptype], &udata)) < 0) + if ((status = H5FS_sect_try_shrink_eoa(f, f->shared->fs_man[ptype], &udata)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - else if(status > 0) + else if (status > 0) eoa_shrank = TRUE; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { /* Check the last section of each free-space manager */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { - if(f->shared->fs_man[type]) { + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { + if (f->shared->fs_man[type]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ udata.alloc_type = type; - if((status = H5FS_sect_try_shrink_eoa(f, f->shared->fs_man[type], &udata)) < 0) + if ((status = H5FS_sect_try_shrink_eoa(f, f->shared->fs_man[type], &udata)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - else if(status > 0) - eoa_shrank = TRUE; + else if (status > 0) + eoa_shrank = TRUE; } /* end if */ - } /* end for */ + } /* end for */ /* check the two aggregators */ - if((status = H5MF_aggrs_try_shrink_eoa(f)) < 0) + if ((status = H5MF_aggrs_try_shrink_eoa(f)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - else if(status > 0) + else if (status > 0) eoa_shrank = TRUE; } /* end else */ - } while(eoa_shrank); + } while (eoa_shrank); done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__close_shrink_eoa() */ - /*------------------------------------------------------------------------- * Function: H5MF_get_freespace * @@ -2272,22 +2254,22 @@ done: herr_t H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) { - haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ - hsize_t ma_size = 0; /* Size of "metadata aggregator" */ - haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ - hsize_t sda_size = 0; /* Size of "small data aggregator" */ - hsize_t tot_fs_size = 0; /* Amount of all free space managed */ - hsize_t tot_meta_size = 0; /* Amount of metadata for free space managers */ - H5FD_mem_t tt; /* Memory type for iteration */ - H5F_mem_page_t type; /* Memory type for iteration */ - H5F_mem_page_t start_type; /* Memory type for iteration */ - H5F_mem_page_t end_type; /* Memory type for iteration */ - htri_t fs_started[H5F_MEM_PAGE_NTYPES]; /* Indicate whether the free-space manager has been started */ - haddr_t fs_eoa[H5FD_MEM_NTYPES]; /* EAO for each free-space manager */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ + hsize_t ma_size = 0; /* Size of "metadata aggregator" */ + haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ + hsize_t sda_size = 0; /* Size of "small data aggregator" */ + hsize_t tot_fs_size = 0; /* Amount of all free space managed */ + hsize_t tot_meta_size = 0; /* Amount of metadata for free space managers */ + H5FD_mem_t tt; /* Memory type for iteration */ + H5F_mem_page_t type; /* Memory type for iteration */ + H5F_mem_page_t start_type; /* Memory type for iteration */ + H5F_mem_page_t end_type; /* Memory type for iteration */ + htri_t fs_started[H5F_MEM_PAGE_NTYPES]; /* Indicate whether the free-space manager has been started */ + haddr_t fs_eoa[H5FD_MEM_NTYPES]; /* EAO for each free-space manager */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -2304,103 +2286,102 @@ H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) curr_ring = H5AC_RING_RDFSM; /* Determine start/end points for loop */ - if(H5F_PAGED_AGGR(f)) { + if (H5F_PAGED_AGGR(f)) { start_type = H5F_MEM_PAGE_META; - end_type = H5F_MEM_PAGE_NTYPES; + end_type = H5F_MEM_PAGE_NTYPES; } /* end if */ else { start_type = (H5F_mem_page_t)H5FD_MEM_SUPER; - end_type = (H5F_mem_page_t)H5FD_MEM_NTYPES; + end_type = (H5F_mem_page_t)H5FD_MEM_NTYPES; } /* end else */ - for(tt = H5FD_MEM_SUPER; tt < H5FD_MEM_NTYPES; tt++) - if(HADDR_UNDEF == (fs_eoa[tt] = H5F_get_eoa(f, tt))) + for (tt = H5FD_MEM_SUPER; tt < H5FD_MEM_NTYPES; tt++) + if (HADDR_UNDEF == (fs_eoa[tt] = H5F_get_eoa(f, tt))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") - if(!H5F_PAGED_AGGR(f)) { + if (!H5F_PAGED_AGGR(f)) { /* Retrieve metadata aggregator info, if available */ - if(H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) + if (H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") /* Retrieve 'small data' aggregator info, if available */ - if(H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) + if (H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") } /* end if */ /* Iterate over all the free space types that have managers and get each free list's space */ - for(type = start_type; type < end_type; type++) { + for (type = start_type; type < end_type; type++) { fs_started[type] = FALSE; /* Check if the free space for the file has been initialized */ - if(!f->shared->fs_man[type] && H5F_addr_defined(f->shared->fs_addr[type])) { - if(H5MF__open_fstype(f, type) < 0) + if (!f->shared->fs_man[type] && H5F_addr_defined(f->shared->fs_addr[type])) { + if (H5MF__open_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") HDassert(f->shared->fs_man[type]); fs_started[type] = TRUE; } /* end if */ /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ /* Check if there's free space of this type */ - if(f->shared->fs_man[type]) { - hsize_t type_fs_size = 0; /* Amount of free space managed for each type */ - hsize_t type_meta_size = 0; /* Amount of free space metadata for each type */ + if (f->shared->fs_man[type]) { + hsize_t type_fs_size = 0; /* Amount of free space managed for each type */ + hsize_t type_meta_size = 0; /* Amount of free space metadata for each type */ /* Retrieve free space size from free space manager */ - if(H5FS_sect_stats(f->shared->fs_man[type], &type_fs_size, NULL) < 0) + if (H5FS_sect_stats(f->shared->fs_man[type], &type_fs_size, NULL) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") - if(H5FS_size(f->shared->fs_man[type], &type_meta_size) < 0) + if (H5FS_size(f->shared->fs_man[type], &type_meta_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space metadata stats") /* Increment total free space for types */ tot_fs_size += type_fs_size; tot_meta_size += type_meta_size; } /* end if */ - } /* end for */ + } /* end for */ /* Close the free-space managers if they were opened earlier in this routine */ - for(type = start_type; type < end_type; type++) { + for (type = start_type; type < end_type; type++) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, &curr_ring); curr_ring = needed_ring; } /* end if */ - if(fs_started[type]) - if(H5MF__close_fstype(f, type) < 0) + if (fs_started[type]) + if (H5MF__close_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't close file free space") } /* end for */ /* Set the value(s) to return */ /* (The metadata & small data aggregators count as free space now, since they aren't at EOA) */ - if(tot_space) + if (tot_space) *tot_space = tot_fs_size + ma_size + sda_size; - if(meta_size) + if (meta_size) *meta_size = tot_meta_size; done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_get_freespace() */ - /*------------------------------------------------------------------------- * Function: H5MF_get_free_sections() * @@ -2417,14 +2398,14 @@ done: ssize_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - size_t total_sects = 0; /* Total number of sections */ - H5MF_sect_iter_ud_t sect_udata; /* User data for callback */ - H5F_mem_page_t start_type, end_type; /* Memory types to iterate over */ - H5F_mem_page_t ty; /* Memory type for iteration */ - ssize_t ret_value = -1; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + size_t total_sects = 0; /* Total number of sections */ + H5MF_sect_iter_ud_t sect_udata; /* User data for callback */ + H5F_mem_page_t start_type, end_type; /* Memory types to iterate over */ + H5F_mem_page_t ty; /* Memory type for iteration */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, (-1)) @@ -2446,22 +2427,22 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t * block. */ - if(type == H5FD_MEM_DEFAULT) { + if (type == H5FD_MEM_DEFAULT) { start_type = H5F_MEM_PAGE_SUPER; - end_type = H5F_MEM_PAGE_NTYPES; + end_type = H5F_MEM_PAGE_NTYPES; } /* end if */ else { start_type = end_type = (H5F_mem_page_t)type; - if(H5F_PAGED_AGGR(f)) /* set to the corresponding LARGE free-space manager */ + if (H5F_PAGED_AGGR(f)) /* set to the corresponding LARGE free-space manager */ end_type = (H5F_mem_page_t)(end_type + H5FD_MEM_NTYPES); else end_type++; } /* end else */ /* Set up user data for section iteration */ - sect_udata.sects = sect_info; + sect_udata.sects = sect_info; sect_udata.sect_count = nsects; - sect_udata.sect_idx = 0; + sect_udata.sect_idx = 0; /* Set the ring type in the API context. In most cases, we will * need H5AC_RING_RDFSM, so initially set the ring in @@ -2471,41 +2452,42 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t curr_ring = H5AC_RING_RDFSM; /* Iterate over memory types, retrieving the number of sections of each type */ - for(ty = start_type; ty < end_type; ty++) { - hbool_t fs_started = FALSE; /* The free-space manager is opened or not */ - size_t nums = 0; /* The number of free-space sections */ + for (ty = start_type; ty < end_type; ty++) { + hbool_t fs_started = FALSE; /* The free-space manager is opened or not */ + size_t nums = 0; /* The number of free-space sections */ /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, ty)) + if (H5MF__fsm_type_is_self_referential(f->shared, ty)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, &curr_ring); curr_ring = needed_ring; } /* end if */ - if(!f->shared->fs_man[ty] && H5F_addr_defined(f->shared->fs_addr[ty])) { - if(H5MF__open_fstype(f, ty) < 0) + if (!f->shared->fs_man[ty] && H5F_addr_defined(f->shared->fs_addr[ty])) { + if (H5MF__open_fstype(f, ty) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), "can't open the free space manager") HDassert(f->shared->fs_man[ty]); fs_started = TRUE; } /* end if */ /* Check if there's free space sections of this type */ - if(f->shared->fs_man[ty]) - if(H5MF__get_free_sects(f, f->shared->fs_man[ty], §_udata, &nums) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), "can't get section info for the free space manager") + if (f->shared->fs_man[ty]) + if (H5MF__get_free_sects(f, f->shared->fs_man[ty], §_udata, &nums) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), + "can't get section info for the free space manager") /* Increment total # of sections */ total_sects += nums; /* Close the free space manager of this type, if we started it here */ - if(fs_started) - if(H5MF__close_fstype(f, ty) < 0) + if (fs_started) + if (H5MF__close_fstype(f, ty) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCLOSEOBJ, (-1), "can't close file free space") - if((H5F_PAGED_AGGR(f)) && (type != H5FD_MEM_DEFAULT)) + if ((H5F_PAGED_AGGR(f)) && (type != H5FD_MEM_DEFAULT)) ty = (H5F_mem_page_t)(ty + H5FD_MEM_NTYPES - 2); } /* end for */ @@ -2514,13 +2496,12 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF_get_free_sections() */ - /*------------------------------------------------------------------------- * Function: H5MF__sects_cb() * @@ -2537,21 +2518,20 @@ done: static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata) { - H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; + H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; H5MF_sect_iter_ud_t *udata = (H5MF_sect_iter_ud_t *)_udata; FUNC_ENTER_STATIC_NOERR - if(udata->sect_idx < udata->sect_count) { + if (udata->sect_idx < udata->sect_count) { udata->sects[udata->sect_idx].addr = sect->sect_info.addr; - udata->sects[udata->sect_idx].size = sect->sect_info.size; + udata->sects[udata->sect_idx].size = sect->sect_info.size; udata->sect_idx++; } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MF__sects_cb() */ - /*------------------------------------------------------------------------- * Function: H5MF__get_free_sects * @@ -2567,8 +2547,8 @@ H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata) static herr_t H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums) { - hsize_t hnums = 0; /* # of sections */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t hnums = 0; /* # of sections */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2579,21 +2559,20 @@ H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, HDassert(fspace); /* Query how many sections of this type */ - if(H5FS_sect_stats(fspace, NULL, &hnums) < 0) + if (H5FS_sect_stats(fspace, NULL, &hnums) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") H5_CHECKED_ASSIGN(*nums, size_t, hnums, hsize_t); /* Check if we should retrieve the section info */ - if(sect_udata->sects && *nums > 0) + if (sect_udata->sects && *nums > 0) /* Iterate over all the free space sections of this type, adding them to the user's section info */ - if(H5FS_sect_iterate(f, fspace, H5MF__sects_cb, sect_udata) < 0) + if (H5FS_sect_iterate(f, fspace, H5MF__sects_cb, sect_udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_BADITER, FAIL, "can't iterate over sections") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__get_free_sects() */ - /*------------------------------------------------------------------------- * Function: H5MF_settle_raw_data_fsm() * @@ -2698,16 +2677,16 @@ done: herr_t H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) { - int pass_count; - hsize_t alloc_size; - H5F_mem_t mem_type; /* Memory type for iteration */ - H5F_mem_page_t fsm_type; /* FSM type for iteration */ - H5O_fsinfo_t fsinfo; /* Free space manager info message */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + int pass_count; + hsize_t alloc_size; + H5F_mem_t mem_type; /* Memory type for iteration */ + H5F_mem_page_t fsm_type; /* FSM type for iteration */ + H5O_fsinfo_t fsinfo; /* Free space manager info message */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -2720,9 +2699,9 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * Only need to settle things if we are persisting free space and * the private property in f->shared->null_fsm_addr is not enabled. */ - if(f->shared->fs_persist && !H5F_NULL_FSM_ADDR(f)) { - hbool_t fsm_opened[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ - hbool_t fsm_visited[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ + if (f->shared->fs_persist && !H5F_NULL_FSM_ADDR(f)) { + hbool_t fsm_opened[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ + hbool_t fsm_visited[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ /* Sanity check */ HDassert(f->shared->sblock); @@ -2755,7 +2734,7 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * is enabled -- skip this if so. */ /* Vailin -- is this correct? */ - if(!H5F_PAGED_AGGR(f) && (H5MF_free_aggrs(f) < 0)) + if (!H5F_PAGED_AGGR(f) && (H5MF_free_aggrs(f) < 0)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Set the ring type in the DXPL. In most cases, we will @@ -2793,81 +2772,82 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * setting the allocation size accordingly if paged allocation is * enabled. */ - for(pass_count = 0; pass_count <= 1; pass_count++) { - if(pass_count == 0) + for (pass_count = 0; pass_count <= 1; pass_count++) { + if (pass_count == 0) alloc_size = 1; - else if ( H5F_PAGED_AGGR(f) ) + else if (H5F_PAGED_AGGR(f)) alloc_size = f->shared->fs_page_size + 1; else /* no need for a second pass */ break; - for(mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; mem_type++) { + for (mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; mem_type++) { H5MF__alloc_to_fs_type(f->shared, mem_type, alloc_size, &fsm_type); - if(pass_count == 0) { /* this is the first pass */ + if (pass_count == 0) { /* this is the first pass */ HDassert(fsm_type > H5F_MEM_PAGE_DEFAULT); HDassert(fsm_type < H5F_MEM_PAGE_LARGE_SUPER); - } /* end if */ - else if(H5F_PAGED_AGGR(f)) { /* page alloc active */ + } /* end if */ + else if (H5F_PAGED_AGGR(f)) { /* page alloc active */ HDassert(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER); HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); - } /* end else-if */ - else /* paged allocation disabled -- should be unreachable */ + } /* end else-if */ + else /* paged allocation disabled -- should be unreachable */ HDassert(FALSE); - if(!fsm_visited[fsm_type]) { + if (!fsm_visited[fsm_type]) { fsm_visited[fsm_type] = TRUE; /* If there is no active FSM for this type, but such a FSM has * space allocated in file, open it so that we can free its file * space. */ - if(NULL == f->shared->fs_man[fsm_type]) { - if(H5F_addr_defined(f->shared->fs_addr[fsm_type])) { + if (NULL == f->shared->fs_man[fsm_type]) { + if (H5F_addr_defined(f->shared->fs_addr[fsm_type])) { /* Sanity check */ HDassert(fsm_opened[fsm_type] == FALSE); - if(H5MF__open_fstype(f, fsm_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") + if (H5MF__open_fstype(f, fsm_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, + "can't initialize file free space manager") fsm_opened[fsm_type] = TRUE; } /* end if */ - } /* end if */ + } /* end if */ - if(f->shared->fs_man[fsm_type]) { + if (f->shared->fs_man[fsm_type]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) - needed_ring = H5AC_RING_MDFSM; + if (H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) + needed_ring = H5AC_RING_MDFSM; else - needed_ring = H5AC_RING_RDFSM; + needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ /* Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") /* Check if the free space manager has space in the file */ - if(H5F_addr_defined(fs_stat.addr) || H5F_addr_defined(fs_stat.sect_addr)) { + if (H5F_addr_defined(fs_stat.addr) || H5F_addr_defined(fs_stat.sect_addr)) { /* Delete the free space manager in the file. Will * reallocate later if the free space manager contains * any free space. */ - if(H5FS_free(f, f->shared->fs_man[fsm_type], TRUE) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free-space headers") + if (H5FS_free(f, f->shared->fs_man[fsm_type], TRUE) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't release free-space headers") f->shared->fs_addr[fsm_type] = HADDR_UNDEF; } /* end if */ - } /* end if */ + } /* end if */ /* note that we are tracking opened FSM -- we will close them * at the end of the function. */ } /* end if */ - } /* end for */ - } /* end for */ - + } /* end for */ + } /* end for */ /* c) Delete the free space manager superblock extension message * if allocated. @@ -2880,15 +2860,15 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * file space manager info message is guaranteed to exist. * Leave it in for now, but consider removing it. */ - if(H5F_addr_defined(f->shared->sblock->ext_addr)) - if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") + if (H5F_addr_defined(f->shared->sblock->ext_addr)) + if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "error in removing message from superblock extension") /* As the final element in 1), shrink the EOA for the file */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") - /* 2) Ensure that space is allocated for the free space manager superblock * extension message. Must do this now, before reallocating file space * for free space managers, as it is possible that this allocation may @@ -2902,18 +2882,18 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * those addresses are unknown. This is OK -- we will write the correct * values to the message at free space manager shutdown. */ - for(fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) + for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) fsinfo.fs_addr[fsm_type - 1] = HADDR_UNDEF; - fsinfo.strategy = f->shared->fs_strategy; - fsinfo.persist = f->shared->fs_persist; - fsinfo.threshold = f->shared->fs_threshold; - fsinfo.page_size = f->shared->fs_page_size; - fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; + fsinfo.threshold = f->shared->fs_threshold; + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension") - + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, + "error in writing fsinfo message to superblock extension") /* 3) Scan all free space managers not involved in allocating * space for free space managers. For each such free space @@ -2935,38 +2915,38 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) */ /* Reinitialize fsm_visited */ - for(fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) + for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) fsm_visited[fsm_type] = FALSE; - for(pass_count = 0; pass_count <= 1; pass_count++) { - if(pass_count == 0) + for (pass_count = 0; pass_count <= 1; pass_count++) { + if (pass_count == 0) alloc_size = 1; - else if(H5F_PAGED_AGGR(f)) + else if (H5F_PAGED_AGGR(f)) alloc_size = f->shared->fs_page_size + 1; else /* no need for a second pass */ break; - for(mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; mem_type++) { + for (mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; mem_type++) { H5MF__alloc_to_fs_type(f->shared, mem_type, alloc_size, &fsm_type); - if(pass_count == 0) { /* this is the first pass */ + if (pass_count == 0) { /* this is the first pass */ HDassert(fsm_type > H5F_MEM_PAGE_DEFAULT); HDassert(fsm_type < H5F_MEM_PAGE_LARGE_SUPER); - } /* end if */ - else if(H5F_PAGED_AGGR(f)) { /* page alloc active */ + } /* end if */ + else if (H5F_PAGED_AGGR(f)) { /* page alloc active */ HDassert(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER); HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); - } /* end else-if */ - else /* paged allocation disabled -- should be unreachable */ + } /* end else-if */ + else /* paged allocation disabled -- should be unreachable */ HDassert(FALSE); /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ @@ -2975,21 +2955,21 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * to free space managers, ensure that we don't visit any FSM * more than once. */ - if(!fsm_visited[fsm_type]) { + if (!fsm_visited[fsm_type]) { fsm_visited[fsm_type] = TRUE; - if(f->shared->fs_man[fsm_type]) { + if (f->shared->fs_man[fsm_type]) { /* Only allocate file space if the target free space manager * doesn't allocate file space for free space managers. Note * that this is also the deciding factor as to whether a FSM * in in the raw data FSM ring. */ - if(!H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) { + if (!H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) { /* The current ring should be H5AC_RING_RDFSM */ HDassert(curr_ring == H5AC_RING_RDFSM); /* Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0 ) + if (H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") /* If the free space manager contains section info, @@ -2997,31 +2977,35 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * space must not be allocated at present -- verify * verify this with assertions). */ - if(fs_stat.serial_sect_count > 0) { + if (fs_stat.serial_sect_count > 0) { /* Sanity check */ HDassert(!H5F_addr_defined(fs_stat.addr)); /* Allocate FSM header */ - if(H5FS_alloc_hdr(f, f->shared->fs_man[fsm_type], &f->shared->fs_addr[fsm_type]) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocated free-space header") + if (H5FS_alloc_hdr(f, f->shared->fs_man[fsm_type], + &f->shared->fs_addr[fsm_type]) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't allocated free-space header") /* Allocate FSM section info */ HDassert(!H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.alloc_sect_size == 0); - if(H5FS_alloc_sect(f, f->shared->fs_man[fsm_type]) < 0 ) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate free-space section info") + if (H5FS_alloc_sect(f, f->shared->fs_man[fsm_type]) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't allocate free-space section info") #ifndef NDEBUG /* Re-Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") + if (H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't get free-space info") HDassert(H5F_addr_defined(fs_stat.addr)); HDassert(H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.serial_sect_count > 0); HDassert(fs_stat.alloc_sect_size > 0); HDassert(fs_stat.alloc_sect_size == fs_stat.sect_size); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end if */ else { HDassert(!H5F_addr_defined(fs_stat.addr)); @@ -3029,21 +3013,22 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) HDassert(fs_stat.serial_sect_count == 0); HDassert(fs_stat.alloc_sect_size == 0); } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Close any opened FSMs */ - if(fsm_opened[fsm_type]) { - if(H5MF__close_fstype(f, fsm_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't close file free space manager") + if (fsm_opened[fsm_type]) { + if (H5MF__close_fstype(f, fsm_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, + "can't close file free space manager") fsm_opened[fsm_type] = FALSE; } /* end if */ - } /* end if */ - } /* end for */ - } /* end for */ + } /* end if */ + } /* end for */ + } /* end for */ /* verify that all opened FSMs were closed */ - for(fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) + for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) HDassert(!fsm_opened[fsm_type]); /* Indicate that the FSM was settled successfully */ @@ -3052,14 +3037,12 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF_settle_raw_data_fsm() */ - - /*------------------------------------------------------------------------- * Function: H5MF_settle_meta_data_fsm() * @@ -3159,19 +3142,19 @@ done: herr_t H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) { - H5F_mem_page_t sm_fshdr_fs_type; /* small fs hdr fsm */ - H5F_mem_page_t sm_fssinfo_fs_type; /* small fs sinfo fsm */ - H5F_mem_page_t lg_fshdr_fs_type; /* large fs hdr fsm */ - H5F_mem_page_t lg_fssinfo_fs_type; /* large fs sinfo fsm */ - H5FS_t *sm_hdr_fspace = NULL; /* ptr to sm FSM hdr alloc FSM */ - H5FS_t *sm_sinfo_fspace = NULL; /* ptr to sm FSM sinfo alloc FSM */ - H5FS_t *lg_hdr_fspace = NULL; /* ptr to lg FSM hdr alloc FSM */ - H5FS_t *lg_sinfo_fspace = NULL; /* ptr to lg FSM sinfo alloc FSM */ - haddr_t eoa_fsm_fsalloc; /* eoa after file space allocation */ - /* for self referential FSMs */ - hbool_t continue_alloc_fsm = FALSE; /* Continue allocating addr and sect_addr for FSMs */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_mem_page_t sm_fshdr_fs_type; /* small fs hdr fsm */ + H5F_mem_page_t sm_fssinfo_fs_type; /* small fs sinfo fsm */ + H5F_mem_page_t lg_fshdr_fs_type; /* large fs hdr fsm */ + H5F_mem_page_t lg_fssinfo_fs_type; /* large fs sinfo fsm */ + H5FS_t * sm_hdr_fspace = NULL; /* ptr to sm FSM hdr alloc FSM */ + H5FS_t * sm_sinfo_fspace = NULL; /* ptr to sm FSM sinfo alloc FSM */ + H5FS_t * lg_hdr_fspace = NULL; /* ptr to lg FSM hdr alloc FSM */ + H5FS_t * lg_sinfo_fspace = NULL; /* ptr to lg FSM sinfo alloc FSM */ + haddr_t eoa_fsm_fsalloc; /* eoa after file space allocation */ + /* for self referential FSMs */ + hbool_t continue_alloc_fsm = FALSE; /* Continue allocating addr and sect_addr for FSMs */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -3184,7 +3167,7 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) * Only need to settle things if we are persisting free space and * the private property in f->shared->null_fsm_addr is not enabled. */ - if(f->shared->fs_persist && !H5F_NULL_FSM_ADDR(f)) { + if (f->shared->fs_persist && !H5F_NULL_FSM_ADDR(f)) { /* Sanity check */ HDassert(f->shared->lf); @@ -3204,12 +3187,14 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) HDassert(!H5F_addr_defined(f->shared->fs_addr[sm_fssinfo_fs_type])); /* Note that in most cases, sm_hdr_fspace will equal sm_sinfo_fspace. */ - sm_hdr_fspace = f->shared->fs_man[sm_fshdr_fs_type]; + sm_hdr_fspace = f->shared->fs_man[sm_fshdr_fs_type]; sm_sinfo_fspace = f->shared->fs_man[sm_fssinfo_fs_type]; - if(H5F_PAGED_AGGR(f)) { - H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); - H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); + if (H5F_PAGED_AGGR(f)) { + H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, + &lg_fshdr_fs_type); + H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, + &lg_fssinfo_fs_type); HDassert(lg_fshdr_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); HDassert(lg_fshdr_fs_type < H5F_MEM_PAGE_NTYPES); @@ -3221,7 +3206,7 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) HDassert(!H5F_addr_defined(f->shared->fs_addr[lg_fssinfo_fs_type])); /* Note that in most cases, lg_hdr_fspace will equal lg_sinfo_fspace. */ - lg_hdr_fspace = f->shared->fs_man[lg_fshdr_fs_type]; + lg_hdr_fspace = f->shared->fs_man[lg_fshdr_fs_type]; lg_sinfo_fspace = f->shared->fs_man[lg_fssinfo_fs_type]; } /* end if */ @@ -3229,56 +3214,56 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) H5AC_set_ring(H5AC_RING_MDFSM, &orig_ring); #ifndef NDEBUG -{ - H5FS_stat_t fs_stat; /* Information for hdr FSM */ - - if(sm_hdr_fspace) { - /* Query free space manager info for this type */ - if(H5FS_stat_info(f, sm_hdr_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") - - HDassert(!H5F_addr_defined(fs_stat.addr)); - HDassert(!H5F_addr_defined(fs_stat.sect_addr)); - HDassert(fs_stat.alloc_sect_size == 0); - } /* end if */ - - /* Verify that sm_sinfo_fspace is floating if it exists and is distinct */ - if((sm_sinfo_fspace) && (sm_hdr_fspace != sm_sinfo_fspace)) { - /* Query free space manager info for this type */ - if(H5FS_stat_info(f, sm_sinfo_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") - - HDassert(!H5F_addr_defined(fs_stat.addr)); - HDassert(!H5F_addr_defined(fs_stat.sect_addr)); - HDassert(fs_stat.alloc_sect_size == 0); - } /* end if */ + { + H5FS_stat_t fs_stat; /* Information for hdr FSM */ - if(H5F_PAGED_AGGR(f)) { - /* Verify that lg_hdr_fspace is floating if it exists */ - if(lg_hdr_fspace) { + if (sm_hdr_fspace) { /* Query free space manager info for this type */ - if(H5FS_stat_info(f, lg_hdr_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (3)") + if (H5FS_stat_info(f, sm_hdr_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") HDassert(!H5F_addr_defined(fs_stat.addr)); HDassert(!H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.alloc_sect_size == 0); } /* end if */ - /* Verify that lg_sinfo_fspace is floating if it - * exists and is distinct - */ - if((lg_sinfo_fspace) && (lg_hdr_fspace != lg_sinfo_fspace)) { + /* Verify that sm_sinfo_fspace is floating if it exists and is distinct */ + if ((sm_sinfo_fspace) && (sm_hdr_fspace != sm_sinfo_fspace)) { /* Query free space manager info for this type */ - if(H5FS_stat_info(f, lg_sinfo_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (4)") + if (H5FS_stat_info(f, sm_sinfo_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") HDassert(!H5F_addr_defined(fs_stat.addr)); HDassert(!H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.alloc_sect_size == 0); } /* end if */ - } /* end if */ -} + + if (H5F_PAGED_AGGR(f)) { + /* Verify that lg_hdr_fspace is floating if it exists */ + if (lg_hdr_fspace) { + /* Query free space manager info for this type */ + if (H5FS_stat_info(f, lg_hdr_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (3)") + + HDassert(!H5F_addr_defined(fs_stat.addr)); + HDassert(!H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.alloc_sect_size == 0); + } /* end if */ + + /* Verify that lg_sinfo_fspace is floating if it + * exists and is distinct + */ + if ((lg_sinfo_fspace) && (lg_hdr_fspace != lg_sinfo_fspace)) { + /* Query free space manager info for this type */ + if (H5FS_stat_info(f, lg_sinfo_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (4)") + + HDassert(!H5F_addr_defined(fs_stat.addr)); + HDassert(!H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.alloc_sect_size == 0); + } /* end if */ + } /* end if */ + } #endif /* NDEBUG */ /* Free the space in the metadata aggregator. Do this via the @@ -3289,11 +3274,11 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) * is enabled -- don't attempt to free if this is the case. */ /* (for space not at EOF, it may be put into free space managers) */ - if((!H5F_PAGED_AGGR(f)) && (H5MF_free_aggrs(f) < 0)) + if ((!H5F_PAGED_AGGR(f)) && (H5MF_free_aggrs(f) < 0)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Trying shrinking the EOA for the file */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* WARNING: This approach settling the self referential free space @@ -3324,35 +3309,42 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) */ do { continue_alloc_fsm = FALSE; - if(sm_hdr_fspace) - if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, sm_hdr_fspace, &(f->shared->fs_addr[sm_fshdr_fs_type])) < 0) + if (sm_hdr_fspace) + if (H5FS_vfd_alloc_hdr_and_section_info_if_needed( + f, sm_hdr_fspace, &(f->shared->fs_addr[sm_fshdr_fs_type])) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate sm hdr FSM file space") - if(sm_sinfo_fspace && (sm_sinfo_fspace != sm_hdr_fspace)) - if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, sm_sinfo_fspace, &(f->shared->fs_addr[sm_fssinfo_fs_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate sm sinfo FSM file space") - - if(H5F_PAGED_AGGR(f)) { - if(lg_hdr_fspace) - if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, lg_hdr_fspace, &(f->shared->fs_addr[lg_fshdr_fs_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate lg hdr FSM file space") - - if(lg_sinfo_fspace && (lg_sinfo_fspace != lg_hdr_fspace)) - if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, lg_sinfo_fspace, &(f->shared->fs_addr[lg_fssinfo_fs_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate lg sinfo FSM file space") + if (sm_sinfo_fspace && (sm_sinfo_fspace != sm_hdr_fspace)) + if (H5FS_vfd_alloc_hdr_and_section_info_if_needed( + f, sm_sinfo_fspace, &(f->shared->fs_addr[sm_fssinfo_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't vfd allocate sm sinfo FSM file space") + + if (H5F_PAGED_AGGR(f)) { + if (lg_hdr_fspace) + if (H5FS_vfd_alloc_hdr_and_section_info_if_needed( + f, lg_hdr_fspace, &(f->shared->fs_addr[lg_fshdr_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't vfd allocate lg hdr FSM file space") + + if (lg_sinfo_fspace && (lg_sinfo_fspace != lg_hdr_fspace)) + if (H5FS_vfd_alloc_hdr_and_section_info_if_needed( + f, lg_sinfo_fspace, &(f->shared->fs_addr[lg_fssinfo_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't vfd allocate lg sinfo FSM file space") } /* end if */ - sm_hdr_fspace = f->shared->fs_man[sm_fshdr_fs_type]; + sm_hdr_fspace = f->shared->fs_man[sm_fshdr_fs_type]; sm_sinfo_fspace = f->shared->fs_man[sm_fssinfo_fs_type]; - if(H5F_PAGED_AGGR(f)) { - lg_hdr_fspace = f->shared->fs_man[lg_fshdr_fs_type]; + if (H5F_PAGED_AGGR(f)) { + lg_hdr_fspace = f->shared->fs_man[lg_fshdr_fs_type]; lg_sinfo_fspace = f->shared->fs_man[lg_fssinfo_fs_type]; } - if(H5MF__continue_alloc_fsm(f->shared, sm_hdr_fspace, sm_sinfo_fspace, lg_hdr_fspace, lg_sinfo_fspace, &continue_alloc_fsm) < 0) + if (H5MF__continue_alloc_fsm(f->shared, sm_hdr_fspace, sm_sinfo_fspace, lg_hdr_fspace, + lg_sinfo_fspace, &continue_alloc_fsm) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate lg sinfo FSM file space") - } while(continue_alloc_fsm); - + } while (continue_alloc_fsm); /* All free space managers should have file space allocated for them * now, and should see no further allocations / deallocations. @@ -3366,24 +3358,22 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) * free space managers. Assuming no cache image, this should be the * final EOA of the file. */ - if(HADDR_UNDEF == (eoa_fsm_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + if (HADDR_UNDEF == (eoa_fsm_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") - f->shared->eoa_fsm_fsalloc = eoa_fsm_fsalloc; + f->shared->eoa_fsm_fsalloc = eoa_fsm_fsalloc; /* Indicate that the FSM was settled successfully */ *fsm_settled = TRUE; } /* end if */ - done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF_settle_meta_data_fsm() */ - /*------------------------------------------------------------------------- * Function: H5MF__continue_alloc_fsm * @@ -3399,7 +3389,7 @@ done: */ static herr_t H5MF__continue_alloc_fsm(H5F_shared_t *f_sh, H5FS_t *sm_hdr_fspace, H5FS_t *sm_sinfo_fspace, - H5FS_t *lg_hdr_fspace, H5FS_t *lg_sinfo_fspace, hbool_t *continue_alloc_fsm) + H5FS_t *lg_hdr_fspace, H5FS_t *lg_sinfo_fspace, hbool_t *continue_alloc_fsm) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3408,34 +3398,33 @@ H5MF__continue_alloc_fsm(H5F_shared_t *f_sh, H5FS_t *sm_hdr_fspace, H5FS_t *sm_s HDassert(continue_alloc_fsm); /* Check sm_hdr_fspace */ - if(sm_hdr_fspace && sm_hdr_fspace->serial_sect_count > 0 && sm_hdr_fspace->sinfo) { + if (sm_hdr_fspace && sm_hdr_fspace->serial_sect_count > 0 && sm_hdr_fspace->sinfo) { H5MF_CHECK_FSM(sm_hdr_fspace, continue_alloc_fsm); } /* end if */ - if(!(*continue_alloc_fsm)) - if(sm_sinfo_fspace && sm_sinfo_fspace != sm_hdr_fspace && - sm_sinfo_fspace->serial_sect_count > 0 && sm_sinfo_fspace->sinfo) { + if (!(*continue_alloc_fsm)) + if (sm_sinfo_fspace && sm_sinfo_fspace != sm_hdr_fspace && sm_sinfo_fspace->serial_sect_count > 0 && + sm_sinfo_fspace->sinfo) { H5MF_CHECK_FSM(sm_hdr_fspace, continue_alloc_fsm); } /* end if */ - if(H5F_SHARED_PAGED_AGGR(f_sh) && !(*continue_alloc_fsm)) { + if (H5F_SHARED_PAGED_AGGR(f_sh) && !(*continue_alloc_fsm)) { /* Check lg_hdr_fspace */ - if(lg_hdr_fspace && lg_hdr_fspace->serial_sect_count > 0 && lg_hdr_fspace->sinfo) { + if (lg_hdr_fspace && lg_hdr_fspace->serial_sect_count > 0 && lg_hdr_fspace->sinfo) { H5MF_CHECK_FSM(lg_hdr_fspace, continue_alloc_fsm); } /* end if */ /* Check lg_sinfo_fspace */ - if(!(*continue_alloc_fsm)) - if(lg_sinfo_fspace && lg_sinfo_fspace != lg_hdr_fspace && - lg_sinfo_fspace->serial_sect_count > 0 && lg_sinfo_fspace->sinfo) { + if (!(*continue_alloc_fsm)) + if (lg_sinfo_fspace && lg_sinfo_fspace != lg_hdr_fspace && + lg_sinfo_fspace->serial_sect_count > 0 && lg_sinfo_fspace->sinfo) { H5MF_CHECK_FSM(lg_sinfo_fspace, continue_alloc_fsm); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MF__continue_alloc_fsm() */ - /*------------------------------------------------------------------------- * Function: H5MF__fsm_type_is_self_referential() * @@ -3456,7 +3445,7 @@ H5MF__fsm_type_is_self_referential(H5F_shared_t *f_sh, H5F_mem_page_t fsm_type) H5F_mem_page_t sm_fssinfo_fsm; H5F_mem_page_t lg_fshdr_fsm; H5F_mem_page_t lg_fssinfo_fsm; - hbool_t result = FALSE; + hbool_t result = FALSE; FUNC_ENTER_STATIC_NOERR @@ -3468,12 +3457,12 @@ H5MF__fsm_type_is_self_referential(H5F_shared_t *f_sh, H5F_mem_page_t fsm_type) H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); - if(H5F_SHARED_PAGED_AGGR(f_sh)) { + if (H5F_SHARED_PAGED_AGGR(f_sh)) { H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_HDR, f_sh->fs_page_size + 1, &lg_fshdr_fsm); H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_SINFO, f_sh->fs_page_size + 1, &lg_fssinfo_fsm); - result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm) - || (fsm_type == lg_fshdr_fsm) || (fsm_type == lg_fssinfo_fsm); + result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm) || (fsm_type == lg_fshdr_fsm) || + (fsm_type == lg_fssinfo_fsm); } /* end if */ else { /* In principle, fsm_type should always be less than @@ -3482,7 +3471,7 @@ H5MF__fsm_type_is_self_referential(H5F_shared_t *f_sh, H5F_mem_page_t fsm_type) * not observe this principle, force the result to FALSE if * fsm_type is greater than or equal to H5F_MEM_PAGE_LARGE_SUPER. */ - if(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER) + if (fsm_type >= H5F_MEM_PAGE_LARGE_SUPER) result = FALSE; else result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm); @@ -3491,7 +3480,6 @@ H5MF__fsm_type_is_self_referential(H5F_shared_t *f_sh, H5F_mem_page_t fsm_type) FUNC_LEAVE_NOAPI(result) } /* H5MF__fsm_type_is_self_referential() */ - /*------------------------------------------------------------------------- * Function: H5MF__fsm_is_self_referential() * @@ -3510,7 +3498,7 @@ H5MF__fsm_is_self_referential(H5F_shared_t *f_sh, H5FS_t *fspace) { H5F_mem_page_t sm_fshdr_fsm; H5F_mem_page_t sm_fssinfo_fsm; - hbool_t result = FALSE; + hbool_t result = FALSE; FUNC_ENTER_STATIC_NOERR @@ -3521,21 +3509,18 @@ H5MF__fsm_is_self_referential(H5F_shared_t *f_sh, H5FS_t *fspace) H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); - if(H5F_SHARED_PAGED_AGGR(f_sh)) { + if (H5F_SHARED_PAGED_AGGR(f_sh)) { H5F_mem_page_t lg_fshdr_fsm; H5F_mem_page_t lg_fssinfo_fsm; H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_HDR, f_sh->fs_page_size + 1, &lg_fshdr_fsm); H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_SINFO, f_sh->fs_page_size + 1, &lg_fssinfo_fsm); - result = (fspace == f_sh->fs_man[sm_fshdr_fsm]) || - (fspace == f_sh->fs_man[sm_fssinfo_fsm]) || - (fspace == f_sh->fs_man[lg_fshdr_fsm]) || - (fspace == f_sh->fs_man[lg_fssinfo_fsm]); + result = (fspace == f_sh->fs_man[sm_fshdr_fsm]) || (fspace == f_sh->fs_man[sm_fssinfo_fsm]) || + (fspace == f_sh->fs_man[lg_fshdr_fsm]) || (fspace == f_sh->fs_man[lg_fssinfo_fsm]); } /* end if */ else - result = (fspace == f_sh->fs_man[sm_fshdr_fsm]) || - (fspace == f_sh->fs_man[sm_fssinfo_fsm]); + result = (fspace == f_sh->fs_man[sm_fshdr_fsm]) || (fspace == f_sh->fs_man[sm_fssinfo_fsm]); FUNC_LEAVE_NOAPI(result) } /* H5MF__fsm_is_self_referential() */ diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 476dacd..7e836de 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -23,62 +23,51 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5MFpkg.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5MFpkg.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ #define EXTEND_THRESHOLD 0.10F - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5MF__aggr_free(H5F_t *f, H5FD_mem_t type, - H5F_blk_aggr_t *aggr); -static haddr_t H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, - H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size); -static herr_t H5MF__aggr_reset(H5F_t *f, H5F_blk_aggr_t *aggr); -static htri_t H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr); - +static herr_t H5MF__aggr_free(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr); +static haddr_t H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, + hsize_t size); +static herr_t H5MF__aggr_reset(H5F_t *f, H5F_blk_aggr_t *aggr); +static htri_t H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5MF_aggr_vfd_alloc * @@ -99,11 +88,11 @@ static htri_t H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_ haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); + HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_AGGR_DEBUG */ /* check arguments */ @@ -113,14 +102,16 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HDassert(size > 0); /* Couldn't find anything from the free space manager, go allocate some */ - if(alloc_type != H5FD_MEM_DRAW && alloc_type != H5FD_MEM_GHEAP) { + if (alloc_type != H5FD_MEM_DRAW && alloc_type != H5FD_MEM_GHEAP) { /* Handle metadata differently from "raw" data */ - if(HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), alloc_type, size))) + if (HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), + alloc_type, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate metadata") } /* end if */ else { /* Allocate "raw" data: H5FD_MEM_DRAW and H5FD_MEM_GHEAP */ - if(HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), H5FD_MEM_DRAW, size))) + if (HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), + H5FD_MEM_DRAW, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data") } /* end else */ @@ -129,13 +120,12 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ done: #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); + HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); #endif /* H5MF_AGGR_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_aggr_vfd_alloc() */ - /*------------------------------------------------------------------------- * Function: H5MF__aggr_alloc * @@ -151,31 +141,32 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, *------------------------------------------------------------------------- */ static haddr_t -H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, - H5FD_mem_t type, hsize_t size) +H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size) { - haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ - hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ - haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ + hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ + haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_STATIC #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); + HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); #endif /* H5MF_AGGR_DEBUG */ /* check args */ HDassert(f); HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); HDassert(other_aggr); - HDassert(other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); HDassert(other_aggr->feature_flag != aggr->feature_flag); HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); HDassert(size > 0); /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") /* @@ -194,729 +185,751 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); * the cache eventually adjusts/evicts ageout entries and ends up flushing out the * same entry that is being serialized (flush_in_progress). */ - if((f->shared->feature_flags & aggr->feature_flag) && f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE && (!f->shared->closing || !f->shared->fs_persist)) { + if ((f->shared->feature_flags & aggr->feature_flag) && + f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE && + (!f->shared->closing || !f->shared->fs_persist)) { #ifdef REPLACE - if((f->shared->feature_flags & aggr->feature_flag) && f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE && !f->shared->closing) { + if ((f->shared->feature_flags & aggr->feature_flag) && + f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE && !f->shared->closing) { #endif - haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregrator fragment */ - hsize_t aggr_frag_size = 0; /* Size of aggregator fragment */ - hsize_t alignment; /* Alignment of this section */ - hsize_t aggr_mis_align = 0; /* Mis-alignment of aggregator */ - H5FD_mem_t alloc_type, other_alloc_type;/* Current aggregator & 'other' aggregator types */ + haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregrator fragment */ + hsize_t aggr_frag_size = 0; /* Size of aggregator fragment */ + hsize_t alignment; /* Alignment of this section */ + hsize_t aggr_mis_align = 0; /* Mis-alignment of aggregator */ + H5FD_mem_t alloc_type, other_alloc_type; /* Current aggregator & 'other' aggregator types */ #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_size, aggr->size); + HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_size, aggr->size); #endif /* H5MF_AGGR_DEBUG */ - /* Turn off alignment if allocation < threshold */ - alignment = H5F_ALIGNMENT(f); - if(!((alignment > 1) && (size >= H5F_THRESHOLD(f)))) - alignment = 0; /* no alignment */ + /* Turn off alignment if allocation < threshold */ + alignment = H5F_ALIGNMENT(f); + if (!((alignment > 1) && (size >= H5F_THRESHOLD(f)))) + alignment = 0; /* no alignment */ - /* Generate fragment if aggregator is mis-aligned */ - if(alignment && H5F_addr_gt(aggr->addr, 0) && (aggr_mis_align = (aggr->addr + H5F_BASE_ADDR(f)) % alignment)) { - aggr_frag_addr = aggr->addr; - aggr_frag_size = alignment - aggr_mis_align; - } /* end if */ + /* Generate fragment if aggregator is mis-aligned */ + if (alignment && H5F_addr_gt(aggr->addr, 0) && + (aggr_mis_align = (aggr->addr + H5F_BASE_ADDR(f)) % alignment)) { + aggr_frag_addr = aggr->addr; + aggr_frag_size = alignment - aggr_mis_align; + } /* end if */ - alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; - other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; - - /* Check if the space requested is larger than the space left in the block */ - if((size + aggr_frag_size) > aggr->size) { - htri_t extended = FALSE; /* Whether the file was extended */ - - /* Check if the block asked for is too large for 'normal' aggregator block */ - if(size >= aggr->alloc_size) { - hsize_t ext_size = size + aggr_frag_size; - - /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - - if((aggr->addr > 0) && (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") - else if(extended) { - /* aggr->size is unchanged */ - ret_value = aggr->addr + aggr_frag_size; - aggr->addr += ext_size; - aggr->tot_size += ext_size; - } + alloc_type = + aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; + other_alloc_type = + other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; + + /* Check if the space requested is larger than the space left in the block */ + if ((size + aggr_frag_size) > aggr->size) { + htri_t extended = FALSE; /* Whether the file was extended */ + + /* Check if the block asked for is too large for 'normal' aggregator block */ + if (size >= aggr->alloc_size) { + hsize_t ext_size = size + aggr_frag_size; + + /* Check for overlapping into file's temporary allocation space */ + if (H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) + HGOTO_ERROR( + H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, + "'normal' file space allocation request will overlap into 'temporary' file space") + + if ((aggr->addr > 0) && + (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") + else if (extended) { + /* aggr->size is unchanged */ + ret_value = aggr->addr + aggr_frag_size; + aggr->addr += ext_size; + aggr->tot_size += ext_size; + } + else { + /* Release "other" aggregator, if it exists, is at the end of the allocated space, + * has allocated more than one block and the unallocated space is greater than its + * allocation block size. + */ + if ((other_aggr->size > 0) && + (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && + (other_aggr->tot_size > other_aggr->size) && + ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { + if (H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation block") + } /* end if */ + + /* Allocate space from the VFD (i.e. at the end of the file) */ + if (HADDR_UNDEF == + (ret_value = H5F__alloc(f, alloc_type, size, &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + } /* end else */ + } /* end if */ else { - /* Release "other" aggregator, if it exists, is at the end of the allocated space, - * has allocated more than one block and the unallocated space is greater than its - * allocation block size. - */ - if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && - (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { - if(H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") - } /* end if */ + hsize_t ext_size = aggr->alloc_size; - /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (ret_value = H5F__alloc(f, alloc_type, size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") - } /* end else */ - } /* end if */ - else { - hsize_t ext_size = aggr->alloc_size; - - /* Allocate another block */ + /* Allocate another block */ #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: Allocating block\n", FUNC); + HDfprintf(stderr, "%s: Allocating block\n", FUNC); #endif /* H5MF_AGGR_DEBUG */ - if(aggr_frag_size > (ext_size - size)) - ext_size += (aggr_frag_size - (ext_size - size)); - - /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - - if((aggr->addr > 0) && (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") - else if(extended) { - aggr->addr += aggr_frag_size; - aggr->size += (ext_size - aggr_frag_size); - aggr->tot_size += ext_size; - } /* end else-if */ - else { - haddr_t new_space; /* Address of new space allocated */ - - /* Release "other" aggregator, if it exists, is at the end of the allocated space, - * has allocated more than one block and the unallocated space is greater than its - * allocation block size. - */ - if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && - (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { - if(H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") - } /* end if */ - - /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (new_space = H5F__alloc(f, alloc_type, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") - - /* Return the unused portion of the block to a free list */ - if(aggr->size > 0) - if(H5MF_xfree(f, alloc_type, aggr->addr, aggr->size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") - - /* If the block is not to be aligned, fold the eoa fragment - * into the newly allocated aggregator, as it could have - * been allocated in an aligned manner if the aggregator - * block is larger than the threshold */ - if(eoa_frag_size && !alignment) { - HDassert(eoa_frag_addr + eoa_frag_size == new_space); - aggr->addr = eoa_frag_addr; - aggr->size = aggr->alloc_size + eoa_frag_size; - aggr->tot_size = aggr->size; - - /* Reset EOA fragment */ - eoa_frag_addr = HADDR_UNDEF; - eoa_frag_size = 0; - } /* end if */ + if (aggr_frag_size > (ext_size - size)) + ext_size += (aggr_frag_size - (ext_size - size)); + + /* Check for overlapping into file's temporary allocation space */ + if (H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) + HGOTO_ERROR( + H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, + "'normal' file space allocation request will overlap into 'temporary' file space") + + if ((aggr->addr > 0) && + (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") + else if (extended) { + aggr->addr += aggr_frag_size; + aggr->size += (ext_size - aggr_frag_size); + aggr->tot_size += ext_size; + } /* end else-if */ else { - /* Point the aggregator at the newly allocated block */ - aggr->addr = new_space; - aggr->size = aggr->alloc_size; - aggr->tot_size = aggr->alloc_size; - } /* end else */ - } /* end else */ + haddr_t new_space; /* Address of new space allocated */ - /* Allocate space out of the metadata block */ - ret_value = aggr->addr; - aggr->size -= size; - aggr->addr += size; - } /* end else */ + /* Release "other" aggregator, if it exists, is at the end of the allocated space, + * has allocated more than one block and the unallocated space is greater than its + * allocation block size. + */ + if ((other_aggr->size > 0) && + (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && + (other_aggr->tot_size > other_aggr->size) && + ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { + if (H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation block") + } /* end if */ + + /* Allocate space from the VFD (i.e. at the end of the file) */ + if (HADDR_UNDEF == (new_space = H5F__alloc(f, alloc_type, aggr->alloc_size, + &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + + /* Return the unused portion of the block to a free list */ + if (aggr->size > 0) + if (H5MF_xfree(f, alloc_type, aggr->addr, aggr->size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation block") + + /* If the block is not to be aligned, fold the eoa fragment + * into the newly allocated aggregator, as it could have + * been allocated in an aligned manner if the aggregator + * block is larger than the threshold */ + if (eoa_frag_size && !alignment) { + HDassert(eoa_frag_addr + eoa_frag_size == new_space); + aggr->addr = eoa_frag_addr; + aggr->size = aggr->alloc_size + eoa_frag_size; + aggr->tot_size = aggr->size; + + /* Reset EOA fragment */ + eoa_frag_addr = HADDR_UNDEF; + eoa_frag_size = 0; + } /* end if */ + else { + /* Point the aggregator at the newly allocated block */ + aggr->addr = new_space; + aggr->size = aggr->alloc_size; + aggr->tot_size = aggr->alloc_size; + } /* end else */ + } /* end else */ + + /* Allocate space out of the metadata block */ + ret_value = aggr->addr; + aggr->size -= size; + aggr->addr += size; + } /* end else */ - /* Freeing any possible fragment due to file allocation */ - if(eoa_frag_size) - if(H5MF_xfree(f, alloc_type, eoa_frag_addr, eoa_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") + /* Freeing any possible fragment due to file allocation */ + if (eoa_frag_size) + if (H5MF_xfree(f, alloc_type, eoa_frag_addr, eoa_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") - /* Freeing any possible fragment due to alignment in the block after extension */ - if(extended && aggr_frag_size) - if(H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") - } /* end if */ + /* Freeing any possible fragment due to alignment in the block after extension */ + if (extended && aggr_frag_size) + if (H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation fragment") + } /* end if */ + else { + /* Allocate space out of the block */ + ret_value = aggr->addr + aggr_frag_size; + aggr->size -= (size + aggr_frag_size); + aggr->addr += (size + aggr_frag_size); + + /* free any possible fragment */ + if (aggr_frag_size) + if (H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation fragment") + } /* end else */ + } /* end if */ else { - /* Allocate space out of the block */ - ret_value = aggr->addr + aggr_frag_size; - aggr->size -= (size + aggr_frag_size); - aggr->addr += (size + aggr_frag_size); - - /* free any possible fragment */ - if(aggr_frag_size) - if(H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") + /* Allocate data from the file */ + if (HADDR_UNDEF == (ret_value = H5F__alloc(f, type, size, &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + + /* Check if fragment was generated */ + if (eoa_frag_size) + /* Put fragment on the free list */ + if (H5MF_xfree(f, type, eoa_frag_addr, eoa_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") } /* end else */ - } /* end if */ - else { - /* Allocate data from the file */ - if(HADDR_UNDEF == (ret_value = H5F__alloc(f, type, size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") - - /* Check if fragment was generated */ - if(eoa_frag_size) - /* Put fragment on the free list */ - if(H5MF_xfree(f, type, eoa_frag_addr, eoa_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") - } /* end else */ - /* Sanity check for overlapping into file's temporary allocation space */ - HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); + /* Sanity check for overlapping into file's temporary allocation space */ + HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); - /* Post-condition sanity check */ - if(H5F_ALIGNMENT(f) && size >= H5F_THRESHOLD(f)) - HDassert(!((ret_value + H5FD_get_base_addr(f->shared->lf)) % H5F_ALIGNMENT(f))); + /* Post-condition sanity check */ + if (H5F_ALIGNMENT(f) && size >= H5F_THRESHOLD(f)) + HDassert(!((ret_value + H5FD_get_base_addr(f->shared->lf)) % H5F_ALIGNMENT(f))); done: #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); + HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5MF_AGGR_DEBUG */ - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__aggr_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggr_alloc() */ - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_try_extend - * - * Purpose: Check if a block is inside an aggregator block and extend it - * if possible. - * - * Note: - * When the block to be extended adjoins the aggregator-- - * 1) When the aggregator is at end of file: - * A) If the request is below the threshold, extend the block into the aggregator - * B) If the request is above the threshold, - * a) extend the aggregator by aggr->alloc_size or the extended amount - * b) extend the block into the aggregator - * 2) When the aggregator is not at end of file: - * Extended the block into the aggregator if it has enough space to satisfy the request - * - * Return: Success: TRUE(1) - Block was extended - * FALSE(0) - Block could not be extended - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, December 13, 2007 - * - *------------------------------------------------------------------------- - */ -htri_t -H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, - H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested) -{ - htri_t ret_value = FALSE; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_try_extend + * + * Purpose: Check if a block is inside an aggregator block and extend it + * if possible. + * + * Note: + * When the block to be extended adjoins the aggregator-- + * 1) When the aggregator is at end of file: + * A) If the request is below the threshold, extend the block into the aggregator + * B) If the request is above the threshold, + * a) extend the aggregator by aggr->alloc_size or the extended amount + * b) extend the block into the aggregator + * 2) When the aggregator is not at end of file: + * Extended the block into the aggregator if it has enough space to satisfy the request + * + * Return: Success: TRUE(1) - Block was extended + * FALSE(0) - Block could not be extended + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Thursday, December 13, 2007 + * + *------------------------------------------------------------------------- + */ + htri_t H5MF__aggr_try_extend(H5F_t * f, H5F_blk_aggr_t * aggr, H5FD_mem_t type, haddr_t blk_end, + hsize_t extra_requested) + { + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + + /* Check if this aggregator is active */ + if (f->shared->feature_flags & aggr->feature_flag) { + /* + * If the block being tested adjoins the beginning of the aggregator + * block, check if the aggregator can accommodate the extension. + */ + if (H5F_addr_eq(blk_end, aggr->addr)) { + haddr_t eoa; /* EOA for the file */ - FUNC_ENTER_PACKAGE + /* Get the EOA for the file */ + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + /* If the aggregator is at the end of file: */ + if (H5F_addr_eq(eoa, aggr->addr + aggr->size)) { + /* If extra_requested is below percentage threshold, extend block into the aggregator. */ + if (extra_requested <= (hsize_t)(EXTEND_THRESHOLD * (float)aggr->size)) { + aggr->size -= extra_requested; + aggr->addr += extra_requested; - /* Check if this aggregator is active */ - if(f->shared->feature_flags & aggr->feature_flag) { - /* - * If the block being tested adjoins the beginning of the aggregator - * block, check if the aggregator can accommodate the extension. - */ - if(H5F_addr_eq(blk_end, aggr->addr)) { - haddr_t eoa; /* EOA for the file */ - - /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") - - /* If the aggregator is at the end of file: */ - if(H5F_addr_eq(eoa, aggr->addr + aggr->size)) { - /* If extra_requested is below percentage threshold, extend block into the aggregator. */ - if(extra_requested <= (hsize_t)(EXTEND_THRESHOLD * (float)aggr->size)) { - aggr->size -= extra_requested; - aggr->addr += extra_requested; - - /* Indicate success */ - HGOTO_DONE(TRUE); - } /* end if */ - /* - * If extra_requested is above percentage threshold: - * 1) "bubble" up the aggregator by aggr->alloc_size or extra_requested - * 2) extend the block into the aggregator - */ + /* Indicate success */ + HGOTO_DONE(TRUE); + } /* end if */ + /* + * If extra_requested is above percentage threshold: + * 1) "bubble" up the aggregator by aggr->alloc_size or extra_requested + * 2) extend the block into the aggregator + */ + else { + hsize_t extra = + (extra_requested < aggr->alloc_size) ? aggr->alloc_size : extra_requested; + + if ((ret_value = H5F__try_extend(f, type, (aggr->addr + aggr->size), extra)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") + else if (ret_value == TRUE) { + /* Shift the aggregator block by the extra requested */ + /* (allocates the space for the extra_requested) */ + aggr->addr += extra_requested; + + /* Add extra to the aggregator's total allocated amount */ + aggr->tot_size += extra; + + /* Account for any space added to the aggregator */ + /* (either 0 (if extra_requested > aggr->alloc_size) or + * (aggr->alloc_size - extra_requested) -QAK + */ + aggr->size += extra; + aggr->size -= extra_requested; + } /* end else-if */ + } /* end else */ + } /* end if */ else { - hsize_t extra = (extra_requested < aggr->alloc_size) ? aggr->alloc_size : extra_requested; - - if((ret_value = H5F__try_extend(f, type, (aggr->addr + aggr->size), extra)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") - else if(ret_value == TRUE) { - /* Shift the aggregator block by the extra requested */ - /* (allocates the space for the extra_requested) */ + /* The aggreator is not at end of file */ + /* Check if aggregator has enough internal space to satisfy the extension. */ + if (aggr->size >= extra_requested) { + /* Extend block into aggregator */ + aggr->size -= extra_requested; aggr->addr += extra_requested; - /* Add extra to the aggregator's total allocated amount */ - aggr->tot_size += extra; - - /* Account for any space added to the aggregator */ - /* (either 0 (if extra_requested > aggr->alloc_size) or - * (aggr->alloc_size - extra_requested) -QAK - */ - aggr->size += extra; - aggr->size -= extra_requested; - } /* end else-if */ - } /* end else */ - } /* end if */ - else { - /* The aggreator is not at end of file */ - /* Check if aggregator has enough internal space to satisfy the extension. */ - if(aggr->size >= extra_requested) { - /* Extend block into aggregator */ - aggr->size -= extra_requested; - aggr->addr += extra_requested; - - /* Indicate success */ - HGOTO_DONE(TRUE); - } /* end if */ - } /* end else */ - } /* end if */ - } /* end if */ + /* Indicate success */ + HGOTO_DONE(TRUE); + } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__aggr_try_extend() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_can_absorb - * - * Purpose: Check if a section adjoins an aggregator block and one can - * absorb the other. - * - * Return: Success: TRUE(1) - Section or aggregator can be absorbed - * FALSE(0) - Section and aggregator can not be absorbed - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Friday, February 1, 2008 - * - *------------------------------------------------------------------------- - */ -htri_t -H5MF__aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, - const H5MF_free_section_t *sect, H5MF_shrink_type_t *shrink) -{ - htri_t ret_value = FALSE; /* Return value */ - - FUNC_ENTER_PACKAGE_NOERR + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggr_try_extend() */ - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - HDassert(sect); - HDassert(shrink); - - /* Check if this aggregator is active */ - if(f->shared->feature_flags & aggr->feature_flag) { - /* Check if the block adjoins the beginning or end of the aggregator */ - if(H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr) - || H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)) { + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_can_absorb + * + * Purpose: Check if a section adjoins an aggregator block and one can + * absorb the other. + * + * Return: Success: TRUE(1) - Section or aggregator can be absorbed + * FALSE(0) - Section and aggregator can not be absorbed + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Friday, February 1, 2008 + * + *------------------------------------------------------------------------- + */ + htri_t H5MF__aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, const H5MF_free_section_t *sect, + H5MF_shrink_type_t *shrink) + { + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(sect); + HDassert(shrink); + + /* Check if this aggregator is active */ + if (f->shared->feature_flags & aggr->feature_flag) { + /* Check if the block adjoins the beginning or end of the aggregator */ + if (H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr) || + H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)) { #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: section {%a, %Hu} adjoins aggr = {%a, %Hu}\n", "H5MF__aggr_can_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); + HDfprintf(stderr, "%s: section {%a, %Hu} adjoins aggr = {%a, %Hu}\n", "H5MF__aggr_can_absorb", + sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); #endif /* H5MF_AGGR_DEBUG */ - /* Check if aggregator would get too large and should be absorbed into section */ - if((aggr->size + sect->sect_info.size) >= aggr->alloc_size) - *shrink = H5MF_SHRINK_SECT_ABSORB_AGGR; - else - *shrink = H5MF_SHRINK_AGGR_ABSORB_SECT; - - /* Indicate success */ - HGOTO_DONE(TRUE) - } /* end if */ - } /* end if */ + /* Check if aggregator would get too large and should be absorbed into section */ + if ((aggr->size + sect->sect_info.size) >= aggr->alloc_size) + *shrink = H5MF_SHRINK_SECT_ABSORB_AGGR; + else + *shrink = H5MF_SHRINK_AGGR_ABSORB_SECT; + + /* Indicate success */ + HGOTO_DONE(TRUE) + } /* end if */ + } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__aggr_can_absorb() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_absorb - * - * Purpose: Absorb a free space section into an aggregator block or - * vice versa. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Friday, February 1, 2008 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MF__aggr_absorb(const H5F_t H5_ATTR_UNUSED *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, - hbool_t allow_sect_absorb) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - HDassert(f->shared->feature_flags & aggr->feature_flag); - HDassert(sect); - - /* Check if aggregator would get too large and should be absorbed into section */ - if((aggr->size + sect->sect_info.size) >= aggr->alloc_size && allow_sect_absorb) { - /* Check if the section adjoins the beginning or end of the aggregator */ - if(H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr)) { -#ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins front of section = {%a, %Hu}\n", "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); -#endif /* H5MF_AGGR_DEBUG */ - /* Absorb aggregator onto end of section */ - sect->sect_info.size += aggr->size; - } /* end if */ - else { - /* Sanity check */ - HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggr_can_absorb() */ + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_absorb + * + * Purpose: Absorb a free space section into an aggregator block or + * vice versa. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, February 1, 2008 + * + *------------------------------------------------------------------------- + */ + herr_t H5MF__aggr_absorb(const H5F_t H5_ATTR_UNUSED *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, + hbool_t allow_sect_absorb) + { + FUNC_ENTER_PACKAGE_NOERR + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(f->shared->feature_flags & aggr->feature_flag); + HDassert(sect); + + /* Check if aggregator would get too large and should be absorbed into section */ + if ((aggr->size + sect->sect_info.size) >= aggr->alloc_size && allow_sect_absorb) { + /* Check if the section adjoins the beginning or end of the aggregator */ + if (H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr)) { #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins end of section = {%a, %Hu}\n", "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); + HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins front of section = {%a, %Hu}\n", + "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, + sect->sect_info.size); #endif /* H5MF_AGGR_DEBUG */ - /* Absorb aggregator onto beginning of section */ - sect->sect_info.addr -= aggr->size; - sect->sect_info.size += aggr->size; - } /* end if */ + /* Absorb aggregator onto end of section */ + sect->sect_info.size += aggr->size; + } /* end if */ + else { + /* Sanity check */ + HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); - /* Reset aggregator */ - aggr->tot_size = 0; - aggr->addr = 0; - aggr->size = 0; - } /* end if */ - else { - /* Check if the section adjoins the beginning or end of the aggregator */ - if(H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr)) { #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: section {%a, %Hu} adjoins front of aggr = {%a, %Hu}\n", "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); + HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins end of section = {%a, %Hu}\n", + "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, + sect->sect_info.size); #endif /* H5MF_AGGR_DEBUG */ - /* Absorb section onto front of aggregator */ - aggr->addr -= sect->sect_info.size; - aggr->size += sect->sect_info.size; + /* Absorb aggregator onto beginning of section */ + sect->sect_info.addr -= aggr->size; + sect->sect_info.size += aggr->size; + } /* end if */ - /* Sections absorbed onto front of aggregator count against the total - * amount of space aggregated together. - */ - aggr->tot_size -= MIN(aggr->tot_size, sect->sect_info.size); + /* Reset aggregator */ + aggr->tot_size = 0; + aggr->addr = 0; + aggr->size = 0; } /* end if */ else { - /* Sanity check */ - HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); - + /* Check if the section adjoins the beginning or end of the aggregator */ + if (H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr)) { #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: section {%a, %Hu} adjoins end of aggr = {%a, %Hu}\n", "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); + HDfprintf(stderr, "%s: section {%a, %Hu} adjoins front of aggr = {%a, %Hu}\n", + "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, + aggr->size); #endif /* H5MF_AGGR_DEBUG */ - /* Absorb section onto end of aggregator */ - aggr->size += sect->sect_info.size; - } /* end if */ - /* Sanity check */ - HDassert(!allow_sect_absorb || (aggr->size < aggr->alloc_size)); - } /* end else */ + /* Absorb section onto front of aggregator */ + aggr->addr -= sect->sect_info.size; + aggr->size += sect->sect_info.size; - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5MF__aggr_absorb() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_query - * - * Purpose: Query a block aggregator's current address & size info - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Thursday, December 13, 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, - hsize_t *size) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - - /* Check if this aggregator is active */ - if(f->shared->feature_flags & aggr->feature_flag) { - if(addr) - *addr = aggr->addr; - if(size) - *size = aggr->size; - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5MF__aggr_query() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_reset - * - * Purpose: Reset a block aggregator, returning any space back to file - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Thursday, December 13, 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5MF__aggr_reset(H5F_t *f, H5F_blk_aggr_t *aggr) -{ - H5FD_mem_t alloc_type; /* Type of file memory to work with */ - herr_t ret_value = SUCCEED; /* Return value */ + /* Sections absorbed onto front of aggregator count against the total + * amount of space aggregated together. + */ + aggr->tot_size -= MIN(aggr->tot_size, sect->sect_info.size); + } /* end if */ + else { + /* Sanity check */ + HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); - FUNC_ENTER_STATIC +#ifdef H5MF_AGGR_DEBUG + HDfprintf(stderr, "%s: section {%a, %Hu} adjoins end of aggr = {%a, %Hu}\n", + "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, + aggr->size); +#endif /* H5MF_AGGR_DEBUG */ + /* Absorb section onto end of aggregator */ + aggr->size += sect->sect_info.size; + } /* end if */ + /* Sanity check */ + HDassert(!allow_sect_absorb || (aggr->size < aggr->alloc_size)); + } /* end else */ - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + FUNC_LEAVE_NOAPI(SUCCEED) + } /* end H5MF__aggr_absorb() */ - /* Set the type of memory in the file */ - alloc_type = (aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW); /* Type of file memory to work with */ + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_query + * + * Purpose: Query a block aggregator's current address & size info + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, December 13, 2007 + * + *------------------------------------------------------------------------- + */ + herr_t H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, hsize_t *size) + { + FUNC_ENTER_PACKAGE_NOERR + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + + /* Check if this aggregator is active */ + if (f->shared->feature_flags & aggr->feature_flag) { + if (addr) + *addr = aggr->addr; + if (size) + *size = aggr->size; + } /* end if */ - /* Check if this aggregator is active */ - if(f->shared->feature_flags & aggr->feature_flag) { - haddr_t tmp_addr; /* Temporary holder for aggregator address */ - hsize_t tmp_size; /* Temporary holder for aggregator size */ + FUNC_LEAVE_NOAPI(SUCCEED) + } /* end H5MF__aggr_query() */ - /* Retain aggregator info */ - tmp_addr = aggr->addr; - tmp_size = aggr->size; + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_reset + * + * Purpose: Reset a block aggregator, returning any space back to file + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, December 13, 2007 + * + *------------------------------------------------------------------------- + */ + static herr_t H5MF__aggr_reset(H5F_t * f, H5F_blk_aggr_t * aggr) + { + H5FD_mem_t alloc_type; /* Type of file memory to work with */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + + /* Set the type of memory in the file */ + alloc_type = (aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA + ? H5FD_MEM_DEFAULT + : H5FD_MEM_DRAW); /* Type of file memory to work with */ + + /* Check if this aggregator is active */ + if (f->shared->feature_flags & aggr->feature_flag) { + haddr_t tmp_addr; /* Temporary holder for aggregator address */ + hsize_t tmp_size; /* Temporary holder for aggregator size */ + + /* Retain aggregator info */ + tmp_addr = aggr->addr; + tmp_size = aggr->size; #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: tmp_addr = %a, tmp_size = %Hu\n", FUNC, tmp_addr, tmp_size); + HDfprintf(stderr, "%s: tmp_addr = %a, tmp_size = %Hu\n", FUNC, tmp_addr, tmp_size); #endif /* H5MF_AGGR_DEBUG */ - /* Reset aggregator block information */ - aggr->tot_size = 0; - aggr->addr = 0; - aggr->size = 0; + /* Reset aggregator block information */ + aggr->tot_size = 0; + aggr->addr = 0; + aggr->size = 0; - /* Return the unused portion of the metadata block to the file */ - if(tmp_size > 0 && (H5F_INTENT(f) & H5F_ACC_RDWR)) - if(H5MF_xfree(f, alloc_type, tmp_addr, tmp_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't release aggregator's free space") - } /* end if */ + /* Return the unused portion of the metadata block to the file */ + if (tmp_size > 0 && (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (H5MF_xfree(f, alloc_type, tmp_addr, tmp_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't release aggregator's free space") + } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__aggr_reset() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF_free_aggrs - * - * Purpose: Reset a metadata & small block aggregators, returning any space - * back to file - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Vailin Choi - * July 1st, 2009 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MF_free_aggrs(H5F_t *f) -{ - H5F_blk_aggr_t *first_aggr; /* First aggregator to reset */ - H5F_blk_aggr_t *second_aggr; /* Second aggregator to reset */ - haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ - hsize_t ma_size = 0; /* Size of "metadata aggregator" */ - haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ - hsize_t sda_size = 0; /* Size of "small data aggregator" */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggr_reset() */ - /* Check args */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->lf); - - if (f->shared->closing && H5MF_process_deferred_frees(f, UINT64_MAX) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "could not process deferrals") - - /* Retrieve metadata aggregator info, if available */ - if(H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") - - /* Retrieve 'small data' aggregator info, if available */ - if(H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") - - /* Make certain we release the aggregator that's later in the file first */ - /* (so the file shrinks properly) */ - if(H5F_addr_defined(ma_addr) && H5F_addr_defined(sda_addr)) { - if(H5F_addr_lt(ma_addr, sda_addr)) { - first_aggr = &(f->shared->sdata_aggr); - second_aggr = &(f->shared->meta_aggr); - } /* end if */ + /*------------------------------------------------------------------------- + * Function: H5MF_free_aggrs + * + * Purpose: Reset a metadata & small block aggregators, returning any space + * back to file + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * July 1st, 2009 + * + *------------------------------------------------------------------------- + */ + herr_t H5MF_free_aggrs(H5F_t * f) + { + H5F_blk_aggr_t *first_aggr; /* First aggregator to reset */ + H5F_blk_aggr_t *second_aggr; /* Second aggregator to reset */ + haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ + hsize_t ma_size = 0; /* Size of "metadata aggregator" */ + haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ + hsize_t sda_size = 0; /* Size of "small data aggregator" */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + + if (f->shared->closing && H5MF_process_deferred_frees(f, UINT64_MAX) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "could not process deferrals") + + /* Retrieve metadata aggregator info, if available */ + if (H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") + + /* Retrieve 'small data' aggregator info, if available */ + if (H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") + + /* Make certain we release the aggregator that's later in the file first */ + /* (so the file shrinks properly) */ + if (H5F_addr_defined(ma_addr) && H5F_addr_defined(sda_addr)) { + if (H5F_addr_lt(ma_addr, sda_addr)) { + first_aggr = &(f->shared->sdata_aggr); + second_aggr = &(f->shared->meta_aggr); + } /* end if */ + else { + first_aggr = &(f->shared->meta_aggr); + second_aggr = &(f->shared->sdata_aggr); + } /* end else */ + } /* end if */ else { - first_aggr = &(f->shared->meta_aggr); + first_aggr = &(f->shared->meta_aggr); second_aggr = &(f->shared->sdata_aggr); } /* end else */ - } /* end if */ - else { - first_aggr = &(f->shared->meta_aggr); - second_aggr = &(f->shared->sdata_aggr); - } /* end else */ - /* Release the unused portion of the metadata and "small data" blocks back - * to the free lists in the file. - */ - if(H5MF__aggr_reset(f, first_aggr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset metadata block") - if(H5MF__aggr_reset(f, second_aggr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset 'small data' block") + /* Release the unused portion of the metadata and "small data" blocks back + * to the free lists in the file. + */ + if (H5MF__aggr_reset(f, first_aggr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset metadata block") + if (H5MF__aggr_reset(f, second_aggr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset 'small data' block") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_free_aggrs() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF_free_aggrs() */ - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_can_shrink_eoa - * - * Purpose: Check if the remaining space in the aggregator is at EOA - * - * Return: Success: non-negative (TRUE/FALSE) - * Failure: negative - * - * Programmer: Vailin Choi - * - *------------------------------------------------------------------------- - */ -static htri_t -H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr) -{ - haddr_t eoa = HADDR_UNDEF; /* EOA for the file */ - htri_t ret_value = FALSE; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_can_shrink_eoa + * + * Purpose: Check if the remaining space in the aggregator is at EOA + * + * Return: Success: non-negative (TRUE/FALSE) + * Failure: negative + * + * Programmer: Vailin Choi + * + *------------------------------------------------------------------------- + */ + static htri_t H5MF__aggr_can_shrink_eoa(H5F_t * f, H5FD_mem_t type, H5F_blk_aggr_t * aggr) + { + haddr_t eoa = HADDR_UNDEF; /* EOA for the file */ + htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - /* Sanity check */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + /* Sanity check */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") + /* Get the EOA for the file */ + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") - /* Check if the aggregator is at EOA */ - if(aggr->size > 0 && H5F_addr_defined(aggr->addr)) - ret_value = H5F_addr_eq(eoa, aggr->addr + aggr->size); + /* Check if the aggregator is at EOA */ + if (aggr->size > 0 && H5F_addr_defined(aggr->addr)) + ret_value = H5F_addr_eq(eoa, aggr->addr + aggr->size); done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF__aggr_can_shrink_eoa() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_free - * - * Purpose: Free the aggregator's space in the file. - * - * Note: Does _not_ put the space on a free list - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Vailin Choi - * - *------------------------------------------------------------------------- - */ -static herr_t -H5MF__aggr_free(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr) -{ - herr_t ret_value = SUCCEED; /* Return value */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5MF__aggr_can_shrink_eoa() */ - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(f); - HDassert(f->shared->lf); - HDassert(aggr); - HDassert(H5F_addr_defined(aggr->addr)); - HDassert(aggr->size > 0); - HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - HDassert(f->shared->feature_flags & aggr->feature_flag); + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_free + * + * Purpose: Free the aggregator's space in the file. + * + * Note: Does _not_ put the space on a free list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * + *------------------------------------------------------------------------- + */ + static herr_t H5MF__aggr_free(H5F_t * f, H5FD_mem_t type, H5F_blk_aggr_t * aggr) + { + herr_t ret_value = SUCCEED; /* Return value */ - /* Free the remaining space at EOA in the aggregator */ - if(H5F__free(f, type, aggr->addr, aggr->size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregation block") + FUNC_ENTER_STATIC - /* Reset the aggregator */ - aggr->tot_size = 0; - aggr->addr = HADDR_UNDEF; - aggr->size = 0; + /* Sanity check */ + HDassert(f); + HDassert(f->shared->lf); + HDassert(aggr); + HDassert(H5F_addr_defined(aggr->addr)); + HDassert(aggr->size > 0); + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(f->shared->feature_flags & aggr->feature_flag); + + /* Free the remaining space at EOA in the aggregator */ + if (H5F__free(f, type, aggr->addr, aggr->size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregation block") + + /* Reset the aggregator */ + aggr->tot_size = 0; + aggr->addr = HADDR_UNDEF; + aggr->size = 0; done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF__aggr_free() */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5MF__aggr_free() */ - -/*------------------------------------------------------------------------- - * Function: H5MF_aggrs_try_shrink_eoa - * - * Purpose: Check the metadata & small block aggregators to see if - * EOA shrink is possible; if so, shrink each aggregator - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Vailin Choi - * - *------------------------------------------------------------------------- - */ -htri_t -H5MF_aggrs_try_shrink_eoa(H5F_t *f) -{ - htri_t ma_status; /* Whether the metadata aggregator can shrink the EOA */ - htri_t sda_status; /* Whether the small data aggregator can shrink the EOA */ - htri_t ret_value = FAIL; /* Return value */ + /*------------------------------------------------------------------------- + * Function: H5MF_aggrs_try_shrink_eoa + * + * Purpose: Check the metadata & small block aggregators to see if + * EOA shrink is possible; if so, shrink each aggregator + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * + *------------------------------------------------------------------------- + */ + htri_t H5MF_aggrs_try_shrink_eoa(H5F_t * f) + { + htri_t ma_status; /* Whether the metadata aggregator can shrink the EOA */ + htri_t sda_status; /* Whether the small data aggregator can shrink the EOA */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(FAIL) - /* Check args */ - HDassert(f); - HDassert(f->shared); + /* Check args */ + HDassert(f); + HDassert(f->shared); - if((ma_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr))) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") - if(ma_status > 0) - if(H5MF__aggr_free(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + if ((ma_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr))) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") + if (ma_status > 0) + if (H5MF__aggr_free(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - if((sda_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr))) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") - if(sda_status > 0) - if(H5MF__aggr_free(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + if ((sda_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr))) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") + if (sda_status > 0) + if (H5MF__aggr_free(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - ret_value = (ma_status || sda_status); + ret_value = (ma_status || sda_status); done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_aggrs_try_shrink_eoa() */ - + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF_aggrs_try_shrink_eoa() */ diff --git a/src/H5MFdbg.c b/src/H5MFdbg.c index 43e2305..8530e6e 100644 --- a/src/H5MFdbg.c +++ b/src/H5MFdbg.c @@ -26,43 +26,38 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ -#define H5MF_DEBUGGING /* Need access to file space debugging routines */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ +#define H5MF_DEBUGGING /* Need access to file space debugging routines */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5MFpkg.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5MFpkg.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for free space section iterator callback */ typedef struct { - H5FS_t *fspace; /* Free space manager */ - FILE *stream; /* Stream for output */ - int indent; /* Indention amount */ - int fwidth; /* Field width amount */ + H5FS_t *fspace; /* Free space manager */ + FILE * stream; /* Stream for output */ + int indent; /* Indention amount */ + int fwidth; /* Field width amount */ } H5MF_debug_iter_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -73,17 +68,14 @@ static herr_t H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata); /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5MF__sects_debug_cb * @@ -100,9 +92,9 @@ static herr_t H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata); static herr_t H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) { - H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* Section to dump info */ - H5MF_debug_iter_ud_t *udata = (H5MF_debug_iter_ud_t *)_udata; /* User data for callbacks */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_free_section_t * sect = (H5MF_free_section_t *)_sect; /* Section to dump info */ + H5MF_debug_iter_ud_t *udata = (H5MF_debug_iter_ud_t *)_udata; /* User data for callbacks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -113,33 +105,30 @@ H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) HDassert(udata); /* Print generic section information */ - HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, - "Section type:", - (sect->sect_info.type == H5MF_FSPACE_SECT_SIMPLE ? "simple" : - (sect->sect_info.type == H5MF_FSPACE_SECT_SMALL ? "small" : - (sect->sect_info.type == H5MF_FSPACE_SECT_LARGE ? "large" : "unknown")))); + HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, "Section type:", + (sect->sect_info.type == H5MF_FSPACE_SECT_SIMPLE + ? "simple" + : (sect->sect_info.type == H5MF_FSPACE_SECT_SMALL + ? "small" + : (sect->sect_info.type == H5MF_FSPACE_SECT_LARGE ? "large" : "unknown")))); HDfprintf(udata->stream, "%*s%-*s %a\n", udata->indent, "", udata->fwidth, - "Section address:", - sect->sect_info.addr); + "Section address:", sect->sect_info.addr); HDfprintf(udata->stream, "%*s%-*s %Hu\n", udata->indent, "", udata->fwidth, - "Section size:", - sect->sect_info.size); + "Section size:", sect->sect_info.size); HDfprintf(udata->stream, "%*s%-*s %Hu\n", udata->indent, "", udata->fwidth, - "End of section:", - (haddr_t)((sect->sect_info.addr + sect->sect_info.size) - 1)); + "End of section:", (haddr_t)((sect->sect_info.addr + sect->sect_info.size) - 1)); HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, - "Section state:", - (sect->sect_info.state == H5FS_SECT_LIVE ? "live" : "serialized")); + "Section state:", (sect->sect_info.state == H5FS_SECT_LIVE ? "live" : "serialized")); /* Dump section-specific debugging information */ - if(H5FS_sect_debug(udata->fspace, _sect, udata->stream, udata->indent + 3, MAX(0, udata->fwidth - 3)) < 0) + if (H5FS_sect_debug(udata->fspace, _sect, udata->stream, udata->indent + 3, MAX(0, udata->fwidth - 3)) < + 0) HGOTO_ERROR(H5E_RESOURCE, H5E_BADITER, FAIL, "can't dump section's debugging info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__sects_debug_cb() */ - /*------------------------------------------------------------------------- * Function: H5MF_sects_debug * @@ -157,7 +146,7 @@ herr_t H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth) { H5F_mem_page_t type; /* Memory type for iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -169,14 +158,14 @@ H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth HDassert(indent >= 0); HDassert(fwidth >= 0); - for(type = H5F_MEM_PAGE_DEFAULT; type < H5F_MEM_PAGE_NTYPES; type++) - if(H5F_addr_eq(f->shared->fs_addr[type], fs_addr)) { - if(!f->shared->fs_man[type]) - if(H5MF__open_fstype(f, type) < 0) + for (type = H5F_MEM_PAGE_DEFAULT; type < H5F_MEM_PAGE_NTYPES; type++) + if (H5F_addr_eq(f->shared->fs_addr[type], fs_addr)) { + if (!f->shared->fs_man[type]) + if (H5MF__open_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") - if(f->shared->fs_man[type]) { - H5MF_debug_iter_ud_t udata; /* User data for callbacks */ + if (f->shared->fs_man[type]) { + H5MF_debug_iter_ud_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ udata.fspace = f->shared->fs_man[type]; @@ -185,11 +174,11 @@ H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth udata.fwidth = fwidth; /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, f->shared->fs_man[type], H5MF__sects_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, f->shared->fs_man[type], H5MF__sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") /* Close the free space information */ - if(H5FS_close(f, f->shared->fs_man[type]) < 0) + if (H5FS_close(f, f->shared->fs_man[type]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") } /* end if */ break; @@ -200,7 +189,7 @@ done: } /* H5MF_sects_debug() */ #ifdef H5MF_ALLOC_DEBUG_DUMP - + /*------------------------------------------------------------------------- * Function: H5MF__sects_dump * @@ -217,14 +206,14 @@ done: herr_t H5MF__sects_dump(H5F_t *f, FILE *stream) { - haddr_t eoa; /* End of allocated space in the file */ - int indent = 0; /* Amount to indent */ - int fwidth = 50; /* Field width */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t eoa; /* End of allocated space in the file */ + int indent = 0; /* Amount to indent */ + int fwidth = 50; /* Field width */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); + HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* @@ -234,16 +223,16 @@ HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); HDassert(stream); /* Retrieve the 'eoa' for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); + HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); #endif /* H5MF_ALLOC_DEBUG */ - if(H5F_PAGED_AGGR(f)) { /* File space paging */ - H5F_mem_page_t ptype; /* Memory type for iteration -- page fs */ + if (H5F_PAGED_AGGR(f)) { /* File space paging */ + H5F_mem_page_t ptype; /* Memory type for iteration -- page fs */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { /* Print header for type */ HDfprintf(stream, "%*sFile Free Space Info for type = %u:\n", indent, "", (unsigned)ptype); @@ -251,8 +240,8 @@ HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); HDfprintf(stream, "%*sSections:\n", indent + 3, ""); /* If there is a free space manager for this type, iterate over them */ - if(f->shared->fs_man[ptype]) { - H5MF_debug_iter_ud_t udata; /* User data for callbacks */ + if (f->shared->fs_man[ptype]) { + H5MF_debug_iter_ud_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ udata.fspace = f->shared->fs_man[ptype]; @@ -261,42 +250,44 @@ HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); udata.fwidth = MAX(0, fwidth - 6); /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, f->shared->fs_man[ptype], H5MF__sects_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, f->shared->fs_man[ptype], H5MF__sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") } /* end if */ else /* No sections of this type */ HDfprintf(stream, "%*s\n", indent + 6, ""); - } /* end for */ - } /* end if */ - else { /* not file space paging */ - H5FD_mem_t atype; /* Memory type for iteration -- aggr fs */ - haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ - hsize_t ma_size = 0; /* Size of "metadata aggregator" */ - haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ - hsize_t sda_size = 0; /* Size of "small data aggregator" */ + } /* end for */ + } /* end if */ + else { /* not file space paging */ + H5FD_mem_t atype; /* Memory type for iteration -- aggr fs */ + haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ + hsize_t ma_size = 0; /* Size of "metadata aggregator" */ + haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ + hsize_t sda_size = 0; /* Size of "small data aggregator" */ /* Retrieve metadata aggregator info, if available */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: ma_addr = %a, ma_size = %Hu, end of ma = %a\n", FUNC, ma_addr, ma_size, (haddr_t)((ma_addr + ma_size) - 1)); + HDfprintf(stderr, "%s: ma_addr = %a, ma_size = %Hu, end of ma = %a\n", FUNC, ma_addr, ma_size, + (haddr_t)((ma_addr + ma_size) - 1)); #endif /* H5MF_ALLOC_DEBUG */ /* Retrieve 'small data' aggregator info, if available */ H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, sda_addr, sda_size, (haddr_t)((sda_addr + sda_size) - 1)); + HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, sda_addr, sda_size, + (haddr_t)((sda_addr + sda_size) - 1)); #endif /* H5MF_ALLOC_DEBUG */ /* Iterate over all the free space types that have managers and dump each free list's space */ - for(atype = H5FD_MEM_DEFAULT; atype < H5FD_MEM_NTYPES; atype++) { + for (atype = H5FD_MEM_DEFAULT; atype < H5FD_MEM_NTYPES; atype++) { /* Print header for type */ HDfprintf(stream, "%*sFile Free Space Info for type = %u:\n", indent, "", (unsigned)atype); /* Check for this type being mapped to another type */ - if(H5FD_MEM_DEFAULT == f->shared->fs_type_map[atype] || atype == f->shared->fs_type_map[atype]) { + if (H5FD_MEM_DEFAULT == f->shared->fs_type_map[atype] || atype == f->shared->fs_type_map[atype]) { /* Retrieve the 'eoa' for this file memory type */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, atype))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, atype))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "eoa:", eoa); @@ -304,8 +295,8 @@ HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, HDfprintf(stream, "%*sSections:\n", indent + 3, ""); /* If there is a free space manager for this type, iterate over them */ - if(f->shared->fs_man[atype]) { - H5MF_debug_iter_ud_t udata; /* User data for callbacks */ + if (f->shared->fs_man[atype]) { + H5MF_debug_iter_ud_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ udata.fspace = f->shared->fs_man[atype]; @@ -314,20 +305,20 @@ HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, udata.fwidth = MAX(0, fwidth - 6); /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, f->shared->fs_man[atype], H5MF__sects_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, f->shared->fs_man[atype], H5MF__sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") - } /* end if */ + } /* end if */ else /* No sections of this type */ HDfprintf(stream, "%*s\n", indent + 6, ""); } /* end if */ else - HDfprintf(stream, "%*sMapped to type = %u\n", indent, "", (unsigned)f->shared->fs_type_map[atype]); + HDfprintf(stream, "%*sMapped to type = %u\n", indent, "", + (unsigned)f->shared->fs_type_map[atype]); } /* end for */ - } /* end else */ + } /* end else */ done: -HDfprintf(stderr, "%s: Done dumping file free space sections\n", FUNC); + HDfprintf(stderr, "%s: Done dumping file free space sections\n", FUNC); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__sects_dump() */ #endif /* H5MF_ALLOC_DEBUG_DUMP */ - diff --git a/src/H5MFmodule.h b/src/H5MFmodule.h index 53daabf..d4dd52b 100644 --- a/src/H5MFmodule.h +++ b/src/H5MFmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5MF_MODULE -#define H5_MY_PKG H5MF -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5MF +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO #endif /* _H5MFmodule_H */ - diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index fc398db..4f39a8b 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -30,8 +30,7 @@ #include "H5MFprivate.h" /* Other private headers needed by this file */ -#include "H5FSprivate.h" /* File free space */ - +#include "H5FSprivate.h" /* File free space */ /**************************/ /* Package Private Macros */ @@ -51,32 +50,34 @@ /* Free-space section types for file */ /* (values stored in free space data structures in file) */ -#define H5MF_FSPACE_SECT_SIMPLE 0 /* For non-paged aggregation: section is a range of actual bytes in file */ -#define H5MF_FSPACE_SECT_SMALL 1 /* For paged aggregation: "small" meta/raw data section which is < fsp_size) */ -#define H5MF_FSPACE_SECT_LARGE 2 /* For paged aggregation: "large" Section which is >= fsp_size) */ +#define H5MF_FSPACE_SECT_SIMPLE 0 /* For non-paged aggregation: section is a range of actual bytes in file \ + */ +#define H5MF_FSPACE_SECT_SMALL \ + 1 /* For paged aggregation: "small" meta/raw data section which is < fsp_size) */ +#define H5MF_FSPACE_SECT_LARGE 2 /* For paged aggregation: "large" Section which is >= fsp_size) */ /* Get section class type based on size */ -#define H5MF_SECT_CLASS_TYPE(F, S) \ - ((H5F_PAGED_AGGR(F)) ? \ - ((S >= (F)->shared->fs_page_size) ? H5MF_FSPACE_SECT_LARGE : H5MF_FSPACE_SECT_SMALL) : H5MF_FSPACE_SECT_SIMPLE) +#define H5MF_SECT_CLASS_TYPE(F, S) \ + ((H5F_PAGED_AGGR(F)) \ + ? ((S >= (F)->shared->fs_page_size) ? H5MF_FSPACE_SECT_LARGE : H5MF_FSPACE_SECT_SMALL) \ + : H5MF_FSPACE_SECT_SIMPLE) /* Get section class cls */ -#define H5MF_SECT_CLS_TYPE(F, S) \ - ((H5F_PAGED_AGGR(F)) ? \ - ((S >= (F)->shared->fs_page_size) ? \ - H5MF_FSPACE_SECT_CLS_LARGE : H5MF_FSPACE_SECT_CLS_SMALL) : H5MF_FSPACE_SECT_CLS_SIMPLE) +#define H5MF_SECT_CLS_TYPE(F, S) \ + ((H5F_PAGED_AGGR(F)) \ + ? ((S >= (F)->shared->fs_page_size) ? H5MF_FSPACE_SECT_CLS_LARGE : H5MF_FSPACE_SECT_CLS_SMALL) \ + : H5MF_FSPACE_SECT_CLS_SIMPLE) /* Calculate the mis-aligned fragment */ -#define H5MF_EOA_MISALIGN(F, E, A, FR) \ -{ \ - hsize_t m; \ - \ - if(H5F_addr_gt((E), 0) && ((m) = ((E) + H5F_BASE_ADDR(F)) % (A))) \ - (FR) = (A) - m; \ - else \ - (FR) = 0; \ -} - +#define H5MF_EOA_MISALIGN(F, E, A, FR) \ + { \ + hsize_t m; \ + \ + if (H5F_addr_gt((E), 0) && ((m) = ((E) + H5F_BASE_ADDR(F)) % (A))) \ + (FR) = (A)-m; \ + else \ + (FR) = 0; \ + } /****************************/ /* Package Private Typedefs */ @@ -84,21 +85,22 @@ /* File free space section info */ typedef struct H5MF_free_section_t { - H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ + H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ #ifdef NOT_YET union { struct { - H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */ - unsigned par_entry; /* Entry of free section's direct block in parent indirect block */ + H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */ + unsigned par_entry; /* Entry of free section's direct block in parent indirect block */ } single; struct { - struct H5HF_free_section_t *under; /* Pointer to indirect block underlying row section */ - unsigned row; /* Row for range of blocks */ - unsigned col; /* Column for range of blocks */ - unsigned num_entries; /* Number of entries covered */ + struct H5HF_free_section_t *under; /* Pointer to indirect block underlying row section */ + unsigned row; /* Row for range of blocks */ + unsigned col; /* Column for range of blocks */ + unsigned num_entries; /* Number of entries covered */ /* Fields that aren't stored */ - hbool_t checked_out; /* Flag to indicate that a row section is temporarily out of the free space manager */ + hbool_t checked_out; /* Flag to indicate that a row section is temporarily out of the free space + manager */ } row; struct { /* Holds either a pointer to an indirect block (if its "live") or @@ -108,23 +110,24 @@ typedef struct H5MF_free_section_t { * or not) */ union { - H5HF_indirect_t *iblock; /* Indirect block for free section */ - hsize_t iblock_off; /* Indirect block offset in "heap space" */ + H5HF_indirect_t *iblock; /* Indirect block for free section */ + hsize_t iblock_off; /* Indirect block offset in "heap space" */ } u; - unsigned row; /* Row for range of blocks */ - unsigned col; /* Column for range of blocks */ - unsigned num_entries; /* Number of entries covered */ + unsigned row; /* Row for range of blocks */ + unsigned col; /* Column for range of blocks */ + unsigned num_entries; /* Number of entries covered */ /* Fields that aren't stored */ - struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */ - unsigned par_entry; /* Entry within parent indirect section */ - hsize_t span_size; /* Size of space tracked, in "heap space" */ - unsigned iblock_entries; /* Number of entries in indirect block where section is located */ - unsigned rc; /* Reference count of outstanding row & child indirect sections */ - unsigned dir_nrows; /* Number of direct rows in section */ - struct H5HF_free_section_t **dir_rows; /* Array of pointers to outstanding row sections */ - unsigned indir_nents; /* Number of indirect entries in section */ - struct H5HF_free_section_t **indir_ents; /* Array of pointers to outstanding child indirect sections */ + struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */ + unsigned par_entry; /* Entry within parent indirect section */ + hsize_t span_size; /* Size of space tracked, in "heap space" */ + unsigned iblock_entries; /* Number of entries in indirect block where section is located */ + unsigned rc; /* Reference count of outstanding row & child indirect sections */ + unsigned dir_nrows; /* Number of direct rows in section */ + struct H5HF_free_section_t **dir_rows; /* Array of pointers to outstanding row sections */ + unsigned indir_nents; /* Number of indirect entries in section */ + struct H5HF_free_section_t * + *indir_ents; /* Array of pointers to outstanding child indirect sections */ } indirect; } u; #endif /* NOT_YET */ @@ -132,34 +135,33 @@ typedef struct H5MF_free_section_t { /* Type of "container shrink" operation to perform */ typedef enum { - H5MF_SHRINK_EOA, /* Section should shrink the EOA value */ - H5MF_SHRINK_AGGR_ABSORB_SECT, /* Section should merge into the aggregator block */ - H5MF_SHRINK_SECT_ABSORB_AGGR /* Aggregator block should merge into the section */ + H5MF_SHRINK_EOA, /* Section should shrink the EOA value */ + H5MF_SHRINK_AGGR_ABSORB_SECT, /* Section should merge into the aggregator block */ + H5MF_SHRINK_SECT_ABSORB_AGGR /* Aggregator block should merge into the section */ } H5MF_shrink_type_t; /* User data for free space manager section callbacks */ typedef struct H5MF_sect_ud_t { /* Down */ - H5F_t *f; /* Pointer to file to operate on */ - H5FD_mem_t alloc_type; /* Type of memory being allocated */ - hbool_t allow_sect_absorb; /* Whether sections are allowed to absorb a block aggregator */ - hbool_t allow_eoa_shrink_only; /* Whether shrinking eoa is allowed only for the section */ + H5F_t * f; /* Pointer to file to operate on */ + H5FD_mem_t alloc_type; /* Type of memory being allocated */ + hbool_t allow_sect_absorb; /* Whether sections are allowed to absorb a block aggregator */ + hbool_t allow_eoa_shrink_only; /* Whether shrinking eoa is allowed only for the section */ /* Up */ - H5MF_shrink_type_t shrink; /* Type of shrink operation to perform */ - H5F_blk_aggr_t *aggr; /* Aggregator block to operate on */ + H5MF_shrink_type_t shrink; /* Type of shrink operation to perform */ + H5F_blk_aggr_t * aggr; /* Aggregator block to operate on */ } H5MF_sect_ud_t; /* Information about the current free-space manager to use */ typedef struct H5MF_fs_t { H5F_fs_state_t *fs_state; - haddr_t *fs_addr; - H5FS_t **fs_man; - hsize_t align_thres; /* Threshold for alignment */ - hsize_t alignment; /* Alignment */ + haddr_t * fs_addr; + H5FS_t ** fs_man; + hsize_t align_thres; /* Threshold for alignment */ + hsize_t alignment; /* Alignment */ } H5MF_fs_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -169,7 +171,6 @@ H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1]; H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1]; H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1]; - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -179,24 +180,21 @@ H5_DLL herr_t H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type); H5_DLL herr_t H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type); H5_DLL htri_t H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, haddr_t *addr); H5_DLL herr_t H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_section_t *node); -H5_DLL void H5MF__alloc_to_fs_type(H5F_shared_t *f_sh, H5FD_mem_t alloc_type, - hsize_t size, H5F_mem_page_t *fs_type); +H5_DLL void H5MF__alloc_to_fs_type(H5F_shared_t *f_sh, H5FD_mem_t alloc_type, hsize_t size, + H5F_mem_page_t *fs_type); /* 'simple/small/large' section routines */ -H5_DLL H5MF_free_section_t *H5MF__sect_new(unsigned ctype, haddr_t sect_off, - hsize_t sect_size); -H5_DLL herr_t H5MF__sect_free(H5FS_section_info_t *sect); - +H5_DLL H5MF_free_section_t *H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size); +H5_DLL herr_t H5MF__sect_free(H5FS_section_info_t *sect); /* Block aggregator routines */ -H5_DLL htri_t H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, - H5FD_mem_t type, haddr_t abs_blk_end, hsize_t extra_requested); +H5_DLL htri_t H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, H5FD_mem_t type, haddr_t abs_blk_end, + hsize_t extra_requested); H5_DLL htri_t H5MF__aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, - const H5MF_free_section_t *sect, H5MF_shrink_type_t *shrink); -H5_DLL herr_t H5MF__aggr_absorb(const H5F_t *f, H5F_blk_aggr_t *aggr, - H5MF_free_section_t *sect, hbool_t allow_sect_absorb); -H5_DLL herr_t H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, - haddr_t *addr, hsize_t *size); + const H5MF_free_section_t *sect, H5MF_shrink_type_t *shrink); +H5_DLL herr_t H5MF__aggr_absorb(const H5F_t *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, + hbool_t allow_sect_absorb); +H5_DLL herr_t H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, hsize_t *size); /* Debugging routines */ #ifdef H5MF_ALLOC_DEBUG_DUMP @@ -208,4 +206,3 @@ H5_DLL herr_t H5MF__sects_dump(H5F_t *f, FILE *stream); #endif /* H5MF_TESTING */ #endif /* _H5MFpkg_H */ - diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h index c7e9e6e..ee1aa4b 100644 --- a/src/H5MFprivate.h +++ b/src/H5MFprivate.h @@ -25,24 +25,21 @@ #define _H5MFprivate_H /* Private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File Drivers */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File Drivers */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -56,13 +53,10 @@ H5_DLL herr_t H5MF_try_close(H5F_t *f); /* File space allocation routines */ H5_DLL haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size); H5_DLL haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size); -H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, - hsize_t size); -H5_DLL herr_t H5MF_try_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, - hsize_t size, hsize_t extra_requested); +H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size); +H5_DLL herr_t H5MF_try_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested); H5_DLL htri_t H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size); -H5_DLL ssize_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, - H5F_sect_info_t *sect_info); +H5_DLL ssize_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info); /* File 'temporary' space allocation routines */ H5_DLL haddr_t H5MF_alloc_tmp(H5F_t *f, hsize_t size); @@ -87,9 +81,7 @@ H5_DLL herr_t H5MF_tidy_self_referential_fsm_hack(H5F_t *f); /* Debugging routines */ #ifdef H5MF_DEBUGGING -H5_DLL herr_t H5MF_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth); +H5_DLL herr_t H5MF_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); #endif /* H5MF_DEBUGGING */ #endif /* end _H5MFprivate_H */ - diff --git a/src/H5MFsection.c b/src/H5MFsection.c index 6d23748..5ea8883 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -23,74 +23,58 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5MFpkg.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5MFpkg.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* 'simple/small/large' section callbacks */ -static H5FS_section_info_t *H5MF__sect_deserialize(const H5FS_section_class_t *cls, - const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); -static herr_t H5MF__sect_valid(const H5FS_section_class_t *cls, - const H5FS_section_info_t *sect); -static H5FS_section_info_t *H5MF__sect_split(H5FS_section_info_t *sect, - hsize_t frag_size); - +static H5FS_section_info_t *H5MF__sect_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, + haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); +static herr_t H5MF__sect_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect); +static H5FS_section_info_t *H5MF__sect_split(H5FS_section_info_t *sect, hsize_t frag_size); /* 'simple' section callbacks */ -static htri_t H5MF__sect_simple_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF__sect_simple_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static htri_t H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, - void *udata); -static herr_t H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, - void *udata); - +static htri_t H5MF__sect_simple_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5MF__sect_simple_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static htri_t H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *udata); +static herr_t H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *udata); /* 'small' section callbacks */ static herr_t H5MF__sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata); -static htri_t H5MF__sect_small_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF__sect_small_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); +static htri_t H5MF__sect_small_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5MF__sect_small_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); /* 'large' section callbacks */ -static htri_t H5MF__sect_large_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF__sect_large_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static htri_t H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, - void *udata); -static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, - void *udata); +static htri_t H5MF__sect_large_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5MF__sect_large_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static htri_t H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *udata); +static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *udata); /*********************/ /* Package Variables */ @@ -99,86 +83,85 @@ static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, /* Class info for "simple" free space sections */ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ /* Class variables */ - H5MF_FSPACE_SECT_SIMPLE, /* Section type */ - 0, /* Extra serialized size */ + H5MF_FSPACE_SECT_SIMPLE, /* Section type */ + 0, /* Extra serialized size */ H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - H5MF__sect_deserialize, /* Deserialize section */ - H5MF__sect_simple_can_merge, /* Can sections merge? */ - H5MF__sect_simple_merge, /* Merge sections */ - H5MF__sect_simple_can_shrink, /* Can section shrink container?*/ - H5MF__sect_simple_shrink, /* Shrink container w/section */ - H5MF__sect_free, /* Free section */ - H5MF__sect_valid, /* Check validity of section */ - H5MF__sect_split, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_simple_can_merge, /* Can sections merge? */ + H5MF__sect_simple_merge, /* Merge sections */ + H5MF__sect_simple_can_shrink, /* Can section shrink container?*/ + H5MF__sect_simple_shrink, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; /* Class info for "small" free space sections */ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1] = {{ /* Class variables */ - H5MF_FSPACE_SECT_SMALL, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + H5MF_FSPACE_SECT_SMALL, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - H5MF__sect_small_add, /* Add section */ + H5MF__sect_small_add, /* Add section */ NULL, /* Serialize section */ - H5MF__sect_deserialize, /* Deserialize section */ - H5MF__sect_small_can_merge, /* Can sections merge? */ - H5MF__sect_small_merge, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - H5MF__sect_free, /* Free section */ - H5MF__sect_valid, /* Check validity of section */ - H5MF__sect_split, /* Split section node for alignment */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_small_can_merge, /* Can sections merge? */ + H5MF__sect_small_merge, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ NULL, /* Dump debugging for section */ }}; /* Class info for "large" free space sections */ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1] = {{ /* Class variables */ - H5MF_FSPACE_SECT_LARGE, /* Section type */ - 0, /* Extra serialized size */ + H5MF_FSPACE_SECT_LARGE, /* Section type */ + 0, /* Extra serialized size */ H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - H5MF__sect_deserialize, /* Deserialize section */ - H5MF__sect_large_can_merge, /* Can sections merge? */ - H5MF__sect_large_merge, /* Merge sections */ - H5MF__sect_large_can_shrink, /* Can section shrink container?*/ - H5MF__sect_large_shrink, /* Shrink container w/section */ - H5MF__sect_free, /* Free section */ - H5MF__sect_valid, /* Check validity of section */ - H5MF__sect_split, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_large_can_merge, /* Can sections merge? */ + H5MF__sect_large_merge, /* Merge sections */ + H5MF__sect_large_can_shrink, /* Can section shrink container?*/ + H5MF__sect_large_shrink, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -190,7 +173,6 @@ H5FL_DEFINE(H5MF_free_section_t); * "simple/small/large" section callbacks */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_new * @@ -207,8 +189,8 @@ H5FL_DEFINE(H5MF_free_section_t); H5MF_free_section_t * H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) { - H5MF_free_section_t *sect; /* 'Simple' free space section to add */ - H5MF_free_section_t *ret_value = NULL; /* Return value */ + H5MF_free_section_t *sect; /* 'Simple' free space section to add */ + H5MF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -216,15 +198,16 @@ H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) HDassert(sect_size); /* Create free space section node */ - if(NULL == (sect = H5FL_MALLOC(H5MF_free_section_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for direct block free list section") + if (NULL == (sect = H5FL_MALLOC(H5MF_free_section_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for direct block free list section") /* Set the information passed in */ sect->sect_info.addr = sect_off; sect->sect_info.size = sect_size; /* Set the section's class & state */ - sect->sect_info.type = ctype; + sect->sect_info.type = ctype; sect->sect_info.state = H5FS_SECT_LIVE; /* Set return value */ @@ -234,7 +217,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__sect_new() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_free * @@ -251,7 +233,7 @@ done: herr_t H5MF__sect_free(H5FS_section_info_t *_sect) { - H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* File free section */ + H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* File free section */ FUNC_ENTER_PACKAGE_NOERR @@ -262,9 +244,8 @@ H5MF__sect_free(H5FS_section_info_t *_sect) sect = H5FL_FREE(H5MF_free_section_t, sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF__sect_free() */ +} /* H5MF__sect_free() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_deserialize * @@ -279,12 +260,11 @@ H5MF__sect_free(H5FS_section_info_t *_sect) *------------------------------------------------------------------------- */ static H5FS_section_info_t * -H5MF__sect_deserialize(const H5FS_section_class_t *cls, - const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, - hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) +H5MF__sect_deserialize(const H5FS_section_class_t *cls, const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, + hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) { - H5MF_free_section_t *sect; /* New section */ - H5FS_section_info_t *ret_value = NULL; /* Return value */ + H5MF_free_section_t *sect; /* New section */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -294,7 +274,7 @@ H5MF__sect_deserialize(const H5FS_section_class_t *cls, HDassert(sect_size); /* Create free space section for block */ - if(NULL == (sect = H5MF__sect_new(cls->type, sect_addr, sect_size))) + if (NULL == (sect = H5MF__sect_new(cls->type, sect_addr, sect_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") /* Set return value */ @@ -304,7 +284,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_valid * @@ -319,16 +298,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, - const H5FS_section_info_t +H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5FS_section_info_t #ifdef NDEBUG - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* NDEBUG */ - *_sect) + *_sect) { #ifndef NDEBUG - const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ -#endif /* NDEBUG */ + const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ +#endif /* NDEBUG */ FUNC_ENTER_STATIC_NOERR @@ -336,8 +314,7 @@ H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, HDassert(sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF__sect_valid() */ - +} /* H5MF__sect_valid() */ /*------------------------------------------------------------------------- * Function: H5MF__sect_split @@ -355,12 +332,12 @@ H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, static H5FS_section_info_t * H5MF__sect_split(H5FS_section_info_t *sect, hsize_t frag_size) { - H5MF_free_section_t *ret_value = NULL; /* Return value */ + H5MF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space for new section */ - if(NULL == (ret_value = H5MF__sect_new(sect->type, sect->addr, frag_size))) + if (NULL == (ret_value = H5MF__sect_new(sect->type, sect->addr, frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") /* Set new section's info */ @@ -374,7 +351,7 @@ done: /* * "simple" section callbacks */ - + /*------------------------------------------------------------------------- * Function: H5MF__sect_simple_can_merge * @@ -391,19 +368,19 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ - const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ - htri_t ret_value = FAIL; /* Return value */ + const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ + const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Check if second section adjoins first section */ @@ -412,7 +389,6 @@ H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_simple_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_simple_merge * @@ -430,11 +406,11 @@ H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, */ static herr_t H5MF__sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void H5_ATTR_UNUSED *_udata) + void H5_ATTR_UNUSED *_udata) { - H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ - H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ + H5MF_free_section_t * sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -449,14 +425,13 @@ H5MF__sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_simple_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_simple_can_shrink * @@ -473,11 +448,11 @@ done: static htri_t H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { - const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - haddr_t eoa; /* End of address space in the file */ - haddr_t end; /* End of section to extend */ - htri_t ret_value = FAIL; /* Return value */ + const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ + H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + haddr_t eoa; /* End of address space in the file */ + haddr_t end; /* End of section to extend */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC @@ -487,18 +462,19 @@ H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) HDassert(udata->f); /* Retrieve the end of the file's address space */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(udata->f, udata->alloc_type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") + if (HADDR_UNDEF == (eoa = H5F_get_eoa(udata->f, udata->alloc_type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* Compute address of end of section to check */ end = sect->sect_info.addr + sect->sect_info.size; /* Check if the section is exactly at the end of the allocated space in the file */ - if(H5F_addr_eq(end, eoa)) { + if (H5F_addr_eq(end, eoa)) { /* Set the shrinking type */ udata->shrink = H5MF_SHRINK_EOA; #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, sect->sect_info.size, eoa); + HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, + sect->sect_info.size, eoa); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ @@ -506,47 +482,51 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect- } /* end if */ else { /* Shrinking can't occur if the 'eoa_shrink_only' flag is set and we're not shrinking the EOA */ - if(udata->allow_eoa_shrink_only) + if (udata->allow_eoa_shrink_only) HGOTO_DONE(FALSE) /* Check if this section is allowed to merge with metadata aggregation block */ - if(udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_METADATA) { - htri_t status; /* Status from aggregator adjoin */ + if (udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_METADATA) { + htri_t status; /* Status from aggregator adjoin */ /* See if section can absorb the aggregator & vice versa */ - if((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->meta_aggr), sect, &(udata->shrink))) < 0) + if ((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->meta_aggr), sect, + &(udata->shrink))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "error merging section with aggregation block") - else if(status > 0) { + else if (status > 0) { /* Set the aggregator to operate on */ udata->aggr = &(udata->f->shared->meta_aggr); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins metadata aggregator\n", FUNC, sect->sect_info.addr, sect->sect_info.size); + HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins metadata aggregator\n", FUNC, + sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ HGOTO_DONE(TRUE) } /* end if */ - } /* end if */ + } /* end if */ /* Check if this section is allowed to merge with small 'raw' aggregation block */ - if(udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_RAWDATA) { - htri_t status; /* Status from aggregator adjoin */ + if (udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_RAWDATA) { + htri_t status; /* Status from aggregator adjoin */ /* See if section can absorb the aggregator & vice versa */ - if((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->sdata_aggr), sect, &(udata->shrink))) < 0) + if ((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->sdata_aggr), sect, + &(udata->shrink))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "error merging section with aggregation block") - else if(status > 0) { + else if (status > 0) { /* Set the aggregator to operate on */ udata->aggr = &(udata->f->shared->sdata_aggr); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins small data aggregator\n", FUNC, sect->sect_info.addr, sect->sect_info.size); + HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins small data aggregator\n", FUNC, + sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ HGOTO_DONE(TRUE) } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Set return value */ ret_value = FALSE; @@ -555,7 +535,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_simple_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_simple_shrink * @@ -572,9 +551,9 @@ done: static herr_t H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) { - H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ + H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -584,12 +563,12 @@ H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert(udata->f); /* Check for shrinking file */ - if(H5MF_SHRINK_EOA == udata->shrink) { + if (H5MF_SHRINK_EOA == udata->shrink) { /* Sanity check */ HDassert(H5F_INTENT(udata->f) & H5F_ACC_RDWR); /* Release section's space at EOA */ - if(H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) + if (H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") } /* end if */ else { @@ -597,14 +576,15 @@ H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert(udata->aggr); /* Absorb the section into the aggregator or vice versa */ - if(H5MF__aggr_absorb(udata->f, udata->aggr, *sect, udata->allow_sect_absorb) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't absorb section into aggregator or vice versa") + if (H5MF__aggr_absorb(udata->f, udata->aggr, *sect, udata->allow_sect_absorb) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, + "can't absorb section into aggregator or vice versa") } /* end else */ /* Check for freeing section */ - if(udata->shrink != H5MF_SHRINK_SECT_ABSORB_AGGR) { + if (udata->shrink != H5MF_SHRINK_SECT_ABSORB_AGGR) { /* Free section */ - if(H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") /* Mark section as freed, for free space manager */ @@ -619,7 +599,6 @@ done: * "small" section callbacks */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_small_add * @@ -638,51 +617,52 @@ done: static herr_t H5MF__sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) { - H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* Fractal heap free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - haddr_t sect_end; - hsize_t rem, prem; - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* Fractal heap free section */ + H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + haddr_t sect_end; + hsize_t rem, prem; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Entering, section {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, (*sect)->sect_info.size); + HDfprintf(stderr, "%s: Entering, section {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, + (*sect)->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Do not adjust the section raw data or global heap data */ - if(udata->alloc_type == H5FD_MEM_DRAW || udata->alloc_type == H5FD_MEM_GHEAP) + if (udata->alloc_type == H5FD_MEM_DRAW || udata->alloc_type == H5FD_MEM_GHEAP) HGOTO_DONE(ret_value); sect_end = (*sect)->sect_info.addr + (*sect)->sect_info.size; - rem = sect_end % udata->f->shared->fs_page_size; - prem = udata->f->shared->fs_page_size - rem; + rem = sect_end % udata->f->shared->fs_page_size; + prem = udata->f->shared->fs_page_size - rem; /* Drop the section if it is at page end and its size is <= pgend threshold */ - if(!rem && (*sect)->sect_info.size <= H5F_PGEND_META_THRES(udata->f) && (*flags & H5FS_ADD_RETURNED_SPACE)) { - if(H5MF__sect_free((H5FS_section_info_t *)(*sect)) < 0) + if (!rem && (*sect)->sect_info.size <= H5F_PGEND_META_THRES(udata->f) && + (*flags & H5FS_ADD_RETURNED_SPACE)) { + if (H5MF__sect_free((H5FS_section_info_t *)(*sect)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") *sect = NULL; *flags &= (unsigned)~H5FS_ADD_RETURNED_SPACE; *flags |= H5FS_PAGE_END_NO_ADD; #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section is dropped\n", FUNC); + HDfprintf(stderr, "%s: section is dropped\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ - } /* end if */ + } /* end if */ /* Adjust the section if it is not at page end but its size + prem is at page end */ - else - if(prem <= H5F_PGEND_META_THRES(udata->f)) { - (*sect)->sect_info.size += prem; + else if (prem <= H5F_PGEND_META_THRES(udata->f)) { + (*sect)->sect_info.size += prem; #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section is adjusted {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, (*sect)->sect_info.size); + HDfprintf(stderr, "%s: section is adjusted {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, + (*sect)->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_small_add() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_small_can_merge * @@ -699,37 +679,36 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF__sect_small_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void *_udata) +H5MF__sect_small_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, void *_udata) { - const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ - const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - htri_t ret_value = FALSE; /* Return value */ + const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ + const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ + H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Check if second section adjoins first section */ ret_value = H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr); - if(ret_value > 0) + if (ret_value > 0) /* If they are on different pages, couldn't merge */ - if((sect1->sect_info.addr / udata->f->shared->fs_page_size) != (((sect2->sect_info.addr + sect2->sect_info.size - 1) / udata->f->shared->fs_page_size))) - ret_value = FALSE; + if ((sect1->sect_info.addr / udata->f->shared->fs_page_size) != + (((sect2->sect_info.addr + sect2->sect_info.size - 1) / udata->f->shared->fs_page_size))) + ret_value = FALSE; #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_small_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_small_merge * @@ -747,13 +726,12 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); *------------------------------------------------------------------------- */ static herr_t -H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void *_udata) +H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { - H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ - H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ + H5MF_free_section_t * sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ + H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -767,8 +745,8 @@ H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 /* Add second section's size to first section */ (*sect1)->sect_info.size += sect2->sect_info.size; - if((*sect1)->sect_info.size == udata->f->shared->fs_page_size) { - if(H5MF_xfree(udata->f, udata->alloc_type, (*sect1)->sect_info.addr, (*sect1)->sect_info.size) < 0) + if ((*sect1)->sect_info.size == udata->f->shared->fs_page_size) { + if (H5MF_xfree(udata->f, udata->alloc_type, (*sect1)->sect_info.addr, (*sect1)->sect_info.size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free merged section") /* Need to free possible raw/metadata page in the page buffer. @@ -778,17 +756,17 @@ H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 * Note: Update of raw data page (large or small sized) is handled * by the PB cache */ - if(udata->f->shared->pb_ptr != NULL) - if(H5PB_remove_entry(udata->f->shared, (*sect1)->sect_info.addr) < 0) + if (udata->f->shared->pb_ptr != NULL) + if (H5PB_remove_entry(udata->f->shared, (*sect1)->sect_info.addr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free merged section from page buffer") - if(H5MF__sect_free((H5FS_section_info_t *)(*sect1)) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)(*sect1)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") *sect1 = NULL; } /* end if */ /* Get rid of second section */ - if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: @@ -799,7 +777,6 @@ done: * "Large" section callbacks */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_large_can_merge (same as H5MF__sect_simple_can_merge) * @@ -815,26 +792,26 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF__sect_large_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5MF__sect_large_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ - const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ - htri_t ret_value = FALSE; /* Return value */ + const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ + const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ if (!H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)) { - HDfprintf(stderr, "%s.%d: sect1->sect_info.addr %" PRIuHADDR - ", sect2->sect_info.addr %" PRIuHADDR "\n", __func__, __LINE__, - sect1->sect_info.addr, sect2->sect_info.addr); - HDfprintf(stderr, "%s.%d: sect1->sect_info.size %" PRIuHSIZE - ", sect2->sect_info.size %" PRIuHSIZE "\n", __func__, __LINE__, - sect1->sect_info.size, sect2->sect_info.size); + HDfprintf(stderr, + "%s.%d: sect1->sect_info.addr %" PRIuHADDR ", sect2->sect_info.addr %" PRIuHADDR "\n", + __func__, __LINE__, sect1->sect_info.addr, sect2->sect_info.addr); + HDfprintf(stderr, + "%s.%d: sect1->sect_info.size %" PRIuHSIZE ", sect2->sect_info.size %" PRIuHSIZE "\n", + __func__, __LINE__, sect1->sect_info.size, sect2->sect_info.size); HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't merge") } HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); @@ -842,14 +819,13 @@ H5MF__sect_large_can_merge(const H5FS_section_info_t *_sect1, ret_value = H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_large_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_large_merge (same as H5MF__sect_simple_merge) * @@ -865,12 +841,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF__sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void H5_ATTR_UNUSED *_udata) +H5MF__sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { - H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ - H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ + H5MF_free_section_t * sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -885,14 +860,13 @@ H5MF__sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_large_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_large_can_shrink * @@ -908,11 +882,11 @@ done: static htri_t H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { - const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - haddr_t eoa; /* End of address space in the file */ - haddr_t end; /* End of section to extend */ - htri_t ret_value = FALSE; /* Return value */ + const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ + H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + haddr_t eoa; /* End of address space in the file */ + haddr_t end; /* End of section to extend */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -923,18 +897,19 @@ H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) HDassert(udata->f); /* Retrieve the end of the file's address space */ - if(HADDR_UNDEF == (eoa = H5FD_get_eoa(udata->f->shared->lf, udata->alloc_type))) + if (HADDR_UNDEF == (eoa = H5FD_get_eoa(udata->f->shared->lf, udata->alloc_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* Compute address of end of section to check */ end = sect->sect_info.addr + sect->sect_info.size; /* Check if the section is exactly at the end of the allocated space in the file */ - if(H5F_addr_eq(end, eoa) && sect->sect_info.size >= udata->f->shared->fs_page_size) { + if (H5F_addr_eq(end, eoa) && sect->sect_info.size >= udata->f->shared->fs_page_size) { /* Set the shrinking type */ udata->shrink = H5MF_SHRINK_EOA; #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, sect->sect_info.size, eoa); + HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, + sect->sect_info.size, eoa); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ @@ -945,7 +920,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_large_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_large_shrink * @@ -961,10 +935,10 @@ done: static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) { - H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - hsize_t frag_size = 0; /* Fragment size */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ + H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + hsize_t frag_size = 0; /* Fragment size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -982,14 +956,15 @@ H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) /* Free full pages from EOA */ /* Retain partial page in the free-space manager so as to keep EOA at page boundary */ - if(H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr+frag_size, (*sect)->sect_info.size-frag_size) < 0) + if (H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr + frag_size, + (*sect)->sect_info.size - frag_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") - if(frag_size) /* Adjust section size for the partial page */ + if (frag_size) /* Adjust section size for the partial page */ (*sect)->sect_info.size = frag_size; else { /* Free section */ - if(H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") /* Mark section as freed, for free space manager */ @@ -999,4 +974,3 @@ H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_large_shrink() */ - diff --git a/src/H5MM.c b/src/H5MM.c index cceac4f..a7cb196 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -22,81 +22,75 @@ *------------------------------------------------------------------------- */ - /****************/ /* Module Setup */ /****************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ #if defined H5_MEMORY_ALLOC_SANITY_CHECK -#define H5MM_SIG_SIZE 4 -#define H5MM_HEAD_GUARD_SIZE 8 -#define H5MM_TAIL_GUARD_SIZE 8 -#define H5MM_BLOCK_FROM_BUF(mem) ((H5MM_block_t *)((void *)((unsigned char *)mem - (offsetof(H5MM_block_t, b) + H5MM_HEAD_GUARD_SIZE)))) +#define H5MM_SIG_SIZE 4 +#define H5MM_HEAD_GUARD_SIZE 8 +#define H5MM_TAIL_GUARD_SIZE 8 +#define H5MM_BLOCK_FROM_BUF(mem) \ + ((H5MM_block_t *)((void *)((unsigned char *)mem - (offsetof(H5MM_block_t, b) + H5MM_HEAD_GUARD_SIZE)))) #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - /******************/ /* Local Typedefs */ /******************/ #if defined H5_MEMORY_ALLOC_SANITY_CHECK /* Memory allocation "block", wrapped around each allocation */ -struct H5MM_block_t; /* Forward declaration for typedef */ +struct H5MM_block_t; /* Forward declaration for typedef */ typedef struct H5MM_block_t { - unsigned char sig[H5MM_SIG_SIZE]; /* Signature for the block, to indicate it was allocated with H5MM* interface */ - struct H5MM_block_t *next; /* Pointer to next block in the list of allocated blocks */ - struct H5MM_block_t *prev; /* Pointer to previous block in the list of allocated blocks */ + unsigned char + sig[H5MM_SIG_SIZE]; /* Signature for the block, to indicate it was allocated with H5MM* interface */ + struct H5MM_block_t *next; /* Pointer to next block in the list of allocated blocks */ + struct H5MM_block_t *prev; /* Pointer to previous block in the list of allocated blocks */ union { struct { - size_t size; /* Size of allocated block */ - hbool_t in_use; /* Whether the block is in use or is free */ + size_t size; /* Size of allocated block */ + hbool_t in_use; /* Whether the block is in use or is free */ } info; - double _align; /* Align following buffer (b) to double boundary (unused) */ + double _align; /* Align following buffer (b) to double boundary (unused) */ } u; - unsigned char b[]; /* Buffer for caller (includes header and footer) */ + unsigned char b[]; /* Buffer for caller (includes header and footer) */ } H5MM_block_t; #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - /********************/ /* Local Prototypes */ /********************/ -#if defined H5_MEMORY_ALLOC_SANITY_CHECK +#if defined H5_MEMORY_ALLOC_SANITY_CHECK static hbool_t H5MM__is_our_block(void *mem); -static void H5MM__sanity_check_block(const H5MM_block_t *block); -static void H5MM__sanity_check(void *mem); +static void H5MM__sanity_check_block(const H5MM_block_t *block); +static void H5MM__sanity_check(void *mem); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ #if defined H5_MEMORY_ALLOC_SANITY_CHECK /* Constant strings for block signature, head & tail guards */ -static const char H5MM_block_signature_s[H5MM_SIG_SIZE] = {'H', '5', 'M', 'M'}; +static const char H5MM_block_signature_s[H5MM_SIG_SIZE] = {'H', '5', 'M', 'M'}; static const char H5MM_block_head_guard_s[H5MM_HEAD_GUARD_SIZE] = {'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F'}; static const char H5MM_block_tail_guard_s[H5MM_TAIL_GUARD_SIZE] = {'B', 'E', 'E', 'F', 'D', 'E', 'A', 'D'}; @@ -107,18 +101,17 @@ static hbool_t H5MM_init_s = FALSE; static H5MM_block_t H5MM_block_head_s; /* Statistics about block allocations */ -static unsigned long long H5MM_total_alloc_bytes_s = 0; -static size_t H5MM_curr_alloc_bytes_s = 0; -static size_t H5MM_peak_alloc_bytes_s = 0; -static size_t H5MM_max_block_size_s = 0; -static size_t H5MM_total_alloc_blocks_count_s = 0; -static size_t H5MM_curr_alloc_blocks_count_s = 0; -static size_t H5MM_peak_alloc_blocks_count_s = 0; +static unsigned long long H5MM_total_alloc_bytes_s = 0; +static size_t H5MM_curr_alloc_bytes_s = 0; +static size_t H5MM_peak_alloc_bytes_s = 0; +static size_t H5MM_max_block_size_s = 0; +static size_t H5MM_total_alloc_blocks_count_s = 0; +static size_t H5MM_curr_alloc_blocks_count_s = 0; +static size_t H5MM_peak_alloc_blocks_count_s = 0; #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - #if defined H5_MEMORY_ALLOC_SANITY_CHECK - + /*------------------------------------------------------------------------- * Function: H5MM__is_our_block * @@ -138,10 +131,9 @@ H5MM__is_our_block(void *mem) { H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); - return(0 == HDmemcmp(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE)); + return (0 == HDmemcmp(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE)); } - /*------------------------------------------------------------------------- * Function: H5MM__sanity_check_block * @@ -160,13 +152,13 @@ H5MM__sanity_check_block(const H5MM_block_t *block) HDassert(block->u.info.size > 0); HDassert(block->u.info.in_use); /* Check for head & tail guards, if not head of linked list */ - if(block->u.info.size != SIZET_MAX) { + if (block->u.info.size != SIZET_MAX) { HDassert(0 == HDmemcmp(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE)); - HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->u.info.size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); + HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->u.info.size, H5MM_block_tail_guard_s, + H5MM_TAIL_GUARD_SIZE)); } } - /*------------------------------------------------------------------------- * Function: H5MM__sanity_check * @@ -188,7 +180,6 @@ H5MM__sanity_check(void *mem) H5MM__sanity_check_block(block); } - /*------------------------------------------------------------------------- * Function: H5MM_sanity_check_all * @@ -207,13 +198,12 @@ H5MM_sanity_check_all(void) H5MM_block_t *curr = NULL; curr = H5MM_block_head_s.next; - while(curr != &H5MM_block_head_s) { + while (curr != &H5MM_block_head_s) { H5MM__sanity_check_block(curr); curr = curr->next; } /* end while */ } /* end H5MM_sanity_check_all() */ - /*------------------------------------------------------------------------- * Function: H5MM_final_sanity_check * @@ -237,13 +227,13 @@ H5MM_final_sanity_check(void) HDfprintf(stderr, "%s: H5MM_total_alloc_bytes_s = %llu\n", __func__, H5MM_total_alloc_bytes_s); HDfprintf(stderr, "%s: H5MM_peak_alloc_bytes_s = %zu\n", __func__, H5MM_peak_alloc_bytes_s); HDfprintf(stderr, "%s: H5MM_max_block_size_s = %zu\n", __func__, H5MM_max_block_size_s); - HDfprintf(stderr, "%s: H5MM_total_alloc_blocks_count_s = %zu\n", __func__, H5MM_total_alloc_blocks_count_s); + HDfprintf(stderr, "%s: H5MM_total_alloc_blocks_count_s = %zu\n", __func__, + H5MM_total_alloc_blocks_count_s); HDfprintf(stderr, "%s: H5MM_peak_alloc_blocks_count_s = %zu\n", __func__, H5MM_peak_alloc_blocks_count_s); #endif /* H5MM_PRINT_MEMORY_STATS */ } #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - /*------------------------------------------------------------------------- * Function: H5MM_malloc * @@ -273,44 +263,45 @@ H5MM_malloc(size_t size) #if defined H5_MEMORY_ALLOC_SANITY_CHECK /* Initialize block list head singleton */ - if(!H5MM_init_s) { + if (!H5MM_init_s) { H5MM_memcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); - H5MM_block_head_s.next = &H5MM_block_head_s; - H5MM_block_head_s.prev = &H5MM_block_head_s; - H5MM_block_head_s.u.info.size = SIZET_MAX; + H5MM_block_head_s.next = &H5MM_block_head_s; + H5MM_block_head_s.prev = &H5MM_block_head_s; + H5MM_block_head_s.u.info.size = SIZET_MAX; H5MM_block_head_s.u.info.in_use = TRUE; H5MM_init_s = TRUE; - } /* end if */ + } /* end if */ #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - if(size) { + if (size) { #if defined H5_MEMORY_ALLOC_SANITY_CHECK H5MM_block_t *block; - size_t alloc_size = sizeof(H5MM_block_t) + size + H5MM_HEAD_GUARD_SIZE + H5MM_TAIL_GUARD_SIZE; + size_t alloc_size = sizeof(H5MM_block_t) + size + H5MM_HEAD_GUARD_SIZE + H5MM_TAIL_GUARD_SIZE; - if(NULL != (block = (H5MM_block_t *)HDmalloc(alloc_size))) { + if (NULL != (block = (H5MM_block_t *)HDmalloc(alloc_size))) { /* Set up block */ H5MM_memcpy(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE); - block->next = H5MM_block_head_s.next; + block->next = H5MM_block_head_s.next; H5MM_block_head_s.next = block; - block->next->prev = block; - block->prev = &H5MM_block_head_s; - block->u.info.size = size; - block->u.info.in_use = TRUE; + block->next->prev = block; + block->prev = &H5MM_block_head_s; + block->u.info.size = size; + block->u.info.in_use = TRUE; H5MM_memcpy(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE); - H5MM_memcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE); + H5MM_memcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, + H5MM_TAIL_GUARD_SIZE); /* Update statistics */ H5MM_total_alloc_bytes_s += size; H5MM_curr_alloc_bytes_s += size; - if(H5MM_curr_alloc_bytes_s > H5MM_peak_alloc_bytes_s) + if (H5MM_curr_alloc_bytes_s > H5MM_peak_alloc_bytes_s) H5MM_peak_alloc_bytes_s = H5MM_curr_alloc_bytes_s; - if(size > H5MM_max_block_size_s) + if (size > H5MM_max_block_size_s) H5MM_max_block_size_s = size; H5MM_total_alloc_blocks_count_s++; H5MM_curr_alloc_blocks_count_s++; - if(H5MM_curr_alloc_blocks_count_s > H5MM_peak_alloc_blocks_count_s) + if (H5MM_curr_alloc_blocks_count_s > H5MM_peak_alloc_blocks_count_s) H5MM_peak_alloc_blocks_count_s = H5MM_curr_alloc_blocks_count_s; /* Set buffer to return */ @@ -318,17 +309,16 @@ H5MM_malloc(size_t size) } /* end if */ else ret_value = NULL; -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDmalloc(size); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - } /* end if */ + } /* end if */ else ret_value = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_malloc() */ - /*------------------------------------------------------------------------- * Function: H5MM_calloc * @@ -358,21 +348,20 @@ H5MM_calloc(size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(size) { + if (size) { #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(NULL != (ret_value = H5MM_malloc(size))) + if (NULL != (ret_value = H5MM_malloc(size))) HDmemset(ret_value, 0, size); -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDcalloc((size_t)1, size); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - } /* end if */ + } /* end if */ else ret_value = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_calloc() */ - /*------------------------------------------------------------------------- * Function: H5MM_realloc * @@ -403,16 +392,16 @@ H5MM_realloc(void *mem, size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(NULL == mem && 0 == size) + if (NULL == mem && 0 == size) /* Not defined in the standard, return NULL */ ret_value = NULL; else { #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(size > 0) { - if(mem) { - if(H5MM__is_our_block(mem)) { - H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); - size_t old_size = block->u.info.size; + if (size > 0) { + if (mem) { + if (H5MM__is_our_block(mem)) { + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + size_t old_size = block->u.info.size; H5MM__sanity_check(mem); @@ -428,19 +417,18 @@ H5MM_realloc(void *mem, size_t size) } else ret_value = H5MM_xfree(mem); -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDrealloc(mem, size); /* Some platforms do not return NULL if size is zero. */ - if(0 == size) + if (0 == size) ret_value = NULL; #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_realloc() */ - /*------------------------------------------------------------------------- * Function: H5MM_xstrdup * @@ -457,12 +445,12 @@ H5MM_realloc(void *mem, size_t size) char * H5MM_xstrdup(const char *s) { - char *ret_value = NULL; + char *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) - if(s) { - if(NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) + if (s) { + if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); } /* end if */ @@ -471,7 +459,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_xstrdup() */ - /*------------------------------------------------------------------------- * Function: H5MM_strdup * @@ -495,9 +482,9 @@ H5MM_strdup(const char *s) FUNC_ENTER_NOAPI(NULL) - if(!s) + if (!s) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "null string") - if(NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) + if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); @@ -505,7 +492,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_strdup() */ - /*------------------------------------------------------------------------- * Function: H5MM_xfree * @@ -529,9 +515,9 @@ H5MM_xfree(void *mem) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(mem) { + if (mem) { #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(H5MM__is_our_block(mem)) { + if (H5MM__is_our_block(mem)) { H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); /* Run sanity checks on this block and its neighbors */ @@ -545,10 +531,10 @@ H5MM_xfree(void *mem) /* Reset block info */ HDmemset(block->sig, 0, H5MM_SIG_SIZE); - block->next->prev = block->prev; - block->prev->next = block->next; - block->next = NULL; - block->prev = NULL; + block->next->prev = block->prev; + block->prev->next = block->next; + block->next = NULL; + block->prev = NULL; block->u.info.in_use = FALSE; /* Free the block (finally!) */ @@ -556,15 +542,14 @@ H5MM_xfree(void *mem) } else HDfree(mem); -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ HDfree(mem); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(NULL) } /* end H5MM_xfree() */ - /*------------------------------------------------------------------------- * Function: H5MM_xfree_const * @@ -589,7 +574,6 @@ H5MM_xfree_const(const void *mem) FUNC_LEAVE_NOAPI(NULL) } /* end H5MM_xfree_const() */ - /*------------------------------------------------------------------------- * Function: H5MM_memcpy * @@ -625,7 +609,6 @@ H5MM_memcpy(void *dest, const void *src, size_t n) } /* end H5MM_memcpy() */ - /*------------------------------------------------------------------------- * Function: H5MM_get_alloc_stats * @@ -651,20 +634,19 @@ H5MM_get_alloc_stats(H5_alloc_stats_t *stats) FUNC_ENTER_NOAPI_NOERR #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(stats) { - stats->total_alloc_bytes = H5MM_total_alloc_bytes_s; - stats->curr_alloc_bytes = H5MM_curr_alloc_bytes_s; - stats->peak_alloc_bytes = H5MM_peak_alloc_bytes_s; - stats->max_block_size = H5MM_max_block_size_s; + if (stats) { + stats->total_alloc_bytes = H5MM_total_alloc_bytes_s; + stats->curr_alloc_bytes = H5MM_curr_alloc_bytes_s; + stats->peak_alloc_bytes = H5MM_peak_alloc_bytes_s; + stats->max_block_size = H5MM_max_block_size_s; stats->total_alloc_blocks_count = H5MM_total_alloc_blocks_count_s; - stats->curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s; - stats->peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s; - } /* end if */ -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ - if(stats) + stats->curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s; + stats->peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s; + } /* end if */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ + if (stats) HDmemset(stats, 0, sizeof(H5_alloc_stats_t)); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5MM_get_alloc_stats() */ - +} /* end H5MM_get_alloc_stats() */ diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index 0787eb2..f58a9df 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -31,27 +31,26 @@ #if defined H5_MEMORY_ALLOC_SANITY_CHECK /*#define H5MM_PRINT_MEMORY_STATS */ -#define H5MM_free(Z) H5MM_xfree(Z) +#define H5MM_free(Z) H5MM_xfree(Z) #else /* H5_MEMORY_ALLOC_SANITY_CHECK */ -#define H5MM_free(Z) HDfree(Z) +#define H5MM_free(Z) HDfree(Z) #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* * Library prototypes... */ -H5_DLL void *H5MM_malloc(size_t size); -H5_DLL void *H5MM_calloc(size_t size); -H5_DLL void *H5MM_realloc(void *mem, size_t size); -H5_DLL char *H5MM_xstrdup(const char *s); -H5_DLL char *H5MM_strdup(const char *s); -H5_DLL void *H5MM_xfree(void *mem); -H5_DLL void *H5MM_xfree_const(const void *mem); -H5_DLL void *H5MM_memcpy(void *dest, const void *src, size_t n); +H5_DLL void * H5MM_malloc(size_t size); +H5_DLL void * H5MM_calloc(size_t size); +H5_DLL void * H5MM_realloc(void *mem, size_t size); +H5_DLL char * H5MM_xstrdup(const char *s); +H5_DLL char * H5MM_strdup(const char *s); +H5_DLL void * H5MM_xfree(void *mem); +H5_DLL void * H5MM_xfree_const(const void *mem); +H5_DLL void * H5MM_memcpy(void *dest, const void *src, size_t n); H5_DLL herr_t H5MM_get_alloc_stats(H5_alloc_stats_t *stats); -#if defined H5_MEMORY_ALLOC_SANITY_CHECK -H5_DLL void H5MM_sanity_check_all(void); -H5_DLL void H5MM_final_sanity_check(void); +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +H5_DLL void H5MM_sanity_check_all(void); +H5_DLL void H5MM_final_sanity_check(void); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ #endif /* _H5MMprivate_H */ - diff --git a/src/H5MMpublic.h b/src/H5MMpublic.h index 4e54c33..f66fafb 100644 --- a/src/H5MMpublic.h +++ b/src/H5MMpublic.h @@ -42,4 +42,3 @@ extern "C" { } #endif #endif /* _H5MMpublic_H */ - diff --git a/src/H5MP.c b/src/H5MP.c index 7947e7d..f52bb6b 100644 --- a/src/H5MP.c +++ b/src/H5MP.c @@ -27,36 +27,33 @@ *------------------------------------------------------------------------- */ -#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ +#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ /* Private headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5MPpkg.h" /* Memory Pools */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5MPpkg.h" /* Memory Pools */ /****************/ /* Local Macros */ /****************/ /* Minimum sized block */ -#define H5MP_MIN_BLOCK (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGNMENT) +#define H5MP_MIN_BLOCK (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGNMENT) /* First block in page */ -#define H5MP_PAGE_FIRST_BLOCK(p) \ +#define H5MP_PAGE_FIRST_BLOCK(p) \ (H5MP_page_blk_t *)((void *)((unsigned char *)(p) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /********************************/ /* Package Variable Definitions */ /********************************/ @@ -64,7 +61,6 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /********************/ /* Static Variables */ /********************/ @@ -72,8 +68,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Declare a free list to manage the H5MP_pool_t struct */ H5FL_DEFINE(H5MP_pool_t); - - /*------------------------------------------------------------------------- * Function: H5MP_create * @@ -90,40 +84,39 @@ H5FL_DEFINE(H5MP_pool_t); H5MP_pool_t * H5MP_create(size_t page_size, unsigned flags) { - H5MP_pool_t *mp = NULL; /* New memory pool header */ - H5MP_pool_t *ret_value = NULL; /* Return value */ + H5MP_pool_t *mp = NULL; /* New memory pool header */ + H5MP_pool_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate space for the pool header */ - if(NULL == (mp = H5FL_MALLOC(H5MP_pool_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for memory pool header") + if (NULL == (mp = H5FL_MALLOC(H5MP_pool_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for memory pool header") /* Assign information */ mp->page_size = H5MP_BLOCK_ALIGN(page_size); - mp->flags = flags; + mp->flags = flags; /* Initialize information */ mp->free_size = 0; - mp->first = NULL; - mp->max_size = mp->page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)); + mp->first = NULL; + mp->max_size = mp->page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)); /* Create factory for pool pages */ - if(NULL == (mp->page_fac = H5FL_fac_init(page_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't create page factory") + if (NULL == (mp->page_fac = H5FL_fac_init(page_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't create page factory") /* Set return value */ ret_value = mp; done: - if(NULL == ret_value && mp) - if(H5MP_close(mp) < 0) + if (NULL == ret_value && mp) + if (H5MP_close(mp) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "unable to free memory pool header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5MP_create() */ - /*------------------------------------------------------------------------- * Function: H5MP_new_page * @@ -140,9 +133,9 @@ done: static H5MP_page_t * H5MP_new_page(H5MP_pool_t *mp, size_t page_size) { - H5MP_page_t *new_page; /* New page created */ - H5MP_page_blk_t *first_blk; /* Pointer to first block in page */ - H5MP_page_t *ret_value = NULL; /* Return value */ + H5MP_page_t * new_page; /* New page created */ + H5MP_page_blk_t *first_blk; /* Pointer to first block in page */ + H5MP_page_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -151,34 +144,34 @@ H5MP_new_page(H5MP_pool_t *mp, size_t page_size) HDassert(page_size >= mp->page_size); /* Allocate page */ - if(page_size > mp->page_size) { - if(NULL == (new_page = (H5MP_page_t *)H5MM_malloc(page_size))) + if (page_size > mp->page_size) { + if (NULL == (new_page = (H5MP_page_t *)H5MM_malloc(page_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") new_page->free_size = page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)); new_page->fac_alloc = FALSE; } /* end if */ else { - if(NULL == (new_page = (H5MP_page_t *)H5FL_FAC_MALLOC(mp->page_fac))) + if (NULL == (new_page = (H5MP_page_t *)H5FL_FAC_MALLOC(mp->page_fac))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") new_page->free_size = mp->max_size; new_page->fac_alloc = TRUE; } /* end else */ #ifdef QAK -HDfprintf(stderr,"%s: Allocating new page = %p\n", FUNC, new_page); + HDfprintf(stderr, "%s: Allocating new page = %p\n", FUNC, new_page); #endif /* QAK */ /* Initialize page information */ - first_blk = H5MP_PAGE_FIRST_BLOCK(new_page); - first_blk->size = new_page->free_size; - first_blk->page = new_page; + first_blk = H5MP_PAGE_FIRST_BLOCK(new_page); + first_blk->size = new_page->free_size; + first_blk->page = new_page; first_blk->is_free = TRUE; - first_blk->prev = NULL; - first_blk->next = NULL; + first_blk->prev = NULL; + first_blk->next = NULL; /* Insert into page list */ new_page->prev = NULL; new_page->next = mp->first; - if(mp->first) + if (mp->first) mp->first->prev = new_page; mp->first = new_page; @@ -193,7 +186,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MP_new_page() */ - /*------------------------------------------------------------------------- * Function: H5MP_malloc * @@ -208,12 +200,12 @@ done: *------------------------------------------------------------------------- */ void * -H5MP_malloc (H5MP_pool_t *mp, size_t request) +H5MP_malloc(H5MP_pool_t *mp, size_t request) { - H5MP_page_t *alloc_page = NULL; /* Page to allocate space from */ - H5MP_page_blk_t *alloc_free; /* Pointer to free space in page */ - size_t needed; /* Size requested, plus block header and alignment */ - void *ret_value = NULL; /* Return value */ + H5MP_page_t * alloc_page = NULL; /* Page to allocate space from */ + H5MP_page_blk_t *alloc_free; /* Pointer to free space in page */ + size_t needed; /* Size requested, plus block header and alignment */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -224,31 +216,31 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) /* Compute actual size needed */ needed = H5MP_BLOCK_ALIGN(request) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)); #ifdef QAK -HDfprintf(stderr,"%s: sizeof(H5MP_page_blk_t) = %Zu\n", FUNC, sizeof(H5MP_page_blk_t)); -HDfprintf(stderr,"%s: request = %Zu, needed = %Zu\n", FUNC, request, needed); + HDfprintf(stderr, "%s: sizeof(H5MP_page_blk_t) = %Zu\n", FUNC, sizeof(H5MP_page_blk_t)); + HDfprintf(stderr, "%s: request = %Zu, needed = %Zu\n", FUNC, request, needed); #endif /* QAK */ /* See if the request can be handled by existing free space */ - if(needed <= mp->free_size) { - size_t pool_free_avail; /* Amount of free space possibly available in pool */ + if (needed <= mp->free_size) { + size_t pool_free_avail; /* Amount of free space possibly available in pool */ /* Locate page with enough free space */ - alloc_page = mp->first; + alloc_page = mp->first; pool_free_avail = mp->free_size; - while(alloc_page && pool_free_avail >= needed) { + while (alloc_page && pool_free_avail >= needed) { /* If we found a page with enough free space, search for large * enough free block on that page */ - if(alloc_page->free_size >= needed) { - size_t page_free_avail; /* Amount of free space possibly available */ + if (alloc_page->free_size >= needed) { + size_t page_free_avail; /* Amount of free space possibly available */ /* Locate large enough block */ - alloc_free = alloc_page->free_blk; + alloc_free = alloc_page->free_blk; page_free_avail = alloc_page->free_size; - while(alloc_free && page_free_avail >= needed) { - if(alloc_free->is_free) { + while (alloc_free && page_free_avail >= needed) { + if (alloc_free->is_free) { /* If we found a large enough block, leave now */ - if(alloc_free->size >= needed) - goto found; /* Needed to escape double "while" loop */ + if (alloc_free->size >= needed) + goto found; /* Needed to escape double "while" loop */ /* Decrement amount of potential space left */ page_free_avail -= alloc_free->size; @@ -257,7 +249,7 @@ HDfprintf(stderr,"%s: request = %Zu, needed = %Zu\n", FUNC, request, needed); /* Go to next block */ alloc_free = alloc_free->next; } /* end while */ - } /* end if */ + } /* end if */ /* Decrement amount of potential space left */ pool_free_avail -= alloc_page->free_size; @@ -265,17 +257,17 @@ HDfprintf(stderr,"%s: request = %Zu, needed = %Zu\n", FUNC, request, needed); /* Go to next page */ alloc_page = alloc_page->next; } /* end while */ - } /* end if */ + } /* end if */ { - size_t page_size; /* Size of page needed */ + size_t page_size; /* Size of page needed */ /* Check if the request is too large for a standard page */ - page_size = (needed > mp->max_size) ? - (needed + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) : mp->page_size; + page_size = + (needed > mp->max_size) ? (needed + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) : mp->page_size; /* Allocate new page */ - if(NULL == (alloc_page = H5MP_new_page(mp, page_size))) + if (NULL == (alloc_page = H5MP_new_page(mp, page_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") /* Set the block to allocate from */ @@ -290,24 +282,24 @@ found: HDassert(alloc_free); /* Check if we can subdivide the free space */ - if(alloc_free->size > (needed + H5MP_MIN_BLOCK)) { - H5MP_page_blk_t *new_free; /* New free block created */ + if (alloc_free->size > (needed + H5MP_MIN_BLOCK)) { + H5MP_page_blk_t *new_free; /* New free block created */ /* Carve out new free block after block to allocate */ new_free = (H5MP_page_blk_t *)((void *)(((unsigned char *)alloc_free) + needed)); /* Link into existing lists */ new_free->next = alloc_free->next; - if(alloc_free->next) + if (alloc_free->next) alloc_free->next->prev = new_free; - new_free->prev = alloc_free; + new_free->prev = alloc_free; alloc_free->next = new_free; /* Set blocks' information */ - new_free->size = alloc_free->size - needed; - new_free->is_free = TRUE; - new_free->page = alloc_free->page; - alloc_free->size = needed; + new_free->size = alloc_free->size - needed; + new_free->is_free = TRUE; + new_free->page = alloc_free->page; + alloc_free->size = needed; alloc_free->is_free = FALSE; } /* end if */ else { @@ -317,21 +309,20 @@ found: /* Update page & pool's free size information */ alloc_page->free_size -= alloc_free->size; - if(alloc_page->free_blk == alloc_free) + if (alloc_page->free_blk == alloc_free) alloc_page->free_blk = alloc_free->next; mp->free_size -= alloc_free->size; /* Set new space pointer for the return value */ ret_value = ((unsigned char *)alloc_free) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)); #ifdef QAK -HDfprintf(stderr,"%s: Allocating space from page, ret_value = %p\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Allocating space from page, ret_value = %p\n", FUNC, ret_value); #endif /* QAK */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MP_malloc() */ - /*------------------------------------------------------------------------- * Function: H5MP_free * @@ -350,9 +341,9 @@ done: void * H5MP_free(H5MP_pool_t *mp, void *spc) { - H5MP_page_blk_t *spc_blk; /* Block for space to free */ - H5MP_page_t *spc_page; /* Page containing block to free */ - void *ret_value = NULL; /* Return value */ + H5MP_page_blk_t *spc_blk; /* Block for space to free */ + H5MP_page_t * spc_page; /* Page containing block to free */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -361,7 +352,8 @@ H5MP_free(H5MP_pool_t *mp, void *spc) HDassert(spc); /* Get block header for space to free */ - spc_blk = (H5MP_page_blk_t *)((void *)(((unsigned char *)spc) - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))); + spc_blk = + (H5MP_page_blk_t *)((void *)(((unsigned char *)spc) - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))); /* Mark block as free */ HDassert(spc_blk->is_free == FALSE); @@ -370,57 +362,56 @@ H5MP_free(H5MP_pool_t *mp, void *spc) /* Add it's space to the amount of free space in the page & pool */ spc_page = spc_blk->page; #ifdef QAK -HDfprintf(stderr,"%s: Freeing from page = %p\n", "H5MP_free", spc_page); + HDfprintf(stderr, "%s: Freeing from page = %p\n", "H5MP_free", spc_page); #endif /* QAK */ spc_page->free_size += spc_blk->size; mp->free_size += spc_blk->size; /* Move page with newly freed space to front of list of pages in pool */ - if(spc_page != mp->first) { + if (spc_page != mp->first) { /* Remove page from list */ spc_page->prev->next = spc_page->next; - if(spc_page->next) + if (spc_page->next) spc_page->next->prev = spc_page->prev; /* Insert page at beginning of list */ - spc_page->prev = NULL; - spc_page->next = mp->first; + spc_page->prev = NULL; + spc_page->next = mp->first; mp->first->prev = spc_page; - mp->first = spc_page; + mp->first = spc_page; } /* end if */ /* Check if block can be merged with free space after it on page */ - if(spc_blk->next != NULL) { - H5MP_page_blk_t *next_blk; /* Block following space to free */ + if (spc_blk->next != NULL) { + H5MP_page_blk_t *next_blk; /* Block following space to free */ next_blk = spc_blk->next; HDassert(next_blk->prev == spc_blk); - if(next_blk->is_free) { + if (next_blk->is_free) { spc_blk->size += next_blk->size; spc_blk->next = next_blk->next; } /* end if */ - } /* end if */ + } /* end if */ /* Check if block can be merged with free space before it on page */ - if(spc_blk->prev != NULL) { - H5MP_page_blk_t *prev_blk; /* Block before space to free */ + if (spc_blk->prev != NULL) { + H5MP_page_blk_t *prev_blk; /* Block before space to free */ prev_blk = spc_blk->prev; HDassert(prev_blk->next == spc_blk); - if(prev_blk->is_free) { + if (prev_blk->is_free) { prev_blk->size += spc_blk->size; prev_blk->next = spc_blk->next; } /* end if */ - } /* end if */ + } /* end if */ /* Check if the block freed becomes the first free block on the page */ - if(spc_page->free_blk == NULL || spc_blk < spc_page->free_blk) + if (spc_page->free_blk == NULL || spc_blk < spc_page->free_blk) spc_page->free_blk = spc_blk; FUNC_LEAVE_NOAPI(ret_value) } /* end H5MP_free() */ - /*------------------------------------------------------------------------- * Function: H5MP_close * @@ -437,32 +428,32 @@ HDfprintf(stderr,"%s: Freeing from page = %p\n", "H5MP_free", spc_page); herr_t H5MP_close(H5MP_pool_t *mp) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Release memory for pool pages */ - if(mp->first != NULL) { - H5MP_page_t *page, *next_page; /* Pointer to pages in pool */ + if (mp->first != NULL) { + H5MP_page_t *page, *next_page; /* Pointer to pages in pool */ /* Iterate through pages, releasing them */ page = mp->first; - while(page) { + while (page) { next_page = page->next; /* Free the page appropriately */ - if(page->fac_alloc) + if (page->fac_alloc) page = (H5MP_page_t *)H5FL_FAC_FREE(mp->page_fac, page); else page = (H5MP_page_t *)H5MM_xfree(page); page = next_page; } /* end while */ - } /* end if */ + } /* end if */ /* Release page factory */ - if(mp->page_fac) - if(H5FL_fac_term(mp->page_fac) < 0) + if (mp->page_fac) + if (H5FL_fac_term(mp->page_fac) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy page factory") done: @@ -471,4 +462,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MP_close() */ - diff --git a/src/H5MPmodule.h b/src/H5MPmodule.h index 27f7706..70e457a 100644 --- a/src/H5MPmodule.h +++ b/src/H5MPmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5MP_MODULE -#define H5_MY_PKG H5MP -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5MP +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO #endif /* _H5MPmodule_H */ - diff --git a/src/H5MPpkg.h b/src/H5MPpkg.h index 29a25fa..4011f46 100644 --- a/src/H5MPpkg.h +++ b/src/H5MPpkg.h @@ -27,10 +27,10 @@ #define _H5MPpkg_H /* Get package's private header */ -#include "H5MPprivate.h" /* Memory Pools */ +#include "H5MPprivate.h" /* Memory Pools */ /* Other private headers needed by this file */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ @@ -40,60 +40,56 @@ /* (Ideas from Apache APR :-) */ /* Default alignment necessary */ -#define H5MP_BLOCK_ALIGNMENT 8 +#define H5MP_BLOCK_ALIGNMENT 8 /* General alignment macro */ /* (this only works for aligning to power of 2 boundary) */ -#define H5MP_ALIGN(x, a) \ - (((x) + ((size_t)(a)) - 1) & ~(((size_t)(a)) - 1)) +#define H5MP_ALIGN(x, a) (((x) + ((size_t)(a)) - 1) & ~(((size_t)(a)) - 1)) /* Default alignment */ #define H5MP_BLOCK_ALIGN(x) H5MP_ALIGN(x, H5MP_BLOCK_ALIGNMENT) - /****************************/ /* Package Private Typedefs */ /****************************/ /* Free block in pool */ typedef struct H5MP_page_blk_t { - size_t size; /* Size of block (includes this H5MP_page_blk_t info) */ - unsigned is_free:1; /* Flag to indicate the block is free */ - struct H5MP_page_t *page; /* Pointer to page block is located in */ - struct H5MP_page_blk_t *prev; /* Pointer to previous block in page */ - struct H5MP_page_blk_t *next; /* Pointer to next block in page */ + size_t size; /* Size of block (includes this H5MP_page_blk_t info) */ + unsigned is_free : 1; /* Flag to indicate the block is free */ + struct H5MP_page_t * page; /* Pointer to page block is located in */ + struct H5MP_page_blk_t *prev; /* Pointer to previous block in page */ + struct H5MP_page_blk_t *next; /* Pointer to next block in page */ } H5MP_page_blk_t; /* Memory pool page */ typedef struct H5MP_page_t { - size_t free_size; /* Total amount of free space in page */ - unsigned fac_alloc:1; /* Flag to indicate the page was allocated by the pool's factory */ - H5MP_page_blk_t *free_blk; /* Pointer to first free block in page */ - struct H5MP_page_t *next; /* Pointer to next page in pool */ - struct H5MP_page_t *prev; /* Pointer to previous page in pool */ + size_t free_size; /* Total amount of free space in page */ + unsigned fac_alloc : 1; /* Flag to indicate the page was allocated by the pool's factory */ + H5MP_page_blk_t * free_blk; /* Pointer to first free block in page */ + struct H5MP_page_t *next; /* Pointer to next page in pool */ + struct H5MP_page_t *prev; /* Pointer to previous page in pool */ } H5MP_page_t; /* Memory pool header */ struct H5MP_pool_t { H5FL_fac_head_t *page_fac; /* Free-list factory for pages */ - size_t page_size; /* Page size for pool */ - size_t free_size; /* Total amount of free space in pool */ - size_t max_size; /* Maximum block that will fit in a standard page */ - H5MP_page_t *first; /* Pointer to first page in pool */ - unsigned flags; /* Bit flags for pool settings */ + size_t page_size; /* Page size for pool */ + size_t free_size; /* Total amount of free space in pool */ + size_t max_size; /* Maximum block that will fit in a standard page */ + H5MP_page_t * first; /* Pointer to first page in pool */ + unsigned flags; /* Bit flags for pool settings */ }; - /*****************************************/ /* Package Private Variable Declarations */ /*****************************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ #ifdef H5MP_TESTING -H5_DLL herr_t H5MP_get_pool_free_size (const H5MP_pool_t *mp, size_t *free_size); +H5_DLL herr_t H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size); H5_DLL htri_t H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp); H5_DLL herr_t H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page); H5_DLL herr_t H5MP_get_page_free_size(const H5MP_page_t *mp, size_t *page); @@ -101,4 +97,3 @@ H5_DLL herr_t H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **nex #endif /* H5MP_TESTING */ #endif /* _H5MPpkg_H */ - diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h index 009cb50..22e36cc 100644 --- a/src/H5MPprivate.h +++ b/src/H5MPprivate.h @@ -30,16 +30,14 @@ /* Private headers needed by this file */ - /**************************/ /* Library Private Macros */ /**************************/ /* Pool creation flags */ /* Default settings */ -#define H5MP_FLG_DEFAULT 0 -#define H5MP_PAGE_SIZE_DEFAULT 4096 /* (bytes) */ - +#define H5MP_FLG_DEFAULT 0 +#define H5MP_PAGE_SIZE_DEFAULT 4096 /* (bytes) */ /****************************/ /* Library Private Typedefs */ @@ -48,13 +46,12 @@ /* Memory pool header (defined in H5MPpkg.c) */ typedef struct H5MP_pool_t H5MP_pool_t; - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL H5MP_pool_t *H5MP_create (size_t page_size, unsigned flags); -H5_DLL void * H5MP_malloc (H5MP_pool_t *mp, size_t request); -H5_DLL void * H5MP_free (H5MP_pool_t *mp, void *spc); -H5_DLL herr_t H5MP_close (H5MP_pool_t *mp); +H5_DLL H5MP_pool_t *H5MP_create(size_t page_size, unsigned flags); +H5_DLL void * H5MP_malloc(H5MP_pool_t *mp, size_t request); +H5_DLL void * H5MP_free(H5MP_pool_t *mp, void *spc); +H5_DLL herr_t H5MP_close(H5MP_pool_t *mp); #endif /* _H5MPprivate_H */ diff --git a/src/H5MPtest.c b/src/H5MPtest.c index 0cba847..9fb7c5f 100644 --- a/src/H5MPtest.c +++ b/src/H5MPtest.c @@ -17,19 +17,18 @@ * Purpose: Memory pool testing functions. */ -#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ -#define H5MP_TESTING /*include H5MP testing funcs*/ +#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ +#define H5MP_TESTING /*include H5MP testing funcs*/ /* Private headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5MPpkg.h" /* Memory Pools */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5MPpkg.h" /* Memory Pools */ +#include "H5Eprivate.h" /* Error handling */ /* Static Prototypes */ /* Package variables */ - /*------------------------------------------------------------------------- * Function: H5MP_get_pool_free_size * @@ -61,7 +60,6 @@ H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MP_get_pool_free_size() */ - /*------------------------------------------------------------------------- * Function: H5MP_get_pool_first_page * @@ -93,7 +91,6 @@ H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MP_get_pool_first_page() */ - /*------------------------------------------------------------------------- * Function: H5MP_pool_is_free_size_correct * @@ -116,9 +113,9 @@ H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page) htri_t H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) { - H5MP_page_t *page; /* Pointer to current page */ - size_t pool_free; /* Size of pages' free space */ - htri_t ret_value = TRUE; /* Return value */ + H5MP_page_t *page; /* Pointer to current page */ + size_t pool_free; /* Size of pages' free space */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -127,17 +124,17 @@ H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) /* Iterate through pages, checking the free size & accumulating the * free space for all the pages */ - page = mp->first; + page = mp->first; pool_free = 0; - while(page != NULL) { - H5MP_page_blk_t *blk; /* Pointer to current free block */ - size_t page_free; /* Size of blocks on free list */ + while (page != NULL) { + H5MP_page_blk_t *blk; /* Pointer to current free block */ + size_t page_free; /* Size of blocks on free list */ /* Iterate through the blocks in page, accumulating free space */ blk = (H5MP_page_blk_t *)((void *)((unsigned char *)page + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))); page_free = 0; - while(blk != NULL) { - if(blk->is_free) + while (blk != NULL) { + if (blk->is_free) page_free += blk->size; blk = blk->next; } /* end while */ @@ -145,10 +142,11 @@ H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) /* Check that the free space from the blocks on the free list * corresponds to space in page */ #ifdef QAK -HDfprintf(stderr,"%s: page_free = %Zu, page->free_size = %Zu\n", "H5MP_pool_is_free_size_correct", page_free, page->free_size); + HDfprintf(stderr, "%s: page_free = %Zu, page->free_size = %Zu\n", "H5MP_pool_is_free_size_correct", + page_free, page->free_size); #endif /* QAK */ - if(page_free != page->free_size) - HGOTO_DONE (FALSE) + if (page_free != page->free_size) + HGOTO_DONE(FALSE) /* Increment the amount of free space in pool */ pool_free += page->free_size; @@ -160,16 +158,16 @@ HDfprintf(stderr,"%s: page_free = %Zu, page->free_size = %Zu\n", "H5MP_pool_is_f /* Check that the free space from the pages * corresponds to free space in pool */ #ifdef QAK -HDfprintf(stderr,"%s: pool_free = %Zu, mp->free_size = %Zu\n", "H5MP_pool_is_free_size_correct", pool_free, mp->free_size); + HDfprintf(stderr, "%s: pool_free = %Zu, mp->free_size = %Zu\n", "H5MP_pool_is_free_size_correct", + pool_free, mp->free_size); #endif /* QAK */ - if(pool_free != mp->free_size) - HGOTO_DONE (FALSE) + if (pool_free != mp->free_size) + HGOTO_DONE(FALSE) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MP_pool_is_free_size_correct() */ - /*------------------------------------------------------------------------- * Function: H5MP_get_page_free_size * @@ -201,7 +199,6 @@ H5MP_get_page_free_size(const H5MP_page_t *page, size_t *free_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MP_get_page_free_size() */ - /*------------------------------------------------------------------------- * Function: H5MP_get_page_next_page * @@ -232,4 +229,3 @@ H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **next_page) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MP_get_page_next_page() */ - diff --git a/src/H5MV.c b/src/H5MV.c index 66d60b4..2541176 100644 --- a/src/H5MV.c +++ b/src/H5MV.c @@ -24,22 +24,20 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#define H5FS_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MVmodule.h" /* This source code file is part of the H5MV module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5FS_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MVmodule.h" /* This source code file is part of the H5MV module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FSpkg.h" /* File free space */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MVpkg.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FSpkg.h" /* File free space */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MVpkg.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ @@ -48,8 +46,8 @@ /* Define this to display debugging information for VFD SWMR */ /* #define H5MV_VFD_SWMR_DEBUG */ -#define H5MV_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ -#define H5MV_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ +#define H5MV_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ +#define H5MV_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ /******************/ /* Local Typedefs */ @@ -57,17 +55,15 @@ /* User data for section info iterator callback for iterating over free space sections */ typedef struct { - H5F_sect_info_t *sects; /* section info to be retrieved */ - size_t sect_count; /* # of sections requested */ - size_t sect_idx; /* the current count of sections */ + H5F_sect_info_t *sects; /* section info to be retrieved */ + size_t sect_count; /* # of sections requested */ + size_t sect_idx; /* the current count of sections */ } H5MV_sect_iter_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -76,7 +72,7 @@ static haddr_t H5MV__extend_md(H5F_shared_t *, hsize_t); /* Space allocation routines */ H5_DLL haddr_t H5MV__alloc_md(H5F_shared_t *, hsize_t); -H5_DLL htri_t H5MV__try_extend_md(H5F_shared_t *, haddr_t, hsize_t); +H5_DLL htri_t H5MV__try_extend_md(H5F_shared_t *, haddr_t, hsize_t); /*********************/ /* Package Variables */ @@ -85,17 +81,14 @@ H5_DLL htri_t H5MV__try_extend_md(H5F_shared_t *, haddr_t, hsize_t); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5MV__create() * @@ -112,9 +105,9 @@ H5MV__create(H5F_t *f) { H5F_shared_t *shared = f->shared; /* Free space section classes implemented for file */ - const H5FS_section_class_t *classes[] = { H5MV_FSPACE_SECT_CLS_SIMPLE }; - H5FS_create_t fs_create; /* Free space creation parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *classes[] = {H5MV_FSPACE_SECT_CLS_SIMPLE}; + H5FS_create_t fs_create; /* Free space creation parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -124,24 +117,24 @@ H5MV__create(H5F_t *f) HDassert(shared->fs_state_md == H5F_FS_STATE_CLOSED); /* Set the free space creation parameters */ - fs_create.client = H5FS_CLIENT_MD_VFD_ID; + fs_create.client = H5FS_CLIENT_MD_VFD_ID; fs_create.shrink_percent = H5MV_FSPACE_SHRINK; fs_create.expand_percent = H5MV_FSPACE_EXPAND; - fs_create.max_sect_addr = 1 + H5VM_log2_gen((uint64_t)shared->maxaddr); - fs_create.max_sect_size = shared->maxaddr; + fs_create.max_sect_addr = 1 + H5VM_log2_gen((uint64_t)shared->maxaddr); + fs_create.max_sect_size = shared->maxaddr; - if(NULL == (shared->fs_man_md = H5FS_create(f, NULL, &fs_create, NELMTS(classes), classes, f, shared->fs_page_size, shared->fs_page_size))) + if (NULL == (shared->fs_man_md = H5FS_create(f, NULL, &fs_create, NELMTS(classes), classes, f, + shared->fs_page_size, shared->fs_page_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space info") /* Set the state for the free space manager to "open", if it is now */ - if(shared->fs_man_md) + if (shared->fs_man_md) shared->fs_state_md = H5F_FS_STATE_OPEN; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV__create() */ - /*------------------------------------------------------------------------- * Function: H5MV_close * @@ -155,8 +148,8 @@ done: herr_t H5MV_close(H5F_t *f) { - H5F_shared_t *shared = f->shared; - herr_t ret_value = SUCCEED; /* Return value */ + H5F_shared_t *shared = f->shared; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -165,33 +158,31 @@ H5MV_close(H5F_t *f) */ HDassert(shared); #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: Trying to close free space manager\n", FUNC); + HDfprintf(stderr, "%s: Trying to close free space manager\n", FUNC); #endif /* Close an existing free space structure for the file */ - if(shared->fs_man_md) { + if (shared->fs_man_md) { #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: Going to close free space manager\n", FUNC); + HDfprintf(stderr, "%s: Going to close free space manager\n", FUNC); #endif HDassert(shared->fs_state_md != H5F_FS_STATE_CLOSED); - if(H5FS_close(f, shared->fs_man_md) < 0) + if (H5FS_close(f, shared->fs_man_md) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free space info") } - shared->fs_man_md = NULL; + shared->fs_man_md = NULL; shared->fs_state_md = H5F_FS_STATE_CLOSED; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV_close() */ - - /*------------------------------------------------------------------------- * Function: H5MV__find_sect * - * Purpose: To find a section from the specified free-space manager + * Purpose: To find a section from the specified free-space manager * to fulfill the request. * If found, re-add the left-over space back to the manager. * @@ -203,8 +194,8 @@ done: htri_t H5MV__find_sect(H5F_t *f, hsize_t size, H5FS_t *fspace, haddr_t *addr) { - H5MV_free_section_t *node; /* Free space section pointer */ - htri_t ret_value = FAIL; /* Whether an existing free list node was found */ + H5MV_free_section_t *node; /* Free space section pointer */ + htri_t ret_value = FAIL; /* Whether an existing free list node was found */ FUNC_ENTER_PACKAGE @@ -212,30 +203,30 @@ H5MV__find_sect(H5F_t *f, hsize_t size, H5FS_t *fspace, haddr_t *addr) HDassert(fspace); /* Try to get a section from the free space manager */ - if((ret_value = H5FS_sect_find(f, fspace, size, (H5FS_section_info_t **)&node)) < 0) + if ((ret_value = H5FS_sect_find(f, fspace, size, (H5FS_section_info_t **)&node)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "error locating free space in file") #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: section found = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: section found = %t\n", FUNC, ret_value); #endif /* Check for actually finding section */ - if(ret_value) { + if (ret_value) { /* Sanity check */ HDassert(node); /* Retrieve return value */ - if(addr) + if (addr) *addr = node->sect_info.addr; /* Check for eliminating the section */ - if(node->sect_info.size == size) { + if (node->sect_info.size == size) { #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: freeing node\n", FUNC); + HDfprintf(stderr, "%s: freeing node\n", FUNC); #endif /* Free section node */ - if(H5MV__sect_free(&node->sect_info) < 0) + if (H5MV__sect_free(&node->sect_info) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") } /* end if */ else { @@ -244,20 +235,20 @@ HDfprintf(stderr, "%s: freeing node\n", FUNC); node->sect_info.size -= size; #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: adding node, node->sect_info.addr = %a, node->sect_info.size = %Hu\n", FUNC, node->sect_info.addr, node->sect_info.size); + HDfprintf(stderr, "%s: adding node, node->sect_info.addr = %a, node->sect_info.size = %Hu\n", + FUNC, node->sect_info.addr, node->sect_info.size); #endif /* Re-add the section to the free-space manager */ - if(H5FS_sect_add(f, fspace, &node->sect_info, H5FS_ADD_RETURNED_SPACE, f) < 0) + if (H5FS_sect_add(f, fspace, &node->sect_info, H5FS_ADD_RETURNED_SPACE, f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV__find_sect() */ - /*------------------------------------------------------------------------- * Function: H5MV_alloc * @@ -272,12 +263,12 @@ done: haddr_t H5MV_alloc(H5F_t *f, hsize_t size) { - H5F_shared_t *shared = f->shared; - haddr_t eoa; /* EOA for the file */ - hsize_t frag_size = 0; /* Fragment size */ - hsize_t misalign_size = 0; /* Mis-aligned size */ - H5MV_free_section_t *node = NULL; /* Free space section pointer */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5F_shared_t * shared = f->shared; + haddr_t eoa; /* EOA for the file */ + hsize_t frag_size = 0; /* Fragment size */ + hsize_t misalign_size = 0; /* Mis-aligned size */ + H5MV_free_section_t *node = NULL; /* Free space section pointer */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -286,42 +277,45 @@ H5MV_alloc(H5F_t *f, hsize_t size) HDassert(size > 0); /* Search for large enough space in the free space manager */ - if(shared->fs_man_md != NULL) { - if(H5MV__find_sect(f, size, shared->fs_man_md, &ret_value) < 0) + if (shared->fs_man_md != NULL) { + if (H5MV__find_sect(f, size, shared->fs_man_md, &ret_value) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "error locating a node") } /* If no space is found from the free-space manager or no free-space manager, extend md's EOF */ - if(!H5F_addr_defined(ret_value)) { + if (!H5F_addr_defined(ret_value)) { /* Get the EOA for the metadata file */ - if(HADDR_UNDEF == (eoa = H5MV_get_vfd_swmr_md_eoa(shared))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa for VFD SWMR metadata file") + if (HADDR_UNDEF == (eoa = H5MV_get_vfd_swmr_md_eoa(shared))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, + "Unable to get eoa for VFD SWMR metadata file") /* If EOA is mis-aligned, calculate the fragment size */ - if(H5F_addr_gt(eoa, 0) && (misalign_size = eoa % shared->fs_page_size)) + if (H5F_addr_gt(eoa, 0) && (misalign_size = eoa % shared->fs_page_size)) frag_size = shared->fs_page_size - misalign_size; /* Allocate from end of file */ - if(HADDR_UNDEF == (ret_value = H5MV__alloc_md(shared, size + frag_size))) + if (HADDR_UNDEF == (ret_value = H5MV__alloc_md(shared, size + frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed") /* If there is a mis-aligned fragment at EOA */ - if(frag_size) { + if (frag_size) { /* Start up the free-space manager if not so */ - if(shared->fs_man_md == NULL) { - if(H5MV__create(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space manager") + if (shared->fs_man_md == NULL) { + if (H5MV__create(f) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, + "can't initialize free space manager") } HDassert(shared->fs_man_md); /* Create the free-space section for the fragment */ - if(NULL == (node = H5MV__sect_new(eoa, frag_size))) + if (NULL == (node = H5MV__sect_new(eoa, frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") /* Add the section */ - if(H5FS_sect_add(f, shared->fs_man_md, &node->sect_info, H5FS_ADD_RETURNED_SPACE, f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't re-add section to file free space") + if (H5FS_sect_add(f, shared->fs_man_md, &node->sect_info, H5FS_ADD_RETURNED_SPACE, f) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, + "can't re-add section to file free space") node = NULL; } @@ -335,8 +329,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV_alloc() */ - - /*------------------------------------------------------------------------- * Function: H5MV_free * @@ -350,69 +342,67 @@ done: herr_t H5MV_free(H5F_t *f, haddr_t addr, hsize_t size) { - H5F_shared_t *shared = f->shared; - H5MV_free_section_t *node = NULL; /* Free space section pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_shared_t * shared = f->shared; + H5MV_free_section_t *node = NULL; /* Free space section pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); - if(!H5F_addr_defined(addr) || 0 == size) + if (!H5F_addr_defined(addr) || 0 == size) HGOTO_DONE(SUCCEED) HDassert(addr != 0); - /* Check if the free space manager for the file has been initialized */ - if(shared->fs_man_md == NULL) { + if (shared->fs_man_md == NULL) { /* If there's no free space manager for objects of this type, * see if we can avoid creating one by checking if the freed * space is at the end of the file */ - htri_t status; /* "can absorb" status for section into */ + htri_t status; /* "can absorb" status for section into */ - /* Try to shrink the file */ - if((status = H5MV_try_shrink(f, addr, size)) < 0) + /* Try to shrink the file */ + if ((status = H5MV_try_shrink(f, addr, size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check for absorbing block") - else if(status > 0) + else if (status > 0) HGOTO_DONE(SUCCEED) /* If we are deleting the free space manager, leave now, to avoid * [re-]starting it: dropping free space section on the floor. */ - if(shared->fs_state_md == H5F_FS_STATE_DELETING) + if (shared->fs_state_md == H5F_FS_STATE_DELETING) HGOTO_DONE(SUCCEED) /* There's either already a free space manager, or the freed * space isn't at the end of the file, so start up (or create) * the file space manager */ - if(H5MV__create(f) < 0) + if (H5MV__create(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space manager") } /* Create the free-space section for the freed section */ - if(NULL == (node = H5MV__sect_new(addr, size))) + if (NULL == (node = H5MV__sect_new(addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") HDassert(shared->fs_man_md); - /* Add the section */ - if(H5FS_sect_add(f, shared->fs_man_md, &node->sect_info, H5FS_ADD_RETURNED_SPACE, f) < 0) + /* Add the section */ + if (H5FS_sect_add(f, shared->fs_man_md, &node->sect_info, H5FS_ADD_RETURNED_SPACE, f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") node = NULL; done: /* Release section node, if allocated and not added to section list or merged */ - if(node) - if(H5MV__sect_free(&node->sect_info) < 0) + if (node) + if (H5MV__sect_free(&node->sect_info) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV_free() */ - /*------------------------------------------------------------------------- * Function: H5MV_try_extend * @@ -428,12 +418,13 @@ htri_t H5MV_try_extend(H5F_t *f, haddr_t addr, hsize_t size, hsize_t extra_requested) { H5F_shared_t *shared = f->shared; - haddr_t end; /* End of block to extend */ - htri_t ret_value = FALSE; /* Return value */ + haddr_t end; /* End of block to extend */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: Entering: addr = %a, size = %Hu, extra_requested = %Hu\n", FUNC, addr, size, extra_requested); + HDfprintf(stderr, "%s: Entering: addr = %a, size = %Hu, extra_requested = %Hu\n", FUNC, addr, size, + extra_requested); #endif /* Sanity check */ @@ -444,21 +435,22 @@ HDfprintf(stderr, "%s: Entering: addr = %a, size = %Hu, extra_requested = %Hu\n" end = addr + size; /* Try extending the block at EOA */ - if((ret_value = H5MV__try_extend_md(shared, end, extra_requested)) < 0) + if ((ret_value = H5MV__try_extend_md(shared, end, extra_requested)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: extended = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: extended = %t\n", FUNC, ret_value); #endif /* If no extension so far, try to extend into a free-space section */ - if(ret_value == FALSE) { + if (ret_value == FALSE) { /* Try to extend the block into a free-space section */ - if(shared->fs_man_md) { - if((ret_value = H5FS_sect_try_extend(f, shared->fs_man_md, addr, size, extra_requested, H5FS_ADD_RETURNED_SPACE, NULL)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending block in free space manager") + if (shared->fs_man_md) { + if ((ret_value = H5FS_sect_try_extend(f, shared->fs_man_md, addr, size, extra_requested, + H5FS_ADD_RETURNED_SPACE, NULL)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending block in free space manager") #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: Try to H5FS_sect_try_extend = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Try to H5FS_sect_try_extend = %t\n", FUNC, ret_value); #endif } /* end if */ @@ -466,17 +458,16 @@ HDfprintf(stderr, "%s: Try to H5FS_sect_try_extend = %t\n", FUNC, ret_value); done: #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV_try_extend() */ - /*------------------------------------------------------------------------- * Function: H5MV_try_shrink * - * Purpose: Try to shrink the size of a file with a block + * Purpose: Try to shrink the size of a file with a block * * Return: Non-negative on success/Negative on failure * @@ -485,13 +476,13 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); htri_t H5MV_try_shrink(H5F_t *f, haddr_t addr, hsize_t size) { - H5F_shared_t *shared = f->shared; - H5MV_free_section_t *node = NULL; /* Free space section pointer */ - htri_t ret_value = FALSE; /* Return value */ + H5F_shared_t * shared = f->shared; + H5MV_free_section_t *node = NULL; /* Free space section pointer */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: Entering - addr = %a, size = %Hu\n", FUNC, addr, size); + HDfprintf(stderr, "%s: Entering - addr = %a, size = %Hu\n", FUNC, addr, size); #endif /* check arguments */ @@ -500,29 +491,29 @@ HDfprintf(stderr, "%s: Entering - addr = %a, size = %Hu\n", FUNC, addr, size); HDassert(size > 0); /* Create free-space section for block */ - if(NULL == (node = H5MV__sect_new(addr, size))) + if (NULL == (node = H5MV__sect_new(addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* Check if the block can shrink the container */ - if((ret_value = H5MV__sect_can_shrink(&node->sect_info, f)) < 0) + if ((ret_value = H5MV__sect_can_shrink(&node->sect_info, f)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check if section can shrink container") - else if(ret_value > 0) { + else if (ret_value > 0) { /* Shrink or absorb the section */ - if(H5MV__sect_shrink((H5FS_section_info_t **)&node, f) < 0) + if (H5MV__sect_shrink((H5FS_section_info_t **)&node, f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink container") } /* end if */ done: /* Free section node allocated */ - if(node && H5MV__sect_free(&node->sect_info) < 0) + if (node && H5MV__sect_free(&node->sect_info) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV_try_shrink() */ - + /*------------------------------------------------------------------------- * Function: H5MV__free_md * @@ -536,7 +527,7 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); herr_t H5MV__free_md(H5F_shared_t *shared, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -544,23 +535,23 @@ H5MV__free_md(H5F_shared_t *shared, haddr_t addr, hsize_t size) HDassert(shared); HDassert(size > 0); - /* Sanity checking */ - if(!H5F_addr_defined(addr)) + /* Sanity checking */ + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "invalid file offset") /* XXX what's maxaddr used here for? */ - if(addr > shared->maxaddr || H5F_addr_overflow(addr, size) || (addr + size) > shared->maxaddr) + if (addr > shared->maxaddr || H5F_addr_overflow(addr, size) || (addr + size) > shared->maxaddr) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "invalid file free space region to free") /* Check if this free block is at the end of file allocated space. * Truncate it if this is true. */ - if(shared->vfd_swmr_md_eoa == (addr + size)) + if (shared->vfd_swmr_md_eoa == (addr + size)) shared->vfd_swmr_md_eoa = addr; else { /* leak memory */ #ifdef H5MV_VFD_SWMR_DEBUG -HDfprintf(stderr, "%s: LEAKED MEMORY!!! addr = %a, size = %Hu\n", FUNC, addr, size); + HDfprintf(stderr, "%s: LEAKED MEMORY!!! addr = %a, size = %Hu\n", FUNC, addr, size); #endif } /* end else */ @@ -568,11 +559,10 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV__free_md() */ - /*------------------------------------------------------------------------- * Function: H5MV__alloc_md * - * Purpose: Allocate space at the end of the metadata file + * Purpose: Allocate space at the end of the metadata file * * Return: Success: Non-negative * Failure: Negative @@ -582,7 +572,7 @@ done: haddr_t H5MV__alloc_md(H5F_shared_t *shared, hsize_t size) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_PACKAGE @@ -593,7 +583,7 @@ H5MV__alloc_md(H5F_shared_t *shared, hsize_t size) /* Extend the EOA space of the metadata file */ ret_value = H5MV__extend_md(shared, size); - if(!H5F_addr_defined(ret_value)) + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver eoa update request failed") done: @@ -614,7 +604,7 @@ done: htri_t H5MV__try_extend_md(H5F_shared_t *shared, haddr_t blk_end, hsize_t extra_requested) { - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE @@ -623,10 +613,10 @@ H5MV__try_extend_md(H5F_shared_t *shared, haddr_t blk_end, hsize_t extra_request HDassert(extra_requested > 0); /* Check if the block is exactly at the end of the file */ - if(H5F_addr_eq(blk_end, shared->vfd_swmr_md_eoa)) { + if (H5F_addr_eq(blk_end, shared->vfd_swmr_md_eoa)) { - /* Extend the EOA space of the metadata file */ - if(HADDR_UNDEF == H5MV__extend_md(shared, extra_requested)) + /* Extend the EOA space of the metadata file */ + if (HADDR_UNDEF == H5MV__extend_md(shared, extra_requested)) HGOTO_ERROR(H5E_FILE, H5E_CANTEXTEND, FAIL, "driver extend request failed") /* Indicate success */ @@ -647,11 +637,11 @@ done: * *------------------------------------------------------------------------- */ -static haddr_t +static haddr_t H5MV__extend_md(H5F_shared_t *shared, hsize_t size) { haddr_t eoa; - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -662,7 +652,7 @@ H5MV__extend_md(H5F_shared_t *shared, hsize_t size) /* XXX why does this check maxaddr? That should have no bearing on * the metadata file. */ - if(H5F_addr_overflow(eoa, size) || (eoa + size) > shared->maxaddr) + if (H5F_addr_overflow(eoa, size) || (eoa + size) > shared->maxaddr) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") /* Set the address to return */ @@ -675,7 +665,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5MV_get_vfd_swmr_md_eoa * diff --git a/src/H5MVmodule.h b/src/H5MVmodule.h index 5a95767..1d9be49 100644 --- a/src/H5MVmodule.h +++ b/src/H5MVmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5MV_MODULE -#define H5_MY_PKG H5MV -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5MV +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO #endif /* _H5MVmodule_H */ - diff --git a/src/H5MVpkg.h b/src/H5MVpkg.h index cb29879..3ff214d 100644 --- a/src/H5MVpkg.h +++ b/src/H5MVpkg.h @@ -30,8 +30,7 @@ #include "H5MVprivate.h" /* Other private headers needed by this file */ -#include "H5FSprivate.h" /* File free space */ - +#include "H5FSprivate.h" /* File free space */ /**************************/ /* Package Private Macros */ @@ -42,7 +41,8 @@ /* Free-space section types for file */ /* (values stored in free space data structures in file) */ -#define H5MV_FSPACE_SECT_SIMPLE 0 /* For non-paged aggregation: section is a range of actual bytes in file */ +#define H5MV_FSPACE_SECT_SIMPLE 0 /* For non-paged aggregation: section is a range of actual bytes in file \ + */ /****************************/ /* Package Private Typedefs */ @@ -50,7 +50,7 @@ /* File free space section info */ typedef struct H5MV_free_section_t { - H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ + H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ } H5MV_free_section_t; /*****************************/ @@ -60,7 +60,6 @@ typedef struct H5MV_free_section_t { /* H5MF single section inherits serializable properties from H5FS_section_class_t */ H5_DLLVAR H5FS_section_class_t H5MV_FSPACE_SECT_CLS_SIMPLE[1]; - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -70,16 +69,14 @@ H5_DLL herr_t H5MV__create(H5F_t *f); /* free-space section routines */ H5_DLL H5MV_free_section_t *H5MV__sect_new(haddr_t sect_off, hsize_t sect_size); -H5_DLL herr_t H5MV__sect_free(H5FS_section_info_t *sect); -H5_DLL htri_t H5MV__sect_can_shrink(const H5FS_section_info_t *_sect, void *udata); -H5_DLL herr_t H5MV__sect_shrink(H5FS_section_info_t **_sect, void *udata); -H5_DLL haddr_t H5MV_get_vfd_swmr_md_eoa(const H5F_shared_t *); -H5_DLL herr_t H5MV__free_md(H5F_shared_t *, haddr_t, hsize_t); - +H5_DLL herr_t H5MV__sect_free(H5FS_section_info_t *sect); +H5_DLL htri_t H5MV__sect_can_shrink(const H5FS_section_info_t *_sect, void *udata); +H5_DLL herr_t H5MV__sect_shrink(H5FS_section_info_t **_sect, void *udata); +H5_DLL haddr_t H5MV_get_vfd_swmr_md_eoa(const H5F_shared_t *); +H5_DLL herr_t H5MV__free_md(H5F_shared_t *, haddr_t, hsize_t); /* Testing routines */ #ifdef H5MF_TESTING #endif /* H5MF_TESTING */ #endif /* _H5MFpkg_H */ - diff --git a/src/H5MVprivate.h b/src/H5MVprivate.h index 2c0e95a..e292b6e 100644 --- a/src/H5MVprivate.h +++ b/src/H5MVprivate.h @@ -23,23 +23,20 @@ #define _H5MVprivate_H /* Private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -50,9 +47,8 @@ H5_DLL herr_t H5MV_close(H5F_t *f); /* File space allocation routines */ H5_DLL haddr_t H5MV_alloc(H5F_t *f, hsize_t size); -H5_DLL herr_t H5MV_free(H5F_t *f, haddr_t addr, hsize_t size); -H5_DLL herr_t H5MV_try_extend(H5F_t *f, haddr_t addr, hsize_t size, hsize_t extra_requested); -H5_DLL htri_t H5MV_try_shrink(H5F_t *f, haddr_t addr, hsize_t size); +H5_DLL herr_t H5MV_free(H5F_t *f, haddr_t addr, hsize_t size); +H5_DLL herr_t H5MV_try_extend(H5F_t *f, haddr_t addr, hsize_t size, hsize_t extra_requested); +H5_DLL htri_t H5MV_try_shrink(H5F_t *f, haddr_t addr, hsize_t size); #endif /* end _H5MVprivate_H */ - diff --git a/src/H5MVsection.c b/src/H5MVsection.c index 81f1a00..ae6f433 100644 --- a/src/H5MVsection.c +++ b/src/H5MVsection.c @@ -23,49 +23,39 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MVmodule.h" /* This source code file is part of the H5MF module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MVmodule.h" /* This source code file is part of the H5MF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5MVpkg.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5MVpkg.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* 'simple' section callbacks */ -static htri_t H5MV__sect_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MV__sect_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static herr_t H5MV__sect_valid(const H5FS_section_class_t *cls, - const H5FS_section_info_t *sect); -static H5FS_section_info_t *H5MV__sect_split(H5FS_section_info_t *sect, - hsize_t frag_size); - - +static htri_t H5MV__sect_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5MV__sect_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static herr_t H5MV__sect_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect); +static H5FS_section_info_t *H5MV__sect_split(H5FS_section_info_t *sect, hsize_t frag_size); /*********************/ /* Package Variables */ @@ -74,35 +64,33 @@ static H5FS_section_info_t *H5MV__sect_split(H5FS_section_info_t *sect, /* Class info for "simple" free space sections */ H5FS_section_class_t H5MV_FSPACE_SECT_CLS_SIMPLE[1] = {{ /* Class variables */ - H5MV_FSPACE_SECT_SIMPLE, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK | H5FS_CLS_GHOST_OBJ, /* Class flags */ - NULL, /* Class private info */ + H5MV_FSPACE_SECT_SIMPLE, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK | H5FS_CLS_GHOST_OBJ, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - NULL, /* Deserialize section */ - H5MV__sect_can_merge, /* Can sections merge? */ - H5MV__sect_merge, /* Merge sections */ - H5MV__sect_can_shrink, /* Can section shrink container?*/ - H5MV__sect_shrink, /* Shrink container w/section */ - H5MV__sect_free, /* Free section */ - H5MV__sect_valid, /* Check validity of section */ - H5MV__sect_split, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + NULL, /* Deserialize section */ + H5MV__sect_can_merge, /* Can sections merge? */ + H5MV__sect_merge, /* Merge sections */ + H5MV__sect_can_shrink, /* Can section shrink container?*/ + H5MV__sect_shrink, /* Shrink container w/section */ + H5MV__sect_free, /* Free section */ + H5MV__sect_valid, /* Check validity of section */ + H5MV__sect_split, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -110,11 +98,10 @@ H5FS_section_class_t H5MV_FSPACE_SECT_CLS_SIMPLE[1] = {{ /* Declare a free list to manage the H5MF_free_section_t struct */ H5FL_DEFINE(H5MV_free_section_t); -/* +/* * "simple" section callbacks */ - /*------------------------------------------------------------------------- * Function: H5MV__sect_new * @@ -127,8 +114,8 @@ H5FL_DEFINE(H5MV_free_section_t); H5MV_free_section_t * H5MV__sect_new(haddr_t sect_off, hsize_t sect_size) { - H5MV_free_section_t *sect; /* 'Simple' free space section to add */ - H5MV_free_section_t *ret_value = NULL; /* Return value */ + H5MV_free_section_t *sect; /* 'Simple' free space section to add */ + H5MV_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -136,7 +123,7 @@ H5MV__sect_new(haddr_t sect_off, hsize_t sect_size) HDassert(sect_size); /* Create free space section node */ - if(NULL == (sect = H5FL_MALLOC(H5MV_free_section_t))) + if (NULL == (sect = H5FL_MALLOC(H5MV_free_section_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free section node") /* Set the information passed in */ @@ -144,7 +131,7 @@ H5MV__sect_new(haddr_t sect_off, hsize_t sect_size) sect->sect_info.size = sect_size; /* Set the section's class & state */ - sect->sect_info.type = H5MV_FSPACE_SECT_SIMPLE; + sect->sect_info.type = H5MV_FSPACE_SECT_SIMPLE; sect->sect_info.state = H5FS_SECT_LIVE; /* Set return value */ @@ -154,7 +141,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MV__sect_new() */ - /*------------------------------------------------------------------------- * Function: H5MV__sect_free * @@ -168,7 +154,7 @@ done: herr_t H5MV__sect_free(H5FS_section_info_t *_sect) { - H5MV_free_section_t *sect = (H5MV_free_section_t *)_sect; /* File free section */ + H5MV_free_section_t *sect = (H5MV_free_section_t *)_sect; /* File free section */ FUNC_ENTER_PACKAGE_NOERR @@ -179,10 +165,8 @@ H5MV__sect_free(H5FS_section_info_t *_sect) sect = H5FL_FREE(H5MV_free_section_t, sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MV__sect_free() */ - +} /* H5MV__sect_free() */ - /*------------------------------------------------------------------------- * Function: H5MV__sect_can_merge * @@ -196,19 +180,19 @@ H5MV__sect_free(H5FS_section_info_t *_sect) *------------------------------------------------------------------------- */ static htri_t -H5MV__sect_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5MV__sect_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - const H5MV_free_section_t *sect1 = (const H5MV_free_section_t *)_sect1; /* File free section */ - const H5MV_free_section_t *sect2 = (const H5MV_free_section_t *)_sect2; /* File free section */ - htri_t ret_value = FAIL; /* Return value */ + const H5MV_free_section_t *sect1 = (const H5MV_free_section_t *)_sect1; /* File free section */ + const H5MV_free_section_t *sect2 = (const H5MV_free_section_t *)_sect2; /* File free section */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Check if second section adjoins first section */ @@ -217,7 +201,6 @@ H5MV__sect_can_merge(const H5FS_section_info_t *_sect1, FUNC_LEAVE_NOAPI(ret_value) } /* H5MV__sect_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5MV__sect_merge * @@ -231,12 +214,11 @@ H5MV__sect_can_merge(const H5FS_section_info_t *_sect1, *------------------------------------------------------------------------- */ static herr_t -H5MV__sect_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void H5_ATTR_UNUSED *_udata) +H5MV__sect_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { - H5MV_free_section_t **sect1 = (H5MV_free_section_t **)_sect1; /* File free section */ - H5MV_free_section_t *sect2 = (H5MV_free_section_t *)_sect2; /* File free section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MV_free_section_t **sect1 = (H5MV_free_section_t **)_sect1; /* File free section */ + H5MV_free_section_t * sect2 = (H5MV_free_section_t *)_sect2; /* File free section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -251,14 +233,13 @@ H5MV__sect_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5MV__sect_free((H5FS_section_info_t *)sect2) < 0) + if (H5MV__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MV__sect_merge() */ - /*------------------------------------------------------------------------- * Function: H5MV__sect_can_shrink * @@ -272,12 +253,12 @@ done: htri_t H5MV__sect_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { - const H5MV_free_section_t *sect = (const H5MV_free_section_t *)_sect; /* File free section */ - H5F_t *f = (H5F_t *)_udata; - H5F_shared_t *shared = f->shared; - haddr_t eoa; /* End of address space in the file */ - haddr_t end; /* End of section to extend */ - htri_t ret_value = FALSE; /* Return value */ + const H5MV_free_section_t *sect = (const H5MV_free_section_t *)_sect; /* File free section */ + H5F_t * f = (H5F_t *)_udata; + H5F_shared_t * shared = f->shared; + haddr_t eoa; /* End of address space in the file */ + haddr_t end; /* End of section to extend */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -285,14 +266,14 @@ H5MV__sect_can_shrink(const H5FS_section_info_t *_sect, void *_udata) HDassert(sect); /* Retrieve the end oa the file's address space */ - if(HADDR_UNDEF == (eoa = H5MV_get_vfd_swmr_md_eoa(shared))) + if (HADDR_UNDEF == (eoa = H5MV_get_vfd_swmr_md_eoa(shared))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "get_eoa request for VFD SWMR metadata file failed") /* Compute address of end of section to check */ end = sect->sect_info.addr + sect->sect_info.size; /* Check if the section is exactly at the end of the allocated space in the file */ - if(H5F_addr_eq(end, eoa)) + if (H5F_addr_eq(end, eoa)) /* Indicate shrinking can occur */ ret_value = TRUE; @@ -300,7 +281,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MV__sect_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5MV__sect_shrink * @@ -314,10 +294,10 @@ done: herr_t H5MV__sect_shrink(H5FS_section_info_t **_sect, void *_udata) { - H5F_t *f = (H5F_t *)_udata; - H5F_shared_t *shared = f->shared; - H5MV_free_section_t **sect = (H5MV_free_section_t **)_sect; /* File free section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * f = (H5F_t *)_udata; + H5F_shared_t * shared = f->shared; + H5MV_free_section_t **sect = (H5MV_free_section_t **)_sect; /* File free section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -326,21 +306,20 @@ H5MV__sect_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert(H5F_SHARED_INTENT(shared) & H5F_ACC_RDWR); /* Release section's space at EOA */ - if(H5MV__free_md(shared, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) + if (H5MV__free_md(shared, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "free request for VFD SWMR metadata file failed") /* Free the section */ - if(H5MV__sect_free(&(*sect)->sect_info) < 0) + if (H5MV__sect_free(&(*sect)->sect_info) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") - /* Mark section as freed, for free space manager */ - *sect = NULL; + /* Mark section as freed, for free space manager */ + *sect = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MV__sect_shrink() */ - /*------------------------------------------------------------------------- * Function: H5MV__sect_valid * @@ -354,7 +333,7 @@ done: static herr_t H5MV__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5FS_section_info_t *_sect) { - const H5MV_free_section_t *sect = (const H5MV_free_section_t *)_sect; /* File free section */ + const H5MV_free_section_t *sect = (const H5MV_free_section_t *)_sect; /* File free section */ FUNC_ENTER_STATIC_NOERR @@ -362,7 +341,7 @@ H5MV__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5FS_sect HDassert(sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MV__sect_valid() */ +} /* H5MV__sect_valid() */ /*------------------------------------------------------------------------- * Function: H5MV__sect_split @@ -378,13 +357,13 @@ H5MV__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5FS_sect static H5FS_section_info_t * H5MV__sect_split(H5FS_section_info_t *sect, hsize_t frag_size) { - H5MV_free_section_t *ret_value = NULL; /* Return value */ + H5MV_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space for new section */ - if(NULL == (ret_value = H5MV__sect_new(sect->addr, frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") + if (NULL == (ret_value = H5MV__sect_new(sect->addr, frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") /* Set new section's info */ sect->addr += frag_size; diff --git a/src/H5Mmodule.h b/src/H5Mmodule.h index 00a586f..ab84a9a 100644 --- a/src/H5Mmodule.h +++ b/src/H5Mmodule.h @@ -22,10 +22,8 @@ * reporting macros. */ #define H5M_MODULE -#define H5_MY_PKG H5M -#define H5_MY_PKG_ERR H5E_MAP -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5M +#define H5_MY_PKG_ERR H5E_MAP +#define H5_MY_PKG_INIT YES #endif /* _H5Dmodule_H */ - - diff --git a/src/H5Mpkg.h b/src/H5Mpkg.h index 86ff45c..56d1943 100644 --- a/src/H5Mpkg.h +++ b/src/H5Mpkg.h @@ -32,20 +32,16 @@ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ #endif /*_H5Dpkg_H*/ - diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h index 3d0e8cc..7adc97e 100644 --- a/src/H5Mprivate.h +++ b/src/H5Mprivate.h @@ -21,11 +21,10 @@ #include "H5Mpublic.h" /* Private headers needed by this file */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Zprivate.h" /* Data filters */ - +#include "H5FDprivate.h" /* File drivers */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Zprivate.h" /* Data filters */ /**************************/ /* Library Private Macros */ @@ -37,45 +36,43 @@ * to have any effect. */ #ifdef NDEBUG -# undef H5M_DEBUG +#undef H5M_DEBUG #endif /* ======== Map creation property names ======== */ /* ======== Map access property names ======== */ -#define H5M_ACS_KEY_PREFETCH_SIZE_NAME "key_prefetch_size" /* Number of keys to prefetch during map iteration */ -#define H5M_ACS_KEY_ALLOC_SIZE_NAME "key_alloc_size" /* Initial allocation size for keys prefetched during map iteration */ +#define H5M_ACS_KEY_PREFETCH_SIZE_NAME \ + "key_prefetch_size" /* Number of keys to prefetch during map iteration */ +#define H5M_ACS_KEY_ALLOC_SIZE_NAME \ + "key_alloc_size" /* Initial allocation size for keys prefetched during map iteration */ /* Default temporary buffer size */ -#define H5D_TEMP_BUF_SIZE (1024 * 1024) +#define H5D_TEMP_BUF_SIZE (1024 * 1024) /* Default I/O vector size */ -#define H5D_IO_VECTOR_SIZE 1024 +#define H5D_IO_VECTOR_SIZE 1024 /* Default VL allocation & free info */ -#define H5D_VLEN_ALLOC NULL -#define H5D_VLEN_ALLOC_INFO NULL -#define H5D_VLEN_FREE NULL -#define H5D_VLEN_FREE_INFO NULL +#define H5D_VLEN_ALLOC NULL +#define H5D_VLEN_ALLOC_INFO NULL +#define H5D_VLEN_FREE NULL +#define H5D_VLEN_FREE_INFO NULL /* Default virtual dataset list size */ #define H5D_VIRTUAL_DEF_LIST_SIZE 8 - /****************************/ /* Library Private Typedefs */ /****************************/ H5_DLL herr_t H5M_init(void); - /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ #endif /* _H5Mprivate_H */ - diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h index 524ab0f..643a1e6 100644 --- a/src/H5Mpublic.h +++ b/src/H5Mpublic.h @@ -26,23 +26,21 @@ #include "H5public.h" #include "H5Ipublic.h" - /*****************/ /* Public Macros */ /*****************/ /* Macros defining operation IDs for map VOL callbacks (implemented using the * "optional" VOL callback) */ -#define H5VL_MAP_CREATE 1 -#define H5VL_MAP_OPEN 2 -#define H5VL_MAP_GET_VAL 3 -#define H5VL_MAP_EXISTS 4 -#define H5VL_MAP_PUT 5 -#define H5VL_MAP_GET 6 -#define H5VL_MAP_SPECIFIC 7 -#define H5VL_MAP_OPTIONAL 8 -#define H5VL_MAP_CLOSE 9 - +#define H5VL_MAP_CREATE 1 +#define H5VL_MAP_OPEN 2 +#define H5VL_MAP_GET_VAL 3 +#define H5VL_MAP_EXISTS 4 +#define H5VL_MAP_PUT 5 +#define H5VL_MAP_GET 6 +#define H5VL_MAP_SPECIFIC 7 +#define H5VL_MAP_OPTIONAL 8 +#define H5VL_MAP_CLOSE 9 /*******************/ /* Public Typedefs */ @@ -50,28 +48,26 @@ /* types for map GET callback */ typedef enum H5VL_map_get_t { - H5VL_MAP_GET_MAPL, /* map access property list */ - H5VL_MAP_GET_MCPL, /* map creation property list */ - H5VL_MAP_GET_KEY_TYPE, /* key type */ - H5VL_MAP_GET_VAL_TYPE, /* value type */ - H5VL_MAP_GET_COUNT /* key count */ + H5VL_MAP_GET_MAPL, /* map access property list */ + H5VL_MAP_GET_MCPL, /* map creation property list */ + H5VL_MAP_GET_KEY_TYPE, /* key type */ + H5VL_MAP_GET_VAL_TYPE, /* value type */ + H5VL_MAP_GET_COUNT /* key count */ } H5VL_map_get_t; /* types for map SPECIFIC callback */ typedef enum H5VL_map_specific_t { - H5VL_MAP_ITER, /* H5Miterate */ - H5VL_MAP_DELETE /* H5Mdelete */ + H5VL_MAP_ITER, /* H5Miterate */ + H5VL_MAP_DELETE /* H5Mdelete */ } H5VL_map_specific_t; /* Callback for H5Miterate() */ typedef herr_t (*H5M_iterate_t)(hid_t map_id, const void *key, void *op_data); - /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -85,30 +81,26 @@ extern "C" { */ #ifdef H5_HAVE_MAP_API -H5_DLL hid_t H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, - hid_t val_type_id, hid_t lcpl_id, hid_t mcpl_id, hid_t mapl_id); -H5_DLL hid_t H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, - hid_t mcpl_id, hid_t mapl_id); +H5_DLL hid_t H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, hid_t val_type_id, hid_t lcpl_id, + hid_t mcpl_id, hid_t mapl_id); +H5_DLL hid_t H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id, hid_t mapl_id); H5_DLL hid_t H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id); H5_DLL herr_t H5Mclose(hid_t map_id); -H5_DLL hid_t H5Mget_key_type(hid_t map_id); -H5_DLL hid_t H5Mget_val_type(hid_t map_id); -H5_DLL hid_t H5Mget_create_plist(hid_t map_id); -H5_DLL hid_t H5Mget_access_plist(hid_t map_id); +H5_DLL hid_t H5Mget_key_type(hid_t map_id); +H5_DLL hid_t H5Mget_val_type(hid_t map_id); +H5_DLL hid_t H5Mget_create_plist(hid_t map_id); +H5_DLL hid_t H5Mget_access_plist(hid_t map_id); H5_DLL herr_t H5Mget_count(hid_t map_id, hsize_t *count, hid_t dxpl_id); -H5_DLL herr_t H5Mput(hid_t map_id, hid_t key_mem_type_id, const void *key, - hid_t val_mem_type_id, const void *value, hid_t dxpl_id); -H5_DLL herr_t H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, - hid_t val_mem_type_id, void *value, hid_t dxpl_id); -H5_DLL herr_t H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, - hbool_t *exists, hid_t dxpl_id); -H5_DLL herr_t H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, - H5M_iterate_t op, void *op_data, hid_t dxpl_id); -H5_DLL herr_t H5Miterate_by_name(hid_t loc_id, const char *map_name, - hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, - hid_t dxpl_id, hid_t lapl_id); -H5_DLL herr_t H5Mdelete(hid_t map_id, hid_t key_mem_type_id, - const void *key, hid_t dxpl_id); +H5_DLL herr_t H5Mput(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t val_mem_type_id, + const void *value, hid_t dxpl_id); +H5_DLL herr_t H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t val_mem_type_id, void *value, + hid_t dxpl_id); +H5_DLL herr_t H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, hid_t dxpl_id); +H5_DLL herr_t H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, + hid_t dxpl_id); +H5_DLL herr_t H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, hid_t key_mem_type_id, + H5M_iterate_t op, void *op_data, hid_t dxpl_id, hid_t lapl_id); +H5_DLL herr_t H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t dxpl_id); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -124,4 +116,3 @@ H5_DLL herr_t H5Mdelete(hid_t map_id, hid_t key_mem_type_id, #endif #endif /* _H5Mpublic_H */ - diff --git a/src/H5O.c b/src/H5O.c index d943e37..39037a9 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -24,58 +24,49 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5Opkg.h" /* Object headers */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5Oopen * @@ -102,27 +93,27 @@ hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5I_type_t opened_type; - void *opened_obj = NULL; + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5I_type_t opened_type; + void * opened_obj = NULL; H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, lapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location struct fields */ @@ -132,18 +123,18 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) loc_params.obj_type = H5I_get_type(loc_id); /* Open the object */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") /* Get an atom for the object */ - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ - /*------------------------------------------------------------------------- * Function: H5Oopen_by_idx * @@ -168,54 +159,54 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, hid_t lapl_id) +H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5I_type_t opened_type; - void *opened_obj = NULL; + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5I_type_t opened_type; + void * opened_obj = NULL; H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check args */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the object */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Oopen_by_token * @@ -232,45 +223,45 @@ done: hid_t H5Oopen_by_token(hid_t loc_id, H5O_token_t token) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - H5I_type_t opened_type; /* Opened object type */ - void *opened_obj = NULL; /* Opened object */ - H5VL_loc_params_t loc_params; /* Location parameters */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5I_type_t opened_type; /* Opened object type */ + void * opened_obj = NULL; /* Opened object */ + H5VL_loc_params_t loc_params; /* Location parameters */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "ik", loc_id, token); /* Check args */ - if(H5O_IS_TOKEN_UNDEF(token)) + if (H5O_IS_TOKEN_UNDEF(token)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "can't open H5O_TOKEN_UNDEF") /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get object type */ - if((vol_obj_type = H5I_get_type(loc_id)) < 0) + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &token; - loc_params.obj_type = vol_obj_type; + loc_params.obj_type = vol_obj_type; /* Open the object */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") /* Register the object's ID */ - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_token() */ - /*------------------------------------------------------------------------- * Function: H5Olink * @@ -293,78 +284,79 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, - hid_t lapl_id) +H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* object of obj_id */ - H5VL_object_t *vol_obj2 = NULL; /* object of new_loc_id */ - H5VL_object_t tmp_vol_obj; /* Temporary object */ + H5VL_object_t * vol_obj1 = NULL; /* object of obj_id */ + H5VL_object_t * vol_obj2 = NULL; /* object of new_loc_id */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*sii", obj_id, new_loc_id, new_name, lcpl_id, lapl_id); /* Check arguments */ - if(new_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot use H5L_SAME_LOC when only one location is specified") - if(!new_name || !*new_name) + if (new_loc_id == H5L_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "cannot use H5L_SAME_LOC when only one location is specified") + if (!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Avoid compiler warning on 32-bit machines */ #if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T - if(HDstrlen(new_name) > H5L_MAX_LINK_NAME_LEN) + if (HDstrlen(new_name) > H5L_MAX_LINK_NAME_LEN) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "name too long") #endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */ - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Get the link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, obj_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, obj_id, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params1.type = H5VL_OBJECT_BY_SELF; + loc_params1.type = H5VL_OBJECT_BY_SELF; loc_params1.obj_type = H5I_get_type(obj_id); - loc_params2.type = H5VL_OBJECT_BY_NAME; - loc_params2.obj_type = H5I_get_type(new_loc_id); - loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; - if(H5L_SAME_LOC != obj_id) + if (H5L_SAME_LOC != obj_id) /* get the location object */ - if(NULL == (vol_obj1 = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj1 = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(H5L_SAME_LOC != new_loc_id) + if (H5L_SAME_LOC != new_loc_id) /* get the location object */ - if(NULL == (vol_obj2 = H5VL_vol_object(new_loc_id))) + if (NULL == (vol_obj2 = H5VL_vol_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL connectors are the same */ - if(vol_obj1 && vol_obj2) + if (vol_obj1 && vol_obj2) if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "Objects are accessed through different VOL connectors and can't be linked") /* Construct a temporary VOL object */ - tmp_vol_obj.data = vol_obj2->data; + tmp_vol_obj.data = vol_obj2->data; tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector); /* Create a link to the object */ - if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj1->data, &loc_params1) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj1->data, &loc_params1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) } /* end H5Olink() */ - /*------------------------------------------------------------------------- * Function: H5Oincr_refcount * @@ -388,33 +380,33 @@ done: herr_t H5Oincr_refcount(hid_t object_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(object_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(object_id))) + if (NULL == (vol_obj = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(object_id) < 0) + if (H5CX_set_loc(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Change the object's reference count */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, 1) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: FUNC_LEAVE_API(ret_value) } /* end H5O_incr_refcount() */ - /*------------------------------------------------------------------------- * Function: H5Odecr_refcount * @@ -438,33 +430,33 @@ done: herr_t H5Odecr_refcount(hid_t object_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(object_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(object_id))) + if (NULL == (vol_obj = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(object_id) < 0) + if (H5CX_set_loc(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Change the object's reference count */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, -1) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Odecr_refcount() */ - /*------------------------------------------------------------------------- * Function: H5Oexists_by_name * @@ -481,25 +473,25 @@ done: htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set the location struct fields */ @@ -509,14 +501,14 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) loc_params.obj_type = H5I_get_type(loc_id); /* Check if the object exists */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_EXISTS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Oexists_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info3 * @@ -532,36 +524,36 @@ done: herr_t H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); /* Check args */ - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oinfo, fields) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info3() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info_by_name3 * @@ -575,28 +567,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_name3(hid_t loc_id, const char *name, - H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) +H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill out location struct */ @@ -606,18 +597,18 @@ H5Oget_info_by_name3(hid_t loc_id, const char *name, loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oinfo, fields) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_name3() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info_by_idx3 * @@ -633,54 +624,54 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) +H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, fields, lapl_id); /* Check args */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oinfo, fields) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx3() */ - /*------------------------------------------------------------------------- * Function: H5Oget_native_info * @@ -696,36 +687,36 @@ done: herr_t H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo, unsigned fields) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); /* Check args */ - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") - if(fields & ~H5O_NATIVE_INFO_ALL) + if (fields & ~H5O_NATIVE_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_native_info() */ - /*------------------------------------------------------------------------- * Function: H5Oget_native_info_by_name * @@ -739,28 +730,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo, - unsigned fields, hid_t lapl_id) +H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo, unsigned fields, + hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") - if(fields & ~H5O_NATIVE_INFO_ALL) + if (fields & ~H5O_NATIVE_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill out location struct */ @@ -770,18 +761,18 @@ H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oi loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object: '%s'", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_native_info_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Oget_native_info_by_idx * @@ -797,54 +788,54 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_native_info_t *oinfo, unsigned fields, hid_t lapl_id) +H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5O_native_info_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, fields, lapl_id); /* Check args */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(fields & ~H5O_NATIVE_INFO_ALL) + if (fields & ~H5O_NATIVE_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_native_info_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Oset_comment * @@ -865,34 +856,34 @@ done: herr_t H5Oset_comment(hid_t obj_id, const char *comment) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", obj_id, comment); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(obj_id) < 0) + if (H5CX_set_loc(obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(obj_id); /* (Re)set the object's comment */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, comment) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oset_comment() */ - /*------------------------------------------------------------------------- * Function: H5Oset_comment_by_name * @@ -911,22 +902,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, - hid_t lapl_id) +H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, name, comment, lapl_id); /* Check args */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill in location struct fields */ @@ -936,18 +926,18 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* (Re)set the object's comment */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, comment) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object: '%s'", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Oset_comment_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Oget_comment * @@ -967,30 +957,30 @@ done: ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*sz", obj_id, comment, bufsize); /* Get the object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Set fields in the location struct */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(obj_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); /* Retrieve the object's comment */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, comment, bufsize, &ret_value) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_comment() */ - /*------------------------------------------------------------------------- * Function: H5Oget_comment_by_name * @@ -1008,22 +998,21 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, - hid_t lapl_id) +H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE5("Zs", "i*s*szi", loc_id, name, comment, bufsize, lapl_id); /* Check args */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, (-1), "can't set access property list info") /* Fill in location struct fields */ @@ -1033,18 +1022,18 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Retrieve the object's comment */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, comment, bufsize, &ret_value) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object: '%s'", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_comment_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Ovisit3 * @@ -1081,43 +1070,44 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate2_t op, void *op_data, unsigned fields) +H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, void *op_data, + unsigned fields) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIox*xIu", obj_id, idx_type, order, op, op_data, fields); /* Check args */ - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(obj_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Ovisit3() */ - /*------------------------------------------------------------------------- * Function: H5Ovisit_by_name3 * @@ -1154,37 +1144,37 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields, hid_t lapl_id) +H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate2_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIox*xIui", loc_id, obj_name, idx_type, order, op, op_data, fields, lapl_id); /* Check args */ - if(!obj_name) + if (!obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") - if(!*obj_name) + if (!*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location parameters */ @@ -1194,14 +1184,15 @@ H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Ovisit_by_name3() */ - /*------------------------------------------------------------------------- * Function: H5Oclose * @@ -1222,20 +1213,20 @@ done: herr_t H5Oclose(hid_t object_id) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); /* Get the type of the object and close it in the correct way */ - switch(H5I_get_type(object_id)) { + switch (H5I_get_type(object_id)) { case H5I_GROUP: case H5I_DATATYPE: case H5I_DATASET: case H5I_MAP: - if(H5I_object(object_id) == NULL) + if (H5I_object(object_id) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object") - if(H5I_dec_app_ref(object_id) < 0) + if (H5I_dec_app_ref(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") break; @@ -1254,15 +1245,15 @@ H5Oclose(hid_t object_id) case H5I_SPACE_SEL_ITER: case H5I_NTYPES: default: - HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)") - break; + HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, + "not a valid file object ID (dataset, group, or datatype)") + break; } /* end switch */ done: FUNC_LEAVE_API(ret_value) } /* end H5Oclose() */ - /*------------------------------------------------------------------------- * Function: H5O_disable_mdc_flushes * @@ -1275,7 +1266,7 @@ done: herr_t H5O_disable_mdc_flushes(H5O_loc_t *oloc) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL); @@ -1286,7 +1277,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5O_disable_mdc_flushes() */ - /*------------------------------------------------------------------------- * Function: H5Odisable_mdc_flushes * @@ -1304,9 +1294,9 @@ done: herr_t H5Odisable_mdc_flushes(hid_t object_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE1("e", "i", object_id); @@ -1320,18 +1310,18 @@ H5Odisable_mdc_flushes(hid_t object_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(object_id); /* Cork the object */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); done: FUNC_LEAVE_API(ret_value); } /* H5Odisable_mdc_flushes() */ - /*------------------------------------------------------------------------- * Function: H5O_enable_mdc_flushes * @@ -1344,7 +1334,7 @@ done: herr_t H5O_enable_mdc_flushes(H5O_loc_t *oloc) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL); @@ -1355,7 +1345,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5O_enable_mdc_flushes() */ - /*------------------------------------------------------------------------- * Function: H5Oenable_mdc_flushes * @@ -1373,34 +1362,34 @@ done: herr_t H5Oenable_mdc_flushes(hid_t object_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE1("e", "i", object_id); /* Make sure the ID is a file object */ - if(H5I_is_file_object(object_id) != TRUE) + if (H5I_is_file_object(object_id) != TRUE) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(object_id))) + if (NULL == (vol_obj = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(object_id); /* Uncork the object */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); done: FUNC_LEAVE_API(ret_value); } /* H5Oenable_mdc_flushes() */ - /*------------------------------------------------------------------------- * Function: H5O_are_mdc_flushes_disabled * @@ -1413,7 +1402,7 @@ done: herr_t H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL); @@ -1426,7 +1415,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O_are_mdc_flushes_disabled() */ - /*------------------------------------------------------------------------- * Function: H5Oare_mdc_flushes_disabled * @@ -1447,38 +1435,38 @@ done: herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL); H5TRACE2("e", "i*b", object_id, are_disabled); /* Sanity check */ - if(!are_disabled) + if (!are_disabled) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location from ID"); /* Make sure the ID is a file object */ - if(H5I_is_file_object(object_id) != TRUE) + if (H5I_is_file_object(object_id) != TRUE) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(object_id))) + if (NULL == (vol_obj = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(object_id); /* Get the cork status */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, are_disabled) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, are_disabled) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status"); done: FUNC_LEAVE_API(ret_value) } /* H5Oare_mdc_flushes_disabled() */ - /*--------------------------------------------------------------------------- * Function: H5Otoken_cmp * @@ -1495,30 +1483,28 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, - int *cmp_value) +H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) { - H5VL_object_t *vol_obj; /* VOL object for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* VOL object for ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*k*k*Is", loc_id, token1, token2, cmp_value); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(NULL == cmp_value) + if (NULL == cmp_value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid cmp_value pointer") /* Compare the two tokens */ - if(H5VL_token_cmp(vol_obj, token1, token2, cmp_value) < 0) + if (H5VL_token_cmp(vol_obj, token1, token2, cmp_value) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "object token comparison failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Otoken_cmp() */ - /*--------------------------------------------------------------------------- * Function: H5Otoken_to_str * @@ -1533,33 +1519,32 @@ herr_t H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str) { H5VL_object_t *vol_obj; /* VOL object for ID */ - H5I_type_t vol_obj_type; /* VOL object's type */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_type_t vol_obj_type; /* VOL object's type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*k**s", loc_id, token, token_str); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(NULL == token) + if (NULL == token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") - if(NULL == token_str) + if (NULL == token_str) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token string pointer") /* Get object type */ - if((vol_obj_type = H5I_get_type(loc_id)) < 0) + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object type") /* Serialize the token */ - if(H5VL_token_to_str(vol_obj, vol_obj_type, token, token_str) < 0) + if (H5VL_token_to_str(vol_obj, vol_obj_type, token, token_str) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "object token serialization failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Otoken_to_str() */ - /*--------------------------------------------------------------------------- * Function: H5Otoken_from_str * @@ -1574,29 +1559,28 @@ herr_t H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token) { H5VL_object_t *vol_obj; /* VOL object for ID */ - H5I_type_t vol_obj_type; /* VOL object's type */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_type_t vol_obj_type; /* VOL object's type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*k", loc_id, token_str, token); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(NULL == token) + if (NULL == token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") - if(NULL == token_str) + if (NULL == token_str) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token string pointer") /* Get object type */ - if((vol_obj_type = H5I_get_type(loc_id)) < 0) + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object type") /* Deserialize the token */ - if(H5VL_token_from_str(vol_obj, vol_obj_type, token_str, token) < 0) + if (H5VL_token_from_str(vol_obj, vol_obj_type, token_str, token) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "object token deserialization failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Otoken_from_str() */ - diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index 2d95ee9..24acc29 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -22,72 +22,66 @@ *------------------------------------------------------------------------- */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O__ainfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__ainfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_ainfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_ainfo_copy(const void *_mesg, void *_dest); +static void * H5O_ainfo_copy(const void *_mesg, void *_dest); static size_t H5O_ainfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__ainfo_free(void *_mesg); static herr_t H5O__ainfo_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static herr_t H5O_ainfo_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static void *H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, - H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, - H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__ainfo_post_copy_file(const H5O_loc_t *src_oloc, - const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, - unsigned *mesg_flags, H5O_copy_t *cpy_info); -static herr_t H5O__ainfo_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O_ainfo_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *udata); +static void * H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__ainfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, + void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info); +static herr_t H5O__ainfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_AINFO[1] = {{ - H5O_AINFO_ID, /*message id number */ - "ainfo", /*message name for debugging */ - sizeof(H5O_ainfo_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__ainfo_decode, /*decode message */ - H5O_ainfo_encode, /*encode message */ - H5O_ainfo_copy, /*copy the native value */ - H5O_ainfo_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__ainfo_free, /* free method */ - H5O__ainfo_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - H5O_ainfo_pre_copy_file, /* pre copy native value to file */ - H5O__ainfo_copy_file, /* copy native value to file */ - H5O__ainfo_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__ainfo_debug /*debug the message */ + H5O_AINFO_ID, /*message id number */ + "ainfo", /*message name for debugging */ + sizeof(H5O_ainfo_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__ainfo_decode, /*decode message */ + H5O_ainfo_encode, /*encode message */ + H5O_ainfo_copy, /*copy the native value */ + H5O_ainfo_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__ainfo_free, /* free method */ + H5O__ainfo_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + H5O_ainfo_pre_copy_file, /* pre copy native value to file */ + H5O__ainfo_copy_file, /* copy native value to file */ + H5O__ainfo_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__ainfo_debug /*debug the message */ }}; /* Current version of attribute info information */ -#define H5O_AINFO_VERSION 0 +#define H5O_AINFO_VERSION 0 /* Flags for attribute info flag encoding */ -#define H5O_AINFO_TRACK_CORDER 0x01 -#define H5O_AINFO_INDEX_CORDER 0x02 -#define H5O_AINFO_ALL_FLAGS (H5O_AINFO_TRACK_CORDER | H5O_AINFO_INDEX_CORDER) +#define H5O_AINFO_TRACK_CORDER 0x01 +#define H5O_AINFO_INDEX_CORDER 0x02 +#define H5O_AINFO_ALL_FLAGS (H5O_AINFO_TRACK_CORDER | H5O_AINFO_INDEX_CORDER) /* Declare a free list to manage the H5O_ainfo_t struct */ H5FL_DEFINE_STATIC(H5O_ainfo_t); - /*------------------------------------------------------------------------- * Function: H5O__ainfo_decode * @@ -103,13 +97,12 @@ H5FL_DEFINE_STATIC(H5O_ainfo_t); *------------------------------------------------------------------------- */ static void * -H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_ainfo_t *ainfo = NULL; /* Attribute info */ - unsigned char flags; /* Flags for encoding attribute info */ - void *ret_value = NULL; /* Return value */ + H5O_ainfo_t * ainfo = NULL; /* Attribute info */ + unsigned char flags; /* Flags for encoding attribute info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -118,16 +111,16 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_AINFO_VERSION) + if (*p++ != H5O_AINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (ainfo = H5FL_MALLOC(H5O_ainfo_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (ainfo = H5FL_MALLOC(H5O_ainfo_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the flags for the message */ flags = *p++; - if(flags & ~H5O_AINFO_ALL_FLAGS) + if (flags & ~H5O_AINFO_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") ainfo->track_corder = (flags & H5O_AINFO_TRACK_CORDER) ? TRUE : FALSE; ainfo->index_corder = (flags & H5O_AINFO_INDEX_CORDER) ? TRUE : FALSE; @@ -136,7 +129,7 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ainfo->nattrs = HSIZET_MAX; /* Max. creation order value for the object */ - if(ainfo->track_corder) + if (ainfo->track_corder) UINT16DECODE(p, ainfo->max_crt_idx) else ainfo->max_crt_idx = H5O_MAX_CRT_ORDER_IDX; @@ -148,7 +141,7 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, H5F_addr_decode(f, &p, &(ainfo->name_bt2_addr)); /* Address of v2 B-tree to index creation order of links, if there is one */ - if(ainfo->index_corder) + if (ainfo->index_corder) H5F_addr_decode(f, &p, &(ainfo->corder_bt2_addr)); else ainfo->corder_bt2_addr = HADDR_UNDEF; @@ -157,13 +150,12 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = ainfo; done: - if(ret_value == NULL && ainfo != NULL) + if (ret_value == NULL && ainfo != NULL) ainfo = H5FL_FREE(H5O_ainfo_t, ainfo); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__ainfo_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_ainfo_encode * @@ -180,8 +172,8 @@ done: static herr_t H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - unsigned char flags; /* Flags for encoding attribute info */ + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; + unsigned char flags; /* Flags for encoding attribute info */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -196,10 +188,10 @@ H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co /* The flags for the attribute indices */ flags = (unsigned char)(ainfo->track_corder ? H5O_AINFO_TRACK_CORDER : 0); flags = (unsigned char)(flags | (ainfo->index_corder ? H5O_AINFO_INDEX_CORDER : 0)); - *p++ = flags; + *p++ = flags; /* Max. creation order value for the object */ - if(ainfo->track_corder) + if (ainfo->track_corder) UINT16ENCODE(p, ainfo->max_crt_idx); /* Address of fractal heap to store "dense" attributes */ @@ -209,7 +201,7 @@ H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co H5F_addr_encode(f, &p, ainfo->name_bt2_addr); /* Address of v2 B-tree to index creation order of attributes, if they are indexed */ - if(ainfo->index_corder) + if (ainfo->index_corder) H5F_addr_encode(f, &p, ainfo->corder_bt2_addr); else HDassert(!H5F_addr_defined(ainfo->corder_bt2_addr)); @@ -217,7 +209,6 @@ H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_ainfo_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_ainfo_copy * @@ -236,16 +227,16 @@ H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co static void * H5O_ainfo_copy(const void *_mesg, void *_dest) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - H5O_ainfo_t *dest = (H5O_ainfo_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; + H5O_ainfo_t * dest = (H5O_ainfo_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(ainfo); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_ainfo_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_ainfo_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ *dest = *ainfo; @@ -257,7 +248,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_ainfo_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_ainfo_size * @@ -277,23 +267,25 @@ done: static size_t H5O_ainfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = (size_t)(1 /* Version */ - + 1 /* Index flags */ - + (ainfo->track_corder ? 2 : 0) /* Curr. max. creation order value */ - + H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" attributes */ - + H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of attributes */ - + (ainfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0)); /* Address of v2 B-tree for indexing creation order values of attributes */ + ret_value = + (size_t)(1 /* Version */ + + 1 /* Index flags */ + + (ainfo->track_corder ? 2 : 0) /* Curr. max. creation order value */ + + H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" attributes */ + + H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of attributes */ + + (ainfo->index_corder + ? H5F_SIZEOF_ADDR(f) + : 0)); /* Address of v2 B-tree for indexing creation order values of attributes */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_ainfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_free * @@ -318,7 +310,6 @@ H5O__ainfo_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__ainfo_free() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_delete * @@ -336,8 +327,8 @@ H5O__ainfo_free(void *mesg) static herr_t H5O__ainfo_delete(H5F_t *f, H5O_t H5_ATTR_NDEBUG_UNUSED *open_oh, void *_mesg) { - H5O_ainfo_t *ainfo = (H5O_ainfo_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_ainfo_t *ainfo = (H5O_ainfo_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -347,16 +338,15 @@ H5O__ainfo_delete(H5F_t *f, H5O_t H5_ATTR_NDEBUG_UNUSED *open_oh, void *_mesg) HDassert(open_oh); /* If the object is using "dense" attribute storage, delete it */ - if(H5F_addr_defined(ainfo->fheap_addr)) + if (H5F_addr_defined(ainfo->fheap_addr)) /* Delete the attribute */ - if(H5A__dense_delete(f, ainfo) < 0) + if (H5A__dense_delete(f, ainfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free dense attribute storage") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__ainfo_delete() */ - /*------------------------------------------------------------------------- * Function: H5O_ainfo_pre_copy_file * @@ -373,7 +363,7 @@ done: */ static herr_t H5O_ainfo_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) + hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -384,13 +374,12 @@ H5O_ainfo_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSE /* If we are not copying attributes into the destination file, indicate * that this message should be deleted. */ - if(cpy_info->copy_without_attr) + if (cpy_info->copy_without_attr) *deleted = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_ainfo_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_copy_file * @@ -406,12 +395,12 @@ H5O_ainfo_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSE */ static void * H5O__ainfo_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, void *mesg_src, H5F_t *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { H5O_ainfo_t *ainfo_src = (H5O_ainfo_t *)mesg_src; H5O_ainfo_t *ainfo_dst = NULL; - void *ret_value = NULL; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -423,19 +412,19 @@ H5O__ainfo_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, void *mesg_src, H5F_ HDassert(!cpy_info->copy_without_attr); /* Allocate space for the destination message */ - if(NULL == (ainfo_dst = H5FL_MALLOC(H5O_ainfo_t))) + if (NULL == (ainfo_dst = H5FL_MALLOC(H5O_ainfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the top level of the information */ *ainfo_dst = *ainfo_src; - if(H5F_addr_defined(ainfo_src->fheap_addr)) { + if (H5F_addr_defined(ainfo_src->fheap_addr)) { /* Prepare to copy dense attributes - actual copy in post_copy */ /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); - if(H5A__dense_create(file_dst, ainfo_dst) < 0) + if (H5A__dense_create(file_dst, ainfo_dst) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") /* Reset metadata tag */ @@ -447,13 +436,12 @@ H5O__ainfo_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, void *mesg_src, H5F_ done: /* Release destination attribute information on failure */ - if(!ret_value && ainfo_dst) + if (!ret_value && ainfo_dst) ainfo_dst = H5FL_FREE(H5O_ainfo_t, ainfo_dst); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__ainfo_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_post_copy_file * @@ -471,26 +459,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__ainfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, - H5O_loc_t *dst_oloc, void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info) +H5O__ainfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, + void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info) { const H5O_ainfo_t *ainfo_src = (const H5O_ainfo_t *)mesg_src; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(ainfo_src); - if(H5F_addr_defined(ainfo_src->fheap_addr)) - if(H5A__dense_post_copy_file_all(src_oloc, ainfo_src, dst_oloc, (H5O_ainfo_t *)mesg_dst, cpy_info) < 0) + if (H5F_addr_defined(ainfo_src->fheap_addr)) + if (H5A__dense_post_copy_file_all(src_oloc, ainfo_src, dst_oloc, (H5O_ainfo_t *)mesg_dst, cpy_info) < + 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__ainfo_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_debug * @@ -505,10 +492,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__ainfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__ainfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *) _mesg; + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -519,22 +505,19 @@ H5O__ainfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of attributes:", ainfo->nattrs); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Number of attributes:", ainfo->nattrs); HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Track creation order of attributes:", ainfo->track_corder); + "Track creation order of attributes:", ainfo->track_corder); HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Index creation order of attributes:", ainfo->index_corder); + "Index creation order of attributes:", ainfo->index_corder); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. creation index value:", (unsigned)ainfo->max_crt_idx); + "Max. creation index value:", (unsigned)ainfo->max_crt_idx); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' attribute storage fractal heap address:", ainfo->fheap_addr); + "'Dense' attribute storage fractal heap address:", ainfo->fheap_addr); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' attribute storage name index v2 B-tree address:", ainfo->name_bt2_addr); + "'Dense' attribute storage name index v2 B-tree address:", ainfo->name_bt2_addr); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' attribute storage creation order index v2 B-tree address:", ainfo->corder_bt2_addr); - + "'Dense' attribute storage creation order index v2 B-tree address:", ainfo->corder_bt2_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__ainfo_debug() */ - diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 8850ef6..e411854 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -26,50 +26,44 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5O__add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, - hbool_t *chk_dirtied, size_t idx, uint8_t *new_gap_loc, size_t new_gap_size); -static herr_t H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, - H5O_mesg_t *mesg, uint8_t *new_gap_loc, size_t new_gap_size); -static herr_t H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, - const H5O_msg_class_t *new_type, void *new_native, size_t new_size); -static htri_t H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, - unsigned chunkno, size_t size, size_t *msg_idx); +static herr_t H5O__add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, size_t idx, + uint8_t *new_gap_loc, size_t new_gap_size); +static herr_t H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, uint8_t *new_gap_loc, + size_t new_gap_size); +static herr_t H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new_type, + void *new_native, size_t new_size); +static htri_t H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size_t *msg_idx); static herr_t H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, - H5O_msg_alloc_info_t *found_msg); -static herr_t H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, - size_t *new_idx); + H5O_msg_alloc_info_t *found_msg); +static herr_t H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t *new_idx); static herr_t H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx); static htri_t H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u); static htri_t H5O__move_msgs_forward(H5F_t *f, H5O_t *oh); @@ -77,7 +71,6 @@ static htri_t H5O__merge_null(H5F_t *f, H5O_t *oh); static htri_t H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh); static herr_t H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno); - /*********************/ /* Package Variables */ /*********************/ @@ -85,18 +78,14 @@ static herr_t H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno); /* Declare extern the free list for H5O_cont_t's */ H5FL_EXTERN(H5O_cont_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O__add_gap * @@ -111,12 +100,12 @@ H5FL_EXTERN(H5O_cont_t); *------------------------------------------------------------------------- */ static herr_t -H5O__add_gap(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, - size_t idx, uint8_t *new_gap_loc, size_t new_gap_size) +H5O__add_gap(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, size_t idx, + uint8_t *new_gap_loc, size_t new_gap_size) { - hbool_t merged_with_null; /* Whether the gap was merged with a null message */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t merged_with_null; /* Whether the gap was merged with a null message */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -128,74 +117,75 @@ H5O__add_gap(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t *oh, unsigned chunkno, hbool_ HDassert(new_gap_size); #ifndef NDEBUG -if(chunkno > 0) { - unsigned chk_proxy_status = 0; /* Object header chunk proxy entry cache status */ + if (chunkno > 0) { + unsigned chk_proxy_status = 0; /* Object header chunk proxy entry cache status */ - /* Check the object header chunk proxy's status in the metadata cache */ - if(H5AC_get_entry_status(f, oh->chunk[chunkno].addr, &chk_proxy_status) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check metadata cache status for object header chunk proxy") + /* Check the object header chunk proxy's status in the metadata cache */ + if (H5AC_get_entry_status(f, oh->chunk[chunkno].addr, &chk_proxy_status) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, + "unable to check metadata cache status for object header chunk proxy") - /* Make certain that object header is protected */ - HDassert(chk_proxy_status & H5AC_ES__IS_PROTECTED); -} /* end if */ + /* Make certain that object header is protected */ + HDassert(chk_proxy_status & H5AC_ES__IS_PROTECTED); + } /* end if */ #endif /* NDEBUG */ /* Check for existing null message in chunk */ merged_with_null = FALSE; - for(u = 0; u < oh->nmesgs && !merged_with_null; u++) { + for (u = 0; u < oh->nmesgs && !merged_with_null; u++) { /* Find a null message in the chunk with the new gap */ /* (a null message that's not the one we are eliminating) */ - if(H5O_NULL_ID == oh->mesg[u].type->id && oh->mesg[u].chunkno == chunkno - && u != idx) { + if (H5O_NULL_ID == oh->mesg[u].type->id && oh->mesg[u].chunkno == chunkno && u != idx) { /* Sanity check - chunks with null messages shouldn't have a gap */ HDassert(oh->chunk[chunkno].gap == 0); /* Eliminate the gap in the chunk */ - if(H5O__eliminate_gap(oh, chk_dirtied, &oh->mesg[u], new_gap_loc, new_gap_size) < 0) + if (H5O__eliminate_gap(oh, chk_dirtied, &oh->mesg[u], new_gap_loc, new_gap_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't eliminate gap in chunk") /* Set flag to indicate that the gap was handled */ merged_with_null = TRUE; } /* end if */ - } /* end for */ + } /* end for */ /* If we couldn't find a null message in the chunk, move the gap to the end */ - if(!merged_with_null) { + if (!merged_with_null) { /* Adjust message offsets after new gap forward in chunk */ - for(u = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].chunkno == chunkno && oh->mesg[u].raw > new_gap_loc) + for (u = 0; u < oh->nmesgs; u++) + if (oh->mesg[u].chunkno == chunkno && oh->mesg[u].raw > new_gap_loc) oh->mesg[u].raw -= new_gap_size; /* Slide raw message info forward in chunk image */ HDmemmove(new_gap_loc, new_gap_loc + new_gap_size, - (size_t)((oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))) - (new_gap_loc + new_gap_size))); + (size_t)((oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))) - + (new_gap_loc + new_gap_size))); /* Add existing gap size to new gap size */ new_gap_size += oh->chunk[chunkno].gap; /* Merging with existing gap will allow for a new null message */ - if(new_gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { - H5O_mesg_t *null_msg; /* Pointer to new null message */ + if (new_gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { + H5O_mesg_t *null_msg; /* Pointer to new null message */ /* Check if we need to extend message table to hold the new null message */ - if(oh->nmesgs >= oh->alloc_nmesgs) - if(H5O__alloc_msgs(oh, (size_t)1) < 0) + if (oh->nmesgs >= oh->alloc_nmesgs) + if (H5O__alloc_msgs(oh, (size_t)1) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Increment new gap size */ oh->chunk[chunkno].gap += new_gap_size; /* Create new null message, with the tail of the previous null message */ - null_msg = &(oh->mesg[oh->nmesgs++]); - null_msg->type = H5O_MSG_NULL; - null_msg->native = NULL; + null_msg = &(oh->mesg[oh->nmesgs++]); + null_msg->type = H5O_MSG_NULL; + null_msg->native = NULL; null_msg->raw_size = new_gap_size - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - null_msg->raw = (oh->chunk[chunkno].image + oh->chunk[chunkno].size) - - (H5O_SIZEOF_CHKSUM_OH(oh) + null_msg->raw_size); + null_msg->raw = (oh->chunk[chunkno].image + oh->chunk[chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + null_msg->raw_size); null_msg->chunkno = chunkno; /* Zero out new null message's raw data */ - if(null_msg->raw_size) + if (null_msg->raw_size) HDmemset(null_msg->raw, 0, null_msg->raw_size); /* Mark message as dirty */ @@ -215,7 +205,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__add_gap() */ - /*------------------------------------------------------------------------- * Function: H5O__eliminate_gap * @@ -237,11 +226,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, - uint8_t *gap_loc, size_t gap_size) +H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, uint8_t *gap_loc, size_t gap_size) { - uint8_t *move_start, *move_end; /* Pointers to area of messages to move */ - hbool_t null_before_gap; /* Flag whether the null message is before the gap or not */ + uint8_t *move_start, *move_end; /* Pointers to area of messages to move */ + hbool_t null_before_gap; /* Flag whether the null message is before the gap or not */ FUNC_ENTER_STATIC_NOERR @@ -257,37 +245,36 @@ H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, null_before_gap = (hbool_t)(mesg->raw < gap_loc); /* Set up information about region of messages to move */ - if(null_before_gap) { + if (null_before_gap) { move_start = mesg->raw + mesg->raw_size; - move_end = gap_loc; + move_end = gap_loc; } /* end if */ else { move_start = gap_loc + gap_size; - move_end = mesg->raw - H5O_SIZEOF_MSGHDR_OH(oh); + move_end = mesg->raw - H5O_SIZEOF_MSGHDR_OH(oh); } /* end else */ /* Check for messages between null message and gap */ - if(move_end > move_start) { - unsigned u; /* Local index variable */ + if (move_end > move_start) { + unsigned u; /* Local index variable */ /* Look for messages that need to move, to adjust raw pointers in chunk */ /* (this doesn't change the moved messages 'dirty' state) */ - for(u = 0; u < oh->nmesgs; u++) { - uint8_t *msg_start; /* Start of encoded message in chunk */ + for (u = 0; u < oh->nmesgs; u++) { + uint8_t *msg_start; /* Start of encoded message in chunk */ msg_start = oh->mesg[u].raw - H5O_SIZEOF_MSGHDR_OH(oh); - if(oh->mesg[u].chunkno == mesg->chunkno - && (msg_start >= move_start && msg_start < move_end)) { + if (oh->mesg[u].chunkno == mesg->chunkno && (msg_start >= move_start && msg_start < move_end)) { /* Move message's raw pointer in appropriate direction */ - if(null_before_gap) + if (null_before_gap) oh->mesg[u].raw += gap_size; else oh->mesg[u].raw -= gap_size; } /* end if */ - } /* end for */ + } /* end for */ /* Slide raw message info in chunk image */ - if(null_before_gap) + if (null_before_gap) /* Slide messages down */ HDmemmove(move_start + gap_size, move_start, (size_t)(move_end - move_start)); else { @@ -298,12 +285,12 @@ H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, mesg->raw -= gap_size; } /* end else */ } - else if(move_end == move_start && !null_before_gap) { - /* Slide null message up */ - HDmemmove(move_start - gap_size, move_start, mesg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + else if (move_end == move_start && !null_before_gap) { + /* Slide null message up */ + HDmemmove(move_start - gap_size, move_start, mesg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); - /* Adjust start of null message */ - mesg->raw -= gap_size; + /* Adjust start of null message */ + mesg->raw -= gap_size; } /* end if */ /* Zero out addition to null message */ @@ -316,13 +303,12 @@ H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, oh->chunk[mesg->chunkno].gap = 0; /* Mark null message as dirty */ - mesg->dirty = TRUE; + mesg->dirty = TRUE; *chk_dirtied = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5O__eliminate_gap() */ - /*------------------------------------------------------------------------- * * Function: H5O__alloc_null @@ -338,13 +324,13 @@ H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, *------------------------------------------------------------------------- */ static herr_t -H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, - const H5O_msg_class_t *new_type, void *new_native, size_t new_size) +H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new_type, void *new_native, + size_t new_size) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */ - H5O_mesg_t *alloc_msg; /* Pointer to null message to allocate out of */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */ + H5O_mesg_t * alloc_msg; /* Pointer to null message to allocate out of */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -357,29 +343,31 @@ H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, alloc_msg = &oh->mesg[null_idx]; /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, alloc_msg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, alloc_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Check if there's a need to split the null message */ - if(alloc_msg->raw_size > new_size) { + if (alloc_msg->raw_size > new_size) { /* Check for producing a gap in the chunk */ - if((alloc_msg->raw_size - new_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { - size_t gap_size = alloc_msg->raw_size - new_size; /* Size of gap produced */ + if ((alloc_msg->raw_size - new_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { + size_t gap_size = alloc_msg->raw_size - new_size; /* Size of gap produced */ /* Adjust the size of the null message being eliminated */ alloc_msg->raw_size = new_size; /* Add the gap to the chunk */ - if(H5O__add_gap(f, oh, alloc_msg->chunkno, &chk_dirtied, null_idx, alloc_msg->raw + alloc_msg->raw_size, gap_size) < 0) + if (H5O__add_gap(f, oh, alloc_msg->chunkno, &chk_dirtied, null_idx, + alloc_msg->raw + alloc_msg->raw_size, gap_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert gap in chunk") } /* end if */ else { - size_t new_mesg_size = new_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Total size of newly allocated message */ - H5O_mesg_t *null_msg; /* Pointer to new null message */ + size_t new_mesg_size = + new_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Total size of newly allocated message */ + H5O_mesg_t *null_msg; /* Pointer to new null message */ /* Check if we need to extend message table to hold the new null message */ - if(oh->nmesgs >= oh->alloc_nmesgs) { - if(H5O__alloc_msgs(oh, (size_t)1) < 0) + if (oh->nmesgs >= oh->alloc_nmesgs) { + if (H5O__alloc_msgs(oh, (size_t)1) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* "Retarget" 'alloc_msg' pointer into newly re-allocated array of messages */ @@ -387,50 +375,50 @@ H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, } /* end if */ /* Create new null message, with the tail of the previous null message */ - null_msg = &(oh->mesg[oh->nmesgs++]); - null_msg->type = H5O_MSG_NULL; - null_msg->native = NULL; - null_msg->raw = alloc_msg->raw + new_mesg_size; + null_msg = &(oh->mesg[oh->nmesgs++]); + null_msg->type = H5O_MSG_NULL; + null_msg->native = NULL; + null_msg->raw = alloc_msg->raw + new_mesg_size; null_msg->raw_size = alloc_msg->raw_size - new_mesg_size; - null_msg->chunkno = alloc_msg->chunkno; + null_msg->chunkno = alloc_msg->chunkno; /* Mark the message as dirty */ null_msg->dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; /* Check for gap in new null message's chunk */ - if(oh->chunk[null_msg->chunkno].gap > 0) { - unsigned null_chunkno = null_msg->chunkno; /* Chunk w/gap */ + if (oh->chunk[null_msg->chunkno].gap > 0) { + unsigned null_chunkno = null_msg->chunkno; /* Chunk w/gap */ /* Eliminate the gap in the chunk */ - if(H5O__eliminate_gap(oh, &chk_dirtied, null_msg, - ((oh->chunk[null_chunkno].image + oh->chunk[null_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[null_chunkno].gap)), - oh->chunk[null_chunkno].gap) < 0) + if (H5O__eliminate_gap(oh, &chk_dirtied, null_msg, + ((oh->chunk[null_chunkno].image + oh->chunk[null_chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[null_chunkno].gap)), + oh->chunk[null_chunkno].gap) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") } /* end if */ /* Set the size of the new "real" message */ alloc_msg->raw_size = new_size; } /* end else */ - } /* end if */ + } /* end if */ /* Initialize the new message */ - alloc_msg->type = new_type; + alloc_msg->type = new_type; alloc_msg->native = new_native; /* Mark the new message as dirty */ alloc_msg->dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; done: /* Release chunk */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_null() */ - /*------------------------------------------------------------------------- * * Function: H5O__alloc_msgs @@ -448,10 +436,10 @@ done: herr_t H5O__alloc_msgs(H5O_t *oh, size_t min_alloc) { - size_t old_alloc; /* Old number of messages allocated */ - size_t na; /* New number of messages allocated */ - H5O_mesg_t *new_mesg; /* Pointer to new message array */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t old_alloc; /* Old number of messages allocated */ + size_t na; /* New number of messages allocated */ + H5O_mesg_t *new_mesg; /* Pointer to new message array */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -460,15 +448,15 @@ H5O__alloc_msgs(H5O_t *oh, size_t min_alloc) /* Initialize number of messages information */ old_alloc = oh->alloc_nmesgs; - na = oh->alloc_nmesgs + MAX(oh->alloc_nmesgs, min_alloc); /* At least double */ + na = oh->alloc_nmesgs + MAX(oh->alloc_nmesgs, min_alloc); /* At least double */ /* Attempt to allocate more memory */ - if(NULL == (new_mesg = H5FL_SEQ_REALLOC(H5O_mesg_t, oh->mesg, na))) + if (NULL == (new_mesg = H5FL_SEQ_REALLOC(H5O_mesg_t, oh->mesg, na))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Update ohdr information */ oh->alloc_nmesgs = na; - oh->mesg = new_mesg; + oh->mesg = new_mesg; /* Set new object header info to zeros */ HDmemset(&oh->mesg[old_alloc], 0, (oh->alloc_nmesgs - old_alloc) * sizeof(H5O_mesg_t)); @@ -477,7 +465,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_msgs() */ - /*------------------------------------------------------------------------- * * Function: H5O__alloc_extend_chunk @@ -507,23 +494,22 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, - size_t *msg_idx) +H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size_t *msg_idx) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - size_t delta; /* Change in chunk's size */ - size_t aligned_size = H5O_ALIGN_OH(oh, size); - uint8_t *old_image; /* Old address of chunk's image in memory */ - size_t old_size; /* Old size of chunk */ - htri_t was_extended; /* If chunk can be extended */ - size_t extend_msg = 0; /* Index of null message to extend */ - hbool_t extended_msg = FALSE; /* Whether an existing message was extended */ - uint8_t new_size_flags = 0; /* New chunk #0 size flags */ - hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ - size_t extra_prfx_size = 0; /* Extra bytes added to object header prefix */ - size_t u; /* Local index variable */ - htri_t ret_value = TRUE; /* return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + size_t delta; /* Change in chunk's size */ + size_t aligned_size = H5O_ALIGN_OH(oh, size); + uint8_t * old_image; /* Old address of chunk's image in memory */ + size_t old_size; /* Old size of chunk */ + htri_t was_extended; /* If chunk can be extended */ + size_t extend_msg = 0; /* Index of null message to extend */ + hbool_t extended_msg = FALSE; /* Whether an existing message was extended */ + uint8_t new_size_flags = 0; /* New chunk #0 size flags */ + hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ + size_t extra_prfx_size = 0; /* Extra bytes added to object header prefix */ + size_t u; /* Local index variable */ + htri_t ret_value = TRUE; /* return value */ FUNC_ENTER_STATIC @@ -538,22 +524,22 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, /* Test to see if the specified chunk ends with a null messages. * If successful, set the index of the the null message in extend_msg. */ - for(u = 0; u < oh->nmesgs; u++) { + for (u = 0; u < oh->nmesgs; u++) { /* Check for null message at end of proper chunk */ /* (account for possible checksum at end of chunk) */ - if(oh->mesg[u].chunkno == chunkno && H5O_NULL_ID == oh->mesg[u].type->id && - ((oh->mesg[u].raw + oh->mesg[u].raw_size) - == ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - - (oh->chunk[chunkno].gap + H5O_SIZEOF_CHKSUM_OH(oh))))) { + if (oh->mesg[u].chunkno == chunkno && H5O_NULL_ID == oh->mesg[u].type->id && + ((oh->mesg[u].raw + oh->mesg[u].raw_size) == + ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - + (oh->chunk[chunkno].gap + H5O_SIZEOF_CHKSUM_OH(oh))))) { - extend_msg = u; + extend_msg = u; extended_msg = TRUE; break; } /* end if */ - } /* end for */ + } /* end for */ /* If we can extend an existing null message, adjust the delta appropriately */ - if(extended_msg) { + if (extended_msg) { HDassert(oh->chunk[chunkno].gap == 0); delta = aligned_size - oh->mesg[extend_msg].raw_size; } /* end if */ @@ -562,89 +548,90 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, delta = H5O_ALIGN_OH(oh, delta); /* Check for changing the chunk #0 data size enough to need adjusting the flags */ - if(oh->version > H5O_VERSION_1 && chunkno == 0) { - uint64_t chunk0_size; /* Size of chunk 0's data */ + if (oh->version > H5O_VERSION_1 && chunkno == 0) { + uint64_t chunk0_size; /* Size of chunk 0's data */ size_t orig_prfx_size = (size_t)1 << (oh->flags & H5O_HDR_CHUNK0_SIZE); /* Original prefix size */ HDassert(oh->chunk[0].size >= (size_t)H5O_SIZEOF_HDR(oh)); chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); /* Check for moving to a 8-byte size encoding */ - if(orig_prfx_size < 8 && (chunk0_size + delta) > 4294967295) { - extra_prfx_size = 8 - orig_prfx_size; - new_size_flags = H5O_HDR_CHUNK0_8; + if (orig_prfx_size < 8 && (chunk0_size + delta) > 4294967295) { + extra_prfx_size = 8 - orig_prfx_size; + new_size_flags = H5O_HDR_CHUNK0_8; adjust_size_flags = TRUE; } /* end if */ /* Check for moving to a 4-byte size encoding */ - else if(orig_prfx_size < 4 && (chunk0_size + delta) > 65535) { - extra_prfx_size = 4 - orig_prfx_size; - new_size_flags = H5O_HDR_CHUNK0_4; + else if (orig_prfx_size < 4 && (chunk0_size + delta) > 65535) { + extra_prfx_size = 4 - orig_prfx_size; + new_size_flags = H5O_HDR_CHUNK0_4; adjust_size_flags = TRUE; } /* end if */ /* Check for moving to a 2-byte size encoding */ - else if(orig_prfx_size < 2 && (chunk0_size + delta) > 255) { - extra_prfx_size = 2 - orig_prfx_size; - new_size_flags = H5O_HDR_CHUNK0_2; + else if (orig_prfx_size < 2 && (chunk0_size + delta) > 255) { + extra_prfx_size = 2 - orig_prfx_size; + new_size_flags = H5O_HDR_CHUNK0_2; adjust_size_flags = TRUE; } /* end if */ - } /* end if */ + } /* end if */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Determine whether the chunk can be extended */ - was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, oh->chunk[chunkno].addr, (hsize_t)(oh->chunk[chunkno].size), (hsize_t)(delta + extra_prfx_size)); - if(was_extended < 0) /* error */ + was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, oh->chunk[chunkno].addr, + (hsize_t)(oh->chunk[chunkno].size), (hsize_t)(delta + extra_prfx_size)); + if (was_extended < 0) /* error */ HGOTO_ERROR(H5E_OHDR, H5E_CANTEXTEND, FAIL, "can't tell if we can extend chunk") - else if(was_extended == FALSE) /* can't extend -- we are done */ + else if (was_extended == FALSE) /* can't extend -- we are done */ HGOTO_DONE(FALSE) /* Adjust object header prefix flags */ - if(adjust_size_flags) { + if (adjust_size_flags) { oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); oh->flags |= new_size_flags; /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end if */ /* If we can extend an existing null message, take care of that */ - if(extended_msg) { + if (extended_msg) { /* Adjust message size of existing null message */ oh->mesg[extend_msg].raw_size += delta; } /* end if */ /* Create new null message for end of chunk */ else { /* Create a new null message */ - if(oh->nmesgs >= oh->alloc_nmesgs) - if(H5O__alloc_msgs(oh, (size_t)1) < 0) + if (oh->nmesgs >= oh->alloc_nmesgs) + if (H5O__alloc_msgs(oh, (size_t)1) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Set extension message */ extend_msg = oh->nmesgs++; /* Initialize new null message */ - oh->mesg[extend_msg].type = H5O_MSG_NULL; + oh->mesg[extend_msg].type = H5O_MSG_NULL; oh->mesg[extend_msg].native = NULL; - oh->mesg[extend_msg].raw = ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[chunkno].gap)) - + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[extend_msg].raw = ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[chunkno].gap)) + + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[extend_msg].raw_size = (delta + oh->chunk[chunkno].gap) - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - oh->mesg[extend_msg].chunkno = chunkno; + oh->mesg[extend_msg].chunkno = chunkno; } /* end else */ /* Mark the extended message as dirty */ oh->mesg[extend_msg].dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; /* Allocate more memory space for chunk's image */ old_image = oh->chunk[chunkno].image; - old_size = oh->chunk[chunkno].size; + old_size = oh->chunk[chunkno].size; oh->chunk[chunkno].size += delta + extra_prfx_size; oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image, old_image, oh->chunk[chunkno].size); - if(NULL == oh->chunk[chunkno].image) + if (NULL == oh->chunk[chunkno].image) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't reallocate extended object header chunk") oh->chunk[chunkno].gap = 0; @@ -652,28 +639,28 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, HDmemset(oh->chunk[chunkno].image + old_size, 0, oh->chunk[chunkno].size - old_size); /* Move chunk 0 data up if the size flags changed */ - if(adjust_size_flags) + if (adjust_size_flags) HDmemmove(oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh), - oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) - extra_prfx_size, - old_size - (size_t)H5O_SIZEOF_HDR(oh) + extra_prfx_size); + oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) - extra_prfx_size, + old_size - (size_t)H5O_SIZEOF_HDR(oh) + extra_prfx_size); /* Spin through existing messages, adjusting them */ - for(u = 0; u < oh->nmesgs; u++) { + for (u = 0; u < oh->nmesgs; u++) { /* Adjust raw addresses for messages in this chunk to reflect new 'image' address */ - if(oh->mesg[u].chunkno == chunkno) + if (oh->mesg[u].chunkno == chunkno) oh->mesg[u].raw = oh->chunk[chunkno].image + extra_prfx_size + (oh->mesg[u].raw - old_image); /* Find continuation message which points to this chunk and adjust chunk's size */ /* (Chunk 0 doesn't have a continuation message that points to it, * its size is directly encoded in the object header) */ - if(chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) && - (((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) { - H5O_chunk_proxy_t *chk_proxy2 = NULL; /* Chunk that continuation message is in */ - hbool_t chk_dirtied2 = FALSE; /* Flag for unprotecting chunk */ - unsigned cont_chunkno = oh->mesg[u].chunkno; /* Chunk # for continuation message */ + if (chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) && + (((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) { + H5O_chunk_proxy_t *chk_proxy2 = NULL; /* Chunk that continuation message is in */ + hbool_t chk_dirtied2 = FALSE; /* Flag for unprotecting chunk */ + unsigned cont_chunkno = oh->mesg[u].chunkno; /* Chunk # for continuation message */ /* Protect chunk containing continuation message */ - if(NULL == (chk_proxy2 = H5O__chunk_protect(f, oh, cont_chunkno))) + if (NULL == (chk_proxy2 = H5O__chunk_protect(f, oh, cont_chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Adjust size in continuation message */ @@ -682,16 +669,16 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, /* Flag continuation message as dirty */ oh->mesg[u].dirty = TRUE; - chk_dirtied2 = TRUE; + chk_dirtied2 = TRUE; /* Release chunk containing continuation message */ - if(H5O__chunk_unprotect(f, chk_proxy2, chk_dirtied2) < 0) + if (H5O__chunk_unprotect(f, chk_proxy2, chk_dirtied2) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") } /* end if */ - } /* end for */ + } /* end for */ /* Resize the chunk in the cache */ - if(H5O__chunk_resize(oh, chk_proxy) < 0) + if (H5O__chunk_resize(oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize object header chunk") /* Set new message index */ @@ -699,13 +686,12 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, done: /* Release chunk */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_extend_chunk() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc_find_best_nonnull * @@ -735,13 +721,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, - H5O_msg_alloc_info_t *found_msg) +H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, H5O_msg_alloc_info_t *found_msg) { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - size_t cont_size; /* Continuation message size */ - size_t multi_size; /* Size of all the messages in the last chunk */ - unsigned u; /* Local index variable */ + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ + size_t cont_size; /* Continuation message size */ + size_t multi_size; /* Size of all the messages in the last chunk */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -762,89 +747,92 @@ H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, * ordering (although ordering is *not* guaranteed!). * */ - cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); + cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); multi_size = 0; - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { /* Don't consider continuation messages (for now) */ - if(H5O_CONT_ID != curr_msg->type->id) { - unsigned msg_chunkno = curr_msg->chunkno; /* Chunk that the message is in */ - uint8_t *end_chunk_data = (oh->chunk[msg_chunkno].image + oh->chunk[msg_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[msg_chunkno].gap); /* End of message data in chunk */ - uint8_t *end_msg = curr_msg->raw + curr_msg->raw_size; /* End of current message */ - size_t gap_size = 0; /* Size of gap after current message */ - size_t null_size = 0; /* Size of NULL message after current message */ - unsigned null_msgno = 0; /* Index of NULL message after current message */ - size_t total_size; /* Total size of available space "around" current message */ + if (H5O_CONT_ID != curr_msg->type->id) { + unsigned msg_chunkno = curr_msg->chunkno; /* Chunk that the message is in */ + uint8_t *end_chunk_data = + (oh->chunk[msg_chunkno].image + oh->chunk[msg_chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[msg_chunkno].gap); /* End of message data in chunk */ + uint8_t *end_msg = curr_msg->raw + curr_msg->raw_size; /* End of current message */ + size_t gap_size = 0; /* Size of gap after current message */ + size_t null_size = 0; /* Size of NULL message after current message */ + unsigned null_msgno = 0; /* Index of NULL message after current message */ + size_t total_size; /* Total size of available space "around" current message */ /* Check if the message is the last one in the chunk */ - if(end_msg == end_chunk_data) + if (end_msg == end_chunk_data) gap_size = oh->chunk[msg_chunkno].gap; else { - H5O_mesg_t *tmp_msg; /* Temp. pointer to message to operate on */ - unsigned v; /* Local index variable */ + H5O_mesg_t *tmp_msg; /* Temp. pointer to message to operate on */ + unsigned v; /* Local index variable */ /* Check for null message after this message, in same chunk */ - for(v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { - if(tmp_msg->type->id == H5O_NULL_ID && (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { + for (v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { + if (tmp_msg->type->id == H5O_NULL_ID && + (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { null_msgno = v; - null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; + null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; break; } /* end if */ /* XXX: Should also check for NULL message in front of current message... */ } /* end for */ - } /* end else */ + } /* end else */ /* Add up current message's total available space */ total_size = curr_msg->raw_size + gap_size + null_size; /* Check if message is large enough to hold continuation info */ - if(total_size >= cont_size) { - hbool_t better = FALSE; /* Whether the current message is better than a previous one */ + if (total_size >= cont_size) { + hbool_t better = FALSE; /* Whether the current message is better than a previous one */ /* Check for first message that can be moved */ - if(found_msg->msgno < 0) + if (found_msg->msgno < 0) better = TRUE; else { /* Prioritize moving non-attributes above attributes */ /* (Even attributes with an otherwise better fit */ - if(found_msg->id == H5O_ATTR_ID && curr_msg->type->id != H5O_ATTR_ID) + if (found_msg->id == H5O_ATTR_ID && curr_msg->type->id != H5O_ATTR_ID) better = TRUE; /* Either two attributes, or two non-attributes */ else { /* Take a smaller one */ - if(total_size < found_msg->total_size) + if (total_size < found_msg->total_size) better = TRUE; /* If they are the same size, choose the earliest one * in the chunk array */ /* (Could also bias toward message earlier / later * chunk in, but shouldn't be a big deal - QAK, 2016/10/21) */ - else if(total_size == found_msg->total_size) { - if(msg_chunkno < found_msg->chunkno) + else if (total_size == found_msg->total_size) { + if (msg_chunkno < found_msg->chunkno) better = TRUE; } /* end else-if */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* If we found a better message, keep its info */ - if(better) { - found_msg->msgno = (int)u; - found_msg->id = curr_msg->type->id; - found_msg->chunkno = msg_chunkno; - found_msg->gap_size = gap_size; - found_msg->null_size = null_size; + if (better) { + found_msg->msgno = (int)u; + found_msg->id = curr_msg->type->id; + found_msg->chunkno = msg_chunkno; + found_msg->gap_size = gap_size; + found_msg->null_size = null_size; found_msg->total_size = total_size; found_msg->null_msgno = null_msgno; } /* end if */ - } /* end if */ - else if(found_msg->msgno < 0 && msg_chunkno == oh->nchunks - 1) + } /* end if */ + else if (found_msg->msgno < 0 && msg_chunkno == oh->nchunks - 1) /* Keep track of the total size of smaller messages in the last * chunk, in case we need to move more than 1 message. */ multi_size += curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); } /* end if */ - } /* end for */ + } /* end for */ /* * If we must move some other message to make room for the null @@ -856,7 +844,7 @@ H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, * If all else fails, move every message in the last chunk. * */ - if(found_msg->msgno < 0) + if (found_msg->msgno < 0) *size += multi_size; else *size += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[found_msg->msgno].raw_size; @@ -864,7 +852,6 @@ H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, FUNC_LEAVE_NOAPI(SUCCEED) } /* H5O__alloc_find_best_nonnull() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc_chunk * @@ -884,19 +871,19 @@ H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, *------------------------------------------------------------------------- */ herr_t -H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, - const H5O_msg_alloc_info_t *found_msg, size_t *new_idx) +H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, const H5O_msg_alloc_info_t *found_msg, + size_t *new_idx) { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - H5O_chunk_proxy_t *chk_proxy; /* Chunk that message is in */ - size_t cont_size; /*continuation message size */ - size_t idx; /* Message number */ - uint8_t *p = NULL; /* Pointer into new chunk image */ - H5O_cont_t *cont = NULL; /*native continuation message */ - unsigned chunkno; /* Chunk allocated */ - haddr_t new_chunk_addr; /* Address of new chunk in file */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_mesg_t * curr_msg; /* Pointer to current message to operate on */ + H5O_chunk_proxy_t *chk_proxy; /* Chunk that message is in */ + size_t cont_size; /*continuation message size */ + size_t idx; /* Message number */ + uint8_t * p = NULL; /* Pointer into new chunk image */ + H5O_cont_t * cont = NULL; /*native continuation message */ + unsigned chunkno; /* Chunk allocated */ + haddr_t new_chunk_addr; /* Address of new chunk in file */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -919,37 +906,37 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, * on the chunk and the continuation chunk magic #. (which are only present * in later versions of the object header) */ - size += H5O_SIZEOF_CHKHDR_OH(oh); + size += H5O_SIZEOF_CHKHDR_OH(oh); /* Allocate space in file to hold the new chunk */ new_chunk_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)size); - if(!H5F_addr_defined(new_chunk_addr)) + if (!H5F_addr_defined(new_chunk_addr)) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "unable to allocate space for new chunk") /* Create the new chunk giving it a file address. */ - if(oh->nchunks >= oh->alloc_nchunks) { - size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ + if (oh->nchunks >= oh->alloc_nchunks) { + size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ H5O_chunk_t *x; - if(NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) + if (NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate larger chunk array, na = %zu", na) oh->alloc_nchunks = na; - oh->chunk = x; + oh->chunk = x; } /* end if */ H5_CHECKED_ASSIGN(chunkno, unsigned, oh->nchunks, size_t); oh->nchunks++; oh->chunk[chunkno].addr = new_chunk_addr; oh->chunk[chunkno].size = size; - oh->chunk[chunkno].gap = 0; - if(NULL == (oh->chunk[chunkno].image = p = H5FL_BLK_CALLOC(chunk_image, size))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate image for chunk, size = %zu", size) + oh->chunk[chunkno].gap = 0; + if (NULL == (oh->chunk[chunkno].image = p = H5FL_BLK_CALLOC(chunk_image, size))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate image for chunk, size = %zu", size) oh->chunk[chunkno].chunk_proxy = NULL; /* If this is a later version of the object header format, put the magic * # at the beginning of the chunk image. */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { H5MM_memcpy(p, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC); p += H5_SIZEOF_MAGIC; } /* end if */ @@ -958,30 +945,30 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, * Make sure we have enough space for all possible new messages * that could be generated below. */ - if(oh->nmesgs + 3 > oh->alloc_nmesgs) - if(H5O__alloc_msgs(oh, (size_t)3) < 0) + if (oh->nmesgs + 3 > oh->alloc_nmesgs) + if (H5O__alloc_msgs(oh, (size_t)3) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Check if we need to move multiple messages, in order to make room for the new message */ cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); - if(found_null >= oh->nmesgs) { - if(found_msg->msgno < 0) { + if (found_null >= oh->nmesgs) { + if (found_msg->msgno < 0) { /* Move all non-null messages in the last chunk to the new chunk. This * should be extremely rare so we don't care too much about minimizing * the space used. */ - H5O_mesg_t *null_msg; /* Pointer to new null message */ + H5O_mesg_t *null_msg; /* Pointer to new null message */ /* Protect last chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno - 1))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno - 1))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Copy each message to the new location */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) - if(curr_msg->chunkno == chunkno - 1) { - if(curr_msg->type->id == H5O_NULL_ID) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) + if (curr_msg->chunkno == chunkno - 1) { + if (curr_msg->type->id == H5O_NULL_ID) { /* Delete the null message */ - if(u < oh->nmesgs - 1) + if (u < oh->nmesgs - 1) HDmemmove(curr_msg, curr_msg + 1, ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end if */ @@ -990,30 +977,31 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, /* Copy the raw data */ H5MM_memcpy(p, curr_msg->raw - (size_t)H5O_SIZEOF_MSGHDR_OH(oh), - curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Update the message info */ curr_msg->chunkno = chunkno; - curr_msg->raw = p + H5O_SIZEOF_MSGHDR_OH(oh); + curr_msg->raw = p + H5O_SIZEOF_MSGHDR_OH(oh); /* Account for copied message in new chunk */ p += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size; size -= (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size; } /* end else */ - } /* end if */ + } /* end if */ /* Create a null message spanning the entire last chunk */ - found_null = oh->nmesgs++; - null_msg = &(oh->mesg[found_null]); - null_msg->type = H5O_MSG_NULL; - null_msg->dirty = TRUE; + found_null = oh->nmesgs++; + null_msg = &(oh->mesg[found_null]); + null_msg->type = H5O_MSG_NULL; + null_msg->dirty = TRUE; null_msg->native = NULL; - null_msg->raw = oh->chunk[chunkno - 1].image - + ((chunkno == 1) ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh)) - - H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); - null_msg->raw_size = oh->chunk[chunkno - 1].size - - ((chunkno == 1) ? (size_t)H5O_SIZEOF_HDR(oh) : (size_t)H5O_SIZEOF_CHKHDR_OH(oh)) - - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); + null_msg->raw = oh->chunk[chunkno - 1].image + + ((chunkno == 1) ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh)) - + H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); + null_msg->raw_size = + oh->chunk[chunkno - 1].size - + ((chunkno == 1) ? (size_t)H5O_SIZEOF_HDR(oh) : (size_t)H5O_SIZEOF_CHKHDR_OH(oh)) - + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); null_msg->chunkno = chunkno - 1; HDassert(null_msg->raw_size >= cont_size); @@ -1022,34 +1010,34 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, oh->chunk[chunkno - 1].gap = 0; /* Release chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) + if (H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") } /* end if */ else { /* Move message (that will be replaced with continuation message) * to new chunk, if necessary. */ - H5O_mesg_t *null_msg; /* Pointer to new null message */ + H5O_mesg_t *null_msg; /* Pointer to new null message */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[found_msg->msgno].chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[found_msg->msgno].chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Create null message for space that message to copy currently occupies */ - found_null = oh->nmesgs++; - null_msg = &(oh->mesg[found_null]); - null_msg->type = H5O_MSG_NULL; - null_msg->native = NULL; - null_msg->raw = oh->mesg[found_msg->msgno].raw; + found_null = oh->nmesgs++; + null_msg = &(oh->mesg[found_null]); + null_msg->type = H5O_MSG_NULL; + null_msg->native = NULL; + null_msg->raw = oh->mesg[found_msg->msgno].raw; null_msg->raw_size = oh->mesg[found_msg->msgno].raw_size; - null_msg->chunkno = oh->mesg[found_msg->msgno].chunkno; + null_msg->chunkno = oh->mesg[found_msg->msgno].chunkno; /* Copy the message to move (& its prefix) to its new location */ H5MM_memcpy(p, oh->mesg[found_msg->msgno].raw - H5O_SIZEOF_MSGHDR_OH(oh), - oh->mesg[found_msg->msgno].raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + oh->mesg[found_msg->msgno].raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Switch moved message to point to new location */ - oh->mesg[found_msg->msgno].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[found_msg->msgno].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[found_msg->msgno].chunkno = chunkno; /* Account for copied message in new chunk */ @@ -1057,25 +1045,28 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, size -= (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[found_msg->msgno].raw_size; /* Add any available space after the message to move to the new null message */ - if(found_msg->gap_size > 0) { + if (found_msg->gap_size > 0) { /* Absorb a gap after the moved message */ HDassert(oh->chunk[null_msg->chunkno].gap == found_msg->gap_size); null_msg->raw_size += found_msg->gap_size; oh->chunk[null_msg->chunkno].gap = 0; } /* end if */ - else if(found_msg->null_size > 0) { - H5O_mesg_t *old_null_msg = &oh->mesg[found_msg->null_msgno]; /* Pointer to NULL message to eliminate */ + else if (found_msg->null_size > 0) { + H5O_mesg_t *old_null_msg = + &oh->mesg[found_msg->null_msgno]; /* Pointer to NULL message to eliminate */ /* Absorb a null message after the moved message */ - HDassert((null_msg->raw + null_msg->raw_size) == (old_null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh))); + HDassert((null_msg->raw + null_msg->raw_size) == + (old_null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh))); null_msg->raw_size += found_msg->null_size; /* Release any information/memory for message */ H5O__msg_free_mesg(old_null_msg); /* Remove null message from list of messages */ - if(found_msg->null_msgno < (oh->nmesgs - 1)) - HDmemmove(old_null_msg, old_null_msg + 1, ((oh->nmesgs - 1) - found_msg->null_msgno) * sizeof(H5O_mesg_t)); + if (found_msg->null_msgno < (oh->nmesgs - 1)) + HDmemmove(old_null_msg, old_null_msg + 1, + ((oh->nmesgs - 1) - found_msg->null_msgno) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ @@ -1089,34 +1080,34 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, null_msg->dirty = TRUE; /* Release chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) + if (H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") } /* end if */ - } /* end if */ + } /* end if */ /* Create null message for [rest of] space in new chunk */ /* (account for chunk's magic # & checksum) */ - idx = oh->nmesgs++; - oh->mesg[idx].type = H5O_MSG_NULL; - oh->mesg[idx].dirty = TRUE; - oh->mesg[idx].native = NULL; - oh->mesg[idx].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); + idx = oh->nmesgs++; + oh->mesg[idx].type = H5O_MSG_NULL; + oh->mesg[idx].dirty = TRUE; + oh->mesg[idx].native = NULL; + oh->mesg[idx].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[idx].raw_size = size - (size_t)(H5O_SIZEOF_CHKHDR_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh)); - oh->mesg[idx].chunkno = chunkno; + oh->mesg[idx].chunkno = chunkno; /* Insert the new chunk into the cache */ - if(H5O__chunk_add(f, oh, chunkno, oh->mesg[found_null].chunkno) < 0) + if (H5O__chunk_add(f, oh, chunkno, oh->mesg[found_null].chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't add new chunk to cache") /* Initialize the continuation information */ - if(NULL == (cont = H5FL_MALLOC(H5O_cont_t))) + if (NULL == (cont = H5FL_MALLOC(H5O_cont_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - cont->addr = oh->chunk[chunkno].addr; - cont->size = oh->chunk[chunkno].size; + cont->addr = oh->chunk[chunkno].addr; + cont->size = oh->chunk[chunkno].size; cont->chunkno = chunkno; /* Split the null message and point at continuation message */ - if(H5O__alloc_null(f, oh, found_null, H5O_MSG_CONT, cont, cont_size) < 0) + if (H5O__alloc_null(f, oh, found_null, H5O_MSG_CONT, cont, cont_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't split null message") /* Set new message index value */ @@ -1126,7 +1117,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_chunk() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc_new_chunk * @@ -1165,10 +1155,10 @@ done: static herr_t H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t *new_idx) { - size_t cont_size; /*continuation message size */ - size_t idx; /* Message number */ - H5O_msg_alloc_info_t found_msg; /* Best fit non-null message */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t cont_size; /*continuation message size */ + size_t idx; /* Message number */ + H5O_msg_alloc_info_t found_msg; /* Best fit non-null message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1178,27 +1168,26 @@ H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t *new_idx) size = H5O_ALIGN_OH(oh, size); /* Find the smallest null message that could hold a continuation message */ - idx = oh->nmesgs; + idx = oh->nmesgs; cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); - if(H5O__alloc_find_best_null(oh, cont_size, &idx) < 0) + if (H5O__alloc_find_best_null(oh, cont_size, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "error while locating best null header message") /* If we couldn't find a null message, locate the best message to move to new chunk */ - if(idx >= oh->nmesgs) { + if (idx >= oh->nmesgs) { found_msg.msgno = -1; - if(H5O__alloc_find_best_nonnull(f, oh, &size, &found_msg) < 0) + if (H5O__alloc_find_best_nonnull(f, oh, &size, &found_msg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "error while locating best non-null header message") } /* end if */ /* Allocate and initialize new chunk in the file */ - if(H5O__alloc_chunk(f, oh, size, idx, &found_msg, new_idx) < 0) + if (H5O__alloc_chunk(f, oh, size, idx, &found_msg, new_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate new object header chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_new_chunk() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc_find_best_null * @@ -1216,8 +1205,8 @@ done: static herr_t H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx) { - size_t idx; /* Index of message which fits allocation */ - ssize_t found_null; /* Best fit null message */ + size_t idx; /* Index of message which fits allocation */ + ssize_t found_null; /* Best fit null message */ FUNC_ENTER_STATIC_NOERR @@ -1228,53 +1217,52 @@ H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx) /* Find the smallest null message that could hold the new object header message */ found_null = -1; - for(idx = 0; idx < oh->nmesgs; idx++) { - if(H5O_NULL_ID == oh->mesg[idx].type->id) { + for (idx = 0; idx < oh->nmesgs; idx++) { + if (H5O_NULL_ID == oh->mesg[idx].type->id) { /* If we found an exact fit, use it */ - if(oh->mesg[idx].raw_size == size) { + if (oh->mesg[idx].raw_size == size) { /* Keep first exact fit */ - if(found_null < 0) + if (found_null < 0) found_null = (ssize_t)idx; else /* If we've got more than one exact fit, choose the one in the earliest chunk */ - if(oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) { - found_null = (ssize_t)idx; + if (oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) { + found_null = (ssize_t)idx; - /* If we found an exact fit in object header chunk #0, we can get out */ - /* (Could extend this to look for earliest message in - * chunk #0 - QAK, 2016/10/21) - */ - if(0 == oh->mesg[idx].chunkno) - break; - } /* end if */ - } /* end if */ + /* If we found an exact fit in object header chunk #0, we can get out */ + /* (Could extend this to look for earliest message in + * chunk #0 - QAK, 2016/10/21) + */ + if (0 == oh->mesg[idx].chunkno) + break; + } /* end if */ + } /* end if */ /* Look for null message that's larger than needed */ - else if(oh->mesg[idx].raw_size > size) { + else if (oh->mesg[idx].raw_size > size) { /* Keep first one found */ - if(found_null < 0) + if (found_null < 0) found_null = (ssize_t)idx; else /* Check for better fit */ - if(oh->mesg[idx].raw_size < oh->mesg[found_null].raw_size) - found_null = (ssize_t)idx; - else { - /* If they are the same size, choose the one in the earliest chunk */ - if(oh->mesg[idx].raw_size == oh->mesg[found_null].raw_size) { - if(oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) - found_null = (ssize_t)idx; - } /* end if */ - } /* end else */ - } /* end else-if */ + if (oh->mesg[idx].raw_size < oh->mesg[found_null].raw_size) + found_null = (ssize_t)idx; + else { + /* If they are the same size, choose the one in the earliest chunk */ + if (oh->mesg[idx].raw_size == oh->mesg[found_null].raw_size) { + if (oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) + found_null = (ssize_t)idx; + } /* end if */ + } /* end else */ + } /* end else-if */ /* else: Ignore too-small null messages */ } /* end if */ - } /* end for */ - if(found_null >= 0) + } /* end for */ + if (found_null >= 0) *mesg_idx = (size_t)found_null; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5O__alloc_find_best_null() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc * @@ -1289,8 +1277,7 @@ H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx) *------------------------------------------------------------------------- */ herr_t -H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - const void *mesg, size_t *mesg_idx) +H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, const void *mesg, size_t *mesg_idx) { size_t raw_size; /* Raw size of message */ size_t aligned_size; /* Size of message including alignment */ @@ -1307,20 +1294,20 @@ H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, /* Compute the size needed to store the message in the object header */ raw_size = (type->raw_size)(f, FALSE, mesg); - if(0 == raw_size) + if (0 == raw_size) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "can't compute object header message size") - if(raw_size >= H5O_MESG_MAX_SIZE) + if (raw_size >= H5O_MESG_MAX_SIZE) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "object header message is too large") aligned_size = H5O_ALIGN_OH(oh, raw_size); /* Find the smallest null message that could hold the new object header message */ idx = oh->nmesgs; - if(H5O__alloc_find_best_null(oh, aligned_size, &idx) < 0) + if (H5O__alloc_find_best_null(oh, aligned_size, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "error while locating best null header message") /* if we didn't find one, then allocate more header space */ - if(idx >= oh->nmesgs) { - unsigned chunkno; + if (idx >= oh->nmesgs) { + unsigned chunkno; /* check to see if we can extend one of the chunks. If we can, * do so. Otherwise, we will have to allocate a new chunk. @@ -1328,28 +1315,28 @@ H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, * Note that in this new version of this function, all chunks * must have file space allocated to them. */ - for(chunkno = 0; chunkno < oh->nchunks; chunkno++) { - htri_t tri_result; /* Status from attempting to extend chunk */ + for (chunkno = 0; chunkno < oh->nchunks; chunkno++) { + htri_t tri_result; /* Status from attempting to extend chunk */ - if((tri_result = H5O__alloc_extend_chunk(f, oh, chunkno, raw_size, &idx)) < 0) + if ((tri_result = H5O__alloc_extend_chunk(f, oh, chunkno, raw_size, &idx)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTEXTEND, FAIL, "can't extend existing chunk") - if(tri_result == TRUE) - break; + if (tri_result == TRUE) + break; } /* end for */ /* If we were not able to extend a chunk, create a new one */ - if(idx >= oh->nmesgs) - if(H5O__alloc_new_chunk(f, oh, raw_size, &idx) < 0) + if (idx >= oh->nmesgs) + if (H5O__alloc_new_chunk(f, oh, raw_size, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create a new object header data chunk") } /* end if */ HDassert(idx < oh->nmesgs); /* Split the null message and point at continuation message */ - if(H5O__alloc_null(f, oh, idx, type, NULL, aligned_size) < 0) + if (H5O__alloc_null(f, oh, idx, type, NULL, aligned_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't split null message") /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") /* Set message index value */ @@ -1359,7 +1346,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc() */ - /*------------------------------------------------------------------------- * * Function: H5O__release_mesg @@ -1377,9 +1363,9 @@ done: herr_t H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1389,13 +1375,14 @@ H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) HDassert(mesg); /* Check if we should operate on the message */ - if(adj_link) + if (adj_link) /* Free any space referred to in the file from this message */ - if(H5O__delete_mesg(f, oh, mesg) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") + if (H5O__delete_mesg(f, oh, mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, + "unable to delete file space for object header message") /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, mesg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, mesg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Free any native information */ @@ -1403,7 +1390,8 @@ H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) /* Change message type to nil and zero it */ mesg->type = H5O_MSG_NULL; - HDassert(mesg->raw + mesg->raw_size <= (oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[mesg->chunkno].gap)); + HDassert(mesg->raw + mesg->raw_size <= (oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[mesg->chunkno].gap)); HDmemset(mesg->raw, 0, mesg->raw_size); /* Clear message flags */ @@ -1414,23 +1402,23 @@ H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) chk_dirtied = TRUE; /* Check if chunk has a gap currently */ - if(oh->chunk[mesg->chunkno].gap) { + if (oh->chunk[mesg->chunkno].gap) { /* Eliminate the gap in the chunk */ - if(H5O__eliminate_gap(oh, &chk_dirtied, mesg, - ((oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[mesg->chunkno].gap)), - oh->chunk[mesg->chunkno].gap) < 0) + if (H5O__eliminate_gap(oh, &chk_dirtied, mesg, + ((oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[mesg->chunkno].gap)), + oh->chunk[mesg->chunkno].gap) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") } /* end if */ done: /* Release chunk, if not already done */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__release_mesg() */ - /*------------------------------------------------------------------------- * Function: H5O__move_cont * @@ -1447,11 +1435,11 @@ done: static htri_t H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that continuation message is in */ - H5O_mesg_t *cont_msg; /* Pointer to the continuation message */ - unsigned deleted_chunkno; /* Chunk # to delete */ - hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */ - htri_t ret_value = TRUE; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that continuation message is in */ + H5O_mesg_t * cont_msg; /* Pointer to the continuation message */ + unsigned deleted_chunkno; /* Chunk # to delete */ + hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -1465,23 +1453,23 @@ H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) deleted_chunkno = ((H5O_cont_t *)(cont_msg->native))->chunkno; /* Check if continuation message is pointing to the last chunk */ - if(deleted_chunkno == (oh->nchunks - 1)) { - size_t nonnull_size; /* Total size of nonnull messages in the chunk pointed to by cont message */ - H5O_mesg_t *curr_msg; /* Pointer to the current message to operate on */ - size_t gap_size; /* Size of gap produced */ - size_t v; /* Local index variable */ + if (deleted_chunkno == (oh->nchunks - 1)) { + size_t nonnull_size; /* Total size of nonnull messages in the chunk pointed to by cont message */ + H5O_mesg_t *curr_msg; /* Pointer to the current message to operate on */ + size_t gap_size; /* Size of gap produced */ + size_t v; /* Local index variable */ /* Spin through messages */ nonnull_size = 0; - for(v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) { - if(curr_msg->chunkno == deleted_chunkno) { + for (v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) { + if (curr_msg->chunkno == deleted_chunkno) { /* Find size of all non-null messages in the chunk pointed to by the continuation message */ - if(curr_msg->type->id != H5O_NULL_ID) { + if (curr_msg->type->id != H5O_NULL_ID) { HDassert(curr_msg->type->id != H5O_CONT_ID); nonnull_size += curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Size of gap in chunk w/continuation message */ gap_size = oh->chunk[cont_msg->chunkno].gap; @@ -1490,48 +1478,49 @@ H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) /* (Could count any null messages in the chunk w/the continuation * message also, but that is pretty complex. -QAK) */ - if(nonnull_size && nonnull_size <= (gap_size + cont_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh))) { - uint8_t *move_start, *move_end; /* Pointers to area of messages to move */ - unsigned cont_chunkno; /* Chunk number for continuation message */ + if (nonnull_size && + nonnull_size <= (gap_size + cont_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh))) { + uint8_t *move_start, *move_end; /* Pointers to area of messages to move */ + unsigned cont_chunkno; /* Chunk number for continuation message */ /* Get continuation info */ - move_start = cont_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); - move_end = cont_msg->raw + cont_msg->raw_size; + move_start = cont_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); + move_end = cont_msg->raw + cont_msg->raw_size; cont_chunkno = cont_msg->chunkno; /* Convert continuation message into a null message. Do not delete * the target chunk yet, so we can still copy messages from it. */ - if(H5O__release_mesg(f, oh, cont_msg, FALSE) < 0) + if (H5O__release_mesg(f, oh, cont_msg, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to convert into null message") /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Move message(s) forward into continuation message */ - for(v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) + for (v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) /* Look for messages in chunk to delete */ - if(curr_msg->chunkno == deleted_chunkno) { + if (curr_msg->chunkno == deleted_chunkno) { /* Move messages out of chunk to delete */ - if(curr_msg->type->id != H5O_NULL_ID) { - size_t move_size; /* Size of the message to be moved */ + if (curr_msg->type->id != H5O_NULL_ID) { + size_t move_size; /* Size of the message to be moved */ /* Compute size of message to move */ move_size = curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Move message out of deleted chunk */ H5MM_memcpy(move_start, curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), move_size); - curr_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); + curr_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); curr_msg->chunkno = cont_chunkno; - chk_dirtied = TRUE; + chk_dirtied = TRUE; /* Adjust location to move messages to */ move_start += move_size; } /* end else */ - } /* end if */ + } /* end if */ /* Delete the target chunk */ - if(H5O__chunk_delete(f, oh, deleted_chunkno) < 0) + if (H5O__chunk_delete(f, oh, deleted_chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove chunk from cache") HDassert(move_start <= (move_end + gap_size)); @@ -1539,65 +1528,66 @@ H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) /* Check if there is space remaining in the continuation message */ /* (The remaining space can be gap or a null message) */ gap_size += (size_t)(move_end - move_start); - if(gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { + if (gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { /* Adjust size of null (was continuation) message */ cont_msg->raw_size = gap_size - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - cont_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); - cont_msg->dirty = TRUE; - chk_dirtied = TRUE; + cont_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); + cont_msg->dirty = TRUE; + chk_dirtied = TRUE; } /* end if */ else { /* Check if there is space that should be a gap */ - if(gap_size > 0) { + if (gap_size > 0) { /* Convert remnant into gap in chunk */ - if(H5O__add_gap(f, oh, cont_chunkno, &chk_dirtied, cont_u, move_start, gap_size) < 0) + if (H5O__add_gap(f, oh, cont_chunkno, &chk_dirtied, cont_u, move_start, gap_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert gap in chunk") } /* end if */ /* Release any information/memory for continuation message */ H5O__msg_free_mesg(cont_msg); - if(cont_u < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[cont_u], &oh->mesg[cont_u + 1], ((oh->nmesgs - 1) - cont_u) * sizeof(H5O_mesg_t)); + if (cont_u < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[cont_u], &oh->mesg[cont_u + 1], + ((oh->nmesgs - 1) - cont_u) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end else */ /* Move message(s) forward into continuation message */ /* Note: unsigned v wrapping around at the end */ - for(v = oh->nmesgs - 1, curr_msg = &oh->mesg[v]; v < oh->nmesgs; v--, curr_msg--) + for (v = oh->nmesgs - 1, curr_msg = &oh->mesg[v]; v < oh->nmesgs; v--, curr_msg--) /* Look for messages in chunk to delete */ - if(curr_msg->chunkno == deleted_chunkno) { + if (curr_msg->chunkno == deleted_chunkno) { /* Remove all null messages in deleted chunk from list of messages */ - if(curr_msg->type->id == H5O_NULL_ID) { + if (curr_msg->type->id == H5O_NULL_ID) { /* Release any information/memory for message */ H5O__msg_free_mesg(curr_msg); chk_dirtied = TRUE; /* Remove from message list */ - if(v < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); + if (v < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], + ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end if */ - } /* end if */ + } /* end if */ /* Remove chunk from list of chunks */ oh->chunk[deleted_chunkno].image = H5FL_BLK_FREE(chunk_image, oh->chunk[deleted_chunkno].image); oh->nchunks--; - } /* end if */ + } /* end if */ else ret_value = FALSE; - } /* end if */ + } /* end if */ else ret_value = FALSE; done: /* Release chunk, if not already done */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__move_cont() */ - /*------------------------------------------------------------------------- * * Function: H5O__move_msgs_forward @@ -1615,14 +1605,14 @@ done: static htri_t H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) { - H5O_chunk_proxy_t *null_chk_proxy = NULL; /* Chunk that null message is in */ - H5O_chunk_proxy_t *curr_chk_proxy = NULL; /* Chunk that message is in */ - H5O_chunk_proxy_t *cont_targ_chk_proxy = NULL; /* Chunk that continuation message points to */ - hbool_t null_chk_dirtied = FALSE; /* Flags for unprotecting null chunk */ - hbool_t curr_chk_dirtied = FALSE; /* Flags for unprotecting curr chunk */ - hbool_t packed_msg; /* Flag to indicate that messages were packed */ - hbool_t did_packing = FALSE; /* Whether any messages were packed */ - htri_t ret_value = FAIL; /* Return value */ + H5O_chunk_proxy_t *null_chk_proxy = NULL; /* Chunk that null message is in */ + H5O_chunk_proxy_t *curr_chk_proxy = NULL; /* Chunk that message is in */ + H5O_chunk_proxy_t *cont_targ_chk_proxy = NULL; /* Chunk that continuation message points to */ + hbool_t null_chk_dirtied = FALSE; /* Flags for unprotecting null chunk */ + hbool_t curr_chk_dirtied = FALSE; /* Flags for unprotecting curr chunk */ + hbool_t packed_msg; /* Flag to indicate that messages were packed */ + hbool_t did_packing = FALSE; /* Whether any messages were packed */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC @@ -1634,54 +1624,59 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) * add a list of messages to each chunk -QAK) */ do { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - unsigned u; /* Local index variable */ + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ + unsigned u; /* Local index variable */ /* Reset packed messages flag */ packed_msg = FALSE; /* Scan through messages for messages that can be moved earlier in chunks */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - if(H5O_NULL_ID == curr_msg->type->id) { - H5O_chunk_t *chunk; /* Pointer to chunk that null message is in */ + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + if (H5O_NULL_ID == curr_msg->type->id) { + H5O_chunk_t *chunk; /* Pointer to chunk that null message is in */ /* Check if null message is not last in chunk */ chunk = &(oh->chunk[curr_msg->chunkno]); - if((curr_msg->raw + curr_msg->raw_size) - != ((chunk->image + chunk->size) - (H5O_SIZEOF_CHKSUM_OH(oh) + chunk->gap))) { - H5O_mesg_t *nonnull_msg; /* Pointer to current message to operate on */ - unsigned v; /* Local index variable */ - - /* Loop over messages again, looking for the message in the chunk after the null message */ - for(v = 0, nonnull_msg = &oh->mesg[0]; v < oh->nmesgs; v++, nonnull_msg++) { + if ((curr_msg->raw + curr_msg->raw_size) != + ((chunk->image + chunk->size) - (H5O_SIZEOF_CHKSUM_OH(oh) + chunk->gap))) { + H5O_mesg_t *nonnull_msg; /* Pointer to current message to operate on */ + unsigned v; /* Local index variable */ + + /* Loop over messages again, looking for the message in the chunk after the null message + */ + for (v = 0, nonnull_msg = &oh->mesg[0]; v < oh->nmesgs; v++, nonnull_msg++) { /* Locate message that is immediately after the null message */ - if((curr_msg->chunkno == nonnull_msg->chunkno) && - ((curr_msg->raw + curr_msg->raw_size) == (nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)))) { + if ((curr_msg->chunkno == nonnull_msg->chunkno) && + ((curr_msg->raw + curr_msg->raw_size) == + (nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)))) { /* Don't swap messages if the second message is also a null message */ /* (We'll merge them together later, in another routine) */ - if(H5O_NULL_ID != nonnull_msg->type->id) { + if (H5O_NULL_ID != nonnull_msg->type->id) { /* Protect chunk */ - if(NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + if (NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, + "unable to load object header chunk") /* Copy raw data for non-null message to new location */ HDmemmove(curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), - nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), nonnull_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), + nonnull_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Adjust non-null message's offset in chunk */ nonnull_msg->raw = curr_msg->raw; /* Adjust null message's offset in chunk */ - curr_msg->raw = nonnull_msg->raw + - nonnull_msg->raw_size + H5O_SIZEOF_MSGHDR_OH(oh); + curr_msg->raw = + nonnull_msg->raw + nonnull_msg->raw_size + H5O_SIZEOF_MSGHDR_OH(oh); /* Mark null message dirty */ /* (since we need to re-encode its message header) */ curr_msg->dirty = TRUE; /* Release chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, null_chk_proxy, TRUE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + if (H5O__chunk_unprotect(f, null_chk_proxy, TRUE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") null_chk_proxy = NULL; /* Set the flag to indicate that the null message @@ -1694,56 +1689,55 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) /* Break out of loop */ break; } /* end if */ - } /* end for */ + } /* end for */ /* Should have been message after null message */ HDassert(v < oh->nmesgs); } /* end if */ - } /* end if */ + } /* end if */ else { - H5O_mesg_t *null_msg; /* Pointer to current message to operate on */ - size_t v; /* Local index variable */ + H5O_mesg_t *null_msg; /* Pointer to current message to operate on */ + size_t v; /* Local index variable */ /* Check if messages in chunk pointed to can replace continuation message */ - if(H5O_CONT_ID == curr_msg->type->id) { - htri_t status; /* Status from moving messages */ + if (H5O_CONT_ID == curr_msg->type->id) { + htri_t status; /* Status from moving messages */ - if((status = H5O__move_cont(f, oh, u)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "Error in moving messages into cont message") - else if(status > 0) { /* Message(s) got moved into "continuation" message */ + if ((status = H5O__move_cont(f, oh, u)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, + "Error in moving messages into cont message") + else if (status > 0) { /* Message(s) got moved into "continuation" message */ packed_msg = TRUE; break; } /* end else-if */ - } /* end if */ + } /* end if */ /* Loop over messages again, looking for large enough null message in earlier chunk */ - for(v = 0, null_msg = &oh->mesg[0]; v < oh->nmesgs; v++, null_msg++) { - if(H5O_NULL_ID == null_msg->type->id && curr_msg->chunkno > null_msg->chunkno - && curr_msg->raw_size <= null_msg->raw_size) { - unsigned old_chunkno; /* Old message information */ + for (v = 0, null_msg = &oh->mesg[0]; v < oh->nmesgs; v++, null_msg++) { + if (H5O_NULL_ID == null_msg->type->id && curr_msg->chunkno > null_msg->chunkno && + curr_msg->raw_size <= null_msg->raw_size) { + unsigned old_chunkno; /* Old message information */ uint8_t *old_raw; /* Keep old information about non-null message */ old_chunkno = curr_msg->chunkno; - old_raw = curr_msg->raw; + old_raw = curr_msg->raw; /* Protect chunks */ - if(NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, null_msg->chunkno))) + if (NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, null_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") - if(NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) + if (NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* If the message being moved is a continuation * message and we are doing SWMR writes, we must * update the flush dependencies */ - if(oh->swmr_write && (H5O_CONT_ID == curr_msg->type->id)) { - void *null_chk_mdc_obj; /* The metadata cache object for the null_msg chunk */ + if (oh->swmr_write && (H5O_CONT_ID == curr_msg->type->id)) { + void *null_chk_mdc_obj; /* The metadata cache object for the null_msg chunk */ /* Point to the metadata cache object for the * null message chunk, oh if in chunk 0 or the * proxy otherwise */ - null_chk_mdc_obj = (null_msg->chunkno == 0 - ? (void *)oh - : (void *)null_chk_proxy); + null_chk_mdc_obj = (null_msg->chunkno == 0 ? (void *)oh : (void *)null_chk_proxy); /* The other chunks involved should never be * chunk 0 */ @@ -1751,102 +1745,119 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) HDassert(((H5O_cont_t *)(curr_msg->native))->chunkno > 0); /* Protect continuation message target chunk */ - if(NULL == (cont_targ_chk_proxy = H5O__chunk_protect(f, oh, ((H5O_cont_t *)(curr_msg->native))->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + if (NULL == (cont_targ_chk_proxy = H5O__chunk_protect( + f, oh, ((H5O_cont_t *)(curr_msg->native))->chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, + "unable to load object header chunk") /* Check for flush dependency on previous continuation chunk */ /* (As opposed to chunk 0) */ - if(cont_targ_chk_proxy->fd_parent) { + if (cont_targ_chk_proxy->fd_parent) { /* Remove flush dependency on old continuation * message chunk */ HDassert(cont_targ_chk_proxy); HDassert(curr_chk_proxy); HDassert((void *)curr_chk_proxy == cont_targ_chk_proxy->fd_parent); - if(H5AC_destroy_flush_dependency(curr_chk_proxy, cont_targ_chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + if (H5AC_destroy_flush_dependency(curr_chk_proxy, cont_targ_chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency") cont_targ_chk_proxy->fd_parent = NULL; } /* end if */ /* Avoid (another) flush dependency on chunk 0 */ - if(0 != null_msg->chunkno) { + if (0 != null_msg->chunkno) { /* Sanity checks */ HDassert(null_chk_mdc_obj); - HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->magic == + H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->type); - HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->type->id == H5AC_OHDR_CHK_ID); + HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->type->id == + H5AC_OHDR_CHK_ID); /* Create flush dependency on new continuation * message chunk */ - if(H5AC_create_flush_dependency(null_chk_mdc_obj, cont_targ_chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + if (H5AC_create_flush_dependency(null_chk_mdc_obj, cont_targ_chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency") cont_targ_chk_proxy->fd_parent = null_chk_mdc_obj; } /* end if */ /* Unprotect continuation message target chunk */ - if(H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + if (H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") cont_targ_chk_proxy = NULL; } /* end if */ /* Copy raw data for non-null message to new chunk */ - H5MM_memcpy(null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + H5MM_memcpy(null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), + curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), + curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Point non-null message at null message's space */ curr_msg->chunkno = null_msg->chunkno; - curr_msg->raw = null_msg->raw; - curr_chk_dirtied = TRUE; + curr_msg->raw = null_msg->raw; + curr_chk_dirtied = TRUE; /* Change information for null message */ - if(curr_msg->raw_size == null_msg->raw_size) { + if (curr_msg->raw_size == null_msg->raw_size) { /* Point null message at old non-null space */ /* (Instead of freeing it and allocating new message) */ null_msg->chunkno = old_chunkno; - null_msg->raw = old_raw; + null_msg->raw = old_raw; /* Mark null message dirty */ - null_msg->dirty = TRUE; + null_msg->dirty = TRUE; null_chk_dirtied = TRUE; /* Release current chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - curr_chk_proxy = NULL; + if (H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") + curr_chk_proxy = NULL; curr_chk_dirtied = FALSE; /* Check for gap in null message's chunk */ - if(oh->chunk[old_chunkno].gap > 0) { + if (oh->chunk[old_chunkno].gap > 0) { /* Eliminate the gap in the chunk */ - if(H5O__eliminate_gap(oh, &null_chk_dirtied, null_msg, - ((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[old_chunkno].gap)), + if (H5O__eliminate_gap( + oh, &null_chk_dirtied, null_msg, + ((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[old_chunkno].gap)), oh->chunk[old_chunkno].gap) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, + "can't eliminate gap in chunk") } /* end if */ /* Release null chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - null_chk_proxy = NULL; + if (H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") + null_chk_proxy = NULL; null_chk_dirtied = FALSE; } /* end if */ else { - size_t new_null_msg; /* Message index for new null message */ + size_t new_null_msg; /* Message index for new null message */ /* Check if null message is large enough to still exist */ - if((null_msg->raw_size - curr_msg->raw_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { - size_t gap_size = null_msg->raw_size - curr_msg->raw_size; /* Size of gap produced */ + if ((null_msg->raw_size - curr_msg->raw_size) < + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { + size_t gap_size = + null_msg->raw_size - curr_msg->raw_size; /* Size of gap produced */ /* Adjust the size of the null message being eliminated */ null_msg->raw_size = curr_msg->raw_size; /* Mark null message dirty */ - null_msg->dirty = TRUE; + null_msg->dirty = TRUE; null_chk_dirtied = TRUE; /* Add the gap to the chunk */ - if(H5O__add_gap(f, oh, null_msg->chunkno, &null_chk_dirtied, v, null_msg->raw + null_msg->raw_size, gap_size) < 0) + if (H5O__add_gap(f, oh, null_msg->chunkno, &null_chk_dirtied, v, + null_msg->raw + null_msg->raw_size, gap_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert gap in chunk") /* Re-use message # for new null message taking place of non-null message */ @@ -1858,15 +1869,17 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) null_msg->raw_size -= curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Mark null message dirty */ - null_msg->dirty = TRUE; + null_msg->dirty = TRUE; null_chk_dirtied = TRUE; /* Create new null message for previous location of non-null message */ - if(oh->nmesgs >= oh->alloc_nmesgs) { - if(H5O__alloc_msgs(oh, (size_t)1) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") + if (oh->nmesgs >= oh->alloc_nmesgs) { + if (H5O__alloc_msgs(oh, (size_t)1) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "can't allocate more space for messages") - /* "Retarget" 'curr_msg' pointer into newly re-allocated array of messages */ + /* "Retarget" 'curr_msg' pointer into newly re-allocated array of messages + */ curr_msg = &oh->mesg[u]; } /* end if */ @@ -1875,35 +1888,40 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) } /* end else */ /* Release null message's chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - null_chk_proxy = NULL; + if (H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") + null_chk_proxy = NULL; null_chk_dirtied = FALSE; /* Initialize new null message to take over non-null message's location */ - oh->mesg[new_null_msg].type = H5O_MSG_NULL; - oh->mesg[new_null_msg].native = NULL; - oh->mesg[new_null_msg].raw = old_raw; + oh->mesg[new_null_msg].type = H5O_MSG_NULL; + oh->mesg[new_null_msg].native = NULL; + oh->mesg[new_null_msg].raw = old_raw; oh->mesg[new_null_msg].raw_size = curr_msg->raw_size; - oh->mesg[new_null_msg].chunkno = old_chunkno; + oh->mesg[new_null_msg].chunkno = old_chunkno; /* Mark new null message dirty */ oh->mesg[new_null_msg].dirty = TRUE; - curr_chk_dirtied = TRUE; + curr_chk_dirtied = TRUE; /* Check for gap in new null message's chunk */ - if(oh->chunk[old_chunkno].gap > 0) { + if (oh->chunk[old_chunkno].gap > 0) { /* Eliminate the gap in the chunk */ - if(H5O__eliminate_gap(oh, &curr_chk_dirtied, &oh->mesg[new_null_msg], - ((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[old_chunkno].gap)), + if (H5O__eliminate_gap( + oh, &curr_chk_dirtied, &oh->mesg[new_null_msg], + ((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[old_chunkno].gap)), oh->chunk[old_chunkno].gap) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, + "can't eliminate gap in chunk") } /* end if */ /* Release new null message's chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - curr_chk_proxy = NULL; + if (H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") + curr_chk_proxy = NULL; curr_chk_dirtied = FALSE; } /* end else */ @@ -1916,31 +1934,32 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) */ break; } /* end if */ - } /* end for */ + } /* end for */ /* If we packed messages, get out of loop and start over */ /* (Don't know if this has any benefit one way or the other -QAK) */ - if(packed_msg) + if (packed_msg) break; } /* end else */ - } /* end for */ + } /* end for */ /* If we did any packing, remember that */ - if(packed_msg) + if (packed_msg) did_packing = TRUE; - } while(packed_msg); + } while (packed_msg); /* Set return value */ ret_value = (htri_t)did_packing; done: - if(ret_value < 0) { - if(null_chk_proxy && H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) + if (ret_value < 0) { + if (null_chk_proxy && H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect null object header chunk") - if(curr_chk_proxy && H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) + if (curr_chk_proxy && H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect current object header chunk") - if(cont_targ_chk_proxy && H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect continuation message target object header chunk") + if (cont_targ_chk_proxy && H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect continuation message target object header chunk") } /* end if */ else HDassert(!null_chk_proxy && !curr_chk_proxy && !cont_targ_chk_proxy); @@ -1948,7 +1967,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__move_msgs_forward() */ - /*------------------------------------------------------------------------- * * Function: H5O__merge_null @@ -1966,9 +1984,9 @@ done: static htri_t H5O__merge_null(H5F_t *f, H5O_t *oh) { - hbool_t merged_msg; /* Flag to indicate that messages were merged */ - hbool_t did_merging = FALSE; /* Whether any messages were merged */ - htri_t ret_value = FAIL; /* Return value */ + hbool_t merged_msg; /* Flag to indicate that messages were merged */ + hbool_t did_merging = FALSE; /* Whether any messages were merged */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC @@ -1980,38 +1998,41 @@ H5O__merge_null(H5F_t *f, H5O_t *oh) * a list of messages to each chunk -QAK) */ do { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - unsigned u; /* Local index variable */ + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ + unsigned u; /* Local index variable */ /* Reset merged messages flag */ merged_msg = FALSE; /* Scan messages for adjacent null messages & merge them */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - if(H5O_NULL_ID == curr_msg->type->id) { - H5O_mesg_t *curr_msg2; /* Pointer to current message to operate on */ - unsigned v; /* Local index variable */ + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + if (H5O_NULL_ID == curr_msg->type->id) { + H5O_mesg_t *curr_msg2; /* Pointer to current message to operate on */ + unsigned v; /* Local index variable */ /* Should be no gaps in chunk with null message */ HDassert(oh->chunk[curr_msg->chunkno].gap == 0); /* Loop over messages again, looking for null message in same chunk */ - for(v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) { - if(u != v && H5O_NULL_ID == curr_msg2->type->id && curr_msg->chunkno == curr_msg2->chunkno) { - ssize_t adj_raw; /* Amount to adjust raw message pointer */ - size_t adj_raw_size; /* Amount to adjust raw message size */ + for (v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) { + if (u != v && H5O_NULL_ID == curr_msg2->type->id && + curr_msg->chunkno == curr_msg2->chunkno) { + ssize_t adj_raw; /* Amount to adjust raw message pointer */ + size_t adj_raw_size; /* Amount to adjust raw message size */ /* Check for second message after first message */ - if((curr_msg->raw + curr_msg->raw_size) == (curr_msg2->raw - H5O_SIZEOF_MSGHDR_OH(oh))) { + if ((curr_msg->raw + curr_msg->raw_size) == + (curr_msg2->raw - H5O_SIZEOF_MSGHDR_OH(oh))) { /* Extend first null message length to cover second null message */ - adj_raw = 0; + adj_raw = 0; adj_raw_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size; /* Message has been merged */ merged_msg = TRUE; } /* end if */ /* Check for second message before first message */ - else if((curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == (curr_msg2->raw + curr_msg2->raw_size)) { + else if ((curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == + (curr_msg2->raw + curr_msg2->raw_size)) { /* Adjust first message address and extend length to cover second message */ adj_raw = -((ssize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size)); adj_raw_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size; @@ -2021,16 +2042,17 @@ H5O__merge_null(H5F_t *f, H5O_t *oh) } /* end if */ /* Second message has been merged, delete it */ - if(merged_msg) { - H5O_chunk_proxy_t *curr_chk_proxy; /* Chunk that message is in */ - htri_t result; + if (merged_msg) { + H5O_chunk_proxy_t *curr_chk_proxy; /* Chunk that message is in */ + htri_t result; /* Release any information/memory for second message */ H5O__msg_free_mesg(curr_msg2); /* Protect chunk */ - if(NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + if (NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, + "unable to load object header chunk") /* Adjust first message address and extend length to cover second message */ curr_msg->raw += adj_raw; @@ -2040,45 +2062,48 @@ H5O__merge_null(H5F_t *f, H5O_t *oh) curr_msg->dirty = TRUE; /* Release new null message's chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, curr_chk_proxy, TRUE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + if (H5O__chunk_unprotect(f, curr_chk_proxy, TRUE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") /* Remove second message from list of messages */ - if(v < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); + if (v < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], + ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ oh->nmesgs--; - /* The merge null message might span the entire chunk: scan for empty chunk to remove */ - if((result = H5O__remove_empty_chunks(f, oh)) < 0) + /* The merge null message might span the entire chunk: scan for empty chunk to + * remove */ + if ((result = H5O__remove_empty_chunks(f, oh)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't remove empty chunk") - else if(result > 0) + else if (result > 0) /* Get out of loop */ break; /* If the merged message is too large, shrink the chunk */ - if(curr_msg->raw_size >= H5O_MESG_MAX_SIZE) - if(H5O__alloc_shrink_chunk(f, oh, curr_msg->chunkno) < 0) + if (curr_msg->raw_size >= H5O_MESG_MAX_SIZE) + if (H5O__alloc_shrink_chunk(f, oh, curr_msg->chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "unable to shrink chunk") /* Get out of loop */ break; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Get out of loop if we merged messages */ - if(merged_msg) + if (merged_msg) break; } /* end if */ - } /* end for */ + } /* end for */ /* If we did any merging, remember that */ - if(merged_msg) + if (merged_msg) did_merging = TRUE; - } while(merged_msg); + } while (merged_msg); /* Set return value */ ret_value = (htri_t)did_merging; @@ -2087,7 +2112,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__merge_null() */ - /*------------------------------------------------------------------------- * * Function: H5O__remove_empty_chunks @@ -2109,9 +2133,9 @@ done: static htri_t H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) { - hbool_t deleted_chunk; /* Whether to a chunk was deleted */ - hbool_t did_deleting = FALSE; /* Whether any chunks were deleted */ - htri_t ret_value = FAIL; /* Return value */ + hbool_t deleted_chunk; /* Whether to a chunk was deleted */ + hbool_t did_deleting = FALSE; /* Whether any chunks were deleted */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC @@ -2120,39 +2144,39 @@ H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) /* Loop until no chunks are freed */ do { - H5O_mesg_t *null_msg; /* Pointer to null message found */ - H5O_mesg_t *cont_msg; /* Pointer to continuation message found */ - unsigned u, v; /* Local index variables */ + H5O_mesg_t *null_msg; /* Pointer to null message found */ + H5O_mesg_t *cont_msg; /* Pointer to continuation message found */ + unsigned u, v; /* Local index variables */ /* Reset 'chunk deleted' flag */ deleted_chunk = FALSE; /* Scan messages for null messages that fill an entire chunk */ - for(u = 0, null_msg = &oh->mesg[0]; u < oh->nmesgs; u++, null_msg++) { + for (u = 0, null_msg = &oh->mesg[0]; u < oh->nmesgs; u++, null_msg++) { /* If a null message takes up an entire object header chunk (and * its not the "base" chunk), delete that chunk from object header */ - if(H5O_NULL_ID == null_msg->type->id && null_msg->chunkno > 0 && - ((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + null_msg->raw_size) - == (oh->chunk[null_msg->chunkno].size - H5O_SIZEOF_CHKHDR_OH(oh))) { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - unsigned null_msg_no; /* Message # for null message */ - unsigned deleted_chunkno; /* Chunk # to delete */ + if (H5O_NULL_ID == null_msg->type->id && null_msg->chunkno > 0 && + ((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + null_msg->raw_size) == + (oh->chunk[null_msg->chunkno].size - H5O_SIZEOF_CHKHDR_OH(oh))) { + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ + unsigned null_msg_no; /* Message # for null message */ + unsigned deleted_chunkno; /* Chunk # to delete */ /* Locate continuation message that points to chunk */ - for(v = 0, cont_msg = &oh->mesg[0]; v < oh->nmesgs; v++, cont_msg++) { - if(H5O_CONT_ID == cont_msg->type->id) { + for (v = 0, cont_msg = &oh->mesg[0]; v < oh->nmesgs; v++, cont_msg++) { + if (H5O_CONT_ID == cont_msg->type->id) { /* Decode current continuation message if necessary */ H5O_LOAD_NATIVE(f, 0, oh, cont_msg, FAIL) /* Check if the chunkno needs to be set */ /* (should only occur when the continuation message is first decoded) */ - if(0 == ((H5O_cont_t *)(cont_msg->native))->chunkno) { - unsigned w; /* Local index variable */ + if (0 == ((H5O_cont_t *)(cont_msg->native))->chunkno) { + unsigned w; /* Local index variable */ /* Find chunk that this continuation message points to */ - for(w = 0; w < oh->nchunks; w++) - if(oh->chunk[w].addr == ((H5O_cont_t *)(cont_msg->native))->addr) { + for (w = 0; w < oh->nchunks; w++) + if (oh->chunk[w].addr == ((H5O_cont_t *)(cont_msg->native))->addr) { ((H5O_cont_t *)(cont_msg->native))->chunkno = w; break; } /* end if */ @@ -2160,21 +2184,21 @@ H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) } /* end if */ /* Check for correct chunk to delete */ - if(oh->chunk[null_msg->chunkno].addr == ((H5O_cont_t *)(cont_msg->native))->addr) + if (oh->chunk[null_msg->chunkno].addr == ((H5O_cont_t *)(cont_msg->native))->addr) break; } /* end if */ - } /* end for */ + } /* end for */ /* Must be a continuation message that points to chunk containing null message */ HDassert(v < oh->nmesgs); HDassert(cont_msg); HDassert(((H5O_cont_t *)(cont_msg->native))->chunkno == null_msg->chunkno); /* Initialize information about null message */ - null_msg_no = u; + null_msg_no = u; deleted_chunkno = null_msg->chunkno; /* Convert continuation message into a null message */ - if(H5O__release_mesg(f, oh, cont_msg, TRUE) < 0) + if (H5O__release_mesg(f, oh, cont_msg, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to convert into null message") /* @@ -2182,27 +2206,31 @@ H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) */ /* Free memory for chunk image */ - oh->chunk[null_msg->chunkno].image = H5FL_BLK_FREE(chunk_image, oh->chunk[null_msg->chunkno].image); + oh->chunk[null_msg->chunkno].image = + H5FL_BLK_FREE(chunk_image, oh->chunk[null_msg->chunkno].image); /* Remove chunk from list of chunks */ - if(null_msg->chunkno < (oh->nchunks - 1)) { - HDmemmove(&oh->chunk[null_msg->chunkno], &oh->chunk[null_msg->chunkno + 1], ((oh->nchunks - 1) - null_msg->chunkno) * sizeof(H5O_chunk_t)); + if (null_msg->chunkno < (oh->nchunks - 1)) { + HDmemmove(&oh->chunk[null_msg->chunkno], &oh->chunk[null_msg->chunkno + 1], + ((oh->nchunks - 1) - null_msg->chunkno) * sizeof(H5O_chunk_t)); /* Adjust chunk number for any chunk proxies that are in the cache */ - for(u = null_msg->chunkno; u < (oh->nchunks - 1); u++) { - unsigned chk_proxy_status = 0; /* Metadata cache status of chunk proxy for chunk */ + for (u = null_msg->chunkno; u < (oh->nchunks - 1); u++) { + unsigned chk_proxy_status = 0; /* Metadata cache status of chunk proxy for chunk */ /* Check the chunk proxy's status in the metadata cache */ - if(H5AC_get_entry_status(f, oh->chunk[u].addr, &chk_proxy_status) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check metadata cache status for chunk proxy") + if (H5AC_get_entry_status(f, oh->chunk[u].addr, &chk_proxy_status) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, + "unable to check metadata cache status for chunk proxy") /* If the entry is in the cache, update its chunk index */ - if(chk_proxy_status & H5AC_ES__IN_CACHE) { - if(H5O__chunk_update_idx(f, oh, u) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update index for chunk proxy") + if (chk_proxy_status & H5AC_ES__IN_CACHE) { + if (H5O__chunk_update_idx(f, oh, u) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, + "unable to update index for chunk proxy") } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* Decrement # of chunks */ /* (Don't bother reducing size of chunk array for now -QAK) */ @@ -2216,35 +2244,36 @@ H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) H5O__msg_free_mesg(null_msg); /* Remove null message from list of messages */ - if(null_msg_no < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[null_msg_no], &oh->mesg[null_msg_no + 1], ((oh->nmesgs - 1) - null_msg_no) * sizeof(H5O_mesg_t)); + if (null_msg_no < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[null_msg_no], &oh->mesg[null_msg_no + 1], + ((oh->nmesgs - 1) - null_msg_no) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ oh->nmesgs--; /* Adjust chunk # for messages in chunks after deleted chunk */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { /* Sanity check - there should be no messages in deleted chunk */ HDassert(curr_msg->chunkno != deleted_chunkno); /* Adjust chunk index for messages in later chunks */ - if(curr_msg->chunkno > deleted_chunkno) + if (curr_msg->chunkno > deleted_chunkno) curr_msg->chunkno--; /* Check for continuation message */ - if(H5O_CONT_ID == curr_msg->type->id) { + if (H5O_CONT_ID == curr_msg->type->id) { /* Decode current continuation message if necessary */ H5O_LOAD_NATIVE(f, 0, oh, curr_msg, FAIL) /* Check if the chunkno needs to be set */ /* (should only occur when the continuation message is first decoded) */ - if(0 == ((H5O_cont_t *)(curr_msg->native))->chunkno) { - unsigned w; /* Local index variable */ + if (0 == ((H5O_cont_t *)(curr_msg->native))->chunkno) { + unsigned w; /* Local index variable */ /* Find chunk that this continuation message points to */ - for(w = 0; w < oh->nchunks; w++) - if(oh->chunk[w].addr == ((H5O_cont_t *)(curr_msg->native))->addr) { + for (w = 0; w < oh->nchunks; w++) + if (oh->chunk[w].addr == ((H5O_cont_t *)(curr_msg->native))->addr) { ((H5O_cont_t *)(curr_msg->native))->chunkno = w; break; } /* end if */ @@ -2252,22 +2281,22 @@ H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) } /* end if */ else { /* Check for pointer to chunk after deleted chunk */ - if(((H5O_cont_t *)(curr_msg->native))->chunkno > deleted_chunkno) + if (((H5O_cont_t *)(curr_msg->native))->chunkno > deleted_chunkno) ((H5O_cont_t *)(curr_msg->native))->chunkno--; } /* end else */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Found chunk to delete */ deleted_chunk = TRUE; break; } /* end if */ - } /* end for */ + } /* end for */ /* If we deleted any chunks, remember that */ - if(deleted_chunk) + if (deleted_chunk) did_deleting = TRUE; - } while(deleted_chunk); + } while (deleted_chunk); /* Set return value */ ret_value = (htri_t)did_deleting; @@ -2276,7 +2305,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__remove_empty_chunks() */ - /*------------------------------------------------------------------------- * * Function: H5O__condense_header @@ -2294,9 +2322,9 @@ done: herr_t H5O__condense_header(H5F_t *f, H5O_t *oh) { - hbool_t rescan_header; /* Whether to rescan header */ - htri_t result; /* Result from packing/merging/etc */ - herr_t ret_value = SUCCEED; /* return value */ + hbool_t rescan_header; /* Whether to rescan header */ + htri_t result; /* Result from packing/merging/etc */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -2310,34 +2338,33 @@ H5O__condense_header(H5F_t *f, H5O_t *oh) /* Scan for messages that can be moved earlier in chunks */ result = H5O__move_msgs_forward(f, oh); - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't move header messages forward") - if(result > 0) + if (result > 0) rescan_header = TRUE; /* Scan for adjacent null messages & merge them */ result = H5O__merge_null(f, oh); - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack null header messages") - if(result > 0) + if (result > 0) rescan_header = TRUE; /* Scan for empty chunks to remove */ result = H5O__remove_empty_chunks(f, oh); - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't remove empty chunk") - if(result > 0) + if (result > 0) rescan_header = TRUE; - } while(rescan_header); + } while (rescan_header); #ifdef H5O_DEBUG -H5O__assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__condense_header() */ - /*------------------------------------------------------------------------- * * Function: H5O__alloc_shrink_chunk @@ -2355,21 +2382,21 @@ done: static herr_t H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) { - H5O_chunk_t *chunk = &oh->chunk[chunkno]; /* Chunk to shrink */ - H5O_chunk_proxy_t *chk_proxy = NULL; /* Metadata cache proxy for chunk to shrink */ - H5O_mesg_t *curr_msg; /* Current message to examine */ - uint8_t *old_image = chunk->image; /* Old address of chunk's image in memory */ - size_t old_size = chunk->size; /* Old size of chunk */ - size_t new_size = chunk->size - chunk->gap; /* Size of shrunk chunk */ - size_t total_msg_size; /* Size of the messages in this chunk */ - size_t min_chunk_size = H5O_ALIGN_OH(oh, H5O_MIN_SIZE); /* Minimum chunk size */ - size_t sizeof_chksum = H5O_SIZEOF_CHKSUM_OH(oh); /* Size of chunk checksum */ - size_t sizeof_msghdr = H5O_SIZEOF_MSGHDR_OH(oh); /* Size of message header */ - uint8_t new_size_flags = 0; /* New chunk #0 size flags */ - hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ - size_t less_prfx_size = 0; /* Bytes removed from object header prefix */ - size_t u; /* Index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_t * chunk = &oh->chunk[chunkno]; /* Chunk to shrink */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Metadata cache proxy for chunk to shrink */ + H5O_mesg_t * curr_msg; /* Current message to examine */ + uint8_t * old_image = chunk->image; /* Old address of chunk's image in memory */ + size_t old_size = chunk->size; /* Old size of chunk */ + size_t new_size = chunk->size - chunk->gap; /* Size of shrunk chunk */ + size_t total_msg_size; /* Size of the messages in this chunk */ + size_t min_chunk_size = H5O_ALIGN_OH(oh, H5O_MIN_SIZE); /* Minimum chunk size */ + size_t sizeof_chksum = H5O_SIZEOF_CHKSUM_OH(oh); /* Size of chunk checksum */ + size_t sizeof_msghdr = H5O_SIZEOF_MSGHDR_OH(oh); /* Size of message header */ + uint8_t new_size_flags = 0; /* New chunk #0 size flags */ + hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ + size_t less_prfx_size = 0; /* Bytes removed from object header prefix */ + size_t u; /* Index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2378,33 +2405,32 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) HDassert(oh); /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Loop backwards to increase the chance of seeing more null messages at the * end of the chunk. Note that we rely on unsigned u wrapping around at the * end. */ - for(u = oh->nmesgs - 1, curr_msg = &oh->mesg[u]; u < oh->nmesgs; u--, curr_msg--) { - if((H5O_NULL_ID == curr_msg->type->id) && (chunkno == curr_msg->chunkno)) { + for (u = oh->nmesgs - 1, curr_msg = &oh->mesg[u]; u < oh->nmesgs; u--, curr_msg--) { + if ((H5O_NULL_ID == curr_msg->type->id) && (chunkno == curr_msg->chunkno)) { size_t shrink_size = curr_msg->raw_size + sizeof_msghdr; /* Amount to shrink the chunk by */ /* If the current message is not at the end of the chunk, copy the - * data after it (except the checksum). - */ - if(curr_msg->raw + curr_msg->raw_size - < old_image + new_size - sizeof_chksum) { - unsigned v; /* Index */ - H5O_mesg_t *curr_msg2; - uint8_t *src = curr_msg->raw + curr_msg->raw_size; /* Source location */ + * data after it (except the checksum). + */ + if (curr_msg->raw + curr_msg->raw_size < old_image + new_size - sizeof_chksum) { + unsigned v; /* Index */ + H5O_mesg_t *curr_msg2; + uint8_t * src = curr_msg->raw + curr_msg->raw_size; /* Source location */ /* Slide down the raw data */ HDmemmove(curr_msg->raw - sizeof_msghdr, src, - (size_t)(old_image + new_size - sizeof_chksum - src)); + (size_t)(old_image + new_size - sizeof_chksum - src)); /* Update the raw data pointers for messages after this one */ - for(v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) - if((chunkno == curr_msg2->chunkno) && (curr_msg2->raw > curr_msg->raw)) + for (v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) + if ((chunkno == curr_msg2->chunkno) && (curr_msg2->raw > curr_msg->raw)) curr_msg2->raw -= shrink_size; } /* end if */ @@ -2415,29 +2441,29 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) H5O__msg_free_mesg(curr_msg); /* Remove the deleted null message from list of messages */ - if(u < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[u], &oh->mesg[u+1], ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); + if (u < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[u], &oh->mesg[u + 1], ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now) */ oh->nmesgs--; } /* end if */ - } /* end for */ + } /* end for */ /* Check if the chunk is too small, extend if necessary */ total_msg_size = new_size - (size_t)(chunkno == 0 ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh)); - if(total_msg_size < min_chunk_size) { + if (total_msg_size < min_chunk_size) { HDassert(oh->alloc_nmesgs > oh->nmesgs); oh->nmesgs++; /* Initialize new null message to make the chunk large enough */ - curr_msg = &oh->mesg[oh->nmesgs - 1]; - curr_msg->type = H5O_MSG_NULL; - curr_msg->dirty = TRUE; + curr_msg = &oh->mesg[oh->nmesgs - 1]; + curr_msg->type = H5O_MSG_NULL; + curr_msg->dirty = TRUE; curr_msg->native = NULL; - curr_msg->raw = old_image + new_size + sizeof_msghdr - sizeof_chksum; - curr_msg->raw_size = MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size), - sizeof_msghdr) - sizeof_msghdr; + curr_msg->raw = old_image + new_size + sizeof_msghdr - sizeof_chksum; + curr_msg->raw_size = + MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size), sizeof_msghdr) - sizeof_msghdr; curr_msg->chunkno = chunkno; /* update the new chunk size */ @@ -2445,67 +2471,67 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) } /* end if */ /* Check for changing the chunk #0 data size enough to need adjusting the flags */ - if(oh->version > H5O_VERSION_1 && chunkno == 0) { - uint64_t chunk0_newsize = new_size - (size_t)H5O_SIZEOF_HDR(oh); /* New size of chunk 0's data */ + if (oh->version > H5O_VERSION_1 && chunkno == 0) { + uint64_t chunk0_newsize = new_size - (size_t)H5O_SIZEOF_HDR(oh); /* New size of chunk 0's data */ size_t orig_prfx_size = (size_t)1 << (oh->flags & H5O_HDR_CHUNK0_SIZE); /* Original prefix size */ /* Check for moving to a 1-byte size encoding */ - if(orig_prfx_size > 1 && chunk0_newsize <= 255) { - less_prfx_size = orig_prfx_size - 1; - new_size_flags = H5O_HDR_CHUNK0_1; + if (orig_prfx_size > 1 && chunk0_newsize <= 255) { + less_prfx_size = orig_prfx_size - 1; + new_size_flags = H5O_HDR_CHUNK0_1; adjust_size_flags = TRUE; } /* end if */ /* Check for moving to a 2-byte size encoding */ - else if(orig_prfx_size > 2 && chunk0_newsize <= 65535) { - less_prfx_size = orig_prfx_size - 2; - new_size_flags = H5O_HDR_CHUNK0_2; + else if (orig_prfx_size > 2 && chunk0_newsize <= 65535) { + less_prfx_size = orig_prfx_size - 2; + new_size_flags = H5O_HDR_CHUNK0_2; adjust_size_flags = TRUE; } /* end if */ /* Check for moving to a 4-byte size encoding */ - else if(orig_prfx_size > 4 && chunk0_newsize <= 4294967295) { - less_prfx_size = orig_prfx_size - 4; - new_size_flags = H5O_HDR_CHUNK0_4; + else if (orig_prfx_size > 4 && chunk0_newsize <= 4294967295) { + less_prfx_size = orig_prfx_size - 4; + new_size_flags = H5O_HDR_CHUNK0_4; adjust_size_flags = TRUE; } /* end if */ - } /* end if */ + } /* end if */ - if(adjust_size_flags) { + if (adjust_size_flags) { /* Adjust object header prefix flags */ oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); oh->flags |= new_size_flags; /* Slide chunk 0 data down */ HDmemmove(chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum, - chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum + less_prfx_size, - new_size - (size_t)H5O_SIZEOF_HDR(oh)); + chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum + less_prfx_size, + new_size - (size_t)H5O_SIZEOF_HDR(oh)); /* Adjust chunk size */ new_size -= less_prfx_size; } /* end if */ /* Allocate less memory space for chunk's image */ - chunk->size = new_size; + chunk->size = new_size; chunk->image = H5FL_BLK_REALLOC(chunk_image, old_image, chunk->size); - chunk->gap = 0; - if(NULL == oh->chunk[chunkno].image) + chunk->gap = 0; + if (NULL == oh->chunk[chunkno].image) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Spin through existing messages, adjusting them */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - if(adjust_size_flags || (chunk->image != old_image)) + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + if (adjust_size_flags || (chunk->image != old_image)) /* Adjust raw addresses for messages in this chunk to reflect new 'image' address */ - if(curr_msg->chunkno == chunkno) + if (curr_msg->chunkno == chunkno) curr_msg->raw = chunk->image - less_prfx_size + (curr_msg->raw - old_image); /* Find continuation message which points to this chunk and adjust chunk's size */ /* (Chunk 0 doesn't have a continuation message that points to it and * its size is directly encoded in the object header) */ - if(chunkno > 0 && (H5O_CONT_ID == curr_msg->type->id) && - (((H5O_cont_t *)(curr_msg->native))->chunkno == chunkno)) { - H5O_chunk_proxy_t *cont_chk_proxy; /* Chunk that message is in */ + if (chunkno > 0 && (H5O_CONT_ID == curr_msg->type->id) && + (((H5O_cont_t *)(curr_msg->native))->chunkno == chunkno)) { + H5O_chunk_proxy_t *cont_chk_proxy; /* Chunk that message is in */ /* Protect chunk */ - if(NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) + if (NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Adjust size of continuation message */ @@ -2516,26 +2542,25 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) curr_msg->dirty = TRUE; /* Release chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, cont_chk_proxy, TRUE) < 0) + if (H5O__chunk_unprotect(f, cont_chk_proxy, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") } /* end if */ - } /* end for */ + } /* end for */ HDassert(new_size <= old_size); /* Resize the chunk in the cache */ - if(H5O__chunk_resize(oh, chk_proxy) < 0) + if (H5O__chunk_resize(oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize object header chunk") /* Free the unused space in the file */ - if(H5MF_xfree(f, H5FD_MEM_OHDR, chunk->addr + new_size, (hsize_t)(old_size - new_size)) < 0) + if (H5MF_xfree(f, H5FD_MEM_OHDR, chunk->addr + new_size, (hsize_t)(old_size - new_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to shrink object header chunk") done: /* Release chunk, marking it dirty */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_shrink_chunk() */ - diff --git a/src/H5Oattr.c b/src/H5Oattr.c index e38ef5c..b56aadd 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -11,87 +11,83 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5S_FRIEND /*suppress error about including H5Spkg */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Spkg.h" /* Dataspaces */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Spkg.h" /* Dataspaces */ /* PRIVATE PROTOTYPES */ static herr_t H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg); -static void *H5O_attr_decode(H5F_t *f, H5O_t *open_oh, - unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); -static void *H5O_attr_copy(const void *_mesg, void *_dest); +static void * H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); +static void * H5O_attr_copy(const void *_mesg, void *_dest); static size_t H5O_attr_size(const H5F_t *f, const void *_mesg); static herr_t H5O__attr_free(void *mesg); -static herr_t H5O_attr_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static void *H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, - void *native_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__attr_post_copy_file(const H5O_loc_t *src_oloc, - const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, - H5O_copy_t *cpy_info); +static herr_t H5O_attr_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *udata); +static void * H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, void *native_src, + H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__attr_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, + void *mesg_dst, H5O_copy_t *cpy_info); static herr_t H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx); static herr_t H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx); -static herr_t H5O__attr_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__attr_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_ATTR -#define H5O_SHARED_DECODE H5O_attr_shared_decode -#define H5O_SHARED_DECODE_REAL H5O_attr_decode -#define H5O_SHARED_ENCODE H5O_attr_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_attr_encode -#define H5O_SHARED_SIZE H5O_attr_shared_size -#define H5O_SHARED_SIZE_REAL H5O_attr_size -#define H5O_SHARED_DELETE H5O__attr_shared_delete -#define H5O_SHARED_DELETE_REAL H5O__attr_delete -#define H5O_SHARED_LINK H5O__attr_shared_link -#define H5O_SHARED_LINK_REAL H5O__attr_link -#define H5O_SHARED_COPY_FILE H5O__attr_shared_copy_file -#define H5O_SHARED_COPY_FILE_REAL H5O__attr_copy_file -#define H5O_SHARED_POST_COPY_FILE H5O_attr_shared_post_copy_file -#define H5O_SHARED_POST_COPY_FILE_REAL H5O__attr_post_copy_file -#undef H5O_SHARED_POST_COPY_FILE_UPD -#define H5O_SHARED_DEBUG H5O_attr_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__attr_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#define H5O_SHARED_TYPE H5O_MSG_ATTR +#define H5O_SHARED_DECODE H5O_attr_shared_decode +#define H5O_SHARED_DECODE_REAL H5O_attr_decode +#define H5O_SHARED_ENCODE H5O_attr_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O_attr_encode +#define H5O_SHARED_SIZE H5O_attr_shared_size +#define H5O_SHARED_SIZE_REAL H5O_attr_size +#define H5O_SHARED_DELETE H5O__attr_shared_delete +#define H5O_SHARED_DELETE_REAL H5O__attr_delete +#define H5O_SHARED_LINK H5O__attr_shared_link +#define H5O_SHARED_LINK_REAL H5O__attr_link +#define H5O_SHARED_COPY_FILE H5O__attr_shared_copy_file +#define H5O_SHARED_COPY_FILE_REAL H5O__attr_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O_attr_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE_REAL H5O__attr_post_copy_file +#undef H5O_SHARED_POST_COPY_FILE_UPD +#define H5O_SHARED_DEBUG H5O_attr_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__attr_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_ATTR[1] = {{ - H5O_ATTR_ID, /* message id number */ - "attribute", /* message name for debugging */ - sizeof(H5A_t), /* native message size */ - H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ - H5O_attr_shared_decode, /* decode message */ - H5O_attr_shared_encode, /* encode message */ - H5O_attr_copy, /* copy the native value */ - H5O_attr_shared_size, /* size of raw message */ - H5O__attr_reset, /* reset method */ - H5O__attr_free, /* free method */ - H5O__attr_shared_delete, /* file delete method */ - H5O__attr_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - H5O_attr_pre_copy_file, /* pre copy native value to file */ - H5O__attr_shared_copy_file, /* copy native value to file */ - H5O_attr_shared_post_copy_file, /* post copy native value to file */ - H5O_attr_get_crt_index, /* get creation index */ - H5O_attr_set_crt_index, /* set creation index */ - H5O_attr_shared_debug /* debug the message */ + H5O_ATTR_ID, /* message id number */ + "attribute", /* message name for debugging */ + sizeof(H5A_t), /* native message size */ + H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ + H5O_attr_shared_decode, /* decode message */ + H5O_attr_shared_encode, /* encode message */ + H5O_attr_copy, /* copy the native value */ + H5O_attr_shared_size, /* size of raw message */ + H5O__attr_reset, /* reset method */ + H5O__attr_free, /* free method */ + H5O__attr_shared_delete, /* file delete method */ + H5O__attr_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + H5O_attr_pre_copy_file, /* pre copy native value to file */ + H5O__attr_shared_copy_file, /* copy native value to file */ + H5O_attr_shared_post_copy_file, /* post copy native value to file */ + H5O_attr_get_crt_index, /* get creation index */ + H5O_attr_set_crt_index, /* set creation index */ + H5O_attr_shared_debug /* debug the message */ }}; /* Flags for attribute flag encoding */ -#define H5O_ATTR_FLAG_TYPE_SHARED 0x01 -#define H5O_ATTR_FLAG_SPACE_SHARED 0x02 -#define H5O_ATTR_FLAG_ALL 0x03 +#define H5O_ATTR_FLAG_TYPE_SHARED 0x01 +#define H5O_ATTR_FLAG_SPACE_SHARED 0x02 +#define H5O_ATTR_FLAG_ALL 0x03 /* Declare external the free list for H5S_t's */ H5FL_EXTERN(H5S_t); @@ -99,7 +95,6 @@ H5FL_EXTERN(H5S_t); /* Declare external the free list for H5S_extent_t's */ H5FL_EXTERN(H5S_extent_t); - /*-------------------------------------------------------------------------- NAME H5O_attr_decode @@ -119,17 +114,17 @@ H5FL_EXTERN(H5S_extent_t); function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * -H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned *ioflags, + size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5A_t *attr = NULL; - H5S_extent_t *extent; /*extent dimensionality information */ - size_t name_len; /*attribute name length */ - size_t dt_size; /* Datatype size */ - hssize_t sds_size; /* Signed Dataspace size */ - hsize_t ds_size; /* Dataspace size */ - unsigned flags = 0; /* Attribute flags */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_t * attr = NULL; + H5S_extent_t *extent; /*extent dimensionality information */ + size_t name_len; /*attribute name length */ + size_t dt_size; /* Datatype size */ + hssize_t sds_size; /* Signed Dataspace size */ + hsize_t ds_size; /* Dataspace size */ + unsigned flags = 0; /* Attribute flags */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -137,27 +132,27 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, HDassert(f); HDassert(p); - if(NULL == (attr = H5FL_CALLOC(H5A_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (attr = H5FL_CALLOC(H5A_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) + if (NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared attr structure") /* Version number */ attr->shared->version = *p++; - if(attr->shared->version < H5O_ATTR_VERSION_1 || attr->shared->version > H5O_ATTR_VERSION_LATEST) - HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "bad version number for attribute message") + if (attr->shared->version < H5O_ATTR_VERSION_1 || attr->shared->version > H5O_ATTR_VERSION_LATEST) + HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "bad version number for attribute message") /* Get the flags byte if we have a later version of the attribute */ - if(attr->shared->version >= H5O_ATTR_VERSION_2) { + if (attr->shared->version >= H5O_ATTR_VERSION_2) { flags = *p++; /* Check for unknown flag */ - if(flags & (unsigned)~H5O_ATTR_FLAG_ALL) + if (flags & (unsigned)~H5O_ATTR_FLAG_ALL) HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "unknown flag for attribute message") } /* end if */ else - p++; /* Byte is unused when version<2 */ + p++; /* Byte is unused when version<2 */ /* * Decode the sizes of the parts of the attribute. The sizes stored in @@ -171,27 +166,28 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, * Decode the character encoding for the name for versions 3 or later, * as well as some reserved bytes. */ - if(attr->shared->version >= H5O_ATTR_VERSION_3) + if (attr->shared->version >= H5O_ATTR_VERSION_3) attr->shared->encoding = (H5T_cset_t)*p++; /* Decode and store the name */ - if(NULL == (attr->shared->name = H5MM_strdup((const char *)p))) + if (NULL == (attr->shared->name = H5MM_strdup((const char *)p))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Make an attempt to detect corrupted name or name length - HDFFV-10588 */ - if(name_len != (HDstrlen(attr->shared->name) + 1)) + if (name_len != (HDstrlen(attr->shared->name) + 1)) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "attribute name has different length than stored length") - if(attr->shared->version < H5O_ATTR_VERSION_2) - p += H5O_ALIGN_OLD(name_len); /* advance the memory pointer */ + if (attr->shared->version < H5O_ATTR_VERSION_2) + p += H5O_ALIGN_OLD(name_len); /* advance the memory pointer */ else - p += name_len; /* advance the memory pointer */ + p += name_len; /* advance the memory pointer */ /* Decode the attribute's datatype */ - if(NULL == (attr->shared->dt = (H5T_t *)(H5O_MSG_DTYPE->decode)(f, open_oh, - ((flags & H5O_ATTR_FLAG_TYPE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, attr->shared->dt_size, p))) + if (NULL == (attr->shared->dt = (H5T_t *)(H5O_MSG_DTYPE->decode)( + f, open_oh, ((flags & H5O_ATTR_FLAG_TYPE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, + attr->shared->dt_size, p))) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype") - if(attr->shared->version < H5O_ATTR_VERSION_2) + if (attr->shared->version < H5O_ATTR_VERSION_2) p += H5O_ALIGN_OLD(attr->shared->dt_size); else p += attr->shared->dt_size; @@ -199,12 +195,13 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, /* decode the attribute dataspace. It can be shared in versions >= 3 * What's actually shared, though, is only the extent. */ - if(NULL == (attr->shared->ds = H5FL_CALLOC(H5S_t))) + if (NULL == (attr->shared->ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Decode attribute's dataspace extent */ - if((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)(f, open_oh, - ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, attr->shared->ds_size, p)) == NULL) + if ((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)( + f, open_oh, ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, + attr->shared->ds_size, p)) == NULL) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace") /* Copy the extent information to the dataspace */ @@ -214,22 +211,22 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, extent = H5FL_FREE(H5S_extent_t, extent); /* Default to entire dataspace being selected */ - if(H5S_select_all(attr->shared->ds, FALSE) < 0) + if (H5S_select_all(attr->shared->ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") - if(attr->shared->version < H5O_ATTR_VERSION_2) + if (attr->shared->version < H5O_ATTR_VERSION_2) p += H5O_ALIGN_OLD(attr->shared->ds_size); else p += attr->shared->ds_size; /* Get the datatype's size */ - if(0 == (dt_size = H5T_get_size(attr->shared->dt))) + if (0 == (dt_size = H5T_get_size(attr->shared->dt))) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size") /* Get the datatype & dataspace sizes */ - if(0 == (dt_size = H5T_get_size(attr->shared->dt))) + if (0 == (dt_size = H5T_get_size(attr->shared->dt))) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size") - if((sds_size = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + if ((sds_size = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get dataspace size") ds_size = (hsize_t)sds_size; @@ -237,13 +234,13 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, H5_CHECKED_ASSIGN(attr->shared->data_size, size_t, ds_size * (hsize_t)dt_size, hsize_t); /* Go get the data */ - if(attr->shared->data_size) { + if (attr->shared->data_size) { /* Ensure that data size doesn't exceed buffer size, in case of it's being corrupted in the file */ - if(attr->shared->data_size > p_size) + if (attr->shared->data_size > p_size) HGOTO_ERROR(H5E_RESOURCE, H5E_OVERFLOW, NULL, "data size exceeds buffer size") - if(NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, attr->shared->data_size))) + if (NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, attr->shared->data_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(attr->shared->data, p, attr->shared->data_size); } /* end if */ @@ -256,11 +253,11 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, ret_value = attr; done: - if(NULL == ret_value) - if(attr) { + if (NULL == ret_value) + if (attr) { /* Free any dynamically allocated items */ - if(attr->shared) - if(H5A__shared_free(attr) < 0) + if (attr->shared) + if (H5A__shared_free(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info") attr = H5FL_FREE(H5A_t, attr); @@ -269,7 +266,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_attr_decode() */ - /*-------------------------------------------------------------------------- NAME H5O_attr_encode @@ -289,12 +285,12 @@ done: static herr_t H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) { - const H5A_t *attr = (const H5A_t *) mesg; - size_t name_len; /* Attribute name length */ - htri_t is_type_shared; /* Flag to indicate that a shared datatype is used for this attribute */ - htri_t is_space_shared; /* Flag to indicate that a shared dataspace is used for this attribute */ - unsigned flags = 0; /* Attribute flags */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5A_t *attr = (const H5A_t *)mesg; + size_t name_len; /* Attribute name length */ + htri_t is_type_shared; /* Flag to indicate that a shared datatype is used for this attribute */ + htri_t is_space_shared; /* Flag to indicate that a shared dataspace is used for this attribute */ + unsigned flags = 0; /* Attribute flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -304,21 +300,21 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) HDassert(attr); /* Check whether datatype and dataspace are shared */ - if((is_type_shared = H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt)) < 0) + if ((is_type_shared = H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't determine if datatype is shared") - if((is_space_shared = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->shared->ds)) < 0) + if ((is_space_shared = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->shared->ds)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't determine if dataspace is shared") /* Encode Version */ *p++ = attr->shared->version; /* Set attribute flags if version >1 */ - if(attr->shared->version >= H5O_ATTR_VERSION_2) { - flags = (is_type_shared ? H5O_ATTR_FLAG_TYPE_SHARED : 0 ); + if (attr->shared->version >= H5O_ATTR_VERSION_2) { + flags = (is_type_shared ? H5O_ATTR_FLAG_TYPE_SHARED : 0); flags |= (is_space_shared ? H5O_ATTR_FLAG_SPACE_SHARED : 0); - *p++ = (uint8_t)flags; /* Set flags for attribute */ - } /* end if */ + *p++ = (uint8_t)flags; /* Set flags for attribute */ + } /* end if */ else *p++ = 0; /* Reserved, for version <2 */ @@ -333,12 +329,12 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) UINT16ENCODE(p, attr->shared->ds_size); /* The character encoding for the attribute's name, in later versions */ - if(attr->shared->version >= H5O_ATTR_VERSION_3) + if (attr->shared->version >= H5O_ATTR_VERSION_3) *p++ = (uint8_t)attr->shared->encoding; /* Write the name including null terminator */ H5MM_memcpy(p, attr->shared->name, name_len); - if(attr->shared->version < H5O_ATTR_VERSION_2) { + if (attr->shared->version < H5O_ATTR_VERSION_2) { /* Pad to the correct number of bytes */ HDmemset(p + name_len, 0, H5O_ALIGN_OLD(name_len) - name_len); p += H5O_ALIGN_OLD(name_len); @@ -347,10 +343,10 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) p += name_len; /* encode the attribute datatype */ - if((H5O_MSG_DTYPE->encode)(f, FALSE, p, attr->shared->dt) < 0) + if ((H5O_MSG_DTYPE->encode)(f, FALSE, p, attr->shared->dt) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute datatype") - if(attr->shared->version < H5O_ATTR_VERSION_2) { + if (attr->shared->version < H5O_ATTR_VERSION_2) { HDmemset(p + attr->shared->dt_size, 0, H5O_ALIGN_OLD(attr->shared->dt_size) - attr->shared->dt_size); p += H5O_ALIGN_OLD(attr->shared->dt_size); } /* end if */ @@ -358,10 +354,10 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) p += attr->shared->dt_size; /* encode the attribute dataspace */ - if((H5O_MSG_SDSPACE->encode)(f, FALSE, p, &(attr->shared->ds->extent)) < 0) + if ((H5O_MSG_SDSPACE->encode)(f, FALSE, p, &(attr->shared->ds->extent)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute dataspace") - if(attr->shared->version < H5O_ATTR_VERSION_2) { + if (attr->shared->version < H5O_ATTR_VERSION_2) { HDmemset(p + attr->shared->ds_size, 0, H5O_ALIGN_OLD(attr->shared->ds_size) - attr->shared->ds_size); p += H5O_ALIGN_OLD(attr->shared->ds_size); } /* end if */ @@ -369,7 +365,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) p += attr->shared->ds_size; /* Store attribute data. If there's no data, store 0 as fill value. */ - if(attr->shared->data) + if (attr->shared->data) H5MM_memcpy(p, attr->shared->data, attr->shared->data_size); else HDmemset(p, 0, attr->shared->data_size); @@ -378,7 +374,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_attr_encode() */ - /*-------------------------------------------------------------------------- NAME H5O_attr_copy @@ -397,7 +392,7 @@ done: static void * H5O_attr_copy(const void *_src, void *_dst) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -405,14 +400,13 @@ H5O_attr_copy(const void *_src, void *_dst) HDassert(_src); /* copy */ - if(NULL == (ret_value = (H5A_t *)H5A__copy((H5A_t *)_dst, (const H5A_t *)_src))) + if (NULL == (ret_value = (H5A_t *)H5A__copy((H5A_t *)_dst, (const H5A_t *)_src))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_attr_copy() */ - /*-------------------------------------------------------------------------- NAME H5O_attr_size @@ -432,48 +426,47 @@ done: static size_t H5O_attr_size(const H5F_t H5_ATTR_UNUSED *f, const void *_mesg) { - const H5A_t *attr = (const H5A_t *)_mesg; - size_t name_len; - size_t ret_value = 0; + const H5A_t *attr = (const H5A_t *)_mesg; + size_t name_len; + size_t ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(attr); /* Common size information */ - ret_value = 1 + /*version */ - 1 + /*reserved/flags */ - 2 + /*name size inc. null */ - 2 + /*type size */ - 2; /*space size */ + ret_value = 1 + /*version */ + 1 + /*reserved/flags */ + 2 + /*name size inc. null */ + 2 + /*type size */ + 2; /*space size */ /* Length of attribute name */ name_len = HDstrlen(attr->shared->name) + 1; /* Version-specific size information */ - if(attr->shared->version == H5O_ATTR_VERSION_1) - ret_value += H5O_ALIGN_OLD(name_len) + /*attribute name */ - H5O_ALIGN_OLD(attr->shared->dt_size) + /*datatype */ - H5O_ALIGN_OLD(attr->shared->ds_size) + /*dataspace */ - attr->shared->data_size; /*the data itself */ - else if(attr->shared->version == H5O_ATTR_VERSION_2) - ret_value += name_len + /*attribute name */ - attr->shared->dt_size + /*datatype */ - attr->shared->ds_size + /*dataspace */ - attr->shared->data_size; /*the data itself */ - else if(attr->shared->version == H5O_ATTR_VERSION_3) - ret_value += 1 + /*character encoding */ - name_len + /*attribute name */ - attr->shared->dt_size + /*datatype */ - attr->shared->ds_size + /*dataspace */ - attr->shared->data_size; /*the data itself */ + if (attr->shared->version == H5O_ATTR_VERSION_1) + ret_value += H5O_ALIGN_OLD(name_len) + /*attribute name */ + H5O_ALIGN_OLD(attr->shared->dt_size) + /*datatype */ + H5O_ALIGN_OLD(attr->shared->ds_size) + /*dataspace */ + attr->shared->data_size; /*the data itself */ + else if (attr->shared->version == H5O_ATTR_VERSION_2) + ret_value += name_len + /*attribute name */ + attr->shared->dt_size + /*datatype */ + attr->shared->ds_size + /*dataspace */ + attr->shared->data_size; /*the data itself */ + else if (attr->shared->version == H5O_ATTR_VERSION_3) + ret_value += 1 + /*character encoding */ + name_len + /*attribute name */ + attr->shared->dt_size + /*datatype */ + attr->shared->ds_size + /*dataspace */ + attr->shared->data_size; /*the data itself */ else HDassert(0 && "Bad attribute version"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_attr_size() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_reset * @@ -495,7 +488,6 @@ H5O__attr_reset(void H5_ATTR_UNUSED *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__attr_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_free * @@ -511,21 +503,20 @@ H5O__attr_reset(void H5_ATTR_UNUSED *_mesg) static herr_t H5O__attr_free(void *mesg) { - H5A_t *attr = (H5A_t *)mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t *attr = (H5A_t *)mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(mesg); - if(H5A__close(attr) < 0) + if (H5A__close(attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "unable to close attribute object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_free() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_delete * @@ -541,8 +532,8 @@ done: herr_t H5O__attr_delete(H5F_t *f, H5O_t *oh, void *_mesg) { - H5A_t *attr = (H5A_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t *attr = (H5A_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -551,18 +542,17 @@ H5O__attr_delete(H5F_t *f, H5O_t *oh, void *_mesg) HDassert(attr); /* Decrement reference count on datatype in file */ - if((H5O_MSG_DTYPE->del)(f, oh, attr->shared->dt) < 0) + if ((H5O_MSG_DTYPE->del)(f, oh, attr->shared->dt) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust datatype link count") /* Decrement reference count on dataspace in file */ - if((H5O_MSG_SDSPACE->del)(f, oh, attr->shared->ds) < 0) + if ((H5O_MSG_SDSPACE->del)(f, oh, attr->shared->ds) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust dataspace link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_link * @@ -579,8 +569,8 @@ done: herr_t H5O__attr_link(H5F_t *f, H5O_t *oh, void *_mesg) { - H5A_t *attr = (H5A_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t *attr = (H5A_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -594,16 +584,15 @@ H5O__attr_link(H5F_t *f, H5O_t *oh, void *_mesg) * message is deleted. */ /* Increment reference count on datatype & dataspace in file */ - if((H5O_MSG_DTYPE->link)(f, oh, attr->shared->dt) < 0) + if ((H5O_MSG_DTYPE->link)(f, oh, attr->shared->dt) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust datatype link count") - if((H5O_MSG_SDSPACE->link)(f, oh, attr->shared->ds) < 0) + if ((H5O_MSG_SDSPACE->link)(f, oh, attr->shared->ds) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust dataspace link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_link() */ - /*------------------------------------------------------------------------- * Function: H5O_attr_pre_copy_file * @@ -618,11 +607,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) { - const H5A_t *attr_src = (const H5A_t *)native_src; /* Source attribute */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5A_t *attr_src = (const H5A_t *)native_src; /* Source attribute */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -634,20 +623,19 @@ H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src, /* Check to ensure that the version of the message to be copied does not exceed * the message version allowed by the destination file's high bound. */ - if(attr_src->shared->version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (attr_src->shared->version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "attribute message version out of bounds") /* If we are not copying attributes into the destination file, indicate * that this message should be deleted. */ - if(cpy_info->copy_without_attr) + if (cpy_info->copy_without_attr) *deleted = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_attr_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_copy_file * @@ -662,11 +650,11 @@ done: *------------------------------------------------------------------------- */ static void * -H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_type, - void *native_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_type, void *native_src, + H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, + void H5_ATTR_UNUSED *udata) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -679,17 +667,16 @@ H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_ /* Mark datatype as being on disk now. This step used to be done in a lower level * by H5O_dtype_decode. But it has been moved up. Not an ideal place, but no better * place than here. */ - if(H5T_set_loc(((H5A_t *)native_src)->shared->dt, H5F_VOL_OBJ(file_src), H5T_LOC_DISK) < 0) + if (H5T_set_loc(((H5A_t *)native_src)->shared->dt, H5F_VOL_OBJ(file_src), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location") - if(NULL == (ret_value = H5A__attr_copy_file((H5A_t *)native_src, file_dst, recompute_size, cpy_info))) + if (NULL == (ret_value = H5A__attr_copy_file((H5A_t *)native_src, file_dst, recompute_size, cpy_info))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__attr_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_post_copy_file * @@ -707,21 +694,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__attr_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, - H5O_loc_t *dst_oloc, void *mesg_dst, H5O_copy_t *cpy_info) +H5O__attr_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, + H5O_copy_t *cpy_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(H5A__attr_post_copy_file(src_oloc, (const H5A_t *)mesg_src, dst_oloc, (H5A_t *)mesg_dst, cpy_info) < 0) + if (H5A__attr_post_copy_file(src_oloc, (const H5A_t *)mesg_src, dst_oloc, (H5A_t *)mesg_dst, cpy_info) < + 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__attr_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O_attr_get_crt_index * @@ -737,7 +724,7 @@ done: static herr_t H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) { - const H5A_t *attr = (const H5A_t *)_mesg; + const H5A_t *attr = (const H5A_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -750,7 +737,6 @@ H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_attr_get_crt_index() */ - /*------------------------------------------------------------------------- * Function: H5O_attr_set_crt_index * @@ -766,7 +752,7 @@ H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) static herr_t H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) { - H5A_t *attr = (H5A_t *)_mesg; + H5A_t *attr = (H5A_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -778,7 +764,6 @@ H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_attr_set_crt_index() */ - /*-------------------------------------------------------------------------- NAME H5O__attr_debug @@ -798,12 +783,12 @@ H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) parameter. --------------------------------------------------------------------------*/ static herr_t -H5O__attr_debug(H5F_t *f, const void *_mesg, FILE * stream, int indent, int fwidth) +H5O__attr_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5A_t *mesg = (const H5A_t *)_mesg; - const char *s; /* Temporary string pointer */ - char buf[128]; /* Temporary string buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + const char * s; /* Temporary string pointer */ + char buf[128]; /* Temporary string buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -813,10 +798,8 @@ H5O__attr_debug(H5F_t *f, const void *_mesg, FILE * stream, int indent, int fwid HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, - "Name:", - mesg->shared->name); - switch(mesg->shared->encoding) { + HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, "Name:", mesg->shared->name); + switch (mesg->shared->encoding) { case H5T_CSET_ASCII: s = "ASCII"; break; @@ -849,37 +832,27 @@ H5O__attr_debug(H5F_t *f, const void *_mesg, FILE * stream, int indent, int fwid s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Character Set of Name:", - s); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Object opened:", - mesg->obj_opened); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Object:", - mesg->oloc.addr); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Character Set of Name:", s); + HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, "Object opened:", mesg->obj_opened); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Object:", mesg->oloc.addr); /* Check for attribute creation order index on the attribute */ - if(mesg->shared->crt_idx != H5O_MAX_CRT_ORDER_IDX) + if (mesg->shared->crt_idx != H5O_MAX_CRT_ORDER_IDX) HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Creation Index:", - (unsigned)mesg->shared->crt_idx); + "Creation Index:", (unsigned)mesg->shared->crt_idx); HDfprintf(stream, "%*sDatatype...\n", indent, ""); - HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0,fwidth - 3), - "Encoded Size:", - (unsigned long)(mesg->shared->dt_size)); - if((H5O_MSG_DTYPE->debug)(f, mesg->shared->dt, stream, indent + 3, MAX(0, fwidth - 3)) < 0) + HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3), + "Encoded Size:", (unsigned long)(mesg->shared->dt_size)); + if ((H5O_MSG_DTYPE->debug)(f, mesg->shared->dt, stream, indent + 3, MAX(0, fwidth - 3)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display datatype message info") HDfprintf(stream, "%*sDataspace...\n", indent, ""); HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3), - "Encoded Size:", - (unsigned long)(mesg->shared->ds_size)); - if(H5S_debug(f, mesg->shared->ds, stream, indent + 3, MAX(0, fwidth - 3)) < 0) + "Encoded Size:", (unsigned long)(mesg->shared->ds_size)); + if (H5S_debug(f, mesg->shared->ds, stream, indent + 3, MAX(0, fwidth - 3)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display dataspace message info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_debug() */ - diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index d498be5..0406bbc 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -24,122 +24,114 @@ /* Module Setup */ /****************/ -#define H5A_FRIEND /* Suppress error about including H5Apkg.h */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#define H5A_FRIEND /* Suppress error about including H5Apkg.h */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Fprivate.h" /* File */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Fprivate.h" /* File */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for iteration when converting attributes to dense storage */ typedef struct { - H5F_t *f; /* Pointer to file for insertion */ - H5O_ainfo_t *ainfo; /* Attribute info struct */ + H5F_t * f; /* Pointer to file for insertion */ + H5O_ainfo_t *ainfo; /* Attribute info struct */ } H5O_iter_cvt_t; /* User data for iteration when opening an attribute */ typedef struct { /* down */ - const char *name; /* Name of attribute to open */ + const char *name; /* Name of attribute to open */ /* up */ - H5A_t *attr; /* Attribute data to update object header with */ + H5A_t *attr; /* Attribute data to update object header with */ } H5O_iter_opn_t; /* User data for iteration when updating an attribute */ typedef struct { /* down */ - H5F_t *f; /* Pointer to file attribute is in */ - H5A_t *attr; /* Attribute data to update object header with */ + H5F_t *f; /* Pointer to file attribute is in */ + H5A_t *attr; /* Attribute data to update object header with */ /* up */ - hbool_t found; /* Whether the attribute was found */ + hbool_t found; /* Whether the attribute was found */ } H5O_iter_wrt_t; /* User data for iteration when renaming an attribute */ typedef struct { /* down */ - H5F_t *f; /* Pointer to file attribute is in */ - const char *old_name; /* Old name of attribute */ - const char *new_name; /* New name of attribute */ + H5F_t * f; /* Pointer to file attribute is in */ + const char *old_name; /* Old name of attribute */ + const char *new_name; /* New name of attribute */ /* up */ - hbool_t found; /* Whether the attribute was found */ + hbool_t found; /* Whether the attribute was found */ } H5O_iter_ren_t; /* User data for iteration when removing an attribute */ typedef struct { /* down */ - H5F_t *f; /* Pointer to file attribute is in */ - const char *name; /* Name of attribute to open */ + H5F_t * f; /* Pointer to file attribute is in */ + const char *name; /* Name of attribute to open */ /* up */ - hbool_t found; /* Found attribute to delete */ + hbool_t found; /* Found attribute to delete */ } H5O_iter_rm_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata); -static htri_t H5O__attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, - const char* name_to_open); +static herr_t H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata); +static htri_t H5O__attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char *name_to_open); static herr_t H5O__attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, - unsigned H5_ATTR_UNUSED *oh_modified, void *_udata); + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata); static herr_t H5O__attr_open_by_idx_cb(const H5A_t *attr, void *_ret_attr); -static herr_t H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata); +static herr_t H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata); static herr_t H5O__attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg, - unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, void *_udata); -static herr_t H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata); + unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, + void *_udata); +static herr_t H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata); static herr_t H5O__attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo); -static herr_t H5O__attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata); +static herr_t H5O__attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata); static herr_t H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg, - unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, void *_udata); + unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, + void *_udata); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O__attr_to_dense_cb * @@ -155,12 +147,12 @@ static herr_t H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg, *------------------------------------------------------------------------- */ static herr_t -H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata/*in,out*/) +H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata /*in,out*/) { - H5O_iter_cvt_t *udata = (H5O_iter_cvt_t *)_udata; /* Operator user data */ - H5A_t *attr = (H5A_t *)mesg->native; /* Pointer to attribute to insert */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_cvt_t *udata = (H5O_iter_cvt_t *)_udata; /* Operator user data */ + H5A_t * attr = (H5A_t *)mesg->native; /* Pointer to attribute to insert */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -173,12 +165,12 @@ H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(attr); /* Insert attribute into dense storage */ - if(H5A__dense_insert(udata->f, udata->ainfo, attr) < 0) + if (H5A__dense_insert(udata->f, udata->ainfo, attr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") /* Convert message into a null message in the header */ /* (don't delete attribute's space in the file though) */ - if(H5O__release_mesg(udata->f, oh, mesg, FALSE) < 0) + if (H5O__release_mesg(udata->f, oh, mesg, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message") /* Indicate that the object header was modified */ @@ -188,7 +180,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_to_dense_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_create * @@ -204,10 +195,10 @@ done: herr_t H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -216,26 +207,26 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) HDassert(attr); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") + if (NULL == (oh = H5O_pin(loc))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check if this object already has attribute information */ - if(oh->version > H5O_VERSION_1) { - hbool_t new_ainfo = FALSE; /* Flag to indicate that the attribute information is new */ - htri_t ainfo_exists; /* Whether the attribute info was retrieved */ + if (oh->version > H5O_VERSION_1) { + hbool_t new_ainfo = FALSE; /* Flag to indicate that the attribute information is new */ + htri_t ainfo_exists; /* Whether the attribute info was retrieved */ /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") - if(!ainfo_exists) { + if (!ainfo_exists) { /* Initialize attribute information */ - ainfo.track_corder = (hbool_t)((oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) ? TRUE : FALSE); - ainfo.index_corder = (hbool_t)((oh->flags & H5O_HDR_ATTR_CRT_ORDER_INDEXED) ? TRUE : FALSE); - ainfo.max_crt_idx = 0; + ainfo.track_corder = (hbool_t)((oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) ? TRUE : FALSE); + ainfo.index_corder = (hbool_t)((oh->flags & H5O_HDR_ATTR_CRT_ORDER_INDEXED) ? TRUE : FALSE); + ainfo.max_crt_idx = 0; ainfo.corder_bt2_addr = HADDR_UNDEF; - ainfo.nattrs = 0; - ainfo.fheap_addr = HADDR_UNDEF; - ainfo.name_bt2_addr = HADDR_UNDEF; + ainfo.nattrs = 0; + ainfo.fheap_addr = HADDR_UNDEF; + ainfo.name_bt2_addr = HADDR_UNDEF; /* Set flag to add attribute information to object header */ new_ainfo = TRUE; @@ -248,46 +239,47 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) } /* end else */ /* Check if switching to "dense" attribute storage is possible */ - if(!H5F_addr_defined(ainfo.fheap_addr)) { - htri_t sharable; /* Whether the attribute will be shared */ - size_t raw_size = 0; /* Raw size of message */ + if (!H5F_addr_defined(ainfo.fheap_addr)) { + htri_t sharable; /* Whether the attribute will be shared */ + size_t raw_size = 0; /* Raw size of message */ /* Check for attribute being sharable */ - if((sharable = H5SM_can_share(loc->file, NULL, NULL, H5O_ATTR_ID, attr)) < 0) + if ((sharable = H5SM_can_share(loc->file, NULL, NULL, H5O_ATTR_ID, attr)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't determine attribute sharing status") - else if(sharable == FALSE) { + else if (sharable == FALSE) { /* Compute the size needed to encode the attribute */ raw_size = (H5O_MSG_ATTR->raw_size)(loc->file, FALSE, attr); } /* end if */ /* Check for condititions for switching to "dense" attribute storage are met */ - if(ainfo.nattrs == oh->max_compact || (!sharable && raw_size >= H5O_MESG_MAX_SIZE)) { - H5O_iter_cvt_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + if (ainfo.nattrs == oh->max_compact || (!sharable && raw_size >= H5O_MESG_MAX_SIZE)) { + H5O_iter_cvt_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Create dense storage for attributes */ - if(H5A__dense_create(loc->file, &ainfo) < 0) + if (H5A__dense_create(loc->file, &ainfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create dense storage for attributes") /* Set up user data for callback */ - udata.f = loc->file; + udata.f = loc->file; udata.ainfo = &ainfo; /* Iterate over existing attributes, moving them to dense storage */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__attr_to_dense_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTCONVERT, FAIL, "error converting attributes to dense storage") + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTCONVERT, FAIL, + "error converting attributes to dense storage") } /* end if */ - } /* end if */ + } /* end if */ /* Increment attribute count on object */ ainfo.nattrs++; /* Check whether we're tracking the creation index on attributes */ - if(ainfo.track_corder) { + if (ainfo.track_corder) { /* Check for attribute creation order index on the object wrapping around */ - if(ainfo.max_crt_idx == H5O_MAX_CRT_ORDER_IDX) + if (ainfo.max_crt_idx == H5O_MAX_CRT_ORDER_IDX) HGOTO_ERROR(H5E_ATTR, H5E_CANTINC, FAIL, "attribute creation index can't be incremented") /* Set the creation order index on the attribute & incr. creation order index */ @@ -298,14 +290,13 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) attr->shared->crt_idx = H5O_MAX_CRT_ORDER_IDX; /* Add the attribute information message, if one is needed */ - if(new_ainfo) { - if(H5O__msg_append_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, &ainfo) < 0) + if (new_ainfo) { + if (H5O__msg_append_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new attribute info message") } /* end if */ /* Otherwise, update existing message */ - else - if(H5O__msg_write_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, &ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info message") + else if (H5O__msg_write_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, &ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info message") } /* end if */ else { /* Set "bogus" creation index for attribute */ @@ -316,15 +307,15 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) } /* end else */ /* Check for storing attribute with dense storage */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Insert attribute into dense storage */ - if(H5A__dense_insert(loc->file, &ainfo, attr) < 0) + if (H5A__dense_insert(loc->file, &ainfo, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to add to dense storage") } /* end if */ else /* Append new message to object header */ - if(H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new attribute in header") + if (H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new attribute in header") /* Increment reference count for shared attribute object for the * object handle created by the caller function H5A__create. The count @@ -334,11 +325,11 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) attr->shared->nrefs += 1; /* Was new attribute shared? */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) > 0) { - hsize_t attr_rc; /* Attribute's ref count in shared message storage */ + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) > 0) { + hsize_t attr_rc; /* Attribute's ref count in shared message storage */ /* Retrieve ref count for shared attribute */ - if(H5SM_get_refcount(loc->file, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) + if (H5SM_get_refcount(loc->file, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") /* If this is not the first copy of the attribute in the shared message @@ -364,26 +355,25 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) * * *ick* -QAK, 2007/01/08 */ - if(attr_rc > 1) { - if(H5O__attr_delete(loc->file, oh, attr) < 0) + if (attr_rc > 1) { + if (H5O__attr_delete(loc->file, oh, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } /* end if */ - } /* end if */ - else if(shared_mesg < 0) - HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") + } /* end if */ + else if (shared_mesg < 0) + HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_create() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_open_cb * @@ -399,11 +389,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5O__attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5O_iter_opn_t *udata = (H5O_iter_opn_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_opn_t *udata = (H5O_iter_opn_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -413,15 +403,14 @@ H5O__attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(!udata->attr); /* Check for correct attribute message to modify */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { /* Make a copy of the attribute to return */ - if(NULL == (udata->attr = H5A__copy(NULL, (H5A_t *)mesg->native))) + if (NULL == (udata->attr = H5A__copy(NULL, (H5A_t *)mesg->native))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy attribute") /* Assign [somewhat arbitrary] creation order value, for older versions * of the format or if creation order is not tracked */ - if(oh->version == H5O_VERSION_1 - || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) + if (oh->version == H5O_VERSION_1 || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) udata->attr->shared->crt_idx = sequence; /* Stop iterating */ @@ -432,7 +421,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_open_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_open_by_name * @@ -448,12 +436,12 @@ done: H5A_t * H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - H5A_t *exist_attr = NULL; /* Existing opened attribute object */ - H5A_t *opened_attr = NULL; /* Newly opened attribute object */ - htri_t found_open_attr = FALSE; /* Whether opened object is found */ - H5A_t *ret_value = NULL; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + H5A_t * exist_attr = NULL; /* Existing opened attribute object */ + H5A_t * opened_attr = NULL; /* Newly opened attribute object */ + htri_t found_open_attr = FALSE; /* Whether opened object is found */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -462,49 +450,49 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) HDassert(name); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, NULL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't check for attribute info message") } /* end if */ /* If found the attribute is already opened, make a copy of it to share the * object information. If not, open attribute as a new object */ - if((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, name)) < 0) + if ((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "failed in finding opened attribute") - else if(found_open_attr == TRUE) { - if(NULL == (opened_attr = H5A__copy(NULL, exist_attr))) + else if (found_open_attr == TRUE) { + if (NULL == (opened_attr = H5A__copy(NULL, exist_attr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy existing attribute") } /* end else if */ else { /* Check for attributes in dense storage */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Open attribute with dense storage */ - if(NULL == (opened_attr = H5A__dense_open(loc->file, &ainfo, name))) + if (NULL == (opened_attr = H5A__dense_open(loc->file, &ainfo, name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") } /* end if */ else { - H5O_iter_opn_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_opn_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ udata.name = name; udata.attr = NULL; /* Iterate over attributes, to locate correct one to open */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__attr_open_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "error updating attribute") /* Check that we found the attribute */ - if(!udata.attr) + if (!udata.attr) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't locate attribute: '%s'", name) /* Get attribute opened from object header */ @@ -513,7 +501,7 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) } /* end else */ /* Mark datatype as being on disk now */ - if(H5T_set_loc(opened_attr->shared->dt, H5F_VOL_OBJ(loc->file), H5T_LOC_DISK) < 0) + if (H5T_set_loc(opened_attr->shared->dt, H5F_VOL_OBJ(loc->file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location") } /* end else */ @@ -521,18 +509,17 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) ret_value = opened_attr; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, NULL, "unable to release object header") /* Release any resources, on error */ - if(NULL == ret_value && opened_attr) - if(H5A__close(opened_attr) < 0) + if (NULL == ret_value && opened_attr) + if (H5A__close(opened_attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_open_by_name() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_open_by_idx_cb * @@ -549,8 +536,8 @@ done: static herr_t H5O__attr_open_by_idx_cb(const H5A_t *attr, void *_ret_attr) { - H5A_t **ret_attr = (H5A_t **)_ret_attr; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_STOP; /* Return value */ + H5A_t **ret_attr = (H5A_t **)_ret_attr; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_STOP; /* Return value */ FUNC_ENTER_STATIC @@ -559,14 +546,13 @@ H5O__attr_open_by_idx_cb(const H5A_t *attr, void *_ret_attr) HDassert(ret_attr); /* Copy attribute information. Shared some attribute information. */ - if(NULL == (*ret_attr = H5A__copy(NULL, attr))) + if (NULL == (*ret_attr = H5A__copy(NULL, attr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_open_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_open_by_idx * @@ -581,14 +567,13 @@ done: *------------------------------------------------------------------------- */ H5A_t * -H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - H5A_t *exist_attr = NULL; /* Existing opened attribute object */ - H5A_t *opened_attr = NULL; /* Newly opened attribute object */ - htri_t found_open_attr = FALSE; /* Whether opened object is found */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + H5A_t * exist_attr = NULL; /* Existing opened attribute object */ + H5A_t * opened_attr = NULL; /* Newly opened attribute object */ + htri_t found_open_attr = FALSE; /* Whether opened object is found */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -596,48 +581,48 @@ H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, HDassert(loc); /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.op_type = H5A_ATTR_OP_LIB; attr_op.u.lib_op = H5O__attr_open_by_idx_cb; /* Iterate over attributes to locate correct one */ - if(H5O_attr_iterate_real((hid_t)-1, loc, idx_type, order, n, NULL, &attr_op, &opened_attr) < 0) + if (H5O_attr_iterate_real((hid_t)-1, loc, idx_type, order, n, NULL, &attr_op, &opened_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, NULL, "can't locate attribute") /* Find out whether it has already been opened. If it has, close the object * and make a copy of the already opened object to share the object info. */ - if(opened_attr) { - if((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, opened_attr->shared->name)) < 0) + if (opened_attr) { + if ((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, opened_attr->shared->name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "failed in finding opened attribute") /* If found that the attribute is already opened, make a copy of it * and close the object just opened. */ - if(found_open_attr && exist_attr) { - if(H5A__close(opened_attr) < 0) + if (found_open_attr && exist_attr) { + if (H5A__close(opened_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute") - if(NULL == (opened_attr = H5A__copy(NULL, exist_attr))) + if (NULL == (opened_attr = H5A__copy(NULL, exist_attr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy existing attribute") - } else { + } + else { /* Mark datatype as being on disk now */ - if(H5T_set_loc(opened_attr->shared->dt, H5F_VOL_OBJ(loc->file), H5T_LOC_DISK) < 0) + if (H5T_set_loc(opened_attr->shared->dt, H5F_VOL_OBJ(loc->file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location") } /* end if */ - } /* end if */ + } /* end if */ /* Set return value */ ret_value = opened_attr; done: /* Release any resources, on error */ - if(NULL == ret_value && opened_attr) - if(H5A__close(opened_attr) < 0) + if (NULL == ret_value && opened_attr) + if (H5A__close(opened_attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_open_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_find_opened_attr * @@ -654,71 +639,70 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5O__attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char* name_to_open) +H5O__attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char *name_to_open) { - hid_t *attr_id_list = NULL; /* List of IDs for opened attributes */ - unsigned long loc_fnum; /* File serial # for object */ - size_t num_open_attr; /* Number of opened attributes */ - htri_t ret_value = FALSE; /* Return value */ + hid_t * attr_id_list = NULL; /* List of IDs for opened attributes */ + unsigned long loc_fnum; /* File serial # for object */ + size_t num_open_attr; /* Number of opened attributes */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC /* Get file serial number for the location of attribute */ - if(H5F_get_fileno(loc->file, &loc_fnum) < 0) + if (H5F_get_fileno(loc->file, &loc_fnum) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "can't get file serial number") /* Count all opened attributes */ - if(H5F_get_obj_count(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, FALSE, &num_open_attr) < 0) + if (H5F_get_obj_count(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, FALSE, &num_open_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't count opened attributes") /* Find out whether the attribute has been opened */ - if(num_open_attr) { - size_t check_num_attr; /* Number of open attribute IDs */ - size_t u; /* Local index variable */ + if (num_open_attr) { + size_t check_num_attr; /* Number of open attribute IDs */ + size_t u; /* Local index variable */ /* Allocate space for the attribute ID list */ - if(NULL == (attr_id_list = (hid_t *)H5MM_malloc(num_open_attr * sizeof(hid_t)))) + if (NULL == (attr_id_list = (hid_t *)H5MM_malloc(num_open_attr * sizeof(hid_t)))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "unable to allocate memory for attribute ID list") /* Retrieve the IDs of all opened attributes */ - if(H5F_get_obj_ids(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, num_open_attr, attr_id_list, FALSE, &check_num_attr) < 0) + if (H5F_get_obj_ids(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, num_open_attr, attr_id_list, FALSE, + &check_num_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get IDs of opened attributes") - if(check_num_attr != num_open_attr) + if (check_num_attr != num_open_attr) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "open attribute count mismatch") /* Iterate over the attributes */ - for(u = 0; u < num_open_attr; u++) { - unsigned long attr_fnum; /* Attributes file serial number */ + for (u = 0; u < num_open_attr; u++) { + unsigned long attr_fnum; /* Attributes file serial number */ /* Get pointer to attribute */ - if(NULL == (*attr = (H5A_t *)H5VL_object_verify(attr_id_list[u], H5I_ATTR))) + if (NULL == (*attr = (H5A_t *)H5VL_object_verify(attr_id_list[u], H5I_ATTR))) HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, FAIL, "not an attribute") /* Get file serial number for attribute */ - if(H5F_get_fileno((*attr)->oloc.file, &attr_fnum) < 0) + if (H5F_get_fileno((*attr)->oloc.file, &attr_fnum) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "can't get file serial number") /* Verify whether it's the right object. The attribute name, object * address to which the attribute is attached, and file serial * number should all match. */ - if(!HDstrcmp(name_to_open, (*attr)->shared->name) && - loc->addr == (*attr)->oloc.addr && - loc_fnum == attr_fnum) { + if (!HDstrcmp(name_to_open, (*attr)->shared->name) && loc->addr == (*attr)->oloc.addr && + loc_fnum == attr_fnum) { ret_value = TRUE; break; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ done: - if(attr_id_list) + if (attr_id_list) H5MM_free(attr_id_list); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_find_opened_attr() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_update_shared * @@ -735,10 +719,10 @@ done: herr_t H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, H5O_shared_t *update_sh_mesg) { - H5O_shared_t sh_mesg; /* Shared object header message */ - hsize_t attr_rc; /* Attribute's ref count in shared message storage */ - htri_t shared_mesg; /* Whether the message should be shared */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_shared_t sh_mesg; /* Shared object header message */ + hsize_t attr_rc; /* Attribute's ref count in shared message storage */ + htri_t shared_mesg; /* Whether the message should be shared */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -747,22 +731,22 @@ H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, H5O_shared_t *update_s HDassert(attr); /* Extract shared message info from current attribute (for later use) */ - if(H5O_set_shared(&sh_mesg, &(attr->sh_loc)) < 0) + if (H5O_set_shared(&sh_mesg, &(attr->sh_loc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't get shared message") /* Reset existing sharing information */ - if(H5O_msg_reset_share(H5O_ATTR_ID, attr) < 0) + if (H5O_msg_reset_share(H5O_ATTR_ID, attr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to reset attribute sharing") /* Store new version of message as a SOHM */ /* (should always work, since we're not changing the size of the attribute) */ - if((shared_mesg = H5SM_try_share(f, oh, 0, H5O_ATTR_ID, attr, NULL)) == 0) + if ((shared_mesg = H5SM_try_share(f, oh, 0, H5O_ATTR_ID, attr, NULL)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "attribute changed sharing status") - else if(shared_mesg < 0) + else if (shared_mesg < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't share attribute") /* Retrieve shared message storage ref count for new shared attribute */ - if(H5SM_get_refcount(f, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) + if (H5SM_get_refcount(f, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") /* If the newly shared attribute needs to share "ownership" of the shared @@ -774,25 +758,24 @@ H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, H5O_shared_t *update_s * * *ick* -QAK, 2007/01/08 */ - if(attr_rc == 1) + if (attr_rc == 1) /* Increment reference count on attribute components */ - if(H5O__attr_link(f, oh, attr) < 0) + if (H5O__attr_link(f, oh, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") /* Remove the old attribute from the SOHM storage */ - if(H5SM_delete(f, oh, &sh_mesg) < 0) + if (H5SM_delete(f, oh, &sh_mesg) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute in shared storage") /* Extract updated shared message info from modified attribute, if requested */ - if(update_sh_mesg) - if(H5O_set_shared(update_sh_mesg, &(attr->sh_loc)) < 0) + if (update_sh_mesg) + if (H5O_set_shared(update_sh_mesg, &(attr->sh_loc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't get shared message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_update_shared() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_write_cb * @@ -808,13 +791,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata/*in,out*/) +H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata /*in,out*/) { - H5O_iter_wrt_t *udata = (H5O_iter_wrt_t *)_udata; /* Operator user data */ - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_wrt_t * udata = (H5O_iter_wrt_t *)_udata; /* Operator user data */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -824,15 +807,15 @@ H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Check for correct attribute message to modify */ - if(0 == HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->attr->shared->name)) { + if (0 == HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->attr->shared->name)) { /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(udata->f, oh, mesg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(udata->f, oh, mesg->chunkno))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load object header chunk") /* Because the attribute structure is shared now. The only situation that requires * copying the data is when the metadata cache evicts and reloads this attribute. * The shared attribute structure will be different in that situation. SLU-2010/7/29 */ - if(((H5A_t *)mesg->native)->shared != udata->attr->shared) { + if (((H5A_t *)mesg->native)->shared != udata->attr->shared) { /* Sanity check */ HDassert(((H5A_t *)mesg->native)->shared->data); HDassert(udata->attr->shared->data); @@ -840,7 +823,8 @@ H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, /* (Needs to occur before updating the shared message, or the hash * value on the old & new messages will be the same) */ - H5MM_memcpy(((H5A_t *)mesg->native)->shared->data, udata->attr->shared->data, udata->attr->shared->data_size); + H5MM_memcpy(((H5A_t *)mesg->native)->shared->data, udata->attr->shared->data, + udata->attr->shared->data_size); } /* end if */ /* Mark the message as modified */ @@ -848,14 +832,15 @@ H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, chk_dirtied = TRUE; /* Release chunk */ - if(H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) + if (H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") chk_proxy = NULL; /* Update the shared attribute in the SOHM storage */ - if(mesg->flags & H5O_MSG_FLAG_SHARED) - if(H5O__attr_update_shared(udata->f, oh, udata->attr, (H5O_shared_t *)mesg->native) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, "unable to update attribute in shared storage") + if (mesg->flags & H5O_MSG_FLAG_SHARED) + if (H5O__attr_update_shared(udata->f, oh, udata->attr, (H5O_shared_t *)mesg->native) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, + "unable to update attribute in shared storage") /* Indicate that the object header was modified */ *oh_modified = H5O_MODIFY; @@ -869,13 +854,12 @@ H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, done: /* Release chunk, if not already done */ - if(chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_write_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_write * @@ -891,9 +875,9 @@ done: herr_t H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -902,55 +886,54 @@ H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr) HDassert(attr); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Modify the attribute data in dense storage */ - if(H5A__dense_write(loc->file, &ainfo, attr) < 0) + if (H5A__dense_write(loc->file, &ainfo, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") } /* end if */ else { - H5O_iter_wrt_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_wrt_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ - udata.f = loc->file; - udata.attr = attr; + udata.f = loc->file; + udata.attr = attr; udata.found = FALSE; /* Iterate over attributes, to locate correct one to update */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__attr_write_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") /* Check that we found the attribute */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate open attribute?") } /* end else */ /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_write */ - /*------------------------------------------------------------------------- * Function: H5O__attr_rename_chk_cb * @@ -966,11 +949,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5O__attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg /*in,out*/, + unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, + void *_udata /*in,out*/) { - H5O_iter_ren_t *udata = (H5O_iter_ren_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_ren_t *udata = (H5O_iter_ren_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -980,7 +964,7 @@ H5O__attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Check for existing attribute with new name */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->new_name) == 0) { + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->new_name) == 0) { /* Indicate that we found an existing attribute with the new name*/ udata->found = TRUE; @@ -991,7 +975,6 @@ H5O__attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_rename_chk_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_rename_mod_cb * @@ -1012,13 +995,13 @@ H5O__attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, *------------------------------------------------------------------------- */ static herr_t -H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata/*in,out*/) +H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata /*in,out*/) { - H5O_iter_ren_t *udata = (H5O_iter_ren_t *)_udata; /* Operator user data */ - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_ren_t * udata = (H5O_iter_ren_t *)_udata; /* Operator user data */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1028,11 +1011,11 @@ H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Find correct attribute message to rename */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->old_name) == 0) { - unsigned old_version = ((H5A_t *)mesg->native)->shared->version; /* Old version of the attribute */ + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->old_name) == 0) { + unsigned old_version = ((H5A_t *)mesg->native)->shared->version; /* Old version of the attribute */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(udata->f, oh, mesg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(udata->f, oh, mesg->chunkno))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load object header chunk") /* Change the name for the attribute */ @@ -1040,7 +1023,7 @@ H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, ((H5A_t *)mesg->native)->shared->name = H5MM_xstrdup(udata->new_name); /* Recompute the version to encode the attribute with */ - if(H5A__set_version(udata->f, ((H5A_t *)mesg->native)) < 0) + if (H5A__set_version(udata->f, ((H5A_t *)mesg->native)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5_ITER_ERROR, "unable to update attribute version") /* Mark the message as modified */ @@ -1048,24 +1031,25 @@ H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, chk_dirtied = TRUE; /* Release chunk */ - if(H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) + if (H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") chk_proxy = NULL; /* Check for shared message */ - if(mesg->flags & H5O_MSG_FLAG_SHARED) { + if (mesg->flags & H5O_MSG_FLAG_SHARED) { /* Update the shared attribute in the SOHM storage */ - if(H5O__attr_update_shared(udata->f, oh, (H5A_t *)mesg->native, NULL) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, "unable to update attribute in shared storage") + if (H5O__attr_update_shared(udata->f, oh, (H5A_t *)mesg->native, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, + "unable to update attribute in shared storage") } /* end if */ else { /* Sanity check */ HDassert(H5O_msg_is_shared(H5O_ATTR_ID, (H5A_t *)mesg->native) == FALSE); /* Check for attribute message changing size */ - if(HDstrlen(udata->new_name) != HDstrlen(udata->old_name) || - old_version != ((H5A_t *)mesg->native)->shared->version) { - H5A_t *attr; /* Attribute to re-add */ + if (HDstrlen(udata->new_name) != HDstrlen(udata->old_name) || + old_version != ((H5A_t *)mesg->native)->shared->version) { + H5A_t *attr; /* Attribute to re-add */ /* Take ownership of the message's native info (the attribute) * so any shared objects in the file aren't adjusted (and @@ -1077,22 +1061,25 @@ H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, * list of messages during the "add the modified attribute" * step, invalidating the message pointer we have here - QAK) */ - attr = (H5A_t *)mesg->native; + attr = (H5A_t *)mesg->native; mesg->native = NULL; /* Delete old attribute */ /* (doesn't decrement the link count on shared components because * the "native" pointer has been reset) */ - if(H5O__release_mesg(udata->f, oh, mesg, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to release previous attribute") + if (H5O__release_mesg(udata->f, oh, mesg, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, H5_ITER_ERROR, + "unable to release previous attribute") - *oh_modified = H5O_MODIFY_CONDENSE; + *oh_modified = H5O_MODIFY_CONDENSE; /* Append renamed attribute to object header */ /* (Don't let it become shared) */ - if(H5O__msg_append_real(udata->f, oh, H5O_MSG_ATTR, (mesg->flags | H5O_MSG_FLAG_DONTSHARE), 0, attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to relocate renamed attribute in header") + if (H5O__msg_append_real(udata->f, oh, H5O_MSG_ATTR, (mesg->flags | H5O_MSG_FLAG_DONTSHARE), + 0, attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5_ITER_ERROR, + "unable to relocate renamed attribute in header") /* Sanity check */ HDassert(H5O_msg_is_shared(H5O_ATTR_ID, attr) == FALSE); @@ -1100,7 +1087,7 @@ H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, /* Close the local copy of the attribute */ H5A__close(attr); } /* end if */ - } /* end else */ + } /* end else */ /* Indicate that the object header was modified */ *oh_modified |= H5O_MODIFY; @@ -1114,13 +1101,12 @@ H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, done: /* Release chunk, if not already done */ - if(chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_rename_mod_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_rename * @@ -1134,12 +1120,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, - const char *new_name) +H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, const char *new_name) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -1149,66 +1134,65 @@ H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, HDassert(new_name); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Rename the attribute data in dense storage */ - if(H5A__dense_rename(loc->file, &ainfo, old_name, new_name) < 0) + if (H5A__dense_rename(loc->file, &ainfo, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") } /* end if */ else { - H5O_iter_ren_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_ren_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ - udata.f = loc->file; + udata.f = loc->file; udata.old_name = old_name; udata.new_name = new_name; - udata.found = FALSE; + udata.found = FALSE; /* Iterate over attributes, to check if "new name" exists already */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__attr_rename_chk_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") /* If the new name was found, indicate an error */ - if(udata.found) + if (udata.found) HGOTO_ERROR(H5E_ATTR, H5E_EXISTS, FAIL, "attribute with new name already exists") /* Iterate over attributes again, to actually rename attribute with old name */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__attr_rename_mod_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") /* Check that we found the attribute to rename */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute with old name") } /* end else */ /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_rename() */ - /*------------------------------------------------------------------------- * Function: H5O_attr_iterate_real * @@ -1222,14 +1206,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, - const H5A_attr_iter_op_t *attr_op, void *op_data) +H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, + hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - herr_t ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(loc->addr) @@ -1240,62 +1223,62 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, HDassert(attr_op); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check for skipping too many attributes */ - if(skip > 0 && skip >= ainfo.nattrs) + if (skip > 0 && skip >= ainfo.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Release the object header */ - if(H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") oh = NULL; /* Iterate over attributes in dense storage */ - if((ret_value = H5A__dense_iterate(loc->file, loc_id, &ainfo, idx_type, order, skip, last_attr, attr_op, op_data)) < 0) + if ((ret_value = H5A__dense_iterate(loc->file, loc_id, &ainfo, idx_type, order, skip, last_attr, + attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); } /* end if */ else { /* Build table of attributes for compact storage */ - if(H5A__compact_build_table(loc->file, oh, idx_type, order, &atable) < 0) + if (H5A__compact_build_table(loc->file, oh, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Release the object header */ - if(H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") oh = NULL; /* Check for skipping too many attributes */ - if(skip > 0 && skip >= atable.nattrs) + if (skip > 0 && skip >= atable.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Iterate over attributes in table */ - if((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) + if ((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "iteration operator failed"); } /* end else */ done: /* Release resources */ - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_attr_iterate_real() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_iterate * @@ -1309,11 +1292,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) +H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, + const H5A_attr_iter_op_t *attr_op, void *op_data) { - H5G_loc_t loc; /* Object location */ - herr_t ret_value = FAIL; /* Return value */ + H5G_loc_t loc; /* Object location */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1321,18 +1304,18 @@ H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, HDassert(attr_op); /* Look up location for location ID */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if (H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Iterate over attributes to locate correct one */ - if((ret_value = H5O_attr_iterate_real(loc_id, loc.oloc, idx_type, order, skip, last_attr, attr_op, op_data)) < 0) + if ((ret_value = + H5O_attr_iterate_real(loc_id, loc.oloc, idx_type, order, skip, last_attr, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_iterate() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_remove_update * @@ -1356,8 +1339,8 @@ done: static herr_t H5O__attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) { - H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1370,40 +1353,41 @@ H5O__attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) ainfo->nattrs--; /* Check for shifting from dense storage back to compact storage */ - if(H5F_addr_defined(ainfo->fheap_addr) && ainfo->nattrs < oh->min_dense) { - hbool_t can_convert = TRUE; /* Whether converting to attribute messages is possible */ - size_t u; /* Local index */ + if (H5F_addr_defined(ainfo->fheap_addr) && ainfo->nattrs < oh->min_dense) { + hbool_t can_convert = TRUE; /* Whether converting to attribute messages is possible */ + size_t u; /* Local index */ /* Build the table of attributes for this object */ - if(H5A__dense_build_table(loc->file, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, &atable) < 0) + if (H5A__dense_build_table(loc->file, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Inspect attributes in table for ones that can't be converted back * into attribute message form (currently only attributes which * can't fit into an object header message) */ - for(u = 0; u < ainfo->nattrs; u++) - if(H5O_msg_size_oh(loc->file, oh, H5O_ATTR_ID, (atable.attrs[u]), (size_t)0) >= H5O_MESG_MAX_SIZE) { + for (u = 0; u < ainfo->nattrs; u++) + if (H5O_msg_size_oh(loc->file, oh, H5O_ATTR_ID, (atable.attrs[u]), (size_t)0) >= + H5O_MESG_MAX_SIZE) { can_convert = FALSE; break; } /* end if */ /* If ok, insert attributes as object header messages */ - if(can_convert) { - H5A_t *exist_attr = NULL; + if (can_convert) { + H5A_t *exist_attr = NULL; htri_t found_open_attr = FALSE; /* Iterate over attributes, to put them into header */ - for(u = 0; u < ainfo->nattrs; u++) { - htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ + for (u = 0; u < ainfo->nattrs; u++) { + htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ /* Check if attribute is shared */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, (atable.attrs[u]))) < 0) + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, (atable.attrs[u]))) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared") - else if(shared_mesg == 0) { + else if (shared_mesg == 0) { /* Increment reference count on attribute components */ /* (so that they aren't deleted when the dense attribute storage is deleted) */ - if(H5O__attr_link(loc->file, oh, (atable.attrs[u])) < 0) + if (H5O__attr_link(loc->file, oh, (atable.attrs[u])) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") } /* end if */ else { @@ -1414,51 +1398,50 @@ H5O__attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) /* Insert attribute message into object header (Will increment reference count on shared attributes) */ /* Find out whether the attribute has been opened */ - if((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, (atable.attrs[u])->shared->name)) < 0) + if ((found_open_attr = + H5O__attr_find_opened_attr(loc, &exist_attr, (atable.attrs[u])->shared->name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "failed in finding opened attribute") /* If found the attribute is already opened, use the opened message to insert. If not, still use the message in the attribute table. */ - if(found_open_attr && exist_attr) { - if(H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, exist_attr) < 0) + if (found_open_attr && exist_attr) { + if (H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, exist_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't create message") } /* end if */ - else - if(H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, (atable.attrs[u])) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't create message") + else if (H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, (atable.attrs[u])) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't create message") } /* end for */ /* Remove the dense storage */ - if(H5A__dense_delete(loc->file, ainfo) < 0) + if (H5A__dense_delete(loc->file, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete dense attribute storage") } /* end if */ - } /* end if */ + } /* end if */ /* Update the message after removing the attribute */ /* This is particularly needed when removing the last attribute that is * accessed via fractal heap/v2 B-tree (HDFFV-9277) */ - if(H5O__msg_write_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, ainfo) < 0) + if (H5O__msg_write_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info message") /* Check if we have deleted all the attributes and the attribute info * message should be deleted itself. */ - if(ainfo->nattrs == 0) { - if(H5O__msg_remove_real(loc->file, oh, H5O_MSG_AINFO, H5O_ALL, NULL, NULL, TRUE) < 0) + if (ainfo->nattrs == 0) { + if (H5O__msg_remove_real(loc->file, oh, H5O_MSG_AINFO, H5O_ALL, NULL, NULL, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute info") } /* end if */ done: /* Release resources */ - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_remove_update() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_remove_cb * @@ -1474,11 +1457,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata/*in,out*/) +H5O__attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata /*in,out*/) { - H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1488,9 +1471,9 @@ H5O__attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Check for correct attribute message to modify */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { /* Convert message into a null message (i.e. delete it) */ - if(H5O__release_mesg(udata->f, oh, mesg, TRUE) < 0) + if (H5O__release_mesg(udata->f, oh, mesg, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message") /* Indicate that the object header was modified */ @@ -1507,7 +1490,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_remove_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_remove * @@ -1523,10 +1505,10 @@ done: herr_t H5O__attr_remove(const H5O_loc_t *loc, const char *name) { - H5O_t *oh = NULL; /* Pointer to actual object header */ + H5O_t * oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -1535,60 +1517,59 @@ H5O__attr_remove(const H5O_loc_t *loc, const char *name) HDassert(name); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Delete attribute from dense storage */ - if(H5A__dense_remove(loc->file, &ainfo, name) < 0) + if (H5A__dense_remove(loc->file, &ainfo, name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end if */ else { - H5O_iter_rm_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_rm_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ - udata.f = loc->file; - udata.name = name; + udata.f = loc->file; + udata.name = name; udata.found = FALSE; /* Iterate over attributes, to locate correct one to delete */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__attr_remove_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "error deleting attribute") /* Check that we found the attribute */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute") } /* end else */ /* Update the attribute information after removing an attribute */ - if(ainfo_exists) - if(H5O__attr_remove_update(loc, oh, &ainfo) < 0) + if (ainfo_exists) + if (H5O__attr_remove_update(loc, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info") /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_remove() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_remove_by_idx * @@ -1603,14 +1584,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ - H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ + H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -1618,70 +1598,69 @@ H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, HDassert(loc); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Delete attribute from dense storage */ - if(H5A__dense_remove_by_idx(loc->file, &ainfo, idx_type, order, n) < 0) + if (H5A__dense_remove_by_idx(loc->file, &ainfo, idx_type, order, n) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end if */ else { - H5O_iter_rm_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_rm_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Build table of attributes for compact storage */ - if(H5A__compact_build_table(loc->file, oh, idx_type, order, &atable) < 0) + if (H5A__compact_build_table(loc->file, oh, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Check for skipping too many attributes */ - if(n >= atable.nattrs) + if (n >= atable.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Set up user data for callback, to remove the attribute by name */ - udata.f = loc->file; - udata.name = ((atable.attrs[n])->shared)->name; + udata.f = loc->file; + udata.name = ((atable.attrs[n])->shared)->name; udata.found = FALSE; /* Iterate over attributes, to locate correct one to delete */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__attr_remove_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "error deleting attribute") /* Check that we found the attribute */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute") } /* end else */ /* Update the attribute information after removing an attribute */ - if(ainfo_exists) - if(H5O__attr_remove_update(loc, oh, &ainfo) < 0) + if (ainfo_exists) + if (H5O__attr_remove_update(loc, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info") /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_count_real * @@ -1697,7 +1676,7 @@ done: herr_t H5O__attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -1707,26 +1686,26 @@ H5O__attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs) HDassert(nattrs); /* Check for attributes stored densely */ - if(oh->version > H5O_VERSION_1) { - htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ - H5O_ainfo_t ainfo; /* Attribute information for object */ + if (oh->version > H5O_VERSION_1) { + htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ + H5O_ainfo_t ainfo; /* Attribute information for object */ /* Attempt to get the attribute information from the object header */ - if((ainfo_exists = H5A__get_ainfo(f, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(f, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") - else if(ainfo_exists > 0) + else if (ainfo_exists > 0) *nattrs = ainfo.nattrs; else *nattrs = 0; } /* end if */ else { - hsize_t attr_count; /* Number of attributes found */ - unsigned u; /* Local index variable */ + hsize_t attr_count; /* Number of attributes found */ + unsigned u; /* Local index variable */ /* Loop over all messages, counting the attributes */ attr_count = 0; - for(u = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].type == H5O_MSG_ATTR) + for (u = 0; u < oh->nmesgs; u++) + if (oh->mesg[u].type == H5O_MSG_ATTR) attr_count++; *nattrs = attr_count; } /* end else */ @@ -1735,7 +1714,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_count_real */ - /*------------------------------------------------------------------------- * Function: H5O__attr_exists_cb * @@ -1751,11 +1729,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1764,7 +1742,7 @@ H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Check for correct attribute message */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { /* Indicate that this message is the attribute sought */ udata->found = TRUE; @@ -1775,7 +1753,6 @@ H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_exists_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_exists * @@ -1791,9 +1768,9 @@ H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, htri_t H5O__attr_exists(const H5O_loc_t *loc, const char *name) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -1802,36 +1779,36 @@ H5O__attr_exists(const H5O_loc_t *loc, const char *name) HDassert(name); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check if attribute exists in dense storage */ - if((ret_value = H5A__dense_exists(loc->file, &ainfo, name)) < 0) + if ((ret_value = H5A__dense_exists(loc->file, &ainfo, name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error checking for existence of attribute") } /* end if */ else { - H5O_iter_rm_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_rm_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ - udata.f = loc->file; - udata.name = name; + udata.f = loc->file; + udata.name = name; udata.found = FALSE; /* Iterate over existing attributes, checking for attribute with same name */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__attr_exists_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error checking for existence of attribute") /* Check that we found the attribute */ @@ -1839,13 +1816,12 @@ H5O__attr_exists(const H5O_loc_t *loc, const char *name) } /* end else */ done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_exists() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_bh_info * @@ -1861,10 +1837,10 @@ done: herr_t H5O__attr_bh_info(H5F_t *f, H5O_t *oh, H5_ih_info_t *bh_info) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1873,63 +1849,64 @@ H5O__attr_bh_info(H5F_t *f, H5O_t *oh, H5_ih_info_t *bh_info) HDassert(bh_info); /* Attributes are only stored in fractal heap & indexed w/v2 B-tree in later versions */ - if(oh->version > H5O_VERSION_1) { - H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ + if (oh->version > H5O_VERSION_1) { + H5O_ainfo_t ainfo; /* Attribute information for object */ + htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(f, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(f, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") - else if(ainfo_exists > 0) { + else if (ainfo_exists > 0) { /* Check if name index available */ - if(H5F_addr_defined(ainfo.name_bt2_addr)) { + if (H5F_addr_defined(ainfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ - if(H5B2_size(bt2_name, &(bh_info->index_size)) < 0) + if (H5B2_size(bt2_name, &(bh_info->index_size)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") } /* end if */ /* Check if creation order index available */ - if(H5F_addr_defined(ainfo.corder_bt2_addr)) { + if (H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(f, ainfo.corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(f, ainfo.corder_bt2_addr, NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ - if(H5B2_size(bt2_corder, &(bh_info->index_size)) < 0) + if (H5B2_size(bt2_corder, &(bh_info->index_size)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") } /* end if */ /* Get storage size of fractal heap, if it's used */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Open the fractal heap for attributes */ - if(NULL == (fheap = H5HF_open(f, ainfo.fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo.fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Get heap storage size */ - if(H5HF_size(fheap, &(bh_info->heap_size)) < 0) + if (H5HF_size(fheap, &(bh_info->heap_size)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__attr_bh_info() */ +} /* H5O__attr_bh_info() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5O__attr_count * @@ -1945,9 +1922,9 @@ done: int H5O__attr_count(const H5O_loc_t *loc) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - hsize_t nattrs; /* Number of attributes */ - int ret_value = -1; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + hsize_t nattrs; /* Number of attributes */ + int ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -1955,21 +1932,20 @@ H5O__attr_count(const H5O_loc_t *loc) HDassert(loc); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Retrieve # of attributes on object */ - if(H5O__attr_count_real(loc->file, oh, &nattrs) < 0) + if (H5O__attr_count_real(loc->file, oh, &nattrs) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve attribute count") /* Set return value */ ret_value = (int)nattrs; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_count */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Obogus.c b/src/H5Obogus.c index f3cca0f..400f8f4 100644 --- a/src/H5Obogus.c +++ b/src/H5Obogus.c @@ -26,73 +26,70 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ #ifdef H5O_ENABLE_BOGUS /* PRIVATE PROTOTYPES */ -static void *H5O__bogus_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__bogus_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_bogus_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); static size_t H5O_bogus_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); -static herr_t H5O__bogus_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__bogus_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_BOGUS_VALID[1] = {{ - H5O_BOGUS_VALID_ID, /*message id number */ - "bogus valid", /*message name for debugging */ - 0, /*native message size */ - H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ - H5O__bogus_decode, /*decode message */ - H5O_bogus_encode, /*encode message */ - NULL, /*copy the native value */ - H5O_bogus_size, /*raw message size */ - NULL, /*free internal memory */ - NULL, /*free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__bogus_debug /*debug the message */ + H5O_BOGUS_VALID_ID, /*message id number */ + "bogus valid", /*message name for debugging */ + 0, /*native message size */ + H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ + H5O__bogus_decode, /*decode message */ + H5O_bogus_encode, /*encode message */ + NULL, /*copy the native value */ + H5O_bogus_size, /*raw message size */ + NULL, /*free internal memory */ + NULL, /*free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__bogus_debug /*debug the message */ }}; /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_BOGUS_INVALID[1] = {{ - H5O_BOGUS_INVALID_ID, /*message id number */ - "bogus invalid", /*message name for debugging */ - 0, /*native message size */ - H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ - H5O__bogus_decode, /*decode message */ - H5O_bogus_encode, /*encode message */ - NULL, /*copy the native value */ - H5O_bogus_size, /*raw message size */ - NULL, /*free internal memory */ - NULL, /*free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__bogus_debug /*debug the message */ + H5O_BOGUS_INVALID_ID, /*message id number */ + "bogus invalid", /*message name for debugging */ + 0, /*native message size */ + H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ + H5O__bogus_decode, /*decode message */ + H5O_bogus_encode, /*encode message */ + NULL, /*copy the native value */ + H5O_bogus_size, /*raw message size */ + NULL, /*free internal memory */ + NULL, /*free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__bogus_debug /*debug the message */ }}; - /*------------------------------------------------------------------------- * Function: H5O__bogus_decode * @@ -110,12 +107,11 @@ const H5O_msg_class_t H5O_MSG_BOGUS_INVALID[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O__bogus_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__bogus_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_bogus_t *mesg = NULL; - void *ret_value; /* Return value */ + void * ret_value; /* Return value */ FUNC_ENTER_STATIC @@ -124,27 +120,26 @@ H5O__bogus_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Allocate the bogus message */ - if(NULL == (mesg = (H5O_bogus_t *)H5MM_calloc(sizeof(H5O_bogus_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (mesg = (H5O_bogus_t *)H5MM_calloc(sizeof(H5O_bogus_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* decode */ UINT32DECODE(p, mesg->u); /* Validate the bogus info */ - if(mesg->u != H5O_BOGUS_VALUE) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid bogus value :-)") + if (mesg->u != H5O_BOGUS_VALUE) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid bogus value :-)") /* Set return value */ ret_value = mesg; done: - if(ret_value == NULL && mesg != NULL) + if (ret_value == NULL && mesg != NULL) H5MM_xfree(mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__bogus_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_bogus_encode * @@ -159,7 +154,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_bogus_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void H5_ATTR_UNUSED *mesg) +H5O_bogus_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void H5_ATTR_UNUSED *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -174,7 +170,6 @@ H5O_bogus_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_bogus_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_bogus_size * @@ -194,14 +189,14 @@ H5O_bogus_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, *------------------------------------------------------------------------- */ static size_t -H5O_bogus_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *mesg) +H5O_bogus_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(4) } /* end H5O_bogus_size() */ - /*------------------------------------------------------------------------- * Function: H5O__bogus_debug * @@ -218,10 +213,9 @@ H5O_bogus_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sha *------------------------------------------------------------------------- */ static herr_t -H5O__bogus_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__bogus_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_bogus_t *mesg = (const H5O_bogus_t *)_mesg; + const H5O_bogus_t *mesg = (const H5O_bogus_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -232,10 +226,8 @@ H5O__bogus_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s `%u'\n", indent, "", fwidth, - "Bogus Value:", mesg->u); + HDfprintf(stream, "%*s%-*s `%u'\n", indent, "", fwidth, "Bogus Value:", mesg->u); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__bogus_debug() */ #endif /* H5O_ENABLE_BOGUS */ - diff --git a/src/H5Obtreek.c b/src/H5Obtreek.c index 5a98e59..b63f338 100644 --- a/src/H5Obtreek.c +++ b/src/H5Obtreek.c @@ -11,7 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* Programmer: Quincey Koziol * Thursday, March 1, 2007 * @@ -19,50 +18,47 @@ * information in the superblock extension. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object headers */ +#include "H5MMprivate.h" /* Memory management */ -static void *H5O_btreek_decode(H5F_t *f, H5O_t *open_oh, - unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O_btreek_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_btreek_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_btreek_copy(const void *_mesg, void *_dest); +static void * H5O_btreek_copy(const void *_mesg, void *_dest); static size_t H5O_btreek_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); -static herr_t H5O__btreek_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__btreek_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_BTREEK[1] = {{ - H5O_BTREEK_ID, /*message id number */ - "v1 B-tree 'K' values", /*message name for debugging */ - sizeof(H5O_btreek_t), /*native message size */ - 0, /* messages are sharable? */ - H5O_btreek_decode, /*decode message */ - H5O_btreek_encode, /*encode message */ - H5O_btreek_copy, /*copy the native value */ - H5O_btreek_size, /*raw message size */ - NULL, /*free internal memory */ - NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__btreek_debug /*debug the message */ + H5O_BTREEK_ID, /*message id number */ + "v1 B-tree 'K' values", /*message name for debugging */ + sizeof(H5O_btreek_t), /*native message size */ + 0, /* messages are sharable? */ + H5O_btreek_decode, /*decode message */ + H5O_btreek_encode, /*encode message */ + H5O_btreek_copy, /*copy the native value */ + H5O_btreek_size, /*raw message size */ + NULL, /*free internal memory */ + NULL, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__btreek_debug /*debug the message */ }}; /* Current version of v1 B-tree 'K' value information */ -#define H5O_BTREEK_VERSION 0 +#define H5O_BTREEK_VERSION 0 - /*------------------------------------------------------------------------- * Function: H5O_btreek_decode * @@ -78,12 +74,11 @@ const H5O_msg_class_t H5O_MSG_BTREEK[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O_btreek_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O_btreek_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_btreek_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_btreek_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -92,12 +87,12 @@ H5O_btreek_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_BTREEK_VERSION) + if (*p++ != H5O_BTREEK_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (mesg = (H5O_btreek_t *)H5MM_calloc(sizeof(H5O_btreek_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for v1 B-tree 'K' message") + if (NULL == (mesg = (H5O_btreek_t *)H5MM_calloc(sizeof(H5O_btreek_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for v1 B-tree 'K' message") /* Retrieve non-default B-tree 'K' values */ UINT16DECODE(p, mesg->btree_k[H5B_CHUNK_ID]); @@ -111,7 +106,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_btreek_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_btreek_encode * @@ -125,7 +119,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_btreek_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O_btreek_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; @@ -145,7 +140,6 @@ H5O_btreek_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_btreek_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_btreek_copy * @@ -163,17 +157,18 @@ H5O_btreek_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared static void * H5O_btreek_copy(const void *_mesg, void *_dest) { - const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; - H5O_btreek_t *dest = (H5O_btreek_t *)_dest; - void *ret_value = NULL; /* Return value */ + const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; + H5O_btreek_t * dest = (H5O_btreek_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity check */ HDassert(mesg); - if(!dest && NULL == (dest = (H5O_btreek_t *)H5MM_malloc(sizeof(H5O_btreek_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message") + if (!dest && NULL == (dest = (H5O_btreek_t *)H5MM_malloc(sizeof(H5O_btreek_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for shared message table message") /* All this message requires is a shallow copy */ *dest = *mesg; @@ -185,7 +180,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_btreek_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_btreek_size * @@ -201,24 +195,24 @@ done: *------------------------------------------------------------------------- */ static size_t -H5O_btreek_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) +H5O_btreek_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value; + size_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ HDassert(f); - ret_value = 1 + /* Version number */ - 2 + /* Chunked storage internal B-tree 'K' value */ - 2 + /* Symbol table node internal B-tree 'K' value */ - 2; /* Symbol table node leaf 'K' value */ + ret_value = 1 + /* Version number */ + 2 + /* Chunked storage internal B-tree 'K' value */ + 2 + /* Symbol table node internal B-tree 'K' value */ + 2; /* Symbol table node leaf 'K' value */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_btreek_size() */ - /*------------------------------------------------------------------------- * Function: H5O__btreek_debug * @@ -232,8 +226,7 @@ H5O_btreek_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sh *------------------------------------------------------------------------- */ static herr_t -H5O__btreek_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__btreek_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; @@ -247,12 +240,11 @@ H5O__btreek_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Chunked storage internal B-tree 'K' value:", mesg->btree_k[H5B_CHUNK_ID]); + "Chunked storage internal B-tree 'K' value:", mesg->btree_k[H5B_CHUNK_ID]); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table node internal B-tree 'K' value:", mesg->btree_k[H5B_SNODE_ID]); + "Symbol table node internal B-tree 'K' value:", mesg->btree_k[H5B_SNODE_ID]); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table node leaf 'K' value:", mesg->sym_leaf_k); + "Symbol table node leaf 'K' value:", mesg->sym_leaf_k); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__btreek_debug() */ - diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 53ae461..86f781f 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -26,76 +26,64 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache callbacks */ static herr_t H5O__cache_get_initial_load_size(void *udata, size_t *image_len); -static herr_t H5O__cache_get_final_load_size(const void *image_ptr, size_t image_len, - void *udata, size_t *actual_len); +static herr_t H5O__cache_get_final_load_size(const void *image_ptr, size_t image_len, void *udata, + size_t *actual_len); static htri_t H5O__cache_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5O__cache_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5O__cache_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5O__cache_image_len(const void *thing, size_t *image_len); -static herr_t H5O__cache_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5O__cache_notify(H5AC_notify_action_t action, void *_thing); static herr_t H5O__cache_free_icr(void *thing); static herr_t H5O__cache_chk_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5O__cache_chk_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5O__cache_chk_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5O__cache_chk_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5O__cache_chk_image_len(const void *thing, size_t *image_len); -static herr_t H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, - void *thing); +static herr_t H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing); static herr_t H5O__cache_chk_free_icr(void *thing); /* Prefix routines */ -static herr_t H5O__prefix_deserialize(const uint8_t *image, - H5O_cache_ud_t *udata); +static herr_t H5O__prefix_deserialize(const uint8_t *image, H5O_cache_ud_t *udata); /* Chunk routines */ -static herr_t H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, - const uint8_t *image, H5O_common_cache_ud_t *udata, hbool_t *dirty); +static herr_t H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, + H5O_common_cache_ud_t *udata, hbool_t *dirty); static herr_t H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno); /* Misc. routines */ -static herr_t H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, - const H5O_cont_t *cont); - +static herr_t H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, const H5O_cont_t *cont); /*********************/ /* Package Variables */ @@ -103,40 +91,40 @@ static herr_t H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, /* H5O object header prefix inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_OHDR[1] = {{ - H5AC_OHDR_ID, /* Metadata client ID */ - "object header", /* Metadata client name (for debugging) */ - H5FD_MEM_OHDR, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5O__cache_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5O__cache_get_final_load_size, /* 'get_final_load_size' callback */ - H5O__cache_verify_chksum, /* 'verify_chksum' callback */ - H5O__cache_deserialize, /* 'deserialize' callback */ - H5O__cache_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5O__cache_serialize, /* 'serialize' callback */ - H5O__cache_notify, /* 'notify' callback */ - H5O__cache_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + H5AC_OHDR_ID, /* Metadata client ID */ + "object header", /* Metadata client name (for debugging) */ + H5FD_MEM_OHDR, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5O__cache_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5O__cache_get_final_load_size, /* 'get_final_load_size' callback */ + H5O__cache_verify_chksum, /* 'verify_chksum' callback */ + H5O__cache_deserialize, /* 'deserialize' callback */ + H5O__cache_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5O__cache_serialize, /* 'serialize' callback */ + H5O__cache_notify, /* 'notify' callback */ + H5O__cache_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* H5O object header chunk inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_OHDR_CHK[1] = {{ - H5AC_OHDR_CHK_ID, /* Metadata client ID */ - "object header continuation chunk", /* Metadata client name (for debugging) */ - H5FD_MEM_OHDR, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_OHDR_CHK_ID, /* Metadata client ID */ + "object header continuation chunk", /* Metadata client name (for debugging) */ + H5FD_MEM_OHDR, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5O__cache_chk_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5O__cache_chk_verify_chksum, /* 'verify_chksum' callback */ - H5O__cache_chk_deserialize, /* 'deserialize' callback */ - H5O__cache_chk_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5O__cache_chk_serialize, /* 'serialize' callback */ - H5O__cache_chk_notify, /* 'notify' callback */ - H5O__cache_chk_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* VFD SWMR 'refresh' callback */ + NULL, /* 'get_final_load_size' callback */ + H5O__cache_chk_verify_chksum, /* 'verify_chksum' callback */ + H5O__cache_chk_deserialize, /* 'deserialize' callback */ + H5O__cache_chk_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5O__cache_chk_serialize, /* 'serialize' callback */ + H5O__cache_chk_notify, /* 'notify' callback */ + H5O__cache_chk_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* VFD SWMR 'refresh' callback */ }}; /* Declare external the free list for H5O_unknown_t's */ @@ -148,18 +136,14 @@ H5FL_EXTERN(H5O_chunk_proxy_t); /* Declare the free list for H5O_cont_t sequences */ H5FL_SEQ_DEFINE(H5O_cont_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O__cache_get_initial_load_size() * @@ -188,7 +172,6 @@ H5O__cache_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cache_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_get_final_load_size() * @@ -203,11 +186,11 @@ H5O__cache_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *_udata, size_t *actual_len) +H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, + size_t *actual_len) { - H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -218,7 +201,7 @@ H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED i HDassert(*actual_len == image_len); /* Deserialize the object header prefix */ - if(H5O__prefix_deserialize((const uint8_t *)image, udata) < 0) + if (H5O__prefix_deserialize((const uint8_t *)image, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "can't deserialize object header prefix") /* Sanity check */ @@ -231,7 +214,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_verify_chksum * @@ -249,9 +231,9 @@ done: static htri_t H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -261,14 +243,14 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) HDassert(udata->oh); /* There is no checksum for version 1 */ - if(udata->oh->version != H5O_VERSION_1) { - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + if (udata->oh->version != H5O_VERSION_1) { + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) { + if (stored_chksum != computed_chksum) { /* These fields are not deserialized yet in H5O__prefix_deserialize() */ HDassert(udata->oh->chunk == NULL); HDassert(udata->oh->mesg == NULL); @@ -277,16 +259,15 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) /* Indicate that udata->oh is to be freed later in H5O__prefix_deserialize() */ udata->free_oh = TRUE; - ret_value = FALSE; + ret_value = FALSE; } /* end if */ - } /* end if */ + } /* end if */ else HDassert(!(udata->common.file_intent & H5F_ACC_SWMR_WRITE)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_deserialize * @@ -308,12 +289,11 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) *------------------------------------------------------------------------- */ static void * -H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t *dirty) +H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t *dirty) { - H5O_t *oh = NULL; /* Object header read in */ - H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ - void * ret_value = NULL; /* Return value */ + H5O_t * oh = NULL; /* Object header read in */ + H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -330,9 +310,9 @@ H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void * through the 'get_final_load_size' callback and not deserialized if * the object header is coming from a cache image - QAK, 2016/12/14) */ - if(NULL == udata->oh) { + if (NULL == udata->oh) { /* Deserialize the object header prefix */ - if(H5O__prefix_deserialize((const uint8_t *)image, udata) < 0) + if (H5O__prefix_deserialize((const uint8_t *)image, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't deserialize object header prefix") /* Sanity check */ @@ -346,16 +326,17 @@ H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void oh->swmr_write = !!(H5F_INTENT(udata->common.f) & H5F_ACC_SWMR_WRITE); /* Create object header proxy if doing SWMR writes */ - if(oh->swmr_write) { + if (oh->swmr_write) { /* Create virtual entry, for use as proxy */ - if(NULL == (oh->proxy = H5AC_proxy_entry_create())) + if (NULL == (oh->proxy = H5AC_proxy_entry_create())) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, NULL, "can't create object header proxy") } /* end if */ else oh->proxy = NULL; /* Parse the first chunk */ - if(H5O__chunk_deserialize(oh, udata->common.addr, udata->chunk0_size, (const uint8_t *)image, &(udata->common), dirty) < 0) + if (H5O__chunk_deserialize(oh, udata->common.addr, udata->chunk0_size, (const uint8_t *)image, + &(udata->common), dirty) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't deserialize first object header chunk") /* Note that we've loaded the object header from the file */ @@ -366,14 +347,13 @@ H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void done: /* Release the [possibly partially initialized] object header on errors */ - if(!ret_value && oh) - if(H5O__free(oh) < 0) + if (!ret_value && oh) + if (H5O__free(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header data") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_image_len * @@ -392,7 +372,7 @@ done: static herr_t H5O__cache_image_len(const void *_thing, size_t *image_len) { - const H5O_t *oh = (const H5O_t *)_thing; /* Object header to query */ + const H5O_t *oh = (const H5O_t *)_thing; /* Object header to query */ FUNC_ENTER_STATIC_NOERR @@ -408,7 +388,6 @@ H5O__cache_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cache_image_len() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_serialize * @@ -426,9 +405,9 @@ H5O__cache_image_len(const void *_thing, size_t *image_len) static herr_t H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) { - H5O_t *oh = (H5O_t *)_thing; /* Object header to encode */ - uint8_t *chunk_image; /* Pointer to object header prefix buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = (H5O_t *)_thing; /* Object header to encode */ + uint8_t *chunk_image; /* Pointer to object header prefix buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -453,8 +432,8 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) * on the entire block of memory needs to be updated if anything is * modified */ - if(oh->version > H5O_VERSION_1) { - uint64_t chunk0_size; /* Size of chunk 0's data */ + if (oh->version > H5O_VERSION_1) { + uint64_t chunk0_size; /* Size of chunk 0's data */ HDassert(oh->chunk[0].size >= (size_t)H5O_SIZEOF_HDR(oh)); chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); @@ -470,7 +449,7 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) *chunk_image++ = oh->flags; /* Time fields */ - if(oh->flags & H5O_HDR_STORE_TIMES) { + if (oh->flags & H5O_HDR_STORE_TIMES) { UINT32ENCODE(chunk_image, oh->atime); UINT32ENCODE(chunk_image, oh->mtime); UINT32ENCODE(chunk_image, oh->ctime); @@ -478,37 +457,37 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) } /* end if */ /* Attribute fields */ - if(oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { + if (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { UINT16ENCODE(chunk_image, oh->max_compact); UINT16ENCODE(chunk_image, oh->min_dense); } /* end if */ /* First chunk size */ - switch(oh->flags & H5O_HDR_CHUNK0_SIZE) { - case 0: /* 1 byte size */ + switch (oh->flags & H5O_HDR_CHUNK0_SIZE) { + case 0: /* 1 byte size */ HDassert(chunk0_size < 256); *chunk_image++ = (uint8_t)chunk0_size; break; - case 1: /* 2 byte size */ + case 1: /* 2 byte size */ HDassert(chunk0_size < 65536); UINT16ENCODE(chunk_image, chunk0_size); break; - case 2: /* 4 byte size */ + case 2: /* 4 byte size */ /* use <= 2**32 -1 to stay within 4 bytes integer range */ HDassert(chunk0_size <= 4294967295UL); UINT32ENCODE(chunk_image, chunk0_size); break; - case 3: /* 8 byte size */ + case 3: /* 8 byte size */ UINT64ENCODE(chunk_image, chunk0_size); break; default: HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0") } /* end switch */ - } /* end if */ + } /* end if */ else { /* Version */ *chunk_image++ = oh->version; @@ -518,8 +497,8 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) /* Number of messages */ #ifdef H5O_ENABLE_BAD_MESG_COUNT - if(oh->store_bad_mesg_count) - UINT16ENCODE(chunk_image, (oh->nmesgs - 1)) + if (oh->store_bad_mesg_count) + UINT16ENCODE(chunk_image, (oh->nmesgs - 1)) else #endif /* H5O_ENABLE_BAD_MESG_COUNT */ UINT16ENCODE(chunk_image, oh->nmesgs); @@ -535,10 +514,11 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) chunk_image += (size_t)(H5O_SIZEOF_HDR(oh) - 12); } /* end else */ - HDassert((size_t)(chunk_image - oh->chunk[0].image) == (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); + HDassert((size_t)(chunk_image - oh->chunk[0].image) == + (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); /* Serialize messages for this chunk */ - if(H5O__chunk_serialize(f, oh, (unsigned)0) < 0) + if (H5O__chunk_serialize(f, oh, (unsigned)0) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "unable to serialize first object header chunk") /* copy the chunk into the image -- this is potentially expensive. @@ -551,7 +531,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_serialize() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_notify * @@ -567,8 +546,8 @@ done: static herr_t H5O__cache_notify(H5AC_notify_action_t action, void *_thing) { - H5O_t *oh = (H5O_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = (H5O_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -577,15 +556,15 @@ H5O__cache_notify(H5AC_notify_action_t action, void *_thing) */ HDassert(oh); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: - if(oh->swmr_write) { + if (oh->swmr_write) { /* Sanity check */ HDassert(oh->proxy); /* Register the object header as a parent of the virtual entry */ - if(H5AC_proxy_entry_add_parent(oh->proxy, oh) < 0) + if (H5AC_proxy_entry_add_parent(oh->proxy, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't add object header as parent of proxy") } /* end if */ break; @@ -595,32 +574,30 @@ H5O__cache_notify(H5AC_notify_action_t action, void *_thing) /* do nothing */ break; - case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: - { - unsigned u; /* Local index variable */ + case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: { + unsigned u; /* Local index variable */ - /* Mark messages stored with the object header (i.e. messages in chunk 0) as clean */ - for(u = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].chunkno == 0) - oh->mesg[u].dirty = FALSE; + /* Mark messages stored with the object header (i.e. messages in chunk 0) as clean */ + for (u = 0; u < oh->nmesgs; u++) + if (oh->mesg[u].chunkno == 0) + oh->mesg[u].dirty = FALSE; #ifndef NDEBUG - /* Reset the number of messages dirtied by decoding */ - oh->ndecode_dirtied = 0; + /* Reset the number of messages dirtied by decoding */ + oh->ndecode_dirtied = 0; #endif /* NDEBUG */ - } - break; + } break; case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: - case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: - case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: + case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: + case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: /* do nothing */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if(oh->swmr_write) { + if (oh->swmr_write) { /* Unregister the object header as a parent of the virtual entry */ - if(H5AC_proxy_entry_remove_parent(oh->proxy, oh) < 0) + if (H5AC_proxy_entry_remove_parent(oh->proxy, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't remove object header as parent of proxy") } /* end if */ break; @@ -633,7 +610,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_notify() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_free_icr * @@ -654,8 +630,8 @@ done: static herr_t H5O__cache_free_icr(void *_thing) { - H5O_t *oh = (H5O_t *)_thing; /* Object header to destroy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = (H5O_t *)_thing; /* Object header to destroy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -665,14 +641,13 @@ H5O__cache_free_icr(void *_thing) HDassert(oh->cache_info.type == H5AC_OHDR); /* Destroy object header */ - if(H5O__free(oh) < 0) + if (H5O__free(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_get_initial_load_size() * @@ -706,7 +681,6 @@ H5O__cache_chk_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cache_chk_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_chk_verify_chksum * @@ -724,9 +698,9 @@ H5O__cache_chk_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5O__cache_chk_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -734,21 +708,20 @@ H5O__cache_chk_verify_chksum(const void *_image, size_t len, void *_udata) HDassert(image); /* There is no checksum for version 1 */ - if(udata->oh->version != H5O_VERSION_1) { - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + if (udata->oh->version != H5O_VERSION_1) { + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ - /* Get stored and computed checksums */ - H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); + /* Get stored and computed checksums */ + H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_deserialize * @@ -765,12 +738,11 @@ H5O__cache_chk_verify_chksum(const void *_image, size_t len, void *_udata) *------------------------------------------------------------------------- */ static void * -H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t *dirty) +H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t *dirty) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk proxy object */ - H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */ - void *ret_value = NULL; /* Return value */ + H5O_chunk_proxy_t * chk_proxy = NULL; /* Chunk proxy object */ + H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -782,18 +754,19 @@ H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, HDassert(dirty); /* Allocate space for the object header data structure */ - if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) + if (NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Check if we are still decoding the object header */ /* (as opposed to bringing a piece of it back from the file) */ - if(udata->decoding) { + if (udata->decoding) { /* Sanity check */ HDassert(udata->common.f); HDassert(udata->common.cont_msg_info); /* Parse the chunk */ - if(H5O__chunk_deserialize(udata->oh, udata->common.addr, udata->size, (const uint8_t *)image, &(udata->common), dirty) < 0) + if (H5O__chunk_deserialize(udata->oh, udata->common.addr, udata->size, (const uint8_t *)image, + &(udata->common), dirty) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't deserialize object header chunk") /* Set the chunk number for the chunk proxy */ @@ -809,11 +782,12 @@ H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, /* Sanity check that the chunk representation we have in memory is * the same as the one being brought in from disk. */ - HDassert(0 == HDmemcmp(image, udata->oh->chunk[chk_proxy->chunkno].image, udata->oh->chunk[chk_proxy->chunkno].size)); + HDassert(0 == HDmemcmp(image, udata->oh->chunk[chk_proxy->chunkno].image, + udata->oh->chunk[chk_proxy->chunkno].size)); } /* end else */ /* Increment reference count of object header */ - if(H5O__inc_rc(udata->oh) < 0) + if (H5O__inc_rc(udata->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "can't increment reference count on object header") chk_proxy->oh = udata->oh; @@ -821,14 +795,13 @@ H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, ret_value = chk_proxy; done: - if(NULL == ret_value) - if(chk_proxy && H5O__chunk_dest(chk_proxy) < 0) + if (NULL == ret_value) + if (chk_proxy && H5O__chunk_dest(chk_proxy) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_image_len * @@ -846,7 +819,7 @@ done: static herr_t H5O__cache_chk_image_len(const void *_thing, size_t *image_len) { - const H5O_chunk_proxy_t * chk_proxy = (const H5O_chunk_proxy_t *)_thing; /* Chunk proxy to query */ + const H5O_chunk_proxy_t *chk_proxy = (const H5O_chunk_proxy_t *)_thing; /* Chunk proxy to query */ FUNC_ENTER_STATIC_NOERR @@ -862,7 +835,6 @@ H5O__cache_chk_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cache_chk_image_len() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_serialize * @@ -882,8 +854,8 @@ H5O__cache_chk_image_len(const void *_thing, size_t *image_len) static herr_t H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *_thing) { - H5O_chunk_proxy_t * chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk to serialize */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk to serialize */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -897,7 +869,7 @@ H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *_thing) HDassert(chk_proxy->oh->chunk[chk_proxy->chunkno].size == len); /* Serialize messages for this chunk */ - if(H5O__chunk_serialize(f, chk_proxy->oh, chk_proxy->chunkno) < 0) + if (H5O__chunk_serialize(f, chk_proxy->oh, chk_proxy->chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "unable to serialize object header continuation chunk") /* copy the chunk into the image -- this is potentially expensive. @@ -909,7 +881,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_serialize() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_notify * @@ -926,7 +897,7 @@ static herr_t H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) { H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -936,28 +907,29 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) HDassert(chk_proxy); HDassert(chk_proxy->oh); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: - if(chk_proxy->oh->swmr_write) { + if (chk_proxy->oh->swmr_write) { /* Add flush dependency on chunk with continuation, if one exists */ - if(chk_proxy->fd_parent) { + if (chk_proxy->fd_parent) { /* Sanity checks */ - HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == + H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type); - HDassert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) - || (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); + HDassert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) || + (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); /* Add flush dependency from chunk containing the continuation message * that points to this chunk (either oh or another chunk proxy object) */ - if(H5AC_create_flush_dependency(chk_proxy->fd_parent, chk_proxy) < 0) + if (H5AC_create_flush_dependency(chk_proxy->fd_parent, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ /* Add flush dependency on object header */ { - if(H5AC_create_flush_dependency(chk_proxy->oh, chk_proxy) < 0) + if (H5AC_create_flush_dependency(chk_proxy->oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -967,8 +939,9 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) HDassert(chk_proxy->oh->proxy); /* Register the object header chunk as a parent of the virtual entry */ - if(H5AC_proxy_entry_add_parent(chk_proxy->oh->proxy, chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't add object header chunk as parent of proxy") + if (H5AC_proxy_entry_add_parent(chk_proxy->oh->proxy, chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, + "can't add object header chunk as parent of proxy") } } /* end if */ break; @@ -978,61 +951,61 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) /* do nothing */ break; - case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: - { - unsigned u; /* Local index variable */ + case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: { + unsigned u; /* Local index variable */ - /* Mark messages in chunk as clean */ - for(u = 0; u < chk_proxy->oh->nmesgs; u++) - if(chk_proxy->oh->mesg[u].chunkno == chk_proxy->chunkno) - chk_proxy->oh->mesg[u].dirty = FALSE; - } - break; + /* Mark messages in chunk as clean */ + for (u = 0; u < chk_proxy->oh->nmesgs; u++) + if (chk_proxy->oh->mesg[u].chunkno == chk_proxy->chunkno) + chk_proxy->oh->mesg[u].dirty = FALSE; + } break; case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: - case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: - case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: + case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: + case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: /* do nothing */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if(chk_proxy->oh->swmr_write) { + if (chk_proxy->oh->swmr_write) { /* Remove flush dependency on parent object header chunk, if one is set */ - if(chk_proxy->fd_parent) { + if (chk_proxy->fd_parent) { /* Sanity checks */ - HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == + H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type); - HDassert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) || (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); + HDassert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) || + (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); - if(H5AC_destroy_flush_dependency(chk_proxy->fd_parent, chk_proxy) < 0) + if (H5AC_destroy_flush_dependency(chk_proxy->fd_parent, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") chk_proxy->fd_parent = NULL; } /* end if */ /* Unregister the object header as a parent of the virtual entry */ - if(H5AC_destroy_flush_dependency(chk_proxy->oh, chk_proxy) < 0) + if (H5AC_destroy_flush_dependency(chk_proxy->oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Unregister the object header chunk as a parent of the virtual entry */ - if(H5AC_proxy_entry_remove_parent(chk_proxy->oh->proxy, chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't remove object header chunk as parent of proxy") + if (H5AC_proxy_entry_remove_parent(chk_proxy->oh->proxy, chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, + "can't remove object header chunk as parent of proxy") } /* end if */ break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_notify() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_free_icr * @@ -1054,8 +1027,8 @@ done: static herr_t H5O__cache_chk_free_icr(void *_thing) { - H5O_chunk_proxy_t * chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk proxy to release */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk proxy to release */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1065,14 +1038,13 @@ H5O__cache_chk_free_icr(void *_thing) HDassert(chk_proxy->cache_info.type == H5AC_OHDR_CHK); /* Destroy object header chunk proxy */ - if(H5O__chunk_dest(chk_proxy) < 0) + if (H5O__chunk_dest(chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk proxy") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5O__add_cont_msg * @@ -1101,27 +1073,26 @@ H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, const H5O_cont_t *cont) HDassert(cont); /* Increase chunk array size, if necessary */ - if(cont_msg_info->nmsgs >= cont_msg_info->alloc_nmsgs) { - size_t na = MAX(H5O_NCHUNKS, cont_msg_info->alloc_nmsgs * 2); /* Double # of messages allocated */ + if (cont_msg_info->nmsgs >= cont_msg_info->alloc_nmsgs) { + size_t na = MAX(H5O_NCHUNKS, cont_msg_info->alloc_nmsgs * 2); /* Double # of messages allocated */ H5O_cont_t *x; - if(NULL == (x = H5FL_SEQ_REALLOC(H5O_cont_t, cont_msg_info->msgs, na))) + if (NULL == (x = H5FL_SEQ_REALLOC(H5O_cont_t, cont_msg_info->msgs, na))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "memory allocation failed") cont_msg_info->alloc_nmsgs = na; - cont_msg_info->msgs = x; + cont_msg_info->msgs = x; } /* end if */ /* Init the continuation message info */ - contno = cont_msg_info->nmsgs++; - cont_msg_info->msgs[contno].addr = cont->addr; - cont_msg_info->msgs[contno].size = cont->size; + contno = cont_msg_info->nmsgs++; + cont_msg_info->msgs[contno].addr = cont->addr; + cont_msg_info->msgs[contno].size = cont->size; cont_msg_info->msgs[contno].chunkno = cont->chunkno; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__add_cont_msg() */ - /*------------------------------------------------------------------------- * Function: H5O__prefix_deserialize() * @@ -1138,9 +1109,9 @@ done: static herr_t H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5O_t *oh = NULL; /* Object header read in */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5O_t * oh = NULL; /* Object header read in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1149,7 +1120,7 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) HDassert(udata); /* Allocate space for the new object header data structure */ - if(NULL == (oh = H5FL_CALLOC(H5O_t))) + if (NULL == (oh = H5FL_CALLOC(H5O_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed") /* File-specific, non-stored information */ @@ -1158,26 +1129,26 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) /* Check for presence of magic number */ /* (indicates version 2 or later) */ - if(!HDmemcmp(image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + if (!HDmemcmp(image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* Magic number */ image += H5_SIZEOF_MAGIC; /* Version */ oh->version = *image++; - if(H5O_VERSION_2 != oh->version) + if (H5O_VERSION_2 != oh->version) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "bad object header version number") /* Flags */ oh->flags = *image++; - if(oh->flags & ~H5O_HDR_ALL_FLAGS) + if (oh->flags & ~H5O_HDR_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown object header status flag(s)") /* Number of links to object (unless overridden by refcount message) */ oh->nlink = 1; /* Time fields */ - if(oh->flags & H5O_HDR_STORE_TIMES) { - uint32_t tmp; /* Temporary value */ + if (oh->flags & H5O_HDR_STORE_TIMES) { + uint32_t tmp; /* Temporary value */ UINT32DECODE(image, tmp); oh->atime = (time_t)tmp; @@ -1192,45 +1163,45 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) oh->atime = oh->mtime = oh->ctime = oh->btime = 0; /* Attribute fields */ - if(oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { + if (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { UINT16DECODE(image, oh->max_compact); UINT16DECODE(image, oh->min_dense); - if(oh->max_compact < oh->min_dense) + if (oh->max_compact < oh->min_dense) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header attribute phase change values") } /* end if */ else { oh->max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF; - oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF; + oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF; } /* end else */ /* First chunk size */ - switch(oh->flags & H5O_HDR_CHUNK0_SIZE) { - case 0: /* 1 byte size */ + switch (oh->flags & H5O_HDR_CHUNK0_SIZE) { + case 0: /* 1 byte size */ udata->chunk0_size = *image++; break; - case 1: /* 2 byte size */ + case 1: /* 2 byte size */ UINT16DECODE(image, udata->chunk0_size); break; - case 2: /* 4 byte size */ + case 2: /* 4 byte size */ UINT32DECODE(image, udata->chunk0_size); break; - case 3: /* 8 byte size */ + case 3: /* 8 byte size */ UINT64DECODE(image, udata->chunk0_size); break; default: HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0") } /* end switch */ - if(udata->chunk0_size > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) + if (udata->chunk0_size > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header chunk size") } /* end if */ else { /* Version */ oh->version = *image++; - if(H5O_VERSION_1 != oh->version) + if (H5O_VERSION_1 != oh->version) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "bad object header version number") /* Flags */ @@ -1250,12 +1221,12 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) /* Reset unused attribute fields */ oh->max_compact = 0; - oh->min_dense = 0; + oh->min_dense = 0; /* First chunk size */ UINT32DECODE(image, udata->chunk0_size); - if((udata->v1_pfx_nmesgs > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) || - (udata->v1_pfx_nmesgs == 0 && udata->chunk0_size > 0)) + if ((udata->v1_pfx_nmesgs > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) || + (udata->v1_pfx_nmesgs == 0 && udata->chunk0_size > 0)) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header chunk size") /* Reserved, in version 1 (for 8-byte alignment padding) */ @@ -1268,16 +1239,17 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) /* If udata->oh is to be freed (see H5O__cache_verify_chksum), save the pointer to udata->oh and free it later after setting udata->oh with the new object header */ - if(udata->free_oh) { + if (udata->free_oh) { H5O_t *saved_oh = udata->oh; HDassert(udata->oh); /* Save the object header for later use in 'deserialize' callback */ udata->oh = oh; - if(H5O__free(saved_oh) < 0) + if (H5O__free(saved_oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") udata->free_oh = FALSE; - } else + } + else /* Save the object header for later use in 'deserialize' callback */ udata->oh = oh; @@ -1285,14 +1257,13 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) done: /* Release the [possibly partially initialized] object header on errors */ - if(ret_value < 0 && oh) - if(H5O__free(oh) < 0) + if (ret_value < 0 && oh) + if (H5O__free(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header data") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__prefix_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_deserialize * @@ -1309,16 +1280,17 @@ done: */ static herr_t H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, - H5O_common_cache_ud_t *udata, hbool_t *dirty) + H5O_common_cache_ud_t *udata, hbool_t *dirty) { - const uint8_t *chunk_image; /* Pointer into buffer to decode */ - uint8_t *eom_ptr; /* Pointer to end of messages for a chunk */ - unsigned merged_null_msgs = 0; /* Number of null messages merged together */ - unsigned chunkno; /* Current chunk's index */ + const uint8_t *chunk_image; /* Pointer into buffer to decode */ + uint8_t * eom_ptr; /* Pointer to end of messages for a chunk */ + unsigned merged_null_msgs = 0; /* Number of null messages merged together */ + unsigned chunkno; /* Current chunk's index */ #ifndef NDEBUG - unsigned nullcnt; /* Count of null messages (for sanity checking gaps in chunks) */ -#endif /* NDEBUG */ - hbool_t mesgs_modified = FALSE; /* Whether any messages were modified when the object header was deserialized */ + unsigned nullcnt; /* Count of null messages (for sanity checking gaps in chunks) */ +#endif /* NDEBUG */ + hbool_t mesgs_modified = + FALSE; /* Whether any messages were modified when the object header was deserialized */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1331,26 +1303,26 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image HDassert(udata->cont_msg_info); /* Increase chunk array size, if necessary */ - if(oh->nchunks >= oh->alloc_nchunks) { - size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ + if (oh->nchunks >= oh->alloc_nchunks) { + size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ H5O_chunk_t *x; - if(NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) + if (NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed") oh->alloc_nchunks = na; - oh->chunk = x; + oh->chunk = x; } /* end if */ /* Init the chunk data info */ - chunkno = (unsigned)oh->nchunks++; - oh->chunk[chunkno].gap = 0; + chunkno = (unsigned)oh->nchunks++; + oh->chunk[chunkno].gap = 0; oh->chunk[chunkno].addr = addr; - if(chunkno == 0) + if (chunkno == 0) /* First chunk's 'image' includes room for the object header prefix */ oh->chunk[0].size = len + (size_t)H5O_SIZEOF_HDR(oh); else oh->chunk[chunkno].size = len; - if(NULL == (oh->chunk[chunkno].image = H5FL_BLK_MALLOC(chunk_image, oh->chunk[chunkno].size))) + if (NULL == (oh->chunk[chunkno].image = H5FL_BLK_MALLOC(chunk_image, oh->chunk[chunkno].size))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed") oh->chunk[chunkno].chunk_proxy = NULL; @@ -1361,13 +1333,13 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image chunk_image = oh->chunk[chunkno].image; /* Handle chunk 0 as special case */ - if(chunkno == 0) + if (chunkno == 0) /* Skip over [already decoded] prefix */ chunk_image += (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)); /* Check for magic # on chunks > 0 in later versions of the format */ - else if(chunkno > 0 && oh->version > H5O_VERSION_1) { + else if (chunkno > 0 && oh->version > H5O_VERSION_1) { /* Magic number */ - if(HDmemcmp(chunk_image, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(chunk_image, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "wrong object header chunk signature") chunk_image += H5_SIZEOF_MAGIC; } /* end if */ @@ -1377,67 +1349,65 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image #ifndef NDEBUG nullcnt = 0; #endif /* NDEBUG */ - while(chunk_image < eom_ptr) { - size_t mesg_size; /* Size of message read in */ - unsigned id; /* ID (type) of current message */ - uint8_t flags; /* Flags for current message */ - H5O_msg_crt_idx_t crt_idx = 0; /* Creation index for current message */ + while (chunk_image < eom_ptr) { + size_t mesg_size; /* Size of message read in */ + unsigned id; /* ID (type) of current message */ + uint8_t flags; /* Flags for current message */ + H5O_msg_crt_idx_t crt_idx = 0; /* Creation index for current message */ /* Decode message prefix info */ /* Version # */ - if(oh->version == H5O_VERSION_1) + if (oh->version == H5O_VERSION_1) UINT16DECODE(chunk_image, id) else id = *chunk_image++; /* Message size */ UINT16DECODE(chunk_image, mesg_size); - if(mesg_size != H5O_ALIGN_OH(oh, mesg_size)) + if (mesg_size != H5O_ALIGN_OH(oh, mesg_size)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "message not aligned") /* Message flags */ flags = *chunk_image++; - if(flags & ~H5O_MSG_FLAG_BITS) + if (flags & ~H5O_MSG_FLAG_BITS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unknown flag for message") - if((flags & H5O_MSG_FLAG_SHARED) && (flags & H5O_MSG_FLAG_DONTSHARE)) + if ((flags & H5O_MSG_FLAG_SHARED) && (flags & H5O_MSG_FLAG_DONTSHARE)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad flag combination for message") - if((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE)) + if ((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad flag combination for message") - if((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && !(flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN)) + if ((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && !(flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad flag combination for message") /* Delay checking the "shareable" flag until we've made sure id * references a valid message class that this version of the library * knows about */ /* Reserved bytes/creation index */ - if(oh->version == H5O_VERSION_1) + if (oh->version == H5O_VERSION_1) chunk_image += 3; /*reserved*/ else { /* Only decode creation index if they are being tracked */ - if(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) + if (oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) UINT16DECODE(chunk_image, crt_idx); } /* end else */ /* Try to detect invalidly formatted object header message that * extends past end of chunk. */ - if(chunk_image + mesg_size > eom_ptr) + if (chunk_image + mesg_size > eom_ptr) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "corrupt object header") #ifndef NDEBUG /* Increment count of null messages */ - if(H5O_NULL_ID == id) + if (H5O_NULL_ID == id) nullcnt++; #endif /* NDEBUG */ /* Check for combining two adjacent 'null' messages */ - if((udata->file_intent & H5F_ACC_RDWR) && - H5O_NULL_ID == id && oh->nmesgs > 0 && - H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id && - oh->mesg[oh->nmesgs - 1].chunkno == chunkno) { + if ((udata->file_intent & H5F_ACC_RDWR) && H5O_NULL_ID == id && oh->nmesgs > 0 && + H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id && oh->mesg[oh->nmesgs - 1].chunkno == chunkno) { - size_t mesgno; /* Current message to operate on */ + size_t mesgno; /* Current message to operate on */ /* Combine adjacent null messages */ mesgno = oh->nmesgs - 1; @@ -1446,12 +1416,12 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image merged_null_msgs++; } /* end if */ else { - H5O_mesg_t *mesg; /* Pointer to new message */ - unsigned ioflags = 0; /* Flags for decode routine */ + H5O_mesg_t *mesg; /* Pointer to new message */ + unsigned ioflags = 0; /* Flags for decode routine */ /* Check if we need to extend message table to hold the new message */ - if(oh->nmesgs >= oh->alloc_nmesgs) - if(H5O__alloc_msgs(oh, (size_t)1) < 0) + if (oh->nmesgs >= oh->alloc_nmesgs) + if (H5O__alloc_msgs(oh, (size_t)1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate more space for messages") /* Get pointer to message to set up */ @@ -1461,26 +1431,26 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image oh->nmesgs++; /* Initialize information about message */ - mesg->dirty = FALSE; - mesg->flags = flags; - mesg->crt_idx = crt_idx; - mesg->native = NULL; - mesg->raw = (uint8_t *)chunk_image; /* Casting away const OK - QAK */ + mesg->dirty = FALSE; + mesg->flags = flags; + mesg->crt_idx = crt_idx; + mesg->native = NULL; + mesg->raw = (uint8_t *)chunk_image; /* Casting away const OK - QAK */ mesg->raw_size = mesg_size; - mesg->chunkno = chunkno; + mesg->chunkno = chunkno; /* Point unknown messages at 'unknown' message class */ /* (Usually from future versions of the library) */ - if(id >= H5O_UNKNOWN_ID || + if (id >= H5O_UNKNOWN_ID || #ifdef H5O_ENABLE_BOGUS - id == H5O_BOGUS_VALID_ID || + id == H5O_BOGUS_VALID_ID || #endif - NULL == H5O_msg_class_g[id]) { + NULL == H5O_msg_class_g[id]) { - H5O_unknown_t *unknown; /* Pointer to "unknown" message info */ + H5O_unknown_t *unknown; /* Pointer to "unknown" message info */ /* Allocate "unknown" message info */ - if(NULL == (unknown = H5FL_MALLOC(H5O_unknown_t))) + if (NULL == (unknown = H5FL_MALLOC(H5O_unknown_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Save the original message type ID */ @@ -1493,14 +1463,14 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image mesg->type = H5O_msg_class_g[H5O_UNKNOWN_ID]; /* Check for "fail if unknown" message flags */ - if(((udata->file_intent & H5F_ACC_RDWR) && - (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE)) - || (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "unknown message with 'fail if unknown' flag found") + if (((udata->file_intent & H5F_ACC_RDWR) && + (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE)) || + (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, + "unknown message with 'fail if unknown' flag found") /* Check for "mark if unknown" message flag, etc. */ - else if((flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) && - !(flags & H5O_MSG_FLAG_WAS_UNKNOWN) && - (udata->file_intent & H5F_ACC_RDWR)) { + else if ((flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) && !(flags & H5O_MSG_FLAG_WAS_UNKNOWN) && + (udata->file_intent & H5F_ACC_RDWR)) { /* Mark the message as "unknown" */ /* This is a bit aggressive, since the application may @@ -1516,17 +1486,17 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image mesg->flags |= H5O_MSG_FLAG_WAS_UNKNOWN; /* Mark the message and chunk as dirty */ - mesg->dirty = TRUE; + mesg->dirty = TRUE; mesgs_modified = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Check for message of unshareable class marked as "shareable" */ - if((flags & H5O_MSG_FLAG_SHAREABLE) - && H5O_msg_class_g[id] - && !(H5O_msg_class_g[id]->share_flags & H5O_SHARE_IS_SHARABLE)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "message of unshareable class flagged as shareable") + if ((flags & H5O_MSG_FLAG_SHAREABLE) && H5O_msg_class_g[id] && + !(H5O_msg_class_g[id]->share_flags & H5O_SHARE_IS_SHARABLE)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, + "message of unshareable class flagged as shareable") /* Set message class for "known" messages */ mesg->type = H5O_msg_class_g[id]; @@ -1536,61 +1506,65 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image /* (detect continuation messages, ref. count messages, etc.) */ /* Check if message is a continuation message */ - if(H5O_CONT_ID == id) { + if (H5O_CONT_ID == id) { H5O_cont_t *cont; /* Decode continuation message */ - cont = (H5O_cont_t *)(H5O_MSG_CONT->decode)(udata->f, NULL, 0, &ioflags, mesg->raw_size, mesg->raw); - H5_CHECKED_ASSIGN(cont->chunkno, unsigned, udata->cont_msg_info->nmsgs + 1, size_t); /* the next continuation message/chunk */ + cont = (H5O_cont_t *)(H5O_MSG_CONT->decode)(udata->f, NULL, 0, &ioflags, mesg->raw_size, + mesg->raw); + H5_CHECKED_ASSIGN(cont->chunkno, unsigned, udata->cont_msg_info->nmsgs + 1, + size_t); /* the next continuation message/chunk */ /* Save 'native' form of continuation message */ mesg->native = cont; /* Add to continuation messages left to interpret */ - if(H5O__add_cont_msg(udata->cont_msg_info, cont) < 0) + if (H5O__add_cont_msg(udata->cont_msg_info, cont) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't add continuation message") } /* end if */ /* Check if message is a ref. count message */ - else if(H5O_REFCOUNT_ID == id) { + else if (H5O_REFCOUNT_ID == id) { H5O_refcount_t *refcount; /* Decode ref. count message */ - if(oh->version <= H5O_VERSION_1) - HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "object header version does not support reference count message") - refcount = (H5O_refcount_t *)(H5O_MSG_REFCOUNT->decode)(udata->f, NULL, 0, &ioflags, mesg->raw_size, mesg->raw); + if (oh->version <= H5O_VERSION_1) + HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, + "object header version does not support reference count message") + refcount = (H5O_refcount_t *)(H5O_MSG_REFCOUNT->decode)(udata->f, NULL, 0, &ioflags, + mesg->raw_size, mesg->raw); /* Save 'native' form of ref. count message */ mesg->native = refcount; /* Set object header values */ oh->has_refcount_msg = TRUE; - if(!refcount) + if (!refcount) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't decode refcount") oh->nlink = *refcount; } /* end if */ /* Check if message is a link message */ - else if(H5O_LINK_ID == id) { + else if (H5O_LINK_ID == id) { /* Increment the count of link messages */ oh->link_msgs_seen++; } /* end if */ /* Check if message is an attribute message */ - else if(H5O_ATTR_ID == id) { + else if (H5O_ATTR_ID == id) { /* Increment the count of attribute messages */ oh->attr_msgs_seen++; } /* end if */ /* Mark the message & chunk as dirty if the message was changed by decoding */ - if((ioflags & H5O_DECODEIO_DIRTY) && (udata->file_intent & H5F_ACC_RDWR)) { - mesg->dirty = TRUE; + if ((ioflags & H5O_DECODEIO_DIRTY) && (udata->file_intent & H5F_ACC_RDWR)) { + mesg->dirty = TRUE; mesgs_modified = TRUE; } /* end if */ - } /* end else */ + } /* end else */ /* Advance decode pointer past message */ chunk_image += mesg_size; /* Check for 'gap' at end of chunk */ - if((eom_ptr - chunk_image) > 0 && (eom_ptr - chunk_image) < H5O_SIZEOF_MSGHDR_OH(oh)) { + if ((eom_ptr - chunk_image) > 0 && (eom_ptr - chunk_image) < H5O_SIZEOF_MSGHDR_OH(oh)) { /* Gaps can only occur in later versions of the format */ HDassert(oh->version > H5O_VERSION_1); @@ -1603,13 +1577,13 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image /* Increment location in chunk */ chunk_image += oh->chunk[chunkno].gap; } /* end if */ - } /* end while */ + } /* end while */ /* Check for correct checksum on chunks, in later versions of the format */ - if(oh->version > H5O_VERSION_1) { - uint32_t stored_chksum; /* Checksum from file */ + if (oh->version > H5O_VERSION_1) { + uint32_t stored_chksum; /* Checksum from file */ - /* checksum verification already done in verify_chksum cb */ + /* checksum verification already done in verify_chksum cb */ /* Metadata checksum */ UINT32DECODE(chunk_image, stored_chksum); @@ -1619,24 +1593,23 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image HDassert(chunk_image == oh->chunk[chunkno].image + oh->chunk[chunkno].size); /* Mark the chunk dirty if we've modified messages */ - if(mesgs_modified) - *dirty = TRUE; + if (mesgs_modified) + *dirty = TRUE; /* Mark the chunk dirty if we've merged null messages */ - if(merged_null_msgs > 0) { + if (merged_null_msgs > 0) { udata->merged_null_msgs += merged_null_msgs; - *dirty = TRUE; + *dirty = TRUE; } /* end if */ done: - if(ret_value < 0 && udata->cont_msg_info->msgs) { - udata->cont_msg_info->msgs = H5FL_SEQ_FREE(H5O_cont_t, udata->cont_msg_info->msgs); + if (ret_value < 0 && udata->cont_msg_info->msgs) { + udata->cont_msg_info->msgs = H5FL_SEQ_FREE(H5O_cont_t, udata->cont_msg_info->msgs); udata->cont_msg_info->alloc_nmsgs = 0; } FUNC_LEAVE_NOAPI(ret_value) } /* H5O__chunk_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_serialize * @@ -1654,9 +1627,9 @@ done: static herr_t H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno) { - H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1665,32 +1638,35 @@ H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno) HDassert(oh); /* Encode any dirty messages in this chunk */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) - if(curr_msg->dirty && curr_msg->chunkno == chunkno) + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) + if (curr_msg->dirty && curr_msg->chunkno == chunkno) /* Casting away const OK -QAK */ - if(H5O_msg_flush((H5F_t *)f, oh, curr_msg) < 0) + if (H5O_msg_flush((H5F_t *)f, oh, curr_msg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message") /* Sanity checks */ - if(oh->version > H5O_VERSION_1) + if (oh->version > H5O_VERSION_1) /* Make certain the magic # is present */ - HDassert(!HDmemcmp(oh->chunk[chunkno].image, (chunkno == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5_SIZEOF_MAGIC)); + HDassert(!HDmemcmp(oh->chunk[chunkno].image, (chunkno == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), + H5_SIZEOF_MAGIC)); else /* Gaps should never occur in version 1 of the format */ HDassert(oh->chunk[chunkno].gap == 0); /* Extra work, for later versions of the format */ - if(oh->version > H5O_VERSION_1) { - uint32_t metadata_chksum; /* Computed metadata checksum value */ - uint8_t *chunk_image; /* Pointer into object header chunk */ + if (oh->version > H5O_VERSION_1) { + uint32_t metadata_chksum; /* Computed metadata checksum value */ + uint8_t *chunk_image; /* Pointer into object header chunk */ /* Check for gap in chunk & zero it out */ - if(oh->chunk[chunkno].gap) + if (oh->chunk[chunkno].gap) HDmemset((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - - (H5O_SIZEOF_CHKSUM + oh->chunk[chunkno].gap), 0, oh->chunk[chunkno].gap); + (H5O_SIZEOF_CHKSUM + oh->chunk[chunkno].gap), + 0, oh->chunk[chunkno].gap); /* Compute metadata checksum */ - metadata_chksum = H5_checksum_metadata(oh->chunk[chunkno].image, (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM), 0); + metadata_chksum = + H5_checksum_metadata(oh->chunk[chunkno].image, (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM), 0); /* Metadata checksum */ chunk_image = oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM); @@ -1700,4 +1676,3 @@ H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__chunk_serialize() */ - diff --git a/src/H5Ocache_image.c b/src/H5Ocache_image.c index 6ac04c8..1fb497a 100644 --- a/src/H5Ocache_image.c +++ b/src/H5Ocache_image.c @@ -26,62 +26,56 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MFprivate.h" /* File space management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Opkg.h" /* Object headers */ +#include "H5MFprivate.h" /* File space management */ /* Callbacks for message class */ -static void *H5O__mdci_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); -static herr_t H5O__mdci_encode(H5F_t *f, hbool_t disable_shared, - uint8_t *p, const void *_mesg); -static void *H5O__mdci_copy(const void *_mesg, void *_dest); -static size_t H5O__mdci_size(const H5F_t *f, hbool_t disable_shared, - const void *_mesg); +static void *H5O__mdci_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); +static herr_t H5O__mdci_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); +static void * H5O__mdci_copy(const void *_mesg, void *_dest); +static size_t H5O__mdci_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__mdci_free(void *mesg); static herr_t H5O__mdci_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static herr_t H5O__mdci_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__mdci_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_MDCI[1] = {{ - H5O_MDCI_MSG_ID, /* message id number */ - "mdci", /* message name for debugging */ - sizeof(H5O_mdci_t), /* native message size */ - 0, /* messages are sharable? */ - H5O__mdci_decode, /* decode message */ - H5O__mdci_encode, /* encode message */ - H5O__mdci_copy, /* copy method */ - H5O__mdci_size, /* size of mdc image message */ - NULL, /* reset method */ - H5O__mdci_free, /* free method */ - H5O__mdci_delete, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__mdci_debug /* debugging */ + H5O_MDCI_MSG_ID, /* message id number */ + "mdci", /* message name for debugging */ + sizeof(H5O_mdci_t), /* native message size */ + 0, /* messages are sharable? */ + H5O__mdci_decode, /* decode message */ + H5O__mdci_encode, /* encode message */ + H5O__mdci_copy, /* copy method */ + H5O__mdci_size, /* size of mdc image message */ + NULL, /* reset method */ + H5O__mdci_free, /* free method */ + H5O__mdci_delete, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__mdci_debug /* debugging */ }}; /* Only one version of the metadata cache image message at present */ -#define H5O_MDCI_VERSION_0 0 +#define H5O_MDCI_VERSION_0 0 /* Declare the free list for H5O_mdci_t's */ H5FL_DEFINE(H5O_mdci_t); - - /*------------------------------------------------------------------------- * Function: H5O__mdci_decode * @@ -97,12 +91,11 @@ H5FL_DEFINE(H5O_mdci_t); *------------------------------------------------------------------------- */ static void * -H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_mdci_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_mdci_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -111,12 +104,13 @@ H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_MDCI_VERSION_0) + if (*p++ != H5O_MDCI_VERSION_0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (mesg = (H5O_mdci_t *)H5FL_MALLOC(H5O_mdci_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for metadata cache image message") + if (NULL == (mesg = (H5O_mdci_t *)H5FL_MALLOC(H5O_mdci_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for metadata cache image message") /* Decode */ H5F_addr_decode(f, &p, &(mesg->addr)); @@ -129,7 +123,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_encode * @@ -143,8 +136,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, - uint8_t *p, const void *_mesg) +H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; @@ -163,7 +155,6 @@ H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_copy * @@ -181,15 +172,15 @@ H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, static void * H5O__mdci_copy(const void *_mesg, void *_dest) { - const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; - H5O_mdci_t *dest = (H5O_mdci_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; + H5O_mdci_t * dest = (H5O_mdci_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(mesg); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_mdci_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_mdci_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -202,7 +193,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_mdci__copy() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_size * @@ -220,24 +210,22 @@ done: *------------------------------------------------------------------------- */ static size_t -H5O__mdci_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, - const void H5_ATTR_UNUSED *_mesg) +H5O__mdci_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)( 1 + /* Version number */ - H5F_SIZEOF_ADDR(f) + /* addr of metadata cache */ - /* image block */ - H5F_SIZEOF_SIZE(f) ); /* length of metadata cache */ - /* image block */ + ret_value = (size_t)(1 + /* Version number */ + H5F_SIZEOF_ADDR(f) + /* addr of metadata cache */ + /* image block */ + H5F_SIZEOF_SIZE(f)); /* length of metadata cache */ + /* image block */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_size() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_free * @@ -262,7 +250,6 @@ H5O__mdci_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_free() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_delete * @@ -279,8 +266,8 @@ static herr_t H5O__mdci_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) { H5O_mdci_t *mesg = (H5O_mdci_t *)_mesg; - haddr_t final_eoa; /* For sanity check */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t final_eoa; /* For sanity check */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -289,7 +276,7 @@ H5O__mdci_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) HDassert(mesg); /* Free file space for cache image */ - if(H5F_addr_defined(mesg->addr)) { + if (H5F_addr_defined(mesg->addr)) { /* The space for the cache image block was allocated directly * from the VFD layer at the end of file. As this was the * last file space allocation before shutdown, the cache image @@ -323,20 +310,19 @@ H5O__mdci_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) * time constraints, I don't want to go there now. */ - - - if(f->shared->closing) { + if (f->shared->closing) { /* Get the eoa, and verify that it has the expected value */ - if(HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "unable to get file size") HDassert(H5F_addr_eq(final_eoa, mesg->addr + mesg->size)); - if(H5FD_free(f->shared->lf, H5FD_MEM_SUPER, f, mesg->addr, mesg->size) < 0) + if (H5FD_free(f->shared->lf, H5FD_MEM_SUPER, f, mesg->addr, mesg->size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't free MDC image") - } else { - if(H5MF_xfree(f, H5FD_MEM_SUPER, mesg->addr, mesg->size) < 0) + } + else { + if (H5MF_xfree(f, H5FD_MEM_SUPER, mesg->addr, mesg->size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free file space for cache image block") } @@ -346,7 +332,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_debug * @@ -360,10 +345,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_mdci_t *mdci = (const H5O_mdci_t *) _mesg; + const H5O_mdci_t *mdci = (const H5O_mdci_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -374,12 +358,10 @@ H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Metadata Cache Image Block address:", mdci->addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Metadata Cache Image Block address:", mdci->addr); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Metadata Cache Image Block size in bytes:", mdci->size); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_debug() */ - diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index cb31cec..9f12a09 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -26,37 +26,31 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object headers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -64,18 +58,14 @@ /* Declare the free list for H5O_chunk_proxy_t's */ H5FL_DEFINE(H5O_chunk_proxy_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O__chunk_add * @@ -91,9 +81,10 @@ H5FL_DEFINE(H5O_chunk_proxy_t); herr_t H5O__chunk_add(H5F_t *f, H5O_t *oh, unsigned idx, unsigned cont_chunkno) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ - H5O_chunk_proxy_t *cont_chk_proxy = NULL; /* Proxy for chunk containing continuation message that points to this chunk, if not chunk 0 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ + H5O_chunk_proxy_t *cont_chk_proxy = + NULL; /* Proxy for chunk containing continuation message that points to this chunk, if not chunk 0 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -104,46 +95,45 @@ H5O__chunk_add(H5F_t *f, H5O_t *oh, unsigned idx, unsigned cont_chunkno) HDassert(idx > 0); /* Allocate space for the object header data structure */ - if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) + if (NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Increment reference count on object header */ - if(H5O__inc_rc(oh) < 0) + if (H5O__inc_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "can't increment reference count on object header") /* Set the values in the chunk proxy */ - chk_proxy->f = f; - chk_proxy->oh = oh; + chk_proxy->f = f; + chk_proxy->oh = oh; chk_proxy->chunkno = idx; /* Determine the parent of the chunk */ - if(cont_chunkno != 0) { - if(NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) + if (cont_chunkno != 0) { + if (NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") chk_proxy->fd_parent = cont_chk_proxy; } /* end else */ /* Insert the chunk proxy into the cache */ - if(H5AC_insert_entry(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header chunk") chk_proxy = NULL; done: /* Cleanup on failure */ - if(ret_value < 0) - if(chk_proxy && H5O__chunk_dest(chk_proxy) < 0) + if (ret_value < 0) + if (chk_proxy && H5O__chunk_dest(chk_proxy) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk") /* Release resources */ - if(cont_chk_proxy) - if(H5O__chunk_unprotect(f, cont_chk_proxy, FALSE) < 0) + if (cont_chk_proxy) + if (H5O__chunk_unprotect(f, cont_chk_proxy, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_add() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_protect * @@ -159,8 +149,8 @@ done: H5O_chunk_proxy_t * H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for protected chunk */ - H5O_chunk_proxy_t *ret_value = NULL; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for protected chunk */ + H5O_chunk_proxy_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -170,33 +160,34 @@ H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx) HDassert(idx < oh->nchunks); /* Check for protecting first chunk */ - if(0 == idx) { + if (0 == idx) { /* Create new "fake" chunk proxy for first chunk */ /* (since the first chunk is already handled by the H5O_t object) */ - if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) + if (NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Increment reference count on object header */ - if(H5O__inc_rc(oh) < 0) + if (H5O__inc_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "can't increment reference count on object header") /* Set chunk proxy fields */ - chk_proxy->f = f; - chk_proxy->oh = oh; + chk_proxy->f = f; + chk_proxy->oh = oh; chk_proxy->chunkno = idx; } /* end if */ else { - H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ + H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ /* Construct the user data for protecting chunk proxy */ /* (and _not_ decoding it) */ HDmemset(&chk_udata, 0, sizeof(chk_udata)); - chk_udata.oh = oh; + chk_udata.oh = oh; chk_udata.chunkno = idx; - chk_udata.size = oh->chunk[idx].size; + chk_udata.size = oh->chunk[idx].size; /* Get the chunk proxy */ - if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, &chk_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, + &chk_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk") /* Sanity check */ @@ -209,14 +200,13 @@ H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx) done: /* Cleanup on error */ - if(!ret_value) - if(0 == idx && chk_proxy && H5O__chunk_dest(chk_proxy) < 0) + if (!ret_value) + if (0 == idx && chk_proxy && H5O__chunk_dest(chk_proxy) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_protect() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_unprotect * @@ -232,7 +222,7 @@ done: herr_t H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t dirtied) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -241,16 +231,16 @@ H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t dirtied) HDassert(chk_proxy); /* Check for releasing first chunk */ - if(0 == chk_proxy->chunkno) { + if (0 == chk_proxy->chunkno) { /* Check for dirtying the first chunk */ - if(dirtied) { + if (dirtied) { /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(chk_proxy->oh) < 0) + if (H5AC_mark_entry_dirty(chk_proxy->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end else/if */ /* Decrement reference count of object header */ - if(H5O__dec_rc(chk_proxy->oh) < 0) + if (H5O__dec_rc(chk_proxy->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count on object header") /* Free fake chunk proxy */ @@ -258,7 +248,8 @@ H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t dirtied) } /* end if */ else { /* Release the chunk proxy from the cache, possibly marking it dirty */ - if(H5AC_unprotect(f, H5AC_OHDR_CHK, chk_proxy->oh->chunk[chk_proxy->chunkno].addr, chk_proxy, (dirtied ? H5AC__DIRTIED_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(f, H5AC_OHDR_CHK, chk_proxy->oh->chunk[chk_proxy->chunkno].addr, chk_proxy, + (dirtied ? H5AC__DIRTIED_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") } /* end else */ @@ -266,7 +257,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__chunk_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_resize * @@ -282,7 +272,7 @@ done: herr_t H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -291,14 +281,14 @@ H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy) HDassert(chk_proxy); /* Check for resizing first chunk */ - if(0 == chk_proxy->chunkno) { + if (0 == chk_proxy->chunkno) { /* Resize object header in cache */ - if(H5AC_resize_entry(oh, oh->chunk[0].size) < 0) + if (H5AC_resize_entry(oh, oh->chunk[0].size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize chunk in cache") } /* end if */ else { /* Resize chunk in cache */ - if(H5AC_resize_entry(chk_proxy, oh->chunk[chk_proxy->chunkno].size) < 0) + if (H5AC_resize_entry(chk_proxy, oh->chunk[chk_proxy->chunkno].size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize chunk in cache") } /* end else */ @@ -306,7 +296,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__chunk_resize() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_update_idx * @@ -322,9 +311,9 @@ done: herr_t H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx) { - H5O_chunk_proxy_t *chk_proxy = NULL;/* Proxy for chunk, to mark it dirty in the cache */ - H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ + H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -337,26 +326,26 @@ H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx) /* Construct the user data for protecting chunk proxy */ /* (and _not_ decoding it) */ HDmemset(&chk_udata, 0, sizeof(chk_udata)); - chk_udata.oh = oh; + chk_udata.oh = oh; chk_udata.chunkno = idx; - chk_udata.size = oh->chunk[idx].size; + chk_udata.size = oh->chunk[idx].size; /* Get the chunk proxy */ - if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, &chk_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, + &chk_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Update index for chunk proxy in cache */ chk_proxy->chunkno = idx; /* Release the chunk proxy from the cache, marking it deleted */ - if(H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_update_idx() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_delete * @@ -372,9 +361,9 @@ done: herr_t H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx) { - H5O_chunk_proxy_t *chk_proxy = NULL;/* Proxy for chunk, to mark it dirty in the cache */ - unsigned cache_flags = H5AC__DELETED_FLAG; /* Flags for unprotecting proxy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ + unsigned cache_flags = H5AC__DELETED_FLAG; /* Flags for unprotecting proxy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -385,22 +374,21 @@ H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx) HDassert(idx > 0); /* Get the chunk proxy */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, idx))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, idx))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Only free file space if not doing SWMR writes */ - if(!oh->swmr_write) + if (!oh->swmr_write) cache_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; done: /* Release the chunk proxy from the cache, marking it deleted */ - if(chk_proxy && H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, cache_flags) < 0) + if (chk_proxy && H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, cache_flags) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_dest * @@ -424,7 +412,7 @@ H5O__chunk_dest(H5O_chunk_proxy_t *chk_proxy) HDassert(chk_proxy); /* Decrement reference count of object header */ - if(chk_proxy->oh && H5O__dec_rc(chk_proxy->oh) < 0) + if (chk_proxy->oh && H5O__dec_rc(chk_proxy->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count on object header") /* Release the chunk proxy object */ @@ -433,4 +421,3 @@ H5O__chunk_dest(H5O_chunk_proxy_t *chk_proxy) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__chunk_dest() */ - diff --git a/src/H5Ocont.c b/src/H5Ocont.c index 68a88e2..c8241f8 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -25,54 +25,50 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O__cont_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void *H5O__cont_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); static herr_t H5O__cont_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); static size_t H5O__cont_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__cont_free(void *mesg); static herr_t H5O__cont_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static herr_t H5O__cont_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__cont_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_CONT[1] = {{ - H5O_CONT_ID, /*message id number */ - "hdr continuation", /*message name for debugging */ - sizeof(H5O_cont_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__cont_decode, /*decode message */ - H5O__cont_encode, /*encode message */ - NULL, /*no copy method */ - H5O__cont_size, /*size of header continuation */ - NULL, /*reset method */ - H5O__cont_free, /* free method */ - H5O__cont_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__cont_debug /*debugging */ + H5O_CONT_ID, /*message id number */ + "hdr continuation", /*message name for debugging */ + sizeof(H5O_cont_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__cont_decode, /*decode message */ + H5O__cont_encode, /*encode message */ + NULL, /*no copy method */ + H5O__cont_size, /*size of header continuation */ + NULL, /*reset method */ + H5O__cont_free, /* free method */ + H5O__cont_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__cont_debug /*debugging */ }}; /* Declare the free list for H5O_cont_t's */ H5FL_DEFINE(H5O_cont_t); - /*------------------------------------------------------------------------- * Function: H5O__cont_decode * @@ -88,12 +84,11 @@ H5FL_DEFINE(H5O_cont_t); *------------------------------------------------------------------------- */ static void * -H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_cont_t *cont = NULL; - void *ret_value = NULL; /* Return value */ + H5O_cont_t *cont = NULL; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -102,8 +97,8 @@ H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Allocate space for the message */ - if(NULL == (cont = H5FL_MALLOC(H5O_cont_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (NULL == (cont = H5FL_MALLOC(H5O_cont_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Decode */ H5F_addr_decode(f, &p, &(cont->addr)); @@ -117,7 +112,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cont_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_encode * @@ -133,7 +127,7 @@ done: static herr_t H5O__cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_cont_t *cont = (const H5O_cont_t *) _mesg; + const H5O_cont_t *cont = (const H5O_cont_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -151,7 +145,6 @@ H5O__cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cont_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_size * @@ -171,18 +164,17 @@ H5O__cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co static size_t H5O__cont_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)(H5F_SIZEOF_ADDR(f) + /* Continuation header address */ - H5F_SIZEOF_SIZE(f)); /* Continuation header length */ + ret_value = (size_t)(H5F_SIZEOF_ADDR(f) + /* Continuation header address */ + H5F_SIZEOF_SIZE(f)); /* Continuation header length */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cont_size() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_free * @@ -207,7 +199,6 @@ H5O__cont_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cont_free() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_delete * @@ -223,8 +214,8 @@ H5O__cont_free(void *mesg) static herr_t H5O__cont_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_cont_t *mesg = (H5O_cont_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_cont_t *mesg = (H5O_cont_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -234,14 +225,13 @@ H5O__cont_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) /* Notify the cache that the chunk has been deleted */ /* (releases the space for the chunk) */ - if(H5O__chunk_delete(f, open_oh, mesg->chunkno) < 0) + if (H5O__chunk_delete(f, open_oh, mesg->chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove chunk from cache") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cont_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_debug * @@ -255,10 +245,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__cont_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__cont_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_cont_t *cont = (const H5O_cont_t *) _mesg; + const H5O_cont_t *cont = (const H5O_cont_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -269,15 +258,11 @@ H5O__cont_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Continuation address:", cont->addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Continuation address:", cont->addr); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Continuation size in bytes:", - (unsigned long) (cont->size)); - HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, - "Points to chunk number:", - (int) (cont->chunkno)); + "Continuation size in bytes:", (unsigned long)(cont->size)); + HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Points to chunk number:", (int)(cont->chunkno)); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cont_debug() */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 469a9e0..66a6847 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -24,76 +24,70 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Key object for skiplist of committed datatypes */ typedef struct H5O_copy_search_comm_dt_key_t { - H5T_t *dt; /* Datatype */ - unsigned long fileno; /* File number */ + H5T_t * dt; /* Datatype */ + unsigned long fileno; /* File number */ } H5O_copy_search_comm_dt_key_t; /* Callback struct for building a list of committed datatypes */ typedef struct H5O_copy_search_comm_dt_ud_t { - H5SL_t *dst_dt_list; /* Skip list of committed datatypes */ - H5G_loc_t *dst_root_loc; /* Starting location for iteration */ - H5O_loc_t obj_oloc; /* Object location (for attribute iteration callback) */ + H5SL_t * dst_dt_list; /* Skip list of committed datatypes */ + H5G_loc_t *dst_root_loc; /* Starting location for iteration */ + H5O_loc_t obj_oloc; /* Object location (for attribute iteration callback) */ } H5O_copy_search_comm_dt_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5O__copy_free_addrmap_cb(void *item, void *key, void *op_data); static herr_t H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, - H5O_copy_t *cpy_info, H5O_type_t *obj_type, void **udata); -static herr_t H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, - hid_t ocpypl_id, hid_t lcpl_id); -static herr_t H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id); + H5O_copy_t *cpy_info, H5O_type_t *obj_type, void **udata); +static herr_t H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, hid_t ocpypl_id, + hid_t lcpl_id); +static herr_t H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, hid_t ocpypl_id, + hid_t lcpl_id); static herr_t H5O__copy_free_comm_dt_cb(void *item, void *key, void *op_data); -static int H5O__copy_comm_dt_cmp(const void *dt1, const void *dt2); -static herr_t H5O__copy_search_comm_dt_cb(hid_t group, const char *name, - const H5L_info2_t *linfo, void *udata); -static htri_t H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, - H5O_loc_t *oloc_dst/*in, out*/, H5O_copy_t *cpy_info); -static herr_t H5O__copy_insert_comm_dt(H5F_t *file_src, H5O_t *oh_src, - H5O_loc_t *oloc_dst, H5O_copy_t *cpy_info); - +static int H5O__copy_comm_dt_cmp(const void *dt1, const void *dt2); +static herr_t H5O__copy_search_comm_dt_cb(hid_t group, const char *name, const H5L_info2_t *linfo, + void *udata); +static htri_t H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*in, out*/, + H5O_copy_t *cpy_info); +static herr_t H5O__copy_insert_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst, + H5O_copy_t *cpy_info); /*********************/ /* Package Variables */ @@ -112,13 +106,10 @@ H5FL_DEFINE(haddr_t); /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Ocopy * @@ -194,67 +185,65 @@ H5FL_DEFINE(haddr_t); *------------------------------------------------------------------------- */ herr_t -H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) +H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, + hid_t lcpl_id) { - H5VL_object_t *vol_obj1 = NULL; /* object of src_id */ + H5VL_object_t * vol_obj1 = NULL; /* object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* object of dst_id */ + H5VL_object_t * vol_obj2 = NULL; /* object of dst_id */ H5VL_loc_params_t loc_params2; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id); /* Check arguments */ - if(!src_name || !*src_name) + if (!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified") - if(!dst_name || !*dst_name) + if (!dst_name || !*dst_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") /* Get correct property lists */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") /* Get object copy property list */ if (H5P_DEFAULT == ocpypl_id) ocpypl_id = H5P_OBJECT_COPY_DEFAULT; - else - if(TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") + else if (TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(src_loc_id) < 0) + if (H5CX_set_loc(src_loc_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* get the object */ - if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - loc_params1.type = H5VL_OBJECT_BY_SELF; - loc_params1.obj_type = H5I_get_type(src_loc_id); + loc_params1.type = H5VL_OBJECT_BY_SELF; + loc_params1.obj_type = H5I_get_type(src_loc_id); /* get the object */ - if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - loc_params2.type = H5VL_OBJECT_BY_SELF; - loc_params2.obj_type = H5I_get_type(dst_loc_id); + loc_params2.type = H5VL_OBJECT_BY_SELF; + loc_params2.obj_type = H5I_get_type(dst_loc_id); /* Copy the object */ - if(H5VL_object_copy(vol_obj1, &loc_params1, src_name, vol_obj2, &loc_params2, dst_name, ocpypl_id, lcpl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_object_copy(vol_obj1, &loc_params1, src_name, vol_obj2, &loc_params2, dst_name, ocpypl_id, + lcpl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: FUNC_LEAVE_API(ret_value) } /* end H5Ocopy() */ - /*------------------------------------------------------------------------- * Function: H5O_copy * @@ -268,16 +257,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) +H5O_copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id) { - H5G_loc_t src_loc; /* Source object group location */ - H5G_name_t src_path; /* Opened source object hier. path */ - H5O_loc_t src_oloc; /* Opened source object object location */ - htri_t dst_exists; /* Does destination name exist already? */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ - hbool_t obj_open = FALSE; /* Entry at 'name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t src_loc; /* Source object group location */ + H5G_name_t src_path; /* Opened source object hier. path */ + H5O_loc_t src_oloc; /* Opened source object object location */ + htri_t dst_exists; /* Does destination name exist already? */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + hbool_t obj_open = FALSE; /* Entry at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -288,9 +277,9 @@ H5O_copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, HDassert(dst_name && *dst_name); /* Check if destination name already exists */ - if((dst_exists = H5L_exists_tolerant(dst_loc, dst_name)) < 0) + if ((dst_exists = H5L_exists_tolerant(dst_loc, dst_name)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check if destination name exists") - if(TRUE == dst_exists) + if (TRUE == dst_exists) HGOTO_ERROR(H5E_OHDR, H5E_EXISTS, FAIL, "destination object already exists") /* Set up opened group location to fill in */ @@ -299,29 +288,28 @@ H5O_copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, H5G_loc_reset(&src_loc); /* Find the source object to copy */ - if(H5G_loc_find(loc, src_name, &src_loc/*out*/) < 0) + if (H5G_loc_find(loc, src_name, &src_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found") loc_found = TRUE; /* Open source object's object header */ - if(H5O_open(&src_oloc) < 0) + if (H5O_open(&src_oloc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") obj_open = TRUE; /* Do the actual copying of the object */ - if(H5O__copy_obj(&src_loc, dst_loc, dst_name, ocpypl_id, lcpl_id) < 0) + if (H5O__copy_obj(&src_loc, dst_loc, dst_name, ocpypl_id, lcpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: - if(loc_found && H5G_loc_free(&src_loc) < 0) + if (loc_found && H5G_loc_free(&src_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - if(obj_open && H5O_close(&src_oloc, NULL) < 0) + if (obj_open && H5O_close(&src_oloc, NULL) < 0) HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_copy() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_header_real * @@ -343,27 +331,27 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, - H5O_copy_t *cpy_info, H5O_type_t *obj_type, void **udata /*out*/) +H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5O_copy_t *cpy_info, + H5O_type_t *obj_type, void **udata /*out*/) { - H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */ - H5O_t *oh_src = NULL; /* Object header for source object */ - H5O_t *oh_dst = NULL; /* Object header for destination object */ - unsigned mesgno = 0; - haddr_t addr_new = HADDR_UNDEF; - hbool_t *deleted = NULL; /* Array of flags indicating whether messages should be copied */ - hbool_t inserted = FALSE; /* Whether the destination object header has been inserted into the cache */ - size_t null_msgs; /* Number of NULL messages found in each loop */ - size_t orig_dst_msgs; /* Original # of messages in dest. object */ - H5O_mesg_t *mesg_src; /* Message in source object header */ - H5O_mesg_t *mesg_dst; /* Message in destination object header */ - const H5O_msg_class_t *copy_type; /* Type of message to use for copying */ - const H5O_obj_class_t *obj_class = NULL; /* Type of object we are copying */ - void *cpy_udata = NULL; /* User data for passing to message callbacks */ - uint64_t dst_oh_size; /* Total size of the destination OH */ - size_t dst_oh_null; /* Size of the null message to add to destination OH */ - size_t dst_oh_gap; /* Size of the gap in chunk #0 of destination OH */ - uint8_t *current_pos; /* Current position in destination image */ + H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */ + H5O_t * oh_src = NULL; /* Object header for source object */ + H5O_t * oh_dst = NULL; /* Object header for destination object */ + unsigned mesgno = 0; + haddr_t addr_new = HADDR_UNDEF; + hbool_t * deleted = NULL; /* Array of flags indicating whether messages should be copied */ + hbool_t inserted = FALSE; /* Whether the destination object header has been inserted into the cache */ + size_t null_msgs; /* Number of NULL messages found in each loop */ + size_t orig_dst_msgs; /* Original # of messages in dest. object */ + H5O_mesg_t *mesg_src; /* Message in source object header */ + H5O_mesg_t *mesg_dst; /* Message in destination object header */ + const H5O_msg_class_t *copy_type; /* Type of message to use for copying */ + const H5O_obj_class_t *obj_class = NULL; /* Type of object we are copying */ + void * cpy_udata = NULL; /* User data for passing to message callbacks */ + uint64_t dst_oh_size; /* Total size of the destination OH */ + size_t dst_oh_null; /* Size of the null message to add to destination OH */ + size_t dst_oh_gap; /* Size of the gap in chunk #0 of destination OH */ + uint8_t * current_pos; /* Current position in destination image */ size_t msghdr_size; herr_t ret_value = SUCCEED; @@ -376,88 +364,88 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, HDassert(cpy_info); /* Get pointer to object class for this object */ - if(NULL == (obj_class = H5O__obj_class(oloc_src))) + if (NULL == (obj_class = H5O__obj_class(oloc_src))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") /* Set the pointer to the shared struct for the object if opened in the file */ cpy_info->shared_fo = H5FO_opened(oloc_src->file, oloc_src->addr); /* Get source object header */ - if(NULL == (oh_src = H5O_protect(oloc_src, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh_src = H5O_protect(oloc_src, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Retrieve user data for particular type of object to copy */ - if(obj_class->get_copy_file_udata && (NULL == (cpy_udata = (obj_class->get_copy_file_udata)()))) + if (obj_class->get_copy_file_udata && (NULL == (cpy_udata = (obj_class->get_copy_file_udata)()))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to retrieve copy user data") /* If we are merging committed datatypes, check for a match in the destination * file now */ - if(cpy_info->merge_comm_dt && obj_class->type == H5O_TYPE_NAMED_DATATYPE) { + if (cpy_info->merge_comm_dt && obj_class->type == H5O_TYPE_NAMED_DATATYPE) { unsigned long fileno_src; /* fileno for source file */ unsigned long fileno_dst; /* fileno for destination file */ - htri_t merge; /* Whether we found a match in the destination file */ + htri_t merge; /* Whether we found a match in the destination file */ /* Check if the source and dest file are the same. If so, just return * the source object address */ H5F_GET_FILENO(oloc_src->file, fileno_src); H5F_GET_FILENO(oloc_dst->file, fileno_dst); - if(fileno_src == fileno_dst) { - merge = TRUE; + if (fileno_src == fileno_dst) { + merge = TRUE; oloc_dst->addr = oloc_src->addr; } /* end if */ else /* Search for a matching committed datatype, building the list if * necessary */ - if((merge = H5O__copy_search_comm_dt(oloc_src->file, oh_src, oloc_dst, cpy_info)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't search for matching committed datatype") + if ((merge = H5O__copy_search_comm_dt(oloc_src->file, oh_src, oloc_dst, cpy_info)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't search for matching committed datatype") - if(merge) { + if (merge) { /* Found a match, add to skip list and exit */ /* Allocate space for the address mapping of the object copied */ - if(NULL == (addr_map = H5FL_MALLOC(H5O_addr_map_t))) + if (NULL == (addr_map = H5FL_MALLOC(H5O_addr_map_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Insert the address mapping for the found object into the copied * list */ addr_map->src_obj_pos.fileno = fileno_src; - addr_map->src_obj_pos.addr = oloc_src->addr; - addr_map->dst_addr = oloc_dst->addr; - addr_map->is_locked = TRUE; /* We've locked the object currently */ - addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */ - addr_map->obj_class = obj_class; - addr_map->udata = cpy_udata; + addr_map->src_obj_pos.addr = oloc_src->addr; + addr_map->dst_addr = oloc_dst->addr; + addr_map->is_locked = TRUE; /* We've locked the object currently */ + addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */ + addr_map->obj_class = obj_class; + addr_map->udata = cpy_udata; /* Insert into skip list */ - if(H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) { + if (H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) { addr_map = H5FL_FREE(H5O_addr_map_t, addr_map); HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") } /* end if */ HGOTO_DONE(SUCCEED) } /* end if */ - } /* end if */ + } /* end if */ /* Flush any dirty messages in source object header to update the header chunks */ - if(H5O__flush_msgs(oloc_src->file, oh_src) < 0) + if (H5O__flush_msgs(oloc_src->file, oh_src) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object header messages") /* Allocate the destination object header and fill in header fields */ - if(NULL == (oh_dst = H5FL_CALLOC(H5O_t))) + if (NULL == (oh_dst = H5FL_CALLOC(H5O_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize header information */ oh_dst->version = oh_src->version; /* Version bounds check for destination object header */ - if(oh_dst->version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(oloc_dst->file)]) + if (oh_dst->version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(oloc_dst->file)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "destination object header version out of bounds") - oh_dst->flags = oh_src->flags; + oh_dst->flags = oh_src->flags; oh_dst->link_msgs_seen = oh_src->link_msgs_seen; oh_dst->attr_msgs_seen = oh_src->attr_msgs_seen; - oh_dst->sizeof_size = H5F_SIZEOF_SIZE(oloc_dst->file); - oh_dst->sizeof_addr = H5F_SIZEOF_ADDR(oloc_dst->file); - oh_dst->swmr_write = !!(H5F_INTENT(oloc_dst->file) & H5F_ACC_SWMR_WRITE); + oh_dst->sizeof_size = H5F_SIZEOF_SIZE(oloc_dst->file); + oh_dst->sizeof_addr = H5F_SIZEOF_ADDR(oloc_dst->file); + oh_dst->swmr_write = !!(H5F_INTENT(oloc_dst->file) & H5F_ACC_SWMR_WRITE); /* Copy time fields */ oh_dst->atime = oh_src->atime; @@ -467,12 +455,12 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Copy attribute storage information */ oh_dst->max_compact = oh_src->max_compact; - oh_dst->min_dense = oh_src->min_dense; + oh_dst->min_dense = oh_src->min_dense; /* Create object header proxy if doing SWMR writes */ - if(oh_dst->swmr_write) { + if (oh_dst->swmr_write) { /* Create virtual entry, for use as proxy */ - if(NULL == (oh_dst->proxy = H5AC_proxy_entry_create())) + if (NULL == (oh_dst->proxy = H5AC_proxy_entry_create())) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") } /* end if */ else @@ -485,7 +473,7 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, oh_dst->alloc_nchunks = oh_dst->nchunks = 0; /* Allocate memory for the chunk array - always start with 1 chunk */ - if(NULL == (oh_dst->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)1))) + if (NULL == (oh_dst->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Update number of allocated chunks. There are still no chunks used. */ @@ -494,7 +482,7 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Allocate memory for "deleted" array. This array marks the message in * the source that shouldn't be copied to the destination. */ - if(NULL == (deleted = (hbool_t *)H5MM_malloc(sizeof(hbool_t) * oh_src->nmesgs))) + if (NULL == (deleted = (hbool_t *)H5MM_malloc(sizeof(hbool_t) * oh_src->nmesgs))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDmemset(deleted, FALSE, sizeof(hbool_t) * oh_src->nmesgs); @@ -503,12 +491,12 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, * Keep track of how many NULL or deleted messages we find (or create) */ null_msgs = 0; - for(mesgno = 0; mesgno < oh_src->nmesgs; mesgno++) { + for (mesgno = 0; mesgno < oh_src->nmesgs; mesgno++) { /* Set up convenience variables */ mesg_src = &(oh_src->mesg[mesgno]); /* Sanity check */ - HDassert(!mesg_src->dirty); /* Should be cleared by earlier call to flush messages */ + HDassert(!mesg_src->dirty); /* Should be cleared by earlier call to flush messages */ /* Get message class to operate on */ copy_type = mesg_src->type; @@ -516,14 +504,14 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Check for continuation message; these are converted to NULL * messages because the destination OH will have only one chunk */ - if(H5O_CONT_ID == mesg_src->type->id || H5O_NULL_ID == mesg_src->type->id) { + if (H5O_CONT_ID == mesg_src->type->id || H5O_NULL_ID == mesg_src->type->id) { deleted[mesgno] = TRUE; ++null_msgs; copy_type = H5O_MSG_NULL; } /* end if */ HDassert(copy_type); - if(copy_type->pre_copy_file) { + if (copy_type->pre_copy_file) { /* Decode the message if necessary. */ H5O_LOAD_NATIVE(oloc_src->file, 0, oh_src, mesg_src, FAIL) @@ -534,58 +522,58 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, cpy_info->file_dst = oloc_dst->file; /* Perform "pre copy" operation on message */ - if((copy_type->pre_copy_file)(oloc_src->file, mesg_src->native, - &(deleted[mesgno]), cpy_info, cpy_udata) < 0) + if ((copy_type->pre_copy_file)(oloc_src->file, mesg_src->native, &(deleted[mesgno]), cpy_info, + cpy_udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'pre copy' operation on message") /* Check if the message should be deleted in the destination */ - if(deleted[mesgno]) + if (deleted[mesgno]) /* Mark message as deleted */ ++null_msgs; } /* end if(copy_type->pre_copy_file) */ - } /* end for */ + } /* end for */ /* Initialize size of message list. It may or may not include the NULL messages * detected above. */ - if(cpy_info->preserve_null) + if (cpy_info->preserve_null) oh_dst->alloc_nmesgs = oh_dst->nmesgs = oh_src->nmesgs; else oh_dst->alloc_nmesgs = oh_dst->nmesgs = (oh_src->nmesgs - null_msgs); /* Allocate memory for destination message array */ - if(oh_dst->alloc_nmesgs > 0) - if(NULL == (oh_dst->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh_dst->alloc_nmesgs))) + if (oh_dst->alloc_nmesgs > 0) + if (NULL == (oh_dst->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh_dst->alloc_nmesgs))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* "copy" pass over messages, to perform main message copying */ null_msgs = 0; - for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { + for (mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { /* Skip any deleted or NULL messages in the source unless the * preserve_null flag is set */ - if(FALSE == cpy_info->preserve_null) { - while(deleted[mesgno + null_msgs]) { + if (FALSE == cpy_info->preserve_null) { + while (deleted[mesgno + null_msgs]) { ++null_msgs; HDassert(mesgno + null_msgs < oh_src->nmesgs); } /* end while */ - } /* end if */ + } /* end if */ /* Set up convenience variables */ mesg_src = &(oh_src->mesg[mesgno + null_msgs]); mesg_dst = &(oh_dst->mesg[mesgno]); /* Initialize non-zero components of destination message */ - mesg_dst->crt_idx = mesg_src->crt_idx; - mesg_dst->flags = mesg_src->flags; + mesg_dst->crt_idx = mesg_src->crt_idx; + mesg_dst->flags = mesg_src->flags; mesg_dst->raw_size = mesg_src->raw_size; - mesg_dst->type = mesg_src->type; + mesg_dst->type = mesg_src->type; /* If we're preserving deleted messages, set their types to 'NULL' * in the destination. */ - if(cpy_info->preserve_null && deleted[mesgno]) { - mesg_dst->type = H5O_MSG_NULL; + if (cpy_info->preserve_null && deleted[mesgno]) { + mesg_dst->type = H5O_MSG_NULL; mesg_dst->flags = 0; mesg_dst->dirty = TRUE; } /* end if */ @@ -598,9 +586,9 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, HDassert(copy_type); /* copy this message into destination file */ - if(copy_type->copy_file) { - hbool_t recompute_size; /* Whether copy_file callback created a shared message */ - unsigned mesg_flags; /* Message flags */ + if (copy_type->copy_file) { + hbool_t recompute_size; /* Whether copy_file callback created a shared message */ + unsigned mesg_flags; /* Message flags */ /* Decode the message if necessary. */ H5O_LOAD_NATIVE(oloc_src->file, 0, oh_src, mesg_src, FAIL) @@ -608,20 +596,18 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Get destination message flags, and unset shared and shareable * flags. mesg_dst->flags will contain the original flags for now. */ - mesg_flags = (unsigned)mesg_dst->flags & ~H5O_MSG_FLAG_SHARED - & ~H5O_MSG_FLAG_SHAREABLE; + mesg_flags = (unsigned)mesg_dst->flags & ~H5O_MSG_FLAG_SHARED & ~H5O_MSG_FLAG_SHAREABLE; /* Copy the source message */ recompute_size = FALSE; - if(NULL == (mesg_dst->native = H5O__msg_copy_file(copy_type, oloc_src->file, - mesg_src->native, oloc_dst->file, &recompute_size, - &mesg_flags, cpy_info, cpy_udata))) + if (NULL == (mesg_dst->native = + H5O__msg_copy_file(copy_type, oloc_src->file, mesg_src->native, oloc_dst->file, + &recompute_size, &mesg_flags, cpy_info, cpy_udata))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object header message") /* Check if the sharing state changed, and recompute the size if so */ - if(!(mesg_flags & H5O_MSG_FLAG_SHARED) - != !(mesg_dst->flags & H5O_MSG_FLAG_SHARED)) + if (!(mesg_flags & H5O_MSG_FLAG_SHARED) != !(mesg_dst->flags & H5O_MSG_FLAG_SHARED)) recompute_size = TRUE; /* Set destination message flags */ @@ -631,15 +617,15 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* (its sharing status or one of its components (for attributes) * could have changed) */ - if(recompute_size) - mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst, - H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, FALSE, mesg_dst->native)); + if (recompute_size) + mesg_dst->raw_size = H5O_ALIGN_OH( + oh_dst, H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, FALSE, mesg_dst->native)); - /* Mark the message in the destination as dirty, so it'll get encoded when the object header is flushed */ + /* Mark the message in the destination as dirty, so it'll get encoded when the object header is + * flushed */ mesg_dst->dirty = TRUE; } /* end if (mesg_src->type->copy_file) */ - } /* end of mesgno loop */ - + } /* end of mesgno loop */ /* Allocate the destination header and copy any messages that didn't have * copy callbacks. They get copied directly from the source image to the @@ -652,35 +638,35 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Compute space for messages. */ dst_oh_size = 0; - for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { + for (mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { dst_oh_size += (uint64_t)H5O_SIZEOF_MSGHDR_OH(oh_dst); dst_oh_size += oh_dst->mesg[mesgno].raw_size; } /* end for */ /* Check if we need to determine correct value for chunk #0 size bits */ - if(oh_dst->version > H5O_VERSION_1) { + if (oh_dst->version > H5O_VERSION_1) { /* Reset destination object header's "chunk 0 size" flags */ oh_dst->flags = (uint8_t)(oh_dst->flags & ~H5O_HDR_CHUNK0_SIZE); /* Determine correct value for chunk #0 size bits */ - if(dst_oh_size > 4294967295) + if (dst_oh_size > 4294967295) oh_dst->flags |= H5O_HDR_CHUNK0_8; - else if(dst_oh_size > 65535) + else if (dst_oh_size > 65535) oh_dst->flags |= H5O_HDR_CHUNK0_4; - else if(dst_oh_size > 255) + else if (dst_oh_size > 255) oh_dst->flags |= H5O_HDR_CHUNK0_2; } /* end if */ /* Check if the chunk's data portion is too small */ dst_oh_gap = dst_oh_null = 0; - if(dst_oh_size < H5O_MIN_SIZE) { - size_t delta = (size_t)(H5O_MIN_SIZE - dst_oh_size); /* Delta in chunk size needed */ + if (dst_oh_size < H5O_MIN_SIZE) { + size_t delta = (size_t)(H5O_MIN_SIZE - dst_oh_size); /* Delta in chunk size needed */ /* Sanity check */ HDassert((oh_dst->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_1); /* Determine whether to create gap or NULL message */ - if(delta < H5O_SIZEOF_MSGHDR_OH(oh_dst)) + if (delta < H5O_SIZEOF_MSGHDR_OH(oh_dst)) dst_oh_gap = delta; else dst_oh_null = delta; @@ -696,7 +682,8 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, dst_oh_size += (uint64_t)H5O_SIZEOF_HDR(oh_dst); /* Allocate space for chunk in destination file */ - if(HADDR_UNDEF == (oh_dst->chunk[0].addr = H5MF_alloc(oloc_dst->file, H5FD_MEM_OHDR, (hsize_t)dst_oh_size))) + if (HADDR_UNDEF == + (oh_dst->chunk[0].addr = H5MF_alloc(oloc_dst->file, H5FD_MEM_OHDR, (hsize_t)dst_oh_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header") addr_new = oh_dst->chunk[0].addr; @@ -709,12 +696,12 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, * clear to zero bytes, so we just set the buffer to zero's here. * (QAK - 2010/08/17) */ - if(NULL == (oh_dst->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, (size_t)dst_oh_size))) + if (NULL == (oh_dst->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, (size_t)dst_oh_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set dest. chunk information */ oh_dst->chunk[0].size = (size_t)dst_oh_size; - oh_dst->chunk[0].gap = dst_oh_gap; + oh_dst->chunk[0].gap = dst_oh_gap; /* Update size of chunk array. The destination now has one chunk. */ oh_dst->nchunks = 1; @@ -731,29 +718,29 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Write the magic number for versions > 1 and skip the rest of the * header. This will be written when the header is flushed to disk. */ - if(oh_dst->version > H5O_VERSION_1) + if (oh_dst->version > H5O_VERSION_1) H5MM_memcpy(current_pos, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); current_pos += H5O_SIZEOF_HDR(oh_dst) - H5O_SIZEOF_CHKSUM_OH(oh_dst); /* Loop through destination messages, updating their "raw" info */ null_msgs = 0; - for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { + for (mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { /* Skip any deleted or NULL messages in the source unless the * preserve_null flag is set. */ - if(FALSE == cpy_info->preserve_null) { - while(deleted[mesgno + null_msgs]) { + if (FALSE == cpy_info->preserve_null) { + while (deleted[mesgno + null_msgs]) { ++null_msgs; HDassert(mesgno + null_msgs < oh_src->nmesgs); } /* end while */ - } /* end if */ + } /* end if */ /* Set up convenience variables */ mesg_src = &(oh_src->mesg[mesgno + null_msgs]); mesg_dst = &(oh_dst->mesg[mesgno]); /* Copy each message that wasn't dirtied above */ - if(!mesg_dst->dirty) + if (!mesg_dst->dirty) /* Copy the message header plus the message's raw data. */ H5MM_memcpy(current_pos, mesg_src->raw - msghdr_size, msghdr_size + mesg_src->raw_size); @@ -768,56 +755,56 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, orig_dst_msgs = oh_dst->nmesgs; /* Check if we need to add a NULL message to this header */ - if(dst_oh_null > 0) { - size_t null_idx; /* Index of new NULL message */ + if (dst_oh_null > 0) { + size_t null_idx; /* Index of new NULL message */ /* Make sure we have enough space for new NULL message */ - if(oh_dst->nmesgs + 1 > oh_dst->alloc_nmesgs) - if(H5O__alloc_msgs(oh_dst, (size_t)1) < 0) + if (oh_dst->nmesgs + 1 > oh_dst->alloc_nmesgs) + if (H5O__alloc_msgs(oh_dst, (size_t)1) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Create null message for [rest of] space in new chunk */ /* (account for chunk's magic # & checksum) */ - null_idx = oh_dst->nmesgs++; - oh_dst->mesg[null_idx].type = H5O_MSG_NULL; - oh_dst->mesg[null_idx].dirty = TRUE; - oh_dst->mesg[null_idx].native = NULL; - oh_dst->mesg[null_idx].raw = current_pos + msghdr_size; - oh_dst->mesg[null_idx].raw_size = dst_oh_null - msghdr_size; - oh_dst->mesg[null_idx].chunkno = 0; + null_idx = oh_dst->nmesgs++; + oh_dst->mesg[null_idx].type = H5O_MSG_NULL; + oh_dst->mesg[null_idx].dirty = TRUE; + oh_dst->mesg[null_idx].native = NULL; + oh_dst->mesg[null_idx].raw = current_pos + msghdr_size; + oh_dst->mesg[null_idx].raw_size = dst_oh_null - msghdr_size; + oh_dst->mesg[null_idx].chunkno = 0; } /* end if */ /* Make sure we filled the chunk, except for room at the end for a checksum */ - HDassert(current_pos + dst_oh_gap + dst_oh_null + H5O_SIZEOF_CHKSUM_OH(oh_dst) == (size_t)dst_oh_size + oh_dst->chunk[0].image); + HDassert(current_pos + dst_oh_gap + dst_oh_null + H5O_SIZEOF_CHKSUM_OH(oh_dst) == + (size_t)dst_oh_size + oh_dst->chunk[0].image); /* Set the dest. object location to the first chunk address */ HDassert(H5F_addr_defined(addr_new)); oloc_dst->addr = addr_new; - /* If we are merging committed datatypes and this is a committed datatype, insert * the copied datatype into the list of committed datatypes in the target file. */ - if(cpy_info->merge_comm_dt && obj_class->type == H5O_TYPE_NAMED_DATATYPE) - if(H5O__copy_insert_comm_dt(oloc_src->file, oh_src, oloc_dst, cpy_info) < 0) + if (cpy_info->merge_comm_dt && obj_class->type == H5O_TYPE_NAMED_DATATYPE) + if (H5O__copy_insert_comm_dt(oloc_src->file, oh_src, oloc_dst, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't insert committed datatype into destination list") /* Allocate space for the address mapping of the object copied */ - if(NULL == (addr_map = H5FL_MALLOC(H5O_addr_map_t))) + if (NULL == (addr_map = H5FL_MALLOC(H5O_addr_map_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Insert the address mapping for the new object into the copied list */ /* (Do this here, because "post copy" possibly checks it) */ H5F_GET_FILENO(oloc_src->file, addr_map->src_obj_pos.fileno); addr_map->src_obj_pos.addr = oloc_src->addr; - addr_map->dst_addr = oloc_dst->addr; - addr_map->is_locked = TRUE; /* We've locked the object currently */ - addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */ - addr_map->obj_class = obj_class; - addr_map->udata = cpy_udata; + addr_map->dst_addr = oloc_dst->addr; + addr_map->is_locked = TRUE; /* We've locked the object currently */ + addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */ + addr_map->obj_class = obj_class; + addr_map->udata = cpy_udata; /* Insert into skip list */ - if(H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) { + if (H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) { addr_map = H5FL_FREE(H5O_addr_map_t, addr_map); HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") } /* end if */ @@ -826,16 +813,16 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, * object header for destination object */ null_msgs = 0; - for(mesgno = 0; mesgno < orig_dst_msgs; mesgno++) { + for (mesgno = 0; mesgno < orig_dst_msgs; mesgno++) { /* Skip any deleted or NULL messages in the source unless the * preserve_null flag is set */ - if(FALSE == cpy_info->preserve_null) { - while(deleted[mesgno + null_msgs]) { + if (FALSE == cpy_info->preserve_null) { + while (deleted[mesgno + null_msgs]) { ++null_msgs; HDassert(mesgno + null_msgs < oh_src->nmesgs); } /* end while */ - } /* end if */ + } /* end if */ /* Set up convenience variables */ mesg_src = &(oh_src->mesg[mesgno + null_msgs]); @@ -848,8 +835,8 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, copy_type = mesg_dst->type; HDassert(copy_type); - if(copy_type->post_copy_file && mesg_src->native) { - unsigned mesg_flags; /* Message flags */ + if (copy_type->post_copy_file && mesg_src->native) { + unsigned mesg_flags; /* Message flags */ /* Sanity check destination message */ HDassert(mesg_dst->type == mesg_src->type); @@ -863,67 +850,68 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, cpy_info->oh_dst = oh_dst; /* Perform "post copy" operation on message */ - if((copy_type->post_copy_file)(oloc_src, mesg_src->native, oloc_dst, - mesg_dst->native, &mesg_flags, cpy_info) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'post copy' operation on message") + if ((copy_type->post_copy_file)(oloc_src, mesg_src->native, oloc_dst, mesg_dst->native, + &mesg_flags, cpy_info) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, + "unable to perform 'post copy' operation on message") /* Verify that the flags did not change */ - HDassert(mesg_flags == (unsigned) mesg_dst->flags); + HDassert(mesg_flags == (unsigned)mesg_dst->flags); } /* end if */ - } /* end for */ + } /* end for */ /* Indicate that the destination address will no longer be locked */ addr_map->is_locked = FALSE; /* Increment object header's reference count, if any descendents have created links to this object */ - if(addr_map->inc_ref_count) { + if (addr_map->inc_ref_count) { H5_CHECK_OVERFLOW(addr_map->inc_ref_count, hsize_t, unsigned); oh_dst->nlink += (unsigned)addr_map->inc_ref_count; } /* end if */ /* Retag all copied metadata to apply the destination object's tag */ - if(H5AC_retag_copied_metadata(oloc_dst->file, oloc_dst->addr) < 0) + if (H5AC_retag_copied_metadata(oloc_dst->file, oloc_dst->addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "unable to re-tag metadata entries") /* Set metadata tag for destination object's object header */ H5_BEGIN_TAG(oloc_dst->addr); /* Insert destination object header in cache */ - if(H5AC_insert_entry(oloc_dst->file, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(oloc_dst->file, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") - oh_dst = NULL; + oh_dst = NULL; inserted = TRUE; /* Reset metadat tag */ H5_END_TAG /* Set obj_type and udata, if requested */ - if(obj_type) { + if (obj_type) { HDassert(udata); *obj_type = obj_class->type; - *udata = cpy_udata; + *udata = cpy_udata; } /* end if */ done: /* Free deleted array */ - if(deleted) + if (deleted) H5MM_free(deleted); /* Release pointer to source object header and its derived objects */ - if(oh_src && H5O_unprotect(oloc_src, oh_src, H5AC__NO_FLAGS_SET) < 0) + if (oh_src && H5O_unprotect(oloc_src, oh_src, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") /* Free destination object header on failure */ - if(ret_value < 0) { - if(oh_dst && !inserted) { - if(H5O__free(oh_dst) < 0) + if (ret_value < 0) { + if (oh_dst && !inserted) { + if (H5O__free(oh_dst) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - if(H5O_loc_reset(oloc_dst) < 0) + if (H5O_loc_reset(oloc_dst) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") } /* end if */ - if(addr_map == NULL && cpy_udata) { - if(obj_class && obj_class->free_copy_file_udata) + if (addr_map == NULL && cpy_udata) { + if (obj_class && obj_class->free_copy_file_udata) obj_class->free_copy_file_udata(cpy_udata); } /* end if */ } @@ -931,7 +919,6 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__copy_header_real() */ - /*------------------------------------------------------------------------- * Function: H5O_copy_header_map * @@ -946,14 +933,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, - H5O_copy_t *cpy_info, hbool_t inc_depth, H5O_type_t *obj_type, - void **udata /*out*/) +H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5O_copy_t *cpy_info, + hbool_t inc_depth, H5O_type_t *obj_type, void **udata /*out*/) { - H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */ - H5_obj_t src_obj_pos; /* Position of source object */ - hbool_t inc_link; /* Whether to increment the link count for the object */ - herr_t ret_value = SUCCEED; + H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */ + H5_obj_t src_obj_pos; /* Position of source object */ + hbool_t inc_link; /* Whether to increment the link count for the object */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -969,24 +955,23 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, src_obj_pos.addr = oloc_src->addr; /* Search for the object in the skip list of copied objects */ - addr_map = (H5O_addr_map_t *)H5SL_search(cpy_info->map_list, - &src_obj_pos); + addr_map = (H5O_addr_map_t *)H5SL_search(cpy_info->map_list, &src_obj_pos); /* Check if address is already in list of objects copied */ - if(addr_map == NULL) { + if (addr_map == NULL) { /* Copy object for the first time */ /* Check for incrementing the depth of copy */ /* (Can't do this for all copies, since committed datatypes should always be copied) */ - if(inc_depth) + if (inc_depth) cpy_info->curr_depth++; /* Copy object referred to */ - if(H5O__copy_header_real(oloc_src, oloc_dst, cpy_info, obj_type, udata) < 0) + if (H5O__copy_header_real(oloc_src, oloc_dst, cpy_info, obj_type, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Check for incrementing the depth of copy */ - if(inc_depth) + if (inc_depth) cpy_info->curr_depth--; /* When an object is copied for the first time, increment it's link */ @@ -1000,10 +985,10 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, oloc_dst->addr = addr_map->dst_addr; /* Return saved obj_type and udata, if requested */ - if(obj_type) { + if (obj_type) { HDassert(udata); *obj_type = addr_map->obj_class->type; - *udata = addr_map->udata; + *udata = addr_map->udata; } /* end if */ /* If the object is locked currently (because we are copying a group @@ -1011,7 +996,7 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, * increment it's deferred reference count instead of incrementing the * reference count now. */ - if(addr_map->is_locked) { + if (addr_map->is_locked) { addr_map->inc_ref_count++; inc_link = FALSE; } /* end if */ @@ -1020,15 +1005,14 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, } /* end else */ /* Increment destination object's link count, if allowed */ - if(inc_link) - if(H5O_link(oloc_dst, 1) < 0) + if (inc_link) + if (H5O_link(oloc_dst, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to increment object link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_copy_header_map() */ - /*-------------------------------------------------------------------------- NAME H5O__copy_free_addrmap_cb @@ -1058,7 +1042,7 @@ H5O__copy_free_addrmap_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UN HDassert(item); /* Release user data for particular type of object */ - if(item->udata) { + if (item->udata) { HDassert(item->obj_class); HDassert(item->obj_class->free_copy_file_udata); (item->obj_class->free_copy_file_udata)(item->udata); @@ -1068,9 +1052,8 @@ H5O__copy_free_addrmap_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UN item = H5FL_FREE(H5O_addr_map_t, item); FUNC_LEAVE_NOAPI(0) -} /* H5O__copy_free_addrmap_cb() */ +} /* H5O__copy_free_addrmap_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_header * @@ -1084,15 +1067,14 @@ H5O__copy_free_addrmap_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UN *------------------------------------------------------------------------- */ static herr_t -H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, - hid_t ocpypl_id, hid_t lcpl_id) +H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, hid_t ocpypl_id, hid_t lcpl_id) { - H5O_copy_t cpy_info; /* Information for copying object */ - H5P_genplist_t *ocpy_plist; /* Object copy property list created */ + H5O_copy_t cpy_info; /* Information for copying object */ + H5P_genplist_t * ocpy_plist; /* Object copy property list created */ H5O_copy_dtype_merge_list_t *dt_list = NULL; /* List of datatype merge suggestions */ - H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ - unsigned cpy_option = 0; /* Copy options */ - herr_t ret_value = SUCCEED; + H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ + unsigned cpy_option = 0; /* Copy options */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1106,40 +1088,40 @@ H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, HDmemset(&cpy_info, 0, sizeof(H5O_copy_t)); /* Get the copy property list */ - if(NULL == (ocpy_plist = (H5P_genplist_t *)H5I_object(ocpypl_id))) + if (NULL == (ocpy_plist = (H5P_genplist_t *)H5I_object(ocpypl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve the copy parameters */ - if(H5P_get(ocpy_plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) + if (H5P_get(ocpy_plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag") /* Retrieve the marge committed datatype list */ - if(H5P_peek(ocpy_plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + if (H5P_peek(ocpy_plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge committed datatype list") /* Get callback info */ - if(H5P_get(ocpy_plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) + if (H5P_get(ocpy_plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") /* Convert copy flags into copy struct */ - if((cpy_option & H5O_COPY_SHALLOW_HIERARCHY_FLAG) > 0) { + if ((cpy_option & H5O_COPY_SHALLOW_HIERARCHY_FLAG) > 0) { cpy_info.copy_shallow = TRUE; - cpy_info.max_depth = 1; + cpy_info.max_depth = 1; } /* end if */ else - cpy_info.max_depth = -1; /* Current default is for full, recursive hier. copy */ + cpy_info.max_depth = -1; /* Current default is for full, recursive hier. copy */ cpy_info.curr_depth = 0; - if((cpy_option & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) + if ((cpy_option & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) cpy_info.expand_soft_link = TRUE; - if((cpy_option & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) + if ((cpy_option & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) cpy_info.expand_ext_link = TRUE; - if((cpy_option & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) + if ((cpy_option & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) cpy_info.expand_ref = TRUE; - if((cpy_option & H5O_COPY_WITHOUT_ATTR_FLAG) > 0) + if ((cpy_option & H5O_COPY_WITHOUT_ATTR_FLAG) > 0) cpy_info.copy_without_attr = TRUE; - if((cpy_option & H5O_COPY_PRESERVE_NULL_FLAG) > 0) + if ((cpy_option & H5O_COPY_PRESERVE_NULL_FLAG) > 0) cpy_info.preserve_null = TRUE; - if((cpy_option & H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) > 0) + if ((cpy_option & H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) > 0) cpy_info.merge_comm_dt = TRUE; /* Add dt_list to copy struct */ @@ -1153,23 +1135,22 @@ H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, cpy_info.lcpl_id = lcpl_id; /* Create a skip list to keep track of which objects are copied */ - if(NULL == (cpy_info.map_list = H5SL_create(H5SL_TYPE_OBJ, NULL))) + if (NULL == (cpy_info.map_list = H5SL_create(H5SL_TYPE_OBJ, NULL))) HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, FAIL, "cannot make skip list") /* copy the object from the source file to the destination file */ - if(H5O__copy_header_real(oloc_src, oloc_dst, &cpy_info, NULL, NULL) < 0) + if (H5O__copy_header_real(oloc_src, oloc_dst, &cpy_info, NULL, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: - if(cpy_info.map_list) + if (cpy_info.map_list) H5SL_destroy(cpy_info.map_list, H5O__copy_free_addrmap_cb, NULL); - if(cpy_info.dst_dt_list) + if (cpy_info.dst_dt_list) H5SL_destroy(cpy_info.dst_dt_list, H5O__copy_free_comm_dt_cb, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_header() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_obj * @@ -1183,15 +1164,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id) +H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) { - H5G_name_t new_path; /* Copied object group hier. path */ - H5O_loc_t new_oloc; /* Copied object object location */ - H5G_loc_t new_loc; /* Group location of object copied */ - H5F_t *cached_dst_file; /* Cached destination file */ - hbool_t entry_inserted = FALSE; /* Flag to indicate that the new entry was inserted into a group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_name_t new_path; /* Copied object group hier. path */ + H5O_loc_t new_oloc; /* Copied object object location */ + H5G_loc_t new_loc; /* Group location of object copied */ + H5F_t * cached_dst_file; /* Cached destination file */ + hbool_t entry_inserted = FALSE; /* Flag to indicate that the new entry was inserted into a group */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1213,7 +1193,7 @@ H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, cached_dst_file = dst_loc->oloc->file; /* Copy the object from the source file to the destination file */ - if(H5O__copy_header(src_loc->oloc, &new_oloc, ocpypl_id, lcpl_id) < 0) + if (H5O__copy_header(src_loc->oloc, &new_oloc, ocpypl_id, lcpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Patch dst_loc. Again, this can be removed once oloc's point to shared @@ -1221,19 +1201,18 @@ H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, dst_loc->oloc->file = cached_dst_file; /* Insert the new object in the destination file's group */ - if(H5L_link(dst_loc, dst_name, &new_loc, lcpl_id) < 0) + if (H5L_link(dst_loc, dst_name, &new_loc, lcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link") entry_inserted = TRUE; done: /* Free the ID to name buffers */ - if(entry_inserted) + if (entry_inserted) H5G_loc_free(&new_loc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_obj() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_free_comm_dt_cb * @@ -1249,8 +1228,8 @@ done: static herr_t H5O__copy_free_comm_dt_cb(void *item, void *_key, void H5_ATTR_UNUSED *_op_data) { - haddr_t *addr = (haddr_t *)item; - H5O_copy_search_comm_dt_key_t *key = (H5O_copy_search_comm_dt_key_t *)_key; + haddr_t * addr = (haddr_t *)item; + H5O_copy_search_comm_dt_key_t *key = (H5O_copy_search_comm_dt_key_t *)_key; FUNC_ENTER_STATIC_NOERR @@ -1259,13 +1238,12 @@ H5O__copy_free_comm_dt_cb(void *item, void *_key, void H5_ATTR_UNUSED *_op_data) HDassert(key->dt); key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); - key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); - addr = H5FL_FREE(haddr_t, addr); + key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); + addr = H5FL_FREE(haddr_t, addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__copy_free_comm_dt_cb */ - /*------------------------------------------------------------------------- * Function: H5O__copy_comm_dt_cmp * @@ -1284,18 +1262,18 @@ H5O__copy_free_comm_dt_cb(void *item, void *_key, void H5_ATTR_UNUSED *_op_data) static int H5O__copy_comm_dt_cmp(const void *_key1, const void *_key2) { - const H5O_copy_search_comm_dt_key_t *key1 = (const H5O_copy_search_comm_dt_key_t *)_key1; - const H5O_copy_search_comm_dt_key_t *key2 = (const H5O_copy_search_comm_dt_key_t *)_key2; - int ret_value = 0; + const H5O_copy_search_comm_dt_key_t *key1 = (const H5O_copy_search_comm_dt_key_t *)_key1; + const H5O_copy_search_comm_dt_key_t *key2 = (const H5O_copy_search_comm_dt_key_t *)_key2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR /* Check fileno. It is unlikely to be different so check if they are equal * first so only one comparison needs to be made. */ - if(key1->fileno != key2->fileno) { - if(key1->fileno < key2->fileno) + if (key1->fileno != key2->fileno) { + if (key1->fileno < key2->fileno) HGOTO_DONE(-1) - if(key1->fileno > key2->fileno) + if (key1->fileno > key2->fileno) HGOTO_DONE(1) } /* end if */ @@ -1305,7 +1283,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_comm_dt_cmp */ - /*------------------------------------------------------------------------- * Function: H5O_copy_search_comm_dt_attr_cb * @@ -1325,12 +1302,12 @@ done: static herr_t H5O_copy_search_comm_dt_attr_cb(const H5A_t *attr, void *_udata) { - H5O_copy_search_comm_dt_ud_t *udata = (H5O_copy_search_comm_dt_ud_t *)_udata; - H5T_t *dt = NULL; /* Datatype */ - H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - haddr_t *addr = NULL; /* Destination address */ - hbool_t obj_inserted = FALSE; /* Object inserted into skip list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_copy_search_comm_dt_ud_t * udata = (H5O_copy_search_comm_dt_ud_t *)_udata; + H5T_t * dt = NULL; /* Datatype */ + H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ + haddr_t * addr = NULL; /* Destination address */ + hbool_t obj_inserted = FALSE; /* Object inserted into skip list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1341,53 +1318,52 @@ H5O_copy_search_comm_dt_attr_cb(const H5A_t *attr, void *_udata) HDassert(H5F_addr_defined(udata->obj_oloc.addr)); /* Get attribute datatype */ - if(NULL == (dt = H5A_type(attr))) + if (NULL == (dt = H5A_type(attr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get attribute datatype") /* Check if the datatype is committed and search the skip list if so */ - if(H5T_is_named(dt)) { + if (H5T_is_named(dt)) { /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy datatype into key */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_copy(H5O_DTYPE_ID, dt, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_copy(H5O_DTYPE_ID, dt, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy datatype message") /* Get datatype object fileno */ H5F_GET_FILENO(udata->obj_oloc.file, key->fileno); - if(!H5SL_search(udata->dst_dt_list, key)) { + if (!H5SL_search(udata->dst_dt_list, key)) { /* Allocate destination address */ - if(NULL == (addr = H5FL_MALLOC(haddr_t))) + if (NULL == (addr = H5FL_MALLOC(haddr_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Add the destination datatype to the skip list */ *addr = ((H5O_shared_t *)(key->dt))->u.loc.oh_addr; - if(H5SL_insert(udata->dst_dt_list, addr, key) < 0) + if (H5SL_insert(udata->dst_dt_list, addr, key) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") obj_inserted = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: /* Release resources */ - if(!obj_inserted) { - if(key) { - if(key->dt) + if (!obj_inserted) { + if (key) { + if (key->dt) key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); } /* end if */ - if(addr) { + if (addr) { HDassert(ret_value < 0); addr = H5FL_FREE(haddr_t, addr); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_copy_search_comm_dt_attr_cb */ - /*------------------------------------------------------------------------- * Function: H5O_copy_search_comm_dt_check * @@ -1404,15 +1380,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_copy_search_comm_dt_check(H5O_loc_t *obj_oloc, - H5O_copy_search_comm_dt_ud_t *udata) +H5O_copy_search_comm_dt_check(H5O_loc_t *obj_oloc, H5O_copy_search_comm_dt_ud_t *udata) { - H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - haddr_t *addr = NULL; /* Destination address */ - hbool_t obj_inserted = FALSE; /* Object inserted into skip list */ - H5A_attr_iter_op_t attr_op; /* Attribute iteration operator */ - const H5O_obj_class_t *obj_class = NULL; /* Type of object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ + haddr_t * addr = NULL; /* Destination address */ + hbool_t obj_inserted = FALSE; /* Object inserted into skip list */ + H5A_attr_iter_op_t attr_op; /* Attribute iteration operator */ + const H5O_obj_class_t * obj_class = NULL; /* Type of object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1423,90 +1398,90 @@ H5O_copy_search_comm_dt_check(H5O_loc_t *obj_oloc, HDassert(udata->dst_root_loc); /* Get pointer to object class for this object */ - if((obj_class = H5O__obj_class(obj_oloc)) == NULL) + if ((obj_class = H5O__obj_class(obj_oloc)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") /* Check if the object is a datatype, a dataset using a committed * datatype, or contains an attribute using a committed datatype */ - if(obj_class->type == H5O_TYPE_NAMED_DATATYPE) { + if (obj_class->type == H5O_TYPE_NAMED_DATATYPE) { /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Read the destination datatype */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_read(obj_oloc, H5O_DTYPE_ID, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_read(obj_oloc, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read DTYPE message") /* Get destination object fileno */ H5F_GET_FILENO(obj_oloc->file, key->fileno); /* Check if the datatype is already present in the skip list */ - if(!H5SL_search(udata->dst_dt_list, key)) { + if (!H5SL_search(udata->dst_dt_list, key)) { /* Allocate destination address */ - if(NULL == (addr = H5FL_MALLOC(haddr_t))) + if (NULL == (addr = H5FL_MALLOC(haddr_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Add the destination datatype to the skip list */ *addr = obj_oloc->addr; - if(H5SL_insert(udata->dst_dt_list, addr, key) < 0) + if (H5SL_insert(udata->dst_dt_list, addr, key) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") obj_inserted = TRUE; } /* end if */ - } /* end if */ - else if(obj_class->type == H5O_TYPE_DATASET) { + } /* end if */ + else if (obj_class->type == H5O_TYPE_DATASET) { /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Read the destination datatype */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_read(obj_oloc, H5O_DTYPE_ID, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_read(obj_oloc, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read DTYPE message") /* Check if the datatype is committed and search the skip list if so */ - if(H5T_is_named(key->dt)) { + if (H5T_is_named(key->dt)) { /* Get datatype object fileno */ H5F_GET_FILENO(obj_oloc->file, key->fileno); - if(!H5SL_search(udata->dst_dt_list, key)) { + if (!H5SL_search(udata->dst_dt_list, key)) { /* Allocate destination address */ - if(NULL == (addr = H5FL_MALLOC(haddr_t))) + if (NULL == (addr = H5FL_MALLOC(haddr_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Add the destination datatype to the skip list */ *addr = ((H5O_shared_t *)(key->dt))->u.loc.oh_addr; - if(H5SL_insert(udata->dst_dt_list, addr, key) < 0) + if (H5SL_insert(udata->dst_dt_list, addr, key) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") obj_inserted = TRUE; } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Search within attributes */ - attr_op.op_type = H5A_ATTR_OP_LIB; - attr_op.u.lib_op = H5O_copy_search_comm_dt_attr_cb; + attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.u.lib_op = H5O_copy_search_comm_dt_attr_cb; udata->obj_oloc.file = obj_oloc->file; udata->obj_oloc.addr = obj_oloc->addr; - if(H5O_attr_iterate_real((hid_t)-1, obj_oloc, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, udata) < 0) + if (H5O_attr_iterate_real((hid_t)-1, obj_oloc, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, + udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "error iterating over attributes"); done: /* Release resources */ - if(!obj_inserted) { - if(key) { - if(key->dt) + if (!obj_inserted) { + if (key) { + if (key->dt) key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); } /* end if */ - if(addr) { + if (addr) { HDassert(ret_value < 0); addr = H5FL_FREE(haddr_t, addr); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_copy_search_comm_dt_check */ - /*------------------------------------------------------------------------- * Function: H5O__copy_search_comm_dt_cb * @@ -1522,15 +1497,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, - const H5L_info2_t *linfo, void *_udata) +H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo, + void *_udata) { - H5O_copy_search_comm_dt_ud_t *udata = (H5O_copy_search_comm_dt_ud_t *)_udata; /* Skip list of dtypes in dest file */ - H5G_loc_t obj_loc; /* Location of object */ - H5O_loc_t obj_oloc; /* Object's object location */ - H5G_name_t obj_path; /* Object's group hier. path */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_copy_search_comm_dt_ud_t *udata = + (H5O_copy_search_comm_dt_ud_t *)_udata; /* Skip list of dtypes in dest file */ + H5G_loc_t obj_loc; /* Location of object */ + H5O_loc_t obj_oloc; /* Object's object location */ + H5G_name_t obj_path; /* Object's group hier. path */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1542,31 +1518,30 @@ H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, HDassert(udata->dst_root_loc); /* Check if this is a hard link */ - if(linfo->type == H5L_TYPE_HARD) { + if (linfo->type == H5L_TYPE_HARD) { /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; obj_loc.path = &obj_path; H5G_loc_reset(&obj_loc); /* Find the object */ - if(H5G_loc_find(udata->dst_root_loc, name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(udata->dst_root_loc, name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") obj_found = TRUE; /* Check object and add to skip list if appropriate */ - if(H5O_copy_search_comm_dt_check(&obj_oloc, udata) < 0) + if (H5O_copy_search_comm_dt_check(&obj_oloc, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "can't check object") } /* end if */ done: /* Release resources */ - if(obj_found && H5G_loc_free(&obj_loc) < 0) + if (obj_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_search_comm_dt_cb */ - /*------------------------------------------------------------------------- * Function: H5O__copy_search_comm_dt * @@ -1585,14 +1560,14 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, - H5O_loc_t *oloc_dst/*in, out*/, H5O_copy_t *cpy_info) +H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*in, out*/, + H5O_copy_t *cpy_info) { - H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - haddr_t *dst_addr; /* Destination datatype address */ - H5G_loc_t dst_root_loc = {NULL, NULL}; /* Destination root group location */ - H5O_copy_search_comm_dt_ud_t udata; /* Group iteration user data */ - herr_t ret_value = FALSE; /* Return value */ + H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ + haddr_t * dst_addr; /* Destination datatype address */ + H5G_loc_t dst_root_loc = {NULL, NULL}; /* Destination root group location */ + H5O_copy_search_comm_dt_ud_t udata; /* Group iteration user data */ + herr_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -1604,33 +1579,33 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, HDassert(cpy_info); /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Read the source datatype */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_read_oh(file_src, oh_src, H5O_DTYPE_ID, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_read_oh(file_src, oh_src, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read DTYPE message") /* Get destination object fileno */ H5F_GET_FILENO(oloc_dst->file, key->fileno); /* Check if the destination dtype list exists, create it if it does not */ - if(!cpy_info->dst_dt_list) { + if (!cpy_info->dst_dt_list) { /* Create the skip list */ - if(NULL == (cpy_info->dst_dt_list = H5SL_create(H5SL_TYPE_GENERIC, H5O__copy_comm_dt_cmp))) + if (NULL == (cpy_info->dst_dt_list = H5SL_create(H5SL_TYPE_GENERIC, H5O__copy_comm_dt_cmp))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for committed datatypes") /* Add suggested types to list, if they are present */ - if(cpy_info->dst_dt_suggestion_list) { + if (cpy_info->dst_dt_suggestion_list) { H5O_copy_dtype_merge_list_t *suggestion = cpy_info->dst_dt_suggestion_list; - H5G_loc_t obj_loc; /* Location of object */ - H5O_loc_t obj_oloc; /* Object's object location */ - H5G_name_t obj_path; /* Object's group hier. path */ + H5G_loc_t obj_loc; /* Location of object */ + H5O_loc_t obj_oloc; /* Object's object location */ + H5G_name_t obj_path; /* Object's group hier. path */ /* Set up the root group in the destination file */ - if(NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(oloc_dst->file)))) + if (NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(oloc_dst->file)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(oloc_dst->file)))) + if (NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(oloc_dst->file)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Set up opened group location to fill in */ @@ -1639,99 +1614,99 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5G_loc_reset(&obj_loc); /* Build udata */ - udata.dst_dt_list = cpy_info->dst_dt_list; - udata.dst_root_loc = &dst_root_loc; + udata.dst_dt_list = cpy_info->dst_dt_list; + udata.dst_root_loc = &dst_root_loc; udata.obj_oloc.file = NULL; udata.obj_oloc.addr = HADDR_UNDEF; /* Walk through the list of datatype suggestions */ - while(suggestion) { + while (suggestion) { /* Find the object */ - if(H5G_loc_find(&dst_root_loc, suggestion->path, &obj_loc/*out*/) < 0) + if (H5G_loc_find(&dst_root_loc, suggestion->path, &obj_loc /*out*/) < 0) /* Ignore errors - i.e. suggestions not present in * destination file */ H5E_clear_stack(NULL); else /* Check object and add to skip list if appropriate */ - if(H5O_copy_search_comm_dt_check(&obj_oloc, &udata) < 0) { - if(H5G_loc_free(&obj_loc) < 0) - HERROR(H5E_OHDR, H5E_CANTRELEASE, "can't free location"); - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't check object") - } /* end if */ + if (H5O_copy_search_comm_dt_check(&obj_oloc, &udata) < 0) { + if (H5G_loc_free(&obj_loc) < 0) + HERROR(H5E_OHDR, H5E_CANTRELEASE, "can't free location"); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't check object") + } /* end if */ /* Free location */ - if(H5G_loc_free(&obj_loc) < 0) + if (H5G_loc_free(&obj_loc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location"); /* Advance the suggestion pointer */ suggestion = suggestion->next; } /* end while */ - } /* end if */ + } /* end if */ } - if(!cpy_info->dst_dt_list_complete) { + if (!cpy_info->dst_dt_list_complete) { /* Search for the type in the destination file, and return its address * if found, but only if the list is populated with and only with * suggested types. We will search complete lists later. */ - if(cpy_info->dst_dt_suggestion_list - && NULL != (dst_addr = (haddr_t *)H5SL_search( - cpy_info->dst_dt_list, key))) { + if (cpy_info->dst_dt_suggestion_list && + NULL != (dst_addr = (haddr_t *)H5SL_search(cpy_info->dst_dt_list, key))) { oloc_dst->addr = *dst_addr; - ret_value = TRUE; + ret_value = TRUE; } /* end if */ else { H5O_mcdt_search_ret_t search_cb_ret = H5O_MCDT_SEARCH_CONT; /* Make callback to see if we should search destination file */ - if(cpy_info->mcdt_cb) - if((search_cb_ret = cpy_info->mcdt_cb(cpy_info->mcdt_ud)) == H5O_MCDT_SEARCH_ERROR) + if (cpy_info->mcdt_cb) + if ((search_cb_ret = cpy_info->mcdt_cb(cpy_info->mcdt_ud)) == H5O_MCDT_SEARCH_ERROR) HGOTO_ERROR(H5E_OHDR, H5E_CALLBACK, FAIL, "callback returned error") - if(search_cb_ret == H5O_MCDT_SEARCH_CONT) { + if (search_cb_ret == H5O_MCDT_SEARCH_CONT) { /* Build the complete dst dt list */ /* Set up the root group in the destination file, if necessary */ - if(!dst_root_loc.oloc) { + if (!dst_root_loc.oloc) { HDassert(!dst_root_loc.path); - if(NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(oloc_dst->file)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(oloc_dst->file)))) + if (NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(oloc_dst->file)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get object location for root group") + if (NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(oloc_dst->file)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") } /* end if */ else HDassert(dst_root_loc.path); /* Build udata. Note that this may be done twice in some cases, but - * it should be rare and should be cheaper on average than trying to - * keep track of whether it was done before. */ - udata.dst_dt_list = cpy_info->dst_dt_list; - udata.dst_root_loc = &dst_root_loc; + * it should be rare and should be cheaper on average than trying to + * keep track of whether it was done before. */ + udata.dst_dt_list = cpy_info->dst_dt_list; + udata.dst_root_loc = &dst_root_loc; udata.obj_oloc.file = NULL; udata.obj_oloc.addr = HADDR_UNDEF; /* Traverse the destination file, adding committed datatypes to the skip - * list */ - if(H5G_visit(&dst_root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O__copy_search_comm_dt_cb, &udata) < 0) + * list */ + if (H5G_visit(&dst_root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O__copy_search_comm_dt_cb, + &udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") cpy_info->dst_dt_list_complete = TRUE; } /* end if */ - else - if(search_cb_ret != H5O_MCDT_SEARCH_STOP) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown return value for callback") + else if (search_cb_ret != H5O_MCDT_SEARCH_STOP) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown return value for callback") } /* end if */ - } /* end if */ + } /* end if */ /* Search for the type in the destination file, and return its address if * found, but only if the list is complete */ - if(cpy_info->dst_dt_list_complete) { - if(NULL != (dst_addr = (haddr_t *)H5SL_search(cpy_info->dst_dt_list, key))) { + if (cpy_info->dst_dt_list_complete) { + if (NULL != (dst_addr = (haddr_t *)H5SL_search(cpy_info->dst_dt_list, key))) { oloc_dst->addr = *dst_addr; - ret_value = TRUE; + ret_value = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: - if(key) { - if(key->dt) + if (key) { + if (key->dt) key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); } /* end if */ @@ -1739,7 +1714,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_search_comm_dt */ - /*------------------------------------------------------------------------- * Function: H5O__copy_insert_comm_dt * @@ -1754,12 +1728,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__copy_insert_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst, - H5O_copy_t *cpy_info) +H5O__copy_insert_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst, H5O_copy_t *cpy_info) { - H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - haddr_t *addr = NULL; /* Destination object address */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ + haddr_t * addr = NULL; /* Destination object address */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1772,37 +1745,36 @@ H5O__copy_insert_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst, HDassert(cpy_info->dst_dt_list); /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Read the datatype. Read from the source file because the destination * object could be changed in the post-copy. */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_read_oh(file_src, oh_src, H5O_DTYPE_ID, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_read_oh(file_src, oh_src, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read DTYPE message") /* Get destination object fileno */ H5F_GET_FILENO(oloc_dst->file, key->fileno); /* Allocate destination address */ - if(NULL == (addr = H5FL_MALLOC(haddr_t))) + if (NULL == (addr = H5FL_MALLOC(haddr_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Add the destination datatype to the skip list */ *addr = oloc_dst->addr; - if(H5SL_insert(cpy_info->dst_dt_list, addr, key) < 0) + if (H5SL_insert(cpy_info->dst_dt_list, addr, key) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") done: - if(ret_value < 0) { - if(key) { - if(key->dt) + if (ret_value < 0) { + if (key) { + if (key->dt) key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); } /* end if */ - if(addr) + if (addr) addr = H5FL_FREE(haddr_t, addr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_insert_comm_dt */ - diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c index 0de661f..a6d22de 100644 --- a/src/H5Ocopy_ref.c +++ b/src/H5Ocopy_ref.c @@ -23,29 +23,26 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5R_FRIEND /* Suppress error about including H5Rpkg */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5R_FRIEND /* Suppress error about including H5Rpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Rpkg.h" /* References */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Rpkg.h" /* References */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -54,23 +51,22 @@ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, - H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info); -static herr_t H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, - const void *buf_src, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, - void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info); -static herr_t H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, - const void *buf_src, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, - void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info); -static herr_t H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, - H5T_t *dt_src, const void *buf_src, size_t nbytes_src, H5O_loc_t *dst_oloc, - H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, - H5O_copy_t *cpy_info); +static herr_t H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, + H5O_copy_t *cpy_info); +static herr_t H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t *dst_oloc, + H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, + H5O_copy_t *cpy_info); +static herr_t H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t *dst_oloc, + H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, + H5O_copy_t *cpy_info); +static herr_t H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, + const void *buf_src, size_t nbytes_src, H5O_loc_t *dst_oloc, + H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, + H5O_copy_t *cpy_info); /*********************/ /* Package Variables */ @@ -83,12 +79,10 @@ H5FL_BLK_EXTERN(type_conv); /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5O__copy_obj_by_ref * @@ -99,10 +93,9 @@ H5FL_BLK_EXTERN(type_conv); *------------------------------------------------------------------------- */ static herr_t -H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, - H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info) +H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -110,15 +103,15 @@ H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, HDassert(dst_oloc); /* Perform the copy, or look up existing copy */ - if((ret_value = H5O_copy_header_map(src_oloc, dst_oloc, cpy_info, FALSE, NULL, NULL)) < 0) + if ((ret_value = H5O_copy_header_map(src_oloc, dst_oloc, cpy_info, FALSE, NULL, NULL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Check if a new valid object is copied to the destination */ - if(H5F_addr_defined(dst_oloc->addr) && (ret_value > SUCCEED)) { - char tmp_obj_name[80]; - H5G_name_t new_path; - H5O_loc_t new_oloc; - H5G_loc_t new_loc; + if (H5F_addr_defined(dst_oloc->addr) && (ret_value > SUCCEED)) { + char tmp_obj_name[80]; + H5G_name_t new_path; + H5O_loc_t new_oloc; + H5G_loc_t new_loc; /* Set up group location for new object */ new_loc.oloc = &new_oloc; @@ -128,7 +121,8 @@ H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, new_oloc.addr = dst_oloc->addr; /* Pick a default name for the new object */ - HDsnprintf(tmp_obj_name, sizeof(tmp_obj_name), "~obj_pointed_by_%llu", (unsigned long long)dst_oloc->addr); + HDsnprintf(tmp_obj_name, sizeof(tmp_obj_name), "~obj_pointed_by_%llu", + (unsigned long long)dst_oloc->addr); /* Create a link to the newly copied object */ /* Note: since H5O_copy_header_map actually copied the target object, it @@ -136,7 +130,7 @@ H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, * pass the obj_type and udata fields returned by H5O_copy_header_map. * This could be changed in the future to slightly improve performance * --NAF */ - if(H5L_link(dst_root_loc, tmp_obj_name, &new_loc, cpy_info->lcpl_id) < 0) + if (H5L_link(dst_root_loc, tmp_obj_name, &new_loc, cpy_info->lcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link") H5G_loc_free(&new_loc); @@ -146,7 +140,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_obj_by_ref() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_expand_ref_object1 * @@ -157,50 +150,49 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, - H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, void *buf_dst, - size_t ref_count, H5O_copy_t *cpy_info) +H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t *dst_oloc, + H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info) { - const hobj_ref_t *src_ref = (const hobj_ref_t *)buf_src; - hobj_ref_t *dst_ref = (hobj_ref_t *)buf_dst; - const unsigned char zeros[H5R_OBJ_REF_BUF_SIZE] = { 0 }; - size_t buf_size = H5R_OBJ_REF_BUF_SIZE; - size_t i; /* Local index variable */ - size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file); - herr_t ret_value = SUCCEED; + const hobj_ref_t * src_ref = (const hobj_ref_t *)buf_src; + hobj_ref_t * dst_ref = (hobj_ref_t *)buf_dst; + const unsigned char zeros[H5R_OBJ_REF_BUF_SIZE] = {0}; + size_t buf_size = H5R_OBJ_REF_BUF_SIZE; + size_t i; /* Local index variable */ + size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file); + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Making equivalent references in the destination file */ - for(i = 0; i < ref_count; i++) { - const unsigned char *src_buf = (const unsigned char *)&src_ref[i]; - unsigned char *dst_buf = (unsigned char *)&dst_ref[i]; - H5O_token_t tmp_token = { 0 }; + for (i = 0; i < ref_count; i++) { + const unsigned char *src_buf = (const unsigned char *)&src_ref[i]; + unsigned char * dst_buf = (unsigned char *)&dst_ref[i]; + H5O_token_t tmp_token = {0}; /* If data is not initialized, copy zeros and skip */ - if(0 == HDmemcmp(src_buf, zeros, buf_size)) { + if (0 == HDmemcmp(src_buf, zeros, buf_size)) { HDmemset(dst_buf, 0, buf_size); continue; } /* Set up for the object copy for the reference */ - if(H5R__decode_token_obj_compat(src_buf, &buf_size, &tmp_token, token_size) < 0) + if (H5R__decode_token_obj_compat(src_buf, &buf_size, &tmp_token, token_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode src object address") - if(H5VL_native_token_to_addr(src_oloc->file, H5I_FILE, tmp_token, &src_oloc->addr) < 0) + if (H5VL_native_token_to_addr(src_oloc->file, H5I_FILE, tmp_token, &src_oloc->addr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") - if(!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0) + if (!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer") dst_oloc->addr = HADDR_UNDEF; /* Attempt to copy object from source to destination file */ - if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) + if (H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Set the object reference info for the destination file */ - if(H5VL_native_addr_to_token(dst_oloc->file, H5I_FILE, dst_oloc->addr, &tmp_token) < 0) + if (H5VL_native_addr_to_token(dst_oloc->file, H5I_FILE, dst_oloc->addr, &tmp_token) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") - if(H5R__encode_token_obj_compat((const H5O_token_t *)&tmp_token, token_size, dst_buf, &buf_size) < 0) + if (H5R__encode_token_obj_compat((const H5O_token_t *)&tmp_token, token_size, dst_buf, &buf_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to encode dst object address") } /* end for */ @@ -208,7 +200,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_expand_ref_object1() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_expand_ref_region1 * @@ -219,49 +210,48 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, - H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, void *buf_dst, - size_t ref_count, H5O_copy_t *cpy_info) +H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t *dst_oloc, + H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info) { - const hdset_reg_ref_t *src_ref = (const hdset_reg_ref_t *)buf_src; - hdset_reg_ref_t *dst_ref = (hdset_reg_ref_t *)buf_dst; - const unsigned char zeros[H5R_DSET_REG_REF_BUF_SIZE] = { 0 }; - size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; + const hdset_reg_ref_t *src_ref = (const hdset_reg_ref_t *)buf_src; + hdset_reg_ref_t * dst_ref = (hdset_reg_ref_t *)buf_dst; + const unsigned char zeros[H5R_DSET_REG_REF_BUF_SIZE] = {0}; + size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Making equivalent references in the destination file */ - for(i = 0; i < ref_count; i++) { + for (i = 0; i < ref_count; i++) { const unsigned char *src_buf = (const unsigned char *)&src_ref[i]; - unsigned char *dst_buf = (unsigned char *)&dst_ref[i]; - unsigned char *data = NULL; - size_t data_size; - const uint8_t *p; - uint8_t *q; + unsigned char * dst_buf = (unsigned char *)&dst_ref[i]; + unsigned char * data = NULL; + size_t data_size; + const uint8_t * p; + uint8_t * q; /* If data is not initialized, copy zeros and skip */ - if(0 == HDmemcmp(src_buf, zeros, buf_size)) { + if (0 == HDmemcmp(src_buf, zeros, buf_size)) { HDmemset(dst_buf, 0, buf_size); continue; } /* Read from heap */ - if(H5R__decode_heap(src_oloc->file, src_buf, &buf_size, &data, &data_size) < 0) + if (H5R__decode_heap(src_oloc->file, src_buf, &buf_size, &data, &data_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode dataset region information") /* Get object address */ p = (const uint8_t *)data; H5F_addr_decode(src_oloc->file, &p, &src_oloc->addr); - if(!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0) { + if (!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0) { H5MM_free(data); HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer") } dst_oloc->addr = HADDR_UNDEF; /* Attempt to copy object from source to destination file */ - if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) { + if (H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) { H5MM_free(data); HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") } /* end if */ @@ -271,7 +261,7 @@ H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, H5F_addr_encode(dst_oloc->file, &q, dst_oloc->addr); /* Write to heap */ - if(H5R__encode_heap(dst_oloc->file, dst_buf, &buf_size, data, (size_t)data_size) < 0) { + if (H5R__encode_heap(dst_oloc->file, dst_buf, &buf_size, data, (size_t)data_size) < 0) { H5MM_free(data); HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode dataset region information") } @@ -284,7 +274,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_expand_ref_region1() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_expand_ref_object2 * @@ -295,137 +284,135 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, - const void *buf_src, size_t nbytes_src, H5O_loc_t *dst_oloc, - H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, - H5O_copy_t *cpy_info) +H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, const void *buf_src, + size_t nbytes_src, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, void *buf_dst, + size_t ref_count, H5O_copy_t *cpy_info) { - H5T_t *dt_mem = NULL; /* Memory datatype */ - H5T_t *dt_dst = NULL; /* Destination datatype */ - hid_t tid_mem = H5I_INVALID_HID; /* Datatype ID for memory datatype */ - hid_t tid_dst = H5I_INVALID_HID; /* Datatype ID for memory datatype */ - H5T_path_t *tpath_src_mem = NULL, - *tpath_mem_dst = NULL; /* Datatype conversion paths */ - size_t i; /* Local index variable */ - hbool_t reg_tid_src = (tid_src == H5I_INVALID_HID); - hid_t dst_loc_id = H5I_INVALID_HID; - void *conv_buf = NULL; /* Buffer for converting data */ - size_t conv_buf_size = 0; /* Buffer size */ - void *reclaim_buf = NULL; /* Buffer for reclaiming data */ - H5S_t *buf_space = NULL; /* Dataspace describing buffer */ - hsize_t buf_dim[1] = {ref_count}; /* Dimension for buffer */ - size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file); - herr_t ret_value = SUCCEED; + H5T_t * dt_mem = NULL; /* Memory datatype */ + H5T_t * dt_dst = NULL; /* Destination datatype */ + hid_t tid_mem = H5I_INVALID_HID; /* Datatype ID for memory datatype */ + hid_t tid_dst = H5I_INVALID_HID; /* Datatype ID for memory datatype */ + H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ + size_t i; /* Local index variable */ + hbool_t reg_tid_src = (tid_src == H5I_INVALID_HID); + hid_t dst_loc_id = H5I_INVALID_HID; + void * conv_buf = NULL; /* Buffer for converting data */ + size_t conv_buf_size = 0; /* Buffer size */ + void * reclaim_buf = NULL; /* Buffer for reclaiming data */ + H5S_t * buf_space = NULL; /* Dataspace describing buffer */ + hsize_t buf_dim[1] = {ref_count}; /* Dimension for buffer */ + size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file); + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Create datatype ID for src datatype. */ - if((tid_src == H5I_INVALID_HID) && (tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) + if ((tid_src == H5I_INVALID_HID) && (tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") /* create a memory copy of the reference datatype */ - if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { (void)H5T_close_real(dt_mem); HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ /* create reference datatype at the destinaton file */ - if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy") - if(H5T_set_loc(dt_dst, H5F_VOL_OBJ(dst_oloc->file), H5T_LOC_DISK) < 0) { + if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(dst_oloc->file), H5T_LOC_DISK) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ - if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { + if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype") } /* end if */ /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) + if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes") - /* Use extra conversion buffer (TODO we should avoid using an extra buffer once the H5Ocopy code has been reworked) */ + /* Use extra conversion buffer (TODO we should avoid using an extra buffer once the H5Ocopy code has been + * reworked) */ conv_buf_size = MAX(H5T_get_size(dt_src), H5T_get_size(dt_mem)) * ref_count; - if(NULL == (conv_buf = H5FL_BLK_MALLOC(type_conv, conv_buf_size))) + if (NULL == (conv_buf = H5FL_BLK_MALLOC(type_conv, conv_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") H5MM_memcpy(conv_buf, buf_src, nbytes_src); /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, ref_count, (size_t)0, (size_t)0, conv_buf, NULL) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, ref_count, (size_t)0, (size_t)0, conv_buf, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, FAIL, "datatype conversion failed") /* Retrieve loc ID */ - if((dst_loc_id = H5F_get_id(dst_oloc->file)) < 0) + if ((dst_loc_id = H5F_get_id(dst_oloc->file)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Making equivalent references in the destination file */ - for(i = 0; i < ref_count; i++) { - H5R_ref_t *ref_ptr = (H5R_ref_t *)conv_buf; - H5R_ref_priv_t *ref = (H5R_ref_priv_t *)&ref_ptr[i]; - H5O_token_t tmp_token = { 0 }; + for (i = 0; i < ref_count; i++) { + H5R_ref_t * ref_ptr = (H5R_ref_t *)conv_buf; + H5R_ref_priv_t *ref = (H5R_ref_priv_t *)&ref_ptr[i]; + H5O_token_t tmp_token = {0}; /* Get src object address */ - if(H5R__get_obj_token(ref, &tmp_token, &token_size) < 0) + if (H5R__get_obj_token(ref, &tmp_token, &token_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object token") - if(H5VL_native_token_to_addr(src_oloc->file, H5I_FILE, tmp_token, &src_oloc->addr) < 0) + if (H5VL_native_token_to_addr(src_oloc->file, H5I_FILE, tmp_token, &src_oloc->addr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") /* Attempt to copy object from source to destination file */ - if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) + if (H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Set dst object address */ - if(H5VL_native_addr_to_token(dst_oloc->file, H5I_FILE, dst_oloc->addr, &tmp_token) < 0) + if (H5VL_native_addr_to_token(dst_oloc->file, H5I_FILE, dst_oloc->addr, &tmp_token) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") - if(H5R__set_obj_token(ref, (const H5O_token_t *)&tmp_token, token_size) < 0) + if (H5R__set_obj_token(ref, (const H5O_token_t *)&tmp_token, token_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set object token") /* Do not set app_ref since references are released once the copy is done */ - if(H5R__set_loc_id(ref, dst_loc_id, TRUE, FALSE) < 0) + if (H5R__set_loc_id(ref, dst_loc_id, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set destination loc id") } /* end for */ /* Copy into another buffer, to reclaim memory later */ - if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, conv_buf_size))) + if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, conv_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") H5MM_memcpy(reclaim_buf, conv_buf, conv_buf_size); - if(NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL))) + if (NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, ref_count, (size_t)0, (size_t)0, conv_buf, NULL) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, ref_count, (size_t)0, (size_t)0, conv_buf, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, FAIL, "datatype conversion failed") H5MM_memcpy(buf_dst, conv_buf, nbytes_src); /* Reclaim space from reference data */ - if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "unable to reclaim reference data") done: - if(buf_space && (H5S_close(buf_space) < 0)) + if (buf_space && (H5S_close(buf_space) < 0)) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't close dataspace") /* Don't decrement ID, we want to keep underlying datatype */ - if(reg_tid_src && (tid_src > 0) && (NULL == H5I_remove(tid_src))) + if (reg_tid_src && (tid_src > 0) && (NULL == H5I_remove(tid_src))) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if((tid_mem > 0) && H5I_dec_ref(tid_mem) < 0) + if ((tid_mem > 0) && H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if((tid_dst > 0) && H5I_dec_ref(tid_dst) < 0) + if ((tid_dst > 0) && H5I_dec_ref(tid_dst) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(reclaim_buf) + if (reclaim_buf) reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf); - if(conv_buf) + if (conv_buf) conv_buf = H5FL_BLK_FREE(type_conv, conv_buf); - if((dst_loc_id != H5I_INVALID_HID) && (H5I_dec_ref(dst_loc_id) < 0)) + if ((dst_loc_id != H5I_INVALID_HID) && (H5I_dec_ref(dst_loc_id) < 0)) HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_expand_ref_object2() */ - /*------------------------------------------------------------------------- * Function: H5O_copy_expand_ref * @@ -436,15 +423,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, - void *buf_src, size_t nbytes_src, H5F_t *file_dst, void *buf_dst, - H5O_copy_t *cpy_info) +H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, void *buf_src, size_t nbytes_src, + H5F_t *file_dst, void *buf_dst, H5O_copy_t *cpy_info) { - H5O_loc_t dst_oloc; /* Copied object object location */ - H5O_loc_t src_oloc; /* Temporary object location for source object */ - H5G_loc_t dst_root_loc; /* The location of root group of the destination file */ - size_t ref_count; - herr_t ret_value = SUCCEED; + H5O_loc_t dst_oloc; /* Copied object object location */ + H5O_loc_t src_oloc; /* Temporary object location for source object */ + H5G_loc_t dst_root_loc; /* The location of root group of the destination file */ + size_t ref_count; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -463,35 +449,38 @@ H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, dst_oloc.file = file_dst; /* Set up the root group in the destination file */ - if(NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(file_dst)))) + if (NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(file_dst)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(file_dst)))) + if (NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(file_dst)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Determine # of reference elements to copy */ ref_count = nbytes_src / H5T_get_size(dt_src); /* Copy object references */ - switch(H5T_get_ref_type(dt_src)) { + switch (H5T_get_ref_type(dt_src)) { case H5R_OBJECT1: - if(H5O__copy_expand_ref_object1(&src_oloc, buf_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, cpy_info) < 0) + if (H5O__copy_expand_ref_object1(&src_oloc, buf_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, + cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand H5R_OBJECT1 reference") break; case H5R_DATASET_REGION1: - if(H5O__copy_expand_ref_region1(&src_oloc, buf_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, cpy_info) < 0) + if (H5O__copy_expand_ref_region1(&src_oloc, buf_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, + cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand H5R_DATASET_REGION1 reference") break; case H5R_DATASET_REGION2: case H5R_ATTR: case H5R_OBJECT2: - if(H5O__copy_expand_ref_object2(&src_oloc, tid_src, dt_src, buf_src, nbytes_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, cpy_info) < 0) + if (H5O__copy_expand_ref_object2(&src_oloc, tid_src, dt_src, buf_src, nbytes_src, &dst_oloc, + &dst_root_loc, buf_dst, ref_count, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand reference") break; case H5R_BADTYPE: case H5R_MAXTYPE: default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - break; + break; } /* end switch */ done: diff --git a/src/H5Odbg.c b/src/H5Odbg.c index 3c91cae..17a5917 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -26,55 +26,47 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Ppublic.h" /* Property Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Ppublic.h" /* Property Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifdef H5O_DEBUG - + /*------------------------------------------------------------------------- * Function: H5O__assert * @@ -92,25 +84,25 @@ herr_t H5O__assert(const H5O_t *oh) { - H5O_mesg_t *curr_msg; /* Pointer to current message to examine */ - H5O_mesg_t *tmp_msg; /* Pointer to temporary message to examine */ - unsigned cont_msgs_found = 0; /* # of continuation messages for object */ - size_t meta_space; /* Size of header metadata */ - size_t mesg_space; /* Size of message raw data */ - size_t free_space; /* Size of free space in header */ - size_t hdr_size; /* Size of header's chunks */ - unsigned u, v; /* Local index variables */ + H5O_mesg_t *curr_msg; /* Pointer to current message to examine */ + H5O_mesg_t *tmp_msg; /* Pointer to temporary message to examine */ + unsigned cont_msgs_found = 0; /* # of continuation messages for object */ + size_t meta_space; /* Size of header metadata */ + size_t mesg_space; /* Size of message raw data */ + size_t free_space; /* Size of free space in header */ + size_t hdr_size; /* Size of header's chunks */ + unsigned u, v; /* Local index variables */ FUNC_ENTER_PACKAGE_NOERR /* Initialize the tracking variables */ - hdr_size = 0; + hdr_size = 0; meta_space = (size_t)H5O_SIZEOF_HDR(oh) + (size_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); mesg_space = 0; free_space = 0; /* Loop over all chunks in object header */ - for(u = 0; u < oh->nchunks; u++) { + for (u = 0; u < oh->nchunks; u++) { /* Accumulate the size of the header on header */ hdr_size += oh->chunk[u].size; @@ -125,9 +117,10 @@ H5O__assert(const H5O_t *oh) HDassert(H5F_addr_defined(oh->chunk[u].addr)); /* Version specific checks */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Make certain that the magic number is correct for each chunk */ - HDassert(!HDmemcmp(oh->chunk[u].image, (u == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5_SIZEOF_MAGIC)); + HDassert( + !HDmemcmp(oh->chunk[u].image, (u == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5_SIZEOF_MAGIC)); /* Check for valid gap size */ HDassert(oh->chunk[u].gap < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); @@ -138,33 +131,33 @@ H5O__assert(const H5O_t *oh) } /* end for */ /* Check for correct chunk #0 size flags */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { uint64_t chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); - if(chunk0_size <= 255) + if (chunk0_size <= 255) HDassert((oh->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_1); - else if(chunk0_size <= 65535) + else if (chunk0_size <= 65535) HDassert((oh->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_2); - else if(chunk0_size <= 4294967295) + else if (chunk0_size <= 4294967295) HDassert((oh->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_4); else HDassert((oh->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_8); } /* end if */ /* Loop over all messages in object header */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { uint8_t H5_ATTR_NDEBUG_UNUSED *curr_hdr; /* Start of current message header */ - size_t curr_tot_size; /* Total size of current message (including header) */ + size_t curr_tot_size; /* Total size of current message (including header) */ - curr_hdr = curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); + curr_hdr = curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); curr_tot_size = curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Accumulate information, based on the type of message */ - if(H5O_NULL_ID == curr_msg->type->id) + if (H5O_NULL_ID == curr_msg->type->id) free_space += curr_tot_size; - else if(H5O_CONT_ID == curr_msg->type->id) { - H5O_cont_t *cont = (H5O_cont_t *)curr_msg->native; - hbool_t H5_ATTR_NDEBUG_UNUSED found_chunk = FALSE; /* Found a chunk that matches */ + else if (H5O_CONT_ID == curr_msg->type->id) { + H5O_cont_t * cont = (H5O_cont_t *)curr_msg->native; + hbool_t H5_ATTR_NDEBUG_UNUSED found_chunk = FALSE; /* Found a chunk that matches */ HDassert(cont); @@ -173,13 +166,13 @@ H5O__assert(const H5O_t *oh) /* Sanity check that every continuation message has a matching chunk */ /* (and only one) */ - for(v = 0; v < oh->nchunks; v++) { - if(H5F_addr_eq(cont->addr, oh->chunk[v].addr) && cont->size == oh->chunk[v].size) { + for (v = 0; v < oh->nchunks; v++) { + if (H5F_addr_eq(cont->addr, oh->chunk[v].addr) && cont->size == oh->chunk[v].size) { HDassert(cont->chunkno == v); HDassert(!found_chunk); found_chunk = TRUE; } /* end if */ - } /* end for */ + } /* end for */ HDassert(found_chunk); meta_space += curr_tot_size; @@ -196,25 +189,29 @@ H5O__assert(const H5O_t *oh) HDassert(curr_msg->chunkno < oh->nchunks); /* Make certain null messages aren't in chunks with gaps */ - if(H5O_NULL_ID == curr_msg->type->id) + if (H5O_NULL_ID == curr_msg->type->id) HDassert(oh->chunk[curr_msg->chunkno].gap == 0); /* Make certain that the message is completely in a chunk message area */ - HDassert(curr_tot_size <= (oh->chunk[curr_msg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[curr_msg->chunkno].gap)); - if(curr_msg->chunkno == 0) - HDassert(curr_hdr >= oh->chunk[curr_msg->chunkno].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); + HDassert(curr_tot_size <= (oh->chunk[curr_msg->chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[curr_msg->chunkno].gap)); + if (curr_msg->chunkno == 0) + HDassert(curr_hdr >= + oh->chunk[curr_msg->chunkno].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); else - HDassert(curr_hdr >= oh->chunk[curr_msg->chunkno].image + (H5O_SIZEOF_CHKHDR_OH(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); - HDassert(curr_msg->raw + curr_msg->raw_size <= (oh->chunk[curr_msg->chunkno].image + oh->chunk[curr_msg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[curr_msg->chunkno].gap)); + HDassert(curr_hdr >= oh->chunk[curr_msg->chunkno].image + + (H5O_SIZEOF_CHKHDR_OH(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); + HDassert(curr_msg->raw + curr_msg->raw_size <= + (oh->chunk[curr_msg->chunkno].image + oh->chunk[curr_msg->chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[curr_msg->chunkno].gap)); /* Make certain that no other messages overlap this message */ - for(v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { - if(u != v) - HDassert(!((tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) >= curr_hdr - && (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) - < (curr_hdr + curr_tot_size))); + for (v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { + if (u != v) + HDassert(!((tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) >= curr_hdr && + (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) < (curr_hdr + curr_tot_size))); } /* end for */ - } /* end for */ + } /* end for */ /* Sanity check that the # of cont. messages is correct for the # of chunks */ HDassert(oh->nchunks == (cont_msgs_found + 1)); @@ -226,7 +223,6 @@ H5O__assert(const H5O_t *oh) } /* end H5O__assert() */ #endif /* H5O_DEBUG */ - /*------------------------------------------------------------------------- * Function: H5O_debug_id * @@ -244,14 +240,14 @@ H5O__assert(const H5O_t *oh) herr_t H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidth) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = FAIL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->debug); HDassert(f); @@ -261,14 +257,13 @@ H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int ind HDassert(fwidth >= 0); /* Call the debug method in the class */ - if((ret_value = (type->debug)(f, mesg, stream, indent, fwidth)) < 0) + if ((ret_value = (type->debug)(f, mesg, stream, indent, fwidth)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "unable to debug message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_debug_id() */ - /*------------------------------------------------------------------------- * Function: H5O__debug_real * @@ -285,10 +280,10 @@ done: herr_t H5O__debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth) { - size_t mesg_total = 0, chunk_total = 0, gap_total = 0; - unsigned *sequence = NULL; - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; + size_t mesg_total = 0, chunk_total = 0, gap_total = 0; + unsigned *sequence = NULL; + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -303,93 +298,71 @@ H5O__debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int /* debug */ HDfprintf(stream, "%*sObject Header...\n", indent, ""); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Dirty:", - oh->cache_info.is_dirty); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Version:", - oh->version); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Header size (in bytes):", - (unsigned)H5O_SIZEOF_HDR(oh)); + HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, "Dirty:", oh->cache_info.is_dirty); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", oh->version); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of links:", - oh->nlink); + "Header size (in bytes):", (unsigned)H5O_SIZEOF_HDR(oh)); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of links:", oh->nlink); /* Extra information for later versions */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Display object's status flags */ + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Attribute creation order tracked:", + (oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) ? "Yes" : "No"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Attribute creation order indexed:", + (oh->flags & H5O_HDR_ATTR_CRT_ORDER_INDEXED) ? "Yes" : "No"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Attribute storage phase change values:", + (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? "Non-default" : "Default"); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Attribute creation order tracked:", - (oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) ? "Yes" : "No"); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Attribute creation order indexed:", - (oh->flags & H5O_HDR_ATTR_CRT_ORDER_INDEXED) ? "Yes" : "No"); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Attribute storage phase change values:", - (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? "Non-default" : "Default"); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Timestamps:", - (oh->flags & H5O_HDR_STORE_TIMES) ? "Enabled" : "Disabled"); - if(oh->flags & ~H5O_HDR_ALL_FLAGS) - HDfprintf(stream, "*** UNKNOWN OBJECT HEADER STATUS FLAG: %02x!\n", - (unsigned)oh->flags); + "Timestamps:", (oh->flags & H5O_HDR_STORE_TIMES) ? "Enabled" : "Disabled"); + if (oh->flags & ~H5O_HDR_ALL_FLAGS) + HDfprintf(stream, "*** UNKNOWN OBJECT HEADER STATUS FLAG: %02x!\n", (unsigned)oh->flags); /* Only dump times, if they are tracked */ - if(oh->flags & H5O_HDR_STORE_TIMES) { - struct tm *tm; /* Time structure */ - char buf[128]; /* Buffer for formatting time info */ + if (oh->flags & H5O_HDR_STORE_TIMES) { + struct tm *tm; /* Time structure */ + char buf[128]; /* Buffer for formatting time info */ /* Time fields */ tm = HDlocaltime(&oh->atime); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Access Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Access Time:", buf); tm = HDlocaltime(&oh->mtime); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Modification Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Modification Time:", buf); tm = HDlocaltime(&oh->ctime); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Change Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Change Time:", buf); tm = HDlocaltime(&oh->btime); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Birth Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Birth Time:", buf); } /* end if */ /* Attribute tracking fields */ - if(oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { + if (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. compact attributes:", - (unsigned)oh->max_compact); + "Max. compact attributes:", (unsigned)oh->max_compact); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. dense attributes:", - (unsigned)oh->min_dense); + "Min. dense attributes:", (unsigned)oh->min_dense); } /* end if */ - } /* end if */ + } /* end if */ HDfprintf(stream, "%*s%-*s %Zu (%Zu)\n", indent, "", fwidth, - "Number of messages (allocated):", - oh->nmesgs, oh->alloc_nmesgs); - HDfprintf(stream, "%*s%-*s %Zu (%Zu)\n", indent, "", fwidth, - "Number of chunks (allocated):", - oh->nchunks, oh->alloc_nchunks); + "Number of messages (allocated):", oh->nmesgs, oh->alloc_nmesgs); + HDfprintf(stream, "%*s%-*s %Zu (%Zu)\n", indent, "", fwidth, "Number of chunks (allocated):", oh->nchunks, + oh->alloc_nchunks); /* debug each chunk */ - for(i = 0, chunk_total = 0; i < oh->nchunks; i++) { + for (i = 0, chunk_total = 0; i < oh->nchunks; i++) { size_t chunk_size; HDfprintf(stream, "%*sChunk %d...\n", indent, "", i); - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), - "Address:", - oh->chunk[i].addr); + HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "Address:", oh->chunk[i].addr); /* Decrement chunk 0's size by the object header prefix size */ - if(0 == i) { - if(H5F_addr_ne(oh->chunk[i].addr, addr)) + if (0 == i) { + if (H5F_addr_ne(oh->chunk[i].addr, addr)) HDfprintf(stream, "*** WRONG ADDRESS FOR CHUNK #0!\n"); chunk_size = oh->chunk[i].size - (size_t)H5O_SIZEOF_HDR(oh); } /* end if */ @@ -400,142 +373,130 @@ H5O__debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int chunk_total += chunk_size; gap_total += oh->chunk[i].gap; - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Size in bytes:", - chunk_size); + HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), "Size in bytes:", chunk_size); - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Gap:", - oh->chunk[i].gap); + HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), "Gap:", oh->chunk[i].gap); } /* end for */ /* debug each message */ - if(NULL == (sequence = (unsigned *)H5MM_calloc(NELMTS(H5O_msg_class_g) * sizeof(unsigned)))) + if (NULL == (sequence = (unsigned *)H5MM_calloc(NELMTS(H5O_msg_class_g) * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for(i = 0, mesg_total = 0; i < oh->nmesgs; i++) { - const H5O_msg_class_t *debug_type; /* Type of message to use for callbacks */ - unsigned chunkno; /* Chunk for message */ + for (i = 0, mesg_total = 0; i < oh->nmesgs; i++) { + const H5O_msg_class_t *debug_type; /* Type of message to use for callbacks */ + unsigned chunkno; /* Chunk for message */ /* Accumulate message's size to total */ mesg_total += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[i].raw_size; /* For version 2 object header, add size of "OCHK" for continuation chunk */ - if(oh->mesg[i].type->id == H5O_CONT_ID) + if (oh->mesg[i].type->id == H5O_CONT_ID) mesg_total += H5O_SIZEOF_CHKHDR_OH(oh); HDfprintf(stream, "%*sMessage %d...\n", indent, "", i); /* check for bad message id */ - if(oh->mesg[i].type->id >= (int)NELMTS(H5O_msg_class_g)) { + if (oh->mesg[i].type->id >= (int)NELMTS(H5O_msg_class_g)) { HDfprintf(stream, "*** BAD MESSAGE ID 0x%04x\n", oh->mesg[i].type->id); continue; } /* end if */ /* message name and size */ - HDfprintf(stream, "%*s%-*s 0x%04x `%s' (%d)\n", - indent + 3, "", MAX(0, fwidth - 3), - "Message ID (sequence number):", - (unsigned) (oh->mesg[i].type->id), - oh->mesg[i].type->name, - sequence[oh->mesg[i].type->id]++); - HDfprintf(stream, "%*s%-*s %t\n", indent + 3, "", MAX (0, fwidth - 3), - "Dirty:", - oh->mesg[i].dirty); - HDfprintf(stream, "%*s%-*s ", indent + 3, "", MAX (0, fwidth - 3), - "Message flags:"); - if(oh->mesg[i].flags) { + HDfprintf(stream, "%*s%-*s 0x%04x `%s' (%d)\n", indent + 3, "", MAX(0, fwidth - 3), + "Message ID (sequence number):", (unsigned)(oh->mesg[i].type->id), oh->mesg[i].type->name, + sequence[oh->mesg[i].type->id]++); + HDfprintf(stream, "%*s%-*s %t\n", indent + 3, "", MAX(0, fwidth - 3), "Dirty:", oh->mesg[i].dirty); + HDfprintf(stream, "%*s%-*s ", indent + 3, "", MAX(0, fwidth - 3), "Message flags:"); + if (oh->mesg[i].flags) { hbool_t flag_printed = FALSE; /* Sanity check that all flags in format are covered below */ - HDcompile_assert(H5O_MSG_FLAG_BITS == (H5O_MSG_FLAG_CONSTANT|H5O_MSG_FLAG_SHARED|H5O_MSG_FLAG_DONTSHARE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE|H5O_MSG_FLAG_MARK_IF_UNKNOWN|H5O_MSG_FLAG_WAS_UNKNOWN|H5O_MSG_FLAG_SHAREABLE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)); + HDcompile_assert(H5O_MSG_FLAG_BITS == + (H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_SHARED | H5O_MSG_FLAG_DONTSHARE | + H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE | H5O_MSG_FLAG_MARK_IF_UNKNOWN | + H5O_MSG_FLAG_WAS_UNKNOWN | H5O_MSG_FLAG_SHAREABLE | + H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)); - if(oh->mesg[i].flags & H5O_MSG_FLAG_CONSTANT) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_CONSTANT) { HDfprintf(stream, "%sC", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) { HDfprintf(stream, "%sS", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_DONTSHARE) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_DONTSHARE) { HDfprintf(stream, "%sDS", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE) { HDfprintf(stream, "%sFIUW", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) { HDfprintf(stream, "%sMIU", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_WAS_UNKNOWN) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_WAS_UNKNOWN) { HDassert(oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN); HDfprintf(stream, "%sWU", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_SHAREABLE) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_SHAREABLE) { HDfprintf(stream, "%sSA", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) { HDfprintf(stream, "%sFIUA", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(!flag_printed) + if (!flag_printed) HDfprintf(stream, "-"); HDfprintf(stream, ">\n"); - if(oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS) - HDfprintf(stream, "%*s%-*s 0x%02x\n", indent + 3,"", MAX(0, fwidth - 3), - "*** ADDITIONAL UNKNOWN FLAGS --->", - oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS); + if (oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS) + HDfprintf(stream, "%*s%-*s 0x%02x\n", indent + 3, "", MAX(0, fwidth - 3), + "*** ADDITIONAL UNKNOWN FLAGS --->", oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS); } /* end if */ else HDfprintf(stream, "\n"); HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", MAX(0, fwidth - 3), - "Chunk number:", - oh->mesg[i].chunkno); + "Chunk number:", oh->mesg[i].chunkno); chunkno = oh->mesg[i].chunkno; - if(chunkno >= oh->nchunks) + if (chunkno >= oh->nchunks) HDfprintf(stream, "*** BAD CHUNK NUMBER\n"); HDfprintf(stream, "%*s%-*s (%Zu, %Zu) bytes\n", indent + 3, "", MAX(0, fwidth - 3), - "Raw message data (offset, size) in chunk:", - (size_t)(oh->mesg[i].raw - oh->chunk[chunkno].image), - oh->mesg[i].raw_size); + "Raw message data (offset, size) in chunk:", + (size_t)(oh->mesg[i].raw - oh->chunk[chunkno].image), oh->mesg[i].raw_size); /* check the size */ - if((oh->mesg[i].raw + oh->mesg[i].raw_size > - oh->chunk[chunkno].image + oh->chunk[chunkno].size) || - (oh->mesg[i].raw < oh->chunk[chunkno].image)) + if ((oh->mesg[i].raw + oh->mesg[i].raw_size > oh->chunk[chunkno].image + oh->chunk[chunkno].size) || + (oh->mesg[i].raw < oh->chunk[chunkno].image)) HDfprintf(stream, "*** BAD MESSAGE RAW ADDRESS\n"); /* decode the message */ debug_type = oh->mesg[i].type; - if(NULL == oh->mesg[i].native && debug_type->decode) + if (NULL == oh->mesg[i].native && debug_type->decode) H5O_LOAD_NATIVE(f, H5O_DECODEIO_NOCHANGE, oh, &oh->mesg[i], FAIL) /* print the message */ - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - "Message Information:"); - if(debug_type->debug && oh->mesg[i].native != NULL) + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Message Information:"); + if (debug_type->debug && oh->mesg[i].native != NULL) (debug_type->debug)(f, oh->mesg[i].native, stream, indent + 6, MAX(0, fwidth - 6)); else HDfprintf(stream, "%*s\n", indent + 6, ""); } /* end for */ - if((mesg_total + gap_total) != chunk_total) + if ((mesg_total + gap_total) != chunk_total) HDfprintf(stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n"); done: /* Release resources */ - if(sequence) + if (sequence) sequence = (unsigned *)H5MM_xfree(sequence); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__debug_real() */ - /*------------------------------------------------------------------------- * Function: H5O_debug * @@ -552,9 +513,9 @@ done: herr_t H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) { - H5O_t *oh = NULL; /* Object header to display */ - H5O_loc_t loc; /* Object location for object to delete */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header to display */ + H5O_loc_t loc; /* Object location for object to delete */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -566,21 +527,20 @@ H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) HDassert(fwidth >= 0); /* Set up the object location */ - loc.file = f; - loc.addr = addr; + loc.file = f; + loc.addr = addr; loc.holding_file = FALSE; - if(NULL == (oh = H5O_protect(&loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(&loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* debug */ - if(H5O__debug_real(f, oh, addr, stream, indent, fwidth) < 0) + if (H5O__debug_real(f, oh, addr, stream, indent, fwidth) < 0) HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "debug dump call failed") done: - if(oh && H5O_unprotect(&loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_debug() */ - diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index aca0d59..c355cae 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -25,17 +25,16 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -45,47 +44,41 @@ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Adapter for using deprecated H5Ovisit1 callbacks with the VOL */ typedef struct H5O_visit1_adapter_t { - H5O_iterate1_t real_op; /* Application callback to invoke */ - unsigned fields; /* Original fields passed to H5Ovisit */ - void *real_op_data; /* Application op_data */ + H5O_iterate1_t real_op; /* Application callback to invoke */ + unsigned fields; /* Original fields passed to H5Ovisit */ + void * real_op_data; /* Application op_data */ } H5O_visit1_adapter_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5O__reset_info1(H5O_info1_t *oinfo); static herr_t H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, void *op_data); -static herr_t H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, - H5O_info1_t *oinfo, unsigned fields); +static herr_t H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, H5O_info1_t *oinfo, + unsigned fields); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5O__reset_info1 * @@ -108,7 +101,6 @@ H5O__reset_info1(H5O_info1_t *oinfo) FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5O__reset_info1() */ - /*------------------------------------------------------------------------- * Function: H5O__iterate1_adapter * @@ -124,16 +116,15 @@ H5O__reset_info1(H5O_info1_t *oinfo) *------------------------------------------------------------------------- */ static herr_t -H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, - void *op_data) +H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, void *op_data) { H5O_visit1_adapter_t *shim_data = (H5O_visit1_adapter_t *)op_data; - H5O_info1_t oinfo; /* Deprecated object info struct */ - unsigned dm_fields; /* Fields for data model query */ - unsigned nat_fields; /* Fields for native query */ - H5VL_object_t *vol_obj; /* Object of obj_id */ - H5VL_loc_params_t loc_params; /* Location parameters for VOL callback */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_info1_t oinfo; /* Deprecated object info struct */ + unsigned dm_fields; /* Fields for data model query */ + unsigned nat_fields; /* Fields for native query */ + H5VL_object_t * vol_obj; /* Object of obj_id */ + H5VL_loc_params_t loc_params; /* Location parameters for VOL callback */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -142,29 +133,30 @@ H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, HDassert(op_data); /* Reset the legacy info struct */ - if(H5O__reset_info1(&oinfo) < 0) + if (H5O__reset_info1(&oinfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") /* Check for retrieving data model information */ dm_fields = shim_data->fields & (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS); - if(dm_fields) { + if (dm_fields) { /* Set the data model fields */ - if(shim_data->fields & H5O_INFO_BASIC) { - oinfo.fileno = oinfo2->fileno; - oinfo.type = oinfo2->type; - oinfo.rc = oinfo2->rc; + if (shim_data->fields & H5O_INFO_BASIC) { + oinfo.fileno = oinfo2->fileno; + oinfo.type = oinfo2->type; + oinfo.rc = oinfo2->rc; /* Deserialize VOL object token into object address */ - if(H5VLnative_token_to_addr(obj_id, oinfo2->token, &oinfo.addr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + if (H5VLnative_token_to_addr(obj_id, oinfo2->token, &oinfo.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") } - if(shim_data->fields & H5O_INFO_TIME) { - oinfo.atime = oinfo2->atime; - oinfo.mtime = oinfo2->mtime; - oinfo.ctime = oinfo2->ctime; - oinfo.btime = oinfo2->btime; + if (shim_data->fields & H5O_INFO_TIME) { + oinfo.atime = oinfo2->atime; + oinfo.mtime = oinfo2->mtime; + oinfo.ctime = oinfo2->ctime; + oinfo.btime = oinfo2->btime; } - if(shim_data->fields & H5O_INFO_NUM_ATTRS) + if (shim_data->fields & H5O_INFO_NUM_ATTRS) oinfo.num_attrs = oinfo2->num_attrs; } @@ -175,23 +167,24 @@ H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, loc_params.obj_type = H5I_get_type(obj_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") /* Check for retrieving native information */ nat_fields = shim_data->fields & (H5O_INFO_HDR | H5O_INFO_META_SIZE); - if(nat_fields) { - H5O_native_info_t nat_info; /* Native object info */ + if (nat_fields) { + H5O_native_info_t nat_info; /* Native object info */ /* Retrieve the object's native information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, &nat_info, nat_fields) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, &nat_info, nat_fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native info for object") /* Set the native fields */ - if(shim_data->fields & H5O_INFO_HDR) + if (shim_data->fields & H5O_INFO_HDR) H5MM_memcpy(&(oinfo.hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); - if(shim_data->fields & H5O_INFO_META_SIZE) { - H5MM_memcpy(&(oinfo.meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); + if (shim_data->fields & H5O_INFO_META_SIZE) { + H5MM_memcpy(&(oinfo.meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); H5MM_memcpy(&(oinfo.meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); } } @@ -203,7 +196,6 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O__iterate1_adapter() */ - /*------------------------------------------------------------------------- * Function: H5O__get_info_old * @@ -217,12 +209,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, - H5O_info1_t *oinfo, unsigned fields) +H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, H5O_info1_t *oinfo, unsigned fields) { - unsigned dm_fields; /* Fields for data model query */ - unsigned nat_fields; /* Fields for native query */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned dm_fields; /* Fields for data model query */ + unsigned nat_fields; /* Fields for native query */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -231,66 +222,69 @@ H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, HDassert(loc_params); /* Reset the passed-in info struct */ - if(H5O__reset_info1(oinfo) < 0) + if (H5O__reset_info1(oinfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") /* Check for retrieving data model information */ dm_fields = fields & (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS); - if(dm_fields) { - H5O_info2_t dm_info; /* Data model object info */ + if (dm_fields) { + H5O_info2_t dm_info; /* Data model object info */ /* Retrieve the object's data model information */ - if(H5VL_object_get(vol_obj, loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &dm_info, dm_fields) < 0) + if (H5VL_object_get(vol_obj, loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &dm_info, dm_fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") /* Set the data model fields */ - if(fields & H5O_INFO_BASIC) { + if (fields & H5O_INFO_BASIC) { void *vol_obj_data; - if(NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + if (NULL == (vol_obj_data = H5VL_object_data(vol_obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") oinfo->fileno = dm_info.fileno; - oinfo->type = dm_info.type; - oinfo->rc = dm_info.rc; + oinfo->type = dm_info.type; + oinfo->rc = dm_info.rc; /* Deserialize VOL object token into object address */ - if(H5VL_native_token_to_addr(vol_obj_data, loc_params->obj_type, dm_info.token, &oinfo->addr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + if (H5VL_native_token_to_addr(vol_obj_data, loc_params->obj_type, dm_info.token, &oinfo->addr) < + 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") } /* end if */ - if(fields & H5O_INFO_TIME) { + if (fields & H5O_INFO_TIME) { oinfo->atime = dm_info.atime; oinfo->mtime = dm_info.mtime; oinfo->ctime = dm_info.ctime; oinfo->btime = dm_info.btime; } /* end if */ - if(fields & H5O_INFO_NUM_ATTRS) + if (fields & H5O_INFO_NUM_ATTRS) oinfo->num_attrs = dm_info.num_attrs; } /* end if */ /* Check for retrieving native information */ nat_fields = fields & (H5O_INFO_HDR | H5O_INFO_META_SIZE); - if(nat_fields) { - H5O_native_info_t nat_info; /* Native object info */ + if (nat_fields) { + H5O_native_info_t nat_info; /* Native object info */ /* Retrieve the object's native information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, &nat_info, nat_fields) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, loc_params, &nat_info, nat_fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native info for object") /* Set the native fields */ - if(fields & H5O_INFO_HDR) + if (fields & H5O_INFO_HDR) H5MM_memcpy(&(oinfo->hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); - if(fields & H5O_INFO_META_SIZE) { - H5MM_memcpy(&(oinfo->meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); + if (fields & H5O_INFO_META_SIZE) { + H5MM_memcpy(&(oinfo->meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); H5MM_memcpy(&(oinfo->meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__get_info_old() */ - /*------------------------------------------------------------------------- * Function: H5Oopen_by_addr * @@ -329,54 +323,57 @@ done: hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - H5I_type_t opened_type; /* Opened object type */ - void *opened_obj = NULL; /* Opened object */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - hbool_t is_native_vol_obj; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5I_type_t opened_type; /* Opened object type */ + void * opened_obj = NULL; /* Opened object */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + hbool_t is_native_vol_obj; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "ia", loc_id, addr); /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get object type */ - if((vol_obj_type = H5I_get_type(loc_id)) < 0) + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") - if(is_native_vol_obj) { + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (is_native_vol_obj) { /* This is a native-specific routine that requires serialization of the token */ - if(H5VLnative_addr_to_token(loc_id, addr, &obj_token) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, H5I_INVALID_HID, "can't serialize address into object token") + if (H5VLnative_addr_to_token(loc_id, addr, &obj_token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, H5I_INVALID_HID, + "can't serialize address into object token") } /* end if */ else - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Oopen_by_addr is only meant to be used with the native VOL connector") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Oopen_by_addr is only meant to be used with the native VOL connector") - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = vol_obj_type; + loc_params.obj_type = vol_obj_type; /* Open the object */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") /* Register the object's ID */ - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_addr() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info1 * @@ -390,34 +387,33 @@ done: herr_t H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", loc_id, oinfo); /* Check args */ - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info1() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info_by_name1 * @@ -431,23 +427,23 @@ done: herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t *oinfo, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill out location struct */ @@ -457,18 +453,17 @@ H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t *oinfo, hid_t l loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_name1() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info_by_idx1 * @@ -484,52 +479,51 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, hid_t lapl_id) +H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5O_info1_t *oinfo, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIoh*xi", loc_id, group_name, idx_type, order, n, oinfo, lapl_id); /* Check args */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx1() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info2 * @@ -547,43 +541,44 @@ done: herr_t H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - hbool_t is_native_vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); /* Check args */ - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Set location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Oget_info2 is only meant to be used with the native VOL connector") + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Oget_info2 is only meant to be used with the native VOL connector") /* Retrieve deprecated info struct */ - if(H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info2() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info_by_name2 * @@ -599,29 +594,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo, - unsigned fields, hid_t lapl_id) +H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - hbool_t is_native_vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill out location struct */ @@ -631,24 +625,25 @@ H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo, loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Oget_info_by_name2 is only meant to be used with the native VOL connector") + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Oget_info_by_name2 is only meant to be used with the native VOL connector") /* Retrieve deprecated info struct */ - if(H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_name2() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info_by_idx2 * @@ -666,61 +661,62 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, unsigned fields, hid_t lapl_id) +H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5O_info1_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - hbool_t is_native_vol_obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, fields, lapl_id); /* Check args */ - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_IDX; - loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; loc_params.loc_data.loc_by_idx.idx_type = idx_type; - loc_params.loc_data.loc_by_idx.order = order; - loc_params.loc_data.loc_by_idx.n = n; - loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Oget_info_by_idx2 is only meant to be used with the native VOL connector") + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Oget_info_by_idx2 is only meant to be used with the native VOL connector") /* Retrieve deprecated info struct */ - if(H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx2() */ - /*------------------------------------------------------------------------- * Function: H5Ovisit1 * @@ -754,47 +750,47 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate1_t op, void *op_data) +H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIox*x", obj_id, idx_type, order, op, op_data); /* Check args */ - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(obj_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); /* Set up adapter */ - shim_data.real_op = op; - shim_data.fields = H5O_INFO_ALL; + shim_data.real_op = op; + shim_data.fields = H5O_INFO_ALL; shim_data.real_op_data = op_data; /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, (void *)&shim_data, H5O_INFO_ALL)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, + (void *)&shim_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Ovisit1() */ - /*------------------------------------------------------------------------- * Function: H5Ovisit_by_name1 * @@ -828,36 +824,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate1_t op, void *op_data, hid_t lapl_id) +H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; - H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sIiIox*xi", loc_id, obj_name, idx_type, order, op, op_data, lapl_id); /* Check args */ - if(!obj_name) + if (!obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") - if(!*obj_name) + if (!*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location parameters */ @@ -867,19 +863,20 @@ H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Set up adapter */ - shim_data.real_op = op; - shim_data.fields = H5O_INFO_ALL; + shim_data.real_op = op; + shim_data.fields = H5O_INFO_ALL; shim_data.real_op_data = op_data; /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, (void *)&shim_data, H5O_INFO_ALL)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, + (void *)&shim_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Ovisit_by_name1() */ - /*------------------------------------------------------------------------- * Function: H5Ovisit2 * @@ -916,57 +913,59 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate1_t op, void *op_data, unsigned fields) +H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data, + unsigned fields) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIox*xIu", obj_id, idx_type, order, op, op_data, fields); /* Check args */ - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Ovisit2 is only meant to be used with the native VOL connector") + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Ovisit2 is only meant to be used with the native VOL connector") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(obj_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); /* Set up adapter */ - shim_data.real_op = op; - shim_data.fields = fields; + shim_data.real_op = op; + shim_data.fields = fields; shim_data.real_op_data = op_data; /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, (void *)&shim_data, fields)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, + (void *)&shim_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Ovisit2() */ - /*------------------------------------------------------------------------- * Function: H5Ovisit_by_name2 * @@ -1003,46 +1002,48 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate1_t op, void *op_data, unsigned fields, hid_t lapl_id) +H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate1_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_object_t * vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ hbool_t is_native_vol_obj; - herr_t ret_value; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIox*xIui", loc_id, obj_name, idx_type, order, op, op_data, fields, lapl_id); /* Check args */ - if(!obj_name) + if (!obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") - if(!*obj_name) + if (!*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") - if(!is_native_vol_obj) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Ovisit_by_name2 is only meant to be used with the native VOL connector") + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Ovisit_by_name2 is only meant to be used with the native VOL connector") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_NAME; @@ -1051,13 +1052,14 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Set up adapter */ - shim_data.real_op = op; - shim_data.fields = fields; + shim_data.real_op = op; + shim_data.fields = fields; shim_data.real_op_data = op_data; /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, (void *)&shim_data, fields)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, + (void *)&shim_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -1065,4 +1067,3 @@ done: } /* end H5Ovisit_by_name2() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Odrvinfo.c b/src/H5Odrvinfo.c index eb678e4..ac72b5f 100644 --- a/src/H5Odrvinfo.c +++ b/src/H5Odrvinfo.c @@ -11,7 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* Programmer: Quincey Koziol * Thursday, March 1, 2007 * @@ -19,51 +18,48 @@ * in the superblock extension. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object headers */ +#include "H5MMprivate.h" /* Memory management */ -static void *H5O_drvinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O_drvinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_drvinfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_drvinfo_copy(const void *_mesg, void *_dest); +static void * H5O_drvinfo_copy(const void *_mesg, void *_dest); static size_t H5O_drvinfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__drvinfo_reset(void *_mesg); -static herr_t H5O__drvinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__drvinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_DRVINFO[1] = {{ - H5O_DRVINFO_ID, /*message id number */ - "driver info", /*message name for debugging */ - sizeof(H5O_drvinfo_t), /*native message size */ - 0, /* messages are sharable? */ - H5O_drvinfo_decode, /*decode message */ - H5O_drvinfo_encode, /*encode message */ - H5O_drvinfo_copy, /*copy the native value */ - H5O_drvinfo_size, /*raw message size */ - H5O__drvinfo_reset, /*free internal memory */ - NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__drvinfo_debug /*debug the message */ + H5O_DRVINFO_ID, /*message id number */ + "driver info", /*message name for debugging */ + sizeof(H5O_drvinfo_t), /*native message size */ + 0, /* messages are sharable? */ + H5O_drvinfo_decode, /*decode message */ + H5O_drvinfo_encode, /*encode message */ + H5O_drvinfo_copy, /*copy the native value */ + H5O_drvinfo_size, /*raw message size */ + H5O__drvinfo_reset, /*free internal memory */ + NULL, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__drvinfo_debug /*debug the message */ }}; /* Current version of driver info information */ -#define H5O_DRVINFO_VERSION 0 +#define H5O_DRVINFO_VERSION 0 - /*------------------------------------------------------------------------- * Function: H5O_drvinfo_decode * @@ -79,12 +75,11 @@ const H5O_msg_class_t H5O_MSG_DRVINFO[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_drvinfo_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_drvinfo_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -93,12 +88,12 @@ H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_DRVINFO_VERSION) + if (*p++ != H5O_DRVINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (mesg = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info message") + if (NULL == (mesg = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info message") /* Retrieve driver name */ H5MM_memcpy(mesg->name, p, 8); @@ -110,9 +105,9 @@ H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(mesg->len); /* Allocate space for buffer */ - if(NULL == (mesg->buf = (uint8_t *)H5MM_malloc(mesg->len))) { + if (NULL == (mesg->buf = (uint8_t *)H5MM_malloc(mesg->len))) { mesg = (H5O_drvinfo_t *)H5MM_xfree(mesg); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info buffer") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info buffer") } /* end if */ /* Copy encoded driver info into buffer */ @@ -125,7 +120,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_drvinfo_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_drvinfo_encode * @@ -139,7 +133,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O_drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; @@ -161,7 +156,6 @@ H5O_drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_share FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_drvinfo_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_drvinfo_copy * @@ -179,26 +173,27 @@ H5O_drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_share static void * H5O_drvinfo_copy(const void *_mesg, void *_dest) { - const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; - H5O_drvinfo_t *dest = (H5O_drvinfo_t *)_dest; - void *ret_value = NULL; /* Return value */ + const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; + H5O_drvinfo_t * dest = (H5O_drvinfo_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity check */ HDassert(mesg); - if(!dest && NULL == (dest = (H5O_drvinfo_t *)H5MM_malloc(sizeof(H5O_drvinfo_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message") + if (!dest && NULL == (dest = (H5O_drvinfo_t *)H5MM_malloc(sizeof(H5O_drvinfo_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for shared message table message") /* Shallow copy the fields */ *dest = *mesg; /* Copy the buffer */ - if(NULL == (dest->buf = (uint8_t *)H5MM_malloc(mesg->len))) { - if(dest != _dest) + if (NULL == (dest->buf = (uint8_t *)H5MM_malloc(mesg->len))) { + if (dest != _dest) dest = (H5O_drvinfo_t *)H5MM_xfree(dest); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ H5MM_memcpy(dest->buf, mesg->buf, mesg->len); @@ -209,7 +204,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_drvinfo_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_drvinfo_size * @@ -227,8 +221,8 @@ done: static size_t H5O_drvinfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -236,15 +230,14 @@ H5O_drvinfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_s HDassert(f); HDassert(mesg); - ret_value = 1 + /* Version number */ - 8 + /* Driver name */ - 2 + /* Buffer length */ - mesg->len; /* Buffer */ + ret_value = 1 + /* Version number */ + 8 + /* Driver name */ + 2 + /* Buffer length */ + mesg->len; /* Buffer */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_drvinfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__drvinfo_reset * @@ -262,7 +255,7 @@ H5O_drvinfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_s static herr_t H5O__drvinfo_reset(void *_mesg) { - H5O_drvinfo_t *mesg = (H5O_drvinfo_t *) _mesg; + H5O_drvinfo_t *mesg = (H5O_drvinfo_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -275,7 +268,6 @@ H5O__drvinfo_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__drvinfo_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__drvinfo_debug * @@ -289,8 +281,7 @@ H5O__drvinfo_reset(void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__drvinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__drvinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; @@ -303,12 +294,8 @@ H5O__drvinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Driver name:", mesg->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Buffer size:", mesg->len); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Driver name:", mesg->name); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Buffer size:", mesg->len); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__drvinfo_debug() */ - - diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 6eaaae9..a3c3a29 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -11,108 +11,103 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5T_FRIEND /*prevent warning from including H5Tpkg */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5T_FRIEND /*prevent warning from including H5Tpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VMprivate.h" /* Vectors and arrays */ /* PRIVATE PROTOTYPES */ static herr_t H5O_dtype_encode(H5F_t *f, uint8_t *p, const void *mesg); -static void *H5O_dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void *H5O_dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); static void *H5O_dtype_copy(const void *_mesg, void *_dest); static size_t H5O_dtype_size(const H5F_t *f, const void *_mesg); static herr_t H5O__dtype_reset(void *_mesg); static herr_t H5O__dtype_free(void *_mesg); static herr_t H5O_dtype_set_share(void *_mesg, const H5O_shared_t *sh); static htri_t H5O_dtype_can_share(const void *_mesg); -static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata); -static void *H5O__dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, - void *native_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__dtype_shared_post_copy_upd(const H5O_loc_t *src_oloc, - const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, - H5O_copy_t *cpy_info); -static herr_t H5O__dtype_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *_udata); +static void * H5O__dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, void *native_src, + H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, + void *udata); +static herr_t H5O__dtype_shared_post_copy_upd(const H5O_loc_t *src_oloc, const void *mesg_src, + H5O_loc_t *dst_oloc, void *mesg_dst, H5O_copy_t *cpy_info); +static herr_t H5O__dtype_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_DTYPE -#define H5O_SHARED_DECODE H5O_dtype_shared_decode -#define H5O_SHARED_DECODE_REAL H5O_dtype_decode -#define H5O_SHARED_ENCODE H5O_dtype_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_dtype_encode -#define H5O_SHARED_SIZE H5O_dtype_shared_size -#define H5O_SHARED_SIZE_REAL H5O_dtype_size -#define H5O_SHARED_DELETE H5O__dtype_shared_delete +#define H5O_SHARED_TYPE H5O_MSG_DTYPE +#define H5O_SHARED_DECODE H5O_dtype_shared_decode +#define H5O_SHARED_DECODE_REAL H5O_dtype_decode +#define H5O_SHARED_ENCODE H5O_dtype_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O_dtype_encode +#define H5O_SHARED_SIZE H5O_dtype_shared_size +#define H5O_SHARED_SIZE_REAL H5O_dtype_size +#define H5O_SHARED_DELETE H5O__dtype_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O__dtype_shared_link +#define H5O_SHARED_LINK H5O__dtype_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O__dtype_shared_copy_file -#define H5O_SHARED_COPY_FILE_REAL H5O__dtype_copy_file -#define H5O_SHARED_POST_COPY_FILE H5O_dtype_shared_post_copy_file -#undef H5O_SHARED_POST_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE_UPD H5O__dtype_shared_post_copy_upd -#define H5O_SHARED_DEBUG H5O_dtype_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__dtype_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#define H5O_SHARED_COPY_FILE H5O__dtype_shared_copy_file +#define H5O_SHARED_COPY_FILE_REAL H5O__dtype_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O_dtype_shared_post_copy_file +#undef H5O_SHARED_POST_COPY_FILE_REAL +#define H5O_SHARED_POST_COPY_FILE_UPD H5O__dtype_shared_post_copy_upd +#define H5O_SHARED_DEBUG H5O_dtype_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__dtype_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* Macros to check for the proper version of a datatype */ #ifdef H5_STRICT_FORMAT_CHECKS /* If the version is too low, give an error. No error if nochange is set * because in that case we are either debugging or deleting the object header */ -#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \ - if(((VERS) < (MIN_VERS)) && !(*(IOF) & H5O_DECODEIO_NOCHANGE)) \ +#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \ + if (((VERS) < (MIN_VERS)) && !(*(IOF)&H5O_DECODEIO_NOCHANGE)) \ HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, ERR, "incorrect " CLASS " datatype version") #else /* H5_STRICT_FORMAT_CHECKS */ /* If the version is too low and we are allowed to change the message, upgrade * it and mark the object header as dirty */ -#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \ - if(((VERS) < (MIN_VERS)) && !(*(IOF) & H5O_DECODEIO_NOCHANGE)) { \ - (VERS) = (MIN_VERS); \ - if(H5T__upgrade_version((DT), (VERS)) < 0) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade " CLASS " encoding version") \ - *(IOF) |= H5O_DECODEIO_DIRTY; \ - } /* end if */ +#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \ + if (((VERS) < (MIN_VERS)) && !(*(IOF)&H5O_DECODEIO_NOCHANGE)) { \ + (VERS) = (MIN_VERS); \ + if (H5T__upgrade_version((DT), (VERS)) < 0) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade " CLASS " encoding version") \ + *(IOF) |= H5O_DECODEIO_DIRTY; \ + } /* end if */ #endif /* H5_STRICT_FORMAT_CHECKS */ /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ - H5O_DTYPE_ID, /* message id number */ - "datatype", /* message name for debugging */ - sizeof(H5T_t), /* native message size */ - H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */ - H5O_dtype_shared_decode, /* decode message */ - H5O_dtype_shared_encode, /* encode message */ - H5O_dtype_copy, /* copy the native value */ - H5O_dtype_shared_size, /* size of raw message */ - H5O__dtype_reset, /* reset method */ - H5O__dtype_free, /* free method */ - H5O__dtype_shared_delete, /* file delete method */ - H5O__dtype_shared_link, /* link method */ - H5O_dtype_set_share, /* set share method */ - H5O_dtype_can_share, /* can share method */ - H5O_dtype_pre_copy_file, /* pre copy native value to file */ - H5O__dtype_shared_copy_file, /* copy native value to file */ - H5O_dtype_shared_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_dtype_shared_debug /* debug the message */ + H5O_DTYPE_ID, /* message id number */ + "datatype", /* message name for debugging */ + sizeof(H5T_t), /* native message size */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_dtype_shared_decode, /* decode message */ + H5O_dtype_shared_encode, /* encode message */ + H5O_dtype_copy, /* copy the native value */ + H5O_dtype_shared_size, /* size of raw message */ + H5O__dtype_reset, /* reset method */ + H5O__dtype_free, /* free method */ + H5O__dtype_shared_delete, /* file delete method */ + H5O__dtype_shared_link, /* link method */ + H5O_dtype_set_share, /* set share method */ + H5O_dtype_can_share, /* can share method */ + H5O_dtype_pre_copy_file, /* pre copy native value to file */ + H5O__dtype_shared_copy_file, /* copy native value to file */ + H5O_dtype_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O_dtype_shared_debug /* debug the message */ }}; - /*------------------------------------------------------------------------- * Function: H5O_dtype_decode_helper * @@ -129,12 +124,12 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ *------------------------------------------------------------------------- */ static htri_t -H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t *dt) +H5O_dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t *dt) { - unsigned flags, version; - unsigned i; - size_t z; - htri_t ret_value = FALSE; /* Return value */ + unsigned flags, version; + unsigned i; + size_t z; + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -144,24 +139,24 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * /* Version, class & flags */ UINT32DECODE(*pp, flags); - version = (flags>>4) & 0x0f; - if(version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_LATEST) + version = (flags >> 4) & 0x0f; + if (version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_LATEST) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for datatype message") dt->shared->version = version; - dt->shared->type = (H5T_class_t)(flags & 0x0f); + dt->shared->type = (H5T_class_t)(flags & 0x0f); flags >>= 8; /* Size */ UINT32DECODE(*pp, dt->shared->size); - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_INTEGER: /* * Integer types... */ - dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE; UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); @@ -172,19 +167,19 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * * Floating-point types... */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - if(version >= H5O_DTYPE_VERSION_3) { + if (version >= H5O_DTYPE_VERSION_3) { /* Unsupported byte order*/ - if((flags & 0x40) && !(flags & 0x1)) + if ((flags & 0x40) && !(flags & 0x1)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bad byte order for datatype message") /* VAX order if both 1st and 6th bits are turned on*/ - if(flags & 0x40) + if (flags & 0x40) dt->shared->u.atomic.order = H5T_ORDER_VAX; } /* end if */ dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO; - switch((flags >> 4) & 0x03) { + switch ((flags >> 4) & 0x03) { case 0: dt->shared->u.atomic.u.f.norm = H5T_NORM_NONE; break; @@ -203,16 +198,16 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * dt->shared->u.atomic.u.f.sign = (flags >> 8) & 0xff; UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); - dt->shared->u.atomic.u.f.epos = *(*pp)++; + dt->shared->u.atomic.u.f.epos = *(*pp)++; dt->shared->u.atomic.u.f.esize = *(*pp)++; HDassert(dt->shared->u.atomic.u.f.esize > 0); - dt->shared->u.atomic.u.f.mpos = *(*pp)++; + dt->shared->u.atomic.u.f.mpos = *(*pp)++; dt->shared->u.atomic.u.f.msize = *(*pp)++; HDassert(dt->shared->u.atomic.u.f.msize > 0); UINT32DECODE(*pp, dt->shared->u.atomic.u.f.ebias); break; - case H5T_TIME: /* Time datatypes */ + case H5T_TIME: /* Time datatypes */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; @@ -221,13 +216,13 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * /* * Character string types... */ - dt->shared->u.atomic.order = H5T_ORDER_NONE; - dt->shared->u.atomic.prec = 8 * dt->shared->size; - dt->shared->u.atomic.offset = 0; + dt->shared->u.atomic.order = H5T_ORDER_NONE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + dt->shared->u.atomic.offset = 0; dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; - dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); + dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); dt->shared->u.atomic.u.s.cset = (H5T_cset_t)((flags >> 4) & 0x0f); break; @@ -235,7 +230,7 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * /* * Bit fields... */ - dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; UINT16DECODE(*pp, dt->shared->u.atomic.offset); @@ -248,209 +243,214 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * */ z = flags & (H5T_OPAQUE_TAG_MAX - 1); HDassert(0 == (z & 0x7)); /*must be aligned*/ - if(NULL == (dt->shared->u.opaque.tag = (char *)H5MM_malloc(z + 1))) + if (NULL == (dt->shared->u.opaque.tag = (char *)H5MM_malloc(z + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") H5MM_memcpy(dt->shared->u.opaque.tag, *pp, z); dt->shared->u.opaque.tag[z] = '\0'; *pp += z; break; - case H5T_COMPOUND: - { - unsigned offset_nbytes; /* Size needed to encode member offsets */ - size_t max_memb_pos = 0; /* Maximum member covered, so far */ - unsigned max_version = 0; /* Maximum member version */ - unsigned upgrade_to = 0; /* Version number we can "soft" upgrade to */ - unsigned j; + case H5T_COMPOUND: { + unsigned offset_nbytes; /* Size needed to encode member offsets */ + size_t max_memb_pos = 0; /* Maximum member covered, so far */ + unsigned max_version = 0; /* Maximum member version */ + unsigned upgrade_to = 0; /* Version number we can "soft" upgrade to */ + unsigned j; - /* Compute the # of bytes required to store a member offset */ - offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); + /* Compute the # of bytes required to store a member offset */ + offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); - /* - * Compound datatypes... - */ - dt->shared->u.compnd.nmembs = flags & 0xffff; - if(dt->shared->u.compnd.nmembs == 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid number of members: %u", dt->shared->u.compnd.nmembs) - dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs; - dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_calloc(dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)); - dt->shared->u.compnd.memb_size = 0; - if(NULL == dt->shared->u.compnd.memb) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - unsigned ndims = 0; /* Number of dimensions of the array field */ - htri_t can_upgrade; /* Whether we can upgrade this type's version */ - hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */ - H5T_t *array_dt; /* Temporary pointer to the array datatype */ - H5T_t *temp_type; /* Temporary pointer to the field's datatype */ - - /* Decode the field name */ - dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); - - /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */ - if(version >= H5O_DTYPE_VERSION_3) - /* Advance past name, including null terminator */ - *pp += HDstrlen((const char *)*pp) + 1; - else - /* Advance multiple of 8 w/ null terminator */ - *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; + /* + * Compound datatypes... + */ + dt->shared->u.compnd.nmembs = flags & 0xffff; + if (dt->shared->u.compnd.nmembs == 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid number of members: %u", + dt->shared->u.compnd.nmembs) + dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs; + dt->shared->u.compnd.memb = + (H5T_cmemb_t *)H5MM_calloc(dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)); + dt->shared->u.compnd.memb_size = 0; + if (NULL == dt->shared->u.compnd.memb) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + unsigned ndims = 0; /* Number of dimensions of the array field */ + htri_t can_upgrade; /* Whether we can upgrade this type's version */ + hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */ + H5T_t * array_dt; /* Temporary pointer to the array datatype */ + H5T_t * temp_type; /* Temporary pointer to the field's datatype */ + + /* Decode the field name */ + dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); - /* Decode the field offset */ - /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ - if(version >= H5O_DTYPE_VERSION_3) - UINT32DECODE_VAR(*pp, dt->shared->u.compnd.memb[i].offset, offset_nbytes) - else - UINT32DECODE(*pp, dt->shared->u.compnd.memb[i].offset) - - /* Older versions of the library allowed a field to have - * intrinsic 'arrayness'. Newer versions of the library - * use the separate array datatypes. */ - if(version == H5O_DTYPE_VERSION_1) { - /* Decode the number of dimensions */ - ndims = *(*pp)++; - - /* Check that ndims is valid */ - if(ndims > 4) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array") - - *pp += 3; /*reserved bytes */ - - /* Skip dimension permutation */ - *pp += 4; - - /* Skip reserved bytes */ - *pp += 4; - - /* Decode array dimension sizes */ - for(j = 0; j < 4; j++) - UINT32DECODE(*pp, dim[j]); - } /* end if */ - - /* Allocate space for the field's datatype */ - if(NULL == (temp_type = H5T__alloc())) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Decode the field's datatype information */ - if((can_upgrade = H5O_dtype_decode_helper(ioflags, pp, temp_type)) < 0) { - for(j = 0; j <= i; j++) - H5MM_xfree(dt->shared->u.compnd.memb[j].name); - H5MM_xfree(dt->shared->u.compnd.memb); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type") - } /* end if */ - - /* Upgrade the version if we can and it is necessary */ - if(can_upgrade && temp_type->shared->version > version) { - upgrade_to = temp_type->shared->version; - - /* Pass "can_upgrade" flag down to parent type */ - ret_value = TRUE; - } /* end if */ - - /* Go create the array datatype now, for older versions of the datatype message */ - if(version == H5O_DTYPE_VERSION_1) { - /* Check if this member is an array field */ - if(ndims > 0) { - /* Create the array datatype for the field */ - if((array_dt = H5T__array_create(temp_type, ndims, dim)) == NULL) { - for(j = 0; j <= i; j++) - H5MM_xfree(dt->shared->u.compnd.memb[j].name); - H5MM_xfree(dt->shared->u.compnd.memb); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype") - } /* end if */ - - /* Close the base type for the array */ - (void)H5T_close_real(temp_type); - - /* Make the array type the type that is set for the field */ - temp_type = array_dt; - - /* Reset array version if NOCHANGE is specified (i.e. h5debug) */ - if(*ioflags & H5O_DECODEIO_NOCHANGE) - temp_type->shared->version = H5O_DTYPE_VERSION_1; - else { - /* Otherwise upgrade the compound version */ - if(upgrade_to < temp_type->shared->version) - upgrade_to = temp_type->shared->version; - - /* Set the return value to indicate that we should freely - * upgrade parent types */ - ret_value = TRUE; - } /* end else */ + /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */ + if (version >= H5O_DTYPE_VERSION_3) + /* Advance past name, including null terminator */ + *pp += HDstrlen((const char *)*pp) + 1; + else + /* Advance multiple of 8 w/ null terminator */ + *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; + + /* Decode the field offset */ + /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ + if (version >= H5O_DTYPE_VERSION_3) + UINT32DECODE_VAR(*pp, dt->shared->u.compnd.memb[i].offset, offset_nbytes) + else + UINT32DECODE(*pp, dt->shared->u.compnd.memb[i].offset) + + /* Older versions of the library allowed a field to have + * intrinsic 'arrayness'. Newer versions of the library + * use the separate array datatypes. */ + if (version == H5O_DTYPE_VERSION_1) { + /* Decode the number of dimensions */ + ndims = *(*pp)++; + + /* Check that ndims is valid */ + if (ndims > 4) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array") + + *pp += 3; /*reserved bytes */ + + /* Skip dimension permutation */ + *pp += 4; + + /* Skip reserved bytes */ + *pp += 4; + + /* Decode array dimension sizes */ + for (j = 0; j < 4; j++) + UINT32DECODE(*pp, dim[j]); + } /* end if */ + + /* Allocate space for the field's datatype */ + if (NULL == (temp_type = H5T__alloc())) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Decode the field's datatype information */ + if ((can_upgrade = H5O_dtype_decode_helper(ioflags, pp, temp_type)) < 0) { + for (j = 0; j <= i; j++) + H5MM_xfree(dt->shared->u.compnd.memb[j].name); + H5MM_xfree(dt->shared->u.compnd.memb); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type") + } /* end if */ + + /* Upgrade the version if we can and it is necessary */ + if (can_upgrade && temp_type->shared->version > version) { + upgrade_to = temp_type->shared->version; + + /* Pass "can_upgrade" flag down to parent type */ + ret_value = TRUE; + } /* end if */ + + /* Go create the array datatype now, for older versions of the datatype message */ + if (version == H5O_DTYPE_VERSION_1) { + /* Check if this member is an array field */ + if (ndims > 0) { + /* Create the array datatype for the field */ + if ((array_dt = H5T__array_create(temp_type, ndims, dim)) == NULL) { + for (j = 0; j <= i; j++) + H5MM_xfree(dt->shared->u.compnd.memb[j].name); + H5MM_xfree(dt->shared->u.compnd.memb); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, + "unable to create array datatype") } /* end if */ - } /* end if */ - - /* Keep track of the maximum member version found */ - if(temp_type->shared->version > max_version) - max_version = temp_type->shared->version; - - /* - * Set the "force conversion" flag if VL datatype fields exist in this - * type or any component types - */ - if(temp_type->shared->force_conv == TRUE) - dt->shared->force_conv = TRUE; - - /* Member size */ - dt->shared->u.compnd.memb[i].size = temp_type->shared->size; - dt->shared->u.compnd.memb_size += temp_type->shared->size; - - /* Set the field datatype (finally :-) */ - dt->shared->u.compnd.memb[i].type = temp_type; - - /* Check if this field overlaps with a prior field */ - /* (probably indicates that the file is corrupt) */ - if(i > 0 && dt->shared->u.compnd.memb[i].offset < max_memb_pos) { - for(j = 0; j < i; j++) - if(dt->shared->u.compnd.memb[i].offset >= dt->shared->u.compnd.memb[j].offset - && dt->shared->u.compnd.memb[i].offset < (dt->shared->u.compnd.memb[j].offset + dt->shared->u.compnd.memb[j].size)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "member overlaps with previous member") - } /* end if */ - - /* Update the maximum member position covered */ - max_memb_pos = MAX(max_memb_pos, (dt->shared->u.compnd.memb[i].offset + dt->shared->u.compnd.memb[i].size)); - } /* end for */ - /* Check if the compound type is packed */ - H5T__update_packed(dt); - - /* Upgrade the compound if requested */ - if(version < upgrade_to) { - version = upgrade_to; - if(H5T__upgrade_version(dt, upgrade_to) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade compound encoding version") - /* We won't mark the message dirty since there were no - * errors in the file, simply type versions that we will no - * longer encode. */ + /* Close the base type for the array */ + (void)H5T_close_real(temp_type); + + /* Make the array type the type that is set for the field */ + temp_type = array_dt; + + /* Reset array version if NOCHANGE is specified (i.e. h5debug) */ + if (*ioflags & H5O_DECODEIO_NOCHANGE) + temp_type->shared->version = H5O_DTYPE_VERSION_1; + else { + /* Otherwise upgrade the compound version */ + if (upgrade_to < temp_type->shared->version) + upgrade_to = temp_type->shared->version; + + /* Set the return value to indicate that we should freely + * upgrade parent types */ + ret_value = TRUE; + } /* end else */ + } /* end if */ + } /* end if */ + + /* Keep track of the maximum member version found */ + if (temp_type->shared->version > max_version) + max_version = temp_type->shared->version; + + /* + * Set the "force conversion" flag if VL datatype fields exist in this + * type or any component types + */ + if (temp_type->shared->force_conv == TRUE) + dt->shared->force_conv = TRUE; + + /* Member size */ + dt->shared->u.compnd.memb[i].size = temp_type->shared->size; + dt->shared->u.compnd.memb_size += temp_type->shared->size; + + /* Set the field datatype (finally :-) */ + dt->shared->u.compnd.memb[i].type = temp_type; + + /* Check if this field overlaps with a prior field */ + /* (probably indicates that the file is corrupt) */ + if (i > 0 && dt->shared->u.compnd.memb[i].offset < max_memb_pos) { + for (j = 0; j < i; j++) + if (dt->shared->u.compnd.memb[i].offset >= dt->shared->u.compnd.memb[j].offset && + dt->shared->u.compnd.memb[i].offset < + (dt->shared->u.compnd.memb[j].offset + dt->shared->u.compnd.memb[j].size)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, + "member overlaps with previous member") } /* end if */ - /* Check that no member of this compound has a version greater - * than the compound itself. */ - H5O_DTYPE_CHECK_VERSION(dt, version, max_version, ioflags, "compound", FAIL) - } - break; + /* Update the maximum member position covered */ + max_memb_pos = MAX(max_memb_pos, + (dt->shared->u.compnd.memb[i].offset + dt->shared->u.compnd.memb[i].size)); + } /* end for */ + + /* Check if the compound type is packed */ + H5T__update_packed(dt); + + /* Upgrade the compound if requested */ + if (version < upgrade_to) { + version = upgrade_to; + if (H5T__upgrade_version(dt, upgrade_to) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade compound encoding version") + /* We won't mark the message dirty since there were no + * errors in the file, simply type versions that we will no + * longer encode. */ + } /* end if */ + + /* Check that no member of this compound has a version greater + * than the compound itself. */ + H5O_DTYPE_CHECK_VERSION(dt, version, max_version, ioflags, "compound", FAIL) + } break; case H5T_REFERENCE: /* Reference datatypes... */ - dt->shared->u.atomic.order = H5T_ORDER_NONE; - dt->shared->u.atomic.prec = 8 * dt->shared->size; - dt->shared->u.atomic.offset = 0; + dt->shared->u.atomic.order = H5T_ORDER_NONE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + dt->shared->u.atomic.offset = 0; dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; /* Set reference type */ dt->shared->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f); - if(dt->shared->u.atomic.u.r.rtype <= H5R_BADTYPE - || dt->shared->u.atomic.u.r.rtype >= H5R_MAXTYPE) + if (dt->shared->u.atomic.u.r.rtype <= H5R_BADTYPE || + dt->shared->u.atomic.u.r.rtype >= H5R_MAXTYPE) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "invalid reference type"); /* Set generic flag */ - if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT2 - || dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION2 - || dt->shared->u.atomic.u.r.rtype == H5R_ATTR) { - dt->shared->u.atomic.u.r.opaque = TRUE; + if (dt->shared->u.atomic.u.r.rtype == H5R_OBJECT2 || + dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION2 || + dt->shared->u.atomic.u.r.rtype == H5R_ATTR) { + dt->shared->u.atomic.u.r.opaque = TRUE; dt->shared->u.atomic.u.r.version = (unsigned)((flags >> 4) & 0x0f); - if(dt->shared->u.atomic.u.r.version != H5R_ENCODE_VERSION) + if (dt->shared->u.atomic.u.r.version != H5R_ENCODE_VERSION) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "reference version does not match"); - } else + } + else dt->shared->u.atomic.u.r.opaque = FALSE; /* This type needs conversion */ @@ -458,7 +458,7 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * /* Mark location of this type as undefined for now. The caller * function should decide the location. */ - if(H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") break; @@ -467,26 +467,27 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * * Enumeration datatypes... */ dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff; - if(NULL == (dt->shared->parent = H5T__alloc())) + if (NULL == (dt->shared->parent = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) + if (H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent datatype") /* Check if the parent of this enum has a version greater than the * enum itself. */ - H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, - ioflags, "enum", FAIL) + H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "enum", FAIL) - if(NULL == (dt->shared->u.enumer.name = (char **)H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char*))) || - NULL == (dt->shared->u.enumer.value = (uint8_t *)H5MM_calloc(dt->shared->u.enumer.nalloc * dt->shared->parent->shared->size))) + if (NULL == (dt->shared->u.enumer.name = + (char **)H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char *))) || + NULL == (dt->shared->u.enumer.value = (uint8_t *)H5MM_calloc( + dt->shared->u.enumer.nalloc * dt->shared->parent->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Names */ - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) { - dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp); + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { + dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char *)*pp); /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */ - if(version >= H5O_DTYPE_VERSION_3) + if (version >= H5O_DTYPE_VERSION_3) /* Advance past name, including null terminator */ *pp += HDstrlen((const char *)*pp) + 1; else @@ -496,79 +497,76 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * /* Values */ H5MM_memcpy(dt->shared->u.enumer.value, *pp, - dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); + dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); *pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; - case H5T_VLEN: /* Variable length datatypes... */ + case H5T_VLEN: /* Variable length datatypes... */ /* Set the type of VL information, either sequence or string */ dt->shared->u.vlen.type = (H5T_vlen_type_t)(flags & 0x0f); - if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { dt->shared->u.vlen.pad = (H5T_str_t)((flags >> 4) & 0x0f); dt->shared->u.vlen.cset = (H5T_cset_t)((flags >> 8) & 0x0f); } /* end if */ /* Decode base type of VL information */ - if(NULL == (dt->shared->parent = H5T__alloc())) + if (NULL == (dt->shared->parent = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) + if (H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type") /* Check if the parent of this vlen has a version greater than the * vlen itself. */ - H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, - ioflags, "vlen", FAIL) + H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "vlen", FAIL) - dt->shared->force_conv=TRUE; + dt->shared->force_conv = TRUE; /* Mark location this type as undefined for now. The caller function should * decide the location. */ - if(H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") break; - case H5T_ARRAY: /* Array datatypes */ + case H5T_ARRAY: /* Array datatypes */ /* Decode the number of dimensions */ dt->shared->u.array.ndims = *(*pp)++; /* Double-check the number of dimensions */ - if(dt->shared->u.array.ndims > H5S_MAX_RANK) + if (dt->shared->u.array.ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "too many dimensions for array datatype") /* Skip reserved bytes, if version has them */ - if(version < H5O_DTYPE_VERSION_3) + if (version < H5O_DTYPE_VERSION_3) *pp += 3; /* Decode array dimension sizes & compute number of elements */ - for(i = 0, dt->shared->u.array.nelem = 1; i < (unsigned)dt->shared->u.array.ndims; i++) { + for (i = 0, dt->shared->u.array.nelem = 1; i < (unsigned)dt->shared->u.array.ndims; i++) { UINT32DECODE(*pp, dt->shared->u.array.dim[i]); dt->shared->u.array.nelem *= dt->shared->u.array.dim[i]; } /* end for */ /* Skip array dimension permutations, if version has them */ - if(version < H5O_DTYPE_VERSION_3) + if (version < H5O_DTYPE_VERSION_3) *pp += dt->shared->u.array.ndims * 4; /* Decode base type of array */ - if(NULL == (dt->shared->parent = H5T__alloc())) + if (NULL == (dt->shared->parent = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) + if (H5O_dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode array parent type") /* Check if the parent of this array has a version greater than the * array itself. */ - H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, - ioflags, "array", FAIL) + H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "array", FAIL) /* There should be no array datatypes with version < 2. */ - H5O_DTYPE_CHECK_VERSION(dt, version, H5O_DTYPE_VERSION_2, ioflags, - "array", FAIL) + H5O_DTYPE_CHECK_VERSION(dt, version, H5O_DTYPE_VERSION_2, ioflags, "array", FAIL) /* * Set the "force conversion" flag if a VL base datatype is used or * or if any components of the base datatype are VL types. */ - if(dt->shared->parent->shared->force_conv == TRUE) + if (dt->shared->parent->shared->force_conv == TRUE) dt->shared->force_conv = TRUE; break; @@ -579,18 +577,17 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t * } /* end switch */ done: - if(ret_value < 0) { - if(dt != NULL) { - if(dt->shared != NULL) + if (ret_value < 0) { + if (dt != NULL) { + if (dt->shared != NULL) dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); dt = H5FL_FREE(H5T_t, dt); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_decode_helper() */ - /*------------------------------------------------------------------------- * Function: H5O_dtype_encode_helper * @@ -610,11 +607,11 @@ done: static herr_t H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) { - unsigned flags = 0; - uint8_t *hdr = (uint8_t *)*pp; - unsigned i; - size_t n, z; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned flags = 0; + uint8_t *hdr = (uint8_t *)*pp; + unsigned i; + size_t n, z; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -626,14 +623,14 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) *pp += 4; UINT32ENCODE(*pp, dt->shared->size); - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_INTEGER: /* * Integer datatypes... */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing */ + break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; @@ -644,12 +641,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_ORDER_MIXED: case H5T_ORDER_NONE: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; @@ -659,12 +657,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ERROR: case H5T_PAD_BACKGROUND: @@ -674,12 +673,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) break; default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: - break; /*nothing */ + break; /*nothing */ case H5T_SGN_2: flags |= 0x08; @@ -688,7 +688,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_SGN_ERROR: case H5T_NSGN: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "sign scheme is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "sign scheme is not supported in file format yet") } /* end switch */ UINT16ENCODE(*pp, dt->shared->u.atomic.offset); @@ -701,13 +702,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing*/ + break; /*nothing*/ case H5T_ORDER_BE: flags |= 0x01; break; - case H5T_ORDER_VAX: /*turn on 1st and 6th (reserved before adding VAX) bits*/ + case H5T_ORDER_VAX: /*turn on 1st and 6th (reserved before adding VAX) bits*/ flags |= 0x41; HDassert(dt->shared->version >= H5O_DTYPE_VERSION_3); break; @@ -716,12 +717,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; @@ -731,12 +733,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x04; @@ -746,12 +749,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.u.f.pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x08; @@ -761,12 +765,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_NONE: - break; /*nothing */ + break; /*nothing */ case H5T_NORM_MSBSET: flags |= 0x10; @@ -778,7 +783,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_NORM_ERROR: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "normalization scheme is not supported in file format yet") } /* end switch */ flags = (unsigned)(flags | ((dt->shared->u.atomic.u.f.sign << 8) & 0xff00)); @@ -795,10 +801,10 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) UINT32ENCODE(*pp, dt->shared->u.atomic.u.f.ebias); break; - case H5T_TIME: /* Time datatypes... */ + case H5T_TIME: /* Time datatypes... */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing */ + break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; @@ -809,7 +815,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet") } /* end switch */ UINT16ENCODE(*pp, dt->shared->u.atomic.prec); break; @@ -834,7 +841,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing */ + break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; @@ -845,12 +852,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; @@ -860,12 +868,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x04; @@ -875,7 +884,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ UINT16ENCODE(*pp, dt->shared->u.atomic.offset); @@ -889,94 +899,93 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) * null terminated). */ { - size_t aligned; + size_t aligned; - z = HDstrlen(dt->shared->u.opaque.tag); + z = HDstrlen(dt->shared->u.opaque.tag); aligned = (z + 7) & (H5T_OPAQUE_TAG_MAX - 8); - flags = (unsigned)(flags | aligned); - H5MM_memcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned)); - for(n = MIN(z, aligned); n < aligned; n++) + flags = (unsigned)(flags | aligned); + H5MM_memcpy(*pp, dt->shared->u.opaque.tag, MIN(z, aligned)); + for (n = MIN(z, aligned); n < aligned; n++) (*pp)[n] = 0; *pp += aligned; } break; - case H5T_COMPOUND: - { - unsigned offset_nbytes; /* Size needed to encode member offsets */ + case H5T_COMPOUND: { + unsigned offset_nbytes; /* Size needed to encode member offsets */ - /* Compute the # of bytes required to store a member offset */ - offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); + /* Compute the # of bytes required to store a member offset */ + offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); - /* - * Compound datatypes... + /* + * Compound datatypes... + */ + flags = dt->shared->u.compnd.nmembs & 0xffff; + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + /* Sanity check */ + /* (compound datatypes w/array members must be encoded w/version >= 2) */ + HDassert(dt->shared->u.compnd.memb[i].type->shared->type != H5T_ARRAY || + dt->shared->version >= H5O_DTYPE_VERSION_2); + + /* Check that the version is at least as great as the member */ + HDassert(dt->shared->version >= dt->shared->u.compnd.memb[i].type->shared->version); + + /* Name */ + HDstrcpy((char *)(*pp), dt->shared->u.compnd.memb[i].name); + + /* Version 3 of the datatype message removed the padding to multiple of 8 bytes */ + n = HDstrlen(dt->shared->u.compnd.memb[i].name); + if (dt->shared->version >= H5O_DTYPE_VERSION_3) + *pp += n + 1; + else { + /* Pad name to multiple of 8 bytes */ + for (z = n + 1; z % 8; z++) + (*pp)[z] = '\0'; + *pp += z; + } /* end if */ + + /* Member offset */ + /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ + if (dt->shared->version >= H5O_DTYPE_VERSION_3) + UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes) + else + UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset) + + /* If we don't have any array fields, write out the old style + * member information, for better backward compatibility + * Write out all zeros for the array information, though... */ - flags = dt->shared->u.compnd.nmembs & 0xffff; - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - /* Sanity check */ - /* (compound datatypes w/array members must be encoded w/version >= 2) */ - HDassert(dt->shared->u.compnd.memb[i].type->shared->type != H5T_ARRAY || dt->shared->version >= H5O_DTYPE_VERSION_2); - - /* Check that the version is at least as great as the member */ - HDassert(dt->shared->version >= dt->shared->u.compnd.memb[i].type->shared->version); - - /* Name */ - HDstrcpy((char*)(*pp), dt->shared->u.compnd.memb[i].name); - - /* Version 3 of the datatype message removed the padding to multiple of 8 bytes */ - n = HDstrlen(dt->shared->u.compnd.memb[i].name); - if(dt->shared->version >= H5O_DTYPE_VERSION_3) - *pp += n + 1; - else { - /* Pad name to multiple of 8 bytes */ - for(z = n + 1; z % 8; z++) - (*pp)[z] = '\0'; - *pp += z; - } /* end if */ - - /* Member offset */ - /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ - if(dt->shared->version >= H5O_DTYPE_VERSION_3) - UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes) - else - UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset) + if (dt->shared->version == H5O_DTYPE_VERSION_1) { + unsigned j; - /* If we don't have any array fields, write out the old style - * member information, for better backward compatibility - * Write out all zeros for the array information, though... - */ - if(dt->shared->version == H5O_DTYPE_VERSION_1) { - unsigned j; + /* Dimensionality */ + *(*pp)++ = 0; - /* Dimensionality */ - *(*pp)++ = 0; + /* Reserved */ + *(*pp)++ = 0; + *(*pp)++ = 0; + *(*pp)++ = 0; - /* Reserved */ - *(*pp)++ = 0; - *(*pp)++ = 0; - *(*pp)++ = 0; + /* Dimension permutation */ + UINT32ENCODE(*pp, 0); - /* Dimension permutation */ - UINT32ENCODE(*pp, 0); + /* Reserved */ + UINT32ENCODE(*pp, 0); - /* Reserved */ + /* Dimensions */ + for (j = 0; j < 4; j++) UINT32ENCODE(*pp, 0); + } /* end if */ - /* Dimensions */ - for(j = 0; j < 4; j++) - UINT32ENCODE(*pp, 0); - } /* end if */ - - /* Subtype */ - if(H5O_dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type") - } /* end for */ - } - break; + /* Subtype */ + if (H5O_dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type") + } /* end for */ + } break; case H5T_REFERENCE: flags |= (dt->shared->u.atomic.u.r.rtype & 0x0f); - if(dt->shared->u.atomic.u.r.opaque) + if (dt->shared->u.atomic.u.r.opaque) flags = (unsigned)(flags | (((unsigned)dt->shared->u.atomic.u.r.version & 0x0f) << 4)); break; @@ -990,47 +999,48 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) flags = dt->shared->u.enumer.nmembs & 0xffff; /* Parent type */ - if(H5O_dtype_encode_helper(pp, dt->shared->parent) < 0) + if (H5O_dtype_encode_helper(pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent datatype") /* Names, each a multiple of eight bytes */ - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) { + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { /* Name */ - HDstrcpy((char*)(*pp), dt->shared->u.enumer.name[i]); + HDstrcpy((char *)(*pp), dt->shared->u.enumer.name[i]); /* Version 3 of the datatype message removed the padding to multiple of 8 bytes */ n = HDstrlen(dt->shared->u.enumer.name[i]); - if(dt->shared->version >= H5O_DTYPE_VERSION_3) + if (dt->shared->version >= H5O_DTYPE_VERSION_3) *pp += n + 1; else { /* Pad to multiple of 8 bytes */ - for(z = n + 1; z % 8; z++) + for (z = n + 1; z % 8; z++) (*pp)[z] = '\0'; *pp += z; } /* end for */ - } /* end for */ + } /* end for */ /* Values */ - H5MM_memcpy(*pp, dt->shared->u.enumer.value, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); + H5MM_memcpy(*pp, dt->shared->u.enumer.value, + dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); *pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; - case H5T_VLEN: /* Variable length datatypes... */ + case H5T_VLEN: /* Variable length datatypes... */ /* Check that the version is at least as great as the parent */ HDassert(dt->shared->version >= dt->shared->parent->shared->version); flags |= (dt->shared->u.vlen.type & 0x0f); - if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { - flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.pad & 0x0f) << 4)); - flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8)); + if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { + flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.pad & 0x0f) << 4)); + flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8)); } /* end if */ /* Encode base type of VL information */ - if(H5O_dtype_encode_helper(pp, dt->shared->parent) < 0) + if (H5O_dtype_encode_helper(pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type") break; - case H5T_ARRAY: /* Array datatypes */ + case H5T_ARRAY: /* Array datatypes */ /* Double-check the number of dimensions */ HDassert(dt->shared->u.array.ndims <= H5S_MAX_RANK); @@ -1045,7 +1055,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) *(*pp)++ = (uint8_t)dt->shared->u.array.ndims; /* Drop this information for Version 3 of the format */ - if(dt->shared->version < H5O_DTYPE_VERSION_3) { + if (dt->shared->version < H5O_DTYPE_VERSION_3) { /* Reserved */ *(*pp)++ = '\0'; *(*pp)++ = '\0'; @@ -1053,18 +1063,18 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) } /* end if */ /* Encode array dimensions */ - for(i = 0; i < (unsigned)dt->shared->u.array.ndims; i++) + for (i = 0; i < (unsigned)dt->shared->u.array.ndims; i++) UINT32ENCODE(*pp, dt->shared->u.array.dim[i]); /* Drop this information for Version 3 of the format */ - if(dt->shared->version < H5O_DTYPE_VERSION_3) { + if (dt->shared->version < H5O_DTYPE_VERSION_3) { /* Encode 'fake' array dimension permutations */ - for(i = 0; i < (unsigned)dt->shared->u.array.ndims; i++) + for (i = 0; i < (unsigned)dt->shared->u.array.ndims; i++) UINT32ENCODE(*pp, i); } /* end if */ /* Encode base type of array's information */ - if(H5O_dtype_encode_helper(pp, dt->shared->parent) < 0) + if (H5O_dtype_encode_helper(pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type") break; @@ -1085,31 +1095,30 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_encode_helper() */ - /*-------------------------------------------------------------------------- NAME H5O_dtype_decode PURPOSE Decode a message and return a pointer to a memory struct - with the decoded information + with the decoded information USAGE void *H5O_dtype_decode(f, mesg_flags, p) - H5F_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct unsigned mesg_flags; IN: Message flags to influence decoding - const uint8 *p; IN: the raw information buffer + const uint8 *p; IN: the raw information buffer RETURNS Pointer to the new message in native order on success, NULL on failure DESCRIPTION - This function decodes the "raw" disk form of a simple datatype message + This function decodes the "raw" disk form of a simple datatype message into a struct in memory native format. The struct is allocated within this function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * H5O_dtype_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned *ioflags/*in,out*/, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned *ioflags /*in,out*/, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5T_t *dt = NULL; - void *ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1117,11 +1126,11 @@ H5O_dtype_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigne HDassert(p); /* Allocate datatype message */ - if(NULL == (dt = H5T__alloc())) + if (NULL == (dt = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Perform actual decode of message */ - if(H5O_dtype_decode_helper(ioflags, &p, dt) < 0) + if (H5O_dtype_decode_helper(ioflags, &p, dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type") /* Set return value */ @@ -1131,7 +1140,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_decode() */ - /*-------------------------------------------------------------------------- NAME H5O_dtype_encode @@ -1139,21 +1147,21 @@ done: Encode a simple datatype message USAGE herr_t H5O_dtype_encode(f, raw_size, p, mesg) - H5F_t *f; IN: pointer to the HDF5 file struct - size_t raw_size; IN: size of the raw information buffer - const uint8 *p; IN: the raw information buffer - const void *mesg; IN: Pointer to the simple datatype struct + H5F_t *f; IN: pointer to the HDF5 file struct + size_t raw_size; IN: size of the raw information buffer + const uint8 *p; IN: the raw information buffer + const void *mesg; IN: Pointer to the simple datatype struct RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function encodes the native memory form of the simple datatype + This function encodes the native memory form of the simple datatype message in the "raw" disk form. --------------------------------------------------------------------------*/ static herr_t H5O_dtype_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *mesg) { - const H5T_t *dt = (const H5T_t *) mesg; - herr_t ret_value = SUCCEED; /* Return value */ + const H5T_t *dt = (const H5T_t *)mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1163,14 +1171,13 @@ H5O_dtype_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *mesg) HDassert(dt); /* encode */ - if(H5O_dtype_encode_helper(&p, dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type") + if (H5O_dtype_encode_helper(&p, dt) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_encode() */ - /*-------------------------------------------------------------------------- NAME H5O_dtype_copy @@ -1178,22 +1185,22 @@ done: Copies a message from MESG to DEST, allocating DEST if necessary. USAGE void *H5O_dtype_copy(mesg, dest) - const void *mesg; IN: Pointer to the source simple datatype - struct - const void *dest; IN: Pointer to the destination simple - datatype struct + const void *mesg; IN: Pointer to the source simple datatype + struct + const void *dest; IN: Pointer to the destination simple + datatype struct RETURNS Pointer to DEST on success, NULL on failure DESCRIPTION - This function copies a native (memory) simple datatype message, + This function copies a native (memory) simple datatype message, allocating the destination structure if necessary. --------------------------------------------------------------------------*/ static void * H5O_dtype_copy(const void *_src, void *_dst) { - const H5T_t *src = (const H5T_t *) _src; - H5T_t *dst; - void *ret_value = NULL; /* Return value */ + const H5T_t *src = (const H5T_t *)_src; + H5T_t * dst; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1201,14 +1208,14 @@ H5O_dtype_copy(const void *_src, void *_dst) HDassert(src); /* Copy */ - if(NULL == (dst = H5T_copy(src, H5T_COPY_ALL))) + if (NULL == (dst = H5T_copy(src, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type") /* Was result already allocated? */ - if(_dst) { - *((H5T_t *) _dst) = *dst; - dst = H5FL_FREE(H5T_t, dst); - dst = (H5T_t *) _dst; + if (_dst) { + *((H5T_t *)_dst) = *dst; + dst = H5FL_FREE(H5T_t, dst); + dst = (H5T_t *)_dst; } /* end if */ /* Set return value */ @@ -1218,7 +1225,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_copy() */ - /*-------------------------------------------------------------------------- NAME H5O_dtype_size @@ -1226,21 +1232,21 @@ done: Return the raw message size in bytes USAGE void *H5O_dtype_size(f, mesg) - H5F_t *f; IN: pointer to the HDF5 file struct - const void *mesg; IN: Pointer to the source simple datatype struct + H5F_t *f; IN: pointer to the HDF5 file struct + const void *mesg; IN: Pointer to the source simple datatype struct RETURNS Size of message on success, 0 on failure DESCRIPTION - This function returns the size of the raw simple datatype message on + This function returns the size of the raw simple datatype message on success. (Not counting the message type or size fields, only the data portion of the message). It doesn't take into account alignment. --------------------------------------------------------------------------*/ static size_t H5O_dtype_size(const H5F_t *f, const void *_mesg) { - const H5T_t *dt = (const H5T_t *)_mesg; - unsigned u; /* Local index variable */ - size_t ret_value = 0; /* Return value */ + const H5T_t *dt = (const H5T_t *)_mesg; + unsigned u; /* Local index variable */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1248,11 +1254,11 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) HDassert(dt); /* Set the common size information */ - ret_value = 4 + /* Type, class & flags */ - 4; /* Size of datatype */ + ret_value = 4 + /* Type, class & flags */ + 4; /* Size of datatype */ /* Add in the property field length for each datatype class */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_INTEGER: ret_value += 4; break; @@ -1273,54 +1279,52 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) ret_value += (HDstrlen(dt->shared->u.opaque.tag) + 7) & (H5T_OPAQUE_TAG_MAX - 8); break; - case H5T_COMPOUND: - { - unsigned offset_nbytes; /* Size needed to encode member offsets */ + case H5T_COMPOUND: { + unsigned offset_nbytes; /* Size needed to encode member offsets */ - /* Compute the # of bytes required to store a member offset */ - offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); + /* Compute the # of bytes required to store a member offset */ + offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); - /* Compute the total size needed to encode compound datatype */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) { - size_t name_len; /* Length of field's name */ + /* Compute the total size needed to encode compound datatype */ + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) { + size_t name_len; /* Length of field's name */ - /* Get length of field's name */ - name_len = HDstrlen(dt->shared->u.compnd.memb[u].name); + /* Get length of field's name */ + name_len = HDstrlen(dt->shared->u.compnd.memb[u].name); - /* Versions of the format >= 3 don't pad out the name */ - if(dt->shared->version >= H5O_DTYPE_VERSION_3) - ret_value += name_len + 1; - else - ret_value += ((name_len + 8) / 8) * 8; - - /* Check for encoding array datatype or using the latest file format */ - /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ - if(dt->shared->version >= H5O_DTYPE_VERSION_3) - ret_value += offset_nbytes; /*member offset*/ - else if(dt->shared->version == H5O_DTYPE_VERSION_2) - ret_value += 4; /*member offset*/ - else - ret_value += 4 + /*member offset*/ - 1 + /*dimensionality*/ - 3 + /*reserved*/ - 4 + /*permutation*/ - 4 + /*reserved*/ - 16; /*dimensions*/ - ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[u].type); - } /* end for */ - } - break; + /* Versions of the format >= 3 don't pad out the name */ + if (dt->shared->version >= H5O_DTYPE_VERSION_3) + ret_value += name_len + 1; + else + ret_value += ((name_len + 8) / 8) * 8; + + /* Check for encoding array datatype or using the latest file format */ + /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ + if (dt->shared->version >= H5O_DTYPE_VERSION_3) + ret_value += offset_nbytes; /*member offset*/ + else if (dt->shared->version == H5O_DTYPE_VERSION_2) + ret_value += 4; /*member offset*/ + else + ret_value += 4 + /*member offset*/ + 1 + /*dimensionality*/ + 3 + /*reserved*/ + 4 + /*permutation*/ + 4 + /*reserved*/ + 16; /*dimensions*/ + ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[u].type); + } /* end for */ + } break; case H5T_ENUM: ret_value += H5O_dtype_size(f, dt->shared->parent); - for(u = 0; u < dt->shared->u.enumer.nmembs; u++) { - size_t name_len; /* Length of field's name */ + for (u = 0; u < dt->shared->u.enumer.nmembs; u++) { + size_t name_len; /* Length of field's name */ /* Get length of field's name */ name_len = HDstrlen(dt->shared->u.enumer.name[u]); /* Versions of the format >= 3 don't pad out the name */ - if(dt->shared->version >= H5O_DTYPE_VERSION_3) + if (dt->shared->version >= H5O_DTYPE_VERSION_3) ret_value += name_len + 1; else ret_value += ((name_len + 8) / 8) * 8; @@ -1334,10 +1338,10 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) case H5T_ARRAY: ret_value += 1; /* ndims */ - if(dt->shared->version < H5O_DTYPE_VERSION_3) - ret_value += 3; /* reserved bytes*/ + if (dt->shared->version < H5O_DTYPE_VERSION_3) + ret_value += 3; /* reserved bytes*/ ret_value += 4 * dt->shared->u.array.ndims; /* dimensions */ - if(dt->shared->version < H5O_DTYPE_VERSION_3) + if (dt->shared->version < H5O_DTYPE_VERSION_3) ret_value += 4 * dt->shared->u.array.ndims; /* dimension permutations */ ret_value += H5O_dtype_size(f, dt->shared->parent); break; @@ -1354,7 +1358,6 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) FUNC_LEAVE_NOAPI(ret_value) } /* H5O_dtype_size() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_reset * @@ -1371,17 +1374,16 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) static herr_t H5O__dtype_reset(void *_mesg) { - H5T_t *dt = (H5T_t *) _mesg; + H5T_t *dt = (H5T_t *)_mesg; FUNC_ENTER_STATIC_NOERR - if(dt) + if (dt) H5T__free(dt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__dtype_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_free * @@ -1397,7 +1399,7 @@ H5O__dtype_reset(void *_mesg) static herr_t H5O__dtype_free(void *mesg) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1405,14 +1407,13 @@ H5O__dtype_free(void *mesg) HDassert(mesg); /* Release the datatype */ - if(H5T_close_real((H5T_t *)mesg) < 0) + if (H5T_close_real((H5T_t *)mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_free() */ - /*------------------------------------------------------------------------- * Function: H5O_dtype_set_share * @@ -1426,9 +1427,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh) +H5O_dtype_set_share(void *_mesg /*in,out*/, const H5O_shared_t *sh) { - H5T_t *dt = (H5T_t *)_mesg; + H5T_t *dt = (H5T_t *)_mesg; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1443,18 +1444,18 @@ H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh) /* Make sure we're not sharing a committed type in the heap */ HDassert(sh->type == H5O_SHARE_TYPE_COMMITTED || - (dt->shared->state != H5T_STATE_OPEN && dt->shared->state != H5T_STATE_NAMED)); + (dt->shared->state != H5T_STATE_OPEN && dt->shared->state != H5T_STATE_NAMED)); /* Copy the shared information */ - if(H5O_set_shared(&(dt->sh_loc), sh) < 0) + if (H5O_set_shared(&(dt->sh_loc), sh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy shared message info") /* If this is now a committed datatype, set its state properly. */ - if(sh->type == H5O_SHARE_TYPE_COMMITTED) { + if (sh->type == H5O_SHARE_TYPE_COMMITTED) { dt->shared->state = H5T_STATE_NAMED; /* Set up the object location for the datatype also */ - if(H5O_loc_reset(&(dt->oloc)) < 0) + if (H5O_loc_reset(&(dt->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to reset location") dt->oloc.file = sh->file; dt->oloc.addr = sh->u.loc.oh_addr; @@ -1464,7 +1465,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_set_share() */ - /*------------------------------------------------------------------------- * Function: H5O_dtype_can_share * @@ -1484,31 +1484,30 @@ done: static htri_t H5O_dtype_can_share(const void *_mesg) { - const H5T_t *mesg = (const H5T_t *)_mesg; - htri_t tri_ret; - htri_t ret_value = TRUE; + const H5T_t *mesg = (const H5T_t *)_mesg; + htri_t tri_ret; + htri_t ret_value = TRUE; FUNC_ENTER_NOAPI_NOINIT HDassert(mesg); /* Don't share immutable datatypes */ - if((tri_ret = H5T_is_immutable(mesg)) > 0) + if ((tri_ret = H5T_is_immutable(mesg)) > 0) HGOTO_DONE(FALSE) - else if(tri_ret < 0) + else if (tri_ret < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is immutable") /* Don't share committed datatypes */ - if((tri_ret = H5T_is_named(mesg)) > 0) + if ((tri_ret = H5T_is_named(mesg)) > 0) HGOTO_DONE(FALSE) - else if(tri_ret < 0) + else if (tri_ret < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is shared") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_can_share() */ - /*------------------------------------------------------------------------- * Function: H5O_dtype_pre_copy_file * @@ -1525,13 +1524,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, - void *_udata) +H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t H5_ATTR_UNUSED *deleted, + const H5O_copy_t *cpy_info, void *_udata) { - const H5T_t *dt_src = (const H5T_t *)mesg_src; /* Source datatype */ - H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5T_t * dt_src = (const H5T_t *)mesg_src; /* Source datatype */ + H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1543,7 +1541,7 @@ H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version as indicated by the destination file's high bound */ - if(dt_src->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (dt_src->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "datatype message version out of bounds") /* If the user data is non-NULL, assume we are copying a dataset @@ -1553,13 +1551,13 @@ H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, * message is an early version, but since the layout information isn't * available here, we just make a copy in all situations) */ - if(udata) { + if (udata) { /* Create a memory copy of the variable-length datatype */ - if(NULL == (udata->src_dtype = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (udata->src_dtype = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") /* Set the location of the source datatype to describe the disk form of the data */ - if(H5T_set_loc(udata->src_dtype, H5F_VOL_OBJ(file_src), H5T_LOC_DISK) < 0) + if (H5T_set_loc(udata->src_dtype, H5F_VOL_OBJ(file_src), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ @@ -1567,7 +1565,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_copy_file * @@ -1582,33 +1579,32 @@ done: *------------------------------------------------------------------------- */ static void * -H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_type, - void *native_src, H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size, - H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_type, void *native_src, + H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size, + H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { - H5T_t *dst_mesg; /* Destination datatype */ - void *ret_value = NULL; /* Return value */ + H5T_t *dst_mesg; /* Destination datatype */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Perform a normal copy of the object header message */ - if(NULL == (dst_mesg = (H5T_t *)H5O_dtype_copy(native_src, NULL))) + if (NULL == (dst_mesg = (H5T_t *)H5O_dtype_copy(native_src, NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy") /* The datatype will be in the new file; set its location. */ - if(H5T_set_loc(dst_mesg, H5F_VOL_OBJ(file_dst), H5T_LOC_DISK) < 0) + if (H5T_set_loc(dst_mesg, H5F_VOL_OBJ(file_dst), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to set location") ret_value = dst_mesg; done: - if(NULL == ret_value) + if (NULL == ret_value) H5O_msg_free(mesg_type->id, dst_mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_shared_post_copy_upd * @@ -1623,18 +1619,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, - const void H5_ATTR_UNUSED *mesg_src, H5O_loc_t H5_ATTR_UNUSED *dst_oloc, void *mesg_dst, - H5O_copy_t H5_ATTR_UNUSED *cpy_info) +H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, const void H5_ATTR_UNUSED *mesg_src, + H5O_loc_t H5_ATTR_UNUSED *dst_oloc, void *mesg_dst, + H5O_copy_t H5_ATTR_UNUSED *cpy_info) { - H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { + if (dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { HDassert(H5T_is_named(dt_dst)); - if(H5O_loc_reset(&(dt_dst->oloc)) < 0) + if (H5O_loc_reset(&(dt_dst->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to reset location") dt_dst->oloc.file = dt_dst->sh_loc.file; dt_dst->oloc.addr = dt_dst->sh_loc.u.loc.oh_addr; @@ -1647,7 +1643,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_shared_post_copy_upd */ - /*-------------------------------------------------------------------------- NAME H5O__dtype_debug @@ -1655,27 +1650,26 @@ done: Prints debugging information for a message USAGE void *H5O__dtype_debug(f, mesg, stream, indent, fwidth) - H5F_t *f; IN: pointer to the HDF5 file struct - const void *mesg; IN: Pointer to the source simple datatype - struct - FILE *stream; IN: Pointer to the stream for output data - int indent; IN: Amount to indent information by - int fwidth; IN: Field width (?) + H5F_t *f; IN: pointer to the HDF5 file struct + const void *mesg; IN: Pointer to the source simple datatype + struct + FILE *stream; IN: Pointer to the stream for output data + int indent; IN: Amount to indent information by + int fwidth; IN: Field width (?) RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function prints debugging output to the stream passed as a + This function prints debugging output to the stream passed as a parameter. --------------------------------------------------------------------------*/ static herr_t -H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, - int fwidth) +H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidth) { - const H5T_t *dt = (const H5T_t*)mesg; - const char *s; - char buf[256]; - unsigned i; - size_t k; + const H5T_t *dt = (const H5T_t *)mesg; + const char * s; + char buf[256]; + unsigned i; + size_t k; FUNC_ENTER_STATIC_NOERR @@ -1738,61 +1732,48 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type class:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type class:", s); - HDfprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth, - "Size:", - (unsigned long)(dt->shared->size), 1 == dt->shared->size ? "" : "s"); + HDfprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth, "Size:", (unsigned long)(dt->shared->size), + 1 == dt->shared->size ? "" : "s"); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Version:", dt->shared->version); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", dt->shared->version); if (H5T_COMPOUND == dt->shared->type) { HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of members:", - dt->shared->u.compnd.nmembs); - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { + "Number of members:", dt->shared->u.compnd.nmembs); + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { HDsprintf(buf, "Member %u:", i); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - buf, - dt->shared->u.compnd.memb[i].name); - HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth-3), - "Byte offset:", - (unsigned long)(dt->shared->u.compnd.memb[i].offset)); - H5O__dtype_debug(f, dt->shared->u.compnd.memb[i].type, stream, - indent + 3, MAX(0, fwidth - 3)); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.compnd.memb[i].name); + HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3), + "Byte offset:", (unsigned long)(dt->shared->u.compnd.memb[i].offset)); + H5O__dtype_debug(f, dt->shared->u.compnd.memb[i].type, stream, indent + 3, MAX(0, fwidth - 3)); } /* end for */ - } /* end if */ - else if(H5T_ENUM == dt->shared->type) { + } /* end if */ + else if (H5T_ENUM == dt->shared->type) { HDfprintf(stream, "%*s%s\n", indent, "", "Base type:"); - H5O__dtype_debug(f, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3)); + H5O__dtype_debug(f, dt->shared->parent, stream, indent + 3, MAX(0, fwidth - 3)); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of members:", - dt->shared->u.enumer.nmembs); - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) { + "Number of members:", dt->shared->u.enumer.nmembs); + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { HDsprintf(buf, "Member %u:", i); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - buf, - dt->shared->u.enumer.name[i]); - HDfprintf(stream, "%*s%-*s 0x", indent, "", fwidth, - "Raw bytes of value:"); - for(k = 0; k < dt->shared->parent->shared->size; k++) - HDfprintf(stream, "%02x", (unsigned)*((uint8_t *)dt->shared->u.enumer.value + (i * dt->shared->parent->shared->size) + k)); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.enumer.name[i]); + HDfprintf(stream, "%*s%-*s 0x", indent, "", fwidth, "Raw bytes of value:"); + for (k = 0; k < dt->shared->parent->shared->size; k++) + HDfprintf(stream, "%02x", + (unsigned)*((uint8_t *)dt->shared->u.enumer.value + + (i * dt->shared->parent->shared->size) + k)); HDfprintf(stream, "\n"); } /* end for */ + } /* end else if */ + else if (H5T_OPAQUE == dt->shared->type) { + HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, "Tag:", dt->shared->u.opaque.tag); } /* end else if */ - else if(H5T_OPAQUE == dt->shared->type) { - HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, - "Tag:", dt->shared->u.opaque.tag); - } /* end else if */ - else if(H5T_REFERENCE == dt->shared->type) { - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, - "Fix dumping reference types!"); + else if (H5T_REFERENCE == dt->shared->type) { + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Fix dumping reference types!"); } /* end else if */ - else if(H5T_STRING == dt->shared->type) { - switch(dt->shared->u.atomic.u.s.cset) { + else if (H5T_STRING == dt->shared->type) { + switch (dt->shared->u.atomic.u.s.cset) { case H5T_CSET_ASCII: s = "ASCII"; break; @@ -1825,11 +1806,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Character Set:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Character Set:", s); - switch(dt->shared->u.atomic.u.s.pad) { + switch (dt->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: s = "NULL Terminated"; break; @@ -1865,12 +1844,10 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "String Padding:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "String Padding:", s); } /* end else if */ - else if(H5T_VLEN == dt->shared->type) { - switch(dt->shared->u.vlen.type) { + else if (H5T_VLEN == dt->shared->type) { + switch (dt->shared->u.vlen.type) { case H5T_VLEN_SEQUENCE: s = "sequence"; break; @@ -1886,10 +1863,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Vlen type:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Vlen type:", s); - switch(dt->shared->u.vlen.loc) { + switch (dt->shared->u.vlen.loc) { case H5T_LOC_MEMORY: s = "memory"; break; @@ -1905,12 +1881,11 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Location:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Location:", s); /* Extra information for VL-strings */ - if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { - switch(dt->shared->u.vlen.cset) { + if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { + switch (dt->shared->u.vlen.cset) { case H5T_CSET_ASCII: s = "ASCII"; break; @@ -1943,11 +1918,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Character Set:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Character Set:", s); - switch(dt->shared->u.vlen.pad) { + switch (dt->shared->u.vlen.pad) { case H5T_STR_NULLTERM: s = "NULL Terminated"; break; @@ -1983,17 +1956,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "String Padding:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "String Padding:", s); } /* end if */ - } /* end else if */ - else if(H5T_ARRAY == dt->shared->type) { - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Rank:", - dt->shared->u.array.ndims); + } /* end else if */ + else if (H5T_ARRAY == dt->shared->type) { + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Rank:", dt->shared->u.array.ndims); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:"); - for(i = 0; i < dt->shared->u.array.ndims; i++) + for (i = 0; i < dt->shared->u.array.ndims; i++) HDfprintf(stream, "%s%u", (i ? ", " : ""), (unsigned)dt->shared->u.array.dim[i]); HDfprintf(stream, "}\n"); HDfprintf(stream, "%*s%s\n", indent, "", "Base type:"); @@ -2027,19 +1996,15 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Byte order:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Byte order:", s); HDfprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth, - "Precision:", - (unsigned long)(dt->shared->u.atomic.prec), - 1==dt->shared->u.atomic.prec?"":"s"); + "Precision:", (unsigned long)(dt->shared->u.atomic.prec), + 1 == dt->shared->u.atomic.prec ? "" : "s"); HDfprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth, - "Offset:", - (unsigned long)(dt->shared->u.atomic.offset), - 1==dt->shared->u.atomic.offset?"":"s"); + "Offset:", (unsigned long)(dt->shared->u.atomic.offset), + 1 == dt->shared->u.atomic.offset ? "" : "s"); switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: @@ -2060,8 +2025,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = "pad?"; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Low pad type:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Low pad type:", s); switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: @@ -2082,8 +2046,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = "pad?"; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "High pad type:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "High pad type:", s); if (H5T_FLOAT == dt->shared->type) { switch (dt->shared->u.atomic.u.f.pad) { @@ -2109,8 +2072,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Internal pad type:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Internal pad type:", s); switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_IMPLIED: @@ -2127,35 +2089,28 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, case H5T_NORM_ERROR: default: - HDsprintf(buf, "H5T_NORM_%d", (int) (dt->shared->u.atomic.u.f.norm)); + HDsprintf(buf, "H5T_NORM_%d", (int)(dt->shared->u.atomic.u.f.norm)); s = buf; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Normalization:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Normalization:", s); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Sign bit location:", - (unsigned long) (dt->shared->u.atomic.u.f.sign)); + "Sign bit location:", (unsigned long)(dt->shared->u.atomic.u.f.sign)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Exponent location:", - (unsigned long) (dt->shared->u.atomic.u.f.epos)); + "Exponent location:", (unsigned long)(dt->shared->u.atomic.u.f.epos)); HDfprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth, - "Exponent bias:", - (unsigned long) (dt->shared->u.atomic.u.f.ebias)); + "Exponent bias:", (unsigned long)(dt->shared->u.atomic.u.f.ebias)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Exponent size:", - (unsigned long) (dt->shared->u.atomic.u.f.esize)); + "Exponent size:", (unsigned long)(dt->shared->u.atomic.u.f.esize)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Mantissa location:", - (unsigned long) (dt->shared->u.atomic.u.f.mpos)); + "Mantissa location:", (unsigned long)(dt->shared->u.atomic.u.f.mpos)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Mantissa size:", - (unsigned long) (dt->shared->u.atomic.u.f.msize)); + "Mantissa size:", (unsigned long)(dt->shared->u.atomic.u.f.msize)); } /* end if */ else if (H5T_INTEGER == dt->shared->type) { @@ -2171,15 +2126,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, case H5T_SGN_ERROR: case H5T_NSGN: default: - HDsprintf(buf, "H5T_SGN_%d", (int) (dt->shared->u.atomic.u.i.sign)); + HDsprintf(buf, "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign)); s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Sign scheme:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Sign scheme:", s); } /* end else if */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__dtype_debug() */ - diff --git a/src/H5Oefl.c b/src/H5Oefl.c index b18d819..f95324d 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -16,56 +16,52 @@ * Tuesday, November 25, 1997 */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O_efl_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O_efl_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); static herr_t H5O_efl_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_efl_copy(const void *_mesg, void *_dest); +static void * H5O_efl_copy(const void *_mesg, void *_dest); static size_t H5O_efl_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__efl_reset(void *_mesg); -static void *H5O__efl_copy_file(H5F_t *file_src, void *mesg_src, - H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, - H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__efl_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static void * H5O__efl_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__efl_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_EFL[1] = {{ - H5O_EFL_ID, /*message id number */ - "external file list", /*message name for debugging */ - sizeof(H5O_efl_t), /*native message size */ - 0, /* messages are sharable? */ - H5O_efl_decode, /*decode message */ - H5O_efl_encode, /*encode message */ - H5O_efl_copy, /*copy native value */ - H5O_efl_size, /*size of message on disk */ - H5O__efl_reset, /*reset method */ - NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - H5O__efl_copy_file, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__efl_debug /*debug the message */ + H5O_EFL_ID, /*message id number */ + "external file list", /*message name for debugging */ + sizeof(H5O_efl_t), /*native message size */ + 0, /* messages are sharable? */ + H5O_efl_decode, /*decode message */ + H5O_efl_encode, /*encode message */ + H5O_efl_copy, /*copy native value */ + H5O_efl_size, /*size of message on disk */ + H5O__efl_reset, /*reset method */ + NULL, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + H5O__efl_copy_file, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__efl_debug /*debug the message */ }}; -#define H5O_EFL_VERSION 1 +#define H5O_EFL_VERSION 1 - /*------------------------------------------------------------------------- * Function: H5O_efl_decode * @@ -87,16 +83,15 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_efl_t *mesg = NULL; + H5O_efl_t * mesg = NULL; int version; - const char *s = NULL; - H5HL_t *heap; - size_t u; /* Local index variable */ - void *ret_value = NULL; /* Return value */ + const char *s = NULL; + H5HL_t * heap; + size_t u; /* Local index variable */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -104,12 +99,12 @@ H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(f); HDassert(p); - if(NULL == (mesg = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) + if (NULL == (mesg = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Version */ version = *p++; - if(version != H5O_EFL_VERSION) + if (version != H5O_EFL_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for external file list message") /* Reserved */ @@ -117,7 +112,7 @@ H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, /* Number of slots */ UINT16DECODE(p, mesg->nalloc); - HDassert(mesg->nalloc>0); + HDassert(mesg->nalloc > 0); UINT16DECODE(p, mesg->nused); HDassert(mesg->nused <= mesg->nalloc); @@ -127,44 +122,44 @@ H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, #ifndef NDEBUG HDassert(H5F_addr_defined(mesg->heap_addr)); - if(NULL == (heap = H5HL_protect(f, mesg->heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(f, mesg->heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") s = (const char *)H5HL_offset_into(heap, 0); HDassert(s && !*s); - if(H5HL_unprotect(heap) < 0) + if (H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") heap = NULL; #endif /* Decode the file list */ mesg->slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t)); - if(NULL == mesg->slot) + if (NULL == mesg->slot) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (heap = H5HL_protect(f, mesg->heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(f, mesg->heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") - for(u = 0; u < mesg->nused; u++) { + for (u = 0; u < mesg->nused; u++) { /* Name */ - H5F_DECODE_LENGTH (f, p, mesg->slot[u].name_offset); + H5F_DECODE_LENGTH(f, p, mesg->slot[u].name_offset); - if((s = (const char *)H5HL_offset_into(heap, mesg->slot[u].name_offset)) == NULL) + if ((s = (const char *)H5HL_offset_into(heap, mesg->slot[u].name_offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get external file name") - if(*s == (char)'\0') + if (*s == (char)'\0') HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "invalid external file name") - mesg->slot[u].name = H5MM_xstrdup (s); + mesg->slot[u].name = H5MM_xstrdup(s); HDassert(mesg->slot[u].name); /* File offset */ - H5F_DECODE_LENGTH (f, p, mesg->slot[u].offset); + H5F_DECODE_LENGTH(f, p, mesg->slot[u].offset); /* Size */ - H5F_DECODE_LENGTH (f, p, mesg->slot[u].size); + H5F_DECODE_LENGTH(f, p, mesg->slot[u].size); } /* end for */ - if(H5HL_unprotect(heap) < 0) + if (H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") heap = NULL; @@ -172,14 +167,13 @@ H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = mesg; done: - if(ret_value == NULL) - if(mesg != NULL) + if (ret_value == NULL) + if (mesg != NULL) H5MM_xfree(mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_efl_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_efl_encode * @@ -195,8 +189,8 @@ done: static herr_t H5O_efl_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; - size_t u; /* Local index variable */ + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + size_t u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -224,21 +218,20 @@ H5O_efl_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, cons H5F_addr_encode(f, &p, mesg->heap_addr); /* Encode file list */ - for(u = 0; u < mesg->nused; u++) { - /* - * The name should have been added to the heap when the dataset was - * created. - */ - HDassert(mesg->slot[u].name_offset); - H5F_ENCODE_LENGTH(f, p, mesg->slot[u].name_offset); - H5F_ENCODE_LENGTH(f, p, (hsize_t)mesg->slot[u].offset); - H5F_ENCODE_LENGTH(f, p, mesg->slot[u].size); + for (u = 0; u < mesg->nused; u++) { + /* + * The name should have been added to the heap when the dataset was + * created. + */ + HDassert(mesg->slot[u].name_offset); + H5F_ENCODE_LENGTH(f, p, mesg->slot[u].name_offset); + H5F_ENCODE_LENGTH(f, p, (hsize_t)mesg->slot[u].offset); + H5F_ENCODE_LENGTH(f, p, mesg->slot[u].size); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_efl_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_efl_copy * @@ -257,11 +250,11 @@ H5O_efl_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, cons static void * H5O_efl_copy(const void *_mesg, void *_dest) { - const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; - H5O_efl_t *dest = (H5O_efl_t *) _dest; - size_t u; /* Local index variable */ - hbool_t slot_allocated = FALSE; /* Flag to indicate that dynamic allocation has begun */ - void *ret_value = NULL; /* Return value */ + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + H5O_efl_t * dest = (H5O_efl_t *)_dest; + size_t u; /* Local index variable */ + hbool_t slot_allocated = FALSE; /* Flag to indicate that dynamic allocation has begun */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -269,43 +262,42 @@ H5O_efl_copy(const void *_mesg, void *_dest) HDassert(mesg); /* Allocate destination message, if necessary */ - if(!dest && NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) + if (!dest && NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message") /* copy */ *dest = *mesg; /* Deep copy allocated information */ - if(dest->nalloc > 0) { - if(NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_calloc(dest->nalloc * sizeof(H5O_efl_entry_t)))) + if (dest->nalloc > 0) { + if (NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_calloc(dest->nalloc * sizeof(H5O_efl_entry_t)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slots") slot_allocated = TRUE; - for(u = 0; u < mesg->nused; u++) { + for (u = 0; u < mesg->nused; u++) { dest->slot[u] = mesg->slot[u]; - if(NULL == (dest->slot[u].name = H5MM_xstrdup(mesg->slot[u].name))) + if (NULL == (dest->slot[u].name = H5MM_xstrdup(mesg->slot[u].name))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slot name") } /* end for */ - } /* end if */ + } /* end if */ /* Set return value */ ret_value = dest; done: - if(NULL == ret_value) { - if(slot_allocated) { - for(u = 0; u < dest->nused; u++) - if(dest->slot[u].name != NULL && dest->slot[u].name != mesg->slot[u].name) + if (NULL == ret_value) { + if (slot_allocated) { + for (u = 0; u < dest->nused; u++) + if (dest->slot[u].name != NULL && dest->slot[u].name != mesg->slot[u].name) dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name); dest->slot = (H5O_efl_entry_t *)H5MM_xfree(dest->slot); } /* end if */ - if(NULL == _dest) + if (NULL == _dest) dest = (H5O_efl_t *)H5MM_xfree(dest); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_efl_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_efl_size * @@ -326,8 +318,8 @@ done: static size_t H5O_efl_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; - size_t ret_value = 0; + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + size_t ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -335,18 +327,17 @@ H5O_efl_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void * HDassert(f); HDassert(mesg); - ret_value = (size_t)H5F_SIZEOF_ADDR(f) + /*heap address */ - 2 + /*slots allocated*/ - 2 + /*num slots used*/ - 4 + /*reserved */ - mesg->nused * ((size_t)H5F_SIZEOF_SIZE(f) + /*name offset */ - (size_t)H5F_SIZEOF_SIZE(f) + /*file offset */ - (size_t)H5F_SIZEOF_SIZE(f)); /*file size */ + ret_value = (size_t)H5F_SIZEOF_ADDR(f) + /*heap address */ + 2 + /*slots allocated*/ + 2 + /*num slots used*/ + 4 + /*reserved */ + mesg->nused * ((size_t)H5F_SIZEOF_SIZE(f) + /*name offset */ + (size_t)H5F_SIZEOF_SIZE(f) + /*file offset */ + (size_t)H5F_SIZEOF_SIZE(f)); /*file size */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_efl_size() */ - /*------------------------------------------------------------------------- * Function: H5O__efl_reset * @@ -363,8 +354,8 @@ H5O_efl_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void * static herr_t H5O__efl_reset(void *_mesg) { - H5O_efl_t *mesg = (H5O_efl_t *) _mesg; - size_t u; /* Local index variable */ + H5O_efl_t *mesg = (H5O_efl_t *)_mesg; + size_t u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -372,9 +363,9 @@ H5O__efl_reset(void *_mesg) HDassert(mesg); /* reset */ - if(mesg->slot) { - for(u = 0; u < mesg->nused; u++) { - mesg->slot[u].name = (char *)H5MM_xfree(mesg->slot[u].name); + if (mesg->slot) { + for (u = 0; u < mesg->nused; u++) { + mesg->slot[u].name = (char *)H5MM_xfree(mesg->slot[u].name); mesg->slot[u].name_offset = 0; } /* end for */ mesg->slot = (H5O_efl_entry_t *)H5MM_xfree(mesg->slot); @@ -385,7 +376,6 @@ H5O__efl_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__efl_reset() */ - /*------------------------------------------------------------------------- * Function: H5O_efl_total_size * @@ -402,29 +392,28 @@ H5O__efl_reset(void *_mesg) *------------------------------------------------------------------------- */ hsize_t -H5O_efl_total_size (H5O_efl_t *efl) +H5O_efl_total_size(H5O_efl_t *efl) { - hsize_t ret_value = 0, tmp; + hsize_t ret_value = 0, tmp; FUNC_ENTER_NOAPI_NOINIT - if(efl->nused > 0 && H5O_EFL_UNLIMITED == efl->slot[efl->nused - 1].size) - ret_value = H5O_EFL_UNLIMITED; + if (efl->nused > 0 && H5O_EFL_UNLIMITED == efl->slot[efl->nused - 1].size) + ret_value = H5O_EFL_UNLIMITED; else { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ - for(u = 0; u < efl->nused; u++, ret_value = tmp) { - tmp = ret_value + efl->slot[u].size; - if(tmp <= ret_value) - HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed"); - } /* end for */ - } /* end else */ + for (u = 0; u < efl->nused; u++, ret_value = tmp) { + tmp = ret_value + efl->slot[u].size; + if (tmp <= ret_value) + HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed"); + } /* end for */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_efl_total_size() */ - /*------------------------------------------------------------------------- * Function: H5O__efl_copy_file * @@ -441,14 +430,14 @@ done: */ static void * H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *_udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *_udata) { - H5O_efl_t *efl_src = (H5O_efl_t *) mesg_src; - H5O_efl_t *efl_dst = NULL; - H5HL_t *heap = NULL; /* Pointer to local heap for EFL file names */ - size_t idx, size, name_offset, heap_size; - void *ret_value = NULL; /* Return value */ + H5O_efl_t *efl_src = (H5O_efl_t *)mesg_src; + H5O_efl_t *efl_dst = NULL; + H5HL_t * heap = NULL; /* Pointer to local heap for EFL file names */ + size_t idx, size, name_offset, heap_size; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG) @@ -457,34 +446,34 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d HDassert(file_dst); /* Allocate space for the destination efl */ - if(NULL == (efl_dst = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) + if (NULL == (efl_dst = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the "top level" information */ H5MM_memcpy(efl_dst, efl_src, sizeof(H5O_efl_t)); /* Determine size needed for destination heap */ - heap_size = H5HL_ALIGN(1); /* "empty" name */ - for(idx = 0; idx < efl_src->nused; idx++) + heap_size = H5HL_ALIGN(1); /* "empty" name */ + for (idx = 0; idx < efl_src->nused; idx++) heap_size += H5HL_ALIGN(HDstrlen(efl_src->slot[idx].name) + 1); /* Create name heap */ - if(H5HL_create(file_dst, heap_size, &efl_dst->heap_addr/*out*/) < 0) + if (H5HL_create(file_dst, heap_size, &efl_dst->heap_addr /*out*/) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, NULL, "can't create heap") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(file_dst, efl_dst->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(file_dst, efl_dst->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to protect EFL file name heap") /* Insert "empty" name first */ - if(UFAIL == (name_offset = H5HL_insert(file_dst, heap, (size_t)1, ""))) + if (UFAIL == (name_offset = H5HL_insert(file_dst, heap, (size_t)1, ""))) HGOTO_ERROR(H5E_EFL, H5E_CANTINSERT, NULL, "can't insert file name into heap") HDassert(0 == name_offset); /* allocate array of external file entries */ - if(efl_src->nalloc > 0) { + if (efl_src->nalloc > 0) { size = efl_src->nalloc * sizeof(H5O_efl_entry_t); - if((efl_dst->slot = (H5O_efl_entry_t *)H5MM_calloc(size)) == NULL) + if ((efl_dst->slot = (H5O_efl_entry_t *)H5MM_calloc(size)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy content from the source. Need to update later */ @@ -492,10 +481,10 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d } /* end if */ /* copy the name from the source */ - for(idx = 0; idx < efl_src->nused; idx++) { + for (idx = 0; idx < efl_src->nused; idx++) { efl_dst->slot[idx].name = H5MM_xstrdup(efl_src->slot[idx].name); - if(UFAIL == (efl_dst->slot[idx].name_offset = H5HL_insert(file_dst, heap, - HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name))) + if (UFAIL == (efl_dst->slot[idx].name_offset = H5HL_insert( + file_dst, heap, HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name))) HGOTO_ERROR(H5E_EFL, H5E_CANTINSERT, NULL, "can't insert file name into heap") } /* end for */ @@ -504,16 +493,15 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to unprotect EFL file name heap") - if(!ret_value) - if(efl_dst) + if (!ret_value) + if (efl_dst) H5MM_xfree(efl_dst); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__efl_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__efl_debug * @@ -527,11 +515,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__efl_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__efl_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; - size_t u; + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + size_t u; FUNC_ENTER_STATIC_NOERR @@ -542,36 +529,29 @@ H5O__efl_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Heap address:", mesg->heap_addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Heap address:", mesg->heap_addr); - HDfprintf(stream, "%*s%-*s %u/%u\n", indent, "", fwidth, - "Slots used/allocated:", - mesg->nused, mesg->nalloc); + HDfprintf(stream, "%*s%-*s %u/%u\n", indent, "", fwidth, "Slots used/allocated:", mesg->nused, + mesg->nalloc); - for(u = 0; u < mesg->nused; u++) { - char buf[64]; + for (u = 0; u < mesg->nused; u++) { + char buf[64]; - HDsnprintf(buf, sizeof(buf), "File %u", (unsigned)u); - HDfprintf(stream, "%*s%s:\n", indent, "", buf); + HDsnprintf(buf, sizeof(buf), "File %u", (unsigned)u); + HDfprintf(stream, "%*s%s:\n", indent, "", buf); - HDfprintf(stream, "%*s%-*s \"%s\"\n", indent+3, "", MAX (fwidth-3, 0), - "Name:", - mesg->slot[u].name); + HDfprintf(stream, "%*s%-*s \"%s\"\n", indent + 3, "", MAX(fwidth - 3, 0), + "Name:", mesg->slot[u].name); - HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), - "Name offset:", - (unsigned long)(mesg->slot[u].name_offset)); + HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(fwidth - 3, 0), + "Name offset:", (unsigned long)(mesg->slot[u].name_offset)); - HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), - "Offset of data in file:", - (unsigned long)(mesg->slot[u].offset)); + HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(fwidth - 3, 0), + "Offset of data in file:", (unsigned long)(mesg->slot[u].offset)); - HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), - "Bytes reserved for data:", - (unsigned long)(mesg->slot[u].size)); + HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(fwidth - 3, 0), + "Bytes reserved for data:", (unsigned long)(mesg->slot[u].size)); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__efl_debug() */ - diff --git a/src/H5Ofill.c b/src/H5Ofill.c index cb75bc3..1c31447 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -18,139 +18,136 @@ * uninitialized data points of a dataset. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ - - -static void *H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ + +static void * H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_fill_old_encode(H5F_t *f, uint8_t *p, const void *_mesg); static size_t H5O_fill_old_size(const H5F_t *f, const void *_mesg); -static void *H5O_fill_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O_fill_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_fill_new_encode(H5F_t *f, uint8_t *p, const void *_mesg); static size_t H5O_fill_new_size(const H5F_t *f, const void *_mesg); -static void *H5O_fill_copy(const void *_mesg, void *_dest); +static void * H5O_fill_copy(const void *_mesg, void *_dest); static herr_t H5O__fill_reset(void *_mesg); static herr_t H5O__fill_free(void *_mesg); -static herr_t H5O__fill_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__fill_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__fill_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__fill_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_FILL -#define H5O_SHARED_DECODE H5O_fill_shared_decode -#define H5O_SHARED_DECODE_REAL H5O_fill_old_decode -#define H5O_SHARED_ENCODE H5O_fill_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_fill_old_encode -#define H5O_SHARED_SIZE H5O_fill_shared_size -#define H5O_SHARED_SIZE_REAL H5O_fill_old_size -#define H5O_SHARED_DELETE H5O__fill_shared_delete +#define H5O_SHARED_TYPE H5O_MSG_FILL +#define H5O_SHARED_DECODE H5O_fill_shared_decode +#define H5O_SHARED_DECODE_REAL H5O_fill_old_decode +#define H5O_SHARED_ENCODE H5O_fill_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O_fill_old_encode +#define H5O_SHARED_SIZE H5O_fill_shared_size +#define H5O_SHARED_SIZE_REAL H5O_fill_old_size +#define H5O_SHARED_DELETE H5O__fill_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O__fill_shared_link +#define H5O_SHARED_LINK H5O__fill_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O__fill_shared_copy_file +#define H5O_SHARED_COPY_FILE H5O__fill_shared_copy_file #undef H5O_SHARED_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE H5O_fill_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O_fill_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#undef H5O_SHARED_POST_COPY_FILE_UPD -#define H5O_SHARED_DEBUG H5O_fill_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__fill_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#undef H5O_SHARED_POST_COPY_FILE_UPD +#define H5O_SHARED_DEBUG H5O_fill_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__fill_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* Set up & include shared message "interface" info */ /* (Kludgy 'undef's in order to re-include the H5Oshared.h header) */ #undef H5O_SHARED_TYPE -#define H5O_SHARED_TYPE H5O_MSG_FILL_NEW +#define H5O_SHARED_TYPE H5O_MSG_FILL_NEW #undef H5O_SHARED_DECODE -#define H5O_SHARED_DECODE H5O_fill_new_shared_decode +#define H5O_SHARED_DECODE H5O_fill_new_shared_decode #undef H5O_SHARED_DECODE_REAL -#define H5O_SHARED_DECODE_REAL H5O_fill_new_decode +#define H5O_SHARED_DECODE_REAL H5O_fill_new_decode #undef H5O_SHARED_ENCODE -#define H5O_SHARED_ENCODE H5O_fill_new_shared_encode +#define H5O_SHARED_ENCODE H5O_fill_new_shared_encode #undef H5O_SHARED_ENCODE_REAL -#define H5O_SHARED_ENCODE_REAL H5O_fill_new_encode +#define H5O_SHARED_ENCODE_REAL H5O_fill_new_encode #undef H5O_SHARED_SIZE -#define H5O_SHARED_SIZE H5O_fill_new_shared_size +#define H5O_SHARED_SIZE H5O_fill_new_shared_size #undef H5O_SHARED_SIZE_REAL -#define H5O_SHARED_SIZE_REAL H5O_fill_new_size +#define H5O_SHARED_SIZE_REAL H5O_fill_new_size #undef H5O_SHARED_DELETE -#define H5O_SHARED_DELETE H5O__fill_new_shared_delete +#define H5O_SHARED_DELETE H5O__fill_new_shared_delete #undef H5O_SHARED_DELETE_REAL #undef H5O_SHARED_LINK -#define H5O_SHARED_LINK H5O__fill_new_shared_link +#define H5O_SHARED_LINK H5O__fill_new_shared_link #undef H5O_SHARED_LINK_REAL #undef H5O_SHARED_COPY_FILE -#define H5O_SHARED_COPY_FILE H5O__fill_new_shared_copy_file +#define H5O_SHARED_COPY_FILE H5O__fill_new_shared_copy_file #undef H5O_SHARED_COPY_FILE_REAL #undef H5O_SHARED_POST_COPY_FILE -#define H5O_SHARED_POST_COPY_FILE H5O_fill_new_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O_fill_new_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#undef H5O_SHARED_POST_COPY_FILE_UPD +#undef H5O_SHARED_POST_COPY_FILE_UPD #undef H5O_SHARED_DEBUG -#define H5O_SHARED_DEBUG H5O_fill_new_shared_debug +#define H5O_SHARED_DEBUG H5O_fill_new_shared_debug #undef H5O_SHARED_DEBUG_REAL -#define H5O_SHARED_DEBUG_REAL H5O__fill_debug +#define H5O_SHARED_DEBUG_REAL H5O__fill_debug #undef H5Oshared_H -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* This message derives from H5O message class, for old fill value before version 1.5 */ const H5O_msg_class_t H5O_MSG_FILL[1] = {{ - H5O_FILL_ID, /*message id number */ - "fill", /*message name for debugging */ - sizeof(H5O_fill_t), /*native message size */ - H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */ - H5O_fill_shared_decode, /*decode message */ - H5O_fill_shared_encode, /*encode message */ - H5O_fill_copy, /*copy the native value */ - H5O_fill_shared_size, /*raw message size */ - H5O__fill_reset, /*free internal memory */ - H5O__fill_free, /* free method */ - H5O__fill_shared_delete, /* file delete method */ - H5O__fill_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - H5O__fill_pre_copy_file, /* pre copy native value to file */ - H5O__fill_shared_copy_file, /* copy native value to file */ - H5O_fill_shared_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_fill_shared_debug /*debug the message */ + H5O_FILL_ID, /*message id number */ + "fill", /*message name for debugging */ + sizeof(H5O_fill_t), /*native message size */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_fill_shared_decode, /*decode message */ + H5O_fill_shared_encode, /*encode message */ + H5O_fill_copy, /*copy the native value */ + H5O_fill_shared_size, /*raw message size */ + H5O__fill_reset, /*free internal memory */ + H5O__fill_free, /* free method */ + H5O__fill_shared_delete, /* file delete method */ + H5O__fill_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + H5O__fill_pre_copy_file, /* pre copy native value to file */ + H5O__fill_shared_copy_file, /* copy native value to file */ + H5O_fill_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O_fill_shared_debug /*debug the message */ }}; /* This message derives from H5O message class, for new fill value after version 1.4 */ const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{ - H5O_FILL_NEW_ID, /*message id number */ - "fill_new", /*message name for debugging */ - sizeof(H5O_fill_t), /*native message size */ - H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */ - H5O_fill_new_shared_decode, /*decode message */ - H5O_fill_new_shared_encode, /*encode message */ - H5O_fill_copy, /*copy the native value */ - H5O_fill_new_shared_size, /*raw message size */ - H5O__fill_reset, /*free internal memory */ - H5O__fill_free, /* free method */ - H5O__fill_new_shared_delete, /* file delete method */ - H5O__fill_new_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - H5O__fill_pre_copy_file, /* pre copy native value to file */ - H5O__fill_new_shared_copy_file, /* copy native value to file */ - H5O_fill_new_shared_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_fill_new_shared_debug /*debug the message */ + H5O_FILL_NEW_ID, /*message id number */ + "fill_new", /*message name for debugging */ + sizeof(H5O_fill_t), /*native message size */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_fill_new_shared_decode, /*decode message */ + H5O_fill_new_shared_encode, /*encode message */ + H5O_fill_copy, /*copy the native value */ + H5O_fill_new_shared_size, /*raw message size */ + H5O__fill_reset, /*free internal memory */ + H5O__fill_free, /* free method */ + H5O__fill_new_shared_delete, /* file delete method */ + H5O__fill_new_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + H5O__fill_pre_copy_file, /* pre copy native value to file */ + H5O__fill_new_shared_copy_file, /* copy native value to file */ + H5O_fill_new_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O_fill_new_shared_debug /*debug the message */ }}; /* Format version bounds for fill value */ @@ -163,13 +160,15 @@ const unsigned H5O_fill_ver_bounds[] = { }; /* Masks, shift values & flags for fill value message */ -#define H5O_FILL_MASK_ALLOC_TIME 0x03 -#define H5O_FILL_SHIFT_ALLOC_TIME 0 -#define H5O_FILL_MASK_FILL_TIME 0x03 -#define H5O_FILL_SHIFT_FILL_TIME 2 -#define H5O_FILL_FLAG_UNDEFINED_VALUE 0x10 -#define H5O_FILL_FLAG_HAVE_VALUE 0x20 -#define H5O_FILL_FLAGS_ALL (H5O_FILL_MASK_ALLOC_TIME | (H5O_FILL_MASK_FILL_TIME << H5O_FILL_SHIFT_FILL_TIME) | H5O_FILL_FLAG_UNDEFINED_VALUE | H5O_FILL_FLAG_HAVE_VALUE) +#define H5O_FILL_MASK_ALLOC_TIME 0x03 +#define H5O_FILL_SHIFT_ALLOC_TIME 0 +#define H5O_FILL_MASK_FILL_TIME 0x03 +#define H5O_FILL_SHIFT_FILL_TIME 2 +#define H5O_FILL_FLAG_UNDEFINED_VALUE 0x10 +#define H5O_FILL_FLAG_HAVE_VALUE 0x20 +#define H5O_FILL_FLAGS_ALL \ + (H5O_FILL_MASK_ALLOC_TIME | (H5O_FILL_MASK_FILL_TIME << H5O_FILL_SHIFT_FILL_TIME) | \ + H5O_FILL_FLAG_UNDEFINED_VALUE | H5O_FILL_FLAG_HAVE_VALUE) /* Declare a free list to manage the H5O_fill_t struct */ H5FL_DEFINE(H5O_fill_t); @@ -177,7 +176,6 @@ H5FL_DEFINE(H5O_fill_t); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - /*------------------------------------------------------------------------- * Function: H5O_fill_new_decode * @@ -195,27 +193,27 @@ H5FL_BLK_EXTERN(type_conv); */ static void * H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, + const uint8_t *p) { - H5O_fill_t *fill = NULL; - void *ret_value = NULL; /* Return value */ + H5O_fill_t *fill = NULL; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(f); HDassert(p); - if(NULL == (fill = H5FL_CALLOC(H5O_fill_t))) + if (NULL == (fill = H5FL_CALLOC(H5O_fill_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message") /* Version */ fill->version = *p++; - if(fill->version < H5O_FILL_VERSION_1 || fill->version > H5O_FILL_VERSION_LATEST) + if (fill->version < H5O_FILL_VERSION_1 || fill->version > H5O_FILL_VERSION_LATEST) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for fill value message") /* Decode each version */ - if(fill->version < H5O_FILL_VERSION_3) { + if (fill->version < H5O_FILL_VERSION_3) { /* Space allocation time */ fill->alloc_time = (H5D_alloc_time_t)*p++; @@ -226,51 +224,52 @@ H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, fill->fill_defined = *p++; /* Only decode fill value information if one is defined */ - if(fill->fill_defined) { + if (fill->fill_defined) { INT32DECODE(p, fill->size); - if(fill->size > 0) { + if (fill->size > 0) { H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t); - if((size_t)fill->size > p_size) + if ((size_t)fill->size > p_size) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "destination buffer too small") - if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) + if (NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") H5MM_memcpy(fill->buf, p, (size_t)fill->size); } /* end if */ - } /* end if */ + } /* end if */ else fill->size = (-1); } /* end if */ else { - unsigned flags; /* Status flags */ + unsigned flags; /* Status flags */ /* Flags */ flags = *p++; /* Check for unknown flags */ - if(flags & (unsigned)~H5O_FILL_FLAGS_ALL) + if (flags & (unsigned)~H5O_FILL_FLAGS_ALL) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unknown flag for fill value message") /* Space allocation time */ - fill->alloc_time = (H5D_alloc_time_t)((flags >> H5O_FILL_SHIFT_ALLOC_TIME) & H5O_FILL_MASK_ALLOC_TIME); + fill->alloc_time = + (H5D_alloc_time_t)((flags >> H5O_FILL_SHIFT_ALLOC_TIME) & H5O_FILL_MASK_ALLOC_TIME); /* Fill value write time */ fill->fill_time = (H5D_fill_time_t)((flags >> H5O_FILL_SHIFT_FILL_TIME) & H5O_FILL_MASK_FILL_TIME); /* Check for undefined fill value */ - if(flags & H5O_FILL_FLAG_UNDEFINED_VALUE) { + if (flags & H5O_FILL_FLAG_UNDEFINED_VALUE) { /* Sanity check */ HDassert(!(flags & H5O_FILL_FLAG_HAVE_VALUE)); /* Set value for "undefined" fill value */ fill->size = (-1); } /* end if */ - else if(flags & H5O_FILL_FLAG_HAVE_VALUE) { + else if (flags & H5O_FILL_FLAG_HAVE_VALUE) { /* Fill value size */ UINT32DECODE(p, fill->size); /* Fill value */ H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t); - if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) + if (NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") H5MM_memcpy(fill->buf, p, (size_t)fill->size); @@ -281,14 +280,14 @@ H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, /* Set the "defined" flag */ fill->fill_defined = TRUE; } /* end else */ - } /* end else */ + } /* end else */ /* Set return value */ ret_value = (void *)fill; done: - if(!ret_value && fill) { - if(fill->buf) + if (!ret_value && fill) { + if (fill->buf) H5MM_xfree(fill->buf); fill = H5FL_FREE(H5O_fill_t, fill); } /* end if */ @@ -296,7 +295,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_new_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_old_decode * @@ -311,49 +309,48 @@ done: *------------------------------------------------------------------------- */ static void * -H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t p_size, const uint8_t *p) +H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_fill_t *fill = NULL; /* Decoded fill value message */ - htri_t exists = FALSE; - H5T_t *dt = NULL; - void *ret_value = NULL; /* Return value */ + H5O_fill_t *fill = NULL; /* Decoded fill value message */ + htri_t exists = FALSE; + H5T_t * dt = NULL; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(f); HDassert(p); - if(NULL == (fill = H5FL_CALLOC(H5O_fill_t))) + if (NULL == (fill = H5FL_CALLOC(H5O_fill_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message") /* Set non-zero default fields */ - fill->version = H5O_FILL_VERSION_2; + fill->version = H5O_FILL_VERSION_2; fill->alloc_time = H5D_ALLOC_TIME_LATE; - fill->fill_time = H5D_FILL_TIME_IFSET; + fill->fill_time = H5D_FILL_TIME_IFSET; /* Fill value size */ UINT32DECODE(p, fill->size); /* Only decode the fill value itself if there is one */ - if(fill->size > 0) { + if (fill->size > 0) { H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t); - if((size_t)fill->size > p_size) + if ((size_t)fill->size > p_size) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "destination buffer too small") /* Get the datatype message */ - if((exists = H5O_msg_exists_oh(open_oh, H5O_DTYPE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(open_oh, H5O_DTYPE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read object header") - if(exists) { - if(NULL == (dt = (H5T_t *)H5O_msg_read_oh(f, open_oh, H5O_DTYPE_ID, NULL))) + if (exists) { + if (NULL == (dt = (H5T_t *)H5O_msg_read_oh(f, open_oh, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't read DTYPE message") /* Verify size */ - if(fill->size != (ssize_t)H5T_GET_SIZE(dt)) + if (fill->size != (ssize_t)H5T_GET_SIZE(dt)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "inconsistent fill value size") } /* end if */ - if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) + if (NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") H5MM_memcpy(fill->buf, p, (size_t)fill->size); fill->fill_defined = TRUE; @@ -362,14 +359,14 @@ H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, fill->size = (-1); /* Set return value */ - ret_value = (void*)fill; + ret_value = (void *)fill; done: - if(dt) + if (dt) H5O_msg_free(H5O_DTYPE_ID, dt); - if(!ret_value && fill) { - if(fill->buf) + if (!ret_value && fill) { + if (fill->buf) H5MM_xfree(fill->buf); fill = H5FL_FREE(H5O_fill_t, fill); } /* end if */ @@ -377,7 +374,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_old_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_new_encode * @@ -395,7 +391,7 @@ done: static herr_t H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) { - const H5O_fill_t *fill = (const H5O_fill_t *)_fill; + const H5O_fill_t *fill = (const H5O_fill_t *)_fill; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -406,7 +402,7 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) /* Version */ *p++ = (uint8_t)fill->version; - if(fill->version < H5O_FILL_VERSION_3) { + if (fill->version < H5O_FILL_VERSION_3) { /* Space allocation time */ *p++ = (uint8_t)fill->alloc_time; @@ -417,28 +413,29 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) *p++ = (uint8_t)fill->fill_defined; /* Only write out the size and fill value if it is defined */ - if(fill->fill_defined) { + if (fill->fill_defined) { UINT32ENCODE(p, fill->size); - if(fill->size > 0) - if(fill->buf) { + if (fill->size > 0) + if (fill->buf) { H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t); H5MM_memcpy(p, fill->buf, (size_t)fill->size); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { - uint8_t flags = 0; /* Fill value setting flags */ + uint8_t flags = 0; /* Fill value setting flags */ /* Encode space allocation time */ HDassert(fill->alloc_time == (H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time)); - flags = (uint8_t)(flags | ((H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time) << H5O_FILL_SHIFT_ALLOC_TIME)); + flags = + (uint8_t)(flags | ((H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time) << H5O_FILL_SHIFT_ALLOC_TIME)); /* Encode fill value writing time */ HDassert(fill->fill_time == (H5O_FILL_MASK_FILL_TIME & fill->fill_time)); flags = (uint8_t)(flags | ((H5O_FILL_MASK_FILL_TIME & fill->fill_time) << H5O_FILL_SHIFT_FILL_TIME)); /* Check if we need to encode a fill value size */ - if(fill->size < 0) { + if (fill->size < 0) { /* Indicate that the fill value has been "undefined" by the user */ flags |= H5O_FILL_FLAG_UNDEFINED_VALUE; @@ -448,7 +445,7 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) /* Sanity check */ HDassert(!fill->buf); } /* end if */ - else if(fill->size > 0) { + else if (fill->size > 0) { /* Indicate that a fill value size is present */ flags |= H5O_FILL_FLAG_HAVE_VALUE; @@ -470,12 +467,11 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) /* Sanity check */ HDassert(!fill->buf); } /* end else */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_fill_new_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_old_encode * @@ -500,13 +496,12 @@ H5O_fill_old_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) HDassert(fill && NULL == fill->type); UINT32ENCODE(p, fill->size); - if(fill->buf) + if (fill->buf) H5MM_memcpy(p, fill->buf, (size_t)fill->size); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_fill_old_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_copy * @@ -526,72 +521,74 @@ H5O_fill_old_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) static void * H5O_fill_copy(const void *_src, void *_dst) { - const H5O_fill_t *src = (const H5O_fill_t *)_src; - H5O_fill_t *dst = (H5O_fill_t *)_dst; - void *ret_value = NULL; /* Return value */ + const H5O_fill_t *src = (const H5O_fill_t *)_src; + H5O_fill_t * dst = (H5O_fill_t *)_dst; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(src); - if(!dst && NULL == (dst = H5FL_MALLOC(H5O_fill_t))) + if (!dst && NULL == (dst = H5FL_MALLOC(H5O_fill_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill message") /* Shallow copy basic fields */ *dst = *src; /* Copy data type of fill value */ - if(src->type) { - if(NULL == (dst->type = H5T_copy(src->type, H5T_COPY_TRANSIENT))) + if (src->type) { + if (NULL == (dst->type = H5T_copy(src->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "can't copy datatype") } /* end if */ else dst->type = NULL; /* Copy fill value and its size */ - if(src->buf) { + if (src->buf) { H5_CHECK_OVERFLOW(src->size, ssize_t, size_t); - if(NULL == (dst->buf = H5MM_malloc((size_t)src->size))) + if (NULL == (dst->buf = H5MM_malloc((size_t)src->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") H5MM_memcpy(dst->buf, src->buf, (size_t)src->size); /* Check for needing to convert/copy fill value */ - if(src->type) { - H5T_path_t *tpath; /* Conversion information */ + if (src->type) { + H5T_path_t *tpath; /* Conversion information */ /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(src->type, dst->type))) - HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, "unable to convert between src and dst data types") + if (NULL == (tpath = H5T_path_find(src->type, dst->type))) + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, + "unable to convert between src and dst data types") /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ - if(!H5T_path_noop(tpath)) { - hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */ - uint8_t *bkg_buf = NULL; /* Background conversion buffer */ - size_t bkg_size; /* Size of background buffer */ + if (!H5T_path_noop(tpath)) { + hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */ + uint8_t *bkg_buf = NULL; /* Background conversion buffer */ + size_t bkg_size; /* Size of background buffer */ /* Wrap copies of types to convert */ dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->type, H5T_COPY_TRANSIENT), FALSE); - if(dst_id < 0) + if (dst_id < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy/register datatype") src_id = H5I_register(H5I_DATATYPE, H5T_copy(src->type, H5T_COPY_ALL), FALSE); - if(src_id < 0) { + if (src_id < 0) { H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy/register datatype") } /* end if */ /* Allocate a background buffer */ bkg_size = MAX(H5T_get_size(dst->type), H5T_get_size(src->type)); - if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { + if (H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ /* Convert fill value */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, dst->buf, bkg_buf) < 0) { + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, dst->buf, bkg_buf) < + 0) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, NULL, "datatype conversion failed") } /* end if */ @@ -599,11 +596,11 @@ H5O_fill_copy(const void *_src, void *_dst) /* Release the background buffer */ H5I_dec_ref(src_id); H5I_dec_ref(dst_id); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else dst->buf = NULL; @@ -611,19 +608,18 @@ H5O_fill_copy(const void *_src, void *_dst) ret_value = dst; done: - if(!ret_value && dst) { - if(dst->buf) + if (!ret_value && dst) { + if (dst->buf) H5MM_xfree(dst->buf); - if(dst->type) + if (dst->type) (void)H5T_close_real(dst->type); - if(!_dst) + if (!_dst) dst = H5FL_FREE(H5O_fill_t, dst); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_new_size * @@ -644,8 +640,8 @@ done: static size_t H5O_fill_new_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) { - const H5O_fill_t *fill = (const H5O_fill_t *)_fill; - size_t ret_value = 0; /* Return value */ + const H5O_fill_t *fill = (const H5O_fill_t *)_fill; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -653,27 +649,26 @@ H5O_fill_new_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) HDassert(fill); /* Determine size for different versions */ - if(fill->version < H5O_FILL_VERSION_3) { - ret_value = 1 + /* Version number */ - 1 + /* Space allocation time */ - 1 + /* Fill value write time */ - 1; /* Fill value defined */ - if(fill->fill_defined) - ret_value += 4 + /* Fill value size */ - (fill->size > 0 ? (size_t)fill->size : 0); /* Size of fill value */ - } /* end if */ + if (fill->version < H5O_FILL_VERSION_3) { + ret_value = 1 + /* Version number */ + 1 + /* Space allocation time */ + 1 + /* Fill value write time */ + 1; /* Fill value defined */ + if (fill->fill_defined) + ret_value += 4 + /* Fill value size */ + (fill->size > 0 ? (size_t)fill->size : 0); /* Size of fill value */ + } /* end if */ else { - ret_value = 1 + /* Version number */ - 1; /* Status flags */ - if(fill->size > 0) - ret_value += 4 + /* Fill value size */ - (size_t)fill->size; /* Size of fill value */ - } /* end else */ + ret_value = 1 + /* Version number */ + 1; /* Status flags */ + if (fill->size > 0) + ret_value += 4 + /* Fill value size */ + (size_t)fill->size; /* Size of fill value */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_new_size() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_old_size * @@ -701,7 +696,6 @@ H5O_fill_old_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) FUNC_LEAVE_NOAPI(4 + (size_t)fill->size) } /* end H5O_fill_old_size() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_reset_dyn * @@ -717,32 +711,32 @@ H5O_fill_old_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) herr_t H5O_fill_reset_dyn(H5O_fill_t *fill) { - hid_t fill_type_id = -1; /* Datatype ID for fill value datatype when reclaiming VL fill values */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t fill_type_id = -1; /* Datatype ID for fill value datatype when reclaiming VL fill values */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(fill); - if(fill->buf) { - if(fill->type && H5T_detect_class(fill->type, H5T_VLEN, FALSE) > 0) { - H5T_t *fill_type; /* Copy of fill value datatype */ - H5S_t *fill_space; /* Scalar dataspace for fill value element */ + if (fill->buf) { + if (fill->type && H5T_detect_class(fill->type, H5T_VLEN, FALSE) > 0) { + H5T_t *fill_type; /* Copy of fill value datatype */ + H5S_t *fill_space; /* Scalar dataspace for fill value element */ /* Copy the fill value datatype and get an ID for it */ - if(NULL == (fill_type = H5T_copy(fill->type, H5T_COPY_TRANSIENT))) + if (NULL == (fill_type = H5T_copy(fill->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy fill value datatype") - if((fill_type_id = H5I_register(H5I_DATATYPE, fill_type, FALSE)) < 0) { + if ((fill_type_id = H5I_register(H5I_DATATYPE, fill_type, FALSE)) < 0) { (void)H5T_close_real(fill_type); HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register fill value datatype") } /* end if */ /* Create a scalar dataspace for the fill value element */ - if(NULL == (fill_space = H5S_create(H5S_SCALAR))) + if (NULL == (fill_space = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create scalar dataspace") /* Reclaim any variable length components of the fill value */ - if(H5T_reclaim(fill_type_id, fill_space, fill->buf) < 0) { + if (H5T_reclaim(fill_type_id, fill_space, fill->buf) < 0) { H5S_close(fill_space); HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "unable to reclaim variable-length fill value data") } /* end if */ @@ -755,19 +749,18 @@ H5O_fill_reset_dyn(H5O_fill_t *fill) fill->buf = H5MM_xfree(fill->buf); } /* end if */ fill->size = 0; - if(fill->type) { + if (fill->type) { (void)H5T_close_real(fill->type); fill->type = NULL; } /* end if */ done: - if(fill_type_id > 0 && H5I_dec_ref(fill_type_id) < 0) + if (fill_type_id > 0 && H5I_dec_ref(fill_type_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_reset_dyn() */ - /*------------------------------------------------------------------------- * Function: H5O__fill_reset * @@ -783,7 +776,7 @@ done: static herr_t H5O__fill_reset(void *_fill) { - H5O_fill_t *fill = (H5O_fill_t *)_fill; + H5O_fill_t *fill = (H5O_fill_t *)_fill; FUNC_ENTER_STATIC_NOERR @@ -800,7 +793,6 @@ H5O__fill_reset(void *_fill) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fill_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__fill_free * @@ -825,7 +817,6 @@ H5O__fill_free(void *fill) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fill_free() */ - /*------------------------------------------------------------------------- * Function: H5O__fill_pre_copy_file * @@ -840,11 +831,11 @@ H5O__fill_free(void *fill) *------------------------------------------------------------------------- */ static herr_t -H5O__fill_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, - hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__fill_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, hbool_t H5_ATTR_UNUSED *deleted, + const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) { - const H5O_fill_t *fill_src = (const H5O_fill_t *)mesg_src; /* Source fill value */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_fill_t *fill_src = (const H5O_fill_t *)mesg_src; /* Source fill value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -854,14 +845,13 @@ H5O__fill_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version allowed by the destination file's high bound */ - if(fill_src->version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (fill_src->version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "fill value message version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__fill_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__fill_debug * @@ -875,11 +865,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, - int indent, int fwidth) +H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, int indent, int fwidth) { const H5O_fill_t *fill = (const H5O_fill_t *)_fill; - H5D_fill_value_t fill_status; /* Whether the fill value is defined */ + H5D_fill_value_t fill_status; /* Whether the fill value is defined */ FUNC_ENTER_STATIC_NOERR @@ -890,70 +879,69 @@ H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Space Allocation Time:"); - switch(fill->alloc_time) { + switch (fill->alloc_time) { case H5D_ALLOC_TIME_EARLY: - HDfprintf(stream,"Early\n"); + HDfprintf(stream, "Early\n"); break; case H5D_ALLOC_TIME_LATE: - HDfprintf(stream,"Late\n"); + HDfprintf(stream, "Late\n"); break; case H5D_ALLOC_TIME_INCR: - HDfprintf(stream,"Incremental\n"); + HDfprintf(stream, "Incremental\n"); break; case H5D_ALLOC_TIME_DEFAULT: case H5D_ALLOC_TIME_ERROR: default: - HDfprintf(stream,"Unknown!\n"); + HDfprintf(stream, "Unknown!\n"); break; } /* end switch */ HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Time:"); - switch(fill->fill_time) { + switch (fill->fill_time) { case H5D_FILL_TIME_ALLOC: - HDfprintf(stream,"On Allocation\n"); + HDfprintf(stream, "On Allocation\n"); break; case H5D_FILL_TIME_NEVER: - HDfprintf(stream,"Never\n"); + HDfprintf(stream, "Never\n"); break; case H5D_FILL_TIME_IFSET: - HDfprintf(stream,"If Set\n"); + HDfprintf(stream, "If Set\n"); break; case H5D_FILL_TIME_ERROR: default: - HDfprintf(stream,"Unknown!\n"); + HDfprintf(stream, "Unknown!\n"); break; } /* end switch */ HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Value Defined:"); H5P_is_fill_value_defined((const H5O_fill_t *)fill, &fill_status); - switch(fill_status) { + switch (fill_status) { case H5D_FILL_VALUE_UNDEFINED: - HDfprintf(stream,"Undefined\n"); + HDfprintf(stream, "Undefined\n"); break; case H5D_FILL_VALUE_DEFAULT: - HDfprintf(stream,"Default\n"); + HDfprintf(stream, "Default\n"); break; case H5D_FILL_VALUE_USER_DEFINED: - HDfprintf(stream,"User Defined\n"); + HDfprintf(stream, "User Defined\n"); break; case H5D_FILL_VALUE_ERROR: default: - HDfprintf(stream,"Unknown!\n"); + HDfprintf(stream, "Unknown!\n"); break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %Zd\n", indent, "", fwidth, - "Size:", fill->size); + HDfprintf(stream, "%*s%-*s %Zd\n", indent, "", fwidth, "Size:", fill->size); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Data type:"); - if(fill->type) { + if (fill->type) { H5T_debug(fill->type, stream); HDfprintf(stream, "\n"); } /* end if */ @@ -963,7 +951,6 @@ H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fill_debug() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_convert * @@ -982,10 +969,10 @@ H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, herr_t H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) { - H5T_path_t *tpath; /* Type conversion info */ - void *buf = NULL, *bkg = NULL; /* Conversion buffers */ - hid_t src_id = -1, dst_id = -1; /* Datatype identifiers */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_path_t *tpath; /* Type conversion info */ + void * buf = NULL, *bkg = NULL; /* Conversion buffers */ + hid_t src_id = -1, dst_id = -1; /* Datatype identifiers */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -994,9 +981,9 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) HDassert(fill_changed); /* No-op cases */ - if(!fill->buf || !fill->type || 0 == H5T_cmp(fill->type, dset_type, FALSE)) { + if (!fill->buf || !fill->type || 0 == H5T_cmp(fill->type, dset_type, FALSE)) { /* Don't need datatype for fill value */ - if(fill->type) + if (fill->type) (void)H5T_close_real(fill->type); fill->type = NULL; @@ -1009,38 +996,38 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) /* * Can we convert between source and destination data types? */ - if(NULL == (tpath = H5T_path_find(fill->type, dset_type))) + if (NULL == (tpath = H5T_path_find(fill->type, dset_type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") /* Don't bother doing anything if there will be no actual conversion */ - if(!H5T_path_noop(tpath)) { - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill->type, H5T_COPY_ALL), FALSE)) < 0 || - (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dset_type, H5T_COPY_ALL), FALSE)) < 0) + if (!H5T_path_noop(tpath)) { + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill->type, H5T_COPY_ALL), FALSE)) < 0 || + (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dset_type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy/register data type") /* * Datatype conversions are always done in place, so we need a buffer * that is large enough for both source and destination. */ - if(H5T_get_size(fill->type) >= H5T_get_size(dset_type)) + if (H5T_get_size(fill->type) >= H5T_get_size(dset_type)) buf = fill->buf; else { - if(NULL == (buf = H5MM_malloc(H5T_get_size(dset_type)))) + if (NULL == (buf = H5MM_malloc(H5T_get_size(dset_type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") H5MM_memcpy(buf, fill->buf, H5T_get_size(fill->type)); } /* end else */ /* Use CALLOC here to clear the buffer in case later the library thinks there's * data in the background. */ - if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(dset_type)))) + if (H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(dset_type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") /* Do the conversion */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Update the fill message */ - if(buf != fill->buf) { + if (buf != fill->buf) { H5T_vlen_reclaim_elmt(fill->buf, fill->type); H5MM_xfree(fill->buf); fill->buf = buf; @@ -1054,19 +1041,18 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) } /* end if */ done: - if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + if (src_id >= 0 && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") - if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") - if(buf != fill->buf) + if (buf != fill->buf) H5MM_xfree(buf); - if(bkg) + if (bkg) H5MM_xfree(bkg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_convert() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_set_version * @@ -1081,8 +1067,8 @@ done: herr_t H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1094,7 +1080,7 @@ H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) version = MAX(fill->version, H5O_fill_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "Filter pipeline version out of bounds") /* Set the message version */ @@ -1103,4 +1089,3 @@ H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_set_version() */ - diff --git a/src/H5Oflush.c b/src/H5Oflush.c index eeed75e..143694b 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -26,39 +26,35 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ -#define H5D_FRIEND /* Suppress error about including H5Dpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Errors */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Opkg.h" /* Objects */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Errors */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Opkg.h" /* Objects */ +#include "H5Tpkg.h" /* Datatypes */ /********************/ /* Local Prototypes */ /********************/ static herr_t H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag); -static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, - H5G_loc_t *obj_loc); - +static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc); /*************/ /* Functions */ /*************/ - - /*------------------------------------------------------------------------- * Function: H5Oflush * @@ -74,34 +70,34 @@ static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, herr_t H5Oflush(hid_t obj_id) { - H5VL_object_t *vol_obj = NULL; /* Object of obj_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of obj_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", obj_id); /* Check args */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(obj_id) < 0) + if (H5CX_set_loc(obj_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(obj_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); /* Flush the object */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_id) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_FLUSH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oflush() */ - /*------------------------------------------------------------------------- * Function: H5O_flush * @@ -118,33 +114,32 @@ done: herr_t H5O_flush(H5O_loc_t *oloc, hid_t obj_id) { - void *obj_ptr; /* Pointer to object */ - const H5O_obj_class_t *obj_class; /* Class of object */ - herr_t ret_value = SUCCEED; /* Return value */ + void * obj_ptr; /* Pointer to object */ + const H5O_obj_class_t *obj_class; /* Class of object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the object pointer */ - if(NULL == (obj_ptr = H5VL_object(obj_id))) + if (NULL == (obj_ptr = H5VL_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the object class */ - if(NULL == (obj_class = H5O__obj_class(oloc))) + if (NULL == (obj_class = H5O__obj_class(oloc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object class") /* Flush the object of this class */ - if(obj_class->flush && obj_class->flush(obj_ptr) < 0) + if (obj_class->flush && obj_class->flush(obj_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") /* Flush the object metadata and invoke flush callback */ - if(H5O_flush_common(oloc, obj_id) < 0) + if (H5O_flush_common(oloc, obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object and object flush callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_flush() */ - /*------------------------------------------------------------------------- * Function: H5O_flush_common * @@ -160,28 +155,27 @@ done: herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id) { - haddr_t tag = 0; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t tag = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Retrieve tag for object */ - if(H5O__oh_tag(oloc, &tag) < 0) + if (H5O__oh_tag(oloc, &tag) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object metadata") /* Flush metadata based on tag value of the object */ - if(H5F_flush_tagged_metadata(oloc->file, tag) < 0) + if (H5F_flush_tagged_metadata(oloc->file, tag) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") /* Check to invoke callback */ - if(H5F_object_flush_cb(oloc->file, obj_id) < 0) + if (H5F_object_flush_cb(oloc->file, obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to do object flush callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_flush_common() */ - /*------------------------------------------------------------------------- * Function: H5O__oh_tag * @@ -198,8 +192,8 @@ done: static herr_t H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -207,22 +201,21 @@ H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag) HDassert(oloc); /* Get object header for object */ - if(NULL == (oh = H5O_protect(oloc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(oloc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object's object header") /* Get object header's address (i.e. the tag value for this object) */ - if(HADDR_UNDEF == (*tag = H5O_OH_GET_ADDR(oh))) + if (HADDR_UNDEF == (*tag = H5O_OH_GET_ADDR(oh))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get address of object header") done: /* Unprotect object header on failure */ - if(oh && H5O_unprotect(oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__oh_tag() */ - /*------------------------------------------------------------------------- * Function: H5Orefresh * @@ -238,34 +231,34 @@ done: herr_t H5Orefresh(hid_t oid) { - H5VL_object_t *vol_obj = NULL; /* Object of oid */ - H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of oid */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", oid); /* Check args */ - if(NULL == (vol_obj = H5VL_vol_object(oid))) + if (NULL == (vol_obj = H5VL_vol_object(oid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(oid) < 0) + if (H5CX_set_loc(oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(oid); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(oid); /* Refresh the object */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oid) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") done: FUNC_LEAVE_API(ret_value) } /* end H5Orefresh() */ - /*------------------------------------------------------------------------- * Function: H5O_refresh_metadata * @@ -289,20 +282,20 @@ done: herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) { - hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* If the file is opened with write access, no need to perform refresh actions. */ - if(!(H5F_INTENT(oloc.file) & H5F_ACC_RDWR)) { - H5G_loc_t obj_loc; - H5O_loc_t obj_oloc; - H5G_name_t obj_path; - H5O_refresh_state_t state; - H5D_t *ds; + if (!(H5F_INTENT(oloc.file) & H5F_ACC_RDWR)) { + H5G_loc_t obj_loc; + H5O_loc_t obj_oloc; + H5G_name_t obj_path; + H5O_refresh_state_t state; + H5D_t * ds; const H5VL_object_t *vol_obj; - H5VL_t *connector = NULL; + H5VL_t * connector = NULL; /* Create empty object location */ obj_loc.oloc = &obj_oloc; @@ -319,26 +312,24 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) * The vol_obj will disappear when the underlying object is closed, so * we can't use that directly. */ - if(NULL == (vol_obj = H5VL_vol_object(oid))) + if (NULL == (vol_obj = H5VL_vol_object(oid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") connector = vol_obj->connector; /* Save important datatype state */ switch (H5I_get_type(oid)) { - case H5I_DATATYPE: - if (H5T_save_refresh_state(oid, &state.shared_ohdr_info) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, - "unable to save datatype state"); - break; - case H5I_DATASET: - ds = (H5D_t *)vol_obj->data; - state.dapl_id = ds->shared->dapl_id; - if (H5I_inc_ref(state.dapl_id, false) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "could not increase refcnt"); - break; - default: - break; + case H5I_DATATYPE: + if (H5T_save_refresh_state(oid, &state.shared_ohdr_info) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to save datatype state"); + break; + case H5I_DATASET: + ds = (H5D_t *)vol_obj->data; + state.dapl_id = ds->shared->dapl_id; + if (H5I_inc_ref(state.dapl_id, false) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not increase refcnt"); + break; + default: + break; } /* Bump the number of references on the VOL connector. @@ -347,12 +338,11 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) connector->nrefs++; /* Close object & evict its metadata */ - if((H5O__refresh_metadata_close(oid, oloc, &obj_loc)) < 0) + if ((H5O__refresh_metadata_close(oid, oloc, &obj_loc)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Re-open the object, re-fetching its metadata */ - if (H5O_refresh_metadata_reopen(oid, &obj_loc, &state, connector, - FALSE) < 0) + if (H5O_refresh_metadata_reopen(oid, &obj_loc, &state, connector, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Restore the number of references on the VOL connector */ @@ -360,29 +350,27 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) /* Restore important datatype state */ switch (H5I_get_type(oid)) { - case H5I_DATATYPE: - if(H5T_restore_refresh_state(oid, &state.shared_ohdr_info) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to restore datatype state") - break; - case H5I_DATASET: - if (H5I_dec_ref(state.dapl_id) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "could not decrease refcnt"); - break; - default: - break; + case H5I_DATATYPE: + if (H5T_restore_refresh_state(oid, &state.shared_ohdr_info) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to restore datatype state") + break; + case H5I_DATASET: + if (H5I_dec_ref(state.dapl_id) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not decrease refcnt"); + break; + default: + break; } } /* end if */ done: - if(objs_incr) + if (objs_incr) H5F_decr_nopen_objs(oloc.file); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_refresh_metadata() */ - /*------------------------------------------------------------------------- * Function: H5O__refresh_metadata_close * @@ -405,14 +393,14 @@ done: static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc) { - haddr_t tag = 0; /* Tag for object */ - hbool_t corked = FALSE; /* Whether object's metadata is corked */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t tag = 0; /* Tag for object */ + hbool_t corked = FALSE; /* Whether object's metadata is corked */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make deep local copy of object's location information */ - if(obj_loc) { + if (obj_loc) { H5G_loc_t tmp_loc; H5G_loc(oid, &tmp_loc); @@ -420,40 +408,39 @@ H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc) } /* end if */ /* Handle close for multiple dataset opens */ - if(H5I_get_type(oid) == H5I_DATASET) - if(H5D_mult_refresh_close(oid) < 0) + if (H5I_get_type(oid) == H5I_DATASET) + if (H5D_mult_refresh_close(oid) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to prepare refresh for dataset") /* Retrieve tag for object */ - if(H5O__oh_tag(&oloc, &tag) < 0) + if (H5O__oh_tag(&oloc, &tag) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to get object header address") /* Get cork status of the object with tag */ - if(H5AC_cork(oloc.file, tag, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(oloc.file, tag, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_ATOM, H5E_SYSTEM, FAIL, "unable to retrieve an object's cork status") /* Close the object */ - if(H5I_dec_ref(oid) < 0) + if (H5I_dec_ref(oid) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to close object") /* Flush metadata based on tag value of the object */ - if(H5F_flush_tagged_metadata(oloc.file, tag) < 0) + if (H5F_flush_tagged_metadata(oloc.file, tag) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") /* Evict the object's tagged metadata */ - if(H5F_evict_tagged_metadata(oloc.file, tag) < 0) + if (H5F_evict_tagged_metadata(oloc.file, tag) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to evict metadata") /* Re-cork object with tag */ - if(corked) - if(H5AC_cork(oloc.file, tag, H5AC__SET_CORK, &corked) < 0) + if (corked) + if (H5AC_cork(oloc.file, tag, H5AC__SET_CORK, &corked) < 0) HGOTO_ERROR(H5E_ATOM, H5E_SYSTEM, FAIL, "unable to cork the object") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O__refresh_metadata_close() */ - /*------------------------------------------------------------------------- * Function: H5O_refresh_metadata_reopen * @@ -469,12 +456,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, - const H5O_refresh_state_t *state, H5VL_t *vol_connector, hbool_t start_swmr) +H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, const H5O_refresh_state_t *state, + H5VL_t *vol_connector, hbool_t start_swmr) { - void *object = NULL; /* Object for this operation */ - H5I_type_t type; /* Type of object for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + void * object = NULL; /* Object for this operation */ + H5I_type_t type; /* Type of object for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -485,28 +472,26 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, /* Get object's type */ type = H5I_get_type(oid); - switch(type) { + switch (type) { case H5I_GROUP: /* Re-open the group */ - if(NULL == (object = H5G_open(obj_loc))) + if (NULL == (object = H5G_open(obj_loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open group") break; case H5I_DATATYPE: /* Re-open the named datatype */ - if(NULL == (object = H5T_open(obj_loc))) + if (NULL == (object = H5T_open(obj_loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") break; case H5I_DATASET: - object = H5D_open(obj_loc, - (state == NULL) ? H5P_DATASET_ACCESS_DEFAULT : state->dapl_id); - if(NULL == object) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, - "unable to open dataset"); + object = H5D_open(obj_loc, (state == NULL) ? H5P_DATASET_ACCESS_DEFAULT : state->dapl_id); + if (NULL == object) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset"); } - if(!start_swmr) /* No need to handle multiple opens when H5Fstart_swmr_write() */ - if(H5D_mult_refresh_reopen((H5D_t *)object) < 0) + if (!start_swmr) /* No need to handle multiple opens when H5Fstart_swmr_write() */ + if (H5D_mult_refresh_reopen((H5D_t *)object) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to finish refresh for dataset") break; @@ -528,15 +513,15 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, case H5I_SPACE_SEL_ITER: case H5I_NTYPES: default: - HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "not a valid file object ID (dataset, group, or datatype)") - break; + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, + "not a valid file object ID (dataset, group, or datatype)") + break; } /* end switch */ /* Re-register ID for the object */ - if((H5VL_register_using_existing_id(type, object, vol_connector, TRUE, oid)) < 0) + if ((H5VL_register_using_existing_id(type, object, vol_connector, TRUE, oid)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to re-register object ID after refresh") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_refresh_metadata_reopen() */ - diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index e2fa4e5..3dfb3f3 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -21,65 +21,62 @@ * *------------------------------------------------------------------------- */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O_fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O_fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_fsinfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_fsinfo_copy(const void *_mesg, void *_dest); +static void * H5O_fsinfo_copy(const void *_mesg, void *_dest); static size_t H5O_fsinfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__fsinfo_free(void *mesg); -static herr_t H5O__fsinfo_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__fsinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_FSINFO[1] = {{ - H5O_FSINFO_ID, /* message id number */ - "fsinfo", /* message name for debugging */ - sizeof(H5O_fsinfo_t), /* native message size */ - 0, /* messages are sharable? */ - H5O_fsinfo_decode, /* decode message */ - H5O_fsinfo_encode, /* encode message */ - H5O_fsinfo_copy, /* copy the native value */ - H5O_fsinfo_size, /* size of free-space manager info message */ - NULL, /* default reset method */ - H5O__fsinfo_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__fsinfo_debug /* debug the message */ + H5O_FSINFO_ID, /* message id number */ + "fsinfo", /* message name for debugging */ + sizeof(H5O_fsinfo_t), /* native message size */ + 0, /* messages are sharable? */ + H5O_fsinfo_decode, /* decode message */ + H5O_fsinfo_encode, /* encode message */ + H5O_fsinfo_copy, /* copy the native value */ + H5O_fsinfo_size, /* size of free-space manager info message */ + NULL, /* default reset method */ + H5O__fsinfo_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__fsinfo_debug /* debug the message */ }}; /* Format version bounds for fsinfo message */ /* This message exists starting library release v1.10 */ static const unsigned H5O_fsinfo_ver_bounds[] = { - H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */ - H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */ - H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */ - H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V112 */ - H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */ + H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */ + H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */ + H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V112 */ + H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; -#define N_FSINFO_VERSION_BOUNDS H5F_LIBVER_NBOUNDS +#define N_FSINFO_VERSION_BOUNDS H5F_LIBVER_NBOUNDS /* Declare a free list to manage the H5O_fsinfo_t struct */ H5FL_DEFINE_STATIC(H5O_fsinfo_t); - /*------------------------------------------------------------------------- * Function: H5O_fsinfo_decode * @@ -93,14 +90,13 @@ H5FL_DEFINE_STATIC(H5O_fsinfo_t); *------------------------------------------------------------------------- */ static void * -H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_fsinfo_t *fsinfo = NULL; /* File space info message */ - H5F_mem_page_t ptype; /* Memory type for iteration */ - unsigned vers; /* message version */ - void *ret_value = NULL; /* Return value */ + H5O_fsinfo_t * fsinfo = NULL; /* File space info message */ + H5F_mem_page_t ptype; /* Memory type for iteration */ + unsigned vers; /* message version */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -109,44 +105,44 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Allocate space for message */ - if(NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) + if (NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo->fs_addr[ptype - 1] = HADDR_UNDEF; /* Version of message */ vers = *p++; - if(vers == H5O_FSINFO_VERSION_0) { - H5F_file_space_type_t strategy; /* Strategy */ - hsize_t threshold; /* Threshold */ - H5FD_mem_t type; /* Memory type for iteration */ + if (vers == H5O_FSINFO_VERSION_0) { + H5F_file_space_type_t strategy; /* Strategy */ + hsize_t threshold; /* Threshold */ + H5FD_mem_t type; /* Memory type for iteration */ - fsinfo->persist = H5F_FREE_SPACE_PERSIST_DEF; - fsinfo->threshold = H5F_FREE_SPACE_THRESHOLD_DEF; - fsinfo->page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; - fsinfo->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; + fsinfo->persist = H5F_FREE_SPACE_PERSIST_DEF; + fsinfo->threshold = H5F_FREE_SPACE_THRESHOLD_DEF; + fsinfo->page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; + fsinfo->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; fsinfo->eoa_pre_fsm_fsalloc = HADDR_UNDEF; strategy = (H5F_file_space_type_t)*p++; /* File space strategy */ H5F_DECODE_LENGTH(f, p, threshold); /* Free-space section threshold */ /* Map version 0 (deprecated) to version 1 message */ - switch(strategy) { + switch (strategy) { case H5F_FILE_SPACE_ALL_PERSIST: - fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; - fsinfo->persist = TRUE; + fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + fsinfo->persist = TRUE; fsinfo->threshold = threshold; - if(HADDR_UNDEF == (fsinfo->eoa_pre_fsm_fsalloc = H5F_get_eoa(f, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (fsinfo->eoa_pre_fsm_fsalloc = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get file size") - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) - H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type-1])); + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) + H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type - 1])); break; case H5F_FILE_SPACE_ALL: - fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fsinfo->threshold = threshold; break; @@ -165,23 +161,24 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, } /* end switch */ fsinfo->version = H5O_FSINFO_VERSION_1; - fsinfo->mapped = TRUE; - - } else { + fsinfo->mapped = TRUE; + } + else { HDassert(vers >= H5O_FSINFO_VERSION_1); - fsinfo->version = vers; + fsinfo->version = vers; fsinfo->strategy = (H5F_fspace_strategy_t)*p++; /* File space strategy */ - fsinfo->persist = *p++; /* Free-space persist or not */ + fsinfo->persist = *p++; /* Free-space persist or not */ H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section threshold */ H5F_DECODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ UINT16DECODE(p, fsinfo->pgend_meta_thres); /* Page end metdata threshold */ - H5F_addr_decode(f, &p, &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ + H5F_addr_decode(f, &p, + &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ /* Decode addresses of free space managers, if persisting */ - if(fsinfo->persist) { - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + if (fsinfo->persist) { + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) H5F_addr_decode(f, &p, &(fsinfo->fs_addr[ptype - 1])); } /* end if */ @@ -192,13 +189,12 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = fsinfo; done: - if(ret_value == NULL && fsinfo != NULL) + if (ret_value == NULL && fsinfo != NULL) fsinfo = H5FL_FREE(H5O_fsinfo_t, fsinfo); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fsinfo_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_fsinfo_encode * @@ -213,8 +209,8 @@ done: static herr_t H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - H5F_mem_page_t ptype; /* Memory type for iteration */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + H5F_mem_page_t ptype; /* Memory type for iteration */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -223,26 +219,25 @@ H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c HDassert(p); HDassert(fsinfo); - *p++ = (uint8_t)fsinfo->version; /* message version */ - *p++ = (uint8_t)fsinfo->strategy; /* File space strategy */ - *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ + *p++ = (uint8_t)fsinfo->version; /* message version */ + *p++ = (uint8_t)fsinfo->strategy; /* File space strategy */ + *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ H5F_ENCODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section size threshold */ - H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ - UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ - H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ + H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ + UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ + H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ /* Store addresses of free-space managers, if persisting */ - if(fsinfo->persist) { + if (fsinfo->persist) { /* Addresses of free-space managers */ - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) H5F_addr_encode(f, &p, fsinfo->fs_addr[ptype - 1]); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_fsinfo_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_fsinfo_copy * @@ -259,15 +254,15 @@ H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c static void * H5O_fsinfo_copy(const void *_mesg, void *_dest) { - const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - H5O_fsinfo_t *dest = (H5O_fsinfo_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + H5O_fsinfo_t * dest = (H5O_fsinfo_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(fsinfo); - if(!dest && NULL == (dest = H5FL_CALLOC(H5O_fsinfo_t))) + if (!dest && NULL == (dest = H5FL_CALLOC(H5O_fsinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -280,7 +275,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fsinfo_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_fsinfo_size * @@ -298,25 +292,24 @@ done: static size_t H5O_fsinfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - ret_value = 3 /* Version, strategy & persist */ - + (size_t)H5F_SIZEOF_SIZE(f) /* Free-space section threshold */ - + (size_t)H5F_SIZEOF_SIZE(f) /* File space page size */ - + 2 /* Page end meta threshold */ - + (size_t)H5F_SIZEOF_ADDR(f); + ret_value = 3 /* Version, strategy & persist */ + + (size_t)H5F_SIZEOF_SIZE(f) /* Free-space section threshold */ + + (size_t)H5F_SIZEOF_SIZE(f) /* File space page size */ + + 2 /* Page end meta threshold */ + + (size_t)H5F_SIZEOF_ADDR(f); /* Free-space manager addresses */ - if(fsinfo->persist) + if (fsinfo->persist) ret_value += (H5F_MEM_PAGE_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fsinfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__fsinfo_free * @@ -340,7 +333,6 @@ H5O__fsinfo_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fsinfo_free() */ - /*------------------------------------------------------------------------- * Function: H5O_fsinfo_set_version * @@ -355,8 +347,8 @@ H5O__fsinfo_free(void *mesg) herr_t H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -367,11 +359,11 @@ H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo version = H5O_FSINFO_VERSION_1; /* Upgrade to the version indicated by the file's low bound if higher */ - if(H5O_fsinfo_ver_bounds[low] != H5O_INVALID_VERSION) + if (H5O_fsinfo_ver_bounds[low] != H5O_INVALID_VERSION) version = MAX(version, H5O_fsinfo_ver_bounds[low]); /* Version bounds check */ - if(H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || version > H5O_fsinfo_ver_bounds[high]) + if (H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || version > H5O_fsinfo_ver_bounds[high]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") /* Set the message version */ @@ -381,7 +373,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fsinfo_set_version() */ - /*------------------------------------------------------------------------- * Function: H5O_fsinfo_check_version * @@ -406,14 +397,13 @@ H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo) HDassert(fsinfo); /* Check the version */ - if(H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || fsinfo->version > H5O_fsinfo_ver_bounds[high]) + if (H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || fsinfo->version > H5O_fsinfo_ver_bounds[high]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fsinfo_check_version() */ - /*------------------------------------------------------------------------- * Function: H5O__fsinfo_debug * @@ -426,11 +416,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *) _mesg; - H5F_mem_page_t ptype; /* Free-space types for iteration */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + H5F_mem_page_t ptype; /* Free-space types for iteration */ FUNC_ENTER_STATIC_NOERR @@ -442,7 +431,7 @@ H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "File space strategy:"); - switch(fsinfo->strategy) { + switch (fsinfo->strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: HDfprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_FSM_AGGR"); break; @@ -464,14 +453,12 @@ H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDfprintf(stream, "%s\n", "unknown"); } /* end switch */ - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Free-space persist:", fsinfo->persist); + HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, "Free-space persist:", fsinfo->persist); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Free-space section threshold:", fsinfo->threshold); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "File space page size:", fsinfo->page_size); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "File space page size:", fsinfo->page_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Page end metadata threshold:", fsinfo->pgend_meta_thres); @@ -479,12 +466,11 @@ H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "eoa_pre_fsm_fsalloc:", fsinfo->eoa_pre_fsm_fsalloc); - if(fsinfo->persist) { - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + if (fsinfo->persist) { + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Free space manager address:", fsinfo->fs_addr[ptype-1]); + "Free space manager address:", fsinfo->fs_addr[ptype - 1]); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fsinfo_debug() */ - diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c index d6190c6..499c245 100644 --- a/src/H5Oginfo.c +++ b/src/H5Oginfo.c @@ -22,61 +22,57 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O_ginfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void *H5O_ginfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); static herr_t H5O_ginfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_ginfo_copy(const void *_mesg, void *_dest); +static void * H5O_ginfo_copy(const void *_mesg, void *_dest); static size_t H5O_ginfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__ginfo_free(void *_mesg); -static herr_t H5O__ginfo_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__ginfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_GINFO[1] = {{ - H5O_GINFO_ID, /*message id number */ - "ginfo", /*message name for debugging */ - sizeof(H5O_ginfo_t), /*native message size */ - 0, /* messages are sharable? */ - H5O_ginfo_decode, /*decode message */ - H5O_ginfo_encode, /*encode message */ - H5O_ginfo_copy, /*copy the native value */ - H5O_ginfo_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__ginfo_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__ginfo_debug /*debug the message */ + H5O_GINFO_ID, /*message id number */ + "ginfo", /*message name for debugging */ + sizeof(H5O_ginfo_t), /*native message size */ + 0, /* messages are sharable? */ + H5O_ginfo_decode, /*decode message */ + H5O_ginfo_encode, /*encode message */ + H5O_ginfo_copy, /*copy the native value */ + H5O_ginfo_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__ginfo_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__ginfo_debug /*debug the message */ }}; /* Current version of group info information */ -#define H5O_GINFO_VERSION 0 +#define H5O_GINFO_VERSION 0 /* Flags for group info flag encoding */ -#define H5O_GINFO_STORE_PHASE_CHANGE 0x01 -#define H5O_GINFO_STORE_EST_ENTRY_INFO 0x02 -#define H5O_GINFO_ALL_FLAGS (H5O_GINFO_STORE_PHASE_CHANGE | H5O_GINFO_STORE_EST_ENTRY_INFO) +#define H5O_GINFO_STORE_PHASE_CHANGE 0x01 +#define H5O_GINFO_STORE_EST_ENTRY_INFO 0x02 +#define H5O_GINFO_ALL_FLAGS (H5O_GINFO_STORE_PHASE_CHANGE | H5O_GINFO_STORE_EST_ENTRY_INFO) /* Declare a free list to manage the H5O_ginfo_t struct */ H5FL_DEFINE_STATIC(H5O_ginfo_t); - /*------------------------------------------------------------------------- * Function: H5O_ginfo_decode * @@ -94,13 +90,12 @@ H5FL_DEFINE_STATIC(H5O_ginfo_t); *------------------------------------------------------------------------- */ static void * -H5O_ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O_ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_ginfo_t *ginfo = NULL; /* Pointer to group information message */ - unsigned char flags; /* Flags for encoding group info */ - void *ret_value = NULL; /* Return value */ + H5O_ginfo_t * ginfo = NULL; /* Pointer to group information message */ + unsigned char flags; /* Flags for encoding group info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -108,52 +103,51 @@ H5O_ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_GINFO_VERSION) + if (*p++ != H5O_GINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (ginfo = H5FL_CALLOC(H5O_ginfo_t))) + if (NULL == (ginfo = H5FL_CALLOC(H5O_ginfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the flags for the group */ flags = *p++; - if(flags & ~H5O_GINFO_ALL_FLAGS) + if (flags & ~H5O_GINFO_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") ginfo->store_link_phase_change = (flags & H5O_GINFO_STORE_PHASE_CHANGE) ? TRUE : FALSE; - ginfo->store_est_entry_info = (flags & H5O_GINFO_STORE_EST_ENTRY_INFO) ? TRUE : FALSE; + ginfo->store_est_entry_info = (flags & H5O_GINFO_STORE_EST_ENTRY_INFO) ? TRUE : FALSE; /* Get the max. # of links to store compactly & the min. # of links to store densely */ - if(ginfo->store_link_phase_change) { + if (ginfo->store_link_phase_change) { UINT16DECODE(p, ginfo->max_compact) UINT16DECODE(p, ginfo->min_dense) } /* end if */ else { ginfo->max_compact = H5G_CRT_GINFO_MAX_COMPACT; - ginfo->min_dense = H5G_CRT_GINFO_MIN_DENSE; + ginfo->min_dense = H5G_CRT_GINFO_MIN_DENSE; } /* end else */ /* Get the estimated # of entries & name lengths */ - if(ginfo->store_est_entry_info) { + if (ginfo->store_est_entry_info) { UINT16DECODE(p, ginfo->est_num_entries) UINT16DECODE(p, ginfo->est_name_len) } /* end if */ else { ginfo->est_num_entries = H5G_CRT_GINFO_EST_NUM_ENTRIES; - ginfo->est_name_len = H5G_CRT_GINFO_EST_NAME_LEN; + ginfo->est_name_len = H5G_CRT_GINFO_EST_NAME_LEN; } /* end if */ /* Set return value */ ret_value = ginfo; done: - if(ret_value == NULL) - if(ginfo != NULL) + if (ret_value == NULL) + if (ginfo != NULL) ginfo = H5FL_FREE(H5O_ginfo_t, ginfo); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_ginfo_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_ginfo_encode * @@ -168,10 +162,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O_ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *) _mesg; - unsigned char flags = 0; /* Flags for encoding group info */ + const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; + unsigned char flags = 0; /* Flags for encoding group info */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -183,18 +178,18 @@ H5O_ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, *p++ = H5O_GINFO_VERSION; /* The flags for the group info */ - flags = (unsigned char)(ginfo->store_link_phase_change ? H5O_GINFO_STORE_PHASE_CHANGE : 0); - flags = (unsigned char)(flags | (ginfo->store_est_entry_info ? H5O_GINFO_STORE_EST_ENTRY_INFO : 0)); - *p++ = flags; + flags = (unsigned char)(ginfo->store_link_phase_change ? H5O_GINFO_STORE_PHASE_CHANGE : 0); + flags = (unsigned char)(flags | (ginfo->store_est_entry_info ? H5O_GINFO_STORE_EST_ENTRY_INFO : 0)); + *p++ = flags; /* Store the max. # of links to store compactly & the min. # of links to store densely */ - if(ginfo->store_link_phase_change) { + if (ginfo->store_link_phase_change) { UINT16ENCODE(p, ginfo->max_compact) UINT16ENCODE(p, ginfo->min_dense) } /* end if */ /* Estimated # of entries & name lengths */ - if(ginfo->store_est_entry_info) { + if (ginfo->store_est_entry_info) { UINT16ENCODE(p, ginfo->est_num_entries) UINT16ENCODE(p, ginfo->est_name_len) } /* end if */ @@ -202,7 +197,6 @@ H5O_ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_ginfo_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_ginfo_copy * @@ -222,15 +216,15 @@ H5O_ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, static void * H5O_ginfo_copy(const void *_mesg, void *_dest) { - const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; - H5O_ginfo_t *dest = (H5O_ginfo_t *)_dest; - void *ret_value = NULL; /* Return value */ + const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; + H5O_ginfo_t * dest = (H5O_ginfo_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(ginfo); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_ginfo_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_ginfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -243,7 +237,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_ginfo_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_ginfo_size * @@ -264,27 +257,26 @@ done: static size_t H5O_ginfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = 1 + /* Version */ - 1 + /* Flags */ - (ginfo->store_link_phase_change ? ( - (size_t)(2 + /* "Max compact" links */ - 2) /* "Min dense" links */ - ) : 0) + /* "Min dense" links */ - (ginfo->store_est_entry_info ? ( - (size_t)(2 + /* Estimated # of entries in group */ - 2) /* Estimated length of name of entry in group */ - ) : 0); + ret_value = 1 + /* Version */ + 1 + /* Flags */ + (ginfo->store_link_phase_change ? ((size_t)(2 + /* "Max compact" links */ + 2) /* "Min dense" links */ + ) + : 0) + /* "Min dense" links */ + (ginfo->store_est_entry_info ? ((size_t)(2 + /* Estimated # of entries in group */ + 2) /* Estimated length of name of entry in group */ + ) + : 0); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_ginfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__ginfo_free * @@ -309,7 +301,6 @@ H5O__ginfo_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__ginfo_free() */ - /*------------------------------------------------------------------------- * Function: H5O__ginfo_debug * @@ -324,10 +315,9 @@ H5O__ginfo_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__ginfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__ginfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *) _mesg; + const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -338,15 +328,12 @@ H5O__ginfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Max. compact links:", ginfo->max_compact); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Min. dense links:", ginfo->min_dense); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. compact links:", ginfo->max_compact); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. dense links:", ginfo->min_dense); + "Estimated # of objects in group:", ginfo->est_num_entries); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Estimated # of objects in group:", ginfo->est_num_entries); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Estimated length of object in group's name:", ginfo->est_name_len); + "Estimated length of object in group's name:", ginfo->est_name_len); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__ginfo_debug() */ - diff --git a/src/H5Oint.c b/src/H5Oint.c index 04220af..cafa846 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -24,53 +24,48 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for recursive traversal over objects from a group */ typedef struct { - hid_t obj_id; /* The ID for the starting group */ - H5G_loc_t *start_loc; /* Location of starting group */ - H5SL_t *visited; /* Skip list for tracking visited nodes */ - H5O_iterate2_t op; /* Application callback */ - void *op_data; /* Application's op data */ - unsigned fields; /* Selection of object info */ + hid_t obj_id; /* The ID for the starting group */ + H5G_loc_t * start_loc; /* Location of starting group */ + H5SL_t * visited; /* Skip list for tracking visited nodes */ + H5O_iterate2_t op; /* Application callback */ + void * op_data; /* Application's op data */ + unsigned fields; /* Selection of object info */ } H5O_iter_visit_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -78,13 +73,10 @@ typedef struct { static herr_t H5O__delete_oh(H5F_t *f, H5O_t *oh); static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type); static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr); -static herr_t H5O__free_visit_visited(void *item, void *key, - void *operator_data/*in,out*/); -static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info2_t *linfo, - void *_udata); +static herr_t H5O__free_visit_visited(void *item, void *key, void *operator_data /*in,out*/); +static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void *_udata); static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh); -static herr_t H5O__reset_info2(H5O_info2_t *oinfo); - +static herr_t H5O__reset_info2(H5O_info2_t *oinfo); /*********************/ /* Package Variables */ @@ -99,45 +91,45 @@ hbool_t H5_PKG_INIT_VAR = FALSE; * message. */ const H5O_msg_class_t *const H5O_msg_class_g[] = { - H5O_MSG_NULL, /*0x0000 Null */ - H5O_MSG_SDSPACE, /*0x0001 Dataspace */ - H5O_MSG_LINFO, /*0x0002 Link information */ - H5O_MSG_DTYPE, /*0x0003 Datatype */ - H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */ - H5O_MSG_FILL_NEW, /*0x0005 New data storage -- fill value */ - H5O_MSG_LINK, /*0x0006 Link */ - H5O_MSG_EFL, /*0x0007 Data storage -- external data files */ - H5O_MSG_LAYOUT, /*0x0008 Data Layout */ + H5O_MSG_NULL, /*0x0000 Null */ + H5O_MSG_SDSPACE, /*0x0001 Dataspace */ + H5O_MSG_LINFO, /*0x0002 Link information */ + H5O_MSG_DTYPE, /*0x0003 Datatype */ + H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */ + H5O_MSG_FILL_NEW, /*0x0005 New data storage -- fill value */ + H5O_MSG_LINK, /*0x0006 Link */ + H5O_MSG_EFL, /*0x0007 Data storage -- external data files */ + H5O_MSG_LAYOUT, /*0x0008 Data Layout */ #ifdef H5O_ENABLE_BOGUS - H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */ -#else /* H5O_ENABLE_BOGUS */ - NULL, /*0x0009 "Bogus valid" (for testing) */ -#endif /* H5O_ENABLE_BOGUS */ - H5O_MSG_GINFO, /*0x000A Group information */ - H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */ + H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */ +#else /* H5O_ENABLE_BOGUS */ + NULL, /*0x0009 "Bogus valid" (for testing) */ +#endif /* H5O_ENABLE_BOGUS */ + H5O_MSG_GINFO, /*0x000A Group information */ + H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */ H5O_MSG_ATTR, /*0x000C Attribute */ H5O_MSG_NAME, /*0x000D Object name */ - H5O_MSG_MTIME, /*0x000E Object modification date and time */ - H5O_MSG_SHMESG, /*0x000F File-wide shared message table */ + H5O_MSG_MTIME, /*0x000E Object modification date and time */ + H5O_MSG_SHMESG, /*0x000F File-wide shared message table */ H5O_MSG_CONT, /*0x0010 Object header continuation */ H5O_MSG_STAB, /*0x0011 Symbol table */ - H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */ - H5O_MSG_BTREEK, /*0x0013 Non-default v1 B-tree 'K' values */ - H5O_MSG_DRVINFO, /*0x0014 Driver info settings */ - H5O_MSG_AINFO, /*0x0015 Attribute information */ - H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */ - H5O_MSG_FSINFO, /*0x0017 Free-space manager info */ - H5O_MSG_MDCI, /*0x0018 Metadata cache image */ - H5O_MSG_UNKNOWN /*0x0019 Placeholder for unknown message */ + H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */ + H5O_MSG_BTREEK, /*0x0013 Non-default v1 B-tree 'K' values */ + H5O_MSG_DRVINFO, /*0x0014 Driver info settings */ + H5O_MSG_AINFO, /*0x0015 Attribute information */ + H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */ + H5O_MSG_FSINFO, /*0x0017 Free-space manager info */ + H5O_MSG_MDCI, /*0x0018 Metadata cache image */ + H5O_MSG_UNKNOWN /*0x0019 Placeholder for unknown message */ }; /* Format version bounds for object header */ const unsigned H5O_obj_ver_bounds[] = { - H5O_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_VERSION_2, /* H5F_LIBVER_V18 */ - H5O_VERSION_2, /* H5F_LIBVER_V110 */ - H5O_VERSION_2, /* H5F_LIBVER_V112 */ - H5O_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_VERSION_2, /* H5F_LIBVER_V110 */ + H5O_VERSION_2, /* H5F_LIBVER_V112 */ + H5O_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /* Declare a free list to manage the H5O_t struct */ @@ -156,12 +148,8 @@ H5FL_BLK_DEFINE(chunk_image); H5FL_SEQ_EXTERN(H5O_cont_t); /* The canonical 'undefined' token */ -const H5O_token_t H5O_TOKEN_UNDEF_g = {{ - 255, 255, 255, 255, - 255, 255, 255, 255, - 255, 255, 255, 255, - 255, 255, 255, 255}}; - +const H5O_token_t H5O_TOKEN_UNDEF_g = { + {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}}; /*****************************/ /* Library Private Variables */ @@ -173,7 +161,6 @@ H5FL_EXTERN(time_t); /* Declare external the free list for H5_obj_t's */ H5FL_EXTERN(H5_obj_t); - /*******************/ /* Local Variables */ /*******************/ @@ -185,12 +172,11 @@ H5FL_EXTERN(H5_obj_t); * datatype message is a datatype but only some of them are datasets. */ static const H5O_obj_class_t *const H5O_obj_class_g[] = { - H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */ - H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */ - H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */ + H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */ + H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */ + H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */ }; - /*------------------------------------------------------------------------- * Function: H5O__init_package * @@ -217,7 +203,6 @@ H5O__init_package(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__init_package() */ - /*------------------------------------------------------------------------- * Function: H5O_set_version * @@ -235,8 +220,8 @@ H5O__init_package(void) static herr_t H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx) { - uint8_t version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -245,7 +230,7 @@ H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx HDassert(oh); /* Set the correct version to encode object header with */ - if(store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) + if (store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) version = H5O_VERSION_LATEST; else version = H5O_VERSION_1; @@ -254,7 +239,7 @@ H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx version = (uint8_t)MAX(version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "object header version out of bounds") /* Set the message version */ @@ -264,7 +249,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_set_version() */ - /*------------------------------------------------------------------------- * Function: H5O_create * @@ -296,8 +280,8 @@ done: herr_t H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc /*out*/) { - H5O_t *oh = NULL; - herr_t ret_value = SUCCEED; + H5O_t *oh = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -309,22 +293,21 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc * header version is set internally */ oh = H5O__create_ohdr(f, ocpl_id); - if(NULL == oh) + if (NULL == oh) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't instantiate object header") /* apply object header information to file */ - if(H5O__apply_ohdr(f, oh, ocpl_id, size_hint, initial_rc, loc) < 0) + if (H5O__apply_ohdr(f, oh, ocpl_id, size_hint, initial_rc, loc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't apply object header to file") done: - if((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + if ((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "can't delete object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_create() */ - /*----------------------------------------------------------------------------- * Function: H5O__create_ohdr * @@ -342,9 +325,9 @@ H5O_t * H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) { H5P_genplist_t *oc_plist; - H5O_t *oh = NULL; /* Object header in Freelist */ - uint8_t oh_flags; /* Initial status flags */ - H5O_t *ret_value = NULL; + H5O_t * oh = NULL; /* Object header in Freelist */ + uint8_t oh_flags; /* Initial status flags */ + H5O_t * ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -352,32 +335,30 @@ H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); /* Check for invalid access request */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file") oh = H5FL_CALLOC(H5O_t); - if(NULL == oh) + if (NULL == oh) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id); - if(NULL == oc_plist) + if (NULL == oc_plist) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a property list") /* Get any object header status flags set by properties */ - if(H5P_DATASET_CREATE_DEFAULT == ocpl_id) - { + if (H5P_DATASET_CREATE_DEFAULT == ocpl_id) { /* If the OCPL is the default DCPL, we can get the header flags from the * API context. Otherwise we have to call H5P_get */ - if(H5CX_get_ohdr_flags(&oh_flags) < 0) + if (H5CX_get_ohdr_flags(&oh_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") } - else - { - if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) + else { + if (H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") } - if(H5O_set_version(f, oh, oh_flags, H5F_STORE_MSG_CRT_IDX(f)) < 0) + if (H5O_set_version(f, oh, oh_flags, H5F_STORE_MSG_CRT_IDX(f)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, NULL, "can't set version of object header") oh->flags = oh_flags; @@ -385,13 +366,12 @@ H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) ret_value = oh; done: - if((NULL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + if ((NULL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "can't delete object header") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__create_ohdr() */ - /*----------------------------------------------------------------------------- * Function: H5O__apply_ohdr * @@ -427,63 +407,65 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini oh->sizeof_size = H5F_SIZEOF_SIZE(f); oh->sizeof_addr = H5F_SIZEOF_ADDR(f); - oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); /* funky cast */ + oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); /* funky cast */ #ifdef H5O_ENABLE_BAD_MESG_COUNT /* Check whether the "bad message count" property is set */ - if(0 < H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME)) + if (0 < H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME)) /* Get bad message count flag -- from property list */ - if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) + if (H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag") #endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* Create object header proxy if doing SWMR writes */ - if(oh->swmr_write) { + if (oh->swmr_write) { oh->proxy = H5AC_proxy_entry_create(); - if(NULL == oh->proxy) + if (NULL == oh->proxy) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") - } else { + } + else { oh->proxy = NULL; } oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id); - if(NULL == oc_plist) + if (NULL == oc_plist) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") /* Initialize version-specific fields */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Initialize all time fields */ - if(oh->flags & H5O_HDR_STORE_TIMES) + if (oh->flags & H5O_HDR_STORE_TIMES) oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now(); else oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - if(H5F_STORE_MSG_CRT_IDX(f)) + if (H5F_STORE_MSG_CRT_IDX(f)) /* flag to record message creation indices */ oh->flags |= H5O_HDR_ATTR_CRT_ORDER_TRACKED; /* Get attribute storage phase change values -- from property list */ - if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) + if (H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") - if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) + if (H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") /* Check for non-default attribute storage phase change values */ - if(H5O_CRT_ATTR_MAX_COMPACT_DEF != oh->max_compact || H5O_CRT_ATTR_MIN_DENSE_DEF != oh->min_dense ) + if (H5O_CRT_ATTR_MAX_COMPACT_DEF != oh->max_compact || H5O_CRT_ATTR_MIN_DENSE_DEF != oh->min_dense) oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE; - /* Determine correct value for chunk #0 size bits */ + /* Determine correct value for chunk #0 size bits */ /* Avoid compiler warning on 32-bit machines */ #if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T - if(size_hint > 4294967295UL) + if (size_hint > 4294967295UL) oh->flags |= H5O_HDR_CHUNK0_8; else #endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */ - if(size_hint > 65535) + if (size_hint > 65535) oh->flags |= H5O_HDR_CHUNK0_4; - else if(size_hint > 255) + else if (size_hint > 255) oh->flags |= H5O_HDR_CHUNK0_2; - } else { + } + else { /* Reset unused time fields */ oh->atime = oh->mtime = oh->ctime = oh->btime = 0; } /* end if/else header version >1 */ @@ -494,49 +476,50 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini /* Allocate disk space for header and first chunk */ oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)oh_size); - if(HADDR_UNDEF == oh_addr) + if (HADDR_UNDEF == oh_addr) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header") /* Create the chunk list */ - oh->nchunks = 1; + oh->nchunks = 1; oh->alloc_nchunks = 1; - oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks); - if(NULL == oh->chunk) + oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks); + if (NULL == oh->chunk) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the first chunk */ oh->chunk[0].addr = oh_addr; oh->chunk[0].size = oh_size; - oh->chunk[0].gap = 0; + oh->chunk[0].gap = 0; /* Allocate enough space for the first chunk */ /* (including space for serializing the object header prefix */ oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size); - if(NULL == oh->chunk[0].image) + if (NULL == oh->chunk[0].image) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") oh->chunk[0].chunk_proxy = NULL; /* Put magic # for object header in first chunk */ - if(H5O_VERSION_1 < oh->version) + if (H5O_VERSION_1 < oh->version) H5MM_memcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); /* Create the message list */ - oh->nmesgs = 1; + oh->nmesgs = 1; oh->alloc_nmesgs = H5O_NMESGS; - oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs); - if(NULL == oh->mesg) + oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs); + if (NULL == oh->mesg) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the initial "null" message; covers the entire first chunk */ - oh->mesg[0].type = H5O_MSG_NULL; - oh->mesg[0].dirty = TRUE; + oh->mesg[0].type = H5O_MSG_NULL; + oh->mesg[0].dirty = TRUE; oh->mesg[0].native = NULL; - oh->mesg[0].raw = oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[0].raw = + oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - oh->mesg[0].chunkno = 0; + oh->mesg[0].chunkno = 0; /* Check for non-zero initial refcount on the object header */ - if(initial_rc > 0) { + if (initial_rc > 0) { /* Set the initial refcount & pin the header when its inserted */ oh->rc = initial_rc; insert_flags |= H5AC__PIN_ENTRY_FLAG; @@ -546,7 +529,7 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini H5_BEGIN_TAG(oh_addr); /* Cache object header */ - if(H5AC_insert_entry(f, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) + if (H5AC_insert_entry(f, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") /* Reset object header pointer, now that it's been inserted into the cache */ @@ -559,14 +542,13 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini loc_out->file = f; loc_out->addr = oh_addr; - if(H5O_open(loc_out) < 0) + if (H5O_open(loc_out) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header") done: FUNC_LEAVE_NOAPI(ret_value); } /* H5O__apply_ohdr() */ - /*------------------------------------------------------------------------- * Function: H5O_open * @@ -588,7 +570,7 @@ done: herr_t H5O_open(H5O_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -597,12 +579,12 @@ H5O_open(H5O_loc_t *loc) HDassert(loc->file); #ifdef H5O_DEBUG - if(H5DEBUG(O)) + if (H5DEBUG(O)) HDfprintf(H5DEBUG(O), "> %a\n", loc->addr); #endif /* Turn off the variable for holding file or increment open-lock counters */ - if(loc->holding_file) + if (loc->holding_file) loc->holding_file = FALSE; else H5F_INCR_NOPEN_OBJS(loc->file); @@ -611,7 +593,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open() */ - /*------------------------------------------------------------------------- * Function: H5O_open_name * @@ -628,11 +609,11 @@ done: void * H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - void *ret_value = NULL; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -646,23 +627,22 @@ H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type) H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Open the object */ - if(NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + if (NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: - if(NULL == ret_value) - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (NULL == ret_value) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_name() */ - /*------------------------------------------------------------------------- * Function: H5O_open_by_idx * @@ -677,14 +657,14 @@ done: *------------------------------------------------------------------------- */ void * -H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5I_type_t *opened_type) +H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5I_type_t *opened_type) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - void *ret_value = NULL; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -697,24 +677,23 @@ H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(loc, name, idx_type, order, n, &obj_loc/*out*/) < 0) + if (H5G_loc_find_by_idx(loc, name, idx_type, order, n, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "group not found") loc_found = TRUE; /* Open the object */ - if(NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + if (NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: /* Release the object location if we failed after copying it */ - if(NULL == ret_value) - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (NULL == ret_value) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5O_open_by_addr * @@ -731,10 +710,10 @@ done: void * H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr, H5I_type_t *opened_type) { - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - void *ret_value = NULL; /* Return value */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -747,17 +726,16 @@ H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr, H5I_type_t *opened_type) H5G_loc_reset(&obj_loc); obj_loc.oloc->addr = addr; obj_loc.oloc->file = loc->oloc->file; - H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ + H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ /* Open the object */ - if(NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + if (NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_by_addr() */ - /*------------------------------------------------------------------------- * Function: H5O_open_by_loc * @@ -774,27 +752,26 @@ done: void * H5O_open_by_loc(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - const H5O_obj_class_t *obj_class; /* Class of object for location */ - void *ret_value = NULL; /* Return value */ + const H5O_obj_class_t *obj_class; /* Class of object for location */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) HDassert(obj_loc); /* Get the object class for this location */ - if(NULL == (obj_class = H5O__obj_class(obj_loc->oloc))) + if (NULL == (obj_class = H5O__obj_class(obj_loc->oloc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object class") /* Call the object class's 'open' routine */ HDassert(obj_class->open); - if(NULL == (ret_value = obj_class->open(obj_loc, opened_type))) + if (NULL == (ret_value = obj_class->open(obj_loc, opened_type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_by_loc() */ - /*------------------------------------------------------------------------- * Function: H5O_close * @@ -810,7 +787,7 @@ done: herr_t H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -825,16 +802,17 @@ H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) * It's needed by the evict-on-close code. Clients can ignore * this value by passing in NULL. */ - if(file_closed) + if (file_closed) *file_closed = FALSE; /* Decrement open-lock counters */ H5F_DECR_NOPEN_OBJS(loc->file); #ifdef H5O_DEBUG - if(H5DEBUG(O)) { - if(FALSE == H5F_ID_EXISTS(loc->file) && 1 == H5F_NREFS(loc->file)) - HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file)); + if (H5DEBUG(O)) { + if (FALSE == H5F_ID_EXISTS(loc->file) && 1 == H5F_NREFS(loc->file)) + HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", loc->addr, + (unsigned long)H5F_NOPEN_OBJS(loc->file)); else HDfprintf(H5DEBUG(O), "< %a\n", loc->addr); } @@ -844,20 +822,19 @@ H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) * If the file open object count has reached the number of open mount points * (each of which has a group open in the file) attempt to close the file. */ - if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file)) + if (H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file)) /* Attempt to close down the file hierarchy */ - if(H5F_try_close(loc->file, file_closed) < 0) + if (H5F_try_close(loc->file, file_closed) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") /* Release location information */ - if(H5O_loc_free(loc) < 0) + if (H5O_loc_free(loc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "problem attempting to free location") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_close() */ - /*------------------------------------------------------------------------- * Function: H5O__link_oh * @@ -877,8 +854,8 @@ done: int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) { - haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */ - int ret_value = -1; /* Return value */ + haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */ + int ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -888,59 +865,59 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) HDassert(deleted); /* Check for adjusting link count */ - if(adjust) { - if(adjust < 0) { + if (adjust) { + if (adjust < 0) { /* Check for too large of an adjustment */ - if((unsigned)(-adjust) > oh->nlink) + if ((unsigned)(-adjust) > oh->nlink) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, (-1), "link count would be negative") /* Adjust the link count for the object header */ oh->nlink = (unsigned)((int)oh->nlink + adjust); /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, (-1), "unable to mark object header as dirty") /* Check if the object should be deleted */ - if(oh->nlink == 0) { + if (oh->nlink == 0) { /* Check if the object is still open by the user */ - if(H5FO_opened(f, addr) != NULL) { + if (H5FO_opened(f, addr) != NULL) { /* Flag the object to be deleted when it's closed */ - if(H5FO_mark(f, addr, TRUE) < 0) + if (H5FO_mark(f, addr, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "can't mark object for deletion") } /* end if */ else { /* Mark the object header for deletion */ *deleted = TRUE; } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* A new object, or one that will be deleted */ - if(0 == oh->nlink) { + if (0 == oh->nlink) { /* Check if the object is currently open, but marked for deletion */ - if(H5FO_marked(f, addr)) { + if (H5FO_marked(f, addr)) { /* Remove "delete me" flag on the object */ - if(H5FO_mark(f, addr, FALSE) < 0) + if (H5FO_mark(f, addr, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "can't mark object for deletion") } /* end if */ - } /* end if */ + } /* end if */ /* Adjust the link count for the object header */ oh->nlink = (unsigned)((int)oh->nlink + adjust); /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, (-1), "unable to mark object header as dirty") } /* end if */ /* Check for operations on refcount message */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check if the object has a refcount message already */ - if(oh->has_refcount_msg) { + if (oh->has_refcount_msg) { /* Check for removing refcount message */ - if(oh->nlink <= 1) { - if(H5O__msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE) < 0) + if (oh->nlink <= 1) { + if (H5O__msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "unable to delete refcount message") oh->has_refcount_msg = FALSE; } /* end if */ @@ -948,22 +925,24 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) else { H5O_refcount_t refcount = oh->nlink; - if(H5O__msg_write_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) + if (H5O__msg_write_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, (-1), "unable to update refcount message") } /* end else */ - } /* end if */ + } /* end if */ else { /* Check for adding refcount message to object */ - if(oh->nlink > 1) { + if (oh->nlink > 1) { H5O_refcount_t refcount = oh->nlink; - if(H5O__msg_append_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) + if (H5O__msg_append_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, (-1), "unable to create new refcount message") oh->has_refcount_msg = TRUE; } /* end if */ - } /* end else */ - } /* end if */ - } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ /* Set return value */ ret_value = (int)oh->nlink; @@ -972,7 +951,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__link_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_link * @@ -992,9 +970,9 @@ done: int H5O_link(const H5O_loc_t *loc, int adjust) { - H5O_t *oh = NULL; - hbool_t deleted = FALSE; /* Whether the object was deleted */ - int ret_value = -1; /* Return value */ + H5O_t * oh = NULL; + hbool_t deleted = FALSE; /* Whether the object was deleted */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -1004,23 +982,22 @@ H5O_link(const H5O_loc_t *loc, int adjust) HDassert(H5F_addr_defined(loc->addr)); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Call the "real" link routine */ - if((ret_value = H5O__link_oh(loc->file, adjust, oh, &deleted)) < 0) + if ((ret_value = H5O__link_oh(loc->file, adjust, oh, &deleted)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust object link count") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") - if(ret_value >= 0 && deleted && H5O_delete(loc->file, loc->addr) < 0) + if (ret_value >= 0 && deleted && H5O_delete(loc->file, loc->addr) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_link() */ - /*------------------------------------------------------------------------- * Function: H5O_protect * @@ -1041,11 +1018,11 @@ done: H5O_t * H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) { - H5O_t *oh = NULL; /* Object header protected */ - H5O_cache_ud_t udata; /* User data for protecting object header */ - H5O_cont_msgs_t cont_msg_info; /* Continuation message info */ - unsigned file_intent; /* R/W intent on file */ - H5O_t *ret_value = NULL; /* Return value */ + H5O_t * oh = NULL; /* Object header protected */ + H5O_cache_ud_t udata; /* User data for protecting object header */ + H5O_cont_msgs_t cont_msg_info; /* Continuation message info */ + unsigned file_intent; /* R/W intent on file */ + H5O_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, NULL) @@ -1057,35 +1034,35 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) HDassert((prot_flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Check for valid address */ - if(!H5F_addr_defined(loc->addr)) + if (!H5F_addr_defined(loc->addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "address undefined") /* Check for write access on the file */ file_intent = H5F_INTENT(loc->file); - if((0 == (prot_flags & H5AC__READ_ONLY_FLAG)) && (0 == (file_intent & H5F_ACC_RDWR))) + if ((0 == (prot_flags & H5AC__READ_ONLY_FLAG)) && (0 == (file_intent & H5F_ACC_RDWR))) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file") /* Construct the user data for protect callback */ - udata.made_attempt = FALSE; - udata.v1_pfx_nmesgs = 0; - udata.chunk0_size = 0; - udata.oh = NULL; - udata.free_oh = FALSE; - udata.common.f = loc->file; - udata.common.file_intent = file_intent; + udata.made_attempt = FALSE; + udata.v1_pfx_nmesgs = 0; + udata.chunk0_size = 0; + udata.oh = NULL; + udata.free_oh = FALSE; + udata.common.f = loc->file; + udata.common.file_intent = file_intent; udata.common.merged_null_msgs = 0; HDmemset(&cont_msg_info, 0, sizeof(cont_msg_info)); udata.common.cont_msg_info = &cont_msg_info; - udata.common.addr = loc->addr; + udata.common.addr = loc->addr; /* Lock the object header into the cache */ - if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, H5AC_OHDR, loc->addr, &udata, prot_flags))) + if (NULL == (oh = (H5O_t *)H5AC_protect(loc->file, H5AC_OHDR, loc->addr, &udata, prot_flags))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") /* Check if there are any continuation messages to process */ - if(cont_msg_info.nmsgs > 0) { - size_t curr_msg; /* Current continuation message to process */ - H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ + if (cont_msg_info.nmsgs > 0) { + size_t curr_msg; /* Current continuation message to process */ + H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ /* Sanity check - we should only have continuation messages to process * when the object header is actually loaded from the file. @@ -1094,30 +1071,32 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) HDassert(cont_msg_info.msgs); /* Construct the user data for protecting chunks */ - chk_udata.decoding = TRUE; - chk_udata.oh = oh; - chk_udata.chunkno = UINT_MAX; /* Set to invalid value, for better error detection */ - chk_udata.common.f = loc->file; - chk_udata.common.file_intent = file_intent; + chk_udata.decoding = TRUE; + chk_udata.oh = oh; + chk_udata.chunkno = UINT_MAX; /* Set to invalid value, for better error detection */ + chk_udata.common.f = loc->file; + chk_udata.common.file_intent = file_intent; chk_udata.common.merged_null_msgs = udata.common.merged_null_msgs; - chk_udata.common.cont_msg_info = &cont_msg_info; + chk_udata.common.cont_msg_info = &cont_msg_info; /* Read in continuation messages, until there are no more */ /* (Note that loading chunks could increase the # of continuation * messages if new ones are found - QAK, 19/11/2016) */ curr_msg = 0; - while(curr_msg < cont_msg_info.nmsgs) { - H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */ + while (curr_msg < cont_msg_info.nmsgs) { + H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */ #ifndef NDEBUG - size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ -#endif /* NDEBUG */ + size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ +#endif /* NDEBUG */ /* Bring the chunk into the cache */ /* (which adds to the object header) */ chk_udata.common.addr = cont_msg_info.msgs[curr_msg].addr; - chk_udata.size = cont_msg_info.msgs[curr_msg].size; - if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(loc->file, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, &chk_udata, prot_flags))) + chk_udata.size = cont_msg_info.msgs[curr_msg].size; + if (NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(loc->file, H5AC_OHDR_CHK, + cont_msg_info.msgs[curr_msg].addr, + &chk_udata, prot_flags))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk") /* Sanity check */ @@ -1126,7 +1105,8 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) HDassert(oh->nchunks == (chkcnt + 1)); /* Release the chunk from the cache */ - if(H5AC_unprotect(loc->file, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(loc->file, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, chk_proxy, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header chunk") /* Advance to next continuation message */ @@ -1143,7 +1123,7 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) /* Check for incorrect # of object header messages, if we've just loaded * this object header from the file */ - if(udata.made_attempt) { + if (udata.made_attempt) { /* Don't enforce the error on an incorrect # of object header messages bug * unless strict format checking is enabled. This allows for older * files, created with a version of the library that had a bug in tracking @@ -1152,39 +1132,39 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) */ #ifdef H5_STRICT_FORMAT_CHECKS /* Check for incorrect # of messages in v1 object header */ - if(oh->version == H5O_VERSION_1 && - (oh->nmesgs + udata.common.merged_null_msgs) != udata.v1_pfx_nmesgs) + if (oh->version == H5O_VERSION_1 && + (oh->nmesgs + udata.common.merged_null_msgs) != udata.v1_pfx_nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - incorrect # of messages") #endif /* H5_STRICT_FORMAT_CHECKS */ - } /* end if */ + } /* end if */ #ifdef H5O_DEBUG -H5O__assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ /* Pin the other chunks also when requested, so that the object header * proxy can be set up. */ - if(pin_all_chunks && oh->nchunks > 1) { - unsigned u; /* Local index variable */ + if (pin_all_chunks && oh->nchunks > 1) { + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(oh->swmr_write); /* Iterate over chunks > 0 */ - for(u = 1; u < oh->nchunks; u++) { - H5O_chunk_proxy_t *chk_proxy; /* Chunk proxy */ + for (u = 1; u < oh->nchunks; u++) { + H5O_chunk_proxy_t *chk_proxy; /* Chunk proxy */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(loc->file, oh, u))) + if (NULL == (chk_proxy = H5O__chunk_protect(loc->file, oh, u))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header chunk") /* Pin chunk proxy*/ - if(H5AC_pin_protected_entry(chk_proxy) < 0 ) + if (H5AC_pin_protected_entry(chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header chunk") /* Unprotect chunk */ - if(H5O__chunk_unprotect(loc->file, chk_proxy, FALSE) < 0) + if (H5O__chunk_unprotect(loc->file, chk_proxy, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header chunk") /* Preserve chunk proxy pointer for later */ @@ -1199,14 +1179,13 @@ H5O__assert(oh); ret_value = oh; done: - if(ret_value == NULL && oh) - if(H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (ret_value == NULL && oh) + if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_protect() */ - /*------------------------------------------------------------------------- * Function: H5O_pin * @@ -1227,8 +1206,8 @@ done: H5O_t * H5O_pin(const H5O_loc_t *loc) { - H5O_t *oh = NULL; /* Object header */ - H5O_t *ret_value = NULL; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5O_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1236,12 +1215,12 @@ H5O_pin(const H5O_loc_t *loc) HDassert(loc); /* Get header */ - if(NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header") /* Increment the reference count on the object header */ /* (which will pin it, if appropriate) */ - if(H5O__inc_rc(oh) < 0) + if (H5O__inc_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "unable to increment reference count on object header") /* Set the return value */ @@ -1249,13 +1228,12 @@ H5O_pin(const H5O_loc_t *loc) done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_pin() */ - /*------------------------------------------------------------------------- * Function: H5O_unpin * @@ -1274,7 +1252,7 @@ done: herr_t H5O_unpin(H5O_t *oh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1283,14 +1261,13 @@ H5O_unpin(H5O_t *oh) /* Decrement the reference count on the object header */ /* (which will unpin it, if appropriate) */ - if(H5O__dec_rc(oh) < 0) + if (H5O__dec_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_unpin() */ - /*------------------------------------------------------------------------- * Function: H5O_unprotect * @@ -1310,7 +1287,7 @@ done: herr_t H5O_unprotect(const H5O_loc_t *loc, H5O_t *oh, unsigned oh_flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1319,35 +1296,34 @@ H5O_unprotect(const H5O_loc_t *loc, H5O_t *oh, unsigned oh_flags) HDassert(oh); /* Unpin the other chunks */ - if(oh->chunks_pinned && oh->nchunks > 1) { - unsigned u; /* Local index variable */ + if (oh->chunks_pinned && oh->nchunks > 1) { + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(oh->swmr_write); /* Iterate over chunks > 0 */ - for(u = 1; u < oh->nchunks; u++) { - if(NULL != oh->chunk[u].chunk_proxy) { + for (u = 1; u < oh->nchunks; u++) { + if (NULL != oh->chunk[u].chunk_proxy) { /* Release chunk proxy */ - if(H5AC_unpin_entry(oh->chunk[u].chunk_proxy) < 0) + if (H5AC_unpin_entry(oh->chunk[u].chunk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header chunk") oh->chunk[u].chunk_proxy = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* Reet the flag from the unprotect */ oh->chunks_pinned = FALSE; } /* end if */ /* Unprotect the object header */ - if(H5AC_unprotect(loc->file, H5AC_OHDR, oh->chunk[0].addr, oh, oh_flags) < 0) + if (H5AC_unprotect(loc->file, H5AC_OHDR, oh->chunk[0].addr, oh, oh_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5O_touch_oh * @@ -1365,10 +1341,10 @@ done: herr_t H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - time_t now; /* Current time */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + time_t now; /* Current time */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1376,43 +1352,45 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) HDassert(oh); /* Check if this object header is tracking times */ - if(oh->flags & H5O_HDR_STORE_TIMES) { + if (oh->flags & H5O_HDR_STORE_TIMES) { /* Get current time */ now = H5_now(); /* Check version, to determine how to store time information */ - if(oh->version == H5O_VERSION_1) { - size_t idx; /* Index of modification time message to update */ + if (oh->version == H5O_VERSION_1) { + size_t idx; /* Index of modification time message to update */ /* Look for existing message */ - for(idx = 0; idx < oh->nmesgs; idx++) - if(H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type) + for (idx = 0; idx < oh->nmesgs; idx++) + if (H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type) break; /* Create a new message, if necessary */ - if(idx == oh->nmesgs) { - unsigned mesg_flags = 0; /* Flags for message in object header */ + if (idx == oh->nmesgs) { + unsigned mesg_flags = 0; /* Flags for message in object header */ /* If we would have to create a new message, but we aren't 'forcing' it, get out now */ - if(!force) - HGOTO_DONE(SUCCEED); /*nothing to do*/ + if (!force) + HGOTO_DONE(SUCCEED); /*nothing to do*/ /* Allocate space for the modification time message */ - if(H5O__msg_alloc(f, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message") + if (H5O__msg_alloc(f, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, + "unable to allocate space for modification time message") /* Set the message's flags if appropriate */ oh->mesg[idx].flags = (uint8_t)mesg_flags; } /* end if */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[idx].chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[idx].chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Allocate 'native' space, if necessary */ - if(NULL == oh->mesg[idx].native) { - if(NULL == (oh->mesg[idx].native = H5FL_MALLOC(time_t))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for modification time message") + if (NULL == oh->mesg[idx].native) { + if (NULL == (oh->mesg[idx].native = H5FL_MALLOC(time_t))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, + "memory allocation failed for modification time message") } /* end if */ /* Update the message */ @@ -1420,7 +1398,7 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) /* Mark the message as dirty */ oh->mesg[idx].dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; } /* end if */ else { /* XXX: For now, update access time & change fields in the object header @@ -1429,20 +1407,19 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) oh->atime = oh->ctime = now; /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end else */ - } /* end if */ + } /* end if */ done: /* Release chunk */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_touch_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_touch * @@ -1461,9 +1438,9 @@ done: herr_t H5O_touch(const H5O_loc_t *loc, hbool_t force) { - H5O_t *oh = NULL; /* Object header to modify */ - unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header to modify */ + unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1471,18 +1448,18 @@ H5O_touch(const H5O_loc_t *loc, hbool_t force) HDassert(loc); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Create/Update the modification time message */ - if(H5O_touch_oh(loc->file, oh, force) < 0) + if (H5O_touch_oh(loc->file, oh, force) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update object modificaton time") /* Mark object header as changed */ oh_flags |= H5AC__DIRTIED_FLAG; done: - if(oh && H5O_unprotect(loc, oh, oh_flags) < 0) + if (oh && H5O_unprotect(loc, oh, oh_flags) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) @@ -1506,9 +1483,9 @@ done: herr_t H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) { - size_t idx; /* Local index variable */ - H5O_msg_class_t *type; /* Message class type */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; /* Local index variable */ + H5O_msg_class_t *type; /* Message class type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1516,30 +1493,30 @@ H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) HDassert(oh); /* Look for existing message */ - for(idx = 0; idx < oh->nmesgs; idx++) - if(H5O_MSG_BOGUS_VALID == oh->mesg[idx].type || H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type) + for (idx = 0; idx < oh->nmesgs; idx++) + if (H5O_MSG_BOGUS_VALID == oh->mesg[idx].type || H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type) break; /* Create a new message */ - if(idx == oh->nmesgs) { - H5O_bogus_t *bogus; /* Pointer to the bogus information */ + if (idx == oh->nmesgs) { + H5O_bogus_t *bogus; /* Pointer to the bogus information */ /* Allocate the native message in memory */ - if(NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t)))) + if (NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message") /* Update the native value */ bogus->u = H5O_BOGUS_VALUE; - if(bogus_id == H5O_BOGUS_VALID_ID) + if (bogus_id == H5O_BOGUS_VALID_ID) type = H5O_MSG_BOGUS_VALID; - else if(bogus_id == H5O_BOGUS_INVALID_ID) + else if (bogus_id == H5O_BOGUS_INVALID_ID) type = H5O_MSG_BOGUS_INVALID; else HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message") /* Allocate space in the object header for bogus message */ - if(H5O__msg_alloc(f, oh, type, &mesg_flags, bogus, &idx) < 0) + if (H5O__msg_alloc(f, oh, type, &mesg_flags, bogus, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") /* Point to "bogus" information (take it over) */ @@ -1549,7 +1526,7 @@ H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) oh->mesg[idx].flags = mesg_flags; /* Mark the message and object header as dirty */ - oh->mesg[idx].dirty = TRUE; + oh->mesg[idx].dirty = TRUE; oh->cache_info.is_dirty = TRUE; } /* end if */ @@ -1558,7 +1535,6 @@ done: } /* end H5O_bogus_oh() */ #endif /* H5O_ENABLE_BOGUS */ - /*------------------------------------------------------------------------- * Function: H5O_delete * @@ -1578,11 +1554,11 @@ done: herr_t H5O_delete(H5F_t *f, haddr_t addr) { - H5O_t *oh = NULL; /* Object header information */ - H5O_loc_t loc; /* Object location for object to delete */ - unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ - hbool_t corked; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header information */ + H5O_loc_t loc; /* Object location for object to delete */ + unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ + hbool_t corked; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(addr, FAIL) @@ -1591,36 +1567,35 @@ H5O_delete(H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Set up the object location */ - loc.file = f; - loc.addr = addr; + loc.file = f; + loc.addr = addr; loc.holding_file = FALSE; /* Get the object header information */ - if(NULL == (oh = H5O_protect(&loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(&loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Delete object */ - if(H5O__delete_oh(f, oh) < 0) + if (H5O__delete_oh(f, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") /* Uncork cache entries with tag: addr */ - if(H5AC_cork(f, addr, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(f, addr, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(f, addr, H5AC__UNCORK, NULL) < 0) + if (corked) + if (H5AC_cork(f, addr, H5AC__UNCORK, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* Mark object header as deleted */ oh_flags = H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; done: - if(oh && H5O_unprotect(&loc, oh, oh_flags) < 0) + if (oh && H5O_unprotect(&loc, oh, oh_flags) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__delete_oh * @@ -1641,9 +1616,9 @@ done: static herr_t H5O__delete_oh(H5F_t *f, H5O_t *oh) { - H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ + H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1654,17 +1629,17 @@ H5O__delete_oh(H5F_t *f, H5O_t *oh) /* Walk through the list of object header messages, asking each one to * delete any file space used */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { /* Free any space referred to in the file from this message */ - if(H5O__delete_mesg(f, oh, curr_msg) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") + if (H5O__delete_mesg(f, oh, curr_msg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, + "unable to delete file space for object header message") } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__delete_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_obj_type * @@ -1681,27 +1656,26 @@ done: herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type) { - H5O_t *oh = NULL; /* Object header for location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header for location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Retrieve the type of the object */ - if(H5O__obj_type_real(oh, obj_type) < 0) + if (H5O__obj_type_real(oh, obj_type) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_obj_type() */ - /*------------------------------------------------------------------------- * Function: H5O__obj_type_real * @@ -1718,7 +1692,7 @@ done: static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) { - const H5O_obj_class_t *obj_class; /* Class of object for header */ + const H5O_obj_class_t *obj_class; /* Class of object for header */ FUNC_ENTER_STATIC_NOERR @@ -1727,7 +1701,7 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) HDassert(obj_type); /* Look up class for object header */ - if(NULL == (obj_class = H5O__obj_class_real(oh))) { + if (NULL == (obj_class = H5O__obj_class_real(oh))) { /* Clear error stack from "failed" class lookup */ H5E_clear_stack(NULL); @@ -1742,7 +1716,6 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__obj_type_real() */ - /*------------------------------------------------------------------------- * Function: H5O__obj_class * @@ -1759,27 +1732,26 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) const H5O_obj_class_t * H5O__obj_class(const H5O_loc_t *loc) { - H5O_t *oh = NULL; /* Object header for location */ - const H5O_obj_class_t *ret_value = NULL; /* Return value */ + H5O_t * oh = NULL; /* Object header for location */ + const H5O_obj_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") /* Test whether entry qualifies as a particular type of object */ - if(NULL == (ret_value = H5O__obj_class_real(oh))) + if (NULL == (ret_value = H5O__obj_class_real(oh))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object type") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__obj_class() */ - /*------------------------------------------------------------------------- * Function: H5O__obj_class_real * @@ -1796,8 +1768,8 @@ done: static const H5O_obj_class_t * H5O__obj_class_real(const H5O_t *oh) { - size_t i; /* Local index variable */ - const H5O_obj_class_t *ret_value = NULL; /* Return value */ + size_t i; /* Local index variable */ + const H5O_obj_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1806,23 +1778,22 @@ H5O__obj_class_real(const H5O_t *oh) /* Test whether entry qualifies as a particular type of object */ /* (Note: loop is in reverse order, to test specific objects first) */ - for(i = NELMTS(H5O_obj_class_g); i > 0; --i) { - htri_t isa; /* Is entry a particular type? */ + for (i = NELMTS(H5O_obj_class_g); i > 0; --i) { + htri_t isa; /* Is entry a particular type? */ - if((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0) + if ((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") - else if(isa) + else if (isa) HGOTO_DONE(H5O_obj_class_g[i - 1]) } - if(0 == i) + if (0 == i) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__obj_class_real() */ - /*------------------------------------------------------------------------- * Function: H5O_get_loc * @@ -1839,23 +1810,23 @@ done: H5O_loc_t * H5O_get_loc(hid_t object_id) { - H5O_loc_t *ret_value = NULL; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - switch(H5I_get_type(object_id)) { + switch (H5I_get_type(object_id)) { case H5I_GROUP: - if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id))) + if (NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from group ID") break; case H5I_DATASET: - if(NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id))) + if (NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from dataset ID") break; case H5I_DATATYPE: - if(NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id))) + if (NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from datatype ID") break; @@ -1884,7 +1855,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_loc() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_reset * @@ -1913,7 +1883,6 @@ H5O_loc_reset(H5O_loc_t *loc) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_reset() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_copy * @@ -1939,7 +1908,7 @@ H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth) HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP); /* Invoke correct routine */ - if(depth == H5_COPY_SHALLOW) + if (depth == H5_COPY_SHALLOW) H5O_loc_copy_shallow(dst, src); else H5O_loc_copy_deep(dst, src); @@ -1947,7 +1916,6 @@ H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_copy_shallow * @@ -1982,7 +1950,6 @@ H5O_loc_copy_shallow(H5O_loc_t *dst, H5O_loc_t *src) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_copy_shallow() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_copy_deep * @@ -2013,13 +1980,12 @@ H5O_loc_copy_deep(H5O_loc_t *dst, const H5O_loc_t *src) /* If the original entry was holding open the file, this one should * hold it open, too. */ - if(src->holding_file) + if (src->holding_file) H5F_INCR_NOPEN_OBJS(dst->file); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_copy_deep() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_hold_file * @@ -2044,7 +2010,7 @@ H5O_loc_hold_file(H5O_loc_t *loc) HDassert(loc->file); /* If this location is not already holding its file open, do so. */ - if(!loc->holding_file) { + if (!loc->holding_file) { H5F_INCR_NOPEN_OBJS(loc->file); loc->holding_file = TRUE; } @@ -2052,7 +2018,6 @@ H5O_loc_hold_file(H5O_loc_t *loc) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_hold_file() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_free * @@ -2079,11 +2044,11 @@ H5O_loc_free(H5O_loc_t *loc) HDassert(loc); /* If this location is holding its file open try to close the file. */ - if(loc->holding_file) { + if (loc->holding_file) { H5F_DECR_NOPEN_OBJS(loc->file); loc->holding_file = FALSE; - if(H5F_NOPEN_OBJS(loc->file) <= 0) { - if(H5F_try_close(loc->file, NULL) < 0) + if (H5F_NOPEN_OBJS(loc->file) <= 0) { + if (H5F_try_close(loc->file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") } } @@ -2092,7 +2057,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_loc_free() */ - /*------------------------------------------------------------------------- * Function: H5O_get_hdr_info * @@ -2109,8 +2073,8 @@ done: herr_t H5O_get_hdr_info(const H5O_loc_t *loc, H5O_hdr_info_t *hdr) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2122,21 +2086,20 @@ H5O_get_hdr_info(const H5O_loc_t *loc, H5O_hdr_info_t *hdr) HDmemset(hdr, 0, sizeof(*hdr)); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") /* Get the information for the object header */ - if(H5O__get_hdr_info_real(oh, hdr) < 0) + if (H5O__get_hdr_info_real(oh, hdr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_hdr_info() */ - /*------------------------------------------------------------------------- * Function: H5O__get_hdr_info_real * @@ -2153,9 +2116,9 @@ done: static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) { - const H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ - const H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */ - unsigned u; /* Local index variable */ + const H5O_mesg_t * curr_msg; /* Pointer to current message being operated on */ + const H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -2174,18 +2137,18 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) hdr->flags = oh->flags; /* Iterate over all the messages, accumulating message size & type information */ - hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); - hdr->space.mesg = 0; - hdr->space.free = 0; + hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); + hdr->space.mesg = 0; + hdr->space.free = 0; hdr->mesg.present = 0; - hdr->mesg.shared = 0; - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - uint64_t type_flag; /* Flag for message type */ + hdr->mesg.shared = 0; + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + uint64_t type_flag; /* Flag for message type */ /* Accumulate space usage information, based on the type of message */ - if(H5O_NULL_ID == curr_msg->type->id) + if (H5O_NULL_ID == curr_msg->type->id) hdr->space.free += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size); - else if(H5O_CONT_ID == curr_msg->type->id) + else if (H5O_CONT_ID == curr_msg->type->id) hdr->space.meta += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size); else { hdr->space.meta += (hsize_t)H5O_SIZEOF_MSGHDR_OH(oh); @@ -2197,13 +2160,13 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) hdr->mesg.present |= type_flag; /* Set flag if the message is shared in some way */ - if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \ + if (curr_msg->flags & H5O_MSG_FLAG_SHARED) hdr->mesg.shared |= type_flag; } /* end for */ /* Iterate over all the chunks, adding any gaps to the free space */ hdr->space.total = 0; - for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) { + for (u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) { /* Accumulate the size of the header on disk */ hdr->space.total += curr_chunk->size; @@ -2217,7 +2180,6 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__get_hdr_info_real() */ - /*------------------------------------------------------------------------- * Function: H5O_get_info * @@ -2234,9 +2196,9 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) herr_t H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields) { - const H5O_obj_class_t *obj_class; /* Class of object for header */ - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_obj_class_t *obj_class; /* Class of object for header */ + H5O_t * oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -2245,24 +2207,24 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields) HDassert(oinfo); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Get class for object */ - if(NULL == (obj_class = H5O__obj_class_real(oh))) + if (NULL == (obj_class = H5O__obj_class_real(oh))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") /* Reset the object info structure */ - if(H5O__reset_info2(oinfo) < 0) + if (H5O__reset_info2(oinfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") /* Get basic information, if requested */ - if(fields & H5O_INFO_BASIC) { + if (fields & H5O_INFO_BASIC) { /* Retrieve the file's fileno */ H5F_GET_FILENO(loc->file, oinfo->fileno); /* Set the object's address into the token */ - if(H5VL_native_addr_to_token(loc->file, H5I_FILE, loc->addr, &oinfo->token) < 0) + if (H5VL_native_addr_to_token(loc->file, H5I_FILE, loc->addr, &oinfo->token) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") /* Retrieve the type of the object */ @@ -2273,15 +2235,15 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields) } /* end if */ /* Get time information, if requested */ - if(fields & H5O_INFO_TIME) { - if(oh->version > H5O_VERSION_1) { + if (fields & H5O_INFO_TIME) { + if (oh->version > H5O_VERSION_1) { oinfo->atime = oh->atime; oinfo->mtime = oh->mtime; oinfo->ctime = oh->ctime; oinfo->btime = oh->btime; } /* end if */ else { - htri_t exists; /* Flag if header message of interest exists */ + htri_t exists; /* Flag if header message of interest exists */ /* No information for access & modification fields */ /* (we stopped updating the "modification time" header message for @@ -2293,41 +2255,40 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields) oinfo->btime = 0; /* Might be information for modification time */ - if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME message") - if(exists > 0) { + if (exists > 0) { /* Get "old style" modification time info */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_ID, &oinfo->ctime)) + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_ID, &oinfo->ctime)) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME message") } /* end if */ else { /* Check for "new style" modification time info */ - if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME_NEW message") - if(exists > 0) { + if (exists > 0) { /* Get "new style" modification time info */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_NEW_ID, &oinfo->ctime)) + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_NEW_ID, &oinfo->ctime)) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME_NEW message") } /* end if */ else oinfo->ctime = 0; } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Retrieve # of attributes */ - if(fields & H5O_INFO_NUM_ATTRS) - if(H5O__attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0) + if (fields & H5O_INFO_NUM_ATTRS) + if (H5O__attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_get_info() */ - /*------------------------------------------------------------------------- * Function: H5O_get_native_info * @@ -2344,9 +2305,9 @@ done: herr_t H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fields) { - const H5O_obj_class_t *obj_class; /* Class of object for header */ - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_obj_class_t *obj_class; /* Class of object for header */ + H5O_t * oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -2355,42 +2316,41 @@ H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fie HDassert(oinfo); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Get class for object */ - if(NULL == (obj_class = H5O__obj_class_real(oh))) + if (NULL == (obj_class = H5O__obj_class_real(oh))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") /* Reset the object info structure */ HDmemset(oinfo, 0, sizeof(*oinfo)); /* Get the information for the object header, if requested */ - if(fields & H5O_NATIVE_INFO_HDR) - if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0) + if (fields & H5O_NATIVE_INFO_HDR) + if (H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") /* Get B-tree & heap metadata storage size, if requested */ - if(fields & H5O_NATIVE_INFO_META_SIZE) { + if (fields & H5O_NATIVE_INFO_META_SIZE) { /* Check for 'bh_info' callback for this type of object */ - if(obj_class->bh_info) + if (obj_class->bh_info) /* Call the object's class 'bh_info' routine */ - if((obj_class->bh_info)(loc, oh, &oinfo->meta_size.obj) < 0) + if ((obj_class->bh_info)(loc, oh, &oinfo->meta_size.obj) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info") /* Get B-tree & heap info for any attributes */ - if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0) + if (H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info") } /* end if */ done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_get_native_info() */ - /*------------------------------------------------------------------------- * Function: H5O_get_create_plist * @@ -2407,8 +2367,8 @@ done: herr_t H5O_get_create_plist(const H5O_loc_t *loc, H5P_genplist_t *oc_plist) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2417,35 +2377,38 @@ H5O_get_create_plist(const H5O_loc_t *loc, H5P_genplist_t *oc_plist) HDassert(oc_plist); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Set property values, if they were used for the object */ - if(oh->version > H5O_VERSION_1) { - uint8_t ohdr_flags; /* "User-visible" object header status flags */ + if (oh->version > H5O_VERSION_1) { + uint8_t ohdr_flags; /* "User-visible" object header status flags */ /* Set attribute storage values */ - if(H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list") - if(H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) + if (H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, + "can't set max. # of compact attributes in property list") + if (H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list") /* Mask off non-"user visible" flags */ - H5_CHECKED_ASSIGN(ohdr_flags, uint8_t, oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES), int); + H5_CHECKED_ASSIGN(ohdr_flags, uint8_t, + oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | + H5O_HDR_STORE_TIMES), + int); /* Set object header flags */ - if(H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags") } /* end if */ done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5O_get_nlinks * @@ -2462,8 +2425,8 @@ done: herr_t H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2472,20 +2435,19 @@ H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks) HDassert(nlinks); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Retrieve the # of link messages seen when the object header was loaded */ *nlinks = oh->link_msgs_seen; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_nlinks() */ - /*------------------------------------------------------------------------- * Function: H5O_obj_create * @@ -2502,8 +2464,8 @@ done: void * H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc) { - size_t u; /* Local index variable */ - void *ret_value = NULL; /* Return value */ + size_t u; /* Local index variable */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2514,25 +2476,24 @@ H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc HDassert(obj_loc); /* Iterate through the object classes */ - for(u = 0; u < NELMTS(H5O_obj_class_g); u++) { + for (u = 0; u < NELMTS(H5O_obj_class_g); u++) { /* Check for correct type of object to create */ - if(H5O_obj_class_g[u]->type == obj_type) { + if (H5O_obj_class_g[u]->type == obj_type) { /* Call the object class's 'create' routine */ HDassert(H5O_obj_class_g[u]->create); - if(NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc))) + if (NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") /* Break out of loop */ break; } /* end if */ - } /* end for */ + } /* end for */ HDassert(ret_value); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_obj_create() */ - /*------------------------------------------------------------------------- * Function: H5O_get_oh_addr * @@ -2562,7 +2523,6 @@ H5O_get_oh_addr(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->chunk[0].addr) } /* end H5O_get_oh_addr() */ - /*------------------------------------------------------------------------- * Function: H5O_get_oh_flags * @@ -2579,7 +2539,6 @@ H5O_get_oh_flags(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->flags); /* flags can be 0 */ } /* H5O_get_oh_flags() */ - /*------------------------------------------------------------------------- * Function: H5O_get_oh_mtime * @@ -2601,7 +2560,6 @@ H5O_get_oh_mtime(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->mtime); } /* H5O_get_oh_mtime() */ - /*------------------------------------------------------------------------- * Function: H5O_get_oh_version * @@ -2619,7 +2577,6 @@ H5O_get_oh_version(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->version); } /* H5O_get_oh_version() */ - /*------------------------------------------------------------------------- * Function: H5O_get_rc_and_type * @@ -2636,8 +2593,8 @@ H5O_get_oh_version(const H5O_t *oh) herr_t H5O_get_rc_and_type(const H5O_loc_t *loc, unsigned *rc, H5O_type_t *otype) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2645,26 +2602,25 @@ H5O_get_rc_and_type(const H5O_loc_t *loc, unsigned *rc, H5O_type_t *otype) HDassert(loc); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Set the object's reference count */ - if(rc) + if (rc) *rc = oh->nlink; /* Retrieve the type of the object */ - if(otype) - if(H5O__obj_type_real(oh, otype) < 0) + if (otype) + if (H5O__obj_type_real(oh, otype) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_rc_and_type() */ - /*------------------------------------------------------------------------- * Function: H5O__free_visit_visited * @@ -2678,7 +2634,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/) +H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data /*in,out*/) { FUNC_ENTER_STATIC_NOERR @@ -2687,7 +2643,6 @@ H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSE FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__free_visit_visited() */ - /*------------------------------------------------------------------------- * Function: H5O__visit_cb * @@ -2702,15 +2657,14 @@ H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static herr_t -H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo, - void *_udata) +H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo, void *_udata) { - H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */ - H5G_loc_t obj_loc; /* Location of object */ - H5G_name_t obj_path; /* Object's group hier. path */ - H5O_loc_t obj_oloc; /* Object's object location */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */ + H5G_loc_t obj_loc; /* Location of object */ + H5G_name_t obj_path; /* Object's group hier. path */ + H5O_loc_t obj_oloc; /* Object's object location */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -2720,8 +2674,8 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *l HDassert(udata); /* Check if this is a hard link */ - if(linfo->type == H5L_TYPE_HARD) { - H5_obj_t obj_pos; /* Object "position" for this object */ + if (linfo->type == H5L_TYPE_HARD) { + H5_obj_t obj_pos; /* Object "position" for this object */ /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -2730,7 +2684,7 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *l /* Find the object using the LAPL passed in */ /* (Correctly handles mounted files) */ - if(H5G_loc_find(udata->start_loc, name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(udata->start_loc, name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") obj_found = TRUE; @@ -2739,47 +2693,47 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *l obj_pos.addr = obj_oloc.addr; /* Check if we've seen the object the link references before */ - if(NULL == H5SL_search(udata->visited, &obj_pos)) { - H5O_info2_t oinfo; /* Object info */ + if (NULL == H5SL_search(udata->visited, &obj_pos)) { + H5O_info2_t oinfo; /* Object info */ /* Get the object's info */ - if(H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0) + if (H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info") /* Make the application callback */ ret_value = (udata->op)(udata->obj_id, name, &oinfo, udata->op_data); /* Check for continuing to visit objects */ - if(ret_value == H5_ITER_CONT) { + if (ret_value == H5_ITER_CONT) { /* If its ref count is > 1, we add it to the list of visited objects */ /* (because it could come up again during traversal) */ - if(oinfo.rc > 1) { - H5_obj_t *new_node; /* New object node for visited list */ + if (oinfo.rc > 1) { + H5_obj_t *new_node; /* New object node for visited list */ /* Allocate new object "position" node */ - if((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) + if ((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate object node") /* Set node information */ *new_node = obj_pos; /* Add to list of visited objects */ - if(H5SL_insert(udata->visited, new_node, new_node) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert object node into visited list") + if (H5SL_insert(udata->visited, new_node, new_node) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, + "can't insert object node into visited list") } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ done: /* Release resources */ - if(obj_found && H5G_loc_free(&obj_loc) < 0) + if (obj_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__visit_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__visit * @@ -2815,19 +2769,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields) +H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate2_t op, void *op_data, unsigned fields) { - H5O_iter_visit_ud_t udata; /* User data for callback */ - H5G_loc_t obj_loc; /* Location used to open object */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - H5O_info2_t oinfo; /* Object info struct */ - void *obj = NULL; /* Object */ - H5I_type_t opened_type; /* ID type of object */ - hid_t obj_id = H5I_INVALID_HID; /* ID of object */ - herr_t ret_value = FAIL; /* Return value */ + H5O_iter_visit_ud_t udata; /* User data for callback */ + H5G_loc_t obj_loc; /* Location used to open object */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + H5O_info2_t oinfo; /* Object info struct */ + void * obj = NULL; /* Object */ + H5I_type_t opened_type; /* ID type of object */ + hid_t obj_id = H5I_INVALID_HID; /* ID of object */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -2843,97 +2797,97 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Get the object's info */ - if(H5O_get_info(&obj_oloc, &oinfo, fields) < 0) + if (H5O_get_info(&obj_oloc, &oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") /* Open the object */ /* (Takes ownership of the obj_loc information) */ - if(NULL == (obj = H5O_open_by_loc(&obj_loc, &opened_type))) + if (NULL == (obj = H5O_open_by_loc(&obj_loc, &opened_type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") /* Get an ID for the visited object */ - if((obj_id = H5VL_wrap_register(opened_type, obj, TRUE)) < 0) + if ((obj_id = H5VL_wrap_register(opened_type, obj, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register visited object") /* Make callback for starting object */ - if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) + if ((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects") /* Check return value of first callback */ - if(ret_value != H5_ITER_CONT) + if (ret_value != H5_ITER_CONT) HGOTO_DONE(ret_value); /* Check for object being a group */ - if(oinfo.type == H5O_TYPE_GROUP) { - H5G_loc_t start_loc; /* Location of starting group */ - H5G_loc_t vis_loc; /* Location of visited group */ + if (oinfo.type == H5O_TYPE_GROUP) { + H5G_loc_t start_loc; /* Location of starting group */ + H5G_loc_t vis_loc; /* Location of visited group */ /* Get the location of the starting group */ - if(H5G_loc(obj_id, &start_loc) < 0) + if (H5G_loc(obj_id, &start_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Set up user data for visiting links */ - udata.obj_id = obj_id; + udata.obj_id = obj_id; udata.start_loc = &start_loc; - udata.op = op; - udata.op_data = op_data; - udata.fields = fields; + udata.op = op; + udata.op_data = op_data; + udata.fields = fields; /* Create skip list to store visited object information */ - if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) + if ((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects") /* If its ref count is > 1, we add it to the list of visited objects */ /* (because it could come up again during traversal) */ - if(oinfo.rc > 1) { - H5_obj_t *obj_pos; /* New object node for visited list */ + if (oinfo.rc > 1) { + H5_obj_t *obj_pos; /* New object node for visited list */ /* Allocate new object "position" node */ - if((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) + if ((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "can't allocate object node") /* Construct unique "position" for this object */ obj_pos->fileno = oinfo.fileno; /* De-serialize object token into an object address */ - if(H5VL_native_token_to_addr(loc->oloc->file, H5I_FILE, oinfo.token, &(obj_pos->addr)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + if (H5VL_native_token_to_addr(loc->oloc->file, H5I_FILE, oinfo.token, &(obj_pos->addr)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") /* Add to list of visited objects */ - if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) + if (H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") } /* Get the location of the visited group */ - if(H5G_loc(obj_id, &vis_loc) < 0) + if (H5G_loc(obj_id, &vis_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Call internal group visitation routine */ - if((ret_value = H5G_visit(&vis_loc, ".", idx_type, order, H5O__visit_cb, &udata)) < 0) + if ((ret_value = H5G_visit(&vis_loc, ".", idx_type, order, H5O__visit_cb, &udata)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") } /* end if */ done: -/* XXX (VOL MERGE): Probably also want to consider closing obj here on failures */ - if(obj_id != H5I_INVALID_HID) { - if(H5I_dec_app_ref(obj_id) < 0) + /* XXX (VOL MERGE): Probably also want to consider closing obj here on failures */ + if (obj_id != H5I_INVALID_HID) { + if (H5I_dec_app_ref(obj_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") } - else if(loc_found && H5G_loc_free(&obj_loc) < 0) + else if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - if(udata.visited) + if (udata.visited) H5SL_destroy(udata.visited, H5O__free_visit_visited, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__visit() */ - /*------------------------------------------------------------------------- * Function: H5O__inc_rc * @@ -2950,7 +2904,7 @@ done: herr_t H5O__inc_rc(H5O_t *oh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2958,8 +2912,8 @@ H5O__inc_rc(H5O_t *oh) HDassert(oh); /* Pin the object header when the reference count goes above 0 */ - if(oh->rc == 0) - if(H5AC_pin_protected_entry(oh) < 0) + if (oh->rc == 0) + if (H5AC_pin_protected_entry(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Increment reference count */ @@ -2969,7 +2923,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__inc_rc() */ - /*------------------------------------------------------------------------- * Function: H5O__dec_rc * @@ -2986,7 +2939,7 @@ done: herr_t H5O__dec_rc(H5O_t *oh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2997,15 +2950,14 @@ H5O__dec_rc(H5O_t *oh) oh->rc--; /* Unpin the object header when the reference count goes back to 0 */ - if(oh->rc == 0) - if(H5AC_unpin_entry(oh) < 0) + if (oh->rc == 0) + if (H5AC_unpin_entry(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dec_rc() */ - /*------------------------------------------------------------------------- * Function: H5O_dec_rc_by_loc * @@ -3023,8 +2975,8 @@ done: herr_t H5O_dec_rc_by_loc(const H5O_loc_t *loc) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3032,23 +2984,22 @@ H5O_dec_rc_by_loc(const H5O_loc_t *loc) HDassert(loc); /* Get header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Decrement the reference count on the object header */ /* (which will unpin it, if appropriate) */ - if(H5O__dec_rc(oh) < 0) + if (H5O__dec_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dec_rc_by_loc() */ - /*------------------------------------------------------------------------- * Function: H5O_get_proxy * @@ -3072,7 +3023,6 @@ H5O_get_proxy(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->proxy) } /* end H5O_get_proxy() */ - /*------------------------------------------------------------------------- * Function: H5O__free * @@ -3089,8 +3039,8 @@ H5O_get_proxy(const H5O_t *oh) herr_t H5O__free(H5O_t *oh) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3099,20 +3049,20 @@ H5O__free(H5O_t *oh) HDassert(0 == oh->rc); /* Destroy chunks */ - if(oh->chunk) { - for(u = 0; u < oh->nchunks; u++) + if (oh->chunk) { + for (u = 0; u < oh->nchunks; u++) oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image); oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk); } /* end if */ /* Destroy messages */ - if(oh->mesg) { - for(u = 0; u < oh->nmesgs; u++) { + if (oh->mesg) { + for (u = 0; u < oh->nmesgs; u++) { #ifndef NDEBUG /* Verify that message is clean, unless it could have been marked * dirty by decoding */ - if(oh->ndecode_dirtied && oh->mesg[u].dirty) + if (oh->ndecode_dirtied && oh->mesg[u].dirty) oh->ndecode_dirtied--; else HDassert(oh->mesg[u].dirty == 0); @@ -3128,8 +3078,8 @@ H5O__free(H5O_t *oh) } /* end if */ /* Destroy the proxy */ - if(oh->proxy) - if(H5AC_proxy_entry_dest(oh->proxy) < 0) + if (oh->proxy) + if (H5AC_proxy_entry_dest(oh->proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy virtual entry used for proxy") /* destroy object header */ @@ -3155,9 +3105,8 @@ H5O__reset_info2(H5O_info2_t *oinfo) /* Reset the passed-in info struct */ HDmemset(oinfo, 0, sizeof(H5O_info2_t)); - oinfo->type = H5O_TYPE_UNKNOWN; + oinfo->type = H5O_TYPE_UNKNOWN; oinfo->token = H5O_TOKEN_UNDEF; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5O__reset_info2() */ - diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 8e6e204..b99e7a9 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -17,69 +17,62 @@ * Purpose: Messages related to data layout. */ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ - +#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ /* Local macros */ - /* PRIVATE PROTOTYPES */ -static void *H5O__layout_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__layout_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O__layout_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O__layout_copy(const void *_mesg, void *_dest); +static void * H5O__layout_copy(const void *_mesg, void *_dest); static size_t H5O__layout_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__layout_reset(void *_mesg); static herr_t H5O__layout_free(void *_mesg); static herr_t H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static herr_t H5O__layout_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static void *H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, - H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, - H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__layout_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__layout_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *udata); +static void * H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__layout_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{ - H5O_LAYOUT_ID, /* message id number */ - "layout", /* message name for debugging */ - sizeof(H5O_layout_t), /* native message size */ - 0, /* messages are sharable? */ - H5O__layout_decode, /* decode message */ - H5O__layout_encode, /* encode message */ - H5O__layout_copy, /* copy the native value */ - H5O__layout_size, /* size of message on disk */ - H5O__layout_reset, /* reset method */ - H5O__layout_free, /* free the struct */ - H5O__layout_delete, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - H5O__layout_pre_copy_file, /* pre copy native value to file */ - H5O__layout_copy_file, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__layout_debug /* debug the message */ + H5O_LAYOUT_ID, /* message id number */ + "layout", /* message name for debugging */ + sizeof(H5O_layout_t), /* native message size */ + 0, /* messages are sharable? */ + H5O__layout_decode, /* decode message */ + H5O__layout_encode, /* encode message */ + H5O__layout_copy, /* copy the native value */ + H5O__layout_size, /* size of message on disk */ + H5O__layout_reset, /* reset method */ + H5O__layout_free, /* free the struct */ + H5O__layout_delete, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + H5O__layout_pre_copy_file, /* pre copy native value to file */ + H5O__layout_copy_file, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__layout_debug /* debug the message */ }}; - /* Declare a free list to manage the H5O_layout_t struct */ H5FL_DEFINE(H5O_layout_t); - /*------------------------------------------------------------------------- * Function: H5O__layout_decode * @@ -96,14 +89,13 @@ H5FL_DEFINE(H5O_layout_t); *------------------------------------------------------------------------- */ static void * -H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_layout_t *mesg = NULL; - uint8_t *heap_block = NULL; - unsigned u; - void *ret_value = NULL; /* Return value */ + H5O_layout_t *mesg = NULL; + uint8_t * heap_block = NULL; + unsigned u; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -112,20 +104,20 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(NULL == (mesg = H5FL_CALLOC(H5O_layout_t))) + if (NULL == (mesg = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") mesg->storage.type = H5D_LAYOUT_ERROR; mesg->version = *p++; - if(mesg->version < H5O_LAYOUT_VERSION_1 || mesg->version > H5O_LAYOUT_VERSION_4) + if (mesg->version < H5O_LAYOUT_VERSION_1 || mesg->version > H5O_LAYOUT_VERSION_4) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for layout message") - if(mesg->version < H5O_LAYOUT_VERSION_3) { - unsigned ndims; /* Num dimensions in chunk */ + if (mesg->version < H5O_LAYOUT_VERSION_3) { + unsigned ndims; /* Num dimensions in chunk */ /* Dimensionality */ ndims = *p++; - if(!ndims || ndims > H5O_LAYOUT_NDIMS) + if (!ndims || ndims > H5O_LAYOUT_NDIMS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is out of range") /* Layout class */ @@ -139,13 +131,13 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, p += 5; /* Address */ - if(mesg->type == H5D_CONTIGUOUS) { + if (mesg->type == H5D_CONTIGUOUS) { H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); /* Set the layout operations */ mesg->ops = H5D_LOPS_CONTIG; } /* end if */ - else if(mesg->type == H5D_CHUNKED) { + else if (mesg->type == H5D_CHUNKED) { H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Set the layout operations */ @@ -154,7 +146,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, /* Set the chunk operations */ /* (Only "btree" indexing type currently supported in this version) */ mesg->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE; - mesg->storage.u.chunk.ops = H5D_COPS_BTREE; + mesg->storage.u.chunk.ops = H5D_COPS_BTREE; } /* end if */ else { /* Sanity check */ @@ -165,49 +157,51 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, } /* end else */ /* Read the size */ - if(mesg->type != H5D_CHUNKED) { + if (mesg->type != H5D_CHUNKED) { /* Don't compute size of contiguous storage here, due to possible * truncation of the dimension sizes when they were stored in this * version of the layout message. Compute the contiguous storage * size in the dataset code, where we've got the dataspace * information available also. - QAK 5/26/04 */ - p += ndims * 4; /* Skip over dimension sizes (32-bit quantities) */ - } /* end if */ + p += ndims * 4; /* Skip over dimension sizes (32-bit quantities) */ + } /* end if */ else { - mesg->u.chunk.ndims=ndims; - for(u = 0; u < ndims; u++) + mesg->u.chunk.ndims = ndims; + for (u = 0; u < ndims; u++) UINT32DECODE(p, mesg->u.chunk.dim[u]); /* Compute chunk size */ - for(u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < ndims; u++) + for (u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < ndims; u++) mesg->u.chunk.size *= mesg->u.chunk.dim[u]; } /* end if */ - if(mesg->type == H5D_COMPACT) { + if (mesg->type == H5D_COMPACT) { UINT32DECODE(p, mesg->storage.u.compact.size); - if(mesg->storage.u.compact.size > 0) { - if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer") + if (mesg->storage.u.compact.size > 0) { + if (NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for compact data buffer") H5MM_memcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size); p += mesg->storage.u.compact.size; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* Layout & storage class */ mesg->type = mesg->storage.type = (H5D_layout_t)*p++; /* Interpret the rest of the message according to the layout class */ - switch(mesg->type) { + switch (mesg->type) { case H5D_COMPACT: /* Compact data size */ UINT16DECODE(p, mesg->storage.u.compact.size); - if(mesg->storage.u.compact.size > 0) { + if (mesg->storage.u.compact.size > 0) { /* Allocate space for compact data */ - if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed for compact data buffer") + if (NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, + "memory allocation failed for compact data buffer") /* Compact data */ H5MM_memcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size); @@ -230,36 +224,37 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, break; case H5D_CHUNKED: - if(mesg->version < H5O_LAYOUT_VERSION_4) { + if (mesg->version < H5O_LAYOUT_VERSION_4) { /* Set the chunked layout flags */ mesg->u.chunk.flags = (uint8_t)0; /* Dimensionality */ mesg->u.chunk.ndims = *p++; - if(mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) + if (mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is too large") /* B-tree address */ H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Chunk dimensions */ - for(u = 0; u < mesg->u.chunk.ndims; u++) { + for (u = 0; u < mesg->u.chunk.ndims; u++) { UINT32DECODE(p, mesg->u.chunk.dim[u]); /* Just in case that something goes very wrong, such as file corruption. */ - if(mesg->u.chunk.dim[u] == 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "chunk dimension must be positive: mesg->u.chunk.dim[%u] = %u", - u, mesg->u.chunk.dim[u]) + if (mesg->u.chunk.dim[u] == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, + "chunk dimension must be positive: mesg->u.chunk.dim[%u] = %u", u, + mesg->u.chunk.dim[u]) } /* end for */ /* Compute chunk size */ - for(u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++) + for (u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++) mesg->u.chunk.size *= mesg->u.chunk.dim[u]; /* Set the chunk operations */ /* (Only "btree" indexing type supported with v3 of message format) */ mesg->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE; - mesg->storage.u.chunk.ops = H5D_COPS_BTREE; + mesg->storage.u.chunk.ops = H5D_COPS_BTREE; } /* end if */ else { /* Get the chunked layout flags */ @@ -269,44 +264,45 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, /* (Currently issues an error for all non-zero values, * until features are added for the flags) */ - if(mesg->u.chunk.flags & ~H5O_LAYOUT_ALL_CHUNK_FLAGS) + if (mesg->u.chunk.flags & ~H5O_LAYOUT_ALL_CHUNK_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad flag value for message") /* Dimensionality */ mesg->u.chunk.ndims = *p++; - if(mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) + if (mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "dimensionality is too large") /* Encoded # of bytes for each chunk dimension */ mesg->u.chunk.enc_bytes_per_dim = *p++; - if(mesg->u.chunk.enc_bytes_per_dim == 0 || mesg->u.chunk.enc_bytes_per_dim > 8) + if (mesg->u.chunk.enc_bytes_per_dim == 0 || mesg->u.chunk.enc_bytes_per_dim > 8) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "encoded chunk dimension size is too large") /* Chunk dimensions */ - for(u = 0; u < mesg->u.chunk.ndims; u++) + for (u = 0; u < mesg->u.chunk.ndims; u++) UINT64DECODE_VAR(p, mesg->u.chunk.dim[u], mesg->u.chunk.enc_bytes_per_dim); /* Compute chunk size */ - for(u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++) + for (u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++) mesg->u.chunk.size *= mesg->u.chunk.dim[u]; /* Chunk index type */ mesg->u.chunk.idx_type = (H5D_chunk_index_t)*p++; - if(mesg->u.chunk.idx_type >= H5D_CHUNK_IDX_NTYPES) + if (mesg->u.chunk.idx_type >= H5D_CHUNK_IDX_NTYPES) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "unknown chunk index type") mesg->storage.u.chunk.idx_type = mesg->u.chunk.idx_type; - switch(mesg->u.chunk.idx_type) { + switch (mesg->u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "v1 B-tree index type should never be in a v4 layout message") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "v1 B-tree index type should never be in a v4 layout message") break; - case H5D_CHUNK_IDX_NONE: /* Implicit Index */ + case H5D_CHUNK_IDX_NONE: /* Implicit Index */ mesg->storage.u.chunk.ops = H5D_COPS_NONE; break; - case H5D_CHUNK_IDX_SINGLE: /* Single Chunk Index */ - if(mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + case H5D_CHUNK_IDX_SINGLE: /* Single Chunk Index */ + if (mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { H5F_DECODE_LENGTH(f, p, mesg->storage.u.chunk.u.single.nbytes); UINT32DECODE(p, mesg->storage.u.chunk.u.single.filter_mask); } /* end if */ @@ -318,8 +314,9 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = *p++; - if(0 == mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid fixed array creation parameter") + if (0 == mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid fixed array creation parameter") /* Set the chunk operations */ mesg->storage.u.chunk.ops = H5D_COPS_FARRAY; @@ -328,26 +325,31 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5D_CHUNK_IDX_EARRAY: /* Extensible array creation parameters */ mesg->u.chunk.u.earray.cparam.max_nelmts_bits = *p++; - if(0 == mesg->u.chunk.u.earray.cparam.max_nelmts_bits) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.max_nelmts_bits) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") mesg->u.chunk.u.earray.cparam.idx_blk_elmts = *p++; - if(0 == mesg->u.chunk.u.earray.cparam.idx_blk_elmts) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.idx_blk_elmts) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") mesg->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs = *p++; - if(0 == mesg->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") mesg->u.chunk.u.earray.cparam.data_blk_min_elmts = *p++; - if(0 == mesg->u.chunk.u.earray.cparam.data_blk_min_elmts) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.data_blk_min_elmts) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = *p++; - if(0 == mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") /* Set the chunk operations */ mesg->storage.u.chunk.ops = H5D_COPS_EARRAY; break; - case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ + case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ UINT32DECODE(p, mesg->u.chunk.u.btree2.cparam.node_size); mesg->u.chunk.u.btree2.cparam.split_percent = *p++; mesg->u.chunk.u.btree2.cparam.merge_percent = *p++; @@ -371,7 +373,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5D_VIRTUAL: /* Check version */ - if(mesg->version < H5O_LAYOUT_VERSION_4) + if (mesg->version < H5O_LAYOUT_VERSION_4) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "invalid layout version with virtual layout") /* Heap information */ @@ -379,115 +381,147 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, UINT32DECODE(p, mesg->storage.u.virt.serial_list_hobjid.idx); /* Initialize other fields */ - mesg->storage.u.virt.list_nused = 0; - mesg->storage.u.virt.list = NULL; + mesg->storage.u.virt.list_nused = 0; + mesg->storage.u.virt.list = NULL; mesg->storage.u.virt.list_nalloc = 0; - mesg->storage.u.virt.view = H5D_VDS_ERROR; - mesg->storage.u.virt.printf_gap = HSIZE_UNDEF; + mesg->storage.u.virt.view = H5D_VDS_ERROR; + mesg->storage.u.virt.printf_gap = HSIZE_UNDEF; mesg->storage.u.virt.source_fapl = -1; mesg->storage.u.virt.source_dapl = -1; - mesg->storage.u.virt.init = FALSE; + mesg->storage.u.virt.init = FALSE; /* Decode heap block if it exists */ - if(mesg->storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { + if (mesg->storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { const uint8_t *heap_block_p; - uint8_t heap_vers; - size_t block_size = 0; - size_t tmp_size; - hsize_t tmp_hsize; - uint32_t stored_chksum; - uint32_t computed_chksum; - size_t i; + uint8_t heap_vers; + size_t block_size = 0; + size_t tmp_size; + hsize_t tmp_hsize; + uint32_t stored_chksum; + uint32_t computed_chksum; + size_t i; /* Read heap */ - if(NULL == (heap_block = (uint8_t *)H5HG_read(f, &(mesg->storage.u.virt.serial_list_hobjid), NULL, &block_size))) + if (NULL == (heap_block = (uint8_t *)H5HG_read( + f, &(mesg->storage.u.virt.serial_list_hobjid), NULL, &block_size))) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "Unable to read global heap block") heap_block_p = (const uint8_t *)heap_block; /* Decode the version number of the heap block encoding */ heap_vers = (uint8_t)*heap_block_p++; - if((uint8_t)H5O_LAYOUT_VDS_GH_ENC_VERS != heap_vers) - HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "bad version # of encoded VDS heap information, expected %u, got %u", (unsigned)H5O_LAYOUT_VDS_GH_ENC_VERS, (unsigned)heap_vers) + if ((uint8_t)H5O_LAYOUT_VDS_GH_ENC_VERS != heap_vers) + HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, + "bad version # of encoded VDS heap information, expected %u, got %u", + (unsigned)H5O_LAYOUT_VDS_GH_ENC_VERS, (unsigned)heap_vers) /* Number of entries */ H5F_DECODE_LENGTH(f, heap_block_p, tmp_hsize) /* Allocate entry list */ - if(NULL == (mesg->storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc((size_t)tmp_hsize * sizeof(H5O_storage_virtual_ent_t)))) + if (NULL == (mesg->storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc( + (size_t)tmp_hsize * sizeof(H5O_storage_virtual_ent_t)))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate heap block") mesg->storage.u.virt.list_nalloc = (size_t)tmp_hsize; - mesg->storage.u.virt.list_nused = (size_t)tmp_hsize; + mesg->storage.u.virt.list_nused = (size_t)tmp_hsize; /* Decode each entry */ - for(i = 0; i < mesg->storage.u.virt.list_nused; i++) { + for (i = 0; i < mesg->storage.u.virt.list_nused; i++) { /* Source file name */ tmp_size = HDstrlen((const char *)heap_block_p) + 1; - if(NULL == (mesg->storage.u.virt.list[i].source_file_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source file name") - (void)H5MM_memcpy(mesg->storage.u.virt.list[i].source_file_name, heap_block_p, tmp_size); + if (NULL == + (mesg->storage.u.virt.list[i].source_file_name = (char *)H5MM_malloc(tmp_size))) + HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, + "unable to allocate memory for source file name") + (void)H5MM_memcpy(mesg->storage.u.virt.list[i].source_file_name, heap_block_p, + tmp_size); heap_block_p += tmp_size; /* Source dataset name */ tmp_size = HDstrlen((const char *)heap_block_p) + 1; - if(NULL == (mesg->storage.u.virt.list[i].source_dset_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source dataset name") - (void)H5MM_memcpy(mesg->storage.u.virt.list[i].source_dset_name, heap_block_p, tmp_size); + if (NULL == + (mesg->storage.u.virt.list[i].source_dset_name = (char *)H5MM_malloc(tmp_size))) + HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, + "unable to allocate memory for source dataset name") + (void)H5MM_memcpy(mesg->storage.u.virt.list[i].source_dset_name, heap_block_p, + tmp_size); heap_block_p += tmp_size; /* Source selection */ - if(H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_select, &heap_block_p) < 0) + if (H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_select, + &heap_block_p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode source space selection") /* Virtual selection */ - if(H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_dset.virtual_select, &heap_block_p) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode virtual space selection") + if (H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_dset.virtual_select, + &heap_block_p) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, + "can't decode virtual space selection") /* Parse source file and dataset names for "printf" * style format specifiers */ - if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_file_name, &mesg->storage.u.virt.list[i].parsed_source_file_name, &mesg->storage.u.virt.list[i].psfn_static_strlen, &mesg->storage.u.virt.list[i].psfn_nsubs) < 0) + if (H5D_virtual_parse_source_name( + mesg->storage.u.virt.list[i].source_file_name, + &mesg->storage.u.virt.list[i].parsed_source_file_name, + &mesg->storage.u.virt.list[i].psfn_static_strlen, + &mesg->storage.u.virt.list[i].psfn_nsubs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't parse source file name") - if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_dset_name, &mesg->storage.u.virt.list[i].parsed_source_dset_name, &mesg->storage.u.virt.list[i].psdn_static_strlen, &mesg->storage.u.virt.list[i].psdn_nsubs) < 0) + if (H5D_virtual_parse_source_name( + mesg->storage.u.virt.list[i].source_dset_name, + &mesg->storage.u.virt.list[i].parsed_source_dset_name, + &mesg->storage.u.virt.list[i].psdn_static_strlen, + &mesg->storage.u.virt.list[i].psdn_nsubs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't parse source dataset name") /* Set source names in source_dset struct */ - if((mesg->storage.u.virt.list[i].psfn_nsubs == 0) - && (mesg->storage.u.virt.list[i].psdn_nsubs == 0)) { - if(mesg->storage.u.virt.list[i].parsed_source_file_name) - mesg->storage.u.virt.list[i].source_dset.file_name = mesg->storage.u.virt.list[i].parsed_source_file_name->name_segment; + if ((mesg->storage.u.virt.list[i].psfn_nsubs == 0) && + (mesg->storage.u.virt.list[i].psdn_nsubs == 0)) { + if (mesg->storage.u.virt.list[i].parsed_source_file_name) + mesg->storage.u.virt.list[i].source_dset.file_name = + mesg->storage.u.virt.list[i].parsed_source_file_name->name_segment; else - mesg->storage.u.virt.list[i].source_dset.file_name = mesg->storage.u.virt.list[i].source_file_name; - if(mesg->storage.u.virt.list[i].parsed_source_dset_name) - mesg->storage.u.virt.list[i].source_dset.dset_name = mesg->storage.u.virt.list[i].parsed_source_dset_name->name_segment; + mesg->storage.u.virt.list[i].source_dset.file_name = + mesg->storage.u.virt.list[i].source_file_name; + if (mesg->storage.u.virt.list[i].parsed_source_dset_name) + mesg->storage.u.virt.list[i].source_dset.dset_name = + mesg->storage.u.virt.list[i].parsed_source_dset_name->name_segment; else - mesg->storage.u.virt.list[i].source_dset.dset_name = mesg->storage.u.virt.list[i].source_dset_name; + mesg->storage.u.virt.list[i].source_dset.dset_name = + mesg->storage.u.virt.list[i].source_dset_name; } /* end if */ /* unlim_dim fields */ - mesg->storage.u.virt.list[i].unlim_dim_source = H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_select); - mesg->storage.u.virt.list[i].unlim_dim_virtual = H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_dset.virtual_select); - mesg->storage.u.virt.list[i].unlim_extent_source = HSIZE_UNDEF; + mesg->storage.u.virt.list[i].unlim_dim_source = + H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_select); + mesg->storage.u.virt.list[i].unlim_dim_virtual = + H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_dset.virtual_select); + mesg->storage.u.virt.list[i].unlim_extent_source = HSIZE_UNDEF; mesg->storage.u.virt.list[i].unlim_extent_virtual = HSIZE_UNDEF; - mesg->storage.u.virt.list[i].clip_size_source = HSIZE_UNDEF; - mesg->storage.u.virt.list[i].clip_size_virtual = HSIZE_UNDEF; + mesg->storage.u.virt.list[i].clip_size_source = HSIZE_UNDEF; + mesg->storage.u.virt.list[i].clip_size_virtual = HSIZE_UNDEF; /* Clipped selections */ - if(mesg->storage.u.virt.list[i].unlim_dim_virtual < 0) { - mesg->storage.u.virt.list[i].source_dset.clipped_source_select = mesg->storage.u.virt.list[i].source_select; - mesg->storage.u.virt.list[i].source_dset.clipped_virtual_select = mesg->storage.u.virt.list[i].source_dset.virtual_select; + if (mesg->storage.u.virt.list[i].unlim_dim_virtual < 0) { + mesg->storage.u.virt.list[i].source_dset.clipped_source_select = + mesg->storage.u.virt.list[i].source_select; + mesg->storage.u.virt.list[i].source_dset.clipped_virtual_select = + mesg->storage.u.virt.list[i].source_dset.virtual_select; } /* end if */ /* Check mapping for validity (do both pre and post * checks here, since we had to allocate the entry list * before decoding the selections anyways) */ - if(H5D_virtual_check_mapping_pre(mesg->storage.u.virt.list[i].source_dset.virtual_select, mesg->storage.u.virt.list[i].source_select, H5O_VIRTUAL_STATUS_INVALID) < 0) + if (H5D_virtual_check_mapping_pre( + mesg->storage.u.virt.list[i].source_dset.virtual_select, + mesg->storage.u.virt.list[i].source_select, H5O_VIRTUAL_STATUS_INVALID) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid mapping selections") - if(H5D_virtual_check_mapping_post(&mesg->storage.u.virt.list[i]) < 0) + if (H5D_virtual_check_mapping_post(&mesg->storage.u.virt.list[i]) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid mapping entry") /* Update min_dims */ - if(H5D_virtual_update_min_dims(mesg, i) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to update virtual dataset minimum dimensions") + if (H5D_virtual_update_min_dims(mesg, i) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, + "unable to update virtual dataset minimum dimensions") } /* end for */ /* Read stored checksum */ @@ -497,11 +531,12 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, computed_chksum = H5_checksum_metadata(heap_block, block_size - (size_t)4, 0); /* Verify checksum */ - if(stored_chksum != computed_chksum) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "incorrect metadata checksum for global heap block") + if (stored_chksum != computed_chksum) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "incorrect metadata checksum for global heap block") /* Verify that the heap block size is correct */ - if((size_t)(heap_block_p - heap_block) != block_size) + if ((size_t)(heap_block_p - heap_block) != block_size) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "incorrect heap block size") } /* end if */ @@ -515,16 +550,16 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, default: HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class") } /* end switch */ - } /* end else */ + } /* end else */ /* Set return value */ ret_value = mesg; done: - if(ret_value == NULL) - if(mesg) { - if(mesg->type == H5D_VIRTUAL) - if(H5D__virtual_reset_layout(mesg) < 0) + if (ret_value == NULL) + if (mesg) { + if (mesg->type == H5D_VIRTUAL) + if (H5D__virtual_reset_layout(mesg) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to reset virtual layout") mesg = H5FL_FREE(H5O_layout_t, mesg); } /* end if */ @@ -534,7 +569,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_encode * @@ -554,9 +588,9 @@ done: static herr_t H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -566,21 +600,20 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, HDassert(p); /* Message version */ - *p++ = (uint8_t)((mesg->version < H5O_LAYOUT_VERSION_3) ? - H5O_LAYOUT_VERSION_3 : mesg->version); + *p++ = (uint8_t)((mesg->version < H5O_LAYOUT_VERSION_3) ? H5O_LAYOUT_VERSION_3 : mesg->version); /* Layout class */ *p++ = (uint8_t)mesg->type; /* Write out layout class specific information */ - switch(mesg->type) { + switch (mesg->type) { case H5D_COMPACT: /* Size of raw data */ UINT16ENCODE(p, mesg->storage.u.compact.size); /* Raw data */ - if(mesg->storage.u.compact.size > 0) { - if(mesg->storage.u.compact.buf) + if (mesg->storage.u.compact.size > 0) { + if (mesg->storage.u.compact.buf) H5MM_memcpy(p, mesg->storage.u.compact.buf, mesg->storage.u.compact.size); else HDmemset(p, 0, mesg->storage.u.compact.size); @@ -597,7 +630,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, break; case H5D_CHUNKED: - if(mesg->version < H5O_LAYOUT_VERSION_4) { + if (mesg->version < H5O_LAYOUT_VERSION_4) { /* Number of dimensions */ HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); *p++ = (uint8_t)mesg->u.chunk.ndims; @@ -606,7 +639,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, H5F_addr_encode(f, &p, mesg->storage.u.chunk.idx_addr); /* Dimension sizes */ - for(u = 0; u < mesg->u.chunk.ndims; u++) + for (u = 0; u < mesg->u.chunk.ndims; u++) UINT32ENCODE(p, mesg->u.chunk.dim[u]); } /* end if */ else { @@ -622,23 +655,24 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, *p++ = (uint8_t)mesg->u.chunk.enc_bytes_per_dim; /* Dimension sizes */ - for(u = 0; u < mesg->u.chunk.ndims; u++) + for (u = 0; u < mesg->u.chunk.ndims; u++) UINT64ENCODE_VAR(p, mesg->u.chunk.dim[u], mesg->u.chunk.enc_bytes_per_dim); /* Chunk index type */ *p++ = (uint8_t)mesg->u.chunk.idx_type; - switch(mesg->u.chunk.idx_type) { + switch (mesg->u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "v1 B-tree index type should never be in a v4 layout message") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, + "v1 B-tree index type should never be in a v4 layout message") break; - case H5D_CHUNK_IDX_NONE: /* Implicit */ + case H5D_CHUNK_IDX_NONE: /* Implicit */ break; - case H5D_CHUNK_IDX_SINGLE: /* Single Chunk */ + case H5D_CHUNK_IDX_SINGLE: /* Single Chunk */ /* Filter information */ - if(mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + if (mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { H5F_ENCODE_LENGTH(f, p, mesg->storage.u.chunk.u.single.nbytes); UINT32ENCODE(p, mesg->storage.u.chunk.u.single.filter_mask); } /* end if */ @@ -658,7 +692,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, *p++ = mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits; break; - case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ + case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ UINT32ENCODE(p, mesg->u.chunk.u.btree2.cparam.node_size); *p++ = mesg->u.chunk.u.btree2.cparam.split_percent; *p++ = mesg->u.chunk.u.btree2.cparam.merge_percent; @@ -694,7 +728,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_copy * @@ -713,9 +746,9 @@ done: static void * H5O__layout_copy(const void *_mesg, void *_dest) { - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - H5O_layout_t *dest = (H5O_layout_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; + H5O_layout_t * dest = (H5O_layout_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -723,26 +756,27 @@ H5O__layout_copy(const void *_mesg, void *_dest) HDassert(mesg); /* Allocate destination message, if necessary */ - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_layout_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "layout message allocation failed") /* copy */ *dest = *mesg; /* Special actions for each type of layout */ - switch(mesg->type) { + switch (mesg->type) { case H5D_COMPACT: /* Deep copy the buffer for compact datasets also */ - if(mesg->storage.u.compact.size > 0) { + if (mesg->storage.u.compact.size > 0) { /* Sanity check */ HDassert(mesg->storage.u.compact.buf); /* Allocate memory for the raw data */ - if(NULL == (dest->storage.u.compact.buf = H5MM_malloc(dest->storage.u.compact.size))) + if (NULL == (dest->storage.u.compact.buf = H5MM_malloc(dest->storage.u.compact.size))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") /* Copy over the raw data */ - H5MM_memcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, dest->storage.u.compact.size); + H5MM_memcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, + dest->storage.u.compact.size); } /* end if */ else HDassert(dest->storage.u.compact.buf == NULL); @@ -754,12 +788,12 @@ H5O__layout_copy(const void *_mesg, void *_dest) case H5D_CHUNKED: /* Reset the pointer of the chunked storage index but not the address */ - if(dest->storage.u.chunk.ops) + if (dest->storage.u.chunk.ops) H5D_chunk_idx_reset(&dest->storage.u.chunk, FALSE); break; case H5D_VIRTUAL: - if(H5D__virtual_copy_layout(dest) < 0) + if (H5D__virtual_copy_layout(dest) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy virtual layout") break; @@ -773,14 +807,13 @@ H5O__layout_copy(const void *_mesg, void *_dest) ret_value = dest; done: - if(ret_value == NULL) - if(NULL == _dest) + if (ret_value == NULL) + if (NULL == _dest) dest = H5FL_FREE(H5O_layout_t, dest); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_copy() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_size * @@ -800,8 +833,8 @@ done: static size_t H5O__layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - size_t ret_value = 0; /* Return value */ + const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -816,7 +849,6 @@ H5O__layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const vo FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_size() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_reset * @@ -833,22 +865,22 @@ H5O__layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const vo static herr_t H5O__layout_reset(void *_mesg) { - H5O_layout_t *mesg = (H5O_layout_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *mesg = (H5O_layout_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(mesg) { + if (mesg) { /* Free the compact storage buffer */ - if(H5D_COMPACT == mesg->type) + if (H5D_COMPACT == mesg->type) mesg->storage.u.compact.buf = H5MM_xfree(mesg->storage.u.compact.buf); - else if(H5D_VIRTUAL == mesg->type) + else if (H5D_VIRTUAL == mesg->type) /* Free the virtual entry list */ - if(H5D__virtual_reset_layout(mesg) < 0) + if (H5D__virtual_reset_layout(mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to reset virtual layout") /* Reset the message */ - mesg->type = H5D_CONTIGUOUS; + mesg->type = H5D_CONTIGUOUS; mesg->version = H5O_LAYOUT_VERSION_DEFAULT; } /* end if */ @@ -856,7 +888,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_free * @@ -872,7 +903,7 @@ done: static herr_t H5O__layout_free(void *_mesg) { - H5O_layout_t *mesg = (H5O_layout_t *) _mesg; + H5O_layout_t *mesg = (H5O_layout_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -886,7 +917,6 @@ H5O__layout_free(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__layout_free() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_delete * @@ -902,8 +932,8 @@ H5O__layout_free(void *_mesg) static herr_t H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_layout_t *mesg = (H5O_layout_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *mesg = (H5O_layout_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -913,26 +943,26 @@ H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) HDassert(mesg); /* Perform different actions, depending on the type of storage */ - switch(mesg->type) { - case H5D_COMPACT: /* Compact data storage */ + switch (mesg->type) { + case H5D_COMPACT: /* Compact data storage */ /* Nothing required */ break; - case H5D_CONTIGUOUS: /* Contiguous block on disk */ + case H5D_CONTIGUOUS: /* Contiguous block on disk */ /* Free the file space for the raw data */ - if(H5D__contig_delete(f, &mesg->storage) < 0) + if (H5D__contig_delete(f, &mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") break; - case H5D_CHUNKED: /* Chunked blocks on disk */ + case H5D_CHUNKED: /* Chunked blocks on disk */ /* Free the file space for the index & chunk raw data */ - if(H5D__chunk_delete(f, open_oh, &mesg->storage) < 0) + if (H5D__chunk_delete(f, open_oh, &mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") break; - case H5D_VIRTUAL: /* Virtual dataset */ + case H5D_VIRTUAL: /* Virtual dataset */ /* Free the file space virtual dataset */ - if(H5D__virtual_delete(f, &mesg->storage) < 0) + if (H5D__virtual_delete(f, &mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") break; @@ -946,7 +976,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_pre_copy_file * @@ -962,10 +991,11 @@ done: */ static herr_t H5O__layout_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, - hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) + hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, + void H5_ATTR_UNUSED *udata) { - const H5O_layout_t *layout_src = (const H5O_layout_t *)mesg_src; /* Source layout */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout_src = (const H5O_layout_t *)mesg_src; /* Source layout */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -975,14 +1005,13 @@ H5O__layout_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version allowed by the destination file's high bound */ - if(layout_src->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (layout_src->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "layout message version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_copy_file * @@ -999,14 +1028,14 @@ done: */ static void * H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info, void *_udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t *cpy_info, void *_udata) { - H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ - H5O_layout_t *layout_src = (H5O_layout_t *) mesg_src; - H5O_layout_t *layout_dst = NULL; - hbool_t copied = FALSE; /* Whether the data was copied */ - void *ret_value = NULL; /* Return value */ + H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ + H5O_layout_t * layout_src = (H5O_layout_t *)mesg_src; + H5O_layout_t * layout_dst = NULL; + hbool_t copied = FALSE; /* Whether the data was copied */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1016,15 +1045,16 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, HDassert(file_dst); /* Copy the layout information */ - if(NULL == (layout_dst = (H5O_layout_t *)H5O__layout_copy(layout_src, NULL))) + if (NULL == (layout_dst = (H5O_layout_t *)H5O__layout_copy(layout_src, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy layout") /* Copy the layout type specific information */ - switch(layout_src->type) { + switch (layout_src->type) { case H5D_COMPACT: - if(layout_src->storage.u.compact.buf) { + if (layout_src->storage.u.compact.buf) { /* copy compact raw data */ - if(H5D__compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info) < 0) + if (H5D__compact_copy(file_src, &layout_src->storage.u.compact, file_dst, + &layout_dst->storage.u.compact, udata->src_dtype, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") copied = TRUE; } /* end if */ @@ -1035,24 +1065,29 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, * layout message less than version 3 because versions 1 & 2 would * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ - if(layout_src->version < H5O_LAYOUT_VERSION_3) - layout_dst->storage.u.contig.size = H5S_extent_nelem(udata->src_space_extent) * - H5T_get_size(udata->src_dtype); + if (layout_src->version < H5O_LAYOUT_VERSION_3) + layout_dst->storage.u.contig.size = + H5S_extent_nelem(udata->src_space_extent) * H5T_get_size(udata->src_dtype); - if(H5D__contig_is_space_alloc(&layout_src->storage) - || (cpy_info->shared_fo && H5D__contig_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) { + if (H5D__contig_is_space_alloc(&layout_src->storage) || + (cpy_info->shared_fo && + H5D__contig_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) { /* copy contiguous raw data */ - if(H5D__contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info) < 0) + if (H5D__contig_copy(file_src, &layout_src->storage.u.contig, file_dst, + &layout_dst->storage.u.contig, udata->src_dtype, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage") copied = TRUE; } /* end if */ break; case H5D_CHUNKED: - if(H5D__chunk_is_space_alloc(&layout_src->storage) - || (cpy_info->shared_fo && H5D__chunk_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) { + if (H5D__chunk_is_space_alloc(&layout_src->storage) || + (cpy_info->shared_fo && + H5D__chunk_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) { /* Create chunked layout */ - if(H5D__chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, udata->common.src_pline, cpy_info) < 0) + if (H5D__chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, + &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, + udata->common.src_pline, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") copied = TRUE; } /* end if */ @@ -1061,7 +1096,7 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, case H5D_VIRTUAL: /* Copy virtual layout. Always copy so the memory fields get copied * properly. */ - if(H5D__virtual_copy(file_dst, layout_dst) < 0) + if (H5D__virtual_copy(file_dst, layout_dst) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy virtual storage") break; @@ -1072,21 +1107,20 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, } /* end switch */ /* Check if copy routine was invoked (which frees the source datatype) */ - if(copied) + if (copied) udata->src_dtype = NULL; /* Set return value */ ret_value = layout_dst; done: - if(!ret_value) - if(layout_dst) - layout_dst = H5FL_FREE(H5O_layout_t, layout_dst); + if (!ret_value) + if (layout_dst) + layout_dst = H5FL_FREE(H5O_layout_t, layout_dst); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_debug * @@ -1100,11 +1134,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - size_t u; + const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; + size_t u; FUNC_ENTER_STATIC_NOERR @@ -1115,61 +1148,52 @@ H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Version:", mesg->version); - switch(mesg->type) { + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", mesg->version); + switch (mesg->type) { case H5D_CHUNKED: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type:", "Chunked"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Chunked"); /* Chunk # of dims & size */ HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Number of dimensions:", - (unsigned long)(mesg->u.chunk.ndims)); + "Number of dimensions:", (unsigned long)(mesg->u.chunk.ndims)); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Size:"); - for(u = 0; u < (size_t)mesg->u.chunk.ndims; u++) + for (u = 0; u < (size_t)mesg->u.chunk.ndims; u++) HDfprintf(stream, "%s%lu", u ? ", " : "", (unsigned long)(mesg->u.chunk.dim[u])); HDfprintf(stream, "}\n"); /* Index information */ - switch(mesg->u.chunk.idx_type) { + switch (mesg->u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "v1 B-tree"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "v1 B-tree"); break; case H5D_CHUNK_IDX_NONE: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "Implicit"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Implicit"); break; case H5D_CHUNK_IDX_SINGLE: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "Single Chunk"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Single Chunk"); break; case H5D_CHUNK_IDX_FARRAY: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "Fixed Array"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Fixed Array"); /* (Should print the fixed array creation parameters) */ break; case H5D_CHUNK_IDX_EARRAY: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "Extensible Array"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Extensible Array"); /* (Should print the extensible array creation parameters) */ break; case H5D_CHUNK_IDX_BT2: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "v2 B-tree"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "v2 B-tree"); /* (Should print the v2-Btree creation parameters) */ break; case H5D_CHUNK_IDX_NTYPES: default: - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Index Type:", "Unknown", (unsigned)mesg->u.chunk.idx_type); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Index Type:", "Unknown", + (unsigned)mesg->u.chunk.idx_type); break; } /* end switch */ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, @@ -1177,49 +1201,44 @@ H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, break; case H5D_CONTIGUOUS: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type:", "Contiguous"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Contiguous"); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Data address:", mesg->storage.u.contig.addr); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Data Size:", mesg->storage.u.contig.size); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Data Size:", mesg->storage.u.contig.size); break; case H5D_COMPACT: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type:", "Compact"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Compact"); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data Size:", mesg->storage.u.compact.size); break; case H5D_VIRTUAL: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type:", "Virtual"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Virtual"); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Global heap address:", mesg->storage.u.virt.serial_list_hobjid.addr); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Global heap index:", mesg->storage.u.virt.serial_list_hobjid.idx); - for(u = 0; u < mesg->storage.u.virt.list_nused; u++) { + for (u = 0; u < mesg->storage.u.virt.list_nused; u++) { HDfprintf(stream, "%*sMapping %u:\n", indent, "", u); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth - 3, - "Virtual selection:", ""); + "Virtual selection:", ""); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth - 3, - "Source file name:", mesg->storage.u.virt.list[u].source_file_name); + "Source file name:", mesg->storage.u.virt.list[u].source_file_name); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth - 3, - "Source dataset name:", mesg->storage.u.virt.list[u].source_dset_name); + "Source dataset name:", mesg->storage.u.virt.list[u].source_dset_name); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth - 3, - "Source selection:", ""); + "Source selection:", ""); } /* end for */ break; case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: default: - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Type:", "Unknown", (unsigned)mesg->type); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Type:", "Unknown", + (unsigned)mesg->type); break; } /* end switch */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__layout_debug() */ - diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index a2f88d9..ae3d4a1 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -22,80 +22,75 @@ *------------------------------------------------------------------------- */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#define H5L_FRIEND /*suppress error about including H5Lpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Lpkg.h" /* Links */ -#include "H5Opkg.h" /* Object headers */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5L_FRIEND /*suppress error about including H5Lpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Lpkg.h" /* Links */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O__linfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__linfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_linfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_linfo_copy(const void *_mesg, void *_dest); +static void * H5O_linfo_copy(const void *_mesg, void *_dest); static size_t H5O_linfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__linfo_free(void *_mesg); static herr_t H5O__linfo_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static void *H5O__linfo_copy_file(H5F_t *file_src, void *native_src, - H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, - H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__linfo_post_copy_file(const H5O_loc_t *parent_src_oloc, - const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, - unsigned *mesg_flags, H5O_copy_t *cpy_info); -static herr_t H5O__linfo_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static void *H5O__linfo_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__linfo_post_copy_file(const H5O_loc_t *parent_src_oloc, const void *mesg_src, + H5O_loc_t *dst_oloc, void *mesg_dst, unsigned *mesg_flags, + H5O_copy_t *cpy_info); +static herr_t H5O__linfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_LINFO[1] = {{ - H5O_LINFO_ID, /*message id number */ - "linfo", /*message name for debugging */ - sizeof(H5O_linfo_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__linfo_decode, /*decode message */ - H5O_linfo_encode, /*encode message */ - H5O_linfo_copy, /*copy the native value */ - H5O_linfo_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__linfo_free, /* free method */ - H5O__linfo_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - H5O__linfo_copy_file, /* copy native value to file */ - H5O__linfo_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__linfo_debug /*debug the message */ + H5O_LINFO_ID, /*message id number */ + "linfo", /*message name for debugging */ + sizeof(H5O_linfo_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__linfo_decode, /*decode message */ + H5O_linfo_encode, /*encode message */ + H5O_linfo_copy, /*copy the native value */ + H5O_linfo_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__linfo_free, /* free method */ + H5O__linfo_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + H5O__linfo_copy_file, /* copy native value to file */ + H5O__linfo_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__linfo_debug /*debug the message */ }}; /* Current version of link info information */ -#define H5O_LINFO_VERSION 0 +#define H5O_LINFO_VERSION 0 /* Flags for link info index flag encoding */ -#define H5O_LINFO_TRACK_CORDER 0x01 -#define H5O_LINFO_INDEX_CORDER 0x02 -#define H5O_LINFO_ALL_FLAGS (H5O_LINFO_TRACK_CORDER | H5O_LINFO_INDEX_CORDER) +#define H5O_LINFO_TRACK_CORDER 0x01 +#define H5O_LINFO_INDEX_CORDER 0x02 +#define H5O_LINFO_ALL_FLAGS (H5O_LINFO_TRACK_CORDER | H5O_LINFO_INDEX_CORDER) /* Data exchange structure to use when copying links from src to dst */ typedef struct { - const H5O_loc_t *src_oloc; /* Source object location */ - H5O_loc_t *dst_oloc; /* Destination object location */ - H5O_linfo_t *dst_linfo; /* Destination object's link info message */ - H5O_copy_t *cpy_info; /* Information for copy operation */ + const H5O_loc_t *src_oloc; /* Source object location */ + H5O_loc_t * dst_oloc; /* Destination object location */ + H5O_linfo_t * dst_linfo; /* Destination object's link info message */ + H5O_copy_t * cpy_info; /* Information for copy operation */ } H5O_linfo_postcopy_ud_t; /* Declare a free list to manage the H5O_linfo_t struct */ H5FL_DEFINE_STATIC(H5O_linfo_t); - /*------------------------------------------------------------------------- * Function: H5O__linfo_decode * @@ -111,13 +106,12 @@ H5FL_DEFINE_STATIC(H5O_linfo_t); *------------------------------------------------------------------------- */ static void * -H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_linfo_t *linfo = NULL; /* Link info */ - unsigned char index_flags; /* Flags for encoding link index info */ - void *ret_value = NULL; /* Return value */ + H5O_linfo_t * linfo = NULL; /* Link info */ + unsigned char index_flags; /* Flags for encoding link index info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -126,16 +120,16 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_LINFO_VERSION) + if (*p++ != H5O_LINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (linfo = H5FL_MALLOC(H5O_linfo_t))) + if (NULL == (linfo = H5FL_MALLOC(H5O_linfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the index flags for the group */ index_flags = *p++; - if(index_flags & ~H5O_LINFO_ALL_FLAGS) + if (index_flags & ~H5O_LINFO_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") linfo->track_corder = (index_flags & H5O_LINFO_TRACK_CORDER) ? TRUE : FALSE; linfo->index_corder = (index_flags & H5O_LINFO_INDEX_CORDER) ? TRUE : FALSE; @@ -144,7 +138,7 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, linfo->nlinks = HSIZET_MAX; /* Max. link creation order value for the group, if tracked */ - if(linfo->track_corder) + if (linfo->track_corder) INT64DECODE(p, linfo->max_corder) else linfo->max_corder = 0; @@ -156,7 +150,7 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, H5F_addr_decode(f, &p, &(linfo->name_bt2_addr)); /* Address of v2 B-tree to index creation order of links, if there is one */ - if(linfo->index_corder) + if (linfo->index_corder) H5F_addr_decode(f, &p, &(linfo->corder_bt2_addr)); else linfo->corder_bt2_addr = HADDR_UNDEF; @@ -165,14 +159,13 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = linfo; done: - if(ret_value == NULL) - if(linfo != NULL) + if (ret_value == NULL) + if (linfo != NULL) linfo = H5FL_FREE(H5O_linfo_t, linfo); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__linfo_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_linfo_encode * @@ -189,8 +182,8 @@ done: static herr_t H5O_linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; - unsigned char index_flags; /* Flags for encoding link index info */ + const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; + unsigned char index_flags; /* Flags for encoding link index info */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -205,10 +198,10 @@ H5O_linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co /* The flags for the link indices */ index_flags = (uint8_t)(linfo->track_corder ? H5O_LINFO_TRACK_CORDER : 0); index_flags = (uint8_t)(index_flags | (linfo->index_corder ? H5O_LINFO_INDEX_CORDER : 0)); - *p++ = index_flags; + *p++ = index_flags; /* Max. link creation order value for the group, if tracked */ - if(linfo->track_corder) + if (linfo->track_corder) INT64ENCODE(p, linfo->max_corder) /* Address of fractal heap to store "dense" links */ @@ -218,7 +211,7 @@ H5O_linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co H5F_addr_encode(f, &p, linfo->name_bt2_addr); /* Address of v2 B-tree to index creation order of links, if they are indexed */ - if(linfo->index_corder) + if (linfo->index_corder) H5F_addr_encode(f, &p, linfo->corder_bt2_addr); else HDassert(!H5F_addr_defined(linfo->corder_bt2_addr)); @@ -226,7 +219,6 @@ H5O_linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_linfo_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_linfo_copy * @@ -245,15 +237,15 @@ H5O_linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co static void * H5O_linfo_copy(const void *_mesg, void *_dest) { - const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; - H5O_linfo_t *dest = (H5O_linfo_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; + H5O_linfo_t * dest = (H5O_linfo_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(linfo); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_linfo_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_linfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -266,7 +258,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_linfo_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_linfo_size * @@ -286,23 +277,24 @@ done: static size_t H5O_linfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = 1 /* Version */ - + 1 /* Index flags */ - + (linfo->track_corder ? (size_t)8 : 0) /* Curr. max. creation order value */ - + (size_t)H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */ - + (size_t)H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */ - + (linfo->index_corder ? (size_t)H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of links */ + ret_value = + 1 /* Version */ + + 1 /* Index flags */ + + (linfo->track_corder ? (size_t)8 : 0) /* Curr. max. creation order value */ + + (size_t)H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */ + + (size_t)H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */ + + (linfo->index_corder ? (size_t)H5F_SIZEOF_ADDR(f) + : 0); /* Address of v2 B-tree for indexing creation order values of links */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_linfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_free * @@ -327,7 +319,6 @@ H5O__linfo_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__linfo_free() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_delete * @@ -343,8 +334,8 @@ H5O__linfo_free(void *mesg) static herr_t H5O__linfo_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) { - H5O_linfo_t *linfo = (H5O_linfo_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t *linfo = (H5O_linfo_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -353,15 +344,14 @@ H5O__linfo_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) HDassert(linfo); /* If the group is using "dense" link storage, delete it */ - if(H5F_addr_defined(linfo->fheap_addr)) - if(H5G__dense_delete(f, linfo, TRUE) < 0) + if (H5F_addr_defined(linfo->fheap_addr)) + if (H5G__dense_delete(f, linfo, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free dense link storage") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__linfo_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_copy_file * @@ -378,13 +368,13 @@ done: */ static void * H5O__linfo_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info, void *_udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t *cpy_info, void *_udata) { - H5O_linfo_t *linfo_src = (H5O_linfo_t *) native_src; - H5O_linfo_t *linfo_dst = NULL; - H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *) _udata; - void *ret_value = NULL; /* Return value */ + H5O_linfo_t * linfo_src = (H5O_linfo_t *)native_src; + H5O_linfo_t * linfo_dst = NULL; + H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *)_udata; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG) @@ -393,18 +383,18 @@ H5O__linfo_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t *fi HDassert(cpy_info); /* Copy the source message */ - if(NULL == (linfo_dst = (H5O_linfo_t *)H5O_linfo_copy(linfo_src, NULL))) + if (NULL == (linfo_dst = (H5O_linfo_t *)H5O_linfo_copy(linfo_src, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "memory allocation failed") /* If we are performing a 'shallow hierarchy' copy, and the links in this * group won't be included in the destination, reset the link info for * this group. */ - if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) { - linfo_dst->nlinks = 0; - linfo_dst->max_corder = 0; - linfo_dst->fheap_addr = HADDR_UNDEF; - linfo_dst->name_bt2_addr = HADDR_UNDEF; + if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) { + linfo_dst->nlinks = 0; + linfo_dst->max_corder = 0; + linfo_dst->fheap_addr = HADDR_UNDEF; + linfo_dst->name_bt2_addr = HADDR_UNDEF; linfo_dst->corder_bt2_addr = HADDR_UNDEF; } /* end if */ else { @@ -412,25 +402,24 @@ H5O__linfo_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t *fi /* (XXX: should probably get the "creation" parameters for the source group's * dense link storage components and use those - QAK) */ - if(H5F_addr_defined(linfo_src->fheap_addr)) { + if (H5F_addr_defined(linfo_src->fheap_addr)) { /* Create the dense link storage */ - if(H5G__dense_create(file_dst, linfo_dst, udata->common.src_pline) < 0) + if (H5G__dense_create(file_dst, linfo_dst, udata->common.src_pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create 'dense' form of new format group") } /* end if */ - } /* end else */ + } /* end else */ /* Set return value */ ret_value = linfo_dst; done: - if(!ret_value) - if(linfo_dst) + if (!ret_value) + if (linfo_dst) linfo_dst = H5FL_FREE(H5O_linfo_t, linfo_dst); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5O__linfo_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_post_copy_file_cb * @@ -449,10 +438,10 @@ done: static herr_t H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) { - H5O_linfo_postcopy_ud_t *udata = (H5O_linfo_postcopy_ud_t *)_udata; /* 'User data' passed in */ - H5O_link_t dst_lnk; /* Destination link to insert */ - hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_linfo_postcopy_ud_t *udata = (H5O_linfo_postcopy_ud_t *)_udata; /* 'User data' passed in */ + H5O_link_t dst_lnk; /* Destination link to insert */ + hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -461,7 +450,7 @@ H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) HDassert(udata); /* Copy the link (and the object it points to) */ - if(H5L__link_copy_file(udata->dst_oloc->file, src_lnk, udata->src_oloc, &dst_lnk, udata->cpy_info) < 0) + if (H5L__link_copy_file(udata->dst_oloc->file, src_lnk, udata->src_oloc, &dst_lnk, udata->cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy link") dst_lnk_init = TRUE; @@ -470,7 +459,7 @@ H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) /* Insert the new object in the destination file's group */ /* (Doesn't increment the link count - that's already been taken care of for hard links) */ - if(H5G__dense_insert(udata->dst_oloc->file, udata->dst_linfo, &dst_lnk) < 0) + if (H5G__dense_insert(udata->dst_oloc->file, udata->dst_linfo, &dst_lnk) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link") /* Reset metadata tag in API context */ @@ -478,13 +467,12 @@ H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) done: /* Check if the destination link has been initialized */ - if(dst_lnk_init) + if (dst_lnk_init) H5O_msg_reset(H5O_LINK_ID, &dst_lnk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__linfo_post_copy_file_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_post_copy_file * @@ -498,13 +486,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, - H5O_loc_t *dst_oloc, void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info) +H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, + void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info) { - const H5O_linfo_t *linfo_src = (const H5O_linfo_t *)mesg_src; - H5O_linfo_t *linfo_dst = (H5O_linfo_t *)mesg_dst; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_linfo_t *linfo_src = (const H5O_linfo_t *)mesg_src; + H5O_linfo_t * linfo_dst = (H5O_linfo_t *)mesg_dst; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -517,21 +504,22 @@ H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, HDassert(cpy_info); /* If we are performing a 'shallow hierarchy' copy, get out now */ - if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) + if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) HGOTO_DONE(SUCCEED) /* Check for copying dense link storage */ - if(H5F_addr_defined(linfo_src->fheap_addr)) { - H5O_linfo_postcopy_ud_t udata; /* User data for iteration callback */ + if (H5F_addr_defined(linfo_src->fheap_addr)) { + H5O_linfo_postcopy_ud_t udata; /* User data for iteration callback */ /* Set up dense link iteration user data */ - udata.src_oloc = src_oloc; - udata.dst_oloc = dst_oloc; + udata.src_oloc = src_oloc; + udata.dst_oloc = dst_oloc; udata.dst_linfo = linfo_dst; - udata.cpy_info = cpy_info; + udata.cpy_info = cpy_info; /* Iterate over the links in the group, building a table of the link messages */ - if(H5G__dense_iterate(src_oloc->file, linfo_src, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, H5O__linfo_post_copy_file_cb, &udata) < 0) + if (H5G__dense_iterate(src_oloc->file, linfo_src, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, + H5O__linfo_post_copy_file_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") } /* end if */ @@ -539,7 +527,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__linfo_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_debug * @@ -554,10 +541,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__linfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__linfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_linfo_t *linfo = (const H5O_linfo_t *) _mesg; + const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -569,21 +555,17 @@ H5O__linfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Track creation order of links:", linfo->track_corder); + "Track creation order of links:", linfo->track_corder); HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Index creation order of links:", linfo->index_corder); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of links:", linfo->nlinks); - HDfprintf(stream, "%*s%-*s %Hd\n", indent, "", fwidth, - "Max. creation order value:", linfo->max_corder); + "Index creation order of links:", linfo->index_corder); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Number of links:", linfo->nlinks); + HDfprintf(stream, "%*s%-*s %Hd\n", indent, "", fwidth, "Max. creation order value:", linfo->max_corder); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' link storage fractal heap address:", linfo->fheap_addr); + "'Dense' link storage fractal heap address:", linfo->fheap_addr); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' link storage name index v2 B-tree address:", linfo->name_bt2_addr); + "'Dense' link storage name index v2 B-tree address:", linfo->name_bt2_addr); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' link storage creation order index v2 B-tree address:", linfo->corder_bt2_addr); - + "'Dense' link storage creation order index v2 B-tree address:", linfo->corder_bt2_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__linfo_debug() */ - diff --git a/src/H5Olink.c b/src/H5Olink.c index c27b51f..1c2d3ac 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -22,84 +22,79 @@ *------------------------------------------------------------------------- */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#define H5L_FRIEND /*suppress error about including H5Lpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ - +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5L_FRIEND /*suppress error about including H5Lpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O__link_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void *H5O__link_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); static herr_t H5O_link_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_link_copy(const void *_mesg, void *_dest); +static void * H5O_link_copy(const void *_mesg, void *_dest); static size_t H5O_link_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__link_reset(void *_mesg); static herr_t H5O__link_free(void *_mesg); -static herr_t H5O_link_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static void *H5O__link_copy_file(H5F_t *file_src, void *native_src, - H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, - H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__link_post_copy_file(const H5O_loc_t *src_oloc, - const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, - unsigned *mesg_flags, H5O_copy_t *cpy_info); -static herr_t H5O__link_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O_link_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *udata); +static void * H5O__link_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, + void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info); +static herr_t H5O__link_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_LINK[1] = {{ - H5O_LINK_ID, /*message id number */ - "link", /*message name for debugging */ - sizeof(H5O_link_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__link_decode, /*decode message */ - H5O_link_encode, /*encode message */ - H5O_link_copy, /*copy the native value */ - H5O_link_size, /*size of symbol table entry */ - H5O__link_reset, /* reset method */ - H5O__link_free, /* free method */ - H5O_link_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - H5O_link_pre_copy_file, /* pre copy native value to file */ - H5O__link_copy_file, /* copy native value to file */ - H5O__link_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__link_debug /*debug the message */ + H5O_LINK_ID, /*message id number */ + "link", /*message name for debugging */ + sizeof(H5O_link_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__link_decode, /*decode message */ + H5O_link_encode, /*encode message */ + H5O_link_copy, /*copy the native value */ + H5O_link_size, /*size of symbol table entry */ + H5O__link_reset, /* reset method */ + H5O__link_free, /* free method */ + H5O_link_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + H5O_link_pre_copy_file, /* pre copy native value to file */ + H5O__link_copy_file, /* copy native value to file */ + H5O__link_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__link_debug /*debug the message */ }}; /* Current version of link information */ -#define H5O_LINK_VERSION 1 +#define H5O_LINK_VERSION 1 /* Flags for link flag encoding */ -#define H5O_LINK_NAME_SIZE 0x03 /* 2-bit field for size of name length */ -#define H5O_LINK_STORE_CORDER 0x04 /* Whether to store creation index */ -#define H5O_LINK_STORE_LINK_TYPE 0x08 /* Whether to store non-default link type */ -#define H5O_LINK_STORE_NAME_CSET 0x10 /* Whether to store non-default name character set */ -#define H5O_LINK_ALL_FLAGS (H5O_LINK_NAME_SIZE | H5O_LINK_STORE_CORDER | H5O_LINK_STORE_LINK_TYPE | H5O_LINK_STORE_NAME_CSET) +#define H5O_LINK_NAME_SIZE 0x03 /* 2-bit field for size of name length */ +#define H5O_LINK_STORE_CORDER 0x04 /* Whether to store creation index */ +#define H5O_LINK_STORE_LINK_TYPE 0x08 /* Whether to store non-default link type */ +#define H5O_LINK_STORE_NAME_CSET 0x10 /* Whether to store non-default name character set */ +#define H5O_LINK_ALL_FLAGS \ + (H5O_LINK_NAME_SIZE | H5O_LINK_STORE_CORDER | H5O_LINK_STORE_LINK_TYPE | H5O_LINK_STORE_NAME_CSET) /* Individual definitions of name size values */ -#define H5O_LINK_NAME_1 0x00 /* Use 1-byte value for name length */ -#define H5O_LINK_NAME_2 0x01 /* Use 2-byte value for name length */ -#define H5O_LINK_NAME_4 0x02 /* Use 4-byte value for name length */ -#define H5O_LINK_NAME_8 0x03 /* Use 8-byte value for name length */ +#define H5O_LINK_NAME_1 0x00 /* Use 1-byte value for name length */ +#define H5O_LINK_NAME_2 0x01 /* Use 2-byte value for name length */ +#define H5O_LINK_NAME_4 0x02 /* Use 4-byte value for name length */ +#define H5O_LINK_NAME_8 0x03 /* Use 8-byte value for name length */ /* Declare a free list to manage the H5O_link_t struct */ H5FL_DEFINE_STATIC(H5O_link_t); - /*------------------------------------------------------------------------- * Function: H5O__link_decode * @@ -117,15 +112,14 @@ H5FL_DEFINE_STATIC(H5O_link_t); *------------------------------------------------------------------------- */ static void * -H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t p_size, const uint8_t *p) +H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_link_t *lnk = NULL; /* Pointer to link message */ - size_t len = 0; /* Length of a string in the message */ - unsigned char link_flags; /* Flags for encoding link info */ - const uint8_t *p_end = p + p_size; /* End of the p buffer */ - void *ret_value = NULL; /* Return value */ + H5O_link_t * lnk = NULL; /* Pointer to link message */ + size_t len = 0; /* Length of a string in the message */ + unsigned char link_flags; /* Flags for encoding link info */ + const uint8_t *p_end = p + p_size; /* End of the p buffer */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -134,86 +128,86 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(*p++ != H5O_LINK_VERSION) + if (*p++ != H5O_LINK_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (lnk = H5FL_CALLOC(H5O_link_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (lnk = H5FL_CALLOC(H5O_link_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the encoding flags for the link */ link_flags = *p++; - if(link_flags & ~H5O_LINK_ALL_FLAGS) + if (link_flags & ~H5O_LINK_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") /* Check for non-default link type */ - if(link_flags & H5O_LINK_STORE_LINK_TYPE) { + if (link_flags & H5O_LINK_STORE_LINK_TYPE) { /* Get the type of the link */ lnk->type = (H5L_type_t)*p++; - if(lnk->type < H5L_TYPE_HARD || lnk->type > H5L_TYPE_MAX) + if (lnk->type < H5L_TYPE_HARD || lnk->type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad link type") } /* end if */ else lnk->type = H5L_TYPE_HARD; /* Get the link creation time from the file */ - if(link_flags & H5O_LINK_STORE_CORDER) { + if (link_flags & H5O_LINK_STORE_CORDER) { INT64DECODE(p, lnk->corder) lnk->corder_valid = TRUE; } /* end if */ else { - lnk->corder = 0; + lnk->corder = 0; lnk->corder_valid = FALSE; } /* end else */ /* Check for non-default name character set */ - if(link_flags & H5O_LINK_STORE_NAME_CSET) { + if (link_flags & H5O_LINK_STORE_NAME_CSET) { /* Get the link name's character set */ lnk->cset = (H5T_cset_t)*p++; - if(lnk->cset < H5T_CSET_ASCII || lnk->cset > H5T_CSET_UTF8) + if (lnk->cset < H5T_CSET_ASCII || lnk->cset > H5T_CSET_UTF8) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad cset type") } /* end if */ else lnk->cset = H5T_CSET_ASCII; /* Get the length of the link's name */ - switch(link_flags & H5O_LINK_NAME_SIZE) { - case 0: /* 1 byte size */ + switch (link_flags & H5O_LINK_NAME_SIZE) { + case 0: /* 1 byte size */ len = *p++; break; - case 1: /* 2 byte size */ + case 1: /* 2 byte size */ UINT16DECODE(p, len); break; - case 2: /* 4 byte size */ + case 2: /* 4 byte size */ UINT32DECODE(p, len); break; - case 3: /* 8 byte size */ + case 3: /* 8 byte size */ UINT64DECODE(p, len); break; default: HDassert(0 && "bad size for name"); } /* end switch */ - if(len == 0) + if (len == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid name length") /* Make sure that length doesn't exceed buffer size, which could occur when the file is corrupted */ - if(p + len > p_end) + if (p + len > p_end) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") /* Get the link's name */ - if(NULL == (lnk->name = (char *)H5MM_malloc(len + 1))) + if (NULL == (lnk->name = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(lnk->name, p, len); lnk->name[len] = '\0'; p += len; /* Get the appropriate information for each type of link */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: /* Get the address of the object the link points to */ H5F_addr_decode(f, &p, &(lnk->u.hard.addr)); @@ -222,15 +216,15 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5L_TYPE_SOFT: /* Get the link value */ UINT16DECODE(p, len) - if(len == 0) + if (len == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid link length") /* Make sure that length doesn't exceed buffer size, which could occur when the file is corrupted */ - if(p + len > p_end) + if (p + len > p_end) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") - if(NULL == (lnk->u.soft.name = (char *)H5MM_malloc((size_t)len + 1))) + if (NULL == (lnk->u.soft.name = (char *)H5MM_malloc((size_t)len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(lnk->u.soft.name, p, len); lnk->u.soft.name[len] = '\0'; @@ -242,20 +236,19 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5L_TYPE_ERROR: case H5L_TYPE_MAX: default: - if(lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) + if (lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unknown link type") /* A UD link. Get the user-supplied data */ UINT16DECODE(p, len) lnk->u.ud.size = len; - if(len > 0) - { + if (len > 0) { /* Make sure that length doesn't exceed buffer size, which could occur when the file is corrupted */ - if(p + len > p_end) + if (p + len > p_end) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") - if(NULL == (lnk->u.ud.udata = H5MM_malloc((size_t)len))) + if (NULL == (lnk->u.ud.udata = H5MM_malloc((size_t)len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(lnk->u.ud.udata, p, len); p += len; @@ -268,13 +261,13 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = lnk; done: - if(ret_value == NULL) - if(lnk != NULL) { - if(lnk->name != NULL) + if (ret_value == NULL) + if (lnk != NULL) { + if (lnk->name != NULL) H5MM_xfree(lnk->name); - if(lnk->type == H5L_TYPE_SOFT && lnk->u.soft.name != NULL) + if (lnk->type == H5L_TYPE_SOFT && lnk->u.soft.name != NULL) H5MM_xfree(lnk->u.soft.name); - if(lnk->type >= H5L_TYPE_UD_MIN && lnk->u.ud.size > 0 && lnk->u.ud.udata != NULL) + if (lnk->type >= H5L_TYPE_UD_MIN && lnk->u.ud.size > 0 && lnk->u.ud.udata != NULL) H5MM_xfree(lnk->u.ud.udata); lnk = H5FL_FREE(H5O_link_t, lnk); } /* end if */ @@ -282,7 +275,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__link_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_link_encode * @@ -299,9 +291,9 @@ done: static herr_t H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_link_t *lnk = (const H5O_link_t *) _mesg; - uint64_t len; /* Length of a string in the message */ - unsigned char link_flags; /* Flags for encoding link info */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; + uint64_t len; /* Length of a string in the message */ + unsigned char link_flags; /* Flags for encoding link info */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -318,46 +310,46 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con *p++ = H5O_LINK_VERSION; /* The encoding flags for the link */ - if(len > 4294967295) + if (len > 4294967295) link_flags = H5O_LINK_NAME_8; - else if(len > 65535) + else if (len > 65535) link_flags = H5O_LINK_NAME_4; - else if(len > 255) + else if (len > 255) link_flags = H5O_LINK_NAME_2; else link_flags = H5O_LINK_NAME_1; link_flags = (unsigned char)(link_flags | (lnk->corder_valid ? H5O_LINK_STORE_CORDER : 0)); link_flags = (unsigned char)(link_flags | ((lnk->type != H5L_TYPE_HARD) ? H5O_LINK_STORE_LINK_TYPE : 0)); link_flags = (unsigned char)(link_flags | ((lnk->cset != H5T_CSET_ASCII) ? H5O_LINK_STORE_NAME_CSET : 0)); - *p++ = link_flags; + *p++ = link_flags; /* Store the type of a non-default link */ - if(link_flags & H5O_LINK_STORE_LINK_TYPE) + if (link_flags & H5O_LINK_STORE_LINK_TYPE) *p++ = (uint8_t)lnk->type; /* Store the link creation order in the file, if its valid */ - if(lnk->corder_valid) + if (lnk->corder_valid) INT64ENCODE(p, lnk->corder) /* Store a non-default link name character set */ - if(link_flags & H5O_LINK_STORE_NAME_CSET) + if (link_flags & H5O_LINK_STORE_NAME_CSET) *p++ = (uint8_t)lnk->cset; /* Store the link name's length */ - switch(link_flags & H5O_LINK_NAME_SIZE) { - case 0: /* 1 byte size */ + switch (link_flags & H5O_LINK_NAME_SIZE) { + case 0: /* 1 byte size */ *p++ = (uint8_t)len; break; - case 1: /* 2 byte size */ + case 1: /* 2 byte size */ UINT16ENCODE(p, len); break; - case 2: /* 4 byte size */ + case 2: /* 4 byte size */ UINT32ENCODE(p, len); break; - case 3: /* 8 byte size */ + case 3: /* 8 byte size */ UINT64ENCODE(p, len); break; @@ -370,7 +362,7 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con p += len; /* Store the appropriate information for each type of link */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: /* Store the address of the object the link points to */ H5F_addr_encode(f, &p, lnk->u.hard.addr); @@ -395,10 +387,9 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con /* Store the user-supplied data, however long it is */ len = (uint16_t)lnk->u.ud.size; UINT16ENCODE(p, len) - if(len > 0) - { + if (len > 0) { H5MM_memcpy(p, lnk->u.ud.udata, (size_t)len); - p+=len; + p += len; } break; } /* end switch */ @@ -406,7 +397,6 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_link_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_link_copy * @@ -426,54 +416,53 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con static void * H5O_link_copy(const void *_mesg, void *_dest) { - const H5O_link_t *lnk = (const H5O_link_t *) _mesg; - H5O_link_t *dest = (H5O_link_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; + H5O_link_t * dest = (H5O_link_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check args */ HDassert(lnk); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_link_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_link_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy static information */ *dest = *lnk; /* Duplicate the link's name */ HDassert(lnk->name); - if(NULL == (dest->name = H5MM_xstrdup(lnk->name))) + if (NULL == (dest->name = H5MM_xstrdup(lnk->name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't duplicate link name") /* Copy other information needed for different link types */ - if(lnk->type == H5L_TYPE_SOFT) { - if(NULL == (dest->u.soft.name = H5MM_xstrdup(lnk->u.soft.name))) + if (lnk->type == H5L_TYPE_SOFT) { + if (NULL == (dest->u.soft.name = H5MM_xstrdup(lnk->u.soft.name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't duplicate soft link value") } /* end if */ - else if(lnk->type >= H5L_TYPE_UD_MIN) { - if(lnk->u.ud.size > 0) { - if(NULL == (dest->u.ud.udata = H5MM_malloc(lnk->u.ud.size))) + else if (lnk->type >= H5L_TYPE_UD_MIN) { + if (lnk->u.ud.size > 0) { + if (NULL == (dest->u.ud.udata = H5MM_malloc(lnk->u.ud.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(dest->u.ud.udata, lnk->u.ud.udata, lnk->u.ud.size); } /* end if */ - } /* end if */ + } /* end if */ /* Set return value */ ret_value = dest; done: - if(NULL == ret_value) - if(dest) { - if(dest->name && dest->name != lnk->name) + if (NULL == ret_value) + if (dest) { + if (dest->name && dest->name != lnk->name) dest->name = (char *)H5MM_xfree(dest->name); - if(NULL == _dest) - dest = H5FL_FREE(H5O_link_t ,dest); + if (NULL == _dest) + dest = H5FL_FREE(H5O_link_t, dest); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_link_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_link_size * @@ -495,9 +484,9 @@ static size_t H5O_link_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; - uint64_t name_len; /* Length of name */ - size_t name_size; /* Size of encoded name length */ - size_t ret_value = 0; /* Return value */ + uint64_t name_len; /* Length of name */ + size_t name_size; /* Size of encoded name length */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -508,33 +497,33 @@ H5O_link_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void name_len = (uint64_t)HDstrlen(lnk->name); /* Determine correct value for name size bits */ - if(name_len > 4294967295) + if (name_len > 4294967295) name_size = 8; - else if(name_len > 65535) + else if (name_len > 65535) name_size = 4; - else if(name_len > 255) + else if (name_len > 255) name_size = 2; else name_size = 1; /* Set return value */ - ret_value = 1 + /* Version */ - 1 + /* Link encoding flags */ + ret_value = 1 + /* Version */ + 1 + /* Link encoding flags */ (lnk->type != H5L_TYPE_HARD ? (size_t)1 : 0) + /* Link type */ - (lnk->corder_valid ? 8 : 0) + /* Creation order */ - (lnk->cset != H5T_CSET_ASCII ? 1 : 0) + /* Character set */ - name_size + /* Name length */ - name_len; /* Name */ + (lnk->corder_valid ? 8 : 0) + /* Creation order */ + (lnk->cset != H5T_CSET_ASCII ? 1 : 0) + /* Character set */ + name_size + /* Name length */ + name_len; /* Name */ /* Add the appropriate length for each type of link */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: ret_value += H5F_SIZEOF_ADDR(f); break; case H5L_TYPE_SOFT: - ret_value += 2 + /* Link value length */ - HDstrlen(lnk->u.soft.name); /* Link value */ + ret_value += 2 + /* Link value length */ + HDstrlen(lnk->u.soft.name); /* Link value */ break; case H5L_TYPE_ERROR: @@ -542,15 +531,14 @@ H5O_link_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void case H5L_TYPE_MAX: default: /* Default is user-defined link type */ HDassert(lnk->type >= H5L_TYPE_UD_MIN); - ret_value += 2 + /* User-defined data size */ - lnk->u.ud.size; /* User-defined data */ + ret_value += 2 + /* User-defined data size */ + lnk->u.ud.size; /* User-defined data */ break; } /* end switch */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_link_size() */ - /*------------------------------------------------------------------------- * Function: H5O__link_reset * @@ -571,12 +559,12 @@ H5O__link_reset(void *_mesg) FUNC_ENTER_STATIC_NOERR - if(lnk) { + if (lnk) { /* Free information for link (but don't free link pointer) */ - if(lnk->type == H5L_TYPE_SOFT) + if (lnk->type == H5L_TYPE_SOFT) lnk->u.soft.name = (char *)H5MM_xfree(lnk->u.soft.name); else if (lnk->type >= H5L_TYPE_UD_MIN) { - if(lnk->u.ud.size > 0) + if (lnk->u.ud.size > 0) lnk->u.ud.udata = H5MM_xfree(lnk->u.ud.udata); } /* end if */ lnk->name = (char *)H5MM_xfree(lnk->name); @@ -585,7 +573,6 @@ H5O__link_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__link_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__link_free * @@ -612,7 +599,6 @@ H5O__link_free(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__link_free() */ - /*------------------------------------------------------------------------- * Function: H5O_link_delete * @@ -628,9 +614,9 @@ H5O__link_free(void *_mesg) herr_t H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) { - H5O_link_t *lnk = (H5O_link_t *)_mesg; - hid_t file_id = -1; /* ID for the file the link is located in (passed to user callback) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t *lnk = (H5O_link_t *)_mesg; + hid_t file_id = -1; /* ID for the file the link is located in (passed to user callback) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -640,7 +626,7 @@ H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) /* Check for adjusting the link count when the link is removed */ /* Adjust the reference count of the object when a hard link is removed */ - if(lnk->type == H5L_TYPE_HARD) { + if (lnk->type == H5L_TYPE_HARD) { H5O_loc_t oloc; /* Construct object location for object, in order to decrement it's ref count */ @@ -650,38 +636,37 @@ H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) oloc.addr = lnk->u.hard.addr; /* Decrement the ref count for the object */ - if(H5O_link(&oloc, -1) < 0) + if (H5O_link(&oloc, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to decrement object link count") } /* end if */ /* Perform the "delete" callback when a user-defined link is removed */ - else if(lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ + else if (lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ /* Get the link class for this type of link. */ - if(NULL == (link_class = H5L_find_class(lnk->type))) + if (NULL == (link_class = H5L_find_class(lnk->type))) HGOTO_ERROR(H5E_OHDR, H5E_NOTREGISTERED, FAIL, "link class not registered") /* Check for delete callback */ - if(link_class->del_func) { + if (link_class->del_func) { /* Get a file ID for the file the link is in */ - if((file_id = H5F_get_id(f)) < 0) + if ((file_id = H5F_get_id(f)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get file ID") /* Call user-defined link's 'delete' callback */ - if((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) + if ((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CALLBACK, FAIL, "link deletion callback returned failure") } /* end if */ - } /* end if */ + } /* end if */ done: /* Release the file ID */ - if(file_id > 0 && H5I_dec_ref(file_id) < 0) + if (file_id > 0 && H5I_dec_ref(file_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_link_delete() */ - /*------------------------------------------------------------------------- * Function: H5O_link_pre_copy_file * @@ -699,7 +684,7 @@ done: */ static herr_t H5O_link_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) + hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -712,13 +697,12 @@ H5O_link_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED * in the destination object header before performing any other actions * on it. */ - if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) + if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) *deleted = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_link_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__link_copy_file * @@ -735,11 +719,11 @@ H5O_link_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED */ static void * H5O__link_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t H5_ATTR_UNUSED *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { - H5O_link_t *link_src = (H5O_link_t *)native_src; - void *ret_value = NULL; /* Return value */ + H5O_link_t *link_src = (H5O_link_t *)native_src; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -749,19 +733,18 @@ H5O__link_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t H5_A HDassert(cpy_info->max_depth < 0 || cpy_info->curr_depth < cpy_info->max_depth); /* Sanity check source link type */ - if(link_src->type > H5L_TYPE_SOFT && link_src->type < H5L_TYPE_UD_MIN) + if (link_src->type > H5L_TYPE_SOFT && link_src->type < H5L_TYPE_UD_MIN) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "unrecognized built-in link type") /* Allocate "blank" link for destination */ /* (values will be filled in during 'post copy' operation) */ - if(NULL == (ret_value = H5FL_CALLOC(H5O_link_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (ret_value = H5FL_CALLOC(H5O_link_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__link_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__link_post_copy_file * @@ -775,13 +758,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, - H5O_loc_t *dst_oloc, void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info) +H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, + unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info) { - const H5O_link_t *link_src = (const H5O_link_t *)mesg_src; - H5O_link_t *link_dst = (H5O_link_t *)mesg_dst; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_link_t *link_src = (const H5O_link_t *)mesg_src; + H5O_link_t * link_dst = (H5O_link_t *)mesg_dst; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -795,14 +777,13 @@ H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, HDassert(cpy_info->max_depth < 0 || cpy_info->curr_depth < cpy_info->max_depth); /* Copy the link (and the object it points to) */ - if(H5L__link_copy_file(dst_oloc->file, link_src, src_oloc, link_dst, cpy_info) < 0) + if (H5L__link_copy_file(dst_oloc->file, link_src, src_oloc, link_dst, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy link") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__link_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__link_debug * @@ -817,11 +798,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__link_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__link_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_link_t *lnk = (const H5O_link_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -832,52 +812,50 @@ H5O__link_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Link Type:", (lnk->type == H5L_TYPE_HARD ? "Hard" : - (lnk->type == H5L_TYPE_SOFT ? "Soft" : - (lnk->type == H5L_TYPE_EXTERNAL ? "External" : - (lnk->type >= H5L_TYPE_UD_MIN ? "User-defined" : "Unknown"))))); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Link Type:", + (lnk->type == H5L_TYPE_HARD + ? "Hard" + : (lnk->type == H5L_TYPE_SOFT + ? "Soft" + : (lnk->type == H5L_TYPE_EXTERNAL + ? "External" + : (lnk->type >= H5L_TYPE_UD_MIN ? "User-defined" : "Unknown"))))); - if(lnk->corder_valid) - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Creation Order:", lnk->corder); + if (lnk->corder_valid) + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Creation Order:", lnk->corder); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Link Name Character Set:", (lnk->cset == H5T_CSET_ASCII ? - "ASCII" : (lnk->cset == H5T_CSET_UTF8 ? "UTF-8" : "Unknown"))); - HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, - "Link Name:", lnk->name); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Link Name Character Set:", + (lnk->cset == H5T_CSET_ASCII ? "ASCII" : (lnk->cset == H5T_CSET_UTF8 ? "UTF-8" : "Unknown"))); + HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, "Link Name:", lnk->name); /* Display link-specific information */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Object address:", lnk->u.hard.addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Object address:", lnk->u.hard.addr); break; case H5L_TYPE_SOFT: - HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, - "Link Value:", lnk->u.soft.name); + HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, "Link Value:", lnk->u.soft.name); break; case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: default: - if(lnk->type >= H5L_TYPE_UD_MIN) { - if(lnk->type == H5L_TYPE_EXTERNAL) { - const char *objname = (const char *)lnk->u.ud.udata + (HDstrlen((const char *)lnk->u.ud.udata) + 1); + if (lnk->type >= H5L_TYPE_UD_MIN) { + if (lnk->type == H5L_TYPE_EXTERNAL) { + const char *objname = + (const char *)lnk->u.ud.udata + (HDstrlen((const char *)lnk->u.ud.udata) + 1); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "External File Name:", lnk->u.ud.udata); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "External Object Name:", objname); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "External Object Name:", objname); } /* end if */ else { HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "User-Defined Link Size:", lnk->u.ud.size); } /* end else */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type") break; @@ -886,4 +864,3 @@ H5O__link_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__link_debug() */ - diff --git a/src/H5Omessage.c b/src/H5Omessage.c index d66ea69..5100e72 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -26,75 +26,64 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for iteration while removing a message */ typedef struct { - H5F_t *f; /* Pointer to file for insertion */ - int sequence; /* Sequence # to search for */ - unsigned nfailed; /* # of failed message removals */ - H5O_operator_t op; /* Callback routine for removal operations */ - void *op_data; /* Callback data for removal operations */ - hbool_t adj_link; /* Whether to adjust links when removing messages */ + H5F_t * f; /* Pointer to file for insertion */ + int sequence; /* Sequence # to search for */ + unsigned nfailed; /* # of failed message removals */ + H5O_operator_t op; /* Callback routine for removal operations */ + void * op_data; /* Callback data for removal operations */ + hbool_t adj_link; /* Whether to adjust links when removing messages */ } H5O_iter_rm_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5O__msg_reset_real(const H5O_msg_class_t *type, void *native); -static herr_t H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned *oh_modified, void *_udata/*in,out*/); -static herr_t H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, - const H5O_msg_class_t *type, const void *mesg, unsigned mesg_flags, - unsigned update_flags); - +static herr_t H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned *oh_modified, void *_udata /*in,out*/); +static herr_t H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, const void *mesg, + unsigned mesg_flags, unsigned update_flags); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O_msg_create * @@ -111,11 +100,10 @@ static herr_t H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, *------------------------------------------------------------------------- */ herr_t -H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg) +H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, unsigned update_flags, void *mesg) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -126,21 +114,20 @@ H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, HDassert(mesg); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Go append message to object header */ - if(H5O_msg_append_oh(loc->file, oh, type_id, mesg_flags, update_flags, mesg) < 0) + if (H5O_msg_append_oh(loc->file, oh, type_id, mesg_flags, update_flags, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to append to object header") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_create() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_append_oh * @@ -159,33 +146,32 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, - unsigned mesg_flags, unsigned update_flags, void *mesg) +H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, unsigned update_flags, + void *mesg) { - const H5O_msg_class_t *type; /* Original H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Original H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(f); HDassert(oh); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); HDassert(mesg); /* Append new message to object header */ - if(H5O__msg_append_real(f, oh, type, mesg_flags, update_flags, mesg) < 0) + if (H5O__msg_append_real(f, oh, type, mesg_flags, update_flags, mesg) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new message in header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_append_oh() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_append_real * @@ -202,11 +188,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, void *mesg) +H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, + unsigned update_flags, void *mesg) { - size_t idx; /* Index of message to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; /* Index of message to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -218,21 +204,20 @@ H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(mesg); /* Allocate space for a new message */ - if(H5O__msg_alloc(f, oh, type, &mesg_flags, mesg, &idx) < 0) + if (H5O__msg_alloc(f, oh, type, &mesg_flags, mesg, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create new message") /* Copy the information for the message */ - if(H5O__copy_mesg(f, oh, idx, type, mesg, mesg_flags, update_flags) < 0) + if (H5O__copy_mesg(f, oh, idx, type, mesg, mesg_flags, update_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to write message") #ifdef H5O_DEBUG -H5O__assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_append_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_write * @@ -254,12 +239,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg) +H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, unsigned update_flags, void *mesg) { - H5O_t *oh = NULL; /* Object header to use */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header to use */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -267,29 +251,28 @@ H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, HDassert(loc); HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Call the "real" modify routine */ - if(H5O__msg_write_real(loc->file, oh, type, mesg_flags, update_flags, mesg) < 0) + if (H5O__msg_write_real(loc->file, oh, type, mesg_flags, update_flags, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header message") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_write() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_write_oh * @@ -310,33 +293,32 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_msg_write_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg) +H5O_msg_write_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, unsigned update_flags, + void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(oh->cache_info.addr, FAIL) /* check args */ HDassert(f); HDassert(oh); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); /* Call the "real" modify routine */ - if(H5O__msg_write_real(f, oh, type, mesg_flags, update_flags, mesg) < 0) + if (H5O__msg_write_real(f, oh, type, mesg_flags, update_flags, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header message") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_msg_write_oh() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_write_real * @@ -358,12 +340,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, void *mesg) +H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, + unsigned update_flags, void *mesg) { - H5O_mesg_t *idx_msg; /* Pointer to message to modify */ - size_t idx; /* Index of message to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_mesg_t *idx_msg; /* Pointer to message to modify */ + size_t idx; /* Index of message to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -376,22 +358,22 @@ H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); /* Locate message of correct type */ - for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) - if(type == idx_msg->type) + for (idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if (type == idx_msg->type) break; - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message type not found") /* Check for modifying a constant message */ - if(!(update_flags & H5O_UPDATE_FORCE) && (idx_msg->flags & H5O_MSG_FLAG_CONSTANT)) + if (!(update_flags & H5O_UPDATE_FORCE) && (idx_msg->flags & H5O_MSG_FLAG_CONSTANT)) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify constant message") /* This message is shared, but it's being modified. */ - else if((idx_msg->flags & H5O_MSG_FLAG_SHARED) || (idx_msg->flags & H5O_MSG_FLAG_SHAREABLE)) { - htri_t status; /* Status of "try share" call */ + else if ((idx_msg->flags & H5O_MSG_FLAG_SHARED) || (idx_msg->flags & H5O_MSG_FLAG_SHAREABLE)) { + htri_t status; /* Status of "try share" call */ - /* First, sanity check to make sure it's not a committed message; - * these can't ever be modified. - */ + /* First, sanity check to make sure it's not a committed message; + * these can't ever be modified. + */ HDassert(((H5O_shared_t *)idx_msg->native)->type != H5O_SHARE_TYPE_COMMITTED); /* Also, sanity check that a message doesn't switch status from being @@ -407,7 +389,7 @@ H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, * the location of the object changes (from in another object's * header to the SOHM heap), so just delete it first -QAK) */ - if(H5SM_delete(f, oh, (H5O_shared_t *)idx_msg->native) < 0) + if (H5SM_delete(f, oh, (H5O_shared_t *)idx_msg->native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete message from SOHM index") /* If we're replacing a shared message, the new message must be shared @@ -417,24 +399,24 @@ H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, * XXX: This doesn't handle freeing extra space in object header from * a message shrinking. */ - if((status = H5SM_try_share(f, ((mesg_flags & H5O_MSG_FLAG_SHARED) ? NULL : oh), 0, idx_msg->type->id, mesg, &mesg_flags)) < 0) + if ((status = H5SM_try_share(f, ((mesg_flags & H5O_MSG_FLAG_SHARED) ? NULL : oh), 0, + idx_msg->type->id, mesg, &mesg_flags)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message") - if(status == FALSE && (mesg_flags & H5O_MSG_FLAG_SHARED)) + if (status == FALSE && (mesg_flags & H5O_MSG_FLAG_SHARED)) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "message changed sharing status") } /* end if */ /* Copy the information for the message */ - if(H5O__copy_mesg(f, oh, idx, type, mesg, mesg_flags, update_flags) < 0) + if (H5O__copy_mesg(f, oh, idx, type, mesg, mesg_flags, update_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message") #ifdef H5O_DEBUG -H5O__assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_write_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_read * @@ -461,8 +443,8 @@ done: void * H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg) { - H5O_t *oh = NULL; /* Object header to use */ - void *ret_value = NULL; /* Return value */ + H5O_t *oh = NULL; /* Object header to use */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, NULL) @@ -473,21 +455,20 @@ H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg) HDassert(type_id < NELMTS(H5O_msg_class_g)); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header") /* Call the "real" read routine */ - if(NULL == (ret_value = H5O_msg_read_oh(loc->file, oh, type_id, mesg))) + if (NULL == (ret_value = H5O_msg_read_oh(loc->file, oh, type_id, mesg))) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header message") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_msg_read() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_read_oh * @@ -514,9 +495,9 @@ done: void * H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - unsigned idx; /* Message's index in object header */ - void *ret_value = NULL; + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + unsigned idx; /* Message's index in object header */ + void * ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -524,14 +505,14 @@ H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg) HDassert(f); HDassert(oh); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Scan through the messages looking for the right one */ - for(idx = 0; idx < oh->nmesgs; idx++) - if(type == oh->mesg[idx].type) + for (idx = 0; idx < oh->nmesgs; idx++) + if (type == oh->mesg[idx].type) break; - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "message type not found") /* @@ -545,14 +526,13 @@ H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg) * the raw message) so we must copy the native message before * returning. */ - if(NULL == (ret_value = (type->copy)(oh->mesg[idx].native, mesg))) + if (NULL == (ret_value = (type->copy)(oh->mesg[idx].native, mesg))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_read_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_reset * @@ -571,25 +551,24 @@ done: herr_t H5O_msg_reset(unsigned type_id, void *native) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Call the "real" reset routine */ - if(H5O__msg_reset_real(type, native) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "unable to reset object header") + if (H5O__msg_reset_real(type, native) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "unable to reset object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_reset_real * @@ -608,16 +587,16 @@ done: static herr_t H5O__msg_reset_real(const H5O_msg_class_t *type, void *native) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(type); - if(native) { - if(type->reset) { - if((type->reset)(native) < 0) + if (native) { + if (type->reset) { + if ((type->reset)(native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "reset method failed") } /* end if */ else @@ -628,7 +607,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_reset_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_free * @@ -647,14 +625,14 @@ done: void * H5O_msg_free(unsigned type_id, void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - void *ret_value = NULL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Call the "real" free routine */ @@ -663,7 +641,6 @@ H5O_msg_free(unsigned type_id, void *mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_free() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_free_mesg * @@ -690,7 +667,6 @@ H5O__msg_free_mesg(H5O_mesg_t *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__msg_free_mesg() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_free_real * @@ -713,9 +689,9 @@ H5O_msg_free_real(const H5O_msg_class_t *type, void *msg_native) /* check args */ HDassert(type); - if(msg_native) { + if (msg_native) { H5O__msg_reset_real(type, msg_native); - if(NULL != (type->free)) + if (NULL != (type->free)) (type->free)(msg_native); else H5MM_xfree(msg_native); @@ -724,7 +700,6 @@ H5O_msg_free_real(const H5O_msg_class_t *type, void *msg_native) FUNC_LEAVE_NOAPI(NULL) } /* end H5O_msg_free_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_copy * @@ -743,26 +718,25 @@ H5O_msg_free_real(const H5O_msg_class_t *type, void *msg_native) void * H5O_msg_copy(unsigned type_id, const void *mesg, void *dst) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - void *ret_value = NULL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* check args */ HDassert(mesg); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Call the message class's copy routine */ - if(NULL == (ret_value = (type->copy)(mesg, dst))) + if (NULL == (ret_value = (type->copy)(mesg, dst))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy object header message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_count * @@ -781,10 +755,10 @@ done: int H5O_msg_count(const H5O_loc_t *loc, unsigned type_id) { - H5O_t *oh = NULL; /* Object header to operate on */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - unsigned msg_count; /* Message count */ - int ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Object header to operate on */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + unsigned msg_count; /* Message count */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -793,11 +767,11 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id) HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Count the messages of the correct type */ @@ -805,13 +779,12 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id) H5_CHECKED_ASSIGN(ret_value, int, msg_count, unsigned); done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_count() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_count_real * @@ -830,8 +803,8 @@ done: unsigned H5O__msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type) { - unsigned u; /* Local index variable */ - unsigned ret_value = 0; /* Return value */ + unsigned u; /* Local index variable */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -840,14 +813,13 @@ H5O__msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type) HDassert(type); /* Loop over all messages, counting the ones of the type looked for */ - for(u = ret_value = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].type == type) + for (u = ret_value = 0; u < oh->nmesgs; u++) + if (oh->mesg[u].type == type) ret_value++; FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_count_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_exists * @@ -869,8 +841,8 @@ H5O__msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type) htri_t H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id) { - H5O_t *oh = NULL; /* Object header for location */ - htri_t ret_value = FAIL; /* Return value */ + H5O_t *oh = NULL; /* Object header for location */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -879,21 +851,20 @@ H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id) HDassert(type_id < NELMTS(H5O_msg_class_g)); /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Call the "real" exists routine */ - if((ret_value = H5O_msg_exists_oh(oh, type_id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to verify object header message") + if ((ret_value = H5O_msg_exists_oh(oh, type_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to verify object header message") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_msg_exists() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_exists_oh * @@ -915,27 +886,26 @@ done: htri_t H5O_msg_exists_oh(const H5O_t *oh, unsigned type_id) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - unsigned u; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + unsigned u; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(oh); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Scan through the messages looking for the right one */ - for(u = 0; u < oh->nmesgs; u++) - if(type == oh->mesg[u].type) + for (u = 0; u < oh->nmesgs; u++) + if (type == oh->mesg[u].type) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_exists_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_remove * @@ -959,9 +929,9 @@ done: herr_t H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj_link) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -969,27 +939,26 @@ H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj HDassert(loc); HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Call the "real" remove routine */ - if((ret_value = H5O__msg_remove_real(loc->file, oh, type, sequence, NULL, NULL, adj_link)) < 0) + if ((ret_value = H5O__msg_remove_real(loc->file, oh, type, sequence, NULL, NULL, adj_link)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove object header message") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_remove() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_remove_op * @@ -1008,12 +977,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, - H5O_operator_t op, void *op_data, hbool_t adj_link) +H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, H5O_operator_t op, void *op_data, + hbool_t adj_link) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1021,27 +990,26 @@ H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, HDassert(loc); HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Call the "real" remove routine */ - if((ret_value = H5O__msg_remove_real(loc->file, oh, type, sequence, op, op_data, adj_link)) < 0) + if ((ret_value = H5O__msg_remove_real(loc->file, oh, type, sequence, op, op_data, adj_link)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove object header message") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_remove_op() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_remove_cb * @@ -1058,12 +1026,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned *oh_modified, void *_udata/*in,out*/) +H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, unsigned *oh_modified, + void *_udata /*in,out*/) { - H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ - htri_t try_remove = FALSE; /* Whether to try removing a message */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ + htri_t try_remove = FALSE; /* Whether to try removing a message */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1071,33 +1039,34 @@ H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(mesg); /* Check for callback routine */ - if(udata->op) { + if (udata->op) { /* Call the iterator callback */ - if((try_remove = (udata->op)(mesg->native, sequence, udata->op_data)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "object header message deletion callback failed") + if ((try_remove = (udata->op)(mesg->native, sequence, udata->op_data)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, + "object header message deletion callback failed") } /* end if */ else { /* If there's no callback routine, does the sequence # match? */ - if((int)sequence == udata->sequence || H5O_ALL == udata->sequence) + if ((int)sequence == udata->sequence || H5O_ALL == udata->sequence) try_remove = TRUE; } /* end else */ /* Try removing the message, if indicated */ - if(try_remove) { + if (try_remove) { /* * Keep track of how many times we failed trying to remove constant * messages. * (OK to remove constant messages - QAK) */ /* Convert message into a null message */ - if(H5O__release_mesg(udata->f, oh, mesg, udata->adj_link) < 0) + if (H5O__release_mesg(udata->f, oh, mesg, udata->adj_link) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to release message") /* Indicate that the object header was modified */ *oh_modified = H5O_MODIFY_CONDENSE; /* Break out now, if we've found the correct message */ - if(udata->sequence == H5O_FIRST || udata->sequence != H5O_ALL) + if (udata->sequence == H5O_FIRST || udata->sequence != H5O_ALL) HGOTO_DONE(H5_ITER_STOP) } /* end if */ @@ -1105,7 +1074,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_remove_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_remove_real * @@ -1124,12 +1092,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - int sequence, H5O_operator_t app_op, void *op_data, hbool_t adj_link) +H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, int sequence, H5O_operator_t app_op, + void *op_data, hbool_t adj_link) { - H5O_iter_rm_t udata; /* User data for iterator */ - H5O_mesg_operator_t op; /* Wrapper for operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_iter_rm_t udata; /* User data for iterator */ + H5O_mesg_operator_t op; /* Wrapper for operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1139,32 +1107,31 @@ H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(type); /* Make certain we are allowed to modify the file */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file") + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file") /* Set up iterator operator data */ - udata.f = f; + udata.f = f; udata.sequence = sequence; - udata.nfailed = 0; - udata.op = app_op; - udata.op_data = op_data; + udata.nfailed = 0; + udata.op = app_op; + udata.op_data = op_data; udata.adj_link = adj_link; /* Iterate over the messages, deleting appropriate one(s) */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__msg_remove_cb; - if(H5O__msg_iterate_real(f, oh, type, &op, &udata) < 0) + if (H5O__msg_iterate_real(f, oh, type, &op, &udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "error iterating over messages") /* Fail if we tried to remove any constant messages */ - if(udata.nfailed) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to remove constant message(s)") + if (udata.nfailed) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to remove constant message(s)") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_remove_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_iterate * @@ -1197,12 +1164,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, - const H5O_mesg_operator_t *op, void *op_data) +H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, const H5O_mesg_operator_t *op, void *op_data) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1211,26 +1177,25 @@ H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(op); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Call the "real" iterate routine */ - if((ret_value = H5O__msg_iterate_real(loc->file, oh, type, op, op_data)) < 0) + if ((ret_value = H5O__msg_iterate_real(loc->file, oh, type, op, op_data)) < 0) HERROR(H5E_OHDR, H5E_BADITER, "unable to iterate over object header messages"); done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_iterate() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_iterate_real * @@ -1263,14 +1228,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - const H5O_mesg_operator_t *op, void *op_data) +H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, const H5O_mesg_operator_t *op, + void *op_data) { - H5O_mesg_t *idx_msg; /* Pointer to current message */ - unsigned idx; /* Absolute index of current message in all messages */ - unsigned sequence; /* Relative index of current message for messages of type */ - unsigned oh_modified = 0; /* Whether the callback modified the object header */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_mesg_t *idx_msg; /* Pointer to current message */ + unsigned idx; /* Absolute index of current message in all messages */ + unsigned sequence; /* Relative index of current message for messages of type */ + unsigned oh_modified = 0; /* Whether the callback modified the object header */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_PACKAGE @@ -1282,55 +1247,54 @@ H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(op->u.app_op); /* Iterate over messages */ - for(sequence = 0, idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs && !ret_value; idx++, idx_msg++) { - if(type == idx_msg->type) { + for (sequence = 0, idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs && !ret_value; idx++, idx_msg++) { + if (type == idx_msg->type) { /* Decode the message if necessary. */ H5O_LOAD_NATIVE(f, 0, oh, idx_msg, FAIL) /* Check for making an "internal" (i.e. within the H5O package) callback */ - if(op->op_type == H5O_MESG_OP_LIB) + if (op->op_type == H5O_MESG_OP_LIB) ret_value = (op->u.lib_op)(oh, idx_msg, sequence, &oh_modified, op_data); else ret_value = (op->u.app_op)(idx_msg->native, sequence, op_data); /* Check for iterator callback indicating to get out of loop */ - if(ret_value != 0) + if (ret_value != 0) break; /* Increment sequence value for message type */ sequence++; } /* end if */ - } /* end for */ + } /* end for */ /* Check for error from iterator */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_OHDR, H5E_CANTLIST, "iterator function failed"); done: /* Check if object message was modified */ - if(oh_modified) { + if (oh_modified) { /* Try to condense object header info */ /* (Since this routine is used to remove messages from an * object header, the header will be condensed after each * message removal) */ - if(oh_modified & H5O_MODIFY_CONDENSE) - if(H5O__condense_header(f, oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack object header") + if (oh_modified & H5O_MODIFY_CONDENSE) + if (H5O__condense_header(f, oh) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack object header") /* Mark object header as changed */ - if(H5O_touch_oh(f, oh, FALSE) < 0) + if (H5O_touch_oh(f, oh, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update time on object") /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_iterate_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_raw_size * @@ -1346,31 +1310,29 @@ done: *------------------------------------------------------------------------- */ size_t -H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared, - const void *mesg) +H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared, const void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - size_t ret_value = 0; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->raw_size); HDassert(f); HDassert(mesg); /* Compute the raw data size for the mesg */ - if(0 == (ret_value = (type->raw_size)(f, disable_shared, mesg))) + if (0 == (ret_value = (type->raw_size)(f, disable_shared, mesg))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_raw_size() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_size_f * @@ -1389,35 +1351,33 @@ done: *------------------------------------------------------------------------- */ size_t -H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, - const void *mesg, size_t extra_raw) +H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, const void *mesg, size_t extra_raw) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - H5P_genplist_t *ocpl; /* Object Creation Property list */ - uint8_t oh_flags; /* Object header status flags */ - size_t ret_value = 0; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + H5P_genplist_t * ocpl; /* Object Creation Property list */ + uint8_t oh_flags; /* Object header status flags */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->raw_size); HDassert(f); HDassert(mesg); /* Get the property list */ - if(NULL == (ocpl = (H5P_genplist_t *)H5I_object(ocpl_id))) + if (NULL == (ocpl = (H5P_genplist_t *)H5I_object(ocpl_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, 0, "not a property list") /* Get any object header status flags set by properties */ - if(H5P_get(ocpl, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) + if (H5P_get(ocpl, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "can't get object header flags") - /* Compute the raw data size for the mesg */ - if((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0) + if ((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message") /* Add in "extra" raw space */ @@ -1427,14 +1387,13 @@ H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, ret_value = (size_t)H5O_ALIGN_F(f, ret_value); /* Add space for message header */ - ret_value += (size_t)H5O_SIZEOF_MSGHDR_F(f, - (H5F_STORE_MSG_CRT_IDX(f) || oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)); + ret_value += (size_t)H5O_SIZEOF_MSGHDR_F( + f, (H5F_STORE_MSG_CRT_IDX(f) || oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_size_f() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_size_oh * @@ -1453,24 +1412,23 @@ done: *------------------------------------------------------------------------- */ size_t -H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, - const void *mesg, size_t extra_raw) +H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, const void *mesg, size_t extra_raw) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - size_t ret_value = 0; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->raw_size); HDassert(f); HDassert(mesg); /* Compute the raw data size for the mesg */ - if((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0) + if ((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message") /* Add in "extra" raw space */ @@ -1486,7 +1444,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_size_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_can_share * @@ -1507,19 +1464,19 @@ done: htri_t H5O_msg_can_share(unsigned type_id, const void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value = FAIL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); /* If there is a can_share callback, use it */ - if(type->can_share) + if (type->can_share) ret_value = (type->can_share)(mesg); else { /* Otherwise, the message can be shared if messages of this type are @@ -1536,7 +1493,6 @@ H5O_msg_can_share(unsigned type_id, const void *mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_can_share() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_can_share_in_ohdr * @@ -1554,14 +1510,14 @@ H5O_msg_can_share(unsigned type_id, const void *mesg) htri_t H5O_msg_can_share_in_ohdr(unsigned type_id) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value = FAIL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Otherwise, the message can be shared if messages of this type are @@ -1573,7 +1529,6 @@ H5O_msg_can_share_in_ohdr(unsigned type_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_can_share_in_ohdr() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_is_shared * @@ -1592,25 +1547,25 @@ H5O_msg_can_share_in_ohdr(unsigned type_id) htri_t H5O_msg_is_shared(unsigned type_id, const void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value = FAIL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ #ifdef H5O_ENABLE_BOGUS - if(type_id >= NELMTS(H5O_msg_class_g)) + if (type_id >= NELMTS(H5O_msg_class_g)) ret_value = FALSE; else #endif /* H5O_ENABLE_BOGUS */ { HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); /* If messages in a class aren't sharable, then obviously this message isn't shared! :-) */ - if(type->share_flags & H5O_SHARE_IS_SHARABLE) + if (type->share_flags & H5O_SHARE_IS_SHARABLE) ret_value = H5O_IS_STORED_SHARED(((const H5O_shared_t *)mesg)->type); else ret_value = FALSE; @@ -1619,7 +1574,6 @@ H5O_msg_is_shared(unsigned type_id, const void *mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_is_shared() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_set_share * @@ -1637,14 +1591,14 @@ H5O_msg_is_shared(unsigned type_id, const void *mesg) herr_t H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->share_flags & H5O_SHARE_IS_SHARABLE); HDassert(mesg); @@ -1654,15 +1608,15 @@ H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, void *mesg) /* If there's a special action for this class that needs to be performed * when setting the shared component, do that */ - if(type->set_share) { - if((type->set_share)(mesg, share) < 0) + if (type->set_share) { + if ((type->set_share)(mesg, share) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set shared message information") } /* end if */ else { /* Set this message as the shared component for the message, wiping out * any information that was there before */ - if(H5O_set_shared((H5O_shared_t *)mesg, share) < 0) + if (H5O_set_shared((H5O_shared_t *)mesg, share) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set shared message information") } /* end else */ @@ -1670,7 +1624,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_set_share() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_reset_share * @@ -1692,7 +1645,7 @@ H5O_msg_reset_share(unsigned H5_ATTR_NDEBUG_UNUSED type_id, void *mesg) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - HDassert(H5O_msg_class_g[type_id]); /* map the type ID to the actual type object */ + HDassert(H5O_msg_class_g[type_id]); /* map the type ID to the actual type object */ HDassert(H5O_msg_class_g[type_id]->share_flags & H5O_SHARE_IS_SHARABLE); HDassert(mesg); @@ -1702,7 +1655,6 @@ H5O_msg_reset_share(unsigned H5_ATTR_NDEBUG_UNUSED type_id, void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_msg_reset_share() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_get_crt_index * @@ -1719,22 +1671,22 @@ H5O_msg_reset_share(unsigned H5_ATTR_NDEBUG_UNUSED type_id, void *mesg) herr_t H5O_msg_get_crt_index(unsigned type_id, const void *mesg, H5O_msg_crt_idx_t *crt_idx) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); HDassert(crt_idx); /* If there is a "get_crt_index callback, use it */ - if(type->get_crt_index) { + if (type->get_crt_index) { /* Retrieve the creation index from the native message */ - if((type->get_crt_index)(mesg, crt_idx) < 0) + if ((type->get_crt_index)(mesg, crt_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve creation index") } /* end if */ else @@ -1744,7 +1696,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_get_crt_index() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_encode * @@ -1762,29 +1713,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared, - unsigned char *buf, const void *mesg) +H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared, unsigned char *buf, const void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(f); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Encode */ - if((type->encode)(f, disable_shared, buf, mesg) < 0) + if ((type->encode)(f, disable_shared, buf, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_decode * @@ -1807,30 +1756,28 @@ done: *------------------------------------------------------------------------- */ void * -H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, - const unsigned char *buf) +H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, const unsigned char *buf) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - unsigned ioflags = 0; /* Flags for decode routine */ - void *ret_value = NULL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + unsigned ioflags = 0; /* Flags for decode routine */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* check args */ HDassert(f); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* decode */ - if(NULL == (ret_value = (type->decode)(f, open_oh, 0, &ioflags, buf_size, buf))) + if (NULL == (ret_value = (type->decode)(f, open_oh, 0, &ioflags, buf_size, buf))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_copy_file * @@ -1850,11 +1797,10 @@ done: *------------------------------------------------------------------------- */ void * -H5O__msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, - void *native_src, H5F_t *file_dst, hbool_t *recompute_size, - unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata) +H5O__msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, void *native_src, H5F_t *file_dst, + hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1870,14 +1816,14 @@ H5O__msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, /* The copy_file callback will return an H5O_shared_t only if the message * to be copied is a committed datatype. */ - if(NULL == (ret_value = (type->copy_file)(file_src, native_src, file_dst, recompute_size, mesg_flags, cpy_info, udata))) + if (NULL == (ret_value = (type->copy_file)(file_src, native_src, file_dst, recompute_size, mesg_flags, + cpy_info, udata))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object header message to file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_alloc * @@ -1892,8 +1838,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned *mesg_flags, void *native, size_t *mesg_idx) +H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned *mesg_flags, void *native, + size_t *mesg_idx) { size_t new_idx; /* New index for message */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ @@ -1911,28 +1857,28 @@ H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(mesg_idx); /* Check if message is already shared */ - if((shared_mesg = H5O_msg_is_shared(type->id, native)) < 0) + if ((shared_mesg = H5O_msg_is_shared(type->id, native)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "error determining if message is shared") - else if(shared_mesg > 0) { + else if (shared_mesg > 0) { /* Increment message's reference count */ - if(type->link && (type->link)(f, oh, native) < 0) + if (type->link && (type->link)(f, oh, native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared message ref count") *mesg_flags |= H5O_MSG_FLAG_SHARED; } /* end if */ else { /* Attempt to share message */ - if(H5SM_try_share(f, oh, 0, type->id, native, mesg_flags) < 0) + if (H5SM_try_share(f, oh, 0, type->id, native, mesg_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") } /* end else */ /* Allocate space in the object header for the message */ - if(H5O__alloc(f, oh, type, native, &new_idx) < 0) + if (H5O__alloc(f, oh, type, native, &new_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for message") /* Get the message's "creation index", if it has one */ - if(type->get_crt_index) { + if (type->get_crt_index) { /* Retrieve the creation index from the native message */ - if((type->get_crt_index)(native, &oh->mesg[new_idx].crt_idx) < 0) + if ((type->get_crt_index)(native, &oh->mesg[new_idx].crt_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve creation index") } /* end if */ @@ -1943,7 +1889,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_alloc() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_mesg * @@ -1958,13 +1903,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, - const void *mesg, unsigned mesg_flags, unsigned update_flags) +H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, const void *mesg, + unsigned mesg_flags, unsigned update_flags) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - H5O_mesg_t *idx_msg = &oh->mesg[idx]; /* Pointer to message to modify */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + H5O_mesg_t * idx_msg = &oh->mesg[idx]; /* Pointer to message to modify */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1976,14 +1921,14 @@ H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, HDassert(mesg); /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, idx_msg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, idx_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Reset existing native information for the header's message */ H5O__msg_reset_real(type, idx_msg->native); /* Copy the native object for the message */ - if(NULL == (idx_msg->native = (type->copy)(mesg, idx_msg->native))) + if (NULL == (idx_msg->native = (type->copy)(mesg, idx_msg->native))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy message to object header") /* Update the message flags */ @@ -1991,27 +1936,26 @@ H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, /* Mark the message as modified */ idx_msg->dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; /* Release chunk */ - if(H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") chk_proxy = NULL; /* Update the modification time, if requested */ - if(update_flags & H5O_UPDATE_TIME) - if(H5O_touch_oh(f, oh, FALSE) < 0) + if (update_flags & H5O_UPDATE_TIME) + if (H5O_touch_oh(f, oh, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: /* Release chunk, if not already released */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_mesg() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_delete * @@ -2037,26 +1981,25 @@ done: herr_t H5O_msg_delete(H5F_t *f, H5O_t *open_oh, unsigned type_id, void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(f); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* delete */ - if((type->del) && (type->del)(f, open_oh, mesg) < 0) + if ((type->del) && (type->del)(f, open_oh, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__delete_mesg * @@ -2075,8 +2018,8 @@ done: herr_t H5O__delete_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) { - const H5O_msg_class_t *type = mesg->type; /* Type of object to free */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type = mesg->type; /* Type of object to free */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2086,19 +2029,19 @@ H5O__delete_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) HDassert(oh); /* Check if there is a file space deletion callback for this type of message */ - if(type->del) { + if (type->del) { /* Decode the message if necessary. */ H5O_LOAD_NATIVE(f, H5O_DECODEIO_NOCHANGE, oh, mesg, FAIL) - if((type->del)(f, oh, mesg->native) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") + if ((type->del)(f, oh, mesg->native) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, + "unable to delete file space for object header message") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__delete_mesg() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_flush * @@ -2115,9 +2058,9 @@ done: herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) { - uint8_t *p; /* Temporary pointer to encode with */ - unsigned msg_id; /* ID for message */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *p; /* Temporary pointer to encode with */ + unsigned msg_id; /* ID for message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2129,13 +2072,13 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) p = mesg->raw - H5O_SIZEOF_MSGHDR_OH(oh); /* Retrieve actual message ID, for unknown messages */ - if(mesg->type == H5O_MSG_UNKNOWN) + if (mesg->type == H5O_MSG_UNKNOWN) msg_id = *(H5O_unknown_t *)(mesg->native); else msg_id = (uint8_t)mesg->type->id; /* Encode the message prefix */ - if(oh->version == H5O_VERSION_1) + if (oh->version == H5O_VERSION_1) UINT16ENCODE(p, msg_id) else *p++ = (uint8_t)msg_id; @@ -2144,22 +2087,22 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) *p++ = mesg->flags; /* Only encode reserved bytes for version 1 of format */ - if(oh->version == H5O_VERSION_1) { + if (oh->version == H5O_VERSION_1) { *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ - } /* end for */ + } /* end for */ /* Only encode creation index for version 2+ of format */ else { /* Only encode creation index if they are being tracked */ - if(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) + if (oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) UINT16ENCODE(p, mesg->crt_idx); } /* end else */ HDassert(p == mesg->raw); #ifndef NDEBUG /* Make certain that null messages aren't in chunks w/gaps */ - if(H5O_NULL_ID == msg_id) + if (H5O_NULL_ID == msg_id) HDassert(oh->chunk[mesg->chunkno].gap == 0); else /* Non-null messages should always have a native pointer */ @@ -2167,7 +2110,7 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) #endif /* NDEBUG */ /* Encode the message itself, if it's not an "unknown" message */ - if(mesg->native && mesg->type != H5O_MSG_UNKNOWN) { + if (mesg->native && mesg->type != H5O_MSG_UNKNOWN) { /* * Encode the message. If the message is shared then we * encode a Shared Object message instead of the object @@ -2176,19 +2119,19 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) HDassert(mesg->raw >= oh->chunk[mesg->chunkno].image); HDassert(mesg->raw_size == H5O_ALIGN_OH(oh, mesg->raw_size)); HDassert(mesg->raw + mesg->raw_size <= - oh->chunk[mesg->chunkno].image + (oh->chunk[mesg->chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))); + oh->chunk[mesg->chunkno].image + (oh->chunk[mesg->chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))); #ifndef NDEBUG -/* Sanity check that the message won't overwrite past it's allocated space */ -{ - size_t msg_size; - - msg_size = mesg->type->raw_size(f, FALSE, mesg->native); - msg_size = H5O_ALIGN_OH(oh, msg_size); - HDassert(msg_size <= mesg->raw_size); -} + /* Sanity check that the message won't overwrite past it's allocated space */ + { + size_t msg_size; + + msg_size = mesg->type->raw_size(f, FALSE, mesg->native); + msg_size = H5O_ALIGN_OH(oh, msg_size); + HDassert(msg_size <= mesg->raw_size); + } #endif /* NDEBUG */ HDassert(mesg->type->encode); - if((mesg->type->encode)(f, FALSE, mesg->raw, mesg->native) < 0) + if ((mesg->type->encode)(f, FALSE, mesg->raw, mesg->native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message") } /* end if */ @@ -2199,7 +2142,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_flush() */ - /*------------------------------------------------------------------------- * Function: H5O__flush_msgs * @@ -2216,9 +2158,9 @@ done: herr_t H5O__flush_msgs(H5F_t *f, H5O_t *oh) { - H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2227,26 +2169,25 @@ H5O__flush_msgs(H5F_t *f, H5O_t *oh) HDassert(oh); /* Encode any dirty messages */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) - if(curr_msg->dirty) - if(H5O_msg_flush(f, oh, curr_msg) < 0) + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) + if (curr_msg->dirty) + if (H5O_msg_flush(f, oh, curr_msg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message") /* Sanity check for the correct # of messages in object header */ - if(oh->nmesgs != u) + if (oh->nmesgs != u) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "corrupt object header - too few messages") #ifndef NDEBUG - /* Reset the number of messages dirtied by decoding, as they have all - * been flushed */ - oh->ndecode_dirtied = 0; + /* Reset the number of messages dirtied by decoding, as they have all + * been flushed */ + oh->ndecode_dirtied = 0; #endif /* NDEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__flush_msgs() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_get_flags * @@ -2261,11 +2202,11 @@ done: herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t *flags) { - H5O_t *oh = NULL; /* Object header to use */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - H5O_mesg_t *idx_msg; /* Pointer to message to modify */ - unsigned idx; /* Index of message to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header to use */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + H5O_mesg_t * idx_msg; /* Pointer to message to modify */ + unsigned idx; /* Index of message to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2274,26 +2215,26 @@ H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t *flags) HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Locate message of correct type */ - for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) - if(type == idx_msg->type) + for (idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if (type == idx_msg->type) break; - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message type not found") /* Set return value */ *flags = idx_msg->flags; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Omodule.h b/src/H5Omodule.h index df3ab56..1d355f7 100644 --- a/src/H5Omodule.h +++ b/src/H5Omodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5O_MODULE -#define H5_MY_PKG H5O -#define H5_MY_PKG_ERR H5E_OHDR -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5O +#define H5_MY_PKG_ERR H5E_OHDR +#define H5_MY_PKG_INIT YES #endif /* _H5Omodule_H */ - diff --git a/src/H5Omtime.c b/src/H5Omtime.c index fbf7613..bf648e0 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -17,86 +17,82 @@ * Purpose: The object modification time message. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ - - -static void *H5O__mtime_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__mtime_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_mtime_new_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); static size_t H5O_mtime_new_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); -static void *H5O__mtime_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__mtime_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_mtime_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_mtime_copy(const void *_mesg, void *_dest); +static void * H5O_mtime_copy(const void *_mesg, void *_dest); static size_t H5O_mtime_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__mtime_free(void *_mesg); -static herr_t H5O__mtime_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__mtime_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_MTIME[1] = {{ - H5O_MTIME_ID, /*message id number */ - "mtime", /*message name for debugging */ - sizeof(time_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__mtime_decode, /*decode message */ - H5O_mtime_encode, /*encode message */ - H5O_mtime_copy, /*copy the native value */ - H5O_mtime_size, /*raw message size */ - NULL, /* reset method */ - H5O__mtime_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__mtime_debug /*debug the message */ + H5O_MTIME_ID, /*message id number */ + "mtime", /*message name for debugging */ + sizeof(time_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__mtime_decode, /*decode message */ + H5O_mtime_encode, /*encode message */ + H5O_mtime_copy, /*copy the native value */ + H5O_mtime_size, /*raw message size */ + NULL, /* reset method */ + H5O__mtime_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__mtime_debug /*debug the message */ }}; /* This message derives from H5O message class */ /* (Only encode, decode & size routines are different from old mtime routines) */ const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{ - H5O_MTIME_NEW_ID, /*message id number */ - "mtime_new", /*message name for debugging */ - sizeof(time_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__mtime_new_decode, /*decode message */ - H5O_mtime_new_encode, /*encode message */ - H5O_mtime_copy, /*copy the native value */ - H5O_mtime_new_size, /*raw message size */ - NULL, /* reset method */ - H5O__mtime_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__mtime_debug /*debug the message */ + H5O_MTIME_NEW_ID, /*message id number */ + "mtime_new", /*message name for debugging */ + sizeof(time_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__mtime_new_decode, /*decode message */ + H5O_mtime_new_encode, /*encode message */ + H5O_mtime_copy, /*copy the native value */ + H5O_mtime_new_size, /*raw message size */ + NULL, /* reset method */ + H5O__mtime_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__mtime_debug /*debug the message */ }}; /* Current version of new mtime information */ -#define H5O_MTIME_VERSION 1 +#define H5O_MTIME_VERSION 1 /* Declare a free list to manage the time_t struct */ H5FL_DEFINE(time_t); - /*------------------------------------------------------------------------- * Function: H5O__mtime_new_decode * @@ -118,12 +114,12 @@ H5FL_DEFINE(time_t); */ static void * H5O__mtime_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, + size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - time_t *mesg; - uint32_t tmp_time; /* Temporary copy of the time */ - void *ret_value = NULL; /* Return value */ + time_t * mesg; + uint32_t tmp_time; /* Temporary copy of the time */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -132,28 +128,27 @@ H5O__mtime_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(*p++ != H5O_MTIME_VERSION) + if (*p++ != H5O_MTIME_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for mtime message"); /* Skip reserved bytes */ - p+=3; + p += 3; /* Get the time_t from the file */ UINT32DECODE(p, tmp_time); /* The return value */ - if (NULL==(mesg = H5FL_MALLOC(time_t))) + if (NULL == (mesg = H5FL_MALLOC(time_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); *mesg = (time_t)tmp_time; /* Set return value */ - ret_value=mesg; + ret_value = mesg; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mtime_new_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__mtime_decode * @@ -174,14 +169,13 @@ done: *------------------------------------------------------------------------- */ static void * -H5O__mtime_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__mtime_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - time_t *mesg, the_time; - struct tm tm; - int i; /* Local index variable */ - void *ret_value = NULL; /* Return value */ + time_t * mesg, the_time; + struct tm tm; + int i; /* Local index variable */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -190,24 +184,24 @@ H5O__mtime_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - for(i = 0; i < 14; i++) - if(!HDisdigit(p[i])) + for (i = 0; i < 14; i++) + if (!HDisdigit(p[i])) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message") /* Convert YYYYMMDDhhmmss UTC to a time_t. */ HDmemset(&tm, 0, sizeof tm); - tm.tm_year = (p[0]-'0')*1000 + (p[1]-'0')*100 + (p[2]-'0')*10 + (p[3]-'0') - 1900; - tm.tm_mon = (p[4]-'0')*10 + (p[5]-'0') - 1; - tm.tm_mday = (p[6]-'0')*10 + (p[7]-'0'); - tm.tm_hour = (p[8]-'0')*10 + (p[9]-'0'); - tm.tm_min = (p[10]-'0')*10 + (p[11]-'0'); - tm.tm_sec = (p[12]-'0')*10 + (p[13]-'0'); + tm.tm_year = (p[0] - '0') * 1000 + (p[1] - '0') * 100 + (p[2] - '0') * 10 + (p[3] - '0') - 1900; + tm.tm_mon = (p[4] - '0') * 10 + (p[5] - '0') - 1; + tm.tm_mday = (p[6] - '0') * 10 + (p[7] - '0'); + tm.tm_hour = (p[8] - '0') * 10 + (p[9] - '0'); + tm.tm_min = (p[10] - '0') * 10 + (p[11] - '0'); + tm.tm_sec = (p[12] - '0') * 10 + (p[13] - '0'); tm.tm_isdst = -1; /* (figure it out) */ - if((time_t)-1 == (the_time = H5_make_time(&tm))) + if ((time_t)-1 == (the_time = H5_make_time(&tm))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't construct time info") /* The return value */ - if(NULL == (mesg = H5FL_MALLOC(time_t))) + if (NULL == (mesg = H5FL_MALLOC(time_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") *mesg = the_time; @@ -218,7 +212,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mtime_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_mtime_new_encode * @@ -233,9 +226,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O_mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const time_t *mesg = (const time_t *) _mesg; + const time_t *mesg = (const time_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -258,7 +252,6 @@ H5O_mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sha FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_mtime_new_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_mtime_encode * @@ -275,10 +268,11 @@ H5O_mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sha *------------------------------------------------------------------------- */ static herr_t -H5O_mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O_mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const time_t *mesg = (const time_t *) _mesg; - struct tm *tm; + const time_t *mesg = (const time_t *)_mesg; + struct tm * tm; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -289,14 +283,12 @@ H5O_mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, /* encode */ tm = HDgmtime(mesg); - HDsprintf((char*)p, "%04d%02d%02d%02d%02d%02d", - 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); + HDsprintf((char *)p, "%04d%02d%02d%02d%02d%02d", 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- * Function: H5O_mtime_copy * @@ -318,28 +310,27 @@ H5O_mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, static void * H5O_mtime_copy(const void *_mesg, void *_dest) { - const time_t *mesg = (const time_t *) _mesg; - time_t *dest = (time_t *) _dest; - void *ret_value = NULL; /* Return value */ + const time_t *mesg = (const time_t *)_mesg; + time_t * dest = (time_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(mesg); - if (!dest && NULL==(dest = H5FL_MALLOC(time_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (!dest && NULL == (dest = H5FL_MALLOC(time_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *mesg; /* Set return value */ - ret_value=dest; + ret_value = dest; done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5O_mtime_new_size * @@ -361,7 +352,8 @@ done: *------------------------------------------------------------------------- */ static size_t -H5O_mtime_new_size(const H5F_t H5_ATTR_UNUSED * f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED * mesg) +H5O_mtime_new_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -372,7 +364,6 @@ H5O_mtime_new_size(const H5F_t H5_ATTR_UNUSED * f, hbool_t H5_ATTR_UNUSED disabl FUNC_LEAVE_NOAPI(8) } /* end H5O_mtime_new_size() */ - /*------------------------------------------------------------------------- * Function: H5O_mtime_size * @@ -394,7 +385,8 @@ H5O_mtime_new_size(const H5F_t H5_ATTR_UNUSED * f, hbool_t H5_ATTR_UNUSED disabl *------------------------------------------------------------------------- */ static size_t -H5O_mtime_size(const H5F_t H5_ATTR_UNUSED * f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED * mesg) +H5O_mtime_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *mesg) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -405,7 +397,6 @@ H5O_mtime_size(const H5F_t H5_ATTR_UNUSED * f, hbool_t H5_ATTR_UNUSED disable_sh FUNC_LEAVE_NOAPI(16) } - /*------------------------------------------------------------------------- * Function: H5O__mtime_free * @@ -430,7 +421,6 @@ H5O__mtime_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mtime_free() */ - /*------------------------------------------------------------------------- * Function: H5O__mtime_debug * @@ -445,12 +435,11 @@ H5O__mtime_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__mtime_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__mtime_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const time_t *mesg = (const time_t *)_mesg; - struct tm *tm; - char buf[128]; + const time_t *mesg = (const time_t *)_mesg; + struct tm * tm; + char buf[128]; FUNC_ENTER_STATIC_NOERR @@ -465,9 +454,7 @@ H5O__mtime_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, tm = HDlocaltime(mesg); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Time:", buf); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mtime_debug() */ - diff --git a/src/H5Oname.c b/src/H5Oname.c index 1f20f10..1d122af 100644 --- a/src/H5Oname.c +++ b/src/H5Oname.c @@ -22,50 +22,46 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O__name_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void *H5O__name_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); static herr_t H5O_name_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_name_copy(const void *_mesg, void *_dest); +static void * H5O_name_copy(const void *_mesg, void *_dest); static size_t H5O_name_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__name_reset(void *_mesg); -static herr_t H5O__name_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__name_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_NAME[1] = {{ - H5O_NAME_ID, /*message id number */ - "name", /*message name for debugging */ - sizeof(H5O_name_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__name_decode, /*decode message */ - H5O_name_encode, /*encode message */ - H5O_name_copy, /*copy the native value */ - H5O_name_size, /*raw message size */ - H5O__name_reset, /*free internal memory */ - NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__name_debug /*debug the message */ + H5O_NAME_ID, /*message id number */ + "name", /*message name for debugging */ + sizeof(H5O_name_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__name_decode, /*decode message */ + H5O_name_encode, /*encode message */ + H5O_name_copy, /*copy the native value */ + H5O_name_size, /*raw message size */ + H5O__name_reset, /*free internal memory */ + NULL, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__name_debug /*debug the message */ }}; - /*------------------------------------------------------------------------- * Function: H5O__name_decode * @@ -83,12 +79,11 @@ const H5O_msg_class_t H5O_MSG_NAME[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O__name_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__name_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_name_t *mesg; - void *ret_value = NULL; /* Return value */ + H5O_name_t *mesg; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -97,23 +92,22 @@ H5O__name_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(NULL == (mesg = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (mesg->s = (char *)H5MM_strdup((const char *)p))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (mesg = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (mesg->s = (char *)H5MM_strdup((const char *)p))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set return value */ ret_value = mesg; done: - if(NULL == ret_value) - if(mesg) + if (NULL == ret_value) + if (mesg) mesg = (H5O_name_t *)H5MM_xfree(mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__name_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_name_encode * @@ -132,7 +126,7 @@ done: static herr_t H5O_name_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_name_t *mesg = (const H5O_name_t *) _mesg; + const H5O_name_t *mesg = (const H5O_name_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -142,12 +136,11 @@ H5O_name_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, HDassert(mesg && mesg->s); /* encode */ - HDstrcpy((char*)p, mesg->s); + HDstrcpy((char *)p, mesg->s); FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- * Function: H5O_name_copy * @@ -169,35 +162,34 @@ H5O_name_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, static void * H5O_name_copy(const void *_mesg, void *_dest) { - const H5O_name_t *mesg = (const H5O_name_t *) _mesg; - H5O_name_t *dest = (H5O_name_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_name_t *mesg = (const H5O_name_t *)_mesg; + H5O_name_t * dest = (H5O_name_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(mesg); - if(!dest && NULL == (dest = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ *dest = *mesg; - if(NULL == (dest->s = H5MM_xstrdup(mesg->s))) + if (NULL == (dest->s = H5MM_xstrdup(mesg->s))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set return value */ ret_value = dest; done: - if(NULL == ret_value) - if(dest && NULL == _dest) + if (NULL == ret_value) + if (dest && NULL == _dest) dest = (H5O_name_t *)H5MM_xfree(dest); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_name_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_name_size * @@ -221,8 +213,8 @@ done: static size_t H5O_name_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_name_t *mesg = (const H5O_name_t *) _mesg; - size_t ret_value = 0; /* Return value */ + const H5O_name_t *mesg = (const H5O_name_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -235,7 +227,6 @@ H5O_name_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5O__name_reset * @@ -253,7 +244,7 @@ H5O_name_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar static herr_t H5O__name_reset(void *_mesg) { - H5O_name_t *mesg = (H5O_name_t *) _mesg; + H5O_name_t *mesg = (H5O_name_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -266,7 +257,6 @@ H5O__name_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__name_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__name_debug * @@ -283,10 +273,9 @@ H5O__name_reset(void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__name_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__name_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_name_t *mesg = (const H5O_name_t *)_mesg; + const H5O_name_t *mesg = (const H5O_name_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -297,10 +286,7 @@ H5O__name_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, - "Name:", - mesg->s); + HDfprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", mesg->s); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__name_debug() */ - diff --git a/src/H5Onull.c b/src/H5Onull.c index 5697455..78f5a69 100644 --- a/src/H5Onull.c +++ b/src/H5Onull.c @@ -22,34 +22,31 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Opkg.h" /* Object headers */ /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_NULL[1] = {{ - H5O_NULL_ID, /*message id number */ - "null", /*message name for debugging */ - 0, /*native message size */ - 0, /* messages are sharable? */ - NULL, /*no decode method */ - NULL, /*no encode method */ - NULL, /*no copy method */ - NULL, /*no size method */ - NULL, /*no reset method */ - NULL, /*no free method */ - NULL, /*no file delete method */ - NULL, /*no link method */ - NULL, /*no set share method */ - NULL, /*no can share method */ - NULL, /*no pre copy native value to file */ - NULL, /*no copy native value to file */ - NULL, /*no post copy native value to file */ - NULL, /*no get creation index */ - NULL, /*no set creation index */ - NULL /*no debug method */ + H5O_NULL_ID, /*message id number */ + "null", /*message name for debugging */ + 0, /*native message size */ + 0, /* messages are sharable? */ + NULL, /*no decode method */ + NULL, /*no encode method */ + NULL, /*no copy method */ + NULL, /*no size method */ + NULL, /*no reset method */ + NULL, /*no free method */ + NULL, /*no file delete method */ + NULL, /*no link method */ + NULL, /*no set share method */ + NULL, /*no can share method */ + NULL, /*no pre copy native value to file */ + NULL, /*no copy native value to file */ + NULL, /*no post copy native value to file */ + NULL, /*no get creation index */ + NULL, /*no set creation index */ + NULL /*no debug method */ }}; - diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 16ea8e5..e63e622 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -19,32 +19,33 @@ #define _H5Opkg_H /* Get package's private header */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Oprivate.h" /* Object headers */ /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ /* Object header macros */ -#define H5O_NMESGS 8 /*initial number of messages */ -#define H5O_NCHUNKS 2 /*initial number of chunks */ -#define H5O_MIN_SIZE 22 /* Min. obj header data size (must be big enough for a message prefix and a continuation message) */ -#define H5O_MSG_TYPES 26 /* # of types of messages */ -#define H5O_MAX_CRT_ORDER_IDX 65535 /* Max. creation order index value */ +#define H5O_NMESGS 8 /*initial number of messages */ +#define H5O_NCHUNKS 2 /*initial number of chunks */ +#define H5O_MIN_SIZE \ + 22 /* Min. obj header data size (must be big enough for a message prefix and a continuation message) */ +#define H5O_MSG_TYPES 26 /* # of types of messages */ +#define H5O_MAX_CRT_ORDER_IDX 65535 /* Max. creation order index value */ /* Versions of object header structure */ /* Initial version of the object header format */ -#define H5O_VERSION_1 1 +#define H5O_VERSION_1 1 /* Revised version - leaves out reserved bytes and alignment padding, and adds * magic number as prefix and checksum as suffix for all chunks. */ -#define H5O_VERSION_2 2 +#define H5O_VERSION_2 2 /* The latest version of the format. Look through the 'flush' * and 'size' callback for places to change when updating this. */ -#define H5O_VERSION_LATEST H5O_VERSION_2 +#define H5O_VERSION_LATEST H5O_VERSION_2 /* * Align messages on 8-byte boundaries because we would like to copy the @@ -54,20 +55,13 @@ * * Note: We no longer attempt to do this. - QAK, 10/16/06 */ -#define H5O_ALIGN_OLD(X) (8 * (((X) + 7) / 8)) -#define H5O_ALIGN_VERS(V, X) \ - (((V) == H5O_VERSION_1) ? \ - H5O_ALIGN_OLD(X) \ - : \ - (X) \ - ) -#define H5O_ALIGN_OH(O, X) \ - H5O_ALIGN_VERS((O)->version, X) -#define H5O_ALIGN_F(F, X) \ - H5O_ALIGN_VERS(MAX(H5O_VERSION_1, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), X) +#define H5O_ALIGN_OLD(X) (8 * (((X) + 7) / 8)) +#define H5O_ALIGN_VERS(V, X) (((V) == H5O_VERSION_1) ? H5O_ALIGN_OLD(X) : (X)) +#define H5O_ALIGN_OH(O, X) H5O_ALIGN_VERS((O)->version, X) +#define H5O_ALIGN_F(F, X) H5O_ALIGN_VERS(MAX(H5O_VERSION_1, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), X) /* Size of checksum (on disk) */ -#define H5O_SIZEOF_CHKSUM 4 +#define H5O_SIZEOF_CHKSUM 4 /* ========= Object Creation properties ============ */ /* Default values for some of the object creation properties */ @@ -76,99 +70,87 @@ * default attribute phase change storage are handled correctly if they * are changed. */ -#define H5O_CRT_ATTR_MAX_COMPACT_DEF 8 -#define H5O_CRT_ATTR_MIN_DENSE_DEF 6 -#define H5O_CRT_OHDR_FLAGS_DEF H5O_HDR_STORE_TIMES +#define H5O_CRT_ATTR_MAX_COMPACT_DEF 8 +#define H5O_CRT_ATTR_MIN_DENSE_DEF 6 +#define H5O_CRT_OHDR_FLAGS_DEF H5O_HDR_STORE_TIMES /* Object header status flag definitions */ -#define H5O_HDR_CHUNK0_1 0x00 /* Use 1-byte value for chunk #0 size */ -#define H5O_HDR_CHUNK0_2 0x01 /* Use 2-byte value for chunk #0 size */ -#define H5O_HDR_CHUNK0_4 0x02 /* Use 4-byte value for chunk #0 size */ -#define H5O_HDR_CHUNK0_8 0x03 /* Use 8-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_1 0x00 /* Use 1-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_2 0x01 /* Use 2-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_4 0x02 /* Use 4-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_8 0x03 /* Use 8-byte value for chunk #0 size */ /* * Size of object header prefix. */ -#define H5O_SIZEOF_HDR(O) \ - (((O)->version == H5O_VERSION_1) \ - ? \ - H5O_ALIGN_OLD(1 + /*version number */ \ - 1 + /*reserved */ \ - 2 + /*number of messages */ \ - 4 + /*reference count */ \ - 4) /*chunk data size */ \ - : \ - (H5_SIZEOF_MAGIC + /*magic number */ \ - 1 + /*version number */ \ - 1 + /*flags */ \ - (((O)->flags & H5O_HDR_STORE_TIMES) ? ( \ - 4 + /*access time */ \ - 4 + /*modification time */ \ - 4 + /*change time */ \ - 4 /*birth time */ \ - ) : 0) + \ - (((O)->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? ( \ - 2 + /*max compact attributes */ \ - 2 /*min dense attributes */ \ - ) : 0) + \ - (1 << ((O)->flags & H5O_HDR_CHUNK0_SIZE)) + /*chunk 0 data size */ \ - H5O_SIZEOF_CHKSUM) /*checksum size */ \ +#define H5O_SIZEOF_HDR(O) \ + (((O)->version == H5O_VERSION_1) \ + ? H5O_ALIGN_OLD(1 + /*version number */ \ + 1 + /*reserved */ \ + 2 + /*number of messages */ \ + 4 + /*reference count */ \ + 4) /*chunk data size */ \ + : (H5_SIZEOF_MAGIC + /*magic number */ \ + 1 + /*version number */ \ + 1 + /*flags */ \ + (((O)->flags & H5O_HDR_STORE_TIMES) ? (4 + /*access time */ \ + 4 + /*modification time */ \ + 4 + /*change time */ \ + 4 /*birth time */ \ + ) \ + : 0) + \ + (((O)->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? (2 + /*max compact attributes */ \ + 2 /*min dense attributes */ \ + ) \ + : 0) + \ + (1 << ((O)->flags & H5O_HDR_CHUNK0_SIZE)) + /*chunk 0 data size */ \ + H5O_SIZEOF_CHKSUM) /*checksum size */ \ ) /* * Size of object header message prefix */ -#define H5O_SIZEOF_MSGHDR_VERS(V,C) \ - (((V) == H5O_VERSION_1) \ - ? \ - H5O_ALIGN_OLD(2 + /*message type */ \ - 2 + /*sizeof message data */ \ - 1 + /*flags */ \ - 3) /*reserved */ \ - : \ - (1 + /*message type */ \ - 2 + /*sizeof message data */ \ - 1 + /*flags */ \ - ((C) ? ( \ - 2 /*creation index */ \ - ) : 0)) \ - ) -#define H5O_SIZEOF_MSGHDR_OH(O) \ - (unsigned)H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) -#define H5O_SIZEOF_MSGHDR_F(F, C) \ - (unsigned)H5O_SIZEOF_MSGHDR_VERS(MAX((H5F_STORE_MSG_CRT_IDX(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), (C)) +#define H5O_SIZEOF_MSGHDR_VERS(V, C) \ + (((V) == H5O_VERSION_1) ? H5O_ALIGN_OLD(2 + /*message type */ \ + 2 + /*sizeof message data */ \ + 1 + /*flags */ \ + 3) /*reserved */ \ + : (1 + /*message type */ \ + 2 + /*sizeof message data */ \ + 1 + /*flags */ \ + ((C) ? (2 /*creation index */ \ + ) \ + : 0))) +#define H5O_SIZEOF_MSGHDR_OH(O) \ + (unsigned)H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags &H5O_HDR_ATTR_CRT_ORDER_TRACKED) +#define H5O_SIZEOF_MSGHDR_F(F, C) \ + (unsigned)H5O_SIZEOF_MSGHDR_VERS(MAX((H5F_STORE_MSG_CRT_IDX(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), \ + (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), \ + (C)) /* * Size of chunk "header" for each chunk */ -#define H5O_SIZEOF_CHKHDR_VERS(V) \ - (((V) == H5O_VERSION_1) \ - ? \ - 0 + /*no magic # */ \ - 0 /*no checksum */ \ - : \ - H5_SIZEOF_MAGIC + /*magic # */ \ - H5O_SIZEOF_CHKSUM /*checksum */ \ +#define H5O_SIZEOF_CHKHDR_VERS(V) \ + (((V) == H5O_VERSION_1) ? 0 + /*no magic # */ \ + 0 /*no checksum */ \ + : H5_SIZEOF_MAGIC + /*magic # */ \ + H5O_SIZEOF_CHKSUM /*checksum */ \ ) -#define H5O_SIZEOF_CHKHDR_OH(O) \ - H5O_SIZEOF_CHKHDR_VERS((O)->version) +#define H5O_SIZEOF_CHKHDR_OH(O) H5O_SIZEOF_CHKHDR_VERS((O)->version) /* * Size of checksum for each chunk */ -#define H5O_SIZEOF_CHKSUM_VERS(V) \ - (((V) == H5O_VERSION_1) \ - ? \ - 0 /*no checksum */ \ - : \ - H5O_SIZEOF_CHKSUM /*checksum */ \ +#define H5O_SIZEOF_CHKSUM_VERS(V) \ + (((V) == H5O_VERSION_1) ? 0 /*no checksum */ \ + : H5O_SIZEOF_CHKSUM /*checksum */ \ ) -#define H5O_SIZEOF_CHKSUM_OH(O) \ - H5O_SIZEOF_CHKSUM_VERS((O)->version) +#define H5O_SIZEOF_CHKSUM_OH(O) H5O_SIZEOF_CHKSUM_VERS((O)->version) /* Input/output flags for decode functions */ -#define H5O_DECODEIO_NOCHANGE 0x01u /* IN: do not modify values */ -#define H5O_DECODEIO_DIRTY 0x02u /* OUT: message has been changed */ +#define H5O_DECODEIO_NOCHANGE 0x01u /* IN: do not modify values */ +#define H5O_DECODEIO_DIRTY 0x02u /* OUT: message has been changed */ /* Macro to incremend ndecode_dirtied (only if we are debugging) */ #ifndef NDEBUG @@ -179,41 +161,43 @@ /* Load native information for a message, if it's not already present */ /* (Only works for messages with decode callback) */ -#define H5O_LOAD_NATIVE(F, IOF, OH, MSG, ERR) \ - if(NULL == (MSG)->native) { \ - const H5O_msg_class_t *msg_type = (MSG)->type; \ - unsigned ioflags = (IOF); \ - \ - /* Decode the message */ \ - HDassert(msg_type->decode); \ - if(NULL == ((MSG)->native = (msg_type->decode)((F), (OH), (MSG)->flags, &ioflags, (MSG)->raw_size, (MSG)->raw))) \ - HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \ - \ - /* Mark the message dirty if it was changed by decoding */ \ - if((ioflags & H5O_DECODEIO_DIRTY) && (H5F_get_intent((F)) & H5F_ACC_RDWR)) { \ - (MSG)->dirty = TRUE; \ - /* Increment the count of messages dirtied by decoding, but */ \ - /* only ifndef NDEBUG */ \ - INCR_NDECODE_DIRTIED(OH) \ - } \ - \ - /* Set the message's "shared info", if it's shareable */ \ - if((MSG)->flags & H5O_MSG_FLAG_SHAREABLE) { \ - HDassert(msg_type->share_flags & H5O_SHARE_IS_SHARABLE); \ - H5O_UPDATE_SHARED((H5O_shared_t *)(MSG)->native, H5O_SHARE_TYPE_HERE, (F), msg_type->id, (MSG)->crt_idx, (OH)->chunk[0].addr) \ - } /* end if */ \ - \ - /* Set the message's "creation index", if it has one */ \ - if(msg_type->set_crt_index) { \ - /* Set the creation index for the message */ \ - if((msg_type->set_crt_index)((MSG)->native, (MSG)->crt_idx) < 0) \ - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, ERR, "unable to set creation index") \ - } /* end if */ \ - } /* end if */ +#define H5O_LOAD_NATIVE(F, IOF, OH, MSG, ERR) \ + if (NULL == (MSG)->native) { \ + const H5O_msg_class_t *msg_type = (MSG)->type; \ + unsigned ioflags = (IOF); \ + \ + /* Decode the message */ \ + HDassert(msg_type->decode); \ + if (NULL == ((MSG)->native = (msg_type->decode)((F), (OH), (MSG)->flags, &ioflags, (MSG)->raw_size, \ + (MSG)->raw))) \ + HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \ + \ + /* Mark the message dirty if it was changed by decoding */ \ + if ((ioflags & H5O_DECODEIO_DIRTY) && (H5F_get_intent((F)) & H5F_ACC_RDWR)) { \ + (MSG)->dirty = TRUE; \ + /* Increment the count of messages dirtied by decoding, but */ \ + /* only ifndef NDEBUG */ \ + INCR_NDECODE_DIRTIED(OH) \ + } \ + \ + /* Set the message's "shared info", if it's shareable */ \ + if ((MSG)->flags & H5O_MSG_FLAG_SHAREABLE) { \ + HDassert(msg_type->share_flags &H5O_SHARE_IS_SHARABLE); \ + H5O_UPDATE_SHARED((H5O_shared_t *)(MSG)->native, H5O_SHARE_TYPE_HERE, (F), msg_type->id, \ + (MSG)->crt_idx, (OH)->chunk[0].addr) \ + } /* end if */ \ + \ + /* Set the message's "creation index", if it has one */ \ + if (msg_type->set_crt_index) { \ + /* Set the creation index for the message */ \ + if ((msg_type->set_crt_index)((MSG)->native, (MSG)->crt_idx) < 0) \ + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, ERR, "unable to set creation index") \ + } /* end if */ \ + } /* end if */ /* Flags for a message class's "sharability" */ -#define H5O_SHARE_IS_SHARABLE 0x01 -#define H5O_SHARE_IN_OHDR 0x02 +#define H5O_SHARE_IS_SHARABLE 0x01 +#define H5O_SHARE_IN_OHDR 0x02 /* Set the object header size to speculatively read in */ /* (needs to be more than the object header prefix size to work at all and @@ -221,59 +205,61 @@ * size to save the extra I/O operations) */ #define H5O_SPEC_READ_SIZE 512 - /* The "message class" type */ struct H5O_msg_class_t { - unsigned id; /*message type ID on disk */ - const char *name; /*for debugging */ - size_t native_size; /*size of native message */ - unsigned share_flags; /* Message sharing settings */ - void *(*decode)(H5F_t *, H5O_t *, unsigned, unsigned *, size_t, const uint8_t *); - herr_t (*encode)(H5F_t *, hbool_t, uint8_t *, const void *); - void *(*copy)(const void *, void *); /*copy native value */ - size_t (*raw_size)(const H5F_t *, hbool_t, const void *);/*sizeof encoded message */ - herr_t (*reset)(void *); /*free nested data structs */ - herr_t (*free)(void *); /*free main data struct */ - herr_t (*del)(H5F_t *, H5O_t *, void *); /* Delete space in file referenced by this message */ - herr_t (*link)(H5F_t *, H5O_t *, void *); /* Increment any links in file reference by this message */ - herr_t (*set_share)(void*, const H5O_shared_t*); /* Set shared information */ - htri_t (*can_share)(const void *); /* Is message allowed to be shared? */ - herr_t (*pre_copy_file)(H5F_t *, const void *, hbool_t *, const H5O_copy_t *, void *); /*"pre copy" action when copying native value to file */ - void *(*copy_file)(H5F_t *, void *, H5F_t *, hbool_t *, unsigned *, H5O_copy_t *, void *); /*copy native value to file */ - herr_t (*post_copy_file)(const H5O_loc_t *, const void *, H5O_loc_t *, void *, unsigned *, H5O_copy_t *); /*"post copy" action when copying native value to file */ - herr_t (*get_crt_index)(const void *, H5O_msg_crt_idx_t *); /* Get message's creation index */ - herr_t (*set_crt_index)(void *, H5O_msg_crt_idx_t); /* Set message's creation index */ - herr_t (*debug)(H5F_t*, const void*, FILE*, int, int); + unsigned id; /*message type ID on disk */ + const char *name; /*for debugging */ + size_t native_size; /*size of native message */ + unsigned share_flags; /* Message sharing settings */ + void *(*decode)(H5F_t *, H5O_t *, unsigned, unsigned *, size_t, const uint8_t *); + herr_t (*encode)(H5F_t *, hbool_t, uint8_t *, const void *); + void *(*copy)(const void *, void *); /*copy native value */ + size_t (*raw_size)(const H5F_t *, hbool_t, const void *); /*sizeof encoded message */ + herr_t (*reset)(void *); /*free nested data structs */ + herr_t (*free)(void *); /*free main data struct */ + herr_t (*del)(H5F_t *, H5O_t *, void *); /* Delete space in file referenced by this message */ + herr_t (*link)(H5F_t *, H5O_t *, void *); /* Increment any links in file reference by this message */ + herr_t (*set_share)(void *, const H5O_shared_t *); /* Set shared information */ + htri_t (*can_share)(const void *); /* Is message allowed to be shared? */ + herr_t (*pre_copy_file)(H5F_t *, const void *, hbool_t *, const H5O_copy_t *, + void *); /*"pre copy" action when copying native value to file */ + void *(*copy_file)(H5F_t *, void *, H5F_t *, hbool_t *, unsigned *, H5O_copy_t *, + void *); /*copy native value to file */ + herr_t (*post_copy_file)(const H5O_loc_t *, const void *, H5O_loc_t *, void *, unsigned *, + H5O_copy_t *); /*"post copy" action when copying native value to file */ + herr_t (*get_crt_index)(const void *, H5O_msg_crt_idx_t *); /* Get message's creation index */ + herr_t (*set_crt_index)(void *, H5O_msg_crt_idx_t); /* Set message's creation index */ + herr_t (*debug)(H5F_t *, const void *, FILE *, int, int); }; struct H5O_mesg_t { - const H5O_msg_class_t *type; /* type of message */ - hbool_t dirty; /* raw out of date wrt native */ - uint8_t flags; /* message flags */ - H5O_msg_crt_idx_t crt_idx; /* message creation index */ - unsigned chunkno; /* chunk number for this mesg */ - void *native; /* native format message */ - uint8_t *raw; /* pointer to raw data */ - size_t raw_size; /* size with alignment */ + const H5O_msg_class_t *type; /* type of message */ + hbool_t dirty; /* raw out of date wrt native */ + uint8_t flags; /* message flags */ + H5O_msg_crt_idx_t crt_idx; /* message creation index */ + unsigned chunkno; /* chunk number for this mesg */ + void * native; /* native format message */ + uint8_t * raw; /* pointer to raw data */ + size_t raw_size; /* size with alignment */ }; /* Struct for storing information about "best" message to move to new chunk */ typedef struct H5O_msg_alloc_info_t { - int msgno; /* Index in message array */ - unsigned id; /* Message type ID on disk */ - unsigned chunkno; /* Index in chunk array */ - size_t gap_size; /* Size of any "gap" in the chunk immediately after message */ - size_t null_size; /* Size of any null message in the chunk immediately after message */ - size_t total_size; /* Total size of "available" space around message */ - unsigned null_msgno; /* Message index of null message immediately after message */ + int msgno; /* Index in message array */ + unsigned id; /* Message type ID on disk */ + unsigned chunkno; /* Index in chunk array */ + size_t gap_size; /* Size of any "gap" in the chunk immediately after message */ + size_t null_size; /* Size of any null message in the chunk immediately after message */ + size_t total_size; /* Total size of "available" space around message */ + unsigned null_msgno; /* Message index of null message immediately after message */ } H5O_msg_alloc_info_t; typedef struct H5O_chunk_t { - haddr_t addr; /*chunk file address */ - size_t size; /*chunk size */ - size_t gap; /*space at end of chunk too small for null message */ - uint8_t *image; /*image of file */ - struct H5O_chunk_proxy_t *chunk_proxy; /* Pointer to a chunk's proxy when chunk protected */ + haddr_t addr; /*chunk file address */ + size_t size; /*chunk size */ + size_t gap; /*space at end of chunk too small for null message */ + uint8_t * image; /*image of file */ + struct H5O_chunk_proxy_t *chunk_proxy; /* Pointer to a chunk's proxy when chunk protected */ } H5O_chunk_t; struct H5O_t { @@ -281,115 +267,116 @@ struct H5O_t { /* first field in structure */ /* File-specific information (not stored) */ - size_t sizeof_size; /* Size of file sizes */ - size_t sizeof_addr; /* Size of file addresses */ - hbool_t swmr_write; /* Whether we are doing SWMR writes */ + size_t sizeof_size; /* Size of file sizes */ + size_t sizeof_addr; /* Size of file addresses */ + hbool_t swmr_write; /* Whether we are doing SWMR writes */ /* Debugging information (not stored) */ #ifdef H5O_ENABLE_BAD_MESG_COUNT - hbool_t store_bad_mesg_count; /* Flag to indicate that a bad message count should be stored */ - /* (This is to simulate a bug in earlier - * versions of the library) - */ -#endif /* H5O_ENABLE_BAD_MESG_COUNT */ + hbool_t store_bad_mesg_count; /* Flag to indicate that a bad message count should be stored */ + /* (This is to simulate a bug in earlier + * versions of the library) + */ +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ #ifndef NDEBUG - size_t ndecode_dirtied; /* Number of messages dirtied by decoding */ -#endif /* NDEBUG */ + size_t ndecode_dirtied; /* Number of messages dirtied by decoding */ +#endif /* NDEBUG */ /* Chunk management information (not stored) */ - size_t rc; /* Reference count of [continuation] chunks using this structure */ + size_t rc; /* Reference count of [continuation] chunks using this structure */ /* Object information (stored) */ - hbool_t has_refcount_msg; /* Whether the object has a ref. count message */ - unsigned nlink; /*link count */ - uint8_t version; /*version number */ - uint8_t flags; /*flags */ + hbool_t has_refcount_msg; /* Whether the object has a ref. count message */ + unsigned nlink; /*link count */ + uint8_t version; /*version number */ + uint8_t flags; /*flags */ /* Time information (stored, for versions > 1 & H5O_HDR_STORE_TIMES flag set) */ - time_t atime; /*access time */ - time_t mtime; /*modification time */ - time_t ctime; /*change time */ - time_t btime; /*birth time */ + time_t atime; /*access time */ + time_t mtime; /*modification time */ + time_t ctime; /*change time */ + time_t btime; /*birth time */ /* Attribute information (stored, for versions > 1) */ - unsigned max_compact; /* Maximum # of compact attributes */ - unsigned min_dense; /* Minimum # of "dense" attributes */ + unsigned max_compact; /* Maximum # of compact attributes */ + unsigned min_dense; /* Minimum # of "dense" attributes */ /* Message management (stored, encoded in chunks) */ - size_t nmesgs; /*number of messages */ - size_t alloc_nmesgs; /*number of message slots */ - H5O_mesg_t *mesg; /*array of messages */ - size_t link_msgs_seen; /* # of link messages seen when loading header */ - size_t attr_msgs_seen; /* # of attribute messages seen when loading header */ + size_t nmesgs; /*number of messages */ + size_t alloc_nmesgs; /*number of message slots */ + H5O_mesg_t *mesg; /*array of messages */ + size_t link_msgs_seen; /* # of link messages seen when loading header */ + size_t attr_msgs_seen; /* # of attribute messages seen when loading header */ /* Chunk management (not stored) */ - size_t nchunks; /*number of chunks */ - size_t alloc_nchunks; /*chunks allocated */ - H5O_chunk_t *chunk; /*array of chunks */ - hbool_t chunks_pinned; /* Whether chunks are pinned from ohdr protect */ + size_t nchunks; /*number of chunks */ + size_t alloc_nchunks; /*chunks allocated */ + H5O_chunk_t *chunk; /*array of chunks */ + hbool_t chunks_pinned; /* Whether chunks are pinned from ohdr protect */ /* Object header proxy information (not stored) */ - H5AC_proxy_entry_t *proxy; /* Proxy cache entry for all ohdr entries */ + H5AC_proxy_entry_t *proxy; /* Proxy cache entry for all ohdr entries */ }; /* Class for types of objects in file */ typedef struct H5O_obj_class_t { - H5O_type_t type; /*object type on disk */ - const char *name; /*for debugging */ - void *(*get_copy_file_udata)(void); /*retrieve user data for 'copy file' operation */ - void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */ - htri_t (*isa)(const H5O_t *); /*if a header matches an object class */ - void *(*open)(const H5G_loc_t *, H5I_type_t *); /*open an object of this class */ - void *(*create)(H5F_t *, void *, H5G_loc_t *); /*create an object of this class */ - H5O_loc_t *(*get_oloc)(hid_t ); /*get the object header location for an object */ - herr_t (*bh_info)(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); /*get the index & heap info for an object */ - herr_t (*flush)(void *obj_ptr); /*flush an opened object of this class */ + H5O_type_t type; /*object type on disk */ + const char *name; /*for debugging */ + void *(*get_copy_file_udata)(void); /*retrieve user data for 'copy file' operation */ + void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */ + htri_t (*isa)(const H5O_t *); /*if a header matches an object class */ + void *(*open)(const H5G_loc_t *, H5I_type_t *); /*open an object of this class */ + void *(*create)(H5F_t *, void *, H5G_loc_t *); /*create an object of this class */ + H5O_loc_t *(*get_oloc)(hid_t); /*get the object header location for an object */ + herr_t (*bh_info)(const H5O_loc_t *loc, H5O_t *oh, + H5_ih_info_t *bh_info); /*get the index & heap info for an object */ + herr_t (*flush)(void *obj_ptr); /*flush an opened object of this class */ } H5O_obj_class_t; /* Node in skip list to map addresses from one file to another during object header copy */ typedef struct H5O_addr_map_t { - H5_obj_t src_obj_pos; /* Location of source object */ - haddr_t dst_addr; /* Address of object in destination file */ - hbool_t is_locked; /* Indicate that the destination object is locked currently */ - hsize_t inc_ref_count; /* Number of deferred increments to reference count */ - const H5O_obj_class_t *obj_class; /* Object class */ - void *udata; /* Object class copy file udata */ + H5_obj_t src_obj_pos; /* Location of source object */ + haddr_t dst_addr; /* Address of object in destination file */ + hbool_t is_locked; /* Indicate that the destination object is locked currently */ + hsize_t inc_ref_count; /* Number of deferred increments to reference count */ + const H5O_obj_class_t *obj_class; /* Object class */ + void * udata; /* Object class copy file udata */ } H5O_addr_map_t; /* Stack of continuation messages to interpret */ typedef struct H5O_cont_msgs_t { - size_t nmsgs; /* Number of continuation messages found so far */ - size_t alloc_nmsgs; /* Continuation messages allocated */ - H5O_cont_t *msgs; /* Array of continuation messages */ + size_t nmsgs; /* Number of continuation messages found so far */ + size_t alloc_nmsgs; /* Continuation messages allocated */ + H5O_cont_t *msgs; /* Array of continuation messages */ } H5O_cont_msgs_t; /* Common callback information for loading object header prefix from disk */ typedef struct H5O_common_cache_ud_t { - H5F_t *f; /* Pointer to file for object header/chunk */ - unsigned file_intent; /* Read/write intent for file */ - unsigned merged_null_msgs; /* Number of null messages merged together */ - H5O_cont_msgs_t *cont_msg_info; /* Pointer to continuation messages to work on */ - haddr_t addr; /* Address of the prefix or chunk */ + H5F_t * f; /* Pointer to file for object header/chunk */ + unsigned file_intent; /* Read/write intent for file */ + unsigned merged_null_msgs; /* Number of null messages merged together */ + H5O_cont_msgs_t *cont_msg_info; /* Pointer to continuation messages to work on */ + haddr_t addr; /* Address of the prefix or chunk */ } H5O_common_cache_ud_t; /* Callback information for loading object header prefix from disk */ typedef struct H5O_cache_ud_t { - hbool_t made_attempt; /* Whether the deserialize routine was already attempted */ - unsigned v1_pfx_nmesgs; /* Number of messages from v1 prefix header */ - size_t chunk0_size; /* Size of serialized first chunk */ - H5O_t *oh; /* Partially deserialized object header, for later use */ - hbool_t free_oh; /* Whether to free the object header or not */ - H5O_common_cache_ud_t common; /* Common object header cache callback info */ + hbool_t made_attempt; /* Whether the deserialize routine was already attempted */ + unsigned v1_pfx_nmesgs; /* Number of messages from v1 prefix header */ + size_t chunk0_size; /* Size of serialized first chunk */ + H5O_t * oh; /* Partially deserialized object header, for later use */ + hbool_t free_oh; /* Whether to free the object header or not */ + H5O_common_cache_ud_t common; /* Common object header cache callback info */ } H5O_cache_ud_t; /* Structure representing each chunk in the cache */ typedef struct H5O_chunk_proxy_t { - H5AC_info_t cache_info; /* Information for metadata cache functions, _must_ be */ - /* first field in structure */ + H5AC_info_t cache_info; /* Information for metadata cache functions, _must_ be */ + /* first field in structure */ - H5F_t *f; /* Pointer to file for object header/chunk */ - H5O_t *oh; /* Object header for this chunk */ - unsigned chunkno; /* Chunk number for this chunk */ + H5F_t * f; /* Pointer to file for object header/chunk */ + H5O_t * oh; /* Object header for this chunk */ + unsigned chunkno; /* Chunk number for this chunk */ /* Flush depencency parent information (not stored) * @@ -402,16 +389,16 @@ typedef struct H5O_chunk_proxy_t { * parent of the chunk proxy will be either its object header * or the chunk with the continuation message that references this chunk. */ - void *fd_parent; /* Pointer to flush dependency parent */ + void *fd_parent; /* Pointer to flush dependency parent */ } H5O_chunk_proxy_t; /* Callback information for loading object header chunk from disk */ typedef struct H5O_chk_cache_ud_t { - hbool_t decoding; /* Whether the object header is being decoded */ - H5O_t *oh; /* Object header for this chunk */ - unsigned chunkno; /* Index of chunk being brought in (for re-loads) */ - size_t size; /* Size of chunk in the file */ - H5O_common_cache_ud_t common; /* Common object header cache callback info */ + hbool_t decoding; /* Whether the object header is being decoded */ + H5O_t * oh; /* Object header for this chunk */ + unsigned chunkno; /* Index of chunk being brought in (for re-loads) */ + size_t size; /* Size of chunk in the file */ + H5O_common_cache_ud_t common; /* Common object header cache callback info */ } H5O_chk_cache_ud_t; /* Header message ID to class mapping */ @@ -539,7 +526,6 @@ H5_DLLVAR const H5O_msg_class_t H5O_MSG_MDCI[1]; /* Placeholder for unknown message. (0x0019) */ H5_DLLVAR const H5O_msg_class_t H5O_MSG_UNKNOWN[1]; - /* * Object header "object" types */ @@ -555,72 +541,69 @@ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1]; /* Package-local function prototypes */ H5_DLL const H5O_obj_class_t *H5O__obj_class(const H5O_loc_t *loc); -H5_DLL int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted); -H5_DLL herr_t H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields); +H5_DLL int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted); +H5_DLL herr_t H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate2_t op, void *op_data, unsigned fields); H5_DLL herr_t H5O__inc_rc(H5O_t *oh); H5_DLL herr_t H5O__dec_rc(H5O_t *oh); H5_DLL herr_t H5O__free(H5O_t *oh); /* Object header message routines */ -H5_DLL herr_t H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned *mesg_flags, void *mesg, size_t *mesg_idx); -H5_DLL herr_t H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, void *mesg); -H5_DLL herr_t H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, void *mesg); -H5_DLL herr_t H5O__msg_free_mesg(H5O_mesg_t *mesg); +H5_DLL herr_t H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned *mesg_flags, + void *mesg, size_t *mesg_idx); +H5_DLL herr_t H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O__msg_free_mesg(H5O_mesg_t *mesg); H5_DLL unsigned H5O__msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type); -H5_DLL herr_t H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link); -H5_DLL void *H5O__msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, - void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, - unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); +H5_DLL herr_t H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, int sequence, + H5O_operator_t op, void *op_data, hbool_t adj_link); +H5_DLL void *H5O__msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, void *mesg_src, H5F_t *file_dst, + hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, + void *udata); H5_DLL herr_t H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - const H5O_mesg_operator_t *op, void *op_data); + const H5O_mesg_operator_t *op, void *op_data); H5_DLL herr_t H5O__flush_msgs(H5F_t *f, H5O_t *oh); H5_DLL herr_t H5O__delete_mesg(H5F_t *f, H5O_t *open_oh, H5O_mesg_t *mesg); /* Object header chunk routines */ H5_DLL herr_t H5O__chunk_add(H5F_t *f, H5O_t *oh, unsigned idx, unsigned cont_chunkno); H5_DLL H5O_chunk_proxy_t *H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx); -H5_DLL herr_t H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t chk_dirtied); -H5_DLL herr_t H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx); -H5_DLL herr_t H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy); -H5_DLL herr_t H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx); -H5_DLL herr_t H5O__chunk_dest(H5O_chunk_proxy_t *chunk_proxy); +H5_DLL herr_t H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t chk_dirtied); +H5_DLL herr_t H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx); +H5_DLL herr_t H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy); +H5_DLL herr_t H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx); +H5_DLL herr_t H5O__chunk_dest(H5O_chunk_proxy_t *chunk_proxy); /* Collect storage info for btree and heap */ H5_DLL herr_t H5O__attr_bh_info(H5F_t *f, H5O_t *oh, H5_ih_info_t *bh_info); /* Object header allocation routines */ H5_DLL herr_t H5O__alloc_msgs(H5O_t *oh, size_t min_alloc); -H5_DLL herr_t H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, - size_t found_null, const H5O_msg_alloc_info_t *found_msg, size_t *new_idx); -H5_DLL herr_t H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - const void *mesg, size_t *mesg_idx); +H5_DLL herr_t H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, + const H5O_msg_alloc_info_t *found_msg, size_t *new_idx); +H5_DLL herr_t H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, const void *mesg, + size_t *mesg_idx); H5_DLL herr_t H5O__condense_header(H5F_t *f, H5O_t *oh); -H5_DLL herr_t H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, - hbool_t adj_link); +H5_DLL herr_t H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link); /* Shared object operators */ -H5_DLL void * H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, - const uint8_t *buf, const H5O_msg_class_t *type); -H5_DLL herr_t H5O__shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg); +H5_DLL void * H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *buf, + const H5O_msg_class_t *type); +H5_DLL herr_t H5O__shared_encode(const H5F_t *f, uint8_t *buf /*out*/, const H5O_shared_t *sh_mesg); H5_DLL size_t H5O__shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg); -H5_DLL herr_t H5O__shared_delete(H5F_t *f, H5O_t *open_oh, - const H5O_msg_class_t *mesg_type, H5O_shared_t *sh_mesg); -H5_DLL herr_t H5O__shared_link(H5F_t *f, H5O_t *open_oh, - const H5O_msg_class_t *mesg_type, H5O_shared_t *sh_mesg); -H5_DLL herr_t H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, - const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst, - hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, - void *udata); -H5_DLL herr_t H5O__shared_post_copy_file (H5F_t *f, - const H5O_msg_class_t *mesg_type, const H5O_shared_t *shared_src, - H5O_shared_t *shared_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info); -H5_DLL herr_t H5O__shared_debug(const H5O_shared_t *mesg, FILE *stream, - int indent, int fwidth); +H5_DLL herr_t H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *mesg_type, + H5O_shared_t *sh_mesg); +H5_DLL herr_t H5O__shared_link(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *mesg_type, + H5O_shared_t *sh_mesg); +H5_DLL herr_t H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, const H5O_msg_class_t *mesg_type, + const void *_native_src, void *_native_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); +H5_DLL herr_t H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, + const H5O_shared_t *shared_src, H5O_shared_t *shared_dst, + unsigned *mesg_flags, H5O_copy_t *cpy_info); +H5_DLL herr_t H5O__shared_debug(const H5O_shared_t *mesg, FILE *stream, int indent, int fwidth); /* Attribute message operators */ H5_DLL herr_t H5O__attr_reset(void *_mesg); @@ -657,4 +640,3 @@ H5_DLL herr_t H5O__assert(const H5O_t *oh); H5_DLL herr_t H5O__debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth); #endif /* _H5Opkg_H */ - diff --git a/src/H5Opline.c b/src/H5Opline.c index a956725..6f792c2 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -18,90 +18,86 @@ * Purpose: Data filter pipeline message. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5Z_FRIEND /*suppress error about including H5Zpkg */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5Z_FRIEND /*suppress error about including H5Zpkg */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Zpkg.h" /* Data filters */ /* PRIVATE PROTOTYPES */ static herr_t H5O_pline_encode(H5F_t *f, uint8_t *p, const void *mesg); -static void *H5O__pline_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); -static void *H5O_pline_copy(const void *_mesg, void *_dest); +static void * H5O__pline_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); +static void * H5O_pline_copy(const void *_mesg, void *_dest); static size_t H5O_pline_size(const H5F_t *f, const void *_mesg); static herr_t H5O__pline_reset(void *_mesg); static herr_t H5O__pline_free(void *_mesg); -static herr_t H5O_pline_pre_copy_file(H5F_t *file_src, - const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata); -static herr_t H5O__pline_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O_pline_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *_udata); +static herr_t H5O__pline_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_PLINE -#define H5O_SHARED_DECODE H5O_pline_shared_decode -#define H5O_SHARED_DECODE_REAL H5O__pline_decode -#define H5O_SHARED_ENCODE H5O_pline_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_pline_encode -#define H5O_SHARED_SIZE H5O_pline_shared_size -#define H5O_SHARED_SIZE_REAL H5O_pline_size -#define H5O_SHARED_DELETE H5O__pline_shared_delete +#define H5O_SHARED_TYPE H5O_MSG_PLINE +#define H5O_SHARED_DECODE H5O_pline_shared_decode +#define H5O_SHARED_DECODE_REAL H5O__pline_decode +#define H5O_SHARED_ENCODE H5O_pline_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O_pline_encode +#define H5O_SHARED_SIZE H5O_pline_shared_size +#define H5O_SHARED_SIZE_REAL H5O_pline_size +#define H5O_SHARED_DELETE H5O__pline_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O__pline_shared_link +#define H5O_SHARED_LINK H5O__pline_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O__pline_shared_copy_file +#define H5O_SHARED_COPY_FILE H5O__pline_shared_copy_file #undef H5O_SHARED_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE H5O_pline_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O_pline_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#undef H5O_SHARED_POST_COPY_FILE_UPD -#define H5O_SHARED_DEBUG H5O_pline_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__pline_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#undef H5O_SHARED_POST_COPY_FILE_UPD +#define H5O_SHARED_DEBUG H5O_pline_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__pline_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_PLINE[1] = {{ - H5O_PLINE_ID, /* message id number */ - "filter pipeline", /* message name for debugging */ - sizeof(H5O_pline_t), /* native message size */ - H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */ - H5O_pline_shared_decode, /* decode message */ - H5O_pline_shared_encode, /* encode message */ - H5O_pline_copy, /* copy the native value */ - H5O_pline_shared_size, /* size of raw message */ - H5O__pline_reset, /* reset method */ - H5O__pline_free, /* free method */ - H5O__pline_shared_delete, /* file delete method */ - H5O__pline_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - H5O_pline_pre_copy_file, /* pre copy native value to file */ - H5O__pline_shared_copy_file, /* copy native value to file */ - H5O_pline_shared_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_pline_shared_debug /* debug the message */ + H5O_PLINE_ID, /* message id number */ + "filter pipeline", /* message name for debugging */ + sizeof(H5O_pline_t), /* native message size */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_pline_shared_decode, /* decode message */ + H5O_pline_shared_encode, /* encode message */ + H5O_pline_copy, /* copy the native value */ + H5O_pline_shared_size, /* size of raw message */ + H5O__pline_reset, /* reset method */ + H5O__pline_free, /* free method */ + H5O__pline_shared_delete, /* file delete method */ + H5O__pline_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + H5O_pline_pre_copy_file, /* pre copy native value to file */ + H5O__pline_shared_copy_file, /* copy native value to file */ + H5O_pline_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O_pline_shared_debug /* debug the message */ }}; /* Format version bounds for filter pipleline */ const unsigned H5O_pline_ver_bounds[] = { - H5O_PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_PLINE_VERSION_2, /* H5F_LIBVER_V18 */ - H5O_PLINE_VERSION_2, /* H5F_LIBVER_V110 */ - H5O_PLINE_VERSION_2, /* H5F_LIBVER_V112 */ - H5O_PLINE_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_PLINE_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_PLINE_VERSION_2, /* H5F_LIBVER_V110 */ + H5O_PLINE_VERSION_2, /* H5F_LIBVER_V112 */ + H5O_PLINE_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /* Declare a free list to manage the H5O_pline_t struct */ H5FL_DEFINE(H5O_pline_t); - /*------------------------------------------------------------------------- * Function: H5O__pline_decode * @@ -116,16 +112,15 @@ H5FL_DEFINE(H5O_pline_t); *------------------------------------------------------------------------- */ static void * -H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t p_size, const uint8_t *p) +H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_pline_t *pline = NULL; /* Pipeline message */ - H5Z_filter_info_t *filter; /* Filter to decode */ - size_t name_length; /* Length of filter name */ - size_t i; /* Local index variable */ - const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ - void *ret_value = NULL; /* Return value */ + H5O_pline_t * pline = NULL; /* Pipeline message */ + H5Z_filter_info_t *filter; /* Filter to decode */ + size_t name_length; /* Length of filter name */ + size_t i; /* Local index variable */ + const uint8_t * p_end = p + p_size - 1; /* End of the p buffer */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -133,17 +128,17 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Allocate space for I/O pipeline message */ - if(NULL == (pline = H5FL_CALLOC(H5O_pline_t))) + if (NULL == (pline = H5FL_CALLOC(H5O_pline_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Version */ pline->version = *p++; - if(pline->version < H5O_PLINE_VERSION_1 || pline->version > H5O_PLINE_VERSION_LATEST) + if (pline->version < H5O_PLINE_VERSION_1 || pline->version > H5O_PLINE_VERSION_LATEST) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "bad version number for filter pipeline message") /* Number of filters */ pline->nused = *p++; - if(pline->nused > H5Z_MAX_NFILTERS) { + if (pline->nused > H5Z_MAX_NFILTERS) { /* Reset the number of filters used to avoid array traversal in error * handling code. @@ -154,25 +149,25 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, } /* Reserved */ - if(pline->version == H5O_PLINE_VERSION_1) + if (pline->version == H5O_PLINE_VERSION_1) p += 6; /* Allocate array for filters */ pline->nalloc = pline->nused; - if(NULL == (pline->filter = (H5Z_filter_info_t *)H5MM_calloc(pline->nalloc * sizeof(pline->filter[0])))) + if (NULL == (pline->filter = (H5Z_filter_info_t *)H5MM_calloc(pline->nalloc * sizeof(pline->filter[0])))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Decode filters */ - for(i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { + for (i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { /* Filter ID */ UINT16DECODE(p, filter->id); /* Length of filter name */ - if(pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) + if (pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) name_length = 0; else { UINT16DECODE(p, name_length); - if(pline->version == H5O_PLINE_VERSION_1 && name_length % 8) + if (pline->version == H5O_PLINE_VERSION_1 && name_length % 8) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter name length is not a multiple of eight") } /* end if */ @@ -183,17 +178,17 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, UINT16DECODE(p, filter->cd_nelmts); /* Filter name, if there is one */ - if(name_length) { - size_t actual_name_length; /* Actual length of name */ + if (name_length) { + size_t actual_name_length; /* Actual length of name */ /* Determine actual name length (without padding, but with null terminator) */ actual_name_length = HDstrlen((const char *)p) + 1; HDassert(actual_name_length <= name_length); /* Allocate space for the filter name, or use the internal buffer */ - if(actual_name_length > H5Z_COMMON_NAME_LEN) { + if (actual_name_length > H5Z_COMMON_NAME_LEN) { filter->name = (char *)H5MM_malloc(actual_name_length); - if(NULL == filter->name) + if (NULL == filter->name) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for filter name") } /* end if */ else @@ -204,13 +199,13 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, } /* end if */ /* Filter parameters */ - if(filter->cd_nelmts) { - size_t j; /* Local index variable */ + if (filter->cd_nelmts) { + size_t j; /* Local index variable */ /* Allocate space for the client data elements, or use the internal buffer */ - if(filter->cd_nelmts > H5Z_COMMON_CD_VALUES) { + if (filter->cd_nelmts > H5Z_COMMON_CD_VALUES) { filter->cd_values = (unsigned *)H5MM_malloc(filter->cd_nelmts * sizeof(unsigned)); - if(NULL == filter->cd_values) + if (NULL == filter->cd_values) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for client data") } /* end if */ else @@ -223,20 +218,22 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, if (p + 4 - 1 <= p_end) UINT32DECODE(p, filter->cd_values[j]) else - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "ran off the end of the buffer: current p = %p, p_size = %zu, p_end = %p", p, p_size, p_end) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "ran off the end of the buffer: current p = %p, p_size = %zu, p_end = %p", p, + p_size, p_end) } - if(pline->version == H5O_PLINE_VERSION_1) - if(filter->cd_nelmts % 2) + if (pline->version == H5O_PLINE_VERSION_1) + if (filter->cd_nelmts % 2) p += 4; /*padding*/ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Set return value */ ret_value = pline; done: - if(NULL == ret_value && pline) { + if (NULL == ret_value && pline) { H5O__pline_reset(pline); H5O__pline_free(pline); } /* end if */ @@ -244,7 +241,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__pline_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_pline_encode * @@ -258,11 +254,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg) +H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p /*out*/, const void *mesg) { - const H5O_pline_t *pline = (const H5O_pline_t*)mesg; /* Pipeline message to encode */ - const H5Z_filter_info_t *filter; /* Filter to encode */ - size_t i, j; /* Local index variables */ + const H5O_pline_t * pline = (const H5O_pline_t *)mesg; /* Pipeline message to encode */ + const H5Z_filter_info_t *filter; /* Filter to encode */ + size_t i, j; /* Local index variables */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -273,37 +269,37 @@ H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg) /* Message header */ *p++ = (uint8_t)pline->version; *p++ = (uint8_t)(pline->nused); - if(pline->version == H5O_PLINE_VERSION_1) { - *p++ = 0; /*reserved 1*/ - *p++ = 0; /*reserved 2*/ - *p++ = 0; /*reserved 3*/ - *p++ = 0; /*reserved 4*/ - *p++ = 0; /*reserved 5*/ - *p++ = 0; /*reserved 6*/ - } /* end if */ + if (pline->version == H5O_PLINE_VERSION_1) { + *p++ = 0; /*reserved 1*/ + *p++ = 0; /*reserved 2*/ + *p++ = 0; /*reserved 3*/ + *p++ = 0; /*reserved 4*/ + *p++ = 0; /*reserved 5*/ + *p++ = 0; /*reserved 6*/ + } /* end if */ /* Encode filters */ - for(i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { - const char *name; /* Filter name */ - size_t name_length; /* Length of filter name */ + for (i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { + const char *name; /* Filter name */ + size_t name_length; /* Length of filter name */ /* Filter ID */ - UINT16ENCODE(p, filter->id); + UINT16ENCODE(p, filter->id); /* Skip writing the name length & name if the filter is an internal filter */ - if(pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) { + if (pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) { name_length = 0; - name = NULL; + name = NULL; } /* end if */ else { - H5Z_class2_t *cls; /* Filter class */ + H5Z_class2_t *cls; /* Filter class */ /* * Get the filter name. If the pipeline message has a name in it then * use that one. Otherwise try to look up the filter and get the name * as it was registered. */ - if(NULL == (name = filter->name) && (cls = H5Z_find(filter->id))) + if (NULL == (name = filter->name) && (cls = H5Z_find(filter->id))) name = cls->name; name_length = name ? HDstrlen(name) + 1 : 0; @@ -312,37 +308,36 @@ H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg) } /* end else */ /* Filter flags */ - UINT16ENCODE(p, filter->flags); + UINT16ENCODE(p, filter->flags); /* # of filter parameters */ - UINT16ENCODE(p, filter->cd_nelmts); + UINT16ENCODE(p, filter->cd_nelmts); /* Encode name, if there is one to encode */ - if(name_length > 0) { + if (name_length > 0) { /* Store name, with null terminator */ - H5MM_memcpy(p, name, name_length); - p += name_length; + H5MM_memcpy(p, name, name_length); + p += name_length; /* Pad out name to alignment, in older versions */ - if(pline->version == H5O_PLINE_VERSION_1) - while(name_length++ % 8) + if (pline->version == H5O_PLINE_VERSION_1) + while (name_length++ % 8) *p++ = 0; - } /* end if */ + } /* end if */ /* Filter parameters */ - for(j = 0; j < filter->cd_nelmts; j++) - UINT32ENCODE(p, filter->cd_values[j]); + for (j = 0; j < filter->cd_nelmts; j++) + UINT32ENCODE(p, filter->cd_values[j]); /* Align the parameters for older versions of the format */ - if(pline->version == H5O_PLINE_VERSION_1) - if(filter->cd_nelmts % 2) + if (pline->version == H5O_PLINE_VERSION_1) + if (filter->cd_nelmts % 2) UINT32ENCODE(p, 0); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_pline_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_pline_copy * @@ -360,82 +355,83 @@ H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg) *------------------------------------------------------------------------- */ static void * -H5O_pline_copy(const void *_src, void *_dst/*out*/) +H5O_pline_copy(const void *_src, void *_dst /*out*/) { - const H5O_pline_t *src = (const H5O_pline_t *)_src; /* Source pipeline message */ - H5O_pline_t *dst = (H5O_pline_t *)_dst; /* Destination pipeline message */ - size_t i; /* Local index variable */ - H5O_pline_t *ret_value = NULL; /* Return value */ + const H5O_pline_t *src = (const H5O_pline_t *)_src; /* Source pipeline message */ + H5O_pline_t * dst = (H5O_pline_t *)_dst; /* Destination pipeline message */ + size_t i; /* Local index variable */ + H5O_pline_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Allocate pipeline message, if not provided */ - if(!dst && NULL == (dst = H5FL_MALLOC(H5O_pline_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dst && NULL == (dst = H5FL_MALLOC(H5O_pline_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Shallow copy basic fields */ *dst = *src; /* Copy over filters, if any */ dst->nalloc = dst->nused; - if(dst->nalloc) { + if (dst->nalloc) { /* Allocate array to hold filters */ - if(NULL == (dst->filter = (H5Z_filter_info_t *)H5MM_calloc(dst->nalloc * sizeof(dst->filter[0])))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (dst->filter = (H5Z_filter_info_t *)H5MM_calloc(dst->nalloc * sizeof(dst->filter[0])))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Deep-copy filters */ - for(i = 0; i < src->nused; i++) { + for (i = 0; i < src->nused; i++) { /* Basic filter information */ dst->filter[i] = src->filter[i]; /* Filter name */ - if(src->filter[i].name) { - size_t namelen; /* Length of source filter name, including null terminator */ + if (src->filter[i].name) { + size_t namelen; /* Length of source filter name, including null terminator */ namelen = HDstrlen(src->filter[i].name) + 1; /* Allocate space for the filter name, or use the internal buffer */ - if(namelen > H5Z_COMMON_NAME_LEN) { + if (namelen > H5Z_COMMON_NAME_LEN) { dst->filter[i].name = (char *)H5MM_strdup(src->filter[i].name); - if(NULL == dst->filter[i].name) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for filter name") + if (NULL == dst->filter[i].name) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for filter name") } /* end if */ else dst->filter[i].name = dst->filter[i]._name; } /* end if */ /* Filter parameters */ - if(src->filter[i].cd_nelmts > 0) { + if (src->filter[i].cd_nelmts > 0) { /* Allocate space for the client data elements, or use the internal buffer */ - if(src->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES) { - if(NULL == (dst->filter[i].cd_values = (unsigned *)H5MM_malloc(src->filter[i].cd_nelmts* sizeof(unsigned)))) + if (src->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES) { + if (NULL == (dst->filter[i].cd_values = + (unsigned *)H5MM_malloc(src->filter[i].cd_nelmts * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(dst->filter[i].cd_values, src->filter[i].cd_values, - src->filter[i].cd_nelmts * sizeof(unsigned)); + src->filter[i].cd_nelmts * sizeof(unsigned)); } /* end if */ else dst->filter[i].cd_values = dst->filter[i]._cd_values; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else - dst->filter = NULL; + dst->filter = NULL; /* Set return value */ ret_value = dst; done: - if(!ret_value && dst) { + if (!ret_value && dst) { H5O__pline_reset(dst); - if(!_dst) + if (!_dst) H5O__pline_free(dst); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_pline_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_pline_size * @@ -453,50 +449,53 @@ done: static size_t H5O_pline_size(const H5F_t H5_ATTR_UNUSED *f, const void *mesg) { - const H5O_pline_t *pline = (const H5O_pline_t*)mesg; /* Pipeline message */ - size_t i; /* Local index variable */ - size_t ret_value = 0; /* Return value */ + const H5O_pline_t *pline = (const H5O_pline_t *)mesg; /* Pipeline message */ + size_t i; /* Local index variable */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Message header */ - ret_value = (size_t)(1 + /*version */ - 1 + /*number of filters */ - (pline->version == H5O_PLINE_VERSION_1 ? 6 : 0)); /*reserved */ + ret_value = (size_t)(1 + /*version */ + 1 + /*number of filters */ + (pline->version == H5O_PLINE_VERSION_1 ? 6 : 0)); /*reserved */ /* Calculate size of each filter in pipeline */ - for(i = 0; i < pline->nused; i++) { - size_t name_len; /* Length of filter name */ - const char *name; /* Filter name */ + for (i = 0; i < pline->nused; i++) { + size_t name_len; /* Length of filter name */ + const char *name; /* Filter name */ /* Don't write the name length & name if the filter is an internal filter */ - if(pline->version > H5O_PLINE_VERSION_1 && pline->filter[i].id < H5Z_FILTER_RESERVED) + if (pline->version > H5O_PLINE_VERSION_1 && pline->filter[i].id < H5Z_FILTER_RESERVED) name_len = 0; else { - H5Z_class2_t *cls; /* Filter class */ + H5Z_class2_t *cls; /* Filter class */ /* Get the name of the filter, same as done with H5O_pline_encode() */ - if(NULL == (name = pline->filter[i].name) && (cls = H5Z_find(pline->filter[i].id))) + if (NULL == (name = pline->filter[i].name) && (cls = H5Z_find(pline->filter[i].id))) name = cls->name; name_len = name ? HDstrlen(name) + 1 : 0; } /* end else */ - ret_value += 2 + /*filter identification number */ - (size_t)((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */ - 2 + /*flags */ - 2 + /*number of client data values */ - (pline->version == H5O_PLINE_VERSION_1 ? (size_t)H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ - - ret_value += pline->filter[i].cd_nelmts * 4; - if(pline->version == H5O_PLINE_VERSION_1) - if(pline->filter[i].cd_nelmts % 2) + ret_value += + 2 + /*filter identification number */ + (size_t)((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) + ? 2 + : 0) + /*name length */ + 2 + /*flags */ + 2 + /*number of client data values */ + (pline->version == H5O_PLINE_VERSION_1 ? (size_t)H5O_ALIGN_OLD(name_len) + : name_len); /*length of the filter name */ + + ret_value += pline->filter[i].cd_nelmts * 4; + if (pline->version == H5O_PLINE_VERSION_1) + if (pline->filter[i].cd_nelmts % 2) ret_value += 4; } /* end for */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_pline_size() */ - /*------------------------------------------------------------------------- * Function: H5O__pline_reset * @@ -513,8 +512,8 @@ H5O_pline_size(const H5F_t H5_ATTR_UNUSED *f, const void *mesg) static herr_t H5O__pline_reset(void *mesg) { - H5O_pline_t *pline = (H5O_pline_t*)mesg; /* Pipeline message */ - size_t i; /* Local index variable */ + H5O_pline_t *pline = (H5O_pline_t *)mesg; /* Pipeline message */ + size_t i; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -528,14 +527,14 @@ H5O__pline_reset(void *mesg) if (pline->filter) { /* Free information for each filter */ - for(i = 0; i < pline->nused; i++) { - if(pline->filter[i].name && pline->filter[i].name != pline->filter[i]._name) + for (i = 0; i < pline->nused; i++) { + if (pline->filter[i].name && pline->filter[i].name != pline->filter[i]._name) HDassert((HDstrlen(pline->filter[i].name) + 1) > H5Z_COMMON_NAME_LEN); - if(pline->filter[i].name != pline->filter[i]._name) + if (pline->filter[i].name != pline->filter[i]._name) pline->filter[i].name = (char *)H5MM_xfree(pline->filter[i].name); - if(pline->filter[i].cd_values && pline->filter[i].cd_values != pline->filter[i]._cd_values) + if (pline->filter[i].cd_values && pline->filter[i].cd_values != pline->filter[i]._cd_values) HDassert(pline->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES); - if(pline->filter[i].cd_values != pline->filter[i]._cd_values) + if (pline->filter[i].cd_values != pline->filter[i]._cd_values) pline->filter[i].cd_values = (unsigned *)H5MM_xfree(pline->filter[i].cd_values); } /* end for */ @@ -552,7 +551,6 @@ H5O__pline_reset(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__pline_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__pline_free * @@ -577,7 +575,6 @@ H5O__pline_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__pline_free() */ - /*------------------------------------------------------------------------- * Function: H5O_pline_pre_copy_file * @@ -594,12 +591,12 @@ H5O__pline_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_pline_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, - hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void *_udata) +H5O_pline_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, hbool_t H5_ATTR_UNUSED *deleted, + const H5O_copy_t *cpy_info, void *_udata) { - const H5O_pline_t *pline_src = (const H5O_pline_t *)mesg_src; /* Source pline */ - H5O_copy_file_ud_common_t *udata = (H5O_copy_file_ud_common_t *)_udata; /* Object copying user data */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_pline_t * pline_src = (const H5O_pline_t *)mesg_src; /* Source pline */ + H5O_copy_file_ud_common_t *udata = (H5O_copy_file_ud_common_t *)_udata; /* Object copying user data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -610,22 +607,21 @@ H5O_pline_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version allowed by the destination file's high bound */ - if(pline_src->version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (pline_src->version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "pline message version out of bounds") /* If the user data is non-NULL, assume we are copying a dataset or group * and make a copy of the filter pipeline for later in * the object copying process. */ - if(udata) - if(NULL == (udata->src_pline = (H5O_pline_t *)H5O_pline_copy(pline_src, NULL))) + if (udata) + if (NULL == (udata->src_pline = (H5O_pline_t *)H5O_pline_copy(pline_src, NULL))) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to copy") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_pline_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__pline_debug * @@ -641,11 +637,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, - int indent, int fwidth) +H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int indent, int fwidth) { - const H5O_pline_t *pline = (const H5O_pline_t *)mesg; - size_t i, j; + const H5O_pline_t *pline = (const H5O_pline_t *)mesg; + size_t i, j; FUNC_ENTER_STATIC_NOERR @@ -656,49 +651,40 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %Zu/%Zu\n", indent, "", fwidth, - "Number of filters:", - pline->nused, - pline->nalloc); + HDfprintf(stream, "%*s%-*s %Zu/%Zu\n", indent, "", fwidth, "Number of filters:", pline->nused, + pline->nalloc); /* Loop over all the filters */ - for(i = 0; i < pline->nused; i++) { - char name[32]; - - HDsnprintf(name, sizeof(name), "Filter at position %u", (unsigned)i); - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, name); - HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3), - "Filter identification:", - (unsigned)(pline->filter[i].id)); - if(pline->filter[i].name) - HDfprintf(stream, "%*s%-*s \"%s\"\n", indent + 3, "", MAX(0, fwidth - 3), - "Filter name:", - pline->filter[i].name); - else - HDfprintf(stream, "%*s%-*s NONE\n", indent + 3, "", MAX(0, fwidth - 3), - "Filter name:"); - HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3), - "Flags:", - pline->filter[i].flags); - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Num CD values:", - pline->filter[i].cd_nelmts); + for (i = 0; i < pline->nused; i++) { + char name[32]; + + HDsnprintf(name, sizeof(name), "Filter at position %u", (unsigned)i); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, name); + HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3), + "Filter identification:", (unsigned)(pline->filter[i].id)); + if (pline->filter[i].name) + HDfprintf(stream, "%*s%-*s \"%s\"\n", indent + 3, "", MAX(0, fwidth - 3), + "Filter name:", pline->filter[i].name); + else + HDfprintf(stream, "%*s%-*s NONE\n", indent + 3, "", MAX(0, fwidth - 3), "Filter name:"); + HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3), + "Flags:", pline->filter[i].flags); + HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), + "Num CD values:", pline->filter[i].cd_nelmts); /* Filter parameters */ - for(j = 0; j < pline->filter[i].cd_nelmts; j++) { - char field_name[32]; + for (j = 0; j < pline->filter[i].cd_nelmts; j++) { + char field_name[32]; - HDsnprintf(field_name, sizeof(field_name), "CD value %lu", (unsigned long)j); - HDfprintf(stream, "%*s%-*s %u\n", indent + 6, "", MAX(0, fwidth - 6), - field_name, - pline->filter[i].cd_values[j]); - } /* end for */ - } /* end for */ + HDsnprintf(field_name, sizeof(field_name), "CD value %lu", (unsigned long)j); + HDfprintf(stream, "%*s%-*s %u\n", indent + 6, "", MAX(0, fwidth - 6), field_name, + pline->filter[i].cd_values[j]); + } /* end for */ + } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__pline_debug() */ - /*------------------------------------------------------------------------- * Function: H5O_pline_set_version * @@ -713,8 +699,8 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, herr_t H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -726,7 +712,7 @@ H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline) version = MAX(pline->version, H5O_pline_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_PLINE, H5E_BADRANGE, FAIL, "Filter pipeline version out of bounds") /* Set the message version */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 9a1c1ed..f22e0a0 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -25,30 +25,30 @@ #define _H5Oprivate_H /* Early typedefs to avoid circular dependencies */ -typedef struct H5O_t H5O_t; +typedef struct H5O_t H5O_t; typedef struct H5O_fill_t H5O_fill_t; /* Include the public header file for this API */ -#include "H5Opublic.h" /* Object header functions */ +#include "H5Opublic.h" /* Object header functions */ /* Public headers needed by this file */ -#include "H5Dpublic.h" /* Dataset functions */ -#include "H5Lpublic.h" /* Link functions */ -#include "H5Spublic.h" /* Dataspace functions */ +#include "H5Dpublic.h" /* Dataset functions */ +#include "H5Lpublic.h" /* Link functions */ +#include "H5Spublic.h" /* Dataspace functions */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5SLprivate.h" /* Skip lists */ -#include "H5Tprivate.h" /* Datatype functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatype functions */ #include "H5VLprivate.h" -#include "H5Zprivate.h" /* I/O pipeline filters */ +#include "H5Zprivate.h" /* I/O pipeline filters */ /* Forward references of package typedefs */ typedef struct H5O_msg_class_t H5O_msg_class_t; -typedef struct H5O_mesg_t H5O_mesg_t; +typedef struct H5O_mesg_t H5O_mesg_t; /* Values used to create the shared message & attribute heaps */ /* (Note that these parameters have been tuned so that the resulting heap ID @@ -56,35 +56,38 @@ typedef struct H5O_mesg_t H5O_mesg_t; * directly in an 8 byte integer in memory, think carefully before changing it. * -QAK) */ -#define H5O_FHEAP_MAN_WIDTH 4 -#define H5O_FHEAP_MAN_START_BLOCK_SIZE 1024 -#define H5O_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024) -#define H5O_FHEAP_MAN_MAX_INDEX 40 -#define H5O_FHEAP_MAN_START_ROOT_ROWS 1 -#define H5O_FHEAP_CHECKSUM_DBLOCKS TRUE -#define H5O_FHEAP_MAX_MAN_SIZE (4 * 1024) -#define H5O_FHEAP_ID_LEN 8 +#define H5O_FHEAP_MAN_WIDTH 4 +#define H5O_FHEAP_MAN_START_BLOCK_SIZE 1024 +#define H5O_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024) +#define H5O_FHEAP_MAN_MAX_INDEX 40 +#define H5O_FHEAP_MAN_START_ROOT_ROWS 1 +#define H5O_FHEAP_CHECKSUM_DBLOCKS TRUE +#define H5O_FHEAP_MAX_MAN_SIZE (4 * 1024) +#define H5O_FHEAP_ID_LEN 8 /* Object header macros */ -#define H5O_MESG_MAX_SIZE 65536 /*max obj header message size */ -#define H5O_ALL (-1) /* Operate on all messages of type */ -#define H5O_FIRST (-2) /* Operate on first message of type */ +#define H5O_MESG_MAX_SIZE 65536 /*max obj header message size */ +#define H5O_ALL (-1) /* Operate on all messages of type */ +#define H5O_FIRST (-2) /* Operate on first message of type */ /* Flags needed when encoding messages */ -#define H5O_MSG_NO_FLAGS_SET 0x00u -#define H5O_MSG_FLAG_CONSTANT 0x01u -#define H5O_MSG_FLAG_SHARED 0x02u -#define H5O_MSG_FLAG_DONTSHARE 0x04u +#define H5O_MSG_NO_FLAGS_SET 0x00u +#define H5O_MSG_FLAG_CONSTANT 0x01u +#define H5O_MSG_FLAG_SHARED 0x02u +#define H5O_MSG_FLAG_DONTSHARE 0x04u #define H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE 0x08u -#define H5O_MSG_FLAG_MARK_IF_UNKNOWN 0x10u -#define H5O_MSG_FLAG_WAS_UNKNOWN 0x20u -#define H5O_MSG_FLAG_SHAREABLE 0x40u -#define H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS 0x80u -#define H5O_MSG_FLAG_BITS (H5O_MSG_FLAG_CONSTANT|H5O_MSG_FLAG_SHARED|H5O_MSG_FLAG_DONTSHARE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE|H5O_MSG_FLAG_MARK_IF_UNKNOWN|H5O_MSG_FLAG_WAS_UNKNOWN|H5O_MSG_FLAG_SHAREABLE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) +#define H5O_MSG_FLAG_MARK_IF_UNKNOWN 0x10u +#define H5O_MSG_FLAG_WAS_UNKNOWN 0x20u +#define H5O_MSG_FLAG_SHAREABLE 0x40u +#define H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS 0x80u +#define H5O_MSG_FLAG_BITS \ + (H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_SHARED | H5O_MSG_FLAG_DONTSHARE | \ + H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE | H5O_MSG_FLAG_MARK_IF_UNKNOWN | \ + H5O_MSG_FLAG_WAS_UNKNOWN | H5O_MSG_FLAG_SHAREABLE | H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) /* Flags for updating messages */ -#define H5O_UPDATE_TIME 0x01u -#define H5O_UPDATE_FORCE 0x02u /* Force updating the message */ +#define H5O_UPDATE_TIME 0x01u +#define H5O_UPDATE_FORCE 0x02u /* Force updating the message */ /* Hash value constants */ #define H5O_HASH_SIZE 32 @@ -93,30 +96,36 @@ typedef struct H5O_mesg_t H5O_mesg_t; /* #define H5O_ENABLE_BOGUS */ /* ========= Object Creation properties ============ */ -#define H5O_CRT_ATTR_MAX_COMPACT_NAME "max compact attr" /* Max. # of attributes to store compactly */ -#define H5O_CRT_ATTR_MIN_DENSE_NAME "min dense attr" /* Min. # of attributes to store densely */ -#define H5O_CRT_OHDR_FLAGS_NAME "object header flags" /* Object header flags */ -#define H5O_CRT_PIPELINE_NAME "pline" /* Filter pipeline */ -#define H5O_CRT_PIPELINE_DEF {{0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_PLINE_VERSION_1, 0, 0, NULL} +#define H5O_CRT_ATTR_MAX_COMPACT_NAME "max compact attr" /* Max. # of attributes to store compactly */ +#define H5O_CRT_ATTR_MIN_DENSE_NAME "min dense attr" /* Min. # of attributes to store densely */ +#define H5O_CRT_OHDR_FLAGS_NAME "object header flags" /* Object header flags */ +#define H5O_CRT_PIPELINE_NAME "pline" /* Filter pipeline */ +#define H5O_CRT_PIPELINE_DEF \ + { \ + {0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_PLINE_VERSION_1, 0, 0, NULL \ + } #ifdef H5O_ENABLE_BOGUS -#define H5O_BOGUS_MSG_FLAGS_NAME "bogus msg flags" /* Flags for 'bogus' message */ -#define H5O_BOGUS_MSG_FLAGS_SIZE sizeof(uint8_t) +#define H5O_BOGUS_MSG_FLAGS_NAME "bogus msg flags" /* Flags for 'bogus' message */ +#define H5O_BOGUS_MSG_FLAGS_SIZE sizeof(uint8_t) /* bogus ID can be either (a) H5O_BOGUS_VALID_ID or (b) H5O_BOGUS_INVALID_ID */ -#define H5O_BOGUS_MSG_ID_NAME "bogus msg id" /* ID for 'bogus' message */ -#define H5O_BOGUS_MSG_ID_SIZE sizeof(unsigned) +#define H5O_BOGUS_MSG_ID_NAME "bogus msg id" /* ID for 'bogus' message */ +#define H5O_BOGUS_MSG_ID_SIZE sizeof(unsigned) #endif /* H5O_ENABLE_BOGUS */ #ifdef H5O_ENABLE_BAD_MESG_COUNT -#define H5O_BAD_MESG_COUNT_NAME "bad message count" /* Flag setting bad message count */ -#define H5O_BAD_MESG_COUNT_SIZE sizeof(hbool_t) +#define H5O_BAD_MESG_COUNT_NAME "bad message count" /* Flag setting bad message count */ +#define H5O_BAD_MESG_COUNT_SIZE sizeof(hbool_t) #endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* ========= Object Copy properties ============ */ -#define H5O_CPY_OPTION_NAME "copy object" /* Copy options */ -#define H5O_CPY_MERGE_COMM_DT_LIST_NAME "merge committed dtype list" /* List of datatype paths to search in the dest file for merging */ -#define H5O_CPY_MCDT_SEARCH_CB_NAME "committed dtype list search" /* Callback function when the search for a matching committed datatype is complete */ +#define H5O_CPY_OPTION_NAME "copy object" /* Copy options */ +#define H5O_CPY_MERGE_COMM_DT_LIST_NAME \ + "merge committed dtype list" /* List of datatype paths to search in the dest file for merging */ +#define H5O_CPY_MCDT_SEARCH_CB_NAME \ + "committed dtype list search" /* Callback function when the search for a matching committed datatype is \ + complete */ /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5O_MODULE @@ -132,97 +141,98 @@ typedef struct H5O_mesg_t H5O_mesg_t; #endif /* H5O_MODULE */ /* Set the fields in a shared message structure */ -#define H5O_UPDATE_SHARED(SH_MESG, SH_TYPE, F, MSG_TYPE, CRT_IDX, OH_ADDR) \ - { \ - (SH_MESG)->type = (SH_TYPE); \ - (SH_MESG)->file = (F); \ - (SH_MESG)->msg_type_id = (MSG_TYPE); \ - (SH_MESG)->u.loc.index = (CRT_IDX); \ - (SH_MESG)->u.loc.oh_addr = (OH_ADDR); \ +#define H5O_UPDATE_SHARED(SH_MESG, SH_TYPE, F, MSG_TYPE, CRT_IDX, OH_ADDR) \ + { \ + (SH_MESG)->type = (SH_TYPE); \ + (SH_MESG)->file = (F); \ + (SH_MESG)->msg_type_id = (MSG_TYPE); \ + (SH_MESG)->u.loc.index = (CRT_IDX); \ + (SH_MESG)->u.loc.oh_addr = (OH_ADDR); \ } /* end block */ - /* Fractal heap ID type for shared message & attribute heap IDs. */ typedef union { - uint8_t id[H5O_FHEAP_ID_LEN]; /* Buffer to hold ID, for encoding/decoding */ - uint64_t val; /* Value, for quick comparisons */ + uint8_t id[H5O_FHEAP_ID_LEN]; /* Buffer to hold ID, for encoding/decoding */ + uint64_t val; /* Value, for quick comparisons */ } H5O_fheap_id_t; /* The object location information for an object */ typedef struct H5O_loc_t { - H5F_t *file; /* File that object header is located within */ - haddr_t addr; /* File address of object header */ - hbool_t holding_file; /* True if this object header has incremented - * its file's count of open objects. */ + H5F_t * file; /* File that object header is located within */ + haddr_t addr; /* File address of object header */ + hbool_t holding_file; /* True if this object header has incremented + * its file's count of open objects. */ } H5O_loc_t; /* Typedef for linked list of datatype merge suggestions */ typedef struct H5O_copy_dtype_merge_list_t { - char *path; /* Path to datatype in destination file */ + char * path; /* Path to datatype in destination file */ struct H5O_copy_dtype_merge_list_t *next; /* Next object in list */ } H5O_copy_dtype_merge_list_t; /* Structure for callback property before searching the global list of committed datatypes at destination */ typedef struct H5O_mcdt_cb_info_t { - H5O_mcdt_search_cb_t func; - void *user_data; + H5O_mcdt_search_cb_t func; + void * user_data; } H5O_mcdt_cb_info_t; /* Settings/flags for copying an object */ typedef struct H5O_copy_t { - hbool_t copy_shallow; /* Flag to perform shallow hierarchy copy */ - hbool_t expand_soft_link; /* Flag to expand soft links */ - hbool_t expand_ext_link; /* Flag to expand external links */ - hbool_t expand_ref; /* Flag to expand object references */ - hbool_t copy_without_attr; /* Flag to not copy attributes */ - hbool_t preserve_null; /* Flag to not delete NULL messages */ - hbool_t merge_comm_dt; /* Flag to merge committed datatypes in dest file */ + hbool_t copy_shallow; /* Flag to perform shallow hierarchy copy */ + hbool_t expand_soft_link; /* Flag to expand soft links */ + hbool_t expand_ext_link; /* Flag to expand external links */ + hbool_t expand_ref; /* Flag to expand object references */ + hbool_t copy_without_attr; /* Flag to not copy attributes */ + hbool_t preserve_null; /* Flag to not delete NULL messages */ + hbool_t merge_comm_dt; /* Flag to merge committed datatypes in dest file */ H5O_copy_dtype_merge_list_t *dst_dt_suggestion_list; /* Suggestions for merging committed datatypes */ - int curr_depth; /* Current depth in hierarchy copied */ - int max_depth; /* Maximum depth in hierarchy to copy */ - H5SL_t *map_list; /* Skip list to hold address mappings */ - H5SL_t *dst_dt_list; /* Skip list to hold committed datatypes in dest file */ - hbool_t dst_dt_list_complete; /* Whether the destination datatype list is complete (i.e. not only populated with "suggestions" from H5Padd_merge_committed_dtype_path) */ - H5O_t *oh_dst; /* The destination object header */ - H5F_t *file_dst; /* The destination file pointer */ - /* This is used in the pre_copy_file callback to obtain - the destination file's high bound. The high bound - is used to index into the corresponding message's - array of versions for doing version bounds check. */ - void *shared_fo; /* The shared pointer for the src object */ - H5O_mcdt_search_cb_t mcdt_cb; /* The callback to invoke before searching the global list of committed datatypes at destination */ - void *mcdt_ud; /* User data passed to callback */ - hid_t lcpl_id; /* LCPL for callbacks' use */ + int curr_depth; /* Current depth in hierarchy copied */ + int max_depth; /* Maximum depth in hierarchy to copy */ + H5SL_t * map_list; /* Skip list to hold address mappings */ + H5SL_t * dst_dt_list; /* Skip list to hold committed datatypes in dest file */ + hbool_t dst_dt_list_complete; /* Whether the destination datatype list is complete (i.e. not only + populated with "suggestions" from H5Padd_merge_committed_dtype_path) */ + H5O_t *oh_dst; /* The destination object header */ + H5F_t *file_dst; /* The destination file pointer */ + /* This is used in the pre_copy_file callback to obtain + the destination file's high bound. The high bound + is used to index into the corresponding message's + array of versions for doing version bounds check. */ + void * shared_fo; /* The shared pointer for the src object */ + H5O_mcdt_search_cb_t mcdt_cb; /* The callback to invoke before searching the global list of committed + datatypes at destination */ + void *mcdt_ud; /* User data passed to callback */ + hid_t lcpl_id; /* LCPL for callbacks' use */ } H5O_copy_t; /* Header message IDs */ -#define H5O_NULL_ID 0x0000 /* Null Message. */ -#define H5O_SDSPACE_ID 0x0001 /* Dataspace Message. */ -#define H5O_LINFO_ID 0x0002 /* Link info Message. */ -#define H5O_DTYPE_ID 0x0003 /* Datatype Message. */ -#define H5O_FILL_ID 0x0004 /* Fill Value Message. (Old) */ -#define H5O_FILL_NEW_ID 0x0005 /* Fill Value Message. (New) */ -#define H5O_LINK_ID 0x0006 /* Link Message. */ -#define H5O_EFL_ID 0x0007 /* External File List Message */ -#define H5O_LAYOUT_ID 0x0008 /* Data Layout Message. */ -#define H5O_BOGUS_VALID_ID 0x0009 /* "Bogus valid" Message. */ -#define H5O_GINFO_ID 0x000a /* Group info Message. */ -#define H5O_PLINE_ID 0x000b /* Filter pipeline message. */ -#define H5O_ATTR_ID 0x000c /* Attribute Message. */ -#define H5O_NAME_ID 0x000d /* Object name message. */ -#define H5O_MTIME_ID 0x000e /* Modification time message. (Old) */ -#define H5O_SHMESG_ID 0x000f /* Shared message "SOHM" table. */ -#define H5O_CONT_ID 0x0010 /* Object header continuation message. */ -#define H5O_STAB_ID 0x0011 /* Symbol table message. */ -#define H5O_MTIME_NEW_ID 0x0012 /* Modification time message. (New) */ -#define H5O_BTREEK_ID 0x0013 /* v1 B-tree 'K' values message. */ -#define H5O_DRVINFO_ID 0x0014 /* Driver info message. */ -#define H5O_AINFO_ID 0x0015 /* Attribute info message. */ -#define H5O_REFCOUNT_ID 0x0016 /* Reference count message. */ -#define H5O_FSINFO_ID 0x0017 /* File space info message. */ -#define H5O_MDCI_MSG_ID 0x0018 /* Metadata Cache Image Message */ -#define H5O_UNKNOWN_ID 0x0019 /* Placeholder message ID for unknown message. */ - /* (this should never exist in a file) */ +#define H5O_NULL_ID 0x0000 /* Null Message. */ +#define H5O_SDSPACE_ID 0x0001 /* Dataspace Message. */ +#define H5O_LINFO_ID 0x0002 /* Link info Message. */ +#define H5O_DTYPE_ID 0x0003 /* Datatype Message. */ +#define H5O_FILL_ID 0x0004 /* Fill Value Message. (Old) */ +#define H5O_FILL_NEW_ID 0x0005 /* Fill Value Message. (New) */ +#define H5O_LINK_ID 0x0006 /* Link Message. */ +#define H5O_EFL_ID 0x0007 /* External File List Message */ +#define H5O_LAYOUT_ID 0x0008 /* Data Layout Message. */ +#define H5O_BOGUS_VALID_ID 0x0009 /* "Bogus valid" Message. */ +#define H5O_GINFO_ID 0x000a /* Group info Message. */ +#define H5O_PLINE_ID 0x000b /* Filter pipeline message. */ +#define H5O_ATTR_ID 0x000c /* Attribute Message. */ +#define H5O_NAME_ID 0x000d /* Object name message. */ +#define H5O_MTIME_ID 0x000e /* Modification time message. (Old) */ +#define H5O_SHMESG_ID 0x000f /* Shared message "SOHM" table. */ +#define H5O_CONT_ID 0x0010 /* Object header continuation message. */ +#define H5O_STAB_ID 0x0011 /* Symbol table message. */ +#define H5O_MTIME_NEW_ID 0x0012 /* Modification time message. (New) */ +#define H5O_BTREEK_ID 0x0013 /* v1 B-tree 'K' values message. */ +#define H5O_DRVINFO_ID 0x0014 /* Driver info message. */ +#define H5O_AINFO_ID 0x0015 /* Attribute info message. */ +#define H5O_REFCOUNT_ID 0x0016 /* Reference count message. */ +#define H5O_FSINFO_ID 0x0017 /* File space info message. */ +#define H5O_MDCI_MSG_ID 0x0018 /* Metadata Cache Image Message */ +#define H5O_UNKNOWN_ID 0x0019 /* Placeholder message ID for unknown message. */ + /* (this should never exist in a file) */ /* * Note: Must increment H5O_MSG_TYPES in H5Opkg.h and update H5O_msg_class_g * in H5O.c when creating a new message type. Also bump the value of @@ -231,34 +241,33 @@ typedef struct H5O_copy_t { * * (this should never exist in a file) */ -#define H5O_BOGUS_INVALID_ID 0x001a /* "Bogus invalid" Message. */ +#define H5O_BOGUS_INVALID_ID 0x001a /* "Bogus invalid" Message. */ /* Shared object message types. * Shared objects can be committed, in which case the shared message contains * the location of the object header that holds the message, or shared in the * heap, in which case the shared message holds their heap ID. */ -#define H5O_SHARE_TYPE_UNSHARED 0 /* Message is not shared */ -#define H5O_SHARE_TYPE_SOHM 1 /* Message is stored in SOHM heap */ -#define H5O_SHARE_TYPE_COMMITTED 2 /* Message is stored in another object header */ -#define H5O_SHARE_TYPE_HERE 3 /* Message is stored in this object header, but is sharable */ +#define H5O_SHARE_TYPE_UNSHARED 0 /* Message is not shared */ +#define H5O_SHARE_TYPE_SOHM 1 /* Message is stored in SOHM heap */ +#define H5O_SHARE_TYPE_COMMITTED 2 /* Message is stored in another object header */ +#define H5O_SHARE_TYPE_HERE 3 /* Message is stored in this object header, but is sharable */ /* Detect messages that aren't stored in message's object header */ -#define H5O_IS_STORED_SHARED(T) ((((T) == H5O_SHARE_TYPE_SOHM) || ((T) == H5O_SHARE_TYPE_COMMITTED)) ? TRUE : FALSE) +#define H5O_IS_STORED_SHARED(T) \ + ((((T) == H5O_SHARE_TYPE_SOHM) || ((T) == H5O_SHARE_TYPE_COMMITTED)) ? TRUE : FALSE) /* Detect shared messages that are "tracked" in some other location */ #define H5O_IS_TRACKED_SHARED(T) ((T) > 0) - /* Specify the object header address and index needed * to locate a message in another object header. */ typedef struct H5O_mesg_loc_t { - H5O_msg_crt_idx_t index; /* index within object header */ - haddr_t oh_addr; /* address of object header */ + H5O_msg_crt_idx_t index; /* index within object header */ + haddr_t oh_addr; /* address of object header */ } H5O_mesg_loc_t; - /* * Shared object header message info. * @@ -266,12 +275,12 @@ typedef struct H5O_mesg_loc_t { * include a H5O_shared_t struct as the first field in their "native" type) */ typedef struct H5O_shared_t { - unsigned type; /* Type describing how message is shared */ - H5F_t *file; /* File that message is located within */ - unsigned msg_type_id; /* Message's type ID */ + unsigned type; /* Type describing how message is shared */ + H5F_t * file; /* File that message is located within */ + unsigned msg_type_id; /* Message's type ID */ union { - H5O_mesg_loc_t loc; /* Object location info */ - H5O_fheap_id_t heap_id; /* ID within the SOHM heap */ + H5O_mesg_loc_t loc; /* Object location info */ + H5O_fheap_id_t heap_id; /* ID within the SOHM heap */ } u; } H5O_shared_t; @@ -280,8 +289,8 @@ typedef struct H5O_shared_t { * H5O_refresh_metadata(). */ typedef union _H5O_refresh_state { - hid_t dapl_id; // dataset refresh: access plist - H5O_shared_t shared_ohdr_info; // datatype refresh + hid_t dapl_id; // dataset refresh: access plist + H5O_shared_t shared_ohdr_info; // datatype refresh } H5O_refresh_state_t; /* @@ -298,24 +307,24 @@ typedef union _H5O_refresh_state { */ typedef struct H5O_linfo_t { /* Creation order info */ - hbool_t track_corder; /* Are creation order values tracked on links? */ - hbool_t index_corder; /* Are creation order values indexed on links? */ - int64_t max_corder; /* Current max. creation order value for group */ - haddr_t corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of links */ + hbool_t track_corder; /* Are creation order values tracked on links? */ + hbool_t index_corder; /* Are creation order values indexed on links? */ + int64_t max_corder; /* Current max. creation order value for group */ + haddr_t corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of links */ /* Storage management info */ - hsize_t nlinks; /* Number of links in the group */ - haddr_t fheap_addr; /* Address of fractal heap for storing "dense" links */ - haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of links */ + hsize_t nlinks; /* Number of links in the group */ + haddr_t fheap_addr; /* Address of fractal heap for storing "dense" links */ + haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of links */ } H5O_linfo_t; /* Initial version of the "old" fill value information */ /* (It doesn't look like this value was ever used in the file -QAK) */ -#define H5O_FILL_VERSION_1 1 +#define H5O_FILL_VERSION_1 1 /* Revised version of the "new" fill value information */ -#define H5O_FILL_VERSION_2 2 +#define H5O_FILL_VERSION_2 2 /* Version of the "new" fill value information with smaller default format */ -#define H5O_FILL_VERSION_3 3 +#define H5O_FILL_VERSION_3 3 /* The latest version of the format. Look through the 'encode', 'decode' * and 'size' callback for places to change when updating this. */ @@ -331,15 +340,15 @@ typedef struct H5O_linfo_t { */ struct H5O_fill_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ - - unsigned version; /* Encoding version number */ - H5T_t *type; /*type. Null implies same as dataset */ - ssize_t size; /*number of bytes in the fill value */ - void *buf; /*the fill value */ - H5D_alloc_time_t alloc_time; /* time to allocate space */ - H5D_fill_time_t fill_time; /* time to write fill value */ - hbool_t fill_defined; /* whether fill value is defined */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + + unsigned version; /* Encoding version number */ + H5T_t * type; /*type. Null implies same as dataset */ + ssize_t size; /*number of bytes in the fill value */ + void * buf; /*the fill value */ + H5D_alloc_time_t alloc_time; /* time to allocate space */ + H5D_fill_time_t fill_time; /* time to write fill value */ + hbool_t fill_defined; /* whether fill value is defined */ }; /* @@ -347,28 +356,28 @@ struct H5O_fill_t { * (Data structure in memory) */ typedef struct H5O_link_hard_t { - haddr_t addr; /* Object header address */ + haddr_t addr; /* Object header address */ } H5O_link_hard_t; typedef struct H5O_link_soft_t { - char *name; /* Destination name */ + char *name; /* Destination name */ } H5O_link_soft_t; typedef struct H5O_link_ud_t { - void *udata; /* Opaque data supplied by the user */ - size_t size; /* Size of udata */ + void * udata; /* Opaque data supplied by the user */ + size_t size; /* Size of udata */ } H5O_link_ud_t; typedef struct H5O_link_t { - H5L_type_t type; /* Type of link */ - hbool_t corder_valid; /* Creation order for link is valid (not stored) */ - int64_t corder; /* Creation order for link (stored if it's valid) */ - H5T_cset_t cset; /* Character set of link name */ - char *name; /* Link name */ + H5L_type_t type; /* Type of link */ + hbool_t corder_valid; /* Creation order for link is valid (not stored) */ + int64_t corder; /* Creation order for link (stored if it's valid) */ + H5T_cset_t cset; /* Character set of link name */ + char * name; /* Link name */ union { - H5O_link_hard_t hard; /* Information for hard links */ - H5O_link_soft_t soft; /* Information for soft links */ - H5O_link_ud_t ud; /* Information for user-defined links */ + H5O_link_hard_t hard; /* Information for hard links */ + H5O_link_soft_t soft; /* Information for soft links */ + H5O_link_ud_t ud; /* Information for user-defined links */ } u; } H5O_link_t; @@ -376,53 +385,50 @@ typedef struct H5O_link_t { * External File List Message * (Data structure in memory) */ -#define H5O_EFL_ALLOC 16 /*number of slots to alloc at once */ -#define H5O_EFL_UNLIMITED H5F_UNLIMITED /*max possible file size */ +#define H5O_EFL_ALLOC 16 /*number of slots to alloc at once */ +#define H5O_EFL_UNLIMITED H5F_UNLIMITED /*max possible file size */ typedef struct H5O_efl_entry_t { - size_t name_offset; /*offset of name within heap */ - char *name; /*malloc'd name */ - HDoff_t offset; /*offset of data within file */ - hsize_t size; /*size allocated within file */ + size_t name_offset; /*offset of name within heap */ + char * name; /*malloc'd name */ + HDoff_t offset; /*offset of data within file */ + hsize_t size; /*size allocated within file */ } H5O_efl_entry_t; typedef struct H5O_efl_t { - haddr_t heap_addr; /*address of name heap */ - size_t nalloc; /*number of slots allocated */ - size_t nused; /*number of slots used */ - H5O_efl_entry_t *slot; /*array of external file entries */ + haddr_t heap_addr; /*address of name heap */ + size_t nalloc; /*number of slots allocated */ + size_t nused; /*number of slots used */ + H5O_efl_entry_t *slot; /*array of external file entries */ } H5O_efl_t; - /* * Data Layout Message. * (Data structure in file) */ -#define H5O_LAYOUT_NDIMS (H5S_MAX_RANK+1) +#define H5O_LAYOUT_NDIMS (H5S_MAX_RANK + 1) /* Flags for chunked layout feature encoding */ -#define H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS 0x01 -#define H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER 0x02 -#define H5O_LAYOUT_ALL_CHUNK_FLAGS ( \ - H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS \ - | H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER \ - ) +#define H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS 0x01 +#define H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER 0x02 +#define H5O_LAYOUT_ALL_CHUNK_FLAGS \ + (H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS | H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) /* Version # of encoded virtual dataset global heap blocks */ -#define H5O_LAYOUT_VDS_GH_ENC_VERS 0 +#define H5O_LAYOUT_VDS_GH_ENC_VERS 0 /* Initial version of the layout information. Used when space is allocated */ -#define H5O_LAYOUT_VERSION_1 1 +#define H5O_LAYOUT_VERSION_1 1 /* This version added support for delaying allocation */ -#define H5O_LAYOUT_VERSION_2 2 +#define H5O_LAYOUT_VERSION_2 2 /* This version is revised to store just the information needed for each * storage type, and to straighten out problems with contiguous layout's * sizes (was encoding them as 4-byte values when they were really n-byte * values (where n usually is 8)). */ -#define H5O_LAYOUT_VERSION_3 3 +#define H5O_LAYOUT_VERSION_3 3 /* This version adds different types of indices to chunked datasets, allows * for larger chunk dimensions, stores chunk indices into their own @@ -431,7 +437,7 @@ typedef struct H5O_efl_t { * the storage used for partial chunks on boundaries, adds the virtual * layout type, etc. */ -#define H5O_LAYOUT_VERSION_4 4 +#define H5O_LAYOUT_VERSION_4 4 /* The default version of the format. (Earlier versions had bugs) */ #define H5O_LAYOUT_VERSION_DEFAULT H5O_LAYOUT_VERSION_3 @@ -441,215 +447,229 @@ typedef struct H5O_efl_t { #define H5O_LAYOUT_VERSION_LATEST H5O_LAYOUT_VERSION_4 /* Forward declaration of structs used below */ -struct H5D_layout_ops_t; /* Defined in H5Dpkg.h */ -struct H5D_chunk_ops_t; /* Defined in H5Dpkg.h */ +struct H5D_layout_ops_t; /* Defined in H5Dpkg.h */ +struct H5D_chunk_ops_t; /* Defined in H5Dpkg.h */ typedef struct H5O_storage_contig_t { - haddr_t addr; /* File address of data */ - hsize_t size; /* Size of data in bytes */ + haddr_t addr; /* File address of data */ + hsize_t size; /* Size of data in bytes */ } H5O_storage_contig_t; typedef struct H5O_storage_chunk_btree_t { - haddr_t dset_ohdr_addr; /* File address dataset's object header */ - H5UC_t *shared; /* Ref-counted shared info for B-tree nodes */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ + H5UC_t *shared; /* Ref-counted shared info for B-tree nodes */ } H5O_storage_chunk_btree_t; /* Forward declaration of structs used below */ -struct H5FA_t; /* Defined in H5FAprivate.h */ +struct H5FA_t; /* Defined in H5FAprivate.h */ typedef struct H5O_storage_chunk_farray_t { - haddr_t dset_ohdr_addr; /* File address dataset's object header */ - struct H5FA_t *fa; /* Pointer to fixed index array struct */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ + struct H5FA_t *fa; /* Pointer to fixed index array struct */ } H5O_storage_chunk_farray_t; /* Forward declaration of structs used below */ -struct H5EA_t; /* Defined in H5EAprivate.h */ +struct H5EA_t; /* Defined in H5EAprivate.h */ typedef struct H5O_storage_chunk_earray_t { - haddr_t dset_ohdr_addr; /* File address dataset's object header */ - struct H5EA_t *ea; /* Pointer to extensible index array struct */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ + struct H5EA_t *ea; /* Pointer to extensible index array struct */ } H5O_storage_chunk_earray_t; /* Filtered info for single chunk index */ typedef struct H5O_storage_chunk_single_filt_t { - uint32_t nbytes; /* Size of chunk (in file) */ - uint32_t filter_mask; /* Excluded filters for chunk */ + uint32_t nbytes; /* Size of chunk (in file) */ + uint32_t filter_mask; /* Excluded filters for chunk */ } H5O_storage_chunk_single_filt_t; /* Forward declaration of structs used below */ -struct H5B2_t; /* Defined in H5B2pkg.h */ +struct H5B2_t; /* Defined in H5B2pkg.h */ typedef struct H5O_storage_chunk_bt2_t { - haddr_t dset_ohdr_addr; /* File address dataset's object header */ - struct H5B2_t *bt2; /* Pointer to b-tree 2 struct */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ + struct H5B2_t *bt2; /* Pointer to b-tree 2 struct */ } H5O_storage_chunk_bt2_t; typedef struct H5O_storage_chunk_t { - H5D_chunk_index_t idx_type; /* Type of chunk index */ - haddr_t idx_addr; /* File address of chunk index */ - const struct H5D_chunk_ops_t *ops; /* Pointer to chunked storage operations */ + H5D_chunk_index_t idx_type; /* Type of chunk index */ + haddr_t idx_addr; /* File address of chunk index */ + const struct H5D_chunk_ops_t *ops; /* Pointer to chunked storage operations */ union { - H5O_storage_chunk_btree_t btree; /* Information for v1 B-tree index */ - H5O_storage_chunk_bt2_t btree2; /* Information for v2 B-tree index */ - H5O_storage_chunk_earray_t earray; /* Information for extensible array index */ - H5O_storage_chunk_farray_t farray; /* Information for fixed array index */ + H5O_storage_chunk_btree_t btree; /* Information for v1 B-tree index */ + H5O_storage_chunk_bt2_t btree2; /* Information for v2 B-tree index */ + H5O_storage_chunk_earray_t earray; /* Information for extensible array index */ + H5O_storage_chunk_farray_t farray; /* Information for fixed array index */ H5O_storage_chunk_single_filt_t single; /* Information for single chunk w/ filters index */ } u; } H5O_storage_chunk_t; typedef struct H5O_storage_compact_t { - hbool_t dirty; /* Dirty flag for compact dataset */ - size_t size; /* Size of buffer in bytes */ - void *buf; /* Buffer for compact dataset */ + hbool_t dirty; /* Dirty flag for compact dataset */ + size_t size; /* Size of buffer in bytes */ + void * buf; /* Buffer for compact dataset */ } H5O_storage_compact_t; typedef struct H5O_storage_virtual_srcdset_t { /* Stored */ - struct H5S_t *virtual_select; /* Selection in the virtual dataset that is mapped to source selection */ + struct H5S_t *virtual_select; /* Selection in the virtual dataset that is mapped to source selection */ /* Not stored */ - char *file_name; /* Source file name used for virtual dataset mapping */ - char *dset_name; /* Source dataset name used for virtual dataset mapping */ - struct H5S_t *clipped_source_select; /* Clipped version of source_select */ + char * file_name; /* Source file name used for virtual dataset mapping */ + char * dset_name; /* Source dataset name used for virtual dataset mapping */ + struct H5S_t *clipped_source_select; /* Clipped version of source_select */ struct H5S_t *clipped_virtual_select; /* Clipped version of virtual_select */ - struct H5D_t *dset; /* Source dataset */ - hbool_t dset_exists; /* Whether the dataset exists (was opened successfully) */ + struct H5D_t *dset; /* Source dataset */ + hbool_t dset_exists; /* Whether the dataset exists (was opened successfully) */ /* Temporary - only used during I/O operation, NULL at all other times */ - struct H5S_t *projected_mem_space; /* Selection within mem_space for this mapping */ + struct H5S_t *projected_mem_space; /* Selection within mem_space for this mapping */ } H5O_storage_virtual_srcdset_t; typedef struct H5O_storage_virtual_name_seg_t { - char *name_segment; /* String for this name segment */ - struct H5O_storage_virtual_name_seg_t *next; /* Next name segment */ + char * name_segment; /* String for this name segment */ + struct H5O_storage_virtual_name_seg_t *next; /* Next name segment */ } H5O_storage_virtual_name_seg_t; typedef enum H5O_virtual_space_status_t { - H5O_VIRTUAL_STATUS_INVALID = 0, /* Space extent is invalid */ - H5O_VIRTUAL_STATUS_SEL_BOUNDS, /* Space extent set to bounds of selection */ - H5O_VIRTUAL_STATUS_USER, /* Space extent provided by application */ - H5O_VIRTUAL_STATUS_CORRECT /* Space extent matches dataset */ + H5O_VIRTUAL_STATUS_INVALID = 0, /* Space extent is invalid */ + H5O_VIRTUAL_STATUS_SEL_BOUNDS, /* Space extent set to bounds of selection */ + H5O_VIRTUAL_STATUS_USER, /* Space extent provided by application */ + H5O_VIRTUAL_STATUS_CORRECT /* Space extent matches dataset */ } H5O_virtual_space_status_t; typedef struct H5O_storage_virtual_ent_t { /* Stored */ - H5O_storage_virtual_srcdset_t source_dset; /* Information about the source dataset */ - char *source_file_name; /* Original (unparsed) source file name */ - char *source_dset_name; /* Original (unparsed) source dataset name */ - struct H5S_t *source_select; /* Selection in the source dataset for mapping */ + H5O_storage_virtual_srcdset_t source_dset; /* Information about the source dataset */ + char * source_file_name; /* Original (unparsed) source file name */ + char * source_dset_name; /* Original (unparsed) source dataset name */ + struct H5S_t * source_select; /* Selection in the source dataset for mapping */ /* Not stored */ - H5O_storage_virtual_srcdset_t *sub_dset; /* Array of sub-source dataset info structs */ - size_t sub_dset_nalloc; /* Number of slots allocated in sub_dset */ - size_t sub_dset_nused; /* Number of slots "used" in sub_dset - essentially the farthest sub dataset in the extent */ - size_t sub_dset_io_start; /* First element in sub_dset involved in current I/O op. Field has no meaning and may be uninitialized at all other times */ - size_t sub_dset_io_end; /* First element in sub_dset outside of current I/O op. Field has no meaning and may be uninitialized at all other times */ + H5O_storage_virtual_srcdset_t *sub_dset; /* Array of sub-source dataset info structs */ + size_t sub_dset_nalloc; /* Number of slots allocated in sub_dset */ + size_t sub_dset_nused; /* Number of slots "used" in sub_dset - essentially the farthest sub dataset in the + extent */ + size_t sub_dset_io_start; /* First element in sub_dset involved in current I/O op. Field has no meaning + and may be uninitialized at all other times */ + size_t sub_dset_io_end; /* First element in sub_dset outside of current I/O op. Field has no meaning and + may be uninitialized at all other times */ H5O_storage_virtual_name_seg_t *parsed_source_file_name; /* Parsed version of source_dset.file_name */ - size_t psfn_static_strlen; /* Length of parsed_source_file_name without block number substitutions */ - size_t psfn_nsubs; /* Number of block number substitutions in parsed_source_file_name */ + size_t psfn_static_strlen; /* Length of parsed_source_file_name without block number substitutions */ + size_t psfn_nsubs; /* Number of block number substitutions in parsed_source_file_name */ H5O_storage_virtual_name_seg_t *parsed_source_dset_name; /* Parsed version of source_dset.dset_name */ - size_t psdn_static_strlen; /* Length of parsed_source_dset_name without block number substitutions */ - size_t psdn_nsubs; /* Number of block number substitutions in parsed_source_dset_name */ - int unlim_dim_source; /* Unlimited dimension in source_select */ - int unlim_dim_virtual; /* Unlimited dimension in virtual_select */ - hsize_t unlim_extent_source; /* Extent of unlimited dimension in source dset last time virtual_select was patched to match selection */ - hsize_t unlim_extent_virtual; /* Extent of unlimited dimension in virtual dset last time source_select was patched to match selection */ - hsize_t clip_size_virtual; /* Size selection would be clipped to in virtual selection, ignoring other mappings, when source extent == unlim_extent_source */ - hsize_t clip_size_source; /* Size selection would be clipped to in source selection when virtual extent == unlim_extent_virtual */ - H5O_virtual_space_status_t source_space_status; /* Extent patching status of source_select */ + size_t psdn_static_strlen; /* Length of parsed_source_dset_name without block number substitutions */ + size_t psdn_nsubs; /* Number of block number substitutions in parsed_source_dset_name */ + int unlim_dim_source; /* Unlimited dimension in source_select */ + int unlim_dim_virtual; /* Unlimited dimension in virtual_select */ + hsize_t unlim_extent_source; /* Extent of unlimited dimension in source dset last time virtual_select was + patched to match selection */ + hsize_t unlim_extent_virtual; /* Extent of unlimited dimension in virtual dset last time source_select was + patched to match selection */ + hsize_t clip_size_virtual; /* Size selection would be clipped to in virtual selection, ignoring other + mappings, when source extent == unlim_extent_source */ + hsize_t clip_size_source; /* Size selection would be clipped to in source selection when virtual extent == + unlim_extent_virtual */ + H5O_virtual_space_status_t source_space_status; /* Extent patching status of source_select */ H5O_virtual_space_status_t virtual_space_status; /* Extent patching status of virtual_select */ } H5O_storage_virtual_ent_t; typedef struct H5O_storage_virtual_t { /* Stored in message */ - H5HG_t serial_list_hobjid; /* Global heap ID for the list of virtual mapping entries stored on disk */ + H5HG_t serial_list_hobjid; /* Global heap ID for the list of virtual mapping entries stored on disk */ /* Stored in heap */ - size_t list_nused; /* Number of array elements used in list */ - H5O_storage_virtual_ent_t *list; /* Array of virtual dataset mapping entries */ + size_t list_nused; /* Number of array elements used in list */ + H5O_storage_virtual_ent_t *list; /* Array of virtual dataset mapping entries */ /* Not stored */ - size_t list_nalloc; /* Number of slots allocated */ - hsize_t min_dims[H5S_MAX_RANK]; /* Minimum extent of VDS (maximum of all non-unlimited selection bounds) */ - H5D_vds_view_t view; /* Method for calculating the extent of the virtual dataset with unlimited selections */ - hsize_t printf_gap; /* Maximum number of sequential missing source datasets before terminating the search for more */ - hid_t source_fapl; /* FAPL to use to open source files */ - hid_t source_dapl; /* DAPL to use to open source datasets */ - hbool_t init; /* Whether all information has been completely initialized */ + size_t list_nalloc; /* Number of slots allocated */ + hsize_t + min_dims[H5S_MAX_RANK]; /* Minimum extent of VDS (maximum of all non-unlimited selection bounds) */ + H5D_vds_view_t + view; /* Method for calculating the extent of the virtual dataset with unlimited selections */ + hsize_t printf_gap; /* Maximum number of sequential missing source datasets before terminating the search + for more */ + hid_t source_fapl; /* FAPL to use to open source files */ + hid_t source_dapl; /* DAPL to use to open source datasets */ + hbool_t init; /* Whether all information has been completely initialized */ } H5O_storage_virtual_t; typedef struct H5O_storage_t { - H5D_layout_t type; /* Type of layout */ + H5D_layout_t type; /* Type of layout */ union { - H5O_storage_contig_t contig; /* Information for contiguous storage */ - H5O_storage_chunk_t chunk; /* Information for chunked storage */ - H5O_storage_compact_t compact; /* Information for compact storage */ - H5O_storage_virtual_t virt; /* Information for virtual storage */ + H5O_storage_contig_t contig; /* Information for contiguous storage */ + H5O_storage_chunk_t chunk; /* Information for chunked storage */ + H5O_storage_compact_t compact; /* Information for compact storage */ + H5O_storage_virtual_t virt; /* Information for virtual storage */ } u; } H5O_storage_t; typedef struct H5O_layout_chunk_farray_t { /* Creation parameters for fixed array data structure */ struct { - uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) - - i.e. # of bits needed to store max. # of elements - in a data block page */ + uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) - + i.e. # of bits needed to store max. # of elements + in a data block page */ } cparam; } H5O_layout_chunk_farray_t; typedef struct H5O_layout_chunk_earray_t { /* Creation parameters for extensible array data structure */ struct { - uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ - uint8_t idx_blk_elmts; /* # of elements to store in index block */ - uint8_t data_blk_min_elmts; /* Min. # of elements per data block */ - uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ - uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # + of elements */ + uint8_t idx_blk_elmts; /* # of elements to store in index block */ + uint8_t data_blk_min_elmts; /* Min. # of elements per data block */ + uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ + uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits + needed to store max. # of elements in data block page */ } cparam; - unsigned unlim_dim; /* Rank of unlimited dimension for dataset */ - uint32_t swizzled_dim[H5O_LAYOUT_NDIMS]; /* swizzled chunk dimensions */ - hsize_t swizzled_down_chunks[H5O_LAYOUT_NDIMS]; /* swizzled "down" size of number of chunks in each dimension */ - hsize_t swizzled_max_down_chunks[H5O_LAYOUT_NDIMS]; /* swizzled max "down" size of number of chunks in each dimension */ + unsigned unlim_dim; /* Rank of unlimited dimension for dataset */ + uint32_t swizzled_dim[H5O_LAYOUT_NDIMS]; /* swizzled chunk dimensions */ + hsize_t swizzled_down_chunks[H5O_LAYOUT_NDIMS]; /* swizzled "down" size of number of chunks in each + dimension */ + hsize_t swizzled_max_down_chunks[H5O_LAYOUT_NDIMS]; /* swizzled max "down" size of number of chunks in + each dimension */ } H5O_layout_chunk_earray_t; typedef struct H5O_layout_chunk_bt2_t { /* Creation parameters for v2 B-tree data structure */ struct { - uint32_t node_size; /* Size of each node (in bytes) */ - uint8_t split_percent; /* % full to split nodes */ - uint8_t merge_percent; /* % full to merge nodes */ + uint32_t node_size; /* Size of each node (in bytes) */ + uint8_t split_percent; /* % full to split nodes */ + uint8_t merge_percent; /* % full to merge nodes */ } cparam; } H5O_layout_chunk_bt2_t; typedef struct H5O_layout_chunk_t { - H5D_chunk_index_t idx_type; /* Type of chunk index */ - uint8_t flags; /* Chunk layout flags */ - unsigned ndims; /* Num dimensions in chunk */ - uint32_t dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in elements */ - unsigned enc_bytes_per_dim; /* Encoded # of bytes for storing each chunk dimension */ - uint32_t size; /* Size of chunk in bytes */ - hsize_t nchunks; /* Number of chunks in dataset */ - hsize_t max_nchunks; /* Max. number of chunks in dataset */ - hsize_t chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset dimension */ - hsize_t max_chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset's max. dimension */ - hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ - hsize_t max_down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each max dim */ + H5D_chunk_index_t idx_type; /* Type of chunk index */ + uint8_t flags; /* Chunk layout flags */ + unsigned ndims; /* Num dimensions in chunk */ + uint32_t dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in elements */ + unsigned enc_bytes_per_dim; /* Encoded # of bytes for storing each chunk dimension */ + uint32_t size; /* Size of chunk in bytes */ + hsize_t nchunks; /* Number of chunks in dataset */ + hsize_t max_nchunks; /* Max. number of chunks in dataset */ + hsize_t chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset dimension */ + hsize_t max_chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset's max. dimension */ + hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ + hsize_t max_down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each max dim */ union { H5O_layout_chunk_farray_t farray; /* Information for fixed array index */ H5O_layout_chunk_earray_t earray; /* Information for extensible array index */ - H5O_layout_chunk_bt2_t btree2; /* Information for v2 B-tree index */ + H5O_layout_chunk_bt2_t btree2; /* Information for v2 B-tree index */ } u; } H5O_layout_chunk_t; typedef struct H5O_layout_t { - H5D_layout_t type; /* Type of layout */ - unsigned version; /* Version of message */ - const struct H5D_layout_ops_t *ops; /* Pointer to data layout I/O operations */ + H5D_layout_t type; /* Type of layout */ + unsigned version; /* Version of message */ + const struct H5D_layout_ops_t *ops; /* Pointer to data layout I/O operations */ union { - H5O_layout_chunk_t chunk; /* Information for chunked layout */ + H5O_layout_chunk_t chunk; /* Information for chunked layout */ } u; - H5O_storage_t storage; /* Information for storing dataset elements */ + H5O_storage_t storage; /* Information for storing dataset elements */ } H5O_layout_t; #ifdef H5O_ENABLE_BOGUS @@ -657,10 +677,10 @@ typedef struct H5O_layout_t { * "Bogus" Message. * (Data structure in memory) */ -#define H5O_BOGUS_VALUE 0xdeadbeef +#define H5O_BOGUS_VALUE 0xdeadbeef typedef struct H5O_bogus_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ - unsigned u; /* Hold the bogus info */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + unsigned u; /* Hold the bogus info */ } H5O_bogus_t; #endif /* H5O_ENABLE_BOGUS */ @@ -673,19 +693,19 @@ typedef struct H5O_bogus_t { */ typedef struct H5O_ginfo_t { /* "Old" format group info (not stored) */ - uint32_t lheap_size_hint; /* Local heap size hint */ + uint32_t lheap_size_hint; /* Local heap size hint */ /* "New" format group info (stored) */ /* (storage management info) */ - hbool_t store_link_phase_change;/* Whether to store the link phase change values */ - uint16_t max_compact; /* Maximum # of compact links */ - uint16_t min_dense; /* Minimum # of "dense" links */ + hbool_t store_link_phase_change; /* Whether to store the link phase change values */ + uint16_t max_compact; /* Maximum # of compact links */ + uint16_t min_dense; /* Minimum # of "dense" links */ /* (initial object header size info) */ - hbool_t store_est_entry_info; /* Whether to store the est. entry values */ - uint16_t est_num_entries; /* Estimated # of entries in group */ - uint16_t est_name_len; /* Estimated length of entry name */ + hbool_t store_est_entry_info; /* Whether to store the est. entry values */ + uint16_t est_num_entries; /* Estimated # of entries in group */ + uint16_t est_name_len; /* Estimated length of entry name */ } H5O_ginfo_t; /* @@ -694,25 +714,25 @@ typedef struct H5O_ginfo_t { */ /* The initial version of the format */ -#define H5O_PLINE_VERSION_1 1 +#define H5O_PLINE_VERSION_1 1 /* This version encodes the message fields more efficiently */ /* (Drops the reserved bytes, doesn't align the name and doesn't encode the * filter name at all if it's a filter provided by the library) */ -#define H5O_PLINE_VERSION_2 2 +#define H5O_PLINE_VERSION_2 2 /* The latest version of the format. Look through the 'encode' and 'size' * callbacks for places to change when updating this. */ #define H5O_PLINE_VERSION_LATEST H5O_PLINE_VERSION_2 typedef struct H5O_pline_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ - unsigned version; /* Encoding version number */ - size_t nalloc; /*num elements in `filter' array */ - size_t nused; /*num filters defined */ - H5Z_filter_info_t *filter; /*array of filters */ + unsigned version; /* Encoding version number */ + size_t nalloc; /*num elements in `filter' array */ + size_t nused; /*num filters defined */ + H5Z_filter_info_t *filter; /*array of filters */ } H5O_pline_t; /* @@ -721,7 +741,7 @@ typedef struct H5O_pline_t { */ typedef struct H5O_name_t { - char *s; /*ptr to malloc'd memory */ + char *s; /*ptr to malloc'd memory */ } H5O_name_t; /* @@ -731,9 +751,9 @@ typedef struct H5O_name_t { * (Data structure in memory) */ typedef struct H5O_shmesg_table_t { - haddr_t addr; /*file address of SOHM table */ - unsigned version; /*SOHM table version number */ - unsigned nindexes; /*number of indexes in the table */ + haddr_t addr; /*file address of SOHM table */ + unsigned version; /*SOHM table version number */ + unsigned nindexes; /*number of indexes in the table */ } H5O_shmesg_table_t; /* @@ -742,11 +762,11 @@ typedef struct H5O_shmesg_table_t { */ typedef struct H5O_cont_t { - haddr_t addr; /*address of continuation block */ - size_t size; /*size of continuation block */ + haddr_t addr; /*address of continuation block */ + size_t size; /*size of continuation block */ /* the following field(s) do not appear on disk */ - unsigned chunkno; /*chunk this mesg refers to */ + unsigned chunkno; /*chunk this mesg refers to */ } H5O_cont_t; /* @@ -754,8 +774,8 @@ typedef struct H5O_cont_t { * (Data structure in memory) */ typedef struct H5O_stab_t { - haddr_t btree_addr; /*address of B-tree */ - haddr_t heap_addr; /*address of name heap */ + haddr_t btree_addr; /*address of B-tree */ + haddr_t heap_addr; /*address of name heap */ } H5O_stab_t; /* @@ -765,8 +785,8 @@ typedef struct H5O_stab_t { * (Data structure in memory) */ typedef struct H5O_btreek_t { - unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree internal node 'K' values */ - unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree internal node 'K' values */ + unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ } H5O_btreek_t; /* @@ -775,11 +795,11 @@ typedef struct H5O_btreek_t { * (Data structure in memory) */ typedef struct H5O_drvinfo_t { -/* Information for H5AC cache functions, _must_ be first field in structure */ - H5AC_info_t cache_info; - char name[9]; /* Driver name */ - size_t len; /* Length of encoded buffer */ - uint8_t *buf; /* Buffer for encoded info */ + /* Information for H5AC cache functions, _must_ be first field in structure */ + H5AC_info_t cache_info; + char name[9]; /* Driver name */ + size_t len; /* Length of encoded buffer */ + uint8_t * buf; /* Buffer for encoded info */ } H5O_drvinfo_t; /* @@ -789,40 +809,41 @@ typedef struct H5O_drvinfo_t { */ typedef struct H5O_ainfo_t { /* Creation order info */ - hbool_t track_corder; /* Are creation order values tracked on attributes? */ - hbool_t index_corder; /* Are creation order values indexed on attributes? */ - H5O_msg_crt_idx_t max_crt_idx; /* Maximum attribute creation index used */ - haddr_t corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of "dense" attributes */ + hbool_t track_corder; /* Are creation order values tracked on attributes? */ + hbool_t index_corder; /* Are creation order values indexed on attributes? */ + H5O_msg_crt_idx_t max_crt_idx; /* Maximum attribute creation index used */ + haddr_t + corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of "dense" attributes */ /* Storage management info */ - hsize_t nattrs; /* Number of attributes on the object */ - haddr_t fheap_addr; /* Address of fractal heap for storing "dense" attributes */ - haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of "dense" attributes */ + hsize_t nattrs; /* Number of attributes on the object */ + haddr_t fheap_addr; /* Address of fractal heap for storing "dense" attributes */ + haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of "dense" attributes */ } H5O_ainfo_t; /* * Reference Count Message. * (Data structure in memory) */ -typedef uint32_t H5O_refcount_t; /* Contains # of links to object, if >1 */ +typedef uint32_t H5O_refcount_t; /* Contains # of links to object, if >1 */ /* * "Unknown" Message. * (Data structure in memory) */ -typedef unsigned H5O_unknown_t; /* Original message type ID */ +typedef unsigned H5O_unknown_t; /* Original message type ID */ /* To indicate an invalid version for a message that does not exist yet for the release */ /* Message version is 1 byte so the value can be 0 to 255 */ -#define H5O_INVALID_VERSION 256 +#define H5O_INVALID_VERSION 256 /* The initial version of the fsinfo message: deprecated */ /* This version is mapped to version 1 from release 1.10.1 onwards */ -#define H5O_FSINFO_VERSION_0 0 +#define H5O_FSINFO_VERSION_0 0 /* The latest version for fsinfo message */ -#define H5O_FSINFO_VERSION_1 1 -#define H5O_FSINFO_VERSION_LATEST H5O_FSINFO_VERSION_1 +#define H5O_FSINFO_VERSION_1 1 +#define H5O_FSINFO_VERSION_LATEST H5O_FSINFO_VERSION_1 /* * File space info Message. * Contains file space management info and @@ -830,17 +851,17 @@ typedef unsigned H5O_unknown_t; /* Original message type ID */ * (Data structure in memory) */ typedef struct H5O_fsinfo_t { - unsigned version; /* Version number */ - H5F_fspace_strategy_t strategy; /* File space strategy */ - hbool_t persist; /* Persisting free-space or not */ - hsize_t threshold; /* Free-space section threshold */ - hsize_t page_size; /* For paged aggregation: file space page size */ - size_t pgend_meta_thres; /* For paged aggregation: page end metadata threshold */ - haddr_t eoa_pre_fsm_fsalloc; /* For paged aggregation: the eoa before free-space headers & sinfo */ - haddr_t fs_addr[H5F_MEM_PAGE_NTYPES - 1]; /* 13 addresses of free-space managers */ - /* For non-paged aggregation: only 6 addresses are used */ - hbool_t mapped; /* Not stored */ - /* Indicate the message is mapped from version 0 to version 1 */ + unsigned version; /* Version number */ + H5F_fspace_strategy_t strategy; /* File space strategy */ + hbool_t persist; /* Persisting free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + hsize_t page_size; /* For paged aggregation: file space page size */ + size_t pgend_meta_thres; /* For paged aggregation: page end metadata threshold */ + haddr_t eoa_pre_fsm_fsalloc; /* For paged aggregation: the eoa before free-space headers & sinfo */ + haddr_t fs_addr[H5F_MEM_PAGE_NTYPES - 1]; /* 13 addresses of free-space managers */ + /* For non-paged aggregation: only 6 addresses are used */ + hbool_t mapped; /* Not stored */ + /* Indicate the message is mapped from version 0 to version 1 */ } H5O_fsinfo_t; /* @@ -849,60 +870,58 @@ typedef struct H5O_fsinfo_t { * (Data structure in memory) */ typedef struct H5O_mdci_t { - haddr_t addr; /* address of MDC image block */ - hsize_t size; /* size of MDC image block */ + haddr_t addr; /* address of MDC image block */ + hsize_t size; /* size of MDC image block */ } H5O_mdci_t; /* Typedef for "application" iteration operations */ -typedef herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx, - void *operator_data/*in,out*/); +typedef herr_t (*H5O_operator_t)(const void *mesg /*in*/, unsigned idx, void *operator_data /*in,out*/); /* Typedef for "internal library" iteration operations */ -typedef herr_t (*H5O_lib_operator_t)(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned *oh_modified/*out*/, void *operator_data/*in,out*/); +typedef herr_t (*H5O_lib_operator_t)(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned *oh_modified /*out*/, void *operator_data /*in,out*/); /* Some syntactic sugar to make the compiler happy with two different kinds of iterator callbacks */ typedef enum H5O_mesg_operator_type_t { - H5O_MESG_OP_APP, /* Application callback */ - H5O_MESG_OP_LIB /* Library internal callback */ + H5O_MESG_OP_APP, /* Application callback */ + H5O_MESG_OP_LIB /* Library internal callback */ } H5O_mesg_operator_type_t; -#define H5O_MODIFY_CONDENSE 0x01 -#define H5O_MODIFY 0x02 +#define H5O_MODIFY_CONDENSE 0x01 +#define H5O_MODIFY 0x02 typedef struct { H5O_mesg_operator_type_t op_type; union { - H5O_operator_t app_op; /* Application callback for each message */ - H5O_lib_operator_t lib_op; /* Library internal callback for each message */ + H5O_operator_t app_op; /* Application callback for each message */ + H5O_lib_operator_t lib_op; /* Library internal callback for each message */ } u; } H5O_mesg_operator_t; /* Typedef for abstract object creation */ typedef struct { - H5O_type_t obj_type; /* Type of object to create */ - void *crt_info; /* Information for object creation callback */ - void *new_obj; /* Pointer to new object created */ + H5O_type_t obj_type; /* Type of object to create */ + void * crt_info; /* Information for object creation callback */ + void * new_obj; /* Pointer to new object created */ } H5O_obj_create_t; - /* Forward declarations for prototype arguments */ struct H5P_genplist_t; /* Object header routines */ H5_DLL herr_t H5O_init(void); -H5_DLL herr_t H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, - hid_t ocpl_id, H5O_loc_t *loc/*out*/); +H5_DLL herr_t H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, + H5O_loc_t *loc /*out*/); H5_DLL H5O_t *H5O__create_ohdr(H5F_t *f, hid_t ocpl_id); -H5_DLL herr_t H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, - size_t size_hint, size_t initial_rc, H5O_loc_t *loc_out); +H5_DLL herr_t H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t initial_rc, + H5O_loc_t *loc_out); H5_DLL herr_t H5O_open(H5O_loc_t *loc); -H5_DLL void *H5O_open_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5I_type_t *opened_type/*out*/); -H5_DLL void *H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr, H5I_type_t *opened_type/*out*/); -H5_DLL void *H5O_open_by_loc(const H5G_loc_t *obj_loc, H5I_type_t *opened_type/*out*/); -H5_DLL herr_t H5O_close(H5O_loc_t *loc, hbool_t *file_closed/*out*/); -H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust); +H5_DLL void * H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5I_type_t *opened_type /*out*/); +H5_DLL void * H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr, H5I_type_t *opened_type /*out*/); +H5_DLL void * H5O_open_by_loc(const H5G_loc_t *obj_loc, H5I_type_t *opened_type /*out*/); +H5_DLL herr_t H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/); +H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust); H5_DLL H5O_t *H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks); H5_DLL H5O_t *H5O_pin(const H5O_loc_t *loc); H5_DLL herr_t H5O_unpin(H5O_t *oh); @@ -913,75 +932,69 @@ H5_DLL herr_t H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force); #ifdef H5O_ENABLE_BOGUS H5_DLL herr_t H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned mesg_id, unsigned mesg_flags); #endif /* H5O_ENABLE_BOGUS */ -H5_DLL herr_t H5O_delete(H5F_t *f, haddr_t addr); -H5_DLL herr_t H5O_get_hdr_info(const H5O_loc_t *oloc, H5O_hdr_info_t *hdr); -H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, H5O_info2_t *oinfo, unsigned fields); -H5_DLL herr_t H5O_get_native_info(const H5O_loc_t *oloc, H5O_native_info_t *oinfo, unsigned fields); -H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type); -H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, struct H5P_genplist_t *oc_plist); -H5_DLL void *H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type/*out*/); -H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks); -H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc); +H5_DLL herr_t H5O_delete(H5F_t *f, haddr_t addr); +H5_DLL herr_t H5O_get_hdr_info(const H5O_loc_t *oloc, H5O_hdr_info_t *hdr); +H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, H5O_info2_t *oinfo, unsigned fields); +H5_DLL herr_t H5O_get_native_info(const H5O_loc_t *oloc, H5O_native_info_t *oinfo, unsigned fields); +H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type); +H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, struct H5P_genplist_t *oc_plist); +H5_DLL void * H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type /*out*/); +H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks); +H5_DLL void * H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc); H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh); H5_DLL uint8_t H5O_get_oh_flags(const H5O_t *oh); -H5_DLL time_t H5O_get_oh_mtime(const H5O_t *oh); +H5_DLL time_t H5O_get_oh_mtime(const H5O_t *oh); H5_DLL uint8_t H5O_get_oh_version(const H5O_t *oh); -H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, unsigned *rc, H5O_type_t *otype); +H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, unsigned *rc, H5O_type_t *otype); H5_DLL H5AC_proxy_entry_t *H5O_get_proxy(const H5O_t *oh); /* Object header message routines */ H5_DLL herr_t H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg); -H5_DLL herr_t H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, - unsigned mesg_flags, unsigned update_flags, void *mesg); -H5_DLL herr_t H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, - unsigned mesg_flags, unsigned update_flags, void *mesg); -H5_DLL herr_t H5O_msg_write_oh(H5F_t *f, H5O_t *oh, unsigned type_id, - unsigned mesg_flags, unsigned update_flags, void *mesg); + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O_msg_write_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, + unsigned update_flags, void *mesg); H5_DLL herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg); -H5_DLL void *H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg); -H5_DLL void *H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg); +H5_DLL void * H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg); +H5_DLL void * H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg); H5_DLL herr_t H5O_msg_reset(unsigned type_id, void *native); -H5_DLL void *H5O_msg_free(unsigned type_id, void *mesg); -H5_DLL void *H5O_msg_free_real(const H5O_msg_class_t *type, void *mesg); -H5_DLL void *H5O_msg_copy(unsigned type_id, const void *mesg, void *dst); -H5_DLL int H5O_msg_count(const H5O_loc_t *loc, unsigned type_id); +H5_DLL void * H5O_msg_free(unsigned type_id, void *mesg); +H5_DLL void * H5O_msg_free_real(const H5O_msg_class_t *type, void *mesg); +H5_DLL void * H5O_msg_copy(unsigned type_id, const void *mesg, void *dst); +H5_DLL int H5O_msg_count(const H5O_loc_t *loc, unsigned type_id); H5_DLL htri_t H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id); H5_DLL htri_t H5O_msg_exists_oh(const H5O_t *oh, unsigned type_id); -H5_DLL herr_t H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, - hbool_t adj_link); -H5_DLL herr_t H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, - H5O_operator_t op, void *op_data, hbool_t adj_link); -H5_DLL herr_t H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, - const H5O_mesg_operator_t *op, void *op_data); -H5_DLL size_t H5O_msg_raw_size(const H5F_t *f, unsigned type_id, - hbool_t disable_shared, const void *mesg); -H5_DLL size_t H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, - const void *mesg, size_t extra_raw); -H5_DLL size_t H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, - const void *mesg, size_t extra_raw); +H5_DLL herr_t H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj_link); +H5_DLL herr_t H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, H5O_operator_t op, + void *op_data, hbool_t adj_link); +H5_DLL herr_t H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, const H5O_mesg_operator_t *op, + void *op_data); +H5_DLL size_t H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared, const void *mesg); +H5_DLL size_t H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, const void *mesg, + size_t extra_raw); +H5_DLL size_t H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, const void *mesg, + size_t extra_raw); H5_DLL htri_t H5O_msg_is_shared(unsigned type_id, const void *mesg); H5_DLL htri_t H5O_msg_can_share(unsigned type_id, const void *mesg); H5_DLL htri_t H5O_msg_can_share_in_ohdr(unsigned type_id); -H5_DLL herr_t H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, - void *mesg); +H5_DLL herr_t H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, void *mesg); H5_DLL herr_t H5O_msg_reset_share(unsigned type_id, void *mesg); -H5_DLL herr_t H5O_msg_get_crt_index(unsigned type_id, const void *mesg, - H5O_msg_crt_idx_t *crt_idx); -H5_DLL herr_t H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared, - unsigned char *buf, const void *obj); -H5_DLL void* H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, - size_t buf_size, const unsigned char *buf); -H5_DLL herr_t H5O_msg_delete(H5F_t *f, H5O_t *open_oh, unsigned type_id, - void *mesg); +H5_DLL herr_t H5O_msg_get_crt_index(unsigned type_id, const void *mesg, H5O_msg_crt_idx_t *crt_idx); +H5_DLL herr_t H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared, unsigned char *buf, + const void *obj); +H5_DLL void * H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, + const unsigned char *buf); +H5_DLL herr_t H5O_msg_delete(H5F_t *f, H5O_t *open_oh, unsigned type_id, void *mesg); H5_DLL herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t *flags); /* Object metadata flush/refresh routines */ H5_DLL herr_t H5O_flush(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc); -H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t, H5G_loc_t *, - const H5O_refresh_state_t *, H5VL_t *, hbool_t); +H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t, H5G_loc_t *, const H5O_refresh_state_t *, H5VL_t *, hbool_t); /* Cache corking functions */ H5_DLL herr_t H5O_disable_mdc_flushes(H5O_loc_t *oloc); @@ -990,18 +1003,17 @@ H5_DLL herr_t H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disable /* Object copying routines */ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, - H5O_copy_t *cpy_info, hbool_t inc_depth, - H5O_type_t *obj_type, void **udata); -H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, - void *buf_src, size_t nbytes_src, H5F_t *file_dst, void *buf_dst, - H5O_copy_t *cpy_info); -H5_DLL herr_t H5O_copy(const H5G_loc_t *src_loc, const char *src_name, - H5G_loc_t *dst_loc, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id); + H5O_copy_t *cpy_info, hbool_t inc_depth, H5O_type_t *obj_type, + void **udata); +H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, void *buf_src, + size_t nbytes_src, H5F_t *file_dst, void *buf_dst, H5O_copy_t *cpy_info); +H5_DLL herr_t H5O_copy(const H5G_loc_t *src_loc, const char *src_name, H5G_loc_t *dst_loc, + const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id); /* Debugging routines */ -H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5O_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, - int fwidth); +H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int indent, + int fwidth); +H5_DLL herr_t H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); /* These functions operate on object locations */ H5_DLL herr_t H5O_loc_reset(H5O_loc_t *loc); @@ -1022,7 +1034,7 @@ H5_DLL herr_t H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo); /* Fill value operators */ H5_DLL herr_t H5O_fill_reset_dyn(H5O_fill_t *fill); H5_DLL herr_t H5O_fill_convert(H5O_fill_t *fill, H5T_t *type, hbool_t *fill_changed); -H5_DLL herr_t H5O_fill_set_version(H5F_t * f, H5O_fill_t *fill); +H5_DLL herr_t H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill); /* Link operators */ H5_DLL herr_t H5O_link_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); @@ -1034,4 +1046,3 @@ H5_DLL herr_t H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline); H5_DLL herr_t H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src); #endif /* _H5Oprivate_H */ - diff --git a/src/H5Opublic.h b/src/H5Opublic.h index d0f8ab3..49f98d7 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -26,23 +26,23 @@ #define _H5Opublic_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Ipublic.h" /* IDs */ -#include "H5Lpublic.h" /* Links */ +#include "H5public.h" /* Generic Functions */ +#include "H5Ipublic.h" /* IDs */ +#include "H5Lpublic.h" /* Links */ /*****************/ /* Public Macros */ /*****************/ /* Flags for object copy (H5Ocopy) */ -#define H5O_COPY_SHALLOW_HIERARCHY_FLAG (0x0001u) /* Copy only immediate members */ -#define H5O_COPY_EXPAND_SOFT_LINK_FLAG (0x0002u) /* Expand soft links into new objects */ -#define H5O_COPY_EXPAND_EXT_LINK_FLAG (0x0004u) /* Expand external links into new objects */ -#define H5O_COPY_EXPAND_REFERENCE_FLAG (0x0008u) /* Copy objects that are pointed by references */ -#define H5O_COPY_WITHOUT_ATTR_FLAG (0x0010u) /* Copy object without copying attributes */ -#define H5O_COPY_PRESERVE_NULL_FLAG (0x0020u) /* Copy NULL messages (empty space) */ -#define H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG (0x0040u) /* Merge committed datatypes in dest file */ -#define H5O_COPY_ALL (0x007Fu) /* All object copying flags (for internal checking) */ +#define H5O_COPY_SHALLOW_HIERARCHY_FLAG (0x0001u) /* Copy only immediate members */ +#define H5O_COPY_EXPAND_SOFT_LINK_FLAG (0x0002u) /* Expand soft links into new objects */ +#define H5O_COPY_EXPAND_EXT_LINK_FLAG (0x0004u) /* Expand external links into new objects */ +#define H5O_COPY_EXPAND_REFERENCE_FLAG (0x0008u) /* Copy objects that are pointed by references */ +#define H5O_COPY_WITHOUT_ATTR_FLAG (0x0010u) /* Copy object without copying attributes */ +#define H5O_COPY_PRESERVE_NULL_FLAG (0x0020u) /* Copy NULL messages (empty space) */ +#define H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG (0x0040u) /* Merge committed datatypes in dest file */ +#define H5O_COPY_ALL (0x007Fu) /* All object copying flags (for internal checking) */ /* Flags for shared message indexes. * Pass these flags in using the mesg_type_flags parameter in @@ -51,48 +51,51 @@ * but we need to assign each kind of message to a different bit so that * one index can hold multiple types.) */ -#define H5O_SHMESG_NONE_FLAG 0x0000 /* No shared messages */ +#define H5O_SHMESG_NONE_FLAG 0x0000 /* No shared messages */ #define H5O_SHMESG_SDSPACE_FLAG ((unsigned)1 << 0x0001) /* Simple Dataspace Message. */ #define H5O_SHMESG_DTYPE_FLAG ((unsigned)1 << 0x0003) /* Datatype Message. */ #define H5O_SHMESG_FILL_FLAG ((unsigned)1 << 0x0005) /* Fill Value Message. */ #define H5O_SHMESG_PLINE_FLAG ((unsigned)1 << 0x000b) /* Filter pipeline message. */ #define H5O_SHMESG_ATTR_FLAG ((unsigned)1 << 0x000c) /* Attribute Message. */ -#define H5O_SHMESG_ALL_FLAG (H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_FILL_FLAG | H5O_SHMESG_PLINE_FLAG | H5O_SHMESG_ATTR_FLAG) +#define H5O_SHMESG_ALL_FLAG \ + (H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_FILL_FLAG | H5O_SHMESG_PLINE_FLAG | \ + H5O_SHMESG_ATTR_FLAG) /* Object header status flag definitions */ -#define H5O_HDR_CHUNK0_SIZE 0x03 /* 2-bit field indicating # of bytes to store the size of chunk 0's data */ -#define H5O_HDR_ATTR_CRT_ORDER_TRACKED 0x04 /* Attribute creation order is tracked */ -#define H5O_HDR_ATTR_CRT_ORDER_INDEXED 0x08 /* Attribute creation order has index */ -#define H5O_HDR_ATTR_STORE_PHASE_CHANGE 0x10 /* Non-default attribute storage phase change values stored */ -#define H5O_HDR_STORE_TIMES 0x20 /* Store access, modification, change & birth times for object */ -#define H5O_HDR_ALL_FLAGS (H5O_HDR_CHUNK0_SIZE | H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_ATTR_STORE_PHASE_CHANGE | H5O_HDR_STORE_TIMES) +#define H5O_HDR_CHUNK0_SIZE 0x03 /* 2-bit field indicating # of bytes to store the size of chunk 0's data */ +#define H5O_HDR_ATTR_CRT_ORDER_TRACKED 0x04 /* Attribute creation order is tracked */ +#define H5O_HDR_ATTR_CRT_ORDER_INDEXED 0x08 /* Attribute creation order has index */ +#define H5O_HDR_ATTR_STORE_PHASE_CHANGE 0x10 /* Non-default attribute storage phase change values stored */ +#define H5O_HDR_STORE_TIMES 0x20 /* Store access, modification, change & birth times for object */ +#define H5O_HDR_ALL_FLAGS \ + (H5O_HDR_CHUNK0_SIZE | H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | \ + H5O_HDR_ATTR_STORE_PHASE_CHANGE | H5O_HDR_STORE_TIMES) /* Maximum shared message values. Number of indexes is 8 to allow room to add * new types of messages. */ -#define H5O_SHMESG_MAX_NINDEXES 8 +#define H5O_SHMESG_MAX_NINDEXES 8 #define H5O_SHMESG_MAX_LIST_SIZE 5000 /* Flags for H5Oget_info. * Theses flags determine which fields will be filled in in the H5O_info_t * struct. */ -#define H5O_INFO_BASIC 0x0001u /* Fill in the fileno, addr, type, and rc fields */ -#define H5O_INFO_TIME 0x0002u /* Fill in the atime, mtime, ctime, and btime fields */ -#define H5O_INFO_NUM_ATTRS 0x0004u /* Fill in the num_attrs field */ -#define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS) +#define H5O_INFO_BASIC 0x0001u /* Fill in the fileno, addr, type, and rc fields */ +#define H5O_INFO_TIME 0x0002u /* Fill in the atime, mtime, ctime, and btime fields */ +#define H5O_INFO_NUM_ATTRS 0x0004u /* Fill in the num_attrs field */ +#define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS) /* Flags for H5Oget_native_info. * Theses flags determine which fields will be filled in in the H5O_native_info_t * struct. */ -#define H5O_NATIVE_INFO_HDR 0x0008u /* Fill in the hdr field */ -#define H5O_NATIVE_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ -#define H5O_NATIVE_INFO_ALL (H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) +#define H5O_NATIVE_INFO_HDR 0x0008u /* Fill in the hdr field */ +#define H5O_NATIVE_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ +#define H5O_NATIVE_INFO_ALL (H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) /* Convenience macro to check if the token is the 'undefined' token value */ -#define H5O_IS_TOKEN_UNDEF(token) (!HDmemcmp(&(token), &(H5O_TOKEN_UNDEF), sizeof(H5O_token_t))) - +#define H5O_IS_TOKEN_UNDEF(token) (!HDmemcmp(&(token), &(H5O_TOKEN_UNDEF), sizeof(H5O_token_t))) /*******************/ /* Public Typedefs */ @@ -100,54 +103,54 @@ /* Types of objects in file */ typedef enum H5O_type_t { - H5O_TYPE_UNKNOWN = -1, /* Unknown object type */ - H5O_TYPE_GROUP, /* Object is a group */ - H5O_TYPE_DATASET, /* Object is a dataset */ - H5O_TYPE_NAMED_DATATYPE, /* Object is a named data type */ - H5O_TYPE_MAP, /* Object is a map */ - H5O_TYPE_NTYPES /* Number of different object types (must be last!) */ + H5O_TYPE_UNKNOWN = -1, /* Unknown object type */ + H5O_TYPE_GROUP, /* Object is a group */ + H5O_TYPE_DATASET, /* Object is a dataset */ + H5O_TYPE_NAMED_DATATYPE, /* Object is a named data type */ + H5O_TYPE_MAP, /* Object is a map */ + H5O_TYPE_NTYPES /* Number of different object types (must be last!) */ } H5O_type_t; /* Information struct for object header metadata (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) */ typedef struct H5O_hdr_info_t { - unsigned version; /* Version number of header format in file */ - unsigned nmesgs; /* Number of object header messages */ - unsigned nchunks; /* Number of object header chunks */ - unsigned flags; /* Object header status flags */ + unsigned version; /* Version number of header format in file */ + unsigned nmesgs; /* Number of object header messages */ + unsigned nchunks; /* Number of object header chunks */ + unsigned flags; /* Object header status flags */ struct { - hsize_t total; /* Total space for storing object header in file */ - hsize_t meta; /* Space within header for object header metadata information */ - hsize_t mesg; /* Space within header for actual message information */ - hsize_t free; /* Free space within object header */ + hsize_t total; /* Total space for storing object header in file */ + hsize_t meta; /* Space within header for object header metadata information */ + hsize_t mesg; /* Space within header for actual message information */ + hsize_t free; /* Free space within object header */ } space; struct { - uint64_t present; /* Flags to indicate presence of message type in header */ - uint64_t shared; /* Flags to indicate message type is shared in header */ + uint64_t present; /* Flags to indicate presence of message type in header */ + uint64_t shared; /* Flags to indicate message type is shared in header */ } mesg; } H5O_hdr_info_t; /* Data model information struct for objects */ /* (For H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx version 3) */ typedef struct H5O_info2_t { - unsigned long fileno; /* File number that object is located in */ - H5O_token_t token; /* Token representing the object */ - H5O_type_t type; /* Basic object type (group, dataset, etc.) */ - unsigned rc; /* Reference count of object */ - time_t atime; /* Access time */ - time_t mtime; /* Modification time */ - time_t ctime; /* Change time */ - time_t btime; /* Birth time */ - hsize_t num_attrs; /* # of attributes attached to object */ + unsigned long fileno; /* File number that object is located in */ + H5O_token_t token; /* Token representing the object */ + H5O_type_t type; /* Basic object type (group, dataset, etc.) */ + unsigned rc; /* Reference count of object */ + time_t atime; /* Access time */ + time_t mtime; /* Modification time */ + time_t ctime; /* Change time */ + time_t btime; /* Birth time */ + hsize_t num_attrs; /* # of attributes attached to object */ } H5O_info2_t; /* Native file format information struct for objects */ /* (For H5Oget_native_info / H5Oget_native_info_by_name / H5Oget_native_info_by_idx) */ typedef struct H5O_native_info_t { - H5O_hdr_info_t hdr; /* Object header information */ + H5O_hdr_info_t hdr; /* Object header information */ /* Extra metadata storage for obj & attributes */ struct { - H5_ih_info_t obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ - H5_ih_info_t attr; /* v2 B-tree & heap for attributes */ + H5_ih_info_t obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ + H5_ih_info_t attr; /* v2 B-tree & heap for attributes */ } meta_size; } H5O_native_info_t; @@ -155,24 +158,23 @@ typedef struct H5O_native_info_t { typedef uint32_t H5O_msg_crt_idx_t; /* Prototype for H5Ovisit/H5Ovisit_by_name() operator (version 3) */ -typedef herr_t (*H5O_iterate2_t)(hid_t obj, const char *name, const H5O_info2_t *info, - void *op_data); +typedef herr_t (*H5O_iterate2_t)(hid_t obj, const char *name, const H5O_info2_t *info, void *op_data); typedef enum H5O_mcdt_search_ret_t { - H5O_MCDT_SEARCH_ERROR = -1, /* Abort H5Ocopy */ - H5O_MCDT_SEARCH_CONT, /* Continue the global search of all committed datatypes in the destination file */ - H5O_MCDT_SEARCH_STOP /* Stop the search, but continue copying. The committed datatype will be copied but not merged. */ + H5O_MCDT_SEARCH_ERROR = -1, /* Abort H5Ocopy */ + H5O_MCDT_SEARCH_CONT, /* Continue the global search of all committed datatypes in the destination file */ + H5O_MCDT_SEARCH_STOP /* Stop the search, but continue copying. The committed datatype will be copied but + not merged. */ } H5O_mcdt_search_ret_t; -/* Callback to invoke when completing the search for a matching committed datatype from the committed dtype list */ +/* Callback to invoke when completing the search for a matching committed datatype from the committed dtype + * list */ typedef H5O_mcdt_search_ret_t (*H5O_mcdt_search_cb_t)(void *op_data); - /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -180,50 +182,48 @@ typedef H5O_mcdt_search_ret_t (*H5O_mcdt_search_cb_t)(void *op_data); extern "C" { #endif -H5_DLL hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL hid_t H5Oopen_by_token(hid_t loc_id, H5O_token_t token); -H5_DLL hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id); +H5_DLL hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id); +H5_DLL hid_t H5Oopen_by_token(hid_t loc_id, H5O_token_t token); +H5_DLL hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, hid_t lapl_id); H5_DLL htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id); H5_DLL herr_t H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields); -H5_DLL herr_t H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_t *oinfo, - unsigned fields, hid_t lapl_id); -H5_DLL herr_t H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info2_t *oinfo, - unsigned fields, hid_t lapl_id); +H5_DLL herr_t H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_t *oinfo, unsigned fields, + hid_t lapl_id); +H5_DLL herr_t H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_info2_t *oinfo, unsigned fields, + hid_t lapl_id); H5_DLL herr_t H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo, unsigned fields); H5_DLL herr_t H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo, - unsigned fields, hid_t lapl_id); -H5_DLL herr_t H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_native_info_t *oinfo, - unsigned fields, hid_t lapl_id); -H5_DLL herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, - hid_t lcpl_id, hid_t lapl_id); + unsigned fields, hid_t lapl_id); +H5_DLL herr_t H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_native_info_t *oinfo, + unsigned fields, hid_t lapl_id); +H5_DLL herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id); H5_DLL herr_t H5Oincr_refcount(hid_t object_id); H5_DLL herr_t H5Odecr_refcount(hid_t object_id); -H5_DLL herr_t H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id); +H5_DLL herr_t H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id); H5_DLL herr_t H5Oset_comment(hid_t obj_id, const char *comment); -H5_DLL herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, - const char *comment, hid_t lapl_id); +H5_DLL herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id); H5_DLL ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize); -H5_DLL ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, - char *comment, size_t bufsize, hid_t lapl_id); -H5_DLL herr_t H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate2_t op, void *op_data, unsigned fields); -H5_DLL herr_t H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, - void *op_data, unsigned fields, hid_t lapl_id); -H5_DLL herr_t H5Oclose(hid_t object_id); -H5_DLL herr_t H5Oflush(hid_t obj_id); -H5_DLL herr_t H5Orefresh(hid_t oid); -H5_DLL herr_t H5Odisable_mdc_flushes(hid_t object_id); -H5_DLL herr_t H5Oenable_mdc_flushes(hid_t object_id); -H5_DLL herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); -H5_DLL herr_t H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, - int *cmp_value); -H5_DLL herr_t H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str); -H5_DLL herr_t H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token); +H5_DLL ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, + hid_t lapl_id); +H5_DLL herr_t H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, + void *op_data, unsigned fields); +H5_DLL herr_t H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields, + hid_t lapl_id); +H5_DLL herr_t H5Oclose(hid_t object_id); +H5_DLL herr_t H5Oflush(hid_t obj_id); +H5_DLL herr_t H5Orefresh(hid_t oid); +H5_DLL herr_t H5Odisable_mdc_flushes(hid_t object_id); +H5_DLL herr_t H5Oenable_mdc_flushes(hid_t object_id); +H5_DLL herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); +H5_DLL herr_t H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value); +H5_DLL herr_t H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str); +H5_DLL herr_t H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token); /* The canonical 'undefined' token value */ #define H5O_TOKEN_UNDEF (H5OPEN H5O_TOKEN_UNDEF_g) @@ -238,70 +238,65 @@ H5_DLLVAR const H5O_token_t H5O_TOKEN_UNDEF_g; /* Macros */ /* Deprecated flags for earlier versions of H5Oget_info* */ -#define H5O_INFO_HDR 0x0008u /* Fill in the hdr field */ -#define H5O_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ +#define H5O_INFO_HDR 0x0008u /* Fill in the hdr field */ +#define H5O_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ #undef H5O_INFO_ALL -#define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE) +#define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE) /* Typedefs */ /* A struct that's part of the H5G_stat_t structure (deprecated) */ typedef struct H5O_stat_t { - hsize_t size; /* Total size of object header in file */ - hsize_t free; /* Free space within object header */ - unsigned nmesgs; /* Number of object header messages */ - unsigned nchunks; /* Number of object header chunks */ + hsize_t size; /* Total size of object header in file */ + hsize_t free; /* Free space within object header */ + unsigned nmesgs; /* Number of object header messages */ + unsigned nchunks; /* Number of object header chunks */ } H5O_stat_t; /* Information struct for object */ /* (For H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx versions 1 & 2) */ typedef struct H5O_info1_t { - unsigned long fileno; /* File number that object is located in */ - haddr_t addr; /* Object address in file */ - H5O_type_t type; /* Basic object type (group, dataset, etc.) */ - unsigned rc; /* Reference count of object */ - time_t atime; /* Access time */ - time_t mtime; /* Modification time */ - time_t ctime; /* Change time */ - time_t btime; /* Birth time */ - hsize_t num_attrs; /* # of attributes attached to object */ - H5O_hdr_info_t hdr; /* Object header information */ + unsigned long fileno; /* File number that object is located in */ + haddr_t addr; /* Object address in file */ + H5O_type_t type; /* Basic object type (group, dataset, etc.) */ + unsigned rc; /* Reference count of object */ + time_t atime; /* Access time */ + time_t mtime; /* Modification time */ + time_t ctime; /* Change time */ + time_t btime; /* Birth time */ + hsize_t num_attrs; /* # of attributes attached to object */ + H5O_hdr_info_t hdr; /* Object header information */ /* Extra metadata storage for obj & attributes */ struct { - H5_ih_info_t obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ - H5_ih_info_t attr; /* v2 B-tree & heap for attributes */ + H5_ih_info_t obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ + H5_ih_info_t attr; /* v2 B-tree & heap for attributes */ } meta_size; } H5O_info1_t; /* Prototype for H5Ovisit/H5Ovisit_by_name() operator (versions 1 & 2) */ -typedef herr_t (*H5O_iterate1_t)(hid_t obj, const char *name, const H5O_info1_t *info, - void *op_data); - +typedef herr_t (*H5O_iterate1_t)(hid_t obj, const char *name, const H5O_info1_t *info, void *op_data); /* Function prototypes */ -H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); +H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); H5_DLL herr_t H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo); -H5_DLL herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t *oinfo, - hid_t lapl_id); -H5_DLL herr_t H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, - hid_t lapl_id); +H5_DLL herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t *oinfo, hid_t lapl_id); +H5_DLL herr_t H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, hid_t lapl_id); H5_DLL herr_t H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields); -H5_DLL herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo, - unsigned fields, hid_t lapl_id); -H5_DLL herr_t H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, - unsigned fields, hid_t lapl_id); -H5_DLL herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate1_t op, void *op_data); -H5_DLL herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, - void *op_data, hid_t lapl_id); -H5_DLL herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate1_t op, void *op_data, unsigned fields); -H5_DLL herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, - void *op_data, unsigned fields, hid_t lapl_id); +H5_DLL herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo, unsigned fields, + hid_t lapl_id); +H5_DLL herr_t H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, unsigned fields, + hid_t lapl_id); +H5_DLL herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, + void *op_data); +H5_DLL herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate1_t op, void *op_data, hid_t lapl_id); +H5_DLL herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, + void *op_data, unsigned fields); +H5_DLL herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate1_t op, void *op_data, unsigned fields, + hid_t lapl_id); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -309,4 +304,3 @@ H5_DLL herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, } #endif #endif /* _H5Opublic_H */ - diff --git a/src/H5Orefcount.c b/src/H5Orefcount.c index 66b79bb..1526ac0 100644 --- a/src/H5Orefcount.c +++ b/src/H5Orefcount.c @@ -22,58 +22,54 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O__refcount_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__refcount_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_refcount_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_refcount_copy(const void *_mesg, void *_dest); +static void * H5O_refcount_copy(const void *_mesg, void *_dest); static size_t H5O_refcount_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__refcount_free(void *_mesg); -static herr_t H5O_refcount_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__refcount_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O_refcount_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__refcount_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_REFCOUNT[1] = {{ - H5O_REFCOUNT_ID, /*message id number */ - "refcount", /*message name for debugging */ - sizeof(H5O_refcount_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__refcount_decode, /*decode message */ - H5O_refcount_encode, /*encode message */ - H5O_refcount_copy, /*copy the native value */ - H5O_refcount_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__refcount_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - H5O_refcount_pre_copy_file, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__refcount_debug /*debug the message */ + H5O_REFCOUNT_ID, /*message id number */ + "refcount", /*message name for debugging */ + sizeof(H5O_refcount_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__refcount_decode, /*decode message */ + H5O_refcount_encode, /*encode message */ + H5O_refcount_copy, /*copy the native value */ + H5O_refcount_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__refcount_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + H5O_refcount_pre_copy_file, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__refcount_debug /*debug the message */ }}; /* Current version of ref. count information */ -#define H5O_REFCOUNT_VERSION 0 +#define H5O_REFCOUNT_VERSION 0 /* Declare a free list to manage the H5O_refcount_t struct */ H5FL_DEFINE_STATIC(H5O_refcount_t); - /*------------------------------------------------------------------------- * Function: H5O__refcount_decode * @@ -90,11 +86,11 @@ H5FL_DEFINE_STATIC(H5O_refcount_t); */ static void * H5O__refcount_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, + size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_refcount_t *refcount = NULL; /* Reference count */ - void *ret_value = NULL; /* Return value */ + H5O_refcount_t *refcount = NULL; /* Reference count */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -103,12 +99,12 @@ H5O__refcount_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_REFCOUNT_VERSION) + if (*p++ != H5O_REFCOUNT_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (refcount = H5FL_MALLOC(H5O_refcount_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (refcount = H5FL_MALLOC(H5O_refcount_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get ref. count for object */ UINT32DECODE(p, *refcount) @@ -117,13 +113,12 @@ H5O__refcount_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = refcount; done: - if(ret_value == NULL && refcount != NULL) + if (ret_value == NULL && refcount != NULL) refcount = H5FL_FREE(H5O_refcount_t, refcount); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__refcount_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_refcount_encode * @@ -138,9 +133,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O_refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; + const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -158,7 +154,6 @@ H5O_refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_refcount_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_refcount_copy * @@ -177,16 +172,16 @@ H5O_refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar static void * H5O_refcount_copy(const void *_mesg, void *_dest) { - const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; - H5O_refcount_t *dest = (H5O_refcount_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; + H5O_refcount_t * dest = (H5O_refcount_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(refcount); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_refcount_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_refcount_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ *dest = *refcount; @@ -198,7 +193,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_refcount_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_refcount_size * @@ -217,20 +211,19 @@ done: */ static size_t H5O_refcount_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, - const void H5_ATTR_UNUSED *_mesg) + const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value; /* Return value */ + size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = 1 /* Version */ - + 4; /* Ref. count */ + ret_value = 1 /* Version */ + + 4; /* Ref. count */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_refcount_size() */ - /*------------------------------------------------------------------------- * Function: H5O__refcount_free * @@ -255,7 +248,6 @@ H5O__refcount_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__refcount_free() */ - /*------------------------------------------------------------------------- * Function: H5O_refcount_pre_copy_file * @@ -272,7 +264,8 @@ H5O__refcount_free(void *mesg) */ static herr_t H5O_refcount_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, - hbool_t *deleted, const H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) + hbool_t *deleted, const H5O_copy_t H5_ATTR_UNUSED *cpy_info, + void H5_ATTR_UNUSED *udata) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -288,7 +281,6 @@ H5O_refcount_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UN FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_refcount_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__refcount_debug * @@ -303,10 +295,9 @@ H5O_refcount_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UN *------------------------------------------------------------------------- */ static herr_t -H5O__refcount_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__refcount_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_refcount_t *refcount = (const H5O_refcount_t *) _mesg; + const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -317,9 +308,7 @@ H5O__refcount_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of links:", (unsigned)*refcount); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of links:", (unsigned)*refcount); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__refcount_debug() */ - diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 33310dc..aad150f 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -11,75 +11,73 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5S_FRIEND /*prevent warning from including H5Spkg.h */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Spkg.h" /* Dataspaces */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5S_FRIEND /*prevent warning from including H5Spkg.h */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Spkg.h" /* Dataspaces */ /* PRIVATE PROTOTYPES */ -static void *H5O__sdspace_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__sdspace_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg); -static void *H5O_sdspace_copy(const void *_mesg, void *_dest); +static void * H5O_sdspace_copy(const void *_mesg, void *_dest); static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg); static herr_t H5O__sdspace_reset(void *_mesg); static herr_t H5O__sdspace_free(void *_mesg); -static herr_t H5O_sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata); -static herr_t H5O__sdspace_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O_sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *_udata); +static herr_t H5O__sdspace_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_SDSPACE -#define H5O_SHARED_DECODE H5O_sdspace_shared_decode -#define H5O_SHARED_DECODE_REAL H5O__sdspace_decode -#define H5O_SHARED_ENCODE H5O_sdspace_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_sdspace_encode -#define H5O_SHARED_SIZE H5O_sdspace_shared_size -#define H5O_SHARED_SIZE_REAL H5O_sdspace_size -#define H5O_SHARED_DELETE H5O__sdspace_shared_delete +#define H5O_SHARED_TYPE H5O_MSG_SDSPACE +#define H5O_SHARED_DECODE H5O_sdspace_shared_decode +#define H5O_SHARED_DECODE_REAL H5O__sdspace_decode +#define H5O_SHARED_ENCODE H5O_sdspace_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O_sdspace_encode +#define H5O_SHARED_SIZE H5O_sdspace_shared_size +#define H5O_SHARED_SIZE_REAL H5O_sdspace_size +#define H5O_SHARED_DELETE H5O__sdspace_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O__sdspace_shared_link +#define H5O_SHARED_LINK H5O__sdspace_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O__sdspace_shared_copy_file +#define H5O_SHARED_COPY_FILE H5O__sdspace_shared_copy_file #undef H5O_SHARED_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE H5O_sdspace_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O_sdspace_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#undef H5O_SHARED_POST_COPY_FILE_UPD -#define H5O_SHARED_DEBUG H5O_sdspace_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__sdspace_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#undef H5O_SHARED_POST_COPY_FILE_UPD +#define H5O_SHARED_DEBUG H5O_sdspace_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__sdspace_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{ - H5O_SDSPACE_ID, /* message id number */ - "dataspace", /* message name for debugging */ - sizeof(H5S_extent_t), /* native message size */ - H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */ - H5O_sdspace_shared_decode, /* decode message */ - H5O_sdspace_shared_encode, /* encode message */ - H5O_sdspace_copy, /* copy the native value */ - H5O_sdspace_shared_size, /* size of symbol table entry */ - H5O__sdspace_reset, /* default reset method */ - H5O__sdspace_free, /* free method */ - H5O__sdspace_shared_delete, /* file delete method */ - H5O__sdspace_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - H5O_sdspace_pre_copy_file, /* pre copy native value to file */ - H5O__sdspace_shared_copy_file,/* copy native value to file */ - H5O_sdspace_shared_post_copy_file,/* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_sdspace_shared_debug /* debug the message */ + H5O_SDSPACE_ID, /* message id number */ + "dataspace", /* message name for debugging */ + sizeof(H5S_extent_t), /* native message size */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_sdspace_shared_decode, /* decode message */ + H5O_sdspace_shared_encode, /* encode message */ + H5O_sdspace_copy, /* copy the native value */ + H5O_sdspace_shared_size, /* size of symbol table entry */ + H5O__sdspace_reset, /* default reset method */ + H5O__sdspace_free, /* free method */ + H5O__sdspace_shared_delete, /* file delete method */ + H5O__sdspace_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + H5O_sdspace_pre_copy_file, /* pre copy native value to file */ + H5O__sdspace_shared_copy_file, /* copy native value to file */ + H5O_sdspace_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O_sdspace_shared_debug /* debug the message */ }}; /* Declare external the free list for H5S_extent_t's */ @@ -88,34 +86,32 @@ H5FL_EXTERN(H5S_extent_t); /* Declare external the free list for hsize_t arrays */ H5FL_ARR_EXTERN(hsize_t); - /*-------------------------------------------------------------------------- NAME H5O__sdspace_decode PURPOSE Decode a simple dimensionality message and return a pointer to a memory - struct with the decoded information + struct with the decoded information USAGE void *H5O__sdspace_decode(f, mesg_flags, p) - H5F_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct unsigned mesg_flags; IN: Message flags to influence decoding - const uint8 *p; IN: the raw information buffer + const uint8 *p; IN: the raw information buffer RETURNS Pointer to the new message in native order on success, NULL on failure DESCRIPTION - This function decodes the "raw" disk form of a simple dimensionality + This function decodes the "raw" disk form of a simple dimensionality message into a struct in memory native format. The struct is allocated within this function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * -H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5S_extent_t *sdim = NULL;/* New extent dimensionality structure */ - unsigned flags, version; - unsigned i; /* Local counting variable */ - void *ret_value = NULL; /* Return value */ + H5S_extent_t *sdim = NULL; /* New extent dimensionality structure */ + unsigned flags, version; + unsigned i; /* Local counting variable */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -124,29 +120,29 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(NULL == (sdim = H5FL_CALLOC(H5S_extent_t))) + if (NULL == (sdim = H5FL_CALLOC(H5S_extent_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, NULL, "dataspace structure allocation failed") /* Check version */ version = *p++; - if(version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2) + if (version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in dataspace message") sdim->version = version; /* Get rank */ sdim->rank = *p++; - if(sdim->rank > H5S_MAX_RANK) + if (sdim->rank > H5S_MAX_RANK) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "simple dataspace dimensionality is too large") /* Get dataspace flags for later */ flags = *p++; /* Get or determine the type of the extent */ - if(version >= H5O_SDSPACE_VERSION_2) + if (version >= H5O_SDSPACE_VERSION_2) sdim->type = (H5S_class_t)*p++; else { /* Set the dataspace type to be simple or scalar as appropriate */ - if(sdim->rank > 0) + if (sdim->rank > 0) sdim->type = H5S_SIMPLE; else sdim->type = H5S_SCALAR; @@ -157,38 +153,38 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(sdim->type != H5S_NULL || sdim->version >= H5O_SDSPACE_VERSION_2); /* Only Version 1 has these reserved bytes */ - if(version == H5O_SDSPACE_VERSION_1) + if (version == H5O_SDSPACE_VERSION_1) p += 4; /*reserved*/ /* Decode dimension sizes */ - if(sdim->rank > 0) { - if(NULL == (sdim->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) + if (sdim->rank > 0) { + if (NULL == (sdim->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - for(i = 0; i < sdim->rank; i++) + for (i = 0; i < sdim->rank; i++) H5F_DECODE_LENGTH(f, p, sdim->size[i]); - if(flags & H5S_VALID_MAX) { - if(NULL == (sdim->max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) + if (flags & H5S_VALID_MAX) { + if (NULL == (sdim->max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - for(i = 0; i < sdim->rank; i++) - H5F_DECODE_LENGTH (f, p, sdim->max[i]); + for (i = 0; i < sdim->rank; i++) + H5F_DECODE_LENGTH(f, p, sdim->max[i]); } /* end if */ - } /* end if */ + } /* end if */ /* Compute the number of elements in the extent */ - if(sdim->type == H5S_NULL) + if (sdim->type == H5S_NULL) sdim->nelem = 0; else { - for(i = 0, sdim->nelem = 1; i < sdim->rank; i++) + for (i = 0, sdim->nelem = 1; i < sdim->rank; i++) sdim->nelem *= sdim->size[i]; } /* end else */ /* Set return value */ - ret_value = (void*)sdim; /*success*/ + ret_value = (void *)sdim; /*success*/ done: - if(!ret_value && sdim) { + if (!ret_value && sdim) { H5S__extent_release(sdim); sdim = H5FL_FREE(H5S_extent_t, sdim); } /* end if */ @@ -196,7 +192,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__sdspace_decode() */ - /*-------------------------------------------------------------------------- NAME H5O_sdspace_encode @@ -204,22 +199,22 @@ done: Encode a simple dimensionality message USAGE herr_t H5O_sdspace_encode(f, raw_size, p, mesg) - H5F_t *f; IN: pointer to the HDF5 file struct - size_t raw_size; IN: size of the raw information buffer - const uint8 *p; IN: the raw information buffer - const void *mesg; IN: Pointer to the extent dimensionality struct + H5F_t *f; IN: pointer to the HDF5 file struct + size_t raw_size; IN: size of the raw information buffer + const uint8 *p; IN: the raw information buffer + const void *mesg; IN: Pointer to the extent dimensionality struct RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function encodes the native memory form of the simple + This function encodes the native memory form of the simple dimensionality message in the "raw" disk form. MODIFICATIONS - Robb Matzke, 1998-04-09 - The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes - instead of just four bytes. + Robb Matzke, 1998-04-09 + The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes + instead of just four bytes. - Robb Matzke, 1998-07-20 + Robb Matzke, 1998-07-20 Added a version number and reformatted the message for aligment. Raymond Lu @@ -231,9 +226,9 @@ done: static herr_t H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) { - const H5S_extent_t *sdim = (const H5S_extent_t *)_mesg; - unsigned flags = 0; - unsigned u; /* Local counting variable */ + const H5S_extent_t *sdim = (const H5S_extent_t *)_mesg; + unsigned flags = 0; + unsigned u; /* Local counting variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -251,12 +246,12 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) *p++ = (uint8_t)sdim->rank; /* Flags */ - if(sdim->max) + if (sdim->max) flags |= H5S_VALID_MAX; *p++ = (uint8_t)flags; /* Dataspace type */ - if(sdim->version > H5O_SDSPACE_VERSION_1) + if (sdim->version > H5O_SDSPACE_VERSION_1) *p++ = (uint8_t)sdim->type; else { *p++ = 0; /*reserved*/ @@ -264,22 +259,21 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ - } /* end else */ + } /* end else */ /* Current & maximum dimensions */ - if(sdim->rank > 0) { - for(u = 0; u < sdim->rank; u++) + if (sdim->rank > 0) { + for (u = 0; u < sdim->rank; u++) H5F_ENCODE_LENGTH(f, p, sdim->size[u]); - if(flags & H5S_VALID_MAX) { - for(u = 0; u < sdim->rank; u++) + if (flags & H5S_VALID_MAX) { + for (u = 0; u < sdim->rank; u++) H5F_ENCODE_LENGTH(f, p, sdim->max[u]); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_sdspace_encode() */ - /*-------------------------------------------------------------------------- NAME H5O_sdspace_copy @@ -287,44 +281,43 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) Copies a message from MESG to DEST, allocating DEST if necessary. USAGE void *H5O_sdspace_copy(_mesg, _dest) - const void *_mesg; IN: Pointer to the source extent dimensionality struct - const void *_dest; IN: Pointer to the destination extent dimensionality struct + const void *_mesg; IN: Pointer to the source extent dimensionality struct + const void *_dest; IN: Pointer to the destination extent dimensionality struct RETURNS Pointer to DEST on success, NULL on failure DESCRIPTION - This function copies a native (memory) simple dimensionality message, + This function copies a native (memory) simple dimensionality message, allocating the destination structure if necessary. --------------------------------------------------------------------------*/ static void * H5O_sdspace_copy(const void *_mesg, void *_dest) { - const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg; - H5S_extent_t *dest = (H5S_extent_t *)_dest; - void *ret_value = NULL; /* Return value */ + const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg; + H5S_extent_t * dest = (H5S_extent_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(mesg); - if(!dest && NULL == (dest = H5FL_CALLOC(H5S_extent_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = H5FL_CALLOC(H5S_extent_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy extent information */ - if(H5S__extent_copy_real(dest, mesg, TRUE) < 0) + if (H5S__extent_copy_real(dest, mesg, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent") /* Set return value */ ret_value = dest; done: - if(NULL == ret_value) - if(dest && NULL == _dest) + if (NULL == ret_value) + if (dest && NULL == _dest) dest = H5FL_FREE(H5S_extent_t, dest); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_sdspace_copy() */ - /*-------------------------------------------------------------------------- NAME H5O_sdspace_size @@ -332,34 +325,34 @@ done: Return the raw message size in bytes USAGE void *H5O_sdspace_size(f, mesg) - H5F_t *f; IN: pointer to the HDF5 file struct - const void *mesg; IN: Pointer to the source extent dimensionality struct + H5F_t *f; IN: pointer to the HDF5 file struct + const void *mesg; IN: Pointer to the source extent dimensionality struct RETURNS Size of message on success, zero on failure DESCRIPTION - This function returns the size of the raw simple dimensionality message on + This function returns the size of the raw simple dimensionality message on success. (Not counting the message type or size fields, only the data portion of the message). It doesn't take into account alignment. MODIFICATIONS - Robb Matzke, 1998-04-09 - The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes - instead of just four bytes. + Robb Matzke, 1998-04-09 + The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes + instead of just four bytes. --------------------------------------------------------------------------*/ static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg) { - const H5S_extent_t *space = (const H5S_extent_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5S_extent_t *space = (const H5S_extent_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Basic information for all dataspace messages */ - ret_value = (size_t)(1 + /* Version */ - 1 + /* Rank */ - 1 + /* Flags */ - 1 + /* Dataspace type/reserved */ - ((space->version > H5O_SDSPACE_VERSION_1) ? 0 : 4)); /* Eliminated/reserved */ + ret_value = (size_t)(1 + /* Version */ + 1 + /* Rank */ + 1 + /* Flags */ + 1 + /* Dataspace type/reserved */ + ((space->version > H5O_SDSPACE_VERSION_1) ? 0 : 4)); /* Eliminated/reserved */ /* Add in the dimension sizes */ ret_value += space->rank * H5F_SIZEOF_SIZE(f); @@ -370,7 +363,6 @@ H5O_sdspace_size(const H5F_t *f, const void *_mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_sdspace_size() */ - /*------------------------------------------------------------------------- * Function: H5O__sdspace_reset * @@ -387,7 +379,7 @@ H5O_sdspace_size(const H5F_t *f, const void *_mesg) static herr_t H5O__sdspace_reset(void *_mesg) { - H5S_extent_t *mesg = (H5S_extent_t*)_mesg; + H5S_extent_t *mesg = (H5S_extent_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -396,7 +388,6 @@ H5O__sdspace_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__sdspace_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__sdsdpace_free * @@ -421,7 +412,6 @@ H5O__sdspace_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__sdspace_free() */ - /*------------------------------------------------------------------------- * Function: H5O_sdspace_pre_copy_file * @@ -439,11 +429,11 @@ H5O__sdspace_free(void *mesg) */ static herr_t H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, - hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void *_udata) + hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void *_udata) { - const H5S_extent_t *src_space_extent = (const H5S_extent_t *)mesg_src; /* Source dataspace extent */ - H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5S_extent_t *src_space_extent = (const H5S_extent_t *)mesg_src; /* Source dataspace extent */ + H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -455,7 +445,7 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version allowed by the destination file's high bound */ - if(src_space_extent->version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (src_space_extent->version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "dataspace message version out of bounds") /* If the user data is non-NULL, assume we are copying a dataset @@ -464,13 +454,13 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, * if the layout is an early version, but that information isn't * available here, so we just make a copy of it in all cases) */ - if(udata) { + if (udata) { /* Allocate copy of dataspace extent */ - if(NULL == (udata->src_space_extent = H5FL_CALLOC(H5S_extent_t))) + if (NULL == (udata->src_space_extent = H5FL_CALLOC(H5S_extent_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "dataspace extent allocation failed") /* Create a copy of the dataspace extent */ - if(H5S__extent_copy_real(udata->src_space_extent, src_space_extent, TRUE) < 0) + if (H5S__extent_copy_real(udata->src_space_extent, src_space_extent, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") } /* end if */ @@ -478,7 +468,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dspace_pre_copy_file() */ - /*-------------------------------------------------------------------------- NAME H5O__sdspace_debug @@ -486,22 +475,21 @@ done: Prints debugging information for a simple dimensionality message USAGE void *H5O__sdspace_debug(f, mesg, stream, indent, fwidth) - H5F_t *f; IN: pointer to the HDF5 file struct - const void *mesg; IN: Pointer to the source extent dimensionality struct - FILE *stream; IN: Pointer to the stream for output data - int indent; IN: Amount to indent information by - int fwidth; IN: Field width (?) + H5F_t *f; IN: pointer to the HDF5 file struct + const void *mesg; IN: Pointer to the source extent dimensionality struct + FILE *stream; IN: Pointer to the stream for output data + int indent; IN: Amount to indent information by + int fwidth; IN: Field width (?) RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function prints debugging output to the stream passed as a + This function prints debugging output to the stream passed as a parameter. --------------------------------------------------------------------------*/ static herr_t -H5O__sdspace_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE * stream, - int indent, int fwidth) +H5O__sdspace_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int indent, int fwidth) { - const H5S_extent_t *sdim = (const H5S_extent_t *)mesg; + const H5S_extent_t *sdim = (const H5S_extent_t *)mesg; FUNC_ENTER_STATIC_NOERR @@ -512,33 +500,30 @@ H5O__sdspace_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Rank:", - (unsigned long) (sdim->rank)); + HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Rank:", (unsigned long)(sdim->rank)); - if(sdim->rank > 0) { - unsigned u; /* local counting variable */ + if (sdim->rank > 0) { + unsigned u; /* local counting variable */ HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:"); - for(u = 0; u < sdim->rank; u++) - HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]); - HDfprintf (stream, "}\n"); + for (u = 0; u < sdim->rank; u++) + HDfprintf(stream, "%s%Hu", u ? ", " : "", sdim->size[u]); + HDfprintf(stream, "}\n"); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:"); - if(sdim->max) { - HDfprintf (stream, "{"); - for(u = 0; u < sdim->rank; u++) { - if(H5S_UNLIMITED==sdim->max[u]) - HDfprintf (stream, "%sUNLIM", u?", ":""); + if (sdim->max) { + HDfprintf(stream, "{"); + for (u = 0; u < sdim->rank; u++) { + if (H5S_UNLIMITED == sdim->max[u]) + HDfprintf(stream, "%sUNLIM", u ? ", " : ""); else - HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]); + HDfprintf(stream, "%s%Hu", u ? ", " : "", sdim->max[u]); } /* end for */ - HDfprintf (stream, "}\n"); + HDfprintf(stream, "}\n"); } /* end if */ else - HDfprintf (stream, "CONSTANT\n"); + HDfprintf(stream, "CONSTANT\n"); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__sdspace_debug() */ - diff --git a/src/H5Oshared.c b/src/H5Oshared.c index b49e501..d3d4983 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -28,70 +28,62 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5HFprivate.h" /* Fractal heap */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5HFprivate.h" /* Fractal heap */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* First version, with full symbol table entry as link for object header sharing */ -#define H5O_SHARED_VERSION_1 1 +#define H5O_SHARED_VERSION_1 1 /* Older version, with just address of object as link for object header sharing */ -#define H5O_SHARED_VERSION_2 2 +#define H5O_SHARED_VERSION_2 2 /* Newest version, which recognizes messages that are stored in the SOHM heap */ -#define H5O_SHARED_VERSION_3 3 -#define H5O_SHARED_VERSION_LATEST H5O_SHARED_VERSION_3 +#define H5O_SHARED_VERSION_3 3 +#define H5O_SHARED_VERSION_LATEST H5O_SHARED_VERSION_3 /* Size of stack buffer for serialized messages */ -#define H5O_MESG_BUF_SIZE 128 - +#define H5O_MESG_BUF_SIZE 128 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static void *H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, - const H5O_shared_t *shared, const H5O_msg_class_t *type); -static herr_t H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, - const H5O_msg_class_t *type, H5O_shared_t *shared, int adjust); - +static void * H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t *shared, + const H5O_msg_class_t *type); +static herr_t H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, + H5O_shared_t *shared, int adjust); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O__shared_read * @@ -109,13 +101,13 @@ static herr_t H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, *------------------------------------------------------------------------- */ static void * -H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, - const H5O_shared_t *shared, const H5O_msg_class_t *type) +H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t *shared, + const H5O_msg_class_t *type) { H5HF_t *fheap = NULL; - H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ + H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ uint8_t mesg_buf[H5O_MESG_BUF_SIZE]; /* Buffer for deserializing messages */ - void *ret_value = NULL; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -131,77 +123,77 @@ H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, HDassert(H5O_IS_STORED_SHARED(shared->type)); /* Check for implicit shared object header message */ - if(shared->type == H5O_SHARE_TYPE_SOHM) { - haddr_t fheap_addr; /* Address of SOHM heap */ - uint8_t *mesg_ptr; /* Pointer to raw message in heap */ - size_t mesg_size; /* Size of message */ + if (shared->type == H5O_SHARE_TYPE_SOHM) { + haddr_t fheap_addr; /* Address of SOHM heap */ + uint8_t *mesg_ptr; /* Pointer to raw message in heap */ + size_t mesg_size; /* Size of message */ /* Retrieve the fractal heap address for shared messages */ - if(H5SM_get_fheap_addr(f, type->id, &fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, type->id, &fheap_addr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "can't get fheap address for shared messages") /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, fheap_addr))) + if (NULL == (fheap = H5HF_open(f, fheap_addr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") /* Get the size of the message in the heap */ - if(H5HF_get_obj_len(fheap, &(shared->u.heap_id), &mesg_size) < 0) + if (H5HF_get_obj_len(fheap, &(shared->u.heap_id), &mesg_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "can't get message size from fractal heap.") /* Wrap the local buffer for serialized message */ - if(NULL == (wb = H5WB_wrap(mesg_buf, sizeof(mesg_buf)))) + if (NULL == (wb = H5WB_wrap(mesg_buf, sizeof(mesg_buf)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for message */ - if(NULL == (mesg_ptr = (uint8_t *)H5WB_actual(wb, mesg_size))) + if (NULL == (mesg_ptr = (uint8_t *)H5WB_actual(wb, mesg_size))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "can't get actual buffer") /* Retrieve the message from the heap */ - if(H5HF_read(fheap, &(shared->u.heap_id), mesg_ptr) < 0) + if (H5HF_read(fheap, &(shared->u.heap_id), mesg_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "can't read message from fractal heap.") /* Decode the message */ - if(NULL == (ret_value = (type->decode)(f, open_oh, 0, ioflags, mesg_size, mesg_ptr))) + if (NULL == (ret_value = (type->decode)(f, open_oh, 0, ioflags, mesg_size, mesg_ptr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode shared message.") } /* end if */ else { - H5O_loc_t oloc; /* Location for object header where message is stored */ + H5O_loc_t oloc; /* Location for object header where message is stored */ HDassert(shared->type == H5O_SHARE_TYPE_COMMITTED); /* Build the object location for the shared message's object header */ - oloc.file = f; - oloc.addr = shared->u.loc.oh_addr; + oloc.file = f; + oloc.addr = shared->u.loc.oh_addr; oloc.holding_file = FALSE; - if(open_oh && oloc.addr == H5O_OH_GET_ADDR(open_oh)) { + if (open_oh && oloc.addr == H5O_OH_GET_ADDR(open_oh)) { /* The shared message is in the already opened object header. This * is possible, for example, if an attribute's datatype is shared in * the same object header the attribute is in. Read the message * directly. */ - if(NULL == (ret_value = H5O_msg_read_oh(f, open_oh, type->id, NULL))) + if (NULL == (ret_value = H5O_msg_read_oh(f, open_oh, type->id, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read message") - } else + } + else /* The shared message is in another object header */ - if(NULL == (ret_value = H5O_msg_read(&oloc, type->id, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read message") + if (NULL == (ret_value = H5O_msg_read(&oloc, type->id, NULL))) + HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read message") } /* end else */ /* Mark the message as shared */ - if(H5O_msg_set_share(type->id, shared, ret_value) < 0) + if (H5O_msg_set_share(type->id, shared, ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to set sharing information") done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't close fractal heap") - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, NULL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_read() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_link_adj * @@ -223,10 +215,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, - H5O_shared_t *shared, int adjust) +H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, H5O_shared_t *shared, int adjust) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -235,8 +226,8 @@ H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, HDassert(shared); /* Check for type of shared message */ - if(shared->type == H5O_SHARE_TYPE_COMMITTED) { - H5O_loc_t oloc; /* Location for object header where message is stored */ + if (shared->type == H5O_SHARE_TYPE_COMMITTED) { + H5O_loc_t oloc; /* Location for object header where message is stored */ /* * The shared message is stored in some object header. @@ -257,46 +248,46 @@ H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "interfile hard links are not allowed")*/ /* Build the object location for the shared message's object header */ - oloc.file = f; - oloc.addr = shared->u.loc.oh_addr; + oloc.file = f; + oloc.addr = shared->u.loc.oh_addr; oloc.holding_file = FALSE; - if(open_oh && oloc.addr == H5O_OH_GET_ADDR(open_oh)) { + if (open_oh && oloc.addr == H5O_OH_GET_ADDR(open_oh)) { /* The shared message is in the already opened object header. This * is possible, for example, if an attribute's datatype is shared in * the same object header the attribute is in. Adjust the link * count directly. */ hbool_t deleted = FALSE; /* This is used only to satisfy H5O__link_oh */ - if(H5O__link_oh(f, adjust, open_oh, &deleted) < 0) + if (H5O__link_oh(f, adjust, open_oh, &deleted) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") HDassert(!deleted); - } else + } + else /* The shared message is in another object header */ - if(H5O_link(&oloc, adjust) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") + if (H5O_link(&oloc, adjust) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") } /* end if */ else { HDassert(shared->type == H5O_SHARE_TYPE_SOHM || shared->type == H5O_SHARE_TYPE_HERE); /* Check for decrementing reference count on shared message */ - if(adjust < 0) { - if(H5SM_delete(f, open_oh, shared) < 0) + if (adjust < 0) { + if (H5SM_delete(f, open_oh, shared) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to delete message from SOHM table") } /* end if */ /* Check for incrementing reference count on message */ - else if(adjust > 0) { - if(H5SM_try_share(f, open_oh, 0, type->id, shared, NULL) < 0) + else if (adjust > 0) { + if (H5SM_try_share(f, open_oh, 0, type->id, shared, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "error trying to share message") } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_link_adj() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_decode * @@ -312,11 +303,11 @@ done: */ void * H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *buf, - const H5O_msg_class_t *type) + const H5O_msg_class_t *type) { - H5O_shared_t sh_mesg; /* Shared message info */ - unsigned version; /* Shared message version */ - void *ret_value = NULL; /* Return value */ + H5O_shared_t sh_mesg; /* Shared message info */ + unsigned version; /* Shared message version */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -327,13 +318,13 @@ H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *b /* Version */ version = *buf++; - if(version < H5O_SHARED_VERSION_1 || version > H5O_SHARED_VERSION_LATEST) + if (version < H5O_SHARED_VERSION_1 || version > H5O_SHARED_VERSION_LATEST) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message") /* Get the shared information type * Flags are unused before version 3. */ - if(version >= H5O_SHARED_VERSION_2) + if (version >= H5O_SHARED_VERSION_2) sh_mesg.type = *buf++; else { sh_mesg.type = H5O_SHARE_TYPE_COMMITTED; @@ -341,23 +332,23 @@ H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *b } /* end else */ /* Skip reserved bytes (for version 1) */ - if(version == H5O_SHARED_VERSION_1) + if (version == H5O_SHARED_VERSION_1) buf += 6; /* Body */ - if(version == H5O_SHARED_VERSION_1) { + if (version == H5O_SHARED_VERSION_1) { /* Initialize other location fields */ sh_mesg.u.loc.index = 0; /* Decode stored "symbol table entry" into message location */ - buf += H5F_SIZEOF_SIZE(f); /* Skip over local heap address */ + buf += H5F_SIZEOF_SIZE(f); /* Skip over local heap address */ H5F_addr_decode(f, &buf, &(sh_mesg.u.loc.oh_addr)); } /* end if */ else if (version >= H5O_SHARED_VERSION_2) { /* If this message is in the heap, copy a heap ID. * Otherwise, it is a named datatype, so copy an H5O_loc_t. */ - if(sh_mesg.type == H5O_SHARE_TYPE_SOHM) { + if (sh_mesg.type == H5O_SHARE_TYPE_SOHM) { HDassert(version >= H5O_SHARED_VERSION_3); H5MM_memcpy(&sh_mesg.u.heap_id, buf, sizeof(sh_mesg.u.heap_id)); } /* end if */ @@ -365,27 +356,26 @@ H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *b /* The H5O_COMMITTED_FLAG should be set if this message * is from an older version before the flag existed. */ - if(version < H5O_SHARED_VERSION_3) + if (version < H5O_SHARED_VERSION_3) sh_mesg.type = H5O_SHARE_TYPE_COMMITTED; sh_mesg.u.loc.index = 0; H5F_addr_decode(f, &buf, &sh_mesg.u.loc.oh_addr); } /* end else */ - } /* end else if */ + } /* end else if */ /* Set file pointer & message type for all types of shared messages */ - sh_mesg.file = f; + sh_mesg.file = f; sh_mesg.msg_type_id = type->id; /* Retrieve actual message, through decoded shared message info */ - if(NULL == (ret_value = H5O__shared_read(f, open_oh, ioflags, &sh_mesg, type))) + if (NULL == (ret_value = H5O__shared_read(f, open_oh, ioflags, &sh_mesg, type))) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to retrieve native message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_encode * @@ -399,9 +389,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg) +H5O__shared_encode(const H5F_t *f, uint8_t *buf /*out*/, const H5O_shared_t *sh_mesg) { - unsigned version; + unsigned version; FUNC_ENTER_PACKAGE_NOERR @@ -413,12 +403,12 @@ H5O__shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_m /* If this message is shared in the heap, we need to use version 3 of the * encoding and encode the SHARED_IN_HEAP flag. */ - if(sh_mesg->type == H5O_SHARE_TYPE_SOHM) + if (sh_mesg->type == H5O_SHARE_TYPE_SOHM) version = H5O_SHARED_VERSION_LATEST; else { HDassert(sh_mesg->type == H5O_SHARE_TYPE_COMMITTED); version = H5O_SHARED_VERSION_2; /* version 1 is no longer used */ - } /* end else */ + } /* end else */ *buf++ = (uint8_t)version; *buf++ = (uint8_t)sh_mesg->type; @@ -426,7 +416,7 @@ H5O__shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_m /* Encode either the heap ID of the message or the address of the * object header that holds it. */ - if(sh_mesg->type == H5O_SHARE_TYPE_SOHM) + if (sh_mesg->type == H5O_SHARE_TYPE_SOHM) H5MM_memcpy(buf, &(sh_mesg->u.heap_id), sizeof(sh_mesg->u.heap_id)); else H5F_addr_encode(f, &buf, sh_mesg->u.loc.oh_addr); @@ -434,7 +424,6 @@ H5O__shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_m FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__shared_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_set_shared * @@ -463,7 +452,6 @@ H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_set_shared() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_size * @@ -480,26 +468,25 @@ H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src) size_t H5O__shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR - if(sh_mesg->type == H5O_SHARE_TYPE_COMMITTED) { - ret_value = (size_t)1 + /* Version */ - (size_t)1 + /* Type field */ - (size_t)H5F_SIZEOF_ADDR(f); /* Sharing by another obj hdr */ - } /* end if */ + if (sh_mesg->type == H5O_SHARE_TYPE_COMMITTED) { + ret_value = (size_t)1 + /* Version */ + (size_t)1 + /* Type field */ + (size_t)H5F_SIZEOF_ADDR(f); /* Sharing by another obj hdr */ + } /* end if */ else { HDassert(sh_mesg->type == H5O_SHARE_TYPE_SOHM); - ret_value = 1 + /* Version */ - 1 + /* Type field */ - H5O_FHEAP_ID_LEN; /* Shared in the heap */ - } /* end else */ + ret_value = 1 + /* Version */ + 1 + /* Type field */ + H5O_FHEAP_ID_LEN; /* Shared in the heap */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_size() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_delete * @@ -513,10 +500,9 @@ H5O__shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg) *------------------------------------------------------------------------- */ herr_t -H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, - H5O_shared_t *sh_mesg) +H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, H5O_shared_t *sh_mesg) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -534,14 +520,13 @@ H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, */ /* Decrement the reference count on the shared object */ - if(H5O__shared_link_adj(f, open_oh, type, sh_mesg, -1) < 0) + if (H5O__shared_link_adj(f, open_oh, type, sh_mesg, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_link * @@ -556,10 +541,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__shared_link(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, - H5O_shared_t *sh_mesg) +H5O__shared_link(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, H5O_shared_t *sh_mesg) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -568,14 +552,13 @@ H5O__shared_link(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, HDassert(sh_mesg); /* Increment the reference count on the shared object */ - if(H5O__shared_link_adj(f, open_oh, type, sh_mesg, 1) < 0) + if (H5O__shared_link_adj(f, open_oh, type, sh_mesg, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_link() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_copy_file * @@ -590,13 +573,15 @@ done: */ herr_t H5O__shared_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, H5F_t *file_dst, - const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned *mesg_flags, H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info, - void H5_ATTR_UNUSED *udata) + const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst, + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned *mesg_flags, + H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { - const H5O_shared_t *shared_src = (const H5O_shared_t *)_native_src; /* Alias to shared info in native source */ - H5O_shared_t *shared_dst = (H5O_shared_t *)_native_dst; /* Alias to shared info in native destination message */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *shared_src = + (const H5O_shared_t *)_native_src; /* Alias to shared info in native source */ + H5O_shared_t *shared_dst = + (H5O_shared_t *)_native_dst; /* Alias to shared info in native destination message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -618,12 +603,12 @@ H5O__shared_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, H5F_t *file_dst, * be updated (to allow calculation of the final size) but the message is * not actually shared. */ - if(shared_src->type != H5O_SHARE_TYPE_COMMITTED) { + if (shared_src->type != H5O_SHARE_TYPE_COMMITTED) { /* Simulate trying to share new message in the destination file. */ /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); - if(H5SM_try_share(file_dst, NULL, H5SM_DEFER, mesg_type->id, _native_dst, mesg_flags) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_DEFER, mesg_type->id, _native_dst, mesg_flags) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to determine if message should be shared") /* Reset metadata tag */ @@ -640,7 +625,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__shared_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_post_copy_file * @@ -660,11 +644,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, - const H5O_shared_t *shared_src, H5O_shared_t *shared_dst, - unsigned *mesg_flags, H5O_copy_t *cpy_info) +H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, const H5O_shared_t *shared_src, + H5O_shared_t *shared_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -674,7 +657,7 @@ H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, HDassert(shared_dst); /* Copy the target of committed messages, try to share others */ - if(shared_src->type == H5O_SHARE_TYPE_COMMITTED) { + if (shared_src->type == H5O_SHARE_TYPE_COMMITTED) { H5O_loc_t dst_oloc; H5O_loc_t src_oloc; @@ -683,7 +666,7 @@ H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, dst_oloc.file = f; src_oloc.file = shared_src->file; src_oloc.addr = shared_src->u.loc.oh_addr; - if(H5O_copy_header_map(&src_oloc, &dst_oloc, cpy_info, FALSE, NULL, NULL) < 0) + if (H5O_copy_header_map(&src_oloc, &dst_oloc, cpy_info, FALSE, NULL, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Set up destination message's shared info */ @@ -691,14 +674,13 @@ H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, } /* end if */ else /* Share the message */ - if(H5SM_try_share(f, NULL, H5SM_WAS_DEFERRED, mesg_type->id, shared_dst, mesg_flags) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't share message") + if (H5SM_try_share(f, NULL, H5SM_WAS_DEFERRED, mesg_type->id, shared_dst, mesg_flags) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't share message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_debug * @@ -722,43 +704,30 @@ H5O__shared_debug(const H5O_shared_t *mesg, FILE *stream, int indent, int fwidth HDassert(indent >= 0); HDassert(fwidth >= 0); - switch(mesg->type) { + switch (mesg->type) { case H5O_SHARE_TYPE_UNSHARED: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Shared Message type:", - "Unshared"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Shared Message type:", "Unshared"); break; case H5O_SHARE_TYPE_COMMITTED: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Shared Message type:", - "Obj Hdr"); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Object address:", - mesg->u.loc.oh_addr); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Shared Message type:", "Obj Hdr"); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Object address:", mesg->u.loc.oh_addr); break; case H5O_SHARE_TYPE_SOHM: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Shared Message type:", - "SOHM"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Shared Message type:", "SOHM"); HDfprintf(stream, "%*s%-*s %016llx\n", indent, "", fwidth, - "Heap ID:", - (unsigned long long)mesg->u.heap_id.val); + "Heap ID:", (unsigned long long)mesg->u.heap_id.val); break; case H5O_SHARE_TYPE_HERE: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Shared Message type:", - "Here"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Shared Message type:", "Here"); break; default: - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Shared Message type:", - "Unknown", (unsigned)mesg->type); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Shared Message type:", "Unknown", + (unsigned)mesg->type); } /* end switch */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__shared_debug() */ - diff --git a/src/H5Oshared.h b/src/H5Oshared.h index e4ad980..189c6be 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -27,7 +27,6 @@ #ifndef H5Oshared_H #define H5Oshared_H - /*------------------------------------------------------------------------- * Function: H5O_SHARED_DECODE * @@ -46,10 +45,10 @@ *------------------------------------------------------------------------- */ static H5_INLINE void * -H5O_SHARED_DECODE(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p) +H5O_SHARED_DECODE(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -64,22 +63,22 @@ H5O_SHARED_DECODE(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, #endif /* H5O_SHARED_DECODE_REAL */ /* Check for shared message */ - if(mesg_flags & H5O_MSG_FLAG_SHARED) { + if (mesg_flags & H5O_MSG_FLAG_SHARED) { /* Retrieve native message info indirectly through shared message */ - if(NULL == (ret_value = H5O__shared_decode(f, open_oh, ioflags, p, H5O_SHARED_TYPE))) + if (NULL == (ret_value = H5O__shared_decode(f, open_oh, ioflags, p, H5O_SHARED_TYPE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message") - /* We currently do not support automatically fixing shared messages */ + /* We currently do not support automatically fixing shared messages */ #ifdef H5_STRICT_FORMAT_CHECKS - if(*ioflags & H5O_DECODEIO_DIRTY) + if (*ioflags & H5O_DECODEIO_DIRTY) HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, "unable to mark shared message dirty") -#else /* H5_STRICT_FORMAT_CHECKS */ +#else /* H5_STRICT_FORMAT_CHECKS */ *ioflags &= ~H5O_DECODEIO_DIRTY; #endif /* H5_STRICT_FORMAT_CHECKS */ - } /* end if */ + } /* end if */ else { /* Decode native message directly */ - if(NULL == (ret_value = H5O_SHARED_DECODE_REAL(f, open_oh, mesg_flags, ioflags, p_size, p))) + if (NULL == (ret_value = H5O_SHARED_DECODE_REAL(f, open_oh, mesg_flags, ioflags, p_size, p))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode native message") } /* end else */ @@ -87,7 +86,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_DECODE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_ENCODE * @@ -108,8 +106,9 @@ done: static H5_INLINE herr_t H5O_SHARED_ENCODE(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg) { - const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *sh_mesg = + (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -127,14 +126,14 @@ H5O_SHARED_ENCODE(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mes HDassert(sh_mesg->type == H5O_SHARE_TYPE_UNSHARED || sh_mesg->msg_type_id == H5O_SHARED_TYPE->id); /* Check for message stored elsewhere */ - if(H5O_IS_STORED_SHARED(sh_mesg->type) && !disable_shared) { + if (H5O_IS_STORED_SHARED(sh_mesg->type) && !disable_shared) { /* Encode shared message into buffer */ - if(H5O__shared_encode(f, p, sh_mesg) < 0) + if (H5O__shared_encode(f, p, sh_mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode shared message") } /* end if */ else { /* Encode native message directly */ - if(H5O_SHARED_ENCODE_REAL(f, p, _mesg) < 0) + if (H5O_SHARED_ENCODE_REAL(f, p, _mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode native message") } /* end else */ @@ -142,7 +141,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_ENCODE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_SIZE * @@ -163,8 +161,9 @@ done: static H5_INLINE size_t H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg) { - const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - size_t ret_value = 0; /* Return value */ + const H5O_shared_t *sh_mesg = + (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -179,14 +178,14 @@ H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg) #endif /* H5O_SHARED_SIZE_REAL */ /* Check for message stored elsewhere */ - if(H5O_IS_STORED_SHARED(sh_mesg->type) && !disable_shared) { + if (H5O_IS_STORED_SHARED(sh_mesg->type) && !disable_shared) { /* Retrieve encoded size of shared message */ - if(0 == (ret_value = H5O__shared_size(f, sh_mesg))) + if (0 == (ret_value = H5O__shared_size(f, sh_mesg))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, 0, "unable to retrieve encoded size of shared message") } /* end if */ else { /* Retrieve size of native message directly */ - if(0 == (ret_value = H5O_SHARED_SIZE_REAL(f, _mesg))) + if (0 == (ret_value = H5O_SHARED_SIZE_REAL(f, _mesg))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, 0, "unable to retrieve encoded size of native message") } /* end else */ @@ -194,7 +193,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_SIZE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_DELETE * @@ -216,8 +214,8 @@ done: static H5_INLINE herr_t H5O_SHARED_DELETE(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -229,24 +227,23 @@ H5O_SHARED_DELETE(H5F_t *f, H5O_t *open_oh, void *_mesg) #endif /* H5O_SHARED_DELETE */ /* Check for message tracked elsewhere */ - if(H5O_IS_TRACKED_SHARED(sh_mesg->type)) { + if (H5O_IS_TRACKED_SHARED(sh_mesg->type)) { /* Decrement the reference count on the shared message/object */ - if(H5O__shared_delete(f, open_oh, H5O_SHARED_TYPE, sh_mesg) < 0) + if (H5O__shared_delete(f, open_oh, H5O_SHARED_TYPE, sh_mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for shared message") } /* end if */ #ifdef H5O_SHARED_DELETE_REAL else { /* Decrement the reference count on the native message directly */ - if(H5O_SHARED_DELETE_REAL(f, open_oh, _mesg) < 0) + if (H5O_SHARED_DELETE_REAL(f, open_oh, _mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for native message") - } /* end else */ + } /* end else */ #endif /* H5O_SHARED_DELETE_REAL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_DELETE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_LINK * @@ -268,8 +265,8 @@ done: static H5_INLINE herr_t H5O_SHARED_LINK(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -281,24 +278,23 @@ H5O_SHARED_LINK(H5F_t *f, H5O_t *open_oh, void *_mesg) #endif /* H5O_SHARED_LINK */ /* Check for message tracked elsewhere */ - if(H5O_IS_TRACKED_SHARED(sh_mesg->type)) { + if (H5O_IS_TRACKED_SHARED(sh_mesg->type)) { /* Increment the reference count on the shared message/object */ - if(H5O__shared_link(f, open_oh, H5O_SHARED_TYPE, sh_mesg) < 0) + if (H5O__shared_link(f, open_oh, H5O_SHARED_TYPE, sh_mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for shared message") } /* end if */ #ifdef H5O_SHARED_LINK_REAL else { /* Increment the reference count on the native message directly */ - if(H5O_SHARED_LINK_REAL(f, open_oh, _mesg) < 0) + if (H5O_SHARED_LINK_REAL(f, open_oh, _mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for native message") - } /* end else */ + } /* end else */ #endif /* H5O_SHARED_LINK_REAL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_LINK() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_COPY_FILE * @@ -317,12 +313,11 @@ done: *------------------------------------------------------------------------- */ static H5_INLINE void * -H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, - hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, - void *udata) +H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata) { - void *dst_mesg = NULL; /* Destination message */ - void *ret_value = NULL; /* Return value */ + void *dst_mesg = NULL; /* Destination message */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -335,11 +330,12 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, #ifdef H5O_SHARED_COPY_FILE_REAL /* Call native message's copy file callback to copy the message */ - if(NULL == (dst_mesg = H5O_SHARED_COPY_FILE_REAL(file_src, H5O_SHARED_TYPE, _native_src, file_dst, recompute_size, cpy_info, udata))) + if (NULL == (dst_mesg = H5O_SHARED_COPY_FILE_REAL(file_src, H5O_SHARED_TYPE, _native_src, file_dst, + recompute_size, cpy_info, udata))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy native message to another file") -#else /* H5O_SHARED_COPY_FILE_REAL */ +#else /* H5O_SHARED_COPY_FILE_REAL */ /* No copy file callback defined, just copy the message itself */ - if(NULL == (dst_mesg = (H5O_SHARED_TYPE->copy)(_native_src, NULL))) + if (NULL == (dst_mesg = (H5O_SHARED_TYPE->copy)(_native_src, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy native message") #endif /* H5O_SHARED_COPY_FILE_REAL */ @@ -347,22 +343,21 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, HDmemset(dst_mesg, 0, sizeof(H5O_shared_t)); /* Handle sharing destination message */ - if(H5O__shared_copy_file(file_src, file_dst, H5O_SHARED_TYPE, _native_src, - dst_mesg, recompute_size, mesg_flags, cpy_info, udata) < 0) + if (H5O__shared_copy_file(file_src, file_dst, H5O_SHARED_TYPE, _native_src, dst_mesg, recompute_size, + mesg_flags, cpy_info, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "unable to determine if message should be shared") /* Set return value */ ret_value = dst_mesg; done: - if(!ret_value) - if(dst_mesg) + if (!ret_value) + if (dst_mesg) H5O_msg_free(H5O_SHARED_TYPE->id, dst_mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_COPY_FILE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_POST_COPY_FILE * @@ -382,12 +377,12 @@ done: */ static H5_INLINE herr_t H5O_SHARED_POST_COPY_FILE(const H5O_loc_t H5_ATTR_NDEBUG_UNUSED *oloc_src, const void *mesg_src, - H5O_loc_t *oloc_dst, void *mesg_dst, unsigned *mesg_flags, - H5O_copy_t *cpy_info) + H5O_loc_t *oloc_dst, void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info) { - const H5O_shared_t *shared_src = (const H5O_shared_t *)mesg_src; /* Alias to shared info in native source */ - H5O_shared_t *shared_dst = (H5O_shared_t *)mesg_dst; /* Alias to shared info in native destination */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *shared_src = + (const H5O_shared_t *)mesg_src; /* Alias to shared info in native source */ + H5O_shared_t *shared_dst = (H5O_shared_t *)mesg_dst; /* Alias to shared info in native destination */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -406,34 +401,33 @@ H5O_SHARED_POST_COPY_FILE(const H5O_loc_t H5_ATTR_NDEBUG_UNUSED *oloc_src, const #ifdef H5O_SHARED_POST_COPY_FILE_REAL /* Call native message's post copy file callback to copy the message */ - if(H5O_SHARED_POST_COPY_FILE_REAL(oloc_src, mesg_src, oloc_dst, mesg_dst, cpy_info) <0 ) + if (H5O_SHARED_POST_COPY_FILE_REAL(oloc_src, mesg_src, oloc_dst, mesg_dst, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy native message to another file") #endif /* H5O_SHARED_POST_COPY_FILE_REAL */ /* Update shared message after the post copy - will short circuit in * production if the DEFER pass determined it will not be shared; debug mode * verifies that it is indeed the case */ - if(H5O__shared_post_copy_file(oloc_dst->file, H5O_SHARED_TYPE, - shared_src, shared_dst, mesg_flags, cpy_info) < 0) + if (H5O__shared_post_copy_file(oloc_dst->file, H5O_SHARED_TYPE, shared_src, shared_dst, mesg_flags, + cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to fix shared message in post copy") #ifdef H5O_SHARED_POST_COPY_FILE_UPD /* Call native message's post copy file update callback to update the * message */ - if(H5O_SHARED_POST_COPY_FILE_UPD(oloc_src, mesg_src, oloc_dst, mesg_dst, cpy_info) < 0) + if (H5O_SHARED_POST_COPY_FILE_UPD(oloc_src, mesg_src, oloc_dst, mesg_dst, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to update native message") #endif /* H5O_SHARED_POST_COPY_FILE_UPD */ /* Make sure that if the the source or destination is committed, both are * committed */ - HDassert((shared_src->type == H5O_SHARE_TYPE_COMMITTED) - == (shared_dst->type == H5O_SHARE_TYPE_COMMITTED)); + HDassert((shared_src->type == H5O_SHARE_TYPE_COMMITTED) == + (shared_dst->type == H5O_SHARE_TYPE_COMMITTED)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_POST_COPY_FILE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_DEBUG * @@ -452,11 +446,11 @@ done: *------------------------------------------------------------------------- */ static H5_INLINE herr_t -H5O_SHARED_DEBUG(H5F_t *f, const void *_mesg, FILE *stream, int indent, - int fwidth) +H5O_SHARED_DEBUG(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *sh_mesg = + (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -471,14 +465,14 @@ H5O_SHARED_DEBUG(H5F_t *f, const void *_mesg, FILE *stream, int indent, #endif /* H5O_SHARED_DEBUG_REAL */ /* Check for message stored elsewhere */ - if(H5O_IS_STORED_SHARED(sh_mesg->type)) { + if (H5O_IS_STORED_SHARED(sh_mesg->type)) { /* Print shared message information */ - if(H5O__shared_debug(sh_mesg, stream, indent, fwidth) < 0) + if (H5O__shared_debug(sh_mesg, stream, indent, fwidth) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display shared message info") } /* end if */ /* Call native message's debug callback */ - if(H5O_SHARED_DEBUG_REAL(f, _mesg, stream, indent, fwidth) < 0) + if (H5O_SHARED_DEBUG_REAL(f, _mesg, stream, indent, fwidth) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display native message info") done: @@ -486,4 +480,3 @@ done: } /* end H5O_SHARED_DEBUG() */ #endif /* H5Oshared_H */ - diff --git a/src/H5Oshmesg.c b/src/H5Oshmesg.c index 136268a..50f7c75 100644 --- a/src/H5Oshmesg.c +++ b/src/H5Oshmesg.c @@ -11,7 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* Programmer: James Laird * Monday, January 29, 2007 * @@ -19,47 +18,44 @@ * information in the superblock extension. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object headers */ +#include "H5MMprivate.h" /* Memory management */ -static void *H5O__shmesg_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void * H5O__shmesg_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, + size_t p_size, const uint8_t *p); static herr_t H5O_shmesg_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_shmesg_copy(const void *_mesg, void *_dest); +static void * H5O_shmesg_copy(const void *_mesg, void *_dest); static size_t H5O_shmesg_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); -static herr_t H5O__shmesg_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__shmesg_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_SHMESG[1] = {{ H5O_SHMESG_ID, /*message id number */ "shared message table", /*message name for debugging */ - sizeof(H5O_shmesg_table_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__shmesg_decode, /*decode message */ - H5O_shmesg_encode, /*encode message */ + sizeof(H5O_shmesg_table_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__shmesg_decode, /*decode message */ + H5O_shmesg_encode, /*encode message */ H5O_shmesg_copy, /*copy the native value */ - H5O_shmesg_size, /*raw message size */ + H5O_shmesg_size, /*raw message size */ NULL, /*free internal memory */ NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ H5O__shmesg_debug /*debug the message */ }}; - /*------------------------------------------------------------------------- * Function: H5O__shmesg_decode * @@ -75,12 +71,11 @@ const H5O_msg_class_t H5O_MSG_SHMESG[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O__shmesg_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__shmesg_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_shmesg_table_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_shmesg_table_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -88,8 +83,9 @@ H5O__shmesg_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(f); HDassert(p); - if(NULL == (mesg = (H5O_shmesg_table_t *)H5MM_calloc(sizeof(H5O_shmesg_table_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message") + if (NULL == (mesg = (H5O_shmesg_table_t *)H5MM_calloc(sizeof(H5O_shmesg_table_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for shared message table message") /* Retrieve version, table address, and number of indexes */ mesg->version = *p++; @@ -103,7 +99,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shmesg_decode() */ - /*------------------------------------------------------------------------- * Function: H5O_shmesg_encode * @@ -136,7 +131,6 @@ H5O_shmesg_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_shmesg_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_shmesg_copy * @@ -154,17 +148,18 @@ H5O_shmesg_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c static void * H5O_shmesg_copy(const void *_mesg, void *_dest) { - const H5O_shmesg_table_t *mesg = (const H5O_shmesg_table_t *)_mesg; - H5O_shmesg_table_t *dest = (H5O_shmesg_table_t *)_dest; - void *ret_value = NULL; /* Return value */ + const H5O_shmesg_table_t *mesg = (const H5O_shmesg_table_t *)_mesg; + H5O_shmesg_table_t * dest = (H5O_shmesg_table_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity check */ HDassert(mesg); - if(!dest && NULL == (dest = (H5O_shmesg_table_t *)H5MM_malloc(sizeof(H5O_shmesg_table_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message") + if (!dest && NULL == (dest = (H5O_shmesg_table_t *)H5MM_malloc(sizeof(H5O_shmesg_table_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for shared message table message") /* All this message requires is a shallow copy */ *dest = *mesg; @@ -176,7 +171,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_shmesg_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_shmesg_size * @@ -194,21 +188,20 @@ done: static size_t H5O_shmesg_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ HDassert(f); - ret_value = (size_t)(1 + /* Version number */ - H5F_SIZEOF_ADDR(f) + /* Table address */ - 1); /* Number of indexes */ + ret_value = (size_t)(1 + /* Version number */ + H5F_SIZEOF_ADDR(f) + /* Table address */ + 1); /* Number of indexes */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_shmesg_size() */ - /*------------------------------------------------------------------------- * Function: H5O__shmesg_debug * @@ -222,8 +215,7 @@ H5O_shmesg_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const voi *------------------------------------------------------------------------- */ static herr_t -H5O__shmesg_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__shmesg_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_shmesg_table_t *mesg = (const H5O_shmesg_table_t *)_mesg; @@ -236,13 +228,9 @@ H5O__shmesg_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Version:", mesg->version); - HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Shared message table address:", mesg->addr); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of indexes:", mesg->nindexes); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", mesg->version); + HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, "Shared message table address:", mesg->addr); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of indexes:", mesg->nindexes); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__shmesg_debug() */ - diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 0f14a4b..a1aad7d 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -22,63 +22,57 @@ *------------------------------------------------------------------------- */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Opkg.h" /* Object headers */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O__stab_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void *H5O__stab_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); static herr_t H5O__stab_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O__stab_copy(const void *_mesg, void *_dest); +static void * H5O__stab_copy(const void *_mesg, void *_dest); static size_t H5O__stab_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__stab_free(void *_mesg); static herr_t H5O__stab_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static void *H5O__stab_copy_file(H5F_t *file_src, void *native_src, - H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, - H5O_copy_t *cpy_info, void *_udata); -static herr_t H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, - const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, - unsigned *mesg_flags, H5O_copy_t *cpy_info); -static herr_t H5O__stab_debug(H5F_t *f, const void *_mesg, - FILE * stream, int indent, int fwidth); +static void * H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *_udata); +static herr_t H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, + void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info); +static herr_t H5O__stab_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_STAB[1] = {{ - H5O_STAB_ID, /*message id number */ - "stab", /*message name for debugging */ - sizeof(H5O_stab_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__stab_decode, /*decode message */ - H5O__stab_encode, /*encode message */ - H5O__stab_copy, /*copy the native value */ - H5O__stab_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__stab_free, /* free method */ - H5O__stab_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - H5O__stab_copy_file, /* copy native value to file */ - H5O__stab_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__stab_debug /*debug the message */ + H5O_STAB_ID, /*message id number */ + "stab", /*message name for debugging */ + sizeof(H5O_stab_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__stab_decode, /*decode message */ + H5O__stab_encode, /*encode message */ + H5O__stab_copy, /*copy the native value */ + H5O__stab_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__stab_free, /* free method */ + H5O__stab_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + H5O__stab_copy_file, /* copy native value to file */ + H5O__stab_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__stab_debug /*debug the message */ }}; /* Declare a free list to manage the H5O_stab_t struct */ H5FL_DEFINE_STATIC(H5O_stab_t); - /*------------------------------------------------------------------------- * Function: H5O__stab_decode * @@ -96,12 +90,11 @@ H5FL_DEFINE_STATIC(H5O_stab_t); *------------------------------------------------------------------------- */ static void * -H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_stab_t *stab = NULL; - void *ret_value = NULL; /* Return value */ + H5O_stab_t *stab = NULL; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -110,7 +103,7 @@ H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(NULL == (stab = H5FL_CALLOC(H5O_stab_t))) + if (NULL == (stab = H5FL_CALLOC(H5O_stab_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5F_addr_decode(f, &p, &(stab->btree_addr)); H5F_addr_decode(f, &p, &(stab->heap_addr)); @@ -119,15 +112,14 @@ H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = stab; done: - if(ret_value == NULL) { - if(stab != NULL) + if (ret_value == NULL) { + if (stab != NULL) stab = H5FL_FREE(H5O_stab_t, stab); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__stab_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_encode * @@ -144,7 +136,7 @@ done: static herr_t H5O__stab_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; + const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -160,7 +152,6 @@ H5O__stab_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__stab_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_copy * @@ -180,16 +171,16 @@ H5O__stab_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co static void * H5O__stab_copy(const void *_mesg, void *_dest) { - const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; - H5O_stab_t *dest = (H5O_stab_t *) _dest; - void *ret_value = NULL; /* Return value */ + const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; + H5O_stab_t * dest = (H5O_stab_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(stab); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_stab_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_stab_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *stab; @@ -201,7 +192,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__stab_copy() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_size * @@ -222,7 +212,7 @@ done: static size_t H5O__stab_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -232,7 +222,6 @@ H5O__stab_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__stab_size() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_free * @@ -257,7 +246,6 @@ H5O__stab_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__stab_free() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_delete * @@ -273,7 +261,7 @@ H5O__stab_free(void *mesg) static herr_t H5O__stab_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *mesg) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -282,14 +270,13 @@ H5O__stab_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *mesg) HDassert(mesg); /* Free the file space for the symbol table */ - if(H5G__stab_delete(f, (const H5O_stab_t *)mesg) < 0) + if (H5G__stab_delete(f, (const H5O_stab_t *)mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free symbol table") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__stab_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_copy_file * @@ -306,14 +293,14 @@ done: */ static void * H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t H5_ATTR_UNUSED *cpy_info, void *_udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t H5_ATTR_UNUSED *cpy_info, void *_udata) { - H5O_stab_t *stab_src = (H5O_stab_t *) native_src; - H5O_stab_t *stab_dst = NULL; - H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *)_udata; - size_t size_hint; /* Local heap initial size */ - void *ret_value = NULL; /* Return value */ + H5O_stab_t * stab_src = (H5O_stab_t *)native_src; + H5O_stab_t * stab_dst = NULL; + H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *)_udata; + size_t size_hint; /* Local heap initial size */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -322,40 +309,39 @@ H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, HDassert(file_dst); /* Allocate space for the destination stab */ - if(NULL == (stab_dst = H5FL_MALLOC(H5O_stab_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (stab_dst = H5FL_MALLOC(H5O_stab_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the old local heap's size and use that as the hint for the new heap */ - if(H5HL_get_size(file_src, stab_src->heap_addr, &size_hint) < 0) + if (H5HL_get_size(file_src, stab_src->heap_addr, &size_hint) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, NULL, "can't query local heap size") /* Set copy metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create components of symbol table message */ - if(H5G__stab_create_components(file_dst, stab_dst, size_hint) < 0) + if (H5G__stab_create_components(file_dst, stab_dst, size_hint) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTINIT, NULL, "can't create symbol table components") /* Reset metadata tag */ H5_END_TAG /* Cache stab in udata */ - udata->cache_type = H5G_CACHED_STAB; + udata->cache_type = H5G_CACHED_STAB; udata->cache.stab.btree_addr = stab_dst->btree_addr; - udata->cache.stab.heap_addr = stab_dst->heap_addr; + udata->cache.stab.heap_addr = stab_dst->heap_addr; /* Set return value */ ret_value = stab_dst; done: - if(!ret_value) - if(stab_dst) + if (!ret_value) + if (stab_dst) stab_dst = H5FL_FREE(H5O_stab_t, stab_dst); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__stab_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_post_copy_file * @@ -369,14 +355,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, - H5O_loc_t *dst_oloc, void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info) +H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, + unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info) { - const H5O_stab_t *stab_src = (const H5O_stab_t *)mesg_src; - H5O_stab_t *stab_dst = (H5O_stab_t *)mesg_dst; - H5G_bt_it_cpy_t udata; /* B-tree user data */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_stab_t *stab_src = (const H5O_stab_t *)mesg_src; + H5O_stab_t * stab_dst = (H5O_stab_t *)mesg_dst; + H5G_bt_it_cpy_t udata; /* B-tree user data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -388,25 +373,24 @@ H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, HDassert(cpy_info); /* If we are performing a 'shallow hierarchy' copy, get out now */ - if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) + if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) HGOTO_DONE(SUCCEED) /* Set up B-tree iteration user data */ - udata.src_oloc = src_oloc; + udata.src_oloc = src_oloc; udata.src_heap_addr = stab_src->heap_addr; - udata.dst_file = dst_oloc->file; - udata.dst_stab = stab_dst; - udata.cpy_info = cpy_info; + udata.dst_file = dst_oloc->file; + udata.dst_stab = stab_dst; + udata.cpy_info = cpy_info; /* Iterate over objects in group, copying them */ - if((H5B_iterate(src_oloc->file, H5B_SNODE, stab_src->btree_addr, H5G__node_copy, &udata)) < 0) + if ((H5B_iterate(src_oloc->file, H5B_SNODE, stab_src->btree_addr, H5G__node_copy, &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__stab_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_debug * @@ -423,10 +407,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O__stab_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__stab_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; + const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -437,12 +420,9 @@ H5O__stab_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "B-tree address:", stab->btree_addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "B-tree address:", stab->btree_addr); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Name heap address:", stab->heap_addr); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Name heap address:", stab->heap_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__stab_debug() */ - diff --git a/src/H5Otest.c b/src/H5Otest.c index df08ff7..c191125 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -21,58 +21,49 @@ /* Module Setup */ /****************/ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5O_TESTING /*suppress warning about H5O testing funcs*/ - +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5O_TESTING /*suppress warning about H5O testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*-------------------------------------------------------------------------- NAME H5O__is_attr_dense_test @@ -95,37 +86,37 @@ htri_t H5O__is_attr_dense_test(hid_t oid) { - H5O_t *oh = NULL; /* Object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t *loc; /* Pointer to object's location */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - htri_t ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + H5O_loc_t * loc; /* Pointer to object's location */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check if dense storage is being used */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check for any messages in object header */ HDassert(H5O__msg_count_real(oh, H5O_MSG_ATTR) == 0); @@ -135,15 +126,14 @@ H5O__is_attr_dense_test(hid_t oid) ret_value = FALSE; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__is_attr_dense_test() */ +} /* H5O__is_attr_dense_test() */ - /*-------------------------------------------------------------------------- NAME H5O__is_attr_empty_test @@ -165,34 +155,34 @@ done: htri_t H5O__is_attr_empty_test(hid_t oid) { - H5O_t *oh = NULL; /* Object header */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ - H5O_loc_t *loc; /* Pointer to object's location */ - hsize_t nattrs; /* Number of attributes */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - htri_t ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ + H5O_loc_t * loc; /* Pointer to object's location */ + hsize_t nattrs; /* Number of attributes */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ @@ -200,10 +190,10 @@ H5O__is_attr_empty_test(hid_t oid) nattrs = H5O__msg_count_real(oh, H5O_MSG_ATTR); /* Check for later version of object header format & attribute info available */ - if(oh->version > H5O_VERSION_1) { - if(ainfo_exists) { + if (oh->version > H5O_VERSION_1) { + if (ainfo_exists) { /* Check for using dense storage */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check for any messages in object header */ HDassert(nattrs == 0); @@ -211,15 +201,17 @@ H5O__is_attr_empty_test(hid_t oid) H5_BEGIN_TAG(loc->addr); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for name index") /* Reset metadata tag in API context */ H5_END_TAG /* Retrieve # of records in name index */ - if(H5B2_get_nrec(bt2_name, &nattrs) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") + if (H5B2_get_nrec(bt2_name, &nattrs) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, + "unable to retrieve # of records from name index") } /* end if */ /* Verify that attribute count in object header is correct */ @@ -234,17 +226,16 @@ H5O__is_attr_empty_test(hid_t oid) done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__is_attr_empty_test() */ +} /* H5O__is_attr_empty_test() */ - /*-------------------------------------------------------------------------- NAME H5O__num_attrs_test @@ -267,34 +258,34 @@ done: herr_t H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) { - H5O_t *oh = NULL; /* Object header */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t *loc; /* Pointer to object's location */ - hsize_t obj_nattrs; /* Number of attributes */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + H5O_loc_t * loc; /* Pointer to object's location */ + hsize_t obj_nattrs; /* Number of attributes */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ @@ -302,9 +293,9 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) obj_nattrs = H5O__msg_count_real(oh, H5O_MSG_ATTR); /* Check for later version of object header format */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for using dense storage */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check for any messages in object header */ HDassert(obj_nattrs == 0); @@ -312,14 +303,14 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) H5_BEGIN_TAG(loc->addr); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in API context */ H5_END_TAG /* Retrieve # of records in name index */ - if(H5B2_get_nrec(bt2_name, &obj_nattrs) < 0) + if (H5B2_get_nrec(bt2_name, &obj_nattrs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") } /* end if */ @@ -332,17 +323,16 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__num_attrs_test() */ +} /* H5O__num_attrs_test() */ - /*-------------------------------------------------------------------------- NAME H5O__attr_dense_info_test @@ -367,22 +357,22 @@ done: herr_t H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) { - H5O_t *oh = NULL; /* Object header */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t *loc; /* Pointer to object's location */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + H5O_loc_t * loc; /* Pointer to object's location */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; @@ -390,40 +380,42 @@ H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) H5_BEGIN_TAG(loc->addr); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR_TAG(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for 'dense' attribute storage file addresses being defined */ - if(!H5F_addr_defined(ainfo.fheap_addr)) + if (!H5F_addr_defined(ainfo.fheap_addr)) HGOTO_DONE_TAG(FAIL) - if(!H5F_addr_defined(ainfo.name_bt2_addr)) + if (!H5F_addr_defined(ainfo.name_bt2_addr)) HGOTO_DONE_TAG(FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ - if(H5B2_get_nrec(bt2_name, name_count) < 0) + if (H5B2_get_nrec(bt2_name, name_count) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ - if(H5F_addr_defined(ainfo.corder_bt2_addr)) { + if (H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(loc->file, ainfo.corder_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(loc->file, ainfo.corder_bt2_addr, NULL))) + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ - if(H5B2_get_nrec(bt2_corder, corder_count) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") + if (H5B2_get_nrec(bt2_corder, corder_count) < 0) + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, + "unable to retrieve # of records from creation order index") } /* end if */ else *corder_count = 0; @@ -433,19 +425,18 @@ H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__attr_dense_info_test() */ +} /* H5O__attr_dense_info_test() */ - /*-------------------------------------------------------------------------- NAME H5O__check_msg_marked_test @@ -470,45 +461,45 @@ done: herr_t H5O__check_msg_marked_test(hid_t oid, hbool_t flag_val) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t *loc; /* Pointer to object's location */ - H5O_mesg_t *idx_msg; /* Pointer to message */ - unsigned idx; /* Index of message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5O_loc_t * loc; /* Pointer to object's location */ + H5O_mesg_t *idx_msg; /* Pointer to message */ + unsigned idx; /* Index of message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Locate "unknown" message */ - for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) - if(idx_msg->type->id == H5O_UNKNOWN_ID) { + for (idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if (idx_msg->type->id == H5O_UNKNOWN_ID) { /* Check for "unknown" message having the correct flags */ - if(((idx_msg->flags & H5O_MSG_FLAG_WAS_UNKNOWN) > 0) != flag_val) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "'unknown' message has incorrect 'was unknown' flag value") + if (((idx_msg->flags & H5O_MSG_FLAG_WAS_UNKNOWN) > 0) != flag_val) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, + "'unknown' message has incorrect 'was unknown' flag value") /* Break out of loop, to indicate that the "unknown" message was found */ break; } /* end if */ /* Check for not finding an "unknown" message */ - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "'unknown' message type not found") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__check_msg_marked_test() */ +} /* H5O__check_msg_marked_test() */ - /*-------------------------------------------------------------------------- NAME H5O__expunge_chunks_test @@ -531,16 +522,16 @@ done: herr_t H5O__expunge_chunks_test(const H5O_loc_t *loc) { - H5O_t *oh = NULL; /* Object header */ - haddr_t chk_addr[16]; /* Array of chunk addresses */ - size_t nchunks; /* Number of chunks in object header */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + haddr_t chk_addr[16]; /* Array of chunk addresses */ + size_t nchunks; /* Number of chunks in object header */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Safety check */ @@ -548,24 +539,24 @@ H5O__expunge_chunks_test(const H5O_loc_t *loc) HDassert(0 < nchunks && nchunks < NELMTS(chk_addr)); /* Iterate over all the chunks, saving the chunk addresses */ - for(u = 0; u < oh->nchunks; u++) + for (u = 0; u < oh->nchunks; u++) chk_addr[u] = oh->chunk[u].addr; /* Release the object header */ - if(H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header") /* Iterate over all the saved chunk addresses, evicting them from the cache */ /* (in reverse order, so that chunk #0 is unpinned) */ - for(u = nchunks - 1; u < nchunks; u--) - if(H5AC_expunge_entry(loc->file, (u == 0 ? H5AC_OHDR : H5AC_OHDR_CHK), chk_addr[u], H5AC__NO_FLAGS_SET) < 0) + for (u = nchunks - 1; u < nchunks; u--) + if (H5AC_expunge_entry(loc->file, (u == 0 ? H5AC_OHDR : H5AC_OHDR_CHK), chk_addr[u], + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTEXPUNGE, FAIL, "unable to expunge object header chunk") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__expunge_chunks_test() */ +} /* H5O__expunge_chunks_test() */ - /*-------------------------------------------------------------------------- NAME H5O__get_rc_test @@ -589,7 +580,7 @@ done: herr_t H5O__get_rc_test(const H5O_loc_t *loc, unsigned *rc) { - H5O_t *oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -599,7 +590,7 @@ H5O__get_rc_test(const H5O_loc_t *loc, unsigned *rc) HDassert(rc); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Save the refcount for the object header */ @@ -607,13 +598,12 @@ H5O__get_rc_test(const H5O_loc_t *loc, unsigned *rc) done: /* Release the object header */ - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__get_rc_test() */ +} /* H5O__get_rc_test() */ - /*-------------------------------------------------------------------------- NAME H5O__msg_get_chunkno_test @@ -638,31 +628,31 @@ done: herr_t H5O__msg_get_chunkno_test(hid_t oid, unsigned msg_type, unsigned *chunk_num) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t *loc; /* Pointer to object's location */ - H5O_mesg_t *idx_msg; /* Pointer to message */ - unsigned idx; /* Index of message */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5O_loc_t * loc; /* Pointer to object's location */ + H5O_mesg_t *idx_msg; /* Pointer to message */ + unsigned idx; /* Index of message */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Locate first message of given type */ - for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) - if(idx_msg->type->id == msg_type) { + for (idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if (idx_msg->type->id == msg_type) { /* Set the chunk number for the message */ *chunk_num = idx_msg->chunkno; @@ -671,19 +661,18 @@ H5O__msg_get_chunkno_test(hid_t oid, unsigned msg_type, unsigned *chunk_num) } /* end if */ /* Check for not finding a message of the given type*/ - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message of type not found") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__msg_get_chunkno_test() */ +} /* H5O__msg_get_chunkno_test() */ - /*-------------------------------------------------------------------------- NAME H5O__msg_move_to_new_chunk_test @@ -706,76 +695,80 @@ done: herr_t H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t *loc; /* Pointer to object's location */ - H5O_mesg_t *curr_msg; /* Pointer to current message */ - unsigned idx; /* Index of message */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Object header */ + H5O_loc_t * loc; /* Pointer to object's location */ + H5O_mesg_t *curr_msg; /* Pointer to current message */ + unsigned idx; /* Index of message */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Locate first message of given type */ - for(idx = 0, curr_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, curr_msg++) - if(curr_msg->type->id == msg_type) { - H5O_msg_alloc_info_t found_msg; /* Information about message to move */ - unsigned msg_chunkno = curr_msg->chunkno; /* Chunk that the message is in */ - uint8_t *end_chunk_data = (oh->chunk[msg_chunkno].image + oh->chunk[msg_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[msg_chunkno].gap); /* End of message data in chunk */ - uint8_t *end_msg = curr_msg->raw + curr_msg->raw_size; /* End of current message */ - size_t gap_size = 0; /* Size of gap after current message */ - size_t null_size = 0; /* Size of NULL message after current message */ - unsigned null_msgno = 0; /* Index of NULL message after current message */ - size_t total_size; /* Total size of available space "around" current message */ - size_t new_idx; /* Index of new null message */ + for (idx = 0, curr_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, curr_msg++) + if (curr_msg->type->id == msg_type) { + H5O_msg_alloc_info_t found_msg; /* Information about message to move */ + unsigned msg_chunkno = curr_msg->chunkno; /* Chunk that the message is in */ + uint8_t * end_chunk_data = + (oh->chunk[msg_chunkno].image + oh->chunk[msg_chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[msg_chunkno].gap); /* End of message data in chunk */ + uint8_t *end_msg = curr_msg->raw + curr_msg->raw_size; /* End of current message */ + size_t gap_size = 0; /* Size of gap after current message */ + size_t null_size = 0; /* Size of NULL message after current message */ + unsigned null_msgno = 0; /* Index of NULL message after current message */ + size_t total_size; /* Total size of available space "around" current message */ + size_t new_idx; /* Index of new null message */ /* Check if the message is the last one in the chunk */ - if(end_msg == end_chunk_data) + if (end_msg == end_chunk_data) gap_size = oh->chunk[msg_chunkno].gap; else { - H5O_mesg_t *tmp_msg; /* Temp. pointer to message to operate on */ - unsigned v; /* Local index variable */ + H5O_mesg_t *tmp_msg; /* Temp. pointer to message to operate on */ + unsigned v; /* Local index variable */ /* Check for null message after this message, in same chunk */ - for(v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { - if(tmp_msg->type->id == H5O_NULL_ID && (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { + for (v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { + if (tmp_msg->type->id == H5O_NULL_ID && + (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { null_msgno = v; - null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; + null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; break; } /* end if */ /* XXX: Should also check for NULL message in front of current message... */ } /* end for */ - } /* end else */ + } /* end else */ /* Add up current message's total available space */ total_size = curr_msg->raw_size + gap_size + null_size; /* Set up "found message" info for moving the message */ - found_msg.msgno = (int)idx; - found_msg.id = curr_msg->type->id; - found_msg.chunkno = msg_chunkno; - found_msg.gap_size = gap_size; - found_msg.null_size = null_size; + found_msg.msgno = (int)idx; + found_msg.id = curr_msg->type->id; + found_msg.chunkno = msg_chunkno; + found_msg.gap_size = gap_size; + found_msg.null_size = null_size; found_msg.total_size = total_size; found_msg.null_msgno = null_msgno; /* Allocate and initialize new chunk in the file, moving the found message */ /* (*new_idx returned from this routine is unused here) */ - if(H5O__alloc_chunk(loc->file, oh, (curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)), oh->nmesgs, &found_msg, &new_idx) < 0) + if (H5O__alloc_chunk(loc->file, oh, (curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)), + oh->nmesgs, &found_msg, &new_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate new object header chunk") /* Break out of loop, the message was found */ @@ -783,11 +776,10 @@ H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type) } /* end if */ done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__msg_get_chunkno_test() */ - +} /* H5O__msg_get_chunkno_test() */ diff --git a/src/H5Ounknown.c b/src/H5Ounknown.c index 89c00ad..57d1be6 100644 --- a/src/H5Ounknown.c +++ b/src/H5Ounknown.c @@ -22,46 +22,43 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ static herr_t H5O__unknown_free(void *_mesg); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_UNKNOWN[1] = {{ - H5O_UNKNOWN_ID, /*message id number */ - "unknown", /*message name for debugging */ - 0, /*native message size */ - 0, /* messages are sharable? */ - NULL, /*decode message */ - NULL, /*encode message */ - NULL, /*copy the native value */ - NULL, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__unknown_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - NULL /*debug the message */ + H5O_UNKNOWN_ID, /*message id number */ + "unknown", /*message name for debugging */ + 0, /*native message size */ + 0, /* messages are sharable? */ + NULL, /*decode message */ + NULL, /*encode message */ + NULL, /*copy the native value */ + NULL, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__unknown_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + NULL /*debug the message */ }}; /* Declare a free list to manage the H5O_unknown_t struct */ H5FL_DEFINE(H5O_unknown_t); - /*------------------------------------------------------------------------- * Function: H5O__unknown_free * @@ -85,4 +82,3 @@ H5O__unknown_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__unknown_free() */ - diff --git a/src/H5P.c b/src/H5P.c index 9bc293b..d43dd5e 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -20,40 +20,36 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Typedef for property iterator callback */ typedef struct { - H5P_iterate_t iter_func; /* Iterator callback */ - hid_t id; /* Property list or class ID */ - void *iter_data; /* Iterator callback pointer */ + H5P_iterate_t iter_func; /* Iterator callback */ + hid_t id; /* Property list or class ID */ + void * iter_data; /* Iterator callback pointer */ } H5P_iter_ud_t; - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -61,17 +57,14 @@ typedef struct { /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*-------------------------------------------------------------------------- NAME H5Pcopy @@ -96,46 +89,46 @@ hbool_t H5_PKG_INIT_VAR = FALSE; hid_t H5Pcopy(hid_t id) { - void *obj; /* Property object to copy */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + void *obj; /* Property object to copy */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", id); - if(H5P_DEFAULT == id) + if (H5P_DEFAULT == id) HGOTO_DONE(H5P_DEFAULT); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not property object"); - if(NULL == (obj = H5I_object(id))) + if (NULL == (obj = H5I_object(id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "property object doesn't exist"); /* Compare property lists */ - if(H5I_GENPROP_LST == H5I_get_type(id)) { - if((ret_value = H5P_copy_plist((H5P_genplist_t *)obj, TRUE)) < 0) + if (H5I_GENPROP_LST == H5I_get_type(id)) { + if ((ret_value = H5P_copy_plist((H5P_genplist_t *)obj, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "can't copy property list"); } /* end if */ /* Must be property classes */ else { - H5P_genclass_t *copy_class; /* Copy of class */ + H5P_genclass_t *copy_class; /* Copy of class */ /* Copy the class */ - if((copy_class = H5P__copy_pclass((H5P_genclass_t *)obj)) == NULL) + if ((copy_class = H5P__copy_pclass((H5P_genclass_t *)obj)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "can't copy property class"); /* Get an atom for the copied class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, copy_class, TRUE)) < 0) { + if ((ret_value = H5I_register(H5I_GENPROP_CLS, copy_class, TRUE)) < 0) { H5P__close_class(copy_class); - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, + "unable to atomize property list class"); } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pcopy() */ +} /* H5Pcopy() */ - /*-------------------------------------------------------------------------- NAME H5Pcreate_class @@ -171,52 +164,49 @@ done: REVISION LOG --------------------------------------------------------------------------*/ hid_t -H5Pcreate_class(hid_t parent, const char *name, - H5P_cls_create_func_t cls_create, void *create_data, - H5P_cls_copy_func_t cls_copy, void *copy_data, - H5P_cls_close_func_t cls_close, void *close_data - ) +H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func_t cls_create, void *create_data, + H5P_cls_copy_func_t cls_copy, void *copy_data, H5P_cls_close_func_t cls_close, + void *close_data) { - H5P_genclass_t *par_class = NULL; /* Pointer to the parent class */ - H5P_genclass_t *pclass = NULL; /* Property list class created */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genclass_t *par_class = NULL; /* Pointer to the parent class */ + H5P_genclass_t *pclass = NULL; /* Property list class created */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE8("i", "i*sx*xx*xx*x", parent, name, cls_create, create_data, cls_copy, copy_data, cls_close, close_data); /* Check arguments. */ - if(H5P_DEFAULT!=parent && (H5I_GENPROP_CLS!=H5I_get_type(parent))) + if (H5P_DEFAULT != parent && (H5I_GENPROP_CLS != H5I_get_type(parent))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list class") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid class name") - if((create_data != NULL && cls_create == NULL) - || (copy_data != NULL && cls_copy == NULL) - || (close_data != NULL && cls_close == NULL)) + if ((create_data != NULL && cls_create == NULL) || (copy_data != NULL && cls_copy == NULL) || + (close_data != NULL && cls_close == NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "data specified, but no callback provided") /* Get the pointer to the parent class */ - if(parent == H5P_DEFAULT) + if (parent == H5P_DEFAULT) par_class = NULL; - else if(NULL == (par_class = (H5P_genclass_t *)H5I_object(parent))) + else if (NULL == (par_class = (H5P_genclass_t *)H5I_object(parent))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't retrieve parent class") /* Create the new property list class */ - if(NULL == (pclass = H5P__create_class(par_class, name, H5P_TYPE_USER, cls_create, create_data, cls_copy, copy_data, cls_close, close_data))) + if (NULL == (pclass = H5P__create_class(par_class, name, H5P_TYPE_USER, cls_create, create_data, cls_copy, + copy_data, cls_close, close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list class") /* Get an atom for the class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class") done: - if(H5I_INVALID_HID == ret_value && pclass) + if (H5I_INVALID_HID == ret_value && pclass) H5P__close_class(pclass); FUNC_LEAVE_API(ret_value) -} /* H5Pcreate_class() */ +} /* H5Pcreate_class() */ - /*-------------------------------------------------------------------------- NAME H5Pcreate @@ -242,25 +232,24 @@ done: hid_t H5Pcreate(hid_t cls_id) { - H5P_genclass_t *pclass; /* Property list class to modify */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genclass_t *pclass; /* Property list class to modify */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", cls_id); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list class"); /* Create the new property list */ - if((ret_value = H5P_create_id(pclass, TRUE)) < 0) + if ((ret_value = H5P_create_id(pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pcreate() */ +} /* H5Pcreate() */ - /*-------------------------------------------------------------------------- NAME H5Pregister2 @@ -416,52 +405,51 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pregister2(hid_t cls_id, const char *name, size_t size, void *def_value, - H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, - H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, - H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, - H5P_prp_close_func_t prp_close) +H5Pregister2(hid_t cls_id, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create, + H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, + H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { - H5P_genclass_t *pclass; /* Property list class to modify */ + H5P_genclass_t *pclass; /* Property list class to modify */ H5P_genclass_t *orig_pclass; /* Original property class */ - herr_t ret_value; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE11("e", "i*sz*xxxxxxxx", cls_id, name, size, def_value, prp_create, prp_set, prp_get, prp_delete, prp_copy, prp_cmp, prp_close); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid class name") - if(size > 0 && def_value == NULL) + if (size > 0 && def_value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default") /* Create the new property list class */ orig_pclass = pclass; - if((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy, prp_cmp, prp_close)) < 0) + if ((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL, + prp_delete, prp_copy, prp_cmp, prp_close)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in class") /* Check if the property class changed and needs to be substituted in the ID */ - if(pclass != orig_pclass) { - H5P_genclass_t *old_pclass; /* Old property class */ + if (pclass != orig_pclass) { + H5P_genclass_t *old_pclass; /* Old property class */ /* Substitute the new property class in the ID */ - if(NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass))) + if (NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass))) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to substitute property class in ID") HDassert(old_pclass == orig_pclass); /* Close the previous class */ - if(H5P__close_class(old_pclass) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "unable to close original property class after substitution") + if (H5P__close_class(old_pclass) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, + "unable to close original property class after substitution") } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pregister2() */ +} /* H5Pregister2() */ - /*-------------------------------------------------------------------------- NAME H5Pinsert2 @@ -602,36 +590,34 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pinsert2(hid_t plist_id, const char *name, size_t size, void *value, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, - H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) +H5Pinsert2(hid_t plist_id, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, + H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, + H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { - H5P_genplist_t *plist; /* Property list to modify */ - herr_t ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list to modify */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE10("e", "i*sz*xxxxxxx", plist_id, name, size, value, prp_set, prp_get, prp_delete, prp_copy, prp_cmp, prp_close); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name") - if(size > 0 && value == NULL) + if (size > 0 && value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default") /* Create the new property list class */ - if((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, - NULL, NULL, prp_delete, prp_copy, prp_cmp, prp_close)) < 0) + if ((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy, + prp_cmp, prp_close)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in plist") done: FUNC_LEAVE_API(ret_value) -} /* H5Pinsert2() */ +} /* H5Pinsert2() */ - /*-------------------------------------------------------------------------- NAME H5Pset @@ -666,29 +652,28 @@ done: herr_t H5Pset(hid_t plist_id, const char *name, const void *value) { - H5P_genplist_t *plist; /* Property list to modify */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list to modify */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*x", plist_id, name, value); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); - if(value == NULL) + if (value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalied property value"); /* Go set the value */ - if(H5P_set(plist, name, value) < 0) + if (H5P_set(plist, name, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to set value in plist"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pset() */ +} /* H5Pset() */ - /*-------------------------------------------------------------------------- NAME H5Pexist @@ -714,41 +699,39 @@ done: htri_t H5Pexist(hid_t id, const char *name) { - H5P_genplist_t *plist; /* Property list to query */ - H5P_genclass_t *pclass; /* Property class to query */ - htri_t ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + H5P_genclass_t *pclass; /* Property class to query */ + htri_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "i*s", id, name); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Check for the existance of the property in the list or class */ - if(H5I_GENPROP_LST == H5I_get_type(id)) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(id))) + if (H5I_GENPROP_LST == H5I_get_type(id)) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if((ret_value = H5P_exist_plist(plist, name)) < 0) + if ((ret_value = H5P_exist_plist(plist, name)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in list"); } /* end if */ + else if (H5I_GENPROP_CLS == H5I_get_type(id)) { + if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); + if ((ret_value = H5P__exist_pclass(pclass, name)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in class"); + } /* end if */ else - if(H5I_GENPROP_CLS == H5I_get_type(id)) { - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); - if((ret_value = H5P__exist_pclass(pclass, name)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in class"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pexist() */ +} /* H5Pexist() */ - /*-------------------------------------------------------------------------- NAME H5Pget_size @@ -775,46 +758,44 @@ done: herr_t H5Pget_size(hid_t id, const char *name, size_t *size) { - H5P_genclass_t *pclass; /* Property class to query */ - H5P_genplist_t *plist; /* Property list to query */ - herr_t ret_value; /* return value */ + H5P_genclass_t *pclass; /* Property class to query */ + H5P_genplist_t *plist; /* Property list to query */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*z", id, name, size); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); - if(size==NULL) + if (size == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property size"); - if(H5I_GENPROP_LST == H5I_get_type(id)) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(id))) + if (H5I_GENPROP_LST == H5I_get_type(id)) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Check the property size */ - if((ret_value = H5P__get_size_plist(plist, name, size)) < 0) + if ((ret_value = H5P__get_size_plist(plist, name, size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist"); } /* end if */ - else - if(H5I_GENPROP_CLS == H5I_get_type(id)) { - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + else if (H5I_GENPROP_CLS == H5I_get_type(id)) { + if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - /* Check the property size */ - if((ret_value = H5P__get_size_pclass(pclass, name, size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + /* Check the property size */ + if ((ret_value = H5P__get_size_pclass(pclass, name, size)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist"); + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pget_size() */ +} /* H5Pget_size() */ - /*-------------------------------------------------------------------------- NAME H5Pencode2 @@ -842,29 +823,28 @@ done: herr_t H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*x*zi", plist_id, buf, nalloc, fapl_id); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Call the internal encode routine */ - if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) + if ((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pencode2() */ +} /* H5Pencode2() */ - /*-------------------------------------------------------------------------- NAME H5Pdecode @@ -891,20 +871,19 @@ done: hid_t H5Pdecode(const void *buf) { - hid_t ret_value = H5I_INVALID_HID; /* return value */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*x", buf); /* Call the internal decode routine */ - if((ret_value = H5P__decode(buf)) < 0) + if ((ret_value = H5P__decode(buf)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, H5I_INVALID_HID, "unable to decode property list"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pdecode() */ +} /* H5Pdecode() */ - /*-------------------------------------------------------------------------- NAME H5Pget_class @@ -928,37 +907,36 @@ done: hid_t H5Pget_class(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list to query */ - H5P_genclass_t *pclass=NULL; /* Property list class */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + H5P_genclass_t *pclass = NULL; /* Property list class */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", plist_id); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list"); /* Retrieve the property list class */ - if((pclass = H5P_get_class(plist)) == NULL) + if ((pclass = H5P_get_class(plist)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "unable to query class of property list"); /* Increment the outstanding references to the class object */ - if(H5P__access_class(pclass, H5P_MOD_INC_REF) < 0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID,"Can't increment class ID ref count"); + if (H5P__access_class(pclass, H5P_MOD_INC_REF) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't increment class ID ref count"); /* Get an atom for the class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class"); done: - if(H5I_INVALID_HID == ret_value && pclass) + if (H5I_INVALID_HID == ret_value && pclass) H5P__close_class(pclass); FUNC_LEAVE_API(ret_value) -} /* H5Pget_class() */ +} /* H5Pget_class() */ - /*-------------------------------------------------------------------------- NAME H5Pget_nprops @@ -985,40 +963,38 @@ done: herr_t H5Pget_nprops(hid_t id, size_t *nprops) { - H5P_genplist_t *plist; /* Property list to query */ - H5P_genclass_t *pclass; /* Property class to query */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + H5P_genclass_t *pclass; /* Property class to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*z", id, nprops); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); - if(nprops==NULL) + if (nprops == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property nprops pointer"); - if(H5I_GENPROP_LST == H5I_get_type(id)) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(id))) + if (H5I_GENPROP_LST == H5I_get_type(id)) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(H5P__get_nprops_plist(plist, nprops) < 0) + if (H5P__get_nprops_plist(plist, nprops) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in plist"); } /* end if */ + else if (H5I_GENPROP_CLS == H5I_get_type(id)) { + if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); + if (H5P_get_nprops_pclass(pclass, nprops, FALSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in pclass"); + } /* end if */ else - if(H5I_GENPROP_CLS == H5I_get_type(id)) { - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); - if(H5P_get_nprops_pclass(pclass, nprops, FALSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in pclass"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pget_nprops() */ +} /* H5Pget_nprops() */ - /*-------------------------------------------------------------------------- NAME H5Pequal @@ -1042,26 +1018,26 @@ done: htri_t H5Pequal(hid_t id1, hid_t id2) { - void *obj1, *obj2; /* Property objects to compare */ - htri_t ret_value = FALSE; /* return value */ + void * obj1, *obj2; /* Property objects to compare */ + htri_t ret_value = FALSE; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", id1, id2); /* Check arguments. */ - if((H5I_GENPROP_LST != H5I_get_type(id1) && H5I_GENPROP_CLS != H5I_get_type(id1)) - || (H5I_GENPROP_LST != H5I_get_type(id2) && H5I_GENPROP_CLS != H5I_get_type(id2))) + if ((H5I_GENPROP_LST != H5I_get_type(id1) && H5I_GENPROP_CLS != H5I_get_type(id1)) || + (H5I_GENPROP_LST != H5I_get_type(id2) && H5I_GENPROP_CLS != H5I_get_type(id2))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property objects") - if(H5I_get_type(id1) != H5I_get_type(id2)) + if (H5I_get_type(id1) != H5I_get_type(id2)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not the same kind of property objects") - if(NULL == (obj1 = H5I_object(id1)) || NULL == (obj2 = H5I_object(id2))) + if (NULL == (obj1 = H5I_object(id1)) || NULL == (obj2 = H5I_object(id2))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist") /* Compare property lists */ - if(H5I_GENPROP_LST == H5I_get_type(id1)) { + if (H5I_GENPROP_LST == H5I_get_type(id1)) { int cmp_ret = 0; - if(H5P__cmp_plist((const H5P_genplist_t *)obj1, (const H5P_genplist_t *)obj2, &cmp_ret) < 0) + if (H5P__cmp_plist((const H5P_genplist_t *)obj1, (const H5P_genplist_t *)obj2, &cmp_ret) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOMPARE, FAIL, "can't compare property lists") /* Set return value */ @@ -1069,15 +1045,14 @@ H5Pequal(hid_t id1, hid_t id2) } /* end if */ /* Must be property classes */ else { - if(H5P__cmp_class((const H5P_genclass_t *)obj1, (const H5P_genclass_t *)obj2) == 0) + if (H5P__cmp_class((const H5P_genclass_t *)obj1, (const H5P_genclass_t *)obj2) == 0) ret_value = TRUE; } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pequal() */ +} /* H5Pequal() */ - /*-------------------------------------------------------------------------- NAME H5Pisa_class @@ -1104,26 +1079,25 @@ done: htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id) { - htri_t ret_value; /* return value */ + htri_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", plist_id, pclass_id); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(plist_id)) + if (H5I_GENPROP_LST != H5I_get_type(plist_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(H5I_GENPROP_CLS != H5I_get_type(pclass_id)) + if (H5I_GENPROP_CLS != H5I_get_type(pclass_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Compare the property list's class against the other class */ - if((ret_value = H5P_isa_class(plist_id, pclass_id)) < 0) + if ((ret_value = H5P_isa_class(plist_id, pclass_id)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pisa_class() */ +} /* H5Pisa_class() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_cb @@ -1148,8 +1122,8 @@ property list or class. static int H5P__iterate_cb(H5P_genprop_t *prop, void *_udata) { - H5P_iter_ud_t *udata = (H5P_iter_ud_t *)_udata; /* Pointer to user data */ - int ret_value = 0; /* Return value */ + H5P_iter_ud_t *udata = (H5P_iter_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1163,7 +1137,6 @@ H5P__iterate_cb(H5P_genprop_t *prop, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__iterate_cb() */ - /*-------------------------------------------------------------------------- NAME H5Piterate @@ -1220,46 +1193,46 @@ iteration, the function's behavior is undefined. int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) { - H5P_iter_ud_t udata; /* User data for internal iterator callback */ - int fake_idx = 0; /* Index when user doesn't provide one */ - void *obj; /* Property object to copy */ - int ret_value; /* return value */ + H5P_iter_ud_t udata; /* User data for internal iterator callback */ + int fake_idx = 0; /* Index when user doesn't provide one */ + void * obj; /* Property object to copy */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Is", "i*Isx*x", id, idx, iter_func, iter_data); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); - if(NULL == (obj = H5I_object(id))) + if (NULL == (obj = H5I_object(id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); - if(iter_func == NULL) + if (iter_func == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration callback"); /* Set up user data */ udata.iter_func = iter_func; - udata.id = id; + udata.id = id; udata.iter_data = iter_data; - if(H5I_GENPROP_LST == H5I_get_type(id)) { + if (H5I_GENPROP_LST == H5I_get_type(id)) { /* Iterate over a property list */ - if((ret_value = H5P__iterate_plist((H5P_genplist_t *)obj, TRUE, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) + if ((ret_value = H5P__iterate_plist((H5P_genplist_t *)obj, TRUE, (idx ? idx : &fake_idx), + H5P__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list"); } /* end if */ + else if (H5I_GENPROP_CLS == H5I_get_type(id)) { + /* Iterate over a property class */ + if ((ret_value = H5P__iterate_pclass((H5P_genclass_t *)obj, (idx ? idx : &fake_idx), H5P__iterate_cb, + &udata)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class"); + } /* end if */ else - if(H5I_GENPROP_CLS == H5I_get_type(id)) { - /* Iterate over a property class */ - if((ret_value = H5P__iterate_pclass((H5P_genclass_t *)obj, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value) -} /* H5Piterate() */ +} /* H5Piterate() */ - /*-------------------------------------------------------------------------- NAME H5Pget @@ -1291,29 +1264,28 @@ done: herr_t H5Pget(hid_t plist_id, const char *name, void *value) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*x", plist_id, name, value); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); - if(value==NULL) + if (value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalied property value"); /* Go get the value */ - if(H5P_get(plist,name,value) < 0) + if (H5P_get(plist, name, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pget() */ +} /* H5Pget() */ - /*-------------------------------------------------------------------------- NAME H5Premove @@ -1343,27 +1315,26 @@ done: herr_t H5Premove(hid_t plist_id, const char *name) { - H5P_genplist_t *plist; /* Property list to modify */ - herr_t ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list to modify */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, name); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Create the new property list class */ - if((ret_value = H5P_remove(plist, name)) < 0) + if ((ret_value = H5P_remove(plist, name)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property"); done: FUNC_LEAVE_API(ret_value) -} /* H5Premove() */ +} /* H5Premove() */ - /*-------------------------------------------------------------------------- NAME H5Pcopy_prop @@ -1405,41 +1376,40 @@ done: herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name) { - H5I_type_t src_id_type, dst_id_type; /* ID types */ - herr_t ret_value = SUCCEED; /* return value */ + H5I_type_t src_id_type, dst_id_type; /* ID types */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*s", dst_id, src_id, name); /* Check arguments. */ - if((src_id_type = H5I_get_type(src_id)) < 0) + if ((src_id_type = H5I_get_type(src_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid source ID") - if((dst_id_type = H5I_get_type(dst_id)) < 0) + if ((dst_id_type = H5I_get_type(dst_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid destination ID") - if((H5I_GENPROP_LST != src_id_type && H5I_GENPROP_CLS != src_id_type) - || (H5I_GENPROP_LST != dst_id_type && H5I_GENPROP_CLS != dst_id_type)) + if ((H5I_GENPROP_LST != src_id_type && H5I_GENPROP_CLS != src_id_type) || + (H5I_GENPROP_LST != dst_id_type && H5I_GENPROP_CLS != dst_id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property objects") - if(src_id_type != dst_id_type) + if (src_id_type != dst_id_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not the same kind of property objects") - if(!name || !*name) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") /* Compare property lists */ - if(H5I_GENPROP_LST == src_id_type) { - if(H5P__copy_prop_plist(dst_id, src_id, name) < 0) + if (H5I_GENPROP_LST == src_id_type) { + if (H5P__copy_prop_plist(dst_id, src_id, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property between lists") } /* end if */ /* Must be property classes */ else { - if(H5P__copy_prop_pclass(dst_id, src_id, name) < 0) + if (H5P__copy_prop_pclass(dst_id, src_id, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property between classes") } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pcopy_prop() */ +} /* H5Pcopy_prop() */ - /*-------------------------------------------------------------------------- NAME H5Punregister @@ -1464,27 +1434,26 @@ done: herr_t H5Punregister(hid_t pclass_id, const char *name) { - H5P_genclass_t *pclass; /* Property list class to modify */ - herr_t ret_value; /* return value */ + H5P_genclass_t *pclass; /* Property list class to modify */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", pclass_id, name); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Remove the property list from class */ - if((ret_value = H5P__unregister(pclass, name)) < 0) + if ((ret_value = H5P__unregister(pclass, name)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to remove property from class"); done: FUNC_LEAVE_API(ret_value) -} /* H5Punregister() */ +} /* H5Punregister() */ - /*-------------------------------------------------------------------------- NAME H5Pclose @@ -1509,27 +1478,26 @@ done: herr_t H5Pclose(hid_t plist_id) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Allow default property lists to pass through without throwing an error */ - if(H5P_DEFAULT != plist_id) { + if (H5P_DEFAULT != plist_id) { /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(plist_id)) + if (H5I_GENPROP_LST != H5I_get_type(plist_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Close the property list */ - if(H5I_dec_app_ref(plist_id) < 0) + if (H5I_dec_app_ref(plist_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close") } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pclose() */ +} /* H5Pclose() */ - /*-------------------------------------------------------------------------- NAME H5Pget_class_name @@ -1553,25 +1521,24 @@ done: char * H5Pget_class_name(hid_t pclass_id) { - H5P_genclass_t *pclass; /* Property class to query */ - char *ret_value; /* return value */ + H5P_genclass_t *pclass; /* Property class to query */ + char * ret_value; /* return value */ FUNC_ENTER_API(NULL) H5TRACE1("*s", "i", pclass_id); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class"); /* Get the property list class name */ - if((ret_value = H5P_get_class_name(pclass)) == NULL) + if ((ret_value = H5P_get_class_name(pclass)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "unable to query name of class"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pget_class_name() */ +} /* H5Pget_class_name() */ - /*-------------------------------------------------------------------------- NAME H5Pget_class_parent @@ -1594,37 +1561,36 @@ done: hid_t H5Pget_class_parent(hid_t pclass_id) { - H5P_genclass_t *pclass; /* Property class to query */ - H5P_genclass_t *parent = NULL; /* Parent's property class */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genclass_t *pclass; /* Property class to query */ + H5P_genclass_t *parent = NULL; /* Parent's property class */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", pclass_id); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property class") /* Retrieve the property class's parent */ - if(NULL == (parent = H5P__get_class_parent(pclass))) + if (NULL == (parent = H5P__get_class_parent(pclass))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "unable to query class of property list") /* Increment the outstanding references to the class object */ - if(H5P__access_class(parent, H5P_MOD_INC_REF) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID,"Can't increment class ID ref count") + if (H5P__access_class(parent, H5P_MOD_INC_REF) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't increment class ID ref count") /* Get an atom for the class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, parent, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_GENPROP_CLS, parent, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class") done: - if(H5I_INVALID_HID == ret_value && parent) + if (H5I_INVALID_HID == ret_value && parent) H5P__close_class(parent); FUNC_LEAVE_API(ret_value) -} /* H5Pget_class_parent() */ +} /* H5Pget_class_parent() */ - /*-------------------------------------------------------------------------- NAME H5Pclose_class @@ -1646,20 +1612,19 @@ done: herr_t H5Pclose_class(hid_t cls_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", cls_id); /* Check arguments */ - if(H5I_GENPROP_CLS != H5I_get_type(cls_id)) + if (H5I_GENPROP_CLS != H5I_get_type(cls_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Close the property list class */ - if(H5I_dec_app_ref(cls_id) < 0) + if (H5I_dec_app_ref(cls_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close") done: FUNC_LEAVE_API(ret_value) -} /* H5Pclose_class() */ - +} /* H5Pclose_class() */ diff --git a/src/H5PB.c b/src/H5PB.c index 66e0687..4c49fb7 100644 --- a/src/H5PB.c +++ b/src/H5PB.c @@ -14,8 +14,8 @@ /*------------------------------------------------------------------------- * * Created: H5PB2.c - * - * Purpose: Re-implementation of the page buffer with added features to + * + * Purpose: Re-implementation of the page buffer with added features to * support VFD SWMR. * JRM -- 10/11/18 * @@ -26,24 +26,22 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /* suppress error about including H5Fpkg */ -#include "H5PBmodule.h" /* This source code file is part of the +#define H5F_FRIEND /* suppress error about including H5Fpkg */ +#include "H5PBmodule.h" /* This source code file is part of the * H5PB module */ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PBpkg.h" /* File access */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PBpkg.h" /* File access */ /****************/ /* Local Macros */ @@ -59,7 +57,7 @@ /* Round _x up to nearest _size. */ #ifndef roundup -#define roundup(_x, _size) ((((_x) + (_size) - 1) / (_size)) * (_size)) +#define roundup(_x, _size) ((((_x) + (_size)-1) / (_size)) * (_size)) #endif /******************/ @@ -67,8 +65,8 @@ /******************/ typedef struct _metadata_section { - haddr_t addr; - size_t len; + haddr_t addr; + size_t len; const char *buf; } metadata_section_t; @@ -76,16 +74,14 @@ typedef struct _metadata_section { /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static H5PB_entry_t * H5PB__allocate_page(H5PB_t *pb_ptr, size_t buf_size, - hbool_t clean_image); +static H5PB_entry_t *H5PB__allocate_page(H5PB_t *pb_ptr, size_t buf_size, hbool_t clean_image); -static herr_t H5PB__create_new_page(H5PB_t *pb_ptr, haddr_t addr, size_t size, - H5FD_mem_t type, hbool_t clean_image, H5PB_entry_t **entry_ptr_ptr); +static herr_t H5PB__create_new_page(H5PB_t *pb_ptr, haddr_t addr, size_t size, H5FD_mem_t type, + hbool_t clean_image, H5PB_entry_t **entry_ptr_ptr); static void H5PB__deallocate_page(H5PB_entry_t *entry_ptr); @@ -93,8 +89,7 @@ static herr_t H5PB__evict_entry(H5F_shared_t *, H5PB_entry_t *, hbool_t, hbool_t static herr_t H5PB__flush_entry(H5F_shared_t *, H5PB_t *, H5PB_entry_t *); -static herr_t H5PB__load_page(H5F_shared_t *, H5PB_t *, haddr_t, - H5FD_mem_t, H5PB_entry_t **); +static herr_t H5PB__load_page(H5F_shared_t *, H5PB_t *, haddr_t, H5FD_mem_t, H5PB_entry_t **); static herr_t H5PB__make_space(H5F_shared_t *, H5PB_t *, H5FD_mem_t); @@ -102,18 +97,13 @@ static herr_t H5PB__mark_entry_clean(H5PB_t *, H5PB_entry_t *); static herr_t H5PB__mark_entry_dirty(H5F_shared_t *, H5PB_t *, H5PB_entry_t *); -static herr_t H5PB__read_meta(H5F_shared_t *, H5FD_mem_t, haddr_t, - size_t, void *); +static herr_t H5PB__read_meta(H5F_shared_t *, H5FD_mem_t, haddr_t, size_t, void *); -static herr_t H5PB__read_raw(H5F_shared_t *, H5FD_mem_t, haddr_t, - size_t, void *); +static herr_t H5PB__read_raw(H5F_shared_t *, H5FD_mem_t, haddr_t, size_t, void *); -static herr_t H5PB__write_meta(H5F_shared_t *, H5FD_mem_t, haddr_t, - size_t, const void *); - -static herr_t H5PB__write_raw(H5F_shared_t *, H5FD_mem_t, haddr_t, - size_t, const void *); +static herr_t H5PB__write_meta(H5F_shared_t *, H5FD_mem_t, haddr_t, size_t, const void *); +static herr_t H5PB__write_raw(H5F_shared_t *, H5FD_mem_t, haddr_t, size_t, const void *); static void H5PB_log_access_by_size_counts(const H5PB_t *); @@ -124,24 +114,20 @@ static void H5PB_log_access_by_size_counts(const H5PB_t *); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /* Declare a free list to manage the H5PB_t struct */ H5FL_DEFINE_STATIC(H5PB_t); /* Declare a free list to manage the H5PB_entry_t struct */ H5FL_DEFINE_STATIC(H5PB_entry_t); - /*------------------------------------------------------------------------- * * Function: H5PB_reset_stats @@ -167,7 +153,7 @@ H5PB_reset_stats(H5PB_t *pb_ptr) HDassert(pb_ptr); HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); - for ( i = 0; i < H5PB__NUM_STAT_TYPES; i++ ) { + for (i = 0; i < H5PB__NUM_STAT_TYPES; i++) { pb_ptr->bypasses[i] = 0; pb_ptr->accesses[i] = 0; @@ -179,7 +165,7 @@ H5PB_reset_stats(H5PB_t *pb_ptr) pb_ptr->evictions[i] = 0; pb_ptr->clears[i] = 0; } - + pb_ptr->max_lru_len = 0; pb_ptr->max_lru_size = 0; pb_ptr->lru_md_skips = 0; @@ -212,35 +198,34 @@ H5PB_reset_stats(H5PB_t *pb_ptr) FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5PB_reset_stats() */ +} /* H5PB_reset_stats() */ - /*------------------------------------------------------------------------- * Function: H5PB_get_stats * * Purpose: This function was created without documentation. * What follows is my best understanding of Mohamad's intent. * - * Retrieve statistics collected about page accesses for the + * Retrieve statistics collected about page accesses for the * page buffer layer. * - * --accesses: the number of metadata and raw data accesses + * --accesses: the number of metadata and raw data accesses * to the page buffer layer * - * --hits: the number of metadata and raw data hits in + * --hits: the number of metadata and raw data hits in * the page buffer layer * - * --misses: the number of metadata and raw data misses in + * --misses: the number of metadata and raw data misses in * the page buffer layer * - * --evictions: the number of metadata and raw data evictions + * --evictions: the number of metadata and raw data evictions * from the page buffer layer * - * --bypasses: the number of metadata and raw data accesses + * --bypasses: the number of metadata and raw data accesses * that bypass the page buffer layer * * TODO: The available stats have changed considerably - * since Mohamad wrote this routine. Update + * since Mohamad wrote this routine. Update * the function once things settle down. * * JRM -- 4/13/20 @@ -252,34 +237,33 @@ H5PB_reset_stats(H5PB_t *pb_ptr) *------------------------------------------------------------------------- */ herr_t -H5PB_get_stats(const H5PB_t *pb_ptr, unsigned accesses[2], unsigned hits[2], - unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]) +H5PB_get_stats(const H5PB_t *pb_ptr, unsigned accesses[2], unsigned hits[2], unsigned misses[2], + unsigned evictions[2], unsigned bypasses[2]) { FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(pb_ptr); - accesses[0] = (unsigned)pb_ptr->accesses[0]; - accesses[1] = (unsigned)pb_ptr->accesses[1]; - accesses[2] = (unsigned)pb_ptr->accesses[2]; - hits[0] = (unsigned)pb_ptr->hits[0]; - hits[1] = (unsigned)pb_ptr->hits[1]; - hits[2] = (unsigned)pb_ptr->hits[2]; - misses[0] = (unsigned)pb_ptr->misses[0]; - misses[1] = (unsigned)pb_ptr->misses[1]; - misses[2] = (unsigned)pb_ptr->misses[2]; + accesses[0] = (unsigned)pb_ptr->accesses[0]; + accesses[1] = (unsigned)pb_ptr->accesses[1]; + accesses[2] = (unsigned)pb_ptr->accesses[2]; + hits[0] = (unsigned)pb_ptr->hits[0]; + hits[1] = (unsigned)pb_ptr->hits[1]; + hits[2] = (unsigned)pb_ptr->hits[2]; + misses[0] = (unsigned)pb_ptr->misses[0]; + misses[1] = (unsigned)pb_ptr->misses[1]; + misses[2] = (unsigned)pb_ptr->misses[2]; evictions[0] = (unsigned)pb_ptr->evictions[0]; evictions[1] = (unsigned)pb_ptr->evictions[1]; evictions[2] = (unsigned)pb_ptr->evictions[2]; - bypasses[0] = (unsigned)pb_ptr->bypasses[0]; - bypasses[1] = (unsigned)pb_ptr->bypasses[1]; - bypasses[2] = (unsigned)pb_ptr->bypasses[2]; + bypasses[0] = (unsigned)pb_ptr->bypasses[0]; + bypasses[1] = (unsigned)pb_ptr->bypasses[1]; + bypasses[2] = (unsigned)pb_ptr->bypasses[2]; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5PB_get_stats */ +} /* H5PB_get_stats */ - /*------------------------------------------------------------------------- * * Function: H5PB_print_stats() @@ -299,9 +283,9 @@ H5PB_get_stats(const H5PB_t *pb_ptr, unsigned accesses[2], unsigned hits[2], herr_t H5PB_print_stats(const H5PB_t *pb_ptr) { - double ave_succ_search_depth = 0.0L; - double ave_failed_search_depth = 0.0L; - double ave_delayed_write = 0.0L; + double ave_succ_search_depth = 0.0L; + double ave_failed_search_depth = 0.0L; + double ave_delayed_write = 0.0L; double ave_delayed_write_ins_depth = 0.0L; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -312,128 +296,115 @@ H5PB_print_stats(const H5PB_t *pb_ptr) HDfprintf(stdout, "\n\nPage Buffer Statistics (raw/meta/mpmde): \n\n"); HDfprintf(stdout, "bypasses = %lld (%lld/%lld/%lld)\n", - (pb_ptr->bypasses[0] + pb_ptr->bypasses[1] + pb_ptr->bypasses[2]), - pb_ptr->bypasses[0], pb_ptr->bypasses[1], pb_ptr->bypasses[2]); + (pb_ptr->bypasses[0] + pb_ptr->bypasses[1] + pb_ptr->bypasses[2]), pb_ptr->bypasses[0], + pb_ptr->bypasses[1], pb_ptr->bypasses[2]); HDfprintf(stdout, "acesses = %lld (%lld/%lld/%lld)\n", - (pb_ptr->accesses[0] + pb_ptr->accesses[1] + pb_ptr->accesses[2]), - pb_ptr->accesses[0], pb_ptr->accesses[1], pb_ptr->accesses[2]); + (pb_ptr->accesses[0] + pb_ptr->accesses[1] + pb_ptr->accesses[2]), pb_ptr->accesses[0], + pb_ptr->accesses[1], pb_ptr->accesses[2]); HDfprintf(stdout, "hits = %lld (%lld/%lld/%lld)\n", - (pb_ptr->hits[0] + pb_ptr->hits[1] + pb_ptr->hits[2]), - pb_ptr->hits[0], pb_ptr->hits[1], pb_ptr->hits[2]); + (pb_ptr->hits[0] + pb_ptr->hits[1] + pb_ptr->hits[2]), pb_ptr->hits[0], pb_ptr->hits[1], + pb_ptr->hits[2]); HDfprintf(stdout, "misses = %lld (%lld/%lld/%lld)\n", - (pb_ptr->misses[0] + pb_ptr->misses[1] + pb_ptr->misses[2]), - pb_ptr->misses[0], pb_ptr->misses[1], pb_ptr->misses[2]); + (pb_ptr->misses[0] + pb_ptr->misses[1] + pb_ptr->misses[2]), pb_ptr->misses[0], + pb_ptr->misses[1], pb_ptr->misses[2]); HDfprintf(stdout, "loads = %lld (%lld/%lld/%lld)\n", - (pb_ptr->loads[0] + pb_ptr->loads[1] + pb_ptr->loads[2]), - pb_ptr->loads[0], pb_ptr->loads[1], pb_ptr->loads[2]); + (pb_ptr->loads[0] + pb_ptr->loads[1] + pb_ptr->loads[2]), pb_ptr->loads[0], pb_ptr->loads[1], + pb_ptr->loads[2]); HDfprintf(stdout, "insertions = %lld (%lld/%lld/%lld)\n", - (pb_ptr->insertions[0] + pb_ptr->insertions[1] + - pb_ptr->insertions[2]), - pb_ptr->insertions[0], pb_ptr->insertions[1], - pb_ptr->insertions[2]); + (pb_ptr->insertions[0] + pb_ptr->insertions[1] + pb_ptr->insertions[2]), pb_ptr->insertions[0], + pb_ptr->insertions[1], pb_ptr->insertions[2]); HDfprintf(stdout, "flushes = %lld (%lld/%lld/%lld)\n", - (pb_ptr->flushes[0] + pb_ptr->flushes[1] + pb_ptr->flushes[2]), - pb_ptr->flushes[0], pb_ptr->flushes[1], pb_ptr->flushes[2]); + (pb_ptr->flushes[0] + pb_ptr->flushes[1] + pb_ptr->flushes[2]), pb_ptr->flushes[0], + pb_ptr->flushes[1], pb_ptr->flushes[2]); HDfprintf(stdout, "evictions = %lld (%lld/%lld/%lld)\n", - (pb_ptr->evictions[0] + pb_ptr->evictions[1] + - pb_ptr->evictions[2]), - pb_ptr->evictions[0], pb_ptr->evictions[1], pb_ptr->evictions[2]); + (pb_ptr->evictions[0] + pb_ptr->evictions[1] + pb_ptr->evictions[2]), pb_ptr->evictions[0], + pb_ptr->evictions[1], pb_ptr->evictions[2]); HDfprintf(stdout, "clears = %lld (%lld/%lld/%lld)\n", - (pb_ptr->clears[0] + pb_ptr->clears[1] + pb_ptr->clears[2]), - pb_ptr->clears[0], pb_ptr->clears[1], pb_ptr->clears[2]); - - HDfprintf(stdout, "max LRU len / size = %lld / %lld\n", - pb_ptr->max_lru_len, pb_ptr->max_lru_size); + (pb_ptr->clears[0] + pb_ptr->clears[1] + pb_ptr->clears[2]), pb_ptr->clears[0], + pb_ptr->clears[1], pb_ptr->clears[2]); + + HDfprintf(stdout, "max LRU len / size = %lld / %lld\n", pb_ptr->max_lru_len, pb_ptr->max_lru_size); - HDfprintf(stdout, - "LRU make space md/rd/tl skips = %lld/%lld/%lld\n", - pb_ptr->lru_md_skips, pb_ptr->lru_rd_skips, - pb_ptr->lru_tl_skips); + HDfprintf(stdout, "LRU make space md/rd/tl skips = %lld/%lld/%lld\n", pb_ptr->lru_md_skips, + pb_ptr->lru_rd_skips, pb_ptr->lru_tl_skips); - HDfprintf(stdout, "hash table insertions / deletions = %lld / %lld\n", - pb_ptr->total_ht_insertions, pb_ptr->total_ht_deletions); + HDfprintf(stdout, "hash table insertions / deletions = %lld / %lld\n", pb_ptr->total_ht_insertions, + pb_ptr->total_ht_deletions); - if ( pb_ptr->successful_ht_searches > 0 ) { + if (pb_ptr->successful_ht_searches > 0) { - ave_succ_search_depth = - (double)(pb_ptr->total_successful_ht_search_depth) / - (double)(pb_ptr->successful_ht_searches); + ave_succ_search_depth = + (double)(pb_ptr->total_successful_ht_search_depth) / (double)(pb_ptr->successful_ht_searches); } - HDfprintf(stdout, "successful ht searches / ave depth = %lld / %llf\n", - pb_ptr->successful_ht_searches, ave_succ_search_depth); + HDfprintf(stdout, "successful ht searches / ave depth = %lld / %llf\n", pb_ptr->successful_ht_searches, + ave_succ_search_depth); - if ( pb_ptr->failed_ht_searches > 0 ) { + if (pb_ptr->failed_ht_searches > 0) { - ave_failed_search_depth = - (double)(pb_ptr->total_failed_ht_search_depth) / - (double)(pb_ptr->failed_ht_searches); + ave_failed_search_depth = + (double)(pb_ptr->total_failed_ht_search_depth) / (double)(pb_ptr->failed_ht_searches); } - HDfprintf(stdout, "failed ht searches / ave depth = %lld / %llf\n", - pb_ptr->failed_ht_searches, ave_failed_search_depth); + HDfprintf(stdout, "failed ht searches / ave depth = %lld / %llf\n", pb_ptr->failed_ht_searches, + ave_failed_search_depth); - HDfprintf(stdout, "max index length / size = %lld / %lld\n", - pb_ptr->max_index_len, pb_ptr->max_index_size); + HDfprintf(stdout, "max index length / size = %lld / %lld\n", pb_ptr->max_index_len, + pb_ptr->max_index_size); - HDfprintf(stdout, "max rd / md / mpmde entries = %lld / %lld / %lld\n", - pb_ptr->max_rd_pages, pb_ptr->max_md_pages, - pb_ptr->max_mpmde_count); + HDfprintf(stdout, "max rd / md / mpmde entries = %lld / %lld / %lld\n", pb_ptr->max_rd_pages, + pb_ptr->max_md_pages, pb_ptr->max_mpmde_count); - HDfprintf(stdout, "tick list max len / size = %lld / %lld\n", - pb_ptr->max_tl_len, pb_ptr->max_tl_size); + HDfprintf(stdout, "tick list max len / size = %lld / %lld\n", pb_ptr->max_tl_len, pb_ptr->max_tl_size); - HDfprintf(stdout, "delayed write list max len / size = %lld / %lld\n", - pb_ptr->max_dwl_len, pb_ptr->max_dwl_size); + HDfprintf(stdout, "delayed write list max len / size = %lld / %lld\n", pb_ptr->max_dwl_len, + pb_ptr->max_dwl_size); - if ( pb_ptr->delayed_writes > 0 ) { + if (pb_ptr->delayed_writes > 0) { - ave_delayed_write = (double)(pb_ptr->total_delay) / - (double)(pb_ptr->delayed_writes); - ave_delayed_write_ins_depth = (double)(pb_ptr->total_dwl_ins_depth) / - (double)(pb_ptr->delayed_writes); + ave_delayed_write = (double)(pb_ptr->total_delay) / (double)(pb_ptr->delayed_writes); + ave_delayed_write_ins_depth = + (double)(pb_ptr->total_dwl_ins_depth) / (double)(pb_ptr->delayed_writes); } - HDfprintf(stdout, - "delayed writes / ave delay / ave ins depth = %lld / %llf / %llf\n", - pb_ptr->delayed_writes, ave_delayed_write, ave_delayed_write_ins_depth); + HDfprintf(stdout, "delayed writes / ave delay / ave ins depth = %lld / %llf / %llf\n", + pb_ptr->delayed_writes, ave_delayed_write, ave_delayed_write_ins_depth); - HDfprintf(stdout, "metadata read / write splits = %lld / %lld.\n", - pb_ptr->md_read_splits, pb_ptr->md_write_splits); + HDfprintf(stdout, "metadata read / write splits = %lld / %lld.\n", pb_ptr->md_read_splits, + pb_ptr->md_write_splits); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5PB_print_stats */ - /*------------------------------------------------------------------------- * * Function: H5PB_add_new_page * - * Purpose: Insert a new blank page to the page buffer if the page + * Purpose: Insert a new blank page to the page buffer if the page * buffer is configured to allow pages of the specified * type. * - * This function is called by the MF layer when a new page - * is allocated to indicate to the page buffer layer that - * a read of the page from the file is not necessary since + * This function is called by the MF layer when a new page + * is allocated to indicate to the page buffer layer that + * a read of the page from the file is not necessary since * it's an empty page. * * For purposes of the VFD SWMR writer, we also track pages - * that are inserted via this call, as the fact that the + * that are inserted via this call, as the fact that the * page was allocated implies that an earlier version does * not exist in the HDF5 file, and thus we need not concern - * ourselves with delaying the write of this pages to avoid + * ourselves with delaying the write of this pages to avoid * messages from the future on the reader. * - * Note that this function inserts the new page without - * attempting to make space. This can result in the page + * Note that this function inserts the new page without + * attempting to make space. This can result in the page * buffer exceeding its maximum size. * * Note also that it is possible that the page (marked clean) @@ -443,20 +414,20 @@ H5PB_print_stats(const H5PB_t *pb_ptr) * * Programmer: John Mainzer -- 10/12/18 * - * Changes: Modified function to function to prevent the insertion + * Changes: Modified function to function to prevent the insertion * of raw data pages when operating in VFD SWMR mode. * * JRM -- 3/25/20 * *------------------------------------------------------------------------- */ -herr_t +herr_t H5PB_add_new_page(H5F_shared_t *shared, H5FD_mem_t type, haddr_t page_addr) { - hbool_t can_insert = TRUE; - H5PB_t *pb_ptr = NULL; - H5PB_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t can_insert = TRUE; + H5PB_t * pb_ptr = NULL; + H5PB_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -468,30 +439,26 @@ H5PB_add_new_page(H5F_shared_t *shared, H5FD_mem_t type, haddr_t page_addr) HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); - if ( H5FD_MEM_DRAW == type ) { /* raw data page insertion */ + if (H5FD_MEM_DRAW == type) { /* raw data page insertion */ - if ( ( pb_ptr->min_md_pages == pb_ptr->max_pages ) || - ( pb_ptr->vfd_swmr ) ) { + if ((pb_ptr->min_md_pages == pb_ptr->max_pages) || (pb_ptr->vfd_swmr)) { can_insert = FALSE; - } - } else { /* metadata page insertion */ + } + else { /* metadata page insertion */ - if ( pb_ptr->min_rd_pages == pb_ptr->max_pages ) { + if (pb_ptr->min_rd_pages == pb_ptr->max_pages) { can_insert = FALSE; } } - if ( can_insert ) { + if (can_insert) { - if ( H5PB__create_new_page(pb_ptr, page_addr, - (size_t)(pb_ptr->page_size), - type, TRUE, &entry_ptr) < 0 ) + if (H5PB__create_new_page(pb_ptr, page_addr, (size_t)(pb_ptr->page_size), type, TRUE, &entry_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "new page buffer page creation failed.") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "new page buffer page creation failed.") /* make note that this page was allocated, not loaded from file */ entry_ptr->loaded = FALSE; @@ -506,7 +473,6 @@ done: } /* H5PB_add_new_page */ - /*------------------------------------------------------------------------- * * Function: H5PB_create @@ -517,9 +483,9 @@ done: * * Programmer: John Mainzer -- 10/11/18 * - * Changes: Added initialization for the vfd_swmr field. Also + * Changes: Added initialization for the vfd_swmr field. Also * added code to force min_rd_pages to 0 if vfd_swrm is - * TRUE. Do this since we now exclude raw data from the + * TRUE. Do this since we now exclude raw data from the * page buffer when operating in VFD SWMR mode. * * JRM -- 3/28/20 @@ -527,16 +493,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5PB_create(H5F_shared_t *shared, size_t size, unsigned page_buf_min_meta_perc, +H5PB_create(H5F_shared_t *shared, size_t size, unsigned page_buf_min_meta_perc, unsigned page_buf_min_raw_perc) { - hbool_t vfd_swmr = FALSE; + hbool_t vfd_swmr = FALSE; hbool_t vfd_swmr_writer = FALSE; - int i; + int i; int32_t min_md_pages; int32_t min_rd_pages; - H5PB_t *pb_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5PB_t *pb_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -547,12 +513,11 @@ H5PB_create(H5F_shared_t *shared, size_t size, unsigned page_buf_min_meta_perc, HDassert((page_buf_min_meta_perc + page_buf_min_raw_perc) <= 100); /* Check args */ - if ( shared->fs_strategy != H5F_FSPACE_STRATEGY_PAGE ) + if (shared->fs_strategy != H5F_FSPACE_STRATEGY_PAGE) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, \ - "Enabling Page Buffering requires PAGE file space strategy") + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "Enabling Page Buffering requires PAGE file space strategy") - else if ( size > shared->fs_page_size ) { + else if (size > shared->fs_page_size) { /* round size down to the next multiple of fs_page_size */ @@ -563,26 +528,21 @@ H5PB_create(H5F_shared_t *shared, size_t size, unsigned page_buf_min_meta_perc, H5_CHECKED_ASSIGN(size, size_t, temp_size, hsize_t); } /* end if */ - else if ( 0 != size % shared->fs_page_size ) + else if (0 != size % shared->fs_page_size) - HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTINIT, FAIL, \ - "Page Buffer size must be >= to the page size") + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTINIT, FAIL, "Page Buffer size must be >= to the page size") /* Calculate the minimum page count for metadata and raw data - * based on the fractions provided + * based on the fractions provided */ - min_md_pages = (int32_t)((size * page_buf_min_meta_perc) / - (shared->fs_page_size * 100)); - min_rd_pages = (int32_t)((size * page_buf_min_raw_perc) / - (shared->fs_page_size * 100)); + min_md_pages = (int32_t)((size * page_buf_min_meta_perc) / (shared->fs_page_size * 100)); + min_rd_pages = (int32_t)((size * page_buf_min_raw_perc) / (shared->fs_page_size * 100)); HDassert(min_md_pages >= 0); HDassert(min_rd_pages >= 0); - HDassert((min_md_pages + min_rd_pages) <= - (int32_t)(size / shared->fs_page_size)); - + HDassert((min_md_pages + min_rd_pages) <= (int32_t)(size / shared->fs_page_size)); /* compute vfd_swrm and vfd_swmr_writer */ - if ( H5F_SHARED_VFD_SWMR_CONFIG(shared) ) { + if (H5F_SHARED_VFD_SWMR_CONFIG(shared)) { vfd_swmr = TRUE; @@ -591,39 +551,37 @@ H5PB_create(H5F_shared_t *shared, size_t size, unsigned page_buf_min_meta_perc, */ min_rd_pages = 0; - if ( H5F_SHARED_INTENT(shared) & H5F_ACC_RDWR ) { + if (H5F_SHARED_INTENT(shared) & H5F_ACC_RDWR) { HDassert(shared->vfd_swmr_config.writer); vfd_swmr_writer = TRUE; } } - /* Allocate the new page buffering structure */ - if(NULL == (pb_ptr = H5FL_MALLOC(H5PB_t))) + if (NULL == (pb_ptr = H5FL_MALLOC(H5PB_t))) HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") /* initialize the new instance of H5PB_t */ - pb_ptr->magic = H5PB__H5PB_T_MAGIC; - pb_ptr->page_size = shared->fs_page_size; - H5_CHECKED_ASSIGN(pb_ptr->page_size, size_t, \ - shared->fs_page_size, hsize_t); - pb_ptr->max_pages = (int32_t)(size / shared->fs_page_size); - pb_ptr->curr_pages = 0; - pb_ptr->curr_md_pages = 0; - pb_ptr->curr_rd_pages = 0; - pb_ptr->min_md_pages = min_md_pages; - pb_ptr->min_rd_pages = min_rd_pages; - - pb_ptr->max_size = size; - pb_ptr->min_meta_perc = page_buf_min_meta_perc; - pb_ptr->min_raw_perc = page_buf_min_raw_perc; + pb_ptr->magic = H5PB__H5PB_T_MAGIC; + pb_ptr->page_size = shared->fs_page_size; + H5_CHECKED_ASSIGN(pb_ptr->page_size, size_t, shared->fs_page_size, hsize_t); + pb_ptr->max_pages = (int32_t)(size / shared->fs_page_size); + pb_ptr->curr_pages = 0; + pb_ptr->curr_md_pages = 0; + pb_ptr->curr_rd_pages = 0; + pb_ptr->min_md_pages = min_md_pages; + pb_ptr->min_rd_pages = min_rd_pages; + + pb_ptr->max_size = size; + pb_ptr->min_meta_perc = page_buf_min_meta_perc; + pb_ptr->min_raw_perc = page_buf_min_raw_perc; /* index */ - for ( i = 0; i < H5PB__HASH_TABLE_LEN; i++ ) - pb_ptr->ht[i] = NULL; + for (i = 0; i < H5PB__HASH_TABLE_LEN; i++) + pb_ptr->ht[i] = NULL; pb_ptr->index_len = 0; pb_ptr->clean_index_len = 0; pb_ptr->dirty_index_len = 0; @@ -636,70 +594,66 @@ H5PB_create(H5F_shared_t *shared, size_t size, unsigned page_buf_min_meta_perc, pb_ptr->il_tail = NULL; /* LRU */ - pb_ptr->LRU_len = 0; - pb_ptr->LRU_size = 0; - pb_ptr->LRU_head_ptr = NULL; - pb_ptr->LRU_tail_ptr = NULL; - + pb_ptr->LRU_len = 0; + pb_ptr->LRU_size = 0; + pb_ptr->LRU_head_ptr = NULL; + pb_ptr->LRU_tail_ptr = NULL; - /* VFD SWMR specific fields. - * The following fields are defined iff vfd_swmr_writer is TRUE. + /* VFD SWMR specific fields. + * The following fields are defined iff vfd_swmr_writer is TRUE. */ - pb_ptr->vfd_swmr = vfd_swmr; - pb_ptr->vfd_swmr_writer = vfd_swmr_writer; - pb_ptr->mpmde_count = 0; - pb_ptr->cur_tick = 0; + pb_ptr->vfd_swmr = vfd_swmr; + pb_ptr->vfd_swmr_writer = vfd_swmr_writer; + pb_ptr->mpmde_count = 0; + pb_ptr->cur_tick = 0; /* delayed write list */ - pb_ptr->max_delay = 0; - pb_ptr->dwl_len = 0; - pb_ptr->dwl_size = 0; - pb_ptr->dwl_head_ptr = NULL; - pb_ptr->dwl_tail_ptr = NULL; + pb_ptr->max_delay = 0; + pb_ptr->dwl_len = 0; + pb_ptr->dwl_size = 0; + pb_ptr->dwl_head_ptr = NULL; + pb_ptr->dwl_tail_ptr = NULL; /* tick list */ - pb_ptr->tl_len = 0; - pb_ptr->tl_size = 0; - pb_ptr->tl_head_ptr = NULL; - pb_ptr->tl_tail_ptr = NULL; + pb_ptr->tl_len = 0; + pb_ptr->tl_size = 0; + pb_ptr->tl_head_ptr = NULL; + pb_ptr->tl_tail_ptr = NULL; H5PB_reset_stats(pb_ptr); shared->pb_ptr = pb_ptr; - /* if this is a VFD SWMR reader, inform the reader VFD that the - * page buffer is configured. Note that this is for sanity - * checking, and only needed until we modify the file open - * code to create the page buffer before any file reads in + /* if this is a VFD SWMR reader, inform the reader VFD that the + * page buffer is configured. Note that this is for sanity + * checking, and only needed until we modify the file open + * code to create the page buffer before any file reads in * the VFD SWMR reader case. After that, this code should be * removed. * JRM -- 1/29/19 */ - if ( ( H5F_SHARED_VFD_SWMR_CONFIG(shared) ) && - ( 0 == (H5F_SHARED_INTENT(shared) & H5F_ACC_RDWR) ) ) { + if ((H5F_SHARED_VFD_SWMR_CONFIG(shared)) && (0 == (H5F_SHARED_INTENT(shared) & H5F_ACC_RDWR))) { HDassert(shared->lf); - HDassert(! shared->vfd_swmr_config.writer); + HDassert(!shared->vfd_swmr_config.writer); H5FD_vfd_swmr_set_pb_configured(shared->lf); } done: - if ( ret_value < 0 ) { + if (ret_value < 0) { - if ( pb_ptr != NULL ) { + if (pb_ptr != NULL) { pb_ptr = H5FL_FREE(H5PB_t, pb_ptr); - - } - } + } + } FUNC_LEAVE_NOAPI(ret_value) } /* H5PB_create */ - /*------------------------------------------------------------------------- * * Function: H5PB_dest @@ -718,11 +672,11 @@ done: herr_t H5PB_dest(H5F_shared_t *shared) { - int i; - H5PB_t *pb_ptr = NULL; + int i; + H5PB_t * pb_ptr = NULL; H5PB_entry_t *entry_ptr = NULL; H5PB_entry_t *evict_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -730,7 +684,7 @@ H5PB_dest(H5F_shared_t *shared) HDassert(shared); /* flush and destroy the page buffer, if it exists */ - if ( shared->pb_ptr ) { + if (shared->pb_ptr) { pb_ptr = shared->pb_ptr; @@ -738,32 +692,30 @@ H5PB_dest(H5F_shared_t *shared) HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); - /* the current implementation if very inefficient, and will - * fail if there are any outstanding delayed writes -- must fix this + /* the current implementation if very inefficient, and will + * fail if there are any outstanding delayed writes -- must fix this */ - for ( i = 0; i < H5PB__HASH_TABLE_LEN; i++ ) { + for (i = 0; i < H5PB__HASH_TABLE_LEN; i++) { entry_ptr = pb_ptr->ht[i]; - while ( entry_ptr ) { + while (entry_ptr) { HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); evict_ptr = entry_ptr; entry_ptr = entry_ptr->ht_next; - if ( evict_ptr->is_dirty ) { + if (evict_ptr->is_dirty) { - if ( H5PB__flush_entry(shared, pb_ptr, evict_ptr) < 0 ) + if (H5PB__flush_entry(shared, pb_ptr, evict_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "Can't flush entry") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "Can't flush entry") } - if ( H5PB__evict_entry(shared, evict_ptr, TRUE, TRUE) < 0 ) + if (H5PB__evict_entry(shared, evict_ptr, TRUE, TRUE) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "forced eviction failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "forced eviction failed") entry_ptr = pb_ptr->ht[i]; } @@ -791,7 +743,7 @@ H5PB_dest(H5F_shared_t *shared) HDassert(pb_ptr->tl_head_ptr == NULL); HDassert(pb_ptr->tl_tail_ptr == NULL); - pb_ptr->magic = 0; + pb_ptr->magic = 0; shared->pb_ptr = H5FL_FREE(H5PB_t, pb_ptr); } @@ -801,7 +753,6 @@ done: } /* H5PB_dest */ - /*------------------------------------------------------------------------- * * Function: H5PB_flush @@ -819,11 +770,11 @@ done: herr_t H5PB_flush(H5F_shared_t *shared) { - int i; - H5PB_t *pb_ptr = NULL; + int i; + H5PB_t * pb_ptr = NULL; H5PB_entry_t *entry_ptr = NULL; H5PB_entry_t *flush_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -832,33 +783,32 @@ H5PB_flush(H5F_shared_t *shared) pb_ptr = shared->pb_ptr; - if ( pb_ptr ) { + if (pb_ptr) { HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); /* the current implementation is very inefficient, and will - * fail if there are any delayed writes -- must fix this + * fail if there are any delayed writes -- must fix this */ - for ( i = 0; i < H5PB__HASH_TABLE_LEN; i++ ) { + for (i = 0; i < H5PB__HASH_TABLE_LEN; i++) { entry_ptr = pb_ptr->ht[i]; - while ( entry_ptr ) { + while (entry_ptr) { HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); flush_ptr = entry_ptr; entry_ptr = entry_ptr->ht_next; - if ( flush_ptr->is_dirty ) { + if (flush_ptr->is_dirty) { if (flush_ptr->delay_write_until != 0) continue; - if ( H5PB__flush_entry(shared, pb_ptr, flush_ptr) < 0 ) + if (H5PB__flush_entry(shared, pb_ptr, flush_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "Can't flush entry") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "Can't flush entry") } } } @@ -870,7 +820,6 @@ done: } /* H5PB_flush */ - /*------------------------------------------------------------------------- * * Function: H5PB_page_exists @@ -878,7 +827,7 @@ done: * Purpose: Test to see if a page buffer page exists at the specified * address. Set *page_exists_ptr to TRUE or FALSE accordingly. * - * This function exists for the convenience of the test + * This function exists for the convenience of the test * code * * Return: Non-negative on success/Negative on failure @@ -892,10 +841,10 @@ done: herr_t H5PB_page_exists(H5F_shared_t *shared, haddr_t addr, hbool_t *page_exists_ptr) { - uint64_t page; - H5PB_t *pb_ptr = NULL; + uint64_t page; + H5PB_t * pb_ptr = NULL; H5PB_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -919,7 +868,7 @@ H5PB_page_exists(H5F_shared_t *shared, haddr_t addr, hbool_t *page_exists_ptr) HDassert((NULL == entry_ptr) || (entry_ptr->addr == addr)); - *page_exists_ptr = ( entry_ptr != NULL ); + *page_exists_ptr = (entry_ptr != NULL); done: @@ -931,9 +880,9 @@ static void H5PB_count_meta_access_by_size(H5PB_t *pb, size_t size) { const size_t nslots = NELMTS(pb->access_size_count); - size_t i, hi; + size_t i, hi; - for (hi = pb->page_size, i = 0; i < nslots - 1; i++, hi *= 2){ + for (hi = pb->page_size, i = 0; i < nslots - 1; i++, hi *= 2) { if (size <= hi) break; } @@ -944,101 +893,98 @@ static void H5PB_log_access_by_size_counts(const H5PB_t *pb) { const size_t nslots = NELMTS(pb->access_size_count); - size_t i, lo, hi; + size_t i, lo, hi; - for (lo = 0, hi = pb->page_size, i = 0; - i < nslots - 1; - i++, lo = hi + 1, hi *= 2) { + for (lo = 0, hi = pb->page_size, i = 0; i < nslots - 1; i++, lo = hi + 1, hi *= 2) { } } - /*------------------------------------------------------------------------- * * Function: H5PB_read * * Purpose: Satisfy the read from the page buffer if possible. * - * 1) If the page buffer is disabled, simply read from the + * 1) If the page buffer is disabled, simply read from the * HDF5 file and return. * - * 2) If the read is for raw data, and the page buffer is - * configured for metadata only (i.e. min_md_pages == + * 2) If the read is for raw data, and the page buffer is + * configured for metadata only (i.e. min_md_pages == * max_pages), or if we are operating in VFD SWMR mode - * (i.e. vfd_swmr == TRUE), simply read from the HDF5 + * (i.e. vfd_swmr == TRUE), simply read from the HDF5 * file and return. * - * 3) If the read is for raw data, and is of page size or - * larger, read it directly from the HDF5 file. + * 3) If the read is for raw data, and is of page size or + * larger, read it directly from the HDF5 file. * - * It is possible that the page buffer contains dirty pages + * It is possible that the page buffer contains dirty pages * that intersect with the read -- test for this and update - * the read buffer from the page buffer if any such pages - * exist. + * the read buffer from the page buffer if any such pages + * exist. * - * Note that no pages are inserted into the page buffer in + * Note that no pages are inserted into the page buffer in * this case. * - * 4) If the read is for raw data, and it is of size less - * than the page size, satisfy the read from the page - * buffer, loading and inserting pages into the + * 4) If the read is for raw data, and it is of size less + * than the page size, satisfy the read from the page + * buffer, loading and inserting pages into the * page buffer as necessary * - * 5) If the read is for metadata, and the page buffer is - * configured for raw data only (i.e. min_rd_pages == + * 5) If the read is for metadata, and the page buffer is + * configured for raw data only (i.e. min_rd_pages == * max_pages), simply read from the HDF5 file and return. * * The free space manager guarantees that allocations larger * than one page will be page alligned, and that allocations * of size less than or equal to page size will not cross page - * boundaries. Further, unlike raw data, metadata is always + * boundaries. Further, unlike raw data, metadata is always * written and read atomically. * - * In principle, this should make it easy to discriminate - * between small and multi-page metadata entries so that - * pages containing the former will be buffered and the + * In principle, this should make it easy to discriminate + * between small and multi-page metadata entries so that + * pages containing the former will be buffered and the * latter be read directly from file. * * Unfortunately, there are several flies in the ointment. * - * First, the fixed and extensible array on disk data - * structures allocate multiple metadata cache entries in + * First, the fixed and extensible array on disk data + * structures allocate multiple metadata cache entries in * a single block, and use this fact to make the addresses * of all but the first entry in the block computable. While * this simplifies the fixed and extensible array on disk data * structures, if complicates the metadata cache and the page - * buffer. Needless to say, the correct solution to this - * problem is to remove the complexity at its source. However, + * buffer. Needless to say, the correct solution to this + * problem is to remove the complexity at its source. However, * for now, we must code around the problem. * * Thus, this function must examine each read request - * to determine if it crosses page boundaries and is not for + * to determine if it crosses page boundaries and is not for * two or more complete pages. If it does, and it is one of * the fixed or extensible array entries that is sub-allocated - * from a larger space allocation, the read request must be - * split into the minimal set of read requests that either - * don't cross page boundaries, or are page aligned and + * from a larger space allocation, the read request must be + * split into the minimal set of read requests that either + * don't cross page boundaries, or are page aligned and * consist of an integral number of pages. * * - * Second, the metadata cache does not always know the - * size of metadata entries when it tries to read them. In - * such cases, it issues speculative reads that may be either - * smaller or larger than the actual size of the piece of + * Second, the metadata cache does not always know the + * size of metadata entries when it tries to read them. In + * such cases, it issues speculative reads that may be either + * smaller or larger than the actual size of the piece of * metadata that is finally read. * * Since we are guaranteed that all metadata allocations larger * that one page are page aligned (with the exception of those * sub-allocated from larger allocations -- which we deal with - * by splitting I/O requests as discussed above), we can safely - * clip at the page boundary any non page aligned metadata - * read that crosses page boundaries. + * by splitting I/O requests as discussed above), we can safely + * clip at the page boundary any non page aligned metadata + * read that crosses page boundaries. * * However, page aligned reads could wind up being either * small or multi-page. This results in two scenarios that * we must handle: * - * a) A page aligned read of size less than one page + * a) A page aligned read of size less than one page * turns out to be mult-page. * * In this case, the initial speculative read will @@ -1046,44 +992,44 @@ H5PB_log_access_by_size_counts(const H5PB_t *pb) * buffer. This page must be evicted on the subsequent * read of size greater than page size. * - * In the context of VFD SWMR, it is also possible that - * that the multi-page metadata entry is already in the - * page buffer -- in which case the initial read should + * In the context of VFD SWMR, it is also possible that + * that the multi-page metadata entry is already in the + * page buffer -- in which case the initial read should * be satisfied from the multi-page page buffer entry. * - * b) A page aligned, larger than one page read turns out + * b) A page aligned, larger than one page read turns out * to be small (less than one page). * - * If there is already a page in the page buffer with - * same address, we can safely clip the original + * If there is already a page in the page buffer with + * same address, we can safely clip the original * read to page size * * The above considerations resolve into the following cases: * * 6) If the read is for metadata and not page aligned, clip * the read to the end of the current page if necessary. - * Load the relevant page if necessary and satisfy the + * Load the relevant page if necessary and satisfy the * read from the page buffer. Note that it there is an - * existing page, it must not be a multi-page metadata + * existing page, it must not be a multi-page metadata * entry. It it is, flag an error. * - * 7) If the read is for metadata, is page aligned, is larger + * 7) If the read is for metadata, is page aligned, is larger * than one page, and there is no entry in the page buffer, * satisfy the read from the file * - * 8) If the read is for metadata, is page aligned, is larger + * 8) If the read is for metadata, is page aligned, is larger * than one page, and there is a regular entry at the target * page address, test to see if the read is speculative. * - * If it is not, evict the page, and satisfy the read from + * If it is not, evict the page, and satisfy the read from * file. Flag an error if the page was dirty. * - * If it is, clip the read to one page, and satisfy the + * If it is, clip the read to one page, and satisfy the * read from the existing regular entry. * * 9) If the read is for metadata, is page aligned, is larger * than one page, and there is a multi-page metadata entry - * at the target page address, test to see if + * at the target page address, test to see if * pb_ptr->vfd_swmr_write is TRUE. * * If it is, satisfy the read from the multi-page metadata @@ -1091,57 +1037,55 @@ H5PB_log_access_by_size_counts(const H5PB_t *pb) * * if pb_ptr->vfd_swmr_write is FALSE, flag an error. * - * 10) If the read is for metadata, is page aligned, is no - * larger than a page, test to see if the page buffer + * 10) If the read is for metadata, is page aligned, is no + * larger than a page, test to see if the page buffer * contains a page at the target address. * - * If it doesn't, load the page and satisfy the read + * If it doesn't, load the page and satisfy the read * from it. * - * If it contains a regular page entry, satisfy the read + * If it contains a regular page entry, satisfy the read * from it. * * If it contains a multipage metadata entry at the target * address, satisfy the read from the multi-page metadata - * entry if pb_ptr->vfd_swmr_write is TRUE, and flag an + * entry if pb_ptr->vfd_swmr_write is TRUE, and flag an * error otherwise. * * Observe that this function handles casses 1, 2, and 5 - * directly, calls H5PB_read_raw() for cases 3 & 4, and + * directly, calls H5PB_read_raw() for cases 3 & 4, and * calls H5PB_read_meta() for cases 6), 7, 8, 9), and 10). * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer -- 10/11/18 * - * Changes: Updated for discovery of the fact that the fixed and - * extensible array data structures allocate multiple - * metadata cache entries in a single block, and thus - * violate that invarient that metadata entries either + * Changes: Updated for discovery of the fact that the fixed and + * extensible array data structures allocate multiple + * metadata cache entries in a single block, and thus + * violate that invarient that metadata entries either * do not cross page boundaries, or are page aligned. * * JRM -- 3/28/20 * *------------------------------------------------------------------------- */ - + herr_t -H5PB_read(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, - void *buf/*out*/) +H5PB_read(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - H5PB_t *pb_ptr; /* Page buffer for this file */ - hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ - hbool_t split_read = FALSE; /* whether the read must be split */ - herr_t ret_value = SUCCEED; /* Return value */ + H5PB_t *pb_ptr; /* Page buffer for this file */ + hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ + hbool_t split_read = FALSE; /* whether the read must be split */ + herr_t ret_value = SUCCEED; /* Return value */ /* the following six fields are defined iff split_read is TRUE */ - haddr_t prefix_addr = HADDR_UNDEF; /* addr of prefix -- if defined */ - haddr_t body_addr = HADDR_UNDEF; /* addr of body -- if defined */ - haddr_t suffix_addr = HADDR_UNDEF; /* addr of suffix -- if defined */ - size_t prefix_size = 0; /* size of prefix */ - size_t body_size = 0; /* size of body */ - size_t suffix_size = 0; /* size of suffix */ - + haddr_t prefix_addr = HADDR_UNDEF; /* addr of prefix -- if defined */ + haddr_t body_addr = HADDR_UNDEF; /* addr of body -- if defined */ + haddr_t suffix_addr = HADDR_UNDEF; /* addr of suffix -- if defined */ + size_t prefix_size = 0; /* size of prefix */ + size_t body_size = 0; /* size of body */ + size_t suffix_size = 0; /* size of suffix */ FUNC_ENTER_NOAPI(FAIL) @@ -1153,109 +1097,106 @@ H5PB_read(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, if (pb_ptr != NULL && type != H5FD_MEM_DRAW) H5PB_count_meta_access_by_size(pb_ptr, size); - if ( pb_ptr == NULL ) { + if (pb_ptr == NULL) { bypass_pb = TRUE; /* case 1) -- page buffer is disabled */ - - } else { + } + else { HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); - if ( H5FD_MEM_DRAW == type ) { /* raw data read */ + if (H5FD_MEM_DRAW == type) { /* raw data read */ - if ( ( pb_ptr->min_md_pages == pb_ptr->max_pages ) || - ( pb_ptr->vfd_swmr ) ) { + if ((pb_ptr->min_md_pages == pb_ptr->max_pages) || (pb_ptr->vfd_swmr)) { - /* case 2) -- page buffer configured for metadata only + /* case 2) -- page buffer configured for metadata only * or vfd swmr. */ bypass_pb = TRUE; - } - } else { /* metadata read */ + } + else { /* metadata read */ - if ( pb_ptr->min_rd_pages == pb_ptr->max_pages ) { + if (pb_ptr->min_rd_pages == pb_ptr->max_pages) { /* case 5) -- page buffer configured for raw data only */ bypass_pb = TRUE; - - } else { + } + else { /* determine whether the read request must be split, - * and if so, compute the start points and sizes of + * and if so, compute the start points and sizes of * of the sections. * - * Note: The following code is almost identical to the - * similar code in H5PB_write(). Thus, on the surface, - * it is an obvious candidate for refactoring into a + * Note: The following code is almost identical to the + * similar code in H5PB_write(). Thus, on the surface, + * it is an obvious candidate for refactoring into a * function 0r macro. * - * However, there are subtle differences between - * the two pieces of code which are driven by the - * possibility of speculative reads. + * However, there are subtle differences between + * the two pieces of code which are driven by the + * possibility of speculative reads. * - * More to the point, further changes may be necessary. - * Thus we should wait on refactoring until this code has - * been in daily use for some time, and it is clear + * More to the point, further changes may be necessary. + * Thus we should wait on refactoring until this code has + * been in daily use for some time, and it is clear * that further changes are unlikely. */ - int mdc_client_id = -1; /* id of mdc client, or -1 if undef */ - uint64_t start_page; /* page index of first page in read */ - uint64_t second_page; /* page index of second page in read */ - uint64_t end_page; /* page index of last page in read */ - uint64_t body_page; /* page index of start of body */ - haddr_t start_page_addr; /* addr of first page in read */ - haddr_t second_page_addr;/* addr of second page in read */ - haddr_t end_page_addr; /* addr of last page in read */ - haddr_t end_addr; /* addr of last byte in read */ - + int mdc_client_id = -1; /* id of mdc client, or -1 if undef */ + uint64_t start_page; /* page index of first page in read */ + uint64_t second_page; /* page index of second page in read */ + uint64_t end_page; /* page index of last page in read */ + uint64_t body_page; /* page index of start of body */ + haddr_t start_page_addr; /* addr of first page in read */ + haddr_t second_page_addr; /* addr of second page in read */ + haddr_t end_page_addr; /* addr of last page in read */ + haddr_t end_addr; /* addr of last byte in read */ + /* Calculate the aligned address of the first page */ - start_page = (addr / pb_ptr->page_size); + start_page = (addr / pb_ptr->page_size); start_page_addr = start_page * pb_ptr->page_size; /* Calculate the aligned address of the last page */ - end_addr = addr + (haddr_t)(size - 1); - end_page = end_addr / (haddr_t)(pb_ptr->page_size); + end_addr = addr + (haddr_t)(size - 1); + end_page = end_addr / (haddr_t)(pb_ptr->page_size); end_page_addr = end_page * pb_ptr->page_size; HDassert(start_page_addr <= addr); HDassert(addr < start_page_addr + (haddr_t)(pb_ptr->page_size)); HDassert(start_page <= end_page); - HDassert(end_page_addr <= ((addr + (haddr_t)size - 1))); - HDassert((addr + (haddr_t)size - 1) < - (end_page_addr + pb_ptr->page_size)); + HDassert(end_page_addr <= ((addr + (haddr_t)size - 1))); + HDassert((addr + (haddr_t)size - 1) < (end_page_addr + pb_ptr->page_size)); - /* test to see if the read crosses a page boundary, and - * does not start on a page boundary, and is not of an + /* test to see if the read crosses a page boundary, and + * does not start on a page boundary, and is not of an * integral number of pages. */ - if ( ( start_page < end_page ) && - ( ! ( ( addr == start_page_addr ) && - ( end_page_addr + (haddr_t)(pb_ptr->page_size) == - end_addr + 1 ) ) ) ) { + if ((start_page < end_page) && + (!((addr == start_page_addr) && + (end_page_addr + (haddr_t)(pb_ptr->page_size) == end_addr + 1)))) { - /* the read crosses a page boundary and is not + /* the read crosses a page boundary and is not * page aligned and of length some multiple of page size. * - * Test to see if the read is for a metadata entry that + * Test to see if the read is for a metadata entry that * is sub-allocated from a larger space allocation. * * Note that the following test may have to be * adjusted. */ mdc_client_id = H5C_get_curr_io_client_type(shared->cache); - - if ( ( mdc_client_id == (int)H5AC_EARRAY_DBLK_PAGE_ID ) || \ - ( mdc_client_id == (int)H5AC_FARRAY_DBLK_PAGE_ID ) ) { + + if ((mdc_client_id == (int)H5AC_EARRAY_DBLK_PAGE_ID) || + (mdc_client_id == (int)H5AC_FARRAY_DBLK_PAGE_ID)) { split_read = TRUE; } } - if ( split_read ) { + if (split_read) { /* compute the base addresses and length of the prefix, - * body, and suffix of the read, where these terms are + * body, and suffix of the read, where these terms are * defined as follows: * * prefix: All bytes from addr to the first page address @@ -1263,91 +1204,79 @@ H5PB_read(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, * the prefix is empty. * * body: All bytes from the first page address covered - * by the read up to but not including the last - * page address in the read. Note that the - * length of the body must be a multiple of the - * page size. If only one page address is + * by the read up to but not including the last + * page address in the read. Note that the + * length of the body must be a multiple of the + * page size. If only one page address is * included in the read, the body is empty. * * suffix: All bytes from the last page address in the - * read until the end of the read. If the + * read until the end of the read. If the * read ends on a page boundary, the suffix is * empty. * - * Since we know that the read crosses at least one - * page boundary, and we have aleady filtered out the - * body only case, at least two of the above must be + * Since we know that the read crosses at least one + * page boundary, and we have aleady filtered out the + * body only case, at least two of the above must be * non-empty. */ - second_page = start_page + 1; - second_page_addr = - (haddr_t)(second_page * pb_ptr->page_size); + second_page = start_page + 1; + second_page_addr = (haddr_t)(second_page * pb_ptr->page_size); - if ( addr > start_page_addr ) { /* prefix exists */ + if (addr > start_page_addr) { /* prefix exists */ prefix_addr = addr; prefix_size = (size_t)(second_page_addr - addr); HDassert(prefix_addr > start_page_addr); HDassert(prefix_size < pb_ptr->page_size); - HDassert(((size_t)(addr - start_page_addr) + \ - prefix_size) == pb_ptr->page_size); + HDassert(((size_t)(addr - start_page_addr) + prefix_size) == pb_ptr->page_size); } - if ( size - prefix_size >= pb_ptr->page_size ) { - + if (size - prefix_size >= pb_ptr->page_size) { + /* body exists */ - if ( addr == start_page_addr ) { + if (addr == start_page_addr) { body_page = start_page; body_addr = start_page_addr; - - } else { + } + else { body_page = second_page; body_addr = second_page_addr; } - if ( end_addr < end_page_addr + - (haddr_t)(pb_ptr->page_size - 1) ) { + if (end_addr < end_page_addr + (haddr_t)(pb_ptr->page_size - 1)) { /* suffix exists */ - body_size = (size_t)(end_page - body_page) * - pb_ptr->page_size; - - } else { + body_size = (size_t)(end_page - body_page) * pb_ptr->page_size; + } + else { /* suffix is empty */ - body_size = (size_t)(end_page - body_page + 1) * - pb_ptr->page_size; + body_size = (size_t)(end_page - body_page + 1) * pb_ptr->page_size; } - HDassert((body_page == start_page) || \ - (body_page == start_page + 1)); + HDassert((body_page == start_page) || (body_page == start_page + 1)); - HDassert(body_addr == \ - (haddr_t)(body_page * pb_ptr->page_size)); + HDassert(body_addr == (haddr_t)(body_page * pb_ptr->page_size)); HDassert(body_size < size); HDassert(body_size >= pb_ptr->page_size); - - HDassert(body_addr == \ - addr + (haddr_t)prefix_size); - HDassert((body_addr + (haddr_t)body_size) \ - <= (end_addr + 1)); + HDassert(body_addr == addr + (haddr_t)prefix_size); + HDassert((body_addr + (haddr_t)body_size) <= (end_addr + 1)); } - if ( end_addr < end_page_addr + - (haddr_t)(pb_ptr->page_size - 1) ) { + if (end_addr < end_page_addr + (haddr_t)(pb_ptr->page_size - 1)) { suffix_addr = end_page_addr; suffix_size = (end_addr + 1) - end_page_addr; - HDassert(suffix_addr == \ - addr + (haddr_t)(prefix_size + body_size)); + HDassert(suffix_addr == addr + (haddr_t)(prefix_size + body_size)); } HDassert(size == prefix_size + body_size + suffix_size); @@ -1360,79 +1289,70 @@ H5PB_read(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, /* at present, the page buffer must be disabled in the parallel case. * However, just in case ... */ - if ( H5F_SHARED_HAS_FEATURE(shared, H5FD_FEAT_HAS_MPI) ) { + if (H5F_SHARED_HAS_FEATURE(shared, H5FD_FEAT_HAS_MPI)) { bypass_pb = TRUE; - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ + if (bypass_pb) { /* cases 1, 2. and 5 */ - if ( bypass_pb ) { /* cases 1, 2. and 5 */ - - if ( H5FD_read(shared->lf, type, addr, size, buf) < 0 ) + if (H5FD_read(shared->lf, type, addr, size, buf) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "read through failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "read through failed") /* Update statistics */ - if ( pb_ptr ) { + if (pb_ptr) { H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size); } - } else { - - if ( H5FD_MEM_DRAW == type ) { /* cases 3 and 4 */ + } + else { - if ( H5PB__read_raw(shared, type, addr, size, buf) < 0 ) + if (H5FD_MEM_DRAW == type) { /* cases 3 and 4 */ - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "H5PB_read_raw() failed") + if (H5PB__read_raw(shared, type, addr, size, buf) < 0) - } else if ( split_read ) { + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "H5PB_read_raw() failed") + } + else if (split_read) { /* handle the sub-allocated entry case */ /* read prefix if it exists */ - if ( prefix_size > 0 ) { - - if ( H5PB__read_meta(shared, type, prefix_addr, - prefix_size, buf) < 0 ) + if (prefix_size > 0) { - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "H5PB_read_meta() failed on prefix") + if (H5PB__read_meta(shared, type, prefix_addr, prefix_size, buf) < 0) + + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "H5PB_read_meta() failed on prefix") } /* read body -- if it exists. */ - if ( body_size > 0 ) { + if (body_size > 0) { - if ( H5PB__read_meta(shared, type, body_addr, body_size, - (void *)((uint8_t *)buf + - prefix_size)) < 0 ) + if (H5PB__read_meta(shared, type, body_addr, body_size, + (void *)((uint8_t *)buf + prefix_size)) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "H5PB_read_meta() failed on body") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "H5PB_read_meta() failed on body") } /* read suffix -- if it exists. */ - if ( suffix_size > 0 ) { + if (suffix_size > 0) { - if ( H5PB__read_meta(shared, type, suffix_addr, suffix_size, - (void *)((uint8_t *)buf + prefix_size + - body_size)) < 0 ) + if (H5PB__read_meta(shared, type, suffix_addr, suffix_size, + (void *)((uint8_t *)buf + prefix_size + body_size)) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "H5PB_read_meta() failed on suffix") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "H5PB_read_meta() failed on suffix") } H5PB__UPDATE_STATS_FOR_READ_SPLIT(pb_ptr) + } + else { /* pass to H5PB_read_meta() -- cases 6, 7, 8, 9, & 10 */ - } else { /* pass to H5PB_read_meta() -- cases 6, 7, 8, 9, & 10 */ - - if ( H5PB__read_meta(shared, type, addr, size, buf) < 0 ) + if (H5PB__read_meta(shared, type, addr, size, buf) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "H5PB_read_meta() failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "H5PB_read_meta() failed") } } @@ -1455,11 +1375,10 @@ done: static int shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, hbool_t only_mark) { - ptrdiff_t i; + ptrdiff_t i; H5FD_vfd_swmr_idx_entry_t *entry; - entry = vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, - shared->mdf_idx_entries_used, page, FALSE); + entry = vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, FALSE); if (entry == NULL) return 0; @@ -1478,29 +1397,25 @@ shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, hbool_t only_mark) i = entry - shared->mdf_idx; if (shared->mdf_idx_entries_used > i + 1) { - const size_t ntocopy = - (size_t)(shared->mdf_idx_entries_used - (i + 1)); - HDmemmove(&shared->mdf_idx[i], - &shared->mdf_idx[i + 1], - ntocopy * sizeof(shared->mdf_idx[i + 1])); + const size_t ntocopy = (size_t)(shared->mdf_idx_entries_used - (i + 1)); + HDmemmove(&shared->mdf_idx[i], &shared->mdf_idx[i + 1], ntocopy * sizeof(shared->mdf_idx[i + 1])); } shared->mdf_idx_entries_used--; return 0; } - /*------------------------------------------------------------------------- * * Function: H5PB_remove_entry * * Purpose: Remove possible metadata entry with ADDR from the PB cache. * - * This is in response to the data corruption bug from fheap.c + * This is in response to the data corruption bug from fheap.c * with page buffering + page strategy. * * Note: Large metadata page bypasses the PB cache. * - * Note: Update of raw data page (large or small sized) is + * Note: Update of raw data page (large or small sized) is * handled by the PB cache. * * Return: Non-negative on success/Negative on failure @@ -1509,9 +1424,9 @@ shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, hbool_t only_mark) * * Changes: Reworked function for re-implementation of the page buffer. * - * In the context of VFD SWMR, it is possible that the - * discarded page or multi-page metadata entry has been - * modified during the current tick and/or is subject to a + * In the context of VFD SWMR, it is possible that the + * discarded page or multi-page metadata entry has been + * modified during the current tick and/or is subject to a * delayed write. We must detect this, and remove the entry * from the tick list and/or delayed write list before it is * evicted. @@ -1520,9 +1435,9 @@ shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, hbool_t only_mark) * * JRM -- 10/23/18 * - * We also need to evict modified pages from the page + * We also need to evict modified pages from the page * buffer in the VFD SWMR reader case to avoid message from - * the past bugs. This function will serve for this for + * the past bugs. This function will serve for this for * now, but for efficiency, we may want a version that takes * a list of pages instead. * @@ -1533,10 +1448,10 @@ shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, hbool_t only_mark) herr_t H5PB_remove_entry(H5F_shared_t *shared, haddr_t addr) { - uint64_t page; - H5PB_t *pb_ptr = NULL; + uint64_t page; + H5PB_t * pb_ptr = NULL; H5PB_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1554,47 +1469,46 @@ H5PB_remove_entry(H5F_shared_t *shared, haddr_t addr) /* Search for page in the hash table */ H5PB__SEARCH_INDEX(pb_ptr, page, entry_ptr, FAIL) - if ( entry_ptr ) { + if (entry_ptr) { HDassert(entry_ptr->addr == addr); /* A page or a metadata multi-page with vfd_swmr_writer (case 7) */ - HDassert( (entry_ptr->size == pb_ptr->page_size) || - (entry_ptr->size > pb_ptr->page_size && - entry_ptr->mem_type != H5FD_MEM_DRAW && - pb_ptr->vfd_swmr_writer) ); + HDassert((entry_ptr->size == pb_ptr->page_size) || + (entry_ptr->size > pb_ptr->page_size && entry_ptr->mem_type != H5FD_MEM_DRAW && + pb_ptr->vfd_swmr_writer)); - if ( entry_ptr->modified_this_tick ) { + if (entry_ptr->modified_this_tick) { H5PB__REMOVE_FROM_TL(pb_ptr, entry_ptr, FAIL); entry_ptr->modified_this_tick = FALSE; } - if ( entry_ptr->delay_write_until > 0 ) { + if (entry_ptr->delay_write_until > 0) { entry_ptr->delay_write_until = 0; H5PB__REMOVE_FROM_DWL(pb_ptr, entry_ptr, FAIL) - if ( ! ( entry_ptr->is_mpmde ) ) { + if (!(entry_ptr->is_mpmde)) { H5PB__UPDATE_RP_FOR_INSERTION(pb_ptr, entry_ptr, FAIL); } } /* if the entry is dirty, mark it clean before we evict */ - if ( ( entry_ptr->is_dirty ) && - ( H5PB__mark_entry_clean(pb_ptr, entry_ptr) < 0 ) ) + if ((entry_ptr->is_dirty) && (H5PB__mark_entry_clean(pb_ptr, entry_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "mark entry clean failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "mark entry clean failed") - if ( H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0 ) + if (H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "forced eviction failed") - HDassert(!shared->vfd_swmr_writer || vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, FALSE) == NULL); + HDassert(!shared->vfd_swmr_writer || + vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, + FALSE) == NULL); } done: @@ -1603,85 +1517,84 @@ done: } /* H5PB_remove_entry */ - /*------------------------------------------------------------------------- * * Function: H5PB_remove_entries * - * Purpose: Remove entries in the page buffer associated with a - * newly freed multi-page block of file space. + * Purpose: Remove entries in the page buffer associated with a + * newly freed multi-page block of file space. * * There are several possible situations here. * * In the context of metadata, there are two possible cases. * - * 1) The block of file space is associated with a metadata + * 1) The block of file space is associated with a metadata * entry. * - * In regular operating mode, this entry will not be + * In regular operating mode, this entry will not be * cached in the page buffer, so there should be nothing * to do. * * In VFD SWMR mode, the entry may be cached in a single * multi-page entry. * - * 2) The block of file space has been sub-allocated + * 2) The block of file space has been sub-allocated * into multiple metadata entries (i.e. fixed and extensible * array). In this case, the individual entries may cross - * boundaries without being page aligned -- however, for - * purposes of the page buffer, I/O requests on these - * entries will have been broken up into requests that + * boundaries without being page aligned -- however, for + * purposes of the page buffer, I/O requests on these + * entries will have been broken up into requests that * either do not cross page boundaries or are page aligned. * - * In the context of raw data, the page buffer may or may - * not contain regular entries scattered over the space + * In the context of raw data, the page buffer may or may + * not contain regular entries scattered over the space * touched by the newly freed file space. * * In all contexts, there is no guarantee that the page buffer * will contain any of the possible entries. * * Space allocations larger than one page must be page alligned. - * Further, any space between the end of a multi-page allocation + * Further, any space between the end of a multi-page allocation * and the next page boundary will remain un-allocated until after * the original allocation is freed. This implies that: * * 1) The address passed into this call must be page aligned. * - * 2) The page buffer may safely discard any page that + * 2) The page buffer may safely discard any page that * intersects with the newly freed file space allocation. * * The bottom line here is that we must scan the page buffer * index, and discard all entries that intersect the supplied * address and length. As a sanity check, we must verify that - * any such entries don't overlap. + * any such entries don't overlap. * * Also, in the context of the VFD SWMR write, it is possible - * that the discarded pages will reside in the tick list or - * the delayed write list -- if so, they must be removed + * that the discarded pages will reside in the tick list or + * the delayed write list -- if so, they must be removed * prior to eviction. * - * Note: + * Note: * - * This function scans the page buffer hash table to - * find entries to remove. While this is normally - * pretty in-expensive, a very large (i.e. GB) file + * This function scans the page buffer hash table to + * find entries to remove. While this is normally + * pretty in-expensive, a very large (i.e. GB) file * space free may impose significant cost. * - * As best I understand it, such frees are rare, so + * As best I understand it, such frees are rare, so * the current solution should be good enough for now. - * However, if we determine that the current solution + * However, if we determine that the current solution * is too expensive, two alternate solutions come to mine. * * a) Scan the index list instead of the hash table - * if the free is sufficiently large. Also, skip + * if the free is sufficiently large. Also, skip * entirely if the page buffer doesn't contain any * pages of the appropriate type. * - * b) Whenever writing a large metadata entry, scan for - * intersecting entries and delete them. (potential - * issues with fixed and variable array entries are - * dealt with via the splitting mechanism.) In this - * case we would also have to simply ignore writes + * b) Whenever writing a large metadata entry, scan for + * intersecting entries and delete them. (potential + * issues with fixed and variable array entries are + * dealt with via the splitting mechanism.) In this + * case we would also have to simply ignore writes * beyond EOA on flush or close. * * Note that we already scan for intersecting entries @@ -1702,14 +1615,14 @@ done: herr_t H5PB_remove_entries(H5F_shared_t *shared, haddr_t addr, hsize_t size) { - uint64_t i; - uint64_t start_page; - uint64_t end_page; - int64_t entry_pages = 0; - hsize_t entry_size; - H5PB_t *pb_ptr = NULL; + uint64_t i; + uint64_t start_page; + uint64_t end_page; + int64_t entry_pages = 0; + hsize_t entry_size; + H5PB_t * pb_ptr = NULL; H5PB_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1730,33 +1643,30 @@ H5PB_remove_entries(H5F_shared_t *shared, haddr_t addr, hsize_t size) HDassert(start_page <= end_page); HDassert(((end_page - start_page) * pb_ptr->page_size) <= size); HDassert(size <= ((end_page - start_page + 1) * pb_ptr->page_size)); - - for ( i = start_page; i <= end_page; i++ ) - { + + for (i = start_page; i <= end_page; i++) { /* test to see if page i exists */ H5PB__SEARCH_INDEX(pb_ptr, i, entry_ptr, FAIL) - if ( entry_ptr ) { + if (entry_ptr) { /* verify that this entry doesn't overlap with a previously * visited entry. */ HDassert(entry_pages <= 0); - entry_size = entry_ptr->size; + entry_size = entry_ptr->size; entry_pages = (int64_t)(entry_size / pb_ptr->page_size); - if ( (uint64_t)entry_pages * pb_ptr->page_size < entry_size ) { + if ((uint64_t)entry_pages * pb_ptr->page_size < entry_size) { entry_pages++; } /* remove the entry */ - if ( H5PB_remove_entry(shared, entry_ptr->addr) < 0 ) - - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "H5PB_remove_entry() failed") + if (H5PB_remove_entry(shared, entry_ptr->addr) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "H5PB_remove_entry() failed") } entry_pages--; } @@ -1767,16 +1677,15 @@ done: } /* H5PB_remove_entries() */ - /*------------------------------------------------------------------------- * * Function: H5PB_update_entry * - * Purpose: In PHDF5, metadata cache entries that are written by other + * Purpose: In PHDF5, metadata cache entries that are written by other * processes are simply marked clean in the current process. * However, if the page buffer is enabled, entries marked - * clean must still be written to the page buffer so as to - * keep the contents of metadata pages consistent on all + * clean must still be written to the page buffer so as to + * keep the contents of metadata pages consistent on all * processes. * * Do this as follows: @@ -1785,13 +1694,13 @@ done: * metadata pages. If it isn't, return. * * 2) Test to see if the page buffer contains the page that - * contains the supplied metadata cache entry. If it + * contains the supplied metadata cache entry. If it * doesn't, return. * - * 3) Write the supplied buffer to page at the appropriate + * 3) Write the supplied buffer to page at the appropriate * offset. * - * Note that at present, page buffering is disabled in the + * Note that at present, page buffering is disabled in the * parallel case. Thus this function has not been tested. * * Return: Non-negative on success/Negative on failure @@ -1802,14 +1711,14 @@ done: * *------------------------------------------------------------------------- */ -herr_t +herr_t H5PB_update_entry(H5PB_t *pb_ptr, haddr_t addr, size_t size, const void *buf) { - uint64_t page; - size_t offset; + uint64_t page; + size_t offset; H5PB_entry_t *entry_ptr = NULL; - haddr_t page_addr; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t page_addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1820,26 +1729,25 @@ H5PB_update_entry(H5PB_t *pb_ptr, haddr_t addr, size_t size, const void *buf) HDassert(size <= pb_ptr->page_size); HDassert(buf); - if ( pb_ptr->min_rd_pages < pb_ptr->max_pages ) { + if (pb_ptr->min_rd_pages < pb_ptr->max_pages) { /* page buffer is configured to accept metadata pages */ /* Calculate the aligned address of the containing page */ - page = (addr / pb_ptr->page_size); + page = (addr / pb_ptr->page_size); page_addr = page * pb_ptr->page_size; H5PB__SEARCH_INDEX(pb_ptr, page, entry_ptr, FAIL) - if ( entry_ptr ) { + if (entry_ptr) { - HDassert( entry_ptr->is_metadata ); - HDassert( ! (entry_ptr->is_mpmde) ); + HDassert(entry_ptr->is_metadata); + HDassert(!(entry_ptr->is_mpmde)); HDassert(addr + size <= page_addr + pb_ptr->page_size); offset = addr - page_addr; - HDmemcpy(((uint8_t *)(entry_ptr->image_ptr) + offset), - buf, size); + HDmemcpy(((uint8_t *)(entry_ptr->image_ptr) + offset), buf, size); /* should we mark the page dirty? If so, replace the following * with a call to H5PB__mark_entry_dirty() @@ -1854,12 +1762,11 @@ done: } /* H5PB_update_entry */ - /*------------------------------------------------------------------------- * * Function: H5PB_vfd_swmr__release_delayed_writes * - * Purpose: After the tick list has been released, and before the + * Purpose: After the tick list has been released, and before the * beginning of the next tick, we must scan the delayed * write list, and release those entries whose delays have * expired. @@ -1867,10 +1774,10 @@ done: * Note that pages of metadata, and multi-page metadata entries * are handled differently. * - * Regular pages are removed from the delayed write list and + * Regular pages are removed from the delayed write list and * inserted in the replacement policy * - * In contrast, multi-page metadata entries are simply + * In contrast, multi-page metadata entries are simply * flushed and evicted. * * Since the delayed write list is sorted in decreasing @@ -1886,12 +1793,12 @@ done: * *------------------------------------------------------------------------- */ -herr_t +herr_t H5PB_vfd_swmr__release_delayed_writes(H5F_shared_t *shared) { - H5PB_t * pb_ptr = NULL; + H5PB_t * pb_ptr = NULL; H5PB_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1906,8 +1813,7 @@ H5PB_vfd_swmr__release_delayed_writes(H5F_shared_t *shared) HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); HDassert(pb_ptr->vfd_swmr_writer); - while (pb_ptr->dwl_tail_ptr && - pb_ptr->dwl_tail_ptr->delay_write_until <= shared->tick_num) { + while (pb_ptr->dwl_tail_ptr && pb_ptr->dwl_tail_ptr->delay_write_until <= shared->tick_num) { entry_ptr = pb_ptr->dwl_tail_ptr; @@ -1917,19 +1823,17 @@ H5PB_vfd_swmr__release_delayed_writes(H5F_shared_t *shared) H5PB__REMOVE_FROM_DWL(pb_ptr, entry_ptr, FAIL) - if ( entry_ptr->is_mpmde ) { /* flush and evict now */ - - if ( H5PB__flush_entry(shared, pb_ptr, entry_ptr) < 0 ) + if (entry_ptr->is_mpmde) { /* flush and evict now */ - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "flush of mpmde failed") + if (H5PB__flush_entry(shared, pb_ptr, entry_ptr) < 0) - if ( H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0 ) + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "flush of mpmde failed") - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "eviction of mpmde failed") + if (H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0) - } else { /* insert it in the replacement policy */ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "eviction of mpmde failed") + } + else { /* insert it in the replacement policy */ H5PB__UPDATE_RP_FOR_INSERT_APPEND(pb_ptr, entry_ptr, FAIL) } @@ -1941,12 +1845,11 @@ done: } /* H5PB_vfd_swmr__release_delayed_writes() */ - /*------------------------------------------------------------------------- * * Function: H5PB_vfd_swmr__release_tick_list * - * Purpose: After the metadata file has been updated, and before the + * Purpose: After the metadata file has been updated, and before the * beginning of the next tick, we must release the tick list. * * This function performs this function. @@ -1962,12 +1865,12 @@ done: * *------------------------------------------------------------------------- */ -herr_t +herr_t H5PB_vfd_swmr__release_tick_list(H5F_shared_t *shared) { - H5PB_t * pb_ptr = NULL; + H5PB_t * pb_ptr = NULL; H5PB_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1983,7 +1886,7 @@ H5PB_vfd_swmr__release_tick_list(H5F_shared_t *shared) HDassert(pb_ptr->vfd_swmr_writer); /* remove all entries from the tick list */ - while ( pb_ptr->tl_head_ptr ) { + while (pb_ptr->tl_head_ptr) { entry_ptr = pb_ptr->tl_head_ptr; @@ -1991,22 +1894,20 @@ H5PB_vfd_swmr__release_tick_list(H5F_shared_t *shared) entry_ptr->modified_this_tick = FALSE; - if ( entry_ptr->is_mpmde ) { - + if (entry_ptr->is_mpmde) { + HDassert(entry_ptr->is_dirty); - if ( entry_ptr->delay_write_until == 0 ) { + if (entry_ptr->delay_write_until == 0) { /* flush and evict the multi-page metadata entry immediately */ - if ( H5PB__flush_entry(shared, pb_ptr, entry_ptr) < 0 ) + if (H5PB__flush_entry(shared, pb_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "flush of mpmde failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "flush of mpmde failed") - if ( H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0 ) + if (H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "eviction of mpmde failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "eviction of mpmde failed") } } /* if the entry is not a multi-page metadata entry, it must already @@ -2026,13 +1927,12 @@ done: } /* H5PB_vfd_swmr__release_tick_list */ - /*------------------------------------------------------------------------- * * Function: H5PB_vfd_swmr__set_tick * * Purpose: At the beginning of each tick, the page buffer must be told - * to synchronize its copy of the current tick with that of + * to synchronize its copy of the current tick with that of * the file to which the page buffer belongs. * * This function performs this function. @@ -2045,11 +1945,11 @@ done: * *------------------------------------------------------------------------- */ -herr_t +herr_t H5PB_vfd_swmr__set_tick(H5F_shared_t *shared) { - H5PB_t * pb_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5PB_t *pb_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2065,10 +1965,11 @@ H5PB_vfd_swmr__set_tick(H5F_shared_t *shared) HDassert(pb_ptr->vfd_swmr_writer); /* the tick must always increase by 1 -- verify this */ - if ( shared->tick_num != pb_ptr->cur_tick + 1 ) + if (shared->tick_num != pb_ptr->cur_tick + 1) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "shared->tick_num (%" PRIu64 ") != (%" PRIu64 ") pb_ptr->cur_tick + 1 ?!?!", shared->tick_num, pb_ptr->cur_tick) + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, + "shared->tick_num (%" PRIu64 ") != (%" PRIu64 ") pb_ptr->cur_tick + 1 ?!?!", + shared->tick_num, pb_ptr->cur_tick) pb_ptr->cur_tick = shared->tick_num; @@ -2078,82 +1979,81 @@ done: } /* H5PB_vfd_swmr__release_tick_list */ - /*------------------------------------------------------------------------- * * Function: H5PB_vfd_swmr__update_index * - * Purpose: In the VFD SWMR writer, all metadata writes to the page - * buffer during a tick are buffered in the page buffer in - * the tick list. Further, the metadata cache is flushed - * to the page buffer at the end of the tick so that all - * metadata changes during the tick are reflected in the + * Purpose: In the VFD SWMR writer, all metadata writes to the page + * buffer during a tick are buffered in the page buffer in + * the tick list. Further, the metadata cache is flushed + * to the page buffer at the end of the tick so that all + * metadata changes during the tick are reflected in the * tick list. * - * Once this is done, the internal representation of the - * metadata file index must be updated from the tick list - * so that the metadata file can be updated, and the tick + * Once this is done, the internal representation of the + * metadata file index must be updated from the tick list + * so that the metadata file can be updated, and the tick * list can be emptied and prepared to buffer metadata changes * in the next tick. * * This function is called to accomplish this. Its cycle of * operation is as follows: * - * 1) Scan the tick list. For each entry (*entry), test + * 1) Scan the tick list. For each entry (*entry), test * to see if it appears in the index. * - * If it does the entry must have been modified in the + * If it does the entry must have been modified in the * past tick. Update the index entry (*ie_ptr) as follows: * - * a) Set ie_ptr->entry_ptr = entry->image_ptr. This - * is needed to give the metadata file update code + * a) Set ie_ptr->entry_ptr = entry->image_ptr. This + * is needed to give the metadata file update code * access to the image of the target page or multi-page * multi-date entry. Note that ie_ptr->entry_ptr will * be set to NULL as soon as the metadata file is updated, - * so the buffer pointed to by entry->image_ptr can - * be safely discarded at any time after the metadata + * so the buffer pointed to by entry->image_ptr can + * be safely discarded at any time after the metadata * file update. * * b) Set ie_ptr->tick_of_last_change to the current tick. * * c) If entry->is_dirty, set ie_ptr->clean to FALSE. * If entry->is_dirty is FALSE, set ie_ptr->clean - * to TRUE and set ie_ptr->tick_of_last_flush to the + * to TRUE and set ie_ptr->tick_of_last_flush to the * current tick. * - * If the tick list entry (*entry) doesn't appear in - * the index, allocate a metadata file index entry (*ie_ptr), + * If the tick list entry (*entry) doesn't appear in + * the index, allocate a metadata file index entry (*ie_ptr), * and initialize it as follows: * * ie_ptr->hdf5_page_offset = entry->page * ie_ptr->length = entry->size * ie_ptr->delayed_flush = entry->delay_write_until - * + * * and then update the new entry as per the existing entry * case described above. * - * 2) Scan the internal representation of the metadata file + * 2) Scan the internal representation of the metadata file * index for entries that do not appear in the tick list. * For each such entry (*ie_ptr), proceed as follows: * - * 1) If ie_ptr->clean, we are done -- proceed to the + * 1) If ie_ptr->clean, we are done -- proceed to the * next index entry that doesn't appear in the tick list. * - * 2) Test to see if the cognate entry appears in the page + * 2) Test to see if the cognate entry appears in the page * buffer. If it doesn't, it must have been flushed and * evicted in the past tick. Set * - * ie_ptr->clean = TRUE, and + * ie_ptr->clean = TRUE, and * * ie_ptr->tick_of_last_flush = current tick * - * and proceed to the next index entry that doesn't + * and proceed to the next index entry that doesn't * appear in the tick list. * * 3) If the cognate entry does appear in the page buffer * and is clean, proceed as per 2) above. * - * 4) In all other cases, do nothing, and proceed to the + * 4) In all other cases, do nothing, and proceed to the * next index entry that does not appear in the tick list. * * @@ -2166,24 +2066,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5PB_vfd_swmr__update_index(H5F_t *f, - uint32_t * idx_ent_added_ptr, - uint32_t * idx_ent_modified_ptr, - uint32_t * idx_ent_not_in_tl_ptr, - uint32_t * idx_ent_not_in_tl_flushed_ptr) +H5PB_vfd_swmr__update_index(H5F_t *f, uint32_t *idx_ent_added_ptr, uint32_t *idx_ent_modified_ptr, + uint32_t *idx_ent_not_in_tl_ptr, uint32_t *idx_ent_not_in_tl_flushed_ptr) { - H5F_shared_t * const shared = f->shared; - const uint64_t tick_num = shared->tick_num; - uint32_t i; - uint32_t idx_ent_added = 0; - uint32_t idx_ent_modified = 0; - uint32_t idx_ent_not_in_tl = 0; - uint32_t idx_ent_not_in_tl_flushed = 0; - H5PB_t * pb_ptr = NULL; - H5PB_entry_t *entry; - H5FD_vfd_swmr_idx_entry_t * ie_ptr = NULL; - H5FD_vfd_swmr_idx_entry_t * idx = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5F_shared_t *const shared = f->shared; + const uint64_t tick_num = shared->tick_num; + uint32_t i; + uint32_t idx_ent_added = 0; + uint32_t idx_ent_modified = 0; + uint32_t idx_ent_not_in_tl = 0; + uint32_t idx_ent_not_in_tl_flushed = 0; + H5PB_t * pb_ptr = NULL; + H5PB_entry_t * entry; + H5FD_vfd_swmr_idx_entry_t *ie_ptr = NULL; + H5FD_vfd_swmr_idx_entry_t *idx = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2216,20 +2113,16 @@ H5PB_vfd_swmr__update_index(H5F_t *f, /* see if the shadow index already contains an entry for *entry. */ - ie_ptr = vfd_swmr_pageno_to_mdf_idx_entry(idx, - shared->mdf_idx_entries_used, target_page, FALSE); + ie_ptr = vfd_swmr_pageno_to_mdf_idx_entry(idx, shared->mdf_idx_entries_used, target_page, FALSE); - if ( ie_ptr == NULL ) { /* alloc new entry in the metadata file index*/ + if (ie_ptr == NULL) { /* alloc new entry in the metadata file index*/ uint32_t new_index_entry_index; - new_index_entry_index = shared->mdf_idx_entries_used + - idx_ent_added++; + new_index_entry_index = shared->mdf_idx_entries_used + idx_ent_added++; if (new_index_entry_index >= shared->mdf_idx_len && (idx = vfd_swmr_enlarge_shadow_index(f)) == NULL) { - HDfprintf(stderr, - "\n\nmax mdf index len (%" PRIu32 ") exceeded.\n\n", - shared->mdf_idx_len); + HDfprintf(stderr, "\n\nmax mdf index len (%" PRIu32 ") exceeded.\n\n", shared->mdf_idx_len); HDfprintf(stderr, "tick = %" PRIu64 ".\n", tick_num); HDexit(EXIT_FAILURE); } @@ -2237,19 +2130,19 @@ H5PB_vfd_swmr__update_index(H5F_t *f, ie_ptr = idx + new_index_entry_index; /* partial initialization of new entry -- rest done later */ - ie_ptr->hdf5_page_offset = target_page; - ie_ptr->md_file_page_offset = 0; /* undefined at this point */ - ie_ptr->chksum = 0; /* undefined at this point */ + ie_ptr->hdf5_page_offset = target_page; + ie_ptr->md_file_page_offset = 0; /* undefined at this point */ + ie_ptr->chksum = 0; /* undefined at this point */ /* ie_ptr->entry_ptr initialized below */ /* ie_ptr->tick_of_last_change initialized below */ /* ie_ptr->clean initialized below */ /* ie_ptr->tick_of_last_flush initialized below */ - ie_ptr->delayed_flush = entry->delay_write_until; - ie_ptr->moved_to_lower_file = FALSE; - ie_ptr->garbage = FALSE; - ie_ptr->length = (uint32_t)entry->size; - - } else { + ie_ptr->delayed_flush = entry->delay_write_until; + ie_ptr->moved_to_lower_file = FALSE; + ie_ptr->garbage = FALSE; + ie_ptr->length = (uint32_t)entry->size; + } + else { /* If entry->size changed, discard the too-small (too-big?) * shadow region and set the shadow-file page number to 0 * so that H5F_update_vfd_swmr_metadata_file() will @@ -2262,16 +2155,16 @@ H5PB_vfd_swmr__update_index(H5F_t *f, HDassert(ret == 0); ie_ptr->md_file_page_offset = 0; - ie_ptr->length = (uint32_t)entry->size; + ie_ptr->length = (uint32_t)entry->size; } idx_ent_modified++; } - ie_ptr->entry_ptr = entry->image_ptr; - ie_ptr->tick_of_last_change = tick_num; + ie_ptr->entry_ptr = entry->image_ptr; + ie_ptr->tick_of_last_change = tick_num; HDassert(entry->is_dirty); - ie_ptr->clean = FALSE; + ie_ptr->clean = FALSE; ie_ptr->tick_of_last_flush = 0; } @@ -2280,10 +2173,9 @@ H5PB_vfd_swmr__update_index(H5F_t *f, * in the page buffer, or is clean in the page buffer, mark the index * entry clean and as having been flushed in the current tick. */ - for ( i = 0; i < shared->mdf_idx_entries_used; i++ ) { + for (i = 0; i < shared->mdf_idx_entries_used; i++) { - HDassert(i == 0 || - idx[i - 1].hdf5_page_offset < idx[i].hdf5_page_offset); + HDassert(i == 0 || idx[i - 1].hdf5_page_offset < idx[i].hdf5_page_offset); ie_ptr = idx + i; @@ -2299,16 +2191,14 @@ H5PB_vfd_swmr__update_index(H5F_t *f, if (entry == NULL || !entry->is_dirty) { idx_ent_not_in_tl_flushed++; - ie_ptr->clean = TRUE; + ie_ptr->clean = TRUE; ie_ptr->tick_of_last_flush = tick_num; } } - HDassert(idx_ent_modified + idx_ent_not_in_tl == - shared->mdf_idx_entries_used); + HDassert(idx_ent_modified + idx_ent_not_in_tl == shared->mdf_idx_entries_used); - HDassert(idx_ent_modified + idx_ent_not_in_tl + idx_ent_added <= - shared->mdf_idx_len); + HDassert(idx_ent_modified + idx_ent_not_in_tl + idx_ent_added <= shared->mdf_idx_len); *idx_ent_added_ptr = idx_ent_added; *idx_ent_modified_ptr = idx_ent_modified; @@ -2321,7 +2211,6 @@ done: } /* H5PB_vfd_swmr__update_index() */ - /*------------------------------------------------------------------------- * * Function: H5PB_write @@ -2329,32 +2218,32 @@ done: * Purpose: Write data into the Page Buffer if practical, and to file * otherwise. Specifically: * - * 1) If the page buffer is disabled, simply write to the + * 1) If the page buffer is disabled, simply write to the * HDF5 file and return. * - * 2) If the write is raw data, and the page buffer is - * configured for metadata only (i.e. min_md_pages == - * max_pages), or if the page buffer is operating in + * 2) If the write is raw data, and the page buffer is + * configured for metadata only (i.e. min_md_pages == + * max_pages), or if the page buffer is operating in * vfd_swmr mode, simply write to the HDF5 file and return. * - * 3) If the write is raw data, and is of page size or - * larger, write directly from the HDF5 file. + * 3) If the write is raw data, and is of page size or + * larger, write directly from the HDF5 file. * - * It is possible that the write intersects one or more + * It is possible that the write intersects one or more * pages in the page buffer -- test for this and update - * any partially written pages, and evict any pages + * any partially written pages, and evict any pages * that are completely overwritten. * - * Note that no pages are inserted into the page buffer in + * Note that no pages are inserted into the page buffer in * this case. * - * 4) If the write is of raw data, and it is of size less + * 4) If the write is of raw data, and it is of size less * than the page size, write the page into the page - * buffer, loading and inserting pages into the + * buffer, loading and inserting pages into the * page buffer as necessary * - * 5) If the write is of metadata, and the page buffer is - * configured for raw data only (i.e. min_rd_pages == + * 5) If the write is of metadata, and the page buffer is + * configured for raw data only (i.e. min_rd_pages == * max_pages), simply write to the HDF5 file and return. * * The free space manager guarantees that allocations larger @@ -2394,68 +2283,68 @@ done: * we have to program around the issue for now. * * Fortunately, for purposes of the page buffer, this is - * relatively easy -- when we encounter a metadata write - * that crosses one or more page boundaries, and is not - * both page aligned and an integral number of pages, we - * query the metadata cache to determine the type of the + * relatively easy -- when we encounter a metadata write + * that crosses one or more page boundaries, and is not + * both page aligned and an integral number of pages, we + * query the metadata cache to determine the type of the * client whose data is being writtne. If it is one of the * mis-behaving types, we split it into two or three writes * such that each write either doesn't cross page boundaries, * or is page aligned and an integral number of pages. * - * This is done in this function, and is not reflected in + * This is done in this function, and is not reflected in * the case analysis in the rest of this comment. * * 6) If the write is of metadata, the write is larger than - * one page, and vfd_swmr_writer is FALSE, simply write - * to the HDF5 file. There is no need to check the - * page buffer, as metadata is always read atomically, - * and entries of this size are not buffered in the page + * one page, and vfd_swmr_writer is FALSE, simply write + * to the HDF5 file. There is no need to check the + * page buffer, as metadata is always read atomically, + * and entries of this size are not buffered in the page * buffer. * - * Observe that this write must be page aligned. This + * Observe that this write must be page aligned. This * should be enforced by the free space manager, but * for now it is enforced by the above mentioned practice - * of splitting writes from cache client that don't + * of splitting writes from cache client that don't * allocate each entry separately. * * 7) If the write is of metadata, the write is larger than * one page, and vfd_swmr_writer is TRUE, the write must * buffered in the page buffer until the end of the tick. * - * If it doesn't exist already, create a multi-page metadata - * entry in the page buffer and copy the write into it. + * If it doesn't exist already, create a multi-page metadata + * entry in the page buffer and copy the write into it. * Insert the new entry in the tick list if necessary. * - * Test to see if the write of the multi-page metadata - * entry must be delayed. If so, place the entry in + * Test to see if the write of the multi-page metadata + * entry must be delayed. If so, place the entry in * the delayed write list. Otherwise, the multi-page * metadata entry will be written to the HDF5 file and - * evicted when the tick list is released at the of the + * evicted when the tick list is released at the of the * tick. * * * 8) If the write is of metadata, and the write is of size * less than or equal to the page size, write the data - * into the page buffer, loading and inserting a page + * into the page buffer, loading and inserting a page * if necessary. * * If, in addition, vfd_swmr_writer is TRUE, add the page * touched by the write to the tick list. - * - * Observe that this function handles casses 1, 2, 5, and 6 - * directly, calls H5PB_write_raw() for cases 3 & 4, and + * + * Observe that this function handles casses 1, 2, 5, and 6 + * directly, calls H5PB_write_raw() for cases 3 & 4, and * calls H5PB_read_meta() for cases 7, and 8. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer -- 10/11/18 * - * Changes: Updated to support splitting of metadata writes that - * are not page aligned and cross page boundaries into + * Changes: Updated to support splitting of metadata writes that + * are not page aligned and cross page boundaries into * 2 or 3 writes that are either page aligned or do not - * cross page boundaries. Full details in the header - * comment above, that has been updated to document + * cross page boundaries. Full details in the header + * comment above, that has been updated to document * this change. * * Also updated case 2 to bypass the page buffer for raw @@ -2466,21 +2355,20 @@ done: *------------------------------------------------------------------------- */ herr_t -H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, - const void *buf) +H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { - H5PB_t *pb_ptr; /* Page buffer for this file */ - hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ - hbool_t split_write = FALSE; /* whether md write must be split */ - herr_t ret_value = SUCCEED; /* Return value */ + H5PB_t *pb_ptr; /* Page buffer for this file */ + hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ + hbool_t split_write = FALSE; /* whether md write must be split */ + herr_t ret_value = SUCCEED; /* Return value */ /* the following six fields are defined iff split_write is TRUE */ - haddr_t prefix_addr = HADDR_UNDEF; /* addr of prefix -- if defined */ - haddr_t body_addr = HADDR_UNDEF; /* addr of body -- if defined */ - haddr_t suffix_addr = HADDR_UNDEF; /* addr of suffix -- if defined */ - size_t prefix_size = 0; /* size of prefix */ - size_t body_size = 0; /* size of body */ - size_t suffix_size = 0; /* size of suffix */ + haddr_t prefix_addr = HADDR_UNDEF; /* addr of prefix -- if defined */ + haddr_t body_addr = HADDR_UNDEF; /* addr of body -- if defined */ + haddr_t suffix_addr = HADDR_UNDEF; /* addr of suffix -- if defined */ + size_t prefix_size = 0; /* size of prefix */ + size_t body_size = 0; /* size of body */ + size_t suffix_size = 0; /* size of suffix */ FUNC_ENTER_NOAPI(FAIL) @@ -2489,67 +2377,66 @@ H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, if (pb_ptr != NULL && type != H5FD_MEM_DRAW) H5PB_count_meta_access_by_size(pb_ptr, size); - if ( pb_ptr == NULL ) { + if (pb_ptr == NULL) { bypass_pb = TRUE; /* case 1) -- page buffer is disabled */ - - } else { + } + else { HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); - if ( H5FD_MEM_DRAW == type ) { /* raw data write */ + if (H5FD_MEM_DRAW == type) { /* raw data write */ - if ( ( pb_ptr->min_md_pages == pb_ptr->max_pages ) || - ( pb_ptr->vfd_swmr ) ) { + if ((pb_ptr->min_md_pages == pb_ptr->max_pages) || (pb_ptr->vfd_swmr)) { /* case 2) -- page buffer configured for metadata only */ bypass_pb = TRUE; - } - } else { /* metadata write */ + } + else { /* metadata write */ - if ( pb_ptr->min_rd_pages == pb_ptr->max_pages ) { + if (pb_ptr->min_rd_pages == pb_ptr->max_pages) { /* case 5) -- page buffer configured for raw data only */ bypass_pb = TRUE; - - } else { + } + else { /* determine whether the write request must be split, * and if so, compute the start points and sizes of * of the sections. * - * Note: The following code is almost identical to the - * similar code in H5PB_read(). Thus, on the surface, - * it is an obvious candidate for refactoring into a + * Note: The following code is almost identical to the + * similar code in H5PB_read(). Thus, on the surface, + * it is an obvious candidate for refactoring into a * function or macro. * - * However, there are subtle differences between - * the two pieces of code which are driven by the - * possibility of speculative reads. + * However, there are subtle differences between + * the two pieces of code which are driven by the + * possibility of speculative reads. * - * More to the point, further changes may be necessary. - * Thus we should wait on refactoring until this code has - * been in daily use for some time, and it is clear + * More to the point, further changes may be necessary. + * Thus we should wait on refactoring until this code has + * been in daily use for some time, and it is clear * that further changes are unlikely. */ - int mdc_client_id = -1; /* id of mdc client, or -1 if undef */ - uint64_t start_page; /* page index of first page in read */ - uint64_t second_page; /* page index of second page in read */ - uint64_t end_page; /* page index of last page in read */ - uint64_t body_page; /* page index of start of body */ - haddr_t start_page_addr; /* addr of first page in read */ - haddr_t second_page_addr;/* addr of second page in read */ - haddr_t end_page_addr; /* addr of last page in read */ - haddr_t end_addr; /* addr of last byte in read */ + int mdc_client_id = -1; /* id of mdc client, or -1 if undef */ + uint64_t start_page; /* page index of first page in read */ + uint64_t second_page; /* page index of second page in read */ + uint64_t end_page; /* page index of last page in read */ + uint64_t body_page; /* page index of start of body */ + haddr_t start_page_addr; /* addr of first page in read */ + haddr_t second_page_addr; /* addr of second page in read */ + haddr_t end_page_addr; /* addr of last page in read */ + haddr_t end_addr; /* addr of last byte in read */ /* Calculate the aligned address of the first page */ - start_page = (addr / pb_ptr->page_size); + start_page = (addr / pb_ptr->page_size); start_page_addr = start_page * pb_ptr->page_size; /* Calculate the aligned address of the last page */ - end_addr = addr + (haddr_t)(size - 1); - end_page = end_addr / (haddr_t)(pb_ptr->page_size); + end_addr = addr + (haddr_t)(size - 1); + end_page = end_addr / (haddr_t)(pb_ptr->page_size); end_page_addr = end_page * pb_ptr->page_size; HDassert(start_page_addr <= addr); @@ -2557,17 +2444,15 @@ H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, HDassert(start_page <= end_page); HDassert(end_page_addr <= ((addr + (haddr_t)size - 1))); - HDassert((addr + (haddr_t)size - 1) < - (end_page_addr + pb_ptr->page_size)); + HDassert((addr + (haddr_t)size - 1) < (end_page_addr + pb_ptr->page_size)); /* test to see if the write crosses a page boundary, and * does not start on a page boundary, and is not of an * integral number of pages. */ - if ( ( start_page < end_page ) && - ( ! ( ( addr == start_page_addr ) && - ( end_page_addr + (haddr_t)(pb_ptr->page_size) == - end_addr + 1 ) ) ) ) { + if ((start_page < end_page) && + (!((addr == start_page_addr) && + (end_page_addr + (haddr_t)(pb_ptr->page_size) == end_addr + 1)))) { /* the read crosses a page boundary and is not * page aligned and of length some multiple of page size. @@ -2580,17 +2465,17 @@ H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, */ mdc_client_id = H5C_get_curr_io_client_type(shared->cache); - if ( ( mdc_client_id == (int)H5AC_EARRAY_DBLK_PAGE_ID ) || \ - ( mdc_client_id == (int)H5AC_FARRAY_DBLK_PAGE_ID ) ) { + if ((mdc_client_id == (int)H5AC_EARRAY_DBLK_PAGE_ID) || + (mdc_client_id == (int)H5AC_FARRAY_DBLK_PAGE_ID)) { split_write = TRUE; - - } else { + } + else { HDassert(addr == start_page_addr); HDassert(size > pb_ptr->page_size); - if ( ! pb_ptr->vfd_swmr_writer ) { + if (!pb_ptr->vfd_swmr_writer) { /* case 6) -- multi-page entry with fixed / * extensible array filtered out, and no @@ -2599,22 +2484,22 @@ H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, bypass_pb = TRUE; } } - } else if ( ( size > pb_ptr->page_size ) && - ( ! pb_ptr->vfd_swmr_writer ) ) { + } + else if ((size > pb_ptr->page_size) && (!pb_ptr->vfd_swmr_writer)) { /* write is larger than page size and we are not * in VFD SWMR mode -- bypass the page buffer. * This is also case 6. We catch it here as * the code to determine whether to split only * looks at I/O requests that cross page bundaries - * and are not both page aligned and an integral + * and are not both page aligned and an integral * number of pages in length. */ HDassert(start_page_addr == addr); bypass_pb = TRUE; } - if ( split_write ) { + if (split_write) { /* compute the base addresses and length of the prefix, * body, and suffix of the write, where these terms are @@ -2642,74 +2527,62 @@ H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, * non-empty. */ - second_page = start_page + 1; - second_page_addr = - (haddr_t)(second_page * pb_ptr->page_size); + second_page = start_page + 1; + second_page_addr = (haddr_t)(second_page * pb_ptr->page_size); - if ( addr > start_page_addr ) { /* prefix exists */ + if (addr > start_page_addr) { /* prefix exists */ prefix_addr = addr; prefix_size = (size_t)(second_page_addr - addr); HDassert(prefix_addr > start_page_addr); HDassert(prefix_size < pb_ptr->page_size); - HDassert(((size_t)(addr - start_page_addr) + \ - prefix_size) == pb_ptr->page_size); + HDassert(((size_t)(addr - start_page_addr) + prefix_size) == pb_ptr->page_size); } - if ( size - prefix_size >= pb_ptr->page_size ) { + if (size - prefix_size >= pb_ptr->page_size) { /* body exists */ - if ( addr == start_page_addr ) { + if (addr == start_page_addr) { body_page = start_page; body_addr = start_page_addr; - - } else { + } + else { body_page = second_page; body_addr = second_page_addr; } - if ( end_addr < end_page_addr + - (haddr_t)(pb_ptr->page_size - 1) ) { + if (end_addr < end_page_addr + (haddr_t)(pb_ptr->page_size - 1)) { /* suffix exists */ - body_size = (size_t)(end_page - body_page) * - pb_ptr->page_size; - - } else { + body_size = (size_t)(end_page - body_page) * pb_ptr->page_size; + } + else { /* suffix is empty */ - body_size = (size_t)(end_page - body_page + 1) * - pb_ptr->page_size; + body_size = (size_t)(end_page - body_page + 1) * pb_ptr->page_size; } - HDassert((body_page == start_page) || \ - (body_page == start_page + 1)); + HDassert((body_page == start_page) || (body_page == start_page + 1)); - HDassert(body_addr == \ - (haddr_t)(body_page * pb_ptr->page_size)); + HDassert(body_addr == (haddr_t)(body_page * pb_ptr->page_size)); HDassert(body_size < size); HDassert(body_size >= pb_ptr->page_size); - - HDassert(body_addr == \ - addr + (haddr_t)prefix_size); - HDassert((body_addr + (haddr_t)body_size) \ - <= (end_addr + 1)); + HDassert(body_addr == addr + (haddr_t)prefix_size); + HDassert((body_addr + (haddr_t)body_size) <= (end_addr + 1)); } - if ( end_addr < end_page_addr + - (haddr_t)(pb_ptr->page_size - 1) ) { + if (end_addr < end_page_addr + (haddr_t)(pb_ptr->page_size - 1)) { suffix_addr = end_page_addr; suffix_size = (end_addr + 1) - end_page_addr; - HDassert(suffix_addr == \ - addr + (haddr_t)(prefix_size + body_size)); + HDassert(suffix_addr == addr + (haddr_t)(prefix_size + body_size)); } HDassert(size == prefix_size + body_size + suffix_size); @@ -2722,112 +2595,100 @@ H5PB_write(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, /* at present, the page buffer must be disabled in the parallel case. * However, just in case ... */ - if(H5F_SHARED_HAS_FEATURE(shared, H5FD_FEAT_HAS_MPI)) { + if (H5F_SHARED_HAS_FEATURE(shared, H5FD_FEAT_HAS_MPI)) { bypass_pb = TRUE; - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ + if (bypass_pb) { /* cases 1, 2. 5, and 6 */ - if ( bypass_pb ) { /* cases 1, 2. 5, and 6 */ + if (H5FD_write(shared->lf, type, addr, size, buf) < 0) - if ( H5FD_write(shared->lf, type, addr, size, buf) < 0 ) - - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, - "write through lower VFD failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "write through lower VFD failed") /* Update statistics */ - if ( pb_ptr ) { + if (pb_ptr) { H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size); } - } else { - - if ( H5FD_MEM_DRAW == type ) { /* cases 3 and 4 */ + } + else { - if ( H5PB__write_raw(shared, type, addr, size, buf) < 0 ) + if (H5FD_MEM_DRAW == type) { /* cases 3 and 4 */ - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "H5PB_read_raw() failed") + if (H5PB__write_raw(shared, type, addr, size, buf) < 0) - } else if ( split_write ) { + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "H5PB_read_raw() failed") + } + else if (split_write) { /* handle the sub-allocated entry case */ /* write prefix if it exists */ - if ( prefix_size > 0 ) { + if (prefix_size > 0) { - if ( H5PB__write_meta(shared, type, addr, - prefix_size, buf) < 0 ) + if (H5PB__write_meta(shared, type, addr, prefix_size, buf) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "H5PB__write_meta() failed on prefix") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "H5PB__write_meta() failed on prefix") } /* write the body if it exists */ - if ( body_size > 0 ) { + if (body_size > 0) { - /* The "body_size == pb_ptr->page_size" clause in the + /* The "body_size == pb_ptr->page_size" clause in the * following if is required since in normal operating - * mode, the page buffer buffers metadata I/O + * mode, the page buffer buffers metadata I/O * requests of page size or less. * * Thus this clause ensures that a single page body * does not bypass the page buffer, setting the potential * for an older version to shadow the most recent version. * - * Note: The page buffer really shouldn't buffer page - * aligned single page metadata I/O requests, as it + * Note: The page buffer really shouldn't buffer page + * aligned single page metadata I/O requests, as it * creates extra overhead to no purpose. However, - * fixing this is a bit tricky, and the case doesn't - * appear to be common. Thus, while it should be + * fixing this is a bit tricky, and the case doesn't + * appear to be common. Thus, while it should be * fixed, I don't think it is urgent. - * + * * JRM 4/19/20 */ - if ( ( pb_ptr->vfd_swmr ) || - ( body_size == pb_ptr->page_size ) ) { - - if ( H5PB__write_meta(shared, type, body_addr, body_size, - (const void *)((const uint8_t *)buf + - prefix_size)) < 0 ) + if ((pb_ptr->vfd_swmr) || (body_size == pb_ptr->page_size)) { - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "H5PB__write_meta() failed on body") + if (H5PB__write_meta(shared, type, body_addr, body_size, + (const void *)((const uint8_t *)buf + prefix_size)) < 0) - } else { + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "H5PB__write_meta() failed on body") + } + else { - if ( H5FD_write(shared->lf, type, body_addr, body_size, - (const void *)((const uint8_t *)buf + - prefix_size)) < 0 ) + if (H5FD_write(shared->lf, type, body_addr, body_size, + (const void *)((const uint8_t *)buf + prefix_size)) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "write through of body failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "write through of body failed") H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size); } } /* write the suffix if it exists */ - if ( suffix_size > 0 ) { + if (suffix_size > 0) { - if ( H5PB__write_meta(shared, type, suffix_addr, suffix_size, - (const void *)((const uint8_t *)buf + - prefix_size + body_size)) < 0 ) + if (H5PB__write_meta(shared, type, suffix_addr, suffix_size, + (const void *)((const uint8_t *)buf + prefix_size + body_size)) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "H5PB_write_meta() failed on suffix") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "H5PB_write_meta() failed on suffix") } H5PB__UPDATE_STATS_FOR_WRITE_SPLIT(pb_ptr) + } + else { /* cases 7, and 8 */ - } else { /* cases 7, and 8 */ - - if ( H5PB__write_meta(shared, type, addr, size, buf) < 0 ) + if (H5PB__write_meta(shared, type, addr, size, buf) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "H5PB_write_meta() failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "H5PB_write_meta() failed") } } @@ -2837,7 +2698,6 @@ done: } /* end H5PB_write() */ - /**************************************************************************/ /***************************** STATIC FUNCTIONS ***************************/ /**************************************************************************/ @@ -2847,8 +2707,8 @@ done: * Function: H5PB__allocate_page * * Purpose: Allocate an instance of H5PB_entry_t and its associated - * buffer. The supplied size must be greater than or - * equal to pb_ptr->page_size, and equal to that value if + * buffer. The supplied size must be greater than or + * equal to pb_ptr->page_size, and equal to that value if * pb_ptr->vfd_swmr_writer is FALSE. * * The associated buffer is zeroed if clean_image is TRUE. @@ -2866,8 +2726,8 @@ static H5PB_entry_t * H5PB__allocate_page(H5PB_t *pb_ptr, size_t size, hbool_t clean_image) { H5PB_entry_t *entry_ptr = NULL; - void * image_ptr = NULL; - H5PB_entry_t *ret_value = NULL; /* Return value */ + void * image_ptr = NULL; + H5PB_entry_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2878,46 +2738,44 @@ H5PB__allocate_page(H5PB_t *pb_ptr, size_t size, hbool_t clean_image) HDassert((size == pb_ptr->page_size) || (pb_ptr->vfd_swmr_writer)); /* allocate the entry and its associated image buffer */ - if ( NULL == (entry_ptr = H5FL_MALLOC(H5PB_entry_t))) + if (NULL == (entry_ptr = H5FL_MALLOC(H5PB_entry_t))) - HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, NULL, \ - "memory allocation for H5PB_entry_t failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, NULL, "memory allocation for H5PB_entry_t failed") - if ( clean_image ) { + if (clean_image) { image_ptr = H5MM_calloc(size); - - } else { + } + else { image_ptr = H5MM_malloc(size); } - if ( NULL == image_ptr ) + if (NULL == image_ptr) - HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, NULL, \ - "memory allocation for page image failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, NULL, "memory allocation for page image failed") /* initialize the new page buffer entry */ - entry_ptr->magic = H5PB__H5PB_ENTRY_T_MAGIC; - entry_ptr->pb_ptr = pb_ptr; - entry_ptr->addr = HADDR_UNDEF; - entry_ptr->page = 0; - entry_ptr->size = size; - entry_ptr->image_ptr = image_ptr; - entry_ptr->mem_type = H5FD_MEM_DEFAULT; - entry_ptr->is_metadata = FALSE; - entry_ptr->is_mpmde = FALSE; - entry_ptr->is_dirty = FALSE; + entry_ptr->magic = H5PB__H5PB_ENTRY_T_MAGIC; + entry_ptr->pb_ptr = pb_ptr; + entry_ptr->addr = HADDR_UNDEF; + entry_ptr->page = 0; + entry_ptr->size = size; + entry_ptr->image_ptr = image_ptr; + entry_ptr->mem_type = H5FD_MEM_DEFAULT; + entry_ptr->is_metadata = FALSE; + entry_ptr->is_mpmde = FALSE; + entry_ptr->is_dirty = FALSE; /* fields supporting the hash table */ - entry_ptr->ht_prev = NULL; - entry_ptr->ht_next = NULL; - entry_ptr->il_prev = NULL; - entry_ptr->il_next = NULL; + entry_ptr->ht_prev = NULL; + entry_ptr->ht_next = NULL; + entry_ptr->il_prev = NULL; + entry_ptr->il_next = NULL; /* fields supporting replacement policise */ - entry_ptr->next = NULL; - entry_ptr->prev = NULL; + entry_ptr->next = NULL; + entry_ptr->prev = NULL; /* fields supporting VFD SWMR */ entry_ptr->is_mpmde = FALSE; @@ -2931,15 +2789,15 @@ H5PB__allocate_page(H5PB_t *pb_ptr, size_t size, hbool_t clean_image) done: - if ( NULL == ret_value ) { + if (NULL == ret_value) { - if ( entry_ptr ) { + if (entry_ptr) { entry_ptr->magic = 0; - entry_ptr = H5FL_FREE(H5PB_entry_t, entry_ptr); + entry_ptr = H5FL_FREE(H5PB_entry_t, entry_ptr); } - if ( image_ptr ) { + if (image_ptr) { image_ptr = H5MM_xfree(image_ptr); } @@ -2949,12 +2807,11 @@ done: } /* H5PB__allocate_page() */ - /*------------------------------------------------------------------------- * * Function: H5PB__create_new_page * - * Purpose: Create a new page and insert it in the page buffer with + * Purpose: Create a new page and insert it in the page buffer with * the specified address and type. If entry_ptr_ptr is not * NULL, return a pointer to the new entry in *entry_ptr_ptr. * @@ -2969,15 +2826,15 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5PB__create_new_page(H5PB_t *pb_ptr, haddr_t addr, size_t size, - H5FD_mem_t type, hbool_t clean_image, H5PB_entry_t **entry_ptr_ptr) +herr_t +H5PB__create_new_page(H5PB_t *pb_ptr, haddr_t addr, size_t size, H5FD_mem_t type, hbool_t clean_image, + H5PB_entry_t **entry_ptr_ptr) { - hbool_t inserted_in_index = FALSE; - hbool_t inserted_in_lru = FALSE; - uint64_t page; + hbool_t inserted_in_index = FALSE; + hbool_t inserted_in_lru = FALSE; + uint64_t page; H5PB_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2989,43 +2846,40 @@ H5PB__create_new_page(H5PB_t *pb_ptr, haddr_t addr, size_t size, HDassert((uint64_t)(addr) == (page * (uint64_t)(pb_ptr->page_size))); HDassert(size >= pb_ptr->page_size); - HDassert((size == pb_ptr->page_size) || - ((pb_ptr->vfd_swmr_writer) && (type != H5FD_MEM_DRAW))); + HDassert((size == pb_ptr->page_size) || ((pb_ptr->vfd_swmr_writer) && (type != H5FD_MEM_DRAW))); HDassert((NULL == entry_ptr_ptr) || (NULL == *entry_ptr_ptr)); H5PB__SEARCH_INDEX(pb_ptr, page, entry_ptr, FAIL); - if ( entry_ptr != NULL ) { + if (entry_ptr != NULL) { - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "page buffer already contains a page at the specified address") - } + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, + "page buffer already contains a page at the specified address") + } entry_ptr = H5PB__allocate_page(pb_ptr, size, clean_image); - if ( NULL == entry_ptr ) - HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, \ - "Can't allocate new page buffer entry") + if (NULL == entry_ptr) + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "Can't allocate new page buffer entry") /* perform additional initialization */ HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); HDassert(entry_ptr->pb_ptr == pb_ptr); - entry_ptr->addr = addr; - entry_ptr->page = page; + entry_ptr->addr = addr; + entry_ptr->page = page; HDassert(entry_ptr->size == size); HDassert(entry_ptr->image_ptr); entry_ptr->mem_type = type; entry_ptr->is_metadata = (type != H5FD_MEM_DRAW); - entry_ptr->is_mpmde = ((entry_ptr->is_metadata) && - (size > pb_ptr->page_size)); + entry_ptr->is_mpmde = ((entry_ptr->is_metadata) && (size > pb_ptr->page_size)); entry_ptr->is_dirty = FALSE; /* insert in the hash table */ H5PB__INSERT_IN_INDEX(pb_ptr, entry_ptr, FAIL) - inserted_in_index = TRUE; + inserted_in_index = TRUE; /* insert at the head of the LRU if it isn't a multi-page metadata entry */ - if ( ! entry_ptr->is_mpmde ) { + if (!entry_ptr->is_mpmde) { H5PB__UPDATE_RP_FOR_INSERTION(pb_ptr, entry_ptr, FAIL) inserted_in_lru = TRUE; @@ -3034,23 +2888,23 @@ H5PB__create_new_page(H5PB_t *pb_ptr, haddr_t addr, size_t size, /* updates stats */ H5PB__UPDATE_STATS_FOR_INSERTION(pb_ptr, entry_ptr); - if ( entry_ptr_ptr ) { + if (entry_ptr_ptr) { *entry_ptr_ptr = entry_ptr; } done: - if ( ret_value < 0 ) { + if (ret_value < 0) { - if ( entry_ptr ) { + if (entry_ptr) { - if ( inserted_in_lru ) { + if (inserted_in_lru) { H5PB__UPDATE_RP_FOR_EVICTION(pb_ptr, entry_ptr, FAIL); } - if ( inserted_in_index ) { + if (inserted_in_index) { H5PB__DELETE_FROM_INDEX(pb_ptr, entry_ptr, FAIL) } @@ -3064,13 +2918,12 @@ done: } /* H5PB_add_new_page */ - /*------------------------------------------------------------------------- * * Function: H5PB__deallocate_page * - * Purpose: Free the supplied instance of H5PB_entry_t and its - * associated buffer. The entry must be clean and removed + * Purpose: Free the supplied instance of H5PB_entry_t and its + * associated buffer. The entry must be clean and removed * from the page buffer before this function is called. * * Return: void @@ -3081,7 +2934,7 @@ done: * *------------------------------------------------------------------------- */ -static void +static void H5PB__deallocate_page(H5PB_entry_t *entry_ptr) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3101,27 +2954,26 @@ H5PB__deallocate_page(H5PB_entry_t *entry_ptr) HDassert(entry_ptr->tl_next == NULL); HDassert(entry_ptr->tl_prev == NULL); - entry_ptr->magic = 0; + entry_ptr->magic = 0; entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); - entry_ptr = H5FL_FREE(H5PB_entry_t, entry_ptr); + entry_ptr = H5FL_FREE(H5PB_entry_t, entry_ptr); FUNC_LEAVE_NOAPI_VOID } /* H5PB__deallocate_page() */ - /*------------------------------------------------------------------------- * * Function: H5PB__evict_entry * - * Purpose: Evict the target entry from the from the page buffer, and - * de-allocate its associated image and instance of + * Purpose: Evict the target entry from the from the page buffer, and + * de-allocate its associated image and instance of * H5PB_entry_t. * - * In general, entries must be clean before they can be - * evicted, and the minimum metadata and raw data limits - * must be respected. Attempts to evict an entry that - * that do not respect these constraints will generate + * In general, entries must be clean before they can be + * evicted, and the minimum metadata and raw data limits + * must be respected. Attempts to evict an entry that + * that do not respect these constraints will generate * and error unless the force parameter is TRUE, in which * case, these constraints are ignored. * @@ -3147,11 +2999,10 @@ H5PB__deallocate_page(H5PB_entry_t *entry_ptr) *------------------------------------------------------------------------- */ static herr_t -H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, hbool_t force, - hbool_t only_mark) +H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, hbool_t force, hbool_t only_mark) { - H5PB_t *pb_ptr = shared->pb_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5PB_t *pb_ptr = shared->pb_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3162,50 +3013,45 @@ H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, hbool_t force, HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); HDassert(entry_ptr->size > 0); HDassert(entry_ptr->image_ptr); - /* entries on either the tick list or the delayed write + /* entries on either the tick list or the delayed write * list may not be evicted -- verify this. */ HDassert(!(entry_ptr->modified_this_tick)); HDassert(entry_ptr->delay_write_until == 0); - if ( ( ! force ) && ( entry_ptr->is_dirty ) ) + if ((!force) && (entry_ptr->is_dirty)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "Attempt to evict a dirty entry"); + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "Attempt to evict a dirty entry"); - if ( ! force ) { + if (!force) { /* it is OK to evict an metadata page if pb_ptr->curr_md_pages == * pb_ptr->min_md_pages - 1 if we are about to replace it with another - * metadata page. + * metadata page. + * + * Similarly, it is OK to evict an raw data page if + * pb_ptr->curr_rd_pages == pb_ptr->min_rd_pages - 1 if we are + * about to replace it with another raw data page. * - * Similarly, it is OK to evict an raw data page if - * pb_ptr->curr_rd_pages == pb_ptr->min_rd_pages - 1 if we are - * about to replace it with another raw data page. - * - * Assume sanity checks have been made before this call, and + * Assume sanity checks have been made before this call, and * allow the above without testing the intended replacement. */ - if ( ( entry_ptr->is_metadata ) && - ( pb_ptr->curr_md_pages < pb_ptr->min_md_pages ) ) { - - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "Attempt to violate min_md_pages"); + if ((entry_ptr->is_metadata) && (pb_ptr->curr_md_pages < pb_ptr->min_md_pages)) { - } else if ( ( ! entry_ptr->is_metadata ) && - ( pb_ptr->curr_rd_pages < pb_ptr->min_rd_pages ) ) { + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "Attempt to violate min_md_pages"); + } + else if ((!entry_ptr->is_metadata) && (pb_ptr->curr_rd_pages < pb_ptr->min_rd_pages)) { - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "Attempt to violate min_rd_pages"); - } - } else if ( ( entry_ptr->is_dirty ) && - ( H5PB__mark_entry_clean(pb_ptr, entry_ptr) < 0 ) ) { + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "Attempt to violate min_rd_pages"); + } + } + else if ((entry_ptr->is_dirty) && (H5PB__mark_entry_clean(pb_ptr, entry_ptr) < 0)) { HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "mark entry clean failed") } /* if the entry is in the replacement policy, remove it */ - if ( ! (entry_ptr->is_mpmde) ) { + if (!(entry_ptr->is_mpmde)) { H5PB__UPDATE_RP_FOR_EVICTION(pb_ptr, entry_ptr, FAIL) } @@ -3213,7 +3059,7 @@ H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, hbool_t force, /* remove the entry from the hash table */ H5PB__DELETE_FROM_INDEX(pb_ptr, entry_ptr, FAIL) - /* We need to remove the entry from the shadow file index in + /* We need to remove the entry from the shadow file index in * the VFD SWMR case. * * If a multipage metadata entry is deallocated, and a new, single-page @@ -3232,10 +3078,8 @@ H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, hbool_t force, * the image will be bigger. So the shadow file will never see the * entire image written, just the first page of the image. */ - if (shared->vfd_swmr_writer && - shadow_idx_entry_remove(shared, entry_ptr->page, only_mark) == -1) { - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, - "failed to remove shadow index entry") + if (shared->vfd_swmr_writer && shadow_idx_entry_remove(shared, entry_ptr->page, only_mark) == -1) { + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "failed to remove shadow index entry") } /* update stats for eviction */ @@ -3250,22 +3094,21 @@ done: } /* H5PB__evict_entry() */ - /*------------------------------------------------------------------------- * * Function: H5PB__flush_entry * * Purpose: Flush the target entry to file. * - * Under normal circumstances, the entry will be in the + * Under normal circumstances, the entry will be in the * replacement policy. In this, also update the replacement * policy for flush. * * If pb_ptr->vfd_swmr_writer, it is possible that the target * is a multi-page metadata entry. In this case, the entry - * is not in the replacement policy, and thus the policy + * is not in the replacement policy, and thus the policy * should not be updated. - * + * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer -- 10/14/18 @@ -3277,8 +3120,8 @@ done: static herr_t H5PB__flush_entry(H5F_shared_t *shared, H5PB_t *pb_ptr, H5PB_entry_t *const entry_ptr) { - haddr_t eoa; /* Current EOA for the file */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t eoa; /* Current EOA for the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3298,46 +3141,44 @@ H5PB__flush_entry(H5F_shared_t *shared, H5PB_t *pb_ptr, H5PB_entry_t *const entr HDassert(0 == entry_ptr->delay_write_until); /* Retrieve the 'eoa' for the file */ - if ( HADDR_UNDEF == (eoa = H5FD_get_eoa(shared->lf, entry_ptr->mem_type)) ) + if (HADDR_UNDEF == (eoa = H5FD_get_eoa(shared->lf, entry_ptr->mem_type))) - HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, \ - "driver get_eoa request failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eoa request failed") - /* TODO: update the free space manager to inform the page buffer when + /* TODO: update the free space manager to inform the page buffer when * space is de-allocated so that the following assertions will be * true in all cases. */ - /* Verify that the base addresss of the page is within the EOA. If it - * isn't, the associated page has been discarded and should have been - * removed from the page buffer. This is a bug in the HDF5 library, so + /* Verify that the base addresss of the page is within the EOA. If it + * isn't, the associated page has been discarded and should have been + * removed from the page buffer. This is a bug in the HDF5 library, so * an assertion is adequate here. */ - HDassert( eoa > entry_ptr->addr ); + HDassert(eoa > entry_ptr->addr); - /* Space at the end of the file should be allocate in increments of + /* Space at the end of the file should be allocate in increments of * pages. Thus the entire page should be within the EOA. Again, * an assertion is adequate here. */ - HDassert( eoa >= entry_ptr->addr + entry_ptr->size ); + HDassert(eoa >= entry_ptr->addr + entry_ptr->size); /* flush the entry */ - if ( H5FD_write(shared->lf, entry_ptr->mem_type, entry_ptr->addr, - entry_ptr->size, entry_ptr->image_ptr) < 0 ) + if (H5FD_write(shared->lf, entry_ptr->mem_type, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) < + 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "file write failed") /* mark the entry clean */ - if ( H5PB__mark_entry_clean(pb_ptr, entry_ptr) < 0 ) + if (H5PB__mark_entry_clean(pb_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "mark entry clean failed") - /* if the entry is on the LRU, update the replacement policy */ if (!entry_ptr->is_mpmde) { HDassert(entry_ptr->delay_write_until == 0); - H5PB__UPDATE_RP_FOR_FLUSH(pb_ptr, entry_ptr, FAIL) + H5PB__UPDATE_RP_FOR_FLUSH(pb_ptr, entry_ptr, FAIL) } /* update stats for flush */ @@ -3349,29 +3190,28 @@ done: } /* H5PB__flush_entry() */ - /*------------------------------------------------------------------------- * * Function: H5PB__load_page * * Purpose: Load the page with the specified base address and insert - * it into the page buffer. If necessary and possible, make + * it into the page buffer. If necessary and possible, make * space for the new page first. * * Note that the size of the page is always pb_ptr->page_size, - * even in the VFD SWMR case, as in this context, multi-page - * metadata entries are always written in full, and they + * even in the VFD SWMR case, as in this context, multi-page + * metadata entries are always written in full, and they * may only enter the page buffer as the result of a write. * * In the context of VFD SWMR, when a page is loaded from - * file, it is possible that the VFD SWMR writer must delay - * writes to the page to avoid the possibility of message from + * file, it is possible that the VFD SWMR writer must delay + * writes to the page to avoid the possibility of message from * the future bugs on the VFD SWMR reader. For this reason, * make note of the fact that the entry has been loaded from * from file, so that the necessary checks can be made when * writing to the page. - * - * Return: SUCCEED if no errors are encountered, and + * + * Return: SUCCEED if no errors are encountered, and * FAIL otherwise. * * Programmer: John Mainzer -- 10/18/18 @@ -3381,14 +3221,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5PB__load_page(H5F_shared_t *shared, H5PB_t *pb_ptr, haddr_t addr, - H5FD_mem_t type, H5PB_entry_t **entry_ptr_ptr) +H5PB__load_page(H5F_shared_t *shared, H5PB_t *pb_ptr, haddr_t addr, H5FD_mem_t type, + H5PB_entry_t **entry_ptr_ptr) { - hbool_t skip_read = FALSE; - haddr_t eof = HADDR_UNDEF; + hbool_t skip_read = FALSE; + haddr_t eof = HADDR_UNDEF; H5PB_entry_t *entry_ptr = NULL; - void *image_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + void * image_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3399,7 +3239,7 @@ H5PB__load_page(H5F_shared_t *shared, H5PB_t *pb_ptr, haddr_t addr, HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); HDassert((entry_ptr_ptr == NULL) || (*entry_ptr_ptr == NULL)); -#if 0 /* JRM */ +#if 0 /* JRM */ haddr_t eoa; /* Retrieve the 'eoa' for the file */ if ( HADDR_UNDEF == (eoa = H5FD_get_eoa(shared->lf, type))) @@ -3411,10 +3251,9 @@ H5PB__load_page(H5F_shared_t *shared, H5PB_t *pb_ptr, haddr_t addr, HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ "Attempt to load page that extends past EOA") #endif /* JRM */ - if ( HADDR_UNDEF == (eof = H5FD_get_eof(shared->lf, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (eof = H5FD_get_eof(shared->lf, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, \ - "driver get_eof request failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eof request failed") #if 0 /* It is possible that this page been allocated but not @@ -3427,19 +3266,14 @@ H5PB__load_page(H5F_shared_t *shared, H5PB_t *pb_ptr, haddr_t addr, #endif /* make space in the page buffer if necessary */ - if ( ( pb_ptr->curr_pages >= pb_ptr->max_pages ) && - ( H5PB__make_space(shared, pb_ptr, type) < 0 ) ) - - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "H5PB__make_space() reports an error") + if ((pb_ptr->curr_pages >= pb_ptr->max_pages) && (H5PB__make_space(shared, pb_ptr, type) < 0)) + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "H5PB__make_space() reports an error") /* Create a new page buffer page and insert it into the page buffer */ - if ( H5PB__create_new_page(pb_ptr, addr, (size_t)(pb_ptr->page_size), - type, skip_read, &entry_ptr) < 0 ) + if (H5PB__create_new_page(pb_ptr, addr, (size_t)(pb_ptr->page_size), type, skip_read, &entry_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "can't create new page buffer page") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "can't create new page buffer page") HDassert(entry_ptr); HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); @@ -3449,23 +3283,21 @@ H5PB__load_page(H5F_shared_t *shared, H5PB_t *pb_ptr, haddr_t addr, HDassert(image_ptr); - /* Read the contents of the page from file, and store it in the + /* Read the contents of the page from file, and store it in the * image buffer associated with the new entry. */ - if ( ( ! skip_read ) && - ( H5FD_read(shared->lf, type, addr, entry_ptr->size, image_ptr) < 0 ) ) + if ((!skip_read) && (H5FD_read(shared->lf, type, addr, entry_ptr->size, image_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "driver read request failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed") /* If in fact the page was read from file, make note of this fact * for purposes of VFD SWMR delayed writes in the VFD SWMR writer. */ - entry_ptr->loaded = ! skip_read; + entry_ptr->loaded = !skip_read; H5PB__UPDATE_STATS_FOR_LOAD(pb_ptr, entry_ptr) - if ( entry_ptr_ptr ) { + if (entry_ptr_ptr) { *entry_ptr_ptr = entry_ptr; } @@ -3478,49 +3310,48 @@ done: } /* H5PB__load_page() */ - /*------------------------------------------------------------------------- * * Function: H5PB__make_space * - * Purpose: Evict one or more pages from the page buffer so as to + * Purpose: Evict one or more pages from the page buffer so as to * reduce the size of the page buffer to pb_ptr->max_pages - 1. * if possible. * - * Note that the function must not be called under - * nonsensical conditions -- thus if either + * Note that the function must not be called under + * nonsensical conditions -- thus if either * * 1) the inserted type is metadata and min_rd_pages == - * max_pages, or + * max_pages, or * * 2) the inserted type is raw data and min_md_pages == * max_pages - * - * holds, the function has been called in error, and an + * + * holds, the function has been called in error, and an * assertion failure is appropriate. * - * If the page buffer is below its maximum size, we are + * If the page buffer is below its maximum size, we are * done, and the function simply returns. * - * Otherwise, scan upwards from the bottom of the LRU list, + * Otherwise, scan upwards from the bottom of the LRU list, * examining each entry in turn. * - * If the entry is dirty, flush it, move it to the top of the + * If the entry is dirty, flush it, move it to the top of the * LRU, and continue with the scan. Note in the VFD SWMR case, - * we do not have to concern ourselves with delayed writes in - * this context, as all entries which are subject to delayed + * we do not have to concern ourselves with delayed writes in + * this context, as all entries which are subject to delayed * writes must reside on the delayed write list, not the LRU list. * * If the entry is: * * 1) clean * - * 2) either: + * 2) either: * - * a) the target entry is metadata and + * a) the target entry is metadata and * curr_md_pages > min_md_pages. * - * b) the target entry is raw data and + * b) the target entry is raw data and * curr_rd_pages > min_rd_pages. * * c) the target entry is metadata, the inserted_type @@ -3529,7 +3360,7 @@ done: * d) the target entry is raw data, the inserted_type * is raw data, and curr_rd_pages == min_rd_pages. * - * 3) The entry is not on the tick list (which can only + * 3) The entry is not on the tick list (which can only * happen if pb_ptr->vfd_swmr_writer is TRUE). * * evict the entry and test to see if pb_ptr->curr_pages < @@ -3539,18 +3370,18 @@ done: * * Under normal circumstances, it should always be possible * to reduce the size of the page buffer below pb_ptr->max_pages. - * However, due to prohibition on evicting entries on the + * However, due to prohibition on evicting entries on the * tick list, and either flushing or evicting entries on the * delayed write list, this will not in general be the case - * if pb_ptr->vfd_swmr_writer is TRUE. In this case, the - * page buffer may exceed its maximum size by an arbitrary + * if pb_ptr->vfd_swmr_writer is TRUE. In this case, the + * page buffer may exceed its maximum size by an arbitrary * amount. * - * If this situation occurs with any regularity, we will - * need a mechanism to avoid attempts to make space when + * If this situation occurs with any regularity, we will + * need a mechanism to avoid attempts to make space when * it is not possible to do so. * - * Return: SUCCEED if no errors are encountered, and + * Return: SUCCEED if no errors are encountered, and * FAIL otherwise. * * Programmer: John Mainzer -- 10/14/18 @@ -3562,11 +3393,11 @@ done: static herr_t H5PB__make_space(H5F_shared_t *shared, H5PB_t *pb_ptr, H5FD_mem_t inserted_type) { - hbool_t inserting_md; + hbool_t inserting_md; H5PB_entry_t *search_ptr; H5PB_entry_t *flush_ptr; H5PB_entry_t *evict_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3575,83 +3406,78 @@ H5PB__make_space(H5F_shared_t *shared, H5PB_t *pb_ptr, H5FD_mem_t inserted_type) HDassert(pb_ptr->magic == H5PB__H5PB_T_MAGIC); HDassert(pb_ptr->min_md_pages + pb_ptr->min_rd_pages <= pb_ptr->max_pages); - inserting_md = ( H5FD_MEM_DRAW != inserted_type ); + inserting_md = (H5FD_MEM_DRAW != inserted_type); - if ( ( inserting_md ) && ( pb_ptr->min_rd_pages == pb_ptr->max_pages ) ) + if ((inserting_md) && (pb_ptr->min_rd_pages == pb_ptr->max_pages)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, - "can't make space for metadata -- pb config for raw data only") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, + "can't make space for metadata -- pb config for raw data only") - if ( ( ! inserting_md ) && ( pb_ptr->min_md_pages == pb_ptr->max_pages ) ) + if ((!inserting_md) && (pb_ptr->min_md_pages == pb_ptr->max_pages)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, - "can't make space for raw data -- pb config for metadata only") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, + "can't make space for raw data -- pb config for metadata only") search_ptr = pb_ptr->LRU_tail_ptr; - while ( ( search_ptr ) && ( pb_ptr->curr_pages >= pb_ptr->max_pages ) ) { + while ((search_ptr) && (pb_ptr->curr_pages >= pb_ptr->max_pages)) { HDassert(search_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); - if ( search_ptr->modified_this_tick ) { /* entry is on tick list */ + if (search_ptr->modified_this_tick) { /* entry is on tick list */ search_ptr = search_ptr->prev; H5PB__UPDATE_STATS_FOR_LRU_TL_SKIP(pb_ptr); - - } else if ( ( inserting_md ) && - ( ! (search_ptr->is_metadata) ) && - ( pb_ptr->curr_rd_pages <= pb_ptr->min_rd_pages ) ) { + } + else if ((inserting_md) && (!(search_ptr->is_metadata)) && + (pb_ptr->curr_rd_pages <= pb_ptr->min_rd_pages)) { search_ptr = search_ptr->prev; H5PB__UPDATE_STATS_FOR_LRU_RD_SKIP(pb_ptr); - - } else if ( ( ! inserting_md ) && - ( search_ptr->is_metadata ) && - ( pb_ptr->curr_md_pages <= pb_ptr->min_md_pages ) ) { + } + else if ((!inserting_md) && (search_ptr->is_metadata) && + (pb_ptr->curr_md_pages <= pb_ptr->min_md_pages)) { search_ptr = search_ptr->prev; H5PB__UPDATE_STATS_FOR_LRU_MD_SKIP(pb_ptr); + } + else if (search_ptr->is_dirty) { - } else if ( search_ptr->is_dirty ) { - - /* One can make the argument that we should test for dirty - * entries first, instead of skipping potentially dirty - * entries in the above clauses. However, I suspect that - * this would result in excessive flushes. Lets try it + /* One can make the argument that we should test for dirty + * entries first, instead of skipping potentially dirty + * entries in the above clauses. However, I suspect that + * this would result in excessive flushes. Lets try it * this way for now. */ flush_ptr = search_ptr; - /* if the *search_ptr has a predecessor in the LRU, + /* if the *search_ptr has a predecessor in the LRU, * set set search_ptr equal to search_ptr->prev. Otherwise, - * leave search_ptr unchanged, so that it can be examined + * leave search_ptr unchanged, so that it can be examined * on the next pass through the while loop after it has been * flushed. */ - if ( search_ptr->prev ) { + if (search_ptr->prev) { search_ptr = search_ptr->prev; } - if ( H5PB__flush_entry(shared, pb_ptr, flush_ptr) < 0 ) + if (H5PB__flush_entry(shared, pb_ptr, flush_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "Can't flush entry") - - } else { /* evict the entry */ + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "Can't flush entry") + } + else { /* evict the entry */ - evict_ptr = search_ptr; + evict_ptr = search_ptr; search_ptr = search_ptr->prev; - if ( H5PB__evict_entry(shared, evict_ptr, FALSE, FALSE) < 0 ) + if (H5PB__evict_entry(shared, evict_ptr, FALSE, FALSE) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "Can't evict entry") + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "Can't evict entry") } } - HDassert( ( search_ptr == NULL ) || - ( pb_ptr->curr_pages < pb_ptr->max_pages ) ); + HDassert((search_ptr == NULL) || (pb_ptr->curr_pages < pb_ptr->max_pages)); done: @@ -3659,7 +3485,6 @@ done: } /* H5PB__make_space() */ - /*------------------------------------------------------------------------- * * Function: H5PB__mark_entry_clean @@ -3668,12 +3493,12 @@ done: * * This function is typically used when an entry has been * completely overwritten and is about to be evicted. In - * this case, the entry must be marked clean to avoid + * this case, the entry must be marked clean to avoid * sanity check failures on evictions. * - * While this function does update the index for the + * While this function does update the index for the * entry clean, it does not update the replacement policy. - * If this is desired, it must be done by the caller. + * If this is desired, it must be done by the caller. * * Return: Non-negative on success/Negative on failure * @@ -3686,7 +3511,7 @@ done: static herr_t H5PB__mark_entry_clean(H5PB_t *pb_ptr, H5PB_entry_t *entry_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3707,7 +3532,7 @@ H5PB__mark_entry_clean(H5PB_t *pb_ptr, H5PB_entry_t *entry_ptr) /* update the index for the entry clean */ H5PB__UPDATE_INDEX_FOR_ENTRY_CLEAN(pb_ptr, entry_ptr) - /* don't update the replacement policy -- this will be done by + /* don't update the replacement policy -- this will be done by * the caller if desired. */ @@ -3717,25 +3542,24 @@ done: } /* H5PB__mark_entry_clean() */ - /*------------------------------------------------------------------------- * * Function: H5PB__mark_entry_dirty * * Purpose: Mark the target entry as dirty. * - * If pb_ptr->vfd_swmr_writer is FALSE, the entry will be - * in the replacement policy. In this, we simply mark the - * entry as dirty, and update the replacement policy for an + * If pb_ptr->vfd_swmr_writer is FALSE, the entry will be + * in the replacement policy. In this, we simply mark the + * entry as dirty, and update the replacement policy for an * access. * - * If pb_ptr->vfd_swmr_writer, it is possible that we must - * delay writes to the target page or multi-page metadata - * entry to avoid message from the future bugs on the VFD - * SWMR readers. In such cases we must set the - * delay_write_until field and insert the entry on the + * If pb_ptr->vfd_swmr_writer, it is possible that we must + * delay writes to the target page or multi-page metadata + * entry to avoid message from the future bugs on the VFD + * SWMR readers. In such cases we must set the + * delay_write_until field and insert the entry on the * delayed write list instead of the replacement policy. - * + * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer -- 10/14/18 @@ -3747,7 +3571,7 @@ done: static herr_t H5PB__mark_entry_dirty(H5F_shared_t *shared, H5PB_t *pb_ptr, H5PB_entry_t *entry_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3763,7 +3587,7 @@ H5PB__mark_entry_dirty(H5F_shared_t *shared, H5PB_t *pb_ptr, H5PB_entry_t *entry HDassert((pb_ptr->vfd_swmr_writer) || (!(entry_ptr->is_mpmde))); /* mark the entry dirty if necessary */ - if ( ! ( entry_ptr->is_dirty ) ) { + if (!(entry_ptr->is_dirty)) { entry_ptr->is_dirty = TRUE; @@ -3772,18 +3596,14 @@ H5PB__mark_entry_dirty(H5F_shared_t *shared, H5PB_t *pb_ptr, H5PB_entry_t *entry /* since the entry was clean, there can be no pending delayed write */ HDassert(entry_ptr->delay_write_until == 0); - if ( ( pb_ptr->vfd_swmr_writer ) && - ( entry_ptr->loaded ) && - ( entry_ptr->mem_type != H5FD_MEM_DRAW ) && - ( H5F_vfd_swmr_writer__delay_write(shared, entry_ptr->page, - &(entry_ptr->delay_write_until)) < 0 ) ) + if ((pb_ptr->vfd_swmr_writer) && (entry_ptr->loaded) && (entry_ptr->mem_type != H5FD_MEM_DRAW) && + (H5F_vfd_swmr_writer__delay_write(shared, entry_ptr->page, &(entry_ptr->delay_write_until)) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "get delayed write request failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "get delayed write request failed") - if ( entry_ptr->delay_write_until > 0 ) { + if (entry_ptr->delay_write_until > 0) { - if ( ! ( entry_ptr->is_mpmde ) ) { + if (!(entry_ptr->is_mpmde)) { /* remove the entry from the replacement policy */ @@ -3791,26 +3611,26 @@ H5PB__mark_entry_dirty(H5F_shared_t *shared, H5PB_t *pb_ptr, H5PB_entry_t *entry } H5PB__INSERT_IN_DWL(pb_ptr, entry_ptr, FAIL) + } + else if (!(entry_ptr->is_mpmde)) { - } else if ( ! (entry_ptr->is_mpmde) ) { - - H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) - - } else { + H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) + } + else { - /* the entry should be a multi-page metadata entry that + /* the entry should be a multi-page metadata entry that * has been modified this tick. Thus no action is required. */ HDassert(entry_ptr->is_mpmde); HDassert(pb_ptr->vfd_swmr_writer); } - } else if ( ( ! (entry_ptr->is_mpmde) ) && - ( entry_ptr->delay_write_until == 0 ) ) { + } + else if ((!(entry_ptr->is_mpmde)) && (entry_ptr->delay_write_until == 0)) { /* the entry is dirty and on the replacement policy -- just update - * the replacement policy for an access + * the replacement policy for an access */ - H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) + H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) } done: @@ -3819,44 +3639,43 @@ done: } /* H5PB__mark_entry_dirty() */ - /*------------------------------------------------------------------------- * * Function: H5PB__read_meta * - * Purpose: Satisfy a metadata read in cases 7, 8, 9, and 10) + * Purpose: Satisfy a metadata read in cases 7, 8, 9, and 10) * H5PB_read(). Specifically: * * 6) If the read is for metadata and not page aligned, clip * the read to the end of the current page if necessary. - * Load the relevant page if necessary and satisfy the + * Load the relevant page if necessary and satisfy the * read from the page buffer. Note that it there is an - * existing page, it must not be a multi-page metadata + * existing page, it must not be a multi-page metadata * entry. It it is, flag an error. * * Recall that by the time we get to this function, - * un-aligned page reads from the fixed and variable + * un-aligned page reads from the fixed and variable * length array structures that cross page boundaries - * have already been split into two or three reads + * have already been split into two or three reads * that conform to the usual pattern of metadata reads. * - * 7) If the read is for metadata, is page aligned, is larger + * 7) If the read is for metadata, is page aligned, is larger * than one page, and there is no entry in the page buffer, * satisfy the read from the file * - * 8) If the read is for metadata, is page aligned, is larger + * 8) If the read is for metadata, is page aligned, is larger * than one page, and there is a regular entry at the target * page address, test to see if the read is speculative. * - * If it is not, evict the page, and satisfy the read from + * If it is not, evict the page, and satisfy the read from * file. Flag an error if the page was dirty. * - * If it is, clip the read to one page, and satisfy the + * If it is, clip the read to one page, and satisfy the * read from the existing regular entry. * * 9) If the read is for metadata, is page aligned, is larger * than one page, and there is a multi-page metadata entry - * at the target page address, test to see if + * at the target page address, test to see if * pb_ptr->vfd_swmr_write is TRUE. * * If it is, satisfy the read from the multi-page metadata @@ -3864,19 +3683,19 @@ done: * * if pb_ptr->vfd_swmr_write is FALSE, flag an error. * - * 10) If the read is for metadata, is page aligned, is no - * larger than a page, test to see if the page buffer + * 10) If the read is for metadata, is page aligned, is no + * larger than a page, test to see if the page buffer * contains a page at the target address. * - * If it doesn't, load the page and satisfy the read + * If it doesn't, load the page and satisfy the read * from it. * - * If it contains a regular page entry, satisfy the read + * If it contains a regular page entry, satisfy the read * from it. * * If it contains a multipage metadata entry at the target * address, satisfy the read from the multi-page metadata - * entry if pb_ptr->vfd_swmr_write is TRUE, and flag an + * entry if pb_ptr->vfd_swmr_write is TRUE, and flag an * error otherwise. * * The above case analysis may be a bit hard to read. If so, @@ -3896,7 +3715,7 @@ done: * | size | entry | VFD | | * P/A: | > PL | exists | SWMR | Spec | Comments: * ------+------+--------+------+---------+------------------------------------- - * N | X | N || R | X | X | Clip read to page boundary if + * N | X | N || R | X | X | Clip read to page boundary if * | | | | | necessary * | | | | | Load entry if necessary * | | | | | Satisfy read from entry (case 6) @@ -3910,7 +3729,7 @@ done: * Y | Y | R | X | Y | Clip read to page boundary * | | | | | Satisfy read from entry (case 8) * ------+------+--------+------+---------+------------------------------------- - * Y | Y | R | X | N | Evict entry + * Y | Y | R | X | N | Evict entry * | | | | | (must be clean -- flag error if not) * | | | | | Satisfy read from file (case 8) * ------+------+--------+------+---------+------------------------------------- @@ -3930,7 +3749,7 @@ done: * ------+------+--------+------+---------+------------------------------------- * Y | N | MPMDE | N | X | Error (case 10) * ------+------+--------+------+---------+------------------------------------- - * + * * Observe that the above cases imply that: * * 1) The page buffer is defined. @@ -3940,16 +3759,16 @@ done: * * 3) This is a metadata read. * - * Note also that if the metadata read is of size - * no larger than page size, it may not cross page + * Note also that if the metadata read is of size + * no larger than page size, it may not cross page * boundaries. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer -- 10/11/18 * - * Changes: Updated to use the speculative read hint from the - * metadata cache, and remove the static variable + * Changes: Updated to use the speculative read hint from the + * metadata cache, and remove the static variable * containing the base address of the last read. * * JRM -- 4/5/20 @@ -3957,19 +3776,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5PB__read_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, - size_t size, void *buf/*out*/) +H5PB__read_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - hbool_t bypass = FALSE; /* flag indicating PB bypassed */ - hbool_t speculative = FALSE; /* speculative read hint from mdc */ - H5PB_t *pb_ptr; /* Page buffer for this file */ - H5PB_entry_t *entry_ptr; /* Pointer to page buffer entry */ - H5FD_t *file; /* File driver pointer */ - uint64_t page; /* page offset of addr */ - haddr_t page_addr; /* page containing addr */ - size_t offset; /* offset of read in page */ - size_t clipped_size; /* possibley clipped size */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t bypass = FALSE; /* flag indicating PB bypassed */ + hbool_t speculative = FALSE; /* speculative read hint from mdc */ + H5PB_t * pb_ptr; /* Page buffer for this file */ + H5PB_entry_t *entry_ptr; /* Pointer to page buffer entry */ + H5FD_t * file; /* File driver pointer */ + uint64_t page; /* page offset of addr */ + haddr_t page_addr; /* page containing addr */ + size_t offset; /* offset of read in page */ + size_t clipped_size; /* possibley clipped size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3989,47 +3807,43 @@ H5PB__read_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, HDassert(buf); /* Calculate the aligned address of the first page */ - page = (addr / pb_ptr->page_size); + page = (addr / pb_ptr->page_size); page_addr = page * pb_ptr->page_size; - if ( page_addr != addr ) { /* case 6 */ - + if (page_addr != addr) { /* case 6 */ + /* If the read is for metadata and not page aligned, clip * the read to the end of the current page if necessary. - * Load the relevant page if necessary and satisfy the + * Load the relevant page if necessary and satisfy the * read from the page buffer. Note that it there is an - * existing page, it must not be a multi-page metadata + * existing page, it must not be a multi-page metadata * entry. It it is, flag an error. */ offset = addr - page_addr; - if ( (offset + size) <= pb_ptr->page_size ) { + if ((offset + size) <= pb_ptr->page_size) { clipped_size = size; + } + else { - } else { - - clipped_size = size - ( (offset + size) - pb_ptr->page_size); + clipped_size = size - ((offset + size) - pb_ptr->page_size); } - HDassert( clipped_size > 0 ); - HDassert( clipped_size <= size ); - HDassert( (offset + clipped_size) <= pb_ptr->page_size ); + HDassert(clipped_size > 0); + HDassert(clipped_size <= size); + HDassert((offset + clipped_size) <= pb_ptr->page_size); /* get the containing page */ H5PB__SEARCH_INDEX(pb_ptr, page, entry_ptr, FAIL) /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, ((entry_ptr) != NULL), \ - TRUE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, ((entry_ptr) != NULL), TRUE, FALSE) - if ( ( NULL == entry_ptr ) && - ( H5PB__load_page(shared, pb_ptr, page_addr, - type, &entry_ptr) < 0 ) ) + if ((NULL == entry_ptr) && (H5PB__load_page(shared, pb_ptr, page_addr, type, &entry_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "page buffer page load request failed (1)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "page buffer page load request failed (1)") HDassert(entry_ptr); HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); @@ -4038,115 +3852,105 @@ H5PB__read_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, HDassert(!(entry_ptr->is_mpmde)); /* copy data from the page into read buffer */ - HDmemcpy((uint8_t *)buf, (uint8_t *)(entry_ptr->image_ptr) + offset, - clipped_size); + HDmemcpy((uint8_t *)buf, (uint8_t *)(entry_ptr->image_ptr) + offset, clipped_size); /* if the entry is on the LRU, update the replacement policy */ - if ( ( ! (entry_ptr->is_mpmde) ) && - ( entry_ptr->delay_write_until == 0 ) ) { + if ((!(entry_ptr->is_mpmde)) && (entry_ptr->delay_write_until == 0)) { - H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) + H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) } - } else { + } + else { - HDassert( page_addr == addr ); + HDassert(page_addr == addr); - if ( size > pb_ptr->page_size ) { + if (size > pb_ptr->page_size) { /* search the page buffer for an entry at page */ H5PB__SEARCH_INDEX(pb_ptr, page, entry_ptr, FAIL) - - if ( entry_ptr == NULL ) { /* case 7 */ + if (entry_ptr == NULL) { /* case 7 */ /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, FALSE, \ - TRUE, size > pb_ptr->page_size) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, FALSE, TRUE, size > pb_ptr->page_size) /* If the read is for metadata, is page aligned, is larger * than page size, and there is no entry in the page buffer, * satisfy the read from the file */ - if ( H5FD_read(file, type, addr, size, buf) < 0) + if (H5FD_read(file, type, addr, size, buf) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "driver read request failed (1)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed (1)") bypass = TRUE; H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size); + } + else { - } else { - - HDassert( entry_ptr ); - HDassert( entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC ); - HDassert( entry_ptr->is_metadata ); + HDassert(entry_ptr); + HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); + HDassert(entry_ptr->is_metadata); - if ( ! ( entry_ptr->is_mpmde ) ) { /* case 8 */ + if (!(entry_ptr->is_mpmde)) { /* case 8 */ - /* If the read is for metadata, is page aligned, is larger + /* If the read is for metadata, is page aligned, is larger * than one page, and there is a regular entry at the target * page address, test to see if the read is speculative. * * If it is not, evict the page, and satisfy the read from * file. Flag an error if the page was dirty. * - * If it is, clip the read to one page, and satisfy + * If it is, clip the read to one page, and satisfy * the read from the existing regular entry. */ - HDassert( entry_ptr->size == pb_ptr->page_size ); + HDassert(entry_ptr->size == pb_ptr->page_size); speculative = H5C_get_curr_read_speculative(shared->cache); - if ( ! speculative ) { + if (!speculative) { - /* since this is likely a second try, don't update + /* since this is likely a second try, don't update * hit rate stats. */ - HDassert( ! ( entry_ptr->is_dirty ) ); + HDassert(!(entry_ptr->is_dirty)); - if ( H5PB__evict_entry(shared, entry_ptr, - TRUE, FALSE) < 0 ) + if (H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "forced eviction failed (1)") - if ( H5FD_read(file, type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "forced eviction failed (1)") + if (H5FD_read(file, type, addr, size, buf) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "driver read request failed (2)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed (2)") bypass = TRUE; H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size); + } + else { - } else { - - HDassert( entry_ptr->image_ptr ); + HDassert(entry_ptr->image_ptr); /* copy data from the page into read buffer */ - HDmemcpy((uint8_t *)buf, - (uint8_t *)(entry_ptr->image_ptr), - entry_ptr->size); + HDmemcpy((uint8_t *)buf, (uint8_t *)(entry_ptr->image_ptr), entry_ptr->size); - /* if the entry is on the LRU, update the replacement - * policy + /* if the entry is on the LRU, update the replacement + * policy */ - if ( ( ! (entry_ptr->is_mpmde) ) && - ( entry_ptr->delay_write_until == 0 ) ) { + if ((!(entry_ptr->is_mpmde)) && (entry_ptr->delay_write_until == 0)) { - H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) + H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) } /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, TRUE, \ - TRUE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, TRUE, TRUE, FALSE) } - } else { /* case 9 */ + } + else { /* case 9 */ /* If the read is for metadata, is page aligned, is larger * than one page, and there is a multi-page metadata entry - * at the target page address, test to see if + * at the target page address, test to see if * pb_ptr->vfd_swmr_write is TRUE. * * If it is, satisfy the read from the multi-page metadata @@ -4154,87 +3958,80 @@ H5PB__read_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, * * if pb_ptr->vfd_swmr_write is FALSE, flag an error. */ - HDassert( entry_ptr->is_mpmde ); - HDassert( pb_ptr->vfd_swmr_writer ); + HDassert(entry_ptr->is_mpmde); + HDassert(pb_ptr->vfd_swmr_writer); - if ( size > entry_ptr->size ) { + if (size > entry_ptr->size) { clipped_size = entry_ptr->size; - - } else { + } + else { clipped_size = size; } - + /* copy data from the page into read buffer */ - HDmemcpy((uint8_t *)buf, (uint8_t *)(entry_ptr->image_ptr), - clipped_size); + HDmemcpy((uint8_t *)buf, (uint8_t *)(entry_ptr->image_ptr), clipped_size); - /* if the entry is on the LRU, update the replacement - * policy + /* if the entry is on the LRU, update the replacement + * policy */ - if ( ( ! (entry_ptr->is_mpmde) ) && - ( entry_ptr->delay_write_until == 0 ) ) { + if ((!(entry_ptr->is_mpmde)) && (entry_ptr->delay_write_until == 0)) { - H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) + H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) } /* update hit rate stats */ H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, TRUE, TRUE, TRUE) } } - } else { /* case 10 */ - - /* If the read is for metadata, is page aligned, is no - * larger than a page, test to see if the page buffer + } + else { /* case 10 */ + + /* If the read is for metadata, is page aligned, is no + * larger than a page, test to see if the page buffer * contains a page at the target address. * - * If it doesn't, load the page and satisfy the read + * If it doesn't, load the page and satisfy the read * from it. * - * If it contains a regular page entry, satisfy the read + * If it contains a regular page entry, satisfy the read * from it. * * If it contains a multipage metadata entry at the target * address, satisfy the read from the multi-page metadata - * entry if pb_ptr->vfd_swmr_write is TRUE, and flag an + * entry if pb_ptr->vfd_swmr_write is TRUE, and flag an * error otherwise. */ - HDassert( size <= pb_ptr->page_size ); + HDassert(size <= pb_ptr->page_size); /* get the containing page */ H5PB__SEARCH_INDEX(pb_ptr, page, entry_ptr, FAIL) /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - TRUE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), TRUE, FALSE) - if ( ( NULL == entry_ptr ) && - ( H5PB__load_page(shared, pb_ptr, page_addr, - type, &entry_ptr) < 0)) + if ((NULL == entry_ptr) && (H5PB__load_page(shared, pb_ptr, page_addr, type, &entry_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "page buffer page load request failed (2)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "page buffer page load request failed (2)") - HDassert( entry_ptr ); - HDassert( entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC ); - HDassert( entry_ptr->is_metadata ); - HDassert( ( ! ( entry_ptr->is_mpmde ) ) || - ( pb_ptr->vfd_swmr_writer) ); + HDassert(entry_ptr); + HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); + HDassert(entry_ptr->is_metadata); + HDassert((!(entry_ptr->is_mpmde)) || (pb_ptr->vfd_swmr_writer)); /* copy data from the page into read buffer */ HDmemcpy((uint8_t *)buf, (uint8_t *)(entry_ptr->image_ptr), size); /* if the entry is on the LRU, update the replacement policy */ - if ( ( ! (entry_ptr->is_mpmde) ) && - ( entry_ptr->delay_write_until == 0 ) ) { + if ((!(entry_ptr->is_mpmde)) && (entry_ptr->delay_write_until == 0)) { - H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) + H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) } } } - if ( ! bypass ) + if (!bypass) H5PB__UPDATE_STATS_FOR_ACCESS(pb_ptr, type, size); done: @@ -4243,7 +4040,6 @@ done: } /* end H5PB__read_meta() */ - /*------------------------------------------------------------------------- * * Function: H5PB__read_raw @@ -4251,20 +4047,20 @@ done: * Purpose: Satisfy a raw data read in cases 3 and 4 from H5PB_read(). * Specifically: * - * 3) If the read is for raw data, and it is larger than the - * page size, read it directly from the HDF5 file. + * 3) If the read is for raw data, and it is larger than the + * page size, read it directly from the HDF5 file. * - * It is possible that the page buffer contains dirty pages + * It is possible that the page buffer contains dirty pages * that intersect with the read -- test for this and update - * the read buffer from the page buffer if any such pages - * exist. + * the read buffer from the page buffer if any such pages + * exist. * - * Note that no pages are inserted into the page buffer in + * Note that no pages are inserted into the page buffer in * this case. * - * 4) If the read is for raw data, and it is of size less - * than or equal to the page size, satisfy the read from - * the page buffer, loading and inserting pages into the + * 4) If the read is for raw data, and it is of size less + * than or equal to the page size, satisfy the read from + * the page buffer, loading and inserting pages into the * page buffer as necessary * * Observe that this implies that: @@ -4285,22 +4081,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, - void *buf/*out*/) +H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - H5PB_t *pb_ptr; /* Page buffer for this file */ + H5PB_t * pb_ptr; /* Page buffer for this file */ H5PB_entry_t *entry_ptr; /* Pointer to page buffer entry */ - uint64_t first_page; /* page offset of first I/O */ - uint64_t last_page; /* page offset of last I/O */ - uint64_t search_page; /* page offset of current page */ - haddr_t first_page_addr; /* address of first page of I/O */ - haddr_t last_page_addr; /* address of last page of I/O */ - haddr_t search_addr; /* Address of current page */ - hsize_t num_touched_pages; /* Number of pages accessed */ - size_t offset; /* offset of read in page */ - size_t length; /* length of read in page */ - hsize_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + uint64_t first_page; /* page offset of first I/O */ + uint64_t last_page; /* page offset of last I/O */ + uint64_t search_page; /* page offset of current page */ + haddr_t first_page_addr; /* address of first page of I/O */ + haddr_t last_page_addr; /* address of last page of I/O */ + haddr_t search_addr; /* Address of current page */ + hsize_t num_touched_pages; /* Number of pages accessed */ + size_t offset; /* offset of read in page */ + size_t length; /* length of read in page */ + hsize_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4314,130 +4109,122 @@ H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, HDassert(pb_ptr->min_md_pages < pb_ptr->max_pages); HDassert(H5FD_MEM_DRAW == type); - /* Calculate the aligned address of the first page */ - first_page = (addr / pb_ptr->page_size); + first_page = (addr / pb_ptr->page_size); first_page_addr = first_page * pb_ptr->page_size; /* Calculate the aligned address of the last page */ - last_page = ((addr + size - 1) / pb_ptr->page_size); + last_page = ((addr + size - 1) / pb_ptr->page_size); last_page_addr = last_page * pb_ptr->page_size; /* Calculate number of pages that this read spans. */ num_touched_pages = last_page - first_page + 1; - if ( first_page_addr == last_page_addr ) { + if (first_page_addr == last_page_addr) { HDassert(1 == num_touched_pages); last_page_addr = HADDR_UNDEF; - } /* case 3) raw data read of page size or greater. */ - if ( size >= pb_ptr->page_size ) { + if (size >= pb_ptr->page_size) { - if ( H5FD_read(shared->lf, type, addr, size, buf) < 0) + if (H5FD_read(shared->lf, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "read failed") - H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size); - - /* For each page that intersects with the above read, check to see + /* For each page that intersects with the above read, check to see * if it exists in the page buffer, and if so, if it is dirty. * - * If it does and is, update the read buffer with the contents - * of the page so we get the up to date data into the buffer + * If it does and is, update the read buffer with the contents + * of the page so we get the up to date data into the buffer * after the big read from the file. */ search_page = first_page; search_addr = first_page_addr; - for(i = 0; i < num_touched_pages; i++) { + for (i = 0; i < num_touched_pages; i++) { H5PB__SEARCH_INDEX(pb_ptr, search_page, entry_ptr, FAIL) /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - FALSE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), FALSE, FALSE) - if ( entry_ptr ) { + if (entry_ptr) { - HDassert( entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC ); - HDassert( ! ( entry_ptr->is_metadata ) ); - HDassert( entry_ptr->page == search_page ); - HDassert( entry_ptr->addr == search_addr ); - HDassert( entry_ptr->size == pb_ptr->page_size ); - HDassert( entry_ptr->delay_write_until == 0 ); + HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); + HDassert(!(entry_ptr->is_metadata)); + HDassert(entry_ptr->page == search_page); + HDassert(entry_ptr->addr == search_addr); + HDassert(entry_ptr->size == pb_ptr->page_size); + HDassert(entry_ptr->delay_write_until == 0); /* This page and [addr, addr + size) should NOT be disjoint. */ HDassert(!(addr + size <= entry_ptr->addr || entry_ptr->addr + entry_ptr->size <= addr)); - if ( entry_ptr->is_dirty ) { + if (entry_ptr->is_dirty) { - if ( i == 0 ) { + if (i == 0) { - /* handle the possible partial access of the + /* handle the possible partial access of the * first page. */ - HDassert( search_addr == first_page_addr ); - HDassert( search_page == first_page ); + HDassert(search_addr == first_page_addr); + HDassert(search_page == first_page); offset = addr - first_page_addr; - HDassert((( offset == 0 ) && (search_addr == addr )) || - (( offset > 0 ) && ( search_addr < addr ))); + HDassert(((offset == 0) && (search_addr == addr)) || + ((offset > 0) && (search_addr < addr))); HDassert(pb_ptr->page_size >= offset); - HDassert( size >= pb_ptr->page_size - (size_t)offset ); + HDassert(size >= pb_ptr->page_size - (size_t)offset); - HDmemcpy(buf, (uint8_t *)entry_ptr->image_ptr + offset, + HDmemcpy(buf, (uint8_t *)entry_ptr->image_ptr + offset, pb_ptr->page_size - (size_t)offset); + } + else if (i == num_touched_pages - 1) { - } else if ( i == num_touched_pages - 1 ) { - - /* handle the possible partial access of the + /* handle the possible partial access of the * last page. */ - HDassert( i > 0 ); - HDassert( search_addr == last_page_addr ); - HDassert( search_page == last_page ); - HDassert( addr < last_page_addr ); - HDassert( last_page_addr < addr + size ); + HDassert(i > 0); + HDassert(search_addr == last_page_addr); + HDassert(search_page == last_page); + HDassert(addr < last_page_addr); + HDassert(last_page_addr < addr + size); - offset = (num_touched_pages - 2) * pb_ptr->page_size + + offset = (num_touched_pages - 2) * pb_ptr->page_size + (pb_ptr->page_size - (addr - first_page_addr)); HDmemcpy((uint8_t *)buf + offset, entry_ptr->image_ptr, (size_t)((addr + size) - last_page_addr)); + } + else { - } else { - - /* this is an internal page -- copy it in its + /* this is an internal page -- copy it in its * entireity. */ - - offset = (i - 1) * pb_ptr->page_size + - (pb_ptr->page_size - (addr - first_page_addr)); - HDassert ( addr + offset == search_addr ); - HDassert ( offset + pb_ptr->page_size <= size ); + offset = (i - 1) * pb_ptr->page_size + (pb_ptr->page_size - (addr - first_page_addr)); - HDmemcpy((uint8_t *)buf + offset, - entry_ptr->image_ptr, - pb_ptr->page_size); + HDassert(addr + offset == search_addr); + HDassert(offset + pb_ptr->page_size <= size); + + HDmemcpy((uint8_t *)buf + offset, entry_ptr->image_ptr, pb_ptr->page_size); } /* we have touched the entry -- move it to the top * of the LRU if it resides there. * - * The entry will be on the LRU if both it is not - * a multi-page metadata entry and it is not + * The entry will be on the LRU if both it is not + * a multi-page metadata entry and it is not * subject to a delayed write. * - * As this is a raw data page buffer entry, both of + * As this is a raw data page buffer entry, both of * these must be true, and are asserted above. * * Thus, just update the LRU. @@ -4445,14 +4232,15 @@ H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) } /* if ( entry_ptr->is_dirty ) */ - } /* if ( entry_ptr ) */ + } /* if ( entry_ptr ) */ search_page++; search_addr += pb_ptr->page_size; } /* end for */ - } else { - /* case 4: Raw data read of size less than page size. + } + else { + /* case 4: Raw data read of size less than page size. * * In this case, read the desired data from the page buffer, loading * pages if necessary. @@ -4462,12 +4250,12 @@ H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, /* first page */ offset = addr - first_page_addr; - if ( (offset + size) <= pb_ptr->page_size ) { + if ((offset + size) <= pb_ptr->page_size) { HDassert(num_touched_pages == 1); length = size; - - } else { + } + else { HDassert(num_touched_pages == 2); length = size - (pb_ptr->page_size - offset); @@ -4477,29 +4265,23 @@ H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, H5PB__SEARCH_INDEX(pb_ptr, first_page, entry_ptr, FAIL) /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - FALSE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), FALSE, FALSE) - if ( ( NULL == entry_ptr ) && - ( H5PB__load_page(shared, pb_ptr, first_page_addr, - type, &entry_ptr) < 0 ) ) + if ((NULL == entry_ptr) && (H5PB__load_page(shared, pb_ptr, first_page_addr, type, &entry_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "page buffer page load request failed (1)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "page buffer page load request failed (1)") HDassert(entry_ptr); HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); HDassert(entry_ptr->addr == first_page_addr); - /* copy data from first page into read buffer */ - HDmemcpy((uint8_t *)buf, ((uint8_t *)(entry_ptr->image_ptr) + offset), - length); + HDmemcpy((uint8_t *)buf, ((uint8_t *)(entry_ptr->image_ptr) + offset), length); H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) /* second page, if it exists */ - if ( num_touched_pages == 2 ) { + if (num_touched_pages == 2) { offset = length; length = size - offset; @@ -4510,15 +4292,12 @@ H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, H5PB__SEARCH_INDEX(pb_ptr, last_page, entry_ptr, FAIL) /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - FALSE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), FALSE, FALSE) - if ( ( NULL == entry_ptr ) && - ( H5PB__load_page(shared, pb_ptr, last_page_addr, - type, &entry_ptr) < 0 ) ) + if ((NULL == entry_ptr) && + (H5PB__load_page(shared, pb_ptr, last_page_addr, type, &entry_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "page buffer page load request failed (2)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "page buffer page load request failed (2)") HDassert(entry_ptr); HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); @@ -4526,9 +4305,8 @@ H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, HDassert(entry_ptr->page == last_page); /* copy data from second page into read buffer */ - HDmemcpy(((uint8_t *)(buf) + offset), - (uint8_t *)(entry_ptr->image_ptr), length); - + HDmemcpy(((uint8_t *)(buf) + offset), (uint8_t *)(entry_ptr->image_ptr), length); + H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, FAIL) } } /* end else */ @@ -4541,7 +4319,6 @@ done: } /* end H5PB__read_raw() */ - /*------------------------------------------------------------------------- * * Function: H5PB__write_meta @@ -4553,29 +4330,29 @@ done: * one page, and vfd_swmr_writer is TRUE, the write must * buffered in the page buffer until the end of the tick. * - * If it doesn't exist already, create a multi-page metadata - * entry in the page buffer and copy the write into it. + * If it doesn't exist already, create a multi-page metadata + * entry in the page buffer and copy the write into it. * Insert the new entry in the tick list if necessary. * - * Test to see if the write of the multi-page metadata - * entry must be delayed. If so, place the entry in + * Test to see if the write of the multi-page metadata + * entry must be delayed. If so, place the entry in * the delayed write list. Otherwise, the multi-page * metadata entry will be written to the HDF5 file and - * evicted when the tick list is released at the of the + * evicted when the tick list is released at the of the * tick. * * 8) If the write is of metadata, and the write is of size * less than or equal to the page size, write the data - * into the page buffer, loading and inserting a page + * into the page buffer, loading and inserting a page * if necessary. * * If, in addition, vfd_swmr_writer is TRUE, we must: * * * add the page touched by the write to the tick list - * so that it will be buffered until the end of the + * so that it will be buffered until the end of the * tick. * - * * test to see if the write must be delayed, and + * * test to see if the write must be delayed, and * add the page to the delayed write list if so. * * Observe that this implies that: @@ -4587,11 +4364,11 @@ done: * * 3) This is a metadata write. * - * Note also that if the metadata write is of size - * no larger than page size, it may not cross page + * Note also that if the metadata write is of size + * no larger than page size, it may not cross page * boundaries. * - * Further, for writes larger than page size (case 7 only), + * Further, for writes larger than page size (case 7 only), * the base address must be page aligned. * * Return: Non-negative on success/Negative on failure @@ -4603,15 +4380,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, - size_t size, const void *buf/*in*/) +H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf /*in*/) { - H5PB_t *pb_ptr; /* Page buffer for this file */ + H5PB_t * pb_ptr; /* Page buffer for this file */ H5PB_entry_t *entry_ptr; /* Pointer to page buffer entry */ - uint64_t page; /* page offset of addr */ - haddr_t page_addr; /* page containg addr */ - size_t offset; /* offset of write in page */ - herr_t ret_value = SUCCEED; /* Return value */ + uint64_t page; /* page offset of addr */ + haddr_t page_addr; /* page containg addr */ + size_t offset; /* offset of write in page */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4627,7 +4403,7 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, HDassert(buf); /* Calculate the aligned address of the first page */ - page = (addr / pb_ptr->page_size); + page = (addr / pb_ptr->page_size); page_addr = page * pb_ptr->page_size; /* if size > pb_ptr->page_size, addr must be page aligned */ @@ -4636,25 +4412,25 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, H5PB__SEARCH_INDEX(pb_ptr, page, entry_ptr, FAIL) /* case 7) metadata write of size greater than page size. */ - if ( size > pb_ptr->page_size ) { + if (size > pb_ptr->page_size) { offset = 0; - /* The write must be for a multi-page metadata entry, and + /* The write must be for a multi-page metadata entry, and * we must be running as a VFD SWMR writer. * * This requires the following actions: * - * 1) If the multi-page metadata entry is not already in the + * 1) If the multi-page metadata entry is not already in the * page buffer, create an entry for it. * * 2) Overwrite the image of the entry with the write buffer. * - * 3) If the entry is not already on the tick list, add it to + * 3) If the entry is not already on the tick list, add it to * the tick list. - * + * * 4) If the entry is not already on the delayed write list, - * test to see if it should be, and move it from the + * test to see if it should be, and move it from the * LRU to the delayed write list and set the delay_write_until * field appropriately. * @@ -4668,18 +4444,16 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, */ if (entry_ptr != NULL && entry_ptr->size < size) { H5PB_entry_t *overlap; - void *new_image = H5MM_malloc(size); - uint64_t iter_page; - uint64_t last_page = page + - roundup(size, pb_ptr->page_size) / pb_ptr->page_size; + void * new_image = H5MM_malloc(size); + uint64_t iter_page; + uint64_t last_page = page + roundup(size, pb_ptr->page_size) / pb_ptr->page_size; for (iter_page = page + 1; iter_page < last_page; iter_page++) { H5PB__SEARCH_INDEX(pb_ptr, iter_page, overlap, FAIL) HDassert(overlap == NULL); } if (new_image == NULL) { - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, - "couldn't extend entry"); + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "couldn't extend entry"); } H5PB__UPDATE_RP_FOR_REMOVE(pb_ptr, entry_ptr, FAIL) @@ -4692,8 +4466,8 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); entry_ptr->image_ptr = new_image; - entry_ptr->is_mpmde = TRUE; - entry_ptr->size = size; + entry_ptr->is_mpmde = TRUE; + entry_ptr->size = size; if (entry_ptr->modified_this_tick) H5PB__INSERT_IN_TL(pb_ptr, entry_ptr, FAIL) @@ -4701,37 +4475,34 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, } /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - TRUE, TRUE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), TRUE, TRUE) - if ( NULL == entry_ptr ) { + if (NULL == entry_ptr) { - /* the multi-page metadata entry is not currently in the page + /* the multi-page metadata entry is not currently in the page * buffer. Create an entry for it, and insert it into the LRU. * - * Don't bother to try to make space for it, as VFD SWMR + * Don't bother to try to make space for it, as VFD SWMR * ignores the limits on page buffer size. */ - if ( H5PB__create_new_page(pb_ptr, addr, size, type, - FALSE, &entry_ptr) < 0 ) + if (H5PB__create_new_page(pb_ptr, addr, size, type, FALSE, &entry_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "can't create new page buffer page") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "can't create new page buffer page") - /* set entry_ptr->loaded to TRUE so as to trigger the + /* set entry_ptr->loaded to TRUE so as to trigger the * the delayed write test in H5PB__mark_entry_dirty(). */ entry_ptr->loaded = TRUE; } - /* at this point, one way or the other, the multi-page metadata + /* at this point, one way or the other, the multi-page metadata * entry must be in the page buffer. */ HDassert(entry_ptr->is_mpmde); HDassert(size == entry_ptr->size); HDassert(type == entry_ptr->mem_type); - - } else { + } + else { /* case 8) metadata write of size no larger than page size */ offset = addr - page_addr; @@ -4740,13 +4511,10 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, HDassert((offset + size) <= pb_ptr->page_size); /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - TRUE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), TRUE, FALSE) - if (NULL == entry_ptr && - H5PB__load_page(shared, pb_ptr, page_addr, type, &entry_ptr) < 0) { - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "page buffer page load request failed (1)") + if (NULL == entry_ptr && H5PB__load_page(shared, pb_ptr, page_addr, type, &entry_ptr) < 0) { + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "page buffer page load request failed (1)") } HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); @@ -4781,7 +4549,6 @@ done: } /* end H5PB__write_meta() */ - /*------------------------------------------------------------------------- * * Function: H5PB__write_raw @@ -4789,20 +4556,20 @@ done: * Purpose: Satisfy a raw data write in cases 3 and 4 from H5PB_write(). * Specifically: * - * 3) If the write is raw data, and it of page size or - * larger, write directly to the HDF5 file. + * 3) If the write is raw data, and it of page size or + * larger, write directly to the HDF5 file. * - * It is possible that the write intersects one or more + * It is possible that the write intersects one or more * pages in the page buffer -- test for this and update - * any partially written pages, and evict any pages + * any partially written pages, and evict any pages * that are completely overwritten. * - * Note that no pages are inserted into the page buffer in + * Note that no pages are inserted into the page buffer in * this case. * - * 4) If the write is of raw data, and it is of size less + * 4) If the write is of raw data, and it is of size less * than the page size, write the page into the page - * buffer, loading and inserting pages into the + * buffer, loading and inserting pages into the * page buffer as necessary * * Observe that this implies that: @@ -4823,22 +4590,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, - size_t size, const void *buf/*out*/) +H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf /*out*/) { - H5PB_t *pb_ptr; /* Page buffer for this file */ + H5PB_t * pb_ptr; /* Page buffer for this file */ H5PB_entry_t *entry_ptr; /* Pointer to page buffer entry */ - uint64_t first_page; /* page offset of first I/O */ - uint64_t last_page; /* page offset of last I/O */ - uint64_t search_page; /* page offset of current page */ - haddr_t first_page_addr; /* address of first page of I/O */ - haddr_t last_page_addr; /* address of last page of I/O */ - haddr_t search_addr; /* Address of current page */ - hsize_t num_touched_pages; /* Number of pages accessed */ - hsize_t i; /* Local index variable */ - size_t length; /* length of write in a page */ - size_t offset; /* offset of write in a page */ - herr_t ret_value = SUCCEED; /* Return value */ + uint64_t first_page; /* page offset of first I/O */ + uint64_t last_page; /* page offset of last I/O */ + uint64_t search_page; /* page offset of current page */ + haddr_t first_page_addr; /* address of first page of I/O */ + haddr_t last_page_addr; /* address of last page of I/O */ + haddr_t search_addr; /* Address of current page */ + hsize_t num_touched_pages; /* Number of pages accessed */ + hsize_t i; /* Local index variable */ + size_t length; /* length of write in a page */ + size_t offset; /* offset of write in a page */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4855,129 +4621,117 @@ H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, HDassert(H5FD_MEM_DRAW == type); /* Calculate the aligned address of the first page */ - first_page = (addr / pb_ptr->page_size); + first_page = (addr / pb_ptr->page_size); first_page_addr = first_page * pb_ptr->page_size; /* Calculate the aligned address of the last page */ - last_page = ((addr + size - 1) / pb_ptr->page_size); + last_page = ((addr + size - 1) / pb_ptr->page_size); last_page_addr = last_page * pb_ptr->page_size; /* Calculate number of pages that this read spans. */ num_touched_pages = last_page - first_page + 1; - if ( first_page_addr == last_page_addr ) { + if (first_page_addr == last_page_addr) { HDassert(1 == num_touched_pages); last_page_addr = HADDR_UNDEF; - } /* case 3) raw data write of page size or greater. */ - if ( size >= pb_ptr->page_size ) { - if ( H5FD_write(shared->lf, type, addr, size, buf) < 0 ) - - HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, \ - "write through metadata accumulator failed") + if (size >= pb_ptr->page_size) { + if (H5FD_write(shared->lf, type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "write through metadata accumulator failed") H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size); - /* For each page that intersects with the above write, check to see + /* For each page that intersects with the above write, check to see * if it exists in the page buffer. * * If it does and is, and if the write overwrites page fully, * mark the page clean and evict it. * - * If the write only partially intersects a page, update the + * If the write only partially intersects a page, update the * page and mark it dirty. */ search_page = first_page; search_addr = first_page_addr; - for(i = 0; i < num_touched_pages; i++) { + for (i = 0; i < num_touched_pages; i++) { H5PB__SEARCH_INDEX(pb_ptr, search_page, entry_ptr, FAIL) /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - FALSE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), FALSE, FALSE) - if ( entry_ptr ) { + if (entry_ptr) { - HDassert( entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC ); - HDassert( ! ( entry_ptr->is_metadata ) ); - HDassert( entry_ptr->page == search_page ); - HDassert( entry_ptr->addr == search_addr ); - HDassert( entry_ptr->size == pb_ptr->page_size ); - HDassert( entry_ptr->delay_write_until == 0 ); - HDassert( entry_ptr->addr <= addr + size ); + HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); + HDassert(!(entry_ptr->is_metadata)); + HDassert(entry_ptr->page == search_page); + HDassert(entry_ptr->addr == search_addr); + HDassert(entry_ptr->size == pb_ptr->page_size); + HDassert(entry_ptr->delay_write_until == 0); + HDassert(entry_ptr->addr <= addr + size); - if ( ( addr <= entry_ptr->addr ) && - ( entry_ptr->addr + entry_ptr->size <= addr + size ) ) { + if ((addr <= entry_ptr->addr) && (entry_ptr->addr + entry_ptr->size <= addr + size)) { /* the page is completely overwritten -- mark it clean * and evict it. */ - if ( ( entry_ptr->is_dirty ) && - ( H5PB__mark_entry_clean(pb_ptr, entry_ptr) < 0 ) ) + if ((entry_ptr->is_dirty) && (H5PB__mark_entry_clean(pb_ptr, entry_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "mark entry clean failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "mark entry clean failed") if (H5PB__evict_entry(shared, entry_ptr, TRUE, FALSE) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "forced eviction failed (1)") - - } else if ( i == 0 ) { + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "forced eviction failed (1)") + } + else if (i == 0) { /* handle partial overwrite of the first page. */ - HDassert( search_addr == first_page_addr ); - HDassert( search_page == first_page ); - HDassert( search_addr < addr ); - HDassert( entry_ptr->addr + entry_ptr->size <= - addr + size ); + HDassert(search_addr == first_page_addr); + HDassert(search_page == first_page); + HDassert(search_addr < addr); + HDassert(entry_ptr->addr + entry_ptr->size <= addr + size); offset = addr - first_page_addr; - HDassert( offset > 0 ); - HDassert( pb_ptr->page_size >= offset ); - HDassert( size >= pb_ptr->page_size - (size_t)offset ); + HDassert(offset > 0); + HDassert(pb_ptr->page_size >= offset); + HDassert(size >= pb_ptr->page_size - (size_t)offset); - HDmemcpy((uint8_t *)entry_ptr->image_ptr + offset, buf, + HDmemcpy((uint8_t *)entry_ptr->image_ptr + offset, buf, pb_ptr->page_size - (size_t)offset); - if ( H5PB__mark_entry_dirty(shared, pb_ptr, entry_ptr) < 0 ) + if (H5PB__mark_entry_dirty(shared, pb_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "mark entry dirty failed (1)") - - } else if ( i == num_touched_pages - 1 ) { + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "mark entry dirty failed (1)") + } + else if (i == num_touched_pages - 1) { /* handle partial overwrite of the last page. */ - HDassert( i > 0 ); - HDassert( search_addr == last_page_addr ); - HDassert( search_page == last_page ); - HDassert( addr < last_page_addr ); - HDassert( last_page_addr < addr + size ); + HDassert(i > 0); + HDassert(search_addr == last_page_addr); + HDassert(search_page == last_page); + HDassert(addr < last_page_addr); + HDassert(last_page_addr < addr + size); - offset = (num_touched_pages - 2) * pb_ptr->page_size + + offset = (num_touched_pages - 2) * pb_ptr->page_size + (pb_ptr->page_size - (addr - first_page_addr)); - HDmemcpy(entry_ptr->image_ptr, - (const uint8_t *)buf + offset, + HDmemcpy(entry_ptr->image_ptr, (const uint8_t *)buf + offset, (size_t)((addr + size) - last_page_addr)); - if ( H5PB__mark_entry_dirty(shared, pb_ptr, entry_ptr) < 0 ) + if (H5PB__mark_entry_dirty(shared, pb_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "mark entry dirty failed (2)") - } else { + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "mark entry dirty failed (2)") + } + else { /* this should be un-reachable */ HDassert(FALSE); - } } /* if ( entry_ptr ) */ @@ -4985,8 +4739,9 @@ H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, search_addr += pb_ptr->page_size; } /* end for */ - } else { - /* case 4: Raw data write of size less than page size. + } + else { + /* case 4: Raw data write of size less than page size. * * In this case, write the data to the page buffer, loading * pages if necessary. @@ -4996,48 +4751,41 @@ H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, /* first page */ offset = addr - first_page_addr; - if ( (offset + size) <= pb_ptr->page_size ) { + if ((offset + size) <= pb_ptr->page_size) { HDassert(num_touched_pages == 1); length = size; - - } else { + } + else { HDassert(num_touched_pages == 2); length = pb_ptr->page_size - offset; - HDassert( offset + length == pb_ptr->page_size ); + HDassert(offset + length == pb_ptr->page_size); } /* get the first page */ H5PB__SEARCH_INDEX(pb_ptr, first_page, entry_ptr, FAIL) /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - FALSE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), FALSE, FALSE) - if ( ( NULL == entry_ptr ) && - ( H5PB__load_page(shared, pb_ptr, first_page_addr, - type, &entry_ptr) < 0 ) ) + if ((NULL == entry_ptr) && (H5PB__load_page(shared, pb_ptr, first_page_addr, type, &entry_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "page buffer page load request failed (1)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "page buffer page load request failed (1)") HDassert(entry_ptr); HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); HDassert(entry_ptr->addr == first_page_addr); - /* copy data from the write buffer into the first page */ - HDmemcpy(((uint8_t *)(entry_ptr->image_ptr)) + offset, - (const uint8_t *)buf, length); + HDmemcpy(((uint8_t *)(entry_ptr->image_ptr)) + offset, (const uint8_t *)buf, length); - if ( H5PB__mark_entry_dirty(shared, pb_ptr, entry_ptr) < 0 ) + if (H5PB__mark_entry_dirty(shared, pb_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "mark entry dirty failed (3)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "mark entry dirty failed (3)") /* second page, if it exists */ - if ( num_touched_pages == 2 ) { + if (num_touched_pages == 2) { offset = length; length = size - offset; @@ -5048,15 +4796,12 @@ H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, H5PB__SEARCH_INDEX(pb_ptr, last_page, entry_ptr, FAIL) /* update hit rate stats */ - H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), \ - FALSE, FALSE) + H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, (entry_ptr != NULL), FALSE, FALSE) - if ( ( NULL == entry_ptr ) && - ( H5PB__load_page(shared, pb_ptr, last_page_addr, - type, &entry_ptr) < 0 ) ) + if ((NULL == entry_ptr) && + (H5PB__load_page(shared, pb_ptr, last_page_addr, type, &entry_ptr) < 0)) - HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, \ - "page buffer page load request failed (2)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "page buffer page load request failed (2)") HDassert(entry_ptr); HDassert(entry_ptr->magic == H5PB__H5PB_ENTRY_T_MAGIC); @@ -5064,13 +4809,11 @@ H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, HDassert(entry_ptr->page == last_page); /* copy data from the write buffer into the first page */ - HDmemcpy((uint8_t *)(entry_ptr->image_ptr), - ((const uint8_t *)(buf) + offset), length); + HDmemcpy((uint8_t *)(entry_ptr->image_ptr), ((const uint8_t *)(buf) + offset), length); - if ( H5PB__mark_entry_dirty(shared, pb_ptr, entry_ptr) < 0 ) + if (H5PB__mark_entry_dirty(shared, pb_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "mark entry dirty failed (3)") + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "mark entry dirty failed (3)") } } @@ -5081,4 +4824,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PB__write_raw() */ - diff --git a/src/H5PBmodule.h b/src/H5PBmodule.h index c8aabb6..09bee16 100644 --- a/src/H5PBmodule.h +++ b/src/H5PBmodule.h @@ -25,8 +25,8 @@ * reporting macros. */ #define H5PB_MODULE -#define H5_MY_PKG H5PB -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5PB +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO #endif /* _H5PBmodule_H */ diff --git a/src/H5PBpkg.h b/src/H5PBpkg.h index 14804ac..664cfce 100644 --- a/src/H5PBpkg.h +++ b/src/H5PBpkg.h @@ -39,10 +39,9 @@ /* page buffer configuration settings */ -#define H5PB__H5PB_ENTRY_T_MAGIC 0x02030405 -#define H5PB__DO_SANITY_CHECKS TRUE -#define H5PB__COLLECT_PAGE_BUFFER_STATS TRUE - +#define H5PB__H5PB_ENTRY_T_MAGIC 0x02030405 +#define H5PB__DO_SANITY_CHECKS TRUE +#define H5PB__COLLECT_PAGE_BUFFER_STATS TRUE /**************************************************************************** * @@ -69,69 +68,38 @@ #if H5PB__DO_SANITY_CHECKS -#define H5PB__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -if ( ( (head_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (Size) < (int64_t)((entry_ptr)->size ) ) || \ - ( ( (Size) == (int64_t)((entry_ptr)->size) ) && ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->prev == NULL ) && ( (head_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (head_ptr) == (entry_ptr) ) && \ - ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->next == NULL ) && \ - ( (entry_ptr)->prev == NULL ) && \ - ( (Size) == (int64_t)((entry_ptr)->size) ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "DLL pre remove SC failed") \ -} - -#define H5PB__DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( (len) < 0 ) || \ - ( (Size) < 0 ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (size_t)(Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "DLL sanity check failed") \ -} - -#define H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->next != NULL ) || \ - ( (entry_ptr)->prev != NULL ) || \ - ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (size_t)(Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ - ) \ - ) \ - ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "DLL pre insert SC failed") \ -} +#define H5PB__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + if (((head_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ + ((Size) < (int64_t)((entry_ptr)->size)) || \ + (((Size) == (int64_t)((entry_ptr)->size)) && (!((len) == 1))) || \ + (((entry_ptr)->prev == NULL) && ((head_ptr) != (entry_ptr))) || \ + (((entry_ptr)->next == NULL) && ((tail_ptr) != (entry_ptr))) || \ + (((len) == 1) && \ + (!(((head_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->next == NULL) && \ + ((entry_ptr)->prev == NULL) && ((Size) == (int64_t)((entry_ptr)->size)))))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "DLL pre remove SC failed") \ + } + +#define H5PB__DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || ((len) < 0) || \ + ((Size) < 0) || \ + (((len) == 1) && \ + (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((head_ptr)->size != (size_t)(Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->next != NULL)))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "DLL sanity check failed") \ + } + +#define H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + if (((entry_ptr) == NULL) || ((entry_ptr)->next != NULL) || ((entry_ptr)->prev != NULL) || \ + ((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || \ + (((len) == 1) && \ + (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((head_ptr)->size != (size_t)(Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->next != NULL)))) { \ + HDassert(FALSE); \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "DLL pre insert SC failed") \ + } #else /* H5PB__DO_SANITY_CHECKS */ @@ -141,165 +109,121 @@ if ( ( (entry_ptr) == NULL ) || \ #endif /* H5PB__DO_SANITY_CHECKS */ - -#define H5PB__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ -{ \ - H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->next = (entry_ptr); \ - (entry_ptr)->prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += (int64_t)((entry_ptr)->size); \ -} /* H5PB__DLL_APPEND() */ - -#define H5PB__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ -{ \ - H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->prev = (entry_ptr); \ - (entry_ptr)->next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += (int64_t)((entry_ptr)->size); \ -} /* H5PB__DLL_PREPEND() */ - -#define H5PB__DLL_INSERT_BEFORE(entry_ptr, suc_ptr, head_ptr, tail_ptr, len, \ - Size, fail_val) \ -{ \ - HDassert( ((suc_ptr) == NULL) || \ - ((suc_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC) ); \ - \ - if ( suc_ptr == NULL ) \ - /* list empty or no successor -- append */ \ - H5PB__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - \ - else if ( suc_ptr->prev == NULL ) \ - /* successor at head of list -- prepend */ \ - H5PB__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ - \ - else /* sucessor in body of list -- insert before it */ \ - { \ - H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - HDassert(suc_ptr->prev->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ - HDassert(suc_ptr->prev->next == suc_ptr); \ - entry_ptr->prev = suc_ptr->prev; \ - entry_ptr->prev->next = entry_ptr; \ - entry_ptr->next = suc_ptr; \ - suc_ptr->prev = entry_ptr; \ - (len)++; \ - (Size) += (int64_t)((entry_ptr)->size); \ - } \ -} /* H5PB__DLL_INSERT_BEFORE() */ - -#define H5PB__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ -{ \ - H5PB__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->prev = NULL; \ - } \ - else \ - (entry_ptr)->prev->next = (entry_ptr)->next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->next = NULL; \ - } \ - else \ - (entry_ptr)->next->prev = (entry_ptr)->prev; \ - entry_ptr->next = NULL; \ - entry_ptr->prev = NULL; \ - (len)--; \ - (Size) -= (int64_t)((entry_ptr)->size); \ - } \ -} /* H5PB__DLL_REMOVE() */ - +#define H5PB__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (tail_ptr)->next = (entry_ptr); \ + (entry_ptr)->prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += (int64_t)((entry_ptr)->size); \ + } /* H5PB__DLL_APPEND() */ + +#define H5PB__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (head_ptr)->prev = (entry_ptr); \ + (entry_ptr)->next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += (int64_t)((entry_ptr)->size); \ + } /* H5PB__DLL_PREPEND() */ + +#define H5PB__DLL_INSERT_BEFORE(entry_ptr, suc_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + HDassert(((suc_ptr) == NULL) || ((suc_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC)); \ + \ + if (suc_ptr == NULL) \ + /* list empty or no successor -- append */ \ + H5PB__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + \ + else if (suc_ptr->prev == NULL) \ + /* successor at head of list -- prepend */ \ + H5PB__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + \ + else /* sucessor in body of list -- insert before it */ \ + { \ + H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + HDassert(suc_ptr->prev->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert(suc_ptr->prev->next == suc_ptr); \ + entry_ptr->prev = suc_ptr->prev; \ + entry_ptr->prev->next = entry_ptr; \ + entry_ptr->next = suc_ptr; \ + suc_ptr->prev = entry_ptr; \ + (len)++; \ + (Size) += (int64_t)((entry_ptr)->size); \ + } \ + } /* H5PB__DLL_INSERT_BEFORE() */ + +#define H5PB__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5PB__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + if ((head_ptr) == (entry_ptr)) { \ + (head_ptr) = (entry_ptr)->next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->prev = NULL; \ + } \ + else \ + (entry_ptr)->prev->next = (entry_ptr)->next; \ + if ((tail_ptr) == (entry_ptr)) { \ + (tail_ptr) = (entry_ptr)->prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->next = NULL; \ + } \ + else \ + (entry_ptr)->next->prev = (entry_ptr)->prev; \ + entry_ptr->next = NULL; \ + entry_ptr->prev = NULL; \ + (len)--; \ + (Size) -= (int64_t)((entry_ptr)->size); \ + } \ + } /* H5PB__DLL_REMOVE() */ #if H5PB__DO_SANITY_CHECKS -#define H5PB__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (hd_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (Size) < (int64_t)((entry_ptr)->size) ) || \ - ( ( (Size) == (int64_t)((entry_ptr)->size) ) && \ - ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->il_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->il_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->il_next == NULL ) && \ - ( (entry_ptr)->il_prev == NULL ) && \ - ( (Size) == (int64_t)((entry_ptr)->size) ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "il DLL pre remove SC failed") \ -} - -#define H5PB__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->il_next != NULL ) || \ - ( (entry_ptr)->il_prev != NULL ) || \ - ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (hd_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (int64_t)((hd_ptr)->size) != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->il_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->il_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "IL DLL pre insert SC failed") \ -} - -#define H5PB__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (int64_t)((head_ptr)->size) != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->il_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->il_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "IL DLL sanity check failed") \ -} +#define H5PB__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((hd_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ + ((Size) < (int64_t)((entry_ptr)->size)) || \ + (((Size) == (int64_t)((entry_ptr)->size)) && (!((len) == 1))) || \ + (((entry_ptr)->il_prev == NULL) && ((hd_ptr) != (entry_ptr))) || \ + (((entry_ptr)->il_next == NULL) && ((tail_ptr) != (entry_ptr))) || \ + (((len) == 1) && \ + (!(((hd_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->il_next == NULL) && \ + ((entry_ptr)->il_prev == NULL) && ((Size) == (int64_t)((entry_ptr)->size)))))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "il DLL pre remove SC failed") \ + } + +#define H5PB__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((entry_ptr) == NULL) || ((entry_ptr)->il_next != NULL) || ((entry_ptr)->il_prev != NULL) || \ + ((((hd_ptr) == NULL) || ((tail_ptr) == NULL)) && ((hd_ptr) != (tail_ptr))) || \ + (((len) == 1) && (((hd_ptr) != (tail_ptr)) || ((Size) <= 0) || ((hd_ptr) == NULL) || \ + ((int64_t)((hd_ptr)->size) != (Size)))) || \ + (((len) >= 1) && (((hd_ptr) == NULL) || ((hd_ptr)->il_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->il_next != NULL)))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "IL DLL pre insert SC failed") \ + } + +#define H5PB__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || \ + (((len) == 1) && \ + (((head_ptr) != (tail_ptr)) || ((head_ptr) == NULL) || ((int64_t)((head_ptr)->size) != (Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->il_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->il_next != NULL)))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "IL DLL sanity check failed") \ + } #else /* H5PB__DO_SANITY_CHECKS */ @@ -309,171 +233,124 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #endif /* H5PB__DO_SANITY_CHECKS */ - -#define H5PB__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val)\ -{ \ - H5PB__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->il_next = (entry_ptr); \ - (entry_ptr)->il_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += (int64_t)((entry_ptr)->size); \ - H5PB__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fail_val) \ -} /* H5PB__IL_DLL_APPEND() */ - -#define H5PB__IL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ -{ \ - H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->il_prev = (entry_ptr); \ - (entry_ptr)->il_next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += (int64_t)((entry_ptr)->size); \ -} /* H5PB__DLL_PREPEND() */ - - -#define H5PB__IL_DLL_INSERT_BEFORE(entry_ptr, suc_ptr, head_ptr, tail_ptr, \ - len, Size, fail_val) \ -{ \ - HDassert( ((suc_ptr) == NULL) || \ - ((suc_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC) ); \ - \ - if ( suc_ptr == NULL ) \ - /* list empty or no successor -- append */ \ - H5PB__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - \ - else if ( suc_ptr->il_prev == NULL ) \ - /* successor at head of list -- prepend */ \ - H5PB__IL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - \ - else /* sucessor in body of list -- insert before it */ \ - { \ - H5PB__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - HDassert(suc_ptr->il_prev->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ - HDassert(suc_ptr->il_prev->il_next == suc_ptr); \ - entry_ptr->il_prev = suc_ptr->il_prev; \ - entry_ptr->il_prev->il_next = entry_ptr; \ - entry_ptr->il_next = suc_ptr; \ - suc_ptr->il_prev = entry_ptr; \ - (len)++; \ - (Size) += (int64_t)((entry_ptr)->size); \ - } \ -} /* H5PB__DLL_INSERT_BEFORE() */ - -#define H5PB__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -{ \ - H5PB__IL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->il_next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->il_prev = NULL; \ - } \ - else \ - (entry_ptr)->il_prev->il_next = (entry_ptr)->il_next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->il_prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->il_next = NULL; \ - } \ - else \ - (entry_ptr)->il_next->il_prev = (entry_ptr)->il_prev; \ - entry_ptr->il_next = NULL; \ - entry_ptr->il_prev = NULL; \ - (len)--; \ - (Size) -= (int64_t)((entry_ptr)->size); \ - } \ - H5PB__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -} /* H5PB__IL_DLL_REMOVE() */ - +#define H5PB__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5PB__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (tail_ptr)->il_next = (entry_ptr); \ + (entry_ptr)->il_prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += (int64_t)((entry_ptr)->size); \ + H5PB__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fail_val) \ + } /* H5PB__IL_DLL_APPEND() */ + +#define H5PB__IL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5PB__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (head_ptr)->il_prev = (entry_ptr); \ + (entry_ptr)->il_next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += (int64_t)((entry_ptr)->size); \ + } /* H5PB__DLL_PREPEND() */ + +#define H5PB__IL_DLL_INSERT_BEFORE(entry_ptr, suc_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + HDassert(((suc_ptr) == NULL) || ((suc_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC)); \ + \ + if (suc_ptr == NULL) \ + /* list empty or no successor -- append */ \ + H5PB__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + \ + else if (suc_ptr->il_prev == NULL) \ + /* successor at head of list -- prepend */ \ + H5PB__IL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + \ + else /* sucessor in body of list -- insert before it */ \ + { \ + H5PB__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + HDassert(suc_ptr->il_prev->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert(suc_ptr->il_prev->il_next == suc_ptr); \ + entry_ptr->il_prev = suc_ptr->il_prev; \ + entry_ptr->il_prev->il_next = entry_ptr; \ + entry_ptr->il_next = suc_ptr; \ + suc_ptr->il_prev = entry_ptr; \ + (len)++; \ + (Size) += (int64_t)((entry_ptr)->size); \ + } \ + } /* H5PB__DLL_INSERT_BEFORE() */ + +#define H5PB__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + H5PB__IL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + if ((head_ptr) == (entry_ptr)) { \ + (head_ptr) = (entry_ptr)->il_next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->il_prev = NULL; \ + } \ + else \ + (entry_ptr)->il_prev->il_next = (entry_ptr)->il_next; \ + if ((tail_ptr) == (entry_ptr)) { \ + (tail_ptr) = (entry_ptr)->il_prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->il_next = NULL; \ + } \ + else \ + (entry_ptr)->il_next->il_prev = (entry_ptr)->il_prev; \ + entry_ptr->il_next = NULL; \ + entry_ptr->il_prev = NULL; \ + (len)--; \ + (Size) -= (int64_t)((entry_ptr)->size); \ + } \ + H5PB__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + } /* H5PB__IL_DLL_REMOVE() */ #if H5PB__DO_SANITY_CHECKS -#define H5PB__TL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (hd_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (Size) < (int64_t)((entry_ptr)->size ) ) || \ - ( ( (Size) == (int64_t)((entry_ptr)->size) ) && ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->tl_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->tl_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->tl_next == NULL ) && \ - ( (entry_ptr)->tl_prev == NULL ) && \ - ( (Size) == (int64_t)((entry_ptr)->size) ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "TL DLL pre remove SC failed") \ -} - -#define H5PB__TL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( (len) < 0 ) || \ - ( (Size) < 0 ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->tl_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->tl_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "TL DLL sanity check failed") \ -} - -#define H5PB__TL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->tl_next != NULL ) || \ - ( (entry_ptr)->tl_prev != NULL ) || \ - ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (hd_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (int64_t)((hd_ptr)->size) != (Size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->tl_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->tl_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "TL DLL pre insert SC failed") \ -} +#define H5PB__TL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((hd_ptr) == NULL) || ((tail_ptr) == NULL) || ((entry_ptr) == NULL) || ((len) <= 0) || \ + ((Size) < (int64_t)((entry_ptr)->size)) || \ + (((Size) == (int64_t)((entry_ptr)->size)) && (!((len) == 1))) || \ + (((entry_ptr)->tl_prev == NULL) && ((hd_ptr) != (entry_ptr))) || \ + (((entry_ptr)->tl_next == NULL) && ((tail_ptr) != (entry_ptr))) || \ + (((len) == 1) && \ + (!(((hd_ptr) == (entry_ptr)) && ((tail_ptr) == (entry_ptr)) && ((entry_ptr)->tl_next == NULL) && \ + ((entry_ptr)->tl_prev == NULL) && ((Size) == (int64_t)((entry_ptr)->size)))))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "TL DLL pre remove SC failed") \ + } + +#define H5PB__TL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + if (((((head_ptr) == NULL) || ((tail_ptr) == NULL)) && ((head_ptr) != (tail_ptr))) || ((len) < 0) || \ + ((Size) < 0) || \ + (((len) == 1) && (((head_ptr) != (tail_ptr)) || ((Size) <= 0) || ((head_ptr) == NULL) || \ + ((head_ptr)->size != (Size)))) || \ + (((len) >= 1) && (((head_ptr) == NULL) || ((head_ptr)->tl_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->tl_next != NULL)))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "TL DLL sanity check failed") \ + } + +#define H5PB__TL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ + if (((entry_ptr) == NULL) || ((entry_ptr)->tl_next != NULL) || ((entry_ptr)->tl_prev != NULL) || \ + ((((hd_ptr) == NULL) || ((tail_ptr) == NULL)) && ((hd_ptr) != (tail_ptr))) || \ + (((len) == 1) && (((hd_ptr) != (tail_ptr)) || ((Size) <= 0) || ((hd_ptr) == NULL) || \ + ((int64_t)((hd_ptr)->size) != (Size)))) || \ + (((len) >= 1) && (((hd_ptr) == NULL) || ((hd_ptr)->tl_prev != NULL) || ((tail_ptr) == NULL) || \ + ((tail_ptr)->tl_next != NULL)))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, (fv), "TL DLL pre insert SC failed") \ + } #else /* H5PB__DO_SANITY_CHECKS */ @@ -483,72 +360,63 @@ if ( ( (entry_ptr) == NULL ) || \ #endif /* H5PB__DO_SANITY_CHECKS */ +#define H5PB__TL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + { \ + H5PB__TL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (tail_ptr)->tl_next = (entry_ptr); \ + (entry_ptr)->tl_prev = (tail_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += entry_ptr->size; \ + } /* H5PB__AUX_DLL_APPEND() */ + +#define H5PB__TL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + H5PB__TL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (head_ptr)->tl_prev = (entry_ptr); \ + (entry_ptr)->tl_next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (Size) += (int64_t)(entry_ptr->size); \ + } /* H5PB__TL_DLL_PREPEND() */ + +#define H5PB__TL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + H5PB__TL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ + { \ + if ((head_ptr) == (entry_ptr)) { \ + (head_ptr) = (entry_ptr)->tl_next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->tl_prev = NULL; \ + } \ + else \ + (entry_ptr)->tl_prev->tl_next = (entry_ptr)->tl_next; \ + if ((tail_ptr) == (entry_ptr)) { \ + (tail_ptr) = (entry_ptr)->tl_prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->tl_next = NULL; \ + } \ + else \ + (entry_ptr)->tl_next->tl_prev = (entry_ptr)->tl_prev; \ + entry_ptr->tl_next = NULL; \ + entry_ptr->tl_prev = NULL; \ + (len)--; \ + (Size) -= (int64_t)(entry_ptr->size); \ + } \ + } /* H5PB__TL_DLL_REMOVE() */ -#define H5PB__TL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val)\ -{ \ - H5PB__TL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->tl_next = (entry_ptr); \ - (entry_ptr)->tl_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += entry_ptr->size; \ -} /* H5PB__AUX_DLL_APPEND() */ - -#define H5PB__TL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -{ \ - H5PB__TL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->tl_prev = (entry_ptr); \ - (entry_ptr)->tl_next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (Size) += (int64_t)(entry_ptr->size); \ -} /* H5PB__TL_DLL_PREPEND() */ - -#define H5PB__TL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ -{ \ - H5PB__TL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->tl_next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->tl_prev = NULL; \ - } \ - else \ - (entry_ptr)->tl_prev->tl_next = (entry_ptr)->tl_next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->tl_prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->tl_next = NULL; \ - } \ - else \ - (entry_ptr)->tl_next->tl_prev = (entry_ptr)->tl_prev; \ - entry_ptr->tl_next = NULL; \ - entry_ptr->tl_prev = NULL; \ - (len)--; \ - (Size) -= (int64_t)(entry_ptr->size); \ - } \ -} /* H5PB__TL_DLL_REMOVE() */ - - /*********************************************************************** * * Stats collection macros @@ -564,276 +432,282 @@ if ( ( (entry_ptr) == NULL ) || \ #if H5PB__COLLECT_PAGE_BUFFER_STATS -#define H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, hit, is_metadata, is_mpmde) \ -{ \ - int ii; \ - \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - \ - if ( is_metadata ) { \ - if ( is_mpmde ) { \ - ii = H5PB__STATS_MPMDE; \ - } else { \ - ii = H5PB__STATS_MD; \ - } \ - } else { \ - ii = H5PB__STATS_RD; \ - } \ - if ( hit ) \ - ((pb_ptr)->hits[ii])++; \ - else \ - ((pb_ptr)->misses[ii])++; \ -} /* H5PB__UPDATE_PB_HIT_RATE_STATS */ - -#define H5PB__UPDATE_HT_SIZE_STATS(pb_ptr) \ - if ( (pb_ptr)->index_len > (pb_ptr)->max_index_len ) \ - (pb_ptr)->max_index_len = (pb_ptr)->index_len; \ - if ( (pb_ptr)->clean_index_len > (pb_ptr)->max_clean_index_len ) \ - (pb_ptr)->max_clean_index_len = (pb_ptr)->clean_index_len; \ - if ( (pb_ptr)->dirty_index_len > (pb_ptr)->max_dirty_index_len ) \ - (pb_ptr)->max_dirty_index_len = (pb_ptr)->dirty_index_len; \ - if ( (pb_ptr)->index_size > (pb_ptr)->max_index_size ) \ - (pb_ptr)->max_index_size = (pb_ptr)->index_size; \ - if ( (pb_ptr)->clean_index_size > (pb_ptr)->max_clean_index_size ) \ - (pb_ptr)->max_clean_index_size = (pb_ptr)->clean_index_size; \ - if ( (pb_ptr)->dirty_index_size > (pb_ptr)->max_dirty_index_size ) \ - (pb_ptr)->max_dirty_index_size = (pb_ptr)->dirty_index_size; \ - if ( (pb_ptr)->curr_md_pages > (pb_ptr)->max_md_pages ) \ - (pb_ptr)->max_md_pages = (pb_ptr)->curr_md_pages; \ - if ( (pb_ptr)->curr_rd_pages > (pb_ptr)->max_rd_pages ) \ - (pb_ptr)->max_rd_pages = (pb_ptr)->curr_rd_pages; \ - if ( (pb_ptr)->mpmde_count > (pb_ptr)->max_mpmde_count ) \ - (pb_ptr)->max_rd_pages = (pb_ptr)->curr_rd_pages; - -#define H5PB__UPDATE_STATS_FOR_HT_INSERTION(pb_ptr) \ - ((pb_ptr)->total_ht_insertions)++; - - -#define H5PB__UPDATE_STATS_FOR_HT_DELETION(pb_ptr) \ - (pb_ptr)->total_ht_deletions++; - -#define H5PB__UPDATE_STATS_FOR_HT_SEARCH(pb_ptr, success, depth) \ - HDassert(depth >= 0); \ - if ( success ) { \ - (pb_ptr)->successful_ht_searches++; \ - (pb_ptr)->total_successful_ht_search_depth += (int64_t)depth; \ - } else { \ - (pb_ptr)->failed_ht_searches++; \ - (pb_ptr)->total_failed_ht_search_depth += (int64_t)depth; \ - } - -#define H5PB__UPDATE_LRU_SIZE_STATS(pb_ptr) \ - if ( (pb_ptr)->LRU_len > (pb_ptr)->max_lru_len ) \ - (pb_ptr)->max_lru_len = (pb_ptr)->LRU_len; \ - if ( (pb_ptr)->LRU_size > (pb_ptr)->max_lru_size ) \ - (pb_ptr)->max_lru_size = (pb_ptr)->LRU_size; - -#define H5PB__UPDATE_STATS_FOR_LRU_MD_SKIP(pb_ptr) \ - ((pb_ptr)->lru_md_skips)++; - -#define H5PB__UPDATE_STATS_FOR_LRU_RD_SKIP(pb_ptr) \ - ((pb_ptr)->lru_rd_skips)++; - -#define H5PB__UPDATE_STATS_FOR_LRU_TL_SKIP(pb_ptr) \ -{ \ - HDassert(pb_ptr->vfd_swmr_writer); \ - ((pb_ptr)->lru_tl_skips)++; \ -} - -#define H5PB__UPDATE_TL_SIZE_STATS(pb_ptr) \ -{ \ - HDassert((pb_ptr)->vfd_swmr_writer); \ - if ( (pb_ptr)->tl_len > (pb_ptr)->max_tl_len ) \ - (pb_ptr)->max_tl_len = (pb_ptr)->tl_len; \ - if ( (pb_ptr)->tl_size > (pb_ptr)->max_tl_size ) \ - (pb_ptr)->max_tl_size = (pb_ptr)->tl_size; \ -} - -#define H5PB__UPDATE_DWL_SIZE_STATS(pb_ptr) \ -{ \ - HDassert((pb_ptr)->vfd_swmr_writer); \ - if ( (pb_ptr)->dwl_len > (pb_ptr)->max_dwl_len ) \ - (pb_ptr)->max_dwl_len = (pb_ptr)->dwl_len; \ - if ( (pb_ptr)->dwl_size > (pb_ptr)->max_dwl_size ) \ - (pb_ptr)->max_dwl_size = (pb_ptr)->dwl_size; \ -} - -#define H5PB__UPDATE_DWL_DELAYED_WRITES(pb_ptr, insertion_depth, delay) \ -{ \ - HDassert((pb_ptr)->vfd_swmr_writer); \ - (pb_ptr)->delayed_writes++; \ - (pb_ptr)->total_delay += (int64_t)(delay); \ - (pb_ptr)->total_dwl_ins_depth += (insertion_depth); \ -} - - -#define H5PB__UPDATE_STATS_FOR_ACCESS(pb_ptr, type, size) \ -{ \ - int _i; \ - \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - \ - if ( H5FD_MEM_DRAW == (type) ) { \ - _i = H5PB__STATS_RD; \ - } else if ( (size) > (pb_ptr)->page_size ) { \ - _i = H5PB__STATS_MPMDE; \ - } else { \ - _i = H5PB__STATS_MD; \ - } \ - ((pb_ptr)->accesses[_i])++; \ -} /* H5PB__UPDATE_STATS_FOR_ACCESS */ - - -#define H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size) \ -{ \ - int ii; \ - \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - \ - if ( H5FD_MEM_DRAW == (type) ) { \ - ii = H5PB__STATS_RD; \ - } else if ( (size) > (pb_ptr)->page_size ) { \ - ii = H5PB__STATS_MPMDE; \ - } else { \ - ii = H5PB__STATS_MD; \ - } \ - ((pb_ptr)->bypasses[ii])++; \ -} /* H5PB__UPDATE_STATS_FOR_BYPASS */ - - -#define H5PB__UPDATE_STATS_FOR_FLUSH(pb_ptr, entry_ptr) \ -{ \ - int i; \ - \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - HDassert(entry_ptr); \ - HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ - \ - if ( (entry_ptr)->is_metadata ) { \ - if ( (entry_ptr)->is_mpmde ) { \ - i = H5PB__STATS_MPMDE; \ - } else { \ - i = H5PB__STATS_MD; \ - } \ - } else { \ - i = H5PB__STATS_RD; \ - } \ - ((pb_ptr)->flushes[i])++; \ -} /* H5PB__UPDATE_STATS_FOR_FLUSH */ - - -#define H5PB__UPDATE_STATS_FOR_EVICTION(pb_ptr, entry_ptr) \ -{ \ - int i; \ - \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - HDassert(entry_ptr); \ - HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ - \ - if ( (entry_ptr)->is_metadata ) { \ - if ( (entry_ptr)->is_mpmde ) { \ - i = H5PB__STATS_MPMDE; \ - } else { \ - i = H5PB__STATS_MD; \ - } \ - } else { \ - i = H5PB__STATS_RD; \ - } \ - ((pb_ptr)->evictions[i])++; \ -} /* H5PB__UPDATE_STATS_FOR_EVICTION */ - - -#define H5PB__UPDATE_STATS_FOR_CLEAR(pb_ptr, entry_ptr) \ -{ \ - int i; \ - \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - HDassert(entry_ptr); \ - HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ - \ - if ( (entry_ptr)->is_metadata ) { \ - if ( (entry_ptr)->is_mpmde ) { \ - i = H5PB__STATS_MPMDE; \ - } else { \ - i = H5PB__STATS_MD; \ - } \ - } else { \ - i = H5PB__STATS_RD; \ - } \ - ((pb_ptr)->clears[i])++; \ -} /* H5PB__UPDATE_STATS_FOR_CLEAR */ - - -#define H5PB__UPDATE_STATS_FOR_INSERTION(pb_ptr, entry_ptr) \ -{ \ - int i; \ - \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - HDassert(entry_ptr); \ - HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ - \ - if ( (entry_ptr)->is_metadata ) { \ - if ( (entry_ptr)->is_mpmde ) { \ - i = H5PB__STATS_MPMDE; \ - } else { \ - i = H5PB__STATS_MD; \ - } \ - } else { \ - i = H5PB__STATS_RD; \ - } \ - ((pb_ptr)->insertions[i])++; \ -} /* H5PB__UPDATE_STATS_FOR_INSERTION */ - -#define H5PB__UPDATE_STATS_FOR_LOAD(pb_ptr, entry_ptr) \ -{ \ - int i; \ - \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - HDassert(entry_ptr); \ - HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ - \ - if ( (entry_ptr)->is_metadata ) { \ - if ( (entry_ptr)->is_mpmde ) { \ - i = H5PB__STATS_MPMDE; \ - } else { \ - i = H5PB__STATS_MD; \ - } \ - } else { \ - i = H5PB__STATS_RD; \ - } \ - ((pb_ptr)->loads[i])++; \ -} /* H5PB__UPDATE_STATS_FOR_LOAD */ - -#define H5PB__UPDATE_STATS_FOR_READ_SPLIT(pb_ptr) \ -{ \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - (pb_ptr->md_read_splits)++; \ -} /* H5PB__UPDATE_STATS_FOR_READ_SPLIT */ - -#define H5PB__UPDATE_STATS_FOR_WRITE_SPLIT(pb_ptr) \ -{ \ - HDassert(pb_ptr); \ - HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ - (pb_ptr->md_write_splits)++; \ -} /* H5PB__UPDATE_STATS_FOR_READ_SPLIT */ +#define H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, hit, is_metadata, is_mpmde) \ + { \ + int ii; \ + \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + \ + if (is_metadata) { \ + if (is_mpmde) { \ + ii = H5PB__STATS_MPMDE; \ + } \ + else { \ + ii = H5PB__STATS_MD; \ + } \ + } \ + else { \ + ii = H5PB__STATS_RD; \ + } \ + if (hit) \ + ((pb_ptr)->hits[ii])++; \ + else \ + ((pb_ptr)->misses[ii])++; \ + } /* H5PB__UPDATE_PB_HIT_RATE_STATS */ + +#define H5PB__UPDATE_HT_SIZE_STATS(pb_ptr) \ + if ((pb_ptr)->index_len > (pb_ptr)->max_index_len) \ + (pb_ptr)->max_index_len = (pb_ptr)->index_len; \ + if ((pb_ptr)->clean_index_len > (pb_ptr)->max_clean_index_len) \ + (pb_ptr)->max_clean_index_len = (pb_ptr)->clean_index_len; \ + if ((pb_ptr)->dirty_index_len > (pb_ptr)->max_dirty_index_len) \ + (pb_ptr)->max_dirty_index_len = (pb_ptr)->dirty_index_len; \ + if ((pb_ptr)->index_size > (pb_ptr)->max_index_size) \ + (pb_ptr)->max_index_size = (pb_ptr)->index_size; \ + if ((pb_ptr)->clean_index_size > (pb_ptr)->max_clean_index_size) \ + (pb_ptr)->max_clean_index_size = (pb_ptr)->clean_index_size; \ + if ((pb_ptr)->dirty_index_size > (pb_ptr)->max_dirty_index_size) \ + (pb_ptr)->max_dirty_index_size = (pb_ptr)->dirty_index_size; \ + if ((pb_ptr)->curr_md_pages > (pb_ptr)->max_md_pages) \ + (pb_ptr)->max_md_pages = (pb_ptr)->curr_md_pages; \ + if ((pb_ptr)->curr_rd_pages > (pb_ptr)->max_rd_pages) \ + (pb_ptr)->max_rd_pages = (pb_ptr)->curr_rd_pages; \ + if ((pb_ptr)->mpmde_count > (pb_ptr)->max_mpmde_count) \ + (pb_ptr)->max_rd_pages = (pb_ptr)->curr_rd_pages; + +#define H5PB__UPDATE_STATS_FOR_HT_INSERTION(pb_ptr) ((pb_ptr)->total_ht_insertions)++; + +#define H5PB__UPDATE_STATS_FOR_HT_DELETION(pb_ptr) (pb_ptr)->total_ht_deletions++; + +#define H5PB__UPDATE_STATS_FOR_HT_SEARCH(pb_ptr, success, depth) \ + HDassert(depth >= 0); \ + if (success) { \ + (pb_ptr)->successful_ht_searches++; \ + (pb_ptr)->total_successful_ht_search_depth += (int64_t)depth; \ + } \ + else { \ + (pb_ptr)->failed_ht_searches++; \ + (pb_ptr)->total_failed_ht_search_depth += (int64_t)depth; \ + } + +#define H5PB__UPDATE_LRU_SIZE_STATS(pb_ptr) \ + if ((pb_ptr)->LRU_len > (pb_ptr)->max_lru_len) \ + (pb_ptr)->max_lru_len = (pb_ptr)->LRU_len; \ + if ((pb_ptr)->LRU_size > (pb_ptr)->max_lru_size) \ + (pb_ptr)->max_lru_size = (pb_ptr)->LRU_size; + +#define H5PB__UPDATE_STATS_FOR_LRU_MD_SKIP(pb_ptr) ((pb_ptr)->lru_md_skips)++; + +#define H5PB__UPDATE_STATS_FOR_LRU_RD_SKIP(pb_ptr) ((pb_ptr)->lru_rd_skips)++; + +#define H5PB__UPDATE_STATS_FOR_LRU_TL_SKIP(pb_ptr) \ + { \ + HDassert(pb_ptr->vfd_swmr_writer); \ + ((pb_ptr)->lru_tl_skips)++; \ + } + +#define H5PB__UPDATE_TL_SIZE_STATS(pb_ptr) \ + { \ + HDassert((pb_ptr)->vfd_swmr_writer); \ + if ((pb_ptr)->tl_len > (pb_ptr)->max_tl_len) \ + (pb_ptr)->max_tl_len = (pb_ptr)->tl_len; \ + if ((pb_ptr)->tl_size > (pb_ptr)->max_tl_size) \ + (pb_ptr)->max_tl_size = (pb_ptr)->tl_size; \ + } + +#define H5PB__UPDATE_DWL_SIZE_STATS(pb_ptr) \ + { \ + HDassert((pb_ptr)->vfd_swmr_writer); \ + if ((pb_ptr)->dwl_len > (pb_ptr)->max_dwl_len) \ + (pb_ptr)->max_dwl_len = (pb_ptr)->dwl_len; \ + if ((pb_ptr)->dwl_size > (pb_ptr)->max_dwl_size) \ + (pb_ptr)->max_dwl_size = (pb_ptr)->dwl_size; \ + } + +#define H5PB__UPDATE_DWL_DELAYED_WRITES(pb_ptr, insertion_depth, delay) \ + { \ + HDassert((pb_ptr)->vfd_swmr_writer); \ + (pb_ptr)->delayed_writes++; \ + (pb_ptr)->total_delay += (int64_t)(delay); \ + (pb_ptr)->total_dwl_ins_depth += (insertion_depth); \ + } + +#define H5PB__UPDATE_STATS_FOR_ACCESS(pb_ptr, type, size) \ + { \ + int _i; \ + \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + \ + if (H5FD_MEM_DRAW == (type)) { \ + _i = H5PB__STATS_RD; \ + } \ + else if ((size) > (pb_ptr)->page_size) { \ + _i = H5PB__STATS_MPMDE; \ + } \ + else { \ + _i = H5PB__STATS_MD; \ + } \ + ((pb_ptr)->accesses[_i])++; \ + } /* H5PB__UPDATE_STATS_FOR_ACCESS */ + +#define H5PB__UPDATE_STATS_FOR_BYPASS(pb_ptr, type, size) \ + { \ + int ii; \ + \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + \ + if (H5FD_MEM_DRAW == (type)) { \ + ii = H5PB__STATS_RD; \ + } \ + else if ((size) > (pb_ptr)->page_size) { \ + ii = H5PB__STATS_MPMDE; \ + } \ + else { \ + ii = H5PB__STATS_MD; \ + } \ + ((pb_ptr)->bypasses[ii])++; \ + } /* H5PB__UPDATE_STATS_FOR_BYPASS */ + +#define H5PB__UPDATE_STATS_FOR_FLUSH(pb_ptr, entry_ptr) \ + { \ + int i; \ + \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert(entry_ptr); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + \ + if ((entry_ptr)->is_metadata) { \ + if ((entry_ptr)->is_mpmde) { \ + i = H5PB__STATS_MPMDE; \ + } \ + else { \ + i = H5PB__STATS_MD; \ + } \ + } \ + else { \ + i = H5PB__STATS_RD; \ + } \ + ((pb_ptr)->flushes[i])++; \ + } /* H5PB__UPDATE_STATS_FOR_FLUSH */ + +#define H5PB__UPDATE_STATS_FOR_EVICTION(pb_ptr, entry_ptr) \ + { \ + int i; \ + \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert(entry_ptr); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + \ + if ((entry_ptr)->is_metadata) { \ + if ((entry_ptr)->is_mpmde) { \ + i = H5PB__STATS_MPMDE; \ + } \ + else { \ + i = H5PB__STATS_MD; \ + } \ + } \ + else { \ + i = H5PB__STATS_RD; \ + } \ + ((pb_ptr)->evictions[i])++; \ + } /* H5PB__UPDATE_STATS_FOR_EVICTION */ + +#define H5PB__UPDATE_STATS_FOR_CLEAR(pb_ptr, entry_ptr) \ + { \ + int i; \ + \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert(entry_ptr); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + \ + if ((entry_ptr)->is_metadata) { \ + if ((entry_ptr)->is_mpmde) { \ + i = H5PB__STATS_MPMDE; \ + } \ + else { \ + i = H5PB__STATS_MD; \ + } \ + } \ + else { \ + i = H5PB__STATS_RD; \ + } \ + ((pb_ptr)->clears[i])++; \ + } /* H5PB__UPDATE_STATS_FOR_CLEAR */ + +#define H5PB__UPDATE_STATS_FOR_INSERTION(pb_ptr, entry_ptr) \ + { \ + int i; \ + \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert(entry_ptr); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + \ + if ((entry_ptr)->is_metadata) { \ + if ((entry_ptr)->is_mpmde) { \ + i = H5PB__STATS_MPMDE; \ + } \ + else { \ + i = H5PB__STATS_MD; \ + } \ + } \ + else { \ + i = H5PB__STATS_RD; \ + } \ + ((pb_ptr)->insertions[i])++; \ + } /* H5PB__UPDATE_STATS_FOR_INSERTION */ + +#define H5PB__UPDATE_STATS_FOR_LOAD(pb_ptr, entry_ptr) \ + { \ + int i; \ + \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert(entry_ptr); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + \ + if ((entry_ptr)->is_metadata) { \ + if ((entry_ptr)->is_mpmde) { \ + i = H5PB__STATS_MPMDE; \ + } \ + else { \ + i = H5PB__STATS_MD; \ + } \ + } \ + else { \ + i = H5PB__STATS_RD; \ + } \ + ((pb_ptr)->loads[i])++; \ + } /* H5PB__UPDATE_STATS_FOR_LOAD */ + +#define H5PB__UPDATE_STATS_FOR_READ_SPLIT(pb_ptr) \ + { \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + (pb_ptr->md_read_splits)++; \ + } /* H5PB__UPDATE_STATS_FOR_READ_SPLIT */ + +#define H5PB__UPDATE_STATS_FOR_WRITE_SPLIT(pb_ptr) \ + { \ + HDassert(pb_ptr); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + (pb_ptr->md_write_splits)++; \ + } /* H5PB__UPDATE_STATS_FOR_READ_SPLIT */ #else /* H5PB__COLLECT_PAGE_BUFFER_STATS */ -#define H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, hit, is_metadata, is_mpmde) -#define H5PB__UPDATE_HT_SIZE_STATS(pb_ptr) +#define H5PB__UPDATE_PB_HIT_RATE_STATS(pb_ptr, hit, is_metadata, is_mpmde) +#define H5PB__UPDATE_HT_SIZE_STATS(pb_ptr) #define H5PB__UPDATE_STATS_FOR_HT_INSERTION(pb_ptr) #define H5PB__UPDATE_STATS_FOR_HT_DELETION(pb_ptr) #define H5PB__UPDATE_HT_SEARCH_STATS(pb_ptr, success, depth) -#define H5PB__UPDATE_LRU_SIZE_STATS(pb_ptr) +#define H5PB__UPDATE_LRU_SIZE_STATS(pb_ptr) #define H5PB__UPDATE_STATS_FOR_LRU_MD_SKIP(pb_ptr) #define H5PB__UPDATE_STATS_FOR_LRU_RD_SKIP(pb_ptr) #define H5PB__UPDATE_STATS_FOR_LRU_TL_SKIP(pb_ptr) @@ -853,7 +727,6 @@ if ( ( (entry_ptr) == NULL ) || \ #endif /* H5PB__COLLECT_PAGE_BUFFER_STATS */ - /*********************************************************************** * * Hash table access and manipulation macros: @@ -861,8 +734,8 @@ if ( ( (entry_ptr) == NULL ) || \ * The following macros handle searches, insertions, and deletion in * the hash table. * - * Note that the input to the hash function is the page of the page - * buffer entry, not it address (recall that page * page_size) == addr). + * Note that the input to the hash function is the page of the page + * buffer entry, not it address (recall that page * page_size) == addr). * * JRM -- 10/09/18 * @@ -872,243 +745,156 @@ if ( ( (entry_ptr) == NULL ) || \ * ***********************************************************************/ -#define H5PB__HASH_MASK ((uint64_t)(H5PB__HASH_TABLE_LEN - 1)) +#define H5PB__HASH_MASK ((uint64_t)(H5PB__HASH_TABLE_LEN - 1)) -#define H5PB__HASH_FCN(x) (int)(((uint64_t)(x)) & H5PB__HASH_MASK) +#define H5PB__HASH_FCN(x) (int)(((uint64_t)(x)) & H5PB__HASH_MASK) #if H5PB__DO_SANITY_CHECKS -#define H5PB__PRE_HT_INSERT_SC(pb_ptr, entry_ptr, fail_val) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->magic != H5PB__H5PB_T_MAGIC ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->ht_next != NULL ) || \ - ( (entry_ptr)->ht_prev != NULL ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( H5PB__HASH_FCN((entry_ptr)->page) < 0 ) || \ - ( H5PB__HASH_FCN((entry_ptr)->page) >= H5PB__HASH_TABLE_LEN ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + \ - (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_len != (pb_ptr)->il_len ) || \ - ( (pb_ptr)->index_size != (pb_ptr)->il_size ) || \ - ( (pb_ptr)->curr_pages < 0 ) || \ - ( (pb_ptr)->curr_rd_pages < 0 ) || \ - ( (pb_ptr)->curr_md_pages < 0 ) || \ - ( ((pb_ptr)->curr_pages != \ - ((pb_ptr)->curr_md_pages + (pb_ptr)->curr_rd_pages)) ) || \ - ( (pb_ptr)->mpmde_count < 0 ) || \ - ( (pb_ptr)->index_len != \ - ((pb_ptr)->curr_pages + (pb_ptr)->mpmde_count) ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, "pre HT insert SC failed") \ -} - -#define H5PB__POST_HT_INSERT_SC(pb_ptr, entry_ptr, fail_val) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->magic != H5PB__H5PB_T_MAGIC ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + \ - (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_len != (pb_ptr)->il_len ) || \ - ( (pb_ptr)->index_len != \ - ((pb_ptr)->curr_pages + (pb_ptr)->mpmde_count) ) || \ - ( (pb_ptr)->index_size != (pb_ptr)->il_size) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, "post HT insert SC failed") \ -} - -#define H5PB__PRE_HT_REMOVE_SC(pb_ptr, entry_ptr) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->magic != H5PB__H5PB_T_MAGIC ) || \ - ( (pb_ptr)->index_len < 1 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (pb_ptr)->index_size < (int64_t)((entry_ptr)->size) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( H5PB__HASH_FCN((entry_ptr)->page) < 0 ) || \ - ( H5PB__HASH_FCN((entry_ptr)->page) >= H5PB__HASH_TABLE_LEN ) || \ - ( ((pb_ptr)->ht)[(H5PB__HASH_FCN((entry_ptr)->page))] \ - == NULL ) || \ - ( ( ((pb_ptr)->ht)[(H5PB__HASH_FCN((entry_ptr)->page))] \ - != (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev == NULL ) ) || \ - ( ( ((pb_ptr)->ht)[(H5PB__HASH_FCN((entry_ptr)->page))] == \ - (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev != NULL ) ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + \ - (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_len != (pb_ptr)->il_len ) || \ - ( (pb_ptr)->index_size != (pb_ptr)->il_size ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "pre HT remove SC failed") \ -} - -#define H5PB__POST_HT_REMOVE_SC(pb_ptr, entry_ptr) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->magic != H5PB__H5PB_T_MAGIC ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( (entry_ptr)->ht_prev != NULL ) || \ - ( (entry_ptr)->ht_prev != NULL ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + \ - (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_len != (pb_ptr)->il_len ) || \ - ( (pb_ptr)->index_size != (pb_ptr)->il_size ) || \ - ( (pb_ptr)->curr_pages < 0 ) || \ - ( (pb_ptr)->curr_rd_pages < 0 ) || \ - ( (pb_ptr)->curr_md_pages < 0 ) || \ - ( ((pb_ptr)->curr_pages != \ - ((pb_ptr)->curr_md_pages + (pb_ptr)->curr_rd_pages)) ) || \ - ( (pb_ptr)->mpmde_count < 0 ) || \ - ( (pb_ptr)->index_len != \ - ((pb_ptr)->curr_pages + (pb_ptr)->mpmde_count) ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "post HT remove SC failed") \ -} - -#define H5PB__PRE_HT_SEARCH_SC(pb_ptr, page, fail_val) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->magic != H5PB__H5PB_T_MAGIC ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size) ) || \ - ( H5PB__HASH_FCN(page) < 0 ) || \ - ( H5PB__HASH_FCN(page) >= H5PB__HASH_TABLE_LEN ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, "pre HT search SC failed") \ -} - -#define H5PB__POST_SUC_HT_SEARCH_SC(pb_ptr, entry_ptr, k, fail_val) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->magic != H5PB__H5PB_T_MAGIC ) || \ - ( (pb_ptr)->index_len < 1 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (pb_ptr)->index_size < (int64_t)((entry_ptr)->size )) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( ((pb_ptr)->ht)[k] == NULL ) || \ - ( ( ((pb_ptr)->ht)[k] != (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev == NULL ) ) || \ - ( ( ((pb_ptr)->ht)[k] == (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev != NULL ) ) || \ - ( ( (entry_ptr)->ht_prev != NULL ) && \ - ( (entry_ptr)->ht_prev->ht_next != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->ht_next != NULL ) && \ - ( (entry_ptr)->ht_next->ht_prev != (entry_ptr) ) ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, \ - "post successful HT search SC failed") \ -} - -#define H5PB__POST_HT_SHIFT_TO_FRONT_SC(pb_ptr, entry_ptr, k, fail_val) \ -if ( ( (pb_ptr) == NULL ) || \ - ( ((pb_ptr)->ht)[k] != (entry_ptr) ) || \ - ( (entry_ptr)->ht_prev != NULL ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, \ - "post HT shift to front SC failed") \ -} - -#define H5PB__PRE_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->index_len <= 0 ) || \ - ( (pb_ptr)->index_size <= 0 ) || \ - ( (new_size) <= 0 ) || \ - ( (old_size) > (pb_ptr)->index_size ) || \ - ( ( (pb_ptr)->index_len == 1 ) && \ - ( (pb_ptr)->index_size != (old_size) ) ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + \ - (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) || \ - ( ( !( was_clean ) || \ - ( (pb_ptr)->clean_index_size < (old_size) ) ) && \ - ( ( (was_clean) ) || \ - ( (pb_ptr)->dirty_index_size < (old_size) ) ) ) || \ - ( (entry_ptr) == NULL ) || \ - ( (pb_ptr)->index_len != (pb_ptr)->il_len ) || \ - ( (pb_ptr)->index_size != (pb_ptr)->il_size ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "pre HT entry size change SC failed") \ -} - -#define H5PB__POST_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, \ - entry_ptr) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->index_len <= 0 ) || \ - ( (pb_ptr)->index_size <= 0 ) || \ - ( (new_size) > (pb_ptr)->index_size ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + \ - (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) || \ - ( ( !((entry_ptr)->is_dirty ) || \ - ( (pb_ptr)->dirty_index_size < (new_size) ) ) && \ - ( ( ((entry_ptr)->is_dirty) ) || \ - ( (pb_ptr)->clean_index_size < (new_size) ) ) ) || \ - ( ( (pb_ptr)->index_len == 1 ) && \ - ( (pb_ptr)->index_size != (new_size) ) ) || \ - ( (pb_ptr)->index_len != (pb_ptr)->il_len ) || \ - ( (pb_ptr)->index_size != (pb_ptr)->il_size ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "post HT entry size change SC failed") \ -} - -#define H5PB__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->magic != H5PB__H5PB_T_MAGIC ) || \ - ( (pb_ptr)->index_len <= 0 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->is_dirty != FALSE ) || \ - ( (pb_ptr)->index_size < (int64_t)((entry_ptr)->size) ) || \ - ( (pb_ptr)->dirty_index_size < (int64_t)((entry_ptr)->size) ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "pre HT update for entry clean SC failed") \ -} - -#define H5PB__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr) \ -if ( ( (pb_ptr) == NULL ) || \ - ( (pb_ptr)->magic != H5PB__H5PB_T_MAGIC ) || \ - ( (pb_ptr)->index_len <= 0 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->is_dirty != TRUE ) || \ - ( (pb_ptr)->index_size < (int64_t)((entry_ptr)->size) ) || \ - ( (pb_ptr)->clean_index_size < (int64_t)((entry_ptr)->size) ) || \ - ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "pre HT update for entry dirty SC failed") \ -} - -#define H5PB__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr) \ -if ( ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "post HT update for entry clean SC failed") \ -} - -#define H5PB__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr) \ -if ( ( (pb_ptr)->index_size != \ - ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->clean_index_size) ) || \ - ( (pb_ptr)->index_size < ((pb_ptr)->dirty_index_size) ) ) { \ - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "post HT update for entry dirty SC failed") \ -} +#define H5PB__PRE_HT_INSERT_SC(pb_ptr, entry_ptr, fail_val) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->magic != H5PB__H5PB_T_MAGIC) || ((entry_ptr) == NULL) || \ + ((entry_ptr)->ht_next != NULL) || ((entry_ptr)->ht_prev != NULL) || ((entry_ptr)->size <= 0) || \ + (H5PB__HASH_FCN((entry_ptr)->page) < 0) || \ + (H5PB__HASH_FCN((entry_ptr)->page) >= H5PB__HASH_TABLE_LEN) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_len != (pb_ptr)->il_len) || ((pb_ptr)->index_size != (pb_ptr)->il_size) || \ + ((pb_ptr)->curr_pages < 0) || ((pb_ptr)->curr_rd_pages < 0) || ((pb_ptr)->curr_md_pages < 0) || \ + (((pb_ptr)->curr_pages != ((pb_ptr)->curr_md_pages + (pb_ptr)->curr_rd_pages))) || \ + ((pb_ptr)->mpmde_count < 0) || \ + ((pb_ptr)->index_len != ((pb_ptr)->curr_pages + (pb_ptr)->mpmde_count))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, "pre HT insert SC failed") \ + } + +#define H5PB__POST_HT_INSERT_SC(pb_ptr, entry_ptr, fail_val) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->magic != H5PB__H5PB_T_MAGIC) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_len != (pb_ptr)->il_len) || \ + ((pb_ptr)->index_len != ((pb_ptr)->curr_pages + (pb_ptr)->mpmde_count)) || \ + ((pb_ptr)->index_size != (pb_ptr)->il_size)) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, "post HT insert SC failed") \ + } + +#define H5PB__PRE_HT_REMOVE_SC(pb_ptr, entry_ptr) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->magic != H5PB__H5PB_T_MAGIC) || ((pb_ptr)->index_len < 1) || \ + ((entry_ptr) == NULL) || ((pb_ptr)->index_size < (int64_t)((entry_ptr)->size)) || \ + ((entry_ptr)->size <= 0) || (H5PB__HASH_FCN((entry_ptr)->page) < 0) || \ + (H5PB__HASH_FCN((entry_ptr)->page) >= H5PB__HASH_TABLE_LEN) || \ + (((pb_ptr)->ht)[(H5PB__HASH_FCN((entry_ptr)->page))] == NULL) || \ + ((((pb_ptr)->ht)[(H5PB__HASH_FCN((entry_ptr)->page))] != (entry_ptr)) && \ + ((entry_ptr)->ht_prev == NULL)) || \ + ((((pb_ptr)->ht)[(H5PB__HASH_FCN((entry_ptr)->page))] == (entry_ptr)) && \ + ((entry_ptr)->ht_prev != NULL)) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_len != (pb_ptr)->il_len) || ((pb_ptr)->index_size != (pb_ptr)->il_size)) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "pre HT remove SC failed") \ + } + +#define H5PB__POST_HT_REMOVE_SC(pb_ptr, entry_ptr) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->magic != H5PB__H5PB_T_MAGIC) || ((entry_ptr) == NULL) || \ + ((entry_ptr)->size <= 0) || ((entry_ptr)->ht_prev != NULL) || ((entry_ptr)->ht_prev != NULL) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_len != (pb_ptr)->il_len) || ((pb_ptr)->index_size != (pb_ptr)->il_size) || \ + ((pb_ptr)->curr_pages < 0) || ((pb_ptr)->curr_rd_pages < 0) || ((pb_ptr)->curr_md_pages < 0) || \ + (((pb_ptr)->curr_pages != ((pb_ptr)->curr_md_pages + (pb_ptr)->curr_rd_pages))) || \ + ((pb_ptr)->mpmde_count < 0) || \ + ((pb_ptr)->index_len != ((pb_ptr)->curr_pages + (pb_ptr)->mpmde_count))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "post HT remove SC failed") \ + } + +#define H5PB__PRE_HT_SEARCH_SC(pb_ptr, page, fail_val) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->magic != H5PB__H5PB_T_MAGIC) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + (H5PB__HASH_FCN(page) < 0) || (H5PB__HASH_FCN(page) >= H5PB__HASH_TABLE_LEN)) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, "pre HT search SC failed") \ + } + +#define H5PB__POST_SUC_HT_SEARCH_SC(pb_ptr, entry_ptr, k, fail_val) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->magic != H5PB__H5PB_T_MAGIC) || ((pb_ptr)->index_len < 1) || \ + ((entry_ptr) == NULL) || ((pb_ptr)->index_size < (int64_t)((entry_ptr)->size)) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((entry_ptr)->size <= 0) || (((pb_ptr)->ht)[k] == NULL) || \ + ((((pb_ptr)->ht)[k] != (entry_ptr)) && ((entry_ptr)->ht_prev == NULL)) || \ + ((((pb_ptr)->ht)[k] == (entry_ptr)) && ((entry_ptr)->ht_prev != NULL)) || \ + (((entry_ptr)->ht_prev != NULL) && ((entry_ptr)->ht_prev->ht_next != (entry_ptr))) || \ + (((entry_ptr)->ht_next != NULL) && ((entry_ptr)->ht_next->ht_prev != (entry_ptr)))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, "post successful HT search SC failed") \ + } + +#define H5PB__POST_HT_SHIFT_TO_FRONT_SC(pb_ptr, entry_ptr, k, fail_val) \ + if (((pb_ptr) == NULL) || (((pb_ptr)->ht)[k] != (entry_ptr)) || ((entry_ptr)->ht_prev != NULL)) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, fail_val, "post HT shift to front SC failed") \ + } + +#define H5PB__PRE_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, entry_ptr, was_clean) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->index_len <= 0) || ((pb_ptr)->index_size <= 0) || \ + ((new_size) <= 0) || ((old_size) > (pb_ptr)->index_size) || \ + (((pb_ptr)->index_len == 1) && ((pb_ptr)->index_size != (old_size))) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size)) || \ + ((!(was_clean) || ((pb_ptr)->clean_index_size < (old_size))) && \ + (((was_clean)) || ((pb_ptr)->dirty_index_size < (old_size)))) || \ + ((entry_ptr) == NULL) || ((pb_ptr)->index_len != (pb_ptr)->il_len) || \ + ((pb_ptr)->index_size != (pb_ptr)->il_size)) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "pre HT entry size change SC failed") \ + } + +#define H5PB__POST_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, entry_ptr) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->index_len <= 0) || ((pb_ptr)->index_size <= 0) || \ + ((new_size) > (pb_ptr)->index_size) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size)) || \ + ((!((entry_ptr)->is_dirty) || ((pb_ptr)->dirty_index_size < (new_size))) && \ + ((((entry_ptr)->is_dirty)) || ((pb_ptr)->clean_index_size < (new_size)))) || \ + (((pb_ptr)->index_len == 1) && ((pb_ptr)->index_size != (new_size))) || \ + ((pb_ptr)->index_len != (pb_ptr)->il_len) || ((pb_ptr)->index_size != (pb_ptr)->il_size)) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "post HT entry size change SC failed") \ + } + +#define H5PB__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->magic != H5PB__H5PB_T_MAGIC) || ((pb_ptr)->index_len <= 0) || \ + ((entry_ptr) == NULL) || ((entry_ptr)->is_dirty != FALSE) || \ + ((pb_ptr)->index_size < (int64_t)((entry_ptr)->size)) || \ + ((pb_ptr)->dirty_index_size < (int64_t)((entry_ptr)->size)) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "pre HT update for entry clean SC failed") \ + } + +#define H5PB__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr) \ + if (((pb_ptr) == NULL) || ((pb_ptr)->magic != H5PB__H5PB_T_MAGIC) || ((pb_ptr)->index_len <= 0) || \ + ((entry_ptr) == NULL) || ((entry_ptr)->is_dirty != TRUE) || \ + ((pb_ptr)->index_size < (int64_t)((entry_ptr)->size)) || \ + ((pb_ptr)->clean_index_size < (int64_t)((entry_ptr)->size)) || \ + ((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "pre HT update for entry dirty SC failed") \ + } + +#define H5PB__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr) \ + if (((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "post HT update for entry clean SC failed") \ + } + +#define H5PB__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr) \ + if (((pb_ptr)->index_size != ((pb_ptr)->clean_index_size + (pb_ptr)->dirty_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->clean_index_size)) || \ + ((pb_ptr)->index_size < ((pb_ptr)->dirty_index_size))) { \ + HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "post HT update for entry dirty SC failed") \ + } #else /* H5PB__DO_SANITY_CHECKS */ @@ -1121,165 +907,162 @@ if ( ( (pb_ptr)->index_size != \ #define H5PB__POST_HT_SHIFT_TO_FRONT_SC(pb_ptr, entry_ptr, k, fail_val) #define H5PB__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr) #define H5PB__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr) -#define H5PB__PRE_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, \ - entry_ptr, was_clean) -#define H5PB__POST_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, \ - entry_ptr) +#define H5PB__PRE_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, entry_ptr, was_clean) +#define H5PB__POST_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, entry_ptr) #define H5PB__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr) #define H5PB__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr) #endif /* H5PB__DO_SANITY_CHECKS */ +#define H5PB__INSERT_IN_INDEX(pb_ptr, entry_ptr, fail_val) \ + { \ + int k; \ + H5PB__PRE_HT_INSERT_SC(pb_ptr, entry_ptr, fail_val) \ + k = H5PB__HASH_FCN((entry_ptr)->page); \ + if (((pb_ptr)->ht)[k] != NULL) { \ + (entry_ptr)->ht_next = ((pb_ptr)->ht)[k]; \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr); \ + } \ + ((pb_ptr)->ht)[k] = (entry_ptr); \ + (pb_ptr)->index_len++; \ + (pb_ptr)->index_size += (int64_t)((entry_ptr)->size); \ + if ((entry_ptr)->is_dirty) { \ + (pb_ptr)->dirty_index_size += (int64_t)((entry_ptr)->size); \ + } \ + else { \ + (pb_ptr)->clean_index_size += (int64_t)((entry_ptr)->size); \ + } \ + if ((entry_ptr)->is_metadata) { \ + if ((entry_ptr)->is_mpmde) { \ + ((pb_ptr)->mpmde_count)++; \ + } \ + else { \ + ((pb_ptr)->curr_md_pages)++; \ + (pb_ptr)->curr_pages++; \ + } \ + } \ + else { \ + ((pb_ptr)->curr_rd_pages)++; \ + (pb_ptr)->curr_pages++; \ + } \ + H5PB__IL_DLL_APPEND((entry_ptr), (pb_ptr)->il_head, (pb_ptr)->il_tail, (pb_ptr)->il_len, \ + (pb_ptr)->il_size, fail_val) \ + H5PB__UPDATE_STATS_FOR_HT_INSERTION(pb_ptr) \ + H5PB__UPDATE_HT_SIZE_STATS(pb_ptr) \ + H5PB__POST_HT_INSERT_SC(pb_ptr, entry_ptr, fail_val) \ + } + +#define H5PB__DELETE_FROM_INDEX(pb_ptr, entry_ptr, fail_val) \ + { \ + int k; \ + H5PB__PRE_HT_REMOVE_SC(pb_ptr, entry_ptr) \ + k = H5PB__HASH_FCN((entry_ptr)->page); \ + if ((entry_ptr)->ht_next) \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + if ((entry_ptr)->ht_prev) \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + if (((pb_ptr)->ht)[k] == (entry_ptr)) \ + ((pb_ptr)->ht)[k] = (entry_ptr)->ht_next; \ + (entry_ptr)->ht_next = NULL; \ + (entry_ptr)->ht_prev = NULL; \ + (pb_ptr)->index_len--; \ + (pb_ptr)->index_size -= (int64_t)((entry_ptr)->size); \ + if ((entry_ptr)->is_dirty) { \ + (pb_ptr)->dirty_index_size -= (int64_t)((entry_ptr)->size); \ + } \ + else { \ + (pb_ptr)->clean_index_size -= (int64_t)((entry_ptr)->size); \ + } \ + if ((entry_ptr)->is_metadata) { \ + if ((entry_ptr)->is_mpmde) { \ + ((pb_ptr)->mpmde_count)--; \ + } \ + else { \ + ((pb_ptr)->curr_md_pages)--; \ + (pb_ptr)->curr_pages--; \ + } \ + } \ + else { \ + ((pb_ptr)->curr_rd_pages)--; \ + (pb_ptr)->curr_pages--; \ + } \ + H5PB__IL_DLL_REMOVE((entry_ptr), (pb_ptr)->il_head, (pb_ptr)->il_tail, (pb_ptr)->il_len, \ + (pb_ptr)->il_size, fail_val) \ + H5PB__UPDATE_STATS_FOR_HT_DELETION(pb_ptr) \ + H5PB__POST_HT_REMOVE_SC(pb_ptr, entry_ptr) \ + } + +#define H5PB__SEARCH_INDEX(pb_ptr, Page, entry_ptr, fail_val) \ + { \ + int k; \ + int depth = 0; \ + H5PB__PRE_HT_SEARCH_SC(pb_ptr, Page, fail_val) \ + k = H5PB__HASH_FCN(Page); \ + entry_ptr = ((pb_ptr)->ht)[k]; \ + while (entry_ptr) { \ + if ((Page) == (entry_ptr)->page) { \ + H5PB__POST_SUC_HT_SEARCH_SC(pb_ptr, entry_ptr, k, fail_val) \ + if ((entry_ptr) != ((pb_ptr)->ht)[k]) { \ + if ((entry_ptr)->ht_next) \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + HDassert((entry_ptr)->ht_prev != NULL); \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + ((pb_ptr)->ht)[k]->ht_prev = (entry_ptr); \ + (entry_ptr)->ht_next = ((pb_ptr)->ht)[k]; \ + (entry_ptr)->ht_prev = NULL; \ + ((pb_ptr)->ht)[k] = (entry_ptr); \ + H5PB__POST_HT_SHIFT_TO_FRONT_SC(pb_ptr, entry_ptr, k, fail_val) \ + } \ + break; \ + } \ + (entry_ptr) = (entry_ptr)->ht_next; \ + (depth)++; \ + } \ + H5PB__UPDATE_STATS_FOR_HT_SEARCH(pb_ptr, (entry_ptr != NULL), depth) \ + } + +#define H5PB__UPDATE_INDEX_FOR_ENTRY_CLEAN(pb_ptr, entry_ptr) \ + { \ + H5PB__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr); \ + (pb_ptr)->dirty_index_size -= (int64_t)((entry_ptr)->size); \ + (pb_ptr)->clean_index_size += (int64_t)((entry_ptr)->size); \ + H5PB__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr); \ + } + +#define H5PB__UPDATE_INDEX_FOR_ENTRY_DIRTY(pb_ptr, entry_ptr) \ + { \ + H5PB__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr); \ + (pb_ptr)->clean_index_size -= (int64_t)((entry_ptr)->size); \ + (pb_ptr)->dirty_index_size += (int64_t)((entry_ptr)->size); \ + H5PB__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr); \ + } + +#define H5PB__UPDATE_INDEX_FOR_SIZE_CHANGE(pb_ptr, old_size, new_size, entry_ptr, was_clean) \ + { \ + H5PB__PRE_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, entry_ptr, was_clean) \ + (pb_ptr)->index_size -= (old_size); \ + (pb_ptr)->index_size += (new_size); \ + if (was_clean) { \ + (pb_ptr)->clean_index_size -= (old_size); \ + } \ + else { \ + (pb_ptr)->dirty_index_size -= (old_size); \ + } \ + if ((entry_ptr)->is_dirty) { \ + (pb_ptr)->dirty_index_size += (new_size); \ + } \ + else { \ + (pb_ptr)->clean_index_size += (new_size); \ + } \ + H5PB__DLL_UPDATE_FOR_SIZE_CHANGE((pb_ptr)->il_len, (pb_ptr)->il_size, (old_size), (new_size)) \ + H5PB__POST_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, entry_ptr) \ + } -#define H5PB__INSERT_IN_INDEX(pb_ptr, entry_ptr, fail_val) \ -{ \ - int k; \ - H5PB__PRE_HT_INSERT_SC(pb_ptr, entry_ptr, fail_val) \ - k = H5PB__HASH_FCN((entry_ptr)->page); \ - if(((pb_ptr)->ht)[k] != NULL) { \ - (entry_ptr)->ht_next = ((pb_ptr)->ht)[k]; \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr); \ - } \ - ((pb_ptr)->ht)[k] = (entry_ptr); \ - (pb_ptr)->index_len++; \ - (pb_ptr)->index_size += (int64_t)((entry_ptr)->size); \ - if((entry_ptr)->is_dirty) { \ - (pb_ptr)->dirty_index_size += (int64_t)((entry_ptr)->size); \ - } else { \ - (pb_ptr)->clean_index_size += (int64_t)((entry_ptr)->size); \ - } \ - if ( (entry_ptr)->is_metadata ) { \ - if ( (entry_ptr)->is_mpmde ) { \ - ((pb_ptr)->mpmde_count)++; \ - } else { \ - ((pb_ptr)->curr_md_pages)++; \ - (pb_ptr)->curr_pages++; \ - } \ - } else { \ - ((pb_ptr)->curr_rd_pages)++; \ - (pb_ptr)->curr_pages++; \ - } \ - H5PB__IL_DLL_APPEND((entry_ptr), (pb_ptr)->il_head, \ - (pb_ptr)->il_tail, (pb_ptr)->il_len, \ - (pb_ptr)->il_size, fail_val) \ - H5PB__UPDATE_STATS_FOR_HT_INSERTION(pb_ptr) \ - H5PB__UPDATE_HT_SIZE_STATS(pb_ptr) \ - H5PB__POST_HT_INSERT_SC(pb_ptr, entry_ptr, fail_val) \ -} - -#define H5PB__DELETE_FROM_INDEX(pb_ptr, entry_ptr, fail_val) \ -{ \ - int k; \ - H5PB__PRE_HT_REMOVE_SC(pb_ptr, entry_ptr) \ - k = H5PB__HASH_FCN((entry_ptr)->page); \ - if((entry_ptr)->ht_next) \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - if((entry_ptr)->ht_prev) \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - if(((pb_ptr)->ht)[k] == (entry_ptr)) \ - ((pb_ptr)->ht)[k] = (entry_ptr)->ht_next; \ - (entry_ptr)->ht_next = NULL; \ - (entry_ptr)->ht_prev = NULL; \ - (pb_ptr)->index_len--; \ - (pb_ptr)->index_size -= (int64_t)((entry_ptr)->size); \ - if((entry_ptr)->is_dirty) { \ - (pb_ptr)->dirty_index_size -= (int64_t)((entry_ptr)->size); \ - } else { \ - (pb_ptr)->clean_index_size -= (int64_t)((entry_ptr)->size); \ - } \ - if ( (entry_ptr)->is_metadata ) { \ - if ( (entry_ptr)->is_mpmde ) { \ - ((pb_ptr)->mpmde_count)--; \ - } else { \ - ((pb_ptr)->curr_md_pages)--; \ - (pb_ptr)->curr_pages--; \ - } \ - } else { \ - ((pb_ptr)->curr_rd_pages)--; \ - (pb_ptr)->curr_pages--; \ - } \ - H5PB__IL_DLL_REMOVE((entry_ptr), (pb_ptr)->il_head, \ - (pb_ptr)->il_tail, (pb_ptr)->il_len, \ - (pb_ptr)->il_size, fail_val) \ - H5PB__UPDATE_STATS_FOR_HT_DELETION(pb_ptr) \ - H5PB__POST_HT_REMOVE_SC(pb_ptr, entry_ptr) \ -} - -#define H5PB__SEARCH_INDEX(pb_ptr, Page, entry_ptr, fail_val) \ -{ \ - int k; \ - int depth = 0; \ - H5PB__PRE_HT_SEARCH_SC(pb_ptr, Page, fail_val) \ - k = H5PB__HASH_FCN(Page); \ - entry_ptr = ((pb_ptr)->ht)[k]; \ - while(entry_ptr) { \ - if ( (Page) == (entry_ptr)->page ) { \ - H5PB__POST_SUC_HT_SEARCH_SC(pb_ptr, entry_ptr, k, fail_val) \ - if ( (entry_ptr) != ((pb_ptr)->ht)[k] ) { \ - if ( (entry_ptr)->ht_next ) \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - HDassert((entry_ptr)->ht_prev != NULL); \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - ((pb_ptr)->ht)[k]->ht_prev = (entry_ptr); \ - (entry_ptr)->ht_next = ((pb_ptr)->ht)[k]; \ - (entry_ptr)->ht_prev = NULL; \ - ((pb_ptr)->ht)[k] = (entry_ptr); \ - H5PB__POST_HT_SHIFT_TO_FRONT_SC(pb_ptr, entry_ptr, k, fail_val)\ - } \ - break; \ - } \ - (entry_ptr) = (entry_ptr)->ht_next; \ - (depth)++; \ - } \ - H5PB__UPDATE_STATS_FOR_HT_SEARCH(pb_ptr, (entry_ptr != NULL), depth) \ -} - -#define H5PB__UPDATE_INDEX_FOR_ENTRY_CLEAN(pb_ptr, entry_ptr) \ -{ \ - H5PB__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr); \ - (pb_ptr)->dirty_index_size -= (int64_t)((entry_ptr)->size); \ - (pb_ptr)->clean_index_size += (int64_t)((entry_ptr)->size); \ - H5PB__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(pb_ptr, entry_ptr); \ -} - -#define H5PB__UPDATE_INDEX_FOR_ENTRY_DIRTY(pb_ptr, entry_ptr) \ -{ \ - H5PB__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr); \ - (pb_ptr)->clean_index_size -= (int64_t)((entry_ptr)->size); \ - (pb_ptr)->dirty_index_size += (int64_t)((entry_ptr)->size); \ - H5PB__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(pb_ptr, entry_ptr); \ -} - -#define H5PB__UPDATE_INDEX_FOR_SIZE_CHANGE(pb_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ -{ \ - H5PB__PRE_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ - (pb_ptr)->index_size -= (old_size); \ - (pb_ptr)->index_size += (new_size); \ - if(was_clean) { \ - (pb_ptr)->clean_index_size -= (old_size); \ - } else { \ - (pb_ptr)->dirty_index_size -= (old_size); \ - } \ - if((entry_ptr)->is_dirty) { \ - (pb_ptr)->dirty_index_size += (new_size); \ - } else { \ - (pb_ptr)->clean_index_size += (new_size); \ - } \ - H5PB__DLL_UPDATE_FOR_SIZE_CHANGE((pb_ptr)->il_len, \ - (pb_ptr)->il_size, \ - (old_size), (new_size)) \ - H5PB__POST_HT_ENTRY_SIZE_CHANGE_SC(pb_ptr, old_size, new_size, \ - entry_ptr) \ -} - - /*********************************************************************** * * Replacement policy update macros * - * The following macros handle updates to the replacement policy for + * The following macros handle updates to the replacement policy for * insertions, flushes, and evictions. * * At present, the only replacement policy is a modified LRU policy. @@ -1311,36 +1094,35 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__UPDATE_RP_FOR_EVICTION(pb_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( !((entry_ptr)->is_dirty) ); \ - HDassert( (entry_ptr)->size >= pb_ptr->page_size ); \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5PB__DLL_REMOVE((entry_ptr), (pb_ptr)->LRU_head_ptr, \ - (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ - (pb_ptr)->LRU_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - \ -} /* H5PB__UPDATE_RP_FOR_EVICTION */ +#define H5PB__UPDATE_RP_FOR_EVICTION(pb_ptr, entry_ptr, fail_val) \ + { \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert(!((entry_ptr)->is_dirty)); \ + HDassert((entry_ptr)->size >= pb_ptr->page_size); \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5PB__DLL_REMOVE((entry_ptr), (pb_ptr)->LRU_head_ptr, (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ + (pb_ptr)->LRU_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + \ + } /* H5PB__UPDATE_RP_FOR_EVICTION */ /*------------------------------------------------------------------------- * * Macro: H5PB__UPDATE_RP_FOR_REMOVE * * Purpose: Update the replacement policy data structures for the - * removal of the specified page buffer entry from the - * replacement policy, but not from the page buffer. + * removal of the specified page buffer entry from the + * replacement policy, but not from the page buffer. * - * At present, this this only happens when an entry is + * At present, this this only happens when an entry is * dirtied, and subject to a delayed write. * * At present, we only support the modified LRU policy, so @@ -1359,28 +1141,26 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__UPDATE_RP_FOR_REMOVE(pb_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( ! ((entry_ptr)->is_mpmde) ); \ - HDassert( (entry_ptr)->size == pb_ptr->page_size ); \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5PB__DLL_REMOVE((entry_ptr), (pb_ptr)->LRU_head_ptr, \ - (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ - (pb_ptr)->LRU_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - \ -} /* H5PB__UPDATE_RP_FOR_EVICTION */ - - +#define H5PB__UPDATE_RP_FOR_REMOVE(pb_ptr, entry_ptr, fail_val) \ + { \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert(!((entry_ptr)->is_mpmde)); \ + HDassert((entry_ptr)->size == pb_ptr->page_size); \ + \ + /* modified LRU specific code */ \ + \ + /* remove the entry from the LRU list. */ \ + \ + H5PB__DLL_REMOVE((entry_ptr), (pb_ptr)->LRU_head_ptr, (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ + (pb_ptr)->LRU_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + \ + } /* H5PB__UPDATE_RP_FOR_EVICTION */ + /*------------------------------------------------------------------------- * * Macro: H5PB__UPDATE_RP_FOR_ACCESS @@ -1404,31 +1184,28 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( (entry_ptr)->size >= pb_ptr->page_size ); \ - \ - /* modified LRU specific code */ \ - \ - /* Move entry to the head of the LRU */ \ - \ - H5PB__DLL_REMOVE((entry_ptr), (pb_ptr)->LRU_head_ptr, \ - (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ - (pb_ptr)->LRU_size, (fail_val)) \ - \ - H5PB__DLL_PREPEND((entry_ptr), (pb_ptr)->LRU_head_ptr, \ - (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ - (pb_ptr)->LRU_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - \ -} /* H5PB__UPDATE_RP_FOR_ACCESS */ - - +#define H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, fail_val) \ + { \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert((entry_ptr)->size >= pb_ptr->page_size); \ + \ + /* modified LRU specific code */ \ + \ + /* Move entry to the head of the LRU */ \ + \ + H5PB__DLL_REMOVE((entry_ptr), (pb_ptr)->LRU_head_ptr, (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ + (pb_ptr)->LRU_size, (fail_val)) \ + \ + H5PB__DLL_PREPEND((entry_ptr), (pb_ptr)->LRU_head_ptr, (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ + (pb_ptr)->LRU_size, (fail_val)) \ + \ + /* End modified LRU specific code. */ \ + \ + } /* H5PB__UPDATE_RP_FOR_ACCESS */ + /*------------------------------------------------------------------------- * * Macro: H5PB__UPDATE_RP_FOR_FLUSH @@ -1452,23 +1229,22 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__UPDATE_RP_FOR_FLUSH(pb_ptr, entry_ptr, fail_val) \ -{ \ - H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, fail_val) \ - \ -} /* H5PB__UPDATE_RP_FOR_FLUSH */ +#define H5PB__UPDATE_RP_FOR_FLUSH(pb_ptr, entry_ptr, fail_val) \ + { \ + H5PB__UPDATE_RP_FOR_ACCESS(pb_ptr, entry_ptr, fail_val) \ + \ + } /* H5PB__UPDATE_RP_FOR_FLUSH */ - /*------------------------------------------------------------------------- * * Macro: H5PB__UPDATE_RP_FOR_INSERT_APPEND * * Purpose: Update the replacement policy data structures for an - * insertion of the specified cache entry. + * insertion of the specified cache entry. * - * Unlike H5PB__UPDATE_RP_FOR_INSERTION below, mark the - * new entry as the LEAST recently used entry, not the - * most recently used. + * Unlike H5PB__UPDATE_RP_FOR_INSERTION below, mark the + * new entry as the LEAST recently used entry, not the + * most recently used. * * At present, we only support the modified LRU policy, so * this function deals with that case unconditionally. If @@ -1486,28 +1262,26 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__UPDATE_RP_FOR_INSERT_APPEND(pb_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( (entry_ptr)->size == pb_ptr->page_size ); \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the tail of the LRU list. */ \ - \ - H5PB__DLL_APPEND((entry_ptr), (pb_ptr)->LRU_head_ptr, \ - (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ - (pb_ptr)->LRU_size, (fail_val)) \ - \ - H5PB__UPDATE_LRU_SIZE_STATS(pb_ptr) \ - \ - /* End modified LRU specific code. */ \ -} - - +#define H5PB__UPDATE_RP_FOR_INSERT_APPEND(pb_ptr, entry_ptr, fail_val) \ + { \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert((entry_ptr)->size == pb_ptr->page_size); \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the tail of the LRU list. */ \ + \ + H5PB__DLL_APPEND((entry_ptr), (pb_ptr)->LRU_head_ptr, (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ + (pb_ptr)->LRU_size, (fail_val)) \ + \ + H5PB__UPDATE_LRU_SIZE_STATS(pb_ptr) \ + \ + /* End modified LRU specific code. */ \ + } + /*------------------------------------------------------------------------- * * Macro: H5PB__UPDATE_RP_FOR_INSERTION @@ -1531,41 +1305,39 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__UPDATE_RP_FOR_INSERTION(pb_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( (entry_ptr)->size >= pb_ptr->page_size ); \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5PB__DLL_PREPEND((entry_ptr), (pb_ptr)->LRU_head_ptr, \ - (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ - (pb_ptr)->LRU_size, (fail_val)) \ - \ - H5PB__UPDATE_LRU_SIZE_STATS(pb_ptr) \ - \ - /* End modified LRU specific code. */ \ -} - - +#define H5PB__UPDATE_RP_FOR_INSERTION(pb_ptr, entry_ptr, fail_val) \ + { \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert((entry_ptr)->size >= pb_ptr->page_size); \ + \ + /* modified LRU specific code */ \ + \ + /* insert the entry at the head of the LRU list. */ \ + \ + H5PB__DLL_PREPEND((entry_ptr), (pb_ptr)->LRU_head_ptr, (pb_ptr)->LRU_tail_ptr, (pb_ptr)->LRU_len, \ + (pb_ptr)->LRU_size, (fail_val)) \ + \ + H5PB__UPDATE_LRU_SIZE_STATS(pb_ptr) \ + \ + /* End modified LRU specific code. */ \ + } + /*********************************************************************** * * Tick list management macros * - * When the target file is opened in VFD SWMR writer mode, the page - * buffer must retain copies of all metadata writes during each tick so - * that the metadata file can be updated correctly in end of tick + * When the target file is opened in VFD SWMR writer mode, the page + * buffer must retain copies of all metadata writes during each tick so + * that the metadata file can be updated correctly in end of tick * processing. * - * Once tick processing is complete, all entries are removed from the - * tick list, to leave it empty for the next tick. Metadata pages from + * Once tick processing is complete, all entries are removed from the + * tick list, to leave it empty for the next tick. Metadata pages from * the tick list are already in the replacement policy, and thus require - * no further action. + * no further action. * * Multi-page metadata entries are evicted from the page buffer if they * are not subject to delayed write, or left in the delayed write list @@ -1581,7 +1353,7 @@ if ( ( (pb_ptr)->index_size != \ * * Macro: H5PB__INSERT_IN_TL * - * Purpose: Insert the specified page buffer entry at the head of the + * Purpose: Insert the specified page buffer entry at the head of the * tick list. * * Return: N/A @@ -1595,27 +1367,25 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__INSERT_IN_TL(pb_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (pb_ptr)->vfd_swmr_writer ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( (entry_ptr)->modified_this_tick ); \ - HDassert( (entry_ptr)->size >= pb_ptr->page_size ); \ - \ - /* insert the entry at the head of the tick list. */ \ - \ - H5PB__TL_DLL_PREPEND((entry_ptr), (pb_ptr)->tl_head_ptr, \ - (pb_ptr)->tl_tail_ptr, (pb_ptr)->tl_len, \ - (pb_ptr)->tl_size, (fail_val)) \ - \ - H5PB__UPDATE_TL_SIZE_STATS(pb_ptr) \ - \ -} /* H5PB__INSERT_IN_TL */ - - +#define H5PB__INSERT_IN_TL(pb_ptr, entry_ptr, fail_val) \ + { \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((pb_ptr)->vfd_swmr_writer); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert((entry_ptr)->modified_this_tick); \ + HDassert((entry_ptr)->size >= pb_ptr->page_size); \ + \ + /* insert the entry at the head of the tick list. */ \ + \ + H5PB__TL_DLL_PREPEND((entry_ptr), (pb_ptr)->tl_head_ptr, (pb_ptr)->tl_tail_ptr, (pb_ptr)->tl_len, \ + (pb_ptr)->tl_size, (fail_val)) \ + \ + H5PB__UPDATE_TL_SIZE_STATS(pb_ptr) \ + \ + } /* H5PB__INSERT_IN_TL */ + /*------------------------------------------------------------------------- * * Macro: H5PB__REMOVE_FROM_TL @@ -1633,49 +1403,46 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__REMOVE_FROM_TL(pb_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (pb_ptr)->vfd_swmr_writer ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( (entry_ptr)->modified_this_tick ); \ - HDassert( (entry_ptr)->size >= pb_ptr->page_size ); \ - \ - /* remove the entry from the tick list. */ \ - \ - H5PB__TL_DLL_REMOVE((entry_ptr), (pb_ptr)->tl_head_ptr, \ - (pb_ptr)->tl_tail_ptr, (pb_ptr)->tl_len, \ - (pb_ptr)->tl_size, (fail_val)) \ - \ - \ -} /* H5PB__REMOVE_FROM_TL */ - - +#define H5PB__REMOVE_FROM_TL(pb_ptr, entry_ptr, fail_val) \ + { \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((pb_ptr)->vfd_swmr_writer); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert((entry_ptr)->modified_this_tick); \ + HDassert((entry_ptr)->size >= pb_ptr->page_size); \ + \ + /* remove the entry from the tick list. */ \ + \ + H5PB__TL_DLL_REMOVE((entry_ptr), (pb_ptr)->tl_head_ptr, (pb_ptr)->tl_tail_ptr, (pb_ptr)->tl_len, \ + (pb_ptr)->tl_size, (fail_val)) \ + \ + } /* H5PB__REMOVE_FROM_TL */ + /*********************************************************************** * * Delayed write list management macros * - * When the target file is opened in VFD SWMR writer mode, the page - * buffer must delay flush of all metadata pages and multi-page metadata + * When the target file is opened in VFD SWMR writer mode, the page + * buffer must delay flush of all metadata pages and multi-page metadata * entries that: * * 1) have not appeared in the metadata file index for at least max_lag * ticks, and * - * 2) a previous version of the metadata page or multi-page metadata + * 2) a previous version of the metadata page or multi-page metadata * cache entry exists in the file. * - * Failure to do so can result in VFD SWMR readers to receive messages + * Failure to do so can result in VFD SWMR readers to receive messages * from the future. * * To minimize overhead, the delayed write list is sorted in decreasing * values of the constituent delay_write_until fields. * - * Entries are removed from the delayed write list when their + * Entries are removed from the delayed write list when their * delay_write_until fields are satisfied. Metadata pages are inserted - * at the bottom of the replacement policy, and multi-page metadata + * at the bottom of the replacement policy, and multi-page metadata * entries are immediately flushed and evicted. * * The macros required to support this are defined below. @@ -1688,7 +1455,7 @@ if ( ( (pb_ptr)->index_size != \ * * Macro: H5PB__INSERT_IN_DWL * - * Insert the supplied page buffer entry in the delayed write list + * Insert the supplied page buffer entry in the delayed write list * maintaining the invarient: * * entry_ptr->next == NULL || @@ -1707,44 +1474,39 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__INSERT_IN_DWL(pb_ptr, entry_ptr, fail_val) \ -{ \ - int insertion_depth = 0; \ - uint64_t delay; \ - H5PB_entry_t * suc_ptr; \ - \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (pb_ptr)->vfd_swmr_writer ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( (entry_ptr)->size >= pb_ptr->page_size ); \ - HDassert( (entry_ptr)->delay_write_until > (pb_ptr)->cur_tick ); \ - \ - delay = (entry_ptr)->delay_write_until - (pb_ptr)->cur_tick; \ - suc_ptr = pb_ptr->dwl_head_ptr; \ - \ - while ( (suc_ptr) && \ - ((suc_ptr)->delay_write_until > (entry_ptr)->delay_write_until) ) \ - { \ - insertion_depth++; \ - suc_ptr = suc_ptr->next; \ - } \ - \ - H5PB__DLL_INSERT_BEFORE((entry_ptr), (suc_ptr), \ - (pb_ptr)->dwl_head_ptr, \ - (pb_ptr)->dwl_tail_ptr, (pb_ptr)->dwl_len, \ - (pb_ptr)->dwl_size, (fail_val)) \ - \ - if ( entry_ptr->delay_write_until > pb_ptr->max_delay ) \ - pb_ptr->max_delay = entry_ptr->delay_write_until; \ - \ - H5PB__UPDATE_DWL_SIZE_STATS(pb_ptr) \ - H5PB__UPDATE_DWL_DELAYED_WRITES(pb_ptr, insertion_depth, delay) \ - \ -} /* H5PB__INSERT_IN_DWL */ - - +#define H5PB__INSERT_IN_DWL(pb_ptr, entry_ptr, fail_val) \ + { \ + int insertion_depth = 0; \ + uint64_t delay; \ + H5PB_entry_t *suc_ptr; \ + \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((pb_ptr)->vfd_swmr_writer); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert((entry_ptr)->size >= pb_ptr->page_size); \ + HDassert((entry_ptr)->delay_write_until > (pb_ptr)->cur_tick); \ + \ + delay = (entry_ptr)->delay_write_until - (pb_ptr)->cur_tick; \ + suc_ptr = pb_ptr->dwl_head_ptr; \ + \ + while ((suc_ptr) && ((suc_ptr)->delay_write_until > (entry_ptr)->delay_write_until)) { \ + insertion_depth++; \ + suc_ptr = suc_ptr->next; \ + } \ + \ + H5PB__DLL_INSERT_BEFORE((entry_ptr), (suc_ptr), (pb_ptr)->dwl_head_ptr, (pb_ptr)->dwl_tail_ptr, \ + (pb_ptr)->dwl_len, (pb_ptr)->dwl_size, (fail_val)) \ + \ + if (entry_ptr->delay_write_until > pb_ptr->max_delay) \ + pb_ptr->max_delay = entry_ptr->delay_write_until; \ + \ + H5PB__UPDATE_DWL_SIZE_STATS(pb_ptr) \ + H5PB__UPDATE_DWL_DELAYED_WRITES(pb_ptr, insertion_depth, delay) \ + \ + } /* H5PB__INSERT_IN_DWL */ + /*------------------------------------------------------------------------- * * Macro: H5PB__REMOVE_FROM_DWL @@ -1763,26 +1525,23 @@ if ( ( (pb_ptr)->index_size != \ *------------------------------------------------------------------------- */ -#define H5PB__REMOVE_FROM_DWL(pb_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (pb_ptr) ); \ - HDassert( (pb_ptr)->magic == H5PB__H5PB_T_MAGIC ); \ - HDassert( (pb_ptr)->vfd_swmr_writer ); \ - HDassert( (entry_ptr) ); \ - HDassert( (entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC ); \ - HDassert( (entry_ptr)->size >= pb_ptr->page_size ); \ - HDassert( (entry_ptr)->delay_write_until == 0 ); \ - \ - /* remove the entry from the delayed write list. */ \ - \ - H5PB__DLL_REMOVE((entry_ptr), (pb_ptr)->dwl_head_ptr, \ - (pb_ptr)->dwl_tail_ptr, (pb_ptr)->dwl_len, \ - (pb_ptr)->dwl_size, (fail_val)) \ - \ - \ -} /* H5PB__REMOVE_FROM_DWLL */ - - +#define H5PB__REMOVE_FROM_DWL(pb_ptr, entry_ptr, fail_val) \ + { \ + HDassert((pb_ptr)); \ + HDassert((pb_ptr)->magic == H5PB__H5PB_T_MAGIC); \ + HDassert((pb_ptr)->vfd_swmr_writer); \ + HDassert((entry_ptr)); \ + HDassert((entry_ptr)->magic == H5PB__H5PB_ENTRY_T_MAGIC); \ + HDassert((entry_ptr)->size >= pb_ptr->page_size); \ + HDassert((entry_ptr)->delay_write_until == 0); \ + \ + /* remove the entry from the delayed write list. */ \ + \ + H5PB__DLL_REMOVE((entry_ptr), (pb_ptr)->dwl_head_ptr, (pb_ptr)->dwl_tail_ptr, (pb_ptr)->dwl_len, \ + (pb_ptr)->dwl_size, (fail_val)) \ + \ + } /* H5PB__REMOVE_FROM_DWLL */ + /****************************/ /* Package Private Typedefs */ /****************************/ @@ -1791,8 +1550,8 @@ if ( ( (pb_ptr)->index_size != \ * * structure H5PB_entry_t * - * Individual instances of the H5PB_entry_t structure are used to manage - * individual pages in the page buffer. In the case of a VFD SWMR writer, + * Individual instances of the H5PB_entry_t structure are used to manage + * individual pages in the page buffer. In the case of a VFD SWMR writer, * they are also used to manage multi-page metadata entries. * * The fields of this structure are discussed below: @@ -1811,8 +1570,8 @@ if ( ( (pb_ptr)->index_size != \ * * size: Size of the page buffer entry in bytes. Under normal * circumstance, this will always be equal to pb_ptr->page_size. - * However, in the context of a VFD SWMR writer, the page - * buffer may be used to store multi-page metadata entries + * However, in the context of a VFD SWMR writer, the page + * buffer may be used to store multi-page metadata entries * until the end of tick, or to delay writes of such entries * for up to max_lag ticks. * @@ -1823,21 +1582,21 @@ if ( ( (pb_ptr)->index_size != \ * on disk image of the page. In the context of VFD SWMR, * it points to the image of the multi-page metadata entry. * - * mem_type: Type (H5F_mem_t) of the page buffer entry. This value + * mem_type: Type (H5F_mem_t) of the page buffer entry. This value * is needed when reading or writing the entry from/to file. * - * is_metadata: Boolean flag that is set to TRUE iff the associated + * is_metadata: Boolean flag that is set to TRUE iff the associated * entry is a page of metadata (or, in the context of VFD * SWMR, a multi-page metadata entry). * * is_dirty: Boolean flag indicating whether the contents of the page - * buffer entry has been modified since the last time it + * buffer entry has been modified since the last time it * was written to disk. * * * Fields supporting the hash table: * - * Entries in the page buffer are indexed by a more or less conventional + * Entries in the page buffer are indexed by a more or less conventional * hash table with chaining (see header comment on H5PB_t for futher details). * If there are multiple entries in any hash bin, they are stored in a doubly * linked list. @@ -1872,21 +1631,21 @@ if ( ( (pb_ptr)->index_size != \ * necessary for this structure to contain fields supporting that policy. * * At present, only a modified LRU replacement policy is contemplated, - * (see header comment for H5PB_t for details), for which the following + * (see header comment for H5PB_t for details), for which the following * fields are adequate. * - * next: Next pointer in either the LRU, or (in the context of + * next: Next pointer in either the LRU, or (in the context of * VFD SWMR) the delayed write list. If there is no next entry * on the list, this field should be set to NULL. * - * prev: Prev pointer in either the LRU, or (in the context of + * prev: Prev pointer in either the LRU, or (in the context of * VFD SWMR) the delayed write list. If there is no previous * entry on the list, this field should be set to NULL. * * Fields supporting VFD SWMR: * - * is_mpmde: Boolean flag that is set to TRUE iff the entry - * is a multi-page metadata entry. In the absense of VFD + * is_mpmde: Boolean flag that is set to TRUE iff the entry + * is a multi-page metadata entry. In the absense of VFD * SWMR, the field should always be set to FALSE. * * Observe that: @@ -1894,66 +1653,65 @@ if ( ( (pb_ptr)->index_size != \ * is_mpmde <==> is_metadata && size > pb_ptr->page_size * * loaded: Boolean flag that is set to TRUE iff the entry was loaded - * from file. This is a necessary input in determining + * from file. This is a necessary input in determining * whether the write of the entry must be delayed. * - * This field is only maintained in the VFD SWMR case + * This field is only maintained in the VFD SWMR case * and should be false otherwise. * * modified_this_tick: This field is set to TRUE iff pb_ptr->vfd_swrm_write - * and the entry has been modified in the current tick. If + * and the entry has been modified in the current tick. If * modified_this_tick is TRUE, the entry must also be in the * tick list. * - * delay_write_until: Unsigned 64 bit integer containing the first tick + * delay_write_until: Unsigned 64 bit integer containing the first tick * in which the entry may be written to file, or 0 if there * is no such constraint. It should be set ot 0 when VFD * is not enabled. * * tl_next: Next pointer on the list of entries modified in the current - * tick, If the enty is not on the tick list, or if there is + * tick, If the enty is not on the tick list, or if there is * no next entry on the list, this field should be set to NULL. * * tl_prev: Prev pointer on the list of entries modified in the current - * tick, If the enty is not on the tick list, or if there is - * no previous entry on the list, this field should be set to + * tick, If the enty is not on the tick list, or if there is + * no previous entry on the list, this field should be set to * NULL. * ****************************************************************************/ -#define H5PB__H5PB_ENTRY_T_MAGIC 0x02030405 +#define H5PB__H5PB_ENTRY_T_MAGIC 0x02030405 struct H5PB_entry_t { - uint32_t magic; - H5PB_t *pb_ptr; - haddr_t addr; - uint64_t page; - size_t size; - void *image_ptr; - H5FD_mem_t mem_type; - hbool_t is_metadata; - hbool_t is_dirty; + uint32_t magic; + H5PB_t * pb_ptr; + haddr_t addr; + uint64_t page; + size_t size; + void * image_ptr; + H5FD_mem_t mem_type; + hbool_t is_metadata; + hbool_t is_dirty; /* fields supporting the hash table: */ - struct H5PB_entry_t *ht_next; - struct H5PB_entry_t *ht_prev; - struct H5PB_entry_t *il_next; - struct H5PB_entry_t *il_prev; + struct H5PB_entry_t *ht_next; + struct H5PB_entry_t *ht_prev; + struct H5PB_entry_t *il_next; + struct H5PB_entry_t *il_prev; /* fields supporting replacement policies: */ - struct H5PB_entry_t *next; - struct H5PB_entry_t *prev; + struct H5PB_entry_t *next; + struct H5PB_entry_t *prev; /* fields supporting VFD SWMR */ - hbool_t is_mpmde; - hbool_t loaded; - hbool_t modified_this_tick; - uint64_t delay_write_until; - struct H5PB_entry_t *tl_next; - struct H5PB_entry_t *tl_prev; - + hbool_t is_mpmde; + hbool_t loaded; + hbool_t modified_this_tick; + uint64_t delay_write_until; + struct H5PB_entry_t *tl_next; + struct H5PB_entry_t *tl_prev; + }; /* H5PB_entry_t */ #endif /* _H5PBpkg_H */ - diff --git a/src/H5PBprivate.h b/src/H5PBprivate.h index 97de7ae..62d971e 100644 --- a/src/H5PBprivate.h +++ b/src/H5PBprivate.h @@ -15,7 +15,7 @@ * File: H5PBprivate.h * * Purpose: This file contains declarations which are normally visible - * within the HDF5 library, but are not visible at the user + * within the HDF5 library, but are not visible at the user * level * * Programmer: John Mainzer -- 10/07/18 @@ -28,17 +28,14 @@ /* no H5PBpublic.h at present */ - /* Private headers needed by this header */ -#include "H5private.h" /* Generic Functions */ - +#include "H5private.h" /* Generic Functions */ /**************************/ /* Library Private Macros */ /**************************/ -#define H5PB__HASH_TABLE_LEN 4096 /* must be a power of 2 */ - +#define H5PB__HASH_TABLE_LEN 4096 /* must be a power of 2 */ /****************************/ /* Library Private Typedefs */ @@ -47,97 +44,95 @@ /* Typedef for the page buffer entry structure (defined in H5PBpkg.h) */ typedef struct H5PB_entry_t H5PB_entry_t; - - /****************************************************************************** - * + * * structure H5PB_t * - * Catchall structure for all variables specific to an instance of the page + * Catchall structure for all variables specific to an instance of the page * buffer. * * At present, the page buffer serves two purposes in the HDF5 library. * * Under normal operating conditions, it serves as a normal page buffer whose - * purpose is to minimize and optimize file I/O by aggregating small metadata + * purpose is to minimize and optimize file I/O by aggregating small metadata * and raw data writes into pages, and by caching frequently used pages. * - * In addition, when a file is opened for VFD SWMR writing, the page buffer is + * In addition, when a file is opened for VFD SWMR writing, the page buffer is * used to retain copies of all metadata pages and multi-page metadata entries - * that are written in a given tick, and under certain cases, to delay metadata - * page and/or multi-page metadata entry writes for some number of ticks. - * If the entry has not appeared in the VFD SWMR index for at least max_lag - * ticks, this is necessary to avoid message from the future bugs. See the + * that are written in a given tick, and under certain cases, to delay metadata + * page and/or multi-page metadata entry writes for some number of ticks. + * If the entry has not appeared in the VFD SWMR index for at least max_lag + * ticks, this is necessary to avoid message from the future bugs. See the * VFD SWMR RFC for further details. * - * To reflect this, the fields of this structure are divided into three - * sections. Specifically fields needed for general operations, fields needed + * To reflect this, the fields of this structure are divided into three + * sections. Specifically fields needed for general operations, fields needed * for VFD SWMR, and statistics. * * FIELDS FOR GENERAL OPERATIONS: * - * magic: Unsigned 32 bit integer that must always be set to - * H5PB__H5PB_T_MAGIC. This field is used to validate pointers to + * magic: Unsigned 32 bit integer that must always be set to + * H5PB__H5PB_T_MAGIC. This field is used to validate pointers to * instances of H5PB_t. * * page_size: size_t containing the page buffer page size in bytes. * - * max_pages: 64 bit integer containing the nominal maximum number - * of pages in the page buffer. Note that on creation, the page + * max_pages: 64 bit integer containing the nominal maximum number + * of pages in the page buffer. Note that on creation, the page * buffer is empty, and that under certain circumstances (mostly - * related to VFD SWMR) this limit can be exceeded by large + * related to VFD SWMR) this limit can be exceeded by large * amounts. - * + * * curr_pages: 64 bit integer containing the current number of pages - * in the page buffer. curr_pages must always equal the sum of + * in the page buffer. curr_pages must always equal the sum of * curr_md_pages + curr_rd_pages. * - * Note that in the context of VFD SWMR, this count does NOT + * Note that in the context of VFD SWMR, this count does NOT * include multi-page metadata entries. * - * curr_md_pages: 64 bit integer containing the current number of + * curr_md_pages: 64 bit integer containing the current number of * metadata pages in the page buffer. * - * Note that in the context of VFD SWMR, this count does NOT + * Note that in the context of VFD SWMR, this count does NOT * include multi-page metadata entries. * - * curr_rd_pages: 64 bit integer containing the current number of + * curr_rd_pages: 64 bit integer containing the current number of * raw data pages in the page buffer. - * - * min_md_pages: 64 bit integer containing the number of pages in the - * page buffer reserved for metadata. No metadata page may be + * + * min_md_pages: 64 bit integer containing the number of pages in the + * page buffer reserved for metadata. No metadata page may be * evicted from the page buffer if curr_md_pages is less than or * equal to this value. - * - * min_rd_pages: 64 bin integer containing the number of pages in the - * page buffer reserved for raw data. No page or raw data may be + * + * min_rd_pages: 64 bin integer containing the number of pages in the + * page buffer reserved for raw data. No page or raw data may be * evicted from the page buffer if curr_rd_pages is less than or * equal to this value. * - * The FAPL fields are used to store the page buffer configuration data + * The FAPL fields are used to store the page buffer configuration data * provided to the page buffer in the H5PB_create() call. * * max_size: Maximum page buffer size supplied by the FAPL. * - * min_meta_perc: Percent of the page buffer reserved for metadata as + * min_meta_perc: Percent of the page buffer reserved for metadata as * supplied in the FAPL. * - * min_raw_perc: Percent of the page buffer reserved for metadata as + * min_raw_perc: Percent of the page buffer reserved for metadata as * supplied in the FAPL. * * The purpose of the index is to allow us to efficiently look up all pages - * (and multi-page metadata entries in the context of VFD SWMR) in the - * page buffer. - * - * This function is provided by a hash table with chaining, albeit with one + * (and multi-page metadata entries in the context of VFD SWMR) in the + * page buffer. + * + * This function is provided by a hash table with chaining, albeit with one * un-unusual feature. * * Specifically hash table size must be a power of two, and the hash function * simply clips the high order bits off the page offset of the entry. - * - * This should work, as space is typically allocated sequentually, and thus - * via a reverse principle of locality argument, hot pages are unlikely to - * hash to the same bucket. That said, we must collect statistics to alert + * + * This should work, as space is typically allocated sequentually, and thus + * via a reverse principle of locality argument, hot pages are unlikely to + * hash to the same bucket. That said, we must collect statistics to alert * us should this not be the case. * * We also maintain a linked list of all entries in the index to facilitate @@ -151,25 +146,25 @@ typedef struct H5PB_entry_t H5PB_entry_t; * the page buffer. index_len should always equal * clean_index_len + dirty_index_len. * - * clean_index_len: Number of clean entries currently in the hash table + * clean_index_len: Number of clean entries currently in the hash table * used to index the page buffer. * - * dirty_index_len: Number of dirty entries currently in the hash table + * dirty_index_len: Number of dirty entries currently in the hash table * used to index the page buffer. * - * index_size: Number of bytes currently stored in the hash table used to - * index the page buffer. Under normal circumstances, this + * index_size: Number of bytes currently stored in the hash table used to + * index the page buffer. Under normal circumstances, this * value will be index_len * page size. However, if * vfd_swmr_writer is TRUE, it may be larger. * - * index_size should always equal clean_index_size + + * index_size should always equal clean_index_size + * dirty_index_size. * - * clean_index_size: Number of bytes of clean entries currently stored in - * the hash table used to index the page buffer. + * clean_index_size: Number of bytes of clean entries currently stored in + * the hash table used to index the page buffer. * - * dirty_index_size: Number of bytes of dirty entries currently stored in - * the hash table used to index the page buffer. + * dirty_index_size: Number of bytes of dirty entries currently stored in + * the hash table used to index the page buffer. * * il_len: Number of entries on the index list. * @@ -206,16 +201,16 @@ typedef struct H5PB_entry_t H5PB_entry_t; * See most any OS text for a discussion of the LRU replacement policy. * * Under normal operating circumstances (i.e. vfd_swmr_writer is FALSE) - * all entries will reside both in the index and in the LRU. Further, - * all entries will be of size page_size. + * all entries will reside both in the index and in the LRU. Further, + * all entries will be of size page_size. * * The VFD SWMR writer case (i.e. vfd_swmr_writer is TRUE) is complicated * by the requirements that we: * * 1) buffer all metadat writes (including multi-page metadata writes) that - * occur during a tick, and + * occur during a tick, and * - * 2) when necessary, delay metadata writes for up to max_lag ticks to + * 2) when necessary, delay metadata writes for up to max_lag ticks to * avoid message from the future bugs on the VFD SWMR readers. * * See discussion of fields supporting VFD SWMR below for details. @@ -225,23 +220,23 @@ typedef struct H5PB_entry_t H5PB_entry_t; * * LRU_len: Number of page buffer entries currently on the LRU. * - * Observe that LRU_len + dwl_len must always equal + * Observe that LRU_len + dwl_len must always equal * index_len. * - * LRU_size: Number of bytes of page buffer entries currently residing + * LRU_size: Number of bytes of page buffer entries currently residing * on the LRU list. * - * Observe that LRU_size + dwl_size must always equal - * index_size. + * Observe that LRU_size + dwl_size must always equal + * index_size. * * LRU_head_ptr: Pointer to the head of the doubly linked LRU list. Page - * buffer entries on this list are linked by their next and + * buffer entries on this list are linked by their next and * prev fields. * * This field is NULL if the list is empty. * - * LRU_tail_ptr: Pointer to the tail of the doubly linked LRU list. Page - * buffer entries on this list are linked by their next and + * LRU_tail_ptr: Pointer to the tail of the doubly linked LRU list. Page + * buffer entries on this list are linked by their next and * prev fields. * * This field is NULL if the list is empty. @@ -249,23 +244,23 @@ typedef struct H5PB_entry_t H5PB_entry_t; * * FIELDS SUPPORTING VFD SWMR: * - * If the file is opened in VFD SWMR mode (i.e. vfd_swmr == TRUE), all + * If the file is opened in VFD SWMR mode (i.e. vfd_swmr == TRUE), all * raw data I/O must be passed through to the HDF5 file * * If the file is opened as a VFD SWMR writer (i.e. vfd_swmr_writer == TRUE), - * the page buffer must retain the data necessary to update the metadata - * file at the end of each tick, and also delay writes as necessary so as + * the page buffer must retain the data necessary to update the metadata + * file at the end of each tick, and also delay writes as necessary so as * to avoid message from the future bugs on the VFD SWMR readers. * * The tick list exists to allow us to buffer copies of all metadata writes - * during a tick, and the delayed write list supports delayed writes. + * during a tick, and the delayed write list supports delayed writes. * * If a regular page is written to during a tick, it is placed on the tick - * list. If there is no reason to delay its write to file (i.e. either - * it was just allocated, or it has existed in the metadata file index for - * at least max_lag ticks), it is also placed on the LRU, where it may be + * list. If there is no reason to delay its write to file (i.e. either + * it was just allocated, or it has existed in the metadata file index for + * at least max_lag ticks), it is also placed on the LRU, where it may be * flushed, but not evicted. If its write must be delayed, it is placed on - * the delayed write list, where it must remain until its write delay is + * the delayed write list, where it must remain until its write delay is * satisfied -- at which point it is moved to the LRU. * * If a multi-page metadata entry is written during a tick, it is placed on @@ -281,38 +276,38 @@ typedef struct H5PB_entry_t H5PB_entry_t; * Multi-page metadata entries that are not also on the delayed write list * are simply flushed and evicted. * - * The delayed write list is also scanned at the end of each tick. Regular + * The delayed write list is also scanned at the end of each tick. Regular * entries that are now flushable are placed at the head of the LRU. Multi- * page metadata entries that are flushable are flushed and evicted. * - * The remainder of this sections contains discussions of the fields and + * The remainder of this sections contains discussions of the fields and * data structures used to support the above operations. * * vfd_swmr: Boolean flag that is set to TRUE IFF the file is opened * in VFD SWMR mode -- either reader or writer. This field * is used to exclude raw data from the page buffer. * - * vfd_swmr_writer: Boolean flag that is set to TRUE iff the file is - * is opened in VFD SWMR writer mode. The remaining + * vfd_swmr_writer: Boolean flag that is set to TRUE iff the file is + * is opened in VFD SWMR writer mode. The remaining * VFD SWMR fields are defined iff vfd_swmr_writer is TRUE. * - * mpmde_count: int64_t containing the number of multi-page metadata - * entries currently resident in the page buffer. Observe + * mpmde_count: int64_t containing the number of multi-page metadata + * entries currently resident in the page buffer. Observe * that index_len should always equal curr_pages + mpmde_count. * - * cur_tick: uint64_t containing the current tick. This is a copy of + * cur_tick: uint64_t containing the current tick. This is a copy of * the same field in the associated instance of H5F_file_t, * and is maintained as a convenience. * - * In the context of VFD SWMR the delayed write list allows us to delay + * In the context of VFD SWMR the delayed write list allows us to delay * metadata writes to the HDF5 file until it appears in all indexes in the - * last max_lag ticks. This is essential if a version of the page or - * multi-page metadata entry already exists in the HDF5 file -- failure to - * delay the write can result in a message from the future which will + * last max_lag ticks. This is essential if a version of the page or + * multi-page metadata entry already exists in the HDF5 file -- failure to + * delay the write can result in a message from the future which will * likely be perciived as file corruption by the reader. * - * To facilitate identification of entries that must be removed from the - * DWL during the end of tick scan, the list always observes the following + * To facilitate identification of entries that must be removed from the + * DWL during the end of tick scan, the list always observes the following * invarient for any entry on the list: * * entry_ptr->next == NULL || @@ -320,31 +315,31 @@ typedef struct H5PB_entry_t H5PB_entry_t; * * Discussion of the fields used to implement the delayed write list follows: * - * max_delay: Maximum of the delay_write_until fields of the entries on + * max_delay: Maximum of the delay_write_until fields of the entries on * the delayed write list. This must never be more than max_lag - * ticks in advance of the current tick, and should be set to + * ticks in advance of the current tick, and should be set to * zero if the delayed write list is empty. * * dwl_len: Number of page buffer entries currently on the delayed * write list. * - * Observe that LRU_len + dwl_len must always equal + * Observe that LRU_len + dwl_len must always equal * index_len. * - * dwl_size: Number of bytes of page buffer entries currently residing + * dwl_size: Number of bytes of page buffer entries currently residing * on the LRU list. * - * Observe that LRU_size + dwl_size must always equal - * index_size. + * Observe that LRU_size + dwl_size must always equal + * index_size. * * dwl_head_ptr: Pointer to the head of the doubly linked delayed write list. - * Page buffer entries on this list are linked by their next and + * Page buffer entries on this list are linked by their next and * prev fields. * * This field is NULL if the list is empty. * * dwl_tail_ptr: Pointer to the tail of the doubly linked delayed write list. - * Page buffer entries on this list are linked by their next and + * Page buffer entries on this list are linked by their next and * prev fields. * * This field is NULL if the list is empty. @@ -354,27 +349,27 @@ typedef struct H5PB_entry_t H5PB_entry_t; * metadata file at the end of tick. * * To implement this, all entries modified during the current tick are placed - * on the tick list. Entries are removed from the tick list during end of + * on the tick list. Entries are removed from the tick list during end of * tick processing, so each tick starts with an empty tick list. * - * Unless the entry also resides on the delayed write list, entries on the + * Unless the entry also resides on the delayed write list, entries on the * tick list may be flushed, but they may not be evicted. * * Discussion of the fields used to implement the tick list follows: * * tl_len: Number of page buffer entries currently on the tick list * - * tl_size: Number of bytes of page buffer entries currently residing + * tl_size: Number of bytes of page buffer entries currently residing * on the tick list. * * tl_head_ptr: Pointer to the head of the doubly linked tick list. - * Page buffer entries on this list are linked by their tl_next + * Page buffer entries on this list are linked by their tl_next * and tl_prev fields. * * This field is NULL if the list is empty. * * tl_tail_ptr: Pointer to the tail of the doubly linked tick list. - * Page buffer entries on this list are linked by their tl_next + * Page buffer entries on this list are linked by their tl_next * and tl_prev fields. * * This field is NULL if the list is empty. @@ -382,91 +377,91 @@ typedef struct H5PB_entry_t H5PB_entry_t; * * STATISTICS: * - * Multi-page metadata entries (which may only appear in VFD + * Multi-page metadata entries (which may only appear in VFD * SWMR mode) are NOT counted in the following statistics. * - * Note that all statistics fields contain only data since the last time + * Note that all statistics fields contain only data since the last time * that statistics were reset. * * bypasses: Array of int64_t of length H5PB__NUM_STAT_TYPES containing - * the number of times that the page buffer has been - * bypassed for raw data, metadata, and for multi-page - * metadata entries (VFD SWMR only) as indexed by 5PB__STATS_MD, + * the number of times that the page buffer has been + * bypassed for raw data, metadata, and for multi-page + * metadata entries (VFD SWMR only) as indexed by 5PB__STATS_MD, * H5PB__STATS_RD, and H5PB__STATS_MPMDE respectively. * - * accesses: Array of int64_t of length H5PB__NUM_STAT_TYPES containing + * accesses: Array of int64_t of length H5PB__NUM_STAT_TYPES containing * the number of page buffer accesses for raw data, metadata, - * and for multi-page metadata entries (VFD SWMR only) as - * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and - * H5PB__STATS_MPMDE respectively. + * and for multi-page metadata entries (VFD SWMR only) as + * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and + * H5PB__STATS_MPMDE respectively. * - * hits: Array of int64_t of length H5PB__NUM_STAT_TYPES containing + * hits: Array of int64_t of length H5PB__NUM_STAT_TYPES containing * the number of page buffer hits for raw data, metadata, - * and for multi-page metadata entries (VFD SWMR only) as - * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and + * and for multi-page metadata entries (VFD SWMR only) as + * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and * H5PB__STATS_MPMDE respectively. * - * misses: Array of int64_t of length H5PB__NUM_STAT_TYPES containing + * misses: Array of int64_t of length H5PB__NUM_STAT_TYPES containing * the number of page buffer misses for raw data, metadata, - * and for multi-page metadata entries (VFD SWMR only) as - * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and + * and for multi-page metadata entries (VFD SWMR only) as + * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and * H5PB__STATS_MPMDE respectively. * - * loads: Array of int64_t of length H5PB__NUM_STAT_TYPES containing + * loads: Array of int64_t of length H5PB__NUM_STAT_TYPES containing * the number of page buffer loads for raw data, metadata, - * and for multi-page metadata entries (VFD SWMR only) as - * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and + * and for multi-page metadata entries (VFD SWMR only) as + * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and * H5PB__STATS_MPMDE respectively. * - * insertions: Array of int64_t of length H5PB__NUM_STAT_TYPES containing + * insertions: Array of int64_t of length H5PB__NUM_STAT_TYPES containing * the number of page buffer insertions of raw data, metadata, - * and for multi-page metadata entries (VFD SWMR only) as - * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and + * and for multi-page metadata entries (VFD SWMR only) as + * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and * H5PB__STATS_MPMDE respectively. * - * flushes: Array of int64_t of length H5PB__NUM_STAT_TYPES containing + * flushes: Array of int64_t of length H5PB__NUM_STAT_TYPES containing * the number of page buffer flushes of raw data, metadata, - * and for multi-page metadata entries (VFD SWMR only) as - * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and + * and for multi-page metadata entries (VFD SWMR only) as + * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and * H5PB__STATS_MPMDE respectively. * - * evictions: Array of int64_t of length H5PB__NUM_STAT_TYPES containing + * evictions: Array of int64_t of length H5PB__NUM_STAT_TYPES containing * the number of page buffer evictions of raw data, metadata, - * and for multi-page metadata entries (VFD SWMR only) as - * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and + * and for multi-page metadata entries (VFD SWMR only) as + * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and * H5PB__STATS_MPMDE respectively. * - * clears: Array of int64_t of length H5PB__NUM_STAT_TYPES containing + * clears: Array of int64_t of length H5PB__NUM_STAT_TYPES containing * the number of page buffer entry clears of raw data, metadata, - * and for multi-page metadata entries (VFD SWMR only) as - * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and + * and for multi-page metadata entries (VFD SWMR only) as + * indexed by 5PB__STATS_MD, H5PB__STATS_RD, and * H5PB__STATS_MPMDE respectively. * - * max_lru_len: int64_t containing the maximum number of entries that + * max_lru_len: int64_t containing the maximum number of entries that * have appeared in the LRU. * * max_lru_size: int64_t containing the maximum size of the LRU. * - * lru_md_skips: When searching for an entry to evict, metadata entries on - * the LRU must be skipped if the number of metadata pages + * lru_md_skips: When searching for an entry to evict, metadata entries on + * the LRU must be skipped if the number of metadata pages * in the page buffer fails to exceed min_md_pages. * * This int64_t is used to keep a count of these skips. * - * If this number becomes excessive, it will be necessary to + * If this number becomes excessive, it will be necessary to * add a holding tank for such entries. * - * lru_rd_skips: When searching for an entry to evict, raw data entries on - * the LRU must be skipped if the number of raw data pages + * lru_rd_skips: When searching for an entry to evict, raw data entries on + * the LRU must be skipped if the number of raw data pages * in the page buffer fails to exceed min_rd_pages. * * This int64_t is used to keep a count of these skips. * - * If this number becomes excessive, it will be necessary to + * If this number becomes excessive, it will be necessary to * add a holding tank for such entries. * - * Multi-page metadata entries (which appear only in VFD SWMR mode) are - * listed in the hash take, and thus they are counted in the following + * Multi-page metadata entries (which appear only in VFD SWMR mode) are + * listed in the hash take, and thus they are counted in the following * statistics. * * total_ht_insertions: Number of times entries have been inserted into the @@ -508,15 +503,15 @@ typedef struct H5PB_entry_t H5PB_entry_t; * * Statistics pretaining to VFD SWMR. * - * max_mpmde_count: Maximum number of multi-page metadata entries in the + * max_mpmde_count: Maximum number of multi-page metadata entries in the * page buffer. * - * lru_tl_skips: When searching for an entry to evict, metadata entries on + * lru_tl_skips: When searching for an entry to evict, metadata entries on * the LRU must be skipped if they also reside on the tick list. * * This int64_t is used to keep a count of these skips. * - * If this number becomes excessive, it will be necessary to + * If this number becomes excessive, it will be necessary to * add a holding tank for such entries. * * max_tl_len: int64_t containing the maximum value of tl_len. @@ -525,93 +520,92 @@ typedef struct H5PB_entry_t H5PB_entry_t; * * delayed_writes: int64_t containing the total number of delayed writes. * - * total_delay: int64_t containing the total number of ticks by which + * total_delay: int64_t containing the total number of ticks by which * entry writes have been delayed. * * max_dwl_len: int64_t containing the maximum value of dwl_len. * * max_dwl_size: int64_t containing the maximum value of dwl_size. * - * total_dwl_ins_depth: int64_t containing the total insertion depth - * required to maintain the odering invarient on the + * total_dwl_ins_depth: int64_t containing the total insertion depth + * required to maintain the odering invarient on the * delayed write list. * - * md_read_splits: int64_t containing the number of metadata reads that - * are split into two or three sub-reads to manage the - * case in which a group of metadata cache clients + * md_read_splits: int64_t containing the number of metadata reads that + * are split into two or three sub-reads to manage the + * case in which a group of metadata cache clients * sub-allocate entries from a single file space allocationn. * - * md_write_splits: int64_t containing the number of metadata writes that - * are split into two or three sub-writes to manage the - * case in which a group of metadata cache clients + * md_write_splits: int64_t containing the number of metadata writes that + * are split into two or three sub-writes to manage the + * case in which a group of metadata cache clients * sub-allocate entries from a single file space allocationn. - * + * ******************************************************************************/ -#define H5PB__H5PB_T_MAGIC 0x01020304 +#define H5PB__H5PB_T_MAGIC 0x01020304 -#define H5PB__STATS_MD 0 -#define H5PB__STATS_RD 1 -#define H5PB__STATS_MPMDE 2 -#define H5PB__NUM_STAT_TYPES 3 +#define H5PB__STATS_MD 0 +#define H5PB__STATS_RD 1 +#define H5PB__STATS_MPMDE 2 +#define H5PB__NUM_STAT_TYPES 3 typedef struct H5PB_t { /* Fields for general operations: */ uint32_t magic; - size_t page_size; - int64_t max_pages; - int64_t curr_pages; - int64_t curr_md_pages; - int64_t curr_rd_pages; - int64_t min_md_pages; - int64_t min_rd_pages; + size_t page_size; + int64_t max_pages; + int64_t curr_pages; + int64_t curr_md_pages; + int64_t curr_rd_pages; + int64_t min_md_pages; + int64_t min_rd_pages; /* FAPL fields */ - size_t max_size; - unsigned min_meta_perc; + size_t max_size; + unsigned min_meta_perc; unsigned min_raw_perc; /* index */ H5PB_entry_t *(ht[H5PB__HASH_TABLE_LEN]); - int64_t index_len; - int64_t clean_index_len; - int64_t dirty_index_len; - int64_t index_size; - int64_t clean_index_size; - int64_t dirty_index_size; - int64_t il_len; - int64_t il_size; - H5PB_entry_t * il_head; - H5PB_entry_t * il_tail; + int64_t index_len; + int64_t clean_index_len; + int64_t dirty_index_len; + int64_t index_size; + int64_t clean_index_size; + int64_t dirty_index_size; + int64_t il_len; + int64_t il_size; + H5PB_entry_t *il_head; + H5PB_entry_t *il_tail; /* LRU */ - int64_t LRU_len; - int64_t LRU_size; - H5PB_entry_t * LRU_head_ptr; - H5PB_entry_t * LRU_tail_ptr; - + int64_t LRU_len; + int64_t LRU_size; + H5PB_entry_t *LRU_head_ptr; + H5PB_entry_t *LRU_tail_ptr; /* Fields for VFD SWMR operations: */ - hbool_t vfd_swmr; - hbool_t vfd_swmr_writer; - int64_t mpmde_count; + hbool_t vfd_swmr; + hbool_t vfd_swmr_writer; + int64_t mpmde_count; uint64_t cur_tick; /* delayed write list */ - uint64_t max_delay; - int64_t dwl_len; - int64_t dwl_size; - H5PB_entry_t * dwl_head_ptr; - H5PB_entry_t * dwl_tail_ptr; + uint64_t max_delay; + int64_t dwl_len; + int64_t dwl_size; + H5PB_entry_t *dwl_head_ptr; + H5PB_entry_t *dwl_tail_ptr; /* tick list */ - int64_t tl_len; - int64_t tl_size; - H5PB_entry_t * tl_head_ptr; - H5PB_entry_t * tl_tail_ptr; + int64_t tl_len; + int64_t tl_size; + H5PB_entry_t *tl_head_ptr; + H5PB_entry_t *tl_tail_ptr; /* Statistics: */ @@ -619,23 +613,23 @@ typedef struct H5PB_t { /* these statistics count pages only, not multi-page metadata entries * (that occur only in the VFD SWMR writer case). */ - int64_t bypasses[H5PB__NUM_STAT_TYPES]; - int64_t accesses[H5PB__NUM_STAT_TYPES]; - int64_t hits[H5PB__NUM_STAT_TYPES]; - int64_t misses[H5PB__NUM_STAT_TYPES]; - int64_t loads[H5PB__NUM_STAT_TYPES]; - int64_t insertions[H5PB__NUM_STAT_TYPES]; - int64_t flushes[H5PB__NUM_STAT_TYPES]; - int64_t evictions[H5PB__NUM_STAT_TYPES]; - int64_t clears[H5PB__NUM_STAT_TYPES]; + int64_t bypasses[H5PB__NUM_STAT_TYPES]; + int64_t accesses[H5PB__NUM_STAT_TYPES]; + int64_t hits[H5PB__NUM_STAT_TYPES]; + int64_t misses[H5PB__NUM_STAT_TYPES]; + int64_t loads[H5PB__NUM_STAT_TYPES]; + int64_t insertions[H5PB__NUM_STAT_TYPES]; + int64_t flushes[H5PB__NUM_STAT_TYPES]; + int64_t evictions[H5PB__NUM_STAT_TYPES]; + int64_t clears[H5PB__NUM_STAT_TYPES]; uint64_t access_size_count[6]; - int64_t max_lru_len; - int64_t max_lru_size; - int64_t lru_md_skips; - int64_t lru_rd_skips; + int64_t max_lru_len; + int64_t max_lru_size; + int64_t lru_md_skips; + int64_t lru_rd_skips; /* In the VFD SWMR case, both pages and multi-page metadata entries - * are stored in the index. Thus mult-page metadata entries are + * are stored in the index. Thus mult-page metadata entries are * included in the index related statistics. */ int64_t total_ht_insertions; @@ -653,7 +647,6 @@ typedef struct H5PB_t { int64_t max_rd_pages; int64_t max_md_pages; - /* vfd swmr statistics */ int64_t max_mpmde_count; int64_t lru_tl_skips; @@ -673,14 +666,13 @@ typedef struct H5PB_t { /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General routines */ -H5_DLL herr_t H5PB_create(H5F_shared_t *shared, size_t page_buffer_size, - unsigned page_buf_min_meta_perc, unsigned page_buf_min_raw_perc); +H5_DLL herr_t H5PB_create(H5F_shared_t *shared, size_t page_buffer_size, unsigned page_buf_min_meta_perc, + unsigned page_buf_min_raw_perc); H5_DLL herr_t H5PB_flush(H5F_shared_t *); @@ -694,11 +686,9 @@ H5_DLL herr_t H5PB_remove_entry(H5F_shared_t *, haddr_t); H5_DLL herr_t H5PB_remove_entries(H5F_shared_t *, haddr_t, hsize_t); -H5_DLL herr_t H5PB_read(H5F_shared_t *, H5FD_mem_t, haddr_t, - size_t, void * /*out*/); +H5_DLL herr_t H5PB_read(H5F_shared_t *, H5FD_mem_t, haddr_t, size_t, void * /*out*/); -H5_DLL herr_t H5PB_write(H5F_shared_t *, H5FD_mem_t, haddr_t, - size_t, const void *); +H5_DLL herr_t H5PB_write(H5F_shared_t *, H5FD_mem_t, haddr_t, size_t, const void *); /* VFD SWMR specific routines */ H5_DLL herr_t H5PB_vfd_swmr__release_delayed_writes(H5F_shared_t *); @@ -707,22 +697,19 @@ H5_DLL herr_t H5PB_vfd_swmr__release_tick_list(H5F_shared_t *); H5_DLL herr_t H5PB_vfd_swmr__set_tick(H5F_shared_t *); -H5_DLL herr_t H5PB_vfd_swmr__update_index(H5F_t *f, - uint32_t * idx_ent_added_ptr, uint32_t * idx_ent_modified_ptr, - uint32_t * idx_ent_not_in_tl_ptr, uint32_t * idx_ent_not_in_tl_flushed_ptr); +H5_DLL herr_t H5PB_vfd_swmr__update_index(H5F_t *f, uint32_t *idx_ent_added_ptr, + uint32_t *idx_ent_modified_ptr, uint32_t *idx_ent_not_in_tl_ptr, + uint32_t *idx_ent_not_in_tl_flushed_ptr); /* Statistics routines */ H5_DLL herr_t H5PB_reset_stats(H5PB_t *); -H5_DLL herr_t H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], - unsigned hits[2], unsigned misses[2], unsigned evictions[2], - unsigned bypasses[2]); +H5_DLL herr_t H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], + unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); H5_DLL herr_t H5PB_print_stats(const H5PB_t *); - /* test & debug functions */ H5_DLL herr_t H5PB_page_exists(H5F_shared_t *, haddr_t, hbool_t *); #endif /* !_H5PBprivate_H */ - diff --git a/src/H5PL.c b/src/H5PL.c index 0f0f88a..57c9a12 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -14,48 +14,39 @@ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5PLpkg.h" /* Plugin */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5PLpkg.h" /* Plugin */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5PLset_loading_state * @@ -83,20 +74,19 @@ herr_t H5PLset_loading_state(unsigned int plugin_control_mask) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Iu", plugin_control_mask); /* Set the plugin control mask */ - if(H5PL__set_plugin_control_mask(plugin_control_mask) < 0) + if (H5PL__set_plugin_control_mask(plugin_control_mask) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "error setting plugin control mask") done: FUNC_LEAVE_API(ret_value) } /* end H5PLset_loading_state() */ - /*------------------------------------------------------------------------- * Function: H5PLget_loading_state * @@ -116,7 +106,7 @@ done: herr_t H5PLget_loading_state(unsigned int *plugin_control_mask) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*Iu", plugin_control_mask); @@ -125,14 +115,13 @@ H5PLget_loading_state(unsigned int *plugin_control_mask) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plugin_control_mask parameter cannot be NULL") /* Set the plugin control mask */ - if(H5PL__get_plugin_control_mask(plugin_control_mask) < 0) + if (H5PL__get_plugin_control_mask(plugin_control_mask) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error getting plugin control mask") done: FUNC_LEAVE_API(ret_value) } /* end H5PLget_loading_state() */ - /*------------------------------------------------------------------------- * Function: H5PLappend * @@ -165,7 +154,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLappend() */ - /*------------------------------------------------------------------------- * Function: H5PLprepend * @@ -198,7 +186,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLprepend() */ - /*------------------------------------------------------------------------- * Function: H5PLreplace * @@ -212,8 +199,8 @@ done: herr_t H5PLreplace(const char *search_path, unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "*sIu", search_path, idx); @@ -229,7 +216,8 @@ H5PLreplace(const char *search_path, unsigned int idx) if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") else if (idx >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Insert the search path into the path table */ if (H5PL__replace_path(search_path, idx) < 0) @@ -239,7 +227,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLreplace() */ - /*------------------------------------------------------------------------- * Function: H5PLinsert * @@ -254,8 +241,8 @@ done: herr_t H5PLinsert(const char *search_path, unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "*sIu", search_path, idx); @@ -269,7 +256,8 @@ H5PLinsert(const char *search_path, unsigned int idx) /* Check index */ num_paths = H5PL__get_num_paths(); if ((0 != num_paths) && (idx >= num_paths)) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Insert the search path into the path table */ if (H5PL__insert_path(search_path, idx) < 0) @@ -279,7 +267,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLinsert() */ - /*------------------------------------------------------------------------- * Function: H5PLremove * @@ -296,8 +283,8 @@ done: herr_t H5PLremove(unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Iu", idx); @@ -307,7 +294,8 @@ H5PLremove(unsigned int idx) if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") else if (idx >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Delete the search path from the path table */ if (H5PL__remove_path(idx) < 0) @@ -317,7 +305,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLremove() */ - /*------------------------------------------------------------------------- * Function: H5PLget * @@ -345,10 +332,10 @@ done: ssize_t H5PLget(unsigned int idx, char *path_buf, size_t buf_size) { - unsigned num_paths; /* Current number of stored paths */ - const char *path = NULL; /* path from table */ - size_t path_len = 0; /* Length of path */ - ssize_t ret_value = 0; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + const char *path = NULL; /* path from table */ + size_t path_len = 0; /* Length of path */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "Iu*sz", idx, path_buf, buf_size); @@ -358,7 +345,8 @@ H5PLget(unsigned int idx, char *path_buf, size_t buf_size) if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") else if (idx >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Check if the search table is empty */ if (H5PL__get_num_paths() == 0) @@ -383,7 +371,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5PLget() */ - /*------------------------------------------------------------------------- * Function: H5PLsize * @@ -412,4 +399,3 @@ H5PLsize(unsigned int *num_paths) done: FUNC_LEAVE_API(ret_value) } /* end H5PLsize() */ - diff --git a/src/H5PLextern.h b/src/H5PLextern.h index cd5464d..2385d54 100644 --- a/src/H5PLextern.h +++ b/src/H5PLextern.h @@ -21,12 +21,12 @@ #include "hdf5.h" /* plugins always export */ -#if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5PLUGIN_DLL __declspec(dllexport) -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5PLUGIN_DLL __attribute__ ((visibility("default"))) +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5PLUGIN_DLL __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5PLUGIN_DLL __attribute__((visibility("default"))) #else - #define H5PLUGIN_DLL +#define H5PLUGIN_DLL #endif #ifdef __cplusplus @@ -41,4 +41,3 @@ H5PLUGIN_DLL const void *H5PLget_plugin_info(void); #endif #endif /* _H5PLextern_H */ - diff --git a/src/H5PLint.c b/src/H5PLint.c index b69a788..028fe2b 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -15,39 +15,33 @@ * */ - /****************/ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PLpkg.h" /* Plugin */ -#include "H5Zprivate.h" /* Filter pipeline */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLpkg.h" /* Plugin */ +#include "H5Zprivate.h" /* Filter pipeline */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -55,12 +49,10 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -68,16 +60,14 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Bitmask that controls whether classes of plugins * (e.g.: filters, VOL drivers) can be loaded. */ -static unsigned int H5PL_plugin_control_mask_g = H5PL_ALL_PLUGIN; +static unsigned int H5PL_plugin_control_mask_g = H5PL_ALL_PLUGIN; /* This flag will be set to FALSE if the HDF5_PLUGIN_PRELOAD * environment variable was set to H5PL_NO_PLUGIN at * package initialization. */ -static hbool_t H5PL_allow_plugins_g = TRUE; - +static hbool_t H5PL_allow_plugins_g = TRUE; - /*------------------------------------------------------------------------- * Function: H5PL__get_plugin_control_mask * @@ -90,7 +80,7 @@ static hbool_t H5PL_allow_plugins_g = TRUE; herr_t H5PL__get_plugin_control_mask(unsigned int *mask /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -104,7 +94,6 @@ H5PL__get_plugin_control_mask(unsigned int *mask /*out*/) } /* end H5PL__get_plugin_control_mask() */ - /*------------------------------------------------------------------------- * Function: H5PL__set_plugin_control_mask * @@ -117,7 +106,7 @@ H5PL__get_plugin_control_mask(unsigned int *mask /*out*/) herr_t H5PL__set_plugin_control_mask(unsigned int mask) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -133,7 +122,6 @@ H5PL__set_plugin_control_mask(unsigned int mask) } /* end H5PL__set_plugin_control_mask() */ - /*------------------------------------------------------------------------- * Function: H5PL__init_package * @@ -147,8 +135,8 @@ H5PL__set_plugin_control_mask(unsigned int mask) herr_t H5PL__init_package(void) { - char *env_var = NULL; - herr_t ret_value = SUCCEED; + char * env_var = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -159,7 +147,7 @@ H5PL__init_package(void) if (NULL != (env_var = HDgetenv("HDF5_PLUGIN_PRELOAD"))) if (!HDstrcmp(env_var, H5PL_NO_PLUGIN)) { H5PL_plugin_control_mask_g = 0; - H5PL_allow_plugins_g = FALSE; + H5PL_allow_plugins_g = FALSE; } /* Create the table of previously-loaded plugins */ @@ -174,7 +162,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__init_package() */ - /*------------------------------------------------------------------------- * Function: H5PL_term_package * @@ -192,7 +179,7 @@ int H5PL_term_package(void) { hbool_t already_closed = FALSE; - int ret_value = 0; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT @@ -219,7 +206,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL_term_package() */ - /*------------------------------------------------------------------------- * Function: H5PL_load * @@ -237,10 +223,10 @@ done: const void * H5PL_load(H5PL_type_t type, const H5PL_key_t *key) { - H5PL_search_params_t search_params; /* Plugin search parameters */ - hbool_t found = FALSE; /* Whether the plugin was found */ - const void *plugin_info = NULL; /* Information from the plugin */ - const void *ret_value = NULL; + H5PL_search_params_t search_params; /* Plugin search parameters */ + hbool_t found = FALSE; /* Whether the plugin was found */ + const void * plugin_info = NULL; /* Information from the plugin */ + const void * ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -251,8 +237,9 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "filter plugins disabled") break; case H5PL_TYPE_VOL: - if((H5PL_plugin_control_mask_g & H5PL_VOL_PLUGIN) == 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "Virtual Object Layer (VOL) driver plugins disabled") + if ((H5PL_plugin_control_mask_g & H5PL_VOL_PLUGIN) == 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, + "Virtual Object Layer (VOL) driver plugins disabled") break; case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: @@ -262,11 +249,11 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) /* Set up the search parameters */ search_params.type = type; - search_params.key = key; + search_params.key = key; /* Search in the table of already loaded plugin libraries */ - if(H5PL__find_plugin_in_cache(&search_params, &found, &plugin_info) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in plugin cache failed") + if (H5PL__find_plugin_in_cache(&search_params, &found, &plugin_info) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in plugin cache failed") /* If not found, try iterating through the path table to find an appropriate plugin */ if (!found) @@ -281,7 +268,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL_load() */ - /*------------------------------------------------------------------------- * Function: H5PL__open * @@ -304,15 +290,15 @@ done: * get_plugin_info function pointer, but early (4.4.7, at least) gcc * only allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(pedantic) +H5_GCC_DIAG_OFF("pedantic") herr_t -H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, - hbool_t *success, const void **plugin_info) +H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, hbool_t *success, + const void **plugin_info) { - H5PL_HANDLE handle = NULL; - H5PL_get_plugin_type_t get_plugin_type = NULL; - H5PL_get_plugin_info_t get_plugin_info = NULL; - herr_t ret_value = SUCCEED; + H5PL_HANDLE handle = NULL; + H5PL_get_plugin_type_t get_plugin_type = NULL; + H5PL_get_plugin_info_t get_plugin_info = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -322,7 +308,7 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, HDassert(plugin_info); /* Initialize out parameters */ - *success = FALSE; + *success = FALSE; *plugin_info = NULL; /* There are different reasons why a library can't be open, e.g. wrong architecture. @@ -346,13 +332,12 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, HGOTO_DONE(SUCCEED) /* Check the plugin type and return if it doesn't match the one passed in */ - if(type != (H5PL_type_t)(*get_plugin_type)()) + if (type != (H5PL_type_t)(*get_plugin_type)()) HGOTO_DONE(SUCCEED) /* Get the plugin information */ switch (type) { - case H5PL_TYPE_FILTER: - { + case H5PL_TYPE_FILTER: { const H5Z_class2_t *filter_info; /* Get the plugin info */ @@ -362,38 +347,37 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, /* If the filter IDs match, we're done. Set the output parameters. */ if (filter_info->id == key->id) { *plugin_info = (const void *)filter_info; - *success = TRUE; + *success = TRUE; } break; } - case H5PL_TYPE_VOL: - { + case H5PL_TYPE_VOL: { const H5VL_class_t *cls; /* Get the plugin info */ - if(NULL == (cls = (const H5VL_class_t *)(*get_plugin_info)())) + if (NULL == (cls = (const H5VL_class_t *)(*get_plugin_info)())) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL connector info from plugin") /* Which kind of key are we looking for? */ - if(key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { + if (key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { /* If the plugin names match, we're done. Set the output parameters. */ - if(cls->name && !HDstrcmp(cls->name, key->vol.u.name)) { + if (cls->name && !HDstrcmp(cls->name, key->vol.u.name)) { *plugin_info = (const void *)cls; - *success = TRUE; + *success = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Sanity check */ HDassert(key->vol.kind == H5VL_GET_CONNECTOR_BY_VALUE); /* If the plugin values match, we're done. Set the output parameters. */ - if(cls->value == key->vol.u.value) { + if (cls->value == key->vol.u.value) { *plugin_info = (const void *)cls; - *success = TRUE; + *success = TRUE; } /* end if */ - } /* end else */ + } /* end else */ break; } @@ -416,9 +400,8 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__open() */ -H5_GCC_DIAG_ON(pedantic) +H5_GCC_DIAG_ON("pedantic") - /*------------------------------------------------------------------------- * Function: H5PL__close * @@ -437,4 +420,3 @@ H5PL__close(H5PL_HANDLE handle) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5PL__close() */ - diff --git a/src/H5PLmodule.h b/src/H5PLmodule.h index 945441e..8bf11ce 100644 --- a/src/H5PLmodule.h +++ b/src/H5PLmodule.h @@ -23,10 +23,8 @@ * reporting macros. */ #define H5PL_MODULE -#define H5_MY_PKG H5PL -#define H5_MY_PKG_ERR H5E_PLUGIN -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5PL +#define H5_MY_PKG_ERR H5E_PLUGIN +#define H5_MY_PKG_INIT YES #endif /* _H5PLmodule_H */ - - diff --git a/src/H5PLpath.c b/src/H5PLpath.c index ba23fd3..1858cf8 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -30,34 +30,30 @@ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PLpkg.h" /* Plugin */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLpkg.h" /* Plugin */ /****************/ /* Local Macros */ /****************/ /* Initial capacity of the path table */ -#define H5PL_INITIAL_PATH_CAPACITY 16 +#define H5PL_INITIAL_PATH_CAPACITY 16 /* The amount to add to the capacity when the table is full */ -#define H5PL_PATH_CAPACITY_ADD 16 - +#define H5PL_PATH_CAPACITY_ADD 16 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -66,33 +62,30 @@ static herr_t H5PL__insert_at(const char *path, unsigned int idx); static herr_t H5PL__make_space_at(unsigned int idx); static herr_t H5PL__replace_at(const char *path, unsigned int idx); static herr_t H5PL__expand_path_table(void); -static herr_t H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *found, const char *dir, const void **plugin_info); +static herr_t H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *found, + const char *dir, const void **plugin_info); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Stored plugin paths to search */ -static char **H5PL_paths_g = NULL; +static char **H5PL_paths_g = NULL; /* The number of stored paths */ -static unsigned H5PL_num_paths_g = 0; +static unsigned H5PL_num_paths_g = 0; /* The capacity of the path table */ -static unsigned H5PL_path_capacity_g = H5PL_INITIAL_PATH_CAPACITY; - +static unsigned H5PL_path_capacity_g = H5PL_INITIAL_PATH_CAPACITY; - /*------------------------------------------------------------------------- * Function: H5PL__insert_at() * @@ -107,8 +100,8 @@ static unsigned H5PL_path_capacity_g = H5PL_INITIAL_PATH_CAPACITY; static herr_t H5PL__insert_at(const char *path, unsigned int idx) { - char *path_copy = NULL; /* copy of path string (for storing) */ - herr_t ret_value = SUCCEED; /* Return value */ + char * path_copy = NULL; /* copy of path string (for storing) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -127,7 +120,7 @@ H5PL__insert_at(const char *path, unsigned int idx) #ifdef H5_HAVE_WIN32_API /* Clean up Microsoft Windows environment variables in the path string */ - if(H5_expand_windows_env_vars(&path_copy)) + if (H5_expand_windows_env_vars(&path_copy)) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTCONVERT, FAIL, "can't expand environment variable string") #endif /* H5_HAVE_WIN32_API */ @@ -144,7 +137,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__insert_at() */ - /*------------------------------------------------------------------------- * Function: H5PL__make_space_at() * @@ -158,8 +150,8 @@ done: static herr_t H5PL__make_space_at(unsigned int idx) { - unsigned u; /* iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* iterator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -168,14 +160,13 @@ H5PL__make_space_at(unsigned int idx) /* Copy the paths back to make a space */ for (u = H5PL_num_paths_g; u > idx; u--) - H5PL_paths_g[u] = H5PL_paths_g[u-1]; + H5PL_paths_g[u] = H5PL_paths_g[u - 1]; H5PL_paths_g[idx] = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__make_space_at() */ - /*------------------------------------------------------------------------- * Function: H5PL__replace_at() * @@ -190,8 +181,8 @@ H5PL__make_space_at(unsigned int idx) static herr_t H5PL__replace_at(const char *path, unsigned int idx) { - char *path_copy = NULL; /* copy of path string (for storing) */ - herr_t ret_value = SUCCEED; /* Return value */ + char * path_copy = NULL; /* copy of path string (for storing) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -208,9 +199,9 @@ H5PL__replace_at(const char *path, unsigned int idx) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't make internal copy of path") #ifdef H5_HAVE_WIN32_API - /* Clean up Microsoft Windows environment variables in the path string */ - if (H5_expand_windows_env_vars(&path_copy)) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTCONVERT, FAIL, "can't expand environment variable string") + /* Clean up Microsoft Windows environment variables in the path string */ + if (H5_expand_windows_env_vars(&path_copy)) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTCONVERT, FAIL, "can't expand environment variable string") #endif /* H5_HAVE_WIN32_API */ /* Free the existing path entry */ @@ -223,7 +214,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__replace_at() */ - /*------------------------------------------------------------------------- * Function: H5PL__create_path_table * @@ -237,18 +227,18 @@ done: herr_t H5PL__create_path_table(void) { - char *env_var= NULL; /* Path string from environment variable */ - char *paths = NULL; /* Delimited paths string. Either from the - * environment variable or the default. - */ - char *next_path = NULL; /* A path tokenized from the paths string */ - char *lasts = NULL; /* Context pointer for strtok_r() call */ - herr_t ret_value = SUCCEED; /* Return value */ + char *env_var = NULL; /* Path string from environment variable */ + char *paths = NULL; /* Delimited paths string. Either from the + * environment variable or the default. + */ + char * next_path = NULL; /* A path tokenized from the paths string */ + char * lasts = NULL; /* Context pointer for strtok_r() call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Allocate memory for the path table */ - H5PL_num_paths_g = 0; + H5PL_num_paths_g = 0; H5PL_path_capacity_g = H5PL_INITIAL_PATH_CAPACITY; if (NULL == (H5PL_paths_g = (char **)H5MM_calloc((size_t)H5PL_path_capacity_g * sizeof(char *)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path table") @@ -291,7 +281,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__create_path_table() */ - /*------------------------------------------------------------------------- * Function: H5PL__close_path_table * @@ -305,8 +294,8 @@ done: herr_t H5PL__close_path_table(void) { - unsigned u; /* iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* iterator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -325,7 +314,6 @@ H5PL__close_path_table(void) } /* end H5PL__close_path_table() */ - /*------------------------------------------------------------------------- * Function: H5PL__get_num_paths * @@ -344,7 +332,6 @@ H5PL__get_num_paths(void) } /* end H5PL__get_num_paths() */ - /*------------------------------------------------------------------------- * Function: H5PL__expand_path_table * @@ -357,7 +344,7 @@ H5PL__get_num_paths(void) static herr_t H5PL__expand_path_table(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -365,7 +352,8 @@ H5PL__expand_path_table(void) H5PL_path_capacity_g += H5PL_PATH_CAPACITY_ADD; /* Resize the array */ - if(NULL == (H5PL_paths_g = (char **)H5MM_realloc(H5PL_paths_g, (size_t)H5PL_path_capacity_g * sizeof(char *)))) + if (NULL == + (H5PL_paths_g = (char **)H5MM_realloc(H5PL_paths_g, (size_t)H5PL_path_capacity_g * sizeof(char *)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "allocating additional memory for path table failed") /* Initialize the new memory */ @@ -379,7 +367,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__expand_path_table() */ - /*------------------------------------------------------------------------- * Function: H5PL__append_path * @@ -392,7 +379,7 @@ done: herr_t H5PL__append_path(const char *path) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -408,7 +395,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__append_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__prepend_path * @@ -421,7 +407,7 @@ done: herr_t H5PL__prepend_path(const char *path) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -437,7 +423,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__prepend_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__replace_path * @@ -450,7 +435,7 @@ done: herr_t H5PL__replace_path(const char *path, unsigned int idx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -467,7 +452,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__replace_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__insert_path * @@ -481,7 +465,7 @@ done: herr_t H5PL__insert_path(const char *path, unsigned int idx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -498,7 +482,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__insert_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__remove_path * @@ -512,8 +495,8 @@ done: herr_t H5PL__remove_path(unsigned int idx) { - unsigned u; /* iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* iterator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -530,7 +513,7 @@ H5PL__remove_path(unsigned int idx) /* Shift the paths down to close the gap */ for (u = idx; u < H5PL_num_paths_g; u++) - H5PL_paths_g[u] = H5PL_paths_g[u+1]; + H5PL_paths_g[u] = H5PL_paths_g[u + 1]; /* Set the (former) last path to NULL */ H5PL_paths_g[H5PL_num_paths_g] = NULL; @@ -539,7 +522,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__remove_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__get_path * @@ -553,7 +535,7 @@ done: const char * H5PL__get_path(unsigned int idx) { - char *ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -566,7 +548,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__replace_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__find_plugin_in_path_table * @@ -580,10 +561,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool_t *found, const void **plugin_info) +H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool_t *found, + const void **plugin_info) { - unsigned int u; /* iterator */ - herr_t ret_value = SUCCEED; + unsigned int u; /* iterator */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -593,7 +575,7 @@ H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool HDassert(plugin_info); /* Initialize output parameters */ - *found = FALSE; + *found = FALSE; *plugin_info = NULL; /* Loop over the paths in the table, checking for an appropriate plugin */ @@ -601,7 +583,8 @@ H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool /* Search for the plugin in this path */ if (H5PL__find_plugin_in_path(search_params, found, H5PL_paths_g[u], plugin_info) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in path %s encountered an error", H5PL_paths_g[u]) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in path %s encountered an error", + H5PL_paths_g[u]) /* Break out if found */ if (*found) { @@ -615,7 +598,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_path_table() */ - /*------------------------------------------------------------------------- * Function: H5PL__find_plugin_in_path * @@ -633,11 +615,12 @@ done: */ #ifndef H5_HAVE_WIN32_API static herr_t -H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *found, const char *dir, const void **plugin_info) +H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *found, const char *dir, + const void **plugin_info) { - char *path = NULL; - DIR *dirp = NULL; /* Directory stream */ - struct dirent *dp = NULL; /* Directory entry */ + char * path = NULL; + DIR * dirp = NULL; /* Directory stream */ + struct dirent *dp = NULL; /* Directory entry */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -663,17 +646,17 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo */ #ifndef __CYGWIN__ if (!HDstrncmp(dp->d_name, "lib", (size_t)3) && - (HDstrstr(dp->d_name, ".so") || HDstrstr(dp->d_name, ".dylib"))) { + (HDstrstr(dp->d_name, ".so") || HDstrstr(dp->d_name, ".dylib"))) { #else - if (!HDstrncmp(dp->d_name, "cyg", (size_t)3) && - HDstrstr(dp->d_name, ".dll") ) { + if (!HDstrncmp(dp->d_name, "cyg", (size_t)3) && HDstrstr(dp->d_name, ".dll")) { #endif - h5_stat_t my_stat; - size_t len; + h5_stat_t my_stat; + size_t len; /* Allocate & initialize the path name */ - len = HDstrlen(dir) + HDstrlen(H5PL_PATH_SEPARATOR) + HDstrlen(dp->d_name) + 1 /*\0*/ + 4; /* Extra "+4" to quiet GCC warning - 2019/07/05, QAK */ + len = HDstrlen(dir) + HDstrlen(H5PL_PATH_SEPARATOR) + HDstrlen(dp->d_name) + 1 /*\0*/ + + 4; /* Extra "+4" to quiet GCC warning - 2019/07/05, QAK */ if (NULL == (path = (char *)H5MM_calloc(len))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path") @@ -682,7 +665,8 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo /* Get info for directory entry */ if (HDstat(path, &my_stat) == -1) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't stat file %s -- error was: %s", path, HDstrerror(errno)) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't stat file %s -- error was: %s", path, + HDstrerror(errno)) /* If it is a directory, skip it */ if (S_ISDIR(my_stat.st_mode)) @@ -696,7 +680,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo path = (char *)H5MM_xfree(path); } /* end if */ - } /* end while */ + } /* end while */ done: if (dirp) @@ -707,15 +691,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_path() */ -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ static herr_t -H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *found, const char *dir, const void **plugin_info) +H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *found, const char *dir, + const void **plugin_info) { - WIN32_FIND_DATAA fdFile; - HANDLE hFind = INVALID_HANDLE_VALUE; - char *path = NULL; - char service[2048]; - herr_t ret_value = SUCCEED; + WIN32_FIND_DATAA fdFile; + HANDLE hFind = INVALID_HANDLE_VALUE; + char * path = NULL; + char service[2048]; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -740,7 +725,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo /* XXX: Probably just continue here and move the code below over one tab */ - size_t len; + size_t len; /* Allocate & initialize the path name */ len = HDstrlen(dir) + HDstrlen(H5PL_PATH_SEPARATOR) + HDstrlen(fdFile.cFileName) + 1; @@ -773,4 +758,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_path() */ #endif /* H5_HAVE_WIN32_API */ - diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h index 8c2367f..65c56a5 100644 --- a/src/H5PLpkg.h +++ b/src/H5PLpkg.h @@ -25,7 +25,7 @@ #define _H5PLpkg_H /* Include private header file */ -#include "H5PLprivate.h" /* Filter functions */ +#include "H5PLprivate.h" /* Filter functions */ /* Other private headers needed by this file */ @@ -34,8 +34,7 @@ /**************************/ /* Whether to pre-load pathnames for plugin libraries */ -#define H5PL_DEFAULT_PATH H5_DEFAULT_PLUGINDIR - +#define H5PL_DEFAULT_PATH H5_DEFAULT_PLUGINDIR /****************************/ /* Macros for supporting */ @@ -58,75 +57,72 @@ */ #ifdef H5_HAVE_WIN32_API - /* The path separator on this platform */ -# define H5PL_PATH_SEPARATOR ";" +/* The path separator on this platform */ +#define H5PL_PATH_SEPARATOR ";" - /* Handle for dynamic library */ -# define H5PL_HANDLE HINSTANCE +/* Handle for dynamic library */ +#define H5PL_HANDLE HINSTANCE - /* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */ -# define H5PL_OPEN_DLIB(S) LoadLibraryExA(S, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) +/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */ +#define H5PL_OPEN_DLIB(S) LoadLibraryExA(S, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) - /* Get the address of a symbol in dynamic library */ -# define H5PL_GET_LIB_FUNC(H,N) GetProcAddress(H,N) +/* Get the address of a symbol in dynamic library */ +#define H5PL_GET_LIB_FUNC(H, N) GetProcAddress(H, N) - /* Close dynamic library */ -# define H5PL_CLOSE_LIB(H) FreeLibrary(H) +/* Close dynamic library */ +#define H5PL_CLOSE_LIB(H) FreeLibrary(H) - /* Clear error - nothing to do */ -# define H5PL_CLR_ERROR +/* Clear error - nothing to do */ +#define H5PL_CLR_ERROR - /* maximum size for expanding env vars */ -# define H5PL_EXPAND_BUFFER_SIZE 32767 +/* maximum size for expanding env vars */ +#define H5PL_EXPAND_BUFFER_SIZE 32767 - typedef H5PL_type_t(__cdecl *H5PL_get_plugin_type_t)(void); - typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void); +typedef H5PL_type_t(__cdecl *H5PL_get_plugin_type_t)(void); +typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void); #else /* H5_HAVE_WIN32_API */ - /*****************/ - /* POSIX support */ - /*****************/ +/*****************/ +/* POSIX support */ +/*****************/ - /* The path separator on this platform */ -# define H5PL_PATH_SEPARATOR ":" +/* The path separator on this platform */ +#define H5PL_PATH_SEPARATOR ":" - /* Handle for dynamic library */ -# define H5PL_HANDLE void * +/* Handle for dynamic library */ +#define H5PL_HANDLE void * - /* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */ -# define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_LAZY) +/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */ +#define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_LAZY) - /* Get the address of a symbol in dynamic library */ -# define H5PL_GET_LIB_FUNC(H,N) dlsym(H,N) +/* Get the address of a symbol in dynamic library */ +#define H5PL_GET_LIB_FUNC(H, N) dlsym(H, N) - /* Close dynamic library */ -# define H5PL_CLOSE_LIB(H) dlclose(H) +/* Close dynamic library */ +#define H5PL_CLOSE_LIB(H) dlclose(H) - /* Clear error */ -# define H5PL_CLR_ERROR HERROR(H5E_PLUGIN, H5E_CANTGET, "can't dlopen:%s", dlerror()) +/* Clear error */ +#define H5PL_CLR_ERROR HERROR(H5E_PLUGIN, H5E_CANTGET, "can't dlopen:%s", dlerror()) - typedef H5PL_type_t(*H5PL_get_plugin_type_t)(void); - typedef const void *(*H5PL_get_plugin_info_t)(void); +typedef H5PL_type_t (*H5PL_get_plugin_type_t)(void); +typedef const void *(*H5PL_get_plugin_info_t)(void); #endif /* H5_HAVE_WIN32_API */ - /****************************/ /* Package Private Typedefs */ /****************************/ /* Data used to search for plugins */ typedef struct H5PL_search_params_t { - H5PL_type_t type; - const H5PL_key_t *key; + H5PL_type_t type; + const H5PL_key_t *key; } H5PL_search_params_t; - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -137,27 +133,27 @@ H5_DLL herr_t H5PL__set_plugin_control_mask(unsigned int mask); /* Plugin search and manipulation */ H5_DLL herr_t H5PL__open(const char *libname, H5PL_type_t type, const H5PL_key_t *key, - hbool_t *success /*out*/, const void **plugin_info /*out*/); + hbool_t *success /*out*/, const void **plugin_info /*out*/); H5_DLL herr_t H5PL__close(H5PL_HANDLE handle); /* Plugin cache calls */ H5_DLL herr_t H5PL__create_plugin_cache(void); H5_DLL herr_t H5PL__close_plugin_cache(hbool_t *already_closed /*out*/); -H5_DLL herr_t H5PL__add_plugin(H5PL_type_t type, const H5PL_key_t *key, - H5PL_HANDLE handle); -H5_DLL herr_t H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found /*out*/, const void **plugin_info /*out*/); +H5_DLL herr_t H5PL__add_plugin(H5PL_type_t type, const H5PL_key_t *key, H5PL_HANDLE handle); +H5_DLL herr_t H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found /*out*/, + const void **plugin_info /*out*/); /* Plugin search path calls */ -H5_DLL herr_t H5PL__create_path_table(void); -H5_DLL herr_t H5PL__close_path_table(void); -H5_DLL unsigned H5PL__get_num_paths(void); -H5_DLL herr_t H5PL__append_path(const char *path); -H5_DLL herr_t H5PL__prepend_path(const char *path); -H5_DLL herr_t H5PL__replace_path(const char *path, unsigned int index); -H5_DLL herr_t H5PL__insert_path(const char *path, unsigned int index); -H5_DLL herr_t H5PL__remove_path(unsigned int index); +H5_DLL herr_t H5PL__create_path_table(void); +H5_DLL herr_t H5PL__close_path_table(void); +H5_DLL unsigned H5PL__get_num_paths(void); +H5_DLL herr_t H5PL__append_path(const char *path); +H5_DLL herr_t H5PL__prepend_path(const char *path); +H5_DLL herr_t H5PL__replace_path(const char *path, unsigned int index); +H5_DLL herr_t H5PL__insert_path(const char *path, unsigned int index); +H5_DLL herr_t H5PL__remove_path(unsigned int index); H5_DLL const char *H5PL__get_path(unsigned int index); -H5_DLL herr_t H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool_t *found /*out*/, const void **plugin_info /*out*/); +H5_DLL herr_t H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, + hbool_t *found /*out*/, const void **plugin_info /*out*/); #endif /* _H5PLpkg_H */ - diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index c58828f..9c25933 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -26,29 +26,26 @@ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PLpkg.h" /* Plugin */ -#include "H5Zprivate.h" /* Filter pipeline */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLpkg.h" /* Plugin */ +#include "H5Zprivate.h" /* Filter pipeline */ /****************/ /* Local Macros */ /****************/ /* Initial capacity of the plugin cache */ -#define H5PL_INITIAL_CACHE_CAPACITY 16 +#define H5PL_INITIAL_CACHE_CAPACITY 16 /* The amount to add to the capacity when the cache is full */ -#define H5PL_CACHE_CAPACITY_ADD 16 - +#define H5PL_CACHE_CAPACITY_ADD 16 /******************/ /* Local Typedefs */ @@ -56,44 +53,38 @@ /* Type for the list of info for opened plugin libraries */ typedef struct H5PL_plugin_t { - H5PL_type_t type; /* Plugin type */ - H5PL_key_t key; /* Unique key to identify the plugin */ - H5PL_HANDLE handle; /* Plugin handle */ + H5PL_type_t type; /* Plugin type */ + H5PL_key_t key; /* Unique key to identify the plugin */ + H5PL_HANDLE handle; /* Plugin handle */ } H5PL_plugin_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t H5PL__expand_cache(void); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Cache for storing opened plugin libraries */ -static H5PL_plugin_t *H5PL_cache_g = NULL; +static H5PL_plugin_t *H5PL_cache_g = NULL; /* The number of stored plugins */ -static unsigned int H5PL_num_plugins_g = 0; +static unsigned int H5PL_num_plugins_g = 0; /* The capacity of the plugin cache */ -static unsigned int H5PL_cache_capacity_g = 0; +static unsigned int H5PL_cache_capacity_g = 0; - - /*------------------------------------------------------------------------- * Function: H5PL__create_plugin_cache * @@ -107,7 +98,7 @@ static unsigned int H5PL_cache_capacity_g = 0; herr_t H5PL__create_plugin_cache(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -116,7 +107,8 @@ H5PL__create_plugin_cache(void) H5PL_cache_capacity_g = H5PL_INITIAL_CACHE_CAPACITY; - if (NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_calloc((size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) + if (NULL == + (H5PL_cache_g = (H5PL_plugin_t *)H5MM_calloc((size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin cache") done: @@ -130,7 +122,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__create_plugin_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__close_plugin_cache * @@ -144,8 +135,8 @@ done: herr_t H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) { - unsigned int u; /* iterator */ - herr_t ret_value = SUCCEED; + unsigned int u; /* iterator */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_NOERR @@ -157,8 +148,8 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) H5PL__close((H5PL_cache_g[u]).handle); /* Free the cache array */ - H5PL_cache_g = (H5PL_plugin_t *)H5MM_xfree(H5PL_cache_g); - H5PL_num_plugins_g = 0; + H5PL_cache_g = (H5PL_plugin_t *)H5MM_xfree(H5PL_cache_g); + H5PL_num_plugins_g = 0; H5PL_cache_capacity_g = 0; /* Note that actually closed the table (needed by package close call) */ @@ -170,7 +161,6 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__close_plugin_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__expand_cache * @@ -183,7 +173,7 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) static herr_t H5PL__expand_cache(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -191,7 +181,8 @@ H5PL__expand_cache(void) H5PL_cache_capacity_g += H5PL_CACHE_CAPACITY_ADD; /* Resize the array */ - if(NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_realloc(H5PL_cache_g, (size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) + if (NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_realloc(H5PL_cache_g, (size_t)H5PL_cache_capacity_g * + sizeof(H5PL_plugin_t)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "allocating additional memory for plugin cache failed") /* Initialize the new memory */ @@ -205,7 +196,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__expand_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__add_plugin * @@ -218,7 +208,7 @@ done: herr_t H5PL__add_plugin(H5PL_type_t type, const H5PL_key_t *key, H5PL_HANDLE handle) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -228,9 +218,9 @@ H5PL__add_plugin(H5PL_type_t type, const H5PL_key_t *key, H5PL_HANDLE handle) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't expand plugin cache") /* Store the plugin info and bump the # of plugins */ - H5PL_cache_g[H5PL_num_plugins_g].type = type; - H5PL_cache_g[H5PL_num_plugins_g].key = *key; - H5PL_cache_g[H5PL_num_plugins_g].handle = handle; + H5PL_cache_g[H5PL_num_plugins_g].type = type; + H5PL_cache_g[H5PL_num_plugins_g].key = *key; + H5PL_cache_g[H5PL_num_plugins_g].handle = handle; H5PL_num_plugins_g++; @@ -238,7 +228,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__add_plugin() */ - /*------------------------------------------------------------------------- * Function: H5PL__find_plugin_in_cache * @@ -253,12 +242,13 @@ done: /* See the other use of H5PL_GET_LIB_FUNC() for an explanation * for why we disable -Wpedantic here. */ -H5_GCC_DIAG_OFF(pedantic) +H5_GCC_DIAG_OFF("pedantic") herr_t -H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found, const void **plugin_info) +H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found, + const void **plugin_info) { - unsigned int u; /* iterator */ - herr_t ret_value = SUCCEED; + unsigned int u; /* iterator */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -268,20 +258,22 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f HDassert(plugin_info); /* Initialize output parameters */ - *found = FALSE; + *found = FALSE; *plugin_info = NULL; /* Loop over all the plugins, looking for one that matches */ for (u = 0; u < H5PL_num_plugins_g; u++) { /* If the plugin type (filter, etc.) and ID match, query the plugin for its info */ - if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->key->id == (H5PL_cache_g[u]).key.id)) { + if ((search_params->type == (H5PL_cache_g[u]).type) && + (search_params->key->id == (H5PL_cache_g[u]).key.id)) { - H5PL_get_plugin_info_t get_plugin_info_function; - const H5Z_class2_t *filter_info; + H5PL_get_plugin_info_t get_plugin_info_function; + const H5Z_class2_t * filter_info; /* Get the "get plugin info" function from the plugin. */ - if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) + if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC( + (H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") /* Call the "get plugin info" function */ @@ -289,7 +281,7 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") /* Set output parameters */ - *found = TRUE; + *found = TRUE; *plugin_info = filter_info; /* No need to continue processing */ @@ -302,5 +294,4 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_cache() */ -H5_GCC_DIAG_ON(pedantic) - +H5_GCC_DIAG_ON("pedantic") diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index 5ce9b87..43930ad 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -21,37 +21,33 @@ #include "H5PLpublic.h" /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* The key that will be used to find the plugin */ typedef union H5PL_key_t { - int id; /* I/O filters */ + int id; /* I/O filters */ struct { H5VL_get_connector_kind_t kind; /* Kind of VOL lookup to do */ union { - H5VL_class_value_t value; /* VOL connector value */ - const char *name; /* VOL connector name */ + H5VL_class_value_t value; /* VOL connector value */ + const char * name; /* VOL connector name */ } u; } vol; } H5PL_key_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -60,4 +56,3 @@ typedef union H5PL_key_t { H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, const H5PL_key_t *key); #endif /* _H5PLprivate_H */ - diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h index 8e022cc..a54cce0 100644 --- a/src/H5PLpublic.h +++ b/src/H5PLpublic.h @@ -18,7 +18,7 @@ #define _H5PLpublic_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ +#include "H5public.h" /* Generic Functions */ /*******************/ /* Public Typedefs */ @@ -26,39 +26,38 @@ /* Special string to indicate no plugin loading. */ -#define H5PL_NO_PLUGIN "::" +#define H5PL_NO_PLUGIN "::" /* Plugin type used by the plugin library */ typedef enum H5PL_type_t { - H5PL_TYPE_ERROR = -1, /* Error */ - H5PL_TYPE_FILTER = 0, /* Filter */ - H5PL_TYPE_VOL = 1, /* VOL driver */ - H5PL_TYPE_NONE = 2 /* This must be last! */ + H5PL_TYPE_ERROR = -1, /* Error */ + H5PL_TYPE_FILTER = 0, /* Filter */ + H5PL_TYPE_VOL = 1, /* VOL driver */ + H5PL_TYPE_NONE = 2 /* This must be last! */ } H5PL_type_t; /* Common dynamic plugin type flags used by the set/get_loading_state functions */ -#define H5PL_FILTER_PLUGIN 0x0001 -#define H5PL_VOL_PLUGIN 0x0002 -#define H5PL_ALL_PLUGIN 0xFFFF +#define H5PL_FILTER_PLUGIN 0x0001 +#define H5PL_VOL_PLUGIN 0x0002 +#define H5PL_ALL_PLUGIN 0xFFFF #ifdef __cplusplus extern "C" { #endif /* plugin state */ -H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_control_mask); -H5_DLL herr_t H5PLget_loading_state(unsigned int *plugin_control_mask /*out*/); -H5_DLL herr_t H5PLappend(const char *search_path); -H5_DLL herr_t H5PLprepend(const char *search_path); -H5_DLL herr_t H5PLreplace(const char *search_path, unsigned int index); -H5_DLL herr_t H5PLinsert(const char *search_path, unsigned int index); -H5_DLL herr_t H5PLremove(unsigned int index); +H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_control_mask); +H5_DLL herr_t H5PLget_loading_state(unsigned int *plugin_control_mask /*out*/); +H5_DLL herr_t H5PLappend(const char *search_path); +H5_DLL herr_t H5PLprepend(const char *search_path); +H5_DLL herr_t H5PLreplace(const char *search_path, unsigned int index); +H5_DLL herr_t H5PLinsert(const char *search_path, unsigned int index); +H5_DLL herr_t H5PLremove(unsigned int index); H5_DLL ssize_t H5PLget(unsigned int index, char *path_buf /*out*/, size_t buf_size); -H5_DLL herr_t H5PLsize(unsigned int *num_paths /*out*/); +H5_DLL herr_t H5PLsize(unsigned int *num_paths /*out*/); #ifdef __cplusplus } #endif #endif /* _H5PLpublic_H */ - diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index 166a35f..8fc9167 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -24,45 +24,39 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ /* Attribute creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_ACRT[1] = {{ - "attribute create", /* Class name for debugging */ - H5P_TYPE_ATTRIBUTE_CREATE, /* Class type */ + "attribute create", /* Class name for debugging */ + H5P_TYPE_ATTRIBUTE_CREATE, /* Class type */ &H5P_CLS_STRING_CREATE_g, /* Parent class */ &H5P_CLS_ATTRIBUTE_CREATE_g, /* Pointer to class */ @@ -70,16 +64,14 @@ const H5P_libclass_t H5P_CLS_ACRT[1] = {{ &H5P_LST_ATTRIBUTE_CREATE_ID_g, /* Pointer to default property list ID */ NULL, /* Default property registration routine */ - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 5ce12b4..737140a 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -26,20 +26,18 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -47,101 +45,100 @@ /* ========= Dataset Access properties ============ */ /* Definitions for size of raw data chunk cache(slots) */ -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF H5D_CHUNK_CACHE_NSLOTS_DEFAULT -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_chunk_cache_nslots -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_chunk_cache_nslots +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF H5D_CHUNK_CACHE_NSLOTS_DEFAULT +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_chunk_cache_nslots +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_chunk_cache_nslots /* Definition for size of raw data chunk cache(bytes) */ -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF H5D_CHUNK_CACHE_NBYTES_DEFAULT -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_chunk_cache_nbytes -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_chunk_cache_nbytes +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF H5D_CHUNK_CACHE_NBYTES_DEFAULT +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_chunk_cache_nbytes +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_chunk_cache_nbytes /* Definition for preemption read chunks first */ -#define H5D_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) -#define H5D_ACS_PREEMPT_READ_CHUNKS_DEF H5D_CHUNK_CACHE_W0_DEFAULT -#define H5D_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double -#define H5D_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double +#define H5D_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) +#define H5D_ACS_PREEMPT_READ_CHUNKS_DEF H5D_CHUNK_CACHE_W0_DEFAULT +#define H5D_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double +#define H5D_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double /* Definitions for VDS view option */ -#define H5D_ACS_VDS_VIEW_SIZE sizeof(H5D_vds_view_t) -#define H5D_ACS_VDS_VIEW_DEF H5D_VDS_LAST_AVAILABLE -#define H5D_ACS_VDS_VIEW_ENC H5P__dacc_vds_view_enc -#define H5D_ACS_VDS_VIEW_DEC H5P__dacc_vds_view_dec +#define H5D_ACS_VDS_VIEW_SIZE sizeof(H5D_vds_view_t) +#define H5D_ACS_VDS_VIEW_DEF H5D_VDS_LAST_AVAILABLE +#define H5D_ACS_VDS_VIEW_ENC H5P__dacc_vds_view_enc +#define H5D_ACS_VDS_VIEW_DEC H5P__dacc_vds_view_dec /* Definitions for VDS printf gap */ -#define H5D_ACS_VDS_PRINTF_GAP_SIZE sizeof(hsize_t) -#define H5D_ACS_VDS_PRINTF_GAP_DEF (hsize_t)0 -#define H5D_ACS_VDS_PRINTF_GAP_ENC H5P__encode_hsize_t -#define H5D_ACS_VDS_PRINTF_GAP_DEC H5P__decode_hsize_t +#define H5D_ACS_VDS_PRINTF_GAP_SIZE sizeof(hsize_t) +#define H5D_ACS_VDS_PRINTF_GAP_DEF (hsize_t)0 +#define H5D_ACS_VDS_PRINTF_GAP_ENC H5P__encode_hsize_t +#define H5D_ACS_VDS_PRINTF_GAP_DEC H5P__decode_hsize_t /* Definitions for VDS file prefix */ -#define H5D_ACS_VDS_PREFIX_SIZE sizeof(char *) -#define H5D_ACS_VDS_PREFIX_DEF NULL /*default is no prefix */ -#define H5D_ACS_VDS_PREFIX_SET H5P__dapl_vds_file_pref_set -#define H5D_ACS_VDS_PREFIX_GET H5P__dapl_vds_file_pref_get -#define H5D_ACS_VDS_PREFIX_ENC H5P__dapl_vds_file_pref_enc -#define H5D_ACS_VDS_PREFIX_DEC H5P__dapl_vds_file_pref_dec -#define H5D_ACS_VDS_PREFIX_DEL H5P__dapl_vds_file_pref_del -#define H5D_ACS_VDS_PREFIX_COPY H5P__dapl_vds_file_pref_copy -#define H5D_ACS_VDS_PREFIX_CMP H5P__dapl_vds_file_pref_cmp -#define H5D_ACS_VDS_PREFIX_CLOSE H5P__dapl_vds_file_pref_close +#define H5D_ACS_VDS_PREFIX_SIZE sizeof(char *) +#define H5D_ACS_VDS_PREFIX_DEF NULL /*default is no prefix */ +#define H5D_ACS_VDS_PREFIX_SET H5P__dapl_vds_file_pref_set +#define H5D_ACS_VDS_PREFIX_GET H5P__dapl_vds_file_pref_get +#define H5D_ACS_VDS_PREFIX_ENC H5P__dapl_vds_file_pref_enc +#define H5D_ACS_VDS_PREFIX_DEC H5P__dapl_vds_file_pref_dec +#define H5D_ACS_VDS_PREFIX_DEL H5P__dapl_vds_file_pref_del +#define H5D_ACS_VDS_PREFIX_COPY H5P__dapl_vds_file_pref_copy +#define H5D_ACS_VDS_PREFIX_CMP H5P__dapl_vds_file_pref_cmp +#define H5D_ACS_VDS_PREFIX_CLOSE H5P__dapl_vds_file_pref_close /* Definition for append flush */ -#define H5D_ACS_APPEND_FLUSH_SIZE sizeof(H5D_append_flush_t) -#define H5D_ACS_APPEND_FLUSH_DEF {0,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},NULL,NULL} +#define H5D_ACS_APPEND_FLUSH_SIZE sizeof(H5D_append_flush_t) +#define H5D_ACS_APPEND_FLUSH_DEF \ + { \ + 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + NULL, NULL \ + } /* Definitions for external file prefix */ -#define H5D_ACS_EFILE_PREFIX_SIZE sizeof(char *) -#define H5D_ACS_EFILE_PREFIX_DEF NULL /*default is no prefix */ -#define H5D_ACS_EFILE_PREFIX_SET H5P__dapl_efile_pref_set -#define H5D_ACS_EFILE_PREFIX_GET H5P__dapl_efile_pref_get -#define H5D_ACS_EFILE_PREFIX_ENC H5P__dapl_efile_pref_enc -#define H5D_ACS_EFILE_PREFIX_DEC H5P__dapl_efile_pref_dec -#define H5D_ACS_EFILE_PREFIX_DEL H5P__dapl_efile_pref_del -#define H5D_ACS_EFILE_PREFIX_COPY H5P__dapl_efile_pref_copy -#define H5D_ACS_EFILE_PREFIX_CMP H5P__dapl_efile_pref_cmp -#define H5D_ACS_EFILE_PREFIX_CLOSE H5P__dapl_efile_pref_close +#define H5D_ACS_EFILE_PREFIX_SIZE sizeof(char *) +#define H5D_ACS_EFILE_PREFIX_DEF NULL /*default is no prefix */ +#define H5D_ACS_EFILE_PREFIX_SET H5P__dapl_efile_pref_set +#define H5D_ACS_EFILE_PREFIX_GET H5P__dapl_efile_pref_get +#define H5D_ACS_EFILE_PREFIX_ENC H5P__dapl_efile_pref_enc +#define H5D_ACS_EFILE_PREFIX_DEC H5P__dapl_efile_pref_dec +#define H5D_ACS_EFILE_PREFIX_DEL H5P__dapl_efile_pref_del +#define H5D_ACS_EFILE_PREFIX_COPY H5P__dapl_efile_pref_copy +#define H5D_ACS_EFILE_PREFIX_CMP H5P__dapl_efile_pref_cmp +#define H5D_ACS_EFILE_PREFIX_CLOSE H5P__dapl_efile_pref_close /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Property class callbacks */ static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass); -static herr_t H5P__encode_chunk_cache_nslots(const void *value, void **_pp, - size_t *size); +static herr_t H5P__encode_chunk_cache_nslots(const void *value, void **_pp, size_t *size); static herr_t H5P__decode_chunk_cache_nslots(const void **_pp, void *_value); -static herr_t H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, - size_t *size); +static herr_t H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, size_t *size); static herr_t H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value); /* Property list callbacks */ static herr_t H5P__dacc_vds_view_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dacc_vds_view_dec(const void **pp, void *value); -static herr_t H5P__dapl_vds_file_pref_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dapl_vds_file_pref_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__dapl_vds_file_pref_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dapl_vds_file_pref_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dapl_vds_file_pref_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__dapl_vds_file_pref_dec(const void **_pp, void *value); -static herr_t H5P__dapl_vds_file_pref_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dapl_vds_file_pref_copy(const char* name, size_t size, void* value); -static int H5P__dapl_vds_file_pref_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__dapl_vds_file_pref_close(const char* name, size_t size, void* value); +static herr_t H5P__dapl_vds_file_pref_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dapl_vds_file_pref_copy(const char *name, size_t size, void *value); +static int H5P__dapl_vds_file_pref_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dapl_vds_file_pref_close(const char *name, size_t size, void *value); /* Property list callbacks */ -static herr_t H5P__dapl_efile_pref_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dapl_efile_pref_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__dapl_efile_pref_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dapl_efile_pref_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dapl_efile_pref_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__dapl_efile_pref_dec(const void **_pp, void *value); -static herr_t H5P__dapl_efile_pref_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dapl_efile_pref_copy(const char* name, size_t size, void* value); -static int H5P__dapl_efile_pref_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__dapl_efile_pref_close(const char* name, size_t size, void* value); - +static herr_t H5P__dapl_efile_pref_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dapl_efile_pref_copy(const char *name, size_t size, void *value); +static int H5P__dapl_efile_pref_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dapl_efile_pref_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -149,39 +146,38 @@ static herr_t H5P__dapl_efile_pref_close(const char* name, size_t size, void* va /* Dataset access property list class library initialization object */ const H5P_libclass_t H5P_CLS_DACC[1] = {{ - "dataset access", /* Class name for debugging */ - H5P_TYPE_DATASET_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class */ - &H5P_CLS_DATASET_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_DATASET_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P__dacc_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "dataset access", /* Class name for debugging */ + H5P_TYPE_DATASET_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class */ + &H5P_CLS_DATASET_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_ACCESS_ID_g, /* Pointer to default property list ID */ + H5P__dacc_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const H5D_append_flush_t H5D_def_append_flush_g = H5D_ACS_APPEND_FLUSH_DEF; /* Default setting for append flush */ -static const char *H5D_def_efile_prefix_g = H5D_ACS_EFILE_PREFIX_DEF; /* Default external file prefix string */ -static const char *H5D_def_vds_prefix_g = H5D_ACS_VDS_PREFIX_DEF; /* Default vds prefix string */ +static const H5D_append_flush_t H5D_def_append_flush_g = + H5D_ACS_APPEND_FLUSH_DEF; /* Default setting for append flush */ +static const char *H5D_def_efile_prefix_g = + H5D_ACS_EFILE_PREFIX_DEF; /* Default external file prefix string */ +static const char *H5D_def_vds_prefix_g = H5D_ACS_VDS_PREFIX_DEF; /* Default vds prefix string */ - /*------------------------------------------------------------------------- * Function: H5P__dacc_reg_prop * @@ -194,65 +190,69 @@ static const char *H5D_def_vds_prefix_g = H5D_ACS_VDS_PREFIX_DEF; static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass) { - size_t rdcc_nslots = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ - size_t rdcc_nbytes = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ - double rdcc_w0 = H5D_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ - H5D_vds_view_t virtual_view = H5D_ACS_VDS_VIEW_DEF; /* Default VDS view option */ - hsize_t printf_gap = H5D_ACS_VDS_PRINTF_GAP_DEF; /* Default VDS printf gap */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t rdcc_nslots = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ + size_t rdcc_nbytes = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ + double rdcc_w0 = H5D_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ + H5D_vds_view_t virtual_view = H5D_ACS_VDS_VIEW_DEF; /* Default VDS view option */ + hsize_t printf_gap = H5D_ACS_VDS_PRINTF_GAP_DEF; /* Default VDS printf gap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the size of raw data chunk cache (elements) */ - if(H5P__register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, - NULL, NULL, NULL, H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC, H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, + &rdcc_nslots, NULL, NULL, NULL, H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC, + H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache(bytes) */ - if(H5P__register_real(pclass, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &rdcc_nbytes, - NULL, NULL, NULL, H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC, H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE, + &rdcc_nbytes, NULL, NULL, NULL, H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC, + H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the preemption for reading chunks */ - if(H5P__register_real(pclass, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, H5D_ACS_PREEMPT_READ_CHUNKS_SIZE, &rdcc_w0, - NULL, NULL, NULL, H5D_ACS_PREEMPT_READ_CHUNKS_ENC, H5D_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, H5D_ACS_PREEMPT_READ_CHUNKS_SIZE, + &rdcc_w0, NULL, NULL, NULL, H5D_ACS_PREEMPT_READ_CHUNKS_ENC, + H5D_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the VDS view option */ - if(H5P__register_real(pclass, H5D_ACS_VDS_VIEW_NAME, H5D_ACS_VDS_VIEW_SIZE, &virtual_view, - NULL, NULL, NULL, H5D_ACS_VDS_VIEW_ENC, H5D_ACS_VDS_VIEW_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_ACS_VDS_VIEW_NAME, H5D_ACS_VDS_VIEW_SIZE, &virtual_view, NULL, NULL, + NULL, H5D_ACS_VDS_VIEW_ENC, H5D_ACS_VDS_VIEW_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the VDS printf gap */ - if(H5P__register_real(pclass, H5D_ACS_VDS_PRINTF_GAP_NAME, H5D_ACS_VDS_PRINTF_GAP_SIZE, &printf_gap, - NULL, NULL, NULL, H5D_ACS_VDS_PRINTF_GAP_ENC, H5D_ACS_VDS_PRINTF_GAP_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_ACS_VDS_PRINTF_GAP_NAME, H5D_ACS_VDS_PRINTF_GAP_SIZE, &printf_gap, + NULL, NULL, NULL, H5D_ACS_VDS_PRINTF_GAP_ENC, H5D_ACS_VDS_PRINTF_GAP_DEC, NULL, + NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for vds prefix */ - if(H5P__register_real(pclass, H5D_ACS_VDS_PREFIX_NAME, H5D_ACS_VDS_PREFIX_SIZE, &H5D_def_vds_prefix_g, - NULL, H5D_ACS_VDS_PREFIX_SET, H5D_ACS_VDS_PREFIX_GET, H5D_ACS_VDS_PREFIX_ENC, H5D_ACS_VDS_PREFIX_DEC, - H5D_ACS_VDS_PREFIX_DEL, H5D_ACS_VDS_PREFIX_COPY, H5D_ACS_VDS_PREFIX_CMP, H5D_ACS_VDS_PREFIX_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_VDS_PREFIX_NAME, H5D_ACS_VDS_PREFIX_SIZE, &H5D_def_vds_prefix_g, + NULL, H5D_ACS_VDS_PREFIX_SET, H5D_ACS_VDS_PREFIX_GET, H5D_ACS_VDS_PREFIX_ENC, + H5D_ACS_VDS_PREFIX_DEC, H5D_ACS_VDS_PREFIX_DEL, H5D_ACS_VDS_PREFIX_COPY, + H5D_ACS_VDS_PREFIX_CMP, H5D_ACS_VDS_PREFIX_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register info for append flush */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_ACS_APPEND_FLUSH_NAME, H5D_ACS_APPEND_FLUSH_SIZE, &H5D_def_append_flush_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_APPEND_FLUSH_NAME, H5D_ACS_APPEND_FLUSH_SIZE, + &H5D_def_append_flush_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external file prefix */ - if(H5P__register_real(pclass, H5D_ACS_EFILE_PREFIX_NAME, H5D_ACS_EFILE_PREFIX_SIZE, &H5D_def_efile_prefix_g, - NULL, H5D_ACS_EFILE_PREFIX_SET, H5D_ACS_EFILE_PREFIX_GET, H5D_ACS_EFILE_PREFIX_ENC, H5D_ACS_EFILE_PREFIX_DEC, - H5D_ACS_EFILE_PREFIX_DEL, H5D_ACS_EFILE_PREFIX_COPY, H5D_ACS_EFILE_PREFIX_CMP, H5D_ACS_EFILE_PREFIX_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_EFILE_PREFIX_NAME, H5D_ACS_EFILE_PREFIX_SIZE, + &H5D_def_efile_prefix_g, NULL, H5D_ACS_EFILE_PREFIX_SET, H5D_ACS_EFILE_PREFIX_GET, + H5D_ACS_EFILE_PREFIX_ENC, H5D_ACS_EFILE_PREFIX_DEC, H5D_ACS_EFILE_PREFIX_DEL, + H5D_ACS_EFILE_PREFIX_COPY, H5D_ACS_EFILE_PREFIX_CMP, + H5D_ACS_EFILE_PREFIX_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dacc_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_set * @@ -264,7 +264,7 @@ done: */ static herr_t H5P__dapl_vds_file_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -277,7 +277,6 @@ H5P__dapl_vds_file_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_get * @@ -289,7 +288,7 @@ H5P__dapl_vds_file_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU */ static herr_t H5P__dapl_vds_file_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -302,7 +301,6 @@ H5P__dapl_vds_file_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_enc * @@ -316,44 +314,43 @@ H5P__dapl_vds_file_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU static herr_t H5P__dapl_vds_file_pref_enc(const void *value, void **_pp, size_t *size) { - const char *vds_file_pref = *(const char * const *)value; - uint8_t **pp = (uint8_t **)_pp; - size_t len = 0; - uint64_t enc_value; - unsigned enc_size; + const char *vds_file_pref = *(const char *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + size_t len = 0; + uint64_t enc_value; + unsigned enc_size; FUNC_ENTER_NOAPI_NOINIT_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* calculate prefix length */ - if(NULL != vds_file_pref) + if (NULL != vds_file_pref) len = HDstrlen(vds_file_pref); enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* encode the length of the prefix */ *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the prefix */ - if(NULL != vds_file_pref) { + if (NULL != vds_file_pref) { H5MM_memcpy(*(char **)pp, vds_file_pref, len); *pp += len; } /* end if */ - } /* end if */ + } /* end if */ *size += (1 + enc_size); - if(NULL != vds_file_pref) + if (NULL != vds_file_pref) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_dec * @@ -367,12 +364,12 @@ H5P__dapl_vds_file_pref_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dapl_vds_file_pref_dec(const void **_pp, void *_value) { - char **vds_file_pref = (char **)_value; - const uint8_t **pp = (const uint8_t **)_pp; - size_t len; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; + char ** vds_file_pref = (char **)_value; + const uint8_t **pp = (const uint8_t **)_pp; + size_t len; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -389,9 +386,9 @@ H5P__dapl_vds_file_pref_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = (size_t)enc_value; - if(0 != len) { + if (0 != len) { /* Make a copy of the user's prefix string */ - if(NULL == (*vds_file_pref = (char *)H5MM_malloc(len + 1))) + if (NULL == (*vds_file_pref = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix") HDstrncpy(*vds_file_pref, *(const char **)pp, len); (*vds_file_pref)[len] = '\0'; @@ -405,7 +402,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dapl_vds_file_pref_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_del * @@ -416,7 +412,7 @@ done: */ static herr_t H5P__dapl_vds_file_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -427,7 +423,6 @@ H5P__dapl_vds_file_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_del() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_copy * @@ -448,7 +443,6 @@ H5P__dapl_vds_file_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_cmp * @@ -462,24 +456,23 @@ H5P__dapl_vds_file_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNU static int H5P__dapl_vds_file_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const char *pref1 = *(const char * const *)value1; - const char *pref2 = *(const char * const *)value2; - int ret_value = 0; + const char *pref1 = *(const char *const *)value1; + const char *pref2 = *(const char *const *)value2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(NULL == pref1 && NULL != pref2) + if (NULL == pref1 && NULL != pref2) HGOTO_DONE(1); - if(NULL != pref1 && NULL == pref2) + if (NULL != pref1 && NULL == pref2) HGOTO_DONE(-1); - if(NULL != pref1 && NULL != pref2) + if (NULL != pref1 && NULL != pref2) ret_value = HDstrcmp(pref1, pref2); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dapl_vds_file_pref_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_close * @@ -500,7 +493,6 @@ H5P__dapl_vds_file_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UN FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_close() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_set * @@ -512,7 +504,7 @@ H5P__dapl_vds_file_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UN */ static herr_t H5P__dapl_efile_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -525,7 +517,6 @@ H5P__dapl_efile_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_get * @@ -537,7 +528,7 @@ H5P__dapl_efile_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED */ static herr_t H5P__dapl_efile_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -550,7 +541,6 @@ H5P__dapl_efile_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_enc * @@ -564,44 +554,43 @@ H5P__dapl_efile_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED static herr_t H5P__dapl_efile_pref_enc(const void *value, void **_pp, size_t *size) { - const char *efile_pref = *(const char * const *)value; - uint8_t **pp = (uint8_t **)_pp; - size_t len = 0; - uint64_t enc_value; - unsigned enc_size; + const char *efile_pref = *(const char *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + size_t len = 0; + uint64_t enc_value; + unsigned enc_size; FUNC_ENTER_NOAPI_NOINIT_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* calculate prefix length */ - if(NULL != efile_pref) + if (NULL != efile_pref) len = HDstrlen(efile_pref); enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* encode the length of the prefix */ *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the prefix */ - if(NULL != efile_pref) { + if (NULL != efile_pref) { H5MM_memcpy(*(char **)pp, efile_pref, len); *pp += len; } /* end if */ - } /* end if */ + } /* end if */ *size += (1 + enc_size); - if(NULL != efile_pref) + if (NULL != efile_pref) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_dec * @@ -615,12 +604,12 @@ H5P__dapl_efile_pref_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dapl_efile_pref_dec(const void **_pp, void *_value) { - char **efile_pref = (char **)_value; - const uint8_t **pp = (const uint8_t **)_pp; - size_t len; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; + char ** efile_pref = (char **)_value; + const uint8_t **pp = (const uint8_t **)_pp; + size_t len; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -637,9 +626,9 @@ H5P__dapl_efile_pref_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = (size_t)enc_value; - if(0 != len) { + if (0 != len) { /* Make a copy of the user's prefix string */ - if(NULL == (*efile_pref = (char *)H5MM_malloc(len + 1))) + if (NULL == (*efile_pref = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix") HDstrncpy(*efile_pref, *(const char **)pp, len); (*efile_pref)[len] = '\0'; @@ -653,7 +642,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dapl_efile_pref_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_del * @@ -664,7 +652,7 @@ done: */ static herr_t H5P__dapl_efile_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -675,7 +663,6 @@ H5P__dapl_efile_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_del() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_copy * @@ -696,7 +683,6 @@ H5P__dapl_efile_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_cmp * @@ -710,24 +696,23 @@ H5P__dapl_efile_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED static int H5P__dapl_efile_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const char *pref1 = *(const char * const *)value1; - const char *pref2 = *(const char * const *)value2; - int ret_value = 0; + const char *pref1 = *(const char *const *)value1; + const char *pref2 = *(const char *const *)value2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(NULL == pref1 && NULL != pref2) + if (NULL == pref1 && NULL != pref2) HGOTO_DONE(1); - if(NULL != pref1 && NULL == pref2) + if (NULL != pref1 && NULL == pref2) HGOTO_DONE(-1); - if(NULL != pref1 && NULL != pref2) + if (NULL != pref1 && NULL != pref2) ret_value = HDstrcmp(pref1, pref2); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dapl_efile_pref_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_close * @@ -748,7 +733,6 @@ H5P__dapl_efile_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_chunk_cache * @@ -776,34 +760,35 @@ H5P__dapl_efile_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "izzd", dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Check arguments. Note that we allow negative values - they are * considered to "unset" the property. */ - if(rdcc_w0 > (double)1.0f) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); + if (rdcc_w0 > (double)1.0f) + HGOTO_ERROR( + H5E_ARGS, H5E_BADVALUE, FAIL, + "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dapl_id,H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(dapl_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set sizes */ - if(H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of chunks"); - if(H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size"); - if(H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks"); + if (H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of chunks"); + if (H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size"); + if (H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_chunk_cache() */ - /*------------------------------------------------------------------------- * Function: H5Pget_chunk_cache * @@ -821,9 +806,9 @@ done: herr_t H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0) { - H5P_genplist_t *plist; /* Property list pointer */ - H5P_genplist_t *def_plist; /* Default file access property list */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t *def_plist; /* Default file access property list */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*z*z*d", dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0); @@ -840,31 +825,30 @@ H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, doub * from the default fapl is used. */ if (rdcc_nslots) { if (H5P_get(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache number of slots"); if (*rdcc_nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) if (H5P_get(def_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default data cache number of slots"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get default data cache number of slots"); } /* end if */ if (rdcc_nbytes) { if (H5P_get(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache byte size"); if (*rdcc_nbytes == H5D_CHUNK_CACHE_NBYTES_DEFAULT) if (H5P_get(def_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default data cache byte size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get default data cache byte size"); } /* end if */ if (rdcc_w0) { if (H5P_get(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get preempt read chunks"); if (*rdcc_w0 < 0) if (H5P_get(def_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default preempt read chunks"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get default preempt read chunks"); } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_chunk_cache() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_chunk_cache_nslots * @@ -881,9 +865,9 @@ done: static herr_t H5P__encode_chunk_cache_nslots(const void *value, void **_pp, size_t *size) { - uint64_t enc_value; /* Property value to encode */ + uint64_t enc_value; /* Property value to encode */ uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ + unsigned enc_size; /* Size of encoded property */ FUNC_ENTER_PACKAGE_NOERR @@ -893,33 +877,32 @@ H5P__encode_chunk_cache_nslots(const void *value, void **_pp, size_t *size) /* Determine if this is the default value, in which case only encode * enc_size (as 255). Also set size needed for encoding. */ - if(*(const size_t *)value == H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF) { + if (*(const size_t *)value == H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF) { enc_size = 0; *size += 1; } /* end if */ else { - enc_value = (uint64_t)*(const size_t *)value; - enc_size = H5VM_limit_enc_size(enc_value); + enc_value = (uint64_t) * (const size_t *)value; + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size > 0); *size += (1 + enc_size); } /* end else */ HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)enc_size; /* Encode the value if necessary */ - if(enc_size != 0) { + if (enc_size != 0) { UINT64ENCODE_VAR(*pp, enc_value, enc_size); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_chunk_cache_nslots() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_chunk_cache_nslots * @@ -936,10 +919,10 @@ H5P__encode_chunk_cache_nslots(const void *value, void **_pp, size_t *size) static herr_t H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) { - size_t *value = (size_t *)_value; /* Property value to return */ - const uint8_t **pp = (const uint8_t **)_pp; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ + size_t * value = (size_t *)_value; /* Property value to return */ + const uint8_t **pp = (const uint8_t **)_pp; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ FUNC_ENTER_PACKAGE_NOERR @@ -955,7 +938,7 @@ H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) /* Determine if enc_size indicates that this is the default value, in which * case set value to H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF and return */ - if(enc_size == 0) + if (enc_size == 0) *value = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; else { /* Decode the value */ @@ -966,7 +949,6 @@ H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_chunk_cache_nslots() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_chunk_cache_nbytes * @@ -983,9 +965,9 @@ H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) static herr_t H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, size_t *size) { - uint64_t enc_value; /* Property value to encode */ + uint64_t enc_value; /* Property value to encode */ uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ + unsigned enc_size; /* Size of encoded property */ FUNC_ENTER_PACKAGE_NOERR @@ -995,33 +977,32 @@ H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, size_t *size) /* Determine if this is the default value, in which case only encode * enc_size (as 255). Also set size needed for encoding. */ - if(*(const size_t *)value == H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF) { + if (*(const size_t *)value == H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF) { enc_size = 0; *size += 1; } /* end if */ else { - enc_value = (uint64_t)*(const size_t *)value; - enc_size = H5VM_limit_enc_size(enc_value); + enc_value = (uint64_t) * (const size_t *)value; + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size > 0); *size += (1 + enc_size); } /* end else */ HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)enc_size; /* Encode the value if necessary */ - if(enc_size != 0) { + if (enc_size != 0) { UINT64ENCODE_VAR(*pp, enc_value, enc_size); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_chunk_cache_nbytes() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_chunk_cache_nbytes * @@ -1038,10 +1019,10 @@ H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, size_t *size) static herr_t H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) { - size_t *value = (size_t *)_value; /* Property value to return */ - const uint8_t **pp = (const uint8_t **)_pp; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ + size_t * value = (size_t *)_value; /* Property value to return */ + const uint8_t **pp = (const uint8_t **)_pp; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ FUNC_ENTER_PACKAGE_NOERR @@ -1057,7 +1038,7 @@ H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) /* Determine if enc_size indicates that this is the default value, in which * case set value to H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF and return */ - if(enc_size == 0) + if (enc_size == 0) *value = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; else { /* Decode the value */ @@ -1068,7 +1049,6 @@ H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_chunk_cache_nbytes() */ - /*------------------------------------------------------------------------- * Function: H5Pset_virtual_view * @@ -1089,29 +1069,28 @@ H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) herr_t H5Pset_virtual_view(hid_t plist_id, H5D_vds_view_t view) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDv", plist_id, view); /* Check argument */ - if((view != H5D_VDS_FIRST_MISSING) && (view != H5D_VDS_LAST_AVAILABLE)) + if ((view != H5D_VDS_FIRST_MISSING) && (view != H5D_VDS_LAST_AVAILABLE)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid bounds option") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_ACS_VDS_VIEW_NAME, &view) < 0) + if (H5P_set(plist, H5D_ACS_VDS_VIEW_NAME, &view) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_virtual_view() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_view * @@ -1126,26 +1105,25 @@ done: herr_t H5Pget_virtual_view(hid_t plist_id, H5D_vds_view_t *view) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Dv", plist_id, view); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value from property list */ - if(view) - if(H5P_get(plist, H5D_ACS_VDS_VIEW_NAME, view) < 0) + if (view) + if (H5P_get(plist, H5D_ACS_VDS_VIEW_NAME, view) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_view() */ - /*------------------------------------------------------------------------- * Function: H5P__dacc_vds_view_enc * @@ -1160,7 +1138,7 @@ static herr_t H5P__dacc_vds_view_enc(const void *value, void **_pp, size_t *size) { const H5D_vds_view_t *view = (const H5D_vds_view_t *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1168,7 +1146,7 @@ H5P__dacc_vds_view_enc(const void *value, void **_pp, size_t *size) HDassert(view); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode EDC property */ *(*pp)++ = (uint8_t)*view; @@ -1178,7 +1156,6 @@ H5P__dacc_vds_view_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dacc_vds_view_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dacc_vds_view_dec * @@ -1193,7 +1170,7 @@ static herr_t H5P__dacc_vds_view_dec(const void **_pp, void *_value) { H5D_vds_view_t *view = (H5D_vds_view_t *)_value; - const uint8_t **pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1203,12 +1180,11 @@ H5P__dacc_vds_view_dec(const void **_pp, void *_value) HDassert(view); /* Decode EDC property */ - *view = (H5D_vds_view_t)*(*pp)++; + *view = (H5D_vds_view_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dacc_vds_view_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_virtual_printf_gap * @@ -1235,29 +1211,28 @@ H5P__dacc_vds_view_dec(const void **_pp, void *_value) herr_t H5Pset_virtual_printf_gap(hid_t plist_id, hsize_t gap_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, gap_size); /* Check argument */ - if(gap_size == HSIZE_UNDEF) + if (gap_size == HSIZE_UNDEF) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid printf gap size") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &gap_size) < 0) + if (H5P_set(plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &gap_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_virtual_printf_gap() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_printf_gap * @@ -1273,26 +1248,25 @@ done: herr_t H5Pget_virtual_printf_gap(hid_t plist_id, hsize_t *gap_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", plist_id, gap_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value from property list */ - if(gap_size) - if(H5P_get(plist, H5D_ACS_VDS_PRINTF_GAP_NAME, gap_size) < 0) + if (gap_size) + if (H5P_get(plist, H5D_ACS_VDS_PRINTF_GAP_NAME, gap_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_printf_gap() */ - /*------------------------------------------------------------------------- * Function: H5Pset_append_flush * @@ -1309,55 +1283,55 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_append_flush(hid_t plist_id, unsigned ndims, const hsize_t *boundary, H5D_append_cb_t func, void *udata) +H5Pset_append_flush(hid_t plist_id, unsigned ndims, const hsize_t *boundary, H5D_append_cb_t func, + void *udata) { - H5P_genplist_t *plist; /* Property list pointer */ - H5D_append_flush_t info; /* Property for append flush parameters */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5D_append_flush_t info; /* Property for append flush parameters */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIu*hx*x", plist_id, ndims, boundary, func, udata); /* Check arguments */ - if(0 == ndims) + if (0 == ndims) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality cannot be zero") - if(ndims > H5S_MAX_RANK) + if (ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality is too large") - if(!boundary) + if (!boundary) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no boundary dimensions specified") /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ - if(!func && udata) + if (!func && udata) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set up values */ info.ndims = ndims; - info.func = func; + info.func = func; info.udata = udata; HDmemset(info.boundary, 0, sizeof(info.boundary)); /* boundary can be 0 to indicate no boundary is set */ - for(u = 0; u < ndims; u++) { - if(boundary[u] != (boundary[u] & 0xffffffff)) /* negative value (including H5S_UNLIMITED) */ + for (u = 0; u < ndims; u++) { + if (boundary[u] != (boundary[u] & 0xffffffff)) /* negative value (including H5S_UNLIMITED) */ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all boundary dimensions must be less than 2^32") info.boundary[u] = boundary[u]; /* Store user's boundary dimensions */ - } /* end for */ + } /* end for */ /* Set values */ - if(H5P_set(plist, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) + if (H5P_set(plist, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set append flush") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_append_flush() */ - /*------------------------------------------------------------------------- * Function: H5Pget_append_flush() * @@ -1373,39 +1347,38 @@ done: herr_t H5Pget_append_flush(hid_t plist_id, unsigned ndims, hsize_t boundary[], H5D_append_cb_t *func, void **udata) { - H5P_genplist_t *plist; /* property list pointer */ - H5D_append_flush_t info; - unsigned u; /* local index variable */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t * plist; /* property list pointer */ + H5D_append_flush_t info; + unsigned u; /* local index variable */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIu*h*x**x", plist_id, ndims, boundary, func, udata); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve info for append flush */ - if(H5P_get(plist, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) + if (H5P_get(plist, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object flush callback") /* Assign return values */ - if(boundary) { + if (boundary) { HDmemset(boundary, 0, ndims * sizeof(hsize_t)); - if(info.ndims > 0) - for(u = 0; u < info.ndims && u < ndims; u++) + if (info.ndims > 0) + for (u = 0; u < info.ndims && u < ndims; u++) boundary[u] = info.boundary[u]; } /* end if */ - if(func) + if (func) *func = info.func; - if(udata) + if (udata) *udata = info.udata; done: FUNC_LEAVE_API(ret_value) } /* H5Pget_append_flush() */ - /*------------------------------------------------------------------------- * Function: H5Pset_efile_prefix * @@ -1426,25 +1399,24 @@ done: herr_t H5Pset_efile_prefix(hid_t plist_id, const char *prefix) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, prefix); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set prefix */ - if(H5P_set(plist, H5D_ACS_EFILE_PREFIX_NAME, &prefix) < 0) + if (H5P_set(plist, H5D_ACS_EFILE_PREFIX_NAME, &prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_efile_prefix() */ - /*------------------------------------------------------------------------- * Function: H5Pget_efile_prefix * @@ -1458,32 +1430,32 @@ done: ssize_t H5Pget_efile_prefix(hid_t plist_id, char *prefix, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - char *my_prefix; /* Library's copy of the prefix */ - size_t len; /* Length of prefix string */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * my_prefix; /* Library's copy of the prefix */ + size_t len; /* Length of prefix string */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*sz", plist_id, prefix, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current prefix */ - if(H5P_peek(plist, H5D_ACS_EFILE_PREFIX_NAME, &my_prefix) < 0) + if (H5P_peek(plist, H5D_ACS_EFILE_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file prefix") /* Check for prefix being set */ - if(my_prefix) { + if (my_prefix) { /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); - if(prefix) { + if (prefix) { HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); - if(len >= size) + if (len >= size) prefix[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ else len = 0; @@ -1494,13 +1466,12 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_efile_prefix() */ - /*------------------------------------------------------------------------- * Function: H5Pset_virtual_prefix * * Purpose: Set a prefix to be applied to the path of any vds files * traversed. - * + * * If the prefix starts with ${ORIGIN}, this will be replaced by * the absolute path of the directory of the HDF5 file containing * the dataset. @@ -1516,25 +1487,24 @@ done: herr_t H5Pset_virtual_prefix(hid_t plist_id, const char *prefix) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, prefix); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set prefix */ - if(H5P_set(plist, H5D_ACS_VDS_PREFIX_NAME, &prefix) < 0) + if (H5P_set(plist, H5D_ACS_VDS_PREFIX_NAME, &prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_virtual_prefix() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_prefix * @@ -1550,32 +1520,32 @@ done: ssize_t H5Pget_virtual_prefix(hid_t plist_id, char *prefix, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - char *my_prefix; /* Library's copy of the prefix */ - size_t len; /* Length of prefix string */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * my_prefix; /* Library's copy of the prefix */ + size_t len; /* Length of prefix string */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*sz", plist_id, prefix, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current prefix */ - if(H5P_peek(plist, H5D_ACS_VDS_PREFIX_NAME, &my_prefix) < 0) + if (H5P_peek(plist, H5D_ACS_VDS_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vds file prefix") /* Check for prefix being set */ - if(my_prefix) { + if (my_prefix) { /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); - if(prefix) { + if (prefix) { HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); - if(len >= size) + if (len >= size) prefix[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ else len = 0; @@ -1585,4 +1555,3 @@ H5Pget_virtual_prefix(hid_t plist_id, char *prefix, size_t size) done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_prefix() */ - diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 064a9b8..957aac1 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -24,98 +24,206 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ -#define H5D_FRIEND /* Suppress error about including H5Dpkg */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5Zprivate.h" /* Data filters */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5Zprivate.h" /* Data filters */ /****************/ /* Local Macros */ /****************/ /* Define default layout information */ -#define H5D_DEF_STORAGE_COMPACT_INIT {(hbool_t)FALSE, (size_t)0, NULL} -#define H5D_DEF_STORAGE_CONTIG_INIT {HADDR_UNDEF, (hsize_t)0} -#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, H5D_COPS_BTREE, {{HADDR_UNDEF, NULL}}} -#define H5D_DEF_LAYOUT_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, (uint8_t)0, (unsigned)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, (unsigned)0, (uint32_t)0, (hsize_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {{{(uint8_t)0}}}} -#define H5D_DEF_STORAGE_VIRTUAL_INIT {{HADDR_UNDEF, 0}, 0, NULL, 0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, H5D_VDS_ERROR, HSIZE_UNDEF, -1, -1, FALSE} +#define H5D_DEF_STORAGE_COMPACT_INIT \ + { \ + (hbool_t) FALSE, (size_t)0, NULL \ + } +#define H5D_DEF_STORAGE_CONTIG_INIT \ + { \ + HADDR_UNDEF, (hsize_t)0 \ + } +#define H5D_DEF_STORAGE_CHUNK_INIT \ + { \ + H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, H5D_COPS_BTREE, \ + { \ + { \ + HADDR_UNDEF, NULL \ + } \ + } \ + } +#define H5D_DEF_LAYOUT_CHUNK_INIT \ + { \ + H5D_CHUNK_IDX_BTREE, (uint8_t)0, (unsigned)0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + (unsigned)0, (uint32_t)0, (hsize_t)0, (hsize_t)0, \ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + { \ + { \ + { \ + (uint8_t)0 \ + } \ + } \ + } \ + } +#define H5D_DEF_STORAGE_VIRTUAL_INIT \ + { \ + {HADDR_UNDEF, 0}, 0, NULL, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + H5D_VDS_ERROR, HSIZE_UNDEF, -1, -1, FALSE \ + } #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER -#define H5D_DEF_STORAGE_COMPACT {H5D_COMPACT, { .compact = H5D_DEF_STORAGE_COMPACT_INIT }} -#define H5D_DEF_STORAGE_CONTIG {H5D_CONTIGUOUS, { .contig = H5D_DEF_STORAGE_CONTIG_INIT }} -#define H5D_DEF_STORAGE_CHUNK {H5D_CHUNKED, { .chunk = H5D_DEF_STORAGE_CHUNK_INIT }} -#define H5D_DEF_STORAGE_VIRTUAL {H5D_VIRTUAL, { .virt = H5D_DEF_STORAGE_VIRTUAL_INIT }} -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_COMPACT, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_COMPACT} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CONTIG, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CONTIG} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CHUNK, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CHUNK} -#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, H5D_LOPS_VIRTUAL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_VIRTUAL} +#define H5D_DEF_STORAGE_COMPACT \ + { \ + H5D_COMPACT, \ + { \ + .compact = H5D_DEF_STORAGE_COMPACT_INIT \ + } \ + } +#define H5D_DEF_STORAGE_CONTIG \ + { \ + H5D_CONTIGUOUS, \ + { \ + .contig = H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } +#define H5D_DEF_STORAGE_CHUNK \ + { \ + H5D_CHUNKED, \ + { \ + .chunk = H5D_DEF_STORAGE_CHUNK_INIT \ + } \ + } +#define H5D_DEF_STORAGE_VIRTUAL \ + { \ + H5D_VIRTUAL, \ + { \ + .virt = H5D_DEF_STORAGE_VIRTUAL_INIT \ + } \ + } +#define H5D_DEF_LAYOUT_COMPACT \ + { \ + H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_COMPACT, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + H5D_DEF_STORAGE_COMPACT \ + } +#define H5D_DEF_LAYOUT_CONTIG \ + { \ + H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CONTIG, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + H5D_DEF_STORAGE_CONTIG \ + } +#define H5D_DEF_LAYOUT_CHUNK \ + { \ + H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CHUNK, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + H5D_DEF_STORAGE_CHUNK \ + } +#define H5D_DEF_LAYOUT_VIRTUAL \ + { \ + H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, H5D_LOPS_VIRTUAL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + H5D_DEF_STORAGE_VIRTUAL \ + } #else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Note that the compact & chunked layout initialization values are using the * contiguous layout initialization in the union, because the contiguous * layout is first in the union. These values are overridden in the * H5P__init_def_layout() routine. -QAK */ -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_COMPACT \ + { \ + H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + { \ + H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } +#define H5D_DEF_LAYOUT_CONTIG \ + { \ + H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + { \ + H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } +#define H5D_DEF_LAYOUT_CHUNK \ + { \ + H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + { \ + H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } +#define H5D_DEF_LAYOUT_VIRTUAL \ + { \ + H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + { \ + H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* ======== Dataset creation properties ======== */ /* Definitions for storage layout property */ -#define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) -#define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG -#define H5D_CRT_LAYOUT_SET H5P__dcrt_layout_set -#define H5D_CRT_LAYOUT_GET H5P__dcrt_layout_get -#define H5D_CRT_LAYOUT_ENC H5P__dcrt_layout_enc -#define H5D_CRT_LAYOUT_DEC H5P__dcrt_layout_dec -#define H5D_CRT_LAYOUT_DEL H5P__dcrt_layout_del -#define H5D_CRT_LAYOUT_COPY H5P__dcrt_layout_copy -#define H5D_CRT_LAYOUT_CMP H5P__dcrt_layout_cmp -#define H5D_CRT_LAYOUT_CLOSE H5P__dcrt_layout_close +#define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) +#define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG +#define H5D_CRT_LAYOUT_SET H5P__dcrt_layout_set +#define H5D_CRT_LAYOUT_GET H5P__dcrt_layout_get +#define H5D_CRT_LAYOUT_ENC H5P__dcrt_layout_enc +#define H5D_CRT_LAYOUT_DEC H5P__dcrt_layout_dec +#define H5D_CRT_LAYOUT_DEL H5P__dcrt_layout_del +#define H5D_CRT_LAYOUT_COPY H5P__dcrt_layout_copy +#define H5D_CRT_LAYOUT_CMP H5P__dcrt_layout_cmp +#define H5D_CRT_LAYOUT_CLOSE H5P__dcrt_layout_close /* Definitions for fill value. size=0 means fill value will be 0 as * library default; size=-1 means fill value is undefined. */ -#define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) -#define H5D_CRT_FILL_VALUE_DEF {{0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_FILL_VERSION_2, NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_FILL_TIME_IFSET, FALSE} -#define H5D_CRT_FILL_VALUE_SET H5P__dcrt_fill_value_set -#define H5D_CRT_FILL_VALUE_GET H5P__dcrt_fill_value_get -#define H5D_CRT_FILL_VALUE_ENC H5P__dcrt_fill_value_enc -#define H5D_CRT_FILL_VALUE_DEC H5P__dcrt_fill_value_dec -#define H5D_CRT_FILL_VALUE_DEL H5P__dcrt_fill_value_del -#define H5D_CRT_FILL_VALUE_COPY H5P__dcrt_fill_value_copy -#define H5D_CRT_FILL_VALUE_CMP H5P_fill_value_cmp -#define H5D_CRT_FILL_VALUE_CLOSE H5P__dcrt_fill_value_close +#define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) +#define H5D_CRT_FILL_VALUE_DEF \ + { \ + {0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_FILL_VERSION_2, NULL, 0, NULL, H5D_ALLOC_TIME_LATE, \ + H5D_FILL_TIME_IFSET, FALSE \ + } +#define H5D_CRT_FILL_VALUE_SET H5P__dcrt_fill_value_set +#define H5D_CRT_FILL_VALUE_GET H5P__dcrt_fill_value_get +#define H5D_CRT_FILL_VALUE_ENC H5P__dcrt_fill_value_enc +#define H5D_CRT_FILL_VALUE_DEC H5P__dcrt_fill_value_dec +#define H5D_CRT_FILL_VALUE_DEL H5P__dcrt_fill_value_del +#define H5D_CRT_FILL_VALUE_COPY H5P__dcrt_fill_value_copy +#define H5D_CRT_FILL_VALUE_CMP H5P_fill_value_cmp +#define H5D_CRT_FILL_VALUE_CLOSE H5P__dcrt_fill_value_close /* Definitions for space allocation time state */ -#define H5D_CRT_ALLOC_TIME_STATE_SIZE sizeof(unsigned) -#define H5D_CRT_ALLOC_TIME_STATE_DEF 1 -#define H5D_CRT_ALLOC_TIME_STATE_ENC H5P__encode_unsigned -#define H5D_CRT_ALLOC_TIME_STATE_DEC H5P__decode_unsigned +#define H5D_CRT_ALLOC_TIME_STATE_SIZE sizeof(unsigned) +#define H5D_CRT_ALLOC_TIME_STATE_DEF 1 +#define H5D_CRT_ALLOC_TIME_STATE_ENC H5P__encode_unsigned +#define H5D_CRT_ALLOC_TIME_STATE_DEC H5P__decode_unsigned /* Definitions for external file list */ #define H5D_CRT_EXT_FILE_LIST_SIZE sizeof(H5O_efl_t) -#define H5D_CRT_EXT_FILE_LIST_DEF {HADDR_UNDEF, 0, 0, NULL} -#define H5D_CRT_EXT_FILE_LIST_SET H5P__dcrt_ext_file_list_set -#define H5D_CRT_EXT_FILE_LIST_GET H5P__dcrt_ext_file_list_get -#define H5D_CRT_EXT_FILE_LIST_ENC H5P__dcrt_ext_file_list_enc -#define H5D_CRT_EXT_FILE_LIST_DEC H5P__dcrt_ext_file_list_dec -#define H5D_CRT_EXT_FILE_LIST_DEL H5P__dcrt_ext_file_list_del -#define H5D_CRT_EXT_FILE_LIST_COPY H5P__dcrt_ext_file_list_copy -#define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp +#define H5D_CRT_EXT_FILE_LIST_DEF \ + { \ + HADDR_UNDEF, 0, 0, NULL \ + } +#define H5D_CRT_EXT_FILE_LIST_SET H5P__dcrt_ext_file_list_set +#define H5D_CRT_EXT_FILE_LIST_GET H5P__dcrt_ext_file_list_get +#define H5D_CRT_EXT_FILE_LIST_ENC H5P__dcrt_ext_file_list_enc +#define H5D_CRT_EXT_FILE_LIST_DEC H5P__dcrt_ext_file_list_dec +#define H5D_CRT_EXT_FILE_LIST_DEL H5P__dcrt_ext_file_list_del +#define H5D_CRT_EXT_FILE_LIST_COPY H5P__dcrt_ext_file_list_copy +#define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp #define H5D_CRT_EXT_FILE_LIST_CLOSE H5P__dcrt_ext_file_list_close /* Definitions for dataset object header minimization */ #define H5D_CRT_MIN_DSET_HDR_SIZE_SIZE sizeof(hbool_t) @@ -123,17 +231,14 @@ #define H5D_CRT_MIN_DSET_HDR_SIZE_ENC H5P__encode_hbool_t #define H5D_CRT_MIN_DSET_HDR_SIZE_DEC H5P__decode_hbool_t - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -154,7 +259,7 @@ static herr_t H5P__dcrt_layout_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dcrt_layout_dec(const void **pp, void *value); static herr_t H5P__dcrt_layout_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dcrt_layout_copy(const char *name, size_t size, void *value); -static int H5P__dcrt_layout_cmp(const void *value1, const void *value2, size_t size); +static int H5P__dcrt_layout_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__dcrt_layout_close(const char *name, size_t size, void *value); static herr_t H5P__dcrt_fill_value_set(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dcrt_fill_value_get(hid_t prop_id, const char *name, size_t size, void *value); @@ -169,34 +274,32 @@ static herr_t H5P__dcrt_ext_file_list_enc(const void *value, void **pp, size_t * static herr_t H5P__dcrt_ext_file_list_dec(const void **pp, void *value); static herr_t H5P__dcrt_ext_file_list_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dcrt_ext_file_list_copy(const char *name, size_t size, void *value); -static int H5P__dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); +static int H5P__dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__dcrt_ext_file_list_close(const char *name, size_t size, void *value); - /*********************/ /* Package Variables */ /*********************/ /* Dataset creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ - "dataset create", /* Class name for debugging */ - H5P_TYPE_DATASET_CREATE, /* Class type */ - - &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ - &H5P_CLS_DATASET_CREATE_g, /* Pointer to class */ - &H5P_CLS_DATASET_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_DATASET_CREATE_ID_g, /* Pointer to default property list ID */ - H5P__dcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "dataset create", /* Class name for debugging */ + H5P_TYPE_DATASET_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_DATASET_CREATE_g, /* Pointer to class */ + &H5P_CLS_DATASET_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__dcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -204,34 +307,32 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - /***************************/ /* Local Private Variables */ /***************************/ /* Property value defaults */ -static const H5O_layout_t H5D_def_layout_g = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ -static const H5O_fill_t H5D_def_fill_g = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ -static const unsigned H5D_def_alloc_time_state_g = H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ -static const H5O_efl_t H5D_def_efl_g = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ +static const H5O_layout_t H5D_def_layout_g = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ +static const H5O_fill_t H5D_def_fill_g = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ +static const unsigned H5D_def_alloc_time_state_g = + H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ +static const H5O_efl_t H5D_def_efl_g = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ static const unsigned H5O_ohdr_min_g = H5D_CRT_MIN_DSET_HDR_SIZE_DEF; /* Default object header minimization */ /* Defaults for each type of layout */ #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER static const H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; -static const H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; -static const H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; +static const H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; +static const H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; static const H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL; -#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ -static H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; -static H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; -static H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; -static H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL; -static hbool_t H5P_dcrt_def_layout_init_g = FALSE; +#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ +static H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; +static H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; +static H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; +static H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL; +static hbool_t H5P_dcrt_def_layout_init_g = FALSE; #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - - /*------------------------------------------------------------------------- * Function: H5P__dcrt_reg_prop * @@ -246,45 +347,48 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the storage layout property */ - if(H5P__register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &H5D_def_layout_g, - NULL, H5D_CRT_LAYOUT_SET, H5D_CRT_LAYOUT_GET, H5D_CRT_LAYOUT_ENC, H5D_CRT_LAYOUT_DEC, - H5D_CRT_LAYOUT_DEL, H5D_CRT_LAYOUT_COPY, H5D_CRT_LAYOUT_CMP, H5D_CRT_LAYOUT_CLOSE) < 0) + if (H5P__register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &H5D_def_layout_g, NULL, + H5D_CRT_LAYOUT_SET, H5D_CRT_LAYOUT_GET, H5D_CRT_LAYOUT_ENC, H5D_CRT_LAYOUT_DEC, + H5D_CRT_LAYOUT_DEL, H5D_CRT_LAYOUT_COPY, H5D_CRT_LAYOUT_CMP, + H5D_CRT_LAYOUT_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value property */ - if(H5P__register_real(pclass, H5D_CRT_FILL_VALUE_NAME, H5D_CRT_FILL_VALUE_SIZE, &H5D_def_fill_g, - NULL, H5D_CRT_FILL_VALUE_SET, H5D_CRT_FILL_VALUE_GET, H5D_CRT_FILL_VALUE_ENC, H5D_CRT_FILL_VALUE_DEC, - H5D_CRT_FILL_VALUE_DEL, H5D_CRT_FILL_VALUE_COPY, H5D_CRT_FILL_VALUE_CMP, H5D_CRT_FILL_VALUE_CLOSE) < 0) + if (H5P__register_real(pclass, H5D_CRT_FILL_VALUE_NAME, H5D_CRT_FILL_VALUE_SIZE, &H5D_def_fill_g, NULL, + H5D_CRT_FILL_VALUE_SET, H5D_CRT_FILL_VALUE_GET, H5D_CRT_FILL_VALUE_ENC, + H5D_CRT_FILL_VALUE_DEC, H5D_CRT_FILL_VALUE_DEL, H5D_CRT_FILL_VALUE_COPY, + H5D_CRT_FILL_VALUE_CMP, H5D_CRT_FILL_VALUE_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the space allocation time state property */ - if(H5P__register_real(pclass, H5D_CRT_ALLOC_TIME_STATE_NAME, H5D_CRT_ALLOC_TIME_STATE_SIZE, &H5D_def_alloc_time_state_g, - NULL, NULL, NULL, H5D_CRT_ALLOC_TIME_STATE_ENC, H5D_CRT_ALLOC_TIME_STATE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_CRT_ALLOC_TIME_STATE_NAME, H5D_CRT_ALLOC_TIME_STATE_SIZE, + &H5D_def_alloc_time_state_g, NULL, NULL, NULL, H5D_CRT_ALLOC_TIME_STATE_ENC, + H5D_CRT_ALLOC_TIME_STATE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the external file list property */ - if(H5P__register_real(pclass, H5D_CRT_EXT_FILE_LIST_NAME, H5D_CRT_EXT_FILE_LIST_SIZE, &H5D_def_efl_g, - NULL, H5D_CRT_EXT_FILE_LIST_SET, H5D_CRT_EXT_FILE_LIST_GET, H5D_CRT_EXT_FILE_LIST_ENC, H5D_CRT_EXT_FILE_LIST_DEC, - H5D_CRT_EXT_FILE_LIST_DEL, H5D_CRT_EXT_FILE_LIST_COPY, H5D_CRT_EXT_FILE_LIST_CMP, H5D_CRT_EXT_FILE_LIST_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_CRT_EXT_FILE_LIST_NAME, H5D_CRT_EXT_FILE_LIST_SIZE, &H5D_def_efl_g, + NULL, H5D_CRT_EXT_FILE_LIST_SET, H5D_CRT_EXT_FILE_LIST_GET, + H5D_CRT_EXT_FILE_LIST_ENC, H5D_CRT_EXT_FILE_LIST_DEC, H5D_CRT_EXT_FILE_LIST_DEL, + H5D_CRT_EXT_FILE_LIST_COPY, H5D_CRT_EXT_FILE_LIST_CMP, + H5D_CRT_EXT_FILE_LIST_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the object header minimization property */ - if(H5P__register_real(pclass, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, H5D_CRT_MIN_DSET_HDR_SIZE_SIZE, &H5O_ohdr_min_g, - NULL, NULL, NULL, H5D_CRT_MIN_DSET_HDR_SIZE_ENC, H5D_CRT_MIN_DSET_HDR_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, H5D_CRT_MIN_DSET_HDR_SIZE_SIZE, + &H5O_ohdr_min_g, NULL, NULL, NULL, H5D_CRT_MIN_DSET_HDR_SIZE_ENC, + H5D_CRT_MIN_DSET_HDR_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_set * @@ -300,11 +404,11 @@ done: */ static herr_t H5P__dcrt_layout_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ - H5O_layout_t new_layout; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -312,7 +416,7 @@ H5P__dcrt_layout_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na HDassert(value); /* Make copy of layout */ - if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + if (NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") /* Copy new layout message over old one */ @@ -322,7 +426,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_get * @@ -338,11 +441,11 @@ done: */ static herr_t H5P__dcrt_layout_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ - H5O_layout_t new_layout; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -350,7 +453,7 @@ H5P__dcrt_layout_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na HDassert(value); /* Make copy of layout */ - if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + if (NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") /* Copy new layout message over old one */ @@ -360,7 +463,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_enc * @@ -380,11 +482,11 @@ static herr_t H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) { const H5O_layout_t *layout = (const H5O_layout_t *)value; /* Create local aliases for values */ - uint8_t **pp = (uint8_t **)_pp; - uint8_t *tmp_p; - size_t tmp_size; - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t ** pp = (uint8_t **)_pp; + uint8_t * tmp_p; + size_t tmp_size; + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -392,25 +494,25 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) HDassert(layout); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode layout type */ *(*pp)++ = (uint8_t)layout->type; *size += sizeof(uint8_t); /* If layout is chunked, encode chunking structure */ - if(H5D_CHUNKED == layout->type) { + if (H5D_CHUNKED == layout->type) { /* Encode rank */ *(*pp)++ = (uint8_t)layout->u.chunk.ndims; *size += sizeof(uint8_t); /* Encode chunk dims */ HDcompile_assert(sizeof(uint32_t) == sizeof(layout->u.chunk.dim[0])); - for(u = 0; u < (size_t)layout->u.chunk.ndims; u++) { + for (u = 0; u < (size_t)layout->u.chunk.ndims; u++) { UINT32ENCODE(*pp, layout->u.chunk.dim[u]) *size += sizeof(uint32_t); } /* end for */ - } /* end if */ - else if(H5D_VIRTUAL == layout->type) { + } /* end if */ + else if (H5D_VIRTUAL == layout->type) { uint64_t nentries = (uint64_t)layout->storage.u.virt.list_nused; /* Encode number of entries */ @@ -418,7 +520,7 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) *size += (size_t)8; /* Iterate over entries */ - for(u = 0; u < layout->storage.u.virt.list_nused; u++) { + for (u = 0; u < layout->storage.u.virt.list_nused; u++) { /* Source file name */ tmp_size = HDstrlen(layout->storage.u.virt.list[u].source_file_name) + (size_t)1; H5MM_memcpy(*pp, layout->storage.u.virt.list[u].source_file_name, tmp_size); @@ -436,36 +538,36 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) * have verified that the buffer is large enough for the entire * list before we get here. */ tmp_size = (size_t)-1; - tmp_p = *pp; - if(H5S_encode(layout->storage.u.virt.list[u].source_select, pp, &tmp_size) < 0) + tmp_p = *pp; + if (H5S_encode(layout->storage.u.virt.list[u].source_select, pp, &tmp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize source selection") *size += (size_t)(*pp - tmp_p); /* Virtual dataset selection. Same notes as above apply. */ tmp_size = (size_t)-1; - tmp_p = *pp; - if(H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, pp, &tmp_size) < 0) + tmp_p = *pp; + if (H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, pp, &tmp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize virtual selection") *size += (size_t)(*pp - tmp_p); } /* end for */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* Size of layout type */ *size += sizeof(uint8_t); /* If layout is chunked, calculate chunking structure */ - if(H5D_CHUNKED == layout->type) { + if (H5D_CHUNKED == layout->type) { *size += sizeof(uint8_t); *size += layout->u.chunk.ndims * sizeof(uint32_t); } /* end if */ - else if(H5D_VIRTUAL == layout->type) { + else if (H5D_VIRTUAL == layout->type) { /* Calculate size of virtual layout info */ /* number of entries */ *size += (size_t)8; /* Iterate over entries */ - for(u = 0; u < layout->storage.u.virt.list_nused; u++) { + for (u = 0; u < layout->storage.u.virt.list_nused; u++) { /* Source file name */ tmp_size = HDstrlen(layout->storage.u.virt.list[u].source_file_name) + (size_t)1; *size += tmp_size; @@ -476,26 +578,26 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) /* Source selection */ tmp_size = (size_t)0; - tmp_p = NULL; - if(H5S_encode(layout->storage.u.virt.list[u].source_select, &tmp_p, &tmp_size) < 0) + tmp_p = NULL; + if (H5S_encode(layout->storage.u.virt.list[u].source_select, &tmp_p, &tmp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize source selection") *size += tmp_size; /* Virtual dataset selection */ tmp_size = (size_t)0; - tmp_p = NULL; - if(H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, &tmp_p, &tmp_size) < 0) + tmp_p = NULL; + if (H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, &tmp_p, &tmp_size) < + 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize virtual selection") *size += tmp_size; } /* end for */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_dec * @@ -514,11 +616,11 @@ done: static herr_t H5P__dcrt_layout_dec(const void **_pp, void *value) { - const H5O_layout_t *layout; /* Storage layout */ - H5O_layout_t tmp_layout; /* Temporary local layout structure */ - H5D_layout_t type; /* Layout type */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout; /* Storage layout */ + H5O_layout_t tmp_layout; /* Temporary local layout structure */ + H5D_layout_t type; /* Layout type */ + const uint8_t ** pp = (const uint8_t **)_pp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -528,11 +630,11 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) HDassert(value); /* Decode layout type */ - type = (H5D_layout_t)*(*pp)++; + type = (H5D_layout_t) * (*pp)++; /* set default layout in case the type is compact or contiguous, otherwise * decode the chunked structure and set chunked layout */ - switch(type) { + switch (type) { case H5D_COMPACT: layout = &H5D_def_layout_compact_g; break; @@ -541,126 +643,146 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) layout = &H5D_def_layout_contig_g; break; - case H5D_CHUNKED: - { - unsigned ndims; /* Number of chunk dimensions */ - - /* Decode the number of chunk dimensions */ - ndims = *(*pp)++; - - /* default chunk layout */ - if(0 == ndims) - layout = &H5D_def_layout_chunk_g; - else { /* chunk layout structure is encoded*/ - unsigned u; /* Local index variable */ - - /* Initialize to default values */ - tmp_layout = H5D_def_layout_chunk_g; - - /* Set rank & dimensions */ - tmp_layout.u.chunk.ndims = (unsigned)ndims; - for(u = 0; u < ndims; u++) - UINT32DECODE(*pp, tmp_layout.u.chunk.dim[u]) - - /* Point at the newly set up struct */ - layout = &tmp_layout; - } /* end else */ - } - break; + case H5D_CHUNKED: { + unsigned ndims; /* Number of chunk dimensions */ + + /* Decode the number of chunk dimensions */ + ndims = *(*pp)++; + + /* default chunk layout */ + if (0 == ndims) + layout = &H5D_def_layout_chunk_g; + else { /* chunk layout structure is encoded*/ + unsigned u; /* Local index variable */ + + /* Initialize to default values */ + tmp_layout = H5D_def_layout_chunk_g; + + /* Set rank & dimensions */ + tmp_layout.u.chunk.ndims = (unsigned)ndims; + for (u = 0; u < ndims; u++) + UINT32DECODE(*pp, tmp_layout.u.chunk.dim[u]) + + /* Point at the newly set up struct */ + layout = &tmp_layout; + } /* end else */ + } break; + + case H5D_VIRTUAL: { + uint64_t nentries; /* Number of VDS mappings */ + + /* Decode number of entries */ + UINT64DECODE(*pp, nentries) + + if (nentries == (uint64_t)0) + /* Just use the default struct */ + layout = &H5D_def_layout_virtual_g; + else { + size_t tmp_size; + size_t u; /* Local index variable */ + + /* Initialize to default values */ + tmp_layout = H5D_def_layout_virtual_g; + + /* Allocate entry list */ + if (NULL == (tmp_layout.storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc( + (size_t)nentries * sizeof(H5O_storage_virtual_ent_t)))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate heap block") + tmp_layout.storage.u.virt.list_nalloc = (size_t)nentries; + tmp_layout.storage.u.virt.list_nused = (size_t)nentries; + + /* Decode each entry */ + for (u = 0; u < (size_t)nentries; u++) { + /* Source file name */ + tmp_size = HDstrlen((const char *)*pp) + 1; + if (NULL == + (tmp_layout.storage.u.virt.list[u].source_file_name = (char *)H5MM_malloc(tmp_size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, + "unable to allocate memory for source file name") + H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_file_name, *pp, tmp_size); + *pp += tmp_size; + + /* Source dataset name */ + tmp_size = HDstrlen((const char *)*pp) + 1; + if (NULL == + (tmp_layout.storage.u.virt.list[u].source_dset_name = (char *)H5MM_malloc(tmp_size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, + "unable to allocate memory for source dataset name") + H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_dset_name, *pp, tmp_size); + *pp += tmp_size; + + /* Source selection */ + if (NULL == (tmp_layout.storage.u.virt.list[u].source_select = H5S_decode(pp))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode source space selection") + tmp_layout.storage.u.virt.list[u].source_space_status = H5O_VIRTUAL_STATUS_USER; + + /* Virtual selection */ + if (NULL == + (tmp_layout.storage.u.virt.list[u].source_dset.virtual_select = H5S_decode(pp))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode virtual space selection") + tmp_layout.storage.u.virt.list[u].virtual_space_status = H5O_VIRTUAL_STATUS_USER; + + /* Parse source file and dataset names for "printf" + * style format specifiers */ + if (H5D_virtual_parse_source_name( + tmp_layout.storage.u.virt.list[u].source_file_name, + &tmp_layout.storage.u.virt.list[u].parsed_source_file_name, + &tmp_layout.storage.u.virt.list[u].psfn_static_strlen, + &tmp_layout.storage.u.virt.list[u].psfn_nsubs) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source file name") + if (H5D_virtual_parse_source_name( + tmp_layout.storage.u.virt.list[u].source_dset_name, + &tmp_layout.storage.u.virt.list[u].parsed_source_dset_name, + &tmp_layout.storage.u.virt.list[u].psdn_static_strlen, + &tmp_layout.storage.u.virt.list[u].psdn_nsubs) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source dataset name") + + /* Set source names in source_dset struct */ + if ((tmp_layout.storage.u.virt.list[u].psfn_nsubs == 0) && + (tmp_layout.storage.u.virt.list[u].psdn_nsubs == 0)) { + if (tmp_layout.storage.u.virt.list[u].parsed_source_file_name) + tmp_layout.storage.u.virt.list[u].source_dset.file_name = + tmp_layout.storage.u.virt.list[u].parsed_source_file_name->name_segment; + else + tmp_layout.storage.u.virt.list[u].source_dset.file_name = + tmp_layout.storage.u.virt.list[u].source_file_name; + if (tmp_layout.storage.u.virt.list[u].parsed_source_dset_name) + tmp_layout.storage.u.virt.list[u].source_dset.dset_name = + tmp_layout.storage.u.virt.list[u].parsed_source_dset_name->name_segment; + else + tmp_layout.storage.u.virt.list[u].source_dset.dset_name = + tmp_layout.storage.u.virt.list[u].source_dset_name; + } /* end if */ + + /* unlim_dim fields */ + tmp_layout.storage.u.virt.list[u].unlim_dim_source = + H5S_get_select_unlim_dim(tmp_layout.storage.u.virt.list[u].source_select); + tmp_layout.storage.u.virt.list[u].unlim_dim_virtual = H5S_get_select_unlim_dim( + tmp_layout.storage.u.virt.list[u].source_dset.virtual_select); + tmp_layout.storage.u.virt.list[u].unlim_extent_source = HSIZE_UNDEF; + tmp_layout.storage.u.virt.list[u].unlim_extent_virtual = HSIZE_UNDEF; + tmp_layout.storage.u.virt.list[u].clip_size_source = HSIZE_UNDEF; + tmp_layout.storage.u.virt.list[u].clip_size_virtual = HSIZE_UNDEF; + + /* Clipped selections */ + if (tmp_layout.storage.u.virt.list[u].unlim_dim_virtual < 0) { + tmp_layout.storage.u.virt.list[u].source_dset.clipped_source_select = + tmp_layout.storage.u.virt.list[u].source_select; + tmp_layout.storage.u.virt.list[u].source_dset.clipped_virtual_select = + tmp_layout.storage.u.virt.list[u].source_dset.virtual_select; + } /* end if */ + + /* Update min_dims */ + if (H5D_virtual_update_min_dims(&tmp_layout, u) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, + "unable to update virtual dataset minimum dimensions") + } /* end for */ - case H5D_VIRTUAL: - { - uint64_t nentries; /* Number of VDS mappings */ - - /* Decode number of entries */ - UINT64DECODE(*pp, nentries) - - if(nentries == (uint64_t)0) - /* Just use the default struct */ - layout = &H5D_def_layout_virtual_g; - else { - size_t tmp_size; - size_t u; /* Local index variable */ - - /* Initialize to default values */ - tmp_layout = H5D_def_layout_virtual_g; - - /* Allocate entry list */ - if(NULL == (tmp_layout.storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc((size_t)nentries * sizeof(H5O_storage_virtual_ent_t)))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate heap block") - tmp_layout.storage.u.virt.list_nalloc = (size_t)nentries; - tmp_layout.storage.u.virt.list_nused = (size_t)nentries; - - /* Decode each entry */ - for(u = 0; u < (size_t)nentries; u++) { - /* Source file name */ - tmp_size = HDstrlen((const char *)*pp) + 1; - if(NULL == (tmp_layout.storage.u.virt.list[u].source_file_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory for source file name") - H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_file_name, *pp, tmp_size); - *pp += tmp_size; - - /* Source dataset name */ - tmp_size = HDstrlen((const char *)*pp) + 1; - if(NULL == (tmp_layout.storage.u.virt.list[u].source_dset_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory for source dataset name") - H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_dset_name, *pp, tmp_size); - *pp += tmp_size; - - /* Source selection */ - if(NULL == (tmp_layout.storage.u.virt.list[u].source_select = H5S_decode(pp))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode source space selection") - tmp_layout.storage.u.virt.list[u].source_space_status = H5O_VIRTUAL_STATUS_USER; - - /* Virtual selection */ - if(NULL == (tmp_layout.storage.u.virt.list[u].source_dset.virtual_select = H5S_decode(pp))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode virtual space selection") - tmp_layout.storage.u.virt.list[u].virtual_space_status = H5O_VIRTUAL_STATUS_USER; - - /* Parse source file and dataset names for "printf" - * style format specifiers */ - if(H5D_virtual_parse_source_name(tmp_layout.storage.u.virt.list[u].source_file_name, &tmp_layout.storage.u.virt.list[u].parsed_source_file_name, &tmp_layout.storage.u.virt.list[u].psfn_static_strlen, &tmp_layout.storage.u.virt.list[u].psfn_nsubs) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source file name") - if(H5D_virtual_parse_source_name(tmp_layout.storage.u.virt.list[u].source_dset_name, &tmp_layout.storage.u.virt.list[u].parsed_source_dset_name, &tmp_layout.storage.u.virt.list[u].psdn_static_strlen, &tmp_layout.storage.u.virt.list[u].psdn_nsubs) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source dataset name") - - /* Set source names in source_dset struct */ - if((tmp_layout.storage.u.virt.list[u].psfn_nsubs == 0) - && (tmp_layout.storage.u.virt.list[u].psdn_nsubs == 0)) { - if(tmp_layout.storage.u.virt.list[u].parsed_source_file_name) - tmp_layout.storage.u.virt.list[u].source_dset.file_name = tmp_layout.storage.u.virt.list[u].parsed_source_file_name->name_segment; - else - tmp_layout.storage.u.virt.list[u].source_dset.file_name = tmp_layout.storage.u.virt.list[u].source_file_name; - if(tmp_layout.storage.u.virt.list[u].parsed_source_dset_name) - tmp_layout.storage.u.virt.list[u].source_dset.dset_name = tmp_layout.storage.u.virt.list[u].parsed_source_dset_name->name_segment; - else - tmp_layout.storage.u.virt.list[u].source_dset.dset_name = tmp_layout.storage.u.virt.list[u].source_dset_name; - } /* end if */ - - /* unlim_dim fields */ - tmp_layout.storage.u.virt.list[u].unlim_dim_source = H5S_get_select_unlim_dim(tmp_layout.storage.u.virt.list[u].source_select); - tmp_layout.storage.u.virt.list[u].unlim_dim_virtual = H5S_get_select_unlim_dim(tmp_layout.storage.u.virt.list[u].source_dset.virtual_select); - tmp_layout.storage.u.virt.list[u].unlim_extent_source = HSIZE_UNDEF; - tmp_layout.storage.u.virt.list[u].unlim_extent_virtual = HSIZE_UNDEF; - tmp_layout.storage.u.virt.list[u].clip_size_source = HSIZE_UNDEF; - tmp_layout.storage.u.virt.list[u].clip_size_virtual = HSIZE_UNDEF; - - /* Clipped selections */ - if(tmp_layout.storage.u.virt.list[u].unlim_dim_virtual < 0) { - tmp_layout.storage.u.virt.list[u].source_dset.clipped_source_select = tmp_layout.storage.u.virt.list[u].source_select; - tmp_layout.storage.u.virt.list[u].source_dset.clipped_virtual_select = tmp_layout.storage.u.virt.list[u].source_dset.virtual_select; - } /* end if */ - - /* Update min_dims */ - if(H5D_virtual_update_min_dims(&tmp_layout, u) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to update virtual dataset minimum dimensions") - } /* end for */ - - /* Point at the newly set up struct */ - layout = &tmp_layout; - } /* end else */ - } /* end block */ - break; + /* Point at the newly set up struct */ + layout = &tmp_layout; + } /* end else */ + } /* end block */ + break; case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: @@ -675,7 +797,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_del * @@ -691,9 +812,9 @@ done: */ static herr_t H5P__dcrt_layout_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -701,14 +822,13 @@ H5P__dcrt_layout_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na HDassert(value); /* Reset the old layout */ - if(H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) + if (H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__dcrt_layout_copy * @@ -723,19 +843,18 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_layout_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_layout_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ - H5O_layout_t new_layout; - herr_t ret_value = SUCCEED; + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC HDassert(layout); /* Make copy of layout */ - if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + if (NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") /* Set new layout message directly into property list */ @@ -745,7 +864,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_cmp * @@ -763,12 +881,11 @@ done: *------------------------------------------------------------------------- */ static int -H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, - size_t H5_ATTR_UNUSED size) +H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_UNUSED size) { - const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ - *layout2 = (const H5O_layout_t *)_layout2; - herr_t ret_value = 0; /* Return value */ + const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ + *layout2 = (const H5O_layout_t *)_layout2; + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -778,81 +895,97 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, HDassert(size == sizeof(H5O_layout_t)); /* Check for different layout type */ - if(layout1->type < layout2->type) + if (layout1->type < layout2->type) HGOTO_DONE(-1) - if(layout1->type > layout2->type) + if (layout1->type > layout2->type) HGOTO_DONE(1) /* Compare non-dataset-specific fields in layout info */ - switch(layout1->type) { + switch (layout1->type) { case H5D_COMPACT: case H5D_CONTIGUOUS: break; - case H5D_CHUNKED: - { - unsigned u; /* Local index variable */ + case H5D_CHUNKED: { + unsigned u; /* Local index variable */ + + /* Check the number of dimensions */ + if (layout1->u.chunk.ndims < layout2->u.chunk.ndims) + HGOTO_DONE(-1) + if (layout1->u.chunk.ndims > layout2->u.chunk.ndims) + HGOTO_DONE(1) - /* Check the number of dimensions */ - if(layout1->u.chunk.ndims < layout2->u.chunk.ndims) + /* Compare the chunk dims */ + for (u = 0; u < layout1->u.chunk.ndims - 1; u++) { + if (layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) HGOTO_DONE(-1) - if(layout1->u.chunk.ndims > layout2->u.chunk.ndims) + if (layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) + HGOTO_DONE(1) + } /* end for */ + } /* end case */ + break; + + case H5D_VIRTUAL: { + htri_t equal; + int strcmp_ret; + size_t u; /* Local index variable */ + + /* Compare number of mappings */ + if (layout1->storage.u.virt.list_nused < layout2->storage.u.virt.list_nused) + HGOTO_DONE(-1) + if (layout1->storage.u.virt.list_nused > layout2->storage.u.virt.list_nused) + HGOTO_DONE(1) + + /* Iterate over mappings */ + for (u = 0; u < layout1->storage.u.virt.list_nused; u++) { + /* Compare virtual spaces. Note we cannot tell which is + * "greater", so just return 1 if different, -1 on failure. + */ + if ((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_dset.virtual_select, + layout2->storage.u.virt.list[u].source_dset.virtual_select)) < + 0) + HGOTO_DONE(-1) + if (!equal) + HGOTO_DONE(1) + if ((equal = H5S_SELECT_SHAPE_SAME( + layout1->storage.u.virt.list[u].source_dset.virtual_select, + layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) + HGOTO_DONE(-1) + if (!equal) HGOTO_DONE(1) - /* Compare the chunk dims */ - for(u = 0; u < layout1->u.chunk.ndims - 1; u++) { - if(layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) - HGOTO_DONE(-1) - if(layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) - HGOTO_DONE(1) - } /* end for */ - } /* end case */ - break; + /* Compare source file names */ + strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_file_name, + layout2->storage.u.virt.list[u].source_file_name); + if (strcmp_ret < 0) + HGOTO_DONE(-1) + if (strcmp_ret > 0) + HGOTO_DONE(1) - case H5D_VIRTUAL: - { - htri_t equal; - int strcmp_ret; - size_t u; /* Local index variable */ - - /* Compare number of mappings */ - if(layout1->storage.u.virt.list_nused < layout2->storage.u.virt.list_nused) HGOTO_DONE(-1) - if(layout1->storage.u.virt.list_nused > layout2->storage.u.virt.list_nused) HGOTO_DONE(1) - - /* Iterate over mappings */ - for(u = 0; u < layout1->storage.u.virt.list_nused; u++) { - /* Compare virtual spaces. Note we cannot tell which is - * "greater", so just return 1 if different, -1 on failure. - */ - if((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1) - if(!equal) - HGOTO_DONE(1) - if((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1) - if(!equal) - HGOTO_DONE(1) - - /* Compare source file names */ - strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_file_name, layout2->storage.u.virt.list[u].source_file_name); - if(strcmp_ret < 0) HGOTO_DONE(-1) - if(strcmp_ret > 0) HGOTO_DONE(1) - - /* Compare source dataset names */ - strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_dset_name, layout2->storage.u.virt.list[u].source_dset_name); - if(strcmp_ret < 0) HGOTO_DONE(-1) - if(strcmp_ret > 0) HGOTO_DONE(1) - - /* Compare source spaces. Note we cannot tell which is - * "greater", so just return 1 if different, -1 on failure. - */ - if((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1) - if(!equal) - HGOTO_DONE(1) - if((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1) - if(!equal) - HGOTO_DONE(1) - } /* end for */ - } /* end block */ - break; + /* Compare source dataset names */ + strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_dset_name, + layout2->storage.u.virt.list[u].source_dset_name); + if (strcmp_ret < 0) + HGOTO_DONE(-1) + if (strcmp_ret > 0) + HGOTO_DONE(1) + + /* Compare source spaces. Note we cannot tell which is + * "greater", so just return 1 if different, -1 on failure. + */ + if ((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_select, + layout2->storage.u.virt.list[u].source_select)) < 0) + HGOTO_DONE(-1) + if (!equal) + HGOTO_DONE(1) + if ((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_select, + layout2->storage.u.virt.list[u].source_select)) < 0) + HGOTO_DONE(-1) + if (!equal) + HGOTO_DONE(1) + } /* end for */ + } /* end block */ + break; case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: @@ -864,7 +997,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_close * @@ -879,10 +1011,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_layout_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_layout_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -890,14 +1021,13 @@ H5P__dcrt_layout_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED si HDassert(value); /* Reset the old layout */ - if(H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) + if (H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_close() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_set * @@ -913,11 +1043,11 @@ done: */ static herr_t H5P__dcrt_fill_value_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ - H5O_fill_t new_fill; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -925,7 +1055,7 @@ H5P__dcrt_fill_value_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED HDassert(value); /* Make copy of fill value */ - if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + if (NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") /* Copy new fill value message over old one */ @@ -935,7 +1065,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_get * @@ -951,11 +1080,11 @@ done: */ static herr_t H5P__dcrt_fill_value_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ - H5O_fill_t new_fill; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -963,7 +1092,7 @@ H5P__dcrt_fill_value_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED HDassert(value); /* Make copy of fill value */ - if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + if (NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") /* Copy new fill value message over old one */ @@ -973,7 +1102,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_enc * @@ -992,12 +1120,12 @@ done: static herr_t H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) { - const H5O_fill_t *fill = (const H5O_fill_t *)value; /* Create local aliases for values */ - size_t dt_size = 0; /* Size of encoded datatype */ - herr_t ret_value = SUCCEED; /* Return value */ - uint8_t **pp = (uint8_t **)_pp; - uint64_t enc_value; - unsigned enc_size = 0; + const H5O_fill_t *fill = (const H5O_fill_t *)value; /* Create local aliases for values */ + size_t dt_size = 0; /* Size of encoded datatype */ + herr_t ret_value = SUCCEED; /* Return value */ + uint8_t ** pp = (uint8_t **)_pp; + uint64_t enc_value; + unsigned enc_size = 0; FUNC_ENTER_STATIC @@ -1007,7 +1135,7 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) HDassert(fill); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode alloc and fill time */ *(*pp)++ = (uint8_t)fill->alloc_time; *(*pp)++ = (uint8_t)fill->fill_time; @@ -1016,7 +1144,7 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) INT64ENCODE(*pp, fill->size) /* Encode the fill value & datatype */ - if(fill->size > 0) { + if (fill->size > 0) { /* Encode the fill value itself */ H5MM_memcpy(*pp, (uint8_t *)fill->buf, (size_t)fill->size); *pp += fill->size; @@ -1024,12 +1152,12 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) /* Encode fill value datatype */ HDassert(fill->type); - if(H5T_encode(fill->type, NULL, &dt_size) < 0) + if (H5T_encode(fill->type, NULL, &dt_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") /* Encode the size of a size_t */ enc_value = (uint64_t)dt_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); /* Encode the size */ @@ -1038,27 +1166,27 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) /* Encode the size of the encoded datatype */ UINT64ENCODE_VAR(*pp, enc_value, enc_size); - if(H5T_encode(fill->type, *pp, &dt_size) < 0) + if (H5T_encode(fill->type, *pp, &dt_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") *pp += dt_size; } /* end if */ - } /* end if */ + } /* end if */ /* Calculate size needed for encoding */ *size += 2; *size += sizeof(int64_t); - if(fill->size > 0) { + if (fill->size > 0) { /* The size of the fill value buffer */ *size += (size_t)fill->size; /* calculate those if they were not calculated earlier */ - if(NULL == *pp) { + if (NULL == *pp) { /* Get the size of the encoded datatype */ HDassert(fill->type); - if(H5T_encode(fill->type, NULL, &dt_size) < 0) + if (H5T_encode(fill->type, NULL, &dt_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") enc_value = (uint64_t)dt_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); } *size += (1 + enc_size); *size += dt_size; @@ -1068,7 +1196,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_dec * @@ -1087,9 +1214,9 @@ done: static herr_t H5P__dcrt_fill_value_dec(const void **_pp, void *_value) { - H5O_fill_t *fill = (H5O_fill_t *)_value; /* Fill value */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_fill_t * fill = (H5O_fill_t *)_value; /* Fill value */ + const uint8_t **pp = (const uint8_t **)_pp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1100,20 +1227,20 @@ H5P__dcrt_fill_value_dec(const void **_pp, void *_value) *fill = H5D_def_fill_g; /* Decode alloc and fill time */ - fill->alloc_time = (H5D_alloc_time_t)*(*pp)++; - fill->fill_time = (H5D_fill_time_t)*(*pp)++; + fill->alloc_time = (H5D_alloc_time_t) * (*pp)++; + fill->fill_time = (H5D_fill_time_t) * (*pp)++; /* Decode fill size */ INT64DECODE(*pp, fill->size) /* Check if there's a fill value */ - if(fill->size > 0) { - size_t dt_size = 0; + if (fill->size > 0) { + size_t dt_size = 0; uint64_t enc_value; unsigned enc_size; /* Allocate fill buffer and copy the contents in it */ - if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) + if (NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for fill value buffer") H5MM_memcpy((uint8_t *)fill->buf, *pp, (size_t)fill->size); *pp += fill->size; @@ -1126,7 +1253,7 @@ H5P__dcrt_fill_value_dec(const void **_pp, void *_value) dt_size = (size_t)enc_value; /* Decode type */ - if(NULL == (fill->type = H5T_decode(dt_size, *pp))) + if (NULL == (fill->type = H5T_decode(dt_size, *pp))) HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode fill value datatype") *pp += dt_size; } /* end if */ @@ -1135,7 +1262,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_del * @@ -1151,9 +1277,9 @@ done: */ static herr_t H5P__dcrt_fill_value_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1161,14 +1287,13 @@ H5P__dcrt_fill_value_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED HDassert(value); /* Reset the old fill value message */ - if(H5O_msg_reset(H5O_FILL_ID, value) < 0) + if (H5O_msg_reset(H5O_FILL_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release fill value message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_copy * @@ -1183,19 +1308,18 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_fill_value_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_fill_value_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ - H5O_fill_t new_fill; - herr_t ret_value = SUCCEED; + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC HDassert(fill); /* Make copy of fill value message */ - if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + if (NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") /* Set new fill value message directly into property list */ @@ -1205,7 +1329,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_copy() */ - /*------------------------------------------------------------------------- * Function: H5P_fill_value_cmp * @@ -1222,13 +1345,12 @@ done: *------------------------------------------------------------------------- */ int -H5P_fill_value_cmp(const void *_fill1, const void *_fill2, - size_t H5_ATTR_UNUSED size) +H5P_fill_value_cmp(const void *_fill1, const void *_fill2, size_t H5_ATTR_UNUSED size) { - const H5O_fill_t *fill1 = (const H5O_fill_t *)_fill1, /* Create local aliases for values */ - *fill2 = (const H5O_fill_t *)_fill2; - int cmp_value; /* Value from comparison */ - herr_t ret_value = 0; /* Return value */ + const H5O_fill_t *fill1 = (const H5O_fill_t *)_fill1, /* Create local aliases for values */ + *fill2 = (const H5O_fill_t *)_fill2; + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1238,36 +1360,45 @@ H5P_fill_value_cmp(const void *_fill1, const void *_fill2, HDassert(size == sizeof(H5O_fill_t)); /* Check the size of fill values */ - if(fill1->size < fill2->size) HGOTO_DONE(-1); - if(fill1->size > fill2->size) HGOTO_DONE(1); + if (fill1->size < fill2->size) + HGOTO_DONE(-1); + if (fill1->size > fill2->size) + HGOTO_DONE(1); /* Check the types of the fill values */ - if(fill1->type == NULL && fill2->type != NULL) HGOTO_DONE(-1); - if(fill1->type != NULL && fill2->type == NULL) HGOTO_DONE(1); - if(fill1->type != NULL) - if((cmp_value = H5T_cmp(fill1->type, fill2->type, FALSE)) != 0) + if (fill1->type == NULL && fill2->type != NULL) + HGOTO_DONE(-1); + if (fill1->type != NULL && fill2->type == NULL) + HGOTO_DONE(1); + if (fill1->type != NULL) + if ((cmp_value = H5T_cmp(fill1->type, fill2->type, FALSE)) != 0) HGOTO_DONE(cmp_value); /* Check the fill values in the buffers */ - if(fill1->buf == NULL && fill2->buf != NULL) HGOTO_DONE(-1); - if(fill1->buf != NULL && fill2->buf == NULL) HGOTO_DONE(1); - if(fill1->buf != NULL) - if((cmp_value = HDmemcmp(fill1->buf, fill2->buf, (size_t)fill1->size)) != 0) + if (fill1->buf == NULL && fill2->buf != NULL) + HGOTO_DONE(-1); + if (fill1->buf != NULL && fill2->buf == NULL) + HGOTO_DONE(1); + if (fill1->buf != NULL) + if ((cmp_value = HDmemcmp(fill1->buf, fill2->buf, (size_t)fill1->size)) != 0) HGOTO_DONE(cmp_value); /* Check the allocation time for the fill values */ - if(fill1->alloc_time < fill2->alloc_time) HGOTO_DONE(-1); - if(fill1->alloc_time > fill2->alloc_time) HGOTO_DONE(1); + if (fill1->alloc_time < fill2->alloc_time) + HGOTO_DONE(-1); + if (fill1->alloc_time > fill2->alloc_time) + HGOTO_DONE(1); /* Check the fill time for the fill values */ - if(fill1->fill_time < fill2->fill_time) HGOTO_DONE(-1); - if(fill1->fill_time > fill2->fill_time) HGOTO_DONE(1); + if (fill1->fill_time < fill2->fill_time) + HGOTO_DONE(-1); + if (fill1->fill_time > fill2->fill_time) + HGOTO_DONE(1); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_fill_value_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_close * @@ -1282,10 +1413,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_fill_value_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_fill_value_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1293,14 +1423,13 @@ H5P__dcrt_fill_value_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE HDassert(value); /* Reset the old fill value message */ - if(H5O_msg_reset(H5O_FILL_ID, value) < 0) + if (H5O_msg_reset(H5O_FILL_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release fill value message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_close() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_set * @@ -1316,11 +1445,11 @@ done: */ static herr_t H5P__dcrt_ext_file_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ - H5O_efl_t new_efl; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1328,7 +1457,7 @@ H5P__dcrt_ext_file_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU HDassert(value); /* Make copy of external file list */ - if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + if (NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") /* Copy new external file list message over old one */ @@ -1338,7 +1467,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_get * @@ -1354,11 +1482,11 @@ done: */ static herr_t H5P__dcrt_ext_file_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ - H5O_efl_t new_efl; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1366,7 +1494,7 @@ H5P__dcrt_ext_file_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU HDassert(value); /* Make copy of external file list */ - if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + if (NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") /* Copy new external file list message over old one */ @@ -1376,7 +1504,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_enc * @@ -1396,11 +1523,11 @@ static herr_t H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) { const H5O_efl_t *efl = (const H5O_efl_t *)value; /* Create local aliases for values */ - size_t len = 0; /* String length of slot name */ - size_t u; /* Local index variable */ - uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size; - uint64_t enc_value; + size_t len = 0; /* String length of slot name */ + size_t u; /* Local index variable */ + uint8_t ** pp = (uint8_t **)_pp; + unsigned enc_size; + uint64_t enc_value; FUNC_ENTER_STATIC_NOERR @@ -1411,20 +1538,20 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) HDcompile_assert(sizeof(hsize_t) <= sizeof(uint64_t)); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode number of slots used */ enc_value = (uint64_t)efl->nused; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* Encode file list */ - for(u = 0; u < efl->nused; u++) { + for (u = 0; u < efl->nused; u++) { /* Calculate length of slot name and encode it */ - len = HDstrlen(efl->slot[u].name) + 1; + len = HDstrlen(efl->slot[u].name) + 1; enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -1435,23 +1562,23 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) /* Encode offset */ enc_value = (uint64_t)efl->slot[u].offset; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode size */ enc_value = (uint64_t)efl->slot[u].size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); } /* end for */ - } /* end if */ + } /* end if */ /* Calculate size needed for encoding */ *size += (1 + H5VM_limit_enc_size((uint64_t)efl->nused)); - for(u = 0; u < efl->nused; u++) { + for (u = 0; u < efl->nused; u++) { len = HDstrlen(efl->slot[u].name) + 1; *size += (1 + H5VM_limit_enc_size((uint64_t)len)); *size += len; @@ -1462,7 +1589,6 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dcrt_ext_file_list_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_dec * @@ -1481,12 +1607,12 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dcrt_ext_file_list_dec(const void **_pp, void *_value) { - H5O_efl_t *efl = (H5O_efl_t *)_value; /* External file list */ - const uint8_t **pp = (const uint8_t **)_pp; - size_t u, nused; - unsigned enc_size; - uint64_t enc_value; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_efl_t * efl = (H5O_efl_t *)_value; /* External file list */ + const uint8_t **pp = (const uint8_t **)_pp; + size_t u, nused; + unsigned enc_size; + uint64_t enc_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1508,17 +1634,16 @@ H5P__dcrt_ext_file_list_dec(const void **_pp, void *_value) nused = (size_t)enc_value; /* Decode information for each slot */ - for(u = 0; u < nused; u++) { + for (u = 0; u < nused; u++) { size_t len; - if(efl->nused >= efl->nalloc) { - size_t na = efl->nalloc + H5O_EFL_ALLOC; - H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl->slot, - na * sizeof(H5O_efl_entry_t)); - if(!x) + if (efl->nused >= efl->nalloc) { + size_t na = efl->nalloc + H5O_EFL_ALLOC; + H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl->slot, na * sizeof(H5O_efl_entry_t)); + if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed") efl->nalloc = na; - efl->slot = x; + efl->slot = x; } /* end if */ /* Decode length of slot name */ @@ -1551,7 +1676,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_del * @@ -1567,9 +1691,9 @@ done: */ static herr_t H5P__dcrt_ext_file_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1577,14 +1701,13 @@ H5P__dcrt_ext_file_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU HDassert(value); /* Reset the old efl message */ - if(H5O_msg_reset(H5O_EFL_ID, value) < 0) + if (H5O_msg_reset(H5O_EFL_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release external file list message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_copy * @@ -1599,19 +1722,18 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_ext_file_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_ext_file_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ - H5O_efl_t new_efl; - herr_t ret_value = SUCCEED; + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC HDassert(efl); /* Make copy of efl message */ - if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + if (NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") /* Set new efl message directly into property list */ @@ -1621,7 +1743,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_cmp * @@ -1639,13 +1760,12 @@ done: *------------------------------------------------------------------------- */ static int -H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, - size_t H5_ATTR_UNUSED size) +H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t H5_ATTR_UNUSED size) { - const H5O_efl_t *efl1 = (const H5O_efl_t *)_efl1, /* Create local aliases for values */ - *efl2 = (const H5O_efl_t *)_efl2; - int cmp_value; /* Value from comparison */ - herr_t ret_value = 0; /* Return value */ + const H5O_efl_t *efl1 = (const H5O_efl_t *)_efl1, /* Create local aliases for values */ + *efl2 = (const H5O_efl_t *)_efl2; + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1655,47 +1775,60 @@ H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, HDassert(size == sizeof(H5O_efl_t)); /* Check the number of allocated efl entries */ - if(efl1->nalloc < efl2->nalloc) HGOTO_DONE(-1); - if(efl1->nalloc > efl2->nalloc) HGOTO_DONE(1); + if (efl1->nalloc < efl2->nalloc) + HGOTO_DONE(-1); + if (efl1->nalloc > efl2->nalloc) + HGOTO_DONE(1); /* Check the number of used efl entries */ - if(efl1->nused < efl2->nused) HGOTO_DONE(-1); - if(efl1->nused > efl2->nused) HGOTO_DONE(1); + if (efl1->nused < efl2->nused) + HGOTO_DONE(-1); + if (efl1->nused > efl2->nused) + HGOTO_DONE(1); /* Check the efl entry information */ - if(efl1->slot == NULL && efl2->slot != NULL) HGOTO_DONE(-1); - if(efl1->slot != NULL && efl2->slot == NULL) HGOTO_DONE(1); - if(efl1->slot != NULL && efl1->nused > 0) { - size_t u; /* Local index variable */ + if (efl1->slot == NULL && efl2->slot != NULL) + HGOTO_DONE(-1); + if (efl1->slot != NULL && efl2->slot == NULL) + HGOTO_DONE(1); + if (efl1->slot != NULL && efl1->nused > 0) { + size_t u; /* Local index variable */ /* Loop through all entries, comparing them */ - for(u = 0; u < efl1->nused; u++) { + for (u = 0; u < efl1->nused; u++) { /* Check the name offset of the efl entry */ - if(efl1->slot[u].name_offset < efl2->slot[u].name_offset) HGOTO_DONE(-1); - if(efl1->slot[u].name_offset > efl2->slot[u].name_offset) HGOTO_DONE(1); + if (efl1->slot[u].name_offset < efl2->slot[u].name_offset) + HGOTO_DONE(-1); + if (efl1->slot[u].name_offset > efl2->slot[u].name_offset) + HGOTO_DONE(1); /* Check the name of the efl entry */ - if(efl1->slot[u].name == NULL && efl2->slot[u].name != NULL) HGOTO_DONE(-1); - if(efl1->slot[u].name != NULL && efl2->slot[u].name == NULL) HGOTO_DONE(1); - if(efl1->slot[u].name != NULL) - if((cmp_value = HDstrcmp(efl1->slot[u].name, efl2->slot[u].name)) != 0) + if (efl1->slot[u].name == NULL && efl2->slot[u].name != NULL) + HGOTO_DONE(-1); + if (efl1->slot[u].name != NULL && efl2->slot[u].name == NULL) + HGOTO_DONE(1); + if (efl1->slot[u].name != NULL) + if ((cmp_value = HDstrcmp(efl1->slot[u].name, efl2->slot[u].name)) != 0) HGOTO_DONE(cmp_value); /* Check the file offset of the efl entry */ - if(efl1->slot[u].offset < efl2->slot[u].offset) HGOTO_DONE(-1); - if(efl1->slot[u].offset > efl2->slot[u].offset) HGOTO_DONE(1); + if (efl1->slot[u].offset < efl2->slot[u].offset) + HGOTO_DONE(-1); + if (efl1->slot[u].offset > efl2->slot[u].offset) + HGOTO_DONE(1); /* Check the file size of the efl entry */ - if(efl1->slot[u].size < efl2->slot[u].size) HGOTO_DONE(-1); - if(efl1->slot[u].size > efl2->slot[u].size) HGOTO_DONE(1); + if (efl1->slot[u].size < efl2->slot[u].size) + HGOTO_DONE(-1); + if (efl1->slot[u].size > efl2->slot[u].size) + HGOTO_DONE(1); } /* end for */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_close * @@ -1710,10 +1843,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_ext_file_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_ext_file_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1721,14 +1853,13 @@ H5P__dcrt_ext_file_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UN HDassert(value); /* Reset the old efl message */ - if(H5O_msg_reset(H5O_EFL_ID, value) < 0) + if (H5O_msg_reset(H5O_EFL_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release external file list message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_close() */ - /*------------------------------------------------------------------------- * Function: H5P__set_layout * @@ -1744,25 +1875,25 @@ done: static herr_t H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) { - unsigned alloc_time_state; /* State of allocation time property */ - herr_t ret_value = SUCCEED; /* return value */ + unsigned alloc_time_state; /* State of allocation time property */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC /* Get the allocation time state */ - if(H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + if (H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get space allocation time state") /* If we still have the "default" allocation time, change it according to the new layout */ - if(alloc_time_state) { - H5O_fill_t fill; /* Fill value */ + if (alloc_time_state) { + H5O_fill_t fill; /* Fill value */ /* Get current fill value info */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set the default based on layout */ - switch(layout->type) { + switch (layout->type) { case H5D_COMPACT: fill.alloc_time = H5D_ALLOC_TIME_EARLY; break; @@ -1783,12 +1914,12 @@ H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) } /* end switch */ /* Set updated fill value info */ - if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time") } /* end if */ /* Set layout value */ - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, layout) < 0) + if (H5P_set(plist, H5D_CRT_LAYOUT_NAME, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: @@ -1796,7 +1927,7 @@ done: } /* end H5P__set_layout() */ #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER - + /*------------------------------------------------------------------------- * Function: H5P__init_def_layout * @@ -1813,21 +1944,21 @@ done: static herr_t H5P__init_def_layout(void) { - const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; + const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; const H5O_storage_compact_t def_store_compact = H5D_DEF_STORAGE_COMPACT_INIT; - const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT; + const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT; const H5O_storage_virtual_t def_store_virtual = H5D_DEF_STORAGE_VIRTUAL_INIT; FUNC_ENTER_STATIC_NOERR /* Initialize the default layout info for non-contigous layouts */ - H5D_def_layout_compact_g.storage.type = H5D_COMPACT; + H5D_def_layout_compact_g.storage.type = H5D_COMPACT; H5D_def_layout_compact_g.storage.u.compact = def_store_compact; - H5D_def_layout_chunk_g.u.chunk = def_layout_chunk; - H5D_def_layout_chunk_g.storage.type = H5D_CHUNKED; - H5D_def_layout_chunk_g.storage.u.chunk = def_store_chunk; - H5D_def_layout_virtual_g.storage.type = H5D_VIRTUAL; - H5D_def_layout_virtual_g.storage.u.virt = def_store_virtual; + H5D_def_layout_chunk_g.u.chunk = def_layout_chunk; + H5D_def_layout_chunk_g.storage.type = H5D_CHUNKED; + H5D_def_layout_chunk_g.storage.u.chunk = def_store_chunk; + H5D_def_layout_virtual_g.storage.type = H5D_VIRTUAL; + H5D_def_layout_virtual_g.storage.u.virt = def_store_virtual; /* Note that we've initialized the default values */ H5P_dcrt_def_layout_init_g = TRUE; @@ -1836,7 +1967,6 @@ H5P__init_def_layout(void) } /* end H5P__init_def_layout() */ #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - /*------------------------------------------------------------------------- * Function: H5Pset_layout * @@ -1859,32 +1989,32 @@ H5P__init_def_layout(void) herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5O_layout_t *layout; /* Pointer to default layout information for type specified */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + const H5O_layout_t *layout; /* Pointer to default layout information for type specified */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDl", plist_id, layout_type); /* Check arguments */ - if(layout_type < 0 || layout_type >= H5D_NLAYOUTS) + if (layout_type < 0 || layout_type >= H5D_NLAYOUTS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "raw data layout method is not valid") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Get pointer to correct default layout */ - switch(layout_type) { + switch (layout_type) { case H5D_COMPACT: layout = &H5D_def_layout_compact_g; break; @@ -1908,14 +2038,13 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) } /* end switch */ /* Set value */ - if(H5P__set_layout(plist, layout) < 0) + if (H5P__set_layout(plist, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_layout() */ - /*------------------------------------------------------------------------- * Function: H5Pget_layout * @@ -1940,19 +2069,19 @@ done: H5D_layout_t H5Pget_layout(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout property */ - H5D_layout_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout property */ + H5D_layout_t ret_value; /* Return value */ FUNC_ENTER_API(H5D_LAYOUT_ERROR) H5TRACE1("Dl", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5D_LAYOUT_ERROR, "can't find object for ID") /* Peek at layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5D_LAYOUT_ERROR, "can't get layout") /* Set return value */ @@ -1962,7 +2091,6 @@ done: FUNC_LEAVE_API(ret_value) } /* ed H5Pget_layout() */ - /*------------------------------------------------------------------------- * Function: H5Pset_chunk * @@ -1990,29 +2118,29 @@ done: herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t chunk_layout; /* Layout information for setting chunk info */ - uint64_t chunk_nelmts; /* Number of elements in chunk */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t chunk_layout; /* Layout information for setting chunk info */ + uint64_t chunk_nelmts; /* Number of elements in chunk */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIs*[a1]h", plist_id, ndims, dim); /* Check arguments */ - if(ndims <= 0) + if (ndims <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality must be positive") - if(ndims > H5S_MAX_RANK) + if (ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality is too large") - if(!dim) + if (!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no chunk dimensions specified") #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -2020,31 +2148,30 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) H5MM_memcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g)); HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim)); chunk_nelmts = 1; - for(u = 0; u < (unsigned)ndims; u++) { - if(dim[u] == 0) + for (u = 0; u < (unsigned)ndims; u++) { + if (dim[u] == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be positive") - if(dim[u] != (dim[u] & 0xffffffff)) + if (dim[u] != (dim[u] & 0xffffffff)) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be less than 2^32") chunk_nelmts *= dim[u]; - if(chunk_nelmts > (uint64_t)0xffffffff) + if (chunk_nelmts > (uint64_t)0xffffffff) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of elements in chunk must be < 4GB") chunk_layout.u.chunk.dim[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */ - } /* end for */ + } /* end for */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set chunk information in property list */ chunk_layout.u.chunk.ndims = (unsigned)ndims; - if(H5P__set_layout(plist, &chunk_layout) < 0) + if (H5P__set_layout(plist, &chunk_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_chunk() */ - /*------------------------------------------------------------------------- * Function: H5Pget_chunk * @@ -2070,30 +2197,30 @@ done: *------------------------------------------------------------------------- */ int -H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) +H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[] /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - int ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Is", "iIsx", plist_id, max_ndims, dim); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Peek at the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_CHUNKED != layout.type) + if (H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") - if(dim) { - unsigned u; /* Local index variable */ + if (dim) { + unsigned u; /* Local index variable */ /* Get the dimension sizes */ - for(u = 0; u < layout.u.chunk.ndims && u < (unsigned)max_ndims; u++) + for (u = 0; u < layout.u.chunk.ndims && u < (unsigned)max_ndims; u++) dim[u] = layout.u.chunk.dim[u]; } /* end if */ @@ -2104,7 +2231,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_chunk() */ - /*------------------------------------------------------------------------- * Function: H5Pset_virtual * @@ -2126,63 +2252,63 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, - const char *src_dset_name, hid_t src_space_id) +H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, const char *src_dset_name, + hid_t src_space_id) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t virtual_layout; /* Layout information for setting virtual info */ - H5S_t *vspace; /* Virtual dataset space selection */ - H5S_t *src_space; /* Source dataset space selection */ - H5O_storage_virtual_ent_t *old_list = NULL; /* List pointer previously on property list */ - H5O_storage_virtual_ent_t *ent = NULL; /* Convenience pointer to new VDS entry */ - hbool_t retrieved_layout = FALSE; /* Whether the layout has been retrieved */ - hbool_t free_list = FALSE; /* Whether to free the list of virtual entries */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5O_layout_t virtual_layout; /* Layout information for setting virtual info */ + H5S_t * vspace; /* Virtual dataset space selection */ + H5S_t * src_space; /* Source dataset space selection */ + H5O_storage_virtual_ent_t *old_list = NULL; /* List pointer previously on property list */ + H5O_storage_virtual_ent_t *ent = NULL; /* Convenience pointer to new VDS entry */ + hbool_t retrieved_layout = FALSE; /* Whether the layout has been retrieved */ + hbool_t free_list = FALSE; /* Whether to free the list of virtual entries */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*s*si", dcpl_id, vspace_id, src_file_name, src_dset_name, src_space_id); /* Check arguments */ - if(!src_file_name) + if (!src_file_name) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "source file name not provided") - if(!src_dset_name) + if (!src_dset_name) HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "source dataset name not provided") - if(NULL == (vspace = (H5S_t *)H5I_object_verify(vspace_id, H5I_DATASPACE))) + if (NULL == (vspace = (H5S_t *)H5I_object_verify(vspace_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) + if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataspace") /* Check selections for validity */ - if(H5D_virtual_check_mapping_pre(vspace, src_space, H5O_VIRTUAL_STATUS_USER) < 0) + if (H5D_virtual_check_mapping_pre(vspace, src_space, H5O_VIRTUAL_STATUS_USER) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "invalid mapping selections") #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current layout */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") retrieved_layout = TRUE; /* If the layout was not already virtual, Start with default virtual layout. * Otherwise, add the mapping to the current list. */ - if(virtual_layout.type == H5D_VIRTUAL) + if (virtual_layout.type == H5D_VIRTUAL) /* Save old list pointer for error recovery */ old_list = virtual_layout.storage.u.virt.list; else { /* Reset the old layout */ - if(H5O_msg_reset(H5O_LAYOUT_ID, &virtual_layout) < 0) + if (H5O_msg_reset(H5O_LAYOUT_ID, &virtual_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message") /* Copy the default virtual layout */ @@ -2193,61 +2319,64 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, } /* end else */ /* Expand list if necessary */ - if(virtual_layout.storage.u.virt.list_nused == virtual_layout.storage.u.virt.list_nalloc) { - H5O_storage_virtual_ent_t *x; /* Pointer to the new list */ + if (virtual_layout.storage.u.virt.list_nused == virtual_layout.storage.u.virt.list_nalloc) { + H5O_storage_virtual_ent_t *x; /* Pointer to the new list */ size_t new_alloc = MAX(H5D_VIRTUAL_DEF_LIST_SIZE, virtual_layout.storage.u.virt.list_nalloc * 2); /* Expand size of entry list */ - if(NULL == (x = (H5O_storage_virtual_ent_t *)H5MM_realloc(virtual_layout.storage.u.virt.list, new_alloc * sizeof(H5O_storage_virtual_ent_t)))) + if (NULL == (x = (H5O_storage_virtual_ent_t *)H5MM_realloc( + virtual_layout.storage.u.virt.list, new_alloc * sizeof(H5O_storage_virtual_ent_t)))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't reallocate virtual dataset mapping list") - virtual_layout.storage.u.virt.list = x; + virtual_layout.storage.u.virt.list = x; virtual_layout.storage.u.virt.list_nalloc = new_alloc; } /* end if */ /* Add virtual dataset mapping entry */ ent = &virtual_layout.storage.u.virt.list[virtual_layout.storage.u.virt.list_nused]; - HDmemset(ent, 0, sizeof(H5O_storage_virtual_ent_t)); /* Clear before starting to set up */ - if(NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE))) + HDmemset(ent, 0, sizeof(H5O_storage_virtual_ent_t)); /* Clear before starting to set up */ + if (NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") - if(NULL == (ent->source_file_name = H5MM_xstrdup(src_file_name))) + if (NULL == (ent->source_file_name = H5MM_xstrdup(src_file_name))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") - if(NULL == (ent->source_dset_name = H5MM_xstrdup(src_dset_name))) + if (NULL == (ent->source_dset_name = H5MM_xstrdup(src_dset_name))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") - if(NULL == (ent->source_select = H5S_copy(src_space, FALSE, TRUE))) + if (NULL == (ent->source_select = H5S_copy(src_space, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection") - if(H5D_virtual_parse_source_name(ent->source_file_name, &ent->parsed_source_file_name, &ent->psfn_static_strlen, &ent->psfn_nsubs) < 0) + if (H5D_virtual_parse_source_name(ent->source_file_name, &ent->parsed_source_file_name, + &ent->psfn_static_strlen, &ent->psfn_nsubs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source file name") - if(H5D_virtual_parse_source_name(ent->source_dset_name, &ent->parsed_source_dset_name, &ent->psdn_static_strlen, &ent->psdn_nsubs) < 0) + if (H5D_virtual_parse_source_name(ent->source_dset_name, &ent->parsed_source_dset_name, + &ent->psdn_static_strlen, &ent->psdn_nsubs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source dataset name") - if((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) { - if(ent->parsed_source_file_name) + if ((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) { + if (ent->parsed_source_file_name) ent->source_dset.file_name = ent->parsed_source_file_name->name_segment; else ent->source_dset.file_name = ent->source_file_name; - if(ent->parsed_source_dset_name) + if (ent->parsed_source_dset_name) ent->source_dset.dset_name = ent->parsed_source_dset_name->name_segment; else ent->source_dset.dset_name = ent->source_dset_name; } /* end if */ - ent->unlim_dim_source = H5S_get_select_unlim_dim(src_space); + ent->unlim_dim_source = H5S_get_select_unlim_dim(src_space); ent->unlim_dim_virtual = H5S_get_select_unlim_dim(vspace); - if(ent->unlim_dim_virtual < 0) { - ent->source_dset.clipped_source_select = ent->source_select; + if (ent->unlim_dim_virtual < 0) { + ent->source_dset.clipped_source_select = ent->source_select; ent->source_dset.clipped_virtual_select = ent->source_dset.virtual_select; } /* end if */ - ent->unlim_extent_source = HSIZE_UNDEF; + ent->unlim_extent_source = HSIZE_UNDEF; ent->unlim_extent_virtual = HSIZE_UNDEF; - ent->clip_size_source = HSIZE_UNDEF; - ent->clip_size_virtual = HSIZE_UNDEF; - ent->source_space_status = H5O_VIRTUAL_STATUS_USER; + ent->clip_size_source = HSIZE_UNDEF; + ent->clip_size_virtual = HSIZE_UNDEF; + ent->source_space_status = H5O_VIRTUAL_STATUS_USER; ent->virtual_space_status = H5O_VIRTUAL_STATUS_USER; /* Check entry for validity */ - if(H5D_virtual_check_mapping_post(ent) < 0) + if (H5D_virtual_check_mapping_post(ent) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid mapping entry") /* Update min_dims */ - if(H5D_virtual_update_min_dims(&virtual_layout, virtual_layout.storage.u.virt.list_nused) < 0) + if (H5D_virtual_update_min_dims(&virtual_layout, virtual_layout.storage.u.virt.list_nused) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to update virtual dataset minimum dimensions") /* Finish adding entry */ @@ -2256,25 +2385,25 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, done: /* Set VDS layout information in property list */ /* (Even on failure, so there's not a mangled layout struct in the list) */ - if(retrieved_layout) { - if(H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) { + if (retrieved_layout) { + if (H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) { HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") - if(old_list != virtual_layout.storage.u.virt.list) + if (old_list != virtual_layout.storage.u.virt.list) free_list = TRUE; } /* end if */ - } /* end if */ + } /* end if */ /* Check if the entry has been partly allocated but not added to the * property list or not included in list_nused */ - if(ret_value < 0) { + if (ret_value < 0) { /* Free incomplete entry if present */ - if(ent) { + if (ent) { ent->source_file_name = (char *)H5MM_xfree(ent->source_file_name); ent->source_dset_name = (char *)H5MM_xfree(ent->source_dset_name); - if(ent->source_dset.virtual_select && H5S_close(ent->source_dset.virtual_select) < 0) + if (ent->source_dset.virtual_select && H5S_close(ent->source_dset.virtual_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection") ent->source_dset.virtual_select = NULL; - if(ent->source_select && H5S_close(ent->source_select) < 0) + if (ent->source_select && H5S_close(ent->source_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") ent->source_select = NULL; H5D_virtual_free_parsed_name(ent->parsed_source_file_name); @@ -2284,14 +2413,14 @@ done: } /* end if */ /* Free list if necessary */ - if(free_list) - virtual_layout.storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_xfree(virtual_layout.storage.u.virt.list); + if (free_list) + virtual_layout.storage.u.virt.list = + (H5O_storage_virtual_ent_t *)H5MM_xfree(virtual_layout.storage.u.virt.list); } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Pset_virtual() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_count * @@ -2307,24 +2436,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_virtual_count(hid_t dcpl_id, size_t *count/*out*/) +H5Pget_virtual_count(hid_t dcpl_id, size_t *count /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", dcpl_id, count); - if(count) { + if (count) { /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Return the number of mappings */ @@ -2335,7 +2464,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_count() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_vspace * @@ -2355,45 +2483,44 @@ done: hid_t H5Pget_virtual_vspace(hid_t dcpl_id, size_t idx) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - H5S_t *space = NULL; /* Dataspace pointer */ - hid_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + H5S_t * space = NULL; /* Dataspace pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "iz", dcpl_id, idx); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Get the virtual space */ - if(idx >= layout.storage.u.virt.list_nused) + if (idx >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); - if(NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_dset.virtual_select, FALSE, TRUE))) + if (NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Register ID */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") done: /* Free space on failure */ - if((ret_value < 0) && space) - if(H5S_close(space) < 0) + if ((ret_value < 0) && space) + if (H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_vspace() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_srcspace * @@ -2413,26 +2540,26 @@ done: hid_t H5Pget_virtual_srcspace(hid_t dcpl_id, size_t idx) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - H5S_t *space = NULL; /* Dataspace pointer */ - hid_t ret_value = FAIL; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + H5S_t * space = NULL; /* Dataspace pointer */ + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "iz", dcpl_id, idx); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Check index */ - if(idx >= layout.storage.u.virt.list_nused) + if (idx >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); @@ -2440,27 +2567,28 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t idx) * H5O_VIRTUAL_STATUS_CORRECT? -NAF */ /* If source space status is H5O_VIRTUAL_STATUS_INVALID, patch with bounds * of selection */ - if((H5O_VIRTUAL_STATUS_INVALID == layout.storage.u.virt.list[idx].source_space_status) - && (layout.storage.u.virt.list[idx].unlim_dim_source < 0)) { + if ((H5O_VIRTUAL_STATUS_INVALID == layout.storage.u.virt.list[idx].source_space_status) && + (layout.storage.u.virt.list[idx].unlim_dim_source < 0)) { hsize_t bounds_start[H5S_MAX_RANK]; hsize_t bounds_end[H5S_MAX_RANK]; - int rank; - int i; + int rank; + int i; /* Get rank of source space */ - if((rank = H5S_GET_EXTENT_NDIMS(layout.storage.u.virt.list[idx].source_select)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(layout.storage.u.virt.list[idx].source_select)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get source space rank") /* Get bounds of selection */ - if(H5S_SELECT_BOUNDS(layout.storage.u.virt.list[idx].source_select, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS(layout.storage.u.virt.list[idx].source_select, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get selection bounds") /* Adjust bounds to extent */ - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) bounds_end[i]++; /* Set extent */ - if(H5S_set_extent_simple(layout.storage.u.virt.list[idx].source_select, (unsigned)rank, bounds_end, NULL) < 0) + if (H5S_set_extent_simple(layout.storage.u.virt.list[idx].source_select, (unsigned)rank, bounds_end, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set source space extent") /* Update source space status */ @@ -2468,23 +2596,22 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t idx) } /* end if */ /* Get the source space */ - if(NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_select, FALSE, TRUE))) + if (NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Register ID */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") done: /* Free space on failure */ - if((ret_value < 0) && space) - if(H5S_close(space) < 0) + if ((ret_value < 0) && space) + if (H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_srcspace() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_filename * @@ -2515,32 +2642,31 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Pget_virtual_filename(hid_t dcpl_id, size_t idx, char *name/*out*/, - size_t size) +H5Pget_virtual_filename(hid_t dcpl_id, size_t idx, char *name /*out*/, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "izxz", dcpl_id, idx, name, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Get the virtual filename */ - if(idx >= layout.storage.u.virt.list_nused) + if (idx >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); HDassert(layout.storage.u.virt.list[idx].source_file_name); - if(name && (size > 0)) + if (name && (size > 0)) (void)HDstrncpy(name, layout.storage.u.virt.list[idx].source_file_name, size); ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[idx].source_file_name); @@ -2548,7 +2674,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_filename() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_dsetname * @@ -2578,32 +2703,31 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Pget_virtual_dsetname(hid_t dcpl_id, size_t idx, char *name/*out*/, - size_t size) +H5Pget_virtual_dsetname(hid_t dcpl_id, size_t idx, char *name /*out*/, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "izxz", dcpl_id, idx, name, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Get the virtual filename */ - if(idx >= layout.storage.u.virt.list_nused) + if (idx >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); HDassert(layout.storage.u.virt.list[idx].source_dset_name); - if(name && (size > 0)) + if (name && (size > 0)) (void)HDstrncpy(name, layout.storage.u.virt.list[idx].source_dset_name, size); ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[idx].source_dset_name); @@ -2611,7 +2735,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_dsetname() */ - /*------------------------------------------------------------------------- * Function: H5Pset_chunk_opts * @@ -2628,57 +2751,56 @@ done: herr_t H5Pset_chunk_opts(hid_t plist_id, unsigned options) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information for setting chunk info */ - uint8_t layout_flags = 0; /* "options" translated into layout message flags format */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information for setting chunk info */ + uint8_t layout_flags = 0; /* "options" translated into layout message flags format */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, options); /* Check arguments */ - if(options & ~(H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS)) + if (options & ~(H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS)) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "unknown chunk options") #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_CHUNKED != layout.type) + if (H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") /* Translate options into flags that can be used with the layout message */ - if(options & H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) + if (options & H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) layout_flags |= H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS; /* Update the layout message, including the version (if necessary) */ /* This probably isn't the right way to do this, and should be changed once * this branch gets the "real" way to set the layout version */ layout.u.chunk.flags = layout_flags; - if(layout.version < H5O_LAYOUT_VERSION_4) + if (layout.version < H5O_LAYOUT_VERSION_4) layout.version = H5O_LAYOUT_VERSION_4; /* Set layout value */ - if(H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_chunk_opts() */ - /*------------------------------------------------------------------------- * Function: H5Pget_chunk_opts * @@ -2694,9 +2816,9 @@ done: herr_t H5Pget_chunk_opts(hid_t plist_id, unsigned *options) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information for setting chunk info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information for setting chunk info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", plist_id, options); @@ -2705,26 +2827,26 @@ H5Pget_chunk_opts(hid_t plist_id, unsigned *options) /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_CHUNKED != layout.type) + if (H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") - if(options) { + if (options) { /* Translate options from flags that can be used with the layout message * to those known to the public */ *options = 0; - if(layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) + if (layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) *options |= H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS; } /* end if */ @@ -2732,7 +2854,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_chunk_opts() */ - /*------------------------------------------------------------------------- * Function: H5Pset_external * @@ -2759,63 +2880,62 @@ done: herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) { - size_t idx; - hsize_t total, tmp; - H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; + hsize_t total, tmp; + H5O_efl_t efl; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*soh", plist_id, name, offset, size); /* Check arguments */ - if(!name || !*name) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if(offset < 0) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if (offset < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if (H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") - if(efl.nused > 0 && H5O_EFL_UNLIMITED == efl.slot[efl.nused - 1].size) + if (efl.nused > 0 && H5O_EFL_UNLIMITED == efl.slot[efl.nused - 1].size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "previous file size is unlimited") - if(H5O_EFL_UNLIMITED != size) { - for(idx = 0, total = size; idx < efl.nused; idx++, total = tmp) { + if (H5O_EFL_UNLIMITED != size) { + for (idx = 0, total = size; idx < efl.nused; idx++, total = tmp) { tmp = total + efl.slot[idx].size; - if(tmp <= total) + if (tmp <= total) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "total external data size overflowed") } /* end for */ - } /* end if */ + } /* end if */ /* Add to the list */ - if(efl.nused >= efl.nalloc) { - size_t na = efl.nalloc + H5O_EFL_ALLOC; - H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl.slot, na * sizeof(H5O_efl_entry_t)); + if (efl.nused >= efl.nalloc) { + size_t na = efl.nalloc + H5O_EFL_ALLOC; + H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl.slot, na * sizeof(H5O_efl_entry_t)); - if(!x) + if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed") efl.nalloc = na; - efl.slot = x; + efl.slot = x; } /* end if */ - idx = efl.nused; + idx = efl.nused; efl.slot[idx].name_offset = 0; /*not entered into heap yet*/ - efl.slot[idx].name = H5MM_xstrdup(name); - efl.slot[idx].offset = offset; - efl.slot[idx].size = size; + efl.slot[idx].name = H5MM_xstrdup(name); + efl.slot[idx].offset = offset; + efl.slot[idx].size = size; efl.nused++; - if(H5P_poke(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if (H5P_poke(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_external() */ - /*------------------------------------------------------------------------- * Function: H5Pget_external_count * @@ -2840,19 +2960,19 @@ done: int H5Pget_external_count(hid_t plist_id) { - H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - int ret_value; /* return value */ + H5O_efl_t efl; + H5P_genplist_t *plist; /* Property list pointer */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if (H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") /* Set return value */ @@ -2862,7 +2982,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_external_count() */ - /*------------------------------------------------------------------------- * Function: H5Pget_external * @@ -2895,40 +3014,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name/*out*/, - off_t *offset/*out*/, hsize_t *size/*out*/) +H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name /*out*/, off_t *offset /*out*/, + hsize_t *size /*out*/) { - H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5O_efl_t efl; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIuzxxx", plist_id, idx, name_size, name, offset, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if (H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") - if(idx >= efl.nused) + if (idx >= efl.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "external file index is out of range") /* Return values */ - if(name_size>0 && name) + if (name_size > 0 && name) HDstrncpy(name, efl.slot[idx].name, name_size); - if(offset) + if (offset) *offset = efl.slot[idx].offset; - if(size) + if (size) *size = efl.slot[idx].size; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_external() */ - /*------------------------------------------------------------------------- * Function: H5Pset_szip * @@ -2948,29 +3066,29 @@ done: herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) { - H5O_pline_t pline; - H5P_genplist_t *plist; /* Property list pointer */ - unsigned cd_values[2]; /* Filter parameters */ - unsigned int config_flags; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + unsigned cd_values[2]; /* Filter parameters */ + unsigned int config_flags; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, options_mask, pixels_per_block); - if(H5Z_get_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0) + if (H5Z_get_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't get filter info") - if(!(config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED)) + if (!(config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED)) HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled.") /* Check arguments */ - if((pixels_per_block % 2) == 1) + if ((pixels_per_block % 2) == 1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even") - if(pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) + if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is too large") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Always set K13 compression (and un-set CHIP compression) */ @@ -2985,22 +3103,21 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) options_mask &= (unsigned)(~(H5_SZIP_LSB_OPTION_MASK | H5_SZIP_MSB_OPTION_MASK)); /* Set the parameters for the filter */ - cd_values[0]=options_mask; - cd_values[1]=pixels_per_block; + cd_values[0] = options_mask; + cd_values[1] = pixels_per_block; /* Add the filter */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - if(H5Z_append(&pline, H5Z_FILTER_SZIP, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) + if (H5Z_append(&pline, H5Z_FILTER_SZIP, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add szip filter to pipeline") - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_szip() */ - /*------------------------------------------------------------------------- * Function: H5Pset_shuffle * @@ -3020,34 +3137,33 @@ done: herr_t H5Pset_shuffle(hid_t plist_id) { - H5O_pline_t pline; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Check arguments */ - if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + if (TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Add the filter */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - if(H5Z_append(&pline, H5Z_FILTER_SHUFFLE, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) + if (H5Z_append(&pline, H5Z_FILTER_SHUFFLE, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to shuffle the data") - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shuffle() */ - /*------------------------------------------------------------------------- * Function: H5Pset_nbit * @@ -3066,34 +3182,33 @@ done: herr_t H5Pset_nbit(hid_t plist_id) { - H5O_pline_t pline; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Check arguments */ - if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + if (TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Add the nbit filter */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - if(H5Z_append(&pline, H5Z_FILTER_NBIT, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) + if (H5Z_append(&pline, H5Z_FILTER_NBIT, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add nbit filter to pipeline") - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_nbit() */ - /*------------------------------------------------------------------------- * Function: H5Pset_scaleoffset * @@ -3128,25 +3243,25 @@ done: herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor) { - H5O_pline_t pline; - H5P_genplist_t *plist; /* Property list pointer */ - unsigned cd_values[2]; /* Filter parameters */ - herr_t ret_value=SUCCEED; /* return value */ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + unsigned cd_values[2]; /* Filter parameters */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iZaIs", plist_id, scale_type, scale_factor); /* Check arguments */ - if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + if (TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") - if(scale_factor < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scale factor must be >= 0") - if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE && scale_type!=H5Z_SO_INT) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type") + if (scale_factor < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scale factor must be >= 0") + if (scale_type != H5Z_SO_FLOAT_DSCALE && scale_type != H5Z_SO_FLOAT_ESCALE && scale_type != H5Z_SO_INT) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set parameters for the filter @@ -3161,18 +3276,17 @@ H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_fac cd_values[1] = (unsigned)scale_factor; /* Add the scaleoffset filter */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - if(H5Z_append(&pline, H5Z_FILTER_SCALEOFFSET, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) + if (H5Z_append(&pline, H5Z_FILTER_SCALEOFFSET, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add scaleoffset filter to pipeline") - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_scaleoffset() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fill_value * @@ -3193,76 +3307,77 @@ done: herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", plist_id, type_id, value); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current fill value */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Release the dynamic fill value components */ H5O_fill_reset_dyn(&fill); - if(value) { - H5T_t *type; /* Datatype for fill value */ - H5T_path_t *tpath; /* Conversion information */ + if (value) { + H5T_t * type; /* Datatype for fill value */ + H5T_path_t *tpath; /* Conversion information */ /* Retrieve pointer to datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set the fill value */ - if(NULL == (fill.type = H5T_copy(type, H5T_COPY_TRANSIENT))) + if (NULL == (fill.type = H5T_copy(type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy datatype") fill.size = (ssize_t)H5T_get_size(type); - if(NULL == (fill.buf = H5MM_malloc((size_t)fill.size))) + if (NULL == (fill.buf = H5MM_malloc((size_t)fill.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value") H5MM_memcpy(fill.buf, value, (size_t)fill.size); /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(type, type))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") + if (NULL == (tpath = H5T_path_find(type, type))) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest data types") /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ - if(!H5T_path_noop(tpath)) { - uint8_t *bkg_buf = NULL; /* Background conversion buffer */ + if (!H5T_path_noop(tpath)) { + uint8_t *bkg_buf = NULL; /* Background conversion buffer */ /* Allocate a background buffer */ - if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)fill.size))) + if (H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)fill.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Convert the fill value */ - if(H5T_convert(tpath, type_id, type_id, (size_t)1, (size_t)0, (size_t)0, fill.buf, bkg_buf) < 0) { - if(bkg_buf) + if (H5T_convert(tpath, type_id, type_id, (size_t)1, (size_t)0, (size_t)0, fill.buf, bkg_buf) < + 0) { + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end if */ /* Release the background buffer */ - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); } /* end if */ - } /* end if */ + } /* end if */ else fill.size = (-1); /* Update fill value in property list */ - if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set fill value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fill_value() */ - /*------------------------------------------------------------------------- * Function: H5P_get_fill_value * @@ -3280,15 +3395,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/) +H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value /*out*/) { - H5O_fill_t fill; /* Fill value to retrieve */ - H5T_path_t *tpath; /*type conversion info */ - void *buf = NULL; /*conversion buffer */ - void *bkg = NULL; /*conversion buffer */ - hid_t src_id = -1; /*source datatype id */ - hid_t dst_id = -1; /*destination datatype id */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_fill_t fill; /* Fill value to retrieve */ + H5T_path_t *tpath; /*type conversion info */ + void * buf = NULL; /*conversion buffer */ + void * bkg = NULL; /*conversion buffer */ + hid_t src_id = -1; /*source datatype id */ + hid_t dst_id = -1; /*destination datatype id */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3298,23 +3413,23 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/) * datatype conversion might not have resulted in zero. If fill value * is undefined, also return error. */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") - if(fill.size == -1) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "fill value is undefined") + if (fill.size == -1) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "fill value is undefined") /* Check for "default" fill value */ - if(fill.size == 0) { - HDmemset(value, 0, H5T_get_size(type)); - HGOTO_DONE(SUCCEED); + if (fill.size == 0) { + HDmemset(value, 0, H5T_get_size(type)); + HGOTO_DONE(SUCCEED); } /* end if */ - /* - * Can we convert between the source and destination datatypes? - */ - if(NULL == (tpath = H5T_path_find(fill.type, type))) + /* + * Can we convert between the source and destination datatypes? + */ + if (NULL == (tpath = H5T_path_find(fill.type, type))) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill.type, H5T_COPY_TRANSIENT), FALSE)) < 0) + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill.type, H5T_COPY_TRANSIENT), FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy/register datatype") /* @@ -3322,41 +3437,40 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/) * other than the fill value buffer that is large enough for both source * and destination. The app-supplied buffer might do okay. */ - if(H5T_get_size(type) >= H5T_get_size(fill.type)) { + if (H5T_get_size(type) >= H5T_get_size(fill.type)) { buf = value; - if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(type)))) + if (H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(type)))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") } /* end if */ else { - if(NULL == (buf = H5MM_calloc(H5T_get_size(fill.type)))) + if (NULL == (buf = H5MM_calloc(H5T_get_size(fill.type)))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") - if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(fill.type)))) + if (H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(fill.type)))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") } /* end else */ H5MM_memcpy(buf, fill.buf, H5T_get_size(fill.type)); /* Do the conversion */ - if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(type, H5T_COPY_ALL), FALSE)) < 0) + if ((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy/register datatype") - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "datatype conversion failed") - if(buf != value) + if (buf != value) H5MM_memcpy(value, buf, H5T_get_size(type)); done: - if(buf != value) + if (buf != value) H5MM_xfree(buf); - if(bkg != value) + if (bkg != value) H5MM_xfree(bkg); - if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + if (src_id >= 0 && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") - if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_get_fill_value() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fill_value * @@ -3374,34 +3488,33 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/) +H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - H5T_t *type; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5T_t * type; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iix", plist_id, type_id, value); /* Check arguments */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,"no fill value output buffer") + if (!value) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no fill value output buffer") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the fill value */ - if(H5P_get_fill_value(plist, type, value) < 0) + if (H5P_get_fill_value(plist, type, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fill_value() */ - /*------------------------------------------------------------------------- * Function: H5P_is_fill_value_defined * @@ -3425,16 +3538,16 @@ H5P_is_fill_value_defined(const H5O_fill_t *fill, H5D_fill_value_t *status) HDassert(status); /* Check if the fill value was "unset" */ - if(fill->size == -1 && !fill->buf) - *status = H5D_FILL_VALUE_UNDEFINED; + if (fill->size == -1 && !fill->buf) + *status = H5D_FILL_VALUE_UNDEFINED; /* Check if the fill value was set to the default fill value by the library */ - else if(fill->size == 0 && !fill->buf) - *status = H5D_FILL_VALUE_DEFAULT; + else if (fill->size == 0 && !fill->buf) + *status = H5D_FILL_VALUE_DEFAULT; /* Check if the fill value was set by the application */ - else if(fill->size > 0 && fill->buf) - *status = H5D_FILL_VALUE_USER_DEFINED; + else if (fill->size > 0 && fill->buf) + *status = H5D_FILL_VALUE_USER_DEFINED; else { - *status = H5D_FILL_VALUE_ERROR; + *status = H5D_FILL_VALUE_ERROR; HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "invalid combination of fill-value info") } /* end else */ @@ -3442,7 +3555,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_is_fill_value_defined() */ - /*------------------------------------------------------------------------- * Function: H5P_fill_value_defined * @@ -3458,26 +3570,25 @@ done: herr_t H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status) { - H5O_fill_t fill; /* Fill value to query */ - herr_t ret_value = SUCCEED; + H5O_fill_t fill; /* Fill value to query */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) HDassert(status); /* Get the fill value struct */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Get the fill-value status */ - if(H5P_is_fill_value_defined(&fill, status) < 0) + if (H5P_is_fill_value_defined(&fill, status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't check fill value status") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_fill_value_defined() */ - /*------------------------------------------------------------------------- * Function: H5Pfill_value_defined * @@ -3493,8 +3604,8 @@ done: herr_t H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status) { - H5P_genplist_t *plist; /* Property list to query */ - herr_t ret_value = SUCCEED; + H5P_genplist_t *plist; /* Property list to query */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*DF", plist_id, status); @@ -3502,18 +3613,17 @@ H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status) HDassert(status); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the fill-value status */ - if(H5P_fill_value_defined(plist, status) < 0) + if (H5P_fill_value_defined(plist, status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't check fill value status") done: FUNC_LEAVE_API(ret_value) } /* end H5Pfill_value_defined() */ - /*------------------------------------------------------------------------- * Function: H5Pset_alloc_time * @@ -3534,32 +3644,32 @@ done: herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value property to modify */ - unsigned alloc_time_state; /* State of allocation time property */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value property to modify */ + unsigned alloc_time_state; /* State of allocation time property */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDa", plist_id, alloc_time); /* Check arguments */ - if(alloc_time < H5D_ALLOC_TIME_DEFAULT || alloc_time > H5D_ALLOC_TIME_INCR) + if (alloc_time < H5D_ALLOC_TIME_DEFAULT || alloc_time > H5D_ALLOC_TIME_INCR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid allocation time setting") /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Check for resetting to default for layout type */ - if(alloc_time == H5D_ALLOC_TIME_DEFAULT) { - H5O_layout_t layout; /* Type of storage layout */ + if (alloc_time == H5D_ALLOC_TIME_DEFAULT) { + H5O_layout_t layout; /* Type of storage layout */ /* Peek at the storage layout */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") /* Set the default based on layout */ - switch(layout.type) { + switch (layout.type) { case H5D_COMPACT: alloc_time = H5D_ALLOC_TIME_EARLY; break; @@ -3590,23 +3700,22 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) alloc_time_state = 0; /* Retrieve previous fill value settings */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Update property value */ fill.alloc_time = alloc_time; /* Set values */ - if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") - if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + if (H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_alloc_time() */ - /*------------------------------------------------------------------------- * Function: H5Pget_alloc_time * @@ -3622,7 +3731,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/) +H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time /*out*/) { herr_t ret_value = SUCCEED; /* return value */ @@ -3630,16 +3739,16 @@ H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/) H5TRACE2("e", "ix", plist_id, alloc_time); /* Get values */ - if(alloc_time) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value property to query */ + if (alloc_time) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value property to query */ /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve fill value settings */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set user's value */ @@ -3650,7 +3759,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_alloc_time() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fill_time * @@ -3667,37 +3775,36 @@ done: herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value property to modify */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value property to modify */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDf", plist_id, fill_time); /* Check arguments */ - if(fill_time < H5D_FILL_TIME_ALLOC || fill_time > H5D_FILL_TIME_IFSET) + if (fill_time < H5D_FILL_TIME_ALLOC || fill_time > H5D_FILL_TIME_IFSET) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fill time setting") /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve previous fill value settings */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Update property value */ fill.fill_time = fill_time; /* Set values */ - if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fill_time() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fill_time * @@ -3715,7 +3822,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/) +H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time /*out*/) { herr_t ret_value = SUCCEED; /* return value */ @@ -3723,16 +3830,16 @@ H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/) H5TRACE2("e", "ix", plist_id, fill_time); /* Set values */ - if(fill_time) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value property to query */ + if (fill_time) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value property to query */ /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve fill value settings */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set user's value */ @@ -3743,7 +3850,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fill_time() */ - /*----------------------------------------------------------------------------- * Function: H5Pget_dset_no_attrs_hint * @@ -3774,14 +3880,14 @@ H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", dcpl_id, minimize); - if(NULL == minimize) + if (NULL == minimize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "receiving pointer cannot be NULL") plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE); - if(NULL == plist) + if (NULL == plist) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &setting) < 0) + if (H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &setting) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get dset oh minimize flag value") *minimize = setting; @@ -3790,7 +3896,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Pget_dset_no_attrs_hint() */ - /*----------------------------------------------------------------------------- * Function: H5Pset_dset_no_attrs_hint * @@ -3822,16 +3927,15 @@ H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize) H5TRACE2("e", "ib", dcpl_id, minimize); plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE); - if(NULL == plist) + if (NULL == plist) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &prev_set) < 0) + if (H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &prev_set) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get extant dset oh minimize flag value") - if(H5P_poke(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &minimize) < 0) + if (H5P_poke(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &minimize) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't get dset oh minimize flag value") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_dset_no_attrs_hint() */ - diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c index b9efaee..11b6fc3 100644 --- a/src/H5Pdeprec.c +++ b/src/H5Pdeprec.c @@ -29,57 +29,48 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*-------------------------------------------------------------------------- NAME H5Pregister1 @@ -220,51 +211,51 @@ REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pregister1(hid_t cls_id, const char *name, size_t size, void *def_value, - H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, - H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, - H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close) +H5Pregister1(hid_t cls_id, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create, + H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, + H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close) { - H5P_genclass_t *pclass; /* Property list class to modify */ - H5P_genclass_t *orig_pclass; /* Original property class */ - herr_t ret_value; /* Return value */ + H5P_genclass_t *pclass; /* Property list class to modify */ + H5P_genclass_t *orig_pclass; /* Original property class */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE10("e", "i*sz*xxxxxxx", cls_id, name, size, def_value, prp_create, prp_set, prp_get, prp_delete, prp_copy, prp_close); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid class name"); - if(size > 0 && def_value == NULL) + if (size > 0 && def_value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default"); /* Create the new property list class */ orig_pclass = pclass; - if((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy, NULL, prp_close)) < 0) + if ((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL, + prp_delete, prp_copy, NULL, prp_close)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in class"); /* Check if the property class changed and needs to be substituted in the ID */ - if(pclass != orig_pclass) { - H5P_genclass_t *old_pclass; /* Old property class */ + if (pclass != orig_pclass) { + H5P_genclass_t *old_pclass; /* Old property class */ /* Substitute the new property class in the ID */ - if(NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass))) + if (NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass))) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to substitute property class in ID") HDassert(old_pclass == orig_pclass); /* Close the previous class */ - if(H5P__close_class(orig_pclass) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "unable to close original property class after substitution") + if (H5P__close_class(orig_pclass) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, + "unable to close original property class after substitution") } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pregister1() */ +} /* H5Pregister1() */ - /*-------------------------------------------------------------------------- NAME H5Pinsert1 @@ -405,36 +396,34 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pinsert1(hid_t plist_id, const char *name, size_t size, void *value, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, - H5P_prp_close_func_t prp_close) +H5Pinsert1(hid_t plist_id, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, + H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, + H5P_prp_close_func_t prp_close) { - H5P_genplist_t *plist; /* Property list to modify */ - herr_t ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list to modify */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE9("e", "i*sz*xxxxxx", plist_id, name, size, value, prp_set, prp_get, prp_delete, prp_copy, prp_close); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name") - if(size > 0 && value == NULL) + if (size > 0 && value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default") /* Create the new property list class */ - if((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, - NULL, NULL, prp_delete, prp_copy, NULL, prp_close)) < 0) + if ((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy, + NULL, prp_close)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in plist") done: FUNC_LEAVE_API(ret_value) -} /* H5Pinsert1() */ +} /* H5Pinsert1() */ - /*------------------------------------------------------------------------- * Function: H5Pget_version * @@ -459,35 +448,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_version(hid_t plist_id, unsigned *super/*out*/, unsigned *freelist/*out*/, - unsigned *stab/*out*/, unsigned *shhdr/*out*/) +H5Pget_version(hid_t plist_id, unsigned *super /*out*/, unsigned *freelist /*out*/, unsigned *stab /*out*/, + unsigned *shhdr /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ixxxx", plist_id, super, freelist, stab, shhdr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(super) - if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, super) < 0) + if (super) + if (H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, super) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get superblock version") - if(freelist) - *freelist = HDF5_FREESPACE_VERSION; /* (hard-wired) */ - if(stab) - *stab = HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ - if(shhdr) - *shhdr = HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ + if (freelist) + *freelist = HDF5_FREESPACE_VERSION; /* (hard-wired) */ + if (stab) + *stab = HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ + if (shhdr) + *shhdr = HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_version() */ - /*-------------------------------------------------------------------------- NAME H5Pencode1 @@ -512,28 +500,28 @@ done: herr_t H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc) { - H5P_genplist_t *plist; /* Property list to query */ - hid_t temp_fapl_id = H5P_DEFAULT; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + hid_t temp_fapl_id = H5P_DEFAULT; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x*z", plist_id, buf, nalloc); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Call the internal encode routine */ - if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) + if ((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pencode1() */ +} /* H5Pencode1() */ /*------------------------------------------------------------------------- * Function: H5Pset_file_space @@ -549,17 +537,17 @@ herr_t H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold) { - H5F_fspace_strategy_t new_strategy; /* File space strategy type */ - hbool_t new_persist = H5F_FREE_SPACE_PERSIST_DEF; /* Persisting free-space or not */ - hsize_t new_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; /* Free-space section threshold */ - H5F_file_space_type_t in_strategy = strategy; /* Input strategy */ - hsize_t in_threshold = threshold; /* Input threshold */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_fspace_strategy_t new_strategy; /* File space strategy type */ + hbool_t new_persist = H5F_FREE_SPACE_PERSIST_DEF; /* Persisting free-space or not */ + hsize_t new_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; /* Free-space section threshold */ + H5F_file_space_type_t in_strategy = strategy; /* Input strategy */ + hsize_t in_threshold = threshold; /* Input threshold */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iFfh", plist_id, strategy, threshold); - if((unsigned)in_strategy >= H5F_FILE_SPACE_NTYPES) + if ((unsigned)in_strategy >= H5F_FILE_SPACE_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy") /* * For 1.10.0 H5Pset_file_space: @@ -568,20 +556,20 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh * If threshold is zero, the property is not changed; * the existing threshold is retained. */ - if(!in_strategy) + if (!in_strategy) H5Pget_file_space(plist_id, &in_strategy, NULL); - if(!in_threshold) + if (!in_threshold) H5Pget_file_space(plist_id, NULL, &in_threshold); - switch(in_strategy) { + switch (in_strategy) { case H5F_FILE_SPACE_ALL_PERSIST: - new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; - new_persist = TRUE; + new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + new_persist = TRUE; new_threshold = in_threshold; break; case H5F_FILE_SPACE_ALL: - new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; new_threshold = in_threshold; break; @@ -599,14 +587,13 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file space strategy") } - if(H5Pset_file_space_strategy(plist_id, new_strategy, new_persist, new_threshold) < 0) + if (H5Pset_file_space_strategy(plist_id, new_strategy, new_persist, new_threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_file_space() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_space * @@ -621,28 +608,28 @@ done: herr_t H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold) { - H5F_fspace_strategy_t new_strategy; /* File space strategy type */ - hbool_t new_persist; /* Persisting free-space or not */ - hsize_t new_threshold; /* Free-space section threshold */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_fspace_strategy_t new_strategy; /* File space strategy type */ + hbool_t new_persist; /* Persisting free-space or not */ + hsize_t new_threshold; /* Free-space section threshold */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*Ff*h", plist_id, strategy, threshold); /* Get current file space info */ - if(H5Pget_file_space_strategy(plist_id, &new_strategy, &new_persist, &new_threshold) < 0) + if (H5Pget_file_space_strategy(plist_id, &new_strategy, &new_persist, &new_threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy") /* Get value(s) */ - if(strategy) { - switch(new_strategy) { + if (strategy) { + switch (new_strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: - if(new_persist) + if (new_persist) *strategy = H5F_FILE_SPACE_ALL_PERSIST; else *strategy = H5F_FILE_SPACE_ALL; - break; + break; case H5F_FSPACE_STRATEGY_AGGR: *strategy = H5F_FILE_SPACE_AGGR_VFD; @@ -659,11 +646,10 @@ H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *thre } } - if(threshold) + if (threshold) *threshold = new_threshold; done: FUNC_LEAVE_API(ret_value) } /* H5Pget_file_space() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index 3f5754e..b762ac5 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -26,21 +26,19 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -48,41 +46,44 @@ /* ======== Data transfer properties ======== */ /* Definitions for maximum temp buffer size property */ -#define H5D_XFER_MAX_TEMP_BUF_SIZE sizeof(size_t) -#define H5D_XFER_MAX_TEMP_BUF_DEF H5D_TEMP_BUF_SIZE -#define H5D_XFER_MAX_TEMP_BUF_ENC H5P__encode_size_t -#define H5D_XFER_MAX_TEMP_BUF_DEC H5P__decode_size_t +#define H5D_XFER_MAX_TEMP_BUF_SIZE sizeof(size_t) +#define H5D_XFER_MAX_TEMP_BUF_DEF H5D_TEMP_BUF_SIZE +#define H5D_XFER_MAX_TEMP_BUF_ENC H5P__encode_size_t +#define H5D_XFER_MAX_TEMP_BUF_DEC H5P__decode_size_t /* Definitions for type conversion buffer property */ -#define H5D_XFER_TCONV_BUF_SIZE sizeof(void *) -#define H5D_XFER_TCONV_BUF_DEF NULL +#define H5D_XFER_TCONV_BUF_SIZE sizeof(void *) +#define H5D_XFER_TCONV_BUF_DEF NULL /* Definitions for background buffer property */ -#define H5D_XFER_BKGR_BUF_SIZE sizeof(void *) -#define H5D_XFER_BKGR_BUF_DEF NULL +#define H5D_XFER_BKGR_BUF_SIZE sizeof(void *) +#define H5D_XFER_BKGR_BUF_DEF NULL /* Definitions for background buffer type property */ -#define H5D_XFER_BKGR_BUF_TYPE_SIZE sizeof(H5T_bkg_t) -#define H5D_XFER_BKGR_BUF_TYPE_DEF H5T_BKG_NO -#define H5D_XFER_BKGR_BUF_TYPE_ENC H5P__dxfr_bkgr_buf_type_enc -#define H5D_XFER_BKGR_BUF_TYPE_DEC H5P__dxfr_bkgr_buf_type_dec +#define H5D_XFER_BKGR_BUF_TYPE_SIZE sizeof(H5T_bkg_t) +#define H5D_XFER_BKGR_BUF_TYPE_DEF H5T_BKG_NO +#define H5D_XFER_BKGR_BUF_TYPE_ENC H5P__dxfr_bkgr_buf_type_enc +#define H5D_XFER_BKGR_BUF_TYPE_DEC H5P__dxfr_bkgr_buf_type_dec /* Definitions for B-tree node splitting ratio property */ /* (These default B-tree node splitting ratios are also used for splitting * group's B-trees as well as chunked dataset's B-trees - QAK) */ #define H5D_XFER_BTREE_SPLIT_RATIO_SIZE sizeof(double[3]) -#define H5D_XFER_BTREE_SPLIT_RATIO_DEF {0.1f, 0.5f, 0.9f} -#define H5D_XFER_BTREE_SPLIT_RATIO_ENC H5P__dxfr_btree_split_ratio_enc -#define H5D_XFER_BTREE_SPLIT_RATIO_DEC H5P__dxfr_btree_split_ratio_dec +#define H5D_XFER_BTREE_SPLIT_RATIO_DEF \ + { \ + 0.1f, 0.5f, 0.9f \ + } +#define H5D_XFER_BTREE_SPLIT_RATIO_ENC H5P__dxfr_btree_split_ratio_enc +#define H5D_XFER_BTREE_SPLIT_RATIO_DEC H5P__dxfr_btree_split_ratio_dec /* Definitions for vlen allocation function property */ -#define H5D_XFER_VLEN_ALLOC_SIZE sizeof(H5MM_allocate_t) -#define H5D_XFER_VLEN_ALLOC_DEF H5D_VLEN_ALLOC +#define H5D_XFER_VLEN_ALLOC_SIZE sizeof(H5MM_allocate_t) +#define H5D_XFER_VLEN_ALLOC_DEF H5D_VLEN_ALLOC /* Definitions for vlen allocation info property */ -#define H5D_XFER_VLEN_ALLOC_INFO_SIZE sizeof(void *) -#define H5D_XFER_VLEN_ALLOC_INFO_DEF H5D_VLEN_ALLOC_INFO +#define H5D_XFER_VLEN_ALLOC_INFO_SIZE sizeof(void *) +#define H5D_XFER_VLEN_ALLOC_INFO_DEF H5D_VLEN_ALLOC_INFO /* Definitions for vlen free function property */ -#define H5D_XFER_VLEN_FREE_SIZE sizeof(H5MM_free_t) -#define H5D_XFER_VLEN_FREE_DEF H5D_VLEN_FREE +#define H5D_XFER_VLEN_FREE_SIZE sizeof(H5MM_free_t) +#define H5D_XFER_VLEN_FREE_DEF H5D_VLEN_FREE /* Definitions for vlen free info property */ -#define H5D_XFER_VLEN_FREE_INFO_SIZE sizeof(void *) -#define H5D_XFER_VLEN_FREE_INFO_DEF H5D_VLEN_FREE_INFO +#define H5D_XFER_VLEN_FREE_INFO_SIZE sizeof(void *) +#define H5D_XFER_VLEN_FREE_INFO_DEF H5D_VLEN_FREE_INFO /* Definitions for hyperslab vector size property */ /* (Be cautious about increasing the default size, there are arrays allocated * on the stack which depend on it - QAK) @@ -99,71 +100,74 @@ */ /* Definitions for I/O transfer mode property */ -#define H5D_XFER_IO_XFER_MODE_SIZE sizeof(H5FD_mpio_xfer_t) -#define H5D_XFER_IO_XFER_MODE_DEF H5FD_MPIO_INDEPENDENT -#define H5D_XFER_IO_XFER_MODE_ENC H5P__dxfr_io_xfer_mode_enc -#define H5D_XFER_IO_XFER_MODE_DEC H5P__dxfr_io_xfer_mode_dec +#define H5D_XFER_IO_XFER_MODE_SIZE sizeof(H5FD_mpio_xfer_t) +#define H5D_XFER_IO_XFER_MODE_DEF H5FD_MPIO_INDEPENDENT +#define H5D_XFER_IO_XFER_MODE_ENC H5P__dxfr_io_xfer_mode_enc +#define H5D_XFER_IO_XFER_MODE_DEC H5P__dxfr_io_xfer_mode_dec /* Definitions for optimization of MPI-IO transfer mode property */ -#define H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE sizeof(H5FD_mpio_collective_opt_t) -#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEF H5FD_MPIO_COLLECTIVE_IO -#define H5D_XFER_MPIO_COLLECTIVE_OPT_ENC H5P__dxfr_mpio_collective_opt_enc -#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEC H5P__dxfr_mpio_collective_opt_dec -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE sizeof(H5FD_mpio_chunk_opt_t) -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF H5FD_MPIO_CHUNK_DEFAULT -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC H5P__dxfr_mpio_chunk_opt_hard_enc -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC H5P__dxfr_mpio_chunk_opt_hard_dec -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE sizeof(unsigned) -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF H5D_ONE_LINK_CHUNK_IO_THRESHOLD -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC H5P__encode_unsigned -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC H5P__decode_unsigned -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE sizeof(unsigned) -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF H5D_MULTI_CHUNK_IO_COL_THRESHOLD -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC H5P__encode_unsigned -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC H5P__decode_unsigned +#define H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE sizeof(H5FD_mpio_collective_opt_t) +#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEF H5FD_MPIO_COLLECTIVE_IO +#define H5D_XFER_MPIO_COLLECTIVE_OPT_ENC H5P__dxfr_mpio_collective_opt_enc +#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEC H5P__dxfr_mpio_collective_opt_dec +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE sizeof(H5FD_mpio_chunk_opt_t) +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF H5FD_MPIO_CHUNK_DEFAULT +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC H5P__dxfr_mpio_chunk_opt_hard_enc +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC H5P__dxfr_mpio_chunk_opt_hard_dec +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE sizeof(unsigned) +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF H5D_ONE_LINK_CHUNK_IO_THRESHOLD +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC H5P__encode_unsigned +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC H5P__decode_unsigned +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE sizeof(unsigned) +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF H5D_MULTI_CHUNK_IO_COL_THRESHOLD +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC H5P__encode_unsigned +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC H5P__decode_unsigned /* Definitions for chunk opt mode property. */ -#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE sizeof(H5D_mpio_actual_chunk_opt_mode_t) -#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF H5D_MPIO_NO_CHUNK_OPTIMIZATION +#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE sizeof(H5D_mpio_actual_chunk_opt_mode_t) +#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF H5D_MPIO_NO_CHUNK_OPTIMIZATION /* Definitions for chunk io mode property. */ -#define H5D_MPIO_ACTUAL_IO_MODE_SIZE sizeof(H5D_mpio_actual_io_mode_t) -#define H5D_MPIO_ACTUAL_IO_MODE_DEF H5D_MPIO_NO_COLLECTIVE +#define H5D_MPIO_ACTUAL_IO_MODE_SIZE sizeof(H5D_mpio_actual_io_mode_t) +#define H5D_MPIO_ACTUAL_IO_MODE_DEF H5D_MPIO_NO_COLLECTIVE /* Definitions for cause of broken collective io property */ -#define H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE sizeof(uint32_t) -#define H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF H5D_MPIO_COLLECTIVE +#define H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE sizeof(uint32_t) +#define H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF H5D_MPIO_COLLECTIVE /* Definitions for EDC property */ -#define H5D_XFER_EDC_SIZE sizeof(H5Z_EDC_t) -#define H5D_XFER_EDC_DEF H5Z_ENABLE_EDC -#define H5D_XFER_EDC_ENC H5P__dxfr_edc_enc -#define H5D_XFER_EDC_DEC H5P__dxfr_edc_dec +#define H5D_XFER_EDC_SIZE sizeof(H5Z_EDC_t) +#define H5D_XFER_EDC_DEF H5Z_ENABLE_EDC +#define H5D_XFER_EDC_ENC H5P__dxfr_edc_enc +#define H5D_XFER_EDC_DEC H5P__dxfr_edc_dec /* Definitions for filter callback function property */ -#define H5D_XFER_FILTER_CB_SIZE sizeof(H5Z_cb_t) -#define H5D_XFER_FILTER_CB_DEF {NULL,NULL} +#define H5D_XFER_FILTER_CB_SIZE sizeof(H5Z_cb_t) +#define H5D_XFER_FILTER_CB_DEF \ + { \ + NULL, NULL \ + } /* Definitions for type conversion callback function property */ -#define H5D_XFER_CONV_CB_SIZE sizeof(H5T_conv_cb_t) -#define H5D_XFER_CONV_CB_DEF {NULL,NULL} +#define H5D_XFER_CONV_CB_SIZE sizeof(H5T_conv_cb_t) +#define H5D_XFER_CONV_CB_DEF \ + { \ + NULL, NULL \ + } /* Definitions for data transform property */ -#define H5D_XFER_XFORM_SIZE sizeof(void *) -#define H5D_XFER_XFORM_DEF NULL -#define H5D_XFER_XFORM_SET H5P__dxfr_xform_set -#define H5D_XFER_XFORM_GET H5P__dxfr_xform_get -#define H5D_XFER_XFORM_ENC H5P__dxfr_xform_enc -#define H5D_XFER_XFORM_DEC H5P__dxfr_xform_dec -#define H5D_XFER_XFORM_DEL H5P__dxfr_xform_del -#define H5D_XFER_XFORM_COPY H5P__dxfr_xform_copy -#define H5D_XFER_XFORM_CMP H5P__dxfr_xform_cmp -#define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close - +#define H5D_XFER_XFORM_SIZE sizeof(void *) +#define H5D_XFER_XFORM_DEF NULL +#define H5D_XFER_XFORM_SET H5P__dxfr_xform_set +#define H5D_XFER_XFORM_GET H5P__dxfr_xform_get +#define H5D_XFER_XFORM_ENC H5P__dxfr_xform_enc +#define H5D_XFER_XFORM_DEC H5P__dxfr_xform_dec +#define H5D_XFER_XFORM_DEL H5P__dxfr_xform_del +#define H5D_XFER_XFORM_COPY H5P__dxfr_xform_copy +#define H5D_XFER_XFORM_CMP H5P__dxfr_xform_cmp +#define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -184,15 +188,14 @@ static herr_t H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **pp, si static herr_t H5P__dxfr_mpio_chunk_opt_hard_dec(const void **pp, void *value); static herr_t H5P__dxfr_edc_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dxfr_edc_dec(const void **pp, void *value); -static herr_t H5P__dxfr_xform_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dxfr_xform_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__dxfr_xform_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dxfr_xform_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dxfr_xform_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dxfr_xform_dec(const void **pp, void *value); -static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dxfr_xform_copy(const char* name, size_t size, void* value); -static int H5P__dxfr_xform_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__dxfr_xform_close(const char* name, size_t size, void* value); - +static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dxfr_xform_copy(const char *name, size_t size, void *value); +static int H5P__dxfr_xform_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dxfr_xform_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -200,58 +203,67 @@ static herr_t H5P__dxfr_xform_close(const char* name, size_t size, void* value); /* Data transfer property list class library initialization object */ const H5P_libclass_t H5P_CLS_DXFR[1] = {{ - "data transfer", /* Class name for debugging */ - H5P_TYPE_DATASET_XFER, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_DATASET_XFER_g, /* Pointer to class */ - &H5P_CLS_DATASET_XFER_ID_g, /* Pointer to class ID */ - &H5P_LST_DATASET_XFER_ID_g, /* Pointer to default property list ID */ - H5P__dxfr_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "data transfer", /* Class name for debugging */ + H5P_TYPE_DATASET_XFER, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_DATASET_XFER_g, /* Pointer to class */ + &H5P_CLS_DATASET_XFER_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_XFER_ID_g, /* Pointer to default property list ID */ + H5P__dxfr_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /***************************/ /* Local Private Variables */ /***************************/ /* Property value defaults */ -static const size_t H5D_def_max_temp_buf_g = H5D_XFER_MAX_TEMP_BUF_DEF; /* Default value for maximum temp buffer size */ -static const void *H5D_def_tconv_buf_g = H5D_XFER_TCONV_BUF_DEF; /* Default value for type conversion buffer */ -static const void *H5D_def_bkgr_buf_g = H5D_XFER_BKGR_BUF_DEF; /* Default value for background buffer */ +static const size_t H5D_def_max_temp_buf_g = + H5D_XFER_MAX_TEMP_BUF_DEF; /* Default value for maximum temp buffer size */ +static const void *H5D_def_tconv_buf_g = + H5D_XFER_TCONV_BUF_DEF; /* Default value for type conversion buffer */ +static const void * H5D_def_bkgr_buf_g = H5D_XFER_BKGR_BUF_DEF; /* Default value for background buffer */ static const H5T_bkg_t H5D_def_bkgr_buf_type_g = H5D_XFER_BKGR_BUF_TYPE_DEF; -static const double H5D_def_btree_split_ratio_g[3] = H5D_XFER_BTREE_SPLIT_RATIO_DEF; /* Default value for B-tree node split ratios */ -static const H5MM_allocate_t H5D_def_vlen_alloc_g = H5D_XFER_VLEN_ALLOC_DEF; /* Default value for vlen allocation function */ -static const void *H5D_def_vlen_alloc_info_g = H5D_XFER_VLEN_ALLOC_INFO_DEF; /* Default value for vlen allocation information */ -static const H5MM_free_t H5D_def_vlen_free_g = H5D_XFER_VLEN_FREE_DEF; /* Default value for vlen free function */ -static const void *H5D_def_vlen_free_info_g = H5D_XFER_VLEN_FREE_INFO_DEF; /* Default value for vlen free information */ -static const size_t H5D_def_hyp_vec_size_g = H5D_XFER_HYPER_VECTOR_SIZE_DEF; /* Default value for vector size */ -static const H5FD_mpio_xfer_t H5D_def_io_xfer_mode_g = H5D_XFER_IO_XFER_MODE_DEF; /* Default value for I/O transfer mode */ -static const H5FD_mpio_chunk_opt_t H5D_def_mpio_chunk_opt_mode_g = H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF; +static const double H5D_def_btree_split_ratio_g[3] = + H5D_XFER_BTREE_SPLIT_RATIO_DEF; /* Default value for B-tree node split ratios */ +static const H5MM_allocate_t H5D_def_vlen_alloc_g = + H5D_XFER_VLEN_ALLOC_DEF; /* Default value for vlen allocation function */ +static const void *H5D_def_vlen_alloc_info_g = + H5D_XFER_VLEN_ALLOC_INFO_DEF; /* Default value for vlen allocation information */ +static const H5MM_free_t H5D_def_vlen_free_g = + H5D_XFER_VLEN_FREE_DEF; /* Default value for vlen free function */ +static const void *H5D_def_vlen_free_info_g = + H5D_XFER_VLEN_FREE_INFO_DEF; /* Default value for vlen free information */ +static const size_t H5D_def_hyp_vec_size_g = + H5D_XFER_HYPER_VECTOR_SIZE_DEF; /* Default value for vector size */ +static const H5FD_mpio_xfer_t H5D_def_io_xfer_mode_g = + H5D_XFER_IO_XFER_MODE_DEF; /* Default value for I/O transfer mode */ +static const H5FD_mpio_chunk_opt_t H5D_def_mpio_chunk_opt_mode_g = H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF; static const H5FD_mpio_collective_opt_t H5D_def_mpio_collective_opt_mode_g = H5D_XFER_MPIO_COLLECTIVE_OPT_DEF; -static const unsigned H5D_def_mpio_chunk_opt_num_g = H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF; -static const unsigned H5D_def_mpio_chunk_opt_ratio_g = H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF; -static const H5D_mpio_actual_chunk_opt_mode_t H5D_def_mpio_actual_chunk_opt_mode_g = H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF; -static const H5D_mpio_actual_io_mode_t H5D_def_mpio_actual_io_mode_g = H5D_MPIO_ACTUAL_IO_MODE_DEF; -static const H5D_mpio_no_collective_cause_t H5D_def_mpio_no_collective_cause_g = H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF; -static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF; /* Default value for EDC property */ -static const H5Z_cb_t H5D_def_filter_cb_g = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */ -static const H5T_conv_cb_t H5D_def_conv_cb_g = H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */ -static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ - - +static const unsigned H5D_def_mpio_chunk_opt_num_g = H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF; +static const unsigned H5D_def_mpio_chunk_opt_ratio_g = H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF; +static const H5D_mpio_actual_chunk_opt_mode_t H5D_def_mpio_actual_chunk_opt_mode_g = + H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF; +static const H5D_mpio_actual_io_mode_t H5D_def_mpio_actual_io_mode_g = H5D_MPIO_ACTUAL_IO_MODE_DEF; +static const H5D_mpio_no_collective_cause_t H5D_def_mpio_no_collective_cause_g = + H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF; +static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF; /* Default value for EDC property */ +static const H5Z_cb_t H5D_def_filter_cb_g = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */ +static const H5T_conv_cb_t H5D_def_conv_cb_g = + H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */ +static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ + /*------------------------------------------------------------------------- * Function: H5P__dxfr_reg_prop * @@ -266,145 +278,152 @@ static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Defaul static herr_t H5P__dxfr_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the max. temp buffer size property */ - if(H5P__register_real(pclass, H5D_XFER_MAX_TEMP_BUF_NAME, H5D_XFER_MAX_TEMP_BUF_SIZE, &H5D_def_max_temp_buf_g, - NULL, NULL, NULL, H5D_XFER_MAX_TEMP_BUF_ENC, H5D_XFER_MAX_TEMP_BUF_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MAX_TEMP_BUF_NAME, H5D_XFER_MAX_TEMP_BUF_SIZE, + &H5D_def_max_temp_buf_g, NULL, NULL, NULL, H5D_XFER_MAX_TEMP_BUF_ENC, + H5D_XFER_MAX_TEMP_BUF_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the type conversion buffer property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_TCONV_BUF_NAME, H5D_XFER_TCONV_BUF_SIZE, &H5D_def_tconv_buf_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_TCONV_BUF_NAME, H5D_XFER_TCONV_BUF_SIZE, &H5D_def_tconv_buf_g, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the background buffer property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_BKGR_BUF_NAME, H5D_XFER_BKGR_BUF_SIZE, &H5D_def_bkgr_buf_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_BKGR_BUF_NAME, H5D_XFER_BKGR_BUF_SIZE, &H5D_def_bkgr_buf_g, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the background buffer type property */ - if(H5P__register_real(pclass, H5D_XFER_BKGR_BUF_TYPE_NAME, H5D_XFER_BKGR_BUF_TYPE_SIZE, &H5D_def_bkgr_buf_type_g, - NULL, NULL, NULL, H5D_XFER_BKGR_BUF_TYPE_ENC, H5D_XFER_BKGR_BUF_TYPE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_BKGR_BUF_TYPE_NAME, H5D_XFER_BKGR_BUF_TYPE_SIZE, + &H5D_def_bkgr_buf_type_g, NULL, NULL, NULL, H5D_XFER_BKGR_BUF_TYPE_ENC, + H5D_XFER_BKGR_BUF_TYPE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the B-Tree node splitting ratios property */ - if(H5P__register_real(pclass, H5D_XFER_BTREE_SPLIT_RATIO_NAME, H5D_XFER_BTREE_SPLIT_RATIO_SIZE, H5D_def_btree_split_ratio_g, - NULL, NULL, NULL, H5D_XFER_BTREE_SPLIT_RATIO_ENC, H5D_XFER_BTREE_SPLIT_RATIO_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_BTREE_SPLIT_RATIO_NAME, H5D_XFER_BTREE_SPLIT_RATIO_SIZE, + H5D_def_btree_split_ratio_g, NULL, NULL, NULL, H5D_XFER_BTREE_SPLIT_RATIO_ENC, + H5D_XFER_BTREE_SPLIT_RATIO_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen allocation function property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_NAME, H5D_XFER_VLEN_ALLOC_SIZE, &H5D_def_vlen_alloc_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_NAME, H5D_XFER_VLEN_ALLOC_SIZE, &H5D_def_vlen_alloc_g, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen allocation information property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_INFO_NAME, H5D_XFER_VLEN_ALLOC_INFO_SIZE, &H5D_def_vlen_alloc_info_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_INFO_NAME, H5D_XFER_VLEN_ALLOC_INFO_SIZE, + &H5D_def_vlen_alloc_info_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen free function property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_VLEN_FREE_NAME, H5D_XFER_VLEN_FREE_SIZE, &H5D_def_vlen_free_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_VLEN_FREE_NAME, H5D_XFER_VLEN_FREE_SIZE, &H5D_def_vlen_free_g, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen free information property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_VLEN_FREE_INFO_NAME, H5D_XFER_VLEN_FREE_INFO_SIZE, &H5D_def_vlen_free_info_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_VLEN_FREE_INFO_NAME, H5D_XFER_VLEN_FREE_INFO_SIZE, + &H5D_def_vlen_free_info_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vector size property */ - if(H5P__register_real(pclass, H5D_XFER_HYPER_VECTOR_SIZE_NAME, H5D_XFER_HYPER_VECTOR_SIZE_SIZE, &H5D_def_hyp_vec_size_g, - NULL, NULL, NULL, H5D_XFER_HYPER_VECTOR_SIZE_ENC, H5D_XFER_HYPER_VECTOR_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_HYPER_VECTOR_SIZE_NAME, H5D_XFER_HYPER_VECTOR_SIZE_SIZE, + &H5D_def_hyp_vec_size_g, NULL, NULL, NULL, H5D_XFER_HYPER_VECTOR_SIZE_ENC, + H5D_XFER_HYPER_VECTOR_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the I/O transfer mode properties */ - if(H5P__register_real(pclass, H5D_XFER_IO_XFER_MODE_NAME, H5D_XFER_IO_XFER_MODE_SIZE, &H5D_def_io_xfer_mode_g, - NULL, NULL, NULL, H5D_XFER_IO_XFER_MODE_ENC, H5D_XFER_IO_XFER_MODE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_IO_XFER_MODE_NAME, H5D_XFER_IO_XFER_MODE_SIZE, + &H5D_def_io_xfer_mode_g, NULL, NULL, NULL, H5D_XFER_IO_XFER_MODE_ENC, + H5D_XFER_IO_XFER_MODE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE, &H5D_def_mpio_collective_opt_mode_g, - NULL, NULL, NULL, H5D_XFER_MPIO_COLLECTIVE_OPT_ENC, H5D_XFER_MPIO_COLLECTIVE_OPT_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE, + &H5D_def_mpio_collective_opt_mode_g, NULL, NULL, NULL, + H5D_XFER_MPIO_COLLECTIVE_OPT_ENC, H5D_XFER_MPIO_COLLECTIVE_OPT_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE, &H5D_def_mpio_chunk_opt_mode_g, - NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC, H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE, + &H5D_def_mpio_chunk_opt_mode_g, NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC, + H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE, &H5D_def_mpio_chunk_opt_num_g, - NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC, H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE, + &H5D_def_mpio_chunk_opt_num_g, NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC, + H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE, &H5D_def_mpio_chunk_opt_ratio_g, - NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC, H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE, + &H5D_def_mpio_chunk_opt_ratio_g, NULL, NULL, NULL, + H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC, H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the chunk optimization mode property. */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE, &H5D_def_mpio_actual_chunk_opt_mode_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE, + &H5D_def_mpio_actual_chunk_opt_mode_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the actual I/O mode property. */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_MPIO_ACTUAL_IO_MODE_NAME, H5D_MPIO_ACTUAL_IO_MODE_SIZE, &H5D_def_mpio_actual_io_mode_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_MPIO_ACTUAL_IO_MODE_NAME, H5D_MPIO_ACTUAL_IO_MODE_SIZE, + &H5D_def_mpio_actual_io_mode_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the local cause of broken collective I/O */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, &H5D_def_mpio_no_collective_cause_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, + &H5D_def_mpio_no_collective_cause_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the global cause of broken collective I/O */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, &H5D_def_mpio_no_collective_cause_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, + H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, &H5D_def_mpio_no_collective_cause_g, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the EDC property */ - if(H5P__register_real(pclass, H5D_XFER_EDC_NAME, H5D_XFER_EDC_SIZE, &H5D_def_enable_edc_g, - NULL, NULL, NULL, H5D_XFER_EDC_ENC, H5D_XFER_EDC_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_EDC_NAME, H5D_XFER_EDC_SIZE, &H5D_def_enable_edc_g, NULL, NULL, + NULL, H5D_XFER_EDC_ENC, H5D_XFER_EDC_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the filter callback property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_FILTER_CB_NAME, H5D_XFER_FILTER_CB_SIZE, &H5D_def_filter_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_FILTER_CB_NAME, H5D_XFER_FILTER_CB_SIZE, &H5D_def_filter_cb_g, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the type conversion callback property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_CONV_CB_NAME, H5D_XFER_CONV_CB_SIZE, &H5D_def_conv_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_CONV_CB_NAME, H5D_XFER_CONV_CB_SIZE, &H5D_def_conv_cb_g, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the data transform property */ - if(H5P__register_real(pclass, H5D_XFER_XFORM_NAME, H5D_XFER_XFORM_SIZE, &H5D_def_xfer_xform_g, - NULL, H5D_XFER_XFORM_SET, H5D_XFER_XFORM_GET, H5D_XFER_XFORM_ENC, H5D_XFER_XFORM_DEC, - H5D_XFER_XFORM_DEL, H5D_XFER_XFORM_COPY, H5D_XFER_XFORM_CMP, H5D_XFER_XFORM_CLOSE) < 0) + if (H5P__register_real(pclass, H5D_XFER_XFORM_NAME, H5D_XFER_XFORM_SIZE, &H5D_def_xfer_xform_g, NULL, + H5D_XFER_XFORM_SET, H5D_XFER_XFORM_GET, H5D_XFER_XFORM_ENC, H5D_XFER_XFORM_DEC, + H5D_XFER_XFORM_DEL, H5D_XFER_XFORM_COPY, H5D_XFER_XFORM_CMP, + H5D_XFER_XFORM_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_bkgr_buf_type_enc * @@ -424,7 +443,7 @@ static herr_t H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size) { const H5T_bkg_t *bkgr_buf_type = (const H5T_bkg_t *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -432,7 +451,7 @@ H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size) HDassert(bkgr_buf_type); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode background buffer type */ *(*pp)++ = (uint8_t)*bkgr_buf_type; @@ -442,7 +461,6 @@ H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_bkgr_buf_type_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_bkgr_buf_type_dec * @@ -461,8 +479,8 @@ H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_bkgr_buf_type_dec(const void **_pp, void *_value) { - H5T_bkg_t *bkgr_buf_type = (H5T_bkg_t *)_value; /* Background buffer type */ - const uint8_t **pp = (const uint8_t **)_pp; + H5T_bkg_t * bkgr_buf_type = (H5T_bkg_t *)_value; /* Background buffer type */ + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -472,12 +490,11 @@ H5P__dxfr_bkgr_buf_type_dec(const void **_pp, void *_value) HDassert(bkgr_buf_type); /* Decode background buffer type */ - *bkgr_buf_type = (H5T_bkg_t)*(*pp)++; + *bkgr_buf_type = (H5T_bkg_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_bkgr_buf_type_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_btree_split_ratio_enc * @@ -497,7 +514,7 @@ static herr_t H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) { const double *btree_split_ratio = (const double *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -505,7 +522,7 @@ H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) HDassert(btree_split_ratio); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size of a double*/ *(*pp)++ = (uint8_t)sizeof(double); @@ -527,7 +544,6 @@ H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_btree_split_ratio_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_btree_split_ratio_dec * @@ -546,10 +562,10 @@ H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value) { - double *btree_split_ratio = (double *)_value; /* B-tree split ratio */ - unsigned enc_size; /* Size of encoded property */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + double * btree_split_ratio = (double *)_value; /* B-tree split ratio */ + unsigned enc_size; /* Size of encoded property */ + const uint8_t **pp = (const uint8_t **)_pp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -560,7 +576,7 @@ H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(double)) + if (enc_size != sizeof(double)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded") /* Decode the left, middle & left B-tree split ratios */ @@ -572,7 +588,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_btree_split_ratio_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_set * @@ -587,10 +602,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) +H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -598,14 +613,13 @@ H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *nam HDassert(value); /* Make copy of data transform */ - if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_get * @@ -620,10 +634,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) +H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -631,14 +645,13 @@ H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *nam HDassert(value); /* Make copy of data transform */ - if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_enc * @@ -657,11 +670,12 @@ done: static herr_t H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size) { - const H5Z_data_xform_t *data_xform_prop = *(const H5Z_data_xform_t * const *)value; /* Create local alias for values */ - const char *pexp = NULL; /* Pointer to transform expression */ - size_t len = 0; /* Length of transform expression */ - uint8_t **pp = (uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + const H5Z_data_xform_t *data_xform_prop = + *(const H5Z_data_xform_t *const *)value; /* Create local alias for values */ + const char *pexp = NULL; /* Pointer to transform expression */ + size_t len = 0; /* Length of transform expression */ + uint8_t ** pp = (uint8_t **)_pp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -670,27 +684,27 @@ H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size) HDassert(size); /* Check for data transform set */ - if(NULL != data_xform_prop) { + if (NULL != data_xform_prop) { /* Get the transform expression */ - if(NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) + if (NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression") /* Get the transform string expression size */ len = HDstrlen(pexp) + 1; } /* end if */ - if(NULL != *pp) { + if (NULL != *pp) { uint64_t enc_value; unsigned enc_size; /* encode the length of the prefix */ enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); - if(NULL != data_xform_prop) { + if (NULL != data_xform_prop) { /* Sanity check */ HDassert(pexp); @@ -699,18 +713,17 @@ H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size) *pp += len; *pp[0] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ /* Size of encoded data transform */ *size += (1 + H5VM_limit_enc_size((uint64_t)len)); - if(NULL != pexp) + if (NULL != pexp) *size += len; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_dec * @@ -729,12 +742,12 @@ done: static herr_t H5P__dxfr_xform_dec(const void **_pp, void *_value) { - H5Z_data_xform_t **data_xform_prop = (H5Z_data_xform_t **)_value; /* New data xform property */ - size_t len; /* Length of encoded string */ - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; - uint64_t enc_value; - herr_t ret_value = SUCCEED; /* Return value */ + H5Z_data_xform_t **data_xform_prop = (H5Z_data_xform_t **)_value; /* New data xform property */ + size_t len; /* Length of encoded string */ + const uint8_t ** pp = (const uint8_t **)_pp; + unsigned enc_size; + uint64_t enc_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -750,8 +763,8 @@ H5P__dxfr_xform_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = (size_t)enc_value; - if(0 != len) { - if(NULL == (*data_xform_prop = H5Z_xform_create((const char *)*pp))) + if (0 != len) { + if (NULL == (*data_xform_prop = H5Z_xform_create((const char *)*pp))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create data transform info") *pp += len; } /* end if */ @@ -762,7 +775,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_del * @@ -777,22 +789,22 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__dxfr_xform_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__dxfr_xform_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(value); - if(H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing the parse tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_del() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_copy * @@ -810,7 +822,7 @@ done: static herr_t H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -818,14 +830,13 @@ H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size HDassert(value); /* Make copy of data transform */ - if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_cmp * @@ -842,10 +853,12 @@ done: static int H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNUSED size) { - const H5Z_data_xform_t * const *xform1 = (const H5Z_data_xform_t * const *)_xform1; /* Create local aliases for values */ - const H5Z_data_xform_t * const *xform2 = (const H5Z_data_xform_t * const *)_xform2; /* Create local aliases for values */ - const char *pexp1, *pexp2; /* Pointers to transform expressions */ - herr_t ret_value = 0; /* Return value */ + const H5Z_data_xform_t *const *xform1 = + (const H5Z_data_xform_t *const *)_xform1; /* Create local aliases for values */ + const H5Z_data_xform_t *const *xform2 = + (const H5Z_data_xform_t *const *)_xform2; /* Create local aliases for values */ + const char *pexp1, *pexp2; /* Pointers to transform expressions */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -855,10 +868,12 @@ H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNU HDassert(size == sizeof(H5Z_data_xform_t *)); /* Check for a property being set */ - if(*xform1 == NULL && *xform2 != NULL) HGOTO_DONE(-1); - if(*xform1 != NULL && *xform2 == NULL) HGOTO_DONE(1); + if (*xform1 == NULL && *xform2 != NULL) + HGOTO_DONE(-1); + if (*xform1 != NULL && *xform2 == NULL) + HGOTO_DONE(1); - if(*xform1) { + if (*xform1) { HDassert(*xform2); /* Get the transform expressions */ @@ -866,20 +881,21 @@ H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNU pexp2 = H5Z_xform_extract_xform_str(*xform2); /* Check for property expressions */ - if(pexp1 == NULL && pexp2 != NULL) HGOTO_DONE(-1); - if(pexp1 != NULL && pexp2 == NULL) HGOTO_DONE(1); + if (pexp1 == NULL && pexp2 != NULL) + HGOTO_DONE(-1); + if (pexp1 != NULL && pexp2 == NULL) + HGOTO_DONE(1); - if(pexp1) { + if (pexp1) { HDassert(pexp2); ret_value = HDstrcmp(pexp1, pexp2); } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_close * @@ -896,20 +912,19 @@ done: static herr_t H5P__dxfr_xform_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(value); - if(H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing the parse tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_data_transform * @@ -925,46 +940,45 @@ done: herr_t H5Pset_data_transform(hid_t plist_id, const char *expression) { - H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t * plist; /* Property list pointer */ H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */ - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, expression); /* Check arguments */ - if(expression == NULL) + if (expression == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "expression cannot be NULL") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* See if a data transform is already set, and free it if it is */ - if(H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + if (H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression") /* Destroy previous data transform property */ - if(H5Z_xform_destroy(data_xform_prop) < 0) + if (H5Z_xform_destroy(data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") /* Create data transform info from expression */ - if(NULL == (data_xform_prop = H5Z_xform_create(expression))) + if (NULL == (data_xform_prop = H5Z_xform_create(expression))) HGOTO_ERROR(H5E_PLINE, H5E_NOSPACE, FAIL, "unable to create data transform info") /* Update property list (takes ownership of transform) */ - if(H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + if (H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Error setting data transform expression") done: - if(ret_value < 0) - if(data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) + if (ret_value < 0) + if (data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") FUNC_LEAVE_API(ret_value) } /* end H5Pset_data_transform() */ - /*------------------------------------------------------------------------- * Function: H5Pget_data_transform * @@ -990,34 +1004,34 @@ done: ssize_t H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */ - size_t len; - const char* pexp; - ssize_t ret_value; /* return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */ + size_t len; + const char * pexp; + ssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "ixz", plist_id, expression, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + if (H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression") - if(NULL == data_xform_prop) + if (NULL == data_xform_prop) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "data transform has not been set") /* Get the data transform string */ - if(NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression") + if (NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression") /* Copy into application buffer */ len = HDstrlen(pexp); - if(expression) { - HDstrncpy(expression, pexp, MIN(len + 1, size)); - if(len >= size) + if (expression) { + HDstrncpy(expression, pexp, MIN(len + 1, size)); + if (len >= size) expression[size - 1] = '\0'; } /* end if */ @@ -1027,7 +1041,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_data_transform() */ - /*------------------------------------------------------------------------- * Function: H5Pset_buffer * @@ -1052,33 +1065,32 @@ done: herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iz*x*x", plist_id, size, tconv, bkg); /* Check arguments */ - if(size == 0) + if (size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size must not be zero") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0) + if (H5P_set(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer buffer size") - if(H5P_set(plist, H5D_XFER_TCONV_BUF_NAME, &tconv) < 0) + if (H5P_set(plist, H5D_XFER_TCONV_BUF_NAME, &tconv) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer type conversion buffer") - if(H5P_set(plist, H5D_XFER_BKGR_BUF_NAME, &bkg) < 0) + if (H5P_set(plist, H5D_XFER_BKGR_BUF_NAME, &bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set background type conversion buffer") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_buffer() */ - /*------------------------------------------------------------------------- * Function: H5Pget_buffer * @@ -1094,29 +1106,29 @@ done: *------------------------------------------------------------------------- */ size_t -H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) +H5Pget_buffer(hid_t plist_id, void **tconv /*out*/, void **bkg /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - size_t size; /* Type conversion buffer size */ - size_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + size_t size; /* Type conversion buffer size */ + size_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE3("z", "ixx", plist_id, tconv, bkg); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, 0, "can't find object for ID") /* Return values */ - if(tconv) - if(H5P_get(plist, H5D_XFER_TCONV_BUF_NAME, tconv) < 0) + if (tconv) + if (H5P_get(plist, H5D_XFER_TCONV_BUF_NAME, tconv) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "Can't get transfer type conversion buffer") - if(bkg) - if(H5P_get(plist, H5D_XFER_BKGR_BUF_NAME, bkg) < 0) + if (bkg) + if (H5P_get(plist, H5D_XFER_BKGR_BUF_NAME, bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "Can't get background type conversion buffer") /* Get the size */ - if(H5P_get(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0) + if (H5P_get(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, 0, "Can't set transfer buffer size") /* Set the return value */ @@ -1126,7 +1138,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_buffer() */ - /*------------------------------------------------------------------------- * Function: H5Pset_preserve * @@ -1146,27 +1157,26 @@ done: herr_t H5Pset_preserve(hid_t plist_id, hbool_t status) { - H5P_genplist_t *plist; /* Property list pointer */ - H5T_bkg_t need_bkg; /* Value for background buffer type */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5T_bkg_t need_bkg; /* Value for background buffer type */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", plist_id, status); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ need_bkg = status ? H5T_BKG_YES : H5T_BKG_NO; - if(H5P_set(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0) + if (H5P_set(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_preserve() */ - /*------------------------------------------------------------------------- * Function: H5Pget_preserve * @@ -1184,19 +1194,19 @@ done: int H5Pget_preserve(hid_t plist_id) { - H5T_bkg_t need_bkg; /* Background value */ - H5P_genplist_t *plist; /* Property list pointer */ - int ret_value; /* return value */ + H5T_bkg_t need_bkg; /* Background value */ + H5P_genplist_t *plist; /* Property list pointer */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_get(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0) + if (H5P_get(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") /* Set return value */ @@ -1206,7 +1216,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_preserve() */ - /*------------------------------------------------------------------------- * Function: H5Pset_edc_check * @@ -1225,29 +1234,28 @@ done: herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iZe", plist_id, check); /* Check argument */ - if(check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC) + if (check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid value") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_XFER_EDC_NAME, &check) < 0) + if (H5P_set(plist, H5D_XFER_EDC_NAME, &check) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_edc_check() */ - /*------------------------------------------------------------------------- * Function: H5Pget_edc_check * @@ -1266,25 +1274,24 @@ done: H5Z_EDC_t H5Pget_edc_check(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list pointer */ - H5Z_EDC_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5Z_EDC_t ret_value; /* Return value */ FUNC_ENTER_API(H5Z_ERROR_EDC) H5TRACE1("Ze", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_ERROR_EDC, "can't find object for ID") /* Update property list */ - if(H5P_get(plist, H5D_XFER_EDC_NAME, &ret_value) < 0) + if (H5P_get(plist, H5D_XFER_EDC_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5Z_ERROR_EDC, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_edc_check() */ - /*------------------------------------------------------------------------- * Function: H5Pset_filter_callback * @@ -1304,29 +1311,28 @@ done: herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void *op_data) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ - H5Z_cb_t cb_struct; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + H5Z_cb_t cb_struct; FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", plist_id, func, op_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - cb_struct.func = func; + cb_struct.func = func; cb_struct.op_data = op_data; - if (H5P_set(plist,H5D_XFER_FILTER_CB_NAME,&cb_struct)<0) + if (H5P_set(plist, H5D_XFER_FILTER_CB_NAME, &cb_struct) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_type_conv_cb * @@ -1346,29 +1352,28 @@ done: herr_t H5Pset_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t op, void *operate_data) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ - H5T_conv_cb_t cb_struct; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + H5T_conv_cb_t cb_struct; FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", plist_id, op, operate_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - cb_struct.func = op; + cb_struct.func = op; cb_struct.user_data = operate_data; - if (H5P_set(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) + if (H5P_set(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_type_conv_cb * @@ -1388,30 +1393,29 @@ done: herr_t H5Pget_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t *op, void **operate_data) { - H5P_genplist_t *plist; /* Property list pointer */ - H5T_conv_cb_t cb_struct; - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5T_conv_cb_t cb_struct; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", plist_id, op, operate_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get property */ - if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) + if (H5P_get(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") /* Assign return value */ - *op = cb_struct.func; + *op = cb_struct.func; *operate_data = cb_struct.user_data; done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_btree_ratios * @@ -1428,37 +1432,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_btree_ratios(hid_t plist_id, double *left/*out*/, double *middle/*out*/, - double *right/*out*/) +H5Pget_btree_ratios(hid_t plist_id, double *left /*out*/, double *middle /*out*/, double *right /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - double btree_split_ratio[3]; /* B-tree node split ratios */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + double btree_split_ratio[3]; /* B-tree node split ratios */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ixxx", plist_id, left, middle, right); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the split ratios */ - if(H5P_get(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &btree_split_ratio) < 0) + if (H5P_get(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &btree_split_ratio) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") /* Get values */ - if(left) + if (left) *left = btree_split_ratio[0]; - if(middle) + if (middle) *middle = btree_split_ratio[1]; - if(right) + if (right) *right = btree_split_ratio[2]; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_btree_ratios() */ - /*------------------------------------------------------------------------- * Function: H5Pset_btree_ratios * @@ -1480,24 +1482,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_btree_ratios(hid_t plist_id, double left, double middle, - double right) +H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right) { - H5P_genplist_t *plist; /* Property list pointer */ - double split_ratio[3]; /* B-tree node split ratios */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + double split_ratio[3]; /* B-tree node split ratios */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iddd", plist_id, left, middle, right); /* Check arguments */ - if(left < (double)0.0f || left > (double)1.0f - || middle < (double)0.0f || middle > (double)1.0f - || right < (double)0.0f || right > (double)1.0f) + if (left < (double)0.0f || left > (double)1.0f || middle < (double)0.0f || middle > (double)1.0f || + right < (double)0.0f || right > (double)1.0f) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "split ratio must satisfy 0.0<=X<=1.0") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ @@ -1506,14 +1506,13 @@ H5Pset_btree_ratios(hid_t plist_id, double left, double middle, split_ratio[2] = right; /* Set the split ratios */ - if(H5P_set(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratio) < 0) + if (H5P_set(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratio) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_btree_ratios() */ - /*------------------------------------------------------------------------- * Function: H5P_set_vlen_mem_manager * @@ -1534,30 +1533,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, - void *alloc_info, H5MM_free_t free_func, void *free_info) +H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, + H5MM_free_t free_func, void *free_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(plist); /* Update property list */ - if(H5P_set(plist, H5D_XFER_VLEN_ALLOC_NAME, &alloc_func) < 0) + if (H5P_set(plist, H5D_XFER_VLEN_ALLOC_NAME, &alloc_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") - if(H5P_set(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &alloc_info) < 0) + if (H5P_set(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &alloc_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") - if(H5P_set(plist, H5D_XFER_VLEN_FREE_NAME, &free_func) < 0) + if (H5P_set(plist, H5D_XFER_VLEN_FREE_NAME, &free_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") - if(H5P_set(plist, H5D_XFER_VLEN_FREE_INFO_NAME, &free_info) < 0) + if (H5P_set(plist, H5D_XFER_VLEN_FREE_INFO_NAME, &free_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_set_vlen_mem_manager() */ - /*------------------------------------------------------------------------- * Function: H5Pset_vlen_mem_manager * @@ -1578,29 +1576,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, - void *alloc_info, H5MM_free_t free_func, void *free_info) +H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, + void *free_info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ix*xx*x", plist_id, alloc_func, alloc_info, free_func, free_info); /* Check arguments */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Update property list */ - if(H5P_set_vlen_mem_manager(plist, alloc_func, alloc_info, free_func, free_info) < 0) + if (H5P_set_vlen_mem_manager(plist, alloc_func, alloc_info, free_func, free_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set values") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_vlen_mem_manager() */ - /*------------------------------------------------------------------------- * Function: H5Pget_vlen_mem_manager * @@ -1614,37 +1611,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func/*out*/, - void **alloc_info/*out*/, H5MM_free_t *free_func/*out*/, void **free_info/*out*/) +H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func /*out*/, void **alloc_info /*out*/, + H5MM_free_t *free_func /*out*/, void **free_info /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ixxxx", plist_id, alloc_func, alloc_info, free_func, free_info); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(alloc_func) - if(H5P_get(plist, H5D_XFER_VLEN_ALLOC_NAME, alloc_func) < 0) + if (alloc_func) + if (H5P_get(plist, H5D_XFER_VLEN_ALLOC_NAME, alloc_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if(alloc_info) - if(H5P_get(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, alloc_info) < 0) + if (alloc_info) + if (H5P_get(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, alloc_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if(free_func) - if(H5P_get(plist, H5D_XFER_VLEN_FREE_NAME, free_func) < 0) + if (free_func) + if (H5P_get(plist, H5D_XFER_VLEN_FREE_NAME, free_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if(free_info) - if(H5P_get(plist, H5D_XFER_VLEN_FREE_INFO_NAME, free_info) < 0) + if (free_info) + if (H5P_get(plist, H5D_XFER_VLEN_FREE_INFO_NAME, free_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_vlen_mem_manager() */ - /*------------------------------------------------------------------------- * Function: H5Pset_hyper_vector_size * @@ -1669,29 +1665,28 @@ done: herr_t H5Pset_hyper_vector_size(hid_t plist_id, size_t vector_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", plist_id, vector_size); /* Check arguments */ - if(vector_size < 1) + if (vector_size < 1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "vector size too small") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &vector_size) < 0) + if (H5P_set(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &vector_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_hyper_vector_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_hyper_vector_size * @@ -1705,28 +1700,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_hyper_vector_size(hid_t plist_id, size_t *vector_size/*out*/) +H5Pget_hyper_vector_size(hid_t plist_id, size_t *vector_size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, vector_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Return values */ - if(vector_size) - if(H5P_get(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, vector_size) < 0) + if (vector_size) + if (H5P_get(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, vector_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_hyper_vector_size() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_io_xfer_mode_enc * @@ -1746,7 +1740,7 @@ static herr_t H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size) { const H5FD_mpio_xfer_t *xfer_mode = (const H5FD_mpio_xfer_t *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1754,7 +1748,7 @@ H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size) HDassert(xfer_mode); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode I/O transfer mode */ *(*pp)++ = (uint8_t)*xfer_mode; @@ -1764,7 +1758,6 @@ H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_io_xfer_mode_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_io_xfer_mode_dec * @@ -1783,8 +1776,8 @@ H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_io_xfer_mode_dec(const void **_pp, void *_value) { - H5FD_mpio_xfer_t *xfer_mode = (H5FD_mpio_xfer_t *)_value; /* I/O transfer mode */ - const uint8_t **pp = (const uint8_t **)_pp; + H5FD_mpio_xfer_t *xfer_mode = (H5FD_mpio_xfer_t *)_value; /* I/O transfer mode */ + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1794,12 +1787,11 @@ H5P__dxfr_io_xfer_mode_dec(const void **_pp, void *_value) HDassert(xfer_mode); /* Decode I/O transfer mode */ - *xfer_mode = (H5FD_mpio_xfer_t)*(*pp)++; + *xfer_mode = (H5FD_mpio_xfer_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_io_xfer_mode_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_mpio_collective_opt_enc * @@ -1818,7 +1810,8 @@ H5P__dxfr_io_xfer_mode_dec(const void **_pp, void *_value) static herr_t H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size) { - const H5FD_mpio_collective_opt_t *coll_opt = (const H5FD_mpio_collective_opt_t *)value; /* Create local alias for values */ + const H5FD_mpio_collective_opt_t *coll_opt = + (const H5FD_mpio_collective_opt_t *)value; /* Create local alias for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1827,7 +1820,7 @@ H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size) HDassert(coll_opt); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode MPI-I/O collective optimization property */ *(*pp)++ = (uint8_t)*coll_opt; @@ -1837,7 +1830,6 @@ H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_mpio_collective_opt_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_mpio_collective_opt_dec * @@ -1856,7 +1848,8 @@ H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_mpio_collective_opt_dec(const void **_pp, void *_value) { - H5FD_mpio_collective_opt_t *coll_opt = (H5FD_mpio_collective_opt_t *)_value; /* MPI-I/O collective optimization mode */ + H5FD_mpio_collective_opt_t *coll_opt = + (H5FD_mpio_collective_opt_t *)_value; /* MPI-I/O collective optimization mode */ const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1867,12 +1860,11 @@ H5P__dxfr_mpio_collective_opt_dec(const void **_pp, void *_value) HDassert(coll_opt); /* Decode MPI-I/O collective optimization mode */ - *coll_opt = (H5FD_mpio_collective_opt_t)*(*pp)++; + *coll_opt = (H5FD_mpio_collective_opt_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_mpio_collective_opt_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_mpio_chunk_opt_hard_enc * @@ -1891,7 +1883,8 @@ H5P__dxfr_mpio_collective_opt_dec(const void **_pp, void *_value) static herr_t H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size) { - const H5FD_mpio_chunk_opt_t *chunk_opt = (const H5FD_mpio_chunk_opt_t *)value; /* Create local alias for values */ + const H5FD_mpio_chunk_opt_t *chunk_opt = + (const H5FD_mpio_chunk_opt_t *)value; /* Create local alias for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1900,7 +1893,7 @@ H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size) HDassert(chunk_opt); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode MPI-I/O chunk optimization property */ *(*pp)++ = (uint8_t)*chunk_opt; @@ -1910,7 +1903,6 @@ H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_mpio_chunk_opt_hard_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_mpio_chunk_opt_hard_enc * @@ -1929,8 +1921,8 @@ H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_mpio_chunk_opt_hard_dec(const void **_pp, void *_value) { - H5FD_mpio_chunk_opt_t *chunk_opt = (H5FD_mpio_chunk_opt_t *)_value; /* MPI-I/O chunk optimization mode */ - const uint8_t **pp = (const uint8_t **)_pp; + H5FD_mpio_chunk_opt_t *chunk_opt = (H5FD_mpio_chunk_opt_t *)_value; /* MPI-I/O chunk optimization mode */ + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1940,13 +1932,13 @@ H5P__dxfr_mpio_chunk_opt_hard_dec(const void **_pp, void *_value) HDassert(chunk_opt); /* Decode MPI-I/O chunk optimization mode */ - *chunk_opt = (H5FD_mpio_chunk_opt_t)*(*pp)++; + *chunk_opt = (H5FD_mpio_chunk_opt_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_mpio_chunk_opt_hard_dec() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5Pget_mpio_actual_chunk_opt_mode * @@ -1962,26 +1954,25 @@ H5P__dxfr_mpio_chunk_opt_hard_dec(const void **_pp, void *_value) herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode) { - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Do", plist_id, actual_chunk_opt_mode); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Return values */ - if(actual_chunk_opt_mode) - if(H5P_get(plist, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, actual_chunk_opt_mode) < 0) + if (actual_chunk_opt_mode) + if (H5P_get(plist, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, actual_chunk_opt_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mpio_actual_chunk_opt_mode() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mpio_actual_io_mode * @@ -1998,26 +1989,25 @@ done: herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode) { - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Di", plist_id, actual_io_mode); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Return values */ - if(actual_io_mode) - if(H5P_get(plist, H5D_MPIO_ACTUAL_IO_MODE_NAME, actual_io_mode) < 0) + if (actual_io_mode) + if (H5P_get(plist, H5D_MPIO_ACTUAL_IO_MODE_NAME, actual_io_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mpio_actual_io_mode() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mpio_no_collective_cause * @@ -2030,25 +2020,26 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause) +H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, + uint32_t *global_no_collective_cause) { - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*Iu*Iu", plist_id, local_no_collective_cause, global_no_collective_cause); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Return values */ - if(local_no_collective_cause) - if(H5P_get(plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, local_no_collective_cause) < 0) + if (local_no_collective_cause) + if (H5P_get(plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, local_no_collective_cause) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get local value") - if(global_no_collective_cause) - if(H5P_get(plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, global_no_collective_cause) < 0) + if (global_no_collective_cause) + if (H5P_get(plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, global_no_collective_cause) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get global value") done: @@ -2056,7 +2047,6 @@ done: } /* end H5Pget_mpio_no_collective_cause() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_edc_enc * @@ -2076,7 +2066,7 @@ static herr_t H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size) { const H5Z_EDC_t *check = (const H5Z_EDC_t *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -2084,7 +2074,7 @@ H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size) HDassert(check); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode EDC property */ *(*pp)++ = (uint8_t)*check; @@ -2094,7 +2084,6 @@ H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_edc_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_edc_dec * @@ -2113,8 +2102,8 @@ H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_edc_dec(const void **_pp, void *_value) { - H5Z_EDC_t *check = (H5Z_EDC_t *)_value; /* EDC property */ - const uint8_t **pp = (const uint8_t **)_pp; + H5Z_EDC_t * check = (H5Z_EDC_t *)_value; /* EDC property */ + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -2124,8 +2113,7 @@ H5P__dxfr_edc_dec(const void **_pp, void *_value) HDassert(check); /* Decode EDC property */ - *check = (H5Z_EDC_t)*(*pp)++; + *check = (H5Z_EDC_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_edc_dec() */ - diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index d4b6b5f..a33239f 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -20,28 +20,25 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Version # of encoded property lists */ -#define H5P_ENCODE_VERS 0 - +#define H5P_ENCODE_VERS 0 /******************/ /* Local Typedefs */ @@ -49,33 +46,27 @@ /* Typedef for iterator when encoding a property list */ typedef struct { - hbool_t encode; /* Whether the property list should be encoded */ - size_t *enc_size_ptr; /* Pointer to size of encoded buffer */ - void **pp; /* Pointer to encoding buffer pointer */ + hbool_t encode; /* Whether the property list should be encoded */ + size_t *enc_size_ptr; /* Pointer to size of encoded buffer */ + void ** pp; /* Pointer to encoding buffer pointer */ } H5P_enc_iter_ud_t; - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5P__encode_size_t * @@ -92,9 +83,9 @@ typedef struct { herr_t H5P__encode_size_t(const void *value, void **_pp, size_t *size) { - uint64_t enc_value = (uint64_t)*(const size_t *)value; /* Property value to encode */ - uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size = H5VM_limit_enc_size(enc_value); /* Size of encoded property */ + uint64_t enc_value = (uint64_t) * (const size_t *)value; /* Property value to encode */ + uint8_t **pp = (uint8_t **)_pp; + unsigned enc_size = H5VM_limit_enc_size(enc_value); /* Size of encoded property */ FUNC_ENTER_PACKAGE_NOERR @@ -103,7 +94,7 @@ H5P__encode_size_t(const void *value, void **_pp, size_t *size) HDassert(enc_size < 256); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)enc_size; @@ -117,7 +108,6 @@ H5P__encode_size_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_size_t() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_hsize_t * @@ -134,9 +124,9 @@ H5P__encode_size_t(const void *value, void **_pp, size_t *size) herr_t H5P__encode_hsize_t(const void *value, void **_pp, size_t *size) { - uint64_t enc_value = (uint64_t)*(const hsize_t *)value; /* Property value to encode */ - unsigned enc_size = H5VM_limit_enc_size(enc_value); /* Size of encoded property */ - uint8_t **pp = (uint8_t **)_pp; + uint64_t enc_value = (uint64_t) * (const hsize_t *)value; /* Property value to encode */ + unsigned enc_size = H5VM_limit_enc_size(enc_value); /* Size of encoded property */ + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_PACKAGE_NOERR @@ -145,7 +135,7 @@ H5P__encode_hsize_t(const void *value, void **_pp, size_t *size) HDassert(enc_size < 256); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { *(*pp)++ = (uint8_t)enc_size; /* Encode the value */ @@ -158,7 +148,6 @@ H5P__encode_hsize_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_hsize_t() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_unsigned * @@ -183,7 +172,7 @@ H5P__encode_unsigned(const void *value, void **_pp, size_t *size) HDassert(value); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)sizeof(unsigned); @@ -197,7 +186,6 @@ H5P__encode_unsigned(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_unsigned() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_uint8_t * @@ -222,7 +210,7 @@ H5P__encode_uint8_t(const void *value, void **_pp, size_t *size) HDassert(value); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the value */ *(*pp)++ = *(const uint8_t *)value; } /* end if */ @@ -233,7 +221,6 @@ H5P__encode_uint8_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_uint8_t() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_hbool_t * @@ -258,9 +245,9 @@ H5P__encode_hbool_t(const void *value, void **_pp, size_t *size) HDassert(value); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode the value */ - *(*pp)++ = (uint8_t)*(const hbool_t *)value; + *(*pp)++ = (uint8_t) * (const hbool_t *)value; /* Set size needed for encoding */ *size += 1; @@ -268,7 +255,6 @@ H5P__encode_hbool_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_hbool_t() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_double * @@ -293,7 +279,7 @@ H5P__encode_double(const void *value, void **_pp, size_t *size) HDassert(value); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)sizeof(double); @@ -307,7 +293,6 @@ H5P__encode_double(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_double() */ - /*-------------------------------------------------------------------------- NAME H5P__encode_cb @@ -331,8 +316,8 @@ H5P__encode_double(const void *value, void **_pp, size_t *size) static int H5P__encode_cb(H5P_genprop_t *prop, void *_udata) { - H5P_enc_iter_ud_t *udata = (H5P_enc_iter_ud_t *)_udata; /* Pointer to user data */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5P_enc_iter_ud_t *udata = (H5P_enc_iter_ud_t *)_udata; /* Pointer to user data */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -341,13 +326,13 @@ H5P__encode_cb(H5P_genprop_t *prop, void *_udata) HDassert(udata); /* Check if this property can be encoded */ - if(prop->encode) { - size_t prop_name_len; /* Length of property's name */ - size_t prop_value_len; /* Encoded size of property's value */ + if (prop->encode) { + size_t prop_name_len; /* Length of property's name */ + size_t prop_value_len; /* Encoded size of property's value */ /* Encode (or not, if the 'encode' flag is off) the property's name */ prop_name_len = HDstrlen(prop->name) + 1; - if(udata->encode) { + if (udata->encode) { HDstrncpy((char *)*(udata->pp), prop->name, prop_name_len); *(uint8_t **)(udata->pp) += prop_name_len; } /* end if */ @@ -355,7 +340,7 @@ H5P__encode_cb(H5P_genprop_t *prop, void *_udata) /* Encode (or not, if *(udata->pp) is NULL) the property value */ prop_value_len = 0; - if((prop->encode)(prop->value, udata->pp, &prop_value_len) < 0) + if ((prop->encode)(prop->value, udata->pp, &prop_value_len) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, H5_ITER_ERROR, "property encoding routine failed") *(udata->enc_size_ptr) += prop_value_len; } /* end if */ @@ -364,7 +349,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__encode_cb() */ - /*------------------------------------------------------------------------- NAME H5P__encode @@ -389,30 +373,29 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, - size_t *nalloc) +H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, size_t *nalloc) { - H5P_enc_iter_ud_t udata; /* User data for property iteration callback */ - uint8_t *p = (uint8_t *)buf; /* Temporary pointer to encoding buffer */ - int idx; /* Index of property to start at */ - size_t encode_size = 0; /* Size of buffer needed to encode properties */ - hbool_t encode = TRUE; /* Whether the property list should be encoded */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_enc_iter_ud_t udata; /* User data for property iteration callback */ + uint8_t * p = (uint8_t *)buf; /* Temporary pointer to encoding buffer */ + int idx; /* Index of property to start at */ + size_t encode_size = 0; /* Size of buffer needed to encode properties */ + hbool_t encode = TRUE; /* Whether the property list should be encoded */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ - if(NULL == nalloc) + if (NULL == nalloc) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad allocation size pointer") /* If the buffer is NULL, then this call to H5P__encode will return how much * space is needed to encode a property. */ - if(NULL == p) + if (NULL == p) encode = FALSE; /* Encode property list description info */ - if(encode) { + if (encode) { /* Version # of property list encoding */ *p++ = (uint8_t)H5P_ENCODE_VERS; @@ -422,17 +405,17 @@ H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, encode_size += 2; /* Initialize user data for iteration callback */ - udata.encode = encode; + udata.encode = encode; udata.enc_size_ptr = &encode_size; - udata.pp = (void **)&p; + udata.pp = (void **)&p; /* Iterate over all properties in property list, encoding them */ idx = 0; - if(H5P__iterate_plist(plist, enc_all_prop, &idx, H5P__encode_cb, &udata) < 0) + if (H5P__iterate_plist(plist, enc_all_prop, &idx, H5P__encode_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADITER, FAIL, "can't iterate over properties") /* Encode a terminator for list of properties */ - if(encode) + if (encode) *p++ = 0; encode_size++; @@ -443,7 +426,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__encode() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_size_t * @@ -460,10 +442,10 @@ done: herr_t H5P__decode_size_t(const void **_pp, void *_value) { - size_t *value = (size_t *)_value; /* Property value to return */ - const uint8_t **pp = (const uint8_t **)_pp; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ + size_t * value = (size_t *)_value; /* Property value to return */ + const uint8_t **pp = (const uint8_t **)_pp; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ FUNC_ENTER_PACKAGE_NOERR @@ -484,7 +466,6 @@ H5P__decode_size_t(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_size_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_hsize_t * @@ -501,10 +482,10 @@ H5P__decode_size_t(const void **_pp, void *_value) herr_t H5P__decode_hsize_t(const void **_pp, void *_value) { - hsize_t *value = (hsize_t *)_value; /* Property value to return */ - const uint8_t **pp = (const uint8_t **)_pp; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ + hsize_t * value = (hsize_t *)_value; /* Property value to return */ + const uint8_t **pp = (const uint8_t **)_pp; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ FUNC_ENTER_PACKAGE_NOERR @@ -525,7 +506,6 @@ H5P__decode_hsize_t(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_hsize_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_unsigned * @@ -542,10 +522,10 @@ H5P__decode_hsize_t(const void **_pp, void *_value) herr_t H5P__decode_unsigned(const void **_pp, void *_value) { - unsigned *value = (unsigned *)_value; /* Property value to return */ - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned * value = (unsigned *)_value; /* Property value to return */ + const uint8_t **pp = (const uint8_t **)_pp; + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -556,7 +536,7 @@ H5P__decode_unsigned(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") H5_DECODE_UNSIGNED(*pp, *value) @@ -565,7 +545,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode_unsigned() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_uint8_t * @@ -582,9 +561,9 @@ done: herr_t H5P__decode_uint8_t(const void **_pp, void *_value) { - uint8_t *value = (uint8_t *)_value; /* Property value to return */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * value = (uint8_t *)_value; /* Property value to return */ + const uint8_t **pp = (const uint8_t **)_pp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -599,7 +578,6 @@ H5P__decode_uint8_t(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode_uint8_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_hbool_t * @@ -616,9 +594,9 @@ H5P__decode_uint8_t(const void **_pp, void *_value) herr_t H5P__decode_hbool_t(const void **_pp, void *_value) { - hbool_t *value = (hbool_t *)_value; /* Property value to return */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t * value = (hbool_t *)_value; /* Property value to return */ + const uint8_t **pp = (const uint8_t **)_pp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -628,12 +606,11 @@ H5P__decode_hbool_t(const void **_pp, void *_value) HDassert(value); /* Decode the value */ - *value = (hbool_t)*(*pp)++; + *value = (hbool_t) * (*pp)++; FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode_hbool_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_double * @@ -650,10 +627,10 @@ H5P__decode_hbool_t(const void **_pp, void *_value) herr_t H5P__decode_double(const void **_pp, void *_value) { - double *value = (double *)_value; /* Property value to return */ - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; /* Return value */ + double * value = (double *)_value; /* Property value to return */ + const uint8_t **pp = (const uint8_t **)_pp; + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -664,7 +641,7 @@ H5P__decode_double(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(double)) + if (enc_size != sizeof(double)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded") H5_DECODE_DOUBLE(*pp, *value) @@ -673,7 +650,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode_double() */ - /*------------------------------------------------------------------------- NAME H5P__decode @@ -700,46 +676,47 @@ done: hid_t H5P__decode(const void *buf) { - H5P_genplist_t *plist; /* Property list to decode into */ - void *value_buf = NULL; /* Pointer to buffer to use when decoding values */ - const uint8_t *p = (const uint8_t *)buf; /* Current pointer into buffer */ - H5P_plist_type_t type; /* Type of encoded property list */ - hid_t plist_id = -1; /* ID of new property list */ - size_t value_buf_size = 0; /* Size of current value buffer */ - uint8_t vers; /* Version of encoded property list */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t * plist; /* Property list to decode into */ + void * value_buf = NULL; /* Pointer to buffer to use when decoding values */ + const uint8_t * p = (const uint8_t *)buf; /* Current pointer into buffer */ + H5P_plist_type_t type; /* Type of encoded property list */ + hid_t plist_id = -1; /* ID of new property list */ + size_t value_buf_size = 0; /* Size of current value buffer */ + uint8_t vers; /* Version of encoded property list */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ - if(NULL == p) + if (NULL == p) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "decode buffer is NULL") /* Get the version number of the encoded property list */ vers = (uint8_t)*p++; - if((uint8_t)H5P_ENCODE_VERS != vers) - HGOTO_ERROR(H5E_PLIST, H5E_VERSION, FAIL, "bad version # of encoded information, expected %u, got %u", (unsigned)H5P_ENCODE_VERS, (unsigned)vers) + if ((uint8_t)H5P_ENCODE_VERS != vers) + HGOTO_ERROR(H5E_PLIST, H5E_VERSION, FAIL, "bad version # of encoded information, expected %u, got %u", + (unsigned)H5P_ENCODE_VERS, (unsigned)vers) /* Get the type of the property list */ type = (H5P_plist_type_t)*p++; - if(type <= H5P_TYPE_USER || type >= H5P_TYPE_MAX_TYPE) + if (type <= H5P_TYPE_USER || type >= H5P_TYPE_MAX_TYPE) HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "bad type of encoded information: %u", (unsigned)type) /* Create new property list of the specified type */ - if((plist_id = H5P__new_plist_of_type(type)) < 0) + if ((plist_id = H5P__new_plist_of_type(type)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_VERSION, FAIL, "can't create property list of type: %u\n", (unsigned)type); /* Get the property list object */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property class") /* Loop over encoded properties, deserializing their values */ - while(p) { - H5P_genprop_t *prop; /* Pointer to property with same name */ - const char *name; /* Pointer to property list name */ + while (p) { + H5P_genprop_t *prop; /* Pointer to property with same name */ + const char * name; /* Pointer to property list name */ /* Check for end of serialized list of properties */ - if(0 == *p) + if (0 == *p) break; /* Get property list name */ @@ -747,26 +724,27 @@ H5P__decode(const void *buf) p += HDstrlen(name) + 1; /* Find property with name */ - if(NULL == (prop = H5P__find_prop_plist(plist, name))) + if (NULL == (prop = H5P__find_prop_plist(plist, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist: '%s'", name) /* Check if we should increase the size of the value buffer */ - if(prop->size > value_buf_size) { - if(NULL == (value_buf = H5MM_realloc(value_buf, prop->size))) + if (prop->size > value_buf_size) { + if (NULL == (value_buf = H5MM_realloc(value_buf, prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "decoding buffer allocation failed") value_buf_size = prop->size; } /* end if */ /* Decode serialized value */ - if(prop->decode) { - if((prop->decode)((const void **)&p, value_buf) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "property decoding routine failed, property: '%s'", name) + if (prop->decode) { + if ((prop->decode)((const void **)&p, value_buf) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, + "property decoding routine failed, property: '%s'", name) } /* end if */ else HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "no decode callback for property: '%s'", name) /* Set the value for the property */ - if(H5P_poke(plist, name, value_buf) < 0) + if (H5P_poke(plist, name, value_buf) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value for property: '%s'", name) } /* end while */ @@ -775,15 +753,15 @@ H5P__decode(const void *buf) done: /* Release resources */ - if(value_buf) + if (value_buf) value_buf = H5MM_xfree(value_buf); /* Cleanup on error */ - if(ret_value < 0) { - if(plist_id > 0 && H5I_dec_ref(plist_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "unable to close partially initialized property list") + if (ret_value < 0) { + if (plist_id > 0 && H5I_dec_ref(plist_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, + "unable to close partially initialized property list") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode() */ - diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 878ab44..9a63e7a 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -24,232 +24,236 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory Management */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VMprivate.h" /* Vector Functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory Management */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VMprivate.h" /* Vector Functions */ /* Includes needed to set default file driver */ -#include "H5FDsec2.h" /* POSIX unbuffered I/O */ -#include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDsec2.h" /* POSIX unbuffered I/O */ +#include "H5FDstdio.h" /* Standard C buffered I/O */ #ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Win32 I/O */ +#include "H5FDwindows.h" /* Win32 I/O */ #endif -#include "H5FDvfd_swmr.h" /* Posix unbuffered I/O file driver */ +#include "H5FDvfd_swmr.h" /* Posix unbuffered I/O file driver */ /* Includes needed to set default VOL connector */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ /* ========= File Access properties ============ */ /* Definitions for the initial metadata cache resize configuration */ -#define H5F_ACS_META_CACHE_INIT_CONFIG_SIZE sizeof(H5AC_cache_config_t) -#define H5F_ACS_META_CACHE_INIT_CONFIG_DEF H5AC__DEFAULT_CACHE_CONFIG -#define H5F_ACS_META_CACHE_INIT_CONFIG_ENC H5P__facc_cache_config_enc -#define H5F_ACS_META_CACHE_INIT_CONFIG_DEC H5P__facc_cache_config_dec -#define H5F_ACS_META_CACHE_INIT_CONFIG_CMP H5P__facc_cache_config_cmp +#define H5F_ACS_META_CACHE_INIT_CONFIG_SIZE sizeof(H5AC_cache_config_t) +#define H5F_ACS_META_CACHE_INIT_CONFIG_DEF H5AC__DEFAULT_CACHE_CONFIG +#define H5F_ACS_META_CACHE_INIT_CONFIG_ENC H5P__facc_cache_config_enc +#define H5F_ACS_META_CACHE_INIT_CONFIG_DEC H5P__facc_cache_config_dec +#define H5F_ACS_META_CACHE_INIT_CONFIG_CMP H5P__facc_cache_config_cmp /* Definitions for size of raw data chunk cache(slots) */ -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF 521 -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_size_t -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_size_t +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF 521 +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_size_t +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_size_t /* Definition for size of raw data chunk cache(bytes) */ -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF (1024*1024) -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_size_t +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF (1024 * 1024) +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_size_t +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_size_t /* Definition for preemption read chunks first */ -#define H5F_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) -#define H5F_ACS_PREEMPT_READ_CHUNKS_DEF 0.75f -#define H5F_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double -#define H5F_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double +#define H5F_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) +#define H5F_ACS_PREEMPT_READ_CHUNKS_DEF 0.75f +#define H5F_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double +#define H5F_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double /* Definition for threshold for alignment */ -#define H5F_ACS_ALIGN_THRHD_SIZE sizeof(hsize_t) -#define H5F_ACS_ALIGN_THRHD_DEF H5F_ALIGN_THRHD_DEF -#define H5F_ACS_ALIGN_THRHD_ENC H5P__encode_hsize_t -#define H5F_ACS_ALIGN_THRHD_DEC H5P__decode_hsize_t +#define H5F_ACS_ALIGN_THRHD_SIZE sizeof(hsize_t) +#define H5F_ACS_ALIGN_THRHD_DEF H5F_ALIGN_THRHD_DEF +#define H5F_ACS_ALIGN_THRHD_ENC H5P__encode_hsize_t +#define H5F_ACS_ALIGN_THRHD_DEC H5P__decode_hsize_t /* Definition for alignment */ -#define H5F_ACS_ALIGN_SIZE sizeof(hsize_t) -#define H5F_ACS_ALIGN_DEF H5F_ALIGN_DEF -#define H5F_ACS_ALIGN_ENC H5P__encode_hsize_t -#define H5F_ACS_ALIGN_DEC H5P__decode_hsize_t +#define H5F_ACS_ALIGN_SIZE sizeof(hsize_t) +#define H5F_ACS_ALIGN_DEF H5F_ALIGN_DEF +#define H5F_ACS_ALIGN_ENC H5P__encode_hsize_t +#define H5F_ACS_ALIGN_DEC H5P__decode_hsize_t /* Definition for minimum metadata allocation block size (when aggregating metadata allocations. */ -#define H5F_ACS_META_BLOCK_SIZE_SIZE sizeof(hsize_t) -#define H5F_ACS_META_BLOCK_SIZE_DEF H5F_META_BLOCK_SIZE_DEF -#define H5F_ACS_META_BLOCK_SIZE_ENC H5P__encode_hsize_t -#define H5F_ACS_META_BLOCK_SIZE_DEC H5P__decode_hsize_t +#define H5F_ACS_META_BLOCK_SIZE_SIZE sizeof(hsize_t) +#define H5F_ACS_META_BLOCK_SIZE_DEF H5F_META_BLOCK_SIZE_DEF +#define H5F_ACS_META_BLOCK_SIZE_ENC H5P__encode_hsize_t +#define H5F_ACS_META_BLOCK_SIZE_DEC H5P__decode_hsize_t /* Definition for maximum sieve buffer size (when data sieving is allowed by file driver */ -#define H5F_ACS_SIEVE_BUF_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_SIEVE_BUF_SIZE_DEF (64*1024) -#define H5F_ACS_SIEVE_BUF_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_SIEVE_BUF_SIZE_DEC H5P__decode_size_t +#define H5F_ACS_SIEVE_BUF_SIZE_SIZE sizeof(size_t) +#define H5F_ACS_SIEVE_BUF_SIZE_DEF (64 * 1024) +#define H5F_ACS_SIEVE_BUF_SIZE_ENC H5P__encode_size_t +#define H5F_ACS_SIEVE_BUF_SIZE_DEC H5P__decode_size_t /* Definition for minimum "small data" allocation block size (when aggregating "small" raw data allocations. */ -#define H5F_ACS_SDATA_BLOCK_SIZE_SIZE sizeof(hsize_t) -#define H5F_ACS_SDATA_BLOCK_SIZE_DEF H5F_SDATA_BLOCK_SIZE_DEF -#define H5F_ACS_SDATA_BLOCK_SIZE_ENC H5P__encode_hsize_t -#define H5F_ACS_SDATA_BLOCK_SIZE_DEC H5P__decode_hsize_t +#define H5F_ACS_SDATA_BLOCK_SIZE_SIZE sizeof(hsize_t) +#define H5F_ACS_SDATA_BLOCK_SIZE_DEF H5F_SDATA_BLOCK_SIZE_DEF +#define H5F_ACS_SDATA_BLOCK_SIZE_ENC H5P__encode_hsize_t +#define H5F_ACS_SDATA_BLOCK_SIZE_DEC H5P__decode_hsize_t /* Definition for garbage-collect references */ -#define H5F_ACS_GARBG_COLCT_REF_SIZE sizeof(unsigned) -#define H5F_ACS_GARBG_COLCT_REF_DEF 0 -#define H5F_ACS_GARBG_COLCT_REF_ENC H5P__encode_unsigned -#define H5F_ACS_GARBG_COLCT_REF_DEC H5P__decode_unsigned +#define H5F_ACS_GARBG_COLCT_REF_SIZE sizeof(unsigned) +#define H5F_ACS_GARBG_COLCT_REF_DEF 0 +#define H5F_ACS_GARBG_COLCT_REF_ENC H5P__encode_unsigned +#define H5F_ACS_GARBG_COLCT_REF_DEC H5P__decode_unsigned /* Definition for file driver ID & info */ -#define H5F_ACS_FILE_DRV_SIZE sizeof(H5FD_driver_prop_t) -#define H5F_ACS_FILE_DRV_DEF {H5_DEFAULT_VFD, NULL} -#define H5F_ACS_FILE_DRV_CRT H5P__facc_file_driver_create -#define H5F_ACS_FILE_DRV_SET H5P__facc_file_driver_set -#define H5F_ACS_FILE_DRV_GET H5P__facc_file_driver_get -#define H5F_ACS_FILE_DRV_DEL H5P__facc_file_driver_del -#define H5F_ACS_FILE_DRV_COPY H5P__facc_file_driver_copy -#define H5F_ACS_FILE_DRV_CMP H5P__facc_file_driver_cmp -#define H5F_ACS_FILE_DRV_CLOSE H5P__facc_file_driver_close +#define H5F_ACS_FILE_DRV_SIZE sizeof(H5FD_driver_prop_t) +#define H5F_ACS_FILE_DRV_DEF \ + { \ + H5_DEFAULT_VFD, NULL \ + } +#define H5F_ACS_FILE_DRV_CRT H5P__facc_file_driver_create +#define H5F_ACS_FILE_DRV_SET H5P__facc_file_driver_set +#define H5F_ACS_FILE_DRV_GET H5P__facc_file_driver_get +#define H5F_ACS_FILE_DRV_DEL H5P__facc_file_driver_del +#define H5F_ACS_FILE_DRV_COPY H5P__facc_file_driver_copy +#define H5F_ACS_FILE_DRV_CMP H5P__facc_file_driver_cmp +#define H5F_ACS_FILE_DRV_CLOSE H5P__facc_file_driver_close /* Definition for file close degree */ -#define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t) -#define H5F_CLOSE_DEGREE_DEF H5F_CLOSE_DEFAULT -#define H5F_CLOSE_DEGREE_ENC H5P__facc_fclose_degree_enc -#define H5F_CLOSE_DEGREE_DEC H5P__facc_fclose_degree_dec +#define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t) +#define H5F_CLOSE_DEGREE_DEF H5F_CLOSE_DEFAULT +#define H5F_CLOSE_DEGREE_ENC H5P__facc_fclose_degree_enc +#define H5F_CLOSE_DEGREE_DEC H5P__facc_fclose_degree_dec /* Definition for offset position in file for family file driver */ -#define H5F_ACS_FAMILY_OFFSET_SIZE sizeof(hsize_t) -#define H5F_ACS_FAMILY_OFFSET_DEF 0 -#define H5F_ACS_FAMILY_OFFSET_ENC H5P__encode_hsize_t -#define H5F_ACS_FAMILY_OFFSET_DEC H5P__decode_hsize_t +#define H5F_ACS_FAMILY_OFFSET_SIZE sizeof(hsize_t) +#define H5F_ACS_FAMILY_OFFSET_DEF 0 +#define H5F_ACS_FAMILY_OFFSET_ENC H5P__encode_hsize_t +#define H5F_ACS_FAMILY_OFFSET_DEC H5P__decode_hsize_t /* Definition for new member size of family driver. It's private * property only used by h5repart */ -#define H5F_ACS_FAMILY_NEWSIZE_SIZE sizeof(hsize_t) -#define H5F_ACS_FAMILY_NEWSIZE_DEF 0 +#define H5F_ACS_FAMILY_NEWSIZE_SIZE sizeof(hsize_t) +#define H5F_ACS_FAMILY_NEWSIZE_DEF 0 /* Definition for whether to convert family to a single-file driver. * It's a private property only used by h5repart. */ -#define H5F_ACS_FAMILY_TO_SINGLE_SIZE sizeof(hbool_t) -#define H5F_ACS_FAMILY_TO_SINGLE_DEF FALSE +#define H5F_ACS_FAMILY_TO_SINGLE_SIZE sizeof(hbool_t) +#define H5F_ACS_FAMILY_TO_SINGLE_DEF FALSE /* Definition for data type in multi file driver */ -#define H5F_ACS_MULTI_TYPE_SIZE sizeof(H5FD_mem_t) -#define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT -#define H5F_ACS_MULTI_TYPE_ENC H5P__facc_multi_type_enc -#define H5F_ACS_MULTI_TYPE_DEC H5P__facc_multi_type_dec +#define H5F_ACS_MULTI_TYPE_SIZE sizeof(H5FD_mem_t) +#define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT +#define H5F_ACS_MULTI_TYPE_ENC H5P__facc_multi_type_enc +#define H5F_ACS_MULTI_TYPE_DEC H5P__facc_multi_type_dec /* Definition for "low" bound of library format versions */ -#define H5F_ACS_LIBVER_LOW_BOUND_SIZE sizeof(H5F_libver_t) -#define H5F_ACS_LIBVER_LOW_BOUND_DEF H5F_LIBVER_EARLIEST -#define H5F_ACS_LIBVER_LOW_BOUND_ENC H5P__facc_libver_type_enc -#define H5F_ACS_LIBVER_LOW_BOUND_DEC H5P__facc_libver_type_dec +#define H5F_ACS_LIBVER_LOW_BOUND_SIZE sizeof(H5F_libver_t) +#define H5F_ACS_LIBVER_LOW_BOUND_DEF H5F_LIBVER_EARLIEST +#define H5F_ACS_LIBVER_LOW_BOUND_ENC H5P__facc_libver_type_enc +#define H5F_ACS_LIBVER_LOW_BOUND_DEC H5P__facc_libver_type_dec /* Definition for "high" bound of library format versions */ -#define H5F_ACS_LIBVER_HIGH_BOUND_SIZE sizeof(H5F_libver_t) -#define H5F_ACS_LIBVER_HIGH_BOUND_DEF H5F_LIBVER_LATEST -#define H5F_ACS_LIBVER_HIGH_BOUND_ENC H5P__facc_libver_type_enc -#define H5F_ACS_LIBVER_HIGH_BOUND_DEC H5P__facc_libver_type_dec +#define H5F_ACS_LIBVER_HIGH_BOUND_SIZE sizeof(H5F_libver_t) +#define H5F_ACS_LIBVER_HIGH_BOUND_DEF H5F_LIBVER_LATEST +#define H5F_ACS_LIBVER_HIGH_BOUND_ENC H5P__facc_libver_type_enc +#define H5F_ACS_LIBVER_HIGH_BOUND_DEC H5P__facc_libver_type_dec /* Definition for whether to query the file descriptor from the core VFD * instead of the memory address. (Private to library) */ -#define H5F_ACS_WANT_POSIX_FD_SIZE sizeof(hbool_t) -#define H5F_ACS_WANT_POSIX_FD_DEF FALSE +#define H5F_ACS_WANT_POSIX_FD_SIZE sizeof(hbool_t) +#define H5F_ACS_WANT_POSIX_FD_DEF FALSE /* Definition for external file cache size */ -#define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned) -#define H5F_ACS_EFC_SIZE_DEF 0 -#define H5F_ACS_EFC_SIZE_ENC H5P__encode_unsigned -#define H5F_ACS_EFC_SIZE_DEC H5P__decode_unsigned +#define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned) +#define H5F_ACS_EFC_SIZE_DEF 0 +#define H5F_ACS_EFC_SIZE_ENC H5P__encode_unsigned +#define H5F_ACS_EFC_SIZE_DEC H5P__decode_unsigned /* Definition of pointer to initial file image info */ -#define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t) -#define H5F_ACS_FILE_IMAGE_INFO_DEF H5FD_DEFAULT_FILE_IMAGE_INFO -#define H5F_ACS_FILE_IMAGE_INFO_SET H5P__facc_file_image_info_set -#define H5F_ACS_FILE_IMAGE_INFO_GET H5P__facc_file_image_info_get -#define H5F_ACS_FILE_IMAGE_INFO_DEL H5P__facc_file_image_info_del -#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P__facc_file_image_info_copy -#define H5F_ACS_FILE_IMAGE_INFO_CMP H5P__facc_file_image_info_cmp -#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close +#define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t) +#define H5F_ACS_FILE_IMAGE_INFO_DEF H5FD_DEFAULT_FILE_IMAGE_INFO +#define H5F_ACS_FILE_IMAGE_INFO_SET H5P__facc_file_image_info_set +#define H5F_ACS_FILE_IMAGE_INFO_GET H5P__facc_file_image_info_get +#define H5F_ACS_FILE_IMAGE_INFO_DEL H5P__facc_file_image_info_del +#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P__facc_file_image_info_copy +#define H5F_ACS_FILE_IMAGE_INFO_CMP H5P__facc_file_image_info_cmp +#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close /* Definition for # of metadata read attempts */ -#define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned) -#define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0 -#define H5F_ACS_METADATA_READ_ATTEMPTS_ENC H5P__encode_unsigned -#define H5F_ACS_METADATA_READ_ATTEMPTS_DEC H5P__decode_unsigned +#define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned) +#define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0 +#define H5F_ACS_METADATA_READ_ATTEMPTS_ENC H5P__encode_unsigned +#define H5F_ACS_METADATA_READ_ATTEMPTS_DEC H5P__decode_unsigned /* Definition for object flush callback */ -#define H5F_ACS_OBJECT_FLUSH_CB_SIZE sizeof(H5F_object_flush_t) -#define H5F_ACS_OBJECT_FLUSH_CB_DEF {NULL, NULL} +#define H5F_ACS_OBJECT_FLUSH_CB_SIZE sizeof(H5F_object_flush_t) +#define H5F_ACS_OBJECT_FLUSH_CB_DEF \ + { \ + NULL, NULL \ + } /* Definition for status_flags in the superblock */ -#define H5F_ACS_CLEAR_STATUS_FLAGS_SIZE sizeof(hbool_t) -#define H5F_ACS_CLEAR_STATUS_FLAGS_DEF FALSE +#define H5F_ACS_CLEAR_STATUS_FLAGS_SIZE sizeof(hbool_t) +#define H5F_ACS_CLEAR_STATUS_FLAGS_DEF FALSE /* Definition for dropping free-space to the floor when reading in the superblock */ -#define H5F_ACS_NULL_FSM_ADDR_SIZE sizeof(hbool_t) -#define H5F_ACS_NULL_FSM_ADDR_DEF FALSE +#define H5F_ACS_NULL_FSM_ADDR_SIZE sizeof(hbool_t) +#define H5F_ACS_NULL_FSM_ADDR_DEF FALSE /* Definition for skipping EOF check when reading in the superblock */ -#define H5F_ACS_SKIP_EOF_CHECK_SIZE sizeof(hbool_t) -#define H5F_ACS_SKIP_EOF_CHECK_DEF FALSE +#define H5F_ACS_SKIP_EOF_CHECK_SIZE sizeof(hbool_t) +#define H5F_ACS_SKIP_EOF_CHECK_DEF FALSE /* Definition for 'use metadata cache logging' flag */ -#define H5F_ACS_USE_MDC_LOGGING_SIZE sizeof(hbool_t) -#define H5F_ACS_USE_MDC_LOGGING_DEF FALSE -#define H5F_ACS_USE_MDC_LOGGING_ENC H5P__encode_hbool_t -#define H5F_ACS_USE_MDC_LOGGING_DEC H5P__decode_hbool_t +#define H5F_ACS_USE_MDC_LOGGING_SIZE sizeof(hbool_t) +#define H5F_ACS_USE_MDC_LOGGING_DEF FALSE +#define H5F_ACS_USE_MDC_LOGGING_ENC H5P__encode_hbool_t +#define H5F_ACS_USE_MDC_LOGGING_DEC H5P__decode_hbool_t /* Definition for 'mdc log location' flag */ -#define H5F_ACS_MDC_LOG_LOCATION_SIZE sizeof(char *) -#define H5F_ACS_MDC_LOG_LOCATION_DEF NULL /* default is no log location */ -#define H5F_ACS_MDC_LOG_LOCATION_ENC H5P_facc_mdc_log_location_enc -#define H5F_ACS_MDC_LOG_LOCATION_DEC H5P_facc_mdc_log_location_dec -#define H5F_ACS_MDC_LOG_LOCATION_DEL H5P_facc_mdc_log_location_del -#define H5F_ACS_MDC_LOG_LOCATION_COPY H5P_facc_mdc_log_location_copy -#define H5F_ACS_MDC_LOG_LOCATION_CMP H5P_facc_mdc_log_location_cmp -#define H5F_ACS_MDC_LOG_LOCATION_CLOSE H5P_facc_mdc_log_location_close +#define H5F_ACS_MDC_LOG_LOCATION_SIZE sizeof(char *) +#define H5F_ACS_MDC_LOG_LOCATION_DEF NULL /* default is no log location */ +#define H5F_ACS_MDC_LOG_LOCATION_ENC H5P_facc_mdc_log_location_enc +#define H5F_ACS_MDC_LOG_LOCATION_DEC H5P_facc_mdc_log_location_dec +#define H5F_ACS_MDC_LOG_LOCATION_DEL H5P_facc_mdc_log_location_del +#define H5F_ACS_MDC_LOG_LOCATION_COPY H5P_facc_mdc_log_location_copy +#define H5F_ACS_MDC_LOG_LOCATION_CMP H5P_facc_mdc_log_location_cmp +#define H5F_ACS_MDC_LOG_LOCATION_CLOSE H5P_facc_mdc_log_location_close /* Definition for 'start metadata cache logging on access' flag */ -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE sizeof(hbool_t) -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF FALSE -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC H5P__encode_hbool_t -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC H5P__decode_hbool_t +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE sizeof(hbool_t) +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF FALSE +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC H5P__encode_hbool_t +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC H5P__decode_hbool_t /* Definition for evict on close property */ -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE sizeof(hbool_t) -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF FALSE -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC H5P__encode_hbool_t -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC H5P__decode_hbool_t +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE sizeof(hbool_t) +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF FALSE +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC H5P__encode_hbool_t +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC H5P__decode_hbool_t #ifdef H5_HAVE_PARALLEL /* Definition of collective metadata read mode flag */ -#define H5F_ACS_COLL_MD_READ_FLAG_SIZE sizeof(H5P_coll_md_read_flag_t) -#define H5F_ACS_COLL_MD_READ_FLAG_DEF H5P_USER_FALSE -#define H5F_ACS_COLL_MD_READ_FLAG_ENC H5P__encode_coll_md_read_flag_t -#define H5F_ACS_COLL_MD_READ_FLAG_DEC H5P__decode_coll_md_read_flag_t +#define H5F_ACS_COLL_MD_READ_FLAG_SIZE sizeof(H5P_coll_md_read_flag_t) +#define H5F_ACS_COLL_MD_READ_FLAG_DEF H5P_USER_FALSE +#define H5F_ACS_COLL_MD_READ_FLAG_ENC H5P__encode_coll_md_read_flag_t +#define H5F_ACS_COLL_MD_READ_FLAG_DEC H5P__decode_coll_md_read_flag_t /* Definition of collective metadata write mode flag */ -#define H5F_ACS_COLL_MD_WRITE_FLAG_SIZE sizeof(hbool_t) -#define H5F_ACS_COLL_MD_WRITE_FLAG_DEF FALSE -#define H5F_ACS_COLL_MD_WRITE_FLAG_ENC H5P__encode_hbool_t -#define H5F_ACS_COLL_MD_WRITE_FLAG_DEC H5P__decode_hbool_t +#define H5F_ACS_COLL_MD_WRITE_FLAG_SIZE sizeof(hbool_t) +#define H5F_ACS_COLL_MD_WRITE_FLAG_DEF FALSE +#define H5F_ACS_COLL_MD_WRITE_FLAG_ENC H5P__encode_hbool_t +#define H5F_ACS_COLL_MD_WRITE_FLAG_DEC H5P__decode_hbool_t /* Definition for the file's MPI communicator */ -#define H5F_ACS_MPI_PARAMS_COMM_SIZE sizeof(MPI_Comm) -#define H5F_ACS_MPI_PARAMS_COMM_DEF MPI_COMM_NULL -#define H5F_ACS_MPI_PARAMS_COMM_SET H5P__facc_mpi_comm_set -#define H5F_ACS_MPI_PARAMS_COMM_GET H5P__facc_mpi_comm_get -#define H5F_ACS_MPI_PARAMS_COMM_DEL H5P__facc_mpi_comm_del -#define H5F_ACS_MPI_PARAMS_COMM_COPY H5P__facc_mpi_comm_copy -#define H5F_ACS_MPI_PARAMS_COMM_CMP H5P__facc_mpi_comm_cmp -#define H5F_ACS_MPI_PARAMS_COMM_CLOSE H5P__facc_mpi_comm_close +#define H5F_ACS_MPI_PARAMS_COMM_SIZE sizeof(MPI_Comm) +#define H5F_ACS_MPI_PARAMS_COMM_DEF MPI_COMM_NULL +#define H5F_ACS_MPI_PARAMS_COMM_SET H5P__facc_mpi_comm_set +#define H5F_ACS_MPI_PARAMS_COMM_GET H5P__facc_mpi_comm_get +#define H5F_ACS_MPI_PARAMS_COMM_DEL H5P__facc_mpi_comm_del +#define H5F_ACS_MPI_PARAMS_COMM_COPY H5P__facc_mpi_comm_copy +#define H5F_ACS_MPI_PARAMS_COMM_CMP H5P__facc_mpi_comm_cmp +#define H5F_ACS_MPI_PARAMS_COMM_CLOSE H5P__facc_mpi_comm_close /* Definition for the file's MPI info */ -#define H5F_ACS_MPI_PARAMS_INFO_SIZE sizeof(MPI_Info) -#define H5F_ACS_MPI_PARAMS_INFO_DEF MPI_INFO_NULL -#define H5F_ACS_MPI_PARAMS_INFO_SET H5P__facc_mpi_info_set -#define H5F_ACS_MPI_PARAMS_INFO_GET H5P__facc_mpi_info_get -#define H5F_ACS_MPI_PARAMS_INFO_DEL H5P__facc_mpi_info_del -#define H5F_ACS_MPI_PARAMS_INFO_COPY H5P__facc_mpi_info_copy -#define H5F_ACS_MPI_PARAMS_INFO_CMP H5P__facc_mpi_info_cmp -#define H5F_ACS_MPI_PARAMS_INFO_CLOSE H5P__facc_mpi_info_close +#define H5F_ACS_MPI_PARAMS_INFO_SIZE sizeof(MPI_Info) +#define H5F_ACS_MPI_PARAMS_INFO_DEF MPI_INFO_NULL +#define H5F_ACS_MPI_PARAMS_INFO_SET H5P__facc_mpi_info_set +#define H5F_ACS_MPI_PARAMS_INFO_GET H5P__facc_mpi_info_get +#define H5F_ACS_MPI_PARAMS_INFO_DEL H5P__facc_mpi_info_del +#define H5F_ACS_MPI_PARAMS_INFO_COPY H5P__facc_mpi_info_copy +#define H5F_ACS_MPI_PARAMS_INFO_CMP H5P__facc_mpi_info_cmp +#define H5F_ACS_MPI_PARAMS_INFO_CLOSE H5P__facc_mpi_info_close #endif /* H5_HAVE_PARALLEL */ /* Definitions for the initial metadata cache image configuration */ #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE sizeof(H5AC_cache_image_config_t) @@ -258,47 +262,48 @@ #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC H5P__facc_cache_image_config_dec #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP H5P__facc_cache_image_config_cmp /* Definition for total size of page buffer(bytes) */ -#define H5F_ACS_PAGE_BUFFER_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_PAGE_BUFFER_SIZE_DEF 0 -#define H5F_ACS_PAGE_BUFFER_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_PAGE_BUFFER_SIZE_DEC H5P__decode_size_t +#define H5F_ACS_PAGE_BUFFER_SIZE_SIZE sizeof(size_t) +#define H5F_ACS_PAGE_BUFFER_SIZE_DEF 0 +#define H5F_ACS_PAGE_BUFFER_SIZE_ENC H5P__encode_size_t +#define H5F_ACS_PAGE_BUFFER_SIZE_DEC H5P__decode_size_t /* Definition for minimum metadata size of page buffer(bytes) */ -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE sizeof(unsigned) -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF 0 -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC H5P__encode_unsigned -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC H5P__decode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE sizeof(unsigned) +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF 0 +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC H5P__encode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC H5P__decode_unsigned /* Definition for minimum raw data size of page buffer(bytes) */ -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE sizeof(unsigned) -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF 0 -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE sizeof(unsigned) +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF 0 +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned /* Definition for file VOL connector properties (ID, etc.) */ -#define H5F_ACS_VOL_CONN_SIZE sizeof(H5VL_connector_prop_t) -#define H5F_ACS_VOL_CONN_DEF {H5_DEFAULT_VOL, NULL} -#define H5F_ACS_VOL_CONN_CRT H5P__facc_vol_create -#define H5F_ACS_VOL_CONN_SET H5P__facc_vol_set -#define H5F_ACS_VOL_CONN_GET H5P__facc_vol_get -#define H5F_ACS_VOL_CONN_DEL H5P__facc_vol_del -#define H5F_ACS_VOL_CONN_COPY H5P__facc_vol_copy -#define H5F_ACS_VOL_CONN_CMP H5P__facc_vol_cmp -#define H5F_ACS_VOL_CONN_CLOSE H5P__facc_vol_close +#define H5F_ACS_VOL_CONN_SIZE sizeof(H5VL_connector_prop_t) +#define H5F_ACS_VOL_CONN_DEF \ + { \ + H5_DEFAULT_VOL, NULL \ + } +#define H5F_ACS_VOL_CONN_CRT H5P__facc_vol_create +#define H5F_ACS_VOL_CONN_SET H5P__facc_vol_set +#define H5F_ACS_VOL_CONN_GET H5P__facc_vol_get +#define H5F_ACS_VOL_CONN_DEL H5P__facc_vol_del +#define H5F_ACS_VOL_CONN_COPY H5P__facc_vol_copy +#define H5F_ACS_VOL_CONN_CMP H5P__facc_vol_cmp +#define H5F_ACS_VOL_CONN_CLOSE H5P__facc_vol_close /* Definitions for the VFD SWMR configuration */ -#define H5F_ACS_VFD_SWMR_CONFIG_SIZE sizeof(H5F_vfd_swmr_config_t) -#define H5F_ACS_VFD_SWMR_CONFIG_DEF H5F__DEFAULT_VFD_SWMR_CONFIG -#define H5F_ACS_VFD_SWMR_CONFIG_ENC H5P__facc_vfd_swmr_config_enc -#define H5F_ACS_VFD_SWMR_CONFIG_DEC H5P__facc_vfd_swmr_config_dec +#define H5F_ACS_VFD_SWMR_CONFIG_SIZE sizeof(H5F_vfd_swmr_config_t) +#define H5F_ACS_VFD_SWMR_CONFIG_DEF H5F__DEFAULT_VFD_SWMR_CONFIG +#define H5F_ACS_VFD_SWMR_CONFIG_ENC H5P__facc_vfd_swmr_config_enc +#define H5F_ACS_VFD_SWMR_CONFIG_DEC H5P__facc_vfd_swmr_config_dec /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -312,7 +317,7 @@ static herr_t H5P__facc_file_driver_set(hid_t prop_id, const char *name, size_t static herr_t H5P__facc_file_driver_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_file_driver_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_file_driver_copy(const char *name, size_t size, void *value); -static int H5P__facc_file_driver_cmp(const void *value1, const void *value2, size_t size); +static int H5P__facc_file_driver_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__facc_file_driver_close(const char *name, size_t size, void *value); /* File image info property callbacks */ @@ -322,13 +327,13 @@ static herr_t H5P__facc_file_image_info_set(hid_t prop_id, const char *name, siz static herr_t H5P__facc_file_image_info_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_file_image_info_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_file_image_info_copy(const char *name, size_t size, void *value); -static int H5P__facc_file_image_info_cmp(const void *value1, const void *value2, size_t size); +static int H5P__facc_file_image_info_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__facc_file_image_info_close(const char *name, size_t size, void *value); /* encode & decode callbacks */ static herr_t H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_cache_config_dec(const void **_pp, void *value); -static int H5P__facc_cache_config_cmp(const void *value1, const void *value2, size_t size); +static int H5P__facc_cache_config_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_fclose_degree_dec(const void **pp, void *value); static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size); @@ -347,7 +352,8 @@ static int H5P_facc_mdc_log_location_cmp(const void *value1, const void *valu static herr_t H5P_facc_mdc_log_location_close(const char *name, size_t size, void *value); /* Metadata cache image property callbacks */ -static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size); +static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, + size_t H5_ATTR_UNUSED size); static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value); @@ -357,7 +363,7 @@ static herr_t H5P__facc_vol_set(hid_t prop_id, const char *name, size_t size, vo static herr_t H5P__facc_vol_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_vol_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_vol_copy(const char *name, size_t size, void *value); -static int H5P__facc_vol_cmp(const void *value1, const void *value2, size_t size); +static int H5P__facc_vol_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__facc_vol_close(const char *name, size_t size, void *value); #ifdef H5_HAVE_PARALLEL @@ -378,7 +384,6 @@ static int H5P__facc_mpi_info_cmp(const void *value1, const void *value2, siz static herr_t H5P__facc_mpi_info_close(const char *name, size_t size, void *value); #endif /* H5_HAVE_PARALLEL */ - /*********************/ /* Package Variables */ /*********************/ @@ -386,78 +391,105 @@ static herr_t H5P__facc_mpi_info_close(const char *name, size_t size, void *valu /* File access property list class library initialization object */ const H5P_libclass_t H5P_CLS_FACC[1] = {{ "file access", /* Class name for debugging */ - H5P_TYPE_FILE_ACCESS, /* Class type */ + H5P_TYPE_FILE_ACCESS, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_ROOT_g, /* Parent class */ &H5P_CLS_FILE_ACCESS_g, /* Pointer to class */ - &H5P_CLS_FILE_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_FILE_ACCESS_ID_g, /* Pointer to default property list ID */ + &H5P_CLS_FILE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_ACCESS_ID_g, /* Pointer to default property list ID */ H5P__facc_reg_prop, /* Default property registration routine */ - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const H5AC_cache_config_t H5F_def_mdc_initCacheCfg_g = H5F_ACS_META_CACHE_INIT_CONFIG_DEF; /* Default metadata cache settings */ -static const size_t H5F_def_rdcc_nslots_g = H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ -static const size_t H5F_def_rdcc_nbytes_g = H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ -static const double H5F_def_rdcc_w0_g = H5F_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ -static const hsize_t H5F_def_threshold_g = H5F_ACS_ALIGN_THRHD_DEF; /* Default allocation alignment threshold */ -static const hsize_t H5F_def_alignment_g = H5F_ACS_ALIGN_DEF; /* Default allocation alignment value */ -static const hsize_t H5F_def_meta_block_size_g = H5F_ACS_META_BLOCK_SIZE_DEF; /* Default metadata allocation block size */ -static const size_t H5F_def_sieve_buf_size_g = H5F_ACS_SIEVE_BUF_SIZE_DEF; /* Default raw data I/O sieve buffer size */ -static const hsize_t H5F_def_sdata_block_size_g = H5F_ACS_SDATA_BLOCK_SIZE_DEF; /* Default small data allocation block size */ -static const unsigned H5F_def_gc_ref_g = H5F_ACS_GARBG_COLCT_REF_DEF; /* Default garbage collection for references setting */ -static const H5F_close_degree_t H5F_def_close_degree_g = H5F_CLOSE_DEGREE_DEF; /* Default file close degree */ -static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF; /* Default offset for family VFD */ -static const hsize_t H5F_def_family_newsize_g = H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */ -static const hbool_t H5F_def_family_to_single_g = H5F_ACS_FAMILY_TO_SINGLE_DEF; /* Default ?? for family VFD */ -static const H5FD_mem_t H5F_def_mem_type_g = H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */ - -static const H5F_libver_t H5F_def_libver_low_bound_g = H5F_ACS_LIBVER_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */ -static const H5F_libver_t H5F_def_libver_high_bound_g = H5F_ACS_LIBVER_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */ - -static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ -static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ -static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ -static const unsigned H5F_def_metadata_read_attempts_g = H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */ -static const H5F_object_flush_t H5F_def_object_flush_cb_g = H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */ -static const hbool_t H5F_def_clear_status_flags_g = H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */ -static const hbool_t H5F_def_skip_eof_check_g = H5F_ACS_SKIP_EOF_CHECK_DEF; /* Default setting for skipping EOF check */ -static const hbool_t H5F_def_null_fsm_addr_g = H5F_ACS_NULL_FSM_ADDR_DEF; /* Default setting for dropping free-space to the floor */ - -static const hbool_t H5F_def_use_mdc_logging_g = H5F_ACS_USE_MDC_LOGGING_DEF; /* Default metadata cache logging flag */ -static const char *H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */ -static const hbool_t H5F_def_start_mdc_log_on_access_g = H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF; /* Default mdc log start on access flag */ -static const hbool_t H5F_def_evict_on_close_flag_g = H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF; /* Default setting for evict on close property */ +static const H5AC_cache_config_t H5F_def_mdc_initCacheCfg_g = + H5F_ACS_META_CACHE_INIT_CONFIG_DEF; /* Default metadata cache settings */ +static const size_t H5F_def_rdcc_nslots_g = + H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ +static const size_t H5F_def_rdcc_nbytes_g = + H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ +static const double H5F_def_rdcc_w0_g = + H5F_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ +static const hsize_t H5F_def_threshold_g = + H5F_ACS_ALIGN_THRHD_DEF; /* Default allocation alignment threshold */ +static const hsize_t H5F_def_alignment_g = H5F_ACS_ALIGN_DEF; /* Default allocation alignment value */ +static const hsize_t H5F_def_meta_block_size_g = + H5F_ACS_META_BLOCK_SIZE_DEF; /* Default metadata allocation block size */ +static const size_t H5F_def_sieve_buf_size_g = + H5F_ACS_SIEVE_BUF_SIZE_DEF; /* Default raw data I/O sieve buffer size */ +static const hsize_t H5F_def_sdata_block_size_g = + H5F_ACS_SDATA_BLOCK_SIZE_DEF; /* Default small data allocation block size */ +static const unsigned H5F_def_gc_ref_g = + H5F_ACS_GARBG_COLCT_REF_DEF; /* Default garbage collection for references setting */ +static const H5F_close_degree_t H5F_def_close_degree_g = H5F_CLOSE_DEGREE_DEF; /* Default file close degree */ +static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF; /* Default offset for family VFD */ +static const hsize_t H5F_def_family_newsize_g = + H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */ +static const hbool_t H5F_def_family_to_single_g = + H5F_ACS_FAMILY_TO_SINGLE_DEF; /* Default ?? for family VFD */ +static const H5FD_mem_t H5F_def_mem_type_g = + H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */ + +static const H5F_libver_t H5F_def_libver_low_bound_g = + H5F_ACS_LIBVER_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */ +static const H5F_libver_t H5F_def_libver_high_bound_g = + H5F_ACS_LIBVER_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */ + +static const hbool_t H5F_def_want_posix_fd_g = + H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ +static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ +static const H5FD_file_image_info_t H5F_def_file_image_info_g = + H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ +static const unsigned H5F_def_metadata_read_attempts_g = + H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */ +static const H5F_object_flush_t H5F_def_object_flush_cb_g = + H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */ +static const hbool_t H5F_def_clear_status_flags_g = + H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */ +static const hbool_t H5F_def_skip_eof_check_g = + H5F_ACS_SKIP_EOF_CHECK_DEF; /* Default setting for skipping EOF check */ +static const hbool_t H5F_def_null_fsm_addr_g = + H5F_ACS_NULL_FSM_ADDR_DEF; /* Default setting for dropping free-space to the floor */ + +static const hbool_t H5F_def_use_mdc_logging_g = + H5F_ACS_USE_MDC_LOGGING_DEF; /* Default metadata cache logging flag */ +static const char * H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */ +static const hbool_t H5F_def_start_mdc_log_on_access_g = + H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF; /* Default mdc log start on access flag */ +static const hbool_t H5F_def_evict_on_close_flag_g = + H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF; /* Default setting for evict on close property */ #ifdef H5_HAVE_PARALLEL -static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g = H5F_ACS_COLL_MD_READ_FLAG_DEF; /* Default setting for the collective metedata read flag */ -static const hbool_t H5F_def_coll_md_write_flag_g = H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */ -static const MPI_Comm H5F_def_mpi_params_comm_g = H5F_ACS_MPI_PARAMS_COMM_DEF; /* Default MPI communicator */ -static const MPI_Info H5F_def_mpi_params_info_g = H5F_ACS_MPI_PARAMS_INFO_DEF; /* Default MPI info struct */ -#endif /* H5_HAVE_PARALLEL */ -static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g = H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF; /* Default metadata cache image settings */ -static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* Default page buffer size */ -static const unsigned H5F_def_page_buf_min_meta_perc_g = H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF; /* Default page buffer minimum metadata size */ -static const unsigned H5F_def_page_buf_min_raw_perc_g = H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer mininum raw data size */ - -static const H5F_vfd_swmr_config_t H5F_def_vfd_swmr_config_g = H5F_ACS_VFD_SWMR_CONFIG_DEF; /* Default vfd swmr configuration */ - +static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g = + H5F_ACS_COLL_MD_READ_FLAG_DEF; /* Default setting for the collective metedata read flag */ +static const hbool_t H5F_def_coll_md_write_flag_g = + H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */ +static const MPI_Comm H5F_def_mpi_params_comm_g = H5F_ACS_MPI_PARAMS_COMM_DEF; /* Default MPI communicator */ +static const MPI_Info H5F_def_mpi_params_info_g = H5F_ACS_MPI_PARAMS_INFO_DEF; /* Default MPI info struct */ +#endif /* H5_HAVE_PARALLEL */ +static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g = + H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF; /* Default metadata cache image settings */ +static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* Default page buffer size */ +static const unsigned H5F_def_page_buf_min_meta_perc_g = + H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF; /* Default page buffer minimum metadata size */ +static const unsigned H5F_def_page_buf_min_raw_perc_g = + H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer mininum raw data size */ + +static const H5F_vfd_swmr_config_t H5F_def_vfd_swmr_config_g = + H5F_ACS_VFD_SWMR_CONFIG_DEF; /* Default vfd swmr configuration */ /*------------------------------------------------------------------------- * Function: H5P__facc_reg_prop @@ -473,266 +505,293 @@ static const H5F_vfd_swmr_config_t H5F_def_vfd_swmr_config_g = H5F_ACS_VFD_SWMR_ static herr_t H5P__facc_reg_prop(H5P_genclass_t *pclass) { - const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ - const H5VL_connector_prop_t def_vol_prop = H5F_ACS_VOL_CONN_DEF; /* Default VOL connector ID & info (initialized from a variable) */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FD_driver_prop_t def_driver_prop = + H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ + const H5VL_connector_prop_t def_vol_prop = + H5F_ACS_VOL_CONN_DEF; /* Default VOL connector ID & info (initialized from a variable) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the initial metadata cache resize configuration */ - if(H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_CONFIG_SIZE, &H5F_def_mdc_initCacheCfg_g, - NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_ENC, H5F_ACS_META_CACHE_INIT_CONFIG_DEC, - NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_CMP, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_CONFIG_SIZE, + &H5F_def_mdc_initCacheCfg_g, NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_ENC, + H5F_ACS_META_CACHE_INIT_CONFIG_DEC, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_CMP, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache (elements) */ - if(H5P__register_real(pclass, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &H5F_def_rdcc_nslots_g, - NULL, NULL, NULL, H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC, H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE, + &H5F_def_rdcc_nslots_g, NULL, NULL, NULL, H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC, + H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache(bytes) */ - if(H5P__register_real(pclass, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &H5F_def_rdcc_nbytes_g, - NULL, NULL, NULL, H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC, H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE, + &H5F_def_rdcc_nbytes_g, NULL, NULL, NULL, H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC, + H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the preemption for reading chunks */ - if(H5P__register_real(pclass, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, H5F_ACS_PREEMPT_READ_CHUNKS_SIZE, &H5F_def_rdcc_w0_g, - NULL, NULL, NULL, H5F_ACS_PREEMPT_READ_CHUNKS_ENC, H5F_ACS_PREEMPT_READ_CHUNKS_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, H5F_ACS_PREEMPT_READ_CHUNKS_SIZE, + &H5F_def_rdcc_w0_g, NULL, NULL, NULL, H5F_ACS_PREEMPT_READ_CHUNKS_ENC, + H5F_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the threshold for alignment */ - if(H5P__register_real(pclass, H5F_ACS_ALIGN_THRHD_NAME, H5F_ACS_ALIGN_THRHD_SIZE, &H5F_def_threshold_g, - NULL, NULL, NULL, H5F_ACS_ALIGN_THRHD_ENC, H5F_ACS_ALIGN_THRHD_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_ALIGN_THRHD_NAME, H5F_ACS_ALIGN_THRHD_SIZE, &H5F_def_threshold_g, + NULL, NULL, NULL, H5F_ACS_ALIGN_THRHD_ENC, H5F_ACS_ALIGN_THRHD_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the alignment */ - if(H5P__register_real(pclass, H5F_ACS_ALIGN_NAME, H5F_ACS_ALIGN_SIZE, &H5F_def_alignment_g, - NULL, NULL, NULL, H5F_ACS_ALIGN_ENC, H5F_ACS_ALIGN_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_ALIGN_NAME, H5F_ACS_ALIGN_SIZE, &H5F_def_alignment_g, NULL, NULL, + NULL, H5F_ACS_ALIGN_ENC, H5F_ACS_ALIGN_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the minimum metadata allocation block size */ - if(H5P__register_real(pclass, H5F_ACS_META_BLOCK_SIZE_NAME, H5F_ACS_META_BLOCK_SIZE_SIZE, &H5F_def_meta_block_size_g, - NULL, NULL, NULL, H5F_ACS_META_BLOCK_SIZE_ENC, H5F_ACS_META_BLOCK_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_META_BLOCK_SIZE_NAME, H5F_ACS_META_BLOCK_SIZE_SIZE, + &H5F_def_meta_block_size_g, NULL, NULL, NULL, H5F_ACS_META_BLOCK_SIZE_ENC, + H5F_ACS_META_BLOCK_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the maximum sieve buffer size */ - if(H5P__register_real(pclass, H5F_ACS_SIEVE_BUF_SIZE_NAME, H5F_ACS_SIEVE_BUF_SIZE_SIZE, &H5F_def_sieve_buf_size_g, - NULL, NULL, NULL, H5F_ACS_SIEVE_BUF_SIZE_ENC, H5F_ACS_SIEVE_BUF_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_SIEVE_BUF_SIZE_NAME, H5F_ACS_SIEVE_BUF_SIZE_SIZE, + &H5F_def_sieve_buf_size_g, NULL, NULL, NULL, H5F_ACS_SIEVE_BUF_SIZE_ENC, + H5F_ACS_SIEVE_BUF_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the minimum "small data" allocation block size */ - if(H5P__register_real(pclass, H5F_ACS_SDATA_BLOCK_SIZE_NAME, H5F_ACS_SDATA_BLOCK_SIZE_SIZE, &H5F_def_sdata_block_size_g, - NULL, NULL, NULL, H5F_ACS_SDATA_BLOCK_SIZE_ENC, H5F_ACS_SDATA_BLOCK_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_SDATA_BLOCK_SIZE_NAME, H5F_ACS_SDATA_BLOCK_SIZE_SIZE, + &H5F_def_sdata_block_size_g, NULL, NULL, NULL, H5F_ACS_SDATA_BLOCK_SIZE_ENC, + H5F_ACS_SDATA_BLOCK_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the garbage collection reference */ - if(H5P__register_real(pclass, H5F_ACS_GARBG_COLCT_REF_NAME, H5F_ACS_GARBG_COLCT_REF_SIZE, &H5F_def_gc_ref_g, - NULL, NULL, NULL, H5F_ACS_GARBG_COLCT_REF_ENC, H5F_ACS_GARBG_COLCT_REF_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_GARBG_COLCT_REF_NAME, H5F_ACS_GARBG_COLCT_REF_SIZE, + &H5F_def_gc_ref_g, NULL, NULL, NULL, H5F_ACS_GARBG_COLCT_REF_ENC, + H5F_ACS_GARBG_COLCT_REF_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver ID & info */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_FILE_DRV_NAME, H5F_ACS_FILE_DRV_SIZE, &def_driver_prop, - H5F_ACS_FILE_DRV_CRT, H5F_ACS_FILE_DRV_SET, H5F_ACS_FILE_DRV_GET, NULL, NULL, - H5F_ACS_FILE_DRV_DEL, H5F_ACS_FILE_DRV_COPY, H5F_ACS_FILE_DRV_CMP, H5F_ACS_FILE_DRV_CLOSE) < 0) + if (H5P__register_real(pclass, H5F_ACS_FILE_DRV_NAME, H5F_ACS_FILE_DRV_SIZE, &def_driver_prop, + H5F_ACS_FILE_DRV_CRT, H5F_ACS_FILE_DRV_SET, H5F_ACS_FILE_DRV_GET, NULL, NULL, + H5F_ACS_FILE_DRV_DEL, H5F_ACS_FILE_DRV_COPY, H5F_ACS_FILE_DRV_CMP, + H5F_ACS_FILE_DRV_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file close degree */ - if(H5P__register_real(pclass, H5F_ACS_CLOSE_DEGREE_NAME, H5F_CLOSE_DEGREE_SIZE, &H5F_def_close_degree_g, - NULL, NULL, NULL, H5F_CLOSE_DEGREE_ENC, H5F_CLOSE_DEGREE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_CLOSE_DEGREE_NAME, H5F_CLOSE_DEGREE_SIZE, &H5F_def_close_degree_g, + NULL, NULL, NULL, H5F_CLOSE_DEGREE_ENC, H5F_CLOSE_DEGREE_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the offset of family driver info */ - if(H5P__register_real(pclass, H5F_ACS_FAMILY_OFFSET_NAME, H5F_ACS_FAMILY_OFFSET_SIZE, &H5F_def_family_offset_g, - NULL, NULL, NULL, H5F_ACS_FAMILY_OFFSET_ENC, H5F_ACS_FAMILY_OFFSET_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_FAMILY_OFFSET_NAME, H5F_ACS_FAMILY_OFFSET_SIZE, + &H5F_def_family_offset_g, NULL, NULL, NULL, H5F_ACS_FAMILY_OFFSET_ENC, + H5F_ACS_FAMILY_OFFSET_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the private property of new family file size. It's used by h5repart only. */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_FAMILY_NEWSIZE_NAME, H5F_ACS_FAMILY_NEWSIZE_SIZE, &H5F_def_family_newsize_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_FAMILY_NEWSIZE_NAME, H5F_ACS_FAMILY_NEWSIZE_SIZE, + &H5F_def_family_newsize_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the private property of whether convert family to a single-file driver. It's used by h5repart only. */ + /* Register the private property of whether convert family to a single-file driver. It's used by h5repart + * only. */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_FAMILY_TO_SINGLE_NAME, H5F_ACS_FAMILY_TO_SINGLE_SIZE, &H5F_def_family_to_single_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_FAMILY_TO_SINGLE_NAME, H5F_ACS_FAMILY_TO_SINGLE_SIZE, + &H5F_def_family_to_single_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the data type of multi driver info */ - if(H5P__register_real(pclass, H5F_ACS_MULTI_TYPE_NAME, H5F_ACS_MULTI_TYPE_SIZE, &H5F_def_mem_type_g, - NULL, NULL, NULL, H5F_ACS_MULTI_TYPE_ENC, H5F_ACS_MULTI_TYPE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_MULTI_TYPE_NAME, H5F_ACS_MULTI_TYPE_SIZE, &H5F_def_mem_type_g, + NULL, NULL, NULL, H5F_ACS_MULTI_TYPE_ENC, H5F_ACS_MULTI_TYPE_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 'low' bound of library format versions */ - if(H5P__register_real(pclass, H5F_ACS_LIBVER_LOW_BOUND_NAME, H5F_ACS_LIBVER_LOW_BOUND_SIZE, &H5F_def_libver_low_bound_g, - NULL, NULL, NULL, H5F_ACS_LIBVER_LOW_BOUND_ENC, H5F_ACS_LIBVER_LOW_BOUND_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_LIBVER_LOW_BOUND_NAME, H5F_ACS_LIBVER_LOW_BOUND_SIZE, + &H5F_def_libver_low_bound_g, NULL, NULL, NULL, H5F_ACS_LIBVER_LOW_BOUND_ENC, + H5F_ACS_LIBVER_LOW_BOUND_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 'high' bound of library format versions */ - if(H5P__register_real(pclass, H5F_ACS_LIBVER_HIGH_BOUND_NAME, H5F_ACS_LIBVER_HIGH_BOUND_SIZE, &H5F_def_libver_high_bound_g, - NULL, NULL, NULL, H5F_ACS_LIBVER_HIGH_BOUND_ENC, H5F_ACS_LIBVER_HIGH_BOUND_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_LIBVER_HIGH_BOUND_NAME, H5F_ACS_LIBVER_HIGH_BOUND_SIZE, + &H5F_def_libver_high_bound_g, NULL, NULL, NULL, H5F_ACS_LIBVER_HIGH_BOUND_ENC, + H5F_ACS_LIBVER_HIGH_BOUND_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the private property of whether to retrieve the file descriptor from the core VFD */ /* (used internally to the library only) */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_WANT_POSIX_FD_NAME, H5F_ACS_WANT_POSIX_FD_SIZE, &H5F_def_want_posix_fd_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_WANT_POSIX_FD_NAME, H5F_ACS_WANT_POSIX_FD_SIZE, + &H5F_def_want_posix_fd_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the external file cache size */ - if(H5P__register_real(pclass, H5F_ACS_EFC_SIZE_NAME, H5F_ACS_EFC_SIZE_SIZE, &H5F_def_efc_size_g, - NULL, NULL, NULL, H5F_ACS_EFC_SIZE_ENC, H5F_ACS_EFC_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_EFC_SIZE_NAME, H5F_ACS_EFC_SIZE_SIZE, &H5F_def_efc_size_g, NULL, + NULL, NULL, H5F_ACS_EFC_SIZE_ENC, H5F_ACS_EFC_SIZE_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the initial file image info */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE, &H5F_def_file_image_info_g, - NULL, H5F_ACS_FILE_IMAGE_INFO_SET, H5F_ACS_FILE_IMAGE_INFO_GET, NULL, NULL, - H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) + if (H5P__register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE, + &H5F_def_file_image_info_g, NULL, H5F_ACS_FILE_IMAGE_INFO_SET, + H5F_ACS_FILE_IMAGE_INFO_GET, NULL, NULL, H5F_ACS_FILE_IMAGE_INFO_DEL, + H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP, + H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the # of read attempts */ - if(H5P__register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE, &H5F_def_metadata_read_attempts_g, - NULL, NULL, NULL, H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE, + &H5F_def_metadata_read_attempts_g, NULL, NULL, NULL, + H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register object flush callback */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_OBJECT_FLUSH_CB_NAME, H5F_ACS_OBJECT_FLUSH_CB_SIZE, &H5F_def_object_flush_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_OBJECT_FLUSH_CB_NAME, H5F_ACS_OBJECT_FLUSH_CB_SIZE, + &H5F_def_object_flush_cb_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the private property of whether to clear the superblock status_flags. It's used by h5clear only. */ - if(H5P__register_real(pclass, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, H5F_ACS_CLEAR_STATUS_FLAGS_SIZE, &H5F_def_clear_status_flags_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + /* Register the private property of whether to clear the superblock status_flags. It's used by h5clear + * only. */ + if (H5P__register_real(pclass, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, H5F_ACS_CLEAR_STATUS_FLAGS_SIZE, + &H5F_def_clear_status_flags_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the private property of whether to skip EOF check. It's used by h5clear only. */ - if(H5P__register_real(pclass, H5F_ACS_SKIP_EOF_CHECK_NAME, H5F_ACS_SKIP_EOF_CHECK_SIZE, &H5F_def_skip_eof_check_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_SKIP_EOF_CHECK_NAME, H5F_ACS_SKIP_EOF_CHECK_SIZE, + &H5F_def_skip_eof_check_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the private property of whether to drop free-space to the floor. It's used by h5clear only. */ - if(H5P__register_real(pclass, H5F_ACS_NULL_FSM_ADDR_NAME, H5F_ACS_NULL_FSM_ADDR_SIZE, &H5F_def_null_fsm_addr_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_NULL_FSM_ADDR_NAME, H5F_ACS_NULL_FSM_ADDR_SIZE, + &H5F_def_null_fsm_addr_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the metadata cache logging flag. */ - if(H5P__register_real(pclass, H5F_ACS_USE_MDC_LOGGING_NAME, H5F_ACS_USE_MDC_LOGGING_SIZE, &H5F_def_use_mdc_logging_g, - NULL, NULL, NULL, H5F_ACS_USE_MDC_LOGGING_ENC, H5F_ACS_USE_MDC_LOGGING_DEC, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_USE_MDC_LOGGING_NAME, H5F_ACS_USE_MDC_LOGGING_SIZE, + &H5F_def_use_mdc_logging_g, NULL, NULL, NULL, H5F_ACS_USE_MDC_LOGGING_ENC, + H5F_ACS_USE_MDC_LOGGING_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the metadata cache log location. */ - if(H5P__register_real(pclass, H5F_ACS_MDC_LOG_LOCATION_NAME, H5F_ACS_MDC_LOG_LOCATION_SIZE, &H5F_def_mdc_log_location_g, - NULL, NULL, NULL, H5F_ACS_MDC_LOG_LOCATION_ENC, H5F_ACS_MDC_LOG_LOCATION_DEC, - H5F_ACS_MDC_LOG_LOCATION_DEL, H5F_ACS_MDC_LOG_LOCATION_COPY, H5F_ACS_MDC_LOG_LOCATION_CMP, H5F_ACS_MDC_LOG_LOCATION_CLOSE) < 0) + if (H5P__register_real(pclass, H5F_ACS_MDC_LOG_LOCATION_NAME, H5F_ACS_MDC_LOG_LOCATION_SIZE, + &H5F_def_mdc_log_location_g, NULL, NULL, NULL, H5F_ACS_MDC_LOG_LOCATION_ENC, + H5F_ACS_MDC_LOG_LOCATION_DEC, H5F_ACS_MDC_LOG_LOCATION_DEL, + H5F_ACS_MDC_LOG_LOCATION_COPY, H5F_ACS_MDC_LOG_LOCATION_CMP, + H5F_ACS_MDC_LOG_LOCATION_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the flag that indicates whether mdc logging starts on file access. */ - if(H5P__register_real(pclass, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE, &H5F_def_start_mdc_log_on_access_g, - NULL, NULL, NULL, H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC, H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE, + &H5F_def_start_mdc_log_on_access_g, NULL, NULL, NULL, + H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC, H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC, NULL, + NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the evict on close flag */ - if(H5P__register_real(pclass, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE, &H5F_def_evict_on_close_flag_g, - NULL, NULL, NULL, H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC, H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE, + &H5F_def_evict_on_close_flag_g, NULL, NULL, NULL, H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC, + H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #ifdef H5_HAVE_PARALLEL /* Register the metadata collective read flag */ - if(H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5F_ACS_COLL_MD_READ_FLAG_SIZE, &H5F_def_coll_md_read_flag_g, - NULL, NULL, NULL, H5F_ACS_COLL_MD_READ_FLAG_ENC, H5F_ACS_COLL_MD_READ_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5F_ACS_COLL_MD_READ_FLAG_SIZE, + &H5F_def_coll_md_read_flag_g, NULL, NULL, NULL, H5F_ACS_COLL_MD_READ_FLAG_ENC, + H5F_ACS_COLL_MD_READ_FLAG_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the metadata collective write flag */ - if(H5P__register_real(pclass, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, H5F_ACS_COLL_MD_WRITE_FLAG_SIZE, &H5F_def_coll_md_write_flag_g, - NULL, NULL, NULL, H5F_ACS_COLL_MD_WRITE_FLAG_ENC, H5F_ACS_COLL_MD_WRITE_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, H5F_ACS_COLL_MD_WRITE_FLAG_SIZE, + &H5F_def_coll_md_write_flag_g, NULL, NULL, NULL, H5F_ACS_COLL_MD_WRITE_FLAG_ENC, + H5F_ACS_COLL_MD_WRITE_FLAG_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the MPI communicator */ - if(H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_COMM_NAME, H5F_ACS_MPI_PARAMS_COMM_SIZE, &H5F_def_mpi_params_comm_g, - NULL, H5F_ACS_MPI_PARAMS_COMM_SET, H5F_ACS_MPI_PARAMS_COMM_GET, NULL, NULL, - H5F_ACS_MPI_PARAMS_COMM_DEL, H5F_ACS_MPI_PARAMS_COMM_COPY, H5F_ACS_MPI_PARAMS_COMM_CMP, H5F_ACS_MPI_PARAMS_COMM_CLOSE) < 0) + if (H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_COMM_NAME, H5F_ACS_MPI_PARAMS_COMM_SIZE, + &H5F_def_mpi_params_comm_g, NULL, H5F_ACS_MPI_PARAMS_COMM_SET, + H5F_ACS_MPI_PARAMS_COMM_GET, NULL, NULL, H5F_ACS_MPI_PARAMS_COMM_DEL, + H5F_ACS_MPI_PARAMS_COMM_COPY, H5F_ACS_MPI_PARAMS_COMM_CMP, + H5F_ACS_MPI_PARAMS_COMM_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the MPI info struct */ - if(H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_INFO_NAME, H5F_ACS_MPI_PARAMS_INFO_SIZE, &H5F_def_mpi_params_info_g, - NULL, H5F_ACS_MPI_PARAMS_INFO_SET, H5F_ACS_MPI_PARAMS_INFO_GET, NULL, NULL, - H5F_ACS_MPI_PARAMS_INFO_DEL, H5F_ACS_MPI_PARAMS_INFO_COPY, H5F_ACS_MPI_PARAMS_INFO_CMP, H5F_ACS_MPI_PARAMS_INFO_CLOSE) < 0) + if (H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_INFO_NAME, H5F_ACS_MPI_PARAMS_INFO_SIZE, + &H5F_def_mpi_params_info_g, NULL, H5F_ACS_MPI_PARAMS_INFO_SET, + H5F_ACS_MPI_PARAMS_INFO_GET, NULL, NULL, H5F_ACS_MPI_PARAMS_INFO_DEL, + H5F_ACS_MPI_PARAMS_INFO_COPY, H5F_ACS_MPI_PARAMS_INFO_CMP, + H5F_ACS_MPI_PARAMS_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #endif /* H5_HAVE_PARALLEL */ /* Register the initial metadata cache image configuration */ - if(H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE, &H5F_def_mdc_initCacheImageCfg_g, - NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC, - NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, + H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE, &H5F_def_mdc_initCacheImageCfg_g, NULL, + NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC, + H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC, NULL, NULL, + H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of the page buffer size */ - if(H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_SIZE_NAME, H5F_ACS_PAGE_BUFFER_SIZE_SIZE, &H5F_def_page_buf_size_g, - NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_SIZE_ENC, H5F_ACS_PAGE_BUFFER_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_SIZE_NAME, H5F_ACS_PAGE_BUFFER_SIZE_SIZE, + &H5F_def_page_buf_size_g, NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_SIZE_ENC, + H5F_ACS_PAGE_BUFFER_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of the page buffer minimum metadata size */ - if(H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE, &H5F_def_page_buf_min_meta_perc_g, - NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, + H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE, &H5F_def_page_buf_min_meta_perc_g, NULL, + NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC, + H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of the page buffer minimum raw data size */ - if(H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE, &H5F_def_page_buf_min_raw_perc_g, - NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, + H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE, &H5F_def_page_buf_min_raw_perc_g, NULL, + NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC, + H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the default VFD SWMR configuration */ - if(H5P__register_real(pclass, H5F_ACS_VFD_SWMR_CONFIG_NAME, H5F_ACS_VFD_SWMR_CONFIG_SIZE, &H5F_def_vfd_swmr_config_g, - NULL, NULL, NULL, H5F_ACS_VFD_SWMR_CONFIG_ENC, H5F_ACS_VFD_SWMR_CONFIG_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_VFD_SWMR_CONFIG_NAME, H5F_ACS_VFD_SWMR_CONFIG_SIZE, + &H5F_def_vfd_swmr_config_g, NULL, NULL, NULL, H5F_ACS_VFD_SWMR_CONFIG_ENC, + H5F_ACS_VFD_SWMR_CONFIG_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file VOL connector ID & info */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_VOL_CONN_NAME, H5F_ACS_VOL_CONN_SIZE, &def_vol_prop, - H5F_ACS_VOL_CONN_CRT, H5F_ACS_VOL_CONN_SET, H5F_ACS_VOL_CONN_GET, NULL, NULL, - H5F_ACS_VOL_CONN_DEL, H5F_ACS_VOL_CONN_COPY, H5F_ACS_VOL_CONN_CMP, H5F_ACS_VOL_CONN_CLOSE) < 0) + if (H5P__register_real(pclass, H5F_ACS_VOL_CONN_NAME, H5F_ACS_VOL_CONN_SIZE, &def_vol_prop, + H5F_ACS_VOL_CONN_CRT, H5F_ACS_VOL_CONN_SET, H5F_ACS_VOL_CONN_GET, NULL, NULL, + H5F_ACS_VOL_CONN_DEL, H5F_ACS_VOL_CONN_COPY, H5F_ACS_VOL_CONN_CMP, + H5F_ACS_VOL_CONN_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") if (H5P_LST_FILE_ACCESS_ANY_VFD_g == H5I_INVALID_HID) { H5P_LST_FILE_ACCESS_ANY_VFD_g = H5P_create_id(pclass, false); if (H5P_LST_FILE_ACCESS_ANY_VFD_g == H5I_INVALID_HID) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, - "can't create any-vfd fapl"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't create any-vfd fapl"); } } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_alignment * @@ -766,31 +825,30 @@ done: herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ihh", fapl_id, threshold, alignment); /* Check args */ - if(alignment < 1) + if (alignment < 1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "alignment must be positive") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_ALIGN_THRHD_NAME, &threshold) < 0) + if (H5P_set(plist, H5F_ACS_ALIGN_THRHD_NAME, &threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set threshold") - if(H5P_set(plist, H5F_ACS_ALIGN_NAME, &alignment) < 0) + if (H5P_set(plist, H5F_ACS_ALIGN_NAME, &alignment) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_alignment * @@ -806,32 +864,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/, - hsize_t *alignment/*out*/) +H5Pget_alignment(hid_t fapl_id, hsize_t *threshold /*out*/, hsize_t *alignment /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, threshold, alignment); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(threshold) - if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, threshold) < 0) + if (threshold) + if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get threshold") - if(alignment) - if(H5P_get(plist, H5F_ACS_ALIGN_NAME, alignment) < 0) + if (alignment) + if (H5P_get(plist, H5F_ACS_ALIGN_NAME, alignment) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get alignment") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_alignment() */ - /*------------------------------------------------------------------------- * Function: H5P_set_driver * @@ -854,22 +910,22 @@ done: herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(NULL == H5I_object_verify(new_driver_id, H5I_VFL)) + if (NULL == H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID") - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ /* Prepare the driver property */ - driver_prop.driver_id = new_driver_id; + driver_prop.driver_id = new_driver_id; driver_prop.driver_info = new_driver_info; /* Set the driver ID & info property */ - if(H5P_set(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_set(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver ID & info") } /* end if */ else @@ -879,7 +935,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_set_driver() */ - /*------------------------------------------------------------------------- * Function: H5Pset_driver * @@ -902,27 +957,26 @@ done: herr_t H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", plist_id, new_driver_id, new_driver_info); /* Check arguments */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(NULL == H5I_object_verify(new_driver_id, H5I_VFL)) + if (NULL == H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID") /* Set the driver */ - if(H5P_set_driver(plist, new_driver_id, new_driver_info) < 0) + if (H5P_set_driver(plist, new_driver_id, new_driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_driver() */ - /*------------------------------------------------------------------------- * Function: H5P_peek_driver * @@ -944,29 +998,28 @@ done: hid_t H5P_peek_driver(H5P_genplist_t *plist) { - hid_t ret_value = FAIL; /* Return value */ + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the current driver ID */ - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") ret_value = driver_prop.driver_id; } /* end if */ else HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5FD_VFD_DEFAULT == ret_value) + if (H5FD_VFD_DEFAULT == ret_value) ret_value = H5_DEFAULT_VFD; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_peek_driver() */ - /*------------------------------------------------------------------------- * Function: H5Pget_driver * @@ -990,24 +1043,23 @@ done: hid_t H5Pget_driver(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list pointer */ - hid_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", plist_id); - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get the driver */ - if((ret_value = H5P_peek_driver(plist)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver") + if ((ret_value = H5P_peek_driver(plist)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_driver() */ - /*------------------------------------------------------------------------- * Function: H5P_peek_driver_info * @@ -1030,15 +1082,15 @@ done: const void * H5P_peek_driver_info(H5P_genplist_t *plist) { - const void *ret_value = NULL; /* Return value */ + const void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Get the current driver info */ - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info") ret_value = driver_prop.driver_info; } /* end if */ @@ -1049,7 +1101,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_peek_driver_info() */ - /*------------------------------------------------------------------------- * Function: H5Pget_driver_info * @@ -1072,24 +1123,23 @@ done: const void * H5Pget_driver_info(hid_t plist_id) { - H5P_genplist_t *plist = NULL; /* Property list pointer */ - const void *ret_value = NULL; /* Return value */ + H5P_genplist_t *plist = NULL; /* Property list pointer */ + const void * ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE1("*x", "i", plist_id); - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") /* Get the driver info */ - if(NULL == (ret_value = (const void *)H5P_peek_driver_info(plist))) + if (NULL == (ret_value = (const void *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_driver_info() */ - /*------------------------------------------------------------------------- * Function: H5P__file_driver_copy * @@ -1110,35 +1160,35 @@ done: static herr_t H5P__file_driver_copy(void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(value) { + if (value) { H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */ /* Copy the driver & info, if there is one */ - if(info->driver_id > 0) { + if (info->driver_id > 0) { /* Increment the reference count on driver and copy driver info */ - if(H5I_inc_ref(info->driver_id, FALSE) < 0) + if (H5I_inc_ref(info->driver_id, FALSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") /* Copy driver info, if it exists */ - if(info->driver_info) { - H5FD_class_t *driver; /* Pointer to driver */ - void *new_pl; /* Copy of driver info */ + if (info->driver_info) { + H5FD_class_t *driver; /* Pointer to driver */ + void * new_pl; /* Copy of driver info */ /* Retrieve the driver for the ID */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) + if (NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a driver ID") /* Allow the driver to copy or do it ourselves */ - if(driver->fapl_copy) { - if(NULL == (new_pl = (driver->fapl_copy)(info->driver_info))) + if (driver->fapl_copy) { + if (NULL == (new_pl = (driver->fapl_copy)(info->driver_info))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver info copy failed") } /* end if */ - else if(driver->fapl_size > 0) { - if(NULL == (new_pl = H5MM_malloc(driver->fapl_size))) + else if (driver->fapl_size > 0) { + if (NULL == (new_pl = H5MM_malloc(driver->fapl_size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "driver info allocation failed") H5MM_memcpy(new_pl, info->driver_info, driver->fapl_size); } /* end else-if */ @@ -1148,14 +1198,13 @@ H5P__file_driver_copy(void *value) /* Set the driver info for the copy */ info->driver_info = new_pl; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__file_driver_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__file_driver_free * @@ -1172,23 +1221,23 @@ done: static herr_t H5P__file_driver_free(void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(value) { + if (value) { H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */ /* Copy the driver & info, if there is one */ - if(info->driver_id > 0) { + if (info->driver_id > 0) { /* Free the driver info, if it exists */ - if(info->driver_info) - if(H5FD_free_driver_info(info->driver_id, info->driver_info) < 0) + if (info->driver_info) + if (H5FD_free_driver_info(info->driver_id, info->driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") /* Decrement reference count for driver */ - if(H5I_dec_ref(info->driver_id) < 0) + if (H5I_dec_ref(info->driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID") } } @@ -1197,7 +1246,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__file_driver_free() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_create * @@ -1214,19 +1262,18 @@ done: static herr_t H5P__facc_file_driver_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make copy of file driver */ - if(H5P__file_driver_copy(value) < 0) + if (H5P__file_driver_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_create() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_set * @@ -1242,9 +1289,9 @@ done: */ static herr_t H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1252,14 +1299,13 @@ H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSE HDassert(value); /* Make copy of file driver ID & info */ - if(H5P__file_driver_copy(value) < 0) + if (H5P__file_driver_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_set() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_get * @@ -1275,9 +1321,9 @@ done: */ static herr_t H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1285,14 +1331,13 @@ H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSE HDassert(value); /* Make copy of file driver */ - if(H5P__file_driver_copy(value) < 0) + if (H5P__file_driver_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_get() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_del * @@ -1307,21 +1352,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the file driver ID & info */ - if(H5P__file_driver_free(value) < 0) + if (H5P__file_driver_free(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_del() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_copy * @@ -1338,19 +1383,18 @@ done: static herr_t H5P__facc_file_driver_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make copy of file driver */ - if(H5P__file_driver_copy(value) < 0) + if (H5P__file_driver_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_cmp * @@ -1367,14 +1411,14 @@ done: *------------------------------------------------------------------------- */ static int -H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, - size_t H5_ATTR_UNUSED size) +H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) { - const H5FD_driver_prop_t *info1 = (const H5FD_driver_prop_t *)_info1, /* Create local aliases for values */ + const H5FD_driver_prop_t *info1 = + (const H5FD_driver_prop_t *)_info1, /* Create local aliases for values */ *info2 = (const H5FD_driver_prop_t *)_info2; - H5FD_class_t *cls1, *cls2; /* Driver class for each property */ - int cmp_value; /* Value from comparison */ - herr_t ret_value = 0; /* Return value */ + H5FD_class_t *cls1, *cls2; /* Driver class for each property */ + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1384,24 +1428,30 @@ H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, HDassert(size == sizeof(H5FD_driver_prop_t)); /* Compare drivers */ - if(NULL == (cls1 = H5FD_get_class(info1->driver_id))) + if (NULL == (cls1 = H5FD_get_class(info1->driver_id))) HGOTO_DONE(-1) - if(NULL == (cls2 = H5FD_get_class(info2->driver_id))) + if (NULL == (cls2 = H5FD_get_class(info2->driver_id))) HGOTO_DONE(1) - if(cls1->name == NULL && cls2->name != NULL) HGOTO_DONE(-1); - if(cls1->name != NULL && cls2->name == NULL) HGOTO_DONE(1); - if(0 != (cmp_value = HDstrcmp(cls1->name, cls2->name))) + if (cls1->name == NULL && cls2->name != NULL) + HGOTO_DONE(-1); + if (cls1->name != NULL && cls2->name == NULL) + HGOTO_DONE(1); + if (0 != (cmp_value = HDstrcmp(cls1->name, cls2->name))) HGOTO_DONE(cmp_value); /* Compare driver infos */ - if(cls1->fapl_size < cls2->fapl_size) HGOTO_DONE(-1) - if(cls1->fapl_size > cls2->fapl_size) HGOTO_DONE(1) + if (cls1->fapl_size < cls2->fapl_size) + HGOTO_DONE(-1) + if (cls1->fapl_size > cls2->fapl_size) + HGOTO_DONE(1) HDassert(cls1->fapl_size == cls2->fapl_size); - if(info1->driver_info == NULL && info2->driver_info != NULL) HGOTO_DONE(-1); - if(info1->driver_info != NULL && info2->driver_info == NULL) HGOTO_DONE(1); - if(info1->driver_info) { + if (info1->driver_info == NULL && info2->driver_info != NULL) + HGOTO_DONE(-1); + if (info1->driver_info != NULL && info2->driver_info == NULL) + HGOTO_DONE(1); + if (info1->driver_info) { HDassert(cls1->fapl_size > 0); - if(0 != (cmp_value = HDmemcmp(info1->driver_info, info2->driver_info, cls1->fapl_size))) + if (0 != (cmp_value = HDmemcmp(info1->driver_info, info2->driver_info, cls1->fapl_size))) HGOTO_DONE(cmp_value); } /* end if */ @@ -1409,7 +1459,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_close * @@ -1426,19 +1475,18 @@ done: static herr_t H5P__facc_file_driver_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the file driver */ - if(H5P__file_driver_free(value) < 0) + if (H5P__file_driver_free(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_family_offset * @@ -1453,31 +1501,30 @@ done: * Sep 17, 2002 * *------------------------------------------------------------------------- -*/ + */ herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", fapl_id, offset); /* Get the plist structure */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) + if (H5P_set(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set offset for family file") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_family_offset() */ - /*------------------------------------------------------------------------- * Function: H5Pget_family_offset * @@ -1496,21 +1543,21 @@ done: herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", fapl_id, offset); /* Get the plist structure */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(offset) { - if(H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, offset) < 0) + if (offset) { + if (H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set offset for family file") } /* end if */ @@ -1518,7 +1565,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_family_offset() */ - /*------------------------------------------------------------------------- * Function: H5Pset_multi_type * @@ -1537,27 +1583,26 @@ done: herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iMt", fapl_id, type); /* Get the plist structure */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5F_ACS_MULTI_TYPE_NAME, &type) < 0) + if (H5P_set(plist, H5F_ACS_MULTI_TYPE_NAME, &type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type for multi driver") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_multi_type() */ - /*------------------------------------------------------------------------- * Function: H5Pget_multi_type * @@ -1576,21 +1621,21 @@ done: herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Mt", fapl_id, type); /* Get the plist structure */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(type) { - if(H5P_get(plist, H5F_ACS_MULTI_TYPE_NAME, type) < 0) + if (type) { + if (H5P_get(plist, H5F_ACS_MULTI_TYPE_NAME, type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get type for multi driver") } /* end if */ @@ -1598,7 +1643,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_multi_type() */ - /*------------------------------------------------------------------------- * Function: H5Pset_cache * @@ -1622,37 +1666,37 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_cache(hid_t plist_id, int H5_ATTR_UNUSED mdc_nelmts, - size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) +H5Pset_cache(hid_t plist_id, int H5_ATTR_UNUSED mdc_nelmts, size_t rdcc_nslots, size_t rdcc_nbytes, + double rdcc_w0) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIszzd", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Check arguments */ - if(rdcc_w0 < (double)0.0f || rdcc_w0 > (double)1.0f) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive") + if (rdcc_w0 < (double)0.0f || rdcc_w0 > (double)1.0f) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "raw data cache w0 value must be between 0.0 and 1.0 inclusive") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set sizes */ - if(H5P_set(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of slots") - if(H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size") - if(H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks") + if (H5P_set(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots") + if (H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") + if (H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_cache() */ - /*------------------------------------------------------------------------- * Function: H5Pget_cache * @@ -1670,41 +1714,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_cache(hid_t plist_id, int *mdc_nelmts, - size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0) +H5Pget_cache(hid_t plist_id, int *mdc_nelmts, size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*Is*z*z*d", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get sizes */ /* the mdc_nelmts FAPL entry no longer exists, so just return a constant */ - if(mdc_nelmts) + if (mdc_nelmts) *mdc_nelmts = 0; - if(rdcc_nslots) - if(H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots") - if(rdcc_nbytes) - if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size") - if(rdcc_w0) - if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks") + if (rdcc_nslots) + if (H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache number of slots") + if (rdcc_nbytes) + if (H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache byte size") + if (rdcc_w0) + if (H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get preempt read chunks") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_cache() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mdc_image_config * @@ -1721,18 +1763,18 @@ done: herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", plist_id, config_ptr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* validate the new configuration */ - if(H5AC_validate_cache_image_config(config_ptr) < 0) + if (H5AC_validate_cache_image_config(config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache image configuration") /* set the modified metadata cache image config */ @@ -1741,14 +1783,13 @@ H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) * will have to test the version and do translation here. */ - if(H5P_set(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0) + if (H5P_set(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache image initial config") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_mdc_image_config() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mdc_image_config * @@ -1769,21 +1810,21 @@ done: herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", plist_id, config_ptr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* validate the config_ptr */ - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.") - if(config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) + if (config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown image config version.") /* If we ever support multiple versions of H5AC_cache_config_t, we @@ -1792,14 +1833,13 @@ H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) */ /* Get the current initial metadata cache resize configuration */ - if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get metadata cache initial image config") + if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get metadata cache initial image config") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_mdc_image_config() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mdc_config * @@ -1816,18 +1856,18 @@ done: herr_t H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", plist_id, config_ptr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* validate the new configuration */ - if(H5AC_validate_config(config_ptr) < 0) + if (H5AC_validate_config(config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache configuration") /* set the modified config */ @@ -1836,14 +1876,13 @@ H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) * will have to test the version and do translation here. */ - if(H5P_set(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0) + if (H5P_set(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache initial config") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_mdc_config() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mdc_config * @@ -1864,21 +1903,21 @@ done: herr_t H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", plist_id, config_ptr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* validate the config_ptr */ - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.") - if(config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) + if (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown config version.") /* If we ever support multiple versions of H5AC_cache_config_t, we @@ -1887,14 +1926,13 @@ H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) */ /* Get the current initial metadata cache resize configuration */ - if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get metadata cache initial resize config") + if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get metadata cache initial resize config") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_mdc_config() */ - /*------------------------------------------------------------------------- * Function: H5Pset_gc_references * @@ -1929,25 +1967,24 @@ done: herr_t H5Pset_gc_references(hid_t plist_id, unsigned gc_ref) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, gc_ref); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &gc_ref) < 0) + if (H5P_set(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &gc_ref) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_gc_references * @@ -1969,28 +2006,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref/*out*/) +H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, gc_ref); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(gc_ref) - if(H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, gc_ref) < 0) + if (gc_ref) + if (H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, gc_ref) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get garbage collect reference") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_fclose_degree * @@ -2008,25 +2044,24 @@ done: herr_t H5Pset_fclose_degree(hid_t plist_id, H5F_close_degree_t degree) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iFd", plist_id, degree); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_CLOSE_DEGREE_NAME, °ree) < 0) + if (H5P_set(plist, H5F_ACS_CLOSE_DEGREE_NAME, °ree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fclose_degree() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fclose_degree * @@ -2044,24 +2079,23 @@ done: herr_t H5Pget_fclose_degree(hid_t plist_id, H5F_close_degree_t *degree) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Fd", plist_id, degree); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(degree && H5P_get(plist, H5F_ACS_CLOSE_DEGREE_NAME, degree) < 0) + if (degree && H5P_get(plist, H5F_ACS_CLOSE_DEGREE_NAME, degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file close degree") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fclose_degree() */ - /*------------------------------------------------------------------------- * Function: H5Pset_meta_block_size * @@ -2094,25 +2128,24 @@ done: herr_t H5Pset_meta_block_size(hid_t plist_id, hsize_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &size) < 0) + if (H5P_set(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data block size") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_meta_block_size * @@ -2134,21 +2167,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_meta_block_size(hid_t plist_id, hsize_t *size/*out*/) +H5Pget_meta_block_size(hid_t plist_id, hsize_t *size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(size) { - if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, size) < 0) + if (size) { + if (H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get meta data block size") } /* end if */ @@ -2156,7 +2189,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_sieve_buf_size * @@ -2189,25 +2221,24 @@ done: herr_t H5Pset_sieve_buf_size(hid_t plist_id, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0) + if (H5P_set(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set sieve buffer size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_sieve_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_sieve_buf_size * @@ -2229,28 +2260,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_sieve_buf_size(hid_t plist_id, size_t *size/*out*/) +H5Pget_sieve_buf_size(hid_t plist_id, size_t *size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(size) - if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, size) < 0) + if (size) + if (H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get sieve buffer size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_sieve_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5Pset_small_data_block_size * @@ -2278,25 +2308,24 @@ done: herr_t H5Pset_small_data_block_size(hid_t plist_id, hsize_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &size) < 0) + if (H5P_set(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' block size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_small_data_block_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_small_data_block_size * @@ -2313,21 +2342,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size/*out*/) +H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(size) { - if(H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, size) < 0) + if (size) { + if (H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get 'small data' block size") } /* end if */ @@ -2335,7 +2364,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_small_data_block_size() */ - /*------------------------------------------------------------------------- * Function: H5Pset_libver_bounds * @@ -2443,41 +2471,40 @@ done: herr_t H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iFvFv", plist_id, low, high); /* Check args */ - if(low < 0 || low > H5F_LIBVER_LATEST) + if (low < 0 || low > H5F_LIBVER_LATEST) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "low bound is not valid") - if(high < 0 || high > H5F_LIBVER_LATEST) + if (high < 0 || high > H5F_LIBVER_LATEST) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "high bound is not valid") /* (earliest, earliest), (latest, earliest), (v18, earliest) are not valid combinations */ - if(high == H5F_LIBVER_EARLIEST) + if (high == H5F_LIBVER_EARLIEST) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound") /* (latest, v18) is not valid combination */ - if(high < low) + if (high < low) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low) < 0) + if (H5P_set(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set low bound for library format versions") - if(H5P_set(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high) < 0) + if (H5P_set(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set high bound for library format versions") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5Pget_libver_bounds * @@ -2492,27 +2519,26 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low/*out*/, - H5F_libver_t *high/*out*/) +H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low /*out*/, H5F_libver_t *high /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", plist_id, low, high); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Get values */ - if(low) { - if(H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, low) < 0) + /* Get values */ + if (low) { + if (H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, low) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get low bound for library format versions") } - if(high) { - if(H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high) < 0) + if (high) { + if (H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get high bound for library format versions") } @@ -2520,7 +2546,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5Pset_elink_file_cache_size * @@ -2540,25 +2565,24 @@ done: herr_t H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, efc_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) + if (H5P_set(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set elink file cache size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_file_cache_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_file_cache_size * @@ -2578,26 +2602,25 @@ done: herr_t H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", plist_id, efc_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(efc_size) - if(H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, efc_size) < 0) + if (efc_size) + if (H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get elink file cache size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_file_cache_size() */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_image * @@ -2614,29 +2637,31 @@ done: herr_t H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) { - H5P_genplist_t *fapl; /* Property list pointer */ - H5FD_file_image_info_t image_info; /* File image info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * fapl; /* Property list pointer */ + H5FD_file_image_info_t image_info; /* File image info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*xz", fapl_id, buf_ptr, buf_len); /* validate parameters */ - if(!(((buf_ptr == NULL) && (buf_len == 0)) || ((buf_ptr != NULL) && (buf_len > 0)))) + if (!(((buf_ptr == NULL) && (buf_len == 0)) || ((buf_ptr != NULL) && (buf_len > 0)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "inconsistent buf_ptr and buf_len") /* Get the plist structure */ - if(NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old image info */ - if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image pointer") /* Release previous buffer, if it exists */ - if(image_info.buffer != NULL) { - if(image_info.callbacks.image_free) { - if(SUCCEED != image_info.callbacks.image_free(image_info.buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata)) + if (image_info.buffer != NULL) { + if (image_info.callbacks.image_free) { + if (SUCCEED != image_info.callbacks.image_free(image_info.buffer, + H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, + image_info.callbacks.udata)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else @@ -2644,25 +2669,24 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) } /* end if */ /* Update struct */ - if(buf_ptr) { + if (buf_ptr) { /* Allocate memory */ - if(image_info.callbacks.image_malloc) { - if(NULL == (image_info.buffer = image_info.callbacks.image_malloc(buf_len, - H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata))) + if (image_info.callbacks.image_malloc) { + if (NULL == (image_info.buffer = image_info.callbacks.image_malloc( + buf_len, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "image malloc callback failed") - } /* end if */ - else - if(NULL == (image_info.buffer = H5MM_malloc(buf_len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") + } /* end if */ + else if (NULL == (image_info.buffer = H5MM_malloc(buf_len))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") /* Copy data */ - if(image_info.callbacks.image_memcpy) { - if(image_info.buffer != image_info.callbacks.image_memcpy(image_info.buffer, - buf_ptr, buf_len, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, - image_info.callbacks.udata)) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") + if (image_info.callbacks.image_memcpy) { + if (image_info.buffer != image_info.callbacks.image_memcpy(image_info.buffer, buf_ptr, buf_len, + H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, + image_info.callbacks.udata)) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") } /* end if */ - else + else H5MM_memcpy(image_info.buffer, buf_ptr, buf_len); } /* end if */ else @@ -2671,14 +2695,13 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) image_info.size = buf_len; /* Set values */ - if(H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if (H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_file_image() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_image * @@ -2711,19 +2734,19 @@ done: herr_t H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr) { - H5P_genplist_t *fapl; /* Property list pointer */ - H5FD_file_image_info_t image_info; /* File image info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * fapl; /* Property list pointer */ + H5FD_file_image_info_t image_info; /* File image info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i**x*z", fapl_id, buf_ptr_ptr, buf_len_ptr); /* Get the plist structure */ - if(NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info") /* verify file image field consistency */ @@ -2731,32 +2754,32 @@ H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr) ((image_info.buffer == NULL) && (image_info.size == 0))); /* Set output size */ - if(buf_len_ptr != NULL) + if (buf_len_ptr != NULL) *buf_len_ptr = image_info.size; /* Duplicate the image if desired, using callbacks if available */ - if(buf_ptr_ptr != NULL) { - void * copy_ptr = NULL; /* Copy of memory image */ + if (buf_ptr_ptr != NULL) { + void *copy_ptr = NULL; /* Copy of memory image */ - if(image_info.buffer != NULL) { + if (image_info.buffer != NULL) { /* Allocate memory */ - if(image_info.callbacks.image_malloc) { - if(NULL == (copy_ptr = image_info.callbacks.image_malloc(image_info.size, - H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, image_info.callbacks.udata))) + if (image_info.callbacks.image_malloc) { + if (NULL == + (copy_ptr = image_info.callbacks.image_malloc( + image_info.size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, image_info.callbacks.udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "image malloc callback failed") } /* end if */ - else - if(NULL == (copy_ptr = H5MM_malloc(image_info.size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate copy") + else if (NULL == (copy_ptr = H5MM_malloc(image_info.size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate copy") /* Copy data */ - if(image_info.callbacks.image_memcpy) { - if(copy_ptr != image_info.callbacks.image_memcpy(copy_ptr, image_info.buffer, - image_info.size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, - image_info.callbacks.udata)) + if (image_info.callbacks.image_memcpy) { + if (copy_ptr != image_info.callbacks.image_memcpy( + copy_ptr, image_info.buffer, image_info.size, + H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, image_info.callbacks.udata)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") } /* end if */ - else + else H5MM_memcpy(copy_ptr, image_info.buffer, image_info.size); } /* end if */ @@ -2767,7 +2790,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_file_image */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_image_callbacks * @@ -2787,64 +2809,64 @@ done: herr_t H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr) { - H5P_genplist_t *fapl; /* Property list pointer */ - H5FD_file_image_info_t info; /* File image info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * fapl; /* Property list pointer */ + H5FD_file_image_info_t info; /* File image info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", fapl_id, callbacks_ptr); /* Get the plist structure */ - if(NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old info */ - if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image info") /* verify file image field consistency */ - HDassert(((info.buffer != NULL) && (info.size > 0)) || - ((info.buffer == NULL) && (info.size == 0))); + HDassert(((info.buffer != NULL) && (info.size > 0)) || ((info.buffer == NULL) && (info.size == 0))); /* Make sure a file image hasn't already been set */ - if(info.buffer != NULL || info.size > 0) - HGOTO_ERROR(H5E_PLIST, H5E_SETDISALLOWED, FAIL, "setting callbacks when an image is already set is forbidden. It could cause memory leaks.") + if (info.buffer != NULL || info.size > 0) + HGOTO_ERROR( + H5E_PLIST, H5E_SETDISALLOWED, FAIL, + "setting callbacks when an image is already set is forbidden. It could cause memory leaks.") /* verify that callbacks_ptr is not NULL */ - if(NULL == callbacks_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr") + if (NULL == callbacks_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr") /* Make sure udata callbacks are going to be set if udata is going to be set */ - if(callbacks_ptr->udata) - if(callbacks_ptr->udata_copy == NULL || callbacks_ptr->udata_free == NULL) + if (callbacks_ptr->udata) + if (callbacks_ptr->udata_copy == NULL || callbacks_ptr->udata_free == NULL) HGOTO_ERROR(H5E_PLIST, H5E_SETDISALLOWED, FAIL, "udata callbacks must be set if udata is set") /* Release old udata if it exists */ - if(info.callbacks.udata != NULL) { + if (info.callbacks.udata != NULL) { HDassert(info.callbacks.udata_free); - if(info.callbacks.udata_free(info.callbacks.udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed") + if (info.callbacks.udata_free(info.callbacks.udata) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed") } /* end if */ /* Update struct */ info.callbacks = *callbacks_ptr; - if(callbacks_ptr->udata) { + if (callbacks_ptr->udata) { HDassert(callbacks_ptr->udata_copy); HDassert(callbacks_ptr->udata_free); - if((info.callbacks.udata = callbacks_ptr->udata_copy(callbacks_ptr->udata)) == NULL) + if ((info.callbacks.udata = callbacks_ptr->udata_copy(callbacks_ptr->udata)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy the suppplied udata") } /* end if */ /* Set values */ - if(H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if (H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_file_image_callbacks() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_image_callbacks * @@ -2863,44 +2885,42 @@ done: herr_t H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr) { - H5P_genplist_t *fapl; /* Property list pointer */ - H5FD_file_image_info_t info; /* File image info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * fapl; /* Property list pointer */ + H5FD_file_image_info_t info; /* File image info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", fapl_id, callbacks_ptr); /* Get the plist structure */ - if(NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old info */ - if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info") /* verify file image field consistency */ - HDassert(((info.buffer != NULL) && (info.size > 0)) || - ((info.buffer == NULL) && (info.size == 0))); + HDassert(((info.buffer != NULL) && (info.size > 0)) || ((info.buffer == NULL) && (info.size == 0))); /* verify that callbacks_ptr is not NULL */ - if(NULL == callbacks_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr") + if (NULL == callbacks_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr") /* Transfer values to parameters */ *callbacks_ptr = info.callbacks; /* Copy udata if it exists */ - if(info.callbacks.udata != NULL) { + if (info.callbacks.udata != NULL) { HDassert(info.callbacks.udata_copy); - if((callbacks_ptr->udata = info.callbacks.udata_copy(info.callbacks.udata)) == 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy udata") + if ((callbacks_ptr->udata = info.callbacks.udata_copy(info.callbacks.udata)) == 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy udata") } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_file_image_callbacks() */ - /*------------------------------------------------------------------------- * Function: H5P__file_image_info_copy * @@ -2923,12 +2943,12 @@ done: static herr_t H5P__file_image_info_copy(void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(value) { - H5FD_file_image_info_t *info; /* Image info struct */ + if (value) { + H5FD_file_image_info_t *info; /* Image info struct */ info = (H5FD_file_image_info_t *)value; @@ -2936,49 +2956,49 @@ H5P__file_image_info_copy(void *value) HDassert(((info->buffer != NULL) && (info->size > 0)) || ((info->buffer == NULL) && (info->size == 0))); - if(info->buffer && info->size > 0) { - void *old_buffer; /* Pointer to old image buffer */ + if (info->buffer && info->size > 0) { + void *old_buffer; /* Pointer to old image buffer */ /* Store the old buffer */ old_buffer = info->buffer; /* Allocate new buffer */ - if(info->callbacks.image_malloc) { - if(NULL == (info->buffer = info->callbacks.image_malloc(info->size, - H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata))) + if (info->callbacks.image_malloc) { + if (NULL == (info->buffer = info->callbacks.image_malloc( + info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "image malloc callback failed") } /* end if */ else { - if(NULL == (info->buffer = H5MM_malloc(info->size))) + if (NULL == (info->buffer = H5MM_malloc(info->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory block") } /* end else */ /* Copy data to new buffer */ - if(info->callbacks.image_memcpy) { - if(info->buffer != info->callbacks.image_memcpy(info->buffer, old_buffer, - info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") + if (info->callbacks.image_memcpy) { + if (info->buffer != info->callbacks.image_memcpy(info->buffer, old_buffer, info->size, + H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, + info->callbacks.udata)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") } /* end if */ - else + else H5MM_memcpy(info->buffer, old_buffer, info->size); } /* end if */ /* Copy udata if it exists */ - if(info->callbacks.udata) { + if (info->callbacks.udata) { void *old_udata = info->callbacks.udata; - if(NULL == info->callbacks.udata_copy) + if (NULL == info->callbacks.udata_copy) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_copy not defined") info->callbacks.udata = info->callbacks.udata_copy(old_udata); } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__file_image_info_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__file_image_info_free * @@ -2997,12 +3017,12 @@ done: static herr_t H5P__file_image_info_free(void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(value) { - H5FD_file_image_info_t *info; /* Image info struct */ + if (value) { + H5FD_file_image_info_t *info; /* Image info struct */ info = (H5FD_file_image_info_t *)value; @@ -3011,29 +3031,29 @@ H5P__file_image_info_free(void *value) ((info->buffer == NULL) && (info->size == 0))); /* Free buffer */ - if(info->buffer != NULL && info->size > 0) { - if(info->callbacks.image_free) { - if((*info->callbacks.image_free)(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, info->callbacks.udata) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "image_free callback failed") + if (info->buffer != NULL && info->size > 0) { + if (info->callbacks.image_free) { + if ((*info->callbacks.image_free)(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, + info->callbacks.udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else H5MM_xfree(info->buffer); } /* end if */ /* Free udata if it exists */ - if(info->callbacks.udata) { - if(NULL == info->callbacks.udata_free) + if (info->callbacks.udata) { + if (NULL == info->callbacks.udata_free) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_free not defined") - if((*info->callbacks.udata_free)(info->callbacks.udata) < 0) + if ((*info->callbacks.udata_free)(info->callbacks.udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "udata_free callback failed") } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__file_image_info_free() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_image_config_cmp * @@ -3050,33 +3070,44 @@ done: static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size) { - const H5AC_cache_image_config_t *config1 = (const H5AC_cache_image_config_t *)_config1; /* Create local aliases for values */ - const H5AC_cache_image_config_t *config2 = (const H5AC_cache_image_config_t *)_config2; /* Create local aliases for values */ - int ret_value = 0; /* Return value */ + const H5AC_cache_image_config_t *config1 = + (const H5AC_cache_image_config_t *)_config1; /* Create local aliases for values */ + const H5AC_cache_image_config_t *config2 = + (const H5AC_cache_image_config_t *)_config2; /* Create local aliases for values */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check for a property being set */ - if(config1 == NULL && config2 != NULL) HGOTO_DONE(-1); - if(config1 != NULL && config2 == NULL) HGOTO_DONE(1); + if (config1 == NULL && config2 != NULL) + HGOTO_DONE(-1); + if (config1 != NULL && config2 == NULL) + HGOTO_DONE(1); - if(config1->version < config2->version) HGOTO_DONE(-1); - if(config1->version > config2->version) HGOTO_DONE(1); + if (config1->version < config2->version) + HGOTO_DONE(-1); + if (config1->version > config2->version) + HGOTO_DONE(1); - if(config1->generate_image < config2->generate_image) HGOTO_DONE(-1); - if(config1->generate_image > config2->generate_image) HGOTO_DONE(1); + if (config1->generate_image < config2->generate_image) + HGOTO_DONE(-1); + if (config1->generate_image > config2->generate_image) + HGOTO_DONE(1); - if(config1->save_resize_status < config2->save_resize_status) HGOTO_DONE(-1); - if(config1->save_resize_status > config2->save_resize_status) HGOTO_DONE(1); + if (config1->save_resize_status < config2->save_resize_status) + HGOTO_DONE(-1); + if (config1->save_resize_status > config2->save_resize_status) + HGOTO_DONE(1); - if(config1->entry_ageout < config2->entry_ageout) HGOTO_DONE(-1); - if(config1->entry_ageout > config2->entry_ageout) HGOTO_DONE(1); + if (config1->entry_ageout < config2->entry_ageout) + HGOTO_DONE(-1); + if (config1->entry_ageout > config2->entry_ageout) + HGOTO_DONE(1); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_cache_image_config_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_image_config_enc * @@ -3095,7 +3126,8 @@ done: static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size) { - const H5AC_cache_image_config_t *config = (const H5AC_cache_image_config_t *)value; /* Create local aliases for value */ + const H5AC_cache_image_config_t *config = + (const H5AC_cache_image_config_t *)value; /* Create local aliases for value */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3103,7 +3135,7 @@ H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size) /* Sanity check */ HDassert(value); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode type sizes (as a safety check) */ *(*pp)++ = (uint8_t)sizeof(unsigned); @@ -3122,7 +3154,6 @@ H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_cache_image_config_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_image_config_dec * @@ -3142,9 +3173,9 @@ static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value) { H5AC_cache_image_config_t *config = (H5AC_cache_image_config_t *)_value; - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t ** pp = (const uint8_t **)_pp; + unsigned enc_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3159,7 +3190,7 @@ H5P__facc_cache_image_config_dec(const void **_pp, void *_value) /* Decode type sizes */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") INT32DECODE(*pp, config->version); @@ -3174,7 +3205,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_cache_image_config_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_set * @@ -3190,9 +3220,9 @@ done: */ static herr_t H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3200,14 +3230,13 @@ H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U HDassert(value); /* Make copy of file image info */ - if(H5P__file_image_info_copy(value) < 0) + if (H5P__file_image_info_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_set() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_get * @@ -3223,9 +3252,9 @@ done: */ static herr_t H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3233,14 +3262,13 @@ H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U HDassert(value); /* Make copy of file image info */ - if(H5P__file_image_info_copy(value) < 0) + if (H5P__file_image_info_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_get() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_del * @@ -3257,21 +3285,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the file image info */ - if(H5P__file_image_info_free(value) < 0) + if (H5P__file_image_info_free(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_del() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_copy * @@ -3289,19 +3317,18 @@ done: static herr_t H5P__facc_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make copy of file image info */ - if(H5P__file_image_info_copy(value) < 0) + if (H5P__file_image_info_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_cmp * @@ -3318,12 +3345,12 @@ done: *------------------------------------------------------------------------- */ static int -H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, - size_t H5_ATTR_UNUSED size) +H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) { - const H5FD_file_image_info_t *info1 = (const H5FD_file_image_info_t *)_info1, /* Create local aliases for values */ - *info2 = (const H5FD_file_image_info_t *)_info2; - herr_t ret_value = 0; /* Return value */ + const H5FD_file_image_info_t *info1 = (const H5FD_file_image_info_t *) + _info1, /* Create local aliases for values */ + *info2 = (const H5FD_file_image_info_t *)_info2; + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -3333,34 +3360,45 @@ H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, HDassert(size == sizeof(H5FD_file_image_info_t)); /* Check for different buffer sizes */ - if(info1->size < info2->size) HGOTO_DONE(-1) - if(info1->size > info2->size) HGOTO_DONE(1) + if (info1->size < info2->size) + HGOTO_DONE(-1) + if (info1->size > info2->size) + HGOTO_DONE(1) /* Check for different callbacks */ /* (Order in memory is fairly meaningless, so just check for equality) */ - if(info1->callbacks.image_malloc != info2->callbacks.image_malloc) HGOTO_DONE(1) - if(info1->callbacks.image_memcpy != info2->callbacks.image_memcpy) HGOTO_DONE(-1) - if(info1->callbacks.image_realloc != info2->callbacks.image_realloc) HGOTO_DONE(1) - if(info1->callbacks.image_free != info2->callbacks.image_free) HGOTO_DONE(-1) - if(info1->callbacks.udata_copy != info2->callbacks.udata_copy) HGOTO_DONE(1) - if(info1->callbacks.udata_free != info2->callbacks.udata_free) HGOTO_DONE(-1) + if (info1->callbacks.image_malloc != info2->callbacks.image_malloc) + HGOTO_DONE(1) + if (info1->callbacks.image_memcpy != info2->callbacks.image_memcpy) + HGOTO_DONE(-1) + if (info1->callbacks.image_realloc != info2->callbacks.image_realloc) + HGOTO_DONE(1) + if (info1->callbacks.image_free != info2->callbacks.image_free) + HGOTO_DONE(-1) + if (info1->callbacks.udata_copy != info2->callbacks.udata_copy) + HGOTO_DONE(1) + if (info1->callbacks.udata_free != info2->callbacks.udata_free) + HGOTO_DONE(-1) /* Check for different udata */ /* (Don't know how big it is, so can't check contents) */ - if(info1->callbacks.udata < info2->callbacks.udata) HGOTO_DONE(-1) - if(info1->callbacks.udata > info2->callbacks.udata) HGOTO_DONE(1) + if (info1->callbacks.udata < info2->callbacks.udata) + HGOTO_DONE(-1) + if (info1->callbacks.udata > info2->callbacks.udata) + HGOTO_DONE(1) /* Check buffer contents (instead of buffer pointers) */ - if(info1->buffer != NULL && info2->buffer == NULL) HGOTO_DONE(-1) - if(info1->buffer == NULL && info2->buffer != NULL) HGOTO_DONE(1) - if(info1->buffer != NULL && info2->buffer != NULL) + if (info1->buffer != NULL && info2->buffer == NULL) + HGOTO_DONE(-1) + if (info1->buffer == NULL && info2->buffer != NULL) + HGOTO_DONE(1) + if (info1->buffer != NULL && info2->buffer != NULL) ret_value = HDmemcmp(info1->buffer, info2->buffer, size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_close * @@ -3378,19 +3416,18 @@ done: static herr_t H5P__facc_file_image_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the file image info */ - if(H5P__file_image_info_free(value) < 0) + if (H5P__file_image_info_free(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_close() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_config_cmp * @@ -3407,102 +3444,159 @@ done: static int H5P__facc_cache_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size) { - const H5AC_cache_config_t *config1 = (const H5AC_cache_config_t *)_config1; /* Create local aliases for values */ - const H5AC_cache_config_t *config2 = (const H5AC_cache_config_t *)_config2; /* Create local aliases for values */ - int ret_value = 0; /* Return value */ + const H5AC_cache_config_t *config1 = + (const H5AC_cache_config_t *)_config1; /* Create local aliases for values */ + const H5AC_cache_config_t *config2 = + (const H5AC_cache_config_t *)_config2; /* Create local aliases for values */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check for a property being set */ - if(config1 == NULL && config2 != NULL) HGOTO_DONE(-1); - if(config1 != NULL && config2 == NULL) HGOTO_DONE(1); + if (config1 == NULL && config2 != NULL) + HGOTO_DONE(-1); + if (config1 != NULL && config2 == NULL) + HGOTO_DONE(1); - if(config1->version < config2->version) HGOTO_DONE(-1); - if(config1->version > config2->version) HGOTO_DONE(1); + if (config1->version < config2->version) + HGOTO_DONE(-1); + if (config1->version > config2->version) + HGOTO_DONE(1); - if(config1->rpt_fcn_enabled < config2->rpt_fcn_enabled) HGOTO_DONE(-1); - if(config1->rpt_fcn_enabled > config2->rpt_fcn_enabled) HGOTO_DONE(1); + if (config1->rpt_fcn_enabled < config2->rpt_fcn_enabled) + HGOTO_DONE(-1); + if (config1->rpt_fcn_enabled > config2->rpt_fcn_enabled) + HGOTO_DONE(1); - if(config1->evictions_enabled < config2->evictions_enabled) HGOTO_DONE(-1); - if(config1->evictions_enabled > config2->evictions_enabled) HGOTO_DONE(1); + if (config1->evictions_enabled < config2->evictions_enabled) + HGOTO_DONE(-1); + if (config1->evictions_enabled > config2->evictions_enabled) + HGOTO_DONE(1); - if(config1->set_initial_size < config2->set_initial_size) HGOTO_DONE(-1); - if(config1->set_initial_size > config2->set_initial_size) HGOTO_DONE(1); + if (config1->set_initial_size < config2->set_initial_size) + HGOTO_DONE(-1); + if (config1->set_initial_size > config2->set_initial_size) + HGOTO_DONE(1); - if(config1->initial_size < config2->initial_size) HGOTO_DONE(-1); - if(config1->initial_size > config2->initial_size) HGOTO_DONE(1); + if (config1->initial_size < config2->initial_size) + HGOTO_DONE(-1); + if (config1->initial_size > config2->initial_size) + HGOTO_DONE(1); - if(config1->min_clean_fraction < config2->min_clean_fraction) HGOTO_DONE(-1); - if(config1->min_clean_fraction > config2->min_clean_fraction) HGOTO_DONE(1); + if (config1->min_clean_fraction < config2->min_clean_fraction) + HGOTO_DONE(-1); + if (config1->min_clean_fraction > config2->min_clean_fraction) + HGOTO_DONE(1); - if(config1->max_size < config2->max_size) HGOTO_DONE(-1); - if(config1->max_size > config2->max_size) HGOTO_DONE(1); + if (config1->max_size < config2->max_size) + HGOTO_DONE(-1); + if (config1->max_size > config2->max_size) + HGOTO_DONE(1); - if(config1->min_size < config2->min_size) HGOTO_DONE(-1); - if(config1->min_size > config2->min_size) HGOTO_DONE(1); + if (config1->min_size < config2->min_size) + HGOTO_DONE(-1); + if (config1->min_size > config2->min_size) + HGOTO_DONE(1); - if(config1->epoch_length < config2->epoch_length) HGOTO_DONE(-1); - if(config1->epoch_length > config2->epoch_length) HGOTO_DONE(1); + if (config1->epoch_length < config2->epoch_length) + HGOTO_DONE(-1); + if (config1->epoch_length > config2->epoch_length) + HGOTO_DONE(1); - if(config1->incr_mode < config2->incr_mode) HGOTO_DONE(-1); - if(config1->incr_mode > config2->incr_mode) HGOTO_DONE(1); + if (config1->incr_mode < config2->incr_mode) + HGOTO_DONE(-1); + if (config1->incr_mode > config2->incr_mode) + HGOTO_DONE(1); - if(config1->lower_hr_threshold < config2->lower_hr_threshold) HGOTO_DONE(-1); - if(config1->lower_hr_threshold > config2->lower_hr_threshold) HGOTO_DONE(1); + if (config1->lower_hr_threshold < config2->lower_hr_threshold) + HGOTO_DONE(-1); + if (config1->lower_hr_threshold > config2->lower_hr_threshold) + HGOTO_DONE(1); - if(config1->increment < config2->increment) HGOTO_DONE(-1); - if(config1->increment > config2->increment) HGOTO_DONE(1); + if (config1->increment < config2->increment) + HGOTO_DONE(-1); + if (config1->increment > config2->increment) + HGOTO_DONE(1); - if(config1->apply_max_increment < config2->apply_max_increment) HGOTO_DONE(-1); - if(config1->apply_max_increment > config2->apply_max_increment) HGOTO_DONE(1); + if (config1->apply_max_increment < config2->apply_max_increment) + HGOTO_DONE(-1); + if (config1->apply_max_increment > config2->apply_max_increment) + HGOTO_DONE(1); - if(config1->max_increment < config2->max_increment) HGOTO_DONE(-1); - if(config1->max_increment > config2->max_increment) HGOTO_DONE(1); + if (config1->max_increment < config2->max_increment) + HGOTO_DONE(-1); + if (config1->max_increment > config2->max_increment) + HGOTO_DONE(1); - if(config1->flash_incr_mode < config2->flash_incr_mode) HGOTO_DONE(-1); - if(config1->flash_incr_mode > config2->flash_incr_mode) HGOTO_DONE(1); + if (config1->flash_incr_mode < config2->flash_incr_mode) + HGOTO_DONE(-1); + if (config1->flash_incr_mode > config2->flash_incr_mode) + HGOTO_DONE(1); - if(config1->flash_multiple < config2->flash_multiple) HGOTO_DONE(-1); - if(config1->flash_multiple > config2->flash_multiple) HGOTO_DONE(1); + if (config1->flash_multiple < config2->flash_multiple) + HGOTO_DONE(-1); + if (config1->flash_multiple > config2->flash_multiple) + HGOTO_DONE(1); - if(config1->flash_threshold < config2->flash_threshold) HGOTO_DONE(-1); - if(config1->flash_threshold > config2->flash_threshold) HGOTO_DONE(1); + if (config1->flash_threshold < config2->flash_threshold) + HGOTO_DONE(-1); + if (config1->flash_threshold > config2->flash_threshold) + HGOTO_DONE(1); - if(config1->decr_mode < config2->decr_mode) HGOTO_DONE(-1); - if(config1->decr_mode > config2->decr_mode) HGOTO_DONE(1); + if (config1->decr_mode < config2->decr_mode) + HGOTO_DONE(-1); + if (config1->decr_mode > config2->decr_mode) + HGOTO_DONE(1); - if(config1->upper_hr_threshold < config2->upper_hr_threshold) HGOTO_DONE(-1); - if(config1->upper_hr_threshold > config2->upper_hr_threshold) HGOTO_DONE(1); + if (config1->upper_hr_threshold < config2->upper_hr_threshold) + HGOTO_DONE(-1); + if (config1->upper_hr_threshold > config2->upper_hr_threshold) + HGOTO_DONE(1); - if(config1->decrement < config2->decrement) HGOTO_DONE(-1); - if(config1->decrement > config2->decrement) HGOTO_DONE(1); + if (config1->decrement < config2->decrement) + HGOTO_DONE(-1); + if (config1->decrement > config2->decrement) + HGOTO_DONE(1); - if(config1->apply_max_decrement < config2->apply_max_decrement) HGOTO_DONE(-1); - if(config1->apply_max_decrement > config2->apply_max_decrement) HGOTO_DONE(1); + if (config1->apply_max_decrement < config2->apply_max_decrement) + HGOTO_DONE(-1); + if (config1->apply_max_decrement > config2->apply_max_decrement) + HGOTO_DONE(1); - if(config1->max_decrement < config2->max_decrement) HGOTO_DONE(-1); - if(config1->max_decrement > config2->max_decrement) HGOTO_DONE(1); + if (config1->max_decrement < config2->max_decrement) + HGOTO_DONE(-1); + if (config1->max_decrement > config2->max_decrement) + HGOTO_DONE(1); - if(config1->epochs_before_eviction < config2->epochs_before_eviction) HGOTO_DONE(-1); - if(config1->epochs_before_eviction > config2->epochs_before_eviction) HGOTO_DONE(1); + if (config1->epochs_before_eviction < config2->epochs_before_eviction) + HGOTO_DONE(-1); + if (config1->epochs_before_eviction > config2->epochs_before_eviction) + HGOTO_DONE(1); - if(config1->apply_empty_reserve < config2->apply_empty_reserve) HGOTO_DONE(-1); - if(config1->apply_empty_reserve > config2->apply_empty_reserve) HGOTO_DONE(1); + if (config1->apply_empty_reserve < config2->apply_empty_reserve) + HGOTO_DONE(-1); + if (config1->apply_empty_reserve > config2->apply_empty_reserve) + HGOTO_DONE(1); - if(config1->empty_reserve < config2->empty_reserve) HGOTO_DONE(-1); - if(config1->empty_reserve > config2->empty_reserve) HGOTO_DONE(1); + if (config1->empty_reserve < config2->empty_reserve) + HGOTO_DONE(-1); + if (config1->empty_reserve > config2->empty_reserve) + HGOTO_DONE(1); - if(config1->dirty_bytes_threshold < config2->dirty_bytes_threshold) HGOTO_DONE(-1); - if(config1->dirty_bytes_threshold > config2->dirty_bytes_threshold) HGOTO_DONE(1); + if (config1->dirty_bytes_threshold < config2->dirty_bytes_threshold) + HGOTO_DONE(-1); + if (config1->dirty_bytes_threshold > config2->dirty_bytes_threshold) + HGOTO_DONE(1); - if(config1->metadata_write_strategy < config2->metadata_write_strategy) HGOTO_DONE(-1); - if(config1->metadata_write_strategy > config2->metadata_write_strategy) HGOTO_DONE(1); + if (config1->metadata_write_strategy < config2->metadata_write_strategy) + HGOTO_DONE(-1); + if (config1->metadata_write_strategy > config2->metadata_write_strategy) + HGOTO_DONE(1); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_cache_config_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_config_enc * @@ -3521,10 +3615,11 @@ done: static herr_t H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) { - const H5AC_cache_config_t *config = (const H5AC_cache_config_t *)value; /* Create local aliases for values */ + const H5AC_cache_config_t *config = + (const H5AC_cache_config_t *)value; /* Create local aliases for values */ uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - uint64_t enc_value; /* Property to encode */ + unsigned enc_size; /* Size of encoded property */ + uint64_t enc_value; /* Property to encode */ FUNC_ENTER_STATIC_NOERR @@ -3532,7 +3627,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) HDassert(value); HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode type sizes (as a safety check) */ *(*pp)++ = (uint8_t)sizeof(unsigned); *(*pp)++ = (uint8_t)sizeof(double); @@ -3546,7 +3641,8 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, config->close_trace_file); - H5MM_memcpy(*pp, (const uint8_t *)(config->trace_file_name), (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1)); + H5MM_memcpy(*pp, (const uint8_t *)(config->trace_file_name), + (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1)); *pp += H5AC__MAX_TRACE_FILE_NAME_LEN + 1; H5_ENCODE_UNSIGNED(*pp, config->evictions_enabled); @@ -3554,7 +3650,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, config->set_initial_size); enc_value = (uint64_t)config->initial_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -3562,13 +3658,13 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_DOUBLE(*pp, config->min_clean_fraction); enc_value = (uint64_t)config->max_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); enc_value = (uint64_t)config->min_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -3586,7 +3682,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, config->apply_max_increment); enc_value = (uint64_t)config->max_increment; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -3608,7 +3704,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, config->apply_max_decrement); enc_value = (uint64_t)config->max_decrement; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -3640,14 +3736,12 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) *size += 1 + H5VM_limit_enc_size(enc_value); /* Compute encoded size of fixed-size values */ - *size += (5 + (sizeof(unsigned) * 8) + (sizeof(double) * 8) + - (sizeof(int32_t) * 4) + sizeof(int64_t) + - H5AC__MAX_TRACE_FILE_NAME_LEN + 1); + *size += (5 + (sizeof(unsigned) * 8) + (sizeof(double) * 8) + (sizeof(int32_t) * 4) + sizeof(int64_t) + + H5AC__MAX_TRACE_FILE_NAME_LEN + 1); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_cache_config_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_config_dec * @@ -3667,10 +3761,10 @@ static herr_t H5P__facc_cache_config_dec(const void **_pp, void *_value) { H5AC_cache_config_t *config = (H5AC_cache_config_t *)_value; - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; - uint64_t enc_value; - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t ** pp = (const uint8_t **)_pp; + unsigned enc_size; + uint64_t enc_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3685,10 +3779,10 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value) /* Decode type sizes */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") enc_size = *(*pp)++; - if(enc_size != sizeof(double)) + if (enc_size != sizeof(double)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded") /* int */ @@ -3731,7 +3825,7 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value) config->epoch_length = (long int)temp; } /* enum */ - config->incr_mode = (enum H5C_cache_incr_mode)*(*pp)++; + config->incr_mode = (enum H5C_cache_incr_mode) * (*pp)++; H5_DECODE_DOUBLE(*pp, config->lower_hr_threshold); @@ -3745,14 +3839,14 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value) config->max_increment = (size_t)enc_value; /* enum */ - config->flash_incr_mode = (enum H5C_cache_flash_incr_mode)*(*pp)++; + config->flash_incr_mode = (enum H5C_cache_flash_incr_mode) * (*pp)++; H5_DECODE_DOUBLE(*pp, config->flash_multiple); H5_DECODE_DOUBLE(*pp, config->flash_threshold); /* enum */ - config->decr_mode = (enum H5C_cache_decr_mode)*(*pp)++; + config->decr_mode = (enum H5C_cache_decr_mode) * (*pp)++; H5_DECODE_DOUBLE(*pp, config->upper_hr_threshold); @@ -3782,7 +3876,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_cache_config_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_fclose_degree_enc * @@ -3801,7 +3894,8 @@ done: static herr_t H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size) { - const H5F_close_degree_t *fclose_degree = (const H5F_close_degree_t *)value; /* Create local alias for values */ + const H5F_close_degree_t *fclose_degree = + (const H5F_close_degree_t *)value; /* Create local alias for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3810,7 +3904,7 @@ H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size) HDassert(fclose_degree); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode file close degree */ *(*pp)++ = (uint8_t)*fclose_degree; @@ -3820,7 +3914,6 @@ H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_fclose_degree_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_fclose_degree_dec * @@ -3839,8 +3932,8 @@ H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__facc_fclose_degree_dec(const void **_pp, void *_value) { - H5F_close_degree_t *fclose_degree = (H5F_close_degree_t *)_value; /* File close degree */ - const uint8_t **pp = (const uint8_t **)_pp; + H5F_close_degree_t *fclose_degree = (H5F_close_degree_t *)_value; /* File close degree */ + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3850,12 +3943,11 @@ H5P__facc_fclose_degree_dec(const void **_pp, void *_value) HDassert(fclose_degree); /* Decode file close degree */ - *fclose_degree = (H5F_close_degree_t)*(*pp)++; + *fclose_degree = (H5F_close_degree_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_fclose_degree_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_multi_type_enc * @@ -3875,7 +3967,7 @@ static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size) { const H5FD_mem_t *type = (const H5FD_mem_t *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3883,7 +3975,7 @@ H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size) HDassert(type); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode file close degree */ *(*pp)++ = (uint8_t)*type; @@ -3893,7 +3985,6 @@ H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_multi_type_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_multi_type_dec * @@ -3912,8 +4003,8 @@ H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__facc_multi_type_dec(const void **_pp, void *_value) { - H5FD_mem_t *type = (H5FD_mem_t *)_value; /* File close degree */ - const uint8_t **pp = (const uint8_t **)_pp; + H5FD_mem_t * type = (H5FD_mem_t *)_value; /* File close degree */ + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3923,12 +4014,11 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value) HDassert(type); /* Decode multi VFD memory type */ - *type = (H5FD_mem_t)*(*pp)++; + *type = (H5FD_mem_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_multi_type_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_libver_type_enc * @@ -3947,7 +4037,7 @@ static herr_t H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) { const H5F_libver_t *type = (const H5F_libver_t *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3956,7 +4046,7 @@ H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) HDassert(size); /* Encode */ - if(NULL != *pp) + if (NULL != *pp) *(*pp)++ = (uint8_t)*type; /* Size */ @@ -3965,7 +4055,6 @@ H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_libver_type_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_libver_type_dec * @@ -3983,8 +4072,8 @@ H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__facc_libver_type_dec(const void **_pp, void *_value) { - H5F_libver_t *type = (H5F_libver_t *)_value; - const uint8_t **pp = (const uint8_t **)_pp; + H5F_libver_t * type = (H5F_libver_t *)_value; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3994,12 +4083,11 @@ H5P__facc_libver_type_dec(const void **_pp, void *_value) HDassert(type); /* Decode */ - *type = (H5F_libver_t)*(*pp)++; + *type = (H5F_libver_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_libver_type_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vfd_swmr_config_enc * @@ -4016,7 +4104,8 @@ H5P__facc_libver_type_dec(const void **_pp, void *_value) static herr_t H5P__facc_vfd_swmr_config_enc(const void *value, void **_pp, size_t *size) { - const H5F_vfd_swmr_config_t *config = (const H5F_vfd_swmr_config_t *)value; /* Create local aliases for values */ + const H5F_vfd_swmr_config_t *config = + (const H5F_vfd_swmr_config_t *)value; /* Create local aliases for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -4025,7 +4114,7 @@ H5P__facc_vfd_swmr_config_enc(const void *value, void **_pp, size_t *size) HDassert(value); HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); - if(NULL != *pp) { + if (NULL != *pp) { /* int */ INT32ENCODE(*pp, (int32_t)config->version); @@ -4037,20 +4126,18 @@ H5P__facc_vfd_swmr_config_enc(const void *value, void **_pp, size_t *size) INT32ENCODE(*pp, (int32_t)config->pb_expansion_threshold); HDmemcpy(*pp, (const uint8_t *)(config->md_file_path), (size_t)(H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1)); *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1; - HDmemcpy(*pp, (const uint8_t *)(config->log_file_path), (size_t)(H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1)); + HDmemcpy(*pp, (const uint8_t *)(config->log_file_path), + (size_t)(H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1)); *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1; } /* end if */ /* Compute encoded size */ - *size += ( (5 * sizeof(int32_t)) + - (2 * sizeof(unsigned)) + - (2 * (H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1)) ); + *size += ((5 * sizeof(int32_t)) + (2 * sizeof(unsigned)) + (2 * (H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1))); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_vfd_swmr_config_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vfd_swmr_config_dec * @@ -4068,7 +4155,7 @@ static herr_t H5P__facc_vfd_swmr_config_dec(const void **_pp, void *_value) { H5F_vfd_swmr_config_t *config = (H5F_vfd_swmr_config_t *)_value; - const uint8_t **pp = (const uint8_t **)_pp; + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -4102,7 +4189,6 @@ H5P__facc_vfd_swmr_config_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_vfd_swmr_config_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_metadata_read_attempts * @@ -4123,29 +4209,29 @@ H5P__facc_vfd_swmr_config_dec(const void **_pp, void *_value) herr_t H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, attempts); /* Cannot set the # of attempts to 0 */ - if(attempts == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of metadatata read attempts must be greater than 0"); + if (attempts == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "number of metadatata read attempts must be greater than 0"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &attempts) < 0) + if (H5P_set(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &attempts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set # of metadata read attempts") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_metadata_read_attempts() */ - /*------------------------------------------------------------------------- * Function: H5Pget_metadata_read_attempts * @@ -4158,35 +4244,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts/*out*/) +H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, attempts); /* Get values */ - if(attempts) { - H5P_genplist_t *plist; /* Property list pointer */ + if (attempts) { + H5P_genplist_t *plist; /* Property list pointer */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Get the # of read attempts set */ - if(H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, attempts) < 0) + /* Get the # of read attempts set */ + if (H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, attempts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get the number of metadata read attempts") - /* If not set, return the default value */ - if(*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */ - *attempts = H5F_METADATA_READ_ATTEMPTS; + /* If not set, return the default value */ + if (*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */ + *attempts = H5F_METADATA_READ_ATTEMPTS; } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_metadata_read_attempts() */ - /*------------------------------------------------------------------------- * Function: H5Pset_obj_flush_cb * @@ -4202,35 +4287,34 @@ done: herr_t H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata) { - H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t * plist; /* Property list pointer */ H5F_object_flush_t flush_info; - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", plist_id, func, udata); /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ - if(!func && udata) + if (!func && udata) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - flush_info.func = func; + flush_info.func = func; flush_info.udata = udata; /* Set values */ - if(H5P_set(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0) + if (H5P_set(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_obj_flush_cb() */ - /*------------------------------------------------------------------------- * Function: H5Pget_obj_flush_cb * @@ -4246,32 +4330,31 @@ done: herr_t H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata) { - H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t * plist; /* Property list pointer */ H5F_object_flush_t flush_info; - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", plist_id, func, udata); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the callback function and user data */ - if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0) + if (H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object flush callback") /* Assign return value */ - if(func) - *func = flush_info.func; - if(udata) - *udata = flush_info.udata; + if (func) + *func = flush_info.func; + if (udata) + *udata = flush_info.udata; done: FUNC_LEAVE_API(ret_value) } /* H5Pget_obj_flush_cb() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mdc_log_options * @@ -4282,48 +4365,46 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, - hbool_t start_on_access) +H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, hbool_t start_on_access) { - H5P_genplist_t *plist; /* Property list pointer */ - char * tmp_location; /* Working location pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * tmp_location; /* Working location pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ib*sb", plist_id, is_enabled, location, start_on_access); /* Check arguments */ - if(H5P_DEFAULT == plist_id) + if (H5P_DEFAULT == plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(!location) + if (!location) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "location cannot be NULL") /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list") /* Get the current location string and free it */ - if(H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0) + if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current log location") H5MM_xfree(tmp_location); /* Make a copy of the passed-in location */ - if(NULL == (tmp_location = H5MM_xstrdup(location))) + if (NULL == (tmp_location = H5MM_xstrdup(location))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy passed-in log location") /* Set values */ - if(H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0) + if (H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set is_enabled flag") - if(H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0) + if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set log location") - if(H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0) + if (H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set start_on_access flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_mdc_log_options() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mdc_log_options * @@ -4334,41 +4415,41 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, - size_t *location_size, hbool_t *start_on_access) +H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, size_t *location_size, + hbool_t *start_on_access) { - H5P_genplist_t *plist; /* Property list pointer */ - char *location_ptr; /* Pointer to location string */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * location_ptr; /* Pointer to location string */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*b*s*z*b", plist_id, is_enabled, location, location_size, start_on_access); /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list") /* Get simple values */ - if(is_enabled) - if(H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, is_enabled) < 0) + if (is_enabled) + if (H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, is_enabled) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get log location") - if(start_on_access) - if(H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, start_on_access) < 0) + if (start_on_access) + if (H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, start_on_access) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get start_on_access flag") /* Get the location */ - if(location || location_size) - if(H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &location_ptr) < 0) + if (location || location_size) + if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &location_ptr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get log location") /* Copy log location to output buffer */ - if(location_ptr && location) + if (location_ptr && location) H5MM_memcpy(location, location_ptr, *location_size); /* Get location size, including terminating NULL */ - if(location_size) { - if(location_ptr) + if (location_size) { + if (location_ptr) *location_size = HDstrlen(location_ptr) + 1; else *location_size = 0; @@ -4378,7 +4459,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mdc_log_options() */ - /*------------------------------------------------------------------------- * Function: H5P_facc_mdc_log_location_enc * @@ -4394,44 +4474,43 @@ done: static herr_t H5P_facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size) { - const char *log_location = *(const char * const *)value; - uint8_t **pp = (uint8_t **)_pp; - size_t len = 0; - uint64_t enc_value; - unsigned enc_size; + const char *log_location = *(const char *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + size_t len = 0; + uint64_t enc_value; + unsigned enc_size; FUNC_ENTER_NOAPI_NOINIT_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* calculate prefix length */ - if(NULL != log_location) + if (NULL != log_location) len = HDstrlen(log_location); enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* encode the length of the prefix */ *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the prefix */ - if(NULL != log_location) { + if (NULL != log_location) { H5MM_memcpy(*(char **)pp, log_location, len); *pp += len; } /* end if */ - } /* end if */ + } /* end if */ *size += (1 + enc_size); - if(NULL != log_location) + if (NULL != log_location) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P_facc_mdc_log_location_enc() */ - /*------------------------------------------------------------------------- * Function: H5P_facc_mdc_log_location_dec * @@ -4447,12 +4526,12 @@ H5P_facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size) static herr_t H5P_facc_mdc_log_location_dec(const void **_pp, void *_value) { - char **log_location = (char **)_value; - const uint8_t **pp = (const uint8_t **)_pp; - size_t len; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; + char ** log_location = (char **)_value; + const uint8_t **pp = (const uint8_t **)_pp; + size_t len; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -4469,9 +4548,9 @@ H5P_facc_mdc_log_location_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = enc_value; - if(0 != len) { + if (0 != len) { /* Make a copy of the user's prefix string */ - if(NULL == (*log_location = (char *)H5MM_malloc(len + 1))) + if (NULL == (*log_location = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix") HDstrncpy(*log_location, *(const char **)pp, len); (*log_location)[len] = '\0'; @@ -4485,7 +4564,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_facc_mdc_log_location_dec() */ - /*------------------------------------------------------------------------- * Function: H5P_facc_mdc_log_location_del * @@ -4497,7 +4575,7 @@ done: */ static herr_t H5P_facc_mdc_log_location_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -4508,7 +4586,6 @@ H5P_facc_mdc_log_location_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P_facc_mdc_log_location_del() */ - /*------------------------------------------------------------------------- * Function: H5P_facc_mdc_log_location_copy * @@ -4530,7 +4607,6 @@ H5P_facc_mdc_log_location_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_U FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P_facc_mdc_log_location_copy() */ - /*------------------------------------------------------------------------- * Function: H5P_facc_mdc_log_location_cmp * @@ -4545,24 +4621,23 @@ H5P_facc_mdc_log_location_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_U static int H5P_facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const char *pref1 = *(const char * const *)value1; - const char *pref2 = *(const char * const *)value2; - int ret_value = 0; + const char *pref1 = *(const char *const *)value1; + const char *pref2 = *(const char *const *)value2; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(NULL == pref1 && NULL != pref2) + if (NULL == pref1 && NULL != pref2) HGOTO_DONE(1); - if(NULL != pref1 && NULL == pref2) + if (NULL != pref1 && NULL == pref2) HGOTO_DONE(-1); - if(NULL != pref1 && NULL != pref2) + if (NULL != pref1 && NULL != pref2) ret_value = HDstrcmp(pref1, pref2); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_facc_mdc_log_location_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P_facc_mdc_log_location_close * @@ -4585,7 +4660,6 @@ H5P_facc_mdc_log_location_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P_facc_mdc_log_location_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_evict_on_close * @@ -4605,36 +4679,35 @@ H5P_facc_mdc_log_location_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_ *------------------------------------------------------------------------- */ herr_t -H5Pset_evict_on_close(hid_t fapl_id, - hbool_t H5_ATTR_PARALLEL_UNUSED evict_on_close) +H5Pset_evict_on_close(hid_t fapl_id, hbool_t H5_ATTR_PARALLEL_UNUSED evict_on_close) { - H5P_genplist_t *plist; /* property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", fapl_id, evict_on_close); /* Compare the property list's class against the other class */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") #ifndef H5_HAVE_PARALLEL /* Set value */ - if(H5P_set(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) + if (H5P_set(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set evict on close property") #else - HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "evict on close is currently not supported in parallel HDF5") + HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, + "evict on close is currently not supported in parallel HDF5") #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_evict_on_close() */ - /*------------------------------------------------------------------------- * Function: H5Pget_evict_on_close * @@ -4656,21 +4729,21 @@ done: herr_t H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close) { - H5P_genplist_t *plist; /* property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", fapl_id, evict_on_close); /* Compare the property list's class against the other class */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, evict_on_close) < 0) + if (H5P_get(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, evict_on_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get evict on close property") done: @@ -4678,7 +4751,7 @@ done: } /* end H5Pget_evict_on_close() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5P__encode_coll_md_read_flag_t * @@ -4696,7 +4769,7 @@ herr_t H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size) { const H5P_coll_md_read_flag_t *coll_md_read_flag = (const H5P_coll_md_read_flag_t *)value; - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_PACKAGE_NOERR @@ -4704,7 +4777,7 @@ H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size) HDassert(coll_md_read_flag); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the value */ H5MM_memcpy(*pp, coll_md_read_flag, sizeof(H5P_coll_md_read_flag_t)); *pp += sizeof(H5P_coll_md_read_flag_t); @@ -4716,7 +4789,6 @@ H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_coll_md_read_flag_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_coll_md_read_flag_t * @@ -4733,8 +4805,8 @@ H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size) herr_t H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value) { - H5P_coll_md_read_flag_t *coll_md_read_flag = (H5P_coll_md_read_flag_t *)_value; /* File close degree */ - const uint8_t **pp = (const uint8_t **)_pp; + H5P_coll_md_read_flag_t *coll_md_read_flag = (H5P_coll_md_read_flag_t *)_value; /* File close degree */ + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -4744,13 +4816,12 @@ H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value) HDassert(coll_md_read_flag); /* Decode file close degree */ - *coll_md_read_flag = (H5P_coll_md_read_flag_t)*(*pp); + *coll_md_read_flag = (H5P_coll_md_read_flag_t) * (*pp); *pp += sizeof(H5P_coll_md_read_flag_t); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_coll_md_read_flag_t() */ - /*------------------------------------------------------------------------- * Function: H5Pset_all_coll_metadata_ops * @@ -4775,9 +4846,9 @@ H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value) herr_t H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) { - H5P_genplist_t *plist; /* Property list pointer */ - H5P_coll_md_read_flag_t coll_meta_read; /* Property value */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5P_coll_md_read_flag_t coll_meta_read; /* Property value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", plist_id, is_collective); @@ -4786,30 +4857,28 @@ H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) /* (Dataset, group, attribute, and named datype access property lists * are sub-classes of link access property lists -QAK) */ - if(TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) + if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && + TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* set property to either TRUE if > 0, or FALSE otherwise */ - if(is_collective) + if (is_collective) coll_meta_read = H5P_USER_TRUE; else coll_meta_read = H5P_USER_FALSE; /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5_COLL_MD_READ_FLAG_NAME, &coll_meta_read) < 0) + if (H5P_set(plist, H5_COLL_MD_READ_FLAG_NAME, &coll_meta_read) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata read flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_all_coll_metadata_ops() */ - /*------------------------------------------------------------------------- * Function: H5Pget_all_coll_metadata_ops * @@ -4831,7 +4900,7 @@ done: herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", plist_id, is_collective); @@ -4840,24 +4909,24 @@ H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective) /* (Dataset, group, attribute, and named datype access property lists * are sub-classes of link access property lists -QAK) */ - if(TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) + if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && + TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* Get value */ - if(is_collective) { - H5P_coll_md_read_flag_t internal_flag; /* property setting. we need to convert to either TRUE or FALSE */ - H5P_genplist_t *plist; /* Property list pointer */ + if (is_collective) { + H5P_coll_md_read_flag_t + internal_flag; /* property setting. we need to convert to either TRUE or FALSE */ + H5P_genplist_t *plist; /* Property list pointer */ /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &internal_flag) < 0) + if (H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &internal_flag) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core collective metadata read flag") - if(internal_flag < 0) + if (internal_flag < 0) *is_collective = FALSE; else *is_collective = (hbool_t)internal_flag; @@ -4867,7 +4936,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Pget_all_coll_metadata_ops */ - /*------------------------------------------------------------------------- * Function: H5Pset_coll_metadata_write * @@ -4884,29 +4952,28 @@ done: herr_t H5Pset_coll_metadata_write(hid_t plist_id, hbool_t is_collective) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", plist_id, is_collective); /* Compare the property list's class against the other class */ - if(TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &is_collective) < 0) + if (H5P_set(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &is_collective) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata write flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_coll_metadata_write() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mpi_params * @@ -4922,31 +4989,30 @@ done: herr_t H5Pget_mpi_params(hid_t plist_id, MPI_Comm *comm, MPI_Info *info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*Mc*Mi", plist_id, comm, info); /* Make sure that the property list is a fapl */ - if(TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the properties */ - if(H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, comm) < 0) + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, comm) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI communicator from plist") - if(H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, info) < 0) + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI info from plist") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mpi_params() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mpi_params * @@ -4962,35 +5028,34 @@ done: herr_t H5Pset_mpi_params(hid_t plist_id, MPI_Comm comm, MPI_Info info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iMcMi", plist_id, comm, info); /* Make sure the MPI communicator is valid */ - if(MPI_COMM_NULL == comm) + if (MPI_COMM_NULL == comm) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "not a valid argument") /* Make sure that the property list is a fapl */ - if(TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + if (H5P_set(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI communicator") - if(H5P_set(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) + if (H5P_set(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI info object") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_mpi_params() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_comm_set * @@ -5003,21 +5068,21 @@ done: */ static herr_t H5P__facc_mpi_comm_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - MPI_Comm *comm = (MPI_Comm *)value; - MPI_Comm comm_tmp = MPI_COMM_NULL; - herr_t ret_value = SUCCEED; + MPI_Comm *comm = (MPI_Comm *)value; + MPI_Comm comm_tmp = MPI_COMM_NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Make a copy of the MPI communicator */ - if(H5_mpi_comm_dup(*comm, &comm_tmp) < 0) + if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator") done: /* Copy the communicator to the in/out parameter */ - if(ret_value != SUCCEED) + if (ret_value != SUCCEED) *comm = MPI_COMM_NULL; else *comm = comm_tmp; @@ -5025,7 +5090,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_comm_set() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_comm_get * @@ -5038,21 +5102,21 @@ done: */ static herr_t H5P__facc_mpi_comm_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - MPI_Comm *comm = (MPI_Comm *)value; - MPI_Comm comm_tmp = MPI_COMM_NULL; - herr_t ret_value = SUCCEED; + MPI_Comm *comm = (MPI_Comm *)value; + MPI_Comm comm_tmp = MPI_COMM_NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Make a copy of the MPI communicator */ - if(H5_mpi_comm_dup(*comm, &comm_tmp) < 0) + if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator") done: /* Copy the communicator to the out parameter */ - if(ret_value != SUCCEED) + if (ret_value != SUCCEED) *comm = MPI_COMM_NULL; else *comm = comm_tmp; @@ -5060,7 +5124,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_comm_get() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_comm_del * @@ -5072,22 +5135,22 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__facc_mpi_comm_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_mpi_comm_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - MPI_Comm *comm = (MPI_Comm *)value; - herr_t ret_value = SUCCEED; + MPI_Comm *comm = (MPI_Comm *)value; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Free the MPI communicator */ - if(H5_mpi_comm_free(comm) < 0) + if (H5_mpi_comm_free(comm) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_comm_del() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_comm_copy * @@ -5101,19 +5164,19 @@ done: static herr_t H5P__facc_mpi_comm_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - MPI_Comm *comm = (MPI_Comm *)value; - MPI_Comm comm_tmp = MPI_COMM_NULL; - herr_t ret_value = SUCCEED; + MPI_Comm *comm = (MPI_Comm *)value; + MPI_Comm comm_tmp = MPI_COMM_NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Make a copy of the MPI communicator */ - if(H5_mpi_comm_dup(*comm, &comm_tmp) < 0) + if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator") done: /* Copy the communicator to the in/out parameter */ - if(ret_value != SUCCEED) + if (ret_value != SUCCEED) *comm = MPI_COMM_NULL; else *comm = comm_tmp; @@ -5121,7 +5184,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_comm_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_comm_cmp * @@ -5138,21 +5200,20 @@ done: static int H5P__facc_mpi_comm_cmp(const void *_comm1, const void *_comm2, size_t H5_ATTR_UNUSED size) { - const MPI_Comm *comm1 = (const MPI_Comm *)_comm1; - const MPI_Comm *comm2 = (const MPI_Comm *)_comm2; - int ret_value = 0; + const MPI_Comm *comm1 = (const MPI_Comm *)_comm1; + const MPI_Comm *comm2 = (const MPI_Comm *)_comm2; + int ret_value = 0; FUNC_ENTER_STATIC /* Compare the MPI communicators */ - if(H5_mpi_comm_cmp(*comm1, *comm2, &ret_value) < 0) + if (H5_mpi_comm_cmp(*comm1, *comm2, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, 0, "unable to compare MPI communicator") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_comm_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_comm_close * @@ -5166,20 +5227,19 @@ done: static herr_t H5P__facc_mpi_comm_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - MPI_Comm *comm = (MPI_Comm *)value; - herr_t ret_value = SUCCEED; + MPI_Comm *comm = (MPI_Comm *)value; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Free the MPI communicator */ - if(H5_mpi_comm_free(comm) < 0) + if (H5_mpi_comm_free(comm) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_comm_close() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_info_set * @@ -5192,21 +5252,21 @@ done: */ static herr_t H5P__facc_mpi_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - MPI_Info *info = (MPI_Info *)value; - MPI_Info info_tmp = MPI_INFO_NULL; - herr_t ret_value = SUCCEED; + MPI_Info *info = (MPI_Info *)value; + MPI_Info info_tmp = MPI_INFO_NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Make a copy of the MPI info object */ - if(H5_mpi_info_dup(*info, &info_tmp) < 0) + if (H5_mpi_info_dup(*info, &info_tmp) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object") done: /* Copy the info object to the in/out parameter */ - if(ret_value != SUCCEED) + if (ret_value != SUCCEED) *info = MPI_INFO_NULL; else *info = info_tmp; @@ -5214,7 +5274,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_info_set() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_info_get * @@ -5227,21 +5286,21 @@ done: */ static herr_t H5P__facc_mpi_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - MPI_Info *info = (MPI_Info *)value; - MPI_Info info_tmp = MPI_INFO_NULL; - herr_t ret_value = SUCCEED; + MPI_Info *info = (MPI_Info *)value; + MPI_Info info_tmp = MPI_INFO_NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Make a copy of the MPI communicator */ - if(H5_mpi_info_dup(*info, &info_tmp) < 0) + if (H5_mpi_info_dup(*info, &info_tmp) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object") done: /* Copy the info object to the out parameter */ - if(ret_value != SUCCEED) + if (ret_value != SUCCEED) *info = MPI_INFO_NULL; else *info = info_tmp; @@ -5249,7 +5308,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_info_get() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_info_del * @@ -5261,22 +5319,22 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__facc_mpi_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_mpi_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - MPI_Info *info = (MPI_Info *)value; - herr_t ret_value = SUCCEED; + MPI_Info *info = (MPI_Info *)value; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Free the MPI info object */ - if(H5_mpi_info_free(info) < 0) + if (H5_mpi_info_free(info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_info_del() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_info_copy * @@ -5290,19 +5348,19 @@ done: static herr_t H5P__facc_mpi_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - MPI_Info *info = (MPI_Info *)value; - MPI_Info info_tmp = MPI_INFO_NULL; - herr_t ret_value = SUCCEED; + MPI_Info *info = (MPI_Info *)value; + MPI_Info info_tmp = MPI_INFO_NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Make a copy of the MPI info object */ - if(H5_mpi_info_dup(*info, &info_tmp) < 0) + if (H5_mpi_info_dup(*info, &info_tmp) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object") done: /* Copy the info object to the in/out parameter */ - if(ret_value != SUCCEED) + if (ret_value != SUCCEED) *info = MPI_INFO_NULL; else *info = info_tmp; @@ -5310,7 +5368,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_info_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_info_cmp * @@ -5327,21 +5384,20 @@ done: static int H5P__facc_mpi_info_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) { - const MPI_Info *info1 = (const MPI_Info *)_info1; - const MPI_Info *info2 = (const MPI_Info *)_info2; - int ret_value = 0; + const MPI_Info *info1 = (const MPI_Info *)_info1; + const MPI_Info *info2 = (const MPI_Info *)_info2; + int ret_value = 0; FUNC_ENTER_STATIC /* Compare the MPI info objects */ - if(H5_mpi_info_cmp(*info1, *info2, &ret_value) < 0) + if (H5_mpi_info_cmp(*info1, *info2, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, 0, "unable to compare MPI info objects") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_info_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_mpi_info_close * @@ -5355,20 +5411,19 @@ done: static herr_t H5P__facc_mpi_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - MPI_Info *info = (MPI_Info *)value; - herr_t ret_value = SUCCEED; + MPI_Info *info = (MPI_Info *)value; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Free the MPI info object */ - if(H5_mpi_info_free(info) < 0) + if (H5_mpi_info_free(info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_mpi_info_close() */ - /*------------------------------------------------------------------------- * Function: H5Pget_coll_metadata_write * @@ -5384,21 +5439,21 @@ done: herr_t H5Pget_coll_metadata_write(hid_t plist_id, hbool_t *is_collective) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", plist_id, is_collective); /* Compare the property list's class against the other class */ - if(TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, is_collective) < 0) + if (H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, is_collective) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get collective metadata write flag") done: @@ -5406,7 +5461,6 @@ done: } /* end H5Pget_coll_metadata_write() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5Pset_page_buffer_size * @@ -5424,37 +5478,39 @@ done: herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, unsigned min_raw_perc) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "izIuIu", plist_id, buf_size, min_meta_perc, min_raw_perc); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(min_meta_perc > 100) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Minimum metadata fractions must be between 0 and 100 inclusive") - if(min_raw_perc > 100) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Minimum rawdata fractions must be between 0 and 100 inclusive") + if (min_meta_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Minimum metadata fractions must be between 0 and 100 inclusive") + if (min_raw_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Minimum rawdata fractions must be between 0 and 100 inclusive") - if(min_meta_perc + min_raw_perc > 100) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Sum of minimum metadata and raw data fractions can't be bigger than 100"); + if (min_meta_perc + min_raw_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Sum of minimum metadata and raw data fractions can't be bigger than 100"); /* Set size */ - if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &buf_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set page buffer size") - if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &min_meta_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set percentage of min metadata entries") - if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &min_raw_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set percentage of min rawdata entries") + if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set page buffer size") + if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &min_meta_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min metadata entries") + if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &min_raw_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min rawdata entries") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_page_buffer_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_page_buffer_size * @@ -5470,33 +5526,32 @@ done: herr_t H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_perc, unsigned *min_raw_perc) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*z*Iu*Iu", plist_id, buf_size, min_meta_perc, min_raw_perc); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get size */ - if(buf_size) - if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, buf_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer size") - if(min_meta_perc) - if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, min_meta_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer minimum metadata percent") - if(min_raw_perc) - if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, min_raw_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer minimum raw data percent") + if (buf_size) + if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer size") + if (min_meta_perc) + if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, min_meta_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer minimum metadata percent") + if (min_raw_perc) + if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, min_raw_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer minimum raw data percent") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_page_buffer_size() */ - /*------------------------------------------------------------------------- * Function: H5P_set_vol * @@ -5512,22 +5567,22 @@ done: herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(NULL == H5I_object_verify(vol_id, H5I_VOL)) + if (NULL == H5I_object_verify(vol_id, H5I_VOL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5VL_connector_prop_t vol_prop; /* Property for VOL ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5VL_connector_prop_t vol_prop; /* Property for VOL ID & info */ /* Prepare the VOL connector property */ - vol_prop.connector_id = vol_id; + vol_prop.connector_id = vol_id; vol_prop.connector_info = vol_info; /* Set the connector ID & info property */ - if(H5P_set(plist, H5F_ACS_VOL_CONN_NAME, &vol_prop) < 0) + if (H5P_set(plist, H5F_ACS_VOL_CONN_NAME, &vol_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info") } /* end if */ else @@ -5554,59 +5609,57 @@ done: herr_t H5Pset_vfd_swmr_config(hid_t plist_id, H5F_vfd_swmr_config_t *config_ptr) { - H5P_genplist_t *plist; /* Property list pointer */ - size_t name_len; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + size_t name_len; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", plist_id, config_ptr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Validate the input configuration */ - /* Check args */ - if(config_ptr == NULL) + /* Check args */ + if (config_ptr == NULL) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "NULL config_ptr on entry") /* This field must always be set to a known version */ - if(config_ptr->version != H5F__CURR_VFD_SWMR_CONFIG_VERSION) + if (config_ptr->version != H5F__CURR_VFD_SWMR_CONFIG_VERSION) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "Unknown config version") /* This field must be at least 3 */ - if(config_ptr->max_lag < 3 ) + if (config_ptr->max_lag < 3) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "max_lag must be at least 3") /* This field must be >= 2 */ - if(config_ptr->md_pages_reserved < 2 ) + if (config_ptr->md_pages_reserved < 2) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_pages_reserved must be at least 2") /* This field must be in the range [0, 100] */ - if(config_ptr->pb_expansion_threshold > H5F__MAX_PB_EXPANSION_THRESHOLD) + if (config_ptr->pb_expansion_threshold > H5F__MAX_PB_EXPANSION_THRESHOLD) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "pb_expansion_threshold out of range") /* Must provide the path for the metadata file */ name_len = HDstrlen(config_ptr->md_file_path); - if(name_len == 0) + if (name_len == 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_file_path is empty") - else if(name_len > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) + else if (name_len > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_file_path is too long") /* Set the modified config */ - if(H5P_set(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config_ptr) < 0) + if (H5P_set(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config_ptr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache initial config") - if(H5P_set_driver(plist, H5FD_VFD_SWMR, NULL) < 0) + if (H5P_set_driver(plist, H5FD_VFD_SWMR, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VFD SWMR driver info"); done: FUNC_LEAVE_API(ret_value) } /* H5Pset_vfd_swmr_config() */ - - /*------------------------------------------------------------------------- * Function: H5P_reset_vol_class * @@ -5626,24 +5679,23 @@ done: herr_t H5P_reset_vol_class(const H5P_genclass_t *pclass, const H5VL_connector_prop_t *vol_prop) { - H5VL_connector_prop_t old_vol_prop; /* Previous VOL connector property */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_prop_t old_vol_prop; /* Previous VOL connector property */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the connector ID & info property */ - if(H5P__class_get(pclass, H5F_ACS_VOL_CONN_NAME, &old_vol_prop) < 0) + if (H5P__class_get(pclass, H5F_ACS_VOL_CONN_NAME, &old_vol_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector ID & info") /* Set the new connector ID & info property */ - if(H5P__class_set(pclass, H5F_ACS_VOL_CONN_NAME, vol_prop) < 0) + if (H5P__class_set(pclass, H5F_ACS_VOL_CONN_NAME, vol_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_set_vol_class() */ - /*------------------------------------------------------------------------- * Function: H5Pset_vol * @@ -5658,27 +5710,26 @@ done: herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", plist_id, new_vol_id, new_vol_info); /* Check arguments */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(NULL == H5I_object_verify(new_vol_id, H5I_VOL)) + if (NULL == H5I_object_verify(new_vol_id, H5I_VOL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file VOL ID") /* Set the VOL */ - if(H5P_set_vol(plist, new_vol_id, new_vol_info) < 0) + if (H5P_set_vol(plist, new_vol_id, new_vol_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_vol() */ - /*------------------------------------------------------------------------- * Function: H5Pget_vol_id * @@ -5693,26 +5744,26 @@ done: herr_t H5Pget_vol_id(hid_t plist_id, hid_t *vol_id) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*i", plist_id, vol_id); /* Get property list for ID */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get the current VOL ID */ - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ /* Get the connector property */ - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector info") /* Increment the VOL ID's ref count */ - if(H5I_inc_ref(connector_prop.connector_id, TRUE) < 0) + if (H5I_inc_ref(connector_prop.connector_id, TRUE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector ID") /* Set the connector ID to return */ @@ -5739,29 +5790,28 @@ done: herr_t H5Pget_vfd_swmr_config(hid_t plist_id, H5F_vfd_swmr_config_t *config_ptr) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", plist_id, config_ptr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Validate the config_ptr */ - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.") /* Get the current VFD SWMR configuration */ - if(H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config_ptr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get VFD SWMR config") + if (H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config_ptr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VFD SWMR config") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_vfd_swmr_config() */ - /*------------------------------------------------------------------------- * Function: H5Pget_vol_info * @@ -5776,35 +5826,35 @@ done: herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i**x", plist_id, vol_info); /* Get property list for ID */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get the current VOL info */ - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - void *new_connector_info = NULL; /* Copy of connector info */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + void * new_connector_info = NULL; /* Copy of connector info */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ /* Get the connector property */ - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property") /* Copy connector info, if it exists */ - if(connector_prop.connector_info) { - H5VL_class_t *connector; /* Pointer to connector */ + if (connector_prop.connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ /* Retrieve the connector for the ID */ - if(NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) + if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Allocate and copy connector info */ - if(H5VL_copy_connector_info(connector, &new_connector_info, connector_prop.connector_info) < 0) + if (H5VL_copy_connector_info(connector, &new_connector_info, connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed") } /* end if */ @@ -5818,7 +5868,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_vol_info() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vol_create * @@ -5832,19 +5881,18 @@ done: static herr_t H5P__facc_vol_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make copy of the VOL connector */ - if(H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_create() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vol_set * @@ -5856,10 +5904,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -5867,14 +5915,13 @@ H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, HDassert(value); /* Make copy of VOL connector ID & info */ - if(H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_set() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vol_get * @@ -5886,10 +5933,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -5897,14 +5944,13 @@ H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, HDassert(value); /* Make copy of VOL connector */ - if(H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_get() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vol_del * @@ -5916,21 +5962,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the VOL connector ID & info */ - if(H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) + if (H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_del() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vol_copy * @@ -5944,19 +5990,18 @@ done: static herr_t H5P__facc_vol_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make copy of VOL connector */ - if(H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vol_cmp * @@ -5973,12 +6018,13 @@ done: static int H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) { - const H5VL_connector_prop_t *info1 = (const H5VL_connector_prop_t *)_info1; /* Create local aliases for values */ + const H5VL_connector_prop_t *info1 = + (const H5VL_connector_prop_t *)_info1; /* Create local aliases for values */ const H5VL_connector_prop_t *info2 = (const H5VL_connector_prop_t *)_info2; - H5VL_class_t *cls1, *cls2; /* connector class for each property */ - int cmp_value = 0; /* Value from comparison */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Status from info comparison */ - int ret_value = 0; /* Return value */ + H5VL_class_t * cls1, *cls2; /* connector class for each property */ + int cmp_value = 0; /* Value from comparison */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Status from info comparison */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -5988,20 +6034,19 @@ H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED HDassert(size == sizeof(H5VL_connector_prop_t)); /* Compare connectors */ - if(NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->connector_id))) + if (NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->connector_id))) HGOTO_DONE(-1) - if(NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->connector_id))) + if (NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->connector_id))) HGOTO_DONE(1) status = H5VL_cmp_connector_cls(&cmp_value, cls1, cls2); HDassert(status >= 0); - if(cmp_value != 0) + if (cmp_value != 0) HGOTO_DONE(cmp_value); /* At this point, we should be able to assume that we are dealing with * the same connector class struct (or a copies of the same class struct) */ - /* Use one of the classes (cls1) info comparison routines to compare the * info objects */ @@ -6016,7 +6061,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_vol_close * @@ -6030,15 +6074,14 @@ done: static herr_t H5P__facc_vol_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the VOL connector */ - if(H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) + if (H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_close() */ - diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index 3b0ce66..754d34e 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -26,18 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bprivate.h" /* B-tree subclass names */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Bprivate.h" /* B-tree subclass names */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -45,84 +43,90 @@ /* ========= File Creation properties ============ */ /* Definitions for the size of the file user block in bytes */ -#define H5F_CRT_USER_BLOCK_SIZE sizeof(hsize_t) -#define H5F_CRT_USER_BLOCK_DEF 0 -#define H5F_CRT_USER_BLOCK_ENC H5P__encode_hsize_t -#define H5F_CRT_USER_BLOCK_DEC H5P__decode_hsize_t +#define H5F_CRT_USER_BLOCK_SIZE sizeof(hsize_t) +#define H5F_CRT_USER_BLOCK_DEF 0 +#define H5F_CRT_USER_BLOCK_ENC H5P__encode_hsize_t +#define H5F_CRT_USER_BLOCK_DEC H5P__decode_hsize_t /* Definitions for the 1/2 rank for symbol table leaf nodes */ -#define H5F_CRT_SYM_LEAF_SIZE sizeof(unsigned) -#define H5F_CRT_SYM_LEAF_ENC H5P__encode_unsigned -#define H5F_CRT_SYM_LEAF_DEC H5P__decode_unsigned +#define H5F_CRT_SYM_LEAF_SIZE sizeof(unsigned) +#define H5F_CRT_SYM_LEAF_ENC H5P__encode_unsigned +#define H5F_CRT_SYM_LEAF_DEC H5P__decode_unsigned /* Definitions for the 1/2 rank for btree internal nodes */ -#define H5F_CRT_BTREE_RANK_SIZE sizeof(unsigned[H5B_NUM_BTREE_ID]) -#define H5F_CRT_BTREE_RANK_DEF {HDF5_BTREE_SNODE_IK_DEF,HDF5_BTREE_CHUNK_IK_DEF} -#define H5F_CRT_BTREE_RANK_ENC H5P__fcrt_btree_rank_enc -#define H5F_CRT_BTREE_RANK_DEC H5P__fcrt_btree_rank_dec +#define H5F_CRT_BTREE_RANK_SIZE sizeof(unsigned[H5B_NUM_BTREE_ID]) +#define H5F_CRT_BTREE_RANK_DEF \ + { \ + HDF5_BTREE_SNODE_IK_DEF, HDF5_BTREE_CHUNK_IK_DEF \ + } +#define H5F_CRT_BTREE_RANK_ENC H5P__fcrt_btree_rank_enc +#define H5F_CRT_BTREE_RANK_DEC H5P__fcrt_btree_rank_dec /* Definitions for byte number in an address */ -#define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(uint8_t) -#define H5F_CRT_ADDR_BYTE_NUM_DEF H5F_OBJ_ADDR_SIZE -#define H5F_CRT_ADDR_BYTE_NUM_ENC H5P__encode_uint8_t -#define H5F_CRT_ADDR_BYTE_NUM_DEC H5P__decode_uint8_t +#define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(uint8_t) +#define H5F_CRT_ADDR_BYTE_NUM_DEF H5F_OBJ_ADDR_SIZE +#define H5F_CRT_ADDR_BYTE_NUM_ENC H5P__encode_uint8_t +#define H5F_CRT_ADDR_BYTE_NUM_DEC H5P__decode_uint8_t /* Definitions for byte number for object size */ -#define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(uint8_t) -#define H5F_CRT_OBJ_BYTE_NUM_DEF H5F_OBJ_SIZE_SIZE -#define H5F_CRT_OBJ_BYTE_NUM_ENC H5P__encode_uint8_t -#define H5F_CRT_OBJ_BYTE_NUM_DEC H5P__decode_uint8_t +#define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(uint8_t) +#define H5F_CRT_OBJ_BYTE_NUM_DEF H5F_OBJ_SIZE_SIZE +#define H5F_CRT_OBJ_BYTE_NUM_ENC H5P__encode_uint8_t +#define H5F_CRT_OBJ_BYTE_NUM_DEC H5P__decode_uint8_t /* Definitions for version number of the superblock */ -#define H5F_CRT_SUPER_VERS_SIZE sizeof(unsigned) -#define H5F_CRT_SUPER_VERS_DEF HDF5_SUPERBLOCK_VERSION_DEF +#define H5F_CRT_SUPER_VERS_SIZE sizeof(unsigned) +#define H5F_CRT_SUPER_VERS_DEF HDF5_SUPERBLOCK_VERSION_DEF /* Definitions for shared object header messages */ #define H5F_CRT_SHMSG_NINDEXES_SIZE sizeof(unsigned) #define H5F_CRT_SHMSG_NINDEXES_DEF (0) #define H5F_CRT_SHMSG_NINDEXES_ENC H5P__encode_unsigned #define H5F_CRT_SHMSG_NINDEXES_DEC H5P__decode_unsigned #define H5F_CRT_SHMSG_INDEX_TYPES_SIZE sizeof(unsigned[H5O_SHMESG_MAX_NINDEXES]) -#define H5F_CRT_SHMSG_INDEX_TYPES_DEF {0,0,0,0,0,0} -#define H5F_CRT_SHMSG_INDEX_TYPES_ENC H5P__fcrt_shmsg_index_types_enc -#define H5F_CRT_SHMSG_INDEX_TYPES_DEC H5P__fcrt_shmsg_index_types_dec +#define H5F_CRT_SHMSG_INDEX_TYPES_DEF \ + { \ + 0, 0, 0, 0, 0, 0 \ + } +#define H5F_CRT_SHMSG_INDEX_TYPES_ENC H5P__fcrt_shmsg_index_types_enc +#define H5F_CRT_SHMSG_INDEX_TYPES_DEC H5P__fcrt_shmsg_index_types_dec #define H5F_CRT_SHMSG_INDEX_MINSIZE_SIZE sizeof(unsigned[H5O_SHMESG_MAX_NINDEXES]) -#define H5F_CRT_SHMSG_INDEX_MINSIZE_DEF {250,250,250,250,250,250} +#define H5F_CRT_SHMSG_INDEX_MINSIZE_DEF \ + { \ + 250, 250, 250, 250, 250, 250 \ + } #define H5F_CRT_SHMSG_INDEX_MINSIZE_ENC H5P__fcrt_shmsg_index_minsize_enc #define H5F_CRT_SHMSG_INDEX_MINSIZE_DEC H5P__fcrt_shmsg_index_minsize_dec /* Definitions for shared object header list/btree phase change cutoffs */ -#define H5F_CRT_SHMSG_LIST_MAX_SIZE sizeof(unsigned) -#define H5F_CRT_SHMSG_LIST_MAX_DEF (50) -#define H5F_CRT_SHMSG_LIST_MAX_ENC H5P__encode_unsigned -#define H5F_CRT_SHMSG_LIST_MAX_DEC H5P__decode_unsigned -#define H5F_CRT_SHMSG_BTREE_MIN_SIZE sizeof(unsigned) -#define H5F_CRT_SHMSG_BTREE_MIN_DEF (40) -#define H5F_CRT_SHMSG_BTREE_MIN_ENC H5P__encode_unsigned -#define H5F_CRT_SHMSG_BTREE_MIN_DEC H5P__decode_unsigned +#define H5F_CRT_SHMSG_LIST_MAX_SIZE sizeof(unsigned) +#define H5F_CRT_SHMSG_LIST_MAX_DEF (50) +#define H5F_CRT_SHMSG_LIST_MAX_ENC H5P__encode_unsigned +#define H5F_CRT_SHMSG_LIST_MAX_DEC H5P__decode_unsigned +#define H5F_CRT_SHMSG_BTREE_MIN_SIZE sizeof(unsigned) +#define H5F_CRT_SHMSG_BTREE_MIN_DEF (40) +#define H5F_CRT_SHMSG_BTREE_MIN_ENC H5P__encode_unsigned +#define H5F_CRT_SHMSG_BTREE_MIN_DEC H5P__decode_unsigned /* Definitions for file space handling strategy */ -#define H5F_CRT_FILE_SPACE_STRATEGY_SIZE sizeof(H5F_fspace_strategy_t) -#define H5F_CRT_FILE_SPACE_STRATEGY_DEF H5F_FILE_SPACE_STRATEGY_DEF -#define H5F_CRT_FILE_SPACE_STRATEGY_ENC H5P__fcrt_fspace_strategy_enc -#define H5F_CRT_FILE_SPACE_STRATEGY_DEC H5P__fcrt_fspace_strategy_dec -#define H5F_CRT_FREE_SPACE_PERSIST_SIZE sizeof(hbool_t) -#define H5F_CRT_FREE_SPACE_PERSIST_DEF H5F_FREE_SPACE_PERSIST_DEF -#define H5F_CRT_FREE_SPACE_PERSIST_ENC H5P__encode_hbool_t -#define H5F_CRT_FREE_SPACE_PERSIST_DEC H5P__decode_hbool_t -#define H5F_CRT_FREE_SPACE_THRESHOLD_SIZE sizeof(hsize_t) -#define H5F_CRT_FREE_SPACE_THRESHOLD_DEF H5F_FREE_SPACE_THRESHOLD_DEF -#define H5F_CRT_FREE_SPACE_THRESHOLD_ENC H5P__encode_hsize_t -#define H5F_CRT_FREE_SPACE_THRESHOLD_DEC H5P__decode_hsize_t +#define H5F_CRT_FILE_SPACE_STRATEGY_SIZE sizeof(H5F_fspace_strategy_t) +#define H5F_CRT_FILE_SPACE_STRATEGY_DEF H5F_FILE_SPACE_STRATEGY_DEF +#define H5F_CRT_FILE_SPACE_STRATEGY_ENC H5P__fcrt_fspace_strategy_enc +#define H5F_CRT_FILE_SPACE_STRATEGY_DEC H5P__fcrt_fspace_strategy_dec +#define H5F_CRT_FREE_SPACE_PERSIST_SIZE sizeof(hbool_t) +#define H5F_CRT_FREE_SPACE_PERSIST_DEF H5F_FREE_SPACE_PERSIST_DEF +#define H5F_CRT_FREE_SPACE_PERSIST_ENC H5P__encode_hbool_t +#define H5F_CRT_FREE_SPACE_PERSIST_DEC H5P__decode_hbool_t +#define H5F_CRT_FREE_SPACE_THRESHOLD_SIZE sizeof(hsize_t) +#define H5F_CRT_FREE_SPACE_THRESHOLD_DEF H5F_FREE_SPACE_THRESHOLD_DEF +#define H5F_CRT_FREE_SPACE_THRESHOLD_ENC H5P__encode_hsize_t +#define H5F_CRT_FREE_SPACE_THRESHOLD_DEC H5P__decode_hsize_t /* Definitions for file space page size in support of level-2 page caching */ -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE sizeof(hsize_t) -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF H5F_FILE_SPACE_PAGE_SIZE_DEF -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC H5P__encode_hsize_t -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC H5P__decode_hsize_t - +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE sizeof(hsize_t) +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF H5F_FILE_SPACE_PAGE_SIZE_DEF +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC H5P__encode_hsize_t +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC H5P__decode_hsize_t /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -140,59 +144,58 @@ static herr_t H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *value); static herr_t H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value); - /*********************/ /* Package Variables */ /*********************/ /* File creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_FCRT[1] = {{ - "file create", /* Class name for debugging */ - H5P_TYPE_FILE_CREATE, /* Class type */ - - &H5P_CLS_GROUP_CREATE_g, /* Parent class */ - &H5P_CLS_FILE_CREATE_g, /* Pointer to class */ - &H5P_CLS_FILE_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_FILE_CREATE_ID_g, /* Pointer to default property list ID */ - H5P_fcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "file create", /* Class name for debugging */ + H5P_TYPE_FILE_CREATE, /* Class type */ + + &H5P_CLS_GROUP_CREATE_g, /* Parent class */ + &H5P_CLS_FILE_CREATE_g, /* Pointer to class */ + &H5P_CLS_FILE_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_CREATE_ID_g, /* Pointer to default property list ID */ + H5P_fcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const hsize_t H5F_def_userblock_size_g = H5F_CRT_USER_BLOCK_DEF; /* Default userblock size */ -static const unsigned H5F_def_sym_leaf_k_g = H5F_CRT_SYM_LEAF_DEF; /* Default size for symbol table leaf nodes */ -static const unsigned H5F_def_btree_k_g[H5B_NUM_BTREE_ID] = H5F_CRT_BTREE_RANK_DEF; /* Default 'K' values for B-trees in file */ -static const uint8_t H5F_def_sizeof_addr_g = H5F_CRT_ADDR_BYTE_NUM_DEF; /* Default size of addresses in the file */ -static const uint8_t H5F_def_sizeof_size_g = H5F_CRT_OBJ_BYTE_NUM_DEF; /* Default size of sizes in the file */ -static const unsigned H5F_def_superblock_ver_g = H5F_CRT_SUPER_VERS_DEF; /* Default superblock version # */ -static const unsigned H5F_def_num_sohm_indexes_g = H5F_CRT_SHMSG_NINDEXES_DEF; -static const unsigned H5F_def_sohm_index_flags_g[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_TYPES_DEF; -static const unsigned H5F_def_sohm_index_minsizes_g[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_MINSIZE_DEF; -static const unsigned H5F_def_sohm_list_max_g = H5F_CRT_SHMSG_LIST_MAX_DEF; -static const unsigned H5F_def_sohm_btree_min_g = H5F_CRT_SHMSG_BTREE_MIN_DEF; -static const H5F_fspace_strategy_t H5F_def_file_space_strategy_g = H5F_CRT_FILE_SPACE_STRATEGY_DEF; -static const hbool_t H5F_def_free_space_persist_g = H5F_CRT_FREE_SPACE_PERSIST_DEF; -static const hsize_t H5F_def_free_space_threshold_g = H5F_CRT_FREE_SPACE_THRESHOLD_DEF; -static const hsize_t H5F_def_file_space_page_size_g = H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF; - - - +static const hsize_t H5F_def_userblock_size_g = H5F_CRT_USER_BLOCK_DEF; /* Default userblock size */ +static const unsigned H5F_def_sym_leaf_k_g = + H5F_CRT_SYM_LEAF_DEF; /* Default size for symbol table leaf nodes */ +static const unsigned H5F_def_btree_k_g[H5B_NUM_BTREE_ID] = + H5F_CRT_BTREE_RANK_DEF; /* Default 'K' values for B-trees in file */ +static const uint8_t H5F_def_sizeof_addr_g = + H5F_CRT_ADDR_BYTE_NUM_DEF; /* Default size of addresses in the file */ +static const uint8_t H5F_def_sizeof_size_g = H5F_CRT_OBJ_BYTE_NUM_DEF; /* Default size of sizes in the file */ +static const unsigned H5F_def_superblock_ver_g = H5F_CRT_SUPER_VERS_DEF; /* Default superblock version # */ +static const unsigned H5F_def_num_sohm_indexes_g = H5F_CRT_SHMSG_NINDEXES_DEF; +static const unsigned H5F_def_sohm_index_flags_g[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_TYPES_DEF; +static const unsigned H5F_def_sohm_index_minsizes_g[H5O_SHMESG_MAX_NINDEXES] = + H5F_CRT_SHMSG_INDEX_MINSIZE_DEF; +static const unsigned H5F_def_sohm_list_max_g = H5F_CRT_SHMSG_LIST_MAX_DEF; +static const unsigned H5F_def_sohm_btree_min_g = H5F_CRT_SHMSG_BTREE_MIN_DEF; +static const H5F_fspace_strategy_t H5F_def_file_space_strategy_g = H5F_CRT_FILE_SPACE_STRATEGY_DEF; +static const hbool_t H5F_def_free_space_persist_g = H5F_CRT_FREE_SPACE_PERSIST_DEF; +static const hsize_t H5F_def_free_space_threshold_g = H5F_CRT_FREE_SPACE_THRESHOLD_DEF; +static const hsize_t H5F_def_file_space_page_size_g = H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF; + /*------------------------------------------------------------------------- * Function: H5P_fcrt_reg_prop * @@ -207,99 +210,101 @@ static const hsize_t H5F_def_file_space_page_size_g = H5F_CRT_FILE_SPACE_PAGE_SI static herr_t H5P_fcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Register the user block size */ - if(H5P__register_real(pclass, H5F_CRT_USER_BLOCK_NAME, H5F_CRT_USER_BLOCK_SIZE, &H5F_def_userblock_size_g, - NULL, NULL, NULL, H5F_CRT_USER_BLOCK_ENC, H5F_CRT_USER_BLOCK_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_USER_BLOCK_NAME, H5F_CRT_USER_BLOCK_SIZE, + &H5F_def_userblock_size_g, NULL, NULL, NULL, H5F_CRT_USER_BLOCK_ENC, + H5F_CRT_USER_BLOCK_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 1/2 rank for symbol table leaf nodes */ - if(H5P__register_real(pclass, H5F_CRT_SYM_LEAF_NAME, H5F_CRT_SYM_LEAF_SIZE, &H5F_def_sym_leaf_k_g, - NULL, NULL, NULL, H5F_CRT_SYM_LEAF_ENC, H5F_CRT_SYM_LEAF_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SYM_LEAF_NAME, H5F_CRT_SYM_LEAF_SIZE, &H5F_def_sym_leaf_k_g, NULL, + NULL, NULL, H5F_CRT_SYM_LEAF_ENC, H5F_CRT_SYM_LEAF_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 1/2 rank for btree internal nodes */ - if(H5P__register_real(pclass, H5F_CRT_BTREE_RANK_NAME, H5F_CRT_BTREE_RANK_SIZE, H5F_def_btree_k_g, - NULL, NULL, NULL, H5F_CRT_BTREE_RANK_ENC, H5F_CRT_BTREE_RANK_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_BTREE_RANK_NAME, H5F_CRT_BTREE_RANK_SIZE, H5F_def_btree_k_g, NULL, + NULL, NULL, H5F_CRT_BTREE_RANK_ENC, H5F_CRT_BTREE_RANK_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the byte number for an address */ - if(H5P__register_real(pclass, H5F_CRT_ADDR_BYTE_NUM_NAME, H5F_CRT_ADDR_BYTE_NUM_SIZE, &H5F_def_sizeof_addr_g, - NULL, NULL, NULL, H5F_CRT_ADDR_BYTE_NUM_ENC, H5F_CRT_ADDR_BYTE_NUM_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_ADDR_BYTE_NUM_NAME, H5F_CRT_ADDR_BYTE_NUM_SIZE, + &H5F_def_sizeof_addr_g, NULL, NULL, NULL, H5F_CRT_ADDR_BYTE_NUM_ENC, + H5F_CRT_ADDR_BYTE_NUM_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the byte number for object size */ - if(H5P__register_real(pclass, H5F_CRT_OBJ_BYTE_NUM_NAME, H5F_CRT_OBJ_BYTE_NUM_SIZE, &H5F_def_sizeof_size_g, - NULL, NULL, NULL, H5F_CRT_OBJ_BYTE_NUM_ENC, H5F_CRT_OBJ_BYTE_NUM_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_OBJ_BYTE_NUM_NAME, H5F_CRT_OBJ_BYTE_NUM_SIZE, + &H5F_def_sizeof_size_g, NULL, NULL, NULL, H5F_CRT_OBJ_BYTE_NUM_ENC, + H5F_CRT_OBJ_BYTE_NUM_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the superblock version number */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_CRT_SUPER_VERS_NAME, H5F_CRT_SUPER_VERS_SIZE, &H5F_def_superblock_ver_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SUPER_VERS_NAME, H5F_CRT_SUPER_VERS_SIZE, + &H5F_def_superblock_ver_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the shared OH message information */ - if(H5P__register_real(pclass, H5F_CRT_SHMSG_NINDEXES_NAME, H5F_CRT_SHMSG_NINDEXES_SIZE, &H5F_def_num_sohm_indexes_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_NINDEXES_ENC, H5F_CRT_SHMSG_NINDEXES_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_NINDEXES_NAME, H5F_CRT_SHMSG_NINDEXES_SIZE, + &H5F_def_num_sohm_indexes_g, NULL, NULL, NULL, H5F_CRT_SHMSG_NINDEXES_ENC, + H5F_CRT_SHMSG_NINDEXES_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_TYPES_NAME, H5F_CRT_SHMSG_INDEX_TYPES_SIZE, &H5F_def_sohm_index_flags_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_TYPES_ENC, H5F_CRT_SHMSG_INDEX_TYPES_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_TYPES_NAME, H5F_CRT_SHMSG_INDEX_TYPES_SIZE, + &H5F_def_sohm_index_flags_g, NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_TYPES_ENC, + H5F_CRT_SHMSG_INDEX_TYPES_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, H5F_CRT_SHMSG_INDEX_MINSIZE_SIZE, &H5F_def_sohm_index_minsizes_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_MINSIZE_ENC, H5F_CRT_SHMSG_INDEX_MINSIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, H5F_CRT_SHMSG_INDEX_MINSIZE_SIZE, + &H5F_def_sohm_index_minsizes_g, NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_MINSIZE_ENC, + H5F_CRT_SHMSG_INDEX_MINSIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the shared OH cutoff size information */ - if(H5P__register_real(pclass, H5F_CRT_SHMSG_LIST_MAX_NAME, H5F_CRT_SHMSG_LIST_MAX_SIZE, &H5F_def_sohm_list_max_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_LIST_MAX_ENC, H5F_CRT_SHMSG_LIST_MAX_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_LIST_MAX_NAME, H5F_CRT_SHMSG_LIST_MAX_SIZE, + &H5F_def_sohm_list_max_g, NULL, NULL, NULL, H5F_CRT_SHMSG_LIST_MAX_ENC, + H5F_CRT_SHMSG_LIST_MAX_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5F_CRT_SHMSG_BTREE_MIN_NAME, H5F_CRT_SHMSG_BTREE_MIN_SIZE, &H5F_def_sohm_btree_min_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_BTREE_MIN_ENC, H5F_CRT_SHMSG_BTREE_MIN_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_BTREE_MIN_NAME, H5F_CRT_SHMSG_BTREE_MIN_SIZE, + &H5F_def_sohm_btree_min_g, NULL, NULL, NULL, H5F_CRT_SHMSG_BTREE_MIN_ENC, + H5F_CRT_SHMSG_BTREE_MIN_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file space handling strategy */ - if(H5P__register_real(pclass, H5F_CRT_FILE_SPACE_STRATEGY_NAME, H5F_CRT_FILE_SPACE_STRATEGY_SIZE, &H5F_def_file_space_strategy_g, - NULL, NULL, NULL, H5F_CRT_FILE_SPACE_STRATEGY_ENC, H5F_CRT_FILE_SPACE_STRATEGY_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_FILE_SPACE_STRATEGY_NAME, H5F_CRT_FILE_SPACE_STRATEGY_SIZE, + &H5F_def_file_space_strategy_g, NULL, NULL, NULL, H5F_CRT_FILE_SPACE_STRATEGY_ENC, + H5F_CRT_FILE_SPACE_STRATEGY_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the free-space persist flag */ - if(H5P__register_real(pclass, H5F_CRT_FREE_SPACE_PERSIST_NAME, H5F_CRT_FREE_SPACE_PERSIST_SIZE, &H5F_def_free_space_persist_g, - NULL, NULL, NULL, H5F_CRT_FREE_SPACE_PERSIST_ENC, H5F_CRT_FREE_SPACE_PERSIST_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_FREE_SPACE_PERSIST_NAME, H5F_CRT_FREE_SPACE_PERSIST_SIZE, + &H5F_def_free_space_persist_g, NULL, NULL, NULL, H5F_CRT_FREE_SPACE_PERSIST_ENC, + H5F_CRT_FREE_SPACE_PERSIST_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the free space section threshold */ - if(H5P__register_real(pclass, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, H5F_CRT_FREE_SPACE_THRESHOLD_SIZE, &H5F_def_free_space_threshold_g, - NULL, NULL, NULL, H5F_CRT_FREE_SPACE_THRESHOLD_ENC, H5F_CRT_FREE_SPACE_THRESHOLD_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, H5F_CRT_FREE_SPACE_THRESHOLD_SIZE, + &H5F_def_free_space_threshold_g, NULL, NULL, NULL, + H5F_CRT_FREE_SPACE_THRESHOLD_ENC, H5F_CRT_FREE_SPACE_THRESHOLD_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file space page size */ - if(H5P__register_real(pclass, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE, &H5F_def_file_space_page_size_g, - NULL, NULL, NULL, H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC, H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE, + &H5F_def_file_space_page_size_g, NULL, NULL, NULL, + H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC, H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC, NULL, NULL, + NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_fcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_userblock * @@ -316,36 +321,35 @@ done: herr_t H5Pset_userblock(hid_t plist_id, hsize_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, size); /* Sanity check non-zero userblock sizes */ - if(size > 0) { + if (size > 0) { /* Check that the userblock size is >=512 */ - if(size < 512) + if (size < 512) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and less than 512") /* Check that the userblock size is a power of two */ - if(!POWER_OF_TWO(size)) + if (!POWER_OF_TWO(size)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and not a power of two") } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0) + if (H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_userblock() */ - /*------------------------------------------------------------------------- * Function: H5Pget_userblock * @@ -369,26 +373,25 @@ done: herr_t H5Pget_userblock(hid_t plist_id, hsize_t *size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (size) - if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,"can't get user block"); + if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block"); done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_sizes * @@ -406,37 +409,37 @@ done: herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "izz", plist_id, sizeof_addr, sizeof_size); /* Check arguments */ - if(sizeof_addr) { - if(sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16) + if (sizeof_addr) { + if (sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file haddr_t size is not valid") } /* end if */ - if(sizeof_size) { - if(sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16) + if (sizeof_size) { + if (sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file size_t size is not valid") } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(sizeof_addr) { + if (sizeof_addr) { uint8_t tmp_sizeof_addr = (uint8_t)sizeof_addr; - if(H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) + if (H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for an address") } /* end if */ - if(sizeof_size) { + if (sizeof_size) { uint8_t tmp_sizeof_size = (uint8_t)sizeof_size; - if(H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) + if (H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for object ") } /* end if */ @@ -444,7 +447,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_sizes() */ - /*------------------------------------------------------------------------- * Function: H5Pget_sizes * @@ -463,28 +465,28 @@ done: herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr, size_t *sizeof_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*z*z", plist_id, sizeof_addr, sizeof_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(sizeof_addr) { + if (sizeof_addr) { uint8_t tmp_sizeof_addr; - if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) + if (H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for an address") *sizeof_addr = tmp_sizeof_addr; } /* end if */ - if(sizeof_size) { + if (sizeof_size) { uint8_t tmp_sizeof_size; - if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) + if (H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object ") *sizeof_size = tmp_sizeof_size; } /* end if */ @@ -493,7 +495,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_sizes() */ - /*------------------------------------------------------------------------- * Function: H5Pset_sym_k * @@ -527,37 +528,36 @@ done: herr_t H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk) { - unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, ik, lk); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if (ik > 0) { - if((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value exceeds maximum B-tree entries"); + if ((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value exceeds maximum B-tree entries"); - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); btree_k[H5B_SNODE_ID] = ik; - if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree nodes"); } if (lk > 0) - if(H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0) + if (H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for symbol table leaf nodes"); done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_sym_k * @@ -579,34 +579,33 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out */ , unsigned *lk /*out */ ) +H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out */, unsigned *lk /*out */) { - unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", plist_id, ik, lk); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (ik) { - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree nodes"); *ik = btree_k[H5B_SNODE_ID]; } if (lk) - if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0) + if (H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes"); done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_istore_k * @@ -629,9 +628,9 @@ done: herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik) { - unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, ik); @@ -640,25 +639,24 @@ H5Pset_istore_k(hid_t plist_id, unsigned ik) if (ik == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value must be positive"); - if((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) + if ((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value exceeds maximum B-tree entries"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); btree_k[H5B_CHUNK_ID] = ik; - if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree internal nodes"); done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_istore_k * @@ -681,22 +679,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ ) +H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */) { - unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, ik); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ - if(ik) { - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (ik) { + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); *ik = btree_k[H5B_CHUNK_ID]; } /* end if */ @@ -705,7 +703,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_istore_k() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_btree_rank_enc * @@ -724,7 +721,7 @@ static herr_t H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) { const unsigned *btree_k = (const unsigned *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -732,19 +729,19 @@ H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) HDassert(btree_k); HDassert(size); - if(NULL != *pp) { - unsigned u; /* Local index variable */ + if (NULL != *pp) { + unsigned u; /* Local index variable */ /* Encode the size of an unsigned*/ *(*pp)++ = (uint8_t)sizeof(unsigned); /* Encode all the btree */ - for(u = 0 ; u < H5B_NUM_BTREE_ID; u++) { + for (u = 0; u < H5B_NUM_BTREE_ID; u++) { /* Encode the left split value */ H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)btree_k) btree_k++; } /* end for */ - } /* end if */ + } /* end if */ /* Size of type flags values */ *size += 1 + (H5B_NUM_BTREE_ID * sizeof(unsigned)); @@ -752,7 +749,6 @@ H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_btree_rank_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_btree_rank_dec * @@ -770,11 +766,11 @@ H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__fcrt_btree_rank_dec(const void **_pp, void *_value) { - unsigned *btree_k = (unsigned *)_value; - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned * btree_k = (unsigned *)_value; + const uint8_t **pp = (const uint8_t **)_pp; + unsigned enc_size; /* Size of encoded property */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -785,18 +781,17 @@ H5P__fcrt_btree_rank_dec(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* Decode all the type flags */ - for(u = 0 ; u < H5B_NUM_BTREE_ID; u++) + for (u = 0; u < H5B_NUM_BTREE_ID; u++) H5_DECODE_UNSIGNED(*pp, btree_k[u]) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__fcrt_btree_rank_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_shared_mesg_nindexes * @@ -819,28 +814,28 @@ done: herr_t H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, nindexes); /* Check argument */ if (nindexes > H5O_SHMESG_MAX_NINDEXES) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - if(H5P_set(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set number of indexes"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shared_mesg_nindexes() */ - /*------------------------------------------------------------------------- * Function: H5Pget_shared_mesg_nindexes * @@ -857,24 +852,23 @@ done: herr_t H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", plist_id, nindexes); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, nindexes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_shared_mesg_nindexes() */ - /*------------------------------------------------------------------------- * Function: H5Pset_shared_mesg_index * @@ -895,52 +889,51 @@ done: herr_t H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_flags, unsigned min_mesg_size) { - H5P_genplist_t *plist; /* Property list pointer */ - unsigned nindexes; /* Number of SOHM indexes */ - unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ - unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + unsigned nindexes; /* Number of SOHM indexes */ + unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ + unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iIuIuIu", plist_id, index_num, mesg_type_flags, min_mesg_size); /* Check arguments */ - if(mesg_type_flags > H5O_SHMESG_ALL_FLAG) + if (mesg_type_flags > H5O_SHMESG_ALL_FLAG) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "unrecognized flags in mesg_type_flags") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Read the current number of indexes */ - if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes") /* Range check */ - if(index_num >= nindexes) + if (index_num >= nindexes) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index_num is too large; no such index"); /* Get arrays of type flags and message sizes */ - if(H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current index type flags") - if(H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current min sizes") /* Set values in arrays */ type_flags[index_num] = mesg_type_flags; - minsizes[index_num] = min_mesg_size; + minsizes[index_num] = min_mesg_size; /* Write arrays back to plist */ - if(H5P_set(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set index type flags") - if(H5P_set(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set min mesg sizes") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shared_mesg_index() */ - /*------------------------------------------------------------------------- * Function: H5Pget_shared_mesg_index * @@ -956,46 +949,47 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, unsigned *min_mesg_size) +H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, + unsigned *min_mesg_size) { - H5P_genplist_t *plist; /* Property list pointer */ - unsigned nindexes; /* Number of SOHM indexes */ - unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ - unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + unsigned nindexes; /* Number of SOHM indexes */ + unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ + unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iIu*Iu*Iu", plist_id, index_num, mesg_type_flags, min_mesg_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Read the current number of indexes */ - if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes") - if(index_num >= nindexes) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index_num is greater than number of indexes in property list") + if (index_num >= nindexes) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index_num is greater than number of indexes in property list") /* Get arrays of type flags and message sizes */ - if(H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current index type flags") - if(H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current min sizes") /* Get values from arrays */ - if(mesg_type_flags) + if (mesg_type_flags) *mesg_type_flags = type_flags[index_num]; - if(min_mesg_size) + if (min_mesg_size) *min_mesg_size = minsizes[index_num]; done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shared_mesg_index() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_shmsg_index_types_enc * @@ -1015,7 +1009,7 @@ static herr_t H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) { const unsigned *type_flags = (const unsigned *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1023,19 +1017,19 @@ H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) HDassert(type_flags); HDassert(size); - if(NULL != *pp) { - unsigned u; /* Local index variable */ + if (NULL != *pp) { + unsigned u; /* Local index variable */ /* Encode the size of a double*/ *(*pp)++ = (uint8_t)sizeof(unsigned); /* Encode all the type flags */ - for(u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { + for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { /* Encode the left split value */ H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)type_flags) type_flags++; } /* end for */ - } /* end if */ + } /* end if */ /* Size of type flags values */ *size += 1 + (H5O_SHMESG_MAX_NINDEXES * sizeof(unsigned)); @@ -1043,7 +1037,6 @@ H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_shmsg_index_types_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_shmsg_index_types_dec * @@ -1062,11 +1055,11 @@ H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__fcrt_shmsg_index_types_dec(const void **_pp, void *_value) { - unsigned *type_flags = (unsigned *)_value; - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned * type_flags = (unsigned *)_value; + const uint8_t **pp = (const uint8_t **)_pp; + unsigned enc_size; /* Size of encoded property */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1077,18 +1070,17 @@ H5P__fcrt_shmsg_index_types_dec(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* Decode all the type flags */ - for(u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) + for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) H5_DECODE_UNSIGNED(*pp, type_flags[u]) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__fcrt_shmsg_index_types_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_shmsg_index_minsize_enc * @@ -1108,7 +1100,7 @@ static herr_t H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) { const unsigned *minsizes = (const unsigned *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1116,19 +1108,19 @@ H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) HDassert(minsizes); HDassert(size); - if(NULL != *pp) { - unsigned u; /* Local index variable */ + if (NULL != *pp) { + unsigned u; /* Local index variable */ /* Encode the size of a double*/ *(*pp)++ = (uint8_t)sizeof(unsigned); /* Encode all the minsize values */ - for(u = 0 ; u < H5O_SHMESG_MAX_NINDEXES; u++) { + for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { /* Encode the left split value */ H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)minsizes) minsizes++; } /* end for */ - } /* end if */ + } /* end if */ /* Size of type flags values */ *size += 1 + (H5O_SHMESG_MAX_NINDEXES * sizeof(unsigned)); @@ -1136,7 +1128,6 @@ H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_shmsg_index_minsize_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_shmsg_index_minsize_dec * @@ -1155,11 +1146,11 @@ H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *_value) { - unsigned *minsizes = (unsigned *)_value; - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned * minsizes = (unsigned *)_value; + const uint8_t **pp = (const uint8_t **)_pp; + unsigned enc_size; /* Size of encoded property */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1170,18 +1161,17 @@ H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* Decode all the minsize values */ - for(u = 0 ; u < H5O_SHMESG_MAX_NINDEXES; u++) + for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) H5_DECODE_UNSIGNED(*pp, minsizes[u]) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__fcrt_shmsg_index_minsize_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_shared_mesg_phase_change * @@ -1204,8 +1194,8 @@ done: herr_t H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_btree) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, max_list, min_btree); @@ -1215,33 +1205,32 @@ H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_ * * Range check to make certain they will fit into encoded form. */ - if(max_list + 1 < min_btree) + if (max_list + 1 < min_btree) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "minimum B-tree value is greater than maximum list value") - if(max_list > H5O_SHMESG_MAX_LIST_SIZE) + if (max_list > H5O_SHMESG_MAX_LIST_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max list value is larger than H5O_SHMESG_MAX_LIST_SIZE") - if(min_btree > H5O_SHMESG_MAX_LIST_SIZE) + if (min_btree > H5O_SHMESG_MAX_LIST_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min btree value is larger than H5O_SHMESG_MAX_LIST_SIZE") /* Avoid the strange case where max_list == 0 and min_btree == 1, so deleting the * last message in a B-tree makes it become an empty list. */ - if(max_list == 0) + if (max_list == 0) min_btree = 0; /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - if(H5P_set(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &max_list) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &max_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set list maximum in property list"); - if(H5P_set(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &min_btree) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &min_btree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set B-tree minimum in property list"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shared_mesg_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pget_shared_mesg_phase_change * @@ -1258,36 +1247,35 @@ done: herr_t H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *min_btree) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*Iu*Iu", plist_id, max_list, min_btree); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value(s) */ - if(max_list) - if(H5P_get(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, max_list) < 0) + if (max_list) + if (H5P_get(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, max_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get list maximum"); - if(min_btree) - if(H5P_get(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, min_btree) < 0) + if (min_btree) + if (H5P_get(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, min_btree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get SOHM information"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_shared_mesg_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_space_strategy * * Purpose: Sets the "strategy" that the library employs in managing file space * Sets the "persist" value as to persist free-space or not - * Sets the "threshold" value that the free space manager(s) will use to track free space sections. - * Ignore "persist" and "threshold" for strategies that do not use free-space managers + * Sets the "threshold" value that the free space manager(s) will use to track free space + *sections. Ignore "persist" and "threshold" for strategies that do not use free-space managers * * Return: Non-negative on success/Negative on failure * @@ -1298,30 +1286,30 @@ done: herr_t H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iFfbh", plist_id, strategy, persist, threshold); /* Check arguments */ - if(strategy >= H5F_FSPACE_STRATEGY_NTYPES) + if (strategy >= H5F_FSPACE_STRATEGY_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value(s), if non-zero */ - if(H5P_set(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &strategy) < 0) + if (H5P_set(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &strategy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy") /* Ignore persist and threshold settings for strategies that do not use FSM */ - if(strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || strategy == H5F_FSPACE_STRATEGY_PAGE) { - if(H5P_set(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &persist) < 0) + if (strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || strategy == H5F_FSPACE_STRATEGY_PAGE) { + if (H5P_set(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &persist) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set free-space persisting status") - if(H5P_set(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &threshold) < 0) + if (H5P_set(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set free-space threshold") } /* end if */ @@ -1329,7 +1317,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Pset_file_space_strategy() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_space_strategy * @@ -1343,34 +1330,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, hsize_t *threshold) +H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, + hsize_t *threshold) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*Ff*b*h", plist_id, strategy, persist, threshold); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value(s) */ - if(strategy) - if(H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, strategy) < 0) + if (strategy) + if (H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, strategy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy") - if(persist) - if(H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, persist) < 0) + if (persist) + if (H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, persist) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space persisting status") - if(threshold) - if(H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, threshold) < 0) + if (threshold) + if (H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space threshold") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_file_space_strategy() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_fspace_strategy_enc * @@ -1389,7 +1376,8 @@ done: static herr_t H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) { - const H5F_fspace_strategy_t *strategy = (const H5F_fspace_strategy_t *)value; /* Create local alias for values */ + const H5F_fspace_strategy_t *strategy = + (const H5F_fspace_strategy_t *)value; /* Create local alias for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1398,7 +1386,7 @@ H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) HDassert(strategy); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode free-space strategy */ *(*pp)++ = (uint8_t)*strategy; @@ -1408,7 +1396,6 @@ H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_fspace_strategy_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_fspace_strategy_dec * @@ -1427,8 +1414,8 @@ H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value) { - H5F_fspace_strategy_t *strategy = (H5F_fspace_strategy_t *)_value; /* Free-space strategy */ - const uint8_t **pp = (const uint8_t **)_pp; + H5F_fspace_strategy_t *strategy = (H5F_fspace_strategy_t *)_value; /* Free-space strategy */ + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1438,12 +1425,11 @@ H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value) HDassert(strategy); /* Decode free-space strategy */ - *strategy = (H5F_fspace_strategy_t)*(*pp)++; + *strategy = (H5F_fspace_strategy_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_fspace_strategy_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_space_page_size * @@ -1458,31 +1444,30 @@ H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value) herr_t H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, fsp_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(fsp_size < H5F_FILE_SPACE_PAGE_SIZE_MIN) + if (fsp_size < H5F_FILE_SPACE_PAGE_SIZE_MIN) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "cannot set file space page size to less than 512") - if(fsp_size > H5F_FILE_SPACE_PAGE_SIZE_MAX) + if (fsp_size > H5F_FILE_SPACE_PAGE_SIZE_MAX) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "cannot set file space page size to more than 1GB") /* Set the value*/ - if(H5P_set(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsp_size) < 0) + if (H5P_set(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set file space page size") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_file_space_page_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_space_page_size * @@ -1498,22 +1483,21 @@ done: herr_t H5Pget_file_space_page_size(hid_t plist_id, hsize_t *fsp_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", plist_id, fsp_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(fsp_size) - if(H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, fsp_size) < 0) + if (fsp_size) + if (H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, fsp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space page size") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_file_space_page_size() */ - diff --git a/src/H5Pfmpl.c b/src/H5Pfmpl.c index 41ad078..de908e4 100644 --- a/src/H5Pfmpl.c +++ b/src/H5Pfmpl.c @@ -26,18 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -45,20 +43,17 @@ /* ======================== File Mount properties ====================*/ /* Definition for whether absolute symlinks local to file. */ -#define H5F_MNT_SYM_LOCAL_SIZE sizeof(hbool_t) -#define H5F_MNT_SYM_LOCAL_DEF FALSE - +#define H5F_MNT_SYM_LOCAL_SIZE sizeof(hbool_t) +#define H5F_MNT_SYM_LOCAL_DEF FALSE /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -66,45 +61,40 @@ /* Property class callbacks */ static herr_t H5P_fmnt_reg_prop(H5P_genclass_t *pclass); - /*********************/ /* Package Variables */ /*********************/ /* File mount property list class library initialization object */ const H5P_libclass_t H5P_CLS_FMNT[1] = {{ - "file mount", /* Class name for debugging */ - H5P_TYPE_FILE_MOUNT, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_FILE_MOUNT_g, /* Pointer to class */ - &H5P_CLS_FILE_MOUNT_ID_g, /* Pointer to class ID */ - &H5P_LST_FILE_MOUNT_ID_g, /* Pointer to default property list ID */ - H5P_fmnt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "file mount", /* Class name for debugging */ + H5P_TYPE_FILE_MOUNT, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_FILE_MOUNT_g, /* Pointer to class */ + &H5P_CLS_FILE_MOUNT_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_MOUNT_ID_g, /* Pointer to default property list ID */ + H5P_fmnt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const hbool_t H5F_def_local_g = H5F_MNT_SYM_LOCAL_DEF; /* Whether symlinks are local to file */ +static const hbool_t H5F_def_local_g = H5F_MNT_SYM_LOCAL_DEF; /* Whether symlinks are local to file */ - - /*------------------------------------------------------------------------- * Function: H5P_fmnt_reg_prop * @@ -119,16 +109,15 @@ static const hbool_t H5F_def_local_g = H5F_MNT_SYM_LOCAL_DEF; /* Whether sy static herr_t H5P_fmnt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Register property of whether symlinks is local to file */ - if(H5P__register_real(pclass, H5F_MNT_SYM_LOCAL_NAME, H5F_MNT_SYM_LOCAL_SIZE, &H5F_def_local_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_MNT_SYM_LOCAL_NAME, H5F_MNT_SYM_LOCAL_SIZE, &H5F_def_local_g, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_fmnt_reg_prop() */ - diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 03874c8..811a569 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -26,41 +26,36 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ /* ========= Group Creation properties ============ */ -#define H5G_CRT_GROUP_INFO_ENC H5P__gcrt_group_info_enc -#define H5G_CRT_GROUP_INFO_DEC H5P__gcrt_group_info_dec -#define H5G_CRT_LINK_INFO_ENC H5P__gcrt_link_info_enc -#define H5G_CRT_LINK_INFO_DEC H5P__gcrt_link_info_dec - +#define H5G_CRT_GROUP_INFO_ENC H5P__gcrt_group_info_enc +#define H5G_CRT_GROUP_INFO_DEC H5P__gcrt_group_info_dec +#define H5G_CRT_LINK_INFO_ENC H5P__gcrt_link_info_enc +#define H5G_CRT_LINK_INFO_DEC H5P__gcrt_link_info_dec /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -74,46 +69,41 @@ static herr_t H5P__gcrt_group_info_dec(const void **_pp, void *value); static herr_t H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__gcrt_link_info_dec(const void **_pp, void *value); - /*********************/ /* Package Variables */ /*********************/ /* Group creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_GCRT[1] = {{ - "group create", /* Class name for debugging */ - H5P_TYPE_GROUP_CREATE, /* Class type */ - - &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ - &H5P_CLS_GROUP_CREATE_g, /* Pointer to class */ - &H5P_CLS_GROUP_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_GROUP_CREATE_ID_g, /* Pointer to default property list ID */ - H5P__gcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "group create", /* Class name for debugging */ + H5P_TYPE_GROUP_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_GROUP_CREATE_g, /* Pointer to class */ + &H5P_CLS_GROUP_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_GROUP_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__gcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const H5O_ginfo_t H5G_def_ginfo_g = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ -static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ +static const H5O_ginfo_t H5G_def_ginfo_g = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ +static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ - - /*------------------------------------------------------------------------- * Function: H5P__gcrt_reg_prop * @@ -128,27 +118,26 @@ static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Defaul static herr_t H5P__gcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register group info property */ - if(H5P__register_real(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, &H5G_def_ginfo_g, - NULL, NULL, NULL, H5G_CRT_GROUP_INFO_ENC, H5G_CRT_GROUP_INFO_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, &H5G_def_ginfo_g, NULL, + NULL, NULL, H5G_CRT_GROUP_INFO_ENC, H5G_CRT_GROUP_INFO_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register link info property */ - if(H5P__register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &H5G_def_linfo_g, - NULL, NULL, NULL, H5G_CRT_LINK_INFO_ENC, H5G_CRT_LINK_INFO_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &H5G_def_linfo_g, NULL, + NULL, NULL, H5G_CRT_LINK_INFO_ENC, H5G_CRT_LINK_INFO_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__gcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_local_heap_size_hint * @@ -163,33 +152,32 @@ done: herr_t H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", plist_id, size_hint); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") /* Update field */ H5_CHECKED_ASSIGN(ginfo.lheap_size_hint, uint32_t, size_hint, size_t); /* Set value */ - if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_local_heap_size_hint() */ - /*------------------------------------------------------------------------- * Function: H5Pget_local_heap_size_hint * @@ -205,21 +193,21 @@ done: herr_t H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint /*out*/) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, size_hint); - if(size_hint) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ + if (size_hint) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") /* Update field */ @@ -230,7 +218,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_local_heap_size_hint() */ - /*------------------------------------------------------------------------- * Function: H5Pset_link_phase_change * @@ -251,46 +238,45 @@ done: herr_t H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, max_compact, min_dense); /* Range check values */ - if(max_compact < min_dense) + if (max_compact < min_dense) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be >= min dense value") - if(max_compact > 65535) + if (max_compact > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be < 65536") - if(min_dense > 65535) + if (min_dense > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min dense value must be < 65536") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") /* Update fields */ - if(max_compact != H5G_CRT_GINFO_MAX_COMPACT || min_dense != H5G_CRT_GINFO_MIN_DENSE) + if (max_compact != H5G_CRT_GINFO_MAX_COMPACT || min_dense != H5G_CRT_GINFO_MIN_DENSE) ginfo.store_link_phase_change = TRUE; else ginfo.store_link_phase_change = FALSE; ginfo.max_compact = (uint16_t)max_compact; - ginfo.min_dense = (uint16_t)min_dense; + ginfo.min_dense = (uint16_t)min_dense; /* Set group info */ - if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_link_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pget_link_phase_change * @@ -306,27 +292,27 @@ done: herr_t H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned *min_dense /*out*/) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", plist_id, max_compact, min_dense); /* Get values */ - if(max_compact || min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ + if (max_compact || min_dense) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") - if(max_compact) + if (max_compact) *max_compact = ginfo.max_compact; - if(min_dense) + if (min_dense) *min_dense = ginfo.min_dense; } /* end if */ @@ -334,7 +320,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_link_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pset_est_link_info * @@ -357,44 +342,43 @@ done: herr_t H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name_len) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, est_num_entries, est_name_len); /* Range check values */ - if(est_num_entries > 65535) + if (est_num_entries > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "est. number of entries must be < 65536") - if(est_name_len > 65535) + if (est_name_len > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "est. name length must be < 65536") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") /* Update fields */ - if(est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) + if (est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) ginfo.store_est_entry_info = TRUE; else ginfo.store_est_entry_info = FALSE; ginfo.est_num_entries = (uint16_t)est_num_entries; - ginfo.est_name_len = (uint16_t)est_name_len; + ginfo.est_name_len = (uint16_t)est_name_len; /* Set group info */ - if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_est_link_info() */ - /*------------------------------------------------------------------------- * Function: H5Pget_est_link_info * @@ -410,27 +394,27 @@ done: herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /*out*/, unsigned *est_name_len /*out*/) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", plist_id, est_num_entries, est_name_len); /* Get values */ - if(est_num_entries || est_name_len) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ + if (est_num_entries || est_name_len) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") - if(est_num_entries) + if (est_num_entries) *est_num_entries = ginfo.est_num_entries; - if(est_name_len) + if (est_name_len) *est_name_len = ginfo.est_name_len; } /* end if */ @@ -438,7 +422,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_est_link_info() */ - /*------------------------------------------------------------------------- * Function: H5Pset_link_creation_order * @@ -453,23 +436,23 @@ done: herr_t H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_linfo_t linfo; /* Link information structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_linfo_t linfo; /* Link information structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, crt_order_flags); - /* Check for bad combination of flags */ - if(!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) + /* Check for bad combination of flags */ + if (!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tracking creation order is required for index") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get link info */ - if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") /* Update fields */ @@ -477,14 +460,13 @@ H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags) linfo.index_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE); /* Set link info */ - if(H5P_set(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_set(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_link_creation_order() */ - /*------------------------------------------------------------------------- * Function: H5Pget_link_creation_order * @@ -500,25 +482,25 @@ done: herr_t H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /*out*/) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, crt_order_flags); /* Get values */ - if(crt_order_flags) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_linfo_t linfo; /* Link information structure */ + if (crt_order_flags) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_linfo_t linfo; /* Link information structure */ /* Reset the value to return */ *crt_order_flags = 0; /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get link info */ - if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") *crt_order_flags |= linfo.track_corder ? H5P_CRT_ORDER_TRACKED : 0; @@ -529,7 +511,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_link_creation_order() */ - /*------------------------------------------------------------------------- * Function: H5P__gcrt_group_info_enc * @@ -549,11 +530,11 @@ static herr_t H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size) { const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)value; /* Create local aliases for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR - if(NULL != *pp) { + if (NULL != *pp) { UINT32ENCODE(*pp, ginfo->lheap_size_hint) UINT16ENCODE(*pp, ginfo->max_compact) UINT16ENCODE(*pp, ginfo->min_dense) @@ -566,7 +547,6 @@ H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__gcrt_group_info_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__gcrt_group_info_dec * @@ -585,9 +565,9 @@ H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__gcrt_group_info_dec(const void **_pp, void *_value) { - H5O_ginfo_t *ginfo = (H5O_ginfo_t *)_value; /* Group info settings */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_ginfo_t * ginfo = (H5O_ginfo_t *)_value; /* Group info settings */ + const uint8_t **pp = (const uint8_t **)_pp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -602,14 +582,13 @@ H5P__gcrt_group_info_dec(const void **_pp, void *_value) UINT16DECODE(*pp, ginfo->est_name_len) /* Update fields */ - if(ginfo->max_compact != H5G_CRT_GINFO_MAX_COMPACT || - ginfo->min_dense != H5G_CRT_GINFO_MIN_DENSE) + if (ginfo->max_compact != H5G_CRT_GINFO_MAX_COMPACT || ginfo->min_dense != H5G_CRT_GINFO_MIN_DENSE) ginfo->store_link_phase_change = TRUE; else ginfo->store_link_phase_change = FALSE; - if(ginfo->est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || - ginfo->est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) + if (ginfo->est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || + ginfo->est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) ginfo->store_est_entry_info = TRUE; else ginfo->store_est_entry_info = FALSE; @@ -617,7 +596,6 @@ H5P__gcrt_group_info_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__gcrt_group_info_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__gcrt_link_info_enc * @@ -637,11 +615,11 @@ static herr_t H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size) { const H5O_linfo_t *linfo = (const H5O_linfo_t *)value; /* Create local aliases for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR - if(NULL != *pp) { + if (NULL != *pp) { unsigned crt_order_flags = 0; crt_order_flags |= linfo->track_corder ? H5P_CRT_ORDER_TRACKED : 0; @@ -659,7 +637,6 @@ H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__gcrt_link_info_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__gcrt_link_info_dec * @@ -678,16 +655,16 @@ H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__gcrt_link_info_dec(const void **_pp, void *_value) { - H5O_linfo_t *linfo = (H5O_linfo_t *)_value; /* Link info settings */ - const uint8_t **pp = (const uint8_t **)_pp; - unsigned crt_order_flags; - unsigned enc_size; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t * linfo = (H5O_linfo_t *)_value; /* Link info settings */ + const uint8_t **pp = (const uint8_t **)_pp; + unsigned crt_order_flags; + unsigned enc_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* Set property to default value */ @@ -703,4 +680,3 @@ H5P__gcrt_link_info_dec(const void **_pp, void *_value) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__gcrt_link_info_dec() */ - diff --git a/src/H5Pint.c b/src/H5Pint.c index 19ed63e..f95af91 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -20,80 +20,76 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_PARALLEL -#include "H5ACprivate.h" /* Metadata cache */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Typedef for checking for duplicate class names in parent class */ typedef struct { - const H5P_genclass_t *parent; /* Pointer to parent class */ - const char *name; /* Pointer to name to check */ - H5P_genclass_t *new_class; /* Pointer to class during path traversal */ + const H5P_genclass_t *parent; /* Pointer to parent class */ + const char * name; /* Pointer to name to check */ + H5P_genclass_t * new_class; /* Pointer to class during path traversal */ } H5P_check_class_t; /* Typedef for property list iterator callback */ typedef struct { - H5P_iterate_int_t cb_func; /* Iterator callback */ - void *udata; /* Iterator callback pointer */ - const H5P_genplist_t *plist; /* Property list pointer */ - H5SL_t *seen; /* Skip list to hold names of properties already seen */ - int *curr_idx_ptr; /* Pointer to current iteration index */ - int prev_idx; /* Previous iteration index */ + H5P_iterate_int_t cb_func; /* Iterator callback */ + void * udata; /* Iterator callback pointer */ + const H5P_genplist_t *plist; /* Property list pointer */ + H5SL_t * seen; /* Skip list to hold names of properties already seen */ + int * curr_idx_ptr; /* Pointer to current iteration index */ + int prev_idx; /* Previous iteration index */ } H5P_iter_plist_ud_t; /* Typedef for property list class iterator callback */ typedef struct { - H5P_iterate_int_t cb_func; /* Iterator callback */ - void *udata; /* Iterator callback pointer */ - int *curr_idx_ptr; /* Pointer to current iteration index */ - int prev_idx; /* Previous iteration index */ + H5P_iterate_int_t cb_func; /* Iterator callback */ + void * udata; /* Iterator callback pointer */ + int * curr_idx_ptr; /* Pointer to current iteration index */ + int prev_idx; /* Previous iteration index */ } H5P_iter_pclass_ud_t; /* Typedef for property list comparison callback */ typedef struct { - const H5P_genplist_t *plist2; /* Pointer to second property list */ - int cmp_value; /* Value from property comparison */ + const H5P_genplist_t *plist2; /* Pointer to second property list */ + int cmp_value; /* Value from property comparison */ } H5P_plist_cmp_ud_t; /* Typedef for property list set/poke callbacks */ typedef struct { - const void *value; /* Pointer to value to set */ + const void *value; /* Pointer to value to set */ } H5P_prop_set_ud_t; /* Typedef for property list get/peek callbacks */ typedef struct { - void *value; /* Pointer for retrieved value */ + void *value; /* Pointer for retrieved value */ } H5P_prop_get_ud_t; /* Typedef for H5P__do_prop() callbacks */ typedef herr_t (*H5P_do_plist_op_t)(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *udata); + void *udata); typedef herr_t (*H5P_do_pclass_op_t)(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *udata); - + void *udata); /********************/ /* Local Prototypes */ @@ -101,24 +97,22 @@ typedef herr_t (*H5P_do_pclass_op_t)(H5P_genplist_t *plist, const char *name, H5 /* General helper routines */ static H5P_genplist_t *H5P__create(H5P_genclass_t *pclass); -static H5P_genprop_t *H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, - const void *value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, - H5P_prp_delete_func_t prp_delete, - H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, - H5P_prp_close_func_t prp_close); -static H5P_genprop_t *H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type); -static herr_t H5P__free_prop(H5P_genprop_t *prop); -static int H5P__cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2); -static herr_t H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op, - H5P_do_pclass_op_t pclass_op, void *udata); -static int H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key); -static H5P_genprop_t *H5P__find_prop_pclass(H5P_genclass_t *pclass, const char *name); -static herr_t H5P__free_prop_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data); +static H5P_genprop_t * H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, + const void *value, H5P_prp_create_func_t prp_create, + H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, + H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, + H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, + H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); +static H5P_genprop_t * H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type); +static herr_t H5P__free_prop(H5P_genprop_t *prop); +static int H5P__cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2); +static herr_t H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op, + H5P_do_pclass_op_t pclass_op, void *udata); +static int H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key); +static H5P_genprop_t * H5P__find_prop_pclass(H5P_genclass_t *pclass, const char *name); +static herr_t H5P__free_prop_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data); static herr_t H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op_data); - /*********************/ /* Package Variables */ /*********************/ @@ -127,200 +121,200 @@ static herr_t H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H * Predefined property list classes. These are initialized at runtime by * H5P__init_package() in this source file. */ -hid_t H5P_CLS_ROOT_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ROOT_g = NULL; -hid_t H5P_CLS_OBJECT_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g = NULL; -hid_t H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_FILE_CREATE_g = NULL; -hid_t H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_FILE_ACCESS_g = NULL; -hid_t H5P_CLS_DATASET_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATASET_CREATE_g = NULL; -hid_t H5P_CLS_DATASET_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATASET_ACCESS_g = NULL; -hid_t H5P_CLS_DATASET_XFER_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATASET_XFER_g = NULL; -hid_t H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_FILE_MOUNT_g = NULL; -hid_t H5P_CLS_GROUP_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_GROUP_CREATE_g = NULL; -hid_t H5P_CLS_GROUP_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g = NULL; -hid_t H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL; -hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; -hid_t H5P_CLS_MAP_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_MAP_CREATE_g = NULL; -hid_t H5P_CLS_MAP_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_MAP_ACCESS_g = NULL; -hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; -hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g = NULL; -hid_t H5P_CLS_OBJECT_COPY_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_OBJECT_COPY_g = NULL; -hid_t H5P_CLS_LINK_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_LINK_CREATE_g = NULL; -hid_t H5P_CLS_LINK_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL; -hid_t H5P_CLS_STRING_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL; -hid_t H5P_CLS_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_VOL_INITIALIZE_g = NULL; -hid_t H5P_CLS_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_REFERENCE_ACCESS_g = NULL; +hid_t H5P_CLS_ROOT_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ROOT_g = NULL; +hid_t H5P_CLS_OBJECT_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g = NULL; +hid_t H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_FILE_CREATE_g = NULL; +hid_t H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_FILE_ACCESS_g = NULL; +hid_t H5P_CLS_DATASET_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATASET_CREATE_g = NULL; +hid_t H5P_CLS_DATASET_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATASET_ACCESS_g = NULL; +hid_t H5P_CLS_DATASET_XFER_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATASET_XFER_g = NULL; +hid_t H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_FILE_MOUNT_g = NULL; +hid_t H5P_CLS_GROUP_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_GROUP_CREATE_g = NULL; +hid_t H5P_CLS_GROUP_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g = NULL; +hid_t H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL; +hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; +hid_t H5P_CLS_MAP_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_MAP_CREATE_g = NULL; +hid_t H5P_CLS_MAP_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_MAP_ACCESS_g = NULL; +hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; +hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g = NULL; +hid_t H5P_CLS_OBJECT_COPY_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_OBJECT_COPY_g = NULL; +hid_t H5P_CLS_LINK_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_LINK_CREATE_g = NULL; +hid_t H5P_CLS_LINK_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL; +hid_t H5P_CLS_STRING_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL; +hid_t H5P_CLS_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_VOL_INITIALIZE_g = NULL; +hid_t H5P_CLS_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_REFERENCE_ACCESS_g = NULL; /* * Predefined property lists for each predefined class. These are initialized * at runtime by H5P__init_package() in this source file. */ -hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_FILE_ACCESS_ANY_VFD_g = H5I_INVALID_HID; -hid_t H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATASET_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_GROUP_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_MAP_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_MAP_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_ACCESS_ANY_VFD_g = H5I_INVALID_HID; +hid_t H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATASET_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_GROUP_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_MAP_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_MAP_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; /* Root property list class library initialization object */ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ - "root", /* Class name for debugging */ - H5P_TYPE_ROOT, /* Class type */ - - NULL, /* Parent class */ - &H5P_CLS_ROOT_g, /* Pointer to class */ - &H5P_CLS_ROOT_ID_g, /* Pointer to class ID */ - NULL, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "root", /* Class name for debugging */ + H5P_TYPE_ROOT, /* Class type */ + + NULL, /* Parent class */ + &H5P_CLS_ROOT_g, /* Pointer to class */ + &H5P_CLS_ROOT_ID_g, /* Pointer to class ID */ + NULL, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Attribute access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_AACC[1] = {{ - "attribute access", /* Class name for debugging */ - H5P_TYPE_ATTRIBUTE_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_ATTRIBUTE_ACCESS_g, /* Pointer to class */ - &H5P_CLS_ATTRIBUTE_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_ATTRIBUTE_ACCESS_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "attribute access", /* Class name for debugging */ + H5P_TYPE_ATTRIBUTE_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_ATTRIBUTE_ACCESS_g, /* Pointer to class */ + &H5P_CLS_ATTRIBUTE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_ATTRIBUTE_ACCESS_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Group access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_GACC[1] = {{ - "group access", /* Class name for debugging */ - H5P_TYPE_GROUP_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_GROUP_ACCESS_g, /* Pointer to class */ - &H5P_CLS_GROUP_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_GROUP_ACCESS_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "group access", /* Class name for debugging */ + H5P_TYPE_GROUP_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_GROUP_ACCESS_g, /* Pointer to class */ + &H5P_CLS_GROUP_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_GROUP_ACCESS_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Datatype creation property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_TCRT[1] = {{ - "datatype create", /* Class name for debugging */ - H5P_TYPE_DATATYPE_CREATE, /* Class type */ - - &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ - &H5P_CLS_DATATYPE_CREATE_g, /* Pointer to class */ - &H5P_CLS_DATATYPE_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_DATATYPE_CREATE_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "datatype create", /* Class name for debugging */ + H5P_TYPE_DATATYPE_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_DATATYPE_CREATE_g, /* Pointer to class */ + &H5P_CLS_DATATYPE_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_DATATYPE_CREATE_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Datatype access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_TACC[1] = {{ - "datatype access", /* Class name for debugging */ - H5P_TYPE_DATATYPE_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_DATATYPE_ACCESS_g, /* Pointer to class */ - &H5P_CLS_DATATYPE_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_DATATYPE_ACCESS_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "datatype access", /* Class name for debugging */ + H5P_TYPE_DATATYPE_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_DATATYPE_ACCESS_g, /* Pointer to class */ + &H5P_CLS_DATATYPE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_DATATYPE_ACCESS_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* VOL initialization property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_VINI[1] = {{ - "VOL initialization", /* Class name for debugging */ - H5P_TYPE_VOL_INITIALIZE, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_VOL_INITIALIZE_g, /* Pointer to class */ - &H5P_CLS_VOL_INITIALIZE_ID_g, /* Pointer to class ID */ - &H5P_LST_VOL_INITIALIZE_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "VOL initialization", /* Class name for debugging */ + H5P_TYPE_VOL_INITIALIZE, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_VOL_INITIALIZE_g, /* Pointer to class */ + &H5P_CLS_VOL_INITIALIZE_ID_g, /* Pointer to class ID */ + &H5P_LST_VOL_INITIALIZE_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Reference access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_RACC[1] = {{ - "reference access", /* Class name for debugging */ - H5P_TYPE_REFERENCE_ACCESS, /* Class type */ + "reference access", /* Class name for debugging */ + H5P_TYPE_REFERENCE_ACCESS, /* Class type */ &H5P_CLS_FILE_ACCESS_g, /* Parent class */ &H5P_CLS_REFERENCE_ACCESS_g, /* Pointer to class */ @@ -328,67 +322,65 @@ const H5P_libclass_t H5P_CLS_RACC[1] = {{ &H5P_LST_REFERENCE_ACCESS_ID_g, /* Pointer to default property list ID */ NULL, /* Default property registration routine*/ - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Library property list classes defined in other code modules */ /* (And not present in src/H5Pprivate.h) */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_OCRT[1]; /* Object creation */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_STRCRT[1]; /* String create */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_GCRT[1]; /* Group create */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_FCRT[1]; /* File creation */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_DCRT[1]; /* Dataset creation */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_MCRT[1]; /* Map creation */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_DXFR[1]; /* Data transfer */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_FMNT[1]; /* File mount */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_ACRT[1]; /* Attribute creation */ - +H5_DLLVAR const H5P_libclass_t H5P_CLS_OCRT[1]; /* Object creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_STRCRT[1]; /* String create */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_GCRT[1]; /* Group create */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_FCRT[1]; /* File creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_DCRT[1]; /* Dataset creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_MCRT[1]; /* Map creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_DXFR[1]; /* Data transfer */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_FMNT[1]; /* File mount */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_ACRT[1]; /* Attribute creation */ /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Track the revision count of a class, to make comparisons faster */ static unsigned H5P_next_rev = 0; -#define H5P_GET_NEXT_REV (H5P_next_rev++) +#define H5P_GET_NEXT_REV (H5P_next_rev++) /* List of all property list classes in the library */ /* (order here is not important, they will be initialized in the proper * order according to their parent class dependencies) */ -static H5P_libclass_t const * const init_class[] = { - H5P_CLS_ROOT, /* Root */ - H5P_CLS_OCRT, /* Object create */ - H5P_CLS_STRCRT, /* String create */ - H5P_CLS_LACC, /* Link access */ - H5P_CLS_GCRT, /* Group create */ - H5P_CLS_OCPY, /* Object copy */ - H5P_CLS_GACC, /* Group access */ - H5P_CLS_FCRT, /* File creation */ - H5P_CLS_FACC, /* File access */ - H5P_CLS_DCRT, /* Dataset creation */ - H5P_CLS_DACC, /* Dataset access */ - H5P_CLS_DXFR, /* Data transfer */ - H5P_CLS_FMNT, /* File mount */ - H5P_CLS_TCRT, /* Datatype creation */ - H5P_CLS_TACC, /* Datatype access */ - H5P_CLS_MCRT, /* Map creation */ - H5P_CLS_MACC, /* Map access */ - H5P_CLS_ACRT, /* Attribute creation */ - H5P_CLS_AACC, /* Attribute access */ - H5P_CLS_LCRT, /* Link creation */ - H5P_CLS_VINI, /* VOL initialization */ - H5P_CLS_RACC /* Reference access */ +static H5P_libclass_t const *const init_class[] = { + H5P_CLS_ROOT, /* Root */ + H5P_CLS_OCRT, /* Object create */ + H5P_CLS_STRCRT, /* String create */ + H5P_CLS_LACC, /* Link access */ + H5P_CLS_GCRT, /* Group create */ + H5P_CLS_OCPY, /* Object copy */ + H5P_CLS_GACC, /* Group access */ + H5P_CLS_FCRT, /* File creation */ + H5P_CLS_FACC, /* File access */ + H5P_CLS_DCRT, /* Dataset creation */ + H5P_CLS_DACC, /* Dataset access */ + H5P_CLS_DXFR, /* Data transfer */ + H5P_CLS_FMNT, /* File mount */ + H5P_CLS_TCRT, /* Datatype creation */ + H5P_CLS_TACC, /* Datatype access */ + H5P_CLS_MCRT, /* Map creation */ + H5P_CLS_MACC, /* Map access */ + H5P_CLS_ACRT, /* Attribute creation */ + H5P_CLS_AACC, /* Attribute access */ + H5P_CLS_LCRT, /* Link creation */ + H5P_CLS_VINI, /* VOL initialization */ + H5P_CLS_RACC /* Reference access */ }; /* Declare a free list to manage the H5P_genclass_t struct */ @@ -402,22 +394,20 @@ H5FL_DEFINE_STATIC(H5P_genplist_t); /* Generic Property Class ID class */ static const H5I_class_t H5I_GENPROPCLS_CLS[1] = {{ - H5I_GENPROP_CLS, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5P__close_class /* Callback routine for closing objects of this class */ + H5I_GENPROP_CLS, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5P__close_class /* Callback routine for closing objects of this class */ }}; /* Generic Property List ID class */ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ - H5I_GENPROP_LST, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5P_close /* Callback routine for closing objects of this class */ + H5I_GENPROP_LST, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5P_close /* Callback routine for closing objects of this class */ }}; - - /*------------------------------------------------------------------------- * Function: H5P_init * @@ -434,7 +424,7 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ herr_t H5P_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -443,7 +433,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_init() */ - /*-------------------------------------------------------------------------- NAME H5P__init_package -- Initialize interface-specific information @@ -457,9 +446,9 @@ DESCRIPTION herr_t H5P__init_package(void) { - size_t tot_init; /* Total # of classes initialized */ - size_t pass_init; /* # of classes initialized in each pass */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t tot_init; /* Total # of classes initialized */ + size_t pass_init; /* # of classes initialized in each pass */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -469,9 +458,9 @@ H5P__init_package(void) /* * Initialize the Generic Property class & object groups. */ - if(H5I_register_type(H5I_GENPROPCLS_CLS) < 0) + if (H5I_register_type(H5I_GENPROPCLS_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") - if(H5I_register_type(H5I_GENPROPLST_CLS) < 0) + if (H5I_register_type(H5I_GENPROPLST_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") /* Repeatedly pass over the list of property list classes for the library, @@ -480,47 +469,52 @@ H5P__init_package(void) */ tot_init = 0; do { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ /* Reset pass initialization counter */ pass_init = 0; /* Make a pass over all the library's property list classes */ - for(u = 0; u < NELMTS(init_class); u++) { + for (u = 0; u < NELMTS(init_class); u++) { H5P_libclass_t const *lib_class = init_class[u]; /* Current class to operate on */ /* Check if the current class hasn't been initialized and can be now */ HDassert(lib_class->class_id); - if(*lib_class->class_id == (-1) && (lib_class->par_pclass == NULL - || *lib_class->par_pclass != NULL)) { + if (*lib_class->class_id == (-1) && + (lib_class->par_pclass == NULL || *lib_class->par_pclass != NULL)) { /* Sanity check - only the root class is not allowed to have a parent class */ HDassert(lib_class->par_pclass || lib_class == H5P_CLS_ROOT); /* Allocate the new class */ - if(NULL == (*lib_class->pclass = H5P__create_class(lib_class->par_pclass ? *lib_class->par_pclass : NULL, lib_class->name, lib_class->type, lib_class->create_func, lib_class->create_data, lib_class->copy_func, lib_class->copy_data, lib_class->close_func, lib_class->close_data))) + if (NULL == (*lib_class->pclass = H5P__create_class( + lib_class->par_pclass ? *lib_class->par_pclass : NULL, lib_class->name, + lib_class->type, lib_class->create_func, lib_class->create_data, + lib_class->copy_func, lib_class->copy_data, lib_class->close_func, + lib_class->close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed") /* Call routine to register properties for class */ - if(lib_class->reg_prop_func && (*lib_class->reg_prop_func)(*lib_class->pclass) < 0) + if (lib_class->reg_prop_func && (*lib_class->reg_prop_func)(*lib_class->pclass) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register properties") /* Register the new class */ - if((*lib_class->class_id = H5I_register(H5I_GENPROP_CLS, *lib_class->pclass, FALSE)) < 0) + if ((*lib_class->class_id = H5I_register(H5I_GENPROP_CLS, *lib_class->pclass, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class") /* Only register the default property list if it hasn't been created yet */ - if(lib_class->def_plist_id && *lib_class->def_plist_id == (-1)) { + if (lib_class->def_plist_id && *lib_class->def_plist_id == (-1)) { /* Register the default property list for the new class*/ - if((*lib_class->def_plist_id = H5P_create_id(*lib_class->pclass, FALSE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list for class") + if ((*lib_class->def_plist_id = H5P_create_id(*lib_class->pclass, FALSE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, + "can't register default property list for class") } /* end if */ /* Increment class initialization counters */ pass_init++; tot_init++; } /* end if */ - } /* end for */ - } while(pass_init > 0); + } /* end for */ + } while (pass_init > 0); /* Verify that all classes were initialized */ HDassert(tot_init == NELMTS(init_class)); @@ -529,7 +523,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__init_package() */ - /*-------------------------------------------------------------------------- NAME H5P_term_package @@ -550,119 +543,85 @@ done: int H5P_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - int64_t nlist, nclass; + if (H5_PKG_INIT_VAR) { + int64_t nlist, nclass; /* Destroy HDF5 library property classes & lists */ /* Check if there are any open property list classes or lists */ nclass = H5I_nmembers(H5I_GENPROP_CLS); - nlist = H5I_nmembers(H5I_GENPROP_LST); + nlist = H5I_nmembers(H5I_GENPROP_LST); /* If there are any open classes or groups, attempt to get rid of them. */ - if((nclass + nlist) > 0) { + if ((nclass + nlist) > 0) { /* Clear the lists */ - if(nlist > 0) { + if (nlist > 0) { (void)H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE); /* Reset the default property lists, if they've been closed */ - if(H5I_nmembers(H5I_GENPROP_LST) == 0) { - H5P_LST_FILE_CREATE_ID_g = - H5P_LST_FILE_ACCESS_ID_g = - H5P_LST_DATASET_CREATE_ID_g = - H5P_LST_DATASET_ACCESS_ID_g = - H5P_LST_DATASET_XFER_ID_g = - H5P_LST_GROUP_CREATE_ID_g = - H5P_LST_GROUP_ACCESS_ID_g = - H5P_LST_DATATYPE_CREATE_ID_g = - H5P_LST_DATATYPE_ACCESS_ID_g = - H5P_LST_MAP_CREATE_ID_g = - H5P_LST_MAP_ACCESS_ID_g = - H5P_LST_ATTRIBUTE_CREATE_ID_g = - H5P_LST_ATTRIBUTE_ACCESS_ID_g = - H5P_LST_OBJECT_COPY_ID_g = - H5P_LST_LINK_CREATE_ID_g = - H5P_LST_LINK_ACCESS_ID_g = - H5P_LST_VOL_INITIALIZE_ID_g = - H5P_LST_REFERENCE_ACCESS_ID_g = - H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; + if (H5I_nmembers(H5I_GENPROP_LST) == 0) { + H5P_LST_FILE_CREATE_ID_g = H5P_LST_FILE_ACCESS_ID_g = H5P_LST_DATASET_CREATE_ID_g = + H5P_LST_DATASET_ACCESS_ID_g = H5P_LST_DATASET_XFER_ID_g = H5P_LST_GROUP_CREATE_ID_g = + H5P_LST_GROUP_ACCESS_ID_g = H5P_LST_DATATYPE_CREATE_ID_g = + H5P_LST_DATATYPE_ACCESS_ID_g = H5P_LST_MAP_CREATE_ID_g = + H5P_LST_MAP_ACCESS_ID_g = H5P_LST_ATTRIBUTE_CREATE_ID_g = + H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5P_LST_OBJECT_COPY_ID_g = + H5P_LST_LINK_CREATE_ID_g = H5P_LST_LINK_ACCESS_ID_g = + H5P_LST_VOL_INITIALIZE_ID_g = H5P_LST_REFERENCE_ACCESS_ID_g = + H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; } /* end if */ - } /* end if */ + } /* end if */ /* Only attempt to close the classes after all the lists are closed */ - if(nlist == 0 && nclass > 0) { + if (nlist == 0 && nclass > 0) { (void)H5I_clear_type(H5I_GENPROP_CLS, FALSE, FALSE); /* Reset the default property classes, if they've been closed */ - if(H5I_nmembers(H5I_GENPROP_CLS) == 0) { - H5P_CLS_ROOT_g = - H5P_CLS_OBJECT_CREATE_g = - H5P_CLS_FILE_CREATE_g = - H5P_CLS_FILE_ACCESS_g = - H5P_CLS_DATASET_CREATE_g = - H5P_CLS_DATASET_ACCESS_g = - H5P_CLS_DATASET_XFER_g = - H5P_CLS_GROUP_CREATE_g = - H5P_CLS_GROUP_ACCESS_g = - H5P_CLS_DATATYPE_CREATE_g = - H5P_CLS_DATATYPE_ACCESS_g = - H5P_CLS_MAP_CREATE_g = - H5P_CLS_MAP_ACCESS_g = - H5P_CLS_STRING_CREATE_g = - H5P_CLS_ATTRIBUTE_CREATE_g = - H5P_CLS_ATTRIBUTE_ACCESS_g = - H5P_CLS_OBJECT_COPY_g = - H5P_CLS_LINK_CREATE_g = - H5P_CLS_LINK_ACCESS_g = - H5P_CLS_VOL_INITIALIZE_g = - H5P_CLS_REFERENCE_ACCESS_g = - H5P_CLS_FILE_MOUNT_g = NULL; - - H5P_CLS_ROOT_ID_g = - H5P_CLS_OBJECT_CREATE_ID_g = - H5P_CLS_FILE_CREATE_ID_g = - H5P_CLS_FILE_ACCESS_ID_g = - H5P_CLS_DATASET_CREATE_ID_g = - H5P_CLS_DATASET_ACCESS_ID_g = - H5P_CLS_DATASET_XFER_ID_g = - H5P_CLS_GROUP_CREATE_ID_g = - H5P_CLS_GROUP_ACCESS_ID_g = - H5P_CLS_DATATYPE_CREATE_ID_g = - H5P_CLS_DATATYPE_ACCESS_ID_g = - H5P_CLS_MAP_CREATE_ID_g = - H5P_CLS_MAP_ACCESS_ID_g = - H5P_CLS_STRING_CREATE_ID_g = - H5P_CLS_ATTRIBUTE_CREATE_ID_g = - H5P_CLS_ATTRIBUTE_ACCESS_ID_g = - H5P_CLS_OBJECT_COPY_ID_g = - H5P_CLS_LINK_CREATE_ID_g = - H5P_CLS_LINK_ACCESS_ID_g = - H5P_CLS_VOL_INITIALIZE_ID_g = - H5P_CLS_REFERENCE_ACCESS_ID_g = - H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; + if (H5I_nmembers(H5I_GENPROP_CLS) == 0) { + H5P_CLS_ROOT_g = H5P_CLS_OBJECT_CREATE_g = H5P_CLS_FILE_CREATE_g = H5P_CLS_FILE_ACCESS_g = + H5P_CLS_DATASET_CREATE_g = H5P_CLS_DATASET_ACCESS_g = H5P_CLS_DATASET_XFER_g = + H5P_CLS_GROUP_CREATE_g = H5P_CLS_GROUP_ACCESS_g = H5P_CLS_DATATYPE_CREATE_g = + H5P_CLS_DATATYPE_ACCESS_g = H5P_CLS_MAP_CREATE_g = H5P_CLS_MAP_ACCESS_g = + H5P_CLS_STRING_CREATE_g = H5P_CLS_ATTRIBUTE_CREATE_g = + H5P_CLS_ATTRIBUTE_ACCESS_g = H5P_CLS_OBJECT_COPY_g = + H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = + H5P_CLS_VOL_INITIALIZE_g = H5P_CLS_REFERENCE_ACCESS_g = + H5P_CLS_FILE_MOUNT_g = NULL; + + H5P_CLS_ROOT_ID_g = H5P_CLS_OBJECT_CREATE_ID_g = H5P_CLS_FILE_CREATE_ID_g = + H5P_CLS_FILE_ACCESS_ID_g = H5P_CLS_DATASET_CREATE_ID_g = H5P_CLS_DATASET_ACCESS_ID_g = + H5P_CLS_DATASET_XFER_ID_g = H5P_CLS_GROUP_CREATE_ID_g = + H5P_CLS_GROUP_ACCESS_ID_g = H5P_CLS_DATATYPE_CREATE_ID_g = + H5P_CLS_DATATYPE_ACCESS_ID_g = H5P_CLS_MAP_CREATE_ID_g = + H5P_CLS_MAP_ACCESS_ID_g = H5P_CLS_STRING_CREATE_ID_g = + H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5P_CLS_ATTRIBUTE_ACCESS_ID_g = + H5P_CLS_OBJECT_COPY_ID_g = H5P_CLS_LINK_CREATE_ID_g = + H5P_CLS_LINK_ACCESS_ID_g = H5P_CLS_VOL_INITIALIZE_ID_g = + H5P_CLS_REFERENCE_ACCESS_ID_g = + H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; } /* end if */ - } /* end if */ + } /* end if */ n++; /*H5I*/ - } else { + } + else { /* Destroy the property list and class id groups */ n += (H5I_dec_type_ref(H5I_GENPROP_LST) > 0); n += (H5I_dec_type_ref(H5I_GENPROP_CLS) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5P_term_package() */ - /*-------------------------------------------------------------------------- NAME H5P__do_prop_cb1 @@ -688,9 +647,9 @@ H5P_term_package(void) static herr_t H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) { - void *tmp_value = NULL; /* Temporary value buffer */ - H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ - herr_t ret_value = SUCCEED; /* Return value */ + void * tmp_value = NULL; /* Temporary value buffer */ + H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -701,39 +660,38 @@ H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) HDassert(cb); /* Allocate space for a temporary copy of the property value */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) + if (NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value") H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call "type 1" callback ('create', 'copy' or 'close') */ - if(cb(prop->name, prop->size, tmp_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Property callback failed") + if (cb(prop->name, prop->size, tmp_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "Property callback failed") /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) + if (NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") /* Copy the changed value into the new property */ H5MM_memcpy(pcopy->value, tmp_value, prop->size); /* Insert the changed property into the property list */ - if(H5P__add_prop(slist, pcopy) < 0) + if (H5P__add_prop(slist, pcopy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into skip list") done: /* Release the temporary value buffer */ - if(tmp_value) + if (tmp_value) H5MM_xfree(tmp_value); /* Cleanup on failure */ - if(ret_value < 0) - if(pcopy) + if (ret_value < 0) + if (pcopy) H5P__free_prop(pcopy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__do_prop_cb1() */ - /*-------------------------------------------------------------------------- NAME H5P__copy_pclass @@ -757,9 +715,9 @@ done: H5P_genclass_t * H5P__copy_pclass(H5P_genclass_t *pclass) { - H5P_genclass_t *new_pclass = NULL; /* Property list class copied */ - H5P_genprop_t *pcopy; /* Copy of property to insert into class */ - H5P_genclass_t *ret_value=NULL; /* return value */ + H5P_genclass_t *new_pclass = NULL; /* Property list class copied */ + H5P_genprop_t * pcopy; /* Copy of property to insert into class */ + H5P_genclass_t *ret_value = NULL; /* return value */ FUNC_ENTER_PACKAGE @@ -770,43 +728,44 @@ H5P__copy_pclass(H5P_genclass_t *pclass) */ /* Create the new property list class */ - if(NULL == (new_pclass = H5P__create_class(pclass->parent, pclass->name, pclass->type, pclass->create_func, pclass->create_data, pclass->copy_func, pclass->copy_data, pclass->close_func, pclass->close_data))) + if (NULL == (new_pclass = H5P__create_class(pclass->parent, pclass->name, pclass->type, + pclass->create_func, pclass->create_data, pclass->copy_func, + pclass->copy_data, pclass->close_func, pclass->close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "unable to create property list class") /* Copy the properties registered for this class */ - if(pclass->nprops > 0) { - H5SL_node_t *curr_node; /* Current node in skip list */ + if (pclass->nprops > 0) { + H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ - curr_node=H5SL_first(pclass->props); - while(curr_node!=NULL) { + curr_node = H5SL_first(pclass->props); + while (curr_node != NULL) { /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL,"Can't copy property") + if (NULL == (pcopy = H5P__dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "Can't copy property") /* Insert the initialized property into the property list */ - if(H5P__add_prop(new_pclass->props,pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, NULL,"Can't insert property into class") + if (H5P__add_prop(new_pclass->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, NULL, "Can't insert property into class") /* Increment property count for class */ new_pclass->nprops++; /* Get the next property node in the list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Set the return value */ - ret_value=new_pclass; + ret_value = new_pclass; done: - if(NULL == ret_value && new_pclass) + if (NULL == ret_value && new_pclass) H5P__close_class(new_pclass); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__copy_pclass() */ +} /* H5P__copy_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P_copy_plist @@ -831,16 +790,16 @@ done: hid_t H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genplist_t *new_plist=NULL; /* New property list generated from copy */ - H5P_genprop_t *tmp; /* Temporary pointer to properties */ - H5P_genprop_t *new_prop; /* New property created for copy */ - hid_t new_plist_id; /* Property list ID of new list created */ - H5SL_node_t *curr_node; /* Current node in skip list */ - H5SL_t *seen=NULL; /* Skip list containing properties already seen */ - size_t nseen; /* Number of items 'seen' */ - hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genplist_t *new_plist = NULL; /* New property list generated from copy */ + H5P_genprop_t * tmp; /* Temporary pointer to properties */ + H5P_genprop_t * new_prop; /* New property created for copy */ + hid_t new_plist_id; /* Property list ID of new list created */ + H5SL_node_t * curr_node; /* Current node in skip list */ + H5SL_t * seen = NULL; /* Skip list containing properties already seen */ + size_t nseen; /* Number of items 'seen' */ + hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -851,83 +810,88 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) */ /* Allocate room for the property list */ - if(NULL==(new_plist = H5FL_CALLOC(H5P_genplist_t))) + if (NULL == (new_plist = H5FL_CALLOC(H5P_genplist_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Set class state */ - new_plist->pclass = old_plist->pclass; - new_plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ - new_plist->class_init = FALSE; /* Initially, wait until the class callback finishes to set */ + new_plist->pclass = old_plist->pclass; + new_plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ + new_plist->class_init = FALSE; /* Initially, wait until the class callback finishes to set */ /* Initialize the skip list to hold the changed properties */ - if((new_plist->props = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "can't create skip list for changed properties") + if ((new_plist->props = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, + "can't create skip list for changed properties") /* Create the skip list for deleted properties */ - if((new_plist->del = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "can't create skip list for deleted properties") + if ((new_plist->del = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, + "can't create skip list for deleted properties") /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'create' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + if ((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "can't create skip list for seen properties") nseen = 0; /* Cycle through the deleted properties & copy them into the new list's deleted section */ - if(H5SL_count(old_plist->del) > 0) { + if (H5SL_count(old_plist->del) > 0) { curr_node = H5SL_first(old_plist->del); - while(curr_node) { - char *new_name; /* Pointer to new name */ + while (curr_node) { + char *new_name; /* Pointer to new name */ /* Duplicate string for insertion into new deleted property skip list */ - if((new_name = H5MM_xstrdup((char *)H5SL_item(curr_node))) == NULL) + if ((new_name = H5MM_xstrdup((char *)H5SL_item(curr_node))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Insert property name into deleted list */ - if(H5SL_insert(new_plist->del,new_name,new_name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert property into deleted skip list") + if (H5SL_insert(new_plist->del, new_name, new_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, + "can't insert property into deleted skip list") /* Add property name to "seen" list */ - if(H5SL_insert(seen,new_name,new_name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert property into seen skip list") + if (H5SL_insert(seen, new_name, new_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, + "can't insert property into seen skip list") nseen++; /* Get the next property node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Cycle through the properties and copy them also */ - if(H5SL_count(old_plist->props) > 0) { + if (H5SL_count(old_plist->props) > 0) { curr_node = H5SL_first(old_plist->props); - while(curr_node) { + while (curr_node) { /* Get a pointer to the node's property */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Make a copy of the list's property */ - if(NULL == (new_prop = H5P__dup_prop(tmp, H5P_PROP_WITHIN_LIST))) + if (NULL == (new_prop = H5P__dup_prop(tmp, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "Can't copy property") /* Call property copy callback, if it exists */ - if(new_prop->copy) { - if((new_prop->copy)(new_prop->name,new_prop->size,new_prop->value) < 0) { + if (new_prop->copy) { + if ((new_prop->copy)(new_prop->name, new_prop->size, new_prop->value) < 0) { H5P__free_prop(new_prop); HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "Can't copy property") } /* end if */ - } /* end if */ + } /* end if */ /* Insert the initialized property into the property list */ - if(H5P__add_prop(new_plist->props,new_prop) < 0) { + if (H5P__add_prop(new_plist->props, new_prop) < 0) { H5P__free_prop(new_prop); HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "Can't insert property into list") } /* end if */ /* Add property name to "seen" list */ - if(H5SL_insert(seen,new_prop->name,new_prop->name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert property into seen skip list") + if (H5SL_insert(seen, new_prop->name, new_prop->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, + "can't insert property into seen skip list") nseen++; /* Increment the number of properties in list */ @@ -936,35 +900,36 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) /* Get the next property node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* * Check for copying class properties (up through list of parent classes also), * initialize each with default value & make property 'copy' callback. */ - tclass=old_plist->pclass; + tclass = old_plist->pclass; has_parent_class = (hbool_t)(tclass != NULL && tclass->parent != NULL && tclass->parent->nprops > 0); - while(tclass != NULL) { - if(tclass->nprops>0) { + while (tclass != NULL) { + if (tclass->nprops > 0) { /* Walk through the properties in the old class */ curr_node = H5SL_first(tclass->props); - while(curr_node!=NULL) { + while (curr_node != NULL) { /* Get pointer to property from node */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Only "copy" properties we haven't seen before */ - if(nseen == 0 || H5SL_search(seen,tmp->name) == NULL) { + if (nseen == 0 || H5SL_search(seen, tmp->name) == NULL) { /* Call property copy callback, if it exists */ - if(tmp->copy) { + if (tmp->copy) { /* Call the callback & insert changed value into skip list (if necessary) */ - if(H5P__do_prop_cb1(new_plist->props, tmp, tmp->copy) < 0) + if (H5P__do_prop_cb1(new_plist->props, tmp, tmp->copy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "Can't create property") } /* end if */ /* Add property name to "seen" list, if we have other classes to work on */ - if(has_parent_class) { - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert property into seen skip list") + if (has_parent_class) { + if (H5SL_insert(seen, tmp->name, tmp->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, + "can't insert property into seen skip list") nseen++; } /* end if */ @@ -975,35 +940,36 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) /* Get the next property node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Go up to parent class */ tclass = tclass->parent; } /* end while */ /* Increment the number of property lists derived from class */ - if(H5P__access_class(new_plist->pclass, H5P_MOD_INC_LST) < 0) + if (H5P__access_class(new_plist->pclass, H5P_MOD_INC_LST) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't increment class ref count") /* Get an atom for the property list */ - if((new_plist_id = H5I_register(H5I_GENPROP_LST, new_plist, app_ref)) < 0) + if ((new_plist_id = H5I_register(H5I_GENPROP_LST, new_plist, app_ref)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list") - /* Save the property list ID in the property list struct, for use in the property class's 'close' callback */ + /* Save the property list ID in the property list struct, for use in the property class's 'close' callback + */ new_plist->plist_id = new_plist_id; /* Call the class callback (if it exists) now that we have the property list ID * (up through chain of parent classes also) */ tclass = new_plist->pclass; - while(NULL != tclass) { - if(NULL != tclass->copy_func) { - if((tclass->copy_func)(new_plist_id, old_plist->plist_id, old_plist->pclass->copy_data) < 0) { + while (NULL != tclass) { + if (NULL != tclass->copy_func) { + if ((tclass->copy_func)(new_plist_id, old_plist->plist_id, old_plist->pclass->copy_data) < 0) { /* Delete ID, ignore return value */ H5I_remove(new_plist_id); HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't initialize property") } /* end if */ - } /* end if */ + } /* end if */ /* Go up to parent class */ tclass = tclass->parent; @@ -1013,20 +979,19 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) new_plist->class_init = TRUE; /* Set the return value */ - ret_value=new_plist_id; + ret_value = new_plist_id; done: /* Release the list of 'seen' properties */ - if(seen != NULL) + if (seen != NULL) H5SL_close(seen); - if(H5I_INVALID_HID == ret_value && new_plist) + if (H5I_INVALID_HID == ret_value && new_plist) H5P_close(new_plist); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_copy_plist() */ +} /* H5P_copy_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__dup_prop @@ -1049,7 +1014,7 @@ done: static H5P_genprop_t * H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) { - H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ + H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1058,7 +1023,7 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) HDassert(type != H5P_PROP_WITHIN_UNKNOWN); /* Allocate the new property */ - if(NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) + if (NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy basic property information */ @@ -1067,7 +1032,7 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) /* Check if we should duplicate the name or share it */ /* Duplicating property for a class */ - if(type == H5P_PROP_WITHIN_CLASS) { + if (type == H5P_PROP_WITHIN_CLASS) { HDassert(oprop->type == H5P_PROP_WITHIN_CLASS); HDassert(oprop->shared_name == FALSE); @@ -1079,9 +1044,9 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) /* Check if we are duplicating a property from a list or a class */ /* Duplicating a property from a list */ - if(oprop->type == H5P_PROP_WITHIN_LIST) { + if (oprop->type == H5P_PROP_WITHIN_LIST) { /* If the old property's name wasn't shared, we have to copy it here also */ - if(!oprop->shared_name) + if (!oprop->shared_name) prop->name = H5MM_xstrdup(oprop->name); } /* end if */ /* Duplicating a property from a class */ @@ -1095,12 +1060,12 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) /* Set the type */ prop->type = type; } /* end else */ - } /* end else */ + } /* end else */ /* Duplicate current value, if it exists */ - if(oprop->value != NULL) { + if (oprop->value != NULL) { HDassert(prop->size > 0); - if(NULL == (prop->value = H5MM_malloc(prop->size))) + if (NULL == (prop->value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(prop->value, oprop->value, prop->size); } /* end if */ @@ -1110,20 +1075,19 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) done: /* Free any resources allocated */ - if(ret_value == NULL) { - if(prop != NULL) { - if(prop->name != NULL) + if (ret_value == NULL) { + if (prop != NULL) { + if (prop->name != NULL) H5MM_xfree(prop->name); - if(prop->value != NULL) + if (prop->value != NULL) H5MM_xfree(prop->value); prop = H5FL_FREE(H5P_genprop_t, prop); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__dup_prop() */ +} /* H5P__dup_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__create_prop @@ -1158,15 +1122,13 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static H5P_genprop_t * -H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, - const void *value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, - H5P_prp_delete_func_t prp_delete, - H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, - H5P_prp_close_func_t prp_close) +H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, const void *value, + H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, + H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, + H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, + H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { - H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ + H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1176,18 +1138,18 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, HDassert(type != H5P_PROP_WITHIN_UNKNOWN); /* Allocate the new property */ - if(NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) + if (NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the property initial values */ - prop->name = H5MM_xstrdup(name); /* Duplicate name */ + prop->name = H5MM_xstrdup(name); /* Duplicate name */ prop->shared_name = FALSE; - prop->size = size; - prop->type = type; + prop->size = size; + prop->type = type; /* Duplicate value, if it exists */ - if(value != NULL) { - if(NULL == (prop->value = H5MM_malloc (prop->size))) + if (value != NULL) { + if (NULL == (prop->value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(prop->value, value, prop->size); } /* end if */ @@ -1196,14 +1158,14 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, /* Set the function pointers */ prop->create = prp_create; - prop->set = prp_set; - prop->get = prp_get; + prop->set = prp_set; + prop->get = prp_get; prop->encode = prp_encode; prop->decode = prp_decode; - prop->del = prp_delete; - prop->copy = prp_copy; + prop->del = prp_delete; + prop->copy = prp_copy; /* Use custom comparison routine if available, otherwise default to memcmp() */ - if(prp_cmp != NULL) + if (prp_cmp != NULL) prop->cmp = prp_cmp; else prop->cmp = &memcmp; @@ -1214,20 +1176,19 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, done: /* Free any resources allocated */ - if(ret_value == NULL) { - if(prop != NULL) { - if(prop->name != NULL) + if (ret_value == NULL) { + if (prop != NULL) { + if (prop->name != NULL) H5MM_xfree(prop->name); - if(prop->value != NULL) + if (prop->value != NULL) H5MM_xfree(prop->value); prop = H5FL_FREE(H5P_genprop_t, prop); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__create_prop() */ +} /* H5P__create_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__add_prop @@ -1249,7 +1210,7 @@ done: herr_t H5P__add_prop(H5SL_t *slist, H5P_genprop_t *prop) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1258,14 +1219,13 @@ H5P__add_prop(H5SL_t *slist, H5P_genprop_t *prop) HDassert(prop->type != H5P_PROP_WITHIN_UNKNOWN); /* Insert property into skip list */ - if(H5SL_insert(slist, prop, prop->name) < 0) + if (H5SL_insert(slist, prop, prop->name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into skip list") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P__add_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__find_prop_plist @@ -1287,7 +1247,7 @@ done: H5P_genprop_t * H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) { - H5P_genprop_t *ret_value = NULL; /* Return value */ + H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1295,19 +1255,19 @@ H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) HDassert(name); /* Check if the property has been deleted from list */ - if(H5SL_search(plist->del,name) != NULL) { + if (H5SL_search(plist->del, name) != NULL) { HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "property deleted from skip list") } /* end if */ else { /* Get the property data from the skip list */ - if(NULL == (ret_value = (H5P_genprop_t *)H5SL_search(plist->props, name))) { - H5P_genclass_t *tclass; /* Temporary class pointer */ + if (NULL == (ret_value = (H5P_genprop_t *)H5SL_search(plist->props, name))) { + H5P_genclass_t *tclass; /* Temporary class pointer */ /* Couldn't find property in list itself, start searching through class info */ tclass = plist->pclass; - while(tclass != NULL) { + while (tclass != NULL) { /* Find the property in the class */ - if(NULL != (ret_value = (H5P_genprop_t *)H5SL_search(tclass->props, name))) + if (NULL != (ret_value = (H5P_genprop_t *)H5SL_search(tclass->props, name))) /* Got pointer to property - leave now */ break; @@ -1316,16 +1276,15 @@ H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) } /* end while */ /* Check if we haven't found the property */ - if(ret_value == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list") + if (ret_value == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't find property in skip list") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__find_prop_plist() */ +} /* H5P__find_prop_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__find_prop_pclass @@ -1347,7 +1306,7 @@ done: static H5P_genprop_t * H5P__find_prop_pclass(H5P_genclass_t *pclass, const char *name) { - H5P_genprop_t *ret_value = NULL; /* Return value */ + H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1355,14 +1314,13 @@ H5P__find_prop_pclass(H5P_genclass_t *pclass, const char *name) HDassert(name); /* Get the property from the skip list */ - if(NULL == (ret_value = (H5P_genprop_t *)H5SL_search(pclass->props, name))) - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list") + if (NULL == (ret_value = (H5P_genprop_t *)H5SL_search(pclass->props, name))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't find property in skip list") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__find_prop_pclass() */ +} /* H5P__find_prop_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__free_prop @@ -1389,19 +1347,18 @@ H5P__free_prop(H5P_genprop_t *prop) HDassert(prop); /* Release the property value if it exists */ - if(prop->value) + if (prop->value) H5MM_xfree(prop->value); /* Only free the name if we own it */ - if(!prop->shared_name) + if (!prop->shared_name) H5MM_xfree(prop->name); prop = H5FL_FREE(H5P_genprop_t, prop); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5P__free_prop() */ +} /* H5P__free_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__free_prop_cb @@ -1425,24 +1382,23 @@ H5P__free_prop(H5P_genprop_t *prop) static herr_t H5P__free_prop_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) { - H5P_genprop_t *tprop=(H5P_genprop_t *)item; /* Temporary pointer to property */ - hbool_t make_cb = *(hbool_t *)op_data; /* Whether to make property 'close' callback */ + H5P_genprop_t *tprop = (H5P_genprop_t *)item; /* Temporary pointer to property */ + hbool_t make_cb = *(hbool_t *)op_data; /* Whether to make property 'close' callback */ FUNC_ENTER_STATIC_NOERR HDassert(tprop); /* Call the close callback and ignore the return value, there's nothing we can do about it */ - if(make_cb && tprop->close != NULL) + if (make_cb && tprop->close != NULL) (tprop->close)(tprop->name, tprop->size, tprop->value); /* Free the property, ignoring return value, nothing we can do */ H5P__free_prop(tprop); FUNC_LEAVE_NOAPI(0) -} /* H5P__free_prop_cb() */ +} /* H5P__free_prop_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__free_del_name_cb @@ -1465,7 +1421,7 @@ H5P__free_prop_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) static herr_t H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op_data) { - char *del_name=(char *)item; /* Temporary pointer to deleted name */ + char *del_name = (char *)item; /* Temporary pointer to deleted name */ FUNC_ENTER_STATIC_NOERR @@ -1475,9 +1431,8 @@ H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED H5MM_xfree(del_name); FUNC_LEAVE_NOAPI(0) -} /* H5P__free_del_name_cb() */ +} /* H5P__free_del_name_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__access_class @@ -1508,35 +1463,35 @@ H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) HDassert(pclass); HDassert(mod > H5P_MOD_ERR && mod < H5P_MOD_MAX); - switch(mod) { - case H5P_MOD_INC_CLS: /* Increment the dependent class count*/ + switch (mod) { + case H5P_MOD_INC_CLS: /* Increment the dependent class count*/ pclass->classes++; break; - case H5P_MOD_DEC_CLS: /* Decrement the dependent class count*/ + case H5P_MOD_DEC_CLS: /* Decrement the dependent class count*/ pclass->classes--; break; - case H5P_MOD_INC_LST: /* Increment the dependent list count*/ + case H5P_MOD_INC_LST: /* Increment the dependent list count*/ pclass->plists++; break; - case H5P_MOD_DEC_LST: /* Decrement the dependent list count*/ + case H5P_MOD_DEC_LST: /* Decrement the dependent list count*/ pclass->plists--; break; - case H5P_MOD_INC_REF: /* Increment the ID reference count*/ + case H5P_MOD_INC_REF: /* Increment the ID reference count*/ /* Reset the deleted flag if incrementing the reference count */ - if(pclass->deleted) + if (pclass->deleted) pclass->deleted = FALSE; pclass->ref_count++; break; - case H5P_MOD_DEC_REF: /* Decrement the ID reference count*/ + case H5P_MOD_DEC_REF: /* Decrement the ID reference count*/ pclass->ref_count--; /* Mark the class object as deleted if reference count drops to zero */ - if(pclass->ref_count == 0) + if (pclass->ref_count == 0) pclass->deleted = TRUE; break; @@ -1547,14 +1502,14 @@ H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) } /* end switch */ /* Check if we can release the class information now */ - if(pclass->deleted && pclass->plists == 0 && pclass->classes == 0) { - H5P_genclass_t *par_class = pclass->parent; /* Pointer to class's parent */ + if (pclass->deleted && pclass->plists == 0 && pclass->classes == 0) { + H5P_genclass_t *par_class = pclass->parent; /* Pointer to class's parent */ HDassert(pclass->name); H5MM_xfree(pclass->name); /* Free the class properties without making callbacks */ - if(pclass->props) { + if (pclass->props) { hbool_t make_cb = FALSE; H5SL_destroy(pclass->props, H5P__free_prop_cb, &make_cb); @@ -1563,14 +1518,13 @@ H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) pclass = H5FL_FREE(H5P_genclass_t, pclass); /* Reduce the number of dependent classes on parent class also */ - if(par_class != NULL) + if (par_class != NULL) H5P__access_class(par_class, H5P_MOD_DEC_CLS); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5P__access_class() */ +} /* H5P__access_class() */ - /*-------------------------------------------------------------------------- NAME H5P__open_class_path_cb @@ -1595,9 +1549,9 @@ H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) static int H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key) { - H5P_genclass_t *obj = (H5P_genclass_t *)_obj; /* Pointer to the class for this ID */ - H5P_check_class_t *key = (H5P_check_class_t *)_key; /* Pointer to key information for comparison */ - int ret_value = 0; /* Return value */ + H5P_genclass_t * obj = (H5P_genclass_t *)_obj; /* Pointer to the class for this ID */ + H5P_check_class_t *key = (H5P_check_class_t *)_key; /* Pointer to key information for comparison */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1606,18 +1560,17 @@ H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key) HDassert(key); /* Check if the class object has the same parent as the new class */ - if(obj->parent == key->parent) { + if (obj->parent == key->parent) { /* Check if they have the same name */ - if(HDstrcmp(obj->name, key->name) == 0) { + if (HDstrcmp(obj->name, key->name) == 0) { key->new_class = obj; - ret_value = 1; /* Indicate a match */ - } /* end if */ - } /* end if */ + ret_value = 1; /* Indicate a match */ + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__open_class_path_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__create_class @@ -1653,52 +1606,51 @@ H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key) --------------------------------------------------------------------------*/ H5P_genclass_t * H5P__create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t type, - H5P_cls_create_func_t cls_create, void *create_data, - H5P_cls_copy_func_t cls_copy, void *copy_data, - H5P_cls_close_func_t cls_close, void *close_data) + H5P_cls_create_func_t cls_create, void *create_data, H5P_cls_copy_func_t cls_copy, + void *copy_data, H5P_cls_close_func_t cls_close, void *close_data) { - H5P_genclass_t *pclass = NULL; /* Property list class created */ - H5P_genclass_t *ret_value = NULL; /* Return value */ + H5P_genclass_t *pclass = NULL; /* Property list class created */ + H5P_genclass_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE HDassert(name); /* Allow internal classes to break some rules */ /* (This allows the root of the tree to be created with this routine -QAK) */ - if(type == H5P_TYPE_USER) + if (type == H5P_TYPE_USER) HDassert(par_class); /* Allocate room for the class */ - if(NULL == (pclass = H5FL_CALLOC(H5P_genclass_t))) + if (NULL == (pclass = H5FL_CALLOC(H5P_genclass_t))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, NULL, "property list class allocation failed") /* Set class state */ pclass->parent = par_class; - if(NULL == (pclass->name = H5MM_xstrdup(name))) + if (NULL == (pclass->name = H5MM_xstrdup(name))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, NULL, "property list class name allocation failed") - pclass->type = type; - pclass->nprops = 0; /* Classes are created without properties initially */ - pclass->plists = 0; /* No properties lists of this class yet */ - pclass->classes = 0; /* No classes derived from this class yet */ - pclass->ref_count = 1; /* This is the first reference to the new class */ - pclass->deleted = FALSE; /* Not deleted yet... :-) */ - pclass->revision = H5P_GET_NEXT_REV; /* Get a revision number for the class */ + pclass->type = type; + pclass->nprops = 0; /* Classes are created without properties initially */ + pclass->plists = 0; /* No properties lists of this class yet */ + pclass->classes = 0; /* No classes derived from this class yet */ + pclass->ref_count = 1; /* This is the first reference to the new class */ + pclass->deleted = FALSE; /* Not deleted yet... :-) */ + pclass->revision = H5P_GET_NEXT_REV; /* Get a revision number for the class */ /* Create the skip list for properties */ - if(NULL == (pclass->props = H5SL_create(H5SL_TYPE_STR, NULL))) + if (NULL == (pclass->props = H5SL_create(H5SL_TYPE_STR, NULL))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create skip list for properties") /* Set callback functions and pass-along data */ pclass->create_func = cls_create; pclass->create_data = create_data; - pclass->copy_func = cls_copy; - pclass->copy_data = copy_data; - pclass->close_func = cls_close; - pclass->close_data = close_data; + pclass->copy_func = cls_copy; + pclass->copy_data = copy_data; + pclass->close_func = cls_close; + pclass->close_data = close_data; /* Increment parent class's derived class value */ - if(par_class != NULL) { - if(H5P__access_class(par_class, H5P_MOD_INC_CLS) < 0) + if (par_class != NULL) { + if (H5P__access_class(par_class, H5P_MOD_INC_CLS) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, NULL, "Can't increment parent class ref count") } /* end if */ @@ -1707,11 +1659,11 @@ H5P__create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t done: /* Free any resources allocated */ - if(ret_value == NULL) - if(pclass) { - if(pclass->name) + if (ret_value == NULL) + if (pclass) { + if (pclass->name) H5MM_xfree(pclass->name); - if(pclass->props) { + if (pclass->props) { hbool_t make_cb = FALSE; H5SL_destroy(pclass->props, H5P__free_prop_cb, &make_cb); @@ -1720,9 +1672,8 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__create_class() */ +} /* H5P__create_class() */ - /*-------------------------------------------------------------------------- NAME H5P__create @@ -1751,11 +1702,11 @@ done: static H5P_genplist_t * H5P__create(H5P_genclass_t *pclass) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genplist_t *plist = NULL; /* New property list created */ - H5P_genprop_t *tmp; /* Temporary pointer to parent class properties */ - H5SL_t *seen = NULL; /* Skip list to hold names of properties already seen */ - H5P_genplist_t *ret_value = NULL; /* Return value */ + H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genplist_t *plist = NULL; /* New property list created */ + H5P_genprop_t * tmp; /* Temporary pointer to parent class properties */ + H5SL_t * seen = NULL; /* Skip list to hold names of properties already seen */ + H5P_genplist_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1766,106 +1717,106 @@ H5P__create(H5P_genclass_t *pclass) */ /* Allocate room for the property list */ - if(NULL==(plist = H5FL_CALLOC(H5P_genplist_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,"memory allocation failed") + if (NULL == (plist = H5FL_CALLOC(H5P_genplist_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set class state */ - plist->pclass = pclass; - plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ - plist->class_init = FALSE; /* Initially, wait until the class callback finishes to set */ + plist->pclass = pclass; + plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ + plist->class_init = FALSE; /* Initially, wait until the class callback finishes to set */ /* Create the skip list for changed properties */ - if((plist->props = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for changed properties") + if ((plist->props = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create skip list for changed properties") /* Create the skip list for deleted properties */ - if((plist->del = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for deleted properties") + if ((plist->del = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create skip list for deleted properties") /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'create' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for seen properties") + if ((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create skip list for seen properties") /* * Check if we should copy class properties (up through list of parent classes also), * initialize each with default value & make property 'create' callback. */ - tclass=pclass; - while(tclass!=NULL) { - if(tclass->nprops>0) { - H5SL_node_t *curr_node; /* Current node in skip list */ + tclass = pclass; + while (tclass != NULL) { + if (tclass->nprops > 0) { + H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ - curr_node=H5SL_first(tclass->props); - while(curr_node!=NULL) { + curr_node = H5SL_first(tclass->props); + while (curr_node != NULL) { /* Get pointer to property from node */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Only "create" properties we haven't seen before */ - if(H5SL_search(seen,tmp->name) == NULL) { + if (H5SL_search(seen, tmp->name) == NULL) { /* Call property creation callback, if it exists */ - if(tmp->create) { + if (tmp->create) { /* Call the callback & insert changed value into skip list (if necessary) */ - if(H5P__do_prop_cb1(plist->props, tmp, tmp->create) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL,"Can't create property") + if (H5P__do_prop_cb1(plist->props, tmp, tmp->create) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "Can't create property") } /* end if */ /* Add property name to "seen" list */ - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,NULL,"can't insert property into seen skip list") + if (H5SL_insert(seen, tmp->name, tmp->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, NULL, + "can't insert property into seen skip list") /* Increment the number of properties in list */ plist->nprops++; } /* end if */ /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Go up to parent class */ - tclass=tclass->parent; + tclass = tclass->parent; } /* end while */ /* Increment the number of property lists derived from class */ - if(H5P__access_class(plist->pclass,H5P_MOD_INC_LST) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, NULL,"Can't increment class ref count") + if (H5P__access_class(plist->pclass, H5P_MOD_INC_LST) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, NULL, "Can't increment class ref count") /* Set return value */ - ret_value=plist; + ret_value = plist; done: /* Release the skip list of 'seen' properties */ - if(seen!=NULL) + if (seen != NULL) H5SL_close(seen); /* Release resources allocated on failure */ - if(ret_value==NULL) { - if(plist!=NULL) { + if (ret_value == NULL) { + if (plist != NULL) { /* Close & free any changed properties */ - if(plist->props) { - unsigned make_cb=1; + if (plist->props) { + unsigned make_cb = 1; H5SL_destroy(plist->props, H5P__free_prop_cb, &make_cb); } /* end if */ /* Close the deleted property skip list */ - if(plist->del) + if (plist->del) H5SL_close(plist->del); /* Release the property list itself */ plist = H5FL_FREE(H5P_genplist_t, plist); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__create() */ +} /* H5P__create() */ - /*-------------------------------------------------------------------------- NAME H5P_create_id @@ -1891,38 +1842,39 @@ done: hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genplist_t *plist = NULL; /* Property list created */ - hid_t plist_id = FAIL; /* Property list ID */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genplist_t *plist = NULL; /* Property list created */ + hid_t plist_id = FAIL; /* Property list ID */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) HDassert(pclass); /* Create the new property list */ - if((plist = H5P__create(pclass)) == NULL) + if ((plist = H5P__create(pclass)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list") /* Get an atom for the property list */ - if((plist_id = H5I_register(H5I_GENPROP_LST, plist, app_ref)) < 0) + if ((plist_id = H5I_register(H5I_GENPROP_LST, plist, app_ref)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list") - /* Save the property list ID in the property list struct, for use in the property class's 'close' callback */ + /* Save the property list ID in the property list struct, for use in the property class's 'close' callback + */ plist->plist_id = plist_id; /* Call the class callback (if it exists) now that we have the property list ID * (up through chain of parent classes also) */ tclass = plist->pclass; - while(NULL != tclass) { - if(NULL != tclass->create_func) { - if((tclass->create_func)(plist_id, tclass->create_data) < 0) { + while (NULL != tclass) { + if (NULL != tclass->create_func) { + if ((tclass->create_func)(plist_id, tclass->create_data) < 0) { /* Delete ID, ignore return value */ H5I_remove(plist_id); HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't initialize property") } /* end if */ - } /* end if */ + } /* end if */ /* Go up to parent class */ tclass = tclass->parent; @@ -1935,13 +1887,12 @@ H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref) ret_value = plist_id; done: - if(H5I_INVALID_HID == ret_value && plist) + if (H5I_INVALID_HID == ret_value && plist) H5P_close(plist); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_create_id() */ +} /* H5P_create_id() */ - /*-------------------------------------------------------------------------- NAME H5P__register_real @@ -2127,16 +2078,14 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, - const void *def_value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, - H5P_prp_delete_func_t prp_delete, - H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, - H5P_prp_close_func_t prp_close) +H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, const void *def_value, + H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, + H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, + H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, + H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { - H5P_genprop_t *new_prop = NULL; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genprop_t *new_prop = NULL; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2147,18 +2096,18 @@ H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, HDassert((size > 0 && def_value != NULL) || (size == 0)); /* Check for duplicate named properties */ - if(NULL != H5SL_search(pclass->props, name)) + if (NULL != H5SL_search(pclass->props, name)) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists") /* Create property object from parameters */ - if(NULL == (new_prop = H5P__create_prop(name, size, H5P_PROP_WITHIN_CLASS, - def_value, prp_create, prp_set, prp_get, prp_encode, prp_decode, - prp_delete, prp_copy, prp_cmp, prp_close))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property") + if (NULL == (new_prop = H5P__create_prop(name, size, H5P_PROP_WITHIN_CLASS, def_value, prp_create, + prp_set, prp_get, prp_encode, prp_decode, prp_delete, prp_copy, + prp_cmp, prp_close))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "Can't create property") /* Insert property into property list class */ - if(H5P__add_prop(pclass->props, new_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class") + if (H5P__add_prop(pclass->props, new_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into class") /* Increment property count for class */ pclass->nprops++; @@ -2167,14 +2116,13 @@ H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, pclass->revision = H5P_GET_NEXT_REV; done: - if(ret_value < 0) - if(new_prop && H5P__free_prop(new_prop) < 0) + if (ret_value < 0) + if (new_prop && H5P__free_prop(new_prop) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close property") FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__register_real() */ +} /* H5P__register_real() */ - /*-------------------------------------------------------------------------- NAME H5P__register @@ -2359,17 +2307,15 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, - const void *def_value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, - H5P_prp_delete_func_t prp_delete, - H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, - H5P_prp_close_func_t prp_close) +H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, const void *def_value, + H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, + H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, + H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, + H5P_prp_close_func_t prp_close) { - H5P_genclass_t *pclass = *ppclass; /* Pointer to class to modify */ - H5P_genclass_t *new_class = NULL; /* New class pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genclass_t *pclass = *ppclass; /* Pointer to class to modify */ + H5P_genclass_t *new_class = NULL; /* New class pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2380,29 +2326,29 @@ H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, /* Check if class needs to be split because property lists or classes have * been created since the last modification was made to the class. */ - if(pclass->plists > 0 || pclass->classes > 0) { - if(NULL == (new_class = H5P__create_class(pclass->parent, pclass->name, - pclass->type, pclass->create_func, pclass->create_data, - pclass->copy_func, pclass->copy_data, - pclass->close_func, pclass->close_data))) + if (pclass->plists > 0 || pclass->classes > 0) { + if (NULL == (new_class = H5P__create_class( + pclass->parent, pclass->name, pclass->type, pclass->create_func, pclass->create_data, + pclass->copy_func, pclass->copy_data, pclass->close_func, pclass->close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy class") /* Walk through the skip list of the old class and copy properties */ - if(pclass->nprops > 0) { - H5SL_node_t *curr_node; /* Current node in skip list */ + if (pclass->nprops > 0) { + H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ curr_node = H5SL_first(pclass->props); - while(curr_node != NULL) { - H5P_genprop_t *pcopy; /* Property copy */ + while (curr_node != NULL) { + H5P_genprop_t *pcopy; /* Property copy */ /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS))) + if (NULL == + (pcopy = H5P__dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") /* Insert the initialized property into the property class */ - if(H5P__add_prop(new_class->props, pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class") + if (H5P__add_prop(new_class->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into class") /* Increment property count for class */ new_class->nprops++; @@ -2410,30 +2356,29 @@ H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, /* Get the next property node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Use the new class instead of the old one */ pclass = new_class; } /* end if */ /* Really register the property in the class */ - if(H5P__register_real(pclass, name, size, def_value, prp_create, prp_set, prp_get, - prp_encode, prp_decode, prp_delete, prp_copy, prp_cmp, prp_close) < 0) + if (H5P__register_real(pclass, name, size, def_value, prp_create, prp_set, prp_get, prp_encode, + prp_decode, prp_delete, prp_copy, prp_cmp, prp_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "can't register property") /* Update pointer to pointer to class, if a new one was generated */ - if(new_class) + if (new_class) *ppclass = pclass; done: - if(ret_value < 0) - if(new_class && H5P__close_class(new_class) < 0) + if (ret_value < 0) + if (new_class && H5P__close_class(new_class) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close new property class") FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__register() */ +} /* H5P__register() */ - /*-------------------------------------------------------------------------- NAME H5P_insert @@ -2604,14 +2549,13 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, - void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, - H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, - H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) +H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, + H5P_prp_get_func_t prp_get, H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, + H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, + H5P_prp_close_func_t prp_close) { - H5P_genprop_t *new_prop = NULL; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genprop_t *new_prop = NULL; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2620,61 +2564,60 @@ H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, HDassert((size > 0 && value != NULL) || (size == 0)); /* Check for duplicate named properties */ - if(NULL != H5SL_search(plist->props, name)) + if (NULL != H5SL_search(plist->props, name)) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists") /* Check if the property has been deleted */ - if(NULL != H5SL_search(plist->del, name)) { + if (NULL != H5SL_search(plist->del, name)) { char *temp_name = NULL; /* Remove the property name from the deleted property skip list */ - if(NULL == (temp_name = (char *)H5SL_remove(plist->del, name))) - HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from deleted skip list") + if (NULL == (temp_name = (char *)H5SL_remove(plist->del, name))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove property from deleted skip list") /* free the name of the removed property */ H5MM_xfree(temp_name); } /* end if */ else { - H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genclass_t *tclass; /* Temporary class pointer */ /* Check if the property is already in the class hierarchy */ tclass = plist->pclass; - while(tclass) { - if(tclass->nprops > 0) { + while (tclass) { + if (tclass->nprops > 0) { /* Find the property in the class */ - if(NULL != H5SL_search(tclass->props, name)) + if (NULL != H5SL_search(tclass->props, name)) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists") } /* end if */ /* Go up to parent class */ tclass = tclass->parent; } /* end while */ - } /* end else */ + } /* end else */ /* Ok to add to property list */ /* Create property object from parameters */ - if(NULL == (new_prop = H5P__create_prop(name, size, H5P_PROP_WITHIN_LIST, value, NULL, - prp_set, prp_get, prp_encode, prp_decode, prp_delete, prp_copy, - prp_cmp, prp_close))) + if (NULL == + (new_prop = H5P__create_prop(name, size, H5P_PROP_WITHIN_LIST, value, NULL, prp_set, prp_get, + prp_encode, prp_decode, prp_delete, prp_copy, prp_cmp, prp_close))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "Can't create property") /* Insert property into property list class */ - if(H5P__add_prop(plist->props, new_prop) < 0) + if (H5P__add_prop(plist->props, new_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into class") /* Increment property count for class */ plist->nprops++; done: - if(ret_value < 0) - if(new_prop && H5P__free_prop(new_prop) < 0) + if (ret_value < 0) + if (new_prop && H5P__free_prop(new_prop) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close property") FUNC_LEAVE_NOAPI(ret_value) } /* H5P_insert() */ - /*-------------------------------------------------------------------------- NAME H5P__do_prop @@ -2700,11 +2643,11 @@ done: --------------------------------------------------------------------------*/ static herr_t H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op, - H5P_do_pclass_op_t pclass_op, void *udata) + H5P_do_pclass_op_t pclass_op, void *udata) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genprop_t * prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2715,13 +2658,13 @@ H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op HDassert(pclass_op); /* Check if the property has been deleted */ - if(NULL != H5SL_search(plist->del, name)) + if (NULL != H5SL_search(plist->del, name)) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Find property in changed list */ - if(NULL != (prop = (H5P_genprop_t *)H5SL_search(plist->props, name))) { + if (NULL != (prop = (H5P_genprop_t *)H5SL_search(plist->props, name))) { /* Call the 'found in property list' callback */ - if((*plist_op)(plist, name, prop, udata) < 0) + if ((*plist_op)(plist, name, prop, udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on property") } /* end if */ else { @@ -2730,18 +2673,18 @@ H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op * & make property 'set' callback. */ tclass = plist->pclass; - while(NULL != tclass) { - if(tclass->nprops > 0) { + while (NULL != tclass) { + if (tclass->nprops > 0) { /* Find the property in the class */ - if(NULL != (prop = (H5P_genprop_t *)H5SL_search(tclass->props, name))) { + if (NULL != (prop = (H5P_genprop_t *)H5SL_search(tclass->props, name))) { /* Call the 'found in class' callback */ - if((*pclass_op)(plist, name, prop, udata) < 0) + if ((*pclass_op)(plist, name, prop, udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on property") /* Leave */ break; } /* end if */ - } /* end if */ + } /* end if */ /* Go up to parent class */ tclass = tclass->parent; @@ -2750,15 +2693,14 @@ H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op /* If we get this far, then it wasn't in the list of changed properties, * nor in the properties in the class hierarchy, indicate an error */ - if(NULL == tclass) + if (NULL == tclass) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't find property in skip list") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__do_prop() */ +} /* H5P__do_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__poke_plist_cb @@ -2782,10 +2724,10 @@ done: --------------------------------------------------------------------------*/ static herr_t H5P__poke_plist_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDEBUG_UNUSED *name, - H5P_genprop_t *prop, void *_udata) + H5P_genprop_t *prop, void *_udata) { - H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2795,7 +2737,7 @@ H5P__poke_plist_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_AT HDassert(prop); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Overwrite value in property */ @@ -2803,9 +2745,8 @@ H5P__poke_plist_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_AT done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__poke_plist_cb() */ +} /* H5P__poke_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__poke_pclass_cb @@ -2829,11 +2770,11 @@ done: --------------------------------------------------------------------------*/ static herr_t H5P__poke_pclass_cb(H5P_genplist_t *plist, const char H5_ATTR_NDEBUG_UNUSED *name, H5P_genprop_t *prop, - void *_udata) + void *_udata) { - H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ - H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + H5P_genprop_t * pcopy = NULL; /* Copy of property to insert into skip list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2844,29 +2785,28 @@ H5P__poke_pclass_cb(H5P_genplist_t *plist, const char H5_ATTR_NDEBUG_UNUSED *nam HDassert(prop->cmp); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) + if (NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") H5MM_memcpy(pcopy->value, udata->value, pcopy->size); /* Insert the changed property into the property list */ - if(H5P__add_prop(plist->props, pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") + if (H5P__add_prop(plist->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert changed property into skip list") done: /* Cleanup on failure */ - if(ret_value < 0) - if(pcopy) + if (ret_value < 0) + if (pcopy) H5P__free_prop(pcopy); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__poke_pclass_cb() */ +} /* H5P__poke_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_poke @@ -2894,8 +2834,8 @@ done: herr_t H5P_poke(H5P_genplist_t *plist, const char *name, const void *value) { - H5P_prop_set_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2906,14 +2846,13 @@ H5P_poke(H5P_genplist_t *plist, const char *name, const void *value) /* Find the property and set the value */ udata.value = value; - if(H5P__do_prop(plist, name, H5P__poke_plist_cb, H5P__poke_pclass_cb, &udata) < 0) + if (H5P__do_prop(plist, name, H5P__poke_plist_cb, H5P__poke_pclass_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to overwrite value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_poke() */ +} /* H5P_poke() */ - /*-------------------------------------------------------------------------- NAME H5P__set_plist_cb @@ -2936,13 +2875,12 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *_udata) +H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void *_udata) { - H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ - void *tmp_value = NULL; /* Temporary value for property */ - const void *prp_value = NULL; /* Property value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + void * tmp_value = NULL; /* Temporary value for property */ + const void * prp_value = NULL; /* Property value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2952,31 +2890,31 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a copy of the value and pass to 'set' callback */ - if(NULL != prop->set) { + if (NULL != prop->set) { /* Make a copy of the current value, in case the callback fails */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) + if (NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") H5MM_memcpy(tmp_value, udata->value, prop->size); /* Call user's callback */ - if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) + if ((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") - /* Set the pointer for copying */ - prp_value = tmp_value; + /* Set the pointer for copying */ + prp_value = tmp_value; } /* end if */ /* No 'set' callback, just copy value */ else prp_value = udata->value; /* Free any previous value for the property */ - if(NULL != prop->del) { + if (NULL != prop->del) { /* Call user's 'delete' callback */ - if((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) + if ((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release property value") } /* end if */ @@ -2985,13 +2923,12 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, done: /* Free the temporary value buffer */ - if(tmp_value != NULL) + if (tmp_value != NULL) H5MM_xfree(tmp_value); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__set_plist_cb() */ +} /* H5P__set_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__set_pclass_cb @@ -3014,14 +2951,13 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *_udata) +H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void *_udata) { - H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ - H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ - void *tmp_value = NULL; /* Temporary value for property */ - const void *prp_value = NULL; /* Property value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + H5P_genprop_t * pcopy = NULL; /* Copy of property to insert into skip list */ + void * tmp_value = NULL; /* Temporary value for property */ + const void * prp_value = NULL; /* Property value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3032,51 +2968,50 @@ H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop->cmp); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a copy of the value and pass to 'set' callback */ - if(NULL != prop->set) { + if (NULL != prop->set) { /* Make a copy of the current value, in case the callback fails */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) + if (NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") H5MM_memcpy(tmp_value, udata->value, prop->size); /* Call user's callback */ - if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) + if ((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") - /* Set the pointer for copying */ - prp_value = tmp_value; + /* Set the pointer for copying */ + prp_value = tmp_value; } /* end if */ /* No 'set' callback, just copy value */ else prp_value = udata->value; /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) + if (NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") H5MM_memcpy(pcopy->value, prp_value, pcopy->size); /* Insert the changed property into the property list */ - if(H5P__add_prop(plist->props, pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") + if (H5P__add_prop(plist->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert changed property into skip list") done: /* Free the temporary value buffer */ - if(tmp_value != NULL) + if (tmp_value != NULL) H5MM_xfree(tmp_value); /* Cleanup on failure */ - if(ret_value < 0) - if(pcopy) + if (ret_value < 0) + if (pcopy) H5P__free_prop(pcopy); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__set_pclass_cb() */ +} /* H5P__set_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_set @@ -3111,8 +3046,8 @@ done: herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value) { - H5P_prop_set_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3123,14 +3058,13 @@ H5P_set(H5P_genplist_t *plist, const char *name, const void *value) /* Find the property and set the value */ udata.value = value; - if(H5P__do_prop(plist, name, H5P__set_plist_cb, H5P__set_pclass_cb, &udata) < 0) + if (H5P__do_prop(plist, name, H5P__set_plist_cb, H5P__set_pclass_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to set value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_set() */ +} /* H5P_set() */ - /*-------------------------------------------------------------------------- NAME H5P__class_get @@ -3159,8 +3093,8 @@ done: herr_t H5P__class_get(const H5P_genclass_t *pclass, const char *name, void *value) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3170,11 +3104,11 @@ H5P__class_get(const H5P_genclass_t *pclass, const char *name, void *value) HDassert(value); /* Find property in list */ - if(NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name))) + if (NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Copy the property value */ @@ -3184,7 +3118,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P__class_get() */ - /*-------------------------------------------------------------------------- NAME H5P__class_set @@ -3215,8 +3148,8 @@ done: herr_t H5P__class_set(const H5P_genclass_t *pclass, const char *name, const void *value) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3226,11 +3159,11 @@ H5P__class_set(const H5P_genclass_t *pclass, const char *name, const void *value HDassert(value); /* Find property in list */ - if(NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name))) + if (NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Copy the property value */ @@ -3240,7 +3173,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P__class_set() */ - /*-------------------------------------------------------------------------- NAME H5P_exist_plist @@ -3265,7 +3197,7 @@ done: htri_t H5P_exist_plist(const H5P_genplist_t *plist, const char *name) { - htri_t ret_value = FAIL; /* return value */ + htri_t ret_value = FAIL; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3273,18 +3205,18 @@ H5P_exist_plist(const H5P_genplist_t *plist, const char *name) HDassert(name); /* Check for property in deleted property list */ - if(H5SL_search(plist->del, name) != NULL) + if (H5SL_search(plist->del, name) != NULL) ret_value = FALSE; else { /* Check for property in changed property list */ - if(H5SL_search(plist->props, name) != NULL) + if (H5SL_search(plist->props, name) != NULL) ret_value = TRUE; else { - H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genclass_t *tclass; /* Temporary class pointer */ tclass = plist->pclass; - while(tclass != NULL) { - if(H5SL_search(tclass->props, name) != NULL) + while (tclass != NULL) { + if (H5SL_search(tclass->props, name) != NULL) HGOTO_DONE(TRUE) /* Go up to parent class */ @@ -3294,13 +3226,12 @@ H5P_exist_plist(const H5P_genplist_t *plist, const char *name) /* If we've reached here, we couldn't find the property */ ret_value = FALSE; } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_exist_plist() */ +} /* H5P_exist_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__exist_pclass @@ -3325,7 +3256,7 @@ done: htri_t H5P__exist_pclass(H5P_genclass_t *pclass, const char *name) { - htri_t ret_value = FAIL; /* return value */ + htri_t ret_value = FAIL; /* return value */ FUNC_ENTER_PACKAGE_NOERR @@ -3333,14 +3264,14 @@ H5P__exist_pclass(H5P_genclass_t *pclass, const char *name) HDassert(name); /* Check for property in property list */ - if(H5SL_search(pclass->props, name) != NULL) + if (H5SL_search(pclass->props, name) != NULL) ret_value = TRUE; else { - H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genclass_t *tclass; /* Temporary class pointer */ tclass = pclass->parent; - while(tclass != NULL) { - if(H5SL_search(tclass->props, name) != NULL) + while (tclass != NULL) { + if (H5SL_search(tclass->props, name) != NULL) HGOTO_DONE(TRUE) /* Go up to parent class */ @@ -3353,9 +3284,8 @@ H5P__exist_pclass(H5P_genclass_t *pclass, const char *name) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__exist_pclass() */ +} /* H5P__exist_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__get_size_plist @@ -3381,8 +3311,8 @@ done: herr_t H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -3391,7 +3321,7 @@ H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) HDassert(size); /* Find property */ - if(NULL == (prop = H5P__find_prop_plist(plist, name))) + if (NULL == (prop = H5P__find_prop_plist(plist, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Get property size */ @@ -3399,9 +3329,8 @@ H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_size_plist() */ +} /* H5P__get_size_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__get_size_pclass @@ -3427,8 +3356,8 @@ done: herr_t H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -3437,7 +3366,7 @@ H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size) HDassert(size); /* Find property */ - if((prop = H5P__find_prop_pclass(pclass,name)) == NULL) + if ((prop = H5P__find_prop_pclass(pclass, name)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Get property size */ @@ -3445,9 +3374,8 @@ H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_size_pclass() */ +} /* H5P__get_size_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__get_nprops_plist @@ -3480,9 +3408,8 @@ H5P__get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops) *nprops = plist->nprops; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5P__get_nprops_plist() */ +} /* H5P__get_nprops_plist() */ - /*-------------------------------------------------------------------------- NAME H5P_get_nprops_pclass @@ -3507,7 +3434,7 @@ H5P__get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops) herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3518,17 +3445,16 @@ H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recu *nprops = pclass->nprops; /* Check if the class is derived, and walk up the chain, if so */ - if(recurse) - while(pclass->parent != NULL) { - pclass = pclass->parent; - *nprops += pclass->nprops; - } /* end while */ + if (recurse) + while (pclass->parent != NULL) { + pclass = pclass->parent; + *nprops += pclass->nprops; + } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_get_nprops_pclass() */ +} /* H5P_get_nprops_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__cmp_prop @@ -3554,8 +3480,8 @@ done: static int H5P__cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2) { - int cmp_value; /* Value from comparison */ - int ret_value = 0; /* return value */ + int cmp_value; /* Value from comparison */ + int ret_value = 0; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -3563,72 +3489,102 @@ H5P__cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2) HDassert(prop2); /* Check the name */ - if((cmp_value = HDstrcmp(prop1->name, prop2->name)) != 0) + if ((cmp_value = HDstrcmp(prop1->name, prop2->name)) != 0) HGOTO_DONE(cmp_value); /* Check the size of properties */ - if(prop1->size < prop2->size) HGOTO_DONE(-1); - if(prop1->size > prop2->size) HGOTO_DONE(1); + if (prop1->size < prop2->size) + HGOTO_DONE(-1); + if (prop1->size > prop2->size) + HGOTO_DONE(1); /* Check if they both have the same 'create' callback */ - if(prop1->create == NULL && prop2->create != NULL) HGOTO_DONE(-1); - if(prop1->create != NULL && prop2->create == NULL) HGOTO_DONE(1); - if(prop1->create != prop2->create) HGOTO_DONE(-1); + if (prop1->create == NULL && prop2->create != NULL) + HGOTO_DONE(-1); + if (prop1->create != NULL && prop2->create == NULL) + HGOTO_DONE(1); + if (prop1->create != prop2->create) + HGOTO_DONE(-1); /* Check if they both have the same 'set' callback */ - if(prop1->set == NULL && prop2->set != NULL) HGOTO_DONE(-1); - if(prop1->set != NULL && prop2->set == NULL) HGOTO_DONE(1); - if(prop1->set != prop2->set) HGOTO_DONE(-1); + if (prop1->set == NULL && prop2->set != NULL) + HGOTO_DONE(-1); + if (prop1->set != NULL && prop2->set == NULL) + HGOTO_DONE(1); + if (prop1->set != prop2->set) + HGOTO_DONE(-1); /* Check if they both have the same 'get' callback */ - if(prop1->get == NULL && prop2->get != NULL) HGOTO_DONE(-1); - if(prop1->get != NULL && prop2->get == NULL) HGOTO_DONE(1); - if(prop1->get != prop2->get) HGOTO_DONE(-1); + if (prop1->get == NULL && prop2->get != NULL) + HGOTO_DONE(-1); + if (prop1->get != NULL && prop2->get == NULL) + HGOTO_DONE(1); + if (prop1->get != prop2->get) + HGOTO_DONE(-1); /* Check if they both have the same 'encode' callback */ - if(prop1->encode == NULL && prop2->encode != NULL) HGOTO_DONE(-1); - if(prop1->encode != NULL && prop2->encode == NULL) HGOTO_DONE(1); - if(prop1->encode != prop2->encode) HGOTO_DONE(-1); + if (prop1->encode == NULL && prop2->encode != NULL) + HGOTO_DONE(-1); + if (prop1->encode != NULL && prop2->encode == NULL) + HGOTO_DONE(1); + if (prop1->encode != prop2->encode) + HGOTO_DONE(-1); /* Check if they both have the same 'decode' callback */ - if(prop1->decode == NULL && prop2->decode != NULL) HGOTO_DONE(-1); - if(prop1->decode != NULL && prop2->decode == NULL) HGOTO_DONE(1); - if(prop1->decode != prop2->decode) HGOTO_DONE(-1); + if (prop1->decode == NULL && prop2->decode != NULL) + HGOTO_DONE(-1); + if (prop1->decode != NULL && prop2->decode == NULL) + HGOTO_DONE(1); + if (prop1->decode != prop2->decode) + HGOTO_DONE(-1); /* Check if they both have the same 'delete' callback */ - if(prop1->del == NULL && prop2->del != NULL) HGOTO_DONE(-1); - if(prop1->del != NULL && prop2->del == NULL) HGOTO_DONE(1); - if(prop1->del != prop2->del) HGOTO_DONE(-1); + if (prop1->del == NULL && prop2->del != NULL) + HGOTO_DONE(-1); + if (prop1->del != NULL && prop2->del == NULL) + HGOTO_DONE(1); + if (prop1->del != prop2->del) + HGOTO_DONE(-1); /* Check if they both have the same 'copy' callback */ - if(prop1->copy == NULL && prop2->copy != NULL) HGOTO_DONE(-1); - if(prop1->copy != NULL && prop2->copy == NULL) HGOTO_DONE(1); - if(prop1->copy != prop2->copy) HGOTO_DONE(-1); + if (prop1->copy == NULL && prop2->copy != NULL) + HGOTO_DONE(-1); + if (prop1->copy != NULL && prop2->copy == NULL) + HGOTO_DONE(1); + if (prop1->copy != prop2->copy) + HGOTO_DONE(-1); /* Check if they both have the same 'compare' callback */ - if(prop1->cmp == NULL && prop2->cmp != NULL) HGOTO_DONE(-1); - if(prop1->cmp != NULL && prop2->cmp == NULL) HGOTO_DONE(1); - if(prop1->cmp != prop2->cmp) HGOTO_DONE(-1); + if (prop1->cmp == NULL && prop2->cmp != NULL) + HGOTO_DONE(-1); + if (prop1->cmp != NULL && prop2->cmp == NULL) + HGOTO_DONE(1); + if (prop1->cmp != prop2->cmp) + HGOTO_DONE(-1); /* Check if they both have the same 'close' callback */ - if(prop1->close == NULL && prop2->close != NULL) HGOTO_DONE(-1); - if(prop1->close != NULL && prop2->close == NULL) HGOTO_DONE(1); - if(prop1->close != prop2->close) HGOTO_DONE(-1); + if (prop1->close == NULL && prop2->close != NULL) + HGOTO_DONE(-1); + if (prop1->close != NULL && prop2->close == NULL) + HGOTO_DONE(1); + if (prop1->close != prop2->close) + HGOTO_DONE(-1); /* Check if they both have values allocated (or not allocated) */ - if(prop1->value == NULL && prop2->value != NULL) HGOTO_DONE(-1); - if(prop1->value != NULL && prop2->value == NULL) HGOTO_DONE(1); - if(prop1->value != NULL) { + if (prop1->value == NULL && prop2->value != NULL) + HGOTO_DONE(-1); + if (prop1->value != NULL && prop2->value == NULL) + HGOTO_DONE(1); + if (prop1->value != NULL) { /* Call comparison routine */ - if((cmp_value = prop1->cmp(prop1->value, prop2->value, prop1->size)) != 0) + if ((cmp_value = prop1->cmp(prop1->value, prop2->value, prop1->size)) != 0) HGOTO_DONE(cmp_value); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__cmp_prop() */ +} /* H5P__cmp_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__cmp_class @@ -3654,9 +3610,9 @@ done: int H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) { - H5SL_node_t *tnode1, *tnode2; /* Temporary pointer to property nodes */ - int cmp_value; /* Value from comparison */ - int ret_value = 0; /* Return value */ + H5SL_node_t *tnode1, *tnode2; /* Temporary pointer to property nodes */ + int cmp_value; /* Value from comparison */ + int ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -3664,65 +3620,89 @@ H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) HDassert(pclass2); /* Use the revision number to quickly check for identical classes */ - if(pclass1->revision == pclass2->revision) + if (pclass1->revision == pclass2->revision) HGOTO_DONE(0); /* Check the name */ - if((cmp_value = HDstrcmp(pclass1->name, pclass2->name)) != 0) + if ((cmp_value = HDstrcmp(pclass1->name, pclass2->name)) != 0) HGOTO_DONE(cmp_value); /* Check the number of properties */ - if(pclass1->nprops < pclass2->nprops) HGOTO_DONE(-1); - if(pclass1->nprops > pclass2->nprops) HGOTO_DONE(1); + if (pclass1->nprops < pclass2->nprops) + HGOTO_DONE(-1); + if (pclass1->nprops > pclass2->nprops) + HGOTO_DONE(1); /* Check the number of property lists created from the class */ - if(pclass1->plists < pclass2->plists) HGOTO_DONE(-1); - if(pclass1->plists > pclass2->plists) HGOTO_DONE(1); + if (pclass1->plists < pclass2->plists) + HGOTO_DONE(-1); + if (pclass1->plists > pclass2->plists) + HGOTO_DONE(1); /* Check the number of classes derived from the class */ - if(pclass1->classes < pclass2->classes) HGOTO_DONE(-1); - if(pclass1->classes > pclass2->classes) HGOTO_DONE(1); + if (pclass1->classes < pclass2->classes) + HGOTO_DONE(-1); + if (pclass1->classes > pclass2->classes) + HGOTO_DONE(1); /* Check the number of ID references open on the class */ - if(pclass1->ref_count < pclass2->ref_count) HGOTO_DONE(-1); - if(pclass1->ref_count > pclass2->ref_count) HGOTO_DONE(1); + if (pclass1->ref_count < pclass2->ref_count) + HGOTO_DONE(-1); + if (pclass1->ref_count > pclass2->ref_count) + HGOTO_DONE(1); /* Check the property list types */ - if(pclass1->type < pclass2->type) HGOTO_DONE(-1); - if(pclass1->type > pclass2->type) HGOTO_DONE(1); + if (pclass1->type < pclass2->type) + HGOTO_DONE(-1); + if (pclass1->type > pclass2->type) + HGOTO_DONE(1); /* Check whether they are deleted or not */ - if(pclass1->deleted < pclass2->deleted) HGOTO_DONE(-1); - if(pclass1->deleted > pclass2->deleted) HGOTO_DONE(1); + if (pclass1->deleted < pclass2->deleted) + HGOTO_DONE(-1); + if (pclass1->deleted > pclass2->deleted) + HGOTO_DONE(1); /* Check whether they have creation callback functions & data */ - if(pclass1->create_func == NULL && pclass2->create_func != NULL) HGOTO_DONE(-1); - if(pclass1->create_func != NULL && pclass2->create_func == NULL) HGOTO_DONE(1); - if(pclass1->create_func != pclass2->create_func) HGOTO_DONE(-1); - if(pclass1->create_data < pclass2->create_data) HGOTO_DONE(-1); - if(pclass1->create_data > pclass2->create_data) HGOTO_DONE(1); + if (pclass1->create_func == NULL && pclass2->create_func != NULL) + HGOTO_DONE(-1); + if (pclass1->create_func != NULL && pclass2->create_func == NULL) + HGOTO_DONE(1); + if (pclass1->create_func != pclass2->create_func) + HGOTO_DONE(-1); + if (pclass1->create_data < pclass2->create_data) + HGOTO_DONE(-1); + if (pclass1->create_data > pclass2->create_data) + HGOTO_DONE(1); /* Check whether they have close callback functions & data */ - if(pclass1->close_func == NULL && pclass2->close_func != NULL) HGOTO_DONE(-1); - if(pclass1->close_func != NULL && pclass2->close_func == NULL) HGOTO_DONE(1); - if(pclass1->close_func != pclass2->close_func) HGOTO_DONE(-1); - if(pclass1->close_data < pclass2->close_data) HGOTO_DONE(-1); - if(pclass1->close_data > pclass2->close_data) HGOTO_DONE(1); + if (pclass1->close_func == NULL && pclass2->close_func != NULL) + HGOTO_DONE(-1); + if (pclass1->close_func != NULL && pclass2->close_func == NULL) + HGOTO_DONE(1); + if (pclass1->close_func != pclass2->close_func) + HGOTO_DONE(-1); + if (pclass1->close_data < pclass2->close_data) + HGOTO_DONE(-1); + if (pclass1->close_data > pclass2->close_data) + HGOTO_DONE(1); /* Cycle through the properties and compare them also */ tnode1 = H5SL_first(pclass1->props); tnode2 = H5SL_first(pclass2->props); - while(tnode1 || tnode2) { - H5P_genprop_t *prop1, *prop2; /* Property for node */ + while (tnode1 || tnode2) { + H5P_genprop_t *prop1, *prop2; /* Property for node */ /* Check if they both have properties in this skip list node */ - if(tnode1 == NULL && tnode2 != NULL) HGOTO_DONE(-1); - if(tnode1 != NULL && tnode2 == NULL) HGOTO_DONE(1); + if (tnode1 == NULL && tnode2 != NULL) + HGOTO_DONE(-1); + if (tnode1 != NULL && tnode2 == NULL) + HGOTO_DONE(1); /* Compare the two properties */ prop1 = (H5P_genprop_t *)H5SL_item(tnode1); prop2 = (H5P_genprop_t *)H5SL_item(tnode2); - if((cmp_value = H5P__cmp_prop(prop1, prop2)) != 0) + if ((cmp_value = H5P__cmp_prop(prop1, prop2)) != 0) HGOTO_DONE(cmp_value); /* Advance the pointers */ @@ -3732,9 +3712,8 @@ H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__cmp_class() */ +} /* H5P__cmp_class() */ - /*-------------------------------------------------------------------------- NAME H5P__cmp_plist_cb @@ -3761,9 +3740,9 @@ done: static int H5P__cmp_plist_cb(H5P_genprop_t *prop, void *_udata) { - H5P_plist_cmp_ud_t *udata = (H5P_plist_cmp_ud_t *)_udata; /* Pointer to user data */ - htri_t prop2_exist; /* Whether the property exists in the second property list */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5P_plist_cmp_ud_t *udata = (H5P_plist_cmp_ud_t *)_udata; /* Pointer to user data */ + htri_t prop2_exist; /* Whether the property exists in the second property list */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -3772,17 +3751,17 @@ H5P__cmp_plist_cb(H5P_genprop_t *prop, void *_udata) HDassert(udata); /* Check if the property exists in the second property list */ - if((prop2_exist = H5P_exist_plist(udata->plist2, prop->name)) < 0) + if ((prop2_exist = H5P_exist_plist(udata->plist2, prop->name)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5_ITER_ERROR, "can't lookup existance of property?") - if(prop2_exist) { - const H5P_genprop_t *prop2; /* Pointer to property in second plist */ + if (prop2_exist) { + const H5P_genprop_t *prop2; /* Pointer to property in second plist */ /* Look up same property in second property list */ - if(NULL == (prop2 = H5P__find_prop_plist(udata->plist2, prop->name))) + if (NULL == (prop2 = H5P__find_prop_plist(udata->plist2, prop->name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5_ITER_ERROR, "property doesn't exist") /* Compare the two properties */ - if((udata->cmp_value = H5P__cmp_prop(prop, prop2)) != 0) + if ((udata->cmp_value = H5P__cmp_prop(prop, prop2)) != 0) HGOTO_DONE(H5_ITER_STOP); } /* end if */ else { @@ -3795,7 +3774,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__cmp_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__cmp_plist @@ -3821,12 +3799,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, - int *cmp_ret) +H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, int *cmp_ret) { - H5P_plist_cmp_ud_t udata; /* User data for callback */ - int idx = 0; /* Index of property to begin with */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_plist_cmp_ud_t udata; /* User data for callback */ + int idx = 0; /* Index of property to begin with */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3835,39 +3812,39 @@ H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, HDassert(cmp_ret); /* Check the number of properties */ - if(plist1->nprops < plist2->nprops) { + if (plist1->nprops < plist2->nprops) { *cmp_ret = -1; HGOTO_DONE(SUCCEED); } /* end if */ - if(plist1->nprops > plist2->nprops) { + if (plist1->nprops > plist2->nprops) { *cmp_ret = 1; HGOTO_DONE(SUCCEED); } /* end if */ /* Check whether they've been initialized */ - if(plist1->class_init < plist2->class_init) { + if (plist1->class_init < plist2->class_init) { *cmp_ret = -1; HGOTO_DONE(SUCCEED); } /* end if */ - if(plist1->class_init > plist2->class_init) { + if (plist1->class_init > plist2->class_init) { *cmp_ret = 1; HGOTO_DONE(SUCCEED); } /* end if */ /* Set up iterator callback info */ udata.cmp_value = 0; - udata.plist2 = plist2; + udata.plist2 = plist2; /* Iterate over properties in first property list */ - if((ret_value = H5P__iterate_plist(plist1, TRUE, &idx, H5P__cmp_plist_cb, &udata)) < 0) + if ((ret_value = H5P__iterate_plist(plist1, TRUE, &idx, H5P__cmp_plist_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list") - if(ret_value != 0) { + if (ret_value != 0) { *cmp_ret = udata.cmp_value; HGOTO_DONE(SUCCEED); } /* end if */ /* Check the parent classes */ - if((*cmp_ret = H5P__cmp_class(plist1->pclass, plist2->pclass)) != 0) + if ((*cmp_ret = H5P__cmp_class(plist1->pclass, plist2->pclass)) != 0) HGOTO_DONE(SUCCEED); /* Property lists must be equal, set comparison value to 0 */ @@ -3875,9 +3852,8 @@ H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__cmp_plist() */ +} /* H5P__cmp_plist() */ - /*-------------------------------------------------------------------------- NAME H5P_class_isa @@ -3904,7 +3880,7 @@ done: htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3912,11 +3888,12 @@ H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) HDassert(pclass2); /* Compare property classes */ - if(H5P__cmp_class(pclass1, pclass2) == 0) { + if (H5P__cmp_class(pclass1, pclass2) == 0) { HGOTO_DONE(TRUE); - } else { + } + else { /* Check if the class is derived, and walk up the chain, if so */ - if(pclass1->parent != NULL) + if (pclass1->parent != NULL) ret_value = H5P_class_isa(pclass1->parent, pclass2); else HGOTO_DONE(FALSE); @@ -3924,9 +3901,8 @@ H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_class_isa() */ +} /* H5P_class_isa() */ - /*-------------------------------------------------------------------------- NAME H5P_isa_class @@ -3955,27 +3931,26 @@ done: htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id) { - H5P_genplist_t *plist; /* Property list to query */ - H5P_genclass_t *pclass; /* Property list class */ - htri_t ret_value = FAIL; /* Return value */ + H5P_genplist_t *plist; /* Property list to query */ + H5P_genclass_t *pclass; /* Property list class */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class") /* Compare the property list's class against the other class */ - if((ret_value = H5P_class_isa(plist->pclass, pclass)) < 0) + if ((ret_value = H5P_class_isa(plist->pclass, pclass)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_isa_class() */ +} /* H5P_isa_class() */ - /*-------------------------------------------------------------------------- NAME H5P_object_verify @@ -4007,23 +3982,22 @@ done: H5P_genplist_t * H5P_object_verify(hid_t plist_id, hid_t pclass_id) { - H5P_genplist_t *ret_value = NULL; /* Return value */ + H5P_genplist_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Compare the property list's class against the other class */ - if(H5P_isa_class(plist_id, pclass_id) != TRUE) + if (H5P_isa_class(plist_id, pclass_id) != TRUE) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, NULL, "property list is not a member of the class") /* Get the plist structure */ - if(NULL == (ret_value = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (ret_value = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_object_verify() */ +} /* H5P_object_verify() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_plist_cb @@ -4047,10 +4021,10 @@ property list. static int H5P__iterate_plist_cb(void *_item, void *_key, void *_udata) { - H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ - char *key = (char *)_key; /* Pointer to the property's name */ - H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5P_genprop_t * item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char * key = (char *)_key; /* Pointer to the property's name */ + H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -4059,10 +4033,10 @@ H5P__iterate_plist_cb(void *_item, void *_key, void *_udata) HDassert(key); /* Check if we've found the correctly indexed property */ - if(*udata->curr_idx_ptr >= udata->prev_idx) { + if (*udata->curr_idx_ptr >= udata->prev_idx) { /* Call the callback function */ ret_value = (*udata->cb_func)(item, udata->udata); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); } /* end if */ @@ -4070,14 +4044,13 @@ H5P__iterate_plist_cb(void *_item, void *_key, void *_udata) (*udata->curr_idx_ptr)++; /* Add property name to 'seen' list */ - if(H5SL_insert(udata->seen, key, key) < 0) + if (H5SL_insert(udata->seen, key, key) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert property into 'seen' skip list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__iterate_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_plist_pclass_cb @@ -4101,10 +4074,10 @@ deleted, and then chains to the property list callback. static int H5P__iterate_plist_pclass_cb(void *_item, void *_key, void *_udata) { - H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ - char *key = (char *)_key; /* Pointer to the property's name */ - H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5P_genprop_t * item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char * key = (char *)_key; /* Pointer to the property's name */ + H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -4115,14 +4088,12 @@ H5P__iterate_plist_pclass_cb(void *_item, void *_key, void *_udata) /* Only call iterator callback for properties we haven't seen * before and that haven't been deleted. */ - if(NULL == H5SL_search(udata->seen, key) && - NULL == H5SL_search(udata->plist->del, key)) + if (NULL == H5SL_search(udata->seen, key) && NULL == H5SL_search(udata->plist->del, key)) ret_value = H5P__iterate_plist_cb(item, key, udata); FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__iterate_plist_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_plist @@ -4178,14 +4149,14 @@ iteration, the function's behavior is undefined. REVISION LOG --------------------------------------------------------------------------*/ int -H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, int *idx, - H5P_iterate_int_t cb_func, void *udata) +H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, int *idx, H5P_iterate_int_t cb_func, + void *udata) { - H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genclass_t * tclass; /* Temporary class pointer */ H5P_iter_plist_ud_t udata_int; /* User data for skip list iterator */ - H5SL_t *seen = NULL; /* Skip list to hold names of properties already seen */ - int curr_idx = 0; /* Current iteration index */ - int ret_value = 0; /* Return value */ + H5SL_t * seen = NULL; /* Skip list to hold names of properties already seen */ + int curr_idx = 0; /* Current iteration index */ + int ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE @@ -4195,50 +4166,49 @@ H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, int *idx, HDassert(cb_func); /* Create the skip list to hold names of properties already seen */ - if(NULL == (seen = H5SL_create(H5SL_TYPE_STR, NULL))) + if (NULL == (seen = H5SL_create(H5SL_TYPE_STR, NULL))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "can't create skip list for seen properties") /* Set up iterator callback info */ - udata_int.plist = plist; - udata_int.cb_func = cb_func; - udata_int.udata = udata; - udata_int.seen = seen; + udata_int.plist = plist; + udata_int.cb_func = cb_func; + udata_int.udata = udata; + udata_int.seen = seen; udata_int.curr_idx_ptr = &curr_idx; - udata_int.prev_idx = *idx; + udata_int.prev_idx = *idx; /* Iterate over properties in property list proper */ /* (Will be only the non-default (i.e. changed) properties) */ ret_value = H5SL_iterate(plist->props, H5P__iterate_plist_cb, &udata_int); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); /* Check for iterating over all properties, or just non-default ones */ - if(iter_all_prop) { + if (iter_all_prop) { /* Walk up the class hierarchy */ tclass = plist->pclass; - while(tclass != NULL) { + while (tclass != NULL) { /* Iterate over properties in property list class */ ret_value = H5SL_iterate(tclass->props, H5P__iterate_plist_pclass_cb, &udata_int); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); /* Go up to parent class */ tclass = tclass->parent; } /* end while */ - } /* end if */ + } /* end if */ done: /* Set the index we stopped at */ *idx = curr_idx; /* Release the skip list of 'seen' properties */ - if(seen != NULL) + if (seen != NULL) H5SL_close(seen); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__iterate_plist() */ +} /* H5P__iterate_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_pclass_cb @@ -4263,9 +4233,9 @@ property list class. static int H5P__iterate_pclass_cb(void *_item, void H5_ATTR_NDEBUG_UNUSED *_key, void *_udata) { - H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ - H5P_iter_pclass_ud_t *udata = (H5P_iter_pclass_ud_t *)_udata; /* Pointer to user data */ - int ret_value = 0; /* Return value */ + H5P_genprop_t * item = (H5P_genprop_t *)_item; /* Pointer to the property */ + H5P_iter_pclass_ud_t *udata = (H5P_iter_pclass_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -4274,10 +4244,10 @@ H5P__iterate_pclass_cb(void *_item, void H5_ATTR_NDEBUG_UNUSED *_key, void *_uda HDassert((char *)_key); /* Check if we've found the correctly indexed property */ - if(*udata->curr_idx_ptr >= udata->prev_idx) { + if (*udata->curr_idx_ptr >= udata->prev_idx) { /* Call the callback function */ ret_value = (*udata->cb_func)(item, udata->udata); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); } /* end if */ @@ -4288,7 +4258,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__iterate_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_pclass @@ -4341,12 +4310,11 @@ iteration, the function's behavior is undefined. REVISION LOG --------------------------------------------------------------------------*/ int -H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, - H5P_iterate_int_t cb_func, void *udata) +H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, H5P_iterate_int_t cb_func, void *udata) { - H5P_iter_pclass_ud_t udata_int; /* User data for skip list iterator */ - int curr_idx = 0; /* Current iteration index */ - int ret_value = 0; /* Return value */ + H5P_iter_pclass_ud_t udata_int; /* User data for skip list iterator */ + int curr_idx = 0; /* Current iteration index */ + int ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -4356,14 +4324,14 @@ H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, HDassert(cb_func); /* Set up iterator callback info */ - udata_int.cb_func = cb_func; - udata_int.udata = udata; + udata_int.cb_func = cb_func; + udata_int.udata = udata; udata_int.curr_idx_ptr = &curr_idx; - udata_int.prev_idx = *idx; + udata_int.prev_idx = *idx; /* Iterate over properties in property list class proper */ ret_value = H5SL_iterate(pclass->props, H5P__iterate_pclass_cb, &udata_int); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); done: @@ -4371,9 +4339,8 @@ done: *idx = curr_idx; FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__iterate_pclass() */ +} /* H5P__iterate_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__peek_cb @@ -4398,10 +4365,10 @@ done: --------------------------------------------------------------------------*/ static herr_t H5P__peek_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDEBUG_UNUSED *name, - H5P_genprop_t *prop, void *_udata) + H5P_genprop_t *prop, void *_udata) { - H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4411,7 +4378,7 @@ H5P__peek_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDE HDassert(prop); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a (shallow) copy of the value */ @@ -4419,9 +4386,8 @@ H5P__peek_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDE done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__peek_cb() */ +} /* H5P__peek_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_peek @@ -4449,8 +4415,8 @@ done: herr_t H5P_peek(H5P_genplist_t *plist, const char *name, void *value) { - H5P_prop_get_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_get_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4461,14 +4427,13 @@ H5P_peek(H5P_genplist_t *plist, const char *name, void *value) /* Find the property and peek at the value */ udata.value = value; - if(H5P__do_prop(plist, name, H5P__peek_cb, H5P__peek_cb, &udata) < 0) + if (H5P__do_prop(plist, name, H5P__peek_cb, H5P__peek_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to peek at value") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P_peek() */ - /*-------------------------------------------------------------------------- NAME H5P__get_cb @@ -4492,12 +4457,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *_udata) +H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void *_udata) { - H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ - void *tmp_value = NULL; /* Temporary value for property */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ + void * tmp_value = NULL; /* Temporary value for property */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4507,18 +4471,18 @@ H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Call the 'get' callback, if there is one */ - if(NULL != prop->get) { + if (NULL != prop->get) { /* Make a copy of the current value, in case the callback fails */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) + if (NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call user's callback */ - if((*(prop->get))(plist->plist_id, name, prop->size, tmp_value) < 0) + if ((*(prop->get))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") /* Copy new [possibly unchanged] value into return value */ @@ -4530,13 +4494,12 @@ H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, done: /* Free the temporary value buffer */ - if(tmp_value) + if (tmp_value) H5MM_xfree(tmp_value); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_cb() */ +} /* H5P__get_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_get @@ -4568,8 +4531,8 @@ done: herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value) { - H5P_prop_get_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_get_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4580,14 +4543,13 @@ H5P_get(H5P_genplist_t *plist, const char *name, void *value) /* Find the property and get the value */ udata.value = value; - if(H5P__do_prop(plist, name, H5P__get_cb, H5P__get_cb, &udata) < 0) + if (H5P__do_prop(plist, name, H5P__get_cb, H5P__get_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to get value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_get() */ +} /* H5P_get() */ - /*-------------------------------------------------------------------------- NAME H5P__del_plist_cb @@ -4610,10 +4572,9 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void H5_ATTR_UNUSED *_udata) +H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void H5_ATTR_UNUSED *_udata) { - char *del_name = NULL; /* Pointer to deleted name */ + char * del_name = NULL; /* Pointer to deleted name */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4624,22 +4585,22 @@ H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop); /* Pass value to 'close' callback, if it exists */ - if(NULL != prop->del) { + if (NULL != prop->del) { /* Call user's callback */ - if((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) + if ((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release property value") } /* end if */ /* Duplicate string for insertion into new deleted property skip list */ - if(NULL == (del_name = H5MM_xstrdup(name))) + if (NULL == (del_name = H5MM_xstrdup(name))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Insert property name into deleted list */ - if(H5SL_insert(plist->del, del_name, del_name) < 0) + if (H5SL_insert(plist->del, del_name, del_name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into deleted skip list") /* Remove the property from the skip list */ - if(NULL == H5SL_remove(plist->props, prop->name)) + if (NULL == H5SL_remove(plist->props, prop->name)) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove property from skip list") /* Free the property, ignoring return value, nothing we can do */ @@ -4650,14 +4611,13 @@ H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, done: /* Error cleanup */ - if(ret_value < 0) - if(del_name) + if (ret_value < 0) + if (del_name) H5MM_xfree(del_name); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__del_plist_cb() */ +} /* H5P__del_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__del_pclass_cb @@ -4680,11 +4640,10 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void H5_ATTR_UNUSED *_udata) +H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void H5_ATTR_UNUSED *_udata) { - char *del_name = NULL; /* Pointer to deleted name */ - void *tmp_value = NULL; /* Temporary value for property */ + char * del_name = NULL; /* Pointer to deleted name */ + void * tmp_value = NULL; /* Temporary value for property */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4695,23 +4654,24 @@ H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop); /* Pass value to 'del' callback, if it exists */ - if(NULL != prop->del) { + if (NULL != prop->del) { /* Allocate space for a temporary copy of the property value */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value") + if (NULL == (tmp_value = H5MM_malloc(prop->size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, + "memory allocation failed for temporary property value") H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call user's callback */ - if((*(prop->del))(plist->plist_id, name, prop->size, tmp_value) < 0) + if ((*(prop->del))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't close property value") } /* end if */ /* Duplicate string for insertion into new deleted property skip list */ - if(NULL == (del_name = H5MM_xstrdup(name))) + if (NULL == (del_name = H5MM_xstrdup(name))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Insert property name into deleted list */ - if(H5SL_insert(plist->del, del_name, del_name) < 0) + if (H5SL_insert(plist->del, del_name, del_name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into deleted skip list") /* Decrement the number of properties in list */ @@ -4719,18 +4679,17 @@ H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, done: /* Free the temporary value buffer */ - if(tmp_value) + if (tmp_value) H5MM_xfree(tmp_value); /* Error cleanup */ - if(ret_value < 0) - if(del_name) + if (ret_value < 0) + if (del_name) H5MM_xfree(del_name); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__del_pclass_cb() */ +} /* H5P__del_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_remove @@ -4760,7 +4719,7 @@ done: herr_t H5P_remove(H5P_genplist_t *plist, const char *name) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4769,14 +4728,13 @@ H5P_remove(H5P_genplist_t *plist, const char *name) HDassert(name); /* Find the property and get the value */ - if(H5P__do_prop(plist, name, H5P__del_plist_cb, H5P__del_pclass_cb, NULL) < 0) + if (H5P__do_prop(plist, name, H5P__del_plist_cb, H5P__del_pclass_cb, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to remove value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_remove() */ +} /* H5P_remove() */ - /*-------------------------------------------------------------------------- NAME H5P__copy_prop_plist @@ -4811,42 +4769,43 @@ done: herr_t H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) { - H5P_genplist_t *dst_plist; /* Pointer to destination property list */ - H5P_genplist_t *src_plist; /* Pointer to source property list */ - H5P_genprop_t *prop; /* Temporary property pointer */ - H5P_genprop_t *new_prop=NULL; /* Pointer to new property */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *dst_plist; /* Pointer to destination property list */ + H5P_genplist_t *src_plist; /* Pointer to source property list */ + H5P_genprop_t * prop; /* Temporary property pointer */ + H5P_genprop_t * new_prop = NULL; /* Pointer to new property */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE HDassert(name); /* Get the objects to operate on */ - if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_id)) || NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_id))) + if (NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_id)) || + NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist") /* If the property exists in the destination alread */ - if(NULL != H5P__find_prop_plist(dst_plist, name)) { + if (NULL != H5P__find_prop_plist(dst_plist, name)) { /* Delete the property from the destination list, calling the 'close' callback if necessary */ - if(H5P_remove(dst_plist, name) < 0) + if (H5P_remove(dst_plist, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") /* Get the pointer to the source property */ prop = H5P__find_prop_plist(src_plist, name); /* Make a copy of the source property */ - if((new_prop = H5P__dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property") + if ((new_prop = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") /* Call property copy callback, if it exists */ - if(new_prop->copy) { - if((new_prop->copy)(new_prop->name,new_prop->size,new_prop->value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property") + if (new_prop->copy) { + if ((new_prop->copy)(new_prop->name, new_prop->size, new_prop->value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") } /* end if */ /* Insert the initialized property into the property list */ - if(H5P__add_prop(dst_plist->props,new_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into list") + if (H5P__add_prop(dst_plist->props, new_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into list") /* Increment the number of properties in list */ dst_plist->nprops++; @@ -4857,20 +4816,21 @@ H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) prop = H5P__find_prop_plist(src_plist, name); /* Create property object from parameters */ - if(NULL == (new_prop = H5P__create_prop(prop->name, prop->size, H5P_PROP_WITHIN_LIST, prop->value, - prop->create, prop->set, prop->get, prop->encode, prop->decode, - prop->del, prop->copy, prop->cmp, prop->close))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property") + if (NULL == + (new_prop = H5P__create_prop(prop->name, prop->size, H5P_PROP_WITHIN_LIST, prop->value, + prop->create, prop->set, prop->get, prop->encode, prop->decode, + prop->del, prop->copy, prop->cmp, prop->close))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "Can't create property") /* Call property creation callback, if it exists */ - if(new_prop->create) { - if((new_prop->create)(new_prop->name, new_prop->size, new_prop->value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property") + if (new_prop->create) { + if ((new_prop->create)(new_prop->name, new_prop->size, new_prop->value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "Can't initialize property") } /* end if */ /* Insert property into property list class */ - if(H5P__add_prop(dst_plist->props, new_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class") + if (H5P__add_prop(dst_plist->props, new_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into class") /* Increment property count for class */ dst_plist->nprops++; @@ -4878,15 +4838,14 @@ H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) done: /* Cleanup, if necessary */ - if(ret_value < 0) { - if(new_prop != NULL) + if (ret_value < 0) { + if (new_prop != NULL) H5P__free_prop(new_prop); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__copy_prop_plist() */ +} /* H5P__copy_prop_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__copy_prop_pclass @@ -4919,11 +4878,11 @@ done: herr_t H5P__copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name) { - H5P_genclass_t *src_pclass; /* Source property class, containing property to copy */ - H5P_genclass_t *dst_pclass; /* Destination property class */ - H5P_genclass_t *orig_dst_pclass; /* Original destination property class */ - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genclass_t *src_pclass; /* Source property class, containing property to copy */ + H5P_genclass_t *dst_pclass; /* Destination property class */ + H5P_genclass_t *orig_dst_pclass; /* Original destination property class */ + H5P_genprop_t * prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -4931,49 +4890,49 @@ H5P__copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name) HDassert(name); /* Get property list classes */ - if(NULL == (src_pclass = (H5P_genclass_t *)H5I_object(src_id))) + if (NULL == (src_pclass = (H5P_genclass_t *)H5I_object(src_id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "source property class object doesn't exist") - if(NULL == (dst_pclass = (H5P_genclass_t *)H5I_object(dst_id))) + if (NULL == (dst_pclass = (H5P_genclass_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "destination property class object doesn't exist") /* Get the property from the source */ - if(NULL == (prop = H5P__find_prop_pclass(src_pclass, name))) + if (NULL == (prop = H5P__find_prop_pclass(src_pclass, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "unable to locate property") /* If the property exists in the destination already */ - if(H5P__exist_pclass(dst_pclass, name)) { + if (H5P__exist_pclass(dst_pclass, name)) { /* Delete the old property from the destination class */ - if(H5P__unregister(dst_pclass, name) < 0) + if (H5P__unregister(dst_pclass, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") } /* end if */ /* Register the property into the destination */ orig_dst_pclass = dst_pclass; - if(H5P__register(&dst_pclass, name, prop->size, prop->value, prop->create, prop->set, prop->get, - prop->encode, prop->decode, prop->del, prop->copy, prop->cmp, prop->close) < 0) + if (H5P__register(&dst_pclass, name, prop->size, prop->value, prop->create, prop->set, prop->get, + prop->encode, prop->decode, prop->del, prop->copy, prop->cmp, prop->close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") /* Check if the property class changed and needs to be substituted in the ID */ - if(dst_pclass != orig_dst_pclass) { - H5P_genclass_t *old_dst_pclass; /* Old destination property class */ + if (dst_pclass != orig_dst_pclass) { + H5P_genclass_t *old_dst_pclass; /* Old destination property class */ /* Substitute the new destination property class in the ID */ - if(NULL == (old_dst_pclass = (H5P_genclass_t *)H5I_subst(dst_id, dst_pclass))) + if (NULL == (old_dst_pclass = (H5P_genclass_t *)H5I_subst(dst_id, dst_pclass))) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to substitute property class in ID") HDassert(old_dst_pclass == orig_dst_pclass); /* Close the previous class */ - if(H5P__close_class(old_dst_pclass) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "unable to close original property class after substitution") + if (H5P__close_class(old_dst_pclass) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, + "unable to close original property class after substitution") } /* end if */ done: /* Cleanup, if necessary */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__copy_prop_pclass() */ +} /* H5P__copy_prop_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__unregister @@ -4998,8 +4957,8 @@ done: herr_t H5P__unregister(H5P_genclass_t *pclass, const char *name) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5007,12 +4966,12 @@ H5P__unregister(H5P_genclass_t *pclass, const char *name) HDassert(name); /* Get the property node from the skip list */ - if((prop = (H5P_genprop_t *)H5SL_search(pclass->props,name)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list") + if ((prop = (H5P_genprop_t *)H5SL_search(pclass->props, name)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't find property in skip list") /* Remove the property from the skip list */ - if(H5SL_remove(pclass->props,prop->name) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from skip list") + if (H5SL_remove(pclass->props, prop->name) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove property from skip list") /* Free the property, ignoring return value, nothing we can do */ H5P__free_prop(prop); @@ -5025,9 +4984,8 @@ H5P__unregister(H5P_genclass_t *pclass, const char *name) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__unregister() */ +} /* H5P__unregister() */ - /*-------------------------------------------------------------------------- NAME H5P_close @@ -5055,16 +5013,16 @@ done: herr_t H5P_close(void *_plist) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genplist_t *plist=(H5P_genplist_t *)_plist; - H5SL_t *seen=NULL; /* Skip list to hold names of properties already seen */ - size_t nseen; /* Number of items 'seen' */ - hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ - size_t ndel; /* Number of items deleted */ - H5SL_node_t *curr_node; /* Current node in skip list */ - H5P_genprop_t *tmp; /* Temporary pointer to properties */ - unsigned make_cb=0; /* Operator data for property free callback */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genplist_t *plist = (H5P_genplist_t *)_plist; + H5SL_t * seen = NULL; /* Skip list to hold names of properties already seen */ + size_t nseen; /* Number of items 'seen' */ + hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ + size_t ndel; /* Number of items deleted */ + H5SL_node_t * curr_node; /* Current node in skip list */ + H5P_genprop_t * tmp; /* Temporary pointer to properties */ + unsigned make_cb = 0; /* Operator data for property free callback */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT @@ -5073,10 +5031,10 @@ H5P_close(void *_plist) /* Make call to property list class close callback, if needed * (up through chain of parent classes also) */ - if(plist->class_init) { + if (plist->class_init) { tclass = plist->pclass; - while(NULL != tclass) { - if(NULL != tclass->close_func) { + while (NULL != tclass) { + if (NULL != tclass->close_func) { /* Call user's "close" callback function, ignoring return value */ (tclass->close_func)(plist->plist_id, tclass->close_data); } /* end if */ @@ -5084,98 +5042,100 @@ H5P_close(void *_plist) /* Go up to parent class */ tclass = tclass->parent; } /* end while */ - } /* end if */ + } /* end if */ /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'close' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties") + if ((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "can't create skip list for seen properties") nseen = 0; /* Walk through the changed properties in the list */ - if(H5SL_count(plist->props)>0) { - curr_node=H5SL_first(plist->props); - while(curr_node!=NULL) { + if (H5SL_count(plist->props) > 0) { + curr_node = H5SL_first(plist->props); + while (curr_node != NULL) { /* Get pointer to property from node */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Call property close callback, if it exists */ - if(tmp->close) { + if (tmp->close) { /* Call the 'close' callback */ - (tmp->close)(tmp->name,tmp->size,tmp->value); + (tmp->close)(tmp->name, tmp->size, tmp->value); } /* end if */ /* Add property name to "seen" list */ - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list") + if (H5SL_insert(seen, tmp->name, tmp->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into seen skip list") nseen++; /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Determine number of deleted items from property list */ - ndel=H5SL_count(plist->del); + ndel = H5SL_count(plist->del); /* * Check if we should remove class properties (up through list of parent classes also), * initialize each with default value & make property 'remove' callback. */ - tclass=plist->pclass; + tclass = plist->pclass; has_parent_class = (hbool_t)(tclass != NULL && tclass->parent != NULL && tclass->parent->nprops > 0); - while(tclass!=NULL) { - if(tclass->nprops>0) { + while (tclass != NULL) { + if (tclass->nprops > 0) { /* Walk through the properties in the class */ - curr_node=H5SL_first(tclass->props); - while(curr_node!=NULL) { + curr_node = H5SL_first(tclass->props); + while (curr_node != NULL) { /* Get pointer to property from node */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Only "delete" properties we haven't seen before * and that haven't already been deleted */ - if((nseen==0 || H5SL_search(seen,tmp->name) == NULL) && - (ndel==0 || H5SL_search(plist->del,tmp->name) == NULL)) { + if ((nseen == 0 || H5SL_search(seen, tmp->name) == NULL) && + (ndel == 0 || H5SL_search(plist->del, tmp->name) == NULL)) { /* Call property close callback, if it exists */ - if(tmp->close) { - void *tmp_value; /* Temporary value buffer */ + if (tmp->close) { + void *tmp_value; /* Temporary value buffer */ /* Allocate space for a temporary copy of the property value */ - if(NULL==(tmp_value=H5MM_malloc(tmp->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value") - H5MM_memcpy(tmp_value,tmp->value,tmp->size); + if (NULL == (tmp_value = H5MM_malloc(tmp->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for temporary property value") + H5MM_memcpy(tmp_value, tmp->value, tmp->size); /* Call the 'close' callback */ - (tmp->close)(tmp->name,tmp->size,tmp_value); + (tmp->close)(tmp->name, tmp->size, tmp_value); /* Release the temporary value buffer */ H5MM_xfree(tmp_value); } /* end if */ /* Add property name to "seen" list, if we have other classes to work on */ - if(has_parent_class) { - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list") + if (has_parent_class) { + if (H5SL_insert(seen, tmp->name, tmp->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, + "can't insert property into seen skip list") nseen++; } /* end if */ - } /* end if */ + } /* end if */ /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Go up to parent class */ - tclass=tclass->parent; + tclass = tclass->parent; } /* end while */ /* Decrement class's dependent property list value! */ - if(H5P__access_class(plist->pclass,H5P_MOD_DEC_LST) < 0) + if (H5P__access_class(plist->pclass, H5P_MOD_DEC_LST) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "Can't decrement class ref count") /* Free the list of 'seen' properties */ @@ -5193,13 +5153,12 @@ H5P_close(void *_plist) done: /* Release the skip list of 'seen' properties */ - if(seen != NULL) + if (seen != NULL) H5SL_close(seen); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_close() */ +} /* H5P_close() */ - /*-------------------------------------------------------------------------- NAME H5P_get_class_name @@ -5223,20 +5182,19 @@ done: char * H5P_get_class_name(H5P_genclass_t *pclass) { - char *ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) HDassert(pclass); /* Get class name */ - ret_value=H5MM_xstrdup(pclass->name); + ret_value = H5MM_xstrdup(pclass->name); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_get_class_name() */ +} /* H5P_get_class_name() */ - /*-------------------------------------------------------------------------- NAME H5P__get_class_path @@ -5261,26 +5219,27 @@ done: char * H5P__get_class_path(H5P_genclass_t *pclass) { - char *ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE HDassert(pclass); /* Recursively build the full path */ - if(pclass->parent != NULL) { - char *par_path; /* Parent class's full path */ + if (pclass->parent != NULL) { + char *par_path; /* Parent class's full path */ /* Get the parent class's path */ par_path = H5P__get_class_path(pclass->parent); - if(par_path != NULL) { + if (par_path != NULL) { size_t ret_str_len; /* Allocate enough space for the parent class's path, plus the '/' * separator, this class's name and the string terminator */ - ret_str_len = HDstrlen(par_path) + HDstrlen(pclass->name) + 1 + 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */ - if(NULL == (ret_value = (char *)H5MM_malloc(ret_str_len))) + ret_str_len = HDstrlen(par_path) + HDstrlen(pclass->name) + 1 + + 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */ + if (NULL == (ret_value = (char *)H5MM_malloc(ret_str_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for class name") /* Build the full path for this class */ @@ -5297,9 +5256,8 @@ H5P__get_class_path(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_class_path() */ +} /* H5P__get_class_path() */ - /*-------------------------------------------------------------------------- NAME H5P__open_class_path @@ -5322,12 +5280,12 @@ done: H5P_genclass_t * H5P__open_class_path(const char *path) { - char *tmp_path = NULL; /* Temporary copy of the path */ - char *curr_name; /* Pointer to current component of path name */ - char *delimit; /* Pointer to path delimiter during traversal */ - H5P_genclass_t *curr_class; /* Pointer to class during path traversal */ - H5P_check_class_t check_info; /* Structure to hold the information for checking duplicate names */ - H5P_genclass_t *ret_value = NULL; /* Return value */ + char * tmp_path = NULL; /* Temporary copy of the path */ + char * curr_name; /* Pointer to current component of path name */ + char * delimit; /* Pointer to path delimiter during traversal */ + H5P_genclass_t * curr_class; /* Pointer to class during path traversal */ + H5P_check_class_t check_info; /* Structure to hold the information for checking duplicate names */ + H5P_genclass_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -5338,43 +5296,43 @@ H5P__open_class_path(const char *path) HDassert(tmp_path); /* Find the generic property class with this full path */ - curr_name = tmp_path; + curr_name = tmp_path; curr_class = NULL; - while(NULL != (delimit = HDstrchr(curr_name, '/'))) { + while (NULL != (delimit = HDstrchr(curr_name, '/'))) { /* Change the delimiter to terminate the string */ *delimit = '\0'; /* Set up the search structure */ - check_info.parent = curr_class; - check_info.name = curr_name; + check_info.parent = curr_class; + check_info.name = curr_name; check_info.new_class = NULL; /* Find the class with this name & parent by iterating over the open classes */ - if(H5I_iterate(H5I_GENPROP_CLS, H5P__open_class_path_cb, &check_info, FALSE) < 0) + if (H5I_iterate(H5I_GENPROP_CLS, H5P__open_class_path_cb, &check_info, FALSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADITER, NULL, "can't iterate over classes") - else if(NULL == check_info.new_class) - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class") + else if (NULL == check_info.new_class) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class") /* Advance the pointer in the path to the start of the next component */ curr_class = check_info.new_class; - curr_name = delimit + 1; + curr_name = delimit + 1; } /* end while */ /* Should be pointing to the last component in the path name now... */ /* Set up the search structure */ - check_info.parent = curr_class; - check_info.name = curr_name; + check_info.parent = curr_class; + check_info.name = curr_name; check_info.new_class = NULL; /* Find the class with this name & parent by iterating over the open classes */ - if(H5I_iterate(H5I_GENPROP_CLS, H5P__open_class_path_cb, &check_info, FALSE) < 0) + if (H5I_iterate(H5I_GENPROP_CLS, H5P__open_class_path_cb, &check_info, FALSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADITER, NULL, "can't iterate over classes") - else if(NULL == check_info.new_class) + else if (NULL == check_info.new_class) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class") /* Copy it */ - if(NULL == (ret_value = H5P__copy_pclass(check_info.new_class))) + if (NULL == (ret_value = H5P__copy_pclass(check_info.new_class))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "can't copy property class") done: @@ -5384,7 +5342,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P__open_class_path() */ - /*-------------------------------------------------------------------------- NAME H5P__get_class_parent @@ -5407,7 +5364,7 @@ done: H5P_genclass_t * H5P__get_class_parent(const H5P_genclass_t *pclass) { - H5P_genclass_t *ret_value = NULL; /* Return value */ + H5P_genclass_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -5417,9 +5374,8 @@ H5P__get_class_parent(const H5P_genclass_t *pclass) ret_value = pclass->parent; FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_class_parent() */ +} /* H5P__get_class_parent() */ - /*-------------------------------------------------------------------------- NAME H5P__close_class @@ -5440,22 +5396,21 @@ H5P__get_class_parent(const H5P_genclass_t *pclass) herr_t H5P__close_class(void *_pclass) { - H5P_genclass_t *pclass = (H5P_genclass_t *)_pclass; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genclass_t *pclass = (H5P_genclass_t *)_pclass; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(pclass); /* Decrement the reference count & check if the object should go away */ - if(H5P__access_class(pclass, H5P_MOD_DEC_REF) < 0) + if (H5P__access_class(pclass, H5P_MOD_DEC_REF) < 0) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't decrement ID ref count") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__close_class() */ +} /* H5P__close_class() */ - /*------------------------------------------------------------------------- * Function: H5P__new_plist_of_type * @@ -5472,9 +5427,9 @@ done: hid_t H5P__new_plist_of_type(H5P_plist_type_t type) { - H5P_genclass_t *pclass; /* Class of property list to create */ - hid_t class_id; /* ID of class to create */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genclass_t *pclass; /* Class of property list to create */ + hid_t class_id; /* ID of class to create */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE @@ -5483,13 +5438,14 @@ H5P__new_plist_of_type(H5P_plist_type_t type) HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_REFERENCE_ACCESS); /* Check arguments */ - if(type == H5P_TYPE_USER) + if (type == H5P_TYPE_USER) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, H5I_INVALID_HID, "can't create user property list"); - if(type == H5P_TYPE_ROOT) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, H5I_INVALID_HID, "shouldn't be creating root class property list"); + if (type == H5P_TYPE_ROOT) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, H5I_INVALID_HID, + "shouldn't be creating root class property list"); /* Instantiate a property list of the proper type */ - switch(type) { + switch (type) { case H5P_TYPE_OBJECT_CREATE: class_id = H5P_CLS_OBJECT_CREATE_ID_g; break; @@ -5574,7 +5530,7 @@ H5P__new_plist_of_type(H5P_plist_type_t type) class_id = H5P_CLS_REFERENCE_ACCESS_ID_g; break; - case H5P_TYPE_USER: /* shut compiler warnings up */ + case H5P_TYPE_USER: /* shut compiler warnings up */ case H5P_TYPE_ROOT: case H5P_TYPE_MAX_TYPE: default: @@ -5582,18 +5538,17 @@ H5P__new_plist_of_type(H5P_plist_type_t type) } /* end switch */ /* Get the class object */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(class_id))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object(class_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, H5I_INVALID_HID, "not a property class") /* Create the new property list */ - if((ret_value = H5P_create_id(pclass, TRUE)) < 0) + if ((ret_value = H5P_create_id(pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__new_plist_of_type() */ - /*------------------------------------------------------------------------- * Function: H5P_get_plist_id * @@ -5621,7 +5576,6 @@ H5P_get_plist_id(const H5P_genplist_t *plist) FUNC_LEAVE_NOAPI(plist->plist_id) } /* end H5P_get_plist_id() */ - /*------------------------------------------------------------------------- * Function: H5P_get_class * @@ -5649,7 +5603,6 @@ H5P_get_class(const H5P_genplist_t *plist) FUNC_LEAVE_NOAPI(plist->pclass) } /* end H5P_get_class() */ - /*------------------------------------------------------------------------- * Function: H5P_ignore_cmp * @@ -5660,11 +5613,9 @@ H5P_get_class(const H5P_genplist_t *plist) *------------------------------------------------------------------------- */ int -H5P_ignore_cmp(const void H5_ATTR_UNUSED *val1, const void H5_ATTR_UNUSED *val2, - size_t H5_ATTR_UNUSED size) +H5P_ignore_cmp(const void H5_ATTR_UNUSED *val1, const void H5_ATTR_UNUSED *val2, size_t H5_ATTR_UNUSED size) { FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(0) } /* end H5P_ignore_cmp() */ - diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 8fdcc8b..b9a6b60 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -26,19 +26,17 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -46,64 +44,64 @@ /* ======== Link access properties ======== */ /* Definitions for number of soft links to traverse */ -#define H5L_ACS_NLINKS_SIZE sizeof(size_t) -#define H5L_ACS_NLINKS_DEF H5L_NUM_LINKS /*max symlinks to follow per lookup */ -#define H5L_ACS_NLINKS_ENC H5P__encode_size_t -#define H5L_ACS_NLINKS_DEC H5P__decode_size_t - +#define H5L_ACS_NLINKS_SIZE sizeof(size_t) +#define H5L_ACS_NLINKS_DEF H5L_NUM_LINKS /*max symlinks to follow per lookup */ +#define H5L_ACS_NLINKS_ENC H5P__encode_size_t +#define H5L_ACS_NLINKS_DEC H5P__decode_size_t /* Definitions for external link prefix */ -#define H5L_ACS_ELINK_PREFIX_SIZE sizeof(char *) -#define H5L_ACS_ELINK_PREFIX_DEF NULL /*default is no prefix */ -#define H5L_ACS_ELINK_PREFIX_SET H5P__lacc_elink_pref_set -#define H5L_ACS_ELINK_PREFIX_GET H5P__lacc_elink_pref_get -#define H5L_ACS_ELINK_PREFIX_ENC H5P__lacc_elink_pref_enc -#define H5L_ACS_ELINK_PREFIX_DEC H5P__lacc_elink_pref_dec -#define H5L_ACS_ELINK_PREFIX_DEL H5P__lacc_elink_pref_del -#define H5L_ACS_ELINK_PREFIX_COPY H5P__lacc_elink_pref_copy -#define H5L_ACS_ELINK_PREFIX_CMP H5P__lacc_elink_pref_cmp -#define H5L_ACS_ELINK_PREFIX_CLOSE H5P__lacc_elink_pref_close +#define H5L_ACS_ELINK_PREFIX_SIZE sizeof(char *) +#define H5L_ACS_ELINK_PREFIX_DEF NULL /*default is no prefix */ +#define H5L_ACS_ELINK_PREFIX_SET H5P__lacc_elink_pref_set +#define H5L_ACS_ELINK_PREFIX_GET H5P__lacc_elink_pref_get +#define H5L_ACS_ELINK_PREFIX_ENC H5P__lacc_elink_pref_enc +#define H5L_ACS_ELINK_PREFIX_DEC H5P__lacc_elink_pref_dec +#define H5L_ACS_ELINK_PREFIX_DEL H5P__lacc_elink_pref_del +#define H5L_ACS_ELINK_PREFIX_COPY H5P__lacc_elink_pref_copy +#define H5L_ACS_ELINK_PREFIX_CMP H5P__lacc_elink_pref_cmp +#define H5L_ACS_ELINK_PREFIX_CLOSE H5P__lacc_elink_pref_close /* Definitions for setting fapl of external link access */ -#define H5L_ACS_ELINK_FAPL_SIZE sizeof(hid_t) -#define H5L_ACS_ELINK_FAPL_DEF H5P_DEFAULT -#define H5L_ACS_ELINK_FAPL_SET H5P__lacc_elink_fapl_set -#define H5L_ACS_ELINK_FAPL_GET H5P__lacc_elink_fapl_get -#define H5L_ACS_ELINK_FAPL_ENC H5P__lacc_elink_fapl_enc -#define H5L_ACS_ELINK_FAPL_DEC H5P__lacc_elink_fapl_dec -#define H5L_ACS_ELINK_FAPL_DEL H5P__lacc_elink_fapl_del -#define H5L_ACS_ELINK_FAPL_COPY H5P__lacc_elink_fapl_copy -#define H5L_ACS_ELINK_FAPL_CMP H5P__lacc_elink_fapl_cmp -#define H5L_ACS_ELINK_FAPL_CLOSE H5P__lacc_elink_fapl_close +#define H5L_ACS_ELINK_FAPL_SIZE sizeof(hid_t) +#define H5L_ACS_ELINK_FAPL_DEF H5P_DEFAULT +#define H5L_ACS_ELINK_FAPL_SET H5P__lacc_elink_fapl_set +#define H5L_ACS_ELINK_FAPL_GET H5P__lacc_elink_fapl_get +#define H5L_ACS_ELINK_FAPL_ENC H5P__lacc_elink_fapl_enc +#define H5L_ACS_ELINK_FAPL_DEC H5P__lacc_elink_fapl_dec +#define H5L_ACS_ELINK_FAPL_DEL H5P__lacc_elink_fapl_del +#define H5L_ACS_ELINK_FAPL_COPY H5P__lacc_elink_fapl_copy +#define H5L_ACS_ELINK_FAPL_CMP H5P__lacc_elink_fapl_cmp +#define H5L_ACS_ELINK_FAPL_CLOSE H5P__lacc_elink_fapl_close /* Definitions for file access flags for external link traversal */ -#define H5L_ACS_ELINK_FLAGS_SIZE sizeof(unsigned) -#define H5L_ACS_ELINK_FLAGS_DEF H5F_ACC_DEFAULT -#define H5L_ACS_ELINK_FLAGS_ENC H5P__encode_unsigned -#define H5L_ACS_ELINK_FLAGS_DEC H5P__decode_unsigned +#define H5L_ACS_ELINK_FLAGS_SIZE sizeof(unsigned) +#define H5L_ACS_ELINK_FLAGS_DEF H5F_ACC_DEFAULT +#define H5L_ACS_ELINK_FLAGS_ENC H5P__encode_unsigned +#define H5L_ACS_ELINK_FLAGS_DEC H5P__decode_unsigned /* Definitions for callback function for external link traversal */ -#define H5L_ACS_ELINK_CB_SIZE sizeof(H5L_elink_cb_t) -#define H5L_ACS_ELINK_CB_DEF {NULL,NULL} +#define H5L_ACS_ELINK_CB_SIZE sizeof(H5L_elink_cb_t) +#define H5L_ACS_ELINK_CB_DEF \ + { \ + NULL, NULL \ + } #ifdef H5_HAVE_PARALLEL /* Definition for reading metadata collectively */ -#define H5L_ACS_COLL_MD_READ_SIZE sizeof(H5P_coll_md_read_flag_t) -#define H5L_ACS_COLL_MD_READ_DEF H5P_USER_FALSE -#define H5L_ACS_COLL_MD_READ_ENC H5P__encode_coll_md_read_flag_t -#define H5L_ACS_COLL_MD_READ_DEC H5P__decode_coll_md_read_flag_t +#define H5L_ACS_COLL_MD_READ_SIZE sizeof(H5P_coll_md_read_flag_t) +#define H5L_ACS_COLL_MD_READ_DEF H5P_USER_FALSE +#define H5L_ACS_COLL_MD_READ_ENC H5P__encode_coll_md_read_flag_t +#define H5L_ACS_COLL_MD_READ_DEC H5P__decode_coll_md_read_flag_t #endif /* H5_HAVE_PARALLEL */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -112,23 +110,22 @@ static herr_t H5P__lacc_reg_prop(H5P_genclass_t *pclass); /* Property list callbacks */ -static herr_t H5P__lacc_elink_pref_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_pref_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_pref_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__lacc_elink_pref_dec(const void **_pp, void *value); -static herr_t H5P__lacc_elink_pref_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_pref_copy(const char* name, size_t size, void* value); -static int H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__lacc_elink_pref_close(const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_fapl_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_fapl_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_pref_copy(const char *name, size_t size, void *value); +static int H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__lacc_elink_pref_close(const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_fapl_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_fapl_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__lacc_elink_fapl_dec(const void **_pp, void *value); -static herr_t H5P__lacc_elink_fapl_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_fapl_copy(const char* name, size_t size, void* value); -static int H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__lacc_elink_fapl_close(const char* name, size_t size, void* value); - +static herr_t H5P__lacc_elink_fapl_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_fapl_copy(const char *name, size_t size, void *value); +static int H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__lacc_elink_fapl_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -136,44 +133,45 @@ static herr_t H5P__lacc_elink_fapl_close(const char* name, size_t size, void* va /* Dataset creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_LACC[1] = {{ - "link access", /* Class name for debugging */ - H5P_TYPE_LINK_ACCESS, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_LINK_ACCESS_g, /* Pointer to class */ - &H5P_CLS_LINK_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_LINK_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P__lacc_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "link access", /* Class name for debugging */ + H5P_TYPE_LINK_ACCESS, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_LINK_ACCESS_g, /* Pointer to class */ + &H5P_CLS_LINK_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_LINK_ACCESS_ID_g, /* Pointer to default property list ID */ + H5P__lacc_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const size_t H5L_def_nlinks_g = H5L_ACS_NLINKS_DEF; /* Default number of soft links to traverse */ -static const char *H5L_def_elink_prefix_g = H5L_ACS_ELINK_PREFIX_DEF; /* Default external link prefix string */ -static const hid_t H5L_def_fapl_id_g = H5L_ACS_ELINK_FAPL_DEF; /* Default fapl for external link access */ -static const unsigned H5L_def_elink_flags_g = H5L_ACS_ELINK_FLAGS_DEF; /* Default file access flags for external link traversal */ -static const H5L_elink_cb_t H5L_def_elink_cb_g = H5L_ACS_ELINK_CB_DEF; /* Default external link traversal callback */ +static const size_t H5L_def_nlinks_g = H5L_ACS_NLINKS_DEF; /* Default number of soft links to traverse */ +static const char * H5L_def_elink_prefix_g = + H5L_ACS_ELINK_PREFIX_DEF; /* Default external link prefix string */ +static const hid_t H5L_def_fapl_id_g = H5L_ACS_ELINK_FAPL_DEF; /* Default fapl for external link access */ +static const unsigned H5L_def_elink_flags_g = + H5L_ACS_ELINK_FLAGS_DEF; /* Default file access flags for external link traversal */ +static const H5L_elink_cb_t H5L_def_elink_cb_g = + H5L_ACS_ELINK_CB_DEF; /* Default external link traversal callback */ #ifdef H5_HAVE_PARALLEL -static const H5P_coll_md_read_flag_t H5L_def_coll_md_read_g = H5L_ACS_COLL_MD_READ_DEF; /* Default setting for the collective metedata read flag */ -#endif /* H5_HAVE_PARALLEL */ +static const H5P_coll_md_read_flag_t H5L_def_coll_md_read_g = + H5L_ACS_COLL_MD_READ_DEF; /* Default setting for the collective metedata read flag */ +#endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_reg_prop * @@ -189,45 +187,47 @@ static const H5P_coll_md_read_flag_t H5L_def_coll_md_read_g = H5L_ACS_COLL_MD_RE static herr_t H5P__lacc_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register property for number of links traversed */ - if(H5P__register_real(pclass, H5L_ACS_NLINKS_NAME, H5L_ACS_NLINKS_SIZE, &H5L_def_nlinks_g, - NULL, NULL, NULL, H5L_ACS_NLINKS_ENC, H5L_ACS_NLINKS_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_NLINKS_NAME, H5L_ACS_NLINKS_SIZE, &H5L_def_nlinks_g, NULL, NULL, + NULL, H5L_ACS_NLINKS_ENC, H5L_ACS_NLINKS_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external link prefix */ - if(H5P__register_real(pclass, H5L_ACS_ELINK_PREFIX_NAME, H5L_ACS_ELINK_PREFIX_SIZE, &H5L_def_elink_prefix_g, - NULL, H5L_ACS_ELINK_PREFIX_SET, H5L_ACS_ELINK_PREFIX_GET, H5L_ACS_ELINK_PREFIX_ENC, H5L_ACS_ELINK_PREFIX_DEC, - H5L_ACS_ELINK_PREFIX_DEL, H5L_ACS_ELINK_PREFIX_COPY, H5L_ACS_ELINK_PREFIX_CMP, H5L_ACS_ELINK_PREFIX_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_ELINK_PREFIX_NAME, H5L_ACS_ELINK_PREFIX_SIZE, + &H5L_def_elink_prefix_g, NULL, H5L_ACS_ELINK_PREFIX_SET, H5L_ACS_ELINK_PREFIX_GET, + H5L_ACS_ELINK_PREFIX_ENC, H5L_ACS_ELINK_PREFIX_DEC, H5L_ACS_ELINK_PREFIX_DEL, + H5L_ACS_ELINK_PREFIX_COPY, H5L_ACS_ELINK_PREFIX_CMP, + H5L_ACS_ELINK_PREFIX_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register fapl for link access */ - if(H5P__register_real(pclass, H5L_ACS_ELINK_FAPL_NAME, H5L_ACS_ELINK_FAPL_SIZE, &H5L_def_fapl_id_g, - NULL, H5L_ACS_ELINK_FAPL_SET, H5L_ACS_ELINK_FAPL_GET, H5L_ACS_ELINK_FAPL_ENC, H5L_ACS_ELINK_FAPL_DEC, - H5L_ACS_ELINK_FAPL_DEL, H5L_ACS_ELINK_FAPL_COPY, H5L_ACS_ELINK_FAPL_CMP, H5L_ACS_ELINK_FAPL_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_ELINK_FAPL_NAME, H5L_ACS_ELINK_FAPL_SIZE, &H5L_def_fapl_id_g, NULL, + H5L_ACS_ELINK_FAPL_SET, H5L_ACS_ELINK_FAPL_GET, H5L_ACS_ELINK_FAPL_ENC, + H5L_ACS_ELINK_FAPL_DEC, H5L_ACS_ELINK_FAPL_DEL, H5L_ACS_ELINK_FAPL_COPY, + H5L_ACS_ELINK_FAPL_CMP, H5L_ACS_ELINK_FAPL_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external link file access flags */ - if(H5P__register_real(pclass, H5L_ACS_ELINK_FLAGS_NAME, H5L_ACS_ELINK_FLAGS_SIZE, &H5L_def_elink_flags_g, - NULL, NULL, NULL, H5L_ACS_ELINK_FLAGS_ENC, H5L_ACS_ELINK_FLAGS_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_ELINK_FLAGS_NAME, H5L_ACS_ELINK_FLAGS_SIZE, &H5L_def_elink_flags_g, + NULL, NULL, NULL, H5L_ACS_ELINK_FLAGS_ENC, H5L_ACS_ELINK_FLAGS_DEC, NULL, NULL, + NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external link file traversal callback */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5L_ACS_ELINK_CB_NAME, H5L_ACS_ELINK_CB_SIZE, &H5L_def_elink_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_ELINK_CB_NAME, H5L_ACS_ELINK_CB_SIZE, &H5L_def_elink_cb_g, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #ifdef H5_HAVE_PARALLEL /* Register the metadata collective read flag */ - if(H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5L_ACS_COLL_MD_READ_SIZE, &H5L_def_coll_md_read_g, - NULL, NULL, NULL, H5L_ACS_COLL_MD_READ_ENC, H5L_ACS_COLL_MD_READ_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5L_ACS_COLL_MD_READ_SIZE, + &H5L_def_coll_md_read_g, NULL, NULL, NULL, H5L_ACS_COLL_MD_READ_ENC, + H5L_ACS_COLL_MD_READ_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #endif /* H5_HAVE_PARALLEL */ @@ -235,7 +235,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_set * @@ -251,10 +250,10 @@ done: */ static herr_t H5P__lacc_elink_fapl_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -265,12 +264,12 @@ H5P__lacc_elink_fapl_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED l_fapl_id = *(const hid_t *)value; /* Duplicate the FAPL, if it's non-default */ - if(l_fapl_id != H5P_DEFAULT) { + if (l_fapl_id != H5P_DEFAULT) { H5P_genplist_t *l_fapl_plist; - if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + if (NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") - if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + if (((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") } /* end if */ @@ -278,7 +277,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_set() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_get * @@ -294,10 +292,10 @@ done: */ static herr_t H5P__lacc_elink_fapl_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -308,12 +306,12 @@ H5P__lacc_elink_fapl_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED l_fapl_id = *(const hid_t *)value; /* Duplicate the FAPL, if it's non-default */ - if(l_fapl_id != H5P_DEFAULT) { + if (l_fapl_id != H5P_DEFAULT) { H5P_genplist_t *l_fapl_plist; - if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + if (NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") - if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + if (((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") } /* end if */ @@ -321,7 +319,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_enc * @@ -340,46 +337,46 @@ done: static herr_t H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) { - const hid_t *elink_fapl = (const hid_t *)value; /* Property to encode */ - uint8_t **pp = (uint8_t **)_pp; - H5P_genplist_t *fapl_plist; /* Pointer to property list */ - hbool_t non_default_fapl = FALSE; /* Whether the FAPL is non-default */ - size_t fapl_size = 0; /* FAPL's encoded size */ - herr_t ret_value = SUCCEED; /* Return value */ + const hid_t * elink_fapl = (const hid_t *)value; /* Property to encode */ + uint8_t ** pp = (uint8_t **)_pp; + H5P_genplist_t *fapl_plist; /* Pointer to property list */ + hbool_t non_default_fapl = FALSE; /* Whether the FAPL is non-default */ + size_t fapl_size = 0; /* FAPL's encoded size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for non-default FAPL */ - if(*elink_fapl != H5P_DEFAULT) { - if(NULL == (fapl_plist = (H5P_genplist_t *)H5P_object_verify(*elink_fapl, H5P_FILE_ACCESS))) + if (*elink_fapl != H5P_DEFAULT) { + if (NULL == (fapl_plist = (H5P_genplist_t *)H5P_object_verify(*elink_fapl, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property list") non_default_fapl = TRUE; } /* end if */ - if(NULL != *pp) { + if (NULL != *pp) { /* Store whether the FAPL is non-default */ *(*pp)++ = (uint8_t)non_default_fapl; } /* end if */ /* Encode the property list, if non-default */ /* (if *pp == NULL, will only compute the size) */ - if(non_default_fapl) { - if(H5P__encode(fapl_plist, TRUE, NULL, &fapl_size) < 0) + if (non_default_fapl) { + if (H5P__encode(fapl_plist, TRUE, NULL, &fapl_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "can't encode property list") - if(*pp) { + if (*pp) { uint64_t enc_value; unsigned enc_size; /* encode the length of the plist */ enc_value = (uint64_t)fapl_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the plist */ - if(H5P__encode(fapl_plist, TRUE, *pp, &fapl_size) < 0) + if (H5P__encode(fapl_plist, TRUE, *pp, &fapl_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "can't encode property list") *pp += fapl_size; @@ -387,13 +384,12 @@ H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) fapl_size += (1 + H5VM_limit_enc_size((uint64_t)fapl_size)); } /* end if */ - *size += (1 + fapl_size); /* Non-default flag, plus encoded property list size */ + *size += (1 + fapl_size); /* Non-default flag, plus encoded property list size */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_dec * @@ -412,10 +408,10 @@ done: static herr_t H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) { - hid_t *elink_fapl = (hid_t *)_value; /* The elink FAPL value */ - const uint8_t **pp = (const uint8_t **)_pp; - hbool_t non_default_fapl; /* Whether the FAPL is non-default */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t * elink_fapl = (hid_t *)_value; /* The elink FAPL value */ + const uint8_t **pp = (const uint8_t **)_pp; + hbool_t non_default_fapl; /* Whether the FAPL is non-default */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -426,10 +422,10 @@ H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* Determine if the FAPL is non-default */ - non_default_fapl = (hbool_t)*(*pp)++; + non_default_fapl = (hbool_t) * (*pp)++; - if(non_default_fapl) { - size_t fapl_size = 0; /* Encoded size of property list */ + if (non_default_fapl) { + size_t fapl_size = 0; /* Encoded size of property list */ unsigned enc_size; uint64_t enc_value; @@ -440,7 +436,7 @@ H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) fapl_size = (size_t)enc_value; /* Decode the property list */ - if((*elink_fapl = H5P__decode(*pp)) < 0) + if ((*elink_fapl = H5P__decode(*pp)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode property") *pp += fapl_size; @@ -452,7 +448,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_dec() */ - /*-------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_del * @@ -467,10 +462,11 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -481,14 +477,13 @@ H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED l_fapl_id = (*(const hid_t *)value); /* Close the FAPL */ - if(l_fapl_id != H5P_DEFAULT && H5I_dec_ref(l_fapl_id) < 0) + if (l_fapl_id != H5P_DEFAULT && H5I_dec_ref(l_fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_copy * @@ -505,8 +500,8 @@ done: static herr_t H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -517,12 +512,12 @@ H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED l_fapl_id = (*(const hid_t *)value); /* Duplicate the FAPL, if it's non-default */ - if(l_fapl_id != H5P_DEFAULT) { + if (l_fapl_id != H5P_DEFAULT) { H5P_genplist_t *l_fapl_plist; - if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + if (NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") - if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + if (((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") } /* end if */ @@ -530,7 +525,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_cmp * @@ -548,25 +542,29 @@ done: static int H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const hid_t *fapl1 = (const hid_t *)value1; - const hid_t *fapl2 = (const hid_t *)value2; - H5P_genplist_t *obj1, *obj2; /* Property lists to compare */ - int ret_value = 0; + const hid_t * fapl1 = (const hid_t *)value1; + const hid_t * fapl2 = (const hid_t *)value2; + H5P_genplist_t *obj1, *obj2; /* Property lists to compare */ + int ret_value = 0; FUNC_ENTER_STATIC_NOERR /* Check for comparison with default value */ - if(*fapl1 == 0 && *fapl2 > 0) HGOTO_DONE(1); - if(*fapl1 > 0 && *fapl2 == 0) HGOTO_DONE(-1); + if (*fapl1 == 0 && *fapl2 > 0) + HGOTO_DONE(1); + if (*fapl1 > 0 && *fapl2 == 0) + HGOTO_DONE(-1); /* Get the property list objects */ obj1 = (H5P_genplist_t *)H5I_object(*fapl1); obj2 = (H5P_genplist_t *)H5I_object(*fapl2); /* Check for NULL property lists */ - if(obj1 == NULL && obj2 != NULL) HGOTO_DONE(1); - if(obj1 != NULL && obj2 == NULL) HGOTO_DONE(-1); - if(obj1 && obj2) { + if (obj1 == NULL && obj2 != NULL) + HGOTO_DONE(1); + if (obj1 != NULL && obj2 == NULL) + HGOTO_DONE(-1); + if (obj1 && obj2) { herr_t H5_ATTR_NDEBUG_UNUSED status; status = H5P__cmp_plist(obj1, obj2, &ret_value); @@ -577,7 +575,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_cmp() */ - /*-------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_close * @@ -594,8 +591,8 @@ done: static herr_t H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -606,14 +603,13 @@ H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE l_fapl_id = (*(const hid_t *)value); /* Close the FAPL */ - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) + if ((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_close() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_set * @@ -629,7 +625,7 @@ done: */ static herr_t H5P__lacc_elink_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -642,7 +638,6 @@ H5P__lacc_elink_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_set() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_get * @@ -658,7 +653,7 @@ H5P__lacc_elink_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED */ static herr_t H5P__lacc_elink_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -671,7 +666,6 @@ H5P__lacc_elink_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_get() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_enc * @@ -690,44 +684,43 @@ H5P__lacc_elink_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED static herr_t H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) { - const char *elink_pref = *(const char * const *)value; - uint8_t **pp = (uint8_t **)_pp; - size_t len = 0; - uint64_t enc_value; - unsigned enc_size; + const char *elink_pref = *(const char *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + size_t len = 0; + uint64_t enc_value; + unsigned enc_size; FUNC_ENTER_STATIC_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* calculate prefix length */ - if(NULL != elink_pref) + if (NULL != elink_pref) len = HDstrlen(elink_pref); enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* encode the length of the prefix */ *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the prefix */ - if(NULL != elink_pref) { + if (NULL != elink_pref) { H5MM_memcpy(*(char **)pp, elink_pref, len); *pp += len; } /* end if */ - } /* end if */ + } /* end if */ *size += (1 + enc_size); - if(NULL != elink_pref) + if (NULL != elink_pref) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_dec * @@ -746,12 +739,12 @@ H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__lacc_elink_pref_dec(const void **_pp, void *_value) { - char **elink_pref = (char **)_value; - const uint8_t **pp = (const uint8_t **)_pp; - size_t len; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; + char ** elink_pref = (char **)_value; + const uint8_t **pp = (const uint8_t **)_pp; + size_t len; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -768,9 +761,9 @@ H5P__lacc_elink_pref_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = (size_t)enc_value; - if(0 != len) { + if (0 != len) { /* Make a copy of the user's prefix string */ - if(NULL == (*elink_pref = (char *)H5MM_malloc(len + 1))) + if (NULL == (*elink_pref = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix") HDstrncpy(*elink_pref, *(const char **)pp, len); (*elink_pref)[len] = '\0'; @@ -784,7 +777,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_pref_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_del * @@ -799,7 +791,7 @@ done: */ static herr_t H5P__lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -810,7 +802,6 @@ H5P__lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_del() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_copy * @@ -835,7 +826,6 @@ H5P__lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_cmp * @@ -853,24 +843,23 @@ H5P__lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED static int H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const char *pref1 = *(const char * const *)value1; - const char *pref2 = *(const char * const *)value2; - int ret_value = 0; + const char *pref1 = *(const char *const *)value1; + const char *pref2 = *(const char *const *)value2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - if(NULL == pref1 && NULL != pref2) + if (NULL == pref1 && NULL != pref2) HGOTO_DONE(1); - if(NULL != pref1 && NULL == pref2) + if (NULL != pref1 && NULL == pref2) HGOTO_DONE(-1); - if(NULL != pref1 && NULL != pref2) + if (NULL != pref1 && NULL != pref2) ret_value = HDstrcmp(pref1, pref2); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_pref_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_close * @@ -895,7 +884,6 @@ H5P__lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_nlinks * @@ -920,28 +908,27 @@ H5P__lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", plist_id, nlinks); - if(nlinks <= 0) + if (nlinks <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of links must be positive"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set number of links */ - if(H5P_set(plist, H5L_ACS_NLINKS_NAME, &nlinks) < 0) + if (H5P_set(plist, H5L_ACS_NLINKS_NAME, &nlinks) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set nlink info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_nlinks() */ - /*------------------------------------------------------------------------- * Function: H5Pget_nlinks * @@ -961,28 +948,27 @@ done: herr_t H5Pget_nlinks(hid_t plist_id, size_t *nlinks) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*z", plist_id, nlinks); - if(!nlinks) + if (!nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer passed in"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current number of links */ - if(H5P_get(plist, H5L_ACS_NLINKS_NAME, nlinks) < 0) + if (H5P_get(plist, H5L_ACS_NLINKS_NAME, nlinks) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of links") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_elink_prefix * @@ -1000,25 +986,24 @@ done: herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, prefix); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set prefix */ - if(H5P_set(plist, H5L_ACS_ELINK_PREFIX_NAME, &prefix) < 0) + if (H5P_set(plist, H5L_ACS_ELINK_PREFIX_NAME, &prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_prefix() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_prefix * @@ -1038,32 +1023,32 @@ done: ssize_t H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - char *my_prefix; /* Library's copy of the prefix */ - size_t len; /* Length of prefix string */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * my_prefix; /* Library's copy of the prefix */ + size_t len; /* Length of prefix string */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*sz", plist_id, prefix, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current prefix */ - if(H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) + if (H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") /* Check for prefix being set */ - if(my_prefix) { + if (my_prefix) { /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); - if(prefix) { + if (prefix) { HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); - if(len >= size) + if (len >= size) prefix[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ else len = 0; @@ -1089,25 +1074,24 @@ done: herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", lapl_id, fapl_id); /* Check arguments */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link access property list"); /* Set the file access property list for the link access */ - if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) + if (H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fapl for link") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_fapl() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_fapl * @@ -1124,24 +1108,23 @@ done: hid_t H5Pget_elink_fapl(hid_t lapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - hid_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", lapl_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &ret_value) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links") done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_elink_fapl() */ - /*------------------------------------------------------------------------- * Function: H5Pset_elink_acc_flags * @@ -1159,31 +1142,30 @@ done: herr_t H5Pset_elink_acc_flags(hid_t lapl_id, unsigned flags) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", lapl_id, flags); /* Check that flags are valid */ - if(( flags != H5F_ACC_RDWR) && (flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) - && (flags != H5F_ACC_RDONLY) && (flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) - && (flags != H5F_ACC_DEFAULT)) + if ((flags != H5F_ACC_RDWR) && (flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) && + (flags != H5F_ACC_RDONLY) && (flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) && + (flags != H5F_ACC_DEFAULT)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set flags */ - if(H5P_set(plist, H5L_ACS_ELINK_FLAGS_NAME, &flags) < 0) + if (H5P_set(plist, H5L_ACS_ELINK_FLAGS_NAME, &flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set access flags") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_acc_flags() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_acc_flags * @@ -1200,26 +1182,25 @@ done: herr_t H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", lapl_id, flags); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get flags */ - if(flags) - if(H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, flags) < 0) + if (flags) + if (H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "can't get access flags") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_acc_flags() */ - /*------------------------------------------------------------------------- * Function: H5Pset_elink_cb * @@ -1237,35 +1218,34 @@ done: herr_t H5Pset_elink_cb(hid_t lapl_id, H5L_elink_traverse_t func, void *op_data) { - H5P_genplist_t *plist; /* Property list pointer */ - H5L_elink_cb_t cb_info; /* Callback info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5L_elink_cb_t cb_info; /* Callback info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", lapl_id, func, op_data); /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ - if(!func && op_data) + if (!func && op_data) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Populate the callback info struct */ - cb_info.func = func; + cb_info.func = func; cb_info.user_data = op_data; /* Set callback info */ - if(H5P_set(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) + if (H5P_set(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set callback info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_acc_flags() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_cb * @@ -1282,27 +1262,26 @@ done: herr_t H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data) { - H5P_genplist_t *plist; /* Property list pointer */ - H5L_elink_cb_t cb_info; /* Callback info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5L_elink_cb_t cb_info; /* Callback info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", lapl_id, func, op_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get callback_info */ - if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") - if(func) + if (func) *func = cb_info.func; - if(op_data) + if (op_data) *op_data = cb_info.user_data; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_cb() */ - diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index 9c32552..6d43830 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -24,18 +24,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -43,22 +41,19 @@ /* ======== Link creation properties ======== */ /* Definitions for create intermediate groups flag */ -#define H5L_CRT_INTERMEDIATE_GROUP_SIZE sizeof(unsigned) -#define H5L_CRT_INTERMEDIATE_GROUP_DEF 0 -#define H5L_CRT_INTERMEDIATE_GROUP_ENC H5P__encode_unsigned -#define H5L_CRT_INTERMEDIATE_GROUP_DEC H5P__decode_unsigned - +#define H5L_CRT_INTERMEDIATE_GROUP_SIZE sizeof(unsigned) +#define H5L_CRT_INTERMEDIATE_GROUP_DEF 0 +#define H5L_CRT_INTERMEDIATE_GROUP_ENC H5P__encode_unsigned +#define H5L_CRT_INTERMEDIATE_GROUP_DEC H5P__decode_unsigned /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -66,45 +61,41 @@ /* Property class callbacks */ static herr_t H5P_lcrt_reg_prop(H5P_genclass_t *pclass); - /*********************/ /* Package Variables */ /*********************/ /* Link creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_LCRT[1] = {{ - "link create", /* Class name for debugging */ - H5P_TYPE_LINK_CREATE, /* Class type */ - - &H5P_CLS_STRING_CREATE_g, /* Parent class */ - &H5P_CLS_LINK_CREATE_g, /* Pointer to class */ - &H5P_CLS_LINK_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_LINK_CREATE_ID_g, /* Pointer to default property list ID */ - H5P_lcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "link create", /* Class name for debugging */ + H5P_TYPE_LINK_CREATE, /* Class type */ + + &H5P_CLS_STRING_CREATE_g, /* Parent class */ + &H5P_CLS_LINK_CREATE_g, /* Pointer to class */ + &H5P_CLS_LINK_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_LINK_CREATE_ID_g, /* Pointer to default property list ID */ + H5P_lcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const unsigned H5L_def_intmd_group_g = H5L_CRT_INTERMEDIATE_GROUP_DEF; /* Default setting for creating intermediate groups */ - +static const unsigned H5L_def_intmd_group_g = + H5L_CRT_INTERMEDIATE_GROUP_DEF; /* Default setting for creating intermediate groups */ - /*------------------------------------------------------------------------- * Function: H5P_lcrt_reg_prop * @@ -119,21 +110,20 @@ static const unsigned H5L_def_intmd_group_g = H5L_CRT_INTERMEDIATE_GROUP_DEF; herr_t H5P_lcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Register create intermediate groups property */ - if(H5P__register_real(pclass, H5L_CRT_INTERMEDIATE_GROUP_NAME, H5L_CRT_INTERMEDIATE_GROUP_SIZE, &H5L_def_intmd_group_g, - NULL, NULL, NULL, H5L_CRT_INTERMEDIATE_GROUP_ENC, H5L_CRT_INTERMEDIATE_GROUP_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5L_CRT_INTERMEDIATE_GROUP_NAME, H5L_CRT_INTERMEDIATE_GROUP_SIZE, + &H5L_def_intmd_group_g, NULL, NULL, NULL, H5L_CRT_INTERMEDIATE_GROUP_ENC, + H5L_CRT_INTERMEDIATE_GROUP_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_lcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_create_intermediate_group * @@ -151,26 +141,25 @@ done: herr_t H5Pset_create_intermediate_group(hid_t plist_id, unsigned crt_intmd_group) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, crt_intmd_group); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ crt_intmd_group = (unsigned)(crt_intmd_group > 0 ? 1 : 0); - if(H5P_set(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &crt_intmd_group) < 0) + if (H5P_set(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set intermediate group creation flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_create_intermediate_group() */ - /*------------------------------------------------------------------------- * Function: H5Pget_create_intermediate_group * @@ -186,22 +175,21 @@ done: herr_t H5Pget_create_intermediate_group(hid_t plist_id, unsigned *crt_intmd_group /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, crt_intmd_group); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(crt_intmd_group) - if(H5P_get(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, crt_intmd_group) < 0) + if (crt_intmd_group) + if (H5P_get(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get intermediate group creation flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_create_intermediate_group() */ - diff --git a/src/H5Pmapl.c b/src/H5Pmapl.c index 3a3f619..a1f0fae 100644 --- a/src/H5Pmapl.c +++ b/src/H5Pmapl.c @@ -22,18 +22,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Mprivate.h" /* Maps */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Mprivate.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -41,27 +39,24 @@ /* ========= Map Access properties ============ */ /* Definitions for key prefetch size */ -#define H5M_ACS_KEY_PREFETCH_SIZE_SIZE sizeof(size_t) -#define H5M_ACS_KEY_PREFETCH_SIZE_DEF (size_t)(16 * 1024) -#define H5M_ACS_KEY_PREFETCH_SIZE_ENC H5P__encode_size_t -#define H5M_ACS_KEY_PREFETCH_SIZE_DEC H5P__decode_size_t +#define H5M_ACS_KEY_PREFETCH_SIZE_SIZE sizeof(size_t) +#define H5M_ACS_KEY_PREFETCH_SIZE_DEF (size_t)(16 * 1024) +#define H5M_ACS_KEY_PREFETCH_SIZE_ENC H5P__encode_size_t +#define H5M_ACS_KEY_PREFETCH_SIZE_DEC H5P__decode_size_t /* Definition for key prefetch buffer size */ -#define H5M_ACS_KEY_ALLOC_SIZE_SIZE sizeof(size_t) -#define H5M_ACS_KEY_ALLOC_SIZE_DEF (size_t)(1024 * 1024) -#define H5M_ACS_KEY_ALLOC_SIZE_ENC H5P__encode_size_t -#define H5M_ACS_KEY_ALLOC_SIZE_DEC H5P__decode_size_t - +#define H5M_ACS_KEY_ALLOC_SIZE_SIZE sizeof(size_t) +#define H5M_ACS_KEY_ALLOC_SIZE_DEF (size_t)(1024 * 1024) +#define H5M_ACS_KEY_ALLOC_SIZE_ENC H5P__encode_size_t +#define H5M_ACS_KEY_ALLOC_SIZE_DEC H5P__decode_size_t /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -69,42 +64,37 @@ /* Property class callbacks */ static herr_t H5P__macc_reg_prop(H5P_genclass_t *pclass); - /*********************/ /* Package Variables */ /*********************/ /* Map access property list class library initialization object */ const H5P_libclass_t H5P_CLS_MACC[1] = {{ - "map access", /* Class name for debugging */ - H5P_TYPE_MAP_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_MAP_ACCESS_g, /* Pointer to class */ - &H5P_CLS_MAP_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_MAP_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P__macc_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "map access", /* Class name for debugging */ + H5P_TYPE_MAP_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_MAP_ACCESS_g, /* Pointer to class */ + &H5P_CLS_MAP_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_MAP_ACCESS_ID_g, /* Pointer to default property list ID */ + H5P__macc_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5P__macc_reg_prop * @@ -117,28 +107,31 @@ const H5P_libclass_t H5P_CLS_MACC[1] = {{ static herr_t H5P__macc_reg_prop(H5P_genclass_t *pclass) { - size_t key_prefetch_size = H5M_ACS_KEY_PREFETCH_SIZE_DEF; /* Default key prefetch size for iteration */ - size_t key_alloc_size = H5M_ACS_KEY_ALLOC_SIZE_DEF; /* Default key prefetch allocation size for iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t key_prefetch_size = H5M_ACS_KEY_PREFETCH_SIZE_DEF; /* Default key prefetch size for iteration */ + size_t key_alloc_size = + H5M_ACS_KEY_ALLOC_SIZE_DEF; /* Default key prefetch allocation size for iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the key prefetch size for iteration */ - if(H5P__register_real(pclass, H5M_ACS_KEY_PREFETCH_SIZE_NAME, H5M_ACS_KEY_PREFETCH_SIZE_SIZE, &key_prefetch_size, - NULL, NULL, NULL, H5M_ACS_KEY_PREFETCH_SIZE_ENC, H5M_ACS_KEY_PREFETCH_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5M_ACS_KEY_PREFETCH_SIZE_NAME, H5M_ACS_KEY_PREFETCH_SIZE_SIZE, + &key_prefetch_size, NULL, NULL, NULL, H5M_ACS_KEY_PREFETCH_SIZE_ENC, + H5M_ACS_KEY_PREFETCH_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the key prefetch allocation size for iteration */ - if(H5P__register_real(pclass, H5M_ACS_KEY_ALLOC_SIZE_NAME, H5M_ACS_KEY_ALLOC_SIZE_SIZE, &key_alloc_size, - NULL, NULL, NULL, H5M_ACS_KEY_ALLOC_SIZE_ENC, H5M_ACS_KEY_ALLOC_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5M_ACS_KEY_ALLOC_SIZE_NAME, H5M_ACS_KEY_ALLOC_SIZE_SIZE, &key_alloc_size, + NULL, NULL, NULL, H5M_ACS_KEY_ALLOC_SIZE_ENC, H5M_ACS_KEY_ALLOC_SIZE_DEC, NULL, + NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__macc_reg_prop() */ #ifdef H5_HAVE_MAP_API - + /*------------------------------------------------------------------------- * Function: H5Pset_map_iterate_hints * @@ -159,27 +152,26 @@ done: herr_t H5Pset_map_iterate_hints(hid_t mapl_id, size_t key_prefetch_size, size_t key_alloc_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "izz", mapl_id, key_prefetch_size, key_alloc_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(mapl_id, H5P_MAP_ACCESS))) + if (NULL == (plist = H5P_object_verify(mapl_id, H5P_MAP_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set sizes */ - if(H5P_set(plist, H5M_ACS_KEY_PREFETCH_SIZE_NAME, &key_prefetch_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set key prefetch size"); - if(H5P_set(plist, H5M_ACS_KEY_ALLOC_SIZE_NAME, &key_alloc_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set key allocation size"); + if (H5P_set(plist, H5M_ACS_KEY_PREFETCH_SIZE_NAME, &key_prefetch_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set key prefetch size"); + if (H5P_set(plist, H5M_ACS_KEY_ALLOC_SIZE_NAME, &key_alloc_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set key allocation size"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_map_iterate_hints() */ - /*------------------------------------------------------------------------- * Function: H5Pget_map_iterate_hints * @@ -192,23 +184,23 @@ done: herr_t H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size, size_t *key_alloc_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*z*z", mapl_id, key_prefetch_size, key_alloc_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(mapl_id, H5P_MAP_ACCESS))) + if (NULL == (plist = H5P_object_verify(mapl_id, H5P_MAP_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get the properties */ - if(key_prefetch_size) { - if(H5P_get(plist, H5M_ACS_KEY_PREFETCH_SIZE_NAME, key_prefetch_size) < 0) + if (key_prefetch_size) { + if (H5P_get(plist, H5M_ACS_KEY_PREFETCH_SIZE_NAME, key_prefetch_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get key prefetch size"); } /* end if */ - if(key_alloc_size) { - if(H5P_get(plist, H5M_ACS_KEY_ALLOC_SIZE_NAME, key_alloc_size) < 0) + if (key_alloc_size) { + if (H5P_get(plist, H5M_ACS_KEY_ALLOC_SIZE_NAME, key_alloc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get key allocation size"); } /* end if */ diff --git a/src/H5Pmcpl.c b/src/H5Pmcpl.c index 41a6659..ecdf1f0 100644 --- a/src/H5Pmcpl.c +++ b/src/H5Pmcpl.c @@ -24,34 +24,29 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Mprivate.h" /* Maps */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Mprivate.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -59,42 +54,37 @@ /* Property class callbacks */ static herr_t H5P__mcrt_reg_prop(H5P_genclass_t *pclass); - /*********************/ /* Package Variables */ /*********************/ /* Map create property list class library initialization object */ const H5P_libclass_t H5P_CLS_MCRT[1] = {{ - "map create", /* Class name for debugging */ - H5P_TYPE_MAP_CREATE, /* Class type */ - - &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ - &H5P_CLS_MAP_CREATE_g, /* Pointer to class */ - &H5P_CLS_MAP_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_MAP_CREATE_ID_g, /* Pointer to default property list ID */ - H5P__mcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "map create", /* Class name for debugging */ + H5P_TYPE_MAP_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_MAP_CREATE_g, /* Pointer to class */ + &H5P_CLS_MAP_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_MAP_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__mcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /***************************/ /* Local Private Variables */ /***************************/ - - /*------------------------------------------------------------------------- * Function: H5P__mcrt_reg_prop * @@ -106,10 +96,9 @@ const H5P_libclass_t H5P_CLS_MCRT[1] = {{ static herr_t H5P__mcrt_reg_prop(H5P_genclass_t H5_ATTR_UNUSED *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__mcrt_reg_prop() */ - diff --git a/src/H5Pmodule.h b/src/H5Pmodule.h index d5c471a..d6e67d4 100644 --- a/src/H5Pmodule.h +++ b/src/H5Pmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5P_MODULE -#define H5_MY_PKG H5P -#define H5_MY_PKG_ERR H5E_PLIST -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5P +#define H5_MY_PKG_ERR H5E_PLIST +#define H5_MY_PKG_INIT YES #endif /* _H5Pmodule_H */ - diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index a60c593..c34981b 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -26,22 +26,20 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5PLprivate.h" /* Dynamic plugin */ -#include "H5Zprivate.h" /* Filter pipeline */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5PLprivate.h" /* Dynamic plugin */ +#include "H5Zprivate.h" /* Filter pipeline */ /****************/ /* Local Macros */ @@ -49,39 +47,36 @@ /* ========= Object Creation properties ============ */ /* Definitions for the max. # of attributes to store compactly */ -#define H5O_CRT_ATTR_MAX_COMPACT_SIZE sizeof(unsigned) -#define H5O_CRT_ATTR_MAX_COMPACT_ENC H5P__encode_unsigned -#define H5O_CRT_ATTR_MAX_COMPACT_DEC H5P__decode_unsigned +#define H5O_CRT_ATTR_MAX_COMPACT_SIZE sizeof(unsigned) +#define H5O_CRT_ATTR_MAX_COMPACT_ENC H5P__encode_unsigned +#define H5O_CRT_ATTR_MAX_COMPACT_DEC H5P__decode_unsigned /* Definitions for the min. # of attributes to store densely */ -#define H5O_CRT_ATTR_MIN_DENSE_SIZE sizeof(unsigned) -#define H5O_CRT_ATTR_MIN_DENSE_ENC H5P__encode_unsigned -#define H5O_CRT_ATTR_MIN_DENSE_DEC H5P__decode_unsigned +#define H5O_CRT_ATTR_MIN_DENSE_SIZE sizeof(unsigned) +#define H5O_CRT_ATTR_MIN_DENSE_ENC H5P__encode_unsigned +#define H5O_CRT_ATTR_MIN_DENSE_DEC H5P__decode_unsigned /* Definitions for object header flags */ -#define H5O_CRT_OHDR_FLAGS_SIZE sizeof(uint8_t) -#define H5O_CRT_OHDR_FLAGS_ENC H5P__encode_uint8_t -#define H5O_CRT_OHDR_FLAGS_DEC H5P__decode_uint8_t +#define H5O_CRT_OHDR_FLAGS_SIZE sizeof(uint8_t) +#define H5O_CRT_OHDR_FLAGS_ENC H5P__encode_uint8_t +#define H5O_CRT_OHDR_FLAGS_DEC H5P__decode_uint8_t /* Definitions for filter pipeline */ -#define H5O_CRT_PIPELINE_SIZE sizeof(H5O_pline_t) -#define H5O_CRT_PIPELINE_SET H5P__ocrt_pipeline_set -#define H5O_CRT_PIPELINE_GET H5P__ocrt_pipeline_get -#define H5O_CRT_PIPELINE_ENC H5P__ocrt_pipeline_enc -#define H5O_CRT_PIPELINE_DEC H5P__ocrt_pipeline_dec -#define H5O_CRT_PIPELINE_DEL H5P__ocrt_pipeline_del -#define H5O_CRT_PIPELINE_COPY H5P__ocrt_pipeline_copy -#define H5O_CRT_PIPELINE_CMP H5P__ocrt_pipeline_cmp -#define H5O_CRT_PIPELINE_CLOSE H5P__ocrt_pipeline_close - +#define H5O_CRT_PIPELINE_SIZE sizeof(H5O_pline_t) +#define H5O_CRT_PIPELINE_SET H5P__ocrt_pipeline_set +#define H5O_CRT_PIPELINE_GET H5P__ocrt_pipeline_get +#define H5O_CRT_PIPELINE_ENC H5P__ocrt_pipeline_enc +#define H5O_CRT_PIPELINE_DEC H5P__ocrt_pipeline_dec +#define H5O_CRT_PIPELINE_DEL H5P__ocrt_pipeline_del +#define H5O_CRT_PIPELINE_COPY H5P__ocrt_pipeline_copy +#define H5O_CRT_PIPELINE_CMP H5P__ocrt_pipeline_cmp +#define H5O_CRT_PIPELINE_CLOSE H5P__ocrt_pipeline_close /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -96,12 +91,12 @@ static herr_t H5P__ocrt_pipeline_set(hid_t prop_id, const char *name, size_t siz static herr_t H5P__ocrt_pipeline_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__ocrt_pipeline_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__ocrt_pipeline_copy(const char *name, size_t size, void *value); -static int H5P__ocrt_pipeline_cmp(const void *value1, const void *value2, size_t size); +static int H5P__ocrt_pipeline_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__ocrt_pipeline_close(const char *name, size_t size, void *value); /* Local routines */ -static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, - unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]); +static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, + size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]); /*********************/ /* Package Variables */ @@ -109,42 +104,39 @@ static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, /* Object creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_OCRT[1] = {{ - "object create", /* Class name for debugging */ - H5P_TYPE_OBJECT_CREATE, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class */ - &H5P_CLS_OBJECT_CREATE_ID_g, /* Pointer to class ID */ - NULL, /* Pointer to default property list ID */ - H5P__ocrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "object create", /* Class name for debugging */ + H5P_TYPE_OBJECT_CREATE, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class */ + &H5P_CLS_OBJECT_CREATE_ID_g, /* Pointer to class ID */ + NULL, /* Pointer to default property list ID */ + H5P__ocrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const unsigned H5O_def_attr_max_compact_g = H5O_CRT_ATTR_MAX_COMPACT_DEF; /* Default max. compact attribute storage settings */ -static const unsigned H5O_def_attr_min_dense_g = H5O_CRT_ATTR_MIN_DENSE_DEF; /* Default min. dense attribute storage settings */ -static const uint8_t H5O_def_ohdr_flags_g = H5O_CRT_OHDR_FLAGS_DEF; /* Default object header flag settings */ -static const H5O_pline_t H5O_def_pline_g = H5O_CRT_PIPELINE_DEF; /* Default I/O pipeline setting */ - +static const unsigned H5O_def_attr_max_compact_g = + H5O_CRT_ATTR_MAX_COMPACT_DEF; /* Default max. compact attribute storage settings */ +static const unsigned H5O_def_attr_min_dense_g = + H5O_CRT_ATTR_MIN_DENSE_DEF; /* Default min. dense attribute storage settings */ +static const uint8_t H5O_def_ohdr_flags_g = H5O_CRT_OHDR_FLAGS_DEF; /* Default object header flag settings */ +static const H5O_pline_t H5O_def_pline_g = H5O_CRT_PIPELINE_DEF; /* Default I/O pipeline setting */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_reg_prop * @@ -160,39 +152,39 @@ static const H5O_pline_t H5O_def_pline_g = H5O_CRT_PIPELINE_DEF; /* De static herr_t H5P__ocrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register max. compact attribute storage property */ - if(H5P__register_real(pclass, H5O_CRT_ATTR_MAX_COMPACT_NAME, H5O_CRT_ATTR_MAX_COMPACT_SIZE, &H5O_def_attr_max_compact_g, - NULL, NULL, NULL, H5O_CRT_ATTR_MAX_COMPACT_ENC, H5O_CRT_ATTR_MAX_COMPACT_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CRT_ATTR_MAX_COMPACT_NAME, H5O_CRT_ATTR_MAX_COMPACT_SIZE, + &H5O_def_attr_max_compact_g, NULL, NULL, NULL, H5O_CRT_ATTR_MAX_COMPACT_ENC, + H5O_CRT_ATTR_MAX_COMPACT_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register min. dense attribute storage property */ - if(H5P__register_real(pclass, H5O_CRT_ATTR_MIN_DENSE_NAME, H5O_CRT_ATTR_MIN_DENSE_SIZE, &H5O_def_attr_min_dense_g, - NULL, NULL, NULL, H5O_CRT_ATTR_MIN_DENSE_ENC, H5O_CRT_ATTR_MIN_DENSE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CRT_ATTR_MIN_DENSE_NAME, H5O_CRT_ATTR_MIN_DENSE_SIZE, + &H5O_def_attr_min_dense_g, NULL, NULL, NULL, H5O_CRT_ATTR_MIN_DENSE_ENC, + H5O_CRT_ATTR_MIN_DENSE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register object header flags property */ - if(H5P__register_real(pclass, H5O_CRT_OHDR_FLAGS_NAME, H5O_CRT_OHDR_FLAGS_SIZE, &H5O_def_ohdr_flags_g, - NULL, NULL, NULL, H5O_CRT_OHDR_FLAGS_ENC, H5O_CRT_OHDR_FLAGS_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CRT_OHDR_FLAGS_NAME, H5O_CRT_OHDR_FLAGS_SIZE, &H5O_def_ohdr_flags_g, + NULL, NULL, NULL, H5O_CRT_OHDR_FLAGS_ENC, H5O_CRT_OHDR_FLAGS_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the pipeline property */ - if(H5P__register_real(pclass, H5O_CRT_PIPELINE_NAME, H5O_CRT_PIPELINE_SIZE, &H5O_def_pline_g, - NULL, H5O_CRT_PIPELINE_SET, H5O_CRT_PIPELINE_GET, H5O_CRT_PIPELINE_ENC, H5O_CRT_PIPELINE_DEC, - H5O_CRT_PIPELINE_DEL, H5O_CRT_PIPELINE_COPY, H5O_CRT_PIPELINE_CMP, H5O_CRT_PIPELINE_CLOSE) < 0) + if (H5P__register_real(pclass, H5O_CRT_PIPELINE_NAME, H5O_CRT_PIPELINE_SIZE, &H5O_def_pline_g, NULL, + H5O_CRT_PIPELINE_SET, H5O_CRT_PIPELINE_GET, H5O_CRT_PIPELINE_ENC, + H5O_CRT_PIPELINE_DEC, H5O_CRT_PIPELINE_DEL, H5O_CRT_PIPELINE_COPY, + H5O_CRT_PIPELINE_CMP, H5O_CRT_PIPELINE_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_attr_phase_change * @@ -218,35 +210,34 @@ done: herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, max_compact, min_dense); /* Range check values */ - if(max_compact < min_dense) + if (max_compact < min_dense) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be >= min dense value") - if(max_compact > 65535) + if (max_compact > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be < 65536") - if(min_dense > 65535) + if (min_dense > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min dense value must be < 65536") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set property values */ - if(H5P_set(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &max_compact) < 0) + if (H5P_set(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &max_compact) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list") - if(H5P_set(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &min_dense) < 0) + if (H5P_set(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &min_dense) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_attr_phase_change */ - /*------------------------------------------------------------------------- * Function: H5Pget_attr_phase_change * @@ -262,23 +253,23 @@ done: herr_t H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*Iu*Iu", plist_id, max_compact, min_dense); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(max_compact) { - if(H5P_get(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, max_compact) < 0) + if (max_compact) { + if (H5P_get(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, max_compact) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") } /* end if */ - if(min_dense) { - if(H5P_get(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, min_dense) < 0) + if (min_dense) { + if (H5P_get(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, min_dense) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") } /* end if */ @@ -286,7 +277,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_attr_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pset_attr_creation_order * @@ -302,41 +292,42 @@ done: herr_t H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags) { - H5P_genplist_t *plist; /* Property list pointer */ - uint8_t ohdr_flags; /* Object header flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + uint8_t ohdr_flags; /* Object header flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, crt_order_flags); /* Check for bad combination of flags */ - if(!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) + if (!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tracking creation order is required for index") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get object header flags */ - if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Mask off previous attribute creation order flag settings */ - ohdr_flags &= (uint8_t)~(H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED); + ohdr_flags &= (uint8_t) ~(H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED); /* Update with new attribute creation order flags */ - ohdr_flags = (uint8_t)(ohdr_flags | ((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0)); - ohdr_flags = (uint8_t)(ohdr_flags | ((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0)); + ohdr_flags = (uint8_t)(ohdr_flags | + ((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0)); + ohdr_flags = (uint8_t)(ohdr_flags | + ((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0)); /* Set object header flags */ - if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_attr_creation_order() */ - /*------------------------------------------------------------------------- * Function: H5Pget_attr_creation_order * @@ -353,25 +344,25 @@ done: herr_t H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", plist_id, crt_order_flags); /* Get values */ - if(crt_order_flags) { + if (crt_order_flags) { H5P_genplist_t *plist; /* Property list pointer */ - uint8_t ohdr_flags; /* Object header flags */ + uint8_t ohdr_flags; /* Object header flags */ /* Reset the value to return */ *crt_order_flags = 0; /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get object header flags */ - if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Set creation order flags to return */ @@ -383,7 +374,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_attr_creation_order() */ - /*------------------------------------------------------------------------- * Function: H5Pset_obj_track_times * @@ -413,19 +403,19 @@ done: herr_t H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times) { - H5P_genplist_t *plist; /* Property list pointer */ - uint8_t ohdr_flags; /* Object header flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + uint8_t ohdr_flags; /* Object header flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", plist_id, track_times); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get object header flags */ - if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Mask off previous time tracking flag settings */ @@ -435,14 +425,13 @@ H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times) ohdr_flags = (uint8_t)(ohdr_flags | (track_times ? H5O_HDR_STORE_TIMES : 0)); /* Set object header flags */ - if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_obj_track_times() */ - /*------------------------------------------------------------------------- * Function: H5Pget_obj_track_times * @@ -458,22 +447,22 @@ done: herr_t H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", plist_id, track_times); /* Get values */ - if(track_times) { + if (track_times) { H5P_genplist_t *plist; /* Property list pointer */ - uint8_t ohdr_flags; /* Object header flags */ + uint8_t ohdr_flags; /* Object header flags */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get object header flags */ - if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Set track times flag to return */ @@ -484,7 +473,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_obj_track_times() */ - /*------------------------------------------------------------------------- * Function: H5P_modify_filter * @@ -522,31 +510,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, - size_t cd_nelmts, const unsigned cd_values[/*cd_nelmts*/]) +H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned cd_values[/*cd_nelmts*/]) { - H5O_pline_t pline; - herr_t ret_value = SUCCEED; /* return value */ + H5O_pline_t pline; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the pipeline property to modify */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Modify the filter parameters of the I/O pipeline */ - if(H5Z_modify(&pline, filter, flags, cd_nelmts, cd_values) < 0) + if (H5Z_modify(&pline, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_modify_filter() */ - /*------------------------------------------------------------------------- * Function: H5Pmodify_filter * @@ -591,37 +578,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iZfIuz*[a3]Iu", plist_id, filter, flags, cd_nelmts, cd_values); /* Check args */ - if (filter<0 || filter>H5Z_FILTER_MAX) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier") + if (filter < 0 || filter > H5Z_FILTER_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier") if (flags & ~((unsigned)H5Z_FLAG_DEFMASK)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags") - if (cd_nelmts>0 && !cd_values) + if (cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no client data values supplied") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Modify the filter parameters of the I/O pipeline */ - if(H5P_modify_filter(plist, filter, flags, cd_nelmts, cd_values) < 0) + if (H5P_modify_filter(plist, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't modify filter") done: FUNC_LEAVE_API(ret_value) } /* end H5Pmodify_filter() */ - /*------------------------------------------------------------------------- * Function: H5Pset_filter * @@ -667,36 +652,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iZfIuz*[a3]Iu", plist_id, filter, flags, cd_nelmts, cd_values); /* Check args */ - if (filter<0 || filter>H5Z_FILTER_MAX) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier") + if (filter < 0 || filter > H5Z_FILTER_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier") if (flags & ~((unsigned)H5Z_FLAG_DEFMASK)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags") - if (cd_nelmts>0 && !cd_values) + if (cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no client data values supplied") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Call the private function */ - if(H5P__set_filter(plist, filter, flags, cd_nelmts, cd_values) < 0) + if (H5P__set_filter(plist, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "failed to call private function") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_filter() */ - /*------------------------------------------------------------------------- * Function: H5P__set_filter * @@ -733,36 +717,35 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - H5O_pline_t pline; /* Filter pipeline */ - htri_t filter_avail; /* Filter availability */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t pline; /* Filter pipeline */ + htri_t filter_avail; /* Filter availability */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if filter is already available */ - if((filter_avail = H5Z_filter_avail(filter)) < 0) + if ((filter_avail = H5Z_filter_avail(filter)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't check filter availability") /* Get the pipeline property to append to */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the filter to the I/O pipeline */ - if(H5Z_append(&pline, filter, flags, cd_nelmts, cd_values) < 0) + if (H5Z_append(&pline, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__set_filter() */ - /*------------------------------------------------------------------------- * Function: H5Pget_nfilters * @@ -793,29 +776,28 @@ done: int H5Pget_nfilters(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - int ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Set return value */ - ret_value=(int)(pline.nused); + ret_value = (int)(pline.nused); done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_nfilters */ - /*------------------------------------------------------------------------- * Function: H5Pget_filter2 * @@ -848,58 +830,58 @@ done: *------------------------------------------------------------------------- */ H5Z_filter_t -H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/, +H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags /*out*/, size_t *cd_nelmts /*in_out*/, + unsigned cd_values[] /*out*/, size_t namelen, char name[] /*out*/, unsigned *filter_config /*out*/) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ + H5P_genplist_t * plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ const H5Z_filter_info_t *filter; /* Pointer to filter information */ - H5Z_filter_t ret_value; /* return value */ + H5Z_filter_t ret_value; /* return value */ FUNC_ENTER_API(H5Z_FILTER_ERROR) H5TRACE8("Zf", "iIux*zxzxx", plist_id, idx, flags, cd_nelmts, cd_values, namelen, name, filter_config); /* Check args */ - if(cd_nelmts || cd_values) { + if (cd_nelmts || cd_values) { /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ - if(cd_nelmts && *cd_nelmts > 256) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "probable uninitialized *cd_nelmts argument") - if(cd_nelmts && *cd_nelmts > 0 && !cd_values) + if (cd_nelmts && *cd_nelmts > 256) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, + "probable uninitialized *cd_nelmts argument") + if (cd_nelmts && *cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "client data values not supplied") /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ - if(!cd_nelmts) + if (!cd_nelmts) cd_values = NULL; } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_FILTER_ERROR, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") /* Check index */ - if(idx >= pline.nused) + if (idx >= pline.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "filter number is invalid") /* Set pointer to particular filter to query */ filter = &pline.filter[idx]; /* Get filter information */ - if(H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) + if (H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get filter info") /* Set return value */ @@ -909,7 +891,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_filter2() */ - /*------------------------------------------------------------------------- * Function: H5P_get_filter_by_id * @@ -933,33 +914,32 @@ done: *------------------------------------------------------------------------- */ herr_t -H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/, unsigned *filter_config) +H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*in_out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/, unsigned *filter_config) { - H5O_pline_t pline; /* Filter pipeline */ - H5Z_filter_info_t *filter; /* Pointer to filter information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t pline; /* Filter pipeline */ + H5Z_filter_info_t *filter; /* Pointer to filter information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get pipeline info */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Get pointer to filter in pipeline */ - if(NULL == (filter = H5Z_filter_info(&pline, id))) + if (NULL == (filter = H5Z_filter_info(&pline, id))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "filter ID is invalid") /* Get filter information */ - if(H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) + if (H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get filter info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_get_filter_by_id() */ - /*------------------------------------------------------------------------- * Function: H5Pget_filter_by_id2 * @@ -990,52 +970,50 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/, unsigned *filter_config) +H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*in_out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/, unsigned *filter_config) { - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "iZfx*zxzx*Iu", plist_id, id, flags, cd_nelmts, cd_values, namelen, name, filter_config); /* Check args */ - if(cd_nelmts || cd_values) { + if (cd_nelmts || cd_values) { /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ - if(cd_nelmts && *cd_nelmts > 256) + if (cd_nelmts && *cd_nelmts > 256) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "probable uninitialized *cd_nelmts argument") - if(cd_nelmts && *cd_nelmts > 0 && !cd_values) + if (cd_nelmts && *cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "client data values not supplied") /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ - if(!cd_nelmts) + if (!cd_nelmts) cd_values = NULL; } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get filter information */ - if(H5P_get_filter_by_id(plist, id, flags, cd_nelmts, cd_values, namelen, - name, filter_config) < 0) + if (H5P_get_filter_by_id(plist, id, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get filter info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_filter_by_id2() */ - /*------------------------------------------------------------------------- * Function: H5Pall_filters_avail * @@ -1061,30 +1039,29 @@ done: htri_t H5Pall_filters_avail(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - htri_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if all filters are available */ - if((ret_value = H5Z_all_filters_avail(&pline)) < 0) + if ((ret_value = H5Z_all_filters_avail(&pline)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't check pipeline information") done: FUNC_LEAVE_API(ret_value) } /* end H5Pall_filters_avail() */ - /*------------------------------------------------------------------------- * Function: H5P_filter_in_pline * @@ -1103,24 +1080,23 @@ done: htri_t H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id) { - H5O_pline_t pline; /* Filter pipeline */ - htri_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t pline; /* Filter pipeline */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get pipeline info */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if the file is in the pipeline */ - if((ret_value = H5Z_filter_in_pline(&pline, id)) < 0) + if ((ret_value = H5Z_filter_in_pline(&pline, id)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTCOMPARE, FAIL, "can't find filter") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_filter_in_pline() */ - /*------------------------------------------------------------------------- * Function: H5Premove_filter * @@ -1144,29 +1120,29 @@ done: herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iZf", plist_id, filter); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to modify */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if there are any filters */ if (pline.filter) { /* Delete filter */ - if(H5Z_delete(&pline, filter) < 0) + if (H5Z_delete(&pline, filter) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't delete filter") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") } /* end if */ @@ -1174,7 +1150,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Premove_filter() */ - /*------------------------------------------------------------------------- * Function: H5Pset_deflate * @@ -1208,38 +1183,37 @@ done: herr_t H5Pset_deflate(hid_t plist_id, unsigned level) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, level); /* Check arguments */ - if(level > 9) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid deflate level") + if (level > 9) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid deflate level") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to append to */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the filter */ - if(H5Z_append(&pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &level) < 0) + if (H5Z_append(&pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &level) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add deflate filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_deflate() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fletcher32 * @@ -1263,34 +1237,33 @@ done: herr_t H5Pset_fletcher32(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to append to */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the Fletcher32 checksum as a filter */ - if(H5Z_append(&pline, H5Z_FILTER_FLETCHER32, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) + if (H5Z_append(&pline, H5Z_FILTER_FLETCHER32, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add fletcher32 filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fletcher32() */ - /*------------------------------------------------------------------------- * Function: H5P__get_filter * @@ -1304,10 +1277,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5P__get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/, - unsigned *filter_config /*out*/) +H5P__get_filter(const H5Z_filter_info_t *filter, unsigned int *flags /*out*/, size_t *cd_nelmts /*in_out*/, + unsigned cd_values[] /*out*/, size_t namelen, char name[] /*out*/, + unsigned *filter_config /*out*/) { FUNC_ENTER_PACKAGE_NOERR @@ -1315,58 +1287,57 @@ H5P__get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, HDassert(filter); /* Filter flags */ - if(flags) + if (flags) *flags = filter->flags; /* Filter parameters */ - if(cd_values) { - size_t i; /* Local index variable */ + if (cd_values) { + size_t i; /* Local index variable */ - for(i = 0; i < filter->cd_nelmts && i < *cd_nelmts; i++) + for (i = 0; i < filter->cd_nelmts && i < *cd_nelmts; i++) cd_values[i] = filter->cd_values[i]; } /* end if */ /* Number of filter parameters */ - if(cd_nelmts) + if (cd_nelmts) *cd_nelmts = filter->cd_nelmts; /* Filter name */ - if(namelen > 0 && name) { + if (namelen > 0 && name) { const char *s = filter->name; /* If there's no name on the filter, use the class's filter name */ - if(!s) { + if (!s) { H5Z_class2_t *cls = H5Z_find(filter->id); - if(cls) + if (cls) s = cls->name; } /* end if */ /* Check for actual name */ - if(s) { + if (s) { HDstrncpy(name, s, namelen); name[namelen - 1] = '\0'; } /* end if */ else { /* Check for unknown library filter */ /* (probably from a future version of the library) */ - if(filter->id < 256) { + if (filter->id < 256) { HDstrncpy(name, "Unknown library filter", namelen); name[namelen - 1] = '\0'; } /* end if */ else name[0] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ /* Filter configuration (assume filter ID has already been checked) */ - if(filter_config) + if (filter_config) H5Z_get_filter_info(filter->id, filter_config); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__get_filter() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_set * @@ -1382,11 +1353,11 @@ H5P__get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, */ static herr_t H5P__ocrt_pipeline_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ - H5O_pline_t new_pline; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1394,7 +1365,7 @@ H5P__ocrt_pipeline_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * HDassert(value); /* Make copy of I/O pipeline */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") /* Copy new I/O pipeline message over old one */ @@ -1404,7 +1375,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_set() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_get * @@ -1420,11 +1390,11 @@ done: */ static herr_t H5P__ocrt_pipeline_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ - H5O_pline_t new_pline; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1432,7 +1402,7 @@ H5P__ocrt_pipeline_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * HDassert(value); /* Make copy of I/O pipeline */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") /* Copy new I/O pipeline message over old one */ @@ -1442,7 +1412,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_get() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_enc * @@ -1462,8 +1431,8 @@ static herr_t H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) { const H5O_pline_t *pline = (const H5O_pline_t *)value; - uint8_t **pp = (uint8_t **)_pp; - size_t u; /* Local index variable */ + uint8_t ** pp = (uint8_t **)_pp; + size_t u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -1471,7 +1440,7 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) HDassert(size); HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); - if(NULL != *pp) { + if (NULL != *pp) { unsigned enc_size; uint64_t enc_value; @@ -1480,14 +1449,14 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) /* encode nused value */ enc_value = (uint64_t)pline->nused; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode each pipeline */ - for(u = 0; u < pline->nused; u++) { - unsigned v; /* Local index variable */ + for (u = 0; u < pline->nused; u++) { + unsigned v; /* Local index variable */ /* encode filter ID */ INT32ENCODE(*pp, pline->filter[u].id) @@ -1496,7 +1465,7 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, pline->filter[u].flags) /* encode filter name if it exists */ - if(NULL != pline->filter[u].name) { + if (NULL != pline->filter[u].name) { /* encode TRUE indicating that it exits */ *(*pp)++ = (uint8_t)TRUE; @@ -1510,23 +1479,23 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) /* encode cd_nelmts */ enc_value = (uint64_t)pline->filter[u].cd_nelmts; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode all values */ - for(v = 0; v < pline->filter[u].cd_nelmts; v++) + for (v = 0; v < pline->filter[u].cd_nelmts; v++) H5_ENCODE_UNSIGNED(*pp, pline->filter[u].cd_values[v]) } /* end for */ - } /* end if */ + } /* end if */ /* calculate size required for encoding */ *size += 1; *size += (1 + H5VM_limit_enc_size((uint64_t)pline->nused)); - for(u = 0; u < pline->nused; u++) { + for (u = 0; u < pline->nused; u++) { *size += (sizeof(int32_t) + sizeof(unsigned) + 1); - if(NULL != pline->filter[u].name) + if (NULL != pline->filter[u].name) *size += H5Z_COMMON_NAME_LEN; *size += (1 + H5VM_limit_enc_size((uint64_t)pline->filter[u].cd_nelmts)); *size += pline->filter[u].cd_nelmts * sizeof(unsigned); @@ -1535,7 +1504,6 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__ocrt_pipeline_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_dec * @@ -1554,13 +1522,13 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__ocrt_pipeline_dec(const void **_pp, void *_value) { - H5O_pline_t *pline = (H5O_pline_t *)_value; /* Property to set */ - const uint8_t **pp = (const uint8_t **)_pp; - size_t nused; /* Number of filters used for pipeline */ - unsigned enc_size; /* Size of encoded value (in bytes) */ - uint64_t enc_value; /* Value to encode */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t * pline = (H5O_pline_t *)_value; /* Property to set */ + const uint8_t **pp = (const uint8_t **)_pp; + size_t nused; /* Number of filters used for pipeline */ + unsigned enc_size; /* Size of encoded value (in bytes) */ + uint64_t enc_value; /* Value to encode */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1568,7 +1536,7 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) /* Decode the size of size_t */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* decode nused */ @@ -1581,10 +1549,10 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) HDmemset(pline, 0, sizeof(H5O_pline_t)); *pline = H5O_def_pline_g; - for(u = 0; u < nused; u++) { - H5Z_filter_info_t filter; /* Filter info, for pipeline */ - uint8_t has_name; /* Flag to indicate whether filter has a name */ - unsigned v; /* Local index variable */ + for (u = 0; u < nused; u++) { + H5Z_filter_info_t filter; /* Filter info, for pipeline */ + uint8_t has_name; /* Flag to indicate whether filter has a name */ + unsigned v; /* Local index variable */ /* decode filter id */ INT32DECODE(*pp, filter.id) @@ -1594,7 +1562,7 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) /* decode value indicating if the name is encoded */ has_name = *(*pp)++; - if(has_name) { + if (has_name) { /* decode name */ filter.name = H5MM_xstrdup((const char *)(*pp)); *pp += H5Z_COMMON_NAME_LEN; @@ -1608,19 +1576,19 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); filter.cd_nelmts = (size_t)enc_value; - if(filter.cd_nelmts) { - if(NULL == (filter.cd_values = (unsigned *)H5MM_malloc(sizeof(unsigned) * filter.cd_nelmts))) + if (filter.cd_nelmts) { + if (NULL == (filter.cd_values = (unsigned *)H5MM_malloc(sizeof(unsigned) * filter.cd_nelmts))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for cd_values") } /* end if */ else filter.cd_values = NULL; /* decode values */ - for(v = 0; v < filter.cd_nelmts; v++) + for (v = 0; v < filter.cd_nelmts; v++) H5_DECODE_UNSIGNED(*pp, filter.cd_values[v]) /* Add the filter to the I/O pipeline */ - if(H5Z_append(pline, filter.id, filter.flags, filter.cd_nelmts, filter.cd_values) < 0) + if (H5Z_append(pline, filter.id, filter.flags, filter.cd_nelmts, filter.cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") /* Free cd_values, if it was allocated */ @@ -1631,7 +1599,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P__ocrt_pipeline_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_del * @@ -1647,9 +1614,9 @@ done: */ static herr_t H5P__ocrt_pipeline_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1657,14 +1624,13 @@ H5P__ocrt_pipeline_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * HDassert(value); /* Reset the old I/O pipeline */ - if(H5O_msg_reset(H5O_PLINE_ID, value) < 0) + if (H5O_msg_reset(H5O_PLINE_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release I/O pipeline message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_copy * @@ -1679,12 +1645,11 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ - H5O_pline_t new_pline; - herr_t ret_value = SUCCEED; + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1692,7 +1657,7 @@ H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED s HDassert(pline); /* Make copy of I/O pipeline */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") /* Copy new I/O pipeline message over old one */ @@ -1702,7 +1667,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_cmp * @@ -1721,9 +1685,9 @@ done: static int H5P__ocrt_pipeline_cmp(const void *_pline1, const void *_pline2, size_t H5_ATTR_UNUSED size) { - const H5O_pline_t *pline1 = (const H5O_pline_t *)_pline1, /* Create local aliases for values */ - *pline2 = (const H5O_pline_t *)_pline2; - int cmp_value; /* Value from comparison */ + const H5O_pline_t *pline1 = (const H5O_pline_t *)_pline1, /* Create local aliases for values */ + *pline2 = (const H5O_pline_t *)_pline2; + int cmp_value; /* Value from comparison */ herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1734,57 +1698,72 @@ H5P__ocrt_pipeline_cmp(const void *_pline1, const void *_pline2, size_t H5_ATTR_ HDassert(size == sizeof(H5O_pline_t)); /* Check the number of used pipeline entries */ - if(pline1->nused < pline2->nused) HGOTO_DONE(-1); - if(pline1->nused > pline2->nused) HGOTO_DONE(1); + if (pline1->nused < pline2->nused) + HGOTO_DONE(-1); + if (pline1->nused > pline2->nused) + HGOTO_DONE(1); /* Check the filter entry information */ - if(pline1->filter == NULL && pline2->filter != NULL) HGOTO_DONE(-1); - if(pline1->filter != NULL && pline2->filter == NULL) HGOTO_DONE(1); - if(pline1->filter != NULL && pline1->nused > 0) { - size_t u; /* Local index variable */ + if (pline1->filter == NULL && pline2->filter != NULL) + HGOTO_DONE(-1); + if (pline1->filter != NULL && pline2->filter == NULL) + HGOTO_DONE(1); + if (pline1->filter != NULL && pline1->nused > 0) { + size_t u; /* Local index variable */ /* Loop through all filters, comparing them */ - for(u = 0; u < pline1->nused; u++) { + for (u = 0; u < pline1->nused; u++) { /* Check the ID of the filter */ - if(pline1->filter[u].id < pline2->filter[u].id) HGOTO_DONE(-1); - if(pline1->filter[u].id > pline2->filter[u].id) HGOTO_DONE(1); + if (pline1->filter[u].id < pline2->filter[u].id) + HGOTO_DONE(-1); + if (pline1->filter[u].id > pline2->filter[u].id) + HGOTO_DONE(1); /* Check the flags for the filter */ - if(pline1->filter[u].flags < pline2->filter[u].flags) HGOTO_DONE(-1); - if(pline1->filter[u].flags > pline2->filter[u].flags) HGOTO_DONE(1); + if (pline1->filter[u].flags < pline2->filter[u].flags) + HGOTO_DONE(-1); + if (pline1->filter[u].flags > pline2->filter[u].flags) + HGOTO_DONE(1); /* Check the name of the filter */ - if(pline1->filter[u].name == NULL && pline2->filter[u].name != NULL) HGOTO_DONE(-1); - if(pline1->filter[u].name != NULL && pline2->filter[u].name == NULL) HGOTO_DONE(1); - if(pline1->filter[u].name != NULL) - if((cmp_value = HDstrcmp(pline1->filter[u].name, pline2->filter[u].name)) != 0) + if (pline1->filter[u].name == NULL && pline2->filter[u].name != NULL) + HGOTO_DONE(-1); + if (pline1->filter[u].name != NULL && pline2->filter[u].name == NULL) + HGOTO_DONE(1); + if (pline1->filter[u].name != NULL) + if ((cmp_value = HDstrcmp(pline1->filter[u].name, pline2->filter[u].name)) != 0) HGOTO_DONE(cmp_value); /* Check the number of parameters for the filter */ - if(pline1->filter[u].cd_nelmts < pline2->filter[u].cd_nelmts) HGOTO_DONE(-1); - if(pline1->filter[u].cd_nelmts > pline2->filter[u].cd_nelmts) HGOTO_DONE(1); + if (pline1->filter[u].cd_nelmts < pline2->filter[u].cd_nelmts) + HGOTO_DONE(-1); + if (pline1->filter[u].cd_nelmts > pline2->filter[u].cd_nelmts) + HGOTO_DONE(1); /* Check the filter parameter information */ - if(pline1->filter[u].cd_values == NULL && pline2->filter[u].cd_values != NULL) HGOTO_DONE(-1); - if(pline1->filter[u].cd_values != NULL && pline2->filter[u].cd_values == NULL) HGOTO_DONE(1); - if(pline1->filter[u].cd_values != NULL && pline1->filter[u].cd_nelmts > 0) { - size_t v; /* Local index variable */ + if (pline1->filter[u].cd_values == NULL && pline2->filter[u].cd_values != NULL) + HGOTO_DONE(-1); + if (pline1->filter[u].cd_values != NULL && pline2->filter[u].cd_values == NULL) + HGOTO_DONE(1); + if (pline1->filter[u].cd_values != NULL && pline1->filter[u].cd_nelmts > 0) { + size_t v; /* Local index variable */ /* Loop through all parameters, comparing them */ - for(v = 0; v < pline1->filter[u].cd_nelmts; v++) { + for (v = 0; v < pline1->filter[u].cd_nelmts; v++) { /* Check each parameter for the filter */ - if(pline1->filter[u].cd_values[v] < pline2->filter[u].cd_values[v]) HGOTO_DONE(-1); - if(pline1->filter[u].cd_values[v] > pline2->filter[u].cd_values[v]) HGOTO_DONE(1); + if (pline1->filter[u].cd_values[v] < pline2->filter[u].cd_values[v]) + HGOTO_DONE(-1); + if (pline1->filter[u].cd_values[v] > pline2->filter[u].cd_values[v]) + HGOTO_DONE(1); } /* end for */ - } /* end if */ - } /* end for */ - } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_close * @@ -1799,10 +1778,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1810,7 +1788,7 @@ H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED HDassert(value); /* Reset the old I/O pipeline */ - if(H5O_msg_reset(H5O_PLINE_ID, value) < 0) + if (H5O_msg_reset(H5O_PLINE_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release I/O pipeline message") done: @@ -1818,7 +1796,7 @@ done: } /* end H5P__ocrt_pipeline_close() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Pget_filter1 * @@ -1843,57 +1821,57 @@ done: *------------------------------------------------------------------------- */ H5Z_filter_t -H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/) +H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags /*out*/, size_t *cd_nelmts /*in_out*/, + unsigned cd_values[] /*out*/, size_t namelen, char name[] /*out*/) { - H5O_pline_t pline; /* Filter pipeline */ - const H5Z_filter_info_t *filter; /* Pointer to filter information */ - H5P_genplist_t *plist; /* Property list pointer */ - H5Z_filter_t ret_value; /* return value */ + H5O_pline_t pline; /* Filter pipeline */ + const H5Z_filter_info_t *filter; /* Pointer to filter information */ + H5P_genplist_t * plist; /* Property list pointer */ + H5Z_filter_t ret_value; /* return value */ FUNC_ENTER_API(H5Z_FILTER_ERROR) H5TRACE7("Zf", "iIux*zxzx", plist_id, idx, flags, cd_nelmts, cd_values, namelen, name); /* Check args */ - if(cd_nelmts || cd_values) { + if (cd_nelmts || cd_values) { /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ - if(cd_nelmts && *cd_nelmts > 256) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "probable uninitialized *cd_nelmts argument") - if(cd_nelmts && *cd_nelmts > 0 && !cd_values) + if (cd_nelmts && *cd_nelmts > 256) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, + "probable uninitialized *cd_nelmts argument") + if (cd_nelmts && *cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "client data values not supplied") /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ - if(!cd_nelmts) + if (!cd_nelmts) cd_values = NULL; } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_FILTER_ERROR, "can't find object for ID") /* Get pipeline info */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") /* Check more args */ - if(idx >= pline.nused) + if (idx >= pline.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "filter number is invalid") /* Set pointer to particular filter to query */ filter = &pline.filter[idx]; /* Get filter information */ - if(H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, NULL) < 0) + if (H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get filter info") /* Set return value */ @@ -1903,7 +1881,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_filter1() */ - /*------------------------------------------------------------------------- * Function: H5Pget_filter_by_id1 * @@ -1926,48 +1903,47 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/) +H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*in_out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "iZfx*zxzx", plist_id, id, flags, cd_nelmts, cd_values, namelen, name); /* Check args */ - if(cd_nelmts || cd_values) { + if (cd_nelmts || cd_values) { /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ - if(cd_nelmts && *cd_nelmts > 256) + if (cd_nelmts && *cd_nelmts > 256) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "probable uninitialized *cd_nelmts argument") - if(cd_nelmts && *cd_nelmts > 0 && !cd_values) + if (cd_nelmts && *cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "client data values not supplied") /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ - if(!cd_nelmts) + if (!cd_nelmts) cd_values = NULL; } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get filter info */ - if(H5P_get_filter_by_id(plist, id, flags, cd_nelmts, cd_values, namelen, name, NULL) < 0) + if (H5P_get_filter_by_id(plist, id, flags, cd_nelmts, cd_values, namelen, name, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get filter info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_filter_by_id1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index 7390cae..145ba72 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -26,20 +26,18 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -47,43 +45,44 @@ /* ========= Object Copy properties ============ */ /* Definitions for copy options */ -#define H5O_CPY_OPTION_SIZE sizeof(unsigned) -#define H5O_CPY_OPTION_DEF 0 -#define H5O_CPY_OPTION_ENC H5P__encode_unsigned -#define H5O_CPY_OPTION_DEC H5P__decode_unsigned +#define H5O_CPY_OPTION_SIZE sizeof(unsigned) +#define H5O_CPY_OPTION_DEF 0 +#define H5O_CPY_OPTION_ENC H5P__encode_unsigned +#define H5O_CPY_OPTION_DEC H5P__decode_unsigned /* Definitions for merge committed dtype list */ -#define H5O_CPY_MERGE_COMM_DT_LIST_SIZE sizeof(H5O_copy_dtype_merge_list_t *) -#define H5O_CPY_MERGE_COMM_DT_LIST_DEF NULL -#define H5O_CPY_MERGE_COMM_DT_LIST_SET H5P__ocpy_merge_comm_dt_list_set -#define H5O_CPY_MERGE_COMM_DT_LIST_GET H5P__ocpy_merge_comm_dt_list_get -#define H5O_CPY_MERGE_COMM_DT_LIST_ENC H5P__ocpy_merge_comm_dt_list_enc -#define H5O_CPY_MERGE_COMM_DT_LIST_DEC H5P__ocpy_merge_comm_dt_list_dec -#define H5O_CPY_MERGE_COMM_DT_LIST_DEL H5P__ocpy_merge_comm_dt_list_del -#define H5O_CPY_MERGE_COMM_DT_LIST_COPY H5P__ocpy_merge_comm_dt_list_copy -#define H5O_CPY_MERGE_COMM_DT_LIST_CMP H5P__ocpy_merge_comm_dt_list_cmp -#define H5O_CPY_MERGE_COMM_DT_LIST_CLOSE H5P__ocpy_merge_comm_dt_list_close -/* Definitions for callback function when completing the search for a matching committed datatype from the committed dtype list */ -#define H5O_CPY_MCDT_SEARCH_CB_SIZE sizeof(H5O_mcdt_cb_info_t) -#define H5O_CPY_MCDT_SEARCH_CB_DEF {NULL,NULL} - +#define H5O_CPY_MERGE_COMM_DT_LIST_SIZE sizeof(H5O_copy_dtype_merge_list_t *) +#define H5O_CPY_MERGE_COMM_DT_LIST_DEF NULL +#define H5O_CPY_MERGE_COMM_DT_LIST_SET H5P__ocpy_merge_comm_dt_list_set +#define H5O_CPY_MERGE_COMM_DT_LIST_GET H5P__ocpy_merge_comm_dt_list_get +#define H5O_CPY_MERGE_COMM_DT_LIST_ENC H5P__ocpy_merge_comm_dt_list_enc +#define H5O_CPY_MERGE_COMM_DT_LIST_DEC H5P__ocpy_merge_comm_dt_list_dec +#define H5O_CPY_MERGE_COMM_DT_LIST_DEL H5P__ocpy_merge_comm_dt_list_del +#define H5O_CPY_MERGE_COMM_DT_LIST_COPY H5P__ocpy_merge_comm_dt_list_copy +#define H5O_CPY_MERGE_COMM_DT_LIST_CMP H5P__ocpy_merge_comm_dt_list_cmp +#define H5O_CPY_MERGE_COMM_DT_LIST_CLOSE H5P__ocpy_merge_comm_dt_list_close +/* Definitions for callback function when completing the search for a matching committed datatype from the + * committed dtype list */ +#define H5O_CPY_MCDT_SEARCH_CB_SIZE sizeof(H5O_mcdt_cb_info_t) +#define H5O_CPY_MCDT_SEARCH_CB_DEF \ + { \ + NULL, NULL \ + } /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* General routines */ static H5O_copy_dtype_merge_list_t *H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list); -static herr_t H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value); +static herr_t H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value); /* Property class callbacks */ static herr_t H5P__ocpy_reg_prop(H5P_genclass_t *pclass); @@ -94,10 +93,9 @@ static herr_t H5P__ocpy_merge_comm_dt_list_get(hid_t prop_id, const char *name, static herr_t H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *value); static herr_t H5P__ocpy_merge_comm_dt_list_del(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P__ocpy_merge_comm_dt_list_copy(const char* name, size_t size, void* value); -static int H5P__ocpy_merge_comm_dt_list_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__ocpy_merge_comm_dt_list_close(const char* name, size_t size, void* value); - +static herr_t H5P__ocpy_merge_comm_dt_list_copy(const char *name, size_t size, void *value); +static int H5P__ocpy_merge_comm_dt_list_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__ocpy_merge_comm_dt_list_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -105,43 +103,42 @@ static herr_t H5P__ocpy_merge_comm_dt_list_close(const char* name, size_t size, /* Object copy property list class library initialization object */ const H5P_libclass_t H5P_CLS_OCPY[1] = {{ - "object copy", /* Class name for debugging */ - H5P_TYPE_OBJECT_COPY, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_OBJECT_COPY_g, /* Pointer to class */ - &H5P_CLS_OBJECT_COPY_ID_g, /* Pointer to class ID */ - &H5P_LST_OBJECT_COPY_ID_g, /* Pointer to default property list ID */ - H5P__ocpy_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "object copy", /* Class name for debugging */ + H5P_TYPE_OBJECT_COPY, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_OBJECT_COPY_g, /* Pointer to class */ + &H5P_CLS_OBJECT_COPY_ID_g, /* Pointer to class ID */ + &H5P_LST_OBJECT_COPY_ID_g, /* Pointer to default property list ID */ + H5P__ocpy_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const unsigned H5O_def_ocpy_option_g = H5O_CPY_OPTION_DEF; /* Default object copy flags */ -static const H5O_copy_dtype_merge_list_t *H5O_def_merge_comm_dtype_list_g = H5O_CPY_MERGE_COMM_DT_LIST_DEF; /* Default merge committed dtype list */ -static const H5O_mcdt_cb_info_t H5O_def_mcdt_cb_g = H5O_CPY_MCDT_SEARCH_CB_DEF; /* Default callback before searching the global list of committed datatypes at destination */ +static const unsigned H5O_def_ocpy_option_g = H5O_CPY_OPTION_DEF; /* Default object copy flags */ +static const H5O_copy_dtype_merge_list_t *H5O_def_merge_comm_dtype_list_g = + H5O_CPY_MERGE_COMM_DT_LIST_DEF; /* Default merge committed dtype list */ +static const H5O_mcdt_cb_info_t H5O_def_mcdt_cb_g = + H5O_CPY_MCDT_SEARCH_CB_DEF; /* Default callback before searching the global list of committed datatypes at + destination */ /* Declare a free list to manage the H5O_copy_dtype_merge_list_t struct */ H5FL_DEFINE(H5O_copy_dtype_merge_list_t); - - /*------------------------------------------------------------------------- * Function: H5P__ocpy_reg_prop * @@ -156,33 +153,35 @@ H5FL_DEFINE(H5O_copy_dtype_merge_list_t); static herr_t H5P__ocpy_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register copy options property */ - if(H5P__register_real(pclass, H5O_CPY_OPTION_NAME, H5O_CPY_OPTION_SIZE, &H5O_def_ocpy_option_g, - NULL, NULL, NULL, H5O_CPY_OPTION_ENC, H5O_CPY_OPTION_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CPY_OPTION_NAME, H5O_CPY_OPTION_SIZE, &H5O_def_ocpy_option_g, NULL, + NULL, NULL, H5O_CPY_OPTION_ENC, H5O_CPY_OPTION_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register merge named dtype list property */ - if(H5P__register_real(pclass, H5O_CPY_MERGE_COMM_DT_LIST_NAME, H5O_CPY_MERGE_COMM_DT_LIST_SIZE, &H5O_def_merge_comm_dtype_list_g, - NULL, H5O_CPY_MERGE_COMM_DT_LIST_SET, H5O_CPY_MERGE_COMM_DT_LIST_GET, H5O_CPY_MERGE_COMM_DT_LIST_ENC, H5O_CPY_MERGE_COMM_DT_LIST_DEC, - H5O_CPY_MERGE_COMM_DT_LIST_DEL, H5O_CPY_MERGE_COMM_DT_LIST_COPY, H5O_CPY_MERGE_COMM_DT_LIST_CMP, H5O_CPY_MERGE_COMM_DT_LIST_CLOSE) < 0) + if (H5P__register_real(pclass, H5O_CPY_MERGE_COMM_DT_LIST_NAME, H5O_CPY_MERGE_COMM_DT_LIST_SIZE, + &H5O_def_merge_comm_dtype_list_g, NULL, H5O_CPY_MERGE_COMM_DT_LIST_SET, + H5O_CPY_MERGE_COMM_DT_LIST_GET, H5O_CPY_MERGE_COMM_DT_LIST_ENC, + H5O_CPY_MERGE_COMM_DT_LIST_DEC, H5O_CPY_MERGE_COMM_DT_LIST_DEL, + H5O_CPY_MERGE_COMM_DT_LIST_COPY, H5O_CPY_MERGE_COMM_DT_LIST_CMP, + H5O_CPY_MERGE_COMM_DT_LIST_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register property for callback when completing the search for a matching named datatype from the named dtype list */ + /* Register property for callback when completing the search for a matching named datatype from the named + * dtype list */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5O_CPY_MCDT_SEARCH_CB_NAME, H5O_CPY_MCDT_SEARCH_CB_SIZE, &H5O_def_mcdt_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CPY_MCDT_SEARCH_CB_NAME, H5O_CPY_MCDT_SEARCH_CB_SIZE, + &H5O_def_mcdt_cb_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__free_merge_comm_dtype_list * @@ -201,7 +200,7 @@ H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) FUNC_ENTER_STATIC_NOERR /* Free the list */ - while(dt_list) { + while (dt_list) { H5O_copy_dtype_merge_list_t *tmp_node; tmp_node = dt_list->next; @@ -215,7 +214,6 @@ H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) FUNC_LEAVE_NOAPI(NULL); } /* H5P__free_merge_comm_dtype_list */ - /*-------------------------------------------------------------------------- * Function: H5P__copy_merge_comm_dt_list * @@ -232,10 +230,11 @@ H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) static herr_t H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value) { - const H5O_copy_dtype_merge_list_t *src_dt_list; /* Source merge named datatype lists */ - H5O_copy_dtype_merge_list_t *dst_dt_list = NULL; /* Destination merge named datatype lists */ - H5O_copy_dtype_merge_list_t *dst_dt_list_tail = NULL, *tmp_dt_list = NULL; /* temporary merge named datatype lists */ - herr_t ret_value = SUCCEED; + const H5O_copy_dtype_merge_list_t *src_dt_list; /* Source merge named datatype lists */ + H5O_copy_dtype_merge_list_t * dst_dt_list = NULL; /* Destination merge named datatype lists */ + H5O_copy_dtype_merge_list_t * dst_dt_list_tail = NULL, + *tmp_dt_list = NULL; /* temporary merge named datatype lists */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -244,20 +243,20 @@ H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value) /* Make copy of merge committed dtype list */ src_dt_list = *value; - while(src_dt_list) { + while (src_dt_list) { /* Copy src_dt_list */ - if(NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) + if (NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - if(NULL == (tmp_dt_list->path = H5MM_strdup(src_dt_list->path))) + if (NULL == (tmp_dt_list->path = H5MM_strdup(src_dt_list->path))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Add copied node to dest dtype list */ - if(dst_dt_list_tail) { + if (dst_dt_list_tail) { dst_dt_list_tail->next = tmp_dt_list; - dst_dt_list_tail = tmp_dt_list; + dst_dt_list_tail = tmp_dt_list; } /* end if */ else { - dst_dt_list = tmp_dt_list; + dst_dt_list = tmp_dt_list; dst_dt_list_tail = tmp_dt_list; } /* end else */ tmp_dt_list = NULL; @@ -270,18 +269,17 @@ H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value) *value = dst_dt_list; done: - if(ret_value < 0) { + if (ret_value < 0) { dst_dt_list = H5P__free_merge_comm_dtype_list(dst_dt_list); - if(tmp_dt_list) { + if (tmp_dt_list) { tmp_dt_list->path = (char *)H5MM_xfree(tmp_dt_list->path); - tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); + tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__copy_merge_comm_dt_list() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_set * @@ -297,9 +295,9 @@ done: */ static herr_t H5P__ocpy_merge_comm_dt_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -307,14 +305,13 @@ H5P__ocpy_merge_comm_dt_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT HDassert(value); /* Make copy of merge committed dtype list */ - if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + if (H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_set() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_get * @@ -330,9 +327,9 @@ done: */ static herr_t H5P__ocpy_merge_comm_dt_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -340,14 +337,13 @@ H5P__ocpy_merge_comm_dt_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT HDassert(value); /* Make copy of merge committed dtype list */ - if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + if (H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_get() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_enc * @@ -366,10 +362,10 @@ done: static herr_t H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) { - const H5O_copy_dtype_merge_list_t * const *dt_list_ptr = (const H5O_copy_dtype_merge_list_t * const *)value; - uint8_t **pp = (uint8_t **)_pp; - const H5O_copy_dtype_merge_list_t *dt_list; /* Pointer to merge named datatype list */ - size_t len; /* Length of path component */ + const H5O_copy_dtype_merge_list_t *const *dt_list_ptr = (const H5O_copy_dtype_merge_list_t *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + const H5O_copy_dtype_merge_list_t * dt_list; /* Pointer to merge named datatype list */ + size_t len; /* Length of path component */ FUNC_ENTER_STATIC_NOERR @@ -378,12 +374,12 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) /* Iterate over merge committed dtype list */ dt_list = *dt_list_ptr; - while(dt_list) { + while (dt_list) { /* Get length of encoded path */ len = HDstrlen(dt_list->path) + 1; /* Encode merge committed dtype list */ - if(*pp) { + if (*pp) { H5MM_memcpy(*(char **)pp, dt_list->path, len); *pp += len; } /* end if */ @@ -396,7 +392,7 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) } /* end while */ /* Encode the terminator for the string sequence */ - if(*pp) + if (*pp) *(*pp)++ = (uint8_t)'\0'; /* Account for the string sequence terminator */ @@ -405,7 +401,6 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__ocpy_merge_comm_dt_list_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_dec * @@ -424,11 +419,13 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *_value) { - H5O_copy_dtype_merge_list_t **dt_list = (H5O_copy_dtype_merge_list_t **)_value; /* Pointer to merge named datatype list */ - const uint8_t **pp = (const uint8_t **)_pp; - H5O_copy_dtype_merge_list_t *dt_list_tail = NULL, *tmp_dt_list = NULL; /* temporary merge named datatype lists */ - size_t len; /* Length of path component */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_copy_dtype_merge_list_t **dt_list = + (H5O_copy_dtype_merge_list_t **)_value; /* Pointer to merge named datatype list */ + const uint8_t ** pp = (const uint8_t **)_pp; + H5O_copy_dtype_merge_list_t *dt_list_tail = NULL, + *tmp_dt_list = NULL; /* temporary merge named datatype lists */ + size_t len; /* Length of path component */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -442,22 +439,22 @@ H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *_value) /* Decode the string sequence */ len = HDstrlen(*(const char **)pp); - while(len > 0) { + while (len > 0) { /* Create new node & duplicate string */ - if(NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) + if (NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - if(NULL == (tmp_dt_list->path = H5MM_strdup(*(const char **)pp))) + if (NULL == (tmp_dt_list->path = H5MM_strdup(*(const char **)pp))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") *pp += len + 1; HDassert(len == HDstrlen(tmp_dt_list->path)); /* Add copied node to dtype list */ - if(dt_list_tail) { + if (dt_list_tail) { dt_list_tail->next = tmp_dt_list; - dt_list_tail = tmp_dt_list; + dt_list_tail = tmp_dt_list; } /* end if */ else { - *dt_list = tmp_dt_list; + *dt_list = tmp_dt_list; dt_list_tail = tmp_dt_list; } /* end else */ tmp_dt_list = NULL; @@ -470,18 +467,17 @@ H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *_value) *pp += 1; done: - if(ret_value < 0) { + if (ret_value < 0) { *dt_list = H5P__free_merge_comm_dtype_list(*dt_list); - if(tmp_dt_list) { + if (tmp_dt_list) { tmp_dt_list->path = (char *)H5MM_xfree(tmp_dt_list->path); - tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); + tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5P__ocpy_merge_comm_dt_list_dec() */ - /*-------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_del * @@ -497,7 +493,7 @@ done: */ static herr_t H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -510,7 +506,6 @@ H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__ocpy_merge_comm_dt_list_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_copy * @@ -525,10 +520,9 @@ H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT *-------------------------------------------------------------------------- */ static herr_t -H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -536,14 +530,13 @@ H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATT HDassert(value); /* Make copy of merge committed dtype list */ - if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + if (H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_cmp * @@ -561,12 +554,12 @@ done: *------------------------------------------------------------------------- */ static int -H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, - size_t H5_ATTR_UNUSED size) +H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, size_t H5_ATTR_UNUSED size) { - const H5O_copy_dtype_merge_list_t *dt_list1 = *(H5O_copy_dtype_merge_list_t * const *)_dt_list1, /* Create local aliases for values */ - *dt_list2 = *(H5O_copy_dtype_merge_list_t * const *)_dt_list2; - herr_t ret_value = 0; /* Return value */ + const H5O_copy_dtype_merge_list_t *dt_list1 = *(H5O_copy_dtype_merge_list_t *const *) + _dt_list1, /* Create local aliases for values */ + *dt_list2 = *(H5O_copy_dtype_merge_list_t *const *)_dt_list2; + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -577,13 +570,14 @@ H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, /* Walk through the lists, comparing each path. For the lists to be the * same, the paths must be in the same order. */ - while(dt_list1 && dt_list2) { + while (dt_list1 && dt_list2) { HDassert(dt_list1->path); HDassert(dt_list2->path); /* Compare paths */ ret_value = HDstrcmp(dt_list1->path, dt_list2->path); - if(ret_value != 0) HGOTO_DONE(ret_value) + if (ret_value != 0) + HGOTO_DONE(ret_value) /* Advance to next node */ dt_list1 = dt_list1->next; @@ -591,14 +585,15 @@ H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, } /* end while */ /* Check if one list is longer than the other */ - if(dt_list1) HGOTO_DONE(1) - if(dt_list2) HGOTO_DONE(-1) + if (dt_list1) + HGOTO_DONE(1) + if (dt_list2) + HGOTO_DONE(-1) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_cmp() */ - /*-------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_close * @@ -625,7 +620,6 @@ H5P__ocpy_merge_comm_dt_list_close(const char H5_ATTR_UNUSED *name, size_t H5_AT FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__ocpy_merge_comm_dt_list_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_copy_object * @@ -650,29 +644,28 @@ H5P__ocpy_merge_comm_dt_list_close(const char H5_ATTR_UNUSED *name, size_t H5_AT herr_t H5Pset_copy_object(hid_t plist_id, unsigned cpy_option) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, cpy_option); /* Check parameters */ - if(cpy_option & ~H5O_COPY_ALL) + if (cpy_option & ~H5O_COPY_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown option specified") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) + if (H5P_set(plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set copy object flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_copy_object() */ - /*------------------------------------------------------------------------- * Function: H5Pget_copy_object * @@ -688,26 +681,25 @@ done: herr_t H5Pget_copy_object(hid_t plist_id, unsigned *cpy_option /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, cpy_option); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(cpy_option) - if(H5P_get(plist, H5O_CPY_OPTION_NAME, cpy_option) < 0) + if (cpy_option) + if (H5P_get(plist, H5O_CPY_OPTION_NAME, cpy_option) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_copy_object() */ - /*------------------------------------------------------------------------- * Function: H5Padd_merge_committed_dtype_path * @@ -731,50 +723,49 @@ done: herr_t H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_copy_dtype_merge_list_t *old_list; /* Merge committed dtype list currently present */ - H5O_copy_dtype_merge_list_t *new_obj = NULL; /* New object to add to list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5O_copy_dtype_merge_list_t *old_list; /* Merge committed dtype list currently present */ + H5O_copy_dtype_merge_list_t *new_obj = NULL; /* New object to add to list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, path); /* Check parameters */ - if(!path) + if (!path) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no path specified") - if(path[0] == '\0') + if (path[0] == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "path is empty string") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get dtype list */ - if(H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &old_list) < 0) + if (H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &old_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge named dtype list") /* Add the new path to the list */ - if(NULL == (new_obj = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) + if (NULL == (new_obj = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (new_obj->path = H5MM_strdup(path))) + if (NULL == (new_obj->path = H5MM_strdup(path))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") new_obj->next = old_list; /* Update the list stored in the property list */ - if(H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &new_obj) < 0) + if (H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &new_obj) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set merge named dtype list") done: - if(ret_value < 0) - if(new_obj) { + if (ret_value < 0) + if (new_obj) { new_obj->path = (char *)H5MM_xfree(new_obj->path); - new_obj = H5FL_FREE(H5O_copy_dtype_merge_list_t, new_obj); + new_obj = H5FL_FREE(H5O_copy_dtype_merge_list_t, new_obj); } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Padd_merge_committed_dtype_path() */ - /*------------------------------------------------------------------------- * Function: H5Pfree_merge_committed_dtype_paths * @@ -794,33 +785,32 @@ done: herr_t H5Pfree_merge_committed_dtype_paths(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_copy_dtype_merge_list_t *dt_list; /* Merge committed dtype list currently present */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5O_copy_dtype_merge_list_t *dt_list; /* Merge committed dtype list currently present */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get dtype list */ - if(H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + if (H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge committed dtype list") /* Free dtype list */ dt_list = H5P__free_merge_comm_dtype_list(dt_list); /* Update the list stored in the property list (to NULL) */ - if(H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + if (H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set merge committed dtype list") done: FUNC_LEAVE_API(ret_value) } /* end H5Pfree_merge_committed_dtype_paths() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mcdt_search_cb * @@ -842,35 +832,34 @@ done: herr_t H5Pset_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t func, void *op_data) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", plist_id, func, op_data); /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ - if(!func && op_data) + if (!func && op_data) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Populate the callback info struct */ - cb_info.func = func; + /* Populate the callback info struct */ + cb_info.func = func; cb_info.user_data = op_data; /* Set callback info */ - if(H5P_set(plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) + if (H5P_set(plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set callback info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_mcdt_search_cb() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mcdt_search_cb * @@ -891,28 +880,27 @@ done: herr_t H5Pget_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t *func, void **op_data) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", plist_id, func, op_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get callback info */ - if(H5P_get(plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) + if (H5P_get(plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") - if(func) - *func = cb_info.func; + if (func) + *func = cb_info.func; - if(op_data) - *op_data = cb_info.user_data; + if (op_data) + *op_data = cb_info.user_data; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mcdt_search_cb() */ - diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index c8e5e98..04051c8 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -30,27 +30,26 @@ #include "H5Pprivate.h" /* Other private headers needed by this file */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ /* Define enum for type of object that property is within */ typedef enum { - H5P_PROP_WITHIN_UNKNOWN=0, /* Property container is unknown */ - H5P_PROP_WITHIN_LIST, /* Property is within a list */ - H5P_PROP_WITHIN_CLASS /* Property is within a class */ + H5P_PROP_WITHIN_UNKNOWN = 0, /* Property container is unknown */ + H5P_PROP_WITHIN_LIST, /* Property is within a list */ + H5P_PROP_WITHIN_CLASS /* Property is within a class */ } H5P_prop_within_t; /* Define enum for modifications to class */ typedef enum { - H5P_MOD_ERR=(-1), /* Indicate an error */ + H5P_MOD_ERR = (-1), /* Indicate an error */ H5P_MOD_INC_CLS, /* Increment the dependent class count*/ H5P_MOD_DEC_CLS, /* Decrement the dependent class count*/ H5P_MOD_INC_LST, /* Increment the dependent list count*/ @@ -63,54 +62,56 @@ typedef enum { /* Define structure to hold property information */ typedef struct H5P_genprop_t { /* Values for this property */ - char *name; /* Name of property */ - size_t size; /* Size of property value */ - void *value; /* Pointer to property value */ - H5P_prop_within_t type; /* Type of object the property is within */ - hbool_t shared_name; /* Whether the name is shared or not */ + char * name; /* Name of property */ + size_t size; /* Size of property value */ + void * value; /* Pointer to property value */ + H5P_prop_within_t type; /* Type of object the property is within */ + hbool_t shared_name; /* Whether the name is shared or not */ /* Callback function pointers & info */ - H5P_prp_create_func_t create; /* Function to call when a property is created */ - H5P_prp_set_func_t set; /* Function to call when a property value is set */ - H5P_prp_get_func_t get; /* Function to call when a property value is retrieved */ - H5P_prp_encode_func_t encode; /* Function to call when a property is encoded */ - H5P_prp_decode_func_t decode; /* Function to call when a property is decoded */ - H5P_prp_delete_func_t del; /* Function to call when a property is deleted */ - H5P_prp_copy_func_t copy; /* Function to call when a property is copied */ - H5P_prp_compare_func_t cmp; /* Function to call when a property is compared */ - H5P_prp_close_func_t close; /* Function to call when a property is closed */ + H5P_prp_create_func_t create; /* Function to call when a property is created */ + H5P_prp_set_func_t set; /* Function to call when a property value is set */ + H5P_prp_get_func_t get; /* Function to call when a property value is retrieved */ + H5P_prp_encode_func_t encode; /* Function to call when a property is encoded */ + H5P_prp_decode_func_t decode; /* Function to call when a property is decoded */ + H5P_prp_delete_func_t del; /* Function to call when a property is deleted */ + H5P_prp_copy_func_t copy; /* Function to call when a property is copied */ + H5P_prp_compare_func_t cmp; /* Function to call when a property is compared */ + H5P_prp_close_func_t close; /* Function to call when a property is closed */ } H5P_genprop_t; /* Define structure to hold class information */ struct H5P_genclass_t { - struct H5P_genclass_t *parent; /* Pointer to parent class */ - char *name; /* Name of property list class */ - H5P_plist_type_t type; /* Type of property */ - size_t nprops; /* Number of properties in class */ - unsigned plists; /* Number of property lists that have been created since the last modification to the class */ - unsigned classes; /* Number of classes that have been derived since the last modification to the class */ - unsigned ref_count; /* Number of outstanding ID's open on this class object */ - hbool_t deleted; /* Whether this class has been deleted and is waiting for dependent classes & proplists to close */ - unsigned revision; /* Revision number of a particular class (global) */ - H5SL_t *props; /* Skip list containing properties */ + struct H5P_genclass_t *parent; /* Pointer to parent class */ + char * name; /* Name of property list class */ + H5P_plist_type_t type; /* Type of property */ + size_t nprops; /* Number of properties in class */ + unsigned + plists; /* Number of property lists that have been created since the last modification to the class */ + unsigned classes; /* Number of classes that have been derived since the last modification to the class */ + unsigned ref_count; /* Number of outstanding ID's open on this class object */ + hbool_t deleted; /* Whether this class has been deleted and is waiting for dependent classes & proplists + to close */ + unsigned revision; /* Revision number of a particular class (global) */ + H5SL_t * props; /* Skip list containing properties */ /* Callback function pointers & info */ - H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ - void *create_data; /* Pointer to user data to pass along to create callback */ - H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ - void *copy_data; /* Pointer to user data to pass along to copy callback */ - H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ - void *close_data; /* Pointer to user data to pass along to close callback */ + H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ + void * create_data; /* Pointer to user data to pass along to create callback */ + H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ + void * copy_data; /* Pointer to user data to pass along to copy callback */ + H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ + void * close_data; /* Pointer to user data to pass along to close callback */ }; /* Define structure to hold property list information */ struct H5P_genplist_t { - H5P_genclass_t *pclass; /* Pointer to class info */ - hid_t plist_id; /* Copy of the property list ID (for use in close callback) */ - size_t nprops; /* Number of properties in class */ - hbool_t class_init; /* Whether the class initialization callback finished successfully */ - H5SL_t *del; /* Skip list containing names of deleted properties */ - H5SL_t *props; /* Skip list containing properties */ + H5P_genclass_t *pclass; /* Pointer to class info */ + hid_t plist_id; /* Copy of the property list ID (for use in close callback) */ + size_t nprops; /* Number of properties in class */ + hbool_t class_init; /* Whether the class initialization callback finished successfully */ + H5SL_t * del; /* Skip list containing names of deleted properties */ + H5SL_t * props; /* Skip list containing properties */ }; /* Property list/class iterator callback function pointer */ @@ -123,65 +124,55 @@ struct H5Z_filter_info_t; /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ /* Private functions, not part of the publicly documented API */ -H5_DLL H5P_genclass_t *H5P__create_class(H5P_genclass_t *par_class, - const char *name, H5P_plist_type_t type, - H5P_cls_create_func_t cls_create, void *create_data, - H5P_cls_copy_func_t cls_copy, void *copy_data, - H5P_cls_close_func_t cls_close, void *close_data); +H5_DLL H5P_genclass_t *H5P__create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t type, + H5P_cls_create_func_t cls_create, void *create_data, + H5P_cls_copy_func_t cls_copy, void *copy_data, + H5P_cls_close_func_t cls_close, void *close_data); H5_DLL H5P_genclass_t *H5P__copy_pclass(H5P_genclass_t *pclass); -H5_DLL herr_t H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, - const void *def_value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, - H5P_prp_delete_func_t prp_delete, - H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, - H5P_prp_close_func_t prp_close); -H5_DLL herr_t H5P__register(H5P_genclass_t **pclass, const char *name, size_t size, - const void *def_value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, - H5P_prp_delete_func_t prp_delete, - H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, - H5P_prp_close_func_t prp_close); +H5_DLL herr_t H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, const void *def_value, + H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, + H5P_prp_get_func_t prp_get, H5P_prp_encode_func_t prp_encode, + H5P_prp_decode_func_t prp_decode, H5P_prp_delete_func_t prp_delete, + H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, + H5P_prp_close_func_t prp_close); +H5_DLL herr_t H5P__register(H5P_genclass_t **pclass, const char *name, size_t size, const void *def_value, + H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, + H5P_prp_get_func_t prp_get, H5P_prp_encode_func_t prp_encode, + H5P_prp_decode_func_t prp_decode, H5P_prp_delete_func_t prp_delete, + H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, + H5P_prp_close_func_t prp_close); H5_DLL herr_t H5P__add_prop(H5SL_t *props, H5P_genprop_t *prop); H5_DLL herr_t H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod); -H5_DLL herr_t H5P__class_get(const H5P_genclass_t *pclass, const char *name, - void *value); -H5_DLL herr_t H5P__class_set(const H5P_genclass_t *pclass, const char *name, - const void *value); +H5_DLL herr_t H5P__class_get(const H5P_genclass_t *pclass, const char *name, void *value); +H5_DLL herr_t H5P__class_set(const H5P_genclass_t *pclass, const char *name, const void *value); H5_DLL htri_t H5P__exist_pclass(H5P_genclass_t *pclass, const char *name); -H5_DLL herr_t H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, - size_t *size); -H5_DLL herr_t H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, - size_t *size); +H5_DLL herr_t H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size); +H5_DLL herr_t H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size); H5_DLL herr_t H5P__get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops); -H5_DLL int H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); -H5_DLL herr_t H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, - int *cmp_ret); -H5_DLL int H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, - int *idx, H5P_iterate_int_t iter_func, void *iter_data); -H5_DLL int H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, - H5P_iterate_int_t iter_func, void *iter_data); +H5_DLL int H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); +H5_DLL herr_t H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, int *cmp_ret); +H5_DLL int H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, int *idx, + H5P_iterate_int_t iter_func, void *iter_data); +H5_DLL int H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, H5P_iterate_int_t iter_func, + void *iter_data); H5_DLL herr_t H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name); H5_DLL herr_t H5P__copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name); H5_DLL herr_t H5P__unregister(H5P_genclass_t *pclass, const char *name); -H5_DLL char *H5P__get_class_path(H5P_genclass_t *pclass); +H5_DLL char * H5P__get_class_path(H5P_genclass_t *pclass); H5_DLL H5P_genclass_t *H5P__open_class_path(const char *path); H5_DLL H5P_genclass_t *H5P__get_class_parent(const H5P_genclass_t *pclass); -H5_DLL herr_t H5P__close_class(void *_pclass); +H5_DLL herr_t H5P__close_class(void *_pclass); H5_DLL H5P_genprop_t *H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name); -H5_DLL hid_t H5P__new_plist_of_type(H5P_plist_type_t type); +H5_DLL hid_t H5P__new_plist_of_type(H5P_plist_type_t type); /* Encode/decode routines */ -H5_DLL herr_t H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, - void *buf, size_t *nalloc); -H5_DLL hid_t H5P__decode(const void *buf); +H5_DLL herr_t H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, size_t *nalloc); +H5_DLL hid_t H5P__decode(const void *buf); H5_DLL herr_t H5P__encode_hsize_t(const void *value, void **_pp, size_t *size); H5_DLL herr_t H5P__encode_size_t(const void *value, void **_pp, size_t *size); H5_DLL herr_t H5P__encode_unsigned(const void *value, void **_pp, size_t *size); @@ -198,9 +189,8 @@ H5_DLL herr_t H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, siz H5_DLL herr_t H5P__decode_coll_md_read_flag_t(const void **_pp, void *value); /* Private OCPL routines */ -H5_DLL herr_t H5P__get_filter(const struct H5Z_filter_info_t *filter, - unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[], - size_t namelen, char name[], unsigned *filter_config); +H5_DLL herr_t H5P__get_filter(const struct H5Z_filter_info_t *filter, unsigned int *flags, size_t *cd_nelmts, + unsigned cd_values[], size_t namelen, char name[], unsigned *filter_config); /* Testing functions */ #ifdef H5P_TESTING @@ -209,4 +199,3 @@ H5_DLL hid_t H5P__open_class_path_test(const char *path); #endif /* H5P_TESTING */ #endif /* _H5Ppkg_H */ - diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index f7253a0..926b5ca 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -24,64 +24,63 @@ typedef struct H5P_genplist_t H5P_genplist_t; #include "H5Ppublic.h" /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ /**************************/ /* Library Private Macros */ /**************************/ /* ======== String creation property names ======== */ -#define H5P_STRCRT_CHAR_ENCODING_NAME "character_encoding" /* Character set encoding for string */ +#define H5P_STRCRT_CHAR_ENCODING_NAME "character_encoding" /* Character set encoding for string */ /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5P_MODULE -#define H5P_PLIST_ID(P) ((P)->plist_id) -#define H5P_CLASS(P) ((P)->pclass) +#define H5P_PLIST_ID(P) ((P)->plist_id) +#define H5P_CLASS(P) ((P)->pclass) #else /* H5P_MODULE */ -#define H5P_PLIST_ID(P) (H5P_get_plist_id(P)) -#define H5P_CLASS(P) (H5P_get_class(P)) +#define H5P_PLIST_ID(P) (H5P_get_plist_id(P)) +#define H5P_CLASS(P) (H5P_get_class(P)) #endif /* H5P_MODULE */ #define H5_COLL_MD_READ_FLAG_NAME "collective_metadata_read" - /****************************/ /* Library Private Typedefs */ /****************************/ typedef enum H5P_coll_md_read_flag_t { - H5P_FORCE_FALSE = -1, - H5P_USER_FALSE = 0, - H5P_USER_TRUE = 1 + H5P_FORCE_FALSE = -1, + H5P_USER_FALSE = 0, + H5P_USER_TRUE = 1 } H5P_coll_md_read_flag_t; /* Forward declarations for anonymous H5P objects */ typedef struct H5P_genclass_t H5P_genclass_t; typedef enum H5P_plist_type_t { - H5P_TYPE_USER = 0, - H5P_TYPE_ROOT = 1, - H5P_TYPE_OBJECT_CREATE = 2, - H5P_TYPE_FILE_CREATE = 3, - H5P_TYPE_FILE_ACCESS = 4, - H5P_TYPE_DATASET_CREATE = 5, - H5P_TYPE_DATASET_ACCESS = 6, - H5P_TYPE_DATASET_XFER = 7, - H5P_TYPE_FILE_MOUNT = 8, - H5P_TYPE_GROUP_CREATE = 9, - H5P_TYPE_GROUP_ACCESS = 10, - H5P_TYPE_DATATYPE_CREATE = 11, - H5P_TYPE_DATATYPE_ACCESS = 12, - H5P_TYPE_STRING_CREATE = 13, - H5P_TYPE_ATTRIBUTE_CREATE = 14, - H5P_TYPE_OBJECT_COPY = 15, - H5P_TYPE_LINK_CREATE = 16, - H5P_TYPE_LINK_ACCESS = 17, - H5P_TYPE_ATTRIBUTE_ACCESS = 18, - H5P_TYPE_VOL_INITIALIZE = 19, - H5P_TYPE_MAP_CREATE = 20, - H5P_TYPE_MAP_ACCESS = 21, - H5P_TYPE_REFERENCE_ACCESS = 22, + H5P_TYPE_USER = 0, + H5P_TYPE_ROOT = 1, + H5P_TYPE_OBJECT_CREATE = 2, + H5P_TYPE_FILE_CREATE = 3, + H5P_TYPE_FILE_ACCESS = 4, + H5P_TYPE_DATASET_CREATE = 5, + H5P_TYPE_DATASET_ACCESS = 6, + H5P_TYPE_DATASET_XFER = 7, + H5P_TYPE_FILE_MOUNT = 8, + H5P_TYPE_GROUP_CREATE = 9, + H5P_TYPE_GROUP_ACCESS = 10, + H5P_TYPE_DATATYPE_CREATE = 11, + H5P_TYPE_DATATYPE_ACCESS = 12, + H5P_TYPE_STRING_CREATE = 13, + H5P_TYPE_ATTRIBUTE_CREATE = 14, + H5P_TYPE_OBJECT_COPY = 15, + H5P_TYPE_LINK_CREATE = 16, + H5P_TYPE_LINK_ACCESS = 17, + H5P_TYPE_ATTRIBUTE_ACCESS = 18, + H5P_TYPE_VOL_INITIALIZE = 19, + H5P_TYPE_MAP_CREATE = 20, + H5P_TYPE_MAP_ACCESS = 21, + H5P_TYPE_REFERENCE_ACCESS = 22, H5P_TYPE_MAX_TYPE } H5P_plist_type_t; @@ -93,22 +92,22 @@ typedef herr_t (*H5P_reg_prop_func_t)(H5P_genclass_t *pclass); * class variables and methods used to initialize the class. */ typedef struct H5P_libclass_t { - const char *name; /* Class name */ - H5P_plist_type_t type; /* Class type */ + const char * name; /* Class name */ + H5P_plist_type_t type; /* Class type */ - H5P_genclass_t * * par_pclass; /* Pointer to global parent class property list class */ - H5P_genclass_t * * pclass; /* Pointer to global property list class */ - hid_t * const class_id; /* Pointer to global property list class ID */ - hid_t * const def_plist_id; /* Pointer to global default property list ID */ - H5P_reg_prop_func_t reg_prop_func; /* Register class's properties */ + H5P_genclass_t ** par_pclass; /* Pointer to global parent class property list class */ + H5P_genclass_t ** pclass; /* Pointer to global property list class */ + hid_t *const class_id; /* Pointer to global property list class ID */ + hid_t *const def_plist_id; /* Pointer to global default property list ID */ + H5P_reg_prop_func_t reg_prop_func; /* Register class's properties */ /* Class callback function pointers & info */ - H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ - void *create_data; /* Pointer to user data to pass along to create callback */ - H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ - void *copy_data; /* Pointer to user data to pass along to copy callback */ - H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ - void *close_data; /* Pointer to user data to pass along to close callback */ + H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ + void * create_data; /* Pointer to user data to pass along to create callback */ + H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ + void * copy_data; /* Pointer to user data to pass along to copy callback */ + H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ + void * close_data; /* Pointer to user data to pass along to close callback */ } H5P_libclass_t; /*****************************/ @@ -138,15 +137,15 @@ H5_DLLVAR H5P_genclass_t *H5P_CLS_LINK_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_STRING_CREATE_g; /* Internal property list classes */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LCRT[1]; /* Link creation */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LACC[1]; /* Link access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_AACC[1]; /* Attribute access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_DACC[1]; /* Dataset access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_GACC[1]; /* Group access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_TACC[1]; /* Named datatype access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_MACC[1]; /* Map access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_FACC[1]; /* File access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LCRT[1]; /* Link creation */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LACC[1]; /* Link access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_AACC[1]; /* Attribute access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_DACC[1]; /* Dataset access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_GACC[1]; /* Group access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_TACC[1]; /* Named datatype access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_MACC[1]; /* Map access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_FACC[1]; /* File access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */ /******************************/ /* Library Private Prototypes */ @@ -162,44 +161,38 @@ H5_DLL herr_t H5P_init(void); /* Internal versions of API routines */ H5_DLL herr_t H5P_close(void *_plist); -H5_DLL hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref); -H5_DLL hid_t H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref); +H5_DLL hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref); +H5_DLL hid_t H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref); H5_DLL herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value); H5_DLL herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value); H5_DLL herr_t H5P_peek(H5P_genplist_t *plist, const char *name, void *value); H5_DLL herr_t H5P_poke(H5P_genplist_t *plist, const char *name, const void *value); -H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, - void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, - H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, - H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); +H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, void *value, + H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, + H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, + H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, + H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); H5_DLL herr_t H5P_remove(H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_exist_plist(const H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); -H5_DLL char *H5P_get_class_name(H5P_genclass_t *pclass); +H5_DLL char * H5P_get_class_name(H5P_genclass_t *pclass); /* Internal helper routines */ -H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, - hbool_t recurse); -H5_DLL hid_t H5P_peek_driver(H5P_genplist_t *plist); +H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse); +H5_DLL hid_t H5P_peek_driver(H5P_genplist_t *plist); H5_DLL const void *H5P_peek_driver_info(H5P_genplist_t *plist); -H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, - const void *new_driver_info); -H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); -H5_DLL herr_t H5P_reset_vol_class(const H5P_genclass_t *pclass, - const struct H5VL_connector_prop_t *vol_prop); -H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, - H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, - void *free_info); -H5_DLL herr_t H5P_is_fill_value_defined(const struct H5O_fill_t *fill, - H5D_fill_value_t *status); -H5_DLL int H5P_fill_value_cmp(const void *value1, const void *value2, - size_t size); -H5_DLL herr_t H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, - unsigned flags, size_t cd_nelmts, const unsigned cd_values[]); -H5_DLL herr_t H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, - unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[], - size_t namelen, char name[], unsigned *filter_config); +H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); +H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); +H5_DLL herr_t H5P_reset_vol_class(const H5P_genclass_t *pclass, const struct H5VL_connector_prop_t *vol_prop); +H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, + H5MM_free_t free_func, void *free_info); +H5_DLL herr_t H5P_is_fill_value_defined(const struct H5O_fill_t *fill, H5D_fill_value_t *status); +H5_DLL int H5P_fill_value_cmp(const void *value1, const void *value2, size_t size); +H5_DLL herr_t H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned cd_values[]); +H5_DLL herr_t H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags, + size_t *cd_nelmts, unsigned cd_values[], size_t namelen, char name[], + unsigned *filter_config); H5_DLL htri_t H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id); /* Query internal fields of the property list struct */ @@ -211,12 +204,9 @@ H5_DLL htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id); H5_DLL H5P_genplist_t *H5P_object_verify(hid_t plist_id, hid_t pclass_id); /* Private DCPL routines */ -H5_DLL herr_t H5P_fill_value_defined(H5P_genplist_t *plist, - H5D_fill_value_t *status); -H5_DLL herr_t H5P_get_fill_value(H5P_genplist_t *plist, const struct H5T_t *type, - void *value); -H5_DLL int H5P_ignore_cmp(const void H5_ATTR_UNUSED *val1, const void H5_ATTR_UNUSED *val2, - size_t H5_ATTR_UNUSED size); +H5_DLL herr_t H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status); +H5_DLL herr_t H5P_get_fill_value(H5P_genplist_t *plist, const struct H5T_t *type, void *value); +H5_DLL int H5P_ignore_cmp(const void H5_ATTR_UNUSED *val1, const void H5_ATTR_UNUSED *val2, + size_t H5_ATTR_UNUSED size); #endif /* _H5Pprivate_H */ - diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 8d3c92b..14ec28c 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -33,7 +33,6 @@ #include "H5Tpublic.h" #include "H5Zpublic.h" - /*****************/ /* Public Macros */ /*****************/ @@ -41,68 +40,68 @@ /* When this header is included from a private HDF5 header, don't make calls to H5open() */ #undef H5OPEN #ifndef _H5private_H -#define H5OPEN H5open(), -#else /* _H5private_H */ +#define H5OPEN H5open(), +#else /* _H5private_H */ #define H5OPEN -#endif /* _H5private_H */ +#endif /* _H5private_H */ /* * The library's property list classes */ -#define H5P_ROOT (H5OPEN H5P_CLS_ROOT_ID_g) -#define H5P_OBJECT_CREATE (H5OPEN H5P_CLS_OBJECT_CREATE_ID_g) -#define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_ID_g) -#define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_ID_g) -#define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_ID_g) -#define H5P_DATASET_ACCESS (H5OPEN H5P_CLS_DATASET_ACCESS_ID_g) -#define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_ID_g) -#define H5P_FILE_MOUNT (H5OPEN H5P_CLS_FILE_MOUNT_ID_g) -#define H5P_GROUP_CREATE (H5OPEN H5P_CLS_GROUP_CREATE_ID_g) -#define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_ID_g) -#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_ID_g) -#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) -#define H5P_MAP_CREATE (H5OPEN H5P_CLS_MAP_CREATE_ID_g) -#define H5P_MAP_ACCESS (H5OPEN H5P_CLS_MAP_ACCESS_ID_g) -#define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) -#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) -#define H5P_ATTRIBUTE_ACCESS (H5OPEN H5P_CLS_ATTRIBUTE_ACCESS_ID_g) -#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) -#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) -#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) -#define H5P_VOL_INITIALIZE (H5OPEN H5P_CLS_VOL_INITIALIZE_ID_g) -#define H5P_REFERENCE_ACCESS (H5OPEN H5P_CLS_REFERENCE_ACCESS_ID_g) +#define H5P_ROOT (H5OPEN H5P_CLS_ROOT_ID_g) +#define H5P_OBJECT_CREATE (H5OPEN H5P_CLS_OBJECT_CREATE_ID_g) +#define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_ID_g) +#define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_ID_g) +#define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_ID_g) +#define H5P_DATASET_ACCESS (H5OPEN H5P_CLS_DATASET_ACCESS_ID_g) +#define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_ID_g) +#define H5P_FILE_MOUNT (H5OPEN H5P_CLS_FILE_MOUNT_ID_g) +#define H5P_GROUP_CREATE (H5OPEN H5P_CLS_GROUP_CREATE_ID_g) +#define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_ID_g) +#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_ID_g) +#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) +#define H5P_MAP_CREATE (H5OPEN H5P_CLS_MAP_CREATE_ID_g) +#define H5P_MAP_ACCESS (H5OPEN H5P_CLS_MAP_ACCESS_ID_g) +#define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) +#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) +#define H5P_ATTRIBUTE_ACCESS (H5OPEN H5P_CLS_ATTRIBUTE_ACCESS_ID_g) +#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) +#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) +#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) +#define H5P_VOL_INITIALIZE (H5OPEN H5P_CLS_VOL_INITIALIZE_ID_g) +#define H5P_REFERENCE_ACCESS (H5OPEN H5P_CLS_REFERENCE_ACCESS_ID_g) /* * The library's default property lists */ -#define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_ID_g) -#define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_ID_g) -#define H5P_FILE_ACCESS_ANY_VFD (H5OPEN H5P_LST_FILE_ACCESS_ANY_VFD_g) -#define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_ID_g) -#define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_ID_g) -#define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_ID_g) -#define H5P_FILE_MOUNT_DEFAULT (H5OPEN H5P_LST_FILE_MOUNT_ID_g) -#define H5P_GROUP_CREATE_DEFAULT (H5OPEN H5P_LST_GROUP_CREATE_ID_g) -#define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_ID_g) -#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) -#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) -#define H5P_MAP_CREATE_DEFAULT (H5OPEN H5P_LST_MAP_CREATE_ID_g) -#define H5P_MAP_ACCESS_DEFAULT (H5OPEN H5P_LST_MAP_ACCESS_ID_g) -#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) -#define H5P_ATTRIBUTE_ACCESS_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_ACCESS_ID_g) -#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) -#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) -#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) -#define H5P_VOL_INITIALIZE_DEFAULT (H5OPEN H5P_LST_VOL_INITIALIZE_ID_g) -#define H5P_REFERENCE_ACCESS_DEFAULT (H5OPEN H5P_LST_REFERENCE_ACCESS_ID_g) +#define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_ID_g) +#define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_ID_g) +#define H5P_FILE_ACCESS_ANY_VFD (H5OPEN H5P_LST_FILE_ACCESS_ANY_VFD_g) +#define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_ID_g) +#define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_ID_g) +#define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_ID_g) +#define H5P_FILE_MOUNT_DEFAULT (H5OPEN H5P_LST_FILE_MOUNT_ID_g) +#define H5P_GROUP_CREATE_DEFAULT (H5OPEN H5P_LST_GROUP_CREATE_ID_g) +#define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_ID_g) +#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) +#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) +#define H5P_MAP_CREATE_DEFAULT (H5OPEN H5P_LST_MAP_CREATE_ID_g) +#define H5P_MAP_ACCESS_DEFAULT (H5OPEN H5P_LST_MAP_ACCESS_ID_g) +#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) +#define H5P_ATTRIBUTE_ACCESS_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_ACCESS_ID_g) +#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) +#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) +#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) +#define H5P_VOL_INITIALIZE_DEFAULT (H5OPEN H5P_LST_VOL_INITIALIZE_ID_g) +#define H5P_REFERENCE_ACCESS_DEFAULT (H5OPEN H5P_LST_REFERENCE_ACCESS_ID_g) /* Common creation order flags (for links in groups and attributes on objects) */ -#define H5P_CRT_ORDER_TRACKED 0x0001 -#define H5P_CRT_ORDER_INDEXED 0x0002 +#define H5P_CRT_ORDER_TRACKED 0x0001 +#define H5P_CRT_ORDER_INDEXED 0x0002 /* Default value for all property list classes */ -#define H5P_DEFAULT (hid_t)0 +#define H5P_DEFAULT (hid_t)0 #ifdef __cplusplus extern "C" { @@ -112,11 +111,9 @@ extern "C" { /* Public Typedefs */ /*******************/ - /* Define property list class callback function pointer types */ typedef herr_t (*H5P_cls_create_func_t)(hid_t prop_id, void *create_data); -typedef herr_t (*H5P_cls_copy_func_t)(hid_t new_prop_id, hid_t old_prop_id, - void *copy_data); +typedef herr_t (*H5P_cls_copy_func_t)(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); typedef herr_t (*H5P_cls_close_func_t)(hid_t prop_id, void *close_data); /* Define property list callback function pointer types */ @@ -144,7 +141,7 @@ typedef enum H5D_mpio_actual_chunk_opt_mode_t { H5D_MPIO_NO_CHUNK_OPTIMIZATION = 0, H5D_MPIO_LINK_CHUNK, H5D_MPIO_MULTI_CHUNK -} H5D_mpio_actual_chunk_opt_mode_t; +} H5D_mpio_actual_chunk_opt_mode_t; typedef enum H5D_mpio_actual_io_mode_t { /* The following four values are conveniently defined as a bit field so that @@ -157,10 +154,10 @@ typedef enum H5D_mpio_actual_io_mode_t { * CHUNK_INDEPENDENT means that collective I/O was requested, but the * chunk optimization scheme chose independent I/O for each chunk. */ - H5D_MPIO_NO_COLLECTIVE = 0x0, + H5D_MPIO_NO_COLLECTIVE = 0x0, H5D_MPIO_CHUNK_INDEPENDENT = 0x1, - H5D_MPIO_CHUNK_COLLECTIVE = 0x2, - H5D_MPIO_CHUNK_MIXED = 0x1 | 0x2, + H5D_MPIO_CHUNK_COLLECTIVE = 0x2, + H5D_MPIO_CHUNK_MIXED = 0x1 | 0x2, /* The contiguous case is separate from the bit field. */ H5D_MPIO_CONTIGUOUS_COLLECTIVE = 0x4 @@ -168,16 +165,16 @@ typedef enum H5D_mpio_actual_io_mode_t { /* Broken collective IO property */ typedef enum H5D_mpio_no_collective_cause_t { - H5D_MPIO_COLLECTIVE = 0x00, - H5D_MPIO_SET_INDEPENDENT = 0x01, - H5D_MPIO_DATATYPE_CONVERSION = 0x02, - H5D_MPIO_DATA_TRANSFORMS = 0x04, - H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED = 0x08, - H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES = 0x10, - H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET = 0x20, - H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED = 0x40, + H5D_MPIO_COLLECTIVE = 0x00, + H5D_MPIO_SET_INDEPENDENT = 0x01, + H5D_MPIO_DATATYPE_CONVERSION = 0x02, + H5D_MPIO_DATA_TRANSFORMS = 0x04, + H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED = 0x08, + H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES = 0x10, + H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET = 0x20, + H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED = 0x40, H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE = 0x80, - H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE = 0x100 + H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE = 0x100 } H5D_mpio_no_collective_cause_t; /********************/ @@ -237,40 +234,38 @@ H5_DLLVAR hid_t H5P_LST_REFERENCE_ACCESS_ID_g; /*********************/ /* Generic property list routines */ -H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name, - H5P_cls_create_func_t cls_create, void *create_data, - H5P_cls_copy_func_t cls_copy, void *copy_data, - H5P_cls_close_func_t cls_close, void *close_data); -H5_DLL char *H5Pget_class_name(hid_t pclass_id); -H5_DLL hid_t H5Pcreate(hid_t cls_id); -H5_DLL herr_t H5Pregister2(hid_t cls_id, const char *name, size_t size, - void *def_value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_delete_func_t prp_del, H5P_prp_copy_func_t prp_copy, - H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); -H5_DLL herr_t H5Pinsert2(hid_t plist_id, const char *name, size_t size, - void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, - H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); +H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func_t cls_create, + void *create_data, H5P_cls_copy_func_t cls_copy, void *copy_data, + H5P_cls_close_func_t cls_close, void *close_data); +H5_DLL char * H5Pget_class_name(hid_t pclass_id); +H5_DLL hid_t H5Pcreate(hid_t cls_id); +H5_DLL herr_t H5Pregister2(hid_t cls_id, const char *name, size_t size, void *def_value, + H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, + H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_del, + H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, + H5P_prp_close_func_t prp_close); +H5_DLL herr_t H5Pinsert2(hid_t plist_id, const char *name, size_t size, void *value, + H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, + H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, + H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, const void *value); H5_DLL htri_t H5Pexist(hid_t plist_id, const char *name); H5_DLL herr_t H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id); H5_DLL hid_t H5Pdecode(const void *buf); H5_DLL herr_t H5Pget_size(hid_t id, const char *name, size_t *size); H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops); -H5_DLL hid_t H5Pget_class(hid_t plist_id); -H5_DLL hid_t H5Pget_class_parent(hid_t pclass_id); -H5_DLL herr_t H5Pget(hid_t plist_id, const char *name, void * value); +H5_DLL hid_t H5Pget_class(hid_t plist_id); +H5_DLL hid_t H5Pget_class_parent(hid_t pclass_id); +H5_DLL herr_t H5Pget(hid_t plist_id, const char *name, void *value); H5_DLL htri_t H5Pequal(hid_t id1, hid_t id2); H5_DLL htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id); -H5_DLL int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, - void *iter_data); +H5_DLL int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data); H5_DLL herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name); H5_DLL herr_t H5Premove(hid_t plist_id, const char *name); H5_DLL herr_t H5Punregister(hid_t pclass_id, const char *name); H5_DLL herr_t H5Pclose_class(hid_t plist_id); H5_DLL herr_t H5Pclose(hid_t plist_id); -H5_DLL hid_t H5Pcopy(hid_t plist_id); +H5_DLL hid_t H5Pcopy(hid_t plist_id); /* Object creation property list (OCPL) routines */ H5_DLL herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense); @@ -279,109 +274,95 @@ H5_DLL herr_t H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flag H5_DLL herr_t H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags); H5_DLL herr_t H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times); H5_DLL herr_t H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times); -H5_DLL herr_t H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, - unsigned int flags, size_t cd_nelmts, - const unsigned int cd_values[/*cd_nelmts*/]); -H5_DLL herr_t H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, - unsigned int flags, size_t cd_nelmts, - const unsigned int c_values[]); -H5_DLL int H5Pget_nfilters(hid_t plist_id); -H5_DLL H5Z_filter_t H5Pget_filter2(hid_t plist_id, unsigned filter, - unsigned int *flags/*out*/, - size_t *cd_nelmts/*out*/, - unsigned cd_values[]/*out*/, - size_t namelen, char name[], - unsigned *filter_config /*out*/); -H5_DLL herr_t H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t id, - unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, - unsigned cd_values[]/*out*/, size_t namelen, char name[]/*out*/, - unsigned *filter_config/*out*/); -H5_DLL htri_t H5Pall_filters_avail(hid_t plist_id); -H5_DLL herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter); -H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned aggression); -H5_DLL herr_t H5Pset_fletcher32(hid_t plist_id); +H5_DLL herr_t H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]); +H5_DLL herr_t H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int c_values[]); +H5_DLL int H5Pget_nfilters(hid_t plist_id); +H5_DLL H5Z_filter_t H5Pget_filter2(hid_t plist_id, unsigned filter, unsigned int *flags /*out*/, + size_t *cd_nelmts /*out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[], unsigned *filter_config /*out*/); +H5_DLL herr_t H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/, unsigned *filter_config /*out*/); +H5_DLL htri_t H5Pall_filters_avail(hid_t plist_id); +H5_DLL herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter); +H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned aggression); +H5_DLL herr_t H5Pset_fletcher32(hid_t plist_id); /* File creation property list (FCPL) routines */ H5_DLL herr_t H5Pset_userblock(hid_t plist_id, hsize_t size); H5_DLL herr_t H5Pget_userblock(hid_t plist_id, hsize_t *size); -H5_DLL herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, - size_t sizeof_size); -H5_DLL herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr/*out*/, - size_t *sizeof_size/*out*/); +H5_DLL herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size); +H5_DLL herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr /*out*/, size_t *sizeof_size /*out*/); H5_DLL herr_t H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk); -H5_DLL herr_t H5Pget_sym_k(hid_t plist_id, unsigned *ik/*out*/, unsigned *lk/*out*/); +H5_DLL herr_t H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out*/, unsigned *lk /*out*/); H5_DLL herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik); -H5_DLL herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik/*out*/); +H5_DLL herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out*/); H5_DLL herr_t H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes); H5_DLL herr_t H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes); -H5_DLL herr_t H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_flags, unsigned min_mesg_size); -H5_DLL herr_t H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, unsigned *min_mesg_size); +H5_DLL herr_t H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_flags, + unsigned min_mesg_size); +H5_DLL herr_t H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, + unsigned *min_mesg_size); H5_DLL herr_t H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_btree); H5_DLL herr_t H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *min_btree); -H5_DLL herr_t H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold); -H5_DLL herr_t H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, hsize_t *threshold); +H5_DLL herr_t H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, + hsize_t threshold); +H5_DLL herr_t H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, + hsize_t *threshold); H5_DLL herr_t H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size); H5_DLL herr_t H5Pget_file_space_page_size(hid_t plist_id, hsize_t *fsp_size); /* File access property list (FAPL) routines */ -H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, - hsize_t alignment); -H5_DLL herr_t H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/, - hsize_t *alignment/*out*/); -H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, - const void *driver_info); -H5_DLL hid_t H5Pget_driver(hid_t plist_id); +H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment); +H5_DLL herr_t H5Pget_alignment(hid_t fapl_id, hsize_t *threshold /*out*/, hsize_t *alignment /*out*/); +H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_info); +H5_DLL hid_t H5Pget_driver(hid_t plist_id); H5_DLL const void *H5Pget_driver_info(hid_t plist_id); -H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info); -H5_DLL herr_t H5Pget_vol_id(hid_t plist_id, hid_t *vol_id); -H5_DLL herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info); -H5_DLL herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset); -H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); -H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); -H5_DLL herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type); -H5_DLL herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, - size_t rdcc_nslots, size_t rdcc_nbytes, - double rdcc_w0); -H5_DLL herr_t H5Pget_cache(hid_t plist_id, - int *mdc_nelmts, /* out */ - size_t *rdcc_nslots/*out*/, - size_t *rdcc_nbytes/*out*/, double *rdcc_w0); -H5_DLL herr_t H5Pset_mdc_config(hid_t plist_id, - H5AC_cache_config_t * config_ptr); -H5_DLL herr_t H5Pget_mdc_config(hid_t plist_id, - H5AC_cache_config_t * config_ptr); /* out */ -H5_DLL herr_t H5Pset_gc_references(hid_t fapl_id, unsigned gc_ref); -H5_DLL herr_t H5Pget_gc_references(hid_t fapl_id, unsigned *gc_ref/*out*/); -H5_DLL herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t degree); -H5_DLL herr_t H5Pget_fclose_degree(hid_t fapl_id, H5F_close_degree_t *degree); -H5_DLL herr_t H5Pset_meta_block_size(hid_t fapl_id, hsize_t size); -H5_DLL herr_t H5Pget_meta_block_size(hid_t fapl_id, hsize_t *size/*out*/); -H5_DLL herr_t H5Pset_sieve_buf_size(hid_t fapl_id, size_t size); -H5_DLL herr_t H5Pget_sieve_buf_size(hid_t fapl_id, size_t *size/*out*/); -H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size); -H5_DLL herr_t H5Pget_small_data_block_size(hid_t fapl_id, hsize_t *size/*out*/); -H5_DLL herr_t H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, - H5F_libver_t high); -H5_DLL herr_t H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low, - H5F_libver_t *high); -H5_DLL herr_t H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size); -H5_DLL herr_t H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size); -H5_DLL herr_t H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len); -H5_DLL herr_t H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr); -H5_DLL herr_t H5Pset_file_image_callbacks(hid_t fapl_id, - H5FD_file_image_callbacks_t *callbacks_ptr); -H5_DLL herr_t H5Pget_file_image_callbacks(hid_t fapl_id, - H5FD_file_image_callbacks_t *callbacks_ptr); -H5_DLL herr_t H5Pset_core_write_tracking(hid_t fapl_id, hbool_t is_enabled, size_t page_size); -H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size); -H5_DLL herr_t H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts); -H5_DLL herr_t H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts); -H5_DLL herr_t H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata); -H5_DLL herr_t H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata); -H5_DLL herr_t H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, hbool_t start_on_access); -H5_DLL herr_t H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, size_t *location_size, hbool_t *start_on_access); -H5_DLL herr_t H5Pset_evict_on_close(hid_t fapl_id, hbool_t evict_on_close); -H5_DLL herr_t H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close); +H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info); +H5_DLL herr_t H5Pget_vol_id(hid_t plist_id, hid_t *vol_id); +H5_DLL herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info); +H5_DLL herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset); +H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); +H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); +H5_DLL herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type); +H5_DLL herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, size_t rdcc_nslots, size_t rdcc_nbytes, + double rdcc_w0); +H5_DLL herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, /* out */ + size_t *rdcc_nslots /*out*/, size_t *rdcc_nbytes /*out*/, double *rdcc_w0); +H5_DLL herr_t H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr); /* out */ +H5_DLL herr_t H5Pset_gc_references(hid_t fapl_id, unsigned gc_ref); +H5_DLL herr_t H5Pget_gc_references(hid_t fapl_id, unsigned *gc_ref /*out*/); +H5_DLL herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t degree); +H5_DLL herr_t H5Pget_fclose_degree(hid_t fapl_id, H5F_close_degree_t *degree); +H5_DLL herr_t H5Pset_meta_block_size(hid_t fapl_id, hsize_t size); +H5_DLL herr_t H5Pget_meta_block_size(hid_t fapl_id, hsize_t *size /*out*/); +H5_DLL herr_t H5Pset_sieve_buf_size(hid_t fapl_id, size_t size); +H5_DLL herr_t H5Pget_sieve_buf_size(hid_t fapl_id, size_t *size /*out*/); +H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size); +H5_DLL herr_t H5Pget_small_data_block_size(hid_t fapl_id, hsize_t *size /*out*/); +H5_DLL herr_t H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high); +H5_DLL herr_t H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low, H5F_libver_t *high); +H5_DLL herr_t H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size); +H5_DLL herr_t H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size); +H5_DLL herr_t H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len); +H5_DLL herr_t H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr); +H5_DLL herr_t H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr); +H5_DLL herr_t H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr); +H5_DLL herr_t H5Pset_core_write_tracking(hid_t fapl_id, hbool_t is_enabled, size_t page_size); +H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size); +H5_DLL herr_t H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts); +H5_DLL herr_t H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts); +H5_DLL herr_t H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata); +H5_DLL herr_t H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata); +H5_DLL herr_t H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, + hbool_t start_on_access); +H5_DLL herr_t H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, + size_t *location_size, hbool_t *start_on_access); +H5_DLL herr_t H5Pset_evict_on_close(hid_t fapl_id, hbool_t evict_on_close); +H5_DLL herr_t H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close); #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective); H5_DLL herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective); @@ -392,109 +373,90 @@ H5_DLL herr_t H5Pset_mpi_params(hid_t fapl_id, MPI_Comm comm, MPI_Info info); #endif /* H5_HAVE_PARALLEL */ H5_DLL herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr); H5_DLL herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr /*out*/); -H5_DLL herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, unsigned min_raw_per); -H5_DLL herr_t H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_per, unsigned *min_raw_per); +H5_DLL herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, + unsigned min_raw_per); +H5_DLL herr_t H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_per, + unsigned *min_raw_per); /* VFD SWMR configuration */ H5_DLL herr_t H5Pset_vfd_swmr_config(hid_t plist_id, H5F_vfd_swmr_config_t *config_ptr); H5_DLL herr_t H5Pget_vfd_swmr_config(hid_t plist_id, H5F_vfd_swmr_config_t *config_ptr); - /* Dataset creation property list (DCPL) routines */ -H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); +H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); H5_DLL H5D_layout_t H5Pget_layout(hid_t plist_id); -H5_DLL herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]); -H5_DLL int H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/); -H5_DLL herr_t H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, - const char *src_file_name, const char *src_dset_name, hid_t src_space_id); -H5_DLL herr_t H5Pget_virtual_count(hid_t dcpl_id, size_t *count/*out*/); -H5_DLL hid_t H5Pget_virtual_vspace(hid_t dcpl_id, size_t index); -H5_DLL hid_t H5Pget_virtual_srcspace(hid_t dcpl_id, size_t index); -H5_DLL ssize_t H5Pget_virtual_filename(hid_t dcpl_id, size_t index, - char *name/*out*/, size_t size); -H5_DLL ssize_t H5Pget_virtual_dsetname(hid_t dcpl_id, size_t index, - char *name/*out*/, size_t size); -H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, - hsize_t size); -H5_DLL herr_t H5Pset_chunk_opts(hid_t plist_id, unsigned opts); -H5_DLL herr_t H5Pget_chunk_opts(hid_t plist_id, unsigned *opts); -H5_DLL int H5Pget_external_count(hid_t plist_id); -H5_DLL herr_t H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, - char *name/*out*/, off_t *offset/*out*/, - hsize_t *size/*out*/); -H5_DLL herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block); -H5_DLL herr_t H5Pset_shuffle(hid_t plist_id); -H5_DLL herr_t H5Pset_nbit(hid_t plist_id); -H5_DLL herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor); -H5_DLL herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, - const void *value); -H5_DLL herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, - void *value/*out*/); -H5_DLL herr_t H5Pfill_value_defined(hid_t plist, H5D_fill_value_t *status); -H5_DLL herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t - alloc_time); -H5_DLL herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t - *alloc_time/*out*/); -H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); -H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t - *fill_time/*out*/); -H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize); -H5_DLL herr_t H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize); +H5_DLL herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]); +H5_DLL int H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[] /*out*/); +H5_DLL herr_t H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, + const char *src_dset_name, hid_t src_space_id); +H5_DLL herr_t H5Pget_virtual_count(hid_t dcpl_id, size_t *count /*out*/); +H5_DLL hid_t H5Pget_virtual_vspace(hid_t dcpl_id, size_t index); +H5_DLL hid_t H5Pget_virtual_srcspace(hid_t dcpl_id, size_t index); +H5_DLL ssize_t H5Pget_virtual_filename(hid_t dcpl_id, size_t index, char *name /*out*/, size_t size); +H5_DLL ssize_t H5Pget_virtual_dsetname(hid_t dcpl_id, size_t index, char *name /*out*/, size_t size); +H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size); +H5_DLL herr_t H5Pset_chunk_opts(hid_t plist_id, unsigned opts); +H5_DLL herr_t H5Pget_chunk_opts(hid_t plist_id, unsigned *opts); +H5_DLL int H5Pget_external_count(hid_t plist_id); +H5_DLL herr_t H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name /*out*/, + off_t *offset /*out*/, hsize_t *size /*out*/); +H5_DLL herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block); +H5_DLL herr_t H5Pset_shuffle(hid_t plist_id); +H5_DLL herr_t H5Pset_nbit(hid_t plist_id); +H5_DLL herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor); +H5_DLL herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value); +H5_DLL herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value /*out*/); +H5_DLL herr_t H5Pfill_value_defined(hid_t plist, H5D_fill_value_t *status); +H5_DLL herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time); +H5_DLL herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time /*out*/); +H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); +H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time /*out*/); +H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize); +H5_DLL herr_t H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize); /* Dataset access property list (DAPL) routines */ -H5_DLL herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, - size_t rdcc_nbytes, double rdcc_w0); -H5_DLL herr_t H5Pget_chunk_cache(hid_t dapl_id, - size_t *rdcc_nslots/*out*/, - size_t *rdcc_nbytes/*out*/, - double *rdcc_w0/*out*/); -H5_DLL herr_t H5Pset_virtual_view(hid_t plist_id, H5D_vds_view_t view); -H5_DLL herr_t H5Pget_virtual_view(hid_t plist_id, H5D_vds_view_t *view); -H5_DLL herr_t H5Pset_virtual_printf_gap(hid_t plist_id, hsize_t gap_size); -H5_DLL herr_t H5Pget_virtual_printf_gap(hid_t plist_id, hsize_t *gap_size); -H5_DLL herr_t H5Pset_virtual_prefix(hid_t dapl_id, const char* prefix); -H5_DLL ssize_t H5Pget_virtual_prefix(hid_t dapl_id, char* prefix /*out*/, size_t size); -H5_DLL herr_t H5Pset_append_flush(hid_t plist_id, unsigned ndims, - const hsize_t boundary[], H5D_append_cb_t func, void *udata); -H5_DLL herr_t H5Pget_append_flush(hid_t plist_id, unsigned dims, - hsize_t boundary[], H5D_append_cb_t *func, void **udata); -H5_DLL herr_t H5Pset_efile_prefix(hid_t dapl_id, const char* prefix); -H5_DLL ssize_t H5Pget_efile_prefix(hid_t dapl_id, char* prefix /*out*/, size_t size); +H5_DLL herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0); +H5_DLL herr_t H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots /*out*/, size_t *rdcc_nbytes /*out*/, + double *rdcc_w0 /*out*/); +H5_DLL herr_t H5Pset_virtual_view(hid_t plist_id, H5D_vds_view_t view); +H5_DLL herr_t H5Pget_virtual_view(hid_t plist_id, H5D_vds_view_t *view); +H5_DLL herr_t H5Pset_virtual_printf_gap(hid_t plist_id, hsize_t gap_size); +H5_DLL herr_t H5Pget_virtual_printf_gap(hid_t plist_id, hsize_t *gap_size); +H5_DLL herr_t H5Pset_virtual_prefix(hid_t dapl_id, const char *prefix); +H5_DLL ssize_t H5Pget_virtual_prefix(hid_t dapl_id, char *prefix /*out*/, size_t size); +H5_DLL herr_t H5Pset_append_flush(hid_t plist_id, unsigned ndims, const hsize_t boundary[], + H5D_append_cb_t func, void *udata); +H5_DLL herr_t H5Pget_append_flush(hid_t plist_id, unsigned dims, hsize_t boundary[], H5D_append_cb_t *func, + void **udata); +H5_DLL herr_t H5Pset_efile_prefix(hid_t dapl_id, const char *prefix); +H5_DLL ssize_t H5Pget_efile_prefix(hid_t dapl_id, char *prefix /*out*/, size_t size); /* Dataset xfer property list (DXPL) routines */ -H5_DLL herr_t H5Pset_data_transform(hid_t plist_id, const char* expression); -H5_DLL ssize_t H5Pget_data_transform(hid_t plist_id, char* expression /*out*/, size_t size); -H5_DLL herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, - void *bkg); -H5_DLL size_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, - void **bkg/*out*/); -H5_DLL herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); -H5_DLL int H5Pget_preserve(hid_t plist_id); -H5_DLL herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check); +H5_DLL herr_t H5Pset_data_transform(hid_t plist_id, const char *expression); +H5_DLL ssize_t H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size); +H5_DLL herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg); +H5_DLL size_t H5Pget_buffer(hid_t plist_id, void **tconv /*out*/, void **bkg /*out*/); +H5_DLL herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); +H5_DLL int H5Pget_preserve(hid_t plist_id); +H5_DLL herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check); H5_DLL H5Z_EDC_t H5Pget_edc_check(hid_t plist_id); -H5_DLL herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, - void* op_data); -H5_DLL herr_t H5Pset_btree_ratios(hid_t plist_id, double left, double middle, - double right); -H5_DLL herr_t H5Pget_btree_ratios(hid_t plist_id, double *left/*out*/, - double *middle/*out*/, - double *right/*out*/); -H5_DLL herr_t H5Pset_vlen_mem_manager(hid_t plist_id, - H5MM_allocate_t alloc_func, - void *alloc_info, H5MM_free_t free_func, - void *free_info); -H5_DLL herr_t H5Pget_vlen_mem_manager(hid_t plist_id, - H5MM_allocate_t *alloc_func, - void **alloc_info, - H5MM_free_t *free_func, - void **free_info); -H5_DLL herr_t H5Pset_hyper_vector_size(hid_t fapl_id, size_t size); -H5_DLL herr_t H5Pget_hyper_vector_size(hid_t fapl_id, size_t *size/*out*/); -H5_DLL herr_t H5Pset_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t op, void* operate_data); -H5_DLL herr_t H5Pget_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t *op, void** operate_data); +H5_DLL herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void *op_data); +H5_DLL herr_t H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right); +H5_DLL herr_t H5Pget_btree_ratios(hid_t plist_id, double *left /*out*/, double *middle /*out*/, + double *right /*out*/); +H5_DLL herr_t H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, void *alloc_info, + H5MM_free_t free_func, void *free_info); +H5_DLL herr_t H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func, void **alloc_info, + H5MM_free_t *free_func, void **free_info); +H5_DLL herr_t H5Pset_hyper_vector_size(hid_t fapl_id, size_t size); +H5_DLL herr_t H5Pget_hyper_vector_size(hid_t fapl_id, size_t *size /*out*/); +H5_DLL herr_t H5Pset_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t op, void *operate_data); +H5_DLL herr_t H5Pget_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t *op, void **operate_data); #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode); +H5_DLL herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, + H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode); H5_DLL herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode); -H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause); +H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, + uint32_t *global_no_collective_cause); #endif /* H5_HAVE_PARALLEL */ /* Link creation property list (LCPL) routines */ @@ -505,16 +467,19 @@ H5_DLL herr_t H5Pget_create_intermediate_group(hid_t plist_id, unsigned *crt_int H5_DLL herr_t H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint); H5_DLL herr_t H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint /*out*/); H5_DLL herr_t H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense); -H5_DLL herr_t H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned *min_dense /*out*/); +H5_DLL herr_t H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, + unsigned *min_dense /*out*/); H5_DLL herr_t H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name_len); -H5_DLL herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /* out */, unsigned *est_name_len /* out */); +H5_DLL herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /* out */, + unsigned *est_name_len /* out */); H5_DLL herr_t H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags); H5_DLL herr_t H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /* out */); /* Map access property list (MAPL) routines */ #ifdef H5_HAVE_MAP_API H5_DLL herr_t H5Pset_map_iterate_hints(hid_t mapl_id, size_t key_prefetch_size, size_t key_alloc_size); -H5_DLL herr_t H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size /*out*/, size_t *key_alloc_size /*out*/); +H5_DLL herr_t H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size /*out*/, + size_t *key_alloc_size /*out*/); #endif /* H5_HAVE_MAP_API */ /* String creation property list (STRCPL) routines */ @@ -522,16 +487,16 @@ H5_DLL herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding); H5_DLL herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/); /* Link access property list (LAPL) routines */ -H5_DLL herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks); -H5_DLL herr_t H5Pget_nlinks(hid_t plist_id, size_t *nlinks); -H5_DLL herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix); +H5_DLL herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks); +H5_DLL herr_t H5Pget_nlinks(hid_t plist_id, size_t *nlinks); +H5_DLL herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix); H5_DLL ssize_t H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size); -H5_DLL hid_t H5Pget_elink_fapl(hid_t lapl_id); -H5_DLL herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id); -H5_DLL herr_t H5Pset_elink_acc_flags(hid_t lapl_id, unsigned flags); -H5_DLL herr_t H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags); -H5_DLL herr_t H5Pset_elink_cb(hid_t lapl_id, H5L_elink_traverse_t func, void *op_data); -H5_DLL herr_t H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data); +H5_DLL hid_t H5Pget_elink_fapl(hid_t lapl_id); +H5_DLL herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id); +H5_DLL herr_t H5Pset_elink_acc_flags(hid_t lapl_id, unsigned flags); +H5_DLL herr_t H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags); +H5_DLL herr_t H5Pset_elink_cb(hid_t lapl_id, H5L_elink_traverse_t func, void *op_data); +H5_DLL herr_t H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data); /* Object copy property list (OCPYPL) routines */ H5_DLL herr_t H5Pset_copy_object(hid_t plist_id, unsigned crt_intmd); @@ -550,38 +515,33 @@ H5_DLL herr_t H5Pget_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t *func, /* Macros */ /* We renamed the "root" of the property list class hierarchy */ -#define H5P_NO_CLASS H5P_ROOT - +#define H5P_NO_CLASS H5P_ROOT /* Typedefs */ - /* Function prototypes */ -H5_DLL herr_t H5Pregister1(hid_t cls_id, const char *name, size_t size, - void *def_value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_delete_func_t prp_del, H5P_prp_copy_func_t prp_copy, - H5P_prp_close_func_t prp_close); -H5_DLL herr_t H5Pinsert1(hid_t plist_id, const char *name, size_t size, - void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, - H5P_prp_close_func_t prp_close); -H5_DLL herr_t H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc); -H5_DLL H5Z_filter_t H5Pget_filter1(hid_t plist_id, unsigned filter, - unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, - unsigned cd_values[]/*out*/, size_t namelen, char name[]); -H5_DLL herr_t H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, - unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, - unsigned cd_values[]/*out*/, size_t namelen, char name[]/*out*/); -H5_DLL herr_t H5Pget_version(hid_t plist_id, unsigned *boot/*out*/, - unsigned *freelist/*out*/, unsigned *stab/*out*/, - unsigned *shhdr/*out*/); -H5_DLL herr_t H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold); -H5_DLL herr_t H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold); +H5_DLL herr_t H5Pregister1(hid_t cls_id, const char *name, size_t size, void *def_value, + H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, + H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_del, + H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close); +H5_DLL herr_t H5Pinsert1(hid_t plist_id, const char *name, size_t size, void *value, + H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, + H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, + H5P_prp_close_func_t prp_close); +H5_DLL herr_t H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc); +H5_DLL H5Z_filter_t H5Pget_filter1(hid_t plist_id, unsigned filter, unsigned int *flags /*out*/, + size_t *cd_nelmts /*out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[]); +H5_DLL herr_t H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/); +H5_DLL herr_t H5Pget_version(hid_t plist_id, unsigned *boot /*out*/, unsigned *freelist /*out*/, + unsigned *stab /*out*/, unsigned *shhdr /*out*/); +H5_DLL herr_t H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold); +H5_DLL herr_t H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold); #endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus } #endif #endif /* _H5Ppublic_H */ - diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c index 97d6119..69ac1a5 100644 --- a/src/H5Pstrcpl.c +++ b/src/H5Pstrcpl.c @@ -26,18 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -45,22 +43,19 @@ /* ======== String creation properties ======== */ /* Definitions for character set encoding property */ -#define H5P_STRCRT_CHAR_ENCODING_SIZE sizeof(H5T_cset_t) -#define H5P_STRCRT_CHAR_ENCODING_DEF H5F_DEFAULT_CSET -#define H5P_STRCRT_CHAR_ENCODING_ENC H5P__strcrt_char_encoding_enc -#define H5P_STRCRT_CHAR_ENCODING_DEC H5P__strcrt_char_encoding_dec - +#define H5P_STRCRT_CHAR_ENCODING_SIZE sizeof(H5T_cset_t) +#define H5P_STRCRT_CHAR_ENCODING_DEF H5F_DEFAULT_CSET +#define H5P_STRCRT_CHAR_ENCODING_ENC H5P__strcrt_char_encoding_enc +#define H5P_STRCRT_CHAR_ENCODING_DEC H5P__strcrt_char_encoding_dec /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -72,45 +67,41 @@ static herr_t H5P__strcrt_reg_prop(H5P_genclass_t *pclass); static herr_t H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__strcrt_char_encoding_dec(const void **_pp, void *value); - /*********************/ /* Package Variables */ /*********************/ /* String creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_STRCRT[1] = {{ - "string create", /* Class name for debugging */ - H5P_TYPE_STRING_CREATE, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_STRING_CREATE_g, /* Pointer to class */ - &H5P_CLS_STRING_CREATE_ID_g, /* Pointer to class ID */ - NULL, /* Pointer to default property list ID */ - H5P__strcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "string create", /* Class name for debugging */ + H5P_TYPE_STRING_CREATE, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_STRING_CREATE_g, /* Pointer to class */ + &H5P_CLS_STRING_CREATE_ID_g, /* Pointer to class ID */ + NULL, /* Pointer to default property list ID */ + H5P__strcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const H5T_cset_t H5P_def_char_encoding_g = H5P_STRCRT_CHAR_ENCODING_DEF; /* Default character set encoding */ +static const H5T_cset_t H5P_def_char_encoding_g = + H5P_STRCRT_CHAR_ENCODING_DEF; /* Default character set encoding */ - - /*------------------------------------------------------------------------- * Function: H5P__strcrt_reg_prop * @@ -125,21 +116,20 @@ static const H5T_cset_t H5P_def_char_encoding_g = H5P_STRCRT_CHAR_ENCODING_DEF; static herr_t H5P__strcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register character encoding */ - if(H5P__register_real(pclass, H5P_STRCRT_CHAR_ENCODING_NAME, H5P_STRCRT_CHAR_ENCODING_SIZE, &H5P_def_char_encoding_g, - NULL, NULL, NULL, H5P_STRCRT_CHAR_ENCODING_ENC, H5P_STRCRT_CHAR_ENCODING_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5P_STRCRT_CHAR_ENCODING_NAME, H5P_STRCRT_CHAR_ENCODING_SIZE, + &H5P_def_char_encoding_g, NULL, NULL, NULL, H5P_STRCRT_CHAR_ENCODING_ENC, + H5P_STRCRT_CHAR_ENCODING_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__strcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_char_encoding * @@ -154,8 +144,8 @@ done: herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTc", plist_id, encoding); @@ -165,18 +155,17 @@ H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "character encoding is not valid") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_STRING_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_STRING_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set the character encoding */ - if(H5P_set(plist, H5P_STRCRT_CHAR_ENCODING_NAME, &encoding) < 0) + if (H5P_set(plist, H5P_STRCRT_CHAR_ENCODING_NAME, &encoding) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set character encoding") done: FUNC_LEAVE_API(ret_value) } /* end H5P_set_char_encoding() */ - /*------------------------------------------------------------------------- * Function: H5Pget_char_encoding * @@ -191,26 +180,25 @@ done: herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, encoding); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_STRING_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_STRING_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(encoding) - if(H5P_get(plist, H5P_STRCRT_CHAR_ENCODING_NAME, encoding) < 0) + if (encoding) + if (H5P_get(plist, H5P_STRCRT_CHAR_ENCODING_NAME, encoding) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get character encoding flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_char_encoding() */ - /*------------------------------------------------------------------------- * Function: H5P__strcrt_char_encoding_enc * @@ -230,7 +218,7 @@ static herr_t H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) { const H5T_cset_t *encoding = (const H5T_cset_t *)value; /* Create local alias for values */ - uint8_t **pp = (uint8_t **)_pp; + uint8_t ** pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -238,7 +226,7 @@ H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) HDassert(encoding); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode character set encoding */ *(*pp)++ = (uint8_t)*encoding; @@ -248,7 +236,6 @@ H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__strcrt_char_encoding_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__strcrt_char_encoding_dec * @@ -267,8 +254,8 @@ H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__strcrt_char_encoding_dec(const void **_pp, void *_value) { - H5T_cset_t *encoding = (H5T_cset_t *)_value; /* Character set encoding */ - const uint8_t **pp = (const uint8_t **)_pp; + H5T_cset_t * encoding = (H5T_cset_t *)_value; /* Character set encoding */ + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -278,8 +265,7 @@ H5P__strcrt_char_encoding_dec(const void **_pp, void *_value) HDassert(encoding); /* Decode character set encoding */ - *encoding = (H5T_cset_t)*(*pp)++; + *encoding = (H5T_cset_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__strcrt_char_encoding_dec() */ - diff --git a/src/H5Ptest.c b/src/H5Ptest.c index 303fbf7..1ea9746 100644 --- a/src/H5Ptest.c +++ b/src/H5Ptest.c @@ -17,22 +17,20 @@ * Purpose: Generic Property Testing Functions */ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ -#define H5P_TESTING /*suppress warning about H5P testing funcs*/ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ +#define H5P_TESTING /*suppress warning about H5P testing funcs*/ /* Private header files */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5Dprivate.h" /* Dataset */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5Dprivate.h" /* Dataset */ /* Local variables */ /* Local typedefs */ - /*-------------------------------------------------------------------------- NAME H5P__get_class_path_test @@ -58,24 +56,23 @@ char * H5P__get_class_path_test(hid_t pclass_id) { - H5P_genclass_t *pclass; /* Property class to query */ - char *ret_value = NULL; /* Return value */ + H5P_genclass_t *pclass; /* Property class to query */ + char * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class"); /* Get the property list class path */ - if(NULL == (ret_value = H5P__get_class_path(pclass))) + if (NULL == (ret_value = H5P__get_class_path(pclass))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "unable to query full path of class") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_class_path_test() */ +} /* H5P__get_class_path_test() */ - /*-------------------------------------------------------------------------- NAME H5P__open_class_path_test @@ -99,13 +96,13 @@ done: hid_t H5P__open_class_path_test(const char *path) { - H5P_genclass_t *pclass = NULL; /* Property class to query */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genclass_t *pclass = NULL; /* Property class to query */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments. */ - if (NULL == path || *path=='\0') + if (NULL == path || *path == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid class path"); /* Open the property list class */ @@ -121,5 +118,4 @@ done: H5P__close_class(pclass); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__open_class_path_test() */ - +} /* H5P__open_class_path_test() */ diff --git a/src/H5R.c b/src/H5R.c index 8b9c979..dda82eb 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -19,50 +19,43 @@ /* Module Setup */ /****************/ -#include "H5Rmodule.h" /* This source code file is part of the H5R module */ +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Rpkg.h" /* References */ -#include "H5Sprivate.h" /* Dataspaces */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Rpkg.h" /* References */ +#include "H5Sprivate.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5Rcreate_object * @@ -76,79 +69,80 @@ herr_t H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t obj_type; /* Object type of loc_id */ - hid_t file_id = H5I_INVALID_HID;/* File ID */ - H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t obj_type; /* Object type of loc_id */ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*si*Rr", loc_id, name, oapl_id, ref_ptr); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if(oapl_id < 0) + if (oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get object access property list */ - if(H5P_DEFAULT == oapl_id) + if (H5P_DEFAULT == oapl_id) oapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") + else if (TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get object type */ - if((obj_type = H5I_get_type(loc_id)) < 0) + if ((obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the file for the object */ - if((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) + if ((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Retrieve VOL file object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get container info */ - if(H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = oapl_id; - loc_params.obj_type = obj_type; + loc_params.obj_type = obj_type; /* Get the object token */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_token) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") /* Create the reference (do not pass filename, since file_id is attached) */ HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); - if(H5R__create_object((const H5O_token_t *)&obj_token, cont_info.token_size, (H5R_ref_priv_t *)ref_ptr) < 0) + if (H5R__create_object((const H5O_token_t *)&obj_token, cont_info.token_size, (H5R_ref_priv_t *)ref_ptr) < + 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference") /* Attach loc_id to reference and hold reference to it */ - if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) + if (H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") done: - if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) } /* end H5Rcreate_object() */ - /*------------------------------------------------------------------------- * Function: H5Rcreate_region * @@ -161,87 +155,87 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, - hid_t oapl_id, H5R_ref_t *ref_ptr) +H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t obj_type; /* Object type of loc_id */ - hid_t file_id = H5I_INVALID_HID;/* File ID */ - H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t obj_type; /* Object type of loc_id */ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - struct H5S_t *space = NULL; /* Pointer to dataspace containing region */ - herr_t ret_value = SUCCEED; /* Return value */ + struct H5S_t * space = NULL; /* Pointer to dataspace containing region */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sii*Rr", loc_id, name, space_id, oapl_id, ref_ptr); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if((space_id == H5I_BADID) || (space_id == H5S_ALL)) + if ((space_id == H5I_BADID) || (space_id == H5S_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") - if(NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(oapl_id < 0) + if (oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get object access property list */ - if(H5P_DEFAULT == oapl_id) + if (H5P_DEFAULT == oapl_id) oapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") + else if (TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get object type */ - if((obj_type = H5I_get_type(loc_id)) < 0) + if ((obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the file for the object */ - if((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) + if ((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Retrieve VOL file object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get container info */ - if(H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = oapl_id; - loc_params.obj_type = obj_type; + loc_params.obj_type = obj_type; /* Get the object token */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_token) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") /* Create the reference (do not pass filename, since file_id is attached) */ HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); - if(H5R__create_region((const H5O_token_t *)&obj_token, cont_info.token_size, space, (H5R_ref_priv_t *)ref_ptr) < 0) + if (H5R__create_region((const H5O_token_t *)&obj_token, cont_info.token_size, space, + (H5R_ref_priv_t *)ref_ptr) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create region reference") /* Attach loc_id to reference and hold reference to it */ - if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) + if (H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") done: - if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) } /* end H5Rcreate_region() */ - /*------------------------------------------------------------------------- * Function: H5Rcreate_attr * @@ -253,84 +247,84 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, - hid_t oapl_id, H5R_ref_t *ref_ptr) +H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t obj_type; /* Object type of loc_id */ - hid_t file_id = H5I_INVALID_HID;/* File ID */ - H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t obj_type; /* Object type of loc_id */ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*si*Rr", loc_id, name, attr_name, oapl_id, ref_ptr); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name given") - if(oapl_id < 0) + if (oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get object access property list */ - if(H5P_DEFAULT == oapl_id) + if (H5P_DEFAULT == oapl_id) oapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") + else if (TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get object type */ - if((obj_type = H5I_get_type(loc_id)) < 0) + if ((obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the file for the object */ - if((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) + if ((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Retrieve VOL file object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get container info */ - if(H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = oapl_id; - loc_params.obj_type = obj_type; + loc_params.obj_type = obj_type; /* Get the object token */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_token) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") /* Create the reference (do not pass filename, since file_id is attached) */ HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); - if(H5R__create_attr((const H5O_token_t *)&obj_token, cont_info.token_size, attr_name, (H5R_ref_priv_t *)ref_ptr) < 0) + if (H5R__create_attr((const H5O_token_t *)&obj_token, cont_info.token_size, attr_name, + (H5R_ref_priv_t *)ref_ptr) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create attribute reference") /* Attach loc_id to reference and hold reference to it */ - if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) + if (H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") done: - if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) } /* end H5Rcreate_attr() */ - /*------------------------------------------------------------------------- * Function: H5Rdestroy * @@ -344,17 +338,17 @@ done: herr_t H5Rdestroy(H5R_ref_t *ref_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*Rr", ref_ptr); /* Check args */ - if(NULL == ref_ptr) + if (NULL == ref_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid reference pointer") /* Destroy reference */ - if(H5R__destroy((H5R_ref_priv_t *)ref_ptr) < 0) + if (H5R__destroy((H5R_ref_priv_t *)ref_ptr) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "unable to destroy reference") /* Memset back to 0 for safety */ @@ -364,7 +358,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Rdestroy() */ - /*------------------------------------------------------------------------- * Function: H5Rget_type * @@ -378,25 +371,24 @@ done: H5R_type_t H5Rget_type(const H5R_ref_t *ref_ptr) { - H5R_type_t ret_value; /* Return value */ + H5R_type_t ret_value; /* Return value */ FUNC_ENTER_API(H5R_BADTYPE) H5TRACE1("Rt", "*Rr", ref_ptr); /* Check args */ - if(NULL == ref_ptr) + if (NULL == ref_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5R_BADTYPE, "invalid reference pointer") /* Get reference type */ ret_value = H5R__get_type((const H5R_ref_priv_t *)ref_ptr); - if((ret_value <= H5R_BADTYPE) || (ret_value >= H5R_MAXTYPE)) + if ((ret_value <= H5R_BADTYPE) || (ret_value >= H5R_MAXTYPE)) HGOTO_ERROR(H5E_REFERENCE, H5E_BADVALUE, H5R_BADTYPE, "invalid reference type") done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_type() */ - /*------------------------------------------------------------------------- * Function: H5Requal * @@ -409,24 +401,23 @@ done: htri_t H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr) { - htri_t ret_value; /* Return value */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "*Rr*Rr", ref1_ptr, ref2_ptr); /* Check args */ - if(!ref1_ptr || !ref2_ptr) + if (!ref1_ptr || !ref2_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") /* Compare references */ - if((ret_value = H5R__equal((const H5R_ref_priv_t *)ref2_ptr, (const H5R_ref_priv_t *)ref2_ptr)) < 0) + if ((ret_value = H5R__equal((const H5R_ref_priv_t *)ref2_ptr, (const H5R_ref_priv_t *)ref2_ptr)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "cannot compare references") done: FUNC_LEAVE_API(ret_value) } /* end H5Requal() */ - /*------------------------------------------------------------------------- * Function: H5Rcopy * @@ -445,18 +436,17 @@ H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr) H5TRACE2("e", "*Rr*Rr", src_ref_ptr, dst_ref_ptr); /* Check args */ - if(NULL == src_ref_ptr || NULL == dst_ref_ptr) + if (NULL == src_ref_ptr || NULL == dst_ref_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid reference pointer") /* Copy reference */ - if(H5R__copy((const H5R_ref_priv_t *)src_ref_ptr, (H5R_ref_priv_t *)dst_ref_ptr) < 0) + if (H5R__copy((const H5R_ref_priv_t *)src_ref_ptr, (H5R_ref_priv_t *)dst_ref_ptr) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "cannot copy reference") done: FUNC_LEAVE_API(ret_value) } /* end H5Rcopy() */ - /*------------------------------------------------------------------------- * Function: H5Ropen_object * @@ -470,65 +460,65 @@ done: hid_t H5Ropen_object(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) { - hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5I_type_t opened_type; /* Opened object type */ - void *opened_obj = NULL; /* Opened object */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t loc_id; /* Reference location ID */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5I_type_t opened_type; /* Opened object type */ + void * opened_obj = NULL; /* Opened object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*Rrii", ref_ptr, rapl_id, oapl_id); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") - if(H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE - || H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE || + H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") - if(rapl_id < 0) + if (rapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") - if(oapl_id < 0) + if (oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Retrieve loc_id from reference */ - if(H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { /* Attempt to re-open file and pass rapl_id as a fapl_id */ - if((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "cannot re-open referenced file") } /* Get object token */ - if(H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get object token") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&oapl_id, H5P_CLS_DACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&oapl_id, H5P_CLS_DACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Open object by token */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") /* Register object */ - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Ropen_object() */ - /*------------------------------------------------------------------------- * Function: H5Ropen_region * @@ -543,87 +533,88 @@ done: hid_t H5Ropen_region(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) { - hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5I_type_t opened_type; /* Opened object type */ - void *opened_obj = NULL; /* Opened object */ - hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ - H5S_t *space = NULL; /* Dataspace pointer (copy) */ - hid_t space_id = H5I_INVALID_HID; /* Dataspace ID */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t loc_id; /* Reference location ID */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5I_type_t opened_type; /* Opened object type */ + void * opened_obj = NULL; /* Opened object */ + hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ + H5S_t * space = NULL; /* Dataspace pointer (copy) */ + hid_t space_id = H5I_INVALID_HID; /* Dataspace ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*Rrii", ref_ptr, rapl_id, oapl_id); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") - if((H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_DATASET_REGION1) - && (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_DATASET_REGION2)) + if ((H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_DATASET_REGION1) && + (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_DATASET_REGION2)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") - if(rapl_id < 0) + if (rapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") - if(oapl_id < 0) + if (oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Retrieve loc_id from reference */ - if(H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { /* Attempt to re-open file and pass rapl_id as a fapl_id */ - if((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "cannot re-open referenced file") } /* Get object token */ - if(H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get object token") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Open object by token */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") /* Register object */ - if((opened_obj_id = H5VL_register(opened_type, opened_obj, vol_obj->connector, FALSE)) < 0) + if ((opened_obj_id = H5VL_register(opened_type, opened_obj, vol_obj->connector, FALSE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") /* Get VOL object object */ - if(NULL == (opened_obj = H5VL_vol_object(opened_obj_id))) + if (NULL == (opened_obj = H5VL_vol_object(opened_obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get dataspace from object */ - if(H5VL_dataset_get(opened_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &space_id) < 0) + if (H5VL_dataset_get(opened_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &space_id) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace from dataset") - if(NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Get the dataspace with the correct region selected */ - if(H5R__get_region((const H5R_ref_priv_t *)ref_ptr, space) < 0) + if (H5R__get_region((const H5R_ref_priv_t *)ref_ptr, space) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get selection on dataspace") /* Simply return space_id */ ret_value = space_id; done: - if((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) + if ((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object") - if(H5I_INVALID_HID == ret_value) /* Cleanup on failure */ - if((space_id != H5I_INVALID_HID) && (H5I_dec_ref(space_id) < 0)) + if (H5I_INVALID_HID == ret_value) /* Cleanup on failure */ + if ((space_id != H5I_INVALID_HID) && (H5I_dec_ref(space_id) < 0)) HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Ropen_region() */ - /*------------------------------------------------------------------------- * Function: H5Ropen_attr * @@ -637,88 +628,91 @@ done: hid_t H5Ropen_attr(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id) { - hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5I_type_t opened_type; /* Opened object type */ - void *opened_obj = NULL; /* Opened object */ - hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ - void *opened_attr = NULL; /* Opened attribute */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t loc_id; /* Reference location ID */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5I_type_t opened_type; /* Opened object type */ + void * opened_obj = NULL; /* Opened object */ + hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ + void * opened_attr = NULL; /* Opened attribute */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*Rrii", ref_ptr, rapl_id, aapl_id); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") - if(H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_ATTR) + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_ATTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") - if(rapl_id < 0) + if (rapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") - if(aapl_id < 0) + if (aapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Retrieve loc_id from reference */ - if(H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { /* Attempt to re-open file and pass rapl_id as a fapl_id */ - if((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "cannot re-open referenced file") } /* Get object token */ - if(H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get object token") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Open object by token */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") /* Register object */ - if((opened_obj_id = H5VL_register(opened_type, opened_obj, vol_obj->connector, FALSE)) < 0) + if ((opened_obj_id = H5VL_register(opened_type, opened_obj, vol_obj->connector, FALSE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = opened_type; /* Get VOL object object */ - if(NULL == (opened_obj = H5VL_vol_object(opened_obj_id))) + if (NULL == (opened_obj = H5VL_vol_object(opened_obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (opened_attr = H5VL_attr_open(opened_obj, &loc_params, H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr), aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr)) + if (NULL == (opened_attr = H5VL_attr_open(opened_obj, &loc_params, + H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr), aapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", + H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr)) /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, opened_attr, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, opened_attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: - if((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) + if ((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object") - if(H5I_INVALID_HID == ret_value) /* Cleanup on failure */ - if(opened_attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) /* Cleanup on failure */ + if (opened_attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* end H5Ropen_attr() */ - /*------------------------------------------------------------------------- * Function: H5Rget_obj_type3 * @@ -732,53 +726,53 @@ done: herr_t H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type) { - hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t loc_id; /* Reference location ID */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*Rri*Ot", ref_ptr, rapl_id, obj_type); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if(H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE - || H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE || + H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if(rapl_id < 0) + if (rapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve loc_id from reference */ - if(H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { /* Attempt to re-open file and pass rapl_id as a fapl_id */ - if((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, FAIL, "cannot re-open referenced file") } /* Get object token */ - if(H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get object token") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Retrieve object's type */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + obj_type) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve object type") done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_obj_type3() */ - /*------------------------------------------------------------------------- * Function: H5Rget_file_name * @@ -792,42 +786,42 @@ done: ssize_t H5Rget_file_name(const H5R_ref_t *ref_ptr, char *buf, size_t size) { - hid_t loc_id; /* Reference location ID */ - ssize_t ret_value; /* Return value */ + hid_t loc_id; /* Reference location ID */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "*Rr*sz", ref_ptr, buf, size); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") - if(H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE - || H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE || + H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") /* Get name */ - if(H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { /* Un-opened external references do not have loc_id set but hold a * copy of the filename */ - if((ret_value = H5R__get_file_name((const H5R_ref_priv_t *)ref_ptr, buf, size)) < 0) + if ((ret_value = H5R__get_file_name((const H5R_ref_priv_t *)ref_ptr, buf, size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to retrieve file name") } else { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ /* Retrieve VOL file object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5I_FILE, size, buf, &ret_value) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to get file name") + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5I_FILE, + size, buf, &ret_value) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to get file name") } done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_file_name() */ - /*------------------------------------------------------------------------- * Function: H5Rget_obj_name * @@ -841,53 +835,53 @@ done: ssize_t H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size) { - hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - ssize_t ret_value = 0; /* Return value */ + hid_t loc_id; /* Reference location ID */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "*Rri*sz", ref_ptr, rapl_id, buf, size); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") - if(H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE - || H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE || + H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") - if(rapl_id < 0) + if (rapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a property list") /* Retrieve loc_id from reference */ - if(H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { /* Attempt to re-open file and pass rapl_id as a fapl_id */ - if((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, (-1), "cannot re-open referenced file") } /* Get object token */ - if(H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to get object token") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.obj_type = H5I_get_type(loc_id); /* Retrieve object's name */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, buf, size) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value, buf, size) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_obj_name() */ - /*------------------------------------------------------------------------- * Function: H5Rget_attr_name * @@ -900,22 +894,21 @@ done: ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *buf, size_t size) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "*Rr*sz", ref_ptr, buf, size); /* Check args */ - if(ref_ptr == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") - if(H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_ATTR) + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_ATTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") /* Get attribute name */ - if((ret_value = H5R__get_attr_name((const H5R_ref_priv_t *)ref_ptr, buf, size)) < 0) + if ((ret_value = H5R__get_attr_name((const H5R_ref_priv_t *)ref_ptr, buf, size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to determine attribute name") done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_attr_name() */ - diff --git a/src/H5RS.c b/src/H5RS.c index ae500c5..0e05370 100644 --- a/src/H5RS.c +++ b/src/H5RS.c @@ -18,16 +18,15 @@ * */ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5RSprivate.h" /* Reference-counted strings */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5RSprivate.h" /* Reference-counted strings */ /* Private typedefs & structs */ struct H5RS_str_t { - char *s; /* String to be reference counted */ - unsigned wrapped; /* Indicates that the string to be ref-counted is not copied */ - unsigned n; /* Reference count of number of pointers sharing string */ + char * s; /* String to be reference counted */ + unsigned wrapped; /* Indicates that the string to be ref-counted is not copied */ + unsigned n; /* Reference count of number of pointers sharing string */ }; /* Declare a free list to manage the H5RS_str_t struct */ @@ -36,7 +35,6 @@ H5FL_DEFINE_STATIC(H5RS_str_t); /* Declare the PQ free list for the wrapped strings */ H5FL_BLK_DEFINE(str_buf); - /*-------------------------------------------------------------------------- NAME H5RS_xstrdup @@ -59,11 +57,11 @@ H5FL_BLK_DEFINE(str_buf); static char * H5RS_xstrdup(const char *s) { - char *ret_value; /* Return value */ + char *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(s) { + if (s) { size_t len = HDstrlen(s) + 1; ret_value = (char *)H5FL_BLK_MALLOC(str_buf, len); @@ -76,7 +74,6 @@ H5RS_xstrdup(const char *s) FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_xstrdup() */ - /*-------------------------------------------------------------------------- NAME H5RS_create @@ -99,24 +96,23 @@ H5RS_xstrdup(const char *s) H5RS_str_t * H5RS_create(const char *s) { - H5RS_str_t *ret_value; /* Return value */ + H5RS_str_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate ref-counted string structure */ - if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) + if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the internal fields */ - ret_value->s = H5RS_xstrdup(s); + ret_value->s = H5RS_xstrdup(s); ret_value->wrapped = 0; - ret_value->n = 1; + ret_value->n = 1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_create() */ - /*-------------------------------------------------------------------------- NAME H5RS_wrap @@ -139,24 +135,23 @@ done: H5RS_str_t * H5RS_wrap(const char *s) { - H5RS_str_t *ret_value; /* Return value */ + H5RS_str_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate ref-counted string structure */ - if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) + if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the internal fields */ - ret_value->s = (char *)s; + ret_value->s = (char *)s; ret_value->wrapped = 1; - ret_value->n = 1; + ret_value->n = 1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_wrap() */ - /*-------------------------------------------------------------------------- NAME H5RS_own @@ -181,24 +176,23 @@ done: H5RS_str_t * H5RS_own(char *s) { - H5RS_str_t *ret_value; /* Return value */ + H5RS_str_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate ref-counted string structure */ - if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) + if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the internal fields */ - ret_value->s = s; + ret_value->s = s; ret_value->wrapped = 0; - ret_value->n = 1; + ret_value->n = 1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_own() */ - /*-------------------------------------------------------------------------- NAME H5RS_decr @@ -228,8 +222,8 @@ H5RS_decr(H5RS_str_t *rs) HDassert(rs->n > 0); /* Decrement reference count for string */ - if((--rs->n) == 0) { - if(!rs->wrapped) + if ((--rs->n) == 0) { + if (!rs->wrapped) rs->s = (char *)H5FL_BLK_FREE(str_buf, rs->s); rs = H5FL_FREE(H5RS_str_t, rs); } /* end if */ @@ -237,7 +231,6 @@ H5RS_decr(H5RS_str_t *rs) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5RS_decr() */ - /*-------------------------------------------------------------------------- NAME H5RS_incr @@ -269,8 +262,8 @@ H5RS_incr(H5RS_str_t *rs) * string, duplicate the string now, so that the wrapped string can go out * scope appropriately. */ - if(rs->wrapped) { - rs->s = H5RS_xstrdup(rs->s); + if (rs->wrapped) { + rs->s = H5RS_xstrdup(rs->s); rs->wrapped = 0; } /* end if */ @@ -280,7 +273,6 @@ H5RS_incr(H5RS_str_t *rs) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5RS_incr() */ - /*-------------------------------------------------------------------------- NAME H5RS_dup @@ -306,14 +298,13 @@ H5RS_dup(H5RS_str_t *ret_value) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check for valid reference counted string */ - if(ret_value != NULL) + if (ret_value != NULL) /* Increment reference count for string */ ret_value->n++; FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_dup() */ - /*-------------------------------------------------------------------------- NAME H5RS_dup_str @@ -335,8 +326,8 @@ H5RS_dup(H5RS_str_t *ret_value) H5RS_str_t * H5RS_dup_str(const char *s) { - char *new_str; /* Duplicate of string */ - size_t path_len; /* Length of the path */ + char * new_str; /* Duplicate of string */ + size_t path_len; /* Length of the path */ H5RS_str_t *ret_value; FUNC_ENTER_NOAPI(NULL) @@ -348,7 +339,7 @@ H5RS_dup_str(const char *s) path_len = HDstrlen(s); /* Allocate space for the string */ - if(NULL == (new_str = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) + if (NULL == (new_str = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy name for full path */ @@ -361,7 +352,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_dup_str() */ - /*-------------------------------------------------------------------------- NAME H5RS_cmp @@ -398,7 +388,6 @@ H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2) FUNC_LEAVE_NOAPI(HDstrcmp(rs1->s, rs2->s)) } /* end H5RS_cmp() */ - /*-------------------------------------------------------------------------- NAME H5RS_len @@ -429,7 +418,6 @@ H5RS_len(const H5RS_str_t *rs) FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(rs->s)) } /* end H5RS_len() */ - /*-------------------------------------------------------------------------- NAME H5RS_get_str @@ -463,7 +451,6 @@ H5RS_get_str(const H5RS_str_t *rs) FUNC_LEAVE_NOAPI(rs->s) } /* end H5RS_get_str() */ - /*-------------------------------------------------------------------------- NAME H5RS_get_count @@ -494,4 +481,3 @@ H5RS_get_count(const H5RS_str_t *rs) FUNC_LEAVE_NOAPI(rs->n) } /* end H5RS_get_count() */ - diff --git a/src/H5RSprivate.h b/src/H5RSprivate.h index 1d26a18..d1f24cf 100644 --- a/src/H5RSprivate.h +++ b/src/H5RSprivate.h @@ -46,14 +46,13 @@ typedef struct H5RS_str_t H5RS_str_t; H5_DLL H5RS_str_t *H5RS_create(const char *s); H5_DLL H5RS_str_t *H5RS_wrap(const char *s); H5_DLL H5RS_str_t *H5RS_own(char *s); -H5_DLL herr_t H5RS_decr(H5RS_str_t *rs); -H5_DLL herr_t H5RS_incr(H5RS_str_t *rs); +H5_DLL herr_t H5RS_decr(H5RS_str_t *rs); +H5_DLL herr_t H5RS_incr(H5RS_str_t *rs); H5_DLL H5RS_str_t *H5RS_dup(H5RS_str_t *s); H5_DLL H5RS_str_t *H5RS_dup_str(const char *s); -H5_DLL int H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2); -H5_DLL ssize_t H5RS_len(const H5RS_str_t *rs); -H5_DLL char *H5RS_get_str(const H5RS_str_t *rs); -H5_DLL unsigned H5RS_get_count(const H5RS_str_t *rs); +H5_DLL int H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2); +H5_DLL ssize_t H5RS_len(const H5RS_str_t *rs); +H5_DLL char * H5RS_get_str(const H5RS_str_t *rs); +H5_DLL unsigned H5RS_get_count(const H5RS_str_t *rs); #endif /* _H5RSprivate_H */ - diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 4e44683..c29adcc 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -27,57 +27,49 @@ /* Module Setup */ /****************/ -#include "H5Rmodule.h" /* This source code file is part of the H5R module */ - +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ /***********/ /* Headers */ /***********/ /* Public headers needed by this file */ -#include "H5Ppublic.h" /* Property lists */ +#include "H5Ppublic.h" /* Property lists */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Rpkg.h" /* References */ -#include "H5Sprivate.h" /* Dataspaces */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Rpkg.h" /* References */ +#include "H5Sprivate.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -97,42 +89,43 @@ H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5O_type_t obj_type; /* Object type */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5O_type_t obj_type; /* Object type */ const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ - H5G_obj_t ret_value; /* Return value */ + H5G_obj_t ret_value; /* Return value */ FUNC_ENTER_API(H5G_UNKNOWN) H5TRACE3("Go", "iRt*x", id, ref_type, ref); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer") - if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(id))) + if (NULL == (vol_obj = H5VL_vol_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") /* Get object type */ - if((vol_obj_type = H5I_get_type(id)) < 0) + if ((vol_obj_type = H5I_get_type(id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") /* Get object token */ - if(H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5G_UNKNOWN, "unable to get object token") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = vol_obj_type; + loc_params.obj_type = vol_obj_type; /* Retrieve object's type */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &obj_type) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5G_UNKNOWN, "can't retrieve object type") /* Set return value */ @@ -140,9 +133,8 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) done: FUNC_LEAVE_API(ret_value) -} /* end H5Rget_obj_type1() */ +} /* end H5Rget_obj_type1() */ - /*------------------------------------------------------------------------- * Function: H5Rdereference1 * @@ -157,56 +149,56 @@ done: hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5I_type_t opened_type; /* Opened object type */ - void *opened_obj = NULL; /* Opened object */ - const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5I_type_t opened_type; /* Opened object type */ + void * opened_obj = NULL; /* Opened object */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iRt*x", obj_id, ref_type, ref); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") - if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get object type */ - if((vol_obj_type = H5I_get_type(obj_id)) < 0) + if ((vol_obj_type = H5I_get_type(obj_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get object token */ - if(H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object token") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = vol_obj_type; + loc_params.obj_type = vol_obj_type; /* Dereference */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") /* Register object */ - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") done: FUNC_LEAVE_API(ret_value) -} /* end H5Rdereference1() */ +} /* end H5Rdereference1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: H5Rcreate * @@ -220,44 +212,43 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, - hid_t space_id) +H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ - void *vol_obj_file = NULL; - unsigned char *buf = (unsigned char *)ref; /* Return reference pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ + void * vol_obj_file = NULL; + unsigned char * buf = (unsigned char *)ref; /* Return reference pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*xi*sRti", ref, loc_id, name, ref_type, space_id); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(vol_obj, &is_native) < 0) + if (H5VL_object_is_native(vol_obj, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -266,65 +257,68 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, #endif /* NDEBUG */ /* Get object type */ - if((vol_obj_type = H5I_get_type(loc_id)) < 0) + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = vol_obj_type; + loc_params.obj_type = vol_obj_type; /* Get the object token */ - if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_token) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") /* Get the file for the object */ - if((file_id = H5F_get_file_id(vol_obj, vol_obj_type, FALSE)) < 0) + if ((file_id = H5F_get_file_id(vol_obj, vol_obj_type, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Retrieve VOL object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get container info */ - if(H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &cont_info) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") /* Create reference */ - if(ref_type == H5R_OBJECT1) { + if (ref_type == H5R_OBJECT1) { size_t buf_size = H5R_OBJ_REF_BUF_SIZE; - if((ret_value = H5R__encode_token_obj_compat((const H5O_token_t *)&obj_token, cont_info.token_size, buf, &buf_size)) < 0) + if ((ret_value = H5R__encode_token_obj_compat((const H5O_token_t *)&obj_token, cont_info.token_size, + buf, &buf_size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode object reference") } /* end if */ else { - H5F_t *f = NULL; - H5S_t *space = NULL; /* Pointer to dataspace containing region */ + H5F_t *f = NULL; + H5S_t *space = NULL; /* Pointer to dataspace containing region */ size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Retrieve space */ - if(space_id == H5I_BADID) + if (space_id == H5I_BADID) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") - if(NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Retrieve file from VOL object */ - if(NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) + if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Encode dataset region */ - if((ret_value = H5R__encode_token_region_compat(f, (const H5O_token_t *)&obj_token, cont_info.token_size, space, buf, &buf_size)) < 0) + if ((ret_value = H5R__encode_token_region_compat(f, (const H5O_token_t *)&obj_token, + cont_info.token_size, space, buf, &buf_size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode region reference") } /* end else */ done: - if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) -} /* end H5Rcreate() */ +} /* end H5Rcreate() */ - /*------------------------------------------------------------------------- * Function: H5Rget_obj_type2 * @@ -336,51 +330,50 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, - H5O_type_t *obj_type) +H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(id))) + if (NULL == (vol_obj = H5VL_vol_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get object type */ - if((vol_obj_type = H5I_get_type(id)) < 0) + if ((vol_obj_type = H5I_get_type(id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get object token */ - if(H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object token") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = vol_obj_type; + loc_params.obj_type = vol_obj_type; /* Retrieve object's type */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + obj_type) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve object type") done: FUNC_LEAVE_API(ret_value) -} /* end H5Rget_obj_type2() */ +} /* end H5Rget_obj_type2() */ - /*------------------------------------------------------------------------- * Function: H5Rdereference2 * @@ -393,63 +386,62 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, - const void *ref) +H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - H5I_type_t opened_type; /* Opened object type */ - void *opened_obj = NULL; /* Opened object */ - const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + H5I_type_t opened_type; /* Opened object type */ + void * opened_obj = NULL; /* Opened object */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, ref); /* Check args */ - if(oapl_id < 0) + if (oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") - if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&oapl_id, H5P_CLS_DACC, obj_id, FALSE) < 0) + if (H5CX_set_apl(&oapl_id, H5P_CLS_DACC, obj_id, FALSE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Get object type */ - if((vol_obj_type = H5I_get_type(obj_id)) < 0) + if ((vol_obj_type = H5I_get_type(obj_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get object token */ - if(H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object token") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = vol_obj_type; + loc_params.obj_type = vol_obj_type; /* Open object by token */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") /* Register object */ - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") done: FUNC_LEAVE_API(ret_value) -} /* end H5Rdereference2() */ +} /* end H5Rdereference2() */ - /*------------------------------------------------------------------------- * Function: H5Rget_region * @@ -465,37 +457,38 @@ done: hid_t H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - void *vol_obj_file = NULL; /* VOL file */ - H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - H5F_t *f = NULL; /* Native file */ - size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Reference buffer size */ - H5S_t *space = NULL; /* Dataspace object */ - hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ - const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ - hid_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void * vol_obj_file = NULL; /* VOL file */ + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + H5F_t * f = NULL; /* Native file */ + size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Reference buffer size */ + H5S_t * space = NULL; /* Dataspace object */ + hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ + const unsigned char * buf = (const unsigned char *)ref; /* Reference pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iRt*x", id, ref_type, ref); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") - if(ref_type != H5R_DATASET_REGION1) + if (ref_type != H5R_DATASET_REGION1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(id))) + if (NULL == (vol_obj = H5VL_vol_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(vol_obj, &is_native) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't query if file uses native VOL connector") + if (H5VL_object_is_native(vol_obj, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, + "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ HDassert(is_native); @@ -503,40 +496,40 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) #endif /* NDEBUG */ /* Get object type */ - if((vol_obj_type = H5I_get_type(id)) < 0) + if ((vol_obj_type = H5I_get_type(id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get the file for the object */ - if((file_id = H5F_get_file_id(vol_obj, vol_obj_type, FALSE)) < 0) + if ((file_id = H5F_get_file_id(vol_obj, vol_obj_type, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file or file object") /* Retrieve VOL object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Get container info */ - if(H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &cont_info) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get container info") /* Retrieve file from VOL object */ - if(NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) + if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL object") /* Get the dataspace with the correct region selected */ - if(H5R__decode_token_region_compat(f, buf, &buf_size, NULL, cont_info.token_size, &space) < 0) + if (H5R__decode_token_region_compat(f, buf, &buf_size, NULL, cont_info.token_size, &space) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: - if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) -} /* end H5Rget_region1() */ +} /* end H5Rget_region1() */ - /*------------------------------------------------------------------------- * Function: H5Rget_name * @@ -549,47 +542,46 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name, - size_t size) +H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name, size_t size) { - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ - H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ - H5VL_loc_params_t loc_params; /* Location parameters */ - H5O_token_t obj_token = {0}; /* Object token */ - const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE5("Zs", "iRt*x*sz", id, ref_type, ref, name, size); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") - if(ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") /* Get the VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(id))) + if (NULL == (vol_obj = H5VL_vol_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get object type */ - if((vol_obj_type = H5I_get_type(id)) < 0) + if ((vol_obj_type = H5I_get_type(id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Get object token */ - if(H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, (-1), "unable to get object token") /* Set location parameters */ - loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.type = H5VL_OBJECT_BY_TOKEN; loc_params.loc_data.loc_by_token.token = &obj_token; - loc_params.obj_type = vol_obj_type; + loc_params.obj_type = vol_obj_type; /* Retrieve object's name */ - if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size) < 0) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value, name, size) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) -} /* end H5Rget_name() */ - +} /* end H5Rget_name() */ diff --git a/src/H5Rint.c b/src/H5Rint.c index 6dfbf2b..43ca193 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -15,25 +15,24 @@ /* Module Setup */ /****************/ -#include "H5Rmodule.h" /* This source code file is part of the H5R module */ - +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Rpkg.h" /* References */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Rpkg.h" /* References */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -41,87 +40,85 @@ /* Local Macros */ /****************/ -#define H5R_MAX_STRING_LEN (1 << 16) /* Max encoded string length */ +#define H5R_MAX_STRING_LEN (1 << 16) /* Max encoded string length */ /* Encode macro */ -#define H5R_ENCODE(func, val, buf, buf_size, actual, m) do {\ - size_t __nalloc = buf_size; \ - if(func(val, buf, &__nalloc) < 0) \ - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, m) \ - if(buf && buf_size >= __nalloc) { \ - buf += __nalloc; \ - buf_size -= __nalloc; \ - } \ - actual += __nalloc; \ -} while(0) - -#define H5R_ENCODE_VAR(func, var, size, buf, buf_size, actual, m) do { \ - size_t __nalloc = buf_size; \ - if(func(var, size, buf, &__nalloc) < 0) \ - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, m) \ - if(buf && buf_size >= __nalloc) { \ - p += __nalloc; \ - buf_size -= __nalloc; \ - } \ - actual += __nalloc; \ -} while(0) +#define H5R_ENCODE(func, val, buf, buf_size, actual, m) \ + do { \ + size_t __nalloc = buf_size; \ + if (func(val, buf, &__nalloc) < 0) \ + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, m) \ + if (buf && buf_size >= __nalloc) { \ + buf += __nalloc; \ + buf_size -= __nalloc; \ + } \ + actual += __nalloc; \ + } while (0) + +#define H5R_ENCODE_VAR(func, var, size, buf, buf_size, actual, m) \ + do { \ + size_t __nalloc = buf_size; \ + if (func(var, size, buf, &__nalloc) < 0) \ + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, m) \ + if (buf && buf_size >= __nalloc) { \ + p += __nalloc; \ + buf_size -= __nalloc; \ + } \ + actual += __nalloc; \ + } while (0) /* Decode macro */ -#define H5R_DECODE(func, val, buf, buf_size, actual, m) do {\ - size_t __nbytes = buf_size; \ - if(func(buf, &__nbytes, val) < 0) \ - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, m) \ - buf += __nbytes; \ - buf_size -= __nbytes; \ - actual += __nbytes; \ -} while(0) - -#define H5R_DECODE_VAR(func, var, size, buf, buf_size, actual, m) do { \ - size_t __nbytes = buf_size; \ - if(func(buf, &__nbytes, var, size) < 0) \ - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, m) \ - p += __nbytes; \ - buf_size -= __nbytes; \ - actual += __nbytes; \ -} while(0) +#define H5R_DECODE(func, val, buf, buf_size, actual, m) \ + do { \ + size_t __nbytes = buf_size; \ + if (func(buf, &__nbytes, val) < 0) \ + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, m) \ + buf += __nbytes; \ + buf_size -= __nbytes; \ + actual += __nbytes; \ + } while (0) + +#define H5R_DECODE_VAR(func, var, size, buf, buf_size, actual, m) \ + do { \ + size_t __nbytes = buf_size; \ + if (func(buf, &__nbytes, var, size) < 0) \ + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, m) \ + p += __nbytes; \ + buf_size -= __nbytes; \ + actual += __nbytes; \ + } while (0) /* Debug */ //#define H5R_DEBUG #ifdef H5R_DEBUG -#define H5R_LOG_DEBUG(...) do { \ - HDfprintf(stdout, " # %s(): ", __func__); \ - HDfprintf(stdout, __VA_ARGS__); \ - HDfprintf(stdout, "\n"); \ - HDfflush(stdout); \ - } while (0) +#define H5R_LOG_DEBUG(...) \ + do { \ + HDfprintf(stdout, " # %s(): ", __func__); \ + HDfprintf(stdout, __VA_ARGS__); \ + HDfprintf(stdout, "\n"); \ + HDfflush(stdout); \ + } while (0) static const char * -H5R__print_token(const H5O_token_t token) { +H5R__print_token(const H5O_token_t token) +{ static char string[64]; /* Print the raw token. */ HDsnprintf(string, 64, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - (unsigned char)token.__data[15], - (unsigned char)token.__data[14], - (unsigned char)token.__data[13], - (unsigned char)token.__data[12], - (unsigned char)token.__data[11], - (unsigned char)token.__data[10], - (unsigned char)token.__data[9], - (unsigned char)token.__data[8], - (unsigned char)token.__data[7], - (unsigned char)token.__data[6], - (unsigned char)token.__data[5], - (unsigned char)token.__data[4], - (unsigned char)token.__data[3], - (unsigned char)token.__data[2], - (unsigned char)token.__data[1], - (unsigned char)token.__data[0] - ); + (unsigned char)token.__data[15], (unsigned char)token.__data[14], + (unsigned char)token.__data[13], (unsigned char)token.__data[12], + (unsigned char)token.__data[11], (unsigned char)token.__data[10], + (unsigned char)token.__data[9], (unsigned char)token.__data[8], (unsigned char)token.__data[7], + (unsigned char)token.__data[6], (unsigned char)token.__data[5], (unsigned char)token.__data[4], + (unsigned char)token.__data[3], (unsigned char)token.__data[2], (unsigned char)token.__data[1], + (unsigned char)token.__data[0]); return string; } #else -#define H5R_LOG_DEBUG(...) do { } while (0) +#define H5R_LOG_DEBUG(...) \ + do { \ + } while (0) #endif /******************/ @@ -132,8 +129,10 @@ H5R__print_token(const H5O_token_t token) { /* Local Prototypes */ /********************/ -static herr_t H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc); -static herr_t H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, uint8_t *token_size); +static herr_t H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, + size_t *nalloc); +static herr_t H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, + uint8_t *token_size); static herr_t H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc); static herr_t H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr); static herr_t H5R__encode_string(const char *string, unsigned char *buf, size_t *nalloc); @@ -157,7 +156,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Flag indicating "top" of interface has been initialized */ static hbool_t H5R_top_package_initialize_s = FALSE; - /*-------------------------------------------------------------------------- NAME H5R__init_package -- Initialize interface-specific information @@ -184,7 +182,6 @@ H5R__init_package(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5R__init_package() */ - /*-------------------------------------------------------------------------- NAME H5R_top_term_package @@ -206,19 +203,18 @@ H5R__init_package(void) int H5R_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR /* Mark closed if initialized */ - if(H5R_top_package_initialize_s) - if(0 == n) + if (H5R_top_package_initialize_s) + if (0 == n) H5R_top_package_initialize_s = FALSE; FUNC_LEAVE_NOAPI(n) } /* end H5R_top_term_package() */ - /*-------------------------------------------------------------------------- NAME H5R_term_package @@ -242,23 +238,22 @@ H5R_top_term_package(void) int H5R_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(FALSE == H5R_top_package_initialize_s); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } FUNC_LEAVE_NOAPI(n) } /* end H5R_term_package() */ - /*------------------------------------------------------------------------- * Function: H5R__create_object * @@ -269,8 +264,7 @@ H5R_term_package(void) *------------------------------------------------------------------------- */ herr_t -H5R__create_object(const H5O_token_t *obj_token, size_t token_size, - H5R_ref_priv_t *ref) +H5R__create_object(const H5O_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref) { size_t encode_size; herr_t ret_value = SUCCEED; /* Return value */ @@ -281,25 +275,24 @@ H5R__create_object(const H5O_token_t *obj_token, size_t token_size, /* Create new reference */ ref->info.obj.filename = NULL; - ref->loc_id = H5I_INVALID_HID; - ref->type = (uint8_t)H5R_OBJECT2; - if(H5R__set_obj_token(ref, obj_token, token_size) < 0) + ref->loc_id = H5I_INVALID_HID; + ref->type = (uint8_t)H5R_OBJECT2; + if (H5R__set_obj_token(ref, obj_token, token_size) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") /* Cache encoding size (assume no external reference) */ - if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) + if (H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to determine encoding size") ref->encode_size = (uint32_t)encode_size; H5R_LOG_DEBUG("Created object reference, %d, filename=%s, obj_addr=%s, encode size=%u", - (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), - ref->encode_size); + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + ref->encode_size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__create_object() */ - /*------------------------------------------------------------------------- * Function: H5R__create_region * @@ -310,8 +303,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__create_region(const H5O_token_t *obj_token, size_t token_size, - H5S_t *space, H5R_ref_priv_t *ref) +H5R__create_region(const H5O_token_t *obj_token, size_t token_size, H5S_t *space, H5R_ref_priv_t *ref) { size_t encode_size; herr_t ret_value = SUCCEED; /* Return value */ @@ -323,26 +315,26 @@ H5R__create_region(const H5O_token_t *obj_token, size_t token_size, /* Create new reference */ ref->info.obj.filename = NULL; - if(NULL == (ref->info.reg.space = H5S_copy(space, FALSE, TRUE))) + if (NULL == (ref->info.reg.space = H5S_copy(space, FALSE, TRUE))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") ref->loc_id = H5I_INVALID_HID; - ref->type = (uint8_t)H5R_DATASET_REGION2; - if(H5R__set_obj_token(ref, obj_token, token_size) < 0) + ref->type = (uint8_t)H5R_DATASET_REGION2; + if (H5R__set_obj_token(ref, obj_token, token_size) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") /* Cache encoding size (assume no external reference) */ - if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) + if (H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to determine encoding size") ref->encode_size = (uint32_t)encode_size; H5R_LOG_DEBUG("Created region reference, %d, filename=%s, obj_addr=%s, encode size=%u", - (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), - ref->encode_size); + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + ref->encode_size); done: - if(ret_value < 0) - if(ref->info.reg.space) { + if (ret_value < 0) + if (ref->info.reg.space) { H5S_close(ref->info.reg.space); ref->info.reg.space = NULL; } /* end if */ @@ -350,7 +342,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5R__create_region */ - /*------------------------------------------------------------------------- * Function: H5R__create_attr * @@ -361,8 +352,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, - const char *attr_name, H5R_ref_priv_t *ref) +H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, const char *attr_name, H5R_ref_priv_t *ref) { size_t encode_size; herr_t ret_value = SUCCEED; /* Return value */ @@ -373,30 +363,31 @@ H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, HDassert(ref); /* Make sure that attribute name is not longer than supported encode size */ - if(HDstrlen(attr_name) > H5R_MAX_STRING_LEN) - HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, FAIL, "attribute name too long (%d > %d)", (int)HDstrlen(attr_name), H5R_MAX_STRING_LEN) + if (HDstrlen(attr_name) > H5R_MAX_STRING_LEN) + HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, FAIL, "attribute name too long (%d > %d)", + (int)HDstrlen(attr_name), H5R_MAX_STRING_LEN) /* Create new reference */ ref->info.obj.filename = NULL; - if(NULL == (ref->info.attr.name = HDstrdup(attr_name))) + if (NULL == (ref->info.attr.name = HDstrdup(attr_name))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name") ref->loc_id = H5I_INVALID_HID; - ref->type = (uint8_t)H5R_ATTR; - if(H5R__set_obj_token(ref, obj_token, token_size) < 0) + ref->type = (uint8_t)H5R_ATTR; + if (H5R__set_obj_token(ref, obj_token, token_size) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") /* Cache encoding size (assume no external reference) */ - if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) + if (H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to determine encoding size") ref->encode_size = (uint32_t)encode_size; H5R_LOG_DEBUG("Created attribute reference, %d, filename=%s, obj_addr=%s, attr name=%s, encode size=%u", - (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), - ref->info.attr.name, ref->encode_size); + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + ref->info.attr.name, ref->encode_size); done: - if(ret_value < 0) { + if (ret_value < 0) { H5MM_xfree(ref->info.attr.name); ref->info.attr.name = NULL; } /* end if */ @@ -404,7 +395,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5R__create_attr */ - /*------------------------------------------------------------------------- * Function: H5R__destroy * @@ -423,19 +413,18 @@ H5R__destroy(H5R_ref_priv_t *ref) HDassert(ref != NULL); - H5R_LOG_DEBUG("Destroying reference, filename=%s, obj_addr=%s, encode size=%u", - ref->info.obj.filename, H5R__print_token(ref->info.obj.token), - ref->encode_size); + H5R_LOG_DEBUG("Destroying reference, filename=%s, obj_addr=%s, encode size=%u", ref->info.obj.filename, + H5R__print_token(ref->info.obj.token), ref->encode_size); H5MM_xfree(ref->info.obj.filename); ref->info.obj.filename = NULL; - switch(ref->type) { + switch (ref->type) { case H5R_OBJECT2: break; case H5R_DATASET_REGION2: - if(H5S_close(ref->info.reg.space) < 0) + if (H5S_close(ref->info.reg.space) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace") ref->info.reg.space = NULL; break; @@ -459,12 +448,13 @@ H5R__destroy(H5R_ref_priv_t *ref) } /* end switch */ /* Decrement refcount of attached loc_id */ - if(ref->type && (ref->loc_id != H5I_INVALID_HID)) { - if(ref->app_ref) { - if(H5I_dec_app_ref(ref->loc_id) < 0) + if (ref->type && (ref->loc_id != H5I_INVALID_HID)) { + if (ref->app_ref) { + if (H5I_dec_app_ref(ref->loc_id) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") - } else { - if(H5I_dec_ref(ref->loc_id) < 0) + } + else { + if (H5I_dec_ref(ref->loc_id) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") } } @@ -473,7 +463,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__destroy() */ - /*------------------------------------------------------------------------- * Function: H5R__set_loc_id * @@ -495,12 +484,13 @@ H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref) /* If a location ID was previously assigned, decrement refcount and * assign new one */ - if((ref->loc_id != H5I_INVALID_HID)) { - if(ref->app_ref) { - if(H5I_dec_app_ref(ref->loc_id) < 0) + if ((ref->loc_id != H5I_INVALID_HID)) { + if (ref->app_ref) { + if (H5I_dec_app_ref(ref->loc_id) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") - } else { - if(H5I_dec_ref(ref->loc_id) < 0) + } + else { + if (H5I_dec_ref(ref->loc_id) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") } } @@ -510,7 +500,7 @@ H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref) * set app_ref if necessary as references are exposed to users and are * expected to be destroyed, this allows the loc_id to be cleanly released * on shutdown if users fail to call H5Rdestroy(). */ - if(inc_ref && H5I_inc_ref(ref->loc_id, app_ref) < 0) + if (inc_ref && H5I_inc_ref(ref->loc_id, app_ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINC, FAIL, "incrementing location ID failed") ref->app_ref = app_ref; @@ -518,7 +508,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__set_loc_id() */ - /*------------------------------------------------------------------------- * Function: H5R__get_loc_id * @@ -531,7 +520,7 @@ done: hid_t H5R__get_loc_id(const H5R_ref_priv_t *ref) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -542,7 +531,6 @@ H5R__get_loc_id(const H5R_ref_priv_t *ref) FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__get_loc_id() */ - /*------------------------------------------------------------------------- * Function: H5R__reopen_file * @@ -555,63 +543,66 @@ H5R__get_loc_id(const H5R_ref_priv_t *ref) hid_t H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list for FAPL */ - void *new_file = NULL; /* File object opened */ + H5P_genplist_t * plist; /* Property list for FAPL */ + void * new_file = NULL; /* File object opened */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_object_t *vol_obj = NULL; /* VOL object for file */ - hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ - hid_t ret_value = H5I_INVALID_HID; + H5VL_object_t * vol_obj = NULL; /* VOL object for file */ + hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_PACKAGE /* TODO add search path */ /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") - /* Stash a copy of the "top-level" connector property, before any pass-through + /* Stash a copy of the "top-level" connector property, before any pass-through * connectors modify or unwrap it. */ - if(H5CX_set_vol_connector_prop(&connector_prop) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, + "can't set VOL connector info in API context") /* Open the file */ /* (Must open file read-write to allow for object modifications) */ - if(NULL == (new_file = H5VL_file_open(&connector_prop, H5R_REF_FILENAME(ref), H5F_ACC_RDWR, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (new_file = H5VL_file_open(&connector_prop, H5R_REF_FILENAME(ref), H5F_ACC_RDWR, fapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") /* Get an ID for the file */ - if((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) + if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") /* Get the file object */ - if(NULL == (vol_obj = H5VL_vol_object(ret_value))) + if (NULL == (vol_obj = H5VL_vol_object(ret_value))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier") /* Make the 'post open' callback */ supported = FALSE; - if(H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") - if(supported) - if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") + if (supported) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5I_INVALID_HID, + "unable to make file 'post open' callback") /* Attach loc_id to reference */ - if(H5R__set_loc_id((H5R_ref_priv_t *)ref, ret_value, FALSE, TRUE) < 0) + if (H5R__set_loc_id((H5R_ref_priv_t *)ref, ret_value, FALSE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "unable to attach location id to reference") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__reopen_file() */ - /*------------------------------------------------------------------------- * Function: H5R__get_type * @@ -635,7 +626,6 @@ H5R__get_type(const H5R_ref_priv_t *ref) FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__get_type() */ - /*------------------------------------------------------------------------- * Function: H5R__equal * @@ -656,33 +646,33 @@ H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2) HDassert(ref2 != NULL); /* Compare reference types */ - if(ref1->type != ref2->type) + if (ref1->type != ref2->type) HGOTO_DONE(FALSE); /* Compare object addresses */ - if(ref1->token_size != ref2->token_size) + if (ref1->token_size != ref2->token_size) HGOTO_DONE(FALSE); - if(0 != HDmemcmp(&ref1->info.obj.token, &ref2->info.obj.token, ref1->token_size)) + if (0 != HDmemcmp(&ref1->info.obj.token, &ref2->info.obj.token, ref1->token_size)) HGOTO_DONE(FALSE); /* Compare filenames */ - if((ref1->info.obj.filename && (NULL == ref2->info.obj.filename)) - || ((NULL == ref1->info.obj.filename) && ref2->info.obj.filename)) + if ((ref1->info.obj.filename && (NULL == ref2->info.obj.filename)) || + ((NULL == ref1->info.obj.filename) && ref2->info.obj.filename)) HGOTO_DONE(FALSE); - if(ref1->info.obj.filename && ref1->info.obj.filename - && (0 != HDstrcmp(ref1->info.obj.filename, ref2->info.obj.filename))) + if (ref1->info.obj.filename && ref1->info.obj.filename && + (0 != HDstrcmp(ref1->info.obj.filename, ref2->info.obj.filename))) HGOTO_DONE(FALSE); - switch(ref1->type) { + switch (ref1->type) { case H5R_OBJECT2: break; case H5R_DATASET_REGION2: - if((ret_value = H5S_extent_equal(ref1->info.reg.space, ref2->info.reg.space)) < 0) + if ((ret_value = H5S_extent_equal(ref1->info.reg.space, ref2->info.reg.space)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "cannot compare dataspace extents") break; case H5R_ATTR: HDassert(ref1->info.attr.name && ref2->info.attr.name); - if(0 != HDstrcmp(ref1->info.attr.name, ref2->info.attr.name)) + if (0 != HDstrcmp(ref1->info.attr.name, ref2->info.attr.name)) HGOTO_DONE(FALSE); break; case H5R_OBJECT1: @@ -700,7 +690,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__equal() */ - /*------------------------------------------------------------------------- * Function: H5R__copy * @@ -721,18 +710,18 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref) H5MM_memcpy(&dst_ref->info.obj.token, &src_ref->info.obj.token, sizeof(H5O_token_t)); dst_ref->encode_size = src_ref->encode_size; - dst_ref->type = src_ref->type; - dst_ref->token_size = src_ref->token_size; + dst_ref->type = src_ref->type; + dst_ref->token_size = src_ref->token_size; - switch(src_ref->type) { + switch (src_ref->type) { case H5R_OBJECT2: break; case H5R_DATASET_REGION2: - if(NULL == (dst_ref->info.reg.space = H5S_copy(src_ref->info.reg.space, FALSE, TRUE))) + if (NULL == (dst_ref->info.reg.space = H5S_copy(src_ref->info.reg.space, FALSE, TRUE))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") break; case H5R_ATTR: - if(NULL == (dst_ref->info.attr.name = HDstrdup(src_ref->info.attr.name))) + if (NULL == (dst_ref->info.attr.name = HDstrdup(src_ref->info.attr.name))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name") break; case H5R_OBJECT1: @@ -747,10 +736,10 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref) } /* end switch */ /* We only need to keep a copy of the filename if we don't have the loc_id */ - if(src_ref->loc_id == H5I_INVALID_HID) { + if (src_ref->loc_id == H5I_INVALID_HID) { HDassert(src_ref->info.obj.filename); - if(NULL == (dst_ref->info.obj.filename = HDstrdup(src_ref->info.obj.filename))) + if (NULL == (dst_ref->info.obj.filename = HDstrdup(src_ref->info.obj.filename))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy filename") dst_ref->loc_id = H5I_INVALID_HID; } @@ -758,7 +747,7 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref) dst_ref->info.obj.filename = NULL; /* Set location ID and hold reference to it */ - if(H5R__set_loc_id(dst_ref, src_ref->loc_id, TRUE, TRUE) < 0) + if (H5R__set_loc_id(dst_ref, src_ref->loc_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "cannot set reference location ID") } @@ -766,7 +755,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__copy() */ - /*------------------------------------------------------------------------- * Function: H5R__get_obj_token * @@ -777,8 +765,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, - size_t *token_size) +H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, size_t *token_size) { herr_t ret_value = SUCCEED; /* Return value */ @@ -787,19 +774,18 @@ H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, HDassert(ref != NULL); HDassert(ref->token_size <= H5O_MAX_TOKEN_SIZE); - if(obj_token) { - if(0 == ref->token_size) + if (obj_token) { + if (0 == ref->token_size) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "NULL token size") H5MM_memcpy(obj_token, &ref->info.obj.token, sizeof(H5O_token_t)); } - if(token_size) + if (token_size) *token_size = ref->token_size; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__get_obj_token() */ - /*------------------------------------------------------------------------- * Function: H5R__set_obj_token * @@ -810,8 +796,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, - size_t token_size) +H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, size_t token_size) { herr_t ret_value = SUCCEED; /* Return value */ @@ -829,7 +814,6 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__set_obj_token() */ - /*------------------------------------------------------------------------- * Function: H5R__get_region * @@ -853,14 +837,13 @@ H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space) HDassert(space); /* Copy reference selection to destination */ - if(H5S_select_copy(space, ref->info.reg.space, FALSE) < 0) + if (H5S_select_copy(space, ref->info.reg.space, FALSE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__get_region() */ - /*------------------------------------------------------------------------- * Function: H5R__get_file_name * @@ -874,8 +857,8 @@ done: ssize_t H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size) { - size_t copy_len; - ssize_t ret_value = -1; /* Return value */ + size_t copy_len; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -883,7 +866,7 @@ H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size) HDassert(ref != NULL); /* Return if that reference has no filename set */ - if(!ref->info.obj.filename) + if (!ref->info.obj.filename) HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, (-1), "no filename available for that reference") /* Get the file name length */ @@ -891,7 +874,7 @@ H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size) HDassert(copy_len <= H5R_MAX_STRING_LEN); /* Copy the file name */ - if(buf) { + if (buf) { copy_len = MIN(copy_len, size - 1); H5MM_memcpy(buf, ref->info.obj.filename, copy_len); buf[copy_len] = '\0'; @@ -902,7 +885,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__get_file_name() */ - /*------------------------------------------------------------------------- * Function: H5R__get_attr_name * @@ -915,8 +897,8 @@ done: ssize_t H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size) { - ssize_t ret_value = -1; /* Return value */ - size_t attr_name_len; /* Length of the attribute name */ + ssize_t ret_value = -1; /* Return value */ + size_t attr_name_len; /* Length of the attribute name */ FUNC_ENTER_PACKAGE_NOERR @@ -929,7 +911,7 @@ H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size) HDassert(attr_name_len <= H5R_MAX_STRING_LEN); /* Get the attribute name */ - if(buf) { + if (buf) { size_t copy_len = MIN(attr_name_len, size - 1); H5MM_memcpy(buf, ref->info.attr.name, copy_len); buf[copy_len] = '\0'; @@ -940,7 +922,6 @@ H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__get_attr_name() */ - /*------------------------------------------------------------------------- * Function: H5R__encode * @@ -951,12 +932,12 @@ H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size) *------------------------------------------------------------------------- */ herr_t -H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, - size_t *nalloc, unsigned flags) +H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, size_t *nalloc, + unsigned flags) { - uint8_t *p = (uint8_t *)buf; - size_t buf_size = 0, encode_size = 0; - herr_t ret_value = SUCCEED; + uint8_t *p = (uint8_t *)buf; + size_t buf_size = 0, encode_size = 0; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -976,7 +957,7 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, */ /* Don't encode if buffer size isn't big enough or buffer is empty */ - if(buf && *nalloc >= H5R_ENCODE_HEADER_SIZE) { + if (buf && *nalloc >= H5R_ENCODE_HEADER_SIZE) { /* Encode the type of the reference */ *p++ = (uint8_t)ref->type; @@ -988,8 +969,8 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, encode_size += H5R_ENCODE_HEADER_SIZE; /* Encode object token */ - H5R_ENCODE_VAR(H5R__encode_obj_token, &ref->info.obj.token, ref->token_size, - p, buf_size, encode_size, "Cannot encode object address"); + H5R_ENCODE_VAR(H5R__encode_obj_token, &ref->info.obj.token, ref->token_size, p, buf_size, encode_size, + "Cannot encode object address"); /** * TODO Encode VOL info @@ -999,25 +980,24 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, * - avoid duplicating VOL info on each reference * - must query terminal VOL connector to avoid passthrough confusion */ - if(flags & H5R_IS_EXTERNAL) + if (flags & H5R_IS_EXTERNAL) /* Encode file name */ - H5R_ENCODE(H5R__encode_string, filename, p, buf_size, encode_size, - "Cannot encode filename"); + H5R_ENCODE(H5R__encode_string, filename, p, buf_size, encode_size, "Cannot encode filename"); - switch(ref->type) { + switch (ref->type) { case H5R_OBJECT2: break; case H5R_DATASET_REGION2: /* Encode dataspace */ - H5R_ENCODE(H5R__encode_region, ref->info.reg.space, p, buf_size, - encode_size, "Cannot encode region"); + H5R_ENCODE(H5R__encode_region, ref->info.reg.space, p, buf_size, encode_size, + "Cannot encode region"); break; case H5R_ATTR: /* Encode attribute name */ - H5R_ENCODE(H5R__encode_string, ref->info.attr.name, p, buf_size, - encode_size, "Cannot encode attribute name"); + H5R_ENCODE(H5R__encode_string, ref->info.attr.name, p, buf_size, encode_size, + "Cannot encode attribute name"); break; case H5R_OBJECT1: @@ -1032,9 +1012,8 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") } /* end switch */ - H5R_LOG_DEBUG("Encoded reference, filename=%s, obj_addr=%s, encode size=%u", - ref->info.obj.filename, H5R__print_token(ref->info.obj.token), - encode_size); + H5R_LOG_DEBUG("Encoded reference, filename=%s, obj_addr=%s, encode size=%u", ref->info.obj.filename, + H5R__print_token(ref->info.obj.token), encode_size); *nalloc = encode_size; @@ -1042,7 +1021,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__encode() */ - /*------------------------------------------------------------------------- * Function: H5R__decode * @@ -1055,10 +1033,10 @@ done: herr_t H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref) { - const uint8_t *p = (const uint8_t *)buf; - size_t buf_size = 0, decode_size = 0; - uint8_t flags; - herr_t ret_value = SUCCEED; + const uint8_t *p = (const uint8_t *)buf; + size_t buf_size = 0, decode_size = 0; + uint8_t flags; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1068,12 +1046,12 @@ H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref) buf_size = *nbytes; /* Don't decode if buffer size isn't big enough */ - if(buf_size < H5R_ENCODE_HEADER_SIZE) + if (buf_size < H5R_ENCODE_HEADER_SIZE) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Set new reference */ ref->type = (int8_t)*p++; - if(ref->type <= H5R_BADTYPE || ref->type >= H5R_MAXTYPE) + if (ref->type <= H5R_BADTYPE || ref->type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") /* Set flags */ @@ -1083,30 +1061,30 @@ H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref) decode_size += H5R_ENCODE_HEADER_SIZE; /* Decode object token */ - H5R_DECODE_VAR(H5R__decode_obj_token, &ref->info.obj.token, &ref->token_size, - p, buf_size, decode_size, "Cannot decode object address"); + H5R_DECODE_VAR(H5R__decode_obj_token, &ref->info.obj.token, &ref->token_size, p, buf_size, decode_size, + "Cannot decode object address"); /* We do not need to store the filename if the reference is internal */ - if(flags & H5R_IS_EXTERNAL) { + if (flags & H5R_IS_EXTERNAL) { /* Decode file name */ - H5R_DECODE(H5R__decode_string, &ref->info.obj.filename, p, buf_size, - decode_size, "Cannot decode filename"); + H5R_DECODE(H5R__decode_string, &ref->info.obj.filename, p, buf_size, decode_size, + "Cannot decode filename"); } else ref->info.obj.filename = NULL; - switch(ref->type) { + switch (ref->type) { case H5R_OBJECT2: break; case H5R_DATASET_REGION2: /* Decode dataspace */ - H5R_DECODE(H5R__decode_region, &ref->info.reg.space, p, buf_size, - decode_size, "Cannot decode region"); + H5R_DECODE(H5R__decode_region, &ref->info.reg.space, p, buf_size, decode_size, + "Cannot decode region"); break; case H5R_ATTR: /* Decode attribute name */ - H5R_DECODE(H5R__decode_string, &ref->info.attr.name, p, buf_size, - decode_size, "Cannot decode attribute name"); + H5R_DECODE(H5R__decode_string, &ref->info.attr.name, p, buf_size, decode_size, + "Cannot decode attribute name"); break; case H5R_OBJECT1: case H5R_DATASET_REGION1: @@ -1125,9 +1103,8 @@ H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref) /* Set encoding size */ ref->encode_size = (uint32_t)decode_size; - H5R_LOG_DEBUG("Decoded reference, filename=%s, obj_addr=%s, encode size=%u", - ref->info.obj.filename, H5R__print_token(ref->info.obj.token), - ref->encode_size); + H5R_LOG_DEBUG("Decoded reference, filename=%s, obj_addr=%s, encode size=%u", ref->info.obj.filename, + H5R__print_token(ref->info.obj.token), ref->encode_size); *nbytes = decode_size; @@ -1135,7 +1112,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode() */ - /*------------------------------------------------------------------------- * Function: H5R__encode_obj_token * @@ -1146,8 +1122,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, - unsigned char *buf, size_t *nalloc) +H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc) { herr_t ret_value = SUCCEED; @@ -1156,7 +1131,7 @@ H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, HDassert(nalloc); /* Don't encode if buffer size isn't big enough or buffer is empty */ - if(buf && *nalloc >= token_size) { + if (buf && *nalloc >= token_size) { uint8_t *p = (uint8_t *)buf; /* Encode token size */ @@ -1170,7 +1145,6 @@ H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__encode_obj_token() */ - /*------------------------------------------------------------------------- * Function: H5R__decode_obj_token * @@ -1181,11 +1155,10 @@ H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, *------------------------------------------------------------------------- */ static herr_t -H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, - H5O_token_t *obj_token, uint8_t *token_size) +H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, uint8_t *token_size) { - const uint8_t *p = (const uint8_t *)buf; - herr_t ret_value = SUCCEED; + const uint8_t *p = (const uint8_t *)buf; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1195,12 +1168,12 @@ H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, HDassert(token_size); /* Don't decode if buffer size isn't big enough */ - if(*nbytes < H5_SIZEOF_UINT8_T) + if (*nbytes < H5_SIZEOF_UINT8_T) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Get token size */ *token_size = *p++; - if(*token_size > sizeof(H5O_token_t)) + if (*token_size > sizeof(H5O_token_t)) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Invalid token size (%u)", *token_size) /* Make sure that token is initialized */ @@ -1215,7 +1188,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_obj_token() */ - /*------------------------------------------------------------------------- * Function: H5R__encode_region * @@ -1228,9 +1200,9 @@ done: static herr_t H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc) { - uint8_t *p = NULL; /* Pointer to data to store */ - hssize_t buf_size = 0; - herr_t ret_value = SUCCEED; + uint8_t *p = NULL; /* Pointer to data to store */ + hssize_t buf_size = 0; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1238,11 +1210,12 @@ H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc) HDassert(nalloc); /* Get the amount of space required to serialize the selection */ - if((buf_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Cannot determine amount of space needed for serializing selection") + if ((buf_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, + "Cannot determine amount of space needed for serializing selection") /* Don't encode if buffer size isn't big enough or buffer is empty */ - if(buf && *nalloc >= ((size_t)buf_size + 2 * H5_SIZEOF_UINT32_T)) { + if (buf && *nalloc >= ((size_t)buf_size + 2 * H5_SIZEOF_UINT32_T)) { int rank; p = (uint8_t *)buf; @@ -1250,12 +1223,12 @@ H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc) UINT32ENCODE(p, (uint32_t)buf_size); /* Encode the extent rank */ - if((rank = H5S_get_simple_extent_ndims(space)) < 0) + if ((rank = H5S_get_simple_extent_ndims(space)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't get extent rank for selection") UINT32ENCODE(p, (uint32_t)rank); /* Serialize the selection */ - if(H5S_SELECT_SERIALIZE(space, (unsigned char **)&p) < 0) + if (H5S_SELECT_SERIALIZE(space, (unsigned char **)&p) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "can't serialize selection") } /* end if */ *nalloc = (size_t)buf_size + 2 * H5_SIZEOF_UINT32_T; @@ -1264,7 +1237,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__encode_region() */ - /*------------------------------------------------------------------------- * Function: H5R__decode_region * @@ -1277,11 +1249,11 @@ done: static herr_t H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr) { - const uint8_t *p = (const uint8_t *)buf; - size_t buf_size = 0; - unsigned rank; - H5S_t *space; - herr_t ret_value = SUCCEED; + const uint8_t *p = (const uint8_t *)buf; + size_t buf_size = 0; + unsigned rank; + H5S_t * space; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1290,7 +1262,7 @@ H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr) HDassert(space_ptr); /* Don't decode if buffer size isn't big enough */ - if(*nbytes < (2 * H5_SIZEOF_UINT32_T)) + if (*nbytes < (2 * H5_SIZEOF_UINT32_T)) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Decode the selection size */ @@ -1302,25 +1274,24 @@ H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr) buf_size += H5_SIZEOF_UINT32_T; /* Don't decode if buffer size isn't big enough */ - if(*nbytes < buf_size) + if (*nbytes < buf_size) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Deserialize the selection (dataspaces need the extent rank information) */ - if(NULL == (space = H5S_create(H5S_SIMPLE))) + if (NULL == (space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") - if(H5S_set_extent_simple(space, rank, NULL, NULL) < 0) + if (H5S_set_extent_simple(space, rank, NULL, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set extent rank for selection") - if(H5S_SELECT_DESERIALIZE(&space, &p) < 0) + if (H5S_SELECT_DESERIALIZE(&space, &p) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "can't deserialize selection") - *nbytes = buf_size; + *nbytes = buf_size; *space_ptr = space; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_region() */ - /*------------------------------------------------------------------------- * Function: H5R__encode_string * @@ -1343,13 +1314,13 @@ H5R__encode_string(const char *string, unsigned char *buf, size_t *nalloc) /* Get the amount of space required to serialize the string */ string_len = HDstrlen(string); - if(string_len > H5R_MAX_STRING_LEN) + if (string_len > H5R_MAX_STRING_LEN) HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, FAIL, "string too long") /* Compute buffer size, allow for the attribute name length and object address */ buf_size = string_len + sizeof(uint16_t); - if(buf && *nalloc >= buf_size) { + if (buf && *nalloc >= buf_size) { uint8_t *p = (uint8_t *)buf; /* Serialize information for string length into the buffer */ UINT16ENCODE(p, string_len); @@ -1362,7 +1333,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__encode_string() */ - /*------------------------------------------------------------------------- * Function: H5R__decode_string * @@ -1376,9 +1346,9 @@ static herr_t H5R__decode_string(const unsigned char *buf, size_t *nbytes, char **string_ptr) { const uint8_t *p = (const uint8_t *)buf; - size_t string_len; - char *string = NULL; - herr_t ret_value = SUCCEED; + size_t string_len; + char * string = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1387,7 +1357,7 @@ H5R__decode_string(const unsigned char *buf, size_t *nbytes, char **string_ptr) HDassert(string_ptr); /* Don't decode if buffer size isn't big enough */ - if(*nbytes < sizeof(uint16_t)) + if (*nbytes < sizeof(uint16_t)) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Get the string length */ @@ -1395,21 +1365,20 @@ H5R__decode_string(const unsigned char *buf, size_t *nbytes, char **string_ptr) HDassert(string_len <= H5R_MAX_STRING_LEN); /* Allocate the string */ - if(NULL == (string = (char *)H5MM_malloc(string_len + 1))) + if (NULL == (string = (char *)H5MM_malloc(string_len + 1))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTALLOC, FAIL, "Cannot allocate string") - /* Copy the string */ - H5MM_memcpy(string, p, string_len); - string[string_len] = '\0'; + /* Copy the string */ + H5MM_memcpy(string, p, string_len); + string[string_len] = '\0'; - *string_ptr = string; - *nbytes = sizeof(uint16_t) + string_len; + *string_ptr = string; + *nbytes = sizeof(uint16_t) + string_len; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_string() */ - /*------------------------------------------------------------------------- * Function: H5R__encode_heap * @@ -1420,8 +1389,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, - const unsigned char *data, size_t data_size) +H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, const unsigned char *data, size_t data_size) { size_t buf_size; herr_t ret_value = SUCCEED; @@ -1432,12 +1400,12 @@ H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, HDassert(nalloc); buf_size = H5HG_HEAP_ID_SIZE(f); - if(buf && *nalloc >= buf_size) { - H5HG_t hobjid; + if (buf && *nalloc >= buf_size) { + H5HG_t hobjid; uint8_t *p = (uint8_t *)buf; /* Write the reference information to disk (allocates space also) */ - if(H5HG_insert(f, data_size, data, &hobjid) < 0) + if (H5HG_insert(f, data_size, data, &hobjid) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to write reference information") /* Encode the heap information */ @@ -1450,7 +1418,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__encode_heap() */ - /*------------------------------------------------------------------------- * Function: H5R__decode_heap * @@ -1461,13 +1428,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, - unsigned char **data_ptr, size_t *data_size) +H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, + size_t *data_size) { const uint8_t *p = (const uint8_t *)buf; - H5HG_t hobjid; - size_t buf_size; - herr_t ret_value = SUCCEED; + H5HG_t hobjid; + size_t buf_size; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1478,17 +1445,17 @@ H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, buf_size = H5HG_HEAP_ID_SIZE(f); /* Don't decode if buffer size isn't big enough */ - if(*nbytes < buf_size) + if (*nbytes < buf_size) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Get the heap information */ H5F_addr_decode(f, &p, &(hobjid.addr)); - if(!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) + if (!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") UINT32DECODE(p, hobjid.idx); /* Read the information from disk */ - if(NULL == (*data_ptr = (unsigned char *)H5HG_read(f, &hobjid, (void *)*data_ptr, data_size))) + if (NULL == (*data_ptr = (unsigned char *)H5HG_read(f, &hobjid, (void *)*data_ptr, data_size))) HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read reference data") *nbytes = buf_size; @@ -1497,7 +1464,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_heap() */ - /*------------------------------------------------------------------------- * Function: H5R__free_heap * @@ -1510,10 +1476,10 @@ done: herr_t H5R__free_heap(H5F_t *f, const unsigned char *buf, size_t nbytes) { - H5HG_t hobjid; + H5HG_t hobjid; const uint8_t *p = (const uint8_t *)buf; - size_t buf_size; - herr_t ret_value = SUCCEED; + size_t buf_size; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1522,19 +1488,19 @@ H5R__free_heap(H5F_t *f, const unsigned char *buf, size_t nbytes) buf_size = H5HG_HEAP_ID_SIZE(f); /* Don't decode if buffer size isn't big enough */ - if(nbytes < buf_size) + if (nbytes < buf_size) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Get the heap information */ H5F_addr_decode(f, &p, &(hobjid.addr)); - if(!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) + if (!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") UINT32DECODE(p, hobjid.idx); /* Free heap object */ - if(hobjid.addr > 0) { + if (hobjid.addr > 0) { /* Free heap object */ - if(H5HG_remove(f, &hobjid) < 0) + if (H5HG_remove(f, &hobjid) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") } /* end if */ @@ -1542,7 +1508,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__free_heap() */ - /*------------------------------------------------------------------------- * Function: H5R__decode_token_compat * @@ -1554,21 +1519,21 @@ done: */ herr_t H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type, - const unsigned char *buf, H5O_token_t *obj_token) + const unsigned char *buf, H5O_token_t *obj_token) { - hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ - H5VL_object_t *vol_obj_file = NULL; - H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - herr_t ret_value = SUCCEED; + hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ + H5VL_object_t * vol_obj_file = NULL; + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(vol_obj, &is_native) < 0) + if (H5VL_object_is_native(vol_obj, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1577,44 +1542,44 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref #endif /* NDEBUG */ /* Get the file for the object */ - if((file_id = H5F_get_file_id(vol_obj, type, FALSE)) < 0) + if ((file_id = H5F_get_file_id(vol_obj, type, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Retrieve VOL object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get container info */ - if(H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &cont_info) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") - if(ref_type == H5R_OBJECT1) { + if (ref_type == H5R_OBJECT1) { size_t buf_size = H5R_OBJ_REF_BUF_SIZE; /* Get object address */ - if(H5R__decode_token_obj_compat(buf, &buf_size, obj_token, cont_info.token_size) < 0) + if (H5R__decode_token_obj_compat(buf, &buf_size, obj_token, cont_info.token_size) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object token") } /* end if */ else { size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; - H5F_t *f = NULL; + H5F_t *f = NULL; /* Retrieve file from VOL object */ - if(NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) + if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Get object address */ - if(H5R__decode_token_region_compat(f, buf, &buf_size, obj_token, cont_info.token_size, NULL) < 0) + if (H5R__decode_token_region_compat(f, buf, &buf_size, obj_token, cont_info.token_size, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address") } /* end else */ done: - if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_token_compat() */ - /*------------------------------------------------------------------------- * Function: H5R__encode_token_obj_compat * @@ -1625,8 +1590,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, - unsigned char *buf, size_t *nalloc) +H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, + size_t *nalloc) { herr_t ret_value = SUCCEED; @@ -1637,7 +1602,7 @@ H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, HDassert(nalloc); /* Don't encode if buffer size isn't big enough or buffer is empty */ - if(buf && *nalloc >= token_size) + if (buf && *nalloc >= token_size) H5MM_memcpy(buf, obj_token, token_size); *nalloc = token_size; @@ -1645,7 +1610,6 @@ H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__encode_token_obj_compat() */ - /*------------------------------------------------------------------------- * Function: H5R__decode_token_obj_compat * @@ -1656,8 +1620,8 @@ H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, *------------------------------------------------------------------------- */ herr_t -H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, - H5O_token_t *obj_token, size_t token_size) +H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, + size_t token_size) { herr_t ret_value = SUCCEED; @@ -1669,7 +1633,7 @@ H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, HDassert(token_size); /* Don't decode if buffer size isn't big enough */ - if(*nbytes < token_size) + if (*nbytes < token_size) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") H5MM_memcpy(obj_token, buf, token_size); @@ -1680,7 +1644,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5R__decode_token_obj_compat() */ - /*------------------------------------------------------------------------- * Function: H5R__encode_token_region_compat * @@ -1692,12 +1655,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, - size_t token_size, H5S_t *space, unsigned char *buf, size_t *nalloc) +H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size, H5S_t *space, + unsigned char *buf, size_t *nalloc) { - size_t buf_size; - unsigned char *data = NULL; - herr_t ret_value = SUCCEED; + size_t buf_size; + unsigned char *data = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1708,11 +1671,11 @@ H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, HDassert(nalloc); /* Get required buffer size */ - if(H5R__encode_heap(f, NULL, &buf_size, NULL, (size_t)0) < 0) + if (H5R__encode_heap(f, NULL, &buf_size, NULL, (size_t)0) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(buf && *nalloc >= buf_size) { - ssize_t data_size; + if (buf && *nalloc >= buf_size) { + ssize_t data_size; uint8_t *p; /* Pass the correct encoding version for the selection depending on the @@ -1725,15 +1688,16 @@ H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, HDmemset(buf, 0, buf_size); /* Get the amount of space required to serialize the selection */ - if((data_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection") + if ((data_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, + "Invalid amount of space for serializing selection") /* Increase buffer size to allow for the dataset token */ data_size += (hssize_t)token_size; /* Allocate the space to store the serialized information */ H5_CHECK_OVERFLOW(data_size, hssize_t, size_t); - if(NULL == (data = (uint8_t *)H5MM_malloc((size_t)data_size))) + if (NULL == (data = (uint8_t *)H5MM_malloc((size_t)data_size))) HGOTO_ERROR(H5E_REFERENCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Serialize information for dataset OID into heap buffer */ @@ -1742,11 +1706,11 @@ H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, p += token_size; /* Serialize the selection into heap buffer */ - if(H5S_SELECT_SERIALIZE(space, &p) < 0) + if (H5S_SELECT_SERIALIZE(space, &p) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection") /* Write to heap */ - if(H5R__encode_heap(f, buf, nalloc, data, (size_t)data_size) < 0) + if (H5R__encode_heap(f, buf, nalloc, data, (size_t)data_size) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") } *nalloc = buf_size; @@ -1756,7 +1720,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5R__encode_token_region_compat() */ - /*------------------------------------------------------------------------- * Function: H5R__decode_token_region_compat * @@ -1768,16 +1731,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, - size_t *nbytes, H5O_token_t *obj_token, size_t token_size, - H5S_t **space_ptr) +H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, + size_t token_size, H5S_t **space_ptr) { - unsigned char *data = NULL; - H5O_token_t token = { 0 }; - size_t data_size; + unsigned char *data = NULL; + H5O_token_t token = {0}; + size_t data_size; const uint8_t *p; - H5S_t *space = NULL; - herr_t ret_value = SUCCEED; + H5S_t * space = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1787,7 +1749,7 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, HDassert(token_size); /* Read from heap */ - if(H5R__decode_heap(f, buf, nbytes, &data, &data_size) < 0) + if (H5R__decode_heap(f, buf, nbytes, &data, &data_size) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get object address */ @@ -1795,37 +1757,37 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, H5MM_memcpy(&token, p, token_size); p += token_size; - if(space_ptr) { + if (space_ptr) { H5O_loc_t oloc; /* Object location */ /* Initialize the object location */ H5O_loc_reset(&oloc); oloc.file = f; - if(H5VL_native_token_to_addr(f, H5I_FILE, token, &oloc.addr) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + if (H5VL_native_token_to_addr(f, H5I_FILE, token, &oloc.addr) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") /* Open and copy the dataset's dataspace */ - if(NULL == (space = H5S_read(&oloc))) + if (NULL == (space = H5S_read(&oloc))) HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "not found") /* Unserialize the selection */ - if(H5S_SELECT_DESERIALIZE(&space, &p) < 0) + if (H5S_SELECT_DESERIALIZE(&space, &p) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "can't deserialize selection") *space_ptr = space; } - if(obj_token) + if (obj_token) H5MM_memcpy(obj_token, &token, sizeof(H5O_token_t)); done: H5MM_free(data); - if(ret_value < 0) { - if(space && H5S_close(space) < 0) + if (ret_value < 0) { + if (space && H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") } FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_token_region_compat() */ - diff --git a/src/H5Rmodule.h b/src/H5Rmodule.h index 678a668..e4f5313 100644 --- a/src/H5Rmodule.h +++ b/src/H5Rmodule.h @@ -21,9 +21,8 @@ * reporting macros. */ #define H5R_MODULE -#define H5_MY_PKG H5R -#define H5_MY_PKG_ERR H5E_REFERENCE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5R +#define H5_MY_PKG_ERR H5E_REFERENCE +#define H5_MY_PKG_INIT YES #endif /* _H5Rmodule_H */ - diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index 36cf805..a132873 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -26,25 +26,24 @@ #include "H5Rprivate.h" /* Other private headers needed by this file */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ - +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ /**************************/ /* Package Private Macros */ /**************************/ /* Encode flags */ -#define H5R_IS_EXTERNAL 0x1 /* Set when encoding reference to external file */ +#define H5R_IS_EXTERNAL 0x1 /* Set when encoding reference to external file */ /* Macros for convenience */ -#define H5R_REF_FILENAME(x) ((x)->info.obj.filename) -#define H5R_REF_ATTRNAME(x) ((x)->info.attr.name) +#define H5R_REF_FILENAME(x) ((x)->info.obj.filename) +#define H5R_REF_ATTRNAME(x) ((x)->info.attr.name) /* Header size */ -#define H5R_ENCODE_HEADER_SIZE (2 * H5_SIZEOF_UINT8_T) +#define H5R_ENCODE_HEADER_SIZE (2 * H5_SIZEOF_UINT8_T) /****************************/ /* Package Private Typedefs */ @@ -52,79 +51,87 @@ /* Object reference */ typedef struct H5R_ref_priv_obj_t { - H5O_token_t token; /* Object token */ - char *filename; /* File name */ + H5O_token_t token; /* Object token */ + char * filename; /* File name */ } H5R_ref_priv_obj_t; /* Region reference */ typedef struct H5R_ref_priv_reg_t { - H5R_ref_priv_obj_t obj; /* Object reference */ - H5S_t *space; /* Selection */ + H5R_ref_priv_obj_t obj; /* Object reference */ + H5S_t * space; /* Selection */ } H5R_ref_priv_reg_t; /* Attribute reference */ typedef struct H5R_ref_priv_attr_t { - H5R_ref_priv_obj_t obj; /* Object reference */ - char *name; /* Attribute name */ + H5R_ref_priv_obj_t obj; /* Object reference */ + char * name; /* Attribute name */ } H5R_ref_priv_attr_t; /* Generic reference type (keep it cache aligned) */ typedef struct H5R_ref_priv_t { union { - H5R_ref_priv_obj_t obj;/* Object reference */ - H5R_ref_priv_reg_t reg;/* Region reference */ - H5R_ref_priv_attr_t attr;/* Attribute Reference */ + H5R_ref_priv_obj_t obj; /* Object reference */ + H5R_ref_priv_reg_t reg; /* Region reference */ + H5R_ref_priv_attr_t attr; /* Attribute Reference */ } info; - hid_t loc_id; /* Cached location identifier */ - uint32_t encode_size; /* Cached encoding size */ - int8_t type; /* Reference type */ - uint8_t token_size; /* Cached token size */ - hbool_t app_ref; /* App ref on loc_id */ + hid_t loc_id; /* Cached location identifier */ + uint32_t encode_size; /* Cached encoding size */ + int8_t type; /* Reference type */ + uint8_t token_size; /* Cached token size */ + hbool_t app_ref; /* App ref on loc_id */ } H5R_ref_priv_t; /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5R__create_object(const H5O_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref); -H5_DLL herr_t H5R__create_region(const H5O_token_t *obj_token, size_t token_size, H5S_t *space, H5R_ref_priv_t *ref); -H5_DLL herr_t H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, const char *attr_name, H5R_ref_priv_t *ref); -H5_DLL herr_t H5R__destroy(H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__create_object(const H5O_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__create_region(const H5O_token_t *obj_token, size_t token_size, H5S_t *space, + H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, const char *attr_name, + H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__destroy(H5R_ref_priv_t *ref); -H5_DLL herr_t H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref); -H5_DLL hid_t H5R__get_loc_id(const H5R_ref_priv_t *ref); -H5_DLL hid_t H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id); +H5_DLL herr_t H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref); +H5_DLL hid_t H5R__get_loc_id(const H5R_ref_priv_t *ref); +H5_DLL hid_t H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id); -H5_DLL H5R_type_t H5R__get_type(const H5R_ref_priv_t *ref); -H5_DLL htri_t H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2); -H5_DLL herr_t H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref); +H5_DLL H5R_type_t H5R__get_type(const H5R_ref_priv_t *ref); +H5_DLL htri_t H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2); +H5_DLL herr_t H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref); -H5_DLL herr_t H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, size_t *token_size); -H5_DLL herr_t H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, size_t token_size); -H5_DLL herr_t H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space); +H5_DLL herr_t H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, size_t *token_size); +H5_DLL herr_t H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, size_t token_size); +H5_DLL herr_t H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space); -H5_DLL ssize_t H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size); -H5_DLL ssize_t H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size); +H5_DLL ssize_t H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size); +H5_DLL ssize_t H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size); -H5_DLL herr_t H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, size_t *nalloc, unsigned flags); -H5_DLL herr_t H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, size_t *nalloc, + unsigned flags); +H5_DLL herr_t H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref); /* Native HDF5 specific routines */ -H5_DLL herr_t H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, const unsigned char *data, size_t data_size); -H5_DLL herr_t H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, size_t *data_size); -H5_DLL herr_t H5R__free_heap(H5F_t *f, const unsigned char *buf, size_t nbytes); +H5_DLL herr_t H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, const unsigned char *data, + size_t data_size); +H5_DLL herr_t H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, + size_t *data_size); +H5_DLL herr_t H5R__free_heap(H5F_t *f, const unsigned char *buf, size_t nbytes); -H5_DLL herr_t H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type, const unsigned char *buf, H5O_token_t *obj_token); +H5_DLL herr_t H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type, + const unsigned char *buf, H5O_token_t *obj_token); -H5_DLL herr_t H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc); -H5_DLL herr_t H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, size_t token_size); +H5_DLL herr_t H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, + unsigned char *buf, size_t *nalloc); +H5_DLL herr_t H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, + size_t token_size); -H5_DLL herr_t H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size, H5S_t *space, unsigned char *buf, size_t *nalloc); -H5_DLL herr_t H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, size_t token_size, H5S_t **space_ptr); +H5_DLL herr_t H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size, + H5S_t *space, unsigned char *buf, size_t *nalloc); +H5_DLL herr_t H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, + H5O_token_t *obj_token, size_t token_size, H5S_t **space_ptr); #endif /* _H5Rpkg_H */ - diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h index 870deaf..98a8352 100644 --- a/src/H5Rprivate.h +++ b/src/H5Rprivate.h @@ -25,22 +25,18 @@ /* Library Private Macros */ /**************************/ -#define H5R_ENCODE_VERSION 0x1 /* Version for encoding references */ - +#define H5R_ENCODE_VERSION 0x1 /* Version for encoding references */ /****************************/ /* Library Private Typedefs */ /****************************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ -#endif /* _H5Rprivate_H */ - +#endif /* _H5Rprivate_H */ diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index 13d82d7..6b30b85 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -27,14 +27,14 @@ /*****************/ /* Deprecated reference buffer sizes that are kept for backward compatibility */ -#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t) -#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t) + 4) +#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t) +#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t) + 4) /* Default reference buffer size. * Note! Be careful with the sizes of the references because they should really * depend on the run-time values in the file. */ -#define H5R_REF_BUF_SIZE (64) +#define H5R_REF_BUF_SIZE (64) /*******************/ /* Public Typedefs */ @@ -46,8 +46,8 @@ * the datatype message header. */ typedef enum { - H5R_BADTYPE = (-1), /* Invalid reference type */ - H5R_OBJECT1 = 0, /* Backward compatibility (object) */ + H5R_BADTYPE = (-1), /* Invalid reference type */ + H5R_OBJECT1 = 0, /* Backward compatibility (object) */ H5R_DATASET_REGION1 = 1, /* Backward compatibility (region) */ H5R_OBJECT2 = 2, /* Object reference */ H5R_DATASET_REGION2 = 3, /* Region reference */ @@ -81,8 +81,8 @@ typedef struct { */ typedef struct { union { - uint8_t __data[H5R_REF_BUF_SIZE]; /* opaque data */ - int64_t align; /* ensures alignment */ + uint8_t __data[H5R_REF_BUF_SIZE]; /* opaque data */ + int64_t align; /* ensures alignment */ } u; } H5R_ref_t; @@ -90,7 +90,6 @@ typedef struct { /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -100,28 +99,30 @@ extern "C" { #endif /* Constructors */ -H5_DLL herr_t H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_ptr); -H5_DLL herr_t H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, H5R_ref_t *ref_ptr); -H5_DLL herr_t H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl_id, H5R_ref_t *ref_ptr); -H5_DLL herr_t H5Rdestroy(H5R_ref_t *ref_ptr); +H5_DLL herr_t H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_ptr); +H5_DLL herr_t H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, + H5R_ref_t *ref_ptr); +H5_DLL herr_t H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl_id, + H5R_ref_t *ref_ptr); +H5_DLL herr_t H5Rdestroy(H5R_ref_t *ref_ptr); /* Info */ -H5_DLL H5R_type_t H5Rget_type(const H5R_ref_t *ref_ptr); -H5_DLL htri_t H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr); -H5_DLL herr_t H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr); +H5_DLL H5R_type_t H5Rget_type(const H5R_ref_t *ref_ptr); +H5_DLL htri_t H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr); +H5_DLL herr_t H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr); /* Dereference */ -H5_DLL hid_t H5Ropen_object(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); -H5_DLL hid_t H5Ropen_region(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); -H5_DLL hid_t H5Ropen_attr(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id); +H5_DLL hid_t H5Ropen_object(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); +H5_DLL hid_t H5Ropen_region(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); +H5_DLL hid_t H5Ropen_attr(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id); /* Get type */ -H5_DLL herr_t H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type); +H5_DLL herr_t H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type); /* Get name */ -H5_DLL ssize_t H5Rget_file_name(const H5R_ref_t *ref_ptr, char *buf, size_t size); -H5_DLL ssize_t H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size); -H5_DLL ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *buf, size_t size); +H5_DLL ssize_t H5Rget_file_name(const H5R_ref_t *ref_ptr, char *buf, size_t size); +H5_DLL ssize_t H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size); +H5_DLL ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *buf, size_t size); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -131,25 +132,25 @@ H5_DLL ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *buf, size_t siz /* Macros */ /* Versions for compatibility */ -#define H5R_OBJECT H5R_OBJECT1 -#define H5R_DATASET_REGION H5R_DATASET_REGION1 +#define H5R_OBJECT H5R_OBJECT1 +#define H5R_DATASET_REGION H5R_DATASET_REGION1 /* Function prototypes */ #ifndef H5_NO_DEPRECATED_SYMBOLS H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref); -H5_DLL hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref); +H5_DLL hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref); #endif /* H5_NO_DEPRECATED_SYMBOLS */ -H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id); -H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type); -H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref); -H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref); +H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id); +H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type); +H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref); +H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref); H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref, char *name, size_t size); #ifdef __cplusplus } #endif -#endif /* _H5Rpublic_H */ +#endif /* _H5Rpublic_H */ diff --git a/src/H5S.c b/src/H5S.c index 7e48076..1e5f8b4 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -15,47 +15,41 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Spkg.h" /* Dataspaces */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Spkg.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ /* Version of dataspace encoding */ -#define H5S_ENCODE_VERSION 0 - +#define H5S_ENCODE_VERSION 0 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ static htri_t H5S__is_simple(const H5S_t *sdim); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -65,11 +59,11 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Format version bounds for dataspace */ const unsigned H5O_sdspace_ver_bounds[] = { - H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */ - H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V110 */ - H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V112 */ - H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V110 */ + H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V112 */ + H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /* Declare a free list to manage the H5S_extent_t struct */ @@ -81,33 +75,29 @@ H5FL_DEFINE(H5S_t); /* Declare a free list to manage the array's of hsize_t's */ H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK); - /*******************/ /* Local Variables */ /*******************/ /* Dataspace ID class */ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ - H5I_DATASPACE, /* ID class value */ - 0, /* Class flags */ - 2, /* # of reserved IDs for class */ - (H5I_free_t)H5S_close /* Callback routine for closing objects of this class */ + H5I_DATASPACE, /* ID class value */ + 0, /* Class flags */ + 2, /* # of reserved IDs for class */ + (H5I_free_t)H5S_close /* Callback routine for closing objects of this class */ }}; /* Dataspace selection iterator ID class */ static const H5I_class_t H5I_SPACE_SEL_ITER_CLS[1] = {{ - H5I_SPACE_SEL_ITER, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5S_sel_iter_close /* Callback routine for closing objects of this class */ + H5I_SPACE_SEL_ITER, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5S_sel_iter_close /* Callback routine for closing objects of this class */ }}; - /* Flag indicating "top" of interface has been initialized */ static hbool_t H5S_top_package_initialize_s = FALSE; - - /*-------------------------------------------------------------------------- NAME H5S__init_package -- Initialize interface-specific information @@ -121,17 +111,18 @@ DESCRIPTION herr_t H5S__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the dataspace IDs */ - if(H5I_register_type(H5I_DATASPACE_CLS) < 0) + if (H5I_register_type(H5I_DATASPACE_CLS) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace ID class") /* Initialize the atom group for the dataspace selction iterator IDs */ - if(H5I_register_type(H5I_SPACE_SEL_ITER_CLS) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace selection iterator ID class") + if (H5I_register_type(H5I_SPACE_SEL_ITER_CLS) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to initialize dataspace selection iterator ID class") /* Mark "top" of interface as initialized, too */ H5S_top_package_initialize_s = TRUE; @@ -140,7 +131,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__init_package() */ - /*-------------------------------------------------------------------------- NAME H5S_top_term_package @@ -162,30 +152,29 @@ done: int H5S_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5S_top_package_initialize_s) { - if(H5I_nmembers(H5I_DATASPACE) > 0) { + if (H5S_top_package_initialize_s) { + if (H5I_nmembers(H5I_DATASPACE) > 0) { (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ - if(H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { + if (H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark "top" of interface as closed */ - if(0 == n) + if (0 == n) H5S_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5S_top_term_package() */ - /*-------------------------------------------------------------------------- NAME H5S_term_package @@ -209,11 +198,11 @@ H5S_top_term_package(void) int H5S_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_DATASPACE)); HDassert(0 == H5I_nmembers(H5I_SPACE_SEL_ITER)); @@ -226,15 +215,13 @@ H5S_term_package(void) n += (H5I_dec_type_ref(H5I_SPACE_SEL_ITER) > 0); /* Mark interface as closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5S_term_package() */ - - /*-------------------------------------------------------------------------- NAME H5S_get_validiated_dataspace @@ -257,26 +244,26 @@ H5S_term_package(void) herr_t H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(space); /* Check for invalid ID */ - if(space_id < 0) + if (space_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid space_id (ID cannot be a negative number)") /* No special dataspace struct for H5S_ALL */ - if(H5S_ALL == space_id) + if (H5S_ALL == space_id) *space = NULL; else { /* Get the dataspace pointer */ - if(NULL == (*space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (*space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "space_id is not a dataspace ID") /* Check for valid selection */ - if(H5S_SELECT_VALID(*space) != TRUE) + if (H5S_SELECT_VALID(*space) != TRUE) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection + offset not within extent") } @@ -284,7 +271,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_validated_dataspace() */ - /*-------------------------------------------------------------------------- NAME H5S_create @@ -306,25 +292,25 @@ done: H5S_t * H5S_create(H5S_class_t type) { - H5S_t *new_ds = NULL; /* New dataspace created */ + H5S_t *new_ds = NULL; /* New dataspace created */ H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Create a new dataspace */ - if(NULL == (new_ds = H5FL_CALLOC(H5S_t))) + if (NULL == (new_ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Initialize default dataspace state */ new_ds->extent.type = type; - if(type == H5S_NULL) + if (type == H5S_NULL) new_ds->extent.version = H5O_SDSPACE_VERSION_2; else new_ds->extent.version = H5O_SDSPACE_VERSION_1; new_ds->extent.rank = 0; new_ds->extent.size = new_ds->extent.max = NULL; - switch(type) { + switch (type) { case H5S_SCALAR: new_ds->extent.nelem = 1; break; @@ -341,28 +327,27 @@ H5S_create(H5S_class_t type) } /* end switch */ /* Start with "all" selection */ - if(H5S_select_all(new_ds, FALSE) < 0) + if (H5S_select_all(new_ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Reset common selection info pointer */ new_ds->select.sel_info.hslab = NULL; /* Reset "shared" info on extent */ - if(H5O_msg_reset_share(H5O_SDSPACE_ID, &(new_ds->extent.sh_loc)) < 0) + if (H5O_msg_reset_share(H5O_SDSPACE_ID, &(new_ds->extent.sh_loc)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRESET, NULL, "unable to reset shared component info") /* Set return value */ ret_value = new_ds; done: - if(ret_value == NULL) - if(new_ds && H5S_close(new_ds) < 0) + if (ret_value == NULL) + if (new_ds && H5S_close(new_ds) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_create() */ - /*-------------------------------------------------------------------------- NAME H5Screate @@ -384,32 +369,31 @@ done: hid_t H5Screate(H5S_class_t type) { - H5S_t *new_ds = NULL; /* New dataspace structure */ - hid_t ret_value; /* Return value */ + H5S_t *new_ds = NULL; /* New dataspace structure */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "Sc", type); /* Check args */ - if(type <= H5S_NO_CLASS || type > H5S_NULL) /* don't allow complex dataspace yet */ + if (type <= H5S_NO_CLASS || type > H5S_NULL) /* don't allow complex dataspace yet */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace type") - if(NULL == (new_ds = H5S_create(type))) + if (NULL == (new_ds = H5S_create(type))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, new_ds, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, new_ds, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: - if(ret_value < 0) - if(new_ds && H5S_close(new_ds) < 0) + if (ret_value < 0) + if (new_ds && H5S_close(new_ds) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Screate() */ - /*------------------------------------------------------------------------- * Function: H5S__extent_release * @@ -430,20 +414,19 @@ H5S__extent_release(H5S_extent_t *extent) HDassert(extent); /* Release extent */ - if(extent->type == H5S_SIMPLE) { - if(extent->size) + if (extent->type == H5S_SIMPLE) { + if (extent->size) extent->size = H5FL_ARR_FREE(hsize_t, extent->size); - if(extent->max) + if (extent->max) extent->max = H5FL_ARR_FREE(hsize_t, extent->max); } /* end if */ - extent->rank = 0; + extent->rank = 0; extent->nelem = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__extent_release() */ - /*------------------------------------------------------------------------- * Function: H5S_close * @@ -459,18 +442,18 @@ H5S__extent_release(H5S_extent_t *extent) herr_t H5S_close(H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(ds); /* Release selection (this should come before the extent release) */ - if(H5S_SELECT_RELEASE(ds) < 0) + if (H5S_SELECT_RELEASE(ds) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace selection") /* Release extent */ - if(H5S__extent_release(&ds->extent) < 0) + if (H5S__extent_release(&ds->extent) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent") done: @@ -484,7 +467,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_close() */ - /*------------------------------------------------------------------------- * Function: H5Sclose * @@ -500,24 +482,23 @@ done: herr_t H5Sclose(hid_t space_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", space_id); /* Check args */ - if(NULL == H5I_object_verify(space_id, H5I_DATASPACE)) + if (NULL == H5I_object_verify(space_id, H5I_DATASPACE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* When the reference count reaches zero the resources are freed */ - if(H5I_dec_app_ref(space_id) < 0) + if (H5I_dec_app_ref(space_id) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing id") done: FUNC_LEAVE_API(ret_value) } /* end H5Sclose() */ - /*------------------------------------------------------------------------- * Function: H5Scopy * @@ -535,34 +516,33 @@ done: hid_t H5Scopy(hid_t space_id) { - H5S_t *src = NULL; - H5S_t *dst = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *src = NULL; + H5S_t *dst = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", space_id); /* Check args */ - if(NULL == (src = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (src = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Copy */ - if(NULL == (dst = H5S_copy(src, FALSE, TRUE))) + if (NULL == (dst = H5S_copy(src, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy dataspace") /* Atomize */ - if((ret_value = H5I_register (H5I_DATASPACE, dst, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, dst, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: - if(ret_value < 0) - if(dst && H5S_close(dst) < 0) + if (ret_value < 0) + if (dst && H5S_close(dst) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Scopy() */ - /*------------------------------------------------------------------------- * Function: H5Sextent_copy * @@ -576,30 +556,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Sextent_copy(hid_t dst_id,hid_t src_id) +H5Sextent_copy(hid_t dst_id, hid_t src_id) { - H5S_t *src; - H5S_t *dst; - herr_t ret_value = SUCCEED; + H5S_t *src; + H5S_t *dst; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", dst_id, src_id); /* Check args */ - if(NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) + if (NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) + if (NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Copy */ - if(H5S_extent_copy(dst, src) < 0) + if (H5S_extent_copy(dst, src) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") done: FUNC_LEAVE_API(ret_value) } /* end H5Sextent_copy() */ - /*------------------------------------------------------------------------- * Function: H5S_extent_copy * @@ -615,7 +594,7 @@ done: herr_t H5S_extent_copy(H5S_t *dst, const H5S_t *src) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -623,20 +602,19 @@ H5S_extent_copy(H5S_t *dst, const H5S_t *src) HDassert(src); /* Copy extent */ - if(H5S__extent_copy_real(&(dst->extent), &(src->extent), TRUE) < 0) + if (H5S__extent_copy_real(&(dst->extent), &(src->extent), TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") /* If the selection is 'all', update the number of elements selected in the * destination space */ - if(H5S_SEL_ALL == H5S_GET_SELECT_TYPE(dst)) - if(H5S_select_all(dst, FALSE) < 0) + if (H5S_SEL_ALL == H5S_GET_SELECT_TYPE(dst)) + if (H5S_select_all(dst, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_copy() */ - /*------------------------------------------------------------------------- * Function: H5S__extent_copy_real * @@ -653,38 +631,38 @@ herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max) { unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Release destination extent before we copy over it */ - if(H5S__extent_release(dst) < 0) + if (H5S__extent_release(dst) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent") /* Copy the regular fields */ - dst->type = src->type; + dst->type = src->type; dst->version = src->version; - dst->nelem = src->nelem; - dst->rank = src->rank; + dst->nelem = src->nelem; + dst->rank = src->rank; switch (src->type) { case H5S_NULL: case H5S_SCALAR: dst->size = NULL; - dst->max = NULL; + dst->max = NULL; break; case H5S_SIMPLE: - if(src->size) { + if (src->size) { dst->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)src->rank); - for(u = 0; u < src->rank; u++) + for (u = 0; u < src->rank; u++) dst->size[u] = src->size[u]; } /* end if */ else dst->size = NULL; - if(copy_max && src->max) { + if (copy_max && src->max) { dst->max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)src->rank); - for(u = 0; u < src->rank; u++) + for (u = 0; u < src->rank; u++) dst->max[u] = src->max[u]; } /* end if */ else @@ -698,14 +676,13 @@ H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_m } /* end switch */ /* Copy the shared object info */ - if(H5O_set_shared(&(dst->sh_loc), &(src->sh_loc)) < 0) + if (H5O_set_shared(&(dst->sh_loc), &(src->sh_loc)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy shared information") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__extent_copy_real() */ - /*------------------------------------------------------------------------- * Function: H5S_copy * @@ -728,34 +705,33 @@ done: H5S_t * H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max) { - H5S_t *dst = NULL; - H5S_t *ret_value = NULL; /* Return value */ + H5S_t *dst = NULL; + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - if(NULL == (dst = H5FL_CALLOC(H5S_t))) + if (NULL == (dst = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the source dataspace's extent */ - if(H5S__extent_copy_real(&(dst->extent), &(src->extent), copy_max) < 0) + if (H5S__extent_copy_real(&(dst->extent), &(src->extent), copy_max) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent") /* Copy the source dataspace's selection */ - if(H5S_select_copy(dst, src, share_selection) < 0) + if (H5S_select_copy(dst, src, share_selection) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy select") /* Set the return value */ ret_value = dst; done: - if(NULL == ret_value) - if(dst) + if (NULL == ret_value) + if (dst) dst = H5FL_FREE(H5S_t, dst); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_copy() */ - /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_npoints * @@ -777,7 +753,7 @@ done: hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds) { - hssize_t ret_value = -1; /* Return value */ + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) @@ -791,7 +767,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_npoints() */ - /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_npoints * @@ -808,14 +783,14 @@ done: hssize_t H5Sget_simple_extent_npoints(hid_t space_id) { - H5S_t *ds; - hssize_t ret_value; + H5S_t * ds; + hssize_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", space_id); /* Check args */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") ret_value = (hssize_t)H5S_GET_EXTENT_NPOINTS(ds); @@ -824,7 +799,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_npoints() */ - /*------------------------------------------------------------------------- * Function: H5S_get_npoints_max * @@ -846,15 +820,15 @@ done: hsize_t H5S_get_npoints_max(const H5S_t *ds) { - unsigned u; - hsize_t ret_value = 0; /* Return value */ + unsigned u; + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* check args */ HDassert(ds); - switch(H5S_GET_EXTENT_TYPE(ds)) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: ret_value = 0; break; @@ -864,9 +838,9 @@ H5S_get_npoints_max(const H5S_t *ds) break; case H5S_SIMPLE: - if(ds->extent.max) { - for(ret_value = 1, u = 0; u < ds->extent.rank; u++) { - if(H5S_UNLIMITED == ds->extent.max[u]) { + if (ds->extent.max) { + for (ret_value = 1, u = 0; u < ds->extent.rank; u++) { + if (H5S_UNLIMITED == ds->extent.max[u]) { ret_value = HSIZET_MAX; break; } @@ -875,7 +849,7 @@ H5S_get_npoints_max(const H5S_t *ds) } } else - for(ret_value = 1, u = 0; u < ds->extent.rank; u++) + for (ret_value = 1, u = 0; u < ds->extent.rank; u++) ret_value *= ds->extent.size[u]; break; @@ -889,7 +863,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_npoints_max() */ - /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_ndims * @@ -906,14 +879,14 @@ done: int H5Sget_simple_extent_ndims(hid_t space_id) { - H5S_t *ds; - int ret_value = -1; + H5S_t *ds; + int ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", space_id); /* Check args */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a dataspace") ret_value = (int)H5S_GET_EXTENT_NDIMS(ds); @@ -922,7 +895,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_ndims() */ - /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_ndims * @@ -945,14 +917,14 @@ done: int H5S_get_simple_extent_ndims(const H5S_t *ds) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(ds); - switch(H5S_GET_EXTENT_TYPE(ds)) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: case H5S_SCALAR: case H5S_SIMPLE: @@ -969,7 +941,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_ndims() */ - /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_dims * @@ -987,16 +958,16 @@ done: *------------------------------------------------------------------------- */ int -H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, hsize_t maxdims[]/*out*/) +H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[] /*out*/, hsize_t maxdims[] /*out*/) { - H5S_t *ds; - int ret_value = -1; + H5S_t *ds; + int ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE3("Is", "ixx", space_id, dims, maxdims); /* Check args */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a dataspace") ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims); @@ -1005,7 +976,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_dims() */ - /*------------------------------------------------------------------------- * Function: H5S_extent_get_dims * @@ -1023,15 +993,15 @@ done: int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) { - int i; /* Local index variable */ - int ret_value = -1; /* Return value */ + int i; /* Local index variable */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(ext); - switch(ext->type) { + switch (ext->type) { case H5S_NULL: case H5S_SCALAR: ret_value = 0; @@ -1039,16 +1009,16 @@ H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) case H5S_SIMPLE: ret_value = (int)ext->rank; - for(i = 0; i < ret_value; i++) { - if(dims) + for (i = 0; i < ret_value; i++) { + if (dims) dims[i] = ext->size[i]; - if(max_dims) { - if(ext->max) + if (max_dims) { + if (ext->max) max_dims[i] = ext->max[i]; else max_dims[i] = ext->size[i]; } /* end if */ - } /* end for */ + } /* end for */ break; case H5S_NO_CLASS: @@ -1061,7 +1031,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_get_dims() */ - /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_dims * @@ -1079,7 +1048,7 @@ done: int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1087,14 +1056,13 @@ H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) HDassert(ds); /* Get dims for extent */ - if((ret_value = H5S_extent_get_dims(&ds->extent, dims, max_dims)) < 0) + if ((ret_value = H5S_extent_get_dims(&ds->extent, dims, max_dims)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_dims() */ - /*------------------------------------------------------------------------- * Function: H5S_write * @@ -1111,7 +1079,7 @@ done: herr_t H5S_write(H5F_t *f, H5O_t *oh, unsigned update_flags, H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1121,14 +1089,13 @@ H5S_write(H5F_t *f, H5O_t *oh, unsigned update_flags, H5S_t *ds) HDassert(H5S_GET_EXTENT_TYPE(ds) >= 0); /* Write the current dataspace extent to the dataspace message */ - if(H5O_msg_write_oh(f, oh, H5O_SDSPACE_ID, 0, update_flags, &(ds->extent)) < 0) + if (H5O_msg_write_oh(f, oh, H5O_SDSPACE_ID, 0, update_flags, &(ds->extent)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple dataspace message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_write() */ - /*------------------------------------------------------------------------- * Function: H5S_append * @@ -1144,7 +1111,7 @@ done: herr_t H5S_append(H5F_t *f, H5O_t *oh, H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1154,14 +1121,13 @@ H5S_append(H5F_t *f, H5O_t *oh, H5S_t *ds) HDassert(H5S_GET_EXTENT_TYPE(ds) >= 0); /* Add the dataspace message to the object header */ - if(H5O_msg_append_oh(f, oh, H5O_SDSPACE_ID, 0, 0, &(ds->extent)) < 0) + if (H5O_msg_append_oh(f, oh, H5O_SDSPACE_ID, 0, 0, &(ds->extent)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't add simple dataspace message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_append() */ - /*------------------------------------------------------------------------- * Function: H5S_read * @@ -1179,36 +1145,35 @@ done: H5S_t * H5S_read(const H5O_loc_t *loc) { - H5S_t *ds = NULL; /* Dataspace to return */ - H5S_t *ret_value = NULL; /* Return value */ + H5S_t *ds = NULL; /* Dataspace to return */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* check args */ HDassert(loc); - if(NULL == (ds = H5FL_CALLOC(H5S_t))) + if (NULL == (ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == H5O_msg_read(loc, H5O_SDSPACE_ID, &(ds->extent))) + if (NULL == H5O_msg_read(loc, H5O_SDSPACE_ID, &(ds->extent))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to load dataspace info from dataset header") /* Default to entire dataspace being selected */ - if(H5S_select_all(ds, FALSE) < 0) + if (H5S_select_all(ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Set the value for successful return */ ret_value = ds; done: - if(ret_value == NULL) - if(ds != NULL) + if (ret_value == NULL) + if (ds != NULL) ds = H5FL_FREE(H5S_t, ds); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_read() */ - /*-------------------------------------------------------------------------- NAME H5S__is_simple @@ -1226,7 +1191,7 @@ done: static htri_t H5S__is_simple(const H5S_t *sdim) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1234,13 +1199,12 @@ H5S__is_simple(const H5S_t *sdim) HDassert(sdim); /* H5S_NULL shouldn't be simple dataspace */ - ret_value = (H5S_GET_EXTENT_TYPE(sdim) == H5S_SIMPLE || - H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE; + ret_value = + (H5S_GET_EXTENT_TYPE(sdim) == H5S_SIMPLE || H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__is_simple() */ - /*-------------------------------------------------------------------------- NAME H5Sis_simple @@ -1258,14 +1222,14 @@ H5S__is_simple(const H5S_t *sdim) htri_t H5Sis_simple(hid_t space_id) { - H5S_t *space; /* Dataspace to check */ - htri_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to check */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", space_id); /* Check args and all the boring stuff. */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") ret_value = H5S__is_simple(space); @@ -1274,7 +1238,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sis_simple() */ - /*-------------------------------------------------------------------------- NAME H5Sset_extent_simple @@ -1302,44 +1265,44 @@ done: --------------------------------------------------------------------------*/ herr_t -H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], - const hsize_t max[/*rank*/]) +H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], const hsize_t max[/*rank*/]) { - H5S_t *space; /* Dataspace to modify */ - int u; /* Local counting variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space; /* Dataspace to modify */ + int u; /* Local counting variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iIs*[a1]h*[a1]h", space_id, rank, dims, max); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") - if(rank > 0 && dims == NULL) + if (rank > 0 && dims == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified") - if(rank < 0 || rank > H5S_MAX_RANK) + if (rank < 0 || rank > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank") - if(dims) - for(u = 0; u < rank; u++) - if(H5S_UNLIMITED == dims[u]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "current dimension must have a specific size, not H5S_UNLIMITED") - if(max != NULL) { - if(dims == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maximum dimension specified, but no current dimensions specified") - for(u = 0; u < rank; u++) - if(max[u] != H5S_UNLIMITED && max[u] < dims[u]) + if (dims) + for (u = 0; u < rank; u++) + if (H5S_UNLIMITED == dims[u]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "current dimension must have a specific size, not H5S_UNLIMITED") + if (max != NULL) { + if (dims == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "maximum dimension specified, but no current dimensions specified") + for (u = 0; u < rank; u++) + if (max[u] != H5S_UNLIMITED && max[u] < dims[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid maximum dimension size") } /* Do it */ - if(H5S_set_extent_simple(space, (unsigned)rank, dims, max) < 0) + if (H5S_set_extent_simple(space, (unsigned)rank, dims, max) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent") done: FUNC_LEAVE_API(ret_value) } /* end H5Sset_extent_simple() */ - /*------------------------------------------------------------------------- * Function: H5S_set_extent_simple * @@ -1353,11 +1316,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, - const hsize_t *max) +H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1365,16 +1327,16 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, HDassert(rank <= H5S_MAX_RANK); /* shift out of the previous state to a "simple" dataspace. */ - if(H5S__extent_release(&space->extent) < 0) + if (H5S__extent_release(&space->extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "failed to release previous dataspace extent") - if(rank == 0) { /* scalar variable */ - space->extent.type = H5S_SCALAR; + if (rank == 0) { /* scalar variable */ + space->extent.type = H5S_SCALAR; space->extent.nelem = 1; - space->extent.rank = 0; /* set to scalar rank */ - } /* end if */ + space->extent.rank = 0; /* set to scalar rank */ + } /* end if */ else { - hsize_t nelem; /* Number of elements in extent */ + hsize_t nelem; /* Number of elements in extent */ space->extent.type = H5S_SIMPLE; @@ -1383,7 +1345,7 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, space->extent.size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)rank); /* Copy the dimensions & compute the number of elements in the extent */ - for(u = 0, nelem = 1; dims && (u < space->extent.rank); u++) { + for (u = 0, nelem = 1; dims && (u < space->extent.rank); u++) { space->extent.size[u] = dims[u]; nelem *= dims[u]; } /* end for */ @@ -1392,10 +1354,10 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, /* Copy the maximum dimensions if specified. Otherwise, the maximal dimensions are the * same as the dimension */ space->extent.max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)rank); - if(max != NULL) + if (max != NULL) H5MM_memcpy(space->extent.max, max, sizeof(hsize_t) * rank); else - for(u = 0; dims && (u < space->extent.rank); u++) + for (u = 0; dims && (u < space->extent.rank); u++) space->extent.max[u] = dims[u]; } /* end else */ @@ -1406,15 +1368,14 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, space->select.offset_changed = FALSE; /* If the selection is 'all', update the number of elements selected */ - if(H5S_GET_SELECT_TYPE(space) == H5S_SEL_ALL) - if(H5S_select_all(space, FALSE) < 0) + if (H5S_GET_SELECT_TYPE(space) == H5S_SEL_ALL) + if (H5S_select_all(space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent_simple() */ - /*------------------------------------------------------------------------- * Function: H5Screate_simple * @@ -1439,50 +1400,50 @@ done: hid_t H5Screate_simple(int rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]) { - H5S_t *space = NULL; - int i; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *space = NULL; + int i; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "Is*[a0]h*[a0]h", rank, dims, maxdims); /* Check arguments */ - if(rank < 0) + if (rank < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dimensionality cannot be negative") - if(rank > H5S_MAX_RANK) + if (rank > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dimensionality is too large") /* We allow users to use this function to create scalar or null dataspace. * Check DIMS isn't set when the RANK is 0. */ - if(!dims && rank != 0) + if (!dims && rank != 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dataspace information") /* Check whether the current dimensions are valid */ - for(i = 0; i < rank; i++) { - if(H5S_UNLIMITED == dims[i]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "current dimension must have a specific size, not H5S_UNLIMITED") - if(maxdims && H5S_UNLIMITED != maxdims[i] && maxdims[i]extent))) + if (NULL == (ds = H5FL_CALLOC(H5S_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for dataspace conversion path table") + if (NULL == H5O_msg_copy(H5O_SDSPACE_ID, extent, &(ds->extent))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy object") - if(H5S__extent_release(extent) < 0) + if (H5S__extent_release(extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, NULL, "can't release previous dataspace") extent = H5FL_FREE(H5S_extent_t, extent); /* Initialize to "all" selection. Deserialization relies on valid existing selection. */ - if(H5S_select_all(ds, FALSE) < 0) + if (H5S_select_all(ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Decode the select part of dataspace. I believe this part always exists. */ *p = pp; - if(H5S_SELECT_DESERIALIZE(&ds, p) < 0) + if (H5S_SELECT_DESERIALIZE(&ds, p) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode space selection") /* Set return value */ @@ -1749,13 +1707,12 @@ H5S_decode(const unsigned char **p) done: /* Release fake file structure */ - if(f && H5F_fake_free(f) < 0) + if (f && H5F_fake_free(f) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release fake file struct") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_decode() */ - /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_type * @@ -1777,7 +1734,7 @@ done: H5S_class_t H5S_get_simple_extent_type(const H5S_t *space) { - H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ + H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ FUNC_ENTER_NOAPI(H5S_NO_CLASS) @@ -1789,7 +1746,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_type() */ - /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_type * @@ -1807,14 +1763,14 @@ done: H5S_class_t H5Sget_simple_extent_type(hid_t sid) { - H5S_t *space; - H5S_class_t ret_value; /* Return value */ + H5S_t * space; + H5S_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5S_NO_CLASS) H5TRACE1("Sc", "i", sid); /* Check arguments */ - if(NULL == (space = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace") ret_value = H5S_GET_EXTENT_TYPE(space); @@ -1823,7 +1779,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_type() */ - /*-------------------------------------------------------------------------- NAME H5Sset_extent_none @@ -1841,18 +1796,18 @@ done: herr_t H5Sset_extent_none(hid_t space_id) { - H5S_t *space; /* Dataspace to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space; /* Dataspace to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", space_id); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") /* Clear the previous extent from the dataspace */ - if(H5S__extent_release(&space->extent) < 0) + if (H5S__extent_release(&space->extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace") space->extent.type = H5S_NULL; @@ -1861,7 +1816,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sset_extent_none() */ - /*------------------------------------------------------------------------- * Function: H5S_set_extent * @@ -1878,7 +1832,7 @@ htri_t H5S_set_extent(H5S_t *space, const hsize_t *size) { unsigned u; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1887,27 +1841,27 @@ H5S_set_extent(H5S_t *space, const hsize_t *size) HDassert(size); /* Verify that the dimensions being changed are allowed to change */ - for(u = 0; u < space->extent.rank; u++) - if(space->extent.size[u] != size[u]) { + for (u = 0; u < space->extent.rank; u++) + if (space->extent.size[u] != size[u]) { /* Check for invalid dimension size modification */ - if(space->extent.max && H5S_UNLIMITED != space->extent.max[u] && - space->extent.max[u] < size[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "dimension cannot exceed the existing maximal size (new: %llu max: %llu)", (unsigned long long)size[u], (unsigned long long)space->extent.max[u]) + if (space->extent.max && H5S_UNLIMITED != space->extent.max[u] && space->extent.max[u] < size[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "dimension cannot exceed the existing maximal size (new: %llu max: %llu)", + (unsigned long long)size[u], (unsigned long long)space->extent.max[u]) /* Indicate that dimension size can be modified */ ret_value = TRUE; } /* end if */ /* Update dimension size(s) */ - if(ret_value) - if(H5S_set_extent_real(space, size) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "failed to change dimension size(s)") + if (ret_value) + if (H5S_set_extent_real(space, size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "failed to change dimension size(s)") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent() */ - /*------------------------------------------------------------------------- * Function: H5S_has_extent * @@ -1926,13 +1880,13 @@ done: H5_ATTR_PURE hbool_t H5S_has_extent(const H5S_t *ds) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(ds); - if(0 == ds->extent.rank && 0 == ds->extent.nelem && H5S_NULL != ds->extent.type) + if (0 == ds->extent.rank && 0 == ds->extent.nelem && H5S_NULL != ds->extent.type) ret_value = FALSE; else ret_value = TRUE; @@ -1940,7 +1894,6 @@ H5S_has_extent(const H5S_t *ds) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_has_extent() */ - /*------------------------------------------------------------------------- * Function: H5S_set_extent_real * @@ -1957,9 +1910,9 @@ H5S_has_extent(const H5S_t *ds) herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size) { - hsize_t nelem; /* Number of elements in extent */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nelem; /* Number of elements in extent */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1968,26 +1921,25 @@ H5S_set_extent_real(H5S_t *space, const hsize_t *size) HDassert(size); /* Change the dataspace size & re-compute the number of elements in the extent */ - for(u = 0, nelem = 1; u < space->extent.rank; u++ ) { + for (u = 0, nelem = 1; u < space->extent.rank; u++) { space->extent.size[u] = size[u]; nelem *= size[u]; } /* end for */ space->extent.nelem = nelem; /* If the selection is 'all', update the number of elements selected */ - if(H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space)) - if(H5S_select_all(space, FALSE) < 0) + if (H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space)) + if (H5S_select_all(space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Mark the dataspace as no longer shared if it was before */ - if(H5O_msg_reset_share(H5O_SDSPACE_ID, space) < 0) + if (H5O_msg_reset_share(H5O_SDSPACE_ID, space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRESET, FAIL, "can't stop sharing dataspace") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent_real() */ - /*------------------------------------------------------------------------- * Function: H5Sextent_equal * @@ -2005,27 +1957,26 @@ done: htri_t H5Sextent_equal(hid_t space1_id, hid_t space2_id) { - const H5S_t *ds1; /* Dataspaces to compare */ - const H5S_t *ds2; - htri_t ret_value; + const H5S_t *ds1; /* Dataspaces to compare */ + const H5S_t *ds2; + htri_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", space1_id, space2_id); /* check args */ - if(NULL == (ds1 = (const H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE)) || - NULL == (ds2 = (const H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + if (NULL == (ds1 = (const H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE)) || + NULL == (ds2 = (const H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Check dataspaces for extent's equality */ - if((ret_value = H5S_extent_equal(ds1, ds2)) < 0) + if ((ret_value = H5S_extent_equal(ds1, ds2)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "dataspace comparison failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Sextent_equal() */ - /*-------------------------------------------------------------------------- NAME H5S_extent_equal @@ -2042,8 +1993,8 @@ done: H5_ATTR_PURE htri_t H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) { - unsigned u; /* Local index variable */ - htri_t ret_value = TRUE; /* Return value */ + unsigned u; /* Local index variable */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2052,41 +2003,39 @@ H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) HDassert(ds2); /* Make certain the dataspaces are the same type */ - if(ds1->extent.type != ds2->extent.type) + if (ds1->extent.type != ds2->extent.type) HGOTO_DONE(FALSE) /* Make certain the dataspaces are the same rank */ - if(ds1->extent.rank != ds2->extent.rank) + if (ds1->extent.rank != ds2->extent.rank) HGOTO_DONE(FALSE) /* Make certain the dataspaces' current dimensions are the same size */ - if(ds1->extent.rank > 0) { + if (ds1->extent.rank > 0) { HDassert(ds1->extent.size); HDassert(ds2->extent.size); - for(u = 0; u < ds1->extent.rank; u++) - if(ds1->extent.size[u] != ds2->extent.size[u]) + for (u = 0; u < ds1->extent.rank; u++) + if (ds1->extent.size[u] != ds2->extent.size[u]) HGOTO_DONE(FALSE) } /* end if */ /* Make certain the dataspaces' maximum dimensions are the same size */ - if(ds1->extent.rank > 0) { + if (ds1->extent.rank > 0) { /* Check for no maximum dimensions on dataspaces */ - if(ds1->extent.max != NULL && ds2->extent.max != NULL) { - for(u = 0; u < ds1->extent.rank; u++) - if(ds1->extent.max[u] != ds2->extent.max[u]) + if (ds1->extent.max != NULL && ds2->extent.max != NULL) { + for (u = 0; u < ds1->extent.rank; u++) + if (ds1->extent.max[u] != ds2->extent.max[u]) HGOTO_DONE(FALSE) } /* end if */ - else - if((ds1->extent.max == NULL && ds2->extent.max != NULL) || - (ds1->extent.max != NULL && ds2->extent.max == NULL)) - HGOTO_DONE(FALSE) + else if ((ds1->extent.max == NULL && ds2->extent.max != NULL) || + (ds1->extent.max != NULL && ds2->extent.max == NULL)) + HGOTO_DONE(FALSE) } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_equal() */ - /*------------------------------------------------------------------------- * Function: H5S_extent_nelem * @@ -2112,7 +2061,6 @@ H5S_extent_nelem(const H5S_extent_t *ext) FUNC_LEAVE_NOAPI(ext->nelem) } /* end H5S_extent_nelem() */ - /*------------------------------------------------------------------------- * Function: H5S_set_version * @@ -2127,8 +2075,8 @@ H5S_extent_nelem(const H5S_extent_t *ext) herr_t H5S_set_version(H5F_t *f, H5S_t *ds) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2140,7 +2088,7 @@ H5S_set_version(H5F_t *f, H5S_t *ds) version = MAX(ds->extent.version, H5O_sdspace_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "Dataspace version out of bounds") /* Set the message version */ @@ -2149,4 +2097,3 @@ H5S_set_version(H5F_t *f, H5S_t *ds) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_version() */ - diff --git a/src/H5SL.c b/src/H5SL.c index ff8edb8..f35cb3b 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -57,521 +57,516 @@ * */ -#include "H5SLmodule.h" /* This source code file is part of the H5SL module */ - +#include "H5SLmodule.h" /* This source code file is part of the H5SL module */ /* Private headers needed */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5SLprivate.h" /* Skip list routines */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5SLprivate.h" /* Skip list routines */ /* Local Macros */ /* Define the code template for searches for the "OP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_SEARCH_FOUND(SLIST, X, I) \ -{ \ - HDassert(!X->removed); \ - HGOTO_DONE(X->item); \ -} /* end block */ +#define H5SL_LOCATE_SEARCH_FOUND(SLIST, X, I) \ + { \ + HDassert(!X->removed); \ + HGOTO_DONE(X->item); \ + } /* end block */ /* Define the code template for deferred removals for the "OP" in the * H5SL_LOCATE macro */ -#define H5SL_LOCATE_SEARCH_DEFER_REMOVE_FOUND(SLIST, X, I) \ -{ \ - HDassert(!X->removed); \ - X->removed = TRUE; \ - HGOTO_DONE(X->item); \ -} /* end block */ +#define H5SL_LOCATE_SEARCH_DEFER_REMOVE_FOUND(SLIST, X, I) \ + { \ + HDassert(!X->removed); \ + X->removed = TRUE; \ + HGOTO_DONE(X->item); \ + } /* end block */ /* Define the code template for finds for the "OP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_FIND_FOUND(SLIST, X, I) \ -{ \ - HDassert(!X->removed); \ - HGOTO_DONE(X); \ -} /* end block */ - +#define H5SL_LOCATE_FIND_FOUND(SLIST, X, I) \ + { \ + HDassert(!X->removed); \ + HGOTO_DONE(X); \ + } /* end block */ /* Define a code template for comparing scalar keys for the "CMP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_SCALAR_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - (*(TYPE *)((PNODE)->key) < *(TYPE *)PKEY) +#define H5SL_LOCATE_SCALAR_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) (*(TYPE *)((PNODE)->key) < *(TYPE *)PKEY) /* Define a code template for comparing string keys for the "CMP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_STRING_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - (((PNODE)->hashval == HASHVAL) ? \ - (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) < 0) : \ - ((PNODE)->hashval < HASHVAL)) +#define H5SL_LOCATE_STRING_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + (((PNODE)->hashval == HASHVAL) ? (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) < 0) \ + : ((PNODE)->hashval < HASHVAL)) /* Define a code template for comparing H5_obj_t keys for the "CMP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_OBJ_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - ((((TYPE *)((PNODE)->key))->fileno == ((TYPE *)PKEY)->fileno) \ - ? (((TYPE *)((PNODE)->key))->addr < ((TYPE *)PKEY)->addr) \ - : (((TYPE *)((PNODE)->key))->fileno < ((TYPE *)PKEY)->fileno)) +#define H5SL_LOCATE_OBJ_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + ((((TYPE *)((PNODE)->key))->fileno == ((TYPE *)PKEY)->fileno) \ + ? (((TYPE *)((PNODE)->key))->addr < ((TYPE *)PKEY)->addr) \ + : (((TYPE *)((PNODE)->key))->fileno < ((TYPE *)PKEY)->fileno)) /* Define a code template for comparing generic keys for the "CMP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_GENERIC_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - ((SLIST)->cmp((TYPE *)((PNODE)->key), (TYPE *)PKEY) < 0) - +#define H5SL_LOCATE_GENERIC_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + ((SLIST)->cmp((TYPE *)((PNODE)->key), (TYPE *)PKEY) < 0) /* Define a code template for comparing scalar keys for the "EQ" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_SCALAR_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - (*(TYPE *)((PNODE)->key) == *(TYPE *)PKEY) +#define H5SL_LOCATE_SCALAR_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) (*(TYPE *)((PNODE)->key) == *(TYPE *)PKEY) /* Define a code template for comparing string keys for the "EQ" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_STRING_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - (((PNODE)->hashval == HASHVAL) && (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) == 0)) +#define H5SL_LOCATE_STRING_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + (((PNODE)->hashval == HASHVAL) && (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) == 0)) /* Define a code template for comparing H5_obj_t keys for the "EQ" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_OBJ_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - ((((TYPE *)((PNODE)->key))->fileno == ((TYPE *)PKEY)->fileno) && (((TYPE *)((PNODE)->key))->addr == ((TYPE *)PKEY)->addr)) +#define H5SL_LOCATE_OBJ_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + ((((TYPE *)((PNODE)->key))->fileno == ((TYPE *)PKEY)->fileno) && \ + (((TYPE *)((PNODE)->key))->addr == ((TYPE *)PKEY)->addr)) /* Define a code template for comparing generic keys for the "EQ" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_GENERIC_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - ((SLIST)->cmp((TYPE *)((PNODE)->key), (TYPE *)PKEY) == 0) +#define H5SL_LOCATE_GENERIC_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + ((SLIST)->cmp((TYPE *)((PNODE)->key), (TYPE *)PKEY) == 0) - -/* Define a code template for initializing the hash value for scalar keys for the "HASHINIT" in the H5SL_LOCATE macro */ +/* Define a code template for initializing the hash value for scalar keys for the "HASHINIT" in the + * H5SL_LOCATE macro */ #define H5SL_LOCATE_SCALAR_HASHINIT(KEY, HASHVAL) -/* Define a code template for initializing the hash value for string keys for the "HASHINIT" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_STRING_HASHINIT(KEY, HASHVAL) \ - HASHVAL = H5_hash_string((const char *)KEY); +/* Define a code template for initializing the hash value for string keys for the "HASHINIT" in the + * H5SL_LOCATE macro */ +#define H5SL_LOCATE_STRING_HASHINIT(KEY, HASHVAL) HASHVAL = H5_hash_string((const char *)KEY); -/* Define a code template for initializing the hash value for H5_obj_t keys for the "HASHINIT" in the H5SL_LOCATE macro */ +/* Define a code template for initializing the hash value for H5_obj_t keys for the "HASHINIT" in the + * H5SL_LOCATE macro */ #define H5SL_LOCATE_OBJ_HASHINIT(KEY, HASHVAL) -/* Define a code template for initializing the hash value for generic keys for the "HASHINIT" in the H5SL_LOCATE macro */ +/* Define a code template for initializing the hash value for generic keys for the "HASHINIT" in the + * H5SL_LOCATE macro */ #define H5SL_LOCATE_GENERIC_HASHINIT(KEY, HASHVAL) - /* Macro used to find node for operation, if all keys are valid */ -#define H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ -{ \ - int _i; /* Local index variable */ \ - unsigned _count; /* Num nodes searched at this height */ \ - \ - H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ - for(_i = (int)SLIST->curr_level; _i >= 0; _i--) { \ - _count = 0; \ - while(_count < 3 && X->forward[_i] && \ - H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL) ) { \ - X = X->forward[_i]; \ - _count++; \ - } /* end while */ \ - } /* end for */ \ - X = X->forward[0]; \ - if(X != NULL && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(SLIST, TYPE, X, KEY, HASHVAL) ) { \ - /* What to do when a node is found */ \ - H5_GLUE3(H5SL_LOCATE_,OP,_FOUND)(SLIST, X, _i) \ - } /* end if */ \ -} +#define H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + { \ + int _i; /* Local index variable */ \ + unsigned _count; /* Num nodes searched at this height */ \ + \ + H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ + (KEY, HASHVAL) for (_i = (int)SLIST->curr_level; _i >= 0; _i--) \ + { \ + _count = 0; \ + while (_count < 3 && X->forward[_i] && \ + H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) { \ + X = X->forward[_i]; \ + _count++; \ + } /* end while */ \ + } /* end for */ \ + X = X->forward[0]; \ + if (X != NULL && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, X, KEY, HASHVAL)) { \ + /* What to do when a node is found */ \ + H5_GLUE3(H5SL_LOCATE_, OP, _FOUND)(SLIST, X, _i) \ + } /* end if */ \ + } /* Macro used to find node for operation, if there may be "removed" nodes in the * list (whose keys cannot be read) */ -#define H5SL_LOCATE_SAFE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ -{ \ - int _i; /* Local index variable */ \ - H5SL_node_t *_low = X; \ - H5SL_node_t *_high = NULL; \ - \ - H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ - for(_i = (int)SLIST->curr_level; _i >= 0; _i--) { \ - X = _low->forward[_i]; \ - while(X != _high) { \ - if(!X->removed) { \ - if(H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, X, KEY, HASHVAL)) \ - _low = X; \ - else \ - break; \ - } /* end if */ \ - X = X->forward[_i]; \ - } /* end while */ \ - _high = X; \ - if(X != NULL && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(SLIST, TYPE, X, KEY, HASHVAL) ) { \ - /* What to do when a node is found */ \ - H5_GLUE3(H5SL_LOCATE_,OP,_FOUND)(SLIST, X, _i) \ - break; \ - } /* end if */ \ - } /* end for */ \ -} +#define H5SL_LOCATE_SAFE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + { \ + int _i; /* Local index variable */ \ + H5SL_node_t *_low = X; \ + H5SL_node_t *_high = NULL; \ + \ + H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ + (KEY, HASHVAL) for (_i = (int)SLIST->curr_level; _i >= 0; _i--) \ + { \ + X = _low->forward[_i]; \ + while (X != _high) { \ + if (!X->removed) { \ + if (H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X, KEY, HASHVAL)) \ + _low = X; \ + else \ + break; \ + } /* end if */ \ + X = X->forward[_i]; \ + } /* end while */ \ + _high = X; \ + if (X != NULL && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, X, KEY, HASHVAL)) { \ + /* What to do when a node is found */ \ + H5_GLUE3(H5SL_LOCATE_, OP, _FOUND)(SLIST, X, _i) break; \ + } /* end if */ \ + } /* end for */ \ + } /* Macro used to find node for operation */ -#define H5SL_LOCATE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ -{ \ - if((SLIST)->safe_iterating) \ - H5SL_LOCATE_SAFE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - else \ - H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ -} - +#define H5SL_LOCATE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + { \ + if ((SLIST)->safe_iterating) \ + H5SL_LOCATE_SAFE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + else \ + H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + } /* Macro used to grow a node by 1. Does not update pointers. LVL is the current * level of X. Does not update LVL but does update X->lvl. */ -#define H5SL_GROW(X, LVL, ERR) \ -{ \ - /* Check if we need to increase allocation of forward pointers */ \ - if(LVL + 1 >= 1u << X->log_nalloc) { \ - H5SL_node_t **_tmp; \ - HDassert(LVL + 1 == 1u << X->log_nalloc); \ - /* Double the amount of allocated space */ \ - X->log_nalloc++; \ - \ - /* Check if we need to create a new factory */ \ - if(X->log_nalloc >= H5SL_fac_nused_g) { \ - HDassert(X->log_nalloc == H5SL_fac_nused_g); \ - \ - /* Check if we need to allocate space for the factory pointer*/ \ - if(H5SL_fac_nused_g >= H5SL_fac_nalloc_g) { \ - HDassert(H5SL_fac_nused_g == H5SL_fac_nalloc_g); \ - /* Double the size of the array of factory pointers */ \ - H5SL_fac_nalloc_g *= 2; \ - if(NULL == (H5SL_fac_g = (H5FL_fac_head_t **)H5MM_realloc( \ - (void *)H5SL_fac_g, H5SL_fac_nalloc_g \ - * sizeof(H5FL_fac_head_t *)))) \ - HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \ - } /* end if */ \ - \ - /* Create the new factory */ \ - H5SL_fac_g[H5SL_fac_nused_g] = H5FL_fac_init((1u << H5SL_fac_nused_g) * sizeof(H5SL_node_t *)); \ - H5SL_fac_nused_g++; \ - } /* end if */ \ - \ - /* Allocate space for new forward pointers */ \ - if(NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ - HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \ - H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL + 1) * sizeof(H5SL_node_t *)); \ - X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc-1], (void *)X->forward); \ - X->forward = _tmp; \ - } /* end if */ \ - \ - X->level++; \ -} - +#define H5SL_GROW(X, LVL, ERR) \ + { \ + /* Check if we need to increase allocation of forward pointers */ \ + if (LVL + 1 >= 1u << X->log_nalloc) { \ + H5SL_node_t **_tmp; \ + HDassert(LVL + 1 == 1u << X->log_nalloc); \ + /* Double the amount of allocated space */ \ + X->log_nalloc++; \ + \ + /* Check if we need to create a new factory */ \ + if (X->log_nalloc >= H5SL_fac_nused_g) { \ + HDassert(X->log_nalloc == H5SL_fac_nused_g); \ + \ + /* Check if we need to allocate space for the factory pointer*/ \ + if (H5SL_fac_nused_g >= H5SL_fac_nalloc_g) { \ + HDassert(H5SL_fac_nused_g == H5SL_fac_nalloc_g); \ + /* Double the size of the array of factory pointers */ \ + H5SL_fac_nalloc_g *= 2; \ + if (NULL == (H5SL_fac_g = (H5FL_fac_head_t **)H5MM_realloc( \ + (void *)H5SL_fac_g, H5SL_fac_nalloc_g * sizeof(H5FL_fac_head_t *)))) \ + HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \ + } /* end if */ \ + \ + /* Create the new factory */ \ + H5SL_fac_g[H5SL_fac_nused_g] = \ + H5FL_fac_init((1u << H5SL_fac_nused_g) * sizeof(H5SL_node_t *)); \ + H5SL_fac_nused_g++; \ + } /* end if */ \ + \ + /* Allocate space for new forward pointers */ \ + if (NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ + HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \ + H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL + 1) * sizeof(H5SL_node_t *)); \ + X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc - 1], (void *)X->forward); \ + X->forward = _tmp; \ + } /* end if */ \ + \ + X->level++; \ + } /* Macro used to shrink a node by 1. Does not update pointers. LVL is the * current level of X. Does not update LVL but does update X->level. */ -#define H5SL_SHRINK(X, LVL) \ -{ \ - /* Check if we can reduce the allocation of forward pointers */ \ - if(LVL <= 1u << (X->log_nalloc - 1)) { \ - H5SL_node_t **_tmp; \ - HDassert(LVL == 1u << (X->log_nalloc - 1)); \ - X->log_nalloc--; \ - \ - /* Allocate space for new forward pointers */ \ - if(NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ - HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") \ - H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL) * sizeof(H5SL_node_t *)); \ - X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc+1], (void *)X->forward); \ - X->forward = _tmp; \ - } /* end if */ \ - \ - X->level--; \ -} - +#define H5SL_SHRINK(X, LVL) \ + { \ + /* Check if we can reduce the allocation of forward pointers */ \ + if (LVL <= 1u << (X->log_nalloc - 1)) { \ + H5SL_node_t **_tmp; \ + HDassert(LVL == 1u << (X->log_nalloc - 1)); \ + X->log_nalloc--; \ + \ + /* Allocate space for new forward pointers */ \ + if (NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") \ + H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL) * sizeof(H5SL_node_t *)); \ + X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc + 1], (void *)X->forward); \ + X->forward = _tmp; \ + } /* end if */ \ + \ + X->level--; \ + } /* Macro used to grow the level of a node by 1, with appropriate changes to the * head node if necessary. PREV is the previous node of the height that X is to * grow to. */ -#define H5SL_PROMOTE(SLIST, X, PREV, ERR) \ -{ \ - size_t _lvl = X->level; \ - \ - H5SL_GROW(X, _lvl, ERR); \ - \ - if(_lvl == (size_t) SLIST->curr_level) { \ - HDassert(PREV == SLIST->header); \ - /* Grow the head */ \ - H5SL_GROW(PREV, _lvl, ERR) \ - SLIST->curr_level++; \ - X->forward[_lvl+1] = NULL; \ - } else { \ - HDassert(_lvl < (size_t) SLIST->curr_level); \ - X->forward[_lvl+1] = PREV->forward[_lvl+1]; \ - } /* end else */ \ - PREV->forward[_lvl+1] = X; \ -} - +#define H5SL_PROMOTE(SLIST, X, PREV, ERR) \ + { \ + size_t _lvl = X->level; \ + \ + H5SL_GROW(X, _lvl, ERR); \ + \ + if (_lvl == (size_t)SLIST->curr_level) { \ + HDassert(PREV == SLIST->header); \ + /* Grow the head */ \ + H5SL_GROW(PREV, _lvl, ERR) \ + SLIST->curr_level++; \ + X->forward[_lvl + 1] = NULL; \ + } \ + else { \ + HDassert(_lvl < (size_t)SLIST->curr_level); \ + X->forward[_lvl + 1] = PREV->forward[_lvl + 1]; \ + } /* end else */ \ + PREV->forward[_lvl + 1] = X; \ + } /* Macro used to reduce the level of a node by 1. Does not update the head node * "current level". PREV is the previous node of the currrent height of X. */ -#define H5SL_DEMOTE(X, PREV) \ -{ \ - size_t _lvl = X->level; \ - \ - HDassert(PREV->forward[_lvl] == X); \ - PREV->forward[_lvl] = X->forward[_lvl]; \ - H5SL_SHRINK(X, _lvl); \ -} - +#define H5SL_DEMOTE(X, PREV) \ + { \ + size_t _lvl = X->level; \ + \ + HDassert(PREV->forward[_lvl] == X); \ + PREV->forward[_lvl] = X->forward[_lvl]; \ + H5SL_SHRINK(X, _lvl); \ + } /* Macro used to insert node. Does not actually insert the node. After running * this macro, X will contain the node before where the new node should be * inserted (at level 0). */ -#define H5SL_INSERT(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ -{ \ - H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ - H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ - H5SL_node_t *_drop; /* Low node of the gap to drop into */ \ - int _count; /* Number of nodes in the current gap */ \ - int _i; \ - \ - H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ - for(_i = (int)SLIST->curr_level; _i >= 0; _i--) { \ - /* Search for the node to drop into, also count the number of nodes */ \ - /* of height _i in this gap */ \ - _drop = NULL; \ - for(_count = 0; ; _count++) { \ - /* Terminate if this is the last node in the gap */ \ - if(X->forward[_i] == _next) { \ - if(!_drop) \ - _drop = X; \ - break; \ - } /* end if */ \ - \ - /* Check if this node is the start of the next gap */ \ - if(!_drop && !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) \ - _drop = X; \ - \ - /* No need to check the last node in the gap if there are 3, as */ \ - /* there cannot be a fourth */ \ - if(_count == 2) { \ - if(!_drop) \ - _drop = X->forward[_i]; \ - _count = 3; \ - break; \ - } \ - X = X->forward[_i]; \ - } /* end for */ \ - HDassert(!_drop->forward[_i] || \ - !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ - \ - /* Promote the middle node if necessary */ \ - if(_count == 3) { \ - HDassert(X == _last->forward[_i]->forward[_i]); \ - H5SL_PROMOTE(SLIST, X, _last, NULL) \ - } \ - \ - /* Prepare to drop down */ \ - X = _last = _drop; \ - _next = _drop->forward[_i]; \ - } /* end for */ \ - \ - if(_next && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) \ - HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, NULL, "can't insert duplicate key") \ -} - +#define H5SL_INSERT(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + { \ + H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ + H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ + H5SL_node_t *_drop; /* Low node of the gap to drop into */ \ + int _count; /* Number of nodes in the current gap */ \ + int _i; \ + \ + H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ + (KEY, HASHVAL) for (_i = (int)SLIST->curr_level; _i >= 0; _i--) \ + { \ + /* Search for the node to drop into, also count the number of nodes */ \ + /* of height _i in this gap */ \ + _drop = NULL; \ + for (_count = 0;; _count++) { \ + /* Terminate if this is the last node in the gap */ \ + if (X->forward[_i] == _next) { \ + if (!_drop) \ + _drop = X; \ + break; \ + } /* end if */ \ + \ + /* Check if this node is the start of the next gap */ \ + if (!_drop && !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) \ + _drop = X; \ + \ + /* No need to check the last node in the gap if there are 3, as */ \ + /* there cannot be a fourth */ \ + if (_count == 2) { \ + if (!_drop) \ + _drop = X->forward[_i]; \ + _count = 3; \ + break; \ + } \ + X = X->forward[_i]; \ + } /* end for */ \ + HDassert(!_drop->forward[_i] || \ + !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ + \ + /* Promote the middle node if necessary */ \ + if (_count == 3) { \ + HDassert(X == _last->forward[_i]->forward[_i]); \ + H5SL_PROMOTE(SLIST, X, _last, NULL) \ + } \ + \ + /* Prepare to drop down */ \ + X = _last = _drop; \ + _next = _drop->forward[_i]; \ + } /* end for */ \ + \ + if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) \ + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, NULL, "can't insert duplicate key") \ + } /* Macro used to remove node */ -#define H5SL_REMOVE(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ -{ \ - /* Check for deferred removal */ \ - if(SLIST->safe_iterating) \ - H5SL_LOCATE(SEARCH_DEFER_REMOVE, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - else { \ - H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ - H5SL_node_t *_llast = X; /* Lowest node in the previous gap */ \ - H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ - H5SL_node_t *_drop = NULL; /* Low node of the gap to drop into */ \ - H5SL_node_t *_ldrop = NULL; /* Low node of gap before the one to drop into */ \ - H5SL_node_t *_head = SLIST->header; /* Head of the skip list */ \ - int _count; /* Number of nodes in the current gap */ \ - int _i = (int)SLIST->curr_level; \ - \ - if(_i < 0) \ - HGOTO_DONE(NULL); \ - \ - H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ - \ - /* Find the gap to drop in to at the highest level */ \ - while(X && (!X->key || H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, X, KEY, HASHVAL))) { \ - _llast = _last; \ - _last = X; \ - X = X->forward[_i]; \ - } \ - _next = X; \ - \ - /* Main loop */ \ - for(_i--; _i >= 0; _i--) { \ - /* Search for the node to drop into, also count the number of */ \ - /* nodes of height _i in this gap and keep track of of the node */ \ - /* before the one to drop into (_ldrop will become _llast, */ \ - /* _drop will become _last). */ \ - X = _ldrop = _last; \ - _drop = NULL; \ - for(_count = 0; ; _count++) { \ - /* Terminate if this is the last node in the gap */ \ - if(X->forward[_i] == _next) { \ - if(!_drop) \ - _drop = X; \ - break; \ - } /* end if */ \ - \ - /* If we have already found the node to drop into and there */ \ - /* is more than one node in this gap, we can stop searching */ \ - if(_drop) { \ - HDassert(_count >= 1); \ - _count = 2; \ - break; \ - } else { /* !_drop */ \ - /* Check if this node is the start of the next gap */ \ - if (!H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) { \ - _drop = X; \ - /* Again check if we can stop searching */ \ - if(_count) { \ - _count = 2; \ - break; \ - } /* end if */ \ - } /* end if */ \ - else \ - _ldrop = X; \ - } /* end else */ \ - \ - /* No need to check the last node in the gap if there are */ \ - /* 3, as there cannot be a fourth */ \ - if(_count == 2) { \ - if(!_drop) \ - _drop = X->forward[_i]; \ - break; \ - } /* end if */ \ - X = X->forward[_i]; \ - } /* end for */ \ - HDassert(_count >= 1 && _count <= 3); \ - HDassert(!_drop->forward[_i] || \ - !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ - \ - /* Check if we need to adjust node heights */ \ - if(_count == 1) { \ - /* Check if we are in the first gap */ \ - if(_llast == _last) { \ - /* We are in the first gap, count the number of nodes */ \ - /* of height _i in the next gap. We need only check */ \ - /* onenode to see if we should promote the first node */ \ - /* in the next gap */ \ - _llast = _next->forward[_i+1]; \ - \ - /* Demote the separator node */ \ - H5SL_DEMOTE(_next, _last) \ - \ - /* If there are 2 or more nodes, promote the first */ \ - if(_next->forward[_i]->forward[_i] != _llast) { \ - X = _next->forward[_i]; \ - H5SL_PROMOTE(SLIST, X, _last, NULL) \ - } else if(!_head->forward[_i+1]) { \ - /* shrink the header */ \ - HDassert(_i == SLIST->curr_level - 1); \ - HDassert((size_t) SLIST->curr_level == _head->level); \ - \ - H5SL_SHRINK(_head, (size_t) (_i+1)) \ - SLIST->curr_level--; \ - } /* end else */ \ - } else { \ - /* We are not in the first gap, count the number of */ \ - /* nodes of height _i in the previous gap. Note we */ \ - /* "look ahead" in this loop so X has the value of the */ \ - /* last node in the previous gap. */ \ - X = _llast->forward[_i]; \ - for(_count = 1; _count < 3 && X->forward[_i] != _last; _count++) \ - X = X->forward[_i]; \ - HDassert(X->forward[_i] == _last); \ - \ - /* Demote the separator node */ \ - H5SL_DEMOTE(_last, _llast) \ - \ - /* If there are 2 or more nodes, promote the last */ \ - if(_count >= 2) \ - H5SL_PROMOTE(SLIST, X, _llast, NULL) \ - else if(!_head->forward[_i+1]) { \ - /* shrink the header */ \ - HDassert(_i == SLIST->curr_level - 1); \ - HDassert((size_t) SLIST->curr_level == _head->level); \ - \ - H5SL_SHRINK(_head, (size_t) (_i+1)) \ - SLIST->curr_level--; \ - } /* end else */ \ - } /* end else */ \ - } /* end if */ \ - \ - /* Prepare to drop down */ \ - _llast = _ldrop; \ - _last = _drop; \ - _next = _drop->forward[_i]; \ - } /* end for */ \ - \ - /* Check if we've found the node */ \ - if(_next && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) { \ - void *tmp = _next->item; \ - X = _next; \ - \ - /* If the node has a height > 0, swap it with its (lower) */ \ - /* neighbor */ \ - if(X->level) { \ - X = X->backward; \ - _next->key = X->key; \ - _next->item = X->item; \ - _next->hashval = X->hashval; \ - } /* end if */ \ - HDassert(!X->level); \ - \ - /* Remove the node */ \ - X->backward->forward[0] = X->forward[0]; \ - if(SLIST->last == X) \ - SLIST->last = X->backward; \ - else \ - X->forward[0]->backward = X->backward; \ - SLIST->nobjs--; \ - X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[0], X->forward); \ - X = H5FL_FREE(H5SL_node_t, X); \ - \ - HGOTO_DONE(tmp); \ - } /* end if */ \ - } /* end else */ \ -} - +#define H5SL_REMOVE(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + { \ + /* Check for deferred removal */ \ + if (SLIST->safe_iterating) \ + H5SL_LOCATE(SEARCH_DEFER_REMOVE, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + else { \ + H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ + H5SL_node_t *_llast = X; /* Lowest node in the previous gap */ \ + H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ + H5SL_node_t *_drop = NULL; /* Low node of the gap to drop into */ \ + H5SL_node_t *_ldrop = NULL; /* Low node of gap before the one to drop into */ \ + H5SL_node_t *_head = SLIST->header; /* Head of the skip list */ \ + int _count; /* Number of nodes in the current gap */ \ + int _i = (int)SLIST->curr_level; \ + \ + if (_i < 0) \ + HGOTO_DONE(NULL); \ + \ + H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ + (KEY, HASHVAL) \ + \ + /* Find the gap to drop in to at the highest level */ \ + while (X && (!X->key || H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X, KEY, HASHVAL))) \ + { \ + _llast = _last; \ + _last = X; \ + X = X->forward[_i]; \ + } \ + _next = X; \ + \ + /* Main loop */ \ + for (_i--; _i >= 0; _i--) { \ + /* Search for the node to drop into, also count the number of */ \ + /* nodes of height _i in this gap and keep track of of the node */ \ + /* before the one to drop into (_ldrop will become _llast, */ \ + /* _drop will become _last). */ \ + X = _ldrop = _last; \ + _drop = NULL; \ + for (_count = 0;; _count++) { \ + /* Terminate if this is the last node in the gap */ \ + if (X->forward[_i] == _next) { \ + if (!_drop) \ + _drop = X; \ + break; \ + } /* end if */ \ + \ + /* If we have already found the node to drop into and there */ \ + /* is more than one node in this gap, we can stop searching */ \ + if (_drop) { \ + HDassert(_count >= 1); \ + _count = 2; \ + break; \ + } \ + else { /* !_drop */ \ + /* Check if this node is the start of the next gap */ \ + if (!H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) { \ + _drop = X; \ + /* Again check if we can stop searching */ \ + if (_count) { \ + _count = 2; \ + break; \ + } /* end if */ \ + } /* end if */ \ + else \ + _ldrop = X; \ + } /* end else */ \ + \ + /* No need to check the last node in the gap if there are */ \ + /* 3, as there cannot be a fourth */ \ + if (_count == 2) { \ + if (!_drop) \ + _drop = X->forward[_i]; \ + break; \ + } /* end if */ \ + X = X->forward[_i]; \ + } /* end for */ \ + HDassert(_count >= 1 && _count <= 3); \ + HDassert(!_drop->forward[_i] || \ + !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ + \ + /* Check if we need to adjust node heights */ \ + if (_count == 1) { \ + /* Check if we are in the first gap */ \ + if (_llast == _last) { \ + /* We are in the first gap, count the number of nodes */ \ + /* of height _i in the next gap. We need only check */ \ + /* onenode to see if we should promote the first node */ \ + /* in the next gap */ \ + _llast = _next->forward[_i + 1]; \ + \ + /* Demote the separator node */ \ + H5SL_DEMOTE(_next, _last) \ + \ + /* If there are 2 or more nodes, promote the first */ \ + if (_next->forward[_i]->forward[_i] != _llast) { \ + X = _next->forward[_i]; \ + H5SL_PROMOTE(SLIST, X, _last, NULL) \ + } \ + else if (!_head->forward[_i + 1]) { \ + /* shrink the header */ \ + HDassert(_i == SLIST->curr_level - 1); \ + HDassert((size_t)SLIST->curr_level == _head->level); \ + \ + H5SL_SHRINK(_head, (size_t)(_i + 1)) \ + SLIST->curr_level--; \ + } /* end else */ \ + } \ + else { \ + /* We are not in the first gap, count the number of */ \ + /* nodes of height _i in the previous gap. Note we */ \ + /* "look ahead" in this loop so X has the value of the */ \ + /* last node in the previous gap. */ \ + X = _llast->forward[_i]; \ + for (_count = 1; _count < 3 && X->forward[_i] != _last; _count++) \ + X = X->forward[_i]; \ + HDassert(X->forward[_i] == _last); \ + \ + /* Demote the separator node */ \ + H5SL_DEMOTE(_last, _llast) \ + \ + /* If there are 2 or more nodes, promote the last */ \ + if (_count >= 2) \ + H5SL_PROMOTE(SLIST, X, _llast, NULL) \ + else if (!_head->forward[_i + 1]) { \ + /* shrink the header */ \ + HDassert(_i == SLIST->curr_level - 1); \ + HDassert((size_t)SLIST->curr_level == _head->level); \ + \ + H5SL_SHRINK(_head, (size_t)(_i + 1)) \ + SLIST->curr_level--; \ + } /* end else */ \ + } /* end else */ \ + } /* end if */ \ + \ + /* Prepare to drop down */ \ + _llast = _ldrop; \ + _last = _drop; \ + _next = _drop->forward[_i]; \ + } /* end for */ \ + \ + /* Check if we've found the node */ \ + if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) { \ + void *tmp = _next->item; \ + X = _next; \ + \ + /* If the node has a height > 0, swap it with its (lower) */ \ + /* neighbor */ \ + if (X->level) { \ + X = X->backward; \ + _next->key = X->key; \ + _next->item = X->item; \ + _next->hashval = X->hashval; \ + } /* end if */ \ + HDassert(!X->level); \ + \ + /* Remove the node */ \ + X->backward->forward[0] = X->forward[0]; \ + if (SLIST->last == X) \ + SLIST->last = X->backward; \ + else \ + X->forward[0]->backward = X->backward; \ + SLIST->nobjs--; \ + X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[0], X->forward); \ + X = H5FL_FREE(H5SL_node_t, X); \ + \ + HGOTO_DONE(tmp); \ + } /* end if */ \ + } /* end else */ \ + } /* Macro used to search for node */ -#define H5SL_SEARCH(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - H5SL_LOCATE(SEARCH, CMP, SLIST, X, TYPE, KEY, HASHVAL) +#define H5SL_SEARCH(CMP, SLIST, X, TYPE, KEY, HASHVAL) H5SL_LOCATE(SEARCH, CMP, SLIST, X, TYPE, KEY, HASHVAL) /* Macro used to find a node */ -#define H5SL_FIND(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - H5SL_LOCATE(FIND, CMP, SLIST, X, TYPE, KEY, HASHVAL) - +#define H5SL_FIND(CMP, SLIST, X, TYPE, KEY, HASHVAL) H5SL_LOCATE(FIND, CMP, SLIST, X, TYPE, KEY, HASHVAL) /* Private typedefs & structs */ /* Skip list node data structure */ struct H5SL_node_t { - const void *key; /* Pointer to node's key */ - void *item; /* Pointer to node's item */ - size_t level; /* The level of this node */ - size_t log_nalloc; /* log2(Number of slots allocated in forward) */ - uint32_t hashval; /* Hash value for key (only for strings, currently) */ - hbool_t removed; /* Whether the node is "removed" (actual removal deferred) */ - struct H5SL_node_t **forward; /* Array of forward pointers from this node */ - struct H5SL_node_t *backward; /* Backward pointer from this node */ + const void * key; /* Pointer to node's key */ + void * item; /* Pointer to node's item */ + size_t level; /* The level of this node */ + size_t log_nalloc; /* log2(Number of slots allocated in forward) */ + uint32_t hashval; /* Hash value for key (only for strings, currently) */ + hbool_t removed; /* Whether the node is "removed" (actual removal deferred) */ + struct H5SL_node_t **forward; /* Array of forward pointers from this node */ + struct H5SL_node_t * backward; /* Backward pointer from this node */ }; /* Main skip list data structure */ struct H5SL_t { /* Static values for each list */ - H5SL_type_t type; /* Type of skip list */ - H5SL_cmp_t cmp; /* Comparison callback, if type is H5SL_TYPE_GENERIC */ + H5SL_type_t type; /* Type of skip list */ + H5SL_cmp_t cmp; /* Comparison callback, if type is H5SL_TYPE_GENERIC */ /* Dynamic values for each list */ - int curr_level; /* Current top level used in list */ - size_t nobjs; /* Number of active objects in skip list */ - H5SL_node_t *header; /* Header for nodes in skip list */ - H5SL_node_t *last; /* Pointer to last node in skip list */ - hbool_t safe_iterating; /* Whether a routine is "safely" iterating over the list and removals should be deferred */ + int curr_level; /* Current top level used in list */ + size_t nobjs; /* Number of active objects in skip list */ + H5SL_node_t *header; /* Header for nodes in skip list */ + H5SL_node_t *last; /* Pointer to last node in skip list */ + hbool_t safe_iterating; /* Whether a routine is "safely" iterating over the list and removals should be + deferred */ }; /* Static functions */ -static H5SL_node_t * H5SL_new_node(void *item, const void *key, uint32_t hashval); +static H5SL_node_t *H5SL_new_node(void *item, const void *key, uint32_t hashval); static H5SL_node_t *H5SL_insert_common(H5SL_t *slist, void *item, const void *key); -static herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); -static herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); +static herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); +static herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; @@ -584,10 +579,9 @@ H5FL_DEFINE_STATIC(H5SL_node_t); /* Global variables */ static H5FL_fac_head_t **H5SL_fac_g; -static size_t H5SL_fac_nused_g; -static size_t H5SL_fac_nalloc_g; +static size_t H5SL_fac_nused_g; +static size_t H5SL_fac_nalloc_g; - /*-------------------------------------------------------------------------- NAME H5SL__init_package @@ -622,7 +616,6 @@ H5SL__init_package(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL__init_package() */ - /*-------------------------------------------------------------------------- NAME H5SL_term_package @@ -633,7 +626,7 @@ H5SL__init_package(void) RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -642,19 +635,20 @@ H5SL__init_package(void) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -int H5SL_term_package(void) +int +H5SL_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Terminate all the factories */ - if(H5SL_fac_nused_g > 0) { - size_t i; - herr_t H5_ATTR_NDEBUG_UNUSED ret; + if (H5SL_fac_nused_g > 0) { + size_t i; + herr_t H5_ATTR_NDEBUG_UNUSED ret; - for(i = 0; i < H5SL_fac_nused_g; i++) { + for (i = 0; i < H5SL_fac_nused_g; i++) { ret = H5FL_fac_term(H5SL_fac_g[i]); HDassert(ret >= 0); } /* end if */ @@ -664,22 +658,21 @@ int H5SL_term_package(void) } /* end if */ /* Free the list of factories */ - if(H5SL_fac_g) { - H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); + if (H5SL_fac_g) { + H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); H5SL_fac_nalloc_g = 0; n++; } /* end if */ /* Mark the interface as uninitialized */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5SL_term_package() */ - /*-------------------------------------------------------------------------- NAME H5SL_new_node @@ -705,21 +698,21 @@ int H5SL_term_package(void) static H5SL_node_t * H5SL_new_node(void *item, const void *key, uint32_t hashval) { - H5SL_node_t *ret_value = NULL; /* New skip list node */ + H5SL_node_t *ret_value = NULL; /* New skip list node */ FUNC_ENTER_NOAPI_NOINIT /* Allocate the node */ - if(NULL == (ret_value = (H5SL_node_t *)H5FL_MALLOC(H5SL_node_t))) + if (NULL == (ret_value = (H5SL_node_t *)H5FL_MALLOC(H5SL_node_t))) HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") /* Initialize node */ - ret_value->key = key; - ret_value->item = item; - ret_value->level = 0; + ret_value->key = key; + ret_value->item = item; + ret_value->level = 0; ret_value->hashval = hashval; ret_value->removed = FALSE; - if(NULL == (ret_value->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) { + if (NULL == (ret_value->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) { ret_value = H5FL_FREE(H5SL_node_t, ret_value); HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ @@ -729,7 +722,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_new_node() */ - /*-------------------------------------------------------------------------- NAME H5SL_insert_common @@ -754,10 +746,10 @@ done: static H5SL_node_t * H5SL_insert_common(H5SL_t *slist, void *item, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - H5SL_node_t *prev; /* Node before the new node */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + H5SL_node_t *prev; /* Node before the new node */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -773,8 +765,8 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - prev=slist->header; - switch(slist->type) { + prev = slist->header; + switch (slist->type) { case H5SL_TYPE_INT: H5SL_INSERT(SCALAR, slist, prev, const int, key, -) break; @@ -815,21 +807,20 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) HDassert(0 && "Unknown skiplist type!"); } /* end switch */ - /* 'key' must not have been found in existing list, if we get here */ - if(slist->curr_level < 0) + if (slist->curr_level < 0) slist->curr_level = 0; /* Create new node of level 0 */ - if(NULL == (x = H5SL_new_node(item, key, hashval))) - HGOTO_ERROR(H5E_SLIST ,H5E_NOSPACE, NULL, "can't create new skip list node") + if (NULL == (x = H5SL_new_node(item, key, hashval))) + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "can't create new skip list node") /* Update the links */ - x->backward = prev; - x->forward[0] = prev->forward[0]; + x->backward = prev; + x->forward[0] = prev->forward[0]; prev->forward[0] = x; - if(x->forward[0]) + if (x->forward[0]) x->forward[0]->backward = x; else { HDassert(slist->last == prev); @@ -840,13 +831,12 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) slist->nobjs++; /* Set return value */ - ret_value=x; + ret_value = x; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_insert_common() */ - /*-------------------------------------------------------------------------- NAME H5SL_release_common @@ -874,8 +864,8 @@ done: static herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */ - herr_t ret_value = SUCCEED; + H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -887,39 +877,39 @@ H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Free skip list nodes */ node = slist->header->forward[0]; - while(node) { + while (node) { next_node = node->forward[0]; /* Call callback, if one is given */ - if(op) + if (op) /* Casting away const OK -QAK */ (void)(op)(node->item, (void *)node->key, op_data); node->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], node->forward); - node = H5FL_FREE(H5SL_node_t, node); - node = next_node; + node = H5FL_FREE(H5SL_node_t, node); + node = next_node; } /* end while */ /* Reset the header pointers */ - slist->header->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); - if(NULL == (slist->header->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) + slist->header->forward = + (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); + if (NULL == (slist->header->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, FAIL, "memory allocation failed") slist->header->forward[0] = NULL; slist->header->log_nalloc = 0; - slist->header->level = 0; + slist->header->level = 0; /* Reset the last pointer */ slist->last = slist->header; /* Reset the dynamic internal fields */ slist->curr_level = -1; - slist->nobjs = 0; + slist->nobjs = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_release_common() */ - /*-------------------------------------------------------------------------- NAME H5SL_close_common @@ -957,11 +947,12 @@ H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* (Pre-condition) */ /* Free skip list nodes */ - if(H5SL_release_common(slist, op, op_data) < 0) + if (H5SL_release_common(slist, op, op_data) < 0) HGOTO_ERROR(H5E_SLIST, H5E_CANTFREE, FAIL, "can't release skip list nodes") /* Release header node */ - slist->header->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); + slist->header->forward = + (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); slist->header = H5FL_FREE(H5SL_node_t, slist->header); /* Free skip list object */ @@ -971,7 +962,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_close_common() */ - /*-------------------------------------------------------------------------- NAME H5SL_create @@ -992,9 +982,9 @@ done: H5SL_t * H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) { - H5SL_t *new_slist = NULL; /* Pointer to new skip list object created */ - H5SL_node_t *header; /* Pointer to skip list header node */ - H5SL_t *ret_value = NULL; /* Return value */ + H5SL_t * new_slist = NULL; /* Pointer to new skip list object created */ + H5SL_node_t *header; /* Pointer to skip list header node */ + H5SL_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1002,7 +992,7 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) HDassert(type >= H5SL_TYPE_INT && type <= H5SL_TYPE_GENERIC); /* Allocate skip list structure */ - if(NULL == (new_slist = H5FL_MALLOC(H5SL_t))) + if (NULL == (new_slist = H5FL_MALLOC(H5SL_t))) HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the static internal fields */ @@ -1011,13 +1001,13 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) new_slist->cmp = cmp; /* Set the dynamic internal fields */ - new_slist->curr_level = -1; - new_slist->nobjs = 0; + new_slist->curr_level = -1; + new_slist->nobjs = 0; new_slist->safe_iterating = FALSE; /* Allocate the header node */ - if(NULL == (header = H5SL_new_node(NULL, NULL, (uint32_t)ULONG_MAX))) - HGOTO_ERROR(H5E_SLIST ,H5E_NOSPACE, NULL, "can't create new skip list node") + if (NULL == (header = H5SL_new_node(NULL, NULL, (uint32_t)ULONG_MAX))) + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "can't create new skip list node") /* Initialize header node's forward pointer */ header->forward[0] = NULL; @@ -1027,22 +1017,21 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) /* Attach the header */ new_slist->header = header; - new_slist->last = header; + new_slist->last = header; /* Set the return value */ ret_value = new_slist; done: /* Error cleanup */ - if(ret_value == NULL) { - if(new_slist != NULL) + if (ret_value == NULL) { + if (new_slist != NULL) new_slist = H5FL_FREE(H5SL_t, new_slist); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_create() */ - /*-------------------------------------------------------------------------- NAME H5SL_count @@ -1078,7 +1067,6 @@ H5SL_count(H5SL_t *slist) FUNC_LEAVE_NOAPI(slist->nobjs) } /* end H5SL_count() */ - /*-------------------------------------------------------------------------- NAME H5SL_insert @@ -1103,7 +1091,7 @@ H5SL_count(H5SL_t *slist) herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1118,14 +1106,13 @@ H5SL_insert(H5SL_t *slist, void *item, const void *key) /* (Pre-condition) */ /* Insert item into skip list */ - if(H5SL_insert_common(slist,item,key)==NULL) - HGOTO_ERROR(H5E_SLIST,H5E_CANTINSERT,FAIL,"can't create new skip list node") + if (H5SL_insert_common(slist, item, key) == NULL) + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, FAIL, "can't create new skip list node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_insert() */ - /*-------------------------------------------------------------------------- NAME H5SL_add @@ -1153,7 +1140,7 @@ done: H5SL_node_t * H5SL_add(H5SL_t *slist, void *item, const void *key) { - H5SL_node_t *ret_value = NULL; /* Return value */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1168,14 +1155,13 @@ H5SL_add(H5SL_t *slist, void *item, const void *key) /* (Pre-condition) */ /* Insert item into skip list */ - if((ret_value=H5SL_insert_common(slist,item,key))==NULL) - HGOTO_ERROR(H5E_SLIST,H5E_CANTINSERT,NULL,"can't create new skip list node") + if ((ret_value = H5SL_insert_common(slist, item, key)) == NULL) + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, NULL, "can't create new skip list node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_add() */ - /*-------------------------------------------------------------------------- NAME H5SL_remove @@ -1198,9 +1184,9 @@ done: void * H5SL_remove(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - void *ret_value = NULL; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1217,7 +1203,7 @@ H5SL_remove(H5SL_t *slist, const void *key) * level that is before the location to remove */ x = slist->header; - switch(slist->type) { + switch (slist->type) { case H5SL_TYPE_INT: H5SL_REMOVE(SCALAR, slist, x, const int, key, -) break; @@ -1262,7 +1248,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_remove() */ - /*-------------------------------------------------------------------------- NAME H5SL_remove_first @@ -1284,12 +1269,12 @@ done: void * H5SL_remove_first(H5SL_t *slist) { - void *ret_value = NULL; /* Return value */ - H5SL_node_t *head = slist->header; /* Skip list header */ - H5SL_node_t *tmp = slist->header->forward[0]; /* Temporary node pointer */ - H5SL_node_t *next; /* Next node to search for */ - size_t level; /* Skip list level */ - size_t i; /* Index */ + void * ret_value = NULL; /* Return value */ + H5SL_node_t *head = slist->header; /* Skip list header */ + H5SL_node_t *tmp = slist->header->forward[0]; /* Temporary node pointer */ + H5SL_node_t *next; /* Next node to search for */ + size_t level; /* Skip list level */ + size_t i; /* Index */ FUNC_ENTER_NOAPI_NOINIT @@ -1309,7 +1294,7 @@ H5SL_remove_first(H5SL_t *slist) /* Remove item from skip list */ /* Check for empty list */ - if(slist->last != slist->header) { + if (slist->last != slist->header) { /* Assign return value */ ret_value = tmp->item; @@ -1318,58 +1303,59 @@ H5SL_remove_first(H5SL_t *slist) /* Remove the first node */ head->forward[0] = tmp->forward[0]; - if(slist->last == tmp) + if (slist->last == tmp) slist->last = head; else tmp->forward[0]->backward = head; slist->nobjs--; /* Free memory */ tmp->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[0], tmp->forward); - tmp = H5FL_FREE(H5SL_node_t, tmp); + tmp = H5FL_FREE(H5SL_node_t, tmp); /* Reshape the skip list as necessary to maintain 1-2-3 condition */ - for(i=0; i < level; i++) { - next = head->forward[i+1]; + for (i = 0; i < level; i++) { + next = head->forward[i + 1]; HDassert(next); /* Check if head->forward[i] == head->forward[i+1] (illegal) */ - if(head->forward[i] == next) { - tmp = next; - next = next->forward[i+1]; + if (head->forward[i] == next) { + tmp = next; + next = next->forward[i + 1]; - HDassert(tmp->level == i+1); + HDassert(tmp->level == i + 1); /* Demote head->forward[i] */ H5SL_DEMOTE(tmp, head) /* Check if we need to promote the following node to maintain * 1-2-3 condition */ - if(tmp->forward[i]->forward[i] != next) { + if (tmp->forward[i]->forward[i] != next) { HDassert(tmp->forward[i]->forward[i]->forward[i] == next || - tmp->forward[i]->forward[i]->forward[i]->forward[i] == next); + tmp->forward[i]->forward[i]->forward[i]->forward[i] == next); tmp = tmp->forward[i]; H5SL_PROMOTE(slist, tmp, head, NULL); /* In this case, since there is a node of height = i+1 here * now (tmp), we know the skip list must be valid and can * break */ break; - } else if(!head->forward[i+1]) { + } + else if (!head->forward[i + 1]) { /* We just shrunk the largest node, shrink the header */ HDassert(i == level - 1); H5SL_SHRINK(head, level) slist->curr_level--; } /* end else */ - } else + } + else break; } /* end for */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_remove_first() */ - /*-------------------------------------------------------------------------- NAME H5SL_search @@ -1392,9 +1378,9 @@ done: void * H5SL_search(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - void *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void * ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1410,8 +1396,8 @@ H5SL_search(H5SL_t *slist, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - x=slist->header; - switch(slist->type) { + x = slist->header; + switch (slist->type) { case H5SL_TYPE_INT: H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; @@ -1453,13 +1439,12 @@ H5SL_search(H5SL_t *slist, const void *key) } /* end switch */ /* 'key' must not have been found in list, if we get here */ - ret_value=NULL; + ret_value = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_search() */ - /*-------------------------------------------------------------------------- NAME H5SL_less @@ -1485,9 +1470,9 @@ done: void * H5SL_less(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - void *ret_value = NULL; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1506,8 +1491,8 @@ H5SL_less(H5SL_t *slist, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - x=slist->header; - switch(slist->type) { + x = slist->header; + switch (slist->type) { case H5SL_TYPE_INT: H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; @@ -1550,25 +1535,24 @@ H5SL_less(H5SL_t *slist, const void *key) /* An exact match for 'key' must not have been found in list, if we get here */ /* Check for a node with a key that is less than the given 'key' */ - if(x==NULL) { + if (x == NULL) { /* Check for walking off the list */ - if(slist->last!=slist->header) - ret_value=slist->last->item; + if (slist->last != slist->header) + ret_value = slist->last->item; else - ret_value=NULL; + ret_value = NULL; } /* end if */ else { - if(x->backward!=slist->header) - ret_value=x->backward->item; + if (x->backward != slist->header) + ret_value = x->backward->item; else - ret_value=NULL; + ret_value = NULL; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_less() */ - /*-------------------------------------------------------------------------- NAME H5SL_greater @@ -1594,9 +1578,9 @@ done: void * H5SL_greater(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - void *ret_value = NULL; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1616,7 +1600,7 @@ H5SL_greater(H5SL_t *slist, const void *key) * level that is before the location to insert */ x = slist->header; - switch(slist->type) { + switch (slist->type) { case H5SL_TYPE_INT: H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; @@ -1659,7 +1643,7 @@ H5SL_greater(H5SL_t *slist, const void *key) /* An exact match for 'key' must not have been found in list, if we get here */ /* ('x' must be the next node with a key greater than the 'key', or NULL) */ - if(x) + if (x) ret_value = x->item; else ret_value = NULL; @@ -1668,7 +1652,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_greater() */ - /*-------------------------------------------------------------------------- NAME H5SL_find @@ -1693,9 +1676,9 @@ done: H5SL_node_t * H5SL_find(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1711,8 +1694,8 @@ H5SL_find(H5SL_t *slist, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - x=slist->header; - switch(slist->type) { + x = slist->header; + switch (slist->type) { case H5SL_TYPE_INT: H5SL_FIND(SCALAR, slist, x, const int, key, -) break; @@ -1754,13 +1737,12 @@ H5SL_find(H5SL_t *slist, const void *key) } /* end switch */ /* 'key' must not have been found in list, if we get here */ - ret_value=NULL; + ret_value = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_find() */ - /*-------------------------------------------------------------------------- NAME H5SL_below @@ -1786,9 +1768,9 @@ done: H5SL_node_t * H5SL_below(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value = NULL; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1805,7 +1787,7 @@ H5SL_below(H5SL_t *slist, const void *key) * level that is before the location to insert */ x = slist->header; - switch(slist->type) { + switch (slist->type) { case H5SL_TYPE_INT: H5SL_FIND(SCALAR, slist, x, const int, key, -) break; @@ -1848,15 +1830,15 @@ H5SL_below(H5SL_t *slist, const void *key) /* An exact match for 'key' must not have been found in list, if we get here */ /* Check for a node with a key that is less than the given 'key' */ - if(NULL == x) { + if (NULL == x) { /* Check for walking off the list */ - if(slist->last != slist->header) + if (slist->last != slist->header) ret_value = slist->last; else ret_value = NULL; } /* end if */ else { - if(x->backward != slist->header) + if (x->backward != slist->header) ret_value = x->backward; else ret_value = NULL; @@ -1866,7 +1848,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_below() */ - /*-------------------------------------------------------------------------- NAME H5SL_above @@ -1892,9 +1873,9 @@ done: H5SL_node_t * H5SL_above(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value = NULL; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1911,7 +1892,7 @@ H5SL_above(H5SL_t *slist, const void *key) * level that is before the location to insert */ x = slist->header; - switch(slist->type) { + switch (slist->type) { case H5SL_TYPE_INT: H5SL_FIND(SCALAR, slist, x, const int, key, -) break; @@ -1954,7 +1935,7 @@ H5SL_above(H5SL_t *slist, const void *key) /* An exact match for 'key' must not have been found in list, if we get here */ /* ('x' must be the next node with a key greater than the 'key', or NULL) */ - if(x) + if (x) ret_value = x; else ret_value = NULL; @@ -1963,7 +1944,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_above() */ - /*-------------------------------------------------------------------------- NAME H5SL_first @@ -2000,7 +1980,6 @@ H5SL_first(H5SL_t *slist) FUNC_LEAVE_NOAPI(slist->header->forward[0]) } /* end H5SL_first() */ - /*-------------------------------------------------------------------------- NAME H5SL_next @@ -2037,7 +2016,6 @@ H5SL_next(H5SL_node_t *slist_node) FUNC_LEAVE_NOAPI(slist_node->forward[0]) } /* end H5SL_next() */ - /*-------------------------------------------------------------------------- NAME H5SL_prev @@ -2072,10 +2050,9 @@ H5SL_prev(H5SL_node_t *slist_node) /* (Pre-condition) */ /* Walk backward, detecting the header node (which has it's key set to NULL) */ - FUNC_LEAVE_NOAPI(slist_node->backward->key==NULL ? NULL : slist_node->backward) + FUNC_LEAVE_NOAPI(slist_node->backward->key == NULL ? NULL : slist_node->backward) } /* end H5SL_prev() */ - /*-------------------------------------------------------------------------- NAME H5SL_last @@ -2110,10 +2087,9 @@ H5SL_last(H5SL_t *slist) /* (Pre-condition) */ /* Find last node, avoiding the header node */ - FUNC_LEAVE_NOAPI(slist->last==slist->header ? NULL : slist->last) + FUNC_LEAVE_NOAPI(slist->last == slist->header ? NULL : slist->last) } /* end H5SL_last() */ - /*-------------------------------------------------------------------------- NAME H5SL_item @@ -2149,7 +2125,6 @@ H5SL_item(H5SL_node_t *slist_node) FUNC_LEAVE_NOAPI(slist_node->item) } /* end H5SL_item() */ - /*-------------------------------------------------------------------------- NAME H5SL_iterate @@ -2186,9 +2161,9 @@ H5SL_item(H5SL_node_t *slist_node) herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - H5SL_node_t *node; /* Pointer to current skip list node */ - H5SL_node_t *next; /* Pointer to next skip list node */ - herr_t ret_value = 0; /* Return value */ + H5SL_node_t *node; /* Pointer to current skip list node */ + H5SL_node_t *next; /* Pointer to next skip list node */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2200,14 +2175,14 @@ H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Free skip list nodes */ node = slist->header->forward[0]; - while(node != NULL) { + while (node != NULL) { /* Protect against the node being deleted by the callback */ next = node->forward[0]; /* Call the iterator callback */ /* Casting away const OK -QAK */ - if(!node->removed) - if((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) + if (!node->removed) + if ((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) break; /* Advance to next node */ @@ -2217,7 +2192,6 @@ H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_iterate() */ - /*-------------------------------------------------------------------------- NAME H5SL_release @@ -2253,12 +2227,11 @@ H5SL_release(H5SL_t *slist) /* (Pre-condition) */ /* Free skip list nodes */ - H5SL_release_common(slist,NULL,NULL); /* always succeeds */ + H5SL_release_common(slist, NULL, NULL); /* always succeeds */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL_release() */ - /*-------------------------------------------------------------------------- NAME H5SL_free @@ -2302,12 +2275,11 @@ H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* (Pre-condition) */ /* Free skip list nodes */ - H5SL_release_common(slist,op,op_data); /* always succeeds */ + H5SL_release_common(slist, op, op_data); /* always succeeds */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL_free() */ - /*-------------------------------------------------------------------------- NAME H5SL_try_free_safe @@ -2339,8 +2311,8 @@ herr_t H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) { H5SL_node_t *node, *next_node, *last_node; /* Pointers to skip list nodes */ - htri_t op_ret; - herr_t ret_value = SUCCEED; + htri_t op_ret; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -2361,16 +2333,16 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) /* Iterate over skip list nodes, making the callback for each and marking * them as removed if requested by the callback */ node = slist->header->forward[0]; - while(node) { + while (node) { /* Check if the node was already removed */ - if(!node->removed) { + if (!node->removed) { /* Call callback */ /* Casting away const OK -NAF */ - if((op_ret = (op)(node->item , (void *)node->key, op_data)) < 0) + if ((op_ret = (op)(node->item, (void *)node->key, op_data)) < 0) HGOTO_ERROR(H5E_SLIST, H5E_CALLBACK, FAIL, "callback operation failed") /* Check if op indicated that the node should be removed */ - if(op_ret) + if (op_ret) /* Mark the node as removed */ node->removed = TRUE; } /* end if */ @@ -2383,17 +2355,17 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) slist->safe_iterating = FALSE; /* Iterate over nodes, freeing ones marked as removed */ - node = slist->header->forward[0]; + node = slist->header->forward[0]; last_node = slist->header; - while(node) { + while (node) { /* Save next node */ next_node = node->forward[0]; /* Check if the node was marked as removed */ - if(node->removed) { + if (node->removed) { /* Remove the node */ node->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], node->forward); - node = H5FL_FREE(H5SL_node_t, node); + node = H5FL_FREE(H5SL_node_t, node); slist->nobjs--; } /* end if */ else { @@ -2403,18 +2375,19 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) /* Set level to 0. Note there is no need to preserve * node->forward[0] since it was cached above and will always be * updated later. */ - if(node->level > 0) { - node->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], (void *)node->forward); - if(NULL == (node->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) + if (node->level > 0) { + node->forward = + (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], (void *)node->forward); + if (NULL == (node->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") node->log_nalloc = 0; - node->level = 0; + node->level = 0; } /* end if */ /* Update pointers */ last_node->forward[0] = node; - node->backward = last_node; - last_node = node; + node->backward = last_node; + last_node = node; } /* end else */ /* Advance node */ @@ -2423,23 +2396,24 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) /* Final pointer update */ last_node->forward[0] = NULL; - slist->last = last_node; + slist->last = last_node; /* Demote skip list to level 0 */ - if(slist->curr_level > 0) { + if (slist->curr_level > 0) { HDassert(slist->header->level == (size_t)slist->curr_level); - node = slist->header->forward[0]; - slist->header->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], (void *)slist->header->forward); - if(NULL == (slist->header->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) + node = slist->header->forward[0]; + slist->header->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], + (void *)slist->header->forward); + if (NULL == (slist->header->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") slist->header->forward[0] = node; slist->header->log_nalloc = 0; - slist->header->level = 0; + slist->header->level = 0; } /* end if */ /* Check if there are any nodes left */ - if(slist->nobjs > 0) { + if (slist->nobjs > 0) { int i; HDassert(slist->header->forward[0]); @@ -2448,31 +2422,31 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) slist->curr_level = 0; /* Rebuild the forward arrays */ - for(i = 0; slist->curr_level >= i; i++) { + for (i = 0; slist->curr_level >= i; i++) { HDassert(slist->curr_level == i); /* Promote every third node this level until we run out of nodes */ node = last_node = slist->header; - while(1) { + while (1) { /* Check second node in gap, if not present, no need to promote * further this level. */ HDassert(node->forward[i]); node = node->forward[i]->forward[i]; - if(!node) + if (!node) break; /* Check third and fourth node in gap, if either is not present, * no need to promote further this level. */ node = node->forward[i]; - if(!node || !node->forward[i]) + if (!node || !node->forward[i]) break; /* Promote the third node in the gap */ H5SL_PROMOTE(slist, node, last_node, FAIL) last_node = node; } /* end while */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { HDassert(!slist->header->forward[0]); HDassert(slist->last == slist->header); @@ -2486,7 +2460,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_try_free_safe() */ - /*-------------------------------------------------------------------------- NAME H5SL_destroy @@ -2516,7 +2489,7 @@ done: herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2527,12 +2500,11 @@ H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* (Pre-condition) */ /* Close skip list */ - (void)H5SL_close_common(slist,op,op_data); /* always succeeds */ + (void)H5SL_close_common(slist, op, op_data); /* always succeeds */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_destroy() */ - /*-------------------------------------------------------------------------- NAME H5SL_close @@ -2564,8 +2536,7 @@ H5SL_close(H5SL_t *slist) /* (Pre-condition) */ /* Close skip list */ - (void)H5SL_close_common(slist,NULL,NULL); /* always succeeds */ + (void)H5SL_close_common(slist, NULL, NULL); /* always succeeds */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL_close() */ - diff --git a/src/H5SLmodule.h b/src/H5SLmodule.h index 34f08a1..cc13614 100644 --- a/src/H5SLmodule.h +++ b/src/H5SLmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5SL_MODULE -#define H5_MY_PKG H5SL -#define H5_MY_PKG_ERR H5E_SLIST -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5SL +#define H5_MY_PKG_ERR H5E_SLIST +#define H5_MY_PKG_INIT YES #endif /* _H5SLmodule_H */ - diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index 1393a25..8a75d3e 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -34,7 +34,7 @@ /************/ /* Typedefs for skip list struct (defined in H5SL.c) */ -typedef struct H5SL_t H5SL_t; +typedef struct H5SL_t H5SL_t; typedef struct H5SL_node_t H5SL_node_t; /* Typedef for kinds of skip lists supported */ @@ -58,25 +58,23 @@ typedef enum { typedef int (*H5SL_cmp_t)(const void *key1, const void *key2); /* Typedef for iteration operations */ -typedef herr_t (*H5SL_operator_t)(void *item, void *key, - void *operator_data/*in,out*/); +typedef herr_t (*H5SL_operator_t)(void *item, void *key, void *operator_data /*in,out*/); /* Typedef for H5SL_try_free_safe operation callback */ -typedef htri_t (*H5SL_try_free_op_t)(void *item, void *key, - void *operator_data/*in,out*/); +typedef htri_t (*H5SL_try_free_op_t)(void *item, void *key, void *operator_data /*in,out*/); /********************/ /* Private routines */ /********************/ H5_DLL H5SL_t *H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp); -H5_DLL size_t H5SL_count(H5SL_t *slist); -H5_DLL herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key); +H5_DLL size_t H5SL_count(H5SL_t *slist); +H5_DLL herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key); H5_DLL H5SL_node_t *H5SL_add(H5SL_t *slist, void *item, const void *key); -H5_DLL void *H5SL_remove(H5SL_t *slist, const void *key); -H5_DLL void *H5SL_remove_first(H5SL_t *slist); -H5_DLL void *H5SL_search(H5SL_t *slist, const void *key); -H5_DLL void *H5SL_less(H5SL_t *slist, const void *key); -H5_DLL void *H5SL_greater(H5SL_t *slist, const void *key); +H5_DLL void * H5SL_remove(H5SL_t *slist, const void *key); +H5_DLL void * H5SL_remove_first(H5SL_t *slist); +H5_DLL void * H5SL_search(H5SL_t *slist, const void *key); +H5_DLL void * H5SL_less(H5SL_t *slist, const void *key); +H5_DLL void * H5SL_greater(H5SL_t *slist, const void *key); H5_DLL H5SL_node_t *H5SL_find(H5SL_t *slist, const void *key); H5_DLL H5SL_node_t *H5SL_below(H5SL_t *slist, const void *key); H5_DLL H5SL_node_t *H5SL_above(H5SL_t *slist, const void *key); @@ -84,15 +82,13 @@ H5_DLL H5SL_node_t *H5SL_first(H5SL_t *slist); H5_DLL H5SL_node_t *H5SL_next(H5SL_node_t *slist_node); H5_DLL H5SL_node_t *H5SL_prev(H5SL_node_t *slist_node); H5_DLL H5SL_node_t *H5SL_last(H5SL_t *slist); -H5_DLL void *H5SL_item(H5SL_node_t *slist_node); -H5_DLL herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data); -H5_DLL herr_t H5SL_release(H5SL_t *slist); -H5_DLL herr_t H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data); -H5_DLL herr_t H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, - void *op_data); -H5_DLL herr_t H5SL_close(H5SL_t *slist); -H5_DLL herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data); -H5_DLL int H5SL_term_interface(void); +H5_DLL void * H5SL_item(H5SL_node_t *slist_node); +H5_DLL herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data); +H5_DLL herr_t H5SL_release(H5SL_t *slist); +H5_DLL herr_t H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data); +H5_DLL herr_t H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data); +H5_DLL herr_t H5SL_close(H5SL_t *slist); +H5_DLL herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data); +H5_DLL int H5SL_term_interface(void); #endif /* _H5SLprivate_H */ - diff --git a/src/H5SM.c b/src/H5SM.c index 6eea80d..20f6cdd 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -15,67 +15,61 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object Headers */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Udata struct for calls to H5SM__read_iter_op */ typedef struct H5SM_read_udata_t { - H5F_t *file; /* File in which sharing is happening (in) */ + H5F_t * file; /* File in which sharing is happening (in) */ H5O_msg_crt_idx_t idx; /* Creation index of this message (in) */ - size_t buf_size; /* Size of the encoded message (out) */ - void *encoding_buf; /* The encoded message (out) */ + size_t buf_size; /* Size of the encoded message (out) */ + void * encoding_buf; /* The encoded message (out) */ } H5SM_read_udata_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5SM__create_index(H5F_t *f, H5SM_index_header_t *header); -static herr_t H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, - hbool_t delete_heap); +static herr_t H5SM__create_index(H5F_t *f, H5SM_index_header_t *header); +static herr_t H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, hbool_t delete_heap); static haddr_t H5SM__create_list(H5F_t *f, H5SM_index_header_t *header); -static herr_t H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, - size_t *empty_pos, size_t *list_pos); -static herr_t H5SM__convert_list_to_btree(H5F_t * f, H5SM_index_header_t * header, - H5SM_list_t **_list, H5HF_t *fheap, H5O_t *open_oh); -static herr_t H5SM__convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header); -static herr_t H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed); -static herr_t H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, - hbool_t defer, unsigned type_id, void *mesg, unsigned *cache_flags_ptr); -static herr_t H5SM__decr_ref(void *record, void *op_data, hbool_t *changed); -static herr_t H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, - const H5O_shared_t * mesg, unsigned *cache_flags, size_t * /*out*/ mesg_size, - void ** /*out*/ encoded_mesg); -static herr_t H5SM__type_to_flag(unsigned type_id, unsigned *type_flag); -static herr_t H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, - unsigned *oh_modified, void *_udata); -static herr_t H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata); -static herr_t H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, - H5O_t * open_oh, size_t *encoding_size /*out*/, void ** encoded_mesg /*out*/); - +static herr_t H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t *empty_pos, + size_t *list_pos); +static herr_t H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, H5SM_list_t **_list, + H5HF_t *fheap, H5O_t *open_oh); +static herr_t H5SM__convert_btree_to_list(H5F_t *f, H5SM_index_header_t *header); +static herr_t H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed); +static herr_t H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t defer, + unsigned type_id, void *mesg, unsigned *cache_flags_ptr); +static herr_t H5SM__decr_ref(void *record, void *op_data, hbool_t *changed); +static herr_t H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, + const H5O_shared_t *mesg, unsigned *cache_flags, + size_t * /*out*/ mesg_size, void ** /*out*/ encoded_mesg); +static herr_t H5SM__type_to_flag(unsigned type_id, unsigned *type_flag); +static herr_t H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, unsigned *oh_modified, + void *_udata); +static herr_t H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata); +static herr_t H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, H5O_t *open_oh, + size_t *encoding_size /*out*/, void **encoded_mesg /*out*/); /*********************/ /* Package Variables */ @@ -89,18 +83,14 @@ H5FL_ARR_DEFINE(H5SM_index_header_t, H5O_SHMESG_MAX_NINDEXES); H5FL_DEFINE(H5SM_list_t); H5FL_ARR_DEFINE(H5SM_sohm_t, H5O_SHMESG_MAX_LIST_SIZE); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5SM_init * @@ -118,18 +108,18 @@ H5FL_ARR_DEFINE(H5SM_sohm_t, H5O_SHMESG_MAX_LIST_SIZE); *------------------------------------------------------------------------- */ herr_t -H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) +H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) { - H5O_shmesg_table_t sohm_table; /* SOHM message for superblock extension */ - H5SM_master_table_t *table = NULL; /* SOHM master table for file */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - haddr_t table_addr = HADDR_UNDEF; /* Address of SOHM master table in file */ - unsigned list_max, btree_min; /* Phase change limits for SOHM indices */ - unsigned index_type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Messages types stored in each index */ + H5O_shmesg_table_t sohm_table; /* SOHM message for superblock extension */ + H5SM_master_table_t *table = NULL; /* SOHM master table for file */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + haddr_t table_addr = HADDR_UNDEF; /* Address of SOHM master table in file */ + unsigned list_max, btree_min; /* Phase change limits for SOHM indices */ + unsigned index_type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Messages types stored in each index */ unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Message size sharing threshhold for each index */ - unsigned type_flags_used; /* Message type flags used, for sanity checking */ - unsigned x; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned type_flags_used; /* Message type flags used, for sanity checking */ + unsigned x; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -141,30 +131,31 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) H5AC_set_ring(H5AC_RING_USER, &orig_ring); /* Initialize master table */ - if(NULL == (table = H5FL_CALLOC(H5SM_master_table_t))) + if (NULL == (table = H5FL_CALLOC(H5SM_master_table_t))) HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, FAIL, "memory allocation failed for SOHM table") table->num_indexes = H5F_SOHM_NINDEXES(f); - table->table_size = H5SM_TABLE_SIZE(f); + table->table_size = H5SM_TABLE_SIZE(f); /* Get information from fcpl */ - if(H5P_get(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, &index_type_flags) < 0) + if (H5P_get(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, &index_type_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get SOHM type flags") - if(H5P_get(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &list_max) < 0) + if (H5P_get(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &list_max) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get SOHM list maximum") - if(H5P_get(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &btree_min) < 0) + if (H5P_get(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &btree_min) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get SOHM btree minimum") - if(H5P_get(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, &minsizes) < 0) + if (H5P_get(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, &minsizes) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get SOHM message min sizes") /* Verify that values are valid */ - if(table->num_indexes > H5O_SHMESG_MAX_NINDEXES) + if (table->num_indexes > H5O_SHMESG_MAX_NINDEXES) HGOTO_ERROR(H5E_SOHM, H5E_BADRANGE, FAIL, "number of indexes in property list is too large") /* Check that type flags weren't duplicated anywhere */ type_flags_used = 0; - for(x = 0; x < table->num_indexes; ++x) { - if(index_type_flags[x] & type_flags_used) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "the same shared message type flag is assigned to more than one index") + for (x = 0; x < table->num_indexes; ++x) { + if (index_type_flags[x] & type_flags_used) + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "the same shared message type flag is assigned to more than one index") type_flags_used |= index_type_flags[x]; } /* end for */ @@ -182,23 +173,24 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) HDassert(table->num_indexes > 0 && table->num_indexes <= H5O_SHMESG_MAX_NINDEXES); /* Allocate the SOHM indexes as an array. */ - if(NULL == (table->indexes = (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM indexes") + if (NULL == (table->indexes = + (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) + HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM indexes") /* Initialize all of the indexes, but don't allocate space for them to * hold messages until we actually need to write to them. */ - for(x = 0; x < table->num_indexes; x++) { - table->indexes[x].btree_min = btree_min; - table->indexes[x].list_max = list_max; - table->indexes[x].mesg_types = index_type_flags[x]; + for (x = 0; x < table->num_indexes; x++) { + table->indexes[x].btree_min = btree_min; + table->indexes[x].list_max = list_max; + table->indexes[x].mesg_types = index_type_flags[x]; table->indexes[x].min_mesg_size = minsizes[x]; - table->indexes[x].index_addr = HADDR_UNDEF; - table->indexes[x].heap_addr = HADDR_UNDEF; - table->indexes[x].num_messages = 0; + table->indexes[x].index_addr = HADDR_UNDEF; + table->indexes[x].heap_addr = HADDR_UNDEF; + table->indexes[x].num_messages = 0; /* Indexes start as lists unless the list-to-btree threshold is zero */ - if(table->indexes[x].list_max > 0) + if (table->indexes[x].list_max > 0) table->indexes[x].index_type = H5SM_LIST; else table->indexes[x].index_type = H5SM_BTREE; @@ -208,11 +200,11 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) } /* end for */ /* Allocate space for the table on disk */ - if(HADDR_UNDEF == (table_addr = H5MF_alloc(f, H5FD_MEM_SOHM_TABLE, (hsize_t)table->table_size))) + if (HADDR_UNDEF == (table_addr = H5MF_alloc(f, H5FD_MEM_SOHM_TABLE, (hsize_t)table->table_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "file allocation failed for SOHM table") /* Cache the new table */ - if(H5AC_insert_entry(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINS, FAIL, "can't add SOHM table to cache") /* Record the address of the master table in the file */ @@ -221,35 +213,35 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) /* Check for sharing attributes in this file, which means that creation * indices must be tracked on object header message in the file. */ - if(type_flags_used & H5O_SHMESG_ATTR_FLAG) + if (type_flags_used & H5O_SHMESG_ATTR_FLAG) H5F_SET_STORE_MSG_CRT_IDX(f, TRUE); /* Set the ring type to superblock extension */ H5AC_set_ring(H5AC_RING_SBE, NULL); /* Write shared message information to the superblock extension */ - sohm_table.addr = H5F_SOHM_ADDR(f); - sohm_table.version = H5F_SOHM_VERS(f); + sohm_table.addr = H5F_SOHM_ADDR(f); + sohm_table.version = H5F_SOHM_VERS(f); sohm_table.nindexes = H5F_SOHM_NINDEXES(f); - if(H5O_msg_create(ext_loc, H5O_SHMESG_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &sohm_table) < 0) + if (H5O_msg_create(ext_loc, H5O_SHMESG_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, + H5O_UPDATE_TIME, &sohm_table) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to update SOHM header message") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - if(ret_value < 0) { - if(table_addr != HADDR_UNDEF) + if (ret_value < 0) { + if (table_addr != HADDR_UNDEF) H5MF_xfree(f, H5FD_MEM_SOHM_TABLE, table_addr, (hsize_t)table->table_size); - if(table != NULL) + if (table != NULL) table = H5FL_FREE(H5SM_master_table_t, table); } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_init() */ - /*------------------------------------------------------------------------- * Function: H5SM__type_to_flag * @@ -265,12 +257,12 @@ done: static herr_t H5SM__type_to_flag(unsigned type_id, unsigned *type_flag) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Translate the H5O type_id into an H5SM type flag */ - switch(type_id) { + switch (type_id) { case H5O_FILL_ID: type_id = H5O_FILL_NEW_ID; /* Fall through... */ @@ -292,7 +284,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__type_to_flag() */ - /*------------------------------------------------------------------------- * Function: H5SM_get_index * @@ -312,21 +303,21 @@ done: ssize_t H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id) { - size_t x; + size_t x; unsigned type_flag; - ssize_t ret_value = FAIL; + ssize_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT /* Translate the H5O type_id into an H5SM type flag */ - if(H5SM__type_to_flag(type_id, &type_flag) < 0) + if (H5SM__type_to_flag(type_id, &type_flag) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't map message type to flag") /* Search the indexes until we find one that matches this flag or we've * searched them all. */ - for(x = 0; x < table->num_indexes; ++x) - if(table->indexes[x].mesg_types & type_flag) + for (x = 0; x < table->num_indexes; ++x) + if (table->indexes[x].mesg_types & type_flag) HGOTO_DONE((ssize_t)x) /* At this point, ret_value is either the location of the correct @@ -336,7 +327,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_get_index() */ - /*------------------------------------------------------------------------- * Function: H5SM_type_shared * @@ -352,25 +342,26 @@ done: htri_t H5SM_type_shared(H5F_t *f, unsigned type_id) { - H5SM_master_table_t *table = NULL; /* Shared object master table */ - unsigned type_flag; /* Flag corresponding to message type */ - size_t u; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + H5SM_master_table_t *table = NULL; /* Shared object master table */ + unsigned type_flag; /* Flag corresponding to message type */ + size_t u; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(H5AC__SOHM_TAG) /* Translate the H5O type_id into an H5SM type flag */ - if(H5SM__type_to_flag(type_id, &type_flag) < 0) + if (H5SM__type_to_flag(type_id, &type_flag) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't map message type to flag") /* Look up the master SOHM table */ - if(H5F_addr_defined(H5F_SOHM_ADDR(f))) { - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + if (H5F_addr_defined(H5F_SOHM_ADDR(f))) { + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ /* Set up user data for callback */ cache_udata.f = f; - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") } /* end if */ else @@ -380,19 +371,18 @@ H5SM_type_shared(H5F_t *f, unsigned type_id) /* Search the indexes until we find one that matches this flag or we've * searched them all. */ - for(u = 0; u < table->num_indexes; u++) - if(table->indexes[u].mesg_types & type_flag) + for (u = 0; u < table->num_indexes; u++) + if (table->indexes[u].mesg_types & type_flag) HGOTO_DONE(TRUE) done: /* Release the master SOHM table */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_type_shared() */ - /*------------------------------------------------------------------------- * Function: H5SM_get_fheap_addr * @@ -409,10 +399,10 @@ done: herr_t H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) { - H5SM_master_table_t *table = NULL; /* Shared object master table */ - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ - ssize_t index_num; /* Which index */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_master_table_t * table = NULL; /* Shared object master table */ + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + ssize_t index_num; /* Which index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -424,11 +414,12 @@ H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Look up index for message type */ - if((index_num = H5SM_get_index(table, type_id)) < 0) + if ((index_num = H5SM_get_index(table, type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to find correct SOHM index") /* Retrieve heap address for index */ @@ -436,13 +427,12 @@ H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) done: /* Release the master SOHM table */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_get_fheap_addr() */ - /*------------------------------------------------------------------------- * Function: H5SM__create_index * @@ -458,10 +448,10 @@ done: static herr_t H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) { - H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - herr_t ret_value = SUCCEED; + H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -471,11 +461,11 @@ H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) HDassert(header->btree_min <= header->list_max + 1); /* In most cases, the index starts as a list */ - if(header->list_max > 0) { - haddr_t list_addr = HADDR_UNDEF; /* Address of SOHM list */ + if (header->list_max > 0) { + haddr_t list_addr = HADDR_UNDEF; /* Address of SOHM list */ /* Create the list index */ - if(HADDR_UNDEF == (list_addr = H5SM__create_list(f, header))) + if (HADDR_UNDEF == (list_addr = H5SM__create_list(f, header))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "list creation failed for SOHM index") /* Set the index type & address */ @@ -484,20 +474,20 @@ H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) } /* end if */ /* index is a B-tree */ else { - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - haddr_t tree_addr = HADDR_UNDEF; /* Address of SOHM B-tree */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + haddr_t tree_addr = HADDR_UNDEF; /* Address of SOHM B-tree */ /* Create the v2 B-tree index */ - bt2_cparam.cls = H5SM_INDEX; - bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; - bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); + bt2_cparam.cls = H5SM_INDEX; + bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; + bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, &bt2_cparam, f))) + if (NULL == (bt2 = H5B2_create(f, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2, &tree_addr) < 0) + if (H5B2_get_addr(bt2, &tree_addr) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for SOHM index") /* Set the index type & address */ @@ -507,42 +497,41 @@ H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) /* Create a heap to hold the shared messages that the list or B-tree will index */ HDmemset(&fheap_cparam, 0, sizeof(fheap_cparam)); - fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; + fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; fheap_cparam.managed.start_block_size = H5O_FHEAP_MAN_START_BLOCK_SIZE; - fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; - fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; - fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; - fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; - fheap_cparam.id_len = 0; - fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; - if(NULL == (fheap = H5HF_create(f, &fheap_cparam))) + fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; + fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; + fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; + fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; + fheap_cparam.id_len = 0; + fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; + if (NULL == (fheap = H5HF_create(f, &fheap_cparam))) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to create fractal heap") - if(H5HF_get_heap_addr(fheap, &(header->heap_addr)) < 0) + if (H5HF_get_heap_addr(fheap, &(header->heap_addr)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address") #ifndef NDEBUG -{ - size_t fheap_id_len; /* Size of a fractal heap ID */ + { + size_t fheap_id_len; /* Size of a fractal heap ID */ - /* Sanity check ID length */ - if(H5HF_get_id_len(fheap, &fheap_id_len) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") - HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); -} + /* Sanity check ID length */ + if (H5HF_get_id_len(fheap, &fheap_id_len) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") + HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); + } #endif /* NDEBUG */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__create_index */ - /*------------------------------------------------------------------------- * Function: H5SM__delete_index * @@ -565,57 +554,56 @@ done: static herr_t H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, hbool_t delete_heap) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Determine whether index is a list or a B-tree. */ - if(header->index_type == H5SM_LIST) { - unsigned index_status = 0; /* Index list's status in the metadata cache */ + if (header->index_type == H5SM_LIST) { + unsigned index_status = 0; /* Index list's status in the metadata cache */ /* Check the index list's status in the metadata cache */ - if(H5AC_get_entry_status(f, header->index_addr, &index_status) < 0) + if (H5AC_get_entry_status(f, header->index_addr, &index_status) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check metadata cache status for direct block") /* If the index list is in the cache, expunge it now */ - if(index_status & H5AC_ES__IN_CACHE) { + if (index_status & H5AC_ES__IN_CACHE) { /* Sanity checks on index list */ HDassert(!(index_status & H5AC_ES__IS_PINNED)); HDassert(!(index_status & H5AC_ES__IS_PROTECTED)); /* Evict the index list from the metadata cache */ - if(H5AC_expunge_entry(f, H5AC_SOHM_LIST, header->index_addr, H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (H5AC_expunge_entry(f, H5AC_SOHM_LIST, header->index_addr, H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "unable to remove list index from cache") } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(header->index_type == H5SM_BTREE); /* Delete the B-tree. */ - if(H5B2_delete(f, header->index_addr, f, NULL, NULL) < 0) + if (H5B2_delete(f, header->index_addr, f, NULL, NULL) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") /* Revert to list unless B-trees can have zero records */ - if(header->btree_min > 0) + if (header->btree_min > 0) header->index_type = H5SM_LIST; } /* end else */ /* Free the index's heap if requested. */ - if(delete_heap == TRUE) { - if(H5HF_delete(f, header->heap_addr) < 0) + if (delete_heap == TRUE) { + if (H5HF_delete(f, header->heap_addr) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") header->heap_addr = HADDR_UNDEF; } /* end if */ /* Reset index info */ - header->index_addr = HADDR_UNDEF; + header->index_addr = HADDR_UNDEF; header->num_messages = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__delete_index */ - /*------------------------------------------------------------------------- * Function: H5SM__create_list * @@ -634,11 +622,11 @@ done: static haddr_t H5SM__create_list(H5F_t *f, H5SM_index_header_t *header) { - H5SM_list_t *list = NULL; /* List of messages */ - hsize_t x; /* Counter variable */ - size_t num_entries; /* Number of messages to create in list */ - haddr_t addr = HADDR_UNDEF; /* Address of the list on disk */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5SM_list_t *list = NULL; /* List of messages */ + hsize_t x; /* Counter variable */ + size_t num_entries; /* Number of messages to create in list */ + haddr_t addr = HADDR_UNDEF; /* Address of the list on disk */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) @@ -648,44 +636,43 @@ H5SM__create_list(H5F_t *f, H5SM_index_header_t *header) num_entries = header->list_max; /* Allocate list in memory */ - if(NULL == (list = H5FL_CALLOC(H5SM_list_t))) + if (NULL == (list = H5FL_CALLOC(H5SM_list_t))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list") - if(NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_CALLOC(H5SM_sohm_t, num_entries))) + if (NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_CALLOC(H5SM_sohm_t, num_entries))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list") /* Initialize messages in list */ - for(x = 0; x < num_entries; x++) + for (x = 0; x < num_entries; x++) list->messages[x].location = H5SM_NO_LOC; /* Point list at header passed in */ list->header = header; /* Allocate space for the list on disk */ - if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_SOHM_INDEX, (hsize_t)header->list_size))) + if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_SOHM_INDEX, (hsize_t)header->list_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list") /* Put the list into the cache */ - if(H5AC_insert_entry(f, H5AC_SOHM_LIST, addr, list, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_SOHM_LIST, addr, list, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINS, HADDR_UNDEF, "can't add SOHM list to cache") /* Set return value */ ret_value = addr; done: - if(ret_value == HADDR_UNDEF) { - if(list != NULL) { - if(list->messages != NULL) + if (ret_value == HADDR_UNDEF) { + if (list != NULL) { + if (list->messages != NULL) list->messages = H5FL_ARR_FREE(H5SM_sohm_t, list->messages); list = H5FL_FREE(H5SM_list_t, list); } /* end if */ - if(addr != HADDR_UNDEF) + if (addr != HADDR_UNDEF) H5MF_xfree(f, H5FD_MEM_SOHM_INDEX, addr, (hsize_t)header->list_size); } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM__create_list */ - /*------------------------------------------------------------------------- * Function: H5SM__convert_list_to_btree * @@ -708,18 +695,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, - H5SM_list_t **_list, H5HF_t *fheap, H5O_t *open_oh) +H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, H5SM_list_t **_list, H5HF_t *fheap, + H5O_t *open_oh) { - H5SM_list_t *list; /* Pointer to the existing message list */ - H5SM_mesg_key_t key; /* Key for inserting records in v2 B-tree */ - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - haddr_t tree_addr; /* New v2 B-tree's address */ - size_t num_messages; /* Number of messages being tracked */ - size_t x; - void * encoding_buf = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_list_t * list; /* Pointer to the existing message list */ + H5SM_mesg_key_t key; /* Key for inserting records in v2 B-tree */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + haddr_t tree_addr; /* New v2 B-tree's address */ + size_t num_messages; /* Number of messages being tracked */ + size_t x; + void * encoding_buf = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -730,76 +717,76 @@ H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, list = *_list; /* Create the new v2 B-tree for tracking the messages */ - bt2_cparam.cls = H5SM_INDEX; - bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; - bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); + bt2_cparam.cls = H5SM_INDEX; + bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; + bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, &bt2_cparam, f))) + if (NULL == (bt2 = H5B2_create(f, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2, &tree_addr) < 0) + if (H5B2_get_addr(bt2, &tree_addr) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for SOHM index") /* Set up key values that all messages will use. Since these messages * are in the heap, they have a heap ID and no encoding or type_id. */ - key.file = f; - key.fheap = fheap; + key.file = f; + key.fheap = fheap; key.encoding_size = 0; - key.encoding = NULL; + key.encoding = NULL; /* Insert each record into the new B-tree */ - for(x = 0; x < header->list_max; x++) { - if(list->messages[x].location != H5SM_NO_LOC) { + for (x = 0; x < header->list_max; x++) { + if (list->messages[x].location != H5SM_NO_LOC) { /* Copy message into key */ key.message = list->messages[x]; /* Get the encoded message */ - if(H5SM__read_mesg(f, &(key.message), fheap, open_oh, &key.encoding_size, &encoding_buf) < 0) + if (H5SM__read_mesg(f, &(key.message), fheap, open_oh, &key.encoding_size, &encoding_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, FAIL, "Couldn't read SOHM message in list") key.encoding = encoding_buf; /* Insert the message into the B-tree */ - if(H5B2_insert(bt2, &key) < 0) + if (H5B2_insert(bt2, &key) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "couldn't add SOHM to B-tree") /* Free buffer from H5SM__read_mesg */ - if(encoding_buf) + if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); } /* end if */ - } /* end for */ + } /* end for */ /* Unprotect list in cache and release heap */ - if(H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release SOHM list") *_list = list = NULL; /* Delete the old list index (but not its heap, which the new index is * still using!) */ - num_messages = header->num_messages; /* preserve this across the index deletion */ - if(H5SM__delete_index(f, header, FALSE) < 0) + num_messages = header->num_messages; /* preserve this across the index deletion */ + if (H5SM__delete_index(f, header, FALSE) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "can't free list index") /* Set/restore header info */ - header->index_addr = tree_addr; - header->index_type = H5SM_BTREE; + header->index_addr = tree_addr; + header->index_type = H5SM_BTREE; header->num_messages = num_messages; done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") - if(encoding_buf) + if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5SM__convert_list_to_btree() */ - /*------------------------------------------------------------------------- * Function: H5SM__convert_btree_to_list * @@ -815,12 +802,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5SM__convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header) +H5SM__convert_btree_to_list(H5F_t *f, H5SM_index_header_t *header) { - H5SM_list_t *list = NULL; - H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - haddr_t btree_addr; - herr_t ret_value = SUCCEED; + H5SM_list_t * list = NULL; + H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + haddr_t btree_addr; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) @@ -830,35 +817,35 @@ H5SM__convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header) btree_addr = header->index_addr; header->num_messages = 0; - header->index_type = H5SM_LIST; + header->index_type = H5SM_LIST; /* Create a new list index */ - if(HADDR_UNDEF == (header->index_addr = H5SM__create_list(f, header))) + if (HADDR_UNDEF == (header->index_addr = H5SM__create_list(f, header))) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to create shared message list") /* Set up user data for metadata cache callback */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.header = header; /* Protect the SOHM list */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM list index") /* Delete the B-tree and have messages copy themselves to the * list as they're deleted */ - if(H5B2_delete(f, btree_addr, f, H5SM_bt2_convert_to_list_op, list) < 0) + if (H5B2_delete(f, btree_addr, f, H5SM_bt2_convert_to_list_op, list) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") done: /* Release the SOHM list from the cache */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to unprotect SOHM index") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM__convert_btree_to_list() */ - /*------------------------------------------------------------------------- * Function: H5SM_can_share_common * @@ -880,19 +867,19 @@ done: static htri_t H5SM_can_share_common(const H5F_t *f, unsigned type_id, const void *mesg) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check whether this message ought to be shared or not */ /* If sharing is disabled in this file, don't share the message */ - if(!H5F_addr_defined(H5F_SOHM_ADDR(f))) + if (!H5F_addr_defined(H5F_SOHM_ADDR(f))) HGOTO_DONE(FALSE) /* Type-specific check */ - if((ret_value = H5O_msg_can_share(type_id, mesg)) < 0) + if ((ret_value = H5O_msg_can_share(type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "can_share callback returned error") - if(ret_value == FALSE) + if (ret_value == FALSE) HGOTO_DONE(FALSE) /* At this point, the message passes the "trivial" checks and is worth @@ -903,7 +890,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_can_share_common() */ - /*------------------------------------------------------------------------- * Function: H5SM_can_share * @@ -922,64 +908,65 @@ done: *------------------------------------------------------------------------- */ htri_t -H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, - ssize_t *sohm_index_num, unsigned type_id, const void *mesg) +H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, unsigned type_id, + const void *mesg) { - size_t mesg_size; + size_t mesg_size; H5SM_master_table_t *my_table = NULL; - ssize_t index_num; - htri_t tri_ret; - htri_t ret_value = TRUE; + ssize_t index_num; + htri_t tri_ret; + htri_t ret_value = TRUE; FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) /* "trivial" sharing checks */ - if((tri_ret = H5SM_can_share_common(f, type_id, mesg)) < 0) + if ((tri_ret = H5SM_can_share_common(f, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'trivial' sharing checks returned error") - if(tri_ret == FALSE) + if (tri_ret == FALSE) HGOTO_DONE(FALSE) /* Look up the master SOHM table */ /* (use incoming master SOHM table if possible) */ - if(table) + if (table) my_table = table; else { - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ /* Set up user data for callback */ cache_udata.f = f; - if(NULL == (my_table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (my_table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") } /* end if */ /* Find the right index for this message type. If there is no such index * then this type of message isn't shareable */ - if((index_num = H5SM_get_index(my_table, type_id)) < 0) { + if ((index_num = H5SM_get_index(my_table, type_id)) < 0) { H5E_clear_stack(NULL); /*ignore error*/ HGOTO_DONE(FALSE) } /* end if */ /* If the message isn't big enough, don't bother sharing it */ - if(0 == (mesg_size = H5O_msg_raw_size(f, type_id, TRUE, mesg))) + if (0 == (mesg_size = H5O_msg_raw_size(f, type_id, TRUE, mesg))) HGOTO_ERROR(H5E_SOHM, H5E_BADMESG, FAIL, "unable to get OH message size") - if(mesg_size < my_table->indexes[index_num].min_mesg_size) + if (mesg_size < my_table->indexes[index_num].min_mesg_size) HGOTO_DONE(FALSE) /* At this point, the message will be shared, set the index number if requested. */ - if(sohm_index_num) + if (sohm_index_num) *sohm_index_num = index_num; done: /* Release the master SOHM table, if we protected it */ - if(my_table && my_table != table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) + if (my_table && my_table != table && + H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_can_share() */ - /*------------------------------------------------------------------------- * Function: H5SM_try_share * @@ -1041,18 +1028,18 @@ done: *------------------------------------------------------------------------- */ htri_t -H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, - unsigned type_id, void *mesg, unsigned *mesg_flags) +H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, void *mesg, + unsigned *mesg_flags) { - H5SM_master_table_t *table = NULL; - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; - ssize_t index_num; - htri_t tri_ret; + H5SM_master_table_t * table = NULL; + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; + ssize_t index_num; + htri_t tri_ret; #ifndef NDEBUG - unsigned deferred_type = -1u; + unsigned deferred_type = -1u; #endif - htri_t ret_value = TRUE; + htri_t ret_value = TRUE; FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -1060,41 +1047,42 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, * be the same as the one we get here. In debug mode, we make sure this * holds true; otherwise we can leave now if it wasn't shared in the DEFER * pass. */ - if(defer_flags & H5SM_WAS_DEFERRED) + if (defer_flags & H5SM_WAS_DEFERRED) #ifndef NDEBUG deferred_type = ((H5O_shared_t *)mesg)->type; -#else /* NDEBUG */ - if((((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_HERE) - && (((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_SOHM)) +#else /* NDEBUG */ + if ((((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_HERE) && + (((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_SOHM)) HGOTO_DONE(FALSE); #endif /* NDEBUG */ /* "trivial" sharing checks */ - if(mesg_flags && (*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) + if (mesg_flags && (*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) HGOTO_DONE(FALSE) - if((tri_ret = H5SM_can_share_common(f, type_id, mesg)) < 0) + if ((tri_ret = H5SM_can_share_common(f, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'trivial' sharing checks returned error") - if(tri_ret == FALSE) + if (tri_ret == FALSE) HGOTO_DONE(FALSE) /* Set up user data for callback */ cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* "complex" sharing checks */ - if((tri_ret = H5SM_can_share(f, table, &index_num, type_id, mesg)) < 0) + if ((tri_ret = H5SM_can_share(f, table, &index_num, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'complex' sharing checks returned error") - if(tri_ret == FALSE) + if (tri_ret == FALSE) HGOTO_DONE(FALSE) /* At this point, the message will be shared. */ /* If the index hasn't been allocated yet, create it */ - if(table->indexes[index_num].index_addr == HADDR_UNDEF) { - if(H5SM__create_index(f, &(table->indexes[index_num])) < 0) + if (table->indexes[index_num].index_addr == HADDR_UNDEF) { + if (H5SM__create_index(f, &(table->indexes[index_num])) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to create SOHM index") cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ @@ -1102,41 +1090,39 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, /* Write the message as a shared message. This may or may not cause the * message to become shared (if it is unique, it will not be shared). */ - if(H5SM__write_mesg(f, open_oh, &(table->indexes[index_num]), - (defer_flags & H5SM_DEFER) != 0, type_id, mesg, &cache_flags) < 0) + if (H5SM__write_mesg(f, open_oh, &(table->indexes[index_num]), (defer_flags & H5SM_DEFER) != 0, type_id, + mesg, &cache_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "can't write shared message") /* Set flags if this message was "written" without error and wasn't a * 'defer' attempt; it is now either fully shared or "shareable". */ - if(mesg_flags) { - if(((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE) + if (mesg_flags) { + if (((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE) *mesg_flags |= H5O_MSG_FLAG_SHAREABLE; else { HDassert(((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM); *mesg_flags |= H5O_MSG_FLAG_SHARED; } /* end else */ - } /* end if */ + } /* end if */ done: - HDassert((ret_value != TRUE) - || ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE - || ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM); + HDassert((ret_value != TRUE) || ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE || + ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM); #ifndef NDEBUG /* If we previously deferred this operation, make sure the saved message * type is the same as the one we get here. */ - if(defer_flags & H5SM_WAS_DEFERRED) + if (defer_flags & H5SM_WAS_DEFERRED) HDassert(deferred_type == ((H5O_shared_t *)mesg)->type); #endif /* NDEBUG */ /* Release the master SOHM table */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_try_share() */ - /*------------------------------------------------------------------------- * Function: H5SM__incr_ref * @@ -1157,9 +1143,9 @@ done: static herr_t H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed) { - H5SM_sohm_t *message = (H5SM_sohm_t *) record; - H5SM_incr_ref_opdata *op_data = (H5SM_incr_ref_opdata *) _op_data; - herr_t ret_value = SUCCEED; + H5SM_sohm_t * message = (H5SM_sohm_t *)record; + H5SM_incr_ref_opdata *op_data = (H5SM_incr_ref_opdata *)_op_data; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1170,14 +1156,15 @@ H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed) /* If the message was previously shared in an object header, share * it in the heap now. */ - if(message->location == H5SM_IN_OH) { + if (message->location == H5SM_IN_OH) { HDassert(op_data->key && op_data->key->fheap); /* Put the message in the heap and record its new heap ID */ - if(H5HF_insert(op_data->key->fheap, op_data->key->encoding_size, op_data->key->encoding, &message->u.heap_loc.fheap_id) < 0) + if (H5HF_insert(op_data->key->fheap, op_data->key->encoding_size, op_data->key->encoding, + &message->u.heap_loc.fheap_id) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to insert message into fractal heap") - message->location = H5SM_IN_HEAP; + message->location = H5SM_IN_HEAP; message->u.heap_loc.ref_count = 2; } /* end if */ else { @@ -1190,14 +1177,13 @@ H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed) *changed = TRUE; /* Check for retrieving the heap ID */ - if(op_data) - op_data->fheap_id = message->u.heap_loc.fheap_id; + if (op_data) + op_data->fheap_id = message->u.heap_loc.fheap_id; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__incr_ref() */ - /*------------------------------------------------------------------------- * Function: H5SM__write_mesg * @@ -1231,20 +1217,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, - hbool_t defer, unsigned type_id, void *mesg, unsigned *cache_flags_ptr) +H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t defer, unsigned type_id, + void *mesg, unsigned *cache_flags_ptr) { - H5SM_list_t *list = NULL; /* List index */ - H5SM_mesg_key_t key; /* Key used to search the index */ - H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - H5O_shared_t shared; /* Shared H5O message */ - hbool_t found = FALSE; /* Was the message in the index? */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - size_t buf_size; /* Size of the encoded message */ - void * encoding_buf = NULL; /* Buffer for encoded message */ - size_t empty_pos = UFAIL; /* Empty entry in list */ - herr_t ret_value = SUCCEED; + H5SM_list_t * list = NULL; /* List index */ + H5SM_mesg_key_t key; /* Key used to search the index */ + H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + H5O_shared_t shared; /* Shared H5O message */ + hbool_t found = FALSE; /* Was the message in the index? */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + size_t buf_size; /* Size of the encoded message */ + void * encoding_buf = NULL; /* Buffer for encoded message */ + size_t empty_pos = UFAIL; /* Empty entry in list */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) @@ -1254,63 +1240,65 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, HDassert(cache_flags_ptr); /* Encode the message to be written */ - if((buf_size = H5O_msg_raw_size(f, type_id, TRUE, mesg)) == 0) + if ((buf_size = H5O_msg_raw_size(f, type_id, TRUE, mesg)) == 0) HGOTO_ERROR(H5E_SOHM, H5E_BADSIZE, FAIL, "can't find message size") - if(NULL == (encoding_buf = H5MM_malloc(buf_size))) + if (NULL == (encoding_buf = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "can't allocate buffer for encoding") - if(H5O_msg_encode(f, type_id, TRUE, (unsigned char *)encoding_buf, mesg) < 0) + if (H5O_msg_encode(f, type_id, TRUE, (unsigned char *)encoding_buf, mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, FAIL, "can't encode message to be shared") /* Open the fractal heap for this index */ - if(NULL == (fheap = H5HF_open(f, header->heap_addr))) + if (NULL == (fheap = H5HF_open(f, header->heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up a key for the message to be written */ - key.file = f; - key.fheap = fheap; - key.encoding = encoding_buf; - key.encoding_size = buf_size; - key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); + key.file = f; + key.fheap = fheap; + key.encoding = encoding_buf; + key.encoding_size = buf_size; + key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); key.message.location = H5SM_NO_LOC; /* Assume the message is already in the index and try to increment its * reference count. If this fails, the message isn't in the index after * all and we'll need to add it. */ - if(header->index_type == H5SM_LIST) { - size_t list_pos; /* Position in a list index */ + if (header->index_type == H5SM_LIST) { + size_t list_pos; /* Position in a list index */ /* Set up user data for metadata cache callback */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.header = header; /* The index is a list; get it from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, defer ? H5AC__READ_ONLY_FLAG : H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + defer ? H5AC__READ_ONLY_FLAG : H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") /* See if the message is already in the index and get its location. * Also record the first empty list position we find in case we need it * later. */ - if(H5SM__find_in_list(list, &key, &empty_pos, &list_pos) < 0) + if (H5SM__find_in_list(list, &key, &empty_pos, &list_pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to search for message in list") - if(defer) { - if(list_pos != UFAIL) + if (defer) { + if (list_pos != UFAIL) found = TRUE; } /* end if */ else { - if(list_pos != UFAIL) { + if (list_pos != UFAIL) { /* If the message was previously shared in an object header, share * it in the heap now. */ - if(list->messages[list_pos].location == H5SM_IN_OH) { + if (list->messages[list_pos].location == H5SM_IN_OH) { /* Put the message in the heap and record its new heap ID */ - if(H5HF_insert(fheap, key.encoding_size, key.encoding, &shared.u.heap_id) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to insert message into fractal heap") + if (H5HF_insert(fheap, key.encoding_size, key.encoding, &shared.u.heap_id) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, + "unable to insert message into fractal heap") - list->messages[list_pos].location = H5SM_IN_HEAP; - list->messages[list_pos].u.heap_loc.fheap_id = shared.u.heap_id; + list->messages[list_pos].location = H5SM_IN_HEAP; + list->messages[list_pos].u.heap_loc.fheap_id = shared.u.heap_id; list->messages[list_pos].u.heap_loc.ref_count = 2; } /* end if */ else { @@ -1321,27 +1309,27 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, /* Set up the shared location to point to the shared location */ shared.u.heap_id = list->messages[list_pos].u.heap_loc.fheap_id; - found = TRUE; + found = TRUE; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Index is a B-tree */ else { HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") - if(defer) { - htri_t bt2_find; /* Result from searching in the v2 B-tree */ + if (defer) { + htri_t bt2_find; /* Result from searching in the v2 B-tree */ /* If this returns 0, it means that the message wasn't found. */ /* If it return 1, set the heap_id in the shared struct. It will * return a heap ID, since a message with a reference count greater * than 1 is always shared in the heap. */ - if((bt2_find = H5B2_find(bt2, &key, NULL, NULL)) < 0) + if ((bt2_find = H5B2_find(bt2, &key, NULL, NULL)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "can't search for message in index") found = (hbool_t)bt2_find; } /* end if */ @@ -1356,16 +1344,16 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, * return a heap ID, since a message with a reference count greater * than 1 is always shared in the heap. */ - if(H5B2_modify(bt2, &key, H5SM__incr_ref, &op_data) >= 0) { + if (H5B2_modify(bt2, &key, H5SM__incr_ref, &op_data) >= 0) { shared.u.heap_id = op_data.fheap_id; - found = TRUE; + found = TRUE; } /* end if */ else H5E_clear_stack(NULL); /*ignore error*/ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ - if(found) { + if (found) { /* If the message was found, it's shared in the heap (now). Set up a * shared message so we can mark it as shared. */ @@ -1378,17 +1366,17 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, * checkers like valgrind from whining when the partially initialized * shared message is serialized. -QAK */ - if(defer) + if (defer) HDmemset(&shared.u, 0, sizeof(shared.u)); #endif /* H5_USING_MEMCHECKER */ - } /* end if */ + } /* end if */ else { - htri_t share_in_ohdr; /* Whether the new message can be shared in another object's header */ + htri_t share_in_ohdr; /* Whether the new message can be shared in another object's header */ /* Add the message to the index */ /* Check if the message can be shared in another object's header */ - if((share_in_ohdr = H5O_msg_can_share_in_ohdr(type_id)) < 0) + if ((share_in_ohdr = H5O_msg_can_share_in_ohdr(type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'share in ohdr' check returned error") /* If this message can be shared in an object header location, it is @@ -1408,59 +1396,59 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, * no object header location available, insert it in the * heap. */ - if(share_in_ohdr && open_oh) { + if (share_in_ohdr && open_oh) { /* Set up shared component info */ shared.type = H5O_SHARE_TYPE_HERE; /* Retrieve any creation index from the native message */ - if(H5O_msg_get_crt_index(type_id, mesg, &shared.u.loc.index) < 0) + if (H5O_msg_get_crt_index(type_id, mesg, &shared.u.loc.index) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to retrieve creation index") - if(defer) + if (defer) shared.u.loc.oh_addr = HADDR_UNDEF; else { shared.u.loc.oh_addr = H5O_OH_GET_ADDR(open_oh); /* Copy shared component info into key for inserting into index */ - key.message.location = H5SM_IN_OH; + key.message.location = H5SM_IN_OH; key.message.u.mesg_loc = shared.u.loc; } /* end else */ - } /* end if */ + } /* end if */ else { /* Set up shared component info */ /* (heap ID set below, if not deferred) */ shared.type = H5O_SHARE_TYPE_SOHM; - if(!defer) { + if (!defer) { /* Put the message in the heap and record its new heap ID */ - if(H5HF_insert(fheap, key.encoding_size, key.encoding, &shared.u.heap_id) < 0) + if (H5HF_insert(fheap, key.encoding_size, key.encoding, &shared.u.heap_id) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to insert message into fractal heap") - key.message.location = H5SM_IN_HEAP; - key.message.u.heap_loc.fheap_id = shared.u.heap_id; + key.message.location = H5SM_IN_HEAP; + key.message.u.heap_loc.fheap_id = shared.u.heap_id; key.message.u.heap_loc.ref_count = 1; } /* end if */ - } /* end else */ + } /* end else */ - if(!defer) { + if (!defer) { /* Set common information */ key.message.msg_type_id = type_id; /* Check whether the list has grown enough that it needs to become a B-tree */ - if(header->index_type == H5SM_LIST && header->num_messages >= header->list_max) - if(H5SM__convert_list_to_btree(f, header, &list, fheap, open_oh) < 0) + if (header->index_type == H5SM_LIST && header->num_messages >= header->list_max) + if (H5SM__convert_list_to_btree(f, header, &list, fheap, open_oh) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to convert list to B-tree") /* Insert the new message into the SOHM index */ - if(header->index_type == H5SM_LIST) { + if (header->index_type == H5SM_LIST) { /* Index is a list. Find an empty spot if we haven't already */ - if(empty_pos == UFAIL) { + if (empty_pos == UFAIL) { size_t pos; - if(H5SM__find_in_list(list, NULL, &empty_pos, &pos) < 0) + if (H5SM__find_in_list(list, NULL, &empty_pos, &pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to search for message in list") - if(pos == UFAIL || empty_pos == UFAIL) + if (pos == UFAIL || empty_pos == UFAIL) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to find empty entry in list") } /* Insert message into list */ @@ -1473,46 +1461,47 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree, if it isn't already */ - if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") + if (NULL == bt2) { + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for SOHM index") } /* end if */ - if(H5B2_insert(bt2, &key) < 0) + if (H5B2_insert(bt2, &key) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "couldn't add SOHM to B-tree") } /* end else */ ++(header->num_messages); (*cache_flags_ptr) |= H5AC__DIRTIED_FLAG; } /* end if */ - } /* end else */ + } /* end else */ /* Set the file pointer & message type for the shared component */ - shared.file = f; + shared.file = f; shared.msg_type_id = type_id; /* Update the original message's shared component */ - if(H5O_msg_set_share(type_id, &shared, mesg) < 0) + if (H5O_msg_set_share(type_id, &shared, mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADMESG, FAIL, "unable to set sharing information") done: /* Release the fractal heap & v2 B-tree if we opened them */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") /* If we got a list out of the cache, release it (it is always dirty after writing a message) */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") - if(encoding_buf) + if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM__write_mesg() */ - /*------------------------------------------------------------------------- * Function: H5SM_delete * @@ -1534,14 +1523,14 @@ done: herr_t H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) { - H5SM_master_table_t *table = NULL; + H5SM_master_table_t * table = NULL; unsigned cache_flags = H5AC__NO_FLAGS_SET; - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ ssize_t index_num; - size_t mesg_size = 0; - void *mesg_buf = NULL; - void *native_mesg = NULL; - unsigned type_id; /* Message type ID to operate on */ + size_t mesg_size = 0; + void * mesg_buf = NULL; + void * native_mesg = NULL; + unsigned type_id; /* Message type ID to operate on */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -1557,22 +1546,24 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Find the correct index and try to delete from it */ - if((index_num = H5SM_get_index(table, type_id)) < 0) + if ((index_num = H5SM_get_index(table, type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index") /* If mesg_buf is not NULL, the message's reference count has reached * zero and any file space it uses needs to be freed. mesg_buf holds the * serialized form of the message. */ - if(H5SM__delete_from_index(f, open_oh, &(table->indexes[index_num]), sh_mesg, &cache_flags, &mesg_size, &mesg_buf) < 0) + if (H5SM__delete_from_index(f, open_oh, &(table->indexes[index_num]), sh_mesg, &cache_flags, &mesg_size, + &mesg_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete mesage from SOHM index") /* Release the master SOHM table */ - if(H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) + if (H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") table = NULL; @@ -1580,31 +1571,31 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) * reference other shared messages that also need to be deleted, so the * master table needs to be unprotected when we do this. */ - if(mesg_buf) { - if(NULL == (native_mesg = H5O_msg_decode(f, open_oh, type_id, mesg_size, (const unsigned char *)mesg_buf))) + if (mesg_buf) { + if (NULL == + (native_mesg = H5O_msg_decode(f, open_oh, type_id, mesg_size, (const unsigned char *)mesg_buf))) HGOTO_ERROR(H5E_SOHM, H5E_CANTDECODE, FAIL, "can't decode shared message.") - if(H5O_msg_delete(f, open_oh, type_id, native_mesg) < 0) + if (H5O_msg_delete(f, open_oh, type_id, native_mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTFREE, FAIL, "can't delete shared message.") } /* end if */ done: /* Release the master SOHM table (should only happen on error) */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") /* Release any native message we decoded */ - if(native_mesg) + if (native_mesg) H5O_msg_free(type_id, native_mesg); /* Free encoding buf */ - if(mesg_buf) + if (mesg_buf) mesg_buf = H5MM_xfree(mesg_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_delete() */ - /*------------------------------------------------------------------------- * Function: H5SM__find_in_list * @@ -1630,7 +1621,7 @@ static herr_t H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t *empty_pos, size_t *pos) { size_t x; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1639,32 +1630,32 @@ H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t * HDassert(key || empty_pos); /* Initialize empty_pos to an invalid value */ - if(empty_pos) + if (empty_pos) *empty_pos = UFAIL; /* Find the first (only) message equal to the key passed in. * Also record the first empty position we find. */ - for(x = 0; x < list->header->list_max; x++) { - if(list->messages[x].location != H5SM_NO_LOC) { + for (x = 0; x < list->header->list_max; x++) { + if (list->messages[x].location != H5SM_NO_LOC) { int cmp; - if(H5SM__message_compare(key, &(list->messages[x]), &cmp) < 0) + if (H5SM__message_compare(key, &(list->messages[x]), &cmp) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTCOMPARE, FAIL, "can't compare message records") - if(0 == cmp) { + if (0 == cmp) { *pos = x; HGOTO_DONE(SUCCEED) } } - else if(empty_pos && list->messages[x].location == H5SM_NO_LOC) { + else if (empty_pos && list->messages[x].location == H5SM_NO_LOC) { /* Note position */ *empty_pos = x; /* Found earlier position possible, don't check any more */ empty_pos = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* If we reached this point, we didn't find the message */ *pos = UFAIL; @@ -1673,7 +1664,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__find_in_list */ - /*------------------------------------------------------------------------- * Function: H5SM_get_hash_fh_cb * @@ -1691,7 +1681,7 @@ done: herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5SM_fh_ud_gh_t *udata = (H5SM_fh_ud_gh_t *)_udata; /* User data for fractal heap 'op' callback */ + H5SM_fh_ud_gh_t *udata = (H5SM_fh_ud_gh_t *)_udata; /* User data for fractal heap 'op' callback */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1701,7 +1691,6 @@ H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_get_hash_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5SM__decr_ref * @@ -1724,7 +1713,7 @@ H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata) static herr_t H5SM__decr_ref(void *record, void *op_data, hbool_t *changed) { - H5SM_sohm_t *message = (H5SM_sohm_t *) record; + H5SM_sohm_t *message = (H5SM_sohm_t *)record; FUNC_ENTER_STATIC_NOERR @@ -1736,18 +1725,17 @@ H5SM__decr_ref(void *record, void *op_data, hbool_t *changed) * Messages stored in object headers always have refcounts of 1, * so the calling function should know to just delete such a message */ - if(message->location == H5SM_IN_HEAP) { + if (message->location == H5SM_IN_HEAP) { --message->u.heap_loc.ref_count; *changed = TRUE; } /* end if */ - if(op_data) - *(H5SM_sohm_t *)op_data = *message; + if (op_data) + *(H5SM_sohm_t *)op_data = *message; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__decr_ref() */ - /*------------------------------------------------------------------------- * Function: H5SM__delete_from_index * @@ -1766,19 +1754,18 @@ H5SM__decr_ref(void *record, void *op_data, hbool_t *changed) *------------------------------------------------------------------------- */ static herr_t -H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, - const H5O_shared_t *mesg, unsigned *cache_flags, size_t * /*out*/ mesg_size, - void ** /*out*/ encoded_mesg) +H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, const H5O_shared_t *mesg, + unsigned *cache_flags, size_t * /*out*/ mesg_size, void ** /*out*/ encoded_mesg) { - H5SM_list_t *list = NULL; + H5SM_list_t * list = NULL; H5SM_mesg_key_t key; - H5SM_sohm_t message; /* Deleted message returned from index */ - H5SM_sohm_t *message_ptr; /* Pointer to deleted message returned from index */ - H5HF_t *fheap = NULL; /* Fractal heap that contains the message */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - size_t buf_size; /* Size of the encoded message (out) */ - void *encoding_buf = NULL; /* The encoded message (out) */ - unsigned type_id; /* Message type to operate on */ + H5SM_sohm_t message; /* Deleted message returned from index */ + H5SM_sohm_t * message_ptr; /* Pointer to deleted message returned from index */ + H5HF_t * fheap = NULL; /* Fractal heap that contains the message */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + size_t buf_size; /* Size of the encoded message (out) */ + void * encoding_buf = NULL; /* The encoded message (out) */ + unsigned type_id; /* Message type to operate on */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) @@ -1794,55 +1781,56 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, type_id = mesg->msg_type_id; /* Open the heap for this type of message. */ - if(NULL == (fheap = H5HF_open(f, header->heap_addr))) + if (NULL == (fheap = H5HF_open(f, header->heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Get the message size and encoded message for the message to be deleted, * either from its OH or from the heap. */ - if(mesg->type == H5O_SHARE_TYPE_HERE) { - key.message.location = H5SM_IN_OH; + if (mesg->type == H5O_SHARE_TYPE_HERE) { + key.message.location = H5SM_IN_OH; key.message.msg_type_id = type_id; - key.message.u.mesg_loc = mesg->u.loc; + key.message.u.mesg_loc = mesg->u.loc; } /* end if */ else { - key.message.location = H5SM_IN_HEAP; - key.message.msg_type_id = type_id; + key.message.location = H5SM_IN_HEAP; + key.message.msg_type_id = type_id; key.message.u.heap_loc.ref_count = 0; /* Refcount isn't relevant here */ - key.message.u.heap_loc.fheap_id = mesg->u.heap_id; + key.message.u.heap_loc.fheap_id = mesg->u.heap_id; } /* end else */ /* Get the encoded message */ - if(H5SM__read_mesg(f, &key.message, fheap, open_oh, &buf_size, &encoding_buf) < 0) + if (H5SM__read_mesg(f, &key.message, fheap, open_oh, &buf_size, &encoding_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up key for message to be deleted. */ - key.file = f; - key.fheap = fheap; - key.encoding = encoding_buf; + key.file = f; + key.fheap = fheap; + key.encoding = encoding_buf; key.encoding_size = buf_size; - key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); + key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); /* Try to find the message in the index */ - if(header->index_type == H5SM_LIST) { - H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - size_t list_pos; /* Position of the message in the list */ + if (header->index_type == H5SM_LIST) { + H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + size_t list_pos; /* Position of the message in the list */ /* Set up user data for metadata cache callback */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.header = header; /* If the index is stored as a list, get it from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") /* Find the message in the list */ - if(H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) + if (H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to search for message in list") - if(list_pos == UFAIL) + if (list_pos == UFAIL) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") - if(list->messages[list_pos].location == H5SM_IN_HEAP) + if (list->messages[list_pos].location == H5SM_IN_HEAP) --(list->messages[list_pos].u.heap_loc.ref_count); /* Point to the message */ @@ -1853,13 +1841,13 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* If this returns failure, it means that the message wasn't found. * If it succeeds, a copy of the modified message will be returned. */ - if(H5B2_modify(bt2, &key, H5SM__decr_ref, &message) < 0) + if (H5B2_modify(bt2, &key, H5SM__decr_ref, &message) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") /* Point to the message */ @@ -1869,7 +1857,7 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, /* If the ref count is zero or this message was in an OH (which always * has a ref count of 1) delete the message from the index */ - if(message_ptr->location == H5SM_IN_OH || message_ptr->u.heap_loc.ref_count == 0) { + if (message_ptr->location == H5SM_IN_OH || message_ptr->u.heap_loc.ref_count == 0) { /* Save the location */ H5SM_storage_loc_t old_loc = message_ptr->location; @@ -1878,78 +1866,77 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, *cache_flags |= H5AC__DIRTIED_FLAG; /* Remove the message from the index */ - if(header->index_type == H5SM_LIST) + if (header->index_type == H5SM_LIST) message_ptr->location = H5SM_NO_LOC; else { /* Open the index v2 B-tree, if it isn't already */ - if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + if (NULL == bt2) { + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") } /* end if */ - if(H5B2_remove(bt2, &key, NULL, NULL) < 0) + if (H5B2_remove(bt2, &key, NULL, NULL) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "unable to delete message from index") } /* end else */ /* Remove the message from the heap if it was stored in the heap*/ - if(old_loc == H5SM_IN_HEAP) - if(H5HF_remove(fheap, &(message_ptr->u.heap_loc.fheap_id)) < 0) + if (old_loc == H5SM_IN_HEAP) + if (H5HF_remove(fheap, &(message_ptr->u.heap_loc.fheap_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "unable to remove message from heap") - /* Return the message's encoding so anything it references can be freed */ *encoded_mesg = encoding_buf; - *mesg_size = buf_size; + *mesg_size = buf_size; /* If there are no messages left in the index, delete it */ - if(header->num_messages == 0) { + if (header->num_messages == 0) { /* Unprotect cache and release heap */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release SOHM list") list = NULL; HDassert(fheap); - if(H5HF_close(fheap) < 0) + if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") fheap = NULL; /* Delete the index and its heap */ - if(H5SM__delete_index(f, header, TRUE) < 0) + if (H5SM__delete_index(f, header, TRUE) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "can't delete empty index") - } /* end if */ - else if(header->index_type == H5SM_BTREE && header->num_messages < header->btree_min) { + } /* end if */ + else if (header->index_type == H5SM_BTREE && header->num_messages < header->btree_min) { /* Otherwise, if we've just passed the btree-to-list cutoff, convert * this B-tree into a list */ - if(H5SM__convert_btree_to_list(f, header) < 0) + if (H5SM__convert_btree_to_list(f, header) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to convert btree to list") } /* end if */ - } /* end if */ + } /* end if */ done: /* Release the SOHM list */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") /* Release the fractal heap & v2 B-tree if we opened them */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") /* Free the message encoding, if we're not returning it in encoded_mesg * or if there's been an error. */ - if(encoding_buf && (NULL == *encoded_mesg || ret_value < 0)) { + if (encoding_buf && (NULL == *encoded_mesg || ret_value < 0)) { encoding_buf = H5MM_xfree(encoding_buf); - *mesg_size = 0; + *mesg_size = 0; } FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM__delete_from_index() */ - /*------------------------------------------------------------------------- * Function: H5SM_get_info * @@ -1965,13 +1952,13 @@ done: herr_t H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) { - H5F_t *f = ext_loc->file; /* File pointer (convenience variable) */ - H5O_shmesg_table_t sohm_table; /* SOHM message from superblock extension */ - H5SM_master_table_t *table = NULL; /* SOHM master table */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - unsigned tmp_sohm_nindexes; /* Number of shared messages indexes in the table */ - htri_t status; /* Status for message existing */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * f = ext_loc->file; /* File pointer (convenience variable) */ + H5O_shmesg_table_t sohm_table; /* SOHM message from superblock extension */ + H5SM_master_table_t *table = NULL; /* SOHM master table */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + unsigned tmp_sohm_nindexes; /* Number of shared messages indexes in the table */ + htri_t status; /* Status for message existing */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -1981,18 +1968,18 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) HDassert(fc_plist); /* Check for the extension having a 'shared message info' message */ - if((status = H5O_msg_exists(ext_loc, H5O_SHMESG_ID)) < 0) + if ((status = H5O_msg_exists(ext_loc, H5O_SHMESG_ID)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to read object header") - if(status) { - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ - unsigned index_flags[H5O_SHMESG_MAX_NINDEXES]; /* Message flags for each index */ - unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Minimum message size for each index */ - unsigned sohm_l2b; /* SOHM list-to-btree cutoff */ - unsigned sohm_b2l; /* SOHM btree-to-list cutoff */ - unsigned u; /* Local index variable */ + if (status) { + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + unsigned index_flags[H5O_SHMESG_MAX_NINDEXES]; /* Message flags for each index */ + unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Minimum message size for each index */ + unsigned sohm_l2b; /* SOHM list-to-btree cutoff */ + unsigned sohm_b2l; /* SOHM btree-to-list cutoff */ + unsigned u; /* Local index variable */ /* Retrieve the 'shared message info' structure */ - if(NULL == H5O_msg_read(ext_loc, H5O_SHMESG_ID, &sohm_table)) + if (NULL == H5O_msg_read(ext_loc, H5O_SHMESG_ID, &sohm_table)) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "shared message info message not present") /* Portably initialize the arrays */ @@ -2013,7 +2000,8 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) H5AC_set_ring(H5AC_RING_USER, &orig_ring); /* Read the rest of the SOHM table information from the cache */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Get index conversion limits */ @@ -2021,10 +2009,10 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) sohm_b2l = (unsigned)table->indexes[0].btree_min; /* Iterate through all indices */ - for(u = 0; u < table->num_indexes; ++u) { + for (u = 0; u < table->num_indexes; ++u) { /* Pack information about the individual SOHM index */ index_flags[u] = table->indexes[u].mesg_types; - minsizes[u] = (unsigned)table->indexes[u].min_mesg_size; + minsizes[u] = (unsigned)table->indexes[u].min_mesg_size; /* Sanity check */ HDassert(sohm_l2b == table->indexes[u].list_max); @@ -2033,21 +2021,21 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) /* Check for sharing attributes in this file, which means that creation * indices must be tracked on object header message in the file. */ - if(index_flags[u] & H5O_SHMESG_ATTR_FLAG) + if (index_flags[u] & H5O_SHMESG_ATTR_FLAG) H5F_SET_STORE_MSG_CRT_IDX(f, TRUE); } /* end for */ /* Set values in the property list */ tmp_sohm_nindexes = H5F_SOHM_NINDEXES(f); - if(H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &tmp_sohm_nindexes) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &tmp_sohm_nindexes) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTSET, FAIL, "can't set number of SOHM indexes") - if(H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, index_flags) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, index_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTSET, FAIL, "can't set type flags for indexes") - if(H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTSET, FAIL, "can't set type flags for indexes") - if(H5P_set(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &sohm_l2b) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &sohm_l2b) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't set SOHM cutoff in property list") - if(H5P_set(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &sohm_b2l) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &sohm_b2l) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't set SOHM cutoff in property list") } /* end if */ else { @@ -2058,23 +2046,22 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) /* Shared object header messages are disabled */ tmp_sohm_nindexes = H5F_SOHM_NINDEXES(f); - if(H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &tmp_sohm_nindexes) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &tmp_sohm_nindexes) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTSET, FAIL, "can't set number of SOHM indexes") } /* end else */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Release the master SOHM table if we took it out of the cache */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_get_info() */ - /*------------------------------------------------------------------------- * Function: H5SM_reconstitute * @@ -2089,8 +2076,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, - H5O_fheap_id_t heap_id) +H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, H5O_fheap_id_t heap_id) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2098,15 +2084,14 @@ H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, HDassert(sh_mesg); /* Set flag for shared message */ - sh_mesg->type = H5O_SHARE_TYPE_SOHM; - sh_mesg->file = f; + sh_mesg->type = H5O_SHARE_TYPE_SOHM; + sh_mesg->file = f; sh_mesg->msg_type_id = msg_type_id; - sh_mesg->u.heap_id = heap_id; + sh_mesg->u.heap_id = heap_id; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_reconstitute() */ - /*------------------------------------------------------------------------- * Function: H5SM_get_refcount_bt2_cb * @@ -2122,8 +2107,8 @@ H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, static herr_t H5SM_get_refcount_bt2_cb(const void *_record, void *_op_data) { - const H5SM_sohm_t *record = (const H5SM_sohm_t *)_record; /* v2 B-tree record for message */ - H5SM_sohm_t *op_data = (H5SM_sohm_t *)_op_data; /* "op data" from v2 B-tree find */ + const H5SM_sohm_t *record = (const H5SM_sohm_t *)_record; /* v2 B-tree record for message */ + H5SM_sohm_t * op_data = (H5SM_sohm_t *)_op_data; /* "op data" from v2 B-tree find */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2139,7 +2124,6 @@ H5SM_get_refcount_bt2_cb(const void *_record, void *_op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_get_refcount_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5SM_get_refcount * @@ -2153,21 +2137,20 @@ H5SM_get_refcount_bt2_cb(const void *_record, void *_op_data) *------------------------------------------------------------------------- */ herr_t -H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, - hsize_t *ref_count) +H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize_t *ref_count) { - H5HF_t *fheap = NULL; /* Fractal heap that contains shared messages */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - H5SM_master_table_t *table = NULL; /* SOHM master table */ - H5SM_table_cache_ud_t tbl_cache_udata; /* User-data for callback */ - H5SM_list_t *list = NULL; /* SOHM index list for message type (if in list form) */ - H5SM_index_header_t *header=NULL; /* Index header for message type */ - H5SM_mesg_key_t key; /* Key for looking up message */ - H5SM_sohm_t message; /* Shared message returned from callback */ - ssize_t index_num; /* Table index for message type */ - size_t buf_size; /* Size of the encoded message */ - void * encoding_buf = NULL; /* Buffer for encoded message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_t * fheap = NULL; /* Fractal heap that contains shared messages */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5SM_master_table_t * table = NULL; /* SOHM master table */ + H5SM_table_cache_ud_t tbl_cache_udata; /* User-data for callback */ + H5SM_list_t * list = NULL; /* SOHM index list for message type (if in list form) */ + H5SM_index_header_t * header = NULL; /* Index header for message type */ + H5SM_mesg_key_t key; /* Key for looking up message */ + H5SM_sohm_t message; /* Shared message returned from callback */ + ssize_t index_num; /* Table index for message type */ + size_t buf_size; /* Size of the encoded message */ + void * encoding_buf = NULL; /* Buffer for encoded message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(H5AC__SOHM_TAG) @@ -2180,70 +2163,72 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, tbl_cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Find the correct index and find the message in it */ - if((index_num = H5SM_get_index(table, type_id)) < 0) + if ((index_num = H5SM_get_index(table, type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index") header = &(table->indexes[index_num]); /* Open the heap for this message type */ - if(NULL == (fheap = H5HF_open(f, header->heap_addr))) + if (NULL == (fheap = H5HF_open(f, header->heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up a SOHM message to correspond to the shared message passed in */ - key.message.location = H5SM_IN_HEAP; - key.message.u.heap_loc.fheap_id = sh_mesg->u.heap_id; + key.message.location = H5SM_IN_HEAP; + key.message.u.heap_loc.fheap_id = sh_mesg->u.heap_id; key.message.u.heap_loc.ref_count = 0; /* Ref count isn't needed to find message */ /* Get the encoded message */ - if(H5SM__read_mesg(f, &key.message, fheap, NULL, &buf_size, &encoding_buf) < 0) + if (H5SM__read_mesg(f, &key.message, fheap, NULL, &buf_size, &encoding_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up key for message to locate */ - key.file = f; - key.fheap = fheap; - key.encoding = encoding_buf; + key.file = f; + key.fheap = fheap; + key.encoding = encoding_buf; key.encoding_size = buf_size; - key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); + key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); /* Try to find the message in the index */ - if(header->index_type == H5SM_LIST) { - H5SM_list_cache_ud_t lst_cache_udata; /* User-data for metadata cache callback */ - size_t list_pos; /* Position of the message in the list */ + if (header->index_type == H5SM_LIST) { + H5SM_list_cache_ud_t lst_cache_udata; /* User-data for metadata cache callback */ + size_t list_pos; /* Position of the message in the list */ /* Set up user data for metadata cache callback */ - lst_cache_udata.f = f; + lst_cache_udata.f = f; lst_cache_udata.header = header; /* If the index is stored as a list, get it from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, + &lst_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") /* Find the message in the list */ - if(H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) + if (H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to search for message in list") - if(list_pos == UFAIL) + if (list_pos == UFAIL) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") /* Copy the message */ message = list->messages[list_pos]; } /* end if */ else { - htri_t msg_exists; /* Whether the message exists in the v2 B-tree */ + htri_t msg_exists; /* Whether the message exists in the v2 B-tree */ /* Index is a B-tree */ HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* Look up the message in the v2 B-tree */ - if((msg_exists = H5B2_find(bt2, &key, H5SM_get_refcount_bt2_cb, &message)) < 0) + if ((msg_exists = H5B2_find(bt2, &key, H5SM_get_refcount_bt2_cb, &message)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "error finding message in index") - if(!msg_exists) + if (!msg_exists) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") } /* end else */ @@ -2253,21 +2238,20 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, done: /* Release resources */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__NO_FLAGS_SET) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") - if(encoding_buf) + if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_get_refcount() */ - /*------------------------------------------------------------------------- * Function: H5SM__read_iter_op * @@ -2287,11 +2271,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5SM_read_udata_t *udata = (H5SM_read_udata_t *) _udata; - herr_t ret_value = H5_ITER_CONT; + H5SM_read_udata_t *udata = (H5SM_read_udata_t *)_udata; + herr_t ret_value = H5_ITER_CONT; FUNC_ENTER_STATIC @@ -2304,10 +2288,10 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(NULL == udata->encoding_buf); /* Check the creation index for this message */ - if(sequence == udata->idx) { + if (sequence == udata->idx) { /* Check if the message is dirty & flush it to the object header if so */ - if(mesg->dirty) - if(H5O_msg_flush(udata->file, oh, mesg) < 0) + if (mesg->dirty) + if (H5O_msg_flush(udata->file, oh, mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") /* Get the message's encoded size */ @@ -2315,7 +2299,7 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(udata->buf_size); /* Allocate buffer to return the message in */ - if(NULL == (udata->encoding_buf = H5MM_malloc(udata->buf_size))) + if (NULL == (udata->encoding_buf = H5MM_malloc(udata->buf_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed") /* Copy the encoded message into the buffer to return */ @@ -2329,7 +2313,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__read_iter_op() */ - /*------------------------------------------------------------------------- * Function: H5SM__read_mesg_fh_cb * @@ -2347,13 +2330,13 @@ done: static herr_t H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5SM_read_udata_t *udata = (H5SM_read_udata_t *)_udata; - herr_t ret_value = SUCCEED; + H5SM_read_udata_t *udata = (H5SM_read_udata_t *)_udata; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Allocate a buffer to hold the message */ - if(NULL == (udata->encoding_buf = H5MM_malloc(obj_len))) + if (NULL == (udata->encoding_buf = H5MM_malloc(obj_len))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the message from the heap */ @@ -2364,7 +2347,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__read_mesg_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5SM__read_mesg * @@ -2379,13 +2361,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, - H5O_t *open_oh, size_t *encoding_size /*out*/, void ** encoded_mesg /*out*/) +H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, H5O_t *open_oh, + size_t *encoding_size /*out*/, void **encoded_mesg /*out*/) { - H5SM_read_udata_t udata; /* User data for callbacks */ - H5O_loc_t oloc; /* Object location for message in object header */ - H5O_t *oh = NULL; /* Object header for message in object header */ - herr_t ret_value = SUCCEED; + H5SM_read_udata_t udata; /* User data for callbacks */ + H5O_loc_t oloc; /* Object location for message in object header */ + H5O_t * oh = NULL; /* Object header for message in object header */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) @@ -2394,77 +2376,76 @@ H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, HDassert(fheap); /* Set up user data for message iteration */ - udata.file = f; - udata.idx = mesg->u.mesg_loc.index; + udata.file = f; + udata.idx = mesg->u.mesg_loc.index; udata.encoding_buf = NULL; - udata.idx = 0; + udata.idx = 0; /* Get the message size and encoded message for the message to be deleted, * either from its OH or from the heap. */ - if(mesg->location == H5SM_IN_OH) { + if (mesg->location == H5SM_IN_OH) { /* Read message from object header */ - const H5O_msg_class_t *type = NULL; /* Actual H5O class type for the ID */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + const H5O_msg_class_t *type = NULL; /* Actual H5O class type for the ID */ + H5O_mesg_operator_t op; /* Wrapper for operator */ - type = H5O_msg_class_g[mesg->msg_type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[mesg->msg_type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Reset object location for operation */ - if(H5O_loc_reset(&oloc) < 0) + if (H5O_loc_reset(&oloc) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTRESET, FAIL, "unable to initialize location") - if(NULL == open_oh || mesg->u.mesg_loc.oh_addr != H5O_OH_GET_ADDR(open_oh)) { + if (NULL == open_oh || mesg->u.mesg_loc.oh_addr != H5O_OH_GET_ADDR(open_oh)) { /* Open the object in the file */ oloc.file = f; oloc.addr = mesg->u.mesg_loc.oh_addr; - if(H5O_open(&oloc) < 0) + if (H5O_open(&oloc) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, FAIL, "unable to open object header") /* Load the object header from the cache */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load object header") } /* end if */ else oh = open_oh; /* Use the "real" iterate routine so it doesn't try to protect the OH */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5SM__read_iter_op; - if((ret_value = H5O__msg_iterate_real(f, oh, type, &op, &udata)) < 0) + if ((ret_value = H5O__msg_iterate_real(f, oh, type, &op, &udata)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADITER, FAIL, "unable to iterate over object header messages") } /* end if */ else { HDassert(mesg->location == H5SM_IN_HEAP); /* Copy the message from the heap */ - if(H5HF_op(fheap, &(mesg->u.heap_loc.fheap_id), H5SM__read_mesg_fh_cb, &udata) < 0) + if (H5HF_op(fheap, &(mesg->u.heap_loc.fheap_id), H5SM__read_mesg_fh_cb, &udata) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, FAIL, "can't read message from fractal heap.") } /* end else */ HDassert(udata.encoding_buf); HDassert(udata.buf_size); /* Record the returned values */ - *encoded_mesg = udata.encoding_buf; + *encoded_mesg = udata.encoding_buf; *encoding_size = udata.buf_size; done: /* Close the object header if we opened one and had an error */ - if(oh && oh != open_oh) { - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && oh != open_oh) { + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(H5O_close(&oloc, NULL) < 0) + if (H5O_close(&oloc, NULL) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close object header") } /* end if */ /* Release the encoding buffer on error */ - if(ret_value < 0 && udata.encoding_buf) + if (ret_value < 0 && udata.encoding_buf) udata.encoding_buf = H5MM_xfree(udata.encoding_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM__read_mesg */ - /*------------------------------------------------------------------------- * Function: H5SM_table_free * @@ -2493,7 +2474,6 @@ H5SM_table_free(H5SM_master_table_t *table) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_table_free() */ - /*------------------------------------------------------------------------- * Function: H5SM_list_free * @@ -2521,7 +2501,6 @@ H5SM_list_free(H5SM_list_t *list) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_list_free() */ - /*------------------------------------------------------------------------- * Function: H5SM_table_debug * @@ -2538,13 +2517,13 @@ H5SM_list_free(H5SM_list_t *list) *------------------------------------------------------------------------- */ herr_t -H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, - int fwidth, unsigned table_vers, unsigned num_indexes) +H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwidth, unsigned table_vers, + unsigned num_indexes) { - H5SM_master_table_t *table = NULL; /* SOHM master table */ - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ - unsigned x; /* Counter variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_master_table_t * table = NULL; /* SOHM master table */ + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + unsigned x; /* Counter variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -2557,60 +2536,61 @@ H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, /* If table_vers and num_indexes are UFAIL, replace them with values from * userblock */ - if(table_vers == UFAIL) + if (table_vers == UFAIL) table_vers = H5F_SOHM_VERS(f); - else if(table_vers != H5F_SOHM_VERS(f)) + else if (table_vers != H5F_SOHM_VERS(f)) HDfprintf(stream, "*** SOHM TABLE VERSION DOESN'T MATCH VERSION IN SUPERBLOCK!\n"); - if(num_indexes == UFAIL) + if (num_indexes == UFAIL) num_indexes = H5F_SOHM_NINDEXES(f); - else if(num_indexes != H5F_SOHM_NINDEXES(f)) + else if (num_indexes != H5F_SOHM_NINDEXES(f)) HDfprintf(stream, "*** NUMBER OF SOHM INDEXES DOESN'T MATCH VALUE IN SUPERBLOCK!\n"); /* Check arguments. Version must be 0, the only version implemented so far */ - if(table_vers > HDF5_SHAREDHEADER_VERSION) + if (table_vers > HDF5_SHAREDHEADER_VERSION) HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "unknown shared message table version") - if(num_indexes == 0 || num_indexes > H5O_SHMESG_MAX_NINDEXES) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES") + if (num_indexes == 0 || num_indexes > H5O_SHMESG_MAX_NINDEXES) + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES") /* Set up user data for callback */ cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &cache_udata, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") HDfprintf(stream, "%*sShared Message Master Table...\n", indent, ""); - for(x = 0; x < num_indexes; ++x) { + for (x = 0; x < num_indexes; ++x) { HDfprintf(stream, "%*sIndex %d...\n", indent, "", x); - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, - "SOHM Index Type:", - (table->indexes[x].index_type == H5SM_LIST ? "List" : - (table->indexes[x].index_type == H5SM_BTREE ? "B-Tree" : "Unknown"))); + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "SOHM Index Type:", + (table->indexes[x].index_type == H5SM_LIST + ? "List" + : (table->indexes[x].index_type == H5SM_BTREE ? "B-Tree" : "Unknown"))); HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", fwidth, - "Address of index:", table->indexes[x].index_addr); + "Address of index:", table->indexes[x].index_addr); HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", fwidth, - "Address of index's heap:", table->indexes[x].heap_addr); + "Address of index's heap:", table->indexes[x].heap_addr); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent + 3, "", fwidth, - "Message type flags:", table->indexes[x].mesg_types); + "Message type flags:", table->indexes[x].mesg_types); HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, - "Minimum size of messages:", table->indexes[x].min_mesg_size); + "Minimum size of messages:", table->indexes[x].min_mesg_size); HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, - "Number of messages:", table->indexes[x].num_messages); + "Number of messages:", table->indexes[x].num_messages); HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, - "Maximum list size:", table->indexes[x].list_max); + "Maximum list size:", table->indexes[x].list_max); HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, - "Minimum B-tree size:", table->indexes[x].btree_min); + "Minimum B-tree size:", table->indexes[x].btree_min); } /* end for */ done: - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_table_debug() */ - /*------------------------------------------------------------------------- * Function: H5SM_list_debug * @@ -2626,17 +2606,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, - int fwidth, haddr_t table_addr) +H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidth, haddr_t table_addr) { - H5SM_master_table_t *table = NULL; /* SOHM master table */ - H5SM_list_t *list = NULL; /* SOHM index list for message type (if in list form) */ - H5SM_list_cache_ud_t lst_cache_udata; /* List user-data for metadata cache callback */ - H5SM_table_cache_ud_t tbl_cache_udata; /* Table user-data for metadata cache callback */ - H5HF_t *fh = NULL; /* Fractal heap for SOHM messages */ - unsigned index_num; /* Index of list, within master table */ - unsigned x; /* Counter variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_master_table_t * table = NULL; /* SOHM master table */ + H5SM_list_t * list = NULL; /* SOHM index list for message type (if in list form) */ + H5SM_list_cache_ud_t lst_cache_udata; /* List user-data for metadata cache callback */ + H5SM_table_cache_ud_t tbl_cache_udata; /* Table user-data for metadata cache callback */ + H5HF_t * fh = NULL; /* Fractal heap for SOHM messages */ + unsigned index_num; /* Index of list, within master table */ + unsigned x; /* Counter variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -2650,75 +2629,74 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, tbl_cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Determine which index the list is part of */ index_num = table->num_indexes; - for(x = 0; x < table->num_indexes; x++) { - if(H5F_addr_eq(table->indexes[x].index_addr, list_addr)) { + for (x = 0; x < table->num_indexes; x++) { + if (H5F_addr_eq(table->indexes[x].index_addr, list_addr)) { index_num = x; break; } /* end if */ - } /* end for */ - if(x == table->num_indexes) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "list address doesn't match address for any indices in table") + } /* end for */ + if (x == table->num_indexes) + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "list address doesn't match address for any indices in table") /* Set up user data for metadata cache callback */ - lst_cache_udata.f = f; + lst_cache_udata.f = f; lst_cache_udata.header = &(table->indexes[index_num]); /* Get the list from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, + H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") /* Open the heap, if one exists */ - if(H5F_addr_defined(table->indexes[index_num].heap_addr)) - if(NULL == (fh = H5HF_open(f, table->indexes[index_num].heap_addr))) + if (H5F_addr_defined(table->indexes[index_num].heap_addr)) + if (NULL == (fh = H5HF_open(f, table->indexes[index_num].heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open SOHM heap") HDfprintf(stream, "%*sShared Message List Index...\n", indent, ""); - for(x = 0; x < table->indexes[index_num].num_messages; ++x) { + for (x = 0; x < table->indexes[index_num].num_messages; ++x) { HDfprintf(stream, "%*sShared Object Header Message %d...\n", indent, "", x); HDfprintf(stream, "%*s%-*s %08lu\n", indent + 3, "", fwidth, - "Hash value:", (unsigned long)list->messages[x].hash); - if(list->messages[x].location == H5SM_IN_HEAP) { + "Hash value:", (unsigned long)list->messages[x].hash); + if (list->messages[x].location == H5SM_IN_HEAP) { HDassert(fh); - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, - "Location:", "in heap"); + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "Location:", "in heap"); HDfprintf(stream, "%*s%-*s 0x%Zx\n", indent + 3, "", fwidth, - "Heap ID:", list->messages[x].u.heap_loc.fheap_id); + "Heap ID:", list->messages[x].u.heap_loc.fheap_id); HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth, - "Reference count:", list->messages[x].u.heap_loc.ref_count); + "Reference count:", list->messages[x].u.heap_loc.ref_count); } /* end if */ - else if(list->messages[x].location == H5SM_IN_OH) { - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, - "Location:", "in object header"); + else if (list->messages[x].location == H5SM_IN_OH) { + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "Location:", "in object header"); HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", fwidth, - "Object header address:", list->messages[x].u.mesg_loc.oh_addr); + "Object header address:", list->messages[x].u.mesg_loc.oh_addr); HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth, - "Message creation index:", list->messages[x].u.mesg_loc.oh_addr); + "Message creation index:", list->messages[x].u.mesg_loc.oh_addr); HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth, - "Message type ID:", list->messages[x].msg_type_id); + "Message type ID:", list->messages[x].msg_type_id); } /* end if */ else - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, - "Location:", "invalid"); + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "Location:", "invalid"); } /* end for */ done: - if(fh && H5HF_close(fh) < 0) + if (fh && H5HF_close(fh) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close SOHM heap") - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, list_addr, list, H5AC__NO_FLAGS_SET) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, list_addr, list, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_list_debug() */ - /*------------------------------------------------------------------------- * Function: H5SM_ih_size * @@ -2738,12 +2716,12 @@ done: herr_t H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info) { - H5SM_master_table_t *table = NULL; /* SOHM master table */ - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_master_table_t * table = NULL; /* SOHM master table */ + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -2757,61 +2735,61 @@ H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info) cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Get SOHM header size */ *hdr_size = table->table_size; /* Loop over all the indices for shared messages */ - for(u = 0; u < table->num_indexes; u++) { + for (u = 0; u < table->num_indexes; u++) { /* Get index storage size (for either B-tree or list) */ - if(table->indexes[u].index_type == H5SM_BTREE) { - if(H5F_addr_defined(table->indexes[u].index_addr)) { + if (table->indexes[u].index_type == H5SM_BTREE) { + if (H5F_addr_defined(table->indexes[u].index_addr)) { /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, table->indexes[u].index_addr, f))) + if (NULL == (bt2 = H5B2_open(f, table->indexes[u].index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") - if(H5B2_size(bt2, &(ih_info->index_size)) < 0) + if (H5B2_size(bt2, &(ih_info->index_size)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") bt2 = NULL; } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(table->indexes[u].index_type == H5SM_LIST); - ih_info->index_size += table->indexes[u].list_size; + ih_info->index_size += table->indexes[u].list_size; } /* end else */ /* Check for heap for this index */ - if(H5F_addr_defined(table->indexes[u].heap_addr)) { + if (H5F_addr_defined(table->indexes[u].heap_addr)) { /* Open the fractal heap for this index */ - if(NULL == (fheap = H5HF_open(f, table->indexes[u].heap_addr))) + if (NULL == (fheap = H5HF_open(f, table->indexes[u].heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Get heap storage size */ - if(H5HF_size(fheap, &(ih_info->heap_size)) < 0) + if (H5HF_size(fheap, &(ih_info->heap_size)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't retrieve fractal heap storage info") /* Close the fractal heap */ - if(H5HF_close(fheap) < 0) + if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") fheap = NULL; } /* end if */ - } /* end for */ + } /* end for */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_ih_size() */ - diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index 7f6c804..9b9e407 100644 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -15,60 +15,54 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object Headers */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* v2 B-tree callbacks */ -static void *H5SM__bt2_crt_context(void *udata); +static void * H5SM__bt2_crt_context(void *udata); static herr_t H5SM__bt2_dst_context(void *ctx); static herr_t H5SM__bt2_store(void *native, const void *udata); -static herr_t H5SM__bt2_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); - +static herr_t H5SM__bt2_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); /*****************************/ /* Library Private Variables */ /*****************************/ /* v2 B-tree class for SOHM indexes*/ -const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ - H5B2_SOHM_INDEX_ID, /* Type of B-tree */ - "H5B2_SOHM_INDEX_ID", /* Name of B-tree class */ - sizeof(H5SM_sohm_t), /* Size of native record */ - H5SM__bt2_crt_context, /* Create client callback context */ - H5SM__bt2_dst_context, /* Destroy client callback context */ - H5SM__bt2_store, /* Record storage callback */ - H5SM__message_compare, /* Record comparison callback */ - H5SM__message_encode, /* Record encoding callback */ - H5SM__message_decode, /* Record decoding callback */ - H5SM__bt2_debug /* Record debugging callback */ +const H5B2_class_t H5SM_INDEX[1] = {{ + /* B-tree class information */ + H5B2_SOHM_INDEX_ID, /* Type of B-tree */ + "H5B2_SOHM_INDEX_ID", /* Name of B-tree class */ + sizeof(H5SM_sohm_t), /* Size of native record */ + H5SM__bt2_crt_context, /* Create client callback context */ + H5SM__bt2_dst_context, /* Destroy client callback context */ + H5SM__bt2_store, /* Record storage callback */ + H5SM__message_compare, /* Record comparison callback */ + H5SM__message_encode, /* Record encoding callback */ + H5SM__message_decode, /* Record decoding callback */ + H5SM__bt2_debug /* Record debugging callback */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -76,8 +70,6 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ /* Declare a free list to manage the H5SM_bt2_ctx_t struct */ H5FL_DEFINE_STATIC(H5SM_bt2_ctx_t); - - /*------------------------------------------------------------------------- * Function: H5SM__bt2_crt_context * @@ -94,9 +86,9 @@ H5FL_DEFINE_STATIC(H5SM_bt2_ctx_t); static void * H5SM__bt2_crt_context(void *_f) { - H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ - H5SM_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ + H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ + H5SM_bt2_ctx_t *ctx; /* Callback context structure */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -104,7 +96,7 @@ H5SM__bt2_crt_context(void *_f) HDassert(f); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of addresses & lengths in the file */ @@ -117,7 +109,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5SM__bt2_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5SM__bt2_dst_context * @@ -134,7 +125,7 @@ done: static herr_t H5SM__bt2_dst_context(void *_ctx) { - H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -147,7 +138,6 @@ H5SM__bt2_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5SM__bt2_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5SM__bt2_store * @@ -176,7 +166,6 @@ H5SM__bt2_store(void *native, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__bt2_store */ - /*------------------------------------------------------------------------- * Function: H5SM__bt2_debug * @@ -191,28 +180,26 @@ H5SM__bt2_store(void *native, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5SM__bt2_debug(FILE *stream, int indent, int fwidth, - const void *record, const void H5_ATTR_UNUSED *_udata) +H5SM__bt2_debug(FILE *stream, int indent, int fwidth, const void *record, const void H5_ATTR_UNUSED *_udata) { const H5SM_sohm_t *sohm = (const H5SM_sohm_t *)record; FUNC_ENTER_STATIC_NOERR - if(sohm->location == H5SM_IN_HEAP) + if (sohm->location == H5SM_IN_HEAP) HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx}\n", indent, "", fwidth, - "Shared Message in heap:", - sohm->u.heap_loc.fheap_id, sohm->hash, sohm->u.heap_loc.ref_count); + "Shared Message in heap:", sohm->u.heap_loc.fheap_id, sohm->hash, + sohm->u.heap_loc.ref_count); else { HDassert(sohm->location == H5SM_IN_OH); HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx, %Hx}\n", indent, "", fwidth, - "Shared Message in OH:", - sohm->u.mesg_loc.oh_addr, sohm->hash, sohm->msg_type_id, sohm->u.mesg_loc.index); + "Shared Message in OH:", sohm->u.mesg_loc.oh_addr, sohm->hash, sohm->msg_type_id, + sohm->u.mesg_loc.index); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__bt2_debug */ - /*------------------------------------------------------------------------- * Function: H5SM_bt2_convert_to_list_op * @@ -230,11 +217,11 @@ H5SM__bt2_debug(FILE *stream, int indent, int fwidth, *------------------------------------------------------------------------- */ herr_t -H5SM_bt2_convert_to_list_op(const void * record, void *op_data) +H5SM_bt2_convert_to_list_op(const void *record, void *op_data) { const H5SM_sohm_t *message = (const H5SM_sohm_t *)record; - const H5SM_list_t *list = (const H5SM_list_t *)op_data; - size_t mesg_idx; /* Index of message to modify */ + const H5SM_list_t *list = (const H5SM_list_t *)op_data; + size_t mesg_idx; /* Index of message to modify */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -253,4 +240,3 @@ H5SM_bt2_convert_to_list_op(const void * record, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_bt2_convert_to_list_op() */ - diff --git a/src/H5SMcache.c b/src/H5SMcache.c index 998fe9b..5f20e05 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -26,31 +26,27 @@ /* Module Setup */ /****************/ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ - +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ /* Headers */ /***********/ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5SMpkg.h" /* Shared object header messages */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5SMpkg.h" /* Shared object header messages */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -58,76 +54,67 @@ /* Metadata cache (H5AC) callbacks */ static herr_t H5SM__cache_table_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5SM__cache_table_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5SM__cache_table_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5SM__cache_table_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5SM__cache_table_image_len(const void *thing, size_t *image_len); -static herr_t H5SM__cache_table_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5SM__cache_table_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5SM__cache_table_free_icr(void *thing); static herr_t H5SM__cache_list_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5SM__cache_list_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *H5SM__cache_list_deserialize(const void *image, size_t len, - void *udata, hbool_t *dirty); +static void * H5SM__cache_list_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5SM__cache_list_image_len(const void *thing, size_t *image_len); -static herr_t H5SM__cache_list_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +static herr_t H5SM__cache_list_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5SM__cache_list_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5SM inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_SOHM_TABLE[1] = {{ - H5AC_SOHM_TABLE_ID, /* Metadata client ID */ - "shared message table", /* Metadata client name (for debugging) */ - H5FD_MEM_SOHM_TABLE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5SM__cache_table_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5SM__cache_table_verify_chksum, /* 'verify_chksum' callback */ - H5SM__cache_table_deserialize, /* 'deserialize' callback */ - H5SM__cache_table_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5SM__cache_table_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5SM__cache_table_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* 'refresh' callback */ + H5AC_SOHM_TABLE_ID, /* Metadata client ID */ + "shared message table", /* Metadata client name (for debugging) */ + H5FD_MEM_SOHM_TABLE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5SM__cache_table_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5SM__cache_table_verify_chksum, /* 'verify_chksum' callback */ + H5SM__cache_table_deserialize, /* 'deserialize' callback */ + H5SM__cache_table_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5SM__cache_table_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5SM__cache_table_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* 'refresh' callback */ }}; const H5AC_class_t H5AC_SOHM_LIST[1] = {{ - H5AC_SOHM_LIST_ID, /* Metadata client ID */ - "shared message list", /* Metadata client name (for debugging) */ - H5FD_MEM_SOHM_TABLE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5SM__cache_list_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5SM__cache_list_verify_chksum, /* 'verify_chksum' callback */ - H5SM__cache_list_deserialize, /* 'deserialize' callback */ - H5SM__cache_list_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5SM__cache_list_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5SM__cache_list_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ - NULL, /* 'refresh' callback */ + H5AC_SOHM_LIST_ID, /* Metadata client ID */ + "shared message list", /* Metadata client name (for debugging) */ + H5FD_MEM_SOHM_TABLE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5SM__cache_list_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5SM__cache_list_verify_chksum, /* 'verify_chksum' callback */ + H5SM__cache_list_deserialize, /* 'deserialize' callback */ + H5SM__cache_list_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5SM__cache_list_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5SM__cache_list_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ + NULL, /* 'refresh' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_get_initial_load_size() * @@ -145,7 +132,7 @@ const H5AC_class_t H5AC_SOHM_LIST[1] = {{ static herr_t H5SM__cache_table_get_initial_load_size(void *_udata, size_t *image_len) { - const H5SM_table_cache_ud_t *udata = (const H5SM_table_cache_ud_t *)_udata; /* User data for callback */ + const H5SM_table_cache_ud_t *udata = (const H5SM_table_cache_ud_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -160,7 +147,6 @@ H5SM__cache_table_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__cache_table_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_verify_chksum * @@ -177,10 +163,10 @@ H5SM__cache_table_get_initial_load_size(void *_udata, size_t *image_len) htri_t H5SM__cache_table_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -190,13 +176,12 @@ H5SM__cache_table_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_table_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_deserialize * @@ -214,16 +199,16 @@ H5SM__cache_table_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU *------------------------------------------------------------------------- */ static void * -H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { - H5F_t *f; /* File pointer -- from user data */ - H5SM_master_table_t *table = NULL; /* Shared message table that we deserializing */ - H5SM_table_cache_ud_t *udata = (H5SM_table_cache_ud_t *)_udata; /* Pointer to user data */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into input buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - size_t u; /* Counter variable for index headers */ - void *ret_value = NULL; /* Return value */ + H5F_t * f; /* File pointer -- from user data */ + H5SM_master_table_t * table = NULL; /* Shared message table that we deserializing */ + H5SM_table_cache_ud_t *udata = (H5SM_table_cache_ud_t *)_udata; /* Pointer to user data */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into input buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + size_t u; /* Counter variable for index headers */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -241,7 +226,7 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HDassert(H5F_SOHM_VERS(f) == HDF5_SHAREDHEADER_VERSION); /* Allocate space for the master table in memory */ - if(NULL == (table = H5FL_CALLOC(H5SM_master_table_t))) + if (NULL == (table = H5FL_CALLOC(H5SM_master_table_t))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "memory allocation failed") /* Read number of indexes and version from file superblock */ @@ -255,22 +240,23 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HDassert(table->table_size == len); /* Check magic number */ - if(HDmemcmp(image, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "bad SOHM table signature") image += H5_SIZEOF_MAGIC; /* Allocate space for the index headers in memory*/ - if(NULL == (table->indexes = (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) + if (NULL == (table->indexes = + (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "memory allocation failed for SOHM indexes") /* Read in the index headers */ - for(u = 0; u < table->num_indexes; ++u) { + for (u = 0; u < table->num_indexes; ++u) { /* Verify correct version of index list */ - if(H5SM_LIST_VERSION != *image++) + if (H5SM_LIST_VERSION != *image++) HGOTO_ERROR(H5E_SOHM, H5E_VERSION, NULL, "bad shared message list version number") /* Type of the index (list or B-tree) */ - table->indexes[u].index_type= (H5SM_index_type_t)*image++; + table->indexes[u].index_type = (H5SM_index_type_t)*image++; /* Type of messages in the index */ UINT16DECODE(image, table->indexes[u].mesg_types); @@ -293,7 +279,7 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l /* Address of the index's heap */ H5F_addr_decode(f, &image, &(table->indexes[u].heap_addr)); - /* Compute the size of a list index for this SOHM index */ + /* Compute the size of a list index for this SOHM index */ table->indexes[u].list_size = H5SM_LIST_SIZE(f, table->indexes[u].list_max); } /* end for */ @@ -309,14 +295,13 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l ret_value = table; done: - if(!ret_value && table) - if(H5SM_table_free(table) < 0) + if (!ret_value && table) + if (H5SM_table_free(table) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTFREE, NULL, "unable to destroy sohm table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_table_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_image_len * @@ -335,7 +320,8 @@ done: static herr_t H5SM__cache_table_image_len(const void *_thing, size_t *image_len) { - const H5SM_master_table_t *table = (const H5SM_master_table_t *)_thing; /* Shared message table to query */ + const H5SM_master_table_t *table = + (const H5SM_master_table_t *)_thing; /* Shared message table to query */ FUNC_ENTER_STATIC_NOERR @@ -350,7 +336,6 @@ H5SM__cache_table_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__cache_table_image_len() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_serialize * @@ -366,13 +351,12 @@ H5SM__cache_table_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5SM_master_table_t *table = (H5SM_master_table_t *)_thing; /* Shared message table to encode */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - size_t u; /* Counter variable */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + size_t u; /* Counter variable */ FUNC_ENTER_STATIC_NOERR @@ -394,7 +378,7 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ image += H5_SIZEOF_MAGIC; /* Encode each index header */ - for(u = 0; u < table->num_indexes; ++u) { + for (u = 0; u < table->num_indexes; ++u) { /* Version for this list */ *image++ = H5SM_LIST_VERSION; @@ -437,7 +421,6 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ /* no H5SM_cache_table_notify() function */ /*****************************************/ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_free_icr * @@ -458,8 +441,8 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ static herr_t H5SM__cache_table_free_icr(void *_thing) { - H5SM_master_table_t *table = (H5SM_master_table_t *)_thing; /* Shared message table to release */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_master_table_t *table = (H5SM_master_table_t *)_thing; /* Shared message table to release */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -469,14 +452,13 @@ H5SM__cache_table_free_icr(void *_thing) HDassert(table->cache_info.type == H5AC_SOHM_TABLE); /* Destroy Shared Object Header Message table */ - if(H5SM_table_free(table) < 0) + if (H5SM_table_free(table) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTRELEASE, FAIL, "unable to free shared message table") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_cache_table_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_get_initial_load_size() * @@ -495,7 +477,7 @@ done: static herr_t H5SM__cache_list_get_initial_load_size(void *_udata, size_t *image_len) { - const H5SM_list_cache_ud_t *udata = (const H5SM_list_cache_ud_t *)_udata; /* User data for callback */ + const H5SM_list_cache_ud_t *udata = (const H5SM_list_cache_ud_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -511,7 +493,6 @@ H5SM__cache_list_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__cache_list_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_verify_chksum * @@ -528,12 +509,12 @@ H5SM__cache_list_get_initial_load_size(void *_udata, size_t *image_len) htri_t H5SM__cache_list_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5SM_list_cache_ud_t *udata = (H5SM_list_cache_ud_t *)_udata; /* User data for callback */ - size_t chk_size; /* Exact size of the node with checksum at the end */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5SM_list_cache_ud_t *udata = (H5SM_list_cache_ud_t *)_udata; /* User data for callback */ + size_t chk_size; /* Exact size of the node with checksum at the end */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -547,13 +528,12 @@ H5SM__cache_list_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo /* Get stored and computed checksums */ H5F_get_checksums(image, chk_size, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_list_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_deserialize * @@ -570,16 +550,16 @@ H5SM__cache_list_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo *------------------------------------------------------------------------- */ static void * -H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) { - H5SM_list_t *list = NULL; /* The SOHM list being read in */ - H5SM_list_cache_ud_t *udata = (H5SM_list_cache_ud_t *)_udata; /* User data for callback */ - H5SM_bt2_ctx_t ctx; /* Message encoding context */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into input buffer */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - size_t u; /* Counter variable for messages in list */ - void *ret_value = NULL; /* Return value */ + H5SM_list_t * list = NULL; /* The SOHM list being read in */ + H5SM_list_cache_ud_t *udata = (H5SM_list_cache_ud_t *)_udata; /* User data for callback */ + H5SM_bt2_ctx_t ctx; /* Message encoding context */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into input buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + size_t u; /* Counter variable for messages in list */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -592,24 +572,24 @@ H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED le HDassert(dirty); /* Allocate space for the SOHM list data structure */ - if(NULL == (list = H5FL_MALLOC(H5SM_list_t))) + if (NULL == (list = H5FL_MALLOC(H5SM_list_t))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "memory allocation failed") HDmemset(&list->cache_info, 0, sizeof(H5AC_info_t)); /* Allocate list in memory as an array*/ - if(NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_MALLOC(H5SM_sohm_t, udata->header->list_max))) + if (NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_MALLOC(H5SM_sohm_t, udata->header->list_max))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "file allocation failed for SOHM list") list->header = udata->header; /* Check magic number */ - if(HDmemcmp(image, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "bad SOHM list signature") image += H5_SIZEOF_MAGIC; /* Read messages into the list array */ ctx.sizeof_addr = H5F_SIZEOF_ADDR(udata->f); - for(u = 0; u < udata->header->num_messages; u++) { - if(H5SM__message_decode(image, &(list->messages[u]), &ctx) < 0) + for (u = 0; u < udata->header->num_messages; u++) { + if (H5SM__message_decode(image, &(list->messages[u]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "can't decode shared message") image += H5SM_SOHM_ENTRY_SIZE(udata->f); @@ -624,15 +604,15 @@ H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED le HDassert((size_t)(image - (const uint8_t *)_image) <= udata->header->list_size); /* Initialize the rest of the array */ - for(u = udata->header->num_messages; u < udata->header->list_max; u++) + for (u = udata->header->num_messages; u < udata->header->list_max; u++) list->messages[u].location = H5SM_NO_LOC; /* Set return value */ ret_value = list; done: - if(!ret_value && list) { - if(list->messages) + if (!ret_value && list) { + if (list->messages) list->messages = H5FL_ARR_FREE(H5SM_sohm_t, list->messages); list = H5FL_FREE(H5SM_list_t, list); } /* end if */ @@ -640,7 +620,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_list_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_image_len * @@ -657,7 +636,7 @@ done: static herr_t H5SM__cache_list_image_len(const void *_thing, size_t *image_len) { - const H5SM_list_t *list = (const H5SM_list_t *)_thing; /* Shared message list to query */ + const H5SM_list_t *list = (const H5SM_list_t *)_thing; /* Shared message list to query */ FUNC_ENTER_STATIC_NOERR @@ -673,7 +652,6 @@ H5SM__cache_list_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__cache_list_image_len() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_serialize * @@ -689,16 +667,15 @@ H5SM__cache_list_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5SM_list_t *list = (H5SM_list_t *)_thing ; /* Instance being serialized */ - H5SM_bt2_ctx_t ctx; /* Message encoding context */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - size_t mesgs_serialized; /* Number of messages serialized */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_list_t * list = (H5SM_list_t *)_thing; /* Instance being serialized */ + H5SM_bt2_ctx_t ctx; /* Message encoding context */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + size_t mesgs_serialized; /* Number of messages serialized */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -717,16 +694,16 @@ H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_U /* serialize messages from the messages array */ mesgs_serialized = 0; - ctx.sizeof_addr = H5F_SIZEOF_ADDR(f); - for(u = 0; ((u < list->header->list_max) && (mesgs_serialized < list->header->num_messages)); u++) { - if(list->messages[u].location != H5SM_NO_LOC) { - if(H5SM__message_encode(image, &(list->messages[u]), &ctx) < 0) + ctx.sizeof_addr = H5F_SIZEOF_ADDR(f); + for (u = 0; ((u < list->header->list_max) && (mesgs_serialized < list->header->num_messages)); u++) { + if (list->messages[u].location != H5SM_NO_LOC) { + if (H5SM__message_encode(image, &(list->messages[u]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTFLUSH, FAIL, "unable to serialize shared message") image += H5SM_SOHM_ENTRY_SIZE(f); ++mesgs_serialized; } /* end if */ - } /* end for */ + } /* end for */ HDassert(mesgs_serialized == list->header->num_messages); @@ -748,7 +725,6 @@ done: /* no H5SM_cache_list_notify() function */ /****************************************/ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_free_icr * @@ -769,8 +745,8 @@ done: static herr_t H5SM__cache_list_free_icr(void *_thing) { - H5SM_list_t *list = (H5SM_list_t *)_thing; /* Shared message list to release */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_list_t *list = (H5SM_list_t *)_thing; /* Shared message list to release */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -780,10 +756,9 @@ H5SM__cache_list_free_icr(void *_thing) HDassert(list->cache_info.type == H5AC_SOHM_LIST); /* Destroy Shared Object Header Message list */ - if(H5SM_list_free(list) < 0) + if (H5SM_list_free(list) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTRELEASE, FAIL, "unable to free shared message list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_cache_list_free_icr() */ - diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c index e085204..606bd47 100644 --- a/src/H5SMmessage.c +++ b/src/H5SMmessage.c @@ -15,25 +15,22 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object Headers */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -41,35 +38,29 @@ /* Udata struct for calls to H5SM_compare_cb and H5SM_compare_iter_op*/ typedef struct H5SM_compare_udata_t { const H5SM_mesg_key_t *key; /* Key; compare this against stored message */ - H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ - herr_t ret; /* Return value; set this to result of memcmp */ + H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ + herr_t ret; /* Return value; set this to result of memcmp */ } H5SM_compare_udata_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t H5SM_compare_cb(const void *obj, size_t obj_len, void *udata); -static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, - unsigned *oh_modified, void *udata); - +static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, unsigned *oh_modified, + void *udata); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5SM_compare_cb * @@ -94,9 +85,9 @@ H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) FUNC_ENTER_NOAPI_NOINIT_NOERR /* If the encoding sizes are different, it's not the same object */ - if(udata->key->encoding_size > obj_len) + if (udata->key->encoding_size > obj_len) udata->ret = 1; - else if(udata->key->encoding_size < obj_len) + else if (udata->key->encoding_size < obj_len) udata->ret = -1; else /* Sizes are the same. Return result of memcmp */ @@ -105,7 +96,6 @@ H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_compare_cb() */ - /*------------------------------------------------------------------------- * Function: H5SM_compare_iter_op * @@ -123,11 +113,11 @@ H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *) _udata; - herr_t ret_value = H5_ITER_CONT; + H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *)_udata; + herr_t ret_value = H5_ITER_CONT; FUNC_ENTER_NOAPI_NOINIT @@ -139,21 +129,22 @@ H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(udata && udata->key); /* Check the creation index for this message */ - if(sequence == udata->idx) { + if (sequence == udata->idx) { size_t aligned_encoded_size = H5O_ALIGN_OH(oh, udata->key->encoding_size); /* Sanity check the message's length */ HDassert(mesg->raw_size > 0); - if(aligned_encoded_size > mesg->raw_size) + if (aligned_encoded_size > mesg->raw_size) udata->ret = 1; - else if(aligned_encoded_size < mesg->raw_size) + else if (aligned_encoded_size < mesg->raw_size) udata->ret = -1; else { /* Check if the message is dirty & flush it to the object header if so */ - if(mesg->dirty) - if(H5O_msg_flush(udata->key->file, oh, mesg) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") + if (mesg->dirty) + if (H5O_msg_flush(udata->key->file, oh, mesg) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, + "unable to encode object header message") HDassert(udata->key->encoding_size <= mesg->raw_size); udata->ret = HDmemcmp(udata->key->encoding, mesg->raw, udata->key->encoding_size); @@ -167,7 +158,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_compare_iter_op() */ - /*------------------------------------------------------------------------- * Function: H5SM__message_compare * @@ -187,9 +177,9 @@ done: herr_t H5SM__message_compare(const void *rec1, const void *rec2, int *result) { - const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *) rec1; - const H5SM_sohm_t *mesg = (const H5SM_sohm_t *) rec2; - herr_t ret_value = SUCCEED; + const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *)rec1; + const H5SM_sohm_t * mesg = (const H5SM_sohm_t *)rec2; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -199,25 +189,25 @@ H5SM__message_compare(const void *rec1, const void *rec2, int *result) * Likewise, if the message has an OH location that is matched by the * message in the index, we've found the message. */ - if(mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { - if(key->message.u.heap_loc.fheap_id.val == mesg->u.heap_loc.fheap_id.val) { + if (mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { + if (key->message.u.heap_loc.fheap_id.val == mesg->u.heap_loc.fheap_id.val) { *result = 0; HGOTO_DONE(SUCCEED); } } /* end if */ - else if(mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { - if(key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && - key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && - key->message.msg_type_id == mesg->msg_type_id) { + else if (mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { + if (key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && + key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && + key->message.msg_type_id == mesg->msg_type_id) { *result = 0; HGOTO_DONE(SUCCEED); } } /* end if */ /* Compare hash values */ - if(key->message.hash > mesg->hash) + if (key->message.hash > mesg->hash) *result = 1; - else if(key->message.hash < mesg->hash) + else if (key->message.hash < mesg->hash) *result = -1; /* If the hash values match, make sure the messages are really the same */ else { @@ -235,21 +225,21 @@ H5SM__message_compare(const void *rec1, const void *rec2, int *result) /* Compare the encoded message with either the message in the heap or * the message in an object header. */ - if(mesg->location == H5SM_IN_HEAP) { + if (mesg->location == H5SM_IN_HEAP) { /* Call heap op routine with comparison callback */ - if(H5HF_op(key->fheap, &(mesg->u.heap_loc.fheap_id), H5SM_compare_cb, &udata) < 0) + if (H5HF_op(key->fheap, &(mesg->u.heap_loc.fheap_id), H5SM_compare_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ else { - H5O_loc_t oloc; /* Object owning the message */ - H5O_mesg_operator_t op; /* Message operator */ + H5O_loc_t oloc; /* Object owning the message */ + H5O_mesg_operator_t op; /* Message operator */ /* Sanity checks */ HDassert(key->file); HDassert(mesg->location == H5SM_IN_OH); /* Reset the object location */ - if(H5O_loc_reset(&oloc) < 0) + if (H5O_loc_reset(&oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") /* Set up object location */ @@ -260,9 +250,9 @@ H5SM__message_compare(const void *rec1, const void *rec2, int *result) udata.idx = mesg->u.mesg_loc.index; /* Locate the right message and compare with it */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5SM_compare_iter_op; - if(H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata) < 0) + if (H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over links") } /* end else */ @@ -273,7 +263,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__message_compare */ - /*------------------------------------------------------------------------- * Function: H5SM__message_encode * @@ -290,7 +279,7 @@ done: herr_t H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_bt2_ctx_t * ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5SM_sohm_t *message = (const H5SM_sohm_t *)_nrecord; FUNC_ENTER_PACKAGE_NOERR @@ -301,14 +290,14 @@ H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) *raw++ = (uint8_t)message->location; UINT32ENCODE(raw, message->hash); - if(message->location == H5SM_IN_HEAP) { + if (message->location == H5SM_IN_HEAP) { UINT32ENCODE(raw, message->u.heap_loc.ref_count); H5MM_memcpy(raw, message->u.heap_loc.fheap_id.id, (size_t)H5O_FHEAP_ID_LEN); } /* end if */ else { HDassert(message->location == H5SM_IN_OH); - *raw++ = 0; /* reserved (possible flags byte) */ + *raw++ = 0; /* reserved (possible flags byte) */ *raw++ = (uint8_t)message->msg_type_id; UINT16ENCODE(raw, message->u.mesg_loc.index); H5F_addr_encode_len((size_t)ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); @@ -317,7 +306,6 @@ H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__message_encode */ - /*------------------------------------------------------------------------- * Function: H5SM__message_decode * @@ -334,22 +322,22 @@ H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) herr_t H5SM__message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ - H5SM_sohm_t *message = (H5SM_sohm_t *)_nrecord; + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_sohm_t * message = (H5SM_sohm_t *)_nrecord; FUNC_ENTER_PACKAGE_NOERR message->location = (H5SM_storage_loc_t)*raw++; UINT32DECODE(raw, message->hash); - if(message->location == H5SM_IN_HEAP) { + if (message->location == H5SM_IN_HEAP) { UINT32DECODE(raw, message->u.heap_loc.ref_count); H5MM_memcpy(message->u.heap_loc.fheap_id.id, raw, (size_t)H5O_FHEAP_ID_LEN); } /* end if */ else { HDassert(message->location == H5SM_IN_OH); - raw++; /* reserved */ + raw++; /* reserved */ message->msg_type_id = *raw++; UINT16DECODE(raw, message->u.mesg_loc.index); H5F_addr_decode_len((size_t)ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); @@ -357,4 +345,3 @@ H5SM__message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__message_decode */ - diff --git a/src/H5SMmodule.h b/src/H5SMmodule.h index 656c7dd..4961720 100644 --- a/src/H5SMmodule.h +++ b/src/H5SMmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5SM_MODULE -#define H5_MY_PKG H5SM -#define H5_MY_PKG_ERR H5E_SOHM -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5SM +#define H5_MY_PKG_ERR H5E_SOHM +#define H5_MY_PKG_INIT NO #endif /* _H5SMmodule_H */ - diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index bb458a7..296dd5a 100644 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -27,13 +27,12 @@ #define _H5SMpkg_H /* Get package's private header */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata Cache */ -#include "H5B2private.h" /* B-trees */ -#include "H5HFprivate.h" /* Fractal heaps */ - +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5B2private.h" /* B-trees */ +#include "H5HFprivate.h" /* Fractal heaps */ /****************************/ /* Package Macros */ @@ -42,61 +41,59 @@ /* Size of checksum information (on disk) */ #define H5SM_SIZEOF_CHECKSUM 4 -#define H5SM_HEAP_LOC_SIZE ( \ - (unsigned)4 /* Reference count */ \ - + sizeof(H5O_fheap_id_t) /* size of heap ID on disk */ \ +#define H5SM_HEAP_LOC_SIZE \ + ((unsigned)4 /* Reference count */ \ + + sizeof(H5O_fheap_id_t) /* size of heap ID on disk */ \ ) -#define H5SM_OH_LOC_SIZE(f) ( \ - (unsigned)1 /* reserved (possible flags?) */ \ - + (unsigned)1 /* message type ID */ \ - + (unsigned)2 /* creation index of message in OH */ \ - + H5F_SIZEOF_ADDR(f) /* address of OH */ \ +#define H5SM_OH_LOC_SIZE(f) \ + ((unsigned)1 /* reserved (possible flags?) */ \ + + (unsigned)1 /* message type ID */ \ + + (unsigned)2 /* creation index of message in OH */ \ + + H5F_SIZEOF_ADDR(f) /* address of OH */ \ ) -#define H5SM_SOHM_ENTRY_SIZE(f) ( \ - (unsigned)1 /* Message location */ \ - + (unsigned)4 /* Hash value */ \ - + MAX(H5SM_HEAP_LOC_SIZE, H5SM_OH_LOC_SIZE(f)) /* Entry */ \ +#define H5SM_SOHM_ENTRY_SIZE(f) \ + ((unsigned)1 /* Message location */ \ + + (unsigned)4 /* Hash value */ \ + + MAX(H5SM_HEAP_LOC_SIZE, H5SM_OH_LOC_SIZE(f)) /* Entry */ \ ) -#define H5SM_INDEX_HEADER_SIZE(f) ( \ - (unsigned)1 /* Whether index is a list or B-tree */ \ - + (unsigned)1 /* Version of index format */ \ - + (unsigned)2 /* Type of messages stored in the index */ \ - + (unsigned)4 /* Minimum size of messages to share */ \ - + (unsigned)(3 * 2) /* B-tree cutoff, list cutoff, # of shared messages */ \ - + H5F_SIZEOF_ADDR(f) /* Location of list or B-tree */ \ - + H5F_SIZEOF_ADDR(f) /* Address of heap */ \ +#define H5SM_INDEX_HEADER_SIZE(f) \ + ((unsigned)1 /* Whether index is a list or B-tree */ \ + + (unsigned)1 /* Version of index format */ \ + + (unsigned)2 /* Type of messages stored in the index */ \ + + (unsigned)4 /* Minimum size of messages to share */ \ + + (unsigned)(3 * 2) /* B-tree cutoff, list cutoff, # of shared messages */ \ + + H5F_SIZEOF_ADDR(f) /* Location of list or B-tree */ \ + + H5F_SIZEOF_ADDR(f) /* Address of heap */ \ ) /* Format overhead for all SOHM tree metadata in the file */ -#define H5SM_METADATA_PREFIX_SIZE ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + H5SM_SIZEOF_CHECKSUM /* Checksum */ \ - ) - -#define H5SM_TABLE_SIZE(f) ( \ - /* General metadata fields */ \ - H5SM_METADATA_PREFIX_SIZE \ - \ - /* Indices */ \ - + (H5F_SOHM_NINDEXES(f) * H5SM_INDEX_HEADER_SIZE(f)) \ +#define H5SM_METADATA_PREFIX_SIZE \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + H5SM_SIZEOF_CHECKSUM /* Checksum */ \ ) -#define H5SM_LIST_SIZE(f, num_mesg) ( \ - /* General metadata fields */ \ - H5SM_METADATA_PREFIX_SIZE \ - \ - /* Message entries */ \ - + (H5SM_SOHM_ENTRY_SIZE(f) * num_mesg) \ - ) - -#define H5SM_B2_NODE_SIZE 512 +#define H5SM_TABLE_SIZE(f) \ + (/* General metadata fields */ \ + H5SM_METADATA_PREFIX_SIZE \ + \ + /* Indices */ \ + + (H5F_SOHM_NINDEXES(f) * H5SM_INDEX_HEADER_SIZE(f))) + +#define H5SM_LIST_SIZE(f, num_mesg) \ + (/* General metadata fields */ \ + H5SM_METADATA_PREFIX_SIZE \ + \ + /* Message entries */ \ + + (H5SM_SOHM_ENTRY_SIZE(f) * num_mesg)) + +#define H5SM_B2_NODE_SIZE 512 #define H5SM_B2_SPLIT_PERCENT 100 #define H5SM_B2_MERGE_PERCENT 40 -#define H5SM_LIST_VERSION 0 /* Version of Shared Object Header Message List Indexes */ +#define H5SM_LIST_VERSION 0 /* Version of Shared Object Header Message List Indexes */ /****************************/ /* Package Typedefs */ @@ -132,49 +129,49 @@ /* Where a message is stored */ typedef enum { - H5SM_NO_LOC = -1, - H5SM_IN_HEAP = 0, /* Message is stored in the heap */ - H5SM_IN_OH /* Message is stored in an object header */ + H5SM_NO_LOC = -1, + H5SM_IN_HEAP = 0, /* Message is stored in the heap */ + H5SM_IN_OH /* Message is stored in an object header */ } H5SM_storage_loc_t; /* Typedef for a record's location if it's stored in the heap */ typedef struct { - hsize_t ref_count; /* Number of times this message is used in the file */ - H5O_fheap_id_t fheap_id; /* ID of the OHM in the fractal heap */ + hsize_t ref_count; /* Number of times this message is used in the file */ + H5O_fheap_id_t fheap_id; /* ID of the OHM in the fractal heap */ } H5SM_heap_loc_t; /* Typedef for a SOHM index node */ typedef struct { - H5SM_storage_loc_t location; /* Type of message location */ - uint32_t hash; /* Hash value for encoded OHM */ - unsigned msg_type_id; /* Message's type ID */ + H5SM_storage_loc_t location; /* Type of message location */ + uint32_t hash; /* Hash value for encoded OHM */ + unsigned msg_type_id; /* Message's type ID */ union { - H5O_mesg_loc_t mesg_loc; /* Location of message in object header */ - H5SM_heap_loc_t heap_loc; /* Heap ID for message in SOHM heap */ + H5O_mesg_loc_t mesg_loc; /* Location of message in object header */ + H5SM_heap_loc_t heap_loc; /* Heap ID for message in SOHM heap */ } u; } H5SM_sohm_t; /* Types of message indices */ typedef enum { H5SM_BADTYPE = -1, - H5SM_LIST, /* Index is an unsorted list */ - H5SM_BTREE /* Index is a sorted B-tree */ + H5SM_LIST, /* Index is an unsorted list */ + H5SM_BTREE /* Index is a sorted B-tree */ } H5SM_index_type_t; /* Typedef for a SOHM index header */ typedef struct { -/* Stored */ - unsigned mesg_types; /* Bit flag vector of message types */ - size_t min_mesg_size; /* number of messages being tracked */ - size_t list_max; /* >= this many messages, index with a B-tree */ - size_t btree_min; /* <= this many messages, index with a list again */ - size_t num_messages; /* number of messages being tracked */ - H5SM_index_type_t index_type; /* Is the index a list or a B-tree? */ - haddr_t index_addr; /* Address of the actual index (list or B-tree) */ - haddr_t heap_addr; /* Address of the fheap used to store shared messages */ - -/* Not stored */ - size_t list_size; /* Size of list index on disk */ + /* Stored */ + unsigned mesg_types; /* Bit flag vector of message types */ + size_t min_mesg_size; /* number of messages being tracked */ + size_t list_max; /* >= this many messages, index with a B-tree */ + size_t btree_min; /* <= this many messages, index with a list again */ + size_t num_messages; /* number of messages being tracked */ + H5SM_index_type_t index_type; /* Is the index a list or a B-tree? */ + haddr_t index_addr; /* Address of the actual index (list or B-tree) */ + haddr_t heap_addr; /* Address of the fheap used to store shared messages */ + + /* Not stored */ + size_t list_size; /* Size of list index on disk */ } H5SM_index_header_t; /* Typedef for a SOHM list */ @@ -182,8 +179,8 @@ typedef struct { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; - H5SM_index_header_t *header; /* Pointer to the corresponding index header */ - H5SM_sohm_t *messages; /* Actual list, stored as an array */ + H5SM_index_header_t *header; /* Pointer to the corresponding index header */ + H5SM_sohm_t * messages; /* Actual list, stored as an array */ } H5SM_list_t; /* Typedef for shared object header message master table */ @@ -191,20 +188,20 @@ struct H5SM_master_table_t { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; - size_t table_size; /* Size of table on disk */ - unsigned num_indexes; /* Number of indexes */ - H5SM_index_header_t *indexes; /* Array of num_indexes indexes */ + size_t table_size; /* Size of table on disk */ + unsigned num_indexes; /* Number of indexes */ + H5SM_index_header_t *indexes; /* Array of num_indexes indexes */ }; /* Typedef for searching an index (list or B-tree) */ typedef struct { - H5F_t *file; /* File in which sharing is happening */ - H5HF_t *fheap; /* The heap for this message type, open. */ - void *encoding; /* The message encoded, or NULL */ - size_t encoding_size; /* Size of the encoding, or 0 */ - H5SM_sohm_t message; /* The message to find/insert. - * If the message doesn't yet have a - * heap ID, the heap ID will be 0. */ + H5F_t * file; /* File in which sharing is happening */ + H5HF_t * fheap; /* The heap for this message type, open. */ + void * encoding; /* The message encoded, or NULL */ + size_t encoding_size; /* Size of the encoding, or 0 */ + H5SM_sohm_t message; /* The message to find/insert. + * If the message doesn't yet have a + * heap ID, the heap ID will be 0. */ } H5SM_mesg_key_t; /* @@ -213,35 +210,34 @@ typedef struct { */ typedef struct { /* downward (internal) */ - unsigned type_id; /* Message type */ + unsigned type_id; /* Message type */ /* upward */ - uint32_t hash; /* Hash value */ + uint32_t hash; /* Hash value */ } H5SM_fh_ud_gh_t; /* Typedef to increment a reference count in the B-tree */ typedef struct { - H5SM_mesg_key_t *key; /* IN: key for message being incremented */ - H5O_fheap_id_t fheap_id; /* OUT: fheap ID of record */ + H5SM_mesg_key_t *key; /* IN: key for message being incremented */ + H5O_fheap_id_t fheap_id; /* OUT: fheap ID of record */ } H5SM_incr_ref_opdata; /* v2 B-tree client callback context */ typedef struct H5SM_bt2_ctx_t { - uint8_t sizeof_addr; /* Size of file addresses */ + uint8_t sizeof_addr; /* Size of file addresses */ } H5SM_bt2_ctx_t; /* Callback info for loading a shared message table index into the cache */ typedef struct H5SM_table_cache_ud_t { - H5F_t *f; /* File that shared message index stored as a table is in */ + H5F_t *f; /* File that shared message index stored as a table is in */ } H5SM_table_cache_ud_t; /* Callback info for loading a shared message list index into the cache */ typedef struct H5SM_list_cache_ud_t { - H5F_t *f; /* File that shared message index stored as a table is in */ + H5F_t * f; /* File that shared message index stored as a table is in */ H5SM_index_header_t *header; /* Index header for this list */ } H5SM_list_cache_ud_t; - /****************************/ /* Package Variables */ /****************************/ @@ -267,7 +263,7 @@ H5_DLL herr_t H5SM__message_encode(uint8_t *raw, const void *native, void *ctx); H5_DLL herr_t H5SM__message_decode(const uint8_t *raw, void *native, void *ctx); /* H5B2_remove_t callback to add messages to a list index */ -H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void * record, void *op_data); +H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void *record, void *op_data); /* Fractal heap 'op' callback to compute hash value for message "in place" */ H5_DLL herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata); @@ -282,4 +278,3 @@ H5_DLL herr_t H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg #endif /* H5SM_TESTING */ #endif /* _H5SMpkg_H */ - diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h index e6776f3..3d5162f 100644 --- a/src/H5SMprivate.h +++ b/src/H5SMprivate.h @@ -21,8 +21,8 @@ #ifndef _H5SMprivate_H #define _H5SMprivate_H -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ /**************************/ /* Library Private Macros */ @@ -30,9 +30,9 @@ /* Flags for the "defer_flags" argument to H5SM_try_share */ -#define H5SM_DEFER 0x01u /* Don't actually write shared message to index, heap; just update shared info */ -#define H5SM_WAS_DEFERRED 0x02u /* Message was previously updated by a call to H5SM_try_share with H5SM_DEFER */ - +#define H5SM_DEFER 0x01u /* Don't actually write shared message to index, heap; just update shared info */ +#define H5SM_WAS_DEFERRED \ + 0x02u /* Message was previously updated by a call to H5SM_try_share with H5SM_DEFER */ /****************************/ /* Library Private Typedefs */ @@ -41,33 +41,29 @@ /* Forward references of package typedefs */ typedef struct H5SM_master_table_t H5SM_master_table_t; - /******************************/ /* Library Private Prototypes */ /******************************/ /* Generally useful shared message routines */ H5_DLL herr_t H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc); -H5_DLL htri_t H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, - ssize_t *sohm_index_num, unsigned type_id, const void *mesg); -H5_DLL htri_t H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, - unsigned type_id, void *mesg, unsigned *mesg_flags); +H5_DLL htri_t H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, unsigned type_id, + const void *mesg); +H5_DLL htri_t H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, void *mesg, + unsigned *mesg_flags); H5_DLL herr_t H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg); H5_DLL herr_t H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist); H5_DLL htri_t H5SM_type_shared(H5F_t *f, unsigned type_id); H5_DLL herr_t H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr); -H5_DLL herr_t H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, - unsigned msg_type_id, H5O_fheap_id_t heap_id); -H5_DLL herr_t H5SM_get_refcount(H5F_t *f, unsigned type_id, - const H5O_shared_t *sh_mesg, hsize_t *ref_count); +H5_DLL herr_t H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, + H5O_fheap_id_t heap_id); +H5_DLL herr_t H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize_t *ref_count); H5_DLL herr_t H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info); - /* Debugging routines */ -H5_DLL herr_t H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, - int indent, int fwidth, unsigned table_vers, unsigned num_indexes); -H5_DLL herr_t H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, - int indent, int fwidth, haddr_t table_addr); +H5_DLL herr_t H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwidth, + unsigned table_vers, unsigned num_indexes); +H5_DLL herr_t H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidth, + haddr_t table_addr); #endif /*_H5SMprivate_H*/ - diff --git a/src/H5SMtest.c b/src/H5SMtest.c index 0a6149d..51a3290 100644 --- a/src/H5SMtest.c +++ b/src/H5SMtest.c @@ -15,52 +15,43 @@ /* Module Setup */ /****************/ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ -#define H5SM_TESTING /*suppress warning about H5SM testing funcs*/ - +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ +#define H5SM_TESTING /*suppress warning about H5SM testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5SM__get_mesg_count_test * @@ -76,8 +67,8 @@ herr_t H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) { - H5SM_master_table_t *table = NULL; /* SOHM master table */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_master_table_t *table = NULL; /* SOHM master table */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__SOHM_TAG) @@ -86,20 +77,21 @@ H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) HDassert(mesg_count); /* Check for shared messages being enabled */ - if(H5F_addr_defined(H5F_SOHM_ADDR(f))) { - H5SM_index_header_t *header; /* Index header for message type */ - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ - ssize_t index_num; /* Table index for message type */ + if (H5F_addr_defined(H5F_SOHM_ADDR(f))) { + H5SM_index_header_t * header; /* Index header for message type */ + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + ssize_t index_num; /* Table index for message type */ /* Set up user data for callback */ cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Find the correct index for this message type */ - if((index_num = H5SM_get_index(table, type_id)) < 0) + if ((index_num = H5SM_get_index(table, type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index") header = &(table->indexes[index_num]); @@ -112,9 +104,8 @@ H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) done: /* Release resources */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM__get_mesg_count_test() */ - diff --git a/src/H5ST.c b/src/H5ST.c index 3a1020b..266b276 100644 --- a/src/H5ST.c +++ b/src/H5ST.c @@ -16,10 +16,9 @@ Bentley and Robert Sedgewick in the April, 1998, Dr. Dobb's Journal. */ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5STprivate.h" /* Ternary search trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5STprivate.h" /* Ternary search trees */ #ifdef H5ST_DEBUG static herr_t H5ST__dump_internal(H5ST_ptr_t p); @@ -31,7 +30,6 @@ H5FL_DEFINE_STATIC(H5ST_node_t); /* Declare a free list to manage the H5ST_tree_t struct */ H5FL_DEFINE_STATIC(H5ST_tree_t); - /*-------------------------------------------------------------------------- NAME H5ST_create @@ -52,12 +50,12 @@ H5FL_DEFINE_STATIC(H5ST_tree_t); H5ST_tree_t * H5ST_create(void) { - H5ST_tree_t *ret_value; /* Return value */ + H5ST_tree_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate wrapper for TST */ - if(NULL == (ret_value = H5FL_MALLOC(H5ST_tree_t))) + if (NULL == (ret_value = H5FL_MALLOC(H5ST_tree_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the internal fields */ @@ -67,7 +65,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_create() */ - /*-------------------------------------------------------------------------- NAME H5ST_close_internal @@ -92,9 +89,9 @@ H5ST_close_internal(H5ST_ptr_t p) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Recursively free TST */ - if(p) { + if (p) { H5ST_close_internal(p->lokid); - if(p->splitchar) + if (p->splitchar) H5ST_close_internal(p->eqkid); H5ST_close_internal(p->hikid); p = H5FL_FREE(H5ST_node_t, p); @@ -103,7 +100,6 @@ H5ST_close_internal(H5ST_ptr_t p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5ST_close_internal() */ - /*-------------------------------------------------------------------------- NAME H5ST_close @@ -125,16 +121,16 @@ H5ST_close_internal(H5ST_ptr_t p) herr_t H5ST_close(H5ST_tree_t *tree) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ - if(NULL == tree) + if (NULL == tree) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid TST") /* Free the TST itself */ - if(H5ST_close_internal(tree->root) < 0) + if (H5ST_close_internal(tree->root) < 0) HGOTO_ERROR(H5E_TST, H5E_CANTFREE, FAIL, "can't free TST") /* Free root node itself */ @@ -144,7 +140,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_close() */ - /*-------------------------------------------------------------------------- NAME H5ST_insert @@ -168,61 +163,60 @@ done: herr_t H5ST_insert(H5ST_tree_t *tree, const char *s, void *obj) { - int d; /* Comparison value */ - H5ST_ptr_t pp, *p; /* Pointer to current node and pointer to that */ - H5ST_ptr_t parent=NULL; /* Pointer to parent node */ - H5ST_ptr_t up=NULL; /* Pointer to up node */ - herr_t ret_value=SUCCEED; /* Return value */ + int d; /* Comparison value */ + H5ST_ptr_t pp, *p; /* Pointer to current node and pointer to that */ + H5ST_ptr_t parent = NULL; /* Pointer to parent node */ + H5ST_ptr_t up = NULL; /* Pointer to up node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Find the correct location to insert object */ p = &tree->root; - while((pp = *p)) { + while ((pp = *p)) { /* If this node matches the character in the key, then drop down to the lower tree */ - if(0 == (d = *s - pp->splitchar)) { - if(*s++ == 0) + if (0 == (d = *s - pp->splitchar)) { + if (*s++ == 0) HGOTO_ERROR(H5E_TST, H5E_EXISTS, FAIL, "key already in tree") - up=pp; - p = &(pp->eqkid); + up = pp; + p = &(pp->eqkid); } /* end if */ else { /* Walk through the current tree, searching for the matching character */ parent = pp; - if(d < 0) + if (d < 0) p = &(pp->lokid); else p = &(pp->hikid); } /* end else */ - } /* end while */ + } /* end while */ /* Finish walking through the key string, adding nodes until the end */ for (;;) { - if(NULL == (*p = H5FL_MALLOC(H5ST_node_t))) + if (NULL == (*p = H5FL_MALLOC(H5ST_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - pp = *p; + pp = *p; pp->splitchar = *s; - pp->up = up; - pp->parent = parent; + pp->up = up; + pp->parent = parent; pp->lokid = pp->eqkid = pp->hikid = NULL; /* If this is the end of the key string, break out */ - if(*s++ == 0) { + if (*s++ == 0) { pp->eqkid = (H5ST_ptr_t)obj; break; } /* end if */ /* Continue to next character */ parent = NULL; - up = pp; - p = &(pp->eqkid); + up = pp; + p = &(pp->eqkid); } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_insert() */ - /*-------------------------------------------------------------------------- NAME H5ST_search @@ -246,8 +240,8 @@ done: htri_t H5ST_search(H5ST_tree_t *tree, const char *s) { - H5ST_ptr_t p; /* Temporary pointer to TST node */ - htri_t ret_value=FALSE; /* Return value */ + H5ST_ptr_t p; /* Temporary pointer to TST node */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -255,11 +249,12 @@ H5ST_search(H5ST_tree_t *tree, const char *s) while (p) { if (*s < p->splitchar) p = p->lokid; - else if (*s == p->splitchar) { + else if (*s == p->splitchar) { if (*s++ == 0) HGOTO_DONE(TRUE); p = p->eqkid; - } else + } + else p = p->hikid; } /* end while */ @@ -267,7 +262,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_search() */ - /*-------------------------------------------------------------------------- NAME H5ST_find_internal @@ -291,18 +285,19 @@ done: static H5ST_ptr_t H5ST_find_internal(H5ST_ptr_t p, const char *s) { - H5ST_ptr_t ret_value = NULL; /* Return value */ + H5ST_ptr_t ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR while (p) { if (*s < p->splitchar) p = p->lokid; - else if (*s == p->splitchar) { + else if (*s == p->splitchar) { if (*s++ == 0) HGOTO_DONE(p); p = p->eqkid; - } else + } + else p = p->hikid; } /* end while */ @@ -310,7 +305,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_find_internal() */ - /*-------------------------------------------------------------------------- NAME H5ST_find @@ -334,18 +328,17 @@ done: H5ST_ptr_t H5ST_find(H5ST_tree_t *tree, const char *s) { - H5ST_ptr_t ret_value; /* Return value */ + H5ST_ptr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) - if(NULL == (ret_value = H5ST_find_internal(tree->root, s))) + if (NULL == (ret_value = H5ST_find_internal(tree->root, s))) HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_find() */ - /*-------------------------------------------------------------------------- NAME H5ST_locate @@ -368,13 +361,13 @@ done: void * H5ST_locate(H5ST_tree_t *tree, const char *s) { - H5ST_ptr_t node; /* Pointer to node located */ - void *ret_value; /* Return value */ + H5ST_ptr_t node; /* Pointer to node located */ + void * ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Locate the node to remove */ - if(NULL == (node = H5ST_find_internal(tree->root, s))) + if (NULL == (node = H5ST_find_internal(tree->root, s))) HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") /* Get the pointer to the object to return */ @@ -384,7 +377,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5ST_locate() */ - /*-------------------------------------------------------------------------- NAME H5ST_findfirst_internal @@ -406,17 +398,17 @@ done: static H5ST_ptr_t H5ST_findfirst_internal(H5ST_ptr_t p) { - H5ST_ptr_t ret_value = NULL; /* Return value */ + H5ST_ptr_t ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - while(p) { + while (p) { /* Find least node in current tree */ - while(p->lokid) + while (p->lokid) p = p->lokid; /* Is least node '\0'? */ - if(p->splitchar == '\0') { + if (p->splitchar == '\0') { /* Return it */ HGOTO_DONE(p); } /* end if */ @@ -424,13 +416,12 @@ H5ST_findfirst_internal(H5ST_ptr_t p) /* Go down to next level of tree */ p = p->eqkid; } /* end else */ - } /* end while */ + } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_findfirst_internal() */ - /*-------------------------------------------------------------------------- NAME H5ST_findfirst @@ -452,18 +443,17 @@ done: H5ST_ptr_t H5ST_findfirst(H5ST_tree_t *tree) { - H5ST_ptr_t ret_value; /* Return value */ + H5ST_ptr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) - if(NULL == (ret_value = H5ST_findfirst_internal(tree->root))) - HGOTO_ERROR(H5E_TST,H5E_NOTFOUND,NULL,"no nodes in TST"); + if (NULL == (ret_value = H5ST_findfirst_internal(tree->root))) + HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "no nodes in TST"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_findfirst() */ - /*-------------------------------------------------------------------------- NAME H5ST_getnext @@ -485,33 +475,33 @@ done: static H5ST_ptr_t H5ST_getnext(H5ST_ptr_t p) { - H5ST_ptr_t ret_value = NULL; /* Return value */ + H5ST_ptr_t ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* If the node to continue from has higher-valued nodes attached */ - if(p->hikid) { + if (p->hikid) { /* Go to first higher-valued node */ p = p->hikid; /* Find least node from here */ - while(p->lokid) + while (p->lokid) p = p->lokid; HGOTO_DONE(p); } /* end if */ else { - H5ST_ptr_t q; /* Temporary TST node pointer */ + H5ST_ptr_t q; /* Temporary TST node pointer */ /* Go up one level in current tree */ q = p->parent; - if(q == NULL) + if (q == NULL) HGOTO_DONE(NULL); /* While the previous node was the higher-valued node, keep backing up the tree */ - while(q->hikid == p) { + while (q->hikid == p) { p = q; q = p->parent; - if(NULL == q) + if (NULL == q) HGOTO_DONE(NULL); } /* end while */ HGOTO_DONE(q); @@ -521,7 +511,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_getnext() */ - /*-------------------------------------------------------------------------- NAME H5ST_findnext @@ -543,26 +532,25 @@ done: H5ST_ptr_t H5ST_findnext(H5ST_ptr_t p) { - H5ST_ptr_t q; /* Temporary pointer to TST node */ - H5ST_ptr_t ret_value = NULL; /* Return value */ + H5ST_ptr_t q; /* Temporary pointer to TST node */ + H5ST_ptr_t ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Find the next node at the current level, or go back up the tree */ do { q = H5ST_getnext(p); - if(q) { + if (q) { HGOTO_DONE(H5ST_findfirst_internal(q->eqkid)); } /* end if */ else p = p->up; - } while(p); + } while (p); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_findnext() */ - /*-------------------------------------------------------------------------- NAME H5ST_delete_internal @@ -586,24 +574,24 @@ done: static herr_t H5ST_delete_internal(H5ST_ptr_t *root, H5ST_ptr_t p) { - H5ST_ptr_t q, /* Temporary pointer to TST node */ - newp; /* Pointer to node which will replace deleted node in tree */ + H5ST_ptr_t q, /* Temporary pointer to TST node */ + newp; /* Pointer to node which will replace deleted node in tree */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Find node to replace one being deleted */ - if(p->lokid) { + if (p->lokid) { /* If the deleted node has lo & hi kids, attach them together */ - if(p->hikid) { + if (p->hikid) { q = p->lokid; - while(q->hikid) + while (q->hikid) q = q->hikid; - q->hikid = p->hikid; + q->hikid = p->hikid; p->hikid->parent = q; } /* end if */ newp = p->lokid; } /* end if */ - else if(p->hikid) { + else if (p->hikid) { newp = p->hikid; } /* end if */ else { @@ -611,25 +599,25 @@ H5ST_delete_internal(H5ST_ptr_t *root, H5ST_ptr_t p) } /* end else */ /* Deleted node is in middle of tree */ - if(p->parent) { + if (p->parent) { /* Attach new node to correct side of parent */ - if(p == p->parent->lokid) + if (p == p->parent->lokid) p->parent->lokid = newp; else p->parent->hikid = newp; - if(newp) + if (newp) newp->parent = p->parent; } /* end if */ else { - if(newp) + if (newp) newp->parent = p->parent; - if(p->up) { + if (p->up) { p->up->eqkid = newp; /* If we deleted the last node in the TST, delete the upper node also */ - if(NULL == newp) + if (NULL == newp) H5ST_delete_internal(root, p->up); - } /* end if */ + } /* end if */ else /* Deleted last node at top level of tree */ *root = newp; } /* end else */ @@ -639,7 +627,6 @@ H5ST_delete_internal(H5ST_ptr_t *root, H5ST_ptr_t p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5ST_delete_internal() */ - /*-------------------------------------------------------------------------- NAME H5ST_delete @@ -663,18 +650,17 @@ H5ST_delete_internal(H5ST_ptr_t *root, H5ST_ptr_t p) herr_t H5ST_delete(H5ST_tree_t *tree, H5ST_ptr_t p) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5ST_delete_internal(&tree->root, p) < 0) + if (H5ST_delete_internal(&tree->root, p) < 0) HGOTO_ERROR(H5E_TST, H5E_CANTDELETE, FAIL, "can't delete node from TST") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ST_delete() */ - /*-------------------------------------------------------------------------- NAME H5ST_remove @@ -697,20 +683,20 @@ done: void * H5ST_remove(H5ST_tree_t *tree, const char *s) { - H5ST_ptr_t node; /* Pointer to node to remove */ - void *ret_value; /* Return value */ + H5ST_ptr_t node; /* Pointer to node to remove */ + void * ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Locate the node to remove */ - if(NULL == (node = H5ST_find_internal(tree->root, s))) + if (NULL == (node = H5ST_find_internal(tree->root, s))) HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") /* Get the pointer to the object to return */ ret_value = node->eqkid; /* Remove the node from the TST */ - if(H5ST_delete_internal(&tree->root, node) < 0) + if (H5ST_delete_internal(&tree->root, node) < 0) HGOTO_ERROR(H5E_TST, H5E_CANTDELETE, NULL, "can't delete node from TST") done: @@ -718,7 +704,7 @@ done: } /* H5ST_remove() */ #ifdef H5ST_DEBUG - + /*-------------------------------------------------------------------------- NAME H5ST__dump_internal @@ -742,7 +728,7 @@ H5ST__dump_internal(H5ST_ptr_t p) { FUNC_ENTER_STATIC_NOERR - if(p) { + if (p) { HDprintf("p=%p\n", (void *)p); HDprintf("\tp->up=%p\n", (void *)p->up); HDprintf("\tp->parent=%p\n", (void *)p->parent); @@ -752,7 +738,7 @@ H5ST__dump_internal(H5ST_ptr_t p) HDprintf("\tp->splitchar=%c\n", p->splitchar); H5ST__dump_internal(p->lokid); - if(p->splitchar) + if (p->splitchar) H5ST__dump_internal(p->eqkid); else HDprintf("%s\n", (char *)p->eqkid); @@ -762,7 +748,6 @@ H5ST__dump_internal(H5ST_ptr_t p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5ST__dump_internal() */ - /*-------------------------------------------------------------------------- NAME H5ST_dump @@ -792,4 +777,3 @@ H5ST_dump(H5ST_tree_t *tree) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5ST_dump() */ #endif /* H5ST_DEBUG */ - diff --git a/src/H5STprivate.h b/src/H5STprivate.h index 07e9afe..52f8d1f 100644 --- a/src/H5STprivate.h +++ b/src/H5STprivate.h @@ -29,36 +29,35 @@ /* Internal nodes for TST */ typedef struct H5ST_node *H5ST_ptr_t; typedef struct H5ST_node { - char splitchar; /* Character represented at node */ - H5ST_ptr_t up; /* Pointer to the node in the tree above (before) this node */ - H5ST_ptr_t parent; /* Pointer to the next higher tree node in this tree */ - H5ST_ptr_t lokid; /* Pointer to the lower node from this one, in this tree */ - H5ST_ptr_t eqkid; /* Pointer to the parent node in the next tree down (after) this node */ - H5ST_ptr_t hikid; /* Pointer to the higher node from this one, in this tree */ + char splitchar; /* Character represented at node */ + H5ST_ptr_t up; /* Pointer to the node in the tree above (before) this node */ + H5ST_ptr_t parent; /* Pointer to the next higher tree node in this tree */ + H5ST_ptr_t lokid; /* Pointer to the lower node from this one, in this tree */ + H5ST_ptr_t eqkid; /* Pointer to the parent node in the next tree down (after) this node */ + H5ST_ptr_t hikid; /* Pointer to the higher node from this one, in this tree */ } H5ST_node_t; /* Wrapper about TST */ typedef struct { - H5ST_ptr_t root; /* Pointer to actual TST */ + H5ST_ptr_t root; /* Pointer to actual TST */ } H5ST_tree_t; /* Macro to access "data" pointer in H5ST_node_t's returned from functions */ -#define H5ST_NODE_DATA(p) ((void *)(p->eqkid)) +#define H5ST_NODE_DATA(p) ((void *)(p->eqkid)) /* Private routines */ H5_DLL H5ST_tree_t *H5ST_create(void); -H5_DLL herr_t H5ST_close(H5ST_tree_t *p); -H5_DLL herr_t H5ST_insert(H5ST_tree_t *root, const char *s, void *obj); -H5_DLL htri_t H5ST_search(H5ST_tree_t *root, const char *s); -H5_DLL H5ST_ptr_t H5ST_find(H5ST_tree_t *root, const char *s); -H5_DLL void *H5ST_locate(H5ST_tree_t *root, const char *s); -H5_DLL H5ST_ptr_t H5ST_findfirst(H5ST_tree_t *p); -H5_DLL H5ST_ptr_t H5ST_findnext(H5ST_ptr_t p); -H5_DLL void *H5ST_remove(H5ST_tree_t *root, const char *s); -H5_DLL herr_t H5ST_delete(H5ST_tree_t *root, H5ST_ptr_t p); +H5_DLL herr_t H5ST_close(H5ST_tree_t *p); +H5_DLL herr_t H5ST_insert(H5ST_tree_t *root, const char *s, void *obj); +H5_DLL htri_t H5ST_search(H5ST_tree_t *root, const char *s); +H5_DLL H5ST_ptr_t H5ST_find(H5ST_tree_t *root, const char *s); +H5_DLL void * H5ST_locate(H5ST_tree_t *root, const char *s); +H5_DLL H5ST_ptr_t H5ST_findfirst(H5ST_tree_t *p); +H5_DLL H5ST_ptr_t H5ST_findnext(H5ST_ptr_t p); +H5_DLL void * H5ST_remove(H5ST_tree_t *root, const char *s); +H5_DLL herr_t H5ST_delete(H5ST_tree_t *root, H5ST_ptr_t p); #ifdef H5ST_DEBUG H5_DLL herr_t H5ST_dump(H5ST_tree_t *tree); #endif /* H5ST_DEBUG */ #endif /* _H5STprivate_H */ - diff --git a/src/H5Sall.c b/src/H5Sall.c index 9026e7c..2e9f1d4 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -22,72 +22,65 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Selection callbacks */ -static herr_t H5S__all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -static herr_t H5S__all_release(H5S_t *space); -static htri_t H5S__all_is_valid(const H5S_t *space); +static herr_t H5S__all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S__all_release(H5S_t *space); +static htri_t H5S__all_is_valid(const H5S_t *space); static hssize_t H5S__all_serial_size(const H5S_t *space); -static herr_t H5S__all_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__all_deserialize(H5S_t **space, const uint8_t **p); -static herr_t H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); -static herr_t H5S__all_offset(const H5S_t *space, hsize_t *off); -static int H5S__all_unlim_dim(const H5S_t *space); -static htri_t H5S__all_is_contiguous(const H5S_t *space); -static htri_t H5S__all_is_single(const H5S_t *space); -static htri_t H5S__all_is_regular(const H5S_t *space); -static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__all_intersect_block(const H5S_t *space, const hsize_t *start, - const hsize_t *end); -static herr_t H5S__all_adjust_u(H5S_t *space, const hsize_t *offset); -static herr_t H5S__all_adjust_s(H5S_t *space, const hssize_t *offset); -static herr_t H5S__all_project_scalar(const H5S_t *space, hsize_t *offset); -static herr_t H5S__all_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__all_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__all_serialize(const H5S_t *space, uint8_t **p); +static herr_t H5S__all_deserialize(H5S_t **space, const uint8_t **p); +static herr_t H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +static herr_t H5S__all_offset(const H5S_t *space, hsize_t *off); +static int H5S__all_unlim_dim(const H5S_t *space); +static htri_t H5S__all_is_contiguous(const H5S_t *space); +static htri_t H5S__all_is_single(const H5S_t *space); +static htri_t H5S__all_is_regular(const H5S_t *space); +static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__all_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static herr_t H5S__all_adjust_u(H5S_t *space, const hsize_t *offset); +static herr_t H5S__all_adjust_s(H5S_t *space, const hssize_t *offset); +static herr_t H5S__all_project_scalar(const H5S_t *space, hsize_t *offset); +static herr_t H5S__all_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); +static herr_t H5S__all_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ -static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__all_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__all_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S__all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__all_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); -static herr_t H5S__all_iter_release(H5S_sel_iter_t *sel_iter); - +static htri_t H5S__all_iter_has_next_block(const H5S_sel_iter_t *iter); +static herr_t H5S__all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__all_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); +static herr_t H5S__all_iter_release(H5S_sel_iter_t *sel_iter); /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -119,7 +112,6 @@ const H5S_select_class_t H5S_sel_all[1] = {{ H5S__all_iter_init, }}; - /*******************/ /* Local Variables */ /*******************/ @@ -139,8 +131,6 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ H5S__all_iter_release, }}; - - /*------------------------------------------------------------------------- * Function: H5S__all_iter_init * @@ -172,7 +162,6 @@ H5S__all_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__all_iter_coords * @@ -189,7 +178,7 @@ H5S__all_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -198,14 +187,13 @@ H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) HDassert(coords); /* Calculate the coordinates for the current iterator offset */ - if(H5VM_array_calc(iter->u.all.elmt_offset, iter->rank, iter->dims, coords) < 0) + if (H5VM_array_calc(iter->u.all.elmt_offset, iter->rank, iter->dims, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve coordinates") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_iter_coords() */ - /*------------------------------------------------------------------------- * Function: H5S__all_iter_block * @@ -222,7 +210,7 @@ done: static herr_t H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -231,7 +219,7 @@ H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) HDassert(start); HDassert(end); - for(u = 0; u < iter->rank; u++) { + for (u = 0; u < iter->rank; u++) { /* Set the start of the 'all' block */ /* (Always '0' coordinates for now) */ start[u] = 0; @@ -244,7 +232,6 @@ H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__all_iter_nelmts * @@ -268,7 +255,6 @@ H5S__all_iter_nelmts(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(iter->elmt_left) } /* end H5S__all_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_has_next_block @@ -297,7 +283,6 @@ H5S__all_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__all_iter_has_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_next @@ -332,7 +317,6 @@ H5S__all_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_next() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_next_block @@ -361,7 +345,6 @@ H5S__all_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__all_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_get_seq_list @@ -392,10 +375,10 @@ H5S__all_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq, - size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) +H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq, size_t maxelem, size_t *nseq, + size_t *nelem, hsize_t *off, size_t *len) { - size_t elem_used; /* The number of elements used */ + size_t elem_used; /* The number of elements used */ FUNC_ENTER_STATIC_NOERR @@ -431,7 +414,6 @@ H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_release @@ -450,7 +432,7 @@ H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq, REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__all_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter) +H5S__all_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED *iter) { FUNC_ENTER_STATIC_NOERR @@ -460,7 +442,6 @@ H5S__all_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__all_release @@ -492,7 +473,6 @@ H5S__all_release(H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_release() */ - /*-------------------------------------------------------------------------- NAME H5S__all_copy @@ -527,7 +507,6 @@ H5S__all_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSE FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__all_is_valid @@ -558,7 +537,6 @@ H5S__all_is_valid(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5S__all_serial_size @@ -592,7 +570,6 @@ H5S__all_serial_size(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(16) } /* end H5S__all_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__all_serialize @@ -617,7 +594,7 @@ H5S__all_serial_size(const H5S_t H5_ATTR_UNUSED *space) static herr_t H5S__all_serialize(const H5S_t *space, uint8_t **p) { - uint8_t *pp = (*p); /* Local pointer for decoding */ + uint8_t *pp = (*p); /* Local pointer for decoding */ FUNC_ENTER_STATIC_NOERR @@ -629,8 +606,8 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(pp, (uint32_t)H5S_ALL_VERSION_1); /* Store the version number */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ /* Update encoding pointer */ *p = pp; @@ -638,7 +615,6 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__all_deserialize @@ -665,9 +641,9 @@ static herr_t H5S__all_deserialize(H5S_t **space, const uint8_t **p) { uint32_t version; /* Version number */ - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + H5S_t * tmp_space = NULL; /* Pointer to actual dataspace to use, either *space or a newly allocated one */ - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -680,8 +656,8 @@ H5S__all_deserialize(H5S_t **space, const uint8_t **p) This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -690,30 +666,29 @@ H5S__all_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(*p, version); - if(version < H5S_ALL_VERSION_1 || version > H5S_ALL_VERSION_LATEST) + if (version < H5S_ALL_VERSION_1 || version > H5S_ALL_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for all selection") /* Skip over the remainder of the header */ *p += 8; /* Change to "all" selection */ - if(H5S_select_all(tmp_space, TRUE) < 0) + if (H5S_select_all(tmp_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__all_bounds @@ -742,8 +717,8 @@ done: static herr_t H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - unsigned rank; /* Dataspace rank */ - unsigned i; /* index variable */ + unsigned rank; /* Dataspace rank */ + unsigned i; /* index variable */ FUNC_ENTER_STATIC_NOERR @@ -755,15 +730,14 @@ H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) rank = space->extent.rank; /* Just copy over the complete extent */ - for(i = 0; i < rank; i++) { + for (i = 0; i < rank; i++) { start[i] = 0; - end[i] = space->extent.size[i] - 1; + end[i] = space->extent.size[i] - 1; } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__all_offset @@ -798,7 +772,6 @@ H5S__all_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__all_unlim_dim @@ -828,7 +801,6 @@ H5S__all_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(-1) } /* end H5S__all_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__all_is_contiguous @@ -857,7 +829,6 @@ H5S__all_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__all_is_single @@ -886,7 +857,6 @@ H5S__all_is_single(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__all_is_regular @@ -917,7 +887,6 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__all_shape_same @@ -940,9 +909,9 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space) static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) { - int space1_dim; /* Current dimension in first dataspace */ - int space2_dim; /* Current dimension in second dataspace */ - htri_t ret_value = TRUE; /* Return value */ + int space1_dim; /* Current dimension in first dataspace */ + int space2_dim; /* Current dimension in second dataspace */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -959,8 +928,8 @@ H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) * In the following while loop, we test to see if space1 and space2 * have identical size in all dimensions they have in common. */ - while(space2_dim >= 0) { - if(space1->extent.size[space1_dim] != space2->extent.size[space2_dim]) + while (space2_dim >= 0) { + if (space1->extent.size[space1_dim] != space2->extent.size[space2_dim]) HGOTO_DONE(FALSE) space1_dim--; @@ -970,8 +939,8 @@ H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) /* Since we are selecting the entire space, we must also verify that space1 * has size 1 in all dimensions that it does not share with space2. */ - while(space1_dim >= 0) { - if(space1->extent.size[space1_dim] != 1) + while (space1_dim >= 0) { + if (space1->extent.size[space1_dim] != 1) HGOTO_DONE(FALSE) space1_dim--; @@ -981,7 +950,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__all_intersect_block @@ -1002,8 +970,8 @@ done: REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S__all_intersect_block(const H5S_t H5_ATTR_UNUSED *space, - const hsize_t H5_ATTR_UNUSED *start, const hsize_t H5_ATTR_UNUSED *end) +H5S__all_intersect_block(const H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, + const hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -1016,7 +984,6 @@ H5S__all_intersect_block(const H5S_t H5_ATTR_UNUSED *space, FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__all_adjust_u @@ -1047,7 +1014,6 @@ H5S__all_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *off FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S__all_adjust_s @@ -1078,7 +1044,6 @@ H5S__all_adjust_s(H5S_t H5_ATTR_UNUSED *space, const hssize_t H5_ATTR_UNUSED *of FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_adjust_s() */ - /*------------------------------------------------------------------------- * Function: H5S__all_project_scalar * @@ -1107,7 +1072,6 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_project_scalar() */ - /*------------------------------------------------------------------------- * Function: H5S__all_project_simple * @@ -1122,10 +1086,10 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) *------------------------------------------------------------------------- */ static herr_t -H5S__all_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, - H5S_t *new_space, hsize_t H5_ATTR_UNUSED *offset) +H5S__all_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, H5S_t *new_space, + hsize_t H5_ATTR_UNUSED *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1135,14 +1099,13 @@ H5S__all_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, HDassert(offset); /* Select the entire new space */ - if(H5S_select_all(new_space, TRUE) < 0) + if (H5S_select_all(new_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to set all selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S_select_all @@ -1164,7 +1127,7 @@ done: herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1172,8 +1135,8 @@ H5S_select_all(H5S_t *space, hbool_t rel_prev) HDassert(space); /* Remove current selection first */ - if(rel_prev) - if(H5S_SELECT_RELEASE(space) < 0) + if (rel_prev) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Set number of elements in selection */ @@ -1186,7 +1149,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_all() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_all @@ -1214,14 +1176,13 @@ H5Sselect_all(hid_t spaceid) H5TRACE1("e", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Call internal routine to do the work */ - if(H5S_select_all(space, TRUE) < 0) + if (H5S_select_all(space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_all() */ - diff --git a/src/H5Sdbg.c b/src/H5Sdbg.c index 32f5295..8599b47 100644 --- a/src/H5Sdbg.c +++ b/src/H5Sdbg.c @@ -16,7 +16,7 @@ * Created: H5Sdbg.c * Quincey Koziol * Jul 24 2007 - * + * * * Purpose: Dump debugging information about a dataspace * @@ -27,53 +27,43 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Spkg.h" /* Dataspaces */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Spkg.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5S_debug * @@ -89,34 +79,30 @@ herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5S_t *mesg = (const H5S_t*)_mesg; + const H5S_t *mesg = (const H5S_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR - switch(H5S_GET_EXTENT_TYPE(mesg)) { + switch (H5S_GET_EXTENT_TYPE(mesg)) { case H5S_NULL: - HDfprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth, - "Space class:"); + HDfprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth, "Space class:"); break; case H5S_SCALAR: - HDfprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, - "Space class:"); + HDfprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, "Space class:"); break; case H5S_SIMPLE: - HDfprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth, - "Space class:"); + HDfprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth, "Space class:"); H5O_debug_id(H5O_SDSPACE_ID, f, &(mesg->extent), stream, indent + 3, MAX(0, fwidth - 3)); break; case H5S_NO_CLASS: default: HDfprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth, - "Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg))); + "Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg))); break; } /* end switch */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S_debug() */ - diff --git a/src/H5Sdeprec.c b/src/H5Sdeprec.c index e4ec1b0..a3a32fc 100644 --- a/src/H5Sdeprec.c +++ b/src/H5Sdeprec.c @@ -27,56 +27,47 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Spkg.h" /* Dataspaces */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Spkg.h" /* Dataspaces */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Sencode1 * @@ -95,9 +86,9 @@ herr_t H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc) { - H5S_t *dspace; - hid_t temp_fapl_id = H5P_DEFAULT; - herr_t ret_value=SUCCEED; + H5S_t *dspace; + hid_t temp_fapl_id = H5P_DEFAULT; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x*z", obj_id, buf, nalloc); @@ -107,15 +98,14 @@ H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Use (earliest, latest) i.e. not latest format */ - if(H5S_encode(dspace, (unsigned char **)&buf, nalloc)<0) + if (H5S_encode(dspace, (unsigned char **)&buf, nalloc) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace") done: FUNC_LEAVE_API(ret_value) } /* H5Sencode1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 9f75785..37927a6 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -22,21 +22,19 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ @@ -48,32 +46,31 @@ #define H5S_HYPER_COMPUTE_A_NOT_B 0x04 /* Macro to advance a span, possibly recycling it first */ -#define H5S_HYPER_ADVANCE_SPAN(recover, curr_span, next_span) \ - do { \ - H5S_hyper_span_t *saved_next_span = (next_span); \ - \ - /* Check if the span should be recovered */ \ - if(recover) { \ - H5S__hyper_free_span(curr_span); \ - (recover) = FALSE; \ - } /* end if */ \ - \ - /* Set the current span to saved next span */ \ - (curr_span) = saved_next_span; \ - } while(0) +#define H5S_HYPER_ADVANCE_SPAN(recover, curr_span, next_span) \ + do { \ + H5S_hyper_span_t *saved_next_span = (next_span); \ + \ + /* Check if the span should be recovered */ \ + if (recover) { \ + H5S__hyper_free_span(curr_span); \ + (recover) = FALSE; \ + } /* end if */ \ + \ + /* Set the current span to saved next span */ \ + (curr_span) = saved_next_span; \ + } while (0) /* Macro to add "skipped" elements to projection during the execution of * H5S__hyper_project_intersect() */ -#define H5S_HYPER_PROJ_INT_ADD_SKIP(UDATA, ADD, ERR) \ - do { \ - /* If there are any elements to add, we must add them \ - * to the projection first before adding skip */ \ - if((UDATA)->nelem > 0) \ - if(H5S__hyper_proj_int_build_proj(UDATA) < 0) \ +#define H5S_HYPER_PROJ_INT_ADD_SKIP(UDATA, ADD, ERR) \ + do { \ + /* If there are any elements to add, we must add them \ + * to the projection first before adding skip */ \ + if ((UDATA)->nelem > 0) \ + if (H5S__hyper_proj_int_build_proj(UDATA) < 0) \ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, ERR, "can't add elements to projected selection") \ - (UDATA)->skip += (ADD); \ - } while(0) /* end H5S_HYPER_PROJ_INT_ADD_SKIP() */ - + (UDATA)->skip += (ADD); \ + } while (0) /* end H5S_HYPER_PROJ_INT_ADD_SKIP() */ /******************/ /* Local Typedefs */ @@ -86,17 +83,20 @@ typedef hsize_t hbounds_t; /* Struct for holding persistent information during iteration for * H5S__hyper_project_intersect() */ typedef struct { - const H5S_hyper_span_t *ds_span[H5S_MAX_RANK]; /* Array of the current spans in the destination space in each dimension */ + const H5S_hyper_span_t + * ds_span[H5S_MAX_RANK]; /* Array of the current spans in the destination space in each dimension */ hsize_t ds_low[H5S_MAX_RANK]; /* Array of current low bounds (of iteration) for each element in ds_span */ - H5S_hyper_span_info_t *ps_span_info[H5S_MAX_RANK]; /* Array of span info structs for projected space during iteration */ - uint32_t ps_clean_bitmap; /* Bitmap of whether the nth rank has a clean projected space since the last time it was set to 1 */ - unsigned ss_rank; /* Rank of source space */ - unsigned ds_rank; /* Rank of destination space */ - unsigned depth; /* Current depth of iterator in destination space */ - hsize_t skip; /* Number of elements to skip in projected space */ - hsize_t nelem; /* Number of elements to add to projected space (after skip) */ - uint64_t op_gen; /* Operation generation for counting elements */ - hbool_t share_selection; /* Whether span trees in dst_space can be shared with proj_space */ + H5S_hyper_span_info_t + * ps_span_info[H5S_MAX_RANK]; /* Array of span info structs for projected space during iteration */ + uint32_t ps_clean_bitmap; /* Bitmap of whether the nth rank has a clean projected space since the last + time it was set to 1 */ + unsigned ss_rank; /* Rank of source space */ + unsigned ds_rank; /* Rank of destination space */ + unsigned depth; /* Current depth of iterator in destination space */ + hsize_t skip; /* Number of elements to skip in projected space */ + hsize_t nelem; /* Number of elements to add to projected space (after skip) */ + uint64_t op_gen; /* Operation generation for counting elements */ + hbool_t share_selection; /* Whether span trees in dst_space can be shared with proj_space */ } H5S_hyper_project_intersect_ud_t; /* Assert that H5S_MAX_RANK is <= 32 so our trick with using a 32 bit bitmap @@ -106,116 +106,106 @@ typedef struct { #error H5S_MAX_RANK too large for ps_clean_bitmap field in H5S_hyper_project_intersect_ud_t struct #endif - /********************/ /* Local Prototypes */ /********************/ -static H5S_hyper_span_t *H5S__hyper_new_span(hsize_t low, hsize_t high, - H5S_hyper_span_info_t *down, H5S_hyper_span_t *next); +static H5S_hyper_span_t * H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, + H5S_hyper_span_t *next); static H5S_hyper_span_info_t *H5S__hyper_new_span_info(unsigned rank); -static H5S_hyper_span_info_t *H5S__hyper_copy_span_helper( - H5S_hyper_span_info_t *spans, unsigned rank, unsigned op_info_i, - uint64_t op_gen); -static H5S_hyper_span_info_t *H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, - unsigned rank); -static hbool_t H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, - const H5S_hyper_span_info_t *span_info2); -static void H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info); -static void H5S__hyper_free_span(H5S_hyper_span_t *span); -static herr_t H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, - hsize_t start[], hsize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks, - hsize_t **buf); -static herr_t H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, - hsize_t numblocks, hsize_t *buf); +static H5S_hyper_span_info_t *H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, + unsigned op_info_i, uint64_t op_gen); +static H5S_hyper_span_info_t *H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank); +static hbool_t H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, + const H5S_hyper_span_info_t *span_info2); +static void H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info); +static void H5S__hyper_free_span(H5S_hyper_span_t *span); +static herr_t H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], hsize_t end[], + hsize_t rank, hsize_t *startblock, hsize_t *numblocks, hsize_t **buf); +static herr_t H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks, + hsize_t *buf); static H5S_hyper_span_t *H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords); -static herr_t H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, - unsigned ndims, hsize_t low, hsize_t high, H5S_hyper_span_info_t *down); -static herr_t H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, - H5S_hyper_span_info_t *b_spans, unsigned selector, - unsigned ndims, H5S_hyper_span_info_t **a_not_b, - H5S_hyper_span_info_t **a_and_b, H5S_hyper_span_info_t **b_not_a); -static herr_t H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans); -static hsize_t H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, - unsigned op_info_i, uint64_t op_gen); +static herr_t H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, hsize_t low, + hsize_t high, H5S_hyper_span_info_t *down); +static herr_t H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, + unsigned selector, unsigned ndims, H5S_hyper_span_info_t **a_not_b, + H5S_hyper_span_info_t **a_and_b, H5S_hyper_span_info_t **b_not_a); +static herr_t H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans); +static hsize_t H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, + uint64_t op_gen); static hsize_t H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans); -static herr_t H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans); -static H5S_hyper_span_info_t *H5S__hyper_make_spans(unsigned rank, - const hsize_t *start, const hsize_t *stride, - const hsize_t *count, const hsize_t *block); -static herr_t H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, - const H5S_hyper_dim_t *new_hyper_diminfo); -static herr_t H5S__hyper_generate_spans(H5S_t *space); -static hbool_t H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, - const H5S_hyper_span_info_t *spans2); -static herr_t H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, - H5S_hyper_span_info_t *space2_span_lst, hbool_t can_own_span2, - hbool_t *span2_owned, hbool_t *updated_spans, H5S_t **result); -static herr_t H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, - const hsize_t start[], const hsize_t stride[], const hsize_t count[], - const hsize_t block[]); -static herr_t H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], - const hsize_t *app_stride, const hsize_t app_count[], const hsize_t *app_block, - const hsize_t *opt_stride, const hsize_t opt_count[], const hsize_t *opt_block); -static herr_t H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, - H5S_t **result); -static H5S_t *H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2); -static herr_t H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); -static herr_t H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); -static herr_t H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); -static herr_t H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata); -static herr_t H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, - const H5S_hyper_span_info_t *sis_span_info, hsize_t count, unsigned depth, - H5S_hyper_project_intersect_ud_t *udata); -static void H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, - hsize_t *count, hsize_t *block, hsize_t clip_size); -static hsize_t H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, - hsize_t num_slices, hbool_t incl_trail); +static herr_t H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans); +static H5S_hyper_span_info_t *H5S__hyper_make_spans(unsigned rank, const hsize_t *start, + const hsize_t *stride, const hsize_t *count, + const hsize_t *block); +static herr_t H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, + const H5S_hyper_dim_t *new_hyper_diminfo); +static herr_t H5S__hyper_generate_spans(H5S_t *space); +static hbool_t H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, + const H5S_hyper_span_info_t *spans2); +static herr_t H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, H5S_hyper_span_info_t *space2_span_lst, + hbool_t can_own_span2, hbool_t *span2_owned, hbool_t *updated_spans, + H5S_t **result); +static herr_t H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], + const hsize_t stride[], const hsize_t count[], const hsize_t block[]); +static herr_t H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], const hsize_t *app_stride, + const hsize_t app_count[], const hsize_t *app_block, + const hsize_t *opt_stride, const hsize_t opt_count[], + const hsize_t *opt_block); +static herr_t H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **result); +static H5S_t * H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2); +static herr_t H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, + size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); +static herr_t H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, + size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); +static herr_t H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, + size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); +static herr_t H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata); +static herr_t H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, + const H5S_hyper_span_info_t *sis_span_info, hsize_t count, + unsigned depth, H5S_hyper_project_intersect_ud_t *udata); +static void H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, hsize_t *block, + hsize_t clip_size); +static hsize_t H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, + hbool_t incl_trail); /* Selection callbacks */ -static herr_t H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -static herr_t H5S__hyper_release(H5S_t *space); -static htri_t H5S__hyper_is_valid(const H5S_t *space); -static hsize_t H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans); +static herr_t H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S__hyper_release(H5S_t *space); +static htri_t H5S__hyper_is_valid(const H5S_t *space); +static hsize_t H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans); static hssize_t H5S__hyper_serial_size(const H5S_t *space); -static herr_t H5S__hyper_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__hyper_deserialize(H5S_t **space, const uint8_t **p); -static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); -static herr_t H5S__hyper_offset(const H5S_t *space, hsize_t *offset); -static int H5S__hyper_unlim_dim(const H5S_t *space); -static herr_t H5S__hyper_num_elem_non_unlim(const H5S_t *space, - hsize_t *num_elem_non_unlim); -static htri_t H5S__hyper_is_contiguous(const H5S_t *space); -static htri_t H5S__hyper_is_single(const H5S_t *space); -static htri_t H5S__hyper_is_regular(const H5S_t *space); -static htri_t H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, - const hsize_t *end); -static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset); -static herr_t H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset); -static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset); -static herr_t H5S__hyper_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__hyper_serialize(const H5S_t *space, uint8_t **p); +static herr_t H5S__hyper_deserialize(H5S_t **space, const uint8_t **p); +static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +static herr_t H5S__hyper_offset(const H5S_t *space, hsize_t *offset); +static int H5S__hyper_unlim_dim(const H5S_t *space); +static herr_t H5S__hyper_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim); +static htri_t H5S__hyper_is_contiguous(const H5S_t *space); +static htri_t H5S__hyper_is_single(const H5S_t *space); +static htri_t H5S__hyper_is_regular(const H5S_t *space); +static htri_t H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset); +static herr_t H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset); +static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset); +static herr_t H5S__hyper_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); +static herr_t H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ -static herr_t H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__hyper_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *sel_iter); -static herr_t H5S__hyper_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__hyper_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); +static htri_t H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *sel_iter); +static herr_t H5S__hyper_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__hyper_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S__hyper_iter_release(H5S_sel_iter_t *sel_iter); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -249,11 +239,11 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{ /* Format version bounds for dataspace hyperslab selection */ const unsigned H5O_sds_hyper_ver_bounds[] = { - H5S_HYPER_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5S_HYPER_VERSION_1, /* H5F_LIBVER_V18 */ - H5S_HYPER_VERSION_2, /* H5F_LIBVER_V110 */ - H5S_HYPER_VERSION_3, /* H5F_LIBVER_V112 */ - H5S_HYPER_VERSION_3 /* H5F_LIBVER_LATEST */ + H5S_HYPER_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5S_HYPER_VERSION_1, /* H5F_LIBVER_V18 */ + H5S_HYPER_VERSION_2, /* H5F_LIBVER_V110 */ + H5S_HYPER_VERSION_3, /* H5F_LIBVER_V112 */ + H5S_HYPER_VERSION_3 /* H5F_LIBVER_LATEST */ }; /*******************/ @@ -276,16 +266,10 @@ static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{ }}; /* Arrays for default stride, block, etc. */ -static const hsize_t H5S_hyper_zeros_g[H5S_MAX_RANK] = { - 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0}; -static const hsize_t H5S_hyper_ones_g[H5S_MAX_RANK] = { - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1}; +static const hsize_t H5S_hyper_zeros_g[H5S_MAX_RANK] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static const hsize_t H5S_hyper_ones_g[H5S_MAX_RANK] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; /* Declare a free list to manage the H5S_hyper_sel_t struct */ H5FL_DEFINE_STATIC(H5S_hyper_sel_t); @@ -303,7 +287,6 @@ H5FL_EXTERN(H5S_sel_iter_t); /* (Start with '1' to avoid clashing with '0' value in newly allocated structs) */ static uint64_t H5S_hyper_op_gen_g = 1; - /* Uncomment this to provide the debugging routines for printing selection info */ /* #define H5S_HYPER_DEBUG */ #ifdef H5S_HYPER_DEBUG @@ -312,10 +295,13 @@ H5S__hyper_print_spans_helper(FILE *f, const H5S_hyper_span_t *span, unsigned de { FUNC_ENTER_STATIC_NOERR - while(span) { - HDfprintf(f,"%s: %*sdepth=%u, span=%p, (%Hu, %Hu), next=%p\n", FUNC, depth * 2, "", depth, span, span->low, span->high, span->next); - if(span->down) { - HDfprintf(f,"%s: %*sspans=%p, count=%u, bounds[0]={%Hu, %Hu}, head=%p\n", FUNC, (depth + 1) * 2, "", span->down, span->down->count, span->down->low_bounds[0], span->down->high_bounds[0], span->down->head); + while (span) { + HDfprintf(f, "%s: %*sdepth=%u, span=%p, (%Hu, %Hu), next=%p\n", FUNC, depth * 2, "", depth, span, + span->low, span->high, span->next); + if (span->down) { + HDfprintf(f, "%s: %*sspans=%p, count=%u, bounds[0]={%Hu, %Hu}, head=%p\n", FUNC, (depth + 1) * 2, + "", span->down, span->down->count, span->down->low_bounds[0], + span->down->high_bounds[0], span->down->head); H5S__hyper_print_spans_helper(f, span->down->head, depth + 1); } /* end if */ span = span->next; @@ -329,8 +315,9 @@ H5S__hyper_print_spans(FILE *f, const H5S_hyper_span_info_t *span_lst) { FUNC_ENTER_STATIC_NOERR - if(span_lst != NULL) { - HDfprintf(f, "%s: spans=%p, count=%u, bounds[0]={%Hu, %Hu}, head=%p\n", FUNC, span_lst, span_lst->count, span_lst->low_bounds[0], span_lst->high_bounds[0], span_lst->head); + if (span_lst != NULL) { + HDfprintf(f, "%s: spans=%p, count=%u, bounds[0]={%Hu, %Hu}, head=%p\n", FUNC, span_lst, + span_lst->count, span_lst->low_bounds[0], span_lst->high_bounds[0], span_lst->head); H5S__hyper_print_spans_helper(f, span_lst->head, 0); } /* end if */ @@ -350,22 +337,22 @@ H5S__space_print_spans(FILE *f, const H5S_t *space) static herr_t H5S__hyper_print_diminfo_helper(FILE *f, const char *field, unsigned ndims, const H5S_hyper_dim_t *dinfo) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR - if(dinfo != NULL) { + if (dinfo != NULL) { HDfprintf(f, "%s: %s: start=[", FUNC, field); - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) HDfprintf(f, "%Hd%s", dinfo[u].start, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: stride=[", FUNC, field); - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) HDfprintf(f, "%Hu%s", dinfo[u].stride, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: count=[", FUNC, field); - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) HDfprintf(f, "%Hu%s", dinfo[u].count, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: block=[", FUNC, field); - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) HDfprintf(f, "%Hu%s", dinfo[u].block, (u < (ndims - 1) ? ", " : "]\n")); } /* end if */ else @@ -379,13 +366,14 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space) { FUNC_ENTER_STATIC_NOERR - H5S__hyper_print_diminfo_helper(f, "diminfo.opt", space->extent.rank, space->select.sel_info.hslab->diminfo.opt); - H5S__hyper_print_diminfo_helper(f, "diminfo.app", space->extent.rank, space->select.sel_info.hslab->diminfo.app); + H5S__hyper_print_diminfo_helper(f, "diminfo.opt", space->extent.rank, + space->select.sel_info.hslab->diminfo.opt); + H5S__hyper_print_diminfo_helper(f, "diminfo.app", space->extent.rank, + space->select.sel_info.hslab->diminfo.app); FUNC_LEAVE_NOAPI(SUCCEED) } - /*-------------------------------------------------------------------------- NAME H5S__hyper_print_spans_dfs @@ -404,53 +392,52 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_print_spans_dfs(FILE *f, const H5S_hyper_span_info_t *span_lst, - unsigned depth, unsigned dims) +H5S__hyper_print_spans_dfs(FILE *f, const H5S_hyper_span_info_t *span_lst, unsigned depth, unsigned dims) { H5S_hyper_span_t *actual_tail = NULL; H5S_hyper_span_t *cur_elem; - unsigned num_elems = 0; - unsigned u, elem_idx; + unsigned num_elems = 0; + unsigned u, elem_idx; FUNC_ENTER_STATIC_NOERR /* get the actual tail from head */ cur_elem = span_lst->head; HDassert(cur_elem); /* at least 1 element */ - while(cur_elem) { + while (cur_elem) { actual_tail = cur_elem; - cur_elem = cur_elem->next; + cur_elem = cur_elem->next; num_elems++; } /* end while */ - for(u = 0; u < depth; u++) + for (u = 0; u < depth; u++) HDfprintf(f, "\t"); HDfprintf(f, "DIM[%u]: ref_count=%u, #elems=%u, head=%p, tail=%p, actual_tail=%p, matched=%t\n", depth, - span_lst->count, num_elems, span_lst->head, - span_lst->tail, actual_tail, (span_lst->tail == actual_tail)); + span_lst->count, num_elems, span_lst->head, span_lst->tail, actual_tail, + (span_lst->tail == actual_tail)); - for(u = 0; u < depth; u++) + for (u = 0; u < depth; u++) HDfprintf(f, "\t"); HDfprintf(f, "low_bounds=["); - for(u = 0; u < dims - 1; u++) + for (u = 0; u < dims - 1; u++) HDfprintf(f, "%llu,", span_lst->low_bounds[u]); HDfprintf(f, "%llu]\n", span_lst->low_bounds[dims - 1]); - for(u = 0; u < depth; u++) + for (u = 0; u < depth; u++) HDfprintf(f, "\t"); HDfprintf(f, "high_bounds=["); - for(u = 0; u < dims - 1; u++) + for (u = 0; u < dims - 1; u++) HDfprintf(f, "%llu,", span_lst->high_bounds[u]); HDfprintf(f, "%llu]\n", span_lst->high_bounds[dims - 1]); cur_elem = span_lst->head; elem_idx = 0; - while(cur_elem) { - for(u = 0; u < depth; u++) + while (cur_elem) { + for (u = 0; u < depth; u++) HDfprintf(f, "\t"); - HDfprintf(f, "ELEM[%u]: ptr=%p, low=%Hu, high=%Hu, down=%p\n", - elem_idx++, cur_elem, cur_elem->low, cur_elem->high, cur_elem->down); - if(cur_elem->down) + HDfprintf(f, "ELEM[%u]: ptr=%p, low=%Hu, high=%Hu, down=%p\n", elem_idx++, cur_elem, cur_elem->low, + cur_elem->high, cur_elem->down); + if (cur_elem->down) H5S__hyper_print_spans_dfs(f, cur_elem->down, depth + 1, dims); cur_elem = cur_elem->next; } /* end while */ @@ -458,7 +445,6 @@ H5S__hyper_print_spans_dfs(FILE *f, const H5S_hyper_span_info_t *span_lst, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_print_spans_dfs() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_print_space_dfs @@ -479,51 +465,52 @@ static herr_t H5S__hyper_print_space_dfs(FILE *f, const H5S_t *space) { const H5S_hyper_sel_t *hslab = space->select.sel_info.hslab; - const unsigned dims = space->extent.rank; - unsigned u; + const unsigned dims = space->extent.rank; + unsigned u; FUNC_ENTER_STATIC_NOERR HDassert(hslab); HDfprintf(f, "=======================\n"); - HDfprintf(f, "SPACE: span_lst=%p, #dims=%u, offset_changed=%d\n", hslab->span_lst, dims, space->select.offset_changed); + HDfprintf(f, "SPACE: span_lst=%p, #dims=%u, offset_changed=%d\n", hslab->span_lst, dims, + space->select.offset_changed); HDfprintf(f, " offset=["); - for(u = 0; u < dims - 1; u++) + for (u = 0; u < dims - 1; u++) HDfprintf(f, "%lld,", space->select.offset[u]); HDfprintf(f, "%lld]\n", space->select.offset[dims - 1]); HDfprintf(f, " low_bounds=["); - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < dims - 1; u++) + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + for (u = 0; u < dims - 1; u++) HDfprintf(f, "%llu,", space->select.sel_info.hslab->diminfo.low_bounds[u]); HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->diminfo.low_bounds[dims - 1]); } /* end if */ else { - for(u = 0; u < dims - 1; u++) + for (u = 0; u < dims - 1; u++) HDfprintf(f, "%llu,", space->select.sel_info.hslab->span_lst->low_bounds[u]); HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->span_lst->low_bounds[dims - 1]); } /* end else */ HDfprintf(f, " high_bounds=["); - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < dims - 1; u++) + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + for (u = 0; u < dims - 1; u++) HDfprintf(f, "%llu,", space->select.sel_info.hslab->diminfo.high_bounds[u]); HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->diminfo.high_bounds[dims - 1]); } /* end if */ else { - for(u = 0; u < dims - 1; u++) + for (u = 0; u < dims - 1; u++) HDfprintf(f, "%llu,", space->select.sel_info.hslab->span_lst->high_bounds[u]); HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->span_lst->high_bounds[dims - 1]); } /* end else */ /* Print out diminfo, if it's valid */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) H5S__hyper_print_diminfo(f, space); /* Start print out the highest-order of dimension */ - if(hslab->span_lst) + if (hslab->span_lst) H5S__hyper_print_spans_dfs(f, hslab->span_lst, 0, dims); HDfprintf(f, "=======================\n\n"); @@ -531,7 +518,6 @@ H5S__hyper_print_space_dfs(FILE *f, const H5S_t *space) } /* end H5S__hyper_print_space_dfs() */ #endif /* H5S_HYPER_DEBUG */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_get_op_gen * @@ -555,7 +541,6 @@ H5S__hyper_get_op_gen(void) FUNC_LEAVE_NOAPI(H5S_hyper_op_gen_g++); } /* end H5S__hyper_op_gen() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_init * @@ -576,13 +561,13 @@ H5S__hyper_get_op_gen(void) static herr_t H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) { - hsize_t *slab_size; /* Pointer to the dataspace dimensions to use for calc. slab */ - hsize_t acc; /* Accumulator for computing cumulative sizes */ - unsigned slab_dim; /* Rank of the fastest changing dimension for calc. slab */ - unsigned rank; /* Dataspace's dimension rank */ - unsigned u; /* Index variable */ - int i; /* Index variable */ - herr_t ret_value = SUCCEED; /* return value */ + hsize_t *slab_size; /* Pointer to the dataspace dimensions to use for calc. slab */ + hsize_t acc; /* Accumulator for computing cumulative sizes */ + unsigned slab_dim; /* Rank of the fastest changing dimension for calc. slab */ + unsigned rank; /* Dataspace's dimension rank */ + unsigned u; /* Index variable */ + int i; /* Index variable */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -600,15 +585,15 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) /* Attempt to rebuild diminfo if it is invalid and has not been confirmed * to be impossible. */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */ /* Check for the special case of just one H5Sselect_hyperslab call made */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { -/* Initialize the information needed for regular hyperslab I/O */ - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - const hsize_t *mem_size; /* Temporary pointer to dataspace extent's dimension sizes */ - unsigned cont_dim = 0; /* # of contiguous dimensions */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + /* Initialize the information needed for regular hyperslab I/O */ + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + const hsize_t * mem_size; /* Temporary pointer to dataspace extent's dimension sizes */ + unsigned cont_dim = 0; /* # of contiguous dimensions */ /* Set the temporary pointer to the dimension information */ tdiminfo = space->select.sel_info.hslab->diminfo.opt; @@ -626,10 +611,10 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) /* Don't flatten adjacent elements into contiguous block if the * element size is 0. This is for the H5S_select_shape_same() code. */ - if(iter->elmt_size > 0) { + if (iter->elmt_size > 0) { /* Check for any "contiguous" blocks that can be flattened */ - for(u = (rank - 1); u > 0; u--) { - if(tdiminfo[u].count == 1 && tdiminfo[u].block == mem_size[u]) { + for (u = (rank - 1); u > 0; u--) { + if (tdiminfo[u].count == 1 && tdiminfo[u].block == mem_size[u]) { cont_dim++; iter->u.hyp.flattened[u] = TRUE; } /* end if */ @@ -640,18 +625,18 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) } /* end if */ /* Check if the regular selection can be "flattened" */ - if(cont_dim > 0) { - hbool_t last_dim_flattened = TRUE; /* Flag to indicate that the last dimension was flattened */ - unsigned flat_rank = rank-cont_dim; /* Number of dimensions after flattening */ - unsigned curr_dim; /* Current dimension */ + if (cont_dim > 0) { + hbool_t last_dim_flattened = TRUE; /* Flag to indicate that the last dimension was flattened */ + unsigned flat_rank = rank - cont_dim; /* Number of dimensions after flattening */ + unsigned curr_dim; /* Current dimension */ /* Set the iterator's rank to the contiguous dimensions */ iter->u.hyp.iter_rank = flat_rank; /* "Flatten" dataspace extent and selection information */ curr_dim = flat_rank - 1; - for(i = (int)rank - 1, acc = 1; i >= 0; i--) { - if(tdiminfo[i].block == mem_size[i] && i > 0) { + for (i = (int)rank - 1, acc = 1; i >= 0; i--) { + if (tdiminfo[i].block == mem_size[i] && i > 0) { /* "Flatten" this dimension */ HDassert(tdiminfo[i].start == 0); acc *= mem_size[i]; @@ -660,19 +645,19 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) last_dim_flattened = TRUE; } /* end if */ else { - if(last_dim_flattened) { + if (last_dim_flattened) { /* First dimension after flattened dimensions */ iter->u.hyp.diminfo[curr_dim].start = tdiminfo[i].start * acc; /* Special case for single block regular selections */ - if(tdiminfo[i].count == 1) + if (tdiminfo[i].count == 1) iter->u.hyp.diminfo[curr_dim].stride = 1; else iter->u.hyp.diminfo[curr_dim].stride = tdiminfo[i].stride * acc; iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block * acc; - iter->u.hyp.size[curr_dim] = mem_size[i] * acc; - iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i] * (hssize_t)acc; + iter->u.hyp.size[curr_dim] = mem_size[i] * acc; + iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i] * (hssize_t)acc; /* Reset the "last dim flattened" flag to avoid flattened any further dimensions */ last_dim_flattened = FALSE; @@ -682,38 +667,40 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) } /* end if */ else { /* All other dimensions */ - iter->u.hyp.diminfo[curr_dim].start = tdiminfo[i].start; + iter->u.hyp.diminfo[curr_dim].start = tdiminfo[i].start; iter->u.hyp.diminfo[curr_dim].stride = tdiminfo[i].stride; - iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; - iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block; - iter->u.hyp.size[curr_dim] = mem_size[i]; - iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i]; + iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; + iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block; + iter->u.hyp.size[curr_dim] = mem_size[i]; + iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i]; } /* end else */ /* Decrement "current" flattened dimension */ curr_dim--; } /* end if */ - } /* end for */ + } /* end for */ - /* Initialize "flattened" iterator offset to initial location and dataspace extent and selection information to correct values */ - for(u = 0; u < flat_rank; u++) + /* Initialize "flattened" iterator offset to initial location and dataspace extent and selection + * information to correct values */ + for (u = 0; u < flat_rank; u++) iter->u.hyp.off[u] = iter->u.hyp.diminfo[u].start; /* Set up information for computing slab sizes */ - slab_dim = iter->u.hyp.iter_rank - 1; + slab_dim = iter->u.hyp.iter_rank - 1; slab_size = iter->u.hyp.size; } /* end if */ else { /* Make local copy of the regular selection information */ - HDcompile_assert(sizeof(iter->u.hyp.diminfo) == sizeof(space->select.sel_info.hslab->diminfo.opt)); + HDcompile_assert(sizeof(iter->u.hyp.diminfo) == + sizeof(space->select.sel_info.hslab->diminfo.opt)); H5MM_memcpy(iter->u.hyp.diminfo, tdiminfo, sizeof(iter->u.hyp.diminfo)); /* Initialize position to initial location */ - for(u = 0; u < rank; u++) + for (u = 0; u < rank; u++) iter->u.hyp.off[u] = tdiminfo[u].start; /* Set up information for computing slab sizes */ - slab_dim = iter->rank - 1; + slab_dim = iter->rank - 1; slab_size = iter->dims; } /* end else */ @@ -722,9 +709,9 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) /* Initialize irregular region information also (for release) */ iter->u.hyp.spans = NULL; - } /* end if */ - else { /* Initialize the information needed for non-regular hyperslab I/O */ - H5S_hyper_span_info_t *spans; /* Pointer to hyperslab span info node */ + } /* end if */ + else { /* Initialize the information needed for non-regular hyperslab I/O */ + H5S_hyper_span_info_t *spans; /* Pointer to hyperslab span info node */ /* If this iterator is created from an API call, by default we clone the * selection now, as the dataspace could be modified or go out of scope. @@ -735,10 +722,10 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) * close the dataspace that the iterator is operating on, or undefined * behavior will occur. */ - if((iter->flags & H5S_SEL_ITER_API_CALL) && - !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) { + if ((iter->flags & H5S_SEL_ITER_API_CALL) && !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) { /* Copy the span tree */ - if(NULL == (iter->u.hyp.spans = H5S__hyper_copy_span(space->select.sel_info.hslab->span_lst, space->extent.rank))) + if (NULL == (iter->u.hyp.spans = H5S__hyper_copy_span(space->select.sel_info.hslab->span_lst, + space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy span tree") } /* end if */ else { @@ -750,7 +737,7 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) /* Initialize the starting span_info's and spans */ spans = iter->u.hyp.spans; - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { /* Set the pointers to the initial span in each dimension */ HDassert(spans); HDassert(spans->head); @@ -766,7 +753,7 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) } /* end for */ /* Set up information for computing slab sizes */ - slab_dim = iter->rank - 1; + slab_dim = iter->rank - 1; slab_size = iter->dims; /* Flag the diminfo information as not valid in the iterator */ @@ -774,17 +761,18 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) } /* end else */ /* Compute the cumulative size of dataspace dimensions */ - for(i = (int)slab_dim, acc = iter->elmt_size; i >= 0; i--) { + for (i = (int)slab_dim, acc = iter->elmt_size; i >= 0; i--) { iter->u.hyp.slab[i] = acc; acc *= slab_size[i]; } /* end for */ /* Initialize more information for irregular hyperslab selections */ - if(!iter->u.hyp.diminfo_valid) { + if (!iter->u.hyp.diminfo_valid) { /* Set the offset of the first element iterated on, in each dimension */ - for(u = 0; u < rank; u++) + for (u = 0; u < rank; u++) /* Compute the sequential element offset */ - iter->u.hyp.loc_off[u] = ((hsize_t)((hssize_t)iter->u.hyp.off[u] + iter->sel_off[u])) * iter->u.hyp.slab[u]; + iter->u.hyp.loc_off[u] = + ((hsize_t)((hssize_t)iter->u.hyp.off[u] + iter->sel_off[u])) * iter->u.hyp.slab[u]; } /* end if */ /* Initialize type of selection iterator */ @@ -794,7 +782,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_coords * @@ -820,34 +807,35 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) /* Copy the offset of the current point */ /* Check for a single "regular" hyperslab */ - if(iter->u.hyp.diminfo_valid) { + if (iter->u.hyp.diminfo_valid) { /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { - int u, v; /* Dimension indices */ + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { + int u, v; /* Dimension indices */ /* Set the starting rank of both the "natural" & "flattened" dimensions */ u = (int)iter->rank - 1; v = (int)iter->u.hyp.iter_rank - 1; /* Construct the "natural" dimensions from a set of flattened coordinates */ - while(u >= 0) { - if(iter->u.hyp.flattened[u]) { - int begin = u; /* The rank of the first flattened dimension */ + while (u >= 0) { + if (iter->u.hyp.flattened[u]) { + int begin = u; /* The rank of the first flattened dimension */ /* Walk up through as many flattened dimensions as possible */ do { u--; - } while(u >= 0 && iter->u.hyp.flattened[u]); + } while (u >= 0 && iter->u.hyp.flattened[u]); /* Compensate for possibly overshooting dim 0 */ - if(u < 0) + if (u < 0) u = 0; /* Sanity check */ HDassert(v >= 0); /* Compute the coords for the flattened dimensions */ - H5VM_array_calc(iter->u.hyp.off[v], (unsigned)((begin - u) + 1), &(iter->dims[u]), &(coords[u])); + H5VM_array_calc(iter->u.hyp.off[v], (unsigned)((begin - u) + 1), &(iter->dims[u]), + &(coords[u])); /* Continue to faster dimension in both indices */ u--; @@ -855,7 +843,7 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) } /* end if */ else { /* Walk up through as many non-flattened dimensions as possible */ - while(u >= 0 && !iter->u.hyp.flattened[u]) { + while (u >= 0 && !iter->u.hyp.flattened[u]) { /* Sanity check */ HDassert(v >= 0); @@ -866,8 +854,8 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) u--; v--; } /* end while */ - } /* end else */ - } /* end while */ + } /* end else */ + } /* end while */ HDassert(v < 0); } /* end if */ else @@ -879,7 +867,6 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_coords() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_block * @@ -899,7 +886,7 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) static herr_t H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -911,25 +898,24 @@ H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) /* Copy the offset of the current point */ /* Check for a single "regular" hyperslab */ - if(iter->u.hyp.diminfo_valid) { + if (iter->u.hyp.diminfo_valid) { /* Copy the start and compute the end of the block */ - for(u = 0; u < iter->rank; u++) { + for (u = 0; u < iter->rank; u++) { start[u] = iter->u.hyp.off[u]; - end[u] = (start[u] + iter->u.hyp.diminfo[u].block) - 1; + end[u] = (start[u] + iter->u.hyp.diminfo[u].block) - 1; } } /* end if */ else { /* Copy the start & end of the block */ - for(u = 0; u < iter->rank; u++) { + for (u = 0; u < iter->rank; u++) { start[u] = iter->u.hyp.span[u]->low; - end[u] = iter->u.hyp.span[u]->high; + end[u] = iter->u.hyp.span[u]->high; } } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_nelmts * @@ -953,7 +939,6 @@ H5S__hyper_iter_nelmts(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(iter->elmt_left) } /* end H5S__hyper_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_has_next_block @@ -975,7 +960,7 @@ static H5_ATTR_PURE htri_t H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter) { unsigned u; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -983,25 +968,25 @@ H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter) HDassert(iter); /* Check for a single "regular" hyperslab */ - if(iter->u.hyp.diminfo_valid) { - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - const hsize_t *toff; /* Temporary offset in selection */ + if (iter->u.hyp.diminfo_valid) { + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + const hsize_t * toff; /* Temporary offset in selection */ /* Check if the offset of the iterator is at the last location in all dimensions */ tdiminfo = iter->u.hyp.diminfo; - toff = iter->u.hyp.off; - for(u = 0; u < iter->rank; u++) { + toff = iter->u.hyp.off; + for (u = 0; u < iter->rank; u++) { /* If there is only one block, continue */ - if(tdiminfo[u].count == 1) + if (tdiminfo[u].count == 1) continue; - if(toff[u] != (tdiminfo[u].start + ((tdiminfo[u].count - 1) * tdiminfo[u].stride))) + if (toff[u] != (tdiminfo[u].start + ((tdiminfo[u].count - 1) * tdiminfo[u].stride))) HGOTO_DONE(TRUE); } /* end for */ - } /* end if */ + } /* end if */ else { /* Check for any levels of the tree with more sequences in them */ - for(u = 0; u < iter->rank; u++) - if(iter->u.hyp.span[u]->next != NULL) + for (u = 0; u < iter->rank; u++) + if (iter->u.hyp.span[u]->next != NULL) HGOTO_DONE(TRUE); } /* end else */ @@ -1009,7 +994,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_has_next_block() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_next * @@ -1027,22 +1011,22 @@ done: static herr_t H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) { - unsigned ndims; /* Number of dimensions of dataset */ - int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned u; /* Counters */ + unsigned ndims; /* Number of dimensions of dataset */ + int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned u; /* Counters */ FUNC_ENTER_STATIC_NOERR /* Check for the special case of just one H5Sselect_hyperslab call made */ /* (i.e. a regular hyperslab selection */ - if(iter->u.hyp.diminfo_valid) { - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - hsize_t iter_offset[H5S_MAX_RANK]; - hsize_t iter_count[H5S_MAX_RANK]; - int temp_dim; /* Temporary rank holder */ + if (iter->u.hyp.diminfo_valid) { + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + hsize_t iter_offset[H5S_MAX_RANK]; + hsize_t iter_count[H5S_MAX_RANK]; + int temp_dim; /* Temporary rank holder */ /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) /* Set the aliases for the dimension rank */ ndims = iter->u.hyp.iter_rank; else @@ -1056,25 +1040,25 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) tdiminfo = iter->u.hyp.diminfo; /* Calculate the offset and block count for each dimension */ - for(u = 0; u < ndims; u++) { - if(tdiminfo[u].count == 1) { + for (u = 0; u < ndims; u++) { + if (tdiminfo[u].count == 1) { iter_offset[u] = iter->u.hyp.off[u] - tdiminfo[u].start; - iter_count[u] = 0; + iter_count[u] = 0; } /* end if */ else { iter_offset[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride; - iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; + iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; } /* end else */ - } /* end for */ + } /* end for */ /* Loop through, advancing the offset & counts, until all the nelements are accounted for */ - while(nelem > 0) { + while (nelem > 0) { /* Start with the fastest changing dimension */ temp_dim = fast_dim; - while(temp_dim >= 0) { - if(temp_dim == fast_dim) { - size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ - hsize_t block_elem; /* Number of elements left in a block */ + while (temp_dim >= 0) { + if (temp_dim == fast_dim) { + size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ + hsize_t block_elem; /* Number of elements left in a block */ /* Compute the number of elements left in block */ block_elem = tdiminfo[temp_dim].block - iter_offset[temp_dim]; @@ -1092,59 +1076,61 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* Move to the next row in the current dimension */ iter_offset[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(iter_offset[temp_dim] < tdiminfo[temp_dim].block) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (iter_offset[temp_dim] < tdiminfo[temp_dim].block) break; else { /* Move to the next block in the current dimension */ iter_offset[temp_dim] = 0; iter_count[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(iter_count[temp_dim] < tdiminfo[temp_dim].count) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (iter_count[temp_dim] < tdiminfo[temp_dim].count) break; else iter_count[temp_dim] = 0; /* reset back to the beginning of the line */ - } /* end else */ + } /* end else */ /* Decrement dimension count */ temp_dim--; } /* end while */ - } /* end while */ + } /* end while */ /* Translate current iter_offset and iter_count into iterator position */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) iter->u.hyp.off[u] = tdiminfo[u].start + (tdiminfo[u].stride * iter_count[u]) + iter_offset[u]; } /* end if */ /* Must be an irregular hyperslab selection */ else { - H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ - H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t *abs_arr; /* Absolute hyperslab span position */ - int curr_dim; /* Temporary rank holder */ + H5S_hyper_span_t * curr_span; /* Current hyperslab span node */ + H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ + hsize_t * abs_arr; /* Absolute hyperslab span position */ + int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ - ndims = iter->rank; + ndims = iter->rank; fast_dim = (int)ndims - 1; /* Get the pointers to the current span info and span nodes */ abs_arr = iter->u.hyp.off; - ispan = iter->u.hyp.span; + ispan = iter->u.hyp.span; /* Loop through, advancing the span information, until all the nelements are accounted for */ - while(nelem > 0) { + while (nelem > 0) { /* Start at the fastest dim */ curr_dim = fast_dim; /* Work back up through the dimensions */ - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Reset the current span */ curr_span = ispan[curr_dim]; /* Increment absolute position */ - if(curr_dim == fast_dim) { - size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ - hsize_t span_elem; /* Number of elements left in a span */ + if (curr_dim == fast_dim) { + size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ + hsize_t span_elem; /* Number of elements left in a span */ /* Compute the number of elements left in block */ span_elem = (curr_span->high - abs_arr[curr_dim]) + 1; @@ -1163,7 +1149,7 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) abs_arr[curr_dim]++; /* Check if we are still within the span */ - if(abs_arr[curr_dim] <= curr_span->high) + if (abs_arr[curr_dim] <= curr_span->high) break; /* If we walked off that span, advance to the next span */ else { @@ -1171,7 +1157,7 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(curr_span != NULL) { + if (curr_span != NULL) { /* Reset the span in the current dimension */ ispan[curr_dim] = curr_span; @@ -1181,15 +1167,16 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) break; } /* end if */ else - /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ + /* If we finished the span list in this dimension, decrement the dimension worked on + * and loop again */ curr_dim--; } /* end else */ - } /* end while */ + } /* end while */ /* Check if we are finished with the spans in the tree */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Walk back down the iterator positions, resetting them */ - while(curr_dim < fast_dim) { + while (curr_dim < fast_dim) { HDassert(curr_span); HDassert(curr_span->down); HDassert(curr_span->down->head); @@ -1210,13 +1197,12 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* Verify that the curr_span points to the fastest dim */ HDassert(curr_span == ispan[fast_dim]); } /* end if */ - } /* end while */ - } /* end else */ + } /* end while */ + } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_next() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_next_block * @@ -1234,22 +1220,22 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) static herr_t H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) { - unsigned ndims; /* Number of dimensions of dataset */ - int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned u; /* Counters */ + unsigned ndims; /* Number of dimensions of dataset */ + int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned u; /* Counters */ FUNC_ENTER_STATIC_NOERR /* Check for the special case of just one H5Sselect_hyperslab call made */ /* (i.e. a regular hyperslab selection) */ - if(iter->u.hyp.diminfo_valid) { - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - hsize_t iter_offset[H5S_MAX_RANK]; - hsize_t iter_count[H5S_MAX_RANK]; - int temp_dim; /* Temporary rank holder */ + if (iter->u.hyp.diminfo_valid) { + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + hsize_t iter_offset[H5S_MAX_RANK]; + hsize_t iter_count[H5S_MAX_RANK]; + int temp_dim; /* Temporary rank holder */ /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) /* Set the aliases for the dimension rank */ ndims = iter->u.hyp.iter_rank; else @@ -1263,21 +1249,21 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) tdiminfo = iter->u.hyp.diminfo; /* Calculate the offset and block count for each dimension */ - for(u = 0; u < ndims; u++) { - if(tdiminfo[u].count == 1) { + for (u = 0; u < ndims; u++) { + if (tdiminfo[u].count == 1) { iter_offset[u] = iter->u.hyp.off[u] - tdiminfo[u].start; - iter_count[u] = 0; + iter_count[u] = 0; } /* end if */ else { iter_offset[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride; - iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; + iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; } /* end else */ - } /* end for */ + } /* end for */ /* Advance one block */ temp_dim = fast_dim; /* Start with the fastest changing dimension */ - while(temp_dim >= 0) { - if(temp_dim == fast_dim) + while (temp_dim >= 0) { + if (temp_dim == fast_dim) /* Move iterator over current block */ iter_offset[temp_dim] += tdiminfo[temp_dim].block; else @@ -1285,53 +1271,54 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) iter_offset[temp_dim]++; /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(iter_offset[temp_dim] < tdiminfo[temp_dim].block) + if (iter_offset[temp_dim] < tdiminfo[temp_dim].block) break; else { /* Move to the next block in the current dimension */ iter_offset[temp_dim] = 0; iter_count[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(iter_count[temp_dim] < tdiminfo[temp_dim].count) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (iter_count[temp_dim] < tdiminfo[temp_dim].count) break; else iter_count[temp_dim] = 0; /* reset back to the beginning of the line */ - } /* end else */ + } /* end else */ /* Decrement dimension count */ temp_dim--; } /* end while */ /* Translate current iter_offset and iter_count into iterator position */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) iter->u.hyp.off[u] = tdiminfo[u].start + (tdiminfo[u].stride * iter_count[u]) + iter_offset[u]; } /* end if */ /* Must be an irregular hyperslab selection */ else { - H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ - H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t *abs_arr; /* Absolute hyperslab span position */ - int curr_dim; /* Temporary rank holder */ + H5S_hyper_span_t * curr_span; /* Current hyperslab span node */ + H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ + hsize_t * abs_arr; /* Absolute hyperslab span position */ + int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ - ndims = iter->rank; + ndims = iter->rank; fast_dim = (int)ndims - 1; /* Get the pointers to the current span info and span nodes */ abs_arr = iter->u.hyp.off; - ispan = iter->u.hyp.span; + ispan = iter->u.hyp.span; /* Loop through, advancing the span information, until all the nelements are accounted for */ curr_dim = fast_dim; /* Start at the fastest dim */ /* Work back up through the dimensions */ - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Reset the current span */ curr_span = ispan[curr_dim]; /* Increment absolute position */ - if(curr_dim == fast_dim) + if (curr_dim == fast_dim) /* Move the iterator over rest of element in span */ abs_arr[curr_dim] = curr_span->high + 1; else @@ -1339,7 +1326,7 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) abs_arr[curr_dim]++; /* Check if we are still within the span */ - if(abs_arr[curr_dim] <= curr_span->high) + if (abs_arr[curr_dim] <= curr_span->high) break; /* If we walked off that span, advance to the next span */ else { @@ -1347,7 +1334,7 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(curr_span != NULL) { + if (curr_span != NULL) { /* Reset the span in the current dimension */ ispan[curr_dim] = curr_span; @@ -1357,15 +1344,16 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) break; } /* end if */ else - /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ + /* If we finished the span list in this dimension, decrement the dimension worked on and + * loop again */ curr_dim--; } /* end else */ - } /* end while */ + } /* end while */ /* Check if we are finished with the spans in the tree */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Walk back down the iterator positions, resetting them */ - while(curr_dim < fast_dim) { + while (curr_dim < fast_dim) { HDassert(curr_span); HDassert(curr_span->down); HDassert(curr_span->down->head); @@ -1386,12 +1374,11 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) /* Verify that the curr_span points to the fastest dim */ HDassert(curr_span == ispan[fast_dim]); } /* end if */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_gen @@ -1422,28 +1409,28 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, - size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) +H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, + size_t *nelem, hsize_t *off, size_t *len) { - H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ - H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t *slab; /* Cumulative size of each dimension in bytes */ - hsize_t loc_off; /* Byte offset in the dataspace */ - hsize_t last_span_end = 0; /* The offset of the end of the last span */ - hsize_t *abs_arr; /* Absolute hyperslab span position, in elements */ - hsize_t *loc_arr; /* Byte offset of hyperslab span position within buffer */ - const hssize_t *sel_off; /* Offset within the dataspace extent */ - size_t span_elmts = 0; /* Number of elements to actually use for this span */ - size_t span_size = 0; /* Number of bytes in current span to actually process */ - size_t io_left; /* Initial number of elements to process */ - size_t io_elmts_left; /* Number of elements left to process */ - size_t io_used; /* Number of elements processed */ - size_t curr_seq = 0; /* Number of sequence/offsets stored in the arrays */ - size_t elem_size; /* Size of each element iterating over */ - unsigned ndims; /* Number of dimensions of dataset */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - int curr_dim; /* Current dimension being operated on */ - unsigned u; /* Index variable */ + H5S_hyper_span_t * curr_span; /* Current hyperslab span node */ + H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ + hsize_t * slab; /* Cumulative size of each dimension in bytes */ + hsize_t loc_off; /* Byte offset in the dataspace */ + hsize_t last_span_end = 0; /* The offset of the end of the last span */ + hsize_t * abs_arr; /* Absolute hyperslab span position, in elements */ + hsize_t * loc_arr; /* Byte offset of hyperslab span position within buffer */ + const hssize_t * sel_off; /* Offset within the dataspace extent */ + size_t span_elmts = 0; /* Number of elements to actually use for this span */ + size_t span_size = 0; /* Number of bytes in current span to actually process */ + size_t io_left; /* Initial number of elements to process */ + size_t io_elmts_left; /* Number of elements left to process */ + size_t io_used; /* Number of elements processed */ + size_t curr_seq = 0; /* Number of sequence/offsets stored in the arrays */ + size_t elem_size; /* Size of each element iterating over */ + unsigned ndims; /* Number of dimensions of dataset */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + int curr_dim; /* Current dimension being operated on */ + unsigned u; /* Index variable */ FUNC_ENTER_STATIC_NOERR @@ -1457,16 +1444,16 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max HDassert(len); /* Set the rank of the fastest changing dimension */ - ndims = iter->rank; + ndims = iter->rank; fast_dim = (ndims - 1); /* Get the pointers to the current span info and span nodes */ curr_span = iter->u.hyp.span[fast_dim]; - abs_arr = iter->u.hyp.off; - loc_arr = iter->u.hyp.loc_off; - slab = iter->u.hyp.slab; - sel_off = iter->sel_off; - ispan = iter->u.hyp.span; + abs_arr = iter->u.hyp.off; + loc_arr = iter->u.hyp.loc_off; + slab = iter->u.hyp.slab; + sel_off = iter->sel_off; + ispan = iter->u.hyp.span; elem_size = iter->elmt_size; /* Set the amount of elements to perform I/O on, etc. */ @@ -1474,18 +1461,18 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max io_elmts_left = io_left = MIN(maxelem, (size_t)iter->elmt_left); /* Set the offset of the first element iterated on */ - for(u = 0, loc_off = 0; u < ndims; u++) + for (u = 0, loc_off = 0; u < ndims; u++) loc_off += loc_arr[u]; /* Take care of any partial spans leftover from previous I/Os */ - if(abs_arr[fast_dim] != curr_span->low) { + if (abs_arr[fast_dim] != curr_span->low) { /* Finish the span in the fastest changing dimension */ /* Compute the number of elements to attempt in this span */ H5_CHECKED_ASSIGN(span_elmts, size_t, ((curr_span->high - abs_arr[fast_dim]) + 1), hsize_t); /* Check number of elements against upper bounds allowed */ - if(span_elmts > io_elmts_left) + if (span_elmts > io_elmts_left) span_elmts = io_elmts_left; /* Set the span_size, in bytes */ @@ -1505,26 +1492,27 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max io_elmts_left -= span_elmts; /* Check if we are done */ - if(io_elmts_left > 0) { + if (io_elmts_left > 0) { /* Move to next span in fastest changing dimension */ curr_span = curr_span->next; - if(NULL != curr_span) { + if (NULL != curr_span) { /* Move location offset of destination */ loc_off += (curr_span->low - abs_arr[fast_dim]) * elem_size; /* Move iterator for fastest changing dimension */ abs_arr[fast_dim] = curr_span->low; - loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; + loc_arr[fast_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; ispan[fast_dim] = curr_span; } /* end if */ - } /* end if */ + } /* end if */ else { /* Advance the hyperslab iterator */ abs_arr[fast_dim] += span_elmts; /* Check if we are still within the span */ - if(abs_arr[fast_dim] <= curr_span->high) { + if (abs_arr[fast_dim] <= curr_span->high) { /* Sanity check */ HDassert(ispan[fast_dim] == curr_span); @@ -1537,28 +1525,29 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(NULL != curr_span) { + if (NULL != curr_span) { /* Reset absolute position */ abs_arr[fast_dim] = curr_span->low; /* Update location offset */ - loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; + loc_arr[fast_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; /* Reset the span in the current dimension */ ispan[fast_dim] = curr_span; } /* end if */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Adjust iterator pointers */ - if(NULL == curr_span) { -/* Same as code in main loop */ + if (NULL == curr_span) { + /* Same as code in main loop */ /* Start at the next fastest dim */ curr_dim = (int)(fast_dim - 1); /* Work back up through the dimensions */ - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Reset the current span */ curr_span = ispan[curr_dim]; @@ -1566,7 +1555,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim]++; /* Check if we are still within the span */ - if(abs_arr[curr_dim] <= curr_span->high) { + if (abs_arr[curr_dim] <= curr_span->high) { /* Update location offset */ loc_arr[curr_dim] += slab[curr_dim]; @@ -1578,7 +1567,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(NULL != curr_span) { + if (NULL != curr_span) { /* Reset the span in the current dimension */ ispan[curr_dim] = curr_span; @@ -1586,20 +1575,22 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim] = curr_span->low; /* Update byte location */ - loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; + loc_arr[curr_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; break; } /* end if */ else - /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ + /* If we finished the span list in this dimension, decrement the dimension worked on + * and loop again */ curr_dim--; } /* end else */ - } /* end while */ + } /* end while */ /* Check if we have more spans in the tree */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Walk back down the iterator positions, resetting them */ - while((unsigned)curr_dim < fast_dim) { + while ((unsigned)curr_dim < fast_dim) { HDassert(curr_span); HDassert(curr_span->down); HDassert(curr_span->down->head); @@ -1617,25 +1608,26 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim] = curr_span->low; /* Update the location offset */ - loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; + loc_arr[curr_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; } /* end while */ /* Verify that the curr_span points to the fastest dim */ HDassert(curr_span == ispan[fast_dim]); /* Reset the buffer offset */ - for(u = 0, loc_off = 0; u < ndims; u++) + for (u = 0, loc_off = 0; u < ndims; u++) loc_off += loc_arr[u]; } /* end else */ else /* We had better be done with I/O or bad things are going to happen... */ HDassert(io_elmts_left == 0); } /* end if */ - } /* end if */ + } /* end if */ /* Perform the I/O on the elements, based on the position of the iterator */ - while(io_elmts_left > 0 && curr_seq < maxseq) { - H5S_hyper_span_t *prev_span; /* Previous hyperslab span node */ + while (io_elmts_left > 0 && curr_seq < maxseq) { + H5S_hyper_span_t *prev_span; /* Previous hyperslab span node */ /* Sanity check */ HDassert(curr_span); @@ -1644,8 +1636,8 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max prev_span = curr_span; /* Loop over all the spans in the fastest changing dimension */ - while(curr_span != NULL) { - hsize_t nelmts; /* # of elements covered by current span */ + while (curr_span != NULL) { + hsize_t nelmts; /* # of elements covered by current span */ /* Move location offset of current span */ loc_off += (curr_span->low - prev_span->low) * elem_size; @@ -1655,17 +1647,17 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max H5_CHECKED_ASSIGN(span_elmts, size_t, nelmts, hsize_t); /* Check number of elements against upper bounds allowed */ - if(span_elmts >= io_elmts_left) { + if (span_elmts >= io_elmts_left) { /* Trim the number of elements to output */ - span_elmts = io_elmts_left; - span_size = span_elmts * elem_size; + span_elmts = io_elmts_left; + span_size = span_elmts * elem_size; io_elmts_left = 0; -/* COMMON */ + /* COMMON */ /* Store the I/O information for the span */ /* Check if this is appending onto previous sequence */ - if(curr_seq > 0 && last_span_end == loc_off) + if (curr_seq > 0 && last_span_end == loc_off) len[curr_seq - 1] += span_size; else { off[curr_seq] = loc_off; @@ -1674,7 +1666,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Increment the number of sequences in arrays */ curr_seq++; } /* end else */ -/* end COMMON */ + /* end COMMON */ /* Break out now, we are finished with I/O */ break; @@ -1684,11 +1676,11 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max span_size = span_elmts * elem_size; io_elmts_left -= span_elmts; -/* COMMON */ + /* COMMON */ /* Store the I/O information for the span */ /* Check if this is appending onto previous sequence */ - if(curr_seq > 0 && last_span_end == loc_off) + if (curr_seq > 0 && last_span_end == loc_off) len[curr_seq - 1] += span_size; else { off[curr_seq] = loc_off; @@ -1697,10 +1689,10 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Increment the number of sequences in arrays */ curr_seq++; } /* end else */ -/* end COMMON */ + /* end COMMON */ /* If the sequence & offset arrays are full, do what? */ - if(curr_seq >= maxseq) + if (curr_seq >= maxseq) /* Break out now, we are finished with sequences */ break; } /* end else */ @@ -1708,13 +1700,13 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Set the location of the last span's end */ last_span_end = loc_off + span_size; - /* Move to next span in fastest changing dimension */ + /* Move to next span in fastest changing dimension */ prev_span = curr_span; - curr_span = curr_span->next; + curr_span = curr_span->next; } /* end while */ /* Check if we are done */ - if(io_elmts_left == 0 || curr_seq >= maxseq) { + if (io_elmts_left == 0 || curr_seq >= maxseq) { /* Sanity checks */ HDassert(curr_span); @@ -1722,12 +1714,14 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[fast_dim] = curr_span->low + span_elmts; /* Check if we are still within the span */ - if(abs_arr[fast_dim] <= curr_span->high) { + if (abs_arr[fast_dim] <= curr_span->high) { /* Reset the span for the fast dimension */ ispan[fast_dim] = curr_span; /* Update location offset */ - loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + (hssize_t)span_elmts + sel_off[fast_dim])) * slab[fast_dim]; + loc_arr[fast_dim] = + ((hsize_t)((hssize_t)curr_span->low + (hssize_t)span_elmts + sel_off[fast_dim])) * + slab[fast_dim]; break; } /* end if */ @@ -1737,16 +1731,17 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(curr_span != NULL) { + if (curr_span != NULL) { /* Reset absolute position */ abs_arr[fast_dim] = curr_span->low; - loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; + loc_arr[fast_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; ispan[fast_dim] = curr_span; break; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Adjust iterator pointers */ @@ -1754,7 +1749,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_dim = (int)(fast_dim - 1); /* Work back up through the dimensions */ - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Reset the current span */ curr_span = ispan[curr_dim]; @@ -1762,7 +1757,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim]++; /* Check if we are still within the span */ - if(abs_arr[curr_dim] <= curr_span->high) { + if (abs_arr[curr_dim] <= curr_span->high) { /* Update location offset */ loc_arr[curr_dim] += slab[curr_dim]; @@ -1774,7 +1769,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(curr_span != NULL) { + if (curr_span != NULL) { /* Reset the span in the current dimension */ ispan[curr_dim] = curr_span; @@ -1782,25 +1777,27 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim] = curr_span->low; /* Update location offset */ - loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; + loc_arr[curr_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; break; } /* end if */ else - /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ + /* If we finished the span list in this dimension, decrement the dimension worked on and + * loop again */ curr_dim--; } /* end else */ - } /* end while */ + } /* end while */ /* Check if we are finished with the spans in the tree */ - if(curr_dim < 0) { + if (curr_dim < 0) { /* We had better be done with I/O or bad things are going to happen... */ HDassert(io_elmts_left == 0); break; } /* end if */ else { /* Walk back down the iterator positions, resetting them */ - while((unsigned)curr_dim < fast_dim) { + while ((unsigned)curr_dim < fast_dim) { HDassert(curr_span); HDassert(curr_span->down); HDassert(curr_span->down->head); @@ -1818,7 +1815,8 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim] = curr_span->low; /* Update location offset */ - loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; + loc_arr[curr_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; } /* end while */ /* Verify that the curr_span points to the fastest dim */ @@ -1826,7 +1824,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max } /* end else */ /* Reset the buffer offset */ - for(u = 0, loc_off = 0; u < ndims; u++) + for (u = 0, loc_off = 0; u < ndims; u++) loc_off += loc_arr[u]; } /* end while */ @@ -1843,7 +1841,6 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_gen() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_opt @@ -1874,39 +1871,37 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, - size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) +H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, + size_t *nelem, hsize_t *off, size_t *len) { - hsize_t *mem_size; /* Size of the source buffer */ - hsize_t *slab; /* Hyperslab size */ - const hssize_t *sel_off; /* Selection offset in dataspace */ - hsize_t offset[H5S_MAX_RANK]; /* Coordinate offset in dataspace */ - hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary block count */ - hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */ - hsize_t wrap[H5S_MAX_RANK]; /* Bytes to wrap around at the end of a row */ - hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */ - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - hsize_t fast_dim_start, /* Local copies of fastest changing dimension info */ - fast_dim_stride, - fast_dim_block, - fast_dim_offset; - size_t fast_dim_buf_off; /* Local copy of amount to move fastest dimension buffer offset */ - size_t fast_dim_count; /* Number of blocks left in fastest changing dimension */ - size_t tot_blk_count; /* Total number of blocks left to output */ - size_t act_blk_count; /* Actual number of blocks to output */ - size_t total_rows; /* Total number of entire rows to output */ - size_t curr_rows; /* Current number of entire rows to output */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned ndims; /* Number of dimensions of dataset */ - int temp_dim; /* Temporary rank holder */ - hsize_t loc; /* Coordinate offset */ - size_t curr_seq = 0; /* Current sequence being operated on */ - size_t actual_elem; /* The actual number of elements to count */ - size_t actual_bytes;/* The actual number of bytes to copy */ - size_t io_left; /* The number of elements left in I/O operation */ - size_t start_io_left; /* The initial number of elements left in I/O operation */ - size_t elem_size; /* Size of each element iterating over */ - unsigned u; /* Local index variable */ + hsize_t * mem_size; /* Size of the source buffer */ + hsize_t * slab; /* Hyperslab size */ + const hssize_t * sel_off; /* Selection offset in dataspace */ + hsize_t offset[H5S_MAX_RANK]; /* Coordinate offset in dataspace */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary block count */ + hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */ + hsize_t wrap[H5S_MAX_RANK]; /* Bytes to wrap around at the end of a row */ + hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */ + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + hsize_t fast_dim_start, /* Local copies of fastest changing dimension info */ + fast_dim_stride, fast_dim_block, fast_dim_offset; + size_t fast_dim_buf_off; /* Local copy of amount to move fastest dimension buffer offset */ + size_t fast_dim_count; /* Number of blocks left in fastest changing dimension */ + size_t tot_blk_count; /* Total number of blocks left to output */ + size_t act_blk_count; /* Actual number of blocks to output */ + size_t total_rows; /* Total number of entire rows to output */ + size_t curr_rows; /* Current number of entire rows to output */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned ndims; /* Number of dimensions of dataset */ + int temp_dim; /* Temporary rank holder */ + hsize_t loc; /* Coordinate offset */ + size_t curr_seq = 0; /* Current sequence being operated on */ + size_t actual_elem; /* The actual number of elements to count */ + size_t actual_bytes; /* The actual number of bytes to copy */ + size_t io_left; /* The number of elements left in I/O operation */ + size_t start_io_left; /* The initial number of elements left in I/O operation */ + size_t elem_size; /* Size of each element iterating over */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -1923,7 +1918,7 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tdiminfo = iter->u.hyp.diminfo; /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { /* Set the aliases for a few important dimension ranks */ ndims = iter->u.hyp.iter_rank; @@ -1945,9 +1940,9 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max } /* end else */ /* Set up some local variables */ - fast_dim = ndims - 1; + fast_dim = ndims - 1; elem_size = iter->elmt_size; - slab = iter->u.hyp.slab; + slab = iter->u.hyp.slab; /* Calculate the number of elements to sequence through */ H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t); @@ -1955,7 +1950,7 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Sanity check that there aren't any "remainder" sequences in process */ HDassert(!((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 || - ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1))); + ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1))); /* We've cleared the "remainder" of the previous fastest dimension * sequence before calling this routine, so we must be at the beginning of @@ -1970,12 +1965,12 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Copy the location of the point to get */ /* (Add in the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) offset[u] = (hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u]); /* Compute the current "counts" for this location */ - for(u = 0; u < ndims; u++) { - if(tdiminfo[u].count == 1) { + for (u = 0; u < ndims; u++) { + if (tdiminfo[u].count == 1) { tmp_count[u] = 0; tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start; } /* end if */ @@ -1983,10 +1978,10 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tmp_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; tmp_block[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride; } /* end else */ - } /* end for */ + } /* end for */ /* Compute the initial buffer offset */ - for(u = 0, loc = 0; u < ndims; u++) + for (u = 0, loc = 0; u < ndims; u++) loc += offset[u] * slab[u]; /* Set the number of elements to write each time */ @@ -1996,9 +1991,9 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max actual_bytes = actual_elem * elem_size; /* Set local copies of information for the fastest changing dimension */ - fast_dim_start = tdiminfo[fast_dim].start; + fast_dim_start = tdiminfo[fast_dim].start; fast_dim_stride = tdiminfo[fast_dim].stride; - fast_dim_block = tdiminfo[fast_dim].block; + fast_dim_block = tdiminfo[fast_dim].block; H5_CHECKED_ASSIGN(fast_dim_buf_off, size_t, slab[fast_dim] * fast_dim_stride, hsize_t); fast_dim_offset = (hsize_t)((hssize_t)fast_dim_start + sel_off[fast_dim]); @@ -2010,15 +2005,15 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tot_blk_count = MIN(tot_blk_count, (maxseq - curr_seq)); /* Compute the amount to wrap at the end of each row */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) wrap[u] = (mem_size[u] - (tdiminfo[u].stride * tdiminfo[u].count)) * slab[u]; /* Compute the amount to skip between blocks */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) skip[u] = (tdiminfo[u].stride - tdiminfo[u].block) * slab[u]; /* Check if there is a partial row left (with full blocks) */ - if(tmp_count[fast_dim] > 0) { + if (tmp_count[fast_dim] > 0) { /* Get number of blocks in fastest dimension */ H5_CHECKED_ASSIGN(fast_dim_count, size_t, tdiminfo[fast_dim].count - tmp_count[fast_dim], hsize_t); @@ -2029,7 +2024,7 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max act_blk_count = fast_dim_count; /* Loop over all the blocks in the fastest changing dimension */ - while(fast_dim_count > 0) { + while (fast_dim_count > 0) { /* Store the sequence information */ off[curr_seq] = loc; len[curr_seq] = actual_bytes; @@ -2054,23 +2049,24 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tmp_count[fast_dim] += act_blk_count; /* Check if we finished the entire row of blocks */ - if(tmp_count[fast_dim] >= tdiminfo[fast_dim].count) { + if (tmp_count[fast_dim] >= tdiminfo[fast_dim].count) { /* Increment offset in destination buffer */ loc += wrap[fast_dim]; /* Increment information to reflect block just processed */ - offset[fast_dim] = fast_dim_offset; /* reset the offset in the fastest dimension */ + offset[fast_dim] = fast_dim_offset; /* reset the offset in the fastest dimension */ tmp_count[fast_dim] = 0; /* Increment the offset and count for the other dimensions */ temp_dim = (int)fast_dim - 1; - while(temp_dim >= 0) { + while (temp_dim >= 0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_block[temp_dim] < tdiminfo[temp_dim].block) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (tmp_block[temp_dim] < tdiminfo[temp_dim].block) break; else { /* Move to the next block in the current dimension */ @@ -2079,8 +2075,9 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tmp_block[temp_dim] = 0; tmp_count[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_count[temp_dim] < tdiminfo[temp_dim].count) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (tmp_count[temp_dim] < tdiminfo[temp_dim].count) break; else { offset[temp_dim] = (hsize_t)((hssize_t)tdiminfo[temp_dim].start + sel_off[temp_dim]); @@ -2088,17 +2085,17 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tmp_count[temp_dim] = 0; /* reset back to the beginning of the line */ tmp_block[temp_dim] = 0; } /* end else */ - } /* end else */ + } /* end else */ /* Decrement dimension count */ temp_dim--; } /* end while */ - } /* end if */ + } /* end if */ else { /* Update the offset in the fastest dimension */ offset[fast_dim] += (fast_dim_stride * act_blk_count); } /* end else */ - } /* end if */ + } /* end if */ /* Compute the number of entire rows to read in */ H5_CHECK_OVERFLOW(tot_blk_count / tdiminfo[fast_dim].count, hsize_t, size_t); @@ -2108,28 +2105,28 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max H5_CHECKED_ASSIGN(fast_dim_count, size_t, tdiminfo[fast_dim].count, hsize_t); /* Read in data until an entire sequence can't be written out any longer */ - while(curr_rows > 0) { - -#define DUFF_GUTS \ -/* Store the sequence information */ \ -off[curr_seq] = loc; \ -len[curr_seq] = actual_bytes; \ - \ -/* Increment sequence count */ \ -curr_seq++; \ - \ -/* Increment information to reflect block just processed */ \ -loc += fast_dim_buf_off; + while (curr_rows > 0) { + +#define DUFF_GUTS \ + /* Store the sequence information */ \ + off[curr_seq] = loc; \ + len[curr_seq] = actual_bytes; \ + \ + /* Increment sequence count */ \ + curr_seq++; \ + \ + /* Increment information to reflect block just processed */ \ + loc += fast_dim_buf_off; #ifdef NO_DUFFS_DEVICE /* Loop over all the blocks in the fastest changing dimension */ - while(fast_dim_count > 0) { + while (fast_dim_count > 0) { DUFF_GUTS /* Decrement number of blocks */ fast_dim_count--; } /* end while */ -#else /* NO_DUFFS_DEVICE */ +#else /* NO_DUFFS_DEVICE */ { size_t duffs_index; /* Counting index for Duff's device */ @@ -2139,34 +2136,33 @@ loc += fast_dim_buf_off; HDassert(0 && "This Should never be executed!"); break; case 0: - do - { - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 7: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 6: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 5: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 4: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 3: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 2: + do { DUFF_GUTS H5_ATTR_FALLTHROUGH - case 1: - DUFF_GUTS - } while (--duffs_index > 0); + case 7: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 6: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 5: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 4: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 3: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 2: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 1: + DUFF_GUTS + } while (--duffs_index > 0); } /* end switch */ } -#endif /* NO_DUFFS_DEVICE */ +#endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS /* Increment offset in destination buffer */ @@ -2174,13 +2170,13 @@ loc += fast_dim_buf_off; /* Increment the offset and count for the other dimensions */ temp_dim = (int)fast_dim - 1; - while(temp_dim >= 0) { + while (temp_dim >= 0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_block[temp_dim] < tdiminfo[temp_dim].block) + if (tmp_block[temp_dim] < tdiminfo[temp_dim].block) break; else { /* Move to the next block in the current dimension */ @@ -2189,8 +2185,9 @@ loc += fast_dim_buf_off; tmp_block[temp_dim] = 0; tmp_count[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_count[temp_dim] < tdiminfo[temp_dim].count) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (tmp_count[temp_dim] < tdiminfo[temp_dim].count) break; else { offset[temp_dim] = (hsize_t)((hssize_t)tdiminfo[temp_dim].start + sel_off[temp_dim]); @@ -2198,7 +2195,7 @@ loc += fast_dim_buf_off; tmp_count[temp_dim] = 0; /* reset back to the beginning of the line */ tmp_block[temp_dim] = 0; } /* end else */ - } /* end else */ + } /* end else */ /* Decrement dimension count */ temp_dim--; @@ -2219,12 +2216,12 @@ loc += fast_dim_buf_off; tot_blk_count -= (size_t)(total_rows * tdiminfo[fast_dim].count); /* Read in partial row of blocks */ - if(io_left > 0 && curr_seq < maxseq) { + if (io_left > 0 && curr_seq < maxseq) { /* Get remaining number of blocks left to output */ fast_dim_count = tot_blk_count; /* Loop over all the blocks in the fastest changing dimension */ - while(fast_dim_count > 0) { + while (fast_dim_count > 0) { /* Store the sequence information */ off[curr_seq] = loc; len[curr_seq] = actual_bytes; @@ -2243,11 +2240,11 @@ loc += fast_dim_buf_off; io_left -= actual_elem * tot_blk_count; /* Increment information to reflect block just processed */ - offset[fast_dim] += (fast_dim_stride * tot_blk_count); /* move the offset in the fastest dimension */ + offset[fast_dim] += (fast_dim_stride * tot_blk_count); /* move the offset in the fastest dimension */ /* Handle any leftover, partial blocks in this row */ - if(io_left > 0 && curr_seq < maxseq) { - actual_elem = io_left; + if (io_left > 0 && curr_seq < maxseq) { + actual_elem = io_left; actual_bytes = actual_elem * elem_size; /* Store the sequence information */ @@ -2272,7 +2269,7 @@ loc += fast_dim_buf_off; /* Update the iterator with the location we stopped */ /* (Subtract out the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) iter->u.hyp.off[u] = (hsize_t)((hssize_t)offset[u] - sel_off[u]); /* Decrement the number of elements left in selection */ @@ -2287,7 +2284,6 @@ loc += fast_dim_buf_off; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_opt() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_single @@ -2319,25 +2315,25 @@ loc += fast_dim_buf_off; REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, - size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) +H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, + size_t *nelem, hsize_t *off, size_t *len) { - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - const hssize_t *sel_off; /* Selection offset in dataspace */ - hsize_t *mem_size; /* Size of the source buffer */ - hsize_t base_offset[H5S_MAX_RANK]; /* Base coordinate offset in dataspace */ - hsize_t offset[H5S_MAX_RANK]; /* Coordinate offset in dataspace */ - hsize_t *slab; /* Hyperslab size */ - hsize_t fast_dim_block; /* Local copies of fastest changing dimension info */ - hsize_t loc; /* Coordinate offset */ - size_t tot_blk_count; /* Total number of blocks left to output */ - size_t elem_size; /* Size of each element iterating over */ - size_t io_left; /* The number of elements left in I/O operation */ - size_t actual_elem; /* The actual number of elements to count */ - unsigned ndims; /* Number of dimensions of dataset */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned skip_dim; /* Rank of the dimension to skip along */ - unsigned u; /* Local index variable */ + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + const hssize_t * sel_off; /* Selection offset in dataspace */ + hsize_t * mem_size; /* Size of the source buffer */ + hsize_t base_offset[H5S_MAX_RANK]; /* Base coordinate offset in dataspace */ + hsize_t offset[H5S_MAX_RANK]; /* Coordinate offset in dataspace */ + hsize_t * slab; /* Hyperslab size */ + hsize_t fast_dim_block; /* Local copies of fastest changing dimension info */ + hsize_t loc; /* Coordinate offset */ + size_t tot_blk_count; /* Total number of blocks left to output */ + size_t elem_size; /* Size of each element iterating over */ + size_t io_left; /* The number of elements left in I/O operation */ + size_t actual_elem; /* The actual number of elements to count */ + unsigned ndims; /* Number of dimensions of dataset */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned skip_dim; /* Rank of the dimension to skip along */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -2354,7 +2350,7 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t tdiminfo = iter->u.hyp.diminfo; /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { /* Set the aliases for a few important dimension ranks */ ndims = iter->u.hyp.iter_rank; @@ -2376,22 +2372,22 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t } /* end else */ /* Set up some local variables */ - fast_dim = ndims - 1; + fast_dim = ndims - 1; elem_size = iter->elmt_size; - slab = iter->u.hyp.slab; + slab = iter->u.hyp.slab; /* Copy the base location of the block */ /* (Add in the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) base_offset[u] = (hsize_t)((hssize_t)tdiminfo[u].start + sel_off[u]); /* Copy the location of the point to get */ /* (Add in the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) offset[u] = (hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u]); /* Compute the initial buffer offset */ - for(u = 0, loc = 0; u < ndims; u++) + for (u = 0, loc = 0; u < ndims; u++) loc += offset[u] * slab[u]; /* Set local copies of information for the fastest changing dimension */ @@ -2412,14 +2408,14 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t H5_CHECKED_ASSIGN(actual_elem, size_t, fast_dim_block, hsize_t); /* Check for blocks to operate on */ - if(tot_blk_count > 0) { - size_t actual_bytes; /* The actual number of bytes to copy */ + if (tot_blk_count > 0) { + size_t actual_bytes; /* The actual number of bytes to copy */ /* Set the number of actual bytes */ actual_bytes = actual_elem * elem_size; /* Check for 1-dim selection */ - if(0 == fast_dim) { + if (0 == fast_dim) { /* Sanity checks */ HDassert(1 == tot_blk_count); HDassert(io_left == actual_elem); @@ -2429,24 +2425,24 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t *len++ = actual_bytes; } /* end if */ else { - hsize_t skip_slab; /* Temporary copy of slab[fast_dim - 1] */ - size_t blk_count; /* Total number of blocks left to output */ - int i; /* Local index variable */ + hsize_t skip_slab; /* Temporary copy of slab[fast_dim - 1] */ + size_t blk_count; /* Total number of blocks left to output */ + int i; /* Local index variable */ /* Find first dimension w/block >1 */ skip_dim = fast_dim; - for(i = (int)(fast_dim - 1); i >= 0; i--) - if(tdiminfo[i].block > 1) { + for (i = (int)(fast_dim - 1); i >= 0; i--) + if (tdiminfo[i].block > 1) { skip_dim = (unsigned)i; break; } /* end if */ skip_slab = slab[skip_dim]; /* Check for being able to use fast algorithm for 1-D */ - if(0 == skip_dim) { + if (0 == skip_dim) { /* Create sequences until an entire row can't be used */ blk_count = tot_blk_count; - while(blk_count > 0) { + while (blk_count > 0) { /* Store the sequence information */ *off++ = loc; *len++ = actual_bytes; @@ -2462,21 +2458,21 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t offset[skip_dim] += tot_blk_count; } /* end if */ else { - hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */ - hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */ - int temp_dim; /* Temporary rank holder */ + hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */ + hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */ + int temp_dim; /* Temporary rank holder */ /* Set the starting block location */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start; /* Compute the amount to skip between sequences */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) skip[u] = (mem_size[u] - tdiminfo[u].block) * slab[u]; /* Create sequences until an entire row can't be used */ blk_count = tot_blk_count; - while(blk_count > 0) { + while (blk_count > 0) { /* Store the sequence information */ *off++ = loc; *len++ = actual_bytes; @@ -2488,13 +2484,14 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t loc += skip_slab; /* Increment the offset and count for the other dimensions */ - while(temp_dim >= 0) { + while (temp_dim >= 0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_block[temp_dim] < tdiminfo[temp_dim].block) + /* If this block is still in the range of blocks to output for the dimension, break + * out of loop */ + if (tmp_block[temp_dim] < tdiminfo[temp_dim].block) break; else { offset[temp_dim] = base_offset[temp_dim]; @@ -2509,8 +2506,8 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t /* Decrement block count */ blk_count--; } /* end while */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Update the iterator, if there were any blocks used */ @@ -2518,10 +2515,10 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t iter->elmt_left -= tot_blk_count * actual_elem; /* Check if there are elements left in iterator */ - if(iter->elmt_left > 0) { + if (iter->elmt_left > 0) { /* Update the iterator with the location we stopped */ /* (Subtract out the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) iter->u.hyp.off[u] = (hsize_t)((hssize_t)offset[u] - sel_off[u]); } /* end if */ @@ -2533,8 +2530,8 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t } /* end if */ /* Check for partial block, with room for another sequence */ - if(io_left > (tot_blk_count * actual_elem) && tot_blk_count < maxseq) { - size_t elmt_remainder; /* Elements remaining */ + if (io_left > (tot_blk_count * actual_elem) && tot_blk_count < maxseq) { + size_t elmt_remainder; /* Elements remaining */ /* Compute elements left */ elmt_remainder = io_left - (tot_blk_count * actual_elem); @@ -2565,7 +2562,6 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_single() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list @@ -2597,10 +2593,10 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) +H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, + hsize_t *off, size_t *len) { - herr_t ret_value = FAIL; /* return value */ + herr_t ret_value = FAIL; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -2615,19 +2611,19 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, HDassert(len); /* Check for the special case of just one H5Sselect_hyperslab call made */ - if(iter->u.hyp.diminfo_valid) { - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - const hssize_t *sel_off; /* Selection offset in dataspace */ - unsigned ndims; /* Number of dimensions of dataset */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - hbool_t single_block; /* Whether the selection is a single block */ - unsigned u; /* Local index variable */ + if (iter->u.hyp.diminfo_valid) { + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + const hssize_t * sel_off; /* Selection offset in dataspace */ + unsigned ndims; /* Number of dimensions of dataset */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + hbool_t single_block; /* Whether the selection is a single block */ + unsigned u; /* Local index variable */ /* Set a local copy of the diminfo pointer */ tdiminfo = iter->u.hyp.diminfo; /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { /* Set the aliases for a few important dimension ranks */ ndims = iter->u.hyp.iter_rank; @@ -2644,20 +2640,27 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, fast_dim = ndims - 1; /* Check if we stopped in the middle of a sequence of elements */ - if((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 || - ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1)) { - hsize_t *slab; /* Hyperslab size */ - hsize_t loc; /* Coordinate offset */ - size_t leftover; /* The number of elements left over from the last sequence */ - size_t actual_elem; /* The actual number of elements to count */ - size_t elem_size; /* Size of each element iterating over */ + if ((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 || + ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1)) { + hsize_t *slab; /* Hyperslab size */ + hsize_t loc; /* Coordinate offset */ + size_t leftover; /* The number of elements left over from the last sequence */ + size_t actual_elem; /* The actual number of elements to count */ + size_t elem_size; /* Size of each element iterating over */ /* Calculate the number of elements left in the sequence */ - if(tdiminfo[fast_dim].count == 1) { - H5_CHECKED_ASSIGN(leftover, size_t, tdiminfo[fast_dim].block - (iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start), hsize_t); + if (tdiminfo[fast_dim].count == 1) { + H5_CHECKED_ASSIGN(leftover, size_t, + tdiminfo[fast_dim].block - + (iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start), + hsize_t); } /* end if */ else { - H5_CHECKED_ASSIGN(leftover, size_t, tdiminfo[fast_dim].block - ((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride), hsize_t); + H5_CHECKED_ASSIGN( + leftover, size_t, + tdiminfo[fast_dim].block - + ((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride), + hsize_t); } /* end else */ /* Make certain that we don't write too many */ @@ -2665,10 +2668,10 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, /* Set up some local variables */ elem_size = iter->elmt_size; - slab = iter->u.hyp.slab; + slab = iter->u.hyp.slab; /* Compute the initial buffer offset */ - for(u = 0, loc = 0; u < ndims; u++) + for (u = 0, loc = 0; u < ndims; u++) loc += ((hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u])) * slab[u]; /* Add a new sequence */ @@ -2690,29 +2693,29 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, maxseq--; /* Set the number of sequences generated and elements used */ - *nseq = 1; + *nseq = 1; *nelem = actual_elem; /* Check for using up all the sequences/elements */ - if(0 == iter->elmt_left || 0 == maxelem || 0 == maxseq) - return(SUCCEED); + if (0 == iter->elmt_left || 0 == maxelem || 0 == maxseq) + return (SUCCEED); } /* end if */ else { /* Reset the number of sequences generated and elements used */ - *nseq = 0; + *nseq = 0; *nelem = 0; } /* end else */ /* Check for a single block selected */ single_block = TRUE; - for(u = 0; u < ndims; u++) - if(1 != tdiminfo[u].count) { + for (u = 0; u < ndims; u++) + if (1 != tdiminfo[u].count) { single_block = FALSE; break; } /* end if */ /* Check for single block selection */ - if(single_block) + if (single_block) /* Use single-block optimized call to generate sequence list */ ret_value = H5S__hyper_iter_get_seq_list_single(iter, maxseq, maxelem, nseq, nelem, off, len); else @@ -2726,7 +2729,6 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_release @@ -2753,13 +2755,12 @@ H5S__hyper_iter_release(H5S_sel_iter_t *iter) HDassert(iter); /* Free the copy of the hyperslab selection span tree */ - if(iter->u.hyp.spans != NULL) + if (iter->u.hyp.spans != NULL) H5S__hyper_free_span_info(iter->u.hyp.spans); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_new_span @@ -2782,32 +2783,30 @@ H5S__hyper_iter_release(H5S_sel_iter_t *iter) REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_t * -H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, - H5S_hyper_span_t *next) +H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next) { - H5S_hyper_span_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate a new span node */ - if(NULL == (ret_value = H5FL_MALLOC(H5S_hyper_span_t))) + if (NULL == (ret_value = H5FL_MALLOC(H5S_hyper_span_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Copy the span's basic information */ - ret_value->low = low; + ret_value->low = low; ret_value->high = high; ret_value->down = down; ret_value->next = next; /* Increment the reference count of the 'down span' if there is one */ - if(ret_value->down) + if (ret_value->down) ret_value->down->count++; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_new_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_new_span_info @@ -2830,7 +2829,7 @@ done: static H5S_hyper_span_info_t * H5S__hyper_new_span_info(unsigned rank) { - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -2839,18 +2838,17 @@ H5S__hyper_new_span_info(unsigned rank) HDassert(rank <= H5S_MAX_RANK); /* Allocate a new span info node */ - if(NULL == (ret_value = (H5S_hyper_span_info_t *)H5FL_ARR_CALLOC(hbounds_t, rank * 2))) + if (NULL == (ret_value = (H5S_hyper_span_info_t *)H5FL_ARR_CALLOC(hbounds_t, rank * 2))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span info") /* Set low & high bound pointers into the 'bounds' array */ - ret_value->low_bounds = ret_value->bounds; + ret_value->low_bounds = ret_value->bounds; ret_value->high_bounds = &ret_value->bounds[rank]; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_new_span_info() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_copy_span_helper @@ -2872,14 +2870,13 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * -H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, - unsigned op_info_i, uint64_t op_gen) +H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, unsigned op_info_i, uint64_t op_gen) { - H5S_hyper_span_t *span; /* Hyperslab span */ - H5S_hyper_span_t *new_span; /* Temporary hyperslab span */ - H5S_hyper_span_t *prev_span; /* Previous hyperslab span */ - H5S_hyper_span_info_t *new_down; /* New down span tree */ - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_t * span; /* Hyperslab span */ + H5S_hyper_span_t * new_span; /* Temporary hyperslab span */ + H5S_hyper_span_t * prev_span; /* Previous hyperslab span */ + H5S_hyper_span_info_t *new_down; /* New down span tree */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -2887,7 +2884,7 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, HDassert(spans); /* Check if the span tree was already copied */ - if(spans->op_info[op_info_i].op_gen == op_gen) { + if (spans->op_info[op_info_i].op_gen == op_gen) { /* Just return the value of the already copied span tree */ ret_value = spans->op_info[op_info_i].u.copied; @@ -2896,7 +2893,7 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, } /* end if */ else { /* Allocate a new span_info node */ - if(NULL == (ret_value = H5S__hyper_new_span_info(rank))) + if (NULL == (ret_value = H5S__hyper_new_span_info(rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span info") /* Set the non-zero span_info information */ @@ -2911,22 +2908,22 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, spans->op_info[op_info_i].u.copied = ret_value; /* Copy over the nodes in the span list */ - span = spans->head; + span = spans->head; prev_span = NULL; - while(span != NULL) { + while (span != NULL) { /* Allocate a new node */ - if(NULL == (new_span = H5S__hyper_new_span(span->low, span->high, NULL, NULL))) + if (NULL == (new_span = H5S__hyper_new_span(span->low, span->high, NULL, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Append to list of spans */ - if(NULL == prev_span) + if (NULL == prev_span) ret_value->head = new_span; else prev_span->next = new_span; /* Recurse to copy the 'down' spans, if there are any */ - if(span->down != NULL) { - if(NULL == (new_down = H5S__hyper_copy_span_helper(span->down, rank - 1, op_info_i, op_gen))) + if (span->down != NULL) { + if (NULL == (new_down = H5S__hyper_copy_span_helper(span->down, rank - 1, op_info_i, op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy hyperslab spans") new_span->down = new_down; } /* end if */ @@ -2946,7 +2943,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy_span_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_copy_span @@ -2970,8 +2966,8 @@ done: static H5S_hyper_span_info_t * H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank) { - uint64_t op_gen; /* Operation generation value */ - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + uint64_t op_gen; /* Operation generation value */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -2984,14 +2980,13 @@ H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank) /* Copy the hyperslab span tree */ /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ - if(NULL == (ret_value = H5S__hyper_copy_span_helper(spans, rank, 0, op_gen))) + if (NULL == (ret_value = H5S__hyper_copy_span_helper(spans, rank, 0, op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy hyperslab span tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_cmp_spans @@ -3014,23 +3009,23 @@ done: static H5_ATTR_PURE hbool_t H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_span_info_t *span_info2) { - hbool_t ret_value = TRUE; /* Return value */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check for redundant comparison (or both spans being NULL) */ - if(span_info1 != span_info2) { + if (span_info1 != span_info2) { /* Check for one span being NULL */ - if(span_info1 == NULL || span_info2 == NULL) + if (span_info1 == NULL || span_info2 == NULL) HGOTO_DONE(FALSE) else { /* Compare low & high bounds for this span list */ /* (Could compare lower dimensions also, but not certain if * that's worth it. - QAK, 2019/01/23) */ - if(span_info1->low_bounds[0] != span_info2->low_bounds[0]) + if (span_info1->low_bounds[0] != span_info2->low_bounds[0]) HGOTO_DONE(FALSE) - else if(span_info1->high_bounds[0] != span_info2->high_bounds[0]) + else if (span_info1->high_bounds[0] != span_info2->high_bounds[0]) HGOTO_DONE(FALSE) else { const H5S_hyper_span_t *span1; @@ -3045,40 +3040,40 @@ H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_sp HDassert(span2); /* infinite loop which must be broken out of */ - while(1) { + while (1) { /* Check for both spans being NULL */ - if(span1 == NULL && span2 == NULL) + if (span1 == NULL && span2 == NULL) HGOTO_DONE(TRUE) else { /* Check for one span being NULL */ - if(span1 == NULL || span2 == NULL) + if (span1 == NULL || span2 == NULL) HGOTO_DONE(FALSE) else { /* Check if the actual low & high span information is the same */ - if(span1->low != span2->low || span1->high != span2->high) + if (span1->low != span2->low || span1->high != span2->high) HGOTO_DONE(FALSE) else { - if(span1->down != NULL || span2->down != NULL) { - if(!H5S__hyper_cmp_spans(span1->down, span2->down)) + if (span1->down != NULL || span2->down != NULL) { + if (!H5S__hyper_cmp_spans(span1->down, span2->down)) HGOTO_DONE(FALSE) else { /* Keep going... */ } /* end else */ - } /* end if */ + } /* end if */ else { /* Keep going... */ } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ /* Advance to the next nodes in the span list */ span1 = span1->next; span2 = span2->next; } /* end while */ - } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end else */ + } /* end if */ /* Fall through, with default return value of 'TRUE' if spans were already visited */ @@ -3086,7 +3081,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_cmp_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_free_span_info @@ -3118,13 +3112,13 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) span_info->count--; /* Free the span tree if the reference count drops to zero */ - if(span_info->count == 0) { - H5S_hyper_span_t *span; /* Pointer to spans to iterate over */ + if (span_info->count == 0) { + H5S_hyper_span_t *span; /* Pointer to spans to iterate over */ /* Work through the list of spans pointed to by this 'info' node */ span = span_info->head; - while(span != NULL) { - H5S_hyper_span_t *next_span; /* Pointer to next span to iterate over */ + while (span != NULL) { + H5S_hyper_span_t *next_span; /* Pointer to next span to iterate over */ /* Keep a pointer to the next span */ next_span = span->next; @@ -3143,7 +3137,6 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_free_span_info() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_free_span @@ -3172,7 +3165,7 @@ H5S__hyper_free_span(H5S_hyper_span_t *span) HDassert(span); /* Decrement the reference count of the 'down spans', freeing them if appropriate */ - if(span->down != NULL) + if (span->down != NULL) H5S__hyper_free_span_info(span->down); /* Free this span */ @@ -3181,7 +3174,6 @@ H5S__hyper_free_span(H5S_hyper_span_t *span) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_free_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_copy @@ -3210,9 +3202,9 @@ H5S__hyper_free_span(H5S_hyper_span_t *span) static herr_t H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) { - H5S_hyper_sel_t *dst_hslab; /* Pointer to destination hyperslab info */ - const H5S_hyper_sel_t *src_hslab; /* Pointer to source hyperslab info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_sel_t * dst_hslab; /* Pointer to destination hyperslab info */ + const H5S_hyper_sel_t *src_hslab; /* Pointer to source hyperslab info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3221,7 +3213,7 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) HDassert(dst); /* Allocate space for the hyperslab selection information */ - if(NULL == (dst->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) + if (NULL == (dst->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info") /* Set temporary pointers */ @@ -3230,33 +3222,33 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) /* Copy the hyperslab information */ dst_hslab->diminfo_valid = src_hslab->diminfo_valid; - if(src_hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) + if (src_hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) H5MM_memcpy(&dst_hslab->diminfo, &src_hslab->diminfo, sizeof(H5S_hyper_diminfo_t)); /* Check if there is hyperslab span information to copy */ /* (Regular hyperslab information is copied with the selection structure) */ - if(src->select.sel_info.hslab->span_lst != NULL) { - if(share_selection) { + if (src->select.sel_info.hslab->span_lst != NULL) { + if (share_selection) { /* Share the source's span tree by incrementing the reference count on it */ dst->select.sel_info.hslab->span_lst = src->select.sel_info.hslab->span_lst; dst->select.sel_info.hslab->span_lst->count++; } /* end if */ else /* Copy the hyperslab span information */ - dst->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(src->select.sel_info.hslab->span_lst, src->extent.rank); + dst->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(src->select.sel_info.hslab->span_lst, src->extent.rank); } /* end if */ else dst->select.sel_info.hslab->span_lst = NULL; /* Copy the unlimited dimension info */ - dst_hslab->unlim_dim = src_hslab->unlim_dim; + dst_hslab->unlim_dim = src_hslab->unlim_dim; dst_hslab->num_elem_non_unlim = src_hslab->num_elem_non_unlim; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_is_valid @@ -3280,34 +3272,34 @@ done: static htri_t H5S__hyper_is_valid(const H5S_t *space) { - const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ - unsigned u; /* Counter */ - htri_t ret_value = TRUE; /* return value */ + const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ + unsigned u; /* Counter */ + htri_t ret_value = TRUE; /* return value */ FUNC_ENTER_STATIC_NOERR HDassert(space); /* Check for unlimited selection */ - if(space->select.sel_info.hslab->unlim_dim >= 0) + if (space->select.sel_info.hslab->unlim_dim >= 0) HGOTO_DONE(FALSE) /* Check which set of low & high bounds we should be using */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; high_bounds = space->select.sel_info.hslab->diminfo.high_bounds; } /* end if */ else { - low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; + low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; high_bounds = space->select.sel_info.hslab->span_lst->high_bounds; } /* end else */ /* Check each dimension */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Bounds check the selected point + offset against the extent */ - if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) + if (((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) HGOTO_DONE(FALSE) - if((high_bounds[u] + (hsize_t)space->select.offset[u]) >= space->extent.size[u]) + if ((high_bounds[u] + (hsize_t)space->select.offset[u]) >= space->extent.size[u]) HGOTO_DONE(FALSE) } /* end for */ @@ -3315,7 +3307,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_span_nblocks_helper @@ -3336,10 +3327,9 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static hsize_t -H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, - uint64_t op_gen) +H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, uint64_t op_gen) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -3347,31 +3337,31 @@ H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, HDassert(spans); /* Check if the span tree was already counted */ - if(spans->op_info[op_info_i].op_gen == op_gen) + if (spans->op_info[op_info_i].op_gen == op_gen) /* Just return the # of blocks in the already counted span tree */ ret_value = spans->op_info[op_info_i].u.nblocks; - else { /* Count the number of elements in the span tree */ - H5S_hyper_span_t *span; /* Hyperslab span */ + else { /* Count the number of elements in the span tree */ + H5S_hyper_span_t *span; /* Hyperslab span */ span = spans->head; - if(span->down) { - while(span) { + if (span->down) { + while (span) { /* If there are down spans, add the total down span blocks */ ret_value += H5S__hyper_span_nblocks_helper(span->down, op_info_i, op_gen); /* Advance to next span */ span = span->next; } /* end while */ - } /* end if */ + } /* end if */ else { - while(span) { + while (span) { /* If there are no down spans, just count the block in this span */ ret_value++; /* Advance to next span */ span = span->next; } /* end while */ - } /* end else */ + } /* end else */ /* Set the operation generation for this span tree, to avoid re-computing */ spans->op_info[op_info_i].op_gen = op_gen; @@ -3383,7 +3373,6 @@ H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_nblocks_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_span_nblocks @@ -3404,13 +3393,13 @@ H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, static hsize_t H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Count the number of elements in the span tree */ - if(spans != NULL) { - uint64_t op_gen; /* Operation generation value */ + if (spans != NULL) { + uint64_t op_gen; /* Operation generation value */ /* Acquire an operation generation value for this operation */ op_gen = H5S__hyper_get_op_gen(); @@ -3424,7 +3413,6 @@ H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_nblocks() */ - /*-------------------------------------------------------------------------- NAME H5S__get_select_hyper_nblocks @@ -3446,7 +3434,7 @@ H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans) static hsize_t H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -3455,13 +3443,13 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - unsigned u; /* Local index variable */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + unsigned u; /* Local index variable */ /* Check each dimension */ - for(ret_value = 1, u = 0; u < space->extent.rank; u++) - ret_value *= (app_ref ? space->select.sel_info.hslab->diminfo.app[u].count : - space->select.sel_info.hslab->diminfo.opt[u].count); + for (ret_value = 1, u = 0; u < space->extent.rank; u++) + ret_value *= (app_ref ? space->select.sel_info.hslab->diminfo.app[u].count + : space->select.sel_info.hslab->diminfo.opt[u].count); } /* end if */ else ret_value = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst); @@ -3469,7 +3457,6 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__get_select_hyper_nblocks() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_hyper_nblocks @@ -3490,19 +3477,20 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ - hssize_t ret_value; /* return value */ + H5S_t * space; /* Dataspace to modify selection of */ + hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") - if(space->select.sel_info.hslab->unlim_dim >= 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot get number of blocks for unlimited selection") + if (space->select.sel_info.hslab->unlim_dim >= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "cannot get number of blocks for unlimited selection") ret_value = (hssize_t)H5S__get_select_hyper_nblocks(space, TRUE); @@ -3510,7 +3498,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_hyper_nblocks() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_get_enc_size_real @@ -3536,9 +3523,9 @@ H5S__hyper_get_enc_size_real(hsize_t max_size) FUNC_ENTER_STATIC_NOERR - if(max_size > H5S_UINT32_MAX) + if (max_size > H5S_UINT32_MAX) ret_value = H5S_SELECT_INFO_ENC_SIZE_8; - else if(max_size > H5S_UINT16_MAX) + else if (max_size > H5S_UINT16_MAX) ret_value = H5S_SELECT_INFO_ENC_SIZE_4; else ret_value = H5S_SELECT_INFO_ENC_SIZE_2; @@ -3546,7 +3533,6 @@ H5S__hyper_get_enc_size_real(hsize_t max_size) FUNC_LEAVE_NOAPI(ret_value) } /* H5S__hyper_get_enc_size_real() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_get_version_enc_size @@ -3584,70 +3570,74 @@ H5S__hyper_get_enc_size_real(hsize_t max_size) static herr_t H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_t *version, uint8_t *enc_size) { - hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ - hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ - hbool_t count_up_version = FALSE; /* Whether number of blocks exceed H5S_UINT32_MAX */ - hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */ - H5F_libver_t low_bound; /* The 'low' bound of library format versions */ - H5F_libver_t high_bound; /* The 'high' bound of library format versions */ - htri_t is_regular; /* A regular hyperslab or not */ - uint32_t tmp_version; /* Local temporay version */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ + hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ + hbool_t count_up_version = FALSE; /* Whether number of blocks exceed H5S_UINT32_MAX */ + hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */ + H5F_libver_t low_bound; /* The 'low' bound of library format versions */ + H5F_libver_t high_bound; /* The 'high' bound of library format versions */ + htri_t is_regular; /* A regular hyperslab or not */ + uint32_t tmp_version; /* Local temporay version */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get bounding box for the selection */ HDmemset(bounds_end, 0, sizeof(bounds_end)); - if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + if (space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ /* Get bounding box for the selection */ - if(H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) + if (H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") /* Determine whether the number of blocks or the high bounds in the selection exceed (2^32 - 1) */ - if(block_count > H5S_UINT32_MAX) + if (block_count > H5S_UINT32_MAX) count_up_version = TRUE; else { - for(u = 0; u < space->extent.rank; u++) - if(bounds_end[u] > H5S_UINT32_MAX) { + for (u = 0; u < space->extent.rank; u++) + if (bounds_end[u] > H5S_UINT32_MAX) { bound_up_version = TRUE; break; } /* end if */ - } /* end else */ + } /* end else */ /* Get the file's low_bound and high_bound */ - if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) + if (H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context") /* Determine regular hyperslab */ is_regular = H5S__hyper_is_regular(space); - if(low_bound >= H5F_LIBVER_V112 || space->select.sel_info.hslab->unlim_dim >= 0) + if (low_bound >= H5F_LIBVER_V112 || space->select.sel_info.hslab->unlim_dim >= 0) tmp_version = MAX(H5S_HYPER_VERSION_2, H5O_sds_hyper_ver_bounds[low_bound]); else { - if(count_up_version || bound_up_version) + if (count_up_version || bound_up_version) tmp_version = is_regular ? H5S_HYPER_VERSION_2 : H5S_HYPER_VERSION_3; else - tmp_version = (is_regular && block_count >= 4) ? H5O_sds_hyper_ver_bounds[low_bound] : H5S_HYPER_VERSION_1; + tmp_version = + (is_regular && block_count >= 4) ? H5O_sds_hyper_ver_bounds[low_bound] : H5S_HYPER_VERSION_1; } /* end else */ /* Version bounds check */ - if(tmp_version > H5O_sds_hyper_ver_bounds[high_bound]) { - /* Fail for irregular hyperslab if exceeds 32 bits */ - if(count_up_version) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of blocks in hyperslab selection exceeds 2^32") - else if(bound_up_version) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in hyperslab selection exceeds 2^32") + if (tmp_version > H5O_sds_hyper_ver_bounds[high_bound]) { + /* Fail for irregular hyperslab if exceeds 32 bits */ + if (count_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "The number of blocks in hyperslab selection exceeds 2^32") + else if (bound_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "The end of bounding box in hyperslab selection exceeds 2^32") else - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace hyperslab selection version out of bounds") + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "Dataspace hyperslab selection version out of bounds") } /* end if */ /* Set the message version */ *version = tmp_version; /* Determine the encoded size based on version */ - switch(tmp_version) { + switch (tmp_version) { case H5S_HYPER_VERSION_1: *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; break; @@ -3657,18 +3647,18 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ break; case H5S_HYPER_VERSION_3: - if(is_regular) { + if (is_regular) { uint8_t enc1, enc2; hsize_t max1 = 0; hsize_t max2 = 0; /* Find max for count[] and block[] */ - for(u = 0; u < space->extent.rank; u++) { - if(space->select.sel_info.hslab->diminfo.opt[u].count != H5S_UNLIMITED && - space->select.sel_info.hslab->diminfo.opt[u].count > max1) + for (u = 0; u < space->extent.rank; u++) { + if (space->select.sel_info.hslab->diminfo.opt[u].count != H5S_UNLIMITED && + space->select.sel_info.hslab->diminfo.opt[u].count > max1) max1 = space->select.sel_info.hslab->diminfo.opt[u].count; - if(space->select.sel_info.hslab->diminfo.opt[u].block != H5S_UNLIMITED && - space->select.sel_info.hslab->diminfo.opt[u].block > max1) + if (space->select.sel_info.hslab->diminfo.opt[u].block != H5S_UNLIMITED && + space->select.sel_info.hslab->diminfo.opt[u].block > max1) max1 = space->select.sel_info.hslab->diminfo.opt[u].block; } /* end for */ @@ -3676,10 +3666,10 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ enc1 = H5S__hyper_get_enc_size_real(++max1); /* Find max for start[] and stride[] */ - for(u = 0; u < space->extent.rank; u++) { - if(space->select.sel_info.hslab->diminfo.opt[u].start > max2) + for (u = 0; u < space->extent.rank; u++) { + if (space->select.sel_info.hslab->diminfo.opt[u].start > max2) max2 = space->select.sel_info.hslab->diminfo.opt[u].start; - if(space->select.sel_info.hslab->diminfo.opt[u].stride > max2) + if (space->select.sel_info.hslab->diminfo.opt[u].stride > max2) max2 = space->select.sel_info.hslab->diminfo.opt[u].stride; } /* end for */ @@ -3693,12 +3683,12 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ HDassert(space->select.sel_info.hslab->unlim_dim < 0); /* Find max for block_count and bounds_end[] */ - for(u = 0; u < space->extent.rank; u++) - if(bounds_end[u] > max_size) + for (u = 0; u < space->extent.rank; u++) + if (bounds_end[u] > max_size) max_size = bounds_end[u]; /* Determine the encoding size */ - *enc_size = H5S__hyper_get_enc_size_real(max_size); + *enc_size = H5S__hyper_get_enc_size_real(max_size); } /* end else */ break; @@ -3711,7 +3701,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__hyper_get_version_enc_size() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_serial_size @@ -3734,24 +3723,24 @@ done: static hssize_t H5S__hyper_serial_size(const H5S_t *space) { - hsize_t block_count = 0; /* block counter for regular hyperslabs */ - uint32_t version; /* Version number */ - uint8_t enc_size; /* Encoded size of hyperslab selection info */ - hssize_t ret_value = -1; /* return value */ + hsize_t block_count = 0; /* block counter for regular hyperslabs */ + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of hyperslab selection info */ + hssize_t ret_value = -1; /* return value */ FUNC_ENTER_STATIC HDassert(space); /* Determine the number of blocks */ - if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + if (space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ block_count = H5S__get_select_hyper_nblocks(space, FALSE); /* Determine the version and the encoded size */ - if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) + if (H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size") - if(version == H5S_HYPER_VERSION_3) { + if (version == H5S_HYPER_VERSION_3) { /* Version 3: regular */ /* Size required is always: * + + + @@ -3759,9 +3748,8 @@ H5S__hyper_serial_size(const H5S_t *space) * (4 (start/stride/count/block) * * ) = * 14 + (4 * enc_size * rank) bytes */ - if(H5S__hyper_is_regular(space)) - ret_value = (hssize_t)14 + - ((hssize_t)4 * (hssize_t)enc_size * (hssize_t)space->extent.rank); + if (H5S__hyper_is_regular(space)) + ret_value = (hssize_t)14 + ((hssize_t)4 * (hssize_t)enc_size * (hssize_t)space->extent.rank); else { /* Version 3: irregular */ /* Size required is always: @@ -3775,8 +3763,8 @@ H5S__hyper_serial_size(const H5S_t *space) H5_CHECK_OVERFLOW(((unsigned)2 * enc_size * space->extent.rank * block_count), hsize_t, hssize_t); ret_value += (hssize_t)((unsigned)2 * enc_size * space->extent.rank * block_count); } /* end else */ - } /* end if */ - else if(version == H5S_HYPER_VERSION_2) { + } /* end if */ + else if (version == H5S_HYPER_VERSION_2) { /* Version 2 */ /* Size required is always: * + + + @@ -3806,7 +3794,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_serialize_helper @@ -3831,11 +3818,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static void -H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, - hsize_t *start, hsize_t *end, hsize_t rank, uint8_t enc_size, uint8_t **p) +H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, hsize_t *start, hsize_t *end, hsize_t rank, + uint8_t enc_size, uint8_t **p) { - H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - uint8_t *pp = (*p); /* Local pointer for decoding */ + H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ + uint8_t * pp = (*p); /* Local pointer for decoding */ FUNC_ENTER_STATIC_NOERR @@ -3848,31 +3835,31 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, /* Walk through the list of spans, recursing or outputting them */ curr = spans->head; - while(curr != NULL) { + while (curr != NULL) { /* Recurse if this node has down spans */ - if(curr->down != NULL) { + if (curr->down != NULL) { /* Add the starting and ending points for this span to the list */ start[rank] = curr->low; - end[rank] = curr->high; + end[rank] = curr->high; /* Recurse down to the next dimension */ H5S__hyper_serialize_helper(curr->down, start, end, rank + 1, enc_size, &pp); } /* end if */ else { - hsize_t u; /* Index variable */ + hsize_t u; /* Index variable */ /* Encode all the previous dimensions starting & ending points */ - switch(enc_size) { + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: /* Encode previous starting points */ - for(u=0; ulow); /* Encode previous ending points */ - for(u=0; ulow); - /* Encode previous ending points */ - for(u=0; ulow); /* Encode previous ending points */ - for(u=0; unext; @@ -3927,7 +3914,6 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_serialize_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_serialize @@ -3952,24 +3938,24 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, static herr_t H5S__hyper_serialize(const H5S_t *space, uint8_t **p) { - const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ - hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ - hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ - hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ - hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ - uint8_t *pp; /* Local pointer for encoding */ - uint8_t *lenp = NULL; /* pointer to length location for later storage */ - uint32_t len = 0; /* number of bytes used */ - uint32_t version; /* Version number */ - uint8_t flags = 0; /* Flags for message */ - hsize_t block_count = 0; /* block counter for regular hyperslabs */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned ndims; /* Rank of the dataspace */ - unsigned u; /* Local counting variable */ - hbool_t complete = FALSE; /* Whether we are done with the iteration */ - hbool_t is_regular; /* Whether selection is regular */ - uint8_t enc_size; /* Encoded size */ - herr_t ret_value = SUCCEED; /* return value */ + const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ + hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ + hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ + hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ + uint8_t * pp; /* Local pointer for encoding */ + uint8_t * lenp = NULL; /* pointer to length location for later storage */ + uint32_t len = 0; /* number of bytes used */ + uint32_t version; /* Version number */ + uint8_t flags = 0; /* Flags for message */ + hsize_t block_count = 0; /* block counter for regular hyperslabs */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned ndims; /* Rank of the dataspace */ + unsigned u; /* Local counting variable */ + hbool_t complete = FALSE; /* Whether we are done with the iteration */ + hbool_t is_regular; /* Whether selection is regular */ + uint8_t enc_size; /* Encoded size */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -3980,61 +3966,60 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) HDassert(pp); /* Set some convienence values */ - ndims = space->extent.rank; + ndims = space->extent.rank; diminfo = space->select.sel_info.hslab->diminfo.opt; /* Calculate the # of blocks */ - if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + if (space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ block_count = H5S__get_select_hyper_nblocks(space, FALSE); /* Determine the version and the encoded size */ - if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) + if (H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size") - is_regular = H5S__hyper_is_regular(space); - if(is_regular && - (version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3)) + is_regular = H5S__hyper_is_regular(space); + if (is_regular && (version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3)) flags |= H5S_HYPER_REGULAR; /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, version); /* Store the version number */ + UINT32ENCODE(pp, version); /* Store the version number */ - if(version >= 3) { + if (version >= 3) { *(pp)++ = flags; /* Store the flags */ *(pp)++ = enc_size; /* Store size of offset info */ - } /* end if */ + } /* end if */ else { - if(version == 2) + if (version == 2) *(pp)++ = flags; /* Store the flags */ else UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - lenp = pp; /* keep the pointer to the length location for later */ - pp += 4; /* skip over space for length */ + lenp = pp; /* keep the pointer to the length location for later */ + pp += 4; /* skip over space for length */ - len += 4; /* ndims */ - } /* end else */ + len += 4; /* ndims */ + } /* end else */ /* Encode number of dimensions */ UINT32ENCODE(pp, (uint32_t)ndims); - if(is_regular) { - if(version >= H5S_HYPER_VERSION_2) { + if (is_regular) { + if (version >= H5S_HYPER_VERSION_2) { HDassert(H5S_UNLIMITED == HSIZE_UNDEF); /* Iterate over dimensions */ /* Encode start/stride/block/count */ - switch(enc_size) { + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: HDassert(version == H5S_HYPER_VERSION_3); - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { UINT16ENCODE(pp, diminfo[u].start); UINT16ENCODE(pp, diminfo[u].stride); - if(diminfo[u].count == H5S_UNLIMITED) + if (diminfo[u].count == H5S_UNLIMITED) UINT16ENCODE(pp, H5S_UINT16_MAX) else UINT16ENCODE(pp, diminfo[u].count) - if(diminfo[u].block == H5S_UNLIMITED) + if (diminfo[u].block == H5S_UNLIMITED) UINT16ENCODE(pp, H5S_UINT16_MAX) else UINT16ENCODE(pp, diminfo[u].block) @@ -4043,14 +4028,14 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) case H5S_SELECT_INFO_ENC_SIZE_4: HDassert(version == H5S_HYPER_VERSION_3); - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { UINT32ENCODE(pp, diminfo[u].start); UINT32ENCODE(pp, diminfo[u].stride); - if(diminfo[u].count == H5S_UNLIMITED) + if (diminfo[u].count == H5S_UNLIMITED) UINT32ENCODE(pp, H5S_UINT32_MAX) else UINT32ENCODE(pp, diminfo[u].count) - if(diminfo[u].block == H5S_UNLIMITED) + if (diminfo[u].block == H5S_UNLIMITED) UINT32ENCODE(pp, H5S_UINT32_MAX) else UINT32ENCODE(pp, diminfo[u].block) @@ -4059,26 +4044,27 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) case H5S_SELECT_INFO_ENC_SIZE_8: HDassert(version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3); - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { UINT64ENCODE(pp, diminfo[u].start); UINT64ENCODE(pp, diminfo[u].stride); - if(diminfo[u].count == H5S_UNLIMITED) + if (diminfo[u].count == H5S_UNLIMITED) UINT64ENCODE(pp, H5S_UINT64_MAX) else UINT64ENCODE(pp, diminfo[u].count) - if(diminfo[u].block == H5S_UNLIMITED) + if (diminfo[u].block == H5S_UNLIMITED) UINT64ENCODE(pp, H5S_UINT64_MAX) else UINT64ENCODE(pp, diminfo[u].block) } /* end for */ - if(version == H5S_HYPER_VERSION_2) + if (version == H5S_HYPER_VERSION_2) len += (4 * space->extent.rank * 8); break; default: - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "unknown offset info size for hyperslab") break; } /* end switch */ - } /* end if */ + } /* end if */ else { HDassert(version == H5S_HYPER_VERSION_1); @@ -4093,52 +4079,52 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) /* Now serialize the information for the regular hyperslab */ /* Build the tables of count sizes as well as the initial offset */ - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { tmp_count[u] = diminfo[u].count; - offset[u] = diminfo[u].start; + offset[u] = diminfo[u].start; } /* end for */ /* Go iterate over the hyperslabs */ - while(complete == FALSE) { + while (complete == FALSE) { /* Iterate over the blocks in the fastest dimension */ - while(tmp_count[fast_dim] > 0) { + while (tmp_count[fast_dim] > 0) { /* Add 8 bytes times the rank for each hyperslab selected */ len += 8 * ndims; /* Encode hyperslab starting location */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) UINT32ENCODE(pp, (uint32_t)offset[u]); /* Encode hyperslab ending location */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1))); /* Move the offset to the next sequence to start */ - offset[fast_dim]+=diminfo[fast_dim].stride; + offset[fast_dim] += diminfo[fast_dim].stride; /* Decrement the block count */ tmp_count[fast_dim]--; } /* end while */ /* Work on other dimensions if necessary */ - if(fast_dim > 0) { - int temp_dim; /* Temporary rank holder */ + if (fast_dim > 0) { + int temp_dim; /* Temporary rank holder */ /* Reset the block counts */ tmp_count[fast_dim] = diminfo[fast_dim].count; /* Bubble up the decrement to the slower changing dimensions */ temp_dim = (int)fast_dim - 1; - while(temp_dim >= 0 && complete == FALSE) { + while (temp_dim >= 0 && complete == FALSE) { /* Decrement the block count */ tmp_count[temp_dim]--; /* Check if we have more blocks left */ - if(tmp_count[temp_dim] > 0) + if (tmp_count[temp_dim] > 0) break; /* Check for getting out of iterator */ - if(temp_dim == 0) + if (temp_dim == 0) complete = TRUE; /* Reset the block count in this dimension */ @@ -4147,19 +4133,19 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) /* Wrapped a dimension, go up to next dimension */ temp_dim--; } /* end while */ - } /* end if */ + } /* end if */ else - break; /* Break out now, for 1-D selections */ + break; /* Break out now, for 1-D selections */ /* Re-compute offset array */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]); } /* end while */ - } /* end else */ - } /* end if */ - else { /* irregular */ + } /* end else */ + } /* end if */ + else { /* irregular */ /* Encode number of hyperslabs */ - switch(enc_size) { + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: HDassert(version == H5S_HYPER_VERSION_3); H5_CHECK_OVERFLOW(block_count, hsize_t, uint16_t); @@ -4182,7 +4168,7 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) break; } /* end switch */ - if(version == H5S_HYPER_VERSION_1) { + if (version == H5S_HYPER_VERSION_1) { len += 4; /* block_count */ /* Add 8 bytes times the rank for each hyperslab selected */ @@ -4190,12 +4176,13 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) len += (uint32_t)(8 * ndims * block_count); } /* end if */ - H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, enc_size, &pp); + H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, enc_size, + &pp); } /* end else */ /* Encode length */ - if(version <= H5S_HYPER_VERSION_2) - UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ + if (version <= H5S_HYPER_VERSION_2) + UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ /* Update encoding pointer */ *p = pp; @@ -4204,7 +4191,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_deserialize @@ -4230,18 +4216,18 @@ done: static herr_t H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) { - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, - either *space or a newly allocated one */ - hsize_t dims[H5S_MAX_RANK]; /* Dimenion sizes */ - hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */ - hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */ - uint32_t version; /* Version number */ - uint8_t flags = 0; /* Flags */ - uint8_t enc_size = 0; /* Encoded size of selection info */ - unsigned rank; /* rank of points */ - const uint8_t *pp; /* Local pointer for decoding */ - unsigned u; /* Local counting variable */ - herr_t ret_value=FAIL; /* return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + hsize_t dims[H5S_MAX_RANK]; /* Dimenion sizes */ + hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */ + hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */ + uint32_t version; /* Version number */ + uint8_t flags = 0; /* Flags */ + uint8_t enc_size = 0; /* Encoded size of selection info */ + unsigned rank; /* rank of points */ + const uint8_t *pp; /* Local pointer for decoding */ + unsigned u; /* Local counting variable */ + herr_t ret_value = FAIL; /* return value */ FUNC_ENTER_STATIC @@ -4255,8 +4241,8 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) is moved from H5S_select_deserialize() in H5Sselect.c to here. This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -4265,14 +4251,14 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(pp, version); - if(version < H5S_HYPER_VERSION_1 || version > H5S_HYPER_VERSION_LATEST) + if (version < H5S_HYPER_VERSION_1 || version > H5S_HYPER_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for hyperslab selection") - if(version >= (uint32_t)H5S_HYPER_VERSION_2) { + if (version >= (uint32_t)H5S_HYPER_VERSION_2) { /* Decode flags */ flags = *(pp)++; - if(version >= (uint32_t)H5S_HYPER_VERSION_3) + if (version >= (uint32_t)H5S_HYPER_VERSION_3) /* decode size of offset info */ enc_size = *(pp)++; else { @@ -4281,85 +4267,86 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) enc_size = H5S_SELECT_INFO_ENC_SIZE_8; } /* end else */ - /* Check for unknown flags */ - if(flags & ~H5S_SELECT_FLAG_BITS) + /* Check for unknown flags */ + if (flags & ~H5S_SELECT_FLAG_BITS) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection") - } - else { + } + else { /* Skip over the remainder of the header */ pp += 8; enc_size = H5S_SELECT_INFO_ENC_SIZE_4; - } /* end else */ + } /* end else */ - /* Check encoded */ - if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) + /* Check encoded */ + if (enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection") /* Decode the rank of the point selection */ - UINT32DECODE(pp,rank); + UINT32DECODE(pp, rank); - if(!*space) { + if (!*space) { /* Patch the rank of the allocated dataspace */ HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); - if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) + if (H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") } /* end if */ else /* Verify the rank of the provided dataspace */ - if(rank != tmp_space->extent.rank) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace") + if (rank != tmp_space->extent.rank) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "rank of serialized selection does not match dataspace") - if(flags & H5S_HYPER_REGULAR) { - hsize_t stride[H5S_MAX_RANK]; /* Hyperslab stride information */ - hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */ + if (flags & H5S_HYPER_REGULAR) { + hsize_t stride[H5S_MAX_RANK]; /* Hyperslab stride information */ + hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */ /* Sanity checks */ HDassert(H5S_UNLIMITED == HSIZE_UNDEF); HDassert(version >= H5S_HYPER_VERSION_2); - /* Decode start/stride/block/count */ - switch(enc_size) { + /* Decode start/stride/block/count */ + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: - for(u = 0; u < tmp_space->extent.rank; u++) { + for (u = 0; u < tmp_space->extent.rank; u++) { UINT16DECODE(pp, start[u]); UINT16DECODE(pp, stride[u]); UINT16DECODE(pp, count[u]); - if((uint16_t)count[u] == H5S_UINT16_MAX) + if ((uint16_t)count[u] == H5S_UINT16_MAX) count[u] = H5S_UNLIMITED; UINT16DECODE(pp, block[u]); - if((uint16_t)block[u] == H5S_UINT16_MAX) + if ((uint16_t)block[u] == H5S_UINT16_MAX) block[u] = H5S_UNLIMITED; } /* end for */ break; case H5S_SELECT_INFO_ENC_SIZE_4: - for(u = 0; u < tmp_space->extent.rank; u++) { + for (u = 0; u < tmp_space->extent.rank; u++) { UINT32DECODE(pp, start[u]); UINT32DECODE(pp, stride[u]); UINT32DECODE(pp, count[u]); - if((uint32_t)count[u] == H5S_UINT32_MAX) + if ((uint32_t)count[u] == H5S_UINT32_MAX) count[u] = H5S_UNLIMITED; UINT32DECODE(pp, block[u]); - if((uint32_t)block[u] == H5S_UINT32_MAX) + if ((uint32_t)block[u] == H5S_UINT32_MAX) block[u] = H5S_UNLIMITED; } /* end for */ break; case H5S_SELECT_INFO_ENC_SIZE_8: - for(u = 0; u < tmp_space->extent.rank; u++) { + for (u = 0; u < tmp_space->extent.rank; u++) { UINT64DECODE(pp, start[u]); UINT64DECODE(pp, stride[u]); UINT64DECODE(pp, count[u]); - if((uint64_t)count[u] == H5S_UINT64_MAX) + if ((uint64_t)count[u] == H5S_UINT64_MAX) count[u] = H5S_UNLIMITED; UINT64DECODE(pp, block[u]); - if((uint64_t)block[u] == H5S_UINT64_MAX) + if ((uint64_t)block[u] == H5S_UINT64_MAX) block[u] = H5S_UNLIMITED; } /* end for */ break; @@ -4370,21 +4357,21 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) } /* end switch */ /* Select the hyperslab to the current selection */ - if((ret_value = H5S_select_hyperslab(tmp_space, H5S_SELECT_SET, start, stride, count, block)) < 0) + if ((ret_value = H5S_select_hyperslab(tmp_space, H5S_SELECT_SET, start, stride, count, block)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection") } /* end if */ else { - const hsize_t *stride; /* Hyperslab stride information */ - const hsize_t *count; /* Hyperslab count information */ - hsize_t end[H5S_MAX_RANK]; /* Hyperslab end information */ - hsize_t *tstart; /* Temporary hyperslab pointers */ - hsize_t *tend; /* Temporary hyperslab pointers */ - hsize_t *tblock; /* Temporary hyperslab pointers */ - size_t num_elem; /* Number of elements in selection */ - unsigned v; /* Local counting variable */ + const hsize_t *stride; /* Hyperslab stride information */ + const hsize_t *count; /* Hyperslab count information */ + hsize_t end[H5S_MAX_RANK]; /* Hyperslab end information */ + hsize_t * tstart; /* Temporary hyperslab pointers */ + hsize_t * tend; /* Temporary hyperslab pointers */ + hsize_t * tblock; /* Temporary hyperslab pointers */ + size_t num_elem; /* Number of elements in selection */ + unsigned v; /* Local counting variable */ /* Decode the number of blocks */ - switch(enc_size) { + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: UINT16DECODE(pp, num_elem); break; @@ -4406,62 +4393,63 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) stride = count = H5S_hyper_ones_g; /* Retrieve the coordinates from the buffer */ - for(u = 0; u < num_elem; u++) { + for (u = 0; u < num_elem; u++) { /* Decode the starting and ending points */ - switch(enc_size) { + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: - for(tstart = start, v = 0; v < rank; v++, tstart++) + for (tstart = start, v = 0; v < rank; v++, tstart++) UINT16DECODE(pp, *tstart); - for(tend = end, v = 0; v < rank; v++, tend++) + for (tend = end, v = 0; v < rank; v++, tend++) UINT16DECODE(pp, *tend); break; case H5S_SELECT_INFO_ENC_SIZE_4: - for(tstart = start,v = 0; v < rank; v++, tstart++) + for (tstart = start, v = 0; v < rank; v++, tstart++) UINT32DECODE(pp, *tstart); - for(tend = end, v = 0; v < rank; v++, tend++) + for (tend = end, v = 0; v < rank; v++, tend++) UINT32DECODE(pp, *tend); break; case H5S_SELECT_INFO_ENC_SIZE_8: - for(tstart = start, v = 0; v < rank; v++, tstart++) + for (tstart = start, v = 0; v < rank; v++, tstart++) UINT64DECODE(pp, *tstart); - for(tend = end, v = 0; v < rank; v++, tend++) + for (tend = end, v = 0; v < rank; v++, tend++) UINT64DECODE(pp, *tend); break; default: - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "unknown offset info size for hyperslab") break; } /* end switch */ /* Change the ending points into blocks */ - for(tblock = block, tstart = start, tend = end, v = 0; v < rank; v++, tstart++, tend++, tblock++) + for (tblock = block, tstart = start, tend = end, v = 0; v < rank; v++, tstart++, tend++, tblock++) *tblock = (*tend - *tstart) + 1; /* Select or add the hyperslab to the current selection */ - if((ret_value = H5S_select_hyperslab(tmp_space, (u == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, stride, count, block)) < 0) + if ((ret_value = H5S_select_hyperslab(tmp_space, (u == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, + stride, count, block)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection") } /* end for */ - } /* end else */ + } /* end else */ /* Update decoding pointer */ *p = pp; /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_span_blocklist @@ -4496,12 +4484,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], - hsize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks, - hsize_t **buf) +H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], hsize_t end[], hsize_t rank, + hsize_t *startblock, hsize_t *numblocks, hsize_t **buf) { - const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - herr_t ret_value = SUCCEED; /* return value */ + const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -4516,20 +4503,20 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], /* Walk through the list of spans, recursing or outputting them */ curr = spans->head; - while(curr != NULL && *numblocks > 0) { + while (curr != NULL && *numblocks > 0) { /* Recurse if this node has down spans */ - if(curr->down != NULL) { + if (curr->down != NULL) { /* Add the starting and ending points for this span to the list */ start[rank] = curr->low; - end[rank] = curr->high; + end[rank] = curr->high; /* Recurse down to the next dimension */ - if(H5S__hyper_span_blocklist(curr->down, start, end, (rank + 1), startblock, numblocks, buf) < 0) + if (H5S__hyper_span_blocklist(curr->down, start, end, (rank + 1), startblock, numblocks, buf) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans") } /* end if */ else { /* Skip this block if we haven't skipped all the startblocks yet */ - if(*startblock > 0) { + if (*startblock > 0) { /* Decrement the starting block */ (*startblock)--; } /* end if */ @@ -4556,7 +4543,7 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], /* Decrement the number of blocks processed */ (*numblocks)--; } /* end else */ - } /* end else */ + } /* end else */ /* Advance to next node */ curr = curr->next; @@ -4566,7 +4553,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_blocklist() */ - /*-------------------------------------------------------------------------- NAME H5S__get_select_hyper_blocklist @@ -4598,8 +4584,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, - hsize_t numblocks, hsize_t *buf) +H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks, hsize_t *buf) { herr_t ret_value = SUCCEED; /* Return value */ @@ -4612,26 +4597,26 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, /* Attempt to rebuild diminfo if it is invalid and has not been confirmed * to be impossible. */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) H5S__hyper_rebuild(space); /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ - hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ - hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ - hsize_t end[H5S_MAX_RANK]; /* End of elements in dataspace */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned ndims; /* Rank of the dataspace */ - hbool_t done; /* Whether we are done with the iteration */ - unsigned u; /* Counter */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ + hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ + hsize_t end[H5S_MAX_RANK]; /* End of elements in dataspace */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned ndims; /* Rank of the dataspace */ + hbool_t done; /* Whether we are done with the iteration */ + unsigned u; /* Counter */ /* Set some convienence values */ - ndims = space->extent.rank; + ndims = space->extent.rank; fast_dim = ndims - 1; /* Check which set of dimension information to use */ - if(space->select.sel_info.hslab->unlim_dim >= 0) + if (space->select.sel_info.hslab->unlim_dim >= 0) /* * There is an unlimited dimension so we must use diminfo.opt as * it has been "clipped" to the current extent. @@ -4646,21 +4631,21 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, diminfo = space->select.sel_info.hslab->diminfo.app; /* Build the tables of count sizes as well as the initial offset */ - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { tmp_count[u] = diminfo[u].count; - offset[u] = diminfo[u].start; - end[u] = diminfo[u].start + (diminfo[u].block - 1); + offset[u] = diminfo[u].start; + end[u] = diminfo[u].start + (diminfo[u].block - 1); } /* end for */ /* We're not done with the iteration */ done = FALSE; /* Go iterate over the hyperslabs */ - while(!done && numblocks > 0) { + while (!done && numblocks > 0) { /* Skip over initial blocks */ - if(startblock > 0) { + if (startblock > 0) { /* Skip all blocks in row */ - if(startblock >= tmp_count[fast_dim]) { + if (startblock >= tmp_count[fast_dim]) { startblock -= tmp_count[fast_dim]; tmp_count[fast_dim] = 0; } /* end if */ @@ -4675,10 +4660,10 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, /* Done with starting blocks */ startblock = 0; } /* end else */ - } /* end if */ + } /* end if */ /* Iterate over the blocks in the fastest dimension */ - while(tmp_count[fast_dim] > 0 && numblocks > 0) { + while (tmp_count[fast_dim] > 0 && numblocks > 0) { /* Sanity check */ HDassert(startblock == 0); @@ -4702,53 +4687,53 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, } /* end while */ /* Work on other dimensions if necessary */ - if(fast_dim > 0 && numblocks > 0) { - int temp_dim; /* Temporary rank holder */ + if (fast_dim > 0 && numblocks > 0) { + int temp_dim; /* Temporary rank holder */ /* Reset the block counts */ tmp_count[fast_dim] = diminfo[fast_dim].count; /* Bubble up the decrement to the slower changing dimensions */ temp_dim = (int)(fast_dim - 1); - while(temp_dim >= 0 && !done) { + while (temp_dim >= 0 && !done) { /* Decrement the block count */ tmp_count[temp_dim]--; /* Check if we have more blocks left */ - if(tmp_count[temp_dim] > 0) + if (tmp_count[temp_dim] > 0) break; /* Reset the block count in this dimension */ tmp_count[temp_dim] = diminfo[temp_dim].count; /* Check for getting out of iterator */ - if(temp_dim == 0) + if (temp_dim == 0) done = TRUE; /* Wrapped a dimension, go up to next dimension */ temp_dim--; } /* end while */ - } /* end if */ + } /* end if */ /* Re-compute offset & end arrays */ - if(!done) - for(u = 0; u < ndims; u++) { + if (!done) + for (u = 0; u < ndims; u++) { offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]); - end[u] = offset[u] + (diminfo[u].block - 1); + end[u] = offset[u] + (diminfo[u].block - 1); } /* end for */ - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { - hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ - hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ + hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ + hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ - ret_value = H5S__hyper_span_blocklist(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, &startblock, &numblocks, &buf); + ret_value = H5S__hyper_span_blocklist(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, + &startblock, &numblocks, &buf); } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__get_select_hyper_blocklist() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_hyper_blocklist @@ -4780,36 +4765,35 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, - hsize_t numblocks, hsize_t buf[/*numblocks*/]) +H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, + hsize_t buf[/*numblocks*/]) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ihh*[a2]h", spaceid, startblock, numblocks, buf); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer") - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") - if(space->select.sel_info.hslab->unlim_dim >= 0) + if (space->select.sel_info.hslab->unlim_dim >= 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot get blocklist for unlimited selection") /* Go get the correct number of blocks */ - if(numblocks > 0) + if (numblocks > 0) ret_value = H5S__get_select_hyper_blocklist(space, startblock, numblocks, buf); else - ret_value = SUCCEED; /* Successfully got 0 blocks... */ + ret_value = SUCCEED; /* Successfully got 0 blocks... */ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_hyper_blocklist() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_bounds @@ -4839,8 +4823,8 @@ done: static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ - herr_t ret_value = SUCCEED; /* Return value */ + const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4850,36 +4834,36 @@ H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) HDassert(end); /* Check which set of low & high bounds we should be using */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; high_bounds = space->select.sel_info.hslab->diminfo.high_bounds; } /* end if */ else { - low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; + low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; high_bounds = space->select.sel_info.hslab->span_lst->high_bounds; } /* end else */ /* Check for offset set */ - if(space->select.offset_changed) { - unsigned u; /* Local index variable */ + if (space->select.offset_changed) { + unsigned u; /* Local index variable */ /* Loop over dimensions */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Sanity check */ HDassert(low_bounds[u] <= high_bounds[u]); /* Check for offset moving selection negative */ - if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) + if (((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Set the low & high bounds in this dimension */ start[u] = (hsize_t)((hssize_t)low_bounds[u] + space->select.offset[u]); - if((int)u == space->select.sel_info.hslab->unlim_dim) + if ((int)u == space->select.sel_info.hslab->unlim_dim) end[u] = H5S_UNLIMITED; else end[u] = (hsize_t)((hssize_t)high_bounds[u] + space->select.offset[u]); } /* end for */ - } /* end if */ + } /* end if */ else { /* Offset vector is still zeros, just copy low & high bounds */ H5MM_memcpy(start, low_bounds, sizeof(hsize_t) * space->extent.rank); @@ -4890,7 +4874,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_offset @@ -4914,38 +4897,40 @@ done: static herr_t H5S__hyper_offset(const H5S_t *space, hsize_t *offset) { - const hssize_t *sel_offset; /* Pointer to the selection's offset */ - const hsize_t *dim_size; /* Pointer to a dataspace's extent */ - hsize_t accum; /* Accumulator for dimension sizes */ - unsigned rank; /* Dataspace rank */ - int i; /* index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const hssize_t *sel_offset; /* Pointer to the selection's offset */ + const hsize_t * dim_size; /* Pointer to a dataspace's extent */ + hsize_t accum; /* Accumulator for dimension sizes */ + unsigned rank; /* Dataspace rank */ + int i; /* index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - HDassert(space && space->extent.rank>0); + HDassert(space && space->extent.rank > 0); HDassert(offset); /* Start at linear offset 0 */ *offset = 0; /* Set up pointers to arrays of values */ - rank = space->extent.rank; + rank = space->extent.rank; sel_offset = space->select.offset; - dim_size = space->extent.size; + dim_size = space->extent.size; /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->diminfo.opt; /* Local alias for diminfo */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + const H5S_hyper_dim_t *diminfo = + space->select.sel_info.hslab->diminfo.opt; /* Local alias for diminfo */ /* Loop through starting coordinates, calculating the linear offset */ accum = 1; - for(i = (int)(rank - 1); i >= 0; i--) { - hssize_t hyp_offset = (hssize_t)diminfo[i].start + sel_offset[i]; /* Hyperslab's offset in this dimension */ + for (i = (int)(rank - 1); i >= 0; i--) { + hssize_t hyp_offset = + (hssize_t)diminfo[i].start + sel_offset[i]; /* Hyperslab's offset in this dimension */ /* Check for offset moving selection out of the dataspace */ - if(hyp_offset < 0 || (hsize_t)hyp_offset >= dim_size[i]) + if (hyp_offset < 0 || (hsize_t)hyp_offset >= dim_size[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Add the hyperslab's offset in this dimension to the total linear offset */ @@ -4954,14 +4939,14 @@ H5S__hyper_offset(const H5S_t *space, hsize_t *offset) /* Increase the accumulator */ accum *= dim_size[i]; } /* end for */ - } /* end if */ + } /* end if */ else { - const H5S_hyper_span_t *span; /* Hyperslab span node */ - hsize_t dim_accum[H5S_MAX_RANK]; /* Accumulators, for each dimension */ + const H5S_hyper_span_t *span; /* Hyperslab span node */ + hsize_t dim_accum[H5S_MAX_RANK]; /* Accumulators, for each dimension */ /* Calculate the accumulator for each dimension */ accum = 1; - for(i = (int)(rank - 1); i >= 0; i--) { + for (i = (int)(rank - 1); i >= 0; i--) { /* Set the accumulator for this dimension */ dim_accum[i] = accum; @@ -4974,18 +4959,19 @@ H5S__hyper_offset(const H5S_t *space, hsize_t *offset) /* Work down the spans, computing the linear offset */ i = 0; - while(span) { - hssize_t hyp_offset = (hssize_t)span->low + sel_offset[i]; /* Hyperslab's offset in this dimension */ + while (span) { + hssize_t hyp_offset = + (hssize_t)span->low + sel_offset[i]; /* Hyperslab's offset in this dimension */ /* Check for offset moving selection out of the dataspace */ - if(hyp_offset < 0 || (hsize_t)hyp_offset >= dim_size[i]) + if (hyp_offset < 0 || (hsize_t)hyp_offset >= dim_size[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Add the hyperslab's offset in this dimension to the total linear offset */ *offset += (hsize_t)(hyp_offset * (hssize_t)dim_accum[i]); /* Advance to first span in "down" dimension */ - if(span->down) { + if (span->down) { HDassert(span->down->head); span = span->down->head; } /* end if */ @@ -4993,13 +4979,12 @@ H5S__hyper_offset(const H5S_t *space, hsize_t *offset) span = NULL; i++; } /* end while */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_unlim_dim @@ -5026,7 +5011,6 @@ H5S__hyper_unlim_dim(const H5S_t *space) FUNC_LEAVE_NOAPI(space->select.sel_info.hslab->unlim_dim); } /* end H5S__hyper_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_num_elem_non_unlim @@ -5059,7 +5043,7 @@ H5S__hyper_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim) HDassert(num_elem_non_unlim); /* Get number of elements in the non-unlimited dimensions */ - if(space->select.sel_info.hslab->unlim_dim >= 0) + if (space->select.sel_info.hslab->unlim_dim >= 0) *num_elem_non_unlim = space->select.sel_info.hslab->num_elem_non_unlim; else HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "selection has no unlimited dimension") @@ -5068,7 +5052,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_num_elem_non_unlim() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_is_contiguous @@ -5090,10 +5073,10 @@ done: static H5_ATTR_PURE htri_t H5S__hyper_is_contiguous(const H5S_t *space) { - hbool_t small_contiguous, /* Flag for small contiguous block */ - large_contiguous; /* Flag for large contiguous block */ - unsigned u; /* index variable */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t small_contiguous, /* Flag for small contiguous block */ + large_contiguous; /* Flag for large contiguous block */ + unsigned u; /* index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -5101,8 +5084,9 @@ H5S__hyper_is_contiguous(const H5S_t *space) /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->diminfo.opt; /* local alias for diminfo */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + const H5S_hyper_dim_t *diminfo = + space->select.sel_info.hslab->diminfo.opt; /* local alias for diminfo */ /* * For a regular hyperslab to be contiguous, it must have only one @@ -5118,43 +5102,43 @@ H5S__hyper_is_contiguous(const H5S_t *space) */ /* Initialize flags */ - large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */ - small_contiguous = FALSE; /* assume false initially */ + large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */ + small_contiguous = FALSE; /* assume false initially */ /* Check for a "large contigous" block */ - for(u = 0; u < space->extent.rank; u++) { - if(diminfo[u].count > 1) { + for (u = 0; u < space->extent.rank; u++) { + if (diminfo[u].count > 1) { large_contiguous = FALSE; break; } /* end if */ - if(u > 0 && diminfo[u].block != space->extent.size[u]) { + if (u > 0 && diminfo[u].block != space->extent.size[u]) { large_contiguous = FALSE; break; } /* end if */ - } /* end for */ + } /* end for */ /* If we didn't find a large contiguous block, check for a small one */ - if(!large_contiguous) { + if (!large_contiguous) { small_contiguous = TRUE; - for(u = 0; u < space->extent.rank; u++) { - if(diminfo[u].count > 1) { + for (u = 0; u < space->extent.rank; u++) { + if (diminfo[u].count > 1) { small_contiguous = FALSE; break; } /* end if */ - if(u < (space->extent.rank - 1) && diminfo[u].block != 1) { + if (u < (space->extent.rank - 1) && diminfo[u].block != 1) { small_contiguous = FALSE; break; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* Indicate true if it's either a large or small contiguous block */ - if(large_contiguous || small_contiguous) + if (large_contiguous || small_contiguous) ret_value = TRUE; } /* end if */ else { - H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ - H5S_hyper_span_t *span; /* Hyperslab span node */ + H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ + H5S_hyper_span_t * span; /* Hyperslab span node */ /* * For a hyperslab to be contiguous, it must have only one block and @@ -5164,36 +5148,37 @@ H5S__hyper_is_contiguous(const H5S_t *space) * block size must be 1 in all but the fastest changing dimension. */ /* Initialize flags */ - large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */ - small_contiguous = FALSE; /* assume false initially */ + large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */ + small_contiguous = FALSE; /* assume false initially */ /* Get information for slowest changing information */ spans = space->select.sel_info.hslab->span_lst; - span = spans->head; + span = spans->head; /* If there are multiple spans in the slowest changing dimension, the selection isn't contiguous */ - if(span->next != NULL) + if (span->next != NULL) large_contiguous = FALSE; else { /* Now check the rest of the dimensions */ - if(span->down != NULL) { - u = 1; /* Current dimension working on */ + if (span->down != NULL) { + u = 1; /* Current dimension working on */ /* Get the span information for the next fastest dimension */ spans = span->down; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ - while(spans != NULL) { + while (spans != NULL) { span = spans->head; /* Check that this is the only span and it spans the entire dimension */ - if(span->next != NULL) { + if (span->next != NULL) { large_contiguous = FALSE; break; } /* end if */ else { - /* If this span doesn't cover the entire dimension, then this selection isn't contiguous */ - if(((span->high - span->low) + 1) != space->extent.size[u]) { + /* If this span doesn't cover the entire dimension, then this selection isn't + * contiguous */ + if (((span->high - span->low) + 1) != space->extent.size[u]) { large_contiguous = FALSE; break; } /* end if */ @@ -5204,34 +5189,35 @@ H5S__hyper_is_contiguous(const H5S_t *space) /* Increment dimension */ u++; } /* end else */ - } /* end else */ - } /* end while */ - } /* end if */ - } /* end else */ + } /* end else */ + } /* end while */ + } /* end if */ + } /* end else */ /* If we didn't find a large contiguous block, check for a small one */ - if(!large_contiguous) { + if (!large_contiguous) { small_contiguous = TRUE; /* Get information for slowest changing information */ spans = space->select.sel_info.hslab->span_lst; - span = spans->head; + span = spans->head; /* Current dimension working on */ u = 0; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ - while(spans != NULL) { + while (spans != NULL) { span = spans->head; /* Check that this is the only span and it spans the entire dimension */ - if(span->next != NULL) { + if (span->next != NULL) { small_contiguous = FALSE; break; } /* end if */ else { - /* If this span doesn't cover the entire dimension, then this selection isn't contiguous */ - if(u < (space->extent.rank - 1) && ((span->high-span->low) + 1) != 1) { + /* If this span doesn't cover the entire dimension, then this selection isn't contiguous + */ + if (u < (space->extent.rank - 1) && ((span->high - span->low) + 1) != 1) { small_contiguous = FALSE; break; } /* end if */ @@ -5242,19 +5228,18 @@ H5S__hyper_is_contiguous(const H5S_t *space) /* Increment dimension */ u++; } /* end else */ - } /* end else */ - } /* end while */ - } /* end if */ + } /* end else */ + } /* end while */ + } /* end if */ /* Indicate true if it's either a large or small contiguous block */ - if(large_contiguous || small_contiguous) + if (large_contiguous || small_contiguous) ret_value = TRUE; } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_is_single @@ -5276,7 +5261,7 @@ H5S__hyper_is_contiguous(const H5S_t *space) static H5_ATTR_PURE htri_t H5S__hyper_is_single(const H5S_t *space) { - htri_t ret_value = TRUE; /* return value */ + htri_t ret_value = TRUE; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -5286,8 +5271,8 @@ H5S__hyper_is_single(const H5S_t *space) /* (No need to rebuild the dimension info yet, since the span-tree * algorithm is fast -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - unsigned u; /* index variable */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + unsigned u; /* index variable */ /* * For a regular hyperslab to be single, it must have only one @@ -5295,12 +5280,12 @@ H5S__hyper_is_single(const H5S_t *space) */ /* Check for a single block */ - for(u = 0; u < space->extent.rank; u++) - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + for (u = 0; u < space->extent.rank; u++) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) HGOTO_DONE(FALSE) } /* end if */ else { - H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ + H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ /* * For a region to be single, it must have only one block @@ -5309,25 +5294,24 @@ H5S__hyper_is_single(const H5S_t *space) spans = space->select.sel_info.hslab->span_lst; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ - while(spans != NULL) { - H5S_hyper_span_t *span; /* Hyperslab span node */ + while (spans != NULL) { + H5S_hyper_span_t *span; /* Hyperslab span node */ span = spans->head; /* Check that this is the only span and it spans the entire dimension */ - if(span->next != NULL) + if (span->next != NULL) HGOTO_DONE(FALSE) else /* Walk down to the next span */ spans = span->down; } /* end while */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_is_regular @@ -5350,7 +5334,7 @@ done: static htri_t H5S__hyper_is_regular(const H5S_t *space) { - htri_t ret_value = FAIL; /* return value */ + htri_t ret_value = FAIL; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -5360,11 +5344,11 @@ H5S__hyper_is_regular(const H5S_t *space) /* Attempt to rebuild diminfo if it is invalid and has not been confirmed * to be impossible. */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */ /* Only simple check for regular hyperslabs for now... */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) ret_value = TRUE; else ret_value = FALSE; @@ -5372,7 +5356,6 @@ H5S__hyper_is_regular(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_shape_same_helper @@ -5400,10 +5383,10 @@ H5S__hyper_is_regular(const H5S_t *space) --------------------------------------------------------------------------*/ static H5_ATTR_PURE hbool_t H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, - const H5S_hyper_span_info_t *span_info2, hssize_t offset[], - hbool_t rest_zeros[]) + const H5S_hyper_span_info_t *span_info2, hssize_t offset[], + hbool_t rest_zeros[]) { - hbool_t ret_value = TRUE; /* Return value */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -5417,9 +5400,9 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, /* (Could compare lower dimensions also, but not certain if * that's worth it. - QAK, 2019/01/23) */ - if((hsize_t)((hssize_t)span_info1->low_bounds[0] + offset[0]) != span_info2->low_bounds[0]) + if ((hsize_t)((hssize_t)span_info1->low_bounds[0] + offset[0]) != span_info2->low_bounds[0]) HGOTO_DONE(FALSE) - else if((hsize_t)((hssize_t)span_info1->high_bounds[0] + offset[0]) != span_info2->high_bounds[0]) + else if ((hsize_t)((hssize_t)span_info1->high_bounds[0] + offset[0]) != span_info2->high_bounds[0]) HGOTO_DONE(FALSE) else { const H5S_hyper_span_t *span1; @@ -5434,37 +5417,39 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, HDassert(span2); /* infinite loop which must be broken out of */ - while(1) { + while (1) { /* Check for both spans being NULL */ - if(span1 == NULL && span2 == NULL) + if (span1 == NULL && span2 == NULL) HGOTO_DONE(TRUE) /* Check for one span being NULL */ - if(span1 == NULL || span2 == NULL) + if (span1 == NULL || span2 == NULL) HGOTO_DONE(FALSE) /* Check if the actual low & high span information is the same */ - if((hsize_t)((hssize_t)span1->low + offset[0]) != span2->low || (hsize_t)((hssize_t)span1->high + offset[0]) != span2->high) + if ((hsize_t)((hssize_t)span1->low + offset[0]) != span2->low || + (hsize_t)((hssize_t)span1->high + offset[0]) != span2->high) HGOTO_DONE(FALSE) /* Check for down tree for this span */ - if(span1->down != NULL || span2->down != NULL) { + if (span1->down != NULL || span2->down != NULL) { /* If the rest of the span trees have a zero offset, use the faster comparison routine */ - if(rest_zeros[0]) { - if(!H5S__hyper_cmp_spans(span1->down, span2->down)) + if (rest_zeros[0]) { + if (!H5S__hyper_cmp_spans(span1->down, span2->down)) HGOTO_DONE(FALSE) else { /* Keep going... */ } /* end else */ - } /* end if */ + } /* end if */ else { - if(!H5S__hyper_spans_shape_same_helper(span1->down, span2->down, &offset[1], &rest_zeros[1])) + if (!H5S__hyper_spans_shape_same_helper(span1->down, span2->down, &offset[1], + &rest_zeros[1])) HGOTO_DONE(FALSE) else { /* Keep going... */ } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Keep going... */ } /* end else */ @@ -5473,7 +5458,7 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, span1 = span1->next; span2 = span2->next; } /* end while */ - } /* end else */ + } /* end else */ /* Fall through, with default return value of 'TRUE' if spans were already visited */ @@ -5481,7 +5466,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_shape_same_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_shape_same @@ -5503,16 +5487,16 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static H5_ATTR_PURE hbool_t -H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, - const H5S_hyper_span_info_t *span_info2, unsigned ndims) +H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_span_info_t *span_info2, + unsigned ndims) { - const H5S_hyper_span_t *span1; /* Pointer to spans in first span tree */ - const H5S_hyper_span_t *span2; /* Pointer to spans in second span tree */ - hssize_t offset[H5S_MAX_RANK]; /* Offset vector for selections */ - hbool_t rest_zeros[H5S_MAX_RANK]; /* Vector of flags to indicate when remaining offset is all zero */ - hbool_t zero_offset; /* Whether the two selections have a non-zero offset */ - unsigned u; /* Local index variable */ - hbool_t ret_value = TRUE; /* Return value */ + const H5S_hyper_span_t *span1; /* Pointer to spans in first span tree */ + const H5S_hyper_span_t *span2; /* Pointer to spans in second span tree */ + hssize_t offset[H5S_MAX_RANK]; /* Offset vector for selections */ + hbool_t rest_zeros[H5S_MAX_RANK]; /* Vector of flags to indicate when remaining offset is all zero */ + hbool_t zero_offset; /* Whether the two selections have a non-zero offset */ + unsigned u; /* Local index variable */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -5526,16 +5510,16 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, HDmemset(rest_zeros, 0, sizeof(rest_zeros)); /* Check for an offset between the two selections */ - span1 = span_info1->head; - span2 = span_info2->head; + span1 = span_info1->head; + span2 = span_info2->head; zero_offset = TRUE; - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { /* Check for offset in this dimension */ - if(span1->low != span2->low) { + if (span1->low != span2->low) { offset[u] = (hssize_t)span2->low - (hssize_t)span1->low; /* Indicate that the offset vector is not all zeros */ - if(zero_offset) + if (zero_offset) zero_offset = FALSE; } /* end if */ @@ -5544,19 +5528,19 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, HDassert((span1->down && span2->down) || (NULL == span1->down && NULL == span2->down)); /* Advance to next dimension */ - if(span1->down) { + if (span1->down) { span1 = span1->down->head; span2 = span2->down->head; } /* end if */ - } /* end for */ + } /* end for */ /* Check if there's a "tail" of all zeros in a non-zero offset vector */ - if(!zero_offset) { - int i; /* Local index variable */ + if (!zero_offset) { + int i; /* Local index variable */ /* Find first non-zero offset, from the fastest dimension up */ - for(i = (int)(ndims - 1); i >= 0; i--) - if(offset[i]) { + for (i = (int)(ndims - 1); i >= 0; i--) + if (offset[i]) { rest_zeros[i] = TRUE; break; } /* end if */ @@ -5570,7 +5554,7 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, * comparison routine. Otherwise, use a generalized version of that * routine. */ - if(zero_offset) + if (zero_offset) ret_value = H5S__hyper_cmp_spans(span_info1, span_info2); else ret_value = H5S__hyper_spans_shape_same_helper(span_info1, span_info2, offset, rest_zeros); @@ -5578,7 +5562,6 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_shape_same @@ -5606,9 +5589,9 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, static htri_t H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) { - unsigned space1_rank; /* Number of dimensions of first dataspace */ - unsigned space2_rank; /* Number of dimensions of second dataspace */ - htri_t ret_value = TRUE; /* Return value */ + unsigned space1_rank; /* Number of dimensions of first dataspace */ + unsigned space2_rank; /* Number of dimensions of second dataspace */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -5626,16 +5609,16 @@ H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) /* Rebuild diminfo if it is invalid and has not been confirmed to be * impossible */ - if(space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space1); /* Casting away const OK -QAK */ - if(space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space2); /* Casting away const OK -QAK */ + if (space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space1); /* Casting away const OK -QAK */ + if (space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space2); /* Casting away const OK -QAK */ /* If both are regular hyperslabs, compare their diminfo values */ - if(space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES - && space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - int space1_dim; /* Current dimension in first dataspace */ - int space2_dim; /* Current dimension in second dataspace */ + if (space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES && + space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + int space1_dim; /* Current dimension in first dataspace */ + int space2_dim; /* Current dimension in second dataspace */ /* Initialize dimensions */ space1_dim = (int)space1_rank - 1; @@ -5644,63 +5627,65 @@ H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) /* Check that the shapes are the same in the common dimensions, and that * block == 1 in all dimensions that appear only in space1. */ - while(space2_dim >= 0) { - if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].stride != - space2->select.sel_info.hslab->diminfo.opt[space2_dim].stride) + while (space2_dim >= 0) { + if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].stride != + space2->select.sel_info.hslab->diminfo.opt[space2_dim].stride) HGOTO_DONE(FALSE) - if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].count != - space2->select.sel_info.hslab->diminfo.opt[space2_dim].count) + if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].count != + space2->select.sel_info.hslab->diminfo.opt[space2_dim].count) HGOTO_DONE(FALSE) - if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != - space2->select.sel_info.hslab->diminfo.opt[space2_dim].block) + if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != + space2->select.sel_info.hslab->diminfo.opt[space2_dim].block) HGOTO_DONE(FALSE) space1_dim--; space2_dim--; } /* end while */ - while(space1_dim >= 0) { - if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != 1) + while (space1_dim >= 0) { + if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != 1) HGOTO_DONE(FALSE) space1_dim--; } /* end while */ - } /* end if */ + } /* end if */ /* If both aren't regular, use fast irregular comparison */ else { - H5S_hyper_span_info_t *spans1; /* Hyperslab spans for first dataspace */ + H5S_hyper_span_info_t *spans1; /* Hyperslab spans for first dataspace */ /* Make certain that both selections have span trees */ - if(NULL == space1->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans((H5S_t *)space1) < 0) /* Casting away const OK -QAK */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for hyperslab selection") - if(NULL == space2->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans((H5S_t *)space2) < 0) /* Casting away const OK -QAK */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for hyperslab selection") + if (NULL == space1->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans((H5S_t *)space1) < 0) /* Casting away const OK -QAK */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for hyperslab selection") + if (NULL == space2->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans((H5S_t *)space2) < 0) /* Casting away const OK -QAK */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for hyperslab selection") /* If rank of space A is different (guaranteed greater) than * rank of space B, walk down the span tree, verifying * that the block size is 1 on the way down. */ - if(space1_rank > space2_rank) { - unsigned diff_rank = space1_rank - space2_rank; /* Difference in ranks */ + if (space1_rank > space2_rank) { + unsigned diff_rank = space1_rank - space2_rank; /* Difference in ranks */ /* Walk down the dimensions */ spans1 = space1->select.sel_info.hslab->span_lst; - while(diff_rank > 0) { - H5S_hyper_span_t *span; /* Span for this dimension */ + while (diff_rank > 0) { + H5S_hyper_span_t *span; /* Span for this dimension */ /* Get pointer to first span in tree */ span = spans1->head; /* Check for more spans in this dimension */ - if(span->next) + if (span->next) HGOTO_DONE(FALSE) /* Check for span size > 1 element */ - if(span->low != span->high) + if (span->low != span->high) HGOTO_DONE(FALSE) /* Walk down to the next dimension */ @@ -5724,7 +5709,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_release @@ -5754,8 +5738,8 @@ H5S__hyper_release(H5S_t *space) space->select.num_elem = 0; /* Release irregular hyperslab information */ - if(space->select.sel_info.hslab) { - if(space->select.sel_info.hslab->span_lst != NULL) + if (space->select.sel_info.hslab) { + if (space->select.sel_info.hslab->span_lst != NULL) H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst); /* Release space for the hyperslab selection information */ @@ -5765,7 +5749,6 @@ H5S__hyper_release(H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_release() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_coord_to_span @@ -5787,9 +5770,9 @@ H5S__hyper_release(H5S_t *space) static H5S_hyper_span_t * H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) { - H5S_hyper_span_t *new_span; /* Pointer to new span tree for coordinate */ - H5S_hyper_span_info_t *down = NULL; /* Pointer to new span tree for next level down */ - H5S_hyper_span_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_t * new_span; /* Pointer to new span tree for coordinate */ + H5S_hyper_span_info_t *down = NULL; /* Pointer to new span tree for next level down */ + H5S_hyper_span_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -5797,9 +5780,9 @@ H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) HDassert(coords); /* Search for location to insert new element in tree */ - if(rank > 1) { + if (rank > 1) { /* Allocate a span info node for coordinates below this one */ - if(NULL == (down = H5S__hyper_new_span_info(rank - 1))) + if (NULL == (down = H5S__hyper_new_span_info(rank - 1))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set the low & high bounds for this span info node */ @@ -5807,28 +5790,27 @@ H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) H5MM_memcpy(down->high_bounds, &coords[1], (rank - 1) * sizeof(hsize_t)); /* Build span tree for coordinates below this one */ - if(NULL == (down->head = H5S__hyper_coord_to_span(rank - 1, &coords[1]))) + if (NULL == (down->head = H5S__hyper_coord_to_span(rank - 1, &coords[1]))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") - /* Update the tail pointer of the down dimension, and it's a single span element */ - down->tail = down->head; + /* Update the tail pointer of the down dimension, and it's a single span element */ + down->tail = down->head; } /* end if */ /* Build span for this coordinate */ - if(NULL == (new_span = H5S__hyper_new_span(coords[0], coords[0], down, NULL))) + if (NULL == (new_span = H5S__hyper_new_span(coords[0], coords[0], down, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set return value */ ret_value = new_span; done: - if(ret_value == NULL && down != NULL) + if (ret_value == NULL && down != NULL) H5S__hyper_free_span_info(down); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_coord_to_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_add_span_element_helper @@ -5851,11 +5833,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, - unsigned rank, const hsize_t *coords, int *first_dim_modified) +H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, unsigned rank, const hsize_t *coords, + int *first_dim_modified) { - H5S_hyper_span_t *tail_span; /* Pointer to the tail span of one dimension */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_t *tail_span; /* Pointer to the tail span of one dimension */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -5870,24 +5852,24 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, /* Determine if tail span includes a portion of the coordinate */ /* (Should never happen with the lowest level in the span tree) */ - if(coords[0] >= tail_span->low && coords[0] <= tail_span->high) { - H5S_hyper_span_t *prev_down_tail_span; /* Pointer to previous down spans' tail pointer */ - hsize_t prev_down_tail_span_high; /* Value of previous down spans' tail's high value */ + if (coords[0] >= tail_span->low && coords[0] <= tail_span->high) { + H5S_hyper_span_t *prev_down_tail_span; /* Pointer to previous down spans' tail pointer */ + hsize_t prev_down_tail_span_high; /* Value of previous down spans' tail's high value */ /* Retain into about down spans' tail */ - prev_down_tail_span = tail_span->down->tail; + prev_down_tail_span = tail_span->down->tail; prev_down_tail_span_high = tail_span->down->tail->high; /* Drop down a dimension */ HDassert(rank > 1); - if(H5S__hyper_add_span_element_helper(tail_span->down, rank - 1, &coords[1], first_dim_modified) < 0) + if (H5S__hyper_add_span_element_helper(tail_span->down, rank - 1, &coords[1], first_dim_modified) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert coordinate into span tree") /* Check & update high bounds for lower dimensions */ - if(*first_dim_modified >= 0) { - unsigned first_dim; /* First dimension modified, relative to this span tree */ - hbool_t first_dim_set = FALSE; /* Whether first dimension modified is set */ - unsigned u; /* Local index variable */ + if (*first_dim_modified >= 0) { + unsigned first_dim; /* First dimension modified, relative to this span tree */ + hbool_t first_dim_set = FALSE; /* Whether first dimension modified is set */ + unsigned u; /* Local index variable */ /* Adjust first dimension modified to be relative to this span tree */ first_dim = (unsigned)(*first_dim_modified + 1); @@ -5896,33 +5878,33 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, *first_dim_modified = -1; /* Iterate through coordinates */ - for(u = first_dim; u < rank; u++) { + for (u = first_dim; u < rank; u++) { /* Check if coordinate is outside the bounds for this span tree */ - if(coords[u] > span_tree->high_bounds[u]) { + if (coords[u] > span_tree->high_bounds[u]) { /* Update high bounds for this tree */ span_tree->high_bounds[u] = coords[u]; /* Need to signal to higher dimensions if high bounds changed */ - if(!first_dim_set) { + if (!first_dim_set) { *first_dim_modified = (int)u; - first_dim_set = TRUE; + first_dim_set = TRUE; } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ /* Check if previous tail span in down spans is different than current * tail span, or if its high value changed, in which case we should * check if the updated node can share down spans with other nodes. */ - if(tail_span->down->tail != prev_down_tail_span || - prev_down_tail_span_high != tail_span->down->tail->high) { + if (tail_span->down->tail != prev_down_tail_span || + prev_down_tail_span_high != tail_span->down->tail->high) { H5S_hyper_span_t *stop_span; /* Pointer to span to stop at */ - H5S_hyper_span_t *tmp_span; /* Temporary pointer to a span */ - uint64_t op_gen; /* Operation generation value */ + H5S_hyper_span_t *tmp_span; /* Temporary pointer to a span */ + uint64_t op_gen; /* Operation generation value */ /* Determine which span to stop at */ - if(tail_span->down->tail != prev_down_tail_span) { + if (tail_span->down->tail != prev_down_tail_span) { /* Sanity check */ HDassert(prev_down_tail_span->next == tail_span->down->tail); @@ -5948,23 +5930,23 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, * information. */ tmp_span = tail_span->down->head; - while(tmp_span != stop_span) { - hbool_t attempt_merge_spans = FALSE; /* Whether to merge spans */ + while (tmp_span != stop_span) { + hbool_t attempt_merge_spans = FALSE; /* Whether to merge spans */ /* Different tests for when to run the 'merge' algorithm, * depending whether there's "down trees" or not. */ - if(NULL == tmp_span->down) { + if (NULL == tmp_span->down) { /* Spin through spans until we find the one before the 'stop' span */ - if(tmp_span->next == stop_span) + if (tmp_span->next == stop_span) attempt_merge_spans = TRUE; } /* end if */ else { /* Check if we've compared the 'stop' span's "down tree" to * this span's "down tree" already. */ - if(tmp_span->down->op_info[0].op_gen != op_gen) { - if(H5S__hyper_cmp_spans(tmp_span->down, stop_span->down)) + if (tmp_span->down->op_info[0].op_gen != op_gen) { + if (H5S__hyper_cmp_spans(tmp_span->down, stop_span->down)) attempt_merge_spans = TRUE; /* Remember that we visited this span's "down tree" already */ @@ -5973,16 +5955,16 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, */ tmp_span->down->op_info[0].op_gen = op_gen; } /* end if */ - } /* end else */ + } /* end else */ /* Check for merging into previous span */ - if(attempt_merge_spans) { - if(tmp_span->high + 1 == stop_span->low) { + if (attempt_merge_spans) { + if (tmp_span->high + 1 == stop_span->low) { /* Increase size of previous span */ tmp_span->high++; /* Update pointers appropriately */ - if(stop_span == prev_down_tail_span) { + if (stop_span == prev_down_tail_span) { /* Sanity check */ HDassert(stop_span->next == tail_span->down->tail); @@ -5992,7 +5974,7 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, /* Sanity check */ HDassert(tmp_span->next == tail_span->down->tail); - tmp_span->next = NULL; + tmp_span->next = NULL; tail_span->down->tail = tmp_span; } /* end else */ @@ -6001,7 +5983,7 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, } /* end if */ /* Span is disjoint, but has the same "down tree" selection */ /* (If it has a "down tree") */ - else if(stop_span->down) { + else if (stop_span->down) { /* Release "down tree" information */ H5S__hyper_free_span_info(stop_span->down); @@ -6019,23 +6001,24 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, /* Advance to next span to check */ tmp_span = tmp_span->next; } /* end while */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Check if we made it all the way to the bottom span list in the tree * and the new coordinate adjoins the current tail span. */ - if(rank == 1 && (tail_span->high + 1) == coords[0]) + if (rank == 1 && (tail_span->high + 1) == coords[0]) /* Append element to current tail span */ tail_span->high++; else { - H5S_hyper_span_t *new_span; /* New span created for element */ + H5S_hyper_span_t *new_span; /* New span created for element */ /* Make span tree for current coordinate(s) */ - if(NULL == (new_span = H5S__hyper_coord_to_span(rank, coords))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab spans for coordinate") + if (NULL == (new_span = H5S__hyper_coord_to_span(rank, coords))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate hyperslab spans for coordinate") /* Add new span to span tree list */ tail_span->next = new_span; @@ -6047,8 +6030,8 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, span_tree->high_bounds[0] = coords[0]; /* Update high bounds for dimensions below this one */ - for(u = 1; u < rank; u++) - if(coords[u] > span_tree->high_bounds[u]) + for (u = 1; u < rank; u++) + if (coords[u] > span_tree->high_bounds[u]) span_tree->high_bounds[u] = coords[u]; /* Need to signal to higher dimensions that high bounds changed */ @@ -6059,7 +6042,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_add_span_element_helper() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_add_span_element @@ -6101,8 +6083,8 @@ done: herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) { - H5S_hyper_span_info_t *head = NULL; /* Pointer to new head of span tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_info_t *head = NULL; /* Pointer to new head of span tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6112,9 +6094,9 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) HDassert(space->extent.rank == rank); /* Check if this is the first element in the selection */ - if(NULL == space->select.sel_info.hslab) { + if (NULL == space->select.sel_info.hslab) { /* Allocate a span info node */ - if(NULL == (head = H5S__hyper_new_span_info(rank))) + if (NULL == (head = H5S__hyper_new_span_info(rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span info") /* Set the low & high bounds for this span info node */ @@ -6125,14 +6107,14 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) head->count = 1; /* Build span tree for this coordinate */ - if(NULL == (head->head = H5S__hyper_coord_to_span(rank, coords))) + if (NULL == (head->head = H5S__hyper_coord_to_span(rank, coords))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab spans for coordinate") /* Update the tail pointer of this newly created span in dimension "rank" */ head->tail = head->head; /* Allocate selection info */ - if(NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) + if (NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab selection") /* Set the selection to the new span tree */ @@ -6151,10 +6133,11 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) space->select.num_elem = 1; } /* end if */ else { - int first_dim_modified = -1; /* Index of first dimension modified */ + int first_dim_modified = -1; /* Index of first dimension modified */ /* Add the element to the current set of spans */ - if(H5S__hyper_add_span_element_helper(space->select.sel_info.hslab->span_lst, rank, coords, &first_dim_modified) < 0) + if (H5S__hyper_add_span_element_helper(space->select.sel_info.hslab->span_lst, rank, coords, + &first_dim_modified) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert coordinate into span tree") /* Increment # of elements in selection */ @@ -6162,14 +6145,13 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) } /* end else */ done: - if(ret_value < 0) - if(head) + if (ret_value < 0) + if (head) H5S__hyper_free_span_info(head); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_add_span_element() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_intersect_block_helper @@ -6193,11 +6175,10 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static hbool_t -H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, - unsigned rank, const hsize_t *start, const hsize_t *end, unsigned op_info_i, - uint64_t op_gen) +H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, unsigned rank, const hsize_t *start, + const hsize_t *end, unsigned op_info_i, uint64_t op_gen) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -6207,47 +6188,48 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, HDassert(end); /* Check if we've already visited this span tree */ - if(spans->op_info[op_info_i].op_gen != op_gen) { - H5S_hyper_span_t *curr; /* Pointer to current span in 1st span tree */ - unsigned u; /* Local index variable */ + if (spans->op_info[op_info_i].op_gen != op_gen) { + H5S_hyper_span_t *curr; /* Pointer to current span in 1st span tree */ + unsigned u; /* Local index variable */ /* Verify that there is a possibility of an overlap by checking the block * against the low & high bounds for the span tree. */ - for(u = 0; u < rank; u++) - if(start[u] > spans->high_bounds[u] || end[u] < spans->low_bounds[u]) + for (u = 0; u < rank; u++) + if (start[u] > spans->high_bounds[u] || end[u] < spans->low_bounds[u]) HGOTO_DONE(FALSE) /* Get the span list for spans in this tree */ curr = spans->head; /* Iterate over the spans in the tree */ - while(curr != NULL) { + while (curr != NULL) { /* Check for span entirely before block */ - if(curr->high < *start) + if (curr->high < *start) /* Advance to next span in this dimension */ curr = curr->next; /* If this span is past the end of the block, then we're done in this dimension */ - else if(curr->low > *end) + else if (curr->low > *end) HGOTO_DONE(FALSE) /* block & span overlap */ else { /* If this is the bottom dimension, then the span tree overlaps the block */ - if(curr->down == NULL) + if (curr->down == NULL) HGOTO_DONE(TRUE) /* Recursively check spans in next dimension down */ else { /* If there is an intersection in the "down" dimensions, * the span trees overlap. */ - if(H5S__hyper_intersect_block_helper(curr->down, rank - 1, start + 1, end + 1, op_info_i, op_gen)) + if (H5S__hyper_intersect_block_helper(curr->down, rank - 1, start + 1, end + 1, op_info_i, + op_gen)) HGOTO_DONE(TRUE) /* No intersection in down dimensions, advance to next span */ curr = curr->next; } /* end else */ - } /* end else */ - } /* end while */ + } /* end else */ + } /* end while */ /* Set the tree's operation generation */ spans->op_info[op_info_i].op_gen = op_gen; @@ -6259,7 +6241,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_intersect_block_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_intersect_block @@ -6284,7 +6265,7 @@ done: static htri_t H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -6297,43 +6278,43 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize /* Attempt to rebuild diminfo if it is invalid and has not been confirmed * to be impossible. */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -QAK */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -QAK */ /* Check for regular hyperslab intersection */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - hbool_t single_block; /* Whether the regular selection is a single block */ - unsigned u; /* Local index variable */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + hbool_t single_block; /* Whether the regular selection is a single block */ + unsigned u; /* Local index variable */ /* Check for a single block */ /* For a regular hyperslab to be single, it must have only one block * (i.e. count == 1 in all dimensions). */ single_block = TRUE; - for(u = 0; u < space->extent.rank; u++) - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + for (u = 0; u < space->extent.rank; u++) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) single_block = FALSE; /* Single blocks have already been "compared" above, in the low / high * bound checking, so just return TRUE if we've reached here - they * would have been rejected earlier, if they didn't intersect. */ - if(single_block) + if (single_block) HGOTO_DONE(TRUE) else { /* Loop over the dimensions, checking for an intersection */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* If the block's start is <= the hyperslab start, they intersect */ /* (So, if the start is > the hyperslab start, check more conditions) */ - if(start[u] > space->select.sel_info.hslab->diminfo.opt[u].start) { - hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */ - hsize_t nstride; /* Number of strides into the selection */ + if (start[u] > space->select.sel_info.hslab->diminfo.opt[u].start) { + hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */ + hsize_t nstride; /* Number of strides into the selection */ /* Adjust start coord for selection's 'start' offset */ adj_start = start[u] - space->select.sel_info.hslab->diminfo.opt[u].start; /* Compute # of strides into the selection */ - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) nstride = adj_start / space->select.sel_info.hslab->diminfo.opt[u].stride; else nstride = 0; @@ -6349,8 +6330,8 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize /* If the adjusted start doesn't fall within the first hyperslab * span, check for the block overlapping with the next one. */ - if(adj_start >= space->select.sel_info.hslab->diminfo.opt[u].block) { - hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */ + if (adj_start >= space->select.sel_info.hslab->diminfo.opt[u].block) { + hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */ /* Adjust end coord for selection's 'start' offset */ adj_end = end[u] - space->select.sel_info.hslab->diminfo.opt[u].start; @@ -6363,20 +6344,20 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize /* If block doesn't extend over beginning of next span, * it doesn't intersect. */ - if(adj_end < space->select.sel_info.hslab->diminfo.opt[u].stride) + if (adj_end < space->select.sel_info.hslab->diminfo.opt[u].stride) HGOTO_DONE(FALSE) } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* If we've looped through all dimensions and none of them didn't * overlap, then all of them do, so we report TRUE. */ HGOTO_DONE(TRUE) } /* end else */ - } /* end if */ + } /* end if */ else { - uint64_t op_gen; /* Operation generation value */ + uint64_t op_gen; /* Operation generation value */ /* Acquire an operation generation value for this operation */ op_gen = H5S__hyper_get_op_gen(); @@ -6384,14 +6365,14 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize /* Perform the span-by-span intersection check */ /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ - ret_value = H5S__hyper_intersect_block_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, start, end, 0, op_gen); + ret_value = H5S__hyper_intersect_block_helper(space->select.sel_info.hslab->span_lst, + space->extent.rank, start, end, 0, op_gen); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_u_helper @@ -6414,8 +6395,8 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static void -H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, - const hsize_t *offset, unsigned op_info_i, uint64_t op_gen) +H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, const hsize_t *offset, + unsigned op_info_i, uint64_t op_gen) { FUNC_ENTER_STATIC_NOERR @@ -6424,12 +6405,12 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, HDassert(offset); /* Check if we've already set this span tree */ - if(spans->op_info[op_info_i].op_gen != op_gen) { - H5S_hyper_span_t *span; /* Pointer to current span in span tree */ - unsigned u; /* Local index variable */ + if (spans->op_info[op_info_i].op_gen != op_gen) { + H5S_hyper_span_t *span; /* Pointer to current span in span tree */ + unsigned u; /* Local index variable */ /* Adjust the span tree's low & high bounds */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { HDassert(spans->low_bounds[u] >= offset[u]); spans->low_bounds[u] -= offset[u]; spans->high_bounds[u] -= offset[u]; @@ -6437,14 +6418,14 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, /* Iterate over the spans in tree */ span = spans->head; - while(span != NULL) { + while (span != NULL) { /* Adjust span offset */ HDassert(span->low >= *offset); span->low -= *offset; span->high -= *offset; /* Recursively adjust spans in next dimension down */ - if(span->down != NULL) + if (span->down != NULL) H5S__hyper_adjust_u_helper(span->down, rank - 1, offset + 1, op_info_i, op_gen); /* Advance to next span in this dimension */ @@ -6458,7 +6439,6 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_adjust_u_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_u @@ -6480,8 +6460,8 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) { - hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ - unsigned u; /* Local index variable */ + hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -6490,18 +6470,18 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) HDassert(offset); /* Check for an all-zero offset vector */ - for(u = 0; u < space->extent.rank; u++) - if(0 != offset[u]) { + for (u = 0; u < space->extent.rank; u++) + if (0 != offset[u]) { non_zero_offset = TRUE; break; } /* Only perform operation if the offset is non-zero */ - if(non_zero_offset) { + if (non_zero_offset) { /* Subtract the offset from the "regular" coordinates, if they exist */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < space->extent.rank; u++) { + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + for (u = 0; u < space->extent.rank; u++) { HDassert(space->select.sel_info.hslab->diminfo.opt[u].start >= offset[u]); space->select.sel_info.hslab->diminfo.opt[u].start -= offset[u]; @@ -6510,11 +6490,11 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) space->select.sel_info.hslab->diminfo.low_bounds[u] -= offset[u]; space->select.sel_info.hslab->diminfo.high_bounds[u] -= offset[u]; } /* end for */ - } /* end if */ + } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ - if(space->select.sel_info.hslab->span_lst) { - uint64_t op_gen; /* Operation generation value */ + if (space->select.sel_info.hslab->span_lst) { + uint64_t op_gen; /* Operation generation value */ /* Acquire an operation generation value for this operation */ op_gen = H5S__hyper_get_op_gen(); @@ -6522,14 +6502,14 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) /* Perform adjustment */ /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ - H5S__hyper_adjust_u_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, op_gen); + H5S__hyper_adjust_u_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, + op_gen); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_adjust_u() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_project_scalar * @@ -6546,7 +6526,7 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) { - hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ + hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ FUNC_ENTER_STATIC_NOERR @@ -6556,12 +6536,13 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->diminfo.opt; /* Alias for dataspace's diminfo information */ - unsigned u; /* Counter */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + const H5S_hyper_dim_t *diminfo = + space->select.sel_info.hslab->diminfo.opt; /* Alias for dataspace's diminfo information */ + unsigned u; /* Counter */ /* Build the table of the initial offset */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Sanity check diminfo */ HDassert(1 == diminfo[u].count); HDassert(1 == diminfo[u].block); @@ -6572,15 +6553,15 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) /* Keep the offset for later */ block[u] = diminfo[u].start; } /* end for */ - } /* end if */ + } /* end if */ else { - const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - unsigned curr_dim; /* Current dimension being operated on */ + const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ + unsigned curr_dim; /* Current dimension being operated on */ /* Advance down selected spans */ - curr = space->select.sel_info.hslab->span_lst->head; + curr = space->select.sel_info.hslab->span_lst->head; curr_dim = 0; - while(1) { + while (1) { /* Sanity checks */ HDassert(NULL == curr->next); HDassert(curr->low == curr->high); @@ -6590,14 +6571,14 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) block[curr_dim] = curr->low; /* Advance down to next dimension */ - if(curr->down) { + if (curr->down) { curr = curr->down->head; curr_dim++; } /* end if */ else break; } /* end while */ - } /* end else */ + } /* end else */ /* Calculate offset of selection in projected buffer */ *offset = H5VM_array_offset(space->extent.rank, space->extent.size, block); @@ -6605,7 +6586,6 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_project_scalar() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple_lower * @@ -6622,8 +6602,8 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) static herr_t H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) { - H5S_hyper_span_info_t *down; /* Pointer to list of spans */ - unsigned curr_dim; /* Current dimension being operated on */ + H5S_hyper_span_info_t *down; /* Pointer to list of spans */ + unsigned curr_dim; /* Current dimension being operated on */ FUNC_ENTER_STATIC_NOERR @@ -6633,9 +6613,9 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) HDassert(new_space->extent.rank < base_space->extent.rank); /* Walk down the span tree until we reach the selection to project */ - down = base_space->select.sel_info.hslab->span_lst; + down = base_space->select.sel_info.hslab->span_lst; curr_dim = 0; - while(down && curr_dim < (base_space->extent.rank - new_space->extent.rank)) { + while (down && curr_dim < (base_space->extent.rank - new_space->extent.rank)) { /* Sanity check */ HDassert(NULL == down->head->next); @@ -6652,7 +6632,6 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_project_simple_lower() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple_higher * @@ -6669,11 +6648,11 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) static herr_t H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) { - H5S_hyper_span_t *prev_span = NULL; /* Pointer to previous list of spans */ - unsigned delta_rank; /* Difference in dataspace ranks */ - unsigned curr_dim; /* Current dimension being operated on */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_t *prev_span = NULL; /* Pointer to previous list of spans */ + unsigned delta_rank; /* Difference in dataspace ranks */ + unsigned curr_dim; /* Current dimension being operated on */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6684,48 +6663,50 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) /* Create nodes until reaching the correct # of dimensions */ new_space->select.sel_info.hslab->span_lst = NULL; - curr_dim = 0; - delta_rank = (new_space->extent.rank - base_space->extent.rank); - while(curr_dim < delta_rank) { - H5S_hyper_span_info_t *new_span_info; /* Pointer to list of spans */ - H5S_hyper_span_t *new_span; /* Temporary hyperslab span */ + curr_dim = 0; + delta_rank = (new_space->extent.rank - base_space->extent.rank); + while (curr_dim < delta_rank) { + H5S_hyper_span_info_t *new_span_info; /* Pointer to list of spans */ + H5S_hyper_span_t * new_span; /* Temporary hyperslab span */ /* Allocate a new span_info node */ - if(NULL == (new_span_info = H5S__hyper_new_span_info(new_space->extent.rank))) { - if(prev_span) + if (NULL == (new_span_info = H5S__hyper_new_span_info(new_space->extent.rank))) { + if (prev_span) H5S__hyper_free_span(prev_span); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span info") } /* end if */ /* Check for linking into higher span */ - if(prev_span) + if (prev_span) prev_span->down = new_span_info; /* Allocate a new node */ - if(NULL == (new_span = H5S__hyper_new_span((hsize_t)0, (hsize_t)0, NULL, NULL))) { + if (NULL == (new_span = H5S__hyper_new_span((hsize_t)0, (hsize_t)0, NULL, NULL))) { HDassert(new_span_info); - if(!prev_span) + if (!prev_span) (void)H5FL_ARR_FREE(hbounds_t, new_span_info); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") } /* end if */ /* Set the span_info information */ new_span_info->count = 1; - new_span_info->head = new_span; - new_span_info->tail = new_span; + new_span_info->head = new_span; + new_span_info->tail = new_span; /* Set the bounding box */ - for(u = 0; u < delta_rank; u++) { - new_span_info->low_bounds[u] = 0; + for (u = 0; u < delta_rank; u++) { + new_span_info->low_bounds[u] = 0; new_span_info->high_bounds[u] = 0; } /* end for */ - for(; u < new_space->extent.rank; u++) { - new_span_info->low_bounds[u] = base_space->select.sel_info.hslab->span_lst->low_bounds[u - delta_rank]; - new_span_info->high_bounds[u] = base_space->select.sel_info.hslab->span_lst->high_bounds[u - delta_rank]; + for (; u < new_space->extent.rank; u++) { + new_span_info->low_bounds[u] = + base_space->select.sel_info.hslab->span_lst->low_bounds[u - delta_rank]; + new_span_info->high_bounds[u] = + base_space->select.sel_info.hslab->span_lst->high_bounds[u - delta_rank]; } /* end for */ /* Attach to new space, if top span info */ - if(NULL == new_space->select.sel_info.hslab->span_lst) + if (NULL == new_space->select.sel_info.hslab->span_lst) new_space->select.sel_info.hslab->span_lst = new_span_info; /* Remember previous span info */ @@ -6742,17 +6723,17 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) prev_span->down->count++; done: - if(ret_value < 0 && new_space->select.sel_info.hslab->span_lst) { - if(new_space->select.sel_info.hslab->span_lst->head) + if (ret_value < 0 && new_space->select.sel_info.hslab->span_lst) { + if (new_space->select.sel_info.hslab->span_lst->head) H5S__hyper_free_span(new_space->select.sel_info.hslab->span_lst->head); - new_space->select.sel_info.hslab->span_lst = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, new_space->select.sel_info.hslab->span_lst); + new_space->select.sel_info.hslab->span_lst = + (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, new_space->select.sel_info.hslab->span_lst); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_simple_higher() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple * @@ -6767,10 +6748,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, - hsize_t *offset) +H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6780,11 +6760,11 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, HDassert(offset); /* We are setting a new selection, remove any current selection in new dataspace */ - if(H5S_SELECT_RELEASE(new_space) < 0) + if (H5S_SELECT_RELEASE(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Allocate space for the hyperslab selection information */ - if(NULL == (new_space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) + if (NULL == (new_space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info") /* Set unlim_dim */ @@ -6792,25 +6772,26 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(base_space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - unsigned base_space_dim; /* Current dimension in the base dataspace */ - unsigned new_space_dim; /* Current dimension in the new dataspace */ - unsigned u; /* Local index variable */ + if (base_space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + unsigned base_space_dim; /* Current dimension in the base dataspace */ + unsigned new_space_dim; /* Current dimension in the new dataspace */ + unsigned u; /* Local index variable */ /* Check if the new space's rank is < or > base space's rank */ - if(new_space->extent.rank < base_space->extent.rank) { - const H5S_hyper_dim_t *opt_diminfo = base_space->select.sel_info.hslab->diminfo.opt; /* Alias for dataspace's diminfo information */ - hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ + if (new_space->extent.rank < base_space->extent.rank) { + const H5S_hyper_dim_t *opt_diminfo = base_space->select.sel_info.hslab->diminfo + .opt; /* Alias for dataspace's diminfo information */ + hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ /* Compute the offset for the down-projection */ HDmemset(block, 0, sizeof(block)); - for(u = 0; u < (base_space->extent.rank - new_space->extent.rank); u++) + for (u = 0; u < (base_space->extent.rank - new_space->extent.rank); u++) block[u] = opt_diminfo[u].start; *offset = H5VM_array_offset(base_space->extent.rank, base_space->extent.size, block); /* Set the correct dimensions for the base & new spaces */ base_space_dim = base_space->extent.rank - new_space->extent.rank; - new_space_dim = 0; + new_space_dim = 0; } /* end if */ else { HDassert(new_space->extent.rank > base_space->extent.rank); @@ -6819,16 +6800,17 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, *offset = 0; /* Set the diminfo information for the higher dimensions */ - for(new_space_dim = 0; new_space_dim < (new_space->extent.rank - base_space->extent.rank); new_space_dim++) { - new_space->select.sel_info.hslab->diminfo.app[new_space_dim].start = 0; + for (new_space_dim = 0; new_space_dim < (new_space->extent.rank - base_space->extent.rank); + new_space_dim++) { + new_space->select.sel_info.hslab->diminfo.app[new_space_dim].start = 0; new_space->select.sel_info.hslab->diminfo.app[new_space_dim].stride = 1; - new_space->select.sel_info.hslab->diminfo.app[new_space_dim].count = 1; - new_space->select.sel_info.hslab->diminfo.app[new_space_dim].block = 1; + new_space->select.sel_info.hslab->diminfo.app[new_space_dim].count = 1; + new_space->select.sel_info.hslab->diminfo.app[new_space_dim].block = 1; - new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].start = 0; + new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].start = 0; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].stride = 1; - new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].count = 1; - new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].block = 1; + new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].count = 1; + new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].block = 1; } /* end for */ /* Start at beginning of base space's dimension info */ @@ -6836,24 +6818,24 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, } /* end else */ /* Copy the diminfo */ - while(base_space_dim < base_space->extent.rank) { + while (base_space_dim < base_space->extent.rank) { new_space->select.sel_info.hslab->diminfo.app[new_space_dim].start = - base_space->select.sel_info.hslab->diminfo.app[base_space_dim].start; + base_space->select.sel_info.hslab->diminfo.app[base_space_dim].start; new_space->select.sel_info.hslab->diminfo.app[new_space_dim].stride = - base_space->select.sel_info.hslab->diminfo.app[base_space_dim].stride; + base_space->select.sel_info.hslab->diminfo.app[base_space_dim].stride; new_space->select.sel_info.hslab->diminfo.app[new_space_dim].count = - base_space->select.sel_info.hslab->diminfo.app[base_space_dim].count; + base_space->select.sel_info.hslab->diminfo.app[base_space_dim].count; new_space->select.sel_info.hslab->diminfo.app[new_space_dim].block = - base_space->select.sel_info.hslab->diminfo.app[base_space_dim].block; + base_space->select.sel_info.hslab->diminfo.app[base_space_dim].block; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].start = - base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].start; + base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].start; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].stride = - base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].stride; + base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].stride; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].count = - base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].count; + base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].count; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].block = - base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].block; + base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].block; /* Advance to next dimensions */ base_space_dim++; @@ -6861,9 +6843,14 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, } /* end for */ /* Update the bounding box */ - for(u = 0; u < new_space->extent.rank; u++) { - new_space->select.sel_info.hslab->diminfo.low_bounds[u] = new_space->select.sel_info.hslab->diminfo.opt[u].start; - new_space->select.sel_info.hslab->diminfo.high_bounds[u] = new_space->select.sel_info.hslab->diminfo.low_bounds[u] + new_space->select.sel_info.hslab->diminfo.opt[u].stride * (new_space->select.sel_info.hslab->diminfo.opt[u].count - 1) + (new_space->select.sel_info.hslab->diminfo.opt[u].block - 1); + for (u = 0; u < new_space->extent.rank; u++) { + new_space->select.sel_info.hslab->diminfo.low_bounds[u] = + new_space->select.sel_info.hslab->diminfo.opt[u].start; + new_space->select.sel_info.hslab->diminfo.high_bounds[u] = + new_space->select.sel_info.hslab->diminfo.low_bounds[u] + + new_space->select.sel_info.hslab->diminfo.opt[u].stride * + (new_space->select.sel_info.hslab->diminfo.opt[u].count - 1) + + (new_space->select.sel_info.hslab->diminfo.opt[u].block - 1); } /* end for */ /* Indicate that the dimension information is valid */ @@ -6874,18 +6861,18 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, } /* end if */ else { /* Check if the new space's rank is < or > base space's rank */ - if(new_space->extent.rank < base_space->extent.rank) { - const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ - unsigned curr_dim; /* Current dimension being operated on */ + if (new_space->extent.rank < base_space->extent.rank) { + const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ + hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ + unsigned curr_dim; /* Current dimension being operated on */ /* Clear the block buffer */ HDmemset(block, 0, sizeof(block)); /* Advance down selected spans */ - curr = base_space->select.sel_info.hslab->span_lst->head; + curr = base_space->select.sel_info.hslab->span_lst->head; curr_dim = 0; - while(curr && curr_dim < (base_space->extent.rank - new_space->extent.rank)) { + while (curr && curr_dim < (base_space->extent.rank - new_space->extent.rank)) { /* Save the location of the selection in current dimension */ block[curr_dim] = curr->low; @@ -6898,8 +6885,9 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, *offset = H5VM_array_offset(base_space->extent.rank, base_space->extent.size, block); /* Project the base space's selection down in less dimensions */ - if(H5S__hyper_project_simple_lower(base_space, new_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't project hyperslab selection into less dimensions") + if (H5S__hyper_project_simple_lower(base_space, new_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, + "can't project hyperslab selection into less dimensions") } /* end if */ else { HDassert(new_space->extent.rank > base_space->extent.rank); @@ -6908,8 +6896,9 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, *offset = 0; /* Project the base space's selection down in more dimensions */ - if(H5S__hyper_project_simple_higher(base_space, new_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't project hyperslab selection into less dimensions") + if (H5S__hyper_project_simple_higher(base_space, new_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, + "can't project hyperslab selection into less dimensions") } /* end else */ /* Copy the status of the dimension information */ @@ -6926,7 +6915,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_s_helper @@ -6949,8 +6937,8 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static void -H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, - const hssize_t *offset, unsigned op_info_i, uint64_t op_gen) +H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, const hssize_t *offset, + unsigned op_info_i, uint64_t op_gen) { FUNC_ENTER_STATIC_NOERR @@ -6959,27 +6947,27 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, HDassert(offset); /* Check if we've already set this span tree */ - if(spans->op_info[op_info_i].op_gen != op_gen) { - H5S_hyper_span_t *span; /* Pointer to current span in span tree */ - unsigned u; /* Local index variable */ + if (spans->op_info[op_info_i].op_gen != op_gen) { + H5S_hyper_span_t *span; /* Pointer to current span in span tree */ + unsigned u; /* Local index variable */ /* Adjust the span tree's low & high bounds */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { HDassert((hssize_t)spans->low_bounds[u] >= offset[u]); - spans->low_bounds[u] = (hsize_t)((hssize_t)spans->low_bounds[u] - offset[u]); + spans->low_bounds[u] = (hsize_t)((hssize_t)spans->low_bounds[u] - offset[u]); spans->high_bounds[u] = (hsize_t)((hssize_t)spans->high_bounds[u] - offset[u]); } /* end for */ /* Iterate over the spans in tree */ span = spans->head; - while(span != NULL) { + while (span != NULL) { /* Adjust span offset */ HDassert((hssize_t)span->low >= *offset); - span->low = (hsize_t)((hssize_t)span->low - *offset); + span->low = (hsize_t)((hssize_t)span->low - *offset); span->high = (hsize_t)((hssize_t)span->high - *offset); /* Recursively adjust spans in next dimension down */ - if(span->down != NULL) + if (span->down != NULL) H5S__hyper_adjust_s_helper(span->down, rank - 1, offset + 1, op_info_i, op_gen); /* Advance to next span in this dimension */ @@ -6993,7 +6981,6 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_adjust_s_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_s @@ -7015,9 +7002,9 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, static herr_t H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset) { - hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7026,31 +7013,34 @@ H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset) HDassert(offset); /* Check for an all-zero offset vector */ - for(u = 0; u < space->extent.rank; u++) - if(0 != offset[u]) { + for (u = 0; u < space->extent.rank; u++) + if (0 != offset[u]) { non_zero_offset = TRUE; break; } /* end if */ /* Only perform operation if the offset is non-zero */ - if(non_zero_offset) { + if (non_zero_offset) { /* Subtract the offset from the "regular" coordinates, if they exist */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < space->extent.rank; u++) { + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + for (u = 0; u < space->extent.rank; u++) { HDassert((hssize_t)space->select.sel_info.hslab->diminfo.opt[u].start >= offset[u]); - space->select.sel_info.hslab->diminfo.opt[u].start = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.opt[u].start - offset[u]); + space->select.sel_info.hslab->diminfo.opt[u].start = + (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.opt[u].start - offset[u]); /* Adjust the low & high bounds */ HDassert((hssize_t)space->select.sel_info.hslab->diminfo.low_bounds[u] >= offset[u]); - space->select.sel_info.hslab->diminfo.low_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.low_bounds[u] - offset[u]); - space->select.sel_info.hslab->diminfo.high_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.high_bounds[u] - offset[u]); + space->select.sel_info.hslab->diminfo.low_bounds[u] = + (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.low_bounds[u] - offset[u]); + space->select.sel_info.hslab->diminfo.high_bounds[u] = + (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.high_bounds[u] - offset[u]); } /* end for */ - } /* end if */ + } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ - if(space->select.sel_info.hslab->span_lst) { - uint64_t op_gen; /* Operation generation value */ + if (space->select.sel_info.hslab->span_lst) { + uint64_t op_gen; /* Operation generation value */ /* Acquire an operation generation value for this operation */ op_gen = H5S__hyper_get_op_gen(); @@ -7058,7 +7048,8 @@ H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset) /* Perform the adjustment */ /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ - H5S__hyper_adjust_s_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, op_gen); + H5S__hyper_adjust_s_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, + op_gen); } /* end if */ } @@ -7066,7 +7057,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_adjust_s() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_normalize_offset @@ -7091,7 +7081,7 @@ done: htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset) { - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7100,17 +7090,17 @@ H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset) HDassert(old_offset); /* Check for hyperslab selection & offset changed */ - if(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS && space->select.offset_changed) { - unsigned u; /* Local index variable */ + if (H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS && space->select.offset_changed) { + unsigned u; /* Local index variable */ /* Copy & invert the selection offset */ - for(u = 0; u < space->extent.rank; u++) { - old_offset[u] = space->select.offset[u]; + for (u = 0; u < space->extent.rank; u++) { + old_offset[u] = space->select.offset[u]; space->select.offset[u] = -space->select.offset[u]; } /* end for */ /* Call the 'adjust' routine */ - if(H5S__hyper_adjust_s(space, space->select.offset) < 0) + if (H5S__hyper_adjust_s(space, space->select.offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust selection") /* Zero out the selection offset */ @@ -7124,7 +7114,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_normalize_offset() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_denormalize_offset @@ -7149,7 +7138,7 @@ done: herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7158,7 +7147,7 @@ H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset) HDassert(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS); /* Call the 'adjust' routine */ - if(H5S__hyper_adjust_s(space, old_offset) < 0) + if (H5S__hyper_adjust_s(space, old_offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust selection") /* Copy the selection offset over */ @@ -7168,7 +7157,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_denormalize_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_append_span @@ -7191,11 +7179,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, - hsize_t low, hsize_t high, H5S_hyper_span_info_t *down) +H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, hsize_t low, hsize_t high, + H5S_hyper_span_info_t *down) { - H5S_hyper_span_t *new_span = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_t *new_span = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7203,40 +7191,40 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, HDassert(span_tree); /* Check for adding first node to merged spans */ - if(*span_tree == NULL) { + if (*span_tree == NULL) { /* Allocate new span node to append to list */ - if(NULL == (new_span = H5S__hyper_new_span(low, high, down, NULL))) + if (NULL == (new_span = H5S__hyper_new_span(low, high, down, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Make new span the first node in span list */ /* Allocate a new span_info node */ - if(NULL == (*span_tree = H5S__hyper_new_span_info(ndims))) + if (NULL == (*span_tree = H5S__hyper_new_span_info(ndims))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Set the span tree's basic information */ (*span_tree)->count = 1; - (*span_tree)->head = new_span; - (*span_tree)->tail = new_span; + (*span_tree)->head = new_span; + (*span_tree)->tail = new_span; /* Set low & high bounds for new span tree */ - (*span_tree)->low_bounds[0] = low; + (*span_tree)->low_bounds[0] = low; (*span_tree)->high_bounds[0] = high; - if(down) { + if (down) { /* Sanity check */ HDassert(ndims > 1); H5MM_memcpy(&((*span_tree)->low_bounds[1]), down->low_bounds, sizeof(hsize_t) * (ndims - 1)); H5MM_memcpy(&((*span_tree)->high_bounds[1]), down->high_bounds, sizeof(hsize_t) * (ndims - 1)); } /* end if */ - } /* end if */ + } /* end if */ /* Merge or append to existing merged spans list */ else { - htri_t down_cmp = (-1); /* Comparison value for down spans */ + htri_t down_cmp = (-1); /* Comparison value for down spans */ /* Check if span can just extend the previous merged span */ - if((((*span_tree)->tail->high + 1) == low) && - (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) { + if ((((*span_tree)->tail->high + 1) == low) && + (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) { /* Extend previous merged span to include new high bound */ (*span_tree)->tail->high = high; @@ -7245,17 +7233,17 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, (*span_tree)->high_bounds[0] = high; } /* end if */ else { - H5S_hyper_span_info_t *new_down; /* Down pointer for new span node */ + H5S_hyper_span_info_t *new_down; /* Down pointer for new span node */ /* Sanity check */ /* (If down_cmp was set to TRUE above, we won't be in this branch) */ HDassert(down_cmp != TRUE); /* Check if there is actually a down span */ - if(down) { + if (down) { /* Check if the down spans for the new span node are the same as the previous span node */ /* (Uses the 'down span comparison' from earlier, if already computed) */ - if(down_cmp < 0 && (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) + if (down_cmp < 0 && (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) /* Share the previous span's down span tree */ new_down = (*span_tree)->tail->down; else @@ -7265,48 +7253,47 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, new_down = NULL; /* Allocate new span node to append to list */ - if(NULL == (new_span = H5S__hyper_new_span(low, high, new_down, NULL))) + if (NULL == (new_span = H5S__hyper_new_span(low, high, new_down, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Update the high bounds for current dimension */ (*span_tree)->high_bounds[0] = high; /* Update low & high bounds in lower dimensions, if there are any */ - if(down) { + if (down) { /* Sanity checks */ HDassert(ndims > 1); HDassert(down_cmp >= 0); /* Check if we are sharing down spans with a previous node */ /* (Only need to check for bounds changing if down spans aren't shared) */ - if(down_cmp == FALSE) { - unsigned u; /* Local index variable */ + if (down_cmp == FALSE) { + unsigned u; /* Local index variable */ /* Loop over lower dimensions, checking & updating low & high bounds */ - for(u = 0; u < (ndims - 1); u++) { - if(down->low_bounds[u] < (*span_tree)->low_bounds[u + 1]) + for (u = 0; u < (ndims - 1); u++) { + if (down->low_bounds[u] < (*span_tree)->low_bounds[u + 1]) (*span_tree)->low_bounds[u + 1] = down->low_bounds[u]; - if(down->high_bounds[u] > (*span_tree)->high_bounds[u + 1]) + if (down->high_bounds[u] > (*span_tree)->high_bounds[u + 1]) (*span_tree)->high_bounds[u + 1] = down->high_bounds[u]; } /* end for */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Append to end of merged spans list */ (*span_tree)->tail->next = new_span; - (*span_tree)->tail = new_span; + (*span_tree)->tail = new_span; } /* end else */ - } /* end else */ + } /* end else */ done: - if(ret_value < 0) - if(new_span) + if (ret_value < 0) + if (new_span) H5S__hyper_free_span(new_span); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_append_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_clip_spans @@ -7348,15 +7335,14 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, - unsigned selector, unsigned ndims, - H5S_hyper_span_info_t **a_not_b, H5S_hyper_span_info_t **a_and_b, - H5S_hyper_span_info_t **b_not_a) +H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, unsigned selector, + unsigned ndims, H5S_hyper_span_info_t **a_not_b, H5S_hyper_span_info_t **a_and_b, + H5S_hyper_span_info_t **b_not_a) { - hbool_t need_a_not_b; /* Whether to generate a_not_b list */ - hbool_t need_a_and_b; /* Whether to generate a_and_b list */ - hbool_t need_b_not_a; /* Whether to generate b_not_a list */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t need_a_not_b; /* Whether to generate a_not_b list */ + hbool_t need_a_and_b; /* Whether to generate a_and_b list */ + hbool_t need_b_not_a; /* Whether to generate b_not_a list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7373,28 +7359,28 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s need_b_not_a = ((selector & H5S_HYPER_COMPUTE_B_NOT_A) != 0); /* Check if both span trees are not defined */ - if(a_spans == NULL && b_spans == NULL) { + if (a_spans == NULL && b_spans == NULL) { *a_not_b = NULL; *a_and_b = NULL; *b_not_a = NULL; } /* end if */ /* If span 'a' is not defined, but 'b' is, copy 'b' and set the other return span trees to empty */ - else if(a_spans == NULL) { + else if (a_spans == NULL) { *a_not_b = NULL; *a_and_b = NULL; - if(need_b_not_a) { - if(NULL == (*b_not_a = H5S__hyper_copy_span(b_spans, ndims))) + if (need_b_not_a) { + if (NULL == (*b_not_a = H5S__hyper_copy_span(b_spans, ndims))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree") } /* end if */ else *b_not_a = NULL; } /* end if */ /* If span 'b' is not defined, but 'a' is, copy 'a' and set the other return span trees to empty */ - else if(b_spans == NULL) { + else if (b_spans == NULL) { *a_and_b = NULL; *b_not_a = NULL; - if(need_a_not_b) { - if(NULL == (*a_not_b = H5S__hyper_copy_span(a_spans, ndims))) + if (need_a_not_b) { + if (NULL == (*a_not_b = H5S__hyper_copy_span(a_spans, ndims))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree") } /* end if */ else @@ -7403,20 +7389,20 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* If span 'a' and 'b' are both defined, calculate the proper span trees */ else { /* Check if both span trees completely overlap */ - if(H5S__hyper_cmp_spans(a_spans, b_spans)) { + if (H5S__hyper_cmp_spans(a_spans, b_spans)) { *a_not_b = NULL; *b_not_a = NULL; - if(need_a_and_b) { - if(NULL == (*a_and_b = H5S__hyper_copy_span(a_spans, ndims))) + if (need_a_and_b) { + if (NULL == (*a_and_b = H5S__hyper_copy_span(a_spans, ndims))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree") } /* end if */ else *a_and_b = NULL; } /* end if */ else { - H5S_hyper_span_t *span_a; /* Pointer to a node in span tree 'a' */ - H5S_hyper_span_t *span_b; /* Pointer to a node in span tree 'b' */ - hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ + H5S_hyper_span_t *span_a; /* Pointer to a node in span tree 'a' */ + H5S_hyper_span_t *span_b; /* Pointer to a node in span tree 'b' */ + hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ /* Get the pointers to the new and old span lists */ span_a = a_spans->head; @@ -7426,22 +7412,26 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s recover_a = recover_b = FALSE; /* Work through the list of spans in the new list */ - while(span_a != NULL && span_b != NULL) { - H5S_hyper_span_info_t *down_a_not_b; /* Temporary pointer to a_not_b span tree of down spans for overlapping nodes */ - H5S_hyper_span_info_t *down_a_and_b; /* Temporary pointer to a_and_b span tree of down spans for overlapping nodes */ - H5S_hyper_span_info_t *down_b_not_a; /* Temporary pointer to b_and_a span tree of down spans for overlapping nodes */ - H5S_hyper_span_t *tmp_span; /* Temporary pointer to new span */ + while (span_a != NULL && span_b != NULL) { + H5S_hyper_span_info_t *down_a_not_b; /* Temporary pointer to a_not_b span tree of down spans + for overlapping nodes */ + H5S_hyper_span_info_t *down_a_and_b; /* Temporary pointer to a_and_b span tree of down spans + for overlapping nodes */ + H5S_hyper_span_info_t *down_b_not_a; /* Temporary pointer to b_and_a span tree of down spans + for overlapping nodes */ + H5S_hyper_span_t *tmp_span; /* Temporary pointer to new span */ /* Check if span 'a' is completely before span 'b' */ /* AAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - if(span_a->high < span_b->low) { + if (span_a->high < span_b->low) { /* Copy span 'a' and add to a_not_b list */ /* Merge/add span 'a' with/to a_not_b list */ - if(need_a_not_b) - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (need_a_not_b) + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance span 'a', leave span 'b' */ @@ -7452,27 +7442,32 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* AAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low < span_b->low && (span_a->high >= span_b->low && span_a->high <= span_b->high)) { + else if (span_a->low < span_b->low && + (span_a->high >= span_b->low && span_a->high <= span_b->high)) { /* Split span 'a' into two parts at the low bound of span 'b' */ /* Merge/add lower part of span 'a' with/to a_not_b list */ - if(need_a_not_b) - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, span_a->down) < 0) + if (need_a_not_b) + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Check for overlaps between upper part of span 'a' and lower part of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ - HDassert((span_a->down != NULL && span_b->down != NULL) || (span_a->down == NULL && span_b->down == NULL)); + HDassert((span_a->down != NULL && span_b->down != NULL) || + (span_a->down == NULL && span_b->down == NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ - if(span_a->down == NULL) { + if (span_a->down == NULL) { /* Merge/add overlapped part with/to a_and_b list */ - if(need_a_and_b) - if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_a_and_b) + if (H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ - /* If there are down spans, check for the overlap in them and add to each appropriate list */ + /* If there are down spans, check for the overlap in them and add to each appropriate list + */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b = NULL; @@ -7484,52 +7479,60 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s * has been updated in the following clip function (via * all_clips_bounds), there's no need updating the bound box * after each append call in the following codes */ - if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) + if (H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, + &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") /* Check for additions to the a_not_b list */ - if(down_a_not_b) { + if (down_a_not_b) { HDassert(need_a_not_b == TRUE); /* Merge/add overlapped part with/to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_a->high, down_a_not_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_a->high, + down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ - if(down_a_and_b) { + if (down_a_and_b) { HDassert(need_a_and_b == TRUE); /* Merge/add overlapped part with/to a_and_b list */ - if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, down_a_and_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, + down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ - if(down_b_not_a) { + if (down_b_not_a) { HDassert(need_b_not_a == TRUE); /* Merge/add overlapped part with/to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->high, down_b_not_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->high, + down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_b_not_a); } /* end if */ - } /* end else */ + } /* end else */ /* Split off upper part of span 'b' at upper span of span 'a' */ /* Check if there is actually an upper part of span 'b' to split off */ - if(span_a->high < span_b->high) { + if (span_a->high < span_b->high) { /* Allocate new span node for upper part of span 'b' */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, + span_b->down, span_b->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span") /* Advance span 'a' */ @@ -7545,33 +7548,37 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end if */ + } /* end if */ /* Check if span 'a' overlaps the lower & upper bound */ /* of span 'b' */ /* AAAAAAAAAAAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low < span_b->low && span_a->high > span_b->high) { + else if (span_a->low < span_b->low && span_a->high > span_b->high) { /* Split off lower part of span 'a' at lower span of span 'b' */ /* Merge/add lower part of span 'a' with/to a_not_b list */ - if(need_a_not_b) - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, span_a->down) < 0) + if (need_a_not_b) + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Check for overlaps between middle part of span 'a' and span 'b' */ /* Make certain both spans either have a down span or both don't have one */ - HDassert((span_a->down != NULL && span_b->down != NULL) || (span_a->down == NULL && span_b->down == NULL)); + HDassert((span_a->down != NULL && span_b->down != NULL) || + (span_a->down == NULL && span_b->down == NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ - if(span_a->down == NULL) { + if (span_a->down == NULL) { /* Merge/add overlapped part with/to a_and_b list */ - if(need_a_and_b) - if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_a_and_b) + if (H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ - /* If there are down spans, check for the overlap in them and add to each appropriate list */ + /* If there are down spans, check for the overlap in them and add to each appropriate list + */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b = NULL; @@ -7579,50 +7586,58 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s down_b_not_a = NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ - if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) + if (H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, + &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") /* Check for additions to the a_not_b list */ - if(down_a_not_b) { + if (down_a_not_b) { HDassert(need_a_not_b == TRUE); /* Merge/add overlapped part with/to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_b->high, down_a_not_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_b->high, + down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ - if(down_a_and_b) { + if (down_a_and_b) { HDassert(need_a_and_b == TRUE); /* Merge/add overlapped part with/to a_and_b list */ - if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, down_a_and_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, + down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ - if(down_b_not_a) { + if (down_b_not_a) { HDassert(need_b_not_a == TRUE); /* Merge/add overlapped part with/to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, down_b_not_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, + down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_b_not_a); } /* end if */ - } /* end else */ + } /* end else */ /* Split off upper part of span 'a' at upper span of span 'b' */ /* Allocate new span node for upper part of span 'a' */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, span_a->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, + span_a->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span") /* Make upper part of span 'a' the new span 'a' */ @@ -7636,15 +7651,17 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* AAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low >= span_b->low && span_a->high <= span_b->high) { + else if (span_a->low >= span_b->low && span_a->high <= span_b->high) { /* Split off lower part of span 'b' at lower span of span 'a' */ /* Check if there is actually a lower part of span 'b' to split off */ - if(span_a->low > span_b->low) { + if (span_a->low > span_b->low) { /* Merge/add lower part of span 'b' with/to b_not_a list */ - if(need_b_not_a) - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, span_b->down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_b_not_a) + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, + span_b->down) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ else { /* Keep going, nothing to split off */ @@ -7653,16 +7670,19 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* Check for overlaps between span 'a' and midle of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ - HDassert((span_a->down != NULL && span_b->down != NULL) || (span_a->down == NULL && span_b->down == NULL)); + HDassert((span_a->down != NULL && span_b->down != NULL) || + (span_a->down == NULL && span_b->down == NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ - if(span_a->down == NULL) { + if (span_a->down == NULL) { /* Merge/add overlapped part with/to a_and_b list */ - if(need_a_and_b) - if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_a_and_b) + if (H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ - /* If there are down spans, check for the overlap in them and add to each appropriate list */ + /* If there are down spans, check for the overlap in them and add to each appropriate list + */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b = NULL; @@ -7670,52 +7690,60 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s down_b_not_a = NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ - if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) + if (H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, + &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") /* Check for additions to the a_not_b list */ - if(down_a_not_b) { + if (down_a_not_b) { HDassert(need_a_not_b == TRUE); /* Merge/add overlapped part with/to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, down_a_not_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, + down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ - if(down_a_and_b) { + if (down_a_and_b) { HDassert(need_a_and_b == TRUE); /* Merge/add overlapped part with/to a_and_b list */ - if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, down_a_and_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, + down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ - if(down_b_not_a) { + if (down_b_not_a) { HDassert(need_b_not_a == TRUE); /* Merge/add overlapped part with/to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_a->high, down_b_not_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_a->high, + down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_b_not_a); } /* end if */ - } /* end else */ + } /* end else */ /* Check if there is actually an upper part of span 'b' to split off */ - if(span_a->high < span_b->high) { + if (span_a->high < span_b->high) { /* Split off upper part of span 'b' at upper span of span 'a' */ /* Allocate new span node for upper part of spans 'a' */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, + span_b->down, span_b->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* And advance span 'a' */ @@ -7730,21 +7758,24 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end if */ + } /* end if */ /* Check if span 'a' overlaps only the upper bound */ /* of span 'b' */ /* AAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if((span_a->low >= span_b->low && span_a->low <= span_b->high) && span_a->high > span_b->high) { + else if ((span_a->low >= span_b->low && span_a->low <= span_b->high) && + span_a->high > span_b->high) { /* Check if there is actually a lower part of span 'b' to split off */ - if(span_a->low > span_b->low) { + if (span_a->low > span_b->low) { /* Split off lower part of span 'b' at lower span of span 'a' */ /* Merge/add lower part of span 'b' with/to b_not_a list */ - if(need_b_not_a) - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, span_b->down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_b_not_a) + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, + span_b->down) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ else { /* Keep going, nothing to split off */ @@ -7753,16 +7784,19 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* Check for overlaps between lower part of span 'a' and upper part of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ - HDassert((span_a->down != NULL && span_b->down != NULL) || (span_a->down == NULL && span_b->down == NULL)); + HDassert((span_a->down != NULL && span_b->down != NULL) || + (span_a->down == NULL && span_b->down == NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ - if(span_a->down == NULL) { + if (span_a->down == NULL) { /* Merge/add overlapped part with/to a_and_b list */ - if(need_a_and_b) - if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_a_and_b) + if (H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ - /* If there are down spans, check for the overlap in them and add to each appropriate list */ + /* If there are down spans, check for the overlap in them and add to each appropriate list + */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b = NULL; @@ -7770,50 +7804,58 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s down_b_not_a = NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ - if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) + if (H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, + &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") /* Check for additions to the a_not_b list */ - if(down_a_not_b) { + if (down_a_not_b) { HDassert(need_a_not_b == TRUE); /* Merge/add overlapped part with/to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->high, down_a_not_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->high, + down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ - if(down_a_and_b) { + if (down_a_and_b) { HDassert(need_a_and_b == TRUE); /* Merge/add overlapped part with/to a_and_b list */ - if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, down_a_and_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, + down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ - if(down_b_not_a) { + if (down_b_not_a) { HDassert(need_b_not_a == TRUE); /* Merge/add overlapped part with/to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_b->high, down_b_not_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_b->high, + down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_b_not_a); } /* end if */ - } /* end else */ + } /* end else */ /* Split off upper part of span 'a' at upper span of span 'b' */ /* Allocate new span node for upper part of span 'a' */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, span_a->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, + span_a->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Make upper part of span 'a' into new span 'a' */ @@ -7831,19 +7873,20 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* Copy span 'b' and add to b_not_a list */ /* Merge/add span 'b' with/to b_not_a list */ - if(need_b_not_a) - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (need_b_not_a) + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance span 'b', leave span 'a' */ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end while */ + } /* end while */ /* Clean up 'a' spans which haven't been covered yet */ - if(span_a != NULL && span_b == NULL) { + if (span_a != NULL && span_b == NULL) { /* Check if need to merge/add 'a' spans with/to a_not_b list */ - if(need_a_not_b) { + if (need_a_not_b) { /* (This loop, and the similar one below for 'b' spans, * could be replaced with an optimized routine that quickly * appended the remaining spans to the 'not' list, but @@ -7851,25 +7894,26 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s * important use case, it's been left generic, and similar * to other code above. -QAK, 2019/02/01) */ - while(span_a != NULL) { + while (span_a != NULL) { /* Copy span 'a' and add to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance to the next 'a' span */ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); } /* end while */ - } /* end if */ + } /* end if */ else { /* Free the span, if it's generated */ - if(recover_a) + if (recover_a) H5S__hyper_free_span(span_a); } /* end else */ - } /* end if */ + } /* end if */ /* Clean up 'b' spans which haven't been covered yet */ - else if(span_a == NULL && span_b != NULL) { + else if (span_a == NULL && span_b != NULL) { /* Check if need to merge/add 'b' spans with/to b_not_a list */ - if(need_b_not_a) { + if (need_b_not_a) { /* (This loop, and the similar one above for 'a' spans, * could be replaced with an optimized routine that quickly * appended the remaining spans to the 'not' list, but @@ -7877,32 +7921,32 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s * important use case, it's been left generic, and similar * to other code above. -QAK, 2019/02/01) */ - while(span_b != NULL) { + while (span_b != NULL) { /* Copy span 'b' and add to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance to the next 'b' span */ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end while */ - } /* end if */ + } /* end if */ else { /* Free the span, if it's generated */ - if(recover_b) + if (recover_b) H5S__hyper_free_span(span_b); } /* end else */ - } /* end if */ + } /* end if */ else /* Sanity check */ HDassert(span_a == NULL && span_b == NULL); } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_clip_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_merge_spans_helper @@ -7927,11 +7971,10 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * -H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, - unsigned ndims) +H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, unsigned ndims) { H5S_hyper_span_info_t *merged_spans = NULL; /* Pointer to the merged span tree */ - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -7939,19 +7982,19 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HDassert((a_spans != NULL && b_spans != NULL) || (a_spans == NULL && b_spans == NULL)); /* Check if the span trees for the 'a' span and the 'b' span are the same */ - if(H5S__hyper_cmp_spans(a_spans, b_spans)) { - if(a_spans == NULL) + if (H5S__hyper_cmp_spans(a_spans, b_spans)) { + if (a_spans == NULL) merged_spans = NULL; else { /* Copy one of the span trees to return */ - if(NULL == (merged_spans = H5S__hyper_copy_span(a_spans, ndims))) + if (NULL == (merged_spans = H5S__hyper_copy_span(a_spans, ndims))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "can't copy hyperslab span tree") } /* end else */ - } /* end if */ + } /* end if */ else { - H5S_hyper_span_t *span_a; /* Pointer to current span 'a' working on */ - H5S_hyper_span_t *span_b; /* Pointer to current span 'b' working on */ - hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ + H5S_hyper_span_t *span_a; /* Pointer to current span 'a' working on */ + H5S_hyper_span_t *span_b; /* Pointer to current span 'b' working on */ + hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ /* Get the pointers to the 'a' and 'b' span lists */ span_a = a_spans->head; @@ -7961,17 +8004,17 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf recover_a = recover_b = FALSE; /* Work through the list of spans in the new list */ - while(span_a != NULL && span_b != NULL) { - H5S_hyper_span_info_t *tmp_spans; /* Pointer to temporary new span tree */ - H5S_hyper_span_t *tmp_span; /* Pointer to temporary new span */ + while (span_a != NULL && span_b != NULL) { + H5S_hyper_span_info_t *tmp_spans; /* Pointer to temporary new span tree */ + H5S_hyper_span_t * tmp_span; /* Pointer to temporary new span */ /* Check if the 'a' span is completely before 'b' span */ /* AAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - if(span_a->high < span_b->low) { + if (span_a->high < span_b->low) { /* Merge/add span 'a' with/to the merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ @@ -7982,23 +8025,27 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* AAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low < span_b->low && (span_a->high >= span_b->low && span_a->high <= span_b->high)) { + else if (span_a->low < span_b->low && + (span_a->high >= span_b->low && span_a->high <= span_b->high)) { /* Check if span 'a' and span 'b' down spans are equal */ - if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) { + if (H5S__hyper_cmp_spans(span_a->down, span_b->down)) { /* Merge/add copy of span 'a' with/to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { /* Merge/add lower part of span 'a' with/to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Get merged span tree for overlapped section */ tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1); /* Merge/add overlapped section to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, tmp_spans) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, tmp_spans) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ @@ -8006,11 +8053,12 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf } /* end else */ /* Check if there is an upper part of span 'b' */ - if(span_a->high < span_b->high) { + if (span_a->high < span_b->high) { /* Copy upper part of span 'b' as new span 'b' */ /* Allocate new span node to append to list */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, + span_b->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ @@ -8025,29 +8073,32 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end if */ + } /* end if */ /* Check if span 'a' overlaps the lower & upper bound */ /* of span 'b' */ /* AAAAAAAAAAAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low < span_b->low && span_a->high > span_b->high) { + else if (span_a->low < span_b->low && span_a->high > span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ - if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) { + if (H5S__hyper_cmp_spans(span_a->down, span_b->down)) { /* Merge/add copy of lower & middle parts of span 'a' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { /* Merge/add lower part of span 'a' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Get merged span tree for overlapped section */ tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1); /* Merge/add overlapped section to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, tmp_spans) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, tmp_spans) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ @@ -8057,7 +8108,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* Copy upper part of span 'a' as new span 'a' (remember to free) */ /* Allocate new span node to append to list */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, span_a->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, + span_a->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set new span 'a' to tmp_span */ @@ -8071,18 +8123,20 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* AAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low >= span_b->low && span_a->high <= span_b->high) { + else if (span_a->low >= span_b->low && span_a->high <= span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ - if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) { + if (H5S__hyper_cmp_spans(span_a->down, span_b->down)) { /* Merge/add copy of lower & middle parts of span 'b' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { /* Check if there is a lower part of span 'b' */ - if(span_a->low > span_b->low) { + if (span_a->low > span_b->low) { /* Merge/add lower part of span 'b' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, + span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { @@ -8093,7 +8147,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1); /* Merge/add overlapped section to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, tmp_spans) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, tmp_spans) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ @@ -8101,11 +8156,12 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf } /* end else */ /* Check if there is an upper part of span 'b' */ - if(span_a->high < span_b->high) { + if (span_a->high < span_b->high) { /* Copy upper part of span 'b' as new span 'b' (remember to free) */ /* Allocate new span node to append to list */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, + span_b->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ @@ -8120,24 +8176,27 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end if */ + } /* end if */ /* Check if span 'a' overlaps only the upper bound */ /* of span 'b' */ /* AAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if((span_a->low >= span_b->low && span_a->low <= span_b->high) && span_a->high > span_b->high) { + else if ((span_a->low >= span_b->low && span_a->low <= span_b->high) && + span_a->high > span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ - if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) { + if (H5S__hyper_cmp_spans(span_a->down, span_b->down)) { /* Merge/add copy of span 'b' to merged spans if so */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, + span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { /* Check if there is a lower part of span 'b' */ - if(span_a->low > span_b->low) { + if (span_a->low > span_b->low) { /* Merge/add lower part of span 'b' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, + span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { @@ -8148,7 +8207,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1); /* Merge/add overlapped section to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, tmp_spans) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, tmp_spans) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ @@ -8158,7 +8218,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* Copy upper part of span 'a' as new span 'a' */ /* Allocate new span node to append to list */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, span_a->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, + span_a->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set new span 'a' to tmp_span */ @@ -8174,51 +8235,50 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* BBBBBBBBBB */ else { /* Merge/add span 'b' with the merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance span 'b' */ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end while */ + } /* end while */ /* Clean up 'a' spans which haven't been added to the list of merged spans */ - if(span_a != NULL && span_b == NULL) { - while(span_a != NULL) { + if (span_a != NULL && span_b == NULL) { + while (span_a != NULL) { /* Merge/add all 'a' spans into the merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance to next 'a' span, until all processed */ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); } /* end while */ - } /* end if */ + } /* end if */ /* Clean up 'b' spans which haven't been added to the list of merged spans */ - if(span_a == NULL && span_b != NULL) { - while(span_b != NULL) { + if (span_a == NULL && span_b != NULL) { + while (span_b != NULL) { /* Merge/add all 'b' spans into the merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance to next 'b' span, until all processed */ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end while */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Set return value */ ret_value = merged_spans; done: - if(ret_value == NULL) - if(merged_spans) + if (ret_value == NULL) + if (merged_spans) H5S__hyper_free_span_info(merged_spans); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_merge_spans_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_merge_spans @@ -8242,7 +8302,7 @@ done: static herr_t H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8251,7 +8311,7 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) HDassert(new_spans); /* If this is the first span tree in the hyperslab selection, just use it */ - if(space->select.sel_info.hslab->span_lst == NULL) { + if (space->select.sel_info.hslab->span_lst == NULL) { space->select.sel_info.hslab->span_lst = new_spans; space->select.sel_info.hslab->span_lst->count++; } /* end if */ @@ -8259,7 +8319,8 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) H5S_hyper_span_info_t *merged_spans; /* Get the merged spans */ - if(NULL == (merged_spans = H5S__hyper_merge_spans_helper(space->select.sel_info.hslab->span_lst, new_spans, space->extent.rank))) + if (NULL == (merged_spans = H5S__hyper_merge_spans_helper(space->select.sel_info.hslab->span_lst, + new_spans, space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTMERGE, FAIL, "can't merge hyperslab spans") /* Free the previous spans */ @@ -8273,7 +8334,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_merge_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_nelem_helper @@ -8294,10 +8354,9 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static hsize_t -H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, - uint64_t op_gen) +H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, uint64_t op_gen) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8305,25 +8364,25 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, HDassert(spans); /* Check if the span tree was already counted */ - if(spans->op_info[op_info_i].op_gen == op_gen) + if (spans->op_info[op_info_i].op_gen == op_gen) /* Just return the # of elements in the already counted span tree */ ret_value = spans->op_info[op_info_i].u.nelmts; - else { /* Count the number of elements in the span tree */ - const H5S_hyper_span_t *span; /* Hyperslab span */ + else { /* Count the number of elements in the span tree */ + const H5S_hyper_span_t *span; /* Hyperslab span */ span = spans->head; - if(NULL == span->down) { - while(span != NULL) { + if (NULL == span->down) { + while (span != NULL) { /* Compute # of elements covered */ ret_value += (span->high - span->low) + 1; /* Advance to next span */ span = span->next; } /* end while */ - } /* end if */ + } /* end if */ else { - while(span != NULL) { - hsize_t nelmts; /* # of elements covered by current span */ + while (span != NULL) { + hsize_t nelmts; /* # of elements covered by current span */ /* Compute # of elements covered */ nelmts = (span->high - span->low) + 1; @@ -8334,7 +8393,7 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, /* Advance to next span */ span = span->next; } /* end while */ - } /* end else */ + } /* end else */ /* Set the operation generation for this span tree, to avoid re-computing */ spans->op_info[op_info_i].op_gen = op_gen; @@ -8346,7 +8405,6 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_nelem_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_nelem @@ -8367,8 +8425,8 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, static hsize_t H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans) { - uint64_t op_gen; /* Operation generation value */ - hsize_t ret_value = 0; /* Return value */ + uint64_t op_gen; /* Operation generation value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8386,7 +8444,6 @@ H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_nelem() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_add_disjoint_spans @@ -8413,7 +8470,7 @@ H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans) static herr_t H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8425,7 +8482,7 @@ H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) space->select.num_elem += H5S__hyper_spans_nelem(new_spans); /* Add the new spans to the existing selection in the dataspace */ - if(H5S__hyper_merge_spans(space, new_spans) < 0) + if (H5S__hyper_merge_spans(space, new_spans) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't merge hyperslabs") /* Free the memory space for new spans */ @@ -8435,7 +8492,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_add_disjoint_spans */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_make_spans @@ -8462,14 +8518,14 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * -H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride, - const hsize_t *count, const hsize_t *block) +H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride, const hsize_t *count, + const hsize_t *block) { - H5S_hyper_span_info_t *down = NULL; /* Pointer to spans in next dimension down */ - H5S_hyper_span_t *last_span; /* Current position in hyperslab span list */ - H5S_hyper_span_t *head = NULL; /* Head of new hyperslab span list */ - int i; /* Counters */ - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_info_t *down = NULL; /* Pointer to spans in next dimension down */ + H5S_hyper_span_t * last_span; /* Current position in hyperslab span list */ + H5S_hyper_span_t * head = NULL; /* Head of new hyperslab span list */ + int i; /* Counters */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -8481,32 +8537,32 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride HDassert(block); /* Start creating spans in fastest changing dimension */ - for(i = (int)(rank - 1); i >= 0; i--) { - hsize_t curr_low, curr_high; /* Current low & high values */ - hsize_t dim_stride; /* Current dim's stride */ - unsigned u; /* Local index variable */ + for (i = (int)(rank - 1); i >= 0; i--) { + hsize_t curr_low, curr_high; /* Current low & high values */ + hsize_t dim_stride; /* Current dim's stride */ + unsigned u; /* Local index variable */ /* Sanity check */ - if(0 == count[i]) + if (0 == count[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, NULL, "count == 0 is invalid") /* Start a new list in this dimension */ - head = NULL; + head = NULL; last_span = NULL; /* Generate all the span segments for this dimension */ - curr_low = start[i]; - curr_high = start[i] + (block[i] - 1); + curr_low = start[i]; + curr_high = start[i] + (block[i] - 1); dim_stride = stride[i]; - for(u = 0; u < count[i]; u++, curr_low += dim_stride, curr_high += dim_stride) { - H5S_hyper_span_t *span; /* New hyperslab span */ + for (u = 0; u < count[i]; u++, curr_low += dim_stride, curr_high += dim_stride) { + H5S_hyper_span_t *span; /* New hyperslab span */ /* Allocate a span node */ - if(NULL == (span = H5FL_MALLOC(H5S_hyper_span_t))) + if (NULL == (span = H5FL_MALLOC(H5S_hyper_span_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set the span's basic information */ - span->low = curr_low; + span->low = curr_low; span->high = curr_high; span->next = NULL; @@ -8515,7 +8571,7 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride span->down = down; /* Append to the list of spans in this dimension */ - if(head == NULL) + if (head == NULL) head = span; else last_span->next = span; @@ -8525,11 +8581,11 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride } /* end for */ /* Increment ref. count of shared span */ - if(down != NULL) + if (down != NULL) down->count = (unsigned)count[i]; /* Allocate a span info node */ - if(NULL == (down = H5S__hyper_new_span_info(rank))) + if (NULL == (down = H5S__hyper_new_span_info(rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Keep the pointer to the next dimension down's completed list */ @@ -8539,19 +8595,21 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride down->tail = last_span; /* Set the low & high bounds for this dimension */ - down->low_bounds[0] = down->head->low; + down->low_bounds[0] = down->head->low; down->high_bounds[0] = down->tail->high; /* Copy bounds from lower dimensions */ /* (head & tail pointers share lower dimensions, so using either is OK) */ - if(head->down) { - H5MM_memcpy(&down->low_bounds[1], &head->down->low_bounds[0], sizeof(hsize_t) * ((rank - 1) - (unsigned)i)); - H5MM_memcpy(&down->high_bounds[1], &head->down->high_bounds[0], sizeof(hsize_t) * ((rank - 1) - (unsigned)i)); + if (head->down) { + H5MM_memcpy(&down->low_bounds[1], &head->down->low_bounds[0], + sizeof(hsize_t) * ((rank - 1) - (unsigned)i)); + H5MM_memcpy(&down->high_bounds[1], &head->down->high_bounds[0], + sizeof(hsize_t) * ((rank - 1) - (unsigned)i)); } /* end if */ - } /* end for */ + } /* end for */ /* Indicate that there is a pointer to this tree */ - if(down) + if (down) down->count = 1; /* Success! Return the head of the list in the slowest changing dimension */ @@ -8559,32 +8617,31 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride done: /* cleanup if error (ret_value will be NULL) */ - if(!ret_value) { - if(head || down) { - if(head && down) - if(down->head != head) + if (!ret_value) { + if (head || down) { + if (head && down) + if (down->head != head) down = NULL; do { - if(down) { + if (down) { head = down->head; down = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, down); } /* end if */ down = head->down; - while(head) { + while (head) { last_span = head->next; - head = H5FL_FREE(H5S_hyper_span_t, head); - head = last_span; + head = H5FL_FREE(H5S_hyper_span_t, head); + head = last_span; } /* end while */ - } while(down); + } while (down); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_make_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_update_diminfo @@ -8614,10 +8671,9 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, - const H5S_hyper_dim_t *new_hyper_diminfo) +H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, const H5S_hyper_dim_t *new_hyper_diminfo) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8627,182 +8683,180 @@ H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, /* Check for conditions that prevent us from using the fast algorithm here */ /* (and instead require H5S__hyper_rebuild) */ - if(!((op == H5S_SELECT_OR) || (op == H5S_SELECT_XOR)) - || space->select.sel_info.hslab->diminfo_valid != H5S_DIMINFO_VALID_YES - || !space->select.sel_info.hslab->span_lst->head) + if (!((op == H5S_SELECT_OR) || (op == H5S_SELECT_XOR)) || + space->select.sel_info.hslab->diminfo_valid != H5S_DIMINFO_VALID_YES || + !space->select.sel_info.hslab->span_lst->head) space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; else { - H5S_hyper_dim_t tmp_diminfo[H5S_MAX_RANK]; /* Temporary dimension info */ - hbool_t found_nonidentical_dim = FALSE; - unsigned curr_dim; + H5S_hyper_dim_t tmp_diminfo[H5S_MAX_RANK]; /* Temporary dimension info */ + hbool_t found_nonidentical_dim = FALSE; + unsigned curr_dim; /* Copy current diminfo.opt values */ H5MM_memcpy(tmp_diminfo, space->select.sel_info.hslab->diminfo.opt, sizeof(tmp_diminfo)); /* Loop over dimensions */ - for(curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) { + for (curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) { /* Check for this being identical */ - if((tmp_diminfo[curr_dim].start != new_hyper_diminfo[curr_dim].start) - || (tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride) - || (tmp_diminfo[curr_dim].count != new_hyper_diminfo[curr_dim].count) - || (tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block)) { - hsize_t high_start, high_count, high_block; /* The start, count & block values for the higher block */ + if ((tmp_diminfo[curr_dim].start != new_hyper_diminfo[curr_dim].start) || + (tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride) || + (tmp_diminfo[curr_dim].count != new_hyper_diminfo[curr_dim].count) || + (tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block)) { + hsize_t high_start, high_count, + high_block; /* The start, count & block values for the higher block */ /* Dimension is not identical */ /* Check if we already found a nonidentical dim - only one is * allowed */ - if(found_nonidentical_dim) { + if (found_nonidentical_dim) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Check that strides are the same, or count is 1 for one of the * slabs */ - if((tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride) - && (tmp_diminfo[curr_dim].count > 1) - && (new_hyper_diminfo[curr_dim].count > 1)) { + if ((tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride) && + (tmp_diminfo[curr_dim].count > 1) && (new_hyper_diminfo[curr_dim].count > 1)) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Patch tmp_diminfo.stride if its count is 1 */ - if((tmp_diminfo[curr_dim].count == 1) - && (new_hyper_diminfo[curr_dim].count > 1)) + if ((tmp_diminfo[curr_dim].count == 1) && (new_hyper_diminfo[curr_dim].count > 1)) tmp_diminfo[curr_dim].stride = new_hyper_diminfo[curr_dim].stride; /* Determine lowest start, and set tmp_diminfo.start, count and * block to use the lowest, and high_start, high_count and * high_block to use the highest */ - if(tmp_diminfo[curr_dim].start < new_hyper_diminfo[curr_dim].start) { + if (tmp_diminfo[curr_dim].start < new_hyper_diminfo[curr_dim].start) { high_start = new_hyper_diminfo[curr_dim].start; high_count = new_hyper_diminfo[curr_dim].count; high_block = new_hyper_diminfo[curr_dim].block; } /* end if */ else { - high_start = tmp_diminfo[curr_dim].start; + high_start = tmp_diminfo[curr_dim].start; tmp_diminfo[curr_dim].start = new_hyper_diminfo[curr_dim].start; - high_count = tmp_diminfo[curr_dim].count; + high_count = tmp_diminfo[curr_dim].count; tmp_diminfo[curr_dim].count = new_hyper_diminfo[curr_dim].count; - high_block = tmp_diminfo[curr_dim].block; + high_block = tmp_diminfo[curr_dim].block; tmp_diminfo[curr_dim].block = new_hyper_diminfo[curr_dim].block; } /* end else */ /* If count is 1 for both slabs, take different actions */ - if((tmp_diminfo[curr_dim].count == 1) && (high_count == 1)) { + if ((tmp_diminfo[curr_dim].count == 1) && (high_count == 1)) { /* Check for overlap */ - if((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block) - > high_start) { + if ((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block) > high_start) { /* Check operation type */ - if(op == H5S_SELECT_OR) + if (op == H5S_SELECT_OR) /* Merge blocks */ - tmp_diminfo[curr_dim].block = ((high_start + high_block) - >= (tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block)) + tmp_diminfo[curr_dim].block = + ((high_start + high_block) >= + (tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block)) ? (high_start + high_block - tmp_diminfo[curr_dim].start) : tmp_diminfo[curr_dim].block; else { /* Block values must be the same */ - if(tmp_diminfo[curr_dim].block != high_block) { + if (tmp_diminfo[curr_dim].block != high_block) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* XOR - overlap creates 2 blocks */ tmp_diminfo[curr_dim].stride = high_block; - tmp_diminfo[curr_dim].count = 2; - tmp_diminfo[curr_dim].block = high_start - tmp_diminfo[curr_dim].start; + tmp_diminfo[curr_dim].count = 2; + tmp_diminfo[curr_dim].block = high_start - tmp_diminfo[curr_dim].start; } /* end else */ - } /* end if */ - else if((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block) - == high_start) + } /* end if */ + else if ((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block) == high_start) /* Blocks border, merge them */ tmp_diminfo[curr_dim].block += high_block; else { /* Distinct blocks */ /* Block values must be the same */ - if(tmp_diminfo[curr_dim].block != high_block) { + if (tmp_diminfo[curr_dim].block != high_block) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Create strided selection */ tmp_diminfo[curr_dim].stride = high_start - tmp_diminfo[curr_dim].start; - tmp_diminfo[curr_dim].count = 2; + tmp_diminfo[curr_dim].count = 2; } /* end else */ - } /* end if */ + } /* end if */ else { /* Check if block values are the same */ - if(tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block) { + if (tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Check phase of strides */ - if((tmp_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride) - != (new_hyper_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride)) { + if ((tmp_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride) != + (new_hyper_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride)) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Check operation type */ - if(op == H5S_SELECT_OR) { + if (op == H5S_SELECT_OR) { /* Make sure the slabs border or overlap */ - if(high_start > (tmp_diminfo[curr_dim].start - + (tmp_diminfo[curr_dim].count - * tmp_diminfo[curr_dim].stride))) { + if (high_start > (tmp_diminfo[curr_dim].start + + (tmp_diminfo[curr_dim].count * tmp_diminfo[curr_dim].stride))) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ - } /* end if */ + } /* end if */ else /* XOR: Make sure the slabs border */ - if(high_start != (tmp_diminfo[curr_dim].start - + (tmp_diminfo[curr_dim].count - * tmp_diminfo[curr_dim].stride))) { - space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; - break; - } /* end if */ + if (high_start != (tmp_diminfo[curr_dim].start + + (tmp_diminfo[curr_dim].count * tmp_diminfo[curr_dim].stride))) { + space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; + break; + } /* end if */ /* Set count for combined selection */ - tmp_diminfo[curr_dim].count = ((high_start - - tmp_diminfo[curr_dim].start) - / tmp_diminfo[curr_dim].stride) + high_count; + tmp_diminfo[curr_dim].count = + ((high_start - tmp_diminfo[curr_dim].start) / tmp_diminfo[curr_dim].stride) + + high_count; } /* end else */ /* Indicate that we found a nonidentical dim */ found_nonidentical_dim = TRUE; } /* end if */ - } /* end for */ + } /* end for */ /* Check if we succeeded, if so, set the new diminfo values */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) - for(curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) { + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) + for (curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) { hsize_t tmp_high_bound; /* Set the new diminfo values */ - space->select.sel_info.hslab->diminfo.app[curr_dim].start = space->select.sel_info.hslab->diminfo.opt[curr_dim].start = tmp_diminfo[curr_dim].start; + space->select.sel_info.hslab->diminfo.app[curr_dim].start = + space->select.sel_info.hslab->diminfo.opt[curr_dim].start = tmp_diminfo[curr_dim].start; HDassert(tmp_diminfo[curr_dim].stride > 0); - space->select.sel_info.hslab->diminfo.app[curr_dim].stride = space->select.sel_info.hslab->diminfo.opt[curr_dim].stride = tmp_diminfo[curr_dim].stride; + space->select.sel_info.hslab->diminfo.app[curr_dim].stride = + space->select.sel_info.hslab->diminfo.opt[curr_dim].stride = tmp_diminfo[curr_dim].stride; HDassert(tmp_diminfo[curr_dim].count > 0); - space->select.sel_info.hslab->diminfo.app[curr_dim].count = space->select.sel_info.hslab->diminfo.opt[curr_dim].count = tmp_diminfo[curr_dim].count; + space->select.sel_info.hslab->diminfo.app[curr_dim].count = + space->select.sel_info.hslab->diminfo.opt[curr_dim].count = tmp_diminfo[curr_dim].count; HDassert(tmp_diminfo[curr_dim].block > 0); - space->select.sel_info.hslab->diminfo.app[curr_dim].block = space->select.sel_info.hslab->diminfo.opt[curr_dim].block = tmp_diminfo[curr_dim].block; + space->select.sel_info.hslab->diminfo.app[curr_dim].block = + space->select.sel_info.hslab->diminfo.opt[curr_dim].block = tmp_diminfo[curr_dim].block; /* Check for updating the low & high bounds */ - if(tmp_diminfo[curr_dim].start < space->select.sel_info.hslab->diminfo.low_bounds[curr_dim]) + if (tmp_diminfo[curr_dim].start < space->select.sel_info.hslab->diminfo.low_bounds[curr_dim]) space->select.sel_info.hslab->diminfo.low_bounds[curr_dim] = tmp_diminfo[curr_dim].start; - tmp_high_bound = tmp_diminfo[curr_dim].start + - (tmp_diminfo[curr_dim].block - 1) + - (tmp_diminfo[curr_dim].stride * (tmp_diminfo[curr_dim].count - 1)); - if(tmp_high_bound > space->select.sel_info.hslab->diminfo.low_bounds[curr_dim]) + tmp_high_bound = tmp_diminfo[curr_dim].start + (tmp_diminfo[curr_dim].block - 1) + + (tmp_diminfo[curr_dim].stride * (tmp_diminfo[curr_dim].count - 1)); + if (tmp_high_bound > space->select.sel_info.hslab->diminfo.low_bounds[curr_dim]) space->select.sel_info.hslab->diminfo.high_bounds[curr_dim] = tmp_high_bound; } /* end for */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_update_diminfo() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_rebuild_helper @@ -8829,14 +8883,14 @@ H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, static hbool_t H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t span_slab_info[]) { - const H5S_hyper_span_t *span; /* Hyperslab span */ - const H5S_hyper_span_t *prev_span; /* Previous span in list */ - hsize_t start; /* Starting element for this dimension */ - hsize_t stride; /* Stride for this dimension */ - hsize_t block; /* Block size for this dimension */ - hsize_t prev_low; /* Low bound for previous span */ - size_t spancount; /* Number of spans encountered in this dimension */ - hbool_t ret_value = TRUE; /* Return value */ + const H5S_hyper_span_t *span; /* Hyperslab span */ + const H5S_hyper_span_t *prev_span; /* Previous span in list */ + hsize_t start; /* Starting element for this dimension */ + hsize_t stride; /* Stride for this dimension */ + hsize_t block; /* Block size for this dimension */ + hsize_t prev_low; /* Low bound for previous span */ + size_t spancount; /* Number of spans encountered in this dimension */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8844,15 +8898,15 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp HDassert(spans); /* Initialization */ - span = spans->head; - stride = 1; - prev_low = 0; + span = spans->head; + stride = 1; + prev_low = 0; spancount = 0; /* Get "canonical" down span information */ - if(span->down) + if (span->down) /* Go to the next down span and check whether the selection can be rebuilt */ - if(!H5S__hyper_rebuild_helper(span->down, &span_slab_info[1])) + if (!H5S__hyper_rebuild_helper(span->down, &span_slab_info[1])) HGOTO_DONE(FALSE) /* Assign the initial starting point & block size for this dimension */ @@ -8861,31 +8915,31 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp /* Loop the spans */ prev_span = NULL; - while(span) { - if(spancount > 0) { - hsize_t curr_stride; /* Current stride from previous span */ - hsize_t curr_block; /* Block size of current span */ + while (span) { + if (spancount > 0) { + hsize_t curr_stride; /* Current stride from previous span */ + hsize_t curr_block; /* Block size of current span */ /* Sanity check */ HDassert(prev_span); /* Check that down spans match current slab info */ /* (Can skip check if previous span's down pointer is same as current one) */ - if(span->down && prev_span->down != span->down) - if(!H5S__hyper_cmp_spans(span->down, prev_span->down)) + if (span->down && prev_span->down != span->down) + if (!H5S__hyper_cmp_spans(span->down, prev_span->down)) HGOTO_DONE(FALSE) /* Obtain values for stride and block */ curr_stride = span->low - prev_low; - curr_block = (span->high - span->low) + 1; + curr_block = (span->high - span->low) + 1; /* Compare stride and block for this span. To compare stride, * three spans are needed. Account for the first two spans. */ - if(curr_block != block) + if (curr_block != block) HGOTO_DONE(FALSE) - if(spancount > 1) { - if(stride != curr_stride) + if (spancount > 1) { + if (stride != curr_stride) HGOTO_DONE(FALSE) } /* end if */ else @@ -8897,7 +8951,7 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp /* Advance to next span */ prev_span = span; - span = span->next; + span = span->next; spancount++; } /* end while */ @@ -8911,7 +8965,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_rebuild_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_rebuild @@ -8946,14 +8999,17 @@ H5S__hyper_rebuild(H5S_t *space) /* Check whether the slab can be rebuilt */ /* (Only regular selection can be rebuilt. If yes, fill in correct values) */ - if(FALSE == H5S__hyper_rebuild_helper(space->select.sel_info.hslab->span_lst, rebuilt_slab_info)) + if (FALSE == H5S__hyper_rebuild_helper(space->select.sel_info.hslab->span_lst, rebuilt_slab_info)) space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_IMPOSSIBLE; else { /* Set the dimension info & bounds for the dataspace, from the rebuilt info */ H5MM_memcpy(space->select.sel_info.hslab->diminfo.app, rebuilt_slab_info, sizeof(rebuilt_slab_info)); H5MM_memcpy(space->select.sel_info.hslab->diminfo.opt, rebuilt_slab_info, sizeof(rebuilt_slab_info)); - H5MM_memcpy(space->select.sel_info.hslab->diminfo.low_bounds, space->select.sel_info.hslab->span_lst->low_bounds, sizeof(hsize_t) * space->extent.rank); - H5MM_memcpy(space->select.sel_info.hslab->diminfo.high_bounds, space->select.sel_info.hslab->span_lst->high_bounds, sizeof(hsize_t) * space->extent.rank); + H5MM_memcpy(space->select.sel_info.hslab->diminfo.low_bounds, + space->select.sel_info.hslab->span_lst->low_bounds, sizeof(hsize_t) * space->extent.rank); + H5MM_memcpy(space->select.sel_info.hslab->diminfo.high_bounds, + space->select.sel_info.hslab->span_lst->high_bounds, + sizeof(hsize_t) * space->extent.rank); space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES; } /* end else */ @@ -8961,7 +9017,6 @@ H5S__hyper_rebuild(H5S_t *space) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_rebuild() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_generate_spans @@ -8983,12 +9038,12 @@ H5S__hyper_rebuild(H5S_t *space) static herr_t H5S__hyper_generate_spans(H5S_t *space) { - hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ - hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ - hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ - hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ + hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ + hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8996,31 +9051,30 @@ H5S__hyper_generate_spans(H5S_t *space) HDassert(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS); /* Get the diminfo */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Check for unlimited dimension and return error */ /* These should be able to be converted to assertions once everything * that calls this function checks for unlimited selections first * (especially the new hyperslab API) -NAF */ - if(space->select.sel_info.hslab->diminfo.opt[u].count == H5S_UNLIMITED) + if (space->select.sel_info.hslab->diminfo.opt[u].count == H5S_UNLIMITED) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "can't generate spans with unlimited count") - if(space->select.sel_info.hslab->diminfo.opt[u].block == H5S_UNLIMITED) + if (space->select.sel_info.hslab->diminfo.opt[u].block == H5S_UNLIMITED) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "can't generate spans with unlimited block") - tmp_start[u] = space->select.sel_info.hslab->diminfo.opt[u].start; + tmp_start[u] = space->select.sel_info.hslab->diminfo.opt[u].start; tmp_stride[u] = space->select.sel_info.hslab->diminfo.opt[u].stride; - tmp_count[u] = space->select.sel_info.hslab->diminfo.opt[u].count; - tmp_block[u] = space->select.sel_info.hslab->diminfo.opt[u].block; + tmp_count[u] = space->select.sel_info.hslab->diminfo.opt[u].count; + tmp_block[u] = space->select.sel_info.hslab->diminfo.opt[u].block; } /* end for */ /* Build the hyperslab information also */ - if(H5S__generate_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + if (H5S__generate_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_generate_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__check_spans_overlap @@ -9040,10 +9094,9 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static H5_ATTR_PURE hbool_t -H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, - const H5S_hyper_span_info_t *spans2) +H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, const H5S_hyper_span_info_t *spans2) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -9052,23 +9105,23 @@ H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, HDassert(spans2); /* Use low & high bounds to try to avoid spinning through the span lists */ - if(H5S_RANGE_OVERLAP(spans1->low_bounds[0], spans1->high_bounds[0], - spans2->low_bounds[0], spans2->high_bounds[0])) { - H5S_hyper_span_t *span1, *span2; /* Hyperslab spans */ + if (H5S_RANGE_OVERLAP(spans1->low_bounds[0], spans1->high_bounds[0], spans2->low_bounds[0], + spans2->high_bounds[0])) { + H5S_hyper_span_t *span1, *span2; /* Hyperslab spans */ /* Walk over spans, comparing them for overlap */ span1 = spans1->head; span2 = spans2->head; - while(span1 && span2) { + while (span1 && span2) { /* Check current two spans for overlap */ - if(H5S_RANGE_OVERLAP(span1->low, span1->high, span2->low, span2->high)) { + if (H5S_RANGE_OVERLAP(span1->low, span1->high, span2->low, span2->high)) { /* Check for spans in lowest dimension already */ - if(span1->down) { + if (span1->down) { /* Sanity check */ HDassert(span2->down); /* Check lower dimensions for overlap */ - if(H5S__check_spans_overlap(span1->down, span2->down)) + if (H5S__check_spans_overlap(span1->down, span2->down)) HGOTO_DONE(TRUE); } /* end if */ else @@ -9076,32 +9129,31 @@ H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, } /* end if */ /* Advance one of the spans */ - if(span1->high <= span2->high) { + if (span1->high <= span2->high) { /* Advance span1, unless it would be off the list and span2 has more nodes */ - if(NULL == span1->next && NULL != span2->next) + if (NULL == span1->next && NULL != span2->next) span2 = span2->next; else span1 = span1->next; } /* end if */ else { /* Advance span2, unless it would be off the list and span1 has more nodes */ - if(NULL == span2->next && NULL != span1->next) + if (NULL == span2->next && NULL != span1->next) span1 = span1->next; else span2 = span2->next; } /* end else */ - } /* end while */ + } /* end while */ /* Make certain we've exhausted our comparisons */ HDassert((NULL == span1 && (NULL != span2 && NULL == span2->next)) || - ((NULL != span1 && NULL == span1->next) && NULL == span2)); + ((NULL != span1 && NULL == span1->next) && NULL == span2)); } /* end of */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__check_spans_overlap() */ - /*-------------------------------------------------------------------------- NAME H5S__fill_in_new_space @@ -9132,16 +9184,17 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, - H5S_hyper_span_info_t *space2_span_lst, hbool_t can_own_span2, - hbool_t *span2_owned, hbool_t *updated_spans, H5S_t **result) +H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, H5S_hyper_span_info_t *space2_span_lst, + hbool_t can_own_span2, hbool_t *span2_owned, hbool_t *updated_spans, H5S_t **result) { - H5S_hyper_span_info_t *a_not_b = NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ - H5S_hyper_span_info_t *a_and_b = NULL; /* Span tree for hyperslab spans in both old and new span trees */ - H5S_hyper_span_info_t *b_not_a = NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */ - hbool_t overlapped = FALSE; /* Whether selections overlap */ + H5S_hyper_span_info_t *a_not_b = + NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ + H5S_hyper_span_info_t *a_and_b = NULL; /* Span tree for hyperslab spans in both old and new span trees */ + H5S_hyper_span_info_t *b_not_a = + NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */ + hbool_t overlapped = FALSE; /* Whether selections overlap */ hbool_t is_result_new = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -9154,39 +9207,40 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, HDassert(span2_owned); /* Reset flags to return */ - *span2_owned = FALSE; + *span2_owned = FALSE; *updated_spans = FALSE; /* The result shares the same info from space1 */ - if(*result == NULL) { - if(NULL == ((*result) = H5S_copy(space1, TRUE, TRUE))) + if (*result == NULL) { + if (NULL == ((*result) = H5S_copy(space1, TRUE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") space1->select.sel_info.hslab->span_lst->count--; (*result)->select.sel_info.hslab->span_lst = NULL; - is_result_new = TRUE; + is_result_new = TRUE; } /* end if */ /* Check both spaces to see if they overlap */ overlapped = H5S__check_spans_overlap(space1->select.sel_info.hslab->span_lst, space2_span_lst); - if(!overlapped) { - switch(op) { + if (!overlapped) { + switch (op) { case H5S_SELECT_OR: case H5S_SELECT_XOR: /* Add the new disjoint spans to the space */ /* Copy of space1's spans to *result, and another copy of space2's spans */ - if(is_result_new) - (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); - if(!can_own_span2) { + if (is_result_new) + (*result)->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); + if (!can_own_span2) { b_not_a = H5S__hyper_copy_span(space2_span_lst, space1->extent.rank); - if(H5S__hyper_add_disjoint_spans(*result, b_not_a) < 0) + if (H5S__hyper_add_disjoint_spans(*result, b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs") /* The new_spans are now owned by 'space', so they should not be released */ b_not_a = NULL; } /* end if */ else { - if(H5S__hyper_add_disjoint_spans(*result, space2_span_lst) < 0) + if (H5S__hyper_add_disjoint_spans(*result, space2_span_lst) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs") *span2_owned = TRUE; } /* end else */ @@ -9197,21 +9251,22 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, case H5S_SELECT_AND: /* Convert *result to "none" selection */ - if(H5S_select_none(*result) < 0) + if (H5S_select_none(*result) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_DONE(SUCCEED); case H5S_SELECT_NOTB: /* Copy space1's spans to *result */ - if(is_result_new) - (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); + if (is_result_new) + (*result)->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); /* Indicate that the spans changed */ *updated_spans = TRUE; break; case H5S_SELECT_NOTA: - if(!is_result_new) { + if (!is_result_new) { HDassert(space1 == *result); /* Free the current selection */ @@ -9220,11 +9275,12 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, } /* end if */ /* Copy space2's spans to *result */ - if(!can_own_span2) - (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space2_span_lst, space1->extent.rank); + if (!can_own_span2) + (*result)->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(space2_span_lst, space1->extent.rank); else { (*result)->select.sel_info.hslab->span_lst = space2_span_lst; - *span2_owned = TRUE; + *span2_owned = TRUE; } /* end else */ /* Reset the number of items in selection */ @@ -9242,12 +9298,12 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") } /* end switch */ - } /* end if */ + } /* end if */ else { - unsigned selector = 0; /* Select which clipping spans to generate */ + unsigned selector = 0; /* Select which clipping spans to generate */ /* Generate mask for clip operation depending on the op */ - switch(op) { + switch (op) { case H5S_SELECT_OR: /* a + b_not_a */ selector = H5S_HYPER_COMPUTE_B_NOT_A; break; @@ -9278,21 +9334,21 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, } /* end switch */ /* Generate lists of spans which overlap and don't overlap */ - if(H5S__hyper_clip_spans(space1->select.sel_info.hslab->span_lst, - space2_span_lst, selector, space1->extent.rank, - &a_not_b, &a_and_b, &b_not_a) < 0) + if (H5S__hyper_clip_spans(space1->select.sel_info.hslab->span_lst, space2_span_lst, selector, + space1->extent.rank, &a_not_b, &a_and_b, &b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") - switch(op) { + switch (op) { case H5S_SELECT_OR: - if(is_result_new) - (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); + if (is_result_new) + (*result)->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); break; case H5S_SELECT_AND: case H5S_SELECT_XOR: case H5S_SELECT_NOTB: case H5S_SELECT_NOTA: - if(!is_result_new) { + if (!is_result_new) { HDassert(space1 == *result); /* Free the current selection */ @@ -9315,7 +9371,7 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, } /* end switch */ /* Check if there are any non-overlapped selections */ - if(a_not_b) { + if (a_not_b) { /* Other than OR, the span_lst is set to NULL. And in OR, * a_not_b is not needed */ @@ -9335,7 +9391,7 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, a_not_b = NULL; } /* end if */ - if(a_and_b) { + if (a_and_b) { /** * 1. Other than OR, the span_lst is set to NULL. And in OR, * a_and_b is not needed @@ -9358,9 +9414,9 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, a_and_b = NULL; } /* end if */ - if(b_not_a) { + if (b_not_a) { /* Merge the b_not_a spans into the result dataspace */ - if(H5S__hyper_merge_spans(*result, b_not_a) < 0) + if (H5S__hyper_merge_spans(*result, b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs") /* Update the number of elements in current selection */ @@ -9369,10 +9425,10 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, /* Indicate that the spans were updated */ *updated_spans = TRUE; } /* end if */ - } /* end else for the case the new span overlaps with the old (i.e. space) */ + } /* end else for the case the new span overlaps with the old (i.e. space) */ /* Check if the spans weren't updated, and reset selection if so */ - if(!*updated_spans) { + if (!*updated_spans) { /* If updated_spans remains FALSE as in this branch, it means the * result has been cleared in XOR / AND / NOTB / NOTA cases, and the * result is a copy of the dataspace in the OR case. @@ -9381,26 +9437,25 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, * span trees (i.e. a_not_b, a_and_b, and b_not_a), the * updated_spans must be TRUE. */ - if(H5S_SELECT_OR != op) { + if (H5S_SELECT_OR != op) { /* Convert *result to "none" selection */ - if(H5S_select_none(*result) < 0) + if (H5S_select_none(*result) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end else */ - } /* end if */ + } /* end if */ done: /* Free resources */ - if(a_not_b) + if (a_not_b) H5S__hyper_free_span_info(a_not_b); - if(a_and_b) + if (a_and_b) H5S__hyper_free_span_info(a_and_b); - if(b_not_a) + if (b_not_a) H5S__hyper_free_span_info(b_not_a); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__fill_in_new_space() */ - /*------------------------------------------------------------------------- * Function: H5S__generate_hyperlab * @@ -9414,11 +9469,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], - const hsize_t stride[], const hsize_t count[], const hsize_t block[]) +H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], + const hsize_t count[], const hsize_t block[]) { H5S_hyper_span_info_t *new_spans = NULL; /* Span tree for new hyperslab */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -9431,13 +9486,13 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], HDassert(block); /* Generate span tree for new hyperslab information */ - if(NULL == (new_spans = H5S__hyper_make_spans(space->extent.rank, start, stride, count, block))) + if (NULL == (new_spans = H5S__hyper_make_spans(space->extent.rank, start, stride, count, block))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information") /* Generate list of blocks to add/remove based on selection operation */ - if(op == H5S_SELECT_SET) { + if (op == H5S_SELECT_SET) { /* Free current selection */ - if(NULL != space->select.sel_info.hslab->span_lst) + if (NULL != space->select.sel_info.hslab->span_lst) H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst); /* Set the hyperslab selection to the new span tree */ @@ -9451,46 +9506,45 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], } /* end if */ else { hbool_t new_spans_owned = FALSE; - hbool_t updated_spans = FALSE; + hbool_t updated_spans = FALSE; /* Generate new spans for space */ - if(H5S__fill_in_new_space(space, op, new_spans, TRUE, &new_spans_owned, &updated_spans, &space) < 0) + if (H5S__fill_in_new_space(space, op, new_spans, TRUE, &new_spans_owned, &updated_spans, &space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't generate the specified hyperslab") /* Check if the spans were updated by H5S__fill_in_new_space */ - if(updated_spans) { + if (updated_spans) { H5S_hyper_dim_t new_hyper_diminfo[H5S_MAX_RANK]; - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(space->select.sel_info.hslab->span_lst->head); /* Build diminfo struct */ - for(u = 0; u extent.rank; u++) { - new_hyper_diminfo[u].start = start[u]; + for (u = 0; u < space->extent.rank; u++) { + new_hyper_diminfo[u].start = start[u]; new_hyper_diminfo[u].stride = stride[u]; - new_hyper_diminfo[u].count = count[u]; - new_hyper_diminfo[u].block = block[u]; + new_hyper_diminfo[u].count = count[u]; + new_hyper_diminfo[u].block = block[u]; } /* end for */ /* Update space's dim info */ - if(H5S__hyper_update_diminfo(space, op, new_hyper_diminfo) < 0) + if (H5S__hyper_update_diminfo(space, op, new_hyper_diminfo) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info") } /* end if */ /* Indicate that the new_spans are owned, there's no need to free */ - if(new_spans_owned) + if (new_spans_owned) new_spans = NULL; } /* end else */ done: - if(new_spans) + if (new_spans) H5S__hyper_free_span_info(new_spans); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__generate_hyperslab() */ - /*------------------------------------------------------------------------- * Function: H5S__set_regular_hyperslab * @@ -9504,12 +9558,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], - const hsize_t *app_stride, const hsize_t app_count[], const hsize_t *app_block, - const hsize_t *opt_stride, const hsize_t opt_count[], const hsize_t *opt_block) +H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], const hsize_t *app_stride, + const hsize_t app_count[], const hsize_t *app_block, const hsize_t *opt_stride, + const hsize_t opt_count[], const hsize_t *opt_block) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -9524,27 +9578,27 @@ H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], HDassert(opt_block); /* If we are setting a new selection, remove current selection first */ - if(H5S_SELECT_RELEASE(space) < 0) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Allocate space for the hyperslab selection information */ - if(NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) + if (NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info") /* Set the diminfo */ - space->select.num_elem = 1; + space->select.num_elem = 1; space->select.sel_info.hslab->unlim_dim = -1; - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Set application and optimized hyperslab info */ - space->select.sel_info.hslab->diminfo.app[u].start = start[u]; + space->select.sel_info.hslab->diminfo.app[u].start = start[u]; space->select.sel_info.hslab->diminfo.app[u].stride = app_stride[u]; - space->select.sel_info.hslab->diminfo.app[u].count = app_count[u]; - space->select.sel_info.hslab->diminfo.app[u].block = app_block[u]; + space->select.sel_info.hslab->diminfo.app[u].count = app_count[u]; + space->select.sel_info.hslab->diminfo.app[u].block = app_block[u]; - space->select.sel_info.hslab->diminfo.opt[u].start = start[u]; + space->select.sel_info.hslab->diminfo.opt[u].start = start[u]; space->select.sel_info.hslab->diminfo.opt[u].stride = opt_stride[u]; - space->select.sel_info.hslab->diminfo.opt[u].count = opt_count[u]; - space->select.sel_info.hslab->diminfo.opt[u].block = opt_block[u]; + space->select.sel_info.hslab->diminfo.opt[u].count = opt_count[u]; + space->select.sel_info.hslab->diminfo.opt[u].block = opt_block[u]; /* Update # of elements selected */ space->select.num_elem *= (opt_count[u] * opt_block[u]); @@ -9553,20 +9607,21 @@ H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], space->select.sel_info.hslab->diminfo.low_bounds[u] = start[u]; /* Check for unlimited dimension & set high bound */ - if((app_count[u] == H5S_UNLIMITED) || (app_block[u] == H5S_UNLIMITED)) { - space->select.sel_info.hslab->unlim_dim = (int)u; + if ((app_count[u] == H5S_UNLIMITED) || (app_block[u] == H5S_UNLIMITED)) { + space->select.sel_info.hslab->unlim_dim = (int)u; space->select.sel_info.hslab->diminfo.high_bounds[u] = H5S_UNLIMITED; } /* end if */ else - space->select.sel_info.hslab->diminfo.high_bounds[u] = start[u] + opt_stride[u] * (opt_count[u] - 1) + (opt_block[u] - 1); + space->select.sel_info.hslab->diminfo.high_bounds[u] = + start[u] + opt_stride[u] * (opt_count[u] - 1) + (opt_block[u] - 1); } /* end for */ /* Handle unlimited selections */ - if(space->select.sel_info.hslab->unlim_dim >= 0) { + if (space->select.sel_info.hslab->unlim_dim >= 0) { /* Calculate num_elem_non_unlim */ space->select.sel_info.hslab->num_elem_non_unlim = (hsize_t)1; - for(u = 0; u < space->extent.rank; u++) - if((int)u != space->select.sel_info.hslab->unlim_dim) + for (u = 0; u < space->extent.rank; u++) + if ((int)u != space->select.sel_info.hslab->unlim_dim) space->select.sel_info.hslab->num_elem_non_unlim *= (opt_count[u] * opt_block[u]); /* Update num_elem */ @@ -9586,7 +9641,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__set_regular_hyperslab() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_regular_and_single_block * @@ -9604,14 +9658,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], - const hsize_t block[]) +H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], const hsize_t block[]) { - hsize_t select_end, block_end; /* End of block & selection */ - hbool_t single_block; /* Whether the selection is a single block */ - hbool_t overlap; /* Whether block & selection overlap */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t select_end, block_end; /* End of block & selection */ + hbool_t single_block; /* Whether the selection is a single block */ + hbool_t overlap; /* Whether block & selection overlap */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -9622,26 +9675,27 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], /* Check for single block selection in dataspace */ single_block = TRUE; - for(u = 0; u < space->extent.rank; u++) - if(1 != space->select.sel_info.hslab->diminfo.opt[u].count) { + for (u = 0; u < space->extent.rank; u++) + if (1 != space->select.sel_info.hslab->diminfo.opt[u].count) { single_block = FALSE; break; } /* end if */ /* Perform different optimizations, based on type of regular selection */ - if(single_block) { - hsize_t new_start[H5S_MAX_RANK]; /* New starting coordinate */ - hsize_t new_block[H5S_MAX_RANK]; /* New block size */ + if (single_block) { + hsize_t new_start[H5S_MAX_RANK]; /* New starting coordinate */ + hsize_t new_block[H5S_MAX_RANK]; /* New block size */ /* Check for overlap and compute new start offset & block sizes */ overlap = TRUE; - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Compute the end of the selection & block in this dimension */ select_end = space->select.sel_info.hslab->diminfo.high_bounds[u]; - block_end = (start[u] + block[u]) - 1; + block_end = (start[u] + block[u]) - 1; /* Check for overlap */ - if(!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], block_end)) { + if (!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], + block_end)) { overlap = FALSE; break; } /* end if */ @@ -9652,125 +9706,122 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], } /* end for */ /* Check for overlap of selection & block */ - if(overlap) { + if (overlap) { /* Set selection to regular hyperslab */ - if(H5S__set_regular_hyperslab(space, new_start, H5S_hyper_ones_g, H5S_hyper_ones_g, new_block, - H5S_hyper_ones_g, H5S_hyper_ones_g, new_block) < 0) + if (H5S__set_regular_hyperslab(space, new_start, H5S_hyper_ones_g, H5S_hyper_ones_g, new_block, + H5S_hyper_ones_g, H5S_hyper_ones_g, new_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection") } /* end if */ else /* Selection & block don't overlap, set to "none" selection */ - if(H5S_select_none(space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") + if (H5S_select_none(space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end if */ else { hsize_t new_start[H5S_MAX_RANK]; /* New start for hyperslab selection */ hsize_t new_count[H5S_MAX_RANK]; /* New count for hyperslab selection */ - hsize_t stride[H5S_MAX_RANK]; /* Stride for hyperslab selection */ + hsize_t stride[H5S_MAX_RANK]; /* Stride for hyperslab selection */ hsize_t new_block[H5S_MAX_RANK]; /* New block for hyperslab selection */ - hbool_t partial_first_span; /* Whether first span in intersection is partial */ - hbool_t partial_last_span; /* Whether last span in intersection is partial */ + hbool_t partial_first_span; /* Whether first span in intersection is partial */ + hbool_t partial_last_span; /* Whether last span in intersection is partial */ /* Iterate over selection, checking for overlap and computing first / last * span that intersects with the block. */ - overlap = TRUE; + overlap = TRUE; partial_first_span = FALSE; - partial_last_span = FALSE; - for(u = 0; u < space->extent.rank; u++) { - hsize_t first_span_start, first_span_end; /* Start / end of first span */ + partial_last_span = FALSE; + for (u = 0; u < space->extent.rank; u++) { + hsize_t first_span_start, first_span_end; /* Start / end of first span */ hsize_t last_span_start, last_span_end; /* Start / end of last span */ - hsize_t nstride; /* Number of strides into the selection */ + hsize_t nstride; /* Number of strides into the selection */ /* Compute the end of the selection & block in this dimension */ select_end = space->select.sel_info.hslab->diminfo.high_bounds[u]; - block_end = (start[u] + block[u]) - 1; + block_end = (start[u] + block[u]) - 1; /* Check for overlap */ - if(!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], block_end)) { + if (!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], + block_end)) { overlap = FALSE; break; } /* end if */ /* Find first span that is before or overlaps with start of block */ - if(space->select.sel_info.hslab->diminfo.opt[u].start >= start[u]) { + if (space->select.sel_info.hslab->diminfo.opt[u].start >= start[u]) { /* Calculate start & end of first span */ first_span_start = space->select.sel_info.hslab->diminfo.opt[u].start; - first_span_end = (first_span_start + - space->select.sel_info.hslab->diminfo.opt[u].block) - 1; + first_span_end = (first_span_start + space->select.sel_info.hslab->diminfo.opt[u].block) - 1; /* Check if first span overlaps _end_ of block */ - if(block_end >= first_span_start && block_end <= first_span_end) + if (block_end >= first_span_start && block_end <= first_span_end) partial_first_span = TRUE; } /* end if */ else { - hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */ + hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */ /* Adjust start coord for selection's 'start' offset */ adj_start = start[u] - space->select.sel_info.hslab->diminfo.opt[u].start; /* Compute # of strides into the selection */ - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) nstride = adj_start / space->select.sel_info.hslab->diminfo.opt[u].stride; else nstride = 0; /* Calculate start & end of first span */ first_span_start = space->select.sel_info.hslab->diminfo.opt[u].start + - (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride); - first_span_end = (first_span_start + - space->select.sel_info.hslab->diminfo.opt[u].block) - 1; + (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride); + first_span_end = (first_span_start + space->select.sel_info.hslab->diminfo.opt[u].block) - 1; /* Check if first span overlaps start of block */ - if(first_span_start < start[u] && first_span_end >= start[u]) + if (first_span_start < start[u] && first_span_end >= start[u]) partial_first_span = TRUE; /* Advance first span to start higher than block's start, * if it's not partial. */ - if(first_span_end < start[u]) { + if (first_span_end < start[u]) { first_span_start += space->select.sel_info.hslab->diminfo.opt[u].stride; first_span_end += space->select.sel_info.hslab->diminfo.opt[u].stride; } /* end if */ - } /* end else */ + } /* end else */ /* Find last span that is before or overlaps with end of block */ - if(select_end < block_end) { + if (select_end < block_end) { /* Calculate start & end of last span */ - last_span_start = (select_end - - space->select.sel_info.hslab->diminfo.opt[u].block) + 1; - last_span_end = select_end; + last_span_start = (select_end - space->select.sel_info.hslab->diminfo.opt[u].block) + 1; + last_span_end = select_end; /* Check if last span overlaps _start_ of block */ - if(start[u] >= last_span_start && start[u] <= last_span_end) + if (start[u] >= last_span_start && start[u] <= last_span_end) partial_last_span = TRUE; } /* end if */ else { - hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */ + hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */ /* Adjust end coord for selection's 'start' offset */ adj_end = block_end - space->select.sel_info.hslab->diminfo.opt[u].start; /* Compute # of strides into the selection */ - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) nstride = adj_end / space->select.sel_info.hslab->diminfo.opt[u].stride; else nstride = 0; /* Calculate start & end of last span */ last_span_start = space->select.sel_info.hslab->diminfo.opt[u].start + - (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride); - last_span_end = (last_span_start + - space->select.sel_info.hslab->diminfo.opt[u].block) - 1; + (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride); + last_span_end = (last_span_start + space->select.sel_info.hslab->diminfo.opt[u].block) - 1; /* Check if last span overlaps end of block */ - if(block_end >= last_span_start && block_end <= last_span_end) + if (block_end >= last_span_start && block_end <= last_span_end) partial_last_span = TRUE; } /* end else */ /* Check if no spans are inside block */ /* (Can happen when block falls in "gap" between spans) */ - if(last_span_end < start[u]) { + if (last_span_end < start[u]) { overlap = FALSE; break; } /* end if */ @@ -9780,9 +9831,10 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], /* Compute new start / count / block values */ new_start[u] = first_span_start; - if(last_span_start != first_span_start) + if (last_span_start != first_span_start) new_count[u] = ((last_span_start - first_span_start) / - space->select.sel_info.hslab->diminfo.opt[u].stride) + 1; + space->select.sel_info.hslab->diminfo.opt[u].stride) + + 1; else new_count[u] = 1; new_block[u] = space->select.sel_info.hslab->diminfo.opt[u].block; @@ -9792,35 +9844,35 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], } /* end for */ /* Check for overlap of selection & block */ - if(overlap) { + if (overlap) { /* Set selection to regular hyperslab */ - if(H5S__set_regular_hyperslab(space, new_start, stride, new_count, new_block, - stride, new_count, new_block) < 0) + if (H5S__set_regular_hyperslab(space, new_start, stride, new_count, new_block, stride, new_count, + new_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection") /* If there's a partial first or last span, have to 'AND' against selection */ - if(partial_first_span || partial_last_span) { + if (partial_first_span || partial_last_span) { /* Generate span tree for regular selection */ - if(H5S__hyper_generate_spans(space) < 0) + if (H5S__hyper_generate_spans(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree") /* 'AND' against block */ - if(H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, block) < 0) + if (H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, + block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs") } /* end if */ - } /* end if */ + } /* end if */ else { /* Selection & block don't overlap, set to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_regular_and_single_block() */ - /*------------------------------------------------------------------------- * Function: H5S_select_hyperslab * @@ -9834,18 +9886,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], - const hsize_t *stride, const hsize_t count[], const hsize_t *block) +H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], const hsize_t *stride, + const hsize_t count[], const hsize_t *block) { - hsize_t int_stride[H5S_MAX_RANK]; /* Internal storage for stride information */ - hsize_t int_count[H5S_MAX_RANK]; /* Internal storage for count information */ - hsize_t int_block[H5S_MAX_RANK]; /* Internal storage for block information */ - const hsize_t *opt_stride; /* Optimized stride information */ - const hsize_t *opt_count; /* Optimized count information */ - const hsize_t *opt_block; /* Optimized block information */ - int unlim_dim = -1; /* Unlimited dimension in selection, of -1 if none */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t int_stride[H5S_MAX_RANK]; /* Internal storage for stride information */ + hsize_t int_count[H5S_MAX_RANK]; /* Internal storage for count information */ + hsize_t int_block[H5S_MAX_RANK]; /* Internal storage for block information */ + const hsize_t *opt_stride; /* Optimized stride information */ + const hsize_t *opt_count; /* Optimized count information */ + const hsize_t *opt_block; /* Optimized block information */ + int unlim_dim = -1; /* Unlimited dimension in selection, of -1 if none */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -9856,34 +9908,34 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], HDassert(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID); /* Point to the correct stride values */ - if(stride == NULL) + if (stride == NULL) stride = H5S_hyper_ones_g; /* Point to the correct block values */ - if(block == NULL) + if (block == NULL) block = H5S_hyper_ones_g; /* Check new selection */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Check for overlapping hyperslab blocks in new selection. */ - if(count[u] > 1 && stride[u] < block[u]) + if (count[u] > 1 && stride[u] < block[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap") /* Detect zero-sized hyperslabs in new selection */ - if(count[u] == 0 || block[u] == 0) { - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + if (count[u] == 0 || block[u] == 0) { + switch (op) { + case H5S_SELECT_SET: /* Select "set" operation */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ /* Convert to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_DONE(SUCCEED); - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays same */ + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays same */ case H5S_SELECT_NOOP: case H5S_SELECT_APPEND: @@ -9892,73 +9944,75 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") } /* end switch */ - } /* end if */ + } /* end if */ /* Check for unlimited dimension */ - if((count[u] == H5S_UNLIMITED) || (block[u] == H5S_UNLIMITED)) { - if(unlim_dim >= 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot have more than one unlimited dimension in selection") + if ((count[u] == H5S_UNLIMITED) || (block[u] == H5S_UNLIMITED)) { + if (unlim_dim >= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "cannot have more than one unlimited dimension in selection") else { - if(count[u] == block[u]) /* Both are H5S_UNLIMITED */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "count and block cannot both be unlimited") + if (count[u] == block[u]) /* Both are H5S_UNLIMITED */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "count and block cannot both be unlimited") unlim_dim = (int)u; } /* end else */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Optimize hyperslab parameters to merge contiguous blocks, etc. */ - if(stride == H5S_hyper_ones_g && block == H5S_hyper_ones_g) { + if (stride == H5S_hyper_ones_g && block == H5S_hyper_ones_g) { /* Point to existing arrays */ opt_stride = H5S_hyper_ones_g; - opt_count = H5S_hyper_ones_g; - opt_block = count; + opt_count = H5S_hyper_ones_g; + opt_block = count; } /* end if */ else { /* Point to local arrays */ opt_stride = int_stride; - opt_count = int_count; - opt_block = int_block; - for(u = 0; u < space->extent.rank; u++) { + opt_count = int_count; + opt_block = int_block; + for (u = 0; u < space->extent.rank; u++) { /* contiguous hyperslabs have the block size equal to the stride */ - if((stride[u] == block[u]) && (count[u] != H5S_UNLIMITED)) { - int_count[u] = 1; + if ((stride[u] == block[u]) && (count[u] != H5S_UNLIMITED)) { + int_count[u] = 1; int_stride[u] = 1; - if(block[u] == 1) + if (block[u] == 1) int_block[u] = count[u]; else int_block[u] = block[u] * count[u]; } /* end if */ else { - if(count[u] == 1) + if (count[u] == 1) int_stride[u] = 1; else { HDassert((stride[u] > block[u]) || - ((stride[u] == block[u]) && (count[u] == H5S_UNLIMITED))); + ((stride[u] == block[u]) && (count[u] == H5S_UNLIMITED))); int_stride[u] = stride[u]; } /* end else */ int_count[u] = count[u]; int_block[u] = block[u]; } /* end else */ - } /* end for */ - } /* end else */ + } /* end for */ + } /* end else */ /* Check for operating on unlimited selection */ - if((H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS) - && (space->select.sel_info.hslab->unlim_dim >= 0) - && (op != H5S_SELECT_SET)) { + if ((H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS) && + (space->select.sel_info.hslab->unlim_dim >= 0) && (op != H5S_SELECT_SET)) { /* Check for invalid operation */ - if(unlim_dim >= 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot modify unlimited selection with another unlimited selection") - if(!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTA))) + if (unlim_dim >= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "cannot modify unlimited selection with another unlimited selection") + if (!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTA))) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported operation on unlimited selection") HDassert(space->select.sel_info.hslab->diminfo_valid); /* Clip unlimited selection to include new selection */ - if(H5S_hyper_clip_unlim(space, - start[space->select.sel_info.hslab->unlim_dim] - + ((opt_count[space->select.sel_info.hslab->unlim_dim] - (hsize_t)1) - * opt_stride[space->select.sel_info.hslab->unlim_dim]) - + opt_block[space->select.sel_info.hslab->unlim_dim]) < 0) + if (H5S_hyper_clip_unlim(space, + start[space->select.sel_info.hslab->unlim_dim] + + ((opt_count[space->select.sel_info.hslab->unlim_dim] - (hsize_t)1) * + opt_stride[space->select.sel_info.hslab->unlim_dim]) + + opt_block[space->select.sel_info.hslab->unlim_dim]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* If an empty space was returned it must be "none" */ @@ -9966,22 +10020,22 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], } /* end if */ /* Fixup operation for non-hyperslab selections */ - switch(H5S_GET_SELECT_TYPE(space)) { - case H5S_SEL_NONE: /* No elements selected in dataspace */ - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ + switch (H5S_GET_SELECT_TYPE(space)) { + case H5S_SEL_NONE: /* No elements selected in dataspace */ + switch (op) { + case H5S_SELECT_SET: /* Select "set" operation */ /* Change "none" selection to hyperslab selection */ break; - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ op = H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */ break; - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays "none" */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays "none" */ case H5S_SELECT_NOOP: case H5S_SELECT_APPEND: @@ -9992,43 +10046,44 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], } /* end switch */ break; - case H5S_SEL_ALL: /* All elements selected in dataspace */ - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ + case H5S_SEL_ALL: /* All elements selected in dataspace */ + switch (op) { + case H5S_SELECT_SET: /* Select "set" operation */ /* Change "all" selection to hyperslab selection */ break; - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays "all" */ + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays "all" */ - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ op = H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */ break; - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ /* Convert current "all" selection to "real" hyperslab selection */ /* Then allow operation to proceed */ { - const hsize_t *tmp_start; /* Temporary start information */ - const hsize_t *tmp_stride; /* Temporary stride information */ - const hsize_t *tmp_count; /* Temporary count information */ - const hsize_t *tmp_block; /* Temporary block information */ + const hsize_t *tmp_start; /* Temporary start information */ + const hsize_t *tmp_stride; /* Temporary stride information */ + const hsize_t *tmp_count; /* Temporary count information */ + const hsize_t *tmp_block; /* Temporary block information */ /* Set up temporary information for the dimensions */ - tmp_start = H5S_hyper_zeros_g; + tmp_start = H5S_hyper_zeros_g; tmp_stride = tmp_count = H5S_hyper_ones_g; - tmp_block = space->extent.size; + tmp_block = space->extent.size; /* Convert to hyperslab selection */ - if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + if (H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, + tmp_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") } /* end case */ break; - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ /* Convert to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_DONE(SUCCEED); @@ -10045,8 +10100,8 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], /* Hyperslab operation on hyperslab selection, OK */ break; - case H5S_SEL_POINTS: /* Can't combine hyperslab operations and point selections currently */ - if(op == H5S_SELECT_SET) /* Allow only "set" operation to proceed */ + case H5S_SEL_POINTS: /* Can't combine hyperslab operations and point selections currently */ + if (op == H5S_SELECT_SET) /* Allow only "set" operation to proceed */ break; /* Else fall through to error */ H5_ATTR_FALLTHROUGH @@ -10057,54 +10112,58 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") } /* end switch */ - if(op == H5S_SELECT_SET) { + if (op == H5S_SELECT_SET) { /* Set selection to regular hyperslab */ - if(H5S__set_regular_hyperslab(space, start, stride, count, block, opt_stride, opt_count, opt_block) < 0) + if (H5S__set_regular_hyperslab(space, start, stride, count, block, opt_stride, opt_count, opt_block) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection") } /* end if */ - else if(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA) { - hbool_t single_block; /* Whether the selection is a single block */ + else if (op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA) { + hbool_t single_block; /* Whether the selection is a single block */ /* Sanity check */ HDassert(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS); /* Handle unlimited selections */ - if(unlim_dim >= 0) { + if (unlim_dim >= 0) { hsize_t bounds_start[H5S_MAX_RANK]; hsize_t bounds_end[H5S_MAX_RANK]; hsize_t tmp_count = opt_count[unlim_dim]; hsize_t tmp_block = opt_block[unlim_dim]; /* Check for invalid operation */ - if(space->select.sel_info.hslab->unlim_dim >= 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot modify unlimited selection with another unlimited selection") - if(!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTB))) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported operation with unlimited selection") + if (space->select.sel_info.hslab->unlim_dim >= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "cannot modify unlimited selection with another unlimited selection") + if (!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTB))) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "unsupported operation with unlimited selection") /* Get bounds of existing selection */ - if(H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) + if (H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") /* Patch count and block to remove unlimited and include the * existing selection. */ - H5S__hyper_get_clip_diminfo(start[unlim_dim], opt_stride[unlim_dim], &tmp_count, &tmp_block, bounds_end[unlim_dim] + (hsize_t)1); + H5S__hyper_get_clip_diminfo(start[unlim_dim], opt_stride[unlim_dim], &tmp_count, &tmp_block, + bounds_end[unlim_dim] + (hsize_t)1); HDassert((tmp_count == 1) || (opt_count != H5S_hyper_ones_g)); HDassert((tmp_block == 1) || (opt_block != H5S_hyper_ones_g)); - if(opt_count != H5S_hyper_ones_g) { + if (opt_count != H5S_hyper_ones_g) { HDassert(opt_count == int_count); int_count[unlim_dim] = tmp_count; } /* end if */ - if(opt_block != H5S_hyper_ones_g) { + if (opt_block != H5S_hyper_ones_g) { HDassert(opt_block == int_block); int_block[unlim_dim] = tmp_block; } /* end if */ - } /* end if */ + } /* end if */ /* Check for a single block selected */ single_block = TRUE; - for(u = 0; u < space->extent.rank; u++) - if(1 != opt_count[u]) { + for (u = 0; u < space->extent.rank; u++) + if (1 != opt_count[u]) { single_block = FALSE; break; } /* end if */ @@ -10112,25 +10171,26 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], /* Check for single block "AND" operation on a regular hyperslab, which * is used for constructing chunk maps and can be optimized for. */ - if(H5S_SELECT_AND == op && single_block && - space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - if(H5S__hyper_regular_and_single_block(space, start, opt_block) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTOPERATE, FAIL, "can't 'AND' single block against regular hyperslab") + if (H5S_SELECT_AND == op && single_block && + space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + if (H5S__hyper_regular_and_single_block(space, start, opt_block) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTOPERATE, FAIL, + "can't 'AND' single block against regular hyperslab") } /* end if */ else { /* Check if there's no hyperslab span information currently */ - if(NULL == space->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans(space) < 0) + if (NULL == space->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree") /* Set selection type */ space->select.type = H5S_sel_hyper; /* Add in the new hyperslab information */ - if(H5S__generate_hyperslab(space, op, start, opt_stride, opt_count, opt_block) < 0) + if (H5S__generate_hyperslab(space, op, start, opt_stride, opt_count, opt_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs") } /* end else */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") @@ -10138,7 +10198,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_hyperslab() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_hyperslab @@ -10166,8 +10225,8 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], - const hsize_t stride[], const hsize_t count[], const hsize_t block[]) +H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], + const hsize_t count[], const hsize_t block[]) { H5S_t *space; /* Dataspace to modify selection of */ herr_t ret_value = SUCCEED; /* Return value */ @@ -10176,33 +10235,32 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], H5TRACE6("e", "iSs*h*h*h*h", space_id, op, start, stride, count, block); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_SCALAR == H5S_GET_EXTENT_TYPE(space)) + if (H5S_SCALAR == H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space") - if(H5S_NULL == H5S_GET_EXTENT_TYPE(space)) + if (H5S_NULL == H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space") - if(start == NULL || count == NULL) + if (start == NULL || count == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified") - if(!(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID)) + if (!(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") - if(stride != NULL) { - unsigned u; /* Local index variable */ + if (stride != NULL) { + unsigned u; /* Local index variable */ /* Check for 0-sized strides */ - for(u = 0; u < space->extent.rank; u++) - if(stride[u] == 0) + for (u = 0; u < space->extent.rank; u++) + if (stride[u] == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride==0 value") } /* end if */ - if(H5S_select_hyperslab(space, op, start, stride, count, block) < 0) + if (H5S_select_hyperslab(space, op, start, stride, count, block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_hyperslab() */ - /*-------------------------------------------------------------------------- NAME H5S_combine_hyperslab @@ -10234,12 +10292,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], - const hsize_t *stride, const hsize_t count[], const hsize_t *block, - H5S_t **new_space) +H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], const hsize_t *stride, + const hsize_t count[], const hsize_t *block, H5S_t **new_space) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -10252,39 +10309,39 @@ H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], HDassert(*new_space == NULL); /* Point to the correct stride values */ - if(stride == NULL) + if (stride == NULL) stride = H5S_hyper_ones_g; /* Point to the correct block values */ - if(block == NULL) + if (block == NULL) block = H5S_hyper_ones_g; /* Check new selection. */ - for(u = 0; u < old_space->extent.rank; u++) { + for (u = 0; u < old_space->extent.rank; u++) { /* Check for overlapping hyperslab blocks in new selection. */ - if(count[u] > 1 && stride[u] < block[u]) + if (count[u] > 1 && stride[u] < block[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap") /* Detect zero-sized hyperslabs in new selection */ - if(count[u] == 0 || block[u] == 0) { - switch(op) { - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + if (count[u] == 0 || block[u] == 0) { + switch (op) { + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ /* Convert to "none" selection */ /* Copy the first dataspace without sharing the list of spans */ - if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) + if (NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") - if(H5S_select_none((*new_space)) < 0) + if (H5S_select_none((*new_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_DONE(SUCCEED); - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ /* Copy the first dataspace with sharing the list of spans */ - if(NULL == ((*new_space) = H5S_copy(old_space, FALSE, TRUE))) + if (NULL == ((*new_space) = H5S_copy(old_space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") - HGOTO_DONE(SUCCEED); /* Selection stays same */ + HGOTO_DONE(SUCCEED); /* Selection stays same */ case H5S_SELECT_NOOP: case H5S_SELECT_SET: @@ -10294,92 +10351,95 @@ H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") } /* end switch */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ - if(H5S_GET_SELECT_TYPE(old_space) == H5S_SEL_HYPERSLABS) { - hsize_t *old_low_bounds; /* Pointer to old space's low & high bounds */ + if (H5S_GET_SELECT_TYPE(old_space) == H5S_SEL_HYPERSLABS) { + hsize_t *old_low_bounds; /* Pointer to old space's low & high bounds */ hsize_t *old_high_bounds; - hsize_t new_low_bounds[H5S_MAX_RANK]; /* New space's low & high bounds */ - hsize_t new_high_bounds[H5S_MAX_RANK]; - hbool_t overlapped = FALSE; + hsize_t new_low_bounds[H5S_MAX_RANK]; /* New space's low & high bounds */ + hsize_t new_high_bounds[H5S_MAX_RANK]; + hbool_t overlapped = FALSE; /* Set up old space's low & high bounds */ - if(old_space->select.sel_info.hslab->span_lst) { - old_low_bounds = old_space->select.sel_info.hslab->span_lst->low_bounds; + if (old_space->select.sel_info.hslab->span_lst) { + old_low_bounds = old_space->select.sel_info.hslab->span_lst->low_bounds; old_high_bounds = old_space->select.sel_info.hslab->span_lst->high_bounds; } /* end if */ else { - old_low_bounds = old_space->select.sel_info.hslab->diminfo.low_bounds; + old_low_bounds = old_space->select.sel_info.hslab->diminfo.low_bounds; old_high_bounds = old_space->select.sel_info.hslab->diminfo.high_bounds; } /* end else */ /* Generate bounding box for hyperslab parameters */ - for(u = 0; u < old_space->extent.rank; u++) { - new_low_bounds[u] = start[u]; + for (u = 0; u < old_space->extent.rank; u++) { + new_low_bounds[u] = start[u]; new_high_bounds[u] = start[u] + stride[u] * (count[u] - 1) + (block[u] - 1); } /* end for */ /* Check bound box of both spaces to see if they overlap */ - if(H5S_RANGE_OVERLAP(old_low_bounds[0], old_high_bounds[0], - new_low_bounds[0], new_high_bounds[0])) + if (H5S_RANGE_OVERLAP(old_low_bounds[0], old_high_bounds[0], new_low_bounds[0], new_high_bounds[0])) overlapped = TRUE; /* Non-overlapping situations can be handled in special ways */ - if(!overlapped) { + if (!overlapped) { H5S_hyper_span_info_t *new_spans = NULL; - H5S_hyper_dim_t new_hyper_diminfo[H5S_MAX_RANK]; + H5S_hyper_dim_t new_hyper_diminfo[H5S_MAX_RANK]; - if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) + if (NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") - if(NULL != (*new_space)->select.sel_info.hslab->span_lst) { + if (NULL != (*new_space)->select.sel_info.hslab->span_lst) { old_space->select.sel_info.hslab->span_lst->count--; (*new_space)->select.sel_info.hslab->span_lst = NULL; } /* end if */ /* Generate hyperslab info for new space */ - switch(op) { + switch (op) { case H5S_SELECT_OR: case H5S_SELECT_XOR: /* Add the new space to the space */ - if(NULL == (new_spans = H5S__hyper_make_spans(old_space->extent.rank, start, stride, count, block))) + if (NULL == (new_spans = H5S__hyper_make_spans(old_space->extent.rank, start, stride, + count, block))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information") - if(NULL != old_space->select.sel_info.hslab->span_lst) - (*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(old_space->select.sel_info.hslab->span_lst, old_space->extent.rank); - if(H5S__hyper_add_disjoint_spans(*new_space, new_spans) < 0) + if (NULL != old_space->select.sel_info.hslab->span_lst) + (*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span( + old_space->select.sel_info.hslab->span_lst, old_space->extent.rank); + if (H5S__hyper_add_disjoint_spans(*new_space, new_spans) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs") /* Build diminfo struct */ - for(u = 0; u < (*new_space)->extent.rank; u++) { - new_hyper_diminfo[u].start = start[u]; + for (u = 0; u < (*new_space)->extent.rank; u++) { + new_hyper_diminfo[u].start = start[u]; new_hyper_diminfo[u].stride = stride[u]; - new_hyper_diminfo[u].count = count[u]; - new_hyper_diminfo[u].block = block[u]; + new_hyper_diminfo[u].count = count[u]; + new_hyper_diminfo[u].block = block[u]; } /* end for */ /* Update space's dim info */ - if(H5S__hyper_update_diminfo(*new_space, op, new_hyper_diminfo) < 0) + if (H5S__hyper_update_diminfo(*new_space, op, new_hyper_diminfo) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info") break; case H5S_SELECT_AND: - if(H5S_select_none((*new_space)) < 0) + if (H5S_select_none((*new_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") break; case H5S_SELECT_NOTB: - if(NULL != old_space->select.sel_info.hslab->span_lst) { - if(NULL == ((*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(old_space->select.sel_info.hslab->span_lst, old_space->extent.rank))) + if (NULL != old_space->select.sel_info.hslab->span_lst) { + if (NULL == ((*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span( + old_space->select.sel_info.hslab->span_lst, old_space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") } /* end if */ else { - if(H5S_select_none((*new_space)) < 0) + if (H5S_select_none((*new_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end else */ break; case H5S_SELECT_NOTA: - if(H5S__set_regular_hyperslab(*new_space, start, stride, count, block, stride, count, block) < 0) + if (H5S__set_regular_hyperslab(*new_space, start, stride, count, block, stride, count, + block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular selection") break; @@ -10394,21 +10454,20 @@ H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], HGOTO_DONE(SUCCEED); } /* end if(!overlapped) */ - } /* end if the selection of old space is H5S_SEL_HYPERSLABS */ + } /* end if the selection of old space is H5S_SEL_HYPERSLABS */ /* Copy the first dataspace with sharing the list of spans */ - if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) + if (NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") /* Note: a little overhead in calling the function as some conditions are checked again */ - if(H5S_select_hyperslab(*new_space, op, start, stride, count, block) < 0) + if (H5S_select_hyperslab(*new_space, op, start, stride, count, block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_combine_hyperslab() */ - /*------------------------------------------------------------------------- * Function: H5S__fill_in_select * @@ -10427,7 +10486,7 @@ H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **resu { hbool_t span2_owned; hbool_t updated_spans; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -10442,15 +10501,16 @@ H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **resu HDassert(space2->select.sel_info.hslab->span_lst); /* Note: the offset of space2 is not considered here for bounding box */ - if(H5S__fill_in_new_space(space1, op, space2->select.sel_info.hslab->span_lst, FALSE, &span2_owned, &updated_spans, result) < 0) + if (H5S__fill_in_new_space(space1, op, space2->select.sel_info.hslab->span_lst, FALSE, &span2_owned, + &updated_spans, result) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't create the specified selection") /* Update diminfo if space2's diminfo was valid, otherwise just mark it as * invalid if the spans were updated */ HDassert(result); - if(updated_spans) { - if(space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - if(H5S__hyper_update_diminfo(*result, op, space2->select.sel_info.hslab->diminfo.opt) < 0) + if (updated_spans) { + if (space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + if (H5S__hyper_update_diminfo(*result, op, space2->select.sel_info.hslab->diminfo.opt) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info") } /* end if */ else @@ -10461,7 +10521,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__fill_in_select() */ - /*-------------------------------------------------------------------------- NAME H5Scombine_hyperslab @@ -10492,40 +10551,39 @@ done: REVISION LOG --------------------------------------------------------------------------*/ hid_t -H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], - const hsize_t stride[], const hsize_t count[], const hsize_t block[]) +H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], + const hsize_t count[], const hsize_t block[]) { - H5S_t *space; /* Dataspace to modify selection of */ - H5S_t *new_space = NULL; /* New dataspace created */ - hid_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to modify selection of */ + H5S_t *new_space = NULL; /* New dataspace created */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "iSs*h*h*h*h", space_id, op, start, stride, count, block); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") - if(start == NULL || count == NULL) + if (start == NULL || count == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "hyperslab not specified") - if(!(op >= H5S_SELECT_SET && op <= H5S_SELECT_NOTA)) + if (!(op >= H5S_SELECT_SET && op <= H5S_SELECT_NOTA)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, H5I_INVALID_HID, "invalid selection operation") /* Generate new space, with combination of selections */ - if(H5S_combine_hyperslab(space, op, start, stride, count, block, &new_space) < 0) + if (H5S_combine_hyperslab(space, op, start, stride, count, block, &new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to set hyperslab selection") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: - if(ret_value < 0 && new_space) + if (ret_value < 0 && new_space) H5S_close(new_space); FUNC_LEAVE_API(ret_value) } /* end H5Scombine_hyperslab() */ - /*------------------------------------------------------------------------- * Function: H5S__combine_select * @@ -10541,8 +10599,8 @@ done: static H5S_t * H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) { - H5S_t *new_space = NULL; /* New dataspace generated */ - H5S_t *ret_value = NULL; /* Return value */ + H5S_t *new_space = NULL; /* New dataspace generated */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -10552,31 +10610,31 @@ H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) HDassert(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA); /* Check if space1 selections has span trees */ - if(NULL == space1->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans(space1) < 0) + if (NULL == space1->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans(space1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, NULL, "dataspace does not have span tree") - if(NULL == space2->select.sel_info.hslab->span_lst) { - hsize_t tmp_start[H5S_MAX_RANK]; - hsize_t tmp_stride[H5S_MAX_RANK]; - hsize_t tmp_count[H5S_MAX_RANK]; - hsize_t tmp_block[H5S_MAX_RANK]; + if (NULL == space2->select.sel_info.hslab->span_lst) { + hsize_t tmp_start[H5S_MAX_RANK]; + hsize_t tmp_stride[H5S_MAX_RANK]; + hsize_t tmp_count[H5S_MAX_RANK]; + hsize_t tmp_block[H5S_MAX_RANK]; unsigned u; - for(u = 0; u < space2->extent.rank; u++) { - tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start; + for (u = 0; u < space2->extent.rank; u++) { + tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start; tmp_stride[u] = space2->select.sel_info.hslab->diminfo.opt[u].stride; - tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count; - tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block; + tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count; + tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block; } /* end for */ /* Combine hyperslab selection with regular selection directly */ - if(H5S_combine_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block, &new_space) < 0) + if (H5S_combine_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block, &new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to set hyperslab selection") } /* end if */ - else{ + else { /* Combine new_space (a copy of space 1) & space2, with the result in new_space */ - if(H5S__fill_in_select(space1, op, space2, &new_space) < 0) + if (H5S__fill_in_select(space1, op, space2, &new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, NULL, "can't clip hyperslab information") } /* end else */ @@ -10587,13 +10645,12 @@ H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) ret_value = new_space; done: - if(ret_value == NULL && new_space) + if (ret_value == NULL && new_space) H5S_close(new_space); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__combine_select() */ - /*-------------------------------------------------------------------------- NAME H5Scombine_select @@ -10619,27 +10676,27 @@ done: hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) { - H5S_t *space1; /* First Dataspace */ - H5S_t *space2; /* Second Dataspace */ - H5S_t *new_space = NULL; /* New Dataspace */ - hid_t ret_value; /* Return value */ + H5S_t *space1; /* First Dataspace */ + H5S_t *space2; /* Second Dataspace */ + H5S_t *new_space = NULL; /* New Dataspace */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iSsi", space1_id, op, space2_id); /* Check args */ - if(NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) + if (NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") - if(NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + if (NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") - if(!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA)) + if (!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, H5I_INVALID_HID, "invalid selection operation") /* Check that both dataspaces have the same rank */ - if(space1->extent.rank != space2->extent.rank) + if (space1->extent.rank != space2->extent.rank) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dataspaces not same rank") - /* Note: currently, the offset of each dataspace is ignored */ + /* Note: currently, the offset of each dataspace is ignored */ #if 0 /* Check that both dataspaces have the same offset */ /* Same note as in H5Smodify_select */ @@ -10650,25 +10707,25 @@ H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) #endif /* Check that both dataspaces have hyperslab selections */ - if(H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || + H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dataspaces don't have hyperslab selections") /* Go combine the dataspaces */ - if(NULL == (new_space = H5S__combine_select(space1, op, space2))) + if (NULL == (new_space = H5S__combine_select(space1, op, space2))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to create hyperslab selection") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: - if(ret_value < 0 && new_space) + if (ret_value < 0 && new_space) H5S_close(new_space); FUNC_LEAVE_API(ret_value) } /* end H5Scombine_select() */ - /*------------------------------------------------------------------------- * Function: H5S__modify_select * @@ -10684,7 +10741,7 @@ done: herr_t H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -10694,41 +10751,40 @@ H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) HDassert(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA); /* Check that the space selections both have span trees */ - if(NULL == space1->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans(space1) < 0) + if (NULL == space1->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans(space1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree") /* Set unlim_dim */ space1->select.sel_info.hslab->unlim_dim = -1; - if(NULL == space2->select.sel_info.hslab->span_lst) { - hsize_t tmp_start[H5S_MAX_RANK]; - hsize_t tmp_stride[H5S_MAX_RANK]; - hsize_t tmp_count[H5S_MAX_RANK]; - hsize_t tmp_block[H5S_MAX_RANK]; + if (NULL == space2->select.sel_info.hslab->span_lst) { + hsize_t tmp_start[H5S_MAX_RANK]; + hsize_t tmp_stride[H5S_MAX_RANK]; + hsize_t tmp_count[H5S_MAX_RANK]; + hsize_t tmp_block[H5S_MAX_RANK]; unsigned u; - for(u = 0; u < space2->extent.rank; u++) { - tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start; + for (u = 0; u < space2->extent.rank; u++) { + tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start; tmp_stride[u] = space2->select.sel_info.hslab->diminfo.opt[u].stride; - tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count; - tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block; + tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count; + tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block; } /* end for */ /* Call H5S_select_hyperslab directly */ - if(H5S_select_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + if (H5S_select_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection") } /* end if */ else /* Combine spans from space1 & spans from space2, with the result in space1 */ - if(H5S__fill_in_select(space1, op, space2, &space1) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't perform operation on two selections") + if (H5S__fill_in_select(space1, op, space2, &space1) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't perform operation on two selections") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__modify_select() */ - /*-------------------------------------------------------------------------- NAME H5Smodify_select @@ -10754,43 +10810,43 @@ done: herr_t H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) { - H5S_t *space1; /* First Dataspace */ - H5S_t *space2; /* Second Dataspace */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space1; /* First Dataspace */ + H5S_t *space2; /* Second Dataspace */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iSsi", space1_id, op, space2_id); /* Check args */ - if(NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) + if (NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + if (NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA)) + if (!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") /* Check that both dataspaces have the same rank */ - if(space1->extent.rank != space2->extent.rank) + if (space1->extent.rank != space2->extent.rank) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same rank") - /* Check that both dataspaces have the same offset */ - /** Note that this is a tricky part of this function. It's - * possible that two dataspaces have different "offset". If the - * space2 has smaller offset value than that of space1 in a - * dimension, then the span elements of this dimension in - * space2 could have negative "low" and "high" values relative - * to the offset in space1. In other words, if the bounds of - * span elements in space2 are adjusted relative to the offset - * in space1, then every span element's bound is computed as - * "origin_bound+offset2-offset1". Therefore, if offset2 (the - * offset of space2) is smaller, then - * "origin_bound+offset2-offset1" could be negative which is - * not allowed by the bound type declaration as hsize_t! - * As a result, if the op is an OR selection, then the final - * result may contain span elements that have negative bound! - * So right now, the difference in the offset is totally - * ignored!! - */ + /* Check that both dataspaces have the same offset */ + /** Note that this is a tricky part of this function. It's + * possible that two dataspaces have different "offset". If the + * space2 has smaller offset value than that of space1 in a + * dimension, then the span elements of this dimension in + * space2 could have negative "low" and "high" values relative + * to the offset in space1. In other words, if the bounds of + * span elements in space2 are adjusted relative to the offset + * in space1, then every span element's bound is computed as + * "origin_bound+offset2-offset1". Therefore, if offset2 (the + * offset of space2) is smaller, then + * "origin_bound+offset2-offset1" could be negative which is + * not allowed by the bound type declaration as hsize_t! + * As a result, if the op is an OR selection, then the final + * result may contain span elements that have negative bound! + * So right now, the difference in the offset is totally + * ignored!! + */ #if 0 for(u=0; uextent.rank; u++) { if(space1->select.offset[u] != space2->select.offset[u]) @@ -10799,18 +10855,18 @@ H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) #endif /* Check that both dataspaces have hyperslab selections */ - if(H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || + H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections") /* Go refine the first selection */ - if(H5S__modify_select(space1, op, space2) < 0) + if (H5S__modify_select(space1, op, space2) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to modify hyperslab selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Smodify_select() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_proj_int_build_proj @@ -10833,9 +10889,10 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { - H5S_hyper_span_info_t *copied_span_info = NULL; /* Temporary span info pointer */ - herr_t ret_value = SUCCEED; /* Return value */ +H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) +{ + H5S_hyper_span_info_t *copied_span_info = NULL; /* Temporary span info pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -10844,35 +10901,37 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { /* * Skip over skipped elements */ - if(udata->skip > 0) { + if (udata->skip > 0) { /* Work upwards, finishing each span tree before moving up */ HDassert(udata->ds_span[udata->depth]); do { /* Check for lowest dimension */ - if(udata->ds_span[udata->depth]->down) { - if(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) { + if (udata->ds_span[udata->depth]->down) { + if (udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) { /* If we will run out of elements to skip in this span, * advance to the first not fully skipped span and break * out of this loop (start moving downwards) */ - if(udata->skip < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - udata->ds_low[udata->depth] += udata->skip / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; + if (udata->skip < + H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + udata->ds_low[udata->depth] += + udata->skip / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->skip %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; break; } /* end if */ /* Skip over this entire span */ - udata->skip -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); + udata->skip -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(udata->ds_rank - udata->depth == 1); /* If we will run out of elements to skip in this span, * skip the remainder of the skipped elements and break out */ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high); - if(udata->skip < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (udata->skip < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { udata->ds_low[udata->depth] += udata->skip; udata->skip = 0; break; @@ -10884,15 +10943,15 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { /* Advance to next span */ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; - if(udata->ds_span[udata->depth]) + if (udata->ds_span[udata->depth]) udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - else if(udata->depth > 0) { + else if (udata->depth > 0) { /* If present, append this span tree to the higher dimension's, * and release ownership of it */ - if(udata->ps_span_info[udata->depth]) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth - 1], - udata->ds_rank - udata->depth + 1, udata->ds_low[udata->depth - 1], - udata->ds_low[udata->depth - 1], + if (udata->ps_span_info[udata->depth]) { + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth - 1], udata->ds_rank - udata->depth + 1, + udata->ds_low[udata->depth - 1], udata->ds_low[udata->depth - 1], udata->ps_span_info[udata->depth]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]); @@ -10905,44 +10964,47 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { udata->ds_low[udata->depth]++; } /* end if */ else - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "insufficient elements in destination selection") - } while((udata->skip > 0) - || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high)); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "insufficient elements in destination selection") + } while ((udata->skip > 0) || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high)); /* Work downwards until skip is 0 */ HDassert(udata->ds_span[udata->depth]); - while(udata->skip > 0) { + while (udata->skip > 0) { HDassert(udata->ds_span[udata->depth]->down); udata->depth++; udata->ds_span[udata->depth] = udata->ds_span[udata->depth - 1]->down->head; - udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - if(udata->ds_span[udata->depth]->down) { + udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; + if (udata->ds_span[udata->depth]->down) { do { /* If we will run out of elements to skip in this span, * advance to the first not fully skipped span and * continue down */ - if(udata->skip < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - udata->ds_low[udata->depth] += udata->skip / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; + if (udata->skip < + H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + udata->ds_low[udata->depth] += + udata->skip / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->skip %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; break; } /* end if */ /* Skip over this entire span */ - udata->skip -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); + udata->skip -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); /* Advance to next span */ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - } while(udata->skip > 0); + } while (udata->skip > 0); } /* end if */ else { do { /* If we will run out of elements to skip in this span, * skip the remainder of the skipped elements */ - if(udata->skip < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (udata->skip < + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { udata->ds_low[udata->depth] += udata->skip; udata->skip = 0; break; @@ -10955,10 +11017,10 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - } while(udata->skip > 0); + } while (udata->skip > 0); } /* end else */ - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ /* * Add requested number of elements to projected space @@ -10968,77 +11030,92 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { HDassert(udata->ds_span[udata->depth]); do { /* Check for lowest dimension */ - if(udata->ds_span[udata->depth]->down) { - if(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) { + if (udata->ds_span[udata->depth]->down) { + if (udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) { /* If we will run out of elements to add in this span, add * any complete spans, advance to the first not fully added * span, and break out of this loop (start moving downwards) */ - if(udata->nelem < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - if(udata->nelem >= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) { - if(udata->share_selection) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - 1, + if (udata->nelem < + H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (udata->nelem >= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) { + if (udata->share_selection) { + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth], udata->ds_rank - udata->depth, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + + (udata->nelem / + udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - + 1, udata->ds_span[udata->depth]->down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it * afterwards) */ - if(NULL == (copied_span_info = H5S__hyper_copy_span_helper(udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, udata->op_gen))) + if (NULL == (copied_span_info = H5S__hyper_copy_span_helper( + udata->ds_span[udata->depth]->down, + udata->ds_rank - udata->depth, 1, udata->op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination spans") - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - 1, + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth], udata->ds_rank - udata->depth, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + + (udata->nelem / + udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - + 1, copied_span_info) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; } /* end else */ - udata->ds_low[udata->depth] += udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; + udata->ds_low[udata->depth] += + udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->nelem %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; } /* end if */ break; } /* end if */ /* Append span tree for entire span */ - if(udata->share_selection) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_span[udata->depth]->high, - udata->ds_span[udata->depth]->down) < 0) + if (udata->share_selection) { + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], + udata->ds_rank - udata->depth, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, + udata->ds_span[udata->depth]->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") } /* end if */ else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it * afterwards) */ - if(NULL == (copied_span_info = H5S__hyper_copy_span_helper(udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, udata->op_gen))) + if (NULL == (copied_span_info = H5S__hyper_copy_span_helper( + udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, + udata->op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination spans") - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_span[udata->depth]->high, - copied_span_info) < 0) + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], + udata->ds_rank - udata->depth, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, copied_span_info) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; } /* end else */ - udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); + udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(udata->ds_rank - udata->depth == 1); /* If we will run out of elements to add in this span, add the * remainder of the elements and break out */ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high); - if(udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, - udata->ds_low[udata->depth], udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0) + if (udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") udata->ds_low[udata->depth] += udata->nelem; udata->nelem = 0; @@ -11046,24 +11123,24 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { } /* end if */ /* Append span tree for entire span */ - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, - udata->ds_low[udata->depth], udata->ds_span[udata->depth]->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") udata->nelem -= udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1; } /* end else */ /* Advance to next span */ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; - if(udata->ds_span[udata->depth]) + if (udata->ds_span[udata->depth]) udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - else if(udata->depth > 0) { + else if (udata->depth > 0) { /* Append this span tree to the higher dimension's, and release * ownership of it */ HDassert(udata->ps_span_info[udata->depth]); - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth - 1], - udata->ds_rank - udata->depth + 1, udata->ds_low[udata->depth - 1], - udata->ds_low[udata->depth - 1], - udata->ps_span_info[udata->depth]) < 0) + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth - 1], + udata->ds_rank - udata->depth + 1, udata->ds_low[udata->depth - 1], + udata->ds_low[udata->depth - 1], + udata->ps_span_info[udata->depth]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]); udata->ps_span_info[udata->depth] = NULL; @@ -11076,87 +11153,102 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { else { /* We have finished the entire destination span tree. If there are * still elements to add, issue an error. */ - if(udata->nelem > 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "insufficient elements in destination selection") + if (udata->nelem > 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "insufficient elements in destination selection") break; } /* end else */ - } while((udata->nelem > 0) - || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high)); + } while ((udata->nelem > 0) || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high)); /* Work downwards until nelem is 0 */ HDassert(udata->ds_span[udata->depth] || (udata->nelem == 0)); - while(udata->nelem > 0) { + while (udata->nelem > 0) { HDassert(udata->ds_span[udata->depth]->down); udata->depth++; udata->ds_span[udata->depth] = udata->ds_span[udata->depth - 1]->down->head; - udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - if(udata->ds_span[udata->depth]->down) { + udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; + if (udata->ds_span[udata->depth]->down) { do { /* If we will run out of elements to add in this span, add * any complete spans, advance to the first not fully added * span and continue down */ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high); - if(udata->nelem < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - if(udata->nelem >= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) { - if(udata->share_selection) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - 1, + if (udata->nelem < + H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (udata->nelem >= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) { + if (udata->share_selection) { + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth], udata->ds_rank - udata->depth, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + + (udata->nelem / + udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - + 1, udata->ds_span[udata->depth]->down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it * afterwards) */ - if(NULL == (copied_span_info = H5S__hyper_copy_span_helper(udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, udata->op_gen))) + if (NULL == (copied_span_info = H5S__hyper_copy_span_helper( + udata->ds_span[udata->depth]->down, + udata->ds_rank - udata->depth, 1, udata->op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination spans") - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - 1, + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth], udata->ds_rank - udata->depth, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + + (udata->nelem / + udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - + 1, copied_span_info) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; } /* end else */ - udata->ds_low[udata->depth] += udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; + udata->ds_low[udata->depth] += + udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->nelem %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; } /* end if */ break; } /* end if */ /* Append span tree for entire span */ - if(udata->share_selection) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_span[udata->depth]->high, - udata->ds_span[udata->depth]->down) < 0) + if (udata->share_selection) { + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], + udata->ds_rank - udata->depth, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, + udata->ds_span[udata->depth]->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") } /* end if */ else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it * afterwards) */ - if(NULL == (copied_span_info = H5S__hyper_copy_span_helper(udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, udata->op_gen))) + if (NULL == (copied_span_info = H5S__hyper_copy_span_helper( + udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, + udata->op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination spans") - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_span[udata->depth]->high, - copied_span_info) < 0) + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], + udata->ds_rank - udata->depth, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, copied_span_info) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; } /* end else */ - udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); + udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); /* Advance to next span */ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - } while(udata->nelem > 0); + } while (udata->nelem > 0); } /* end if */ else { HDassert(udata->ds_rank - udata->depth == 1); @@ -11164,9 +11256,10 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { /* If we will run out of elements to add in this span, add * the remainder of the elements and break out */ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high); - if(udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, - udata->ds_low[udata->depth], udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0) + if (udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") udata->ds_low[udata->depth] += udata->nelem; udata->nelem = 0; @@ -11174,8 +11267,8 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { } /* end if */ /* Append span tree for entire span */ - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, - udata->ds_low[udata->depth], udata->ds_span[udata->depth]->high, NULL) < 0) + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") udata->nelem -= udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1; @@ -11183,9 +11276,9 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - } while(udata->nelem > 0); + } while (udata->nelem > 0); } /* end else */ - } /* end while */ + } /* end while */ HDassert(udata->skip == 0); HDassert(udata->nelem == 0); @@ -11195,7 +11288,7 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { done: /* Cleanup on failure */ - if(copied_span_info) { + if (copied_span_info) { HDassert(ret_value < 0); H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; @@ -11204,7 +11297,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_proj_int_build_proj() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_proj_int_iterate @@ -11214,8 +11306,8 @@ done: herr_t H5S__hyper_proj_int_iterate(ss_span_info,sis_span_info,count,depth,udata) const H5S_hyper_span_info_t *ss_span_info; IN: Span tree for source selection const H5S_hyper_span_info_t *sis_span_info; IN: Span tree for source intersect selection - hsize_t count; IN: Number of times to compute the intersection of ss_span_info and sis_span_info - unsigned depth; IN: Depth of iteration (in terms of rank) + hsize_t count; IN: Number of times to compute the intersection of ss_span_info and +sis_span_info unsigned depth; IN: Depth of iteration (in terms of rank) H5S_hyper_project_intersect_ud_t *udata; IN/OUT: Persistent shared data for iteration RETURNS Non-negative on success/Negative on failure. @@ -11235,75 +11327,78 @@ done: --------------------------------------------------------------------------*/ static herr_t H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, - const H5S_hyper_span_info_t *sis_span_info, hsize_t count, unsigned depth, - H5S_hyper_project_intersect_ud_t *udata) + const H5S_hyper_span_info_t *sis_span_info, hsize_t count, unsigned depth, + H5S_hyper_project_intersect_ud_t *udata) { - const H5S_hyper_span_t *ss_span; /* Current span in source space */ - const H5S_hyper_span_t *sis_span; /* Current span in source intersect space */ - hsize_t ss_low; /* Current low bounds of source span */ - hsize_t sis_low; /* Current low bounds of source intersect span */ - hsize_t high; /* High bounds of current intersection */ - hsize_t low; /* Low bounds of current intersection */ - hsize_t old_skip; /* Value of udata->skip before main loop */ - hsize_t old_nelem; /* Value of udata->nelem before main loop */ - hbool_t check_intersect; /* Whether to check for intersecting elements */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5S_hyper_span_t *ss_span; /* Current span in source space */ + const H5S_hyper_span_t *sis_span; /* Current span in source intersect space */ + hsize_t ss_low; /* Current low bounds of source span */ + hsize_t sis_low; /* Current low bounds of source intersect span */ + hsize_t high; /* High bounds of current intersection */ + hsize_t low; /* Low bounds of current intersection */ + hsize_t old_skip; /* Value of udata->skip before main loop */ + hsize_t old_nelem; /* Value of udata->nelem before main loop */ + hbool_t check_intersect; /* Whether to check for intersecting elements */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for non-overlapping bounds */ check_intersect = TRUE; - for(u = 0; u < (udata->ss_rank - depth); u++) - if(!H5S_RANGE_OVERLAP(ss_span_info->low_bounds[u], - ss_span_info->high_bounds[u], - sis_span_info->low_bounds[u], - sis_span_info->high_bounds[u])) { + for (u = 0; u < (udata->ss_rank - depth); u++) + if (!H5S_RANGE_OVERLAP(ss_span_info->low_bounds[u], ss_span_info->high_bounds[u], + sis_span_info->low_bounds[u], sis_span_info->high_bounds[u])) { check_intersect = FALSE; break; } /* end if */ /* Only enter main loop if there's something to do */ - if(check_intersect) { + if (check_intersect) { /* Set ps_clean_bitmap */ udata->ps_clean_bitmap |= (((uint32_t)1) << depth); /* Save old skip and nelem */ - old_skip = udata->skip; + old_skip = udata->skip; old_nelem = udata->nelem; /* Intersect spaces once per count */ - for(u = 0; u < count; u++) { - ss_span = ss_span_info->head; + for (u = 0; u < count; u++) { + ss_span = ss_span_info->head; sis_span = sis_span_info->head; HDassert(ss_span && sis_span); - ss_low = ss_span->low; + ss_low = ss_span->low; sis_low = sis_span->low; /* Main loop */ do { /* Check if spans overlap */ - if(H5S_RANGE_OVERLAP(ss_low, ss_span->high, - sis_low, sis_span->high)) { + if (H5S_RANGE_OVERLAP(ss_low, ss_span->high, sis_low, sis_span->high)) { high = MIN(ss_span->high, sis_span->high); - if(ss_span->down) { + if (ss_span->down) { /* Add skipped elements if there's a pre-gap */ - if(ss_low < sis_low) { + if (ss_low < sis_low) { low = sis_low; - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * (sis_low - ss_low), FAIL); + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * + (sis_low - ss_low), + FAIL); } /* end if */ else low = ss_low; /* Recurse into next dimension down */ - if(H5S__hyper_proj_int_iterate(ss_span->down, sis_span->down, high - low + 1, depth + 1, udata) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't iterate over source selections") + if (H5S__hyper_proj_int_iterate(ss_span->down, sis_span->down, high - low + 1, + depth + 1, udata) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, + "can't iterate over source selections") } /* end if */ else { HDassert(depth == udata->ss_rank - 1); /* Add skipped elements if there's a pre-gap */ - if(ss_low < sis_low) { + if (ss_low < sis_low) { low = sis_low; H5S_HYPER_PROJ_INT_ADD_SKIP(udata, sis_low - ss_low, FAIL); } /* end if */ @@ -11315,87 +11410,99 @@ H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, } /* end else */ /* Advance spans */ - if(ss_span->high == sis_span->high) { + if (ss_span->high == sis_span->high) { /* Advance both spans */ ss_span = ss_span->next; - if(ss_span) + if (ss_span) ss_low = ss_span->low; sis_span = sis_span->next; - if(sis_span) + if (sis_span) sis_low = sis_span->low; } /* end if */ - else if(ss_span->high == high) { + else if (ss_span->high == high) { /* Advance source span */ HDassert(ss_span->high < sis_span->high); sis_low = high + 1; ss_span = ss_span->next; - if(ss_span) + if (ss_span) ss_low = ss_span->low; } /* end if */ else { /* Advance source intersect span */ HDassert(ss_span->high > sis_span->high); - ss_low = high + 1; + ss_low = high + 1; sis_span = sis_span->next; - if(sis_span) + if (sis_span) sis_low = sis_span->low; } /* end else */ - } /* end if */ + } /* end if */ else { /* Advance spans */ - if(ss_span->high < sis_low) { + if (ss_span->high < sis_low) { /* Add skipped elements */ - if(ss_span->down) - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * (ss_span->high - ss_low + 1), FAIL); + if (ss_span->down) + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * + (ss_span->high - ss_low + 1), + FAIL); else H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_low + 1, FAIL); /* Advance source span */ ss_span = ss_span->next; - if(ss_span) + if (ss_span) ss_low = ss_span->low; } /* end if */ else { /* Advance source intersect span */ HDassert(ss_low > sis_span->high); sis_span = sis_span->next; - if(sis_span) + if (sis_span) sis_low = sis_span->low; } /* end else */ - } /* end else */ - } while(ss_span && sis_span); + } /* end else */ + } while (ss_span && sis_span); - if(ss_span && !((depth == 0) && (u == count - 1))) { + if (ss_span && !((depth == 0) && (u == count - 1))) { /* Count remaining elements in ss_span_info */ - if(ss_span->down) { - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * (ss_span->high - ss_low + 1), FAIL); + if (ss_span->down) { + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * + (ss_span->high - ss_low + 1), + FAIL); ss_span = ss_span->next; - while(ss_span) { - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * (ss_span->high - ss_span->low + 1), FAIL); + while (ss_span) { + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * + (ss_span->high - ss_span->low + 1), + FAIL); ss_span = ss_span->next; } /* end while */ - } /* end if */ + } /* end if */ else { H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_low + 1, FAIL); ss_span = ss_span->next; - while(ss_span) { + while (ss_span) { H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_span->low + 1, FAIL); ss_span = ss_span->next; } /* end while */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Check if the projected space was not changed since we started the * first iteration of the loop, if so we do not need to continue * looping and can just copy the result */ - if(udata->ps_clean_bitmap & (((uint32_t)1) << depth)) { + if (udata->ps_clean_bitmap & (((uint32_t)1) << depth)) { HDassert(u == 0); - if(udata->skip == old_skip) { + if (udata->skip == old_skip) { /* First case: algorithm added only elements */ HDassert(udata->nelem >= old_nelem); udata->nelem += (count - 1) * (udata->nelem - old_nelem); } /* end if */ - else if(udata->nelem == 0) { + else if (udata->nelem == 0) { /* Second case: algorithm added only skip. In this case, * nelem must be 0 since otherwise adding skip would have * triggered a change in the projected space */ @@ -11414,48 +11521,49 @@ H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, HDassert(udata->skip > old_skip); HDassert(old_nelem == 0); - skip_add = udata->skip - old_skip; + skip_add = udata->skip - old_skip; nelem_add = udata->nelem - old_nelem; - for(u = 1; u < count; u++) { + for (u = 1; u < count; u++) { H5S_HYPER_PROJ_INT_ADD_SKIP(udata, skip_add, FAIL); udata->nelem += nelem_add; } /* end for */ - } /* end else */ + } /* end else */ /* End loop since we already took care of it */ break; } /* end if */ - } /* end for */ - } /* end if */ - else if(depth > 0) + } /* end for */ + } /* end if */ + else if (depth > 0) /* Just count skipped elements */ - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper((H5S_hyper_span_info_t *)ss_span_info, 0, udata->op_gen) * count, FAIL); /* Casting away const OK -NAF */ + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper((H5S_hyper_span_info_t *)ss_span_info, 0, udata->op_gen) * count, + FAIL); /* Casting away const OK -NAF */ /* Clean up if we are done */ - if(depth == 0) { + if (depth == 0) { /* Add remaining elements */ - if(udata->nelem > 0) - if(H5S__hyper_proj_int_build_proj(udata) < 0) + if (udata->nelem > 0) + if (H5S__hyper_proj_int_build_proj(udata) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't add elements to projected selection") /* Append remaining span trees */ - for(u = udata->ds_rank - 1; u > 0; u--) - if(udata->ps_span_info[u]) { - if(H5S__hyper_append_span(&udata->ps_span_info[u - 1], - udata->ds_rank - u + 1, udata->ds_low[u - 1], - udata->ds_low[u - 1], - udata->ps_span_info[u]) < 0) + for (u = udata->ds_rank - 1; u > 0; u--) + if (udata->ps_span_info[u]) { + if (H5S__hyper_append_span(&udata->ps_span_info[u - 1], udata->ds_rank - u + 1, + udata->ds_low[u - 1], udata->ds_low[u - 1], + udata->ps_span_info[u]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(udata->ps_span_info[u]); udata->ps_span_info[u] = NULL; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_proj_int_iterate() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_project_intersection @@ -11465,38 +11573,29 @@ done: within the selection of dst_space USAGE herr_t H5S__hyper_project_intersection(src_space,dst_space,src_intersect_space,proj_space,share_selection) - H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with src_intersect_space - H5S_t *dst_space; IN: Selection that is mapped to src_space, and which contains the result - H5S_t *src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space to obtain the result - H5S_t *proj_space; OUT: Will contain the result (intersection of src_intersect_space and src_space projected from src_space to dst_space) after the operation - hbool_t share_selection; IN: Whether we are allowed to share structures inside dst_space with proj_space - RETURNS - Non-negative on success/Negative on failure. - DESCRIPTION - Projects the intersection of of the selections of src_space and - src_intersect_space within the selection of src_space as a selection - within the selection of dst_space. The result is placed in the selection - of proj_space. Note src_space, dst_space, and src_intersect_space do not - need to use hyperslab selections, but they cannot use point selections. - The result is always a hyperslab or none selection. Note also that - proj_space can share some span trees with dst_space, so proj_space - must not be subsequently modified if dst_space must be preserved. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG + H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with +src_intersect_space H5S_t *dst_space; IN: Selection that is mapped to src_space, and which contains the +result H5S_t *src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space +to obtain the result H5S_t *proj_space; OUT: Will contain the result (intersection of src_intersect_space +and src_space projected from src_space to dst_space) after the operation hbool_t share_selection; IN: Whether +we are allowed to share structures inside dst_space with proj_space RETURNS Non-negative on success/Negative +on failure. DESCRIPTION Projects the intersection of of the selections of src_space and src_intersect_space +within the selection of src_space as a selection within the selection of dst_space. The result is placed in +the selection of proj_space. Note src_space, dst_space, and src_intersect_space do not need to use hyperslab +selections, but they cannot use point selections. The result is always a hyperslab or none selection. Note +also that proj_space can share some span trees with dst_space, so proj_space must not be subsequently modified +if dst_space must be preserved. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, - const H5S_t *src_intersect_space, H5S_t *proj_space, - hbool_t share_selection) + const H5S_t *src_intersect_space, H5S_t *proj_space, hbool_t share_selection) { - H5S_hyper_project_intersect_ud_t udata; /* User data for subroutines */ - const H5S_hyper_span_info_t *ss_span_info; - const H5S_hyper_span_info_t *ds_span_info; - H5S_hyper_span_info_t *ss_span_info_buf = NULL; - H5S_hyper_span_info_t *ds_span_info_buf = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_project_intersect_ud_t udata; /* User data for subroutines */ + const H5S_hyper_span_info_t * ss_span_info; + const H5S_hyper_span_info_t * ds_span_info; + H5S_hyper_span_info_t * ss_span_info_buf = NULL; + H5S_hyper_span_info_t * ds_span_info_buf = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -11515,11 +11614,12 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_HYPERSLABS); /* Set up ss_span_info */ - if(H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_HYPERSLABS) { + if (H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_HYPERSLABS) { /* Make certain the selection has a span tree */ - if(NULL == src_space->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans((H5S_t *)src_space) < 0) /* Casting away const OK -NAF */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for source hyperslab selection") + if (NULL == src_space->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans((H5S_t *)src_space) < 0) /* Casting away const OK -NAF */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for source hyperslab selection") /* Simply point to existing span tree */ ss_span_info = src_space->select.sel_info.hslab->span_lst; @@ -11528,18 +11628,20 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Create temporary span tree from all selection */ HDassert(H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_ALL); - if(NULL == (ss_span_info_buf = H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(src_space), - H5S_hyper_zeros_g, H5S_hyper_zeros_g, H5S_hyper_ones_g, src_space->extent.size))) + if (NULL == (ss_span_info_buf = + H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(src_space), H5S_hyper_zeros_g, + H5S_hyper_zeros_g, H5S_hyper_ones_g, src_space->extent.size))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't create span tree for ALL source space") ss_span_info = ss_span_info_buf; } /* end else */ /* Set up ds_span_info */ - if(H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_HYPERSLABS) { + if (H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_HYPERSLABS) { /* Make certain the selection has a span tree */ - if(NULL == dst_space->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans((H5S_t *)dst_space) < 0) /* Casting away const OK -NAF */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for dsetination hyperslab selection") + if (NULL == dst_space->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans((H5S_t *)dst_space) < 0) /* Casting away const OK -NAF */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for dsetination hyperslab selection") /* Simply point to existing span tree */ ds_span_info = dst_space->select.sel_info.hslab->span_lst; @@ -11548,40 +11650,43 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Create temporary span tree from all selection */ HDassert(H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_ALL); - if(NULL == (ds_span_info_buf = H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(dst_space), - H5S_hyper_zeros_g, H5S_hyper_zeros_g, H5S_hyper_ones_g, dst_space->extent.size))) + if (NULL == (ds_span_info_buf = + H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(dst_space), H5S_hyper_zeros_g, + H5S_hyper_zeros_g, H5S_hyper_ones_g, dst_space->extent.size))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't create span tree for ALL destination space") ds_span_info = ds_span_info_buf; } /* end else */ /* Make certain the source intersect selection has a span tree */ - if(NULL == src_intersect_space->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans((H5S_t *)src_intersect_space) < 0) /* Casting away const OK -NAF */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for source intersect hyperslab selection") + if (NULL == src_intersect_space->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans((H5S_t *)src_intersect_space) < 0) /* Casting away const OK -NAF */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for source intersect hyperslab selection") /* Initialize udata */ /* We will use op_info[0] for nelem and op_info[1] for copied spans */ HDmemset(&udata, 0, sizeof(udata)); - udata.ds_span[0] = ds_span_info->head; - udata.ds_low[0] = udata.ds_span[0]->low; - udata.ss_rank = H5S_GET_EXTENT_NDIMS(src_space); - udata.ds_rank = H5S_GET_EXTENT_NDIMS(dst_space); - udata.op_gen = H5S__hyper_get_op_gen(); + udata.ds_span[0] = ds_span_info->head; + udata.ds_low[0] = udata.ds_span[0]->low; + udata.ss_rank = H5S_GET_EXTENT_NDIMS(src_space); + udata.ds_rank = H5S_GET_EXTENT_NDIMS(dst_space); + udata.op_gen = H5S__hyper_get_op_gen(); udata.share_selection = share_selection; /* Iterate over selections and build projected span tree */ - if(H5S__hyper_proj_int_iterate(ss_span_info, src_intersect_space->select.sel_info.hslab->span_lst, 1, 0, &udata) < 0) + if (H5S__hyper_proj_int_iterate(ss_span_info, src_intersect_space->select.sel_info.hslab->span_lst, 1, 0, + &udata) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "selection iteration failed") /* Remove current selection from proj_space */ - if(H5S_SELECT_RELEASE(proj_space) < 0) + if (H5S_SELECT_RELEASE(proj_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Check for elements in projected space */ - if(udata.ps_span_info[0]) { + if (udata.ps_span_info[0]) { /* Allocate space for the hyperslab selection information (note this sets * diminfo_valid to FALSE, diminfo arrays to 0, and span list to NULL) */ - if(NULL == (proj_space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t))) + if (NULL == (proj_space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info") /* Set selection type */ @@ -11592,7 +11697,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Set span tree */ proj_space->select.sel_info.hslab->span_lst = udata.ps_span_info[0]; - udata.ps_span_info[0] = NULL; + udata.ps_span_info[0] = NULL; /* Set the number of elements in current selection */ proj_space->select.num_elem = H5S__hyper_spans_nelem(proj_space->select.sel_info.hslab->span_lst); @@ -11604,48 +11709,47 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, } /* end if */ else /* If we did not add anything to proj_space, select none instead */ - if(H5S_select_none(proj_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") + if (H5S_select_none(proj_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") done: /* Free ss_span_info_buf */ - if(ss_span_info_buf) { + if (ss_span_info_buf) { H5S__hyper_free_span_info(ss_span_info_buf); ss_span_info_buf = NULL; } /* end if */ /* Free ds_span_info_buf */ - if(ds_span_info_buf) { + if (ds_span_info_buf) { H5S__hyper_free_span_info(ds_span_info_buf); ds_span_info_buf = NULL; } /* end if */ /* Cleanup on error */ - if(ret_value < 0) { + if (ret_value < 0) { unsigned u; /* Free span trees */ - for(u = 0; u < udata.ds_rank; u++) - if(udata.ps_span_info[u]) { + for (u = 0; u < udata.ds_rank; u++) + if (udata.ps_span_info[u]) { H5S__hyper_free_span_info(udata.ps_span_info[u]); udata.ps_span_info[u] = NULL; } /* end if */ - } /* end if */ + } /* end if */ #ifndef NDEBUG /* Verify there are no more span trees */ { unsigned u; - for(u = 0; u < H5S_MAX_RANK; u++) + for (u = 0; u < H5S_MAX_RANK; u++) HDassert(!udata.ps_span_info[u]); - } /* end block */ + } /* end block */ #endif /* NDEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_intersection() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_get_clip_diminfo @@ -11671,20 +11775,19 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static void -H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, - hsize_t *block, hsize_t clip_size) +H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, hsize_t *block, hsize_t clip_size) { FUNC_ENTER_STATIC_NOERR /* Check for selection outside clip size */ - if(start >= clip_size) { - if(*block == H5S_UNLIMITED) + if (start >= clip_size) { + if (*block == H5S_UNLIMITED) *block = 0; else *count = 0; } /* end if */ /* Check for single block in unlimited dimension */ - else if((*block == H5S_UNLIMITED) || (*block == stride)) { + else if ((*block == H5S_UNLIMITED) || (*block == stride)) { /* Calculate actual block size for this clip size */ *block = clip_size - start; *count = (hsize_t)1; @@ -11700,7 +11803,6 @@ H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_get_clip_diminfo() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_clip_unlim @@ -11725,11 +11827,11 @@ H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, herr_t H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) { - H5S_hyper_sel_t *hslab = NULL; /* Convenience pointer to hyperslab info */ - hsize_t orig_count; /* Original count in unlimited dimension */ - int orig_unlim_dim; /* Original unliminted dimension */ - H5S_hyper_dim_t *diminfo = NULL; /* Convenience pointer to diminfo.opt in unlimited dimension */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_sel_t *hslab = NULL; /* Convenience pointer to hyperslab info */ + hsize_t orig_count; /* Original count in unlimited dimension */ + int orig_unlim_dim; /* Original unliminted dimension */ + H5S_hyper_dim_t *diminfo = NULL; /* Convenience pointer to diminfo.opt in unlimited dimension */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -11756,17 +11858,17 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) space->select.sel_info.hslab->unlim_dim = -1; /* Check for nothing returned */ - if((diminfo->block == 0) || (diminfo->count == 0)) { + if ((diminfo->block == 0) || (diminfo->count == 0)) { /* Convert to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") /* Reset the convenience pointers */ - hslab = NULL; + hslab = NULL; diminfo = NULL; } /* end if */ /* Check for single block in unlimited dimension */ - else if(orig_count == (hsize_t)1) { + else if (orig_count == (hsize_t)1) { /* Calculate number of elements */ space->select.num_elem = diminfo->block * hslab->num_elem_non_unlim; @@ -11780,10 +11882,10 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) /* Check if last block is partial. If superset is set, just keep the * last block complete to speed computation. */ HDassert(clip_size > diminfo->start); - if(((diminfo->stride * (diminfo->count - (hsize_t)1)) + diminfo->block) - > (clip_size - diminfo->start)) { - hsize_t start[H5S_MAX_RANK]; - hsize_t block[H5S_MAX_RANK]; + if (((diminfo->stride * (diminfo->count - (hsize_t)1)) + diminfo->block) > + (clip_size - diminfo->start)) { + hsize_t start[H5S_MAX_RANK]; + hsize_t block[H5S_MAX_RANK]; unsigned u; /* Last block is partial, need to construct compound selection */ @@ -11792,22 +11894,23 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) /* Set block to clip_size in unlimited dimension, H5S_MAX_SIZE in * others so only unlimited dimension is clipped */ - for(u = 0; u < space->extent.rank; u++) - if((int)u == orig_unlim_dim) + for (u = 0; u < space->extent.rank; u++) + if ((int)u == orig_unlim_dim) block[u] = clip_size; else block[u] = H5S_MAX_SIZE; /* Generate span tree in selection */ - if(!hslab->span_lst) - if(H5S__hyper_generate_spans(space) < 0) + if (!hslab->span_lst) + if (H5S__hyper_generate_spans(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to generate span tree") /* Indicate that the regular dimensions are no longer valid */ hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; /* "And" selection with calculated block to perform clip operation */ - if(H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, block) < 0) + if (H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, + block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs") } /* end if */ else @@ -11816,17 +11919,16 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) } /* end else */ /* Update the upper bound, if the diminfo is valid */ - if(hslab && (H5S_DIMINFO_VALID_YES == hslab->diminfo_valid)) + if (hslab && (H5S_DIMINFO_VALID_YES == hslab->diminfo_valid)) hslab->diminfo.high_bounds[orig_unlim_dim] = - hslab->diminfo.opt[orig_unlim_dim].start + - hslab->diminfo.opt[orig_unlim_dim].stride * (hslab->diminfo.opt[orig_unlim_dim].count - 1) + - (hslab->diminfo.opt[orig_unlim_dim].block - 1); + hslab->diminfo.opt[orig_unlim_dim].start + + hslab->diminfo.opt[orig_unlim_dim].stride * (hslab->diminfo.opt[orig_unlim_dim].count - 1) + + (hslab->diminfo.opt[orig_unlim_dim].block - 1); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_clip_unlim() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_get_clip_extent_real @@ -11855,13 +11957,12 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static hsize_t -H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, - hbool_t incl_trail) +H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, hbool_t incl_trail) { const H5S_hyper_dim_t *diminfo; /* Convenience pointer to opt_unlim_diminfo in unlimited dimension */ - hsize_t count; - hsize_t rem_slices; - hsize_t ret_value = 0; /* Return value */ + hsize_t count; + hsize_t rem_slices; + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -11872,10 +11973,9 @@ H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, diminfo = &clip_space->select.sel_info.hslab->diminfo.opt[clip_space->select.sel_info.hslab->unlim_dim]; - if(num_slices == 0) + if (num_slices == 0) ret_value = incl_trail ? diminfo->start : 0; - else if((diminfo->block == H5S_UNLIMITED) - || (diminfo->block == diminfo->stride)) + else if ((diminfo->block == H5S_UNLIMITED) || (diminfo->block == diminfo->stride)) /* Unlimited block, just set the extent large enough for the block size * to match num_slices */ ret_value = diminfo->start + num_slices; @@ -11890,25 +11990,23 @@ H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, /* Calculate slices remaining */ rem_slices = num_slices - (count * diminfo->block); - if(rem_slices > 0) + if (rem_slices > 0) /* Must end extent in middle of partial block (or beginning of empty * block if include_trailing_space and rem_slices == 0) */ ret_value = diminfo->start + (count * diminfo->stride) + rem_slices; else { - if(incl_trail) + if (incl_trail) /* End extent just before first missing block */ ret_value = diminfo->start + (count * diminfo->stride); else /* End extent at end of last block */ - ret_value = diminfo->start + ((count - (hsize_t)1) - * diminfo->stride) + diminfo->block; + ret_value = diminfo->start + ((count - (hsize_t)1) * diminfo->stride) + diminfo->block; } /* end else */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_get_clip_extent_real() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_get_clip_extent @@ -11918,30 +12016,20 @@ H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, USAGE hsize_t H5S__hyper_get_clip_extent(clip_space,match_space,incl_trail) const H5S_t *clip_space, IN: Space that clip size will be calculated based on - const H5S_t *match_space, IN: Space containing the same number of elements as clip_space should after clipping - hbool_t incl_trail; IN: Whether to include trailing unselected space - RETURNS - Calculated clip extent (never fails) - DESCRIPTION - Calculates and returns the extent that clip_space should be clipped to - (via H5S_hyper_clip_unlim) in order for it to contain the same number - of elements as match_space. If the clipped selection would end - immediately before a section of unselected space (i.e. at the end of a - block), then if incl_trail is TRUE, the returned clip extent is - selected to include that trailing "blank" space, otherwise it is - selected to end at the end before the blank space. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Note this assumes the offset has been normalized. - EXAMPLES - REVISION LOG + const H5S_t *match_space, IN: Space containing the same number of elements as clip_space should after +clipping hbool_t incl_trail; IN: Whether to include trailing unselected space RETURNS Calculated clip +extent (never fails) DESCRIPTION Calculates and returns the extent that clip_space should be clipped to (via +H5S_hyper_clip_unlim) in order for it to contain the same number of elements as match_space. If the clipped +selection would end immediately before a section of unselected space (i.e. at the end of a block), then if +incl_trail is TRUE, the returned clip extent is selected to include that trailing "blank" space, otherwise it +is selected to end at the end before the blank space. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Note this +assumes the offset has been normalized. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hsize_t -H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, - hbool_t incl_trail) +H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, hbool_t incl_trail) { - hsize_t num_slices; /* Number of slices in unlimited dimension */ - hsize_t ret_value = 0; /* Return value */ + hsize_t num_slices; /* Number of slices in unlimited dimension */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -11951,17 +12039,15 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, HDassert(clip_space->select.sel_info.hslab->unlim_dim >= 0); /* Check for "none" match space */ - if(match_space->select.type->type == H5S_SEL_NONE) + if (match_space->select.type->type == H5S_SEL_NONE) num_slices = (hsize_t)0; else { HDassert(match_space->select.type->type == H5S_SEL_HYPERSLABS); HDassert(match_space->select.sel_info.hslab); /* Calculate number of slices */ - num_slices = match_space->select.num_elem - / clip_space->select.sel_info.hslab->num_elem_non_unlim; - HDassert((match_space->select.num_elem - % clip_space->select.sel_info.hslab->num_elem_non_unlim) == 0); + num_slices = match_space->select.num_elem / clip_space->select.sel_info.hslab->num_elem_non_unlim; + HDassert((match_space->select.num_elem % clip_space->select.sel_info.hslab->num_elem_non_unlim) == 0); } /* end else */ /* Call "real" get_clip_extent function */ @@ -11971,7 +12057,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_get_clip_extent_match @@ -11982,35 +12067,27 @@ done: USAGE hsize_t H5S__hyper_get_clip_extent_match(clip_space,match_space,match_clip_size,incl_trail) const H5S_t *clip_space, IN: Space that clip size will be calculated based on - const H5S_t *match_space, IN: Space that, after being clipped to match_clip_size, contains the same number of elements as clip_space should after clipping - hsize_t match_clip_size, IN: Extent match_space would be clipped to to match the number of elements in clip_space - hbool_t incl_trail; IN: Whether to include trailing unselected space - RETURNS - Calculated clip extent (never fails) - DESCRIPTION - Calculates and returns the extent that clip_space should be clipped to - (via H5S_hyper_clip_unlim) in order for it to contain the same number - of elements as match_space would have after being clipped to - match_clip_size. If the clipped selection would end immediately - before a section of unselected space (i.e. at the end of a block), - then if incl_trail is TRUE, the returned clip extent is selected to - include that trailing "blank" space, otherwise it is selected to end - at the end before the blank space. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Note this assumes the offset has been normalized. - EXAMPLES - REVISION LOG + const H5S_t *match_space, IN: Space that, after being clipped to match_clip_size, contains the same +number of elements as clip_space should after clipping hsize_t match_clip_size, IN: Extent match_space would +be clipped to to match the number of elements in clip_space hbool_t incl_trail; IN: Whether to include +trailing unselected space RETURNS Calculated clip extent (never fails) DESCRIPTION Calculates and returns the +extent that clip_space should be clipped to (via H5S_hyper_clip_unlim) in order for it to contain the same +number of elements as match_space would have after being clipped to match_clip_size. If the clipped selection +would end immediately before a section of unselected space (i.e. at the end of a block), then if incl_trail is +TRUE, the returned clip extent is selected to include that trailing "blank" space, otherwise it is selected to +end at the end before the blank space. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Note this assumes the +offset has been normalized. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hsize_t -H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, - const H5S_t *match_space, hsize_t match_clip_size, hbool_t incl_trail) +H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, const H5S_t *match_space, hsize_t match_clip_size, + hbool_t incl_trail) { - const H5S_hyper_dim_t *match_diminfo; /* Convenience pointer to opt_unlim_diminfo in unlimited dimension in match_space */ - hsize_t count; /* Temporary count */ - hsize_t block; /* Temporary block */ - hsize_t num_slices; /* Number of slices in unlimited dimension */ - hsize_t ret_value = 0; /* Return value */ + const H5S_hyper_dim_t + *match_diminfo; /* Convenience pointer to opt_unlim_diminfo in unlimited dimension in match_space */ + hsize_t count; /* Temporary count */ + hsize_t block; /* Temporary block */ + hsize_t num_slices; /* Number of slices in unlimited dimension */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -12021,10 +12098,11 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, HDassert(match_space->select.sel_info.hslab); HDassert(clip_space->select.sel_info.hslab->unlim_dim >= 0); HDassert(match_space->select.sel_info.hslab->unlim_dim >= 0); - HDassert(clip_space->select.sel_info.hslab->num_elem_non_unlim - == match_space->select.sel_info.hslab->num_elem_non_unlim); + HDassert(clip_space->select.sel_info.hslab->num_elem_non_unlim == + match_space->select.sel_info.hslab->num_elem_non_unlim); - match_diminfo = &match_space->select.sel_info.hslab->diminfo.opt[match_space->select.sel_info.hslab->unlim_dim]; + match_diminfo = + &match_space->select.sel_info.hslab->diminfo.opt[match_space->select.sel_info.hslab->unlim_dim]; /* Get initial count and block */ count = match_diminfo->count; @@ -12033,10 +12111,10 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, /* Calculate number of slices */ /* Check for nothing returned */ - if((block == 0) || (count == 0)) + if ((block == 0) || (count == 0)) num_slices = (hsize_t)0; /* Check for single block in unlimited dimension */ - else if(count == (hsize_t)1) + else if (count == (hsize_t)1) num_slices = block; else { /* Calculate initial num_slices */ @@ -12044,15 +12122,15 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, /* Check for partial last block */ HDassert(match_clip_size >= match_diminfo->start); - if(((match_diminfo->stride * (count - (hsize_t)1)) + block) - > (match_clip_size - match_diminfo->start)) { + if (((match_diminfo->stride * (count - (hsize_t)1)) + block) > + (match_clip_size - match_diminfo->start)) { /* Subtract slices missing from last block */ - HDassert((((match_diminfo->stride * (count - (hsize_t)1)) + block) - - (match_clip_size - match_diminfo->start)) < num_slices); - num_slices -= ((match_diminfo->stride * (count - (hsize_t)1)) - + block) - (match_clip_size - match_diminfo->start); + HDassert((((match_diminfo->stride * (count - (hsize_t)1)) + block) - + (match_clip_size - match_diminfo->start)) < num_slices); + num_slices -= ((match_diminfo->stride * (count - (hsize_t)1)) + block) - + (match_clip_size - match_diminfo->start); } /* end if */ - } /* end else */ + } /* end else */ /* Call "real" get_clip_extent function */ ret_value = H5S__hyper_get_clip_extent_real(clip_space, num_slices, incl_trail); @@ -12061,7 +12139,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent_match() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_get_unlim_block @@ -12087,14 +12164,14 @@ done: H5S_t * H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) { - H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ - H5S_t *space_out = NULL; /* Dataspace to return */ - hsize_t start[H5S_MAX_RANK];/* Hyperslab selection info for unlim. selection */ - hsize_t stride[H5S_MAX_RANK]; - hsize_t count[H5S_MAX_RANK]; - hsize_t block[H5S_MAX_RANK]; - unsigned u; /* Local index variable */ - H5S_t *ret_value = NULL; /* Return value */ + H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ + H5S_t * space_out = NULL; /* Dataspace to return */ + hsize_t start[H5S_MAX_RANK]; /* Hyperslab selection info for unlim. selection */ + hsize_t stride[H5S_MAX_RANK]; + hsize_t count[H5S_MAX_RANK]; + hsize_t block[H5S_MAX_RANK]; + unsigned u; /* Local index variable */ + H5S_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -12108,10 +12185,9 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) /* Set start to select block_indexth block in unlimited dimension and set * count to 1 in that dimension to only select that block. Copy all other * diminfo parameters. */ - for(u = 0; u < space->extent.rank; u++) { - if((int)u == hslab->unlim_dim){ - start[u] = hslab->diminfo.opt[u].start + (block_index - * hslab->diminfo.opt[u].stride); + for (u = 0; u < space->extent.rank; u++) { + if ((int)u == hslab->unlim_dim) { + start[u] = hslab->diminfo.opt[u].start + (block_index * hslab->diminfo.opt[u].stride); count[u] = (hsize_t)1; } /* end if */ else { @@ -12119,17 +12195,17 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) count[u] = hslab->diminfo.opt[u].count; } /* end else */ stride[u] = hslab->diminfo.opt[u].stride; - block[u] = hslab->diminfo.opt[u].block; + block[u] = hslab->diminfo.opt[u].block; } /* end for */ /* Create output space, copy extent */ - if(NULL == (space_out = H5S_create(H5S_SIMPLE))) + if (NULL == (space_out = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, NULL, "unable to create output dataspace") - if(H5S__extent_copy_real(&space_out->extent, &space->extent, TRUE) < 0) + if (H5S__extent_copy_real(&space_out->extent, &space->extent, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "unable to copy destination space extent") /* Select block as defined by start/stride/count/block computed above */ - if(H5S_select_hyperslab(space_out, H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5S_select_hyperslab(space_out, H5S_SELECT_SET, start, stride, count, block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "can't select hyperslab") /* Set return value */ @@ -12137,14 +12213,13 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) done: /* Free space on error */ - if(!ret_value) - if(space_out && H5S_close(space_out) < 0) + if (!ret_value) + if (space_out && H5S_close(space_out) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_unlim_block */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_get_first_inc_block @@ -12170,12 +12245,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ hsize_t -H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, - hbool_t *partial) +H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *partial) { - H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ - H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo in unlimited dimension */ - hsize_t ret_value = 0; + H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ + H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo in unlimited dimension */ + hsize_t ret_value = 0; FUNC_ENTER_NOAPI(0) @@ -12189,30 +12263,28 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, diminfo = &hslab->diminfo.opt[hslab->unlim_dim]; /* Check for selection outside of clip_size */ - if(diminfo->start >= clip_size) { + if (diminfo->start >= clip_size) { ret_value = 0; - if(partial) + if (partial) partial = FALSE; } /* end if */ else { /* Calculate index of first incomplete block */ - ret_value = (clip_size - diminfo->start + diminfo->stride - - diminfo->block) / diminfo->stride; + ret_value = (clip_size - diminfo->start + diminfo->stride - diminfo->block) / diminfo->stride; - if(partial) { + if (partial) { /* Check for partial block */ - if((diminfo->stride * ret_value) < (clip_size - diminfo->start)) + if ((diminfo->stride * ret_value) < (clip_size - diminfo->start)) *partial = TRUE; else *partial = FALSE; } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_first_inc_block */ - /*-------------------------------------------------------------------------- NAME H5Sis_regular_hyperslab @@ -12236,16 +12308,16 @@ done: htri_t H5Sis_regular_hyperslab(hid_t spaceid) { - H5S_t *space; /* Dataspace to query */ - htri_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to query */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") ret_value = H5S__hyper_is_regular(space); @@ -12254,7 +12326,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sis_regular_hyperslab() */ - /*-------------------------------------------------------------------------- NAME H5Sget_regular_hyperslab @@ -12282,39 +12353,37 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[], - hsize_t count[], hsize_t block[]) +H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[], hsize_t count[], hsize_t block[]) { - H5S_t *space; /* Dataspace to query */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t * space; /* Dataspace to query */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*h*h*h*h", spaceid, start, stride, count, block); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") - if(TRUE != H5S__hyper_is_regular(space)) + if (TRUE != H5S__hyper_is_regular(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a regular hyperslab selection") /* Retrieve hyperslab parameters */ - if(start) - for(u = 0; u < space->extent.rank; u++) + if (start) + for (u = 0; u < space->extent.rank; u++) start[u] = space->select.sel_info.hslab->diminfo.app[u].start; - if(stride) - for(u = 0; u < space->extent.rank; u++) + if (stride) + for (u = 0; u < space->extent.rank; u++) stride[u] = space->select.sel_info.hslab->diminfo.app[u].stride; - if(count) - for(u = 0; u < space->extent.rank; u++) + if (count) + for (u = 0; u < space->extent.rank; u++) count[u] = space->select.sel_info.hslab->diminfo.app[u].count; - if(block) - for(u = 0; u < space->extent.rank; u++) + if (block) + for (u = 0; u < space->extent.rank; u++) block[u] = space->select.sel_info.hslab->diminfo.app[u].block; done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_regular_hyperslab() */ - diff --git a/src/H5Smodule.h b/src/H5Smodule.h index 962f0a2..bf6e2cc 100644 --- a/src/H5Smodule.h +++ b/src/H5Smodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5S_MODULE -#define H5_MY_PKG H5S -#define H5_MY_PKG_ERR H5E_DATASPACE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5S +#define H5_MY_PKG_ERR H5E_DATASPACE +#define H5_MY_PKG_INIT YES #endif /* _H5Smodule_H */ - diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 147fd25..307cabc 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -22,26 +22,25 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector and array functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspaces */ +#include "H5VMprivate.h" /* Vector and array functions */ #ifdef H5_HAVE_PARALLEL /****************/ /* Local Macros */ /****************/ -#define H5S_MPIO_INITIAL_ALLOC_COUNT 256 +#define H5S_MPIO_INITIAL_ALLOC_COUNT 256 /*******************/ /* Local Variables */ @@ -53,56 +52,49 @@ /* Node in linked list of MPI data types created during traversal of irregular hyperslab selection */ typedef struct H5S_mpio_mpitype_node_t { - MPI_Datatype type; /* MPI Datatype */ - struct H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */ + MPI_Datatype type; /* MPI Datatype */ + struct H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */ } H5S_mpio_mpitype_node_t; /* List to track MPI data types generated during traversal of irregular hyperslab selection */ typedef struct H5S_mpio_mpitype_list_t { - H5S_mpio_mpitype_node_t *head; /* Pointer to head of list */ - H5S_mpio_mpitype_node_t *tail; /* Pointer to tail of list */ + H5S_mpio_mpitype_node_t *head; /* Pointer to head of list */ + H5S_mpio_mpitype_node_t *tail; /* Pointer to tail of list */ } H5S_mpio_mpitype_list_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); -static herr_t H5S__mpio_none_type(MPI_Datatype *new_type, int *count, - hbool_t *is_derived_type); -static herr_t H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, - MPI_Aint *disp, MPI_Datatype *new_type); -static herr_t H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type, - hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted); -static herr_t H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, - hsize_t **permute_map, MPI_Datatype *new_type, int *count, - hbool_t *is_derived_type); -static herr_t H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); -static herr_t H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); +static herr_t H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type); +static herr_t H5S__mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); +static herr_t H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, MPI_Aint *disp, + MPI_Datatype *new_type); +static herr_t H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map, + hbool_t *is_permuted); +static herr_t H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute_map, + MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); +static herr_t H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, + int *count, hbool_t *is_derived_type); +static herr_t H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, + int *count, hbool_t *is_derived_type); static herr_t H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list); -static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, - size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type, - H5S_mpio_mpitype_list_t *type_list, unsigned op_info_i, uint64_t op_gen); - +static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t elmt_size, + const MPI_Datatype *elmt_type, MPI_Datatype *span_type, + H5S_mpio_mpitype_list_t *type_list, unsigned op_info_i, uint64_t op_gen); /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ - /* Declare a free list to manage the H5S_mpio_mpitype_node_t struct */ H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t); - /*------------------------------------------------------------------------- * Function: H5S__mpio_all_type * @@ -120,14 +112,14 @@ H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t); *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) +H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type) { - hsize_t total_bytes; - hssize_t snelmts; /* Total number of elmts (signed) */ - hsize_t nelmts; /* Total number of elmts */ - hsize_t bigio_count; /* Transition point to create derived type */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t total_bytes; + hssize_t snelmts; /* Total number of elmts (signed) */ + hsize_t nelmts; /* Total number of elmts */ + hsize_t bigio_count; /* Transition point to create derived type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -135,15 +127,15 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, HDassert(space); /* Just treat the entire extent as a block of bytes */ - if((snelmts = (hssize_t)H5S_GET_EXTENT_NPOINTS(space)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") + if ((snelmts = (hssize_t)H5S_GET_EXTENT_NPOINTS(space)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t); total_bytes = (hsize_t)elmt_size * nelmts; bigio_count = H5_mpi_get_bigio_count(); /* Verify that the size can be expressed as a 32 bit integer */ - if(bigio_count >= total_bytes) { + if (bigio_count >= total_bytes) { /* fill in the return values */ *new_type = MPI_BYTE; H5_CHECKED_ASSIGN(*count, int, total_bytes, hsize_t); @@ -151,9 +143,10 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, } else { /* Create a LARGE derived datatype for this transfer */ - if(H5_mpio_create_large_type(total_bytes, 0, MPI_BYTE, new_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large datatype from the all selection") - *count = 1; + if (H5_mpio_create_large_type(total_bytes, 0, MPI_BYTE, new_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large datatype from the all selection") + *count = 1; *is_derived_type = TRUE; } @@ -161,7 +154,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__mpio_all_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_none_type * @@ -184,14 +176,13 @@ H5S__mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type FUNC_ENTER_STATIC_NOERR /* fill in the return values */ - *new_type = MPI_BYTE; - *count = 0; + *new_type = MPI_BYTE; + *count = 0; *is_derived_type = FALSE; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S__mpio_none_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_create_point_datatype * @@ -206,52 +197,53 @@ H5S__mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, - MPI_Aint *disp, MPI_Datatype *new_type) +H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, MPI_Aint *disp, MPI_Datatype *new_type) { - MPI_Datatype elmt_type; /* MPI datatype for individual element */ - hbool_t elmt_type_created = FALSE; /* Whether the element MPI datatype was created */ - int *inner_blocks = NULL; /* Arrays for MPI datatypes when "large" datatype needed */ - MPI_Aint *inner_disps = NULL; - MPI_Datatype *inner_types = NULL; + MPI_Datatype elmt_type; /* MPI datatype for individual element */ + hbool_t elmt_type_created = FALSE; /* Whether the element MPI datatype was created */ + int * inner_blocks = NULL; /* Arrays for MPI datatypes when "large" datatype needed */ + MPI_Aint * inner_disps = NULL; + MPI_Datatype *inner_types = NULL; #if MPI_VERSION < 3 - int *blocks = NULL; /* Array of block sizes for MPI hindexed create call */ - hsize_t u; /* Local index variable */ + int * blocks = NULL; /* Array of block sizes for MPI hindexed create call */ + hsize_t u; /* Local index variable */ #endif - hsize_t bigio_count; /* Transition point to create derived type */ - int mpi_code; /* MPI error code */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t bigio_count; /* Transition point to create derived type */ + int mpi_code; /* MPI error code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Create an MPI datatype for an element */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) elmt_type_created = TRUE; bigio_count = H5_mpi_get_bigio_count(); /* Check whether standard or BIGIO processing will be employeed */ - if(bigio_count >= num_points) { + if (bigio_count >= num_points) { #if MPI_VERSION >= 3 /* Create an MPI datatype for the whole point selection */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)num_points, 1, disp, elmt_type, new_type))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed_block((int)num_points, 1, disp, elmt_type, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_indexed_block failed", mpi_code) #else /* Allocate block sizes for MPI datatype call */ - if(NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * num_points))) + if (NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * num_points))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") - for(u = 0; u < num_points; u++) + for (u = 0; u < num_points; u++) blocks[u] = 1; /* Create an MPI datatype for the whole point selection */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)num_points, blocks, disp, elmt_type, new_type))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed((int)num_points, blocks, disp, elmt_type, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) #endif /* Commit MPI datatype for later use */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) } else { @@ -259,9 +251,9 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, * We'll create an hindexed_block type for every 2G point count and then combine * those and any remaining points into a single large datatype. */ - int total_types, i; - int remaining_points; - int num_big_types; + int total_types, i; + int remaining_points; + int num_big_types; hsize_t leftover; /* Calculate how many Big MPI datatypes are needed to represent the buffer */ @@ -273,82 +265,85 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, total_types = (int)(remaining_points) ? (num_big_types + 1) : num_big_types; /* Allocate array if MPI derived types needed */ - if(NULL == (inner_types = (MPI_Datatype *)H5MM_malloc((sizeof(MPI_Datatype) * (size_t)total_types)))) + if (NULL == (inner_types = (MPI_Datatype *)H5MM_malloc((sizeof(MPI_Datatype) * (size_t)total_types)))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") - if(NULL == (inner_blocks = (int *)H5MM_malloc(sizeof(int) * (size_t)total_types))) + if (NULL == (inner_blocks = (int *)H5MM_malloc(sizeof(int) * (size_t)total_types))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") - if(NULL == (inner_disps = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * (size_t)total_types))) + if (NULL == (inner_disps = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * (size_t)total_types))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") #if MPI_VERSION < 3 /* Allocate block sizes for MPI datatype call */ - if(NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * bigio_count))) + if (NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * bigio_count))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") - for(u = 0; u < bigio_count; u++) + for (u = 0; u < bigio_count; u++) blocks[u] = 1; #endif - for(i = 0; i < num_big_types; i++) { + for (i = 0; i < num_big_types; i++) { #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)bigio_count, - 1, &disp[(hsize_t)i*bigio_count], elmt_type, &inner_types[i]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)bigio_count, 1, + &disp[(hsize_t)i * bigio_count], + elmt_type, &inner_types[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code); #else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)bigio_count, - blocks, &disp[i*bigio_count], elmt_type, &inner_types[i]))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed((int)bigio_count, blocks, &disp[i * bigio_count], + elmt_type, &inner_types[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) #endif inner_blocks[i] = 1; inner_disps[i] = 0; } /* end for*/ - if(remaining_points) { + if (remaining_points) { #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(remaining_points, - 1, &disp[(hsize_t)num_big_types*bigio_count], elmt_type, &inner_types[num_big_types]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block( + remaining_points, 1, &disp[(hsize_t)num_big_types * bigio_count], + elmt_type, &inner_types[num_big_types]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code); #else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points, - blocks, &disp[num_big_types*bigio_count], elmt_type, &inner_types[num_big_types]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points, blocks, + &disp[num_big_types * bigio_count], + elmt_type, &inner_types[num_big_types]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) #endif inner_blocks[num_big_types] = 1; - inner_disps[num_big_types] = 0; + inner_disps[num_big_types] = 0; } - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(total_types, - inner_blocks, inner_disps, inner_types, new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(total_types, inner_blocks, inner_disps, + inner_types, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct", mpi_code); - for(i = 0; i < total_types; i++) + for (i = 0; i < total_types; i++) MPI_Type_free(&inner_types[i]); /* Commit MPI datatype for later use */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) } /* end else */ done: - if(elmt_type_created) + if (elmt_type_created) MPI_Type_free(&elmt_type); #if MPI_VERSION < 3 - if(blocks) + if (blocks) H5MM_free(blocks); #endif - if(inner_types) + if (inner_types) H5MM_free(inner_types); - if(inner_blocks) + if (inner_blocks) H5MM_free(inner_blocks); - if(inner_disps) + if (inner_disps) H5MM_free(inner_disps); FUNC_LEAVE_NOAPI(ret_value) } /* H5S__mpio_create_point_datatype() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_point_type * @@ -370,16 +365,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, - int *count, hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute, - hbool_t *is_permuted) +H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute, hbool_t *is_permuted) { - MPI_Aint *disp = NULL; /* Datatype displacement for each point*/ - H5S_pnt_node_t *curr = NULL; /* Current point being operated on in from the selection */ - hssize_t snum_points; /* Signed number of elements in selection */ - hsize_t num_points; /* Sumber of points in the selection */ - hsize_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + MPI_Aint * disp = NULL; /* Datatype displacement for each point*/ + H5S_pnt_node_t *curr = NULL; /* Current point being operated on in from the selection */ + hssize_t snum_points; /* Signed number of elements in selection */ + hsize_t num_points; /* Sumber of points in the selection */ + hsize_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -387,25 +381,25 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ HDassert(space); /* Get the total number of points selected */ - if((snum_points = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) + if ((snum_points = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") num_points = (hsize_t)snum_points; /* Allocate array for element displacements */ - if(NULL == (disp = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * num_points))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") + if (NULL == (disp = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * num_points))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") /* Allocate array for element permutation - returned to caller */ - if(do_permute) - if(NULL == (*permute = (hsize_t *)H5MM_malloc(sizeof(hsize_t) * num_points))) + if (do_permute) + if (NULL == (*permute = (hsize_t *)H5MM_malloc(sizeof(hsize_t) * num_points))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate permutation array") /* Iterate through list of elements */ curr = space->select.sel_info.pnt_lst->head; - for(u = 0 ; u < num_points ; u++) { + for (u = 0; u < num_points; u++) { /* Calculate the displacement of the current point */ hsize_t disp_tmp = H5VM_array_offset(space->extent.rank, space->extent.size, curr->pnt); - if(disp_tmp > LONG_MAX) /* Maximum value of type long */ + if (disp_tmp > LONG_MAX) /* Maximum value of type long */ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "disp overflow") disp[u] = (MPI_Aint)disp_tmp; disp[u] *= (MPI_Aint)elmt_size; @@ -425,22 +419,22 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ * point 4: map[3] = 2, move the 2nd position since point 1 has a higher disp, * but points 2 and 3 have lower displacements. */ - if(do_permute) { - if(u > 0 && disp[u] < disp[u - 1]) { + if (do_permute) { + if (u > 0 && disp[u] < disp[u - 1]) { hsize_t s = 0, l = u, m = u / 2; *is_permuted = TRUE; do { - if(disp[u] > disp[m]) + if (disp[u] > disp[m]) s = m + 1; - else if(disp[u] < disp[m]) + else if (disp[u] < disp[m]) l = m; else break; m = s + ((l - s) / 2); - } while(s < l); + } while (s < l); - if(m < u) { + if (m < u) { MPI_Aint temp; temp = disp[u]; @@ -455,27 +449,27 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ /* this is a memory space, and no permutation is necessary to create the derived datatype */ else { - ; /* do nothing */ - } /* end else */ + ; /* do nothing */ + } /* end else */ /* get the next point */ curr = curr->next; } /* end for */ /* Create the MPI datatype for the set of element displacements */ - if(H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0) + if (H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create an MPI Datatype from point selection") /* Set values about MPI datatype created */ - *count = 1; + *count = 1; *is_derived_type = TRUE; done: - if(NULL != disp) + if (NULL != disp) H5MM_free(disp); /* Release the permutation buffer, if it wasn't used */ - if(!(*is_permuted) && (*permute)) { + if (!(*is_permuted) && (*permute)) { H5MM_free(*permute); *permute = NULL; } /* end if */ @@ -483,7 +477,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__mpio_point_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_permute_type * @@ -508,17 +501,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) +H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, MPI_Datatype *new_type, + int *count, hbool_t *is_derived_type) { - MPI_Aint *disp = NULL; /* Datatype displacement for each point*/ - H5S_sel_iter_t sel_iter; /* Selection iteration info */ - hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ - hssize_t snum_points; /* Signed number of elements in selection */ - hsize_t num_points; /* Number of points in the selection */ - size_t max_elem; /* Maximum number of elements allowed in sequences */ - hsize_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + MPI_Aint * disp = NULL; /* Datatype displacement for each point*/ + H5S_sel_iter_t sel_iter; /* Selection iteration info */ + hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ + hssize_t snum_points; /* Signed number of elements in selection */ + hsize_t num_points; /* Number of points in the selection */ + size_t max_elem; /* Maximum number of elements allowed in sequences */ + hsize_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -526,39 +519,40 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, HDassert(space); /* Get the total number of points selected */ - if((snum_points = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) + if ((snum_points = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") num_points = (hsize_t)snum_points; /* Allocate array to store point displacements */ - if(NULL == (disp = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * num_points))) + if (NULL == (disp = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * num_points))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") /* Initialize selection iterator */ - if(H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0) + if (H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - sel_iter_init = TRUE; /* Selection iteration info has been initialized */ + sel_iter_init = TRUE; /* Selection iteration info has been initialized */ /* Set the number of elements to iterate over */ H5_CHECKED_ASSIGN(max_elem, size_t, num_points, hsize_t); /* Loop, while elements left in selection */ u = 0; - while(max_elem > 0) { - hsize_t off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */ - size_t len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */ - size_t nelem; /* Number of elements used in sequences */ - size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequence being worked on */ + while (max_elem > 0) { + hsize_t off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */ + size_t len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */ + size_t nelem; /* Number of elements used in sequences */ + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequence being worked on */ /* Get the sequences of bytes */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(&sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(&sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, + len) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { - hsize_t curr_off; /* Current offset within sequence */ - size_t curr_len; /* Length of bytes left to process in sequence */ + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { + hsize_t curr_off; /* Current offset within sequence */ + size_t curr_len; /* Length of bytes left to process in sequence */ /* Get the current offset */ curr_off = off[curr_seq]; @@ -567,19 +561,19 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, curr_len = len[curr_seq]; /* Loop, while bytes left in sequence */ - while(curr_len > 0) { + while (curr_len > 0) { /* Set the displacement of the current point */ - if(curr_off > LONG_MAX) + if (curr_off > LONG_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "curr_off overflow") disp[u] = (MPI_Aint)curr_off; /* This is a memory displacement, so for each point selected, * apply the map that was generated by the file selection */ - if((*permute)[u] != num_points) { + if ((*permute)[u] != num_points) { MPI_Aint temp = disp[u]; HDmemmove(disp + (*permute)[u] + 1, disp + (*permute)[u], - (u - (*permute)[u]) * sizeof(MPI_Aint)); + (u - (*permute)[u]) * sizeof(MPI_Aint)); disp[(*permute)[u]] = temp; } /* end if */ @@ -592,30 +586,30 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, /* Decrement number of bytes left in sequence */ curr_len -= elmt_size; } /* end while */ - } /* end for */ + } /* end for */ /* Decrement number of elements left to process */ max_elem -= nelem; } /* end while */ /* Create the MPI datatype for the set of element displacements */ - if(H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0) + if (H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create an MPI Datatype from point selection") /* Set values about MPI datatype created */ - *count = 1; + *count = 1; *is_derived_type = TRUE; done: /* Release selection iterator */ - if(sel_iter_init) - if(H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) + if (sel_iter_init) + if (H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") /* Free memory */ - if(disp) + if (disp) H5MM_free(disp); - if(*permute) { + if (*permute) { H5MM_free(*permute); *permute = NULL; } /* end if */ @@ -623,7 +617,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__mpio_permute_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_reg_hyper_type * @@ -641,32 +634,32 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) +H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type) { - H5S_sel_iter_t sel_iter; /* Selection iteration info */ - hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ + H5S_sel_iter_t sel_iter; /* Selection iteration info */ + hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ - struct dim { /* less hassle than malloc/free & ilk */ + struct dim { /* less hassle than malloc/free & ilk */ hssize_t start; - hsize_t strid; - hsize_t block; - hsize_t xtent; - hsize_t count; + hsize_t strid; + hsize_t block; + hsize_t xtent; + hsize_t count; } d[H5S_MAX_RANK]; - hsize_t bigio_count; /* Transition point to create derived type */ - hsize_t offset[H5S_MAX_RANK]; - hsize_t max_xtent[H5S_MAX_RANK]; - H5S_hyper_dim_t *diminfo; /* [rank] */ - unsigned rank; - MPI_Datatype inner_type, outer_type; - MPI_Aint extent_len, start_disp, new_extent; - MPI_Aint lb; /* Needed as an argument for MPI_Type_get_extent */ - unsigned u; /* Local index variable */ - int i; /* Local index variable */ - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; + hsize_t bigio_count; /* Transition point to create derived type */ + hsize_t offset[H5S_MAX_RANK]; + hsize_t max_xtent[H5S_MAX_RANK]; + H5S_hyper_dim_t *diminfo; /* [rank] */ + unsigned rank; + MPI_Datatype inner_type, outer_type; + MPI_Aint extent_len, start_disp, new_extent; + MPI_Aint lb; /* Needed as an argument for MPI_Type_get_extent */ + unsigned u; /* Local index variable */ + int i; /* Local index variable */ + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -676,9 +669,9 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, bigio_count = H5_mpi_get_bigio_count(); /* Initialize selection iterator */ - if(H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0) + if (H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - sel_iter_init = TRUE; /* Selection iteration info has been initialized */ + sel_iter_init = TRUE; /* Selection iteration info has been initialized */ /* Abbreviate args */ diminfo = sel_iter.u.hyp.diminfo; @@ -687,14 +680,14 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, /* Make a local copy of the dimension info so we can operate with them */ /* Check if this is a "flattened" regular hyperslab selection */ - if(sel_iter.u.hyp.iter_rank != 0 && sel_iter.u.hyp.iter_rank < space->extent.rank) { + if (sel_iter.u.hyp.iter_rank != 0 && sel_iter.u.hyp.iter_rank < space->extent.rank) { /* Flattened selection */ rank = sel_iter.u.hyp.iter_rank; #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), "%s: Flattened selection\n",FUNC); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), "%s: Flattened selection\n", FUNC); #endif - for(u = 0; u < rank; ++u) { + for (u = 0; u < rank; ++u) { H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t) d[u].start = (hssize_t)diminfo[u].start + sel_iter.u.hyp.sel_off[u]; d[u].strid = diminfo[u].stride; @@ -703,14 +696,14 @@ if(H5DEBUG(S)) d[u].xtent = sel_iter.u.hyp.size[u]; #ifdef H5S_DEBUG -if(H5DEBUG(S)) { - HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu", - FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent); - if(u == 0) - HDfprintf(H5DEBUG(S), " rank=%u\n", rank); - else - HDfprintf(H5DEBUG(S), "\n"); -} + if (H5DEBUG(S)) { + HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu", FUNC, + d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent); + if (u == 0) + HDfprintf(H5DEBUG(S), " rank=%u\n", rank); + else + HDfprintf(H5DEBUG(S), "\n"); + } #endif /* Sanity check */ @@ -718,15 +711,15 @@ if(H5DEBUG(S)) { HDassert(d[u].count > 0); HDassert(d[u].xtent > 0); } /* end for */ - } /* end if */ + } /* end if */ else { /* Non-flattened selection */ rank = space->extent.rank; #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S),"%s: Non-flattened selection\n",FUNC); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), "%s: Non-flattened selection\n", FUNC); #endif - for(u = 0; u < rank; ++u) { + for (u = 0; u < rank; ++u) { H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t) d[u].start = (hssize_t)diminfo[u].start + space->select.offset[u]; d[u].strid = diminfo[u].stride; @@ -735,14 +728,14 @@ if(H5DEBUG(S)) d[u].xtent = space->extent.size[u]; #ifdef H5S_DEBUG -if(H5DEBUG(S)) { - HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu", - FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent); - if(u == 0) - HDfprintf(H5DEBUG(S), " rank=%u\n", rank); - else - HDfprintf(H5DEBUG(S), "\n"); -} + if (H5DEBUG(S)) { + HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu", FUNC, + d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent); + if (u == 0) + HDfprintf(H5DEBUG(S), " rank=%u\n", rank); + else + HDfprintf(H5DEBUG(S), "\n"); + } #endif /* Sanity check */ @@ -750,26 +743,26 @@ if(H5DEBUG(S)) { HDassert(d[u].count > 0); HDassert(d[u].xtent > 0); } /* end for */ - } /* end else */ + } /* end else */ -/********************************************************************** - Compute array "offset[rank]" which gives the offsets for a multi- - dimensional array with dimensions "d[i].xtent" (i=0,1,...,rank-1). -**********************************************************************/ - offset[rank - 1] = 1; + /********************************************************************** + Compute array "offset[rank]" which gives the offsets for a multi- + dimensional array with dimensions "d[i].xtent" (i=0,1,...,rank-1). + **********************************************************************/ + offset[rank - 1] = 1; max_xtent[rank - 1] = d[rank - 1].xtent; #ifdef H5S_DEBUG -if(H5DEBUG(S)) { - i = ((int)rank) - 1; - HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]); -} + if (H5DEBUG(S)) { + i = ((int)rank) - 1; + HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]); + } #endif - for(i = ((int)rank) - 2; i >= 0; --i) { - offset[i] = offset[i + 1] * d[i + 1].xtent; + for (i = ((int)rank) - 2; i >= 0; --i) { + offset[i] = offset[i + 1] * d[i + 1].xtent; max_xtent[i] = max_xtent[i + 1] * d[i].xtent; #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]); #endif } /* end for */ @@ -780,14 +773,14 @@ if(H5DEBUG(S)) */ /******************************************************* -* Construct contig type for inner contig dims: -*******************************************************/ + * Construct contig type for inner contig dims: + *******************************************************/ #ifdef H5S_DEBUG -if(H5DEBUG(S)) { - HDfprintf(H5DEBUG(S), "%s: Making contig type %Zu MPI_BYTEs\n", FUNC, elmt_size); - for(i = ((int)rank) - 1; i >= 0; --i) - HDfprintf(H5DEBUG(S), "d[%d].xtent=%Hu \n", i, d[i].xtent); -} + if (H5DEBUG(S)) { + HDfprintf(H5DEBUG(S), "%s: Making contig type %Zu MPI_BYTEs\n", FUNC, elmt_size); + for (i = ((int)rank) - 1; i >= 0; --i) + HDfprintf(H5DEBUG(S), "d[%d].xtent=%Hu \n", i, d[i].xtent); + } #endif /* LARGE_DATATYPE:: @@ -796,49 +789,50 @@ if(H5DEBUG(S)) { * Otherwise create a compound datatype by iterating as many times as needed * for the innertype to be created. */ - if(bigio_count >= elmt_size) { + if (bigio_count >= elmt_size) { /* Use a single MPI datatype that has a 32 bit size */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &inner_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &inner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } else /* Create the compound datatype for this operation (> 2GB) */ - if(H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &inner_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large inner datatype in hyper selection") - -/******************************************************* -* Construct the type by walking the hyperslab dims -* from the inside out: -*******************************************************/ - for(i = ((int)rank) - 1; i >= 0; --i) { + if (H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &inner_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large inner datatype in hyper selection") + + /******************************************************* + * Construct the type by walking the hyperslab dims + * from the inside out: + *******************************************************/ + for (i = ((int)rank) - 1; i >= 0; --i) { #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), "%s: Dimension i=%d \n" - "start=%Hd count=%Hu block=%Hu stride=%Hu, xtent=%Hu max_xtent=%d\n", - FUNC, i, d[i].start, d[i].count, d[i].block, d[i].strid, d[i].xtent, max_xtent[i]); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), + "%s: Dimension i=%d \n" + "start=%Hd count=%Hu block=%Hu stride=%Hu, xtent=%Hu max_xtent=%d\n", + FUNC, i, d[i].start, d[i].count, d[i].block, d[i].strid, d[i].xtent, max_xtent[i]); #endif #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), "%s: i=%d Making vector-type \n", FUNC,i); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), "%s: i=%d Making vector-type \n", FUNC, i); #endif - /**************************************** - * Build vector type of the selection. - ****************************************/ - if(bigio_count >= d[i].count && - bigio_count >= d[i].block && bigio_count >= d[i].strid) { + /**************************************** + * Build vector type of the selection. + ****************************************/ + if (bigio_count >= d[i].count && bigio_count >= d[i].block && bigio_count >= d[i].strid) { /* All the parameters fit into 32 bit integers so create the vector type normally */ - mpi_code = MPI_Type_vector((int)(d[i].count), /* count */ - (int)(d[i].block), /* blocklength */ - (int)(d[i].strid), /* stride */ - inner_type, /* old type */ - &outer_type); /* new type */ + mpi_code = MPI_Type_vector((int)(d[i].count), /* count */ + (int)(d[i].block), /* blocklength */ + (int)(d[i].strid), /* stride */ + inner_type, /* old type */ + &outer_type); /* new type */ MPI_Type_free(&inner_type); - if(mpi_code != MPI_SUCCESS) + if (mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code) - } - else { + } + else { /* Things get a bit more complicated and require LARGE_DATATYPE processing * There are two MPI datatypes that need to be created: * 1) an internal contiguous block; and @@ -850,19 +844,20 @@ if(H5DEBUG(S)) * (2GB-1)number_of_blocks * the_datatype_extent. */ - MPI_Aint stride_in_bytes, inner_extent; + MPI_Aint stride_in_bytes, inner_extent; MPI_Datatype block_type; /* Create a contiguous datatype inner_type x number of BLOCKS. * Again we need to check that the number of BLOCKS can fit into * a 32 bit integer */ - if(bigio_count < d[i].block) { - if(H5_mpio_create_large_type(d[i].block, 0, inner_type, &block_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large block datatype in hyper selection") + if (bigio_count < d[i].block) { + if (H5_mpio_create_large_type(d[i].block, 0, inner_type, &block_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large block datatype in hyper selection") } - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)d[i].block, inner_type, &block_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_Type_contiguous((int)d[i].block, inner_type, &block_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) /* As of version 4.0, OpenMPI now turns off MPI-1 API calls by default, * so we're using the MPI-2 version even though we don't need the lb @@ -877,18 +872,18 @@ if(H5DEBUG(S)) /* If the element count is larger than what a 32 bit integer can hold, * we call the large type creation function to handle that */ - if(bigio_count < d[i].count) { - if(H5_mpio_create_large_type(d[i].count, stride_in_bytes, block_type, &outer_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large outer datatype in hyper selection") + if (bigio_count < d[i].count) { + if (H5_mpio_create_large_type(d[i].count, stride_in_bytes, block_type, &outer_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large outer datatype in hyper selection") } /* otherwise a regular create_hvector will do */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)d[i].count, /* count */ - 1, /* blocklength */ - stride_in_bytes, /* stride in bytes*/ - block_type, /* old type */ - &outer_type))) /* new type */ - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + else if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)d[i].count, /* count */ + 1, /* blocklength */ + stride_in_bytes, /* stride in bytes*/ + block_type, /* old type */ + &outer_type))) /* new type */ + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) MPI_Type_free(&block_type); MPI_Type_free(&inner_type); @@ -900,14 +895,14 @@ if(H5DEBUG(S)) /* Calculate start and extent values of this dimension */ /* Check if value overflow to cast to type MPI_Aint */ - if(d[i].start > LONG_MAX || offset[i] > LONG_MAX || elmt_size > LONG_MAX) + if (d[i].start > LONG_MAX || offset[i] > LONG_MAX || elmt_size > LONG_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "result overflow") - start_disp = (MPI_Aint)d[i].start * (MPI_Aint)offset[i] * (MPI_Aint)elmt_size; + start_disp = (MPI_Aint)d[i].start * (MPI_Aint)offset[i] * (MPI_Aint)elmt_size; - if(max_xtent[i] > LONG_MAX) + if (max_xtent[i] > LONG_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "max_xtent overflow") new_extent = (MPI_Aint)elmt_size * (MPI_Aint)max_xtent[i]; - if(MPI_SUCCESS != (mpi_code = MPI_Type_get_extent(outer_type, &lb, &extent_len))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_get_extent(outer_type, &lb, &extent_len))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_get_extent failed", mpi_code) /************************************************* @@ -915,52 +910,51 @@ if(H5DEBUG(S)) * so that it still starts at 0, but its extent * is the full extent in this dimension. *************************************************/ - if(start_disp > 0 || extent_len < new_extent) { + if (start_disp > 0 || extent_len < new_extent) { MPI_Datatype interm_type; - int block_len = 1; + int block_len = 1; HDassert(0 == lb); mpi_code = MPI_Type_create_hindexed(1, &block_len, &start_disp, outer_type, &interm_type); MPI_Type_free(&outer_type); - if(mpi_code != MPI_SUCCESS) + if (mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) mpi_code = MPI_Type_create_resized(interm_type, lb, new_extent, &inner_type); MPI_Type_free(&interm_type); - if(mpi_code != MPI_SUCCESS) + if (mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "couldn't resize MPI vector type", mpi_code) } /* end if */ else inner_type = outer_type; } /* end for */ -/****************************************** -* End of loop, walking through dimensions. -*******************************************/ + /****************************************** + * End of loop, walking through dimensions. + *******************************************/ /* At this point inner_type is actually the outermost type, even for 0-trip loop */ *new_type = inner_type; - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* fill in the remaining return values */ - *count = 1; /* only have to move one of these suckers! */ + *count = 1; /* only have to move one of these suckers! */ *is_derived_type = TRUE; done: /* Release selection iterator */ - if(sel_iter_init) - if(H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) + if (sel_iter_init) + if (H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), "Leave %s, count=%ld is_derived_type=%t\n", FUNC, *count, *is_derived_type); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), "Leave %s, count=%ld is_derived_type=%t\n", FUNC, *count, *is_derived_type); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__mpio_reg_hyper_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_span_hyper_type * @@ -979,18 +973,18 @@ if(H5DEBUG(S)) *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) +H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type) { - H5S_mpio_mpitype_list_t type_list; /* List to track MPI data types created */ - MPI_Datatype elmt_type; /* MPI datatype for an element */ - hbool_t elmt_type_is_derived = FALSE; /* Whether the element type has been created */ - MPI_Datatype span_type; /* MPI datatype for overall span tree */ - hsize_t bigio_count; /* Transition point to create derived type */ - hsize_t down[H5S_MAX_RANK]; /* 'down' sizes for each dimension */ - uint64_t op_gen; /* Operation generation value */ - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_mpio_mpitype_list_t type_list; /* List to track MPI data types created */ + MPI_Datatype elmt_type; /* MPI datatype for an element */ + hbool_t elmt_type_is_derived = FALSE; /* Whether the element type has been created */ + MPI_Datatype span_type; /* MPI datatype for overall span tree */ + hsize_t bigio_count; /* Transition point to create derived type */ + hsize_t down[H5S_MAX_RANK]; /* 'down' sizes for each dimension */ + uint64_t op_gen; /* Operation generation value */ + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1002,17 +996,17 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, bigio_count = H5_mpi_get_bigio_count(); /* Create the base type for an element */ - if(bigio_count >= elmt_size) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) + if (bigio_count >= elmt_size) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } - else - if(H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &elmt_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection") + else if (H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &elmt_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large element datatype in span_hyper selection") elmt_type_is_derived = TRUE; /* Compute 'down' sizes for each dimension */ - if(H5VM_array_down(space->extent.rank, space->extent.size, down) < 0) + if (H5VM_array_down(space->extent.rank, space->extent.size, down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGETSIZE, FAIL, "couldn't compute 'down' dimension sizes") /* Acquire an operation generation value for creating MPI datatypes */ @@ -1022,31 +1016,31 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ type_list.head = type_list.tail = NULL; - if(H5S__obtain_datatype(space->select.sel_info.hslab->span_lst, down, elmt_size, &elmt_type, &span_type, &type_list, 0, op_gen) < 0) + if (H5S__obtain_datatype(space->select.sel_info.hslab->span_lst, down, elmt_size, &elmt_type, &span_type, + &type_list, 0, op_gen) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type") - if(MPI_SUCCESS != (mpi_code = MPI_Type_dup(span_type, new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_dup(span_type, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* Release MPI data types generated during span tree traversal */ - if(H5S__release_datatype(&type_list) < 0) + if (H5S__release_datatype(&type_list) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "couldn't release MPI derived data type") /* fill in the remaining return values */ - *count = 1; + *count = 1; *is_derived_type = TRUE; done: /* Release resources */ - if(elmt_type_is_derived) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&elmt_type))) + if (elmt_type_is_derived) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&elmt_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__mpio_span_hyper_type() */ - /*------------------------------------------------------------------------- * Function: H5S__release_datatype * @@ -1061,8 +1055,8 @@ done: static herr_t H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list) { - H5S_mpio_mpitype_node_t *curr; /* Pointer to head of list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_mpio_mpitype_node_t *curr; /* Pointer to head of list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1071,12 +1065,12 @@ H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list) /* Iterate over the list, freeing the MPI data types */ curr = type_list->head; - while(curr) { - H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */ - int mpi_code; /* MPI return status code */ + while (curr) { + H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */ + int mpi_code; /* MPI return status code */ /* Release the MPI data type for this span tree */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&curr->type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&curr->type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) /* Get pointer to next node in list */ @@ -1090,10 +1084,9 @@ H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list) } /* end while */ done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__release_datatype() */ - /*------------------------------------------------------------------------- * Function: H5S__obtain_datatype * @@ -1108,21 +1101,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, - size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type, - H5S_mpio_mpitype_list_t *type_list, unsigned op_info_i, uint64_t op_gen) +H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t elmt_size, + const MPI_Datatype *elmt_type, MPI_Datatype *span_type, + H5S_mpio_mpitype_list_t *type_list, unsigned op_info_i, uint64_t op_gen) { - H5S_hyper_span_t *span; /* Hyperslab span to iterate with */ - hsize_t bigio_count; /* Transition point to create derived type */ - size_t alloc_count = 0; /* Number of span tree nodes allocated at this level */ - size_t outercount = 0; /* Number of span tree nodes at this level */ - MPI_Datatype *inner_type = NULL; - hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */ - int *blocklen = NULL; - MPI_Aint *disp = NULL; - size_t u; /* Local index variable */ - int mpi_code; /* MPI return status code */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_t *span; /* Hyperslab span to iterate with */ + hsize_t bigio_count; /* Transition point to create derived type */ + size_t alloc_count = 0; /* Number of span tree nodes allocated at this level */ + size_t outercount = 0; /* Number of span tree nodes at this level */ + MPI_Datatype * inner_type = NULL; + hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */ + int * blocklen = NULL; + MPI_Aint * disp = NULL; + size_t u; /* Local index variable */ + int mpi_code; /* MPI return status code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1132,39 +1125,41 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, bigio_count = H5_mpi_get_bigio_count(); /* Check if we've visited this span tree before */ - if(spans->op_info[op_info_i].op_gen != op_gen) { - H5S_mpio_mpitype_node_t *type_node; /* Pointer to new node in MPI data type list */ + if (spans->op_info[op_info_i].op_gen != op_gen) { + H5S_mpio_mpitype_node_t *type_node; /* Pointer to new node in MPI data type list */ /* Allocate the initial displacement & block length buffers */ alloc_count = H5S_MPIO_INITIAL_ALLOC_COUNT; - if(NULL == (disp = (MPI_Aint *)H5MM_malloc(alloc_count * sizeof(MPI_Aint)))) + if (NULL == (disp = (MPI_Aint *)H5MM_malloc(alloc_count * sizeof(MPI_Aint)))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") - if(NULL == (blocklen = (int *)H5MM_malloc(alloc_count * sizeof(int)))) + if (NULL == (blocklen = (int *)H5MM_malloc(alloc_count * sizeof(int)))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths") /* If this is the fastest changing dimension, it is the base case for derived datatype. */ span = spans->head; - if(NULL == span->down) { - hbool_t large_block = FALSE; /* Wether the block length is larger than 32 bit integer */ + if (NULL == span->down) { + hbool_t large_block = FALSE; /* Wether the block length is larger than 32 bit integer */ outercount = 0; - while(span) { - hsize_t nelmts; /* # of elements covered by current span */ + while (span) { + hsize_t nelmts; /* # of elements covered by current span */ /* Check if we need to increase the size of the buffers */ - if(outercount >= alloc_count) { - MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */ - int *tmp_blocklen; /* Temporary pointer to new block length buffer */ + if (outercount >= alloc_count) { + MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */ + int * tmp_blocklen; /* Temporary pointer to new block length buffer */ /* Double the allocation count */ alloc_count *= 2; /* Re-allocate the buffers */ - if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") + if (NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of displacements") disp = tmp_disp; - if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths") + if (NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of block lengths") blocklen = tmp_blocklen; } /* end if */ @@ -1172,11 +1167,11 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, nelmts = (span->high - span->low) + 1; /* Store displacement & block length */ - disp[outercount] = (MPI_Aint)elmt_size * (MPI_Aint)span->low; + disp[outercount] = (MPI_Aint)elmt_size * (MPI_Aint)span->low; H5_CHECK_OVERFLOW(nelmts, hsize_t, int) - blocklen[outercount] = (int)nelmts; + blocklen[outercount] = (int)nelmts; - if(bigio_count < (hsize_t)blocklen[outercount]) + if (bigio_count < (hsize_t)blocklen[outercount]) large_block = TRUE; /* at least one block type is large, so set this flag to true */ span = span->next; @@ -1184,49 +1179,53 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, } /* end while */ /* Everything fits into integers, so cast them and use hindexed */ - if(bigio_count >= outercount && large_block == FALSE) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, &spans->op_info[op_info_i].u.down_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - } /* end if */ - else { /* LARGE_DATATYPE:: Something doesn't fit into a 32 bit integer */ - for(u = 0 ; u < outercount; u++) { + if (bigio_count >= outercount && large_block == FALSE) { + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, + &spans->op_info[op_info_i].u.down_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) + } /* end if */ + else { /* LARGE_DATATYPE:: Something doesn't fit into a 32 bit integer */ + for (u = 0; u < outercount; u++) { MPI_Datatype temp_type = MPI_DATATYPE_NULL; /* create the block type from elmt_type while checking the 32 bit int limit */ - if((hsize_t)(blocklen[u]) > bigio_count) { - if(H5_mpio_create_large_type((hsize_t)blocklen[u], 0, *elmt_type, &temp_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection") + if ((hsize_t)(blocklen[u]) > bigio_count) { + if (H5_mpio_create_large_type((hsize_t)blocklen[u], 0, *elmt_type, &temp_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large element datatype in span_hyper selection") } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)blocklen[u], *elmt_type, &temp_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_Type_contiguous((int)blocklen[u], *elmt_type, &temp_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) /* Combine the current datatype that is created with this current block type */ - if(0 == u) /* first iteration, there is no combined datatype yet */ + if (0 == u) /* first iteration, there is no combined datatype yet */ spans->op_info[op_info_i].u.down_type = temp_type; else { - int bl[2] = {1, 1}; - MPI_Aint ds[2] = {disp[u - 1], disp[u]}; + int bl[2] = {1, 1}; + MPI_Aint ds[2] = {disp[u - 1], disp[u]}; MPI_Datatype dt[2] = {spans->op_info[op_info_i].u.down_type, temp_type}; - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, /* count */ - bl, /* blocklength */ - ds, /* stride in bytes*/ - dt, /* old type */ - &spans->op_info[op_info_i].u.down_type))) /* new type */ + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct( + 2, /* count */ + bl, /* blocklength */ + ds, /* stride in bytes*/ + dt, /* old type */ + &spans->op_info[op_info_i].u.down_type))) /* new type */ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) /* Release previous temporary datatype */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&temp_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&temp_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) } /* end else */ - } /* end for */ - } /* end else (LARGE_DATATYPE::) */ - } /* end if */ + } /* end for */ + } /* end else (LARGE_DATATYPE::) */ + } /* end if */ else { - MPI_Aint stride; /* Distance between inner MPI datatypes */ + MPI_Aint stride; /* Distance between inner MPI datatypes */ - if(NULL == (inner_type = (MPI_Datatype *)H5MM_malloc(alloc_count * sizeof(MPI_Datatype)))) + if (NULL == (inner_type = (MPI_Datatype *)H5MM_malloc(alloc_count * sizeof(MPI_Datatype)))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes") /* Calculate the total bytes of the lower dimension */ @@ -1234,39 +1233,44 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, /* Loop over span nodes */ outercount = 0; - while(span) { - MPI_Datatype down_type; /* Temporary MPI datatype for a span tree node's children */ - hsize_t nelmts; /* # of elements covered by current span */ + while (span) { + MPI_Datatype down_type; /* Temporary MPI datatype for a span tree node's children */ + hsize_t nelmts; /* # of elements covered by current span */ /* Check if we need to increase the size of the buffers */ - if(outercount >= alloc_count) { - MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */ - int *tmp_blocklen; /* Temporary pointer to new block length buffer */ - MPI_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */ + if (outercount >= alloc_count) { + MPI_Aint * tmp_disp; /* Temporary pointer to new displacement buffer */ + int * tmp_blocklen; /* Temporary pointer to new block length buffer */ + MPI_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */ /* Double the allocation count */ alloc_count *= 2; /* Re-allocate the buffers */ - if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") + if (NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of displacements") disp = tmp_disp; - if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths") + if (NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of block lengths") blocklen = tmp_blocklen; - if(NULL == (tmp_inner_type = (MPI_Datatype *)H5MM_realloc(inner_type, alloc_count * sizeof(MPI_Datatype)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes") + if (NULL == (tmp_inner_type = (MPI_Datatype *)H5MM_realloc( + inner_type, alloc_count * sizeof(MPI_Datatype)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of inner MPI datatypes") inner_type = tmp_inner_type; } /* end if */ /* Displacement should be in byte and should have dimension information */ /* First using MPI Type vector to build derived data type for this span only */ /* Need to calculate the disp in byte for this dimension. */ - disp[outercount] = (MPI_Aint)span->low * stride; - blocklen[outercount] = 1; + disp[outercount] = (MPI_Aint)span->low * stride; + blocklen[outercount] = 1; /* Generate MPI datatype for next dimension down */ - if(H5S__obtain_datatype(span->down, down + 1, elmt_size, elmt_type, &down_type, type_list, op_info_i, op_gen) < 0) + if (H5S__obtain_datatype(span->down, down + 1, elmt_size, elmt_type, &down_type, type_list, + op_info_i, op_gen) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type") /* Compute the number of elements to attempt in this span */ @@ -1274,27 +1278,29 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, /* Build the MPI datatype for this node */ H5_CHECK_OVERFLOW(nelmts, hsize_t, int) - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)nelmts, 1, stride, down_type, &inner_type[outercount]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)nelmts, 1, stride, down_type, + &inner_type[outercount]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) span = span->next; outercount++; - } /* end while */ + } /* end while */ /* Building the whole vector datatype */ H5_CHECK_OVERFLOW(outercount, size_t, int) - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, &spans->op_info[op_info_i].u.down_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, + &spans->op_info[op_info_i].u.down_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) /* Release inner node types */ - for(u = 0; u < outercount; u++) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) + for (u = 0; u < outercount; u++) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) inner_types_freed = TRUE; } /* end else */ /* Allocate space for the MPI data type list node */ - if(NULL == (type_node = H5FL_MALLOC(H5S_mpio_mpitype_node_t))) + if (NULL == (type_node = H5FL_MALLOC(H5S_mpio_mpitype_node_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate MPI data type list node") /* Set up MPI type node */ @@ -1302,11 +1308,11 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, type_node->next = NULL; /* Add MPI type node to list */ - if(type_list->head == NULL) + if (type_list->head == NULL) type_list->head = type_list->tail = type_node; else { type_list->tail->next = type_node; - type_list->tail = type_node; + type_list->tail = type_node; } /* end else */ /* Remember that we've visited this span tree */ @@ -1318,22 +1324,21 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, done: /* General cleanup */ - if(inner_type != NULL) { - if(!inner_types_freed) - for(u = 0; u < outercount; u++) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) + if (inner_type != NULL) { + if (!inner_types_freed) + for (u = 0; u < outercount; u++) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) H5MM_free(inner_type); } /* end if */ - if(blocklen != NULL) + if (blocklen != NULL) H5MM_free(blocklen); - if(disp != NULL) + if (disp != NULL) H5MM_free(disp); - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__obtain_datatype() */ - /*------------------------------------------------------------------------- * Function: H5S_mpio_space_type * @@ -1352,11 +1357,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, - int *count, hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map, - hbool_t *is_permuted) +H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1365,7 +1369,7 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type HDassert(elmt_size); /* Create MPI type based on the kind of selection */ - switch(H5S_GET_EXTENT_TYPE(space)) { + switch (H5S_GET_EXTENT_TYPE(space)) { case H5S_NULL: case H5S_SCALAR: case H5S_SIMPLE: @@ -1373,11 +1377,12 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type * out-of-order point selection, then permute this selection which * should be a memory selection to match the file space permutation. */ - if(TRUE == *is_permuted) { - switch(H5S_GET_SELECT_TYPE(space)) { + if (TRUE == *is_permuted) { + switch (H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: - if(H5S__mpio_none_type(new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'none' selection to MPI type") + if (H5S__mpio_none_type(new_type, count, is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'none' selection to MPI type") break; case H5S_SEL_ALL: @@ -1386,8 +1391,10 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type /* Sanity check */ HDassert(!do_permute); - if(H5S__mpio_permute_type(space, elmt_size, permute_map, new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'all' selection to MPI type") + if (H5S__mpio_permute_type(space, elmt_size, permute_map, new_type, count, + is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'all' selection to MPI type") break; case H5S_SEL_ERROR: @@ -1396,33 +1403,40 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type HDassert("unknown selection type" && 0); break; } /* end switch */ - } /* end if */ + } /* end if */ /* the file space is not permuted, so do a regular selection */ else { - switch(H5S_GET_SELECT_TYPE(space)) { + switch (H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: - if(H5S__mpio_none_type(new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert 'none' selection to MPI type") + if (H5S__mpio_none_type(new_type, count, is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'none' selection to MPI type") break; case H5S_SEL_ALL: - if(H5S__mpio_all_type(space, elmt_size, new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert 'all' selection to MPI type") + if (H5S__mpio_all_type(space, elmt_size, new_type, count, is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'all' selection to MPI type") break; case H5S_SEL_POINTS: - if(H5S__mpio_point_type(space, elmt_size, new_type, count, is_derived_type, do_permute, permute_map, is_permuted) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'point' selection to MPI type") + if (H5S__mpio_point_type(space, elmt_size, new_type, count, is_derived_type, + do_permute, permute_map, is_permuted) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'point' selection to MPI type") break; case H5S_SEL_HYPERSLABS: - if((H5S_SELECT_IS_REGULAR(space) == TRUE)) { - if(H5S__mpio_reg_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert regular 'hyperslab' selection to MPI type") + if ((H5S_SELECT_IS_REGULAR(space) == TRUE)) { + if (H5S__mpio_reg_hyper_type(space, elmt_size, new_type, count, is_derived_type) < + 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert regular 'hyperslab' selection to MPI type") } /* end if */ - else - if(H5S__mpio_span_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert irregular 'hyperslab' selection to MPI type") + else if (H5S__mpio_span_hyper_type(space, elmt_size, new_type, count, + is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert irregular 'hyperslab' selection to MPI type") break; case H5S_SEL_ERROR: @@ -1431,7 +1445,7 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type HDassert("unknown selection type" && 0); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case H5S_NO_CLASS: @@ -1444,5 +1458,4 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_mpio_space_type() */ -#endif /* H5_HAVE_PARALLEL */ - +#endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Snone.c b/src/H5Snone.c index 672302d..e76dc6a 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -22,72 +22,65 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Selection callbacks */ -static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -static herr_t H5S__none_release(H5S_t *space); -static htri_t H5S__none_is_valid(const H5S_t *space); +static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S__none_release(H5S_t *space); +static htri_t H5S__none_is_valid(const H5S_t *space); static hssize_t H5S__none_serial_size(const H5S_t *space); -static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p); -static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); -static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off); -static int H5S__none_unlim_dim(const H5S_t *space); -static htri_t H5S__none_is_contiguous(const H5S_t *space); -static htri_t H5S__none_is_single(const H5S_t *space); -static htri_t H5S__none_is_regular(const H5S_t *space); -static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__none_intersect_block(const H5S_t *space, const hsize_t *start, - const hsize_t *end); -static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset); -static herr_t H5S__none_adjust_s(H5S_t *space, const hssize_t *offset); -static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset); -static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p); +static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p); +static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off); +static int H5S__none_unlim_dim(const H5S_t *space); +static htri_t H5S__none_is_contiguous(const H5S_t *space); +static htri_t H5S__none_is_single(const H5S_t *space); +static htri_t H5S__none_is_regular(const H5S_t *space); +static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__none_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset); +static herr_t H5S__none_adjust_s(H5S_t *space, const hssize_t *offset); +static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset); +static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); +static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ -static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__none_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__none_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); -static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter); - +static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter); +static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__none_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); +static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter); /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -119,7 +112,6 @@ const H5S_select_class_t H5S_sel_none[1] = {{ H5S__none_iter_init, }}; - /*******************/ /* Local Variables */ /*******************/ @@ -139,8 +131,6 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ H5S__none_iter_release, }}; - - /*------------------------------------------------------------------------- * Function: H5S__none_iter_init * @@ -168,7 +158,6 @@ H5S__none_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_coords * @@ -194,7 +183,6 @@ H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_coords() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_block * @@ -209,7 +197,8 @@ H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR *------------------------------------------------------------------------- */ static herr_t -H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) +H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *start, + hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -221,7 +210,6 @@ H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_ FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_nelmts * @@ -245,7 +233,6 @@ H5S__none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(0) } /* end H5S__none_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_has_next_block @@ -274,7 +261,6 @@ H5S__none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_has_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_next @@ -305,7 +291,6 @@ H5S__none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED n FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_next() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_next_block @@ -334,7 +319,6 @@ H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_get_seq_list @@ -365,9 +349,9 @@ H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, - size_t H5_ATTR_UNUSED maxseq, size_t H5_ATTR_UNUSED maxelem, size_t *nseq, - size_t *nelem, hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len) +H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED maxseq, + size_t H5_ATTR_UNUSED maxelem, size_t *nseq, size_t *nelem, + hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len) { FUNC_ENTER_STATIC_NOERR @@ -389,7 +373,6 @@ H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_release @@ -418,7 +401,6 @@ H5S__none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__none_release @@ -447,7 +429,6 @@ H5S__none_release(H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_release() */ - /*-------------------------------------------------------------------------- NAME H5S__none_copy @@ -482,7 +463,6 @@ H5S__none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUS FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_valid @@ -513,7 +493,6 @@ H5S__none_is_valid(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5S__none_serial_size @@ -547,7 +526,6 @@ H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(16) } /* end H5S__none_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__none_serialize @@ -572,7 +550,7 @@ H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p) { - uint8_t *pp = (*p); /* Local pointer for decoding */ + uint8_t *pp = (*p); /* Local pointer for decoding */ FUNC_ENTER_STATIC_NOERR @@ -584,8 +562,8 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(pp, (uint32_t)H5S_NONE_VERSION_1); /* Store the version number */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ /* Update encoding pointer */ *p = pp; @@ -593,7 +571,6 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__none_deserialize @@ -619,10 +596,10 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p) { - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, - either *space or a newly allocated one */ - uint32_t version; /* Version number */ - herr_t ret_value = SUCCEED; /* return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + uint32_t version; /* Version number */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -634,8 +611,8 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) is moved from H5S_select_deserialize() in H5Sselect.c to here. This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -644,30 +621,29 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(*p, version); - if(version < H5S_NONE_VERSION_1 || version > H5S_NONE_VERSION_LATEST) + if (version < H5S_NONE_VERSION_1 || version > H5S_NONE_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for none selection") /* Skip over the remainder of the header */ *p += 8; /* Change to "none" selection */ - if(H5S_select_none(tmp_space) < 0) + if (H5S_select_none(tmp_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__none_bounds @@ -694,7 +670,8 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) +H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, + hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -705,7 +682,6 @@ H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *star FUNC_LEAVE_NOAPI(FAIL) } /* end H5S_none_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__none_offset @@ -737,7 +713,6 @@ H5S__none_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offs FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__none_unlim_dim @@ -765,7 +740,6 @@ H5S__none_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(-1) } /* end H5S__none_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_contiguous @@ -794,7 +768,6 @@ H5S__none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_single @@ -823,7 +796,6 @@ H5S__none_is_single(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_regular @@ -854,7 +826,6 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__none_shape_same @@ -875,8 +846,7 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, - const H5S_t H5_ATTR_UNUSED *space2) +H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, const H5S_t H5_ATTR_UNUSED *space2) { FUNC_ENTER_STATIC_NOERR @@ -887,7 +857,6 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__none_intersect_block @@ -908,8 +877,8 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, - const hsize_t H5_ATTR_UNUSED *start, const hsize_t H5_ATTR_UNUSED *end) +H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, + const hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -922,7 +891,6 @@ H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_adjust_u @@ -953,7 +921,6 @@ H5S__none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *of FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S__none_adjust_s @@ -984,7 +951,6 @@ H5S__none_adjust_s(H5S_t H5_ATTR_UNUSED *space, const hssize_t H5_ATTR_UNUSED *o FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_adjust_s() */ - /*------------------------------------------------------------------------- * Function: H5S__none_project_scalar * @@ -1009,7 +975,6 @@ H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUS FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_project_scalar() */ - /*------------------------------------------------------------------------- * Function: H5S__none_project_simple * @@ -1024,10 +989,10 @@ H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUS *------------------------------------------------------------------------- */ static herr_t -H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, - H5S_t *new_space, hsize_t H5_ATTR_UNUSED *offset) +H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, H5S_t *new_space, + hsize_t H5_ATTR_UNUSED *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1037,14 +1002,13 @@ H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, HDassert(offset); /* Select the entire new space */ - if(H5S_select_none(new_space) < 0) + if (H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to set none selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S_select_none @@ -1065,7 +1029,7 @@ done: herr_t H5S_select_none(H5S_t *space) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1073,7 +1037,7 @@ H5S_select_none(H5S_t *space) HDassert(space); /* Remove current selection first */ - if(H5S_SELECT_RELEASE(space) < 0) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab") /* Set number of elements in selection */ @@ -1086,7 +1050,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_none() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_none @@ -1107,21 +1070,20 @@ done: herr_t H5Sselect_none(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value = SUCCEED; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Change to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_none() */ - diff --git a/src/H5Spkg.h b/src/H5Spkg.h index e08fedf..3aced26 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -30,62 +30,60 @@ #include "H5Sprivate.h" /* Other private headers needed by this file */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Oprivate.h" /* Object headers */ /* Flags to indicate special dataspace features are active */ -#define H5S_VALID_MAX 0x01 -#define H5S_VALID_PERM 0x02 +#define H5S_VALID_MAX 0x01 +#define H5S_VALID_PERM 0x02 /* Flags for serialization of selections */ -#define H5S_HYPER_REGULAR 0x01 -#define H5S_SELECT_FLAG_BITS (H5S_HYPER_REGULAR) +#define H5S_HYPER_REGULAR 0x01 +#define H5S_SELECT_FLAG_BITS (H5S_HYPER_REGULAR) /* Versions for H5S_SEL_HYPER selection info */ -#define H5S_HYPER_VERSION_1 1 -#define H5S_HYPER_VERSION_2 2 -#define H5S_HYPER_VERSION_3 3 -#define H5S_HYPER_VERSION_LATEST H5S_HYPER_VERSION_3 +#define H5S_HYPER_VERSION_1 1 +#define H5S_HYPER_VERSION_2 2 +#define H5S_HYPER_VERSION_3 3 +#define H5S_HYPER_VERSION_LATEST H5S_HYPER_VERSION_3 /* Versions for H5S_SEL_POINTS selection info */ -#define H5S_POINT_VERSION_1 1 -#define H5S_POINT_VERSION_2 2 -#define H5S_POINT_VERSION_LATEST H5S_POINT_VERSION_2 +#define H5S_POINT_VERSION_1 1 +#define H5S_POINT_VERSION_2 2 +#define H5S_POINT_VERSION_LATEST H5S_POINT_VERSION_2 /* Versions for H5S_SEL_NONE selection info */ -#define H5S_NONE_VERSION_1 1 -#define H5S_NONE_VERSION_LATEST H5S_NONE_VERSION_1 +#define H5S_NONE_VERSION_1 1 +#define H5S_NONE_VERSION_LATEST H5S_NONE_VERSION_1 /* Versions for H5S_SEL_ALL selection info */ -#define H5S_ALL_VERSION_1 1 -#define H5S_ALL_VERSION_LATEST H5S_ALL_VERSION_1 +#define H5S_ALL_VERSION_1 1 +#define H5S_ALL_VERSION_LATEST H5S_ALL_VERSION_1 /* Encoded size of selection info for H5S_SEL_POINTS/H5S_SEL_HYPER */ -#define H5S_SELECT_INFO_ENC_SIZE_2 0x02 /* 2 bytes: 16 bits */ -#define H5S_SELECT_INFO_ENC_SIZE_4 0x04 /* 4 bytes: 32 bits */ -#define H5S_SELECT_INFO_ENC_SIZE_8 0x08 /* 8 bytes: 64 bits */ -#define H5S_SELECT_INFO_ENC_SIZE_BITS ( H5S_SELECT_INFO_ENC_SIZE_2 | \ - H5S_SELECT_INFO_ENC_SIZE_4 | \ - H5S_SELECT_INFO_ENC_SIZE_8 ) +#define H5S_SELECT_INFO_ENC_SIZE_2 0x02 /* 2 bytes: 16 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_4 0x04 /* 4 bytes: 32 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_8 0x08 /* 8 bytes: 64 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_BITS \ + (H5S_SELECT_INFO_ENC_SIZE_2 | H5S_SELECT_INFO_ENC_SIZE_4 | H5S_SELECT_INFO_ENC_SIZE_8) -#define H5S_UINT16_MAX 0x0000FFFF /* 2^16 - 1 = 65,535 */ -#define H5S_UINT32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4,294,967,295 */ -#define H5S_UINT64_MAX ((hsize_t)(-1L)) /* 2^64 - 1 = 18,446,744,073,709,551,615 */ +#define H5S_UINT16_MAX 0x0000FFFF /* 2^16 - 1 = 65,535 */ +#define H5S_UINT32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4,294,967,295 */ +#define H5S_UINT64_MAX ((hsize_t)(-1L)) /* 2^64 - 1 = 18,446,744,073,709,551,615 */ /* Length of stack-allocated sequences for "project intersect" routines */ #define H5S_PROJECT_INTERSECT_NSEQS 256 /* Internal flags for initializing selection iterators */ -#define H5S_SEL_ITER_API_CALL 0x1000 /* Selection iterator created from API call */ - +#define H5S_SEL_ITER_API_CALL 0x1000 /* Selection iterator created from API call */ /* Initial version of the dataspace information */ -#define H5O_SDSPACE_VERSION_1 1 +#define H5O_SDSPACE_VERSION_1 1 /* This version adds support for "null" dataspaces, encodes the type of the * dataspace in the message and eliminated the rest of the "reserved" * bytes. */ -#define H5O_SDSPACE_VERSION_2 2 +#define H5O_SDSPACE_VERSION_2 2 /* The latest version of the format. Look through the 'encode' * and 'size' callbacks for places to change when updating this. */ @@ -93,7 +91,7 @@ /* Maximum dimension size (highest value that is not a special value e.g. * H5S_UNLIMITED) */ -#define H5S_MAX_SIZE ((hsize_t)(hssize_t)(-2)) +#define H5S_MAX_SIZE ((hsize_t)(hssize_t)(-2)) /* Macro for checking if two ranges overlap one another */ /* @@ -102,23 +100,22 @@ * high bound of the other. */ /* (Assumes that low & high bounds are _inclusive_) */ -#define H5S_RANGE_OVERLAP(L1, H1, L2, H2) (!((L1) > (H2) || (L2) > (H1))) - +#define H5S_RANGE_OVERLAP(L1, H1, L2, H2) (!((L1) > (H2) || (L2) > (H1))) /* * Dataspace extent information */ /* Extent container */ struct H5S_extent_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ - H5S_class_t type; /* Type of extent */ - unsigned version; /* Version of object header message to encode this object with */ - hsize_t nelem; /* Number of elements in extent */ + H5S_class_t type; /* Type of extent */ + unsigned version; /* Version of object header message to encode this object with */ + hsize_t nelem; /* Number of elements in extent */ - unsigned rank; /* Number of dimensions */ - hsize_t *size; /* Current size of the dimensions */ - hsize_t *max; /* Maximum size of the dimensions */ + unsigned rank; /* Number of dimensions */ + hsize_t *size; /* Current size of the dimensions */ + hsize_t *max; /* Maximum size of the dimensions */ }; /* @@ -127,48 +124,48 @@ struct H5S_extent_t { /* Node in point selection list (typedef'd in H5Sprivate.h) */ struct H5S_pnt_node_t { - struct H5S_pnt_node_t *next; /* Pointer to next point in list */ - hsize_t pnt[]; /* Selected point */ - /* (NOTE: This uses the C99 "flexible array member" feature) */ + struct H5S_pnt_node_t *next; /* Pointer to next point in list */ + hsize_t pnt[]; /* Selected point */ + /* (NOTE: This uses the C99 "flexible array member" feature) */ }; /* Information about point selection list (typedef'd in H5Sprivate.h) */ struct H5S_pnt_list_t { /* The following two fields defines the bounding box of the whole set of points, relative to the offset */ - hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */ - hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */ + hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */ + hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */ - H5S_pnt_node_t *head; /* Pointer to head of point list */ - H5S_pnt_node_t *tail; /* Pointer to tail of point list */ + H5S_pnt_node_t *head; /* Pointer to head of point list */ + H5S_pnt_node_t *tail; /* Pointer to tail of point list */ }; /* Information about hyperslab spans */ /* Information a particular hyperslab span (typedef'd in H5Sprivate.h) */ struct H5S_hyper_span_t { - hsize_t low, high; /* Low & high bounds of elements selected for span, inclusive */ - struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */ - struct H5S_hyper_span_t *next; /* Pointer to next span in list */ + hsize_t low, high; /* Low & high bounds of elements selected for span, inclusive */ + struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */ + struct H5S_hyper_span_t * next; /* Pointer to next span in list */ }; /* "Operation info" struct. Used to hold temporary information during copies, * 'adjust', 'nelem', and 'rebuild' operations, and higher level algorithms that * generate this information. */ typedef struct H5S_hyper_op_info_t { - uint64_t op_gen; /* Generation of the scratch info */ + uint64_t op_gen; /* Generation of the scratch info */ union { struct H5S_hyper_span_info_t *copied; /* Pointer to already copied span tree */ - hsize_t nelmts; /* # of elements */ - hsize_t nblocks; /* # of blocks */ + hsize_t nelmts; /* # of elements */ + hsize_t nblocks; /* # of blocks */ #ifdef H5_HAVE_PARALLEL MPI_Datatype down_type; /* MPI datatype for span tree */ -#endif /* H5_HAVE_PARALLEL */ - }u; +#endif /* H5_HAVE_PARALLEL */ + } u; } H5S_hyper_op_info_t; /* Information about a list of hyperslab spans in one dimension (typedef'd in H5Sprivate.h) */ struct H5S_hyper_span_info_t { - unsigned count; /* Ref. count of number of spans which share this span */ + unsigned count; /* Ref. count of number of spans which share this span */ /* The following two fields define the bounding box of this set of spans * and all lower dimensions, relative to the offset. @@ -181,25 +178,26 @@ struct H5S_hyper_span_info_t { * arrays correspond to the bounds in "this" dimension, even if * it's not the highest level in the span tree. */ - hsize_t *low_bounds; /* The smallest element selected in each dimension */ - hsize_t *high_bounds; /* The largest element selected in each dimension */ + hsize_t *low_bounds; /* The smallest element selected in each dimension */ + hsize_t *high_bounds; /* The largest element selected in each dimension */ /* "Operation info" fields */ /* (Used during copies, 'adjust', 'nelem', and 'rebuild' operations) */ /* Currently the maximum number of simultaneous operations is 2 */ H5S_hyper_op_info_t op_info[2]; - struct H5S_hyper_span_t *head; /* Pointer to the first span of list of spans in the current dimension */ - struct H5S_hyper_span_t *tail; /* Pointer to the last span of list of spans in the current dimension */ - hsize_t bounds[]; /* Array for storing low & high bounds */ - /* (NOTE: This uses the C99 "flexible array member" feature) */ + struct H5S_hyper_span_t *head; /* Pointer to the first span of list of spans in the current dimension */ + struct H5S_hyper_span_t *tail; /* Pointer to the last span of list of spans in the current dimension */ + hsize_t bounds[]; /* Array for storing low & high bounds */ + /* (NOTE: This uses the C99 "flexible array member" feature) */ }; /* Enum for diminfo_valid field in H5S_hyper_sel_t */ typedef enum { - H5S_DIMINFO_VALID_IMPOSSIBLE, /* 0: diminfo is not valid and can never be valid with the current selection */ - H5S_DIMINFO_VALID_NO, /* 1: diminfo is not valid but may or may not be possible to constuct */ - H5S_DIMINFO_VALID_YES /* 2: diminfo is valid */ + H5S_DIMINFO_VALID_IMPOSSIBLE, /* 0: diminfo is not valid and can never be valid with the current selection + */ + H5S_DIMINFO_VALID_NO, /* 1: diminfo is not valid but may or may not be possible to constuct */ + H5S_DIMINFO_VALID_YES /* 2: diminfo is valid */ } H5S_diminfo_valid_t; /* Information about 'diminfo' form of hyperslab selection */ @@ -212,23 +210,23 @@ typedef struct { * used to set the hyperslab to the application when it queries the * hyperslab selection information. */ - H5S_hyper_dim_t app[H5S_MAX_RANK]; /* Application-set per-dim selection info */ - H5S_hyper_dim_t opt[H5S_MAX_RANK]; /* Optimized per-dim selection info */ + H5S_hyper_dim_t app[H5S_MAX_RANK]; /* Application-set per-dim selection info */ + H5S_hyper_dim_t opt[H5S_MAX_RANK]; /* Optimized per-dim selection info */ /* The following two fields defines the bounding box of the diminfo selection */ /* (relative to the offset) */ - hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */ - hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */ + hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */ + hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */ } H5S_hyper_diminfo_t; /* Information about hyperslab selection */ typedef struct { - H5S_diminfo_valid_t diminfo_valid; /* Whether the dataset has valid diminfo */ + H5S_diminfo_valid_t diminfo_valid; /* Whether the dataset has valid diminfo */ - H5S_hyper_diminfo_t diminfo; /* Dimension info form of hyperslab selection */ - int unlim_dim; /* Dimension where selection is unlimited, or -1 if none */ - hsize_t num_elem_non_unlim; /* # of elements in a "slice" excluding the unlimited dimension */ - H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information of all dimensions */ + H5S_hyper_diminfo_t diminfo; /* Dimension info form of hyperslab selection */ + int unlim_dim; /* Dimension where selection is unlimited, or -1 if none */ + hsize_t num_elem_non_unlim; /* # of elements in a "slice" excluding the unlimited dimension */ + H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information of all dimensions */ } H5S_hyper_sel_t; /* Selection information methods */ @@ -251,8 +249,7 @@ typedef herr_t (*H5S_sel_offset_func_t)(const H5S_t *space, hsize_t *offset); /* Method to get unlimited dimension of selection (or -1 for none) */ typedef int (*H5S_sel_unlim_dim_func_t)(const H5S_t *space); /* Method to get the number of elements in a slice through the unlimited dimension */ -typedef herr_t (*H5S_sel_num_elem_non_unlim_func_t)(const H5S_t *space, - hsize_t *num_elem_non_unlim); +typedef herr_t (*H5S_sel_num_elem_non_unlim_func_t)(const H5S_t *space, hsize_t *num_elem_non_unlim); /* Method to determine if current selection is contiguous */ typedef htri_t (*H5S_sel_is_contiguous_func_t)(const H5S_t *space); /* Method to determine if current selection is a single block */ @@ -262,7 +259,8 @@ typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space); /* Method to determine if two dataspaces' selections are the same shape */ typedef htri_t (*H5S_sel_shape_same_func_t)(const H5S_t *space1, const H5S_t *space2); /* Method to determine if selection intersects a block */ -typedef htri_t (*H5S_sel_intersect_block_func_t)(const H5S_t *space, const hsize_t *start, const hsize_t *end); +typedef htri_t (*H5S_sel_intersect_block_func_t)(const H5S_t *space, const hsize_t *start, + const hsize_t *end); /* Method to adjust a selection by an offset */ typedef herr_t (*H5S_sel_adjust_u_func_t)(H5S_t *space, const hsize_t *offset); /* Method to adjust a selection by an offset (signed) */ @@ -276,50 +274,58 @@ typedef herr_t (*H5S_sel_iter_init_func_t)(const H5S_t *space, H5S_sel_iter_t *s /* Selection class information */ typedef struct { - H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ + H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ /* Methods */ - H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */ - H5S_sel_release_func_t release; /* Method to release current selection */ - H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */ - H5S_sel_serial_size_func_t serial_size; /* Method to determine number of bytes required to store current selection */ - H5S_sel_serialize_func_t serialize; /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ - H5S_sel_deserialize_func_t deserialize; /* Method to store create selection from "serialized" form (a byte sequence suitable for storing on disk) */ - H5S_sel_bounds_func_t bounds; /* Method to determine to smallest n-D bounding box containing the current selection */ - H5S_sel_offset_func_t offset; /* Method to determine linear offset of initial element in selection within dataspace */ - H5S_sel_unlim_dim_func_t unlim_dim; /* Method to get unlimited dimension of selection (or -1 for none) */ - H5S_sel_num_elem_non_unlim_func_t num_elem_non_unlim; /* Method to get the number of elements in a slice through the unlimited dimension */ + H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */ + H5S_sel_release_func_t release; /* Method to release current selection */ + H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */ + H5S_sel_serial_size_func_t + serial_size; /* Method to determine number of bytes required to store current selection */ + H5S_sel_serialize_func_t serialize; /* Method to store current selection in "serialized" form (a byte + sequence suitable for storing on disk) */ + H5S_sel_deserialize_func_t deserialize; /* Method to store create selection from "serialized" form (a byte + sequence suitable for storing on disk) */ + H5S_sel_bounds_func_t + bounds; /* Method to determine to smallest n-D bounding box containing the current selection */ + H5S_sel_offset_func_t + offset; /* Method to determine linear offset of initial element in selection within dataspace */ + H5S_sel_unlim_dim_func_t unlim_dim; /* Method to get unlimited dimension of selection (or -1 for none) */ + H5S_sel_num_elem_non_unlim_func_t num_elem_non_unlim; /* Method to get the number of elements in a slice + through the unlimited dimension */ H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */ - H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ - H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ - H5S_sel_shape_same_func_t shape_same; /* Method to determine if two dataspaces' selections are the same shape */ - H5S_sel_intersect_block_func_t intersect_block; /* Method to determine if a dataspaces' selection intersects a block */ - H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */ - H5S_sel_adjust_s_func_t adjust_s; /* Method to adjust a selection by an offset (signed) */ - H5S_sel_project_scalar project_scalar; /* Method to construct scalar dataspace projection */ - H5S_sel_project_simple project_simple; /* Method to construct simple dataspace projection */ - H5S_sel_iter_init_func_t iter_init; /* Method to initialize iterator for current selection */ + H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ + H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ + H5S_sel_shape_same_func_t + shape_same; /* Method to determine if two dataspaces' selections are the same shape */ + H5S_sel_intersect_block_func_t + intersect_block; /* Method to determine if a dataspaces' selection intersects a block */ + H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */ + H5S_sel_adjust_s_func_t adjust_s; /* Method to adjust a selection by an offset (signed) */ + H5S_sel_project_scalar project_scalar; /* Method to construct scalar dataspace projection */ + H5S_sel_project_simple project_simple; /* Method to construct simple dataspace projection */ + H5S_sel_iter_init_func_t iter_init; /* Method to initialize iterator for current selection */ } H5S_select_class_t; /* Selection information object */ typedef struct { - const H5S_select_class_t *type; /* Pointer to selection's class info */ + const H5S_select_class_t *type; /* Pointer to selection's class info */ - hbool_t offset_changed; /* Indicate that the offset for the selection has been changed */ - hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ + hbool_t offset_changed; /* Indicate that the offset for the selection has been changed */ + hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ - hsize_t num_elem; /* Number of elements in selection */ + hsize_t num_elem; /* Number of elements in selection */ union { - H5S_pnt_list_t *pnt_lst; /* Info about list of selected points (order is important) */ - H5S_hyper_sel_t *hslab; /* Info about hyperslab selection */ + H5S_pnt_list_t * pnt_lst; /* Info about list of selected points (order is important) */ + H5S_hyper_sel_t *hslab; /* Info about hyperslab selection */ } sel_info; } H5S_select_t; /* Main dataspace structure (typedef'd in H5Sprivate.h) */ struct H5S_t { - H5S_extent_t extent; /* Dataspace extent (must stay first) */ - H5S_select_t select; /* Dataspace selection */ + H5S_extent_t extent; /* Dataspace extent (must stay first) */ + H5S_select_t select; /* Dataspace selection */ }; /* Selection iteration methods */ @@ -336,25 +342,31 @@ typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem); /* Method to move selection iterator to the next block in the selection */ typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter); /* Method to retrieve a list of offset/length sequences for selection iterator */ -typedef herr_t (*H5S_sel_iter_get_seq_list_func_t)(H5S_sel_iter_t *iter, - size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, - size_t *len); +typedef herr_t (*H5S_sel_iter_get_seq_list_func_t)(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, + size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); /* Method to release iterator for current selection */ typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter); /* Selection iteration class */ typedef struct H5S_sel_iter_class_t { - H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ + H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ /* Methods on selections */ - H5S_sel_iter_coords_func_t iter_coords; /* Method to retrieve the current coordinates of iterator for current selection */ - H5S_sel_iter_block_func_t iter_block; /* Method to retrieve the current block of iterator for current selection */ - H5S_sel_iter_nelmts_func_t iter_nelmts; /* Method to determine number of elements left in iterator for current selection */ - H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */ - H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */ - H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */ - H5S_sel_iter_get_seq_list_func_t iter_get_seq_list; /* Method to retrieve a list of offset/length sequences for selection iterator */ - H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ + H5S_sel_iter_coords_func_t + iter_coords; /* Method to retrieve the current coordinates of iterator for current selection */ + H5S_sel_iter_block_func_t + iter_block; /* Method to retrieve the current block of iterator for current selection */ + H5S_sel_iter_nelmts_func_t + iter_nelmts; /* Method to determine number of elements left in iterator for current selection */ + H5S_sel_iter_has_next_block_func_t + iter_has_next_block; /* Method to query if there is another block left in the selection */ + H5S_sel_iter_next_func_t + iter_next; /* Method to move selection iterator to the next element in the selection */ + H5S_sel_iter_next_block_func_t + iter_next_block; /* Method to move selection iterator to the next block in the selection */ + H5S_sel_iter_get_seq_list_func_t + iter_get_seq_list; /* Method to retrieve a list of offset/length sequences for selection iterator */ + H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ } H5S_sel_iter_class_t; /* @@ -382,25 +394,22 @@ H5_DLLVAR const unsigned H5O_sdspace_ver_bounds[H5F_LIBVER_NBOUNDS]; /* Extent functions */ H5_DLL herr_t H5S__extent_release(H5S_extent_t *extent); -H5_DLL herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, - hbool_t copy_max); +H5_DLL herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max); /* Operations on hyperslab selections */ H5_DLL uint64_t H5S__hyper_get_op_gen(void); -H5_DLL void H5S__hyper_rebuild(H5S_t *space); -H5_DLL herr_t H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2); -H5_DLL herr_t H5S__hyper_project_intersection(const H5S_t *src_space, - const H5S_t *dst_space, const H5S_t *src_intersect_space, H5S_t *proj_space, - hbool_t share_space); +H5_DLL void H5S__hyper_rebuild(H5S_t *space); +H5_DLL herr_t H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2); +H5_DLL herr_t H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, + const H5S_t *src_intersect_space, H5S_t *proj_space, + hbool_t share_space); /* Testing functions */ #ifdef H5S_TESTING -H5_DLL herr_t H5S__get_rebuild_status_test(hid_t space_id, - H5S_diminfo_valid_t *status1, H5S_diminfo_valid_t *status2); -H5_DLL herr_t H5S__get_diminfo_status_test(hid_t space_id, - H5S_diminfo_valid_t *status); +H5_DLL herr_t H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, + H5S_diminfo_valid_t *status2); +H5_DLL herr_t H5S__get_diminfo_status_test(hid_t space_id, H5S_diminfo_valid_t *status); H5_DLL htri_t H5S__internal_consistency_test(hid_t space_id); #endif /* H5S_TESTING */ #endif /*_H5Spkg_H*/ - diff --git a/src/H5Spoint.c b/src/H5Spoint.c index f53033b..d54f62e 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -22,27 +22,24 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -51,55 +48,50 @@ /* (Makes it easier to understand the alloc / free calls) */ typedef hsize_t hcoords_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, - const hsize_t *coord); -static H5S_pnt_list_t *H5S__copy_pnt_list(const H5S_pnt_list_t *src, - unsigned rank); -static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst); +static herr_t H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord); +static H5S_pnt_list_t *H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank); +static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst); /* Selection callbacks */ -static herr_t H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -static herr_t H5S__point_release(H5S_t *space); -static htri_t H5S__point_is_valid(const H5S_t *space); +static herr_t H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S__point_release(H5S_t *space); +static htri_t H5S__point_is_valid(const H5S_t *space); static hssize_t H5S__point_serial_size(const H5S_t *space); -static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__point_deserialize(H5S_t **space, const uint8_t **p); -static herr_t H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); -static herr_t H5S__point_offset(const H5S_t *space, hsize_t *off); -static int H5S__point_unlim_dim(const H5S_t *space); -static htri_t H5S__point_is_contiguous(const H5S_t *space); -static htri_t H5S__point_is_single(const H5S_t *space); -static htri_t H5S__point_is_regular(const H5S_t *space); -static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); -static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset); -static herr_t H5S__point_adjust_s(H5S_t *space, const hssize_t *offset); -static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset); -static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); -static herr_t H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size); +static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p); +static herr_t H5S__point_deserialize(H5S_t **space, const uint8_t **p); +static herr_t H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +static herr_t H5S__point_offset(const H5S_t *space, hsize_t *off); +static int H5S__point_unlim_dim(const H5S_t *space); +static htri_t H5S__point_is_contiguous(const H5S_t *space); +static htri_t H5S__point_is_single(const H5S_t *space); +static htri_t H5S__point_is_regular(const H5S_t *space); +static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset); +static herr_t H5S__point_adjust_s(H5S_t *space, const hssize_t *offset); +static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset); +static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); +static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size); /* Selection iteration callbacks */ -static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__point_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S__point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__point_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); +static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter); +static herr_t H5S__point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__point_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S__point_iter_release(H5S_sel_iter_t *sel_iter); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -133,11 +125,11 @@ const H5S_select_class_t H5S_sel_point[1] = {{ /* Format version bounds for dataspace hyperslab selection */ const unsigned H5O_sds_point_ver_bounds[] = { - H5S_POINT_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5S_POINT_VERSION_1, /* H5F_LIBVER_V18 */ - H5S_POINT_VERSION_1, /* H5F_LIBVER_V110 */ - H5S_POINT_VERSION_2, /* H5F_LIBVER_V112 */ - H5S_POINT_VERSION_2 /* H5F_LIBVER_LATEST */ + H5S_POINT_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5S_POINT_VERSION_1, /* H5F_LIBVER_V18 */ + H5S_POINT_VERSION_1, /* H5F_LIBVER_V110 */ + H5S_POINT_VERSION_2, /* H5F_LIBVER_V112 */ + H5S_POINT_VERSION_2 /* H5F_LIBVER_LATEST */ }; /*******************/ @@ -165,7 +157,6 @@ H5FL_BARR_DEFINE_STATIC(H5S_pnt_node_t, hcoords_t, H5S_MAX_RANK); /* Declare a free list to manage the H5S_pnt_list_t struct */ H5FL_DEFINE_STATIC(H5S_pnt_list_t); - /*------------------------------------------------------------------------- * Function: H5S__point_iter_init * @@ -181,7 +172,7 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t); static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -198,10 +189,10 @@ H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) * close the dataspace that the iterator is operating on, or undefined * behavior will occur. */ - if((iter->flags & H5S_SEL_ITER_API_CALL) && - !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) { + if ((iter->flags & H5S_SEL_ITER_API_CALL) && !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) { /* Copy the point list */ - if(NULL == (iter->u.pnt.pnt_lst = H5S__copy_pnt_list(space->select.sel_info.pnt_lst, space->extent.rank))) + if (NULL == + (iter->u.pnt.pnt_lst = H5S__copy_pnt_list(space->select.sel_info.pnt_lst, space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy point list") } /* end if */ else @@ -218,7 +209,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__point_iter_coords * @@ -247,7 +237,6 @@ H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_coords() */ - /*------------------------------------------------------------------------- * Function: H5S_point_iter_block * @@ -278,7 +267,6 @@ H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__point_iter_nelmts * @@ -302,7 +290,6 @@ H5S__point_iter_nelmts(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(iter->elmt_left) } /* end H5S__point_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_has_next_block @@ -323,7 +310,7 @@ H5S__point_iter_nelmts(const H5S_sel_iter_t *iter) static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -331,14 +318,13 @@ H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter) HDassert(iter); /* Check if there is another point in the list */ - if(iter->u.pnt.curr->next == NULL) + if (iter->u.pnt.curr->next == NULL) HGOTO_DONE(FALSE); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_has_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_next @@ -367,7 +353,7 @@ H5S__point_iter_next(H5S_sel_iter_t *iter, size_t nelem) HDassert(nelem > 0); /* Increment the iterator */ - while(nelem > 0) { + while (nelem > 0) { iter->u.pnt.curr = iter->u.pnt.curr->next; nelem--; } /* end while */ @@ -375,7 +361,6 @@ H5S__point_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_next() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_next_block @@ -407,7 +392,6 @@ H5S__point_iter_next_block(H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_get_seq_list @@ -438,18 +422,18 @@ H5S__point_iter_next_block(H5S_sel_iter_t *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, - size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) +H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, + hsize_t *off, size_t *len) { - size_t io_left; /* The number of bytes left in the selection */ - size_t start_io_left; /* The initial number of bytes left in the selection */ - H5S_pnt_node_t *node; /* Point node */ - unsigned ndims; /* Dimensionality of dataspace*/ - hsize_t acc; /* Coordinate accumulator */ - hsize_t loc; /* Coordinate offset */ - size_t curr_seq; /* Current sequence being operated on */ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* return value */ + size_t io_left; /* The number of bytes left in the selection */ + size_t start_io_left; /* The initial number of bytes left in the selection */ + H5S_pnt_node_t *node; /* Point node */ + unsigned ndims; /* Dimensionality of dataspace*/ + hsize_t acc; /* Coordinate accumulator */ + hsize_t loc; /* Coordinate offset */ + size_t curr_seq; /* Current sequence being operated on */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -471,24 +455,24 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem /* Walk through the points in the selection, starting at the current */ /* location in the iterator */ - node = iter->u.pnt.curr; + node = iter->u.pnt.curr; curr_seq = 0; - while(NULL != node) { + while (NULL != node) { /* Compute the offset of each selected point in the buffer */ - for(i = (int)(ndims - 1), acc = iter->elmt_size, loc = 0; i >= 0; i--) { + for (i = (int)(ndims - 1), acc = iter->elmt_size, loc = 0; i >= 0; i--) { loc += (hsize_t)((hssize_t)node->pnt[i] + iter->sel_off[i]) * acc; acc *= iter->dims[i]; } /* end for */ /* Check if this is a later point in the selection */ - if(curr_seq > 0) { + if (curr_seq > 0) { /* If a sorted sequence is requested, make certain we don't go backwards in the offset */ - if((iter->flags & H5S_SEL_ITER_GET_SEQ_LIST_SORTED) && loc < off[curr_seq - 1]) + if ((iter->flags & H5S_SEL_ITER_GET_SEQ_LIST_SORTED) && loc < off[curr_seq - 1]) break; /* Check if this point extends the previous sequence */ /* (Unlikely, but possible) */ - if(loc == (off[curr_seq - 1] + len[curr_seq - 1])) { + if (loc == (off[curr_seq - 1] + len[curr_seq - 1])) { /* Extend the previous sequence */ len[curr_seq - 1] += iter->elmt_size; } /* end if */ @@ -500,7 +484,7 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem /* Increment sequence count */ curr_seq++; } /* end else */ - } /* end if */ + } /* end if */ else { /* Add a new sequence */ off[curr_seq] = loc; @@ -518,16 +502,16 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem iter->elmt_left--; /* Check if we're finished with all sequences */ - if(curr_seq == maxseq) + if (curr_seq == maxseq) break; /* Check if we're finished with all the elements available */ - if(io_left == 0) + if (io_left == 0) break; /* Advance to the next point */ node = node->next; - } /* end while */ + } /* end while */ /* Set the number of sequences generated */ *nseq = curr_seq; @@ -538,7 +522,6 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_release @@ -557,7 +540,7 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__point_iter_release(H5S_sel_iter_t * iter) +H5S__point_iter_release(H5S_sel_iter_t *iter) { FUNC_ENTER_STATIC_NOERR @@ -565,14 +548,12 @@ H5S__point_iter_release(H5S_sel_iter_t * iter) HDassert(iter); /* If this iterator copied the point list, we must free it */ - if((iter->flags & H5S_SEL_ITER_API_CALL) && - !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) + if ((iter->flags & H5S_SEL_ITER_API_CALL) && !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) H5S__free_pnt_list(iter->u.pnt.pnt_lst); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__point_add @@ -596,8 +577,8 @@ static herr_t H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) { H5S_pnt_node_t *top = NULL, *curr = NULL, *new_node = NULL; /* Point selection nodes */ - unsigned u; /* Counter */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Counter */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -607,11 +588,11 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c HDassert(coord); HDassert(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND); - for(u = 0; u < num_elem; u++) { - unsigned dim; /* Counter for dimensions */ + for (u = 0; u < num_elem; u++) { + unsigned dim; /* Counter for dimensions */ /* Allocate space for the new node */ - if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, space->extent.rank))) + if (NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") /* Initialize fields in node */ @@ -621,7 +602,7 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c H5MM_memcpy(new_node->pnt, coord + (u * space->extent.rank), (space->extent.rank * sizeof(hsize_t))); /* Link into list */ - if(top == NULL) + if (top == NULL) top = new_node; else curr->next = new_node; @@ -633,31 +614,33 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c * So the following bound box update procedure works correctly * for the SET operation) */ - for(dim = 0; dim < space->extent.rank; dim++) { - space->select.sel_info.pnt_lst->low_bounds[dim] = MIN(space->select.sel_info.pnt_lst->low_bounds[dim], curr->pnt[dim]); - space->select.sel_info.pnt_lst->high_bounds[dim] = MAX(space->select.sel_info.pnt_lst->high_bounds[dim], curr->pnt[dim]); + for (dim = 0; dim < space->extent.rank; dim++) { + space->select.sel_info.pnt_lst->low_bounds[dim] = + MIN(space->select.sel_info.pnt_lst->low_bounds[dim], curr->pnt[dim]); + space->select.sel_info.pnt_lst->high_bounds[dim] = + MAX(space->select.sel_info.pnt_lst->high_bounds[dim], curr->pnt[dim]); } /* end for */ - } /* end for */ + } /* end for */ new_node = NULL; /* Insert the list of points selected in the proper place */ - if(op == H5S_SELECT_SET || op == H5S_SELECT_PREPEND) { + if (op == H5S_SELECT_SET || op == H5S_SELECT_PREPEND) { /* Append current list, if there is one */ - if(NULL != space->select.sel_info.pnt_lst->head) + if (NULL != space->select.sel_info.pnt_lst->head) curr->next = space->select.sel_info.pnt_lst->head; /* Put new list in point selection */ space->select.sel_info.pnt_lst->head = top; /* Change the tail pointer if tail has not been set */ - if(NULL == space->select.sel_info.pnt_lst->tail) + if (NULL == space->select.sel_info.pnt_lst->tail) space->select.sel_info.pnt_lst->tail = curr; - } /* end if */ - else { /* op==H5S_SELECT_APPEND */ - H5S_pnt_node_t *tmp_node; /* Temporary point selection node */ + } /* end if */ + else { /* op==H5S_SELECT_APPEND */ + H5S_pnt_node_t *tmp_node; /* Temporary point selection node */ tmp_node = space->select.sel_info.pnt_lst->head; - if(tmp_node != NULL) { + if (tmp_node != NULL) { HDassert(space->select.sel_info.pnt_lst->tail); space->select.sel_info.pnt_lst->tail->next = top; } /* end if */ @@ -667,29 +650,28 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c } /* end else */ /* Set the number of elements in the new selection */ - if(op == H5S_SELECT_SET) + if (op == H5S_SELECT_SET) space->select.num_elem = num_elem; else space->select.num_elem += num_elem; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Release possibly partially initialized new node */ - if(new_node) + if (new_node) new_node = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, new_node); /* Release possible linked list of nodes */ - while(top) { + while (top) { curr = top->next; - top = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, top); - top = curr; + top = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, top); + top = curr; } /* end while */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_add() */ - /*-------------------------------------------------------------------------- NAME H5S__point_release @@ -727,7 +709,6 @@ H5S__point_release(H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_release() */ - /*-------------------------------------------------------------------------- NAME H5S_select_elements @@ -756,10 +737,9 @@ H5S__point_release(H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, - const hsize_t *coord) +H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -770,24 +750,25 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, HDassert(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND); /* If we are setting a new selection, remove current selection first */ - if(op == H5S_SELECT_SET || H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) - if(H5S_SELECT_RELEASE(space) < 0) + if (op == H5S_SELECT_SET || H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release point selection") /* Allocate space for the point selection information if necessary */ - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS || space->select.sel_info.pnt_lst == NULL) { + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS || space->select.sel_info.pnt_lst == NULL) { hsize_t tmp = HSIZET_MAX; - if(NULL == (space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t))) + if (NULL == (space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information") /* Set the bound box to the default value */ - H5VM_array_fill(space->select.sel_info.pnt_lst->low_bounds, &tmp, sizeof(hsize_t), space->extent.rank); + H5VM_array_fill(space->select.sel_info.pnt_lst->low_bounds, &tmp, sizeof(hsize_t), + space->extent.rank); HDmemset(space->select.sel_info.pnt_lst->high_bounds, 0, sizeof(hsize_t) * space->extent.rank); } /* Add points to selection */ - if(H5S__point_add(space, op, num_elem, coord) < 0) + if (H5S__point_add(space, op, num_elem, coord) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert elements") /* Set selection type */ @@ -797,7 +778,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_elements() */ - /*-------------------------------------------------------------------------- NAME H5S__copy_pnt_list @@ -820,9 +800,9 @@ done: static H5S_pnt_list_t * H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) { - H5S_pnt_list_t *dst = NULL; /* New point list */ - H5S_pnt_node_t *curr, *new_tail; /* Point information nodes */ - H5S_pnt_list_t *ret_value = NULL; /* Return value */ + H5S_pnt_list_t *dst = NULL; /* New point list */ + H5S_pnt_node_t *curr, *new_tail; /* Point information nodes */ + H5S_pnt_list_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -831,16 +811,16 @@ H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) HDassert(rank > 0); /* Allocate room for the head of the point list */ - if(NULL == (dst = H5FL_MALLOC(H5S_pnt_list_t))) + if (NULL == (dst = H5FL_MALLOC(H5S_pnt_list_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate point list node") - curr = src->head; + curr = src->head; new_tail = NULL; - while(curr) { - H5S_pnt_node_t *new_node; /* New point information node */ + while (curr) { + H5S_pnt_node_t *new_node; /* New point information node */ /* Create new point */ - if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, rank))) + if (NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate point node") new_node->next = NULL; @@ -848,11 +828,11 @@ H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) H5MM_memcpy(new_node->pnt, curr->pnt, (rank * sizeof(hsize_t))); /* Keep the order the same when copying */ - if(NULL == new_tail) + if (NULL == new_tail) new_tail = dst->head = new_node; else { new_tail->next = new_node; - new_tail = new_node; + new_tail = new_node; } /* end else */ curr = curr->next; @@ -867,13 +847,12 @@ H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) ret_value = dst; done: - if(NULL == ret_value && dst) + if (NULL == ret_value && dst) H5S__free_pnt_list(dst); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__copy_pnt_list() */ - /*-------------------------------------------------------------------------- NAME H5S__free_pnt_list @@ -894,7 +873,7 @@ done: static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst) { - H5S_pnt_node_t *curr; /* Point information nodes */ + H5S_pnt_node_t *curr; /* Point information nodes */ FUNC_ENTER_STATIC_NOERR @@ -903,10 +882,10 @@ H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst) /* Traverse the list, freeing all memory */ curr = pnt_lst->head; - while(curr) { + while (curr) { H5S_pnt_node_t *tmp_node = curr; - curr = curr->next; + curr = curr->next; tmp_node = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, tmp_node); } /* end while */ @@ -915,7 +894,6 @@ H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst) FUNC_LEAVE_NOAPI_VOID } /* end H5S__free_pnt_list() */ - /*-------------------------------------------------------------------------- NAME H5S__point_copy @@ -939,7 +917,7 @@ H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst) static herr_t H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selection) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -948,14 +926,14 @@ H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selec HDassert(dst); /* Allocate room for the head of the point list */ - if(NULL == (dst->select.sel_info.pnt_lst = H5S__copy_pnt_list(src->select.sel_info.pnt_lst, src->extent.rank))) + if (NULL == + (dst->select.sel_info.pnt_lst = H5S__copy_pnt_list(src->select.sel_info.pnt_lst, src->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy point list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__point_is_valid @@ -979,19 +957,20 @@ done: static htri_t H5S__point_is_valid(const H5S_t *space) { - unsigned u; /* Counter */ - htri_t ret_value = TRUE; /* Return value */ + unsigned u; /* Counter */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(space); /* Check each dimension */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Bounds check the selected point + offset against the extent */ - if((space->select.sel_info.pnt_lst->high_bounds[u] + (hsize_t)space->select.offset[u]) > space->extent.size[u]) + if ((space->select.sel_info.pnt_lst->high_bounds[u] + (hsize_t)space->select.offset[u]) > + space->extent.size[u]) HGOTO_DONE(FALSE) - if(((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) + if (((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) HGOTO_DONE(FALSE) } /* end for */ @@ -999,7 +978,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_elem_npoints @@ -1020,16 +998,16 @@ done: hssize_t H5Sget_select_elem_npoints(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ - hssize_t ret_value; /* return value */ + H5S_t * space; /* Dataspace to modify selection of */ + hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection") ret_value = (hssize_t)H5S_GET_SELECT_NPOINTS(space); @@ -1038,7 +1016,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_elem_npoints() */ - /*-------------------------------------------------------------------------- NAME H5S__point_get_version_enc_size @@ -1071,53 +1048,55 @@ done: static herr_t H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size) { - hbool_t count_up_version = FALSE; /* Whether number of points exceed H5S_UINT32_MAX */ - hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */ - H5F_libver_t low_bound; /* The 'low' bound of library format versions */ - H5F_libver_t high_bound; /* The 'high' bound of library format versions */ - uint32_t tmp_version; /* Local temporary version */ - hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ - hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ - hsize_t max_size = 0; /* Maximum selection size */ - unsigned u; /* Local index veriable */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t count_up_version = FALSE; /* Whether number of points exceed H5S_UINT32_MAX */ + hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */ + H5F_libver_t low_bound; /* The 'low' bound of library format versions */ + H5F_libver_t high_bound; /* The 'high' bound of library format versions */ + uint32_t tmp_version; /* Local temporary version */ + hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ + hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ + hsize_t max_size = 0; /* Maximum selection size */ + unsigned u; /* Local index veriable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get bounding box for the selection */ HDmemset(bounds_end, 0, sizeof(bounds_end)); - if(H5S__point_bounds(space, bounds_start, bounds_end) < 0) + if (H5S__point_bounds(space, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") /* Determine whether number of points or high bounds exceeds (2^32 - 1) */ - if(space->select.num_elem > H5S_UINT32_MAX) + if (space->select.num_elem > H5S_UINT32_MAX) count_up_version = TRUE; else - for(u = 0; u < space->extent.rank; u++) - if(bounds_end[u] > H5S_UINT32_MAX) { + for (u = 0; u < space->extent.rank; u++) + if (bounds_end[u] > H5S_UINT32_MAX) { bound_up_version = TRUE; break; } /* end if */ /* If exceed (2^32 -1) */ - if(count_up_version || bound_up_version) + if (count_up_version || bound_up_version) tmp_version = H5S_POINT_VERSION_2; else tmp_version = H5S_POINT_VERSION_1; /* Get the file's low/high bounds */ - if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) + if (H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context") /* Upgrade to the version indicated by the file's low bound if higher */ tmp_version = MAX(tmp_version, H5O_sds_point_ver_bounds[low_bound]); /* Version bounds check */ - if(tmp_version > H5O_sds_point_ver_bounds[high_bound]) { - if(count_up_version) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of points in point selection exceeds 2^32") - else if(bound_up_version) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in point selection exceeds 2^32") + if (tmp_version > H5O_sds_point_ver_bounds[high_bound]) { + if (count_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "The number of points in point selection exceeds 2^32") + else if (bound_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "The end of bounding box in point selection exceeds 2^32") else HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace point selection version out of bounds") } /* end if */ @@ -1126,7 +1105,7 @@ H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t * *version = tmp_version; /* Get the encoded size use based on version */ - switch(tmp_version) { + switch (tmp_version) { case H5S_POINT_VERSION_1: *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; break; @@ -1134,14 +1113,14 @@ H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t * case H5S_POINT_VERSION_2: /* Find max for num_elem and bounds_end[] */ max_size = space->select.num_elem; - for(u = 0; u < space->extent.rank; u++) - if(bounds_end[u] > max_size) + for (u = 0; u < space->extent.rank; u++) + if (bounds_end[u] > max_size) max_size = bounds_end[u]; /* Determine the encoding size */ - if(max_size > H5S_UINT32_MAX) + if (max_size > H5S_UINT32_MAX) *enc_size = H5S_SELECT_INFO_ENC_SIZE_8; - else if(max_size > H5S_UINT16_MAX) + else if (max_size > H5S_UINT16_MAX) *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; else *enc_size = H5S_SELECT_INFO_ENC_SIZE_2; @@ -1156,7 +1135,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__point_get_version_enc_size() */ - /*-------------------------------------------------------------------------- NAME H5S__point_serial_size @@ -1179,25 +1157,25 @@ done: static hssize_t H5S__point_serial_size(const H5S_t *space) { - uint32_t version; /* Version number */ - uint8_t enc_size; /* Encoded size of point selection info */ - hssize_t ret_value = -1; /* Return value */ + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of point selection info */ + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC HDassert(space); /* Determine the version and encoded size for point selection */ - if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) + if (H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine version and enc_size") /* Basic number of bytes required to serialize point selection: */ - if(version >= H5S_POINT_VERSION_2) + if (version >= H5S_POINT_VERSION_2) /* * + + * + rank (4 bytes)> */ - ret_value=13; + ret_value = 13; else /* * + + + @@ -1209,13 +1187,12 @@ H5S__point_serial_size(const H5S_t *space) ret_value += enc_size; /* Count points in selection */ - ret_value += (hssize_t) (enc_size * space->extent.rank * space->select.num_elem); + ret_value += (hssize_t)(enc_size * space->extent.rank * space->select.num_elem); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__point_serialize @@ -1240,14 +1217,14 @@ done: static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p) { - H5S_pnt_node_t *curr; /* Point information nodes */ - uint8_t *pp; /* Local pointer for encoding */ - uint8_t *lenp = NULL; /* pointer to length location for later storage */ - uint32_t len=0; /* number of bytes used */ - unsigned u; /* local counting variable */ - uint32_t version; /* Version number */ - uint8_t enc_size; /* Encoded size of point selection info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_pnt_node_t *curr; /* Point information nodes */ + uint8_t * pp; /* Local pointer for encoding */ + uint8_t * lenp = NULL; /* pointer to length location for later storage */ + uint32_t len = 0; /* number of bytes used */ + unsigned u; /* local counting variable */ + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of point selection info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1258,27 +1235,28 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) HDassert(pp); /* Determine the version and encoded size for point selection info */ - if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) + if (H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine version and enc_size") /* Store the preamble information */ - UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ + UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, version); /* Store the version number */ - if(version >= 2) { + UINT32ENCODE(pp, version); /* Store the version number */ + if (version >= 2) { *(pp)++ = enc_size; /* Store size of point info */ - } else { + } + else { HDassert(version == H5S_POINT_VERSION_1); - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - lenp = pp; /* Keep the pointer to the length location for later */ - pp += 4; /* Skip over space for length */ - len += 8; /* Add in advance # of bytes for num of dimensions and num elements */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + lenp = pp; /* Keep the pointer to the length location for later */ + pp += 4; /* Skip over space for length */ + len += 8; /* Add in advance # of bytes for num of dimensions and num elements */ } /* Encode number of dimensions */ UINT32ENCODE(pp, (uint32_t)space->extent.rank); - switch(enc_size) { + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: HDassert(version == H5S_POINT_VERSION_2); @@ -1286,12 +1264,12 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) UINT16ENCODE(pp, (uint16_t)space->select.num_elem); /* Encode each point in selection */ - curr=space->select.sel_info.pnt_lst->head; - while(curr!=NULL) { + curr = space->select.sel_info.pnt_lst->head; + while (curr != NULL) { /* Encode each point */ - for(u=0; uextent.rank; u++) + for (u = 0; u < space->extent.rank; u++) UINT16ENCODE(pp, (uint16_t)curr->pnt[u]); - curr=curr->next; + curr = curr->next; } /* end while */ break; @@ -1302,16 +1280,16 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) UINT32ENCODE(pp, (uint32_t)space->select.num_elem); /* Encode each point in selection */ - curr=space->select.sel_info.pnt_lst->head; - while(curr!=NULL) { + curr = space->select.sel_info.pnt_lst->head; + while (curr != NULL) { /* Encode each point */ - for(u=0; uextent.rank; u++) + for (u = 0; u < space->extent.rank; u++) UINT32ENCODE(pp, (uint32_t)curr->pnt[u]); - curr=curr->next; + curr = curr->next; } /* end while */ /* Add 4 bytes times the rank for each element selected */ - if(version == H5S_POINT_VERSION_1) + if (version == H5S_POINT_VERSION_1) len += (uint32_t)space->select.num_elem * 4 * space->extent.rank; break; @@ -1322,12 +1300,12 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) UINT64ENCODE(pp, space->select.num_elem); /* Encode each point in selection */ - curr=space->select.sel_info.pnt_lst->head; - while(curr!=NULL) { + curr = space->select.sel_info.pnt_lst->head; + while (curr != NULL) { /* Encode each point */ - for(u=0; uextent.rank; u++) + for (u = 0; u < space->extent.rank; u++) UINT64ENCODE(pp, curr->pnt[u]); - curr=curr->next; + curr = curr->next; } /* end while */ break; @@ -1337,17 +1315,16 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) } /* end switch */ - if(version == H5S_POINT_VERSION_1) - UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ + if (version == H5S_POINT_VERSION_1) + UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ /* Update encoding pointer */ *p = pp; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S__point_serialize() */ +} /* H5S__point_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__point_deserialize @@ -1373,17 +1350,17 @@ done: static herr_t H5S__point_deserialize(H5S_t **space, const uint8_t **p) { - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, - either *space or a newly allocated one */ - hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */ - uint32_t version; /* Version number */ - uint8_t enc_size = 0; /* Encoded size of selection info */ - hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ - const uint8_t *pp; /* Local pointer for decoding */ - uint64_t num_elem = 0; /* Number of elements in selection */ - unsigned rank; /* Rank of points */ - unsigned i, j; /* local counting variables */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */ + uint32_t version; /* Version number */ + uint8_t enc_size = 0; /* Encoded size of selection info */ + hsize_t * coord = NULL, *tcoord; /* Pointer to array of elements */ + const uint8_t *pp; /* Local pointer for decoding */ + uint64_t num_elem = 0; /* Number of elements in selection */ + unsigned rank; /* Rank of points */ + unsigned i, j; /* local counting variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1397,8 +1374,8 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) is moved from H5S_select_deserialize() in H5Sselect.c to here. This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -1407,10 +1384,10 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(pp, version); - if(version < H5S_POINT_VERSION_1 || version > H5S_POINT_VERSION_LATEST) + if (version < H5S_POINT_VERSION_1 || version > H5S_POINT_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for point selection") - if(version >= (uint32_t)H5S_POINT_VERSION_2) + if (version >= (uint32_t)H5S_POINT_VERSION_2) /* Decode size of point info */ enc_size = *(pp)++; else { @@ -1420,25 +1397,26 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) } /* Check encoded size */ - if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) + if (enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection") /* Decode the rank of the point selection */ - UINT32DECODE(pp,rank); + UINT32DECODE(pp, rank); - if(!*space) { + if (!*space) { /* Patch the rank of the allocated dataspace */ (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); - if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) + if (H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") } /* end if */ else /* Verify the rank of the provided dataspace */ - if(rank != tmp_space->extent.rank) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace") + if (rank != tmp_space->extent.rank) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "rank of serialized selection does not match dataspace") /* decode the number of points */ - switch(enc_size) { + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: UINT16DECODE(pp, num_elem); break; @@ -1453,15 +1431,14 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) break; } /* end switch */ - /* Allocate space for the coordinates */ - if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t)))) + if (NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information") /* Retrieve the coordinates from the buffer */ - for(tcoord = coord, i = 0; i < num_elem; i++) - for(j = 0; j < (unsigned)rank; j++, tcoord++) - switch(enc_size) { + for (tcoord = coord, i = 0; i < num_elem; i++) + for (j = 0; j < (unsigned)rank; j++, tcoord++) + switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: UINT16DECODE(pp, *tcoord); break; @@ -1479,30 +1456,29 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) } /* end switch */ /* Select points */ - if(H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0) + if (H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Update decoding pointer */ *p = pp; /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") /* Free the coordinate array if necessary */ - if(coord != NULL) + if (coord != NULL) H5MM_xfree(coord); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__get_select_elem_pointlist @@ -1535,8 +1511,8 @@ done: static herr_t H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf) { - H5S_pnt_node_t *node; /* Point node */ - unsigned rank; /* Dataspace rank */ + H5S_pnt_node_t *node; /* Point node */ + unsigned rank; /* Dataspace rank */ FUNC_ENTER_STATIC_NOERR @@ -1550,23 +1526,22 @@ H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, hsize_t n node = space->select.sel_info.pnt_lst->head; /* Iterate to the first point to return */ - while(node != NULL && startpoint > 0) { + while (node != NULL && startpoint > 0) { startpoint--; node = node->next; - } /* end while */ + } /* end while */ /* Iterate through the node, copying each point's information */ - while(node != NULL && numpoints > 0) { + while (node != NULL && numpoints > 0) { H5MM_memcpy(buf, node->pnt, sizeof(hsize_t) * rank); buf += rank; numpoints--; node = node->next; - } /* end while */ + } /* end while */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__get_select_elem_pointlist() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_elem_pointlist @@ -1597,21 +1572,20 @@ H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, hsize_t n REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, - hsize_t numpoints, hsize_t buf[/*numpoints*/]) +H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, hsize_t buf[/*numpoints*/]) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ihh*[a2]h", spaceid, startpoint, numpoints, buf); /* Check args */ - if(NULL == buf) + if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer") - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection") ret_value = H5S__get_select_elem_pointlist(space, startpoint, numpoints, buf); @@ -1620,7 +1594,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_elem_pointlist() */ - /*-------------------------------------------------------------------------- NAME H5S__point_bounds @@ -1650,8 +1623,8 @@ done: static herr_t H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1661,24 +1634,26 @@ H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) HDassert(end); /* Loop over dimensions */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Sanity check */ - HDassert(space->select.sel_info.pnt_lst->low_bounds[u] <= space->select.sel_info.pnt_lst->high_bounds[u]); + HDassert(space->select.sel_info.pnt_lst->low_bounds[u] <= + space->select.sel_info.pnt_lst->high_bounds[u]); /* Check for offset moving selection negative */ - if(((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) + if (((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Set the low & high bounds in this dimension */ - start[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]); - end[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] + space->select.offset[u]); + start[u] = + (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]); + end[u] = + (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] + space->select.offset[u]); } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__point_offset @@ -1702,12 +1677,12 @@ done: static herr_t H5S__point_offset(const H5S_t *space, hsize_t *offset) { - const hsize_t *pnt; /* Pointer to a selected point's coordinates */ - const hssize_t *sel_offset; /* Pointer to the selection's offset */ - const hsize_t *dim_size; /* Pointer to a dataspace's extent */ - hsize_t accum; /* Accumulator for dimension sizes */ - int i; /* index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const hsize_t * pnt; /* Pointer to a selected point's coordinates */ + const hssize_t *sel_offset; /* Pointer to the selection's offset */ + const hsize_t * dim_size; /* Pointer to a dataspace's extent */ + hsize_t accum; /* Accumulator for dimension sizes */ + int i; /* index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1718,17 +1693,17 @@ H5S__point_offset(const H5S_t *space, hsize_t *offset) *offset = 0; /* Set up pointers to arrays of values */ - pnt = space->select.sel_info.pnt_lst->head->pnt; + pnt = space->select.sel_info.pnt_lst->head->pnt; sel_offset = space->select.offset; - dim_size = space->extent.size; + dim_size = space->extent.size; /* Loop through coordinates, calculating the linear offset */ accum = 1; - for(i = (int)space->extent.rank - 1; i >= 0; i--) { + for (i = (int)space->extent.rank - 1; i >= 0; i--) { hssize_t pnt_offset = (hssize_t)pnt[i] + sel_offset[i]; /* Point's offset in this dimension */ /* Check for offset moving selection out of the dataspace */ - if(pnt_offset < 0 || (hsize_t)pnt_offset >= dim_size[i]) + if (pnt_offset < 0 || (hsize_t)pnt_offset >= dim_size[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Add the point's offset in this dimension to the total linear offset */ @@ -1742,7 +1717,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__point_unlim_dim @@ -1771,7 +1745,6 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(-1) } /* end H5S__point_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__point_is_contiguous @@ -1796,22 +1769,22 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) static htri_t H5S__point_is_contiguous(const H5S_t *space) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(space); /* One point is definitely contiguous */ - if(space->select.num_elem == 1) + if (space->select.num_elem == 1) ret_value = TRUE; - else /* More than one point might be contiguous, but it's complex to check and we don't need it right now */ + else /* More than one point might be contiguous, but it's complex to check and we don't need it right now + */ ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__point_is_single @@ -1833,14 +1806,14 @@ H5S__point_is_contiguous(const H5S_t *space) static htri_t H5S__point_is_single(const H5S_t *space) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(space); /* One point is definitely 'single' :-) */ - if(space->select.num_elem == 1) + if (space->select.num_elem == 1) ret_value = TRUE; else ret_value = FALSE; @@ -1848,7 +1821,6 @@ H5S__point_is_single(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__point_is_regular @@ -1873,7 +1845,7 @@ H5S__point_is_single(const H5S_t *space) static htri_t H5S__point_is_regular(const H5S_t *space) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1881,7 +1853,7 @@ H5S__point_is_regular(const H5S_t *space) HDassert(space); /* Only simple check for regular points for now... */ - if(space->select.num_elem == 1) + if (space->select.num_elem == 1) ret_value = TRUE; else ret_value = FALSE; @@ -1889,7 +1861,6 @@ H5S__point_is_regular(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__point_shape_same @@ -1912,13 +1883,13 @@ H5S__point_is_regular(const H5S_t *space) static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) { - H5S_pnt_node_t *pnt1, *pnt2; /* Point information nodes */ - hssize_t offset[H5S_MAX_RANK]; /* Offset between the selections */ - unsigned space1_rank; /* Number of dimensions of first dataspace */ - unsigned space2_rank; /* Number of dimensions of second dataspace */ - int space1_dim; /* Current dimension in first dataspace */ - int space2_dim; /* Current dimension in second dataspace */ - htri_t ret_value = TRUE; /* Return value */ + H5S_pnt_node_t *pnt1, *pnt2; /* Point information nodes */ + hssize_t offset[H5S_MAX_RANK]; /* Offset between the selections */ + unsigned space1_rank; /* Number of dimensions of first dataspace */ + unsigned space2_rank; /* Number of dimensions of second dataspace */ + int space1_dim; /* Current dimension in first dataspace */ + int space2_dim; /* Current dimension in second dataspace */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1943,7 +1914,7 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) */ pnt1 = space1->select.sel_info.pnt_lst->head; pnt2 = space2->select.sel_info.pnt_lst->head; - while(space2_dim >= 0) { + while (space2_dim >= 0) { /* Set the relative locations of the selections */ offset[space1_dim] = (hssize_t)pnt2->pnt[space2_dim] - (hssize_t)pnt1->pnt[space1_dim]; @@ -1952,7 +1923,7 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ /* For dimensions that appear only in space1: */ - while(space1_dim >= 0) { + while (space1_dim >= 0) { /* Set the absolute offset of the remaining dimensions */ offset[space1_dim] = (hssize_t)pnt1->pnt[space1_dim]; @@ -1964,14 +1935,14 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) pnt2 = pnt2->next; /* Loop over remaining points */ - while(pnt1 && pnt2) { + while (pnt1 && pnt2) { /* Initialize dimensions */ space1_dim = (int)space1_rank - 1; space2_dim = (int)space2_rank - 1; /* Compare locations in common dimensions, including relative offset */ - while(space2_dim >= 0) { - if((hsize_t)((hssize_t)pnt1->pnt[space1_dim] + offset[space1_dim]) != pnt2->pnt[space2_dim]) + while (space2_dim >= 0) { + if ((hsize_t)((hssize_t)pnt1->pnt[space1_dim] + offset[space1_dim]) != pnt2->pnt[space2_dim]) HGOTO_DONE(FALSE) space1_dim--; @@ -1979,15 +1950,14 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ /* For dimensions that appear only in space1: */ - while(space1_dim >= 0) { + while (space1_dim >= 0) { /* Compare the absolute offset in the remaining dimensions */ - if((hssize_t)pnt1->pnt[space1_dim] != offset[space1_dim]) + if ((hssize_t)pnt1->pnt[space1_dim] != offset[space1_dim]) HGOTO_DONE(FALSE) space1_dim--; } /* end while */ - /* Advance to next point */ pnt1 = pnt1->next; pnt2 = pnt2->next; @@ -1997,7 +1967,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__point_intersect_block @@ -2018,11 +1987,10 @@ done: REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, - const hsize_t *end) +H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end) { - H5S_pnt_node_t *pnt; /* Point information node */ - htri_t ret_value = FALSE; /* Return value */ + H5S_pnt_node_t *pnt; /* Point information node */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -2034,16 +2002,16 @@ H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, /* Loop over points */ pnt = space->select.sel_info.pnt_lst->head; - while(pnt) { - unsigned u; /* Local index variable */ + while (pnt) { + unsigned u; /* Local index variable */ /* Verify that the point is within the block */ - for(u = 0; u < space->extent.rank; u++) - if(pnt->pnt[u] < start[u] || pnt->pnt[u] > end[u]) + for (u = 0; u < space->extent.rank; u++) + if (pnt->pnt[u] < start[u] || pnt->pnt[u] > end[u]) break; /* Check if point was within block for all dimensions */ - if(u == space->extent.rank) + if (u == space->extent.rank) HGOTO_DONE(TRUE) /* Advance to next point */ @@ -2054,7 +2022,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__point_adjust_u @@ -2076,10 +2043,10 @@ done: static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) { - hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ - H5S_pnt_node_t *node; /* Point node */ - unsigned rank; /* Dataspace rank */ - unsigned u; /* Local index variable */ + hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ + H5S_pnt_node_t *node; /* Point node */ + unsigned rank; /* Dataspace rank */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -2087,20 +2054,20 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) HDassert(offset); /* Check for an all-zero offset vector */ - for(u = 0; u < space->extent.rank; u++) - if(0 != offset[u]) { + for (u = 0; u < space->extent.rank; u++) + if (0 != offset[u]) { non_zero_offset = TRUE; break; } /* Only perform operation if the offset is non-zero */ - if(non_zero_offset) { + if (non_zero_offset) { /* Iterate through the nodes, checking the bounds on each element */ node = space->select.sel_info.pnt_lst->head; rank = space->extent.rank; - while(node) { + while (node) { /* Adjust each coordinate for point node */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { /* Check for offset moving selection negative */ HDassert(node->pnt[u] >= offset[u]); @@ -2113,16 +2080,15 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) } /* end while */ /* update the bound box of the selection */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { space->select.sel_info.pnt_lst->low_bounds[u] -= offset[u]; space->select.sel_info.pnt_lst->high_bounds[u] -= offset[u]; } /* end for */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S__point_adjust_s @@ -2144,10 +2110,10 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) static herr_t H5S__point_adjust_s(H5S_t *space, const hssize_t *offset) { - hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ - H5S_pnt_node_t *node; /* Point node */ - unsigned rank; /* Dataspace rank */ - unsigned u; /* Local index variable */ + hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ + H5S_pnt_node_t *node; /* Point node */ + unsigned rank; /* Dataspace rank */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -2155,20 +2121,20 @@ H5S__point_adjust_s(H5S_t *space, const hssize_t *offset) HDassert(offset); /* Check for an all-zero offset vector */ - for(u = 0; u < space->extent.rank; u++) - if(0 != offset[u]) { + for (u = 0; u < space->extent.rank; u++) + if (0 != offset[u]) { non_zero_offset = TRUE; break; } /* end if */ /* Only perform operation if the offset is non-zero */ - if(non_zero_offset) { + if (non_zero_offset) { /* Iterate through the nodes, checking the bounds on each element */ node = space->select.sel_info.pnt_lst->head; rank = space->extent.rank; - while(node) { + while (node) { /* Adjust each coordinate for point node */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { /* Check for offset moving selection negative */ HDassert((hssize_t)node->pnt[u] >= offset[u]); @@ -2181,18 +2147,18 @@ H5S__point_adjust_s(H5S_t *space, const hssize_t *offset) } /* end while */ /* update the bound box of the selection */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { HDassert((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] >= offset[u]); - space->select.sel_info.pnt_lst->low_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] - offset[u]); - space->select.sel_info.pnt_lst->high_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] - offset[u]); + space->select.sel_info.pnt_lst->low_bounds[u] = + (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] - offset[u]); + space->select.sel_info.pnt_lst->high_bounds[u] = + (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] - offset[u]); } /* end for */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_adjust_s() */ - - /*------------------------------------------------------------------------- * Function: H5S__point_project_scalar * @@ -2209,8 +2175,8 @@ H5S__point_adjust_s(H5S_t *space, const hssize_t *offset) static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset) { - const H5S_pnt_node_t *node; /* Point node */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5S_pnt_node_t *node; /* Point node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2222,8 +2188,9 @@ H5S__point_project_scalar(const H5S_t *space, hsize_t *offset) node = space->select.sel_info.pnt_lst->head; /* Check for more than one point selected */ - if(node->next) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "point selection of one element has more than one node!") + if (node->next) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "point selection of one element has more than one node!") /* Calculate offset of selection in projected buffer */ *offset = H5VM_array_offset(space->extent.rank, space->extent.size, node->pnt); @@ -2232,7 +2199,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_project_scalar() */ - /*------------------------------------------------------------------------- * Function: H5S_point_project_simple * @@ -2249,12 +2215,12 @@ done: static herr_t H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset) { - const H5S_pnt_node_t *base_node; /* Point node in base space */ - H5S_pnt_node_t *new_node; /* Point node in new space */ - H5S_pnt_node_t *prev_node; /* Previous point node in new space */ - unsigned rank_diff; /* Difference in ranks between spaces */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5S_pnt_node_t *base_node; /* Point node in base space */ + H5S_pnt_node_t * new_node; /* Point node in new space */ + H5S_pnt_node_t * prev_node; /* Previous point node in new space */ + unsigned rank_diff; /* Difference in ranks between spaces */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2264,16 +2230,16 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of HDassert(offset); /* We are setting a new selection, remove any current selection in new dataspace */ - if(H5S_SELECT_RELEASE(new_space) < 0) + if (H5S_SELECT_RELEASE(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Allocate room for the head of the point list */ - if(NULL == (new_space->select.sel_info.pnt_lst = H5FL_MALLOC(H5S_pnt_list_t))) + if (NULL == (new_space->select.sel_info.pnt_lst = H5FL_MALLOC(H5S_pnt_list_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point list node") /* Check if the new space's rank is < or > base space's rank */ - if(new_space->extent.rank < base_space->extent.rank) { - hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ + if (new_space->extent.rank < base_space->extent.rank) { + hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ /* Compute the difference in ranks */ rank_diff = base_space->extent.rank - new_space->extent.rank; @@ -2286,21 +2252,22 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of /* Iterate through base space's point nodes, copying the point information */ base_node = base_space->select.sel_info.pnt_lst->head; prev_node = NULL; - while(base_node) { + while (base_node) { /* Create new point */ - if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank))) + if (NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") new_node->next = NULL; /* Copy over the point's coordinates */ - H5MM_memcpy(new_node->pnt, &base_node->pnt[rank_diff], (new_space->extent.rank * sizeof(hsize_t))); + H5MM_memcpy(new_node->pnt, &base_node->pnt[rank_diff], + (new_space->extent.rank * sizeof(hsize_t))); /* Keep the order the same when copying */ - if(NULL == prev_node) + if (NULL == prev_node) prev_node = new_space->select.sel_info.pnt_lst->head = new_node; else { prev_node->next = new_node; - prev_node = new_node; + prev_node = new_node; } /* end else */ /* Advance to next node */ @@ -2308,11 +2275,13 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of } /* end while */ /* Update the bounding box */ - for(u = 0; u < new_space->extent.rank; u++) { - new_space->select.sel_info.pnt_lst->low_bounds[u] = base_space->select.sel_info.pnt_lst->low_bounds[u + rank_diff]; - new_space->select.sel_info.pnt_lst->high_bounds[u] = base_space->select.sel_info.pnt_lst->high_bounds[u + rank_diff]; + for (u = 0; u < new_space->extent.rank; u++) { + new_space->select.sel_info.pnt_lst->low_bounds[u] = + base_space->select.sel_info.pnt_lst->low_bounds[u + rank_diff]; + new_space->select.sel_info.pnt_lst->high_bounds[u] = + base_space->select.sel_info.pnt_lst->high_bounds[u + rank_diff]; } /* end for */ - } /* end if */ + } /* end if */ else { HDassert(new_space->extent.rank > base_space->extent.rank); @@ -2325,22 +2294,23 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of /* Iterate through base space's point nodes, copying the point information */ base_node = base_space->select.sel_info.pnt_lst->head; prev_node = NULL; - while(base_node) { + while (base_node) { /* Create new point */ - if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank))) + if (NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") new_node->next = NULL; /* Copy over the point's coordinates */ HDmemset(new_node->pnt, 0, sizeof(hsize_t) * rank_diff); - H5MM_memcpy(&new_node->pnt[rank_diff], base_node->pnt, (new_space->extent.rank * sizeof(hsize_t))); + H5MM_memcpy(&new_node->pnt[rank_diff], base_node->pnt, + (new_space->extent.rank * sizeof(hsize_t))); /* Keep the order the same when copying */ - if(NULL == prev_node) + if (NULL == prev_node) prev_node = new_space->select.sel_info.pnt_lst->head = new_node; else { prev_node->next = new_node; - prev_node = new_node; + prev_node = new_node; } /* end else */ /* Advance to next node */ @@ -2348,15 +2318,17 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of } /* end while */ /* Update the bounding box */ - for(u = 0; u < rank_diff; u++) { - new_space->select.sel_info.pnt_lst->low_bounds[u] = 0; + for (u = 0; u < rank_diff; u++) { + new_space->select.sel_info.pnt_lst->low_bounds[u] = 0; new_space->select.sel_info.pnt_lst->high_bounds[u] = 0; } /* end for */ - for(; u < new_space->extent.rank; u++) { - new_space->select.sel_info.pnt_lst->low_bounds[u] = base_space->select.sel_info.pnt_lst->low_bounds[u - rank_diff]; - new_space->select.sel_info.pnt_lst->high_bounds[u] = base_space->select.sel_info.pnt_lst->high_bounds[u - rank_diff]; + for (; u < new_space->extent.rank; u++) { + new_space->select.sel_info.pnt_lst->low_bounds[u] = + base_space->select.sel_info.pnt_lst->low_bounds[u - rank_diff]; + new_space->select.sel_info.pnt_lst->high_bounds[u] = + base_space->select.sel_info.pnt_lst->high_bounds[u - rank_diff]; } /* end for */ - } /* end else */ + } /* end else */ /* Number of elements selected will be the same */ new_space->select.num_elem = base_space->select.num_elem; @@ -2368,7 +2340,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_elements @@ -2400,32 +2371,30 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem, - const hsize_t *coord) +H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iSsz*h", spaceid, op, num_elem, coord); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_SCALAR == H5S_GET_EXTENT_TYPE(space)) + if (H5S_SCALAR == H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "point doesn't support H5S_SCALAR space") - if(H5S_NULL == H5S_GET_EXTENT_TYPE(space)) + if (H5S_NULL == H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "point doesn't support H5S_NULL space") - if(coord == NULL || num_elem == 0) + if (coord == NULL || num_elem == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified") - if(!(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND)) + if (!(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "unsupported operation attempted") /* Call the real element selection routine */ - if((ret_value = H5S_select_elements(space, op, num_elem, coord)) < 0) + if ((ret_value = H5S_select_elements(space, op, num_elem, coord)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't select elements") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_elements() */ - diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 5100f1c..3389e1f 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -21,20 +21,20 @@ #include "H5Spublic.h" /* Public headers needed by this file */ -#include "H5Dpublic.h" /* Datasets */ +#include "H5Dpublic.h" /* Datasets */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ /* Forward references of package typedefs */ -typedef struct H5S_extent_t H5S_extent_t; -typedef struct H5S_pnt_node_t H5S_pnt_node_t; -typedef struct H5S_pnt_list_t H5S_pnt_list_t; -typedef struct H5S_hyper_span_t H5S_hyper_span_t; +typedef struct H5S_extent_t H5S_extent_t; +typedef struct H5S_pnt_node_t H5S_pnt_node_t; +typedef struct H5S_pnt_list_t H5S_pnt_list_t; +typedef struct H5S_hyper_span_t H5S_hyper_span_t; typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t; /* Information about one dimension in a hyperslab selection */ @@ -47,39 +47,39 @@ typedef struct H5S_hyper_dim_t { /* Point selection iteration container */ typedef struct { - H5S_pnt_list_t *pnt_lst; /* Pointer to point list */ - H5S_pnt_node_t *curr; /* Pointer to next node to output */ + H5S_pnt_list_t *pnt_lst; /* Pointer to point list */ + H5S_pnt_node_t *curr; /* Pointer to next node to output */ } H5S_point_iter_t; /* Hyperslab selection iteration container */ typedef struct { /* Common fields for all hyperslab selections */ - hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */ - hsize_t slab[H5S_MAX_RANK]; /* Cumulative size of each dimension in bytes */ - unsigned iter_rank; /* Rank of iterator information */ - /* (This should always be the same as the dataspace - * rank, except for regular hyperslab selections in - * which there are contiguous regions in the lower - * dimensions that have been "flattened") - */ - hbool_t diminfo_valid; /* Whether the dimension information is valid */ + hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */ + hsize_t slab[H5S_MAX_RANK]; /* Cumulative size of each dimension in bytes */ + unsigned iter_rank; /* Rank of iterator information */ + /* (This should always be the same as the dataspace + * rank, except for regular hyperslab selections in + * which there are contiguous regions in the lower + * dimensions that have been "flattened") + */ + hbool_t diminfo_valid; /* Whether the dimension information is valid */ /* "Flattened" regular hyperslab selection fields */ H5S_hyper_dim_t diminfo[H5S_MAX_RANK]; /* "Flattened" regular selection information */ - hsize_t size[H5S_MAX_RANK]; /* "Flattened" dataspace extent information */ - hssize_t sel_off[H5S_MAX_RANK]; /* "Flattened" selection offset information */ - hbool_t flattened[H5S_MAX_RANK]; /* Whether this dimension has been flattened */ + hsize_t size[H5S_MAX_RANK]; /* "Flattened" dataspace extent information */ + hssize_t sel_off[H5S_MAX_RANK]; /* "Flattened" selection offset information */ + hbool_t flattened[H5S_MAX_RANK]; /* Whether this dimension has been flattened */ /* Irregular hyperslab selection fields */ hsize_t loc_off[H5S_MAX_RANK]; /* Byte offset in buffer, for each dimension's current offset */ H5S_hyper_span_info_t *spans; /* Pointer to copy of the span tree */ - H5S_hyper_span_t *span[H5S_MAX_RANK];/* Array of pointers to span nodes */ + H5S_hyper_span_t * span[H5S_MAX_RANK]; /* Array of pointers to span nodes */ } H5S_hyper_iter_t; /* "All" selection iteration container */ typedef struct { - hsize_t elmt_offset; /* Next element to output */ - hsize_t byte_offset; /* Next byte to output */ + hsize_t elmt_offset; /* Next element to output */ + hsize_t byte_offset; /* Next byte to output */ } H5S_all_iter_t; /* Forward declaration of selection iteration class */ @@ -91,105 +91,107 @@ typedef struct H5S_sel_iter_t { const struct H5S_sel_iter_class_t *type; /* Selection iteration class info */ /* Information common to all iterators */ - unsigned rank; /* Rank of dataspace the selection iterator is operating on */ - hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataspace the selection is operating on */ + unsigned rank; /* Rank of dataspace the selection iterator is operating on */ + hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataspace the selection is operating on */ hssize_t sel_off[H5S_MAX_RANK]; /* Selection offset in dataspace */ - hsize_t elmt_left; /* Number of elements left to iterate over */ - size_t elmt_size; /* Size of elements to iterate over */ - unsigned flags; /* Flags controlling iterator behavior */ + hsize_t elmt_left; /* Number of elements left to iterate over */ + size_t elmt_size; /* Size of elements to iterate over */ + unsigned flags; /* Flags controlling iterator behavior */ /* Information specific to each type of iterator */ union { - H5S_point_iter_t pnt; /* Point selection iteration information */ - H5S_hyper_iter_t hyp; /* New Hyperslab selection iteration information */ - H5S_all_iter_t all; /* "All" selection iteration information */ + H5S_point_iter_t pnt; /* Point selection iteration information */ + H5S_hyper_iter_t hyp; /* New Hyperslab selection iteration information */ + H5S_all_iter_t all; /* "All" selection iteration information */ } u; } H5S_sel_iter_t; /* Selection iteration operator for internal library callbacks */ -typedef herr_t (*H5S_sel_iter_lib_op_t)(void *elem, const H5T_t *type, - unsigned ndim, const hsize_t *point, void *op_data); +typedef herr_t (*H5S_sel_iter_lib_op_t)(void *elem, const H5T_t *type, unsigned ndim, const hsize_t *point, + void *op_data); /* Describe kind of callback to make */ typedef enum H5S_sel_iter_op_type_t { - H5S_SEL_ITER_OP_APP, /* Application callback */ - H5S_SEL_ITER_OP_LIB /* Library internal callback */ + H5S_SEL_ITER_OP_APP, /* Application callback */ + H5S_SEL_ITER_OP_LIB /* Library internal callback */ } H5S_sel_iter_op_type_t; typedef struct H5S_sel_iter_app_op_t { - H5D_operator_t op; /* Callback */ - hid_t type_id; /* Type ID to be passed to callback */ + H5D_operator_t op; /* Callback */ + hid_t type_id; /* Type ID to be passed to callback */ } H5S_sel_iter_app_op_t; typedef struct H5S_sel_iter_op_t { H5S_sel_iter_op_type_t op_type; union { - H5S_sel_iter_app_op_t app_op; /* Application callback */ - H5S_sel_iter_lib_op_t lib_op; /* Library internal callback */ + H5S_sel_iter_app_op_t app_op; /* Application callback */ + H5S_sel_iter_lib_op_t lib_op; /* Library internal callback */ } u; } H5S_sel_iter_op_t; /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5S_MODULE -#define H5S_GET_EXTENT_TYPE(S) ((S)->extent.type) -#define H5S_GET_EXTENT_NDIMS(S) ((S)->extent.rank) -#define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem) -#define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem) -#define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type) -#define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S)) -#define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S)) -#define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.type->serialize)(S,BUF)) -#define H5S_SELECT_BOUNDS(S,START,END) ((*(S)->select.type->bounds)(S,START,END)) -#define H5S_SELECT_OFFSET(S, OFFSET) ((*(S)->select.type->offset)(S, OFFSET)) -#define H5S_SELECT_IS_CONTIGUOUS(S) ((*(S)->select.type->is_contiguous)(S)) -#define H5S_SELECT_IS_SINGLE(S) ((*(S)->select.type->is_single)(S)) -#define H5S_SELECT_IS_REGULAR(S) ((*(S)->select.type->is_regular)(S)) -#define H5S_SELECT_ADJUST_U(S,O) ((*(S)->select.type->adjust_u)(S, O)) -#define H5S_SELECT_ADJUST_S(S,O) ((*(S)->select.type->adjust_s)(S, O)) -#define H5S_SELECT_PROJECT_SCALAR(S,O) ((*(S)->select.type->project_scalar)(S, O)) -#define H5S_SELECT_PROJECT_SIMPLE(S,NS, O) ((*(S)->select.type->project_simple)(S, NS, O)) -#define H5S_SELECT_ITER_COORDS(ITER,COORDS) ((*(ITER)->type->iter_coords)(ITER,COORDS)) -#define H5S_SELECT_ITER_BLOCK(ITER,START,END) ((*(ITER)->type->iter_block)(ITER,START,END)) -#define H5S_SELECT_ITER_NELMTS(ITER) ((*(ITER)->type->iter_nelmts)(ITER)) +#define H5S_GET_EXTENT_TYPE(S) ((S)->extent.type) +#define H5S_GET_EXTENT_NDIMS(S) ((S)->extent.rank) +#define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem) +#define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem) +#define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type) +#define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S)) +#define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S)) +#define H5S_SELECT_SERIALIZE(S, BUF) ((*(S)->select.type->serialize)(S, BUF)) +#define H5S_SELECT_BOUNDS(S, START, END) ((*(S)->select.type->bounds)(S, START, END)) +#define H5S_SELECT_OFFSET(S, OFFSET) ((*(S)->select.type->offset)(S, OFFSET)) +#define H5S_SELECT_IS_CONTIGUOUS(S) ((*(S)->select.type->is_contiguous)(S)) +#define H5S_SELECT_IS_SINGLE(S) ((*(S)->select.type->is_single)(S)) +#define H5S_SELECT_IS_REGULAR(S) ((*(S)->select.type->is_regular)(S)) +#define H5S_SELECT_ADJUST_U(S, O) ((*(S)->select.type->adjust_u)(S, O)) +#define H5S_SELECT_ADJUST_S(S, O) ((*(S)->select.type->adjust_s)(S, O)) +#define H5S_SELECT_PROJECT_SCALAR(S, O) ((*(S)->select.type->project_scalar)(S, O)) +#define H5S_SELECT_PROJECT_SIMPLE(S, NS, O) ((*(S)->select.type->project_simple)(S, NS, O)) +#define H5S_SELECT_ITER_COORDS(ITER, COORDS) ((*(ITER)->type->iter_coords)(ITER, COORDS)) +#define H5S_SELECT_ITER_BLOCK(ITER, START, END) ((*(ITER)->type->iter_block)(ITER, START, END)) +#define H5S_SELECT_ITER_NELMTS(ITER) ((*(ITER)->type->iter_nelmts)(ITER)) #define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_has_next_block)(ITER)) -#define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->type->iter_next)(ITER,NELEM)) +#define H5S_SELECT_ITER_NEXT(ITER, NELEM) ((*(ITER)->type->iter_next)(ITER, NELEM)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_next_block)(ITER)) -#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(ITER)->type->iter_get_seq_list)(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) -#define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER)) +#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER, MAXSEQ, MAXBYTES, NSEQ, NBYTES, OFF, LEN) \ + ((*(ITER)->type->iter_get_seq_list)(ITER, MAXSEQ, MAXBYTES, NSEQ, NBYTES, OFF, LEN)) +#define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER)) #else /* H5S_MODULE */ -#define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) -#define H5S_GET_EXTENT_NDIMS(S) (H5S_get_simple_extent_ndims(S)) -#define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) -#define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S)) -#define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S)) -#define H5S_SELECT_VALID(S) (H5S_select_valid(S)) -#define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S)) -#define H5S_SELECT_SERIALIZE(S,BUF) (H5S_select_serialize(S,BUF)) -#define H5S_SELECT_BOUNDS(S,START,END) (H5S_get_select_bounds(S,START,END)) -#define H5S_SELECT_OFFSET(S, OFFSET) (H5S_get_select_offset(S, OFFSET)) -#define H5S_SELECT_IS_CONTIGUOUS(S) (H5S_select_is_contiguous(S)) -#define H5S_SELECT_IS_SINGLE(S) (H5S_select_is_single(S)) -#define H5S_SELECT_IS_REGULAR(S) (H5S_select_is_regular(S)) -#define H5S_SELECT_ADJUST_U(S,O) (H5S_select_adjust_u(S, O)) -#define H5S_SELECT_ADJUST_S(S,O) (H5S_select_adjust_s(S, O)) -#define H5S_SELECT_PROJECT_SCALAR(S,O) (H5S_select_project_scalar(S, O)) -#define H5S_SELECT_PROJECT_SIMPLE(S,NS,O) (H5S_select_project_simple(S, NS, O)) -#define H5S_SELECT_ITER_COORDS(ITER,COORDS) (H5S_select_iter_coords(ITER,COORDS)) -#define H5S_SELECT_ITER_BLOCK(ITER,START,END) (H5S_select_iter_block(ITER,START,END)) -#define H5S_SELECT_ITER_NELMTS(ITER) (H5S_select_iter_nelmts(ITER)) +#define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) +#define H5S_GET_EXTENT_NDIMS(S) (H5S_get_simple_extent_ndims(S)) +#define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) +#define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S)) +#define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S)) +#define H5S_SELECT_VALID(S) (H5S_select_valid(S)) +#define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S)) +#define H5S_SELECT_SERIALIZE(S, BUF) (H5S_select_serialize(S, BUF)) +#define H5S_SELECT_BOUNDS(S, START, END) (H5S_get_select_bounds(S, START, END)) +#define H5S_SELECT_OFFSET(S, OFFSET) (H5S_get_select_offset(S, OFFSET)) +#define H5S_SELECT_IS_CONTIGUOUS(S) (H5S_select_is_contiguous(S)) +#define H5S_SELECT_IS_SINGLE(S) (H5S_select_is_single(S)) +#define H5S_SELECT_IS_REGULAR(S) (H5S_select_is_regular(S)) +#define H5S_SELECT_ADJUST_U(S, O) (H5S_select_adjust_u(S, O)) +#define H5S_SELECT_ADJUST_S(S, O) (H5S_select_adjust_s(S, O)) +#define H5S_SELECT_PROJECT_SCALAR(S, O) (H5S_select_project_scalar(S, O)) +#define H5S_SELECT_PROJECT_SIMPLE(S, NS, O) (H5S_select_project_simple(S, NS, O)) +#define H5S_SELECT_ITER_COORDS(ITER, COORDS) (H5S_select_iter_coords(ITER, COORDS)) +#define H5S_SELECT_ITER_BLOCK(ITER, START, END) (H5S_select_iter_block(ITER, START, END)) +#define H5S_SELECT_ITER_NELMTS(ITER) (H5S_select_iter_nelmts(ITER)) #define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) (H5S_select_iter_has_next_block(ITER)) -#define H5S_SELECT_ITER_NEXT(ITER,NELEM)(H5S_select_iter_next(ITER,NELEM)) +#define H5S_SELECT_ITER_NEXT(ITER, NELEM) (H5S_select_iter_next(ITER, NELEM)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) (H5S_select_iter_next_block(ITER)) -#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_iter_get_seq_list(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) -#define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER)) +#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER, MAXSEQ, MAXBYTES, NSEQ, NBYTES, OFF, LEN) \ + (H5S_select_iter_get_seq_list(ITER, MAXSEQ, MAXBYTES, NSEQ, NBYTES, OFF, LEN)) +#define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER)) #endif /* H5S_MODULE */ /* Handle these callbacks in a special way, since they have prologs that need to be executed */ -#define H5S_SELECT_COPY(DST,SRC,SHARE) (H5S_select_copy(DST,SRC,SHARE)) -#define H5S_SELECT_SHAPE_SAME(S1,S2) (H5S_select_shape_same(S1,S2)) -#define H5S_SELECT_INTERSECT_BLOCK(S,START,END) (H5S_select_intersect_block(S,START,END)) -#define H5S_SELECT_RELEASE(S) (H5S_select_release(S)) -#define H5S_SELECT_DESERIALIZE(S,BUF) (H5S_select_deserialize(S,BUF)) +#define H5S_SELECT_COPY(DST, SRC, SHARE) (H5S_select_copy(DST, SRC, SHARE)) +#define H5S_SELECT_SHAPE_SAME(S1, S2) (H5S_select_shape_same(S1, S2)) +#define H5S_SELECT_INTERSECT_BLOCK(S, START, END) (H5S_select_intersect_block(S, START, END)) +#define H5S_SELECT_RELEASE(S) (H5S_select_release(S)) +#define H5S_SELECT_DESERIALIZE(S, BUF) (H5S_select_deserialize(S, BUF)) /* Forward declaration of structs used below */ struct H5O_t; @@ -199,74 +201,67 @@ struct H5O_loc_t; typedef struct H5S_t H5S_t; /* Operations on dataspaces */ -H5_DLL H5S_t *H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max); -H5_DLL herr_t H5S_close(H5S_t *ds); +H5_DLL H5S_t * H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max); +H5_DLL herr_t H5S_close(H5S_t *ds); H5_DLL H5S_class_t H5S_get_simple_extent_type(const H5S_t *ds); -H5_DLL hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds); -H5_DLL hsize_t H5S_get_npoints_max(const H5S_t *ds); -H5_DLL hbool_t H5S_has_extent(const H5S_t *ds); -H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds); -H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[]/*out*/, - hsize_t max_dims[]/*out*/); +H5_DLL hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds); +H5_DLL hsize_t H5S_get_npoints_max(const H5S_t *ds); +H5_DLL hbool_t H5S_has_extent(const H5S_t *ds); +H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds); +H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[] /*out*/, hsize_t max_dims[] /*out*/); H5_DLL herr_t H5S_write(H5F_t *f, struct H5O_t *oh, unsigned update_flags, H5S_t *ds); H5_DLL herr_t H5S_append(H5F_t *f, struct H5O_t *oh, H5S_t *ds); H5_DLL H5S_t *H5S_read(const struct H5O_loc_t *loc); H5_DLL htri_t H5S_set_extent(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); -H5_DLL herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, - const hsize_t *dims, const hsize_t *max); +H5_DLL herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max); H5_DLL H5S_t *H5S_create(H5S_class_t type); -H5_DLL herr_t H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space/*out*/); -H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], - const hsize_t maxdims[/*rank*/]); +H5_DLL herr_t H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space /*out*/); +H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]); H5_DLL herr_t H5S_set_version(H5F_t *f, H5S_t *ds); H5_DLL herr_t H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc); H5_DLL H5S_t *H5S_decode(const unsigned char **p); -H5_DLL herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, - int fwidth); +H5_DLL herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Operations on dataspace extents */ H5_DLL hsize_t H5S_extent_nelem(const H5S_extent_t *ext); -H5_DLL int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]); -H5_DLL htri_t H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2); -H5_DLL herr_t H5S_extent_copy(H5S_t *dst, const H5S_t *src); +H5_DLL int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]); +H5_DLL htri_t H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2); +H5_DLL herr_t H5S_extent_copy(H5S_t *dst, const H5S_t *src); /* Operations on selections */ -H5_DLL herr_t H5S_select_deserialize(H5S_t **space, const uint8_t **p); +H5_DLL herr_t H5S_select_deserialize(H5S_t **space, const uint8_t **p); H5_DLL H5S_sel_type H5S_get_select_type(const H5S_t *space); -H5_DLL herr_t H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, - const H5S_sel_iter_op_t *op, void *op_data); -H5_DLL herr_t H5S_select_fill(const void *fill, size_t fill_size, - const H5S_t *space, void *buf); -H5_DLL htri_t H5S_select_valid(const H5S_t *space); -H5_DLL hsize_t H5S_get_select_npoints(const H5S_t *space); -H5_DLL herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); -H5_DLL herr_t H5S_get_select_offset(const H5S_t *space, hsize_t *offset); -H5_DLL int H5S_get_select_unlim_dim(const H5S_t *space); -H5_DLL herr_t H5S_get_select_num_elem_non_unlim(const H5S_t *space, - hsize_t *num_elem_non_unlim); -H5_DLL herr_t H5S_select_offset(H5S_t *space, const hssize_t *offset); -H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -H5_DLL htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2); -H5_DLL htri_t H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, - const hsize_t *end); -H5_DLL herr_t H5S_select_construct_projection(const H5S_t *base_space, - H5S_t **new_space_ptr, unsigned new_space_rank, const void *buf, - void const **adj_buf_ptr, hsize_t element_size); -H5_DLL herr_t H5S_select_release(H5S_t *ds); -H5_DLL hssize_t H5S_select_serial_size(const H5S_t *space); -H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p); -H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space); -H5_DLL htri_t H5S_select_is_single(const H5S_t *space); -H5_DLL htri_t H5S_select_is_regular(const H5S_t *space); -H5_DLL herr_t H5S_select_adjust_u(H5S_t *space, const hsize_t *offset); -H5_DLL herr_t H5S_select_adjust_s(H5S_t *space, const hssize_t *offset); -H5_DLL herr_t H5S_select_project_scalar(const H5S_t *space, hsize_t *offset); -H5_DLL herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -H5_DLL herr_t H5S_select_project_intersection(const H5S_t *src_space, - const H5S_t *dst_space, const H5S_t *src_intersect_space, - H5S_t **new_space_ptr, hbool_t share_space); -H5_DLL herr_t H5S_select_subtract(H5S_t *space, H5S_t *subtract_space); +H5_DLL herr_t H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, + const H5S_sel_iter_op_t *op, void *op_data); +H5_DLL herr_t H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *buf); +H5_DLL htri_t H5S_select_valid(const H5S_t *space); +H5_DLL hsize_t H5S_get_select_npoints(const H5S_t *space); +H5_DLL herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +H5_DLL herr_t H5S_get_select_offset(const H5S_t *space, hsize_t *offset); +H5_DLL int H5S_get_select_unlim_dim(const H5S_t *space); +H5_DLL herr_t H5S_get_select_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim); +H5_DLL herr_t H5S_select_offset(H5S_t *space, const hssize_t *offset); +H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +H5_DLL htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2); +H5_DLL htri_t H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +H5_DLL herr_t H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, + unsigned new_space_rank, const void *buf, + void const **adj_buf_ptr, hsize_t element_size); +H5_DLL herr_t H5S_select_release(H5S_t *ds); +H5_DLL hssize_t H5S_select_serial_size(const H5S_t *space); +H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p); +H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space); +H5_DLL htri_t H5S_select_is_single(const H5S_t *space); +H5_DLL htri_t H5S_select_is_regular(const H5S_t *space); +H5_DLL herr_t H5S_select_adjust_u(H5S_t *space, const hsize_t *offset); +H5_DLL herr_t H5S_select_adjust_s(H5S_t *space, const hssize_t *offset); +H5_DLL herr_t H5S_select_project_scalar(const H5S_t *space, hsize_t *offset); +H5_DLL herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); +H5_DLL herr_t H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, + const H5S_t *src_intersect_space, H5S_t **new_space_ptr, + hbool_t share_space); +H5_DLL herr_t H5S_select_subtract(H5S_t *space, H5S_t *subtract_space); /* Operations on all selections */ H5_DLL herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev); @@ -275,49 +270,40 @@ H5_DLL herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev); H5_DLL herr_t H5S_select_none(H5S_t *space); /* Operations on point selections */ -H5_DLL herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op, - size_t num_elem, const hsize_t *coord); +H5_DLL herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord); /* Operations on hyperslab selections */ -H5_DLL herr_t H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], - const hsize_t *stride, const hsize_t count[], const hsize_t *block); -H5_DLL herr_t H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, - const hsize_t start[], const hsize_t *stride, const hsize_t count[], - const hsize_t *block, H5S_t **new_space); -H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, - const hsize_t *coords); -H5_DLL htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset); -H5_DLL herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset); -H5_DLL herr_t H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size); -H5_DLL hsize_t H5S_hyper_get_clip_extent(const H5S_t *clip_space, - const H5S_t *match_space, hbool_t incl_trail); -H5_DLL hsize_t H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, - const H5S_t *match_space, hsize_t match_clip_size, hbool_t incl_trail); -H5_DLL H5S_t *H5S_hyper_get_unlim_block(const H5S_t *space, - hsize_t block_index); -H5_DLL hsize_t H5S_hyper_get_first_inc_block(const H5S_t *space, - hsize_t clip_size, hbool_t *partial); +H5_DLL herr_t H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], + const hsize_t *stride, const hsize_t count[], const hsize_t *block); +H5_DLL herr_t H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], + const hsize_t *stride, const hsize_t count[], const hsize_t *block, + H5S_t **new_space); +H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords); +H5_DLL htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset); +H5_DLL herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset); +H5_DLL herr_t H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size); +H5_DLL hsize_t H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, + hbool_t incl_trail); +H5_DLL hsize_t H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, const H5S_t *match_space, + hsize_t match_clip_size, hbool_t incl_trail); +H5_DLL H5S_t * H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index); +H5_DLL hsize_t H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *partial); /* Operations on selection iterators */ -H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, const H5S_t *space, - size_t elmt_size, unsigned flags); -H5_DLL herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords); +H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, const H5S_t *space, size_t elmt_size, + unsigned flags); +H5_DLL herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords); H5_DLL hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter); -H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -H5_DLL herr_t H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); +H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +H5_DLL herr_t H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter); H5_DLL herr_t H5S_sel_iter_close(H5S_sel_iter_t *sel_iter); #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, - /* out: */ MPI_Datatype *new_type, - int *count, - hbool_t *is_derived_type, - hbool_t do_permute, - hsize_t **permute_map, - hbool_t * is_permuted); + /* out: */ MPI_Datatype *new_type, int *count, hbool_t *is_derived_type, + hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted); #endif /* H5_HAVE_PARALLEL */ #endif /* _H5Sprivate_H */ - diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 1ca79ea..ad0bbd5 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -22,96 +22,98 @@ #include "H5Ipublic.h" /* Define atomic datatypes */ -#define H5S_ALL (hid_t)0 -#define H5S_UNLIMITED HSIZE_UNDEF +#define H5S_ALL (hid_t)0 +#define H5S_UNLIMITED HSIZE_UNDEF /* Define user-level maximum number of dimensions */ -#define H5S_MAX_RANK 32 +#define H5S_MAX_RANK 32 /* Flags for selection iterators */ -#define H5S_SEL_ITER_GET_SEQ_LIST_SORTED 0x0001 /* Retrieve elements from iterator - * in increasing offset order, for - * each call to retrieve sequences. - * Currently, this only applies to - * point selections, as hyperslab - * selections are always returned - * in increasing offset order. - * - * Note that the order is only - * increasing for each call to - * get_seq_list, the next set of - * sequences could start with an - * earlier offset than the previous - * one. - */ -#define H5S_SEL_ITER_SHARE_WITH_DATASPACE 0x0002 /* Don't copy the dataspace - * selection when creating the - * selection iterator. - * - * This can improve performance - * of creating the iterator, but - * the dataspace _MUST_NOT_ be - * modified or closed until the - * selection iterator is closed - * or the iterator's behavior - * will be undefined. - */ +#define H5S_SEL_ITER_GET_SEQ_LIST_SORTED \ + 0x0001 /* Retrieve elements from iterator \ + * in increasing offset order, for \ + * each call to retrieve sequences. \ + * Currently, this only applies to \ + * point selections, as hyperslab \ + * selections are always returned \ + * in increasing offset order. \ + * \ + * Note that the order is only \ + * increasing for each call to \ + * get_seq_list, the next set of \ + * sequences could start with an \ + * earlier offset than the previous \ + * one. \ + */ +#define H5S_SEL_ITER_SHARE_WITH_DATASPACE \ + 0x0002 /* Don't copy the dataspace \ + * selection when creating the \ + * selection iterator. \ + * \ + * This can improve performance \ + * of creating the iterator, but \ + * the dataspace _MUST_NOT_ be \ + * modified or closed until the \ + * selection iterator is closed \ + * or the iterator's behavior \ + * will be undefined. \ + */ /* Different types of dataspaces */ typedef enum H5S_class_t { - H5S_NO_CLASS = -1, /*error */ - H5S_SCALAR = 0, /*scalar variable */ - H5S_SIMPLE = 1, /*simple dataspace */ - H5S_NULL = 2 /*null dataspace */ + H5S_NO_CLASS = -1, /*error */ + H5S_SCALAR = 0, /*scalar variable */ + H5S_SIMPLE = 1, /*simple dataspace */ + H5S_NULL = 2 /*null dataspace */ } H5S_class_t; /* Different ways of combining selections */ typedef enum H5S_seloper_t { - H5S_SELECT_NOOP = -1, /* error */ - H5S_SELECT_SET = 0, /* Select "set" operation */ - H5S_SELECT_OR, /* Binary "or" operation for hyperslabs - * (add new selection to existing selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * A or B: CCCCCCCCCCCCCCCC - */ - H5S_SELECT_AND, /* Binary "and" operation for hyperslabs - * (only leave overlapped regions in selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * A and B: CCCC - */ - H5S_SELECT_XOR, /* Binary "xor" operation for hyperslabs - * (only leave non-overlapped regions in selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * A xor B: CCCCCC CCCCCC - */ - H5S_SELECT_NOTB, /* Binary "not" operation for hyperslabs - * (only leave non-overlapped regions in original selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * A not B: CCCCCC - */ - H5S_SELECT_NOTA, /* Binary "not" operation for hyperslabs - * (only leave non-overlapped regions in new selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * B not A: CCCCCC - */ - H5S_SELECT_APPEND, /* Append elements to end of point selection */ - H5S_SELECT_PREPEND, /* Prepend elements to beginning of point selection */ - H5S_SELECT_INVALID /* Invalid upper bound on selection operations */ + H5S_SELECT_NOOP = -1, /* error */ + H5S_SELECT_SET = 0, /* Select "set" operation */ + H5S_SELECT_OR, /* Binary "or" operation for hyperslabs + * (add new selection to existing selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * A or B: CCCCCCCCCCCCCCCC + */ + H5S_SELECT_AND, /* Binary "and" operation for hyperslabs + * (only leave overlapped regions in selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * A and B: CCCC + */ + H5S_SELECT_XOR, /* Binary "xor" operation for hyperslabs + * (only leave non-overlapped regions in selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * A xor B: CCCCCC CCCCCC + */ + H5S_SELECT_NOTB, /* Binary "not" operation for hyperslabs + * (only leave non-overlapped regions in original selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * A not B: CCCCCC + */ + H5S_SELECT_NOTA, /* Binary "not" operation for hyperslabs + * (only leave non-overlapped regions in new selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * B not A: CCCCCC + */ + H5S_SELECT_APPEND, /* Append elements to end of point selection */ + H5S_SELECT_PREPEND, /* Prepend elements to beginning of point selection */ + H5S_SELECT_INVALID /* Invalid upper bound on selection operations */ } H5S_seloper_t; /* Enumerated type for the type of selection */ typedef enum { - H5S_SEL_ERROR = -1, /* Error */ - H5S_SEL_NONE = 0, /* Nothing selected */ - H5S_SEL_POINTS = 1, /* Points / elements selected */ - H5S_SEL_HYPERSLABS = 2, /* Hyperslab selected */ - H5S_SEL_ALL = 3, /* Entire extent selected */ - H5S_SEL_N /*THIS MUST BE LAST */ + H5S_SEL_ERROR = -1, /* Error */ + H5S_SEL_NONE = 0, /* Nothing selected */ + H5S_SEL_POINTS = 1, /* Points / elements selected */ + H5S_SEL_HYPERSLABS = 2, /* Hyperslab selected */ + H5S_SEL_ALL = 3, /* Entire extent selected */ + H5S_SEL_N /*THIS MUST BE LAST */ } H5S_sel_type; #ifdef __cplusplus @@ -119,65 +121,57 @@ extern "C" { #endif /* Operations on dataspaces */ -H5_DLL hid_t H5Screate(H5S_class_t type); -H5_DLL hid_t H5Screate_simple(int rank, const hsize_t dims[], - const hsize_t maxdims[]); -H5_DLL herr_t H5Sset_extent_simple(hid_t space_id, int rank, - const hsize_t dims[], const hsize_t max[]); -H5_DLL hid_t H5Scopy(hid_t space_id); -H5_DLL herr_t H5Sclose(hid_t space_id); -H5_DLL herr_t H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl); -H5_DLL hid_t H5Sdecode(const void *buf); -H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id); -H5_DLL int H5Sget_simple_extent_ndims(hid_t space_id); -H5_DLL int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[], - hsize_t maxdims[]); -H5_DLL htri_t H5Sis_simple(hid_t space_id); +H5_DLL hid_t H5Screate(H5S_class_t type); +H5_DLL hid_t H5Screate_simple(int rank, const hsize_t dims[], const hsize_t maxdims[]); +H5_DLL herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[], const hsize_t max[]); +H5_DLL hid_t H5Scopy(hid_t space_id); +H5_DLL herr_t H5Sclose(hid_t space_id); +H5_DLL herr_t H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl); +H5_DLL hid_t H5Sdecode(const void *buf); +H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id); +H5_DLL int H5Sget_simple_extent_ndims(hid_t space_id); +H5_DLL int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[], hsize_t maxdims[]); +H5_DLL htri_t H5Sis_simple(hid_t space_id); H5_DLL H5S_class_t H5Sget_simple_extent_type(hid_t space_id); -H5_DLL herr_t H5Sset_extent_none(hid_t space_id); -H5_DLL herr_t H5Sextent_copy(hid_t dst_id,hid_t src_id); -H5_DLL htri_t H5Sextent_equal(hid_t sid1, hid_t sid2); +H5_DLL herr_t H5Sset_extent_none(hid_t space_id); +H5_DLL herr_t H5Sextent_copy(hid_t dst_id, hid_t src_id); +H5_DLL htri_t H5Sextent_equal(hid_t sid1, hid_t sid2); /* Operations on dataspace selections */ H5_DLL H5S_sel_type H5Sget_select_type(hid_t spaceid); -H5_DLL hssize_t H5Sget_select_npoints(hid_t spaceid); -H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); -H5_DLL htri_t H5Sselect_valid(hid_t spaceid); -H5_DLL herr_t H5Sselect_adjust(hid_t spaceid, const hssize_t *offset); -H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[], - hsize_t end[]); -H5_DLL htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id); -H5_DLL htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, - const hsize_t *end); -H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset); -H5_DLL herr_t H5Sselect_all(hid_t spaceid); -H5_DLL herr_t H5Sselect_none(hid_t spaceid); -H5_DLL herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op, - size_t num_elem, const hsize_t *coord); +H5_DLL hssize_t H5Sget_select_npoints(hid_t spaceid); +H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); +H5_DLL htri_t H5Sselect_valid(hid_t spaceid); +H5_DLL herr_t H5Sselect_adjust(hid_t spaceid, const hssize_t *offset); +H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]); +H5_DLL htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id); +H5_DLL htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *end); +H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset); +H5_DLL herr_t H5Sselect_all(hid_t spaceid); +H5_DLL herr_t H5Sselect_none(hid_t spaceid); +H5_DLL herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op, size_t num_elem, const hsize_t *coord); H5_DLL hssize_t H5Sget_select_elem_npoints(hid_t spaceid); -H5_DLL herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, - hsize_t numpoints, hsize_t buf[/*numpoints*/]); -H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, - const hsize_t start[], const hsize_t _stride[], const hsize_t count[], - const hsize_t _block[]); -H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, - const hsize_t start[], const hsize_t _stride[], const hsize_t count[], - const hsize_t _block[]); -H5_DLL herr_t H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id); -H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id); -H5_DLL htri_t H5Sis_regular_hyperslab(hid_t spaceid); -H5_DLL htri_t H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], - hsize_t stride[], hsize_t count[], hsize_t block[]); +H5_DLL herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, + hsize_t buf[/*numpoints*/]); +H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], + const hsize_t _stride[], const hsize_t count[], const hsize_t _block[]); +H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], + const hsize_t _stride[], const hsize_t count[], const hsize_t _block[]); +H5_DLL herr_t H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id); +H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id); +H5_DLL htri_t H5Sis_regular_hyperslab(hid_t spaceid); +H5_DLL htri_t H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[], hsize_t count[], + hsize_t block[]); H5_DLL hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid); -H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, - hsize_t numblocks, hsize_t buf[/*numblocks*/]); -H5_DLL hid_t H5Sselect_project_intersection(hid_t src_space_id, - hid_t dst_space_id, hid_t src_intersect_space_id); +H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, + hsize_t buf[/*numblocks*/]); +H5_DLL hid_t H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, + hid_t src_intersect_space_id); /* Operations on dataspace selection iterators */ -H5_DLL hid_t H5Ssel_iter_create(hid_t spaceid, size_t elmt_size, unsigned flags); -H5_DLL herr_t H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); +H5_DLL hid_t H5Ssel_iter_create(hid_t spaceid, size_t elmt_size, unsigned flags); +H5_DLL herr_t H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); H5_DLL herr_t H5Ssel_iter_close(hid_t sel_iter_id); /* Symbols defined for compatibility with previous versions of the HDF5 API. @@ -194,4 +188,3 @@ H5_DLL herr_t H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc); } #endif #endif /* _H5Spublic_H */ - diff --git a/src/H5Sselect.c b/src/H5Sselect.c index c9d7fc0..b93dfbd 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -21,36 +21,31 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspaces */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ /* All the valid public flags to H5Ssel_iter_create() */ -#define H5S_SEL_ITER_ALL_PUBLIC_FLAGS (H5S_SEL_ITER_GET_SEQ_LIST_SORTED | \ - H5S_SEL_ITER_SHARE_WITH_DATASPACE) - +#define H5S_SEL_ITER_ALL_PUBLIC_FLAGS (H5S_SEL_ITER_GET_SEQ_LIST_SORTED | H5S_SEL_ITER_SHARE_WITH_DATASPACE) /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -61,12 +56,10 @@ static htri_t H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter); static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter); #endif /* LATER */ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -80,13 +73,10 @@ H5FL_SEQ_EXTERN(size_t); /* Declare extern free list to manage sequences of hsize_t */ H5FL_SEQ_EXTERN(hsize_t); - /*******************/ /* Local Variables */ /*******************/ - - /*-------------------------------------------------------------------------- NAME H5S_select_offset @@ -125,7 +115,6 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S_select_offset() */ - /*-------------------------------------------------------------------------- NAME H5Soffset_simple @@ -138,37 +127,36 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function creates an offset for the selection within an extent, allowing + This function creates an offset for the selection within an extent, allowing the same shaped selection to be moved to different locations within a dataspace without requiring it to be re-defined. --------------------------------------------------------------------------*/ herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset) { - H5S_t *space; /* Dataspace to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space; /* Dataspace to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Hs", space_id, offset); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") - if(space->extent.rank == 0 || (H5S_GET_EXTENT_TYPE(space) == H5S_SCALAR - || H5S_GET_EXTENT_TYPE(space) == H5S_NULL)) + if (space->extent.rank == 0 || + (H5S_GET_EXTENT_TYPE(space) == H5S_SCALAR || H5S_GET_EXTENT_TYPE(space) == H5S_NULL)) HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace") - if(offset == NULL) + if (offset == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified") /* Set the selection offset */ - if(H5S_select_offset(space, offset) < 0) + if (H5S_select_offset(space, offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset") done: FUNC_LEAVE_API(ret_value) } /* end H5Soffset_simple() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_copy @@ -193,28 +181,27 @@ done: herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id) { - H5S_t *src; - H5S_t *dst; - herr_t ret_value = SUCCEED; + H5S_t *src; + H5S_t *dst; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", dst_id, src_id); /* Check args */ - if(NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) + if (NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) + if (NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Copy */ - if(H5S_select_copy(dst, src, FALSE) < 0) + if (H5S_select_copy(dst, src, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_copy() */ - /*-------------------------------------------------------------------------- NAME H5S_select_copy @@ -243,7 +230,7 @@ done: herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -252,21 +239,20 @@ H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) HDassert(src); /* Release the current selection */ - if(H5S_SELECT_RELEASE(dst) < 0) + if (H5S_SELECT_RELEASE(dst) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") /* Copy regular fields */ dst->select = src->select; /* Perform correct type of copy based on the type of selection */ - if((ret_value = (*src->select.type->copy)(dst, src, share_selection)) < 0) + if ((ret_value = (*src->select.type->copy)(dst, src, share_selection)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection specific information") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_copy() */ - /*------------------------------------------------------------------------- * Function: H5S_select_release * @@ -286,21 +272,20 @@ done: herr_t H5S_select_release(H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(ds); /* Call the selection type's release function */ - if((ds->select.type) && ((ret_value = (*ds->select.type->release)(ds)) < 0)) + if ((ds->select.type) && ((ret_value = (*ds->select.type->release)(ds)) < 0)) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_release() */ - /*------------------------------------------------------------------------- * Function: H5S_select_serial_size * @@ -321,7 +306,7 @@ done: hssize_t H5S_select_serial_size(const H5S_t *space) { - hssize_t ret_value = -1; /* Return value */ + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -333,7 +318,6 @@ H5S_select_serial_size(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S_select_serialize @@ -361,7 +345,7 @@ H5S_select_serial_size(const H5S_t *space) herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -374,7 +358,6 @@ H5S_select_serialize(const H5S_t *space, uint8_t **p) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_serialize() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_npoints @@ -395,14 +378,14 @@ H5S_select_serialize(const H5S_t *space, uint8_t **p) hssize_t H5Sget_select_npoints(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ - hssize_t ret_value; /* return value */ + H5S_t * space; /* Dataspace to modify selection of */ + hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") ret_value = (hssize_t)H5S_GET_SELECT_NPOINTS(space); @@ -411,7 +394,6 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Sget_select_npoints() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_npoints @@ -443,7 +425,6 @@ H5S_get_select_npoints(const H5S_t *space) FUNC_LEAVE_NOAPI(space->select.num_elem) } /* end H5S_get_select_npoints() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_valid @@ -467,14 +448,14 @@ H5S_get_select_npoints(const H5S_t *space) htri_t H5Sselect_valid(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ - htri_t ret_value; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + htri_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") ret_value = H5S_SELECT_VALID(space); @@ -483,7 +464,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_valid() */ - /*-------------------------------------------------------------------------- NAME H5S_select_valid @@ -510,7 +490,7 @@ done: htri_t H5S_select_valid(const H5S_t *space) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -521,7 +501,6 @@ H5S_select_valid(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_valid() */ - /*-------------------------------------------------------------------------- NAME H5S_select_deserialize @@ -551,8 +530,8 @@ H5S_select_valid(const H5S_t *space) herr_t H5S_select_deserialize(H5S_t **space, const uint8_t **p) { - uint32_t sel_type; /* Pointer to the selection type */ - herr_t ret_value = FAIL; /* Return value */ + uint32_t sel_type; /* Pointer to the selection type */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -564,20 +543,20 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) UINT32DECODE(*p, sel_type); /* Make routine for selection type */ - switch(sel_type) { - case H5S_SEL_POINTS: /* Sequence of points selected */ + switch (sel_type) { + case H5S_SEL_POINTS: /* Sequence of points selected */ ret_value = (*H5S_sel_point->deserialize)(space, p); break; - case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ + case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ ret_value = (*H5S_sel_hyper->deserialize)(space, p); break; - case H5S_SEL_ALL: /* Entire extent selected */ + case H5S_SEL_ALL: /* Entire extent selected */ ret_value = (*H5S_sel_all->deserialize)(space, p); break; - case H5S_SEL_NONE: /* Nothing selected */ + case H5S_SEL_NONE: /* Nothing selected */ ret_value = (*H5S_sel_none->deserialize)(space, p); break; @@ -585,14 +564,13 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) break; } - if(ret_value < 0) + if (ret_value < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_bounds @@ -626,16 +604,16 @@ done: herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*h*h", spaceid, start, end); /* Check args */ - if(start == NULL || end == NULL) + if (start == NULL || end == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer") - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") ret_value = H5S_SELECT_BOUNDS(space, start, end); @@ -644,7 +622,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_bounds @@ -675,7 +652,7 @@ done: herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -689,7 +666,6 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_offset @@ -716,7 +692,7 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) herr_t H5S_get_select_offset(const H5S_t *space, hsize_t *offset) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -729,7 +705,6 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_offset() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_unlim_dim @@ -755,7 +730,7 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset) int H5S_get_select_unlim_dim(const H5S_t *space) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -767,7 +742,6 @@ H5S_get_select_unlim_dim(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_num_elem_non_unlim @@ -789,8 +763,7 @@ H5S_get_select_unlim_dim(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_get_select_num_elem_non_unlim(const H5S_t *space, - hsize_t *num_elem_non_unlim) +H5S_get_select_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim) { herr_t ret_value = SUCCEED; /* return value */ @@ -801,18 +774,18 @@ H5S_get_select_num_elem_non_unlim(const H5S_t *space, HDassert(num_elem_non_unlim); /* Check for selection callback */ - if(!space->select.type->num_elem_non_unlim) + if (!space->select.type->num_elem_non_unlim) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "selection type has no num_elem_non_unlim callback") /* Make selection callback */ - if((*space->select.type->num_elem_non_unlim)(space, num_elem_non_unlim) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements in non-unlimited dimension") + if ((*space->select.type->num_elem_non_unlim)(space, num_elem_non_unlim) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, + "can't get number of elements in non-unlimited dimension") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S_select_is_contiguous @@ -837,7 +810,7 @@ done: htri_t H5S_select_is_contiguous(const H5S_t *space) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -849,7 +822,6 @@ H5S_select_is_contiguous(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S_select_is_single @@ -874,7 +846,7 @@ H5S_select_is_contiguous(const H5S_t *space) htri_t H5S_select_is_single(const H5S_t *space) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -886,7 +858,6 @@ H5S_select_is_single(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S_select_is_regular @@ -911,7 +882,7 @@ H5S_select_is_single(const H5S_t *space) htri_t H5S_select_is_regular(const H5S_t *space) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -923,7 +894,6 @@ H5S_select_is_regular(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S_select_adjust_u @@ -948,7 +918,7 @@ H5S_select_is_regular(const H5S_t *space) herr_t H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -962,7 +932,6 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S_select_adjust_s @@ -987,7 +956,7 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) herr_t H5S_select_adjust_s(H5S_t *space, const hssize_t *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1001,7 +970,6 @@ H5S_select_adjust_s(H5S_t *space, const hssize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_adjust_s() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_adjust @@ -1023,35 +991,34 @@ H5S_select_adjust_s(H5S_t *space, const hssize_t *offset) herr_t H5Sselect_adjust(hid_t space_id, const hssize_t *offset) { - H5S_t *space; - hsize_t low_bounds[H5S_MAX_RANK]; - hsize_t high_bounds[H5S_MAX_RANK]; + H5S_t * space; + hsize_t low_bounds[H5S_MAX_RANK]; + hsize_t high_bounds[H5S_MAX_RANK]; unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Hs", space_id, offset); - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == offset) + if (NULL == offset) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "NULL offset pointer") /* Check bounds */ - if(H5S_SELECT_BOUNDS(space, low_bounds, high_bounds) < 0) + if (H5S_SELECT_BOUNDS(space, low_bounds, high_bounds) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") - for(u = 0; u < space->extent.rank; u++) - if(offset[u] > (hssize_t)low_bounds[u]) + for (u = 0; u < space->extent.rank; u++) + if (offset[u] > (hssize_t)low_bounds[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjustment would move selection below zero offset") - if(H5S_select_adjust_s(space, offset) < 0) + if (H5S_select_adjust_s(space, offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_adjust() */ - /*-------------------------------------------------------------------------- NAME H5S_select_project_scalar @@ -1077,7 +1044,7 @@ done: herr_t H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1090,7 +1057,6 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_scalar() */ - /*-------------------------------------------------------------------------- NAME H5S_select_project_simple @@ -1117,7 +1083,7 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1131,7 +1097,6 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_init @@ -1151,10 +1116,9 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) in the dataspace's selection. --------------------------------------------------------------------------*/ herr_t -H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, - size_t elmt_size, unsigned flags) +H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_size, unsigned flags) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1168,7 +1132,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, sel_iter->rank = space->extent.rank; /* If dims > 0, copy the dataspace dimensions & selection offset */ - if(sel_iter->rank > 0) { + if (sel_iter->rank > 0) { H5MM_memcpy(sel_iter->dims, space->extent.size, sizeof(hsize_t) * space->extent.rank); H5MM_memcpy(sel_iter->sel_off, space->select.offset, sizeof(hsize_t) * space->extent.rank); } @@ -1189,7 +1153,6 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_init() */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_coords @@ -1215,7 +1178,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1230,7 +1193,7 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) } /* end H5S_select_iter_coords() */ #ifdef LATER - + /*-------------------------------------------------------------------------- NAME H5S_select_iter_block @@ -1257,7 +1220,7 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) static herr_t H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { - herr_t ret_value; /* return value */ + herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1273,7 +1236,6 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) } /* end H5S_select_iter_block() */ #endif /* LATER */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_nelmts @@ -1297,7 +1259,7 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1311,7 +1273,7 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) } /* end H5S_select_iter_nelmts() */ #ifdef LATER - + /*-------------------------------------------------------------------------- NAME H5S_select_iter_has_next_block @@ -1336,7 +1298,7 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) static htri_t H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) { - herr_t ret_value; /* return value */ + herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1350,7 +1312,6 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) } /* end H5S_select_iter_has_next_block() */ #endif /* LATER */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_next @@ -1376,25 +1337,25 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) herr_t H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(iter); - HDassert(nelem>0); + HDassert(nelem > 0); /* Call iter_next routine for selection type */ ret_value = (*iter->type->iter_next)(iter, nelem); /* Decrement the number of elements left in selection */ - iter->elmt_left-=nelem; + iter->elmt_left -= nelem; FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_next() */ #ifdef LATER - + /*-------------------------------------------------------------------------- NAME H5S_select_iter_next_block @@ -1421,7 +1382,7 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter) { - herr_t ret_value; /* return value */ + herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1435,7 +1396,6 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) } /* end H5S_select_iter_next_block() */ #endif /* LATER */ - /*------------------------------------------------------------------------- * Function: H5S_select_iter_get_seq_list * @@ -1454,10 +1414,10 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) *------------------------------------------------------------------------- */ herr_t -H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmts, - size_t *nseq, size_t *nelmts, hsize_t *off, size_t *len) +H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmts, size_t *nseq, + size_t *nelmts, hsize_t *off, size_t *len) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1465,14 +1425,13 @@ H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmt HDassert(iter); /* Call the selection type's get_seq_list function */ - if((ret_value = (*iter->type->iter_get_seq_list)(iter, maxseq, maxelmts, nseq, nelmts, off, len)) < 0) + if ((ret_value = (*iter->type->iter_get_seq_list)(iter, maxseq, maxelmts, nseq, nelmts, off, len)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_release @@ -1496,7 +1455,7 @@ done: herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1509,7 +1468,6 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S_select_iterate @@ -1539,20 +1497,20 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter) the selection is not modified. --------------------------------------------------------------------------*/ herr_t -H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, - const H5S_sel_iter_op_t *op, void *op_data) +H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, const H5S_sel_iter_op_t *op, + void *op_data) { - H5S_sel_iter_t *iter = NULL; /* Selection iteration info */ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ - hsize_t *off = NULL; /* Array to store sequence offsets */ - size_t *len = NULL; /* Array to store sequence lengths */ - hssize_t nelmts; /* Number of elements in selection */ - hsize_t space_size[H5S_MAX_RANK]; /* Dataspace size */ - size_t max_elem; /* Maximum number of elements allowed in sequences */ - size_t elmt_size; /* Datatype size */ - unsigned ndims; /* Number of dimensions in dataspace */ - herr_t user_ret = 0; /* User's return value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_sel_iter_t *iter = NULL; /* Selection iteration info */ + hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ + hsize_t * off = NULL; /* Array to store sequence offsets */ + size_t * len = NULL; /* Array to store sequence lengths */ + hssize_t nelmts; /* Number of elements in selection */ + hsize_t space_size[H5S_MAX_RANK]; /* Dataspace size */ + size_t max_elem; /* Maximum number of elements allowed in sequences */ + size_t elmt_size; /* Datatype size */ + unsigned ndims; /* Number of dimensions in dataspace */ + herr_t user_ret = 0; /* User's return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1563,29 +1521,29 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, HDassert(op); /* Get the datatype size */ - if(0 == (elmt_size = H5T_get_size(type))) + if (0 == (elmt_size = H5T_get_size(type))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid") /* Allocate the selection iterator */ - if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize iterator */ - if(H5S_select_iter_init(iter, space, elmt_size, 0) < 0) + if (H5S_select_iter_init(iter, space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - iter_init = TRUE; /* Selection iteration info has been initialized */ + iter_init = TRUE; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ - if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") /* Get the rank of the dataspace */ ndims = space->extent.rank; - if(ndims > 0) { - /* Copy the size of the space */ - HDassert(space->extent.size); - H5MM_memcpy(space_size, space->extent.size, ndims * sizeof(hsize_t)); + if (ndims > 0) { + /* Copy the size of the space */ + HDassert(space->extent.size); + H5MM_memcpy(space_size, space->extent.size, ndims * sizeof(hsize_t)); } /* end if */ space_size[ndims] = elmt_size; @@ -1593,25 +1551,26 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, H5_CHECKED_ASSIGN(max_elem, size_t, nelmts, hssize_t); /* Allocate the offset & length arrays */ - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate offset vector array") /* Loop, while elements left in selection */ - while(max_elem > 0 && user_ret == 0) { - size_t nelem; /* Number of elements used in sequences */ - size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequence being worked on */ + while (max_elem > 0 && user_ret == 0) { + size_t nelem; /* Number of elements used in sequences */ + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequence being worked on */ /* Get the sequences of bytes */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, + len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq && user_ret == 0; curr_seq++) { - hsize_t curr_off; /* Current offset within sequence */ - size_t curr_len; /* Length of bytes left to process in sequence */ + for (curr_seq = 0; curr_seq < nseq && user_ret == 0; curr_seq++) { + hsize_t curr_off; /* Current offset within sequence */ + size_t curr_len; /* Length of bytes left to process in sequence */ /* Get the current offset */ curr_off = off[curr_seq]; @@ -1620,14 +1579,14 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, curr_len = len[curr_seq]; /* Loop, while bytes left in sequence */ - while(curr_len > 0 && user_ret == 0) { - hsize_t coords[H5S_MAX_RANK]; /* Coordinates of element in dataspace */ - hsize_t tmp_off; /* Temporary offset within sequence */ - uint8_t *loc; /* Current element location in buffer */ - int i; /* Local Index variable */ + while (curr_len > 0 && user_ret == 0) { + hsize_t coords[H5S_MAX_RANK]; /* Coordinates of element in dataspace */ + hsize_t tmp_off; /* Temporary offset within sequence */ + uint8_t *loc; /* Current element location in buffer */ + int i; /* Local Index variable */ /* Compute the coordinate from the offset */ - for(i = (int)ndims, tmp_off = curr_off; i >= 0; i--) { + for (i = (int)ndims, tmp_off = curr_off; i >= 0; i--) { coords[i] = tmp_off % space_size[i]; tmp_off /= space_size[i]; } /* end for */ @@ -1636,23 +1595,23 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, loc = (unsigned char *)buf + curr_off; /* Check which type of callback to make */ - switch(op->op_type) { + switch (op->op_type) { case H5S_SEL_ITER_OP_APP: /* Make the application callback */ user_ret = (op->u.app_op.op)(loc, op->u.app_op.type_id, ndims, coords, op_data); - break; + break; case H5S_SEL_ITER_OP_LIB: /* Call the library's callback */ user_ret = (op->u.lib_op)(loc, type, ndims, coords, op_data); - break; + break; default: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported op type") } /* end switch */ /* Check for error return from iterator */ - if(user_ret < 0) + if (user_ret < 0) HERROR(H5E_DATASPACE, H5E_CANTNEXT, "iteration operator failed"); /* Increment offset in dataspace */ @@ -1661,7 +1620,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, /* Decrement number of bytes left in sequence */ curr_len -= elmt_size; } /* end while */ - } /* end for */ + } /* end for */ /* Decrement number of elements left to process */ max_elem -= nelem; @@ -1672,21 +1631,20 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); /* Release selection iterator */ - if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(iter) + if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iterate() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_type @@ -1699,20 +1657,20 @@ done: Non-negative on success/Negative on failure. Return value is from the set of values in the H5S_sel_type enumerated type. DESCRIPTION - This function retrieves the type of selection currently defined for + This function retrieves the type of selection currently defined for a dataspace. --------------------------------------------------------------------------*/ H5S_sel_type H5Sget_select_type(hid_t space_id) { - H5S_t *space; /* dataspace to modify */ - H5S_sel_type ret_value; /* Return value */ + H5S_t * space; /* dataspace to modify */ + H5S_sel_type ret_value; /* Return value */ FUNC_ENTER_API(H5S_SEL_ERROR) H5TRACE1("St", "i", space_id); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a dataspace") /* Set return value */ @@ -1722,7 +1680,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_type() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_type @@ -1735,7 +1692,7 @@ done: Non-negative on success/Negative on failure. Return value is from the set of values in the H5S_sel_type enumerated type. DESCRIPTION - This function retrieves the type of selection currently defined for + This function retrieves the type of selection currently defined for a dataspace. COMMENTS This routine participates in the "Inlining C function pointers" @@ -1745,7 +1702,7 @@ done: H5_ATTR_PURE H5S_sel_type H5S_get_select_type(const H5S_t *space) { - H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */ + H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1758,7 +1715,6 @@ H5S_get_select_type(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_type() */ - /*-------------------------------------------------------------------------- NAME H5S_select_shape_same @@ -1785,11 +1741,11 @@ H5S_get_select_type(const H5S_t *space) htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) { - H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */ - H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */ - hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */ - hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */ - htri_t ret_value = TRUE; /* Return value */ + H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */ + H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */ + hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */ + hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1798,20 +1754,20 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) HDassert(space2); /* Check for different number of elements selected */ - if(H5S_GET_SELECT_NPOINTS(space1) != H5S_GET_SELECT_NPOINTS(space2)) + if (H5S_GET_SELECT_NPOINTS(space1) != H5S_GET_SELECT_NPOINTS(space2)) HGOTO_DONE(FALSE) /* Check special cases if both dataspaces aren't scalar */ /* (If only one is, the number of selected points check is sufficient) */ - if(space1->extent.rank > 0 && space2->extent.rank > 0) { - const H5S_t *space_a; /* Dataspace with larger rank */ - const H5S_t *space_b; /* Dataspace with smaller rank */ - unsigned space_a_rank; /* Number of dimensions of dataspace A */ - unsigned space_b_rank; /* Number of dimensions of dataspace B */ - int space_a_dim; /* Current dimension in dataspace A */ - int space_b_dim; /* Current dimension in dataspace B */ - H5S_sel_type sel_a_type; /* Selection type for dataspace A */ - H5S_sel_type sel_b_type; /* Selection type for dataspace B */ + if (space1->extent.rank > 0 && space2->extent.rank > 0) { + const H5S_t *space_a; /* Dataspace with larger rank */ + const H5S_t *space_b; /* Dataspace with smaller rank */ + unsigned space_a_rank; /* Number of dimensions of dataspace A */ + unsigned space_b_rank; /* Number of dimensions of dataspace B */ + int space_a_dim; /* Current dimension in dataspace A */ + int space_b_dim; /* Current dimension in dataspace B */ + H5S_sel_type sel_a_type; /* Selection type for dataspace A */ + H5S_sel_type sel_b_type; /* Selection type for dataspace B */ /* Need to be able to handle spaces of different rank: * @@ -1827,7 +1783,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) * * Set all this up here. */ - if(space1->extent.rank >= space2->extent.rank) { + if (space1->extent.rank >= space2->extent.rank) { space_a = space1; space_b = space2; } /* end if */ @@ -1845,29 +1801,30 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) sel_b_type = H5S_GET_SELECT_TYPE(space_b); /* If selections aren't "none", compare their bounds */ - if(sel_a_type != H5S_SEL_NONE && sel_b_type != H5S_SEL_NONE) { - hsize_t low_a[H5S_MAX_RANK]; /* Low bound of selection in dataspace a */ - hsize_t low_b[H5S_MAX_RANK]; /* Low bound of selection in dataspace b */ - hsize_t high_a[H5S_MAX_RANK]; /* High bound of selection in dataspace a */ - hsize_t high_b[H5S_MAX_RANK]; /* High bound of selection in dataspace b */ + if (sel_a_type != H5S_SEL_NONE && sel_b_type != H5S_SEL_NONE) { + hsize_t low_a[H5S_MAX_RANK]; /* Low bound of selection in dataspace a */ + hsize_t low_b[H5S_MAX_RANK]; /* Low bound of selection in dataspace b */ + hsize_t high_a[H5S_MAX_RANK]; /* High bound of selection in dataspace a */ + hsize_t high_b[H5S_MAX_RANK]; /* High bound of selection in dataspace b */ /* Get low & high bounds for both dataspaces */ - if(H5S_SELECT_BOUNDS(space_a, low_a, high_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for first dataspace") - if(H5S_SELECT_BOUNDS(space_b, low_b, high_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for second dataspace") + if (H5S_SELECT_BOUNDS(space_a, low_a, high_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, + "can't get selection bounds for first dataspace") + if (H5S_SELECT_BOUNDS(space_b, low_b, high_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, + "can't get selection bounds for second dataspace") /* Check that the range between the low & high bounds are the same */ space_a_dim = (int)space_a_rank - 1; space_b_dim = (int)space_b_rank - 1; - while(space_b_dim >= 0) { + while (space_b_dim >= 0) { /* Sanity check */ HDassert(low_a[space_a_dim] <= high_a[space_a_dim]); HDassert(low_a[space_b_dim] <= high_a[space_b_dim]); /* Verify that the ranges are the same */ - if((high_a[space_a_dim] - low_a[space_a_dim]) - != (high_b[space_b_dim] - low_b[space_b_dim])) + if ((high_a[space_a_dim] - low_a[space_a_dim]) != (high_b[space_b_dim] - low_b[space_b_dim])) HGOTO_DONE(FALSE) /* Go to next dimension */ @@ -1876,45 +1833,45 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ /* Check that the rest of the ranges in space a are "flat" */ - while(space_a_dim >= 0) { + while (space_a_dim >= 0) { /* Sanity check */ HDassert(low_a[space_a_dim] <= high_a[space_a_dim]); /* This range should be flat to be the same in a lower dimension */ - if(low_a[space_a_dim] != high_a[space_a_dim]) + if (low_a[space_a_dim] != high_a[space_a_dim]) HGOTO_DONE(FALSE) space_a_dim--; } /* end while */ /* Check for a single block in each selection */ - if(H5S_SELECT_IS_SINGLE(space_a) && H5S_SELECT_IS_SINGLE(space_b)) { + if (H5S_SELECT_IS_SINGLE(space_a) && H5S_SELECT_IS_SINGLE(space_b)) { /* If both selections are a single block and their bounds are * the same, then the selections are the same, even if the * selection types are different. */ HGOTO_DONE(TRUE) } /* end if */ - } /* end if */ + } /* end if */ /* If the dataspaces have the same selection type, use the selection's * shape_same operator. */ - if(sel_a_type == sel_b_type) + if (sel_a_type == sel_b_type) ret_value = (*space_a->select.type->shape_same)(space_a, space_b); /* Otherwise, iterate through all the blocks in the selection */ else { - hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */ - hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */ - hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */ - hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */ - hssize_t offset[H5S_MAX_RANK]; /* Offset of selection b blocks relative to selection a blocks */ - hbool_t first_block = TRUE; /* Flag to indicate the first block */ + hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */ + hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */ + hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */ + hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */ + hssize_t offset[H5S_MAX_RANK]; /* Offset of selection b blocks relative to selection a blocks */ + hbool_t first_block = TRUE; /* Flag to indicate the first block */ /* Allocate the selection iterators */ - if(NULL == (iter_a = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter_a = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") - if(NULL == (iter_b = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter_b = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize iterator for each dataspace selection @@ -1922,21 +1879,21 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) * that the selection iterator shouldn't be "flattened", since we * aren't actually going to be doing I/O with the iterators. */ - if(H5S_select_iter_init(iter_a, space_a, (size_t)0, 0) < 0) + if (H5S_select_iter_init(iter_a, space_a, (size_t)0, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator a") iter_a_init = TRUE; - if(H5S_select_iter_init(iter_b, space_b, (size_t)0, 0) < 0) + if (H5S_select_iter_init(iter_b, space_b, (size_t)0, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator b") iter_b_init = TRUE; /* Iterate over all the blocks in each selection */ - while(1) { - htri_t status_a, status_b; /* Status from next block checks */ + while (1) { + htri_t status_a, status_b; /* Status from next block checks */ /* Get the current block for each selection iterator */ - if(H5S_SELECT_ITER_BLOCK(iter_a, start_a, end_a) < 0) + if (H5S_SELECT_ITER_BLOCK(iter_a, start_a, end_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block a") - if(H5S_SELECT_ITER_BLOCK(iter_b, start_b, end_b) < 0) + if (H5S_SELECT_ITER_BLOCK(iter_b, start_b, end_b) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block b") space_a_dim = (int)space_a_rank - 1; @@ -1945,13 +1902,13 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) /* The first block only compares the sizes and sets the * relative offsets for later blocks */ - if(first_block) { + if (first_block) { /* If the block sizes in the common dimensions from * each selection don't match, get out */ - while(space_b_dim >= 0) { - if((end_a[space_a_dim] - start_a[space_a_dim]) != - (end_b[space_b_dim] - start_b[space_b_dim])) + while (space_b_dim >= 0) { + if ((end_a[space_a_dim] - start_a[space_a_dim]) != + (end_b[space_b_dim] - start_b[space_b_dim])) HGOTO_DONE(FALSE) /* Set the relative locations of the selections */ @@ -1964,8 +1921,8 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) /* Similarly, if the block size in any dimension that appears only * in space_a is not equal to 1, get out. */ - while(space_a_dim >= 0) { - if(start_a[space_a_dim] != end_a[space_a_dim]) + while (space_a_dim >= 0) { + if (start_a[space_a_dim] != end_a[space_a_dim]) HGOTO_DONE(FALSE) space_a_dim--; @@ -1977,14 +1934,15 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) /* Check over the blocks for each selection */ else { /* For dimensions that space_a and space_b have in common: */ - while(space_b_dim >= 0) { + while (space_b_dim >= 0) { /* Check if the blocks are in the same relative location */ - if((hsize_t)((hssize_t)start_a[space_a_dim] + offset[space_a_dim]) != start_b[space_b_dim]) + if ((hsize_t)((hssize_t)start_a[space_a_dim] + offset[space_a_dim]) != + start_b[space_b_dim]) HGOTO_DONE(FALSE) /* If the block sizes from each selection doesn't match, get out */ - if((end_a[space_a_dim] - start_a[space_a_dim]) != - (end_b[space_b_dim] - start_b[space_b_dim])) + if ((end_a[space_a_dim] - start_a[space_a_dim]) != + (end_b[space_b_dim] - start_b[space_b_dim])) HGOTO_DONE(FALSE) space_a_dim--; @@ -1992,53 +1950,54 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ /* For dimensions that appear only in space_a: */ - while(space_a_dim >= 0) { + while (space_a_dim >= 0) { /* If the block size isn't 1, get out */ - if(start_a[space_a_dim] != end_a[space_a_dim]) + if (start_a[space_a_dim] != end_a[space_a_dim]) HGOTO_DONE(FALSE) space_a_dim--; } /* end while */ - } /* end else */ + } /* end else */ /* Check if we are able to advance to the next selection block */ - if((status_a = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_a)) < 0) + if ((status_a = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_a)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block a") - if((status_b = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_b)) < 0) + if ((status_b = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_b)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block b") /* Did we run out of blocks at the same time? */ - if((status_a == FALSE) && (status_b == FALSE)) + if ((status_a == FALSE) && (status_b == FALSE)) break; - else if(status_a != status_b) + else if (status_a != status_b) HGOTO_DONE(FALSE) else { /* Advance to next block in selection iterators */ - if(H5S_SELECT_ITER_NEXT_BLOCK(iter_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block a") + if (H5S_SELECT_ITER_NEXT_BLOCK(iter_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, + "unable to advance to next iterator block a") - if(H5S_SELECT_ITER_NEXT_BLOCK(iter_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block b") + if (H5S_SELECT_ITER_NEXT_BLOCK(iter_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, + "unable to advance to next iterator block b") } /* end else */ - } /* end while */ - } /* end else */ - } /* end if */ + } /* end while */ + } /* end else */ + } /* end if */ done: - if(iter_a_init && H5S_SELECT_ITER_RELEASE(iter_a) < 0) + if (iter_a_init && H5S_SELECT_ITER_RELEASE(iter_a) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator a") - if(iter_a) + if (iter_a) iter_a = H5FL_FREE(H5S_sel_iter_t, iter_a); - if(iter_b_init && H5S_SELECT_ITER_RELEASE(iter_b) < 0) + if (iter_b_init && H5S_SELECT_ITER_RELEASE(iter_b) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator b") - if(iter_b) + if (iter_b) iter_b = H5FL_FREE(H5S_sel_iter_t, iter_b); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_shape_same @@ -2062,25 +2021,24 @@ done: htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id) { - H5S_t *space1, *space2; /* Dataspaces to compare */ - htri_t ret_value; /* Return value */ + H5S_t *space1, *space2; /* Dataspaces to compare */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", space1_id, space2_id); - if(NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) + if (NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + if (NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if((ret_value = H5S_select_shape_same(space1, space2)) < 0) + if ((ret_value = H5S_select_shape_same(space1, space2)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't compare selections") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S_select_intersect_block @@ -2105,10 +2063,9 @@ done: don't call it directly, use the appropriate macro defined in H5Sprivate.h. --------------------------------------------------------------------------*/ htri_t -H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, - const hsize_t *end) +H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2118,31 +2075,30 @@ H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, HDassert(end); /* If selections aren't "none", compare their bounds */ - if(H5S_SEL_NONE != H5S_GET_SELECT_TYPE(space)) { - hsize_t low[H5S_MAX_RANK]; /* Low bound of selection in dataspace */ - hsize_t high[H5S_MAX_RANK]; /* High bound of selection in dataspace */ - unsigned u; /* Local index variable */ + if (H5S_SEL_NONE != H5S_GET_SELECT_TYPE(space)) { + hsize_t low[H5S_MAX_RANK]; /* Low bound of selection in dataspace */ + hsize_t high[H5S_MAX_RANK]; /* High bound of selection in dataspace */ + unsigned u; /* Local index variable */ /* Get low & high bounds for dataspace selection */ - if(H5S_SELECT_BOUNDS(space, low, high) < 0) + if (H5S_SELECT_BOUNDS(space, low, high) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for dataspace") /* Loop over selection bounds and block, checking for overlap */ - for(u = 0; u < space->extent.rank; u++) + for (u = 0; u < space->extent.rank; u++) /* If selection bounds & block don't overlap, can leave now */ - if(!H5S_RANGE_OVERLAP(low[u], high[u], start[u], end[u])) + if (!H5S_RANGE_OVERLAP(low[u], high[u], start[u], end[u])) HGOTO_DONE(FALSE) } /* end if */ /* Call selection type's intersect routine */ - if((ret_value = (*space->select.type->intersect_block)(space, start, end)) < 0) + if ((ret_value = (*space->select.type->intersect_block)(space, start, end)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't intersect block with selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_intersect_block @@ -2168,35 +2124,35 @@ done: htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *end) { - H5S_t *space; /* Dataspace to query */ - unsigned u; /* Local index value */ - htri_t ret_value = FAIL; /* Return value */ + H5S_t * space; /* Dataspace to query */ + unsigned u; /* Local index value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*h*h", space_id, start, end); /* Check arguments */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == start) + if (NULL == start) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "block start array pointer is NULL") - if(NULL == end) + if (NULL == end) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "block end array pointer is NULL") /* Range check start & end values */ - for(u = 0; u < space->extent.rank; u++) - if(start[u] > end[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "block start[%u] (%llu) > end[%u] (%llu)", u, (unsigned long long)start[u], u, (unsigned long long)end[u]) + for (u = 0; u < space->extent.rank; u++) + if (start[u] > end[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "block start[%u] (%llu) > end[%u] (%llu)", u, + (unsigned long long)start[u], u, (unsigned long long)end[u]) /* Call internal routine to do comparison */ - if((ret_value = H5S_select_intersect_block(space, start, end)) < 0) + if ((ret_value = H5S_select_intersect_block(space, start, end)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't compare selection and block") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S_select_construct_projection @@ -2227,15 +2183,15 @@ done: adj_buf_ptr) const H5S_t *base_space; IN: Ptr to Dataspace to project H5S_t ** new_space_ptr; OUT: Ptr to location in which to return - the address of the projected space + the address of the projected space int new_space_rank; IN: Rank of the projected space. const void * buf; IN: Base address of the buffer - associated with the base space. - May be NULL. + associated with the base space. + May be NULL. void ** adj_buf_ptr; OUT: If buf != NULL, store the base - address of the section of buf - that is described by *new_space_ptr - in *adj_buf_ptr. + address of the section of buf + that is described by *new_space_ptr + in *adj_buf_ptr. RETURNS Non-negative on success/Negative on failure. @@ -2258,45 +2214,46 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, - unsigned new_space_rank, const void *buf, void const **adj_buf_ptr, hsize_t element_size) +H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, unsigned new_space_rank, + const void *buf, void const **adj_buf_ptr, hsize_t element_size) { - H5S_t * new_space = NULL; /* New dataspace constructed */ - hsize_t base_space_dims[H5S_MAX_RANK]; /* Current dimensions of base dataspace */ - hsize_t base_space_maxdims[H5S_MAX_RANK]; /* Maximum dimensions of base dataspace */ - int sbase_space_rank; /* Signed # of dimensions of base dataspace */ - unsigned base_space_rank; /* # of dimensions of base dataspace */ - hsize_t projected_space_element_offset = 0; /* Offset of selected element in projected buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t * new_space = NULL; /* New dataspace constructed */ + hsize_t base_space_dims[H5S_MAX_RANK]; /* Current dimensions of base dataspace */ + hsize_t base_space_maxdims[H5S_MAX_RANK]; /* Maximum dimensions of base dataspace */ + int sbase_space_rank; /* Signed # of dimensions of base dataspace */ + unsigned base_space_rank; /* # of dimensions of base dataspace */ + hsize_t projected_space_element_offset = 0; /* Offset of selected element in projected buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ HDassert(base_space != NULL); - HDassert((H5S_GET_EXTENT_TYPE(base_space) == H5S_SCALAR) || (H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE)); + HDassert((H5S_GET_EXTENT_TYPE(base_space) == H5S_SCALAR) || + (H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE)); HDassert(new_space_ptr != NULL); HDassert((new_space_rank != 0) || (H5S_GET_SELECT_NPOINTS(base_space) <= 1)); HDassert(new_space_rank <= H5S_MAX_RANK); HDassert((buf == NULL) || (adj_buf_ptr != NULL)); - HDassert(element_size > 0 ); + HDassert(element_size > 0); /* Get the extent info for the base dataspace */ - if((sbase_space_rank = H5S_get_simple_extent_dims(base_space, base_space_dims, base_space_maxdims)) < 0) + if ((sbase_space_rank = H5S_get_simple_extent_dims(base_space, base_space_dims, base_space_maxdims)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality of base space") base_space_rank = (unsigned)sbase_space_rank; HDassert(base_space_rank != new_space_rank); /* Check if projected space is scalar */ - if(new_space_rank == 0) { - hssize_t npoints; /* Number of points selected */ + if (new_space_rank == 0) { + hssize_t npoints; /* Number of points selected */ /* Retreve the number of elements selected */ - if((npoints = (hssize_t)H5S_GET_SELECT_NPOINTS(base_space)) < 0) + if ((npoints = (hssize_t)H5S_GET_SELECT_NPOINTS(base_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get number of points selected") HDassert(npoints <= 1); /* Create new scalar dataspace */ - if(NULL == (new_space = H5S_create(H5S_SCALAR))) + if (NULL == (new_space = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create scalar dataspace") /* No need to register the dataspace(i.e. get an ID) as @@ -2312,7 +2269,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * same shape as the file dataspace, and that data * space is scalar. */ - if(1 == npoints) { + if (1 == npoints) { /* Assuming that the selection in the base dataspace is not * empty, we must compute the offset of the selected item in * the buffer associated with the base dataspace. @@ -2323,20 +2280,20 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * selection, may be either point, hyperspace, or all. * */ - if(H5S_SELECT_PROJECT_SCALAR(base_space, &projected_space_element_offset) < 0) + if (H5S_SELECT_PROJECT_SCALAR(base_space, &projected_space_element_offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to project scalar selection") } /* end if */ else { HDassert(0 == npoints); - if(H5S_select_none(new_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't delete default selection") - } /* end else */ - } /* end if */ - else { /* projected space must be simple */ - hsize_t new_space_dims[H5S_MAX_RANK]; /* Current dimensions for new dataspace */ - hsize_t new_space_maxdims[H5S_MAX_RANK];/* Maximum dimensions for new dataspace */ - unsigned rank_diff; /* Difference in ranks */ + if (H5S_select_none(new_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't delete default selection") + } /* end else */ + } /* end if */ + else { /* projected space must be simple */ + hsize_t new_space_dims[H5S_MAX_RANK]; /* Current dimensions for new dataspace */ + hsize_t new_space_maxdims[H5S_MAX_RANK]; /* Maximum dimensions for new dataspace */ + unsigned rank_diff; /* Difference in ranks */ /* Set up the dimensions of the new, projected dataspace. * @@ -2366,8 +2323,8 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * only in the higher rank dataspace (i.e. those with * more slowly changing indicies). */ - if(new_space_rank > base_space_rank) { - hsize_t tmp_dim_size = 1; /* Temporary dimension value, for filling arrays */ + if (new_space_rank > base_space_rank) { + hsize_t tmp_dim_size = 1; /* Temporary dimension value, for filling arrays */ /* we must copy the dimensions of the base space into * the fastest changing dimensions of the new space, @@ -2376,22 +2333,26 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, rank_diff = new_space_rank - base_space_rank; H5VM_array_fill(new_space_dims, &tmp_dim_size, sizeof(tmp_dim_size), rank_diff); H5VM_array_fill(new_space_maxdims, &tmp_dim_size, sizeof(tmp_dim_size), rank_diff); - H5MM_memcpy(&new_space_dims[rank_diff], base_space_dims, sizeof(new_space_dims[0]) * base_space_rank); - H5MM_memcpy(&new_space_maxdims[rank_diff], base_space_maxdims, sizeof(new_space_maxdims[0]) * base_space_rank); - } /* end if */ + H5MM_memcpy(&new_space_dims[rank_diff], base_space_dims, + sizeof(new_space_dims[0]) * base_space_rank); + H5MM_memcpy(&new_space_maxdims[rank_diff], base_space_maxdims, + sizeof(new_space_maxdims[0]) * base_space_rank); + } /* end if */ else { /* new_space_rank < base_space_rank */ /* we must copy the fastest changing dimension of the * base space into the dimensions of the new space. */ rank_diff = base_space_rank - new_space_rank; - H5MM_memcpy(new_space_dims, &base_space_dims[rank_diff], sizeof(new_space_dims[0]) * new_space_rank); - H5MM_memcpy(new_space_maxdims, &base_space_maxdims[rank_diff], sizeof(new_space_maxdims[0]) * new_space_rank); + H5MM_memcpy(new_space_dims, &base_space_dims[rank_diff], + sizeof(new_space_dims[0]) * new_space_rank); + H5MM_memcpy(new_space_maxdims, &base_space_maxdims[rank_diff], + sizeof(new_space_maxdims[0]) * new_space_rank); } /* end else */ /* now have the new space rank and dimensions set up -- * so we can create the new simple dataspace. */ - if(NULL == (new_space = H5S_create_simple(new_space_rank, new_space_dims, new_space_maxdims))) + if (NULL == (new_space = H5S_create_simple(new_space_rank, new_space_dims, new_space_maxdims))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* No need to register the dataspace(i.e. get an ID) as @@ -2402,7 +2363,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * dataspace. We must now project the selection in the base * dataspace into the projected dataspace. */ - if(H5S_SELECT_PROJECT_SIMPLE(base_space, new_space, &projected_space_element_offset) < 0) + if (H5S_SELECT_PROJECT_SIMPLE(base_space, new_space, &projected_space_element_offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to project simple selection") /* If we get this far, we have created the new dataspace, and projected @@ -2413,18 +2374,20 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * project the offset into the new dataspace and set the * offset_changed flag. */ - if(H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE && base_space->select.offset_changed) { - if(new_space_rank > base_space_rank) { + if (H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE && base_space->select.offset_changed) { + if (new_space_rank > base_space_rank) { HDmemset(new_space->select.offset, 0, sizeof(new_space->select.offset[0]) * rank_diff); - H5MM_memcpy(&new_space->select.offset[rank_diff], base_space->select.offset, sizeof(new_space->select.offset[0]) * base_space_rank); + H5MM_memcpy(&new_space->select.offset[rank_diff], base_space->select.offset, + sizeof(new_space->select.offset[0]) * base_space_rank); } /* end if */ else - H5MM_memcpy(new_space->select.offset, &base_space->select.offset[rank_diff], sizeof(new_space->select.offset[0]) * new_space_rank); + H5MM_memcpy(new_space->select.offset, &base_space->select.offset[rank_diff], + sizeof(new_space->select.offset[0]) * new_space_rank); /* Propagate the offset changed flag into the new dataspace. */ new_space->select.offset_changed = TRUE; } /* end if */ - } /* end else */ + } /* end else */ /* If we have done the projection correctly, the following assertion * should hold. @@ -2435,8 +2398,8 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, *new_space_ptr = new_space; /* now adjust the buffer if required */ - if(buf != NULL) { - if(new_space_rank < base_space_rank) { + if (buf != NULL) { + if (new_space_rank < base_space_rank) { /* a bit of pointer magic here: * * Since we can't do pointer arithmetic on void pointers, we first @@ -2448,7 +2411,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * to a pointer to void, and assign the result to *adj_buf_ptr. */ *adj_buf_ptr = (const void *)(((const uint8_t *)buf) + - ((size_t)(projected_space_element_offset * element_size))); + ((size_t)(projected_space_element_offset * element_size))); } /* end if */ else /* No adjustment necessary */ @@ -2457,14 +2420,13 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, done: /* Cleanup on error */ - if(ret_value < 0) - if(new_space && H5S_close(new_space) < 0) + if (ret_value < 0) + if (new_space && H5S_close(new_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_construct_projection() */ - /*-------------------------------------------------------------------------- NAME H5S_select_fill @@ -2492,13 +2454,13 @@ done: herr_t H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_buf) { - H5S_sel_iter_t *iter = NULL; /* Selection iteration info */ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ - hsize_t *off = NULL; /* Array to store sequence offsets */ - size_t *len = NULL; /* Array to store sequence lengths */ - hssize_t nelmts; /* Number of elements in selection */ - size_t max_elem; /* Total number of elements in selection */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_sel_iter_t *iter = NULL; /* Selection iteration info */ + hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ + hsize_t * off = NULL; /* Array to store sequence offsets */ + size_t * len = NULL; /* Array to store sequence lengths */ + hssize_t nelmts; /* Number of elements in selection */ + size_t max_elem; /* Total number of elements in selection */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2509,40 +2471,41 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b HDassert(_buf); /* Allocate the selection iterator */ - if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize iterator */ - if(H5S_select_iter_init(iter, space, fill_size, 0) < 0) + if (H5S_select_iter_init(iter, space, fill_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - iter_init = TRUE; /* Selection iteration info has been initialized */ + iter_init = TRUE; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ - if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") /* Compute the number of bytes to process */ H5_CHECKED_ASSIGN(max_elem, size_t, nelmts, hssize_t); /* Allocate the offset & length arrays */ - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate offset vector array") /* Loop, while elements left in selection */ - while(max_elem > 0) { - size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequnce being worked on */ - size_t nelem; /* Number of elements used in sequences */ + while (max_elem > 0) { + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequnce being worked on */ + size_t nelem; /* Number of elements used in sequences */ /* Get the sequences of bytes */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, + len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Loop over sequences */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { - uint8_t *buf; /* Current location in buffer */ + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { + uint8_t *buf; /* Current location in buffer */ /* Get offset in memory buffer */ buf = (uint8_t *)_buf + off[curr_seq]; @@ -2558,21 +2521,20 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); /* Release selection iterator */ - if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(iter) + if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_fill() */ - /*-------------------------------------------------------------------------- NAME H5S_select_project_intersection @@ -2584,11 +2546,12 @@ done: USAGE herr_t H5S_select_project_intersection(src_space,dst_space,src_intersect_space,proj_space,share_selection) - H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with src_intersect_space - H5S_t *dst_space; IN: Selection that is mapped to src_space - H5S_t *src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space to obtain the result - H5S_t **new_space_ptr; OUT: Will contain the result (intersection of src_intersect_space and src_space projected from src_space to dst_space) after the operation - hbool_t share_selection; IN: Whether we are allowed to share structures inside dst_space with proj_space + H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with +src_intersect_space H5S_t *dst_space; IN: Selection that is mapped to src_space H5S_t +*src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space to obtain the +result H5S_t **new_space_ptr; OUT: Will contain the result (intersection of src_intersect_space and src_space +projected from src_space to dst_space) after the operation hbool_t share_selection; IN: Whether we are allowed +to share structures inside dst_space with proj_space RETURNS Non-negative on success/Negative on failure. @@ -2606,16 +2569,16 @@ done: --------------------------------------------------------------------------*/ herr_t H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, - const H5S_t *src_intersect_space, H5S_t **new_space_ptr, - hbool_t share_selection) + const H5S_t *src_intersect_space, H5S_t **new_space_ptr, + hbool_t share_selection) { - H5S_t *new_space = NULL; /* New dataspace constructed */ - H5S_t *tmp_src_intersect_space = NULL; /* Temporary SIS converted from points->hyperslabs */ - H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */ - hbool_t ss_iter_init = FALSE; /* Whether ss_iter has been initialized */ - H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */ - hbool_t ds_iter_init = FALSE; /* Whether ds_iter has been initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t * new_space = NULL; /* New dataspace constructed */ + H5S_t * tmp_src_intersect_space = NULL; /* Temporary SIS converted from points->hyperslabs */ + H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */ + hbool_t ss_iter_init = FALSE; /* Whether ss_iter has been initialized */ + H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */ + hbool_t ds_iter_init = FALSE; /* Whether ds_iter has been initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2627,31 +2590,30 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(H5S_GET_SELECT_NPOINTS(src_space) == H5S_GET_SELECT_NPOINTS(dst_space)); HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space)); - if(NULL == (ss_iter = H5FL_CALLOC(H5S_sel_iter_t))) + if (NULL == (ss_iter = H5FL_CALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") - if(NULL == (ds_iter = H5FL_CALLOC(H5S_sel_iter_t))) + if (NULL == (ds_iter = H5FL_CALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Create new space, using dst extent. Start with "all" selection. */ - if(NULL == (new_space = H5S_create(H5S_SIMPLE))) + if (NULL == (new_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create output dataspace") - if(H5S__extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0) + if (H5S__extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy destination space extent") /* If the intersecting space is "all", the intersection must be equal to the * source space and the projection must be equal to the destination space */ - if(H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_ALL) { + if (H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_ALL) { /* Copy the destination selection. */ - if(H5S_select_copy(new_space, dst_space, FALSE) < 0) + if (H5S_select_copy(new_space, dst_space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination space selection") } /* end if */ /* If any of the selections contain no elements, the projection must be * "none" */ - else if((H5S_GET_SELECT_NPOINTS(src_intersect_space) == 0) - || (H5S_GET_SELECT_NPOINTS(src_space) == 0) - || (H5S_GET_SELECT_NPOINTS(dst_space) == 0)) { + else if ((H5S_GET_SELECT_NPOINTS(src_intersect_space) == 0) || (H5S_GET_SELECT_NPOINTS(src_space) == 0) || + (H5S_GET_SELECT_NPOINTS(dst_space) == 0)) { /* Change to "none" selection */ - if(H5S_select_none(new_space) < 0) + if (H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ else { @@ -2667,28 +2629,28 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Check for scalar dst_space. In this case we simply check if the * (single) point selected in src_space intersects src_intersect_space, * if so select all in new_space, otherwise select none. */ - if(H5S_GET_EXTENT_TYPE(dst_space) == H5S_SCALAR) { + if (H5S_GET_EXTENT_TYPE(dst_space) == H5S_SCALAR) { hsize_t coords_start[H5S_MAX_RANK]; hsize_t coords_end[H5S_MAX_RANK]; - htri_t intersect; + htri_t intersect; /* Get source space bounds. Should be a single point. */ - if(H5S_SELECT_BOUNDS(src_space, coords_start, coords_end) < 0) + if (H5S_SELECT_BOUNDS(src_space, coords_start, coords_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get source space bounds") - HDassert(0 == HDmemcmp(coords_start, coords_end, H5S_GET_EXTENT_NDIMS(src_space) * sizeof(coords_start[0]))); + HDassert(0 == HDmemcmp(coords_start, coords_end, + H5S_GET_EXTENT_NDIMS(src_space) * sizeof(coords_start[0]))); /* Check for intersection */ - if((intersect = H5S_SELECT_INTERSECT_BLOCK(src_intersect_space, coords_start, coords_end)) < 0) + if ((intersect = H5S_SELECT_INTERSECT_BLOCK(src_intersect_space, coords_start, coords_end)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't check for intersection") /* Select all or none as appropriate */ - if(intersect) { - if(H5S_select_all(new_space, TRUE) < 0) + if (intersect) { + if (H5S_select_all(new_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't select all") } /* end if */ - else - if(H5S_select_none(new_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") + else if (H5S_select_none(new_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ else { /* If the source intersect space is a point selection, convert it to a @@ -2697,20 +2659,26 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Maybe we should just leave it as a point selection for the point by * point algorithm? The search through the selection in * H5S_SELECT_INTERSECT_BLOCK will likely be O(N) either way. -NAF */ - if(H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_POINTS) { + if (H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_POINTS) { H5S_pnt_node_t *curr_pnt = src_intersect_space->select.sel_info.pnt_lst->head; /* Create dataspace and copy extent */ - if(NULL == (tmp_src_intersect_space = H5S_create(H5S_SIMPLE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create temporary source intersect dataspace") - if(H5S__extent_copy_real(&tmp_src_intersect_space->extent, &src_intersect_space->extent, FALSE) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy source intersect space extent") + if (NULL == (tmp_src_intersect_space = H5S_create(H5S_SIMPLE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, + "unable to create temporary source intersect dataspace") + if (H5S__extent_copy_real(&tmp_src_intersect_space->extent, &src_intersect_space->extent, + FALSE) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, + "unable to copy source intersect space extent") /* Iterate over points */ - for(curr_pnt = src_intersect_space->select.sel_info.pnt_lst->head; curr_pnt; curr_pnt = curr_pnt->next) + for (curr_pnt = src_intersect_space->select.sel_info.pnt_lst->head; curr_pnt; + curr_pnt = curr_pnt->next) /* Add point to hyperslab selection */ - if(H5S_hyper_add_span_element(tmp_src_intersect_space, src_intersect_space->extent.rank, curr_pnt->pnt) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't add point to temporary dataspace selection") + if (H5S_hyper_add_span_element(tmp_src_intersect_space, src_intersect_space->extent.rank, + curr_pnt->pnt) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, + "can't add point to temporary dataspace selection") /* Redirect local src_intersect_space pointer (will not affect * calling function) */ @@ -2722,21 +2690,23 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* If either the source space or the destination space is a point * selection, iterate element by element */ - if((H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_POINTS) - || (H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_POINTS)) { + if ((H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_POINTS) || + (H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_POINTS)) { hsize_t coords[H5S_MAX_RANK]; - htri_t intersect; + htri_t intersect; /* Start with "none" selection */ - if(H5S_select_none(new_space) < 0) + if (H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Initialize iterators */ - if(H5S_select_iter_init(ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize source space selection iterator") + if (H5S_select_iter_init(ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, + "can't initialize source space selection iterator") ss_iter_init = TRUE; - if(H5S_select_iter_init(ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize destination space selection iterator") + if (H5S_select_iter_init(ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, + "can't initialize destination space selection iterator") ds_iter_init = TRUE; /* Iterate over points */ @@ -2745,32 +2715,37 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(ss_iter->elmt_left > 0); /* Get SS coords */ - if(H5S_SELECT_ITER_COORDS(ss_iter, coords) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get source selection coordinates") + if (H5S_SELECT_ITER_COORDS(ss_iter, coords) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, + "can't get source selection coordinates") /* Check for intersection */ - if((intersect = H5S_SELECT_INTERSECT_BLOCK(src_intersect_space, coords, coords)) < 0) + if ((intersect = H5S_SELECT_INTERSECT_BLOCK(src_intersect_space, coords, coords)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't check for intersection") /* Add point if it intersects */ - if(intersect) { + if (intersect) { /* Get DS coords */ - if(H5S_SELECT_ITER_COORDS(ds_iter, coords) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get destination selection coordinates") + if (H5S_SELECT_ITER_COORDS(ds_iter, coords) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, + "can't get destination selection coordinates") /* Add point to new_space */ - if(H5S_select_elements(new_space, H5S_SELECT_APPEND, 1, coords) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't add point to new selection") + if (H5S_select_elements(new_space, H5S_SELECT_APPEND, 1, coords) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, + "can't add point to new selection") } /* end if */ /* Advance iterators */ - if(H5S_SELECT_ITER_NEXT(ss_iter, 1) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne source selection iterator") + if (H5S_SELECT_ITER_NEXT(ss_iter, 1) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, + "can't advacne source selection iterator") ss_iter->elmt_left--; - if(H5S_SELECT_ITER_NEXT(ds_iter, 1) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne destination selection iterator") + if (H5S_SELECT_ITER_NEXT(ds_iter, 1) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, + "can't advacne destination selection iterator") ds_iter->elmt_left--; - } while(ss_iter->elmt_left > 0); + } while (ss_iter->elmt_left > 0); HDassert(H5S_SELECT_ITER_NELMTS(ds_iter) == 0); } /* end if */ else { @@ -2780,27 +2755,29 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Source and destination selections are all or hyperslab, * intersecting selection is hyperslab. Call the hyperslab routine * to project to another hyperslab selection. */ - if(H5S__hyper_project_intersection(src_space, dst_space, src_intersect_space, new_space, share_selection) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't project hyperslab onto destination selection") + if (H5S__hyper_project_intersection(src_space, dst_space, src_intersect_space, new_space, + share_selection) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, + "can't project hyperslab onto destination selection") } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* load the address of the new space into *new_space_ptr */ *new_space_ptr = new_space; done: /* Cleanup on error */ - if(ret_value < 0) - if(new_space && H5S_close(new_space) < 0) + if (ret_value < 0) + if (new_space && H5S_close(new_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") /* General cleanup */ - if(tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0) + if (tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release temporary dataspace") - if(ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0) + if (ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release source selection iterator") - if(ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0) + if (ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release destination selection iterator") ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter); @@ -2809,7 +2786,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_intersection() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_project_intersection @@ -2821,9 +2797,10 @@ done: USAGE hid_t H5Sselect_project_intersection(src_space_id,dst_space_d,src_intersect_space_id) - hid_t src_space_id; IN: Selection that is mapped to dst_space_id, and intersected with src_intersect_space_id - hid_t dst_space_id; IN: Selection that is mapped to src_space_id - hid_t src_intersect_space_id; IN: Selection whose intersection with src_space_id is projected to dst_space_id to obtain the result + hid_t src_space_id; IN: Selection that is mapped to dst_space_id, and intersected with +src_intersect_space_id hid_t dst_space_id; IN: Selection that is mapped to src_space_id hid_t +src_intersect_space_id; IN: Selection whose intersection with src_space_id is projected to dst_space_id to +obtain the result RETURNS A dataspace with a selection equal to the intersection of @@ -2842,51 +2819,50 @@ done: REVISION LOG --------------------------------------------------------------------------*/ hid_t -H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, - hid_t src_intersect_space_id) +H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, hid_t src_intersect_space_id) { H5S_t *src_space, *dst_space, *src_intersect_space; /* Input dataspaces */ - H5S_t *proj_space = NULL; /* Output dataspace */ - hid_t ret_value; /* Return value */ + H5S_t *proj_space = NULL; /* Output dataspace */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "iii", src_space_id, dst_space_id, src_intersect_space_id); /* Check args */ - if(NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) + if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) + if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (src_intersect_space = (H5S_t *)H5I_object_verify(src_intersect_space_id, H5I_DATASPACE))) + if (NULL == (src_intersect_space = (H5S_t *)H5I_object_verify(src_intersect_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") /* Check numbers of points selected matches in source and destination */ - if(H5S_GET_SELECT_NPOINTS(src_space) != H5S_GET_SELECT_NPOINTS(dst_space)) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "number of points selected in source space does not match that in destination space") + if (H5S_GET_SELECT_NPOINTS(src_space) != H5S_GET_SELECT_NPOINTS(dst_space)) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "number of points selected in source space does not match that in destination space") /* Check numbers of dimensions matches in source and source intersect spaces */ - if(H5S_GET_EXTENT_NDIMS(src_space) != H5S_GET_EXTENT_NDIMS(src_intersect_space)) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "rank of source space does not match rank of source intersect space") + if (H5S_GET_EXTENT_NDIMS(src_space) != H5S_GET_EXTENT_NDIMS(src_intersect_space)) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "rank of source space does not match rank of source intersect space") /* Perform operation */ - if(H5S_select_project_intersection(src_space, dst_space, - src_intersect_space, &proj_space, FALSE) < 0) + if (H5S_select_project_intersection(src_space, dst_space, src_intersect_space, &proj_space, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project dataspace intersection") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, proj_space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, proj_space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: - if(ret_value < 0) - if(proj_space && H5S_close(proj_space) < 0) + if (ret_value < 0) + if (proj_space && H5S_close(proj_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Sselect_project_intersection() */ - /*-------------------------------------------------------------------------- NAME H5S_select_subtract @@ -2915,7 +2891,7 @@ done: herr_t H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2925,40 +2901,40 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) /* If either space is using the none selection, then we do not need to do * anything */ - if((space->select.type->type != H5S_SEL_NONE) - && (subtract_space->select.type->type != H5S_SEL_NONE)) { + if ((space->select.type->type != H5S_SEL_NONE) && (subtract_space->select.type->type != H5S_SEL_NONE)) { /* If subtract_space is using the all selection, set space to none */ - if(subtract_space->select.type->type == H5S_SEL_ALL) { + if (subtract_space->select.type->type == H5S_SEL_ALL) { /* Change to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ /* If either selection is a point selection, fail currently */ - else if((subtract_space->select.type->type == H5S_SEL_POINTS) || - (space->select.type->type == H5S_SEL_POINTS)) { + else if ((subtract_space->select.type->type == H5S_SEL_POINTS) || + (space->select.type->type == H5S_SEL_POINTS)) { HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported") } /* end if */ else { /* Check for all selection in space, convert to hyperslab */ - if(space->select.type->type == H5S_SEL_ALL) { + if (space->select.type->type == H5S_SEL_ALL) { /* Convert current "all" selection to "real" hyperslab selection */ /* Then allow operation to proceed */ - hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ - hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ - hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ - hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ - unsigned u; /* Local index variable */ + hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ + hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ + hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ + unsigned u; /* Local index variable */ /* Fill in temporary information for the dimensions */ - for(u = 0; u < space->extent.rank; u++) { - tmp_start[u] = 0; + for (u = 0; u < space->extent.rank; u++) { + tmp_start[u] = 0; tmp_stride[u] = 1; - tmp_count[u] = 1; - tmp_block[u] = space->extent.size[u]; + tmp_count[u] = 1; + tmp_block[u] = space->extent.size[u]; } /* end for */ /* Convert to hyperslab selection */ - if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + if (H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end if */ @@ -2966,16 +2942,15 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) HDassert(subtract_space->select.type->type == H5S_SEL_HYPERSLABS); /* Both spaces are now hyperslabs, perform the operation */ - if(H5S__modify_select(space, H5S_SELECT_NOTB, subtract_space) < 0) + if (H5S__modify_select(space, H5S_SELECT_NOTB, subtract_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't subtract hyperslab") } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_subtract() */ - /*-------------------------------------------------------------------------- NAME H5Ssel_iter_create @@ -2999,41 +2974,41 @@ done: hid_t H5Ssel_iter_create(hid_t space_id, size_t elmt_size, unsigned flags) { - H5S_t *space; /* Dataspace with selection to iterate over */ - H5S_sel_iter_t *sel_iter; /* Selection iterator created */ - hid_t ret_value; /* Return value */ + H5S_t * space; /* Dataspace with selection to iterate over */ + H5S_sel_iter_t *sel_iter; /* Selection iterator created */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "izIu", space_id, elmt_size, flags); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") - if(elmt_size == 0) + if (elmt_size == 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "element size must be greater than 0") - if(flags != (flags & H5S_SEL_ITER_ALL_PUBLIC_FLAGS)) + if (flags != (flags & H5S_SEL_ITER_ALL_PUBLIC_FLAGS)) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "invalid selection iterator flag") /* Allocate the iterator */ - if(NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate selection iterator") /* Add flag to indicate that this iterator is from an API call */ flags |= H5S_SEL_ITER_API_CALL; /* Initialize the selection iterator */ - if(H5S_select_iter_init(sel_iter, space, elmt_size, flags) < 0) + if (H5S_select_iter_init(sel_iter, space, elmt_size, flags) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to initialize selection iterator") /* Atomize */ - if((ret_value = H5I_register(H5I_SPACE_SEL_ITER, sel_iter, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace selection iterator atom") + if ((ret_value = H5I_register(H5I_SPACE_SEL_ITER, sel_iter, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, H5I_INVALID_HID, + "unable to register dataspace selection iterator atom") done: FUNC_LEAVE_API(ret_value) } /* end H5Ssel_iter_create() */ - /*-------------------------------------------------------------------------- NAME H5Ssel_iter_get_seq_list @@ -3081,31 +3056,31 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq, size_t maxbytes, - size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len) +H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, + hsize_t *off, size_t *len) { - H5S_sel_iter_t *sel_iter; /* Dataspace selection iterator to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_sel_iter_t *sel_iter; /* Dataspace selection iterator to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "izz*z*z*h*z", sel_iter_id, maxseq, maxbytes, nseq, nbytes, off, len); /* Check args */ - if(NULL == (sel_iter = (H5S_sel_iter_t *)H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER))) + if (NULL == (sel_iter = (H5S_sel_iter_t *)H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator") - if(NULL == nseq) + if (NULL == nseq) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "'nseq' pointer is NULL") - if(NULL == nbytes) + if (NULL == nbytes) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "'nbytes' pointer is NULL") - if(NULL == off) + if (NULL == off) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "offset array pointer is NULL") - if(NULL == len) + if (NULL == len) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "length array pointer is NULL") /* Get the sequences of bytes */ - if(maxseq > 0 && maxbytes > 0 && sel_iter->elmt_left > 0) { - if(H5S_SELECT_ITER_GET_SEQ_LIST(sel_iter, maxseq, maxbytes, nseq, nbytes, off, len) < 0) + if (maxseq > 0 && maxbytes > 0 && sel_iter->elmt_left > 0) { + if (H5S_SELECT_ITER_GET_SEQ_LIST(sel_iter, maxseq, maxbytes, nseq, nbytes, off, len) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "sequence length generation failed") } /* end if */ else @@ -3115,7 +3090,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Ssel_iter_get_seq_list() */ - /*------------------------------------------------------------------------- * Function: H5S_sel_iter_close * @@ -3131,7 +3105,7 @@ done: herr_t H5S_sel_iter_close(H5S_sel_iter_t *sel_iter) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3139,8 +3113,9 @@ H5S_sel_iter_close(H5S_sel_iter_t *sel_iter) HDassert(sel_iter); /* Call selection type-specific release routine */ - if(H5S_SELECT_ITER_RELEASE(sel_iter) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "problem releasing a selection iterator's type-specific info") + if (H5S_SELECT_ITER_RELEASE(sel_iter) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, + "problem releasing a selection iterator's type-specific info") /* Release the structure */ sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter); @@ -3149,7 +3124,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_sel_iter_close() */ - /*-------------------------------------------------------------------------- NAME H5Ssel_iter_close @@ -3172,20 +3146,19 @@ done: herr_t H5Ssel_iter_close(hid_t sel_iter_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", sel_iter_id); /* Check args */ - if(NULL == H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER)) + if (NULL == H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER)) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator") /* When the reference count reaches zero the resources are freed */ - if(H5I_dec_app_ref(sel_iter_id) < 0) + if (H5I_dec_app_ref(sel_iter_id) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing dataspace selection iterator ID") done: FUNC_LEAVE_API(ret_value) } /* end H5Ssel_iter_close() */ - diff --git a/src/H5Stest.c b/src/H5Stest.c index b61b6bf..d180d2c 100644 --- a/src/H5Stest.c +++ b/src/H5Stest.c @@ -21,49 +21,41 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ -#define H5S_TESTING /*suppress warning about H5S testing funcs*/ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ +#define H5S_TESTING /*suppress warning about H5S testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Spkg.h" /* Dataspaces */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Spkg.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - - /*-------------------------------------------------------------------------- NAME H5S__get_rebuild_status_test @@ -89,8 +81,7 @@ REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, - H5S_diminfo_valid_t *status2) +H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, H5S_diminfo_valid_t *status2) { H5S_t *space; /* Pointer to 1st dataspace */ herr_t ret_value = SUCCEED; /* Return value */ @@ -100,14 +91,14 @@ H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, HDassert(status1); HDassert(status2); - /* Get dataspace structures */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + /* Get dataspace structures */ + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") *status1 = space->select.sel_info.hslab->diminfo_valid; /* Fully rebuild diminfo, if necessary */ - if(*status1 == H5S_DIMINFO_VALID_NO) + if (*status1 == H5S_DIMINFO_VALID_NO) H5S__hyper_rebuild(space); *status2 = space->select.sel_info.hslab->diminfo_valid; @@ -116,7 +107,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__get_rebuild_status_test() */ - /*-------------------------------------------------------------------------- NAME H5S__get_diminfo_status_test @@ -147,8 +137,8 @@ H5S__get_diminfo_status_test(hid_t space_id, H5S_diminfo_valid_t *status) HDassert(status); - /* Get dataspace structures */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + /* Get dataspace structures */ + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") *status = space->select.sel_info.hslab->diminfo_valid; @@ -181,24 +171,25 @@ H5S__check_spans_tail_ptr(const H5S_hyper_span_info_t *span_lst) { H5S_hyper_span_t *cur_elem; H5S_hyper_span_t *actual_tail = NULL; - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC HDassert(span_lst); cur_elem = span_lst->head; - while(cur_elem) { + while (cur_elem) { actual_tail = cur_elem; /* check the next dimension of lower order */ - if(NULL != cur_elem->down) - if((ret_value = H5S__check_spans_tail_ptr(cur_elem->down)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") + if (NULL != cur_elem->down) + if ((ret_value = H5S__check_spans_tail_ptr(cur_elem->down)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the seletion has inconsistent tail pointers") cur_elem = cur_elem->next; } /* end while */ - if(actual_tail != span_lst->tail) + if (actual_tail != span_lst->tail) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") done: @@ -228,25 +219,24 @@ H5S__check_points_tail_ptr(const H5S_pnt_list_t *pnt_lst) { H5S_pnt_node_t *cur_elem; H5S_pnt_node_t *actual_tail = NULL; - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC HDassert(pnt_lst); cur_elem = pnt_lst->head; - while(cur_elem) { + while (cur_elem) { actual_tail = cur_elem; - cur_elem = cur_elem->next; + cur_elem = cur_elem->next; } /* end while */ - if(actual_tail != pnt_lst->tail) + if (actual_tail != pnt_lst->tail) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__check_points_tail_ptr */ - /*-------------------------------------------------------------------------- NAME H5S__check_internal_consistency @@ -269,60 +259,70 @@ done: static herr_t H5S__check_internal_consistency(const H5S_t *space) { - hsize_t low_bounds[H5S_MAX_RANK]; - hsize_t high_bounds[H5S_MAX_RANK]; + hsize_t low_bounds[H5S_MAX_RANK]; + hsize_t high_bounds[H5S_MAX_RANK]; unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(space); - if(space->select.type->type == H5S_SEL_NONE) + if (space->select.type->type == H5S_SEL_NONE) HGOTO_DONE(ret_value); /* Initialize the inputs */ - for(u = 0; u < space->extent.rank; u++) { - low_bounds[u] = HSIZET_MAX; + for (u = 0; u < space->extent.rank; u++) { + low_bounds[u] = HSIZET_MAX; high_bounds[u] = 0; } /* end for */ /* Check the bound box */ - if(H5S_get_select_bounds(space, low_bounds, high_bounds) < 0) + if (H5S_get_select_bounds(space, low_bounds, high_bounds) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the bound box could not be retrieved") - if(space->select.type->type == H5S_SEL_HYPERSLABS) { + if (space->select.type->type == H5S_SEL_HYPERSLABS) { H5S_hyper_sel_t *hslab = space->select.sel_info.hslab; - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < space->extent.rank; u++) { - if((hsize_t)((hssize_t)hslab->diminfo.low_bounds[u] + space->select.offset[u]) != low_bounds[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the lower bound box of the selection is inconsistent") - if((hsize_t)((hssize_t)hslab->diminfo.high_bounds[u] + space->select.offset[u]) != high_bounds[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the higher bound box of the selection is inconsistent") + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + for (u = 0; u < space->extent.rank; u++) { + if ((hsize_t)((hssize_t)hslab->diminfo.low_bounds[u] + space->select.offset[u]) != + low_bounds[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the lower bound box of the selection is inconsistent") + if ((hsize_t)((hssize_t)hslab->diminfo.high_bounds[u] + space->select.offset[u]) != + high_bounds[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the higher bound box of the selection is inconsistent") } /* end for */ - } /* end if */ + } /* end if */ else { - for(u = 0; u < space->extent.rank; u++) { - if((hsize_t)((hssize_t)hslab->span_lst->low_bounds[u] + space->select.offset[u]) != low_bounds[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the lower bound box of the selection is inconsistent") - if((hsize_t)((hssize_t)hslab->span_lst->high_bounds[u] + space->select.offset[u]) != high_bounds[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the higher bound box of the selection is inconsistent") + for (u = 0; u < space->extent.rank; u++) { + if ((hsize_t)((hssize_t)hslab->span_lst->low_bounds[u] + space->select.offset[u]) != + low_bounds[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the lower bound box of the selection is inconsistent") + if ((hsize_t)((hssize_t)hslab->span_lst->high_bounds[u] + space->select.offset[u]) != + high_bounds[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the higher bound box of the selection is inconsistent") } /* end for */ - } /* end else */ + } /* end else */ /* check the tail pointer */ - if((NULL != hslab) && (NULL != hslab->span_lst)) - if(H5S__check_spans_tail_ptr(hslab->span_lst) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") + if ((NULL != hslab) && (NULL != hslab->span_lst)) + if (H5S__check_spans_tail_ptr(hslab->span_lst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the seletion has inconsistent tail pointers") } /* end if */ - else if(space->select.type->type == H5S_SEL_POINTS) { + else if (space->select.type->type == H5S_SEL_POINTS) { H5S_pnt_list_t *pnt_lst = space->select.sel_info.pnt_lst; - if(NULL != pnt_lst) - if(H5S__check_points_tail_ptr(pnt_lst) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") + if (NULL != pnt_lst) + if (H5S__check_points_tail_ptr(pnt_lst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the seletion has inconsistent tail pointers") } /* end else-if */ done: @@ -351,20 +351,20 @@ done: htri_t H5S__internal_consistency_test(hid_t space_id) { - H5S_t *space; /* Pointer to 1st dataspace */ - htri_t ret_value = TRUE; /* Return value */ + H5S_t *space; /* Pointer to 1st dataspace */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE - /* Get dataspace structures */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + /* Get dataspace structures */ + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Check if the dataspace selections are the same shape */ - if(FAIL == H5S__check_internal_consistency(space)) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "The dataspace has inconsistent internal state") + if (FAIL == H5S__check_internal_consistency(space)) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "The dataspace has inconsistent internal state") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__internal_consistency_test() */ - diff --git a/src/H5T.c b/src/H5T.c index 25c1f75..4202ced 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -22,33 +22,31 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ -#define H5T_ENCODE_VERSION 0 +#define H5T_ENCODE_VERSION 0 /* * Type initialization macros @@ -60,242 +58,277 @@ */ /* Define the code template for bitfields for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_BITFIELD_CORE { \ - dt->shared->type = H5T_BITFIELD; \ -} +#define H5T_INIT_TYPE_BITFIELD_CORE \ + { \ + dt->shared->type = H5T_BITFIELD; \ + } -#define H5T_INIT_TYPE_BITFIELD_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - H5T_INIT_TYPE_BITFIELD_CORE; \ -} +#define H5T_INIT_TYPE_BITFIELD_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + H5T_INIT_TYPE_BITFIELD_CORE; \ + } -#define H5T_INIT_TYPE_BITFIELDLE_CORE { \ - H5T_INIT_TYPE_BITFIELD_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_BITFIELDLE_CORE \ + { \ + H5T_INIT_TYPE_BITFIELD_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_BITFIELDBE_CORE { \ - H5T_INIT_TYPE_BITFIELD_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_BITFIELDBE_CORE \ + { \ + H5T_INIT_TYPE_BITFIELD_COMMON(H5T_ORDER_BE) \ + } /* Define the code template for times for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_TIME_CORE { \ - dt->shared->type = H5T_TIME; \ -} +#define H5T_INIT_TYPE_TIME_CORE \ + { \ + dt->shared->type = H5T_TIME; \ + } /* Define the code template for types which reset the offset for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_OFFSET_CORE { \ - dt->shared->u.atomic.offset = 0; \ -} +#define H5T_INIT_TYPE_OFFSET_CORE \ + { \ + dt->shared->u.atomic.offset = 0; \ + } /* Define common code for all numeric types (floating-point & int, signed & unsigned) */ -#define H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) { \ - dt->shared->u.atomic.order = ENDIANNESS; \ - dt->shared->u.atomic.offset = 0; \ - dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; \ - dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; \ -} +#define H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + { \ + dt->shared->u.atomic.order = ENDIANNESS; \ + dt->shared->u.atomic.offset = 0; \ + dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; \ + dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; \ + } /* Define the code templates for standard floats for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_FLOAT_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->shared->u.atomic.u.f.sign = 31; \ - dt->shared->u.atomic.u.f.epos = 23; \ - dt->shared->u.atomic.u.f.esize = 8; \ - dt->shared->u.atomic.u.f.ebias = 0x7f; \ - dt->shared->u.atomic.u.f.mpos = 0; \ - dt->shared->u.atomic.u.f.msize = 23; \ - dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ -} +#define H5T_INIT_TYPE_FLOAT_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.f.sign = 31; \ + dt->shared->u.atomic.u.f.epos = 23; \ + dt->shared->u.atomic.u.f.esize = 8; \ + dt->shared->u.atomic.u.f.ebias = 0x7f; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 23; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + } -#define H5T_INIT_TYPE_FLOATLE_CORE { \ - H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_FLOATLE_CORE \ + { \ + H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_FLOATBE_CORE { \ - H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_FLOATBE_CORE \ + { \ + H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_BE) \ + } /* Define the code templates for standard doubles for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_DOUBLE_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->shared->u.atomic.u.f.sign = 63; \ - dt->shared->u.atomic.u.f.epos = 52; \ - dt->shared->u.atomic.u.f.esize = 11; \ - dt->shared->u.atomic.u.f.ebias = 0x03ff; \ - dt->shared->u.atomic.u.f.mpos = 0; \ - dt->shared->u.atomic.u.f.msize = 52; \ - dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ -} +#define H5T_INIT_TYPE_DOUBLE_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.f.sign = 63; \ + dt->shared->u.atomic.u.f.epos = 52; \ + dt->shared->u.atomic.u.f.esize = 11; \ + dt->shared->u.atomic.u.f.ebias = 0x03ff; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 52; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + } -#define H5T_INIT_TYPE_DOUBLELE_CORE { \ - H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_DOUBLELE_CORE \ + { \ + H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_DOUBLEBE_CORE { \ - H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_DOUBLEBE_CORE \ + { \ + H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_BE) \ + } /* Define the code templates for VAX float for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_FLOATVAX_CORE { \ - H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ - dt->shared->u.atomic.u.f.sign = 31; \ - dt->shared->u.atomic.u.f.epos = 23; \ - dt->shared->u.atomic.u.f.esize = 8; \ - dt->shared->u.atomic.u.f.ebias = 0x81; \ - dt->shared->u.atomic.u.f.mpos = 0; \ - dt->shared->u.atomic.u.f.msize = 23; \ - dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ - dt->shared->version = H5O_DTYPE_VERSION_3; \ -} +#define H5T_INIT_TYPE_FLOATVAX_CORE \ + { \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ + dt->shared->u.atomic.u.f.sign = 31; \ + dt->shared->u.atomic.u.f.epos = 23; \ + dt->shared->u.atomic.u.f.esize = 8; \ + dt->shared->u.atomic.u.f.ebias = 0x81; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 23; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + dt->shared->version = H5O_DTYPE_VERSION_3; \ + } /* Define the code templates for VAX double for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_DOUBLEVAX_CORE { \ - H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ - dt->shared->u.atomic.u.f.sign = 63; \ - dt->shared->u.atomic.u.f.epos = 52; \ - dt->shared->u.atomic.u.f.esize = 11; \ - dt->shared->u.atomic.u.f.ebias = 0x0401; \ - dt->shared->u.atomic.u.f.mpos = 0; \ - dt->shared->u.atomic.u.f.msize = 52; \ - dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ - dt->shared->version = H5O_DTYPE_VERSION_3; \ -} +#define H5T_INIT_TYPE_DOUBLEVAX_CORE \ + { \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ + dt->shared->u.atomic.u.f.sign = 63; \ + dt->shared->u.atomic.u.f.epos = 52; \ + dt->shared->u.atomic.u.f.esize = 11; \ + dt->shared->u.atomic.u.f.ebias = 0x0401; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 52; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + dt->shared->version = H5O_DTYPE_VERSION_3; \ + } /* Define the code templates for standard signed integers for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_SINT_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->shared->u.atomic.u.i.sign = H5T_SGN_2; \ -} +#define H5T_INIT_TYPE_SINT_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.i.sign = H5T_SGN_2; \ + } -#define H5T_INIT_TYPE_SINTLE_CORE { \ - H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_SINTLE_CORE \ + { \ + H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_SINTBE_CORE { \ - H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_SINTBE_CORE \ + { \ + H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_BE) \ + } /* Define the code templates for standard unsigned integers for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_UINT_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->shared->u.atomic.u.i.sign = H5T_SGN_NONE; \ -} +#define H5T_INIT_TYPE_UINT_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.i.sign = H5T_SGN_NONE; \ + } -#define H5T_INIT_TYPE_UINTLE_CORE { \ - H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_UINTLE_CORE \ + { \ + H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_UINTBE_CORE { \ - H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_UINTBE_CORE \ + { \ + H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_BE) \ + } /* Define a macro for common code for all newly allocate datatypes */ -#define H5T_INIT_TYPE_ALLOC_COMMON(TYPE) { \ - dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; \ - dt->shared->type = TYPE; \ -} +#define H5T_INIT_TYPE_ALLOC_COMMON(TYPE) \ + { \ + dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; \ + dt->shared->type = TYPE; \ + } /* Define the code templates for opaque for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_OPAQ_CORE { \ - H5T_INIT_TYPE_ALLOC_COMMON(H5T_OPAQUE) \ - dt->shared->u.opaque.tag = H5MM_xstrdup(""); \ -} +#define H5T_INIT_TYPE_OPAQ_CORE \ + { \ + H5T_INIT_TYPE_ALLOC_COMMON(H5T_OPAQUE) \ + dt->shared->u.opaque.tag = H5MM_xstrdup(""); \ + } /* Define the code templates for strings for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_STRING_COMMON { \ - H5T_INIT_TYPE_ALLOC_COMMON(H5T_STRING) \ - H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ - dt->shared->u.atomic.u.s.cset = H5F_DEFAULT_CSET; \ -} +#define H5T_INIT_TYPE_STRING_COMMON \ + { \ + H5T_INIT_TYPE_ALLOC_COMMON(H5T_STRING) \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ + dt->shared->u.atomic.u.s.cset = H5F_DEFAULT_CSET; \ + } -#define H5T_INIT_TYPE_CSTRING_CORE { \ - H5T_INIT_TYPE_STRING_COMMON \ - dt->shared->u.atomic.u.s.pad = H5T_STR_NULLTERM; \ -} +#define H5T_INIT_TYPE_CSTRING_CORE \ + { \ + H5T_INIT_TYPE_STRING_COMMON \ + dt->shared->u.atomic.u.s.pad = H5T_STR_NULLTERM; \ + } -#define H5T_INIT_TYPE_FORSTRING_CORE { \ - H5T_INIT_TYPE_STRING_COMMON \ - dt->shared->u.atomic.u.s.pad = H5T_STR_SPACEPAD; \ -} +#define H5T_INIT_TYPE_FORSTRING_CORE \ + { \ + H5T_INIT_TYPE_STRING_COMMON \ + dt->shared->u.atomic.u.s.pad = H5T_STR_SPACEPAD; \ + } /* Define the code templates for references for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_REF_COMMON { \ - H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \ - H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ - dt->shared->force_conv = TRUE; \ - dt->shared->u.atomic.u.r.file = NULL; \ - dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; \ - dt->shared->u.atomic.u.r.cls = NULL; \ -} +#define H5T_INIT_TYPE_REF_COMMON \ + { \ + H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ + dt->shared->force_conv = TRUE; \ + dt->shared->u.atomic.u.r.file = NULL; \ + dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; \ + dt->shared->u.atomic.u.r.cls = NULL; \ + } -#define H5T_INIT_TYPE_OBJREF_CORE { \ - H5T_INIT_TYPE_REF_COMMON \ - dt->shared->u.atomic.u.r.rtype = H5R_OBJECT1; \ - dt->shared->u.atomic.u.r.opaque = FALSE; \ - dt->shared->u.atomic.u.r.version = 0; \ -} +#define H5T_INIT_TYPE_OBJREF_CORE \ + { \ + H5T_INIT_TYPE_REF_COMMON \ + dt->shared->u.atomic.u.r.rtype = H5R_OBJECT1; \ + dt->shared->u.atomic.u.r.opaque = FALSE; \ + dt->shared->u.atomic.u.r.version = 0; \ + } -#define H5T_INIT_TYPE_REGREF_CORE { \ - H5T_INIT_TYPE_REF_COMMON \ - dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION1; \ - dt->shared->u.atomic.u.r.opaque = FALSE; \ - dt->shared->u.atomic.u.r.version = 0; \ -} +#define H5T_INIT_TYPE_REGREF_CORE \ + { \ + H5T_INIT_TYPE_REF_COMMON \ + dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION1; \ + dt->shared->u.atomic.u.r.opaque = FALSE; \ + dt->shared->u.atomic.u.r.version = 0; \ + } /* rtype value is only used as a placeholder to differentiate the type from * other types, any opaque (i.e. "new") reference type could be used. */ -#define H5T_INIT_TYPE_REF_CORE { \ - H5T_INIT_TYPE_REF_COMMON \ - dt->shared->u.atomic.u.r.rtype = H5R_OBJECT2; \ - dt->shared->u.atomic.u.r.opaque = TRUE; \ - dt->shared->u.atomic.u.r.version = H5R_ENCODE_VERSION; \ - dt->shared->version = H5O_DTYPE_VERSION_4; \ -} +#define H5T_INIT_TYPE_REF_CORE \ + { \ + H5T_INIT_TYPE_REF_COMMON \ + dt->shared->u.atomic.u.r.rtype = H5R_OBJECT2; \ + dt->shared->u.atomic.u.r.opaque = TRUE; \ + dt->shared->u.atomic.u.r.version = H5R_ENCODE_VERSION; \ + dt->shared->version = H5O_DTYPE_VERSION_4; \ + } /* Define the code templates for the "SIZE_TMPL" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_SET_SIZE(SIZE) { \ - dt->shared->size = SIZE; \ - dt->shared->u.atomic.prec = 8 * SIZE; \ -} +#define H5T_INIT_TYPE_SET_SIZE(SIZE) \ + { \ + dt->shared->size = SIZE; \ + dt->shared->u.atomic.prec = 8 * SIZE; \ + } -#define H5T_INIT_TYPE_NOSET_SIZE(SIZE) { \ -} +#define H5T_INIT_TYPE_NOSET_SIZE(SIZE) \ + { \ + } /* Define the code templates for the "CRT_TMPL" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_COPY_CREATE(BASE) { \ - /* Base off of existing datatype */ \ - if(NULL == (dt = H5T_copy(BASE, H5T_COPY_TRANSIENT))) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "duplicating base type failed") \ -} - -#define H5T_INIT_TYPE_ALLOC_CREATE(BASE) { \ - /* Allocate new datatype info */ \ - if(NULL == (dt = H5T__alloc())) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") \ -} - +#define H5T_INIT_TYPE_COPY_CREATE(BASE) \ + { \ + /* Base off of existing datatype */ \ + if (NULL == (dt = H5T_copy(BASE, H5T_COPY_TRANSIENT))) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "duplicating base type failed") \ + } -#define H5T_INIT_TYPE(GUTS,GLOBAL,CRT_TMPL,BASE,SIZE_TMPL,SIZE) { \ - /* Get new datatype struct */ \ - H5_GLUE3(H5T_INIT_TYPE_,CRT_TMPL,_CREATE)(BASE) \ - \ - /* Adjust information for all types */ \ - dt->shared->state = H5T_STATE_IMMUTABLE; \ - H5_GLUE3(H5T_INIT_TYPE_,SIZE_TMPL,_SIZE)(SIZE) \ - \ - /* Adjust information for this type */ \ - H5_GLUE3(H5T_INIT_TYPE_, GUTS, _CORE) \ - \ - /* Atomize result */ \ - if((GLOBAL = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom") \ -} +#define H5T_INIT_TYPE_ALLOC_CREATE(BASE) \ + { \ + /* Allocate new datatype info */ \ + if (NULL == (dt = H5T__alloc())) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") \ + } +#define H5T_INIT_TYPE(GUTS, GLOBAL, CRT_TMPL, BASE, SIZE_TMPL, SIZE) \ + { \ + /* Get new datatype struct */ \ + H5_GLUE3(H5T_INIT_TYPE_, CRT_TMPL, _CREATE) \ + (BASE) \ + \ + /* Adjust information for all types */ \ + dt->shared->state = H5T_STATE_IMMUTABLE; \ + H5_GLUE3(H5T_INIT_TYPE_, SIZE_TMPL, _SIZE) \ + (SIZE) \ + \ + /* Adjust information for this type */ \ + H5_GLUE3(H5T_INIT_TYPE_, GUTS, _CORE) \ + \ + /* Atomize result */ \ + if ((GLOBAL = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom") \ + } /******************/ /* Local Typedefs */ @@ -304,24 +337,24 @@ /* Typedef for recursive const-correct datatype copying routines */ typedef H5T_t *(*H5T_copy_func_t)(H5T_t *old_dt); - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_lib_conv_t func); +static herr_t H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, + H5T_lib_conv_t func); static herr_t H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_func_t *conv); static herr_t H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func); static htri_t H5T__compiler_conv(H5T_t *src, H5T_t *dst); static herr_t H5T__set_size(H5T_t *dt, size_t size); static herr_t H5T__close_cb(H5T_t *dt); -static H5T_path_t *H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_func_t *conv); -static hbool_t H5T__detect_vlen_ref(const H5T_t *dt); -static H5T_t *H5T__initiate_copy(const H5T_t *old_dt); -static H5T_t *H5T__copy_transient(H5T_t *old_dt); -static H5T_t *H5T__copy_all(H5T_t *old_dt); -static herr_t H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, - H5T_shared_t *reopened_fo, hbool_t set_memory_type, H5T_copy_func_t copyfn); - +static H5T_path_t *H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, + H5T_conv_func_t *conv); +static hbool_t H5T__detect_vlen_ref(const H5T_t *dt); +static H5T_t * H5T__initiate_copy(const H5T_t *old_dt); +static H5T_t * H5T__copy_transient(H5T_t *old_dt); +static H5T_t * H5T__copy_all(H5T_t *old_dt); +static herr_t H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo, + hbool_t set_memory_type, H5T_copy_func_t copyfn); /*****************************/ /* Library Private Variables */ @@ -330,7 +363,6 @@ static herr_t H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, /* The native endianness of the platform */ H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR; - /*********************/ /* Package Variables */ /*********************/ @@ -345,83 +377,83 @@ hbool_t H5_PKG_INIT_VAR = FALSE; * If more of these are added, the new ones must be added to the list of * types to reset in H5T_term_package(). */ -hid_t H5T_IEEE_F32BE_g = FAIL; -hid_t H5T_IEEE_F32LE_g = FAIL; -hid_t H5T_IEEE_F64BE_g = FAIL; -hid_t H5T_IEEE_F64LE_g = FAIL; - -hid_t H5T_VAX_F32_g = FAIL; -hid_t H5T_VAX_F64_g = FAIL; - -hid_t H5T_STD_I8BE_g = FAIL; -hid_t H5T_STD_I8LE_g = FAIL; -hid_t H5T_STD_I16BE_g = FAIL; -hid_t H5T_STD_I16LE_g = FAIL; -hid_t H5T_STD_I32BE_g = FAIL; -hid_t H5T_STD_I32LE_g = FAIL; -hid_t H5T_STD_I64BE_g = FAIL; -hid_t H5T_STD_I64LE_g = FAIL; -hid_t H5T_STD_U8BE_g = FAIL; -hid_t H5T_STD_U8LE_g = FAIL; -hid_t H5T_STD_U16BE_g = FAIL; -hid_t H5T_STD_U16LE_g = FAIL; -hid_t H5T_STD_U32BE_g = FAIL; -hid_t H5T_STD_U32LE_g = FAIL; -hid_t H5T_STD_U64BE_g = FAIL; -hid_t H5T_STD_U64LE_g = FAIL; -hid_t H5T_STD_B8BE_g = FAIL; -hid_t H5T_STD_B8LE_g = FAIL; -hid_t H5T_STD_B16BE_g = FAIL; -hid_t H5T_STD_B16LE_g = FAIL; -hid_t H5T_STD_B32BE_g = FAIL; -hid_t H5T_STD_B32LE_g = FAIL; -hid_t H5T_STD_B64BE_g = FAIL; -hid_t H5T_STD_B64LE_g = FAIL; -hid_t H5T_STD_REF_OBJ_g = FAIL; -hid_t H5T_STD_REF_DSETREG_g = FAIL; -hid_t H5T_STD_REF_g = FAIL; - -hid_t H5T_UNIX_D32BE_g = FAIL; -hid_t H5T_UNIX_D32LE_g = FAIL; -hid_t H5T_UNIX_D64BE_g = FAIL; -hid_t H5T_UNIX_D64LE_g = FAIL; - -hid_t H5T_C_S1_g = FAIL; - -hid_t H5T_FORTRAN_S1_g = FAIL; - -hid_t H5T_NATIVE_SCHAR_g = FAIL; -hid_t H5T_NATIVE_UCHAR_g = FAIL; -hid_t H5T_NATIVE_SHORT_g = FAIL; -hid_t H5T_NATIVE_USHORT_g = FAIL; -hid_t H5T_NATIVE_INT_g = FAIL; -hid_t H5T_NATIVE_UINT_g = FAIL; -hid_t H5T_NATIVE_LONG_g = FAIL; -hid_t H5T_NATIVE_ULONG_g = FAIL; -hid_t H5T_NATIVE_LLONG_g = FAIL; -hid_t H5T_NATIVE_ULLONG_g = FAIL; -hid_t H5T_NATIVE_FLOAT_g = FAIL; -hid_t H5T_NATIVE_DOUBLE_g = FAIL; -#if H5_SIZEOF_LONG_DOUBLE !=0 -hid_t H5T_NATIVE_LDOUBLE_g = FAIL; +hid_t H5T_IEEE_F32BE_g = FAIL; +hid_t H5T_IEEE_F32LE_g = FAIL; +hid_t H5T_IEEE_F64BE_g = FAIL; +hid_t H5T_IEEE_F64LE_g = FAIL; + +hid_t H5T_VAX_F32_g = FAIL; +hid_t H5T_VAX_F64_g = FAIL; + +hid_t H5T_STD_I8BE_g = FAIL; +hid_t H5T_STD_I8LE_g = FAIL; +hid_t H5T_STD_I16BE_g = FAIL; +hid_t H5T_STD_I16LE_g = FAIL; +hid_t H5T_STD_I32BE_g = FAIL; +hid_t H5T_STD_I32LE_g = FAIL; +hid_t H5T_STD_I64BE_g = FAIL; +hid_t H5T_STD_I64LE_g = FAIL; +hid_t H5T_STD_U8BE_g = FAIL; +hid_t H5T_STD_U8LE_g = FAIL; +hid_t H5T_STD_U16BE_g = FAIL; +hid_t H5T_STD_U16LE_g = FAIL; +hid_t H5T_STD_U32BE_g = FAIL; +hid_t H5T_STD_U32LE_g = FAIL; +hid_t H5T_STD_U64BE_g = FAIL; +hid_t H5T_STD_U64LE_g = FAIL; +hid_t H5T_STD_B8BE_g = FAIL; +hid_t H5T_STD_B8LE_g = FAIL; +hid_t H5T_STD_B16BE_g = FAIL; +hid_t H5T_STD_B16LE_g = FAIL; +hid_t H5T_STD_B32BE_g = FAIL; +hid_t H5T_STD_B32LE_g = FAIL; +hid_t H5T_STD_B64BE_g = FAIL; +hid_t H5T_STD_B64LE_g = FAIL; +hid_t H5T_STD_REF_OBJ_g = FAIL; +hid_t H5T_STD_REF_DSETREG_g = FAIL; +hid_t H5T_STD_REF_g = FAIL; + +hid_t H5T_UNIX_D32BE_g = FAIL; +hid_t H5T_UNIX_D32LE_g = FAIL; +hid_t H5T_UNIX_D64BE_g = FAIL; +hid_t H5T_UNIX_D64LE_g = FAIL; + +hid_t H5T_C_S1_g = FAIL; + +hid_t H5T_FORTRAN_S1_g = FAIL; + +hid_t H5T_NATIVE_SCHAR_g = FAIL; +hid_t H5T_NATIVE_UCHAR_g = FAIL; +hid_t H5T_NATIVE_SHORT_g = FAIL; +hid_t H5T_NATIVE_USHORT_g = FAIL; +hid_t H5T_NATIVE_INT_g = FAIL; +hid_t H5T_NATIVE_UINT_g = FAIL; +hid_t H5T_NATIVE_LONG_g = FAIL; +hid_t H5T_NATIVE_ULONG_g = FAIL; +hid_t H5T_NATIVE_LLONG_g = FAIL; +hid_t H5T_NATIVE_ULLONG_g = FAIL; +hid_t H5T_NATIVE_FLOAT_g = FAIL; +hid_t H5T_NATIVE_DOUBLE_g = FAIL; +#if H5_SIZEOF_LONG_DOUBLE != 0 +hid_t H5T_NATIVE_LDOUBLE_g = FAIL; #endif -hid_t H5T_NATIVE_B8_g = FAIL; -hid_t H5T_NATIVE_B16_g = FAIL; -hid_t H5T_NATIVE_B32_g = FAIL; -hid_t H5T_NATIVE_B64_g = FAIL; -hid_t H5T_NATIVE_OPAQUE_g = FAIL; -hid_t H5T_NATIVE_HADDR_g = FAIL; -hid_t H5T_NATIVE_HSIZE_g = FAIL; -hid_t H5T_NATIVE_HSSIZE_g = FAIL; -hid_t H5T_NATIVE_HERR_g = FAIL; -hid_t H5T_NATIVE_HBOOL_g = FAIL; - -hid_t H5T_NATIVE_INT8_g = FAIL; -hid_t H5T_NATIVE_UINT8_g = FAIL; -hid_t H5T_NATIVE_INT_LEAST8_g = FAIL; -hid_t H5T_NATIVE_UINT_LEAST8_g = FAIL; -hid_t H5T_NATIVE_INT_FAST8_g = FAIL; -hid_t H5T_NATIVE_UINT_FAST8_g = FAIL; +hid_t H5T_NATIVE_B8_g = FAIL; +hid_t H5T_NATIVE_B16_g = FAIL; +hid_t H5T_NATIVE_B32_g = FAIL; +hid_t H5T_NATIVE_B64_g = FAIL; +hid_t H5T_NATIVE_OPAQUE_g = FAIL; +hid_t H5T_NATIVE_HADDR_g = FAIL; +hid_t H5T_NATIVE_HSIZE_g = FAIL; +hid_t H5T_NATIVE_HSSIZE_g = FAIL; +hid_t H5T_NATIVE_HERR_g = FAIL; +hid_t H5T_NATIVE_HBOOL_g = FAIL; + +hid_t H5T_NATIVE_INT8_g = FAIL; +hid_t H5T_NATIVE_UINT8_g = FAIL; +hid_t H5T_NATIVE_INT_LEAST8_g = FAIL; +hid_t H5T_NATIVE_UINT_LEAST8_g = FAIL; +hid_t H5T_NATIVE_INT_FAST8_g = FAIL; +hid_t H5T_NATIVE_UINT_FAST8_g = FAIL; hid_t H5T_NATIVE_INT16_g = FAIL; hid_t H5T_NATIVE_UINT16_g = FAIL; @@ -450,46 +482,46 @@ hid_t H5T_NATIVE_UINT_FAST64_g = FAIL; * datatype or C structures, which are different from the alignments for memory * address below this group of variables. */ -size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_UCHAR_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_SHORT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_USHORT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_INT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_LONG_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_ULONG_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_LLONG_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_ULLONG_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g = 0; -#if H5_SIZEOF_LONG_DOUBLE !=0 -size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_UCHAR_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_SHORT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_USHORT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_INT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_LONG_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_ULONG_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_LLONG_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_ULLONG_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g = 0; +#if H5_SIZEOF_LONG_DOUBLE != 0 +size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g = 0; #endif -size_t H5T_POINTER_COMP_ALIGN_g = 0; -size_t H5T_HVL_COMP_ALIGN_g = 0; -size_t H5T_HOBJREF_COMP_ALIGN_g = 0; -size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0; -size_t H5T_REF_COMP_ALIGN_g = 0; +size_t H5T_POINTER_COMP_ALIGN_g = 0; +size_t H5T_HVL_COMP_ALIGN_g = 0; +size_t H5T_HOBJREF_COMP_ALIGN_g = 0; +size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0; +size_t H5T_REF_COMP_ALIGN_g = 0; /* * Alignment constraints for native types. These are initialized at run time * in H5Tinit.c */ -size_t H5T_NATIVE_SCHAR_ALIGN_g = 0; -size_t H5T_NATIVE_UCHAR_ALIGN_g = 0; -size_t H5T_NATIVE_SHORT_ALIGN_g = 0; -size_t H5T_NATIVE_USHORT_ALIGN_g = 0; -size_t H5T_NATIVE_INT_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_ALIGN_g = 0; -size_t H5T_NATIVE_LONG_ALIGN_g = 0; -size_t H5T_NATIVE_ULONG_ALIGN_g = 0; -size_t H5T_NATIVE_LLONG_ALIGN_g = 0; -size_t H5T_NATIVE_ULLONG_ALIGN_g = 0; -size_t H5T_NATIVE_FLOAT_ALIGN_g = 0; -size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0; -#if H5_SIZEOF_LONG_DOUBLE !=0 -size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; +size_t H5T_NATIVE_SCHAR_ALIGN_g = 0; +size_t H5T_NATIVE_UCHAR_ALIGN_g = 0; +size_t H5T_NATIVE_SHORT_ALIGN_g = 0; +size_t H5T_NATIVE_USHORT_ALIGN_g = 0; +size_t H5T_NATIVE_INT_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_ALIGN_g = 0; +size_t H5T_NATIVE_LONG_ALIGN_g = 0; +size_t H5T_NATIVE_ULONG_ALIGN_g = 0; +size_t H5T_NATIVE_LLONG_ALIGN_g = 0; +size_t H5T_NATIVE_ULLONG_ALIGN_g = 0; +size_t H5T_NATIVE_FLOAT_ALIGN_g = 0; +size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0; +#if H5_SIZEOF_LONG_DOUBLE != 0 +size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; #endif /* @@ -497,40 +529,40 @@ size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; * H5Tinit.c if the types are provided by the system. Otherwise we set their * values to 0 here (no alignment calculated). */ -size_t H5T_NATIVE_INT8_ALIGN_g = 0; -size_t H5T_NATIVE_UINT8_ALIGN_g = 0; -size_t H5T_NATIVE_INT_LEAST8_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g = 0; -size_t H5T_NATIVE_INT_FAST8_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_FAST8_ALIGN_g = 0; - -size_t H5T_NATIVE_INT16_ALIGN_g = 0; -size_t H5T_NATIVE_UINT16_ALIGN_g = 0; -size_t H5T_NATIVE_INT_LEAST16_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g = 0; -size_t H5T_NATIVE_INT_FAST16_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_FAST16_ALIGN_g = 0; - -size_t H5T_NATIVE_INT32_ALIGN_g = 0; -size_t H5T_NATIVE_UINT32_ALIGN_g = 0; -size_t H5T_NATIVE_INT_LEAST32_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g = 0; -size_t H5T_NATIVE_INT_FAST32_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_FAST32_ALIGN_g = 0; - -size_t H5T_NATIVE_INT64_ALIGN_g = 0; -size_t H5T_NATIVE_UINT64_ALIGN_g = 0; -size_t H5T_NATIVE_INT_LEAST64_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g = 0; -size_t H5T_NATIVE_INT_FAST64_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0; +size_t H5T_NATIVE_INT8_ALIGN_g = 0; +size_t H5T_NATIVE_UINT8_ALIGN_g = 0; +size_t H5T_NATIVE_INT_LEAST8_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g = 0; +size_t H5T_NATIVE_INT_FAST8_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_FAST8_ALIGN_g = 0; + +size_t H5T_NATIVE_INT16_ALIGN_g = 0; +size_t H5T_NATIVE_UINT16_ALIGN_g = 0; +size_t H5T_NATIVE_INT_LEAST16_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g = 0; +size_t H5T_NATIVE_INT_FAST16_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_FAST16_ALIGN_g = 0; + +size_t H5T_NATIVE_INT32_ALIGN_g = 0; +size_t H5T_NATIVE_UINT32_ALIGN_g = 0; +size_t H5T_NATIVE_INT_LEAST32_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g = 0; +size_t H5T_NATIVE_INT_FAST32_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_FAST32_ALIGN_g = 0; + +size_t H5T_NATIVE_INT64_ALIGN_g = 0; +size_t H5T_NATIVE_UINT64_ALIGN_g = 0; +size_t H5T_NATIVE_INT_LEAST64_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g = 0; +size_t H5T_NATIVE_INT_FAST64_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ -float H5T_NATIVE_FLOAT_POS_INF_g = 0.0f; -float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0f; -double H5T_NATIVE_DOUBLE_POS_INF_g = (double)0.0f; -double H5T_NATIVE_DOUBLE_NEG_INF_g = (double)0.0f; +float H5T_NATIVE_FLOAT_POS_INF_g = 0.0f; +float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0f; +double H5T_NATIVE_DOUBLE_POS_INF_g = (double)0.0f; +double H5T_NATIVE_DOUBLE_NEG_INF_g = (double)0.0f; /* Declare the free list for H5T_t's and H5T_shared_t's */ H5FL_DEFINE(H5T_t); @@ -538,11 +570,11 @@ H5FL_DEFINE(H5T_shared_t); /* Format version bounds for datatype */ const unsigned H5O_dtype_ver_bounds[] = { - H5O_DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V18 */ - H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V110 */ - H5O_DTYPE_VERSION_4, /* H5F_LIBVER_V112 */ - H5O_DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V110 */ + H5O_DTYPE_VERSION_4, /* H5F_LIBVER_V112 */ + H5O_DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /*******************/ @@ -554,12 +586,12 @@ const unsigned H5O_dtype_ver_bounds[] = { * which is used as the key by which the `entries' array is sorted. */ static struct { - int npaths; /*number of paths defined */ - size_t apaths; /*number of paths allocated */ - H5T_path_t **path; /*sorted array of path pointers */ - int nsoft; /*number of soft conversions defined */ - size_t asoft; /*number of soft conversions allocated */ - H5T_soft_t *soft; /*unsorted array of soft conversions */ + int npaths; /*number of paths defined */ + size_t apaths; /*number of paths allocated */ + H5T_path_t **path; /*sorted array of path pointers */ + int nsoft; /*number of soft conversions defined */ + size_t asoft; /*number of soft conversions allocated */ + H5T_soft_t * soft; /*unsorted array of soft conversions */ } H5T_g; /* Declare the free list for H5T_path_t's */ @@ -567,18 +599,15 @@ H5FL_DEFINE_STATIC(H5T_path_t); /* Datatype ID class */ static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ - H5I_DATATYPE, /* ID class value */ - 0, /* Class flags */ - 8, /* # of reserved IDs for class */ - (H5I_free_t)H5T__close_cb /* Callback routine for closing objects of this class */ + H5I_DATATYPE, /* ID class value */ + 0, /* Class flags */ + 8, /* # of reserved IDs for class */ + (H5I_free_t)H5T__close_cb /* Callback routine for closing objects of this class */ }}; - /* Flag indicating "top" of interface has been initialized */ static hbool_t H5T_top_package_initialize_s = FALSE; - - /*------------------------------------------------------------------------- * Function: H5T_init * @@ -595,7 +624,7 @@ static hbool_t H5T_top_package_initialize_s = FALSE; herr_t H5T_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -604,7 +633,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_init() */ - /*------------------------------------------------------------------------- * Function: H5T__init_inf * @@ -622,22 +650,22 @@ done: static herr_t H5T__init_inf(void) { - H5T_t *dst_p; /* Datatype type operate on */ - H5T_atomic_t *dst; /* Datatype's atomic info */ - uint8_t *d; /* Pointer to value to set */ - size_t half_size; /* Half the type size */ - size_t u; /* Local index value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * dst_p; /* Datatype type operate on */ + H5T_atomic_t *dst; /* Datatype's atomic info */ + uint8_t * d; /* Pointer to value to set */ + size_t half_size; /* Half the type size */ + size_t u; /* Local index value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get the float datatype */ - if(NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) + if (NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") dst = &dst_p->shared->u.atomic; /* Check that we can re-order the bytes correctly */ - if(H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) + if (H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") /* +Inf */ @@ -649,12 +677,12 @@ H5T__init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE == H5T_native_order_g) { half_size = dst_p->shared->size / 2; - for(u = 0; u < half_size; u++) { - uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; d[dst_p->shared->size - (u + 1)] = d[u]; - d[u] = tmp; + d[u] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* -Inf */ d = (uint8_t *)&H5T_NATIVE_FLOAT_NEG_INF_g; @@ -663,22 +691,22 @@ H5T__init_inf(void) H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ - if(H5T_ORDER_BE == H5T_native_order_g) { + if (H5T_ORDER_BE == H5T_native_order_g) { half_size = dst_p->shared->size / 2; - for(u = 0; u < half_size; u++) { - uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; d[dst_p->shared->size - (u + 1)] = d[u]; - d[u] = tmp; + d[u] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* Get the double datatype */ - if(NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) + if (NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") dst = &dst_p->shared->u.atomic; /* Check that we can re-order the bytes correctly */ - if(H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) + if (H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") /* +Inf */ @@ -688,14 +716,14 @@ H5T__init_inf(void) H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ - if(H5T_ORDER_BE == H5T_native_order_g) { + if (H5T_ORDER_BE == H5T_native_order_g) { half_size = dst_p->shared->size / 2; - for(u = 0; u < half_size; u++) { - uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; d[dst_p->shared->size - (u + 1)] = d[u]; - d[u] = tmp; + d[u] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* -Inf */ d = (uint8_t *)&H5T_NATIVE_DOUBLE_NEG_INF_g; @@ -704,20 +732,19 @@ H5T__init_inf(void) H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ - if(H5T_ORDER_BE == H5T_native_order_g) { + if (H5T_ORDER_BE == H5T_native_order_g) { half_size = dst_p->shared->size / 2; - for(u = 0; u < half_size; u++) { - uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; d[dst_p->shared->size - (u + 1)] = d[u]; - d[u] = tmp; + d[u] = tmp; } /* end for */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__init_inf() */ - /*-------------------------------------------------------------------------- NAME H5T__init_package -- Initialize interface-specific information @@ -732,50 +759,51 @@ DESCRIPTION herr_t H5T__init_package(void) { - H5T_t *native_schar=NULL; /* Datatype structure for native signed char */ - H5T_t *native_uchar=NULL; /* Datatype structure for native unsigned char */ - H5T_t *native_short=NULL; /* Datatype structure for native short */ - H5T_t *native_ushort=NULL; /* Datatype structure for native unsigned short */ - H5T_t *native_int=NULL; /* Datatype structure for native int */ - H5T_t *native_uint=NULL; /* Datatype structure for native unsigned int */ - H5T_t *native_long=NULL; /* Datatype structure for native long */ - H5T_t *native_ulong=NULL; /* Datatype structure for native unsigned long */ - H5T_t *native_llong=NULL; /* Datatype structure for native long long */ - H5T_t *native_ullong=NULL; /* Datatype structure for native unsigned long long */ - H5T_t *native_float=NULL; /* Datatype structure for native float */ - H5T_t *native_double=NULL; /* Datatype structure for native double */ -#if H5_SIZEOF_LONG_DOUBLE !=0 - H5T_t *native_ldouble=NULL; /* Datatype structure for native long double */ + H5T_t *native_schar = NULL; /* Datatype structure for native signed char */ + H5T_t *native_uchar = NULL; /* Datatype structure for native unsigned char */ + H5T_t *native_short = NULL; /* Datatype structure for native short */ + H5T_t *native_ushort = NULL; /* Datatype structure for native unsigned short */ + H5T_t *native_int = NULL; /* Datatype structure for native int */ + H5T_t *native_uint = NULL; /* Datatype structure for native unsigned int */ + H5T_t *native_long = NULL; /* Datatype structure for native long */ + H5T_t *native_ulong = NULL; /* Datatype structure for native unsigned long */ + H5T_t *native_llong = NULL; /* Datatype structure for native long long */ + H5T_t *native_ullong = NULL; /* Datatype structure for native unsigned long long */ + H5T_t *native_float = NULL; /* Datatype structure for native float */ + H5T_t *native_double = NULL; /* Datatype structure for native double */ +#if H5_SIZEOF_LONG_DOUBLE != 0 + H5T_t *native_ldouble = NULL; /* Datatype structure for native long double */ #endif - H5T_t *std_u8le=NULL; /* Datatype structure for unsigned 8-bit little-endian integer */ - H5T_t *std_u8be=NULL; /* Datatype structure for unsigned 8-bit big-endian integer */ - H5T_t *std_u16le=NULL; /* Datatype structure for unsigned 16-bit little-endian integer */ - H5T_t *std_u16be=NULL; /* Datatype structure for unsigned 16-bit big-endian integer */ - H5T_t *std_u32le=NULL; /* Datatype structure for unsigned 32-bit little-endian integer */ - H5T_t *std_u32be=NULL; /* Datatype structure for unsigned 32-bit big-endian integer */ - H5T_t *std_u64le=NULL; /* Datatype structure for unsigned 64-bit little-endian integer */ - H5T_t *std_u64be=NULL; /* Datatype structure for unsigned 64-bit big-endian integer */ - H5T_t *dt = NULL; - H5T_t *fixedpt=NULL; /* Datatype structure for native int */ - H5T_t *floatpt=NULL; /* Datatype structure for native float */ - H5T_t *string=NULL; /* Datatype structure for C string */ - H5T_t *bitfield=NULL; /* Datatype structure for bitfield */ - H5T_t *compound=NULL; /* Datatype structure for compound objects */ - H5T_t *enum_type=NULL; /* Datatype structure for enum objects */ - H5T_t *vlen=NULL; /* Datatype structure for vlen objects */ - H5T_t *array=NULL; /* Datatype structure for array objects */ - H5T_t *objref=NULL; /* Datatype structure for deprecated reference objects */ - H5T_t *regref=NULL; /* Datatype structure for deprecated region references */ - H5T_t *ref=NULL; /* Datatype structure for opaque references */ - hsize_t dim[1]={1}; /* Dimension info for array datatype */ - herr_t status; - hbool_t copied_dtype = TRUE; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * std_u8le = NULL; /* Datatype structure for unsigned 8-bit little-endian integer */ + H5T_t * std_u8be = NULL; /* Datatype structure for unsigned 8-bit big-endian integer */ + H5T_t * std_u16le = NULL; /* Datatype structure for unsigned 16-bit little-endian integer */ + H5T_t * std_u16be = NULL; /* Datatype structure for unsigned 16-bit big-endian integer */ + H5T_t * std_u32le = NULL; /* Datatype structure for unsigned 32-bit little-endian integer */ + H5T_t * std_u32be = NULL; /* Datatype structure for unsigned 32-bit big-endian integer */ + H5T_t * std_u64le = NULL; /* Datatype structure for unsigned 64-bit little-endian integer */ + H5T_t * std_u64be = NULL; /* Datatype structure for unsigned 64-bit big-endian integer */ + H5T_t * dt = NULL; + H5T_t * fixedpt = NULL; /* Datatype structure for native int */ + H5T_t * floatpt = NULL; /* Datatype structure for native float */ + H5T_t * string = NULL; /* Datatype structure for C string */ + H5T_t * bitfield = NULL; /* Datatype structure for bitfield */ + H5T_t * compound = NULL; /* Datatype structure for compound objects */ + H5T_t * enum_type = NULL; /* Datatype structure for enum objects */ + H5T_t * vlen = NULL; /* Datatype structure for vlen objects */ + H5T_t * array = NULL; /* Datatype structure for array objects */ + H5T_t * objref = NULL; /* Datatype structure for deprecated reference objects */ + H5T_t * regref = NULL; /* Datatype structure for deprecated region references */ + H5T_t * ref = NULL; /* Datatype structure for opaque references */ + hsize_t dim[1] = {1}; /* Dimension info for array datatype */ + herr_t status; + hbool_t copied_dtype = + TRUE; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Initialize the atom group for the file IDs */ - if(H5I_register_type(H5I_DATATYPE_CLS) < 0) + if (H5I_register_type(H5I_DATATYPE_CLS) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Make certain there aren't too many classes of datatypes defined */ @@ -786,36 +814,36 @@ H5T__init_package(void) * Initialize pre-defined native datatypes from code generated during * the library configuration by H5detect. */ - if(H5T__init_native() < 0) + if (H5T__init_native() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Get the atomic datatype structures needed by the initialization code below */ - if(NULL == (native_schar = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) + if (NULL == (native_schar = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_uchar = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR_g))) + if (NULL == (native_uchar = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_short = (H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) + if (NULL == (native_short = (H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_ushort = (H5T_t *)H5I_object(H5T_NATIVE_USHORT_g))) + if (NULL == (native_ushort = (H5T_t *)H5I_object(H5T_NATIVE_USHORT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_int = (H5T_t *)H5I_object(H5T_NATIVE_INT_g))) + if (NULL == (native_int = (H5T_t *)H5I_object(H5T_NATIVE_INT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_uint = (H5T_t *)H5I_object(H5T_NATIVE_UINT_g))) + if (NULL == (native_uint = (H5T_t *)H5I_object(H5T_NATIVE_UINT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_long = (H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) + if (NULL == (native_long = (H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_ulong = (H5T_t *)H5I_object(H5T_NATIVE_ULONG_g))) + if (NULL == (native_ulong = (H5T_t *)H5I_object(H5T_NATIVE_ULONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_llong = (H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) + if (NULL == (native_llong = (H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_ullong = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG_g))) + if (NULL == (native_ullong = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_float = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) + if (NULL == (native_float = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_double = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) + if (NULL == (native_double = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") -#if H5_SIZEOF_LONG_DOUBLE !=0 - if(NULL == (native_ldouble = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE_g))) +#if H5_SIZEOF_LONG_DOUBLE != 0 + if (NULL == (native_ldouble = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") #endif @@ -825,31 +853,31 @@ H5T__init_package(void) */ /* 1-byte bit field */ - H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B8_g,COPY,native_uint,SET,1) + H5T_INIT_TYPE(BITFIELD, H5T_NATIVE_B8_g, COPY, native_uint, SET, 1) /* 2-byte bit field */ - H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B16_g,COPY,native_uint,SET,2) + H5T_INIT_TYPE(BITFIELD, H5T_NATIVE_B16_g, COPY, native_uint, SET, 2) /* 4-byte bit field */ - H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B32_g,COPY,native_uint,SET,4) + H5T_INIT_TYPE(BITFIELD, H5T_NATIVE_B32_g, COPY, native_uint, SET, 4) /* 8-byte bit field */ - H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B64_g,COPY,native_uint,SET,8) + H5T_INIT_TYPE(BITFIELD, H5T_NATIVE_B64_g, COPY, native_uint, SET, 8) /* haddr_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HADDR_g,COPY,native_uint,SET,sizeof(haddr_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HADDR_g, COPY, native_uint, SET, sizeof(haddr_t)) /* hsize_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HSIZE_g,COPY,native_uint,SET,sizeof(hsize_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HSIZE_g, COPY, native_uint, SET, sizeof(hsize_t)) /* hssize_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HSSIZE_g,COPY,native_int,SET,sizeof(hssize_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HSSIZE_g, COPY, native_int, SET, sizeof(hssize_t)) /* herr_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HERR_g,COPY,native_int,SET,sizeof(herr_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HERR_g, COPY, native_int, SET, sizeof(herr_t)) /* hbool_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HBOOL_g,COPY,native_uint,SET,sizeof(hbool_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HBOOL_g, COPY, native_uint, SET, sizeof(hbool_t)) /*------------------------------------------------------------ * IEEE Types @@ -857,16 +885,16 @@ H5T__init_package(void) */ /* IEEE 4-byte little-endian float */ - H5T_INIT_TYPE(FLOATLE,H5T_IEEE_F32LE_g,COPY,native_double,SET,4) + H5T_INIT_TYPE(FLOATLE, H5T_IEEE_F32LE_g, COPY, native_double, SET, 4) /* IEEE 4-byte big-endian float */ - H5T_INIT_TYPE(FLOATBE,H5T_IEEE_F32BE_g,COPY,native_double,SET,4) + H5T_INIT_TYPE(FLOATBE, H5T_IEEE_F32BE_g, COPY, native_double, SET, 4) /* IEEE 8-byte little-endian float */ - H5T_INIT_TYPE(DOUBLELE,H5T_IEEE_F64LE_g,COPY,native_double,SET,8) + H5T_INIT_TYPE(DOUBLELE, H5T_IEEE_F64LE_g, COPY, native_double, SET, 8) /* IEEE 8-byte big-endian float */ - H5T_INIT_TYPE(DOUBLEBE,H5T_IEEE_F64BE_g,COPY,native_double,SET,8) + H5T_INIT_TYPE(DOUBLEBE, H5T_IEEE_F64BE_g, COPY, native_double, SET, 8) /*------------------------------------------------------------ * VAX Types @@ -874,10 +902,10 @@ H5T__init_package(void) */ /* VAX 4-byte float */ - H5T_INIT_TYPE(FLOATVAX,H5T_VAX_F32_g,COPY,native_double,SET,4) + H5T_INIT_TYPE(FLOATVAX, H5T_VAX_F32_g, COPY, native_double, SET, 4) /* VAX 8-byte double */ - H5T_INIT_TYPE(DOUBLEVAX,H5T_VAX_F64_g,COPY,native_double,SET,8) + H5T_INIT_TYPE(DOUBLEVAX, H5T_VAX_F64_g, COPY, native_double, SET, 8) /*------------------------------------------------------------ * C99 types @@ -885,60 +913,60 @@ H5T__init_package(void) */ /* 1-byte little-endian (endianness is irrelevant) signed integer */ - H5T_INIT_TYPE(SINTLE,H5T_STD_I8LE_g,COPY,native_int,SET,1) + H5T_INIT_TYPE(SINTLE, H5T_STD_I8LE_g, COPY, native_int, SET, 1) /* 1-byte big-endian (endianness is irrelevant) signed integer */ - H5T_INIT_TYPE(SINTBE,H5T_STD_I8BE_g,COPY,native_int,SET,1) + H5T_INIT_TYPE(SINTBE, H5T_STD_I8BE_g, COPY, native_int, SET, 1) /* 2-byte little-endian signed integer */ - H5T_INIT_TYPE(SINTLE,H5T_STD_I16LE_g,COPY,native_int,SET,2) + H5T_INIT_TYPE(SINTLE, H5T_STD_I16LE_g, COPY, native_int, SET, 2) /* 2-byte big-endian signed integer */ - H5T_INIT_TYPE(SINTBE,H5T_STD_I16BE_g,COPY,native_int,SET,2) + H5T_INIT_TYPE(SINTBE, H5T_STD_I16BE_g, COPY, native_int, SET, 2) /* 4-byte little-endian signed integer */ - H5T_INIT_TYPE(SINTLE,H5T_STD_I32LE_g,COPY,native_int,SET,4) + H5T_INIT_TYPE(SINTLE, H5T_STD_I32LE_g, COPY, native_int, SET, 4) /* 4-byte big-endian signed integer */ - H5T_INIT_TYPE(SINTBE,H5T_STD_I32BE_g,COPY,native_int,SET,4) + H5T_INIT_TYPE(SINTBE, H5T_STD_I32BE_g, COPY, native_int, SET, 4) /* 8-byte little-endian signed integer */ - H5T_INIT_TYPE(SINTLE,H5T_STD_I64LE_g,COPY,native_int,SET,8) + H5T_INIT_TYPE(SINTLE, H5T_STD_I64LE_g, COPY, native_int, SET, 8) /* 8-byte big-endian signed integer */ - H5T_INIT_TYPE(SINTBE,H5T_STD_I64BE_g,COPY,native_int,SET,8) + H5T_INIT_TYPE(SINTBE, H5T_STD_I64BE_g, COPY, native_int, SET, 8) /* 1-byte little-endian (endianness is irrelevant) unsigned integer */ - H5T_INIT_TYPE(UINTLE,H5T_STD_U8LE_g,COPY,native_uint,SET,1) - std_u8le=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTLE, H5T_STD_U8LE_g, COPY, native_uint, SET, 1) + std_u8le = dt; /* Keep type for later */ /* 1-byte big-endian (endianness is irrelevant) unsigned integer */ - H5T_INIT_TYPE(UINTBE,H5T_STD_U8BE_g,COPY,native_uint,SET,1) - std_u8be=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTBE, H5T_STD_U8BE_g, COPY, native_uint, SET, 1) + std_u8be = dt; /* Keep type for later */ /* 2-byte little-endian unsigned integer */ - H5T_INIT_TYPE(UINTLE,H5T_STD_U16LE_g,COPY,native_uint,SET,2) - std_u16le=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTLE, H5T_STD_U16LE_g, COPY, native_uint, SET, 2) + std_u16le = dt; /* Keep type for later */ /* 2-byte big-endian unsigned integer */ - H5T_INIT_TYPE(UINTBE,H5T_STD_U16BE_g,COPY,native_uint,SET,2) - std_u16be=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTBE, H5T_STD_U16BE_g, COPY, native_uint, SET, 2) + std_u16be = dt; /* Keep type for later */ /* 4-byte little-endian unsigned integer */ - H5T_INIT_TYPE(UINTLE,H5T_STD_U32LE_g,COPY,native_uint,SET,4) - std_u32le=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTLE, H5T_STD_U32LE_g, COPY, native_uint, SET, 4) + std_u32le = dt; /* Keep type for later */ /* 4-byte big-endian unsigned integer */ - H5T_INIT_TYPE(UINTBE,H5T_STD_U32BE_g,COPY,native_uint,SET,4) - std_u32be=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTBE, H5T_STD_U32BE_g, COPY, native_uint, SET, 4) + std_u32be = dt; /* Keep type for later */ /* 8-byte little-endian unsigned integer */ - H5T_INIT_TYPE(UINTLE,H5T_STD_U64LE_g,COPY,native_uint,SET,8) - std_u64le=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTLE, H5T_STD_U64LE_g, COPY, native_uint, SET, 8) + std_u64le = dt; /* Keep type for later */ /* 8-byte big-endian unsigned integer */ - H5T_INIT_TYPE(UINTBE,H5T_STD_U64BE_g,COPY,native_uint,SET,8) - std_u64be=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTBE, H5T_STD_U64BE_g, COPY, native_uint, SET, 8) + std_u64be = dt; /* Keep type for later */ /*------------------------------------------------------------ * Native, Little- & Big-endian bitfields @@ -947,7 +975,7 @@ H5T__init_package(void) /* little-endian (order is irrelevant) 8-bit bitfield */ H5T_INIT_TYPE(BITFIELDLE, H5T_STD_B8LE_g, COPY, std_u8le, NOSET, -) - bitfield=dt; /* Keep type for later */ + bitfield = dt; /* Keep type for later */ /* big-endian (order is irrelevant) 8-bit bitfield */ H5T_INIT_TYPE(BITFIELDBE, H5T_STD_B8BE_g, COPY, std_u8be, NOSET, -) @@ -987,7 +1015,6 @@ H5T__init_package(void) /* Big-endian 64-bit UNIX time_t */ H5T_INIT_TYPE(TIME, H5T_UNIX_D64BE_g, COPY, std_u64be, NOSET, -) - /* Indicate that the types that are created from here down are allocated * H5FL_ALLOC(), not copied with H5T_copy() */ @@ -1003,7 +1030,7 @@ H5T__init_package(void) /* One-byte character string */ H5T_INIT_TYPE(CSTRING, H5T_C_S1_g, ALLOC, -, SET, 1) - string = dt; /* Keep type for later */ + string = dt; /* Keep type for later */ /*------------------------------------------------------------ * The `Fortran' architecture @@ -1020,21 +1047,21 @@ H5T__init_package(void) /* Deprecated object reference type */ H5T_INIT_TYPE(OBJREF, H5T_STD_REF_OBJ_g, ALLOC, -, NOSET, -) - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") - objref = dt; /* Keep type for later */ + objref = dt; /* Keep type for later */ /* Deprecated region reference type */ H5T_INIT_TYPE(REGREF, H5T_STD_REF_DSETREG_g, ALLOC, -, NOSET, -) - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") - regref = dt; /* Keep type for later */ + regref = dt; /* Keep type for later */ /* Opaque reference type */ H5T_INIT_TYPE(REF, H5T_STD_REF_g, ALLOC, -, NOSET, -) - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") - ref = dt; /* Keep type for later */ + ref = dt; /* Keep type for later */ /* * Register conversion functions beginning with the most general and @@ -1084,80 +1111,123 @@ H5T__init_package(void) */ /* floating point */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_dbl", native_float, native_double, H5T__conv_float_double); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_flt", native_double, native_float, H5T__conv_double_float); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_dbl", native_float, native_double, H5T__conv_float_double); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_flt", native_double, native_float, H5T__conv_double_float); #if H5_SIZEOF_LONG_DOUBLE != 0 - status |= H5T__register_int(H5T_PERS_HARD, "flt_ldbl", native_float, native_ldouble, H5T__conv_float_ldouble); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_ldbl", native_double, native_ldouble, H5T__conv_double_ldouble); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_flt", native_ldouble, native_float, H5T__conv_ldouble_float); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_dbl", native_ldouble, native_double, H5T__conv_ldouble_double); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_ldbl", native_float, native_ldouble, H5T__conv_float_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_ldbl", native_double, native_ldouble, H5T__conv_double_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_flt", native_ldouble, native_float, H5T__conv_ldouble_float); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_dbl", native_ldouble, native_double, H5T__conv_ldouble_double); #endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ /* from long long */ - status |= H5T__register_int(H5T_PERS_HARD, "llong_ullong", native_llong, native_ullong, H5T__conv_llong_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_llong", native_ullong, native_llong, H5T__conv_ullong_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_ullong", native_llong, native_ullong, H5T__conv_llong_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_llong", native_ullong, native_llong, H5T__conv_ullong_llong); status |= H5T__register_int(H5T_PERS_HARD, "llong_long", native_llong, native_long, H5T__conv_llong_long); - status |= H5T__register_int(H5T_PERS_HARD, "llong_ulong", native_llong, native_ulong, H5T__conv_llong_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_long", native_ullong, native_long, H5T__conv_ullong_long); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_ulong", native_ullong, native_ulong, H5T__conv_ullong_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "llong_short", native_llong, native_short, H5T__conv_llong_short); - status |= H5T__register_int(H5T_PERS_HARD, "llong_ushort", native_llong, native_ushort, H5T__conv_llong_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_short", native_ullong, native_short, H5T__conv_ullong_short); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_ushort", native_ullong, native_ushort, H5T__conv_ullong_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_ulong", native_llong, native_ulong, H5T__conv_llong_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_long", native_ullong, native_long, H5T__conv_ullong_long); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_ulong", native_ullong, native_ulong, H5T__conv_ullong_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_short", native_llong, native_short, H5T__conv_llong_short); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_ushort", native_llong, native_ushort, H5T__conv_llong_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_short", native_ullong, native_short, H5T__conv_ullong_short); + status |= H5T__register_int(H5T_PERS_HARD, "ullong_ushort", native_ullong, native_ushort, + H5T__conv_ullong_ushort); status |= H5T__register_int(H5T_PERS_HARD, "llong_int", native_llong, native_int, H5T__conv_llong_int); status |= H5T__register_int(H5T_PERS_HARD, "llong_uint", native_llong, native_uint, H5T__conv_llong_uint); status |= H5T__register_int(H5T_PERS_HARD, "ullong_int", native_ullong, native_int, H5T__conv_ullong_int); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_uint", native_ullong, native_uint, H5T__conv_ullong_uint); - status |= H5T__register_int(H5T_PERS_HARD, "llong_schar", native_llong, native_schar, H5T__conv_llong_schar); - status |= H5T__register_int(H5T_PERS_HARD, "llong_uchar", native_llong, native_uchar, H5T__conv_llong_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_schar", native_ullong, native_schar, H5T__conv_ullong_schar); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_uchar", native_ullong, native_uchar, H5T__conv_ullong_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_uint", native_ullong, native_uint, H5T__conv_ullong_uint); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_schar", native_llong, native_schar, H5T__conv_llong_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_uchar", native_llong, native_uchar, H5T__conv_llong_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_schar", native_ullong, native_schar, H5T__conv_ullong_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_uchar", native_ullong, native_uchar, H5T__conv_ullong_uchar); /* From long */ status |= H5T__register_int(H5T_PERS_HARD, "long_llong", native_long, native_llong, H5T__conv_long_llong); - status |= H5T__register_int(H5T_PERS_HARD, "long_ullong", native_long, native_ullong, H5T__conv_long_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_llong", native_ulong, native_llong, H5T__conv_ulong_llong); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_ullong", native_ulong, native_ullong, H5T__conv_ulong_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "long_ullong", native_long, native_ullong, H5T__conv_long_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_llong", native_ulong, native_llong, H5T__conv_ulong_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_ullong", native_ulong, native_ullong, H5T__conv_ulong_ullong); status |= H5T__register_int(H5T_PERS_HARD, "long_ulong", native_long, native_ulong, H5T__conv_long_ulong); status |= H5T__register_int(H5T_PERS_HARD, "ulong_long", native_ulong, native_long, H5T__conv_ulong_long); status |= H5T__register_int(H5T_PERS_HARD, "long_short", native_long, native_short, H5T__conv_long_short); - status |= H5T__register_int(H5T_PERS_HARD, "long_ushort", native_long, native_ushort, H5T__conv_long_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_short", native_ulong, native_short, H5T__conv_ulong_short); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_ushort", native_ulong, native_ushort, H5T__conv_ulong_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "long_ushort", native_long, native_ushort, H5T__conv_long_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_short", native_ulong, native_short, H5T__conv_ulong_short); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_ushort", native_ulong, native_ushort, H5T__conv_ulong_ushort); status |= H5T__register_int(H5T_PERS_HARD, "long_int", native_long, native_int, H5T__conv_long_int); status |= H5T__register_int(H5T_PERS_HARD, "long_uint", native_long, native_uint, H5T__conv_long_uint); status |= H5T__register_int(H5T_PERS_HARD, "ulong_int", native_ulong, native_int, H5T__conv_ulong_int); status |= H5T__register_int(H5T_PERS_HARD, "ulong_uint", native_ulong, native_uint, H5T__conv_ulong_uint); status |= H5T__register_int(H5T_PERS_HARD, "long_schar", native_long, native_schar, H5T__conv_long_schar); status |= H5T__register_int(H5T_PERS_HARD, "long_uchar", native_long, native_uchar, H5T__conv_long_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_schar", native_ulong, native_schar, H5T__conv_ulong_schar); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_uchar", native_ulong, native_uchar, H5T__conv_ulong_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_schar", native_ulong, native_schar, H5T__conv_ulong_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_uchar", native_ulong, native_uchar, H5T__conv_ulong_uchar); /* From short */ - status |= H5T__register_int(H5T_PERS_HARD, "short_llong", native_short, native_llong, H5T__conv_short_llong); - status |= H5T__register_int(H5T_PERS_HARD, "short_ullong", native_short, native_ullong, H5T__conv_short_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_llong", native_ushort, native_llong, H5T__conv_ushort_llong); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_ullong", native_ushort, native_ullong, H5T__conv_ushort_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "short_llong", native_short, native_llong, H5T__conv_short_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "short_ullong", native_short, native_ullong, H5T__conv_short_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_llong", native_ushort, native_llong, H5T__conv_ushort_llong); + status |= H5T__register_int(H5T_PERS_HARD, "ushort_ullong", native_ushort, native_ullong, + H5T__conv_ushort_ullong); status |= H5T__register_int(H5T_PERS_HARD, "short_long", native_short, native_long, H5T__conv_short_long); - status |= H5T__register_int(H5T_PERS_HARD, "short_ulong", native_short, native_ulong, H5T__conv_short_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_long", native_ushort, native_long, H5T__conv_ushort_long); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_ulong", native_ushort, native_ulong, H5T__conv_ushort_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "short_ushort", native_short, native_ushort, H5T__conv_short_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_short", native_ushort, native_short, H5T__conv_ushort_short); + status |= + H5T__register_int(H5T_PERS_HARD, "short_ulong", native_short, native_ulong, H5T__conv_short_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_long", native_ushort, native_long, H5T__conv_ushort_long); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_ulong", native_ushort, native_ulong, H5T__conv_ushort_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "short_ushort", native_short, native_ushort, H5T__conv_short_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_short", native_ushort, native_short, H5T__conv_ushort_short); status |= H5T__register_int(H5T_PERS_HARD, "short_int", native_short, native_int, H5T__conv_short_int); status |= H5T__register_int(H5T_PERS_HARD, "short_uint", native_short, native_uint, H5T__conv_short_uint); status |= H5T__register_int(H5T_PERS_HARD, "ushort_int", native_ushort, native_int, H5T__conv_ushort_int); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_uint", native_ushort, native_uint, H5T__conv_ushort_uint); - status |= H5T__register_int(H5T_PERS_HARD, "short_schar", native_short, native_schar, H5T__conv_short_schar); - status |= H5T__register_int(H5T_PERS_HARD, "short_uchar", native_short, native_uchar, H5T__conv_short_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_schar", native_ushort, native_schar, H5T__conv_ushort_schar); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_uchar", native_ushort, native_uchar, H5T__conv_ushort_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_uint", native_ushort, native_uint, H5T__conv_ushort_uint); + status |= + H5T__register_int(H5T_PERS_HARD, "short_schar", native_short, native_schar, H5T__conv_short_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "short_uchar", native_short, native_uchar, H5T__conv_short_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_schar", native_ushort, native_schar, H5T__conv_ushort_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_uchar", native_ushort, native_uchar, H5T__conv_ushort_uchar); /* From int */ status |= H5T__register_int(H5T_PERS_HARD, "int_llong", native_int, native_llong, H5T__conv_int_llong); status |= H5T__register_int(H5T_PERS_HARD, "int_ullong", native_int, native_ullong, H5T__conv_int_ullong); status |= H5T__register_int(H5T_PERS_HARD, "uint_llong", native_uint, native_llong, H5T__conv_uint_llong); - status |= H5T__register_int(H5T_PERS_HARD, "uint_ullong", native_uint, native_ullong, H5T__conv_uint_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "uint_ullong", native_uint, native_ullong, H5T__conv_uint_ullong); status |= H5T__register_int(H5T_PERS_HARD, "int_long", native_int, native_long, H5T__conv_int_long); status |= H5T__register_int(H5T_PERS_HARD, "int_ulong", native_int, native_ulong, H5T__conv_int_ulong); status |= H5T__register_int(H5T_PERS_HARD, "uint_long", native_uint, native_long, H5T__conv_uint_long); @@ -1165,7 +1235,8 @@ H5T__init_package(void) status |= H5T__register_int(H5T_PERS_HARD, "int_short", native_int, native_short, H5T__conv_int_short); status |= H5T__register_int(H5T_PERS_HARD, "int_ushort", native_int, native_ushort, H5T__conv_int_ushort); status |= H5T__register_int(H5T_PERS_HARD, "uint_short", native_uint, native_short, H5T__conv_uint_short); - status |= H5T__register_int(H5T_PERS_HARD, "uint_ushort", native_uint, native_ushort, H5T__conv_uint_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "uint_ushort", native_uint, native_ushort, H5T__conv_uint_ushort); status |= H5T__register_int(H5T_PERS_HARD, "int_uint", native_int, native_uint, H5T__conv_int_uint); status |= H5T__register_int(H5T_PERS_HARD, "uint_int", native_uint, native_int, H5T__conv_uint_int); status |= H5T__register_int(H5T_PERS_HARD, "int_schar", native_int, native_schar, H5T__conv_int_schar); @@ -1174,44 +1245,68 @@ H5T__init_package(void) status |= H5T__register_int(H5T_PERS_HARD, "uint_uchar", native_uint, native_uchar, H5T__conv_uint_uchar); /* From char */ - status |= H5T__register_int(H5T_PERS_HARD, "schar_llong", native_schar, native_llong, H5T__conv_schar_llong); - status |= H5T__register_int(H5T_PERS_HARD, "schar_ullong", native_schar, native_ullong, H5T__conv_schar_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_llong", native_uchar, native_llong, H5T__conv_uchar_llong); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_ullong", native_uchar, native_ullong, H5T__conv_uchar_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_llong", native_schar, native_llong, H5T__conv_schar_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_ullong", native_schar, native_ullong, H5T__conv_schar_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_llong", native_uchar, native_llong, H5T__conv_uchar_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_ullong", native_uchar, native_ullong, H5T__conv_uchar_ullong); status |= H5T__register_int(H5T_PERS_HARD, "schar_long", native_schar, native_long, H5T__conv_schar_long); - status |= H5T__register_int(H5T_PERS_HARD, "schar_ulong", native_schar, native_ulong, H5T__conv_schar_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_ulong", native_schar, native_ulong, H5T__conv_schar_ulong); status |= H5T__register_int(H5T_PERS_HARD, "uchar_long", native_uchar, native_long, H5T__conv_uchar_long); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_ulong", native_uchar, native_ulong, H5T__conv_uchar_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "schar_short", native_schar, native_short, H5T__conv_schar_short); - status |= H5T__register_int(H5T_PERS_HARD, "schar_ushort", native_schar, native_ushort, H5T__conv_schar_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_short", native_uchar, native_short, H5T__conv_uchar_short); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_ushort", native_uchar, native_ushort, H5T__conv_uchar_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_ulong", native_uchar, native_ulong, H5T__conv_uchar_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_short", native_schar, native_short, H5T__conv_schar_short); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_ushort", native_schar, native_ushort, H5T__conv_schar_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_short", native_uchar, native_short, H5T__conv_uchar_short); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_ushort", native_uchar, native_ushort, H5T__conv_uchar_ushort); status |= H5T__register_int(H5T_PERS_HARD, "schar_int", native_schar, native_int, H5T__conv_schar_int); status |= H5T__register_int(H5T_PERS_HARD, "schar_uint", native_schar, native_uint, H5T__conv_schar_uint); status |= H5T__register_int(H5T_PERS_HARD, "uchar_int", native_uchar, native_int, H5T__conv_uchar_int); status |= H5T__register_int(H5T_PERS_HARD, "uchar_uint", native_uchar, native_uint, H5T__conv_uchar_uint); - status |= H5T__register_int(H5T_PERS_HARD, "schar_uchar", native_schar, native_uchar, H5T__conv_schar_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_schar", native_uchar, native_schar, H5T__conv_uchar_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_uchar", native_schar, native_uchar, H5T__conv_schar_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_schar", native_uchar, native_schar, H5T__conv_uchar_schar); /* From char to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "schar_flt", native_schar, native_float, H5T__conv_schar_float); - status |= H5T__register_int(H5T_PERS_HARD, "schar_dbl", native_schar, native_double, H5T__conv_schar_double); - status |= H5T__register_int(H5T_PERS_HARD, "schar_ldbl", native_schar, native_ldouble, H5T__conv_schar_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_flt", native_schar, native_float, H5T__conv_schar_float); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_dbl", native_schar, native_double, H5T__conv_schar_double); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_ldbl", native_schar, native_ldouble, H5T__conv_schar_ldouble); /* From unsigned char to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "uchar_flt", native_uchar, native_float, H5T__conv_uchar_float); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_dbl", native_uchar, native_double, H5T__conv_uchar_double); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_ldbl", native_uchar, native_ldouble, H5T__conv_uchar_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_flt", native_uchar, native_float, H5T__conv_uchar_float); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_dbl", native_uchar, native_double, H5T__conv_uchar_double); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_ldbl", native_uchar, native_ldouble, H5T__conv_uchar_ldouble); /* From short to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "short_flt", native_short, native_float, H5T__conv_short_float); - status |= H5T__register_int(H5T_PERS_HARD, "short_dbl", native_short, native_double, H5T__conv_short_double); - status |= H5T__register_int(H5T_PERS_HARD, "short_ldbl", native_short, native_ldouble, H5T__conv_short_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "short_flt", native_short, native_float, H5T__conv_short_float); + status |= + H5T__register_int(H5T_PERS_HARD, "short_dbl", native_short, native_double, H5T__conv_short_double); + status |= + H5T__register_int(H5T_PERS_HARD, "short_ldbl", native_short, native_ldouble, H5T__conv_short_ldouble); /* From unsigned short to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "ushort_flt", native_ushort, native_float, H5T__conv_ushort_float); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_dbl", native_ushort, native_double, H5T__conv_ushort_double); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_ldbl", native_ushort, native_ldouble, H5T__conv_ushort_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_flt", native_ushort, native_float, H5T__conv_ushort_float); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_dbl", native_ushort, native_double, H5T__conv_ushort_double); + status |= H5T__register_int(H5T_PERS_HARD, "ushort_ldbl", native_ushort, native_ldouble, + H5T__conv_ushort_ldouble); /* From int to floats */ status |= H5T__register_int(H5T_PERS_HARD, "int_flt", native_int, native_float, H5T__conv_int_float); @@ -1221,51 +1316,74 @@ H5T__init_package(void) /* From unsigned int to floats */ status |= H5T__register_int(H5T_PERS_HARD, "uint_flt", native_uint, native_float, H5T__conv_uint_float); status |= H5T__register_int(H5T_PERS_HARD, "uint_dbl", native_uint, native_double, H5T__conv_uint_double); - status |= H5T__register_int(H5T_PERS_HARD, "uint_ldbl", native_uint, native_ldouble, H5T__conv_uint_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "uint_ldbl", native_uint, native_ldouble, H5T__conv_uint_ldouble); /* From long to floats */ status |= H5T__register_int(H5T_PERS_HARD, "long_flt", native_long, native_float, H5T__conv_long_float); status |= H5T__register_int(H5T_PERS_HARD, "long_dbl", native_long, native_double, H5T__conv_long_double); - status |= H5T__register_int(H5T_PERS_HARD, "long_ldbl", native_long, native_ldouble, H5T__conv_long_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "long_ldbl", native_long, native_ldouble, H5T__conv_long_ldouble); /* From unsigned long to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "ulong_flt", native_ulong, native_float, H5T__conv_ulong_float); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_dbl", native_ulong, native_double, H5T__conv_ulong_double); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_ldbl", native_ulong, native_ldouble, H5T__conv_ulong_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_flt", native_ulong, native_float, H5T__conv_ulong_float); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_dbl", native_ulong, native_double, H5T__conv_ulong_double); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_ldbl", native_ulong, native_ldouble, H5T__conv_ulong_ldouble); /* From long long to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T__conv_llong_float); - status |= H5T__register_int(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T__conv_llong_double); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T__conv_llong_float); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T__conv_llong_double); #ifdef H5T_CONV_INTERNAL_LLONG_LDOUBLE - status |= H5T__register_int(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T__conv_llong_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T__conv_llong_ldouble); #endif /* H5T_CONV_INTERNAL_LLONG_LDOUBLE */ /* From unsigned long long to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T__conv_ullong_float); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T__conv_ullong_double); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T__conv_ullong_float); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T__conv_ullong_double); #ifdef H5T_CONV_INTERNAL_ULLONG_LDOUBLE - status |= H5T__register_int(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, H5T__conv_ullong_ldouble); + status |= H5T__register_int(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, + H5T__conv_ullong_ldouble); #endif /* H5T_CONV_INTERNAL_ULLONG_LDOUBLE */ /* From floats to char */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_schar", native_float, native_schar, H5T__conv_float_schar); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_schar", native_double, native_schar, H5T__conv_double_schar); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_schar", native_ldouble, native_schar, H5T__conv_ldouble_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_schar", native_float, native_schar, H5T__conv_float_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_schar", native_double, native_schar, H5T__conv_double_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_schar", native_ldouble, native_schar, H5T__conv_ldouble_schar); /* From floats to unsigned char */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_uchar", native_float, native_uchar, H5T__conv_float_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_uchar", native_double, native_uchar, H5T__conv_double_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_uchar", native_ldouble, native_uchar, H5T__conv_ldouble_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_uchar", native_float, native_uchar, H5T__conv_float_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_uchar", native_double, native_uchar, H5T__conv_double_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_uchar", native_ldouble, native_uchar, H5T__conv_ldouble_uchar); /* From floats to short */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_short", native_float, native_short, H5T__conv_float_short); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_short", native_double, native_short, H5T__conv_double_short); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_short", native_ldouble, native_short, H5T__conv_ldouble_short); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_short", native_float, native_short, H5T__conv_float_short); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_short", native_double, native_short, H5T__conv_double_short); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_short", native_ldouble, native_short, H5T__conv_ldouble_short); /* From floats to unsigned short */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_ushort", native_float, native_ushort, H5T__conv_float_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_ushort", native_double, native_ushort, H5T__conv_double_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ushort", native_ldouble, native_ushort, H5T__conv_ldouble_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_ushort", native_float, native_ushort, H5T__conv_float_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_ushort", native_double, native_ushort, H5T__conv_double_ushort); + status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ushort", native_ldouble, native_ushort, + H5T__conv_ldouble_ushort); /* From floats to int */ status |= H5T__register_int(H5T_PERS_HARD, "flt_int", native_float, native_int, H5T__conv_float_int); @@ -1275,30 +1393,41 @@ H5T__init_package(void) /* From floats to unsigned int */ status |= H5T__register_int(H5T_PERS_HARD, "flt_uint", native_float, native_uint, H5T__conv_float_uint); status |= H5T__register_int(H5T_PERS_HARD, "dbl_uint", native_double, native_uint, H5T__conv_double_uint); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_uint", native_ldouble, native_uint, H5T__conv_ldouble_uint); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_uint", native_ldouble, native_uint, H5T__conv_ldouble_uint); /* From floats to long */ status |= H5T__register_int(H5T_PERS_HARD, "flt_long", native_float, native_long, H5T__conv_float_long); status |= H5T__register_int(H5T_PERS_HARD, "dbl_long", native_double, native_long, H5T__conv_double_long); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_long", native_ldouble, native_long, H5T__conv_ldouble_long); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_long", native_ldouble, native_long, H5T__conv_ldouble_long); /* From floats to unsigned long */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_ulong", native_float, native_ulong, H5T__conv_float_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_ulong", native_double, native_ulong, H5T__conv_double_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ulong", native_ldouble, native_ulong, H5T__conv_ldouble_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_ulong", native_float, native_ulong, H5T__conv_float_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_ulong", native_double, native_ulong, H5T__conv_double_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_ulong", native_ldouble, native_ulong, H5T__conv_ldouble_ulong); /* From floats to long long */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T__conv_float_llong); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T__conv_double_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T__conv_float_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T__conv_double_llong); #ifdef H5T_CONV_INTERNAL_LDOUBLE_LLONG - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T__conv_ldouble_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T__conv_ldouble_llong); #endif /* H5T_CONV_INTERNAL_LDOUBLE_LLONG */ /* From floats to unsigned long long */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_ullong", native_float, native_ullong, H5T__conv_float_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_ullong", native_double, native_ullong, H5T__conv_double_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_ullong", native_float, native_ullong, H5T__conv_float_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_ullong", native_double, native_ullong, H5T__conv_double_ullong); #if H5T_CONV_INTERNAL_LDOUBLE_ULLONG - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ullong", native_ldouble, native_ullong, H5T__conv_ldouble_ullong); + status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ullong", native_ldouble, native_ullong, + H5T__conv_ldouble_ullong); #endif /* H5T_CONV_INTERNAL_LDOUBLE_ULLONG */ /* @@ -1311,7 +1440,7 @@ H5T__init_package(void) /* Initialize the +/- Infinity values for floating-point types */ status |= H5T__init_inf(); - if(status < 0) + if (status < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function(s)") /* Register datatype creation property class properties here. See similar @@ -1319,13 +1448,13 @@ H5T__init_package(void) */ /* Only register the default property list if it hasn't been created yet */ - if(H5P_LST_DATATYPE_CREATE_ID_g == (-1)) { + if (H5P_LST_DATATYPE_CREATE_ID_g == (-1)) { /* ========== Datatype Creation Property Class Initialization ============*/ HDassert(H5P_CLS_DATATYPE_CREATE_g != NULL); /* Register the default datatype creation property list */ - if((H5P_LST_DATATYPE_CREATE_ID_g = H5P_create_id(H5P_CLS_DATATYPE_CREATE_g, FALSE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") + if ((H5P_LST_DATATYPE_CREATE_ID_g = H5P_create_id(H5P_CLS_DATATYPE_CREATE_g, FALSE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ /* Mark "top" of interface as initialized, too */ @@ -1333,32 +1462,31 @@ H5T__init_package(void) done: /* General cleanup */ - if(compound != NULL) + if (compound != NULL) (void)H5T_close_real(compound); - if(enum_type != NULL) + if (enum_type != NULL) (void)H5T_close_real(enum_type); - if(vlen != NULL) + if (vlen != NULL) (void)H5T_close_real(vlen); - if(array != NULL) + if (array != NULL) (void)H5T_close_real(array); /* Error cleanup */ - if(ret_value < 0) { - if(dt) { + if (ret_value < 0) { + if (dt) { /* Check if we should call H5T_close_real or H5FL_FREE */ - if(copied_dtype) + if (copied_dtype) (void)H5T_close_real(dt); else { dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); - dt = H5FL_FREE(H5T_t, dt); + dt = H5FL_FREE(H5T_t, dt); } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__init_package() */ - /*------------------------------------------------------------------------- * Function: H5T__unlock_cb * @@ -1376,14 +1504,14 @@ done: static int H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata) { - H5T_t *dt = (H5T_t *)_dt; - int *n = (int *)_udata; + H5T_t *dt = (H5T_t *)_dt; + int * n = (int *)_udata; FUNC_ENTER_STATIC_NOERR HDassert(dt && dt->shared); - if(H5T_STATE_IMMUTABLE==dt->shared->state) { + if (H5T_STATE_IMMUTABLE == dt->shared->state) { dt->shared->state = H5T_STATE_RDONLY; (*n)++; } /* end if */ @@ -1391,7 +1519,6 @@ H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__unlock_cb() */ - /*------------------------------------------------------------------------- * Function: H5T_top_term_package * @@ -1409,66 +1536,70 @@ H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata) int H5T_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5T_top_package_initialize_s) { + if (H5T_top_package_initialize_s) { /* Unregister all conversion functions */ - if(H5T_g.path) { + if (H5T_g.path) { int i, nprint = 0; - for(i = 0; i < H5T_g.npaths; i++) { + for (i = 0; i < H5T_g.npaths; i++) { H5T_path_t *path; path = H5T_g.path[i]; HDassert(path); - if(path->conv.u.app_func) { - H5T__print_stats(path, &nprint/*in,out*/); + if (path->conv.u.app_func) { + H5T__print_stats(path, &nprint /*in,out*/); path->cdata.command = H5T_CONV_FREE; - if(path->conv.is_app) { - if((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (path->conv.is_app) { + if ((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { - HDfprintf(H5DEBUG(T), "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + HDfprintf(H5DEBUG(T), + "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->conv.u.app_func), path->name); } /* end if */ #endif H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { - if((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + if ((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { - HDfprintf(H5DEBUG(T), "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + HDfprintf(H5DEBUG(T), + "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->conv.u.lib_func), path->name); } /* end if */ #endif H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end else */ - } /* end if */ + } /* end if */ + } /* end else */ + } /* end if */ - if(path->src) + if (path->src) (void)H5T_close_real(path->src); - if(path->dst) + if (path->dst) (void)H5T_close_real(path->dst); - path = H5FL_FREE(H5T_path_t, path); + path = H5FL_FREE(H5T_path_t, path); H5T_g.path[i] = NULL; } /* end for */ /* Clear conversion tables */ - H5T_g.path = (H5T_path_t **)H5MM_xfree(H5T_g.path); + H5T_g.path = (H5T_path_t **)H5MM_xfree(H5T_g.path); H5T_g.npaths = 0; H5T_g.apaths = 0; - H5T_g.soft = (H5T_soft_t *)H5MM_xfree(H5T_g.soft); - H5T_g.nsoft = 0; - H5T_g.asoft = 0; + H5T_g.soft = (H5T_soft_t *)H5MM_xfree(H5T_g.soft); + H5T_g.nsoft = 0; + H5T_g.asoft = 0; n++; } /* end if */ @@ -1479,121 +1610,120 @@ H5T_top_term_package(void) H5I_iterate(H5I_DATATYPE, H5T__unlock_cb, &n, FALSE); /* Release all datatype IDs */ - if(H5I_nmembers(H5I_DATATYPE) > 0) { + if (H5I_nmembers(H5I_DATATYPE) > 0) { (void)H5I_clear_type(H5I_DATATYPE, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Reset all the datatype IDs */ - if(H5T_IEEE_F32BE_g > 0) { - H5T_IEEE_F32BE_g = FAIL; - H5T_IEEE_F32LE_g = FAIL; - H5T_IEEE_F64BE_g = FAIL; - H5T_IEEE_F64LE_g = FAIL; - - H5T_STD_I8BE_g = FAIL; - H5T_STD_I8LE_g = FAIL; - H5T_STD_I16BE_g = FAIL; - H5T_STD_I16LE_g = FAIL; - H5T_STD_I32BE_g = FAIL; - H5T_STD_I32LE_g = FAIL; - H5T_STD_I64BE_g = FAIL; - H5T_STD_I64LE_g = FAIL; - H5T_STD_U8BE_g = FAIL; - H5T_STD_U8LE_g = FAIL; - H5T_STD_U16BE_g = FAIL; - H5T_STD_U16LE_g = FAIL; - H5T_STD_U32BE_g = FAIL; - H5T_STD_U32LE_g = FAIL; - H5T_STD_U64BE_g = FAIL; - H5T_STD_U64LE_g = FAIL; - H5T_STD_B8BE_g = FAIL; - H5T_STD_B8LE_g = FAIL; - H5T_STD_B16BE_g = FAIL; - H5T_STD_B16LE_g = FAIL; - H5T_STD_B32BE_g = FAIL; - H5T_STD_B32LE_g = FAIL; - H5T_STD_B64BE_g = FAIL; - H5T_STD_B64LE_g = FAIL; - H5T_STD_REF_OBJ_g = FAIL; - H5T_STD_REF_DSETREG_g = FAIL; - H5T_STD_REF_g = FAIL; - - H5T_UNIX_D32BE_g = FAIL; - H5T_UNIX_D32LE_g = FAIL; - H5T_UNIX_D64BE_g = FAIL; - H5T_UNIX_D64LE_g = FAIL; - - H5T_C_S1_g = FAIL; - - H5T_FORTRAN_S1_g = FAIL; - - H5T_NATIVE_SCHAR_g = FAIL; - H5T_NATIVE_UCHAR_g = FAIL; - H5T_NATIVE_SHORT_g = FAIL; - H5T_NATIVE_USHORT_g = FAIL; - H5T_NATIVE_INT_g = FAIL; - H5T_NATIVE_UINT_g = FAIL; - H5T_NATIVE_LONG_g = FAIL; - H5T_NATIVE_ULONG_g = FAIL; - H5T_NATIVE_LLONG_g = FAIL; - H5T_NATIVE_ULLONG_g = FAIL; - H5T_NATIVE_FLOAT_g = FAIL; - H5T_NATIVE_DOUBLE_g = FAIL; -#if H5_SIZEOF_LONG_DOUBLE !=0 - H5T_NATIVE_LDOUBLE_g = FAIL; + if (H5T_IEEE_F32BE_g > 0) { + H5T_IEEE_F32BE_g = FAIL; + H5T_IEEE_F32LE_g = FAIL; + H5T_IEEE_F64BE_g = FAIL; + H5T_IEEE_F64LE_g = FAIL; + + H5T_STD_I8BE_g = FAIL; + H5T_STD_I8LE_g = FAIL; + H5T_STD_I16BE_g = FAIL; + H5T_STD_I16LE_g = FAIL; + H5T_STD_I32BE_g = FAIL; + H5T_STD_I32LE_g = FAIL; + H5T_STD_I64BE_g = FAIL; + H5T_STD_I64LE_g = FAIL; + H5T_STD_U8BE_g = FAIL; + H5T_STD_U8LE_g = FAIL; + H5T_STD_U16BE_g = FAIL; + H5T_STD_U16LE_g = FAIL; + H5T_STD_U32BE_g = FAIL; + H5T_STD_U32LE_g = FAIL; + H5T_STD_U64BE_g = FAIL; + H5T_STD_U64LE_g = FAIL; + H5T_STD_B8BE_g = FAIL; + H5T_STD_B8LE_g = FAIL; + H5T_STD_B16BE_g = FAIL; + H5T_STD_B16LE_g = FAIL; + H5T_STD_B32BE_g = FAIL; + H5T_STD_B32LE_g = FAIL; + H5T_STD_B64BE_g = FAIL; + H5T_STD_B64LE_g = FAIL; + H5T_STD_REF_OBJ_g = FAIL; + H5T_STD_REF_DSETREG_g = FAIL; + H5T_STD_REF_g = FAIL; + + H5T_UNIX_D32BE_g = FAIL; + H5T_UNIX_D32LE_g = FAIL; + H5T_UNIX_D64BE_g = FAIL; + H5T_UNIX_D64LE_g = FAIL; + + H5T_C_S1_g = FAIL; + + H5T_FORTRAN_S1_g = FAIL; + + H5T_NATIVE_SCHAR_g = FAIL; + H5T_NATIVE_UCHAR_g = FAIL; + H5T_NATIVE_SHORT_g = FAIL; + H5T_NATIVE_USHORT_g = FAIL; + H5T_NATIVE_INT_g = FAIL; + H5T_NATIVE_UINT_g = FAIL; + H5T_NATIVE_LONG_g = FAIL; + H5T_NATIVE_ULONG_g = FAIL; + H5T_NATIVE_LLONG_g = FAIL; + H5T_NATIVE_ULLONG_g = FAIL; + H5T_NATIVE_FLOAT_g = FAIL; + H5T_NATIVE_DOUBLE_g = FAIL; +#if H5_SIZEOF_LONG_DOUBLE != 0 + H5T_NATIVE_LDOUBLE_g = FAIL; #endif - H5T_NATIVE_B8_g = FAIL; - H5T_NATIVE_B16_g = FAIL; - H5T_NATIVE_B32_g = FAIL; - H5T_NATIVE_B64_g = FAIL; - H5T_NATIVE_OPAQUE_g = FAIL; - H5T_NATIVE_HADDR_g = FAIL; - H5T_NATIVE_HSIZE_g = FAIL; - H5T_NATIVE_HSSIZE_g = FAIL; - H5T_NATIVE_HERR_g = FAIL; - H5T_NATIVE_HBOOL_g = FAIL; - - H5T_NATIVE_INT8_g = FAIL; - H5T_NATIVE_UINT8_g = FAIL; - H5T_NATIVE_INT_LEAST8_g = FAIL; - H5T_NATIVE_UINT_LEAST8_g = FAIL; - H5T_NATIVE_INT_FAST8_g = FAIL; - H5T_NATIVE_UINT_FAST8_g = FAIL; - - H5T_NATIVE_INT16_g = FAIL; - H5T_NATIVE_UINT16_g = FAIL; - H5T_NATIVE_INT_LEAST16_g = FAIL; - H5T_NATIVE_UINT_LEAST16_g = FAIL; - H5T_NATIVE_INT_FAST16_g = FAIL; - H5T_NATIVE_UINT_FAST16_g = FAIL; - - H5T_NATIVE_INT32_g = FAIL; - H5T_NATIVE_UINT32_g = FAIL; - H5T_NATIVE_INT_LEAST32_g = FAIL; - H5T_NATIVE_UINT_LEAST32_g = FAIL; - H5T_NATIVE_INT_FAST32_g = FAIL; - H5T_NATIVE_UINT_FAST32_g = FAIL; - - H5T_NATIVE_INT64_g = FAIL; - H5T_NATIVE_UINT64_g = FAIL; - H5T_NATIVE_INT_LEAST64_g = FAIL; - H5T_NATIVE_UINT_LEAST64_g = FAIL; - H5T_NATIVE_INT_FAST64_g = FAIL; - H5T_NATIVE_UINT_FAST64_g = FAIL; + H5T_NATIVE_B8_g = FAIL; + H5T_NATIVE_B16_g = FAIL; + H5T_NATIVE_B32_g = FAIL; + H5T_NATIVE_B64_g = FAIL; + H5T_NATIVE_OPAQUE_g = FAIL; + H5T_NATIVE_HADDR_g = FAIL; + H5T_NATIVE_HSIZE_g = FAIL; + H5T_NATIVE_HSSIZE_g = FAIL; + H5T_NATIVE_HERR_g = FAIL; + H5T_NATIVE_HBOOL_g = FAIL; + + H5T_NATIVE_INT8_g = FAIL; + H5T_NATIVE_UINT8_g = FAIL; + H5T_NATIVE_INT_LEAST8_g = FAIL; + H5T_NATIVE_UINT_LEAST8_g = FAIL; + H5T_NATIVE_INT_FAST8_g = FAIL; + H5T_NATIVE_UINT_FAST8_g = FAIL; + + H5T_NATIVE_INT16_g = FAIL; + H5T_NATIVE_UINT16_g = FAIL; + H5T_NATIVE_INT_LEAST16_g = FAIL; + H5T_NATIVE_UINT_LEAST16_g = FAIL; + H5T_NATIVE_INT_FAST16_g = FAIL; + H5T_NATIVE_UINT_FAST16_g = FAIL; + + H5T_NATIVE_INT32_g = FAIL; + H5T_NATIVE_UINT32_g = FAIL; + H5T_NATIVE_INT_LEAST32_g = FAIL; + H5T_NATIVE_UINT_LEAST32_g = FAIL; + H5T_NATIVE_INT_FAST32_g = FAIL; + H5T_NATIVE_UINT_FAST32_g = FAIL; + + H5T_NATIVE_INT64_g = FAIL; + H5T_NATIVE_UINT64_g = FAIL; + H5T_NATIVE_INT_LEAST64_g = FAIL; + H5T_NATIVE_UINT_LEAST64_g = FAIL; + H5T_NATIVE_INT_FAST64_g = FAIL; + H5T_NATIVE_UINT_FAST64_g = FAIL; n++; } /* end if */ - /* Mark "top" of interface as closed */ - if(0 == n) + /* Mark "top" of interface as closed */ + if (0 == n) H5T_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5T_top_term_package() */ - /*------------------------------------------------------------------------- * Function: H5T_term_package * @@ -1615,11 +1745,11 @@ H5T_top_term_package(void) int H5T_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity check */ HDassert(0 == H5I_nmembers(H5I_DATATYPE)); HDassert(FALSE == H5T_top_package_initialize_s); @@ -1628,14 +1758,13 @@ H5T_term_package(void) n += (H5I_dec_type_ref(H5I_DATATYPE) > 0); /* Mark interface as closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5T_term_package() */ - /*------------------------------------------------------------------------- * Function: H5T__close_cb * @@ -1648,7 +1777,7 @@ H5T_term_package(void) static herr_t H5T__close_cb(H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1659,26 +1788,25 @@ H5T__close_cb(H5T_t *dt) /* If this datatype is VOL-managed (i.e.: has a VOL object), * close it through the VOL connector. */ - if(NULL != dt->vol_obj) { + if (NULL != dt->vol_obj) { /* Close the connector-managed datatype data */ - if(H5VL_datatype_close(dt->vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_datatype_close(dt->vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") /* Free the VOL object */ - if(H5VL_free_object(dt->vol_obj) < 0) + if (H5VL_free_object(dt->vol_obj) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") dt->vol_obj = NULL; } /* end if */ /* Close the datatype */ - if(H5T_close(dt) < 0) + if (H5T_close(dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__close_cb() */ - /*------------------------------------------------------------------------- * Function: H5Tcreate * @@ -1701,29 +1829,28 @@ done: hid_t H5Tcreate(H5T_class_t type, size_t size) { - H5T_t *dt = NULL; /* New datatype constructed */ - hid_t ret_value; /* Return value */ + H5T_t *dt = NULL; /* New datatype constructed */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "Ttz", type, size); /* check args. We support string (fixed-size or variable-length) now. */ - if(size <= 0 && size != H5T_VARIABLE) + if (size <= 0 && size != H5T_VARIABLE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive") /* create the type */ - if(NULL == (dt = H5T__create(type, size))) + if (NULL == (dt = H5T__create(type, size))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type") /* Get an ID for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype ID") done: FUNC_LEAVE_API(ret_value) } /* end H5Tcreate() */ - /*------------------------------------------------------------------------- * Function: H5Tcopy * @@ -1745,40 +1872,41 @@ done: hid_t H5Tcopy(hid_t obj_id) { - H5T_t *dt = NULL; /* Pointer to the datatype to copy */ - H5T_t *new_dt = NULL; /* Pointer to the new datatype */ - hid_t dset_tid = H5I_INVALID_HID; /* Datatype ID from dataset */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5T_t *dt = NULL; /* Pointer to the datatype to copy */ + H5T_t *new_dt = NULL; /* Pointer to the new datatype */ + hid_t dset_tid = H5I_INVALID_HID; /* Datatype ID from dataset */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", obj_id); - switch(H5I_get_type(obj_id)) { + switch (H5I_get_type(obj_id)) { case H5I_DATATYPE: /* The argument is a datatype handle */ - if(NULL == (dt = (H5T_t *)H5I_object(obj_id))) + if (NULL == (dt = (H5T_t *)H5I_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "obj_id is not a datatype ID") break; - case H5I_DATASET: - { - H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + case H5I_DATASET: { + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ /* The argument is a dataset handle */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(obj_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(obj_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "type_id is not a dataset ID") /* Get the datatype from the dataset * NOTE: This will have to be closed after we're done with it. */ - if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &dset_tid) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype from the dataset") + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &dset_tid) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, + "unable to get datatype from the dataset") /* Unwrap the type ID */ - if(NULL == (dt = (H5T_t *)H5I_object(dset_tid))) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "received invalid datatype from the dataset") - } - break; + if (NULL == (dt = (H5T_t *)H5I_object(dset_tid))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, + "received invalid datatype from the dataset") + } break; case H5I_UNINIT: case H5I_BADID: @@ -1801,29 +1929,28 @@ H5Tcopy(hid_t obj_id) } /* end switch */ /* Copy datatype */ - if(NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT))) + if (NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy"); /* Get an ID for the copied datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype atom") done: /* If we got a type ID from a passed-in dataset, we need to close that */ - if(dset_tid != H5I_INVALID_HID) - if(H5I_dec_app_ref(dset_tid) < 0) + if (dset_tid != H5I_INVALID_HID) + if (H5I_dec_app_ref(dset_tid) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADATOM, FAIL, "problem freeing temporary dataset type ID") /* Close the new datatype on errors */ - if(H5I_INVALID_HID == ret_value) - if(new_dt && H5T_close_real(new_dt) < 0) + if (H5I_INVALID_HID == ret_value) + if (new_dt && H5T_close_real(new_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release datatype info") FUNC_LEAVE_API(ret_value) } /* end H5Tcopy() */ - /*------------------------------------------------------------------------- * Function: H5Tclose * @@ -1838,27 +1965,26 @@ done: herr_t H5Tclose(hid_t type_id) { - H5T_t *dt; /* Pointer to datatype to close */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Pointer to datatype to close */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_IMMUTABLE == dt->shared->state) + if (H5T_STATE_IMMUTABLE == dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") /* When the reference count reaches zero the resources are freed */ - if(H5I_dec_app_ref(type_id) < 0) + if (H5I_dec_app_ref(type_id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") done: FUNC_LEAVE_API(ret_value) } /* end H5Tclose() */ - /*------------------------------------------------------------------------- * Function: H5Tequal * @@ -1876,17 +2002,17 @@ done: htri_t H5Tequal(hid_t type1_id, hid_t type2_id) { - const H5T_t *dt1; /* Pointer to first datatype */ - const H5T_t *dt2; /* Pointer to second datatype */ - htri_t ret_value; /* Return value */ + const H5T_t *dt1; /* Pointer to first datatype */ + const H5T_t *dt2; /* Pointer to second datatype */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", type1_id, type2_id); /* check args */ - if(NULL == (dt1 = (H5T_t *)H5I_object_verify(type1_id, H5I_DATATYPE))) + if (NULL == (dt1 = (H5T_t *)H5I_object_verify(type1_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == (dt2 = (H5T_t *)H5I_object_verify(type2_id, H5I_DATATYPE))) + if (NULL == (dt2 = (H5T_t *)H5I_object_verify(type2_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") ret_value = (0 == H5T_cmp(dt1, dt2, FALSE)) ? TRUE : FALSE; @@ -1895,7 +2021,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tequal() */ - /*------------------------------------------------------------------------- * Function: H5Tlock * @@ -1923,26 +2048,25 @@ done: herr_t H5Tlock(hid_t type_id) { - H5T_t *dt; /* Datatype to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) + if (H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to lock named datatype") - if(H5T_lock(dt, TRUE) < 0) + if (H5T_lock(dt, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tlock() */ - /*------------------------------------------------------------------------- * Function: H5Tget_class * @@ -1960,14 +2084,14 @@ done: H5T_class_t H5Tget_class(hid_t type_id) { - H5T_t *dt; /* Pointer to datatype */ - H5T_class_t ret_value; /* Return value */ + H5T_t * dt; /* Pointer to datatype */ + H5T_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NO_CLASS) H5TRACE1("Tt", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a datatype") /* Set return value */ @@ -1977,7 +2101,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_class() */ - /*------------------------------------------------------------------------- * Function: H5T_get_class * @@ -1998,27 +2121,26 @@ done: H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal) { - H5T_class_t ret_value = H5T_NO_CLASS; /* Return value */ + H5T_class_t ret_value = H5T_NO_CLASS; /* Return value */ FUNC_ENTER_NOAPI(H5T_NO_CLASS) HDassert(dt); /* Externally, a VL string is a string; internally, a VL string is a VL. */ - if(internal) { - ret_value=dt->shared->type; + if (internal) { + ret_value = dt->shared->type; } else { - if(H5T_IS_VL_STRING(dt->shared)) - ret_value=H5T_STRING; + if (H5T_IS_VL_STRING(dt->shared)) + ret_value = H5T_STRING; else - ret_value=dt->shared->type; + ret_value = dt->shared->type; } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_get_class() */ - +} /* end H5T_get_class() */ /*------------------------------------------------------------------------- * Function: H5Tdetect_class @@ -2035,27 +2157,26 @@ done: htri_t H5Tdetect_class(hid_t type, H5T_class_t cls) { - H5T_t *dt; /* Datatype to query */ - htri_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "iTt", type, cls); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a datatype") - if(!(cls > H5T_NO_CLASS && cls < H5T_NCLASSES)) + if (!(cls > H5T_NO_CLASS && cls < H5T_NCLASSES)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a datatype class") /* Set return value */ - if((ret_value = H5T_detect_class(dt, cls, TRUE)) < 0) + if ((ret_value = H5T_detect_class(dt, cls, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5T_NO_CLASS, "can't get datatype class") done: FUNC_LEAVE_API(ret_value) } /* end H5Tdetect_class() */ - /*------------------------------------------------------------------------- * Function: H5T_detect_class * @@ -2072,8 +2193,8 @@ done: htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api) { - unsigned i; - htri_t ret_value = FALSE; /* Return value */ + unsigned i; + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2085,26 +2206,27 @@ H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api) * string belongs to the H5T_VLEN class, which would otherwise return * true. -QAK) */ - if(from_api && H5T_IS_VL_STRING(dt->shared)) + if (from_api && H5T_IS_VL_STRING(dt->shared)) HGOTO_DONE(H5T_STRING == cls); /* Check if this type is the correct type */ - if(dt->shared->type == cls) + if (dt->shared->type == cls) HGOTO_DONE(TRUE); /* check for types that might have the correct type as a component */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - htri_t nested_ret; /* Return value from nested call */ + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + htri_t nested_ret; /* Return value from nested call */ /* Check if this field's type is the correct type */ - if(dt->shared->u.compnd.memb[i].type->shared->type == cls) + if (dt->shared->u.compnd.memb[i].type->shared->type == cls) HGOTO_DONE(TRUE); /* Recurse if it's VL, compound, enum or array */ - if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) - if((nested_ret = H5T_detect_class(dt->shared->u.compnd.memb[i].type, cls, from_api)) != FALSE) + if (H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) + if ((nested_ret = H5T_detect_class(dt->shared->u.compnd.memb[i].type, cls, from_api)) != + FALSE) HGOTO_DONE(nested_ret); } /* end for */ break; @@ -2131,7 +2253,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_detect_class() */ - /*------------------------------------------------------------------------- * Function: H5Tis_variable_str * @@ -2147,25 +2268,24 @@ done: htri_t H5Tis_variable_str(hid_t dtype_id) { - H5T_t *dt; /* Datatype to query */ - htri_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", dtype_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set return value */ - if((ret_value = H5T_is_variable_str(dt)) < 0) + if ((ret_value = H5T_is_variable_str(dt)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "can't determine if datatype is VL-string") done: FUNC_LEAVE_API(ret_value) } /* end H5Tis_variable_str() */ - /*------------------------------------------------------------------------- * Function: H5T_is_variable_str * @@ -2186,7 +2306,6 @@ H5T_is_variable_str(const H5T_t *dt) FUNC_LEAVE_NOAPI(H5T_IS_VL_STRING(dt->shared)) } /* end H5T_is_variable_str() */ - /*------------------------------------------------------------------------- * Function: H5Tget_size * @@ -2206,14 +2325,14 @@ H5T_is_variable_str(const H5T_t *dt) size_t H5Tget_size(hid_t type_id) { - H5T_t *dt; /* Datatype to query */ - size_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + size_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("z", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") /* size */ @@ -2223,7 +2342,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_size() */ - /*------------------------------------------------------------------------- * Function: H5Tset_size * @@ -2251,35 +2369,34 @@ done: herr_t H5Tset_size(hid_t type_id, size_t size) { - H5T_t *dt; /* Datatype to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, size); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") - if(size <= 0 && size != H5T_VARIABLE) + if (size <= 0 && size != H5T_VARIABLE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive") - if(size == H5T_VARIABLE && !H5T_IS_STRING(dt->shared)) + if (size == H5T_VARIABLE && !H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "only strings may be variable length") - if(H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") - if(H5T_REFERENCE == dt->shared->type) + if (H5T_REFERENCE == dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for this datatype") /* Modify the datatype */ - if(H5T__set_size(dt, size) < 0) + if (H5T__set_size(dt, size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_size() */ - /*------------------------------------------------------------------------- * Function: H5Tget_super * @@ -2297,29 +2414,29 @@ done: hid_t H5Tget_super(hid_t type) { - H5T_t *dt; /* Datatype to query */ - H5T_t *super = NULL; /* Supertype */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5T_t *dt; /* Datatype to query */ + H5T_t *super = NULL; /* Supertype */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", type); - if(NULL == (dt = (H5T_t *)H5I_object_verify(type,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype") - if(NULL == (super = H5T_get_super(dt))) + if (NULL == (super = H5T_get_super(dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "not a datatype") - if((ret_value = H5I_register(H5I_DATATYPE, super, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, super, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register parent datatype") done: - if(H5I_INVALID_HID == ret_value) - if(super && H5T_close_real(super) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release super datatype info") + if (H5I_INVALID_HID == ret_value) + if (super && H5T_close_real(super) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, + "unable to release super datatype info") FUNC_LEAVE_API(ret_value) } /* end H5Tget_super() */ - /*------------------------------------------------------------------------- * Function: H5T_get_super * @@ -2344,16 +2461,15 @@ H5T_get_super(const H5T_t *dt) HDassert(dt); - if(!dt->shared->parent) + if (!dt->shared->parent) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type"); - if(NULL == (ret_value = H5T_copy(dt->shared->parent, H5T_COPY_ALL))) + if (NULL == (ret_value = H5T_copy(dt->shared->parent, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_super() */ - /*------------------------------------------------------------------------- * Function: H5T__register_int * @@ -2366,11 +2482,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, - H5T_lib_conv_t func) +H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_lib_conv_t func) { - H5T_conv_func_t conv_func; /* Conversion function wrapper */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_conv_func_t conv_func; /* Conversion function wrapper */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2382,18 +2497,18 @@ H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, HDassert(func); /* Set up conversion function wrapper */ - conv_func.is_app = FALSE; + conv_func.is_app = FALSE; conv_func.u.lib_func = func; /* Register conversion */ - if(H5T__register(pers, name, src, dst, &conv_func) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register internal datatype conversion routine") + if (H5T__register(pers, name, src, dst, &conv_func) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to register internal datatype conversion routine") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__register_int() */ - /*------------------------------------------------------------------------- * Function: H5T__register * @@ -2413,16 +2528,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, - H5T_conv_func_t *conv) +H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_func_t *conv) { - hid_t tmp_sid = -1, tmp_did = -1; /*temporary data type IDs */ - H5T_path_t *old_path = NULL; /*existing conversion path */ - H5T_path_t *new_path = NULL; /*new conversion path */ - H5T_cdata_t cdata; /*temporary conversion data */ - int nprint=0; /*number of paths shut down */ - int i; /*counter */ - herr_t ret_value = SUCCEED; /*return value */ + hid_t tmp_sid = -1, tmp_did = -1; /*temporary data type IDs */ + H5T_path_t *old_path = NULL; /*existing conversion path */ + H5T_path_t *new_path = NULL; /*new conversion path */ + H5T_cdata_t cdata; /*temporary conversion data */ + int nprint = 0; /*number of paths shut down */ + int i; /*counter */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_STATIC @@ -2430,14 +2544,14 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, HDassert(src); HDassert(dst); HDassert(conv); - HDassert(H5T_PERS_HARD==pers || H5T_PERS_SOFT==pers); + HDassert(H5T_PERS_HARD == pers || H5T_PERS_SOFT == pers); HDassert(name && *name); - if(H5T_PERS_HARD == pers) { + if (H5T_PERS_HARD == pers) { /* Only bother to register the path if it's not a no-op path (for this machine) */ - if(H5T_cmp(src, dst, FALSE)) { + if (H5T_cmp(src, dst, FALSE)) { /* Locate or create a new conversion path */ - if(NULL == (new_path = H5T__path_find_real(src, dst, name, conv))) + if (NULL == (new_path = H5T__path_find_real(src, dst, name, conv))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to locate/allocate conversion path") /* Notify all other functions to recalculate private data since some @@ -2446,27 +2560,27 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, * functions for the members, so adding a new function should cause * the list to be recalculated to use the new function. */ - for(i = 0; i < H5T_g.npaths; i++) - if(new_path != H5T_g.path[i]) + for (i = 0; i < H5T_g.npaths; i++) + if (new_path != H5T_g.path[i]) H5T_g.path[i]->cdata.recalc = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Add function to end of soft list */ - if((size_t)H5T_g.nsoft >= H5T_g.asoft) { - size_t na = MAX(32, 2 * H5T_g.asoft); + if ((size_t)H5T_g.nsoft >= H5T_g.asoft) { + size_t na = MAX(32, 2 * H5T_g.asoft); H5T_soft_t *x; - if(NULL == (x = (H5T_soft_t *)H5MM_realloc(H5T_g.soft, na * sizeof(H5T_soft_t)))) + if (NULL == (x = (H5T_soft_t *)H5MM_realloc(H5T_g.soft, na * sizeof(H5T_soft_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") H5T_g.asoft = na; - H5T_g.soft = x; + H5T_g.soft = x; } /* end if */ HDstrncpy(H5T_g.soft[H5T_g.nsoft].name, name, (size_t)H5T_NAMELEN); H5T_g.soft[H5T_g.nsoft].name[H5T_NAMELEN - 1] = '\0'; - H5T_g.soft[H5T_g.nsoft].src = src->shared->type; - H5T_g.soft[H5T_g.nsoft].dst = dst->shared->type; - H5T_g.soft[H5T_g.nsoft].conv = *conv; + H5T_g.soft[H5T_g.nsoft].src = src->shared->type; + H5T_g.soft[H5T_g.nsoft].dst = dst->shared->type; + H5T_g.soft[H5T_g.nsoft].conv = *conv; H5T_g.nsoft++; /* @@ -2474,77 +2588,81 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, * conversion function applies should be replaced by a new path that * uses this function. */ - for(i = 1; i < H5T_g.npaths; i++) { + for (i = 1; i < H5T_g.npaths; i++) { old_path = H5T_g.path[i]; HDassert(old_path); /* Does the new soft conversion function apply to this path? */ - if(old_path->is_hard || - old_path->src->shared->type != src->shared->type || - old_path->dst->shared->type != dst->shared->type) + if (old_path->is_hard || old_path->src->shared->type != src->shared->type || + old_path->dst->shared->type != dst->shared->type) continue; - if((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE)) < 0 || - (tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data types for conv query") + if ((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE)) < 0 || + (tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, + "unable to register data types for conv query") HDmemset(&cdata, 0, sizeof cdata); cdata.command = H5T_CONV_INIT; - if(conv->is_app) { - if((conv->u.app_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (conv->is_app) { + if ((conv->u.app_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL, + H5CX_get_dxpl()) < 0) { H5I_dec_ref(tmp_sid); H5I_dec_ref(tmp_did); tmp_sid = tmp_did = -1; H5E_clear_stack(NULL); continue; } /* end if */ + } /* end if */ + else if ((conv->u.lib_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, + NULL) < 0) { + H5I_dec_ref(tmp_sid); + H5I_dec_ref(tmp_did); + tmp_sid = tmp_did = -1; + H5E_clear_stack(NULL); + continue; } /* end if */ - else - if((conv->u.lib_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { - H5I_dec_ref(tmp_sid); - H5I_dec_ref(tmp_did); - tmp_sid = tmp_did = -1; - H5E_clear_stack(NULL); - continue; - } /* end if */ /* Create a new conversion path */ - if(NULL == (new_path = H5FL_CALLOC(H5T_path_t))) + if (NULL == (new_path = H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrncpy(new_path->name, name, (size_t)H5T_NAMELEN); new_path->name[H5T_NAMELEN - 1] = '\0'; - if(NULL == (new_path->src = H5T_copy(old_path->src, H5T_COPY_ALL)) || - NULL == (new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL))) + if (NULL == (new_path->src = H5T_copy(old_path->src, H5T_COPY_ALL)) || + NULL == (new_path->dst = H5T_copy(old_path->dst, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types") - new_path->conv = *conv; + new_path->conv = *conv; new_path->is_hard = FALSE; - new_path->cdata = cdata; + new_path->cdata = cdata; /* Replace previous path */ H5T_g.path[i] = new_path; - new_path = NULL; /*so we don't free it on error*/ + new_path = NULL; /*so we don't free it on error*/ /* Free old path */ H5T__print_stats(old_path, &nprint); old_path->cdata.command = H5T_CONV_FREE; - if(old_path->conv.is_app) { - if((old_path->conv.u.app_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (old_path->conv.is_app) { + if ((old_path->conv.u.app_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx " - "failed to free private data for %s (ignored)\n", - (unsigned long)(old_path->conv.u.app_func), old_path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), + "H5T: conversion function 0x%08lx " + "failed to free private data for %s (ignored)\n", + (unsigned long)(old_path->conv.u.app_func), old_path->name); #endif } /* end if */ - } /* end if */ - else - if((old_path->conv.u.lib_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + } /* end if */ + else if ((old_path->conv.u.lib_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf (H5DEBUG(T), "H5T: conversion function 0x%08lx " - "failed to free private data for %s (ignored)\n", - (unsigned long)(old_path->conv.u.lib_func), old_path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), + "H5T: conversion function 0x%08lx " + "failed to free private data for %s (ignored)\n", + (unsigned long)(old_path->conv.u.lib_func), old_path->name); #endif - } /* end if */ + } /* end if */ (void)H5T_close_real(old_path->src); (void)H5T_close_real(old_path->dst); old_path = H5FL_FREE(H5T_path_t, old_path); @@ -2557,27 +2675,26 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, /* We don't care about any failures during the freeing process */ H5E_clear_stack(NULL); } /* end for */ - } /* end else */ + } /* end else */ done: - if(ret_value < 0) { - if(new_path) { - if(new_path->src) - (void)H5T_close_real(new_path->src); - if(new_path->dst) - (void)H5T_close_real(new_path->dst); - new_path = H5FL_FREE(H5T_path_t, new_path); + if (ret_value < 0) { + if (new_path) { + if (new_path->src) + (void)H5T_close_real(new_path->src); + if (new_path->dst) + (void)H5T_close_real(new_path->dst); + new_path = H5FL_FREE(H5T_path_t, new_path); } /* end if */ - if(tmp_sid >= 0) - H5I_dec_ref(tmp_sid); - if(tmp_did >= 0) - H5I_dec_ref(tmp_did); + if (tmp_sid >= 0) + H5I_dec_ref(tmp_sid); + if (tmp_did >= 0) + H5I_dec_ref(tmp_did); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__register() */ - /*------------------------------------------------------------------------- * Function: H5Tregister * @@ -2598,42 +2715,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, - H5T_conv_t func) +H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func) { - H5T_t *src; /*source data type descriptor */ - H5T_t *dst; /*destination data type desc */ - H5T_conv_func_t conv_func; /* Conversion function wrapper */ - herr_t ret_value = SUCCEED; /*return value */ + H5T_t * src; /*source data type descriptor */ + H5T_t * dst; /*destination data type desc */ + H5T_conv_func_t conv_func; /* Conversion function wrapper */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "Te*siix", pers, name, src_id, dst_id, func); /* Check args */ - if(H5T_PERS_HARD != pers && H5T_PERS_SOFT != pers) + if (H5T_PERS_HARD != pers && H5T_PERS_SOFT != pers) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid function persistence") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conversion must have a name for debugging") - if(NULL == (src = (H5T_t *)H5I_object_verify(src_id,H5I_DATATYPE))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(NULL == (dst = (H5T_t *)H5I_object_verify(dst_id,H5I_DATATYPE))) + if (NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(!func) + if (!func) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no conversion function specified") /* Set up conversion function wrapper */ - conv_func.is_app = TRUE; + conv_func.is_app = TRUE; conv_func.u.app_func = func; /* Go register the function */ - if(H5T__register(pers, name, src, dst, &conv_func) < 0) + if (H5T__register(pers, name, src, dst, &conv_func) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't register conversion function") done: FUNC_LEAVE_API(ret_value) } /* end H5Tregister() */ - /*------------------------------------------------------------------------- * Function: H5T__unregister * @@ -2650,47 +2765,44 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, - H5T_conv_t func) +H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func) { - H5T_path_t *path = NULL; /*conversion path */ - H5T_soft_t *soft = NULL; /*soft conversion information */ - int nprint = 0; /*number of paths shut down */ - int i; /*counter */ + H5T_path_t *path = NULL; /*conversion path */ + H5T_soft_t *soft = NULL; /*soft conversion information */ + int nprint = 0; /*number of paths shut down */ + int i; /*counter */ FUNC_ENTER_STATIC_NOERR /* Remove matching entries from the soft list */ - if(H5T_PERS_DONTCARE == pers || H5T_PERS_SOFT == pers) { - for(i = H5T_g.nsoft - 1; i >= 0; --i) { + if (H5T_PERS_DONTCARE == pers || H5T_PERS_SOFT == pers) { + for (i = H5T_g.nsoft - 1; i >= 0; --i) { soft = H5T_g.soft + i; HDassert(soft); - if(name && *name && HDstrcmp(name, soft->name)) + if (name && *name && HDstrcmp(name, soft->name)) continue; - if(src && src->shared->type != soft->src) + if (src && src->shared->type != soft->src) continue; - if(dst && dst->shared->type != soft->dst) + if (dst && dst->shared->type != soft->dst) continue; - if(func && func != soft->conv.u.app_func) + if (func && func != soft->conv.u.app_func) continue; - HDmemmove(H5T_g.soft + i, H5T_g.soft + i + 1, (size_t)(H5T_g.nsoft - (i + 1)) * sizeof(H5T_soft_t)); + HDmemmove(H5T_g.soft + i, H5T_g.soft + i + 1, + (size_t)(H5T_g.nsoft - (i + 1)) * sizeof(H5T_soft_t)); --H5T_g.nsoft; } /* end for */ - } /* end if */ + } /* end if */ /* Remove matching conversion paths, except no-op path */ - for(i = H5T_g.npaths - 1; i > 0; --i) { + for (i = H5T_g.npaths - 1; i > 0; --i) { path = H5T_g.path[i]; HDassert(path); /* Not a match */ - if(((H5T_PERS_SOFT == pers && path->is_hard) || - (H5T_PERS_HARD == pers && !path->is_hard)) || - (name && *name && HDstrcmp(name, path->name)) || - (src && H5T_cmp(src, path->src, FALSE)) || - (dst && H5T_cmp(dst, path->dst, FALSE)) || - (func && func != path->conv.u.app_func)) { + if (((H5T_PERS_SOFT == pers && path->is_hard) || (H5T_PERS_HARD == pers && !path->is_hard)) || + (name && *name && HDstrcmp(name, path->name)) || (src && H5T_cmp(src, path->src, FALSE)) || + (dst && H5T_cmp(dst, path->dst, FALSE)) || (func && func != path->conv.u.app_func)) { /* * Notify all other functions to recalculate private data since some * functions might cache a list of conversion functions. For @@ -2702,42 +2814,45 @@ H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, } /* end if */ else { /* Remove from table */ - HDmemmove(H5T_g.path + i, H5T_g.path + i + 1, (size_t)(H5T_g.npaths - (i + 1)) * sizeof(H5T_path_t*)); + HDmemmove(H5T_g.path + i, H5T_g.path + i + 1, + (size_t)(H5T_g.npaths - (i + 1)) * sizeof(H5T_path_t *)); --H5T_g.npaths; /* Shut down path */ H5T__print_stats(path, &nprint); path->cdata.command = H5T_CONV_FREE; - if(path->conv.is_app) { - if((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (path->conv.is_app) { + if ((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed " - "to free private data for %s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), + "H5T: conversion function 0x%08lx failed " + "to free private data for %s (ignored)\n", + (unsigned long)(path->conv.u.app_func), path->name); #endif } /* end if */ - } /* end if */ - else - if((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + } /* end if */ + else if ((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed " - "to free private data for %s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), + "H5T: conversion function 0x%08lx failed " + "to free private data for %s (ignored)\n", + (unsigned long)(path->conv.u.lib_func), path->name); #endif - } /* end if */ + } /* end if */ (void)H5T_close_real(path->src); (void)H5T_close_real(path->dst); path = H5FL_FREE(H5T_path_t, path); H5E_clear_stack(NULL); /*ignore all shutdown errors*/ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__unregister() */ - /*------------------------------------------------------------------------- * Function: H5Tunregister * @@ -2755,29 +2870,27 @@ H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, *------------------------------------------------------------------------- */ herr_t -H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, - H5T_conv_t func) +H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func) { - H5T_t *src = NULL, *dst = NULL; /* Datatype descriptors */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *src = NULL, *dst = NULL; /* Datatype descriptors */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "Te*siix", pers, name, src_id, dst_id, func); /* Check arguments */ - if(src_id > 0 && (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)))) + if (src_id > 0 && (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src is not a data type") - if(dst_id > 0 && (NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE)))) + if (dst_id > 0 && (NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE)))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst is not a data type") - if(H5T__unregister(pers, name, src, dst, func) < 0) + if (H5T__unregister(pers, name, src, dst, func) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "internal unregister function failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Tunregister() */ - /*------------------------------------------------------------------------- * Function: H5Tfind * @@ -2799,25 +2912,25 @@ done: H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) { - H5T_t *src, *dst; - H5T_path_t *path; - H5T_conv_t ret_value; /* Return value */ + H5T_t * src, *dst; + H5T_path_t *path; + H5T_conv_t ret_value; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE3("x", "ii**x", src_id, dst_id, pcdata); /* Check args */ - if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || - NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - if(!pcdata) + if (!pcdata) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no address to receive cdata pointer") /* Find it */ - if(NULL == (path = H5T_path_find(src, dst))) + if (NULL == (path = H5T_path_find(src, dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "conversion function not found") - if(pcdata) + if (pcdata) *pcdata = &(path->cdata); /* Set return value */ @@ -2827,7 +2940,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tfind() */ - /*------------------------------------------------------------------------- * Function: H5Tcompiler_conv * @@ -2848,26 +2960,25 @@ done: htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id) { - H5T_t *src, *dst; - htri_t ret_value; /* Return value */ + H5T_t *src, *dst; + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", src_id, dst_id); /* Check args */ - if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || - NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") /* Find it */ - if((ret_value = H5T__compiler_conv(src, dst)) < 0) + if ((ret_value = H5T__compiler_conv(src, dst)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "conversion function not found") done: FUNC_LEAVE_API(ret_value) } /* end H5Tcompiler_conv() */ - /*------------------------------------------------------------------------- * Function: H5Tconvert * @@ -2892,41 +3003,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, - void *background, hid_t dxpl_id) +H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t dxpl_id) { - H5T_path_t *tpath; /* type conversion info */ - H5T_t *src, *dst; /* unatomized types */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_path_t *tpath; /* type conversion info */ + H5T_t * src, *dst; /* unatomized types */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiz*x*xi", src_id, dst_id, nelmts, buf, background, dxpl_id); /* Check args */ - if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || - NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Find the conversion function */ - if(NULL == (tpath = H5T_path_find(src, dst))) + if (NULL == (tpath = H5T_path_find(src, dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types") - if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, buf, background) < 0) + if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, buf, background) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Tconvert() */ - /*------------------------------------------------------------------------- * Function: H5Treclaim * @@ -2945,26 +3053,25 @@ done: herr_t H5Treclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) { - H5S_t *space; /* Dataspace for iteration */ - herr_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace for iteration */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf); /* Check args */ - if(H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL) + if (H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") /* Get the default dataset transfer property list if the user didn't provide one */ - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; - else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); @@ -2974,8 +3081,7 @@ H5Treclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) done: FUNC_LEAVE_API(ret_value) -} /* end H5Treclaim() */ - +} /* end H5Treclaim() */ /*------------------------------------------------------------------------- * Function: H5Tencode @@ -2995,27 +3101,26 @@ done: herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc) { - H5T_t *dtype; - herr_t ret_value = SUCCEED; + H5T_t *dtype; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x*z", obj_id, buf, nalloc); /* Check argument and retrieve object */ - if(NULL == (dtype = (H5T_t *)H5I_object_verify(obj_id, H5I_DATATYPE))) + if (NULL == (dtype = (H5T_t *)H5I_object_verify(obj_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(nalloc == NULL) + if (nalloc == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL pointer for buffer size") /* Go encode the datatype */ - if(H5T_encode(dtype, (unsigned char *)buf, nalloc) < 0) + if (H5T_encode(dtype, (unsigned char *)buf, nalloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tencode() */ - /*------------------------------------------------------------------------- * Function: H5Tdecode * @@ -3038,14 +3143,14 @@ done: hid_t H5Tdecode(const void *buf) { - H5T_t *dt; - hid_t ret_value; /* Return value */ + H5T_t *dt; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "*x", buf); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty buffer") /* Create datatype by decoding buffer @@ -3054,11 +3159,11 @@ H5Tdecode(const void *buf) * Really fixing this will require an H5Tdecode2() call that * takes a size parameter. */ - if(NULL == (dt = H5T_decode(SIZE_MAX, (const unsigned char *)buf))) + if (NULL == (dt = H5T_decode(SIZE_MAX, (const unsigned char *)buf))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "can't decode object") /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type") done: @@ -3070,7 +3175,6 @@ done: *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: H5T_encode * @@ -3089,22 +3193,22 @@ done: herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc) { - size_t buf_size; /* Encoded size of datatype */ - H5F_t *f = NULL; /* Fake file structure*/ - herr_t ret_value = SUCCEED; + size_t buf_size; /* Encoded size of datatype */ + H5F_t *f = NULL; /* Fake file structure*/ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT /* Allocate "fake" file structure */ - if(NULL == (f = H5F_fake_alloc((uint8_t)0))) + if (NULL == (f = H5F_fake_alloc((uint8_t)0))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate fake file struct") /* Find out the size of buffer needed */ - if((buf_size = H5O_msg_raw_size(f, H5O_DTYPE_ID, TRUE, obj)) == 0) + if ((buf_size = H5O_msg_raw_size(f, H5O_DTYPE_ID, TRUE, obj)) == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "can't find datatype size") /* Don't encode if buffer size isn't big enough or buffer is empty */ - if(!buf || *nalloc < (buf_size + 1 + 1)) + if (!buf || *nalloc < (buf_size + 1 + 1)) *nalloc = buf_size + 1 + 1; else { /* Encode the type of the information */ @@ -3114,19 +3218,18 @@ H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc) *buf++ = H5T_ENCODE_VERSION; /* Encode into user's buffer */ - if(H5O_msg_encode(f, H5O_DTYPE_ID, TRUE, buf, obj) < 0) + if (H5O_msg_encode(f, H5O_DTYPE_ID, TRUE, buf, obj) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode object") } /* end else */ done: /* Release fake file structure */ - if(f && H5F_fake_free(f) < 0) + if (f && H5F_fake_free(f) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to release fake file struct") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_encode() */ - /*------------------------------------------------------------------------- * Function: H5T_decode * @@ -3145,42 +3248,41 @@ done: H5T_t * H5T_decode(size_t buf_size, const unsigned char *buf) { - H5F_t *f = NULL; /* Fake file structure*/ - H5T_t *ret_value = NULL; /* Return value */ + H5F_t *f = NULL; /* Fake file structure*/ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Allocate "fake" file structure */ - if(NULL == (f = H5F_fake_alloc((uint8_t)0))) + if (NULL == (f = H5F_fake_alloc((uint8_t)0))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "can't allocate fake file struct") /* Decode the type of the information */ - if(*buf++ != H5O_DTYPE_ID) + if (*buf++ != H5O_DTYPE_ID) HGOTO_ERROR(H5E_DATATYPE, H5E_BADMESG, NULL, "not an encoded datatype") /* Decode the version of the datatype information */ - if(*buf++ != H5T_ENCODE_VERSION) + if (*buf++ != H5T_ENCODE_VERSION) HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, NULL, "unknown version of encoded datatype") /* Decode the serialized datatype message */ - if(NULL == (ret_value = (H5T_t *)H5O_msg_decode(f, NULL, H5O_DTYPE_ID, buf_size, buf))) + if (NULL == (ret_value = (H5T_t *)H5O_msg_decode(f, NULL, H5O_DTYPE_ID, buf_size, buf))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object") /* Mark datatype as being in memory now */ - if(H5T_set_loc(ret_value, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(ret_value, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* No VOL object */ ret_value->vol_obj = NULL; done: /* Release fake file structure */ - if(f && H5F_fake_free(f) < 0) + if (f && H5F_fake_free(f) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release fake file struct") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_decode() */ - /*------------------------------------------------------------------------- * Function: H5T__create * @@ -3204,84 +3306,80 @@ done: H5T_t * H5T__create(H5T_class_t type, size_t size) { - H5T_t *dt = NULL; - H5T_t *ret_value = NULL; + H5T_t *dt = NULL; + H5T_t *ret_value = NULL; FUNC_ENTER_PACKAGE - switch(type) { + switch (type) { case H5T_INTEGER: case H5T_FLOAT: case H5T_TIME: - case H5T_STRING: - { - H5T_t *origin_dt = NULL; + case H5T_STRING: { + H5T_t *origin_dt = NULL; - if(NULL == (origin_dt = (H5T_t *)H5I_object(H5T_C_S1))) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "can't get structure for string type") + if (NULL == (origin_dt = (H5T_t *)H5I_object(H5T_C_S1))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "can't get structure for string type") - /* Copy the default string datatype */ - if(NULL == (dt = H5T_copy(origin_dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + /* Copy the default string datatype */ + if (NULL == (dt = H5T_copy(origin_dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); - /* Modify the datatype */ - if(H5T__set_size(dt, size) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to set size for string type") - } - break; + /* Modify the datatype */ + if (H5T__set_size(dt, size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to set size for string type") + } break; case H5T_BITFIELD: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "type class is not appropriate - use H5Tcopy()") case H5T_OPAQUE: case H5T_COMPOUND: - if(NULL == (dt = H5T__alloc())) + if (NULL == (dt = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") dt->shared->type = type; - if(type == H5T_COMPOUND) { - dt->shared->u.compnd.packed=FALSE; /* Start out unpacked */ - dt->shared->u.compnd.memb_size=0; + if (type == H5T_COMPOUND) { + dt->shared->u.compnd.packed = FALSE; /* Start out unpacked */ + dt->shared->u.compnd.memb_size = 0; } /* end if */ - else if(type == H5T_OPAQUE) + else if (type == H5T_OPAQUE) /* Initialize the tag in case it's not set later. A null tag will * cause problems for later operations. */ dt->shared->u.opaque.tag = H5MM_strdup(""); break; - case H5T_ENUM: - { - hid_t subtype; - H5T_t *sub_t_obj; - - if(sizeof(char) == size) - subtype = H5T_NATIVE_SCHAR_g; - else if(sizeof(short) == size) - subtype = H5T_NATIVE_SHORT_g; - else if(sizeof(int) == size) - subtype = H5T_NATIVE_INT_g; - else if(sizeof(long) == size) - subtype = H5T_NATIVE_LONG_g; + case H5T_ENUM: { + hid_t subtype; + H5T_t *sub_t_obj; + + if (sizeof(char) == size) + subtype = H5T_NATIVE_SCHAR_g; + else if (sizeof(short) == size) + subtype = H5T_NATIVE_SHORT_g; + else if (sizeof(int) == size) + subtype = H5T_NATIVE_INT_g; + else if (sizeof(long) == size) + subtype = H5T_NATIVE_LONG_g; #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if(sizeof(long long) == size) - subtype = H5T_NATIVE_LLONG_g; + else if (sizeof(long long) == size) + subtype = H5T_NATIVE_LLONG_g; #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ - else - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no applicable native integer type") - if(NULL == (dt = H5T__alloc())) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - dt->shared->type = type; - if(NULL == (sub_t_obj = (H5T_t *)H5I_object(subtype))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "unable to get datatype object") - if(NULL == (dt->shared->parent = H5T_copy(sub_t_obj, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy base datatype") - } - break; + else + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no applicable native integer type") + if (NULL == (dt = H5T__alloc())) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + dt->shared->type = type; + if (NULL == (sub_t_obj = (H5T_t *)H5I_object(subtype))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "unable to get datatype object") + if (NULL == (dt->shared->parent = H5T_copy(sub_t_obj, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy base datatype") + } break; - case H5T_VLEN: /* Variable length datatype */ + case H5T_VLEN: /* Variable length datatype */ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tvlen_create()") - case H5T_ARRAY: /* Array datatype */ + case H5T_ARRAY: /* Array datatype */ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tarray_create2()") case H5T_NO_CLASS: @@ -3292,7 +3390,7 @@ H5T__create(H5T_class_t type, size_t size) } /* end switch */ /* Set the size except VL string */ - if(H5T_STRING != type || H5T_VARIABLE != size) + if (H5T_STRING != type || H5T_VARIABLE != size) dt->shared->size = size; /* No VOL object */ @@ -3302,17 +3400,16 @@ H5T__create(H5T_class_t type, size_t size) ret_value = dt; done: - if(NULL == ret_value) { - if(dt) { + if (NULL == ret_value) { + if (dt) { dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); - dt = H5FL_FREE(H5T_t, dt); + dt = H5FL_FREE(H5T_t, dt); } } FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__create() */ - /*------------------------------------------------------------------------- * Function: H5T__initiate_copy * @@ -3333,31 +3430,31 @@ done: static H5T_t * H5T__initiate_copy(const H5T_t *old_dt) { - H5T_t *new_dt = NULL; /* Copy of datatype */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *new_dt = NULL; /* Copy of datatype */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space */ - if(NULL == (new_dt = H5FL_MALLOC(H5T_t))) + if (NULL == (new_dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "H5T_t memory allocation failed") - if(NULL == (new_dt->shared = H5FL_MALLOC(H5T_shared_t))) + if (NULL == (new_dt->shared = H5FL_MALLOC(H5T_shared_t))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "H5T_shared_t memory allocation failed") /* Copy shared information */ *(new_dt->shared) = *(old_dt->shared); /* Reset VOL fields */ - new_dt->vol_obj = NULL; + new_dt->vol_obj = NULL; new_dt->shared->owned_vol_obj = NULL; /* Set return value */ ret_value = new_dt; done: - if(ret_value == NULL) - if(new_dt) { - if(new_dt->shared) + if (ret_value == NULL) + if (new_dt) { + if (new_dt->shared) new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); new_dt = H5FL_FREE(H5T_t, new_dt); } /* end if */ @@ -3365,7 +3462,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__initiate_copy() */ - /*------------------------------------------------------------------------- * Function: H5T__copy_transient * @@ -3382,19 +3478,18 @@ done: static H5T_t * H5T__copy_transient(H5T_t *old_dt) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Copy datatype, with correct method */ - if(NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_TRANSIENT))) + if (NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't make 'transient' copy of datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__copy_transient() */ - /*------------------------------------------------------------------------- * Function: H5T__copy_all * @@ -3411,19 +3506,18 @@ done: static H5T_t * H5T__copy_all(H5T_t *old_dt) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Copy datatype, with correct method */ - if(NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_ALL))) + if (NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't make 'all' copy of datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__copy_transient() */ - /*------------------------------------------------------------------------- * Function: H5T__complete_copy * @@ -3441,126 +3535,137 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo, - hbool_t set_memory_type, H5T_copy_func_t copyfn) +H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo, hbool_t set_memory_type, + H5T_copy_func_t copyfn) { - H5T_t *tmp = NULL; /* Temporary copy of compound field's datatype */ - char *s; /* Temporary copy of compound field name / enum value name */ - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * tmp = NULL; /* Temporary copy of compound field's datatype */ + char * s; /* Temporary copy of compound field name / enum value name */ + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Update fields in the new struct, if we aren't sharing an already opened * committed datatype */ - if(!reopened_fo) { + if (!reopened_fo) { /* Copy parent information */ - if(old_dt->shared->parent) - if(NULL == (new_dt->shared->parent = (*copyfn)(old_dt->shared->parent))) + if (old_dt->shared->parent) + if (NULL == (new_dt->shared->parent = (*copyfn)(old_dt->shared->parent))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy datatype's parent type") - switch(new_dt->shared->type) { - case H5T_COMPOUND: - { - ssize_t accum_change = 0; /* Amount of change in the offset of the fields */ + switch (new_dt->shared->type) { + case H5T_COMPOUND: { + ssize_t accum_change = 0; /* Amount of change in the offset of the fields */ - /* - * Copy all member fields to new type, then overwrite the - * name and type fields of each new member with copied values. - * That is, H5T_copy() is a deep copy. - */ - /* Only malloc if space has been allocated for members - NAF */ - if(new_dt->shared->u.compnd.nalloc > 0) { - if(NULL == (new_dt->shared->u.compnd.memb = H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") - - H5MM_memcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb, + /* + * Copy all member fields to new type, then overwrite the + * name and type fields of each new member with copied values. + * That is, H5T_copy() is a deep copy. + */ + /* Only malloc if space has been allocated for members - NAF */ + if (new_dt->shared->u.compnd.nalloc > 0) { + if (NULL == (new_dt->shared->u.compnd.memb = + H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") + + H5MM_memcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb, new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t)); - } /* end if */ + } /* end if */ - for(i = 0; i < new_dt->shared->u.compnd.nmembs; i++) { - unsigned j; - int old_match; - - if(NULL == (s = H5MM_xstrdup(new_dt->shared->u.compnd.memb[i].name))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy string for compound field's name") - new_dt->shared->u.compnd.memb[i].name = s; - if(NULL == (tmp = (*copyfn)(old_dt->shared->u.compnd.memb[i].type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy compound field's datatype") - new_dt->shared->u.compnd.memb[i].type = tmp; - HDassert(tmp != NULL); - - /* Range check against compound member's offset */ - if((accum_change < 0) && ((ssize_t) new_dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") - - /* Apply the accumulated size change to the offset of the field */ - new_dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; - - if(old_dt->shared->u.compnd.sorted != H5T_SORT_VALUE) { - for(old_match = -1, j = 0; j < old_dt->shared->u.compnd.nmembs; j++) { - if(!HDstrcmp(new_dt->shared->u.compnd.memb[i].name, old_dt->shared->u.compnd.memb[j].name)) { - old_match = (int) j; - break; - } /* end if */ - } /* end for */ - - /* check if we couldn't find a match */ - if(old_match < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "fields in datatype corrupted") - } /* end if */ - else - old_match = (int) i; + for (i = 0; i < new_dt->shared->u.compnd.nmembs; i++) { + unsigned j; + int old_match; + + if (NULL == (s = H5MM_xstrdup(new_dt->shared->u.compnd.memb[i].name))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, + "can't copy string for compound field's name") + new_dt->shared->u.compnd.memb[i].name = s; + if (NULL == (tmp = (*copyfn)(old_dt->shared->u.compnd.memb[i].type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy compound field's datatype") + new_dt->shared->u.compnd.memb[i].type = tmp; + HDassert(tmp != NULL); + + /* Range check against compound member's offset */ + if ((accum_change < 0) && + ((ssize_t)new_dt->shared->u.compnd.memb[i].offset < accum_change)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") - /* If the field changed size, add that change to the accumulated size change */ - if(new_dt->shared->u.compnd.memb[i].type->shared->size != old_dt->shared->u.compnd.memb[old_match].type->shared->size) { - /* Adjust the size of the member */ - new_dt->shared->u.compnd.memb[i].size = (old_dt->shared->u.compnd.memb[old_match].size*tmp->shared->size)/old_dt->shared->u.compnd.memb[old_match].type->shared->size; + /* Apply the accumulated size change to the offset of the field */ + new_dt->shared->u.compnd.memb[i].offset += (size_t)accum_change; - accum_change += (ssize_t) (new_dt->shared->u.compnd.memb[i].type->shared->size - old_dt->shared->u.compnd.memb[old_match].type->shared->size); - } /* end if */ - } /* end for */ + if (old_dt->shared->u.compnd.sorted != H5T_SORT_VALUE) { + for (old_match = -1, j = 0; j < old_dt->shared->u.compnd.nmembs; j++) { + if (!HDstrcmp(new_dt->shared->u.compnd.memb[i].name, + old_dt->shared->u.compnd.memb[j].name)) { + old_match = (int)j; + break; + } /* end if */ + } /* end for */ - /* Range check against datatype size */ - if((accum_change < 0) && ((ssize_t) new_dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") + /* check if we couldn't find a match */ + if (old_match < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "fields in datatype corrupted") + } /* end if */ + else + old_match = (int)i; + + /* If the field changed size, add that change to the accumulated size change */ + if (new_dt->shared->u.compnd.memb[i].type->shared->size != + old_dt->shared->u.compnd.memb[old_match].type->shared->size) { + /* Adjust the size of the member */ + new_dt->shared->u.compnd.memb[i].size = + (old_dt->shared->u.compnd.memb[old_match].size * tmp->shared->size) / + old_dt->shared->u.compnd.memb[old_match].type->shared->size; + + accum_change += + (ssize_t)(new_dt->shared->u.compnd.memb[i].type->shared->size - + old_dt->shared->u.compnd.memb[old_match].type->shared->size); + } /* end if */ + } /* end for */ - /* Apply the accumulated size change to the size of the compound struct */ - new_dt->shared->size += (size_t) accum_change; - } - break; + /* Range check against datatype size */ + if ((accum_change < 0) && ((ssize_t)new_dt->shared->size < accum_change)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") + + /* Apply the accumulated size change to the size of the compound struct */ + new_dt->shared->size += (size_t)accum_change; + } break; case H5T_ENUM: /* - * Copy all member fields to new type, then overwrite the name fields - * of each new member with copied values. That is, H5T_copy() is a - * deep copy. - */ - if(NULL == (new_dt->shared->u.enumer.name = H5MM_malloc(new_dt->shared->u.enumer.nalloc * sizeof(char*)))) + * Copy all member fields to new type, then overwrite the name fields + * of each new member with copied values. That is, H5T_copy() is a + * deep copy. + */ + if (NULL == (new_dt->shared->u.enumer.name = + H5MM_malloc(new_dt->shared->u.enumer.nalloc * sizeof(char *)))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "enam name array memory allocation failed") - if(NULL == (new_dt->shared->u.enumer.value = H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "enam value array memory allocation failed") + if (NULL == (new_dt->shared->u.enumer.value = + H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, + "enam value array memory allocation failed") H5MM_memcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value, - new_dt->shared->u.enumer.nmembs * new_dt->shared->size); - for(i = 0; i < new_dt->shared->u.enumer.nmembs; i++) { - if(NULL == (s = H5MM_xstrdup(old_dt->shared->u.enumer.name[i]))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy string for enum value's name") + new_dt->shared->u.enumer.nmembs * new_dt->shared->size); + for (i = 0; i < new_dt->shared->u.enumer.nmembs; i++) { + if (NULL == (s = H5MM_xstrdup(old_dt->shared->u.enumer.name[i]))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, + "can't copy string for enum value's name") new_dt->shared->u.enumer.name[i] = s; } /* end for */ break; case H5T_VLEN: case H5T_REFERENCE: - if(set_memory_type) + if (set_memory_type) /* H5T_copy converts any type into a memory type */ - if(H5T_set_loc(new_dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(new_dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") break; case H5T_OPAQUE: /* - * Copy the tag name. - */ + * Copy the tag name. + */ new_dt->shared->u.opaque.tag = H5MM_xstrdup(new_dt->shared->u.opaque.tag); break; @@ -3579,29 +3684,29 @@ H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo default: break; } /* end switch */ - } /* end if */ + } /* end if */ /* Set the cached location & name path if the original type was a named * type and the new type is also named. */ - if(H5O_loc_reset(&new_dt->oloc) < 0) + if (H5O_loc_reset(&new_dt->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to initialize location") - if(H5G_name_reset(&new_dt->path) < 0) + if (H5G_name_reset(&new_dt->path) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path") - if(new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { - if(H5O_loc_copy_deep(&(new_dt->oloc), &(old_dt->oloc)) < 0) + if (new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { + if (H5O_loc_copy_deep(&(new_dt->oloc), &(old_dt->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy object location") - if(H5G_name_copy(&(new_dt->path), &(old_dt->path), H5_COPY_DEEP) < 0) + if (H5G_name_copy(&(new_dt->path), &(old_dt->path), H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy path") } /* end if */ /* Copy shared location information if the new type is named or if it is * shared in the heap. */ - if((old_dt->sh_loc.type == H5O_SHARE_TYPE_SOHM || old_dt->sh_loc.type == H5O_SHARE_TYPE_HERE) || - new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { - if(H5O_set_shared(&(new_dt->sh_loc), &(old_dt->sh_loc)) < 0) + if ((old_dt->sh_loc.type == H5O_SHARE_TYPE_SOHM || old_dt->sh_loc.type == H5O_SHARE_TYPE_HERE) || + new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { + if (H5O_set_shared(&(new_dt->sh_loc), &(old_dt->sh_loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy shared information") } /* end if */ else @@ -3612,7 +3717,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__complete_copy() */ - /*------------------------------------------------------------------------- * Function: H5T_copy * @@ -3630,9 +3734,9 @@ done: H5T_t * H5T_copy(const H5T_t *old_dt, H5T_copy_t method) { - H5T_t *new_dt = NULL; /* New datatype */ - H5T_copy_func_t copyfn; /* Pointer to correct copy routine */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t * new_dt = NULL; /* New datatype */ + H5T_copy_func_t copyfn; /* Pointer to correct copy routine */ + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -3640,7 +3744,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) HDassert(old_dt); /* Allocate and copy core datatype information */ - if(NULL == (new_dt = H5T__initiate_copy(old_dt))) + if (NULL == (new_dt = H5T__initiate_copy(old_dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy core datatype info") /* Check what sort of copy we are making */ @@ -3650,7 +3754,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * Return an unlocked transient type. */ new_dt->shared->state = H5T_STATE_TRANSIENT; - copyfn = H5T__copy_transient; + copyfn = H5T__copy_transient; break; case H5T_COPY_ALL: @@ -3658,9 +3762,9 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * Return a transient type (locked or unlocked) or an unopened named * type. Immutable transient types are degraded to read-only. */ - if(H5T_STATE_OPEN==old_dt->shared->state) + if (H5T_STATE_OPEN == old_dt->shared->state) new_dt->shared->state = H5T_STATE_NAMED; - else if(H5T_STATE_IMMUTABLE==old_dt->shared->state) + else if (H5T_STATE_IMMUTABLE == old_dt->shared->state) new_dt->shared->state = H5T_STATE_RDONLY; copyfn = H5T__copy_all; break; @@ -3670,24 +3774,23 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) } /* end switch */ /* Finish making the copy of the datatype */ - if(H5T__complete_copy(new_dt, old_dt, NULL, (method == H5T_COPY_TRANSIENT), copyfn) < 0) + if (H5T__complete_copy(new_dt, old_dt, NULL, (method == H5T_COPY_TRANSIENT), copyfn) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't complete datatype initialization") /* Set return value */ ret_value = new_dt; done: - if(ret_value == NULL) - if(new_dt) { + if (ret_value == NULL) + if (new_dt) { HDassert(new_dt->shared); new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); - new_dt = H5FL_FREE(H5T_t, new_dt); + new_dt = H5FL_FREE(H5T_t, new_dt); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_copy() */ - /*------------------------------------------------------------------------- * Function: H5T_copy_reopen * @@ -3705,9 +3808,9 @@ done: H5T_t * H5T_copy_reopen(H5T_t *old_dt) { - H5T_t *new_dt = NULL; /* New datatype */ - H5T_shared_t *reopened_fo = NULL; /* Pointer to reopened existing named datatype */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t * new_dt = NULL; /* New datatype */ + H5T_shared_t *reopened_fo = NULL; /* Pointer to reopened existing named datatype */ + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -3715,29 +3818,31 @@ H5T_copy_reopen(H5T_t *old_dt) HDassert(old_dt); /* Allocate and copy core datatype information */ - if(NULL == (new_dt = H5T__initiate_copy(old_dt))) + if (NULL == (new_dt = H5T__initiate_copy(old_dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy core datatype info") /* * Return a transient type (locked or unlocked) or an opened named * type. Immutable transient types are degraded to read-only. */ - if(old_dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { + if (old_dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { /* Check if the object is already open */ - if(NULL == (reopened_fo = (H5T_shared_t *)H5FO_opened(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr))) { + if (NULL == + (reopened_fo = (H5T_shared_t *)H5FO_opened(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr))) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open named datatype again */ - if(H5O_open(&old_dt->oloc) < 0) + if (H5O_open(&old_dt->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type") /* Insert opened named datatype into opened object list for the file */ - if(H5FO_insert(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr, new_dt->shared, FALSE)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") + if (H5FO_insert(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr, new_dt->shared, FALSE) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, + "can't insert datatype into list of open objects") /* Increment object count for the object in the top file */ - if(H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") new_dt->shared->fo_count = 1; @@ -3752,14 +3857,14 @@ H5T_copy_reopen(H5T_t *old_dt) reopened_fo->fo_count++; /* Check if the object has been opened through the top file yet */ - if(H5FO_top_count(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) == 0) { + if (H5FO_top_count(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) == 0) { /* Open the object through this top file */ - if(H5O_open(&old_dt->oloc) < 0) + if (H5O_open(&old_dt->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ @@ -3768,28 +3873,27 @@ H5T_copy_reopen(H5T_t *old_dt) } /* end if */ else /* Downgrade immutable datatypes to read-only */ - if(H5T_STATE_IMMUTABLE == old_dt->shared->state) - new_dt->shared->state = H5T_STATE_RDONLY; + if (H5T_STATE_IMMUTABLE == old_dt->shared->state) + new_dt->shared->state = H5T_STATE_RDONLY; /* Finish making the copy of the datatype */ - if(H5T__complete_copy(new_dt, old_dt, reopened_fo, TRUE, H5T_copy_reopen) < 0) + if (H5T__complete_copy(new_dt, old_dt, reopened_fo, TRUE, H5T_copy_reopen) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't complete datatype initialization") /* Set return value */ ret_value = new_dt; done: - if(ret_value == NULL) - if(new_dt) { + if (ret_value == NULL) + if (new_dt) { HDassert(new_dt->shared); new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); - new_dt = H5FL_FREE(H5T_t, new_dt); + new_dt = H5FL_FREE(H5T_t, new_dt); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_copy_reopen() */ - /*------------------------------------------------------------------------- * Function: H5T_lock * @@ -3809,18 +3913,18 @@ done: herr_t H5T_lock(H5T_t *dt, hbool_t immutable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert (dt); + HDassert(dt); switch (dt->shared->state) { case H5T_STATE_TRANSIENT: dt->shared->state = immutable ? H5T_STATE_IMMUTABLE : H5T_STATE_RDONLY; break; case H5T_STATE_RDONLY: - if(immutable) + if (immutable) dt->shared->state = H5T_STATE_IMMUTABLE; break; case H5T_STATE_IMMUTABLE: @@ -3836,7 +3940,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__alloc * @@ -3852,20 +3955,20 @@ done: H5T_t * H5T__alloc(void) { - H5T_t *dt = NULL; /* Pointer to datatype allocated */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; /* Pointer to datatype allocated */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE /* Allocate & initialize datatype wrapper info */ - if(NULL == (dt = H5FL_CALLOC(H5T_t))) + if (NULL == (dt = H5FL_CALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5O_loc_reset(&(dt->oloc)); H5G_name_reset(&(dt->path)); H5O_msg_reset_share(H5O_DTYPE_ID, dt); /* Allocate & initialize shared datatype structure */ - if(NULL == (dt->shared = H5FL_CALLOC(H5T_shared_t))) + if (NULL == (dt->shared = H5FL_CALLOC(H5T_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") dt->shared->version = H5O_DTYPE_VERSION_1; @@ -3876,9 +3979,9 @@ H5T__alloc(void) ret_value = dt; done: - if(ret_value == NULL) - if(dt) { - if(dt->shared) + if (ret_value == NULL) + if (dt) { + if (dt->shared) dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); dt = H5FL_FREE(H5T_t, dt); } /* end if */ @@ -3886,7 +3989,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__alloc() */ - /*------------------------------------------------------------------------- * Function: H5T__free * @@ -3904,8 +4006,8 @@ done: herr_t H5T__free(H5T_t *dt) { - unsigned i; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3915,25 +4017,25 @@ H5T__free(H5T_t *dt) H5G_name_free(&(dt->path)); /* Don't free locked datatypes */ - if(H5T_STATE_IMMUTABLE == dt->shared->state) + if (H5T_STATE_IMMUTABLE == dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close immutable datatype") /* Close the datatype */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { dt->shared->u.compnd.memb[i].name = (char *)H5MM_xfree(dt->shared->u.compnd.memb[i].name); (void)H5T_close_real(dt->shared->u.compnd.memb[i].type); } - dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_xfree(dt->shared->u.compnd.memb); + dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_xfree(dt->shared->u.compnd.memb); dt->shared->u.compnd.nmembs = 0; break; case H5T_ENUM: - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) dt->shared->u.enumer.name[i] = (char *)H5MM_xfree(dt->shared->u.enumer.name[i]); - dt->shared->u.enumer.name = (char **)H5MM_xfree(dt->shared->u.enumer.name); - dt->shared->u.enumer.value = (uint8_t *)H5MM_xfree(dt->shared->u.enumer.value); + dt->shared->u.enumer.name = (char **)H5MM_xfree(dt->shared->u.enumer.name); + dt->shared->u.enumer.value = (uint8_t *)H5MM_xfree(dt->shared->u.enumer.value); dt->shared->u.enumer.nmembs = 0; break; @@ -3958,12 +4060,12 @@ H5T__free(H5T_t *dt) /* Close the parent */ HDassert(dt->shared->parent != dt); - if(dt->shared->parent && H5T_close_real(dt->shared->parent) < 0) + if (dt->shared->parent && H5T_close_real(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close parent data type") dt->shared->parent = NULL; /* Close the owned VOL object */ - if(dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) + if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object") dt->shared->owned_vol_obj = NULL; @@ -3971,7 +4073,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__free() */ - /*------------------------------------------------------------------------- * Function: H5T_close_real * @@ -3990,7 +4091,7 @@ done: herr_t H5T_close_real(H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3998,8 +4099,8 @@ H5T_close_real(H5T_t *dt) HDassert(dt && dt->shared); /* Clean up resources, depending on shared state */ - if(dt->shared->state != H5T_STATE_OPEN) { - if(H5T__free(dt) < 0) + if (dt->shared->state != H5T_STATE_OPEN) { + if (H5T__free(dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); @@ -4015,7 +4116,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_close_real() */ - /*------------------------------------------------------------------------- * Function: H5T_close * @@ -4032,7 +4132,7 @@ done: herr_t H5T_close(H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4041,7 +4141,7 @@ H5T_close(H5T_t *dt) HDassert(dt->shared); /* Named datatype cleanups */ - if(dt->shared->state == H5T_STATE_OPEN) { + if (dt->shared->state == H5T_STATE_OPEN) { /* Decrement refcount count on open named datatype */ dt->shared->fo_count--; @@ -4055,24 +4155,25 @@ H5T_close(H5T_t *dt) */ /* Decrement the ref. count for this object in the top file */ - if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Close things down if this is the last reference to the open named datatype */ - if(0 == dt->shared->fo_count) { - hbool_t corked; /* Whether the named datatype is corked or not */ + if (0 == dt->shared->fo_count) { + hbool_t corked; /* Whether the named datatype is corked or not */ /* Uncork cache entries with object address tag for named datatype */ - if(H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__UNCORK, NULL) < 0) + if (corked) + if (H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__UNCORK, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* Remove the datatype from the list of opened objects in the file */ - if(H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't remove datatype from list of open objects") - if(H5O_close(&dt->oloc, NULL) < 0) + if (H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, + "can't remove datatype from list of open objects") + if (H5O_close(&dt->oloc, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header") /* Mark named datatype closed now */ @@ -4080,27 +4181,26 @@ H5T_close(H5T_t *dt) } /* end if */ else { /* Check reference count for this object in the top file */ - if(H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) { + if (H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) { /* Close object location for named datatype */ - if(H5O_close(&dt->oloc, NULL) < 0) + if (H5O_close(&dt->oloc, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close") } /* end if */ else /* Free object location (i.e. "unhold" the file if appropriate) */ - if(H5O_loc_free(&(dt->oloc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "problem attempting to free location") + if (H5O_loc_free(&(dt->oloc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "problem attempting to free location") } /* end else */ - } /* end if */ + } /* end if */ /* Clean up resources */ - if(H5T_close_real(dt) < 0) + if (H5T_close_real(dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_close() */ - /*------------------------------------------------------------------------- * Function: H5T__set_size * @@ -4130,45 +4230,44 @@ done: static herr_t H5T__set_size(H5T_t *dt, size_t size) { - size_t prec, offset; - herr_t ret_value = SUCCEED; /* Return value */ + size_t prec, offset; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(dt); - HDassert(size!=0); - HDassert(H5T_REFERENCE!=dt->shared->type); - HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(size != 0); + HDassert(H5T_REFERENCE != dt->shared->type); + HDassert(!(H5T_ENUM == dt->shared->type && 0 == dt->shared->u.enumer.nmembs)); - if(dt->shared->parent) { - if(H5T__set_size(dt->shared->parent, size) < 0) + if (dt->shared->parent) { + if (H5T__set_size(dt->shared->parent, size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type"); /* Adjust size of datatype appropriately */ - if(dt->shared->type==H5T_ARRAY) + if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; - else if(dt->shared->type!=H5T_VLEN) + else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } else { if (H5T_IS_ATOMIC(dt->shared)) { offset = dt->shared->u.atomic.offset; - prec = dt->shared->u.atomic.prec; + prec = dt->shared->u.atomic.prec; /* Decrement the offset and precision if necessary */ - if (prec > 8*size) + if (prec > 8 * size) offset = 0; - else - if (offset+prec > 8*size) - offset = 8 * size - prec; - if (prec > 8*size) + else if (offset + prec > 8 * size) + offset = 8 * size - prec; + if (prec > 8 * size) prec = 8 * size; } else prec = offset = 0; - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_INTEGER: case H5T_TIME: case H5T_BITFIELD: @@ -4178,28 +4277,29 @@ H5T__set_size(H5T_t *dt, size_t size) case H5T_COMPOUND: /* If decreasing size, check the last member isn't being cut. */ - if(size < dt->shared->size) { - int num_membs = 0; - unsigned i, max_index = 0; - size_t memb_offset, max_offset = 0; - size_t max_size; + if (size < dt->shared->size) { + int num_membs = 0; + unsigned i, max_index = 0; + size_t memb_offset, max_offset = 0; + size_t max_size; - if((num_membs = H5T_get_nmembers(dt)) < 0) + if ((num_membs = H5T_get_nmembers(dt)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members"); - if(num_membs) { - for(i = 0; i < (unsigned)num_membs; i++) { + if (num_membs) { + for (i = 0; i < (unsigned)num_membs; i++) { memb_offset = H5T_get_member_offset(dt, i); - if(memb_offset > max_offset) { + if (memb_offset > max_offset) { max_offset = memb_offset; - max_index = i; + max_index = i; } /* end if */ - } /* end for */ + } /* end for */ max_size = H5T__get_member_size(dt, max_index); - if(size < (max_offset + max_size)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member "); + if (size < (max_offset + max_size)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "size shrinking will cut off last member "); } /* end if */ /* Compound must not have been packed previously */ @@ -4212,15 +4312,15 @@ H5T__set_size(H5T_t *dt, size_t size) case H5T_STRING: /* Convert string to variable-length datatype */ - if(size == H5T_VARIABLE) { - H5T_t *base = NULL; /* base data type */ - H5T_cset_t tmp_cset; /* Temp. cset info */ - H5T_str_t tmp_strpad; /* Temp. strpad info */ + if (size == H5T_VARIABLE) { + H5T_t * base = NULL; /* base data type */ + H5T_cset_t tmp_cset; /* Temp. cset info */ + H5T_str_t tmp_strpad; /* Temp. strpad info */ /* Get a copy of unsigned char type as the base/parent type */ - if(NULL == (base = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR))) + if (NULL == (base = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype"); - dt->shared->parent=H5T_copy(base,H5T_COPY_ALL); + dt->shared->parent = H5T_copy(base, H5T_COPY_ALL); /* change this datatype into a VL string */ dt->shared->type = H5T_VLEN; @@ -4233,7 +4333,7 @@ H5T__set_size(H5T_t *dt, size_t size) /* Before we mess with the info in the union, extract the * values we need */ - tmp_cset = dt->shared->u.atomic.u.s.cset; + tmp_cset = dt->shared->u.atomic.u.s.cset; tmp_strpad = dt->shared->u.atomic.u.s.pad; /* This is a string, not a sequence */ @@ -4244,11 +4344,11 @@ H5T__set_size(H5T_t *dt, size_t size) dt->shared->u.vlen.pad = tmp_strpad; /* Set up VL information */ - if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location"); } /* end if */ else { - prec = 8 * size; + prec = 8 * size; offset = 0; } /* end else */ break; @@ -4258,10 +4358,11 @@ H5T__set_size(H5T_t *dt, size_t size) * The sign, mantissa, and exponent fields should be adjusted * first when decreasing the size of a floating point type. */ - if(dt->shared->u.atomic.u.f.sign >= prec+offset || - dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || - dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first"); + if (dt->shared->u.atomic.u.f.sign >= prec + offset || + dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec + offset || + dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec + offset) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "adjust sign, mantissa, and exponent fields first"); } break; @@ -4283,16 +4384,16 @@ H5T__set_size(H5T_t *dt, size_t size) } /* end switch */ /* Commit (if we didn't convert this type to a VL string) */ - if(dt->shared->type != H5T_VLEN) { + if (dt->shared->type != H5T_VLEN) { dt->shared->size = size; if (H5T_IS_ATOMIC(dt->shared)) { dt->shared->u.atomic.offset = offset; - dt->shared->u.atomic.prec = prec; + dt->shared->u.atomic.prec = prec; } } /* end if */ /* Check if the new compound type is packed */ - if(dt->shared->type == H5T_COMPOUND) + if (dt->shared->type == H5T_COMPOUND) H5T__update_packed(dt); } /* end else */ @@ -4300,7 +4401,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__set_size() */ - /*------------------------------------------------------------------------- * Function: H5T_get_size * @@ -4328,7 +4428,6 @@ H5T_get_size(const H5T_t *dt) FUNC_LEAVE_NOAPI(dt->shared->size) } /* end H5T_get_size() */ - /*------------------------------------------------------------------------- * Function: H5T_cmp * @@ -4348,12 +4447,12 @@ H5T_get_size(const H5T_t *dt) int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) { - unsigned *idx1 = NULL, *idx2 = NULL; - size_t base_size; - hbool_t swapped; - unsigned u; - int tmp; - int ret_value = 0; + unsigned *idx1 = NULL, *idx2 = NULL; + size_t base_size; + hbool_t swapped; + unsigned u; + int tmp; + int ret_value = 0; FUNC_ENTER_NOAPI(0) @@ -4362,106 +4461,112 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) HDassert(dt2); /* the easy case */ - if(dt1 == dt2) + if (dt1 == dt2) HGOTO_DONE(0); /* compare */ - if(dt1->shared->type < dt2->shared->type) + if (dt1->shared->type < dt2->shared->type) HGOTO_DONE(-1); - if(dt1->shared->type > dt2->shared->type) + if (dt1->shared->type > dt2->shared->type) HGOTO_DONE(1); - if(dt1->shared->size < dt2->shared->size) + if (dt1->shared->size < dt2->shared->size) HGOTO_DONE(-1); - if(dt1->shared->size > dt2->shared->size) + if (dt1->shared->size > dt2->shared->size) HGOTO_DONE(1); - if(dt1->shared->parent && !dt2->shared->parent) + if (dt1->shared->parent && !dt2->shared->parent) HGOTO_DONE(-1); - if(!dt1->shared->parent && dt2->shared->parent) + if (!dt1->shared->parent && dt2->shared->parent) HGOTO_DONE(1); - if(dt1->shared->parent) { + if (dt1->shared->parent) { tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset); - if(tmp < 0) + if (tmp < 0) HGOTO_DONE(-1); - if(tmp > 0) + if (tmp > 0) HGOTO_DONE(1); } /* end if */ - switch(dt1->shared->type) { + switch (dt1->shared->type) { case H5T_COMPOUND: /* * Compound data types... */ - if(dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs) + if (dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs) HGOTO_DONE(-1); - if(dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs) + if (dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs) HGOTO_DONE(1); /* Build an index for each type so the names are sorted */ - if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || - NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned)))) + if (NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || + NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); - for(u = 0; u < dt1->shared->u.compnd.nmembs; u++) + for (u = 0; u < dt1->shared->u.compnd.nmembs; u++) idx1[u] = idx2[u] = u; - if(dt1->shared->u.enumer.nmembs > 1) { + if (dt1->shared->u.enumer.nmembs > 1) { int i; - for(i = (int) dt1->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { + for (i = (int)dt1->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { int j; - for(j = 0, swapped=FALSE; j < i; j++) - if(HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name, - dt1->shared->u.compnd.memb[idx1[j + 1]].name) > 0) { + for (j = 0, swapped = FALSE; j < i; j++) + if (HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name, + dt1->shared->u.compnd.memb[idx1[j + 1]].name) > 0) { unsigned tmp_idx = idx1[j]; - idx1[j] = idx1[j + 1]; - idx1[j + 1] = tmp_idx; - swapped = TRUE; + idx1[j] = idx1[j + 1]; + idx1[j + 1] = tmp_idx; + swapped = TRUE; } } - for(i = (int) dt2->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { + for (i = (int)dt2->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { int j; - for(j = 0, swapped = FALSE; jshared->u.compnd.memb[idx2[j]].name, - dt2->shared->u.compnd.memb[idx2[j + 1]].name) > 0) { + for (j = 0, swapped = FALSE; j < i; j++) + if (HDstrcmp(dt2->shared->u.compnd.memb[idx2[j]].name, + dt2->shared->u.compnd.memb[idx2[j + 1]].name) > 0) { unsigned tmp_idx = idx2[j]; - idx2[j] = idx2[j + 1]; - idx2[j + 1] = tmp_idx; - swapped = TRUE; + idx2[j] = idx2[j + 1]; + idx2[j + 1] = tmp_idx; + swapped = TRUE; } } } /* end if */ #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ - for(u=0; ushared->u.compnd.nmembs-1; u++) { + for (u = 0; u < dt1->shared->u.compnd.nmembs - 1; u++) { HDassert(HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, - dt1->shared->u.compnd.memb[idx1[u + 1]].name)); + dt1->shared->u.compnd.memb[idx1[u + 1]].name)); HDassert(HDstrcmp(dt2->shared->u.compnd.memb[idx2[u]].name, - dt2->shared->u.compnd.memb[idx2[u + 1]].name)); + dt2->shared->u.compnd.memb[idx2[u + 1]].name)); } #endif /* Compare the members */ - for(u=0; ushared->u.compnd.nmembs; u++) { + for (u = 0; u < dt1->shared->u.compnd.nmembs; u++) { tmp = HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, - dt2->shared->u.compnd.memb[idx2[u]].name); - if(tmp < 0) + dt2->shared->u.compnd.memb[idx2[u]].name); + if (tmp < 0) HGOTO_DONE(-1); - if(tmp > 0) + if (tmp > 0) HGOTO_DONE(1); - if(dt1->shared->u.compnd.memb[idx1[u]].offset < dt2->shared->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(-1); - if(dt1->shared->u.compnd.memb[idx1[u]].offset > dt2->shared->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(1); + if (dt1->shared->u.compnd.memb[idx1[u]].offset < dt2->shared->u.compnd.memb[idx2[u]].offset) + HGOTO_DONE(-1); + if (dt1->shared->u.compnd.memb[idx1[u]].offset > dt2->shared->u.compnd.memb[idx2[u]].offset) + HGOTO_DONE(1); - if(dt1->shared->u.compnd.memb[idx1[u]].size < dt2->shared->u.compnd.memb[idx2[u]].size) HGOTO_DONE(-1); - if(dt1->shared->u.compnd.memb[idx1[u]].size > dt2->shared->u.compnd.memb[idx2[u]].size) HGOTO_DONE(1); + if (dt1->shared->u.compnd.memb[idx1[u]].size < dt2->shared->u.compnd.memb[idx2[u]].size) + HGOTO_DONE(-1); + if (dt1->shared->u.compnd.memb[idx1[u]].size > dt2->shared->u.compnd.memb[idx2[u]].size) + HGOTO_DONE(1); tmp = H5T_cmp(dt1->shared->u.compnd.memb[idx1[u]].type, - dt2->shared->u.compnd.memb[idx2[u]].type, superset); - if(tmp < 0) HGOTO_DONE(-1); - if(tmp > 0) HGOTO_DONE(1); + dt2->shared->u.compnd.memb[idx2[u]].type, superset); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); } break; @@ -4473,75 +4578,75 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* If we are doing a "superset" comparison, dt2 is allowed to have * more members than dt1 */ - if(superset) { - if(dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) + if (superset) { + if (dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) HGOTO_DONE(1); } /* end if */ else { - if(dt1->shared->u.enumer.nmembs < dt2->shared->u.enumer.nmembs) + if (dt1->shared->u.enumer.nmembs < dt2->shared->u.enumer.nmembs) HGOTO_DONE(-1); - if(dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) + if (dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) HGOTO_DONE(1); } /* end else */ /* Build an index for each type so the names are sorted */ - if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || - NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.enumer.nmembs * sizeof(unsigned)))) + if (NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || + NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.enumer.nmembs * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); - for(u=0; ushared->u.enumer.nmembs; u++) + for (u = 0; u < dt1->shared->u.enumer.nmembs; u++) idx1[u] = u; - if(dt1->shared->u.enumer.nmembs > 1) { + if (dt1->shared->u.enumer.nmembs > 1) { int i; - for (i = (int) dt1->shared->u.enumer.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { + for (i = (int)dt1->shared->u.enumer.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { int j; - for(j = 0, swapped = FALSE; j < i; j++) - if(HDstrcmp(dt1->shared->u.enumer.name[idx1[j]], - dt1->shared->u.enumer.name[idx1[j+1]]) > 0) { + for (j = 0, swapped = FALSE; j < i; j++) + if (HDstrcmp(dt1->shared->u.enumer.name[idx1[j]], + dt1->shared->u.enumer.name[idx1[j + 1]]) > 0) { unsigned tmp_idx = idx1[j]; - idx1[j] = idx1[j+1]; - idx1[j+1] = tmp_idx; - swapped = TRUE; + idx1[j] = idx1[j + 1]; + idx1[j + 1] = tmp_idx; + swapped = TRUE; } } } - for(u=0; ushared->u.enumer.nmembs; u++) + for (u = 0; u < dt2->shared->u.enumer.nmembs; u++) idx2[u] = u; - if(dt2->shared->u.enumer.nmembs > 1) { + if (dt2->shared->u.enumer.nmembs > 1) { int i; - for(i = (int) dt2->shared->u.enumer.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { + for (i = (int)dt2->shared->u.enumer.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { int j; - for(j = 0, swapped = FALSE; j < i; j++) - if(HDstrcmp(dt2->shared->u.enumer.name[idx2[j]], - dt2->shared->u.enumer.name[idx2[j+1]]) > 0) { + for (j = 0, swapped = FALSE; j < i; j++) + if (HDstrcmp(dt2->shared->u.enumer.name[idx2[j]], + dt2->shared->u.enumer.name[idx2[j + 1]]) > 0) { unsigned tmp_idx = idx2[j]; - idx2[j] = idx2[j+1]; - idx2[j+1] = tmp_idx; - swapped = TRUE; + idx2[j] = idx2[j + 1]; + idx2[j + 1] = tmp_idx; + swapped = TRUE; } } } #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ - for(u=0; ushared->u.enumer.nmembs-1; u++) { - HDassert(HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], - dt1->shared->u.enumer.name[idx1[u+1]])); - HDassert(HDstrcmp(dt2->shared->u.enumer.name[idx2[u]], - dt2->shared->u.enumer.name[idx2[u+1]])); + for (u = 0; u < dt1->shared->u.enumer.nmembs - 1; u++) { + HDassert( + HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], dt1->shared->u.enumer.name[idx1[u + 1]])); + HDassert( + HDstrcmp(dt2->shared->u.enumer.name[idx2[u]], dt2->shared->u.enumer.name[idx2[u + 1]])); } #endif /* Compare the members */ base_size = dt1->shared->parent->shared->size; - for(u=0; ushared->u.enumer.nmembs; u++) { + for (u = 0; u < dt1->shared->u.enumer.nmembs; u++) { unsigned idx = 0; - if(superset) { - unsigned lt = 0, rt; /* Final, left & right key indices */ - int cmp = 1; /* Key comparison value */ + if (superset) { + unsigned lt = 0, rt; /* Final, left & right key indices */ + int cmp = 1; /* Key comparison value */ /* If a superset is allowed, dt2 may have more members * than dt1, so binary search for matching member name in @@ -4549,99 +4654,100 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) */ rt = dt2->shared->u.enumer.nmembs; - while(lt < rt && cmp) { + while (lt < rt && cmp) { idx = (lt + rt) / 2; /* compare */ - if((cmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], - dt2->shared->u.enumer.name[idx2[idx]] ) ) < 0) + if ((cmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], + dt2->shared->u.enumer.name[idx2[idx]])) < 0) rt = idx; else - lt = idx+1; + lt = idx + 1; } /* Leave, if we couldn't find match */ - if(cmp) + if (cmp) HGOTO_DONE(-1); } /* end if */ else { /* Check for exact member name match when not doing * "superset" comparison */ - tmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], - dt2->shared->u.enumer.name[idx2[u]]); - if (tmp<0) HGOTO_DONE(-1); - if (tmp>0) HGOTO_DONE(1); + tmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], dt2->shared->u.enumer.name[idx2[u]]); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); /* Set index value appropriately */ idx = u; } /* end else */ tmp = HDmemcmp((uint8_t *)dt1->shared->u.enumer.value + idx1[u] * base_size, - (uint8_t *)dt2->shared->u.enumer.value + idx2[idx] * base_size, - base_size); - if(tmp<0) HGOTO_DONE(-1); - if(tmp>0) HGOTO_DONE(1); + (uint8_t *)dt2->shared->u.enumer.value + idx2[idx] * base_size, base_size); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); } break; case H5T_VLEN: - HDassert(dt1->shared->u.vlen.type>H5T_VLEN_BADTYPE && dt1->shared->u.vlen.typeshared->u.vlen.type>H5T_VLEN_BADTYPE && dt2->shared->u.vlen.typeshared->u.vlen.loc>=H5T_LOC_BADLOC && dt1->shared->u.vlen.locshared->u.vlen.loc>=H5T_LOC_BADLOC && dt2->shared->u.vlen.locshared->u.vlen.type > H5T_VLEN_BADTYPE && + dt1->shared->u.vlen.type < H5T_VLEN_MAXTYPE); + HDassert(dt2->shared->u.vlen.type > H5T_VLEN_BADTYPE && + dt2->shared->u.vlen.type < H5T_VLEN_MAXTYPE); + HDassert(dt1->shared->u.vlen.loc >= H5T_LOC_BADLOC && dt1->shared->u.vlen.loc < H5T_LOC_MAXLOC); + HDassert(dt2->shared->u.vlen.loc >= H5T_LOC_BADLOC && dt2->shared->u.vlen.loc < H5T_LOC_MAXLOC); /* Arbitrarily sort sequence VL datatypes before string VL datatypes */ - if(dt1->shared->u.vlen.type==H5T_VLEN_SEQUENCE && - dt2->shared->u.vlen.type==H5T_VLEN_STRING) { + if (dt1->shared->u.vlen.type == H5T_VLEN_SEQUENCE && + dt2->shared->u.vlen.type == H5T_VLEN_STRING) { HGOTO_DONE(-1); } - else if(dt1->shared->u.vlen.type==H5T_VLEN_STRING && - dt2->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { + else if (dt1->shared->u.vlen.type == H5T_VLEN_STRING && + dt2->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { HGOTO_DONE(1); } /* Arbitrarily sort VL datatypes in memory before disk */ - if(dt1->shared->u.vlen.loc==H5T_LOC_MEMORY && - dt2->shared->u.vlen.loc==H5T_LOC_DISK) { + if (dt1->shared->u.vlen.loc == H5T_LOC_MEMORY && dt2->shared->u.vlen.loc == H5T_LOC_DISK) { HGOTO_DONE(-1); } - else if(dt1->shared->u.vlen.loc==H5T_LOC_DISK && - dt2->shared->u.vlen.loc==H5T_LOC_MEMORY) { + else if (dt1->shared->u.vlen.loc == H5T_LOC_DISK && dt2->shared->u.vlen.loc == H5T_LOC_MEMORY) { HGOTO_DONE(1); } - else if(dt1->shared->u.vlen.loc==H5T_LOC_BADLOC && - dt2->shared->u.vlen.loc!=H5T_LOC_BADLOC) { + else if (dt1->shared->u.vlen.loc == H5T_LOC_BADLOC && dt2->shared->u.vlen.loc != H5T_LOC_BADLOC) { HGOTO_DONE(1); } /* Don't allow VL types in different files to compare as equal */ - if(dt1->shared->u.vlen.file < dt2->shared->u.vlen.file) + if (dt1->shared->u.vlen.file < dt2->shared->u.vlen.file) HGOTO_DONE(-1); - if(dt1->shared->u.vlen.file > dt2->shared->u.vlen.file) + if (dt1->shared->u.vlen.file > dt2->shared->u.vlen.file) HGOTO_DONE(1); break; case H5T_OPAQUE: - if(dt1->shared->u.opaque.tag && dt2->shared->u.opaque.tag) - HGOTO_DONE(HDstrcmp(dt1->shared->u.opaque.tag,dt2->shared->u.opaque.tag)); + if (dt1->shared->u.opaque.tag && dt2->shared->u.opaque.tag) + HGOTO_DONE(HDstrcmp(dt1->shared->u.opaque.tag, dt2->shared->u.opaque.tag)); break; case H5T_ARRAY: - if(dt1->shared->u.array.ndims < dt2->shared->u.array.ndims) + if (dt1->shared->u.array.ndims < dt2->shared->u.array.ndims) HGOTO_DONE(-1); - if(dt1->shared->u.array.ndims > dt2->shared->u.array.ndims) + if (dt1->shared->u.array.ndims > dt2->shared->u.array.ndims) HGOTO_DONE(1); - for(u=0; ushared->u.array.ndims; u++) { - if(dt1->shared->u.array.dim[u] < dt2->shared->u.array.dim[u]) + for (u = 0; u < dt1->shared->u.array.ndims; u++) { + if (dt1->shared->u.array.dim[u] < dt2->shared->u.array.dim[u]) HGOTO_DONE(-1); - if(dt1->shared->u.array.dim[u] > dt2->shared->u.array.dim[u]) + if (dt1->shared->u.array.dim[u] > dt2->shared->u.array.dim[u]) HGOTO_DONE(1); } tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset); - if(tmp < 0) + if (tmp < 0) HGOTO_DONE(-1); - if(tmp > 0) + if (tmp > 0) HGOTO_DONE(1); break; @@ -4657,79 +4763,95 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* * Atomic datatypes... */ - if(dt1->shared->u.atomic.order < dt2->shared->u.atomic.order) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.order > dt2->shared->u.atomic.order) HGOTO_DONE(1); + if (dt1->shared->u.atomic.order < dt2->shared->u.atomic.order) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.order > dt2->shared->u.atomic.order) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.prec < dt2->shared->u.atomic.prec) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.prec > dt2->shared->u.atomic.prec) HGOTO_DONE(1); + if (dt1->shared->u.atomic.prec < dt2->shared->u.atomic.prec) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.prec > dt2->shared->u.atomic.prec) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.offset < dt2->shared->u.atomic.offset) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.offset > dt2->shared->u.atomic.offset) HGOTO_DONE(1); + if (dt1->shared->u.atomic.offset < dt2->shared->u.atomic.offset) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.offset > dt2->shared->u.atomic.offset) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.lsb_pad < dt2->shared->u.atomic.lsb_pad) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.lsb_pad > dt2->shared->u.atomic.lsb_pad) HGOTO_DONE(1); + if (dt1->shared->u.atomic.lsb_pad < dt2->shared->u.atomic.lsb_pad) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.lsb_pad > dt2->shared->u.atomic.lsb_pad) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.msb_pad < dt2->shared->u.atomic.msb_pad) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.msb_pad > dt2->shared->u.atomic.msb_pad) HGOTO_DONE(1); + if (dt1->shared->u.atomic.msb_pad < dt2->shared->u.atomic.msb_pad) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.msb_pad > dt2->shared->u.atomic.msb_pad) + HGOTO_DONE(1); switch (dt1->shared->type) { case H5T_INTEGER: - if(dt1->shared->u.atomic.u.i.sign < dt2->shared->u.atomic.u.i.sign) + if (dt1->shared->u.atomic.u.i.sign < dt2->shared->u.atomic.u.i.sign) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.i.sign > dt2->shared->u.atomic.u.i.sign) + if (dt1->shared->u.atomic.u.i.sign > dt2->shared->u.atomic.u.i.sign) HGOTO_DONE(1); break; case H5T_FLOAT: - if(dt1->shared->u.atomic.u.f.sign < dt2->shared->u.atomic.u.f.sign) + if (dt1->shared->u.atomic.u.f.sign < dt2->shared->u.atomic.u.f.sign) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.sign > dt2->shared->u.atomic.u.f.sign) + if (dt1->shared->u.atomic.u.f.sign > dt2->shared->u.atomic.u.f.sign) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.epos < dt2->shared->u.atomic.u.f.epos) + if (dt1->shared->u.atomic.u.f.epos < dt2->shared->u.atomic.u.f.epos) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.epos > dt2->shared->u.atomic.u.f.epos) + if (dt1->shared->u.atomic.u.f.epos > dt2->shared->u.atomic.u.f.epos) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.esize < dt2->shared->u.atomic.u.f.esize) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.esize > dt2->shared->u.atomic.u.f.esize) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.esize < dt2->shared->u.atomic.u.f.esize) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.esize > dt2->shared->u.atomic.u.f.esize) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.ebias < dt2->shared->u.atomic.u.f.ebias) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.ebias > dt2->shared->u.atomic.u.f.ebias) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.ebias < dt2->shared->u.atomic.u.f.ebias) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.ebias > dt2->shared->u.atomic.u.f.ebias) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.mpos < dt2->shared->u.atomic.u.f.mpos) + if (dt1->shared->u.atomic.u.f.mpos < dt2->shared->u.atomic.u.f.mpos) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.mpos > dt2->shared->u.atomic.u.f.mpos) + if (dt1->shared->u.atomic.u.f.mpos > dt2->shared->u.atomic.u.f.mpos) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.msize < dt2->shared->u.atomic.u.f.msize) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.msize > dt2->shared->u.atomic.u.f.msize) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.msize < dt2->shared->u.atomic.u.f.msize) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.msize > dt2->shared->u.atomic.u.f.msize) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.norm < dt2->shared->u.atomic.u.f.norm) + if (dt1->shared->u.atomic.u.f.norm < dt2->shared->u.atomic.u.f.norm) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.norm > dt2->shared->u.atomic.u.f.norm) + if (dt1->shared->u.atomic.u.f.norm > dt2->shared->u.atomic.u.f.norm) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.pad < dt2->shared->u.atomic.u.f.pad) + if (dt1->shared->u.atomic.u.f.pad < dt2->shared->u.atomic.u.f.pad) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.pad > dt2->shared->u.atomic.u.f.pad) + if (dt1->shared->u.atomic.u.f.pad > dt2->shared->u.atomic.u.f.pad) HGOTO_DONE(1); break; - case H5T_TIME: /* order and precision are checked above */ + case H5T_TIME: /* order and precision are checked above */ /*void */ break; case H5T_STRING: - if(dt1->shared->u.atomic.u.s.cset < dt2->shared->u.atomic.u.s.cset) + if (dt1->shared->u.atomic.u.s.cset < dt2->shared->u.atomic.u.s.cset) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.s.cset > dt2->shared->u.atomic.u.s.cset) + if (dt1->shared->u.atomic.u.s.cset > dt2->shared->u.atomic.u.s.cset) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.s.pad < dt2->shared->u.atomic.u.s.pad) + if (dt1->shared->u.atomic.u.s.pad < dt2->shared->u.atomic.u.s.pad) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.s.pad > dt2->shared->u.atomic.u.s.pad) + if (dt1->shared->u.atomic.u.s.pad > dt2->shared->u.atomic.u.s.pad) HGOTO_DONE(1); break; @@ -4739,13 +4861,13 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) break; case H5T_REFERENCE: - if(dt1->shared->u.atomic.u.r.rtype < dt2->shared->u.atomic.u.r.rtype) + if (dt1->shared->u.atomic.u.r.rtype < dt2->shared->u.atomic.u.r.rtype) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.r.rtype > dt2->shared->u.atomic.u.r.rtype) + if (dt1->shared->u.atomic.u.r.rtype > dt2->shared->u.atomic.u.r.rtype) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc) + if (dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc) + if (dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc) HGOTO_DONE(1); break; @@ -4760,19 +4882,18 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) HDassert("not implemented yet" && 0); break; } - break; + break; } /* end switch */ done: - if(NULL != idx1) + if (NULL != idx1) H5MM_xfree(idx1); - if(NULL != idx2) + if (NULL != idx2) H5MM_xfree(idx2); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_cmp() */ - /*------------------------------------------------------------------------- * Function: H5T_path_find * @@ -4796,8 +4917,8 @@ done: H5T_path_t * H5T_path_find(const H5T_t *src, const H5T_t *dst) { - H5T_conv_func_t conv_func; /* Conversion function wrapper */ - H5T_path_t *ret_value = NULL; /* Return value */ + H5T_conv_func_t conv_func; /* Conversion function wrapper */ + H5T_path_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -4808,18 +4929,17 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst) HDassert(dst->shared); /* Set up conversion function wrapper */ - conv_func.is_app = FALSE; + conv_func.is_app = FALSE; conv_func.u.lib_func = NULL; /* Call the internal routine, with additional parameters */ - if(NULL == (ret_value = H5T__path_find_real(src, dst, NULL, &conv_func))) + if (NULL == (ret_value = H5T__path_find_real(src, dst, NULL, &conv_func))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't find datatype conversion path") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_path_find() */ - /*------------------------------------------------------------------------- * Function: H5T__path_find_real * @@ -4847,19 +4967,18 @@ done: *------------------------------------------------------------------------- */ static H5T_path_t * -H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, - H5T_conv_func_t *conv) +H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_func_t *conv) { - int lt, rt; /* left and right edges */ - int md; /* middle */ - int cmp; /* comparison result */ - int old_npaths; /* Previous number of paths in table */ - H5T_path_t *table = NULL; /* path existing in the table */ - H5T_path_t *path = NULL; /* new path */ - hid_t src_id = -1, dst_id = -1; /* src and dst type identifiers */ - int i; /* counter */ - int nprint = 0; /* lines of output printed */ - H5T_path_t *ret_value = NULL; /* Return value */ + int lt, rt; /* left and right edges */ + int md; /* middle */ + int cmp; /* comparison result */ + int old_npaths; /* Previous number of paths in table */ + H5T_path_t *table = NULL; /* path existing in the table */ + H5T_path_t *path = NULL; /* new path */ + hid_t src_id = -1, dst_id = -1; /* src and dst type identifiers */ + int i; /* counter */ + int nprint = 0; /* lines of output printed */ + H5T_path_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -4872,25 +4991,27 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, /* * Make sure the first entry in the table is the no-op conversion path. */ - if(0 == H5T_g.npaths) { - if(NULL == (H5T_g.path = (H5T_path_t **)H5MM_malloc(128 * sizeof(H5T_path_t *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path table") + if (0 == H5T_g.npaths) { + if (NULL == (H5T_g.path = (H5T_path_t **)H5MM_malloc(128 * sizeof(H5T_path_t *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for type conversion path table") H5T_g.apaths = 128; - if(NULL == (H5T_g.path[0] = H5FL_CALLOC(H5T_path_t))) + if (NULL == (H5T_g.path[0] = H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for no-op conversion path") HDsnprintf(H5T_g.path[0]->name, sizeof(H5T_g.path[0]->name), "no-op"); - H5T_g.path[0]->conv.is_app = FALSE; + H5T_g.path[0]->conv.is_app = FALSE; H5T_g.path[0]->conv.u.lib_func = H5T__conv_noop; - H5T_g.path[0]->cdata.command = H5T_CONV_INIT; - if(H5T__conv_noop((hid_t)FAIL, (hid_t)FAIL, &(H5T_g.path[0]->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + H5T_g.path[0]->cdata.command = H5T_CONV_INIT; + if (H5T__conv_noop((hid_t)FAIL, (hid_t)FAIL, &(H5T_g.path[0]->cdata), (size_t)0, (size_t)0, (size_t)0, + NULL, NULL) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) + if (H5DEBUG(T)) HDfprintf(H5DEBUG(T), "H5T: unable to initialize no-op conversion function (ignored)\n"); #endif H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ + } /* end if */ H5T_g.path[0]->is_noop = TRUE; - H5T_g.npaths = 1; + H5T_g.npaths = 1; } /* end if */ /* Find the conversion path. If source and destination types are equal @@ -4901,30 +5022,31 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, * Only allow the no-op conversion to occur if no "force conversion" flags * are set */ - if(src->shared->force_conv == FALSE && dst->shared->force_conv == FALSE && 0 == H5T_cmp(src, dst, TRUE)) { + if (src->shared->force_conv == FALSE && dst->shared->force_conv == FALSE && + 0 == H5T_cmp(src, dst, TRUE)) { table = H5T_g.path[0]; - cmp = 0; - md = 0; + cmp = 0; + md = 0; } /* end if */ else { lt = md = 1; - rt = H5T_g.npaths; - cmp = -1; + rt = H5T_g.npaths; + cmp = -1; - while(cmp && lt < rt) { + while (cmp && lt < rt) { md = (lt + rt) / 2; HDassert(H5T_g.path[md]); cmp = H5T_cmp(src, H5T_g.path[md]->src, FALSE); - if(0 == cmp) + if (0 == cmp) cmp = H5T_cmp(dst, H5T_g.path[md]->dst, FALSE); - if(cmp < 0) + if (cmp < 0) rt = md; - else if(cmp > 0) + else if (cmp > 0) lt = md + 1; else table = H5T_g.path[md]; } /* end while */ - } /* end else */ + } /* end else */ /* Keep a record of the number of paths in the table, in case one of the * initialization calls below (hard or soft) causes more entries to be @@ -4937,18 +5059,19 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, * specifying a new hard conversion and the path is a soft conversion, then * create a new path and add the new function to the path. */ - if(!table || (table && conv->is_app && conv->u.app_func) || (table && !table->is_hard && !conv->is_app && conv->u.lib_func)) { - if(NULL == (path = H5FL_CALLOC(H5T_path_t))) + if (!table || (table && conv->is_app && conv->u.app_func) || + (table && !table->is_hard && !conv->is_app && conv->u.lib_func)) { + if (NULL == (path = H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path") - if(name && *name) { + if (name && *name) { HDstrncpy(path->name, name, (size_t)H5T_NAMELEN); path->name[H5T_NAMELEN - 1] = '\0'; } /* end if */ else HDsnprintf(path->name, sizeof(path->name), "NONAME"); - if(NULL == (path->src = H5T_copy(src, H5T_COPY_ALL))) + if (NULL == (path->src = H5T_copy(src, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy datatype for conversion path") - if(NULL == (path->dst = H5T_copy(dst, H5T_COPY_ALL))) + if (NULL == (path->dst = H5T_copy(dst, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy datatype for conversion path") } /* end if */ else @@ -4959,28 +5082,32 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, * the existing path is a soft function, then add the new conversion to the path * and initialize its conversion data. */ - if(conv->u.app_func && (!table || (table && conv->is_app) || (table && !table->is_hard && !conv->is_app))) { + if (conv->u.app_func && + (!table || (table && conv->is_app) || (table && !table->is_hard && !conv->is_app))) { HDassert(path != table); HDassert(NULL == path->conv.u.app_func); - if(path->src && (src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register source conversion type for query") - if(path->dst && (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register destination conversion type for query") + if (path->src && (src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register source conversion type for query") + if (path->dst && (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register destination conversion type for query") path->cdata.command = H5T_CONV_INIT; - if(conv->is_app) { - if((conv->u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) + if (conv->is_app) { + if ((conv->u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, + NULL, H5CX_get_dxpl()) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function") } /* end if */ - else - if((conv->u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function") - if(src_id >= 0) + else if ((conv->u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, + NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function") + if (src_id >= 0) H5I_dec_ref(src_id); - if(dst_id >= 0) + if (dst_id >= 0) H5I_dec_ref(dst_id); src_id = dst_id = -1; - path->conv = *conv; - path->is_hard = TRUE; + path->conv = *conv; + path->is_hard = TRUE; } /* end if */ /* @@ -4990,143 +5117,146 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, * for the no-op conversion path. */ HDassert(path->conv.u.app_func || (src && dst)); - for(i = H5T_g.nsoft - 1; i >= 0 && !path->conv.u.app_func; --i) { + for (i = H5T_g.nsoft - 1; i >= 0 && !path->conv.u.app_func; --i) { hbool_t path_init_error = FALSE; - if(src->shared->type != H5T_g.soft[i].src || dst->shared->type != H5T_g.soft[i].dst) + if (src->shared->type != H5T_g.soft[i].src || dst->shared->type != H5T_g.soft[i].dst) continue; - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register src conversion type for query") - if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register dst conversion type for query") + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register src conversion type for query") + if ((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register dst conversion type for query") path->cdata.command = H5T_CONV_INIT; - if(H5T_g.soft[i].conv.is_app) { - if((H5T_g.soft[i].conv.u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (H5T_g.soft[i].conv.is_app) { + if ((H5T_g.soft[i].conv.u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t)); H5E_clear_stack(NULL); /*ignore the error*/ path_init_error = TRUE; } /* end if */ + } /* end if */ + else if ((H5T_g.soft[i].conv.u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL) < 0) { + HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t)); + H5E_clear_stack(NULL); /*ignore the error*/ + path_init_error = TRUE; } /* end if */ - else - if((H5T_g.soft[i].conv.u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { - HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t)); - H5E_clear_stack(NULL); /*ignore the error*/ - path_init_error = TRUE; - } /* end if */ /* Finish operation, if no error */ - if(!path_init_error) { + if (!path_init_error) { HDstrncpy(path->name, H5T_g.soft[i].name, (size_t)H5T_NAMELEN); path->name[H5T_NAMELEN - 1] = '\0'; - path->conv = H5T_g.soft[i].conv; - path->is_hard = FALSE; + path->conv = H5T_g.soft[i].conv; + path->is_hard = FALSE; } /* end else */ H5I_dec_ref(src_id); H5I_dec_ref(dst_id); src_id = dst_id = -1; } /* end for */ - if(!path->conv.u.app_func) + if (!path->conv.u.app_func) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no appropriate function for conversion path") /* Check if paths were inserted into the table through a recursive call * and re-compute the correct location for this path if so. - QAK, 1/26/02 */ - if(old_npaths != H5T_g.npaths) { + if (old_npaths != H5T_g.npaths) { lt = md = 1; - rt = H5T_g.npaths; - cmp = -1; + rt = H5T_g.npaths; + cmp = -1; - while(cmp && lt < rt) { + while (cmp && lt < rt) { md = (lt + rt) / 2; HDassert(H5T_g.path[md]); cmp = H5T_cmp(src, H5T_g.path[md]->src, FALSE); - if(0 == cmp) + if (0 == cmp) cmp = H5T_cmp(dst, H5T_g.path[md]->dst, FALSE); - if(cmp < 0) + if (cmp < 0) rt = md; - else if(cmp > 0) + else if (cmp > 0) lt = md + 1; else table = H5T_g.path[md]; } /* end while */ - } /* end if */ + } /* end if */ /* Replace an existing table entry or add a new entry */ - if(table && path != table) { + if (table && path != table) { HDassert(table == H5T_g.path[md]); - H5T__print_stats(table, &nprint/*in,out*/); + H5T__print_stats(table, &nprint /*in,out*/); table->cdata.command = H5T_CONV_FREE; - if(table->conv.is_app) { - if((table->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (table->conv.is_app) { + if ((table->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) + if (H5DEBUG(T)) HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + (unsigned long)(path->conv.u.app_func), path->name); #endif H5E_clear_stack(NULL); /*ignore the failure*/ - } /* end if */ - } /* end if */ - else - if((table->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + } /* end if */ + } /* end if */ + else if ((table->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n", + (unsigned long)(path->conv.u.lib_func), path->name); #endif - H5E_clear_stack(NULL); /*ignore the failure*/ - } /* end if */ - if(table->src) + H5E_clear_stack(NULL); /*ignore the failure*/ + } /* end if */ + if (table->src) (void)H5T_close_real(table->src); - if(table->dst) + if (table->dst) (void)H5T_close_real(table->dst); - table = H5FL_FREE(H5T_path_t, table); - table = path; + table = H5FL_FREE(H5T_path_t, table); + table = path; H5T_g.path[md] = path; } /* end if */ - else if(path != table) { + else if (path != table) { HDassert(cmp); - if((size_t)H5T_g.npaths >= H5T_g.apaths) { - size_t na = MAX(128, 2 * H5T_g.apaths); + if ((size_t)H5T_g.npaths >= H5T_g.apaths) { + size_t na = MAX(128, 2 * H5T_g.apaths); H5T_path_t **x; - if(NULL == (x = (H5T_path_t **)H5MM_realloc(H5T_g.path, na * sizeof(H5T_path_t*)))) + if (NULL == (x = (H5T_path_t **)H5MM_realloc(H5T_g.path, na * sizeof(H5T_path_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5T_g.apaths = na; - H5T_g.path = x; + H5T_g.path = x; } /* end if */ - if(cmp > 0) + if (cmp > 0) md++; - HDmemmove(H5T_g.path + md + 1, H5T_g.path + md, (size_t) (H5T_g.npaths - md) * sizeof(H5T_path_t*)); + HDmemmove(H5T_g.path + md + 1, H5T_g.path + md, (size_t)(H5T_g.npaths - md) * sizeof(H5T_path_t *)); H5T_g.npaths++; H5T_g.path[md] = path; - table = path; + table = path; } /* end else-if */ /* Set the flag to indicate both source and destination types are compound types * for the optimization of data reading (in H5Dio.c). */ - if(H5T_COMPOUND == H5T_get_class(src, TRUE) && H5T_COMPOUND == H5T_get_class(dst, TRUE)) + if (H5T_COMPOUND == H5T_get_class(src, TRUE) && H5T_COMPOUND == H5T_get_class(dst, TRUE)) path->are_compounds = TRUE; /* Set return value */ ret_value = path; done: - if(!ret_value && path && path != table) { - if(path->src) + if (!ret_value && path && path != table) { + if (path->src) (void)H5T_close_real(path->src); - if(path->dst) + if (path->dst) (void)H5T_close_real(path->dst); path = H5FL_FREE(H5T_path_t, path); } /* end if */ - if(src_id >= 0) + if (src_id >= 0) H5I_dec_ref(src_id); - if(dst_id >= 0) + if (dst_id >= 0) H5I_dec_ref(dst_id); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__path_find_real() */ - /*------------------------------------------------------------------------- * Function: H5T_path_noop * @@ -5148,10 +5278,9 @@ H5T_path_noop(const H5T_path_t *p) HDassert(p); - FUNC_LEAVE_NOAPI(p->is_noop || (p->is_hard && 0==H5T_cmp(p->src, p->dst, FALSE))) + FUNC_LEAVE_NOAPI(p->is_noop || (p->is_hard && 0 == H5T_cmp(p->src, p->dst, FALSE))) } /* end H5T_path_noop() */ - /*------------------------------------------------------------------------- * Function: H5T_path_compound_subset * @@ -5189,13 +5318,12 @@ H5T_path_compound_subset(const H5T_path_t *p) HDassert(p); - if(p->are_compounds) + if (p->are_compounds) ret_value = H5T__conv_struct_subset(&(p->cdata)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_path_compound_subset */ - /*------------------------------------------------------------------------- * Function: H5T_path_bkg * @@ -5217,7 +5345,6 @@ H5T_path_bkg(const H5T_path_t *p) FUNC_LEAVE_NOAPI(p->cdata.need_bkg) } /* end H5T_path_bkg() */ - /*------------------------------------------------------------------------- * Function: H5T__compiler_conv * @@ -5236,13 +5363,13 @@ H5T_path_bkg(const H5T_path_t *p) static htri_t H5T__compiler_conv(H5T_t *src, H5T_t *dst) { - H5T_path_t *path; - htri_t ret_value = FAIL; /* Return value */ + H5T_path_t *path; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC /* Find it */ - if(NULL == (path = H5T_path_find(src, dst))) + if (NULL == (path = H5T_path_find(src, dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "conversion function not found") ret_value = (htri_t)path->is_hard; @@ -5251,7 +5378,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__compiler_conv() */ - /*------------------------------------------------------------------------- * Function: H5T_convert * @@ -5268,18 +5394,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, - size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) { #ifdef H5T_DEBUG - H5_timer_t timer; /* Timer for conversion */ + H5_timer_t timer; /* Timer for conversion */ #endif - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5T_DEBUG - if(H5DEBUG(T)) { + if (H5DEBUG(T)) { /* Initialize and start timer */ H5_timer_init(&timer); H5_timer_start(&timer); @@ -5288,15 +5414,16 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, /* Call the appropriate conversion callback */ tpath->cdata.command = H5T_CONV_CONV; - if(tpath->conv.is_app) { - if((tpath->conv.u.app_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, bkg, H5CX_get_dxpl()) < 0) + if (tpath->conv.is_app) { + if ((tpath->conv.u.app_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, + bkg, H5CX_get_dxpl()) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end if */ - else - if((tpath->conv.u.lib_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, bkg) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed") + else if ((tpath->conv.u.lib_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, + bkg) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed") #ifdef H5T_DEBUG - if(H5DEBUG(T)) { + if (H5DEBUG(T)) { /* Stop timer */ H5_timer_stop(&timer); @@ -5313,7 +5440,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_convert() */ - /*------------------------------------------------------------------------- * Function: H5T_oloc * @@ -5336,7 +5462,7 @@ H5T_oloc(H5T_t *dt) HDassert(dt); - switch(dt->shared->state) { + switch (dt->shared->state) { case H5T_STATE_TRANSIENT: case H5T_STATE_RDONLY: case H5T_STATE_IMMUTABLE: @@ -5354,7 +5480,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_oloc() */ - /*------------------------------------------------------------------------- * Function: H5T_nameof * @@ -5377,7 +5502,7 @@ H5T_nameof(const H5T_t *dt) HDassert(dt); - switch(dt->shared->state) { + switch (dt->shared->state) { case H5T_STATE_TRANSIENT: case H5T_STATE_RDONLY: case H5T_STATE_IMMUTABLE: @@ -5394,7 +5519,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_nameof() */ - /*------------------------------------------------------------------------- * Function: H5T_is_immutable * @@ -5417,14 +5541,13 @@ H5T_is_immutable(const H5T_t *dt) HDassert(dt); - if(dt->shared->state == H5T_STATE_IMMUTABLE) + if (dt->shared->state == H5T_STATE_IMMUTABLE) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T_is_named * @@ -5443,7 +5566,7 @@ H5T_is_named(const H5T_t *dt) HDassert(dt); - if(dt->vol_obj) + if (dt->vol_obj) ret_value = TRUE; else ret_value = (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state); @@ -5472,32 +5595,32 @@ done: herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(dt); HDassert(f); - if(H5T_is_named(dt) && (dt->sh_loc.file != f)) { - HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED); + if (H5T_is_named(dt) && (dt->sh_loc.file != f)) { + HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED); H5O_msg_reset_share(H5O_DTYPE_ID, dt); - if(H5O_loc_free(&dt->oloc) < 0) + if (H5O_loc_free(&dt->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to initialize location") - if(H5G_name_free(&dt->path) < 0) + if (H5G_name_free(&dt->path) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path") /* If the datatype is committed through the VOL, close it */ - if(NULL != dt->vol_obj) { + if (NULL != dt->vol_obj) { H5VL_object_t *vol_obj = dt->vol_obj; /* Close the datatype through the VOL*/ - if(H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") /* Free the datatype and set the VOL object pointer to NULL */ - if(H5VL_free_object(vol_obj) < 0) + if (H5VL_free_object(vol_obj) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") dt->vol_obj = NULL; } /* end if */ @@ -5507,8 +5630,7 @@ H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_convert_committed_datatype() */ - +} /* end H5T_convert_committed_datatype() */ /*-------------------------------------------------------------------------- * Function: H5T_get_ref_type @@ -5531,13 +5653,12 @@ H5T_get_ref_type(const H5T_t *dt) HDassert(dt); - if(dt->shared->type==H5T_REFERENCE) - ret_value=dt->shared->u.atomic.u.r.rtype; + if (dt->shared->type == H5T_REFERENCE) + ret_value = dt->shared->u.atomic.u.r.rtype; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_get_ref_type() */ - +} /* end H5T_get_ref_type() */ /*------------------------------------------------------------------------- * Function: H5T_is_sensible @@ -5556,27 +5677,27 @@ done: htri_t H5T_is_sensible(const H5T_t *dt) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(dt); - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: /* Only allow compound datatypes with at least one member to be stored on disk */ - if(dt->shared->u.compnd.nmembs > 0) - ret_value=TRUE; + if (dt->shared->u.compnd.nmembs > 0) + ret_value = TRUE; else - ret_value=FALSE; + ret_value = FALSE; break; case H5T_ENUM: /* Only allow enum datatypes with at least one member to be stored on disk */ - if(dt->shared->u.enumer.nmembs > 0) - ret_value=TRUE; + if (dt->shared->u.enumer.nmembs > 0) + ret_value = TRUE; else - ret_value=FALSE; + ret_value = FALSE; break; case H5T_NO_CLASS: @@ -5592,7 +5713,7 @@ H5T_is_sensible(const H5T_t *dt) case H5T_NCLASSES: default: /* Assume all other datatype are sensible to store on disk */ - ret_value=TRUE; + ret_value = TRUE; break; } /* end switch */ @@ -5600,7 +5721,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*-------------------------------------------------------------------------- NAME H5T_set_loc @@ -5625,118 +5745,123 @@ done: htri_t H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) { - htri_t changed; /* Whether H5T_set_loc changed the type (even if the size didn't change) */ - htri_t ret_value = 0; /* Indicate that success, but no location change */ - unsigned i; /* Local index variable */ - size_t old_size; /* Previous size of a field */ + htri_t changed; /* Whether H5T_set_loc changed the type (even if the size didn't change) */ + htri_t ret_value = 0; /* Indicate that success, but no location change */ + unsigned i; /* Local index variable */ + size_t old_size; /* Previous size of a field */ FUNC_ENTER_NOAPI(FAIL) HDassert(dt); - HDassert(loc>=H5T_LOC_BADLOC && loc= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); /* Datatypes can't change in size if the force_conv flag is not set */ - if(dt->shared->force_conv) { + if (dt->shared->force_conv) { /* Check the datatype of this element */ - switch(dt->shared->type) { - case H5T_ARRAY: /* Recurse on VL, compound and array base element type */ + switch (dt->shared->type) { + case H5T_ARRAY: /* Recurse on VL, compound and array base element type */ /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + if (dt->shared->parent->shared->force_conv && + H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { /* Keep the old base element size for later */ - old_size=dt->shared->parent->shared->size; + old_size = dt->shared->parent->shared->size; /* Mark the VL, compound or array type */ - if((changed=H5T_set_loc(dt->shared->parent, file, loc))<0) + if ((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") - if(changed>0) - ret_value=changed; + if (changed > 0) + ret_value = changed; /* Check if the field changed size */ - if(old_size != dt->shared->parent->shared->size) { + if (old_size != dt->shared->parent->shared->size) { /* Adjust the size of the array */ - dt->shared->size = dt->shared->u.array.nelem*dt->shared->parent->shared->size; + dt->shared->size = dt->shared->u.array.nelem * dt->shared->parent->shared->size; } /* end if */ - } /* end if */ + } /* end if */ break; - case H5T_COMPOUND: /* Check each field and recurse on VL, compound and array type */ - { - ssize_t accum_change = 0; /* Amount of change in the offset of the fields */ + case H5T_COMPOUND: /* Check each field and recurse on VL, compound and array type */ + { + ssize_t accum_change = 0; /* Amount of change in the offset of the fields */ - /* Sort the fields based on offsets */ - H5T__sort_value(dt, NULL); + /* Sort the fields based on offsets */ + H5T__sort_value(dt, NULL); - for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { - H5T_t *memb_type; /* Member's datatype pointer */ + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + H5T_t *memb_type; /* Member's datatype pointer */ - /* Range check against compound member's offset */ - if ((accum_change < 0) && ((ssize_t) dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); + /* Range check against compound member's offset */ + if ((accum_change < 0) && ((ssize_t)dt->shared->u.compnd.memb[i].offset < accum_change)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); - /* Apply the accumulated size change to the offset of the field */ - dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; + /* Apply the accumulated size change to the offset of the field */ + dt->shared->u.compnd.memb[i].offset += (size_t)accum_change; - /* Set the member type pointer (for convenience) */ - memb_type = dt->shared->u.compnd.memb[i].type; + /* Set the member type pointer (for convenience) */ + memb_type = dt->shared->u.compnd.memb[i].type; - /* Recurse if it's VL, compound, enum or array */ - /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(memb_type->shared->force_conv && H5T_IS_COMPLEX(memb_type->shared->type)) { - /* Keep the old field size for later */ - old_size = memb_type->shared->size; + /* Recurse if it's VL, compound, enum or array */ + /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) + */ + if (memb_type->shared->force_conv && H5T_IS_COMPLEX(memb_type->shared->type)) { + /* Keep the old field size for later */ + old_size = memb_type->shared->size; - /* Mark the VL, compound, enum or array type */ - if((changed = H5T_set_loc(memb_type, file, loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); - if(changed > 0) - ret_value = changed; + /* Mark the VL, compound, enum or array type */ + if ((changed = H5T_set_loc(memb_type, file, loc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + if (changed > 0) + ret_value = changed; - /* Check if the field changed size */ - if(old_size != memb_type->shared->size) { + /* Check if the field changed size */ + if (old_size != memb_type->shared->size) { - /* Fail if the old_size is zero */ - if (0 == old_size) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero"); + /* Fail if the old_size is zero */ + if (0 == old_size) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, + "old_size of zero would cause division by zero"); - /* Adjust the size of the member */ - dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size; + /* Adjust the size of the member */ + dt->shared->u.compnd.memb[i].size = + (dt->shared->u.compnd.memb[i].size * memb_type->shared->size) / old_size; - /* Add that change to the accumulated size change */ - accum_change += (ssize_t) (memb_type->shared->size - old_size); - } /* end if */ + /* Add that change to the accumulated size change */ + accum_change += (ssize_t)(memb_type->shared->size - old_size); } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ - /* Range check against datatype size */ - if ((accum_change < 0) && ((ssize_t) dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); + /* Range check against datatype size */ + if ((accum_change < 0) && ((ssize_t)dt->shared->size < accum_change)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); - /* Apply the accumulated size change to the datatype */ - dt->shared->size += (size_t) accum_change; - } - break; + /* Apply the accumulated size change to the datatype */ + dt->shared->size += (size_t)accum_change; + } break; - case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL sequence */ + case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL + sequence */ /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { - if((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) + if (dt->shared->parent->shared->force_conv && + H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + if ((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); - if(changed > 0) + if (changed > 0) ret_value = changed; } /* end if */ /* Mark this VL sequence */ - if((changed = H5T__vlen_set_loc(dt, file, loc)) < 0) + if ((changed = H5T__vlen_set_loc(dt, file, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); - if(changed > 0) + if (changed > 0) ret_value = changed; break; case H5T_REFERENCE: /* Reference types go through type conversion */ - if((ret_value = H5T__ref_set_loc(dt, file, loc)) < 0) + if ((ret_value = H5T__ref_set_loc(dt, file, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "Unable to set reference location"); break; @@ -5752,12 +5877,11 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) default: break; } /* end switch */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_set_loc() */ - +} /* end H5T_set_loc() */ /*------------------------------------------------------------------------- * Function: H5T_is_relocatable @@ -5790,14 +5914,13 @@ H5T_is_relocatable(const H5T_t *dt) HDassert(dt); /* VL and reference datatypes are relocatable */ - if(H5T_detect_class(dt, H5T_VLEN, FALSE) || H5T_detect_class(dt, H5T_REFERENCE, FALSE)) + if (H5T_detect_class(dt, H5T_VLEN, FALSE) || H5T_detect_class(dt, H5T_REFERENCE, FALSE)) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_relocatable() */ - /*------------------------------------------------------------------------- * Function: H5T__detect_vlen_ref * @@ -5815,8 +5938,8 @@ done: static hbool_t H5T__detect_vlen_ref(const H5T_t *dt) { - unsigned u; /* Local index variable */ - hbool_t ret_value = FALSE; /* Return value */ + unsigned u; /* Local index variable */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -5825,16 +5948,16 @@ H5T__detect_vlen_ref(const H5T_t *dt) /* Check if this datatype is a vlen reference */ /* TODO currently H5T_STD_REF is always considered as a vlen type */ - if(H5T_REFERENCE == dt->shared->type && !dt->shared->u.atomic.u.r.opaque) + if (H5T_REFERENCE == dt->shared->type && !dt->shared->u.atomic.u.r.opaque) HGOTO_DONE(TRUE); /* Check for types that might have the correct type as a component */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: /* Iterate over all the compound datatype's fields */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) /* Recurse on field's datatype */ - if(H5T__detect_vlen_ref(dt->shared->u.compnd.memb[u].type)) + if (H5T__detect_vlen_ref(dt->shared->u.compnd.memb[u].type)) HGOTO_DONE(TRUE); break; @@ -5861,7 +5984,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__detect_vlen_ref() */ - /*------------------------------------------------------------------------- * Function: H5T_is_vl_storage * @@ -5892,9 +6014,9 @@ H5T_is_vl_storage(const H5T_t *dt) HDassert(dt); /* VL and region reference datatypes are stored in variable-length form */ - if(H5T_detect_class(dt, H5T_VLEN, FALSE)) + if (H5T_detect_class(dt, H5T_VLEN, FALSE)) ret_value = TRUE; - else if(H5T_detect_class(dt, H5T_REFERENCE, FALSE)) + else if (H5T_detect_class(dt, H5T_REFERENCE, FALSE)) ret_value = H5T__detect_vlen_ref(dt); else ret_value = FALSE; @@ -5903,7 +6025,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_vl_storage() */ - /*------------------------------------------------------------------------- * Function: H5T_upgrade_version_cb * @@ -5931,17 +6052,17 @@ H5T_upgrade_version_cb(H5T_t *dt, void *op_value) HDassert(op_value); /* Special behavior for each type of datatype */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: case H5T_ARRAY: case H5T_ENUM: /* These types benefit from "upgrading" their version */ - if(*(unsigned *)op_value > dt->shared->version) + if (*(unsigned *)op_value > dt->shared->version) dt->shared->version = *(unsigned *)op_value; break; case H5T_VLEN: - if(dt->shared->parent->shared->version > dt->shared->version) + if (dt->shared->parent->shared->version > dt->shared->version) dt->shared->version = dt->shared->parent->shared->version; break; @@ -5961,7 +6082,6 @@ H5T_upgrade_version_cb(H5T_t *dt, void *op_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T_upgrade_version_cb() */ - /*------------------------------------------------------------------------- * Function: H5T__upgrade_version * @@ -5979,7 +6099,7 @@ H5T_upgrade_version_cb(H5T_t *dt, void *op_value) herr_t H5T__upgrade_version(H5T_t *dt, unsigned new_version) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5987,14 +6107,13 @@ H5T__upgrade_version(H5T_t *dt, unsigned new_version) HDassert(dt); /* Iterate over entire datatype, upgrading the version of components, if it's useful */ - if(H5T__visit(dt, (H5T_VISIT_SIMPLE | H5T_VISIT_COMPLEX_LAST), H5T_upgrade_version_cb, &new_version) < 0) + if (H5T__visit(dt, (H5T_VISIT_SIMPLE | H5T_VISIT_COMPLEX_LAST), H5T_upgrade_version_cb, &new_version) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "iteration to upgrade datatype encoding version failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__upgrade_version() */ - /*------------------------------------------------------------------------- * Function: H5T_set_version * @@ -6011,8 +6130,8 @@ done: herr_t H5T_set_version(H5F_t *f, H5T_t *dt) { - unsigned vers; /* The version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned vers; /* The version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6021,21 +6140,20 @@ H5T_set_version(H5F_t *f, H5T_t *dt) HDassert(dt); vers = H5O_dtype_ver_bounds[H5F_LOW_BOUND(f)]; - if(vers > dt->shared->version) { + if (vers > dt->shared->version) { /* Upgrade the format version for the datatype */ - if(H5T__upgrade_version(dt, vers) < 0) + if (H5T__upgrade_version(dt, vers) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade datatype encoding") } /* Version bounds check */ - if(dt->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(f)]) + if (dt->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "Datatype version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_set_version() */ - /*------------------------------------------------------------------------- * Function: H5T_patch_file * @@ -6062,8 +6180,8 @@ H5T_patch_file(H5T_t *dt, H5F_t *f) HDassert(dt); HDassert(f); - if(H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state) { - dt->oloc.file = f; + if (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state) { + dt->oloc.file = f; dt->sh_loc.file = f; } /* end if */ @@ -6071,7 +6189,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_patch_file() */ - /*------------------------------------------------------------------------- * Function: H5T_patch_vlen_file * @@ -6094,13 +6211,12 @@ H5T_patch_vlen_file(H5T_t *dt, H5VL_object_t *file) HDassert(dt->shared); HDassert(file); - if((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.file != file) + if ((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.file != file) dt->shared->u.vlen.file = file; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T_patch_vlen_file() */ - /*------------------------------------------------------------------------- * Function: H5T_own_vol_obj * @@ -6128,7 +6244,7 @@ H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj) * owned object. Currently this is only used for holding open VOL objects * used in the "loc" for vlens and references, so if this is being * overwritten we don't need the old one anyways. */ - if(dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) + if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object") /* Take ownership */ @@ -6137,4 +6253,3 @@ H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_own_vol_obj() */ - diff --git a/src/H5TS.c b/src/H5TS.c index ee3b219..bd1b748 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -12,9 +12,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* private headers */ -#include "H5private.h" /*library */ -#include "H5Eprivate.h" /*error handling */ -#include "H5MMprivate.h" /*memory management functions */ +#include "H5private.h" /*library */ +#include "H5Eprivate.h" /*error handling */ +#include "H5MMprivate.h" /*memory management functions */ #ifdef H5_HAVE_THREADSAFE @@ -22,14 +22,14 @@ /* cancelability structure */ typedef struct H5TS_cancel_struct { - int previous_state; + int previous_state; unsigned int cancel_count; } H5TS_cancel_t; /* Global variable definitions */ #ifdef H5_HAVE_WIN_THREADS H5TS_once_t H5TS_first_init_g; -#else /* H5_HAVE_WIN_THREADS */ +#else /* H5_HAVE_WIN_THREADS */ H5TS_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT; #endif /* H5_HAVE_WIN_THREADS */ H5TS_key_t H5TS_errstk_key_g; @@ -47,12 +47,12 @@ typedef struct _tid H5TS_tid_t; struct _tid { H5TS_tid_t *next; - uint64_t id; + uint64_t id; }; /* Pointer to first free thread ID record or NULL. */ static H5TS_tid_t *H5TS_tid_next_free = NULL; -static uint64_t H5TS_tid_next_id = 0; +static uint64_t H5TS_tid_next_id = 0; /* Mutual exclusion for access to H5TS_tid_next_free and H5TS_tid_next_id. */ static pthread_mutex_t H5TS_tid_mtx; @@ -62,7 +62,6 @@ static H5TS_key_t H5TS_tid_key; #endif /* H5_HAVE_WIN_THREADS */ - /*-------------------------------------------------------------------------- * NAME * H5TS_key_destructor @@ -86,11 +85,10 @@ static void H5TS_key_destructor(void *key_val) { /* Use HDfree here instead of H5MM_xfree(), to avoid calling the H5CS routines */ - if(key_val != NULL) + if (key_val != NULL) HDfree(key_val); } - #ifndef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- @@ -117,7 +115,7 @@ H5TS_tid_destructor(void *_v) /* TBD use an atomic CAS */ pthread_mutex_lock(&H5TS_tid_mtx); - tid->next = H5TS_tid_next_free; + tid->next = H5TS_tid_next_free; H5TS_tid_next_free = tid; pthread_mutex_unlock(&H5TS_tid_mtx); } @@ -171,7 +169,7 @@ uint64_t H5TS_thread_id(void) { H5TS_tid_t *tid = pthread_getspecific(H5TS_tid_key); - H5TS_tid_t proto_tid; + H5TS_tid_t proto_tid; /* An ID is already assigned. */ if (tid != NULL) @@ -188,7 +186,7 @@ H5TS_thread_id(void) if ((tid = H5TS_tid_next_free) != NULL) H5TS_tid_next_free = tid->next; else if (H5TS_tid_next_id != UINT64_MAX) { - tid = &proto_tid; + tid = &proto_tid; tid->id = ++H5TS_tid_next_id; } pthread_mutex_unlock(&H5TS_tid_mtx); @@ -236,13 +234,13 @@ H5TS_thread_id(void) void H5TS_pthread_first_thread_init(void) { - H5_g.H5_libinit_g = FALSE; /* Library hasn't been initialized */ - H5_g.H5_libterm_g = FALSE; /* Library isn't being shutdown */ + H5_g.H5_libinit_g = FALSE; /* Library hasn't been initialized */ + H5_g.H5_libterm_g = FALSE; /* Library isn't being shutdown */ #ifdef H5_HAVE_WIN32_API -# ifdef PTW32_STATIC_LIB +#ifdef PTW32_STATIC_LIB pthread_win32_process_attach_np(); -# endif +#endif #endif /* initialize global API mutex lock */ @@ -267,7 +265,6 @@ H5TS_pthread_first_thread_init(void) } #endif /* H5_HAVE_WIN_THREADS */ - /*-------------------------------------------------------------------------- * NAME * H5TS_mutex_lock @@ -291,33 +288,33 @@ H5TS_pthread_first_thread_init(void) herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex) { -#ifdef H5_HAVE_WIN_THREADS - EnterCriticalSection( &mutex->CriticalSection); +#ifdef H5_HAVE_WIN_THREADS + EnterCriticalSection(&mutex->CriticalSection); return 0; -#else /* H5_HAVE_WIN_THREADS */ +#else /* H5_HAVE_WIN_THREADS */ herr_t ret_value = pthread_mutex_lock(&mutex->atomic_lock); if (ret_value) return ret_value; - if(mutex->lock_count && pthread_equal(pthread_self(), mutex->owner_thread)) { + if (mutex->lock_count && pthread_equal(pthread_self(), mutex->owner_thread)) { /* already owned by self - increment count */ mutex->lock_count++; - } else { + } + else { /* if owned by other thread, wait for condition signal */ - while(mutex->lock_count) + while (mutex->lock_count) pthread_cond_wait(&mutex->cond_var, &mutex->atomic_lock); /* After we've received the signal, take ownership of the mutex */ mutex->owner_thread = pthread_self(); - mutex->lock_count = 1; + mutex->lock_count = 1; } return pthread_mutex_unlock(&mutex->atomic_lock); #endif /* H5_HAVE_WIN_THREADS */ } - /*-------------------------------------------------------------------------- * NAME * H5TS_mutex_unlock @@ -341,25 +338,25 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex) { -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS /* Releases ownership of the specified critical section object. */ LeaveCriticalSection(&mutex->CriticalSection); return 0; #else /* H5_HAVE_WIN_THREADS */ herr_t ret_value = pthread_mutex_lock(&mutex->atomic_lock); - if(ret_value) + if (ret_value) return ret_value; mutex->lock_count--; ret_value = pthread_mutex_unlock(&mutex->atomic_lock); - if(mutex->lock_count == 0) { + if (mutex->lock_count == 0) { int err; err = pthread_cond_signal(&mutex->cond_var); - if(err != 0) + if (err != 0) ret_value = err; } /* end if */ @@ -367,7 +364,6 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) #endif /* H5_HAVE_WIN_THREADS */ } /* H5TS_mutex_unlock */ - /*-------------------------------------------------------------------------- * NAME * H5TS_cancel_count_inc @@ -395,12 +391,12 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) herr_t H5TS_cancel_count_inc(void) { -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS /* unsupported; just return 0 */ return SUCCEED; -#else /* H5_HAVE_WIN_THREADS */ +#else /* H5_HAVE_WIN_THREADS */ H5TS_cancel_t *cancel_counter; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; cancel_counter = (H5TS_cancel_t *)H5TS_get_thread_local_value(H5TS_cancel_key_g); @@ -424,8 +420,7 @@ H5TS_cancel_count_inc(void) if (cancel_counter->cancel_count == 0) /* thread entering library */ - ret_value = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, - &cancel_counter->previous_state); + ret_value = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_counter->previous_state); ++cancel_counter->cancel_count; @@ -433,7 +428,6 @@ H5TS_cancel_count_inc(void) #endif /* H5_HAVE_WIN_THREADS */ } - /*-------------------------------------------------------------------------- * NAME * H5TS_cancel_count_dec @@ -459,12 +453,12 @@ H5TS_cancel_count_inc(void) herr_t H5TS_cancel_count_dec(void) { -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS /* unsupported; will just return 0 */ return SUCCEED; -#else /* H5_HAVE_WIN_THREADS */ +#else /* H5_HAVE_WIN_THREADS */ register H5TS_cancel_t *cancel_counter; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; cancel_counter = (H5TS_cancel_t *)H5TS_get_thread_local_value(H5TS_cancel_key_g); @@ -477,7 +471,6 @@ H5TS_cancel_count_dec(void) #endif /* H5_HAVE_WIN_THREADS */ } - #ifdef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- * NAME @@ -500,22 +493,21 @@ H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex) InitializeCriticalSection(&H5_g.init_lock.CriticalSection); /* Set up thread local storage */ - if(TLS_OUT_OF_INDEXES == (H5TS_errstk_key_g = TlsAlloc())) + if (TLS_OUT_OF_INDEXES == (H5TS_errstk_key_g = TlsAlloc())) ret_value = FALSE; #ifdef H5_HAVE_CODESTACK - if(TLS_OUT_OF_INDEXES == (H5TS_funcstk_key_g = TlsAlloc())) + if (TLS_OUT_OF_INDEXES == (H5TS_funcstk_key_g = TlsAlloc())) ret_value = FALSE; #endif /* H5_HAVE_CODESTACK */ - if(TLS_OUT_OF_INDEXES == (H5TS_apictx_key_g = TlsAlloc())) + if (TLS_OUT_OF_INDEXES == (H5TS_apictx_key_g = TlsAlloc())) ret_value = FALSE; return ret_value; } /* H5TS_win32_process_enter() */ #endif /* H5_HAVE_WIN_THREADS */ - #ifdef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- * NAME @@ -546,7 +538,6 @@ H5TS_win32_thread_enter(void) } /* H5TS_win32_thread_enter() */ #endif /* H5_HAVE_WIN_THREADS */ - #ifdef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- * NAME @@ -585,7 +576,6 @@ H5TS_win32_process_exit(void) } /* H5TS_win32_process_exit() */ #endif /* H5_HAVE_WIN_THREADS */ - #ifdef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- * NAME @@ -615,24 +605,23 @@ H5TS_win32_thread_exit(void) /* Clean up per-thread thread local storage */ lpvData = TlsGetValue(H5TS_errstk_key_g); - if(lpvData) + if (lpvData) LocalFree((HLOCAL)lpvData); #ifdef H5_HAVE_CODESTACK lpvData = TlsGetValue(H5TS_funcstk_key_g); - if(lpvData) + if (lpvData) LocalFree((HLOCAL)lpvData); #endif /* H5_HAVE_CODESTACK */ lpvData = TlsGetValue(H5TS_apictx_key_g); - if(lpvData) + if (lpvData) LocalFree((HLOCAL)lpvData); return ret_value; } /* H5TS_win32_thread_exit() */ #endif /* H5_HAVE_WIN_THREADS */ - /*-------------------------------------------------------------------------- * NAME * H5TS_create_thread @@ -653,7 +642,7 @@ H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata) { H5TS_thread_t ret_value; -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS /* When calling C runtime functions, you should use _beginthread or * _beginthreadex instead of CreateThread. Threads created with @@ -669,7 +658,7 @@ H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata) #else /* H5_HAVE_WIN_THREADS */ - pthread_create(&ret_value, attr, (void * (*)(void *))func, udata); + pthread_create(&ret_value, attr, (void *(*)(void *))func, udata); #endif /* H5_HAVE_WIN_THREADS */ @@ -677,5 +666,4 @@ H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata) } /* H5TS_create_thread */ -#endif /* H5_HAVE_THREADSAFE */ - +#endif /* H5_HAVE_THREADSAFE */ diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h index 887f001..2ce8528 100644 --- a/src/H5TSprivate.h +++ b/src/H5TSprivate.h @@ -29,8 +29,8 @@ #ifdef H5_HAVE_THREADSAFE /* Public headers needed by this file */ #ifdef LATER -#include "H5TSpublic.h" /*Public API prototypes */ -#endif /* LATER */ +#include "H5TSpublic.h" /*Public API prototypes */ +#endif /* LATER */ #ifdef H5_HAVE_WIN_THREADS @@ -38,36 +38,36 @@ /* Mutexes, Threads, and Attributes */ typedef struct H5TS_mutex_struct { - CRITICAL_SECTION CriticalSection; + CRITICAL_SECTION CriticalSection; } H5TS_mutex_t; typedef CRITICAL_SECTION H5TS_mutex_simple_t; -typedef HANDLE H5TS_thread_t; -typedef HANDLE H5TS_attr_t; -typedef DWORD H5TS_key_t; -typedef INIT_ONCE H5TS_once_t; +typedef HANDLE H5TS_thread_t; +typedef HANDLE H5TS_attr_t; +typedef DWORD H5TS_key_t; +typedef INIT_ONCE H5TS_once_t; /* Defines */ /* not used on windows side, but need to be defined to something */ -#define H5TS_SCOPE_SYSTEM 0 +#define H5TS_SCOPE_SYSTEM 0 #define H5TS_SCOPE_PROCESS 0 -#define H5TS_CALL_CONV WINAPI +#define H5TS_CALL_CONV WINAPI /* Functions */ -#define H5TS_get_thread_local_value(key) TlsGetValue( key ) -#define H5TS_set_thread_local_value(key, value) TlsSetValue( key, value ) -#define H5TS_attr_init(attr_ptr) 0 -#define H5TS_attr_setscope(attr_ptr, scope) 0 -#define H5TS_attr_destroy(attr_ptr) 0 -#define H5TS_wait_for_thread(thread) WaitForSingleObject(thread, INFINITE) -#define H5TS_mutex_init(mutex) InitializeCriticalSection(mutex) -#define H5TS_mutex_lock_simple(mutex) EnterCriticalSection(mutex) -#define H5TS_mutex_unlock_simple(mutex) LeaveCriticalSection(mutex) +#define H5TS_get_thread_local_value(key) TlsGetValue(key) +#define H5TS_set_thread_local_value(key, value) TlsSetValue(key, value) +#define H5TS_attr_init(attr_ptr) 0 +#define H5TS_attr_setscope(attr_ptr, scope) 0 +#define H5TS_attr_destroy(attr_ptr) 0 +#define H5TS_wait_for_thread(thread) WaitForSingleObject(thread, INFINITE) +#define H5TS_mutex_init(mutex) InitializeCriticalSection(mutex) +#define H5TS_mutex_lock_simple(mutex) EnterCriticalSection(mutex) +#define H5TS_mutex_unlock_simple(mutex) LeaveCriticalSection(mutex) /* Functions called from DllMain */ H5_DLL BOOL CALLBACK H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex); -H5_DLL void H5TS_win32_process_exit(void); -H5_DLL herr_t H5TS_win32_thread_enter(void); -H5_DLL herr_t H5TS_win32_thread_exit(void); +H5_DLL void H5TS_win32_process_exit(void); +H5_DLL herr_t H5TS_win32_thread_enter(void); +H5_DLL herr_t H5TS_win32_thread_exit(void); #define H5TS_thread_id() ((uint64_t)GetCurrentThreadId()) @@ -77,57 +77,56 @@ H5_DLL herr_t H5TS_win32_thread_exit(void); /* Mutexes, Threads, and Attributes */ typedef struct H5TS_mutex_struct { - pthread_t owner_thread; /* current lock owner */ - pthread_mutex_t atomic_lock; /* lock for atomicity of new mechanism */ - pthread_cond_t cond_var; /* condition variable */ - unsigned int lock_count; + pthread_t owner_thread; /* current lock owner */ + pthread_mutex_t atomic_lock; /* lock for atomicity of new mechanism */ + pthread_cond_t cond_var; /* condition variable */ + unsigned int lock_count; } H5TS_mutex_t; -typedef pthread_t H5TS_thread_t; -typedef pthread_attr_t H5TS_attr_t; +typedef pthread_t H5TS_thread_t; +typedef pthread_attr_t H5TS_attr_t; typedef pthread_mutex_t H5TS_mutex_simple_t; -typedef pthread_key_t H5TS_key_t; -typedef pthread_once_t H5TS_once_t; +typedef pthread_key_t H5TS_key_t; +typedef pthread_once_t H5TS_once_t; /* Scope Definitions */ -#define H5TS_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM -#define H5TS_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS -#define H5TS_CALL_CONV /* unused - Windows only */ +#define H5TS_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM +#define H5TS_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +#define H5TS_CALL_CONV /* unused - Windows only */ /* Functions */ -#define H5TS_get_thread_local_value(key) pthread_getspecific( key ) -#define H5TS_set_thread_local_value(key, value) pthread_setspecific( key, value ) -#define H5TS_attr_init(attr_ptr) pthread_attr_init((attr_ptr)) -#define H5TS_attr_setscope(attr_ptr, scope) pthread_attr_setscope(attr_ptr, scope) -#define H5TS_attr_destroy(attr_ptr) pthread_attr_destroy(attr_ptr) -#define H5TS_wait_for_thread(thread) pthread_join(thread, NULL) -#define H5TS_mutex_init(mutex) pthread_mutex_init(mutex, NULL) -#define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex) -#define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex) +#define H5TS_get_thread_local_value(key) pthread_getspecific(key) +#define H5TS_set_thread_local_value(key, value) pthread_setspecific(key, value) +#define H5TS_attr_init(attr_ptr) pthread_attr_init((attr_ptr)) +#define H5TS_attr_setscope(attr_ptr, scope) pthread_attr_setscope(attr_ptr, scope) +#define H5TS_attr_destroy(attr_ptr) pthread_attr_destroy(attr_ptr) +#define H5TS_wait_for_thread(thread) pthread_join(thread, NULL) +#define H5TS_mutex_init(mutex) pthread_mutex_init(mutex, NULL) +#define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex) +#define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex) H5_DLL uint64_t H5TS_thread_id(void); #endif /* H5_HAVE_WIN_THREADS */ /* External global variables */ extern H5TS_once_t H5TS_first_init_g; -extern H5TS_key_t H5TS_errstk_key_g; -extern H5TS_key_t H5TS_funcstk_key_g; -extern H5TS_key_t H5TS_apictx_key_g; +extern H5TS_key_t H5TS_errstk_key_g; +extern H5TS_key_t H5TS_funcstk_key_g; +extern H5TS_key_t H5TS_apictx_key_g; #if defined c_plusplus || defined __cplusplus -extern "C" -{ -#endif /* c_plusplus || __cplusplus */ +extern "C" { +#endif /* c_plusplus || __cplusplus */ -H5_DLL void H5TS_pthread_first_thread_init(void); -H5_DLL herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex); -H5_DLL herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex); -H5_DLL herr_t H5TS_cancel_count_inc(void); -H5_DLL herr_t H5TS_cancel_count_dec(void); -H5_DLL H5TS_thread_t H5TS_create_thread(void *(*func)(void *), H5TS_attr_t * attr, void *udata); +H5_DLL void H5TS_pthread_first_thread_init(void); +H5_DLL herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex); +H5_DLL herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex); +H5_DLL herr_t H5TS_cancel_count_inc(void); +H5_DLL herr_t H5TS_cancel_count_dec(void); +H5_DLL H5TS_thread_t H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata); #if defined c_plusplus || defined __cplusplus } -#endif /* c_plusplus || __cplusplus */ +#endif /* c_plusplus || __cplusplus */ #else /* H5_HAVE_THREADSAFE */ @@ -135,5 +134,4 @@ H5_DLL H5TS_thread_t H5TS_create_thread(void *(*func)(void *), H5TS_attr_t * att #endif /* H5_HAVE_THREADSAFE */ -#endif /* H5TSprivate_H_ */ - +#endif /* H5TSprivate_H_ */ diff --git a/src/H5Tarray.c b/src/H5Tarray.c index 60b3d43..5afe74c 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -20,59 +20,48 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Tarray_create2 * @@ -95,42 +84,41 @@ hid_t H5Tarray_create2(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */]) { - H5T_t *base; /* base datatype */ - H5T_t *dt = NULL; /* new array datatype */ - unsigned u; /* local index variable */ - hid_t ret_value; /* return value */ + H5T_t * base; /* base datatype */ + H5T_t * dt = NULL; /* new array datatype */ + unsigned u; /* local index variable */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iIu*h", base_id, ndims, dim); /* Check args */ - if(ndims < 1 || ndims > H5S_MAX_RANK) + if (ndims < 1 || ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dimensionality") - if(!dim) + if (!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no dimensions specified") - for(u = 0; u < ndims; u++) - if(!(dim[u] > 0)) + for (u = 0; u < ndims; u++) + if (!(dim[u] > 0)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "zero-sized dimension specified") - if(NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) + if (NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an valid base datatype") /* Create the array datatype */ - if(NULL == (dt = H5T__array_create(base, ndims, dim))) + if (NULL == (dt = H5T__array_create(base, ndims, dim))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to create datatype") /* Atomize the type */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype") done: - if(ret_value < 0) - if(dt && H5T_close_real(dt) < 0) + if (ret_value < 0) + if (dt && H5T_close_real(dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "can't release datatype") FUNC_LEAVE_API(ret_value) -} /* end H5Tarray_create2() */ +} /* end H5Tarray_create2() */ - /*------------------------------------------------------------------------- * Function: H5T__array_create * @@ -151,8 +139,8 @@ done: H5T_t * H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) { - unsigned u; /* Local index variable */ - H5T_t *ret_value = NULL; /* New array data type */ + unsigned u; /* Local index variable */ + H5T_t * ret_value = NULL; /* New array data type */ FUNC_ENTER_PACKAGE @@ -161,19 +149,19 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) HDassert(dim); /* Build new type */ - if(NULL == (ret_value = H5T__alloc())) + if (NULL == (ret_value = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") ret_value->shared->type = H5T_ARRAY; /* Copy the base type of the array */ - if(NULL == (ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL))) + if (NULL == (ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy base datatype") /* Set the array parameters */ ret_value->shared->u.array.ndims = ndims; /* Copy the array dimensions & compute the # of elements in the array */ - for(u = 0, ret_value->shared->u.array.nelem = 1; u < ndims; u++) { + for (u = 0, ret_value->shared->u.array.nelem = 1; u < ndims; u++) { H5_CHECKED_ASSIGN(ret_value->shared->u.array.dim[u], size_t, dim[u], hsize_t); ret_value->shared->u.array.nelem *= (size_t)dim[u]; } /* end for */ @@ -182,7 +170,7 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) ret_value->shared->size = ret_value->shared->parent->shared->size * ret_value->shared->u.array.nelem; /* Set the "force conversion" flag if the base datatype indicates */ - if(base->shared->force_conv == TRUE) + if (base->shared->force_conv == TRUE) ret_value->shared->force_conv = TRUE; /* Array datatypes need a later version of the datatype object header message */ @@ -190,9 +178,8 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__array_create */ +} /* end H5T__array_create */ - /*------------------------------------------------------------------------- * Function: H5Tget_array_ndims * @@ -209,16 +196,16 @@ done: int H5Tget_array_ndims(hid_t type_id) { - H5T_t *dt; /* pointer to array datatype */ - int ret_value; /* return value */ + H5T_t *dt; /* pointer to array datatype */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(dt->shared->type != H5T_ARRAY) + if (dt->shared->type != H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype") /* Retrieve the number of dimensions */ @@ -226,9 +213,8 @@ H5Tget_array_ndims(hid_t type_id) done: FUNC_LEAVE_API(ret_value) -} /* end H5Tget_array_ndims */ +} /* end H5Tget_array_ndims */ - /*------------------------------------------------------------------------- * Function: H5T__get_array_ndims * @@ -253,9 +239,8 @@ H5T__get_array_ndims(const H5T_t *dt) /* Retrieve the number of dimensions */ FUNC_LEAVE_NOAPI((int)dt->shared->u.array.ndims) -} /* end H5T__get_array_ndims */ +} /* end H5T__get_array_ndims */ - /*------------------------------------------------------------------------- * Function: H5Tget_array_dims2 * @@ -272,26 +257,25 @@ H5T__get_array_ndims(const H5T_t *dt) int H5Tget_array_dims2(hid_t type_id, hsize_t dims[]) { - H5T_t *dt; /* pointer to array data type */ - int ret_value; /* return value */ + H5T_t *dt; /* pointer to array data type */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("Is", "i*h", type_id, dims); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(dt->shared->type != H5T_ARRAY) + if (dt->shared->type != H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype") /* Retrieve the sizes of the dimensions */ - if((ret_value = H5T__get_array_dims(dt, dims)) < 0) + if ((ret_value = H5T__get_array_dims(dt, dims)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes") done: FUNC_LEAVE_API(ret_value) -} /* end H5Tget_array_dims2() */ +} /* end H5Tget_array_dims2() */ - /*------------------------------------------------------------------------- * Function: H5T__get_array_dims * @@ -309,7 +293,7 @@ done: int H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_PACKAGE_NOERR @@ -317,16 +301,16 @@ H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) HDassert(dt->shared->type == H5T_ARRAY); /* Retrieve the sizes of the dimensions */ - if(dims) - for(u = 0; u < dt->shared->u.array.ndims; u++) + if (dims) + for (u = 0; u < dt->shared->u.array.ndims; u++) dims[u] = dt->shared->u.array.dim[u]; /* Pass along the array rank as the return value */ FUNC_LEAVE_NOAPI((int)dt->shared->u.array.ndims) -} /* end H5T__get_array_dims */ +} /* end H5T__get_array_dims */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Tarray_create1 * @@ -348,44 +332,43 @@ H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) */ hid_t H5Tarray_create1(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], - const int H5_ATTR_UNUSED perm[/* ndims */]) + const int H5_ATTR_UNUSED perm[/* ndims */]) { - H5T_t *base; /* base datatype */ - H5T_t *dt = NULL; /* new array datatype */ - unsigned u; /* local index variable */ - hid_t ret_value; /* return value */ + H5T_t * base; /* base datatype */ + H5T_t * dt = NULL; /* new array datatype */ + unsigned u; /* local index variable */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE4("i", "iIs*h*Is", base_id, ndims, dim, perm); /* Check args */ - if(ndims < 1 || ndims > H5S_MAX_RANK) + if (ndims < 1 || ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dimensionality") - if(!dim) + if (!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no dimensions specified") - for(u = 0; u < (unsigned)ndims; u++) - if(!(dim[u] > 0)) + for (u = 0; u < (unsigned)ndims; u++) + if (!(dim[u] > 0)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "zero-sized dimension specified") - if(NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) + if (NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an valid base datatype") /* Create the array datatype */ - if(NULL == (dt = H5T__array_create(base, (unsigned)ndims, dim))) + if (NULL == (dt = H5T__array_create(base, (unsigned)ndims, dim))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to create datatype") /* Atomize the type */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype") done: - if(ret_value < 0) - if(dt && H5T_close_real(dt) < 0) + if (ret_value < 0) + if (dt && H5T_close_real(dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "can't release datatype") FUNC_LEAVE_API(ret_value) -} /* end H5Tarray_create1() */ +} /* end H5Tarray_create1() */ - /*------------------------------------------------------------------------- * Function: H5Tget_array_dims1 * @@ -402,24 +385,23 @@ done: int H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int H5_ATTR_UNUSED perm[]) { - H5T_t *dt; /* Array datatype to query */ - int ret_value; /* return value */ + H5T_t *dt; /* Array datatype to query */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Is", "i*h*Is", type_id, dims, perm); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(dt->shared->type != H5T_ARRAY) + if (dt->shared->type != H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype") /* Retrieve the sizes of the dimensions */ - if((ret_value = H5T__get_array_dims(dt, dims)) < 0) + if ((ret_value = H5T__get_array_dims(dt, dims)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes") done: FUNC_LEAVE_API(ret_value) -} /* end H5Tget_array_dims1() */ +} /* end H5Tget_array_dims1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Tbit.c b/src/H5Tbit.c index c6c1777..0d8103a 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -16,17 +16,14 @@ * the bytes are in little-endian order. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /*data-type functions */ +#include "H5WBprivate.h" /* Wrapped Buffers */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Tpkg.h" /*data-type functions */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - - - /*------------------------------------------------------------------------- * Function: H5T__bit_copy * @@ -37,12 +34,11 @@ *------------------------------------------------------------------------- */ void -H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, - size_t src_offset, size_t size) +H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, size_t src_offset, size_t size) { - size_t shift; - size_t mask_lo, mask_hi; - size_t s_idx, d_idx; + size_t shift; + size_t mask_lo, mask_hi; + size_t s_idx, d_idx; FUNC_ENTER_PACKAGE_NOERR @@ -71,9 +67,9 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, */ while (src_offset && size > 0) { size_t nbits = MIN3(size, 8 - dst_offset, 8 - src_offset); - size_t mask = ((size_t)1 << nbits) - 1; + size_t mask = ((size_t)1 << nbits) - 1; - dst[d_idx] &= (uint8_t)~(mask << dst_offset); + dst[d_idx] &= (uint8_t) ~(mask << dst_offset); dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset)); src_offset += nbits; @@ -111,7 +107,7 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, * bits). SHIFT is three since the source must be shifted right three bits * to line up with the destination. */ - shift = dst_offset; + shift = dst_offset; mask_lo = ((size_t)1 << (8 - shift)) - 1; mask_hi = (~mask_lo) & 0xff; @@ -128,8 +124,8 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, /* Finish up */ while (size > 0) { - size_t nbits = (size_t)MIN3 (size, 8 - dst_offset, 8 - src_offset); - size_t mask = ((size_t)1 << nbits) - 1; + size_t nbits = (size_t)MIN3(size, 8 - dst_offset, 8 - src_offset); + size_t mask = ((size_t)1 << nbits) - 1; dst[d_idx] &= (uint8_t)(~(mask << dst_offset)); dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset)); @@ -152,7 +148,6 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_copy() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_shift * @@ -173,9 +168,9 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, herr_t H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) { - uint8_t tmp_buf[512]; /* Temporary buffer */ - H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t tmp_buf[512]; /* Temporary buffer */ + H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -189,7 +184,7 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) if (abs_shift_dist >= size) H5T__bit_set(buf, offset, size, 0); else { - size_t buf_size = (size / 8) + 1; /* Size of shift buffer needed */ + size_t buf_size = (size / 8) + 1; /* Size of shift buffer needed */ uint8_t *shift_buf; /* Pointer to shift buffer */ /* Wrap the local buffer for serialized header info */ @@ -217,7 +212,7 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) H5T__bit_set(buf, offset + size - abs_shift_dist, abs_shift_dist, 0); } } /* end else */ - } /* end if */ + } /* end if */ done: /* Release resources */ @@ -227,7 +222,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_shift() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_get_d * @@ -244,24 +238,24 @@ done: uint64_t H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) { - uint64_t val = 0; - size_t i, hs; - uint64_t ret_value = 0; /* Return value */ + uint64_t val = 0; + size_t i, hs; + uint64_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR HDassert(8 * sizeof(val) >= size); - H5T__bit_copy((uint8_t*)&val, (size_t)0, buf, offset, size); - switch(H5T_native_order_g) { + H5T__bit_copy((uint8_t *)&val, (size_t)0, buf, offset, size); + switch (H5T_native_order_g) { case H5T_ORDER_LE: break; case H5T_ORDER_BE: for (i = 0, hs = sizeof(val) / 2; i < hs; i++) { - uint8_t tmp = ((uint8_t*)&val)[i]; - ((uint8_t*)&val)[i] = ((uint8_t*)&val)[sizeof(val) - (i + 1)]; - ((uint8_t*)&val)[sizeof(val) - (i + 1)] = tmp; + uint8_t tmp = ((uint8_t *)&val)[i]; + ((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)]; + ((uint8_t *)&val)[sizeof(val) - (i + 1)] = tmp; } break; @@ -281,7 +275,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_get_d() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_set_d * @@ -294,20 +287,20 @@ done: void H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) { - size_t i, hs; + size_t i, hs; FUNC_ENTER_PACKAGE_NOERR HDassert(8 * sizeof(val) >= size); - switch(H5T_native_order_g) { + switch (H5T_native_order_g) { case H5T_ORDER_LE: break; case H5T_ORDER_BE: for (i = 0, hs = sizeof(val) / 2; i < hs; i++) { - uint8_t tmp = ((uint8_t *)&val)[i]; - ((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)]; + uint8_t tmp = ((uint8_t *)&val)[i]; + ((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)]; ((uint8_t *)&val)[sizeof(val) - (i + 1)] = tmp; } break; @@ -320,12 +313,11 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) HDabort(); } - H5T__bit_copy(buf, offset, (uint8_t*)&val, (size_t)0, size); + H5T__bit_copy(buf, offset, (uint8_t *)&val, (size_t)0, size); FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_set_d() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_set * @@ -339,7 +331,7 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) void H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) { - int idx; + int idx; FUNC_ENTER_PACKAGE_NOERR @@ -349,8 +341,8 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) /* The first partial byte */ if (size && offset % 8) { - size_t nbits = MIN(size, 8 - offset); - unsigned mask = ((unsigned)1 << nbits) - 1; + size_t nbits = MIN(size, 8 - offset); + unsigned mask = ((unsigned)1 << nbits) - 1; if (value) buf[idx] = (uint8_t)(buf[idx] | (mask << offset)); @@ -378,7 +370,6 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_set() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_find * @@ -397,13 +388,12 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) *------------------------------------------------------------------------- */ ssize_t -H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, - hbool_t value) +H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, hbool_t value) { - ssize_t base = (ssize_t)offset; - ssize_t idx, i; - size_t iu; - ssize_t ret_value = (-1); /* Return value */ + ssize_t base = (ssize_t)offset; + ssize_t idx, i; + size_t iu; + ssize_t ret_value = (-1); /* Return value */ /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -486,7 +476,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_find() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_inc * @@ -500,9 +489,9 @@ done: hbool_t H5T__bit_inc(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; - unsigned carry = 1; - unsigned acc, mask; + size_t idx = start / 8; + unsigned carry = 1; + unsigned acc, mask; /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -513,7 +502,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) /* The first partial byte */ if (start) { - if(size + start < 8) + if (size + start < 8) mask = ((unsigned)1 << size) - 1; else mask = ((unsigned)1 << (8 - start)) - 1; @@ -531,7 +520,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) while (carry && size >= 8) { acc = buf[idx]; acc++; - carry = acc & 0x100; + carry = acc & 0x100; buf[idx] = (uint8_t)(acc & 0xff); idx++; size -= 8; @@ -540,7 +529,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) /* The last bits */ if (carry && size > 0) { mask = ((unsigned)1 << size) - 1; - acc = buf[idx] & mask; + acc = buf[idx] & mask; acc++; carry = acc & ((unsigned)1 << size); buf[idx] &= (uint8_t)(~mask); @@ -550,7 +539,6 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) FUNC_LEAVE_NOAPI(carry ? TRUE : FALSE) } /* end H5T__bit_inc() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_dec * @@ -565,10 +553,10 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) hbool_t H5T__bit_dec(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; - size_t pos = start % 8; - uint8_t tmp; - unsigned borrow = 0; + size_t idx = start / 8; + size_t pos = start % 8; + uint8_t tmp; + unsigned borrow = 0; /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -617,18 +605,17 @@ H5T__bit_dec(uint8_t *buf, size_t start, size_t size) * and get 10111100. A bit is borrowed from 6th bit(buf[idx]>>6=00000010, tmp>>6=00000011, * not equal). We need to put this bit back by increment 1000000. */ - tmp = buf[idx]; + tmp = buf[idx]; buf[idx] = (uint8_t)(buf[idx] - (1 << pos)); if ((buf[idx] >> (pos + size)) != tmp >> (pos + size)) { buf[idx] = (uint8_t)(buf[idx] + (1 << (pos + size))); - borrow = 1; + borrow = 1; } } FUNC_LEAVE_NOAPI(borrow ? TRUE : FALSE) } /* end H5T__bit_dec() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_neg * @@ -642,9 +629,9 @@ H5T__bit_dec(uint8_t *buf, size_t start, size_t size) void H5T__bit_neg(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; - size_t pos = start % 8; - uint8_t tmp[1]; + size_t idx = start / 8; + size_t pos = start % 8; + uint8_t tmp[1]; /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -656,30 +643,29 @@ H5T__bit_neg(uint8_t *buf, size_t start, size_t size) tmp[0] = (uint8_t)~buf[idx]; /* Simply copy the negated bit field back to the original byte */ - if((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ - H5T__bit_copy(&(buf[idx]), pos, tmp, pos, (8-pos)); + if ((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ + H5T__bit_copy(&(buf[idx]), pos, tmp, pos, (8 - pos)); idx++; size -= (8 - pos); /* The middle bytes */ - while(size >= 8) { - buf[idx] = (uint8_t)~(buf[idx]); + while (size >= 8) { + buf[idx] = (uint8_t) ~(buf[idx]); idx++; size -= 8; } /* The last partial byte */ - if(size > 0) { + if (size > 0) { /* Similar to the first byte case, where sequence ends in the same byte as starts */ tmp[0] = (uint8_t)~buf[idx]; H5T__bit_copy(&(buf[idx]), (size_t)0, tmp, (size_t)0, size); } } - else { + else { /* bit sequence ends in the same byte as starts */ H5T__bit_copy(&(buf[idx]), pos, tmp, pos, size); } FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_neg() */ - diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index bb660c2..08948b2 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -20,63 +20,54 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory Management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory Management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static H5T_t *H5T__open_oid(const H5G_loc_t *loc); - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -87,8 +78,6 @@ H5FL_EXTERN(H5VL_t); /* Declare a free list to manage the H5VL_object_t struct */ H5FL_EXTERN(H5VL_object_t); - - /*------------------------------------------------------------------------- * Function: H5Tcommit2 * @@ -100,67 +89,65 @@ H5FL_EXTERN(H5VL_object_t); *------------------------------------------------------------------------- */ herr_t -H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, - hid_t tcpl_id, hid_t tapl_id) +H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id) { - void *data = NULL; /* VOL-managed datatype data */ - H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ - H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + void * data = NULL; /* VOL-managed datatype data */ + H5VL_object_t * new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t * dt = NULL; /* High level datatype object that wraps the VOL object */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*siiii", loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id); /* Check arguments */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_is_named(dt)) + if (H5T_is_named(dt)) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Get correct property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") /* Get correct property list */ if (H5P_DEFAULT == tcpl_id) tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") + else if (TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the object from the loc_id */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Commit the type */ - if(NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Set up VOL object */ - if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) + if (NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate top object structure") new_obj->connector = vol_obj->connector; - new_obj->connector->nrefs ++; + new_obj->connector->nrefs++; new_obj->data = data; /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ @@ -170,7 +157,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit2() */ - /*------------------------------------------------------------------------- * Function: H5T__commit_named * @@ -185,13 +171,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, - hid_t lcpl_id, hid_t tcpl_id) +H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, hid_t lcpl_id, hid_t tcpl_id) { - H5O_obj_create_t ocrt_info; /* Information for object creation */ - H5T_obj_create_t tcrt_info; /* Information for named datatype creation */ - H5T_state_t old_state; /* The state of the datatype before H5T__commit. */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_obj_create_t ocrt_info; /* Information for object creation */ + H5T_obj_create_t tcrt_info; /* Information for named datatype creation */ + H5T_state_t old_state; /* The state of the datatype before H5T__commit. */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -206,16 +191,16 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, old_state = dt->shared->state; /* Set up named datatype creation info */ - tcrt_info.dt = dt; + tcrt_info.dt = dt; tcrt_info.tcpl_id = tcpl_id; /* Set up object creation information */ ocrt_info.obj_type = H5O_TYPE_NAMED_DATATYPE; ocrt_info.crt_info = &tcrt_info; - ocrt_info.new_obj = NULL; + ocrt_info.new_obj = NULL; /* Create the new named datatype and link it to its parent group */ - if(H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) + if (H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create and link to named datatype") HDassert(ocrt_info.new_obj); @@ -223,34 +208,34 @@ done: /* If the datatype was committed but something failed after that, we need * to return it to the state it was in before it was committed. */ - if(ret_value < 0 && (NULL != ocrt_info.new_obj)) { - if(dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { + if (ret_value < 0 && (NULL != ocrt_info.new_obj)) { + if (dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { /* Remove the datatype from the list of opened objects in the file */ - if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") - if(H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") + if (H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "can't remove dataset from list of open objects") /* Close the datatype object */ - if(H5O_close(&(dt->oloc), NULL) < 0) + if (H5O_close(&(dt->oloc), NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") /* Remove the datatype's object header from the file */ - if(H5O_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5O_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") /* Mark datatype as being back in memory */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to return datatype to memory") - dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; + dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; dt->shared->state = old_state; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__commit_named() */ - /*------------------------------------------------------------------------- * Function: H5Tcommit_anon * @@ -270,51 +255,50 @@ done: herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) { - void *dt = NULL; /* datatype object created by VOL connector */ - H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ - H5T_t *type = NULL; /* Datatype created */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + void * dt = NULL; /* datatype object created by VOL connector */ + H5VL_object_t * new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t * type = NULL; /* Datatype created */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iiii", loc_id, type_id, tcpl_id, tapl_id); /* Check arguments */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_is_named(type)) + if (H5T_is_named(type)) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Get correct property list */ - if(H5P_DEFAULT == tcpl_id) + if (H5P_DEFAULT == tcpl_id) tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") + else if (TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* Get the file object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Commit the datatype */ - if(NULL == (dt = H5VL_datatype_commit(vol_obj, &loc_params, NULL, type_id, H5P_LINK_CREATE_DEFAULT, - tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (dt = H5VL_datatype_commit(vol_obj, &loc_params, NULL, type_id, H5P_LINK_CREATE_DEFAULT, + tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Setup VOL object */ - if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) + if (NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate top object structure") new_obj->connector = vol_obj->connector; - new_obj->connector->nrefs ++; + new_obj->connector->nrefs++; new_obj->data = dt; /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ @@ -324,7 +308,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit_anon() */ - /*------------------------------------------------------------------------- * Function: H5T__commit_anon * @@ -340,8 +323,8 @@ done: herr_t H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id) { - H5O_loc_t *oloc; /* Object location for datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_loc_t *oloc; /* Object location for datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -351,24 +334,23 @@ H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id) HDassert(tcpl_id != H5P_DEFAULT); /* Commit the type */ - if(H5T__commit(file, type, tcpl_id) < 0) + if (H5T__commit(file, type, tcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Release the datatype's object header */ /* Get the new committed datatype's object location */ - if(NULL == (oloc = H5T_oloc(type))) + if (NULL == (oloc = H5T_oloc(type))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype") /* Decrement refcount on committed datatype's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + if (H5O_dec_rc_by_loc(oloc) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5T__commit_anon() */ - /*------------------------------------------------------------------------- * Function: H5T__commit * @@ -385,11 +367,11 @@ done: herr_t H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) { - H5O_loc_t temp_oloc; /* Temporary object header location */ - H5G_name_t temp_path; /* Temporary path */ - hbool_t loc_init = FALSE; /* Have temp_oloc and temp_path been initialized? */ - size_t dtype_size; /* Size of the datatype message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_loc_t temp_oloc; /* Temporary object header location */ + H5G_name_t temp_path; /* Temporary path */ + hbool_t loc_init = FALSE; /* Have temp_oloc and temp_path been initialized? */ + size_t dtype_size; /* Size of the datatype message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -398,7 +380,7 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) HDassert(tcpl_id != H5P_DEFAULT); /* Check if we are allowed to write to this file */ - if(0 == (H5F_INTENT(file) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "no write intent on file") /* @@ -406,30 +388,30 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing * a named type should always succeed. */ - if(H5T_STATE_NAMED == type->shared->state || H5T_STATE_OPEN == type->shared->state) + if (H5T_STATE_NAMED == type->shared->state || H5T_STATE_OPEN == type->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed") - if(H5T_STATE_IMMUTABLE == type->shared->state) + if (H5T_STATE_IMMUTABLE == type->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable") /* Check for a "sensible" datatype to store on disk */ - if(H5T_is_sensible(type) <= 0) + if (H5T_is_sensible(type) <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible") /* Mark datatype as being on disk now. This step changes the size of * datatype as stored on disk. */ - if(H5T_set_loc(type, H5F_VOL_OBJ(file), H5T_LOC_DISK) < 0) + if (H5T_set_loc(type, H5F_VOL_OBJ(file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") /* Reset datatype location and path */ - if(H5O_loc_reset(&temp_oloc) < 0) + if (H5O_loc_reset(&temp_oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize location") - if(H5G_name_reset(&temp_path) < 0) + if (H5G_name_reset(&temp_path) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize path") loc_init = TRUE; /* Set the version for datatype */ - if(H5T_set_version(file, type) < 0) + if (H5T_set_version(file, type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype") /* Calculate message size information, for creating object header */ @@ -440,56 +422,58 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) * Create the object header and open it for write access. Insert the data * type message and then give the object header a name. */ - if(H5O_create(file, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0) + if (H5O_create(file, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") - if(H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, type) < 0) + if (H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, + H5O_UPDATE_TIME, type) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message") /* Copy the new object header's location into the datatype, taking ownership of it */ - if(H5O_loc_copy_shallow(&(type->oloc), &temp_oloc) < 0) + if (H5O_loc_copy_shallow(&(type->oloc), &temp_oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") - if(H5G_name_copy(&(type->path), &temp_path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(type->path), &temp_path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") loc_init = FALSE; /* Set the shared info fields */ H5T_update_shared(type); - type->shared->state = H5T_STATE_OPEN; + type->shared->state = H5T_STATE_OPEN; type->shared->fo_count = 1; /* Add datatype to the list of open objects in the file */ - if(H5FO_top_incr(type->sh_loc.file, type->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(type->sh_loc.file, type->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't incr object ref. count") - if(H5FO_insert(type->sh_loc.file, type->sh_loc.u.loc.oh_addr, type->shared, TRUE) < 0) + if (H5FO_insert(type->sh_loc.file, type->sh_loc.u.loc.oh_addr, type->shared, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "can't insert datatype into list of open objects") /* Mark datatype as being on memory again. Since this datatype may still be * used in memory after committed to disk, change its size back as in memory. */ - if(H5T_set_loc(type, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(type, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype in memory") done: - if(ret_value < 0) { - if(loc_init) { + if (ret_value < 0) { + if (loc_init) { H5O_loc_free(&temp_oloc); H5G_name_free(&temp_path); } /* end if */ - if((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) { - if(H5O_dec_rc_by_loc(&(type->oloc)) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - if(H5O_close(&(type->oloc), NULL) < 0) + if ((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && + (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) { + if (H5O_dec_rc_by_loc(&(type->oloc)) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, + "unable to decrement refcount on newly created object") + if (H5O_close(&(type->oloc), NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") - if(H5O_delete(file, type->sh_loc.u.loc.oh_addr) < 0) + if (H5O_delete(file, type->sh_loc.u.loc.oh_addr) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") type->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5T__commit() */ - /*------------------------------------------------------------------------- * Function: H5Tcommitted * @@ -502,14 +486,14 @@ done: htri_t H5Tcommitted(hid_t type_id) { - H5T_t *type; /* Datatype to query */ - htri_t ret_value; /* Return value */ + H5T_t *type; /* Datatype to query */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", type_id); /* Check arguments */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set return value */ @@ -519,7 +503,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommitted() */ - /*------------------------------------------------------------------------- * Function: H5T_link * @@ -537,7 +520,7 @@ done: int H5T_link(const H5T_t *type, int adjust) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -545,14 +528,13 @@ H5T_link(const H5T_t *type, int adjust) HDassert(type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED); /* Adjust the link count on the named datatype */ - if((ret_value = H5O_link(&type->oloc, adjust)) < 0) + if ((ret_value = H5O_link(&type->oloc, adjust)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_LINKCOUNT, (-1), "unable to adjust named datatype link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_link() */ - /*------------------------------------------------------------------------- * Function: H5Topen2 * @@ -568,50 +550,50 @@ done: hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) { - void *dt = NULL; /* datatype object created by VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + void * dt = NULL; /* datatype object created by VOL connector */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, tapl_id); /* Check args */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Fill in location struct fields */ - loc_params.type = H5VL_OBJECT_BY_SELF; - loc_params.obj_type = H5I_get_type(loc_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); /* get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Open the datatype */ - if(NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, tapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ - if((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: /* Cleanup on error */ - if(H5I_INVALID_HID == ret_value) - if(dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_API(ret_value) } /* end H5Topen2() */ - /*------------------------------------------------------------------------- * Function: H5Tget_create_plist * @@ -631,39 +613,41 @@ done: hid_t H5Tget_create_plist(hid_t dtype_id) { - H5T_t *type = NULL; /* Datatype object for ID */ - htri_t is_named = FAIL; /* Is the datatype named? */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5T_t *type = NULL; /* Datatype object for ID */ + htri_t is_named = FAIL; /* Is the datatype named? */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dtype_id); /* Check arguments */ - if(NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype") /* Check if the datatype is committed */ - if(FAIL == (is_named = H5T_is_named(type))) + if (FAIL == (is_named = H5T_is_named(type))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't check whether datatype is committed") /* If the datatype is not committed/named, just copy the default * creation property list and return that. */ - if(FALSE == is_named) { - H5P_genplist_t *tcpl_plist = NULL; + if (FALSE == is_named) { + H5P_genplist_t *tcpl_plist = NULL; /* Copy the default datatype creation property list */ - if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) + if (NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list") - if((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") + if ((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, + "unable to copy the creation property list") } /* end if */ /* If the datatype is committed, retrieve further information */ else { H5VL_object_t *vol_obj = type->vol_obj; /* Get the property list through the VOL */ - if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_TCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_TCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") } /* end else */ @@ -671,7 +655,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Tflush * @@ -687,32 +670,32 @@ done: herr_t H5Tflush(hid_t type_id) { - H5T_t *dt; /* Datatype for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(!H5T_is_named(dt)) + if (!H5T_is_named(dt)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(type_id) < 0) + if (H5CX_set_loc(type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Flush metadata for named datatype */ - if(dt->vol_obj) - if(H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id) < 0) + if (dt->vol_obj) + if (H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_FLUSH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") done: FUNC_LEAVE_API(ret_value) } /* H5Tflush */ - /*------------------------------------------------------------------------- * Function: H5Trefresh * @@ -728,32 +711,32 @@ done: herr_t H5Trefresh(hid_t type_id) { - H5T_t *dt; /* Datatype for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(!H5T_is_named(dt)) + if (!H5T_is_named(dt)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(type_id) < 0) + if (H5CX_set_loc(type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Refresh the datatype's metadata */ - if(dt->vol_obj) - if(H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id) < 0) + if (dt->vol_obj) + if (H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_REFRESH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") done: FUNC_LEAVE_API(ret_value) } /* H5Trefresh */ - /*------------------------------------------------------------------------- * Function: H5T__get_create_plist * @@ -776,10 +759,10 @@ done: hid_t H5T__get_create_plist(const H5T_t *type) { - H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */ - H5P_genplist_t *new_plist; /* New datatype creation property list */ - hid_t new_tcpl_id = FAIL; /* New datatype creation property list */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */ + H5P_genplist_t *new_plist; /* New datatype creation property list */ + hid_t new_tcpl_id = FAIL; /* New datatype creation property list */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE @@ -787,32 +770,31 @@ H5T__get_create_plist(const H5T_t *type) HDassert(type); /* Copy the default datatype creation property list */ - if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list") - if((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0) + if (NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list") + if ((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") /* Get property list object for new TCPL */ - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "can't get property list") /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&type->oloc, new_plist) < 0) + if (H5O_get_create_plist(&type->oloc, new_plist) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") /* Set the return value */ ret_value = new_tcpl_id; done: - if(ret_value < 0) - if(new_tcpl_id > 0) - if(H5I_dec_app_ref(new_tcpl_id) < 0) + if (ret_value < 0) + if (new_tcpl_id > 0) + if (H5I_dec_app_ref(new_tcpl_id) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, H5I_INVALID_HID, "unable to close temporary object") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5T__open_name * @@ -829,13 +811,13 @@ done: H5T_t * H5T__open_name(const H5G_loc_t *loc, const char *name) { - H5T_t *dt = NULL; /* Datatype opened in file */ - H5G_name_t path; /* Datatype group hier. path */ - H5O_loc_t oloc; /* Datatype object location */ - H5G_loc_t type_loc; /* Group object for datatype */ - H5O_type_t obj_type; /* Type of object at location */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t * dt = NULL; /* Datatype opened in file */ + H5G_name_t path; /* Datatype group hier. path */ + H5O_loc_t oloc; /* Datatype object location */ + H5G_loc_t type_loc; /* Group object for datatype */ + H5O_type_t obj_type; /* Type of object at location */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -852,33 +834,32 @@ H5T__open_name(const H5G_loc_t *loc, const char *name) * Find the named datatype object header and read the datatype message * from it. */ - if(H5G_loc_find(loc, name, &type_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &type_loc /*out*/) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found") obj_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type) < 0) + if (H5O_obj_type(&oloc, &obj_type) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't get object type") - if(obj_type != H5O_TYPE_NAMED_DATATYPE) + if (obj_type != H5O_TYPE_NAMED_DATATYPE) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "not a named datatype") /* Open it */ - if(NULL == (dt = H5T_open(&type_loc))) + if (NULL == (dt = H5T_open(&type_loc))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") ret_value = dt; done: /* Error cleanup */ - if(NULL == ret_value) - if(obj_found && H5F_addr_defined(type_loc.oloc->addr)) - if(H5G_loc_free(&type_loc) < 0) + if (NULL == ret_value) + if (obj_found && H5F_addr_defined(type_loc.oloc->addr)) + if (H5G_loc_free(&type_loc) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__open_name() */ - /*------------------------------------------------------------------------- * Function: H5T_open * @@ -896,58 +877,58 @@ done: H5T_t * H5T_open(const H5G_loc_t *loc) { - H5T_shared_t *shared_fo = NULL; - H5T_t *dt = NULL; - H5T_t *ret_value = NULL; /* Return value */ + H5T_shared_t *shared_fo = NULL; + H5T_t * dt = NULL; + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) HDassert(loc); /* Check if datatype was already open */ - if(NULL == (shared_fo = (H5T_shared_t *)H5FO_opened(loc->oloc->file, loc->oloc->addr))) { + if (NULL == (shared_fo = (H5T_shared_t *)H5FO_opened(loc->oloc->file, loc->oloc->addr))) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open the datatype object */ - if(NULL == (dt = H5T__open_oid(loc))) + if (NULL == (dt = H5T__open_oid(loc))) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found") /* Add the datatype to the list of opened objects in the file */ - if(H5FO_insert(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr, dt->shared, FALSE) < 0) + if (H5FO_insert(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr, dt->shared, FALSE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") /* Increment object count for the object in the top file */ - if(H5FO_top_incr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") /* Mark any datatypes as being in memory now */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") dt->shared->fo_count = 1; } /* end if */ else { - if(NULL == (dt = H5FL_MALLOC(H5T_t))) + if (NULL == (dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") dt->vol_obj = NULL; #if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG) /* Clear object location */ - if(H5O_loc_reset(&(dt->oloc)) < 0) + if (H5O_loc_reset(&(dt->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reset location") /* Clear path name */ - if(H5G_name_reset(&(dt->path)) < 0) + if (H5G_name_reset(&(dt->path)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reset path") #endif /* H5_USING_MEMCHECKER */ /* Shallow copy (take ownership) of the object location object */ - if(H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0) + if (H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy object location") /* Shallow copy (take ownership) of the group hier. path */ - if(H5G_name_copy(&(dt->path), loc->path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(dt->path), loc->path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy path") /* Set the shared component info */ @@ -957,30 +938,30 @@ H5T_open(const H5G_loc_t *loc) dt->shared = shared_fo; /* Mark any datatypes as being in memory now */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* Increment ref. count on shared info */ shared_fo->fo_count++; /* Check if the object has been opened through the top file yet */ - if(H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) { + if (H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) { /* Open the object through this top file */ - if(H5O_open(&(dt->oloc)) < 0) + if (H5O_open(&(dt->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ ret_value = dt; done: - if(ret_value == NULL) { - if(dt) { - if(shared_fo == NULL) /* Need to free shared fo */ + if (ret_value == NULL) { + if (dt) { + if (shared_fo == NULL) /* Need to free shared fo */ dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); H5O_loc_free(&(dt->oloc)); @@ -989,14 +970,13 @@ done: dt = H5FL_FREE(H5T_t, dt); } /* end if */ - if(shared_fo) + if (shared_fo) shared_fo->fo_count--; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_open() */ - /*------------------------------------------------------------------------- * Function: H5T__open_oid * @@ -1014,30 +994,30 @@ done: static H5T_t * H5T__open_oid(const H5G_loc_t *loc) { - H5T_t *dt = NULL; /* Datatype from the file */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; /* Datatype from the file */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_TAG(loc->oloc->addr) HDassert(loc); /* Open named datatype object in file */ - if(H5O_open(loc->oloc) < 0) + if (H5O_open(loc->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") /* Deserialize the datatype message into a datatype in memory */ - if(NULL == (dt = (H5T_t *)H5O_msg_read(loc->oloc, H5O_DTYPE_ID, NULL))) + if (NULL == (dt = (H5T_t *)H5O_msg_read(loc->oloc, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header") /* Mark the type as named and open */ dt->shared->state = H5T_STATE_OPEN; /* Shallow copy (take ownership) of the object location object */ - if(H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0) + if (H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy object location") /* Shallow copy (take ownership) of the group hier. path */ - if(H5G_name_copy(&(dt->path), loc->path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(dt->path), loc->path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy path") /* Set the shared component info */ @@ -1047,14 +1027,13 @@ H5T__open_oid(const H5G_loc_t *loc) ret_value = dt; done: - if(ret_value == NULL) - if(dt == NULL) + if (ret_value == NULL) + if (dt == NULL) H5O_close(loc->oloc, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5T__open_oid() */ - /*------------------------------------------------------------------------- * Function: H5T_update_shared * @@ -1080,7 +1059,6 @@ H5T_update_shared(H5T_t *dt) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5T_update_shared() */ - /*------------------------------------------------------------------------- * Function: H5T_construct_datatype * @@ -1094,26 +1072,28 @@ H5T_update_shared(H5T_t *dt) H5T_t * H5T_construct_datatype(H5VL_object_t *vol_obj) { - ssize_t nalloc; - void *buf = NULL; - H5T_t *dt = NULL; /* datatype object from VOL connector */ - H5T_t *ret_value = NULL; + ssize_t nalloc; + void * buf = NULL; + H5T_t * dt = NULL; /* datatype object from VOL connector */ + H5T_t * ret_value = NULL; FUNC_ENTER_NOAPI(NULL) /* get required buf size for encoding the datatype */ - if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, NULL, 0) < 0) + if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &nalloc, NULL, 0) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get datatype serialized size") /* allocate buffer to store binary description of the datatype */ - if(NULL == (buf = (void *)H5MM_calloc((size_t)nalloc))) + if (NULL == (buf = (void *)H5MM_calloc((size_t)nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") /* get binary description of the datatype */ - if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, buf, (size_t)nalloc) < 0) + if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &nalloc, buf, (size_t)nalloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get serialized datatype") - if(NULL == (dt = H5T_decode((size_t)nalloc, (const unsigned char *)buf))) + if (NULL == (dt = H5T_decode((size_t)nalloc, (const unsigned char *)buf))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't decode datatype") dt->vol_obj = vol_obj; @@ -1121,13 +1101,12 @@ H5T_construct_datatype(H5VL_object_t *vol_obj) ret_value = dt; done: - if(buf) + if (buf) buf = H5MM_xfree(buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_construct_datatype() */ - /*------------------------------------------------------------------------- * Function: H5T_get_named_type * @@ -1141,17 +1120,16 @@ done: H5VL_object_t * H5T_get_named_type(const H5T_t *dt) { - H5VL_object_t *ret_value = NULL; /* Return value */ + H5VL_object_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(NULL != dt->vol_obj) + if (NULL != dt->vol_obj) ret_value = dt->vol_obj; FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_named_type() */ - /*------------------------------------------------------------------------- * Function: H5T_get_actual_type * @@ -1167,12 +1145,12 @@ H5T_get_named_type(const H5T_t *dt) H5T_t * H5T_get_actual_type(H5T_t *dt) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check if the datatype is committed */ - if(NULL == dt->vol_obj) + if (NULL == dt->vol_obj) ret_value = dt; else ret_value = (H5T_t *)H5VL_object_data(dt->vol_obj); @@ -1180,7 +1158,6 @@ H5T_get_actual_type(H5T_t *dt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_actual_type() */ - /*------------------------------------------------------------------------- * Function: H5T_save_refresh_state * @@ -1193,25 +1170,25 @@ H5T_get_actual_type(H5T_t *dt) herr_t H5T_save_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared) { - H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ - H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(cached_H5O_shared); - if(NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not a datatype ID") vol_dt = (H5T_t *)(dt->vol_obj->data); - if(NULL == vol_dt) + if (NULL == vol_dt) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID") /* Increase the count on the file object */ vol_dt->shared->fo_count += 1; /* Increment object count for the object in the top file */ - if(H5FO_top_incr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't increment object count") /* Cache the H5O_shared_t data */ @@ -1221,7 +1198,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_save_refresh_state() */ - /*------------------------------------------------------------------------- * Function: H5T_restore_refresh_state * @@ -1234,25 +1210,25 @@ done: herr_t H5T_restore_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared) { - H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ - H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(cached_H5O_shared); - if(NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid not a datatype ID") vol_dt = (H5T_t *)(dt->vol_obj->data); - if(NULL == vol_dt) + if (NULL == vol_dt) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID") /* Restore the H5O_shared_t data */ H5MM_memcpy(&(vol_dt->sh_loc), cached_H5O_shared, sizeof(H5O_shared_t)); /* Decrement the ref. count for this object in the top file */ - if(H5FO_top_decr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_decr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "can't decrement object count") /* Decrease the count on the file object */ @@ -1262,7 +1238,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_restore_refresh_state() */ - /*------------------------------------------------------------------------- * Function: H5T_already_vol_managed * @@ -1280,6 +1255,5 @@ H5T_already_vol_managed(const H5T_t *dt) /* Sanity check */ HDassert(dt); - FUNC_LEAVE_NOAPI( dt->vol_obj != NULL ) + FUNC_LEAVE_NOAPI(dt->vol_obj != NULL) } /* end H5T_already_vol_managed() */ - diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index f4a9e04..c616001 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -20,34 +20,30 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /*generic functions */ -#include "H5CXprivate.h" /*API Contexts */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5MMprivate.h" /*memory management */ -#include "H5Tpkg.h" /*data-type functions */ +#include "H5private.h" /*generic functions */ +#include "H5CXprivate.h" /*API Contexts */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5MMprivate.h" /*memory management */ +#include "H5Tpkg.h" /*data-type functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -55,28 +51,22 @@ static herr_t H5T__pack(const H5T_t *dt); static htri_t H5T__is_packed(const H5T_t *dt); static H5T_t *H5T__reopen_member_type(const H5T_t *dt, unsigned membno); - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Tget_member_offset * @@ -100,17 +90,17 @@ static H5T_t *H5T__reopen_member_type(const H5T_t *dt, unsigned membno); size_t H5Tget_member_offset(hid_t type_id, unsigned membno) { - H5T_t *dt; /* Datatype to query */ - size_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + size_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE2("z", "iIu", type_id, membno); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound datatype") - if(membno >= dt->shared->u.compnd.nmembs) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound datatype") + if (membno >= dt->shared->u.compnd.nmembs) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number") /* Value */ ret_value = H5T_GET_MEMBER_OFFSET(dt->shared, membno); @@ -119,7 +109,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_offset() */ - /*------------------------------------------------------------------------- * Function: H5T_get_member_offset * @@ -150,7 +139,6 @@ H5T_get_member_offset(const H5T_t *dt, unsigned membno) FUNC_LEAVE_NOAPI(dt->shared->u.compnd.memb[membno].offset) } /* end H5T_get_member_offset() */ - /*------------------------------------------------------------------------- * Function: H5Tget_member_class * @@ -170,16 +158,16 @@ H5T_get_member_offset(const H5T_t *dt, unsigned membno) H5T_class_t H5Tget_member_class(hid_t type_id, unsigned membno) { - H5T_t *dt; /* Datatype to query */ - H5T_class_t ret_value; /* Return value */ + H5T_t * dt; /* Datatype to query */ + H5T_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NO_CLASS) H5TRACE2("Tt", "iIu", type_id, membno); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a compound datatype") - if(membno >= dt->shared->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5T_NO_CLASS, "invalid member number") /* Get the type's class. We have to use this function to get type class @@ -191,7 +179,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_class() */ - /*------------------------------------------------------------------------- * Function: H5Tget_member_type * @@ -213,36 +200,35 @@ done: hid_t H5Tget_member_type(hid_t type_id, unsigned membno) { - H5T_t *dt; /* Datatype to query */ - H5T_t *memb_dt = NULL; /* Member datatype */ - hid_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + H5T_t *memb_dt = NULL; /* Member datatype */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "iIu", type_id, membno); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a compound datatype") - if(membno >= dt->shared->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid member number") /* Retrieve the datatype for the member */ - if(NULL == (memb_dt = H5T__reopen_member_type(dt, membno))) + if (NULL == (memb_dt = H5T__reopen_member_type(dt, membno))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to retrieve member type") /* Get an ID for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, memb_dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, memb_dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable register datatype atom") done: - if(ret_value < 0) - if(memb_dt && H5T_close(memb_dt) < 0) + if (ret_value < 0) + if (memb_dt && H5T_close(memb_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close datatype") FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_type() */ - /*------------------------------------------------------------------------- * Function: H5T_get_member_type * @@ -262,7 +248,7 @@ done: H5T_t * H5T_get_member_type(const H5T_t *dt, unsigned membno) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -271,14 +257,13 @@ H5T_get_member_type(const H5T_t *dt, unsigned membno) HDassert(membno < dt->shared->u.compnd.nmembs); /* Copy datatype */ - if(NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy member datatype") + if (NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy member datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_member_type() */ - /*------------------------------------------------------------------------- * Function: H5T__reopen_member_type * @@ -299,7 +284,7 @@ done: static H5T_t * H5T__reopen_member_type(const H5T_t *dt, unsigned membno) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -308,14 +293,13 @@ H5T__reopen_member_type(const H5T_t *dt, unsigned membno) HDassert(membno < dt->shared->u.compnd.nmembs); /* Copy datatype, possibly re-opening it */ - if(NULL == (ret_value = H5T_copy_reopen(dt->shared->u.compnd.memb[membno].type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to reopen member datatype") + if (NULL == (ret_value = H5T_copy_reopen(dt->shared->u.compnd.memb[membno].type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to reopen member datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__reopen_member_type() */ - /*------------------------------------------------------------------------- * Function: H5T__get_member_size * @@ -340,7 +324,6 @@ H5T__get_member_size(const H5T_t *dt, unsigned membno) FUNC_LEAVE_NOAPI(dt->shared->u.compnd.memb[membno].type->shared->size) } /* end H5T__get_member_size() */ - /*------------------------------------------------------------------------- * Function: H5Tinsert * @@ -368,34 +351,34 @@ H5T__get_member_size(const H5T_t *dt, unsigned membno) herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id) { - H5T_t *parent; /* The compound parent datatype */ - H5T_t *member; /* The member datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *parent; /* The compound parent datatype */ + H5T_t *member; /* The member datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*szi", parent_id, name, offset, member_id); /* Check args */ - if(parent_id == member_id) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself") - if(NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || H5T_COMPOUND != parent->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") - if(H5T_STATE_TRANSIENT != parent->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name") - if(NULL == (member = (H5T_t *)H5I_object_verify(member_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (parent_id == member_id) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself") + if (NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || + H5T_COMPOUND != parent->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") + if (H5T_STATE_TRANSIENT != parent->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name") + if (NULL == (member = (H5T_t *)H5I_object_verify(member_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Insert */ - if(H5T__insert(parent, name, offset, member) < 0) + if (H5T__insert(parent, name, offset, member) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "unable to insert member") done: FUNC_LEAVE_API(ret_value) } /* end H5Tinsert() */ - /*------------------------------------------------------------------------- * Function: H5Tpack * @@ -414,25 +397,25 @@ done: herr_t H5Tpack(hid_t type_id) { - H5T_t *dt; /* Datatype to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_detect_class(dt, H5T_COMPOUND, TRUE) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || + H5T_detect_class(dt, H5T_COMPOUND, TRUE) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") /* Pack */ - if(H5T__pack(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype") + if (H5T__pack(dt) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tpack() */ - /*------------------------------------------------------------------------- * Function: H5T__insert * @@ -451,10 +434,10 @@ done: herr_t H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member) { - unsigned idx; /* Index of member to insert */ - size_t total_size; - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned idx; /* Index of member to insert */ + size_t total_size; + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -465,45 +448,44 @@ H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member) HDassert(name && *name); /* Does NAME already exist in PARENT? */ - for(i = 0; i < parent->shared->u.compnd.nmembs; i++) - if(!HDstrcmp(parent->shared->u.compnd.memb[i].name, name)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique") + for (i = 0; i < parent->shared->u.compnd.nmembs; i++) + if (!HDstrcmp(parent->shared->u.compnd.memb[i].name, name)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique") /* Does the new member overlap any existing member ? */ total_size = member->shared->size; - for(i = 0; i < parent->shared->u.compnd.nmembs; i++) - if((offset <= parent->shared->u.compnd.memb[i].offset && - (offset + total_size) > parent->shared->u.compnd.memb[i].offset) || - (parent->shared->u.compnd.memb[i].offset <= offset && - (parent->shared->u.compnd.memb[i].offset + - parent->shared->u.compnd.memb[i].size) > offset)) + for (i = 0; i < parent->shared->u.compnd.nmembs; i++) + if ((offset <= parent->shared->u.compnd.memb[i].offset && + (offset + total_size) > parent->shared->u.compnd.memb[i].offset) || + (parent->shared->u.compnd.memb[i].offset <= offset && + (parent->shared->u.compnd.memb[i].offset + parent->shared->u.compnd.memb[i].size) > offset)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member overlaps with another member") /* Does the new member overlap the end of the compound type? */ - if((offset + total_size) > parent->shared->size) + if ((offset + total_size) > parent->shared->size) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member extends past end of compound type") /* Increase member array if necessary */ - if(parent->shared->u.compnd.nmembs >= parent->shared->u.compnd.nalloc) { - unsigned na = MAX(1, parent->shared->u.compnd.nalloc * 2); + if (parent->shared->u.compnd.nmembs >= parent->shared->u.compnd.nalloc) { + unsigned na = MAX(1, parent->shared->u.compnd.nalloc * 2); H5T_cmemb_t *x = (H5T_cmemb_t *)H5MM_realloc(parent->shared->u.compnd.memb, na * sizeof(H5T_cmemb_t)); - if(!x) + if (!x) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") parent->shared->u.compnd.nalloc = na; - parent->shared->u.compnd.memb = x; + parent->shared->u.compnd.memb = x; } /* end if */ /* Add member to end of member array */ - idx = parent->shared->u.compnd.nmembs; - parent->shared->u.compnd.memb[idx].name = H5MM_xstrdup(name); + idx = parent->shared->u.compnd.nmembs; + parent->shared->u.compnd.memb[idx].name = H5MM_xstrdup(name); parent->shared->u.compnd.memb[idx].offset = offset; - parent->shared->u.compnd.memb[idx].size = total_size; - parent->shared->u.compnd.memb[idx].type = H5T_copy(member, H5T_COPY_ALL); + parent->shared->u.compnd.memb[idx].size = total_size; + parent->shared->u.compnd.memb[idx].type = H5T_copy(member, H5T_COPY_ALL); parent->shared->u.compnd.sorted = H5T_SORT_NONE; parent->shared->u.compnd.nmembs++; - parent->shared->u.compnd.memb_size+=total_size; + parent->shared->u.compnd.memb_size += total_size; /* It should not be possible to get this far if the type is already packed * - the new member would overlap something */ @@ -513,23 +495,22 @@ H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member) H5T__update_packed(parent); /* Set the "force conversion" flag if the field's datatype indicates */ - if(member->shared->force_conv == TRUE) + if (member->shared->force_conv == TRUE) parent->shared->force_conv = TRUE; /* Check for member having a later version than the parent */ - if(parent->shared->version < member->shared->version) + if (parent->shared->version < member->shared->version) /* Upgrade parent datatype (and all other members also) */ /* (can't use a partial datatype and later versions of the format are * more efficient, so might as well upgrade all members also... -QAK) */ - if(H5T__upgrade_version(parent, member->shared->version) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade member encoding version") + if (H5T__upgrade_version(parent, member->shared->version) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade member encoding version") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__insert() */ - /*------------------------------------------------------------------------- * Function: H5T__pack * @@ -546,48 +527,49 @@ done: static herr_t H5T__pack(const H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(dt); - if(H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) { + if (H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) { /* If datatype has been packed, skip packing it and indicate success */ - if(TRUE == H5T__is_packed(dt)) + if (TRUE == H5T__is_packed(dt)) HGOTO_DONE(SUCCEED) /* Check for packing unmodifiable datatype */ - if(H5T_STATE_TRANSIENT != dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is read-only") - if(dt->shared->parent) { - if(H5T__pack(dt->shared->parent) < 0) + if (dt->shared->parent) { + if (H5T__pack(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack parent of datatype") /* Adjust size of datatype appropriately */ - if(dt->shared->type == H5T_ARRAY) + if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; - else if(dt->shared->type != H5T_VLEN) + else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } /* end if */ - else if(dt->shared->type == H5T_COMPOUND) { - size_t offset; /* Offset of member */ - unsigned i; /* Local index variable */ + else if (dt->shared->type == H5T_COMPOUND) { + size_t offset; /* Offset of member */ + unsigned i; /* Local index variable */ /* Recursively pack the members */ - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - if(H5T__pack(dt->shared->u.compnd.memb[i].type) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound datatype") + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + if (H5T__pack(dt->shared->u.compnd.memb[i].type) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to pack part of a compound datatype") /* Update the member size */ dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].type)->shared->size; } /* end for */ /* Remove padding between members */ - if(H5T__sort_value(dt, NULL) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") - for(i = 0, offset = 0; i < dt->shared->u.compnd.nmembs; i++) { + if (H5T__sort_value(dt, NULL) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") + for (i = 0, offset = 0; i < dt->shared->u.compnd.nmembs; i++) { dt->shared->u.compnd.memb[i].offset = offset; offset += dt->shared->u.compnd.memb[i].size; } /* end for */ @@ -598,13 +580,12 @@ H5T__pack(const H5T_t *dt) /* Mark the type as packed now */ dt->shared->u.compnd.packed = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__pack() */ - /*------------------------------------------------------------------------- * Function: H5T__is_packed * @@ -623,24 +604,23 @@ done: static htri_t H5T__is_packed(const H5T_t *dt) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(dt); /* Go up the chain as far as possible */ - while(dt->shared->parent) + while (dt->shared->parent) dt = dt->shared->parent; /* If this is a compound datatype, check if it is packed */ - if(dt->shared->type == H5T_COMPOUND) + if (dt->shared->type == H5T_COMPOUND) ret_value = (htri_t)(dt->shared->u.compnd.packed); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__is_packed() */ - /*------------------------------------------------------------------------- * Function: H5T__update_packed * @@ -661,7 +641,7 @@ H5T__is_packed(const H5T_t *dt) void H5T__update_packed(const H5T_t *dt) { - unsigned i; /* Index */ + unsigned i; /* Index */ FUNC_ENTER_PACKAGE_NOERR @@ -669,20 +649,19 @@ H5T__update_packed(const H5T_t *dt) HDassert(dt->shared->type == H5T_COMPOUND); /* First check if all space is used in the "top level" type */ - if(dt->shared->size == dt->shared->u.compnd.memb_size) { + if (dt->shared->size == dt->shared->u.compnd.memb_size) { /* Set the packed flag to TRUE */ dt->shared->u.compnd.packed = TRUE; /* Now check if all members are packed */ - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) - if(!H5T__is_packed(dt->shared->u.compnd.memb[i].type)) { + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) + if (!H5T__is_packed(dt->shared->u.compnd.memb[i].type)) { dt->shared->u.compnd.packed = FALSE; break; } /* end if */ - } /* end if */ + } /* end if */ else dt->shared->u.compnd.packed = FALSE; FUNC_LEAVE_NOAPI_VOID } /* end H5T__update_packed() */ - diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 15658cc..949864b 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -19,22 +19,20 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ @@ -169,12 +167,14 @@ * destination. * */ -#define H5T_CONV_xX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_xX_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - *(D) = (DT)(*(S)); \ -} +#define H5T_CONV_xX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_xX_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + *(D) = (DT)(*(S)); \ + } /* Added a condition branch(else if (*(S) == (DT)(D_MAX))) which seems redundant. * It handles a special situation when the source is "float" and assigned the value @@ -183,415 +183,455 @@ * equal. In this case, do not return exception but make sure the maximum is assigned * to the destination. SLU - 2005/06/29 */ -#define H5T_CONV_Xx_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (ST)(D_MIN)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MIN); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Xx_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (ST)(D_MAX)) { \ - *(D) = (DT)(D_MAX); \ - } else if (*(S) < (ST)(D_MIN)) { \ - *(D) = (DT)(D_MIN); \ - } else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_Ux_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Ux_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (ST)(D_MAX)) { \ - *(D) = (DT)(D_MAX); \ - } else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_sS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_sU_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) < 0) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = 0; \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_sU_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) < 0) \ - *(D) = 0; \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_sU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_sU, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} +#define H5T_CONV_Xx_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MIN); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Xx_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + *(D) = (DT)(D_MAX); \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + *(D) = (DT)(D_MIN); \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Ux_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Ux_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + *(D) = (DT)(D_MAX); \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_sS(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_sU_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) < 0) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = 0; \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_sU_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) < 0) \ + *(D) = 0; \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_sU(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_sU, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } /* Define to 1 if overflow is possible during conversion, 0 otherwise * Because destination is at least as wide as the source, this should only * occur between types of equal size */ -#define H5T_CONV_uS_UCHAR_SHORT 0 -#define H5T_CONV_uS_UCHAR_INT 0 -#define H5T_CONV_uS_UCHAR_LONG 0 -#define H5T_CONV_uS_UCHAR_LLONG 0 +#define H5T_CONV_uS_UCHAR_SHORT 0 +#define H5T_CONV_uS_UCHAR_INT 0 +#define H5T_CONV_uS_UCHAR_LONG 0 +#define H5T_CONV_uS_UCHAR_LLONG 0 #if H5_SIZEOF_SHORT == H5_SIZEOF_INT - #define H5T_CONV_uS_USHORT_INT 1 +#define H5T_CONV_uS_USHORT_INT 1 #else - #define H5T_CONV_uS_USHORT_INT 0 +#define H5T_CONV_uS_USHORT_INT 0 #endif -#define H5T_CONV_uS_USHORT_LONG 0 -#define H5T_CONV_uS_USHORT_LLONG 0 +#define H5T_CONV_uS_USHORT_LONG 0 +#define H5T_CONV_uS_USHORT_LLONG 0 #if H5_SIZEOF_INT == H5_SIZEOF_LONG - #define H5T_CONV_uS_UINT_LONG 1 +#define H5T_CONV_uS_UINT_LONG 1 #else - #define H5T_CONV_uS_UINT_LONG 0 +#define H5T_CONV_uS_UINT_LONG 0 #endif -#define H5T_CONV_uS_UINT_LLONG 0 +#define H5T_CONV_uS_UINT_LLONG 0 #if H5_SIZEOF_LONG == H5_SIZEOF_LONG_LONG - #define H5T_CONV_uS_ULONG_LLONG 1 +#define H5T_CONV_uS_ULONG_LLONG 1 #else - #define H5T_CONV_uS_ULONG_LLONG 0 +#define H5T_CONV_uS_ULONG_LLONG 0 #endif /* Note. If an argument is stringified or concatenated, the prescan does not * occur. To expand the macro, then stringify or concatenate its expansion, * one macro must call another macro that does the stringification or * concatenation. */ -#define H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE) \ - H5_GLUE4(H5T_CONV_uS_, STYPE, _, DTYPE) +#define H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE) H5_GLUE4(H5T_CONV_uS_, STYPE, _, DTYPE) /* Called if overflow is possible */ -#define H5T_CONV_uS_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \ - if (*(S) > (DT)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI,\ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler */ \ - *(D) = (DT)(D_MAX); \ - else if (except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, \ - "can't handle conversion exception") \ - /* if (except_ret==H5T_CONV_HANDLED): Fall through, user handled it */\ - } else \ +#define H5T_CONV_uS_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \ + if (*(S) > (DT)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler */ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if (except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ *(D) = (DT)(*(S)); /* Called if no overflow is possible */ -#define H5T_CONV_uS_CORE_0(S, D, ST, DT, D_MIN, D_MAX) \ - *(D) = (DT)(*(S)); +#define H5T_CONV_uS_CORE_0(S, D, ST, DT, D_MIN, D_MAX) *(D) = (DT)(*(S)); -#define H5T_CONV_uS_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \ - H5_GLUE(H5T_CONV_uS_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX) +#define H5T_CONV_uS_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \ + H5_GLUE(H5T_CONV_uS_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX) -#define H5T_CONV_uS_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) { \ - H5T_CONV_uS_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), \ - S, D, ST, DT, D_MIN, D_MAX) \ -} +#define H5T_CONV_uS_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + H5T_CONV_uS_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), S, D, ST, DT, D_MIN, D_MAX) \ + } /* Called if overflow is possible */ -#define H5T_CONV_uS_NOEX_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \ - if (*(S) > (DT)(D_MAX)) \ - *(D) = (D_MAX); \ - else \ +#define H5T_CONV_uS_NOEX_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \ + if (*(S) > (DT)(D_MAX)) \ + *(D) = (D_MAX); \ + else \ *(D) = (DT)(*(S)); /* Called if no overflow is possible */ -#define H5T_CONV_uS_NOEX_CORE_0(S, D, ST, DT, D_MIN, D_MAX) \ - *(D) = (DT)(*(S)); - -#define H5T_CONV_uS_NOEX_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \ - H5_GLUE(H5T_CONV_uS_NOEX_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX) - -#define H5T_CONV_uS_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) { \ - H5T_CONV_uS_NOEX_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), \ - S, D, ST, DT, D_MIN, D_MAX) \ -} - -#define H5T_CONV_uS(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) { \ - HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ - H5T_CONV(H5T_CONV_uS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_uU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_Ss(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Xx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_Su_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) < 0) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = 0; \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (sizeof(ST)>sizeof(DT) && *(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Su_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) < 0) \ - *(D) = 0; \ - else if (sizeof(ST)>sizeof(DT) && *(S) > (ST)(D_MAX)) \ - *(D) = (DT)(D_MAX); \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_Su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_Us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_Uu(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_su_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - /* Assumes memory format of unsigned & signed integers is same */ \ - if(*(S) < 0) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = 0; \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_su_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - /* Assumes memory format of unsigned & signed integers is same */ \ - if(*(S) < 0) \ - *(D) = 0; \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)==sizeof(DT)); \ - H5T_CONV(H5T_CONV_su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_us_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - /* Assumes memory format of unsigned & signed integers is same */ \ - if (*(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_us_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - /* Assumes memory format of unsigned & signed integers is same */ \ - if(*(S) > (ST)(D_MAX)) \ - *(D) = (DT)(D_MAX); \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)==sizeof(DT)); \ - H5T_CONV(H5T_CONV_us, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_fF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} +#define H5T_CONV_uS_NOEX_CORE_0(S, D, ST, DT, D_MIN, D_MAX) *(D) = (DT)(*(S)); + +#define H5T_CONV_uS_NOEX_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \ + H5_GLUE(H5T_CONV_uS_NOEX_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX) + +#define H5T_CONV_uS_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + H5T_CONV_uS_NOEX_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), S, D, ST, DT, D_MIN, D_MAX) \ + } + +#define H5T_CONV_uS(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_uS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_uU(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_Ss(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Xx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_Su_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) < 0) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = 0; \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (sizeof(ST) > sizeof(DT) && *(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Su_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) < 0) \ + *(D) = 0; \ + else if (sizeof(ST) > sizeof(DT) && *(S) > (ST)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Su(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_Us(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_Uu(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_su_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + /* Assumes memory format of unsigned & signed integers is same */ \ + if (*(S) < 0) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = 0; \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_su_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + /* Assumes memory format of unsigned & signed integers is same */ \ + if (*(S) < 0) \ + *(D) = 0; \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_su(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) == sizeof(DT)); \ + H5T_CONV(H5T_CONV_su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_us_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + /* Assumes memory format of unsigned & signed integers is same */ \ + if (*(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_us_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + /* Assumes memory format of unsigned & signed integers is same */ \ + if (*(S) > (ST)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_us(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) == sizeof(DT)); \ + H5T_CONV(H5T_CONV_us, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_fF(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } /* Same as H5T_CONV_Xx_CORE, except that instead of using D_MAX and D_MIN * when an overflow occurs, use the 'float' infinity values. */ -#define H5T_CONV_Ff_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (ST)(D_MIN)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Ff_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (ST)(D_MAX)) \ - *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ - else if (*(S) < (ST)(D_MIN)) \ - *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_Ff(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ff, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_HI_LO_BIT_SET(TYP, V, LO, HI) { \ - unsigned count; \ - unsigned char p; \ - unsigned u; \ - \ - count = 0; \ - for(u = 0; u < sizeof(TYP); u++) { \ - count = (((unsigned)sizeof(TYP) - 1) - u) * 8; \ - p = (unsigned char)((V) >> count); \ - if(p > 0) { \ - if(p & 0x80) \ - count += 7; \ - else if(p & 0x40) \ - count += 6; \ - else if(p & 0x20) \ - count += 5; \ - else if(p & 0x10) \ - count += 4; \ - else if(p & 0x08) \ - count += 3; \ - else if(p & 0x04) \ - count += 2; \ - else if(p & 0x02) \ - count += 1; \ - break; \ - } /* end if */ \ - } /* end for */ \ - \ - HI = count; \ - \ - count = 0; \ - for(u = 0; u < sizeof(TYP); u++) { \ - p = (unsigned char)((V) >> (u * 8)); \ - if(p > 0) { \ - count = u * 8; \ - \ - if(p & 0x01) \ - ; \ - else if(p & 0x02) \ - count += 1; \ - else if(p & 0x04) \ - count += 2; \ - else if(p & 0x08) \ - count += 3; \ - else if(p & 0x10) \ - count += 4; \ - else if(p & 0x20) \ - count += 5; \ - else if(p & 0x40) \ - count += 6; \ - else if(p & 0x80) \ - count += 7; \ - break; \ - } /* end if */ \ - } /* end for */ \ - \ - LO = count; \ -} - -#define H5T_CONV_xF_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (sprec > dprec) { \ - unsigned low_bit_pos, high_bit_pos; \ - \ - /* Detect high & low bits set in source */ \ - H5T_HI_LO_BIT_SET(ST, *(S), low_bit_pos, high_bit_pos) \ - \ - /* Check for more bits of precision in src than available in dst */ \ - if((high_bit_pos - low_bit_pos) >= dprec) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(*(S)); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } \ - else \ - *(D) = (DT)(*(S)); \ - } \ - else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_xF_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_xF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - H5T_CONV(H5T_CONV_xF, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ -} +#define H5T_CONV_Ff_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Ff_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) \ + *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ + else if (*(S) < (ST)(D_MIN)) \ + *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Ff(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Ff, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_HI_LO_BIT_SET(TYP, V, LO, HI) \ + { \ + unsigned count; \ + unsigned char p; \ + unsigned u; \ + \ + count = 0; \ + for (u = 0; u < sizeof(TYP); u++) { \ + count = (((unsigned)sizeof(TYP) - 1) - u) * 8; \ + p = (unsigned char)((V) >> count); \ + if (p > 0) { \ + if (p & 0x80) \ + count += 7; \ + else if (p & 0x40) \ + count += 6; \ + else if (p & 0x20) \ + count += 5; \ + else if (p & 0x10) \ + count += 4; \ + else if (p & 0x08) \ + count += 3; \ + else if (p & 0x04) \ + count += 2; \ + else if (p & 0x02) \ + count += 1; \ + break; \ + } /* end if */ \ + } /* end for */ \ + \ + HI = count; \ + \ + count = 0; \ + for (u = 0; u < sizeof(TYP); u++) { \ + p = (unsigned char)((V) >> (u * 8)); \ + if (p > 0) { \ + count = u * 8; \ + \ + if (p & 0x01) \ + ; \ + else if (p & 0x02) \ + count += 1; \ + else if (p & 0x04) \ + count += 2; \ + else if (p & 0x08) \ + count += 3; \ + else if (p & 0x10) \ + count += 4; \ + else if (p & 0x20) \ + count += 5; \ + else if (p & 0x40) \ + count += 6; \ + else if (p & 0x80) \ + count += 7; \ + break; \ + } /* end if */ \ + } /* end for */ \ + \ + LO = count; \ + } + +#define H5T_CONV_xF_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (sprec > dprec) { \ + unsigned low_bit_pos, high_bit_pos; \ + \ + /* Detect high & low bits set in source */ \ + H5T_HI_LO_BIT_SET(ST, *(S), low_bit_pos, high_bit_pos) \ + \ + /* Check for more bits of precision in src than available in dst */ \ + if ((high_bit_pos - low_bit_pos) >= dprec) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(*(S)); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_xF_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_xF(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + H5T_CONV(H5T_CONV_xF, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ + } /* Quincey added the condition branch (else if (*(S) != (ST)((DT)(*(S))))). * It handles a special situation when the source is "float" and assigned the value @@ -601,358 +641,398 @@ * (ST)(D_MAX))) is for some compilers like Sun, HP, IBM, and SGI where under * the same situation the "int" doesn't overflow. SLU - 2005/9/12 */ -#define H5T_CONV_Fx_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (ST)(D_MAX) || (sprec < dprec && *(S) == (ST)(D_MAX))) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (ST)(D_MIN)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MIN); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) != (ST)((DT)(*(S)))) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(*(S)); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } \ - else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Fx_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (ST)(D_MAX)) \ - *(D) = (DT)(D_MAX); \ - else if(*(S) < (ST)(D_MIN)) \ - *(D) = (DT)(D_MIN); \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_Fx(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - H5T_CONV(H5T_CONV_Fx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ -} +#define H5T_CONV_Fx_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX) || (sprec < dprec && *(S) == (ST)(D_MAX))) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MIN); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) != (ST)((DT)(*(S)))) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(*(S)); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Fx_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else if (*(S) < (ST)(D_MIN)) \ + *(D) = (DT)(D_MIN); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Fx(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + H5T_CONV(H5T_CONV_Fx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ + } /* Since all "no exception" cores do the same thing (assign the value in the * source location to the destination location, using casting), use one "core" * to do them all. */ #ifndef H5_WANT_DCONV_EXCEPTION -#define H5T_CONV_NO_EXCEPT_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - *(D) = (DT)(*(S)); \ -} +#define H5T_CONV_NO_EXCEPT_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + *(D) = (DT)(*(S)); \ + } #endif /* H5_WANT_DCONV_EXCEPTION */ - /* The main part of every integer hardware conversion macro */ -#define H5T_CONV(GUTS,STYPE,DTYPE,ST,DT,D_MIN,D_MAX,PREC) \ -{ \ - herr_t ret_value=SUCCEED; /* Return value */ \ - \ - FUNC_ENTER_PACKAGE \ - \ -{ \ - size_t elmtno; /*element number */ \ - H5T_CONV_DECL_PREC(PREC) /*declare precision variables, or not */ \ - void *src_buf; /*'raw' source buffer */ \ - void *dst_buf; /*'raw' destination buffer */ \ - ST *src, *s; /*source buffer */ \ - DT *dst, *d; /*destination buffer */ \ - H5T_t *st, *dt; /*datatype descriptors */ \ - ST src_aligned; /*source aligned type */ \ - DT dst_aligned; /*destination aligned type */ \ - hbool_t s_mv, d_mv; /*move data to align it? */ \ - ssize_t s_stride, d_stride; /*src and dst strides */ \ - size_t safe; /*how many elements are safe to process in each pass */ \ - H5T_conv_cb_t cb_struct; /*conversion callback structure */ \ - \ - switch (cdata->command) { \ - case H5T_CONV_INIT: \ - /* Sanity check and initialize statistics */ \ - cdata->need_bkg = H5T_BKG_NO; \ - if (NULL==(st=(H5T_t*)H5I_object(src_id)) || NULL==(dt=(H5T_t*)H5I_object(dst_id))) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ - "unable to dereference datatype object ID") \ - if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ - "disagreement about datatype size") \ - CI_ALLOC_PRIV \ - break; \ - \ - case H5T_CONV_FREE: \ - /* Print and free statistics */ \ - CI_PRINT_STATS(STYPE,DTYPE); \ - CI_FREE_PRIV \ - break; \ - \ - case H5T_CONV_CONV: \ - /* Initialize source & destination strides */ \ - if (buf_stride) { \ - HDassert(buf_stride >= sizeof(ST)); \ - HDassert(buf_stride >= sizeof(DT)); \ - s_stride = d_stride = (ssize_t)buf_stride; \ - } else { \ - s_stride = sizeof(ST); \ - d_stride = sizeof(DT); \ - } \ - \ - /* Is alignment required for source or dest? */ \ - s_mv = H5T_NATIVE_##STYPE##_ALIGN_g>1 && \ - ((size_t)buf%H5T_NATIVE_##STYPE##_ALIGN_g || \ - /* Cray */ ((size_t)((ST*)buf)!=(size_t)buf) || \ - (size_t)s_stride%H5T_NATIVE_##STYPE##_ALIGN_g); \ - d_mv = H5T_NATIVE_##DTYPE##_ALIGN_g>1 && \ - ((size_t)buf%H5T_NATIVE_##DTYPE##_ALIGN_g || \ - /* Cray */ ((size_t)((DT*)buf)!=(size_t)buf) || \ - (size_t)d_stride%H5T_NATIVE_##DTYPE##_ALIGN_g); \ - CI_INC_SRC(s_mv) \ - CI_INC_DST(d_mv) \ - \ - /* Get conversion exception callback property */ \ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") \ - \ - /* Get source and destination datatypes */ \ - if(NULL == (st = (H5T_t *)H5I_object(src_id)) || NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference datatype object ID") \ - \ - H5T_CONV_SET_PREC(PREC) /*init precision variables, or not */ \ - \ - /* The outer loop of the type conversion macro, controlling which */ \ - /* direction the buffer is walked */ \ - while (nelmts>0) { \ - /* Check if we need to go backwards through the buffer */ \ - if(d_stride>s_stride) { \ - /* Compute the number of "safe" destination elements at */ \ - /* the end of the buffer (Those which don't overlap with */ \ - /* any source elements at the beginning of the buffer) */ \ - safe = nelmts - (((nelmts * (size_t)s_stride) + (size_t)(d_stride - 1)) / (size_t)d_stride); \ - \ - /* If we're down to the last few elements, just wrap up */ \ - /* with a "real" reverse copy */ \ - if(safe<2) { \ - src = (ST *)(src_buf = (void *)((uint8_t *)buf + (nelmts - 1) * (size_t)s_stride)); \ - dst = (DT *)(dst_buf = (void *)((uint8_t *)buf + (nelmts - 1) * (size_t)d_stride)); \ - s_stride = -s_stride; \ - d_stride = -d_stride; \ - \ - safe=nelmts; \ - } /* end if */ \ - else { \ - src = (ST *)(src_buf = (void *)((uint8_t *)buf + (nelmts - safe) * (size_t)s_stride)); \ - dst = (DT *)(dst_buf = (void *)((uint8_t *)buf + (nelmts - safe) * (size_t)d_stride)); \ - } /* end else */ \ - } /* end if */ \ - else { \ - /* Single forward pass over all data */ \ - src = (ST *)(src_buf = buf); \ - dst = (DT *)(dst_buf = buf); \ - safe=nelmts; \ - } /* end else */ \ - \ - /* Perform loop over elements to convert */ \ - if (s_mv && d_mv) { \ - /* Alignment is required for both source and dest */ \ - s = &src_aligned; \ - H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DALIGN,POST_SALIGN,POST_DALIGN,GUTS,STYPE,DTYPE,s,d,ST,DT,D_MIN,D_MAX) \ - } else if(s_mv) { \ - /* Alignment is required only for source */ \ - s = &src_aligned; \ - H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DNOALIGN,POST_SALIGN,POST_DNOALIGN,GUTS,STYPE,DTYPE,s,dst,ST,DT,D_MIN,D_MAX) \ - } else if(d_mv) { \ - /* Alignment is required only for destination */ \ - H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DALIGN,POST_SNOALIGN,POST_DALIGN,GUTS,STYPE,DTYPE,src,d,ST,DT,D_MIN,D_MAX) \ - } else { \ - /* Alignment is not required for both source and destination */ \ - H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DNOALIGN,POST_SNOALIGN,POST_DNOALIGN,GUTS,STYPE,DTYPE,src,dst,ST,DT,D_MIN,D_MAX) \ - } \ - \ - /* Decrement number of elements left to convert */ \ - nelmts-=safe; \ - } /* end while */ \ - break; \ - \ - default: \ - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, \ - "unknown conversion command"); \ - } \ -} \ - \ -done: \ - FUNC_LEAVE_NOAPI(ret_value) \ -} +#define H5T_CONV(GUTS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, PREC) \ + { \ + herr_t ret_value = SUCCEED; /* Return value */ \ + \ + FUNC_ENTER_PACKAGE \ + \ + { \ + size_t elmtno; /*element number */ \ + H5T_CONV_DECL_PREC(PREC) /*declare precision variables, or not */ \ + void * src_buf; /*'raw' source buffer */ \ + void * dst_buf; /*'raw' destination buffer */ \ + ST * src, *s; /*source buffer */ \ + DT * dst, *d; /*destination buffer */ \ + H5T_t * st, *dt; /*datatype descriptors */ \ + ST src_aligned; /*source aligned type */ \ + DT dst_aligned; /*destination aligned type */ \ + hbool_t s_mv, d_mv; /*move data to align it? */ \ + ssize_t s_stride, d_stride; /*src and dst strides */ \ + size_t safe; /*how many elements are safe to process in each pass */ \ + H5T_conv_cb_t cb_struct; /*conversion callback structure */ \ + \ + switch (cdata->command) { \ + case H5T_CONV_INIT: \ + /* Sanity check and initialize statistics */ \ + cdata->need_bkg = H5T_BKG_NO; \ + if (NULL == (st = (H5T_t *)H5I_object(src_id)) || \ + NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ + "unable to dereference datatype object ID") \ + if (st->shared->size != sizeof(ST) || dt->shared->size != sizeof(DT)) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "disagreement about datatype size") \ + CI_ALLOC_PRIV \ + break; \ + \ + case H5T_CONV_FREE: \ + /* Print and free statistics */ \ + CI_PRINT_STATS(STYPE, DTYPE); \ + CI_FREE_PRIV \ + break; \ + \ + case H5T_CONV_CONV: \ + /* Initialize source & destination strides */ \ + if (buf_stride) { \ + HDassert(buf_stride >= sizeof(ST)); \ + HDassert(buf_stride >= sizeof(DT)); \ + s_stride = d_stride = (ssize_t)buf_stride; \ + } \ + else { \ + s_stride = sizeof(ST); \ + d_stride = sizeof(DT); \ + } \ + \ + /* Is alignment required for source or dest? */ \ + s_mv = H5T_NATIVE_##STYPE##_ALIGN_g > 1 && \ + ((size_t)buf % H5T_NATIVE_##STYPE##_ALIGN_g || \ + /* Cray */ ((size_t)((ST *)buf) != (size_t)buf) || \ + (size_t)s_stride % H5T_NATIVE_##STYPE##_ALIGN_g); \ + d_mv = H5T_NATIVE_##DTYPE##_ALIGN_g > 1 && \ + ((size_t)buf % H5T_NATIVE_##DTYPE##_ALIGN_g || \ + /* Cray */ ((size_t)((DT *)buf) != (size_t)buf) || \ + (size_t)d_stride % H5T_NATIVE_##DTYPE##_ALIGN_g); \ + CI_INC_SRC(s_mv) \ + CI_INC_DST(d_mv) \ + \ + /* Get conversion exception callback property */ \ + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, \ + "unable to get conversion exception callback") \ + \ + /* Get source and destination datatypes */ \ + if (NULL == (st = (H5T_t *)H5I_object(src_id)) || \ + NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ + "unable to dereference datatype object ID") \ + \ + H5T_CONV_SET_PREC(PREC) /*init precision variables, or not */ \ + \ + /* The outer loop of the type conversion macro, controlling which */ \ + /* direction the buffer is walked */ \ + while (nelmts > 0) { \ + /* Check if we need to go backwards through the buffer */ \ + if (d_stride > s_stride) { \ + /* Compute the number of "safe" destination elements at */ \ + /* the end of the buffer (Those which don't overlap with */ \ + /* any source elements at the beginning of the buffer) */ \ + safe = nelmts - (((nelmts * (size_t)s_stride) + (size_t)(d_stride - 1)) / \ + (size_t)d_stride); \ + \ + /* If we're down to the last few elements, just wrap up */ \ + /* with a "real" reverse copy */ \ + if (safe < 2) { \ + src = (ST *)(src_buf = (void *)((uint8_t *)buf + \ + (nelmts - 1) * (size_t)s_stride)); \ + dst = (DT *)(dst_buf = (void *)((uint8_t *)buf + \ + (nelmts - 1) * (size_t)d_stride)); \ + s_stride = -s_stride; \ + d_stride = -d_stride; \ + \ + safe = nelmts; \ + } /* end if */ \ + else { \ + src = (ST *)(src_buf = (void *)((uint8_t *)buf + \ + (nelmts - safe) * (size_t)s_stride)); \ + dst = (DT *)(dst_buf = (void *)((uint8_t *)buf + \ + (nelmts - safe) * (size_t)d_stride)); \ + } /* end else */ \ + } /* end if */ \ + else { \ + /* Single forward pass over all data */ \ + src = (ST *)(src_buf = buf); \ + dst = (DT *)(dst_buf = buf); \ + safe = nelmts; \ + } /* end else */ \ + \ + /* Perform loop over elements to convert */ \ + if (s_mv && d_mv) { \ + /* Alignment is required for both source and dest */ \ + s = &src_aligned; \ + H5T_CONV_LOOP_OUTER(PRE_SALIGN, PRE_DALIGN, POST_SALIGN, POST_DALIGN, GUTS, \ + STYPE, DTYPE, s, d, ST, DT, D_MIN, D_MAX) \ + } \ + else if (s_mv) { \ + /* Alignment is required only for source */ \ + s = &src_aligned; \ + H5T_CONV_LOOP_OUTER(PRE_SALIGN, PRE_DNOALIGN, POST_SALIGN, POST_DNOALIGN, GUTS, \ + STYPE, DTYPE, s, dst, ST, DT, D_MIN, D_MAX) \ + } \ + else if (d_mv) { \ + /* Alignment is required only for destination */ \ + H5T_CONV_LOOP_OUTER(PRE_SNOALIGN, PRE_DALIGN, POST_SNOALIGN, POST_DALIGN, GUTS, \ + STYPE, DTYPE, src, d, ST, DT, D_MIN, D_MAX) \ + } \ + else { \ + /* Alignment is not required for both source and destination */ \ + H5T_CONV_LOOP_OUTER(PRE_SNOALIGN, PRE_DNOALIGN, POST_SNOALIGN, POST_DNOALIGN, \ + GUTS, STYPE, DTYPE, src, dst, ST, DT, D_MIN, D_MAX) \ + } \ + \ + /* Decrement number of elements left to convert */ \ + nelmts -= safe; \ + } /* end while */ \ + break; \ + \ + default: \ + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); \ + } \ + } \ + \ +done: \ + FUNC_LEAVE_NOAPI(ret_value) \ + } /* Declare the source & destination precision variables */ #define H5T_CONV_DECL_PREC(PREC) H5_GLUE(H5T_CONV_DECL_PREC_, PREC) -#define H5T_CONV_DECL_PREC_Y \ - size_t sprec; /*source precision */ \ - size_t dprec; /*destination precision */ \ - H5T_class_t tclass; /*datatype's class */ +#define H5T_CONV_DECL_PREC_Y \ + size_t sprec; /*source precision */ \ + size_t dprec; /*destination precision */ \ + H5T_class_t tclass; /*datatype's class */ -#define H5T_CONV_DECL_PREC_N /*no precision variables */ +#define H5T_CONV_DECL_PREC_N /*no precision variables */ /* Initialize the source & destination precision variables */ #define H5T_CONV_SET_PREC(PREC) H5_GLUE(H5T_CONV_SET_PREC_, PREC) -#define H5T_CONV_SET_PREC_Y \ - /* Get source & destination precisions into a variable */ \ - tclass = st->shared->type; \ - HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ - if(tclass == H5T_INTEGER) \ - sprec = st->shared->u.atomic.prec; \ - else \ - sprec = 1 + st->shared->u.atomic.u.f.msize; \ - tclass = dt->shared->type; \ - HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ - if(tclass == H5T_INTEGER) \ - dprec = dt->shared->u.atomic.prec; \ - else \ - dprec = 1 + dt->shared->u.atomic.u.f.msize; - -#define H5T_CONV_SET_PREC_N /*don't init precision variables */ +#define H5T_CONV_SET_PREC_Y \ + /* Get source & destination precisions into a variable */ \ + tclass = st->shared->type; \ + HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ + if (tclass == H5T_INTEGER) \ + sprec = st->shared->u.atomic.prec; \ + else \ + sprec = 1 + st->shared->u.atomic.u.f.msize; \ + tclass = dt->shared->type; \ + HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ + if (tclass == H5T_INTEGER) \ + dprec = dt->shared->u.atomic.prec; \ + else \ + dprec = 1 + dt->shared->u.atomic.u.f.msize; + +#define H5T_CONV_SET_PREC_N /*don't init precision variables */ /* Macro defining action on source data which needs to be aligned (before main action) */ -#define H5T_CONV_LOOP_PRE_SALIGN(ST) { \ - H5MM_memcpy(&src_aligned, src, sizeof(ST)); \ -} +#define H5T_CONV_LOOP_PRE_SALIGN(ST) \ + { \ + H5MM_memcpy(&src_aligned, src, sizeof(ST)); \ + } /* Macro defining action on source data which doesn't need to be aligned (before main action) */ -#define H5T_CONV_LOOP_PRE_SNOALIGN(ST) { \ -} +#define H5T_CONV_LOOP_PRE_SNOALIGN(ST) \ + { \ + } /* Macro defining action on destination data which needs to be aligned (before main action) */ -#define H5T_CONV_LOOP_PRE_DALIGN(DT) { \ - d = &dst_aligned; \ -} +#define H5T_CONV_LOOP_PRE_DALIGN(DT) \ + { \ + d = &dst_aligned; \ + } /* Macro defining action on destination data which doesn't need to be aligned (before main action) */ -#define H5T_CONV_LOOP_PRE_DNOALIGN(DT) { \ -} +#define H5T_CONV_LOOP_PRE_DNOALIGN(DT) \ + { \ + } /* Macro defining action on source data which needs to be aligned (after main action) */ -#define H5T_CONV_LOOP_POST_SALIGN(ST) { \ -} +#define H5T_CONV_LOOP_POST_SALIGN(ST) \ + { \ + } /* Macro defining action on source data which doesn't need to be aligned (after main action) */ -#define H5T_CONV_LOOP_POST_SNOALIGN(ST) { \ -} +#define H5T_CONV_LOOP_POST_SNOALIGN(ST) \ + { \ + } /* Macro defining action on destination data which needs to be aligned (after main action) */ -#define H5T_CONV_LOOP_POST_DALIGN(DT) { \ - H5MM_memcpy(dst, &dst_aligned, sizeof(DT)); \ -} +#define H5T_CONV_LOOP_POST_DALIGN(DT) \ + { \ + H5MM_memcpy(dst, &dst_aligned, sizeof(DT)); \ + } /* Macro defining action on destination data which doesn't need to be aligned (after main action) */ -#define H5T_CONV_LOOP_POST_DNOALIGN(DT) { \ -} +#define H5T_CONV_LOOP_POST_DNOALIGN(DT) \ + { \ + } /* The outer wrapper for the type conversion loop, to check for an exception handling routine */ -#define H5T_CONV_LOOP_OUTER(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \ - if(cb_struct.func) { \ - H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \ - } \ - else { \ - H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,H5_GLUE(GUTS,_NOEX),STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \ +#define H5T_CONV_LOOP_OUTER(PRE_SALIGN_GUTS, PRE_DALIGN_GUTS, POST_SALIGN_GUTS, POST_DALIGN_GUTS, GUTS, \ + STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + if (cb_struct.func) { \ + H5T_CONV_LOOP(PRE_SALIGN_GUTS, PRE_DALIGN_GUTS, POST_SALIGN_GUTS, POST_DALIGN_GUTS, GUTS, STYPE, \ + DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + } \ + else { \ + H5T_CONV_LOOP(PRE_SALIGN_GUTS, PRE_DALIGN_GUTS, POST_SALIGN_GUTS, POST_DALIGN_GUTS, \ + H5_GLUE(GUTS, _NOEX), STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ } /* The inner loop of the type conversion macro, actually converting the elements */ -#define H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \ - for (elmtno=0; elmtnopriv)->s_aligned) { \ - HDfprintf(H5DEBUG(T), \ - " %Hu src elements aligned on %lu-byte boundaries\n", \ - ((H5T_conv_hw_t *)cdata->priv)->s_aligned, \ - (unsigned long)H5T_NATIVE_##STYPE##_ALIGN_g); \ - } \ - if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->d_aligned) { \ - HDfprintf(H5DEBUG(T), \ - " %Hu dst elements aligned on %lu-byte boundaries\n", \ - ((H5T_conv_hw_t *)cdata->priv)->d_aligned, \ - (unsigned long)H5T_NATIVE_##DTYPE##_ALIGN_g); \ - } \ -} +#define CI_PRINT_STATS(STYPE, DTYPE) \ + { \ + if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->s_aligned) { \ + HDfprintf(H5DEBUG(T), " %Hu src elements aligned on %lu-byte boundaries\n", \ + ((H5T_conv_hw_t *)cdata->priv)->s_aligned, \ + (unsigned long)H5T_NATIVE_##STYPE##_ALIGN_g); \ + } \ + if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->d_aligned) { \ + HDfprintf(H5DEBUG(T), " %Hu dst elements aligned on %lu-byte boundaries\n", \ + ((H5T_conv_hw_t *)cdata->priv)->d_aligned, \ + (unsigned long)H5T_NATIVE_##DTYPE##_ALIGN_g); \ + } \ + } /* Allocate private alignment structure for atomic types */ -# define CI_ALLOC_PRIV \ - if (NULL==(cdata->priv=H5MM_calloc(sizeof(H5T_conv_hw_t)))) { \ - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, \ - "memory allocation failed"); \ - } +#define CI_ALLOC_PRIV \ + if (NULL == (cdata->priv = H5MM_calloc(sizeof(H5T_conv_hw_t)))) { \ + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); \ + } /* Free private alignment structure for atomic types */ -# define CI_FREE_PRIV \ - if(cdata->priv!=NULL) \ +#define CI_FREE_PRIV \ + if (cdata->priv != NULL) \ cdata->priv = H5MM_xfree(cdata->priv); /* Increment source alignment counter */ -# define CI_INC_SRC(s) if (s) ((H5T_conv_hw_t *)cdata->priv)->s_aligned += nelmts; +#define CI_INC_SRC(s) \ + if (s) \ + ((H5T_conv_hw_t *)cdata->priv)->s_aligned += nelmts; /* Increment destination alignment counter */ -# define CI_INC_DST(d) if (d) ((H5T_conv_hw_t *)cdata->priv)->d_aligned += nelmts; -#else /* H5T_DEBUG */ -# define CI_PRINT_STATS(STYPE,DTYPE) /*void*/ -# define CI_ALLOC_PRIV cdata->priv=NULL; -# define CI_FREE_PRIV /* void */ -# define CI_INC_SRC(s) /* void */ -# define CI_INC_DST(d) /* void */ -#endif /* H5T_DEBUG */ +#define CI_INC_DST(d) \ + if (d) \ + ((H5T_conv_hw_t *)cdata->priv)->d_aligned += nelmts; +#else /* H5T_DEBUG */ +#define CI_PRINT_STATS(STYPE, DTYPE) /*void*/ +#define CI_ALLOC_PRIV cdata->priv = NULL; +#define CI_FREE_PRIV /* void */ +#define CI_INC_SRC(s) /* void */ +#define CI_INC_DST(d) /* void */ +#endif /* H5T_DEBUG */ /* Swap two elements (I & J) of an array using a temporary variable */ -#define H5_SWAP_BYTES(ARRAY,I,J) {uint8_t _tmp; _tmp=ARRAY[I]; ARRAY[I]=ARRAY[J]; ARRAY[J]=_tmp;} +#define H5_SWAP_BYTES(ARRAY, I, J) \ + { \ + uint8_t _tmp; \ + _tmp = ARRAY[I]; \ + ARRAY[I] = ARRAY[J]; \ + ARRAY[J] = _tmp; \ + } /* Minimum size of variable-length conversion buffer */ -#define H5T_VLEN_MIN_CONF_BUF_SIZE 4096 +#define H5T_VLEN_MIN_CONF_BUF_SIZE 4096 /******************/ /* Local Typedefs */ @@ -960,54 +1040,49 @@ done: \ /* Conversion data for H5T__conv_struct() */ typedef struct H5T_conv_struct_t { - int *src2dst; /*mapping from src to dst member num */ - hid_t *src_memb_id; /*source member type ID's */ - hid_t *dst_memb_id; /*destination member type ID's */ - H5T_path_t **memb_path; /*conversion path for each member */ - H5T_subset_info_t subset_info; /*info related to compound subsets */ - unsigned src_nmembs; /*needed by free function */ + int * src2dst; /*mapping from src to dst member num */ + hid_t * src_memb_id; /*source member type ID's */ + hid_t * dst_memb_id; /*destination member type ID's */ + H5T_path_t ** memb_path; /*conversion path for each member */ + H5T_subset_info_t subset_info; /*info related to compound subsets */ + unsigned src_nmembs; /*needed by free function */ } H5T_conv_struct_t; /* Conversion data for H5T__conv_enum() */ typedef struct H5T_enum_struct_t { - int base; /*lowest `in' value */ - unsigned length; /*num elements in arrays */ - int *src2dst; /*map from src to dst index */ + int base; /*lowest `in' value */ + unsigned length; /*num elements in arrays */ + int * src2dst; /*map from src to dst index */ } H5T_enum_struct_t; /* Conversion data for the hardware conversion functions */ typedef struct H5T_conv_hw_t { - size_t s_aligned; /*number source elements aligned */ - size_t d_aligned; /*number destination elements aligned*/ + size_t s_aligned; /*number source elements aligned */ + size_t d_aligned; /*number destination elements aligned*/ } H5T_conv_hw_t; /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5T_reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order); - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -1021,7 +1096,6 @@ H5FL_BLK_DEFINE_STATIC(array_seq); /* Declare a free list to manage pieces of reference data */ H5FL_BLK_DEFINE_STATIC(ref_seq); - /*------------------------------------------------------------------------- * Function: H5T__conv_noop * @@ -1037,15 +1111,14 @@ H5FL_BLK_DEFINE_STATIC(ref_seq); */ herr_t H5T__conv_noop(hid_t H5_ATTR_UNUSED src_id, hid_t H5_ATTR_UNUSED dst_id, H5T_cdata_t *cdata, - size_t H5_ATTR_UNUSED nelmts, size_t H5_ATTR_UNUSED buf_stride, - size_t H5_ATTR_UNUSED bkg_stride, void H5_ATTR_UNUSED *buf, - void H5_ATTR_UNUSED *background) + size_t H5_ATTR_UNUSED nelmts, size_t H5_ATTR_UNUSED buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void H5_ATTR_UNUSED *buf, void H5_ATTR_UNUSED *background) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: cdata->need_bkg = H5T_BKG_NO; break; @@ -1065,7 +1138,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_noop() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_order_opt * @@ -1083,39 +1155,37 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t H5_ATTR_UNUSED bkg_stride, void *_buf, - void H5_ATTR_UNUSED *background) +H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *_buf, void H5_ATTR_UNUSED *background) { - uint8_t *buf = (uint8_t*)_buf; - H5T_t *src = NULL; - H5T_t *dst = NULL; - size_t i; - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *buf = (uint8_t *)_buf; + H5T_t * src = NULL; + H5T_t * dst = NULL; + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(src->shared->size != dst->shared->size || - 0 != src->shared->u.atomic.offset || - 0 != dst->shared->u.atomic.offset) + if (src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || + 0 != dst->shared->u.atomic.offset) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - if((src->shared->type == H5T_REFERENCE && dst->shared->type != H5T_REFERENCE) || - (dst->shared->type == H5T_REFERENCE && src->shared->type != H5T_REFERENCE)) + if ((src->shared->type == H5T_REFERENCE && dst->shared->type != H5T_REFERENCE) || + (dst->shared->type == H5T_REFERENCE && src->shared->type != H5T_REFERENCE)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - if(src->shared->type != H5T_REFERENCE && - !((H5T_ORDER_BE == src->shared->u.atomic.order && H5T_ORDER_LE == dst->shared->u.atomic.order) || - (H5T_ORDER_LE == src->shared->u.atomic.order && H5T_ORDER_BE == dst->shared->u.atomic.order))) + if (src->shared->type != H5T_REFERENCE && !((H5T_ORDER_BE == src->shared->u.atomic.order && + H5T_ORDER_LE == dst->shared->u.atomic.order) || + (H5T_ORDER_LE == src->shared->u.atomic.order && + H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - if(src->shared->size != 1 && src->shared->size != 2 && src->shared->size != 4 && - src->shared->size != 8 && src->shared->size != 16) + if (src->shared->size != 1 && src->shared->size != 2 && src->shared->size != 4 && + src->shared->size != 8 && src->shared->size != 16) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - switch(src->shared->type) { + switch (src->shared->type) { case H5T_INTEGER: case H5T_BITFIELD: case H5T_REFERENCE: @@ -1123,14 +1193,14 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, break; case H5T_FLOAT: - if(src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || - src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || - src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || - src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || - src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || - src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || - src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || - src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) + if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || + src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || + src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || + src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || + src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || + src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || + src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || + src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") break; @@ -1151,13 +1221,13 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Check for "no op" reference conversion */ - if(src->shared->type == H5T_REFERENCE) { + if (src->shared->type == H5T_REFERENCE) { /* Sanity check */ - if(dst->shared->type != H5T_REFERENCE) + if (dst->shared->type != H5T_REFERENCE) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype") /* Check if we are on a little-endian machine (the order that @@ -1169,186 +1239,186 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * "native" hobj_ref_t datatype and I think that would break a * lot of existing programs. -QAK */ - if(H5T_native_order_g == H5T_ORDER_LE) + if (H5T_native_order_g == H5T_ORDER_LE) break; } /* end if */ buf_stride = buf_stride ? buf_stride : src->shared->size; - switch(src->shared->size) { + switch (src->shared->size) { case 1: /*no-op*/ break; case 2: - for(/*void*/; nelmts >= 20; nelmts -= 20) { - H5_SWAP_BYTES(buf, 0, 1); /* 0 */ + for (/*void*/; nelmts >= 20; nelmts -= 20) { + H5_SWAP_BYTES(buf, 0, 1); /* 0 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 1 */ + H5_SWAP_BYTES(buf, 0, 1); /* 1 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 2 */ + H5_SWAP_BYTES(buf, 0, 1); /* 2 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 3 */ + H5_SWAP_BYTES(buf, 0, 1); /* 3 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 4 */ + H5_SWAP_BYTES(buf, 0, 1); /* 4 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 5 */ + H5_SWAP_BYTES(buf, 0, 1); /* 5 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 6 */ + H5_SWAP_BYTES(buf, 0, 1); /* 6 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 7 */ + H5_SWAP_BYTES(buf, 0, 1); /* 7 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 8 */ + H5_SWAP_BYTES(buf, 0, 1); /* 8 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 9 */ + H5_SWAP_BYTES(buf, 0, 1); /* 9 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 10 */ + H5_SWAP_BYTES(buf, 0, 1); /* 10 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 11 */ + H5_SWAP_BYTES(buf, 0, 1); /* 11 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 12 */ + H5_SWAP_BYTES(buf, 0, 1); /* 12 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 13 */ + H5_SWAP_BYTES(buf, 0, 1); /* 13 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 14 */ + H5_SWAP_BYTES(buf, 0, 1); /* 14 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 15 */ + H5_SWAP_BYTES(buf, 0, 1); /* 15 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 16 */ + H5_SWAP_BYTES(buf, 0, 1); /* 16 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 17 */ + H5_SWAP_BYTES(buf, 0, 1); /* 17 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 18 */ + H5_SWAP_BYTES(buf, 0, 1); /* 18 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 19 */ + H5_SWAP_BYTES(buf, 0, 1); /* 19 */ buf += buf_stride; } /* end for */ - for(i = 0; i < nelmts; i++, buf += buf_stride) + for (i = 0; i < nelmts; i++, buf += buf_stride) H5_SWAP_BYTES(buf, 0, 1); break; case 4: - for(/*void*/; nelmts >= 20; nelmts -= 20) { - H5_SWAP_BYTES(buf, 0, 3); /* 0 */ - H5_SWAP_BYTES(buf, 1, 2); + for (/*void*/; nelmts >= 20; nelmts -= 20) { + H5_SWAP_BYTES(buf, 0, 3); /* 0 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 1 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 1 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 2 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 2 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 3 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 3 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 4 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 4 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 5 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 5 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 6 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 6 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 7 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 7 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 8 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 8 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 9 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 9 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 10 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 10 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 11 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 11 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 12 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 12 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 13 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 13 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 14 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 14 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 15 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 15 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 16 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 16 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 17 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 17 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 18 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 18 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 19 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 19 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; } /* end for */ - for(i = 0; i < nelmts; i++, buf += buf_stride) { + for (i = 0; i < nelmts; i++, buf += buf_stride) { H5_SWAP_BYTES(buf, 0, 3); H5_SWAP_BYTES(buf, 1, 2); } /* end for */ break; case 8: - for(/*void*/; nelmts >= 10; nelmts -= 10) { - H5_SWAP_BYTES(buf, 0, 7); /* 0 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + for (/*void*/; nelmts >= 10; nelmts -= 10) { + H5_SWAP_BYTES(buf, 0, 7); /* 0 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 1 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 1 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 2 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 2 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 3 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 3 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 4 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 4 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 5 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 5 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 6 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 6 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 7 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 7 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 8 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 8 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 9 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 9 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; } /* end for */ - for(i = 0; i < nelmts; i++, buf += buf_stride) { + for (i = 0; i < nelmts; i++, buf += buf_stride) { H5_SWAP_BYTES(buf, 0, 7); H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); @@ -1357,107 +1427,107 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, break; case 16: - for(/*void*/; nelmts >= 10; nelmts -= 10) { - H5_SWAP_BYTES(buf, 0, 15); /* 0 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + for (/*void*/; nelmts >= 10; nelmts -= 10) { + H5_SWAP_BYTES(buf, 0, 15); /* 0 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 1 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 1 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 2 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 2 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 3 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 3 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 4 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 4 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 5 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 5 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 6 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 6 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 7 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 7 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 8 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 8 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 9 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 9 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; } /* end for */ - for(i = 0; i < nelmts; i++, buf += buf_stride) { + for (i = 0; i < nelmts; i++, buf += buf_stride) { H5_SWAP_BYTES(buf, 0, 15); H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); } /* end for */ break; @@ -1478,7 +1548,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_order_opt() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_order * @@ -1495,47 +1564,45 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *_buf, - void H5_ATTR_UNUSED *background) +H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *_buf, void H5_ATTR_UNUSED *background) { - uint8_t *buf = (uint8_t*)_buf; - H5T_t *src = NULL; - H5T_t *dst = NULL; - size_t i; - size_t j, md; - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *buf = (uint8_t *)_buf; + H5T_t * src = NULL; + H5T_t * dst = NULL; + size_t i; + size_t j, md; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || - 0 != dst->shared->u.atomic.offset || - !((H5T_ORDER_BE == src->shared->u.atomic.order && - H5T_ORDER_LE == dst->shared->u.atomic.order) || - (H5T_ORDER_LE == src->shared->u.atomic.order && - H5T_ORDER_BE == dst->shared->u.atomic.order))) + if (src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || + 0 != dst->shared->u.atomic.offset || + !((H5T_ORDER_BE == src->shared->u.atomic.order && + H5T_ORDER_LE == dst->shared->u.atomic.order) || + (H5T_ORDER_LE == src->shared->u.atomic.order && + H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - switch(src->shared->type) { + switch (src->shared->type) { case H5T_INTEGER: case H5T_BITFIELD: /* nothing to check */ break; case H5T_FLOAT: - if(src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || - src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || - src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || - src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || - src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || - src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || - src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || - src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) { + if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || + src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || + src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || + src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || + src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || + src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || + src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || + src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") } /* end if */ break; @@ -1558,13 +1625,13 @@ H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = (H5T_t *)H5I_object(src_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") buf_stride = buf_stride ? buf_stride : src->shared->size; - md = src->shared->size / 2; - for(i = 0; i < nelmts; i++, buf += buf_stride) - for(j = 0; j < md; j++) + md = src->shared->size / 2; + for (i = 0; i < nelmts; i++, buf += buf_stride) + for (j = 0; j < md; j++) H5_SWAP_BYTES(buf, j, src->shared->size - (j + 1)); break; @@ -1580,7 +1647,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_order() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_b_b * @@ -1594,39 +1660,35 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *_buf, - void H5_ATTR_UNUSED *background) +H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *_buf, void H5_ATTR_UNUSED *background) { - uint8_t *buf = (uint8_t*)_buf; - H5T_t *src = NULL, *dst = NULL; /*source and dest datatypes */ - ssize_t direction; /*direction of traversal */ - size_t elmtno; /*element number */ - size_t olap; /*num overlapping elements */ - size_t half_size; /*1/2 of total size for swapping*/ - uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t dbuf[256]; /*temp destination buffer */ - size_t msb_pad_offset; /*offset for dest MSB padding */ - size_t i; - uint8_t *src_rev=NULL; /*order-reversed source buffer */ - H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ - H5T_conv_ret_t except_ret; /*return of callback function */ - hbool_t reverse; /*if reverse the order of destination */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * buf = (uint8_t *)_buf; + H5T_t * src = NULL, *dst = NULL; /*source and dest datatypes */ + ssize_t direction; /*direction of traversal */ + size_t elmtno; /*element number */ + size_t olap; /*num overlapping elements */ + size_t half_size; /*1/2 of total size for swapping*/ + uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t dbuf[256]; /*temp destination buffer */ + size_t msb_pad_offset; /*offset for dest MSB padding */ + size_t i; + uint8_t * src_rev = NULL; /*order-reversed source buffer */ + H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ + H5T_conv_ret_t except_ret; /*return of callback function */ + hbool_t reverse; /*if reverse the order of destination */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ORDER_LE != src->shared->u.atomic.order && - H5T_ORDER_BE != src->shared->u.atomic.order) + if (H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(H5T_ORDER_LE != dst->shared->u.atomic.order && - H5T_ORDER_BE != dst->shared->u.atomic.order) + if (H5T_ORDER_LE != dst->shared->u.atomic.order && H5T_ORDER_BE != dst->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") cdata->need_bkg = H5T_BKG_NO; break; @@ -1636,7 +1698,7 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -1644,28 +1706,30 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if(src->shared->size == dst->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src->shared->size == dst->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; - } else if(src->shared->size >= dst->shared->size) { - double olap_d = HDceil((double)(dst->shared->size) / - (double)(src->shared->size - dst->shared->size)); + olap = nelmts; + } + else if (src->shared->size >= dst->shared->size) { + double olap_d = + HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size)); olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olap_d = HDceil((double)(src->shared->size) / - (double)(dst->shared->size - src->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; + } + else { + double olap_d = + HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size; direction = -1; } /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ @@ -1675,13 +1739,13 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if(direction > 0) { + if (direction > 0) { s = sp; d = elmtno < olap ? dbuf : dp; } /* end if */ @@ -1691,12 +1755,12 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end else */ #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if(d == dbuf) + if (d == dbuf) HDassert((dp >= sp && dp < sp + src->shared->size) || - (sp >= dp && sp < dp + dst->shared->size)); + (sp >= dp && sp < dp + dst->shared->size)); else - HDassert((dp < sp && dp + dst->shared->size<=sp) || - (sp < dp && sp + src->shared->size<=dp)); + HDassert((dp < sp && dp + dst->shared->size <= sp) || + (sp < dp && sp + src->shared->size <= dp)); #endif /* @@ -1704,14 +1768,14 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if(H5T_ORDER_BE == src->shared->u.atomic.order) { + if (H5T_ORDER_BE == src->shared->u.atomic.order) { half_size = src->shared->size / 2; - for(i = 0; i < half_size; i++) { - uint8_t tmp = s[src->shared->size - (i + 1)]; + for (i = 0; i < half_size; i++) { + uint8_t tmp = s[src->shared->size - (i + 1)]; s[src->shared->size - (i + 1)] = s[i]; - s[i] = tmp; + s[i] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* Initiate these variables */ except_ret = H5T_CONV_UNHANDLED; @@ -1722,34 +1786,36 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * than the destination then invoke the overflow function or copy * as many bits as possible. Zero extra bits in the destination. */ - if(src->shared->u.atomic.prec > dst->shared->u.atomic.prec) { + if (src->shared->u.atomic.prec > dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T_reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, + cb_struct.user_data); } /* end if */ - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_copy(d, dst->shared->u.atomic.offset, - s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); - } else if(except_ret == H5T_CONV_ABORT) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it*/ reverse = FALSE; - } else { - H5T__bit_copy(d, dst->shared->u.atomic.offset, - s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec); - H5T__bit_set(d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, - dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); + } + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, FALSE); } /* * Fill the destination padding areas. */ - switch(dst->shared->u.atomic.lsb_pad) { + switch (dst->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: H5T__bit_set(d, (size_t)0, dst->shared->u.atomic.offset, FALSE); break; @@ -1765,7 +1831,7 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported LSB padding") } /* end switch */ msb_pad_offset = dst->shared->u.atomic.offset + dst->shared->u.atomic.prec; - switch(dst->shared->u.atomic.msb_pad) { + switch (dst->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: H5T__bit_set(d, msb_pad_offset, 8 * dst->shared->size - msb_pad_offset, FALSE); break; @@ -1785,30 +1851,36 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Put the destination in the correct byte order. See note at * beginning of loop. */ - if(H5T_ORDER_BE == dst->shared->u.atomic.order && reverse) { + if (H5T_ORDER_BE == dst->shared->u.atomic.order && reverse) { half_size = dst->shared->size / 2; - for(i = 0; i < half_size; i++) { - uint8_t tmp = d[dst->shared->size - (i + 1)]; + for (i = 0; i < half_size; i++) { + uint8_t tmp = d[dst->shared->size - (i + 1)]; d[dst->shared->size - (i + 1)] = d[i]; - d[i] = tmp; + d[i] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if(d == dbuf) + if (d == dbuf) H5MM_memcpy(dp, d, dst->shared->size); - if(buf_stride) { - sp += direction * (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ - dp += direction * (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ - } /* end if */ + if (buf_stride) { + sp += direction * + (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + dp += direction * + (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + } /* end if */ else { - sp += direction * (ssize_t)src->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ - dp += direction * (ssize_t)dst->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ - } /* end else */ - } /* end for */ + sp += direction * + (ssize_t) + src->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + dp += direction * + (ssize_t) + dst->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + } /* end else */ + } /* end for */ break; @@ -1817,12 +1889,11 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_b_b() */ - /*------------------------------------------------------------------------- * Function: H5T_conv_struct_free * @@ -1839,15 +1910,14 @@ done: static H5T_conv_struct_t * H5T_conv_struct_free(H5T_conv_struct_t *priv) { - int *src2dst = priv->src2dst; - hid_t *src_memb_id = priv->src_memb_id, - *dst_memb_id = priv->dst_memb_id; - unsigned i; + int * src2dst = priv->src2dst; + hid_t * src_memb_id = priv->src_memb_id, *dst_memb_id = priv->dst_memb_id; + unsigned i; FUNC_ENTER_NOAPI_NOINIT_NOERR - for(i = 0; i < priv->src_nmembs; i++) - if(src2dst[i] >= 0) { + for (i = 0; i < priv->src_nmembs; i++) + if (src2dst[i] >= 0) { int H5_ATTR_NDEBUG_UNUSED status; status = H5I_dec_ref(src_memb_id[i]); @@ -1864,7 +1934,6 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv) FUNC_LEAVE_NOAPI((H5T_conv_struct_t *)H5MM_xfree(priv)) } /* end H5T_conv_struct_free() */ - /*------------------------------------------------------------------------- * Function: H5T_conv_struct_init * @@ -1914,32 +1983,32 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv) static herr_t H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) { - H5T_conv_struct_t *priv = (H5T_conv_struct_t*)(cdata->priv); - int *src2dst = NULL; - unsigned src_nmembs, dst_nmembs; - unsigned i, j; - herr_t ret_value = SUCCEED; /* Return value */ + H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); + int * src2dst = NULL; + unsigned src_nmembs, dst_nmembs; + unsigned i, j; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT src_nmembs = src->shared->u.compnd.nmembs; dst_nmembs = dst->shared->u.compnd.nmembs; - if(!priv) { + if (!priv) { /* * Allocate private data structure and arrays. */ - if(NULL == (priv = (H5T_conv_struct_t *)(cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t)))) || - NULL == (priv->src2dst = (int *)H5MM_malloc(src_nmembs * sizeof(int))) || - NULL == (priv->src_memb_id = (hid_t *)H5MM_malloc(src_nmembs * sizeof(hid_t))) || - NULL == (priv->dst_memb_id = (hid_t *)H5MM_malloc(dst_nmembs * sizeof(hid_t)))) + if (NULL == (priv = (H5T_conv_struct_t *)(cdata->priv = H5MM_calloc(sizeof(H5T_conv_struct_t)))) || + NULL == (priv->src2dst = (int *)H5MM_malloc(src_nmembs * sizeof(int))) || + NULL == (priv->src_memb_id = (hid_t *)H5MM_malloc(src_nmembs * sizeof(hid_t))) || + NULL == (priv->dst_memb_id = (hid_t *)H5MM_malloc(dst_nmembs * sizeof(hid_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - src2dst = priv->src2dst; + src2dst = priv->src2dst; priv->src_nmembs = src_nmembs; /* The flag of special optimization to indicate if source members and destination * members are a subset of each other. Initialize it to FALSE */ - priv->subset_info.subset = H5T_SUBSET_FALSE; + priv->subset_info.subset = H5T_SUBSET_FALSE; priv->subset_info.copy_size = 0; /* @@ -1955,30 +2024,30 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) * source and destination member datatype so we can look up the * member datatype conversion functions later. */ - for(i = 0; i < src_nmembs; i++) { + for (i = 0; i < src_nmembs; i++) { src2dst[i] = -1; - for(j = 0; j < dst_nmembs; j++) { - if(!HDstrcmp(src->shared->u.compnd.memb[i].name, dst->shared->u.compnd.memb[j].name)) { + for (j = 0; j < dst_nmembs; j++) { + if (!HDstrcmp(src->shared->u.compnd.memb[i].name, dst->shared->u.compnd.memb[j].name)) { H5_CHECKED_ASSIGN(src2dst[i], int, j, unsigned); break; } /* end if */ - } /* end for */ - if(src2dst[i] >= 0) { - hid_t tid; - H5T_t *type; + } /* end for */ + if (src2dst[i] >= 0) { + hid_t tid; + H5T_t *type; type = H5T_copy(src->shared->u.compnd.memb[i].type, H5T_COPY_ALL); - tid = H5I_register(H5I_DATATYPE, type, FALSE); + tid = H5I_register(H5I_DATATYPE, type, FALSE); HDassert(tid >= 0); priv->src_memb_id[i] = tid; type = H5T_copy(dst->shared->u.compnd.memb[src2dst[i]].type, H5T_COPY_ALL); - tid = H5I_register(H5I_DATATYPE, type, FALSE); + tid = H5I_register(H5I_DATATYPE, type, FALSE); HDassert(tid >= 0); priv->dst_memb_id[src2dst[i]] = tid; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { /* Restore sorted conditions for the datatypes */ /* (Required for the src2dst array to be valid) */ @@ -1992,62 +2061,72 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) */ src2dst = priv->src2dst; H5MM_xfree(priv->memb_path); - if(NULL == (priv->memb_path = (H5T_path_t **)H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(H5T_path_t*)))) + if (NULL == + (priv->memb_path = (H5T_path_t **)H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(H5T_path_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for(i = 0; i < src_nmembs; i++) { - if(src2dst[i] >= 0) { - H5T_path_t *tpath = H5T_path_find(src->shared->u.compnd.memb[i].type, dst->shared->u.compnd.memb[src2dst[i]].type); + for (i = 0; i < src_nmembs; i++) { + if (src2dst[i] >= 0) { + H5T_path_t *tpath = H5T_path_find(src->shared->u.compnd.memb[i].type, + dst->shared->u.compnd.memb[src2dst[i]].type); - if(NULL == (priv->memb_path[i] = tpath)) { + if (NULL == (priv->memb_path[i] = tpath)) { cdata->priv = H5T_conv_struct_free(priv); HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert member datatype") } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* The compound conversion functions need a background buffer */ cdata->need_bkg = H5T_BKG_YES; - if(src_nmembs < dst_nmembs) { + if (src_nmembs < dst_nmembs) { priv->subset_info.subset = H5T_SUBSET_SRC; - for(i = 0; i < src_nmembs; i++) { + for (i = 0; i < src_nmembs; i++) { /* If any of source members doesn't have counterpart in the same - * order or there's conversion between members, don't do the - * optimization. - */ - if(src2dst[i] != (int)i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { + * order or there's conversion between members, don't do the + * optimization. + */ + if (src2dst[i] != (int)i || + (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || + (priv->memb_path[i])->is_noop == FALSE) { priv->subset_info.subset = H5T_SUBSET_FALSE; break; } /* end if */ - } /* end for */ + } /* end for */ /* Compute the size of the data to be copied for each element. It - * may be smaller than either src or dst if there is extra space at - * the end of src. - */ - if(priv->subset_info.subset == H5T_SUBSET_SRC) - priv->subset_info.copy_size = src->shared->u.compnd.memb[src_nmembs - 1].offset - + src->shared->u.compnd.memb[src_nmembs - 1].size; - } else if(dst_nmembs < src_nmembs) { + * may be smaller than either src or dst if there is extra space at + * the end of src. + */ + if (priv->subset_info.subset == H5T_SUBSET_SRC) + priv->subset_info.copy_size = src->shared->u.compnd.memb[src_nmembs - 1].offset + + src->shared->u.compnd.memb[src_nmembs - 1].size; + } + else if (dst_nmembs < src_nmembs) { priv->subset_info.subset = H5T_SUBSET_DST; - for(i = 0; i < dst_nmembs; i++) { + for (i = 0; i < dst_nmembs; i++) { /* If any of source members doesn't have counterpart in the same order or - * there's conversion between members, don't do the optimization. */ - if(src2dst[i] != (int)i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { + * there's conversion between members, don't do the optimization. */ + if (src2dst[i] != (int)i || + (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || + (priv->memb_path[i])->is_noop == FALSE) { priv->subset_info.subset = H5T_SUBSET_FALSE; break; } } /* end for */ /* Compute the size of the data to be copied for each element. It - * may be smaller than either src or dst if there is extra space at - * the end of dst. - */ - if(priv->subset_info.subset == H5T_SUBSET_DST) - priv->subset_info.copy_size = dst->shared->u.compnd.memb[dst_nmembs-1].offset - + dst->shared->u.compnd.memb[dst_nmembs-1].size; - } else /* If the numbers of source and dest members are equal and no conversion is needed, - * the case should have been handled as noop earlier in H5Dio.c. */ - {;} + * may be smaller than either src or dst if there is extra space at + * the end of dst. + */ + if (priv->subset_info.subset == H5T_SUBSET_DST) + priv->subset_info.copy_size = dst->shared->u.compnd.memb[dst_nmembs - 1].offset + + dst->shared->u.compnd.memb[dst_nmembs - 1].size; + } + else /* If the numbers of source and dest members are equal and no conversion is needed, + * the case should have been handled as noop earlier in H5Dio.c. */ + { + ; + } cdata->recalc = FALSE; @@ -2055,7 +2134,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_conv_struct_init() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_struct_subset * @@ -2083,7 +2161,7 @@ done: H5T_subset_info_t * H5T__conv_struct_subset(const H5T_cdata_t *cdata) { - H5T_conv_struct_t *priv = NULL; + H5T_conv_struct_t *priv = NULL; FUNC_ENTER_PACKAGE_NOERR @@ -2092,10 +2170,9 @@ H5T__conv_struct_subset(const H5T_cdata_t *cdata) priv = (H5T_conv_struct_t *)(cdata->priv); - FUNC_LEAVE_NOAPI((H5T_subset_info_t *) &priv->subset_info) + FUNC_LEAVE_NOAPI((H5T_subset_info_t *)&priv->subset_info) } /* end H5T__conv_struct_subset() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_struct * @@ -2123,29 +2200,29 @@ H5T__conv_struct_subset(const H5T_cdata_t *cdata) *------------------------------------------------------------------------- */ herr_t -H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg) +H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *_buf, void *_bkg) { - uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ - uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ - uint8_t *xbuf = buf, *xbkg = bkg; /*temp pointers into buf and bkg*/ - H5T_t *src = NULL; /*source datatype */ - H5T_t *dst = NULL; /*destination datatype */ - int *src2dst = NULL; /*maps src member to dst member */ - H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ - H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ - size_t offset; /*byte offset wrt struct */ - ssize_t src_delta; /*source stride */ - ssize_t bkg_delta; /*background stride */ - size_t elmtno; - unsigned u; /*counters */ - int i; /*counters */ - H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ + uint8_t * bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ + uint8_t * xbuf = buf, *xbkg = bkg; /*temp pointers into buf and bkg*/ + H5T_t * src = NULL; /*source datatype */ + H5T_t * dst = NULL; /*destination datatype */ + int * src2dst = NULL; /*maps src member to dst member */ + H5T_cmemb_t * src_memb = NULL; /*source struct member descript.*/ + H5T_cmemb_t * dst_memb = NULL; /*destination struct memb desc. */ + size_t offset; /*byte offset wrt struct */ + ssize_t src_delta; /*source stride */ + ssize_t bkg_delta; /*background stride */ + size_t elmtno; + unsigned u; /*counters */ + int i; /*counters */ + H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -2155,12 +2232,12 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_COMPOUND != src->shared->type) + if (H5T_COMPOUND != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") - if(H5T_COMPOUND != dst->shared->type) + if (H5T_COMPOUND != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") - if(H5T_conv_struct_init(src, dst, cdata) < 0) + if (H5T_conv_struct_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") break; @@ -2175,12 +2252,12 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") HDassert(priv); HDassert(bkg && cdata->need_bkg); - if(cdata->recalc && H5T_conv_struct_init(src, dst, cdata) < 0) + if (cdata->recalc && H5T_conv_struct_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") /* @@ -2193,15 +2270,15 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Direction of conversion and striding through background. */ - if(buf_stride) { + if (buf_stride) { H5_CHECKED_ASSIGN(src_delta, ssize_t, buf_stride, size_t); - if(!bkg_stride) { + if (!bkg_stride) { H5_CHECKED_ASSIGN(bkg_delta, ssize_t, dst->shared->size, size_t); } /* end if */ else H5_CHECKED_ASSIGN(bkg_delta, ssize_t, bkg_stride, size_t); } /* end if */ - else if(dst->shared->size <= src->shared->size) { + else if (dst->shared->size <= src->shared->size) { H5_CHECKED_ASSIGN(src_delta, ssize_t, src->shared->size, size_t); H5_CHECKED_ASSIGN(bkg_delta, ssize_t, dst->shared->size, size_t); } /* end else-if */ @@ -2215,7 +2292,7 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end else */ /* Conversion loop... */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* * For each source member which will be present in the * destination, convert the member to the destination type unless @@ -2224,27 +2301,27 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * data point as small as possible with all the free space on the * right side. */ - for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { - if(src2dst[u] < 0) + for (u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if (src2dst[u] < 0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; - if(dst_memb->size <= src_memb->size) { - if(H5T_convert(priv->memb_path[u], priv->src_memb_id[u], - priv->dst_memb_id[src2dst[u]], - (size_t)1, (size_t)0, (size_t)0, /*no striding (packed array)*/ - xbuf + src_memb->offset, xbkg + dst_memb->offset) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") + if (dst_memb->size <= src_memb->size) { + if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u], + priv->dst_memb_id[src2dst[u]], (size_t)1, (size_t)0, + (size_t)0, /*no striding (packed array)*/ + xbuf + src_memb->offset, xbkg + dst_memb->offset) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound datatype member") HDmemmove(xbuf + offset, xbuf + src_memb->offset, dst_memb->size); offset += dst_memb->size; } /* end if */ else { - HDmemmove (xbuf+offset, xbuf+src_memb->offset, - src_memb->size); + HDmemmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); offset += src_memb->size; } /* end else */ - } /* end for */ + } /* end for */ /* * For each source member which will be present in the @@ -2254,19 +2331,20 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * background buffer. */ H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); - for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { - if(src2dst[i] < 0) + for (i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if (src2dst[i] < 0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; - if(dst_memb->size > src_memb->size) { + if (dst_memb->size > src_memb->size) { offset -= src_memb->size; - if(H5T_convert(priv->memb_path[i], - priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]], - (size_t)1, (size_t)0, (size_t)0, /*no striding (packed array)*/ - xbuf + offset, xbkg + dst_memb->offset) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") + if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], + priv->dst_memb_id[src2dst[i]], (size_t)1, (size_t)0, + (size_t)0, /*no striding (packed array)*/ + xbuf + offset, xbkg + dst_memb->offset) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound datatype member") } /* end if */ else offset -= dst_memb->size; @@ -2282,14 +2360,14 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end for */ /* If the bkg_delta was set to -(dst->shared->size), make it positive now */ - if(buf_stride == 0 && dst->shared->size > src->shared->size) + if (buf_stride == 0 && dst->shared->size > src->shared->size) H5_CHECKED_ASSIGN(bkg_delta, ssize_t, dst->shared->size, size_t); /* * Copy the background buffer back into the in-place conversion * buffer. */ - for(xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { + for (xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride ? buf_stride : dst->shared->size; xbkg += bkg_delta; @@ -2305,7 +2383,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_struct() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_struct_opt * @@ -2350,30 +2427,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg) +H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *_buf, void *_bkg) { - uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ - uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ - uint8_t *xbuf = NULL; /*temporary pointer into `buf' */ - uint8_t *xbkg = NULL; /*temporary pointer into `bkg' */ - H5T_t *src = NULL; /*source datatype */ - H5T_t *dst = NULL; /*destination datatype */ - int *src2dst = NULL; /*maps src member to dst member */ - H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ - H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ - size_t offset; /*byte offset wrt struct */ - size_t elmtno; /*element counter */ - size_t copy_size; /*size of element for copying */ - H5T_conv_struct_t *priv = NULL; /*private data */ - hbool_t no_stride = FALSE; /*flag to indicate no stride */ - unsigned u; /*counters */ - int i; /*counters */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ + uint8_t * bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ + uint8_t * xbuf = NULL; /*temporary pointer into `buf' */ + uint8_t * xbkg = NULL; /*temporary pointer into `bkg' */ + H5T_t * src = NULL; /*source datatype */ + H5T_t * dst = NULL; /*destination datatype */ + int * src2dst = NULL; /*maps src member to dst member */ + H5T_cmemb_t * src_memb = NULL; /*source struct member descript.*/ + H5T_cmemb_t * dst_memb = NULL; /*destination struct memb desc. */ + size_t offset; /*byte offset wrt struct */ + size_t elmtno; /*element counter */ + size_t copy_size; /*size of element for copying */ + H5T_conv_struct_t *priv = NULL; /*private data */ + hbool_t no_stride = FALSE; /*flag to indicate no stride */ + unsigned u; /*counters */ + int i; /*counters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -2381,17 +2458,17 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_COMPOUND != src->shared->type) + if (H5T_COMPOUND != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") - if(H5T_COMPOUND != dst->shared->type) + if (H5T_COMPOUND != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") /* Initialize data which is relatively constant */ - if(H5T_conv_struct_init(src, dst, cdata) < 0) + if (H5T_conv_struct_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") - priv = (H5T_conv_struct_t *)(cdata->priv); + priv = (H5T_conv_struct_t *)(cdata->priv); src2dst = priv->src2dst; /* @@ -2404,30 +2481,31 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * of loops as in the actual conversion except it checks that there * is room for each conversion instead of actually doing anything. */ - if(dst->shared->size > src->shared->size) { - for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { - if(src2dst[u] < 0) + if (dst->shared->size > src->shared->size) { + for (u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if (src2dst[u] < 0) continue; src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; - if(dst_memb->size > src_memb->size) + if (dst_memb->size > src_memb->size) offset += src_memb->size; } /* end for */ H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); - for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { - if(src2dst[i] < 0) + for (i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if (src2dst[i] < 0) continue; src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; - if(dst_memb->size > src_memb->size) { + if (dst_memb->size > src_memb->size) { offset -= src_memb->size; - if(dst_memb->size > src->shared->size-offset) { + if (dst_memb->size > src->shared->size - offset) { cdata->priv = H5T_conv_struct_free(priv); - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion is unsupported by this function") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "conversion is unsupported by this function") } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ break; case H5T_CONV_FREE: @@ -2441,11 +2519,11 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Update cached data if necessary */ - if(cdata->recalc && H5T_conv_struct_init(src, dst, cdata) < 0) + if (cdata->recalc && H5T_conv_struct_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") priv = (H5T_conv_struct_t *)(cdata->priv); HDassert(priv); @@ -2468,29 +2546,29 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * background data into the BKG buffer at multiples of BKG_STRIDE; * otherwise assume BKG buffer is the packed destination datatype. */ - if(!buf_stride || !bkg_stride) + if (!buf_stride || !bkg_stride) bkg_stride = dst->shared->size; - if(!buf_stride) { - no_stride = TRUE; + if (!buf_stride) { + no_stride = TRUE; buf_stride = src->shared->size; } /* end if */ - if(priv->subset_info.subset == H5T_SUBSET_SRC || priv->subset_info.subset == H5T_SUBSET_DST) { + if (priv->subset_info.subset == H5T_SUBSET_SRC || priv->subset_info.subset == H5T_SUBSET_DST) { /* If the optimization flag is set to indicate source members are a subset and * in the top of the destination, simply copy the source members to background buffer. */ - xbuf = buf; - xbkg = bkg; + xbuf = buf; + xbkg = bkg; copy_size = priv->subset_info.copy_size; - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, copy_size); /* Update pointers */ xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ - } /* end if */ + } /* end if */ else { /* * For each member where the destination is not larger than the @@ -2499,33 +2577,34 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * destination in the bkg buffer. Otherwise move the element as far * left as possible in the buffer. */ - for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { - if(src2dst[u] < 0) + for (u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if (src2dst[u] < 0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; - if(dst_memb->size <= src_memb->size) { + if (dst_memb->size <= src_memb->size) { xbuf = buf + src_memb->offset; xbkg = bkg + dst_memb->offset; - if(H5T_convert(priv->memb_path[u], priv->src_memb_id[u], - priv->dst_memb_id[src2dst[u]], nelmts, - buf_stride, bkg_stride, xbuf, xbkg) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") - for(elmtno = 0; elmtno < nelmts; elmtno++) { + if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u], + priv->dst_memb_id[src2dst[u]], nelmts, buf_stride, bkg_stride, xbuf, + xbkg) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound datatype member") + for (elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, dst_memb->size); xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ - } /* end if */ + } /* end if */ else { - for(xbuf = buf, elmtno = 0; elmtno < nelmts; elmtno++) { + for (xbuf = buf, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); xbuf += buf_stride; } /* end for */ offset += src_memb->size; } /* end else */ - } /* end else */ + } /* end else */ /* * Work from right to left, converting those members that weren't @@ -2534,34 +2613,35 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * bkg buffer. */ H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); - for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { - if(src2dst[i] < 0) + for (i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if (src2dst[i] < 0) continue; src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; - if(dst_memb->size > src_memb->size) { + if (dst_memb->size > src_memb->size) { offset -= src_memb->size; xbuf = buf + offset; xbkg = bkg + dst_memb->offset; - if(H5T_convert(priv->memb_path[i], priv->src_memb_id[i], - priv->dst_memb_id[src2dst[i]], nelmts, - buf_stride, bkg_stride, xbuf, xbkg) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") - for(elmtno = 0; elmtno < nelmts; elmtno++) { + if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], + priv->dst_memb_id[src2dst[i]], nelmts, buf_stride, bkg_stride, xbuf, + xbkg) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound datatype member") + for (elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, dst_memb->size); xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ - } /* end if */ - } /* end for */ - } /* end else */ + } /* end if */ + } /* end for */ + } /* end else */ - if(no_stride) + if (no_stride) buf_stride = dst->shared->size; /* Move background buffer into result buffer */ - for(xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { + for (xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride; xbkg += bkg_stride; @@ -2577,7 +2657,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_struct_opt() */ - /*------------------------------------------------------------------------- * Function: H5T_conv_enum_init * @@ -2595,21 +2674,21 @@ done: static herr_t H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) { - H5T_enum_struct_t *priv = NULL; /*private conversion data */ - int n; /*src value cast as native int */ - int domain[2] = {0, 0}; /*min and max source values */ - int *map = NULL; /*map from src value to dst idx */ - unsigned length; /*nelmts in map array */ - unsigned i, j; /*counters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_enum_struct_t *priv = NULL; /*private conversion data */ + int n; /*src value cast as native int */ + int domain[2] = {0, 0}; /*min and max source values */ + int * map = NULL; /*map from src value to dst idx */ + unsigned length; /*nelmts in map array */ + unsigned i, j; /*counters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT cdata->need_bkg = H5T_BKG_NO; - if(NULL == (priv = (H5T_enum_struct_t *)(cdata->priv = H5MM_calloc(sizeof(*priv))))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(0 == src->shared->u.enumer.nmembs) - HGOTO_DONE(SUCCEED); + if (NULL == (priv = (H5T_enum_struct_t *)(cdata->priv = H5MM_calloc(sizeof(*priv))))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if (0 == src->shared->u.enumer.nmembs) + HGOTO_DONE(SUCCEED); /* * Check that the source symbol names are a subset of the destination @@ -2618,17 +2697,16 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) */ H5T__sort_name(src, NULL); H5T__sort_name(dst, NULL); - if(NULL == (priv->src2dst = (int *)H5MM_malloc(src->shared->u.enumer.nmembs * sizeof(int)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for(i = 0, j = 0; - i < src->shared->u.enumer.nmembs && j < dst->shared->u.enumer.nmembs; - i++, j++) { - while(j < dst->shared->u.enumer.nmembs && - HDstrcmp(src->shared->u.enumer.name[i], dst->shared->u.enumer.name[j])) + if (NULL == (priv->src2dst = (int *)H5MM_malloc(src->shared->u.enumer.nmembs * sizeof(int)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + for (i = 0, j = 0; i < src->shared->u.enumer.nmembs && j < dst->shared->u.enumer.nmembs; i++, j++) { + while (j < dst->shared->u.enumer.nmembs && + HDstrcmp(src->shared->u.enumer.name[i], dst->shared->u.enumer.name[j])) j++; - if(j >= dst->shared->u.enumer.nmembs) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type") - priv->src2dst[i] = (int)j; + if (j >= dst->shared->u.enumer.nmembs) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "source type is not a subset of destination type") + priv->src2dst[i] = (int)j; } /* end for */ /* @@ -2657,69 +2735,71 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) * Because this is the optimized code, we won't fix it. It should still work in some * situations. SLU - 2011/5/24) */ - if(1 == src->shared->size || sizeof(short) == src->shared->size || sizeof(int) == src->shared->size) { - for(i = 0; i < src->shared->u.enumer.nmembs; i++) { - if(1 == src->shared->size) - n = *((signed char *)((uint8_t *)src->shared->u.enumer.value + i)); - else if (sizeof(short) == src->shared->size) - n = *((short *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); - else - n = *((int *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); - if(0 == i) { - domain[0] = domain[1] = n; - } else { - domain[0] = MIN(domain[0], n); - domain[1] = MAX(domain[1], n); - } - } /* end for */ + if (1 == src->shared->size || sizeof(short) == src->shared->size || sizeof(int) == src->shared->size) { + for (i = 0; i < src->shared->u.enumer.nmembs; i++) { + if (1 == src->shared->size) + n = *((signed char *)((uint8_t *)src->shared->u.enumer.value + i)); + else if (sizeof(short) == src->shared->size) + n = *((short *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); + else + n = *((int *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); + if (0 == i) { + domain[0] = domain[1] = n; + } + else { + domain[0] = MIN(domain[0], n); + domain[1] = MAX(domain[1], n); + } + } /* end for */ HDassert(domain[1] >= domain[0]); - length = (unsigned)(domain[1] - domain[0]) + 1; - if(src->shared->u.enumer.nmembs < 2 || - (double)length / src->shared->u.enumer.nmembs < (double)(1.2f)) { - priv->base = domain[0]; - priv->length = length; - if(NULL == (map = (int *)H5MM_malloc(length * sizeof(int)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for(i = 0; i < length; i++) + length = (unsigned)(domain[1] - domain[0]) + 1; + if (src->shared->u.enumer.nmembs < 2 || + (double)length / src->shared->u.enumer.nmembs < (double)(1.2f)) { + priv->base = domain[0]; + priv->length = length; + if (NULL == (map = (int *)H5MM_malloc(length * sizeof(int)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + for (i = 0; i < length; i++) map[i] = -1; /*entry unused*/ - for(i = 0; i < src->shared->u.enumer.nmembs; i++) { - if(1 == src->shared->size) - n = *((signed char *)((uint8_t *)src->shared->u.enumer.value + i)); - else if(sizeof(short) == src->shared->size) - n = *((short *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); - else - n = *((int *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); - n -= priv->base; - HDassert(n >= 0 && (unsigned)n < priv->length); - HDassert(map[n] < 0); - map[n] = priv->src2dst[i]; - } /* end for */ - - /* - * Replace original src2dst array with our new one. The original - * was indexed by source member number while the new one is - * indexed by source values. - */ - H5MM_xfree(priv->src2dst); - priv->src2dst = map; - HGOTO_DONE(SUCCEED); - } + for (i = 0; i < src->shared->u.enumer.nmembs; i++) { + if (1 == src->shared->size) + n = *((signed char *)((uint8_t *)src->shared->u.enumer.value + i)); + else if (sizeof(short) == src->shared->size) + n = *(( + short *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); + else + n = *( + (int *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); + n -= priv->base; + HDassert(n >= 0 && (unsigned)n < priv->length); + HDassert(map[n] < 0); + map[n] = priv->src2dst[i]; + } /* end for */ + + /* + * Replace original src2dst array with our new one. The original + * was indexed by source member number while the new one is + * indexed by source values. + */ + H5MM_xfree(priv->src2dst); + priv->src2dst = map; + HGOTO_DONE(SUCCEED); + } } /* Sort source type by value and adjust src2dst[] appropriately */ H5T__sort_value(src, priv->src2dst); done: - if (ret_value<0 && priv) { - H5MM_xfree(priv->src2dst); - H5MM_xfree(priv); - cdata->priv = NULL; + if (ret_value < 0 && priv) { + H5MM_xfree(priv->src2dst); + H5MM_xfree(priv); + cdata->priv = NULL; } FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__conv_enum * @@ -2734,24 +2814,23 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *_buf, - void H5_ATTR_UNUSED *bkg) +H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *_buf, void H5_ATTR_UNUSED *bkg) { - uint8_t *buf = (uint8_t*)_buf; /*cast for pointer arithmetic */ - H5T_t *src = NULL, *dst = NULL; /*src and dst datatypes */ - uint8_t *s = NULL, *d = NULL; /*src and dst BUF pointers */ - ssize_t src_delta, dst_delta; /*conversion strides */ - int n; /*src value cast as native int */ - H5T_enum_struct_t *priv = (H5T_enum_struct_t*)(cdata->priv); - H5T_conv_cb_t cb_struct; /*conversion callback structure */ - H5T_conv_ret_t except_ret; /*return of callback function */ - size_t i; /*counters */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ + H5T_t * src = NULL, *dst = NULL; /*src and dst datatypes */ + uint8_t * s = NULL, *d = NULL; /*src and dst BUF pointers */ + ssize_t src_delta, dst_delta; /*conversion strides */ + int n; /*src value cast as native int */ + H5T_enum_struct_t *priv = (H5T_enum_struct_t *)(cdata->priv); + H5T_conv_cb_t cb_struct; /*conversion callback structure */ + H5T_conv_ret_t except_ret; /*return of callback function */ + size_t i; /*counters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * Determine if this conversion function applies to the conversion @@ -2759,14 +2838,14 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the `priv' field of `cdata' with information about the underlying * integer conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ENUM != src->shared->type) + if (H5T_ENUM != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") - if(H5T_ENUM != dst->shared->type) + if (H5T_ENUM != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") - if(H5T_conv_enum_init(src, dst, cdata) < 0) + if (H5T_conv_enum_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize private data") break; @@ -2774,8 +2853,8 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, #ifdef H5T_DEBUG if (H5DEBUG(T)) { HDfprintf(H5DEBUG(T), " Using %s mapping function%s\n", - priv->length?"O(1)":"O(log N)", - priv->length?"":", where N is the number of enum members"); + priv->length ? "O(1)" : "O(log N)", + priv->length ? "" : ", where N is the number of enum members"); } #endif if (priv) { @@ -2786,11 +2865,11 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; case H5T_CONV_CONV: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ENUM != src->shared->type) + if (H5T_ENUM != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") - if(H5T_ENUM != dst->shared->type) + if (H5T_ENUM != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") /* priv->src2dst map was computed for certain sort keys. Make sure those same @@ -2798,35 +2877,37 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * we actually don't care about the source type's order when doing the O(1) * conversion algorithm, which is turned on by non-zero priv->length */ H5T__sort_name(dst, NULL); - if(!priv->length) + if (!priv->length) H5T__sort_value(src, NULL); /* * Direction of conversion. */ - if(buf_stride) { + if (buf_stride) { H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); src_delta = dst_delta = (ssize_t)buf_stride; s = d = buf; - } else if(dst->shared->size <= src->shared->size) { + } + else if (dst->shared->size <= src->shared->size) { H5_CHECKED_ASSIGN(src_delta, ssize_t, src->shared->size, size_t); H5_CHECKED_ASSIGN(dst_delta, ssize_t, dst->shared->size, size_t); s = d = buf; - } else { + } + else { H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); src_delta = -(ssize_t)src->shared->size; dst_delta = -(ssize_t)dst->shared->size; - s = buf + (nelmts - 1) * src->shared->size; - d = buf + (nelmts - 1) * dst->shared->size; + s = buf + (nelmts - 1) * src->shared->size; + d = buf + (nelmts - 1) * dst->shared->size; } /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") - for(i = 0; i < nelmts; i++, s += src_delta, d += dst_delta) { - if(priv->length) { + for (i = 0; i < nelmts; i++, s += src_delta, d += dst_delta) { + if (priv->length) { /* Use O(1) lookup */ /* (The casting won't work when the byte orders are different. i.g. if the source value * is big-endian 0x0000000f, the direct casting "n = *((int*)s);" will make it a big @@ -2834,67 +2915,72 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * optimization code. Please also see the comment in the H5T_conv_enum_init() function. * SLU - 2011/5/24) */ - if(1 == src->shared->size) - n = *((signed char*)s); - else if(sizeof(short) == src->shared->size) + if (1 == src->shared->size) + n = *((signed char *)s); + else if (sizeof(short) == src->shared->size) n = *((short *)((void *)s)); else n = *((int *)((void *)s)); n -= priv->base; - if(n < 0 || (unsigned)n >= priv->length || priv->src2dst[n] < 0) { + if (n < 0 || (unsigned)n >= priv->length || priv->src2dst[n] < 0) { /*overflow*/ except_ret = H5T_CONV_UNHANDLED; /*If user's exception handler is present, use it*/ - if(cb_struct.func) - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - s, d, cb_struct.user_data); + if (cb_struct.func) + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, s, d, + cb_struct.user_data); - if(except_ret == H5T_CONV_UNHANDLED) + if (except_ret == H5T_CONV_UNHANDLED) HDmemset(d, 0xff, dst->shared->size); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + } + else H5MM_memcpy(d, - (uint8_t *)dst->shared->u.enumer.value + ((unsigned)priv->src2dst[n] * dst->shared->size), - dst->shared->size); + (uint8_t *)dst->shared->u.enumer.value + + ((unsigned)priv->src2dst[n] * dst->shared->size), + dst->shared->size); } /* end if */ else { /* Use O(log N) lookup */ unsigned lt = 0; unsigned rt = src->shared->u.enumer.nmembs; unsigned md = 0; - int cmp; + int cmp; - while(lt < rt) { - md = (lt + rt) / 2; + while (lt < rt) { + md = (lt + rt) / 2; cmp = HDmemcmp(s, (uint8_t *)src->shared->u.enumer.value + (md * src->shared->size), src->shared->size); - if(cmp < 0) + if (cmp < 0) rt = md; - else if(cmp > 0) + else if (cmp > 0) lt = md + 1; else break; } /* end while */ - if(lt >= rt) { + if (lt >= rt) { except_ret = H5T_CONV_UNHANDLED; /*If user's exception handler is present, use it*/ - if(cb_struct.func) - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src, d, cb_struct.user_data); + if (cb_struct.func) + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src, d, + cb_struct.user_data); - if(except_ret == H5T_CONV_UNHANDLED) + if (except_ret == H5T_CONV_UNHANDLED) HDmemset(d, 0xff, dst->shared->size); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") } /* end if */ else { HDassert(priv->src2dst[md] >= 0); H5MM_memcpy(d, - (uint8_t *)dst->shared->u.enumer.value + ((unsigned)priv->src2dst[md] * dst->shared->size), - dst->shared->size); + (uint8_t *)dst->shared->u.enumer.value + + ((unsigned)priv->src2dst[md] * dst->shared->size), + dst->shared->size); } /* end else */ - } /* end else */ + } /* end else */ } break; @@ -2908,7 +2994,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_enum() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_enum_numeric * @@ -2927,28 +3012,28 @@ done: */ herr_t H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t H5_ATTR_UNUSED buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *_buf, - void H5_ATTR_UNUSED *bkg) + size_t H5_ATTR_UNUSED buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *_buf, + void H5_ATTR_UNUSED *bkg) { - H5T_t *src, *dst; /*src and dst datatypes */ - H5T_t *src_parent; /*parent type for src */ - hid_t src_parent_id = -1; /*ID for parent of the source */ - H5T_path_t *tpath; /* Conversion information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * src, *dst; /*src and dst datatypes */ + H5T_t * src_parent; /*parent type for src */ + hid_t src_parent_id = -1; /*ID for parent of the source */ + H5T_path_t *tpath; /* Conversion information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * Determine if this conversion function applies to the conversion * path SRC_ID->DST_ID. If not, return failure. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ENUM != src->shared->type) + if (H5T_ENUM != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "source type is not a H5T_ENUM datatype") - if(H5T_INTEGER != dst->shared->type && H5T_FLOAT != dst->shared->type) + if (H5T_INTEGER != dst->shared->type && H5T_FLOAT != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "destination is not an integer type") cdata->need_bkg = H5T_BKG_NO; @@ -2958,19 +3043,23 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne break; case H5T_CONV_CONV: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src_parent = src->shared->parent; - if(NULL == (tpath = H5T_path_find(src_parent, dst))) { - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") - } else if(!H5T_path_noop(tpath)) { - if((src_parent_id = H5I_register(H5I_DATATYPE, H5T_copy(src_parent, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") + if (NULL == (tpath = H5T_path_find(src_parent, dst))) { + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest datatype") + } + else if (!H5T_path_noop(tpath)) { + if ((src_parent_id = H5I_register(H5I_DATATYPE, H5T_copy(src_parent, H5T_COPY_ALL), FALSE)) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, + "unable to register types for conversion") /* Convert the data */ - if(H5T_convert(tpath, src_parent_id, dst_id, nelmts, buf_stride, bkg_stride, _buf, bkg) < 0) + if (H5T_convert(tpath, src_parent_id, dst_id, nelmts, buf_stride, bkg_stride, _buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") } break; @@ -2982,13 +3071,12 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne done: /* Release the temporary datatype IDs used */ - if(src_parent_id >= 0) + if (src_parent_id >= 0) H5I_dec_ref(src_parent_id); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_enum_numeric() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_vlen * @@ -3014,36 +3102,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) -{ - H5T_vlen_alloc_info_t vl_alloc_info;/* VL allocation info */ - H5T_path_t *tpath = NULL; /* Type conversion path */ - hbool_t noop_conv = FALSE; /* Flag to indicate a noop conversion */ - hbool_t write_to_file = FALSE; /* Flag to indicate writing to file */ - htri_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */ - size_t bg_seq_len = 0; /* The number of elements in the background sequence */ - hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */ - H5T_t *src = NULL; /*source datatype */ - H5T_t *dst = NULL; /*destination datatype */ - uint8_t *s = NULL; /*source buffer */ - uint8_t *d = NULL; /*destination buffer */ - uint8_t *b = NULL; /*background buffer */ - ssize_t s_stride, d_stride; /*src and dst strides */ - ssize_t b_stride; /*bkg stride */ - size_t safe; /*how many elements are safe to process in each pass */ - size_t src_base_size, dst_base_size;/*source & destination base size*/ - void *conv_buf = NULL; /*temporary conversion buffer */ - size_t conv_buf_size = 0; /*size of conversion buffer in bytes */ - void *tmp_buf = NULL; /*temporary background buffer */ - size_t tmp_buf_size = 0; /*size of temporary bkg buffer */ - hbool_t nested = FALSE; /*flag of nested VL case */ - size_t elmtno; /*element number counter */ - herr_t ret_value = SUCCEED; /* Return value */ +H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) +{ + H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */ + H5T_path_t * tpath = NULL; /* Type conversion path */ + hbool_t noop_conv = FALSE; /* Flag to indicate a noop conversion */ + hbool_t write_to_file = FALSE; /* Flag to indicate writing to file */ + htri_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */ + size_t bg_seq_len = 0; /* The number of elements in the background sequence */ + hid_t tsrc_id = -1, tdst_id = -1; /*temporary type atoms */ + H5T_t * src = NULL; /*source datatype */ + H5T_t * dst = NULL; /*destination datatype */ + uint8_t * s = NULL; /*source buffer */ + uint8_t * d = NULL; /*destination buffer */ + uint8_t * b = NULL; /*background buffer */ + ssize_t s_stride, d_stride; /*src and dst strides */ + ssize_t b_stride; /*bkg stride */ + size_t safe; /*how many elements are safe to process in each pass */ + size_t src_base_size, dst_base_size; /*source & destination base size*/ + void * conv_buf = NULL; /*temporary conversion buffer */ + size_t conv_buf_size = 0; /*size of conversion buffer in bytes */ + void * tmp_buf = NULL; /*temporary background buffer */ + size_t tmp_buf_size = 0; /*size of temporary bkg buffer */ + hbool_t nested = FALSE; /*flag of nested VL case */ + size_t elmtno; /*element number counter */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -3052,16 +3140,18 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_VLEN != src->shared->type) + if (H5T_VLEN != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype") - if(H5T_VLEN != dst->shared->type) + if (H5T_VLEN != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype") - if(H5T_VLEN_STRING == src->shared->u.vlen.type && H5T_VLEN_STRING == dst->shared->u.vlen.type) { - if((H5T_CSET_ASCII == src->shared->u.vlen.cset && H5T_CSET_UTF8 == dst->shared->u.vlen.cset) - || (H5T_CSET_ASCII == dst->shared->u.vlen.cset && H5T_CSET_UTF8 == src->shared->u.vlen.cset)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "The library doesn't convert between strings of ASCII and UTF") + if (H5T_VLEN_STRING == src->shared->u.vlen.type && H5T_VLEN_STRING == dst->shared->u.vlen.type) { + if ((H5T_CSET_ASCII == src->shared->u.vlen.cset && + H5T_CSET_UTF8 == dst->shared->u.vlen.cset) || + (H5T_CSET_ASCII == dst->shared->u.vlen.cset && H5T_CSET_UTF8 == src->shared->u.vlen.cset)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "The library doesn't convert between strings of ASCII and UTF") } /* end if */ /* Variable-length types don't need a background buffer */ @@ -3077,11 +3167,11 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Initialize source & destination strides */ - if(buf_stride) { + if (buf_stride) { HDassert(buf_stride >= src->shared->size); HDassert(buf_stride >= dst->shared->size); H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); @@ -3093,8 +3183,8 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, s_stride = (ssize_t)src->shared->size; d_stride = (ssize_t)dst->shared->size; } /* end else */ - if(bkg) { - if(bkg_stride) + if (bkg) { + if (bkg_stride) b_stride = (ssize_t)bkg_stride; else b_stride = d_stride; @@ -3107,59 +3197,63 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_base_size = H5T_get_size(dst->shared->parent); /* Set up conversion path for base elements */ - if(NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes") - else if(!H5T_path_noop(tpath)) { + if (NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest datatypes") + else if (!H5T_path_noop(tpath)) { H5T_t *tsrc_cpy = NULL, *tdst_cpy = NULL; - if(NULL == (tsrc_cpy = H5T_copy(src->shared->parent, H5T_COPY_ALL))) + if (NULL == (tsrc_cpy = H5T_copy(src->shared->parent, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy src type for conversion") /* References need to know about the src file */ - if(tsrc_cpy->shared->type == H5T_REFERENCE) - if(H5T_set_loc(tsrc_cpy, src->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) + if (tsrc_cpy->shared->type == H5T_REFERENCE) + if (H5T_set_loc(tsrc_cpy, src->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); - if(NULL == (tdst_cpy = H5T_copy(dst->shared->parent, H5T_COPY_ALL))) + if (NULL == (tdst_cpy = H5T_copy(dst->shared->parent, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy dst type for conversion") /* References need to know about the dst file */ - if(tdst_cpy->shared->type == H5T_REFERENCE) - if(H5T_set_loc(tdst_cpy, dst->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) + if (tdst_cpy->shared->type == H5T_REFERENCE) + if (H5T_set_loc(tdst_cpy, dst->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); - if(((tsrc_id = H5I_register(H5I_DATATYPE, tsrc_cpy, FALSE)) < 0) - || ((tdst_id = H5I_register(H5I_DATATYPE, tdst_cpy, FALSE)) < 0)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") + if (((tsrc_id = H5I_register(H5I_DATATYPE, tsrc_cpy, FALSE)) < 0) || + ((tdst_id = H5I_register(H5I_DATATYPE, tdst_cpy, FALSE)) < 0)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, + "unable to register types for conversion") } /* end else-if */ else noop_conv = TRUE; /* Check if we need a temporary buffer for this conversion */ - if((parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_SYSTEM, FAIL, "internal error when detecting variable-length class") - if(tpath->cdata.need_bkg || parent_is_vlen) { + if ((parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_SYSTEM, FAIL, + "internal error when detecting variable-length class") + if (tpath->cdata.need_bkg || parent_is_vlen) { /* Set up initial background buffer */ tmp_buf_size = MAX(src_base_size, dst_base_size); - if(NULL == (tmp_buf = H5FL_BLK_CALLOC(vlen_seq,tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") + if (NULL == (tmp_buf = H5FL_BLK_CALLOC(vlen_seq, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for type conversion") } /* end if */ /* Get the allocation info */ - if(H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) + if (H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") /* Set flags to indicate we are writing to or reading from the file */ - if(dst->shared->u.vlen.file != NULL) + if (dst->shared->u.vlen.file != NULL) write_to_file = TRUE; /* Set the flag for nested VL case */ - if(write_to_file && parent_is_vlen && bkg != NULL) + if (write_to_file && parent_is_vlen && bkg != NULL) nested = TRUE; /* The outer loop of the type conversion macro, controlling which */ /* direction the buffer is walked */ - while(nelmts > 0) { + while (nelmts > 0) { /* Check if we need to go backwards through the buffer */ - if(d_stride > s_stride) { + if (d_stride > s_stride) { /* Sanity check */ HDassert(s_stride > 0); HDassert(d_stride > 0); @@ -3168,14 +3262,15 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Compute the number of "safe" destination elements at */ /* the end of the buffer (Those which don't overlap with */ /* any source elements at the beginning of the buffer) */ - safe = nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); + safe = + nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); /* If we're down to the last few elements, just wrap up */ /* with a "real" reverse copy */ - if(safe < 2) { - s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; - d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; - b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; + if (safe < 2) { + s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; s_stride = -s_stride; d_stride = -d_stride; b_stride = -b_stride; @@ -3187,40 +3282,41 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride; b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride; } /* end else */ - } /* end if */ + } /* end if */ else { /* Single forward pass over all data */ s = d = (uint8_t *)buf; - b = (uint8_t *)bkg; - safe = nelmts; + b = (uint8_t *)bkg; + safe = nelmts; } /* end else */ - for(elmtno = 0; elmtno < safe; elmtno++) { - hbool_t is_nil; /* Whether sequence is "nil" */ + for (elmtno = 0; elmtno < safe; elmtno++) { + hbool_t is_nil; /* Whether sequence is "nil" */ /* Check for "nil" source sequence */ - if((*(src->shared->u.vlen.cls->isnull))(src->shared->u.vlen.file, s, &is_nil) < 0) + if ((*(src->shared->u.vlen.cls->isnull))(src->shared->u.vlen.file, s, &is_nil) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check if VL data is 'nil'") - else if(is_nil) { + else if (is_nil) { /* Write "nil" sequence to destination location */ - if((*(dst->shared->u.vlen.cls->setnull))(dst->shared->u.vlen.file, d, b) < 0) + if ((*(dst->shared->u.vlen.cls->setnull))(dst->shared->u.vlen.file, d, b) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'") } /* end else-if */ else { - size_t seq_len; /* The number of elements in the current sequence */ + size_t seq_len; /* The number of elements in the current sequence */ /* Get length of element sequences */ - if((*(src->shared->u.vlen.cls->getlen))(src->shared->u.vlen.file, s, &seq_len) < 0) + if ((*(src->shared->u.vlen.cls->getlen))(src->shared->u.vlen.file, s, &seq_len) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length") - /* If we are reading from memory and there is no conversion, just get the pointer to sequence */ - if(write_to_file && noop_conv) { + /* If we are reading from memory and there is no conversion, just get the pointer to + * sequence */ + if (write_to_file && noop_conv) { /* Get direct pointer to sequence */ - if(NULL == (conv_buf = (*(src->shared->u.vlen.cls->getptr))(s))) + if (NULL == (conv_buf = (*(src->shared->u.vlen.cls->getptr))(s))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer") } /* end if */ else { - size_t src_size, dst_size; /*source & destination total size in bytes*/ + size_t src_size, dst_size; /*source & destination total size in bytes*/ src_size = seq_len * src_base_size; dst_size = seq_len * dst_base_size; @@ -3228,91 +3324,106 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Check if conversion buffer is large enough, resize if * necessary. If the SEQ_LEN is 0, allocate a minimal size buffer. */ - if(!seq_len && !conv_buf) { + if (!seq_len && !conv_buf) { conv_buf_size = H5T_VLEN_MIN_CONF_BUF_SIZE; - if(NULL == (conv_buf = H5FL_BLK_CALLOC(vlen_seq, conv_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") - } /* end if */ - else if(conv_buf_size < MAX(src_size, dst_size)) { + if (NULL == (conv_buf = H5FL_BLK_CALLOC(vlen_seq, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") + } /* end if */ + else if (conv_buf_size < MAX(src_size, dst_size)) { /* Only allocate conversion buffer in H5T_VLEN_MIN_CONF_BUF_SIZE increments */ - conv_buf_size = ((MAX(src_size, dst_size) / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * H5T_VLEN_MIN_CONF_BUF_SIZE; - if(NULL == (conv_buf = H5FL_BLK_REALLOC(vlen_seq, conv_buf, conv_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + conv_buf_size = ((MAX(src_size, dst_size) / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * + H5T_VLEN_MIN_CONF_BUF_SIZE; + if (NULL == (conv_buf = H5FL_BLK_REALLOC(vlen_seq, conv_buf, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") HDmemset(conv_buf, 0, conv_buf_size); } /* end else-if */ /* Read in VL sequence */ - if((*(src->shared->u.vlen.cls->read))(src->shared->u.vlen.file, s, conv_buf, src_size) < 0) + if ((*(src->shared->u.vlen.cls->read))(src->shared->u.vlen.file, s, conv_buf, + src_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") } /* end else */ - if(!noop_conv) { + if (!noop_conv) { /* Check if temporary buffer is large enough, resize if necessary */ /* (Chain off the conversion buffer size) */ - if(tmp_buf && tmp_buf_size < conv_buf_size) { + if (tmp_buf && tmp_buf_size < conv_buf_size) { /* Set up initial background buffer */ tmp_buf_size = conv_buf_size; - if(NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + if (NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") HDmemset(tmp_buf, 0, tmp_buf_size); } /* end if */ /* If we are writing and there is a nested VL type, read * the sequence into the background buffer */ - if(nested) { + if (nested) { /* Sanity check */ HDassert(write_to_file); /* Get length of background element sequence */ - if((*(dst->shared->u.vlen.cls->getlen))(dst->shared->u.vlen.file, b, &bg_seq_len) < 0) + if ((*(dst->shared->u.vlen.cls->getlen))(dst->shared->u.vlen.file, b, + &bg_seq_len) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length") /* Read sequence if length > 0 */ - if(bg_seq_len > 0) { - if(tmp_buf_size < (bg_seq_len * MAX(src_base_size, dst_base_size))) { + if (bg_seq_len > 0) { + if (tmp_buf_size < (bg_seq_len * MAX(src_base_size, dst_base_size))) { tmp_buf_size = (bg_seq_len * MAX(src_base_size, dst_base_size)); - if(NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + if (NULL == + (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") HDmemset(tmp_buf, 0, tmp_buf_size); } /* end if */ /* Read in background VL sequence */ - if((*(dst->shared->u.vlen.cls->read))(dst->shared->u.vlen.file, b, tmp_buf, bg_seq_len * dst_base_size) < 0) + if ((*(dst->shared->u.vlen.cls->read))(dst->shared->u.vlen.file, b, + tmp_buf, + bg_seq_len * dst_base_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") } /* end if */ /* If the sequence gets shorter, pad out the original sequence with zeros */ - if(bg_seq_len < seq_len) - HDmemset((uint8_t *)tmp_buf + dst_base_size * bg_seq_len, 0, (seq_len - bg_seq_len) * dst_base_size); + if (bg_seq_len < seq_len) + HDmemset((uint8_t *)tmp_buf + dst_base_size * bg_seq_len, 0, + (seq_len - bg_seq_len) * dst_base_size); } /* end if */ /* Convert VL sequence */ - if(H5T_convert(tpath, tsrc_id, tdst_id, seq_len, (size_t)0, (size_t)0, conv_buf, tmp_buf) < 0) + if (H5T_convert(tpath, tsrc_id, tdst_id, seq_len, (size_t)0, (size_t)0, conv_buf, + tmp_buf) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ /* Write sequence to destination location */ - if((*(dst->shared->u.vlen.cls->write))(dst->shared->u.vlen.file, &vl_alloc_info, d, conv_buf, b, seq_len, dst_base_size) < 0) + if ((*(dst->shared->u.vlen.cls->write))(dst->shared->u.vlen.file, &vl_alloc_info, d, + conv_buf, b, seq_len, dst_base_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data") - if(!noop_conv) { - /* For nested VL case, free leftover heap objects from the deeper level if the length of new data elements is shorter than the old data elements.*/ - if(nested && seq_len < bg_seq_len) { + if (!noop_conv) { + /* For nested VL case, free leftover heap objects from the deeper level if the + * length of new data elements is shorter than the old data elements.*/ + if (nested && seq_len < bg_seq_len) { const uint8_t *tmp; - size_t u; + size_t u; /* Sanity check */ HDassert(write_to_file); tmp = (uint8_t *)tmp_buf + seq_len * dst_base_size; - for(u = seq_len; u < bg_seq_len; u++, tmp += dst_base_size) { + for (u = seq_len; u < bg_seq_len; u++, tmp += dst_base_size) { /* Delete sequence in destination location */ - if((*(dst->shared->u.vlen.cls->del))(dst->shared->u.vlen.file, tmp) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove heap object") + if ((*(dst->shared->u.vlen.cls->del))(dst->shared->u.vlen.file, tmp) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, + "unable to remove heap object") } /* end for */ - } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end if */ + } /* end else */ /* Advance pointers */ s += s_stride; @@ -3325,31 +3436,30 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end while */ /* Release the temporary datatype IDs used */ - if(tsrc_id >= 0) + if (tsrc_id >= 0) H5I_dec_ref(tsrc_id); - if(tdst_id >= 0) + if (tdst_id >= 0) H5I_dec_ref(tdst_id); break; - default: /* Some other command we don't know about yet.*/ + default: /* Some other command we don't know about yet.*/ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") - } /* end switch */ + } /* end switch */ done: /* If the conversion buffer doesn't need to be freed, reset its pointer */ - if(write_to_file && noop_conv) + if (write_to_file && noop_conv) conv_buf = NULL; /* Release the conversion buffer (always allocated, except on errors) */ - if(conv_buf) + if (conv_buf) conv_buf = H5FL_BLK_FREE(vlen_seq, conv_buf); /* Release the background buffer, if we have one */ - if(tmp_buf) + if (tmp_buf) tmp_buf = H5FL_BLK_FREE(vlen_seq, tmp_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_vlen() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_array * @@ -3364,20 +3474,20 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, void *_buf, void H5_ATTR_UNUSED *_bkg) +H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *_buf, void H5_ATTR_UNUSED *_bkg) { - H5T_path_t *tpath; /* Type conversion path */ - hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */ - H5T_t *src = NULL; /*source datatype */ - H5T_t *dst = NULL; /*destination datatype */ - uint8_t *sp, *dp; /*source and dest traversal ptrs */ - ssize_t src_delta, dst_delta; /*source & destination stride */ - int direction; /*direction of traversal */ - size_t elmtno; /*element number counter */ - unsigned u; /* local index variable */ - void *bkg_buf = NULL; /*temporary background buffer */ - herr_t ret_value=SUCCEED; /* Return value */ + H5T_path_t *tpath; /* Type conversion path */ + hid_t tsrc_id = -1, tdst_id = -1; /*temporary type atoms */ + H5T_t * src = NULL; /*source datatype */ + H5T_t * dst = NULL; /*destination datatype */ + uint8_t * sp, *dp; /*source and dest traversal ptrs */ + ssize_t src_delta, dst_delta; /*source & destination stride */ + int direction; /*direction of traversal */ + size_t elmtno; /*element number counter */ + unsigned u; /* local index variable */ + void * bkg_buf = NULL; /*temporary background buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3390,17 +3500,19 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - HDassert(H5T_ARRAY==src->shared->type); - HDassert(H5T_ARRAY==dst->shared->type); + HDassert(H5T_ARRAY == src->shared->type); + HDassert(H5T_ARRAY == dst->shared->type); /* Check the number and sizes of the dimensions */ - if(src->shared->u.array.ndims != dst->shared->u.array.ndims) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions") - for(u = 0; u < src->shared->u.array.ndims; u++) - if(src->shared->u.array.dim[u] != dst->shared->u.array.dim[u]) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions") + if (src->shared->u.array.ndims != dst->shared->u.array.ndims) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "array datatypes do not have the same number of dimensions") + for (u = 0; u < src->shared->u.array.ndims; u++) + if (src->shared->u.array.dim[u] != dst->shared->u.array.dim[u]) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "array datatypes do not have the same sizes of dimensions") /* Array datatypes don't need a background buffer */ cdata->need_bkg = H5T_BKG_NO; @@ -3423,14 +3535,13 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * versa? Also, how many of the elements have the source and * destination areas overlapping? */ - if(src->shared->size >= dst->shared->size || buf_stride > 0) { - sp = dp = (uint8_t*)_buf; + if (src->shared->size >= dst->shared->size || buf_stride > 0) { + sp = dp = (uint8_t *)_buf; direction = 1; - } else { - sp = (uint8_t*)_buf + (nelmts - 1) * - (buf_stride ? buf_stride : src->shared->size); - dp = (uint8_t*)_buf + (nelmts - 1) * - (buf_stride ? buf_stride : dst->shared->size); + } + else { + sp = (uint8_t *)_buf + (nelmts - 1) * (buf_stride ? buf_stride : src->shared->size); + dp = (uint8_t *)_buf + (nelmts - 1) * (buf_stride ? buf_stride : dst->shared->size); direction = -1; } @@ -3444,31 +3555,38 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); /* Set up conversion path for base elements */ - if(NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) { - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes") - } else if (!H5T_path_noop(tpath)) { - if((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL), FALSE)) < 0 || - (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") + if (NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) { + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest datatypes") + } + else if (!H5T_path_noop(tpath)) { + if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL), + FALSE)) < 0 || + (tdst_id = + H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, + "unable to register types for conversion") } /* Check if we need a background buffer for this conversion */ - if(tpath->cdata.need_bkg) { - size_t bkg_buf_size; /*size of background buffer in bytes */ + if (tpath->cdata.need_bkg) { + size_t bkg_buf_size; /*size of background buffer in bytes */ /* Allocate background buffer */ bkg_buf_size = src->shared->u.array.nelem * MAX(src->shared->size, dst->shared->size); - if(NULL == (bkg_buf = H5FL_BLK_CALLOC(array_seq, bkg_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + if (NULL == (bkg_buf = H5FL_BLK_CALLOC(array_seq, bkg_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") } /* end if */ /* Perform the actual conversion */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* Copy the source array into the correct location for the destination */ HDmemmove(dp, sp, src->shared->size); /* Convert array */ - if(H5T_convert(tpath, tsrc_id, tdst_id, src->shared->u.array.nelem, (size_t)0, bkg_stride, dp, bkg_buf) < 0) + if (H5T_convert(tpath, tsrc_id, tdst_id, src->shared->u.array.nelem, (size_t)0, bkg_stride, + dp, bkg_buf) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Advance the source & destination pointers */ @@ -3477,19 +3595,19 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end for */ /* Release the temporary datatype IDs used */ - if(tsrc_id >= 0) + if (tsrc_id >= 0) H5I_dec_ref(tsrc_id); - if(tdst_id >= 0) + if (tdst_id >= 0) H5I_dec_ref(tdst_id); break; - default: /* Some other command we don't know about yet.*/ + default: /* Some other command we don't know about yet.*/ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") } /* end switch */ done: /* Release the background buffer, if we have one */ - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(array_seq, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) @@ -3506,25 +3624,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) { - H5T_t *src = NULL; /* source datatype */ - H5T_t *dst = NULL; /* destination datatype */ - uint8_t *s = NULL; /* source buffer */ - uint8_t *d = NULL; /* destination buffer */ - uint8_t *b = NULL; /* background buffer */ - ssize_t s_stride, d_stride; /* src and dst strides */ - ssize_t b_stride; /* bkg stride */ - size_t safe; /* how many elements are safe to process in each pass */ - void *conv_buf = NULL; /* temporary conversion buffer */ - size_t conv_buf_size = 0; /* size of conversion buffer in bytes */ - size_t elmtno; /* element number counter */ - herr_t ret_value = SUCCEED; /* return value */ + H5T_t * src = NULL; /* source datatype */ + H5T_t * dst = NULL; /* destination datatype */ + uint8_t *s = NULL; /* source buffer */ + uint8_t *d = NULL; /* destination buffer */ + uint8_t *b = NULL; /* background buffer */ + ssize_t s_stride, d_stride; /* src and dst strides */ + ssize_t b_stride; /* bkg stride */ + size_t safe; /* how many elements are safe to process in each pass */ + void * conv_buf = NULL; /* temporary conversion buffer */ + size_t conv_buf_size = 0; /* size of conversion buffer in bytes */ + size_t elmtno; /* element number counter */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -3533,14 +3651,14 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_REFERENCE != src->shared->type) + if (H5T_REFERENCE != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype") - if(H5T_REFERENCE != dst->shared->type) + if (H5T_REFERENCE != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype") /* Only allow for source reference that is not an opaque type, destination must be opaque */ - if(!dst->shared->u.atomic.u.r.opaque) + if (!dst->shared->u.atomic.u.r.opaque) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not an H5T_STD_REF datatype") /* Reference types don't need a background buffer */ @@ -3550,18 +3668,17 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_FREE: break; - case H5T_CONV_CONV: - { + case H5T_CONV_CONV: { /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") HDassert(src->shared->u.atomic.u.r.cls); /* Initialize source & destination strides */ - if(buf_stride) { + if (buf_stride) { HDassert(buf_stride >= src->shared->size); HDassert(buf_stride >= dst->shared->size); H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); @@ -3573,8 +3690,8 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, s_stride = (ssize_t)src->shared->size; d_stride = (ssize_t)dst->shared->size; } /* end else */ - if(bkg) { - if(bkg_stride) + if (bkg) { + if (bkg_stride) b_stride = (ssize_t)bkg_stride; else b_stride = d_stride; @@ -3584,9 +3701,9 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* The outer loop of the type conversion macro, controlling which */ /* direction the buffer is walked */ - while(nelmts > 0) { + while (nelmts > 0) { /* Check if we need to go backwards through the buffer */ - if(d_stride > s_stride) { + if (d_stride > s_stride) { /* Sanity check */ HDassert(s_stride > 0); HDassert(d_stride > 0); @@ -3595,14 +3712,15 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Compute the number of "safe" destination elements at */ /* the end of the buffer (Those which don't overlap with */ /* any source elements at the beginning of the buffer) */ - safe = nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); + safe = + nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); /* If we're down to the last few elements, just wrap up */ /* with a "real" reverse copy */ - if(safe < 2) { - s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; - d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; - b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; + if (safe < 2) { + s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; s_stride = -s_stride; d_stride = -d_stride; b_stride = -b_stride; @@ -3614,63 +3732,68 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride; b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride; } /* end else */ - } /* end if */ + } /* end if */ else { /* Single forward pass over all data */ s = d = (uint8_t *)buf; - b = (uint8_t *)bkg; - safe = nelmts; + b = (uint8_t *)bkg; + safe = nelmts; } /* end else */ - for(elmtno = 0; elmtno < safe; elmtno++) { - size_t buf_size; + for (elmtno = 0; elmtno < safe; elmtno++) { + size_t buf_size; hbool_t dst_copy = FALSE; - hbool_t is_nil; /* Whether reference is "nil" */ + hbool_t is_nil; /* Whether reference is "nil" */ /* Check for "nil" source reference */ - if((*(src->shared->u.atomic.u.r.cls->isnull))(src->shared->u.atomic.u.r.file, s, &is_nil) < 0) + if ((*(src->shared->u.atomic.u.r.cls->isnull))(src->shared->u.atomic.u.r.file, s, + &is_nil) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check if reference data is 'nil'") - if(is_nil) { + if (is_nil) { /* Write "nil" reference to destination location */ - if((*(dst->shared->u.atomic.u.r.cls->setnull))(dst->shared->u.atomic.u.r.file, d, b) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set reference data to 'nil'") + if ((*(dst->shared->u.atomic.u.r.cls->setnull))(dst->shared->u.atomic.u.r.file, d, + b) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, + "can't set reference data to 'nil'") } /* end else-if */ else { /* Get size of references */ - if(0 == (buf_size = src->shared->u.atomic.u.r.cls->getsize( - src->shared->u.atomic.u.r.file, s, src->shared->size, - dst->shared->u.atomic.u.r.file, &dst_copy))) + if (0 == (buf_size = src->shared->u.atomic.u.r.cls->getsize( + src->shared->u.atomic.u.r.file, s, src->shared->size, + dst->shared->u.atomic.u.r.file, &dst_copy))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect size") /* Check if conversion buffer is large enough, resize if necessary. */ - if(conv_buf_size < buf_size) { + if (conv_buf_size < buf_size) { conv_buf_size = buf_size; - if(NULL == (conv_buf = H5FL_BLK_REALLOC(ref_seq, conv_buf, conv_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + if (NULL == (conv_buf = H5FL_BLK_REALLOC(ref_seq, conv_buf, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") HDmemset(conv_buf, 0, conv_buf_size); } /* end if */ - if(dst_copy && (src->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) + if (dst_copy && (src->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) H5MM_memcpy(conv_buf, s, buf_size); else { /* Read reference */ - if(src->shared->u.atomic.u.r.cls->read( + if (src->shared->u.atomic.u.r.cls->read( src->shared->u.atomic.u.r.file, s, src->shared->size, dst->shared->u.atomic.u.r.file, conv_buf, buf_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read reference data") } /* end else */ - if(dst_copy && (dst->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) + if (dst_copy && (dst->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) H5MM_memcpy(d, conv_buf, buf_size); else { /* Write reference to destination location */ - if(dst->shared->u.atomic.u.r.cls->write( - src->shared->u.atomic.u.r.file, conv_buf, buf_size, src->shared->u.atomic.u.r.rtype, - dst->shared->u.atomic.u.r.file, d, dst->shared->size, b) < 0) + if (dst->shared->u.atomic.u.r.cls->write( + src->shared->u.atomic.u.r.file, conv_buf, buf_size, + src->shared->u.atomic.u.r.rtype, dst->shared->u.atomic.u.r.file, d, + dst->shared->size, b) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write reference data") } /* end else */ - } /* end else */ + } /* end else */ /* Advance pointers */ s += s_stride; @@ -3681,22 +3804,21 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Decrement number of elements left to convert */ nelmts -= safe; } /* end while */ - } /* end case */ - break; + } /* end case */ + break; - default: /* Some other command we don't know about yet.*/ + default: /* Some other command we don't know about yet.*/ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") - } /* end switch */ + } /* end switch */ done: /* Release the conversion buffer (always allocated, except on errors) */ - if(conv_buf) + if (conv_buf) conv_buf = H5FL_BLK_FREE(ref_seq, conv_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_ref() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_i_i * @@ -3712,38 +3834,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { - H5T_t *src = NULL; /*source datatype */ - H5T_t *dst = NULL; /*destination datatype */ - ssize_t src_delta, dst_delta; /*source & destination stride */ - int direction; /*direction of traversal */ - size_t elmtno; /*element number */ - size_t half_size; /*half the type size */ - size_t olap; /*num overlapping elements */ - uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t *src_rev=NULL; /*order-reversed source buffer */ - uint8_t dbuf[64]; /*temp destination buffer */ - size_t first; - ssize_t sfirst; /*a signed version of `first' */ - size_t i; /*Local index variables */ - H5T_conv_cb_t cb_struct={NULL, NULL}; /*conversion callback structure */ - H5T_conv_ret_t except_ret; /*return of callback function */ - hbool_t reverse; /*if reverse the order of destination */ - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t * src = NULL; /*source datatype */ + H5T_t * dst = NULL; /*destination datatype */ + ssize_t src_delta, dst_delta; /*source & destination stride */ + int direction; /*direction of traversal */ + size_t elmtno; /*element number */ + size_t half_size; /*half the type size */ + size_t olap; /*num overlapping elements */ + uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t dbuf[64]; /*temp destination buffer */ + size_t first; + ssize_t sfirst; /*a signed version of `first' */ + size_t i; /*Local index variables */ + H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ + H5T_conv_ret_t except_ret; /*return of callback function */ + hbool_t reverse; /*if reverse the order of destination */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) + if (H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(H5T_ORDER_LE != dst->shared->u.atomic.order && H5T_ORDER_BE != dst->shared->u.atomic.order) + if (H5T_ORDER_LE != dst->shared->u.atomic.order && H5T_ORDER_BE != dst->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(dst->shared->size > sizeof dbuf) + if (dst->shared->size > sizeof dbuf) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -3753,7 +3875,7 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -3761,23 +3883,25 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src->shared->size==dst->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src->shared->size == dst->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; - } else if (src->shared->size>=dst->shared->size) { - double olap_d = HDceil((double)(dst->shared->size)/ - (double)(src->shared->size-dst->shared->size)); + olap = nelmts; + } + else if (src->shared->size >= dst->shared->size) { + double olap_d = + HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size)); olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olap_d = HDceil((double)(src->shared->size)/ - (double)(dst->shared->size-src->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts - 1) * src->shared->size; - dp = (uint8_t*)buf + (nelmts - 1) * dst->shared->size; + } + else { + double olap_d = + HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size; direction = -1; } @@ -3791,32 +3915,36 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src->shared->size); + src_rev = (uint8_t *)H5MM_calloc(src->shared->size); /* The conversion loop */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if(direction > 0) { + if (direction > 0) { s = sp; d = elmtno < olap ? dbuf : dp; - } else { + } + else { s = sp; d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); - } else { - HDassert((dpshared->size<=sp) || (spshared->size<=dp)); + if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src->shared->size) || + (sp >= dp && sp < dp + dst->shared->size)); + } + else { + HDassert((dp < sp && dp + dst->shared->size <= sp) || + (sp < dp && sp + src->shared->size <= dp)); } #endif @@ -3825,12 +3953,12 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src->shared->u.atomic.order) { - half_size = src->shared->size/2; - for (i=0; ishared->size-(i+1)]; - s[src->shared->size-(i+1)] = s[i]; - s[i] = tmp; + if (H5T_ORDER_BE == src->shared->u.atomic.order) { + half_size = src->shared->size / 2; + for (i = 0; i < half_size; i++) { + uint8_t tmp = s[src->shared->size - (i + 1)]; + s[src->shared->size - (i + 1)] = s[i]; + s[i] = tmp; } } @@ -3838,23 +3966,23 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * What is the bit number for the msb bit of S which is set? The * bit number is relative to the significant part of the number. */ - sfirst = H5T__bit_find (s, src->shared->u.atomic.offset, src->shared->u.atomic.prec, + sfirst = H5T__bit_find(s, src->shared->u.atomic.offset, src->shared->u.atomic.prec, H5T_BIT_MSB, TRUE); - first = (size_t)sfirst; + first = (size_t)sfirst; /* Set these variables to default */ except_ret = H5T_CONV_UNHANDLED; reverse = TRUE; - if (sfirst<0) { + if (sfirst < 0) { /* * The source has no bits set and must therefore be zero. * Set the destination to zero. */ - H5T__bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); - - } else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign && - H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); + } + else if (H5T_SGN_NONE == src->shared->u.atomic.u.i.sign && + H5T_SGN_NONE == dst->shared->u.atomic.u.i.sign) { /* * Source and destination are both unsigned, but if the * source has more precision bits than the destination then @@ -3862,32 +3990,37 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * destination will be set to the maximum possible value. */ if (src->shared->u.atomic.prec <= dst->shared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, - dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); - } else if (first>=dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, FALSE); + } + else if (first >= dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T_reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - dst->shared->u.atomic.prec); } - - } else if (H5T_SGN_2==src->shared->u.atomic.u.i.sign && - H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) { + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + } + else if (H5T_SGN_2 == src->shared->u.atomic.u.i.sign && + H5T_SGN_NONE == dst->shared->u.atomic.u.i.sign) { /* * If the source is signed and the destination isn't then we * can have overflow if the source contains more bits than @@ -3895,79 +4028,95 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * possible value) or overflow if the source is negative * (destination is set to zero). */ - if (first+1 == src->shared->u.atomic.prec) { + if (first + 1 == src->shared->u.atomic.prec) { /*overflow - source is negative*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T_reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec-1); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec-1, - (dst->shared->u.atomic.prec-src->shared->u.atomic.prec)+1, FALSE); - } else if (first>=dst->shared->u.atomic.prec) { + } + else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec - 1); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec - 1, + (dst->shared->u.atomic.prec - src->shared->u.atomic.prec) + 1, FALSE); + } + else if (first >= dst->shared->u.atomic.prec) { /*overflow - source is positive*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T_reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) - H5T__bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - dst->shared->u.atomic.prec); } - - } else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign && - H5T_SGN_2==dst->shared->u.atomic.u.i.sign) { + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + } + else if (H5T_SGN_NONE == src->shared->u.atomic.u.i.sign && + H5T_SGN_2 == dst->shared->u.atomic.u.i.sign) { /* * If the source is not signed but the destination is then * overflow can occur in which case the destination is set to * the largest possible value (all bits set except the msb). */ - if (first+1 >= dst->shared->u.atomic.prec) { + if (first + 1 >= dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T_reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE); - H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), (size_t)1, FALSE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec - 1, + TRUE); + H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec - 1), + (size_t)1, FALSE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->shared->u.atomic.precshared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, - dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - dst->shared->u.atomic.prec); } - } else if (first+1 == src->shared->u.atomic.prec) { + else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, FALSE); + } + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + } + else if (first + 1 == src->shared->u.atomic.prec) { /* * Both the source and the destination are signed and the * source value is negative. We could experience overflow @@ -3975,91 +4124,112 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * destination is set to a negative number with the largest * possible magnitude. */ - ssize_t sfz = H5T__bit_find (s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec-1, H5T_BIT_MSB, FALSE); - size_t fz = (size_t)sfz; + ssize_t sfz = H5T__bit_find(s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec - 1, H5T_BIT_MSB, FALSE); + size_t fz = (size_t)sfz; - if (sfz>=0 && fz+1>=dst->shared->u.atomic.prec) { + if (sfz >= 0 && fz + 1 >= dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T_reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, FALSE); - H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec - 1, + FALSE); + H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec - 1), + (size_t)1, TRUE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->shared->u.atomic.precshared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, TRUE); - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } - - } else { + else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, TRUE); + } + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + } + else { /* * Source and destination are both signed but the source * value is positive. We could have an overflow in which * case the destination is set to the largest possible * positive value. */ - if (first+1>=dst->shared->u.atomic.prec) { + if (first + 1 >= dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, - cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T_reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE); - H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), (size_t)1, FALSE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec - 1, + TRUE); + H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec - 1), + (size_t)1, FALSE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->shared->u.atomic.precshared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, - dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - dst->shared->u.atomic.prec); + } + else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, FALSE); + } + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); } } /* * Set padding areas in destination. */ - if (dst->shared->u.atomic.offset>0) { - HDassert(H5T_PAD_ZERO==dst->shared->u.atomic.lsb_pad || H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad); - H5T__bit_set(d, (size_t)0, dst->shared->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad)); + if (dst->shared->u.atomic.offset > 0) { + HDassert(H5T_PAD_ZERO == dst->shared->u.atomic.lsb_pad || + H5T_PAD_ONE == dst->shared->u.atomic.lsb_pad); + H5T__bit_set(d, (size_t)0, dst->shared->u.atomic.offset, + (hbool_t)(H5T_PAD_ONE == dst->shared->u.atomic.lsb_pad)); } - if (dst->shared->u.atomic.offset+dst->shared->u.atomic.prec!=8*dst->shared->size) { - HDassert(H5T_PAD_ZERO==dst->shared->u.atomic.msb_pad || H5T_PAD_ONE==dst->shared->u.atomic.msb_pad); - H5T__bit_set (d, dst->shared->u.atomic.offset+dst->shared->u.atomic.prec, - 8*dst->shared->size - (dst->shared->u.atomic.offset+ dst->shared->u.atomic.prec), - (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.msb_pad)); + if (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec != 8 * dst->shared->size) { + HDassert(H5T_PAD_ZERO == dst->shared->u.atomic.msb_pad || + H5T_PAD_ONE == dst->shared->u.atomic.msb_pad); + H5T__bit_set(d, dst->shared->u.atomic.offset + dst->shared->u.atomic.prec, + 8 * dst->shared->size - + (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec), + (hbool_t)(H5T_PAD_ONE == dst->shared->u.atomic.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst->shared->u.atomic.order && reverse) { - half_size = dst->shared->size/2; - for (i=0; ishared->size-(i+1)]; - d[dst->shared->size-(i+1)] = d[i]; - d[i] = tmp; + if (H5T_ORDER_BE == dst->shared->u.atomic.order && reverse) { + half_size = dst->shared->size / 2; + for (i = 0; i < half_size; i++) { + uint8_t tmp = d[dst->shared->size - (i + 1)]; + d[dst->shared->size - (i + 1)] = d[i]; + d[i] = tmp; } } @@ -4067,7 +4237,7 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if(d==dbuf) + if (d == dbuf) H5MM_memcpy(dp, d, dst->shared->size); /* Advance source & destination pointers by delta amounts */ @@ -4082,12 +4252,11 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_i_i() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_f_f * @@ -4103,57 +4272,58 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { /* Traversal-related variables */ - H5T_t *src_p; /*source datatype */ - H5T_t *dst_p; /*destination datatype */ - H5T_atomic_t src; /*atomic source info */ - H5T_atomic_t dst; /*atomic destination info */ - ssize_t src_delta, dst_delta; /*source & destination stride */ - int direction; /*forward or backward traversal */ - size_t elmtno; /*element number */ - size_t half_size; /*half the type size */ - size_t tsize; /*type size for swapping bytes */ - size_t olap; /*num overlapping elements */ - ssize_t bitno = 0; /*bit number */ - uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t *src_rev = NULL; /*order-reversed source buffer */ - uint8_t dbuf[64]; /*temp destination buffer */ - uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ + H5T_t * src_p; /*source datatype */ + H5T_t * dst_p; /*destination datatype */ + H5T_atomic_t src; /*atomic source info */ + H5T_atomic_t dst; /*atomic destination info */ + ssize_t src_delta, dst_delta; /*source & destination stride */ + int direction; /*forward or backward traversal */ + size_t elmtno; /*element number */ + size_t half_size; /*half the type size */ + size_t tsize; /*type size for swapping bytes */ + size_t olap; /*num overlapping elements */ + ssize_t bitno = 0; /*bit number */ + uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t dbuf[64]; /*temp destination buffer */ + uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ - int64_t expo; /*exponent */ - hssize_t expo_max; /*maximum possible dst exponent */ - size_t msize = 0; /*useful size of mantissa in src*/ - size_t mpos; /*offset to useful mant is src */ - uint64_t sign; /*source sign bit value */ - size_t mrsh; /*amount to right shift mantissa*/ - hbool_t carry = FALSE; /*carry after rounding mantissa */ - size_t i; /*miscellaneous counters */ - size_t implied; /*destination implied bits */ - hbool_t denormalized = FALSE; /*is either source or destination denormalized?*/ - H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ - H5T_conv_ret_t except_ret; /*return of callback function */ - hbool_t reverse; /*if reverse the order of destination */ - herr_t ret_value = SUCCEED; /*return value */ + int64_t expo; /*exponent */ + hssize_t expo_max; /*maximum possible dst exponent */ + size_t msize = 0; /*useful size of mantissa in src*/ + size_t mpos; /*offset to useful mant is src */ + uint64_t sign; /*source sign bit value */ + size_t mrsh; /*amount to right shift mantissa*/ + hbool_t carry = FALSE; /*carry after rounding mantissa */ + size_t i; /*miscellaneous counters */ + size_t implied; /*destination implied bits */ + hbool_t denormalized = FALSE; /*is either source or destination denormalized?*/ + H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ + H5T_conv_ret_t except_ret; /*return of callback function */ + hbool_t reverse; /*if reverse the order of destination */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if(H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) + if (H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) + if (H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(dst_p->shared->size > sizeof(dbuf)) + if (dst_p->shared->size > sizeof(dbuf)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") - if(8 * sizeof(expo) - 1 < src.u.f.esize || 8 * sizeof(expo) - 1 < dst.u.f.esize) + if (8 * sizeof(expo) - 1 < src.u.f.esize || 8 * sizeof(expo) - 1 < dst.u.f.esize) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -4163,10 +4333,11 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - src = src_p->shared->u.atomic; - dst = dst_p->shared->u.atomic; + src = src_p->shared->u.atomic; + dst = dst_p->shared->u.atomic; expo_max = ((hssize_t)1 << dst.u.f.esize) - 1; /* @@ -4174,25 +4345,25 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src_p->shared->size==dst_p->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src_p->shared->size == dst_p->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; + olap = nelmts; } - else if (src_p->shared->size>=dst_p->shared->size) { - double olap_d = HDceil((double)(dst_p->shared->size)/ - (double)(src_p->shared->size-dst_p->shared->size)); - olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + else if (src_p->shared->size >= dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size) / + (double)(src_p->shared->size - dst_p->shared->size)); + olap = (size_t)olap_d; + sp = dp = (uint8_t *)buf; direction = 1; } else { - double olap_d = HDceil((double)(src_p->shared->size)/ - (double)(dst_p->shared->size-src_p->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; - direction = -1; + double olap_d = HDceil((double)(src_p->shared->size) / + (double)(dst_p->shared->size - src_p->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst_p->shared->size; + direction = -1; } /* @@ -4205,14 +4376,14 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst_p->shared->size); /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); + src_rev = (uint8_t *)H5MM_calloc(src_p->shared->size); /* The conversion loop */ - for (elmtno=0; elmtno0) { + if (direction > 0) { s = sp; - d = elmtno= nelmts ? dbuf : dp; + d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || - (sp>=dp && spshared->size)); + if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src_p->shared->size) || + (sp >= dp && sp < dp + dst_p->shared->size)); } else { - HDassert((dpshared->size<=sp) || - (spshared->size<=dp)); + HDassert((dp < sp && dp + dst_p->shared->size <= sp) || + (sp < dp && sp + src_p->shared->size <= dp)); } #endif @@ -4246,27 +4417,27 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src.order) { - half_size = src_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp1; + if (H5T_ORDER_BE == src.order) { + half_size = src_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + tmp1 = s[src_p->shared->size - (i + 1)]; + s[src_p->shared->size - (i + 1)] = s[i]; + s[i] = tmp1; } } - else if (H5T_ORDER_VAX==src.order) { + else if (H5T_ORDER_VAX == src.order) { tsize = src_p->shared->size; HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = s[i]; - tmp2 = s[i+1]; + tmp2 = s[i + 1]; - s[i] = s[(tsize-2)-i]; - s[i+1] = s[(tsize-1)-i]; + s[i] = s[(tsize - 2) - i]; + s[i + 1] = s[(tsize - 1) - i]; - s[(tsize-2)-i] = tmp1; - s[(tsize-1)-i] = tmp2; + s[(tsize - 2) - i] = tmp1; + s[(tsize - 1) - i] = tmp2; } } @@ -4278,117 +4449,114 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Check for special cases: +0, -0, +Inf, -Inf, NaN */ - if (H5T__bit_find (s, src.u.f.mpos, src.u.f.msize, - H5T_BIT_LSB, TRUE)<0) { - if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, TRUE)<0) { + if (H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_LSB, TRUE) < 0) { + if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, TRUE) < 0) { /* +0 or -0 */ - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); - H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, FALSE); - H5T__bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_set(d, dst.u.f.epos, dst.u.f.esize, FALSE); + H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); goto padding; } - else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + else if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /* +Inf or -Inf */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - if(sign) - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + if (sign) + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, src_id, dst_id, src_rev, + d, cb_struct.user_data); else - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); - H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); - H5T__bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_set(d, dst.u.f.epos, dst.u.f.esize, TRUE); + H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); /*If the destination no implied mantissa bit, we'll need to set *the 1st bit of mantissa to 1. The Intel-Linux long double is *this case.*/ - if (H5T_NORM_NONE==dst.u.f.norm) - H5T__bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, (size_t)1, TRUE); + if (H5T_NORM_NONE == dst.u.f.norm) + H5T__bit_set(d, dst.u.f.mpos + dst.u.f.msize - 1, (size_t)1, TRUE); } - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") goto padding; } } - else if (H5T_NORM_NONE==src.u.f.norm && H5T__bit_find (s, src.u.f.mpos, src.u.f.msize-1, - H5T_BIT_LSB, TRUE)<0 && H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + else if (H5T_NORM_NONE == src.u.f.norm && + H5T__bit_find(s, src.u.f.mpos, src.u.f.msize - 1, H5T_BIT_LSB, TRUE) < 0 && + H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /*This is a special case for the source of no implied mantissa bit. *If the exponent bits are all 1s and only the 1st bit of mantissa *is set to 1. It's infinity. The Intel-Linux "long double" is this case.*/ /* +Inf or -Inf */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - if(sign) - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + if (sign) + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, src_id, dst_id, src_rev, d, + cb_struct.user_data); else - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); - H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); - H5T__bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_set(d, dst.u.f.epos, dst.u.f.esize, TRUE); + H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); /*If the destination no implied mantissa bit, we'll need to set *the 1st bit of mantissa to 1. The Intel-Linux long double is *this case.*/ - if (H5T_NORM_NONE==dst.u.f.norm) - H5T__bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, (size_t)1, TRUE); + if (H5T_NORM_NONE == dst.u.f.norm) + H5T__bit_set(d, dst.u.f.mpos + dst.u.f.msize - 1, (size_t)1, TRUE); } - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - else if(except_ret == H5T_CONV_ABORT) + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; - /* Temporary solution to handle VAX special values. - * Note that even though we don't support VAX anymore, we - * still need to handle legacy VAX files so this code must - * remain in place. - */ + /* Temporary solution to handle VAX special values. + * Note that even though we don't support VAX anymore, we + * still need to handle legacy VAX files so this code must + * remain in place. + */ } - else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + else if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /* NaN */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NAN, - src_id, dst_id, src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NAN, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { /* There are many NaN values, so we just set all bits of * the significand. */ - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); - H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_set(d, dst.u.f.epos, dst.u.f.esize, TRUE); H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, TRUE); } - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - else if(except_ret == H5T_CONV_ABORT) + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; @@ -4401,58 +4569,60 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ expo = (int64_t)H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); - if (expo==0) - denormalized=TRUE; + if (expo == 0) + denormalized = TRUE; /* * Set markers for the source mantissa, excluding the leading `1' * (might be implied). */ implied = 1; - mpos = src.u.f.mpos; - mrsh = 0; + mpos = src.u.f.mpos; + mrsh = 0; if (0 == expo || H5T_NORM_NONE == src.u.f.norm) { if ((bitno = H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_MSB, TRUE)) > 0) { msize = (size_t)bitno; } - else if (0==bitno) { + else if (0 == bitno) { msize = 1; H5T__bit_set(s, src.u.f.mpos, (size_t)1, FALSE); } } - else if (H5T_NORM_IMPLIED==src.u.f.norm) { + else if (H5T_NORM_IMPLIED == src.u.f.norm) { msize = src.u.f.msize; } else { - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "normalization method not implemented yet") } /* * The sign for the destination is the same as the sign for the * source in all cases. */ - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); /* * Calculate the true source exponent by adjusting according to * the source exponent bias. */ - if (0==expo || H5T_NORM_NONE==src.u.f.norm) { - HDassert(bitno>=0); + if (0 == expo || H5T_NORM_NONE == src.u.f.norm) { + HDassert(bitno >= 0); expo -= (int64_t)((src.u.f.ebias - 1) + (src.u.f.msize - (size_t)bitno)); } - else if (H5T_NORM_IMPLIED==src.u.f.norm) { + else if (H5T_NORM_IMPLIED == src.u.f.norm) { expo -= (int64_t)src.u.f.ebias; } else { - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "normalization method not implemented yet") } /* * If the destination is not normalized then right shift the * mantissa by one. */ - if (H5T_NORM_NONE==dst.u.f.norm) + if (H5T_NORM_NONE == dst.u.f.norm) mrsh++; /* @@ -4468,7 +4638,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; } - else if (expo<=0) { + else if (expo <= 0) { /* * The exponent is too small to fit in the exponent field, * but by shifting the mantissa to the right we can @@ -4476,10 +4646,10 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * longer normalized. */ mrsh += (size_t)(1 - expo); - expo = 0; - denormalized=TRUE; + expo = 0; + denormalized = TRUE; } - else if (expo>=expo_max) { + else if (expo >= expo_max) { /* * The exponent is too large to fit in the available region * or it results in the maximum possible value. Use positive @@ -4488,21 +4658,21 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * handler make sure the source buffer we hand it is in the * original byte order. */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { expo = expo_max; H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; } - else if(except_ret == H5T_CONV_ABORT) + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_HANDLED) { reverse = FALSE; goto next; } @@ -4515,20 +4685,22 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * overflow. That is, if `carry' is clear then the implied * mantissa bit is `1', else it is `10' binary. */ - if (msize>0 && mrsh<=dst.u.f.msize && mrsh+msize>dst.u.f.msize) { + if (msize > 0 && mrsh <= dst.u.f.msize && mrsh + msize > dst.u.f.msize) { bitno = (ssize_t)(mrsh + msize - dst.u.f.msize); HDassert(bitno >= 0 && (size_t)bitno <= msize); /* If the 1st bit being cut off is set and source isn't denormalized.*/ - if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && !denormalized) { + if (H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && !denormalized) { /* Don't do rounding if exponent is 111...110 and mantissa is 111...11. * To do rounding and increment exponent in this case will create an infinity value.*/ - if((H5T__bit_find(s, mpos + (size_t)bitno, msize - (size_t)bitno, H5T_BIT_LSB, FALSE) >= 0 || expo < expo_max - 1)) { + if ((H5T__bit_find(s, mpos + (size_t)bitno, msize - (size_t)bitno, H5T_BIT_LSB, + FALSE) >= 0 || + expo < expo_max - 1)) { carry = H5T__bit_inc(s, mpos + (size_t)bitno - 1, 1 + msize - (size_t)bitno); - if(carry) + if (carry) implied = 2; } } - else if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized) + else if (H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized) /* For either source or destination, denormalized value doesn't increment carry.*/ H5T__bit_inc(s, mpos + (size_t)bitno - 1, 1 + msize - (size_t)bitno); } @@ -4538,41 +4710,36 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Write the mantissa to the destination */ - if (mrsh>dst.u.f.msize+1) { + if (mrsh > dst.u.f.msize + 1) { H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); } - else if (mrsh==dst.u.f.msize+1) { - H5T__bit_set(d, dst.u.f.mpos+1, dst.u.f.msize-1, FALSE); + else if (mrsh == dst.u.f.msize + 1) { + H5T__bit_set(d, dst.u.f.mpos + 1, dst.u.f.msize - 1, FALSE); H5T__bit_set(d, dst.u.f.mpos, (size_t)1, TRUE); } - else if (mrsh==dst.u.f.msize) { + else if (mrsh == dst.u.f.msize) { H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); H5T__bit_set_d(d, dst.u.f.mpos, MIN(2, dst.u.f.msize), (hsize_t)implied); } else { - if (mrsh>0) { - H5T__bit_set(d, dst.u.f.mpos+dst.u.f.msize-mrsh, mrsh, - FALSE); - H5T__bit_set_d(d, dst.u.f.mpos+dst.u.f.msize-mrsh, (size_t)2, - (hsize_t)implied); + if (mrsh > 0) { + H5T__bit_set(d, dst.u.f.mpos + dst.u.f.msize - mrsh, mrsh, FALSE); + H5T__bit_set_d(d, dst.u.f.mpos + dst.u.f.msize - mrsh, (size_t)2, (hsize_t)implied); } - if (mrsh+msize>=dst.u.f.msize) { - H5T__bit_copy(d, dst.u.f.mpos, - s, (mpos+msize+mrsh-dst.u.f.msize), - dst.u.f.msize-mrsh); + if (mrsh + msize >= dst.u.f.msize) { + H5T__bit_copy(d, dst.u.f.mpos, s, (mpos + msize + mrsh - dst.u.f.msize), + dst.u.f.msize - mrsh); } else { - H5T__bit_copy(d, dst.u.f.mpos+dst.u.f.msize-(mrsh+msize), - s, mpos, msize); - H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize-(mrsh+msize), - FALSE); + H5T__bit_copy(d, dst.u.f.mpos + dst.u.f.msize - (mrsh + msize), s, mpos, msize); + H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize - (mrsh + msize), FALSE); } } /* Write the exponent */ if (carry) { expo++; - if (expo>=expo_max) { + if (expo >= expo_max) { /* * The exponent is too large to fit in the available * region or it results in the maximum possible value. @@ -4581,20 +4748,21 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * calling the overflow handler make sure the source * buffer we hand it is in the original byte order. */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { expo = expo_max; H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); } - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { reverse = FALSE; goto next; } @@ -4603,48 +4771,49 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /*reset CARRY*/ carry = FALSE; - H5_CHECK_OVERFLOW(expo,hssize_t,hsize_t); + H5_CHECK_OVERFLOW(expo, hssize_t, hsize_t); H5T__bit_set_d(d, dst.u.f.epos, dst.u.f.esize, (hsize_t)expo); - padding: +padding: /* * Set external padding areas */ - if (dst.offset>0) { - HDassert(H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); - H5T__bit_set (d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); + if (dst.offset > 0) { + HDassert(H5T_PAD_ZERO == dst.lsb_pad || H5T_PAD_ONE == dst.lsb_pad); + H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE == dst.lsb_pad)); } - if (dst.offset+dst.prec!=8*dst_p->shared->size) { - HDassert(H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); - H5T__bit_set (d, dst.offset+dst.prec, 8*dst_p->shared->size - (dst.offset+dst.prec), - (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); + if (dst.offset + dst.prec != 8 * dst_p->shared->size) { + HDassert(H5T_PAD_ZERO == dst.msb_pad || H5T_PAD_ONE == dst.msb_pad); + H5T__bit_set(d, dst.offset + dst.prec, 8 * dst_p->shared->size - (dst.offset + dst.prec), + (hbool_t)(H5T_PAD_ONE == dst.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - d[dst_p->shared->size-(i+1)] = d[i]; - d[i] = tmp; + if (H5T_ORDER_BE == dst.order && reverse) { + half_size = dst_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + uint8_t tmp = d[dst_p->shared->size - (i + 1)]; + d[dst_p->shared->size - (i + 1)] = d[i]; + d[i] = tmp; } - } else if (H5T_ORDER_VAX==dst.order && reverse) { + } + else if (H5T_ORDER_VAX == dst.order && reverse) { tsize = dst_p->shared->size; HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = d[i]; - tmp2 = d[i+1]; + tmp2 = d[i + 1]; - d[i] = d[(tsize-2)-i]; - d[i+1] = d[(tsize-1)-i]; + d[i] = d[(tsize - 2) - i]; + d[i + 1] = d[(tsize - 1) - i]; - d[(tsize-2)-i] = tmp1; - d[(tsize-1)-i] = tmp2; + d[(tsize - 2) - i] = tmp1; + d[(tsize - 1) - i] = tmp2; } } @@ -4652,8 +4821,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - next: - if(d == dbuf) +next: + if (d == dbuf) H5MM_memcpy(dp, d, dst_p->shared->size); /* Advance source & destination pointers by delta amounts */ @@ -4668,13 +4837,12 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_f_f() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_s_s * @@ -4688,40 +4856,45 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, - void H5_ATTR_UNUSED *bkg) +H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { - H5T_t *src=NULL; /*source datatype */ - H5T_t *dst=NULL; /*destination datatype */ - ssize_t src_delta, dst_delta; /*source & destination stride */ - int direction; /*direction of traversal */ - size_t elmtno; /*element number */ - size_t olap; /*num overlapping elements */ - size_t nchars=0; /*number of characters copied */ - uint8_t *s, *sp, *d, *dp; /*src and dst traversal pointers*/ - uint8_t *dbuf=NULL; /*temp buf for overlap convers. */ - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t * src = NULL; /*source datatype */ + H5T_t * dst = NULL; /*destination datatype */ + ssize_t src_delta, dst_delta; /*source & destination stride */ + int direction; /*direction of traversal */ + size_t elmtno; /*element number */ + size_t olap; /*num overlapping elements */ + size_t nchars = 0; /*number of characters copied */ + uint8_t *s, *sp, *d, *dp; /*src and dst traversal pointers*/ + uint8_t *dbuf = NULL; /*temp buf for overlap convers. */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(8 * src->shared->size != src->shared->u.atomic.prec || 8 * dst->shared->size != dst->shared->u.atomic.prec) + if (8 * src->shared->size != src->shared->u.atomic.prec || + 8 * dst->shared->size != dst->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision") - if(0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) + if (0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset") - if(H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 != src->shared->u.atomic.u.s.cset) + if (H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset && + H5T_CSET_UTF8 != src->shared->u.atomic.u.s.cset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad source character set") - if(H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 != dst->shared->u.atomic.u.s.cset) + if (H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset && + H5T_CSET_UTF8 != dst->shared->u.atomic.u.s.cset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad destination character set") - if((H5T_CSET_ASCII == src->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 == dst->shared->u.atomic.u.s.cset) - || (H5T_CSET_ASCII == dst->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 == src->shared->u.atomic.u.s.cset)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "The library doesn't convert between strings of ASCII and UTF") - if(src->shared->u.atomic.u.s.pad < 0 || src->shared->u.atomic.u.s.pad >= H5T_NSTR || - dst->shared->u.atomic.u.s.pad < 0 || dst->shared->u.atomic.u.s.pad >= H5T_NSTR) + if ((H5T_CSET_ASCII == src->shared->u.atomic.u.s.cset && + H5T_CSET_UTF8 == dst->shared->u.atomic.u.s.cset) || + (H5T_CSET_ASCII == dst->shared->u.atomic.u.s.cset && + H5T_CSET_UTF8 == src->shared->u.atomic.u.s.cset)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "The library doesn't convert between strings of ASCII and UTF") + if (src->shared->u.atomic.u.s.pad < 0 || src->shared->u.atomic.u.s.pad >= H5T_NSTR || + dst->shared->u.atomic.u.s.pad < 0 || dst->shared->u.atomic.u.s.pad >= H5T_NSTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding") cdata->need_bkg = H5T_BKG_NO; break; @@ -4731,7 +4904,7 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -4739,26 +4912,28 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src->shared->size==dst->shared->size || buf_stride) { + if (src->shared->size == dst->shared->size || buf_stride) { /* * When the source and destination are the same size we can do * all the conversions in place. */ - sp = dp = (uint8_t*)buf; + sp = dp = (uint8_t *)buf; direction = 1; - olap = 0; - } else if (src->shared->size>=dst->shared->size) { - double olapd = HDceil((double)(dst->shared->size)/ - (double)(src->shared->size-dst->shared->size)); + olap = 0; + } + else if (src->shared->size >= dst->shared->size) { + double olapd = + HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size)); olap = (size_t)olapd; - sp = dp = (uint8_t*)buf; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olapd = HDceil((double)(src->shared->size)/ - (double)(dst->shared->size-src->shared->size)); - olap = (size_t)olapd; - sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; + } + else { + double olapd = + HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size)); + olap = (size_t)olapd; + sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size; direction = -1; } @@ -4772,49 +4947,52 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); /* Allocate the overlap buffer */ - if(NULL == (dbuf = (uint8_t *)H5MM_malloc(dst->shared->size))) + if (NULL == (dbuf = (uint8_t *)H5MM_malloc(dst->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion") /* The conversion loop. */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if(direction > 0) { + if (direction > 0) { s = sp; d = elmtno < olap ? dbuf : dp; - } else { + } + else { s = sp; d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (src->shared->size==dst->shared->size || buf_stride) { - HDassert(s==d); - } else if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || - (sp>=dp && spshared->size)); - } else { - HDassert((dpshared->size<=sp) || - (spshared->size<=dp)); + if (src->shared->size == dst->shared->size || buf_stride) { + HDassert(s == d); + } + else if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src->shared->size) || + (sp >= dp && sp < dp + dst->shared->size)); + } + else { + HDassert((dp < sp && dp + dst->shared->size <= sp) || + (sp < dp && sp + src->shared->size <= dp)); } #endif /* Copy characters from source to destination */ - switch(src->shared->u.atomic.u.s.pad) { + switch (src->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: - for (nchars=0; - ncharsshared->size && ncharsshared->size && s[nchars]; + for (nchars = 0; + nchars < dst->shared->size && nchars < src->shared->size && s[nchars]; nchars++) { d[nchars] = s[nchars]; } break; case H5T_STR_NULLPAD: - for (nchars=0; - ncharsshared->size && ncharsshared->size && s[nchars]; + for (nchars = 0; + nchars < dst->shared->size && nchars < src->shared->size && s[nchars]; nchars++) { d[nchars] = s[nchars]; } @@ -4822,10 +5000,10 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_SPACEPAD: nchars = src->shared->size; - while (nchars>0 && ' '==s[nchars-1]) + while (nchars > 0 && ' ' == s[nchars - 1]) --nchars; nchars = MIN(dst->shared->size, nchars); - if(d != s) + if (d != s) H5MM_memcpy(d, s, nchars); break; @@ -4844,24 +5022,25 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_RESERVED_15: case H5T_STR_ERROR: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source string padding method not supported") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "source string padding method not supported") } /* end switch */ /* Terminate or pad the destination */ - switch(dst->shared->u.atomic.u.s.pad) { + switch (dst->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: - while(nchars < dst->shared->size) + while (nchars < dst->shared->size) d[nchars++] = '\0'; d[dst->shared->size - 1] = '\0'; break; case H5T_STR_NULLPAD: - while(nchars < dst->shared->size) + while (nchars < dst->shared->size) d[nchars++] = '\0'; break; case H5T_STR_SPACEPAD: - while(nchars < dst->shared->size) + while (nchars < dst->shared->size) d[nchars++] = ' '; break; @@ -4880,14 +5059,15 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_RESERVED_15: case H5T_STR_ERROR: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination string padding method not supported") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "destination string padding method not supported") } /* end switch */ /* * If we used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if(d == dbuf) + if (d == dbuf) H5MM_memcpy(dp, d, dst->shared->size); /* Advance source & destination pointers by delta amounts */ @@ -4906,7 +5086,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_s_s() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_uchar * @@ -4922,14 +5101,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_su(SCHAR, UCHAR, signed char, unsigned char, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_schar * @@ -4945,14 +5122,12 @@ H5T__conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_us(UCHAR, SCHAR, unsigned char, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_short * @@ -4968,14 +5143,12 @@ H5T__conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(SCHAR, SHORT, signed char, short, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_ushort * @@ -4991,14 +5164,12 @@ H5T__conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(SCHAR, USHORT, signed char, unsigned short, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_short * @@ -5014,14 +5185,12 @@ H5T__conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(UCHAR, SHORT, unsigned char, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_ushort * @@ -5037,14 +5206,12 @@ H5T__conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(UCHAR, USHORT, unsigned char, unsigned short, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_int * @@ -5060,14 +5227,12 @@ H5T__conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(SCHAR, INT, signed char, int, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_uint * @@ -5083,14 +5248,12 @@ H5T__conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(SCHAR, UINT, signed char, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_int * @@ -5106,14 +5269,12 @@ H5T__conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(UCHAR, INT, unsigned char, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_uint * @@ -5129,14 +5290,12 @@ H5T__conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(UCHAR, UINT, unsigned char, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_long * @@ -5152,14 +5311,12 @@ H5T__conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(SCHAR, LONG, signed char, long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_ulong * @@ -5175,14 +5332,12 @@ H5T__conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(SCHAR, ULONG, signed char, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_long * @@ -5198,14 +5353,12 @@ H5T__conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(UCHAR, LONG, unsigned char, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_ulong * @@ -5221,14 +5374,12 @@ H5T__conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(UCHAR, ULONG, unsigned char, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_llong * @@ -5244,14 +5395,12 @@ H5T__conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(SCHAR, LLONG, signed char, long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_ullong * @@ -5267,14 +5416,12 @@ H5T__conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(SCHAR, ULLONG, signed char, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_llong * @@ -5290,14 +5437,12 @@ H5T__conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(UCHAR, LLONG, unsigned char, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_ullong * @@ -5313,14 +5458,12 @@ H5T__conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(UCHAR, ULLONG, unsigned char, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_schar * @@ -5336,14 +5479,12 @@ H5T__conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(SHORT, SCHAR, short, signed char, SCHAR_MIN, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_uchar * @@ -5359,14 +5500,12 @@ H5T__conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(SHORT, UCHAR, short, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_schar * @@ -5382,14 +5521,12 @@ H5T__conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(USHORT, SCHAR, unsigned short, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_uchar * @@ -5405,14 +5542,12 @@ H5T__conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(USHORT, UCHAR, unsigned short, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_ushort * @@ -5428,14 +5563,12 @@ H5T__conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_su(SHORT, USHORT, short, unsigned short, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_short * @@ -5451,14 +5584,12 @@ H5T__conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_us(USHORT, SHORT, unsigned short, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_int * @@ -5474,14 +5605,12 @@ H5T__conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(SHORT, INT, short, int, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_uint * @@ -5497,14 +5626,12 @@ H5T__conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(SHORT, UINT, short, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_int * @@ -5520,14 +5647,12 @@ H5T__conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(USHORT, INT, unsigned short, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_uint * @@ -5543,14 +5668,12 @@ H5T__conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(USHORT, UINT, unsigned short, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_long * @@ -5566,14 +5689,12 @@ H5T__conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(SHORT, LONG, short, long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_ulong * @@ -5589,14 +5710,12 @@ H5T__conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(SHORT, ULONG, short, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_long * @@ -5612,14 +5731,12 @@ H5T__conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(USHORT, LONG, unsigned short, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_ulong * @@ -5635,14 +5752,12 @@ H5T__conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(USHORT, ULONG, unsigned short, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_llong * @@ -5658,14 +5773,12 @@ H5T__conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(SHORT, LLONG, short, long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_ullong * @@ -5681,14 +5794,12 @@ H5T__conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(SHORT, ULLONG, short, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_llong * @@ -5704,14 +5815,12 @@ H5T__conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(USHORT, LLONG, unsigned short, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_ullong * @@ -5727,14 +5836,12 @@ H5T__conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(USHORT, ULLONG, unsigned short, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_schar * @@ -5750,14 +5857,12 @@ H5T__conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(INT, SCHAR, int, signed char, SCHAR_MIN, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_uchar * @@ -5773,14 +5878,12 @@ H5T__conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(INT, UCHAR, int, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_schar * @@ -5796,14 +5899,12 @@ H5T__conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(UINT, SCHAR, unsigned, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_uchar * @@ -5819,14 +5920,12 @@ H5T__conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(UINT, UCHAR, unsigned, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_short * @@ -5842,14 +5941,12 @@ H5T__conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(INT, SHORT, int, short, SHRT_MIN, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_ushort * @@ -5865,14 +5962,12 @@ H5T__conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(INT, USHORT, int, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_short * @@ -5888,14 +5983,12 @@ H5T__conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(UINT, SHORT, unsigned, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_ushort * @@ -5911,14 +6004,12 @@ H5T__conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(UINT, USHORT, unsigned, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_uint * @@ -5934,14 +6025,12 @@ H5T__conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_su(INT, UINT, int, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_int * @@ -5957,14 +6046,12 @@ H5T__conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_us(UINT, INT, unsigned, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_long * @@ -5980,14 +6067,12 @@ H5T__conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(INT, LONG, int, long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_ulong * @@ -6003,14 +6088,12 @@ H5T__conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(INT, LONG, int, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_long * @@ -6026,14 +6109,12 @@ H5T__conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(UINT, LONG, unsigned, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_ulong * @@ -6049,14 +6130,12 @@ H5T__conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(UINT, ULONG, unsigned, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_llong * @@ -6072,14 +6151,12 @@ H5T__conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(INT, LLONG, int, long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_ullong * @@ -6095,14 +6172,12 @@ H5T__conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(INT, ULLONG, int, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_llong * @@ -6118,14 +6193,12 @@ H5T__conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(UINT, LLONG, unsigned, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_ullong * @@ -6141,14 +6214,12 @@ H5T__conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(UINT, ULLONG, unsigned, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_schar * @@ -6164,14 +6235,12 @@ H5T__conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(LONG, SCHAR, long, signed char, SCHAR_MIN, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_uchar * @@ -6187,14 +6256,12 @@ H5T__conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(LONG, UCHAR, long, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_schar * @@ -6210,14 +6277,12 @@ H5T__conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(ULONG, SCHAR, unsigned long, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_uchar * @@ -6233,14 +6298,12 @@ H5T__conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(ULONG, UCHAR, unsigned long, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_short * @@ -6256,14 +6319,12 @@ H5T__conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(LONG, SHORT, long, short, SHRT_MIN, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_ushort * @@ -6279,14 +6340,12 @@ H5T__conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(LONG, USHORT, long, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_short * @@ -6302,14 +6361,12 @@ H5T__conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(ULONG, SHORT, unsigned long, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_ushort * @@ -6325,14 +6382,12 @@ H5T__conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(ULONG, USHORT, unsigned long, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_int * @@ -6348,14 +6403,12 @@ H5T__conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(LONG, INT, long, int, INT_MIN, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_uint * @@ -6371,14 +6424,12 @@ H5T__conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(LONG, UINT, long, unsigned, -, UINT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_int * @@ -6394,14 +6445,12 @@ H5T__conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(ULONG, INT, unsigned long, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_uint * @@ -6417,14 +6466,12 @@ H5T__conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(ULONG, UINT, unsigned long, unsigned, -, UINT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_ulong * @@ -6440,14 +6487,12 @@ H5T__conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_su(LONG, ULONG, long, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_long * @@ -6463,14 +6508,12 @@ H5T__conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_us(ULONG, LONG, unsigned long, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_llong * @@ -6486,14 +6529,12 @@ H5T__conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sS(LONG, LLONG, long, long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_ullong * @@ -6509,14 +6550,12 @@ H5T__conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_sU(LONG, ULLONG, long, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_llong * @@ -6532,14 +6571,12 @@ H5T__conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uS(ULONG, LLONG, unsigned long, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_ullong * @@ -6555,14 +6592,12 @@ H5T__conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_uU(ULONG, ULLONG, unsigned long, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_schar * @@ -6578,14 +6613,12 @@ H5T__conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(LLONG, SCHAR, long long, signed char, SCHAR_MIN, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_uchar * @@ -6601,14 +6634,12 @@ H5T__conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(LLONG, UCHAR, long long, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_schar * @@ -6624,14 +6655,12 @@ H5T__conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(ULLONG, SCHAR, unsigned long long, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_uchar * @@ -6647,14 +6676,12 @@ H5T__conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(ULLONG, UCHAR, unsigned long long, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_short * @@ -6670,14 +6697,12 @@ H5T__conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(LLONG, SHORT, long long, short, SHRT_MIN, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_ushort * @@ -6693,14 +6718,12 @@ H5T__conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(LLONG, USHORT, long long, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_short * @@ -6716,14 +6739,12 @@ H5T__conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(ULLONG, SHORT, unsigned long long, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_ushort * @@ -6739,14 +6760,12 @@ H5T__conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(ULLONG, USHORT, unsigned long long, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_int * @@ -6762,14 +6781,12 @@ H5T__conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(LLONG, INT, long long, int, INT_MIN, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_uint * @@ -6785,14 +6802,12 @@ H5T__conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(LLONG, UINT, long long, unsigned, -, UINT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_int * @@ -6808,14 +6823,12 @@ H5T__conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(ULLONG, INT, unsigned long long, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_uint * @@ -6831,14 +6844,12 @@ H5T__conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(ULLONG, UINT, unsigned long long, unsigned, -, UINT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_long * @@ -6854,14 +6865,12 @@ H5T__conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ss(LLONG, LONG, long long, long, LONG_MIN, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_ulong * @@ -6877,14 +6886,12 @@ H5T__conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Su(LLONG, ULONG, long long, unsigned long, -, ULONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_long * @@ -6900,14 +6907,12 @@ H5T__conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Us(ULLONG, LONG, unsigned long long, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_ulong * @@ -6923,14 +6928,12 @@ H5T__conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Uu(ULLONG, ULONG, unsigned long long, unsigned long, -, ULONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_ullong * @@ -6946,14 +6949,12 @@ H5T__conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_su(LLONG, ULLONG, long long, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_llong * @@ -6969,14 +6970,12 @@ H5T__conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_us(ULLONG, LLONG, unsigned long long, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_double * @@ -6991,14 +6990,12 @@ H5T__conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_fF(FLOAT, DOUBLE, float, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_ldouble * @@ -7014,15 +7011,13 @@ H5T__conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #if H5_SIZEOF_LONG_DOUBLE != 0 herr_t -H5T__conv_float_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_fF(FLOAT, LDOUBLE, float, long double, -, -); } #endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ - /*------------------------------------------------------------------------- * Function: H5T__conv_double_float * @@ -7037,14 +7032,12 @@ H5T__conv_float_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ff(DOUBLE, FLOAT, double, float, -FLT_MAX, FLT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_ldouble * @@ -7060,15 +7053,13 @@ H5T__conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #if H5_SIZEOF_LONG_DOUBLE != 0 herr_t -H5T__conv_double_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_fF(DOUBLE, LDOUBLE, double, long double, -, -); } #endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_float * @@ -7084,15 +7075,13 @@ H5T__conv_double_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #if H5_SIZEOF_LONG_DOUBLE != 0 herr_t -H5T__conv_ldouble_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ff(LDOUBLE, FLOAT, long double, float, -FLT_MAX, FLT_MAX); } #endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_double * @@ -7108,15 +7097,13 @@ H5T__conv_ldouble_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #if H5_SIZEOF_LONG_DOUBLE != 0 herr_t -H5T__conv_ldouble_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ff(LDOUBLE, DOUBLE, long double, double, -DBL_MAX, DBL_MAX); } #endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_float * @@ -7131,14 +7118,12 @@ H5T__conv_ldouble_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(SCHAR, FLOAT, signed char, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_double * @@ -7153,14 +7138,12 @@ H5T__conv_schar_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(SCHAR, DOUBLE, signed char, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_ldouble * @@ -7175,14 +7158,12 @@ H5T__conv_schar_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_schar_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(SCHAR, LDOUBLE, signed char, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_float * @@ -7197,14 +7178,12 @@ H5T__conv_schar_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(UCHAR, FLOAT, unsigned char, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_double * @@ -7219,14 +7198,12 @@ H5T__conv_uchar_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(UCHAR, DOUBLE, unsigned char, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_ldouble * @@ -7241,14 +7218,12 @@ H5T__conv_uchar_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uchar_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(UCHAR, LDOUBLE, unsigned char, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_float * @@ -7263,14 +7238,12 @@ H5T__conv_uchar_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(SHORT, FLOAT, short, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_double * @@ -7285,14 +7258,12 @@ H5T__conv_short_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(SHORT, DOUBLE, short, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_ldouble * @@ -7307,14 +7278,12 @@ H5T__conv_short_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_short_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(SHORT, LDOUBLE, short, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_float * @@ -7329,14 +7298,12 @@ H5T__conv_short_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(USHORT, FLOAT, unsigned short, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_double * @@ -7351,14 +7318,12 @@ H5T__conv_ushort_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(USHORT, DOUBLE, unsigned short, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_ldouble * @@ -7373,14 +7338,12 @@ H5T__conv_ushort_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ushort_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(USHORT, LDOUBLE, unsigned short, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_float * @@ -7395,14 +7358,12 @@ H5T__conv_ushort_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(INT, FLOAT, int, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_double * @@ -7417,14 +7378,12 @@ H5T__conv_int_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(INT, DOUBLE, int, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_ldouble * @@ -7439,14 +7398,12 @@ H5T__conv_int_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_int_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(INT, LDOUBLE, int, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_float * @@ -7461,14 +7418,12 @@ H5T__conv_int_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(UINT, FLOAT, unsigned int, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_double * @@ -7483,14 +7438,12 @@ H5T__conv_uint_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(UINT, DOUBLE, unsigned int, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_ldouble * @@ -7505,14 +7458,12 @@ H5T__conv_uint_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_uint_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(UINT, LDOUBLE, unsigned int, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_float * @@ -7527,14 +7478,12 @@ H5T__conv_uint_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(LONG, FLOAT, long, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_double * @@ -7549,14 +7498,12 @@ H5T__conv_long_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(LONG, DOUBLE, long, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_ldouble * @@ -7571,14 +7518,12 @@ H5T__conv_long_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_long_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(LONG, LDOUBLE, long, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_float * @@ -7593,14 +7538,12 @@ H5T__conv_long_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(ULONG, FLOAT, unsigned long, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_double * @@ -7615,14 +7558,12 @@ H5T__conv_ulong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(ULONG, DOUBLE, unsigned long, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_ldouble * @@ -7637,14 +7578,12 @@ H5T__conv_ulong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ulong_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(ULONG, LDOUBLE, unsigned long, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_float * @@ -7659,14 +7598,12 @@ H5T__conv_ulong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(LLONG, FLOAT, long long, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_double * @@ -7681,14 +7618,12 @@ H5T__conv_llong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(LLONG, DOUBLE, long long, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_ldouble * @@ -7704,15 +7639,13 @@ H5T__conv_llong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #ifdef H5T_CONV_INTERNAL_LLONG_LDOUBLE herr_t -H5T__conv_llong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_llong_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(LLONG, LDOUBLE, long long, long double, -, -); } #endif /* H5T_CONV_INTERNAL_LLONG_LDOUBLE */ - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_float * @@ -7727,14 +7660,12 @@ H5T__conv_llong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(ULLONG, FLOAT, unsigned long long, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_double * @@ -7749,14 +7680,12 @@ H5T__conv_ullong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(ULLONG, DOUBLE, unsigned long long, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_ldouble * @@ -7772,15 +7701,13 @@ H5T__conv_ullong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #ifdef H5T_CONV_INTERNAL_ULLONG_LDOUBLE herr_t -H5T__conv_ullong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ullong_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_xF(ULLONG, LDOUBLE, unsigned long long, long double, -, -); } #endif /*H5T_CONV_INTERNAL_ULLONG_LDOUBLE*/ - /*------------------------------------------------------------------------- * Function: H5T__conv_float_schar * @@ -7795,16 +7722,14 @@ H5T__conv_ullong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_schar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, SCHAR, float, signed char, SCHAR_MIN, SCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_uchar * @@ -7819,16 +7744,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_uchar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, UCHAR, float, unsigned char, 0, UCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_schar * @@ -7843,16 +7766,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_schar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, SCHAR, double, signed char, SCHAR_MIN, SCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_uchar * @@ -7867,16 +7788,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_uchar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, UCHAR, double, unsigned char, 0, UCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_schar * @@ -7891,16 +7810,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_schar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, SCHAR, long double, signed char, SCHAR_MIN, SCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_uchar * @@ -7915,16 +7832,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_uchar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, UCHAR, long double, unsigned char, 0, UCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_short * @@ -7939,16 +7854,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_short (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, SHORT, float, short, SHRT_MIN, SHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_ushort * @@ -7963,16 +7876,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_ushort (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, USHORT, float, unsigned short, 0, USHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_short * @@ -7987,16 +7898,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_short (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, SHORT, double, short, SHRT_MIN, SHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_ushort * @@ -8011,16 +7920,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_ushort (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, USHORT, double, unsigned short, 0, USHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_short * @@ -8035,16 +7942,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_short (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, SHORT, long double, short, SHRT_MIN, SHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_ushort * @@ -8059,16 +7964,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_ushort (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, USHORT, long double, unsigned short, 0, USHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_int * @@ -8083,16 +7986,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_int (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, INT, float, int, INT_MIN, INT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_uint * @@ -8107,16 +8008,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_uint (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, UINT, float, unsigned int, 0, UINT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_int * @@ -8131,16 +8030,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_int (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, INT, double, int, INT_MIN, INT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_uint * @@ -8155,16 +8052,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_uint (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, UINT, double, unsigned int, 0, UINT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_int * @@ -8179,16 +8074,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_int (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, INT, long double, int, INT_MIN, INT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_uint * @@ -8203,16 +8096,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_uint (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, UINT, long double, unsigned int, 0, UINT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_long * @@ -8227,16 +8118,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_long (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, LONG, float, long, LONG_MIN, LONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_ulong * @@ -8251,16 +8140,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_ulong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, ULONG, float, unsigned long, 0, ULONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_long * @@ -8275,16 +8162,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_long (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, LONG, double, long, LONG_MIN, LONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_ulong * @@ -8299,16 +8184,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_ulong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, ULONG, double, unsigned long, 0, ULONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_long * @@ -8323,16 +8206,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_long (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, LONG, long double, long, LONG_MIN, LONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_ulong * @@ -8347,16 +8228,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_ulong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, ULONG, long double, unsigned long, 0, ULONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_llong * @@ -8371,16 +8250,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_llong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, LLONG, float, long long, LLONG_MIN, LLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_ullong * @@ -8395,16 +8272,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_float_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, ULLONG, float, unsigned long long, 0, ULLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_llong * @@ -8419,16 +8294,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_llong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, LLONG, double, long long, LLONG_MIN, LLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_ullong * @@ -8443,16 +8316,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_double_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, ULLONG, double, unsigned long long, 0, ULLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_llong * @@ -8468,17 +8339,15 @@ H5_GCC_DIAG_ON(float-equal) */ #ifdef H5T_CONV_INTERNAL_LDOUBLE_LLONG herr_t -H5T__conv_ldouble_llong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, LLONG, long double, long long, LLONG_MIN, LLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } #endif /*H5T_CONV_INTERNAL_LDOUBLE_LLONG*/ - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_ullong * @@ -8494,17 +8363,15 @@ H5_GCC_DIAG_ON(float-equal) */ #if H5T_CONV_INTERNAL_LDOUBLE_ULLONG herr_t -H5T__conv_ldouble_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, - void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_ldouble_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, ULLONG, long double, unsigned long long, 0, ULLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } #endif /*H5T_CONV_INTERNAL_LDOUBLE_ULLONG*/ - /*------------------------------------------------------------------------- * Function: H5T__conv_f_i * @@ -8520,51 +8387,52 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { /* Traversal-related variables */ - H5T_t *src_p; /*source datatype */ - H5T_t *dst_p; /*destination datatype */ - H5T_atomic_t src; /*atomic source info */ - H5T_atomic_t dst; /*atomic destination info */ - int direction; /*forward or backward traversal */ - size_t elmtno; /*element number */ - size_t half_size; /*half the type size */ - size_t tsize; /*type size for swapping bytes */ - size_t olap; /*num overlapping elements */ - uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t *src_rev=NULL; /*order-reversed source buffer */ - uint8_t dbuf[64]; /*temp destination buffer */ - uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ + H5T_t * src_p; /*source datatype */ + H5T_t * dst_p; /*destination datatype */ + H5T_atomic_t src; /*atomic source info */ + H5T_atomic_t dst; /*atomic destination info */ + int direction; /*forward or backward traversal */ + size_t elmtno; /*element number */ + size_t half_size; /*half the type size */ + size_t tsize; /*type size for swapping bytes */ + size_t olap; /*num overlapping elements */ + uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t dbuf[64]; /*temp destination buffer */ + uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ - hssize_t expo; /*source exponent */ - hssize_t sign; /*source sign bit value */ - uint8_t *int_buf=NULL; /*buffer for temporary value */ - size_t buf_size; /*buffer size for temporary value */ - size_t i; /*miscellaneous counters */ - size_t first; /*first bit(MSB) in an integer */ - ssize_t sfirst; /*a signed version of `first' */ - H5T_conv_cb_t cb_struct={NULL, NULL}; /*conversion callback structure */ - hbool_t truncated; /*if fraction value is dropped */ - hbool_t reverse; /*if reverse order of destination at the end */ - H5T_conv_ret_t except_ret; /*return of callback function */ - herr_t ret_value=SUCCEED; /* Return value */ + hssize_t expo; /*source exponent */ + hssize_t sign; /*source sign bit value */ + uint8_t * int_buf = NULL; /*buffer for temporary value */ + size_t buf_size; /*buffer size for temporary value */ + size_t i; /*miscellaneous counters */ + size_t first; /*first bit(MSB) in an integer */ + ssize_t sfirst; /*a signed version of `first' */ + H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ + hbool_t truncated; /*if fraction value is dropped */ + hbool_t reverse; /*if reverse order of destination at the end */ + H5T_conv_ret_t except_ret; /*return of callback function */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t*)H5I_object(src_id)) || NULL == (dst_p = (H5T_t*)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if(H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) + if (H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(dst_p->shared->size > sizeof(dbuf)) + if (dst_p->shared->size > sizeof(dbuf)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") - if(8 * sizeof(expo) - 1 < src.u.f.esize) + if (8 * sizeof(expo) - 1 < src.u.f.esize) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -8574,7 +8442,8 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t*)H5I_object(src_id)) || NULL == (dst_p = (H5T_t*)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -8584,40 +8453,42 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if(src_p->shared->size==dst_p->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src_p->shared->size == dst_p->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; - } else if (src_p->shared->size>=dst_p->shared->size) { - double olap_d = HDceil((double)(dst_p->shared->size)/ - (double)(src_p->shared->size-dst_p->shared->size)); - olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + olap = nelmts; + } + else if (src_p->shared->size >= dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size) / + (double)(src_p->shared->size - dst_p->shared->size)); + olap = (size_t)olap_d; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olap_d = HDceil((double)(src_p->shared->size)/ - (double)(dst_p->shared->size-src_p->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; - direction = -1; + } + else { + double olap_d = HDceil((double)(src_p->shared->size) / + (double)(dst_p->shared->size - src_p->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst_p->shared->size; + direction = -1; } /* Allocate enough space for the buffer holding temporary * converted value */ - buf_size = (size_t) (HDpow((double)2.0f, (double)src.u.f.esize) / 8 + 1); - int_buf = (uint8_t*)H5MM_calloc(buf_size); + buf_size = (size_t)(HDpow((double)2.0f, (double)src.u.f.esize) / 8 + 1); + int_buf = (uint8_t *)H5MM_calloc(buf_size); /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); + src_rev = (uint8_t *)H5MM_calloc(src_p->shared->size); /* The conversion loop */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* Set these variables to default */ except_ret = H5T_CONV_UNHANDLED; truncated = FALSE; @@ -8627,21 +8498,23 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if(direction > 0) { + if (direction > 0) { s = sp; - d = elmtno= nelmts ? dbuf : dp; + d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || - (sp>=dp && spshared->size)); - } else { - HDassert((dpshared->size<=sp) || - (spshared->size<=dp)); + if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src_p->shared->size) || + (sp >= dp && sp < dp + dst_p->shared->size)); + } + else { + HDassert((dp < sp && dp + dst_p->shared->size <= sp) || + (sp < dp && sp + src_p->shared->size <= dp)); } #endif /* @@ -8649,152 +8522,170 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src.order) { - half_size = src_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp1; + if (H5T_ORDER_BE == src.order) { + half_size = src_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + tmp1 = s[src_p->shared->size - (i + 1)]; + s[src_p->shared->size - (i + 1)] = s[i]; + s[i] = tmp1; } - } else if (H5T_ORDER_VAX==src.order) { + } + else if (H5T_ORDER_VAX == src.order) { tsize = src_p->shared->size; HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = s[i]; - tmp2 = s[i+1]; + tmp2 = s[i + 1]; - s[i] = s[(tsize-2)-i]; - s[i+1] = s[(tsize-1)-i]; + s[i] = s[(tsize - 2) - i]; + s[i + 1] = s[(tsize - 1) - i]; - s[(tsize-2)-i] = tmp1; - s[(tsize-1)-i] = tmp2; + s[(tsize - 2) - i] = tmp1; + s[(tsize - 1) - i] = tmp2; } } /*zero-set all destination bits*/ - H5T__bit_set (d, dst.offset, dst.prec, FALSE); + H5T__bit_set(d, dst.offset, dst.prec, FALSE); /* * Find the sign bit value of the source. */ - sign = (hssize_t) H5T__bit_get_d(s, src.u.f.sign, (size_t)1); + sign = (hssize_t)H5T__bit_get_d(s, src.u.f.sign, (size_t)1); /* * Check for special cases: +0, -0, +Inf, -Inf, NaN */ - if (H5T__bit_find (s, src.u.f.mpos, src.u.f.msize, - H5T_BIT_LSB, TRUE)<0) { - if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, TRUE)<0) { + if (H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_LSB, TRUE) < 0) { + if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, TRUE) < 0) { /* +0 or -0 */ /* Set all bits to zero */ goto padding; - } else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + } + else if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /* +Infinity or -Infinity */ - if(sign) { /* -Infinity */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (sign) { /* -Infinity */ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - if (H5T_SGN_2==dst.u.i.sign) - H5T__bit_set (d, dst.prec-1, (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { + if (H5T_SGN_2 == dst.u.i.sign) + H5T__bit_set(d, dst.prec - 1, (size_t)1, TRUE); + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else { /* +Infinity */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + } + else { /* +Infinity */ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - if (H5T_SGN_NONE==dst.u.i.sign) - H5T__bit_set (d, dst.offset, dst.prec, TRUE); - else if (H5T_SGN_2==dst.u.i.sign) - H5T__bit_set (d, dst.offset, dst.prec-1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { + if (H5T_SGN_NONE == dst.u.i.sign) + H5T__bit_set(d, dst.offset, dst.prec, TRUE); + else if (H5T_SGN_2 == dst.u.i.sign) + H5T__bit_set(d, dst.offset, dst.prec - 1, TRUE); + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") } goto padding; } - } else if (H5T_NORM_NONE==src.u.f.norm && H5T__bit_find (s, src.u.f.mpos, src.u.f.msize-1, - H5T_BIT_LSB, TRUE)<0 && H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + } + else if (H5T_NORM_NONE == src.u.f.norm && + H5T__bit_find(s, src.u.f.mpos, src.u.f.msize - 1, H5T_BIT_LSB, TRUE) < 0 && + H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /*This is a special case for the source of no implied mantissa bit. *If the exponent bits are all 1s and only the 1st bit of mantissa *is set to 1. It's infinity. The Intel-Linux "long double" is this case.*/ /* +Infinity or -Infinity */ - if(sign) { /* -Infinity */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (sign) { /* -Infinity */ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - if (H5T_SGN_2==dst.u.i.sign) - H5T__bit_set (d, dst.prec-1, (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { + if (H5T_SGN_2 == dst.u.i.sign) + H5T__bit_set(d, dst.prec - 1, (size_t)1, TRUE); + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else { /* +Infinity */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + } + else { /* +Infinity */ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - if (H5T_SGN_NONE==dst.u.i.sign) - H5T__bit_set (d, dst.offset, dst.prec, TRUE); - else if (H5T_SGN_2==dst.u.i.sign) - H5T__bit_set (d, dst.offset, dst.prec-1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { + if (H5T_SGN_NONE == dst.u.i.sign) + H5T__bit_set(d, dst.offset, dst.prec, TRUE); + else if (H5T_SGN_2 == dst.u.i.sign) + H5T__bit_set(d, dst.offset, dst.prec - 1, TRUE); + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") } goto padding; - } else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + } + else if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /* NaN */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NAN, - src_id, dst_id, src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NAN, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { /*Just set all bits to zero.*/ goto padding; - } else if(except_ret == H5T_CONV_HANDLED) { + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) + } + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; @@ -8805,18 +8696,21 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the source bit field where it's located. Not expecting * exponent to be greater than the maximal value of hssize_t. */ - expo = (hssize_t) H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); + expo = (hssize_t)H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); /* * Calculate the true source exponent by adjusting according to * the source exponent bias. */ - if (0==expo || H5T_NORM_NONE==src.u.f.norm) { - expo -= (hssize_t) (src.u.f.ebias-1); - } else if (H5T_NORM_IMPLIED==src.u.f.norm) { - expo -= (hssize_t) src.u.f.ebias; - } else { - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") + if (0 == expo || H5T_NORM_NONE == src.u.f.norm) { + expo -= (hssize_t)(src.u.f.ebias - 1); + } + else if (H5T_NORM_IMPLIED == src.u.f.norm) { + expo -= (hssize_t)src.u.f.ebias; + } + else { + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "normalization method not implemented yet") } /* @@ -8835,7 +8729,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Restore the implicit bit for mantissa if it's implied. * Equivalent to mantissa |= (hsize_t)1<shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, - src_id, dst_id, src_rev, d, cb_struct.user_data); - if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, + d, cb_struct.user_data); + if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } } - } else { /*source is positive*/ - if (first>=dst.prec) { + } + else { /*source is positive*/ + if (first >= dst.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) - H5T__bit_set (d, dst.offset, dst.prec, TRUE); - else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) + H5T__bit_set(d, dst.offset, dst.prec, TRUE); + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else if (first shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) + if (except_ret == H5T_CONV_UNHANDLED) /*copy source value into it if case is ignored by user handler*/ - H5T__bit_copy (d, dst.offset, int_buf, (size_t)0, first+1); - else if(except_ret == H5T_CONV_HANDLED) { + H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, first + 1); + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") } } - } else if (H5T_SGN_2==dst.u.i.sign) { /*Destination is signed*/ - if(sign) { /*source is negative*/ - if(first < dst.prec-1) { - if(truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ + } + else if (H5T_SGN_2 == dst.u.i.sign) { /*Destination is signed*/ + if (sign) { /*source is negative*/ + if (first < dst.prec - 1) { + if (truncated && + cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { /*If this case ignored by user handler*/ + if (except_ret == H5T_CONV_UNHANDLED) { /*If this case ignored by user handler*/ /*Convert to integer representation. Equivalent to ~(value - 1).*/ H5T__bit_dec(int_buf, (size_t)0, 8 * buf_size); H5T__bit_neg(int_buf, (size_t)0, 8 * buf_size); /*copy source value into destination*/ - H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, dst.prec-1); - H5T__bit_set(d, (dst.offset + dst.prec-1), (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, dst.prec - 1); + H5T__bit_set(d, (dst.offset + dst.prec - 1), (size_t)1, TRUE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - } else { + } + else { /* if underflows and no callback, do nothing except turn on * the sign bit because 0x80...00 is the biggest negative value. */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) - H5T__bit_set(d, (dst.offset + dst.prec-1), (size_t)1, TRUE); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) + H5T__bit_set(d, (dst.offset + dst.prec - 1), (size_t)1, TRUE); + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } } - } else { /*source is positive*/ - if (first >= dst.prec-1) { + } + else { /*source is positive*/ + if (first >= dst.prec - 1) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) - H5T__bit_set(d, dst.offset, dst.prec-1, TRUE); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) + H5T__bit_set(d, dst.offset, dst.prec - 1, TRUE); + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - } else if(first < dst.prec-1) { - if(truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ + } + else if (first < dst.prec - 1) { + if (truncated && + cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { /*copy source value into it if case is ignored by user handler*/ - H5T__bit_copy (d, dst.offset, int_buf, (size_t)0, first+1); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, first + 1); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; @@ -9013,47 +8934,47 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } } - padding: +padding: /* * Set padding areas in destination. */ - if (dst.offset>0) { - HDassert(H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); - H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); + if (dst.offset > 0) { + HDassert(H5T_PAD_ZERO == dst.lsb_pad || H5T_PAD_ONE == dst.lsb_pad); + H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE == dst.lsb_pad)); } - if (dst.offset+dst.prec!=8*dst_p->shared->size) { - HDassert(H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); - H5T__bit_set(d, dst.offset+dst.prec, - 8*dst_p->shared->size - (dst.offset+ dst.prec), - (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); + if (dst.offset + dst.prec != 8 * dst_p->shared->size) { + HDassert(H5T_PAD_ZERO == dst.msb_pad || H5T_PAD_ONE == dst.msb_pad); + H5T__bit_set(d, dst.offset + dst.prec, 8 * dst_p->shared->size - (dst.offset + dst.prec), + (hbool_t)(H5T_PAD_ONE == dst.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - d[dst_p->shared->size-(i+1)] = d[i]; - d[i] = tmp1; + if (H5T_ORDER_BE == dst.order && reverse) { + half_size = dst_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + tmp1 = d[dst_p->shared->size - (i + 1)]; + d[dst_p->shared->size - (i + 1)] = d[i]; + d[i] = tmp1; } } - next: +next: /* * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if (d==dbuf) - H5MM_memcpy (dp, d, dst_p->shared->size); + if (d == dbuf) + H5MM_memcpy(dp, d, dst_p->shared->size); if (buf_stride) { - sp += direction * (ssize_t) buf_stride; - dp += direction * (ssize_t) buf_stride; - } else { - sp += direction * (ssize_t) src_p->shared->size; - dp += direction * (ssize_t) dst_p->shared->size; + sp += direction * (ssize_t)buf_stride; + dp += direction * (ssize_t)buf_stride; + } + else { + sp += direction * (ssize_t)src_p->shared->size; + dp += direction * (ssize_t)dst_p->shared->size; } HDmemset(int_buf, 0, buf_size); @@ -9066,15 +8987,14 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(int_buf) + if (int_buf) H5MM_xfree(int_buf); - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_f_i() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_i_f * @@ -9090,53 +9010,54 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { /* Traversal-related variables */ - H5T_t *src_p; /*source datatype */ - H5T_t *dst_p; /*destination datatype */ - H5T_atomic_t src; /*atomic source info */ - H5T_atomic_t dst; /*atomic destination info */ - int direction; /*forward or backward traversal */ - size_t elmtno; /*element number */ - size_t half_size; /*half the type size */ - size_t tsize; /*type size for swapping bytes */ - size_t olap; /*num overlapping elements */ - uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t *src_rev = NULL; /*order-reversed source buffer */ - uint8_t dbuf[64]; /*temp destination buffer */ - uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ + H5T_t * src_p; /*source datatype */ + H5T_t * dst_p; /*destination datatype */ + H5T_atomic_t src; /*atomic source info */ + H5T_atomic_t dst; /*atomic destination info */ + int direction; /*forward or backward traversal */ + size_t elmtno; /*element number */ + size_t half_size; /*half the type size */ + size_t tsize; /*type size for swapping bytes */ + size_t olap; /*num overlapping elements */ + uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t dbuf[64]; /*temp destination buffer */ + uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ - hsize_t expo; /*destination exponent */ - hsize_t expo_max; /*maximal possible exponent value */ - size_t sign; /*source sign bit value */ - hbool_t is_max_neg; /*source is maximal negative value*/ - hbool_t do_round; /*whether there is roundup */ - uint8_t *int_buf = NULL; /*buffer for temporary value */ - size_t buf_size; /*buffer size for temporary value */ - size_t i; /*miscellaneous counters */ - size_t first; /*first bit(MSB) in an integer */ - ssize_t sfirst; /*a signed version of `first' */ - H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ - H5T_conv_ret_t except_ret; /*return of callback function */ - hbool_t reverse; /*if reverse the order of destination */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t expo; /*destination exponent */ + hsize_t expo_max; /*maximal possible exponent value */ + size_t sign; /*source sign bit value */ + hbool_t is_max_neg; /*source is maximal negative value*/ + hbool_t do_round; /*whether there is roundup */ + uint8_t * int_buf = NULL; /*buffer for temporary value */ + size_t buf_size; /*buffer size for temporary value */ + size_t i; /*miscellaneous counters */ + size_t first; /*first bit(MSB) in an integer */ + ssize_t sfirst; /*a signed version of `first' */ + H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ + H5T_conv_ret_t except_ret; /*return of callback function */ + hbool_t reverse; /*if reverse the order of destination */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if(H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) + if (H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(dst_p->shared->size > sizeof(dbuf)) + if (dst_p->shared->size > sizeof(dbuf)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") - if(8 * sizeof(expo) - 1 < src.u.f.esize) + if (8 * sizeof(expo) - 1 < src.u.f.esize) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -9146,7 +9067,8 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -9156,69 +9078,73 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src_p->shared->size==dst_p->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src_p->shared->size == dst_p->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; - } else if (src_p->shared->size>=dst_p->shared->size) { - double olap_d = HDceil((double)(dst_p->shared->size)/ - (double)(src_p->shared->size-dst_p->shared->size)); - olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + olap = nelmts; + } + else if (src_p->shared->size >= dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size) / + (double)(src_p->shared->size - dst_p->shared->size)); + olap = (size_t)olap_d; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olap_d = HDceil((double)(src_p->shared->size)/ - (double)(dst_p->shared->size-src_p->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; - direction = -1; + } + else { + double olap_d = HDceil((double)(src_p->shared->size) / + (double)(dst_p->shared->size - src_p->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst_p->shared->size; + direction = -1; } /* Allocate enough space for the buffer holding temporary * converted value */ - buf_size = (src.prec > dst.u.f.msize ? src.prec : dst.u.f.msize)/8 + 1; - int_buf = (uint8_t*)H5MM_calloc(buf_size); + buf_size = (src.prec > dst.u.f.msize ? src.prec : dst.u.f.msize) / 8 + 1; + int_buf = (uint8_t *)H5MM_calloc(buf_size); /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); + src_rev = (uint8_t *)H5MM_calloc(src_p->shared->size); /* The conversion loop */ - for (elmtno=0; elmtno0) { + if (direction > 0) { s = sp; - d = elmtno= nelmts ? dbuf : dp; + d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || - (sp>=dp && spshared->size)); - } else { - HDassert((dpshared->size<=sp) || - (spshared->size<=dp)); + if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src_p->shared->size) || + (sp >= dp && sp < dp + dst_p->shared->size)); + } + else { + HDassert((dp < sp && dp + dst_p->shared->size <= sp) || + (sp < dp && sp + src_p->shared->size <= dp)); } #endif @@ -9226,56 +9152,58 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src.order) { - half_size = src_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp1; + if (H5T_ORDER_BE == src.order) { + half_size = src_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + tmp1 = s[src_p->shared->size - (i + 1)]; + s[src_p->shared->size - (i + 1)] = s[i]; + s[i] = tmp1; } } /* Zero-set all destination bits*/ - H5T__bit_set (d, dst.offset, dst.prec, FALSE); + H5T__bit_set(d, dst.offset, dst.prec, FALSE); /* Copy source into a temporary buffer */ H5T__bit_copy(int_buf, (size_t)0, s, src.offset, src.prec); /* Find the sign bit value of the source */ - if(H5T_SGN_2 == src.u.i.sign) + if (H5T_SGN_2 == src.u.i.sign) sign = (size_t)H5T__bit_get_d(int_buf, src.prec - 1, (size_t)1); /* What is the bit position(starting from 0 as first one) for the most significant * bit(MSB) of S which is set? */ - if(H5T_SGN_2 == src.u.i.sign) { + if (H5T_SGN_2 == src.u.i.sign) { sfirst = H5T__bit_find(int_buf, (size_t)0, src.prec - 1, H5T_BIT_MSB, TRUE); - if(sign && sfirst < 0) + if (sign && sfirst < 0) /* The case 0x80...00, which is negative with maximal value */ is_max_neg = 1; - } else if(H5T_SGN_NONE == src.u.i.sign) + } + else if (H5T_SGN_NONE == src.u.i.sign) sfirst = H5T__bit_find(int_buf, (size_t)0, src.prec, H5T_BIT_MSB, TRUE); /* Handle special cases here. Integer is zero */ - if(!sign && sfirst < 0) + if (!sign && sfirst < 0) goto padding; /* Convert source integer if it's negative */ - if(H5T_SGN_2 == src.u.i.sign && sign) { - if(!is_max_neg) { + if (H5T_SGN_2 == src.u.i.sign && sign) { + if (!is_max_neg) { /* Equivalent to ~(i - 1) */ H5T__bit_dec(int_buf, (size_t)0, buf_size * 8); H5T__bit_neg(int_buf, (size_t)0, buf_size * 8); sfirst = H5T__bit_find(int_buf, (size_t)0, src.prec - 1, H5T_BIT_MSB, TRUE); - } else { + } + else { /* If it's maximal negative number 0x80...000, treat it as if it overflowed * (create a carry) to help conversion. i.e. a character type number 0x80 * is treated as 0x100. */ - sfirst = (ssize_t)(src.prec - 1); + sfirst = (ssize_t)(src.prec - 1); is_max_neg = 0; } - if(sfirst < 0) + if (sfirst < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "zero bit not found") /* Sign bit has been negated if bit vector isn't 0x80...00. Set all bits in front of @@ -9294,38 +9222,40 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the destination exponent bias. Implied and non-implied normalization * should be the same. */ - if (H5T_NORM_NONE==dst.u.f.norm || H5T_NORM_IMPLIED==dst.u.f.norm) { + if (H5T_NORM_NONE == dst.u.f.norm || H5T_NORM_IMPLIED == dst.u.f.norm) { expo = first + dst.u.f.ebias; } else { - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "normalization method not implemented yet") } /* Handle mantissa part here */ - if (H5T_NORM_IMPLIED==dst.u.f.norm) { + if (H5T_NORM_IMPLIED == dst.u.f.norm) { /* Imply first bit */ H5T__bit_set(int_buf, first, (size_t)1, 0); - } - else if (H5T_NORM_NONE==dst.u.f.norm) { - first++; - } + } + else if (H5T_NORM_NONE == dst.u.f.norm) { + first++; + } /* Roundup for mantissa */ - if(first > dst.u.f.msize) { + if (first > dst.u.f.msize) { /* If the bit sequence is bigger than the mantissa part, there'll be some * precision loss. Let user's handler deal with the case if it's present */ - if(cb_struct.func) { - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_HANDLED) { reverse = FALSE; goto padding; } - else if(except_ret == H5T_CONV_ABORT) + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") /* If user's exception handler does deal with it, we do it by dropping off the @@ -9335,66 +9265,71 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ /* Check 1st dropoff bit, see if it's set. */ - if(H5T__bit_get_d(int_buf, ((first - dst.u.f.msize) - 1), (size_t)1)) { - /* Check all bits after 1st dropoff bit, see if any of them is set. */ - if(((first - dst.u.f.msize) - 1) > 0 && H5T__bit_get_d(int_buf, (size_t)0, ((first - dst.u.f.msize) - 1))) + if (H5T__bit_get_d(int_buf, ((first - dst.u.f.msize) - 1), (size_t)1)) { + /* Check all bits after 1st dropoff bit, see if any of them is set. */ + if (((first - dst.u.f.msize) - 1) > 0 && + H5T__bit_get_d(int_buf, (size_t)0, ((first - dst.u.f.msize) - 1))) do_round = 1; - else { /* The .50...0 case */ + else { /* The .50...0 case */ /* Check if the least significant bit is odd. */ - if(H5T__bit_get_d(int_buf, (first - dst.u.f.msize), (size_t)1)) - do_round = 1; + if (H5T__bit_get_d(int_buf, (first - dst.u.f.msize), (size_t)1)) + do_round = 1; } - } + } /* Right shift to drop off extra bits */ H5T__bit_shift(int_buf, (ssize_t)(dst.u.f.msize - first), (size_t)0, buf_size * 8); - if(do_round) { + if (do_round) { H5T__bit_inc(int_buf, (size_t)0, buf_size * 8); do_round = 0; - /* If integer is like 0x0ff...fff and we need to round up the - * last f, we get 0x100...000. Treat this special case here. - */ - if(H5T__bit_get_d(int_buf, dst.u.f.msize, (size_t)1)) { - if (H5T_NORM_IMPLIED==dst.u.f.norm) { - /* The bit at this 1's position was impled already, so this - * number should be 0x200...000. We need to increment the - * exponent in this case. - */ - expo++; - } else if (H5T_NORM_NONE==dst.u.f.norm) { - /* Right shift 1 bit to let the carried 1 fit in the mantissa, - * and increment exponent by 1. - */ + /* If integer is like 0x0ff...fff and we need to round up the + * last f, we get 0x100...000. Treat this special case here. + */ + if (H5T__bit_get_d(int_buf, dst.u.f.msize, (size_t)1)) { + if (H5T_NORM_IMPLIED == dst.u.f.norm) { + /* The bit at this 1's position was impled already, so this + * number should be 0x200...000. We need to increment the + * exponent in this case. + */ + expo++; + } + else if (H5T_NORM_NONE == dst.u.f.norm) { + /* Right shift 1 bit to let the carried 1 fit in the mantissa, + * and increment exponent by 1. + */ H5T__bit_shift(int_buf, (ssize_t)-1, (size_t)0, buf_size * 8); - expo++; - } - } + expo++; + } + } } - } else { + } + else { /* The bit sequence can fit mantissa part. Left shift to fit in from high-order of - * bit position. */ + * bit position. */ H5T__bit_shift(int_buf, (ssize_t)(dst.u.f.msize - first), (size_t)0, dst.u.f.msize); } - /* Check if the exponent is too big */ - expo_max = (hsize_t) (HDpow((double)2.0f, (double)dst.u.f.esize) - 1); - - if(expo > expo_max) { /*overflows*/ - if(cb_struct.func) { /*user's exception handler. Reverse back source order*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); - - if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + expo_max = (hsize_t)(HDpow((double)2.0f, (double)dst.u.f.esize) - 1); + + if (expo > expo_max) { /*overflows*/ + if (cb_struct.func) { /*user's exception handler. Reverse back source order*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, + cb_struct.user_data); + + if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { reverse = FALSE; goto padding; } - } else { + } + else { /*make destination infinity by setting exponent to maximal number and *mantissa to zero.*/ expo = expo_max; @@ -9402,26 +9337,26 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { /* Set exponent in destination */ H5T__bit_set_d(d, dst.u.f.epos, dst.u.f.esize, expo); /* Copy mantissa into destination */ - H5T__bit_copy(d, dst.u.f.mpos, int_buf, (size_t)0, (buf_size * 8) > dst.u.f.msize ? dst.u.f.msize : buf_size * 8); + H5T__bit_copy(d, dst.u.f.mpos, int_buf, (size_t)0, + (buf_size * 8) > dst.u.f.msize ? dst.u.f.msize : buf_size * 8); } - padding: +padding: /* * Set padding areas in destination. */ - if(dst.offset > 0) { + if (dst.offset > 0) { HDassert(H5T_PAD_ZERO == dst.lsb_pad || H5T_PAD_ONE == dst.lsb_pad); - H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); + H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE == dst.lsb_pad)); } - if(dst.offset + dst.prec != 8 * dst_p->shared->size) { + if (dst.offset + dst.prec != 8 * dst_p->shared->size) { HDassert(H5T_PAD_ZERO == dst.msb_pad || H5T_PAD_ONE == dst.msb_pad); - H5T__bit_set(d, dst.offset + dst.prec, - 8 * dst_p->shared->size - (dst.offset + dst.prec), + H5T__bit_set(d, dst.offset + dst.prec, 8 * dst_p->shared->size - (dst.offset + dst.prec), (hbool_t)(H5T_PAD_ONE == dst.msb_pad)); } @@ -9429,26 +9364,27 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - d[dst_p->shared->size-(i+1)] = d[i]; - d[i] = tmp; + if (H5T_ORDER_BE == dst.order && reverse) { + half_size = dst_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + uint8_t tmp = d[dst_p->shared->size - (i + 1)]; + d[dst_p->shared->size - (i + 1)] = d[i]; + d[i] = tmp; } - } else if (H5T_ORDER_VAX==dst.order && reverse) { + } + else if (H5T_ORDER_VAX == dst.order && reverse) { tsize = dst_p->shared->size; HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = d[i]; - tmp2 = d[i+1]; + tmp2 = d[i + 1]; - d[i] = d[(tsize-2)-i]; - d[i+1] = d[(tsize-1)-i]; + d[i] = d[(tsize - 2) - i]; + d[i + 1] = d[(tsize - 1) - i]; - d[(tsize-2)-i] = tmp1; - d[(tsize-1)-i] = tmp2; + d[(tsize - 2) - i] = tmp1; + d[(tsize - 1) - i] = tmp2; } } @@ -9456,14 +9392,15 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if (d==dbuf) - H5MM_memcpy (dp, d, dst_p->shared->size); + if (d == dbuf) + H5MM_memcpy(dp, d, dst_p->shared->size); if (buf_stride) { - sp += direction * (ssize_t) buf_stride; - dp += direction * (ssize_t) buf_stride; - } else { - sp += direction * (ssize_t) src_p->shared->size; - dp += direction * (ssize_t) dst_p->shared->size; + sp += direction * (ssize_t)buf_stride; + dp += direction * (ssize_t)buf_stride; + } + else { + sp += direction * (ssize_t)src_p->shared->size; + dp += direction * (ssize_t)dst_p->shared->size; } HDmemset(int_buf, 0, buf_size); @@ -9476,15 +9413,14 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(int_buf) + if (int_buf) H5MM_xfree(int_buf); - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_i_f() */ - /*------------------------------------------------------------------------- * Function: H5T_reverse_order * @@ -9504,7 +9440,7 @@ done: static herr_t H5T_reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order) { - size_t i; + size_t i; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -9513,21 +9449,22 @@ H5T_reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order) if (H5T_ORDER_VAX == order) { for (i = 0; i < size; i += 2) { - rev[i] = s[(size - 2) - i]; + rev[i] = s[(size - 2) - i]; rev[i + 1] = s[(size - 1) - i]; } - } else if (H5T_ORDER_BE == order) { - for (i=0; ishared->type == H5T_REFERENCE) { - if(H5T_ref_reclaim(elem, dt) < 0) + if (dt->shared->type == H5T_REFERENCE) { + if (H5T_ref_reclaim(elem, dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim ref elements") - } else { + } + else { HDassert(op_data); /* Allow vlen reclaim to recurse into that routine */ - if(H5T_vlen_reclaim(elem, dt, (H5T_vlen_alloc_info_t *)op_data) < 0) + if (H5T_vlen_reclaim(elem, dt, (H5T_vlen_alloc_info_t *)op_data) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") } diff --git a/src/H5Tcset.c b/src/H5Tcset.c index 186e598..43f85e6 100644 --- a/src/H5Tcset.c +++ b/src/H5Tcset.c @@ -16,15 +16,13 @@ * the character set (cset) for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5Tpkg.h" /*data-type functions */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5Tpkg.h" /*data-type functions */ - - /*------------------------------------------------------------------------- * Function: H5Tget_cset * @@ -48,22 +46,23 @@ H5T_cset_t H5Tget_cset(hid_t type_id) { - H5T_t *dt; - H5T_cset_t ret_value; + H5T_t * dt; + H5T_cset_t ret_value; FUNC_ENTER_API(H5T_CSET_ERROR) H5TRACE1("Tc", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, "not a data type") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, "not a data type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) - dt = dt->shared->parent; /*defer to parent*/ + dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_CSET_ERROR, "operation not defined for data type class") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_CSET_ERROR, + "operation not defined for data type class") /* result */ - if(H5T_IS_FIXED_STRING(dt->shared)) + if (H5T_IS_FIXED_STRING(dt->shared)) ret_value = dt->shared->u.atomic.u.s.cset; else ret_value = dt->shared->u.vlen.cset; @@ -72,7 +71,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tset_cset * @@ -94,26 +92,26 @@ done: herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset) { - H5T_t *dt; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTc", type_id, cset); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (cset < H5T_CSET_ASCII || cset >= H5T_NCSET) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal character set type") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal character set type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) - dt = dt->shared->parent; /*defer to parent*/ + dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for data type class") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for data type class") /* Commit */ - if(H5T_IS_FIXED_STRING(dt->shared)) + if (H5T_IS_FIXED_STRING(dt->shared)) dt->shared->u.atomic.u.s.cset = cset; else dt->shared->u.vlen.cset = cset; @@ -121,4 +119,3 @@ H5Tset_cset(hid_t type_id, H5T_cset_t cset) done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Tdbg.c b/src/H5Tdbg.c index 6188138..9dae22d 100644 --- a/src/H5Tdbg.c +++ b/src/H5Tdbg.c @@ -26,53 +26,43 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5T__print_stats * @@ -93,26 +83,24 @@ *------------------------------------------------------------------------- */ herr_t -H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/*in,out*/) +H5T__print_stats(H5T_path_t H5_ATTR_UNUSED *path, int H5_ATTR_UNUSED *nprint /*in,out*/) { FUNC_ENTER_PACKAGE_NOERR #ifdef H5T_DEBUG - if(H5DEBUG(T) && path->stats.ncalls > 0) { - hsize_t nbytes; + if (H5DEBUG(T) && path->stats.ncalls > 0) { + hsize_t nbytes; char bandwidth[32]; - if(nprint && 0 == (*nprint)++) { - HDfprintf(H5DEBUG(T), "H5T: type conversion statistics:\n"); - HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", - "Conversion", "Elmts", "Calls", "User", - "System", "Elapsed", "Bandwidth"); - HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", - "----------", "-----", "-----", "----", - "------", "-------", "---------"); - } /* end if */ + if (nprint && 0 == (*nprint)++) { + HDfprintf(H5DEBUG(T), "H5T: type conversion statistics:\n"); + HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", "Conversion", "Elmts", "Calls", + "User", "System", "Elapsed", "Bandwidth"); + HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", "----------", "-----", "-----", + "----", "------", "-------", "---------"); + } /* end if */ - if(path->src && path->dst) + if (path->src && path->dst) nbytes = MAX(H5T_get_size(path->src), H5T_get_size(path->dst)); else if (path->src) nbytes = H5T_get_size(path->src); @@ -121,23 +109,17 @@ H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/* else nbytes = 0; - nbytes *= path->stats.nelmts; + nbytes *= path->stats.nelmts; H5_bandwidth(bandwidth, (double)nbytes, path->stats.times.elapsed); - HDfprintf(H5DEBUG(T), " %-16s %10Hd %10d %8T %8T %8T %10s\n", - path->name, - path->stats.nelmts, - path->stats.ncalls, - path->stats.times.user, - path->stats.times.system, - path->stats.times.elapsed, - bandwidth); + HDfprintf(H5DEBUG(T), " %-16s %10Hd %10d %8T %8T %8T %10s\n", path->name, path->stats.nelmts, + path->stats.ncalls, path->stats.times.user, path->stats.times.system, + path->stats.times.elapsed, bandwidth); } /* end if */ #endif FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__print_stats() */ - /*------------------------------------------------------------------------- * Function: H5T_debug * @@ -150,10 +132,10 @@ H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/* herr_t H5T_debug(const H5T_t *dt, FILE *stream) { - const char *s1 = ""; - const char *s2 = ""; + const char *s1 = ""; + const char *s2 = ""; unsigned i; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -199,7 +181,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; case H5T_VLEN: - if(H5T_IS_VL_STRING(dt->shared)) + if (H5T_IS_VL_STRING(dt->shared)) s1 = "str"; else s1 = "vlen"; @@ -211,7 +193,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) default: s1 = ""; break; - } /* end switch */ + } /* end switch */ switch (dt->shared->state) { case H5T_STATE_TRANSIENT: @@ -235,12 +217,12 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; default: HDassert(0 && "This Should never be executed!"); - } /* end switch */ + } /* end switch */ HDfprintf(stream, "%s%s {nbytes=%lu", s1, s2, (unsigned long)(dt->shared->size)); if (H5T_IS_ATOMIC(dt->shared)) { - uint64_t tmp; + uint64_t tmp; switch (dt->shared->u.atomic.order) { case H5T_ORDER_ERROR: @@ -272,9 +254,9 @@ H5T_debug(const H5T_t *dt, FILE *stream) HDfprintf(stream, ", %s", s1); if (dt->shared->u.atomic.offset) - HDfprintf(stream, ", offset=%lu", (unsigned long) (dt->shared->u.atomic.offset)); + HDfprintf(stream, ", offset=%lu", (unsigned long)(dt->shared->u.atomic.offset)); if (dt->shared->u.atomic.prec != 8 * dt->shared->size) - HDfprintf(stream, ", prec=%lu", (unsigned long) (dt->shared->u.atomic.prec)); + HDfprintf(stream, ", prec=%lu", (unsigned long)(dt->shared->u.atomic.prec)); switch (dt->shared->type) { case H5T_NO_CLASS: @@ -282,7 +264,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; case H5T_INTEGER: - switch(dt->shared->u.atomic.u.i.sign) { + switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_ERROR: HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "sign error"); break; @@ -301,12 +283,12 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } /* end switch */ - if(s1) + if (s1) HDfprintf(stream, ", %s", s1); break; case H5T_FLOAT: - switch(dt->shared->u.atomic.u.f.norm) { + switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_ERROR: HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "norm error"); break; @@ -328,20 +310,16 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } /* end switch */ - HDfprintf(stream, ", sign=%lu+1", - (unsigned long)(dt->shared->u.atomic.u.f.sign)); - HDfprintf(stream, ", mant=%lu+%lu (%s)", - (unsigned long)(dt->shared->u.atomic.u.f.mpos), - (unsigned long)(dt->shared->u.atomic.u.f.msize), s1); - HDfprintf(stream, ", exp=%lu+%lu", - (unsigned long)(dt->shared->u.atomic.u.f.epos), - (unsigned long)(dt->shared->u.atomic.u.f.esize)); + HDfprintf(stream, ", sign=%lu+1", (unsigned long)(dt->shared->u.atomic.u.f.sign)); + HDfprintf(stream, ", mant=%lu+%lu (%s)", (unsigned long)(dt->shared->u.atomic.u.f.mpos), + (unsigned long)(dt->shared->u.atomic.u.f.msize), s1); + HDfprintf(stream, ", exp=%lu+%lu", (unsigned long)(dt->shared->u.atomic.u.f.epos), + (unsigned long)(dt->shared->u.atomic.u.f.esize)); tmp = dt->shared->u.atomic.u.f.ebias >> 32; if (tmp) { size_t hi = (size_t)tmp; size_t lo = (size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff); - HDfprintf(stream, " bias=0x%08lx%08lx", - (unsigned long)hi, (unsigned long)lo); + HDfprintf(stream, " bias=0x%08lx%08lx", (unsigned long)hi, (unsigned long)lo); } else { size_t lo = (size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff); @@ -367,9 +345,8 @@ H5T_debug(const H5T_t *dt, FILE *stream) else if (H5T_COMPOUND == dt->shared->type) { /* Compound data type */ for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { - HDfprintf(stream, "\n\"%s\" @%lu", - dt->shared->u.compnd.memb[i].name, - (unsigned long)(dt->shared->u.compnd.memb[i].offset)); + HDfprintf(stream, "\n\"%s\" @%lu", dt->shared->u.compnd.memb[i].name, + (unsigned long)(dt->shared->u.compnd.memb[i].offset)); HDfprintf(stream, " "); H5T_debug(dt->shared->u.compnd.memb[i].type, stream); } /* end for */ @@ -406,14 +383,14 @@ H5T_debug(const H5T_t *dt, FILE *stream) } /* end else */ } else if (H5T_ENUM == dt->shared->type) { - size_t base_size; + size_t base_size; /* Enumeration data type */ HDfprintf(stream, " "); H5T_debug(dt->shared->parent, stream); base_size = dt->shared->parent->shared->size; for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { - size_t k; + size_t k; HDfprintf(stream, "\n\"%s\" = 0x", dt->shared->u.enumer.name[i]); for (k = 0; k < base_size; k++) @@ -433,4 +410,3 @@ H5T_debug(const H5T_t *dt, FILE *stream) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_debug() */ - diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 2c98dc0..69714a9 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -29,53 +29,45 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppublic.h" /* Property Lists */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppublic.h" /* Property Lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -86,9 +78,8 @@ H5FL_EXTERN(H5VL_t); /* Declare a free list to manage the H5VL_object_t struct */ H5FL_EXTERN(H5VL_object_t); - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Tcommit1 * @@ -107,45 +98,46 @@ H5FL_EXTERN(H5VL_object_t); herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) { - void *data = NULL; /* VOL-managed datatype data */ - H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ - H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + void * data = NULL; /* VOL-managed datatype data */ + H5VL_object_t * new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t * dt = NULL; /* High level datatype object that wraps the VOL object */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*si", loc_id, name, type_id); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_is_named(dt)) + if (H5T_is_named(dt)) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); /* get the object from the loc_id */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Commit the datatype */ - if(NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, H5P_LINK_CREATE_DEFAULT, - H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, H5P_LINK_CREATE_DEFAULT, + H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Set up VOL object */ - if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) + if (NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "can't allocate top object structure") new_obj->connector = vol_obj->connector; - new_obj->connector->nrefs ++; + new_obj->connector->nrefs++; new_obj->data = data; /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ @@ -155,7 +147,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit1() */ - /*------------------------------------------------------------------------- * Function: H5Topen1 * @@ -175,40 +166,40 @@ done: hid_t H5Topen1(hid_t loc_id, const char *name) { - void *dt = NULL; /* Datatype object created by VOL connector */ - H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + void * dt = NULL; /* Datatype object created by VOL connector */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") - loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the datatype */ - if(NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, H5P_DATATYPE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, H5P_DATATYPE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ - if((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: /* Cleanup on error */ - if(H5I_INVALID_HID == ret_value) - if(dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5I_INVALID_HID == ret_value) + if (dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to close datatype") FUNC_LEAVE_API(ret_value) } /* end H5Topen1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Tenum.c b/src/H5Tenum.c index 6daa497..f2247bf 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -16,23 +16,18 @@ * in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5MMprivate.h" /*memory management */ -#include "H5Tpkg.h" /*data-type functions */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5MMprivate.h" /*memory management */ +#include "H5Tpkg.h" /*data-type functions */ /* Static local functions */ -static char *H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, - size_t size); -static herr_t H5T_enum_valueof(const H5T_t *dt, const char *name, - void *value/*out*/); - +static char * H5T_enum_nameof(const H5T_t *dt, const void *value, char *name /*out*/, size_t size); +static herr_t H5T_enum_valueof(const H5T_t *dt, const char *name, void *value /*out*/); - /*------------------------------------------------------------------------- * Function: H5Tenum_create * @@ -51,30 +46,30 @@ static herr_t H5T_enum_valueof(const H5T_t *dt, const char *name, hid_t H5Tenum_create(hid_t parent_id) { - H5T_t *parent = NULL; /*base integer data type */ - H5T_t *dt = NULL; /*new enumeration data type */ - hid_t ret_value; /*return value */ + H5T_t *parent = NULL; /*base integer data type */ + H5T_t *dt = NULL; /*new enumeration data type */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", parent_id); /* Check args */ - if(NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || H5T_INTEGER != parent->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an integer data type") + if (NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || + H5T_INTEGER != parent->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an integer data type") /* Build new type */ - if(NULL == (dt = H5T__enum_create(parent))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "cannot create enum type") + if (NULL == (dt = H5T__enum_create(parent))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "cannot create enum type") /* Atomize the type */ - if ((ret_value=H5I_register(H5I_DATATYPE, dt, TRUE))<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register data type atom") + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register data type atom") done: FUNC_LEAVE_API(ret_value) } /* end H5Tenum_create() */ - /*------------------------------------------------------------------------- * Function: H5T__enum_create * @@ -96,16 +91,16 @@ done: H5T_t * H5T__enum_create(const H5T_t *parent) { - H5T_t *ret_value = NULL; /* New enumeration data type */ + H5T_t *ret_value = NULL; /* New enumeration data type */ FUNC_ENTER_PACKAGE HDassert(parent); /* Build new type */ - if(NULL == (ret_value = H5T__alloc())) + if (NULL == (ret_value = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - ret_value->shared->type = H5T_ENUM; + ret_value->shared->type = H5T_ENUM; ret_value->shared->parent = H5T_copy(parent, H5T_COPY_ALL); HDassert(ret_value->shared->parent); ret_value->shared->size = ret_value->shared->parent->shared->size; @@ -114,7 +109,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tenum_insert * @@ -139,31 +133,30 @@ done: herr_t H5Tenum_insert(hid_t type, const char *name, const void *value) { - H5T_t *dt=NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*x", type, name, value); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5T_ENUM != dt->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_ENUM != dt->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified") /* Do work */ - if(H5T__enum_insert(dt, name, value) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member") + if (H5T__enum_insert(dt, name, value) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__enum_insert * @@ -186,8 +179,8 @@ done: herr_t H5T__enum_insert(const H5T_t *dt, const char *name, const void *value) { - unsigned i; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -196,32 +189,33 @@ H5T__enum_insert(const H5T_t *dt, const char *name, const void *value) HDassert(value); /* The name and value had better not already exist */ - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) { - if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition") - if(!HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (i * dt->shared->size), value, dt->shared->size)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition") + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { + if (!HDstrcmp(dt->shared->u.enumer.name[i], name)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition") + if (!HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (i * dt->shared->size), value, + dt->shared->size)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition") } /* end for */ /* Increase table sizes */ - if(dt->shared->u.enumer.nmembs >= dt->shared->u.enumer.nalloc) { - char **names; - uint8_t *values; - unsigned n = MAX(32, 2*dt->shared->u.enumer.nalloc); - - if(NULL == (names = (char **)H5MM_realloc(dt->shared->u.enumer.name, n * sizeof(char *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - dt->shared->u.enumer.name = names; - - if(NULL == (values = (uint8_t *)H5MM_realloc(dt->shared->u.enumer.value, n * dt->shared->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - dt->shared->u.enumer.value = values; - dt->shared->u.enumer.nalloc = n; + if (dt->shared->u.enumer.nmembs >= dt->shared->u.enumer.nalloc) { + char ** names; + uint8_t *values; + unsigned n = MAX(32, 2 * dt->shared->u.enumer.nalloc); + + if (NULL == (names = (char **)H5MM_realloc(dt->shared->u.enumer.name, n * sizeof(char *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + dt->shared->u.enumer.name = names; + + if (NULL == (values = (uint8_t *)H5MM_realloc(dt->shared->u.enumer.value, n * dt->shared->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + dt->shared->u.enumer.value = values; + dt->shared->u.enumer.nalloc = n; } /* end for */ /* Insert new member at end of member arrays */ - dt->shared->u.enumer.sorted = H5T_SORT_NONE; - i = dt->shared->u.enumer.nmembs++; + dt->shared->u.enumer.sorted = H5T_SORT_NONE; + i = dt->shared->u.enumer.nmembs++; dt->shared->u.enumer.name[i] = H5MM_xstrdup(name); H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (i * dt->shared->size), value, dt->shared->size); @@ -229,7 +223,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tget_member_value * @@ -248,30 +241,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Tget_member_value(hid_t type, unsigned membno, void *value/*out*/) +H5Tget_member_value(hid_t type, unsigned membno, void *value /*out*/) { - H5T_t *dt=NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIux", type, membno, value); - if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5T_ENUM != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class") - if (membno>=dt->shared->u.enumer.nmembs) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_ENUM != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class") + if (membno >= dt->shared->u.enumer.nmembs) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer") - if(H5T__get_member_value(dt, membno, value) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get member value") + if (H5T__get_member_value(dt, membno, value) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get member value") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__get_member_value * @@ -291,7 +283,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) +H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value /*out*/) { FUNC_ENTER_PACKAGE_NOERR @@ -303,8 +295,6 @@ H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) FUNC_LEAVE_NOAPI(SUCCEED) } - - /*------------------------------------------------------------------------- * Function: H5Tenum_nameof * @@ -328,32 +318,31 @@ H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, size_t size) +H5Tenum_nameof(hid_t type, const void *value, char *name /*out*/, size_t size) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*xxz", type, value, name, size); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5T_ENUM != dt->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_ENUM != dt->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied") if (!name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied") - if (NULL==H5T_enum_nameof(dt, value, name, size)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed") + if (NULL == H5T_enum_nameof(dt, value, name, size)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T_enum_nameof * @@ -383,13 +372,13 @@ done: *------------------------------------------------------------------------- */ static char * -H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, size_t size) +H5T_enum_nameof(const H5T_t *dt, const void *value, char *name /*out*/, size_t size) { - H5T_t *copied_dt = NULL; /* Do sorting in copied datatype */ - unsigned lt, md = 0, rt; /* Indices for binary search */ - int cmp = (-1); /* Comparison result */ - hbool_t alloc_name = FALSE; /* Whether name has been allocated */ - char *ret_value = NULL; /* Return value */ + H5T_t * copied_dt = NULL; /* Do sorting in copied datatype */ + unsigned lt, md = 0, rt; /* Indices for binary search */ + int cmp = (-1); /* Comparison result */ + hbool_t alloc_name = FALSE; /* Whether name has been allocated */ + char * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -398,62 +387,61 @@ H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, size_t si HDassert(value); HDassert(name || 0 == size); - if(name && size > 0) + if (name && size > 0) *name = '\0'; /* Sanity check */ - if(dt->shared->u.enumer.nmembs == 0) + if (dt->shared->u.enumer.nmembs == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "datatype has no members") /* Do a binary search over the values to find the correct one. Do sorting * and search on the copied datatype to protect the original order. */ - if(NULL == (copied_dt = H5T_copy(dt, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy data type") - if(H5T__sort_value(copied_dt, NULL) < 0) + if (NULL == (copied_dt = H5T_copy(dt, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy data type") + if (H5T__sort_value(copied_dt, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOMPARE, NULL, "value sort failed") lt = 0; rt = copied_dt->shared->u.enumer.nmembs; - while(lt < rt) { - md = (lt + rt) / 2; - cmp = HDmemcmp(value, (uint8_t *)copied_dt->shared->u.enumer.value + (md * copied_dt->shared->size), copied_dt->shared->size); - if(cmp < 0) - rt = md; - else if(cmp > 0) - lt = md + 1; - else - break; + while (lt < rt) { + md = (lt + rt) / 2; + cmp = HDmemcmp(value, (uint8_t *)copied_dt->shared->u.enumer.value + (md * copied_dt->shared->size), + copied_dt->shared->size); + if (cmp < 0) + rt = md; + else if (cmp > 0) + lt = md + 1; + else + break; } /* end while */ /* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */ - if(cmp != 0) + if (cmp != 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "value is currently not defined") /* Save result name */ - if(!name) { - if(NULL == (name = (char *)H5MM_malloc( - HDstrlen(copied_dt->shared->u.enumer.name[md]) + 1))) + if (!name) { + if (NULL == (name = (char *)H5MM_malloc(HDstrlen(copied_dt->shared->u.enumer.name[md]) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); alloc_name = TRUE; } /* end if */ HDstrncpy(name, copied_dt->shared->u.enumer.name[md], size); - if(HDstrlen(copied_dt->shared->u.enumer.name[md]) >= size) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated") + if (HDstrlen(copied_dt->shared->u.enumer.name[md]) >= size) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated") /* Set return value */ ret_value = name; done: - if(copied_dt) - if(H5T_close_real(copied_dt) < 0) + if (copied_dt) + if (H5T_close_real(copied_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close data type"); - if(!ret_value && alloc_name) + if (!ret_value && alloc_name) H5MM_free(name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_enum_nameof() */ - /*------------------------------------------------------------------------- * Function: H5Tenum_valueof * @@ -477,32 +465,31 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/) +H5Tenum_valueof(hid_t type, const char *name, void *value /*out*/) { - H5T_t *dt; - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*sx", type, name, value); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5T_ENUM != dt->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer") - - if(H5T_enum_valueof(dt, name, value) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_ENUM != dt->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if (!value) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer") + + if (H5T_enum_valueof(dt, name, value) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed") done: FUNC_LEAVE_API(ret_value) } /* H5Tenum_valueof() */ - /*------------------------------------------------------------------------- * Function: H5T_enum_valueof * @@ -526,17 +513,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T_enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/) +H5T_enum_valueof(const H5T_t *dt, const char *name, void *value /*out*/) { - unsigned lt, md=0, rt; /*indices for binary search */ - int cmp=(-1); /*comparison result */ - H5T_t *copied_dt = NULL; /*do sorting in copied datatype */ - herr_t ret_value=SUCCEED; /* Return value */ + unsigned lt, md = 0, rt; /*indices for binary search */ + int cmp = (-1); /*comparison result */ + H5T_t * copied_dt = NULL; /*do sorting in copied datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check args */ - HDassert(dt && H5T_ENUM==dt->shared->type); + HDassert(dt && H5T_ENUM == dt->shared->type); HDassert(name && *name); HDassert(value); @@ -546,36 +533,38 @@ H5T_enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/) /* Do a binary search over the names to find the correct one. Do sorting * and search on the copied datatype to protect the original order. */ - if (NULL==(copied_dt=H5T_copy(dt, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type"); - if(H5T__sort_name(copied_dt, NULL) < 0) + if (NULL == (copied_dt = H5T_copy(dt, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type"); + if (H5T__sort_name(copied_dt, NULL) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") lt = 0; rt = copied_dt->shared->u.enumer.nmembs; - while (ltshared->u.enumer.name[md]); - if (cmp<0) { - rt = md; - } else if (cmp>0) { - lt = md+1; - } else { - break; - } + while (lt < rt) { + md = (lt + rt) / 2; + cmp = HDstrcmp(name, copied_dt->shared->u.enumer.name[md]); + if (cmp < 0) { + rt = md; + } + else if (cmp > 0) { + lt = md + 1; + } + else { + break; + } } /* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */ - if (cmp!=0) + if (cmp != 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type") - H5MM_memcpy(value, (uint8_t *)copied_dt->shared->u.enumer.value + (md * copied_dt->shared->size), copied_dt->shared->size); + H5MM_memcpy(value, (uint8_t *)copied_dt->shared->u.enumer.value + (md * copied_dt->shared->size), + copied_dt->shared->size); done: - if(copied_dt) - if(H5T_close_real(copied_dt) < 0) + if (copied_dt) + if (H5T_close_real(copied_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close data type") FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Tfields.c b/src/H5Tfields.c index be0b5f2..37e3941 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -16,16 +16,14 @@ * enumerated & compound datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5MMprivate.h" /*memory management */ +#include "H5Tpkg.h" /*data-type functions */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5MMprivate.h" /*memory management */ -#include "H5Tpkg.h" /*data-type functions */ - - /*------------------------------------------------------------------------- * Function: H5Tget_nmembers * @@ -49,24 +47,23 @@ int H5Tget_nmembers(hid_t type_id) { - H5T_t *dt; /* Datatype to query */ - int ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if((ret_value = H5T_get_nmembers(dt)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot return member number") + if ((ret_value = H5T_get_nmembers(dt)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot return member number") done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_nmembers() */ - /*------------------------------------------------------------------------- * Function: H5T_get_nmembers * @@ -90,24 +87,23 @@ done: int H5T_get_nmembers(const H5T_t *dt) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(dt); - if(H5T_COMPOUND == dt->shared->type) - ret_value = (int)dt->shared->u.compnd.nmembs; - else if(H5T_ENUM == dt->shared->type) - ret_value = (int)dt->shared->u.enumer.nmembs; + if (H5T_COMPOUND == dt->shared->type) + ret_value = (int)dt->shared->u.compnd.nmembs; + else if (H5T_ENUM == dt->shared->type) + ret_value = (int)dt->shared->u.enumer.nmembs; else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for type class") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for type class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_nmembers() */ - /*------------------------------------------------------------------------- * Function: H5Tget_member_name * @@ -132,24 +128,23 @@ done: char * H5Tget_member_name(hid_t type_id, unsigned membno) { - H5T_t *dt = NULL; - char *ret_value; + H5T_t *dt = NULL; + char * ret_value; FUNC_ENTER_API(NULL) H5TRACE2("*s", "iIu", type_id, membno); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - if(NULL == (ret_value = H5T__get_member_name(dt, membno))) + if (NULL == (ret_value = H5T__get_member_name(dt, membno))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get member name") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__get_member_name * @@ -172,7 +167,7 @@ done: char * H5T__get_member_name(H5T_t const *dt, unsigned membno) { - char *ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -180,13 +175,13 @@ H5T__get_member_name(H5T_t const *dt, unsigned membno) switch (dt->shared->type) { case H5T_COMPOUND: - if (membno>=dt->shared->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number") ret_value = H5MM_xstrdup(dt->shared->u.compnd.memb[membno].name); break; case H5T_ENUM: - if (membno>=dt->shared->u.enumer.nmembs) + if (membno >= dt->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number") ret_value = H5MM_xstrdup(dt->shared->u.enumer.name[membno]); break; @@ -210,7 +205,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tget_member_index * @@ -232,28 +226,28 @@ done: int H5Tget_member_index(hid_t type_id, const char *name) { - H5T_t *dt = NULL; - int ret_value=FAIL; - unsigned i; + H5T_t * dt = NULL; + int ret_value = FAIL; + unsigned i; FUNC_ENTER_API(FAIL) H5TRACE2("Is", "i*s", type_id, name); /* Check arguments */ HDassert(name); - if(NULL == (dt = (H5T_t*)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Locate member by name */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) - if(!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) + if (!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) HGOTO_DONE((int)i) break; case H5T_ENUM: - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) - if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) + if (!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_DONE((int)i) break; @@ -276,7 +270,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_index() */ - /*------------------------------------------------------------------------- * Function: H5T__sort_value * @@ -296,12 +289,12 @@ done: herr_t H5T__sort_value(const H5T_t *dt, int *map) { - unsigned nmembs; /* Number of members for datatype */ - size_t size; - hbool_t swapped; /* Whether we've swapped fields */ - uint8_t tbuf[32]; - unsigned i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nmembs; /* Number of members for datatype */ + size_t size; + hbool_t swapped; /* Whether we've swapped fields */ + uint8_t tbuf[32]; + unsigned i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -310,76 +303,78 @@ H5T__sort_value(const H5T_t *dt, int *map) HDassert(H5T_COMPOUND == dt->shared->type || H5T_ENUM == dt->shared->type); /* Use a bubble sort because we can short circuit */ - if(H5T_COMPOUND == dt->shared->type) { - if(H5T_SORT_VALUE != dt->shared->u.compnd.sorted) { - dt->shared->u.compnd.sorted = H5T_SORT_VALUE; - nmembs = dt->shared->u.compnd.nmembs; - for(i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) { - for(j = 0, swapped = FALSE; j < i; j++) { - if(dt->shared->u.compnd.memb[j].offset > dt->shared->u.compnd.memb[j + 1].offset) { - H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; - dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j + 1]; - dt->shared->u.compnd.memb[j + 1] = tmp; - if(map) { - int x = map[j]; - - map[j] = map[j + 1]; - map[j + 1] = x; - } /* end if */ - swapped = TRUE; - } /* end if */ - } /* end for */ - } /* end for */ + if (H5T_COMPOUND == dt->shared->type) { + if (H5T_SORT_VALUE != dt->shared->u.compnd.sorted) { + dt->shared->u.compnd.sorted = H5T_SORT_VALUE; + nmembs = dt->shared->u.compnd.nmembs; + for (i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) { + for (j = 0, swapped = FALSE; j < i; j++) { + if (dt->shared->u.compnd.memb[j].offset > dt->shared->u.compnd.memb[j + 1].offset) { + H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; + dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j + 1]; + dt->shared->u.compnd.memb[j + 1] = tmp; + if (map) { + int x = map[j]; + + map[j] = map[j + 1]; + map[j + 1] = x; + } /* end if */ + swapped = TRUE; + } /* end if */ + } /* end for */ + } /* end for */ #ifndef NDEBUG - /* I never trust a sort :-) -RPM */ - for(i = 0; i < (nmembs - 1); i++) - HDassert(dt->shared->u.compnd.memb[i].offset < dt->shared->u.compnd.memb[i + 1].offset); + /* I never trust a sort :-) -RPM */ + for (i = 0; i < (nmembs - 1); i++) + HDassert(dt->shared->u.compnd.memb[i].offset < dt->shared->u.compnd.memb[i + 1].offset); #endif - } /* end if */ - } else if(H5T_ENUM == dt->shared->type) { - if(H5T_SORT_VALUE != dt->shared->u.enumer.sorted) { - dt->shared->u.enumer.sorted = H5T_SORT_VALUE; - nmembs = dt->shared->u.enumer.nmembs; - size = dt->shared->size; - HDassert(size <= sizeof(tbuf)); - for(i = (nmembs - 1), swapped = TRUE; i > 0 && swapped; --i) { - for(j = 0, swapped = FALSE; j < i; j++) { - if(HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (j * size), (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size) > 0) { - /* Swap names */ - char *tmp = dt->shared->u.enumer.name[j]; - dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j + 1]; - dt->shared->u.enumer.name[j + 1] = tmp; - - /* Swap values */ - H5MM_memcpy(tbuf, (uint8_t *)dt->shared->u.enumer.value + (j * size), size); - H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (j * size), - (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size); - H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size); - - /* Swap map */ - if(map) { - int x = map[j]; - - map[j] = map[j + 1]; - map[j + 1] = x; - } /* end if */ - - swapped = TRUE; - } /* end if */ - } /* end for */ - } /* end for */ + } /* end if */ + } + else if (H5T_ENUM == dt->shared->type) { + if (H5T_SORT_VALUE != dt->shared->u.enumer.sorted) { + dt->shared->u.enumer.sorted = H5T_SORT_VALUE; + nmembs = dt->shared->u.enumer.nmembs; + size = dt->shared->size; + HDassert(size <= sizeof(tbuf)); + for (i = (nmembs - 1), swapped = TRUE; i > 0 && swapped; --i) { + for (j = 0, swapped = FALSE; j < i; j++) { + if (HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (j * size), + (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size) > 0) { + /* Swap names */ + char *tmp = dt->shared->u.enumer.name[j]; + dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j + 1]; + dt->shared->u.enumer.name[j + 1] = tmp; + + /* Swap values */ + H5MM_memcpy(tbuf, (uint8_t *)dt->shared->u.enumer.value + (j * size), size); + H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (j * size), + (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size); + H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size); + + /* Swap map */ + if (map) { + int x = map[j]; + + map[j] = map[j + 1]; + map[j + 1] = x; + } /* end if */ + + swapped = TRUE; + } /* end if */ + } /* end for */ + } /* end for */ #ifndef NDEBUG - /* I never trust a sort :-) -RPM */ - for(i = 0; i < (nmembs - 1); i++) - HDassert(HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (i * size), (uint8_t *)dt->shared->u.enumer.value + ((i + 1) * size), size) < 0); + /* I never trust a sort :-) -RPM */ + for (i = 0; i < (nmembs - 1); i++) + HDassert(HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (i * size), + (uint8_t *)dt->shared->u.enumer.value + ((i + 1) * size), size) < 0); #endif - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__sort_value() */ - /*------------------------------------------------------------------------- * Function: H5T__sort_name * @@ -401,86 +396,85 @@ H5T__sort_value(const H5T_t *dt, int *map) herr_t H5T__sort_name(const H5T_t *dt, int *map) { - unsigned i, j, nmembs; - size_t size; - hbool_t swapped; - uint8_t tbuf[32]; + unsigned i, j, nmembs; + size_t size; + hbool_t swapped; + uint8_t tbuf[32]; FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(dt); - HDassert(H5T_COMPOUND==dt->shared->type || H5T_ENUM==dt->shared->type); + HDassert(H5T_COMPOUND == dt->shared->type || H5T_ENUM == dt->shared->type); /* Use a bubble sort because we can short circuit */ - if (H5T_COMPOUND==dt->shared->type) { - if (H5T_SORT_NAME!=dt->shared->u.compnd.sorted) { - dt->shared->u.compnd.sorted = H5T_SORT_NAME; - nmembs = dt->shared->u.compnd.nmembs; - for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { - for (j=0, swapped=FALSE; jshared->u.compnd.memb[j].name, - dt->shared->u.compnd.memb[j+1].name)>0) { - H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; - dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j+1]; - dt->shared->u.compnd.memb[j+1] = tmp; - swapped = TRUE; - if (map) { - int x = map[j]; - map[j] = map[j+1]; - map[j+1] = x; - } - } - } - } + if (H5T_COMPOUND == dt->shared->type) { + if (H5T_SORT_NAME != dt->shared->u.compnd.sorted) { + dt->shared->u.compnd.sorted = H5T_SORT_NAME; + nmembs = dt->shared->u.compnd.nmembs; + for (i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) { + for (j = 0, swapped = FALSE; j < i; j++) { + if (HDstrcmp(dt->shared->u.compnd.memb[j].name, dt->shared->u.compnd.memb[j + 1].name) > + 0) { + H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; + dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j + 1]; + dt->shared->u.compnd.memb[j + 1] = tmp; + swapped = TRUE; + if (map) { + int x = map[j]; + map[j] = map[j + 1]; + map[j + 1] = x; + } + } + } + } #ifndef NDEBUG - /* I never trust a sort :-) -RPM */ - for (i=0; ishared->u.compnd.memb[i].name, - dt->shared->u.compnd.memb[i+1].name)<0); - } + /* I never trust a sort :-) -RPM */ + for (i = 0; i < nmembs - 1; i++) { + HDassert(HDstrcmp(dt->shared->u.compnd.memb[i].name, dt->shared->u.compnd.memb[i + 1].name) < + 0); + } #endif - } - } else if (H5T_ENUM==dt->shared->type) { - if (H5T_SORT_NAME!=dt->shared->u.enumer.sorted) { - dt->shared->u.enumer.sorted = H5T_SORT_NAME; - nmembs = dt->shared->u.enumer.nmembs; - size = dt->shared->size; - HDassert(size<=sizeof(tbuf)); - for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { - for (j=0, swapped=FALSE; jshared->u.enumer.name[j], - dt->shared->u.enumer.name[j+1])>0) { - /* Swap names */ - char *tmp = dt->shared->u.enumer.name[j]; - dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j+1]; - dt->shared->u.enumer.name[j+1] = tmp; - - /* Swap values */ - H5MM_memcpy(tbuf, (uint8_t *)dt->shared->u.enumer.value + (j * size), size); - H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (j * size), - (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size); - H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size); - - /* Swap map */ - if (map) { - int x = map[j]; - map[j] = map[j+1]; - map[j+1] = x; - } - - swapped = TRUE; - } - } - } + } + } + else if (H5T_ENUM == dt->shared->type) { + if (H5T_SORT_NAME != dt->shared->u.enumer.sorted) { + dt->shared->u.enumer.sorted = H5T_SORT_NAME; + nmembs = dt->shared->u.enumer.nmembs; + size = dt->shared->size; + HDassert(size <= sizeof(tbuf)); + for (i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) { + for (j = 0, swapped = FALSE; j < i; j++) { + if (HDstrcmp(dt->shared->u.enumer.name[j], dt->shared->u.enumer.name[j + 1]) > 0) { + /* Swap names */ + char *tmp = dt->shared->u.enumer.name[j]; + dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j + 1]; + dt->shared->u.enumer.name[j + 1] = tmp; + + /* Swap values */ + H5MM_memcpy(tbuf, (uint8_t *)dt->shared->u.enumer.value + (j * size), size); + H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (j * size), + (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size); + H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size); + + /* Swap map */ + if (map) { + int x = map[j]; + map[j] = map[j + 1]; + map[j + 1] = x; + } + + swapped = TRUE; + } + } + } #ifndef NDEBUG - /* I never trust a sort :-) -RPM */ - for (i=0; ishared->u.enumer.name[i], dt->shared->u.enumer.name[i+1])<0); + /* I never trust a sort :-) -RPM */ + for (i = 0; i < nmembs - 1; i++) + HDassert(HDstrcmp(dt->shared->u.enumer.name[i], dt->shared->u.enumer.name[i + 1]) < 0); #endif - } + } } FUNC_LEAVE_NOAPI(SUCCEED) } - diff --git a/src/H5Tfixed.c b/src/H5Tfixed.c index bc1d84d..9d2de91 100644 --- a/src/H5Tfixed.c +++ b/src/H5Tfixed.c @@ -16,15 +16,13 @@ * integer) datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5Tpkg.h" /*data-type functions */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5Tpkg.h" /*data-type functions */ - - /*------------------------------------------------------------------------- * Function: H5Tget_sign * @@ -45,14 +43,14 @@ H5T_sign_t H5Tget_sign(hid_t type_id) { - H5T_t *dt = NULL; - H5T_sign_t ret_value; + H5T_t * dt = NULL; + H5T_sign_t ret_value; FUNC_ENTER_API(H5T_SGN_ERROR) H5TRACE1("Ts", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR, "not an integer datatype") ret_value = H5T_get_sign(dt); @@ -61,7 +59,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T_get_sign * @@ -82,19 +79,19 @@ done: H5T_sign_t H5T_get_sign(H5T_t const *dt) { - H5T_sign_t ret_value = H5T_SGN_ERROR; /* Return value */ + H5T_sign_t ret_value = H5T_SGN_ERROR; /* Return value */ FUNC_ENTER_NOAPI(H5T_SGN_ERROR) HDassert(dt); /* Defer to parent */ - while(dt->shared->parent) + while (dt->shared->parent) dt = dt->shared->parent; /* Check args */ - if (H5T_INTEGER!=dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_SGN_ERROR, "operation not defined for datatype class") + if (H5T_INTEGER != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_SGN_ERROR, "operation not defined for datatype class") /* Sign */ ret_value = dt->shared->u.atomic.u.i.sign; @@ -103,8 +100,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - - /*------------------------------------------------------------------------- * Function: H5Tset_sign * @@ -124,24 +119,24 @@ done: herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTs", type_id, sign); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer datatype") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (sign < H5T_SGN_NONE || sign >= H5T_NSGN) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type") - if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if (H5T_INTEGER!=dt->shared->type) + if (H5T_INTEGER != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ @@ -150,4 +145,3 @@ H5Tset_sign(hid_t type_id, H5T_sign_t sign) done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Tfloat.c b/src/H5Tfloat.c index 85e8f30..bb9a177 100644 --- a/src/H5Tfloat.c +++ b/src/H5Tfloat.c @@ -16,16 +16,13 @@ * datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5Tpkg.h" /*data-type functions */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5Tpkg.h" /*data-type functions */ - - - /*------------------------------------------------------------------------- * Function: H5Tget_fields * @@ -47,40 +44,39 @@ *------------------------------------------------------------------------- */ herr_t -H5Tget_fields(hid_t type_id, size_t *spos/*out*/, size_t *epos/*out*/, -size_t *esize/*out*/, size_t *mpos/*out*/, size_t *msize/*out*/) +H5Tget_fields(hid_t type_id, size_t *spos /*out*/, size_t *epos /*out*/, size_t *esize /*out*/, + size_t *mpos /*out*/, size_t *msize /*out*/) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "ixxxxx", type_id, spos, epos, esize, mpos, msize); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Get values */ - if(spos) + if (spos) *spos = dt->shared->u.atomic.u.f.sign; - if(epos) + if (epos) *epos = dt->shared->u.atomic.u.f.epos; - if(esize) + if (esize) *esize = dt->shared->u.atomic.u.f.esize; - if(mpos) + if (mpos) *mpos = dt->shared->u.atomic.u.f.mpos; - if(msize) + if (msize) *msize = dt->shared->u.atomic.u.f.msize; done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_fields() */ - /*------------------------------------------------------------------------- * Function: H5Tset_fields * @@ -100,43 +96,42 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, - size_t mpos, size_t msize) +H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "izzzzz", type_id, spos, epos, esize, mpos, msize); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT != dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") - if(epos + esize > dt->shared->u.atomic.prec) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid") - if(mpos + msize > dt->shared->u.atomic.prec) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid") - if(spos >= dt->shared->u.atomic.prec) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") + if (epos + esize > dt->shared->u.atomic.prec) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid") + if (mpos + msize > dt->shared->u.atomic.prec) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid") + if (spos >= dt->shared->u.atomic.prec) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid") /* Check for overlap */ - if(spos >= epos && spos < epos + esize) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within exponent field") - if(spos >= mpos && spos < mpos + msize) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within mantissa field") - if((mpos < epos && mpos + msize > epos) || (epos < mpos && epos + esize > mpos)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent and mantissa fields overlap") + if (spos >= epos && spos < epos + esize) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within exponent field") + if (spos >= mpos && spos < mpos + msize) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within mantissa field") + if ((mpos < epos && mpos + msize > epos) || (epos < mpos && epos + esize > mpos)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent and mantissa fields overlap") /* Commit */ - dt->shared->u.atomic.u.f.sign = spos; - dt->shared->u.atomic.u.f.epos = epos; - dt->shared->u.atomic.u.f.mpos = mpos; + dt->shared->u.atomic.u.f.sign = spos; + dt->shared->u.atomic.u.f.epos = epos; + dt->shared->u.atomic.u.f.mpos = mpos; dt->shared->u.atomic.u.f.esize = esize; dt->shared->u.atomic.u.f.msize = msize; @@ -144,7 +139,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_fields() */ - /*------------------------------------------------------------------------- * Function: H5Tget_ebias * @@ -162,19 +156,19 @@ done: size_t H5Tget_ebias(hid_t type_id) { - H5T_t *dt; /* Datatype */ - size_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype */ + size_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("z", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, 0, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, 0, "operation not defined for datatype class") /* bias */ H5_CHECKED_ASSIGN(ret_value, size_t, dt->shared->u.atomic.u.f.ebias, uint64_t); @@ -183,7 +177,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_ebias() */ - /*------------------------------------------------------------------------- * Function: H5Tset_ebias * @@ -203,21 +196,21 @@ done: herr_t H5Tset_ebias(hid_t type_id, size_t ebias) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, ebias); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT != dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.ebias = ebias; @@ -226,7 +219,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_ebias() */ - /*------------------------------------------------------------------------- * Function: H5Tget_norm * @@ -245,19 +237,19 @@ done: H5T_norm_t H5Tget_norm(hid_t type_id) { - H5T_t *dt; /* Datatype */ - H5T_norm_t ret_value; /* Return value */ + H5T_t * dt; /* Datatype */ + H5T_norm_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NORM_ERROR) H5TRACE1("Tn", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a datatype") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a datatype") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_NORM_ERROR, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_NORM_ERROR, "operation not defined for datatype class") /* norm */ ret_value = dt->shared->u.atomic.u.f.norm; @@ -266,7 +258,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_norm() */ - /*------------------------------------------------------------------------- * Function: H5Tset_norm * @@ -283,23 +274,23 @@ done: herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTn", type_id, norm); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT != dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") - if(norm < H5T_NORM_IMPLIED || norm > H5T_NORM_NONE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + if (norm < H5T_NORM_IMPLIED || norm > H5T_NORM_NONE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.norm = norm; @@ -308,7 +299,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_norm() */ - /*------------------------------------------------------------------------- * Function: H5Tget_inpad * @@ -329,19 +319,19 @@ done: H5T_pad_t H5Tget_inpad(hid_t type_id) { - H5T_t *dt; /* Datatype */ - H5T_pad_t ret_value; /* Return value */ + H5T_t * dt; /* Datatype */ + H5T_pad_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_PAD_ERROR) H5TRACE1("Tp", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a datatype") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a datatype") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_PAD_ERROR, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_PAD_ERROR, "operation not defined for datatype class") /* pad */ ret_value = dt->shared->u.atomic.u.f.pad; @@ -350,7 +340,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_inpad() */ - /*------------------------------------------------------------------------- * Function: H5Tset_inpad * @@ -369,23 +358,23 @@ done: herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTp", type_id, pad); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT != dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") - if(pad < H5T_PAD_ZERO || pad >= H5T_NPAD) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + if (pad < H5T_PAD_ZERO || pad >= H5T_NPAD) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.pad = pad; @@ -393,4 +382,3 @@ H5Tset_inpad(hid_t type_id, H5T_pad_t pad) done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_inpad() */ - diff --git a/src/H5Tmodule.h b/src/H5Tmodule.h index d2ab08c..071e026 100644 --- a/src/H5Tmodule.h +++ b/src/H5Tmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5T_MODULE -#define H5_MY_PKG H5T -#define H5_MY_PKG_ERR H5E_DATATYPE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5T +#define H5_MY_PKG_ERR H5E_DATATYPE +#define H5_MY_PKG_INIT YES #endif /* _H5Tmodule_H */ - diff --git a/src/H5Tnative.c b/src/H5Tnative.c index 357bb08..156ce2d 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -16,32 +16,28 @@ * a "native" datatype for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ -static H5T_t *H5T__get_native_type(H5T_t *dt, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size); -static H5T_t *H5T__get_native_integer(size_t prec, H5T_sign_t sign, - H5T_direction_t direction, size_t *struct_align, size_t *offset, - size_t *comp_size); -static H5T_t *H5T__get_native_float(size_t size, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size); -static H5T_t* H5T__get_native_bitfield(size_t prec, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size); -static herr_t H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, - size_t nelems, size_t align, size_t *struct_align); - - - +static H5T_t *H5T__get_native_type(H5T_t *dt, H5T_direction_t direction, size_t *struct_align, size_t *offset, + size_t *comp_size); +static H5T_t *H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, + size_t *struct_align, size_t *offset, size_t *comp_size); +static H5T_t *H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_align, + size_t *offset, size_t *comp_size); +static H5T_t *H5T__get_native_bitfield(size_t prec, H5T_direction_t direction, size_t *struct_align, + size_t *offset, size_t *comp_size); +static herr_t H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, size_t nelems, + size_t align, size_t *struct_align); + /*------------------------------------------------------------------------- * Function: H5Tget_native_type * @@ -75,39 +71,37 @@ static herr_t H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_siz hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction) { - H5T_t *dt; /* Datatype to create native datatype from */ - H5T_t *new_dt = NULL; /* Datatype for native datatype created */ - size_t comp_size = 0; /* Compound datatype's size */ - hid_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to create native datatype from */ + H5T_t *new_dt = NULL; /* Datatype for native datatype created */ + size_t comp_size = 0; /* Compound datatype's size */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "iTd", type_id, direction); /* Check arguments */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a data type") - if(direction != H5T_DIR_DEFAULT && direction != H5T_DIR_ASCEND - && direction != H5T_DIR_DESCEND) + if (direction != H5T_DIR_DEFAULT && direction != H5T_DIR_ASCEND && direction != H5T_DIR_DESCEND) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not valid direction value") /* Get the native type */ - if(NULL == (new_dt = H5T__get_native_type(dt, direction, NULL, NULL, &comp_size))) + if (NULL == (new_dt = H5T__get_native_type(dt, direction, NULL, NULL, &comp_size))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "cannot retrieve native type") /* Get an ID for the new type */ - if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register data type") done: /* Error cleanup */ - if(ret_value < 0) - if(new_dt && H5T_close_real(new_dt) < 0) + if (ret_value < 0) + if (new_dt && H5T_close_real(new_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_API(ret_value) } /* end H5Tget_native_type() */ - /*------------------------------------------------------------------------- * Function: H5T__get_native_type * @@ -123,71 +117,74 @@ done: *------------------------------------------------------------------------- */ static H5T_t * -H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_align, - size_t *offset, size_t *comp_size) +H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_align, size_t *offset, + size_t *comp_size) { - H5T_t *super_type; /* Super type of VL, array and enum datatypes */ - H5T_t *nat_super_type; /* Native form of VL, array & enum super datatype */ - H5T_t *new_type = NULL; /* New native datatype */ - H5T_t *memb_type = NULL; /* Datatype of member */ - H5T_t **memb_list = NULL; /* List of compound member IDs */ - size_t *memb_offset = NULL; /* List of member offsets in compound type, including member size and alignment */ - char **comp_mname = NULL; /* List of member names in compound type */ - char *memb_name = NULL; /* Enum's member name */ - void *memb_value = NULL; /* Enum's member value */ - void *tmp_memb_value = NULL; /* Enum's member value */ - hsize_t *dims = NULL; /* Dimension sizes for array */ - H5T_class_t h5_class; /* Class of datatype to make native */ - size_t size; /* Size of datatype to make native */ - size_t prec; /* Precision of datatype to make native */ - int snmemb; /* Number of members in compound & enum types */ - unsigned nmemb = 0; /* Number of members in compound & enum types */ - unsigned u; /* Local index variable */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t * super_type; /* Super type of VL, array and enum datatypes */ + H5T_t * nat_super_type; /* Native form of VL, array & enum super datatype */ + H5T_t * new_type = NULL; /* New native datatype */ + H5T_t * memb_type = NULL; /* Datatype of member */ + H5T_t **memb_list = NULL; /* List of compound member IDs */ + size_t *memb_offset = + NULL; /* List of member offsets in compound type, including member size and alignment */ + char ** comp_mname = NULL; /* List of member names in compound type */ + char * memb_name = NULL; /* Enum's member name */ + void * memb_value = NULL; /* Enum's member value */ + void * tmp_memb_value = NULL; /* Enum's member value */ + hsize_t * dims = NULL; /* Dimension sizes for array */ + H5T_class_t h5_class; /* Class of datatype to make native */ + size_t size; /* Size of datatype to make native */ + size_t prec; /* Precision of datatype to make native */ + int snmemb; /* Number of members in compound & enum types */ + unsigned nmemb = 0; /* Number of members in compound & enum types */ + unsigned u; /* Local index variable */ + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC HDassert(dtype); - if(H5T_NO_CLASS == (h5_class = H5T_get_class(dtype, FALSE))) + if (H5T_NO_CLASS == (h5_class = H5T_get_class(dtype, FALSE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class") - if(0 == (size = H5T_get_size(dtype))) + if (0 == (size = H5T_get_size(dtype))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid size") - switch(h5_class) { - case H5T_INTEGER: - { - H5T_sign_t sign; /* Signedness of integer type */ + switch (h5_class) { + case H5T_INTEGER: { + H5T_sign_t sign; /* Signedness of integer type */ - if(H5T_SGN_ERROR == (sign = H5T_get_sign(dtype))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess") + if (H5T_SGN_ERROR == (sign = H5T_get_sign(dtype))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess") - prec = dtype->shared->u.atomic.prec; + prec = dtype->shared->u.atomic.prec; - if(NULL == (ret_value = H5T__get_native_integer(prec, sign, direction, struct_align, offset, comp_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type") - } /* end case */ - break; + if (NULL == + (ret_value = H5T__get_native_integer(prec, sign, direction, struct_align, offset, comp_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type") + } /* end case */ + break; case H5T_FLOAT: - if(NULL == (ret_value = H5T__get_native_float(size, direction, struct_align, offset, comp_size))) + if (NULL == (ret_value = H5T__get_native_float(size, direction, struct_align, offset, comp_size))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") break; case H5T_STRING: - if(NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) + if (NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") - if(H5T_IS_VL_STRING(dtype->shared)) { + if (H5T_IS_VL_STRING(dtype->shared)) { /* Update size, offset and compound alignment for parent. */ - if(H5T__cmp_offset(comp_size, offset, sizeof(char *), (size_t)1, H5T_POINTER_COMP_ALIGN_g, struct_align) < 0) + if (H5T__cmp_offset(comp_size, offset, sizeof(char *), (size_t)1, H5T_POINTER_COMP_ALIGN_g, + struct_align) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } /* end if */ else { /* Update size, offset and compound alignment for parent. */ - if(H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align) < 0) + if (H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, + struct_align) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } /* end else */ break; @@ -197,295 +194,300 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali case H5T_TIME: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "time type is not supported yet") - case H5T_BITFIELD: - { - prec = dtype->shared->u.atomic.prec; + case H5T_BITFIELD: { + prec = dtype->shared->u.atomic.prec; - if(NULL == (ret_value = H5T__get_native_bitfield(prec, direction, struct_align, offset, comp_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer for bitfield type") - } /* end case */ - break; + if (NULL == + (ret_value = H5T__get_native_bitfield(prec, direction, struct_align, offset, comp_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer for bitfield type") + } /* end case */ + break; case H5T_OPAQUE: - if(NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") + if (NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* Update size, offset and compound alignment for parent. */ - if(H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align) < 0) + if (H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, + struct_align) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") break; - case H5T_REFERENCE: - { - H5T_t *dt; /* Datatype to make native */ - size_t align; - size_t ref_size; + case H5T_REFERENCE: { + H5T_t *dt; /* Datatype to make native */ + size_t align; + size_t ref_size; + + if (NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy reference type") - if(NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy reference type") + /* Decide if the data type is object reference. */ + if (NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_OBJ_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - /* Decide if the data type is object reference. */ - if(NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_OBJ_g))) + /* Update size, offset and compound alignment for parent. */ + if (0 == H5T_cmp(ret_value, dt, FALSE)) { + align = H5T_HOBJREF_COMP_ALIGN_g; + ref_size = sizeof(hobj_ref_t); + } /* end if */ + else { + /* Decide if the data type is dataset region reference. */ + if (NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_DSETREG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - /* Update size, offset and compound alignment for parent. */ - if(0 == H5T_cmp(ret_value, dt, FALSE)) { - align = H5T_HOBJREF_COMP_ALIGN_g; - ref_size = sizeof(hobj_ref_t); + if (0 == H5T_cmp(ret_value, dt, FALSE)) { + align = H5T_HDSETREGREF_COMP_ALIGN_g; + ref_size = sizeof(hdset_reg_ref_t); } /* end if */ else { - /* Decide if the data type is dataset region reference. */ - if(NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_DSETREG_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - - if (0 == H5T_cmp(ret_value, dt, FALSE)) { - align = H5T_HDSETREGREF_COMP_ALIGN_g; - ref_size = sizeof(hdset_reg_ref_t); - } /* end if */ - else { - /* Only pointers to underlying opaque reference types */ - align = H5T_REF_COMP_ALIGN_g; - ref_size = sizeof(H5R_ref_t); - } /* end else */ + /* Only pointers to underlying opaque reference types */ + align = H5T_REF_COMP_ALIGN_g; + ref_size = sizeof(H5R_ref_t); } /* end else */ + } /* end else */ - if(H5T__cmp_offset(comp_size, offset, ref_size, (size_t)1, align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") - } /* end case */ - break; + if (H5T__cmp_offset(comp_size, offset, ref_size, (size_t)1, align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + } /* end case */ + break; + + case H5T_COMPOUND: { + size_t children_size = 0; /* Total size of compound members */ + size_t children_st_align = + 0; /* The max alignment among compound members. This'll be the compound alignment */ + + if ((snmemb = H5T_get_nmembers(dtype)) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member") + H5_CHECKED_ASSIGN(nmemb, unsigned, snmemb, int); + + if (NULL == (memb_list = (H5T_t **)H5MM_calloc(nmemb * sizeof(H5T_t *)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if (NULL == (memb_offset = (size_t *)H5MM_calloc(nmemb * sizeof(size_t)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if (NULL == (comp_mname = (char **)H5MM_calloc(nmemb * sizeof(char *)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + + /* Construct child compound type and retrieve a list of their IDs, offsets, total size, and + * alignment for compound type. */ + for (u = 0; u < nmemb; u++) { + if (NULL == (memb_type = H5T_get_member_type(dtype, u))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed") + + if (NULL == (comp_mname[u] = H5T__get_member_name(dtype, u))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed") + + if (NULL == (memb_list[u] = H5T__get_native_type(memb_type, direction, &children_st_align, + &(memb_offset[u]), &children_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member identifier retrieval failed") + + if (H5T_close_real(memb_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + } /* end for */ + + /* The alignment for whole compound type */ + if (children_st_align && children_size % children_st_align) + children_size += children_st_align - (children_size % children_st_align); + + /* Construct new compound type based on native type */ + if (NULL == (new_type = H5T__create(H5T_COMPOUND, children_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot create a compound type") + + /* Insert members for the new compound type */ + for (u = 0; u < nmemb; u++) + if (H5T__insert(new_type, comp_mname[u], memb_offset[u], memb_list[u]) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member to compound datatype") + + /* Update size, offset and compound alignment for parent in the case of + * nested compound type. The alignment for a compound type as one field in + * a compound type is the biggest compound alignment among all its members. + * e.g. in the structure + * typedef struct s1 { + * char c; + * int i; + * s2 st; + * unsigned long long l; + * } s1; + * typedef struct s2 { + * short c2; + * long l2; + * long long ll2; + * } s2; + * The alignment for ST in S1 is the biggest structure alignment of all the + * members of S2, which is probably the LL2 of 'long long'. -SLU 2010/4/28 + */ + if (H5T__cmp_offset(comp_size, offset, children_size, (size_t)1, children_st_align, + struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") - case H5T_COMPOUND: - { - size_t children_size = 0;/* Total size of compound members */ - size_t children_st_align = 0; /* The max alignment among compound members. This'll be the compound alignment */ - - if((snmemb = H5T_get_nmembers(dtype)) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member") - H5_CHECKED_ASSIGN(nmemb, unsigned, snmemb, int); - - if(NULL == (memb_list = (H5T_t **)H5MM_calloc(nmemb * sizeof(H5T_t *)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - if(NULL == (memb_offset = (size_t *)H5MM_calloc(nmemb * sizeof(size_t)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - if(NULL == (comp_mname = (char **)H5MM_calloc(nmemb * sizeof(char *)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - - /* Construct child compound type and retrieve a list of their IDs, offsets, total size, and alignment for compound type. */ - for(u = 0; u < nmemb; u++) { - if(NULL == (memb_type = H5T_get_member_type(dtype, u))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed") - - if(NULL == (comp_mname[u] = H5T__get_member_name(dtype, u))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed") - - if(NULL == (memb_list[u] = H5T__get_native_type(memb_type, direction, &children_st_align, &(memb_offset[u]), &children_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member identifier retrieval failed") - - if(H5T_close_real(memb_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") - } /* end for */ - - /* The alignment for whole compound type */ - if(children_st_align && children_size % children_st_align) - children_size += children_st_align - (children_size % children_st_align); - - /* Construct new compound type based on native type */ - if(NULL == (new_type = H5T__create(H5T_COMPOUND, children_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot create a compound type") - - /* Insert members for the new compound type */ - for(u = 0; u < nmemb; u++) - if(H5T__insert(new_type, comp_mname[u], memb_offset[u], memb_list[u]) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member to compound datatype") - - /* Update size, offset and compound alignment for parent in the case of - * nested compound type. The alignment for a compound type as one field in - * a compound type is the biggest compound alignment among all its members. - * e.g. in the structure - * typedef struct s1 { - * char c; - * int i; - * s2 st; - * unsigned long long l; - * } s1; - * typedef struct s2 { - * short c2; - * long l2; - * long long ll2; - * } s2; - * The alignment for ST in S1 is the biggest structure alignment of all the - * members of S2, which is probably the LL2 of 'long long'. -SLU 2010/4/28 - */ - if(H5T__cmp_offset(comp_size, offset, children_size, (size_t)1, children_st_align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + /* Close member data type */ + for (u = 0; u < nmemb; u++) { + if (H5T_close_real(memb_list[u]) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") - /* Close member data type */ - for(u = 0; u < nmemb; u++) { - if(H5T_close_real(memb_list[u]) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + /* Free member names in list */ + comp_mname[u] = (char *)H5MM_xfree(comp_mname[u]); + } /* end for */ + + /* Free lists for members */ + memb_list = (H5T_t **)H5MM_xfree(memb_list); + memb_offset = (size_t *)H5MM_xfree(memb_offset); + comp_mname = (char **)H5MM_xfree(comp_mname); + + ret_value = new_type; + } /* end case */ + break; + + case H5T_ENUM: { + H5T_path_t *tpath; /* Type conversion info */ + hid_t super_type_id, nat_super_type_id; + + /* Don't need to do anything special for alignment, offset since the ENUM type usually is integer. + */ + + /* Retrieve base type for enumerated type */ + if (NULL == (super_type = H5T_get_super(dtype))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get base type for enumerate type") + if (NULL == (nat_super_type = + H5T__get_native_type(super_type, direction, struct_align, offset, comp_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "base native type retrieval failed") + + if ((super_type_id = H5I_register(H5I_DATATYPE, super_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype") + if ((nat_super_type_id = H5I_register(H5I_DATATYPE, nat_super_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype") + + /* Allocate room for the enum values */ + if (NULL == (tmp_memb_value = H5MM_calloc(H5T_get_size(super_type)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if (NULL == (memb_value = H5MM_calloc(H5T_get_size(nat_super_type)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + + /* Construct new enum type based on native type */ + if (NULL == (new_type = H5T__enum_create(nat_super_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create enum type") + + /* Find the conversion function */ + if (NULL == (tpath = H5T_path_find(super_type, nat_super_type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, + "unable to convert between src and dst data types") + + /* Retrieve member info and insert members into new enum type */ + if ((snmemb = H5T_get_nmembers(dtype)) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumerate data type doesn't have any member") + H5_CHECKED_ASSIGN(nmemb, unsigned, snmemb, int); + for (u = 0; u < nmemb; u++) { + if (NULL == (memb_name = H5T__get_member_name(dtype, u))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member name") + if (H5T__get_member_value(dtype, u, tmp_memb_value) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") + H5MM_memcpy(memb_value, tmp_memb_value, H5T_get_size(super_type)); + + if (H5T_convert(tpath, super_type_id, nat_super_type_id, (size_t)1, (size_t)0, (size_t)0, + memb_value, NULL) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") + + if (H5T__enum_insert(new_type, memb_name, memb_value) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member") + memb_name = (char *)H5MM_xfree(memb_name); + } + memb_value = H5MM_xfree(memb_value); + tmp_memb_value = H5MM_xfree(tmp_memb_value); + + /* Close base type */ + if (H5I_dec_app_ref(nat_super_type_id) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + /* Close super type */ + if (H5I_dec_app_ref(super_type_id) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + + ret_value = new_type; + } /* end case */ + break; + + case H5T_ARRAY: { + int sarray_rank; /* Array's rank */ + unsigned array_rank; /* Array's rank */ + hsize_t nelems = 1; + size_t super_offset = 0; + size_t super_size = 0; + size_t super_align = 0; + + /* Retrieve dimension information for array data type */ + if ((sarray_rank = H5T__get_array_ndims(dtype)) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension rank") + H5_CHECKED_ASSIGN(array_rank, unsigned, sarray_rank, int); + if (NULL == (dims = (hsize_t *)H5MM_malloc(array_rank * sizeof(hsize_t)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if (H5T__get_array_dims(dtype, dims) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension size") + + /* Retrieve base type for array type */ + if (NULL == (super_type = H5T_get_super(dtype))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for array type") + if (NULL == (nat_super_type = H5T__get_native_type(super_type, direction, &super_align, + &super_offset, &super_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed") + + /* Close super type */ + if (H5T_close_real(super_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") + + /* Create a new array type based on native type */ + if (NULL == (new_type = H5T__array_create(nat_super_type, array_rank, dims))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create array type") + + /* Close base type */ + if (H5T_close_real(nat_super_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") + + for (u = 0; u < array_rank; u++) + nelems *= dims[u]; + H5_CHECK_OVERFLOW(nelems, hsize_t, size_t); + if (H5T__cmp_offset(comp_size, offset, super_size, (size_t)nelems, super_align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") - /* Free member names in list */ - comp_mname[u] = (char *)H5MM_xfree(comp_mname[u]); - } /* end for */ + dims = (hsize_t *)H5MM_xfree(dims); - /* Free lists for members */ - memb_list = (H5T_t **)H5MM_xfree(memb_list); - memb_offset = (size_t *)H5MM_xfree(memb_offset); - comp_mname = (char **)H5MM_xfree(comp_mname); + ret_value = new_type; + } /* end case */ + break; - ret_value = new_type; - } /* end case */ - break; + case H5T_VLEN: { + size_t vl_align = 0; + size_t vl_size = 0; + size_t super_size = 0; - case H5T_ENUM: - { - H5T_path_t *tpath; /* Type conversion info */ - hid_t super_type_id, nat_super_type_id; - - /* Don't need to do anything special for alignment, offset since the ENUM type usually is integer. */ - - /* Retrieve base type for enumerated type */ - if(NULL == (super_type = H5T_get_super(dtype))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get base type for enumerate type") - if(NULL == (nat_super_type = H5T__get_native_type(super_type, direction, struct_align, offset, comp_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "base native type retrieval failed") - - if((super_type_id = H5I_register(H5I_DATATYPE, super_type, FALSE)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype") - if((nat_super_type_id = H5I_register(H5I_DATATYPE, nat_super_type, FALSE)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype") - - /* Allocate room for the enum values */ - if(NULL == (tmp_memb_value = H5MM_calloc(H5T_get_size(super_type)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - if(NULL == (memb_value = H5MM_calloc(H5T_get_size(nat_super_type)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - - /* Construct new enum type based on native type */ - if(NULL == (new_type = H5T__enum_create(nat_super_type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create enum type") - - /* Find the conversion function */ - if(NULL == (tpath = H5T_path_find(super_type, nat_super_type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to convert between src and dst data types") - - /* Retrieve member info and insert members into new enum type */ - if((snmemb = H5T_get_nmembers(dtype)) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumerate data type doesn't have any member") - H5_CHECKED_ASSIGN(nmemb, unsigned, snmemb, int); - for(u = 0; u < nmemb; u++) { - if(NULL == (memb_name = H5T__get_member_name(dtype, u))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member name") - if(H5T__get_member_value(dtype, u, tmp_memb_value) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") - H5MM_memcpy(memb_value, tmp_memb_value, H5T_get_size(super_type)); - - if(H5T_convert(tpath, super_type_id, nat_super_type_id, (size_t)1, (size_t)0, (size_t)0, memb_value, NULL) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") - - if(H5T__enum_insert(new_type, memb_name, memb_value) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member") - memb_name = (char *)H5MM_xfree(memb_name); - } - memb_value = H5MM_xfree(memb_value); - tmp_memb_value = H5MM_xfree(tmp_memb_value); - - /* Close base type */ - if(H5I_dec_app_ref(nat_super_type_id) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") - /* Close super type */ - if(H5I_dec_app_ref(super_type_id) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + /* Retrieve base type for array type */ + if (NULL == (super_type = H5T_get_super(dtype))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for VL type") + /* Don't need alignment, offset information if this VL isn't a field of compound type. If it + * is, go to a few steps below to compute the information directly. */ + if (NULL == + (nat_super_type = H5T__get_native_type(super_type, direction, NULL, NULL, &super_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed") - ret_value = new_type; - } /* end case */ - break; + /* Close super type */ + if (H5T_close_real(super_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - case H5T_ARRAY: - { - int sarray_rank; /* Array's rank */ - unsigned array_rank; /* Array's rank */ - hsize_t nelems = 1; - size_t super_offset = 0; - size_t super_size = 0; - size_t super_align = 0; - - /* Retrieve dimension information for array data type */ - if((sarray_rank = H5T__get_array_ndims(dtype)) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension rank") - H5_CHECKED_ASSIGN(array_rank, unsigned, sarray_rank, int); - if(NULL == (dims = (hsize_t*)H5MM_malloc(array_rank * sizeof(hsize_t)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - if(H5T__get_array_dims(dtype, dims) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension size") - - /* Retrieve base type for array type */ - if(NULL == (super_type = H5T_get_super(dtype))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for array type") - if(NULL == (nat_super_type = H5T__get_native_type(super_type, direction, &super_align, - &super_offset, &super_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed") - - /* Close super type */ - if(H5T_close_real(super_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - - /* Create a new array type based on native type */ - if(NULL == (new_type = H5T__array_create(nat_super_type, array_rank, dims))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create array type") - - /* Close base type */ - if(H5T_close_real(nat_super_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - - for(u = 0; u < array_rank; u++) - nelems *= dims[u]; - H5_CHECK_OVERFLOW(nelems, hsize_t, size_t); - if(H5T__cmp_offset(comp_size, offset, super_size, (size_t)nelems, super_align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + /* Create a new array type based on native type */ + if (NULL == (new_type = H5T__vlen_create(nat_super_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create VL type") - dims = (hsize_t *)H5MM_xfree(dims); + /* Close base type */ + if (H5T_close_real(nat_super_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - ret_value = new_type; - } /* end case */ - break; + /* Update size, offset and compound alignment for parent compound type directly. */ + vl_align = H5T_HVL_COMP_ALIGN_g; + vl_size = sizeof(hvl_t); - case H5T_VLEN: - { - size_t vl_align = 0; - size_t vl_size = 0; - size_t super_size = 0; - - /* Retrieve base type for array type */ - if(NULL == (super_type = H5T_get_super(dtype))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for VL type") - /* Don't need alignment, offset information if this VL isn't a field of compound type. If it - * is, go to a few steps below to compute the information directly. */ - if(NULL == (nat_super_type = H5T__get_native_type(super_type, direction, NULL, NULL, &super_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed") - - /* Close super type */ - if(H5T_close_real(super_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - - /* Create a new array type based on native type */ - if(NULL == (new_type = H5T__vlen_create(nat_super_type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create VL type") - - /* Close base type */ - if(H5T_close_real(nat_super_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - - /* Update size, offset and compound alignment for parent compound type directly. */ - vl_align = H5T_HVL_COMP_ALIGN_g; - vl_size = sizeof(hvl_t); - - if(H5T__cmp_offset(comp_size, offset, vl_size, (size_t)1, vl_align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + if (H5T__cmp_offset(comp_size, offset, vl_size, (size_t)1, vl_align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") - ret_value = new_type; - } /* end case */ - break; + ret_value = new_type; + } /* end case */ + break; case H5T_NO_CLASS: case H5T_NCLASSES: @@ -495,30 +497,30 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali done: /* Error cleanup */ - if(NULL == ret_value) { - if(new_type) - if(H5T_close_real(new_type) < 0) + if (NULL == ret_value) { + if (new_type) + if (H5T_close_real(new_type) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype") /* Free lists for members */ - if(memb_list) { - for(u = 0; u < nmemb; u++) - if(memb_list[u] && H5T_close_real(memb_list[u]) < 0) + if (memb_list) { + for (u = 0; u < nmemb; u++) + if (memb_list[u] && H5T_close_real(memb_list[u]) < 0) HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") memb_list = (H5T_t **)H5MM_xfree(memb_list); } /* end if */ memb_offset = (size_t *)H5MM_xfree(memb_offset); - if(comp_mname) { - for(u = 0; u < nmemb; u++) - if(comp_mname[u]) + if (comp_mname) { + for (u = 0; u < nmemb; u++) + if (comp_mname[u]) H5MM_xfree(comp_mname[u]); comp_mname = (char **)H5MM_xfree(comp_mname); } /* end if */ - memb_name = (char *)H5MM_xfree(memb_name); - memb_value = H5MM_xfree(memb_value); + memb_name = (char *)H5MM_xfree(memb_name); + memb_value = H5MM_xfree(memb_value); tmp_memb_value = H5MM_xfree(tmp_memb_value); - dims = (hsize_t *)H5MM_xfree(dims); + dims = (hsize_t *)H5MM_xfree(dims); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -530,8 +532,8 @@ done: * the code below, but early (4.4.7, at least) gcc only allows * diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(duplicated-branches) - +H5_GCC_DIAG_OFF("duplicated-branches") + /*------------------------------------------------------------------------- * Function: H5T__get_native_integer * @@ -547,68 +549,78 @@ H5_GCC_DIAG_OFF(duplicated-branches) *------------------------------------------------------------------------- */ static H5T_t * -H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size) +H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, size_t *struct_align, + size_t *offset, size_t *comp_size) { - H5T_t *dt; /* Appropriate native datatype to copy */ - hid_t tid = (-1); /* Datatype ID of appropriate native datatype */ - size_t align = 0; /* Alignment necessary for native datatype */ - size_t native_size = 0; /* Datatype size of the native type */ - enum match_type { /* The different kinds of integers we can match */ - H5T_NATIVE_INT_MATCH_CHAR, - H5T_NATIVE_INT_MATCH_SHORT, - H5T_NATIVE_INT_MATCH_INT, - H5T_NATIVE_INT_MATCH_LONG, - H5T_NATIVE_INT_MATCH_LLONG, - H5T_NATIVE_INT_MATCH_UNKNOWN - } match = H5T_NATIVE_INT_MATCH_UNKNOWN; - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt; /* Appropriate native datatype to copy */ + hid_t tid = (-1); /* Datatype ID of appropriate native datatype */ + size_t align = 0; /* Alignment necessary for native datatype */ + size_t native_size = 0; /* Datatype size of the native type */ + enum match_type { /* The different kinds of integers we can match */ + H5T_NATIVE_INT_MATCH_CHAR, + H5T_NATIVE_INT_MATCH_SHORT, + H5T_NATIVE_INT_MATCH_INT, + H5T_NATIVE_INT_MATCH_LONG, + H5T_NATIVE_INT_MATCH_LLONG, + H5T_NATIVE_INT_MATCH_UNKNOWN + } match = H5T_NATIVE_INT_MATCH_UNKNOWN; + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { - match = H5T_NATIVE_INT_MATCH_CHAR; + if (direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { + if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { + match = H5T_NATIVE_INT_MATCH_CHAR; native_size = sizeof(char); - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { - match = H5T_NATIVE_INT_MATCH_SHORT; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { + match = H5T_NATIVE_INT_MATCH_SHORT; native_size = sizeof(short); - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { - match = H5T_NATIVE_INT_MATCH_INT; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { + match = H5T_NATIVE_INT_MATCH_INT; native_size = sizeof(int); - } else if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { - match = H5T_NATIVE_INT_MATCH_LONG; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { + match = H5T_NATIVE_INT_MATCH_LONG; native_size = sizeof(long); - } else if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) { - match = H5T_NATIVE_INT_MATCH_LLONG; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) { + match = H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long long); - } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ - match = H5T_NATIVE_INT_MATCH_LLONG; + } + else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ + match = H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long long); } - } else if(direction == H5T_DIR_DESCEND) { - if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { - match = H5T_NATIVE_INT_MATCH_LLONG; + } + else if (direction == H5T_DIR_DESCEND) { + if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { + match = H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long long); - } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { - match = H5T_NATIVE_INT_MATCH_LONG; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { + match = H5T_NATIVE_INT_MATCH_LONG; native_size = sizeof(long); - } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { - match = H5T_NATIVE_INT_MATCH_INT; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { + match = H5T_NATIVE_INT_MATCH_INT; native_size = sizeof(int); - } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { - match = H5T_NATIVE_INT_MATCH_SHORT; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { + match = H5T_NATIVE_INT_MATCH_SHORT; native_size = sizeof(short); - } else { - match = H5T_NATIVE_INT_MATCH_CHAR; + } + else { + match = H5T_NATIVE_INT_MATCH_CHAR; native_size = sizeof(char); } } /* Set the appropriate native datatype information */ - switch(match) { + switch (match) { case H5T_NATIVE_INT_MATCH_CHAR: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_SCHAR; else tid = H5T_NATIVE_UCHAR; @@ -617,7 +629,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, break; case H5T_NATIVE_INT_MATCH_SHORT: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_SHORT; else tid = H5T_NATIVE_USHORT; @@ -625,7 +637,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, break; case H5T_NATIVE_INT_MATCH_INT: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_INT; else tid = H5T_NATIVE_UINT; @@ -634,7 +646,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, break; case H5T_NATIVE_INT_MATCH_LONG: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_LONG; else tid = H5T_NATIVE_ULONG; @@ -643,7 +655,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, break; case H5T_NATIVE_INT_MATCH_LLONG: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_LLONG; else tid = H5T_NATIVE_ULLONG; @@ -658,20 +670,20 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, /* Create new native type */ HDassert(tid >= 0); - if(NULL == (dt = (H5T_t *)H5I_object(tid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") + if (NULL == (dt = (H5T_t *)H5I_object(tid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - if(NULL == (ret_value = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") + if (NULL == (ret_value = H5T_copy(dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") /* compute size and offset of compound type member. */ - if(H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + if (H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_native_integer() */ -H5_GCC_DIAG_ON(duplicated-branches) +H5_GCC_DIAG_ON("duplicated-branches") /* Disable warning for intentional identical branches here -QAK */ /* @@ -679,8 +691,8 @@ H5_GCC_DIAG_ON(duplicated-branches) * the code below, but early (4.4.7, at least) gcc only allows * diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(duplicated-branches) - +H5_GCC_DIAG_OFF("duplicated-branches") + /*------------------------------------------------------------------------- * Function: H5T__get_native_float * @@ -695,93 +707,94 @@ H5_GCC_DIAG_OFF(duplicated-branches) * *------------------------------------------------------------------------- */ -static H5T_t* -H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_align, - size_t *offset, size_t *comp_size) +static H5T_t * +H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_align, size_t *offset, + size_t *comp_size) { - H5T_t *dt=NULL; /* Appropriate native datatype to copy */ - hid_t tid=(-1); /* Datatype ID of appropriate native datatype */ - size_t align=0; /* Alignment necessary for native datatype */ - size_t native_size=0; /* Datatype size of the native type */ - enum match_type { /* The different kinds of floating point types we can match */ - H5T_NATIVE_FLOAT_MATCH_FLOAT, - H5T_NATIVE_FLOAT_MATCH_DOUBLE, -#if H5_SIZEOF_LONG_DOUBLE !=0 - H5T_NATIVE_FLOAT_MATCH_LDOUBLE, + H5T_t *dt = NULL; /* Appropriate native datatype to copy */ + hid_t tid = (-1); /* Datatype ID of appropriate native datatype */ + size_t align = 0; /* Alignment necessary for native datatype */ + size_t native_size = 0; /* Datatype size of the native type */ + enum match_type { /* The different kinds of floating point types we can match */ + H5T_NATIVE_FLOAT_MATCH_FLOAT, + H5T_NATIVE_FLOAT_MATCH_DOUBLE, +#if H5_SIZEOF_LONG_DOUBLE != 0 + H5T_NATIVE_FLOAT_MATCH_LDOUBLE, #endif - H5T_NATIVE_FLOAT_MATCH_UNKNOWN - } match=H5T_NATIVE_FLOAT_MATCH_UNKNOWN; - H5T_t *ret_value = NULL; /* Return value */ + H5T_NATIVE_FLOAT_MATCH_UNKNOWN + } match = H5T_NATIVE_FLOAT_MATCH_UNKNOWN; + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - HDassert(size>0); + HDassert(size > 0); - if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(size<=sizeof(float)) { - match=H5T_NATIVE_FLOAT_MATCH_FLOAT; - native_size = sizeof(float); + if (direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { + if (size <= sizeof(float)) { + match = H5T_NATIVE_FLOAT_MATCH_FLOAT; + native_size = sizeof(float); } - else if(size<=sizeof(double)) { - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; - native_size = sizeof(double); + else if (size <= sizeof(double)) { + match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; + native_size = sizeof(double); } -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if(size<=sizeof(long double)) { - match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; - native_size = sizeof(long double); +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if (size <= sizeof(long double)) { + match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; + native_size = sizeof(long double); } #endif - else { /* If not match, return the biggest datatype */ -#if H5_SIZEOF_LONG_DOUBLE !=0 - match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; - native_size = sizeof(long double); + else { /* If not match, return the biggest datatype */ +#if H5_SIZEOF_LONG_DOUBLE != 0 + match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; + native_size = sizeof(long double); #else - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; + match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; native_size = sizeof(double); #endif - } - } else { -#if H5_SIZEOF_LONG_DOUBLE !=0 - if(size>sizeof(double)) { - match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; - native_size = sizeof(long double); } - else if(size>sizeof(float)) { - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; - native_size = sizeof(double); + } + else { +#if H5_SIZEOF_LONG_DOUBLE != 0 + if (size > sizeof(double)) { + match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; + native_size = sizeof(long double); + } + else if (size > sizeof(float)) { + match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; + native_size = sizeof(double); } else { - match=H5T_NATIVE_FLOAT_MATCH_FLOAT; - native_size = sizeof(float); - } + match = H5T_NATIVE_FLOAT_MATCH_FLOAT; + native_size = sizeof(float); + } #else - if(size>sizeof(float)) { - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; - native_size = sizeof(double); + if (size > sizeof(float)) { + match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; + native_size = sizeof(double); } else { - match=H5T_NATIVE_FLOAT_MATCH_FLOAT; - native_size = sizeof(float); - } + match = H5T_NATIVE_FLOAT_MATCH_FLOAT; + native_size = sizeof(float); + } #endif } /* Set the appropriate native floating point information */ - switch(match) { + switch (match) { case H5T_NATIVE_FLOAT_MATCH_FLOAT: - tid = H5T_NATIVE_FLOAT; + tid = H5T_NATIVE_FLOAT; align = H5T_NATIVE_FLOAT_COMP_ALIGN_g; break; case H5T_NATIVE_FLOAT_MATCH_DOUBLE: - tid = H5T_NATIVE_DOUBLE; + tid = H5T_NATIVE_DOUBLE; align = H5T_NATIVE_DOUBLE_COMP_ALIGN_g; break; -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 case H5T_NATIVE_FLOAT_MATCH_LDOUBLE: - tid = H5T_NATIVE_LDOUBLE; + tid = H5T_NATIVE_LDOUBLE; align = H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; break; #endif @@ -791,20 +804,20 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali } /* end switch */ /* Create new native type */ - HDassert(tid>=0); - if(NULL==(dt=(H5T_t *)H5I_object(tid))) + HDassert(tid >= 0); + if (NULL == (dt = (H5T_t *)H5I_object(tid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) + if ((ret_value = H5T_copy(dt, H5T_COPY_TRANSIENT)) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* compute offset of compound type member. */ - if(H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + if (H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_native_float() */ -H5_GCC_DIAG_ON(duplicated-branches) +H5_GCC_DIAG_ON("duplicated-branches") /* Disable warning for intentional identical branches here -QAK */ /* @@ -812,8 +825,8 @@ H5_GCC_DIAG_ON(duplicated-branches) * the code below, but early (4.4.7, at least) gcc only allows * diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(duplicated-branches) - +H5_GCC_DIAG_OFF("duplicated-branches") + /*------------------------------------------------------------------------- * Function: H5T__get_native_bitfield * @@ -829,78 +842,85 @@ H5_GCC_DIAG_OFF(duplicated-branches) * *------------------------------------------------------------------------- */ -static H5T_t* -H5T__get_native_bitfield(size_t prec, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size) +static H5T_t * +H5T__get_native_bitfield(size_t prec, H5T_direction_t direction, size_t *struct_align, size_t *offset, + size_t *comp_size) { - H5T_t *dt; /* Appropriate native datatype to copy */ - hid_t tid=(-1); /* Datatype ID of appropriate native datatype */ - size_t align=0; /* Alignment necessary for native datatype */ - size_t native_size=0; /* Datatype size of the native type */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt; /* Appropriate native datatype to copy */ + hid_t tid = (-1); /* Datatype ID of appropriate native datatype */ + size_t align = 0; /* Alignment necessary for native datatype */ + size_t native_size = 0; /* Datatype size of the native type */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { - tid = H5T_NATIVE_B8; + if (direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { + if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { + tid = H5T_NATIVE_B8; native_size = 1; - align = H5T_NATIVE_UINT8_ALIGN_g; - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { - tid = H5T_NATIVE_B16; + align = H5T_NATIVE_UINT8_ALIGN_g; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { + tid = H5T_NATIVE_B16; native_size = 2; - align = H5T_NATIVE_UINT16_ALIGN_g; - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { - tid = H5T_NATIVE_B32; + align = H5T_NATIVE_UINT16_ALIGN_g; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { + tid = H5T_NATIVE_B32; native_size = 4; - align = H5T_NATIVE_UINT32_ALIGN_g; - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B64_g))) { - tid = H5T_NATIVE_B64; + align = H5T_NATIVE_UINT32_ALIGN_g; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B64_g))) { + tid = H5T_NATIVE_B64; native_size = 8; - align = H5T_NATIVE_UINT64_ALIGN_g; - } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ - tid = H5T_NATIVE_B64; + align = H5T_NATIVE_UINT64_ALIGN_g; + } + else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ + tid = H5T_NATIVE_B64; native_size = 8; - align = H5T_NATIVE_UINT64_ALIGN_g; + align = H5T_NATIVE_UINT64_ALIGN_g; } - } else if(direction == H5T_DIR_DESCEND) { - if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { - tid = H5T_NATIVE_B64; + } + else if (direction == H5T_DIR_DESCEND) { + if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { + tid = H5T_NATIVE_B64; native_size = 8; - align = H5T_NATIVE_UINT64_ALIGN_g; - } else if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { - tid = H5T_NATIVE_B32; + align = H5T_NATIVE_UINT64_ALIGN_g; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { + tid = H5T_NATIVE_B32; native_size = 4; - align = H5T_NATIVE_UINT32_ALIGN_g; - } else if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { - tid = H5T_NATIVE_B16; + align = H5T_NATIVE_UINT32_ALIGN_g; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { + tid = H5T_NATIVE_B16; native_size = 2; - align = H5T_NATIVE_UINT16_ALIGN_g; - } else { - tid = H5T_NATIVE_B8; + align = H5T_NATIVE_UINT16_ALIGN_g; + } + else { + tid = H5T_NATIVE_B8; native_size = 1; - align = H5T_NATIVE_UINT8_ALIGN_g; + align = H5T_NATIVE_UINT8_ALIGN_g; } } /* Create new native type */ - HDassert(tid>=0); - if(NULL==(dt=(H5T_t *)H5I_object(tid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") + HDassert(tid >= 0); + if (NULL == (dt = (H5T_t *)H5I_object(tid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") + if ((ret_value = H5T_copy(dt, H5T_COPY_TRANSIENT)) == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") /* compute size and offset of compound type member. */ - if(H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + if (H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_native_bitfield() */ -H5_GCC_DIAG_ON(duplicated-branches) +H5_GCC_DIAG_ON("duplicated-branches") - /*------------------------------------------------------------------------- * Function: H5T__cmp_offset * @@ -918,27 +938,26 @@ H5_GCC_DIAG_ON(duplicated-branches) *------------------------------------------------------------------------- */ static herr_t -H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, - size_t nelems, size_t align, size_t *struct_align) +H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, size_t nelems, size_t align, + size_t *struct_align) { FUNC_ENTER_STATIC_NOERR - if(offset && comp_size) { - if(align > 1 && *comp_size % align) { + if (offset && comp_size) { + if (align > 1 && *comp_size % align) { /* Add alignment value */ - *offset = *comp_size + (align - *comp_size % align); + *offset = *comp_size + (align - *comp_size % align); *comp_size += (align - *comp_size % align); } /* end if */ else *offset = *comp_size; /* compute size of compound type member. */ - *comp_size += nelems* elem_size; + *comp_size += nelems * elem_size; } /* end if */ - if(struct_align && *struct_align < align) + if (struct_align && *struct_align < align) *struct_align = align; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__cmp_offset() */ - diff --git a/src/H5Toffset.c b/src/H5Toffset.c index c0e94fc..cff7857 100644 --- a/src/H5Toffset.c +++ b/src/H5Toffset.c @@ -16,19 +16,16 @@ * the datatype offset for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ static herr_t H5T_set_offset(const H5T_t *dt, size_t offset); - - /*------------------------------------------------------------------------- * Function: H5Tget_offset * @@ -61,25 +58,24 @@ static herr_t H5T_set_offset(const H5T_t *dt, size_t offset); int H5Tget_offset(hid_t type_id) { - H5T_t *dt; - int ret_value; + H5T_t *dt; + int ret_value; FUNC_ENTER_API(-1) H5TRACE1("Is", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") /* Get offset */ - if((ret_value = H5T_get_offset(dt)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "cant't get offset for specified datatype") + if ((ret_value = H5T_get_offset(dt)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "cant't get offset for specified datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_offset() */ - /*------------------------------------------------------------------------- * Function: H5T_get_offset * @@ -112,15 +108,15 @@ done: int H5T_get_offset(const H5T_t *dt) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) /* Defer to parent*/ - while(dt->shared->parent) + while (dt->shared->parent) dt = dt->shared->parent; - if(!H5T_IS_ATOMIC(dt->shared)) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") + if (!H5T_IS_ATOMIC(dt->shared)) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Offset */ ret_value = (int)dt->shared->u.atomic.offset; @@ -129,7 +125,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_offset() */ - /*------------------------------------------------------------------------- * Function: H5Tset_offset * @@ -172,33 +167,33 @@ done: herr_t H5Tset_offset(hid_t type_id, size_t offset) { - H5T_t *dt; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, offset); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") - if (H5T_STATE_TRANSIENT!=dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (H5T_STRING == dt->shared->type && offset != 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type") - if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") - if (H5T_COMPOUND==dt->shared->type || H5T_REFERENCE==dt->shared->type || H5T_OPAQUE==dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type") + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") + if (H5T_COMPOUND == dt->shared->type || H5T_REFERENCE == dt->shared->type || + H5T_OPAQUE == dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype") /* Do the real work */ - if (H5T_set_offset(dt, offset)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset") + if (H5T_set_offset(dt, offset) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T_set_offset * @@ -241,29 +236,30 @@ done: static herr_t H5T_set_offset(const H5T_t *dt, size_t offset) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(dt); - HDassert(H5T_STRING!=dt->shared->type || 0==offset); - HDassert(H5T_REFERENCE!=dt->shared->type); - HDassert(H5T_OPAQUE!=dt->shared->type); - HDassert(H5T_COMPOUND!=dt->shared->type); - HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(H5T_STRING != dt->shared->type || 0 == offset); + HDassert(H5T_REFERENCE != dt->shared->type); + HDassert(H5T_OPAQUE != dt->shared->type); + HDassert(H5T_COMPOUND != dt->shared->type); + HDassert(!(H5T_ENUM == dt->shared->type && 0 == dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { - if (H5T_set_offset(dt->shared->parent, offset)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type") + if (H5T_set_offset(dt->shared->parent, offset) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type") /* Adjust size of datatype appropriately */ - if(dt->shared->type==H5T_ARRAY) + if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; - else if(dt->shared->type!=H5T_VLEN) + else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; - } else { - if (offset+dt->shared->u.atomic.prec > 8*dt->shared->size) + } + else { + if (offset + dt->shared->u.atomic.prec > 8 * dt->shared->size) dt->shared->size = (offset + dt->shared->u.atomic.prec + 7) / 8; dt->shared->u.atomic.offset = offset; } @@ -271,4 +267,3 @@ H5T_set_offset(const H5T_t *dt, size_t offset) done: FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Toh.c b/src/H5Toh.c index ab6c09f..95da9be 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -15,69 +15,61 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static htri_t H5O__dtype_isa(const H5O_t *loc); -static void *H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); -static void *H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); +static htri_t H5O__dtype_isa(const H5O_t *loc); +static void * H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); +static void * H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__dtype_get_oloc(hid_t obj_id); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_DATATYPE[1] = {{ - H5O_TYPE_NAMED_DATATYPE, /* object type */ - "named datatype", /* object name, for debugging */ - NULL, /* get 'copy file' user data */ - NULL, /* free 'copy file' user data */ - H5O__dtype_isa, /* "isa" */ - H5O__dtype_open, /* open an object of this class */ - H5O__dtype_create, /* create an object of this class */ - H5O__dtype_get_oloc, /* get an object header location for an object */ - NULL, /* get the index & heap info for an object */ - NULL /* flush an opened object of this class */ + H5O_TYPE_NAMED_DATATYPE, /* object type */ + "named datatype", /* object name, for debugging */ + NULL, /* get 'copy file' user data */ + NULL, /* free 'copy file' user data */ + H5O__dtype_isa, /* "isa" */ + H5O__dtype_open, /* open an object of this class */ + H5O__dtype_create, /* create an object of this class */ + H5O__dtype_get_oloc, /* get an object header location for an object */ + NULL, /* get the index & heap info for an object */ + NULL /* flush an opened object of this class */ }}; - /*------------------------------------------------------------------------- * Function: H5O__dtype_isa * @@ -98,20 +90,19 @@ const H5O_obj_class_t H5O_OBJ_DATATYPE[1] = {{ static htri_t H5O__dtype_isa(const H5O_t *oh) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC HDassert(oh); - if((ret_value = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to read object header") + if ((ret_value = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to read object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_isa() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_open * @@ -128,8 +119,8 @@ done: static void * H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - H5T_t *type = NULL; /* Datatype opened */ - void *ret_value = NULL; /* Return value */ + H5T_t *type = NULL; /* Datatype opened */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -138,20 +129,19 @@ H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) *opened_type = H5I_DATATYPE; /* Open the datatype */ - if(NULL == (type = H5T_open(obj_loc))) + if (NULL == (type = H5T_open(obj_loc))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open datatype") ret_value = (void *)type; done: - if(NULL == ret_value) - if(type && H5T_close(type) < 0) + if (NULL == ret_value) + if (type && H5T_close(type) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_open() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_create * @@ -168,8 +158,8 @@ done: static void * H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) { - H5T_obj_create_t *crt_info = (H5T_obj_create_t *)_crt_info; /* Named datatype creation parameters */ - void *ret_value = NULL; /* Return value */ + H5T_obj_create_t *crt_info = (H5T_obj_create_t *)_crt_info; /* Named datatype creation parameters */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -179,13 +169,13 @@ H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) HDassert(obj_loc); /* Commit the type to the file */ - if(H5T__commit(f, crt_info->dt, crt_info->tcpl_id) < 0) + if (H5T__commit(f, crt_info->dt, crt_info->tcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") /* Set up the new named datatype's location */ - if(NULL == (obj_loc->oloc = H5T_oloc(crt_info->dt))) + if (NULL == (obj_loc->oloc = H5T_oloc(crt_info->dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of named datatype") - if(NULL == (obj_loc->path = H5T_nameof(crt_info->dt))) + if (NULL == (obj_loc->path = H5T_nameof(crt_info->dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of named datatype") /* Set the return value */ @@ -195,7 +185,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_create() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_get_oloc * @@ -212,24 +201,23 @@ done: static H5O_loc_t * H5O__dtype_get_oloc(hid_t obj_id) { - H5T_t *type = NULL; /* Datatype opened */ - H5T_t *dt = NULL; - H5O_loc_t *ret_value = NULL; /* Return value */ + H5T_t * type = NULL; /* Datatype opened */ + H5T_t * dt = NULL; + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Get the datatype */ - if(NULL == (dt = (H5T_t *)H5I_object(obj_id))) + if (NULL == (dt = (H5T_t *)H5I_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* If this is a named datatype, get the VOL driver pointer to the datatype */ type = (H5T_t *)H5T_get_actual_type(dt); /* Get the datatype's object header location */ - if(NULL == (ret_value = H5T_oloc(type))) + if (NULL == (ret_value = H5T_oloc(type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_get_oloc() */ - diff --git a/src/H5Topaque.c b/src/H5Topaque.c index 4e8f1d4..8d18abe 100644 --- a/src/H5Topaque.c +++ b/src/H5Topaque.c @@ -16,17 +16,14 @@ * datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /* Datatypes */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Tpkg.h" /* Datatypes */ - - - /*------------------------------------------------------------------------- * Function: H5Tset_tag * @@ -44,20 +41,20 @@ herr_t H5Tset_tag(hid_t type_id, const char *tag) { - H5T_t *dt=NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", type_id, tag); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if (H5T_OPAQUE!=dt->shared->type) + if (H5T_OPAQUE != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an opaque data type") if (!tag) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no tag") @@ -72,7 +69,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tget_tag * @@ -91,14 +87,14 @@ done: char * H5Tget_tag(hid_t type_id) { - H5T_t *dt=NULL; - char *ret_value; + H5T_t *dt = NULL; + char * ret_value; FUNC_ENTER_API(NULL) H5TRACE1("*s", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ @@ -106,10 +102,9 @@ H5Tget_tag(hid_t type_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "operation not defined for data type class") /* result */ - if (NULL==(ret_value=H5MM_strdup(dt->shared->u.opaque.tag))) + if (NULL == (ret_value = H5MM_strdup(dt->shared->u.opaque.tag))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Torder.c b/src/H5Torder.c index b4babfa..877eddc 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -20,60 +20,49 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5T_set_order(H5T_t *dtype, H5T_order_t order); - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Tget_order * @@ -92,25 +81,24 @@ static herr_t H5T_set_order(H5T_t *dtype, H5T_order_t order); H5T_order_t H5Tget_order(hid_t type_id) { - H5T_t *dt; /* Datatype to query */ - H5T_order_t ret_value; /* Return value */ + H5T_t * dt; /* Datatype to query */ + H5T_order_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_ORDER_ERROR) H5TRACE1("To", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_ORDER_ERROR, "not a datatype") /* Get order */ - if(H5T_ORDER_ERROR == (ret_value = H5T_get_order(dt))) + if (H5T_ORDER_ERROR == (ret_value = H5T_get_order(dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "can't get order for specified datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_order() */ - /*------------------------------------------------------------------------- * Function: H5T_get_order * @@ -127,55 +115,55 @@ done: H5T_order_t H5T_get_order(const H5T_t *dtype) { - H5T_order_t ret_value = H5T_ORDER_NONE; /* Return value */ + H5T_order_t ret_value = H5T_ORDER_NONE; /* Return value */ FUNC_ENTER_NOAPI(H5T_ORDER_ERROR) /* Defer to parent */ - while(dtype->shared->parent) + while (dtype->shared->parent) dtype = dtype->shared->parent; /* Set order for atomic type. */ - if(H5T_IS_ATOMIC(dtype->shared)) + if (H5T_IS_ATOMIC(dtype->shared)) ret_value = dtype->shared->u.atomic.order; else { /* Check for compound datatype */ - if(H5T_COMPOUND == dtype->shared->type) { + if (H5T_COMPOUND == dtype->shared->type) { H5T_order_t memb_order = H5T_ORDER_NONE; - int nmemb; /* Number of members in compound & enum types */ - int i; /* Local index variable */ + int nmemb; /* Number of members in compound & enum types */ + int i; /* Local index variable */ /* Retrieve the number of members */ - if((nmemb = H5T_get_nmembers(dtype)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, "can't get number of members from compound data type") + if ((nmemb = H5T_get_nmembers(dtype)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, + "can't get number of members from compound data type") /* Get order for each compound member type. */ - for(i = 0; i < nmemb; i++) { + for (i = 0; i < nmemb; i++) { /* Get order for member */ - if((memb_order = H5T_get_order(dtype->shared->u.compnd.memb[i].type)) == H5T_ORDER_ERROR) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5T_ORDER_ERROR, "can't get order for compound member") + if ((memb_order = H5T_get_order(dtype->shared->u.compnd.memb[i].type)) == H5T_ORDER_ERROR) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5T_ORDER_ERROR, + "can't get order for compound member") /* Ignore the H5T_ORDER_NONE, write down the first non H5T_ORDER_NONE order. */ - if(memb_order != H5T_ORDER_NONE && ret_value == H5T_ORDER_NONE) + if (memb_order != H5T_ORDER_NONE && ret_value == H5T_ORDER_NONE) ret_value = memb_order; /* If the orders are mixed, stop the loop and report it. * (H5T_ORDER_NONE is ignored) */ - if(memb_order != H5T_ORDER_NONE && ret_value != H5T_ORDER_NONE - && memb_order != ret_value) { + if (memb_order != H5T_ORDER_NONE && ret_value != H5T_ORDER_NONE && memb_order != ret_value) { ret_value = H5T_ORDER_MIXED; break; } /* end if */ - } /* end for */ - } /* end if */ - } /* end else */ + } /* end for */ + } /* end if */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_order() */ - /*------------------------------------------------------------------------- * Function: H5Tset_order * @@ -199,31 +187,30 @@ done: herr_t H5Tset_order(hid_t type_id, H5T_order_t order) { - H5T_t *dt = NULL; /* Datatype to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt = NULL; /* Datatype to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTo", type_id, order); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(order < H5T_ORDER_LE || order > H5T_ORDER_NONE || order == H5T_ORDER_MIXED) + if (order < H5T_ORDER_LE || order > H5T_ORDER_NONE || order == H5T_ORDER_MIXED) HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order") - if(NULL != dt->vol_obj) + if (NULL != dt->vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") - if(H5T_STATE_TRANSIENT != dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is read-only") /* Call internal routine to set the order */ - if(H5T_set_order(dt, order) < 0) + if (H5T_set_order(dt, order) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "can't set order") done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_order() */ - /*------------------------------------------------------------------------- * Function: H5T_set_order * @@ -239,47 +226,47 @@ done: static herr_t H5T_set_order(H5T_t *dtype, H5T_order_t order) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5T_ENUM == dtype->shared->type && dtype->shared->u.enumer.nmembs > 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "operation not allowed after enum members are defined") + if (H5T_ENUM == dtype->shared->type && dtype->shared->u.enumer.nmembs > 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "operation not allowed after enum members are defined") /* For derived data type, defer to parent */ - while(dtype->shared->parent) + while (dtype->shared->parent) dtype = dtype->shared->parent; /* Check for setting order on inappropriate datatype */ - if(order == H5T_ORDER_NONE && !(H5T_REFERENCE == dtype->shared->type || - H5T_OPAQUE == dtype->shared->type || H5T_IS_FIXED_STRING(dtype->shared))) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order for type") + if (order == H5T_ORDER_NONE && !(H5T_REFERENCE == dtype->shared->type || + H5T_OPAQUE == dtype->shared->type || H5T_IS_FIXED_STRING(dtype->shared))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order for type") /* For atomic data type */ - if(H5T_IS_ATOMIC(dtype->shared)) + if (H5T_IS_ATOMIC(dtype->shared)) dtype->shared->u.atomic.order = order; else { /* Check for compound datatype */ - if(H5T_COMPOUND == dtype->shared->type) { - int nmemb; /* Number of members in type */ - int i; /* Local index variable */ + if (H5T_COMPOUND == dtype->shared->type) { + int nmemb; /* Number of members in type */ + int i; /* Local index variable */ /* Retrieve the number of fields in the compound datatype */ - if((nmemb = H5T_get_nmembers(dtype)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get number of members from compound data type") + if ((nmemb = H5T_get_nmembers(dtype)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, + "can't get number of members from compound data type") /* Check for uninitialized compound datatype */ - if(nmemb == 0) + if (nmemb == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_UNINITIALIZED, FAIL, "no member is in the compound data type") /* Loop through all fields of compound type, setting the order */ - for(i = 0; i < nmemb; i++) - if(H5T_set_order(dtype->shared->u.compnd.memb[i].type, order) < 0) + for (i = 0; i < nmemb; i++) + if (H5T_set_order(dtype->shared->u.compnd.memb[i].type, order) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set order for compound member") } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_set_order() */ - diff --git a/src/H5Tpad.c b/src/H5Tpad.c index c96f42a..ecb4b30 100644 --- a/src/H5Tpad.c +++ b/src/H5Tpad.c @@ -16,16 +16,13 @@ * the datatype padding for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ - - - /*------------------------------------------------------------------------- * Function: H5Tget_pad * @@ -45,16 +42,16 @@ *------------------------------------------------------------------------- */ herr_t -H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) +H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out*/, H5T_pad_t *msb /*out*/) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", type_id, lsb, msb); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ @@ -71,7 +68,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tset_pad * @@ -91,20 +87,20 @@ done: herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iTpTp", type_id, lsb, msb); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (lsb < H5T_PAD_ZERO || lsb >= H5T_NPAD || msb < H5T_PAD_ZERO || msb >= H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type") - if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ @@ -118,4 +114,3 @@ H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 600d7aa..719aa17 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -30,46 +30,46 @@ * Define this to enable debugging. */ #ifdef NDEBUG -# undef H5T_DEBUG +#undef H5T_DEBUG #endif /* Get package's private header */ #include "H5Tprivate.h" /* Other private headers needed by this file */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Other public headers needed by this file */ -#include "H5Spublic.h" /* Dataspace functions */ +#include "H5Spublic.h" /* Dataspace functions */ /* Length of debugging name buffer */ -#define H5T_NAMELEN 32 +#define H5T_NAMELEN 32 /* Macro to ease detecting "complex" datatypes (i.e. those with base types or fields) */ -#define H5T_IS_COMPLEX(t) ((t) == H5T_COMPOUND || (t) == H5T_ENUM || (t) == H5T_VLEN || (t) == H5T_ARRAY) +#define H5T_IS_COMPLEX(t) ((t) == H5T_COMPOUND || (t) == H5T_ENUM || (t) == H5T_VLEN || (t) == H5T_ARRAY) /* Macro to ease detecting fixed "string" datatypes */ #define H5T_IS_FIXED_STRING(dt) (H5T_STRING == (dt)->type) /* Macro to ease detecting variable-length "string" datatypes */ -#define H5T_IS_VL_STRING(dt) (H5T_VLEN == (dt)->type && H5T_VLEN_STRING == (dt)->u.vlen.type) +#define H5T_IS_VL_STRING(dt) (H5T_VLEN == (dt)->type && H5T_VLEN_STRING == (dt)->u.vlen.type) /* Macro to ease detecting fixed or variable-length "string" datatypes */ -#define H5T_IS_STRING(dt) (H5T_IS_FIXED_STRING(dt) || H5T_IS_VL_STRING(dt)) +#define H5T_IS_STRING(dt) (H5T_IS_FIXED_STRING(dt) || H5T_IS_VL_STRING(dt)) /* Macro to ease detecting atomic datatypes */ -#define H5T_IS_ATOMIC(dt) (!(H5T_IS_COMPLEX((dt)->type) || (dt)->type == H5T_OPAQUE)) +#define H5T_IS_ATOMIC(dt) (!(H5T_IS_COMPLEX((dt)->type) || (dt)->type == H5T_OPAQUE)) /* Macro to ease retrieving class of shared datatype */ /* (Externally, a VL string is a string; internally, a VL string is a VL. Lie * to the user if they have a VL string and tell them it's in the string * class) */ -#define H5T_GET_CLASS(shared, internal) ((internal) ? (shared)->type : (H5T_IS_VL_STRING(shared) ? H5T_STRING : (shared)->type)) - +#define H5T_GET_CLASS(shared, internal) \ + ((internal) ? (shared)->type : (H5T_IS_VL_STRING(shared) ? H5T_STRING : (shared)->type)) /* * Datatype encoding versions @@ -80,13 +80,13 @@ * vlen sequences of objects which aren't arrays, etc.) or VAX byte-ordered * objects. */ -#define H5O_DTYPE_VERSION_1 1 +#define H5O_DTYPE_VERSION_1 1 /* This is the version to create all datatypes which contain H5T_ARRAY * class objects (array definitely, potentially compound & vlen sequences also), * but not VAX byte-ordered objects. */ -#define H5O_DTYPE_VERSION_2 2 +#define H5O_DTYPE_VERSION_2 2 /* This is the version to create all datatypes which contain VAX byte-ordered * objects (floating-point types, currently). @@ -94,7 +94,7 @@ /* This version also packs compound & enum field names without padding */ /* This version also encodes the member offset of compound fields more efficiently */ /* This version also encodes array types more efficiently */ -#define H5O_DTYPE_VERSION_3 3 +#define H5O_DTYPE_VERSION_3 3 /* This is the version that adds support for new reference types and prevents * older versions of the library to attempt reading unknown types. @@ -105,20 +105,20 @@ * and 'size' callback for places to change when updating this. */ #define H5O_DTYPE_VERSION_LATEST H5O_DTYPE_VERSION_4 - /* Flags for visiting datatype */ -#define H5T_VISIT_COMPLEX_FIRST 0x01 /* Visit complex datatype before visiting member/parent datatypes */ -#define H5T_VISIT_COMPLEX_LAST 0x02 /* Visit complex datatype after visiting member/parent datatypes */ - /* (setting both flags will mean visiting complex type twice) */ -#define H5T_VISIT_SIMPLE 0x04 /* Visit simple datatypes (at all) */ - /* (setting H5T_VISIT_SIMPLE and _not_ setting either H5T_VISIT_COMPLEX_FIRST or H5T_VISIT_COMPLEX_LAST will mean visiting _only_ "simple" "leafs" in the "tree" */ - /* (_not_ setting H5T_VISIT_SIMPLE and setting either H5T_VISIT_COMPLEX_FIRST or H5T_VISIT_COMPLEX_LAST will mean visiting all nodes _except_ "simple" "leafs" in the "tree" */ - +#define H5T_VISIT_COMPLEX_FIRST 0x01 /* Visit complex datatype before visiting member/parent datatypes */ +#define H5T_VISIT_COMPLEX_LAST 0x02 /* Visit complex datatype after visiting member/parent datatypes */ + /* (setting both flags will mean visiting complex type twice) */ +#define H5T_VISIT_SIMPLE 0x04 /* Visit simple datatypes (at all) */ +/* (setting H5T_VISIT_SIMPLE and _not_ setting either H5T_VISIT_COMPLEX_FIRST or H5T_VISIT_COMPLEX_LAST will + * mean visiting _only_ "simple" "leafs" in the "tree" */ +/* (_not_ setting H5T_VISIT_SIMPLE and setting either H5T_VISIT_COMPLEX_FIRST or H5T_VISIT_COMPLEX_LAST will + * mean visiting all nodes _except_ "simple" "leafs" in the "tree" */ /* Define an internal macro for converting long long to long double. Mac OS 10.4 gives some * incorrect conversions. */ #if (H5_WANT_DATA_ACCURACY && defined(H5_LLONG_TO_LDOUBLE_CORRECT)) || (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_LLONG_LDOUBLE 1 +#define H5T_CONV_INTERNAL_LLONG_LDOUBLE 1 #endif /* Define an internal macro for converting unsigned long long to long double. SGI compilers give @@ -127,150 +127,152 @@ * compiler tries to do the conversion. For Cygwin, compiler doesn't do rounding correctly. * Mac OS 10.4 gives some incorrect result. */ #if (H5_WANT_DATA_ACCURACY && defined(H5_LLONG_TO_LDOUBLE_CORRECT)) || (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1 +#define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1 #endif /* Define an internal macro for converting long double to long long. SGI compilers give some incorrect * conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates floating exception. * The hard conversion on Windows .NET 2003 has a bug and gives wrong exception value. */ -#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || \ - (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_LDOUBLE_LLONG 1 +#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || (!H5_WANT_DATA_ACCURACY) +#define H5T_CONV_INTERNAL_LDOUBLE_LLONG 1 #endif /* Define an internal macro for converting long double to unsigned long long. SGI compilers give some * incorrect conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates * floating exception. */ -#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || \ - (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 1 +#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || (!H5_WANT_DATA_ACCURACY) +#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 1 #else -#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 0 +#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 0 #endif /* Statistics about a conversion function */ struct H5T_stats_t { - unsigned ncalls; /*num calls to conversion function */ - hsize_t nelmts; /*total data points converted */ - H5_timevals_t times; /*total time for conversion */ + unsigned ncalls; /*num calls to conversion function */ + hsize_t nelmts; /*total data points converted */ + H5_timevals_t times; /*total time for conversion */ }; /* Library internal datatype conversion functions are... */ -typedef herr_t (*H5T_lib_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +typedef herr_t (*H5T_lib_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); /* Conversion callbacks (library internal ones don't need DXPL) */ typedef struct H5T_conv_func_t { - hbool_t is_app; /* Whether conversion function is registered from application */ + hbool_t is_app; /* Whether conversion function is registered from application */ union { - H5T_conv_t app_func; /* Application data conversion function */ - H5T_lib_conv_t lib_func; /* Library internal data conversion function */ + H5T_conv_t app_func; /* Application data conversion function */ + H5T_lib_conv_t lib_func; /* Library internal data conversion function */ } u; } H5T_conv_func_t; /* The datatype conversion database */ struct H5T_path_t { - char name[H5T_NAMELEN]; /*name for debugging only */ - H5T_t *src; /*source datatype */ - H5T_t *dst; /*destination datatype */ - H5T_conv_func_t conv; /* Conversion function */ - hbool_t is_hard; /*is it a hard function? */ - hbool_t is_noop; /*is it the noop conversion? */ - hbool_t are_compounds; /*are source and dest both compounds?*/ - H5T_stats_t stats; /*statistics for the conversion */ - H5T_cdata_t cdata; /*data for this function */ + char name[H5T_NAMELEN]; /*name for debugging only */ + H5T_t * src; /*source datatype */ + H5T_t * dst; /*destination datatype */ + H5T_conv_func_t conv; /* Conversion function */ + hbool_t is_hard; /*is it a hard function? */ + hbool_t is_noop; /*is it the noop conversion? */ + hbool_t are_compounds; /*are source and dest both compounds?*/ + H5T_stats_t stats; /*statistics for the conversion */ + H5T_cdata_t cdata; /*data for this function */ }; /* Reference function pointers */ typedef herr_t (*H5T_ref_isnullfunc_t)(const H5VL_object_t *file, const void *src_buf, hbool_t *isnull); typedef herr_t (*H5T_ref_setnullfunc_t)(H5VL_object_t *file, void *dst_buf, void *bg_buf); -typedef size_t (*H5T_ref_getsizefunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, hbool_t *dst_copy); -typedef herr_t (*H5T_ref_readfunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); -typedef herr_t (*H5T_ref_writefunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size, void *bg_buf); +typedef size_t (*H5T_ref_getsizefunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +typedef herr_t (*H5T_ref_readfunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +typedef herr_t (*H5T_ref_writefunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, + size_t dst_size, void *bg_buf); typedef struct H5T_ref_class_t { - H5T_ref_isnullfunc_t isnull; /* check if reference value is NIL */ - H5T_ref_setnullfunc_t setnull; /* set a reference value to NIL */ - H5T_ref_getsizefunc_t getsize; /* get reference size (bytes) */ - H5T_ref_readfunc_t read; /* read reference into buffer */ - H5T_ref_writefunc_t write; /* write reference from buffer */ + H5T_ref_isnullfunc_t isnull; /* check if reference value is NIL */ + H5T_ref_setnullfunc_t setnull; /* set a reference value to NIL */ + H5T_ref_getsizefunc_t getsize; /* get reference size (bytes) */ + H5T_ref_readfunc_t read; /* read reference into buffer */ + H5T_ref_writefunc_t write; /* write reference from buffer */ } H5T_ref_class_t; typedef struct H5T_atomic_t { - H5T_order_t order; /* byte order */ - size_t prec; /* precision in bits */ - size_t offset; /* bit position of lsb of value */ - H5T_pad_t lsb_pad; /* type of lsb padding */ - H5T_pad_t msb_pad; /* type of msb padding */ + H5T_order_t order; /* byte order */ + size_t prec; /* precision in bits */ + size_t offset; /* bit position of lsb of value */ + H5T_pad_t lsb_pad; /* type of lsb padding */ + H5T_pad_t msb_pad; /* type of msb padding */ union { struct { - H5T_sign_t sign; /* type of integer sign */ - } i; /* integer; integer types */ + H5T_sign_t sign; /* type of integer sign */ + } i; /* integer; integer types */ struct { - size_t sign; /* bit position of sign bit */ - size_t epos; /* position of lsb of exponent */ - size_t esize; /* size of exponent in bits */ - uint64_t ebias; /* exponent bias */ - size_t mpos; /* position of lsb of mantissa */ - size_t msize; /* size of mantissa */ - H5T_norm_t norm; /* normalization */ - H5T_pad_t pad; /* type of padding for internal bits */ - } f; /* floating-point types */ + size_t sign; /* bit position of sign bit */ + size_t epos; /* position of lsb of exponent */ + size_t esize; /* size of exponent in bits */ + uint64_t ebias; /* exponent bias */ + size_t mpos; /* position of lsb of mantissa */ + size_t msize; /* size of mantissa */ + H5T_norm_t norm; /* normalization */ + H5T_pad_t pad; /* type of padding for internal bits */ + } f; /* floating-point types */ struct { - H5T_cset_t cset; /* character set */ - H5T_str_t pad; /* space or null padding of extra bytes */ - } s; /* string types */ + H5T_cset_t cset; /* character set */ + H5T_str_t pad; /* space or null padding of extra bytes */ + } s; /* string types */ struct { - H5R_type_t rtype; /* type of reference stored */ - unsigned version; /* version of encoded reference */ - hbool_t opaque; /* opaque reference type */ - H5T_loc_t loc; /* location of data in buffer */ - H5VL_object_t *file; /* file VOL pointer (if data is on disk) */ - const H5T_ref_class_t *cls; /* Pointer to ref class callbacks */ - } r; /* reference types */ + H5R_type_t rtype; /* type of reference stored */ + unsigned version; /* version of encoded reference */ + hbool_t opaque; /* opaque reference type */ + H5T_loc_t loc; /* location of data in buffer */ + H5VL_object_t * file; /* file VOL pointer (if data is on disk) */ + const H5T_ref_class_t *cls; /* Pointer to ref class callbacks */ + } r; /* reference types */ } u; } H5T_atomic_t; /* How members are sorted for compound or enum datatypes */ typedef enum H5T_sort_t { - H5T_SORT_NONE = 0, /*not sorted */ - H5T_SORT_NAME = 1, /*sorted by member name */ - H5T_SORT_VALUE = 2 /*sorted by memb offset or enum value*/ + H5T_SORT_NONE = 0, /*not sorted */ + H5T_SORT_NAME = 1, /*sorted by member name */ + H5T_SORT_VALUE = 2 /*sorted by memb offset or enum value*/ } H5T_sort_t; /* A compound datatype member */ typedef struct H5T_cmemb_t { - char *name; /*name of this member */ - size_t offset; /*offset from beginning of struct */ - size_t size; /*size of this member */ - struct H5T_t *type; /*type of this member */ + char * name; /*name of this member */ + size_t offset; /*offset from beginning of struct */ + size_t size; /*size of this member */ + struct H5T_t *type; /*type of this member */ } H5T_cmemb_t; /* A compound datatype */ typedef struct H5T_compnd_t { - unsigned nalloc; /*num entries allocated in MEMB array*/ - unsigned nmembs; /*number of members defined in struct*/ - H5T_sort_t sorted; /*how are members sorted? */ - hbool_t packed; /*are members packed together? */ - H5T_cmemb_t *memb; /*array of struct members */ - size_t memb_size; /*total of all member sizes */ + unsigned nalloc; /*num entries allocated in MEMB array*/ + unsigned nmembs; /*number of members defined in struct*/ + H5T_sort_t sorted; /*how are members sorted? */ + hbool_t packed; /*are members packed together? */ + H5T_cmemb_t *memb; /*array of struct members */ + size_t memb_size; /*total of all member sizes */ } H5T_compnd_t; /* An enumeration datatype */ typedef struct H5T_enum_t { - unsigned nalloc; /*num entries allocated */ - unsigned nmembs; /*number of members defined in enum */ - H5T_sort_t sorted; /*how are members sorted? */ - void *value; /*array of values */ - char **name; /*array of symbol names */ + unsigned nalloc; /*num entries allocated */ + unsigned nmembs; /*number of members defined in enum */ + H5T_sort_t sorted; /*how are members sorted? */ + void * value; /*array of values */ + char ** name; /*array of symbol names */ } H5T_enum_t; /* VL types */ typedef enum { - H5T_VLEN_BADTYPE = -1, /* invalid VL Type */ + H5T_VLEN_BADTYPE = -1, /* invalid VL Type */ H5T_VLEN_SEQUENCE = 0, /* VL sequence */ H5T_VLEN_STRING, /* VL string */ H5T_VLEN_MAXTYPE /* highest type (Invalid as true type) */ @@ -278,106 +280,108 @@ typedef enum { /* VL function pointers */ typedef herr_t (*H5T_vlen_getlen_func_t)(H5VL_object_t *file, const void *vl_addr, size_t *len); -typedef void * (*H5T_vlen_getptr_func_t)(void *vl_addr); +typedef void *(*H5T_vlen_getptr_func_t)(void *vl_addr); typedef herr_t (*H5T_vlen_isnull_func_t)(const H5VL_object_t *file, void *vl_addr, hbool_t *isnull); typedef herr_t (*H5T_vlen_setnull_func_t)(H5VL_object_t *file, void *_vl, void *_bg); typedef herr_t (*H5T_vlen_read_func_t)(H5VL_object_t *file, void *_vl, void *buf, size_t len); -typedef herr_t (*H5T_vlen_write_func_t)(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size); +typedef herr_t (*H5T_vlen_write_func_t)(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size); typedef herr_t (*H5T_vlen_delete_func_t)(H5VL_object_t *file, const void *_vl); /* VL datatype callbacks */ typedef struct H5T_vlen_class_t { - H5T_vlen_getlen_func_t getlen; /* Function to get VL sequence size (in element units, not bytes) */ - H5T_vlen_getptr_func_t getptr; /* Function to get VL sequence pointer */ - H5T_vlen_isnull_func_t isnull; /* Function to check if VL value is NIL */ - H5T_vlen_setnull_func_t setnull;/* Function to set a VL value to NIL */ - H5T_vlen_read_func_t read; /* Function to read VL sequence into buffer */ - H5T_vlen_write_func_t write; /* Function to write VL sequence from buffer */ - H5T_vlen_delete_func_t del; /* Function to delete VL sequence */ + H5T_vlen_getlen_func_t getlen; /* Function to get VL sequence size (in element units, not bytes) */ + H5T_vlen_getptr_func_t getptr; /* Function to get VL sequence pointer */ + H5T_vlen_isnull_func_t isnull; /* Function to check if VL value is NIL */ + H5T_vlen_setnull_func_t setnull; /* Function to set a VL value to NIL */ + H5T_vlen_read_func_t read; /* Function to read VL sequence into buffer */ + H5T_vlen_write_func_t write; /* Function to write VL sequence from buffer */ + H5T_vlen_delete_func_t del; /* Function to delete VL sequence */ } H5T_vlen_class_t; /* A VL datatype */ typedef struct H5T_vlen_t { - H5T_vlen_type_t type; /* Type of VL data in buffer */ - H5T_loc_t loc; /* Location of VL data in buffer */ - H5T_cset_t cset; /* For VL string: character set */ - H5T_str_t pad; /* For VL string: space or null padding of - * extra bytes */ - H5VL_object_t *file; /* File object (if VL data is on disk) */ - const H5T_vlen_class_t *cls; /* Pointer to VL class callbacks */ + H5T_vlen_type_t type; /* Type of VL data in buffer */ + H5T_loc_t loc; /* Location of VL data in buffer */ + H5T_cset_t cset; /* For VL string: character set */ + H5T_str_t pad; /* For VL string: space or null padding of + * extra bytes */ + H5VL_object_t * file; /* File object (if VL data is on disk) */ + const H5T_vlen_class_t *cls; /* Pointer to VL class callbacks */ } H5T_vlen_t; /* An opaque datatype */ typedef struct H5T_opaque_t { - char *tag; /*short type description string */ + char *tag; /*short type description string */ } H5T_opaque_t; /* An array datatype */ typedef struct H5T_array_t { - size_t nelem; /* total number of elements in array */ - unsigned ndims; /* member dimensionality */ - size_t dim[H5S_MAX_RANK]; /* size in each dimension */ + size_t nelem; /* total number of elements in array */ + unsigned ndims; /* member dimensionality */ + size_t dim[H5S_MAX_RANK]; /* size in each dimension */ } H5T_array_t; typedef enum H5T_state_t { - H5T_STATE_TRANSIENT, /*type is a modifiable, closable transient */ - H5T_STATE_RDONLY, /*transient, not modifiable, closable */ - H5T_STATE_IMMUTABLE, /*transient, not modifiable, not closable */ - H5T_STATE_NAMED, /*named constant, not open */ - H5T_STATE_OPEN /*named constant, open object header */ + H5T_STATE_TRANSIENT, /*type is a modifiable, closable transient */ + H5T_STATE_RDONLY, /*transient, not modifiable, closable */ + H5T_STATE_IMMUTABLE, /*transient, not modifiable, not closable */ + H5T_STATE_NAMED, /*named constant, not open */ + H5T_STATE_OPEN /*named constant, open object header */ } H5T_state_t; - /* This struct is shared between all occurrences of an open named type */ +/* This struct is shared between all occurrences of an open named type */ typedef struct H5T_shared_t { - hsize_t fo_count; /* number of references to this file object */ - H5T_state_t state; /*current state of the type */ - H5T_class_t type; /*which class of type is this? */ - size_t size; /*total size of an instance of this type */ - unsigned version; /* Version of object header message to encode this object with */ - hbool_t force_conv;/* Set if this type always needs to be converted and H5T__conv_noop cannot be called */ - struct H5T_t *parent;/*parent type for derived datatypes */ - H5VL_object_t *owned_vol_obj; /* Vol object owned by this type (free on close) */ + hsize_t fo_count; /* number of references to this file object */ + H5T_state_t state; /*current state of the type */ + H5T_class_t type; /*which class of type is this? */ + size_t size; /*total size of an instance of this type */ + unsigned version; /* Version of object header message to encode this object with */ + hbool_t + force_conv; /* Set if this type always needs to be converted and H5T__conv_noop cannot be called */ + struct H5T_t * parent; /*parent type for derived datatypes */ + H5VL_object_t *owned_vol_obj; /* Vol object owned by this type (free on close) */ union { - H5T_atomic_t atomic; /* an atomic datatype */ - H5T_compnd_t compnd; /* a compound datatype (struct) */ - H5T_enum_t enumer; /* an enumeration type (enum) */ - H5T_vlen_t vlen; /* a variable-length datatype */ - H5T_opaque_t opaque; /* an opaque datatype */ - H5T_array_t array; /* an array datatype */ + H5T_atomic_t atomic; /* an atomic datatype */ + H5T_compnd_t compnd; /* a compound datatype (struct) */ + H5T_enum_t enumer; /* an enumeration type (enum) */ + H5T_vlen_t vlen; /* a variable-length datatype */ + H5T_opaque_t opaque; /* an opaque datatype */ + H5T_array_t array; /* an array datatype */ } u; } H5T_shared_t; struct H5T_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ - H5T_shared_t *shared; /* all other information */ - H5O_loc_t oloc; /* Object location, if the type is a named type */ - H5G_name_t path; /* group hier. path if the type is a named type */ - H5VL_object_t *vol_obj; /* pointer to VOL object when working with committed datatypes */ + H5T_shared_t * shared; /* all other information */ + H5O_loc_t oloc; /* Object location, if the type is a named type */ + H5G_name_t path; /* group hier. path if the type is a named type */ + H5VL_object_t *vol_obj; /* pointer to VOL object when working with committed datatypes */ }; /* The master list of soft conversion functions */ typedef struct H5T_soft_t { - char name[H5T_NAMELEN]; /*name for debugging only */ - H5T_class_t src; /*source datatype class */ - H5T_class_t dst; /*destination datatype class */ - H5T_conv_func_t conv; /*the conversion function */ + char name[H5T_NAMELEN]; /*name for debugging only */ + H5T_class_t src; /*source datatype class */ + H5T_class_t dst; /*destination datatype class */ + H5T_conv_func_t conv; /*the conversion function */ } H5T_soft_t; /* Bit search direction */ typedef enum H5T_sdir_t { - H5T_BIT_LSB, /*search lsb toward msb */ - H5T_BIT_MSB /*search msb toward lsb */ + H5T_BIT_LSB, /*search lsb toward msb */ + H5T_BIT_MSB /*search msb toward lsb */ } H5T_sdir_t; /* Typedef for named datatype creation operation */ typedef struct { - H5T_t *dt; /* Datatype to commit */ - hid_t tcpl_id; /* Named datatype creation property list */ + H5T_t *dt; /* Datatype to commit */ + hid_t tcpl_id; /* Named datatype creation property list */ } H5T_obj_create_t; /* Typedef for datatype iteration operations */ -typedef herr_t (*H5T_operator_t)(H5T_t *dt, void *op_data/*in,out*/); +typedef herr_t (*H5T_operator_t)(H5T_t *dt, void *op_data /*in,out*/); /* Array of versions for Datatype */ H5_DLLVAR const unsigned H5O_dtype_ver_bounds[H5F_LIBVER_NBOUNDS]; @@ -389,15 +393,15 @@ H5_DLLVAR const unsigned H5O_dtype_ver_bounds[H5F_LIBVER_NBOUNDS]; * not calculated. These alignment info is only for H5Tget_native_type. * These values are used for structure alignment. */ -H5_DLLVAR size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_SHORT_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_LONG_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_LLONG_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g; -#if H5_SIZEOF_LONG_DOUBLE !=0 -H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_SHORT_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_LONG_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_LLONG_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g; +#if H5_SIZEOF_LONG_DOUBLE != 0 +H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; #endif H5_DLLVAR size_t H5T_POINTER_COMP_ALIGN_g; @@ -412,58 +416,58 @@ H5_DLLVAR size_t H5T_REF_COMP_ALIGN_g; * N=1 no alignment is required; N=0 implies that alignment constraints were * not calculated. */ -H5_DLLVAR size_t H5T_NATIVE_SCHAR_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UCHAR_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_SHORT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_USHORT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_LONG_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_ULONG_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_LLONG_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_ULLONG_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_FLOAT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_DOUBLE_ALIGN_g; -#if H5_SIZEOF_LONG_DOUBLE !=0 -H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_SCHAR_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UCHAR_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_SHORT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_USHORT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_LONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_ULONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_LLONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_ULLONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_FLOAT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_DOUBLE_ALIGN_g; +#if H5_SIZEOF_LONG_DOUBLE != 0 +H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_ALIGN_g; #endif /* C9x alignment constraints */ -H5_DLLVAR size_t H5T_NATIVE_INT8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_LEAST8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_FAST8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_FAST8_ALIGN_g; - -H5_DLLVAR size_t H5T_NATIVE_INT16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_LEAST16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_FAST16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_FAST16_ALIGN_g; - -H5_DLLVAR size_t H5T_NATIVE_INT32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_LEAST32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_FAST32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_FAST32_ALIGN_g; - -H5_DLLVAR size_t H5T_NATIVE_INT64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_LEAST64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_FAST64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_FAST64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_LEAST8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_FAST8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_FAST8_ALIGN_g; + +H5_DLLVAR size_t H5T_NATIVE_INT16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_LEAST16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_FAST16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_FAST16_ALIGN_g; + +H5_DLLVAR size_t H5T_NATIVE_INT32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_LEAST32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_FAST32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_FAST32_ALIGN_g; + +H5_DLLVAR size_t H5T_NATIVE_INT64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_LEAST64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_FAST64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_FAST64_ALIGN_g; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ -H5_DLLVAR float H5T_NATIVE_FLOAT_POS_INF_g; -H5_DLLVAR float H5T_NATIVE_FLOAT_NEG_INF_g; +H5_DLLVAR float H5T_NATIVE_FLOAT_POS_INF_g; +H5_DLLVAR float H5T_NATIVE_FLOAT_NEG_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_POS_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_NEG_INF_g; -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 H5_DLLVAR double H5T_NATIVE_LDOUBLE_POS_INF_g; H5_DLLVAR double H5T_NATIVE_LDOUBLE_NEG_INF_g; #endif @@ -477,708 +481,383 @@ H5_DLL herr_t H5T__init_native(void); H5_DLL H5T_t *H5T__create(H5T_class_t type, size_t size); H5_DLL H5T_t *H5T__alloc(void); H5_DLL herr_t H5T__free(H5T_t *dt); -H5_DLL herr_t H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, - void *op_value); +H5_DLL herr_t H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value); H5_DLL herr_t H5T__upgrade_version(H5T_t *dt, unsigned new_version); /* Committed / named datatype routines */ H5_DLL herr_t H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id); H5_DLL herr_t H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id); -H5_DLL herr_t H5T__commit_named(const H5G_loc_t *loc, const char *name, - H5T_t *dt, hid_t lcpl_id, hid_t tcpl_id); +H5_DLL herr_t H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, hid_t lcpl_id, + hid_t tcpl_id); H5_DLL H5T_t *H5T__open_name(const H5G_loc_t *loc, const char *name); -H5_DLL hid_t H5T__get_create_plist(const H5T_t *type); +H5_DLL hid_t H5T__get_create_plist(const H5T_t *type); /* Conversion functions */ -H5_DLL herr_t H5T__conv_noop(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); - -H5_DLL herr_t H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_noop(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); + +H5_DLL herr_t H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); +H5_DLL herr_t H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); +H5_DLL herr_t H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); +H5_DLL herr_t H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); +H5_DLL herr_t H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); - -H5_DLL herr_t H5T__conv_short_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); - -H5_DLL herr_t H5T__conv_int_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); - -H5_DLL herr_t H5T__conv_long_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); - -H5_DLL herr_t H5T__conv_llong_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uchar_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_short_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ushort_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_int_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_uint_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_long_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ulong_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_llong_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ullong_ldouble(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_float_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_ldouble_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t bkg_stride, - void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); + +H5_DLL herr_t H5T__conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); + +H5_DLL herr_t H5T__conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); + +H5_DLL herr_t H5T__conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); + +H5_DLL herr_t H5T__conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); /* Bit twiddling functions */ -H5_DLL void H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, - size_t src_offset, size_t size); -H5_DLL herr_t H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size); -H5_DLL void H5T__bit_set(uint8_t *buf, size_t offset, size_t size, - hbool_t value); +H5_DLL void H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, size_t src_offset, + size_t size); +H5_DLL herr_t H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size); +H5_DLL void H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value); H5_DLL uint64_t H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size); -H5_DLL void H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, - uint64_t val); -H5_DLL ssize_t H5T__bit_find(uint8_t *buf, size_t offset, size_t size, - H5T_sdir_t direction, hbool_t value); -H5_DLL hbool_t H5T__bit_inc(uint8_t *buf, size_t start, size_t size); -H5_DLL hbool_t H5T__bit_dec(uint8_t *buf, size_t start, size_t size); -H5_DLL void H5T__bit_neg(uint8_t *buf, size_t start, size_t size); +H5_DLL void H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val); +H5_DLL ssize_t H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, hbool_t value); +H5_DLL hbool_t H5T__bit_inc(uint8_t *buf, size_t start, size_t size); +H5_DLL hbool_t H5T__bit_dec(uint8_t *buf, size_t start, size_t size); +H5_DLL void H5T__bit_neg(uint8_t *buf, size_t start, size_t size); /* VL functions */ -H5_DLL H5T_t * H5T__vlen_create(const H5T_t *base); +H5_DLL H5T_t *H5T__vlen_create(const H5T_t *base); H5_DLL htri_t H5T__vlen_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc); /* Array functions */ @@ -1190,10 +869,9 @@ H5_DLL int H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]); H5_DLL htri_t H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc); /* Compound functions */ -H5_DLL herr_t H5T__insert(H5T_t *parent, const char *name, size_t offset, - const H5T_t *member); +H5_DLL herr_t H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member); H5_DLL size_t H5T__get_member_size(const H5T_t *dt, unsigned membno); -H5_DLL void H5T__update_packed(const H5T_t *dt); +H5_DLL void H5T__update_packed(const H5T_t *dt); H5_DLL H5T_subset_info_t *H5T__conv_struct_subset(const H5T_cdata_t *cdata); /* Enumerated type functions */ @@ -1202,12 +880,11 @@ H5_DLL herr_t H5T__enum_insert(const H5T_t *dt, const char *name, const void *va H5_DLL herr_t H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value); /* Field functions (for both compound & enumerated types) */ -H5_DLL char *H5T__get_member_name(H5T_t const *dt, unsigned membno); +H5_DLL char * H5T__get_member_name(H5T_t const *dt, unsigned membno); H5_DLL herr_t H5T__sort_value(const H5T_t *dt, int *map); H5_DLL herr_t H5T__sort_name(const H5T_t *dt, int *map); /* Debugging functions */ -H5_DLL herr_t H5T__print_stats(H5T_path_t *path, int *nprint/*in,out*/); +H5_DLL herr_t H5T__print_stats(H5T_path_t *path, int *nprint /*in,out*/); #endif /* _H5Tpkg_H */ - diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index bd28fc2..d1570a8 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -16,19 +16,16 @@ * the datatype precision for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ static herr_t H5T_set_precision(const H5T_t *dt, size_t prec); - - /*------------------------------------------------------------------------- * Function: H5Tget_precision * @@ -54,25 +51,24 @@ static herr_t H5T_set_precision(const H5T_t *dt, size_t prec); size_t H5Tget_precision(hid_t type_id) { - H5T_t *dt; - size_t ret_value; + H5T_t *dt; + size_t ret_value; FUNC_ENTER_API(0) H5TRACE1("z", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") /* Get precision */ - if((ret_value = H5T_get_precision(dt)) == 0) + if ((ret_value = H5T_get_precision(dt)) == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, 0, "cant't get precision for specified datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_precision() */ - /*------------------------------------------------------------------------- * Function: H5T_get_precision * @@ -93,15 +89,15 @@ done: size_t H5T_get_precision(const H5T_t *dt) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Defer to parent*/ - while(dt->shared->parent) + while (dt->shared->parent) dt = dt->shared->parent; - if(!H5T_IS_ATOMIC(dt->shared)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for specified datatype") + if (!H5T_IS_ATOMIC(dt->shared)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for specified datatype") /* Precision */ ret_value = dt->shared->u.atomic.prec; @@ -110,7 +106,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_precision() */ - /*------------------------------------------------------------------------- * Function: H5Tset_precision * @@ -143,37 +138,36 @@ done: herr_t H5Tset_precision(hid_t type_id, size_t prec) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, prec); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") if (NULL != dt->vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is committed") if (prec == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "precision must be positive") - if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "operation not allowed after members are defined") - if (H5T_STRING==dt->shared->type) + if (H5T_STRING == dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "precision for this type is read-only") - if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) + if (H5T_COMPOUND == dt->shared->type || H5T_OPAQUE == dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified datatype") /* Do the work */ - if (H5T_set_precision(dt, prec)<0) + if (H5T_set_precision(dt, prec) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set precision") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T_set_precision * @@ -206,42 +200,43 @@ done: static herr_t H5T_set_precision(const H5T_t *dt, size_t prec) { - size_t offset, size; - herr_t ret_value=SUCCEED; /* Return value */ + size_t offset, size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(dt); - HDassert(prec>0); - HDassert(H5T_OPAQUE!=dt->shared->type); - HDassert(H5T_COMPOUND!=dt->shared->type); - HDassert(H5T_STRING!=dt->shared->type); - HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(prec > 0); + HDassert(H5T_OPAQUE != dt->shared->type); + HDassert(H5T_COMPOUND != dt->shared->type); + HDassert(H5T_STRING != dt->shared->type); + HDassert(!(H5T_ENUM == dt->shared->type && 0 == dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { - if (H5T_set_precision(dt->shared->parent, prec)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set precision for base type") + if (H5T_set_precision(dt->shared->parent, prec) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set precision for base type") /* Adjust size of datatype appropriately */ - if(dt->shared->type==H5T_ARRAY) + if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; - else if(dt->shared->type!=H5T_VLEN) + else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; - } else { + } + else { if (H5T_IS_ATOMIC(dt->shared)) { - /* Adjust the offset and size */ - offset = dt->shared->u.atomic.offset; - size = dt->shared->size; - if (prec > 8*size) + /* Adjust the offset and size */ + offset = dt->shared->u.atomic.offset; + size = dt->shared->size; + if (prec > 8 * size) offset = 0; - else if (offset+prec > 8 * size) + else if (offset + prec > 8 * size) offset = 8 * size - prec; - if (prec > 8*size) - size = (prec+7) / 8; + if (prec > 8 * size) + size = (prec + 7) / 8; - /* Check that things are still kosher */ - switch (dt->shared->type) { + /* Check that things are still kosher */ + switch (dt->shared->type) { case H5T_INTEGER: case H5T_TIME: case H5T_BITFIELD: @@ -254,10 +249,11 @@ H5T_set_precision(const H5T_t *dt, size_t prec) * first when decreasing the precision of a floating point * type. */ - if (dt->shared->u.atomic.u.f.sign >= prec+offset || - dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || - dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first") + if (dt->shared->u.atomic.u.f.sign >= prec + offset || + dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec + offset || + dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec + offset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "adjust sign, mantissa, and exponent fields first") break; case H5T_NO_CLASS: @@ -271,13 +267,13 @@ H5T_set_precision(const H5T_t *dt, size_t prec) case H5T_NCLASSES: default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class") - } /* end switch */ + } /* end switch */ - /* Commit */ - dt->shared->size = size; + /* Commit */ + dt->shared->size = size; dt->shared->u.atomic.offset = offset; - dt->shared->u.atomic.prec = prec; - } /* end if */ + dt->shared->u.atomic.prec = prec; + } /* end if */ else HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified datatype") } /* end else */ @@ -285,4 +281,3 @@ H5T_set_precision(const H5T_t *dt, size_t prec) done: FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index e05bb4e..d9fe1ac 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -24,33 +24,33 @@ typedef struct H5T_t H5T_t; #include "H5Tpublic.h" /* Other public headers needed by this file */ -#include "H5MMpublic.h" /* Memory management */ +#include "H5MMpublic.h" /* Memory management */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Rprivate.h" /* References */ -#include "H5VLprivate.h" /* VOL Drivers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Rprivate.h" /* References */ +#include "H5VLprivate.h" /* VOL Drivers */ /* Macro for size of temporary buffers to contain a single element */ -#define H5T_ELEM_BUF_SIZE 256 +#define H5T_ELEM_BUF_SIZE 256 /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5T_MODULE -#define H5T_GET_SIZE(T) ((T)->shared->size) -#define H5T_GET_SHARED(T) ((T)->shared) -#define H5T_GET_MEMBER_OFFSET(T, I) ((T)->u.compnd.memb[I].offset) -#define H5T_GET_MEMBER_SIZE(T, I) ((T)->u.compnd.memb[I].shared->size) +#define H5T_GET_SIZE(T) ((T)->shared->size) +#define H5T_GET_SHARED(T) ((T)->shared) +#define H5T_GET_MEMBER_OFFSET(T, I) ((T)->u.compnd.memb[I].offset) +#define H5T_GET_MEMBER_SIZE(T, I) ((T)->u.compnd.memb[I].shared->size) #else /* H5T_MODULE */ -#define H5T_GET_SIZE(T) (H5T_get_size(T)) -#define H5T_GET_SHARED(T) (H5T_get_shared(T)) -#define H5T_GET_MEMBER_OFFSET(T, I) (H5T_get_member_offset((T), (I))) -#define H5T_GET_MEMBER_SIZE(T, I) (H5T_get_member_size((T), (I))) +#define H5T_GET_SIZE(T) (H5T_get_size(T)) +#define H5T_GET_SHARED(T) (H5T_get_shared(T)) +#define H5T_GET_MEMBER_OFFSET(T, I) (H5T_get_member_offset((T), (I))) +#define H5T_GET_MEMBER_SIZE(T, I) (H5T_get_member_size((T), (I))) #endif /* H5T_MODULE */ /* Forward references of package typedefs (declared in H5Tpkg.h) */ typedef struct H5T_stats_t H5T_stats_t; -typedef struct H5T_path_t H5T_path_t; +typedef struct H5T_path_t H5T_path_t; /* Forward reference of H5S_t */ struct H5S_t; @@ -63,24 +63,24 @@ typedef enum H5T_copy_t { /* Location of datatype information */ typedef enum { - H5T_LOC_BADLOC = 0, /* invalid datatype location */ - H5T_LOC_MEMORY, /* data stored in memory */ - H5T_LOC_DISK, /* data stored on disk */ - H5T_LOC_MAXLOC /* highest value (Invalid as true value) */ + H5T_LOC_BADLOC = 0, /* invalid datatype location */ + H5T_LOC_MEMORY, /* data stored in memory */ + H5T_LOC_DISK, /* data stored on disk */ + H5T_LOC_MAXLOC /* highest value (Invalid as true value) */ } H5T_loc_t; /* VL allocation information */ typedef struct { H5MM_allocate_t alloc_func; /* Allocation function */ - void *alloc_info; /* Allocation information */ - H5MM_free_t free_func; /* Free function */ - void *free_info; /* Free information */ + void * alloc_info; /* Allocation information */ + H5MM_free_t free_func; /* Free function */ + void * free_info; /* Free information */ } H5T_vlen_alloc_info_t; /* Structure for conversion callback property */ typedef struct H5T_conv_cb_t { - H5T_conv_except_func_t func; - void* user_data; + H5T_conv_except_func_t func; + void * user_data; } H5T_conv_cb_t; /* Values for the optimization of compound data reading and writing. They indicate @@ -88,16 +88,16 @@ typedef struct H5T_conv_cb_t { * there is no conversion needed. */ typedef enum { - H5T_SUBSET_BADVALUE = -1, /* Invalid value */ - H5T_SUBSET_FALSE = 0, /* Source and destination aren't subset of each other */ - H5T_SUBSET_SRC, /* Source is the subset of dest and no conversion is needed */ - H5T_SUBSET_DST, /* Dest is the subset of source and no conversion is needed */ - H5T_SUBSET_CAP /* Must be the last value */ + H5T_SUBSET_BADVALUE = -1, /* Invalid value */ + H5T_SUBSET_FALSE = 0, /* Source and destination aren't subset of each other */ + H5T_SUBSET_SRC, /* Source is the subset of dest and no conversion is needed */ + H5T_SUBSET_DST, /* Dest is the subset of source and no conversion is needed */ + H5T_SUBSET_CAP /* Must be the last value */ } H5T_subset_t; typedef struct H5T_subset_info_t { - H5T_subset_t subset; /* See above */ - size_t copy_size; /* Size in bytes, to copy for each element */ + H5T_subset_t subset; /* See above */ + size_t copy_size; /* Size in bytes, to copy for each element */ } H5T_subset_info_t; /* Forward declarations for prototype arguments */ @@ -113,26 +113,26 @@ H5_DLL H5T_t *H5T_copy_reopen(H5T_t *old_dt); H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable); H5_DLL herr_t H5T_close(H5T_t *dt); H5_DLL herr_t H5T_close_real(H5T_t *dt); -H5_DLL H5T_t *H5T_get_super(const H5T_t *dt); +H5_DLL H5T_t * H5T_get_super(const H5T_t *dt); H5_DLL H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal); -H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api); -H5_DLL size_t H5T_get_size(const H5T_t *dt); -H5_DLL int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset); -H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc); -H5_DLL H5T_t *H5T_decode(size_t buf_size, const unsigned char *buf); -H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE * stream); +H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api); +H5_DLL size_t H5T_get_size(const H5T_t *dt); +H5_DLL int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset); +H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc); +H5_DLL H5T_t * H5T_decode(size_t buf_size, const unsigned char *buf); +H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE *stream); H5_DLL struct H5O_loc_t *H5T_oloc(H5T_t *dt); H5_DLL H5G_name_t *H5T_nameof(const H5T_t *dt); -H5_DLL htri_t H5T_is_immutable(const H5T_t *dt); -H5_DLL htri_t H5T_is_named(const H5T_t *dt); -H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f); -H5_DLL htri_t H5T_is_relocatable(const H5T_t *dt); +H5_DLL htri_t H5T_is_immutable(const H5T_t *dt); +H5_DLL htri_t H5T_is_named(const H5T_t *dt); +H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f); +H5_DLL htri_t H5T_is_relocatable(const H5T_t *dt); H5_DLL H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst); -H5_DLL hbool_t H5T_path_noop(const H5T_path_t *p); -H5_DLL H5T_bkg_t H5T_path_bkg(const H5T_path_t *p); +H5_DLL hbool_t H5T_path_noop(const H5T_path_t *p); +H5_DLL H5T_bkg_t H5T_path_bkg(const H5T_path_t *p); H5_DLL H5T_subset_info_t *H5T_path_compound_subset(const H5T_path_t *p); -H5_DLL herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, - size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); H5_DLL herr_t H5T_reclaim(hid_t type_id, struct H5S_t *space, void *buf); H5_DLL herr_t H5T_reclaim_cb(void *elem, const H5T_t *dt, unsigned ndim, const hsize_t *point, void *op_data); H5_DLL herr_t H5T_ref_reclaim(void *elem, const H5T_t *dt); @@ -140,26 +140,26 @@ H5_DLL herr_t H5T_vlen_reclaim(void *elem, const H5T_t *dt, H5T_vlen_alloc_info_ H5_DLL herr_t H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt); H5_DLL htri_t H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc); H5_DLL htri_t H5T_is_sensible(const H5T_t *dt); -H5_DLL uint32_t H5T_hash(H5F_t * file, const H5T_t *dt); -H5_DLL herr_t H5T_set_version(H5F_t *f, H5T_t *dt); -H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f); -H5_DLL herr_t H5T_patch_vlen_file(H5T_t *dt, H5VL_object_t *file); -H5_DLL herr_t H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj); -H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); +H5_DLL uint32_t H5T_hash(H5F_t *file, const H5T_t *dt); +H5_DLL herr_t H5T_set_version(H5F_t *f, H5T_t *dt); +H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f); +H5_DLL herr_t H5T_patch_vlen_file(H5T_t *dt, H5VL_object_t *file); +H5_DLL herr_t H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj); +H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); H5_DLL H5T_t *H5T_construct_datatype(H5VL_object_t *dt_obj); H5_DLL H5VL_object_t *H5T_get_named_type(const H5T_t *dt); -H5_DLL H5T_t *H5T_get_actual_type(H5T_t *dt); -H5_DLL herr_t H5T_save_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); -H5_DLL herr_t H5T_restore_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); +H5_DLL H5T_t * H5T_get_actual_type(H5T_t *dt); +H5_DLL herr_t H5T_save_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); +H5_DLL herr_t H5T_restore_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); H5_DLL hbool_t H5T_already_vol_managed(const H5T_t *dt); -H5_DLL htri_t H5T_is_vl_storage(const H5T_t *dt); +H5_DLL htri_t H5T_is_vl_storage(const H5T_t *dt); /* Reference specific functions */ H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt); /* Operations on named datatypes */ H5_DLL H5T_t *H5T_open(const H5G_loc_t *loc); -H5_DLL int H5T_link(const H5T_t *type, int adjust); +H5_DLL int H5T_link(const H5T_t *type, int adjust); H5_DLL herr_t H5T_update_shared(H5T_t *type); /* Field functions (for both compound & enumerated types) */ @@ -169,11 +169,10 @@ H5_DLL size_t H5T_get_member_offset(const H5T_t *dt, unsigned membno); /* Atomic functions */ H5_DLL H5T_order_t H5T_get_order(const H5T_t *dt); -H5_DLL size_t H5T_get_precision(const H5T_t *dt); -H5_DLL int H5T_get_offset(const H5T_t *dt); +H5_DLL size_t H5T_get_precision(const H5T_t *dt); +H5_DLL int H5T_get_offset(const H5T_t *dt); /* Fixed-point functions */ H5_DLL H5T_sign_t H5T_get_sign(H5T_t const *dt); #endif /* _H5Tprivate_H */ - diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 0ec0c73..73a00b6 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -21,53 +21,53 @@ #include "H5public.h" #include "H5Ipublic.h" -#define HOFFSET(S,M) (offsetof(S,M)) +#define HOFFSET(S, M) (offsetof(S, M)) /* These are the various classes of datatypes */ /* If this goes over 16 types (0-15), the file format will need to change) */ typedef enum H5T_class_t { - H5T_NO_CLASS = -1, /*error */ - H5T_INTEGER = 0, /*integer types */ - H5T_FLOAT = 1, /*floating-point types */ - H5T_TIME = 2, /*date and time types */ - H5T_STRING = 3, /*character string types */ - H5T_BITFIELD = 4, /*bit field types */ - H5T_OPAQUE = 5, /*opaque types */ - H5T_COMPOUND = 6, /*compound types */ - H5T_REFERENCE = 7, /*reference types */ - H5T_ENUM = 8, /*enumeration types */ - H5T_VLEN = 9, /*Variable-Length types */ - H5T_ARRAY = 10, /*Array types */ - - H5T_NCLASSES /*this must be last */ + H5T_NO_CLASS = -1, /*error */ + H5T_INTEGER = 0, /*integer types */ + H5T_FLOAT = 1, /*floating-point types */ + H5T_TIME = 2, /*date and time types */ + H5T_STRING = 3, /*character string types */ + H5T_BITFIELD = 4, /*bit field types */ + H5T_OPAQUE = 5, /*opaque types */ + H5T_COMPOUND = 6, /*compound types */ + H5T_REFERENCE = 7, /*reference types */ + H5T_ENUM = 8, /*enumeration types */ + H5T_VLEN = 9, /*Variable-Length types */ + H5T_ARRAY = 10, /*Array types */ + + H5T_NCLASSES /*this must be last */ } H5T_class_t; /* Byte orders */ typedef enum H5T_order_t { - H5T_ORDER_ERROR = -1, /*error */ - H5T_ORDER_LE = 0, /*little endian */ - H5T_ORDER_BE = 1, /*bit endian */ - H5T_ORDER_VAX = 2, /*VAX mixed endian */ - H5T_ORDER_MIXED = 3, /*Compound type with mixed member orders */ - H5T_ORDER_NONE = 4 /*no particular order (strings, bits,..) */ + H5T_ORDER_ERROR = -1, /*error */ + H5T_ORDER_LE = 0, /*little endian */ + H5T_ORDER_BE = 1, /*bit endian */ + H5T_ORDER_VAX = 2, /*VAX mixed endian */ + H5T_ORDER_MIXED = 3, /*Compound type with mixed member orders */ + H5T_ORDER_NONE = 4 /*no particular order (strings, bits,..) */ /*H5T_ORDER_NONE must be last */ } H5T_order_t; /* Types of integer sign schemes */ typedef enum H5T_sign_t { - H5T_SGN_ERROR = -1, /*error */ - H5T_SGN_NONE = 0, /*this is an unsigned type */ - H5T_SGN_2 = 1, /*two's complement */ + H5T_SGN_ERROR = -1, /*error */ + H5T_SGN_NONE = 0, /*this is an unsigned type */ + H5T_SGN_2 = 1, /*two's complement */ - H5T_NSGN = 2 /*this must be last! */ + H5T_NSGN = 2 /*this must be last! */ } H5T_sign_t; /* Floating-point normalization schemes */ typedef enum H5T_norm_t { - H5T_NORM_ERROR = -1, /*error */ - H5T_NORM_IMPLIED = 0, /*msb of mantissa isn't stored, always 1 */ - H5T_NORM_MSBSET = 1, /*msb of mantissa is always 1 */ - H5T_NORM_NONE = 2 /*not normalized */ + H5T_NORM_ERROR = -1, /*error */ + H5T_NORM_IMPLIED = 0, /*msb of mantissa isn't stored, always 1 */ + H5T_NORM_MSBSET = 1, /*msb of mantissa is always 1 */ + H5T_NORM_NONE = 2 /*not normalized */ /*H5T_NORM_NONE must be last */ } H5T_norm_t; @@ -76,159 +76,160 @@ typedef enum H5T_norm_t { * they appear in HDF5 files! */ typedef enum H5T_cset_t { - H5T_CSET_ERROR = -1, /*error */ - H5T_CSET_ASCII = 0, /*US ASCII */ - H5T_CSET_UTF8 = 1, /*UTF-8 Unicode encoding */ - H5T_CSET_RESERVED_2 = 2, /*reserved for later use */ - H5T_CSET_RESERVED_3 = 3, /*reserved for later use */ - H5T_CSET_RESERVED_4 = 4, /*reserved for later use */ - H5T_CSET_RESERVED_5 = 5, /*reserved for later use */ - H5T_CSET_RESERVED_6 = 6, /*reserved for later use */ - H5T_CSET_RESERVED_7 = 7, /*reserved for later use */ - H5T_CSET_RESERVED_8 = 8, /*reserved for later use */ - H5T_CSET_RESERVED_9 = 9, /*reserved for later use */ - H5T_CSET_RESERVED_10 = 10, /*reserved for later use */ - H5T_CSET_RESERVED_11 = 11, /*reserved for later use */ - H5T_CSET_RESERVED_12 = 12, /*reserved for later use */ - H5T_CSET_RESERVED_13 = 13, /*reserved for later use */ - H5T_CSET_RESERVED_14 = 14, /*reserved for later use */ - H5T_CSET_RESERVED_15 = 15 /*reserved for later use */ + H5T_CSET_ERROR = -1, /*error */ + H5T_CSET_ASCII = 0, /*US ASCII */ + H5T_CSET_UTF8 = 1, /*UTF-8 Unicode encoding */ + H5T_CSET_RESERVED_2 = 2, /*reserved for later use */ + H5T_CSET_RESERVED_3 = 3, /*reserved for later use */ + H5T_CSET_RESERVED_4 = 4, /*reserved for later use */ + H5T_CSET_RESERVED_5 = 5, /*reserved for later use */ + H5T_CSET_RESERVED_6 = 6, /*reserved for later use */ + H5T_CSET_RESERVED_7 = 7, /*reserved for later use */ + H5T_CSET_RESERVED_8 = 8, /*reserved for later use */ + H5T_CSET_RESERVED_9 = 9, /*reserved for later use */ + H5T_CSET_RESERVED_10 = 10, /*reserved for later use */ + H5T_CSET_RESERVED_11 = 11, /*reserved for later use */ + H5T_CSET_RESERVED_12 = 12, /*reserved for later use */ + H5T_CSET_RESERVED_13 = 13, /*reserved for later use */ + H5T_CSET_RESERVED_14 = 14, /*reserved for later use */ + H5T_CSET_RESERVED_15 = 15 /*reserved for later use */ } H5T_cset_t; -#define H5T_NCSET H5T_CSET_RESERVED_2 /*Number of character sets actually defined */ +#define H5T_NCSET H5T_CSET_RESERVED_2 /*Number of character sets actually defined */ /* * Type of padding to use in character strings. Do not change these values * since they appear in HDF5 files! */ typedef enum H5T_str_t { - H5T_STR_ERROR = -1, /*error */ - H5T_STR_NULLTERM = 0, /*null terminate like in C */ - H5T_STR_NULLPAD = 1, /*pad with nulls */ - H5T_STR_SPACEPAD = 2, /*pad with spaces like in Fortran */ - H5T_STR_RESERVED_3 = 3, /*reserved for later use */ - H5T_STR_RESERVED_4 = 4, /*reserved for later use */ - H5T_STR_RESERVED_5 = 5, /*reserved for later use */ - H5T_STR_RESERVED_6 = 6, /*reserved for later use */ - H5T_STR_RESERVED_7 = 7, /*reserved for later use */ - H5T_STR_RESERVED_8 = 8, /*reserved for later use */ - H5T_STR_RESERVED_9 = 9, /*reserved for later use */ - H5T_STR_RESERVED_10 = 10, /*reserved for later use */ - H5T_STR_RESERVED_11 = 11, /*reserved for later use */ - H5T_STR_RESERVED_12 = 12, /*reserved for later use */ - H5T_STR_RESERVED_13 = 13, /*reserved for later use */ - H5T_STR_RESERVED_14 = 14, /*reserved for later use */ - H5T_STR_RESERVED_15 = 15 /*reserved for later use */ + H5T_STR_ERROR = -1, /*error */ + H5T_STR_NULLTERM = 0, /*null terminate like in C */ + H5T_STR_NULLPAD = 1, /*pad with nulls */ + H5T_STR_SPACEPAD = 2, /*pad with spaces like in Fortran */ + H5T_STR_RESERVED_3 = 3, /*reserved for later use */ + H5T_STR_RESERVED_4 = 4, /*reserved for later use */ + H5T_STR_RESERVED_5 = 5, /*reserved for later use */ + H5T_STR_RESERVED_6 = 6, /*reserved for later use */ + H5T_STR_RESERVED_7 = 7, /*reserved for later use */ + H5T_STR_RESERVED_8 = 8, /*reserved for later use */ + H5T_STR_RESERVED_9 = 9, /*reserved for later use */ + H5T_STR_RESERVED_10 = 10, /*reserved for later use */ + H5T_STR_RESERVED_11 = 11, /*reserved for later use */ + H5T_STR_RESERVED_12 = 12, /*reserved for later use */ + H5T_STR_RESERVED_13 = 13, /*reserved for later use */ + H5T_STR_RESERVED_14 = 14, /*reserved for later use */ + H5T_STR_RESERVED_15 = 15 /*reserved for later use */ } H5T_str_t; -#define H5T_NSTR H5T_STR_RESERVED_3 /*num H5T_str_t types actually defined */ +#define H5T_NSTR H5T_STR_RESERVED_3 /*num H5T_str_t types actually defined */ /* Type of padding to use in other atomic types */ typedef enum H5T_pad_t { - H5T_PAD_ERROR = -1, /*error */ - H5T_PAD_ZERO = 0, /*always set to zero */ - H5T_PAD_ONE = 1, /*always set to one */ - H5T_PAD_BACKGROUND = 2, /*set to background value */ + H5T_PAD_ERROR = -1, /*error */ + H5T_PAD_ZERO = 0, /*always set to zero */ + H5T_PAD_ONE = 1, /*always set to one */ + H5T_PAD_BACKGROUND = 2, /*set to background value */ - H5T_NPAD = 3 /*THIS MUST BE LAST */ + H5T_NPAD = 3 /*THIS MUST BE LAST */ } H5T_pad_t; /* Commands sent to conversion functions */ typedef enum H5T_cmd_t { - H5T_CONV_INIT = 0, /*query and/or initialize private data */ - H5T_CONV_CONV = 1, /*convert data from source to dest datatype */ - H5T_CONV_FREE = 2 /*function is being removed from path */ + H5T_CONV_INIT = 0, /*query and/or initialize private data */ + H5T_CONV_CONV = 1, /*convert data from source to dest datatype */ + H5T_CONV_FREE = 2 /*function is being removed from path */ } H5T_cmd_t; /* How is the `bkg' buffer used by the conversion function? */ typedef enum H5T_bkg_t { - H5T_BKG_NO = 0, /*background buffer is not needed, send NULL */ - H5T_BKG_TEMP = 1, /*bkg buffer used as temp storage only */ - H5T_BKG_YES = 2 /*init bkg buf with data before conversion */ + H5T_BKG_NO = 0, /*background buffer is not needed, send NULL */ + H5T_BKG_TEMP = 1, /*bkg buffer used as temp storage only */ + H5T_BKG_YES = 2 /*init bkg buf with data before conversion */ } H5T_bkg_t; /* Type conversion client data */ typedef struct H5T_cdata_t { - H5T_cmd_t command;/*what should the conversion function do? */ - H5T_bkg_t need_bkg;/*is the background buffer needed? */ - hbool_t recalc; /*recalculate private data */ - void *priv; /*private data */ + H5T_cmd_t command; /*what should the conversion function do? */ + H5T_bkg_t need_bkg; /*is the background buffer needed? */ + hbool_t recalc; /*recalculate private data */ + void * priv; /*private data */ } H5T_cdata_t; /* Conversion function persistence */ typedef enum H5T_pers_t { - H5T_PERS_DONTCARE = -1, /*wild card */ - H5T_PERS_HARD = 0, /*hard conversion function */ - H5T_PERS_SOFT = 1 /*soft conversion function */ + H5T_PERS_DONTCARE = -1, /*wild card */ + H5T_PERS_HARD = 0, /*hard conversion function */ + H5T_PERS_SOFT = 1 /*soft conversion function */ } H5T_pers_t; /* The order to retrieve atomic native datatype */ typedef enum H5T_direction_t { - H5T_DIR_DEFAULT = 0, /*default direction is inscendent */ - H5T_DIR_ASCEND = 1, /*in inscendent order */ - H5T_DIR_DESCEND = 2 /*in descendent order */ + H5T_DIR_DEFAULT = 0, /*default direction is inscendent */ + H5T_DIR_ASCEND = 1, /*in inscendent order */ + H5T_DIR_DESCEND = 2 /*in descendent order */ } H5T_direction_t; /* The exception type passed into the conversion callback function */ typedef enum H5T_conv_except_t { - H5T_CONV_EXCEPT_RANGE_HI = 0, /*source value is greater than destination's range */ - H5T_CONV_EXCEPT_RANGE_LOW = 1, /*source value is less than destination's range */ - H5T_CONV_EXCEPT_PRECISION = 2, /*source value loses precision in destination */ - H5T_CONV_EXCEPT_TRUNCATE = 3, /*source value is truncated in destination */ - H5T_CONV_EXCEPT_PINF = 4, /*source value is positive infinity(floating number) */ - H5T_CONV_EXCEPT_NINF = 5, /*source value is negative infinity(floating number) */ - H5T_CONV_EXCEPT_NAN = 6 /*source value is NaN(floating number) */ + H5T_CONV_EXCEPT_RANGE_HI = 0, /*source value is greater than destination's range */ + H5T_CONV_EXCEPT_RANGE_LOW = 1, /*source value is less than destination's range */ + H5T_CONV_EXCEPT_PRECISION = 2, /*source value loses precision in destination */ + H5T_CONV_EXCEPT_TRUNCATE = 3, /*source value is truncated in destination */ + H5T_CONV_EXCEPT_PINF = 4, /*source value is positive infinity(floating number) */ + H5T_CONV_EXCEPT_NINF = 5, /*source value is negative infinity(floating number) */ + H5T_CONV_EXCEPT_NAN = 6 /*source value is NaN(floating number) */ } H5T_conv_except_t; /* The return value from conversion callback function H5T_conv_except_func_t */ typedef enum H5T_conv_ret_t { - H5T_CONV_ABORT = -1, /*abort conversion */ - H5T_CONV_UNHANDLED = 0, /*callback function failed to handle the exception */ - H5T_CONV_HANDLED = 1 /*callback function handled the exception successfully */ + H5T_CONV_ABORT = -1, /*abort conversion */ + H5T_CONV_UNHANDLED = 0, /*callback function failed to handle the exception */ + H5T_CONV_HANDLED = 1 /*callback function handled the exception successfully */ } H5T_conv_ret_t; /* Variable Length Datatype struct in memory */ /* (This is only used for VL sequences, not VL strings, which are stored in char *'s) */ typedef struct { size_t len; /* Length of VL data (in base type units) */ - void *p; /* Pointer to VL data */ + void * p; /* Pointer to VL data */ } hvl_t; /* Variable Length String information */ -#define H5T_VARIABLE ((size_t)(-1)) /* Indicate that a string is variable length (null-terminated in C, instead of fixed length) */ +#define H5T_VARIABLE \ + ((size_t)( \ + -1)) /* Indicate that a string is variable length (null-terminated in C, instead of fixed length) */ /* Opaque information */ -#define H5T_OPAQUE_TAG_MAX 256 /* Maximum length of an opaque tag */ - /* This could be raised without too much difficulty */ +#define H5T_OPAQUE_TAG_MAX 256 /* Maximum length of an opaque tag */ + /* This could be raised without too much difficulty */ #ifdef __cplusplus extern "C" { #endif /* All datatype conversion functions are... */ -typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, - void *bkg, hid_t dset_xfer_plist); +typedef herr_t (*H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); /* Exception handler. If an exception like overflow happenes during conversion, * this function is called if it's registered through H5Pset_type_conv_cb. */ -typedef H5T_conv_ret_t (*H5T_conv_except_func_t)(H5T_conv_except_t except_type, - hid_t src_id, hid_t dst_id, void *src_buf, void *dst_buf, void *user_data); +typedef H5T_conv_ret_t (*H5T_conv_except_func_t)(H5T_conv_except_t except_type, hid_t src_id, hid_t dst_id, + void *src_buf, void *dst_buf, void *user_data); /* When this header is included from a private header, don't make calls to H5open() */ #undef H5OPEN #ifndef _H5private_H -#define H5OPEN H5open(), -#else /* _H5private_H */ +#define H5OPEN H5open(), +#else /* _H5private_H */ #define H5OPEN -#endif /* _H5private_H */ +#endif /* _H5private_H */ /* * The IEEE floating point types in various byte orders. */ -#define H5T_IEEE_F32BE (H5OPEN H5T_IEEE_F32BE_g) -#define H5T_IEEE_F32LE (H5OPEN H5T_IEEE_F32LE_g) -#define H5T_IEEE_F64BE (H5OPEN H5T_IEEE_F64BE_g) -#define H5T_IEEE_F64LE (H5OPEN H5T_IEEE_F64LE_g) +#define H5T_IEEE_F32BE (H5OPEN H5T_IEEE_F32BE_g) +#define H5T_IEEE_F32LE (H5OPEN H5T_IEEE_F32LE_g) +#define H5T_IEEE_F64BE (H5OPEN H5T_IEEE_F64BE_g) +#define H5T_IEEE_F64LE (H5OPEN H5T_IEEE_F64LE_g) H5_DLLVAR hid_t H5T_IEEE_F32BE_g; H5_DLLVAR hid_t H5T_IEEE_F32LE_g; H5_DLLVAR hid_t H5T_IEEE_F64BE_g; @@ -238,33 +239,33 @@ H5_DLLVAR hid_t H5T_IEEE_F64LE_g; * These are "standard" types. For instance, signed (2's complement) and * unsigned integers of various sizes and byte orders. */ -#define H5T_STD_I8BE (H5OPEN H5T_STD_I8BE_g) -#define H5T_STD_I8LE (H5OPEN H5T_STD_I8LE_g) -#define H5T_STD_I16BE (H5OPEN H5T_STD_I16BE_g) -#define H5T_STD_I16LE (H5OPEN H5T_STD_I16LE_g) -#define H5T_STD_I32BE (H5OPEN H5T_STD_I32BE_g) -#define H5T_STD_I32LE (H5OPEN H5T_STD_I32LE_g) -#define H5T_STD_I64BE (H5OPEN H5T_STD_I64BE_g) -#define H5T_STD_I64LE (H5OPEN H5T_STD_I64LE_g) -#define H5T_STD_U8BE (H5OPEN H5T_STD_U8BE_g) -#define H5T_STD_U8LE (H5OPEN H5T_STD_U8LE_g) -#define H5T_STD_U16BE (H5OPEN H5T_STD_U16BE_g) -#define H5T_STD_U16LE (H5OPEN H5T_STD_U16LE_g) -#define H5T_STD_U32BE (H5OPEN H5T_STD_U32BE_g) -#define H5T_STD_U32LE (H5OPEN H5T_STD_U32LE_g) -#define H5T_STD_U64BE (H5OPEN H5T_STD_U64BE_g) -#define H5T_STD_U64LE (H5OPEN H5T_STD_U64LE_g) -#define H5T_STD_B8BE (H5OPEN H5T_STD_B8BE_g) -#define H5T_STD_B8LE (H5OPEN H5T_STD_B8LE_g) -#define H5T_STD_B16BE (H5OPEN H5T_STD_B16BE_g) -#define H5T_STD_B16LE (H5OPEN H5T_STD_B16LE_g) -#define H5T_STD_B32BE (H5OPEN H5T_STD_B32BE_g) -#define H5T_STD_B32LE (H5OPEN H5T_STD_B32LE_g) -#define H5T_STD_B64BE (H5OPEN H5T_STD_B64BE_g) -#define H5T_STD_B64LE (H5OPEN H5T_STD_B64LE_g) -#define H5T_STD_REF_OBJ (H5OPEN H5T_STD_REF_OBJ_g) -#define H5T_STD_REF_DSETREG (H5OPEN H5T_STD_REF_DSETREG_g) -#define H5T_STD_REF (H5OPEN H5T_STD_REF_g) +#define H5T_STD_I8BE (H5OPEN H5T_STD_I8BE_g) +#define H5T_STD_I8LE (H5OPEN H5T_STD_I8LE_g) +#define H5T_STD_I16BE (H5OPEN H5T_STD_I16BE_g) +#define H5T_STD_I16LE (H5OPEN H5T_STD_I16LE_g) +#define H5T_STD_I32BE (H5OPEN H5T_STD_I32BE_g) +#define H5T_STD_I32LE (H5OPEN H5T_STD_I32LE_g) +#define H5T_STD_I64BE (H5OPEN H5T_STD_I64BE_g) +#define H5T_STD_I64LE (H5OPEN H5T_STD_I64LE_g) +#define H5T_STD_U8BE (H5OPEN H5T_STD_U8BE_g) +#define H5T_STD_U8LE (H5OPEN H5T_STD_U8LE_g) +#define H5T_STD_U16BE (H5OPEN H5T_STD_U16BE_g) +#define H5T_STD_U16LE (H5OPEN H5T_STD_U16LE_g) +#define H5T_STD_U32BE (H5OPEN H5T_STD_U32BE_g) +#define H5T_STD_U32LE (H5OPEN H5T_STD_U32LE_g) +#define H5T_STD_U64BE (H5OPEN H5T_STD_U64BE_g) +#define H5T_STD_U64LE (H5OPEN H5T_STD_U64LE_g) +#define H5T_STD_B8BE (H5OPEN H5T_STD_B8BE_g) +#define H5T_STD_B8LE (H5OPEN H5T_STD_B8LE_g) +#define H5T_STD_B16BE (H5OPEN H5T_STD_B16BE_g) +#define H5T_STD_B16LE (H5OPEN H5T_STD_B16LE_g) +#define H5T_STD_B32BE (H5OPEN H5T_STD_B32BE_g) +#define H5T_STD_B32LE (H5OPEN H5T_STD_B32LE_g) +#define H5T_STD_B64BE (H5OPEN H5T_STD_B64BE_g) +#define H5T_STD_B64LE (H5OPEN H5T_STD_B64LE_g) +#define H5T_STD_REF_OBJ (H5OPEN H5T_STD_REF_OBJ_g) +#define H5T_STD_REF_DSETREG (H5OPEN H5T_STD_REF_DSETREG_g) +#define H5T_STD_REF (H5OPEN H5T_STD_REF_g) H5_DLLVAR hid_t H5T_STD_I8BE_g; H5_DLLVAR hid_t H5T_STD_I8LE_g; H5_DLLVAR hid_t H5T_STD_I16BE_g; @@ -296,10 +297,10 @@ H5_DLLVAR hid_t H5T_STD_REF_g; /* * Types which are particular to Unix. */ -#define H5T_UNIX_D32BE (H5OPEN H5T_UNIX_D32BE_g) -#define H5T_UNIX_D32LE (H5OPEN H5T_UNIX_D32LE_g) -#define H5T_UNIX_D64BE (H5OPEN H5T_UNIX_D64BE_g) -#define H5T_UNIX_D64LE (H5OPEN H5T_UNIX_D64LE_g) +#define H5T_UNIX_D32BE (H5OPEN H5T_UNIX_D32BE_g) +#define H5T_UNIX_D32LE (H5OPEN H5T_UNIX_D32LE_g) +#define H5T_UNIX_D64BE (H5OPEN H5T_UNIX_D64BE_g) +#define H5T_UNIX_D64LE (H5OPEN H5T_UNIX_D64LE_g) H5_DLLVAR hid_t H5T_UNIX_D32BE_g; H5_DLLVAR hid_t H5T_UNIX_D32LE_g; H5_DLLVAR hid_t H5T_UNIX_D64BE_g; @@ -309,77 +310,77 @@ H5_DLLVAR hid_t H5T_UNIX_D64LE_g; * Types particular to the C language. String types use `bytes' instead * of `bits' as their size. */ -#define H5T_C_S1 (H5OPEN H5T_C_S1_g) +#define H5T_C_S1 (H5OPEN H5T_C_S1_g) H5_DLLVAR hid_t H5T_C_S1_g; /* * Types particular to Fortran. */ -#define H5T_FORTRAN_S1 (H5OPEN H5T_FORTRAN_S1_g) +#define H5T_FORTRAN_S1 (H5OPEN H5T_FORTRAN_S1_g) H5_DLLVAR hid_t H5T_FORTRAN_S1_g; /* * These types are for Intel CPU's. They are little endian with IEEE * floating point. */ -#define H5T_INTEL_I8 H5T_STD_I8LE -#define H5T_INTEL_I16 H5T_STD_I16LE -#define H5T_INTEL_I32 H5T_STD_I32LE -#define H5T_INTEL_I64 H5T_STD_I64LE -#define H5T_INTEL_U8 H5T_STD_U8LE -#define H5T_INTEL_U16 H5T_STD_U16LE -#define H5T_INTEL_U32 H5T_STD_U32LE -#define H5T_INTEL_U64 H5T_STD_U64LE -#define H5T_INTEL_B8 H5T_STD_B8LE -#define H5T_INTEL_B16 H5T_STD_B16LE -#define H5T_INTEL_B32 H5T_STD_B32LE -#define H5T_INTEL_B64 H5T_STD_B64LE -#define H5T_INTEL_F32 H5T_IEEE_F32LE -#define H5T_INTEL_F64 H5T_IEEE_F64LE +#define H5T_INTEL_I8 H5T_STD_I8LE +#define H5T_INTEL_I16 H5T_STD_I16LE +#define H5T_INTEL_I32 H5T_STD_I32LE +#define H5T_INTEL_I64 H5T_STD_I64LE +#define H5T_INTEL_U8 H5T_STD_U8LE +#define H5T_INTEL_U16 H5T_STD_U16LE +#define H5T_INTEL_U32 H5T_STD_U32LE +#define H5T_INTEL_U64 H5T_STD_U64LE +#define H5T_INTEL_B8 H5T_STD_B8LE +#define H5T_INTEL_B16 H5T_STD_B16LE +#define H5T_INTEL_B32 H5T_STD_B32LE +#define H5T_INTEL_B64 H5T_STD_B64LE +#define H5T_INTEL_F32 H5T_IEEE_F32LE +#define H5T_INTEL_F64 H5T_IEEE_F64LE /* * These types are for DEC Alpha CPU's. They are little endian with IEEE * floating point. */ -#define H5T_ALPHA_I8 H5T_STD_I8LE -#define H5T_ALPHA_I16 H5T_STD_I16LE -#define H5T_ALPHA_I32 H5T_STD_I32LE -#define H5T_ALPHA_I64 H5T_STD_I64LE -#define H5T_ALPHA_U8 H5T_STD_U8LE -#define H5T_ALPHA_U16 H5T_STD_U16LE -#define H5T_ALPHA_U32 H5T_STD_U32LE -#define H5T_ALPHA_U64 H5T_STD_U64LE -#define H5T_ALPHA_B8 H5T_STD_B8LE -#define H5T_ALPHA_B16 H5T_STD_B16LE -#define H5T_ALPHA_B32 H5T_STD_B32LE -#define H5T_ALPHA_B64 H5T_STD_B64LE -#define H5T_ALPHA_F32 H5T_IEEE_F32LE -#define H5T_ALPHA_F64 H5T_IEEE_F64LE +#define H5T_ALPHA_I8 H5T_STD_I8LE +#define H5T_ALPHA_I16 H5T_STD_I16LE +#define H5T_ALPHA_I32 H5T_STD_I32LE +#define H5T_ALPHA_I64 H5T_STD_I64LE +#define H5T_ALPHA_U8 H5T_STD_U8LE +#define H5T_ALPHA_U16 H5T_STD_U16LE +#define H5T_ALPHA_U32 H5T_STD_U32LE +#define H5T_ALPHA_U64 H5T_STD_U64LE +#define H5T_ALPHA_B8 H5T_STD_B8LE +#define H5T_ALPHA_B16 H5T_STD_B16LE +#define H5T_ALPHA_B32 H5T_STD_B32LE +#define H5T_ALPHA_B64 H5T_STD_B64LE +#define H5T_ALPHA_F32 H5T_IEEE_F32LE +#define H5T_ALPHA_F64 H5T_IEEE_F64LE /* * These types are for MIPS cpu's commonly used in SGI systems. They are big * endian with IEEE floating point. */ -#define H5T_MIPS_I8 H5T_STD_I8BE -#define H5T_MIPS_I16 H5T_STD_I16BE -#define H5T_MIPS_I32 H5T_STD_I32BE -#define H5T_MIPS_I64 H5T_STD_I64BE -#define H5T_MIPS_U8 H5T_STD_U8BE -#define H5T_MIPS_U16 H5T_STD_U16BE -#define H5T_MIPS_U32 H5T_STD_U32BE -#define H5T_MIPS_U64 H5T_STD_U64BE -#define H5T_MIPS_B8 H5T_STD_B8BE -#define H5T_MIPS_B16 H5T_STD_B16BE -#define H5T_MIPS_B32 H5T_STD_B32BE -#define H5T_MIPS_B64 H5T_STD_B64BE -#define H5T_MIPS_F32 H5T_IEEE_F32BE -#define H5T_MIPS_F64 H5T_IEEE_F64BE +#define H5T_MIPS_I8 H5T_STD_I8BE +#define H5T_MIPS_I16 H5T_STD_I16BE +#define H5T_MIPS_I32 H5T_STD_I32BE +#define H5T_MIPS_I64 H5T_STD_I64BE +#define H5T_MIPS_U8 H5T_STD_U8BE +#define H5T_MIPS_U16 H5T_STD_U16BE +#define H5T_MIPS_U32 H5T_STD_U32BE +#define H5T_MIPS_U64 H5T_STD_U64BE +#define H5T_MIPS_B8 H5T_STD_B8BE +#define H5T_MIPS_B16 H5T_STD_B16BE +#define H5T_MIPS_B32 H5T_STD_B32BE +#define H5T_MIPS_B64 H5T_STD_B64BE +#define H5T_MIPS_F32 H5T_IEEE_F32BE +#define H5T_MIPS_F64 H5T_IEEE_F64BE /* * The VAX floating point types (i.e. in VAX byte order) */ -#define H5T_VAX_F32 (H5OPEN H5T_VAX_F32_g) -#define H5T_VAX_F64 (H5OPEN H5T_VAX_F64_g) +#define H5T_VAX_F32 (H5OPEN H5T_VAX_F32_g) +#define H5T_VAX_F64 (H5OPEN H5T_VAX_F64_g) H5_DLLVAR hid_t H5T_VAX_F32_g; H5_DLLVAR hid_t H5T_VAX_F64_g; @@ -392,32 +393,32 @@ H5_DLLVAR hid_t H5T_VAX_F64_g; * to C's `long long' and LDOUBLE is `long double' (these types might be the * same as `LONG' and `DOUBLE' respectively). */ -#define H5T_NATIVE_CHAR (CHAR_MIN?H5T_NATIVE_SCHAR:H5T_NATIVE_UCHAR) -#define H5T_NATIVE_SCHAR (H5OPEN H5T_NATIVE_SCHAR_g) -#define H5T_NATIVE_UCHAR (H5OPEN H5T_NATIVE_UCHAR_g) -#define H5T_NATIVE_SHORT (H5OPEN H5T_NATIVE_SHORT_g) -#define H5T_NATIVE_USHORT (H5OPEN H5T_NATIVE_USHORT_g) -#define H5T_NATIVE_INT (H5OPEN H5T_NATIVE_INT_g) -#define H5T_NATIVE_UINT (H5OPEN H5T_NATIVE_UINT_g) -#define H5T_NATIVE_LONG (H5OPEN H5T_NATIVE_LONG_g) -#define H5T_NATIVE_ULONG (H5OPEN H5T_NATIVE_ULONG_g) -#define H5T_NATIVE_LLONG (H5OPEN H5T_NATIVE_LLONG_g) -#define H5T_NATIVE_ULLONG (H5OPEN H5T_NATIVE_ULLONG_g) -#define H5T_NATIVE_FLOAT (H5OPEN H5T_NATIVE_FLOAT_g) -#define H5T_NATIVE_DOUBLE (H5OPEN H5T_NATIVE_DOUBLE_g) -#if H5_SIZEOF_LONG_DOUBLE !=0 -#define H5T_NATIVE_LDOUBLE (H5OPEN H5T_NATIVE_LDOUBLE_g) +#define H5T_NATIVE_CHAR (CHAR_MIN ? H5T_NATIVE_SCHAR : H5T_NATIVE_UCHAR) +#define H5T_NATIVE_SCHAR (H5OPEN H5T_NATIVE_SCHAR_g) +#define H5T_NATIVE_UCHAR (H5OPEN H5T_NATIVE_UCHAR_g) +#define H5T_NATIVE_SHORT (H5OPEN H5T_NATIVE_SHORT_g) +#define H5T_NATIVE_USHORT (H5OPEN H5T_NATIVE_USHORT_g) +#define H5T_NATIVE_INT (H5OPEN H5T_NATIVE_INT_g) +#define H5T_NATIVE_UINT (H5OPEN H5T_NATIVE_UINT_g) +#define H5T_NATIVE_LONG (H5OPEN H5T_NATIVE_LONG_g) +#define H5T_NATIVE_ULONG (H5OPEN H5T_NATIVE_ULONG_g) +#define H5T_NATIVE_LLONG (H5OPEN H5T_NATIVE_LLONG_g) +#define H5T_NATIVE_ULLONG (H5OPEN H5T_NATIVE_ULLONG_g) +#define H5T_NATIVE_FLOAT (H5OPEN H5T_NATIVE_FLOAT_g) +#define H5T_NATIVE_DOUBLE (H5OPEN H5T_NATIVE_DOUBLE_g) +#if H5_SIZEOF_LONG_DOUBLE != 0 +#define H5T_NATIVE_LDOUBLE (H5OPEN H5T_NATIVE_LDOUBLE_g) #endif -#define H5T_NATIVE_B8 (H5OPEN H5T_NATIVE_B8_g) -#define H5T_NATIVE_B16 (H5OPEN H5T_NATIVE_B16_g) -#define H5T_NATIVE_B32 (H5OPEN H5T_NATIVE_B32_g) -#define H5T_NATIVE_B64 (H5OPEN H5T_NATIVE_B64_g) -#define H5T_NATIVE_OPAQUE (H5OPEN H5T_NATIVE_OPAQUE_g) -#define H5T_NATIVE_HADDR (H5OPEN H5T_NATIVE_HADDR_g) -#define H5T_NATIVE_HSIZE (H5OPEN H5T_NATIVE_HSIZE_g) -#define H5T_NATIVE_HSSIZE (H5OPEN H5T_NATIVE_HSSIZE_g) -#define H5T_NATIVE_HERR (H5OPEN H5T_NATIVE_HERR_g) -#define H5T_NATIVE_HBOOL (H5OPEN H5T_NATIVE_HBOOL_g) +#define H5T_NATIVE_B8 (H5OPEN H5T_NATIVE_B8_g) +#define H5T_NATIVE_B16 (H5OPEN H5T_NATIVE_B16_g) +#define H5T_NATIVE_B32 (H5OPEN H5T_NATIVE_B32_g) +#define H5T_NATIVE_B64 (H5OPEN H5T_NATIVE_B64_g) +#define H5T_NATIVE_OPAQUE (H5OPEN H5T_NATIVE_OPAQUE_g) +#define H5T_NATIVE_HADDR (H5OPEN H5T_NATIVE_HADDR_g) +#define H5T_NATIVE_HSIZE (H5OPEN H5T_NATIVE_HSIZE_g) +#define H5T_NATIVE_HSSIZE (H5OPEN H5T_NATIVE_HSSIZE_g) +#define H5T_NATIVE_HERR (H5OPEN H5T_NATIVE_HERR_g) +#define H5T_NATIVE_HBOOL (H5OPEN H5T_NATIVE_HBOOL_g) H5_DLLVAR hid_t H5T_NATIVE_SCHAR_g; H5_DLLVAR hid_t H5T_NATIVE_UCHAR_g; H5_DLLVAR hid_t H5T_NATIVE_SHORT_g; @@ -430,7 +431,7 @@ H5_DLLVAR hid_t H5T_NATIVE_LLONG_g; H5_DLLVAR hid_t H5T_NATIVE_ULLONG_g; H5_DLLVAR hid_t H5T_NATIVE_FLOAT_g; H5_DLLVAR hid_t H5T_NATIVE_DOUBLE_g; -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 H5_DLLVAR hid_t H5T_NATIVE_LDOUBLE_g; #endif H5_DLLVAR hid_t H5T_NATIVE_B8_g; @@ -445,12 +446,12 @@ H5_DLLVAR hid_t H5T_NATIVE_HERR_g; H5_DLLVAR hid_t H5T_NATIVE_HBOOL_g; /* C9x integer types */ -#define H5T_NATIVE_INT8 (H5OPEN H5T_NATIVE_INT8_g) -#define H5T_NATIVE_UINT8 (H5OPEN H5T_NATIVE_UINT8_g) -#define H5T_NATIVE_INT_LEAST8 (H5OPEN H5T_NATIVE_INT_LEAST8_g) -#define H5T_NATIVE_UINT_LEAST8 (H5OPEN H5T_NATIVE_UINT_LEAST8_g) -#define H5T_NATIVE_INT_FAST8 (H5OPEN H5T_NATIVE_INT_FAST8_g) -#define H5T_NATIVE_UINT_FAST8 (H5OPEN H5T_NATIVE_UINT_FAST8_g) +#define H5T_NATIVE_INT8 (H5OPEN H5T_NATIVE_INT8_g) +#define H5T_NATIVE_UINT8 (H5OPEN H5T_NATIVE_UINT8_g) +#define H5T_NATIVE_INT_LEAST8 (H5OPEN H5T_NATIVE_INT_LEAST8_g) +#define H5T_NATIVE_UINT_LEAST8 (H5OPEN H5T_NATIVE_UINT_LEAST8_g) +#define H5T_NATIVE_INT_FAST8 (H5OPEN H5T_NATIVE_INT_FAST8_g) +#define H5T_NATIVE_UINT_FAST8 (H5OPEN H5T_NATIVE_UINT_FAST8_g) H5_DLLVAR hid_t H5T_NATIVE_INT8_g; H5_DLLVAR hid_t H5T_NATIVE_UINT8_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST8_g; @@ -458,12 +459,12 @@ H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST8_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST8_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST8_g; -#define H5T_NATIVE_INT16 (H5OPEN H5T_NATIVE_INT16_g) -#define H5T_NATIVE_UINT16 (H5OPEN H5T_NATIVE_UINT16_g) -#define H5T_NATIVE_INT_LEAST16 (H5OPEN H5T_NATIVE_INT_LEAST16_g) -#define H5T_NATIVE_UINT_LEAST16 (H5OPEN H5T_NATIVE_UINT_LEAST16_g) -#define H5T_NATIVE_INT_FAST16 (H5OPEN H5T_NATIVE_INT_FAST16_g) -#define H5T_NATIVE_UINT_FAST16 (H5OPEN H5T_NATIVE_UINT_FAST16_g) +#define H5T_NATIVE_INT16 (H5OPEN H5T_NATIVE_INT16_g) +#define H5T_NATIVE_UINT16 (H5OPEN H5T_NATIVE_UINT16_g) +#define H5T_NATIVE_INT_LEAST16 (H5OPEN H5T_NATIVE_INT_LEAST16_g) +#define H5T_NATIVE_UINT_LEAST16 (H5OPEN H5T_NATIVE_UINT_LEAST16_g) +#define H5T_NATIVE_INT_FAST16 (H5OPEN H5T_NATIVE_INT_FAST16_g) +#define H5T_NATIVE_UINT_FAST16 (H5OPEN H5T_NATIVE_UINT_FAST16_g) H5_DLLVAR hid_t H5T_NATIVE_INT16_g; H5_DLLVAR hid_t H5T_NATIVE_UINT16_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST16_g; @@ -471,12 +472,12 @@ H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST16_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST16_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST16_g; -#define H5T_NATIVE_INT32 (H5OPEN H5T_NATIVE_INT32_g) -#define H5T_NATIVE_UINT32 (H5OPEN H5T_NATIVE_UINT32_g) -#define H5T_NATIVE_INT_LEAST32 (H5OPEN H5T_NATIVE_INT_LEAST32_g) -#define H5T_NATIVE_UINT_LEAST32 (H5OPEN H5T_NATIVE_UINT_LEAST32_g) -#define H5T_NATIVE_INT_FAST32 (H5OPEN H5T_NATIVE_INT_FAST32_g) -#define H5T_NATIVE_UINT_FAST32 (H5OPEN H5T_NATIVE_UINT_FAST32_g) +#define H5T_NATIVE_INT32 (H5OPEN H5T_NATIVE_INT32_g) +#define H5T_NATIVE_UINT32 (H5OPEN H5T_NATIVE_UINT32_g) +#define H5T_NATIVE_INT_LEAST32 (H5OPEN H5T_NATIVE_INT_LEAST32_g) +#define H5T_NATIVE_UINT_LEAST32 (H5OPEN H5T_NATIVE_UINT_LEAST32_g) +#define H5T_NATIVE_INT_FAST32 (H5OPEN H5T_NATIVE_INT_FAST32_g) +#define H5T_NATIVE_UINT_FAST32 (H5OPEN H5T_NATIVE_UINT_FAST32_g) H5_DLLVAR hid_t H5T_NATIVE_INT32_g; H5_DLLVAR hid_t H5T_NATIVE_UINT32_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST32_g; @@ -484,12 +485,12 @@ H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST32_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST32_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST32_g; -#define H5T_NATIVE_INT64 (H5OPEN H5T_NATIVE_INT64_g) -#define H5T_NATIVE_UINT64 (H5OPEN H5T_NATIVE_UINT64_g) -#define H5T_NATIVE_INT_LEAST64 (H5OPEN H5T_NATIVE_INT_LEAST64_g) -#define H5T_NATIVE_UINT_LEAST64 (H5OPEN H5T_NATIVE_UINT_LEAST64_g) -#define H5T_NATIVE_INT_FAST64 (H5OPEN H5T_NATIVE_INT_FAST64_g) -#define H5T_NATIVE_UINT_FAST64 (H5OPEN H5T_NATIVE_UINT_FAST64_g) +#define H5T_NATIVE_INT64 (H5OPEN H5T_NATIVE_INT64_g) +#define H5T_NATIVE_UINT64 (H5OPEN H5T_NATIVE_UINT64_g) +#define H5T_NATIVE_INT_LEAST64 (H5OPEN H5T_NATIVE_INT_LEAST64_g) +#define H5T_NATIVE_UINT_LEAST64 (H5OPEN H5T_NATIVE_UINT_LEAST64_g) +#define H5T_NATIVE_INT_FAST64 (H5OPEN H5T_NATIVE_INT_FAST64_g) +#define H5T_NATIVE_UINT_FAST64 (H5OPEN H5T_NATIVE_UINT_FAST64_g) H5_DLLVAR hid_t H5T_NATIVE_INT64_g; H5_DLLVAR hid_t H5T_NATIVE_UINT64_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST64_g; @@ -498,76 +499,70 @@ H5_DLLVAR hid_t H5T_NATIVE_INT_FAST64_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST64_g; /* Operations defined on all datatypes */ -H5_DLL hid_t H5Tcreate(H5T_class_t type, size_t size); -H5_DLL hid_t H5Tcopy(hid_t type_id); +H5_DLL hid_t H5Tcreate(H5T_class_t type, size_t size); +H5_DLL hid_t H5Tcopy(hid_t type_id); H5_DLL herr_t H5Tclose(hid_t type_id); H5_DLL htri_t H5Tequal(hid_t type1_id, hid_t type2_id); H5_DLL herr_t H5Tlock(hid_t type_id); -H5_DLL herr_t H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, - hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); -H5_DLL hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id); +H5_DLL herr_t H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, + hid_t tapl_id); +H5_DLL hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id); H5_DLL herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id); -H5_DLL hid_t H5Tget_create_plist(hid_t type_id); +H5_DLL hid_t H5Tget_create_plist(hid_t type_id); H5_DLL htri_t H5Tcommitted(hid_t type_id); H5_DLL herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc); -H5_DLL hid_t H5Tdecode(const void *buf); +H5_DLL hid_t H5Tdecode(const void *buf); H5_DLL herr_t H5Tflush(hid_t type_id); H5_DLL herr_t H5Trefresh(hid_t type_id); /* Operations defined on compound datatypes */ -H5_DLL herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, - hid_t member_id); +H5_DLL herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id); H5_DLL herr_t H5Tpack(hid_t type_id); /* Operations defined on enumeration datatypes */ -H5_DLL hid_t H5Tenum_create(hid_t base_id); +H5_DLL hid_t H5Tenum_create(hid_t base_id); H5_DLL herr_t H5Tenum_insert(hid_t type, const char *name, const void *value); -H5_DLL herr_t H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, - size_t size); -H5_DLL herr_t H5Tenum_valueof(hid_t type, const char *name, - void *value/*out*/); +H5_DLL herr_t H5Tenum_nameof(hid_t type, const void *value, char *name /*out*/, size_t size); +H5_DLL herr_t H5Tenum_valueof(hid_t type, const char *name, void *value /*out*/); /* Operations defined on variable-length datatypes */ H5_DLL hid_t H5Tvlen_create(hid_t base_id); /* Operations defined on array datatypes */ -H5_DLL hid_t H5Tarray_create2(hid_t base_id, unsigned ndims, - const hsize_t dim[/* ndims */]); -H5_DLL int H5Tget_array_ndims(hid_t type_id); -H5_DLL int H5Tget_array_dims2(hid_t type_id, hsize_t dims[]); +H5_DLL hid_t H5Tarray_create2(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */]); +H5_DLL int H5Tget_array_ndims(hid_t type_id); +H5_DLL int H5Tget_array_dims2(hid_t type_id, hsize_t dims[]); /* Operations defined on opaque datatypes */ H5_DLL herr_t H5Tset_tag(hid_t type, const char *tag); -H5_DLL char *H5Tget_tag(hid_t type); +H5_DLL char * H5Tget_tag(hid_t type); /* Querying property values */ -H5_DLL hid_t H5Tget_super(hid_t type); +H5_DLL hid_t H5Tget_super(hid_t type); H5_DLL H5T_class_t H5Tget_class(hid_t type_id); -H5_DLL htri_t H5Tdetect_class(hid_t type_id, H5T_class_t cls); -H5_DLL size_t H5Tget_size(hid_t type_id); +H5_DLL htri_t H5Tdetect_class(hid_t type_id, H5T_class_t cls); +H5_DLL size_t H5Tget_size(hid_t type_id); H5_DLL H5T_order_t H5Tget_order(hid_t type_id); -H5_DLL size_t H5Tget_precision(hid_t type_id); -H5_DLL int H5Tget_offset(hid_t type_id); -H5_DLL herr_t H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, - H5T_pad_t *msb/*out*/); -H5_DLL H5T_sign_t H5Tget_sign(hid_t type_id); -H5_DLL herr_t H5Tget_fields(hid_t type_id, size_t *spos/*out*/, - size_t *epos/*out*/, size_t *esize/*out*/, - size_t *mpos/*out*/, size_t *msize/*out*/); +H5_DLL size_t H5Tget_precision(hid_t type_id); +H5_DLL int H5Tget_offset(hid_t type_id); +H5_DLL herr_t H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out*/, H5T_pad_t *msb /*out*/); +H5_DLL H5T_sign_t H5Tget_sign(hid_t type_id); +H5_DLL herr_t H5Tget_fields(hid_t type_id, size_t *spos /*out*/, size_t *epos /*out*/, size_t *esize /*out*/, + size_t *mpos /*out*/, size_t *msize /*out*/); H5_DLL size_t H5Tget_ebias(hid_t type_id); -H5_DLL H5T_norm_t H5Tget_norm(hid_t type_id); -H5_DLL H5T_pad_t H5Tget_inpad(hid_t type_id); -H5_DLL H5T_str_t H5Tget_strpad(hid_t type_id); -H5_DLL int H5Tget_nmembers(hid_t type_id); -H5_DLL char *H5Tget_member_name(hid_t type_id, unsigned membno); -H5_DLL int H5Tget_member_index(hid_t type_id, const char *name); -H5_DLL size_t H5Tget_member_offset(hid_t type_id, unsigned membno); +H5_DLL H5T_norm_t H5Tget_norm(hid_t type_id); +H5_DLL H5T_pad_t H5Tget_inpad(hid_t type_id); +H5_DLL H5T_str_t H5Tget_strpad(hid_t type_id); +H5_DLL int H5Tget_nmembers(hid_t type_id); +H5_DLL char * H5Tget_member_name(hid_t type_id, unsigned membno); +H5_DLL int H5Tget_member_index(hid_t type_id, const char *name); +H5_DLL size_t H5Tget_member_offset(hid_t type_id, unsigned membno); H5_DLL H5T_class_t H5Tget_member_class(hid_t type_id, unsigned membno); -H5_DLL hid_t H5Tget_member_type(hid_t type_id, unsigned membno); -H5_DLL herr_t H5Tget_member_value(hid_t type_id, unsigned membno, void *value/*out*/); -H5_DLL H5T_cset_t H5Tget_cset(hid_t type_id); -H5_DLL htri_t H5Tis_variable_str(hid_t type_id); -H5_DLL hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction); +H5_DLL hid_t H5Tget_member_type(hid_t type_id, unsigned membno); +H5_DLL herr_t H5Tget_member_value(hid_t type_id, unsigned membno, void *value /*out*/); +H5_DLL H5T_cset_t H5Tget_cset(hid_t type_id); +H5_DLL htri_t H5Tis_variable_str(hid_t type_id); +H5_DLL hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction); /* Setting property values */ H5_DLL herr_t H5Tset_size(hid_t type_id, size_t size); @@ -576,8 +571,7 @@ H5_DLL herr_t H5Tset_precision(hid_t type_id, size_t prec); H5_DLL herr_t H5Tset_offset(hid_t type_id, size_t offset); H5_DLL herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb); H5_DLL herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign); -H5_DLL herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos, - size_t esize, size_t mpos, size_t msize); +H5_DLL herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize); H5_DLL herr_t H5Tset_ebias(hid_t type_id, size_t ebias); H5_DLL herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm); H5_DLL herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad); @@ -585,15 +579,13 @@ H5_DLL herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset); H5_DLL herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad); /* Type conversion database */ -H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, - hid_t dst_id, H5T_conv_t func); -H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, - hid_t dst_id, H5T_conv_t func); +H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); +H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); H5_DLL H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata); -H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id); -H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, - void *buf, void *background, hid_t plist_id); -H5_DLL herr_t H5Treclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf); +H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id); +H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, + hid_t plist_id); +H5_DLL herr_t H5Treclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -603,17 +595,14 @@ H5_DLL herr_t H5Treclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *bu /* Macros */ - /* Typedefs */ - /* Function prototypes */ H5_DLL herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id); -H5_DLL hid_t H5Topen1(hid_t loc_id, const char *name); -H5_DLL hid_t H5Tarray_create1(hid_t base_id, int ndims, - const hsize_t dim[/* ndims */], - const int perm[/* ndims */]); -H5_DLL int H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int perm[]); +H5_DLL hid_t H5Topen1(hid_t loc_id, const char *name); +H5_DLL hid_t H5Tarray_create1(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], + const int perm[/* ndims */]); +H5_DLL int H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int perm[]); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -621,4 +610,3 @@ H5_DLL int H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int perm[]); } #endif #endif /* _H5Tpublic_H */ - diff --git a/src/H5Tref.c b/src/H5Tref.c index 7c59e75..64de117 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -15,17 +15,17 @@ * datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#define H5R_FRIEND /*suppress error about including H5Rpkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Fpkg.h" /* File */ -#include "H5Rpkg.h" /* References */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5R_FRIEND /*suppress error about including H5Rpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Fpkg.h" /* File */ +#include "H5Rpkg.h" /* References */ +#include "H5Tpkg.h" /* Datatypes */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -33,12 +33,12 @@ /* Local Macros */ /****************/ -#define H5T_REF_MEM_SIZE (H5R_REF_BUF_SIZE) -#define H5T_REF_OBJ_MEM_SIZE (H5R_OBJ_REF_BUF_SIZE) -#define H5T_REF_DSETREG_MEM_SIZE (H5R_DSET_REG_REF_BUF_SIZE) +#define H5T_REF_MEM_SIZE (H5R_REF_BUF_SIZE) +#define H5T_REF_OBJ_MEM_SIZE (H5R_OBJ_REF_BUF_SIZE) +#define H5T_REF_DSETREG_MEM_SIZE (H5R_DSET_REG_REF_BUF_SIZE) -#define H5T_REF_OBJ_DISK_SIZE(f) (H5F_SIZEOF_ADDR(f)) -#define H5T_REF_DSETREG_DISK_SIZE(f) (H5HG_HEAP_ID_SIZE(f)) +#define H5T_REF_OBJ_DISK_SIZE(f) (H5F_SIZEOF_ADDR(f)) +#define H5T_REF_DSETREG_DISK_SIZE(f) (H5HG_HEAP_ID_SIZE(f)) /******************/ /* Local Typedefs */ @@ -46,8 +46,8 @@ /* For region compatibility support */ struct H5Tref_dsetreg { - H5O_token_t token; /* Object token */ - H5S_t *space; /* Dataspace */ + H5O_token_t token; /* Object token */ + H5S_t * space; /* Dataspace */ }; /********************/ @@ -56,24 +56,37 @@ struct H5Tref_dsetreg { static herr_t H5T__ref_mem_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); static herr_t H5T__ref_mem_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf); -static size_t H5T__ref_mem_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, hbool_t *dst_copy); -static herr_t H5T__ref_mem_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); -static herr_t H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size, void *bg_buf); +static size_t H5T__ref_mem_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +static herr_t H5T__ref_mem_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +static herr_t H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size, + void *bg_buf); static herr_t H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); static herr_t H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf); -static size_t H5T__ref_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, hbool_t *dst_copy); -static herr_t H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); -static herr_t H5T__ref_disk_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size, void *bg_buf); +static size_t H5T__ref_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +static herr_t H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +static herr_t H5T__ref_disk_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, + size_t dst_size, void *bg_buf); /* For compatibility */ static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); -static size_t H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, hbool_t *dst_copy); -static herr_t H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); - -static herr_t H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); -static size_t H5T__ref_dsetreg_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, hbool_t *dst_copy); -static herr_t H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +static size_t H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +static herr_t H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); + +static herr_t H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, + hbool_t *isnull); +static size_t H5T__ref_dsetreg_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +static herr_t H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); /*******************/ /* Local Variables */ @@ -81,38 +94,37 @@ static herr_t H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *sr /* Class for reference in memory */ static const H5T_ref_class_t H5T_ref_mem_g = { - H5T__ref_mem_isnull, /* 'isnull' */ - H5T__ref_mem_setnull, /* 'setnull' */ - H5T__ref_mem_getsize, /* 'getsize' */ - H5T__ref_mem_read, /* 'read' */ - H5T__ref_mem_write /* 'write' */ + H5T__ref_mem_isnull, /* 'isnull' */ + H5T__ref_mem_setnull, /* 'setnull' */ + H5T__ref_mem_getsize, /* 'getsize' */ + H5T__ref_mem_read, /* 'read' */ + H5T__ref_mem_write /* 'write' */ }; static const H5T_ref_class_t H5T_ref_disk_g = { - H5T__ref_disk_isnull, /* 'isnull' */ - H5T__ref_disk_setnull, /* 'setnull' */ - H5T__ref_disk_getsize, /* 'getsize' */ - H5T__ref_disk_read, /* 'read' */ - H5T__ref_disk_write /* 'write' */ + H5T__ref_disk_isnull, /* 'isnull' */ + H5T__ref_disk_setnull, /* 'setnull' */ + H5T__ref_disk_getsize, /* 'getsize' */ + H5T__ref_disk_read, /* 'read' */ + H5T__ref_disk_write /* 'write' */ }; static const H5T_ref_class_t H5T_ref_obj_disk_g = { - H5T__ref_obj_disk_isnull, /* 'isnull' */ - NULL, /* 'setnull' */ - H5T__ref_obj_disk_getsize, /* 'getsize' */ - H5T__ref_obj_disk_read, /* 'read' */ - NULL /* 'write' */ + H5T__ref_obj_disk_isnull, /* 'isnull' */ + NULL, /* 'setnull' */ + H5T__ref_obj_disk_getsize, /* 'getsize' */ + H5T__ref_obj_disk_read, /* 'read' */ + NULL /* 'write' */ }; static const H5T_ref_class_t H5T_ref_dsetreg_disk_g = { - H5T__ref_dsetreg_disk_isnull, /* 'isnull' */ - NULL, /* 'setnull' */ - H5T__ref_dsetreg_disk_getsize, /* 'getsize' */ - H5T__ref_dsetreg_disk_read, /* 'read' */ - NULL /* 'write' */ + H5T__ref_dsetreg_disk_isnull, /* 'isnull' */ + NULL, /* 'setnull' */ + H5T__ref_dsetreg_disk_getsize, /* 'getsize' */ + H5T__ref_dsetreg_disk_read, /* 'read' */ + NULL /* 'write' */ }; - /*------------------------------------------------------------------------- * Function: H5T__ref_set_loc * @@ -139,10 +151,10 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); /* Only change the location if it's different */ - if(loc == dt->shared->u.atomic.u.r.loc && file == dt->shared->u.atomic.u.r.file) + if (loc == dt->shared->u.atomic.u.r.loc && file == dt->shared->u.atomic.u.r.file) HGOTO_DONE(FALSE) - switch(loc) { + switch (loc) { case H5T_LOC_MEMORY: /* Memory based reference datatype */ /* NB. We allow for the file to be non-NULL when doing @@ -152,27 +164,27 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY; /* Reset file ID (since this reference is in memory) */ - dt->shared->u.atomic.u.r.file = file; /* file is NULL */ + dt->shared->u.atomic.u.r.file = file; /* file is NULL */ - if(dt->shared->u.atomic.u.r.opaque) { + if (dt->shared->u.atomic.u.r.opaque) { /* Size in memory, disk size is different */ - dt->shared->size = H5T_REF_MEM_SIZE; + dt->shared->size = H5T_REF_MEM_SIZE; dt->shared->u.atomic.prec = 8 * dt->shared->size; /* Set up the function pointers to access the reference in memory */ dt->shared->u.atomic.u.r.cls = &H5T_ref_mem_g; } /* end if */ - else if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) { + else if (dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) { /* Size in memory, disk size is different */ - dt->shared->size = H5T_REF_OBJ_MEM_SIZE; + dt->shared->size = H5T_REF_OBJ_MEM_SIZE; dt->shared->u.atomic.prec = 8 * dt->shared->size; /* Unused for now */ dt->shared->u.atomic.u.r.cls = NULL; } /* end else-if */ - else if(dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION1) { + else if (dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION1) { /* Size in memory, disk size is different */ - dt->shared->size = H5T_REF_DSETREG_MEM_SIZE; + dt->shared->size = H5T_REF_DSETREG_MEM_SIZE; dt->shared->u.atomic.prec = 8 * dt->shared->size; /* Unused for now */ @@ -191,43 +203,45 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Set file pointer (since this reference is on disk) */ dt->shared->u.atomic.u.r.file = file; - if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) { + if (dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) { H5F_t *f; #ifndef NDEBUG - { - hbool_t is_native = FALSE; /* Whether the file is using the native VOL connector */ + { + hbool_t is_native = FALSE; /* Whether the file is using the native VOL connector */ - /* Check if using native VOL connector */ - if(H5VL_object_is_native(file, &is_native) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + /* Check if using native VOL connector */ + if (H5VL_object_is_native(file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, + "can't query if file uses native VOL connector") - /* Must use native VOL connector for this operation */ - HDassert(is_native); - } + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if(NULL == (f = (H5F_t *)H5VL_object_data(file))) + if (NULL == (f = (H5F_t *)H5VL_object_data(file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Size on disk, memory size is different */ - dt->shared->size = H5T_REF_OBJ_DISK_SIZE(f); + dt->shared->size = H5T_REF_OBJ_DISK_SIZE(f); dt->shared->u.atomic.prec = 8 * dt->shared->size; /* Set up the function pointers to access the reference in memory */ dt->shared->u.atomic.u.r.cls = &H5T_ref_obj_disk_g; } /* end if */ - else if(dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION1) { + else if (dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION1) { H5F_t *f; #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(file, &is_native) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + if (H5VL_object_is_native(file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, + "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ HDassert(is_native); @@ -235,11 +249,11 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if(NULL == (f = (H5F_t *)H5VL_object_data(file))) + if (NULL == (f = (H5F_t *)H5VL_object_data(file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Size on disk, memory size is different */ - dt->shared->size = H5T_REF_DSETREG_DISK_SIZE(f); + dt->shared->size = H5T_REF_DSETREG_DISK_SIZE(f); dt->shared->u.atomic.prec = 8 * dt->shared->size; /* Set up the function pointers to access the reference in memory */ @@ -247,24 +261,24 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) } /* end else-if */ else { H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - size_t ref_encode_size; - H5R_ref_priv_t fixed_ref; + size_t ref_encode_size; + H5R_ref_priv_t fixed_ref; /* Get container info */ - if(H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info") /* Retrieve min encode size (when references have no vlen part) */ HDmemset(&fixed_ref, 0, sizeof(fixed_ref)); - fixed_ref.type = (int8_t)H5R_OBJECT2; + fixed_ref.type = (int8_t)H5R_OBJECT2; fixed_ref.token_size = (uint8_t)cont_info.token_size; - if(H5R__encode(NULL, &fixed_ref, NULL, &ref_encode_size, 0) < 0) + if (H5R__encode(NULL, &fixed_ref, NULL, &ref_encode_size, 0) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't get encode size") /* Size on disk, memory size is different */ - dt->shared->size = MAX(H5_SIZEOF_UINT32_T + - H5R_ENCODE_HEADER_SIZE + cont_info.blob_id_size, - ref_encode_size); + dt->shared->size = MAX(H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE + cont_info.blob_id_size, + ref_encode_size); dt->shared->u.atomic.prec = 8 * dt->shared->size; /* Set up the function pointers to access the information on @@ -289,7 +303,7 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) break; - case H5T_LOC_MAXLOC: /* MAXLOC is invalid */ + case H5T_LOC_MAXLOC: /* MAXLOC is invalid */ default: HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid reference datatype location") } /* end switch */ @@ -299,9 +313,8 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_set_loc() */ +} /* end H5T__ref_set_loc() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_mem_isnull * @@ -312,11 +325,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file, - const void *src_buf, hbool_t *isnull) +H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, hbool_t *isnull) { - const unsigned char zeros[H5T_REF_MEM_SIZE] = { 0 }; - herr_t ret_value = SUCCEED; + const unsigned char zeros[H5T_REF_MEM_SIZE] = {0}; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_NOERR @@ -327,9 +339,8 @@ H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file, *isnull = (0 == HDmemcmp(src_buf, zeros, H5T_REF_MEM_SIZE)) ? TRUE : FALSE; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_mem_isnull() */ +} /* end H5T__ref_mem_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_mem_setnull * @@ -340,8 +351,7 @@ H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file, *------------------------------------------------------------------------- */ static herr_t -H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, - H5_ATTR_UNUSED void *bg_buf) +H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, H5_ATTR_UNUSED void *bg_buf) { herr_t ret_value = SUCCEED; @@ -350,9 +360,8 @@ H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, HDmemset(dst_buf, 0, H5T_REF_MEM_SIZE); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_mem_setnull() */ +} /* end H5T__ref_mem_setnull() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_mem_getsize * @@ -364,13 +373,14 @@ H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, */ static size_t H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, - size_t H5_ATTR_UNUSED src_size, H5VL_object_t *dst_file, hbool_t *dst_copy) + size_t H5_ATTR_UNUSED src_size, H5VL_object_t *dst_file, hbool_t *dst_copy) { - H5VL_object_t *vol_obj = NULL; /* VOL object for src ref's location */ + H5VL_object_t * vol_obj = NULL; /* VOL object for src ref's location */ const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; - char *file_name_buf_dyn = NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ - unsigned flags = 0; /* References flags */ - size_t ret_value = 0; /* Return value */ + char * file_name_buf_dyn = + NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ + unsigned flags = 0; /* References flags */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC @@ -378,38 +388,38 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf HDassert(src_buf); HDassert(src_size == H5T_REF_MEM_SIZE); - if(NULL != dst_file) { - hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ + if (NULL != dst_file) { + hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ /* Retrieve VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") /* Set external flag if referenced file is not destination file */ - if(H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) + if (H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, 0, "can't check if files are equal") flags |= !files_equal ? H5R_IS_EXTERNAL : 0; } /* Force re-calculating encoding size if any flags are set */ - if(flags || !src_ref->encode_size) { - char file_name_buf_static[256]; /* File name */ - ssize_t file_name_len; /* Size of file name buffer */ + if (flags || !src_ref->encode_size) { + char file_name_buf_static[256]; /* File name */ + ssize_t file_name_len; /* Size of file name buffer */ /* Pass the correct encoding version for the selection depending on the * file libver bounds, this is later retrieved in H5S hyper encode */ - if(src_ref->type == (int8_t)H5R_DATASET_REGION2) { - hbool_t is_native = FALSE; /* Whether the dest. file is using the native VOL connector */ + if (src_ref->type == (int8_t)H5R_DATASET_REGION2) { + hbool_t is_native = FALSE; /* Whether the dest. file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(dst_file, &is_native) < 0) + if (H5VL_object_is_native(dst_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") /* Set the file's libver bounds if using the native VOL connector */ - if(is_native) { - H5F_t *dst_f; /* Native file struct */ + if (is_native) { + H5F_t *dst_f; /* Native file struct */ - if(NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file))) + if (NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") H5CX_set_libver_bounds(dst_f); } /* end if */ @@ -418,22 +428,25 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf } /* end if */ /* Get file name */ - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, + sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") - if(file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { - if(NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) + if (file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { + if (NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name") - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, + (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") } /* end if */ /* Determine encoding size */ - if(H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, NULL, &ret_value, flags) < 0) + if (H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, NULL, + &ret_value, flags) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, 0, "unable to determine encoding size") } /* end if */ else { /* Can do a direct copy and skip blob decoding */ - if(src_ref->type == (int8_t)H5R_OBJECT2) + if (src_ref->type == (int8_t)H5R_OBJECT2) *dst_copy = TRUE; /* Get cached encoding size */ @@ -444,9 +457,8 @@ done: H5MM_xfree(file_name_buf_dyn); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_mem_getsize() */ +} /* end H5T__ref_mem_getsize() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_mem_read * @@ -457,18 +469,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, - size_t H5_ATTR_UNUSED src_size, H5VL_object_t *dst_file, void *dst_buf, - size_t dst_size) +H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t H5_ATTR_UNUSED src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size) { - H5VL_object_t *vol_obj; /* VOL object for src ref's location */ - const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; - hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ - char file_name_buf_static[256] = {'\0'}; /* File name */ - char *file_name_buf_dyn = NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ - ssize_t file_name_len; /* Size of file name buffer */ - unsigned flags = 0; /* References flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* VOL object for src ref's location */ + const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; + hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ + char file_name_buf_static[256] = {'\0'}; /* File name */ + char * file_name_buf_dyn = + NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ + ssize_t file_name_len; /* Size of file name buffer */ + unsigned flags = 0; /* References flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -479,34 +491,34 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, HDassert(dst_size); /* Memory-to-memory conversion to support vlen conversion */ - if(NULL == dst_file) { + if (NULL == dst_file) { HDmemcpy(dst_buf, src_buf, dst_size); HGOTO_DONE(ret_value); } /* Retrieve VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) + if (NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") /* Set external flag if referenced file is not destination file */ - if(H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) + if (H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "can't check if files are equal") flags |= !files_equal ? H5R_IS_EXTERNAL : 0; /* Pass the correct encoding version for the selection depending on the * file libver bounds, this is later retrieved in H5S hyper encode */ - if(src_ref->type == (int8_t)H5R_DATASET_REGION2) { - hbool_t is_native = FALSE; /* Whether the dest. file is using the native VOL connector */ + if (src_ref->type == (int8_t)H5R_DATASET_REGION2) { + hbool_t is_native = FALSE; /* Whether the dest. file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(dst_file, &is_native) < 0) + if (H5VL_object_is_native(dst_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") /* Set the file's libver bounds if using the native VOL connector */ - if(is_native) { + if (is_native) { H5F_t *dst_f; - if(NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file))) + if (NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") H5CX_set_libver_bounds(dst_f); } /* end if */ @@ -515,28 +527,30 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, } /* end if */ /* Get file name (if external reference) */ - if(flags) { - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) + if (flags) { + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, + sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") - if(file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { - if(NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) + if (file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { + if (NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name") - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, + (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") } /* end if */ - } /* end if */ + } /* end if */ /* Encode reference */ - if(H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, (unsigned char *)dst_buf, &dst_size, flags) < 0) + if (H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, + (unsigned char *)dst_buf, &dst_size, flags) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Cannot encode reference") done: H5MM_xfree(file_name_buf_dyn); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_mem_read() */ +} /* end H5T__ref_mem_read() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_mem_write * @@ -547,14 +561,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5R_type_t src_type, H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, - size_t dst_size, void H5_ATTR_UNUSED *bg_buf) +H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type, + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size, + void H5_ATTR_UNUSED *bg_buf) { - H5F_t *src_f = NULL; - hid_t file_id = H5I_INVALID_HID; - H5R_ref_priv_t *dst_ref = (H5R_ref_priv_t *)dst_buf; - herr_t ret_value = SUCCEED; + H5F_t * src_f = NULL; + hid_t file_id = H5I_INVALID_HID; + H5R_ref_priv_t *dst_ref = (H5R_ref_priv_t *)dst_buf; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -565,17 +579,17 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size HDassert(dst_size == H5T_REF_MEM_SIZE); /* Memory-to-memory conversion to support vlen conversion */ - if(NULL == src_file) { + if (NULL == src_file) { HDmemcpy(dst_buf, src_buf, src_size); HGOTO_DONE(ret_value); } #ifndef NDEBUG - if((src_type == H5R_OBJECT1) || (src_type == H5R_DATASET_REGION1)) { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + if ((src_type == H5R_OBJECT1) || (src_type == H5R_DATASET_REGION1)) { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -584,35 +598,31 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if(NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Make sure reference buffer is correctly initialized */ HDmemset(dst_buf, 0, dst_size); - switch(src_type) { - case H5R_OBJECT1: - { - size_t token_size = H5F_SIZEOF_ADDR(src_f); + switch (src_type) { + case H5R_OBJECT1: { + size_t token_size = H5F_SIZEOF_ADDR(src_f); - if(H5R__create_object((const H5O_token_t *)src_buf, token_size, dst_ref) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference") - } - break; + if (H5R__create_object((const H5O_token_t *)src_buf, token_size, dst_ref) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference") + } break; - case H5R_DATASET_REGION1: - { - const struct H5Tref_dsetreg *src_reg = (const struct H5Tref_dsetreg *)src_buf; - size_t token_size = H5F_SIZEOF_ADDR(src_f); + case H5R_DATASET_REGION1: { + const struct H5Tref_dsetreg *src_reg = (const struct H5Tref_dsetreg *)src_buf; + size_t token_size = H5F_SIZEOF_ADDR(src_f); - if(H5R__create_region(&src_reg->token, token_size, src_reg->space, dst_ref) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create region reference") + if (H5R__create_region(&src_reg->token, token_size, src_reg->space, dst_ref) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create region reference") - /* create_region creates its internal copy of the space */ - if(H5S_close(src_reg->space) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace") - } - break; + /* create_region creates its internal copy of the space */ + if (H5S_close(src_reg->space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace") + } break; case H5R_DATASET_REGION2: /* Pass the correct encoding version for the selection depending on the @@ -622,7 +632,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size case H5R_OBJECT2: case H5R_ATTR: /* Decode reference */ - if(H5R__decode((const unsigned char *)src_buf, &src_size, dst_ref) < 0) + if (H5R__decode((const unsigned char *)src_buf, &src_size, dst_ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Cannot decode reference") break; @@ -634,24 +644,23 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size } /* end switch */ /* If no filename set, this is not an external reference */ - if(NULL == H5R_REF_FILENAME(dst_ref)) { + if (NULL == H5R_REF_FILENAME(dst_ref)) { /* TODO temporary hack to retrieve file object */ - if((file_id = H5F_get_file_id(src_file, H5I_FILE, FALSE)) < 0) + if ((file_id = H5F_get_file_id(src_file, H5I_FILE, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Attach loc ID to reference and hold reference to it, this is a * user exposed reference so set app_ref to TRUE. */ - if(H5R__set_loc_id(dst_ref, file_id, TRUE, TRUE) < 0) + if (H5R__set_loc_id(dst_ref, file_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") } /* end if */ done: - if((file_id != H5I_INVALID_HID) && (H5I_dec_ref(file_id) < 0)) + if ((file_id != H5I_INVALID_HID) && (H5I_dec_ref(file_id) < 0)) HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_mem_write() */ +} /* end H5T__ref_mem_write() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_disk_isnull * @@ -662,12 +671,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, - hbool_t *isnull) +H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) { const uint8_t *p = (const uint8_t *)src_buf; - H5R_type_t ref_type; - herr_t ret_value = SUCCEED; + H5R_type_t ref_type; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -678,23 +686,23 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, /* Try to check encoded reference type */ ref_type = (H5R_type_t)*p++; - if(ref_type) { + if (ref_type) { /* This is a valid reference */ *isnull = FALSE; - } else { + } + else { /* Skip the size / header */ p = (const uint8_t *)src_buf + H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T; /* Check if blob ID is "nil" */ - if(H5VL_blob_specific(src_file, (void *)p, H5VL_BLOB_ISNULL, isnull) < 0) + if (H5VL_blob_specific(src_file, (void *)p, H5VL_BLOB_ISNULL, isnull) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'") } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_disk_isnull() */ +} /* end H5T__ref_disk_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_disk_setnull * @@ -707,9 +715,9 @@ done: static herr_t H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) { - uint8_t *q = (uint8_t *)dst_buf; - uint8_t *p_bg = (uint8_t *)bg_buf; - herr_t ret_value = SUCCEED; + uint8_t *q = (uint8_t *)dst_buf; + uint8_t *p_bg = (uint8_t *)bg_buf; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -717,12 +725,12 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) HDassert(dst_buf); /* TODO Should get rid of bg stuff */ - if(p_bg) { + if (p_bg) { /* Skip the size / header */ p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); /* Remove blob for old data */ - if(H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0) + if (H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ @@ -734,14 +742,13 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) UINT32ENCODE(q, 0); /* Set blob ID to "nil" */ - if(H5VL_blob_specific(dst_file, q, H5VL_BLOB_SETNULL) < 0) + if (H5VL_blob_specific(dst_file, q, H5VL_BLOB_SETNULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_disk_setnull() */ +} /* end H5T__ref_disk_setnull() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_disk_getsize * @@ -752,13 +759,13 @@ done: *------------------------------------------------------------------------- */ static size_t -H5T__ref_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, - size_t src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, hbool_t *dst_copy) +H5T__ref_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file, hbool_t *dst_copy) { const uint8_t *p = (const uint8_t *)src_buf; - unsigned flags; - H5R_type_t ref_type; - size_t ret_value = 0; + unsigned flags; + H5R_type_t ref_type; + size_t ret_value = 0; FUNC_ENTER_STATIC @@ -766,13 +773,13 @@ H5T__ref_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_bu /* Set reference type */ ref_type = (H5R_type_t)*p++; - if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid reference type") /* Set flags */ flags = (unsigned)*p++; - if(!(flags & H5R_IS_EXTERNAL) && (ref_type == H5R_OBJECT2)) { + if (!(flags & H5R_IS_EXTERNAL) && (ref_type == H5R_OBJECT2)) { /* Can do a direct copy and skip blob decoding */ *dst_copy = TRUE; @@ -788,9 +795,8 @@ H5T__ref_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_bu done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_disk_getsize() */ +} /* end H5T__ref_disk_getsize() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_disk_read * @@ -802,12 +808,12 @@ done: */ static herr_t H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_NDEBUG_UNUSED src_size, - H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size) + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size) { - const uint8_t *p = (const uint8_t *)src_buf; - uint8_t *q = (uint8_t *)dst_buf; - size_t blob_size = dst_size; - herr_t ret_value = SUCCEED; + const uint8_t *p = (const uint8_t *)src_buf; + uint8_t * q = (uint8_t *)dst_buf; + size_t blob_size = dst_size; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -827,14 +833,13 @@ H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_ HDassert(src_size > (H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T)); /* Retrieve blob */ - if(H5VL_blob_get(src_file, p, q, blob_size, NULL) < 0) + if (H5VL_blob_get(src_file, p, q, blob_size, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get blob") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_disk_read() */ +} /* end H5T__ref_disk_read() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_disk_write * @@ -845,15 +850,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, - size_t src_size, H5R_type_t H5_ATTR_UNUSED src_type, H5VL_object_t *dst_file, - void *dst_buf, size_t dst_size, void *bg_buf) +H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t src_size, + H5R_type_t H5_ATTR_UNUSED src_type, H5VL_object_t *dst_file, void *dst_buf, + size_t dst_size, void *bg_buf) { - const uint8_t *p = (const uint8_t *)src_buf; - uint8_t *q = (uint8_t *)dst_buf; - size_t buf_size_left = dst_size; - uint8_t *p_bg = (uint8_t *)bg_buf; - herr_t ret_value = SUCCEED; + const uint8_t *p = (const uint8_t *)src_buf; + uint8_t * q = (uint8_t *)dst_buf; + size_t buf_size_left = dst_size; + uint8_t * p_bg = (uint8_t *)bg_buf; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -863,7 +868,7 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, HDassert(dst_buf); /* TODO Should get rid of bg stuff */ - if(p_bg) { + if (p_bg) { size_t p_buf_size_left = dst_size; /* Skip the size / header */ @@ -872,7 +877,7 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, p_buf_size_left -= (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); /* Remove blob for old data */ - if(H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0) + if (H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ @@ -889,14 +894,13 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, buf_size_left -= H5_SIZEOF_UINT32_T; /* Store blob */ - if(H5VL_blob_put(dst_file, p, src_size, q, NULL) < 0) + if (H5VL_blob_put(dst_file, p, src_size, q, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to put blob") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_disk_write() */ +} /* end H5T__ref_disk_write() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_obj_disk_isnull * @@ -906,13 +910,13 @@ done: * *------------------------------------------------------------------------- */ -static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, - const void *src_buf, hbool_t *isnull) +static herr_t +H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) { - H5F_t *src_f; + H5F_t * src_f; const uint8_t *p = (const uint8_t *)src_buf; - haddr_t addr; - herr_t ret_value = SUCCEED; + haddr_t addr; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -923,10 +927,10 @@ static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -935,7 +939,7 @@ static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if(NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Get the object address */ @@ -946,9 +950,8 @@ static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_obj_disk_isnull() */ +} /* end H5T__ref_obj_disk_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_obj_disk_getsize * @@ -960,8 +963,8 @@ done: */ static size_t H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *src_buf, - size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, - hbool_t H5_ATTR_UNUSED *dst_copy) + size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, + hbool_t H5_ATTR_UNUSED *dst_copy) { H5F_t *src_f; size_t ret_value = 0; @@ -973,10 +976,10 @@ H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *sr #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -985,7 +988,7 @@ H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *sr #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if(NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f)); @@ -994,9 +997,8 @@ H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *sr done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_obj_disk_getsize() */ +} /* end H5T__ref_obj_disk_getsize() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_obj_disk_read * @@ -1008,7 +1010,7 @@ done: */ static herr_t H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t H5_ATTR_UNUSED dst_size) + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t H5_ATTR_UNUSED dst_size) { H5F_t *src_f; herr_t ret_value = SUCCEED; @@ -1021,10 +1023,10 @@ H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_ #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1033,22 +1035,21 @@ H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_ #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if(NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f)); HDassert(dst_size == H5F_SIZEOF_ADDR(src_f)); /* Get object address */ - if(H5R__decode_token_obj_compat((const unsigned char *)src_buf, &src_size, - (H5O_token_t *)dst_buf, H5F_SIZEOF_ADDR(src_f)) < 0) + if (H5R__decode_token_obj_compat((const unsigned char *)src_buf, &src_size, (H5O_token_t *)dst_buf, + H5F_SIZEOF_ADDR(src_f)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_obj_disk_read() */ +} /* end H5T__ref_obj_disk_read() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_dsetreg_disk_isnull * @@ -1059,13 +1060,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, - hbool_t *isnull) +H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) { - H5F_t *src_f; + H5F_t * src_f; const uint8_t *p = (const uint8_t *)src_buf; - haddr_t addr; - herr_t ret_value = SUCCEED; + haddr_t addr; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1076,10 +1076,10 @@ H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1088,7 +1088,7 @@ H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if(NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Get the heap address */ @@ -1099,9 +1099,8 @@ H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_dsetreg_disk_isnull() */ +} /* end H5T__ref_dsetreg_disk_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_dsetreg_disk_getsize * @@ -1112,9 +1111,9 @@ done: *------------------------------------------------------------------------- */ static size_t -H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, - const void H5_ATTR_UNUSED *src_buf, size_t H5_ATTR_UNUSED src_size, - H5VL_object_t H5_ATTR_UNUSED *dst_file, hbool_t H5_ATTR_UNUSED *dst_copy) +H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void H5_ATTR_UNUSED *src_buf, + size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, + hbool_t H5_ATTR_UNUSED *dst_copy) { size_t ret_value = sizeof(struct H5Tref_dsetreg); @@ -1128,18 +1127,18 @@ H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, #ifndef NDEBUG { - H5F_t *src_f; - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + H5F_t * src_f; + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ HDassert(is_native); /* Retrieve file from VOL object */ - if(NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") HDassert(src_size == H5T_REF_DSETREG_DISK_SIZE(src_f)); @@ -1150,9 +1149,8 @@ H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, done: #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_dsetreg_disk_getsize() */ +} /* end H5T__ref_dsetreg_disk_getsize() */ - /*------------------------------------------------------------------------- * Function: H5T__ref_dsetreg_disk_read * @@ -1164,11 +1162,12 @@ done: */ static herr_t H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t H5_ATTR_UNUSED dst_size) + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, + size_t H5_ATTR_UNUSED dst_size) { - H5F_t *src_f; - struct H5Tref_dsetreg *dst_reg = (struct H5Tref_dsetreg *)dst_buf; - herr_t ret_value = SUCCEED; + H5F_t * src_f; + struct H5Tref_dsetreg *dst_reg = (struct H5Tref_dsetreg *)dst_buf; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1179,10 +1178,10 @@ H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t #ifndef NDEBUG { - hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if(H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1191,21 +1190,20 @@ H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if(NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") HDassert(src_size == H5T_REF_DSETREG_DISK_SIZE(src_f)); /* Retrieve object address and space */ - if(H5R__decode_token_region_compat(src_f, (const unsigned char *)src_buf, - &src_size, &dst_reg->token, H5F_SIZEOF_ADDR(src_f), &dst_reg->space) < 0) + if (H5R__decode_token_region_compat(src_f, (const unsigned char *)src_buf, &src_size, &dst_reg->token, + H5F_SIZEOF_ADDR(src_f), &dst_reg->space) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__ref_dsetreg_disk_read() */ +} /* end H5T__ref_dsetreg_disk_read() */ - /*------------------------------------------------------------------------- * Function: H5T_ref_reclaim * @@ -1218,7 +1216,7 @@ done: herr_t H5T_ref_reclaim(void *elem, const H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1226,10 +1224,9 @@ H5T_ref_reclaim(void *elem, const H5T_t *dt) HDassert(elem); HDassert(dt && (dt->shared->type == H5T_REFERENCE)); - if(dt->shared->u.atomic.u.r.opaque && H5R__destroy((H5R_ref_priv_t *)elem) < 0) + if (dt->shared->u.atomic.u.r.opaque && H5R__destroy((H5R_ref_priv_t *)elem) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "cannot free reference") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_ref_reclaim() */ - diff --git a/src/H5Tstrpad.c b/src/H5Tstrpad.c index fa084f1..cf9f047 100644 --- a/src/H5Tstrpad.c +++ b/src/H5Tstrpad.c @@ -16,16 +16,13 @@ * the datatype string padding for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ - - - /*------------------------------------------------------------------------- * Function: H5Tget_strpad * @@ -50,22 +47,22 @@ H5T_str_t H5Tget_strpad(hid_t type_id) { - H5T_t *dt = NULL; - H5T_str_t ret_value; + H5T_t * dt = NULL; + H5T_str_t ret_value; FUNC_ENTER_API(H5T_STR_ERROR) H5TRACE1("Tz", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR, "not a datatype") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) - dt = dt->shared->parent; /*defer to parent*/ + dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_STR_ERROR, "operation not defined for datatype class") /* result */ - if(H5T_IS_FIXED_STRING(dt->shared)) + if (H5T_IS_FIXED_STRING(dt->shared)) ret_value = dt->shared->u.atomic.u.s.pad; else ret_value = dt->shared->u.vlen.pad; @@ -74,7 +71,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tset_strpad * @@ -107,26 +103,26 @@ done: herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTz", type_id, strpad); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (strpad < H5T_STR_NULLTERM || strpad >= H5T_NSTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) - dt = dt->shared->parent; /*defer to parent*/ + dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class") /* Commit */ - if(H5T_IS_FIXED_STRING(dt->shared)) + if (H5T_IS_FIXED_STRING(dt->shared)) dt->shared->u.atomic.u.s.pad = strpad; else dt->shared->u.vlen.pad = strpad; @@ -134,4 +130,3 @@ H5Tset_strpad(hid_t type_id, H5T_str_t strpad) done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Tvisit.c b/src/H5Tvisit.c index c706dee..a9319b4 100644 --- a/src/H5Tvisit.c +++ b/src/H5Tvisit.c @@ -33,53 +33,43 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5T__visit * @@ -96,8 +86,8 @@ herr_t H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value) { - hbool_t is_complex; /* Flag indicating current datatype is "complex" */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t is_complex; /* Flag indicating current datatype is "complex" */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -106,31 +96,30 @@ H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value) HDassert(op); /* Check for complex datatype */ - is_complex = H5T_IS_COMPLEX(dt->shared->type); + is_complex = H5T_IS_COMPLEX(dt->shared->type); /* If the callback is to be made on the datatype first, do that */ - if(is_complex && (visit_flags & H5T_VISIT_COMPLEX_FIRST)) - if(op(dt, op_value) < 0) + if (is_complex && (visit_flags & H5T_VISIT_COMPLEX_FIRST)) + if (op(dt, op_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed") /* Make callback for each member/child, if requested */ - switch(dt->shared->type) { - case H5T_COMPOUND: - { - unsigned u; /* Local index variable */ - - /* Visit each member of the compound datatype */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) - if(H5T__visit(dt->shared->u.compnd.memb[u].type, visit_flags, op, op_value) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "can't visit member datatype") - } /* end case */ - break; + switch (dt->shared->type) { + case H5T_COMPOUND: { + unsigned u; /* Local index variable */ + + /* Visit each member of the compound datatype */ + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) + if (H5T__visit(dt->shared->u.compnd.memb[u].type, visit_flags, op, op_value) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "can't visit member datatype") + } /* end case */ + break; case H5T_ARRAY: case H5T_VLEN: case H5T_ENUM: /* Visit parent type */ - if(H5T__visit(dt->shared->parent, visit_flags, op, op_value) < 0) + if (H5T__visit(dt->shared->parent, visit_flags, op, op_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "can't visit parent datatype") break; @@ -149,18 +138,17 @@ H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value) case H5T_REFERENCE: default: /* Visit "simple" datatypes here */ - if(visit_flags & H5T_VISIT_SIMPLE) - if(op(dt, op_value) < 0) + if (visit_flags & H5T_VISIT_SIMPLE) + if (op(dt, op_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed") break; } /* end switch */ /* If the callback is to be made on the datatype last, do that */ - if(is_complex && (visit_flags & H5T_VISIT_COMPLEX_LAST)) - if(op(dt, op_value) < 0) + if (is_complex && (visit_flags & H5T_VISIT_COMPLEX_LAST)) + if (op(dt, op_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__visit() */ - diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 9d098c6..dd8aa76 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -20,36 +20,33 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -60,7 +57,8 @@ static void * H5T__vlen_mem_seq_getptr(void *_vl); static herr_t H5T__vlen_mem_seq_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); static herr_t H5T__vlen_mem_seq_setnull(H5VL_object_t *file, void *_vl, void *_bg); static herr_t H5T__vlen_mem_seq_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); -static herr_t H5T__vlen_mem_seq_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); +static herr_t H5T__vlen_mem_seq_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); /* Memory-based VL string callbacks */ static herr_t H5T__vlen_mem_str_getlen(H5VL_object_t *file, const void *_vl, size_t *len); @@ -68,71 +66,67 @@ static void * H5T__vlen_mem_str_getptr(void *_vl); static herr_t H5T__vlen_mem_str_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); static herr_t H5T__vlen_mem_str_setnull(H5VL_object_t *file, void *_vl, void *_bg); static herr_t H5T__vlen_mem_str_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); -static herr_t H5T__vlen_mem_str_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); +static herr_t H5T__vlen_mem_str_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); /* Disk-based VL sequence (and string) callbacks */ static herr_t H5T__vlen_disk_getlen(H5VL_object_t *file, const void *_vl, size_t *len); static herr_t H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); static herr_t H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *_bg); static herr_t H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); -static herr_t H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); +static herr_t H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, + void *_buf, void *_bg, size_t seq_len, size_t base_size); static herr_t H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl); - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Class for VL sequences in memory */ static const H5T_vlen_class_t H5T_vlen_mem_seq_g = { - H5T__vlen_mem_seq_getlen, /* 'getlen' */ - H5T__vlen_mem_seq_getptr, /* 'getptr' */ - H5T__vlen_mem_seq_isnull, /* 'isnull' */ - H5T__vlen_mem_seq_setnull, /* 'setnull' */ - H5T__vlen_mem_seq_read, /* 'read' */ - H5T__vlen_mem_seq_write, /* 'write' */ - NULL /* 'delete' */ + H5T__vlen_mem_seq_getlen, /* 'getlen' */ + H5T__vlen_mem_seq_getptr, /* 'getptr' */ + H5T__vlen_mem_seq_isnull, /* 'isnull' */ + H5T__vlen_mem_seq_setnull, /* 'setnull' */ + H5T__vlen_mem_seq_read, /* 'read' */ + H5T__vlen_mem_seq_write, /* 'write' */ + NULL /* 'delete' */ }; /* Class for VL strings in memory */ static const H5T_vlen_class_t H5T_vlen_mem_str_g = { - H5T__vlen_mem_str_getlen, /* 'getlen' */ - H5T__vlen_mem_str_getptr, /* 'getptr' */ - H5T__vlen_mem_str_isnull, /* 'isnull' */ - H5T__vlen_mem_str_setnull, /* 'setnull' */ - H5T__vlen_mem_str_read, /* 'read' */ - H5T__vlen_mem_str_write, /* 'write' */ - NULL /* 'delete' */ + H5T__vlen_mem_str_getlen, /* 'getlen' */ + H5T__vlen_mem_str_getptr, /* 'getptr' */ + H5T__vlen_mem_str_isnull, /* 'isnull' */ + H5T__vlen_mem_str_setnull, /* 'setnull' */ + H5T__vlen_mem_str_read, /* 'read' */ + H5T__vlen_mem_str_write, /* 'write' */ + NULL /* 'delete' */ }; /* Class for both VL strings and sequences in file */ static const H5T_vlen_class_t H5T_vlen_disk_g = { - H5T__vlen_disk_getlen, /* 'getlen' */ - NULL, /* 'getptr' */ - H5T__vlen_disk_isnull, /* 'isnull' */ - H5T__vlen_disk_setnull, /* 'setnull' */ - H5T__vlen_disk_read, /* 'read' */ - H5T__vlen_disk_write, /* 'write' */ - H5T__vlen_disk_delete /* 'delete' */ + H5T__vlen_disk_getlen, /* 'getlen' */ + NULL, /* 'getptr' */ + H5T__vlen_disk_isnull, /* 'isnull' */ + H5T__vlen_disk_setnull, /* 'setnull' */ + H5T__vlen_disk_read, /* 'read' */ + H5T__vlen_disk_write, /* 'write' */ + H5T__vlen_disk_delete /* 'delete' */ }; - - /*------------------------------------------------------------------------- * Function: H5Tvlen_create * @@ -151,30 +145,29 @@ static const H5T_vlen_class_t H5T_vlen_disk_g = { hid_t H5Tvlen_create(hid_t base_id) { - H5T_t *base = NULL; /*base datatype */ - H5T_t *dt = NULL; /*new datatype */ - hid_t ret_value; /*return value */ + H5T_t *base = NULL; /*base datatype */ + H5T_t *dt = NULL; /*new datatype */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", base_id); /* Check args */ - if(NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) + if (NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") /* Create up VL datatype */ - if((dt = H5T__vlen_create(base)) == NULL) + if ((dt = H5T__vlen_create(base)) == NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location") /* Atomize the type */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tvlen_create() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_create * @@ -193,8 +186,8 @@ done: H5T_t * H5T__vlen_create(const H5T_t *base) { - H5T_t *dt = NULL; /* New VL datatype */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; /* New VL datatype */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -202,7 +195,7 @@ H5T__vlen_create(const H5T_t *base) HDassert(base); /* Build new type */ - if(NULL == (dt = H5T__alloc())) + if (NULL == (dt = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "memory allocation failed") dt->shared->type = H5T_VLEN; @@ -211,7 +204,7 @@ H5T__vlen_create(const H5T_t *base) * data, not point to the same VL sequences) */ dt->shared->force_conv = TRUE; - if(NULL == (dt->shared->parent = H5T_copy(base, H5T_COPY_ALL))) + if (NULL == (dt->shared->parent = H5T_copy(base, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy base datatype") /* Inherit encoding version from base type */ @@ -221,21 +214,20 @@ H5T__vlen_create(const H5T_t *base) dt->shared->u.vlen.type = H5T_VLEN_SEQUENCE; /* Set up VL information */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* Set return value */ ret_value = dt; done: - if(!ret_value) - if(dt && H5T_close_real(dt) < 0) + if (!ret_value) + if (dt && H5T_close_real(dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release datatype info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_create() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_set_loc * @@ -256,7 +248,7 @@ htri_t H5T__vlen_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) { H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - htri_t ret_value = FALSE; /* Indicate success, but no location change */ + htri_t ret_value = FALSE; /* Indicate success, but no location change */ FUNC_ENTER_PACKAGE @@ -265,22 +257,22 @@ H5T__vlen_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); /* Only change the location if it's different */ - if(loc != dt->shared->u.vlen.loc || file != dt->shared->u.vlen.file) { - switch(loc) { - case H5T_LOC_MEMORY: /* Memory based VL datatype */ + if (loc != dt->shared->u.vlen.loc || file != dt->shared->u.vlen.file) { + switch (loc) { + case H5T_LOC_MEMORY: /* Memory based VL datatype */ HDassert(NULL == file); /* Mark this type as being stored in memory */ dt->shared->u.vlen.loc = H5T_LOC_MEMORY; - if(dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { + if (dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { /* Size in memory, disk size is different */ dt->shared->size = sizeof(hvl_t); /* Set up the function pointers to access the VL sequence in memory */ dt->shared->u.vlen.cls = &H5T_vlen_mem_seq_g; } /* end if */ - else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + else if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Size in memory, disk size is different */ dt->shared->size = sizeof(char *); @@ -294,14 +286,15 @@ H5T__vlen_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) dt->shared->u.vlen.file = NULL; break; - case H5T_LOC_DISK: /* Disk based VL datatype */ + case H5T_LOC_DISK: /* Disk based VL datatype */ HDassert(file); /* Mark this type as being stored on disk */ dt->shared->u.vlen.loc = H5T_LOC_DISK; /* Get container info */ - if(H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0) + if (H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info") /* The datatype size is equal to 4 bytes for the sequence length @@ -343,7 +336,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_set_loc() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_seq_getlen * @@ -362,7 +354,7 @@ H5T__vlen_mem_seq_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, si #ifdef H5_NO_ALIGNMENT_RESTRICTIONS const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif FUNC_ENTER_STATIC_NOERR @@ -382,7 +374,6 @@ H5T__vlen_mem_seq_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, si FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__vlen_mem_seq_getlen() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_seq_getptr * @@ -401,7 +392,7 @@ H5T__vlen_mem_seq_getptr(void *_vl) #ifdef H5_NO_ALIGNMENT_RESTRICTIONS const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif FUNC_ENTER_STATIC_NOERR @@ -419,7 +410,6 @@ H5T__vlen_mem_seq_getptr(void *_vl) #endif } /* end H5T__vlen_mem_seq_getptr() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_seq_isnull * @@ -436,9 +426,9 @@ static herr_t H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hbool_t *isnull) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif FUNC_ENTER_STATIC_NOERR @@ -457,7 +447,6 @@ H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hb FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__vlen_mem_seq_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_seq_setnull * @@ -473,7 +462,7 @@ H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hb static herr_t H5T__vlen_mem_seq_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5_ATTR_UNUSED *_bg) { - hvl_t vl; /* Temporary hvl_t to use during operation */ + hvl_t vl; /* Temporary hvl_t to use during operation */ FUNC_ENTER_STATIC_NOERR @@ -482,7 +471,7 @@ H5T__vlen_mem_seq_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5 /* Set the "nil" hvl_t */ vl.len = 0; - vl.p = NULL; + vl.p = NULL; /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ H5MM_memcpy(_vl, &vl, sizeof(hvl_t)); @@ -490,7 +479,6 @@ H5T__vlen_mem_seq_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5 FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__vlen_mem_seq_setnull() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_seq_read * @@ -507,9 +495,9 @@ static herr_t H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, size_t len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif FUNC_ENTER_STATIC_NOERR @@ -531,7 +519,6 @@ H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__vlen_mem_seq_read() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_seq_write * @@ -546,10 +533,10 @@ H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, */ static herr_t H5T__vlen_mem_seq_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc_info_t *vl_alloc_info, - void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) + void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { - hvl_t vl; /* Temporary hvl_t to use during operation */ - herr_t ret_value = SUCCEED; /* Return value */ + hvl_t vl; /* Temporary hvl_t to use during operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -557,17 +544,18 @@ H5T__vlen_mem_seq_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc HDassert(_vl); HDassert(buf); - if(seq_len) { - size_t len = seq_len * base_size; /* Sequence size */ + if (seq_len) { + size_t len = seq_len * base_size; /* Sequence size */ /* Use the user's memory allocation routine is one is defined */ - if(vl_alloc_info->alloc_func != NULL) { - if(NULL == (vl.p = (vl_alloc_info->alloc_func)(len, vl_alloc_info->alloc_info))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "application memory allocation routine failed for VL data") - } /* end if */ - else /* Default to system malloc */ - if(NULL == (vl.p = HDmalloc(len))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data") + if (vl_alloc_info->alloc_func != NULL) { + if (NULL == (vl.p = (vl_alloc_info->alloc_func)(len, vl_alloc_info->alloc_info))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, + "application memory allocation routine failed for VL data") + } /* end if */ + else /* Default to system malloc */ + if (NULL == (vl.p = HDmalloc(len))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data") /* Copy the data into the newly allocated buffer */ H5MM_memcpy(vl.p, buf, len); @@ -585,7 +573,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_mem_seq_write() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_str_getlen * @@ -602,9 +589,9 @@ static herr_t H5T__vlen_mem_str_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const char *s = *(const char * const *)_vl; /* Pointer to the user's string information */ + const char *s = *(const char *const *)_vl; /* Pointer to the user's string information */ #else - const char *s = NULL; /* Pointer to the user's string information */ + const char *s = NULL; /* Pointer to the user's string information */ #endif FUNC_ENTER_STATIC_NOERR @@ -621,7 +608,6 @@ H5T__vlen_mem_str_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, si FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__vlen_mem_str_getlen() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_str_getptr * @@ -638,9 +624,9 @@ static void * H5T__vlen_mem_str_getptr(void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s = *(char **)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - char *s = NULL; /* Pointer to the user's string information */ + char * s = NULL; /* Pointer to the user's string information */ #endif FUNC_ENTER_STATIC_NOERR @@ -656,7 +642,6 @@ H5T__vlen_mem_str_getptr(void *_vl) FUNC_LEAVE_NOAPI(s) } /* end H5T__vlen_mem_str_getptr() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_str_isnull * @@ -673,9 +658,9 @@ static herr_t H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hbool_t *isnull) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s = *(char **)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - char *s = NULL; /* Pointer to the user's string information */ + char *s = NULL; /* Pointer to the user's string information */ #endif FUNC_ENTER_STATIC_NOERR @@ -689,7 +674,6 @@ H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hb FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__vlen_mem_str_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_str_setnull * @@ -705,7 +689,7 @@ H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hb static herr_t H5T__vlen_mem_str_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5_ATTR_UNUSED *_bg) { - char *t = NULL; /* Pointer to temporary buffer allocated */ + char *t = NULL; /* Pointer to temporary buffer allocated */ FUNC_ENTER_STATIC_NOERR @@ -715,7 +699,6 @@ H5T__vlen_mem_str_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5 FUNC_LEAVE_NOAPI(SUCCEED) /*lint !e429 The pointer in 't' has been copied */ } /* end H5T__vlen_mem_str_setnull() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_str_read * @@ -729,18 +712,17 @@ H5T__vlen_mem_str_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5 *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, - size_t len) +H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, size_t len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s = *(char **)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - char *s; /* Pointer to the user's string information */ + char *s; /* Pointer to the user's string information */ #endif FUNC_ENTER_STATIC_NOERR - if(len > 0) { + if (len > 0) { /* check parameters */ HDassert(buf); #ifdef H5_NO_ALIGNMENT_RESTRICTIONS @@ -756,7 +738,6 @@ H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__vlen_mem_str_read() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_mem_str_write * @@ -771,11 +752,11 @@ H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, */ static herr_t H5T__vlen_mem_str_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc_info_t *vl_alloc_info, - void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) + void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { - char *t; /* Pointer to temporary buffer allocated */ - size_t len; /* Maximum length of the string to copy */ - herr_t ret_value = SUCCEED; /* Return value */ + char * t; /* Pointer to temporary buffer allocated */ + size_t len; /* Maximum length of the string to copy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -783,13 +764,15 @@ H5T__vlen_mem_str_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc HDassert(buf); /* Use the user's memory allocation routine if one is defined */ - if(vl_alloc_info->alloc_func != NULL) { - if(NULL == (t = (char *)(vl_alloc_info->alloc_func)((seq_len + 1) * base_size, vl_alloc_info->alloc_info))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "application memory allocation routine failed for VL data") - } /* end if */ - else /* Default to system malloc */ - if(NULL == (t = (char *)HDmalloc((seq_len + 1) * base_size))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data") + if (vl_alloc_info->alloc_func != NULL) { + if (NULL == + (t = (char *)(vl_alloc_info->alloc_func)((seq_len + 1) * base_size, vl_alloc_info->alloc_info))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, + "application memory allocation routine failed for VL data") + } /* end if */ + else /* Default to system malloc */ + if (NULL == (t = (char *)HDmalloc((seq_len + 1) * base_size))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data") /* 'write' the string into the buffer, with memcpy() */ len = (seq_len * base_size); @@ -803,7 +786,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) /*lint !e429 The pointer in 't' has been copied */ } /* end H5T__vlen_mem_str_write() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_disk_getlen * @@ -833,7 +815,6 @@ H5T__vlen_disk_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__vlen_disk_getlen() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_disk_isnull * @@ -849,8 +830,8 @@ H5T__vlen_disk_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_ static herr_t H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull) { - uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -863,14 +844,13 @@ H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull) vl += 4; /* Check if blob ID is "nil" */ - if(H5VL_blob_specific(file, vl, H5VL_BLOB_ISNULL, isnull) < 0) + if (H5VL_blob_specific(file, vl, H5VL_BLOB_ISNULL, isnull) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_disk_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_disk_setnull * @@ -886,8 +866,8 @@ done: static herr_t H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg) { - uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -896,23 +876,22 @@ H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg) HDassert(vl); /* Free heap object for old data */ - if(bg != NULL) + if (bg != NULL) /* Delete sequence in destination location */ - if(H5T__vlen_disk_delete(file, bg) < 0) + if (H5T__vlen_disk_delete(file, bg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove background heap object") /* Set the length of the sequence */ UINT32ENCODE(vl, 0); /* Set blob ID to "nil" */ - if(H5VL_blob_specific(file, vl, H5VL_BLOB_SETNULL) < 0) + if (H5VL_blob_specific(file, vl, H5VL_BLOB_SETNULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_disk_setnull() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_disk_read * @@ -928,8 +907,8 @@ done: static herr_t H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *buf, size_t len) { - const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -942,14 +921,13 @@ H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *buf, size_t len) vl += 4; /* Retrieve blob */ - if(H5VL_blob_get(file, vl, buf, len, NULL) < 0) + if (H5VL_blob_get(file, vl, buf, len, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get blob") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_disk_read() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_disk_write * @@ -963,13 +941,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_disk_write(H5VL_object_t *file, - const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info, void *_vl, - void *buf, void *_bg, size_t seq_len, size_t base_size) +H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info, + void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) { - uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - const uint8_t *bg = (const uint8_t *)_bg; /* Pointer to the old data hvl_t */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + const uint8_t *bg = (const uint8_t *)_bg; /* Pointer to the old data hvl_t */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -979,22 +956,21 @@ H5T__vlen_disk_write(H5VL_object_t *file, HDassert(file); /* Free heap object for old data, if non-NULL */ - if(bg != NULL) - if(H5T__vlen_disk_delete(file, bg) < 0) + if (bg != NULL) + if (H5T__vlen_disk_delete(file, bg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove background heap object") /* Set the length of the sequence */ UINT32ENCODE(vl, seq_len); /* Store blob */ - if(H5VL_blob_put(file, buf, (seq_len * base_size), vl, NULL) < 0) + if (H5VL_blob_put(file, buf, (seq_len * base_size), vl, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to put blob") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_disk_write() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_disk_delete * @@ -1010,8 +986,8 @@ done: static herr_t H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl) { - const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1019,15 +995,15 @@ H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl) HDassert(file); /* Free heap object for old data */ - if(vl != NULL) { - size_t seq_len; /* VL sequence's length */ + if (vl != NULL) { + size_t seq_len; /* VL sequence's length */ /* Get length of sequence */ UINT32DECODE(vl, seq_len); /* Delete object, if length > 0 */ - if(seq_len > 0) - if(H5VL_blob_specific(file, (void *)vl, H5VL_BLOB_DELETE) < 0) /* Casting away 'const' OK -QAK */ + if (seq_len > 0) + if (H5VL_blob_specific(file, (void *)vl, H5VL_BLOB_DELETE) < 0) /* Casting away 'const' OK -QAK */ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ @@ -1035,7 +1011,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_disk_delete() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_reclaim * @@ -1051,10 +1026,10 @@ done: herr_t H5T_vlen_reclaim(void *elem, const H5T_t *dt, H5T_vlen_alloc_info_t *alloc_info) { - unsigned u; /* Local index variable */ - H5MM_free_t free_func; /* Free function */ - void *free_info; /* Free info */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + H5MM_free_t free_func; /* Free function */ + void * free_info; /* Free info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1067,69 +1042,71 @@ H5T_vlen_reclaim(void *elem, const H5T_t *dt, H5T_vlen_alloc_info_t *alloc_info) free_info = alloc_info->free_info; /* Check the datatype of this element */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_ARRAY: /* Recurse on each element, if the array's base type is array, VL, enum or compound */ - if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ - for(u = 0; u < dt->shared->u.array.nelem; u++) { + for (u = 0; u < dt->shared->u.array.nelem; u++) { off = ((uint8_t *)elem) + u * (dt->shared->parent->shared->size); - if(H5T_reclaim_cb(off, dt->shared->parent, 0, NULL, alloc_info) < 0) + if (H5T_reclaim_cb(off, dt->shared->parent, 0, NULL, alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free array element") } /* end for */ - } /* end if */ + } /* end if */ break; case H5T_COMPOUND: /* Check each field and recurse on VL, compound, enum or array ones */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) { + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) { /* Recurse if it's VL, compound, enum or array */ - if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[u].type->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->u.compnd.memb[u].type->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ off = ((uint8_t *)elem) + dt->shared->u.compnd.memb[u].offset; - if(H5T_reclaim_cb(off, dt->shared->u.compnd.memb[u].type, 0, NULL, alloc_info) < 0) + if (H5T_reclaim_cb(off, dt->shared->u.compnd.memb[u].type, 0, NULL, alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free compound field") } /* end if */ - } /* end for */ + } /* end for */ break; case H5T_VLEN: /* Recurse on the VL information if it's VL, compound, enum or array, then free VL sequence */ - if(dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { - hvl_t *vl = (hvl_t *)elem; /* Temp. ptr to the vl info */ + if (dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { + hvl_t *vl = (hvl_t *)elem; /* Temp. ptr to the vl info */ /* Check if there is anything actually in this sequence */ - if(vl->len!=0) { + if (vl->len != 0) { /* Recurse if it's VL, array, enum or compound */ - if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset of each array element and recurse on it */ - while(vl->len > 0) { + while (vl->len > 0) { off = ((uint8_t *)vl->p) + (vl->len - 1) * dt->shared->parent->shared->size; - if(H5T_reclaim_cb(off, dt->shared->parent, 0, NULL, alloc_info) < 0) + if (H5T_reclaim_cb(off, dt->shared->parent, 0, NULL, alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free VL element") vl->len--; } /* end while */ - } /* end if */ + } /* end if */ /* Free the VL sequence */ - if(free_func != NULL) + if (free_func != NULL) (*free_func)(vl->p, free_info); else HDfree(vl->p); } /* end if */ - } else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + } + else if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Free the VL string */ - if(free_func != NULL) + if (free_func != NULL) (*free_func)(*(char **)elem, free_info); else HDfree(*(char **)elem); - } else { + } + else { HDassert(0 && "Invalid VL type"); } /* end else */ break; @@ -1158,7 +1135,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_reclaim() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_reclaim_elmt * @@ -1178,8 +1154,8 @@ done: herr_t H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt) { - H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */ - herr_t ret_value = SUCCEED; /* return value */ + H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */ + herr_t ret_value = SUCCEED; /* return value */ HDassert(dt); HDassert(elem); @@ -1187,11 +1163,11 @@ H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt) FUNC_ENTER_NOAPI(FAIL) /* Get VL allocation info */ - if(H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) + if (H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") /* Recurse on buffer to free dynamic fields */ - if(H5T_vlen_reclaim(elem, dt, &vl_alloc_info) < 0) + if (H5T_vlen_reclaim(elem, dt, &vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") done: diff --git a/src/H5UC.c b/src/H5UC.c index dd61539..25f02c9 100644 --- a/src/H5UC.c +++ b/src/H5UC.c @@ -21,17 +21,15 @@ * */ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5UCprivate.h" /* Reference-counted buffers */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5UCprivate.h" /* Reference-counted buffers */ /* Private typedefs & structs */ /* Declare a free list to manage the H5UC_t struct */ H5FL_DEFINE_STATIC(H5UC_t); - /*-------------------------------------------------------------------------- NAME H5UC_create @@ -56,7 +54,7 @@ H5FL_DEFINE_STATIC(H5UC_t); H5UC_t * H5UC_create(void *o, H5UC_free_func_t free_func) { - H5UC_t *ret_value; /* Return value */ + H5UC_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -65,19 +63,18 @@ H5UC_create(void *o, H5UC_free_func_t free_func) HDassert(free_func); /* Allocate ref-counted string structure */ - if(NULL == (ret_value = H5FL_MALLOC(H5UC_t))) - HGOTO_ERROR(H5E_RS,H5E_NOSPACE,NULL,"memory allocation failed") + if (NULL == (ret_value = H5FL_MALLOC(H5UC_t))) + HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the internal fields */ - ret_value->o = o; - ret_value->n = 1; + ret_value->o = o; + ret_value->n = 1; ret_value->free_func = free_func; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5UC_create() */ - /*-------------------------------------------------------------------------- NAME H5UC_decr @@ -100,7 +97,7 @@ done: herr_t H5UC_decr(H5UC_t *rc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -114,8 +111,8 @@ H5UC_decr(H5UC_t *rc) rc->n--; /* Check if we should delete this object now */ - if(rc->n == 0) { - if((rc->free_func)(rc->o) < 0) { + if (rc->n == 0) { + if ((rc->free_func)(rc->o) < 0) { rc = H5FL_FREE(H5UC_t, rc); HGOTO_ERROR(H5E_RS, H5E_CANTFREE, FAIL, "memory release failed") } /* end if */ @@ -125,4 +122,3 @@ H5UC_decr(H5UC_t *rc) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5UC_decr() */ - diff --git a/src/H5UCprivate.h b/src/H5UCprivate.h index e4916df..2d6f40f 100644 --- a/src/H5UCprivate.h +++ b/src/H5UCprivate.h @@ -41,24 +41,22 @@ typedef herr_t (*H5UC_free_func_t)(void *o); /* Typedef for reference counted objects */ typedef struct H5UC_t { - void *o; /* Object to be reference counted */ - size_t n; /* Reference count of number of pointers sharing object */ + void * o; /* Object to be reference counted */ + size_t n; /* Reference count of number of pointers sharing object */ H5UC_free_func_t free_func; /* Function to free object */ } H5UC_t; /**********/ /* Macros */ /**********/ -#define H5UC_INC(rc) ((rc)->n++) -#define H5UC_DEC(rc) (H5UC_decr(rc)) -#define H5UC_GET_OBJ(rc) ((rc)->o) +#define H5UC_INC(rc) ((rc)->n++) +#define H5UC_DEC(rc) (H5UC_decr(rc)) +#define H5UC_GET_OBJ(rc) ((rc)->o) /********************/ /* Private routines */ /********************/ H5_DLL H5UC_t *H5UC_create(void *s, H5UC_free_func_t free_func); -H5_DLL herr_t H5UC_decr(H5UC_t *rc); +H5_DLL herr_t H5UC_decr(H5UC_t *rc); #endif /* _H5RSprivate_H */ - - diff --git a/src/H5VL.c b/src/H5VL.c index c4f38dd..d8c2435 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -21,55 +21,47 @@ /* Module Setup */ /****************/ -#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ - +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VLpkg.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLpkg.h" /* Virtual Object Layer */ /* VOL connectors */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5VLregister_connector * @@ -90,39 +82,44 @@ hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "*xi", cls, vipl_id); /* Check arguments */ if (!cls) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "VOL connector class pointer cannot be NULL") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "VOL connector class pointer cannot be NULL") if (!cls->name) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector class name cannot be the NULL pointer") + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + "VOL connector class name cannot be the NULL pointer") if (0 == HDstrlen(cls->name)) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector class name cannot be the empty string") + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + "VOL connector class name cannot be the empty string") if (cls->info_cls.copy && !cls->info_cls.free) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector must provide free callback for VOL info objects when a copy callback is provided") + HGOTO_ERROR( + H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + "VOL connector must provide free callback for VOL info objects when a copy callback is provided") if (cls->wrap_cls.get_wrap_ctx && !cls->wrap_cls.free_wrap_ctx) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector must provide free callback for object wrapping contexts when a get callback is provided") + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + "VOL connector must provide free callback for object wrapping contexts when a get " + "callback is provided") /* Check VOL initialization property list */ - if(H5P_DEFAULT == vipl_id) + if (H5P_DEFAULT == vipl_id) vipl_id = H5P_VOL_INITIALIZE_DEFAULT; - else - if(TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") + else if (TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") /* Register connector */ - if((ret_value = H5VL__register_connector(cls, TRUE, vipl_id)) < 0) + if ((ret_value = H5VL__register_connector(cls, TRUE, vipl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") done: FUNC_LEAVE_API(ret_value) } /* end H5VLregister_connector() */ - /*------------------------------------------------------------------------- * Function: H5VLregister_connector_by_name * @@ -143,7 +140,7 @@ done: hid_t H5VLregister_connector_by_name(const char *name, hid_t vipl_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "*si", name, vipl_id); @@ -152,24 +149,23 @@ H5VLregister_connector_by_name(const char *name, hid_t vipl_id) if (!name) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null VOL connector name is disallowed") if (0 == HDstrlen(name)) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "zero-length VOL connector name is disallowed") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "zero-length VOL connector name is disallowed") /* Check VOL initialization property list */ - if(H5P_DEFAULT == vipl_id) + if (H5P_DEFAULT == vipl_id) vipl_id = H5P_VOL_INITIALIZE_DEFAULT; - else - if(TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") + else if (TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") /* Register connector */ - if((ret_value = H5VL__register_connector_by_name(name, TRUE, vipl_id)) < 0) + if ((ret_value = H5VL__register_connector_by_name(name, TRUE, vipl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") done: FUNC_LEAVE_API(ret_value) } /* end H5VLregister_connector_by_name() */ - /*------------------------------------------------------------------------- * Function: H5VLregister_connector_by_value * @@ -190,31 +186,30 @@ done: hid_t H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "VCi", value, vipl_id); /* Check arguments */ - if(value < 0) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "negative VOL connector value is disallowed") + if (value < 0) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "negative VOL connector value is disallowed") /* Check VOL initialization property list */ - if(H5P_DEFAULT == vipl_id) + if (H5P_DEFAULT == vipl_id) vipl_id = H5P_VOL_INITIALIZE_DEFAULT; - else - if(TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") + else if (TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") /* Register connector */ - if((ret_value = H5VL__register_connector_by_value(value, TRUE, vipl_id)) < 0) + if ((ret_value = H5VL__register_connector_by_value(value, TRUE, vipl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") done: FUNC_LEAVE_API(ret_value) } /* end H5VLregister_connector_by_value() */ - /*------------------------------------------------------------------------- * Function: H5VLis_connector_registered_by_name * @@ -233,20 +228,19 @@ done: htri_t H5VLis_connector_registered_by_name(const char *name) { - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "*s", name); /* Check if connector with this name is registered */ - if((ret_value = H5VL__is_connector_registered_by_name(name)) < 0) + if ((ret_value = H5VL__is_connector_registered_by_name(name)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL") done: FUNC_LEAVE_API(ret_value) } /* end H5VLis_connector_registered_by_name() */ - /*------------------------------------------------------------------------- * Function: H5VLis_connector_registered_by_value * @@ -268,14 +262,13 @@ H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value) H5TRACE1("t", "VC", connector_value); /* Check if connector with this value is registered */ - if((ret_value = H5VL__is_connector_registered_by_value(connector_value)) < 0) + if ((ret_value = H5VL__is_connector_registered_by_value(connector_value)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL") done: FUNC_LEAVE_API(ret_value) } /* end H5VLis_connector_registered_by_value() */ - /*------------------------------------------------------------------------- * Function: H5VLget_connector_id * @@ -294,20 +287,19 @@ done: hid_t H5VLget_connector_id(hid_t obj_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", obj_id); /* Get connector ID */ - if((ret_value = H5VL__get_connector_id(obj_id, TRUE)) < 0) + if ((ret_value = H5VL__get_connector_id(obj_id, TRUE)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") done: FUNC_LEAVE_API(ret_value) } /* end H5VLget_connector_id() */ - /*------------------------------------------------------------------------- * Function: H5VLget_connector_id_by_name * @@ -328,20 +320,19 @@ done: hid_t H5VLget_connector_id_by_name(const char *name) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*s", name); /* Get connector ID with this name */ - if((ret_value = H5VL__get_connector_id_by_name(name, TRUE)) < 0) + if ((ret_value = H5VL__get_connector_id_by_name(name, TRUE)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") done: FUNC_LEAVE_API(ret_value) } /* end H5VLget_connector_id_by_name() */ - /*------------------------------------------------------------------------- * Function: H5VLget_connector_id_by_value * @@ -359,20 +350,19 @@ done: hid_t H5VLget_connector_id_by_value(H5VL_class_value_t connector_value) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "VC", connector_value); /* Get connector ID with this value */ - if((ret_value = H5VL__get_connector_id_by_value(connector_value, TRUE)) < 0) + if ((ret_value = H5VL__get_connector_id_by_value(connector_value, TRUE)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") done: FUNC_LEAVE_API(ret_value) } /* end H5VLget_connector_id_by_value() */ - /*------------------------------------------------------------------------- * Function: H5VLpeek_connector_id_by_name * @@ -391,20 +381,19 @@ done: hid_t H5VLpeek_connector_id_by_name(const char *name) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*s", name); /* Get connector ID with this name */ - if((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) + if ((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") done: FUNC_LEAVE_API(ret_value) } /* end H5VLpeek_connector_id_by_name() */ - /*------------------------------------------------------------------------- * Function: H5VLpeek_connector_id_by_value * @@ -423,20 +412,19 @@ done: hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "VC", value); /* Get connector ID with this value */ - if((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) + if ((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") done: FUNC_LEAVE_API(ret_value) } /* end H5VLpeek_connector_id_by_value() */ - /*------------------------------------------------------------------------- * Function: H5VLget_connector_name * @@ -455,22 +443,21 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5VLget_connector_name(hid_t obj_id, char *name/*out*/, size_t size) +H5VLget_connector_name(hid_t obj_id, char *name /*out*/, size_t size) { - ssize_t ret_value = -1; + ssize_t ret_value = -1; FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "ixz", obj_id, name, size); /* Call internal routine */ - if((ret_value = H5VL__get_connector_name(obj_id, name, size)) < 0) + if ((ret_value = H5VL__get_connector_name(obj_id, name, size)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get connector name") done: FUNC_LEAVE_API(ret_value) } /* end H5VLget_connector_name() */ - /*------------------------------------------------------------------------- * Function: H5VLclose * @@ -487,24 +474,23 @@ done: herr_t H5VLclose(hid_t vol_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", vol_id); /* Check args */ - if(NULL == H5I_object_verify(vol_id, H5I_VOL)) + if (NULL == H5I_object_verify(vol_id, H5I_VOL)) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector") /* Decrement the ref count on the ID, possibly releasing the VOL connector */ - if(H5I_dec_app_ref(vol_id) < 0) + if (H5I_dec_app_ref(vol_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to close VOL connector ID") done: FUNC_LEAVE_API(ret_value) } /* end H5VLclose() */ - /*------------------------------------------------------------------------- * Function: H5VLunregister_connector * @@ -525,35 +511,34 @@ done: herr_t H5VLunregister_connector(hid_t vol_id) { - hid_t native_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; /* Return value */ + hid_t native_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", vol_id); /* Check arguments */ - if(NULL == H5I_object_verify(vol_id, H5I_VOL)) + if (NULL == H5I_object_verify(vol_id, H5I_VOL)) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* For the time being, we disallow unregistering the native VOL connector */ - if(H5I_INVALID_HID == (native_id = H5VL__get_connector_id_by_name(H5VL_NATIVE_NAME, FALSE))) + if (H5I_INVALID_HID == (native_id = H5VL__get_connector_id_by_name(H5VL_NATIVE_NAME, FALSE))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to find the native VOL connector ID") - if(vol_id == native_id) + if (vol_id == native_id) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "unregistering the native VOL connector is not allowed") /* The H5VL_class_t struct will be freed by this function */ - if(H5I_dec_app_ref(vol_id) < 0) + if (H5I_dec_app_ref(vol_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector") done: - if(native_id != H5I_INVALID_HID) - if(H5I_dec_ref(native_id) < 0) + if (native_id != H5I_INVALID_HID) + if (H5I_dec_ref(native_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement count on native_id") FUNC_LEAVE_API(ret_value) } /* end H5VLunregister_connector() */ - /*--------------------------------------------------------------------------- * Function: H5VLcmp_connector_cls * @@ -571,27 +556,26 @@ done: herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2) { - H5VL_class_t *cls1, *cls2; /* connectors for IDs */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls1, *cls2; /* connectors for IDs */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*Isii", cmp, connector_id1, connector_id2); /* Check args and get class pointers */ - if(NULL == (cls1 = (H5VL_class_t *)H5I_object_verify(connector_id1, H5I_VOL))) + if (NULL == (cls1 = (H5VL_class_t *)H5I_object_verify(connector_id1, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") - if(NULL == (cls2 = (H5VL_class_t *)H5I_object_verify(connector_id2, H5I_VOL))) + if (NULL == (cls2 = (H5VL_class_t *)H5I_object_verify(connector_id2, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Compare the two VOL connector classes */ - if(H5VL_cmp_connector_cls(cmp, cls1, cls2) < 0) + if (H5VL_cmp_connector_cls(cmp, cls1, cls2) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") done: FUNC_LEAVE_API(ret_value) } /* H5VLcmp_connector_cls() */ - /*--------------------------------------------------------------------------- * Function: H5VLwrap_register * @@ -613,7 +597,7 @@ done: hid_t H5VLwrap_register(void *obj, H5I_type_t type) { - hid_t ret_value; /* Return value */ + hid_t ret_value; /* Return value */ /* Use FUNC_ENTER_API_NOINIT here, so the API context doesn't get reset */ FUNC_ENTER_API_NOINIT @@ -624,7 +608,7 @@ H5VLwrap_register(void *obj, H5I_type_t type) * equality checks. We could also group these types together in H5I_type_t, * make some assertions here to guarantee that, then just check the range. */ - switch(type) { + switch (type) { case H5I_FILE: case H5I_GROUP: case H5I_DATATYPE: @@ -648,18 +632,17 @@ H5VLwrap_register(void *obj, H5I_type_t type) default: HGOTO_ERROR(H5E_VOL, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") } /* end switch */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "obj is NULL") /* Wrap the object and register an ID for it */ - if((ret_value = H5VL_wrap_register(type, obj, TRUE)) < 0) + if ((ret_value = H5VL_wrap_register(type, obj, TRUE)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to wrap object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLwrap_register() */ - /*--------------------------------------------------------------------------- * Function: H5VLobject * @@ -677,20 +660,19 @@ done: void * H5VLobject(hid_t id) { - void *ret_value; /* Return value */ + void *ret_value; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE1("*x", "i", id); /* Retrieve the object pointer for the ID */ - if(NULL == (ret_value = H5VL_object(id))) + if (NULL == (ret_value = H5VL_object(id))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to retrieve object") done: FUNC_LEAVE_API(ret_value) } /* H5VLobject() */ - /*------------------------------------------------------------------------- * Function: H5VLget_file_type * @@ -704,41 +686,41 @@ done: hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id) { - H5T_t *dtype; /* unatomized type */ - H5T_t *file_type = NULL; /* copied file type */ - hid_t file_type_id = -1; /* copied file type id */ - H5VL_object_t *file_vol_obj = NULL; /* VOL object for file */ - hid_t ret_value = -1; /* Return value */ + H5T_t * dtype; /* unatomized type */ + H5T_t * file_type = NULL; /* copied file type */ + hid_t file_type_id = -1; /* copied file type id */ + H5VL_object_t *file_vol_obj = NULL; /* VOL object for file */ + hid_t ret_value = -1; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "*xii", file_obj, connector_id, dtype_id); /* Check args */ - if(!file_obj) + if (!file_obj) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "no file object supplied") - if(NULL == (dtype = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (NULL == (dtype = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") /* Create VOL object for file */ - if(NULL == (file_vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, file_obj, connector_id))) + if (NULL == (file_vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, file_obj, connector_id))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") /* Copy the datatype */ - if(NULL == (file_type = H5T_copy(dtype, H5T_COPY_TRANSIENT))) + if (NULL == (file_type = H5T_copy(dtype, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy datatype") /* Register file type id */ - if((file_type_id = H5I_register(H5I_DATATYPE, file_type, FALSE)) < 0) { + if ((file_type_id = H5I_register(H5I_DATATYPE, file_type, FALSE)) < 0) { (void)H5T_close_real(file_type); HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "unable to register file datatype") } /* end if */ /* Set the location of the datatype to be in the file */ - if(H5T_set_loc(file_type, file_vol_obj, H5T_LOC_DISK) < 0) + if (H5T_set_loc(file_type, file_vol_obj, H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't set datatype location") /* file_type now owns file_vol_obj */ - if(H5T_own_vol_obj(file_type, file_vol_obj) < 0) + if (H5T_own_vol_obj(file_type, file_vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't give ownership of VOL object") file_vol_obj = NULL; @@ -747,17 +729,16 @@ H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id) done: /* Cleanup on error */ - if(ret_value < 0) { - if(file_vol_obj && H5VL_free_object(file_vol_obj) < 0) + if (ret_value < 0) { + if (file_vol_obj && H5VL_free_object(file_vol_obj) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to free VOL object") - if(file_type_id >= 0 && H5I_dec_ref(file_type_id) < 0) + if (file_type_id >= 0 && H5I_dec_ref(file_type_id) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to close file datatype") } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5VLget_file_type() */ - /*--------------------------------------------------------------------------- * Function: H5VLretrieve_lib_state * @@ -785,18 +766,17 @@ H5VLretrieve_lib_state(void **state) H5TRACE1("e", "**x", state); /* Check args */ - if(NULL == state) + if (NULL == state) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid state pointer") /* Retrieve the library state */ - if(H5VL_retrieve_lib_state(state) < 0) + if (H5VL_retrieve_lib_state(state) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve library state") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLretrieve_lib_state() */ - /*--------------------------------------------------------------------------- * Function: H5VLrestore_lib_state * @@ -823,18 +803,17 @@ H5VLrestore_lib_state(const void *state) H5TRACE1("e", "*x", state); /* Check args */ - if(NULL == state) + if (NULL == state) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid state pointer") /* Restore the library state */ - if(H5VL_restore_lib_state(state) < 0) + if (H5VL_restore_lib_state(state) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't restore library state") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLrestore_lib_state() */ - /*--------------------------------------------------------------------------- * Function: H5VLreset_lib_state * @@ -866,14 +845,13 @@ H5VLreset_lib_state(void) H5TRACE0("e",""); /* Reset the library state */ - if(H5VL_reset_lib_state() < 0) + if (H5VL_reset_lib_state() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset library state") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLreset_lib_state() */ - /*--------------------------------------------------------------------------- * Function: H5VLfree_lib_state * @@ -902,18 +880,17 @@ H5VLfree_lib_state(void *state) H5TRACE1("e", "*x", state); /* Check args */ - if(NULL == state) + if (NULL == state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid state pointer") /* Free the library state */ - if(H5VL_free_lib_state(state) < 0) + if (H5VL_free_lib_state(state) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free library state") done: FUNC_LEAVE_API(ret_value) } /* H5VLfree_lib_state() */ - /*--------------------------------------------------------------------------- * Function: H5VLquery_optional * @@ -928,23 +905,22 @@ done: herr_t H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, hbool_t *supported) { - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iVSIs*b", obj_id, subcls, opt_type, supported); /* Check args */ - if(NULL == supported) + if (NULL == supported) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid supported pointer") - if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(obj_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Query the connector */ - if(H5VL_introspect_opt_query(vol_obj, subcls, opt_type, supported) < 0) + if (H5VL_introspect_opt_query(vol_obj, subcls, opt_type, supported) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to query VOL connector support") done: FUNC_LEAVE_API(ret_value) } /* H5VLquery_optional() */ - diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index 5c54b5b..5b7eb8d 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -17,203 +17,179 @@ * a specific file format, or remotely on other machines, etc... */ - /****************/ /* Module Setup */ /****************/ -#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ - +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLpkg.h" /* Virtual Object Layer */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLpkg.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static void *H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t space_id, - hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -static void *H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, const char *name, hid_t aapl_id, hid_t dxpl_id, - void **req); -static herr_t H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, - void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, - const void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, H5VL_attr_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); +static void * H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, + hid_t dxpl_id, void **req); +static void * H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, hid_t dxpl_id, + void **req); +static herr_t H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, + hid_t dxpl_id, void **req); +static herr_t H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); static herr_t H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_attr_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, - void **req); -static void *H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, const char *name, hid_t lcpl_id, hid_t type_id, - hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -static void *H5VL__dataset_open(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, const char *name, hid_t dapl_id, hid_t dxpl_id, - void **req); -static herr_t H5VL__dataset_read(void *dset, const H5VL_class_t *cls, - hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, - void *buf, void **req); -static herr_t H5VL__dataset_write(void *obj, const H5VL_class_t *cls, - hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, - const void *buf, void **req); + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static void * H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +static void * H5VL__dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__dataset_read(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, void *buf, void **req); +static herr_t H5VL__dataset_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req); static herr_t H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments); + hid_t dxpl_id, void **req, va_list arguments); static herr_t H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, - H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); + H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); static herr_t H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_dataset_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, - void **req); -static void * H5VL__datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t lcpl_id, - hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -static void *H5VL__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, const char *name, hid_t tapl_id, hid_t dxpl_id, - void **req); -static herr_t H5VL__datatype_get(void *obj, const H5VL_class_t *cls, - H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static void * H5VL__datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, + hid_t tapl_id, hid_t dxpl_id, void **req); +static void * H5VL__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); static herr_t H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, - H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments); -static herr_t H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, - H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, - void **req); -static void * H5VL__file_create(const H5VL_class_t *cls, const char *name, - unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -static void * H5VL__file_open(const H5VL_class_t *cls, const char *name, - unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__file_get(void *obj, const H5VL_class_t *cls, - H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__file_specific(void *obj, const H5VL_class_t *cls, - H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__file_optional(void *obj, const H5VL_class_t *cls, - H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, - void **req); -static void *H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, const char *name, hid_t lcpl_id, hid_t gcpl_id, - hid_t gapl_id, hid_t dxpl_id, void **req); -static void *H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, const char *name, hid_t gapl_id, hid_t dxpl_id, - void **req); -static herr_t H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__group_specific(void *obj, const H5VL_class_t *cls, - H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__group_optional(void *obj, const H5VL_class_t *cls, - H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__group_close(void *obj, const H5VL_class_t *cls, - hid_t dxpl_id, void **req); + H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_datatype_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static void * H5VL__file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id, void **req); +static void * H5VL__file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fapl_id, + hid_t dxpl_id, void **req); +static herr_t H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_file_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static void * H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +static void * H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_group_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__group_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); static herr_t H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, H5VL_link_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, H5VL_link_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL__link_optional(void *obj, const H5VL_class_t *cls, - H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); -static void *H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, - H5I_type_t *opened_type, hid_t dxpl_id, void **req); -static herr_t H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, - const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, - const char *dst_name, const H5VL_class_t *cls, hid_t ocpypl_id, - hid_t lcpl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, H5VL_object_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, H5VL_object_specific_t specific_type, hid_t dxpl_id, - void **req, va_list arguments); -static herr_t H5VL__object_optional(void *obj, const H5VL_class_t *cls, - H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__introspect_get_conn_cls(void *obj, const H5VL_class_t *cls, - H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); -static herr_t H5VL__introspect_opt_query(void *obj, const H5VL_class_t *cls, - H5VL_subclass_t subcls, int opt_type, hbool_t *supported); -static herr_t H5VL__request_wait(void *req, const H5VL_class_t *cls, - uint64_t timeout, H5ES_status_t *status); -static herr_t H5VL__request_notify(void *req, const H5VL_class_t *cls, - H5VL_request_notify_t cb, void *ctx); + const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__link_optional(void *obj, const H5VL_class_t *cls, H5VL_link_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static void * H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + const H5VL_class_t *cls, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__object_optional(void *obj, const H5VL_class_t *cls, H5VL_object_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__introspect_get_conn_cls(void *obj, const H5VL_class_t *cls, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +static herr_t H5VL__introspect_opt_query(void *obj, const H5VL_class_t *cls, H5VL_subclass_t subcls, + int opt_type, hbool_t *supported); +static herr_t H5VL__request_wait(void *req, const H5VL_class_t *cls, uint64_t timeout, H5ES_status_t *status); +static herr_t H5VL__request_notify(void *req, const H5VL_class_t *cls, H5VL_request_notify_t cb, void *ctx); static herr_t H5VL__request_cancel(void *req, const H5VL_class_t *cls); static herr_t H5VL__request_specific(void *req, const H5VL_class_t *cls, - H5VL_request_specific_t specific_type, va_list arguments); -static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls, - H5VL_request_optional_t opt_type, va_list arguments); + H5VL_request_specific_t specific_type, va_list arguments); +static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_request_optional_t opt_type, + va_list arguments); static herr_t H5VL__request_free(void *req, const H5VL_class_t *cls); -static herr_t H5VL__blob_put(void *obj, const H5VL_class_t *cls, - const void *buf, size_t size, void *blob_id, void *ctx); -static herr_t H5VL__blob_get(void *obj, const H5VL_class_t *cls, - const void *blob_id, void *buf, size_t size, void *ctx); -static herr_t H5VL__blob_specific(void *obj, const H5VL_class_t *cls, - void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); -static herr_t H5VL__blob_optional(void *obj, const H5VL_class_t *cls, - void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); -static herr_t H5VL__token_cmp(void *obj, const H5VL_class_t *cls, - const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); +static herr_t H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size, void *blob_id, + void *ctx); +static herr_t H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id, void *buf, size_t size, + void *ctx); +static herr_t H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, + H5VL_blob_specific_t specific_type, va_list arguments); +static herr_t H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, + H5VL_blob_optional_t opt_type, va_list arguments); +static herr_t H5VL__token_cmp(void *obj, const H5VL_class_t *cls, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value); static herr_t H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, - const H5O_token_t *token, char **token_str); + const H5O_token_t *token, char **token_str); static herr_t H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, - const char *token_str, H5O_token_t *token); -static herr_t H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, - hid_t dxpl_id, void **req, va_list arguments); + const char *token_str, H5O_token_t *token); +static herr_t H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, void **req, + va_list arguments); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5VLinitialize * @@ -227,25 +203,24 @@ static herr_t H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, herr_t H5VLinitialize(hid_t connector_id, hid_t vipl_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("e", "ii", connector_id, vipl_id); /* Check args */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Invoke class' callback, if there is one */ - if(cls->initialize && cls->initialize(vipl_id) < 0) + if (cls->initialize && cls->initialize(vipl_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not initialize") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLinitialize() */ - /*------------------------------------------------------------------------- * Function: H5VLterminate * @@ -259,25 +234,24 @@ done: herr_t H5VLterminate(hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE1("e", "i", connector_id); /* Check args */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Invoke class' callback, if there is one */ - if(cls->terminate && cls->terminate() < 0) + if (cls->terminate && cls->terminate() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLterminate() */ - /*--------------------------------------------------------------------------- * Function: H5VLget_cap_flags * @@ -291,25 +265,24 @@ done: herr_t H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("e", "i*Iu", connector_id, cap_flags); /* Check args */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Retrieve capability flags */ - if(cap_flags) + if (cap_flags) *cap_flags = cls->cap_flags; done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLget_cap_flags */ - /*--------------------------------------------------------------------------- * Function: H5VLget_value * @@ -323,25 +296,24 @@ done: herr_t H5VLget_value(hid_t connector_id, H5VL_class_value_t *value) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("e", "i*VC", connector_id, value); /* Check args */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Retrieve connector value */ - if(value) + if (value) *value = cls->value; done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLget_value */ - /*------------------------------------------------------------------------- * Function: H5VL_copy_connector_info * @@ -353,11 +325,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, - const void *src_info) +H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, const void *src_info) { - void *new_connector_info = NULL; /* Copy of connector info */ - herr_t ret_value = SUCCEED; /* Return value */ + void * new_connector_info = NULL; /* Copy of connector info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -365,14 +336,14 @@ H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, HDassert(connector); /* Check for actual source info */ - if(src_info) { + if (src_info) { /* Allow the connector to copy or do it ourselves */ - if(connector->info_cls.copy) { - if(NULL == (new_connector_info = (connector->info_cls.copy)(src_info))) + if (connector->info_cls.copy) { + if (NULL == (new_connector_info = (connector->info_cls.copy)(src_info))) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "connector info copy callback failed") } /* end if */ - else if(connector->info_cls.size > 0) { - if(NULL == (new_connector_info = H5MM_malloc(connector->info_cls.size))) + else if (connector->info_cls.size > 0) { + if (NULL == (new_connector_info = H5MM_malloc(connector->info_cls.size))) HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "connector info allocation failed") H5MM_memcpy(new_connector_info, src_info, connector->info_cls.size); } /* end else-if */ @@ -387,7 +358,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_copy_connector_info() */ - /*--------------------------------------------------------------------------- * Function: H5VLcopy_connector_info * @@ -401,25 +371,24 @@ done: herr_t H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE3("e", "i**x*x", connector_id, dst_vol_info, src_vol_info); /* Check args and get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Copy the VOL connector's info object */ - if(H5VL_copy_connector_info(cls, dst_vol_info, src_vol_info) < 0) + if (H5VL_copy_connector_info(cls, dst_vol_info, src_vol_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy VOL connector info object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLcopy_connector_info() */ - /*------------------------------------------------------------------------- * Function: H5VL_cmp_connector_info * @@ -434,10 +403,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, - const void *info1, const void *info2) +H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const void *info1, const void *info2) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -446,15 +414,15 @@ H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, HDassert(cmp_value); /* Take care of cases where one or both pointers is NULL */ - if(info1 == NULL && info2 != NULL) { + if (info1 == NULL && info2 != NULL) { *cmp_value = -1; HGOTO_DONE(SUCCEED); } /* end if */ - if(info1 != NULL && info2 == NULL) { + if (info1 != NULL && info2 == NULL) { *cmp_value = 1; HGOTO_DONE(SUCCEED); } /* end if */ - if(info1 == NULL && info2 == NULL) { + if (info1 == NULL && info2 == NULL) { *cmp_value = 0; HGOTO_DONE(SUCCEED); } /* end if */ @@ -463,8 +431,8 @@ H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, * if there is a a callback, otherwise just compare the info objects as * memory buffers */ - if(connector->info_cls.cmp) { - if((connector->info_cls.cmp)(cmp_value, info1, info2) < 0) + if (connector->info_cls.cmp) { + if ((connector->info_cls.cmp)(cmp_value, info1, info2) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector info") } /* end if */ else { @@ -476,7 +444,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_cmp_connector_info() */ - /*--------------------------------------------------------------------------- * Function: H5VLcmp_connector_info * @@ -495,25 +462,24 @@ done: herr_t H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, const void *info2) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "*Isi*x*x", cmp, connector_id, info1, info2); /* Check args and get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Compare the two VOL connector info objects */ - if(cmp) + if (cmp) H5VL_cmp_connector_info(cls, cmp, info1, info2); done: FUNC_LEAVE_API(ret_value) } /* H5VLcmp_connector_info() */ - /*------------------------------------------------------------------------- * Function: H5VL_free_connector_info * @@ -527,8 +493,8 @@ done: herr_t H5VL_free_connector_info(hid_t connector_id, const void *info) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -536,15 +502,15 @@ H5VL_free_connector_info(hid_t connector_id, const void *info) HDassert(connector_id > 0); /* Check args and get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Only free info object, if it's non-NULL */ - if(info) { + if (info) { /* Allow the connector to free info or do it ourselves */ - if(cls->info_cls.free) { + if (cls->info_cls.free) { /* Cast through uintptr_t to de-const memory */ - if((cls->info_cls.free)((void *)(uintptr_t)info) < 0) + if ((cls->info_cls.free)((void *)(uintptr_t)info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector info free request failed") } else @@ -555,7 +521,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_free_connector_info() */ - /*--------------------------------------------------------------------------- * Function: H5VLfree_connector_info * @@ -569,20 +534,19 @@ done: herr_t H5VLfree_connector_info(hid_t connector_id, void *info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("e", "i*x", connector_id, info); /* Free the VOL connector info object */ - if(H5VL_free_connector_info(connector_id, info) < 0) + if (H5VL_free_connector_info(connector_id, info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLfree_connector_info() */ - /*--------------------------------------------------------------------------- * Function: H5VLconnector_info_to_str * @@ -596,22 +560,22 @@ done: herr_t H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE3("e", "*xi**s", info, connector_id, str); /* Only serialize info object, if it's non-NULL */ - if(info) { - H5VL_class_t *cls; /* VOL connector's class struct */ + if (info) { + H5VL_class_t *cls; /* VOL connector's class struct */ /* Check args and get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Allow the connector to serialize info */ - if(cls->info_cls.to_str) { - if((cls->info_cls.to_str)(info, str) < 0) + if (cls->info_cls.to_str) { + if ((cls->info_cls.to_str)(info, str) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "can't serialize connector info") } /* end if */ else @@ -624,7 +588,6 @@ done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLconnector_info_to_str() */ - /*--------------------------------------------------------------------------- * Function: H5VLconnector_str_to_info * @@ -638,20 +601,19 @@ done: herr_t H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE3("e", "*si**x", str, connector_id, info); /* Call internal routine */ - if(H5VL__connector_str_to_info(str, connector_id, info) < 0) + if (H5VL__connector_str_to_info(str, connector_id, info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLconnector_str_to_info() */ - /*--------------------------------------------------------------------------- * Function: H5VLget_object * @@ -665,20 +627,20 @@ done: void * H5VLget_object(void *obj, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("*x", "*xi", obj, connector_id); /* Check args */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Check for 'get_object' callback in connector */ - if(cls->wrap_cls.get_object) + if (cls->wrap_cls.get_object) ret_value = (cls->wrap_cls.get_object)(obj); else ret_value = obj; @@ -687,7 +649,6 @@ done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLget_object */ - /*------------------------------------------------------------------------- * Function: H5VL_get_wrap_ctx * @@ -701,7 +662,7 @@ done: herr_t H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -711,12 +672,12 @@ H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx) HDassert(wrap_ctx); /* Allow the connector to copy or do it ourselves */ - if(connector->wrap_cls.get_wrap_ctx) { + if (connector->wrap_cls.get_wrap_ctx) { /* Sanity check */ HDassert(connector->wrap_cls.free_wrap_ctx); /* Invoke connector's callback */ - if((connector->wrap_cls.get_wrap_ctx)(obj, wrap_ctx) < 0) + if ((connector->wrap_cls.get_wrap_ctx)(obj, wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "connector wrap context callback failed") } /* end if */ else @@ -726,7 +687,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_get_wrap_ctx() */ - /*--------------------------------------------------------------------------- * Function: H5VLget_wrap_ctx * @@ -740,25 +700,24 @@ done: herr_t H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE3("e", "*xi**x", obj, connector_id, wrap_ctx); /* Check args and get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Get the VOL connector's object wrapper */ - if(H5VL_get_wrap_ctx(cls, obj, wrap_ctx) < 0) + if (H5VL_get_wrap_ctx(cls, obj, wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to retrieve VOL connector object wrap context") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLget_wrap_ctx() */ - /*------------------------------------------------------------------------- * Function: H5VL_wrap_object * @@ -770,10 +729,9 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, - H5I_type_t obj_type) +H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, H5I_type_t obj_type) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -782,9 +740,9 @@ H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, HDassert(obj); /* Only wrap object if there's a wrap context */ - if(wrap_ctx) { + if (wrap_ctx) { /* Ask the connector to wrap the object */ - if(NULL == (ret_value = (connector->wrap_cls.wrap_object)(obj, obj_type, wrap_ctx))) + if (NULL == (ret_value = (connector->wrap_cls.wrap_object)(obj, obj_type, wrap_ctx))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object") } /* end if */ else @@ -794,7 +752,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_wrap_object() */ - /*--------------------------------------------------------------------------- * Function: H5VLwrap_object * @@ -808,27 +765,26 @@ done: void * H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("*x", "*xIti*x", obj, obj_type, connector_id, wrap_ctx); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Wrap the object */ - if(NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj, obj_type))) + if (NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj, obj_type))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLwrap_object */ - /*------------------------------------------------------------------------- * Function: H5VL_unwrap_object * @@ -842,7 +798,7 @@ done: void * H5VL_unwrap_object(const H5VL_class_t *connector, void *obj) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -851,9 +807,9 @@ H5VL_unwrap_object(const H5VL_class_t *connector, void *obj) HDassert(obj); /* Only unwrap object if there's an unwrap callback */ - if(connector->wrap_cls.wrap_object) { + if (connector->wrap_cls.wrap_object) { /* Ask the connector to unwrap the object */ - if(NULL == (ret_value = (connector->wrap_cls.unwrap_object)(obj))) + if (NULL == (ret_value = (connector->wrap_cls.unwrap_object)(obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't unwrap object") } /* end if */ else @@ -863,7 +819,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_unwrap_object() */ - /*--------------------------------------------------------------------------- * Function: H5VLunwrap_object * @@ -877,27 +832,26 @@ done: void * H5VLunwrap_object(void *obj, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("*x", "*xi", obj, connector_id); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Unwrap the object */ - if(NULL == (ret_value = H5VL_unwrap_object(cls, obj))) + if (NULL == (ret_value = H5VL_unwrap_object(cls, obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to unwrap object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLunwrap_object */ - /*------------------------------------------------------------------------- * Function: H5VL_free_wrap_ctx * @@ -911,7 +865,7 @@ done: herr_t H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -919,9 +873,9 @@ H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx) HDassert(connector); /* Only free wrap context, if it's non-NULL */ - if(wrap_ctx) { + if (wrap_ctx) { /* Free the connector's object wrapping context */ - if((connector->wrap_cls.free_wrap_ctx)(wrap_ctx) < 0) + if ((connector->wrap_cls.free_wrap_ctx)(wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed") } /* end if */ @@ -929,7 +883,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_free_wrap_ctx() */ - /*--------------------------------------------------------------------------- * Function: H5VLfree_wrap_ctx * @@ -943,25 +896,24 @@ done: herr_t H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("e", "*xi", wrap_ctx, connector_id); /* Check args and get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Release the VOL connector's object wrapper */ - if(H5VL_free_wrap_ctx(cls, wrap_ctx) < 0) + if (H5VL_free_wrap_ctx(cls, wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLfree_wrap_ctx() */ - /*------------------------------------------------------------------------- * Function: H5VL__attr_create * @@ -973,27 +925,26 @@ done: *------------------------------------------------------------------------- */ static void * -H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, - hid_t aapl_id, hid_t dxpl_id, void **req) +H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->attr_cls.create) + if (NULL == cls->attr_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'attr create' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->attr_cls.create)(obj, loc_params, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->attr_cls.create)(obj, loc_params, name, type_id, space_id, acpl_id, + aapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "attribute create failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__attr_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_attr_create * @@ -1005,33 +956,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, - hid_t aapl_id, hid_t dxpl_id, void **req) +H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__attr_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__attr_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, + type_id, space_id, acpl_id, aapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "attribute create failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_create() */ - /*------------------------------------------------------------------------- * Function: H5VLattr_create * @@ -1043,32 +993,31 @@ done: *------------------------------------------------------------------------- */ void * -H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, - hid_t aapl_id, hid_t dxpl_id, void **req) +H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE10("*x", "*x*xi*siiiii**x", obj, loc_params, connector_id, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__attr_create(obj, loc_params, cls, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__attr_create(obj, loc_params, cls, name, type_id, space_id, acpl_id, + aapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create attribute") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__attr_open * @@ -1081,25 +1030,24 @@ done: */ static void * H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, - hid_t aapl_id, hid_t dxpl_id, void **req) + hid_t aapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->attr_cls.open) + if (NULL == cls->attr_cls.open) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'attr open' method") /* Call the corresponding VOL open callback */ - if(NULL == (ret_value = (cls->attr_cls.open)(obj, loc_params, name, aapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->attr_cls.open)(obj, loc_params, name, aapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__attr_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_attr_open * @@ -1111,32 +1059,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t aapl_id, hid_t dxpl_id, void **req) +H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__attr_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, aapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__attr_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, + aapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_open() */ - /*------------------------------------------------------------------------- * Function: H5VLattr_open * @@ -1148,31 +1096,30 @@ done: *------------------------------------------------------------------------- */ void * -H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - const char *name, hid_t aapl_id, hid_t dxpl_id, void **req) +H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, aapl_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__attr_open(obj, loc_params, cls, name, aapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__attr_open(obj, loc_params, cls, name, aapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open attribute") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__attr_read * @@ -1184,26 +1131,24 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, - hid_t dxpl_id, void **req) +H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->attr_cls.read) + if (NULL == cls->attr_cls.read) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr read' method") /* Call the corresponding VOL callback */ - if((cls->attr_cls.read)(obj, mem_type_id, buf, dxpl_id, req) < 0) + if ((cls->attr_cls.read)(obj, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "attribute read failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__attr_read() */ - /*------------------------------------------------------------------------- * Function: H5VL_attr_read * @@ -1215,32 +1160,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, void *buf, - hid_t dxpl_id, void **req) +H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__attr_read(vol_obj->data, vol_obj->connector->cls, mem_type_id, buf, dxpl_id, req) < 0) + if (H5VL__attr_read(vol_obj->data, vol_obj->connector->cls, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "attribute read failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_read() */ - /*------------------------------------------------------------------------- * Function: H5VLattr_read * @@ -1254,27 +1197,26 @@ done: herr_t H5VLattr_read(void *obj, hid_t connector_id, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xii*xi**x", obj, connector_id, mem_type_id, buf, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__attr_read(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) + if (H5VL__attr_read(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read attribute") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_read() */ - /*------------------------------------------------------------------------- * Function: H5VL__attr_write * @@ -1286,26 +1228,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, - hid_t dxpl_id, void **req) +H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, hid_t dxpl_id, + void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->attr_cls.write) + if (NULL == cls->attr_cls.write) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr write' method") /* Call the corresponding VOL callback */ - if((cls->attr_cls.write)(obj, mem_type_id, buf, dxpl_id, req) < 0) + if ((cls->attr_cls.write)(obj, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__attr_write() */ - /*------------------------------------------------------------------------- * Function: H5VL_attr_write * @@ -1317,32 +1258,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, const void *buf, - hid_t dxpl_id, void **req) +H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__attr_write(vol_obj->data, vol_obj->connector->cls, mem_type_id, buf, dxpl_id, req) < 0) + if (H5VL__attr_write(vol_obj->data, vol_obj->connector->cls, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_write() */ - /*------------------------------------------------------------------------- * Function: H5VLattr_write * @@ -1354,30 +1293,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLattr_write(void *obj, hid_t connector_id, hid_t mem_type_id, const void *buf, - hid_t dxpl_id, void **req) +H5VLattr_write(void *obj, hid_t connector_id, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xii*xi**x", obj, connector_id, mem_type_id, buf, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__attr_write(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) + if (H5VL__attr_write(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write attribute") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_write() */ - /*------------------------------------------------------------------------- * Function: H5VL__attr_get * @@ -1389,26 +1326,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->attr_cls.get) + if (NULL == cls->attr_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr get' method") /* Call the corresponding VOL callback */ - if((cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__attr_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_attr_get * @@ -1420,40 +1356,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, - hid_t dxpl_id, void **req, ...) +H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__attr_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__attr_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_get() */ - /*------------------------------------------------------------------------- * Function: H5VLattr_get * @@ -1465,31 +1399,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVai**xx", obj, connector_id, get_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__attr_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__attr_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get attribute information") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__attr_specific * @@ -1502,26 +1435,24 @@ done: */ static herr_t H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments) + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->attr_cls.specific) + if (NULL == cls->attr_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr specific' method") /* Call the corresponding VOL callback */ - if((ret_value = (cls->attr_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = (cls->attr_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__attr_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_attr_specific * @@ -1534,39 +1465,39 @@ done: */ herr_t H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...) + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if((ret_value = H5VL__attr_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__attr_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, + dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLattr_specific * @@ -1579,30 +1510,29 @@ done: */ herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("e", "*x*xiVbi**xx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__attr_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__attr_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__attr_optional * @@ -1614,26 +1544,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_attr_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_attr_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->attr_cls.optional) + if (NULL == cls->attr_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr optional' method") /* Call the corresponding VOL callback */ - if((ret_value = (cls->attr_cls.optional)(obj, opt_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = (cls->attr_cls.optional)(obj, opt_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__attr_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_attr_optional * @@ -1645,40 +1574,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, - hid_t dxpl_id, void **req, ...) +H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if((ret_value = H5VL__attr_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__attr_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, + arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLattr_optional * @@ -1690,31 +1619,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVsi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__attr_optional(obj, cls, opt_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__attr_optional(obj, cls, opt_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__attr_close * @@ -1728,23 +1656,22 @@ done: static herr_t H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->attr_cls.close) + if (NULL == cls->attr_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr close' method") /* Call the corresponding VOL callback */ - if((cls->attr_cls.close)(obj, dxpl_id, req) < 0) + if ((cls->attr_cls.close)(obj, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "attribute close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__attr_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_attr_close * @@ -1758,7 +1685,7 @@ done: herr_t H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1766,14 +1693,13 @@ H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) HDassert(vol_obj); /* Call the corresponding internal VOL routine */ - if(H5VL__attr_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + if (H5VL__attr_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "attribute close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_close() */ - /*------------------------------------------------------------------------- * Function: H5VLattr_close * @@ -1787,27 +1713,26 @@ done: herr_t H5VLattr_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__attr_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__attr_close(obj, cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close attribute") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLattr_close() */ - /*------------------------------------------------------------------------- * Function: H5VL__dataset_create * @@ -1820,26 +1745,26 @@ done: */ static void * H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, - hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, + hid_t dapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->dataset_cls.create) + if (NULL == cls->dataset_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'dataset create' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->dataset_cls.create)(obj, loc_params, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->dataset_cls.create)(obj, loc_params, name, lcpl_id, type_id, space_id, + dcpl_id, dapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "dataset create failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__dataset_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_dataset_create * @@ -1851,33 +1776,34 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, - hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, + void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__dataset_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req))) + if (NULL == + (ret_value = H5VL__dataset_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, lcpl_id, + type_id, space_id, dcpl_id, dapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "dataset create failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_create() */ - /*------------------------------------------------------------------------- * Function: H5VLdataset_create * @@ -1889,32 +1815,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, - hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, + void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE11("*x", "*x*xi*siiiiii**x", obj, loc_params, connector_id, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__dataset_create(obj, loc_params, cls, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__dataset_create(obj, loc_params, cls, name, lcpl_id, type_id, space_id, + dcpl_id, dapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create dataset") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdataset_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__dataset_open * @@ -1927,25 +1853,24 @@ done: */ static void * H5VL__dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, - hid_t dapl_id, hid_t dxpl_id, void **req) + hid_t dapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->dataset_cls.open) + if (NULL == cls->dataset_cls.open) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'dataset open' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->dataset_cls.open)(obj, loc_params, name, dapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->dataset_cls.open)(obj, loc_params, name, dapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "dataset open failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__dataset_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_dataset_open * @@ -1957,32 +1882,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t dapl_id, hid_t dxpl_id, void **req) +H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__dataset_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, dapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__dataset_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, + dapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "dataset open failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_open() */ - /*------------------------------------------------------------------------- * Function: H5VLdataset_open * @@ -1994,101 +1919,97 @@ done: *------------------------------------------------------------------------- */ void * -H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - const char *name, hid_t dapl_id, hid_t dxpl_id, void **req) +H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, dapl_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__dataset_open(obj, loc_params, cls, name, dapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__dataset_open(obj, loc_params, cls, name, dapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open dataset") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdataset_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__dataset_read * * Purpose: Reads data from dataset through the VOL -* + * * Return: Success: Non-negative * Failure: Negative * *------------------------------------------------------------------------- */ static herr_t -H5VL__dataset_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, - hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, void *buf, - void **req) +H5VL__dataset_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, void *buf, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->dataset_cls.read) + if (NULL == cls->dataset_cls.read) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset read' method") /* Call the corresponding VOL callback */ - if((cls->dataset_cls.read)(obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + if ((cls->dataset_cls.read)(obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "dataset read failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__dataset_read() */ - /*------------------------------------------------------------------------- * Function: H5VL_dataset_read * * Purpose: Reads data from dataset through the VOL -* + * * Return: Success: Non-negative * Failure: Negative * *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, - hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, void *buf, - void **req) +H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, void *buf, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_read(vol_obj->data, vol_obj->connector->cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + if (H5VL__dataset_read(vol_obj->data, vol_obj->connector->cls, mem_type_id, mem_space_id, file_space_id, + dxpl_id, buf, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "dataset read failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_read() */ - /*------------------------------------------------------------------------- * Function: H5VLdataset_read * @@ -2100,31 +2021,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdataset_read(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t dxpl_id, void *buf, void **req) +H5VLdataset_read(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, void *buf, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE8("e", "*xiiiii*x**x", obj, connector_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_read(obj, cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + if (H5VL__dataset_read(obj, cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read dataset") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdataset_read() */ - /*------------------------------------------------------------------------- * Function: H5VL__dataset_write * @@ -2136,27 +2056,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__dataset_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, - hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf, - void **req) +H5VL__dataset_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->dataset_cls.write) + if (NULL == cls->dataset_cls.write) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset write' method") /* Call the corresponding VOL callback */ - if((cls->dataset_cls.write)(obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + if ((cls->dataset_cls.write)(obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "dataset write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__dataset_write() */ - /*------------------------------------------------------------------------- * Function: H5VL_dataset_write * @@ -2168,33 +2086,32 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, - hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf, - void **req) +H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, const void *buf, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_write(vol_obj->data, vol_obj->connector->cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + if (H5VL__dataset_write(vol_obj->data, vol_obj->connector->cls, mem_type_id, mem_space_id, file_space_id, + dxpl_id, buf, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "dataset write failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_write() */ - /*------------------------------------------------------------------------- * Function: H5VLdataset_write * @@ -2206,31 +2123,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdataset_write(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req) +H5VLdataset_write(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, const void *buf, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE8("e", "*xiiiii*x**x", obj, connector_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_write(obj, cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + if (H5VL__dataset_write(obj, cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write dataset") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdataset_write() */ - /*------------------------------------------------------------------------- * Function: H5VL__dataset_get * @@ -2242,26 +2158,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->dataset_cls.get) + if (NULL == cls->dataset_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset get' method") /* Call the corresponding VOL callback */ - if((cls->dataset_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->dataset_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__dataset_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_dataset_get * @@ -2273,40 +2188,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, - hid_t dxpl_id, void **req, ...) +H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__dataset_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_get() */ - /*------------------------------------------------------------------------- * Function: H5VLdataset_get * @@ -2318,31 +2231,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVci**xx", obj, connector_id, get_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute dataset get callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdataset_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__dataset_specific * @@ -2355,25 +2267,24 @@ done: */ static herr_t H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) + hid_t dxpl_id, void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->dataset_cls.specific) + if (NULL == cls->dataset_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset specific' method") /* Call the corresponding VOL callback */ - if((cls->dataset_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if ((cls->dataset_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__dataset_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_dataset_specific * @@ -2385,40 +2296,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, ...) +H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, + void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__dataset_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, + arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLdataset_specific * @@ -2430,31 +2341,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVdi**xx", obj, connector_id, specific_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdataset_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__dataset_optional * @@ -2466,26 +2376,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_dataset_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->dataset_cls.optional) + if (NULL == cls->dataset_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset optional' method") /* Call the corresponding VOL callback */ - if((cls->dataset_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->dataset_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__dataset_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_dataset_optional * @@ -2497,40 +2406,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_type, - hid_t dxpl_id, void **req, ...) +H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__dataset_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLdataset_optional * @@ -2542,31 +2450,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVti**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__dataset_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdataset_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__dataset_close * @@ -2580,7 +2487,7 @@ done: static herr_t H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2589,18 +2496,17 @@ H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **re HDassert(cls); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->dataset_cls.close) + if (NULL == cls->dataset_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset close' method") /* Call the corresponding VOL callback */ - if((cls->dataset_cls.close)(obj, dxpl_id, req) < 0) + if ((cls->dataset_cls.close)(obj, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "dataset close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__dataset_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_dataset_close * @@ -2614,8 +2520,8 @@ done: herr_t H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2626,23 +2532,22 @@ H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) HDassert(vol_obj->connector->cls); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + if (H5VL__dataset_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "dataset close failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_close() */ - /*------------------------------------------------------------------------- * Function: H5VLdataset_close * @@ -2656,27 +2561,26 @@ done: herr_t H5VLdataset_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__dataset_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__dataset_close(obj, cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close dataset") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdataset_close() */ - /*------------------------------------------------------------------------- * Function: H5VL__datatype_commit * @@ -2689,26 +2593,26 @@ done: */ static void * H5VL__datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, - hid_t dxpl_id, void **req) + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, + hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.commit) + if (NULL == cls->datatype_cls.commit) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'datatype commit' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->datatype_cls.commit)(obj, loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->datatype_cls.commit)(obj, loc_params, name, type_id, lcpl_id, tcpl_id, + tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "datatype commit failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__datatype_commit() */ - /*------------------------------------------------------------------------- * Function: H5VL_datatype_commit * @@ -2720,33 +2624,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_datatype_commit(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, - hid_t dxpl_id, void **req) +H5VL_datatype_commit(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__datatype_commit(vol_obj->data, loc_params, vol_obj->connector->cls, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__datatype_commit(vol_obj->data, loc_params, vol_obj->connector->cls, name, + type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "datatype commit failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_commit() */ - /*------------------------------------------------------------------------- * Function: H5VLdatatype_commit * @@ -2758,32 +2661,31 @@ done: *------------------------------------------------------------------------- */ void * -H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, - hid_t tapl_id, hid_t dxpl_id, void **req) +H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE10("*x", "*x*xi*siiiii**x", obj, loc_params, connector_id, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__datatype_commit(obj, loc_params, cls, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__datatype_commit(obj, loc_params, cls, name, type_id, lcpl_id, tcpl_id, + tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to commit datatype") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdatatype_commit() */ - /*------------------------------------------------------------------------- * Function: H5VL__datatype_open * @@ -2795,26 +2697,25 @@ done: *------------------------------------------------------------------------- */ static void * -H5VL__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +H5VL__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.open) + if (NULL == cls->datatype_cls.open) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "no datatype open callback") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->datatype_cls.open)(obj, loc_params, name, tapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->datatype_cls.open)(obj, loc_params, name, tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "datatype open failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__datatype_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_datatype_open * @@ -2826,32 +2727,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__datatype_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, tapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__datatype_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, + tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "datatype open failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_open() */ - /*------------------------------------------------------------------------- * Function: H5VLdatatype_open * @@ -2863,31 +2764,30 @@ done: *------------------------------------------------------------------------- */ void * -H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, tapl_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__datatype_open(obj, loc_params, cls, name, tapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__datatype_open(obj, loc_params, cls, name, tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open datatype") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdatatype_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__datatype_get * @@ -2899,26 +2799,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.get) + if (NULL == cls->datatype_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype get' method") /* Call the corresponding VOL callback */ - if((cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__datatype_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_datatype_get * @@ -2930,40 +2829,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, - hid_t dxpl_id, void **req, ...) +H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__datatype_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_get() */ - /*------------------------------------------------------------------------- * Function: H5VLdatatype_get * @@ -2975,35 +2872,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVei**xx", obj, connector_id, get_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.get) + if (NULL == cls->datatype_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no `datatype get' method") /* Call the corresponding internal VOL routine */ - if(H5VL__datatype_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute datatype get callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdatatype_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__datatype_specific * @@ -3016,25 +2912,24 @@ done: */ static herr_t H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) + hid_t dxpl_id, void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.specific) + if (NULL == cls->datatype_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype specific' method") /* Call the corresponding VOL callback */ - if((cls->datatype_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if ((cls->datatype_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__datatype_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_datatype_specific * @@ -3046,40 +2941,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, ...) +H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, + void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__datatype_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, + arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLdatatype_specific * @@ -3091,31 +2986,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVfi**xx", obj, connector_id, specific_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__datatype_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdatatype_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__datatype_optional * @@ -3127,26 +3021,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_datatype_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.optional) + if (NULL == cls->datatype_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype optional' method") /* Call the corresponding VOL callback */ - if((cls->datatype_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->datatype_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__datatype_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_datatype_optional * @@ -3158,40 +3051,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t opt_type, - hid_t dxpl_id, void **req, ...) +H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, + void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__datatype_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < + 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLdatatype_optional * @@ -3203,31 +3096,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVui**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__datatype_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__datatype_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdatatype_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__datatype_close * @@ -3239,26 +3131,24 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, - void **req) +H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.close) + if (NULL == cls->datatype_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype close' method") /* Call the corresponding VOL callback */ - if((cls->datatype_cls.close)(obj, dxpl_id, req) < 0) + if ((cls->datatype_cls.close)(obj, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "datatype close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__datatype_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_datatype_close * @@ -3272,29 +3162,28 @@ done: herr_t H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__datatype_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + if (H5VL__datatype_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "datatype close failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_close() */ - /*------------------------------------------------------------------------- * Function: H5VLdatatype_close * @@ -3308,27 +3197,26 @@ done: herr_t H5VLdatatype_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__datatype_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__datatype_close(obj, cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close datatype") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLdatatype_close() */ - /*------------------------------------------------------------------------- * Function: H5VL__file_create * @@ -3343,26 +3231,25 @@ done: *------------------------------------------------------------------------- */ static void * -H5VL__file_create(const H5VL_class_t *cls, const char *name, - unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) +H5VL__file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->file_cls.create) + if (NULL == cls->file_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'file create' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->file_cls.create)(name, flags, fcpl_id, fapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->file_cls.create)(name, flags, fcpl_id, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__file_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_file_create * @@ -3377,27 +3264,26 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, - unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) +H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL Class structure for callback info */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL Class structure for callback info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Get the connector's class */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_create() */ - /*------------------------------------------------------------------------- * Function: H5VLfile_create * @@ -3409,36 +3295,34 @@ done: *------------------------------------------------------------------------- */ void * -H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, - hid_t dxpl_id, void **req) +H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) { - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_class_t * cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("*x", "*sIuiii**x", name, flags, fcpl_id, fapl_id, dxpl_id, req); /* Get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info") /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create file") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLfile_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__file_open * @@ -3450,26 +3334,25 @@ done: *------------------------------------------------------------------------- */ static void * -H5VL__file_open(const H5VL_class_t *cls, const char *name, unsigned flags, - hid_t fapl_id, hid_t dxpl_id, void **req) +H5VL__file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, + void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->file_cls.open) + if (NULL == cls->file_cls.open) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'file open' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->file_cls.open)(name, flags, fapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->file_cls.open)(name, flags, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__file_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_file_open * @@ -3484,27 +3367,26 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_file_open(const H5VL_connector_prop_t *connector_prop, const char *name, - unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) +H5VL_file_open(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fapl_id, + hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL Class structure for callback info */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL Class structure for callback info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Get the connector's class */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_open() */ - /*------------------------------------------------------------------------- * Function: H5VLfile_open * @@ -3516,36 +3398,34 @@ done: *------------------------------------------------------------------------- */ void * -H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, - void **req) +H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) { - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_class_t * cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE5("*x", "*sIuii**x", name, flags, fapl_id, dxpl_id, req); /* Get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info") /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open file") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLfile_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__file_get * @@ -3557,26 +3437,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->file_cls.get) + if (NULL == cls->file_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file get' method") /* Call the corresponding VOL callback */ - if((cls->file_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->file_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__file_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_file_get * @@ -3588,40 +3467,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, - hid_t dxpl_id, void **req, ...) +H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__file_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_get() */ - /*------------------------------------------------------------------------- * Function: H5VLfile_get * @@ -3633,31 +3510,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVgi**xx", obj, connector_id, get_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__file_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute file get callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLfile_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__file_specific * @@ -3669,26 +3545,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->file_cls.specific) + if (NULL == cls->file_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file specific' method") /* Call the corresponding VOL callback */ - if((cls->file_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if ((cls->file_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__file_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_file_specific * @@ -3700,14 +3575,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, ...) +H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, ...) { - const H5VL_class_t *cls; /* VOL connector's class struct */ - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5VL_class_t *cls; /* VOL connector's class struct */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3717,11 +3592,11 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t /* Special treatment of file access check & delete operations */ /* (Retrieve the VOL connector from the FAPL, since the file isn't open) */ - if(specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) { - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - va_list tmp_args; /* argument list passed from the API call */ - hid_t fapl_id; /* File access property list for accessing the file */ + if (specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) { + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + va_list tmp_args; /* argument list passed from the API call */ + hid_t fapl_id; /* File access property list for accessing the file */ /* Get the file access property list to access the file */ HDva_copy(tmp_args, arguments); @@ -3729,13 +3604,13 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t HDva_end(tmp_args); /* Get the VOL info from the FAPL */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector info") /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") } /* end if */ /* Set wrapper info in API context, for all other operations */ @@ -3743,7 +3618,7 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t /* Sanity check */ HDassert(vol_obj); - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; @@ -3752,22 +3627,21 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_t } /* end else */ /* Call the corresponding internal VOL routine */ - if(H5VL__file_specific(vol_obj ? vol_obj->data : NULL, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_specific(vol_obj ? vol_obj->data : NULL, cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLfile_specific * @@ -3781,29 +3655,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVhi**xx", obj, connector_id, specific_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__file_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file specific callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLfile_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__file_optional * @@ -3815,26 +3688,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_file_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_file_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->file_cls.optional) + if (NULL == cls->file_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file optional' method") /* Call the corresponding VOL callback */ - if((cls->file_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->file_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__file_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_file_optional * @@ -3846,40 +3718,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, - hid_t dxpl_id, void **req, ...) +H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__file_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLfile_optional * @@ -3891,31 +3762,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVvi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__file_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__file_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLfile_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__file_close * @@ -3929,7 +3799,7 @@ done: static herr_t H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3938,18 +3808,17 @@ H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) HDassert(cls); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->file_cls.close) + if (NULL == cls->file_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file close' method") /* Call the corresponding VOL callback */ - if((cls->file_cls.close)(obj, dxpl_id, req) < 0) + if ((cls->file_cls.close)(obj, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "file close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__file_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_file_close * @@ -3963,29 +3832,28 @@ done: herr_t H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__file_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + if (H5VL__file_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "file close failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_close() */ - /*------------------------------------------------------------------------- * Function: H5VLfile_close * @@ -3999,27 +3867,26 @@ done: herr_t H5VLfile_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__file_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__file_close(obj, cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLfile_close() */ - /*------------------------------------------------------------------------- * Function: H5VL__group_create * @@ -4031,27 +3898,26 @@ done: *------------------------------------------------------------------------- */ static void * -H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, - hid_t dxpl_id, void **req) +H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->group_cls.create) + if (NULL == cls->group_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'group create' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->group_cls.create)(obj, loc_params, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) + if (NULL == + (ret_value = (cls->group_cls.create)(obj, loc_params, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "group create failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__group_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_group_create * @@ -4063,33 +3929,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, - void **req) +H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__group_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__group_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, + lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "group create failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_create() */ - /*------------------------------------------------------------------------- * Function: H5VLgroup_create * @@ -4101,32 +3966,31 @@ done: *------------------------------------------------------------------------- */ void * -H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id,hid_t dxpl_id, - void **req) +H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE9("*x", "*x*xi*siiii**x", obj, loc_params, connector_id, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__group_create(obj, loc_params, cls, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) + if (NULL == + (ret_value = H5VL__group_create(obj, loc_params, cls, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create group") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLgroup_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__group_open * @@ -4138,26 +4002,25 @@ done: *------------------------------------------------------------------------- */ static void * -H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - const char *name, hid_t gapl_id, hid_t dxpl_id, void **req) +H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->group_cls.open) + if (NULL == cls->group_cls.open) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'group open' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->group_cls.open)(obj, loc_params, name, gapl_id, dxpl_id, req))) + if (NULL == (ret_value = (cls->group_cls.open)(obj, loc_params, name, gapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "group open failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__group_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_group_open * @@ -4169,32 +4032,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t gapl_id, hid_t dxpl_id, void **req) +H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__group_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, gapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__group_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, + gapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "group open failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_open() */ - /*------------------------------------------------------------------------- * Function: H5VLgroup_open * @@ -4207,30 +4070,29 @@ done: */ void * H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, - hid_t gapl_id, hid_t dxpl_id, void **req) + hid_t gapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, gapl_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__group_open(obj, loc_params, cls, name, gapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__group_open(obj, loc_params, cls, name, gapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open group") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLgroup_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__group_get * @@ -4242,26 +4104,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->group_cls.get) + if (NULL == cls->group_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group get' method") /* Call the corresponding VOL callback */ - if((cls->group_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + if ((cls->group_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__group_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_group_get * @@ -4273,40 +4134,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, - hid_t dxpl_id, void **req, ...) +H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__group_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__group_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_get() */ - /*------------------------------------------------------------------------- * Function: H5VLgroup_get * @@ -4318,31 +4177,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVii**xx", obj, connector_id, get_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__group_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__group_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute group get callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLgroup_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__group_specific * @@ -4354,26 +4212,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->group_cls.specific) + if (NULL == cls->group_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group specific' method") /* Call the corresponding VOL callback */ - if((cls->group_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if ((cls->group_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__group_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_group_specific * @@ -4385,40 +4242,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, ...) +H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__group_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__group_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < + 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLgroup_specific * @@ -4430,31 +4287,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVji**xx", obj, connector_id, specific_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__group_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + if (H5VL__group_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLgroup_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__group_optional * @@ -4466,26 +4322,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_group_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->group_cls.optional) + if (NULL == cls->group_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group optional' method") /* Call the corresponding VOL callback */ - if((ret_value = (cls->group_cls.optional)(obj, opt_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = (cls->group_cls.optional)(obj, opt_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__group_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_group_optional * @@ -4497,40 +4352,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type, - hid_t dxpl_id, void **req, ...) +H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, + ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if((ret_value = H5VL__group_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__group_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, + arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLgroup_optional * @@ -4542,31 +4397,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVwi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__group_optional(obj, cls, opt_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__group_optional(obj, cls, opt_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLgroup_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__group_close * @@ -4580,7 +4434,7 @@ done: static herr_t H5VL__group_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Sanity check */ HDassert(obj); @@ -4589,18 +4443,17 @@ H5VL__group_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->group_cls.close) + if (NULL == cls->group_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group close' method") /* Call the corresponding VOL callback */ - if((cls->group_cls.close)(obj, dxpl_id, req) < 0) + if ((cls->group_cls.close)(obj, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "group close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__group_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_group_close * @@ -4614,29 +4467,28 @@ done: herr_t H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__group_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + if (H5VL__group_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "group close failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_close() */ - /*------------------------------------------------------------------------- * Function: H5VLgroup_close * @@ -4650,27 +4502,26 @@ done: herr_t H5VLgroup_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__group_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__group_close(obj, cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close group") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLgroup_close() */ - /*------------------------------------------------------------------------- * Function: H5VL__link_create * @@ -4685,26 +4536,25 @@ done: */ static herr_t H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, - const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, - va_list arguments) + const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->link_cls.create) + if (NULL == cls->link_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link create' method") /* Call the corresponding VOL callback */ - if((cls->link_cls.create)(create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) + if ((cls->link_cls.create)(create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__link_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_link_create * @@ -4717,14 +4567,14 @@ done: */ herr_t H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, - void **req, ...) + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, + ...) { - H5VL_object_t tmp_vol_obj; /* Temporary object */ - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4733,8 +4583,8 @@ H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_o arg_started = TRUE; /* Special case for hard links */ - if(H5VL_LINK_CREATE_HARD == create_type && NULL == vol_obj->data) { - va_list tmp_arguments; /* Copy of argument list passed in */ + if (H5VL_LINK_CREATE_HARD == create_type && NULL == vol_obj->data) { + va_list tmp_arguments; /* Copy of argument list passed in */ /* Get the VOL data pointer from the varargs */ HDva_copy(tmp_arguments, arguments); @@ -4747,27 +4597,27 @@ H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_o tmp_vol_obj.connector = vol_obj->connector; /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(&tmp_vol_obj) < 0) + if (H5VL_set_vol_wrapper(&tmp_vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__link_create(create_type, vol_obj->data, loc_params, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) + if (H5VL__link_create(create_type, vol_obj->data, loc_params, vol_obj->connector->cls, lcpl_id, lapl_id, + dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_create() */ - /*------------------------------------------------------------------------- * Function: H5VLlink_create * @@ -4782,29 +4632,28 @@ done: */ herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, - hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, - va_list arguments) + hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE9("e", "Vk*x*xiiii**xx", create_type, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req, arguments); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) + if (H5VL__link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "unable to create link") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLlink_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__link_copy * @@ -4817,26 +4666,25 @@ done: */ static herr_t H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, - const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req) + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->link_cls.copy) + if (NULL == cls->link_cls.copy) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link copy' method") /* Call the corresponding VOL callback */ - if((cls->link_cls.copy)(src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, lapl_id, dxpl_id, req) < 0) + if ((cls->link_cls.copy)(src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "link copy failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__link_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL_link_copy * @@ -4849,34 +4697,34 @@ done: */ herr_t H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, - const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req) + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) { - const H5VL_object_t *vol_obj; /* VOL object for object with data */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5VL_object_t *vol_obj; /* VOL object for object with data */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ vol_obj = (src_vol_obj->data ? src_vol_obj : dst_vol_obj); - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__link_copy(src_vol_obj->data, loc_params1, (dst_vol_obj ? dst_vol_obj->data : NULL), loc_params2, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + if (H5VL__link_copy(src_vol_obj->data, loc_params1, (dst_vol_obj ? dst_vol_obj->data : NULL), loc_params2, + vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "link copy failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_copy() */ - /*------------------------------------------------------------------------- * Function: H5VLlink_copy * @@ -4891,29 +4739,28 @@ done: */ herr_t H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, - const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req) + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE9("e", "*x*x*x*xiiii**x", src_obj, loc_params1, dst_obj, loc_params2, connector_id, lcpl_id, lapl_id, dxpl_id, req); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__link_copy(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + if (H5VL__link_copy(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLlink_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL__link_move * @@ -4926,26 +4773,25 @@ done: */ static herr_t H5VL__link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, - const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req) + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->link_cls.move) + if (NULL == cls->link_cls.move) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link move' method") /* Call the corresponding VOL callback */ - if((cls->link_cls.move)(src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, lapl_id, dxpl_id, req) < 0) + if ((cls->link_cls.move)(src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "link move failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__link_move() */ - /*------------------------------------------------------------------------- * Function: H5VL_link_move * @@ -4958,34 +4804,34 @@ done: */ herr_t H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, - const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req) + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) { - const H5VL_object_t *vol_obj; /* VOL object for object with data */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5VL_object_t *vol_obj; /* VOL object for object with data */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ vol_obj = (src_vol_obj->data ? src_vol_obj : dst_vol_obj); - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__link_move(src_vol_obj->data, loc_params1, (dst_vol_obj ? dst_vol_obj->data : NULL), loc_params2, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + if (H5VL__link_move(src_vol_obj->data, loc_params1, (dst_vol_obj ? dst_vol_obj->data : NULL), loc_params2, + vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "link move failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_move() */ - /*------------------------------------------------------------------------- * Function: H5VLlink_move * @@ -5000,29 +4846,28 @@ done: */ herr_t H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, - const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req) + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE9("e", "*x*x*x*xiiii**x", src_obj, loc_params1, dst_obj, loc_params2, connector_id, lcpl_id, lapl_id, dxpl_id, req); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__link_move(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + if (H5VL__link_move(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "unable to move object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLlink_move() */ - /*------------------------------------------------------------------------- * Function: H5VL__link_get * @@ -5035,25 +4880,24 @@ done: */ static herr_t H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->link_cls.get) + if (NULL == cls->link_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link get' method") /* Call the corresponding VOL callback */ - if((cls->link_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) + if ((cls->link_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__link_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_link_get * @@ -5065,40 +4909,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...) +H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__link_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__link_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, + arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_get() */ - /*------------------------------------------------------------------------- * Function: H5VLlink_get * @@ -5111,30 +4955,29 @@ done: */ herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) + hid_t dxpl_id, void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("e", "*x*xiVli**xx", obj, loc_params, connector_id, get_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__link_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__link_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute link get callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLlink_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__link_specific * @@ -5147,25 +4990,24 @@ done: */ static herr_t H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->link_cls.specific) + if (NULL == cls->link_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link specific' method") /* Call the corresponding VOL callback */ - if((ret_value = (cls->link_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = (cls->link_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__link_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_link_specific * @@ -5178,39 +5020,39 @@ done: */ herr_t H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...) + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if((ret_value = H5VL__link_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__link_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, + dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLlink_specific * @@ -5223,30 +5065,29 @@ done: */ herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("e", "*x*xiVmi**xx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__link_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__link_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLlink_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__link_optional * @@ -5258,26 +5099,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__link_optional(void *obj, const H5VL_class_t *cls, H5VL_link_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__link_optional(void *obj, const H5VL_class_t *cls, H5VL_link_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->link_cls.optional) + if (NULL == cls->link_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link optional' method") /* Call the corresponding VOL callback */ - if((cls->link_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->link_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__link_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_link_optional * @@ -5289,40 +5129,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, - hid_t dxpl_id, void **req, ...) +H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, + ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__link_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__link_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLlink_optional * @@ -5334,31 +5173,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVxi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__link_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__link_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLlink_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__object_open * @@ -5370,26 +5208,25 @@ done: *------------------------------------------------------------------------- */ static void * -H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, H5I_type_t *opened_type, - hid_t dxpl_id, void **req) +H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, + H5I_type_t *opened_type, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->object_cls.open) + if (NULL == cls->object_cls.open) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'object open' method") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->object_cls.open)(obj, params, opened_type, dxpl_id, req))) + if (NULL == (ret_value = (cls->object_cls.open)(obj, params, opened_type, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "object open failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__object_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_open * @@ -5401,32 +5238,32 @@ done: *------------------------------------------------------------------------- */ void * -H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, - H5I_type_t *opened_type, hid_t dxpl_id, void **req) +H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - void *ret_value = NULL; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__object_open(vol_obj->data, params, vol_obj->connector->cls, opened_type, dxpl_id, req))) + if (NULL == (ret_value = H5VL__object_open(vol_obj->data, params, vol_obj->connector->cls, opened_type, + dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "object open failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_open() */ - /*------------------------------------------------------------------------- * Function: H5VLobject_open * @@ -5439,30 +5276,29 @@ done: */ void * H5VLobject_open(void *obj, const H5VL_loc_params_t *params, hid_t connector_id, H5I_type_t *opened_type, - hid_t dxpl_id, void **req) + hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("*x", "*x*xi*Iti**x", obj, params, connector_id, opened_type, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL__object_open(obj, params, cls, opened_type, dxpl_id, req))) + if (NULL == (ret_value = H5VL__object_open(obj, params, cls, opened_type, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLobject_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__object_copy * @@ -5474,28 +5310,27 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, - void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, - const H5VL_class_t *cls, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, - void **req) +H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, void *dst_obj, + const H5VL_loc_params_t *dst_loc_params, const char *dst_name, const H5VL_class_t *cls, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->object_cls.copy) + if (NULL == cls->object_cls.copy) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object copy' method") /* Call the corresponding VOL callback */ - if((cls->object_cls.copy)(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, ocpypl_id, lcpl_id, dxpl_id, req) < 0) + if ((cls->object_cls.copy)(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, + ocpypl_id, lcpl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "object copy failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__object_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_copy * @@ -5507,38 +5342,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_params, - const char *src_name, const H5VL_object_t *dst_obj, const H5VL_loc_params_t *dst_loc_params, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, - void **req) +H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, + const H5VL_object_t *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Make sure that the VOL connectors are the same */ - if(src_obj->connector->cls->value != dst_obj->connector->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "objects are accessed through different VOL connectors and can't be copied") + if (src_obj->connector->cls->value != dst_obj->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "objects are accessed through different VOL connectors and can't be copied") /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(src_obj) < 0) + if (H5VL_set_vol_wrapper(src_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__object_copy(src_obj->data, src_loc_params, src_name, dst_obj->data, dst_loc_params, dst_name, src_obj->connector->cls, ocpypl_id, lcpl_id, dxpl_id, req) < 0) + if (H5VL__object_copy(src_obj->data, src_loc_params, src_name, dst_obj->data, dst_loc_params, dst_name, + src_obj->connector->cls, ocpypl_id, lcpl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "object copy failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_copy() */ - /*------------------------------------------------------------------------- * Function: H5VLobject_copy * @@ -5550,13 +5385,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, - const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, - const char *dst_name, hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, - hid_t dxpl_id, void **req) +H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, void *dst_obj, + const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t connector_id, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE11("e", "*x*x*s*x*x*siiii**x", src_obj, src_loc_params, src_name, @@ -5564,20 +5398,20 @@ H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, dxpl_id, req); /* Check args and get class pointers */ - if(NULL == src_obj || NULL == dst_obj) + if (NULL == src_obj || NULL == dst_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__object_copy(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, cls, ocpypl_id, lcpl_id, dxpl_id, req) < 0) + if (H5VL__object_copy(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, cls, + ocpypl_id, lcpl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLobject_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL__object_get * @@ -5590,25 +5424,24 @@ done: */ static herr_t H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->object_cls.get) + if (NULL == cls->object_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object get' method") /* Call the corresponding VOL callback */ - if((cls->object_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) + if ((cls->object_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__object_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_get * @@ -5620,40 +5453,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...) +H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__object_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__object_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, + arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_get() */ - /*------------------------------------------------------------------------- * Function: H5VLobject_get * @@ -5666,30 +5499,29 @@ done: */ herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) + hid_t dxpl_id, void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("e", "*x*xiVni**xx", obj, loc_params, connector_id, get_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__object_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) + if (H5VL__object_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute object get callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLobject_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__object_specific * @@ -5702,26 +5534,24 @@ done: */ static herr_t H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments) + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->object_cls.specific) + if (NULL == cls->object_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object specific' method") /* Call the corresponding VOL callback */ - if((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__object_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_specific * @@ -5734,39 +5564,39 @@ done: */ herr_t H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...) + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if((ret_value = H5VL__object_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__object_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, + dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLobject_specific * @@ -5779,34 +5609,33 @@ done: */ herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE7("e", "*x*xiVoi**xx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Check if the corresponding VOL callback exists */ - if(NULL == cls->object_cls.specific) + if (NULL == cls->object_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no `object specific' method") /* Bypass the H5VLint layer, calling the VOL callback directly */ - if((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object specific callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLobject_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__object_optional * @@ -5818,26 +5647,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__object_optional(void *obj, const H5VL_class_t *cls, H5VL_object_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL__object_optional(void *obj, const H5VL_class_t *cls, H5VL_object_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->object_cls.optional) + if (NULL == cls->object_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object optional' method") /* Call the corresponding VOL callback */ - if((cls->object_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + if ((cls->object_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__object_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_optional * @@ -5849,40 +5677,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_type, - hid_t dxpl_id, void **req, ...) +H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, + ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if(H5VL__object_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__object_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLobject_optional * @@ -5894,31 +5721,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiVyi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__object_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + if (H5VL__object_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLobject_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__introspect_get_conn_cls * @@ -5931,10 +5757,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__introspect_get_conn_cls(void *obj, const H5VL_class_t *cls, - H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls) +H5VL__introspect_get_conn_cls(void *obj, const H5VL_class_t *cls, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -5945,18 +5771,17 @@ H5VL__introspect_get_conn_cls(void *obj, const H5VL_class_t *cls, HDassert(conn_cls); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->introspect_cls.get_conn_cls) + if (NULL == cls->introspect_cls.get_conn_cls) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'get_conn_cls' method") /* Call the corresponding VOL callback */ - if((cls->introspect_cls.get_conn_cls)(obj, lvl, conn_cls) < 0) + if ((cls->introspect_cls.get_conn_cls)(obj, lvl, conn_cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__introspect_get_conn_cls() */ - /*------------------------------------------------------------------------- * Function: H5VL_introspect_get_conn_cls * @@ -5970,31 +5795,30 @@ done: */ herr_t H5VL_introspect_get_conn_cls(const H5VL_object_t *vol_obj, H5VL_get_conn_lvl_t lvl, - const H5VL_class_t **conn_cls) + const H5VL_class_t **conn_cls) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__introspect_get_conn_cls(vol_obj->data, vol_obj->connector->cls, lvl, conn_cls) < 0) + if (H5VL__introspect_get_conn_cls(vol_obj->data, vol_obj->connector->cls, lvl, conn_cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector class") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_introspect_get_conn_cls() */ - /*------------------------------------------------------------------------- * Function: H5VLintrospect_get_conn_cls * @@ -6008,33 +5832,32 @@ done: */ herr_t H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t lvl, - const H5VL_class_t **conn_cls) + const H5VL_class_t **conn_cls) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xiVL**x", obj, connector_id, lvl, conn_cls); /* Check args */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL obj pointer") - if(NULL == conn_cls) + if (NULL == conn_cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL conn_cls pointer") /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__introspect_get_conn_cls(obj, cls, lvl, conn_cls) < 0) + if (H5VL__introspect_get_conn_cls(obj, cls, lvl, conn_cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector class") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLintrospect_get_conn_cls() */ - /*------------------------------------------------------------------------- * Function: H5VL__introspect_opt_query * @@ -6047,26 +5870,25 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__introspect_opt_query(void *obj, const H5VL_class_t *cls, H5VL_subclass_t subcls, - int opt_type, hbool_t *supported) +H5VL__introspect_opt_query(void *obj, const H5VL_class_t *cls, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->introspect_cls.opt_query) + if (NULL == cls->introspect_cls.opt_query) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'opt_query' method") /* Call the corresponding VOL callback */ - if((cls->introspect_cls.opt_query)(obj, subcls, opt_type, supported) < 0) + if ((cls->introspect_cls.opt_query)(obj, subcls, opt_type, supported) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__introspect_opt_query() */ - /*------------------------------------------------------------------------- * Function: H5VL_introspect_opt_query * @@ -6079,32 +5901,31 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_introspect_opt_query(const H5VL_object_t *vol_obj, H5VL_subclass_t subcls, - int opt_type, hbool_t *supported) +H5VL_introspect_opt_query(const H5VL_object_t *vol_obj, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__introspect_opt_query(vol_obj->data, vol_obj->connector->cls, subcls, opt_type, supported) < 0) + if (H5VL__introspect_opt_query(vol_obj->data, vol_obj->connector->cls, subcls, opt_type, supported) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_introspect_opt_query() */ - /*------------------------------------------------------------------------- * Function: H5VLintrospect_opt_query * @@ -6117,28 +5938,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, - int opt_type, hbool_t *supported) +H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE5("e", "*xiVSIs*b", obj, connector_id, subcls, opt_type, supported); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__introspect_opt_query(obj, cls, subcls, opt_type, supported) < 0) + if (H5VL__introspect_opt_query(obj, cls, subcls, opt_type, supported) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLintrospect_opt_query() */ - /*------------------------------------------------------------------------- * Function: H5VL__request_wait * @@ -6153,10 +5973,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__request_wait(void *req, const H5VL_class_t *cls, uint64_t timeout, - H5ES_status_t *status) +H5VL__request_wait(void *req, const H5VL_class_t *cls, uint64_t timeout, H5ES_status_t *status) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6166,18 +5985,17 @@ H5VL__request_wait(void *req, const H5VL_class_t *cls, uint64_t timeout, HDassert(status); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->request_cls.wait) + if (NULL == cls->request_cls.wait) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async wait' method") /* Call the corresponding VOL callback */ - if((cls->request_cls.wait)(req, timeout, status) < 0) + if ((cls->request_cls.wait)(req, timeout, status) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__request_wait() */ - /*------------------------------------------------------------------------- * Function: H5VL_request_wait * @@ -6192,11 +6010,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, - H5ES_status_t *status) +H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5ES_status_t *status) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6204,23 +6021,22 @@ H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, HDassert(vol_obj); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__request_wait(vol_obj->data, vol_obj->connector->cls, timeout, status) < 0) + if (H5VL__request_wait(vol_obj->data, vol_obj->connector->cls, timeout, status) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_wait() */ - /*------------------------------------------------------------------------- * Function: H5VLrequest_wait * @@ -6237,25 +6053,24 @@ done: herr_t H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5ES_status_t *status) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xiUL*Es", req, connector_id, timeout, status); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__request_wait(req, cls, timeout, status) < 0) + if (H5VL__request_wait(req, cls, timeout, status) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to wait on request") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLrequest_wait() */ - /*------------------------------------------------------------------------- * Function: H5VL__request_notify * @@ -6270,10 +6085,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__request_notify(void *req, const H5VL_class_t *cls, H5VL_request_notify_t cb, - void *ctx) +H5VL__request_notify(void *req, const H5VL_class_t *cls, H5VL_request_notify_t cb, void *ctx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6282,18 +6096,17 @@ H5VL__request_notify(void *req, const H5VL_class_t *cls, H5VL_request_notify_t c HDassert(cls); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->request_cls.notify) + if (NULL == cls->request_cls.notify) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async notify' method") /* Call the corresponding VOL callback */ - if((cls->request_cls.notify)(req, cb, ctx) < 0) + if ((cls->request_cls.notify)(req, cb, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request notify failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__request_notify() */ - /*------------------------------------------------------------------------- * Function: H5VL_request_notify * @@ -6308,11 +6121,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, - void *ctx) +H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, void *ctx) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6320,23 +6132,22 @@ H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, HDassert(vol_obj); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__request_notify(vol_obj->data, vol_obj->connector->cls, cb, ctx) < 0) + if (H5VL__request_notify(vol_obj->data, vol_obj->connector->cls, cb, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "request notify failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_notify() */ - /*------------------------------------------------------------------------- * Function: H5VLrequest_notify * @@ -6351,28 +6162,26 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, - void *ctx) +H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xix*x", req, connector_id, cb, ctx); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__request_notify(req, cls, cb, ctx) < 0) + if (H5VL__request_notify(req, cls, cb, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to register notify callback for request") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLrequest_notify() */ - /*------------------------------------------------------------------------- * Function: H5VL__request_cancel * @@ -6388,7 +6197,7 @@ done: static herr_t H5VL__request_cancel(void *req, const H5VL_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6397,18 +6206,17 @@ H5VL__request_cancel(void *req, const H5VL_class_t *cls) HDassert(cls); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->request_cls.cancel) + if (NULL == cls->request_cls.cancel) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async cancel' method") /* Call the corresponding VOL callback */ - if((cls->request_cls.cancel)(req) < 0) + if ((cls->request_cls.cancel)(req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__request_cancel() */ - /*------------------------------------------------------------------------- * Function: H5VL_request_cancel * @@ -6424,8 +6232,8 @@ done: herr_t H5VL_request_cancel(const H5VL_object_t *vol_obj) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6433,23 +6241,22 @@ H5VL_request_cancel(const H5VL_object_t *vol_obj) HDassert(vol_obj); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if(H5VL__request_cancel(vol_obj->data, vol_obj->connector->cls) < 0) + if (H5VL__request_cancel(vol_obj->data, vol_obj->connector->cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_cancel() */ - /*------------------------------------------------------------------------- * Function: H5VLrequest_cancel * @@ -6465,25 +6272,24 @@ done: herr_t H5VLrequest_cancel(void *req, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("e", "*xi", req, connector_id); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__request_cancel(req, cls) < 0) + if (H5VL__request_cancel(req, cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to cancel request") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLrequest_cancel() */ - /*------------------------------------------------------------------------- * Function: H5VL__request_specific * @@ -6495,10 +6301,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__request_specific(void *req, const H5VL_class_t *cls, - H5VL_request_specific_t specific_type, va_list arguments) +H5VL__request_specific(void *req, const H5VL_class_t *cls, H5VL_request_specific_t specific_type, + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6507,18 +6313,18 @@ H5VL__request_specific(void *req, const H5VL_class_t *cls, HDassert(cls); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->request_cls.specific) + if (NULL == cls->request_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async specific' method") /* Call the corresponding VOL callback */ - if((ret_value = (cls->request_cls.specific)(req, specific_type, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") + if ((ret_value = (cls->request_cls.specific)(req, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request specific callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__request_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_request_specific * @@ -6530,13 +6336,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_request_specific(const H5VL_object_t *vol_obj, - H5VL_request_specific_t specific_type, ...) +H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_t specific_type, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6544,29 +6349,30 @@ H5VL_request_specific(const H5VL_object_t *vol_obj, HDassert(vol_obj); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, specific_type); arg_started = TRUE; - if((ret_value = H5VL__request_specific(vol_obj->data, vol_obj->connector->cls, specific_type, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") + if ((ret_value = + H5VL__request_specific(vol_obj->data, vol_obj->connector->cls, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request specific callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLrequest_specific * @@ -6578,28 +6384,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, - va_list arguments) +H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xiVrx", req, connector_id, specific_type, arguments); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__request_specific(req, cls, specific_type, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") + if ((ret_value = H5VL__request_specific(req, cls, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request specific callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLrequest_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__request_optional * @@ -6612,9 +6417,9 @@ done: */ static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_request_optional_t opt_type, - va_list arguments) + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6623,18 +6428,18 @@ H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_request_optional HDassert(cls); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->request_cls.optional) + if (NULL == cls->request_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async optional' method") /* Call the corresponding VOL callback */ - if((ret_value = (cls->request_cls.optional)(req, opt_type, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") + if ((ret_value = (cls->request_cls.optional)(req, opt_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__request_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_request_optional * @@ -6646,13 +6451,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_request_optional_t opt_type, - ...) +H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_request_optional_t opt_type, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6660,29 +6464,29 @@ H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_request_optional_t opt_ HDassert(vol_obj); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, opt_type); arg_started = TRUE; - if((ret_value = H5VL__request_optional(vol_obj->data, vol_obj->connector->cls, opt_type, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") + if ((ret_value = H5VL__request_optional(vol_obj->data, vol_obj->connector->cls, opt_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLrequest_optional * @@ -6694,28 +6498,27 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLrequest_optional(void *req, hid_t connector_id, H5VL_request_optional_t opt_type, - va_list arguments) +H5VLrequest_optional(void *req, hid_t connector_id, H5VL_request_optional_t opt_type, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE4("e", "*xiVzx", req, connector_id, opt_type, arguments); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__request_optional(req, cls, opt_type, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") + if ((ret_value = H5VL__request_optional(req, cls, opt_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLrequest_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__request_free * @@ -6729,7 +6532,7 @@ done: static herr_t H5VL__request_free(void *req, const H5VL_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6738,18 +6541,17 @@ H5VL__request_free(void *req, const H5VL_class_t *cls) HDassert(cls); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->request_cls.free) + if (NULL == cls->request_cls.free) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async free' method") /* Call the corresponding VOL callback */ - if((cls->request_cls.free)(req) < 0) + if ((cls->request_cls.free)(req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request free failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__request_free() */ - /*------------------------------------------------------------------------- * Function: H5VL_request_free * @@ -6763,8 +6565,8 @@ done: herr_t H5VL_request_free(const H5VL_object_t *vol_obj) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6772,23 +6574,22 @@ H5VL_request_free(const H5VL_object_t *vol_obj) HDassert(vol_obj); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding VOL callback */ - if(H5VL__request_free(vol_obj->data, vol_obj->connector->cls) < 0) + if (H5VL__request_free(vol_obj->data, vol_obj->connector->cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request free failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_free() */ - /*------------------------------------------------------------------------- * Function: H5VLrequest_free * @@ -6802,25 +6603,24 @@ done: herr_t H5VLrequest_free(void *req, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE2("e", "*xi", req, connector_id); /* Get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if(H5VL__request_free(req, cls) < 0) + if (H5VL__request_free(req, cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to free request") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLrequest_free() */ - /*------------------------------------------------------------------------- * Function: H5VL__blob_put * @@ -6831,10 +6631,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size, - void *blob_id, void *ctx) +H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size, void *blob_id, void *ctx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6845,18 +6644,17 @@ H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size, HDassert(blob_id); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->blob_cls.put) + if (NULL == cls->blob_cls.put) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob put' method") /* Call the corresponding VOL callback */ - if((cls->blob_cls.put)(obj, buf, size, blob_id, ctx) < 0) + if ((cls->blob_cls.put)(obj, buf, size, blob_id, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__blob_put() */ - /*------------------------------------------------------------------------- * Function: H5VL_blob_put * @@ -6870,11 +6668,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, - void *blob_id, void *ctx) +H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void *blob_id, void *ctx) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6884,22 +6681,21 @@ H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, HDassert(blob_id); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding VOL callback */ - if(H5VL__blob_put(vol_obj->data, vol_obj->connector->cls, buf, size, blob_id, ctx) < 0) + if (H5VL__blob_put(vol_obj->data, vol_obj->connector->cls, buf, size, blob_id, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_put() */ - /*------------------------------------------------------------------------- * Function: H5VLblob_put * @@ -6910,30 +6706,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, - void *blob_id, void *ctx) +H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void *blob_id, void *ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xi*xz*x*x", obj, connector_id, buf, size, blob_id, ctx); /* Get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding VOL callback */ - if(H5VL__blob_put(obj, cls, buf, size, blob_id, ctx) < 0) + if (H5VL__blob_put(obj, cls, buf, size, blob_id, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLblob_put() */ - /*------------------------------------------------------------------------- * Function: H5VL__blob_get * @@ -6944,10 +6738,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id, - void *buf, size_t size, void *ctx) +H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id, void *buf, size_t size, void *ctx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6958,18 +6751,17 @@ H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id, HDassert(buf); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->blob_cls.get) + if (NULL == cls->blob_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob get' method") /* Call the corresponding VOL callback */ - if((cls->blob_cls.get)(obj, blob_id, buf, size, ctx) < 0) + if ((cls->blob_cls.get)(obj, blob_id, buf, size, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__blob_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_blob_get * @@ -6980,11 +6772,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, - size_t size, void *ctx) +H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size_t size, void *ctx) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6994,22 +6785,21 @@ H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, HDassert(buf); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding VOL callback */ - if(H5VL__blob_get(vol_obj->data, vol_obj->connector->cls, blob_id, buf, size, ctx) < 0) + if (H5VL__blob_get(vol_obj->data, vol_obj->connector->cls, blob_id, buf, size, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_get() */ - /*------------------------------------------------------------------------- * Function: H5VLblob_get * @@ -7020,30 +6810,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, - size_t size, void *ctx) +H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, size_t size, void *ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xi*x*xz*x", obj, connector_id, blob_id, buf, size, ctx); /* Get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding VOL callback */ - if(H5VL__blob_get(obj, cls, blob_id, buf, size, ctx) < 0) + if (H5VL__blob_get(obj, cls, blob_id, buf, size, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLblob_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__blob_specific * @@ -7057,10 +6845,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, - H5VL_blob_specific_t specific_type, va_list arguments) +H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7070,18 +6858,17 @@ H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, HDassert(blob_id); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->blob_cls.specific) + if (NULL == cls->blob_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob specific' method") /* Call the corresponding VOL callback */ - if((cls->blob_cls.specific)(obj, blob_id, specific_type, arguments) < 0) + if ((cls->blob_cls.specific)(obj, blob_id, specific_type, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__blob_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_blob_specific * @@ -7093,13 +6880,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, - H5VL_blob_specific_t specific_type, ...) +H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specific_t specific_type, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7108,29 +6894,29 @@ H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, HDassert(blob_id); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, specific_type); arg_started = TRUE; - if((ret_value = H5VL__blob_specific(vol_obj->data, vol_obj->connector->cls, blob_id, specific_type, arguments)) < 0) + if ((ret_value = H5VL__blob_specific(vol_obj->data, vol_obj->connector->cls, blob_id, specific_type, + arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_specific() */ - /*------------------------------------------------------------------------- * Function: H5VLblob_specific * @@ -7141,30 +6927,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, - H5VL_blob_specific_t specific_type, va_list arguments) +H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE5("e", "*xi*xVBx", obj, connector_id, blob_id, specific_type, arguments); /* Get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding VOL callback */ - if(H5VL__blob_specific(obj, cls, blob_id, specific_type, arguments) < 0) + if (H5VL__blob_specific(obj, cls, blob_id, specific_type, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob specific operation failed") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLblob_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__blob_optional * @@ -7178,10 +6963,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, - H5VL_blob_optional_t opt_type, va_list arguments) +H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_optional_t opt_type, + va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7191,18 +6976,17 @@ H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, HDassert(blob_id); /* Check if the corresponding VOL callback exists */ - if(NULL == cls->blob_cls.optional) + if (NULL == cls->blob_cls.optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob optional' method") /* Call the corresponding VOL callback */ - if((cls->blob_cls.optional)(obj, blob_id, opt_type, arguments) < 0) + if ((cls->blob_cls.optional)(obj, blob_id, opt_type, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__blob_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_blob_optional * @@ -7214,13 +6998,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, - H5VL_blob_optional_t opt_type, ...) +H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_optional_t opt_type, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7229,29 +7012,29 @@ H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, HDassert(blob_id); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, opt_type); arg_started = TRUE; - if((ret_value = H5VL__blob_optional(vol_obj->data, vol_obj->connector->cls, blob_id, opt_type, arguments)) < 0) + if ((ret_value = + H5VL__blob_optional(vol_obj->data, vol_obj->connector->cls, blob_id, opt_type, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLblob_optional * @@ -7262,30 +7045,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, - H5VL_blob_optional_t opt_type, va_list arguments) +H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_optional_t opt_type, + va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE5("e", "*xi*xVAx", obj, connector_id, blob_id, opt_type, arguments); /* Get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding VOL callback */ - if(H5VL__blob_optional(obj, cls, blob_id, opt_type, arguments) < 0) + if (H5VL__blob_optional(obj, cls, blob_id, opt_type, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob optional operation failed") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLblob_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__token_cmp * @@ -7300,10 +7082,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__token_cmp(void *obj, const H5VL_class_t *cls, - const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) +H5VL__token_cmp(void *obj, const H5VL_class_t *cls, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7313,19 +7095,19 @@ H5VL__token_cmp(void *obj, const H5VL_class_t *cls, HDassert(cmp_value); /* Take care of cases where one or both pointers is NULL */ - if(token1 == NULL && token2 != NULL) + if (token1 == NULL && token2 != NULL) *cmp_value = -1; - else if(token1 != NULL && token2 == NULL) + else if (token1 != NULL && token2 == NULL) *cmp_value = 1; - else if(token1 == NULL && token2 == NULL) + else if (token1 == NULL && token2 == NULL) *cmp_value = 0; else { /* Use the class's token comparison routine to compare the tokens, * if there is a callback, otherwise just compare the tokens as * memory buffers. */ - if(cls->token_cls.cmp) { - if((cls->token_cls.cmp)(obj, token1, token2, cmp_value) < 0) + if (cls->token_cls.cmp) { + if ((cls->token_cls.cmp)(obj, token1, token2, cmp_value) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare object tokens") } /* end if */ else @@ -7336,7 +7118,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__token_cmp() */ - /*------------------------------------------------------------------------- * Function: H5VL_token_cmp * @@ -7351,11 +7132,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, - const H5O_token_t *token2, int *cmp_value) +H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7364,23 +7145,22 @@ H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, HDassert(cmp_value); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__token_cmp(vol_obj->data, vol_obj->connector->cls, token1, token2, cmp_value)) < 0) + if ((ret_value = H5VL__token_cmp(vol_obj->data, vol_obj->connector->cls, token1, token2, cmp_value)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "token compare failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_token_cmp() */ - /*--------------------------------------------------------------------------- * Function: H5VLtoken_cmp * @@ -7397,32 +7177,31 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, - const H5O_token_t *token2, int *cmp_value) +H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE5("e", "*xi*k*k*Is", obj, connector_id, token1, token2, cmp_value); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") - if(NULL == cmp_value) + if (NULL == cmp_value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid cmp_value pointer") /* Call the corresponding internal VOL routine */ - if(H5VL__token_cmp(obj, cls, token1, token2, cmp_value) < 0) + if (H5VL__token_cmp(obj, cls, token1, token2, cmp_value) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "object token comparison failed") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLtoken_cmp() */ - /*------------------------------------------------------------------------- * Function: H5VL__token_to_str * @@ -7434,10 +7213,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, - const H5O_token_t *token, char **token_str) +H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, const H5O_token_t *token, + char **token_str) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7450,8 +7229,8 @@ H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, /* Use the class's token serialization routine on the token if there is a * callback, otherwise just set the token_str to NULL. */ - if(cls->token_cls.to_str) { - if((cls->token_cls.to_str)(obj, obj_type, token, token_str) < 0) + if (cls->token_cls.to_str) { + if ((cls->token_cls.to_str)(obj, obj_type, token, token_str) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "can't serialize object token") } /* end if */ else @@ -7461,7 +7240,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__token_to_str() */ - /*------------------------------------------------------------------------- * Function: H5VL_token_to_str * @@ -7473,11 +7251,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, - const H5O_token_t *token, char **token_str) +H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7487,23 +7265,23 @@ H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, HDassert(token_str); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__token_to_str(vol_obj->data, obj_type, vol_obj->connector->cls, token, token_str)) < 0) + if ((ret_value = H5VL__token_to_str(vol_obj->data, obj_type, vol_obj->connector->cls, token, token_str)) < + 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "token serialization failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_token_to_str() */ - /*--------------------------------------------------------------------------- * Function: H5VLtoken_to_str * @@ -7515,34 +7293,33 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, - const H5O_token_t *token, char **token_str) +H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_token_t *token, + char **token_str) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE5("e", "*xIti*k**s", obj, obj_type, connector_id, token, token_str); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") - if(NULL == token) + if (NULL == token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") - if(NULL == token_str) + if (NULL == token_str) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token_str pointer") /* Call the corresponding internal VOL routine */ - if(H5VL__token_to_str(obj, obj_type, cls, token, token_str) < 0) + if (H5VL__token_to_str(obj, obj_type, cls, token, token_str) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "object token to string failed") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLtoken_to_str() */ - /*------------------------------------------------------------------------- * Function: H5VL__token_from_str * @@ -7554,10 +7331,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, - const char *token_str, H5O_token_t *token) +H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, const char *token_str, + H5O_token_t *token) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7570,8 +7347,8 @@ H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, /* Use the class's token deserialization routine on the token if there is a * callback, otherwise just set the token to H5_TOKEN_UNDEF. */ - if(cls->token_cls.from_str) { - if((cls->token_cls.from_str)(obj, obj_type, token_str, token) < 0) + if (cls->token_cls.from_str) { + if ((cls->token_cls.from_str)(obj, obj_type, token_str, token) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token string") } /* end if */ else @@ -7581,7 +7358,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__token_from_str() */ - /*------------------------------------------------------------------------- * Function: H5VL_token_from_str * @@ -7593,11 +7369,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, - const char *token_str, H5O_token_t *token) +H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const char *token_str, + H5O_token_t *token) { - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -7607,23 +7383,23 @@ H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, HDassert(token_str); /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__token_from_str(vol_obj->data, obj_type, vol_obj->connector->cls, token_str, token)) < 0) + if ((ret_value = + H5VL__token_from_str(vol_obj->data, obj_type, vol_obj->connector->cls, token_str, token)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "token deserialization failed") done: /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_token_from_str() */ - /*--------------------------------------------------------------------------- * Function: H5VLtoken_from_str * @@ -7635,34 +7411,33 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, - const char *token_str, H5O_token_t *token) +H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const char *token_str, + H5O_token_t *token) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE5("e", "*xIti*s*k", obj, obj_type, connector_id, token_str, token); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") - if(NULL == token) + if (NULL == token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") - if(NULL == token_str) + if (NULL == token_str) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token_str pointer") /* Call the corresponding internal VOL routine */ - if(H5VL__token_from_str(obj, obj_type, cls, token_str, token) < 0) + if (H5VL__token_from_str(obj, obj_type, cls, token_str, token) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "object token from string failed") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLtoken_from_str() */ - /*------------------------------------------------------------------------- * Function: H5VL__optional * @@ -7674,26 +7449,24 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, void **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ - if(NULL == cls->optional) + if (NULL == cls->optional) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'optional' method") /* Call the corresponding VOL callback */ - if((ret_value = (cls->optional)(obj, op_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = (cls->optional)(obj, op_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, ret_value, "unable to execute optional callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_optional * @@ -7705,40 +7478,39 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, - void **req, ...) +H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, void **req, ...) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ - herr_t ret_value = SUCCEED; /* Return value */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj) < 0) + if (H5VL_set_vol_wrapper(vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") vol_wrapper_set = TRUE; /* Call the corresponding internal VOL routine */ HDva_start(arguments, req); arg_started = TRUE; - if((ret_value = H5VL__optional(vol_obj->data, vol_obj->connector->cls, op_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = + H5VL__optional(vol_obj->data, vol_obj->connector->cls, op_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute optional callback") done: /* End access to the va_list, if we started it */ - if(arg_started) + if (arg_started) HDva_end(arguments); /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRESET, ret_value, "can't reset VOL wrapper info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_optional() */ - /*------------------------------------------------------------------------- * Function: H5VLoptional * @@ -7750,26 +7522,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, void **req, va_list arguments) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT H5TRACE6("e", "*xiIsi**xx", obj, connector_id, op_type, dxpl_id, req, arguments); /* Check args and get class pointer */ - if(NULL == obj) + if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if((ret_value = H5VL__optional(obj, cls, op_type, dxpl_id, req, arguments)) < 0) + if ((ret_value = H5VL__optional(obj, cls, op_type, dxpl_id, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, ret_value, "unable to execute optional callback") done: FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5VLoptional() */ - diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 4a35f22..63ac910 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -18,31 +18,29 @@ #define _H5VLconnector_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Apublic.h" /* Attributes */ -#include "H5ESpublic.h" /* Event Stack */ -#include "H5Fpublic.h" /* Files */ -#include "H5Ipublic.h" /* IDs */ -#include "H5Lpublic.h" /* Links */ -#include "H5Opublic.h" /* Objects */ -#include "H5Rpublic.h" /* References */ -#include "H5VLpublic.h" /* Virtual Object Layer */ - +#include "H5public.h" /* Generic Functions */ +#include "H5Apublic.h" /* Attributes */ +#include "H5ESpublic.h" /* Event Stack */ +#include "H5Fpublic.h" /* Files */ +#include "H5Ipublic.h" /* IDs */ +#include "H5Lpublic.h" /* Links */ +#include "H5Opublic.h" /* Objects */ +#include "H5Rpublic.h" /* References */ +#include "H5VLpublic.h" /* Virtual Object Layer */ /*****************/ /* Public Macros */ /*****************/ /* Capability flags for connector */ -#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */ -#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */ +#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */ +#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */ /* Container info version */ -#define H5VL_CONTAINER_INFO_VERSION 0x01 /* Container info struct version */ +#define H5VL_CONTAINER_INFO_VERSION 0x01 /* Container info struct version */ /* The maximum size allowed for blobs */ -#define H5VL_MAX_BLOB_ID_SIZE (16) /* Allow for 128-bits blob IDs */ - +#define H5VL_MAX_BLOB_ID_SIZE (16) /* Allow for 128-bits blob IDs */ /*******************/ /* Public Typedefs */ @@ -50,20 +48,20 @@ /* types for attribute GET callback */ typedef enum H5VL_attr_get_t { - H5VL_ATTR_GET_ACPL, /* creation property list */ - H5VL_ATTR_GET_INFO, /* info */ - H5VL_ATTR_GET_NAME, /* access property list */ - H5VL_ATTR_GET_SPACE, /* dataspace */ - H5VL_ATTR_GET_STORAGE_SIZE, /* storage size */ - H5VL_ATTR_GET_TYPE /* datatype */ + H5VL_ATTR_GET_ACPL, /* creation property list */ + H5VL_ATTR_GET_INFO, /* info */ + H5VL_ATTR_GET_NAME, /* access property list */ + H5VL_ATTR_GET_SPACE, /* dataspace */ + H5VL_ATTR_GET_STORAGE_SIZE, /* storage size */ + H5VL_ATTR_GET_TYPE /* datatype */ } H5VL_attr_get_t; /* types for attribute SPECFIC callback */ typedef enum H5VL_attr_specific_t { - H5VL_ATTR_DELETE, /* H5Adelete(_by_name/idx) */ - H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */ - H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */ - H5VL_ATTR_RENAME /* H5Arename(_by_name) */ + H5VL_ATTR_DELETE, /* H5Adelete(_by_name/idx) */ + H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */ + H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */ + H5VL_ATTR_RENAME /* H5Arename(_by_name) */ } H5VL_attr_specific_t; /* Typedef for VOL connector attribute optional VOL operations */ @@ -71,19 +69,19 @@ typedef int H5VL_attr_optional_t; /* types for dataset GET callback */ typedef enum H5VL_dataset_get_t { - H5VL_DATASET_GET_DAPL, /* access property list */ - H5VL_DATASET_GET_DCPL, /* creation property list */ - H5VL_DATASET_GET_SPACE, /* dataspace */ - H5VL_DATASET_GET_SPACE_STATUS, /* space status */ - H5VL_DATASET_GET_STORAGE_SIZE, /* storage size */ - H5VL_DATASET_GET_TYPE /* datatype */ + H5VL_DATASET_GET_DAPL, /* access property list */ + H5VL_DATASET_GET_DCPL, /* creation property list */ + H5VL_DATASET_GET_SPACE, /* dataspace */ + H5VL_DATASET_GET_SPACE_STATUS, /* space status */ + H5VL_DATASET_GET_STORAGE_SIZE, /* storage size */ + H5VL_DATASET_GET_TYPE /* datatype */ } H5VL_dataset_get_t; /* types for dataset SPECFIC callback */ typedef enum H5VL_dataset_specific_t { - H5VL_DATASET_SET_EXTENT, /* H5Dset_extent */ - H5VL_DATASET_FLUSH, /* H5Dflush */ - H5VL_DATASET_REFRESH /* H5Drefresh */ + H5VL_DATASET_SET_EXTENT, /* H5Dset_extent */ + H5VL_DATASET_FLUSH, /* H5Dflush */ + H5VL_DATASET_REFRESH /* H5Drefresh */ } H5VL_dataset_specific_t; /* Typedef for VOL connector dataset optional VOL operations */ @@ -91,15 +89,12 @@ typedef int H5VL_dataset_optional_t; /* types for datatype GET callback */ typedef enum H5VL_datatype_get_t { - H5VL_DATATYPE_GET_BINARY, /* get serialized form of transient type */ - H5VL_DATATYPE_GET_TCPL /* datatype creation property list */ + H5VL_DATATYPE_GET_BINARY, /* get serialized form of transient type */ + H5VL_DATATYPE_GET_TCPL /* datatype creation property list */ } H5VL_datatype_get_t; /* types for datatype SPECFIC callback */ -typedef enum H5VL_datatype_specific_t { - H5VL_DATATYPE_FLUSH, - H5VL_DATATYPE_REFRESH -} H5VL_datatype_specific_t; +typedef enum H5VL_datatype_specific_t { H5VL_DATATYPE_FLUSH, H5VL_DATATYPE_REFRESH } H5VL_datatype_specific_t; /* Typedef and values for native VOL connector named datatype optional VOL operations */ typedef int H5VL_datatype_optional_t; @@ -107,25 +102,25 @@ typedef int H5VL_datatype_optional_t; /* types for file GET callback */ typedef enum H5VL_file_get_t { - H5VL_FILE_GET_CONT_INFO, /* file get container info */ - H5VL_FILE_GET_FAPL, /* file access property list */ - H5VL_FILE_GET_FCPL, /* file creation property list */ - H5VL_FILE_GET_FILENO, /* file number */ - H5VL_FILE_GET_INTENT, /* file intent */ - H5VL_FILE_GET_NAME, /* file name */ - H5VL_FILE_GET_OBJ_COUNT, /* object count in file */ - H5VL_FILE_GET_OBJ_IDS /* object ids in file */ + H5VL_FILE_GET_CONT_INFO, /* file get container info */ + H5VL_FILE_GET_FAPL, /* file access property list */ + H5VL_FILE_GET_FCPL, /* file creation property list */ + H5VL_FILE_GET_FILENO, /* file number */ + H5VL_FILE_GET_INTENT, /* file intent */ + H5VL_FILE_GET_NAME, /* file name */ + H5VL_FILE_GET_OBJ_COUNT, /* object count in file */ + H5VL_FILE_GET_OBJ_IDS /* object ids in file */ } H5VL_file_get_t; /* types for file SPECIFIC callback */ typedef enum H5VL_file_specific_t { - H5VL_FILE_FLUSH, /* Flush file */ - H5VL_FILE_REOPEN, /* Reopen the file */ - H5VL_FILE_MOUNT, /* Mount a file */ - H5VL_FILE_UNMOUNT, /* Unmount a file */ - H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */ - H5VL_FILE_DELETE, /* Delete a file */ - H5VL_FILE_IS_EQUAL /* Check if two files are the same */ + H5VL_FILE_FLUSH, /* Flush file */ + H5VL_FILE_REOPEN, /* Reopen the file */ + H5VL_FILE_MOUNT, /* Mount a file */ + H5VL_FILE_UNMOUNT, /* Unmount a file */ + H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */ + H5VL_FILE_DELETE, /* Delete a file */ + H5VL_FILE_IS_EQUAL /* Check if two files are the same */ } H5VL_file_specific_t; /* Typedef for VOL connector file optional VOL operations */ @@ -133,15 +128,12 @@ typedef int H5VL_file_optional_t; /* types for group GET callback */ typedef enum H5VL_group_get_t { - H5VL_GROUP_GET_GCPL, /* group creation property list */ - H5VL_GROUP_GET_INFO /* group info */ + H5VL_GROUP_GET_GCPL, /* group creation property list */ + H5VL_GROUP_GET_INFO /* group info */ } H5VL_group_get_t; /* types for group SPECFIC callback */ -typedef enum H5VL_group_specific_t { - H5VL_GROUP_FLUSH, - H5VL_GROUP_REFRESH -} H5VL_group_specific_t; +typedef enum H5VL_group_specific_t { H5VL_GROUP_FLUSH, H5VL_GROUP_REFRESH } H5VL_group_specific_t; /* Typedef for VOL connector group optional VOL operations */ typedef int H5VL_group_optional_t; @@ -155,16 +147,16 @@ typedef enum H5VL_link_create_type_t { /* types for link GET callback */ typedef enum H5VL_link_get_t { - H5VL_LINK_GET_INFO, /* link info */ - H5VL_LINK_GET_NAME, /* link name */ - H5VL_LINK_GET_VAL /* link value */ + H5VL_LINK_GET_INFO, /* link info */ + H5VL_LINK_GET_NAME, /* link name */ + H5VL_LINK_GET_VAL /* link value */ } H5VL_link_get_t; /* types for link SPECIFIC callback */ typedef enum H5VL_link_specific_t { - H5VL_LINK_DELETE, /* H5Ldelete(_by_idx) */ - H5VL_LINK_EXISTS, /* link existence */ - H5VL_LINK_ITER /* H5Literate/visit(_by_name) */ + H5VL_LINK_DELETE, /* H5Ldelete(_by_idx) */ + H5VL_LINK_EXISTS, /* link existence */ + H5VL_LINK_ITER /* H5Literate/visit(_by_name) */ } H5VL_link_specific_t; /* Typedef and values for native VOL connector link optional VOL operations */ @@ -173,20 +165,20 @@ typedef int H5VL_link_optional_t; /* types for object GET callback */ typedef enum H5VL_object_get_t { - H5VL_OBJECT_GET_FILE, /* object file */ - H5VL_OBJECT_GET_NAME, /* object name */ - H5VL_OBJECT_GET_TYPE, /* object type */ - H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name) */ + H5VL_OBJECT_GET_FILE, /* object file */ + H5VL_OBJECT_GET_NAME, /* object name */ + H5VL_OBJECT_GET_TYPE, /* object type */ + H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name) */ } H5VL_object_get_t; /* types for object SPECIFIC callback */ typedef enum H5VL_object_specific_t { - H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */ - H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */ - H5VL_OBJECT_LOOKUP, /* Lookup object */ - H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */ - H5VL_OBJECT_FLUSH, /* H5{D|G|O|T}flush */ - H5VL_OBJECT_REFRESH /* H5{D|G|O|T}refresh */ + H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */ + H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */ + H5VL_OBJECT_LOOKUP, /* Lookup object */ + H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */ + H5VL_OBJECT_FLUSH, /* H5{D|G|O|T}flush */ + H5VL_OBJECT_REFRESH /* H5{D|G|O|T}refresh */ } H5VL_object_specific_t; /* Typedef for VOL connector object optional VOL operations */ @@ -194,9 +186,9 @@ typedef int H5VL_object_optional_t; /* types for async request SPECIFIC callback */ typedef enum H5VL_request_specific_t { - H5VL_REQUEST_WAITANY, /* Wait until any request completes */ - H5VL_REQUEST_WAITSOME, /* Wait until at least one requesst completes */ - H5VL_REQUEST_WAITALL /* Wait until all requests complete */ + H5VL_REQUEST_WAITANY, /* Wait until any request completes */ + H5VL_REQUEST_WAITSOME, /* Wait until at least one requesst completes */ + H5VL_REQUEST_WAITALL /* Wait until all requests complete */ } H5VL_request_specific_t; /* Typedef and values for native VOL connector request optional VOL operations */ @@ -205,10 +197,10 @@ typedef int H5VL_request_optional_t; /* types for 'blob' SPECIFIC callback */ typedef enum H5VL_blob_specific_t { - H5VL_BLOB_DELETE, /* Delete a blob (by ID) */ - H5VL_BLOB_GETSIZE, /* Get size of blob */ - H5VL_BLOB_ISNULL, /* Check if a blob ID is "null" */ - H5VL_BLOB_SETNULL /* Set a blob ID to the connector's "null" blob ID value */ + H5VL_BLOB_DELETE, /* Delete a blob (by ID) */ + H5VL_BLOB_GETSIZE, /* Get size of blob */ + H5VL_BLOB_ISNULL, /* Check if a blob ID is "null" */ + H5VL_BLOB_SETNULL /* Set a blob ID to the connector's "null" blob ID value */ } H5VL_blob_specific_t; /* Typedef and values for native VOL connector blob optional VOL operations */ @@ -225,15 +217,15 @@ typedef enum H5VL_loc_type_t { typedef struct H5VL_loc_by_name { const char *name; - hid_t lapl_id; + hid_t lapl_id; } H5VL_loc_by_name_t; typedef struct H5VL_loc_by_idx { - const char *name; - H5_index_t idx_type; + const char * name; + H5_index_t idx_type; H5_iter_order_t order; - hsize_t n; - hid_t lapl_id; + hsize_t n; + hid_t lapl_id; } H5VL_loc_by_idx_t; typedef struct H5VL_loc_by_token { @@ -253,147 +245,152 @@ typedef struct H5VL_loc_params_t { H5I_type_t obj_type; H5VL_loc_type_t type; union { - H5VL_loc_by_token_t loc_by_token; - H5VL_loc_by_name_t loc_by_name; - H5VL_loc_by_idx_t loc_by_idx; + H5VL_loc_by_token_t loc_by_token; + H5VL_loc_by_name_t loc_by_name; + H5VL_loc_by_idx_t loc_by_idx; } loc_data; } H5VL_loc_params_t; /* Info for H5VL_FILE_GET_CONT_INFO */ typedef struct H5VL_file_cont_info_t { - unsigned version; /* version information (keep first) */ - uint64_t feature_flags; /* Container feature flags */ - /* (none currently defined) */ - size_t token_size; /* Size of tokens */ - size_t blob_id_size; /* Size of blob IDs */ + unsigned version; /* version information (keep first) */ + uint64_t feature_flags; /* Container feature flags */ + /* (none currently defined) */ + size_t token_size; /* Size of tokens */ + size_t blob_id_size; /* Size of blob IDs */ } H5VL_file_cont_info_t; /* VOL connector info fields & callbacks */ typedef struct H5VL_info_class_t { - size_t size; /* Size of the VOL info */ - void * (*copy)(const void *info); /* Callback to create a copy of the VOL info */ + size_t size; /* Size of the VOL info */ + void *(*copy)(const void *info); /* Callback to create a copy of the VOL info */ herr_t (*cmp)(int *cmp_value, const void *info1, const void *info2); /* Callback to compare VOL info */ herr_t (*free)(void *info); /* Callback to release a VOL info */ herr_t (*to_str)(const void *info, char **str); /* Callback to serialize connector's info into a string */ - herr_t (*from_str)(const char *str, void **info); /* Callback to deserialize a string into connector's info */ + herr_t (*from_str)(const char *str, + void ** info); /* Callback to deserialize a string into connector's info */ } H5VL_info_class_t; /* VOL object wrap / retrieval callbacks */ /* (These only need to be implemented by "pass through" VOL connectors) */ typedef struct H5VL_wrap_class_t { - void * (*get_object)(const void *obj); /* Callback to retrieve underlying object */ - herr_t (*get_wrap_ctx)(const void *obj, void **wrap_ctx); /* Callback to retrieve the object wrapping context for the connector */ - void * (*wrap_object)(void *obj, H5I_type_t obj_type, void *wrap_ctx); /* Callback to wrap a library object */ - void * (*unwrap_object)(void *obj); /* Callback to unwrap a library object */ - herr_t (*free_wrap_ctx)(void *wrap_ctx); /* Callback to release the object wrapping context for the connector */ + void *(*get_object)(const void *obj); /* Callback to retrieve underlying object */ + herr_t (*get_wrap_ctx)( + const void *obj, + void ** wrap_ctx); /* Callback to retrieve the object wrapping context for the connector */ + void *(*wrap_object)(void *obj, H5I_type_t obj_type, + void *wrap_ctx); /* Callback to wrap a library object */ + void *(*unwrap_object)(void *obj); /* Callback to unwrap a library object */ + herr_t (*free_wrap_ctx)( + void *wrap_ctx); /* Callback to release the object wrapping context for the connector */ } H5VL_wrap_class_t; /* H5A routines */ typedef struct H5VL_attr_class_t { - void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, - hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, - hid_t dxpl_id, void **req); - void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, - hid_t aapl_id, hid_t dxpl_id, void **req); + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, + hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, + hid_t dxpl_id, void **req); herr_t (*read)(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); herr_t (*write)(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); herr_t (*get)(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); - herr_t (*close) (void *attr, hid_t dxpl_id, void **req); + herr_t (*optional)(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *attr, hid_t dxpl_id, void **req); } H5VL_attr_class_t; /* H5D routines */ typedef struct H5VL_dataset_class_t { - void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, - hid_t dapl_id, hid_t dxpl_id, void **req); - void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t dapl_id, hid_t dxpl_id, void **req); - herr_t (*read)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, - hid_t dxpl_id, void * buf, void **req); - herr_t (*write)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, - hid_t dxpl_id, const void * buf, void **req); + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, + hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, + hid_t dxpl_id, void **req); + herr_t (*read)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, + void *buf, void **req); + herr_t (*write)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, + const void *buf, void **req); herr_t (*get)(void *obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); - herr_t (*close) (void *dset, hid_t dxpl_id, void **req); + herr_t (*specific)(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*optional)(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *dset, hid_t dxpl_id, void **req); } H5VL_dataset_class_t; /* H5T routines*/ typedef struct H5VL_datatype_class_t { void *(*commit)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); - void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char * name, - hid_t tapl_id, hid_t dxpl_id, void **req); - herr_t (*get) (void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*close) (void *dt, hid_t dxpl_id, void **req); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, + hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*optional)(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *dt, hid_t dxpl_id, void **req); } H5VL_datatype_class_t; /* H5F routines */ typedef struct H5VL_file_class_t { - void *(*create)(const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, hid_t dxpl_id, void **req); + void *(*create)(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, + void **req); void *(*open)(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); herr_t (*get)(void *obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); - herr_t (*close) (void *file, hid_t dxpl_id, void **req); + herr_t (*specific)(void *obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*optional)(void *obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *file, hid_t dxpl_id, void **req); } H5VL_file_class_t; /* H5G routines */ typedef struct H5VL_group_class_t { - void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); - void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t gapl_id, hid_t dxpl_id, void **req); + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, + hid_t dxpl_id, void **req); herr_t (*get)(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*close) (void *grp, hid_t dxpl_id, void **req); + herr_t (*specific)(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*optional)(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *grp, hid_t dxpl_id, void **req); } H5VL_group_class_t; /* H5L routines */ typedef struct H5VL_link_class_t { herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); - herr_t (*move)(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments); + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req); + herr_t (*move)(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req); + herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, - void **req, va_list arguments); + herr_t (*optional)(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); } H5VL_link_class_t; /* H5O routines */ typedef struct H5VL_object_class_t { - void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, - hid_t dxpl_id, void **req); - herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, + void **req); + herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, + hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*optional)(void *obj, H5VL_object_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); } H5VL_object_class_t; /* Asynchronous request 'notify' callback */ @@ -401,10 +398,10 @@ typedef herr_t (*H5VL_request_notify_t)(void *ctx, H5ES_status_t status); /* "Levels" for 'get connector class' introspection callback */ typedef enum H5VL_get_conn_lvl_t { - H5VL_GET_CONN_LVL_CURR, /* Get "current" connector (for this object) */ - H5VL_GET_CONN_LVL_TERM /* Get "terminal" connector (for this object) */ - /* (Recursively called, for pass-through connectors) */ - /* (Connectors that "split" must choose which connector to return) */ + H5VL_GET_CONN_LVL_CURR, /* Get "current" connector (for this object) */ + H5VL_GET_CONN_LVL_TERM /* Get "terminal" connector (for this object) */ + /* (Recursively called, for pass-through connectors) */ + /* (Connectors that "split" must choose which connector to return) */ } H5VL_get_conn_lvl_t; /* Forward declaration of H5VL_class_t, defined later in this file */ @@ -444,25 +441,25 @@ typedef struct H5VL_token_class_t { /* Class information for each VOL connector */ typedef struct H5VL_class_t { /* Overall connector fields & callbacks */ - unsigned int version; /* VOL connector class struct version # */ - H5VL_class_value_t value; /* Value to identify connector */ - const char *name; /* Connector name (MUST be unique!) */ - unsigned cap_flags; /* Capability flags for connector */ - herr_t (*initialize)(hid_t vipl_id); /* Connector initialization callback */ - herr_t (*terminate)(void); /* Connector termination callback */ + unsigned int version; /* VOL connector class struct version # */ + H5VL_class_value_t value; /* Value to identify connector */ + const char * name; /* Connector name (MUST be unique!) */ + unsigned cap_flags; /* Capability flags for connector */ + herr_t (*initialize)(hid_t vipl_id); /* Connector initialization callback */ + herr_t (*terminate)(void); /* Connector termination callback */ /* VOL framework */ - H5VL_info_class_t info_cls; /* VOL info fields & callbacks */ - H5VL_wrap_class_t wrap_cls; /* VOL object wrap / retrieval callbacks */ + H5VL_info_class_t info_cls; /* VOL info fields & callbacks */ + H5VL_wrap_class_t wrap_cls; /* VOL object wrap / retrieval callbacks */ /* Data Model */ - H5VL_attr_class_t attr_cls; /* Attribute (H5A*) class callbacks */ - H5VL_dataset_class_t dataset_cls; /* Dataset (H5D*) class callbacks */ - H5VL_datatype_class_t datatype_cls; /* Datatype (H5T*) class callbacks */ - H5VL_file_class_t file_cls; /* File (H5F*) class callbacks */ - H5VL_group_class_t group_cls; /* Group (H5G*) class callbacks */ - H5VL_link_class_t link_cls; /* Link (H5L*) class callbacks */ - H5VL_object_class_t object_cls; /* Object (H5O*) class callbacks */ + H5VL_attr_class_t attr_cls; /* Attribute (H5A*) class callbacks */ + H5VL_dataset_class_t dataset_cls; /* Dataset (H5D*) class callbacks */ + H5VL_datatype_class_t datatype_cls; /* Datatype (H5T*) class callbacks */ + H5VL_file_class_t file_cls; /* File (H5F*) class callbacks */ + H5VL_group_class_t group_cls; /* Group (H5G*) class callbacks */ + H5VL_link_class_t link_cls; /* Link (H5L*) class callbacks */ + H5VL_object_class_t object_cls; /* Object (H5O*) class callbacks */ /* Infrastructure / Services */ H5VL_introspect_class_t introspect_cls; /* Container/connector introspection class callbacks */ @@ -471,15 +468,14 @@ typedef struct H5VL_class_t { H5VL_token_class_t token_cls; /* VOL connector object token class callbacks */ /* Catch-all */ - herr_t (*optional)(void *obj, int op_type, hid_t dxpl_id, void **req, va_list arguments); /* Optional callback */ + herr_t (*optional)(void *obj, int op_type, hid_t dxpl_id, void **req, + va_list arguments); /* Optional callback */ } H5VL_class_t; - /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -491,8 +487,7 @@ extern "C" { /* Helper routines for VOL connector authors */ H5_DLL hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); H5_DLL void *H5VLobject(hid_t obj_id); -H5_DLL hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, - hid_t dtype_id); +H5_DLL hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id); H5_DLL hid_t H5VLpeek_connector_id_by_name(const char *name); H5_DLL hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value); @@ -501,4 +496,3 @@ H5_DLL hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value); #endif #endif /* _H5VLconnector_H */ - diff --git a/src/H5VLconnector_passthru.h b/src/H5VLconnector_passthru.h index b04f5eb..07297e1 100644 --- a/src/H5VLconnector_passthru.h +++ b/src/H5VLconnector_passthru.h @@ -27,14 +27,13 @@ #define _H5VLconnector_passthru_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Ipublic.h" /* IDs */ -#include "H5VLpublic.h" /* Virtual Object Layer */ +#include "H5public.h" /* Generic Functions */ +#include "H5Ipublic.h" /* IDs */ +#include "H5VLpublic.h" /* Virtual Object Layer */ /* Semi-public headers mainly for VOL connector authors */ #include "H5VLconnector.h" - /*****************/ /* Public Macros */ /*****************/ @@ -57,18 +56,17 @@ extern "C" { /* Helper routines for VOL connector authors */ H5_DLL herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2); -H5_DLL hid_t H5VLwrap_register(void *obj, H5I_type_t type); +H5_DLL hid_t H5VLwrap_register(void *obj, H5I_type_t type); H5_DLL herr_t H5VLretrieve_lib_state(void **state); H5_DLL herr_t H5VLrestore_lib_state(const void *state); H5_DLL herr_t H5VLreset_lib_state(void); H5_DLL herr_t H5VLfree_lib_state(void *state); /* Pass-through callbacks */ -H5_DLL void *H5VLget_object(void *obj, hid_t connector_id); +H5_DLL void * H5VLget_object(void *obj, hid_t connector_id); H5_DLL herr_t H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx); -H5_DLL void *H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, - void *wrap_ctx); -H5_DLL void *H5VLunwrap_object(void *obj, hid_t connector_id); +H5_DLL void * H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx); +H5_DLL void * H5VLunwrap_object(void *obj, hid_t connector_id); H5_DLL herr_t H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id); /* Public wrappers for generic callbacks */ @@ -79,109 +77,160 @@ H5_DLL herr_t H5VLget_value(hid_t connector_id, H5VL_class_value_t *conn_value); /* Public wrappers for info fields and callbacks */ H5_DLL herr_t H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info); -H5_DLL herr_t H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, - const void *info2); +H5_DLL herr_t H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, const void *info2); H5_DLL herr_t H5VLfree_connector_info(hid_t connector_id, void *vol_info); H5_DLL herr_t H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str); H5_DLL herr_t H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info); /* Public wrappers for attribute callbacks */ -H5_DLL void *H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLattr_read(void *attr, hid_t connector_id, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLattr_write(void *attr, hid_t connector_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, + hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_read(void *attr, hid_t connector_id, hid_t dtype_id, void *buf, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLattr_write(void *attr, hid_t connector_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); H5_DLL herr_t H5VLattr_close(void *attr, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for dataset callbacks */ -H5_DLL void *H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLdataset_read(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); -H5_DLL herr_t H5VLdataset_write(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -H5_DLL herr_t H5VLdataset_get(void *dset, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, + hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdataset_read(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VLdataset_write(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VLdataset_get(void *dset, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); H5_DLL herr_t H5VLdataset_close(void *dset, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for named datatype callbacks */ -H5_DLL void *H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, + hid_t dxpl_id, void **req); +H5_DLL void * H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for file callbacks */ -H5_DLL void *H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLfile_get(void *file, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, + void **req); +H5_DLL void * H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLfile_get(void *file, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); H5_DLL herr_t H5VLfile_close(void *file, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for group callbacks */ -H5_DLL void *H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +H5_DLL void * H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); H5_DLL herr_t H5VLgroup_close(void *grp, hid_t connector_id, hid_t dxpl_id, void **req); /* Public wrappers for link callbacks */ -H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); /* Public wrappers for object callbacks */ -H5_DLL void *H5VLobject_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL void * H5VLobject_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); H5_DLL herr_t H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, - hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); /* Public wrappers for connector/container introspection callbacks */ -H5_DLL herr_t H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, - H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); -H5_DLL herr_t H5VLintrospect_opt_query(void *obj, hid_t connector_id, - H5VL_subclass_t subcls, int opt_type, hbool_t *supported); +H5_DLL herr_t H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported); /* Public wrappers for asynchronous request callbacks */ H5_DLL herr_t H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5ES_status_t *status); H5_DLL herr_t H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx); H5_DLL herr_t H5VLrequest_cancel(void *req, hid_t connector_id); -H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, va_list arguments); -H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, H5VL_request_optional_t opt_type, va_list arguments); +H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, + va_list arguments); +H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, H5VL_request_optional_t opt_type, + va_list arguments); H5_DLL herr_t H5VLrequest_free(void *req, hid_t connector_id); /* Public wrappers for blob callbacks */ -H5_DLL herr_t H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void *blob_id, void *ctx); -H5_DLL herr_t H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, size_t size, void *ctx); -H5_DLL herr_t H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); -H5_DLL herr_t H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); +H5_DLL herr_t H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void *blob_id, + void *ctx); +H5_DLL herr_t H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, size_t size, + void *ctx); +H5_DLL herr_t H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, + H5VL_blob_specific_t specific_type, va_list arguments); +H5_DLL herr_t H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_optional_t opt_type, + va_list arguments); /* Public wrappers for token callbacks */ -H5_DLL herr_t H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); -H5_DLL herr_t H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_token_t *token, char **token_str); -H5_DLL herr_t H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const char *token_str, H5O_token_t *token); +H5_DLL herr_t H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value); +H5_DLL herr_t H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_token_t *token, + char **token_str); +H5_DLL herr_t H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const char *token_str, + H5O_token_t *token); /* Public wrappers for generic 'optional' callback */ -H5_DLL herr_t H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, - void **req, va_list arguments); +H5_DLL herr_t H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, void **req, + va_list arguments); #ifdef __cplusplus } #endif #endif /* _H5VLconnector_passthru_H */ - diff --git a/src/H5VLint.c b/src/H5VLint.c index 861629f..b1c690a 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -17,52 +17,48 @@ * a specific file format, or remotely on other machines, etc... */ - /****************/ /* Module Setup */ /****************/ -#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ - +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Mprivate.h" /* Maps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PLprivate.h" /* Plugins */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VLpkg.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Mprivate.h" /* Maps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLprivate.h" /* Plugins */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLpkg.h" /* Virtual Object Layer */ /* VOL connectors */ -#include "H5VLnative.h" /* Native VOL connector */ -#include "H5VLpassthru.h" /* Pass-through VOL connector */ - +#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLpassthru.h" /* Pass-through VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Object wrapping context info */ typedef struct H5VL_wrap_ctx_t { - unsigned rc; /* Ref. count for the # of times the context was set / reset */ - H5VL_t *connector; /* VOL connector for "outermost" class to start wrap */ - void *obj_wrap_ctx; /* "wrap context" for outermost connector */ + unsigned rc; /* Ref. count for the # of times the context was set / reset */ + H5VL_t * connector; /* VOL connector for "outermost" class to start wrap */ + void * obj_wrap_ctx; /* "wrap context" for outermost connector */ } H5VL_wrap_ctx_t; /* Information needed for iterating over the registered VOL connector hid_t IDs. @@ -73,36 +69,33 @@ typedef struct H5VL_wrap_ctx_t { */ typedef struct { /* IN */ - H5VL_get_connector_kind_t kind; /* Which kind of connector search to make */ + H5VL_get_connector_kind_t kind; /* Which kind of connector search to make */ union { - const char *name; /* The name of the VOL connector to check */ - H5VL_class_value_t value; /* The value of the VOL connector to check */ + const char * name; /* The name of the VOL connector to check */ + H5VL_class_value_t value; /* The value of the VOL connector to check */ } u; /* OUT */ - hid_t found_id; /* The connector ID, if we found a match */ + hid_t found_id; /* The connector ID, if we found a match */ } H5VL_get_connector_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5VL__free_cls(H5VL_class_t *cls); -static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data); -static herr_t H5VL__set_def_conn(void); -static void *H5VL__wrap_obj(void *obj, H5I_type_t obj_type); -static H5VL_object_t *H5VL__new_vol_obj(H5I_type_t type, void *object, - H5VL_t *vol_connector, hbool_t wrap_obj); -static int64_t H5VL__conn_inc_rc(H5VL_t *connector); -static int64_t H5VL__conn_dec_rc(H5VL_t *connector); -static void *H5VL__object(hid_t id, H5I_type_t obj_type); -static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); - +static herr_t H5VL__free_cls(H5VL_class_t *cls); +static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data); +static herr_t H5VL__set_def_conn(void); +static void * H5VL__wrap_obj(void *obj, H5I_type_t obj_type); +static H5VL_object_t *H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, + hbool_t wrap_obj); +static int64_t H5VL__conn_inc_rc(H5VL_t *connector); +static int64_t H5VL__conn_dec_rc(H5VL_t *connector); +static void * H5VL__object(hid_t id, H5I_type_t obj_type); +static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); /*********************/ /* Package Variables */ @@ -111,22 +104,20 @@ static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* VOL ID class */ static const H5I_class_t H5I_VOL_CLS[1] = {{ - H5I_VOL, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5VL__free_cls /* Callback routine for closing objects of this class */ + H5I_VOL, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5VL__free_cls /* Callback routine for closing objects of this class */ }}; /* Declare a free list to manage the H5VL_class_t struct */ @@ -144,8 +135,6 @@ H5FL_DEFINE_STATIC(H5VL_wrap_ctx_t); /* Default VOL connector */ static H5VL_connector_prop_t H5VL_def_conn_s = {-1, NULL}; - - /*------------------------------------------------------------------------- * Function: H5VL_init_phase1 * @@ -163,7 +152,7 @@ static H5VL_connector_prop_t H5VL_def_conn_s = {-1, NULL}; herr_t H5VL_init_phase1(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -173,7 +162,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_init_phase1() */ - /*------------------------------------------------------------------------- * Function: H5VL_init_phase2 * @@ -190,33 +178,32 @@ done: herr_t H5VL_init_phase2(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Initialize all packages for VOL-managed objects */ - if(H5T_init() < 0) + if (H5T_init() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize datatype interface") - if(H5D_init() < 0) + if (H5D_init() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize dataset interface") - if(H5F_init() < 0) + if (H5F_init() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize file interface") - if(H5G_init() < 0) + if (H5G_init() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize group interface") - if(H5A_init() < 0) + if (H5A_init() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize attribute interface") - if(H5M_init() < 0) + if (H5M_init() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize map interface") /* Set up the default VOL connector in the default FAPL */ - if(H5VL__set_def_conn() < 0) + if (H5VL__set_def_conn() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set default VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_init_phase2() */ - /*------------------------------------------------------------------------- * Function: H5VL__init_package * @@ -231,19 +218,18 @@ done: herr_t H5VL__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the VL IDs */ - if(H5I_register_type(H5I_VOL_CLS) < 0) + if (H5I_register_type(H5I_VOL_CLS) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__init_package() */ - /*------------------------------------------------------------------------- * Function: H5VL_term_package * @@ -258,20 +244,20 @@ done: int H5VL_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - if(H5VL_def_conn_s.connector_id > 0) { + if (H5_PKG_INIT_VAR) { + if (H5VL_def_conn_s.connector_id > 0) { /* Release the default VOL connector */ (void)H5VL_conn_free(&H5VL_def_conn_s); - H5VL_def_conn_s.connector_id = -1; + H5VL_def_conn_s.connector_id = -1; H5VL_def_conn_s.connector_info = NULL; n++; } /* end if */ else { - if(H5I_nmembers(H5I_VOL) > 0) { + if (H5I_nmembers(H5I_VOL) > 0) { /* Unregister all VOL connectors */ (void)H5I_clear_type(H5I_VOL, TRUE, FALSE); n++; @@ -281,16 +267,15 @@ H5VL_term_package(void) n += (H5I_dec_type_ref(H5I_VOL) > 0); /* Mark interface as closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5VL_term_package() */ - /*------------------------------------------------------------------------- * Function: H5VL__free_cls * @@ -314,7 +299,7 @@ H5VL__free_cls(H5VL_class_t *cls) HDassert(cls); /* Shut down the VOL connector */ - if(cls->terminate && cls->terminate() < 0) + if (cls->terminate && cls->terminate() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly") /* Release the class */ @@ -325,7 +310,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__free_cls() */ - /*------------------------------------------------------------------------- * Function: H5VL__get_connector_cb * @@ -343,30 +327,29 @@ done: static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data) { - H5VL_get_connector_ud_t *op_data = (H5VL_get_connector_ud_t *)_op_data; /* User data for callback */ - H5VL_class_t *cls = (H5VL_class_t *)obj; - int ret_value = H5_ITER_CONT; /* Callback return value */ + H5VL_get_connector_ud_t *op_data = (H5VL_get_connector_ud_t *)_op_data; /* User data for callback */ + H5VL_class_t * cls = (H5VL_class_t *)obj; + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR - if(H5VL_GET_CONNECTOR_BY_NAME == op_data->kind) { - if(0 == HDstrcmp(cls->name, op_data->u.name)) { + if (H5VL_GET_CONNECTOR_BY_NAME == op_data->kind) { + if (0 == HDstrcmp(cls->name, op_data->u.name)) { op_data->found_id = id; - ret_value = H5_ITER_STOP; + ret_value = H5_ITER_STOP; } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->kind); - if(cls->value == op_data->u.value) { + if (cls->value == op_data->u.value) { op_data->found_id = id; - ret_value = H5_ITER_STOP; + ret_value = H5_ITER_STOP; } /* end if */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__get_connector_cb() */ - /*------------------------------------------------------------------------- * Function: H5VL__set_def_conn * @@ -387,13 +370,13 @@ H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data) static herr_t H5VL__set_def_conn(void) { - H5P_genplist_t *def_fapl; /* Default file access property list */ - H5P_genclass_t *def_fapclass; /* Default file access property class */ - const char *env_var; /* Environment variable for default VOL connector */ - char *buf = NULL; /* Buffer for tokenizing string */ - hid_t connector_id = -1; /* VOL conntector ID */ - void *vol_info = NULL; /* VOL connector info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *def_fapl; /* Default file access property list */ + H5P_genclass_t *def_fapclass; /* Default file access property class */ + const char * env_var; /* Environment variable for default VOL connector */ + char * buf = NULL; /* Buffer for tokenizing string */ + hid_t connector_id = -1; /* VOL conntector ID */ + void * vol_info = NULL; /* VOL connector info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -405,93 +388,95 @@ H5VL__set_def_conn(void) env_var = HDgetenv("HDF5_VOL_CONNECTOR"); /* Only parse the string if it's set */ - if(env_var && *env_var) { - char *lasts = NULL; /* Context pointer for strtok_r() call */ - const char *tok = NULL; /* Token from strtok_r call */ - htri_t connector_is_registered; /* Whether connector is already registered */ + if (env_var && *env_var) { + char * lasts = NULL; /* Context pointer for strtok_r() call */ + const char *tok = NULL; /* Token from strtok_r call */ + htri_t connector_is_registered; /* Whether connector is already registered */ /* Duplicate the string to parse, as it is modified as we go */ - if(NULL == (buf = H5MM_strdup(env_var))) + if (NULL == (buf = H5MM_strdup(env_var))) HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate memory for environment variable string") /* Get the first 'word' of the environment variable. * If it's nothing (environment variable was whitespace) return error. */ - if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) + if (NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "VOL connector environment variable set empty?") /* First, check to see if the connector is already registered */ - if((connector_is_registered = H5VL__is_connector_registered_by_name(tok)) < 0) + if ((connector_is_registered = H5VL__is_connector_registered_by_name(tok)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check if VOL connector already registered") - else if(connector_is_registered) { + else if (connector_is_registered) { /* Retrieve the ID of the already-registered VOL connector */ - if((connector_id = H5VL__get_connector_id_by_name(tok, FALSE)) < 0) + if ((connector_id = H5VL__get_connector_id_by_name(tok, FALSE)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector ID") } /* end else-if */ else { /* Check for VOL connectors that ship with the library */ - if(!HDstrcmp(tok, "native")) { + if (!HDstrcmp(tok, "native")) { connector_id = H5VL_NATIVE; - if(H5I_inc_ref(connector_id, FALSE) < 0) + if (H5I_inc_ref(connector_id, FALSE) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount") } /* end if */ - else if(!HDstrcmp(tok, "pass_through")) { + else if (!HDstrcmp(tok, "pass_through")) { connector_id = H5VL_PASSTHRU; - if(H5I_inc_ref(connector_id, FALSE) < 0) + if (H5I_inc_ref(connector_id, FALSE) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount") } /* end else-if */ else { /* Register the VOL connector */ /* (NOTE: No provisions for vipl_id currently) */ - if((connector_id = H5VL__register_connector_by_name(tok, TRUE, H5P_VOL_INITIALIZE_DEFAULT)) < 0) + if ((connector_id = H5VL__register_connector_by_name(tok, TRUE, H5P_VOL_INITIALIZE_DEFAULT)) < + 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register connector") } /* end else */ - } /* end else */ + } /* end else */ /* Was there any connector info specified in the environment variable? */ - if(NULL != (tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) - if(H5VL__connector_str_to_info(tok, connector_id, &vol_info) < 0) + if (NULL != (tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) + if (H5VL__connector_str_to_info(tok, connector_id, &vol_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info") /* Set the default VOL connector */ - H5VL_def_conn_s.connector_id = connector_id; + H5VL_def_conn_s.connector_id = connector_id; H5VL_def_conn_s.connector_info = vol_info; } /* end if */ else { /* Set the default VOL connector */ - H5VL_def_conn_s.connector_id = H5_DEFAULT_VOL; + H5VL_def_conn_s.connector_id = H5_DEFAULT_VOL; H5VL_def_conn_s.connector_info = NULL; /* Increment the ref count on the default connector */ - if(H5I_inc_ref(H5VL_def_conn_s.connector_id, FALSE) < 0) + if (H5I_inc_ref(H5VL_def_conn_s.connector_id, FALSE) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount") } /* end else */ /* Get default file access pclass */ - if(NULL == (def_fapclass = (H5P_genclass_t *)H5I_object(H5P_FILE_ACCESS))) + if (NULL == (def_fapclass = (H5P_genclass_t *)H5I_object(H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_VOL, H5E_BADATOM, FAIL, "can't find object for default file access property class ID") /* Change the default VOL for the default file access pclass */ - if(H5P_reset_vol_class(def_fapclass, &H5VL_def_conn_s) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set default VOL connector for default file access property class") + if (H5P_reset_vol_class(def_fapclass, &H5VL_def_conn_s) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, + "can't set default VOL connector for default file access property class") /* Get default file access plist */ - if(NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_VOL, H5E_BADATOM, FAIL, "can't find object for default fapl ID") /* Change the default VOL for the default FAPL */ - if(H5P_set_vol(def_fapl, H5VL_def_conn_s.connector_id, H5VL_def_conn_s.connector_info) < 0) + if (H5P_set_vol(def_fapl, H5VL_def_conn_s.connector_id, H5VL_def_conn_s.connector_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set default VOL connector for default FAPL") done: /* Clean up on error */ - if(ret_value < 0) { - if(vol_info) - if(H5VL_free_connector_info(connector_id, vol_info) < 0) + if (ret_value < 0) { + if (vol_info) + if (H5VL_free_connector_info(connector_id, vol_info) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free VOL connector info") - if(connector_id >= 0) + if (connector_id >= 0) /* The H5VL_class_t struct will be freed by this function */ - if(H5I_dec_ref(connector_id) < 0) + if (H5I_dec_ref(connector_id) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector") } /* end if */ @@ -501,7 +486,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__set_def_conn() */ - /*------------------------------------------------------------------------- * Function: H5VL__wrap_obj * @@ -519,8 +503,8 @@ done: static void * H5VL__wrap_obj(void *obj, H5I_type_t obj_type) { - H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ - void *ret_value = NULL; /* Return value */ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -528,13 +512,14 @@ H5VL__wrap_obj(void *obj, H5I_type_t obj_type) HDassert(obj); /* Retrieve the VOL object wrapping context */ - if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't get VOL object wrap context") /* If there is a VOL object wrapping context, wrap the object */ - if(vol_wrap_ctx) { + if (vol_wrap_ctx) { /* Wrap object, using the VOL callback */ - if(NULL == (ret_value = H5VL_wrap_object(vol_wrap_ctx->connector->cls, vol_wrap_ctx->obj_wrap_ctx, obj, obj_type))) + if (NULL == (ret_value = H5VL_wrap_object(vol_wrap_ctx->connector->cls, vol_wrap_ctx->obj_wrap_ctx, + obj, obj_type))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object") } /* end if */ else @@ -544,7 +529,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__wrap_obj() */ - /*------------------------------------------------------------------------- * Function: H5VL__new_vol_obj * @@ -561,9 +545,9 @@ done: static H5VL_object_t * H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t wrap_obj) { - H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ - hbool_t conn_rc_incr = FALSE; /* Whether the VOL connector refcount has been incremented */ - H5VL_object_t *ret_value = NULL; /* Return value */ + H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ + hbool_t conn_rc_incr = FALSE; /* Whether the VOL connector refcount has been incremented */ + H5VL_object_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -572,16 +556,16 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t HDassert(vol_connector); /* Make sure type number is valid */ - if(type != H5I_ATTR && type != H5I_DATASET && type != H5I_DATATYPE - && type != H5I_FILE && type != H5I_GROUP && type != H5I_MAP) + if (type != H5I_ATTR && type != H5I_DATASET && type != H5I_DATATYPE && type != H5I_FILE && + type != H5I_GROUP && type != H5I_MAP) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, NULL, "invalid type number") /* Create the new VOL object */ - if(NULL == (new_vol_obj = H5FL_CALLOC(H5VL_object_t))) + if (NULL == (new_vol_obj = H5FL_CALLOC(H5VL_object_t))) HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate memory for VOL object") new_vol_obj->connector = vol_connector; - if(wrap_obj) { - if(NULL == (new_vol_obj->data = H5VL__wrap_obj(object, type))) + if (wrap_obj) { + if (NULL == (new_vol_obj->data = H5VL__wrap_obj(object, type))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "can't wrap library object") } /* end if */ else @@ -592,8 +576,8 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t conn_rc_incr = TRUE; /* If this is a datatype, we have to hide the VOL object under the H5T_t pointer */ - if(H5I_DATATYPE == type) { - if(NULL == (ret_value = (H5VL_object_t *)H5T_construct_datatype(new_vol_obj))) + if (H5I_DATATYPE == type) { + if (NULL == (ret_value = (H5VL_object_t *)H5T_construct_datatype(new_vol_obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "can't construct datatype object") } /* end if */ else @@ -601,15 +585,14 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t done: /* Cleanup on error */ - if(NULL == ret_value) { - if(conn_rc_incr && H5VL__conn_dec_rc(vol_connector) < 0) + if (NULL == ret_value) { + if (conn_rc_incr && H5VL__conn_dec_rc(vol_connector) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__new_vol_obj() */ - /*------------------------------------------------------------------------- * Function: H5VL_conn_copy * @@ -625,41 +608,41 @@ done: herr_t H5VL_conn_copy(H5VL_connector_prop_t *connector_prop) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(connector_prop) { + if (connector_prop) { /* Copy the connector ID & info, if there is one */ - if(connector_prop->connector_id > 0) { + if (connector_prop->connector_id > 0) { /* Increment the reference count on connector ID and copy connector info */ - if(H5I_inc_ref(connector_prop->connector_id, FALSE) < 0) + if (H5I_inc_ref(connector_prop->connector_id, FALSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector ID") /* Copy connector info, if it exists */ - if(connector_prop->connector_info) { - H5VL_class_t *connector; /* Pointer to connector */ - void *new_connector_info = NULL; /* Copy of connector info */ + if (connector_prop->connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ + void * new_connector_info = NULL; /* Copy of connector info */ /* Retrieve the connector for the ID */ - if(NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop->connector_id))) + if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop->connector_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Allocate and copy connector info */ - if(H5VL_copy_connector_info(connector, &new_connector_info, connector_prop->connector_info) < 0) + if (H5VL_copy_connector_info(connector, &new_connector_info, connector_prop->connector_info) < + 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed") /* Set the connector info to the copy */ connector_prop->connector_info = new_connector_info; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_conn_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL_conn_free * @@ -673,20 +656,21 @@ done: herr_t H5VL_conn_free(const H5VL_connector_prop_t *connector_prop) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(connector_prop) { + if (connector_prop) { /* Free the connector info (if it exists) and decrement the ID */ - if(connector_prop->connector_id > 0) { - if(connector_prop->connector_info) + if (connector_prop->connector_id > 0) { + if (connector_prop->connector_info) /* Free the connector info */ - if(H5VL_free_connector_info(connector_prop->connector_id, connector_prop->connector_info) < 0) + if (H5VL_free_connector_info(connector_prop->connector_id, connector_prop->connector_info) < + 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") /* Decrement reference count for connector ID */ - if(H5I_dec_ref(connector_prop->connector_id) < 0) + if (H5I_dec_ref(connector_prop->connector_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for connector ID") } } @@ -695,7 +679,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_conn_free() */ - /*------------------------------------------------------------------------- * Function: H5VL_register * @@ -711,8 +694,8 @@ done: hid_t H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref) { - H5VL_object_t *vol_obj = NULL; /* VOL object wrapper for library object */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* VOL object wrapper for library object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -722,18 +705,17 @@ H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ /* Set up VOL object for the passed-in data */ /* (Does not wrap object, since it's from a VOL callback) */ - if(NULL == (vol_obj = H5VL__new_vol_obj(type, object, vol_connector, FALSE))) + if (NULL == (vol_obj = H5VL__new_vol_obj(type, object, vol_connector, FALSE))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") /* Register VOL object as _object_ type, for future object API calls */ - if((ret_value = H5I_register(type, vol_obj, app_ref)) < 0) + if ((ret_value = H5I_register(type, vol_obj, app_ref)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize handle") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_register() */ - /*------------------------------------------------------------------------- * Function: H5VL_register_using_existing_id * @@ -753,10 +735,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref, hid_t existing_id) +H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref, + hid_t existing_id) { - H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -766,18 +749,17 @@ H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_conne /* Set up VOL object for the passed-in data */ /* (Wraps object, since it's a library object) */ - if(NULL == (new_vol_obj = H5VL__new_vol_obj(type, object, vol_connector, TRUE))) + if (NULL == (new_vol_obj = H5VL__new_vol_obj(type, object, vol_connector, TRUE))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") /* Call the underlying H5I function to complete the registration */ - if(H5I_register_using_existing_id(type, new_vol_obj, app_ref, existing_id) < 0) + if (H5I_register_using_existing_id(type, new_vol_obj, app_ref, existing_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register object under existing ID") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_register_using_existing_id() */ - /*------------------------------------------------------------------------- * Function: H5VL_register_using_vol_id * @@ -793,46 +775,46 @@ done: hid_t H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref) { - H5VL_class_t *cls = NULL; /* VOL connector class */ - H5VL_t *connector = NULL; /* VOL connector struct */ - hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */ - hid_t ret_value = H5I_INVALID_HID;/* Return value */ + H5VL_class_t *cls = NULL; /* VOL connector class */ + H5VL_t * connector = NULL; /* VOL connector struct */ + hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the VOL class object from the connector's ID */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL connector ID") /* Setup VOL info struct */ - if(NULL == (connector = H5FL_CALLOC(H5VL_t))) + if (NULL == (connector = H5FL_CALLOC(H5VL_t))) HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate VOL info struct") connector->cls = cls; - connector->id = connector_id; - if(H5I_inc_ref(connector->id, FALSE) < 0) + connector->id = connector_id; + if (H5I_inc_ref(connector->id, FALSE) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") conn_id_incr = TRUE; /* Get an ID for the VOL object */ - if((ret_value = H5VL_register(type, obj, connector, app_ref)) < 0) + if ((ret_value = H5VL_register(type, obj, connector, app_ref)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") done: /* Clean up on error */ - if(ret_value < 0) { + if (ret_value < 0) { /* Decrement VOL connector ID ref count on error */ - if(conn_id_incr && H5I_dec_ref(connector_id) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement ref count on VOL connector") + if (conn_id_incr && H5I_dec_ref(connector_id) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement ref count on VOL connector") /* Free VOL connector struct */ - if(NULL != connector) + if (NULL != connector) connector = H5FL_FREE(H5VL_t, connector); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_register_using_vol_id() */ - /*------------------------------------------------------------------------- * Function: H5VL_create_object_using_vol_id * @@ -848,47 +830,46 @@ done: H5VL_object_t * H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id) { - H5VL_class_t *cls = NULL; /* VOL connector class */ - H5VL_t *connector = NULL; /* VOL connector struct */ - hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */ - H5VL_object_t *ret_value = NULL; /* Return value */ + H5VL_class_t * cls = NULL; /* VOL connector class */ + H5VL_t * connector = NULL; /* VOL connector struct */ + hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */ + H5VL_object_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Get the VOL class object from the connector's ID */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Setup VOL info struct */ - if(NULL == (connector = H5FL_CALLOC(H5VL_t))) + if (NULL == (connector = H5FL_CALLOC(H5VL_t))) HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate VOL info struct") connector->cls = cls; - connector->id = connector_id; - if(H5I_inc_ref(connector->id, FALSE) < 0) + connector->id = connector_id; + if (H5I_inc_ref(connector->id, FALSE) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL connector") conn_id_incr = TRUE; /* Set up VOL object for the passed-in data */ /* (Wraps object, since it's a library object) */ - if(NULL == (ret_value = H5VL__new_vol_obj(type, obj, connector, TRUE))) + if (NULL == (ret_value = H5VL__new_vol_obj(type, obj, connector, TRUE))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "can't create VOL object") done: /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Decrement VOL connector ID ref count on error */ - if(conn_id_incr && H5I_dec_ref(connector_id) < 0) + if (conn_id_incr && H5I_dec_ref(connector_id) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector") /* Free VOL connector struct */ - if(NULL != connector) + if (NULL != connector) connector = H5FL_FREE(H5VL_t, connector); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_create_object_using_vol_id() */ - /*------------------------------------------------------------------------- * Function: H5VL__conn_inc_rc * @@ -915,7 +896,6 @@ H5VL__conn_inc_rc(H5VL_t *connector) FUNC_LEAVE_NOAPI(connector->nrefs) } /* end H5VL__conn_inc_rc() */ - /*------------------------------------------------------------------------- * Function: H5VL__conn_dec_rc * @@ -931,7 +911,7 @@ H5VL__conn_inc_rc(H5VL_t *connector) static int64_t H5VL__conn_dec_rc(H5VL_t *connector) { - int64_t ret_value = -1; /* Return value */ + int64_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -942,8 +922,8 @@ H5VL__conn_dec_rc(H5VL_t *connector) connector->nrefs--; /* Check for last reference */ - if(0 == connector->nrefs) { - if(H5I_dec_ref(connector->id) < 0) + if (0 == connector->nrefs) { + if (H5I_dec_ref(connector->id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") H5FL_FREE(H5VL_t, connector); @@ -958,7 +938,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__conn_dec_rc() */ - /*------------------------------------------------------------------------- * Function: H5VL_free_object * @@ -972,7 +951,7 @@ done: herr_t H5VL_free_object(H5VL_object_t *vol_obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -980,7 +959,7 @@ H5VL_free_object(H5VL_object_t *vol_obj) HDassert(vol_obj); /* Decrement refcount on connector */ - if(H5VL__conn_dec_rc(vol_obj->connector) < 0) + if (H5VL__conn_dec_rc(vol_obj->connector) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") vol_obj = H5FL_FREE(H5VL_object_t, vol_obj); @@ -989,7 +968,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_free_object() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_is_native * @@ -1006,10 +984,10 @@ done: herr_t H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native) { - const H5VL_class_t *cls; /* VOL connector class structs for object */ - const H5VL_class_t *native_cls; /* Native VOL connector class structs */ - int cmp_value; /* Comparison result */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5VL_class_t *cls; /* VOL connector class structs for object */ + const H5VL_class_t *native_cls; /* Native VOL connector class structs */ + int cmp_value; /* Comparison result */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1019,15 +997,15 @@ H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native) /* Retrieve the terminal connector class for the object */ cls = NULL; - if(H5VL_introspect_get_conn_cls(obj, H5VL_GET_CONN_LVL_TERM, &cls) < 0) + if (H5VL_introspect_get_conn_cls(obj, H5VL_GET_CONN_LVL_TERM, &cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector class") /* Retrieve the native connector class */ - if(NULL == (native_cls = (H5VL_class_t *)H5I_object_verify(H5VL_NATIVE, H5I_VOL))) + if (NULL == (native_cls = (H5VL_class_t *)H5I_object_verify(H5VL_NATIVE, H5I_VOL))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve native VOL connector class") /* Compare connector classes */ - if(H5VL_cmp_connector_cls(&cmp_value, cls, native_cls) < 0) + if (H5VL_cmp_connector_cls(&cmp_value, cls, native_cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") /* If classes compare equal, then the object is / is in a native connector's file */ @@ -1037,7 +1015,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_is_native() */ - /*------------------------------------------------------------------------- * Function: H5VL_file_is_same * @@ -1051,13 +1028,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, - hbool_t *same_file) +H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, hbool_t *same_file) { - const H5VL_class_t *cls1; /* VOL connector class struct for first object */ - const H5VL_class_t *cls2; /* VOL connector class struct for second object */ - int cmp_value; /* Comparison result */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5VL_class_t *cls1; /* VOL connector class struct for first object */ + const H5VL_class_t *cls2; /* VOL connector class struct for second object */ + int cmp_value; /* Comparison result */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1068,28 +1044,29 @@ H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, /* Retrieve the terminal connectors for each object */ cls1 = NULL; - if(H5VL_introspect_get_conn_cls(vol_obj1, H5VL_GET_CONN_LVL_TERM, &cls1) < 0) + if (H5VL_introspect_get_conn_cls(vol_obj1, H5VL_GET_CONN_LVL_TERM, &cls1) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector class") cls2 = NULL; - if(H5VL_introspect_get_conn_cls(vol_obj2, H5VL_GET_CONN_LVL_TERM, &cls2) < 0) + if (H5VL_introspect_get_conn_cls(vol_obj2, H5VL_GET_CONN_LVL_TERM, &cls2) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector class") /* Compare connector classes */ - if(H5VL_cmp_connector_cls(&cmp_value, cls1, cls2) < 0) + if (H5VL_cmp_connector_cls(&cmp_value, cls1, cls2) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") /* If the connector classes are different, the files are different */ - if(cmp_value) + if (cmp_value) *same_file = FALSE; else { - void *obj2; /* Terminal object for second file */ + void *obj2; /* Terminal object for second file */ /* Get unwrapped (terminal) object for vol_obj2 */ - if(NULL == (obj2 = H5VL_object_data(vol_obj2))) + if (NULL == (obj2 = H5VL_object_data(vol_obj2))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get unwrapped object") /* Make callback */ - if(H5VL_file_specific(vol_obj1, H5VL_FILE_IS_EQUAL, H5P_DATASET_XFER_DEFAULT, NULL, obj2, same_file) < 0) + if (H5VL_file_specific(vol_obj1, H5VL_FILE_IS_EQUAL, H5P_DATASET_XFER_DEFAULT, NULL, obj2, + same_file) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") } /* end else */ @@ -1097,7 +1074,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_is_same() */ - /*------------------------------------------------------------------------- * Function: H5VL_register_connector * @@ -1117,9 +1093,9 @@ done: hid_t H5VL_register_connector(const void *_cls, hbool_t app_ref, hid_t vipl_id) { - const H5VL_class_t *cls = (const H5VL_class_t *)_cls; - H5VL_class_t *saved = NULL; - hid_t ret_value = H5I_INVALID_HID; + const H5VL_class_t *cls = (const H5VL_class_t *)_cls; + H5VL_class_t * saved = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -1127,23 +1103,25 @@ H5VL_register_connector(const void *_cls, hbool_t app_ref, hid_t vipl_id) HDassert(cls); /* Copy the class structure so the caller can reuse or free it */ - if(NULL == (saved = H5FL_MALLOC(H5VL_class_t))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "memory allocation failed for VOL connector class struct") + if (NULL == (saved = H5FL_MALLOC(H5VL_class_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, + "memory allocation failed for VOL connector class struct") H5MM_memcpy(saved, cls, sizeof(H5VL_class_t)); - if(NULL == (saved->name = H5MM_strdup(cls->name))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "memory allocation failed for VOL connector name") + if (NULL == (saved->name = H5MM_strdup(cls->name))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, + "memory allocation failed for VOL connector name") /* Initialize the VOL connector */ - if(cls->initialize && cls->initialize(vipl_id) < 0) + if (cls->initialize && cls->initialize(vipl_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to init VOL connector") /* Create the new class ID */ - if((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0) + if ((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") done: - if(ret_value < 0 && saved) { - if(saved->name) + if (ret_value < 0 && saved) { + if (saved->name) H5MM_xfree_const(saved->name); H5FL_FREE(H5VL_class_t, saved); @@ -1152,7 +1130,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_register_connector() */ - /*------------------------------------------------------------------------- * Function: H5VL__register_connector * @@ -1173,29 +1150,30 @@ done: hid_t H5VL__register_connector(const H5VL_class_t *cls, hbool_t app_ref, hid_t vipl_id) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.u.name = cls->name; + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = cls->name; op_data.found_id = H5I_INVALID_HID; /* Check if connector is already registered */ - if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL IDs") /* Increment the ref count on the existing VOL connector ID, if it's already registered */ - if(op_data.found_id != H5I_INVALID_HID) { - if(H5I_inc_ref(op_data.found_id, app_ref) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + if (op_data.found_id != H5I_INVALID_HID) { + if (H5I_inc_ref(op_data.found_id, app_ref) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, + "unable to increment ref count on VOL connector") ret_value = op_data.found_id; } /* end if */ else { /* Create a new class ID */ - if((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0) + if ((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") } /* end else */ @@ -1203,7 +1181,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__register_connector() */ - /*------------------------------------------------------------------------- * Function: H5VL__register_connector_by_name * @@ -1224,38 +1201,39 @@ done: hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_id) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.u.name = name; + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; op_data.found_id = H5I_INVALID_HID; /* Check if connector is already registered */ - if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids") /* If connector alread registered, increment ref count on ID and return ID */ - if(op_data.found_id != H5I_INVALID_HID) { - if(H5I_inc_ref(op_data.found_id, app_ref) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + if (op_data.found_id != H5I_INVALID_HID) { + if (H5I_inc_ref(op_data.found_id, app_ref) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, + "unable to increment ref count on VOL connector") ret_value = op_data.found_id; } /* end if */ else { - H5PL_key_t key; + H5PL_key_t key; const H5VL_class_t *cls; /* Try loading the connector */ - key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; key.vol.u.name = name; - if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) + if (NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") /* Register the connector we loaded */ - if((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0) + if ((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") } /* end else */ @@ -1263,7 +1241,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__register_connector_by_name() */ - /*------------------------------------------------------------------------- * Function: H5VL__register_connector_by_value * @@ -1284,38 +1261,39 @@ done: hid_t H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid_t vipl_id) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.u.value = value; + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; op_data.found_id = H5I_INVALID_HID; /* Check if connector is already registered */ - if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids") /* If connector alread registered, increment ref count on ID and return ID */ - if(op_data.found_id != H5I_INVALID_HID) { - if(H5I_inc_ref(op_data.found_id, app_ref) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + if (op_data.found_id != H5I_INVALID_HID) { + if (H5I_inc_ref(op_data.found_id, app_ref) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, + "unable to increment ref count on VOL connector") ret_value = op_data.found_id; } /* end if */ else { - H5PL_key_t key; + H5PL_key_t key; const H5VL_class_t *cls; /* Try loading the connector */ - key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE; + key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE; key.vol.u.value = value; - if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) + if (NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") /* Register the connector we loaded */ - if((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0) + if ((ret_value = H5VL_register_connector(cls, app_ref, vipl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") } /* end else */ @@ -1323,7 +1301,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__register_connector_by_value() */ - /*------------------------------------------------------------------------- * Function: H5VL__is_connector_registered_by_name * @@ -1340,29 +1317,28 @@ done: htri_t H5VL__is_connector_registered_by_name(const char *name) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - htri_t ret_value = FALSE; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.u.name = name; + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; op_data.found_id = H5I_INVALID_HID; /* Find connector with name */ - if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors") /* Found a connector with that name */ - if(op_data.found_id != H5I_INVALID_HID) + if (op_data.found_id != H5I_INVALID_HID) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__is_connector_registered_by_name() */ - /*------------------------------------------------------------------------- * Function: H5VL__is_connector_registered_by_value * @@ -1377,29 +1353,28 @@ done: htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - htri_t ret_value = FALSE; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.u.value = value; + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; op_data.found_id = H5I_INVALID_HID; /* Find connector with value */ - if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors") /* Found a connector with that name */ - if(op_data.found_id != H5I_INVALID_HID) + if (op_data.found_id != H5I_INVALID_HID) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__is_connector_registered_by_value() */ - /*------------------------------------------------------------------------- * Function: H5VL__get_connector_id * @@ -1416,25 +1391,24 @@ done: hid_t H5VL__get_connector_id(hid_t obj_id, hbool_t is_api) { - H5VL_object_t *vol_obj = NULL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Get the underlying VOL object for the object ID */ - if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Return the VOL object's VOL class ID */ ret_value = vol_obj->connector->id; - if(H5I_inc_ref(ret_value, is_api) < 0) + if (H5I_inc_ref(ret_value, is_api) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__get_connector_id() */ - /*------------------------------------------------------------------------- * Function: H5VL__get_connector_id_by_name * @@ -1451,23 +1425,22 @@ done: hid_t H5VL__get_connector_id_by_name(const char *name, hbool_t is_api) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Find connector with name */ - if((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) + if ((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector") /* Found a connector with that name */ - if(H5I_inc_ref(ret_value, is_api) < 0) + if (H5I_inc_ref(ret_value, is_api) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__get_connector_id_by_name() */ - /*------------------------------------------------------------------------- * Function: H5VL__get_connector_id_by_value * @@ -1482,23 +1455,22 @@ done: hid_t H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Find connector with value */ - if((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) + if ((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector") /* Found a connector with that value */ - if(H5I_inc_ref(ret_value, is_api) < 0) + if (H5I_inc_ref(ret_value, is_api) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__get_connector_id_by_value() */ - /*------------------------------------------------------------------------- * Function: H5VL__peek_connector_id_by_name * @@ -1514,18 +1486,18 @@ done: hid_t H5VL__peek_connector_id_by_name(const char *name) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.u.name = name; + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; op_data.found_id = H5I_INVALID_HID; /* Find connector with name */ - if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors") /* Set return value */ @@ -1535,7 +1507,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__peek_connector_id_by_name() */ - /*------------------------------------------------------------------------- * Function: H5VL__peek_connector_id_by_value * @@ -1551,18 +1522,18 @@ done: hid_t H5VL__peek_connector_id_by_value(H5VL_class_value_t value) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.u.value = value; + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; op_data.found_id = H5I_INVALID_HID; /* Find connector with value */ - if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors") /* Set return value */ @@ -1572,7 +1543,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__peek_connector_id_by_value() */ - /*------------------------------------------------------------------------- * Function: H5VL__connector_str_to_info * @@ -1589,21 +1559,21 @@ done: herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Only deserialize string, if it's non-NULL */ - if(str) { - H5VL_class_t *cls; /* VOL connector's class struct */ + if (str) { + H5VL_class_t *cls; /* VOL connector's class struct */ /* Check args and get class pointer */ - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Allow the connector to deserialize info */ - if(cls->info_cls.from_str) { - if((cls->info_cls.from_str)(str, info) < 0) + if (cls->info_cls.from_str) { + if ((cls->info_cls.from_str)(str, info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize connector info") } /* end if */ else @@ -1616,7 +1586,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__connector_str_to_info() */ - /*------------------------------------------------------------------------- * Function: H5VL__get_connector_name * @@ -1630,8 +1599,8 @@ done: ssize_t H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size) { - H5VL_object_t *vol_obj; - const H5VL_class_t *cls; + H5VL_object_t * vol_obj; + const H5VL_class_t *cls; size_t len; ssize_t ret_value = -1; @@ -1644,9 +1613,9 @@ H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size) cls = vol_obj->connector->cls; len = HDstrlen(cls->name); - if(name) { + if (name) { HDstrncpy(name, cls->name, MIN(len + 1, size)); - if(len >= size) + if (len >= size) name[size - 1] = '\0'; } /* end if */ @@ -1657,7 +1626,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__get_connector_name() */ - /*------------------------------------------------------------------------- * Function: H5VL_vol_object * @@ -1674,22 +1642,22 @@ done: H5VL_object_t * H5VL_vol_object(hid_t id) { - void *obj = NULL; - H5I_type_t obj_type; - H5VL_object_t *ret_value = NULL; + void * obj = NULL; + H5I_type_t obj_type; + H5VL_object_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) obj_type = H5I_get_type(id); - if(H5I_FILE == obj_type || H5I_GROUP == obj_type || H5I_ATTR == obj_type || - H5I_DATASET == obj_type || H5I_DATATYPE == obj_type) { + if (H5I_FILE == obj_type || H5I_GROUP == obj_type || H5I_ATTR == obj_type || H5I_DATASET == obj_type || + H5I_DATATYPE == obj_type) { /* Get the object */ - if(NULL == (obj = H5I_object(id))) + if (NULL == (obj = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") /* If this is a datatype, get the VOL object attached to the H5T_t struct */ - if(H5I_DATATYPE == obj_type) - if(NULL == (obj = H5T_get_named_type((H5T_t *)obj))) + if (H5I_DATATYPE == obj_type) + if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") } /* end if */ else @@ -1701,7 +1669,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_vol_object() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_data * @@ -1721,7 +1688,7 @@ H5VL_object_data(const H5VL_object_t *vol_obj) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check for 'get_object' callback in connector */ - if(vol_obj->connector->cls->wrap_cls.get_object) + if (vol_obj->connector->cls->wrap_cls.get_object) ret_value = (vol_obj->connector->cls->wrap_cls.get_object)(vol_obj->data); else ret_value = vol_obj->data; @@ -1729,7 +1696,6 @@ H5VL_object_data(const H5VL_object_t *vol_obj) FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_data() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_unwrap * @@ -1748,14 +1714,13 @@ H5VL_object_unwrap(const H5VL_object_t *vol_obj) FUNC_ENTER_NOAPI(NULL) - if(NULL == (ret_value = H5VL_unwrap_object(vol_obj->connector->cls, vol_obj->data))) + if (NULL == (ret_value = H5VL_unwrap_object(vol_obj->connector->cls, vol_obj->data))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't unwrap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_unwrap() */ - /*------------------------------------------------------------------------- * Function: H5VL__object * @@ -1770,13 +1735,13 @@ done: static void * H5VL__object(hid_t id, H5I_type_t obj_type) { - H5VL_object_t *vol_obj = NULL; - void *ret_value = NULL; + H5VL_object_t *vol_obj = NULL; + void * ret_value = NULL; FUNC_ENTER_STATIC /* Get the underlying object */ - switch(obj_type) { + switch (obj_type) { case H5I_GROUP: case H5I_DATASET: case H5I_FILE: @@ -1787,19 +1752,18 @@ H5VL__object(hid_t id, H5I_type_t obj_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") break; - case H5I_DATATYPE: - { - H5T_t *dt = NULL; + case H5I_DATATYPE: { + H5T_t *dt = NULL; - /* get the object */ - if (NULL == (dt = (H5T_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + /* get the object */ + if (NULL == (dt = (H5T_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") - /* Get the actual datatype object that should be the vol_obj */ - if (NULL == (vol_obj = H5T_get_named_type(dt))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") - break; - } + /* Get the actual datatype object that should be the vol_obj */ + if (NULL == (vol_obj = H5T_get_named_type(dt))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") + break; + } case H5I_UNINIT: case H5I_BADID: @@ -1824,7 +1788,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__object() */ - /*------------------------------------------------------------------------- * Function: H5VL_object * @@ -1839,19 +1802,18 @@ done: void * H5VL_object(hid_t id) { - void *ret_value = NULL; + void *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) /* Get the underlying object */ - if(NULL == (ret_value = H5VL__object(id, H5I_get_type(id)))) + if (NULL == (ret_value = H5VL__object(id, H5I_get_type(id)))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't retrieve object for ID") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object() */ - /*------------------------------------------------------------------------- * Function: H5VL_object_verify * @@ -1866,23 +1828,22 @@ done: void * H5VL_object_verify(hid_t id, H5I_type_t obj_type) { - void *ret_value = NULL; + void *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) /* Check of ID of correct type */ - if(obj_type != H5I_get_type(id)) + if (obj_type != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") /* Get the underlying object */ - if(NULL == (ret_value = H5VL__object(id, obj_type))) + if (NULL == (ret_value = H5VL__object(id, obj_type))) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, NULL, "can't retrieve object for ID") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_verify() */ - /*------------------------------------------------------------------------- * Function: H5VL_cmp_connector_cls * @@ -1899,7 +1860,7 @@ done: herr_t H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1908,51 +1869,51 @@ H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_clas HDassert(cls2); /* If the pointers are the same the classes are the same */ - if(cls1 == cls2) { + if (cls1 == cls2) { *cmp_value = 0; HGOTO_DONE(SUCCEED); } /* end if */ /* Compare connector "values" */ - if(cls1->value < cls2->value) { + if (cls1->value < cls2->value) { *cmp_value = -1; HGOTO_DONE(SUCCEED) } /* end if */ - if(cls1->value > cls2->value) { + if (cls1->value > cls2->value) { *cmp_value = 1; HGOTO_DONE(SUCCEED) } /* end if */ HDassert(cls1->value == cls2->value); /* Compare connector names */ - if(cls1->name == NULL && cls2->name != NULL) { + if (cls1->name == NULL && cls2->name != NULL) { *cmp_value = -1; HGOTO_DONE(SUCCEED) } /* end if */ - if(cls1->name != NULL && cls2->name == NULL) { + if (cls1->name != NULL && cls2->name == NULL) { *cmp_value = 1; HGOTO_DONE(SUCCEED) } /* end if */ - if(0 != (*cmp_value = HDstrcmp(cls1->name, cls2->name))) + if (0 != (*cmp_value = HDstrcmp(cls1->name, cls2->name))) HGOTO_DONE(SUCCEED) /* Compare connector VOL API versions */ - if(cls1->version < cls2->version) { + if (cls1->version < cls2->version) { *cmp_value = -1; HGOTO_DONE(SUCCEED) } /* end if */ - if(cls1->version > cls2->version) { + if (cls1->version > cls2->version) { *cmp_value = 1; HGOTO_DONE(SUCCEED) } /* end if */ HDassert(cls1->version == cls2->version); /* Compare connector info */ - if(cls1->info_cls.size < cls2->info_cls.size) { + if (cls1->info_cls.size < cls2->info_cls.size) { *cmp_value = -1; HGOTO_DONE(SUCCEED) } /* end if */ - if(cls1->info_cls.size > cls2->info_cls.size) { + if (cls1->info_cls.size > cls2->info_cls.size) { *cmp_value = 1; HGOTO_DONE(SUCCEED) } /* end if */ @@ -1965,7 +1926,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_cmp_connector_cls() */ - /*------------------------------------------------------------------------- * Function: H5VL_retrieve_lib_state * @@ -1982,7 +1942,7 @@ done: herr_t H5VL_retrieve_lib_state(void **state) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1990,14 +1950,13 @@ H5VL_retrieve_lib_state(void **state) HDassert(state); /* Retrieve the API context state */ - if(H5CX_retrieve_state((H5CX_state_t **)state) < 0) + if (H5CX_retrieve_state((H5CX_state_t **)state) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get API context state") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_retrieve_lib_state() */ - /*------------------------------------------------------------------------- * Function: H5VL_restore_lib_state * @@ -2016,7 +1975,7 @@ done: herr_t H5VL_restore_lib_state(const void *state) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2024,18 +1983,17 @@ H5VL_restore_lib_state(const void *state) HDassert(state); /* Push a new API context on the stack */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't push API context") /* Restore the API context state */ - if(H5CX_restore_state((const H5CX_state_t *)state) < 0) + if (H5CX_restore_state((const H5CX_state_t *)state) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set API context state") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_restore_lib_state() */ - /*------------------------------------------------------------------------- * Function: H5VL_reset_lib_state * @@ -2059,19 +2017,18 @@ done: herr_t H5VL_reset_lib_state(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Pop the API context off the stack */ - if(H5CX_pop() < 0) + if (H5CX_pop() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't pop API context") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_reset_lib_state() */ - /*------------------------------------------------------------------------- * Function: H5VL_free_lib_state * @@ -2090,7 +2047,7 @@ done: herr_t H5VL_free_lib_state(void *state) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2098,14 +2055,13 @@ H5VL_free_lib_state(void *state) HDassert(state); /* Free the API context state */ - if(H5CX_free_state((H5CX_state_t *)state) < 0) + if (H5CX_free_state((H5CX_state_t *)state) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free API context state") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_free_lib_state() */ - /*------------------------------------------------------------------------- * Function: H5VL__free_vol_wrapper * @@ -2121,7 +2077,7 @@ done: static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2132,13 +2088,14 @@ H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx) HDassert(vol_wrap_ctx->connector->cls); /* If there is a VOL connector object wrapping context, release it */ - if(vol_wrap_ctx->obj_wrap_ctx) + if (vol_wrap_ctx->obj_wrap_ctx) /* Release the VOL connector's object wrapping context */ - if((*vol_wrap_ctx->connector->cls->wrap_cls.free_wrap_ctx)(vol_wrap_ctx->obj_wrap_ctx) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release connector's object wrapping context") + if ((*vol_wrap_ctx->connector->cls->wrap_cls.free_wrap_ctx)(vol_wrap_ctx->obj_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, + "unable to release connector's object wrapping context") /* Decrement refcount on connector */ - if(H5VL__conn_dec_rc(vol_wrap_ctx->connector) < 0) + if (H5VL__conn_dec_rc(vol_wrap_ctx->connector) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") /* Release object wrapping context */ @@ -2148,7 +2105,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__free_vol_wrapper() */ - /*------------------------------------------------------------------------- * Function: H5VL_set_vol_wrapper * @@ -2161,8 +2117,8 @@ done: herr_t H5VL_set_vol_wrapper(const H5VL_object_t *vol_obj) { - H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2170,37 +2126,37 @@ H5VL_set_vol_wrapper(const H5VL_object_t *vol_obj) HDassert(vol_obj); /* Retrieve the VOL object wrap context */ - if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL object wrap context") /* Check for existing wrapping context */ - if(NULL == vol_wrap_ctx) { - void *obj_wrap_ctx = NULL; /* VOL connector's wrapping context */ + if (NULL == vol_wrap_ctx) { + void *obj_wrap_ctx = NULL; /* VOL connector's wrapping context */ /* Sanity checks */ HDassert(vol_obj->data); HDassert(vol_obj->connector); /* Check if the connector can create a wrap context */ - if(vol_obj->connector->cls->wrap_cls.get_wrap_ctx) { + if (vol_obj->connector->cls->wrap_cls.get_wrap_ctx) { /* Sanity check */ HDassert(vol_obj->connector->cls->wrap_cls.free_wrap_ctx); /* Get the wrap context from the connector */ - if((vol_obj->connector->cls->wrap_cls.get_wrap_ctx)(vol_obj->data, &obj_wrap_ctx) < 0) + if ((vol_obj->connector->cls->wrap_cls.get_wrap_ctx)(vol_obj->data, &obj_wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve VOL connector's object wrap context") } /* end if */ /* Allocate VOL object wrapper context */ - if(NULL == (vol_wrap_ctx = H5FL_MALLOC(H5VL_wrap_ctx_t))) + if (NULL == (vol_wrap_ctx = H5FL_MALLOC(H5VL_wrap_ctx_t))) HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate VOL wrap context") /* Increment the outstanding objects that are using the connector */ H5VL__conn_inc_rc(vol_obj->connector); /* Set up VOL object wrapper context */ - vol_wrap_ctx->rc = 1; - vol_wrap_ctx->connector = vol_obj->connector; + vol_wrap_ctx->rc = 1; + vol_wrap_ctx->connector = vol_obj->connector; vol_wrap_ctx->obj_wrap_ctx = obj_wrap_ctx; } /* end if */ else @@ -2208,18 +2164,17 @@ H5VL_set_vol_wrapper(const H5VL_object_t *vol_obj) vol_wrap_ctx->rc++; /* Save the wrapper context */ - if(H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0) + if (H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") done: - if(ret_value < 0 && vol_wrap_ctx) + if (ret_value < 0 && vol_wrap_ctx) /* Release object wrapping context */ H5FL_FREE(H5VL_wrap_ctx_t, vol_wrap_ctx); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_set_vol_wrapper() */ - /*------------------------------------------------------------------------- * Function: H5VL_inc_vol_wrapper * @@ -2236,14 +2191,14 @@ herr_t H5VL_inc_vol_wrapper(void *_vol_wrap_ctx) { H5VL_wrap_ctx_t *vol_wrap_ctx = (H5VL_wrap_ctx_t *)_vol_wrap_ctx; /* VOL object wrapping context */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check for valid, active VOL object wrap context */ - if(NULL == vol_wrap_ctx) + if (NULL == vol_wrap_ctx) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?") - if(0 == vol_wrap_ctx->rc) + if (0 == vol_wrap_ctx->rc) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "bad VOL object wrap context refcount?") /* Increment ref count on wrapping context */ @@ -2253,7 +2208,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_inc_vol_wrapper() */ - /*------------------------------------------------------------------------- * Function: H5VL_dec_vol_wrapper * @@ -2271,29 +2225,28 @@ herr_t H5VL_dec_vol_wrapper(void *_vol_wrap_ctx) { H5VL_wrap_ctx_t *vol_wrap_ctx = (H5VL_wrap_ctx_t *)_vol_wrap_ctx; /* VOL object wrapping context */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check for valid, active VOL object wrap context */ - if(NULL == vol_wrap_ctx) + if (NULL == vol_wrap_ctx) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?") - if(0 == vol_wrap_ctx->rc) + if (0 == vol_wrap_ctx->rc) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "bad VOL object wrap context refcount?") /* Decrement ref count on wrapping context */ vol_wrap_ctx->rc--; /* Release context if the ref count drops to zero */ - if(0 == vol_wrap_ctx->rc) - if(H5VL__free_vol_wrapper(vol_wrap_ctx) < 0) + if (0 == vol_wrap_ctx->rc) + if (H5VL__free_vol_wrapper(vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL object wrapping context") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dec_vol_wrapper() */ - /*------------------------------------------------------------------------- * Function: H5VL_reset_vol_wrapper * @@ -2306,42 +2259,41 @@ done: herr_t H5VL_reset_vol_wrapper(void) { - H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Retrieve the VOL object wrap context */ - if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL object wrap context") /* Check for VOL object wrap context */ - if(NULL == vol_wrap_ctx) + if (NULL == vol_wrap_ctx) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?") /* Decrement ref count on wrapping context */ vol_wrap_ctx->rc--; /* Release context if the ref count drops to zero */ - if(0 == vol_wrap_ctx->rc) { + if (0 == vol_wrap_ctx->rc) { /* Release object wrapping context */ - if(H5VL__free_vol_wrapper(vol_wrap_ctx) < 0) + if (H5VL__free_vol_wrapper(vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL object wrapping context") /* Reset the wrapper context */ - if(H5CX_set_vol_wrap_ctx(NULL) < 0) + if (H5CX_set_vol_wrap_ctx(NULL) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") } /* end if */ else /* Save the updated wrapper context */ - if(H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") + if (H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_reset_vol_wrapper() */ - /*------------------------------------------------------------------------- * Function: H5VL_wrap_register * @@ -2354,9 +2306,9 @@ done: hid_t H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref) { - H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ - void *new_obj; /* Newly wrapped object */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + void * new_obj; /* Newly wrapped object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -2366,25 +2318,25 @@ H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref) /* If the datatype is already VOL-managed, the datatype's vol_obj * field will get clobbered later, so disallow this. */ - if(type == H5I_DATATYPE) - if(TRUE == H5T_already_vol_managed((const H5T_t *)obj)) + if (type == H5I_DATATYPE) + if (TRUE == H5T_already_vol_managed((const H5T_t *)obj)) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "can't wrap an uncommitted datatype") /* Wrap the object with VOL connector info */ - if(NULL == (new_obj = H5VL__wrap_obj(obj, type))) + if (NULL == (new_obj = H5VL__wrap_obj(obj, type))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't wrap library object") /* Retrieve the VOL object wrapping context */ - if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context") - if(NULL == vol_wrap_ctx || NULL == vol_wrap_ctx->connector) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "VOL object wrap context or its connector is NULL???") + if (NULL == vol_wrap_ctx || NULL == vol_wrap_ctx->connector) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, + "VOL object wrap context or its connector is NULL???") /* Get an ID for the object */ - if((ret_value = H5VL_register_using_vol_id(type, new_obj, vol_wrap_ctx->connector->id, app_ref)) < 0) + if ((ret_value = H5VL_register_using_vol_id(type, new_obj, vol_wrap_ctx->connector->id, app_ref)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_wrap_register() */ - diff --git a/src/H5VLmodule.h b/src/H5VLmodule.h index 1ae0d61..1ff9137 100644 --- a/src/H5VLmodule.h +++ b/src/H5VLmodule.h @@ -23,9 +23,8 @@ * reporting macros. */ #define H5VL_MODULE -#define H5_MY_PKG H5VL -#define H5_MY_PKG_ERR H5E_VOL -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5VL +#define H5_MY_PKG_ERR H5E_VOL +#define H5_MY_PKG_INIT YES #endif /* _H5VLmodule_H */ - diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 616ca60..0973e34 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -15,21 +15,20 @@ * using HDF5 VFDs. */ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /* The VOL connector identification number */ static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; @@ -38,113 +37,125 @@ static herr_t H5VL__native_term(void); /* Native VOL connector class struct */ static const H5VL_class_t H5VL_native_cls_g = { - H5VL_NATIVE_VERSION, /* version */ - H5VL_NATIVE_VALUE, /* value */ - H5VL_NATIVE_NAME, /* name */ - 0, /* capability flags */ - NULL, /* initialize */ - H5VL__native_term, /* terminate */ - { /* info_cls */ - (size_t)0, /* info size */ - NULL, /* info copy */ - NULL, /* info compare */ - NULL, /* info free */ - NULL, /* info to str */ - NULL /* str to info */ + H5VL_NATIVE_VERSION, /* version */ + H5VL_NATIVE_VALUE, /* value */ + H5VL_NATIVE_NAME, /* name */ + 0, /* capability flags */ + NULL, /* initialize */ + H5VL__native_term, /* terminate */ + { + /* info_cls */ + (size_t)0, /* info size */ + NULL, /* info copy */ + NULL, /* info compare */ + NULL, /* info free */ + NULL, /* info to str */ + NULL /* str to info */ }, - { /* wrap_cls */ - NULL, /* get_object */ - NULL, /* get_wrap_ctx */ - NULL, /* wrap_object */ - NULL, /* unwrap_object */ - NULL /* free_wrap_ctx */ + { + /* wrap_cls */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL /* free_wrap_ctx */ }, - { /* attribute_cls */ - H5VL__native_attr_create, /* create */ - H5VL__native_attr_open, /* open */ - H5VL__native_attr_read, /* read */ - H5VL__native_attr_write, /* write */ - H5VL__native_attr_get, /* get */ - H5VL__native_attr_specific, /* specific */ - H5VL__native_attr_optional, /* optional */ - H5VL__native_attr_close /* close */ + { + /* attribute_cls */ + H5VL__native_attr_create, /* create */ + H5VL__native_attr_open, /* open */ + H5VL__native_attr_read, /* read */ + H5VL__native_attr_write, /* write */ + H5VL__native_attr_get, /* get */ + H5VL__native_attr_specific, /* specific */ + H5VL__native_attr_optional, /* optional */ + H5VL__native_attr_close /* close */ }, - { /* dataset_cls */ - H5VL__native_dataset_create, /* create */ - H5VL__native_dataset_open, /* open */ - H5VL__native_dataset_read, /* read */ - H5VL__native_dataset_write, /* write */ - H5VL__native_dataset_get, /* get */ - H5VL__native_dataset_specific, /* specific */ - H5VL__native_dataset_optional, /* optional */ - H5VL__native_dataset_close /* close */ + { + /* dataset_cls */ + H5VL__native_dataset_create, /* create */ + H5VL__native_dataset_open, /* open */ + H5VL__native_dataset_read, /* read */ + H5VL__native_dataset_write, /* write */ + H5VL__native_dataset_get, /* get */ + H5VL__native_dataset_specific, /* specific */ + H5VL__native_dataset_optional, /* optional */ + H5VL__native_dataset_close /* close */ }, - { /* datatype_cls */ - H5VL__native_datatype_commit, /* commit */ - H5VL__native_datatype_open, /* open */ - H5VL__native_datatype_get, /* get */ - H5VL__native_datatype_specific, /* specific */ - NULL, /* optional */ - H5VL__native_datatype_close /* close */ + { + /* datatype_cls */ + H5VL__native_datatype_commit, /* commit */ + H5VL__native_datatype_open, /* open */ + H5VL__native_datatype_get, /* get */ + H5VL__native_datatype_specific, /* specific */ + NULL, /* optional */ + H5VL__native_datatype_close /* close */ }, - { /* file_cls */ - H5VL__native_file_create, /* create */ - H5VL__native_file_open, /* open */ - H5VL__native_file_get, /* get */ - H5VL__native_file_specific, /* specific */ - H5VL__native_file_optional, /* optional */ - H5VL__native_file_close /* close */ + { + /* file_cls */ + H5VL__native_file_create, /* create */ + H5VL__native_file_open, /* open */ + H5VL__native_file_get, /* get */ + H5VL__native_file_specific, /* specific */ + H5VL__native_file_optional, /* optional */ + H5VL__native_file_close /* close */ }, - { /* group_cls */ - H5VL__native_group_create, /* create */ - H5VL__native_group_open, /* open */ - H5VL__native_group_get, /* get */ - H5VL__native_group_specific, /* specific */ - H5VL__native_group_optional, /* optional */ - H5VL__native_group_close /* close */ + { + /* group_cls */ + H5VL__native_group_create, /* create */ + H5VL__native_group_open, /* open */ + H5VL__native_group_get, /* get */ + H5VL__native_group_specific, /* specific */ + H5VL__native_group_optional, /* optional */ + H5VL__native_group_close /* close */ }, - { /* link_cls */ - H5VL__native_link_create, /* create */ - H5VL__native_link_copy, /* copy */ - H5VL__native_link_move, /* move */ - H5VL__native_link_get, /* get */ - H5VL__native_link_specific, /* specific */ - NULL /* optional */ + { + /* link_cls */ + H5VL__native_link_create, /* create */ + H5VL__native_link_copy, /* copy */ + H5VL__native_link_move, /* move */ + H5VL__native_link_get, /* get */ + H5VL__native_link_specific, /* specific */ + NULL /* optional */ }, - { /* object_cls */ - H5VL__native_object_open, /* open */ - H5VL__native_object_copy, /* copy */ - H5VL__native_object_get, /* get */ - H5VL__native_object_specific, /* specific */ - H5VL__native_object_optional /* optional */ + { + /* object_cls */ + H5VL__native_object_open, /* open */ + H5VL__native_object_copy, /* copy */ + H5VL__native_object_get, /* get */ + H5VL__native_object_specific, /* specific */ + H5VL__native_object_optional /* optional */ }, - { /* introspect_cls */ - H5VL__native_introspect_get_conn_cls, /* get_conn_cls */ - H5VL__native_introspect_opt_query, /* opt_query */ + { + /* introspect_cls */ + H5VL__native_introspect_get_conn_cls, /* get_conn_cls */ + H5VL__native_introspect_opt_query, /* opt_query */ }, - { /* request_cls */ - NULL, /* wait */ - NULL, /* notify */ - NULL, /* cancel */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* free */ + { + /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ }, - { /* blob_cls */ - H5VL__native_blob_put, /* put */ - H5VL__native_blob_get, /* get */ - H5VL__native_blob_specific, /* specific */ - NULL /* optional */ + { + /* blob_cls */ + H5VL__native_blob_put, /* put */ + H5VL__native_blob_get, /* get */ + H5VL__native_blob_specific, /* specific */ + NULL /* optional */ }, - { /* token_cls */ - H5VL__native_token_cmp, /* cmp */ - H5VL__native_token_to_str, /* to_str */ - H5VL__native_str_to_token /* from_str */ + { + /* token_cls */ + H5VL__native_token_cmp, /* cmp */ + H5VL__native_token_to_str, /* to_str */ + H5VL__native_str_to_token /* from_str */ }, - NULL /* optional */ + NULL /* optional */ }; - /*------------------------------------------------------------------------- * Function: H5VL_native_register * @@ -158,13 +169,14 @@ static const H5VL_class_t H5VL_native_cls_g = { hid_t H5VL_native_register(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Register the native VOL connector, if it isn't already */ - if(H5I_INVALID_HID == H5VL_NATIVE_ID_g) - if((H5VL_NATIVE_ID_g = H5VL_register_connector(&H5VL_native_cls_g, TRUE, H5P_VOL_INITIALIZE_DEFAULT)) < 0) + if (H5I_INVALID_HID == H5VL_NATIVE_ID_g) + if ((H5VL_NATIVE_ID_g = + H5VL_register_connector(&H5VL_native_cls_g, TRUE, H5P_VOL_INITIALIZE_DEFAULT)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL connector") /* Set return value */ @@ -174,7 +186,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_register() */ - /*--------------------------------------------------------------------------- * Function: H5VL__native_term * @@ -195,7 +206,6 @@ H5VL__native_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL__native_term() */ - /*--------------------------------------------------------------------------- * Function: H5VL__native_introspect_get_conn_cls * @@ -209,8 +219,8 @@ H5VL__native_term(void) *--------------------------------------------------------------------------- */ herr_t -H5VL__native_introspect_get_conn_cls(void H5_ATTR_UNUSED *obj, - H5VL_get_conn_lvl_t H5_ATTR_UNUSED lvl, const H5VL_class_t **conn_cls) +H5VL__native_introspect_get_conn_cls(void H5_ATTR_UNUSED *obj, H5VL_get_conn_lvl_t H5_ATTR_UNUSED lvl, + const H5VL_class_t **conn_cls) { FUNC_ENTER_PACKAGE_NOERR @@ -223,7 +233,6 @@ H5VL__native_introspect_get_conn_cls(void H5_ATTR_UNUSED *obj, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL__native_introspect_get_conn_cls() */ - /*------------------------------------------------------------------------- * Function: H5VL_native_get_file_addr_len * @@ -238,9 +247,9 @@ H5VL__native_introspect_get_conn_cls(void H5_ATTR_UNUSED *obj, herr_t H5VL_native_get_file_addr_len(hid_t loc_id, size_t *addr_len) { - H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ - void *vol_obj = NULL; /* VOL Object of loc_id */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void * vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -248,22 +257,21 @@ H5VL_native_get_file_addr_len(hid_t loc_id, size_t *addr_len) HDassert(addr_len); /* Get object type */ - if((vol_obj_type = H5I_get_type(loc_id)) < 0) + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve underlying VOL object */ - if(NULL == (vol_obj = H5VL_object(loc_id))) + if (NULL == (vol_obj = H5VL_object(loc_id))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve file address length */ - if(H5VL__native_get_file_addr_len(vol_obj, vol_obj_type, addr_len) < 0) + if (H5VL__native_get_file_addr_len(vol_obj, vol_obj_type, addr_len) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get file address length") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_get_file_addr_len() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_get_file_addr_len * @@ -278,8 +286,8 @@ done: herr_t H5VL__native_get_file_addr_len(void *obj, H5I_type_t obj_type, size_t *addr_len) { - H5F_t *file = NULL; /* File stuct pointer */ - herr_t ret_value = SUCCEED; + H5F_t *file = NULL; /* File stuct pointer */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -288,7 +296,7 @@ H5VL__native_get_file_addr_len(void *obj, H5I_type_t obj_type, size_t *addr_len) HDassert(addr_len); /* Retrieve file from the VOL object */ - if(H5VL_native_get_file_struct(obj, obj_type, &file) < 0) + if (H5VL_native_get_file_struct(obj, obj_type, &file) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get file from VOL object") /* Get the length of an address in this file */ @@ -298,7 +306,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_get_file_addr_len() */ - /*------------------------------------------------------------------------- * Function: H5VLnative_addr_to_token * @@ -311,51 +318,51 @@ done: herr_t H5VLnative_addr_to_token(hid_t loc_id, haddr_t addr, H5O_token_t *token) { - H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ - void *vol_obj = NULL; /* VOL Object of loc_id */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void * vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ia*k", loc_id, addr, token); /* Check args */ - if(NULL == token) + if (NULL == token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "token pointer can't be NULL") /* Get object type */ - if((vol_obj_type = H5I_get_type(loc_id)) < 0) + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve underlying VOL object */ - if(NULL == (vol_obj = H5VL_object(loc_id))) + if (NULL == (vol_obj = H5VL_object(loc_id))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") #ifndef NDEBUG { H5VL_object_t *vol_obj_container; - hbool_t is_native_vol_obj; + hbool_t is_native_vol_obj; /* Get the location object */ - if(NULL == (vol_obj_container = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj_container = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL object is a native connector object */ - if(H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if (H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, + "can't determine if VOL object is native connector object") HDassert(is_native_vol_obj && "not a native VOL connector object"); } #endif /* Convert the haddr_t to an object token */ - if(H5VL_native_addr_to_token(vol_obj, vol_obj_type, addr, token) < 0) + if (H5VL_native_addr_to_token(vol_obj, vol_obj_type, addr, token) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "couldn't serialize haddr_t into object token") done: FUNC_LEAVE_API(ret_value) } /* end H5VLnative_addr_to_token() */ - /*------------------------------------------------------------------------- * Function: H5VL_native_addr_to_token * @@ -369,7 +376,7 @@ herr_t H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t addr, H5O_token_t *token) { uint8_t *p; - size_t addr_len = 0; /* Size of haddr_t */ + size_t addr_len = 0; /* Size of haddr_t */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -379,7 +386,7 @@ H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t addr, H5O_toke HDassert(token); /* Get the length of an haddr_t in the file */ - if(H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0) + if (H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get length of haddr_t from VOL object") /* Ensure that token is initialized */ @@ -393,7 +400,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_addr_to_token() */ - /*------------------------------------------------------------------------- * Function: H5VLnative_token_to_addr * @@ -406,51 +412,51 @@ done: herr_t H5VLnative_token_to_addr(hid_t loc_id, H5O_token_t token, haddr_t *addr) { - H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ - void *vol_obj = NULL; /* VOL Object of loc_id */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void * vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ik*a", loc_id, token, addr); /* Check args */ - if(NULL == addr) + if (NULL == addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr pointer can't be NULL") /* Get object type */ - if((vol_obj_type = H5I_get_type(loc_id)) < 0) + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve underlying VOL object */ - if(NULL == (vol_obj = H5VL_object(loc_id))) + if (NULL == (vol_obj = H5VL_object(loc_id))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") #ifndef NDEBUG { H5VL_object_t *vol_obj_container; - hbool_t is_native_vol_obj; + hbool_t is_native_vol_obj; /* Get the location object */ - if(NULL == (vol_obj_container = (H5VL_object_t *)H5I_object(loc_id))) + if (NULL == (vol_obj_container = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL object is a native connector object */ - if(H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if (H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, + "can't determine if VOL object is native connector object") HDassert(is_native_vol_obj && "not a native VOL connector object"); } #endif /* Convert the object token to an haddr_t */ - if(H5VL_native_token_to_addr(vol_obj, vol_obj_type, token, addr) < 0) + if (H5VL_native_token_to_addr(vol_obj, vol_obj_type, token, addr) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "couldn't deserialize object token into haddr_t") done: FUNC_LEAVE_API(ret_value) } /* end H5VLnative_token_to_addr() */ - /*------------------------------------------------------------------------- * Function: H5VL_native_token_to_addr * @@ -464,7 +470,7 @@ herr_t H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, haddr_t *addr) { const uint8_t *p; - size_t addr_len = 0; /* Size of haddr_t */ + size_t addr_len = 0; /* Size of haddr_t */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -474,7 +480,7 @@ H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, had HDassert(addr); /* Get the length of an haddr_t in the file */ - if(H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0) + if (H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get length of haddr_t from VOL object") /* Decode token */ @@ -485,7 +491,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_token_to_addr() */ - /*--------------------------------------------------------------------------- * Function: H5VL_native_get_file_struct * @@ -498,14 +503,14 @@ done: herr_t H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file) { - H5O_loc_t *oloc = NULL; /* Object location for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_loc_t *oloc = NULL; /* Object location for ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL); *file = NULL; - switch(type) { + switch (type) { case H5I_FILE: *file = (H5F_t *)obj; break; @@ -546,14 +551,13 @@ H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file) } /* end switch */ /* Set return value for objects (not files) */ - if(oloc) + if (oloc) *file = oloc->file; /* Couldn't find a file struct */ - if(!*file) + if (!*file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5VL_native_get_file_struct */ - diff --git a/src/H5VLnative.h b/src/H5VLnative.h index e6be0bd..a20fe65 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -18,85 +18,84 @@ #define _H5VLnative_H /* Public headers needed by this file */ -#include "H5VLpublic.h" /* Virtual Object Layer */ - +#include "H5VLpublic.h" /* Virtual Object Layer */ /*****************/ /* Public Macros */ /*****************/ /* Identifier for the native VOL connector */ -#define H5VL_NATIVE (H5VL_native_register()) +#define H5VL_NATIVE (H5VL_native_register()) /* Characteristics of the native VOL connector */ -#define H5VL_NATIVE_NAME "native" -#define H5VL_NATIVE_VALUE H5_VOL_NATIVE /* enum value */ -#define H5VL_NATIVE_VERSION 0 +#define H5VL_NATIVE_NAME "native" +#define H5VL_NATIVE_VALUE H5_VOL_NATIVE /* enum value */ +#define H5VL_NATIVE_VERSION 0 /* Values for VOL connector attribute optional VOL operations */ #ifndef H5_NO_DEPRECATED_SYMBOLS -#define H5VL_NATIVE_ATTR_ITERATE_OLD 0 /* H5Aiterate (deprecated routine) */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +#define H5VL_NATIVE_ATTR_ITERATE_OLD 0 /* H5Aiterate (deprecated routine) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Values for native VOL connector dataset optional VOL operations */ -#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */ -#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */ -#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */ -#define H5VL_NATIVE_DATASET_GET_NUM_CHUNKS 3 /* H5Dget_num_chunks */ -#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX 4 /* H5Dget_chunk_info */ -#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD 5 /* H5Dget_chunk_info_by_coord */ -#define H5VL_NATIVE_DATASET_CHUNK_READ 6 /* H5Dchunk_read */ -#define H5VL_NATIVE_DATASET_CHUNK_WRITE 7 /* H5Dchunk_write */ -#define H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE 8 /* H5Dvlen_get_buf_size */ -#define H5VL_NATIVE_DATASET_GET_OFFSET 9 /* H5Dget_offset */ +#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */ +#define H5VL_NATIVE_DATASET_GET_NUM_CHUNKS 3 /* H5Dget_num_chunks */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX 4 /* H5Dget_chunk_info */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD 5 /* H5Dget_chunk_info_by_coord */ +#define H5VL_NATIVE_DATASET_CHUNK_READ 6 /* H5Dchunk_read */ +#define H5VL_NATIVE_DATASET_CHUNK_WRITE 7 /* H5Dchunk_write */ +#define H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE 8 /* H5Dvlen_get_buf_size */ +#define H5VL_NATIVE_DATASET_GET_OFFSET 9 /* H5Dget_offset */ /* Values for native VOL connector file optional VOL operations */ -#define H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE 0 /* H5Fclear_elink_file_cache */ -#define H5VL_NATIVE_FILE_GET_FILE_IMAGE 1 /* H5Fget_file_image */ -#define H5VL_NATIVE_FILE_GET_FREE_SECTIONS 2 /* H5Fget_free_sections */ -#define H5VL_NATIVE_FILE_GET_FREE_SPACE 3 /* H5Fget_freespace */ -#define H5VL_NATIVE_FILE_GET_INFO 4 /* H5Fget_info1/2 */ -#define H5VL_NATIVE_FILE_GET_MDC_CONF 5 /* H5Fget_mdc_config */ -#define H5VL_NATIVE_FILE_GET_MDC_HR 6 /* H5Fget_mdc_hit_rate */ -#define H5VL_NATIVE_FILE_GET_MDC_SIZE 7 /* H5Fget_mdc_size */ -#define H5VL_NATIVE_FILE_GET_SIZE 8 /* H5Fget_filesize */ -#define H5VL_NATIVE_FILE_GET_VFD_HANDLE 9 /* H5Fget_vfd_handle */ -#define H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE 10 /* H5Freset_mdc_hit_rate_stats */ -#define H5VL_NATIVE_FILE_SET_MDC_CONFIG 11 /* H5Fset_mdc_config */ -#define H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO 12 /* H5Fget_metadata_read_retry_info */ -#define H5VL_NATIVE_FILE_START_SWMR_WRITE 13 /* H5Fstart_swmr_write */ -#define H5VL_NATIVE_FILE_START_MDC_LOGGING 14 /* H5Fstart_mdc_logging */ -#define H5VL_NATIVE_FILE_STOP_MDC_LOGGING 15 /* H5Fstop_mdc_logging */ -#define H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS 16 /* H5Fget_mdc_logging_status */ -#define H5VL_NATIVE_FILE_FORMAT_CONVERT 17 /* H5Fformat_convert */ -#define H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS 18 /* H5Freset_page_buffering_stats */ -#define H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS 19 /* H5Fget_page_buffering_stats */ -#define H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO 20 /* H5Fget_mdc_image_info */ -#define H5VL_NATIVE_FILE_GET_EOA 21 /* H5Fget_eoa */ -#define H5VL_NATIVE_FILE_INCR_FILESIZE 22 /* H5Fincrement_filesize */ -#define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 23 /* H5Fset_latest_format/libver_bounds */ -#define H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG 24 /* H5Fget_dset_no_attrs_hint */ -#define H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG 25 /* H5Fset_dset_no_attrs_hint */ -#define H5VL_NATIVE_FILE_GET_MPI_ATOMICITY 26 /* H5Fget_mpi_atomicity */ -#define H5VL_NATIVE_FILE_SET_MPI_ATOMICITY 27 /* H5Fset_mpi_atomicity */ -#define H5VL_NATIVE_FILE_POST_OPEN 28 /* Adjust file after open, with wrapping context */ -#define H5VL_NATIVE_FILE_VFD_SWMR_DISABLE_EOT 29 -#define H5VL_NATIVE_FILE_VFD_SWMR_ENABLE_EOT 30 -#define H5VL_NATIVE_FILE_VFD_SWMR_END_TICK 31 +#define H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE 0 /* H5Fclear_elink_file_cache */ +#define H5VL_NATIVE_FILE_GET_FILE_IMAGE 1 /* H5Fget_file_image */ +#define H5VL_NATIVE_FILE_GET_FREE_SECTIONS 2 /* H5Fget_free_sections */ +#define H5VL_NATIVE_FILE_GET_FREE_SPACE 3 /* H5Fget_freespace */ +#define H5VL_NATIVE_FILE_GET_INFO 4 /* H5Fget_info1/2 */ +#define H5VL_NATIVE_FILE_GET_MDC_CONF 5 /* H5Fget_mdc_config */ +#define H5VL_NATIVE_FILE_GET_MDC_HR 6 /* H5Fget_mdc_hit_rate */ +#define H5VL_NATIVE_FILE_GET_MDC_SIZE 7 /* H5Fget_mdc_size */ +#define H5VL_NATIVE_FILE_GET_SIZE 8 /* H5Fget_filesize */ +#define H5VL_NATIVE_FILE_GET_VFD_HANDLE 9 /* H5Fget_vfd_handle */ +#define H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE 10 /* H5Freset_mdc_hit_rate_stats */ +#define H5VL_NATIVE_FILE_SET_MDC_CONFIG 11 /* H5Fset_mdc_config */ +#define H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO 12 /* H5Fget_metadata_read_retry_info */ +#define H5VL_NATIVE_FILE_START_SWMR_WRITE 13 /* H5Fstart_swmr_write */ +#define H5VL_NATIVE_FILE_START_MDC_LOGGING 14 /* H5Fstart_mdc_logging */ +#define H5VL_NATIVE_FILE_STOP_MDC_LOGGING 15 /* H5Fstop_mdc_logging */ +#define H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS 16 /* H5Fget_mdc_logging_status */ +#define H5VL_NATIVE_FILE_FORMAT_CONVERT 17 /* H5Fformat_convert */ +#define H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS 18 /* H5Freset_page_buffering_stats */ +#define H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS 19 /* H5Fget_page_buffering_stats */ +#define H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO 20 /* H5Fget_mdc_image_info */ +#define H5VL_NATIVE_FILE_GET_EOA 21 /* H5Fget_eoa */ +#define H5VL_NATIVE_FILE_INCR_FILESIZE 22 /* H5Fincrement_filesize */ +#define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 23 /* H5Fset_latest_format/libver_bounds */ +#define H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG 24 /* H5Fget_dset_no_attrs_hint */ +#define H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG 25 /* H5Fset_dset_no_attrs_hint */ +#define H5VL_NATIVE_FILE_GET_MPI_ATOMICITY 26 /* H5Fget_mpi_atomicity */ +#define H5VL_NATIVE_FILE_SET_MPI_ATOMICITY 27 /* H5Fset_mpi_atomicity */ +#define H5VL_NATIVE_FILE_POST_OPEN 28 /* Adjust file after open, with wrapping context */ +#define H5VL_NATIVE_FILE_VFD_SWMR_DISABLE_EOT 29 +#define H5VL_NATIVE_FILE_VFD_SWMR_ENABLE_EOT 30 +#define H5VL_NATIVE_FILE_VFD_SWMR_END_TICK 31 /* Values for native VOL connector group optional VOL operations */ #ifndef H5_NO_DEPRECATED_SYMBOLS -#define H5VL_NATIVE_GROUP_ITERATE_OLD 0 /* HG5Giterate (deprecated routine) */ -#define H5VL_NATIVE_GROUP_GET_OBJINFO 1 /* HG5Gget_objinfo (deprecated routine) */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +#define H5VL_NATIVE_GROUP_ITERATE_OLD 0 /* HG5Giterate (deprecated routine) */ +#define H5VL_NATIVE_GROUP_GET_OBJINFO 1 /* HG5Gget_objinfo (deprecated routine) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Values for native VOL connector object optional VOL operations */ -#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */ -#define H5VL_NATIVE_OBJECT_SET_COMMENT 1 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ -#define H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES 2 /* H5Odisable_mdc_flushes */ -#define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 3 /* H5Oenable_mdc_flushes */ -#define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 4 /* H5Oare_mdc_flushes_disabled */ -#define H5VL_NATIVE_OBJECT_GET_NATIVE_INFO 5 /* H5Oget_native_info(_by_idx, _by_name) */ +#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */ +#define H5VL_NATIVE_OBJECT_SET_COMMENT 1 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ +#define H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES 2 /* H5Odisable_mdc_flushes */ +#define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 3 /* H5Oenable_mdc_flushes */ +#define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 4 /* H5Oare_mdc_flushes_disabled */ +#define H5VL_NATIVE_OBJECT_GET_NATIVE_INFO 5 /* H5Oget_native_info(_by_idx, _by_name) */ /*******************/ /* Public Typedefs */ @@ -138,4 +137,3 @@ H5_DLL hid_t H5VL_native_register(void); #endif #endif /* _H5VLnative_H */ - diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c index 1798a0e..0c8de6c 100644 --- a/src/H5VLnative_attr.c +++ b/src/H5VLnative_attr.c @@ -15,23 +15,21 @@ * */ -#define H5A_FRIEND /* Suppress error about including H5Apkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#define H5A_FRIEND /* Suppress error about including H5Apkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - - /*------------------------------------------------------------------------- * Function: H5VL__native_attr_create * @@ -43,42 +41,43 @@ *------------------------------------------------------------------------- */ void * -H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, - hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, + hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - hbool_t loc_found = FALSE; - H5T_t *type, *dt; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - H5A_t *attr = NULL; - void *ret_value = NULL; + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; + H5T_t * type, *dt; /* Datatype to use for attribute */ + H5S_t * space; /* Dataspace to use for attribute */ + H5A_t * attr = NULL; + void * ret_value = NULL; FUNC_ENTER_PACKAGE - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") /* If this is a named datatype, get the connector's pointer to the datatype */ type = H5T_get_actual_type(dt); - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") - if(loc_params->type == H5VL_OBJECT_BY_SELF) { + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Acreate */ /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) + if (NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Acreate_by_name */ - if(NULL == (attr = H5A__create_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name, type, space, acpl_id))) + if (NULL == (attr = H5A__create_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name, type, + space, acpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") } /* end else-if */ else @@ -88,13 +87,12 @@ H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const c done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_attr_open * @@ -107,37 +105,36 @@ done: */ void * H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, - hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) + hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - void *ret_value; + H5G_loc_t loc; /* Object location */ + H5A_t * attr = NULL; /* Attribute opened */ + void * ret_value; FUNC_ENTER_PACKAGE /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(loc_params->type == H5VL_OBJECT_BY_SELF) { + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aopen */ /* Open the attribute */ - if(NULL == (attr = H5A__open(&loc, attr_name))) + if (NULL == (attr = H5A__open(&loc, attr_name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aopen_by_name */ /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + if (NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Aopen_by_idx */ /* Open the attribute in the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) + if (NULL == (attr = H5A__open_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") } /* end else-if */ else @@ -149,7 +146,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_attr_read * @@ -160,26 +156,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ FUNC_ENTER_PACKAGE - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Go write the actual data to the attribute */ - if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0) + if ((ret_value = H5A__read((H5A_t *)attr, mem_type, buf)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_read() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_attr_write * @@ -190,26 +185,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ FUNC_ENTER_PACKAGE - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Go write the actual data to the attribute */ - if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0) + if ((ret_value = H5A__write((H5A_t *)attr, mem_type, buf)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_write() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_attr_get * @@ -220,166 +214,161 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(get_type) { + switch (get_type) { /* H5Aget_space */ - case H5VL_ATTR_GET_SPACE: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A_get_space(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") - break; - } + case H5VL_ATTR_GET_SPACE: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if ((*ret_id = H5A_get_space(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") + break; + } /* H5Aget_type */ - case H5VL_ATTR_GET_TYPE: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A__get_type(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") - break; - } + case H5VL_ATTR_GET_TYPE: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if ((*ret_id = H5A__get_type(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") + break; + } /* H5Aget_create_plist */ - case H5VL_ATTR_GET_ACPL: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; + case H5VL_ATTR_GET_ACPL: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; - if((*ret_id = H5A__get_create_plist(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") + if ((*ret_id = H5A__get_create_plist(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") - break; - } + break; + } /* H5Aget_name */ - case H5VL_ATTR_GET_NAME: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - size_t buf_size = HDva_arg(arguments, size_t); - char *buf = HDva_arg(arguments, char *); - ssize_t *ret_val = HDva_arg(arguments, ssize_t *); - H5A_t *attr = NULL; - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - attr = (H5A_t *)obj; - /* Call private function in turn */ - if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") - } - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the length of the name */ - *ret_val = (ssize_t)HDstrlen(attr->shared->name); - - /* Copy the name into the user's buffer, if given */ - if(buf) { - HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); - if((size_t)(*ret_val) >= buf_size) - buf[buf_size - 1]='\0'; - } /* end if */ - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - - break; + case H5VL_ATTR_GET_NAME: { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + size_t buf_size = HDva_arg(arguments, size_t); + char * buf = HDva_arg(arguments, char *); + ssize_t * ret_val = HDva_arg(arguments, ssize_t *); + H5A_t * attr = NULL; + + if (H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + /* Call private function in turn */ + if (0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") } + else if (H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if (NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the length of the name */ + *ret_val = (ssize_t)HDstrlen(attr->shared->name); + + /* Copy the name into the user's buffer, if given */ + if (buf) { + HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); + if ((size_t)(*ret_val) >= buf_size) + buf[buf_size - 1] = '\0'; + } /* end if */ - /* H5Aget_info */ - case H5VL_ATTR_GET_INFO: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - H5A_info_t *ainfo = HDva_arg(arguments, H5A_info_t *); - H5A_t *attr = NULL; - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - attr = (H5A_t *)obj; - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") - } - else if(H5VL_OBJECT_BY_NAME == loc_params->type) { - char *attr_name = HDva_arg(arguments, char *); - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - - break; + /* Release resources */ + if (attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - case H5VL_ATTR_GET_STORAGE_SIZE: - { - hsize_t *ret = HDva_arg(arguments, hsize_t *); - H5A_t *attr = (H5A_t *)obj; + break; + } - /* Set return value */ - *ret = attr->shared->data_size; - break; + /* H5Aget_info */ + case H5VL_ATTR_GET_INFO: { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5A_info_t * ainfo = HDva_arg(arguments, H5A_info_t *); + H5A_t * attr = NULL; + + if (H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + if (H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") + } + else if (H5VL_OBJECT_BY_NAME == loc_params->type) { + char * attr_name = HDva_arg(arguments, char *); + H5G_loc_t loc; + + /* check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if (NULL == + (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if (H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if (attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else if (H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if (NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if (H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if (attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + case H5VL_ATTR_GET_STORAGE_SIZE: { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + H5A_t * attr = (H5A_t *)obj; + + /* Set return value */ + *ret = attr->shared->data_size; + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") @@ -389,7 +378,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_attr_specific * @@ -401,109 +389,107 @@ done: */ herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) { - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get location for passed-in object */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch(specific_type) { - case H5VL_ATTR_DELETE: - { - char *attr_name = HDva_arg(arguments, char *); - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - /* H5Adelete */ - /* Delete the attribute from the location */ - if(H5O__attr_remove(loc.oloc, attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end if */ - else if(H5VL_OBJECT_BY_NAME == loc_params->type) { - /* H5Adelete_by_name */ - /* Delete the attribute */ - if(H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end else-if */ - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - /* H5Adelete_by_idx */ - /* Delete the attribute from the location */ - if(H5A__delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") - break; - } - - case H5VL_ATTR_EXISTS: - { - const char *attr_name = HDva_arg(arguments, const char *); - htri_t *ret = HDva_arg(arguments, htri_t *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ - /* Check if the attribute exists */ - if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ - /* Check if the attribute exists */ - if((*ret = H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") - break; - } - - case H5VL_ATTR_ITER: - { - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - hsize_t *idx = HDva_arg(arguments, hsize_t *); - H5A_operator2_t op = HDva_arg(arguments, H5A_operator2_t); - void *op_data = HDva_arg(arguments, void *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ - /* Iterate over attributes */ - if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ - /* Iterate over attributes by name */ - if((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") - break; - } + switch (specific_type) { + case H5VL_ATTR_DELETE: { + char *attr_name = HDva_arg(arguments, char *); + + if (H5VL_OBJECT_BY_SELF == loc_params->type) { + /* H5Adelete */ + /* Delete the attribute from the location */ + if (H5O__attr_remove(loc.oloc, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end if */ + else if (H5VL_OBJECT_BY_NAME == loc_params->type) { + /* H5Adelete_by_name */ + /* Delete the attribute */ + if (H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else if (H5VL_OBJECT_BY_IDX == loc_params->type) { + /* H5Adelete_by_idx */ + /* Delete the attribute from the location */ + if (H5A__delete_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") + break; + } + + case H5VL_ATTR_EXISTS: { + const char *attr_name = HDva_arg(arguments, const char *); + htri_t * ret = HDva_arg(arguments, htri_t *); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ + /* Check if the attribute exists */ + if ((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ + /* Check if the attribute exists */ + if ((*ret = H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + case H5VL_ATTR_ITER: { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t * idx = HDva_arg(arguments, hsize_t *); + H5A_operator2_t op = HDva_arg(arguments, H5A_operator2_t); + void * op_data = HDva_arg(arguments, void *); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ + /* Iterate over attributes */ + if ((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ + /* Iterate over attributes by name */ + if ((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, + idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } /* H5Arename/rename_by_name */ - case H5VL_ATTR_RENAME: - { - const char *old_name = HDva_arg(arguments, const char *); - const char *new_name = HDva_arg(arguments, const char *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ - /* Call attribute rename routine */ - if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ - /* Call attribute rename routine */ - if(H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") - break; - } + case H5VL_ATTR_RENAME: { + const char *old_name = HDva_arg(arguments, const char *); + const char *new_name = HDva_arg(arguments, const char *); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ + /* Call attribute rename routine */ + if (H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ + /* Call attribute rename routine */ + if (H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") @@ -513,7 +499,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_attr_optional * @@ -525,28 +510,27 @@ done: */ herr_t H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, H5VL_attr_optional_t opt_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, - va_list H5_ATTR_DEPRECATED_USED arguments) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, + va_list H5_ATTR_DEPRECATED_USED arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(opt_type) { + switch (opt_type) { #ifndef H5_NO_DEPRECATED_SYMBOLS - case H5VL_NATIVE_ATTR_ITERATE_OLD: - { - hid_t loc_id = HDva_arg(arguments, hid_t); - unsigned *attr_num = HDva_arg(arguments, unsigned *); - H5A_operator1_t op = HDva_arg(arguments, H5A_operator1_t); - void *op_data = HDva_arg(arguments, void *); - - /* Call the actual iteration routine */ - if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) - HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); - - break; - } + case H5VL_NATIVE_ATTR_ITERATE_OLD: { + hid_t loc_id = HDva_arg(arguments, hid_t); + unsigned * attr_num = HDva_arg(arguments, unsigned *); + H5A_operator1_t op = HDva_arg(arguments, H5A_operator1_t); + void * op_data = HDva_arg(arguments, void *); + + /* Call the actual iteration routine */ + if ((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); + + break; + } #endif /* H5_NO_DEPRECATED_SYMBOLS */ default: @@ -557,7 +541,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_attr_close * @@ -571,14 +554,13 @@ done: herr_t H5VL__native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5A__close((H5A_t*)attr) < 0) + if (H5A__close((H5A_t *)attr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_close() */ - diff --git a/src/H5VLnative_blob.c b/src/H5VLnative_blob.c index 8e34859..aaac2b3 100644 --- a/src/H5VLnative_blob.c +++ b/src/H5VLnative_blob.c @@ -20,41 +20,33 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ -#include "H5HGprivate.h" /* Global Heaps */ +#include "H5HGprivate.h" /* Global Heaps */ #include "H5VLnative_private.h" /* Native VOL connector */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5VL__native_blob_put * @@ -68,13 +60,12 @@ *------------------------------------------------------------------------- */ herr_t -H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, - void H5_ATTR_UNUSED *ctx) +H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void H5_ATTR_UNUSED *ctx) { - H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */ - uint8_t *id = (uint8_t *)blob_id; /* Pointer to blob ID */ - H5HG_t hobjid; /* New VL sequence's heap ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * f = (H5F_t *)obj; /* Retrieve file pointer */ + uint8_t *id = (uint8_t *)blob_id; /* Pointer to blob ID */ + H5HG_t hobjid; /* New VL sequence's heap ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -84,7 +75,7 @@ H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, HDassert(id); /* Write the VL information to disk (allocates space also) */ - if(H5HG_insert(f, size, buf, &hobjid) < 0) + if (H5HG_insert(f, size, buf, &hobjid) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write blob information") /* Encode the heap information */ @@ -95,7 +86,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_blob_put() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_blob_get * @@ -109,14 +99,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, - void H5_ATTR_UNUSED *ctx) +H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void H5_ATTR_UNUSED *ctx) { - H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */ + H5F_t * f = (H5F_t *)obj; /* Retrieve file pointer */ const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the disk blob ID */ - H5HG_t hobjid; /* Global heap ID for sequence */ - size_t hobj_size; /* Global heap object size returned from H5HG_read() */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_t hobjid; /* Global heap ID for sequence */ + size_t hobj_size; /* Global heap object size returned from H5HG_read() */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -130,20 +119,19 @@ H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, UINT32DECODE(id, hobjid.idx); /* Check if this sequence actually has any data */ - if(hobjid.addr > 0) + if (hobjid.addr > 0) /* Read the VL information from disk */ - if(NULL == H5HG_read(f, &hobjid, buf, &hobj_size)) + if (NULL == H5HG_read(f, &hobjid, buf, &hobj_size)) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read VL information") /* Verify the size is correct */ - if(hobj_size != size) + if (hobj_size != size) HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "Expected global heap object size does not match") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_blob_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_blob_specific * @@ -157,11 +145,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_blob_specific(void *obj, void *blob_id, - H5VL_blob_specific_t specific_type, va_list arguments) +H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments) { - H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -169,69 +156,65 @@ H5VL__native_blob_specific(void *obj, void *blob_id, HDassert(f); HDassert(blob_id); - switch(specific_type) { - case H5VL_BLOB_GETSIZE: - { - const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ - size_t *size = HDva_arg(arguments, size_t *); - H5HG_t hobjid; /* blob's heap ID */ - - /* Get heap information */ - H5F_addr_decode(f, &id, &(hobjid.addr)); - UINT32DECODE(id, hobjid.idx); - - /* Get heap object's size */ - if(hobjid.addr > 0) { - if(H5HG_get_obj_size(f, &hobjid, size) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object") - } /* end if */ - else - *size = 0; /* Return '0' size for 'nil' blob ID */ - - break; - } - - case H5VL_BLOB_ISNULL: - { - const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ - hbool_t *isnull = HDva_arg(arguments, hbool_t *); - haddr_t addr; /* Sequence's heap address */ - - /* Get the heap address */ - H5F_addr_decode(f, &id, &addr); - - /* Check if heap address is 'nil' */ - *isnull = (addr == 0 ? TRUE : FALSE); - - break; - } - - case H5VL_BLOB_SETNULL: - { - uint8_t *id = (uint8_t *)blob_id; /* Pointer to the blob ID */ - /* Encode the "nil" heap pointer information */ - H5F_addr_encode(f, &id, (haddr_t)0); - UINT32ENCODE(id, 0); - - break; - } - - case H5VL_BLOB_DELETE: - { - const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ - H5HG_t hobjid; /* VL sequence's heap ID */ - - /* Get heap information */ - H5F_addr_decode(f, &id, &hobjid.addr); - UINT32DECODE(id, hobjid.idx); - - /* Free heap object */ - if(hobjid.addr > 0) - if(H5HG_remove(f, &hobjid) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object") - - break; - } + switch (specific_type) { + case H5VL_BLOB_GETSIZE: { + const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ + size_t * size = HDva_arg(arguments, size_t *); + H5HG_t hobjid; /* blob's heap ID */ + + /* Get heap information */ + H5F_addr_decode(f, &id, &(hobjid.addr)); + UINT32DECODE(id, hobjid.idx); + + /* Get heap object's size */ + if (hobjid.addr > 0) { + if (H5HG_get_obj_size(f, &hobjid, size) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object") + } /* end if */ + else + *size = 0; /* Return '0' size for 'nil' blob ID */ + + break; + } + + case H5VL_BLOB_ISNULL: { + const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ + hbool_t * isnull = HDva_arg(arguments, hbool_t *); + haddr_t addr; /* Sequence's heap address */ + + /* Get the heap address */ + H5F_addr_decode(f, &id, &addr); + + /* Check if heap address is 'nil' */ + *isnull = (addr == 0 ? TRUE : FALSE); + + break; + } + + case H5VL_BLOB_SETNULL: { + uint8_t *id = (uint8_t *)blob_id; /* Pointer to the blob ID */ + /* Encode the "nil" heap pointer information */ + H5F_addr_encode(f, &id, (haddr_t)0); + UINT32ENCODE(id, 0); + + break; + } + + case H5VL_BLOB_DELETE: { + const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ + H5HG_t hobjid; /* VL sequence's heap ID */ + + /* Get heap information */ + H5F_addr_decode(f, &id, &hobjid.addr); + UINT32DECODE(id, hobjid.idx); + + /* Free heap object */ + if (hobjid.addr > 0) + if (H5HG_remove(f, &hobjid) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object") + + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index 3f62e00..8eac4a3 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -15,22 +15,20 @@ * */ -#define H5D_FRIEND /* Suppress error about including H5Dpkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - - /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_create * @@ -42,61 +40,60 @@ *------------------------------------------------------------------------- */ void * -H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, - hid_t dcpl_id, hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) +H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, + hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - void *ret_value; + H5G_loc_t loc; /* Object location to insert dataset into */ + H5D_t * dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + void * ret_value; FUNC_ENTER_PACKAGE /* Check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(H5I_DATATYPE != H5I_get_type(type_id)) + if (H5I_DATATYPE != H5I_get_type(type_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") /* H5Dcreate_anon */ - if(NULL == name) { + if (NULL == name) { /* build and open the new dataset */ - if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) + if (NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") } /* end if */ /* H5Dcreate2 */ else { /* Create the new dataset & get its ID */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) + if (NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") } /* end else */ ret_value = (void *)dset; done: - if(NULL == name) { + if (NULL == name) { /* Release the dataset's object header, if it was created */ - if(dset) { - H5O_loc_t *oloc; /* Object location for dataset */ + if (dset) { + H5O_loc_t *oloc; /* Object location for dataset */ /* Get the new dataset's object location */ - if(NULL == (oloc = H5D_oloc(dset))) + if (NULL == (oloc = H5D_oloc(dset))) HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + if (H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, + "unable to decrement refcount on newly created object") } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_open * @@ -108,20 +105,20 @@ done: *------------------------------------------------------------------------- */ void * -H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - void *ret_value = NULL; + H5D_t * dset = NULL; + H5G_loc_t loc; /* Object location of group */ + void * ret_value = NULL; FUNC_ENTER_PACKAGE - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) + if (NULL == (dset = H5D__open_name(&loc, name, dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") ret_value = (void *)dset; @@ -130,7 +127,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_read * @@ -141,36 +137,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, - void H5_ATTR_UNUSED **req) +H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t H5_ATTR_UNUSED dxpl_id, void *buf, void H5_ATTR_UNUSED **req) { - H5D_t *dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t * dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == dset->oloc.file) + if (NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") /* Get validated dataspace pointers */ - if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") /* Read raw data */ - if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) + if (H5D__read(dset, mem_type_id, mem_space, file_space, buf /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_read() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_write * @@ -181,36 +175,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, - void H5_ATTR_UNUSED **req) +H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, void H5_ATTR_UNUSED **req) { - H5D_t *dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t * dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* check arguments */ - if(NULL == dset->oloc.file) + if (NULL == dset->oloc.file) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") /* Get validated dataspace pointers */ - if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") /* Write the data */ - if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + if (H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_write() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_get * @@ -221,81 +213,75 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - H5D_t *dset = (H5D_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(get_type) { + switch (get_type) { /* H5Dget_space */ - case H5VL_DATASET_GET_SPACE: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); + case H5VL_DATASET_GET_SPACE: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); - if((*ret_id = H5D__get_space(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") + if ((*ret_id = H5D__get_space(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") - break; - } + break; + } /* H5Dget_space_status */ - case H5VL_DATASET_GET_SPACE_STATUS: - { - H5D_space_status_t *allocation = HDva_arg(arguments, H5D_space_status_t *); + case H5VL_DATASET_GET_SPACE_STATUS: { + H5D_space_status_t *allocation = HDva_arg(arguments, H5D_space_status_t *); - /* Read data space address and return */ - if(H5D__get_space_status(dset, allocation) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") + /* Read data space address and return */ + if (H5D__get_space_status(dset, allocation) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") - break; - } + break; + } /* H5Dget_type */ - case H5VL_DATASET_GET_TYPE: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); + case H5VL_DATASET_GET_TYPE: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); - if((*ret_id = H5D__get_type(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") + if ((*ret_id = H5D__get_type(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") - break; - } + break; + } /* H5Dget_create_plist */ - case H5VL_DATASET_GET_DCPL: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); + case H5VL_DATASET_GET_DCPL: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); - if((*ret_id = H5D_get_create_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") + if ((*ret_id = H5D_get_create_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") - break; - } + break; + } /* H5Dget_access_plist */ - case H5VL_DATASET_GET_DAPL: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); + case H5VL_DATASET_GET_DAPL: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); - if((*ret_id = H5D_get_access_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") + if ((*ret_id = H5D_get_access_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") - break; - } + break; + } /* H5Dget_storage_size */ - case H5VL_DATASET_GET_STORAGE_SIZE: - { - hsize_t *ret = HDva_arg(arguments, hsize_t *); + case H5VL_DATASET_GET_STORAGE_SIZE: { + hsize_t *ret = HDva_arg(arguments, hsize_t *); - /* Set return value */ - if(H5D__get_storage_size(dset, ret) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") - break; - } + /* Set return value */ + if (H5D__get_storage_size(dset, ret) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") @@ -305,7 +291,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_specific * @@ -316,46 +301,43 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - H5D_t *dset = (H5D_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(specific_type) { + switch (specific_type) { /* H5Dspecific_space */ - case H5VL_DATASET_SET_EXTENT: - { /* H5Dset_extent (H5Dextend - deprecated) */ - const hsize_t *size = HDva_arg(arguments, const hsize_t *); + case H5VL_DATASET_SET_EXTENT: { /* H5Dset_extent (H5Dextend - deprecated) */ + const hsize_t *size = HDva_arg(arguments, const hsize_t *); - if(H5D__set_extent(dset, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") - break; - } + if (H5D__set_extent(dset, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") + break; + } - case H5VL_DATASET_FLUSH: - { /* H5Dflush */ - hid_t dset_id = HDva_arg(arguments, hid_t); + case H5VL_DATASET_FLUSH: { /* H5Dflush */ + hid_t dset_id = HDva_arg(arguments, hid_t); - /* Flush the dataset */ - if(H5D__flush(dset, dset_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") + /* Flush the dataset */ + if (H5D__flush(dset, dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") - break; - } + break; + } - case H5VL_DATASET_REFRESH: - { /* H5Drefresh */ - hid_t dset_id = HDva_arg(arguments, hid_t); + case H5VL_DATASET_REFRESH: { /* H5Drefresh */ + hid_t dset_id = HDva_arg(arguments, hid_t); - /* Refresh the dataset */ - if((H5D__refresh(dset_id, dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") + /* Refresh the dataset */ + if ((H5D__refresh(dset_id, dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") - break; - } + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") @@ -365,7 +347,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_optional * @@ -376,233 +357,225 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - H5D_t *dset = (H5D_t *)obj; /* Dataset */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = (H5D_t *)obj; /* Dataset */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(dset); - switch(optional_type) { - case H5VL_NATIVE_DATASET_FORMAT_CONVERT: - { /* H5Dformat_convert */ - switch(dset->shared->layout.type) { - case H5D_CHUNKED: - /* Convert the chunk indexing type to version 1 B-tree if not */ - if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") - break; - - case H5D_CONTIGUOUS: - case H5D_COMPACT: - /* Downgrade the layout version to 3 if greater than 3 */ - if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") - break; - - case H5D_VIRTUAL: - /* Nothing to do even though layout is version 4 */ - break; - - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") - } /* end switch */ - - break; - } - - case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: - { /* H5Dget_chunk_index_type */ - H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Get the chunk indexing type */ - *idx_type = dset->shared->layout.u.chunk.idx_type; - - break; - } - - case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: - { /* H5Dget_chunk_storage_size */ - hsize_t *offset = HDva_arg(arguments, hsize_t *); - hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Call private function */ - if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") - - break; - } - - case H5VL_NATIVE_DATASET_GET_NUM_CHUNKS: - { /* H5Dget_num_chunks */ - const H5S_t *space = NULL; - hid_t space_id = HDva_arg(arguments, hid_t); - hsize_t *nchunks = HDva_arg(arguments, hsize_t *); - - HDassert(dset->shared); - HDassert(dset->shared->space); - - /* When default dataspace is given, use the dataset's dataspace */ - if(space_id == H5S_ALL) - space = dset->shared->space; - else /* otherwise, use the given space ID */ - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID") - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Call private function */ - if(H5D__get_num_chunks(dset, space, nchunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of chunks") - - break; - } - - case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX: - { /* H5Dget_chunk_info */ - const H5S_t *space = NULL; - hid_t space_id = HDva_arg(arguments, hid_t); - hsize_t chk_index = HDva_arg(arguments, hsize_t); - hsize_t *offset = HDva_arg(arguments, hsize_t *); - unsigned *filter_mask = HDva_arg(arguments, unsigned *); - haddr_t *addr = HDva_arg(arguments, haddr_t *); - hsize_t *size = HDva_arg(arguments, hsize_t *); - - HDassert(dset->shared); - HDassert(dset->shared->space); - - /* When default dataspace is given, use the dataset's dataspace */ - if(space_id == H5S_ALL) - space = dset->shared->space; - else /* otherwise, use the given space ID */ - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID") - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Call private function */ - if(H5D__get_chunk_info(dset, space, chk_index, offset, filter_mask, addr, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by index") - break; - } - - case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD: - { /* H5Dget_chunk_info_by_coord */ - hsize_t *offset = HDva_arg(arguments, hsize_t *); - unsigned *filter_mask = HDva_arg(arguments, unsigned *); - haddr_t *addr = HDva_arg(arguments, haddr_t *); - hsize_t *size = HDva_arg(arguments, hsize_t *); - - HDassert(dset->shared); - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Call private function */ - if(H5D__get_chunk_info_by_coord(dset, offset, filter_mask, addr, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by its logical coordinates") - - break; - } - - case H5VL_NATIVE_DATASET_CHUNK_READ: - { /* H5Dread_chunk */ - const hsize_t *offset = HDva_arg(arguments, hsize_t *); - uint32_t *filters = HDva_arg(arguments, uint32_t *); - void *buf = HDva_arg(arguments, void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - - /* Read the raw chunk */ - if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") - - break; - } - - case H5VL_NATIVE_DATASET_CHUNK_WRITE: - { /* H5Dwrite_chunk */ - uint32_t filters = HDva_arg(arguments, uint32_t); - const hsize_t *offset = HDva_arg(arguments, const hsize_t *); - uint32_t data_size_32 = HDva_arg(arguments, uint32_t); - const void *buf = HDva_arg(arguments, const void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - - /* Write chunk */ - if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") - - break; - } - - case H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE: - { /* H5Dvlen_get_buf_size */ - hid_t type_id = HDva_arg(arguments, hid_t); - hid_t space_id = HDva_arg(arguments, hid_t); - hsize_t *size = HDva_arg(arguments, hsize_t *); - - if(H5D__vlen_get_buf_size(dset, type_id, space_id, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of vlen buf needed") - break; - } + switch (optional_type) { + case H5VL_NATIVE_DATASET_FORMAT_CONVERT: { /* H5Dformat_convert */ + switch (dset->shared->layout.type) { + case H5D_CHUNKED: + /* Convert the chunk indexing type to version 1 B-tree if not */ + if (dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) + if ((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, + "unable to downgrade chunk indexing type for dataset") + break; + + case H5D_CONTIGUOUS: + case H5D_COMPACT: + /* Downgrade the layout version to 3 if greater than 3 */ + if (dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) + if ((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, + "unable to downgrade layout version for dataset") + break; + + case H5D_VIRTUAL: + /* Nothing to do even though layout is version 4 */ + break; + + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") + } /* end switch */ + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: { /* H5Dget_chunk_index_type */ + H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Get the chunk indexing type */ + *idx_type = dset->shared->layout.u.chunk.idx_type; + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: { /* H5Dget_chunk_storage_size */ + hsize_t *offset = HDva_arg(arguments, hsize_t *); + hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if (H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") + + break; + } + + case H5VL_NATIVE_DATASET_GET_NUM_CHUNKS: { /* H5Dget_num_chunks */ + const H5S_t *space = NULL; + hid_t space_id = HDva_arg(arguments, hid_t); + hsize_t * nchunks = HDva_arg(arguments, hsize_t *); + + HDassert(dset->shared); + HDassert(dset->shared->space); + + /* When default dataspace is given, use the dataset's dataspace */ + if (space_id == H5S_ALL) + space = dset->shared->space; + else /* otherwise, use the given space ID */ + if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID") + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if (H5D__get_num_chunks(dset, space, nchunks) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of chunks") + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX: { /* H5Dget_chunk_info */ + const H5S_t *space = NULL; + hid_t space_id = HDva_arg(arguments, hid_t); + hsize_t chk_index = HDva_arg(arguments, hsize_t); + hsize_t * offset = HDva_arg(arguments, hsize_t *); + unsigned * filter_mask = HDva_arg(arguments, unsigned *); + haddr_t * addr = HDva_arg(arguments, haddr_t *); + hsize_t * size = HDva_arg(arguments, hsize_t *); + + HDassert(dset->shared); + HDassert(dset->shared->space); + + /* When default dataspace is given, use the dataset's dataspace */ + if (space_id == H5S_ALL) + space = dset->shared->space; + else /* otherwise, use the given space ID */ + if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID") + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if (H5D__get_chunk_info(dset, space, chk_index, offset, filter_mask, addr, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by index") + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD: { /* H5Dget_chunk_info_by_coord */ + hsize_t * offset = HDva_arg(arguments, hsize_t *); + unsigned *filter_mask = HDva_arg(arguments, unsigned *); + haddr_t * addr = HDva_arg(arguments, haddr_t *); + hsize_t * size = HDva_arg(arguments, hsize_t *); + + HDassert(dset->shared); + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if (H5D__get_chunk_info_by_coord(dset, offset, filter_mask, addr, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by its logical coordinates") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_READ: { /* H5Dread_chunk */ + const hsize_t *offset = HDva_arg(arguments, hsize_t *); + uint32_t * filters = HDva_arg(arguments, uint32_t *); + void * buf = HDva_arg(arguments, void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + /* Check arguments */ + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Read the raw chunk */ + if (H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_WRITE: { /* H5Dwrite_chunk */ + uint32_t filters = HDva_arg(arguments, uint32_t); + const hsize_t *offset = HDva_arg(arguments, const hsize_t *); + uint32_t data_size_32 = HDva_arg(arguments, uint32_t); + const void * buf = HDva_arg(arguments, const void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + /* Check arguments */ + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Write chunk */ + if (H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") + + break; + } + + case H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE: { /* H5Dvlen_get_buf_size */ + hid_t type_id = HDva_arg(arguments, hid_t); + hid_t space_id = HDva_arg(arguments, hid_t); + hsize_t *size = HDva_arg(arguments, hsize_t *); + + if (H5D__vlen_get_buf_size(dset, type_id, space_id, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of vlen buf needed") + break; + } /* H5Dget_offset */ - case H5VL_NATIVE_DATASET_GET_OFFSET: - { - haddr_t *ret = HDva_arg(arguments, haddr_t *); + case H5VL_NATIVE_DATASET_GET_OFFSET: { + haddr_t *ret = HDva_arg(arguments, haddr_t *); - /* Set return value */ - *ret = H5D__get_offset(dset); - if(!H5F_addr_defined(*ret)) - *ret = HADDR_UNDEF; - break; - } + /* Set return value */ + *ret = H5D__get_offset(dset); + if (!H5F_addr_defined(*ret)) + *ret = HADDR_UNDEF; + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") @@ -612,7 +585,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_dataset_close * @@ -624,17 +596,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) +H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5D_close((H5D_t*)dset) < 0) + if (H5D_close((H5D_t *)dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_dataset_close() */ - diff --git a/src/H5VLnative_datatype.c b/src/H5VLnative_datatype.c index 1e9d739..5b585ad 100644 --- a/src/H5VLnative_datatype.c +++ b/src/H5VLnative_datatype.c @@ -15,21 +15,19 @@ * */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - - /*------------------------------------------------------------------------- * Function: H5VL__native_datatype_commit * @@ -41,66 +39,65 @@ *------------------------------------------------------------------------- */ void * -H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, + hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5G_loc_t loc; /* Location to commit datatype */ - H5T_t *dt; /* Datatype for ID */ - H5T_t *type = NULL; /* copy of the original type which will be committed */ - void *ret_value = NULL; /* Return value */ + H5G_loc_t loc; /* Location to commit datatype */ + H5T_t * dt; /* Datatype for ID */ + H5T_t * type = NULL; /* copy of the original type which will be committed */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") /* Check arguments. We cannot commit an immutable type because H5Tclose() * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing * a named type should always succeed. */ - if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) + if (H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") - if(H5T_STATE_IMMUTABLE == dt->shared->state) + if (H5T_STATE_IMMUTABLE == dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") /* Check for a "sensible" datatype to store on disk */ - if(H5T_is_sensible(dt) <= 0) + if (H5T_is_sensible(dt) <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") /* Copy the datatype - the copied one will be the type that is * committed, and attached to original datatype above the VOL * layer */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) + if (NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); /* Commit the datatype */ - if(NULL != name) { + if (NULL != name) { /* H5Tcommit */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) + if (H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") } /* end if */ else { /* H5Tcommit_anon */ - if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) + if (H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") } /* end else */ ret_value = (void *)type; done: - if(NULL == ret_value && type) + if (NULL == ret_value && type) H5T_close(type); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_datatype_commit() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_datatype_open * @@ -113,19 +110,20 @@ done: */ void * H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) + hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { - H5T_t *type = NULL; /* Datatype opened in file */ - H5G_loc_t loc; /* Group location of object to open */ - void *ret_value = NULL; + H5T_t * type = NULL; /* Datatype opened in file */ + H5G_loc_t loc; /* Group location of object to open */ + void * ret_value = NULL; FUNC_ENTER_PACKAGE - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") /* Open the datatype */ - if(NULL == (type = H5T__open_name(&loc, name))) + if (NULL == (type = H5T__open_name(&loc, name))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") type->vol_obj = NULL; @@ -136,7 +134,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_datatype_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_datatype_get * @@ -147,38 +144,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - H5T_t *dt = (H5T_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE switch (get_type) { - case H5VL_DATATYPE_GET_BINARY: - { - ssize_t *nalloc = HDva_arg(arguments, ssize_t *); - void *buf = HDva_arg(arguments, void *); - size_t size = HDva_arg(arguments, size_t); + case H5VL_DATATYPE_GET_BINARY: { + ssize_t *nalloc = HDva_arg(arguments, ssize_t *); + void * buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); - if(H5T_encode(dt, (unsigned char *)buf, &size) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") + if (H5T_encode(dt, (unsigned char *)buf, &size) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") - *nalloc = (ssize_t) size; - break; - } + *nalloc = (ssize_t)size; + break; + } /* H5Tget_create_plist */ - case H5VL_DATATYPE_GET_TCPL: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); + case H5VL_DATATYPE_GET_TCPL: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); - if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); + if (H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); - break; - } + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") @@ -188,7 +183,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_datatype_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_datatype_specific * @@ -200,35 +194,33 @@ done: */ herr_t H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) { - H5T_t *dt = (H5T_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(specific_type) { - case H5VL_DATATYPE_FLUSH: - { - hid_t type_id = HDva_arg(arguments, hid_t); + switch (specific_type) { + case H5VL_DATATYPE_FLUSH: { + hid_t type_id = HDva_arg(arguments, hid_t); - /* To flush metadata and invoke flush callback if there is */ - if(H5O_flush_common(&dt->oloc, type_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") + /* To flush metadata and invoke flush callback if there is */ + if (H5O_flush_common(&dt->oloc, type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") - break; - } + break; + } - case H5VL_DATATYPE_REFRESH: - { - hid_t type_id = HDva_arg(arguments, hid_t); + case H5VL_DATATYPE_REFRESH: { + hid_t type_id = HDva_arg(arguments, hid_t); - /* Call private function to refresh datatype object */ - if((H5O_refresh_metadata(type_id, dt->oloc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + /* Call private function to refresh datatype object */ + if ((H5O_refresh_metadata(type_id, dt->oloc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") - break; - } + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") @@ -238,7 +230,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_datatype_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_datatype_close * @@ -252,14 +243,13 @@ done: herr_t H5VL__native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5T_close((H5T_t*)dt) < 0) + if (H5T_close((H5T_t *)dt) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_datatype_close() */ - diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 563f4a6..a035dab 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -15,24 +15,22 @@ * */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Cprivate.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5PBprivate.h" /* Page buffering */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cprivate.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5PBprivate.h" /* Page buffering */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - - /*------------------------------------------------------------------------- * Function: H5VL__native_file_create * @@ -45,10 +43,10 @@ */ void * H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5F_t *new_file = NULL; - void *ret_value = NULL; + H5F_t *new_file = NULL; + void * ret_value = NULL; FUNC_ENTER_PACKAGE @@ -56,26 +54,25 @@ H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t * the EXCL or TRUNC bit is set. All newly-created files are opened for * reading and writing. */ - if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /* default */ + if (0 == (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /* default */ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* Create the file */ - if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) + if (NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") new_file->id_exists = TRUE; ret_value = (void *)new_file; done: - if(NULL == ret_value && new_file) - if(H5F__close(new_file) < 0) + if (NULL == ret_value && new_file) + if (H5F__close(new_file) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_file_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_file_open * @@ -87,29 +84,28 @@ done: *------------------------------------------------------------------------- */ void * -H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { - H5F_t *new_file = NULL; - void *ret_value = NULL; + H5F_t *new_file = NULL; + void * ret_value = NULL; FUNC_ENTER_PACKAGE /* Open the file */ - if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) + if (NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") new_file->id_exists = TRUE; ret_value = (void *)new_file; done: - if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) + if (NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_file_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_file_get * @@ -120,163 +116,155 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - H5F_t *f = NULL; /* File struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *f = NULL; /* File struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(get_type) { + switch (get_type) { /* "get container info" */ - case H5VL_FILE_GET_CONT_INFO: - { - H5VL_file_cont_info_t *info = HDva_arg(arguments, H5VL_file_cont_info_t *); + case H5VL_FILE_GET_CONT_INFO: { + H5VL_file_cont_info_t *info = HDva_arg(arguments, H5VL_file_cont_info_t *); - /* Retrieve the file's container info */ - if(H5F__get_cont_info((H5F_t *)obj, info) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file container info") + /* Retrieve the file's container info */ + if (H5F__get_cont_info((H5F_t *)obj, info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file container info") - break; - } + break; + } /* H5Fget_access_plist */ - case H5VL_FILE_GET_FAPL: - { - H5P_genplist_t *new_plist; /* New property list */ - hid_t *plist_id = HDva_arg(arguments, hid_t *); + case H5VL_FILE_GET_FAPL: { + H5P_genplist_t *new_plist; /* New property list */ + hid_t * plist_id = HDva_arg(arguments, hid_t *); - f = (H5F_t *)obj; + f = (H5F_t *)obj; - /* Retrieve the file's access property list */ - if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file access property list") + /* Retrieve the file's access property list */ + if ((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file access property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - break; - } + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + break; + } /* H5Fget_create_plist */ - case H5VL_FILE_GET_FCPL: - { - H5P_genplist_t *plist; /* Property list */ - hid_t *plist_id = HDva_arg(arguments, hid_t *); + case H5VL_FILE_GET_FCPL: { + H5P_genplist_t *plist; /* Property list */ + hid_t * plist_id = HDva_arg(arguments, hid_t *); - f = (H5F_t *)obj; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + f = (H5F_t *)obj; + if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - /* Create the property list object to return */ - if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") + /* Create the property list object to return */ + if ((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") - break; - } + break; + } /* H5Fget_intent */ - case H5VL_FILE_GET_INTENT: - { - unsigned *intent_flags = HDva_arg(arguments, unsigned *); - - f = (H5F_t *)obj; - - /* HDF5 uses some flags internally that users don't know about. - * Simplify things for them so that they only get either H5F_ACC_RDWR - * or H5F_ACC_RDONLY and any SWMR flags. - */ - if(H5F_INTENT(f) & H5F_ACC_RDWR) { - *intent_flags = H5F_ACC_RDWR; - - /* Check for SWMR write access on the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - *intent_flags |= H5F_ACC_SWMR_WRITE; - } /* end if */ - else { - *intent_flags = H5F_ACC_RDONLY; + case H5VL_FILE_GET_INTENT: { + unsigned *intent_flags = HDva_arg(arguments, unsigned *); - /* Check for SWMR read access on the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) - *intent_flags |= H5F_ACC_SWMR_READ; - } /* end else */ + f = (H5F_t *)obj; + + /* HDF5 uses some flags internally that users don't know about. + * Simplify things for them so that they only get either H5F_ACC_RDWR + * or H5F_ACC_RDONLY and any SWMR flags. + */ + if (H5F_INTENT(f) & H5F_ACC_RDWR) { + *intent_flags = H5F_ACC_RDWR; + + /* Check for SWMR write access on the file */ + if (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) + *intent_flags |= H5F_ACC_SWMR_WRITE; + } /* end if */ + else { + *intent_flags = H5F_ACC_RDONLY; - break; - } + /* Check for SWMR read access on the file */ + if (H5F_INTENT(f) & H5F_ACC_SWMR_READ) + *intent_flags |= H5F_ACC_SWMR_READ; + } /* end else */ + + break; + } /* H5Fget_fileno */ - case H5VL_FILE_GET_FILENO: - { - unsigned long *fno = HDva_arg(arguments, unsigned long *); - unsigned long my_fileno = 0; + case H5VL_FILE_GET_FILENO: { + unsigned long *fno = HDva_arg(arguments, unsigned long *); + unsigned long my_fileno = 0; - f = (H5F_t *)obj; - H5F_GET_FILENO(f, my_fileno); - *fno = my_fileno; /* sigh */ + f = (H5F_t *)obj; + H5F_GET_FILENO(f, my_fileno); + *fno = my_fileno; /* sigh */ - break; - } + break; + } /* H5Fget_name */ - case H5VL_FILE_GET_NAME: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - size_t size = HDva_arg(arguments, size_t); - char *name = HDva_arg(arguments, char *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t len; - - if(H5VL_native_get_file_struct(obj, type, &f) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - len = HDstrlen(H5F_OPEN_NAME(f)); - - if(name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); - if(len >= size) - name[size-1]='\0'; - } /* end if */ + case H5VL_FILE_GET_NAME: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + size_t size = HDva_arg(arguments, size_t); + char * name = HDva_arg(arguments, char *); + ssize_t * ret = HDva_arg(arguments, ssize_t *); + size_t len; + + if (H5VL_native_get_file_struct(obj, type, &f) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + len = HDstrlen(H5F_OPEN_NAME(f)); + + if (name) { + HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1, size)); + if (len >= size) + name[size - 1] = '\0'; + } /* end if */ - /* Set the return value for the API call */ - *ret = (ssize_t)len; - break; - } + /* Set the return value for the API call */ + *ret = (ssize_t)len; + break; + } /* H5Fget_obj_count */ - case H5VL_FILE_GET_OBJ_COUNT: - { - unsigned types = HDva_arg(arguments, unsigned); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - - /* Set the return value */ - *ret = (ssize_t)obj_count; - break; - } + case H5VL_FILE_GET_OBJ_COUNT: { + unsigned types = HDva_arg(arguments, unsigned); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if (H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } /* H5Fget_obj_ids */ - case H5VL_FILE_GET_OBJ_IDS: - { - unsigned types = HDva_arg(arguments, unsigned); - size_t max_objs = HDva_arg(arguments, size_t); - hid_t *oid_list = HDva_arg(arguments, hid_t *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") - - /* Set the return value */ - *ret = (ssize_t)obj_count; - break; - } + case H5VL_FILE_GET_OBJ_IDS: { + unsigned types = HDva_arg(arguments, unsigned); + size_t max_objs = HDva_arg(arguments, size_t); + hid_t * oid_list = HDva_arg(arguments, hid_t *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if (H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") @@ -286,7 +274,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_file_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_file_specific * @@ -297,130 +284,125 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(specific_type) { + switch (specific_type) { /* H5Fflush */ - case H5VL_FILE_FLUSH: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_scope_t scope = (H5F_scope_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_t *f = NULL; /* File to flush */ - - /* Get the file for the object */ - if(H5VL_native_get_file_struct(obj, type, &f) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Nothing to do if the file is read only. This determination is - * made at the shared open(2) flags level, implying that opening a - * file twice, once for read-only and once for read-write, and then - * calling H5Fflush() with the read-only handle, still causes data - * to be flushed. - */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { - /* Flush other files, depending on scope */ - if(H5F_SCOPE_GLOBAL == scope) { - /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") - } /* end if */ - else { - /* Call the flush routine, for this file */ - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - } /* end else */ - } /* end if */ - break; - } + case H5VL_FILE_FLUSH: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_scope_t scope = (H5F_scope_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_t * f = NULL; /* File to flush */ + + /* Get the file for the object */ + if (H5VL_native_get_file_struct(obj, type, &f) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Nothing to do if the file is read only. This determination is + * made at the shared open(2) flags level, implying that opening a + * file twice, once for read-only and once for read-write, and then + * calling H5Fflush() with the read-only handle, still causes data + * to be flushed. + */ + if (H5F_ACC_RDWR & H5F_INTENT(f)) { + /* Flush other files, depending on scope */ + if (H5F_SCOPE_GLOBAL == scope) { + /* Call the flush routine for mounted file hierarchies */ + if (H5F_flush_mounts(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") + } /* end if */ + else { + /* Call the flush routine, for this file */ + if (H5F__flush(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, + "unable to flush file's cached information") + } /* end else */ + } /* end if */ + break; + } /* H5Freopen */ - case H5VL_FILE_REOPEN: - { - void **ret = HDva_arg(arguments, void **); - H5F_t *new_file = NULL; + case H5VL_FILE_REOPEN: { + void **ret = HDva_arg(arguments, void **); + H5F_t *new_file = NULL; - /* Reopen the file through the VOL connector */ - if(NULL == (new_file = H5F__reopen((H5F_t *)obj))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") - new_file->id_exists = TRUE; + /* Reopen the file through the VOL connector */ + if (NULL == (new_file = H5F__reopen((H5F_t *)obj))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + new_file->id_exists = TRUE; - *ret = (void *)new_file; - break; - } + *ret = (void *)new_file; + break; + } /* H5Fmount */ - case H5VL_FILE_MOUNT: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - const char *name = HDva_arg(arguments, const char *); - H5F_t *child = HDva_arg(arguments, H5F_t *); - hid_t fmpl_id = HDva_arg(arguments, hid_t); - H5G_loc_t loc; + case H5VL_FILE_MOUNT: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5F_t * child = HDva_arg(arguments, H5F_t *); + hid_t fmpl_id = HDva_arg(arguments, hid_t); + H5G_loc_t loc; - if(H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if (H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - /* Do the mount */ - if(H5F__mount(&loc, name, child, fmpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + /* Do the mount */ + if (H5F__mount(&loc, name, child, fmpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") - break; - } + break; + } /* H5Funmount */ - case H5VL_FILE_UNMOUNT: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - const char *name = HDva_arg(arguments, const char *); - H5G_loc_t loc; + case H5VL_FILE_UNMOUNT: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5G_loc_t loc; - if(H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if (H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - /* Unmount */ - if(H5F__unmount(&loc, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + /* Unmount */ + if (H5F__unmount(&loc, name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") - break; - } + break; + } /* H5Fis_accessible */ - case H5VL_FILE_IS_ACCESSIBLE: - { - hid_t fapl_id = HDva_arg(arguments, hid_t); - const char *name = HDva_arg(arguments, const char *); - htri_t *result = HDva_arg(arguments, htri_t *); - - /* Call private routine */ - if((*result = H5F__is_hdf5(name, fapl_id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "error in HDF5 file check") - break; - } + case H5VL_FILE_IS_ACCESSIBLE: { + hid_t fapl_id = HDva_arg(arguments, hid_t); + const char *name = HDva_arg(arguments, const char *); + htri_t * result = HDva_arg(arguments, htri_t *); + + /* Call private routine */ + if ((*result = H5F__is_hdf5(name, fapl_id)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "error in HDF5 file check") + break; + } /* H5Fdelete */ - case H5VL_FILE_DELETE: - { - HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "H5Fdelete() is currently not supported in the native VOL connector") - break; - } + case H5VL_FILE_DELETE: { + HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, + "H5Fdelete() is currently not supported in the native VOL connector") + break; + } /* Check if two files are the same */ - case H5VL_FILE_IS_EQUAL: - { - H5F_t *file2 = (H5F_t *)HDva_arg(arguments, void *); - hbool_t *is_equal = HDva_arg(arguments, hbool_t *); - - if(!obj || !file2) - *is_equal = FALSE; - else - *is_equal = (((H5F_t *)obj)->shared == file2->shared); - break; - } + case H5VL_FILE_IS_EQUAL: { + H5F_t * file2 = (H5F_t *)HDva_arg(arguments, void *); + hbool_t *is_equal = HDva_arg(arguments, hbool_t *); + + if (!obj || !file2) + *is_equal = FALSE; + else + *is_equal = (((H5F_t *)obj)->shared == file2->shared); + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") @@ -430,7 +412,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_file_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_file_optional * @@ -441,419 +422,391 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - H5F_t *f = NULL; /* File */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *f = NULL; /* File */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE f = (H5F_t *)obj; - switch(optional_type) { + switch (optional_type) { /* H5Fget_filesize */ - case H5VL_NATIVE_FILE_GET_SIZE: - { - haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ - haddr_t base_addr; /* Base address for the file */ - hsize_t *size = HDva_arg(arguments, hsize_t *); + case H5VL_NATIVE_FILE_GET_SIZE: { + haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ + haddr_t base_addr; /* Base address for the file */ + hsize_t *size = HDva_arg(arguments, hsize_t *); - /* Go get the actual file size */ - if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + /* Go get the actual file size */ + if (H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - base_addr = H5FD_get_base_addr(f->shared->lf); + base_addr = H5FD_get_base_addr(f->shared->lf); - if(size) - *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ + if (size) + *size = (hsize_t)(max_eof_eoa + + base_addr); /* Convert relative base address for file to absolute address */ - break; - } + break; + } /* H5Fget_file_image */ - case H5VL_NATIVE_FILE_GET_FILE_IMAGE: - { - void *buf_ptr = HDva_arg(arguments, void *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t buf_len = HDva_arg(arguments, size_t ); - - /* Do the actual work */ - if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") - break; - } + case H5VL_NATIVE_FILE_GET_FILE_IMAGE: { + void * buf_ptr = HDva_arg(arguments, void *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t buf_len = HDva_arg(arguments, size_t); + + /* Do the actual work */ + if ((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") + break; + } /* H5Fget_freespace */ - case H5VL_NATIVE_FILE_GET_FREE_SPACE: - { - hsize_t tot_space; /* Amount of free space in the file */ - hssize_t *ret = HDva_arg(arguments, hssize_t *); - - /* Go get the actual amount of free space in the file */ - if(H5MF_get_freespace(f, &tot_space, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - *ret = (hssize_t)tot_space; - break; - } + case H5VL_NATIVE_FILE_GET_FREE_SPACE: { + hsize_t tot_space; /* Amount of free space in the file */ + hssize_t *ret = HDva_arg(arguments, hssize_t *); + + /* Go get the actual amount of free space in the file */ + if (H5MF_get_freespace(f, &tot_space, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + *ret = (hssize_t)tot_space; + break; + } /* H5Fget_free_sections */ - case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: - { - H5F_sect_info_t *sect_info = HDva_arg(arguments, H5F_sect_info_t *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - H5F_mem_t type = (H5F_mem_t)HDva_arg(arguments, int); /* enum work-around */ - size_t nsects = HDva_arg(arguments, size_t); - - /* Go get the free-space section information in the file */ - if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - break; - } + case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: { + H5F_sect_info_t *sect_info = HDva_arg(arguments, H5F_sect_info_t *); + ssize_t * ret = HDva_arg(arguments, ssize_t *); + H5F_mem_t type = (H5F_mem_t)HDva_arg(arguments, int); /* enum work-around */ + size_t nsects = HDva_arg(arguments, size_t); + + /* Go get the free-space section information in the file */ + if ((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + break; + } /* H5Fget_info1/2 */ - case H5VL_NATIVE_FILE_GET_INFO: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_info2_t *finfo = HDva_arg(arguments, H5F_info2_t *); + case H5VL_NATIVE_FILE_GET_INFO: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_info2_t *finfo = HDva_arg(arguments, H5F_info2_t *); - /* Get the file struct. This call is careful to not return the file pointer - * for the top file in a mount hierarchy. - */ - if(H5VL_native_get_file_struct(obj, type, &f) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") + /* Get the file struct. This call is careful to not return the file pointer + * for the top file in a mount hierarchy. + */ + if (H5VL_native_get_file_struct(obj, type, &f) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") - /* Get the file info */ - if(H5F__get_info(f, finfo) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") + /* Get the file info */ + if (H5F__get_info(f, finfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") - break; - } + break; + } /* H5Fget_mdc_config */ - case H5VL_NATIVE_FILE_GET_MDC_CONF: - { - H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + case H5VL_NATIVE_FILE_GET_MDC_CONF: { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); - /* Go get the resize configuration */ - if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") - break; - } + /* Go get the resize configuration */ + if (H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") + break; + } /* H5Fget_mdc_hit_rate */ - case H5VL_NATIVE_FILE_GET_MDC_HR: - { - double *hit_rate_ptr = HDva_arg(arguments, double *); + case H5VL_NATIVE_FILE_GET_MDC_HR: { + double *hit_rate_ptr = HDva_arg(arguments, double *); - /* Go get the current hit rate */ - if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") - break; - } + /* Go get the current hit rate */ + if (H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") + break; + } /* H5Fget_mdc_size */ - case H5VL_NATIVE_FILE_GET_MDC_SIZE: - { - size_t *max_size_ptr = HDva_arg(arguments, size_t *); - size_t *min_clean_size_ptr = HDva_arg(arguments, size_t *); - size_t *cur_size_ptr = HDva_arg(arguments, size_t *); - int *cur_num_entries_ptr = HDva_arg(arguments, int *); - uint32_t cur_num_entries; - - /* Go get the size data */ - if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, - cur_size_ptr, &cur_num_entries) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") - - if(cur_num_entries_ptr != NULL) - *cur_num_entries_ptr = (int)cur_num_entries; - break; - } + case H5VL_NATIVE_FILE_GET_MDC_SIZE: { + size_t * max_size_ptr = HDva_arg(arguments, size_t *); + size_t * min_clean_size_ptr = HDva_arg(arguments, size_t *); + size_t * cur_size_ptr = HDva_arg(arguments, size_t *); + int * cur_num_entries_ptr = HDva_arg(arguments, int *); + uint32_t cur_num_entries; + + /* Go get the size data */ + if (H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, cur_size_ptr, + &cur_num_entries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + + if (cur_num_entries_ptr != NULL) + *cur_num_entries_ptr = (int)cur_num_entries; + break; + } /* H5Fget_vfd_handle */ - case H5VL_NATIVE_FILE_GET_VFD_HANDLE: - { - void **file_handle = HDva_arg(arguments, void **); - hid_t fapl_id = HDva_arg(arguments, hid_t); + case H5VL_NATIVE_FILE_GET_VFD_HANDLE: { + void **file_handle = HDva_arg(arguments, void **); + hid_t fapl_id = HDva_arg(arguments, hid_t); - /* Retrieve the VFD handle for the file */ - if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") - break; - } + /* Retrieve the VFD handle for the file */ + if (H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + break; + } /* H5Fclear_elink_file_cache */ - case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: - { - /* Release the EFC */ - if(f->shared->efc) - if(H5F__efc_release(f->shared->efc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") - break; - } + case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: { + /* Release the EFC */ + if (f->shared->efc) + if (H5F__efc_release(f->shared->efc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + break; + } /* H5Freset_mdc_hit_rate_stats */ - case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: - { - /* Reset the hit rate statistic */ - if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") - break; - } + case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: { + /* Reset the hit rate statistic */ + if (H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") + break; + } /* H5Fset_mdc_config */ - case H5VL_NATIVE_FILE_SET_MDC_CONFIG: - { - H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + case H5VL_NATIVE_FILE_SET_MDC_CONFIG: { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); - /* set the resize configuration */ - if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") - break; - } + /* set the resize configuration */ + if (H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") + break; + } /* H5Fget_metadata_read_retry_info */ - case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: - { - H5F_retry_info_t *info = HDva_arg(arguments, H5F_retry_info_t *); + case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: { + H5F_retry_info_t *info = HDva_arg(arguments, H5F_retry_info_t *); - if(H5F_get_metadata_read_retry_info(f, info) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") + if (H5F_get_metadata_read_retry_info(f, info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") - break; - } + break; + } /* H5Fstart_swmr_write */ - case H5VL_NATIVE_FILE_START_SWMR_WRITE: - { - if(H5F__start_swmr_write(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") + case H5VL_NATIVE_FILE_START_SWMR_WRITE: { + if (H5F__start_swmr_write(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") - break; - } + break; + } /* H5Fstart_mdc_logging */ - case H5VL_NATIVE_FILE_START_MDC_LOGGING: - { - /* Call mdc logging function */ - if(H5C_start_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") + case H5VL_NATIVE_FILE_START_MDC_LOGGING: { + /* Call mdc logging function */ + if (H5C_start_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") - break; - } + break; + } /* H5Fstop_mdc_logging */ - case H5VL_NATIVE_FILE_STOP_MDC_LOGGING: - { - /* Call mdc logging function */ - if(H5C_stop_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") + case H5VL_NATIVE_FILE_STOP_MDC_LOGGING: { + /* Call mdc logging function */ + if (H5C_stop_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") - break; - } + break; + } /* H5Fget_mdc_logging_status */ - case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: - { - hbool_t *is_enabled = HDva_arg(arguments, hbool_t *); - hbool_t *is_currently_logging = HDva_arg(arguments, hbool_t *); + case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: { + hbool_t *is_enabled = HDva_arg(arguments, hbool_t *); + hbool_t *is_currently_logging = HDva_arg(arguments, hbool_t *); - /* Call mdc logging function */ - if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") + /* Call mdc logging function */ + if (H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") - break; - } + break; + } /* H5Fformat_convert */ - case H5VL_NATIVE_FILE_FORMAT_CONVERT: - { - /* Convert the format */ - if(H5F__format_convert(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") + case H5VL_NATIVE_FILE_FORMAT_CONVERT: { + /* Convert the format */ + if (H5F__format_convert(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") - break; - } + break; + } /* H5Freset_page_buffering_stats */ - case H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS: - { - /* Sanity check */ - if(NULL == f->shared->pb_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + case H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS: { + /* Sanity check */ + if (NULL == f->shared->pb_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") - /* Reset the statistics */ - if(H5PB_reset_stats(f->shared->pb_ptr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") + /* Reset the statistics */ + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") - break; - } + break; + } /* H5Fget_page_buffering_stats */ - case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: - { - unsigned *accesses = HDva_arg(arguments, unsigned *); - unsigned *hits = HDva_arg(arguments, unsigned *); - unsigned *misses = HDva_arg(arguments, unsigned *); - unsigned *evictions = HDva_arg(arguments, unsigned *); - unsigned *bypasses = HDva_arg(arguments, unsigned *); + case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: { + unsigned *accesses = HDva_arg(arguments, unsigned *); + unsigned *hits = HDva_arg(arguments, unsigned *); + unsigned *misses = HDva_arg(arguments, unsigned *); + unsigned *evictions = HDva_arg(arguments, unsigned *); + unsigned *bypasses = HDva_arg(arguments, unsigned *); - /* Sanity check */ - if(NULL == f->shared->pb_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + /* Sanity check */ + if (NULL == f->shared->pb_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") - /* Get the statistics */ - if(H5PB_get_stats(f->shared->pb_ptr, accesses, hits, misses, evictions, bypasses) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") + /* Get the statistics */ + if (H5PB_get_stats(f->shared->pb_ptr, accesses, hits, misses, evictions, bypasses) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") - break; - } + break; + } /* H5Fget_mdc_image_info */ - case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: - { - haddr_t *image_addr = HDva_arg(arguments, haddr_t *); - hsize_t *image_len = HDva_arg(arguments, hsize_t *); + case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: { + haddr_t *image_addr = HDva_arg(arguments, haddr_t *); + hsize_t *image_len = HDva_arg(arguments, hsize_t *); - /* Go get the address and size of the cache image */ - if(H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") + /* Go get the address and size of the cache image */ + if (H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") - break; - } + break; + } /* H5Fget_eoa */ - case H5VL_NATIVE_FILE_GET_EOA: - { - haddr_t *eoa = HDva_arg(arguments, haddr_t *); - haddr_t rel_eoa; /* Relative address of EOA */ + case H5VL_NATIVE_FILE_GET_EOA: { + haddr_t *eoa = HDva_arg(arguments, haddr_t *); + haddr_t rel_eoa; /* Relative address of EOA */ - /* Sanity check */ - HDassert(eoa); + /* Sanity check */ + HDassert(eoa); - /* This routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") + /* This routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if (!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "must use a SWMR-compatible VFD for this public routine") - /* The real work */ - if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") + /* The real work */ + if (HADDR_UNDEF == (rel_eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") - /* Set return value */ - /* (Note compensating for base address subtraction in internal routine) */ - *eoa = rel_eoa + H5F_get_base_addr(f); + /* Set return value */ + /* (Note compensating for base address subtraction in internal routine) */ + *eoa = rel_eoa + H5F_get_base_addr(f); - break; - } + break; + } /* H5Fincrement_filesize */ - case H5VL_NATIVE_FILE_INCR_FILESIZE: - { - hsize_t increment = HDva_arg(arguments, hsize_t); - haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ + case H5VL_NATIVE_FILE_INCR_FILESIZE: { + hsize_t increment = HDva_arg(arguments, hsize_t); + haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ - /* This public routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") + /* This public routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if (!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "must use a SWMR-compatible VFD for this public routine") - /* Get the maximum of EOA and EOF */ - if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + /* Get the maximum of EOA and EOF */ + if (H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - /* Set EOA to the maximum value + increment */ - if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") + /* Set EOA to the maximum value + increment */ + if (H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") - break; - } + break; + } /* H5Fset_latest_format, H5Fset_libver_bounds */ - case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: - { - H5F_libver_t low = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_libver_t high = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: { + H5F_libver_t low = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_libver_t high = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ - /* Call internal set_libver_bounds function */ - if(H5F__set_libver_bounds(f, low, high) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + /* Call internal set_libver_bounds function */ + if (H5F__set_libver_bounds(f, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") - break; - } + break; + } /* H5Fget_dset_no_attrs_hint */ - case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG: - { - hbool_t *minimize = HDva_arg(arguments, hbool_t *); - *minimize = H5F_GET_MIN_DSET_OHDR(f); - break; - } + case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG: { + hbool_t *minimize = HDva_arg(arguments, hbool_t *); + *minimize = H5F_GET_MIN_DSET_OHDR(f); + break; + } /* H5Fset_dset_no_attrs_hint */ - case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG: - { - int minimize = HDva_arg(arguments, int); - if(H5F_set_min_dset_ohdr(f, (hbool_t)minimize) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set file's dataset object header minimization flag") - break; - } + case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG: { + int minimize = HDva_arg(arguments, int); + if (H5F_set_min_dset_ohdr(f, (hbool_t)minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, + "cannot set file's dataset object header minimization flag") + break; + } #ifdef H5_HAVE_PARALLEL /* H5Fget_mpi_atomicity */ - case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: - { - hbool_t *flag = (hbool_t *)HDva_arg(arguments, hbool_t *); - if (H5F_get_mpi_atomicity(f, flag) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "cannot get MPI atomicity"); - break; - } + case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: { + hbool_t *flag = (hbool_t *)HDva_arg(arguments, hbool_t *); + if (H5F_get_mpi_atomicity(f, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "cannot get MPI atomicity"); + break; + } /* H5Fset_mpi_atomicity */ - case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: - { - hbool_t flag = (hbool_t)HDva_arg(arguments, int); - if (H5F_set_mpi_atomicity(f, flag) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set MPI atomicity"); - break; - } + case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: { + hbool_t flag = (hbool_t)HDva_arg(arguments, int); + if (H5F_set_mpi_atomicity(f, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set MPI atomicity"); + break; + } #endif /* H5_HAVE_PARALLEL */ /* Finalize H5Fopen */ - case H5VL_NATIVE_FILE_POST_OPEN: - { - /* Call package routine */ - if(H5F__post_open((H5F_t *)obj) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't finish opening file") - break; - } + case H5VL_NATIVE_FILE_POST_OPEN: { + /* Call package routine */ + if (H5F__post_open((H5F_t *)obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't finish opening file") + break; + } /* H5Fvfd_swmr_disable_end_of_tick() */ - case H5VL_NATIVE_FILE_VFD_SWMR_DISABLE_EOT: - { - /* Call package routine */ - if(H5F__vfd_swmr_disable_end_of_tick((H5F_t *)obj) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't disable EOT for VFD SWMR") - break; - } + case H5VL_NATIVE_FILE_VFD_SWMR_DISABLE_EOT: { + /* Call package routine */ + if (H5F__vfd_swmr_disable_end_of_tick((H5F_t *)obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't disable EOT for VFD SWMR") + break; + } /* H5Fvfd_swmr_enable_end_of_tick() */ - case H5VL_NATIVE_FILE_VFD_SWMR_ENABLE_EOT: - { - /* Call package routine */ - if(H5F__vfd_swmr_enable_end_of_tick((H5F_t *)obj) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't enable EOT for VFD SWMR") - break; - } + case H5VL_NATIVE_FILE_VFD_SWMR_ENABLE_EOT: { + /* Call package routine */ + if (H5F__vfd_swmr_enable_end_of_tick((H5F_t *)obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't enable EOT for VFD SWMR") + break; + } /* H5Fvfd_swmr_end_tick() */ - case H5VL_NATIVE_FILE_VFD_SWMR_END_TICK: - { - /* Call package routine */ - if(H5F__vfd_swmr_end_tick((H5F_t *)obj) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't trigger EOT processing for VFD SWMR") - break; - } + case H5VL_NATIVE_FILE_VFD_SWMR_END_TICK: { + /* Call package routine */ + if (H5F__vfd_swmr_end_tick((H5F_t *)obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't trigger EOT processing for VFD SWMR") + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") @@ -863,7 +816,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_file_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_file_close * @@ -875,13 +827,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) +H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - int nref; - H5F_t *f = (H5F_t *)file; - hid_t file_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; /* Return value */ + int nref; + H5F_t *f = (H5F_t *)file; + hid_t file_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -893,24 +844,23 @@ H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, * This is only necessary to replicate previous behaviour, and could be * disabled by an option/property to improve performance. */ - if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { + if ((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { /* Get the file ID corresponding to the H5F_t struct */ - if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) + if (H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") /* Get the number of references outstanding for this file ID */ - if((nref = H5I_get_ref(file_id, FALSE)) < 0) + if ((nref = H5I_get_ref(file_id, FALSE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") - if(nref == 1) - if(H5F__flush(f) < 0) + if (nref == 1) + if (H5F__flush(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ /* Close the file */ - if(H5F__close(f) < 0) + if (H5F__close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_file_close() */ - diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c index cca5c55..10dfaaa 100644 --- a/src/H5VLnative_group.c +++ b/src/H5VLnative_group.c @@ -15,20 +15,18 @@ * */ -#define H5G_FRIEND /* Suppress error about including H5Gpkg */ +#define H5G_FRIEND /* Suppress error about including H5Gpkg */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - - /*------------------------------------------------------------------------- * Function: H5VL__native_group_create * @@ -40,62 +38,62 @@ *------------------------------------------------------------------------- */ void * -H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t lcpl_id, hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, + hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ - void *ret_value; + H5G_loc_t loc; /* Location to create group */ + H5G_t * grp = NULL; /* New group created */ + void * ret_value; FUNC_ENTER_PACKAGE /* Set up the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") /* if name is NULL then this is from H5Gcreate_anon */ - if(name == NULL) { - H5G_obj_create_t gcrt_info; /* Information for group creation */ + if (name == NULL) { + H5G_obj_create_t gcrt_info; /* Information for group creation */ /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; + gcrt_info.gcpl_id = gcpl_id; gcrt_info.cache_type = H5G_NOTHING_CACHED; HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) + if (NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") } /* end if */ /* otherwise it's from H5Gcreate */ else { /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) + if (NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") } /* end else */ ret_value = (void *)grp; done: - if(name == NULL) { + if (name == NULL) { /* Release the group's object header, if it was created */ - if(grp) { - H5O_loc_t *oloc; /* Object location for group */ + if (grp) { + H5O_loc_t *oloc; /* Object location for group */ /* Get the new group's object location */ - if(NULL == (oloc = H5G_oloc(grp))) + if (NULL == (oloc = H5G_oloc(grp))) HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - } /* end if */ - } /* end if */ + if (H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, + "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_group_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_group_open * @@ -108,20 +106,20 @@ done: */ void * H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) + hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5G_loc_t loc; /* Location to open group */ - H5G_t *grp = NULL; /* New group opend */ - void *ret_value; + H5G_loc_t loc; /* Location to open group */ + H5G_t * grp = NULL; /* New group opend */ + void * ret_value; FUNC_ENTER_PACKAGE /* Set up the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") /* Open the group */ - if((grp = H5G__open_name(&loc, name)) == NULL) + if ((grp = H5G__open_name(&loc, name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") ret_value = (void *)grp; @@ -130,7 +128,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_group_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_group_get * @@ -141,61 +138,61 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(get_type) { + switch (get_type) { /* H5Gget_create_plist */ - case H5VL_GROUP_GET_GCPL: - { - hid_t *new_gcpl_id = HDva_arg(arguments, hid_t *); - H5G_t *grp = (H5G_t *)obj; + case H5VL_GROUP_GET_GCPL: { + hid_t *new_gcpl_id = HDva_arg(arguments, hid_t *); + H5G_t *grp = (H5G_t *)obj; - if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") - break; - } + if ((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") + break; + } /* H5Gget_info */ - case H5VL_GROUP_GET_INFO: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - H5G_info_t *group_info = HDva_arg(arguments, H5G_info_t *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Gget_info */ - - /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Gget_info_by_name */ - - /* Retrieve the group's information */ - if(H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { - /* H5Gget_info_by_idx */ - - /* Retrieve the group's information */ - if(H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - break; - } + case H5VL_GROUP_GET_INFO: { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5G_info_t * group_info = HDva_arg(arguments, H5G_info_t *); + H5G_loc_t loc; + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Gget_info */ + + /* Retrieve the group's information */ + if (H5G__obj_info(loc.oloc, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Gget_info_by_name */ + + /* Retrieve the group's information */ + if (H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Gget_info_by_idx */ + + /* Retrieve the group's information */ + if (H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") @@ -205,7 +202,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_group_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_group_specific * @@ -216,36 +212,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - H5G_t *grp = (H5G_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_t *grp = (H5G_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(specific_type) { - case H5VL_GROUP_FLUSH: - { - hid_t group_id = HDva_arg(arguments, hid_t); + switch (specific_type) { + case H5VL_GROUP_FLUSH: { + hid_t group_id = HDva_arg(arguments, hid_t); - /* Flush object's metadata to file */ - if(H5O_flush_common(&grp->oloc, group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") + /* Flush object's metadata to file */ + if (H5O_flush_common(&grp->oloc, group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") - break; - } + break; + } - case H5VL_GROUP_REFRESH: - { - hid_t group_id = HDva_arg(arguments, hid_t); + case H5VL_GROUP_REFRESH: { + hid_t group_id = HDva_arg(arguments, hid_t); - /* Call private function to refresh group object */ - if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") + /* Call private function to refresh group object */ + if ((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") - break; - } + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") @@ -255,7 +249,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_group_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_group_optional * @@ -266,55 +259,54 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_group_optional(void H5_ATTR_UNUSED *obj, - H5VL_group_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list H5_ATTR_DEPRECATED_USED arguments) +H5VL__native_group_optional(void H5_ATTR_UNUSED *obj, H5VL_group_optional_t optional_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, + va_list H5_ATTR_DEPRECATED_USED arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(optional_type) { + switch (optional_type) { #ifndef H5_NO_DEPRECATED_SYMBOLS /* H5Giterate (deprecated) */ - case H5VL_NATIVE_GROUP_ITERATE_OLD: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - hsize_t idx = HDva_arg(arguments, hsize_t); - hsize_t *last_obj = HDva_arg(arguments, hsize_t *); - const H5G_link_iterate_t *lnk_op = HDva_arg(arguments, const H5G_link_iterate_t *); - void *op_data = HDva_arg(arguments, void *); - H5G_loc_t grp_loc; - - /* Get the location struct for the object */ - if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Call the actual iteration routine */ - if((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) - HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); - - break; - } + case H5VL_NATIVE_GROUP_ITERATE_OLD: { + const H5VL_loc_params_t * loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hsize_t idx = HDva_arg(arguments, hsize_t); + hsize_t * last_obj = HDva_arg(arguments, hsize_t *); + const H5G_link_iterate_t *lnk_op = HDva_arg(arguments, const H5G_link_iterate_t *); + void * op_data = HDva_arg(arguments, void *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if (H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual iteration routine */ + if ((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, + H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); + + break; + } /* H5Gget_objinfo (deprecated) */ - case H5VL_NATIVE_GROUP_GET_OBJINFO: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - hbool_t follow_link = (hbool_t)HDva_arg(arguments, unsigned); - H5G_stat_t *statbuf = HDva_arg(arguments, H5G_stat_t *); - H5G_loc_t grp_loc; - - /* Get the location struct for the object */ - if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Call the actual group objinfo routine */ - if(H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") - - break; - } + case H5VL_NATIVE_GROUP_GET_OBJINFO: { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hbool_t follow_link = (hbool_t)HDva_arg(arguments, unsigned); + H5G_stat_t * statbuf = HDva_arg(arguments, H5G_stat_t *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if (H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual group objinfo routine */ + if (H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") + + break; + } #endif /* H5_NO_DEPRECATED_SYMBOLS */ default: @@ -325,7 +317,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_group_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_group_close * @@ -339,14 +330,13 @@ done: herr_t H5VL__native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5G_close((H5G_t *)grp) < 0) + if (H5G_close((H5G_t *)grp) < 0) HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_group_close() */ - diff --git a/src/H5VLnative_introspect.c b/src/H5VLnative_introspect.c index 45b8d8c..e59f7fd 100644 --- a/src/H5VLnative_introspect.c +++ b/src/H5VLnative_introspect.c @@ -15,9 +15,9 @@ * */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -25,7 +25,6 @@ * it can return the address of the staticly declared class struct. */ - /*--------------------------------------------------------------------------- * Function: H5VL__native_introspect_opt_query * @@ -37,7 +36,7 @@ */ herr_t H5VL__native_introspect_opt_query(void H5_ATTR_UNUSED *obj, H5VL_subclass_t H5_ATTR_UNUSED cls, - int H5_ATTR_UNUSED opt_type, hbool_t *supported) + int H5_ATTR_UNUSED opt_type, hbool_t *supported) { FUNC_ENTER_PACKAGE_NOERR @@ -49,4 +48,3 @@ H5VL__native_introspect_opt_query(void H5_ATTR_UNUSED *obj, H5VL_subclass_t H5_A FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL__native_introspect_opt_query() */ - diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c index ceb8d61..5ecc1ce 100644 --- a/src/H5VLnative_link.c +++ b/src/H5VLnative_link.c @@ -15,20 +15,18 @@ * */ -#define H5L_FRIEND /* Suppress error about including H5Lpkg */ +#define H5L_FRIEND /* Suppress error about including H5Lpkg */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - - /*------------------------------------------------------------------------- * Function: H5VL__native_link_create * @@ -39,83 +37,83 @@ *------------------------------------------------------------------------- */ herr_t -H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, + hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(create_type) { - case H5VL_LINK_CREATE_HARD: - { - H5G_loc_t cur_loc; - H5G_loc_t link_loc; - void *cur_obj = HDva_arg(arguments, void *); - H5VL_loc_params_t *cur_params = HDva_arg(arguments, H5VL_loc_params_t *); - - if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params->obj_type, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != obj && H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* H5Lcreate_hard */ - if(H5VL_OBJECT_BY_NAME == cur_params->type) { - H5G_loc_t *cur_loc_p, *link_loc_p; - - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - link_loc_p = &link_loc; - if(NULL == cur_obj) - cur_loc_p = link_loc_p; - else if(NULL == obj) - link_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != link_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - - /* Create the link */ - if((ret_value = H5L_create_hard(cur_loc_p, cur_params->loc_data.loc_by_name.name, - link_loc_p, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - } /* end if */ - else { /* H5Olink */ - /* Link to the object */ - if(H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") - } /* end else */ - break; - } - - case H5VL_LINK_CREATE_SOFT: - { - char *target_name = HDva_arg(arguments, char *); - H5G_loc_t link_loc; /* Group location for new link */ - - if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + switch (create_type) { + case H5VL_LINK_CREATE_HARD: { + H5G_loc_t cur_loc; + H5G_loc_t link_loc; + void * cur_obj = HDva_arg(arguments, void *); + H5VL_loc_params_t *cur_params = HDva_arg(arguments, H5VL_loc_params_t *); + + if (NULL != cur_obj && H5G_loc_real(cur_obj, cur_params->obj_type, &cur_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if (NULL != obj && H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* H5Lcreate_hard */ + if (H5VL_OBJECT_BY_NAME == cur_params->type) { + H5G_loc_t *cur_loc_p, *link_loc_p; + + /* Set up current & new location pointers */ + cur_loc_p = &cur_loc; + link_loc_p = &link_loc; + if (NULL == cur_obj) + cur_loc_p = link_loc_p; + else if (NULL == obj) + link_loc_p = cur_loc_p; + else if (cur_loc_p->oloc->file != link_loc_p->oloc->file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "source and destination should be in the same file.") /* Create the link */ - if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - break; - } - - case H5VL_LINK_CREATE_UD: - { - H5G_loc_t link_loc; /* Group location for new link */ - H5L_type_t link_type = (H5L_type_t)HDva_arg(arguments, int); - void *udata = HDva_arg(arguments, void *); - size_t udata_size = HDva_arg(arguments, size_t); - - if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Create link */ - if(H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, link_type, lcpl_id) < 0) + if ((ret_value = H5L_create_hard(cur_loc_p, cur_params->loc_data.loc_by_name.name, link_loc_p, + loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - break; - } + } /* end if */ + else { /* H5Olink */ + /* Link to the object */ + if (H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") + } /* end else */ + break; + } + + case H5VL_LINK_CREATE_SOFT: { + char * target_name = HDva_arg(arguments, char *); + H5G_loc_t link_loc; /* Group location for new link */ + + if (H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Create the link */ + if ((ret_value = H5L_create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, + lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + case H5VL_LINK_CREATE_UD: { + H5G_loc_t link_loc; /* Group location for new link */ + H5L_type_t link_type = (H5L_type_t)HDva_arg(arguments, int); + void * udata = HDva_arg(arguments, void *); + size_t udata_size = HDva_arg(arguments, size_t); + + if (H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Create link */ + if (H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, link_type, + lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } default: HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") @@ -125,7 +123,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_link_create() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_link_copy * @@ -136,41 +133,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) +H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + if (NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + if (NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Set up src & dst location pointers */ src_loc_p = &src_loc; dst_loc_p = &dst_loc; - if(NULL == src_obj) + if (NULL == src_obj) src_loc_p = dst_loc_p; - else if(NULL == dst_obj) + else if (NULL == dst_obj) dst_loc_p = src_loc_p; /* Copy the link */ - if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, - dst_loc_p, loc_params2->loc_data.loc_by_name.name, - TRUE, lcpl_id) < 0) + if (H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, dst_loc_p, + loc_params2->loc_data.loc_by_name.name, TRUE, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_link_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_link_move * @@ -181,41 +175,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) +H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + if (NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + if (NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Set up src & dst location pointers */ src_loc_p = &src_loc; dst_loc_p = &dst_loc; - if(NULL == src_obj) + if (NULL == src_obj) src_loc_p = dst_loc_p; - else if(NULL == dst_obj) + else if (NULL == dst_obj) dst_loc_p = src_loc_p; /* Move the link */ - if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, - dst_loc_p, loc_params2->loc_data.loc_by_name.name, - FALSE, lcpl_id) < 0) + if (H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, dst_loc_p, + loc_params2->loc_data.loc_by_name.name, FALSE, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_link_move() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_link_get * @@ -227,75 +218,77 @@ done: */ herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) { - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch(get_type) { + switch (get_type) { /* H5Lget_info/H5Lget_info_by_idx */ - case H5VL_LINK_GET_INFO: - { - H5L_info2_t *linfo2 = HDva_arg(arguments, H5L_info2_t *); - - /* Get the link information */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ - if(H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo2) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ - if(H5L_get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo2) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } /* end else-if */ - else + case H5VL_LINK_GET_INFO: { + H5L_info2_t *linfo2 = HDva_arg(arguments, H5L_info2_t *); + + /* Get the link information */ + if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ + if (H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo2) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ + if (H5L_get_info_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo2) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - break; - } + break; + } /* H5Lget_name_by_idx */ - case H5VL_LINK_GET_NAME: - { - char *name = HDva_arg(arguments, char *); - size_t size = HDva_arg(arguments, size_t); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - - /* Get the link name */ - if((*ret = H5L_get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, name, size)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + case H5VL_LINK_GET_NAME: { + char * name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); - break; - } + /* Get the link name */ + if ((*ret = H5L_get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, name, size)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + + break; + } /* H5Lget_val/H5Lget_val_by_idx */ - case H5VL_LINK_GET_VAL: - { - void *buf = HDva_arg(arguments, void *); - size_t size = HDva_arg(arguments, size_t); - - /* Get the link information */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ - if(H5L_get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") - } - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ - - if(H5L_get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") - } - else - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + case H5VL_LINK_GET_VAL: { + void * buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + /* Get the link information */ + if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ + if (H5L_get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") + } + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ - break; + if (H5L_get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") } + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") @@ -305,7 +298,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_link_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_link_specific * @@ -317,93 +309,93 @@ done: */ herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(specific_type) { - case H5VL_LINK_EXISTS: - { - htri_t *ret = HDva_arg(arguments, htri_t *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Check for the existence of the link */ - if((*ret = H5L_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") - break; - } - - case H5VL_LINK_ITER: - { - H5G_loc_t loc; - hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - hsize_t *idx_p = HDva_arg(arguments, hsize_t *); - H5L_iterate2_t op = HDva_arg(arguments, H5L_iterate2_t); - void *op_data = HDva_arg(arguments, void *); - - /* Get the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Visit or iterate over the links */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - if(recursive) { - /* H5Lvisit */ - if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") - } /* end if */ - else { - /* H5Literate */ - if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") - } /* end else */ + switch (specific_type) { + case H5VL_LINK_EXISTS: { + htri_t * ret = HDva_arg(arguments, htri_t *); + H5G_loc_t loc; + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Check for the existence of the link */ + if ((*ret = H5L_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") + break; + } + + case H5VL_LINK_ITER: { + H5G_loc_t loc; + hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t * idx_p = HDva_arg(arguments, hsize_t *); + H5L_iterate2_t op = HDva_arg(arguments, H5L_iterate2_t); + void * op_data = HDva_arg(arguments, void *); + + /* Get the location */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Visit or iterate over the links */ + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + if (recursive) { + /* H5Lvisit */ + if ((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - if(recursive) { - /* H5Lvisit_by_name */ - if((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") - } /* end if */ - else { - /* H5Literate_by_name */ - if((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") - } /* end else */ - } /* end else-if */ - else - HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") - - break; - } + else { + /* H5Literate */ + if ((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + if (recursive) { + /* H5Lvisit_by_name */ + if ((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, + op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate_by_name */ + if ((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, + idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") - case H5VL_LINK_DELETE: - { - H5G_loc_t loc; + break; + } - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + case H5VL_LINK_DELETE: { + H5G_loc_t loc; - /* Unlink */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ - if(H5L_delete(&loc, loc_params->loc_data.loc_by_name.name) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ - if(H5L_delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - } /* end else-if */ - else + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unlink */ + if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ + if (H5L_delete(&loc, loc_params->loc_data.loc_by_name.name) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - break; - } + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ + if (H5L_delete_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") @@ -412,4 +404,3 @@ H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_link_specific() */ - diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c index 4fdc0b0..26e86bb 100644 --- a/src/H5VLnative_object.c +++ b/src/H5VLnative_object.c @@ -15,21 +15,20 @@ * */ -#define H5O_FRIEND /* Suppress error about including H5Opkg */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files (pkg needed for id_exists) */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#define H5O_FRIEND /* Suppress error about including H5Opkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files (pkg needed for id_exists) */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ - /*------------------------------------------------------------------------- * Function: H5VL__native_object_open * @@ -42,48 +41,48 @@ */ void * H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) { - H5G_loc_t loc; - void *ret_value = NULL; + H5G_loc_t loc; + void * ret_value = NULL; FUNC_ENTER_PACKAGE - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - switch(loc_params->type) { - case H5VL_OBJECT_BY_NAME: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_name(&loc, loc_params->loc_data.loc_by_name.name, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") - break; - } - - case H5VL_OBJECT_BY_IDX: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") - break; - } - - case H5VL_OBJECT_BY_TOKEN: - { - H5O_token_t token = *loc_params->loc_data.loc_by_token.token; - haddr_t addr; - - /* Decode token */ - if(H5VL_native_token_to_addr(loc.oloc->file, H5I_FILE, token, &addr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, NULL, "can't deserialize object token into address") - - /* Open the object */ - if(NULL == (ret_value = H5O_open_by_addr(&loc, addr, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") - break; - } + switch (loc_params->type) { + case H5VL_OBJECT_BY_NAME: { + /* Open the object */ + if (NULL == (ret_value = H5O_open_name(&loc, loc_params->loc_data.loc_by_name.name, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") + break; + } + + case H5VL_OBJECT_BY_IDX: { + /* Open the object */ + if (NULL == (ret_value = H5O_open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") + break; + } + + case H5VL_OBJECT_BY_TOKEN: { + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; + haddr_t addr; + + /* Decode token */ + if (H5VL_native_token_to_addr(loc.oloc->file, H5I_FILE, token, &addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, NULL, + "can't deserialize object token into address") + + /* Open the object */ + if (NULL == (ret_value = H5O_open_by_addr(&loc, addr, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") + break; + } case H5VL_OBJECT_BY_SELF: default: @@ -94,7 +93,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_object_open() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_object_copy * @@ -106,30 +104,30 @@ done: */ herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) { - H5G_loc_t src_loc; /* Source object group location */ - H5G_loc_t dst_loc; /* Destination group location */ - herr_t ret_value = FAIL; + H5G_loc_t src_loc; /* Source object group location */ + H5G_loc_t dst_loc; /* Destination group location */ + herr_t ret_value = FAIL; FUNC_ENTER_PACKAGE /* get location for objects */ - if(H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + if (H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + if (H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Copy the object */ - if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) + if ((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_object_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_object_get * @@ -141,145 +139,145 @@ done: */ herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) { - herr_t ret_value = SUCCEED; /* Return value */ - H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ FUNC_ENTER_PACKAGE - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch(get_type) { + switch (get_type) { /* Object file */ - case H5VL_OBJECT_GET_FILE: - { - void **ret = HDva_arg(arguments, void **); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - *ret = (void *)loc.oloc->file; - - /* TODO we currently need to set id_exists to TRUE because - * the upper layer will create an ID from the returned - * object. In theory this should not be needed and id_exists - * should be removed once the H5Fmount code gets fixed. */ - loc.oloc->file->id_exists = TRUE; - } else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_file parameters") - break; + case H5VL_OBJECT_GET_FILE: { + void **ret = HDva_arg(arguments, void **); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + *ret = (void *)loc.oloc->file; + + /* TODO we currently need to set id_exists to TRUE because + * the upper layer will create an ID from the returned + * object. In theory this should not be needed and id_exists + * should be removed once the H5Fmount code gets fixed. */ + loc.oloc->file->id_exists = TRUE; } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_file parameters") + break; + } /* Object name */ - case H5VL_OBJECT_GET_NAME: - { - ssize_t *ret = HDva_arg(arguments, ssize_t *); - char *name = HDva_arg(arguments, char *); - size_t size = HDva_arg(arguments, size_t); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* Retrieve object's name */ - if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve object name") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_TOKEN) { - H5O_loc_t obj_oloc; /* Object location */ - H5O_token_t token = *loc_params->loc_data.loc_by_token.token; - - /* Initialize the object location */ - H5O_loc_reset(&obj_oloc); - obj_oloc.file = loc.oloc->file; - - /* Decode token */ - if(H5VL_native_token_to_addr(obj_oloc.file, H5I_FILE, token, &obj_oloc.addr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") - - /* Retrieve object's name */ - if((*ret = H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, name, size)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine object name") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_name parameters") - break; - } + case H5VL_OBJECT_GET_NAME: { + ssize_t *ret = HDva_arg(arguments, ssize_t *); + char * name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + /* Retrieve object's name */ + if ((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve object name") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_TOKEN) { + H5O_loc_t obj_oloc; /* Object location */ + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; + + /* Initialize the object location */ + H5O_loc_reset(&obj_oloc); + obj_oloc.file = loc.oloc->file; + + /* Decode token */ + if (H5VL_native_token_to_addr(obj_oloc.file, H5I_FILE, token, &obj_oloc.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + + /* Retrieve object's name */ + if ((*ret = H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, name, size)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine object name") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_name parameters") + break; + } /* Object type */ - case H5VL_OBJECT_GET_TYPE: - { - H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *); - - if(loc_params->type == H5VL_OBJECT_BY_TOKEN) { - H5O_loc_t obj_oloc; /* Object location */ - unsigned rc; /* Reference count of object */ - H5O_token_t token = *loc_params->loc_data.loc_by_token.token; - - /* Initialize the object location */ - H5O_loc_reset(&obj_oloc); - obj_oloc.file = loc.oloc->file; - - /* Decode token */ - if(H5VL_native_token_to_addr(obj_oloc.file, H5I_FILE, token, &obj_oloc.addr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") - - /* Get the # of links for object, and its type */ - /* (To check to make certain that this object hasn't been deleted) */ - if(H5O_get_rc_and_type(&obj_oloc, &rc, obj_type) < 0 || 0 == rc) - HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") - } else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_type parameters") - break; - } + case H5VL_OBJECT_GET_TYPE: { + H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *); - /* H5Oget_info(_name|_by_idx)3 */ - case H5VL_OBJECT_GET_INFO: - { - H5O_info2_t *oinfo = HDva_arg(arguments, H5O_info2_t *); - unsigned fields = HDva_arg(arguments, unsigned); + if (loc_params->type == H5VL_OBJECT_BY_TOKEN) { + H5O_loc_t obj_oloc; /* Object location */ + unsigned rc; /* Reference count of object */ + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; - /* Use the original H5Oget_info code to get the data */ + /* Initialize the object location */ + H5O_loc_reset(&obj_oloc); + obj_oloc.file = loc.oloc->file; - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", oinfo, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, oinfo, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") - - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, oinfo, fields) < 0) { - H5G_loc_free(&obj_loc); - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") - } /* end if */ - - /* Release the object location */ - if(H5G_loc_free(&obj_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else-if */ - else - HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - break; + /* Decode token */ + if (H5VL_native_token_to_addr(obj_oloc.file, H5I_FILE, token, &obj_oloc.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + + /* Get the # of links for object, and its type */ + /* (To check to make certain that this object hasn't been deleted) */ + if (H5O_get_rc_and_type(&obj_oloc, &rc, obj_type) < 0 || 0 == rc) + HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_type parameters") + break; + } + + /* H5Oget_info(_name|_by_idx)3 */ + case H5VL_OBJECT_GET_INFO: { + H5O_info2_t *oinfo = HDva_arg(arguments, H5O_info2_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Use the original H5Oget_info code to get the data */ + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if (H5G_loc_info(&loc, ".", oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if (H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if (H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if (H5O_get_info(obj_loc.oloc, oinfo, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ + + /* Release the object location */ + if (H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") @@ -289,7 +287,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_object_get() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_object_specific * @@ -300,125 +297,123 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch(specific_type) { + switch (specific_type) { /* H5Oincr_refcount / H5Odecr_refcount */ - case H5VL_OBJECT_CHANGE_REF_COUNT: - { - int update_ref = HDva_arg(arguments, int); - H5O_loc_t *oloc = loc.oloc; + case H5VL_OBJECT_CHANGE_REF_COUNT: { + int update_ref = HDva_arg(arguments, int); + H5O_loc_t *oloc = loc.oloc; - if(H5O_link(oloc, update_ref) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") + if (H5O_link(oloc, update_ref) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") - break; - } + break; + } /* H5Oexists_by_name */ - case H5VL_OBJECT_EXISTS: - { - htri_t *ret = HDva_arg(arguments, htri_t *); - - if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* Check if the object exists */ - if((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", loc_params->loc_data.loc_by_name.name) - } /* end if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") - break; - } + case H5VL_OBJECT_EXISTS: { + htri_t *ret = HDva_arg(arguments, htri_t *); + + if (loc_params->type == H5VL_OBJECT_BY_NAME) { + /* Check if the object exists */ + if ((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", + loc_params->loc_data.loc_by_name.name) + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + break; + } /* Lookup object */ - case H5VL_OBJECT_LOOKUP: - { - H5O_token_t *token = HDva_arg(arguments, H5O_token_t *); - - HDassert(token); - - if(loc_params->type == H5VL_OBJECT_BY_NAME) { - H5G_loc_t obj_loc; /* Group hier. location of object */ - H5G_name_t obj_path; /* Object group hier. path */ - H5O_loc_t obj_oloc; /* Object object location */ - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object */ - if(H5G_loc_find(&loc, loc_params->loc_data.loc_by_name.name, &obj_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - - /* Encode token */ - if(H5VL_native_addr_to_token(loc.oloc->file, H5I_FILE, obj_loc.oloc->addr, token) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") - - /* Release the object location */ - if(H5G_loc_free(&obj_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") - break; - } - - case H5VL_OBJECT_VISIT: - { - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - H5O_iterate2_t op = HDva_arg(arguments, H5O_iterate2_t); - void *op_data = HDva_arg(arguments, void *); - unsigned fields = HDva_arg(arguments, unsigned); - - /* Call internal object visitation routine */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Ovisit */ - if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Ovisit_by_name */ - if((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); - break; - } - - case H5VL_OBJECT_FLUSH: - { - hid_t oid = HDva_arg(arguments, hid_t); - - /* Flush the object's metadata */ - if(H5O_flush(loc.oloc, oid) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") - - break; - } - - case H5VL_OBJECT_REFRESH: - { - hid_t oid = HDva_arg(arguments, hid_t); - H5O_loc_t *oloc = loc.oloc; - - /* Refresh the metadata */ - if(H5O_refresh_metadata(oid, *oloc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") - - break; - } + case H5VL_OBJECT_LOOKUP: { + H5O_token_t *token = HDva_arg(arguments, H5O_token_t *); + + HDassert(token); + + if (loc_params->type == H5VL_OBJECT_BY_NAME) { + H5G_loc_t obj_loc; /* Group hier. location of object */ + H5G_name_t obj_path; /* Object group hier. path */ + H5O_loc_t obj_oloc; /* Object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object */ + if (H5G_loc_find(&loc, loc_params->loc_data.loc_by_name.name, &obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + + /* Encode token */ + if (H5VL_native_addr_to_token(loc.oloc->file, H5I_FILE, obj_loc.oloc->addr, token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, + "can't serialize address into object token") + + /* Release the object location */ + if (H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + break; + } + + case H5VL_OBJECT_VISIT: { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + H5O_iterate2_t op = HDva_arg(arguments, H5O_iterate2_t); + void * op_data = HDva_arg(arguments, void *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Call internal object visitation routine */ + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Ovisit */ + if ((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Ovisit_by_name */ + if ((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, + op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); + break; + } + + case H5VL_OBJECT_FLUSH: { + hid_t oid = HDva_arg(arguments, hid_t); + + /* Flush the object's metadata */ + if (H5O_flush(loc.oloc, oid) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") + + break; + } + + case H5VL_OBJECT_REFRESH: { + hid_t oid = HDva_arg(arguments, hid_t); + H5O_loc_t *oloc = loc.oloc; + + /* Refresh the metadata */ + if (H5O_refresh_metadata(oid, *oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") + + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") @@ -428,7 +423,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_object_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL__native_object_optional * @@ -439,144 +433,139 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) { H5VL_loc_params_t *loc_params = HDva_arg(arguments, H5VL_loc_params_t *); - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - switch(optional_type) { + switch (optional_type) { /* H5Oget_comment / H5Oget_comment_by_name */ - case H5VL_NATIVE_OBJECT_GET_COMMENT: - { - char *comment = HDva_arg(arguments, char *); - size_t bufsize = HDva_arg(arguments, size_t); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - - /* Retrieve the object's comment */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ - if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ - if((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") - break; - } + case H5VL_NATIVE_OBJECT_GET_COMMENT: { + char * comment = HDva_arg(arguments, char *); + size_t bufsize = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Retrieve the object's comment */ + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ + if ((*ret = H5G_loc_get_comment(&loc, ".", comment /*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ + if ((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment /*out*/, + bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } /* H5Oset_comment */ - case H5VL_NATIVE_OBJECT_SET_COMMENT: - { - const char *comment = HDva_arg(arguments, char *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, ".", comment) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") - break; - } + case H5VL_NATIVE_OBJECT_SET_COMMENT: { + const char *comment = HDva_arg(arguments, char *); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ + /* (Re)set the object's comment */ + if (H5G_loc_set_comment(&loc, ".", comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ + /* (Re)set the object's comment */ + if (H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } /* H5Odisable_mdc_flushes */ - case H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES: - { - H5O_loc_t *oloc = loc.oloc; + case H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES: { + H5O_loc_t *oloc = loc.oloc; - if (H5O_disable_mdc_flushes(oloc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork the metadata cache"); + if (H5O_disable_mdc_flushes(oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork the metadata cache"); - break; - } + break; + } /* H5Oenable_mdc_flushes */ - case H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES: - { - H5O_loc_t *oloc = loc.oloc; + case H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES: { + H5O_loc_t *oloc = loc.oloc; - if (H5O_enable_mdc_flushes(oloc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork the metadata cache"); + if (H5O_enable_mdc_flushes(oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork the metadata cache"); - break; - } + break; + } /* H5Oare_mdc_flushes_disabled */ - case H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED: - { - H5O_loc_t *oloc = loc.oloc; - hbool_t *are_disabled = (hbool_t *)HDva_arg(arguments, hbool_t *); + case H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED: { + H5O_loc_t *oloc = loc.oloc; + hbool_t * are_disabled = (hbool_t *)HDva_arg(arguments, hbool_t *); - if (H5O_are_mdc_flushes_disabled(oloc, are_disabled) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine metadata cache cork status"); + if (H5O_are_mdc_flushes_disabled(oloc, are_disabled) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine metadata cache cork status"); - break; - } + break; + } /* H5Oget_native_info(_name|_by_idx) */ - case H5VL_NATIVE_OBJECT_GET_NATIVE_INFO: - { - H5O_native_info_t *native_info = HDva_arg(arguments, H5O_native_info_t *); - unsigned fields = HDva_arg(arguments, unsigned); + case H5VL_NATIVE_OBJECT_GET_NATIVE_INFO: { + H5O_native_info_t *native_info = HDva_arg(arguments, H5O_native_info_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Use the original H5Oget_info code to get the data */ + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if (H5G_loc_native_info(&loc, ".", native_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if (H5G_loc_native_info(&loc, loc_params->loc_data.loc_by_name.name, native_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if (H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if (H5O_get_native_info(obj_loc.oloc, native_info, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ - /* Use the original H5Oget_info code to get the data */ + /* Release the object location */ + if (H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ - /* Retrieve the object's information */ - if(H5G_loc_native_info(&loc, ".", native_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ - /* Retrieve the object's information */ - if(H5G_loc_native_info(&loc, loc_params->loc_data.loc_by_name.name, native_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") - - /* Retrieve the object's information */ - if(H5O_get_native_info(obj_loc.oloc, native_info, fields) < 0) { - H5G_loc_free(&obj_loc); - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") - } /* end if */ - - /* Release the object location */ - if(H5G_loc_free(&obj_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else-if */ - else - HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - - break; - } + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); @@ -585,4 +574,3 @@ H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_object_optional() */ - diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h index 30bddb6..0c2584c 100644 --- a/src/H5VLnative_private.h +++ b/src/H5VLnative_private.h @@ -18,25 +18,21 @@ #define _H5VLnative_private_H /* Private headers needed by this file */ -#include "H5Fprivate.h" /* Files */ -#include "H5VLnative.h" /* Native VOL connector */ - +#include "H5Fprivate.h" /* Files */ +#include "H5VLnative.h" /* Native VOL connector */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ @@ -46,75 +42,130 @@ extern "C" { #endif /* Attribute callbacks */ -H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, + hid_t dxpl_id, void **req); +void * H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t aapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); /* Dataset callbacks */ -H5_DLL void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); -H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_dataset_optional(void *dset, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, + hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_optional(void *dset, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); H5_DLL herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); /* Datatype callbacks */ -H5_DLL void *H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, + hid_t dxpl_id, void **req); +H5_DLL void * H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); /* File callbacks */ -H5_DLL void *H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req); +H5_DLL void * H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); /* Group callbacks */ -H5_DLL void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void * H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +H5_DLL void * H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); /* Link callbacks */ -H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); /* Object callbacks */ -H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, + const char *src_name, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); /* Connector/container introspection functions */ -H5_DLL herr_t H5VL__native_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); -H5_DLL herr_t H5VL__native_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, hbool_t *supported); +H5_DLL herr_t H5VL__native_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VL__native_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, + hbool_t *supported); /* Blob callbacks */ H5_DLL herr_t H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx); H5_DLL herr_t H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); -H5_DLL herr_t H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); +H5_DLL herr_t H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments); /* Token callbacks */ -H5_DLL herr_t H5VL__native_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); -H5_DLL herr_t H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str); -H5_DLL herr_t H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token); +H5_DLL herr_t H5VL__native_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value); +H5_DLL herr_t H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str); +H5_DLL herr_t H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, const char *token_str, + H5O_token_t *token); /* Helper functions */ H5_DLL herr_t H5VL_native_get_file_addr_len(hid_t loc_id, size_t *addr_len); @@ -128,4 +179,3 @@ H5_DLL herr_t H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **fi #endif #endif /* _H5VLnative_private_H */ - diff --git a/src/H5VLnative_token.c b/src/H5VLnative_token.c index 2b5429e..f077ca4 100644 --- a/src/H5VLnative_token.c +++ b/src/H5VLnative_token.c @@ -26,33 +26,26 @@ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*--------------------------------------------------------------------------- * Function: H5VL__native_token_cmp * @@ -65,8 +58,8 @@ *--------------------------------------------------------------------------- */ herr_t -H5VL__native_token_cmp(void H5_ATTR_UNUSED *obj, - const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) +H5VL__native_token_cmp(void H5_ATTR_UNUSED *obj, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) { herr_t ret_value = SUCCEED; @@ -81,7 +74,6 @@ H5VL__native_token_cmp(void H5_ATTR_UNUSED *obj, FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_token_cmp() */ - /*--------------------------------------------------------------------------- * Function: H5VL__native_token_to_str * @@ -93,12 +85,11 @@ H5VL__native_token_cmp(void H5_ATTR_UNUSED *obj, *--------------------------------------------------------------------------- */ herr_t -H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, - char **token_str) +H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str) { haddr_t addr; - size_t addr_ndigits; - herr_t ret_value = SUCCEED; + size_t addr_ndigits; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -106,15 +97,15 @@ H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *tok HDassert(obj); HDassert(token); - if(H5VL_native_token_to_addr(obj, obj_type, *token, &addr) < 0) + if (H5VL_native_token_to_addr(obj, obj_type, *token, &addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't convert object token to address") - if(addr == 0) + if (addr == 0) addr_ndigits = 1; else addr_ndigits = (size_t)(HDfloor(HDlog10((double)addr)) + 1); - if(NULL == (*token_str = H5MM_malloc(addr_ndigits + 1))) + if (NULL == (*token_str = H5MM_malloc(addr_ndigits + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate buffer for token string") HDsnprintf(*token_str, addr_ndigits + 1, H5_PRINTF_HADDR_FMT, addr); @@ -123,7 +114,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_token_to_str() */ - /*--------------------------------------------------------------------------- * Function: H5VL__native_str_to_token * @@ -135,11 +125,10 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, - const char *token_str, H5O_token_t *token) +H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token) { haddr_t addr; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -148,10 +137,9 @@ H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, HDsscanf(token_str, H5_PRINTF_HADDR_FMT, &addr); - if(H5VL_native_addr_to_token(obj, obj_type, addr, token) < 0) + if (H5VL_native_addr_to_token(obj, obj_type, addr, token) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't convert address to object token") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_str_to_token() */ - diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index 2cf470e..eacb01e 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -27,7 +27,6 @@ * */ - /* Header files needed */ /* Do NOT include private HDF5 files here! */ #include @@ -42,7 +41,6 @@ /* This connector's header */ #include "H5VLpassthru.h" - /**********/ /* Macros */ /**********/ @@ -55,7 +53,7 @@ * (from H5win2_defs.h - used on VS2012 and earlier) */ #if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800) -#define va_copy(D,S) ((D) = (S)) +#define va_copy(D, S) ((D) = (S)) #endif /************/ @@ -64,138 +62,200 @@ /* The pass through VOL info object */ typedef struct H5VL_pass_through_t { - hid_t under_vol_id; /* ID for underlying VOL connector */ - void *under_object; /* Info object for underlying VOL connector */ + hid_t under_vol_id; /* ID for underlying VOL connector */ + void *under_object; /* Info object for underlying VOL connector */ } H5VL_pass_through_t; /* The pass through VOL wrapper context */ typedef struct H5VL_pass_through_wrap_ctx_t { - hid_t under_vol_id; /* VOL ID for under VOL */ - void *under_wrap_ctx; /* Object wrapping context for under VOL */ + hid_t under_vol_id; /* VOL ID for under VOL */ + void *under_wrap_ctx; /* Object wrapping context for under VOL */ } H5VL_pass_through_wrap_ctx_t; - /********************* */ /* Function prototypes */ /********************* */ /* Helper routines */ static herr_t H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, - H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...); + H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, ...); static herr_t H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, - H5VL_request_specific_t specific_type, ...); -static herr_t H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, - void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, ...); -static H5VL_pass_through_t *H5VL_pass_through_new_obj(void *under_obj, - hid_t under_vol_id); -static herr_t H5VL_pass_through_free_obj(H5VL_pass_through_t *obj); + H5VL_request_specific_t specific_type, ...); +static herr_t H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t connector_id, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, + ...); +static H5VL_pass_through_t *H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id); +static herr_t H5VL_pass_through_free_obj(H5VL_pass_through_t *obj); /* "Management" callbacks */ static herr_t H5VL_pass_through_init(hid_t vipl_id); static herr_t H5VL_pass_through_term(void); /* VOL info callbacks */ -static void *H5VL_pass_through_info_copy(const void *info); +static void * H5VL_pass_through_info_copy(const void *info); static herr_t H5VL_pass_through_info_cmp(int *cmp_value, const void *info1, const void *info2); static herr_t H5VL_pass_through_info_free(void *info); static herr_t H5VL_pass_through_info_to_str(const void *info, char **str); static herr_t H5VL_pass_through_str_to_info(const char *str, void **info); /* VOL object wrap / retrieval callbacks */ -static void *H5VL_pass_through_get_object(const void *obj); +static void * H5VL_pass_through_get_object(const void *obj); static herr_t H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx); -static void *H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type, - void *wrap_ctx); -static void *H5VL_pass_through_unwrap_object(void *obj); +static void * H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type, void *wrap_ctx); +static void * H5VL_pass_through_unwrap_object(void *obj); static herr_t H5VL_pass_through_free_wrap_ctx(void *obj); /* Attribute callbacks */ -static void *H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -static void *H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +static void * H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, + hid_t dxpl_id, void **req); +static void * H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); static herr_t H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req); /* Dataset callbacks */ -static void *H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -static void *H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +static void * H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +static void * H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req); static herr_t H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, void *buf, void **req); -static herr_t H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -static herr_t H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +static herr_t H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, + void **req); +static herr_t H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); static herr_t H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req); /* Datatype callbacks */ -static void *H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -static void *H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +static void *H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, + hid_t tapl_id, hid_t dxpl_id, void **req); +static void *H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); static herr_t H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req); /* File callbacks */ -static void *H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -static void *H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +static void * H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req); +static void * H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); static herr_t H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req); /* Group callbacks */ -static void *H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -static void *H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +static void * H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +static void * H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); static herr_t H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req); /* Link callbacks */ -static herr_t H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); /* Object callbacks */ -static void *H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments); +static void * H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, + const char *src_name, void *dst_obj, + const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); /* Container/connector introspection callbacks */ -static herr_t H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls); -static herr_t H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, hbool_t *supported); +static herr_t H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +static herr_t H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, + hbool_t *supported); /* Async request callbacks */ static herr_t H5VL_pass_through_request_wait(void *req, uint64_t timeout, H5ES_status_t *status); static herr_t H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx); static herr_t H5VL_pass_through_request_cancel(void *req); -static herr_t H5VL_pass_through_request_specific(void *req, H5VL_request_specific_t specific_type, va_list arguments); -static herr_t H5VL_pass_through_request_optional(void *req, H5VL_request_optional_t opt_type, va_list arguments); +static herr_t H5VL_pass_through_request_specific(void *req, H5VL_request_specific_t specific_type, + va_list arguments); +static herr_t H5VL_pass_through_request_optional(void *req, H5VL_request_optional_t opt_type, + va_list arguments); static herr_t H5VL_pass_through_request_free(void *req); /* Blob callbacks */ static herr_t H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx); static herr_t H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); -static herr_t H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); -static herr_t H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); +static herr_t H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments); +static herr_t H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, + va_list arguments); /* Token callbacks */ -static herr_t H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); -static herr_t H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str); -static herr_t H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token); +static herr_t H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value); +static herr_t H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str); +static herr_t H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, const char *token_str, + H5O_token_t *token); /* Generic optional callback */ -static herr_t H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, va_list arguments); - +static herr_t H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, + va_list arguments); /*******************/ /* Local variables */ @@ -203,116 +263,128 @@ static herr_t H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, /* Pass through VOL connector class struct */ static const H5VL_class_t H5VL_pass_through_g = { - H5VL_PASSTHRU_VERSION, /* version */ - (H5VL_class_value_t)H5VL_PASSTHRU_VALUE, /* value */ - H5VL_PASSTHRU_NAME, /* name */ - 0, /* capability flags */ - H5VL_pass_through_init, /* initialize */ - H5VL_pass_through_term, /* terminate */ - { /* info_cls */ - sizeof(H5VL_pass_through_info_t), /* size */ - H5VL_pass_through_info_copy, /* copy */ - H5VL_pass_through_info_cmp, /* compare */ - H5VL_pass_through_info_free, /* free */ - H5VL_pass_through_info_to_str, /* to_str */ - H5VL_pass_through_str_to_info /* from_str */ + H5VL_PASSTHRU_VERSION, /* version */ + (H5VL_class_value_t)H5VL_PASSTHRU_VALUE, /* value */ + H5VL_PASSTHRU_NAME, /* name */ + 0, /* capability flags */ + H5VL_pass_through_init, /* initialize */ + H5VL_pass_through_term, /* terminate */ + { + /* info_cls */ + sizeof(H5VL_pass_through_info_t), /* size */ + H5VL_pass_through_info_copy, /* copy */ + H5VL_pass_through_info_cmp, /* compare */ + H5VL_pass_through_info_free, /* free */ + H5VL_pass_through_info_to_str, /* to_str */ + H5VL_pass_through_str_to_info /* from_str */ }, - { /* wrap_cls */ - H5VL_pass_through_get_object, /* get_object */ - H5VL_pass_through_get_wrap_ctx, /* get_wrap_ctx */ - H5VL_pass_through_wrap_object, /* wrap_object */ - H5VL_pass_through_unwrap_object, /* unwrap_object */ - H5VL_pass_through_free_wrap_ctx /* free_wrap_ctx */ + { + /* wrap_cls */ + H5VL_pass_through_get_object, /* get_object */ + H5VL_pass_through_get_wrap_ctx, /* get_wrap_ctx */ + H5VL_pass_through_wrap_object, /* wrap_object */ + H5VL_pass_through_unwrap_object, /* unwrap_object */ + H5VL_pass_through_free_wrap_ctx /* free_wrap_ctx */ }, - { /* attribute_cls */ - H5VL_pass_through_attr_create, /* create */ - H5VL_pass_through_attr_open, /* open */ - H5VL_pass_through_attr_read, /* read */ - H5VL_pass_through_attr_write, /* write */ - H5VL_pass_through_attr_get, /* get */ - H5VL_pass_through_attr_specific, /* specific */ - H5VL_pass_through_attr_optional, /* optional */ - H5VL_pass_through_attr_close /* close */ + { + /* attribute_cls */ + H5VL_pass_through_attr_create, /* create */ + H5VL_pass_through_attr_open, /* open */ + H5VL_pass_through_attr_read, /* read */ + H5VL_pass_through_attr_write, /* write */ + H5VL_pass_through_attr_get, /* get */ + H5VL_pass_through_attr_specific, /* specific */ + H5VL_pass_through_attr_optional, /* optional */ + H5VL_pass_through_attr_close /* close */ }, - { /* dataset_cls */ - H5VL_pass_through_dataset_create, /* create */ - H5VL_pass_through_dataset_open, /* open */ - H5VL_pass_through_dataset_read, /* read */ - H5VL_pass_through_dataset_write, /* write */ - H5VL_pass_through_dataset_get, /* get */ - H5VL_pass_through_dataset_specific, /* specific */ - H5VL_pass_through_dataset_optional, /* optional */ - H5VL_pass_through_dataset_close /* close */ + { + /* dataset_cls */ + H5VL_pass_through_dataset_create, /* create */ + H5VL_pass_through_dataset_open, /* open */ + H5VL_pass_through_dataset_read, /* read */ + H5VL_pass_through_dataset_write, /* write */ + H5VL_pass_through_dataset_get, /* get */ + H5VL_pass_through_dataset_specific, /* specific */ + H5VL_pass_through_dataset_optional, /* optional */ + H5VL_pass_through_dataset_close /* close */ }, - { /* datatype_cls */ - H5VL_pass_through_datatype_commit, /* commit */ - H5VL_pass_through_datatype_open, /* open */ - H5VL_pass_through_datatype_get, /* get_size */ - H5VL_pass_through_datatype_specific, /* specific */ - H5VL_pass_through_datatype_optional, /* optional */ - H5VL_pass_through_datatype_close /* close */ + { + /* datatype_cls */ + H5VL_pass_through_datatype_commit, /* commit */ + H5VL_pass_through_datatype_open, /* open */ + H5VL_pass_through_datatype_get, /* get_size */ + H5VL_pass_through_datatype_specific, /* specific */ + H5VL_pass_through_datatype_optional, /* optional */ + H5VL_pass_through_datatype_close /* close */ }, - { /* file_cls */ - H5VL_pass_through_file_create, /* create */ - H5VL_pass_through_file_open, /* open */ - H5VL_pass_through_file_get, /* get */ - H5VL_pass_through_file_specific, /* specific */ - H5VL_pass_through_file_optional, /* optional */ - H5VL_pass_through_file_close /* close */ + { + /* file_cls */ + H5VL_pass_through_file_create, /* create */ + H5VL_pass_through_file_open, /* open */ + H5VL_pass_through_file_get, /* get */ + H5VL_pass_through_file_specific, /* specific */ + H5VL_pass_through_file_optional, /* optional */ + H5VL_pass_through_file_close /* close */ }, - { /* group_cls */ - H5VL_pass_through_group_create, /* create */ - H5VL_pass_through_group_open, /* open */ - H5VL_pass_through_group_get, /* get */ - H5VL_pass_through_group_specific, /* specific */ - H5VL_pass_through_group_optional, /* optional */ - H5VL_pass_through_group_close /* close */ + { + /* group_cls */ + H5VL_pass_through_group_create, /* create */ + H5VL_pass_through_group_open, /* open */ + H5VL_pass_through_group_get, /* get */ + H5VL_pass_through_group_specific, /* specific */ + H5VL_pass_through_group_optional, /* optional */ + H5VL_pass_through_group_close /* close */ }, - { /* link_cls */ - H5VL_pass_through_link_create, /* create */ - H5VL_pass_through_link_copy, /* copy */ - H5VL_pass_through_link_move, /* move */ - H5VL_pass_through_link_get, /* get */ - H5VL_pass_through_link_specific, /* specific */ - H5VL_pass_through_link_optional /* optional */ + { + /* link_cls */ + H5VL_pass_through_link_create, /* create */ + H5VL_pass_through_link_copy, /* copy */ + H5VL_pass_through_link_move, /* move */ + H5VL_pass_through_link_get, /* get */ + H5VL_pass_through_link_specific, /* specific */ + H5VL_pass_through_link_optional /* optional */ }, - { /* object_cls */ - H5VL_pass_through_object_open, /* open */ - H5VL_pass_through_object_copy, /* copy */ - H5VL_pass_through_object_get, /* get */ - H5VL_pass_through_object_specific, /* specific */ - H5VL_pass_through_object_optional /* optional */ + { + /* object_cls */ + H5VL_pass_through_object_open, /* open */ + H5VL_pass_through_object_copy, /* copy */ + H5VL_pass_through_object_get, /* get */ + H5VL_pass_through_object_specific, /* specific */ + H5VL_pass_through_object_optional /* optional */ }, - { /* introspect_cls */ - H5VL_pass_through_introspect_get_conn_cls, /* get_conn_cls */ - H5VL_pass_through_introspect_opt_query, /* opt_query */ + { + /* introspect_cls */ + H5VL_pass_through_introspect_get_conn_cls, /* get_conn_cls */ + H5VL_pass_through_introspect_opt_query, /* opt_query */ }, - { /* request_cls */ - H5VL_pass_through_request_wait, /* wait */ - H5VL_pass_through_request_notify, /* notify */ - H5VL_pass_through_request_cancel, /* cancel */ - H5VL_pass_through_request_specific, /* specific */ - H5VL_pass_through_request_optional, /* optional */ - H5VL_pass_through_request_free /* free */ + { + /* request_cls */ + H5VL_pass_through_request_wait, /* wait */ + H5VL_pass_through_request_notify, /* notify */ + H5VL_pass_through_request_cancel, /* cancel */ + H5VL_pass_through_request_specific, /* specific */ + H5VL_pass_through_request_optional, /* optional */ + H5VL_pass_through_request_free /* free */ }, - { /* blob_cls */ - H5VL_pass_through_blob_put, /* put */ - H5VL_pass_through_blob_get, /* get */ - H5VL_pass_through_blob_specific, /* specific */ - H5VL_pass_through_blob_optional /* optional */ + { + /* blob_cls */ + H5VL_pass_through_blob_put, /* put */ + H5VL_pass_through_blob_get, /* get */ + H5VL_pass_through_blob_specific, /* specific */ + H5VL_pass_through_blob_optional /* optional */ }, - { /* token_cls */ - H5VL_pass_through_token_cmp, /* cmp */ - H5VL_pass_through_token_to_str, /* to_str */ - H5VL_pass_through_token_from_str /* from_str */ + { + /* token_cls */ + H5VL_pass_through_token_cmp, /* cmp */ + H5VL_pass_through_token_to_str, /* to_str */ + H5VL_pass_through_token_from_str /* from_str */ }, - H5VL_pass_through_optional /* optional */ + H5VL_pass_through_optional /* optional */ }; /* The connector identification number, initialized at runtime */ static hid_t H5VL_PASSTHRU_g = H5I_INVALID_HID; - /*------------------------------------------------------------------------- * Function: H5VL__pass_through_new_obj * @@ -331,7 +403,7 @@ H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id) { H5VL_pass_through_t *new_obj; - new_obj = (H5VL_pass_through_t *)calloc(1, sizeof(H5VL_pass_through_t)); + new_obj = (H5VL_pass_through_t *)calloc(1, sizeof(H5VL_pass_through_t)); new_obj->under_object = under_obj; new_obj->under_vol_id = under_vol_id; H5Iinc_ref(new_obj->under_vol_id); @@ -339,7 +411,6 @@ H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id) return new_obj; } /* end H5VL__pass_through_new_obj() */ - /*------------------------------------------------------------------------- * Function: H5VL__pass_through_free_obj * @@ -372,7 +443,6 @@ H5VL_pass_through_free_obj(H5VL_pass_through_t *obj) return 0; } /* end H5VL__pass_through_free_obj() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_register * @@ -391,13 +461,12 @@ hid_t H5VL_pass_through_register(void) { /* Singleton register the pass-through VOL connector ID */ - if(H5VL_PASSTHRU_g < 0) + if (H5VL_PASSTHRU_g < 0) H5VL_PASSTHRU_g = H5VLregister_connector(&H5VL_pass_through_g, H5P_DEFAULT); return H5VL_PASSTHRU_g; } /* end H5VL_pass_through_register() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_init * @@ -423,7 +492,6 @@ H5VL_pass_through_init(hid_t vipl_id) return 0; } /* end H5VL_pass_through_init() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_term * @@ -450,7 +518,6 @@ H5VL_pass_through_term(void) return 0; } /* end H5VL_pass_through_term() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_info_copy * @@ -465,7 +532,7 @@ static void * H5VL_pass_through_info_copy(const void *_info) { const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; - H5VL_pass_through_info_t *new_info; + H5VL_pass_through_info_t * new_info; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO Copy\n"); @@ -477,13 +544,12 @@ H5VL_pass_through_info_copy(const void *_info) /* Increment reference count on underlying VOL ID, and copy the VOL info */ new_info->under_vol_id = info->under_vol_id; H5Iinc_ref(new_info->under_vol_id); - if(info->under_vol_info) + if (info->under_vol_info) H5VLcopy_connector_info(new_info->under_vol_id, &(new_info->under_vol_info), info->under_vol_info); return new_info; } /* end H5VL_pass_through_info_copy() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_info_cmp * @@ -514,18 +580,17 @@ H5VL_pass_through_info_cmp(int *cmp_value, const void *_info1, const void *_info /* Compare under VOL connector classes */ H5VLcmp_connector_cls(cmp_value, info1->under_vol_id, info2->under_vol_id); - if(*cmp_value != 0) + if (*cmp_value != 0) return 0; /* Compare under VOL connector info objects */ H5VLcmp_connector_info(cmp_value, info1->under_vol_id, info1->under_vol_info, info2->under_vol_info); - if(*cmp_value != 0) + if (*cmp_value != 0) return 0; return 0; } /* end H5VL_pass_through_info_cmp() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_info_free * @@ -543,7 +608,7 @@ static herr_t H5VL_pass_through_info_free(void *_info) { H5VL_pass_through_info_t *info = (H5VL_pass_through_info_t *)_info; - hid_t err_id; + hid_t err_id; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO Free\n"); @@ -552,7 +617,7 @@ H5VL_pass_through_info_free(void *_info) err_id = H5Eget_current_stack(); /* Release underlying VOL ID and info */ - if(info->under_vol_info) + if (info->under_vol_info) H5VLfree_connector_info(info->under_vol_id, info->under_vol_info); H5Idec_ref(info->under_vol_id); @@ -564,7 +629,6 @@ H5VL_pass_through_info_free(void *_info) return 0; } /* end H5VL_pass_through_info_free() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_info_to_str * @@ -578,10 +642,10 @@ H5VL_pass_through_info_free(void *_info) static herr_t H5VL_pass_through_info_to_str(const void *_info, char **str) { - const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; - H5VL_class_value_t under_value = (H5VL_class_value_t)-1; - char *under_vol_string = NULL; - size_t under_vol_str_len = 0; + const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; + H5VL_class_value_t under_value = (H5VL_class_value_t)-1; + char * under_vol_string = NULL; + size_t under_vol_str_len = 0; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO To String\n"); @@ -592,7 +656,7 @@ H5VL_pass_through_info_to_str(const void *_info, char **str) H5VLconnector_info_to_str(info->under_vol_info, info->under_vol_id, &under_vol_string); /* Determine length of underlying VOL info string */ - if(under_vol_string) + if (under_vol_string) under_vol_str_len = strlen(under_vol_string); /* Allocate space for our info */ @@ -604,12 +668,12 @@ H5VL_pass_through_info_to_str(const void *_info, char **str) * call had problems on Windows until recently. So, to be as platform-independent * as we can, we're using sprintf() instead. */ - sprintf(*str, "under_vol=%u;under_info={%s}", (unsigned)under_value, (under_vol_string ? under_vol_string : "")); + sprintf(*str, "under_vol=%u;under_info={%s}", (unsigned)under_value, + (under_vol_string ? under_vol_string : "")); return 0; } /* end H5VL_pass_through_info_to_str() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_str_to_info * @@ -624,10 +688,10 @@ static herr_t H5VL_pass_through_str_to_info(const char *str, void **_info) { H5VL_pass_through_info_t *info; - unsigned under_vol_value; - const char *under_vol_info_start, *under_vol_info_end; - hid_t under_vol_id; - void *under_vol_info = NULL; + unsigned under_vol_value; + const char * under_vol_info_start, *under_vol_info_end; + hid_t under_vol_id; + void * under_vol_info = NULL; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INFO String To Info\n"); @@ -635,15 +699,16 @@ H5VL_pass_through_str_to_info(const char *str, void **_info) /* Retrieve the underlying VOL connector value and info */ sscanf(str, "under_vol=%u;", &under_vol_value); - under_vol_id = H5VLregister_connector_by_value((H5VL_class_value_t)under_vol_value, H5P_DEFAULT); + under_vol_id = H5VLregister_connector_by_value((H5VL_class_value_t)under_vol_value, H5P_DEFAULT); under_vol_info_start = strchr(str, '{'); - under_vol_info_end = strrchr(str, '}'); + under_vol_info_end = strrchr(str, '}'); assert(under_vol_info_end > under_vol_info_start); - if(under_vol_info_end != (under_vol_info_start + 1)) { + if (under_vol_info_end != (under_vol_info_start + 1)) { char *under_vol_info_str; under_vol_info_str = (char *)malloc((size_t)(under_vol_info_end - under_vol_info_start)); - memcpy(under_vol_info_str, under_vol_info_start + 1, (size_t)((under_vol_info_end - under_vol_info_start) - 1)); + memcpy(under_vol_info_str, under_vol_info_start + 1, + (size_t)((under_vol_info_end - under_vol_info_start) - 1)); *(under_vol_info_str + (under_vol_info_end - under_vol_info_start)) = '\0'; H5VLconnector_str_to_info(under_vol_info_str, under_vol_id, &under_vol_info); @@ -652,8 +717,8 @@ H5VL_pass_through_str_to_info(const char *str, void **_info) } /* end else */ /* Allocate new pass-through VOL connector info and set its fields */ - info = (H5VL_pass_through_info_t *)calloc(1, sizeof(H5VL_pass_through_info_t)); - info->under_vol_id = under_vol_id; + info = (H5VL_pass_through_info_t *)calloc(1, sizeof(H5VL_pass_through_info_t)); + info->under_vol_id = under_vol_id; info->under_vol_info = under_vol_info; /* Set return value */ @@ -662,7 +727,6 @@ H5VL_pass_through_str_to_info(const char *str, void **_info) return 0; } /* end H5VL_pass_through_str_to_info() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_get_object * @@ -685,7 +749,6 @@ H5VL_pass_through_get_object(const void *obj) return H5VLget_object(o->under_object, o->under_vol_id); } /* end H5VL_pass_through_get_object() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_get_wrap_ctx * @@ -699,7 +762,7 @@ H5VL_pass_through_get_object(const void *obj) static herr_t H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) { - const H5VL_pass_through_t *o = (const H5VL_pass_through_t *)obj; + const H5VL_pass_through_t * o = (const H5VL_pass_through_t *)obj; H5VL_pass_through_wrap_ctx_t *new_wrap_ctx; #ifdef ENABLE_PASSTHRU_LOGGING @@ -720,7 +783,6 @@ H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) return 0; } /* end H5VL_pass_through_get_wrap_ctx() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_wrap_object * @@ -735,8 +797,8 @@ static void * H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type, void *_wrap_ctx) { H5VL_pass_through_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)_wrap_ctx; - H5VL_pass_through_t *new_obj; - void *under; + H5VL_pass_through_t * new_obj; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL WRAP Object\n"); @@ -744,7 +806,7 @@ H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type, void *_wrap_ctx) /* Wrap the object with the underlying VOL */ under = H5VLwrap_object(obj, obj_type, wrap_ctx->under_vol_id, wrap_ctx->under_wrap_ctx); - if(under) + if (under) new_obj = H5VL_pass_through_new_obj(under, wrap_ctx->under_vol_id); else new_obj = NULL; @@ -752,7 +814,6 @@ H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type, void *_wrap_ctx) return new_obj; } /* end H5VL_pass_through_wrap_object() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_unwrap_object * @@ -768,7 +829,7 @@ static void * H5VL_pass_through_unwrap_object(void *obj) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL UNWRAP Object\n"); @@ -777,13 +838,12 @@ H5VL_pass_through_unwrap_object(void *obj) /* Unrap the object with the underlying VOL */ under = H5VLunwrap_object(o->under_object, o->under_vol_id); - if(under) + if (under) H5VL_pass_through_free_obj(o); return under; } /* end H5VL_pass_through_unwrap_object() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_free_wrap_ctx * @@ -801,7 +861,7 @@ static herr_t H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx) { H5VL_pass_through_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)_wrap_ctx; - hid_t err_id; + hid_t err_id; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL WRAP CTX Free\n"); @@ -810,7 +870,7 @@ H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx) err_id = H5Eget_current_stack(); /* Release underlying VOL ID and wrap context */ - if(wrap_ctx->under_wrap_ctx) + if (wrap_ctx->under_wrap_ctx) H5VLfree_wrap_ctx(wrap_ctx->under_wrap_ctx, wrap_ctx->under_vol_id); H5Idec_ref(wrap_ctx->under_vol_id); @@ -822,7 +882,6 @@ H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx) return 0; } /* end H5VL_pass_through_free_wrap_ctx() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_attr_create * @@ -834,33 +893,32 @@ H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx) *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, - hid_t aapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, + hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) { H5VL_pass_through_t *attr; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Create\n"); #endif - under = H5VLattr_create(o->under_object, loc_params, o->under_vol_id, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req); - if(under) { + under = H5VLattr_create(o->under_object, loc_params, o->under_vol_id, name, type_id, space_id, acpl_id, + aapl_id, dxpl_id, req); + if (under) { attr = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else attr = NULL; - return (void*)attr; + return (void *)attr; } /* end H5VL_pass_through_attr_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_attr_open * @@ -872,23 +930,23 @@ H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t aapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, + hid_t dxpl_id, void **req) { H5VL_pass_through_t *attr; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Open\n"); #endif under = H5VLattr_open(o->under_object, loc_params, o->under_vol_id, name, aapl_id, dxpl_id, req); - if(under) { + if (under) { attr = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else @@ -897,7 +955,6 @@ H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, return (void *)attr; } /* end H5VL_pass_through_attr_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_attr_read * @@ -909,11 +966,10 @@ H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, - hid_t dxpl_id, void **req) +H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Read\n"); @@ -922,13 +978,12 @@ H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, ret_value = H5VLattr_read(o->under_object, o->under_vol_id, mem_type_id, buf, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_attr_read() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_attr_write * @@ -940,11 +995,10 @@ H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, - hid_t dxpl_id, void **req) +H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Write\n"); @@ -953,13 +1007,12 @@ H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, ret_value = H5VLattr_write(o->under_object, o->under_vol_id, mem_type_id, buf, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_attr_write() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_attr_get * @@ -971,11 +1024,10 @@ H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Get\n"); @@ -984,13 +1036,12 @@ H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, ret_value = H5VLattr_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_attr_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_attr_specific * @@ -1003,25 +1054,26 @@ H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, */ static herr_t H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Specific\n"); #endif - ret_value = H5VLattr_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, arguments); + ret_value = H5VLattr_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, + arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_attr_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_attr_optional * @@ -1033,11 +1085,11 @@ H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Optional\n"); @@ -1046,13 +1098,12 @@ H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, ret_value = H5VLattr_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_attr_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_attr_close * @@ -1067,7 +1118,7 @@ static herr_t H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL ATTRIBUTE Close\n"); @@ -1076,17 +1127,16 @@ H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req) ret_value = H5VLattr_close(o->under_object, o->under_vol_id, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); /* Release our wrapper, if underlying attribute was closed */ - if(ret_value >= 0) + if (ret_value >= 0) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_attr_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_create * @@ -1098,24 +1148,25 @@ H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req) *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, - hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, + hid_t dxpl_id, void **req) { H5VL_pass_through_t *dset; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Create\n"); #endif - under = H5VLdataset_create(o->under_object, loc_params, o->under_vol_id, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req); - if(under) { + under = H5VLdataset_create(o->under_object, loc_params, o->under_vol_id, name, lcpl_id, type_id, space_id, + dcpl_id, dapl_id, dxpl_id, req); + if (under) { dset = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else @@ -1124,7 +1175,6 @@ H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, return (void *)dset; } /* end H5VL_pass_through_dataset_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_open * @@ -1136,23 +1186,23 @@ H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t dapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) { H5VL_pass_through_t *dset; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Open\n"); #endif under = H5VLdataset_open(o->under_object, loc_params, o->under_vol_id, name, dapl_id, dxpl_id, req); - if(under) { + if (under) { dset = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else @@ -1161,7 +1211,6 @@ H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, return (void *)dset; } /* end H5VL_pass_through_dataset_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_read * @@ -1173,26 +1222,26 @@ H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, void *buf, void **req) +H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t plist_id, void *buf, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Read\n"); #endif - ret_value = H5VLdataset_read(o->under_object, o->under_vol_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req); + ret_value = H5VLdataset_read(o->under_object, o->under_vol_id, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_dataset_read() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_write * @@ -1204,26 +1253,26 @@ H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, const void *buf, void **req) +H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t plist_id, const void *buf, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Write\n"); #endif - ret_value = H5VLdataset_write(o->under_object, o->under_vol_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req); + ret_value = H5VLdataset_write(o->under_object, o->under_vol_id, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_dataset_write() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_get * @@ -1235,11 +1284,11 @@ H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_i *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Get\n"); @@ -1248,13 +1297,12 @@ H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, ret_value = H5VLdataset_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_dataset_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_specific * @@ -1266,12 +1314,12 @@ H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - hid_t under_vol_id; - herr_t ret_value; + hid_t under_vol_id; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL H5Dspecific\n"); @@ -1281,16 +1329,16 @@ H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_t // refresh destroying the current object under_vol_id = o->under_vol_id; - ret_value = H5VLdataset_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + ret_value = + H5VLdataset_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); return ret_value; } /* end H5VL_pass_through_dataset_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_optional * @@ -1302,11 +1350,11 @@ H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_t *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Optional\n"); @@ -1315,13 +1363,12 @@ H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, ret_value = H5VLdataset_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_dataset_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_dataset_close * @@ -1336,7 +1383,7 @@ static herr_t H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATASET Close\n"); @@ -1345,17 +1392,16 @@ H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req) ret_value = H5VLdataset_close(o->under_object, o->under_vol_id, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); /* Release our wrapper, if underlying dataset was closed */ - if(ret_value >= 0) + if (ret_value >= 0) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_dataset_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_datatype_commit * @@ -1367,24 +1413,25 @@ H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req) *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, - hid_t dxpl_id, void **req) +H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, + void **req) { H5VL_pass_through_t *dt; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Commit\n"); #endif - under = H5VLdatatype_commit(o->under_object, loc_params, o->under_vol_id, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req); - if(under) { + under = H5VLdatatype_commit(o->under_object, loc_params, o->under_vol_id, name, type_id, lcpl_id, tcpl_id, + tapl_id, dxpl_id, req); + if (under) { dt = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else @@ -1393,7 +1440,6 @@ H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params return (void *)dt; } /* end H5VL_pass_through_datatype_commit() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_datatype_open * @@ -1405,23 +1451,23 @@ H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) { H5VL_pass_through_t *dt; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Open\n"); #endif under = H5VLdatatype_open(o->under_object, loc_params, o->under_vol_id, name, tapl_id, dxpl_id, req); - if(under) { + if (under) { dt = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else @@ -1430,7 +1476,6 @@ H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, return (void *)dt; } /* end H5VL_pass_through_datatype_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_datatype_get * @@ -1442,11 +1487,11 @@ H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Get\n"); @@ -1455,13 +1500,12 @@ H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, ret_value = H5VLdatatype_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_datatype_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_datatype_specific * @@ -1473,12 +1517,12 @@ H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - hid_t under_vol_id; - herr_t ret_value; + hid_t under_vol_id; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Specific\n"); @@ -1488,16 +1532,16 @@ H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific // refresh destroying the current object under_vol_id = o->under_vol_id; - ret_value = H5VLdatatype_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + ret_value = + H5VLdatatype_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); return ret_value; } /* end H5VL_pass_through_datatype_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_datatype_optional * @@ -1509,11 +1553,11 @@ H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Optional\n"); @@ -1522,13 +1566,12 @@ H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type ret_value = H5VLdatatype_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_datatype_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_datatype_close * @@ -1543,7 +1586,7 @@ static herr_t H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL DATATYPE Close\n"); @@ -1554,17 +1597,16 @@ H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req) ret_value = H5VLdatatype_close(o->under_object, o->under_vol_id, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); /* Release our wrapper, if underlying datatype was closed */ - if(ret_value >= 0) + if (ret_value >= 0) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_datatype_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_create * @@ -1576,13 +1618,13 @@ H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req) *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, + void **req) { H5VL_pass_through_info_t *info; - H5VL_pass_through_t *file; - hid_t under_fapl_id; - void *under; + H5VL_pass_through_t * file; + hid_t under_fapl_id; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Create\n"); @@ -1603,11 +1645,11 @@ H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, /* Open the file with the underlying VOL connector */ under = H5VLfile_create(name, flags, fcpl_id, under_fapl_id, dxpl_id, req); - if(under) { + if (under) { file = H5VL_pass_through_new_obj(under, info->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, info->under_vol_id); } /* end if */ else @@ -1622,7 +1664,6 @@ H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, return (void *)file; } /* end H5VL_pass_through_file_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_open * @@ -1634,13 +1675,12 @@ H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, - hid_t dxpl_id, void **req) +H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) { H5VL_pass_through_info_t *info; - H5VL_pass_through_t *file; - hid_t under_fapl_id; - void *under; + H5VL_pass_through_t * file; + hid_t under_fapl_id; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Open\n"); @@ -1661,11 +1701,11 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, /* Open the file with the underlying VOL connector */ under = H5VLfile_open(name, flags, under_fapl_id, dxpl_id, req); - if(under) { + if (under) { file = H5VL_pass_through_new_obj(under, info->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, info->under_vol_id); } /* end if */ else @@ -1680,7 +1720,6 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, return (void *)file; } /* end H5VL_pass_through_file_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_get * @@ -1692,11 +1731,10 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Get\n"); @@ -1705,13 +1743,12 @@ H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, ret_value = H5VLfile_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_file_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_specific_reissue * @@ -1724,11 +1761,11 @@ H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, - H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...) +H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, ...) { va_list arguments; - herr_t ret_value; + herr_t ret_value; va_start(arguments, req); ret_value = H5VLfile_specific(obj, connector_id, specific_type, dxpl_id, req, arguments); @@ -1737,7 +1774,6 @@ H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, return ret_value; } /* end H5VL_pass_through_file_specific_reissue() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_specific * @@ -1749,41 +1785,43 @@ H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) { - H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; - hid_t under_vol_id = -1; - herr_t ret_value; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + hid_t under_vol_id = -1; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Specific\n"); #endif /* Unpack arguments to get at the child file pointer when mounting a file */ - if(specific_type == H5VL_FILE_MOUNT) { - H5I_type_t loc_type; - const char *name; + if (specific_type == H5VL_FILE_MOUNT) { + H5I_type_t loc_type; + const char * name; H5VL_pass_through_t *child_file; - hid_t plist_id; + hid_t plist_id; /* Retrieve parameters for 'mount' operation, so we can unwrap the child file */ - loc_type = (H5I_type_t)va_arg(arguments, int); /* enum work-around */ - name = va_arg(arguments, const char *); + loc_type = (H5I_type_t)va_arg(arguments, int); /* enum work-around */ + name = va_arg(arguments, const char *); child_file = (H5VL_pass_through_t *)va_arg(arguments, void *); - plist_id = va_arg(arguments, hid_t); + plist_id = va_arg(arguments, hid_t); /* Keep the correct underlying VOL ID for possible async request token */ under_vol_id = o->under_vol_id; /* Re-issue 'file specific' call, using the unwrapped pieces */ - ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, (int)loc_type, name, child_file->under_object, plist_id); + ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, + dxpl_id, req, (int)loc_type, name, + child_file->under_object, plist_id); } /* end if */ - else if(specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) { + else if (specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) { H5VL_pass_through_info_t *info; - hid_t fapl_id, under_fapl_id; - const char *name; - htri_t *ret; + hid_t fapl_id, under_fapl_id; + const char * name; + htri_t * ret; /* Get the arguments for the 'is accessible' check */ fapl_id = va_arg(arguments, hid_t); @@ -1807,7 +1845,8 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, under_vol_id = info->under_vol_id; /* Re-issue 'file specific' call */ - ret_value = H5VL_pass_through_file_specific_reissue(NULL, info->under_vol_id, specific_type, dxpl_id, req, under_fapl_id, name, ret); + ret_value = H5VL_pass_through_file_specific_reissue(NULL, info->under_vol_id, specific_type, dxpl_id, + req, under_fapl_id, name, ret); /* Close underlying FAPL */ H5Pclose(under_fapl_id); @@ -1819,36 +1858,36 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, va_list my_arguments; /* Make a copy of the argument list for later, if reopening */ - if(specific_type == H5VL_FILE_REOPEN) + if (specific_type == H5VL_FILE_REOPEN) va_copy(my_arguments, arguments); /* Keep the correct underlying VOL ID for possible async request token */ under_vol_id = o->under_vol_id; - ret_value = H5VLfile_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + ret_value = + H5VLfile_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); /* Wrap file struct pointer, if we reopened one */ - if(specific_type == H5VL_FILE_REOPEN) { - if(ret_value >= 0) { - void **ret = va_arg(my_arguments, void **); + if (specific_type == H5VL_FILE_REOPEN) { + if (ret_value >= 0) { + void **ret = va_arg(my_arguments, void **); - if(ret && *ret) + if (ret && *ret) *ret = H5VL_pass_through_new_obj(*ret, o->under_vol_id); } /* end if */ /* Finish use of copied vararg list */ va_end(my_arguments); } /* end if */ - } /* end else */ + } /* end else */ /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); return ret_value; } /* end H5VL_pass_through_file_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_optional * @@ -1860,11 +1899,11 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL File Optional\n"); @@ -1873,13 +1912,12 @@ H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, ret_value = H5VLfile_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_file_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_file_close * @@ -1894,7 +1932,7 @@ static herr_t H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL FILE Close\n"); @@ -1903,17 +1941,16 @@ H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req) ret_value = H5VLfile_close(o->under_object, o->under_vol_id, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); /* Release our wrapper, if underlying file was closed */ - if(ret_value >= 0) + if (ret_value >= 0) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_file_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_group_create * @@ -1925,24 +1962,24 @@ H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req) *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, - hid_t dxpl_id, void **req) +H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) { H5VL_pass_through_t *group; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Create\n"); #endif - under = H5VLgroup_create(o->under_object, loc_params, o->under_vol_id, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req); - if(under) { + under = H5VLgroup_create(o->under_object, loc_params, o->under_vol_id, name, lcpl_id, gcpl_id, gapl_id, + dxpl_id, req); + if (under) { group = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else @@ -1951,7 +1988,6 @@ H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, return (void *)group; } /* end H5VL_pass_through_group_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_group_open * @@ -1963,23 +1999,23 @@ H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t gapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, + hid_t dxpl_id, void **req) { H5VL_pass_through_t *group; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Open\n"); #endif under = H5VLgroup_open(o->under_object, loc_params, o->under_vol_id, name, gapl_id, dxpl_id, req); - if(under) { + if (under) { group = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else @@ -1988,7 +2024,6 @@ H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, return (void *)group; } /* end H5VL_pass_through_group_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_group_get * @@ -2000,11 +2035,11 @@ H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, - void **req, va_list arguments) +H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Get\n"); @@ -2013,13 +2048,12 @@ H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, ret_value = H5VLgroup_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_group_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_group_specific * @@ -2031,12 +2065,12 @@ H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - hid_t under_vol_id; - herr_t ret_value; + hid_t under_vol_id; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Specific\n"); @@ -2049,13 +2083,12 @@ H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, ret_value = H5VLgroup_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); return ret_value; } /* end H5VL_pass_through_group_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_group_optional * @@ -2067,11 +2100,11 @@ H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL GROUP Optional\n"); @@ -2080,13 +2113,12 @@ H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, ret_value = H5VLgroup_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_group_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_group_close * @@ -2101,7 +2133,7 @@ static herr_t H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)grp; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL H5Gclose\n"); @@ -2110,17 +2142,16 @@ H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req) ret_value = H5VLgroup_close(o->under_object, o->under_vol_id, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); /* Release our wrapper, if underlying file was closed */ - if(ret_value >= 0) + if (ret_value >= 0) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_group_close() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_link_create_reissue * @@ -2133,15 +2164,16 @@ H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req) *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, - void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, ...) +H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req, ...) { va_list arguments; - herr_t ret_value; + herr_t ret_value; va_start(arguments, req); - ret_value = H5VLlink_create(create_type, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req, arguments); + ret_value = H5VLlink_create(create_type, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req, + arguments); va_end(arguments); return ret_value; @@ -2159,34 +2191,34 @@ H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, */ static herr_t H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, - hid_t dxpl_id, void **req, va_list arguments) + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req, va_list arguments) { - H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - hid_t under_vol_id = -1; - herr_t ret_value; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + hid_t under_vol_id = -1; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Create\n"); #endif /* Try to retrieve the "under" VOL id */ - if(o) + if (o) under_vol_id = o->under_vol_id; /* Fix up the link target object for hard link creation */ - if(H5VL_LINK_CREATE_HARD == create_type) { - void *cur_obj; + if (H5VL_LINK_CREATE_HARD == create_type) { + void * cur_obj; H5VL_loc_params_t *cur_params; /* Retrieve the object & loc params for the link target */ - cur_obj = va_arg(arguments, void *); + cur_obj = va_arg(arguments, void *); cur_params = va_arg(arguments, H5VL_loc_params_t *); /* If it's a non-NULL pointer, find the 'under object' and re-set the property */ - if(cur_obj) { + if (cur_obj) { /* Check if we still need the "under" VOL ID */ - if(under_vol_id < 0) + if (under_vol_id < 0) under_vol_id = ((H5VL_pass_through_t *)cur_obj)->under_vol_id; /* Set the object for the link target */ @@ -2194,19 +2226,21 @@ H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, } /* end if */ /* Re-issue 'link create' call, using the unwrapped pieces */ - ret_value = H5VL_pass_through_link_create_reissue(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, req, cur_obj, cur_params); + ret_value = H5VL_pass_through_link_create_reissue(create_type, (o ? o->under_object : NULL), + loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, + req, cur_obj, cur_params); } /* end if */ else - ret_value = H5VLlink_create(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, req, arguments); + ret_value = H5VLlink_create(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, + lcpl_id, lapl_id, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); return ret_value; } /* end H5VL_pass_through_link_create() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_link_copy * @@ -2223,36 +2257,37 @@ H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req) { - H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; - H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; - hid_t under_vol_id = -1; - herr_t ret_value; + H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; + H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; + hid_t under_vol_id = -1; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Copy\n"); #endif /* Retrieve the "under" VOL id */ - if(o_src) + if (o_src) under_vol_id = o_src->under_vol_id; - else if(o_dst) + else if (o_dst) under_vol_id = o_dst->under_vol_id; assert(under_vol_id > 0); - ret_value = H5VLlink_copy((o_src ? o_src->under_object : NULL), loc_params1, (o_dst ? o_dst->under_object : NULL), loc_params2, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); + ret_value = + H5VLlink_copy((o_src ? o_src->under_object : NULL), loc_params1, (o_dst ? o_dst->under_object : NULL), + loc_params2, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); return ret_value; } /* end H5VL_pass_through_link_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_link_move * @@ -2269,36 +2304,37 @@ H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t lapl_id, hid_t dxpl_id, void **req) +H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req) { - H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; - H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; - hid_t under_vol_id = -1; - herr_t ret_value; + H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; + H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; + hid_t under_vol_id = -1; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Move\n"); #endif /* Retrieve the "under" VOL id */ - if(o_src) + if (o_src) under_vol_id = o_src->under_vol_id; - else if(o_dst) + else if (o_dst) under_vol_id = o_dst->under_vol_id; assert(under_vol_id > 0); - ret_value = H5VLlink_move((o_src ? o_src->under_object : NULL), loc_params1, (o_dst ? o_dst->under_object : NULL), loc_params2, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); + ret_value = + H5VLlink_move((o_src ? o_src->under_object : NULL), loc_params1, (o_dst ? o_dst->under_object : NULL), + loc_params2, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); return ret_value; } /* end H5VL_pass_through_link_move() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_link_get * @@ -2310,11 +2346,11 @@ H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Get\n"); @@ -2323,13 +2359,12 @@ H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, ret_value = H5VLlink_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_link_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_link_specific * @@ -2342,25 +2377,26 @@ H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, */ static herr_t H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Specific\n"); #endif - ret_value = H5VLlink_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, arguments); + ret_value = H5VLlink_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, + arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_link_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_link_optional * @@ -2372,11 +2408,11 @@ H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL LINK Optional\n"); @@ -2385,13 +2421,12 @@ H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, ret_value = H5VLlink_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_link_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_object_open * @@ -2403,23 +2438,23 @@ H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, *------------------------------------------------------------------------- */ static void * -H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, - H5I_type_t *opened_type, hid_t dxpl_id, void **req) +H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) { H5VL_pass_through_t *new_obj; H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - void *under; + void * under; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Open\n"); #endif under = H5VLobject_open(o->under_object, loc_params, o->under_vol_id, opened_type, dxpl_id, req); - if(under) { + if (under) { new_obj = H5VL_pass_through_new_obj(under, o->under_vol_id); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); } /* end if */ else @@ -2428,7 +2463,6 @@ H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, return (void *)new_obj; } /* end H5VL_pass_through_object_open() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_object_copy * @@ -2440,29 +2474,29 @@ H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, - const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, - void **req) +H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) { H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Copy\n"); #endif - ret_value = H5VLobject_copy(o_src->under_object, src_loc_params, src_name, o_dst->under_object, dst_loc_params, dst_name, o_src->under_vol_id, ocpypl_id, lcpl_id, dxpl_id, req); + ret_value = + H5VLobject_copy(o_src->under_object, src_loc_params, src_name, o_dst->under_object, dst_loc_params, + dst_name, o_src->under_vol_id, ocpypl_id, lcpl_id, dxpl_id, req); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o_src->under_vol_id); return ret_value; } /* end H5VL_pass_through_object_copy() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_object_get * @@ -2474,25 +2508,26 @@ H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_pa *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Get\n"); #endif - ret_value = H5VLobject_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); + ret_value = + H5VLobject_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_object_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_object_specific * @@ -2505,12 +2540,12 @@ H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5V */ static herr_t H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, - va_list arguments) + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - hid_t under_vol_id; - herr_t ret_value; + hid_t under_vol_id; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Specific\n"); @@ -2520,16 +2555,16 @@ H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params // refresh destroying the current object under_vol_id = o->under_vol_id; - ret_value = H5VLobject_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, arguments); + ret_value = H5VLobject_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, + arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, under_vol_id); return ret_value; } /* end H5VL_pass_through_object_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_object_optional * @@ -2541,11 +2576,11 @@ H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, - hid_t dxpl_id, void **req, va_list arguments) +H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL OBJECT Optional\n"); @@ -2554,13 +2589,12 @@ H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, ret_value = H5VLobject_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); /* Check for async request */ - if(req && *req) + if (req && *req) *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); return ret_value; } /* end H5VL_pass_through_object_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_introspect_get_conn_clss * @@ -2571,29 +2605,26 @@ H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, - const H5VL_class_t **conn_cls) +H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INTROSPECT GetConnCls\n"); #endif /* Check for querying this connector's class */ - if(H5VL_GET_CONN_LVL_CURR == lvl) { + if (H5VL_GET_CONN_LVL_CURR == lvl) { *conn_cls = &H5VL_pass_through_g; ret_value = 0; } /* end if */ else - ret_value = H5VLintrospect_get_conn_cls(o->under_object, o->under_vol_id, - lvl, conn_cls); + ret_value = H5VLintrospect_get_conn_cls(o->under_object, o->under_vol_id, lvl, conn_cls); return ret_value; } /* end H5VL_pass_through_introspect_get_conn_cls() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_introspect_opt_query * @@ -2604,23 +2635,20 @@ H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, - int opt_type, hbool_t *supported) +H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, hbool_t *supported) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL INTROSPECT OptQuery\n"); #endif - ret_value = H5VLintrospect_opt_query(o->under_object, o->under_vol_id, cls, - opt_type, supported); + ret_value = H5VLintrospect_opt_query(o->under_object, o->under_vol_id, cls, opt_type, supported); return ret_value; } /* end H5VL_pass_through_introspect_opt_query() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_wait * @@ -2635,11 +2663,10 @@ H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_request_wait(void *obj, uint64_t timeout, - H5ES_status_t *status) +H5VL_pass_through_request_wait(void *obj, uint64_t timeout, H5ES_status_t *status) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Wait\n"); @@ -2647,13 +2674,12 @@ H5VL_pass_through_request_wait(void *obj, uint64_t timeout, ret_value = H5VLrequest_wait(o->under_object, o->under_vol_id, timeout, status); - if(ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) + if (ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_request_wait() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_notify * @@ -2671,7 +2697,7 @@ static herr_t H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Notify\n"); @@ -2679,13 +2705,12 @@ H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx) ret_value = H5VLrequest_notify(o->under_object, o->under_vol_id, cb, ctx); - if(ret_value >= 0) + if (ret_value >= 0) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_request_notify() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_cancel * @@ -2702,7 +2727,7 @@ static herr_t H5VL_pass_through_request_cancel(void *obj) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Cancel\n"); @@ -2710,13 +2735,12 @@ H5VL_pass_through_request_cancel(void *obj) ret_value = H5VLrequest_cancel(o->under_object, o->under_vol_id); - if(ret_value >= 0) + if (ret_value >= 0) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_request_cancel() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_specific_reissue * @@ -2730,10 +2754,10 @@ H5VL_pass_through_request_cancel(void *obj) */ static herr_t H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, - H5VL_request_specific_t specific_type, ...) + H5VL_request_specific_t specific_type, ...) { va_list arguments; - herr_t ret_value; + herr_t ret_value; va_start(arguments, specific_type); ret_value = H5VLrequest_specific(obj, connector_id, specific_type, arguments); @@ -2742,7 +2766,6 @@ H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, return ret_value; } /* end H5VL_pass_through_request_specific_reissue() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_specific * @@ -2754,8 +2777,7 @@ H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_type, - va_list arguments) +H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_type, va_list arguments) { herr_t ret_value = -1; @@ -2763,11 +2785,10 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t printf("------- PASS THROUGH VOL REQUEST Specific\n"); #endif - if(H5VL_REQUEST_WAITANY == specific_type || - H5VL_REQUEST_WAITSOME == specific_type || - H5VL_REQUEST_WAITALL == specific_type) { + if (H5VL_REQUEST_WAITANY == specific_type || H5VL_REQUEST_WAITSOME == specific_type || + H5VL_REQUEST_WAITALL == specific_type) { va_list tmp_arguments; - size_t req_count; + size_t req_count; /* Sanity check */ assert(obj == NULL); @@ -2777,12 +2798,12 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t req_count = va_arg(tmp_arguments, size_t); /* Can only use a request to invoke the underlying VOL connector when there's >0 requests */ - if(req_count > 0) { - void **req_array; - void **under_req_array; - uint64_t timeout; + if (req_count > 0) { + void ** req_array; + void ** under_req_array; + uint64_t timeout; H5VL_pass_through_t *o; - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ /* Get the request array */ req_array = va_arg(tmp_arguments, void **); @@ -2792,16 +2813,16 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t /* Create array of underlying VOL requests */ under_req_array = (void **)malloc(req_count * sizeof(void **)); - for(u = 0; u < req_count; u++) + for (u = 0; u < req_count; u++) under_req_array[u] = ((H5VL_pass_through_t *)req_array[u])->under_object; /* Remove the timeout value from the vararg list (it's used in all the calls below) */ timeout = va_arg(tmp_arguments, uint64_t); /* Release requests that have completed */ - if(H5VL_REQUEST_WAITANY == specific_type) { - size_t *idx; /* Pointer to the index of completed request */ - H5ES_status_t *status; /* Pointer to the request's status */ + if (H5VL_REQUEST_WAITANY == specific_type) { + size_t * idx; /* Pointer to the index of completed request */ + H5ES_status_t *status; /* Pointer to the request's status */ /* Retrieve the remaining arguments */ idx = va_arg(tmp_arguments, size_t *); @@ -2809,69 +2830,73 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t status = va_arg(tmp_arguments, H5ES_status_t *); /* Reissue the WAITANY 'request specific' call */ - ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, - idx, - status); + ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, + specific_type, req_count, + under_req_array, timeout, idx, status); /* Release the completed request, if it completed */ - if(ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) { + if (ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) { H5VL_pass_through_t *tmp_o; tmp_o = (H5VL_pass_through_t *)req_array[*idx]; H5VL_pass_through_free_obj(tmp_o); } /* end if */ - } /* end if */ - else if(H5VL_REQUEST_WAITSOME == specific_type) { - size_t *outcount; /* # of completed requests */ - unsigned *array_of_indices; /* Array of indices for completed requests */ + } /* end if */ + else if (H5VL_REQUEST_WAITSOME == specific_type) { + size_t * outcount; /* # of completed requests */ + unsigned * array_of_indices; /* Array of indices for completed requests */ H5ES_status_t *array_of_statuses; /* Array of statuses for completed requests */ /* Retrieve the remaining arguments */ outcount = va_arg(tmp_arguments, size_t *); assert(*outcount <= req_count); - array_of_indices = va_arg(tmp_arguments, unsigned *); + array_of_indices = va_arg(tmp_arguments, unsigned *); array_of_statuses = va_arg(tmp_arguments, H5ES_status_t *); /* Reissue the WAITSOME 'request specific' call */ - ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, outcount, array_of_indices, array_of_statuses); + ret_value = H5VL_pass_through_request_specific_reissue( + o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, + outcount, array_of_indices, array_of_statuses); /* If any requests completed, release them */ - if(ret_value >= 0 && *outcount > 0) { - unsigned *idx_array; /* Array of indices of completed requests */ + if (ret_value >= 0 && *outcount > 0) { + unsigned *idx_array; /* Array of indices of completed requests */ /* Retrieve the array of completed request indices */ idx_array = va_arg(tmp_arguments, unsigned *); /* Release the completed requests */ - for(u = 0; u < *outcount; u++) { + for (u = 0; u < *outcount; u++) { H5VL_pass_through_t *tmp_o; tmp_o = (H5VL_pass_through_t *)req_array[idx_array[u]]; H5VL_pass_through_free_obj(tmp_o); - } /* end for */ - } /* end if */ - } /* end else-if */ - else { /* H5VL_REQUEST_WAITALL == specific_type */ + } /* end for */ + } /* end if */ + } /* end else-if */ + else { /* H5VL_REQUEST_WAITALL == specific_type */ H5ES_status_t *array_of_statuses; /* Array of statuses for completed requests */ /* Retrieve the remaining arguments */ array_of_statuses = va_arg(tmp_arguments, H5ES_status_t *); /* Reissue the WAITALL 'request specific' call */ - ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, array_of_statuses); + ret_value = H5VL_pass_through_request_specific_reissue( + o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, + array_of_statuses); /* Release the completed requests */ - if(ret_value >= 0) { - for(u = 0; u < req_count; u++) { - if(array_of_statuses[u] != H5ES_STATUS_IN_PROGRESS) { + if (ret_value >= 0) { + for (u = 0; u < req_count; u++) { + if (array_of_statuses[u] != H5ES_STATUS_IN_PROGRESS) { H5VL_pass_through_t *tmp_o; tmp_o = (H5VL_pass_through_t *)req_array[u]; H5VL_pass_through_free_obj(tmp_o); } /* end if */ - } /* end for */ - } /* end if */ - } /* end else */ + } /* end for */ + } /* end if */ + } /* end else */ /* Release array of requests for underlying connector */ free(under_req_array); @@ -2886,7 +2911,6 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t return ret_value; } /* end H5VL_pass_through_request_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_optional * @@ -2898,11 +2922,10 @@ H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_t *------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_request_optional(void *obj, H5VL_request_optional_t opt_type, - va_list arguments) +H5VL_pass_through_request_optional(void *obj, H5VL_request_optional_t opt_type, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Optional\n"); @@ -2913,7 +2936,6 @@ H5VL_pass_through_request_optional(void *obj, H5VL_request_optional_t opt_type, return ret_value; } /* end H5VL_pass_through_request_optional() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_request_free * @@ -2929,7 +2951,7 @@ static herr_t H5VL_pass_through_request_free(void *obj) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL REQUEST Free\n"); @@ -2937,13 +2959,12 @@ H5VL_pass_through_request_free(void *obj) ret_value = H5VLrequest_free(o->under_object, o->under_vol_id); - if(ret_value >= 0) + if (ret_value >= 0) H5VL_pass_through_free_obj(o); return ret_value; } /* end H5VL_pass_through_request_free() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_blob_put * @@ -2954,23 +2975,20 @@ H5VL_pass_through_request_free(void *obj) *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size, - void *blob_id, void *ctx) +H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL BLOB Put\n"); #endif - ret_value = H5VLblob_put(o->under_object, o->under_vol_id, buf, size, - blob_id, ctx); + ret_value = H5VLblob_put(o->under_object, o->under_vol_id, buf, size, blob_id, ctx); return ret_value; } /* end H5VL_pass_through_blob_put() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_blob_get * @@ -2981,23 +2999,20 @@ H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size, *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, - size_t size, void *ctx) +H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL BLOB Get\n"); #endif - ret_value = H5VLblob_get(o->under_object, o->under_vol_id, blob_id, buf, - size, ctx); + ret_value = H5VLblob_get(o->under_object, o->under_vol_id, blob_id, buf, size, ctx); return ret_value; } /* end H5VL_pass_through_blob_get() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_blob_specific * @@ -3008,23 +3023,21 @@ H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_blob_specific(void *obj, void *blob_id, - H5VL_blob_specific_t specific_type, va_list arguments) +H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL BLOB Specific\n"); #endif - ret_value = H5VLblob_specific(o->under_object, o->under_vol_id, blob_id, - specific_type, arguments); + ret_value = H5VLblob_specific(o->under_object, o->under_vol_id, blob_id, specific_type, arguments); return ret_value; } /* end H5VL_pass_through_blob_specific() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_blob_optional * @@ -3035,23 +3048,20 @@ H5VL_pass_through_blob_specific(void *obj, void *blob_id, *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_blob_optional(void *obj, void *blob_id, - H5VL_blob_optional_t opt_type, va_list arguments) +H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL BLOB Optional\n"); #endif - ret_value = H5VLblob_optional(o->under_object, o->under_vol_id, blob_id, - opt_type, arguments); + ret_value = H5VLblob_optional(o->under_object, o->under_vol_id, blob_id, opt_type, arguments); return ret_value; } /* end H5VL_pass_through_blob_optional() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_token_cmp * @@ -3064,11 +3074,10 @@ H5VL_pass_through_blob_optional(void *obj, void *blob_id, *--------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, - const H5O_token_t *token2, int *cmp_value) +H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL TOKEN Compare\n"); @@ -3085,7 +3094,6 @@ H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, return ret_value; } /* end H5VL_pass_through_token_cmp() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_token_to_str * @@ -3097,11 +3105,10 @@ H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, *--------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, - const H5O_token_t *token, char **token_str) +H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL TOKEN To string\n"); @@ -3117,7 +3124,6 @@ H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, return ret_value; } /* end H5VL_pass_through_token_to_str() */ - /*--------------------------------------------------------------------------- * Function: H5VL_pass_through_token_from_str * @@ -3129,11 +3135,10 @@ H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, *--------------------------------------------------------------------------- */ static herr_t -H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, - const char *token_str, H5O_token_t *token) +H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL TOKEN From string\n"); @@ -3149,7 +3154,6 @@ H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, return ret_value; } /* end H5VL_pass_through_token_from_str() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_optional * @@ -3160,19 +3164,16 @@ H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, *------------------------------------------------------------------------- */ herr_t -H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, - va_list arguments) +H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, va_list arguments) { H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; - herr_t ret_value; + herr_t ret_value; #ifdef ENABLE_PASSTHRU_LOGGING printf("------- PASS THROUGH VOL generic Optional\n"); #endif - ret_value = H5VLoptional(o->under_object, o->under_vol_id, op_type, - dxpl_id, req, arguments); + ret_value = H5VLoptional(o->under_object, o->under_vol_id, op_type, dxpl_id, req, arguments); return ret_value; } /* end H5VL_pass_through_optional() */ - diff --git a/src/H5VLpassthru.h b/src/H5VLpassthru.h index d145bcd..a8ef42c 100644 --- a/src/H5VLpassthru.h +++ b/src/H5VLpassthru.h @@ -18,23 +18,22 @@ #define _H5VLpassthru_H /* Public headers needed by this file */ -#include "H5VLpublic.h" /* Virtual Object Layer */ +#include "H5VLpublic.h" /* Virtual Object Layer */ /* Identifier for the pass-through VOL connector */ -#define H5VL_PASSTHRU (H5VL_pass_through_register()) +#define H5VL_PASSTHRU (H5VL_pass_through_register()) /* Characteristics of the pass-through VOL connector */ -#define H5VL_PASSTHRU_NAME "pass_through" -#define H5VL_PASSTHRU_VALUE 505 /* VOL connector ID */ -#define H5VL_PASSTHRU_VERSION 0 +#define H5VL_PASSTHRU_NAME "pass_through" +#define H5VL_PASSTHRU_VALUE 505 /* VOL connector ID */ +#define H5VL_PASSTHRU_VERSION 0 /* Pass-through VOL connector info */ typedef struct H5VL_pass_through_info_t { - hid_t under_vol_id; /* VOL ID for under VOL */ - void *under_vol_info; /* VOL info for under VOL */ + hid_t under_vol_id; /* VOL ID for under VOL */ + void *under_vol_info; /* VOL info for under VOL */ } H5VL_pass_through_info_t; - #ifdef __cplusplus extern "C" { #endif @@ -46,4 +45,3 @@ H5_DLL hid_t H5VL_pass_through_register(void); #endif #endif /* _H5VLpassthru_H */ - diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h index 4174732..c784e50 100644 --- a/src/H5VLpkg.h +++ b/src/H5VLpkg.h @@ -24,45 +24,36 @@ #define _H5VLpkg_H /* Get package's private header */ -#include "H5VLprivate.h" /* Generic Functions */ +#include "H5VLprivate.h" /* Generic Functions */ /* Other private headers needed by this file */ - /**************************/ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL hid_t H5VL__register_connector(const H5VL_class_t *cls, hbool_t app_ref, - hid_t vipl_id); -H5_DLL hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref, - hid_t vipl_id); -H5_DLL hid_t H5VL__register_connector_by_value(H5VL_class_value_t value, - hbool_t app_ref, hid_t vipl_id); -H5_DLL htri_t H5VL__is_connector_registered_by_name(const char *name); -H5_DLL htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value); -H5_DLL hid_t H5VL__get_connector_id(hid_t obj_id, hbool_t is_api); -H5_DLL hid_t H5VL__get_connector_id_by_name(const char *name, hbool_t is_api); -H5_DLL hid_t H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api); -H5_DLL hid_t H5VL__peek_connector_id_by_name(const char *name); -H5_DLL hid_t H5VL__peek_connector_id_by_value(H5VL_class_value_t value); -H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, - void **info); -H5_DLL ssize_t H5VL__get_connector_name(hid_t id, char *name/*out*/, size_t size); +H5_DLL hid_t H5VL__register_connector(const H5VL_class_t *cls, hbool_t app_ref, hid_t vipl_id); +H5_DLL hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_id); +H5_DLL hid_t H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid_t vipl_id); +H5_DLL htri_t H5VL__is_connector_registered_by_name(const char *name); +H5_DLL htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value); +H5_DLL hid_t H5VL__get_connector_id(hid_t obj_id, hbool_t is_api); +H5_DLL hid_t H5VL__get_connector_id_by_name(const char *name, hbool_t is_api); +H5_DLL hid_t H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api); +H5_DLL hid_t H5VL__peek_connector_id_by_name(const char *name); +H5_DLL hid_t H5VL__peek_connector_id_by_value(H5VL_class_value_t value); +H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info); +H5_DLL ssize_t H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size); #endif /* _H5VLpkg_H */ - diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 3235357..bb4e60f 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -14,51 +14,47 @@ #define _H5VLprivate_H /* Include package's public header */ -#include "H5VLpublic.h" /* Generic Functions */ +#include "H5VLpublic.h" /* Generic Functions */ /* Private headers needed by this file */ - /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* Internal struct to track VOL connector information for objects */ typedef struct H5VL_t { - const H5VL_class_t *cls; /* Pointer to connector class struct */ - int64_t nrefs; /* Number of references by objects using this struct */ - hid_t id; /* Identifier for the VOL connector */ + const H5VL_class_t *cls; /* Pointer to connector class struct */ + int64_t nrefs; /* Number of references by objects using this struct */ + hid_t id; /* Identifier for the VOL connector */ } H5VL_t; /* Internal vol object structure returned to the API */ typedef struct H5VL_object_t { - void *data; /* Pointer to connector-managed data for this object */ - H5VL_t *connector; /* Pointer to VOL connector struct */ + void * data; /* Pointer to connector-managed data for this object */ + H5VL_t *connector; /* Pointer to VOL connector struct */ } H5VL_object_t; /* Internal structure to hold the connector ID & info for FAPLs */ typedef struct H5VL_connector_prop_t { - hid_t connector_id; /* VOL connector's ID */ - const void *connector_info; /* VOL connector info, for open callbacks */ + hid_t connector_id; /* VOL connector's ID */ + const void *connector_info; /* VOL connector info, for open callbacks */ } H5VL_connector_prop_t; /* Which kind of VOL connector field to use for searching */ typedef enum H5VL_get_connector_kind_t { - H5VL_GET_CONNECTOR_BY_NAME, /* Name field is set */ - H5VL_GET_CONNECTOR_BY_VALUE /* Value field is set */ + H5VL_GET_CONNECTOR_BY_NAME, /* Name field is set */ + H5VL_GET_CONNECTOR_BY_VALUE /* Value field is set */ } H5VL_get_connector_kind_t; - /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ @@ -90,16 +86,14 @@ H5_DLL void *H5VL_object_unwrap(const H5VL_object_t *vol_obj); H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type); H5_DLL H5VL_object_t *H5VL_vol_object(hid_t id); H5_DLL H5VL_object_t *H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id); -H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj); -H5_DLL herr_t H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native); -H5_DLL herr_t H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, - hbool_t *same_file); +H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj); +H5_DLL herr_t H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native); +H5_DLL herr_t H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, + hbool_t *same_file); /* Functions that wrap / unwrap VOL objects */ -H5_DLL herr_t H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, - void **wrap_ctx); -H5_DLL void * H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, - void *obj, H5I_type_t obj_type); +H5_DLL herr_t H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx); +H5_DLL void * H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, H5I_type_t obj_type); H5_DLL void * H5VL_unwrap_object(const H5VL_class_t *connector, void *obj); H5_DLL herr_t H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx); H5_DLL herr_t H5VL_set_vol_wrapper(const H5VL_object_t *vol_obj); @@ -114,86 +108,135 @@ H5_DLL herr_t H5VL_reset_lib_state(void); H5_DLL herr_t H5VL_free_lib_state(void *state); /* ID registration functions */ -H5_DLL hid_t H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref); -H5_DLL hid_t H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref); -H5_DLL hid_t H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref); -H5_DLL herr_t H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref, hid_t existing_id); +H5_DLL hid_t H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref); +H5_DLL hid_t H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref); +H5_DLL hid_t H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref); +H5_DLL herr_t H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, + hbool_t app_ref, hid_t existing_id); /********************************** * VOL connector callback wrappers *********************************/ /* Connector "management" functions */ -H5_DLL int H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, - const void *src_info); -H5_DLL herr_t H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, - const void *info1, const void *info2); +H5_DLL int H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, const void *src_info); +H5_DLL herr_t H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const void *info1, + const void *info2); H5_DLL herr_t H5VL_free_connector_info(hid_t connector_id, const void *info); /* Attribute functions */ -H5_DLL void *H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, ...); +H5_DLL void * H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, + hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t dtype_id, void *buf, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t dtype_id, const void *buf, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + ...); +H5_DLL herr_t H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, + void **req, ...); H5_DLL herr_t H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Dataset functions */ -H5_DLL void *H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, void *buf, void **req); -H5_DLL herr_t H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req); -H5_DLL herr_t H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_dataset_specific(const H5VL_object_t *cls, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, ...); +H5_DLL void * H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, void *buf, void **req); +H5_DLL herr_t H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req); +H5_DLL herr_t H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_dataset_specific(const H5VL_object_t *cls, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_type, + hid_t dxpl_id, void **req, ...); H5_DLL herr_t H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Datatype functions */ -H5_DLL void *H5VL_datatype_commit(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, ...); +H5_DLL void * H5VL_datatype_commit(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, + hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t opt_type, + hid_t dxpl_id, void **req, ...); H5_DLL herr_t H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* File functions */ -H5_DLL void *H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_file_open(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, ...); +H5_DLL void * H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, + hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL_file_open(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, + hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + ...); +H5_DLL herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, + void **req, ...); H5_DLL herr_t H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Group functions */ -H5_DLL void *H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, ...); +H5_DLL void * H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +H5_DLL void * H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, ...); H5_DLL herr_t H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Link functions */ -H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, + void **req, ...); /* Object functions */ -H5_DLL void *H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, const H5VL_object_t *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, ...); +H5_DLL void * H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_params, + const char *src_name, const H5VL_object_t *dst_obj, + const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, + hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_type, + hid_t dxpl_id, void **req, ...); /* Connector/container introspection functions */ H5_DLL herr_t H5VL_introspect_get_conn_cls(const H5VL_object_t *vol_obj, H5VL_get_conn_lvl_t lvl, - const H5VL_class_t **conn_cls); -H5_DLL herr_t H5VL_introspect_opt_query(const H5VL_object_t *vol_obj, H5VL_subclass_t subcls, - int opt_type, hbool_t *supported); + const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VL_introspect_opt_query(const H5VL_object_t *vol_obj, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported); /* Asynchronous functions */ H5_DLL herr_t H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5ES_status_t *status); @@ -204,21 +247,24 @@ H5_DLL herr_t H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_request_o H5_DLL herr_t H5VL_request_free(const H5VL_object_t *vol_obj); /* Blob functions */ -H5_DLL herr_t H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void *blob_id, void *ctx); -H5_DLL herr_t H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size_t size, void *ctx); -H5_DLL herr_t H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specific_t specific_type, ...); -H5_DLL herr_t H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_optional_t opt_type, ...); +H5_DLL herr_t H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void *blob_id, + void *ctx); +H5_DLL herr_t H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size_t size, + void *ctx); +H5_DLL herr_t H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, + H5VL_blob_specific_t specific_type, ...); +H5_DLL herr_t H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_optional_t opt_type, + ...); /* Token functions */ H5_DLL herr_t H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, - const H5O_token_t *token2, int *cmp_value); -H5_DLL herr_t H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, - const H5O_token_t *token, char **token_str); -H5_DLL herr_t H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, - const char *token_str, H5O_token_t *token); + const H5O_token_t *token2, int *cmp_value); +H5_DLL herr_t H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str); +H5_DLL herr_t H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const char *token_str, + H5O_token_t *token); /* Generic functions */ H5_DLL herr_t H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, void **req, ...); #endif /* _H5VLprivate_H */ - diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 8f79adc..919a4b8 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -18,8 +18,8 @@ #define _H5VLpublic_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Ipublic.h" /* IDs */ +#include "H5public.h" /* Generic Functions */ +#include "H5Ipublic.h" /* IDs */ /*****************/ /* Public Macros */ @@ -28,17 +28,15 @@ /* VOL connector identifier values * These are H5VL_class_value_t values, NOT hid_t values! */ -#define H5_VOL_INVALID (-1) /* Invalid ID for VOL connector ID */ -#define H5_VOL_NATIVE 0 /* Native HDF5 file format VOL connector */ -#define H5_VOL_RESERVED 256 /* VOL connector IDs below this value are reserved for library use */ -#define H5_VOL_MAX 65535 /* Maximum VOL connector ID */ - +#define H5_VOL_INVALID (-1) /* Invalid ID for VOL connector ID */ +#define H5_VOL_NATIVE 0 /* Native HDF5 file format VOL connector */ +#define H5_VOL_RESERVED 256 /* VOL connector IDs below this value are reserved for library use */ +#define H5_VOL_MAX 65535 /* Maximum VOL connector ID */ /*******************/ /* Public Typedefs */ /*******************/ - /* * VOL connector identifiers. Values 0 through 255 are for connectors defined * by the HDF5 library. Values 256 through 511 are available for testing new @@ -47,23 +45,22 @@ */ typedef int H5VL_class_value_t; - /* Enum type for each VOL subclass */ /* (Used for various queries, etc) */ typedef enum H5VL_subclass_t { - H5VL_SUBCLS_NONE, /* Operations outside of a subclass */ - H5VL_SUBCLS_INFO, /* 'Info' subclass */ - H5VL_SUBCLS_WRAP, /* 'Wrap' subclass */ - H5VL_SUBCLS_ATTR, /* 'Attribute' subclass */ - H5VL_SUBCLS_DATASET, /* 'Dataset' subclass */ - H5VL_SUBCLS_DATATYPE, /* 'Named datatype' subclass */ - H5VL_SUBCLS_FILE, /* 'File' subclass */ - H5VL_SUBCLS_GROUP, /* 'Group' subclass */ - H5VL_SUBCLS_LINK, /* 'Link' subclass */ - H5VL_SUBCLS_OBJECT, /* 'Object' subclass */ - H5VL_SUBCLS_REQUEST, /* 'Request' subclass */ - H5VL_SUBCLS_BLOB, /* 'Blob' subclass */ - H5VL_SUBCLS_TOKEN /* 'Token' subclass */ + H5VL_SUBCLS_NONE, /* Operations outside of a subclass */ + H5VL_SUBCLS_INFO, /* 'Info' subclass */ + H5VL_SUBCLS_WRAP, /* 'Wrap' subclass */ + H5VL_SUBCLS_ATTR, /* 'Attribute' subclass */ + H5VL_SUBCLS_DATASET, /* 'Dataset' subclass */ + H5VL_SUBCLS_DATATYPE, /* 'Named datatype' subclass */ + H5VL_SUBCLS_FILE, /* 'File' subclass */ + H5VL_SUBCLS_GROUP, /* 'Group' subclass */ + H5VL_SUBCLS_LINK, /* 'Link' subclass */ + H5VL_SUBCLS_OBJECT, /* 'Object' subclass */ + H5VL_SUBCLS_REQUEST, /* 'Request' subclass */ + H5VL_SUBCLS_BLOB, /* 'Blob' subclass */ + H5VL_SUBCLS_TOKEN /* 'Token' subclass */ } H5VL_subclass_t; /********************/ @@ -78,26 +75,25 @@ typedef enum H5VL_subclass_t { extern "C" { #endif -H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id); -H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id); -H5_DLL htri_t H5VLis_connector_registered_by_name(const char *name); -H5_DLL htri_t H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value); -H5_DLL hid_t H5VLget_connector_id(hid_t obj_id); -H5_DLL hid_t H5VLget_connector_id_by_name(const char *name); -H5_DLL hid_t H5VLget_connector_id_by_value(H5VL_class_value_t connector_value); -H5_DLL ssize_t H5VLget_connector_name(hid_t id, char *name/*out*/, size_t size); -H5_DLL herr_t H5VLclose(hid_t connector_id); -H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); -H5_DLL herr_t H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, hbool_t *supported); +H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id); +H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id); +H5_DLL htri_t H5VLis_connector_registered_by_name(const char *name); +H5_DLL htri_t H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value); +H5_DLL hid_t H5VLget_connector_id(hid_t obj_id); +H5_DLL hid_t H5VLget_connector_id_by_name(const char *name); +H5_DLL hid_t H5VLget_connector_id_by_value(H5VL_class_value_t connector_value); +H5_DLL ssize_t H5VLget_connector_name(hid_t id, char *name /*out*/, size_t size); +H5_DLL herr_t H5VLclose(hid_t connector_id); +H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); +H5_DLL herr_t H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, hbool_t *supported); #ifdef __cplusplus } #endif /* Semi-public headers mainly for VOL connector authors */ -#include "H5VLconnector.h" /* VOL connector author routines */ -#include "H5VLconnector_passthru.h" /* Pass-through VOL connector author routines */ -#include "H5VLnative.h" /* Native VOL connector macros, for VOL connector authors */ +#include "H5VLconnector.h" /* VOL connector author routines */ +#include "H5VLconnector_passthru.h" /* Pass-through VOL connector author routines */ +#include "H5VLnative.h" /* Native VOL connector macros, for VOL connector authors */ #endif /* _H5VLpublic_H */ - diff --git a/src/H5VM.c b/src/H5VM.c index d12bea6..ea81f06 100644 --- a/src/H5VM.c +++ b/src/H5VM.c @@ -16,37 +16,32 @@ * Friday, October 10, 1997 */ - #include "H5private.h" #include "H5Eprivate.h" -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" #include "H5VMprivate.h" /* Local typedefs */ typedef struct H5VM_memcpy_ud_t { - unsigned char *dst; /* Pointer to destination buffer */ - const unsigned char *src; /* Pointer to source buffer */ + unsigned char * dst; /* Pointer to destination buffer */ + const unsigned char *src; /* Pointer to source buffer */ } H5VM_memcpy_ud_t; /* Local macros */ #define H5VM_HYPER_NDIMS H5O_LAYOUT_NDIMS /* Local prototypes */ -static void -H5VM_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - const hsize_t *size, hsize_t *stride1); -static void -H5VM_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - const hsize_t *size, hsize_t *stride1, hsize_t *stride2); +static void H5VM_stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size, + hsize_t *stride1); +static void H5VM_stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size, + hsize_t *stride1, hsize_t *stride2); #ifdef LATER -static void -H5VM_stride_copy2(hsize_t nelmts, hsize_t elmt_size, - unsigned dst_n, const hsize_t *dst_size, const ssize_t *dst_stride, void *_dst, - unsigned src_n, const hsize_t *src_size, const ssize_t *src_stride, const void *_src); +static void H5VM_stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, const hsize_t *dst_size, + const ssize_t *dst_stride, void *_dst, unsigned src_n, const hsize_t *src_size, + const ssize_t *src_stride, const void *_src); #endif /* LATER */ - /*------------------------------------------------------------------------- * Function: H5VM_stride_optimize1 * @@ -68,8 +63,8 @@ H5VM_stride_copy2(hsize_t nelmts, hsize_t elmt_size, *------------------------------------------------------------------------- */ static void -H5VM_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - const hsize_t *size, hsize_t *stride1) +H5VM_stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size, + hsize_t *stride1) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -82,17 +77,15 @@ H5VM_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, /* * Combine adjacent memory accesses */ - while (*np && stride1[*np-1]>0 && - (hsize_t)(stride1[*np-1])==*elmt_size) { - *elmt_size *= size[*np-1]; + while (*np && stride1[*np - 1] > 0 && (hsize_t)(stride1[*np - 1]) == *elmt_size) { + *elmt_size *= size[*np - 1]; if (--*np) - stride1[*np-1] += size[*np] * stride1[*np]; + stride1[*np - 1] += size[*np] * stride1[*np]; } FUNC_LEAVE_NOAPI_VOID } - /*------------------------------------------------------------------------- * Function: H5VM_stride_optimize2 * @@ -117,8 +110,8 @@ H5VM_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, *------------------------------------------------------------------------- */ static void -H5VM_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - const hsize_t *size, hsize_t *stride1, hsize_t *stride2) +H5VM_stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size, + hsize_t *stride1, hsize_t *stride2) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -127,92 +120,90 @@ H5VM_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, * zero we still must make one reference. */ HDassert(1 == H5VM_vector_reduce_product(0, NULL)); - HDassert(*elmt_size>0); + HDassert(*elmt_size > 0); /* * Combine adjacent memory accesses */ /* Unroll loop for common cases */ - switch(*np) { + switch (*np) { case 1: /* For 0-D datasets (dunno if this ever gets used...) */ - if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { + if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; - --*np; /* *np decrements to a value of 0 now */ - } /* end if */ + --*np; /* *np decrements to a value of 0 now */ + } /* end if */ break; case 2: /* For 1-D datasets */ - if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { + if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; - --*np; /* *np decrements to a value of 1 now */ + --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; - if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { + if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; - --*np; /* *np decrements to a value of 0 now */ - } /* end if */ - } /* end if */ + --*np; /* *np decrements to a value of 0 now */ + } /* end if */ + } /* end if */ break; case 3: /* For 2-D datasets */ - if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) { + if (stride1[2] == *elmt_size && stride2[2] == *elmt_size) { *elmt_size *= size[2]; - --*np; /* *np decrements to a value of 2 now */ + --*np; /* *np decrements to a value of 2 now */ stride1[1] += size[2] * stride1[2]; stride2[1] += size[2] * stride2[2]; - if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { + if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; - --*np; /* *np decrements to a value of 1 now */ + --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; - if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { + if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; - --*np; /* *np decrements to a value of 0 now */ - } /* end if */ - } /* end if */ - } /* end if */ + --*np; /* *np decrements to a value of 0 now */ + } /* end if */ + } /* end if */ + } /* end if */ break; case 4: /* For 3-D datasets */ - if(stride1[3] == *elmt_size && stride2[3] == *elmt_size) { + if (stride1[3] == *elmt_size && stride2[3] == *elmt_size) { *elmt_size *= size[3]; - --*np; /* *np decrements to a value of 3 now */ + --*np; /* *np decrements to a value of 3 now */ stride1[2] += size[3] * stride1[3]; stride2[2] += size[3] * stride2[3]; - if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) { + if (stride1[2] == *elmt_size && stride2[2] == *elmt_size) { *elmt_size *= size[2]; - --*np; /* *np decrements to a value of 2 now */ + --*np; /* *np decrements to a value of 2 now */ stride1[1] += size[2] * stride1[2]; stride2[1] += size[2] * stride2[2]; - if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { + if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; - --*np; /* *np decrements to a value of 1 now */ + --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; - if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { + if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; - --*np; /* *np decrements to a value of 0 now */ - } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ + --*np; /* *np decrements to a value of 0 now */ + } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ break; default: - while (*np && - stride1[*np-1] == *elmt_size && - stride2[*np-1] == *elmt_size) { - *elmt_size *= size[*np-1]; + while (*np && stride1[*np - 1] == *elmt_size && stride2[*np - 1] == *elmt_size) { + *elmt_size *= size[*np - 1]; if (--*np) { - stride1[*np-1] += size[*np] * stride1[*np]; - stride2[*np-1] += size[*np] * stride2[*np]; + stride1[*np - 1] += size[*np] * stride1[*np]; + stride2[*np - 1] += size[*np] * stride2[*np]; } } break; @@ -221,7 +212,6 @@ H5VM_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, FUNC_LEAVE_NOAPI_VOID } - /*------------------------------------------------------------------------- * Function: H5VM_hyper_stride * @@ -255,14 +245,13 @@ H5VM_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, *------------------------------------------------------------------------- */ hsize_t -H5VM_hyper_stride(unsigned n, const hsize_t *size, - const hsize_t *total_size, const hsize_t *offset, - hsize_t *stride/*out*/) +H5VM_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, const hsize_t *offset, + hsize_t *stride /*out*/) { - hsize_t skip; /*starting point byte offset */ - hsize_t acc; /*accumulator */ - int i; /*counter */ - hsize_t ret_value; /* Return value */ + hsize_t skip; /*starting point byte offset */ + hsize_t acc; /*accumulator */ + int i; /*counter */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -272,42 +261,42 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size, HDassert(stride); /* init */ - HDassert(n>0); - stride[n-1] = 1; - skip = offset ? offset[n-1] : 0; + HDassert(n > 0); + stride[n - 1] = 1; + skip = offset ? offset[n - 1] : 0; - switch(n) { + switch (n) { case 2: /* 1-D dataset */ - HDassert(total_size[1]>=size[1]); - stride[0] = total_size[1]-size[1]; /*overflow checked*/ - acc = total_size[1]; + HDassert(total_size[1] >= size[1]); + stride[0] = total_size[1] - size[1]; /*overflow checked*/ + acc = total_size[1]; skip += acc * (offset ? offset[0] : 0); break; case 3: /* 2-D dataset */ - HDassert(total_size[2]>=size[2]); - stride[1] = total_size[2]-size[2]; /*overflow checked*/ - acc = total_size[2]; + HDassert(total_size[2] >= size[2]); + stride[1] = total_size[2] - size[2]; /*overflow checked*/ + acc = total_size[2]; skip += acc * (offset ? (hsize_t)offset[1] : 0); - HDassert(total_size[1]>=size[1]); + HDassert(total_size[1] >= size[1]); stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/ acc *= total_size[1]; skip += acc * (offset ? (hsize_t)offset[0] : 0); break; case 4: /* 3-D dataset */ - HDassert(total_size[3]>=size[3]); - stride[2] = total_size[3]-size[3]; /*overflow checked*/ - acc = total_size[3]; + HDassert(total_size[3] >= size[3]); + stride[2] = total_size[3] - size[3]; /*overflow checked*/ + acc = total_size[3]; skip += acc * (offset ? (hsize_t)offset[2] : 0); - HDassert(total_size[2]>=size[2]); + HDassert(total_size[2] >= size[2]); stride[1] = acc * (total_size[2] - size[2]); /*overflow checked*/ acc *= total_size[2]; skip += acc * (offset ? (hsize_t)offset[1] : 0); - HDassert(total_size[1]>=size[1]); + HDassert(total_size[1] >= size[1]); stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/ acc *= total_size[1]; skip += acc * (offset ? (hsize_t)offset[0] : 0); @@ -315,22 +304,21 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size, default: /* others */ - for (i=(int)(n-2), acc=1; i>=0; --i) { - HDassert(total_size[i+1]>=size[i+1]); - stride[i] = acc * (total_size[i+1] - size[i+1]); /*overflow checked*/ - acc *= total_size[i+1]; + for (i = (int)(n - 2), acc = 1; i >= 0; --i) { + HDassert(total_size[i + 1] >= size[i + 1]); + stride[i] = acc * (total_size[i + 1] - size[i + 1]); /*overflow checked*/ + acc *= total_size[i + 1]; skip += acc * (offset ? (hsize_t)offset[i] : 0); } break; } /* end switch */ /* Set return value */ - ret_value=skip; + ret_value = skip; FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5VM_hyper_eq * @@ -355,27 +343,27 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size, *------------------------------------------------------------------------- */ htri_t -H5VM_hyper_eq(unsigned n, - const hsize_t *offset1, const hsize_t *size1, - const hsize_t *offset2, const hsize_t *size2) +H5VM_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hsize_t *offset2, + const hsize_t *size2) { - hsize_t nelmts1 = 1, nelmts2 = 1; - unsigned i; - htri_t ret_value=TRUE; /* Return value */ + hsize_t nelmts1 = 1, nelmts2 = 1; + unsigned i; + htri_t ret_value = TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if (n == 0) HGOTO_DONE(TRUE) + if (n == 0) + HGOTO_DONE(TRUE) - for (i=0; i0); - dst_stride[n-1] = 1; - src_stride[n-1] = 1; - dst_start = dst_offset ? dst_offset[n-1] : 0; - src_start = src_offset ? src_offset[n-1] : 0; + HDassert(n > 0); + dst_stride[n - 1] = 1; + src_stride[n - 1] = 1; + dst_start = dst_offset ? dst_offset[n - 1] : 0; + src_start = src_offset ? src_offset[n - 1] : 0; /* Unroll loop for common cases */ - switch(n) { + switch (n) { case 2: - HDassert(dst_size[1]>=size[1]); - HDassert(src_size[1]>=size[1]); + HDassert(dst_size[1] >= size[1]); + HDassert(src_size[1] >= size[1]); dst_stride[0] = dst_size[1] - size[1]; /*overflow checked*/ src_stride[0] = src_size[1] - size[1]; /*overflow checked*/ - dst_acc = dst_size[1]; - src_acc = src_size[1]; + dst_acc = dst_size[1]; + src_acc = src_size[1]; dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0); src_start += src_acc * (src_offset ? src_offset[0] : 0); break; case 3: - HDassert(dst_size[2]>=size[2]); - HDassert(src_size[2]>=size[2]); + HDassert(dst_size[2] >= size[2]); + HDassert(src_size[2] >= size[2]); dst_stride[1] = dst_size[2] - size[2]; /*overflow checked*/ src_stride[1] = src_size[2] - size[2]; /*overflow checked*/ - dst_acc = dst_size[2]; - src_acc = src_size[2]; + dst_acc = dst_size[2]; + src_acc = src_size[2]; dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); src_start += src_acc * (src_offset ? src_offset[1] : 0); - HDassert(dst_size[1]>=size[1]); - HDassert(src_size[1]>=size[1]); + HDassert(dst_size[1] >= size[1]); + HDassert(src_size[1] >= size[1]); dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/ src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/ dst_acc *= dst_size[1]; @@ -578,17 +560,17 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, break; case 4: - HDassert(dst_size[3]>=size[3]); - HDassert(src_size[3]>=size[3]); + HDassert(dst_size[3] >= size[3]); + HDassert(src_size[3] >= size[3]); dst_stride[2] = dst_size[3] - size[3]; /*overflow checked*/ src_stride[2] = src_size[3] - size[3]; /*overflow checked*/ - dst_acc = dst_size[3]; - src_acc = src_size[3]; + dst_acc = dst_size[3]; + src_acc = src_size[3]; dst_start += dst_acc * (dst_offset ? dst_offset[2] : 0); src_start += src_acc * (src_offset ? src_offset[2] : 0); - HDassert(dst_size[2]>=size[2]); - HDassert(src_size[2]>=size[2]); + HDassert(dst_size[2] >= size[2]); + HDassert(src_size[2] >= size[2]); dst_stride[1] = dst_acc * (dst_size[2] - size[2]); /*overflow checked*/ src_stride[1] = src_acc * (src_size[2] - size[2]); /*overflow checked*/ dst_acc *= dst_size[2]; @@ -596,8 +578,8 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); src_start += src_acc * (src_offset ? src_offset[1] : 0); - HDassert(dst_size[1]>=size[1]); - HDassert(src_size[1]>=size[1]); + HDassert(dst_size[1] >= size[1]); + HDassert(src_size[1] >= size[1]); dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/ src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/ dst_acc *= dst_size[1]; @@ -608,13 +590,13 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, default: /* others */ - for (ii=(int)(n-2), dst_acc=1, src_acc=1; ii>=0; --ii) { - HDassert(dst_size[ii+1]>=size[ii+1]); - HDassert(src_size[ii+1]>=size[ii+1]); - dst_stride[ii] = dst_acc * (dst_size[ii+1] - size[ii+1]); /*overflow checked*/ - src_stride[ii] = src_acc * (src_size[ii+1] - size[ii+1]); /*overflow checked*/ - dst_acc *= dst_size[ii+1]; - src_acc *= src_size[ii+1]; + for (ii = (int)(n - 2), dst_acc = 1, src_acc = 1; ii >= 0; --ii) { + HDassert(dst_size[ii + 1] >= size[ii + 1]); + HDassert(src_size[ii + 1] >= size[ii + 1]); + dst_stride[ii] = dst_acc * (dst_size[ii + 1] - size[ii + 1]); /*overflow checked*/ + src_stride[ii] = src_acc * (src_size[ii + 1] - size[ii + 1]); /*overflow checked*/ + dst_acc *= dst_size[ii + 1]; + src_acc *= src_size[ii + 1]; dst_start += dst_acc * (dst_offset ? dst_offset[ii] : 0); src_start += src_acc * (src_offset ? src_offset[ii] : 0); } @@ -627,13 +609,12 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, H5VM_stride_optimize2(&n, &elmt_size, size, dst_stride, src_stride); /* Perform the copy in terms of stride */ - ret_value = H5VM_stride_copy(n, elmt_size, size, - dst_stride, dst+dst_start, src_stride, src+src_start); + ret_value = + H5VM_stride_copy(n, elmt_size, size, dst_stride, dst + dst_start, src_stride, src + src_start); FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5VM_stride_fill * @@ -650,15 +631,15 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, *------------------------------------------------------------------------- */ herr_t -H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, - const hsize_t *stride, void *_dst, unsigned fill_value) +H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *stride, void *_dst, + unsigned fill_value) { - uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */ - hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ - hsize_t nelmts; /*number of elements to fill */ - hsize_t i; /*counter */ - int j; /*counter */ - hbool_t carry; /*subtraction carray value */ + uint8_t *dst = (uint8_t *)_dst; /*cast for ptr arithmetic */ + hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ + hsize_t nelmts; /*number of elements to fill */ + hsize_t i; /*counter */ + int j; /*counter */ + hbool_t carry; /*subtraction carray value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -666,13 +647,13 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, H5VM_vector_cpy(n, idx, size); nelmts = H5VM_vector_reduce_product(n, size); - for (i=0; i=0 && carry; --j) { + for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) { dst += stride[j]; if (--idx[j]) @@ -687,7 +668,6 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- * Function: H5VM_stride_copy * @@ -710,33 +690,32 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, *------------------------------------------------------------------------- */ herr_t -H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, - const hsize_t *dst_stride, void *_dst, - const hsize_t *src_stride, const void *_src) +H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *dst_stride, void *_dst, + const hsize_t *src_stride, const void *_src) { - uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/ - const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/ - hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ - hsize_t nelmts; /*num elements to copy */ - hsize_t i; /*counter */ - int j; /*counters */ - hbool_t carry; /*carray for subtraction*/ + uint8_t * dst = (uint8_t *)_dst; /*cast for ptr arithmetic*/ + const uint8_t *src = (const uint8_t *)_src; /*cast for ptr arithmetic*/ + hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ + hsize_t nelmts; /*num elements to copy */ + hsize_t i; /*counter */ + int j; /*counters */ + hbool_t carry; /*carray for subtraction*/ FUNC_ENTER_NOAPI_NOINIT_NOERR - HDassert(elmt_size=0 && carry; --j) { + for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) { src += src_stride[j]; dst += dst_stride[j]; @@ -748,15 +727,15 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, } } } - } else { - H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); - H5MM_memcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ + } + else { + H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t); + H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ } FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- * Function: H5VM_stride_copy_s * @@ -779,33 +758,32 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, *------------------------------------------------------------------------- */ herr_t -H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, - const hssize_t *dst_stride, void *_dst, - const hssize_t *src_stride, const void *_src) +H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, const hssize_t *dst_stride, void *_dst, + const hssize_t *src_stride, const void *_src) { - uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/ - const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/ - hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ - hsize_t nelmts; /*num elements to copy */ - hsize_t i; /*counter */ - int j; /*counters */ - hbool_t carry; /*carray for subtraction*/ + uint8_t * dst = (uint8_t *)_dst; /*cast for ptr arithmetic*/ + const uint8_t *src = (const uint8_t *)_src; /*cast for ptr arithmetic*/ + hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ + hsize_t nelmts; /*num elements to copy */ + hsize_t i; /*counter */ + int j; /*counters */ + hbool_t carry; /*carray for subtraction*/ FUNC_ENTER_NOAPI_NOINIT_NOERR - HDassert(elmt_size=0 && carry; --j) { + for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) { src += src_stride[j]; dst += dst_stride[j]; @@ -817,16 +795,17 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, } } } - } else { - H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); - H5MM_memcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ + } + else { + H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t); + H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ } FUNC_LEAVE_NOAPI(SUCCEED) } #ifdef LATER - + /*------------------------------------------------------------------------- * Function: H5VM_stride_copy2 * @@ -847,65 +826,60 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, static void H5VM_stride_copy2(hsize_t nelmts, hsize_t elmt_size, - /* destination */ - unsigned dst_n, const hsize_t *dst_size, - const hsize_t *dst_stride, - void *_dst, + /* destination */ + unsigned dst_n, const hsize_t *dst_size, const hsize_t *dst_stride, void *_dst, - /* source */ - unsigned src_n, const hsize_t *src_size, - const hsize_t *src_stride, - const void *_src) + /* source */ + unsigned src_n, const hsize_t *src_size, const hsize_t *src_stride, const void *_src) { - uint8_t *dst = (uint8_t *) _dst; - const uint8_t *src = (const uint8_t *) _src; - hsize_t dst_idx[H5VM_HYPER_NDIMS]; - hsize_t src_idx[H5VM_HYPER_NDIMS]; - hsize_t i; /* Local index variable */ - int j; /* Local index variable */ - hbool_t carry; + uint8_t * dst = (uint8_t *)_dst; + const uint8_t *src = (const uint8_t *)_src; + hsize_t dst_idx[H5VM_HYPER_NDIMS]; + hsize_t src_idx[H5VM_HYPER_NDIMS]; + hsize_t i; /* Local index variable */ + int j; /* Local index variable */ + hbool_t carry; FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(elmt_size < SIZET_MAX); - HDassert(dst_n>0); - HDassert(src_n>0); + HDassert(dst_n > 0); + HDassert(src_n > 0); H5VM_vector_cpy(dst_n, dst_idx, dst_size); H5VM_vector_cpy(src_n, src_idx, src_size); - for (i=0; i=0 && carry; --j) { - dst += dst_stride[j]; - if (--dst_idx[j]) + /* Decrement indices and advance pointers */ + for (j = (int)(dst_n - 1), carry = TRUE; j >= 0 && carry; --j) { + dst += dst_stride[j]; + if (--dst_idx[j]) carry = FALSE; - else { + else { HDassert(dst_size); dst_idx[j] = dst_size[j]; } /* end else */ - } - for (j=(int)(src_n-1), carry=TRUE; j>=0 && carry; --j) { - src += src_stride[j]; - if (--src_idx[j]) + } + for (j = (int)(src_n - 1), carry = TRUE; j >= 0 && carry; --j) { + src += src_stride[j]; + if (--src_idx[j]) carry = FALSE; - else { + else { HDassert(src_size); src_idx[j] = src_size[j]; } /* end else */ - } + } } FUNC_LEAVE_NOAPI_VOID } #endif /* LATER */ - /*------------------------------------------------------------------------- * Function: H5VM_array_fill * @@ -925,10 +899,10 @@ H5VM_stride_copy2(hsize_t nelmts, hsize_t elmt_size, herr_t H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count) { - size_t copy_size; /* size of the buffer to copy */ - size_t copy_items; /* number of items currently copying*/ - size_t items_left; /* number of items left to copy */ - uint8_t *dst=(uint8_t*)_dst;/* alias for pointer arithmetic */ + size_t copy_size; /* size of the buffer to copy */ + size_t copy_items; /* number of items currently copying*/ + size_t items_left; /* number of items left to copy */ + uint8_t *dst = (uint8_t *)_dst; /* alias for pointer arithmetic */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -937,31 +911,29 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count) HDassert(size < SIZET_MAX && size > 0); HDassert(count < SIZET_MAX && count > 0); - H5MM_memcpy(dst, src, size); /* copy first item */ + H5MM_memcpy(dst, src, size); /* copy first item */ /* Initialize counters, etc. while compensating for first element copied */ - copy_size = size; + copy_size = size; copy_items = 1; items_left = count - 1; dst += size; /* copy until we've copied at least half of the items */ - while (items_left >= copy_items) - { - H5MM_memcpy(dst, _dst, copy_size); /* copy the current chunk */ - dst += copy_size; /* move the offset for the next chunk */ - items_left -= copy_items; /* decrement the number of items left */ - - copy_size *= 2; /* increase the size of the chunk to copy */ - copy_items *= 2; /* increase the count of items we are copying */ - } /* end while */ - if (items_left > 0) /* if there are any items left to copy */ + while (items_left >= copy_items) { + H5MM_memcpy(dst, _dst, copy_size); /* copy the current chunk */ + dst += copy_size; /* move the offset for the next chunk */ + items_left -= copy_items; /* decrement the number of items left */ + + copy_size *= 2; /* increase the size of the chunk to copy */ + copy_items *= 2; /* increase the count of items we are copying */ + } /* end while */ + if (items_left > 0) /* if there are any items left to copy */ H5MM_memcpy(dst, _dst, items_left * size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5VM_array_fill() */ +} /* H5VM_array_fill() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_down * @@ -982,8 +954,8 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count) herr_t H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) { - hsize_t acc; /*accumulator */ - int i; /*counter */ + hsize_t acc; /*accumulator */ + int i; /*counter */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -993,15 +965,14 @@ H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) /* Build the sizes of each dimension in the array */ /* (From fastest to slowest) */ - for(i=(int)(n-1),acc=1; i>=0; i--) { - down[i]=acc; + for (i = (int)(n - 1), acc = 1; i >= 0; i--) { + down[i] = acc; acc *= total_size[i]; } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VM_array_down() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_offset_pre * @@ -1023,8 +994,8 @@ H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) hsize_t H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) { - unsigned u; /* Local index variable */ - hsize_t ret_value; /* Return value */ + unsigned u; /* Local index variable */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1033,13 +1004,12 @@ H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) HDassert(offset); /* Compute offset in array */ - for(u = 0, ret_value = 0; u < n; u++) + for (u = 0, ret_value = 0; u < n; u++) ret_value += acc[u] * offset[u]; FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_array_offset_pre() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_offset * @@ -1063,8 +1033,8 @@ H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) hsize_t H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset) { - hsize_t acc_arr[H5VM_HYPER_NDIMS]; /* Accumulated size of down dimensions */ - hsize_t ret_value; /* Return value */ + hsize_t acc_arr[H5VM_HYPER_NDIMS]; /* Accumulated size of down dimensions */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI((HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */ @@ -1073,17 +1043,16 @@ H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset) HDassert(offset); /* Build the sizes of each dimension in the array */ - if(H5VM_array_down(n,total_size,acc_arr)<0) + if (H5VM_array_down(n, total_size, acc_arr) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, UFAIL, "can't compute down sizes") /* Set return value */ - ret_value=H5VM_array_offset_pre(n,acc_arr,offset); + ret_value = H5VM_array_offset_pre(n, acc_arr, offset); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_array_offset() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_calc_pre * @@ -1103,10 +1072,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, - hsize_t *coords) +H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, hsize_t *coords) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1115,7 +1083,7 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, HDassert(coords); /* Compute the coordinates from the offset */ - for(u = 0; u < n; u++) { + for (u = 0; u < n; u++) { coords[u] = offset / down[u]; offset %= down[u]; } /* end for */ @@ -1123,7 +1091,6 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VM_array_calc_pre() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_calc * @@ -1147,8 +1114,8 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, herr_t H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords) { - hsize_t idx[H5VM_HYPER_NDIMS]; /* Size of each dimension in bytes */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t idx[H5VM_HYPER_NDIMS]; /* Size of each dimension in bytes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1158,18 +1125,17 @@ H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t * HDassert(coords); /* Build the sizes of each dimension in the array */ - if(H5VM_array_down(n, total_size, idx) < 0) + if (H5VM_array_down(n, total_size, idx) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute down sizes") /* Compute the coordinates from the offset */ - if(H5VM_array_calc_pre(offset, n, idx, coords) < 0) + if (H5VM_array_calc_pre(offset, n, idx, coords) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute coordinates") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_array_calc() */ - /*------------------------------------------------------------------------- * Function: H5VM_chunk_index * @@ -1211,11 +1177,10 @@ done: *------------------------------------------------------------------------- */ hsize_t -H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, - const hsize_t *down_nchunks) +H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, const hsize_t *down_nchunks) { - hsize_t scaled_coord[H5VM_HYPER_NDIMS]; /* Scaled, coordinates, in terms of chunks */ - hsize_t chunk_idx; /* Chunk index computed */ + hsize_t scaled_coord[H5VM_HYPER_NDIMS]; /* Scaled, coordinates, in terms of chunks */ + hsize_t chunk_idx; /* Chunk index computed */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1231,7 +1196,6 @@ H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, FUNC_LEAVE_NOAPI(chunk_idx) } /* end H5VM_chunk_index() */ - /*------------------------------------------------------------------------- * Function: H5VM_chunk_scaled * @@ -1245,10 +1209,9 @@ H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, *------------------------------------------------------------------------- */ void -H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, - hsize_t *scaled) +H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, hsize_t *scaled) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1260,13 +1223,12 @@ H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, /* Compute the scaled coordinates for actual coordinates */ /* (Note that the 'scaled' array is an 'OUT' parameter) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) scaled[u] = coord[u] / chunk[u]; FUNC_LEAVE_NOAPI_VOID } /* end H5VM_chunk_scaled() */ - /*------------------------------------------------------------------------- * Function: H5VM_chunk_index_scaled * @@ -1312,10 +1274,10 @@ H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, */ hsize_t H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, - const hsize_t *down_nchunks, hsize_t *scaled) + const hsize_t *down_nchunks, hsize_t *scaled) { - hsize_t chunk_idx; /* Computed chunk index */ - unsigned u; /* Local index variable */ + hsize_t chunk_idx; /* Computed chunk index */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1328,16 +1290,16 @@ H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *ch /* Compute the scaled coordinates for actual coordinates */ /* (Note that the 'scaled' array is an 'OUT' parameter) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) scaled[u] = coord[u] / chunk[u]; /* Compute the chunk index */ - chunk_idx = H5VM_array_offset_pre(ndims, down_nchunks, scaled); /*lint !e772 scaled_coord will always be initialized */ + chunk_idx = H5VM_array_offset_pre(ndims, down_nchunks, + scaled); /*lint !e772 scaled_coord will always be initialized */ FUNC_LEAVE_NOAPI(chunk_idx) } /* end H5VM_chunk_index_scaled() */ - /*------------------------------------------------------------------------- * Function: H5VM_opvv * @@ -1361,19 +1323,17 @@ H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *ch *------------------------------------------------------------------------- */ ssize_t -H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], - hsize_t dst_off_arr[], - size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], - hsize_t src_off_arr[], - H5VM_opvv_func_t op, void *op_data) +H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[], + size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[], + H5VM_opvv_func_t op, void *op_data) { - hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */ - hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */ - size_t *dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */ - hsize_t tmp_dst_off, tmp_src_off; /* Temporary source and destination offset values */ - size_t tmp_dst_len, tmp_src_len; /* Temporary source and destination length values */ - size_t acc_len; /* Accumulated length of sequences */ - ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */ + hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */ + hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */ + size_t * dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */ + hsize_t tmp_dst_off, tmp_src_off; /* Temporary source and destination offset values */ + size_t tmp_dst_len, tmp_src_len; /* Temporary source and destination length values */ + size_t acc_len; /* Accumulated length of sequences */ + ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_NOAPI(FAIL) @@ -1404,16 +1364,16 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], max_dst_off_ptr = dst_off_arr + dst_max_nseq; max_src_off_ptr = src_off_arr + src_max_nseq; -/* Work through the sequences */ -/* (Choose smallest sequence available initially) */ + /* Work through the sequences */ + /* (Choose smallest sequence available initially) */ /* Source sequence is less than destination sequence */ - if(tmp_src_len < tmp_dst_len) { + if (tmp_src_len < tmp_dst_len) { src_smaller: acc_len = 0; do { /* Make operator callback */ - if((*op)(tmp_dst_off, tmp_src_off, tmp_src_len, op_data) < 0) + if ((*op)(tmp_dst_off, tmp_src_off, tmp_src_len, op_data) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation") /* Accumulate number of bytes copied */ @@ -1425,7 +1385,7 @@ src_smaller: /* Advance source offset & check for being finished */ src_off_ptr++; - if(src_off_ptr >= max_src_off_ptr) { + if (src_off_ptr >= max_src_off_ptr) { /* Roll accumulated changes into appropriate counters */ *dst_off_ptr = tmp_dst_off; *dst_len_ptr = tmp_dst_len; @@ -1438,24 +1398,24 @@ src_smaller: /* Update source information */ src_len_ptr++; tmp_src_len = *src_len_ptr; - } while(tmp_src_len < tmp_dst_len); + } while (tmp_src_len < tmp_dst_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_dst_len < tmp_src_len) + if (tmp_dst_len < tmp_src_len) goto dst_smaller; else goto equal; } /* end if */ /* Destination sequence is less than source sequence */ - else if(tmp_dst_len < tmp_src_len) { + else if (tmp_dst_len < tmp_src_len) { dst_smaller: acc_len = 0; do { /* Make operator callback */ - if((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0) + if ((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation") /* Accumulate number of bytes copied */ @@ -1467,7 +1427,7 @@ dst_smaller: /* Advance destination offset & check for being finished */ dst_off_ptr++; - if(dst_off_ptr >= max_dst_off_ptr) { + if (dst_off_ptr >= max_dst_off_ptr) { /* Roll accumulated changes into appropriate counters */ *src_off_ptr = tmp_src_off; *src_len_ptr = tmp_src_len; @@ -1480,13 +1440,13 @@ dst_smaller: /* Update destination information */ dst_len_ptr++; tmp_dst_len = *dst_len_ptr; - } while(tmp_dst_len < tmp_src_len); + } while (tmp_dst_len < tmp_src_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_src_len < tmp_dst_len) + if (tmp_src_len < tmp_dst_len) goto src_smaller; else goto equal; @@ -1497,7 +1457,7 @@ equal: acc_len = 0; do { /* Make operator callback */ - if((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0) + if ((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation") /* Accumulate number of bytes copied */ @@ -1506,7 +1466,7 @@ equal: /* Advance source & destination offset & check for being finished */ src_off_ptr++; dst_off_ptr++; - if(src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr) + if (src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr) /* Done with sequences */ goto finished; tmp_src_off = *src_off_ptr; @@ -1519,13 +1479,13 @@ equal: /* Update destination information */ dst_len_ptr++; tmp_dst_len = *dst_len_ptr; - } while(tmp_dst_len == tmp_src_len); + } while (tmp_dst_len == tmp_src_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_dst_len < tmp_src_len) + if (tmp_dst_len < tmp_src_len) goto dst_smaller; else goto src_smaller; @@ -1543,7 +1503,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_opvv() */ - /*------------------------------------------------------------------------- * Function: H5VM_memcpyvv * @@ -1568,20 +1527,19 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5VM_memcpyvv(void *_dst, - size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[], - const void *_src, - size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[]) +H5VM_memcpyvv(void *_dst, size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], + hsize_t dst_off_arr[], const void *_src, size_t src_max_nseq, size_t *src_curr_seq, + size_t src_len_arr[], hsize_t src_off_arr[]) { - unsigned char *dst; /* Destination buffer pointer */ - const unsigned char *src; /* Source buffer pointer */ - hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */ - hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */ - size_t *dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */ - size_t tmp_dst_len; /* Temporary dest. length value */ - size_t tmp_src_len; /* Temporary source length value */ - size_t acc_len; /* Accumulated length of sequences */ - ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */ + unsigned char * dst; /* Destination buffer pointer */ + const unsigned char *src; /* Source buffer pointer */ + hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */ + hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */ + size_t * dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */ + size_t tmp_dst_len; /* Temporary dest. length value */ + size_t tmp_src_len; /* Temporary source length value */ + size_t acc_len; /* Accumulated length of sequences */ + ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1615,11 +1573,11 @@ H5VM_memcpyvv(void *_dst, dst = (unsigned char *)_dst + *dst_off_ptr; src = (const unsigned char *)_src + *src_off_ptr; -/* Work through the sequences */ -/* (Choose smallest sequence available initially) */ + /* Work through the sequences */ + /* (Choose smallest sequence available initially) */ /* Source sequence is less than destination sequence */ - if(tmp_src_len < tmp_dst_len) { + if (tmp_src_len < tmp_dst_len) { src_smaller: acc_len = 0; do { @@ -1634,7 +1592,7 @@ src_smaller: /* Advance source offset & check for being finished */ src_off_ptr++; - if(src_off_ptr >= max_src_off_ptr) { + if (src_off_ptr >= max_src_off_ptr) { /* Roll accumulated changes into appropriate counters */ *dst_off_ptr += acc_len; *dst_len_ptr = tmp_dst_len; @@ -1649,20 +1607,20 @@ src_smaller: /* Update source information */ src_len_ptr++; tmp_src_len = *src_len_ptr; - src = (const unsigned char *)_src + *src_off_ptr; - } while(tmp_src_len < tmp_dst_len); + src = (const unsigned char *)_src + *src_off_ptr; + } while (tmp_src_len < tmp_dst_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_dst_len < tmp_src_len) + if (tmp_dst_len < tmp_src_len) goto dst_smaller; else goto equal; } /* end if */ /* Destination sequence is less than source sequence */ - else if(tmp_dst_len < tmp_src_len) { + else if (tmp_dst_len < tmp_src_len) { dst_smaller: acc_len = 0; do { @@ -1677,7 +1635,7 @@ dst_smaller: /* Advance destination offset & check for being finished */ dst_off_ptr++; - if(dst_off_ptr >= max_dst_off_ptr) { + if (dst_off_ptr >= max_dst_off_ptr) { /* Roll accumulated changes into appropriate counters */ *src_off_ptr += acc_len; *src_len_ptr = tmp_src_len; @@ -1692,14 +1650,14 @@ dst_smaller: /* Update destination information */ dst_len_ptr++; tmp_dst_len = *dst_len_ptr; - dst = (unsigned char *)_dst + *dst_off_ptr; - } while(tmp_dst_len < tmp_src_len); + dst = (unsigned char *)_dst + *dst_off_ptr; + } while (tmp_dst_len < tmp_src_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_src_len < tmp_dst_len) + if (tmp_src_len < tmp_dst_len) goto src_smaller; else goto equal; @@ -1718,26 +1676,26 @@ equal: /* Advance source & destination offset & check for being finished */ src_off_ptr++; dst_off_ptr++; - if(src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr) + if (src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr) /* Done with sequences */ goto finished; /* Update source information */ src_len_ptr++; tmp_src_len = *src_len_ptr; - src = (const unsigned char *)_src + *src_off_ptr; + src = (const unsigned char *)_src + *src_off_ptr; /* Update destination information */ dst_len_ptr++; tmp_dst_len = *dst_len_ptr; - dst = (unsigned char *)_dst + *dst_off_ptr; - } while(tmp_dst_len == tmp_src_len); + dst = (unsigned char *)_dst + *dst_off_ptr; + } while (tmp_dst_len == tmp_src_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_dst_len < tmp_src_len) + if (tmp_dst_len < tmp_src_len) goto dst_smaller; else goto src_smaller; @@ -1753,4 +1711,3 @@ finished: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_memcpyvv() */ - diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h index 26f59e2..3c79370 100644 --- a/src/H5VMprivate.h +++ b/src/H5VMprivate.h @@ -19,124 +19,108 @@ #define H5VMprivate_H /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /* Vector-Vector sequence operation callback */ -typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off, - size_t len, void *udata); +typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off, size_t len, void *udata); /* Vector comparison functions like Fortran66 comparison operators */ -#define H5VM_vector_eq_s(N,V1,V2) (H5VM_vector_cmp_s (N, V1, V2)==0) -#define H5VM_vector_lt_s(N,V1,V2) (H5VM_vector_cmp_s (N, V1, V2)<0) -#define H5VM_vector_gt_s(N,V1,V2) (H5VM_vector_cmp_s (N, V1, V2)>0) -#define H5VM_vector_le_s(N,V1,V2) (H5VM_vector_cmp_s (N, V1, V2)<=0) -#define H5VM_vector_ge_s(N,V1,V2) (H5VM_vector_cmp_s (N, V1, V2)>=0) -#define H5VM_vector_eq_u(N,V1,V2) (H5VM_vector_cmp_u (N, V1, V2)==0) -#define H5VM_vector_lt_u(N,V1,V2) (H5VM_vector_cmp_u (N, V1, V2)<0) -#define H5VM_vector_gt_u(N,V1,V2) (H5VM_vector_cmp_u (N, V1, V2)>0) -#define H5VM_vector_le_u(N,V1,V2) (H5VM_vector_cmp_u (N, V1, V2)<=0) -#define H5VM_vector_ge_u(N,V1,V2) (H5VM_vector_cmp_u (N, V1, V2)>=0) +#define H5VM_vector_eq_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) == 0) +#define H5VM_vector_lt_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) < 0) +#define H5VM_vector_gt_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) > 0) +#define H5VM_vector_le_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) <= 0) +#define H5VM_vector_ge_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) >= 0) +#define H5VM_vector_eq_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) == 0) +#define H5VM_vector_lt_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) < 0) +#define H5VM_vector_gt_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) > 0) +#define H5VM_vector_le_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) <= 0) +#define H5VM_vector_ge_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) >= 0) /* Other functions */ -#define H5VM_vector_cpy(N,DST,SRC) { \ - HDassert(sizeof(*(DST))==sizeof(*(SRC))); \ - if (SRC) H5MM_memcpy (DST, SRC, (N)*sizeof(*(DST))); \ - else HDmemset (DST, 0, (N)*sizeof(*(DST))); \ -} +#define H5VM_vector_cpy(N, DST, SRC) \ + { \ + HDassert(sizeof(*(DST)) == sizeof(*(SRC))); \ + if (SRC) \ + H5MM_memcpy(DST, SRC, (N) * sizeof(*(DST))); \ + else \ + HDmemset(DST, 0, (N) * sizeof(*(DST))); \ + } -#define H5VM_vector_zero(N,DST) HDmemset(DST,0,(N)*sizeof(*(DST))) +#define H5VM_vector_zero(N, DST) HDmemset(DST, 0, (N) * sizeof(*(DST))) /* Given a coordinate offset array (COORDS) of type TYPE, move the unlimited * dimension (UNLIM_DIM) value to offset 0, sliding any intermediate values down * one position. */ -#define H5VM_swizzle_coords(TYPE,COORDS,UNLIM_DIM) { \ - /* COORDS must be an array of type TYPE */ \ - HDassert(sizeof(COORDS[0]) == sizeof(TYPE)); \ - \ - /* Nothing to do when unlimited dimension is at position 0 */ \ - if(0 != (UNLIM_DIM)) { \ - TYPE _tmp = (COORDS)[UNLIM_DIM]; \ - \ - HDmemmove(&(COORDS)[1], &(COORDS)[0], sizeof(TYPE) * (UNLIM_DIM)); \ - (COORDS)[0] = _tmp; \ - } /* end if */ \ -} +#define H5VM_swizzle_coords(TYPE, COORDS, UNLIM_DIM) \ + { \ + /* COORDS must be an array of type TYPE */ \ + HDassert(sizeof(COORDS[0]) == sizeof(TYPE)); \ + \ + /* Nothing to do when unlimited dimension is at position 0 */ \ + if (0 != (UNLIM_DIM)) { \ + TYPE _tmp = (COORDS)[UNLIM_DIM]; \ + \ + HDmemmove(&(COORDS)[1], &(COORDS)[0], sizeof(TYPE) * (UNLIM_DIM)); \ + (COORDS)[0] = _tmp; \ + } /* end if */ \ + } /* Given a coordinate offset array (COORDS) of type TYPE, move the value at * offset 0 to offset of the unlimied dimension (UNLIM_DIM), sliding any * intermediate values up one position. Undoes the "swizzle_coords" operation. */ -#define H5VM_unswizzle_coords(TYPE,COORDS,UNLIM_DIM) { \ - /* COORDS must be an array of type TYPE */ \ - HDassert(sizeof(COORDS[0]) == sizeof(TYPE)); \ - \ - /* Nothing to do when unlimited dimension is at position 0 */ \ - if(0 != (UNLIM_DIM)) { \ - TYPE _tmp = (COORDS)[0]; \ - \ - HDmemmove(&(COORDS)[0], &(COORDS)[1], sizeof(TYPE) * (UNLIM_DIM)); \ - (COORDS)[UNLIM_DIM] = _tmp; \ - } /* end if */ \ -} +#define H5VM_unswizzle_coords(TYPE, COORDS, UNLIM_DIM) \ + { \ + /* COORDS must be an array of type TYPE */ \ + HDassert(sizeof(COORDS[0]) == sizeof(TYPE)); \ + \ + /* Nothing to do when unlimited dimension is at position 0 */ \ + if (0 != (UNLIM_DIM)) { \ + TYPE _tmp = (COORDS)[0]; \ + \ + HDmemmove(&(COORDS)[0], &(COORDS)[1], sizeof(TYPE) * (UNLIM_DIM)); \ + (COORDS)[UNLIM_DIM] = _tmp; \ + } /* end if */ \ + } /* A null pointer is equivalent to a zero vector */ -#define H5VM_ZERO NULL - -H5_DLL hsize_t H5VM_hyper_stride(unsigned n, const hsize_t *size, - const hsize_t *total_size, - const hsize_t *offset, - hsize_t *stride); -H5_DLL htri_t H5VM_hyper_eq(unsigned n, const hsize_t *offset1, - const hsize_t *size1, const hsize_t *offset2, - const hsize_t *size2); -H5_DLL herr_t H5VM_hyper_fill(unsigned n, const hsize_t *_size, - const hsize_t *total_size, - const hsize_t *offset, void *_dst, - unsigned fill_value); -H5_DLL herr_t H5VM_hyper_copy(unsigned n, const hsize_t *size, - const hsize_t *dst_total_size, - const hsize_t *dst_offset, void *_dst, - const hsize_t *src_total_size, - const hsize_t *src_offset, const void *_src); -H5_DLL herr_t H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, - const hsize_t *stride, void *_dst, - unsigned fill_value); -H5_DLL herr_t H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *_size, - const hsize_t *dst_stride, void *_dst, - const hsize_t *src_stride, const void *_src); +#define H5VM_ZERO NULL + +H5_DLL hsize_t H5VM_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, + const hsize_t *offset, hsize_t *stride); +H5_DLL htri_t H5VM_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hsize_t *offset2, + const hsize_t *size2); +H5_DLL herr_t H5VM_hyper_fill(unsigned n, const hsize_t *_size, const hsize_t *total_size, + const hsize_t *offset, void *_dst, unsigned fill_value); +H5_DLL herr_t H5VM_hyper_copy(unsigned n, const hsize_t *size, const hsize_t *dst_total_size, + const hsize_t *dst_offset, void *_dst, const hsize_t *src_total_size, + const hsize_t *src_offset, const void *_src); +H5_DLL herr_t H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *stride, + void *_dst, unsigned fill_value); +H5_DLL herr_t H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *_size, const hsize_t *dst_stride, + void *_dst, const hsize_t *src_stride, const void *_src); H5_DLL herr_t H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *_size, - const hssize_t *dst_stride, void *_dst, - const hssize_t *src_stride, const void *_src); -H5_DLL herr_t H5VM_array_fill(void *_dst, const void *src, size_t size, - size_t count); -H5_DLL herr_t H5VM_array_down(unsigned n, const hsize_t *total_size, - hsize_t *down); -H5_DLL hsize_t H5VM_array_offset_pre(unsigned n, - const hsize_t *acc, const hsize_t *offset); -H5_DLL hsize_t H5VM_array_offset(unsigned n, const hsize_t *total_size, - const hsize_t *offset); -H5_DLL herr_t H5VM_array_calc_pre(hsize_t offset, unsigned n, - const hsize_t *down, hsize_t *coords); -H5_DLL herr_t H5VM_array_calc(hsize_t offset, unsigned n, - const hsize_t *total_size, hsize_t *coords); -H5_DLL hsize_t H5VM_chunk_index(unsigned ndims, const hsize_t *coord, - const uint32_t *chunk, const hsize_t *down_nchunks); -H5_DLL void H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, - const uint32_t *chunk, hsize_t *scaled); -H5_DLL hsize_t H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, - const uint32_t *chunk, const hsize_t *down_nchunks, hsize_t *scaled); + const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, + const void *_src); +H5_DLL herr_t H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count); +H5_DLL herr_t H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down); +H5_DLL hsize_t H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset); +H5_DLL hsize_t H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset); +H5_DLL herr_t H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, hsize_t *coords); +H5_DLL herr_t H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords); +H5_DLL hsize_t H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, + const hsize_t *down_nchunks); +H5_DLL void H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, hsize_t *scaled); +H5_DLL hsize_t H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, + const hsize_t *down_nchunks, hsize_t *scaled); H5_DLL ssize_t H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], - hsize_t dst_off_arr[], - size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], - hsize_t src_off_arr[], - H5VM_opvv_func_t op, void *op_data); -H5_DLL ssize_t H5VM_memcpyvv(void *_dst, - size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[], - const void *_src, - size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[]); - + hsize_t dst_off_arr[], size_t src_max_nseq, size_t *src_curr_seq, + size_t src_len_arr[], hsize_t src_off_arr[], H5VM_opvv_func_t op, void *op_data); +H5_DLL ssize_t H5VM_memcpyvv(void *_dst, size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], + hsize_t dst_off_arr[], const void *_src, size_t src_max_nseq, + size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[]); /*------------------------------------------------------------------------- * Function: H5VM_vector_reduce_product @@ -160,13 +144,15 @@ H5_DLL ssize_t H5VM_memcpyvv(void *_dst, static H5_INLINE hsize_t H5_ATTR_UNUSED H5VM_vector_reduce_product(unsigned n, const hsize_t *v) { - hsize_t ret_value = 1; + hsize_t ret_value = 1; /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if (n && !v) HGOTO_DONE(0) - while (n--) ret_value *= *v++; + if (n && !v) + HGOTO_DONE(0) + while (n--) + ret_value *= *v++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -192,7 +178,7 @@ done: static H5_INLINE htri_t H5_ATTR_UNUSED H5VM_vector_zerop_u(int n, const hsize_t *v) { - htri_t ret_value=TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -200,7 +186,7 @@ H5VM_vector_zerop_u(int n, const hsize_t *v) if (!v) HGOTO_DONE(TRUE) while (n--) - if (*v++) + if (*v++) HGOTO_DONE(FALSE) done: @@ -227,7 +213,7 @@ done: static H5_INLINE htri_t H5_ATTR_UNUSED H5VM_vector_zerop_s(int n, const hssize_t *v) { - htri_t ret_value=TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -235,7 +221,7 @@ H5VM_vector_zerop_s(int n, const hssize_t *v) if (!v) HGOTO_DONE(TRUE) while (n--) - if (*v++) + if (*v++) HGOTO_DONE(FALSE) done: @@ -262,19 +248,24 @@ done: *------------------------------------------------------------------------- */ static H5_INLINE int H5_ATTR_UNUSED -H5VM_vector_cmp_u (unsigned n, const hsize_t *v1, const hsize_t *v2) +H5VM_vector_cmp_u(unsigned n, const hsize_t *v1, const hsize_t *v2) { - int ret_value=0; /* Return value */ + int ret_value = 0; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if (v1 == v2) HGOTO_DONE(0) - if (v1 == NULL) HGOTO_DONE(-1) - if (v2 == NULL) HGOTO_DONE(1) + if (v1 == v2) + HGOTO_DONE(0) + if (v1 == NULL) + HGOTO_DONE(-1) + if (v2 == NULL) + HGOTO_DONE(1) while (n--) { - if (*v1 < *v2) HGOTO_DONE(-1) - if (*v1 > *v2) HGOTO_DONE(1) + if (*v1 < *v2) + HGOTO_DONE(-1) + if (*v1 > *v2) + HGOTO_DONE(1) v1++; v2++; } @@ -283,7 +274,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5VM_vector_cmp_s * @@ -304,19 +294,24 @@ done: *------------------------------------------------------------------------- */ static H5_INLINE int H5_ATTR_UNUSED -H5VM_vector_cmp_s (unsigned n, const hssize_t *v1, const hssize_t *v2) +H5VM_vector_cmp_s(unsigned n, const hssize_t *v1, const hssize_t *v2) { - int ret_value=0; /* Return value */ + int ret_value = 0; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if (v1 == v2) HGOTO_DONE(0) - if (v1 == NULL) HGOTO_DONE(-1) - if (v2 == NULL) HGOTO_DONE(1) + if (v1 == v2) + HGOTO_DONE(0) + if (v1 == NULL) + HGOTO_DONE(-1) + if (v2 == NULL) + HGOTO_DONE(1) while (n--) { - if (*v1 < *v2) HGOTO_DONE(-1) - if (*v1 > *v2) HGOTO_DONE(1) + if (*v1 < *v2) + HGOTO_DONE(-1) + if (*v1 > *v2) + HGOTO_DONE(1) v1++; v2++; } @@ -325,7 +320,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5VM_vector_inc * @@ -343,31 +337,21 @@ done: static H5_INLINE void H5_ATTR_UNUSED H5VM_vector_inc(int n, hsize_t *v1, const hsize_t *v2) { - while (n--) *v1++ += *v2++; + while (n--) + *v1++ += *v2++; } /* Lookup table for general log2(n) routine */ -static const unsigned char LogTable256[] = -{ - 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 -}; - - +static const unsigned char LogTable256[] = { + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; + /*------------------------------------------------------------------------- * Function: H5VM_log2_gen * @@ -390,33 +374,30 @@ static const unsigned char LogTable256[] = static H5_INLINE unsigned H5_ATTR_UNUSED H5VM_log2_gen(uint64_t n) { - unsigned r; /* r will be log2(n) */ - register unsigned int t, tt, ttt; /* temporaries */ + unsigned r; /* r will be log2(n) */ + register unsigned int t, tt, ttt; /* temporaries */ - if((ttt = (unsigned)(n >> 32))) - if((tt = (unsigned)(n >> 48))) - r = (t = (unsigned)(n >> 56)) ? 56 + (unsigned)LogTable256[t] : 48 + (unsigned)LogTable256[tt & 0xFF]; + if ((ttt = (unsigned)(n >> 32))) + if ((tt = (unsigned)(n >> 48))) + r = (t = (unsigned)(n >> 56)) ? 56 + (unsigned)LogTable256[t] + : 48 + (unsigned)LogTable256[tt & 0xFF]; else - r = (t = (unsigned)(n >> 40)) ? 40 + (unsigned)LogTable256[t] : 32 + (unsigned)LogTable256[ttt & 0xFF]; + r = (t = (unsigned)(n >> 40)) ? 40 + (unsigned)LogTable256[t] + : 32 + (unsigned)LogTable256[ttt & 0xFF]; + else if ((tt = (unsigned)(n >> 16))) + r = (t = (unsigned)(n >> 24)) ? 24 + (unsigned)LogTable256[t] : 16 + (unsigned)LogTable256[tt & 0xFF]; else - if((tt = (unsigned)(n >> 16))) - r = (t = (unsigned)(n >> 24)) ? 24 + (unsigned)LogTable256[t] : 16 + (unsigned)LogTable256[tt & 0xFF]; - else - /* Added 'uint8_t' cast to pacify PGCC compiler */ - r = (t = (unsigned)(n >> 8)) ? 8 + (unsigned)LogTable256[t] : (unsigned)LogTable256[(uint8_t)n]; + /* Added 'uint8_t' cast to pacify PGCC compiler */ + r = (t = (unsigned)(n >> 8)) ? 8 + (unsigned)LogTable256[t] : (unsigned)LogTable256[(uint8_t)n]; - return(r); + return (r); } /* H5VM_log2_gen() */ - /* Lookup table for specialized log2(n) of power of two routine */ -static const unsigned MultiplyDeBruijnBitPosition[32] = -{ - 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, - 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 -}; +static const unsigned MultiplyDeBruijnBitPosition[32] = {0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, + 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, + 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; - /*------------------------------------------------------------------------- * Function: H5VM_log2_of2 * @@ -441,10 +422,9 @@ H5VM_log2_of2(uint32_t n) #ifndef NDEBUG HDassert(POWER_OF_TWO(n)); #endif /* NDEBUG */ - return(MultiplyDeBruijnBitPosition[(n * (uint32_t)0x077CB531UL) >> 27]); + return (MultiplyDeBruijnBitPosition[(n * (uint32_t)0x077CB531UL) >> 27]); } /* H5VM_log2_of2() */ - /*------------------------------------------------------------------------- * Function: H5VM_power2up * @@ -459,19 +439,18 @@ H5VM_log2_of2(uint32_t n) static H5_INLINE H5_ATTR_CONST hsize_t H5VM_power2up(hsize_t n) { - hsize_t ret_value = 1; /* Return value */ + hsize_t ret_value = 1; /* Return value */ /* Returns 0 when n exceeds 2^63 */ - if(n >= (hsize_t)1 << ((sizeof(hsize_t) * CHAR_BIT) - 1)) + if (n >= (hsize_t)1 << ((sizeof(hsize_t) * CHAR_BIT) - 1)) ret_value = 0; - while(ret_value && ret_value < n) + while (ret_value && ret_value < n) ret_value <<= 1; - return(ret_value); + return (ret_value); } /* H5VM_power2up */ - /*------------------------------------------------------------------------- * Function: H5VM_limit_enc_size * @@ -491,10 +470,9 @@ H5VM_limit_enc_size(uint64_t limit) return (H5VM_log2_gen(limit) / 8) + 1; } /* end H5VM_limit_enc_size() */ -static const unsigned char H5VM_bit_set_g[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; +static const unsigned char H5VM_bit_set_g[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; static const unsigned char H5VM_bit_clear_g[8] = {0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE}; - /*------------------------------------------------------------------------- * Function: H5VM_bit_get * @@ -521,7 +499,6 @@ H5VM_bit_get(const unsigned char *buf, size_t offset) return (hbool_t)((buf[offset / 8] & (H5VM_bit_set_g[offset % 8])) ? TRUE : FALSE); } /* end H5VM_bit_get() */ - /*------------------------------------------------------------------------- * Function: H5VM_bit_set * @@ -545,11 +522,10 @@ static H5_INLINE void H5_ATTR_UNUSED H5VM_bit_set(unsigned char *buf, size_t offset, hbool_t val) { /* Set/reset the appropriate bit in the buffer */ - if(val) + if (val) buf[offset / 8] |= H5VM_bit_set_g[offset % 8]; else buf[offset / 8] &= H5VM_bit_clear_g[offset % 8]; } /* end H5VM_bit_set() */ #endif /* H5VMprivate_H */ - diff --git a/src/H5WB.c b/src/H5WB.c index 8a85a3a..8d0bcd1 100644 --- a/src/H5WB.c +++ b/src/H5WB.c @@ -28,54 +28,47 @@ /* Module Setup */ /****************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ /* Typedef for buffer wrapper */ struct H5WB_t { - void *wrapped_buf; /* Pointer to wrapped buffer */ - size_t wrapped_size; /* Size of wrapped buffer */ - void *actual_buf; /* Pointer to actual buffer */ - size_t actual_size; /* Size of actual buffer used */ - size_t alloc_size; /* Size of actual buffer allocated */ + void * wrapped_buf; /* Pointer to wrapped buffer */ + size_t wrapped_size; /* Size of wrapped buffer */ + void * actual_buf; /* Pointer to actual buffer */ + size_t actual_size; /* Size of actual buffer used */ + size_t alloc_size; /* Size of actual buffer allocated */ }; - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -86,8 +79,6 @@ H5FL_DEFINE_STATIC(H5WB_t); /* Declare a free list to manage the extra buffer information */ H5FL_BLK_DEFINE_STATIC(extra_buf); - - /*------------------------------------------------------------------------- * Function: H5WB_wrap * @@ -105,8 +96,8 @@ H5FL_BLK_DEFINE_STATIC(extra_buf); H5WB_t * H5WB_wrap(void *buf, size_t buf_size) { - H5WB_t *wb = NULL; /* Wrapped buffer info */ - H5WB_t *ret_value; /* Return value */ + H5WB_t *wb = NULL; /* Wrapped buffer info */ + H5WB_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -117,30 +108,29 @@ H5WB_wrap(void *buf, size_t buf_size) HDassert(buf_size); /* Create wrapped buffer info */ - if(NULL == (wb = H5FL_MALLOC(H5WB_t))) + if (NULL == (wb = H5FL_MALLOC(H5WB_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for wrapped buffer info") /* Wrap buffer given */ - wb->wrapped_buf = buf; + wb->wrapped_buf = buf; wb->wrapped_size = buf_size; /* No actual buffer yet */ - wb->actual_buf = NULL; + wb->actual_buf = NULL; wb->actual_size = 0; - wb->alloc_size = 0; + wb->alloc_size = 0; /* Set the return value */ ret_value = wb; done: /* Release resources on error */ - if(!ret_value && wb) + if (!ret_value && wb) wb = H5FL_FREE(H5WB_t, wb); FUNC_LEAVE_NOAPI(ret_value) } /* end H5WB_wrap() */ - /*------------------------------------------------------------------------- * Function: H5WB_actual * @@ -159,7 +149,7 @@ done: void * H5WB_actual(H5WB_t *wb, size_t need) { - void *ret_value; /* Return value */ + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -170,12 +160,12 @@ H5WB_actual(H5WB_t *wb, size_t need) HDassert(wb->wrapped_buf); /* Check for previously allocated buffer */ - if(wb->actual_buf && wb->actual_buf != wb->wrapped_buf) { + if (wb->actual_buf && wb->actual_buf != wb->wrapped_buf) { /* Sanity check */ HDassert(wb->actual_size > wb->wrapped_size); /* Check if we can re-use existing buffer */ - if(need <= wb->alloc_size) + if (need <= wb->alloc_size) HGOTO_DONE(wb->actual_buf) /* Can't re-use existing buffer, free it and proceed */ else @@ -183,9 +173,9 @@ H5WB_actual(H5WB_t *wb, size_t need) } /* end if */ /* Check if size needed can be fulfilled with wrapped buffer */ - if(need > wb->wrapped_size) { + if (need > wb->wrapped_size) { /* Need to allocate new buffer */ - if(NULL == (wb->actual_buf = H5FL_BLK_MALLOC(extra_buf, need))) + if (NULL == (wb->actual_buf = H5FL_BLK_MALLOC(extra_buf, need))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, NULL, "memory allocation failed") /* Remember size of buffer allocated */ @@ -202,13 +192,12 @@ H5WB_actual(H5WB_t *wb, size_t need) done: /* Remember size of buffer used, if we were successful */ - if(ret_value) + if (ret_value) wb->actual_size = need; FUNC_LEAVE_NOAPI(ret_value) } /* end H5WB_actual() */ - /*------------------------------------------------------------------------- * Function: H5WB_actual_clear * @@ -227,7 +216,7 @@ done: void * H5WB_actual_clear(H5WB_t *wb, size_t need) { - void *ret_value; /* Return value */ + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -238,7 +227,7 @@ H5WB_actual_clear(H5WB_t *wb, size_t need) HDassert(wb->wrapped_buf); /* Get a pointer to an actual buffer */ - if(NULL == (ret_value = H5WB_actual(wb, need))) + if (NULL == (ret_value = H5WB_actual(wb, need))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear the buffer */ @@ -248,7 +237,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5WB_actual_clear() */ - /*------------------------------------------------------------------------- * Function: H5WB_unwrap * @@ -274,7 +262,7 @@ H5WB_unwrap(H5WB_t *wb) HDassert(wb->wrapped_buf); /* Release any extra buffers allocated */ - if(wb->actual_buf && wb->actual_buf != wb->wrapped_buf) { + if (wb->actual_buf && wb->actual_buf != wb->wrapped_buf) { /* Sanity check */ HDassert(wb->actual_size > wb->wrapped_size); @@ -286,4 +274,3 @@ H5WB_unwrap(H5WB_t *wb) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5WB_unwrap() */ - diff --git a/src/H5WBprivate.h b/src/H5WBprivate.h index 4460808..34077a6 100644 --- a/src/H5WBprivate.h +++ b/src/H5WBprivate.h @@ -34,7 +34,6 @@ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -42,21 +41,18 @@ /* Wrapped buffer info (forward decl - defined in H5WB.c) */ typedef struct H5WB_t H5WB_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General routines for wrapped buffer operations */ H5_DLL H5WB_t *H5WB_wrap(void *buf, size_t buf_size); -H5_DLL void *H5WB_actual(H5WB_t *wb, size_t need); -H5_DLL void *H5WB_actual_clear(H5WB_t *wb, size_t need); -H5_DLL herr_t H5WB_unwrap(H5WB_t *wb); +H5_DLL void * H5WB_actual(H5WB_t *wb, size_t need); +H5_DLL void * H5WB_actual_clear(H5WB_t *wb, size_t need); +H5_DLL herr_t H5WB_unwrap(H5WB_t *wb); #endif /* _H5WBprivate_H */ - diff --git a/src/H5Z.c b/src/H5Z.c index 3bd4bcb..a6be406 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -11,60 +11,60 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5PLprivate.h" /* Plugins */ -#include "H5Sprivate.h" /* Dataspace functions */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5PLprivate.h" /* Plugins */ +#include "H5Sprivate.h" /* Dataspace functions */ +#include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_SZLIB_H -# include "szlib.h" +#include "szlib.h" #endif /* Local typedefs */ #ifdef H5Z_DEBUG typedef struct H5Z_stats_t { struct { - hsize_t total; /* total number of bytes processed */ - hsize_t errors; /* bytes of total attributable to errors */ - H5_timevals_t times; /* execution time including errors */ - } stats[2]; /* 0 = output, 1 = input */ + hsize_t total; /* total number of bytes processed */ + hsize_t errors; /* bytes of total attributable to errors */ + H5_timevals_t times; /* execution time including errors */ + } stats[2]; /* 0 = output, 1 = input */ } H5Z_stats_t; #endif /* H5Z_DEBUG */ typedef struct H5Z_object_t { - H5Z_filter_t filter_id; /* ID of the filter we're looking for */ - htri_t found; /* Whether we find an object using the filter */ + H5Z_filter_t filter_id; /* ID of the filter we're looking for */ + htri_t found; /* Whether we find an object using the filter */ #ifdef H5_HAVE_PARALLEL - hbool_t sanity_checked; /* Whether the sanity check for collectively calling H5Zunregister has been done */ -#endif /* H5_HAVE_PARALLEL */ + hbool_t + sanity_checked; /* Whether the sanity check for collectively calling H5Zunregister has been done */ +#endif /* H5_HAVE_PARALLEL */ } H5Z_object_t; /* Enumerated type for dataset creation prelude callbacks */ typedef enum { - H5Z_PRELUDE_CAN_APPLY, /* Call "can apply" callback */ - H5Z_PRELUDE_SET_LOCAL /* Call "set local" callback */ + H5Z_PRELUDE_CAN_APPLY, /* Call "can apply" callback */ + H5Z_PRELUDE_SET_LOCAL /* Call "set local" callback */ } H5Z_prelude_type_t; /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local variables */ -static size_t H5Z_table_alloc_g = 0; -static size_t H5Z_table_used_g = 0; -static H5Z_class2_t *H5Z_table_g = NULL; +static size_t H5Z_table_alloc_g = 0; +static size_t H5Z_table_used_g = 0; +static H5Z_class2_t *H5Z_table_g = NULL; #ifdef H5Z_DEBUG -static H5Z_stats_t *H5Z_stat_table_g = NULL; +static H5Z_stats_t *H5Z_stat_table_g = NULL; #endif /* H5Z_DEBUG */ /* Local functions */ @@ -73,7 +73,6 @@ static int H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t obj_id, void *key) static int H5Z__check_unregister_group_cb(void *obj_ptr, hid_t obj_id, void *key); static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); - /*------------------------------------------------------------------------- * Function: H5Z__init_package * @@ -85,7 +84,7 @@ static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); herr_t H5Z__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -99,7 +98,7 @@ H5Z__init_package(void) if (H5Z_register(H5Z_SCALEOFFSET) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register scaleoffset filter") - /* External filters */ + /* External filters */ #ifdef H5_HAVE_FILTER_DEFLATE if (H5Z_register(H5Z_DEFLATE) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter") @@ -114,7 +113,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__init_package() */ - /*------------------------------------------------------------------------- * Function: H5Z_term_package * @@ -126,34 +124,30 @@ done: int H5Z_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { #ifdef H5Z_DEBUG - char comment[16], bandwidth[32]; - int dir, nprint = 0; - size_t i; - - if(H5DEBUG(Z)) { - for(i = 0; i < H5Z_table_used_g; i++) { - for(dir = 0; dir<2; dir++) { - if(0 == H5Z_stat_table_g[i].stats[dir].total) + char comment[16], bandwidth[32]; + int dir, nprint = 0; + size_t i; + + if (H5DEBUG(Z)) { + for (i = 0; i < H5Z_table_used_g; i++) { + for (dir = 0; dir < 2; dir++) { + if (0 == H5Z_stat_table_g[i].stats[dir].total) continue; - if(0 == nprint++) { + if (0 == nprint++) { /* Print column headers */ HDfprintf(H5DEBUG(Z), "H5Z: filter statistics " - "accumulated over life of library:\n"); - HDfprintf(H5DEBUG(Z), - " %-16s %10s %10s %8s %8s %8s %10s\n", - "Filter", "Total", "Errors", "User", - "System", "Elapsed", "Bandwidth"); - HDfprintf(H5DEBUG(Z), - " %-16s %10s %10s %8s %8s %8s %10s\n", - "------", "-----", "------", "----", - "------", "-------", "---------"); + "accumulated over life of library:\n"); + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "Filter", "Total", + "Errors", "User", "System", "Elapsed", "Bandwidth"); + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "------", "-----", + "------", "----", "------", "-------", "---------"); } /* end if */ /* Truncate the comment to fit in the field */ @@ -161,30 +155,27 @@ H5Z_term_package(void) comment[sizeof(comment) - 1] = '\0'; /* - * Format bandwidth to have four significant digits and - * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or - * the word `Inf' if the elapsed time is zero. - */ - H5_bandwidth(bandwidth, - (double)(H5Z_stat_table_g[i].stats[dir].total), - H5Z_stat_table_g[i].stats[dir].times.elapsed); + * Format bandwidth to have four significant digits and + * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or + * the word `Inf' if the elapsed time is zero. + */ + H5_bandwidth(bandwidth, (double)(H5Z_stat_table_g[i].stats[dir].total), + H5Z_stat_table_g[i].stats[dir].times.elapsed); /* Print the statistics */ - HDfprintf(H5DEBUG(Z), " %s%-15s %10Hd %10Hd %8T %8T %8T %10s\n", - (dir ? "<" : ">"), comment, - H5Z_stat_table_g[i].stats[dir].total, - H5Z_stat_table_g[i].stats[dir].errors, - H5Z_stat_table_g[i].stats[dir].times.user, - H5Z_stat_table_g[i].stats[dir].times.system, - H5Z_stat_table_g[i].stats[dir].times.elapsed, - bandwidth); + HDfprintf(H5DEBUG(Z), " %s%-15s %10Hd %10Hd %8T %8T %8T %10s\n", (dir ? "<" : ">"), + comment, H5Z_stat_table_g[i].stats[dir].total, + H5Z_stat_table_g[i].stats[dir].errors, + H5Z_stat_table_g[i].stats[dir].times.user, + H5Z_stat_table_g[i].stats[dir].times.system, + H5Z_stat_table_g[i].stats[dir].times.elapsed, bandwidth); } /* end for */ - } /* end for */ - } /* end if */ -#endif /* H5Z_DEBUG */ + } /* end for */ + } /* end if */ +#endif /* H5Z_DEBUG */ /* Free the table of filters */ - if(H5Z_table_g) { + if (H5Z_table_g) { H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); #ifdef H5Z_DEBUG @@ -203,7 +194,6 @@ H5Z_term_package(void) FUNC_LEAVE_NOAPI(n) } /* end H5Z_term_package() */ - /*------------------------------------------------------------------------- * Function: H5Zregister * @@ -215,17 +205,17 @@ H5Z_term_package(void) herr_t H5Zregister(const void *cls) { - const H5Z_class2_t *cls_real = (const H5Z_class2_t *) cls; /* "Real" class pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5Z_class2_t *cls_real = (const H5Z_class2_t *)cls; /* "Real" class pointer */ + herr_t ret_value = SUCCEED; /* Return value */ #ifndef H5_NO_DEPRECATED_SYMBOLS - H5Z_class2_t cls_new; /* Translated class struct */ + H5Z_class2_t cls_new; /* Translated class struct */ #endif FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", cls); /* Check args */ - if (cls_real==NULL) + if (cls_real == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class") /* Check H5Z_class_t version number; this is where a function to convert @@ -241,26 +231,26 @@ H5Zregister(const void *cls) if (cls_real->version != H5Z_CLASS_T_VERS) { #ifndef H5_NO_DEPRECATED_SYMBOLS /* Assume it is an old "H5Z_class1_t" instead */ - const H5Z_class1_t *cls_old = (const H5Z_class1_t *) cls; + const H5Z_class1_t *cls_old = (const H5Z_class1_t *)cls; /* Translate to new H5Z_class2_t */ - cls_new.version = H5Z_CLASS_T_VERS; - cls_new.id = cls_old->id; + cls_new.version = H5Z_CLASS_T_VERS; + cls_new.id = cls_old->id; cls_new.encoder_present = 1; cls_new.decoder_present = 1; - cls_new.name = cls_old->name; - cls_new.can_apply = cls_old->can_apply; - cls_new.set_local = cls_old->set_local; - cls_new.filter = cls_old->filter; + cls_new.name = cls_old->name; + cls_new.can_apply = cls_old->can_apply; + cls_new.set_local = cls_old->set_local; + cls_new.filter = cls_old->filter; /* Set cls_real to point to the translated structure */ cls_real = &cls_new; -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ /* Deprecated symbols not allowed, throw an error */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ + } /* end if */ if (cls_real->id < 0 || cls_real->id > H5Z_FILTER_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") @@ -277,7 +267,6 @@ done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_register * @@ -289,10 +278,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Z_register (const H5Z_class2_t *cls) +H5Z_register(const H5Z_class2_t *cls) { - size_t i; - herr_t ret_value = SUCCEED; /* Return value */ + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -307,7 +296,7 @@ H5Z_register (const H5Z_class2_t *cls) /* Filter not already registered */ if (i >= H5Z_table_used_g) { if (H5Z_table_used_g >= H5Z_table_alloc_g) { - size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5Z_table_alloc_g); + size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5Z_table_alloc_g); H5Z_class2_t *table = (H5Z_class2_t *)H5MM_realloc(H5Z_table_g, n * sizeof(H5Z_class2_t)); #ifdef H5Z_DEBUG H5Z_stats_t *stat_table = (H5Z_stats_t *)H5MM_realloc(H5Z_stat_table_g, n * sizeof(H5Z_stats_t)); @@ -325,22 +314,21 @@ H5Z_register (const H5Z_class2_t *cls) /* Initialize */ i = H5Z_table_used_g++; - H5MM_memcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); + H5MM_memcpy(H5Z_table_g + i, cls, sizeof(H5Z_class2_t)); #ifdef H5Z_DEBUG - HDmemset(H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t)); + HDmemset(H5Z_stat_table_g + i, 0, sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ - } /* end if */ + } /* end if */ /* Filter already registered */ else { /* Replace old contents */ - H5MM_memcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); + H5MM_memcpy(H5Z_table_g + i, cls, sizeof(H5Z_class2_t)); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Zunregister * @@ -353,7 +341,7 @@ done: herr_t H5Zunregister(H5Z_filter_t id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Zf", id); @@ -365,14 +353,13 @@ H5Zunregister(H5Z_filter_t id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters") /* Do it */ - if(H5Z__unregister(id) < 0) + if (H5Z__unregister(id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister filter") done: FUNC_LEAVE_API(ret_value) } /* end H5Zunregister() */ - /*------------------------------------------------------------------------- * Function: H5Z__unregister * @@ -386,9 +373,9 @@ done: herr_t H5Z__unregister(H5Z_filter_t filter_id) { - size_t filter_index; /* Local index variable for filter */ - H5Z_object_t object; /* Object to pass to callbacks */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t filter_index; /* Local index variable for filter */ + H5Z_object_t object; /* Object to pass to callbacks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -404,10 +391,10 @@ H5Z__unregister(H5Z_filter_t filter_id) HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter is not registered") /* Initialize the structure object for iteration */ - object.filter_id = filter_id; - object.found = FALSE; + object.filter_id = filter_id; + object.found = FALSE; #ifdef H5_HAVE_PARALLEL - object.sanity_checked = FALSE; + object.sanity_checked = FALSE; #endif /* H5_HAVE_PARALLEL */ /* Iterate through all opened datasets, returns a failure if any of them uses the filter */ @@ -415,14 +402,16 @@ H5Z__unregister(H5Z_filter_t filter_id) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") if (object.found) - HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister filter because a dataset is still using it") + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, + "can't unregister filter because a dataset is still using it") /* Iterate through all opened groups, returns a failure if any of them uses the filter */ if (H5I_iterate(H5I_GROUP, H5Z__check_unregister_group_cb, &object, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") if (object.found) - HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister filter because a group is still using it") + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, + "can't unregister filter because a group is still using it") /* Iterate through all opened files and flush them */ if (H5I_iterate(H5I_FILE, H5Z__flush_file_cb, &object, FALSE) < 0) @@ -430,9 +419,11 @@ H5Z__unregister(H5Z_filter_t filter_id) /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ - HDmemmove(&H5Z_table_g[filter_index], &H5Z_table_g[filter_index+1], sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index)); + HDmemmove(&H5Z_table_g[filter_index], &H5Z_table_g[filter_index + 1], + sizeof(H5Z_class2_t) * ((H5Z_table_used_g - 1) - filter_index)); #ifdef H5Z_DEBUG - HDmemmove(&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index+1], sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-filter_index)); + HDmemmove(&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index + 1], + sizeof(H5Z_stats_t) * ((H5Z_table_used_g - 1) - filter_index)); #endif /* H5Z_DEBUG */ H5Z_table_used_g--; @@ -440,7 +431,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__unregister() */ - /*------------------------------------------------------------------------- * Function: H5Z__check_unregister * @@ -455,8 +445,8 @@ done: static htri_t H5Z__check_unregister(hid_t ocpl_id, H5Z_filter_t filter_id) { - H5P_genplist_t *plist; /* Property list */ - htri_t ret_value = FALSE; /* Return value */ + H5P_genplist_t *plist; /* Property list */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -472,7 +462,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister() */ - /*------------------------------------------------------------------------- * Function: H5Z__check_unregister_group_cb * @@ -490,17 +479,17 @@ done: static int H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) { - hid_t ocpl_id = -1; - H5Z_object_t *object = (H5Z_object_t *)key; - htri_t filter_in_pline = FALSE; - int ret_value = FALSE; /* Return value */ + hid_t ocpl_id = -1; + H5Z_object_t *object = (H5Z_object_t *)key; + htri_t filter_in_pline = FALSE; + int ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC HDassert(obj_ptr); /* Get the group creation property */ - if((ocpl_id = H5G_get_create_plist((H5G_t *)obj_ptr)) < 0) + if ((ocpl_id = H5G_get_create_plist((H5G_t *)obj_ptr)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get group creation property list") /* Check if the filter is in the group creation property list */ @@ -512,7 +501,7 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void */ if (filter_in_pline) { object->found = TRUE; - ret_value = TRUE; + ret_value = TRUE; } done: @@ -523,7 +512,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister_group_cb() */ - /*------------------------------------------------------------------------- * Function: H5Z__check_unregister_dset_cb * @@ -541,10 +529,10 @@ done: static int H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) { - hid_t ocpl_id = -1; - H5Z_object_t *object = (H5Z_object_t *)key; - htri_t filter_in_pline = FALSE; - int ret_value = FALSE; /* Return value */ + hid_t ocpl_id = -1; + H5Z_object_t *object = (H5Z_object_t *)key; + htri_t filter_in_pline = FALSE; + int ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -563,7 +551,7 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void * */ if (filter_in_pline) { object->found = TRUE; - ret_value = TRUE; + ret_value = TRUE; } done: @@ -574,7 +562,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister_dset_cb() */ - /*------------------------------------------------------------------------- * Function: H5Z__flush_file_cb * @@ -586,14 +573,13 @@ done: *------------------------------------------------------------------------- */ static int -H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, - void *key H5_ATTR_PARALLEL_USED) +H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key H5_ATTR_PARALLEL_USED) { - H5F_t *f = (H5F_t *)obj_ptr; /* File object for operations */ + H5F_t *f = (H5F_t *)obj_ptr; /* File object for operations */ #ifdef H5_HAVE_PARALLEL - H5Z_object_t *object = (H5Z_object_t *)key; -#endif /* H5_HAVE_PARALLEL */ - int ret_value = FALSE; /* Return value */ + H5Z_object_t *object = (H5Z_object_t *)key; +#endif /* H5_HAVE_PARALLEL */ + int ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -602,30 +588,30 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, HDassert(key); /* Do a global flush if the file is opened for write */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { + if (H5F_ACC_RDWR & H5F_INTENT(f)) { /* When parallel HDF5 is defined, check for collective metadata reads on this * file and set the flag for metadata I/O in the API context. -QAK, 2018/02/14 */ #ifdef H5_HAVE_PARALLEL /* Check if MPIO driver is used */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - H5P_coll_md_read_flag_t coll_md_read; /* Do all metadata reads collectively */ + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + H5P_coll_md_read_flag_t coll_md_read; /* Do all metadata reads collectively */ /* Sanity check for collectively calling H5Zunregister, if requested */ /* (Sanity check assumes that a barrier on one file's comm * is sufficient (i.e. that there aren't different comms for * different files). -QAK, 2018/02/14) */ - if(H5_coll_api_sanity_check_g && !object->sanity_checked) { - MPI_Comm mpi_comm; /* File's communicator */ + if (H5_coll_api_sanity_check_g && !object->sanity_checked) { + MPI_Comm mpi_comm; /* File's communicator */ /* Retrieve the file communicator */ - if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get MPI communicator") /* Issue the barrier */ - if(mpi_comm != MPI_COMM_NULL) + if (mpi_comm != MPI_COMM_NULL) MPI_Barrier(mpi_comm); /* Set the "sanity checked" flag */ @@ -634,13 +620,13 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, /* Check whether to use the collective metadata read DXPL */ coll_md_read = H5F_COLL_MD_READ(f); - if(H5P_USER_TRUE == coll_md_read) + if (H5P_USER_TRUE == coll_md_read) H5CX_set_coll_metadata_read(TRUE); } /* end if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts((H5F_t *)obj_ptr) < 0) + if (H5F_flush_mounts((H5F_t *)obj_ptr) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy") } /* end if */ @@ -648,7 +634,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__flush_file_cb() */ - /*------------------------------------------------------------------------- * Function: H5Zfilter_avail * @@ -660,7 +645,7 @@ done: htri_t H5Zfilter_avail(H5Z_filter_t id) { - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "Zf", id); @@ -676,7 +661,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Zfilter_avail() */ - /*------------------------------------------------------------------------- * Function: H5Z_filter_avail * @@ -688,10 +672,10 @@ done: htri_t H5Z_filter_avail(H5Z_filter_t id) { - H5PL_key_t key; /* Key for finding a plugin */ - const H5Z_class2_t *filter_info; /* Filter information */ - size_t i; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + H5PL_key_t key; /* Key for finding a plugin */ + const H5Z_class2_t *filter_info; /* Filter information */ + size_t i; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -701,8 +685,8 @@ H5Z_filter_avail(H5Z_filter_t id) HGOTO_DONE(TRUE) key.id = (int)id; - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { - if(H5Z_register(filter_info) < 0) + if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { + if (H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter") HGOTO_DONE(TRUE) } /* end if */ @@ -711,7 +695,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_avail() */ - /*------------------------------------------------------------------------- * Function: H5Z_prelude_callback * @@ -726,12 +709,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, - hid_t space_id, H5Z_prelude_type_t prelude_type) +H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, hid_t space_id, + H5Z_prelude_type_t prelude_type) { - H5Z_class2_t *fclass; /* Individual filter information */ - size_t u; /* Local index variable */ - htri_t ret_value = TRUE; /* Return value */ + H5Z_class2_t *fclass; /* Individual filter information */ + size_t u; /* Local index variable */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -743,7 +726,7 @@ H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, if (NULL == (fclass = H5Z_find(pline->filter[u].id))) { /* Ignore errors from optional filters */ if (pline->filter[u].flags & H5Z_FLAG_OPTIONAL) - H5E_clear_stack (NULL); + H5E_clear_stack(NULL); else HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located") } /* end if */ @@ -753,8 +736,8 @@ H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, case H5Z_PRELUDE_CAN_APPLY: /* Check if filter is configured to be able to encode */ if (!fclass->encoder_present) - HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled."); - + HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, + "Filter present but encoding is disabled."); /* Check if there is a "can apply" callback */ if (fclass->can_apply) { @@ -785,15 +768,14 @@ H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, default: HDassert("invalid prelude type" && 0); } /* end switch */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_prelude_callback() */ - /*------------------------------------------------------------------------- * Function: H5Z_prepare_prelude_callback_dcpl * @@ -810,9 +792,9 @@ done: static herr_t H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_type) { - hid_t space_id = -1; /* ID for dataspace describing chunk */ - H5O_layout_t *dcpl_layout = NULL; /* Dataset's layout information */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t space_id = -1; /* ID for dataspace describing chunk */ + H5O_layout_t *dcpl_layout = NULL; /* Dataset's layout information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -821,7 +803,7 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type /* Check if the property list is non-default */ if (dcpl_id != H5P_DATASET_CREATE_DEFAULT) { - H5P_genplist_t *dc_plist; /* Dataset creation property list object */ + H5P_genplist_t *dc_plist; /* Dataset creation property list object */ /* Get memory for the layout */ if (NULL == (dcpl_layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) @@ -837,7 +819,7 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type /* Check if the dataset is chunked */ if (H5D_CHUNKED == dcpl_layout->type) { - H5O_pline_t dcpl_pline; /* Object's I/O pipeline information */ + H5O_pline_t dcpl_pline; /* Object's I/O pipeline information */ /* Get I/O pipeline information */ if (H5P_peek(dc_plist, H5O_CRT_PIPELINE_NAME, &dcpl_pline) < 0) @@ -845,14 +827,14 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type /* Check if the chunks have filters */ if (dcpl_pline.nused > 0) { - hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ - H5S_t *space; /* Dataspace describing chunk */ - size_t u; /* Local index variable */ + hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ + H5S_t * space; /* Dataspace describing chunk */ + size_t u; /* Local index variable */ /* Create a dataspace for a chunk & set the extent */ - for(u = 0; u < dcpl_layout->u.chunk.ndims; u++) + for (u = 0; u < dcpl_layout->u.chunk.ndims; u++) chunk_dims[u] = dcpl_layout->u.chunk.dim[u]; - if(NULL == (space = H5S_create_simple(dcpl_layout->u.chunk.ndims, chunk_dims, NULL))) + if (NULL == (space = H5S_create_simple(dcpl_layout->u.chunk.ndims, chunk_dims, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Get ID for dataspace to pass to filter routines */ @@ -878,7 +860,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_prepare_prelude_callback_dcpl() */ - /*------------------------------------------------------------------------- * Function: H5Z_can_apply * @@ -897,7 +878,7 @@ done: herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -909,7 +890,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_local * @@ -928,7 +908,7 @@ done: herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -940,7 +920,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local() */ - /*------------------------------------------------------------------------- * Function: H5Z_can_apply_direct * @@ -955,7 +934,7 @@ done: herr_t H5Z_can_apply_direct(const H5O_pline_t *pline) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -969,7 +948,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply_direct() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_local_direct * @@ -988,7 +966,7 @@ done: herr_t H5Z_set_local_direct(const H5O_pline_t *pline) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1002,7 +980,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local_direct() */ - /*------------------------------------------------------------------------- * Function: H5Z_modify * @@ -1013,11 +990,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - size_t idx; /* Index of filter in pipeline */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1036,7 +1013,7 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") /* Change parameters for filter */ - pline->filter[idx].flags = flags; + pline->filter[idx].flags = flags; pline->filter[idx].cd_nelmts = cd_nelmts; /* Free any existing parameters */ @@ -1045,7 +1022,7 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, /* Set parameters */ if (cd_nelmts > 0) { - size_t i; /* Local index variable */ + size_t i; /* Local index variable */ /* Allocate memory or point at internal buffer */ if (cd_nelmts > H5Z_COMMON_CD_VALUES) { @@ -1061,13 +1038,12 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, pline->filter[idx].cd_values[i] = cd_values[i]; } /* end if */ else - pline->filter[idx].cd_values = NULL; + pline->filter[idx].cd_values = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_modify() */ - /*------------------------------------------------------------------------- * Function: H5Z_append * @@ -1078,11 +1054,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - size_t idx; - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1096,7 +1072,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, * decide to relax this restriction in the future. */ if (pline->nused >= H5Z_MAX_NFILTERS) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") /* Check for freshly allocated filter pipeline */ if (pline->version == 0) @@ -1105,7 +1081,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, /* Allocate additional space in the pipeline if it's full */ if (pline->nused >= pline->nalloc) { H5O_pline_t x; - size_t n; + size_t n; /* Each filter's data may be stored internally or may be * a separate block of memory. @@ -1116,7 +1092,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, */ for (n = 0; n < pline->nalloc; ++n) if (pline->filter[n].cd_values == pline->filter[n]._cd_values) - pline->filter[n].cd_values = (unsigned *)((void *) ~((size_t)NULL)); + pline->filter[n].cd_values = (unsigned *)((void *)~((size_t)NULL)); x.nalloc = MAX(H5Z_MAX_NFILTERS, 2 * pline->nalloc); x.filter = (H5Z_filter_info_t *)H5MM_realloc(pline->filter, x.nalloc * sizeof(x.filter[0])); @@ -1127,7 +1103,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, * internal data. */ for (n = 0; n < pline->nalloc; ++n) - if (x.filter[n].cd_values == (void *) ~((size_t) NULL)) + if (x.filter[n].cd_values == (void *)~((size_t)NULL)) x.filter[n].cd_values = x.filter[n]._cd_values; /* Point to newly allocated buffer */ @@ -1136,13 +1112,13 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, } /* end if */ /* Add the new filter to the pipeline */ - idx = pline->nused; - pline->filter[idx].id = filter; - pline->filter[idx].flags = flags; - pline->filter[idx].name = NULL; /*we'll pick it up later*/ + idx = pline->nused; + pline->filter[idx].id = filter; + pline->filter[idx].flags = flags; + pline->filter[idx].name = NULL; /*we'll pick it up later*/ pline->filter[idx].cd_nelmts = cd_nelmts; if (cd_nelmts > 0) { - size_t i; /* Local index variable */ + size_t i; /* Local index variable */ /* Allocate memory or point at internal buffer */ if (cd_nelmts > H5Z_COMMON_CD_VALUES) { @@ -1158,7 +1134,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, pline->filter[idx].cd_values[i] = cd_values[i]; } /* end if */ else - pline->filter[idx].cd_values = NULL; + pline->filter[idx].cd_values = NULL; pline->nused++; @@ -1166,7 +1142,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_append() */ - /*------------------------------------------------------------------------- * Function: H5Z_find_idx * @@ -1180,8 +1155,8 @@ done: static int H5Z_find_idx(H5Z_filter_t id) { - size_t i; /* Local index variable */ - int ret_value = FAIL; /* Return value */ + size_t i; /* Local index variable */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1193,7 +1168,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_find_idx() */ - /*------------------------------------------------------------------------- * Function: H5Z_find * @@ -1207,8 +1181,8 @@ done: H5Z_class2_t * H5Z_find(H5Z_filter_t id) { - int idx; /* Filter index in global table */ - H5Z_class2_t *ret_value = NULL; /* Return value */ + int idx; /* Filter index in global table */ + H5Z_class2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1223,7 +1197,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_find() */ - /*------------------------------------------------------------------------- * Function: H5Z_pipeline * @@ -1248,42 +1221,42 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, - unsigned *filter_mask/*in,out*/, H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, - size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, void **buf/*in,out*/) +H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, unsigned *filter_mask /*in,out*/, H5Z_EDC_t edc_read, + H5Z_cb_t cb_struct, size_t *nbytes /*in,out*/, size_t *buf_size /*in,out*/, + void **buf /*in,out*/) { - size_t idx; - size_t new_nbytes; - int fclass_idx; /* Index of filter class in global table */ - H5Z_class2_t *fclass = NULL; /* Filter class pointer */ + size_t idx; + size_t new_nbytes; + int fclass_idx; /* Index of filter class in global table */ + H5Z_class2_t *fclass = NULL; /* Filter class pointer */ #ifdef H5Z_DEBUG - H5Z_stats_t *fstats = NULL; /* Filter stats pointer */ - H5_timer_t timer; /* Timer for filter operations */ - H5_timevals_t times; /* Elapsed time for each operation */ + H5Z_stats_t * fstats = NULL; /* Filter stats pointer */ + H5_timer_t timer; /* Timer for filter operations */ + H5_timevals_t times; /* Elapsed time for each operation */ #endif - unsigned failed = 0; - unsigned tmp_flags; - size_t i; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned failed = 0; + unsigned tmp_flags; + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_INVMASK))); HDassert(filter_mask); - HDassert(nbytes && *nbytes>0); - HDassert(buf_size && *buf_size>0); + HDassert(nbytes && *nbytes > 0); + HDassert(buf_size && *buf_size > 0); HDassert(buf && *buf); HDassert(!pline || pline->nused < H5Z_MAX_NFILTERS); #ifdef H5Z_DEBUG H5_timer_init(&timer); #endif - if(pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */ - for(i = pline->nused; i > 0; --i) { + if (pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */ + for (i = pline->nused; i > 0; --i) { idx = i - 1; - if(*filter_mask & ((unsigned)1 << idx)) { + if (*filter_mask & ((unsigned)1 << idx)) { failed |= (unsigned)1 << idx; - continue; /* filter excluded */ + continue; /* filter excluded */ } /* If the filter isn't registered and the application doesn't @@ -1291,19 +1264,20 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, * try to load it dynamically and register it. Otherwise, return failure */ if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { - H5PL_key_t key; - const H5Z_class2_t *filter_info; - hbool_t issue_error = FALSE; + H5PL_key_t key; + const H5Z_class2_t *filter_info; + hbool_t issue_error = FALSE; /* Try loading the filter */ key.id = (int)(pline->filter[idx].id); - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { + if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { /* Register the filter we loaded */ - if(H5Z_register(filter_info) < 0) + if (H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") - /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ - if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) + /* Search in the table of registered filters again to find the dynamic filter just loaded + * and registered */ + if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) issue_error = TRUE; } else @@ -1314,9 +1288,11 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, /* Print out the filter name to give more info. But the name is optional for * the filter */ if (pline->filter[idx].name) - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", pline->filter[idx].name) + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", + pline->filter[idx].name) else - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered") + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, + "required filter (name unavailable) is not registered") } } /* end if */ @@ -1329,26 +1305,25 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, tmp_flags = flags | (pline->filter[idx].flags); tmp_flags |= (edc_read == H5Z_DISABLE_EDC) ? H5Z_FLAG_SKIP_EDC : 0; - new_nbytes = (fclass->filter)(tmp_flags, - pline->filter[idx].cd_nelmts, pline->filter[idx].cd_values, - *nbytes, buf_size, buf); + new_nbytes = (fclass->filter)(tmp_flags, pline->filter[idx].cd_nelmts, + pline->filter[idx].cd_values, *nbytes, buf_size, buf); #ifdef H5Z_DEBUG H5_timer_stop(&timer); H5_timer_get_times(timer, ×); fstats->stats[1].times.elapsed += times.elapsed; - fstats->stats[1].times.system += times.system; - fstats->stats[1].times.user += times.user; + fstats->stats[1].times.system += times.system; + fstats->stats[1].times.user += times.user; - fstats->stats[1].total += MAX(*nbytes, new_nbytes); - if(0 == new_nbytes) + fstats->stats[1].total += MAX(*nbytes, new_nbytes); + if (0 == new_nbytes) fstats->stats[1].errors += *nbytes; #endif - if(0 == new_nbytes) { - if((cb_struct.func - && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) - || !cb_struct.func) + if (0 == new_nbytes) { + if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, + cb_struct.op_data))) || + !cb_struct.func) HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read") *nbytes = *buf_size; @@ -1359,20 +1334,20 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, *nbytes = new_nbytes; } } - else if(pline) { /* Write */ - for(idx = 0; idx < pline->nused; idx++) { - if(*filter_mask & ((unsigned)1 << idx)) { + else if (pline) { /* Write */ + for (idx = 0; idx < pline->nused; idx++) { + if (*filter_mask & ((unsigned)1 << idx)) { failed |= (unsigned)1 << idx; - continue; /* filter excluded */ + continue; /* filter excluded */ } - if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { + if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { /* Check if filter is optional -- If it isn't, then error */ - if((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) + if ((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered") failed |= (unsigned)1 << idx; H5E_clear_stack(NULL); - continue; /* filter excluded */ - } /* end if */ + continue; /* filter excluded */ + } /* end if */ fclass = &H5Z_table_g[fclass_idx]; @@ -1381,26 +1356,26 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, H5_timer_start(&timer); #endif - new_nbytes = (fclass->filter)(flags | (pline->filter[idx].flags), - pline->filter[idx].cd_nelmts, pline->filter[idx].cd_values, - *nbytes, buf_size, buf); + new_nbytes = (fclass->filter)(flags | (pline->filter[idx].flags), pline->filter[idx].cd_nelmts, + pline->filter[idx].cd_values, *nbytes, buf_size, buf); #ifdef H5Z_DEBUG H5_timer_stop(&timer); H5_timer_get_times(timer, ×); fstats->stats[0].times.elapsed += times.elapsed; - fstats->stats[0].times.system += times.system; - fstats->stats[0].times.user += times.user; + fstats->stats[0].times.system += times.system; + fstats->stats[0].times.user += times.user; fstats->stats[0].total += MAX(*nbytes, new_nbytes); - if(0 == new_nbytes) + if (0 == new_nbytes) fstats->stats[0].errors += *nbytes; #endif - if(0 == new_nbytes) { - if(0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { - if((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) - || !cb_struct.func) + if (0 == new_nbytes) { + if (0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { + if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, + *nbytes, cb_struct.op_data))) || + !cb_struct.func) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure") *nbytes = *buf_size; @@ -1419,7 +1394,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_filter_info * @@ -1432,8 +1406,8 @@ done: H5Z_filter_info_t * H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) { - size_t idx; /* Index of filter in pipeline */ - H5Z_filter_info_t *ret_value = NULL; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + H5Z_filter_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1456,7 +1430,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_info() */ - /*------------------------------------------------------------------------- * Function: H5Z_filter_in_pline * @@ -1471,8 +1444,8 @@ done: htri_t H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) { - size_t idx; /* Index of filter in pipeline */ - htri_t ret_value = TRUE; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1492,8 +1465,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_in_pline() */ - - /*------------------------------------------------------------------------- * Function: H5Z_all_filters_avail * @@ -1507,8 +1478,8 @@ done: htri_t H5Z_all_filters_avail(const H5O_pline_t *pline) { - size_t i, j; /* Local index variable */ - htri_t ret_value = TRUE; /* Return value */ + size_t i, j; /* Local index variable */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1531,7 +1502,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_all_filters_avail() */ - /*------------------------------------------------------------------------- * Function: H5Z_delete * @@ -1564,8 +1534,8 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) } /* Delete filter */ else { - size_t idx; /* Index of filter in pipeline */ - hbool_t found = FALSE; /* Indicate filter was found in pipeline */ + size_t idx; /* Index of filter in pipeline */ + hbool_t found = FALSE; /* Indicate filter was found in pipeline */ /* Locate the filter in the pipeline */ for (idx = 0; idx < pline->nused; idx++) @@ -1611,7 +1581,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_delete() */ - /*------------------------------------------------------------------------- * Function: H5Zget_filter_info * @@ -1638,7 +1607,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Zget_filter_info() */ - /*------------------------------------------------------------------------- * Function: H5Z_get_filter_info * @@ -1674,4 +1642,3 @@ H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_get_filter_info() */ - diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index 6d7b87e..8be79ae 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -16,42 +16,40 @@ * Friday, August 27, 1999 */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_FILTER_DEFLATE #if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) -# define H5_ZLIB_HEADER "zlib.h" +#define H5_ZLIB_HEADER "zlib.h" #endif #if defined(H5_ZLIB_HEADER) -# include H5_ZLIB_HEADER /* "zlib.h" */ +#include H5_ZLIB_HEADER /* "zlib.h" */ #endif /* Local function prototypes */ -static size_t H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_deflate(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DEFLATE[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DEFLATE, /* Filter id number */ - 1, /* encoder_present flag (set to true) */ - 1, /* decoder_present flag (set to true) */ - "deflate", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - H5Z_filter_deflate, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DEFLATE, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ + "deflate", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z_filter_deflate, /* The actual filter function */ }}; #define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * (double)1.001f) + 12) - /*------------------------------------------------------------------------- * Function: H5Z_filter_deflate * @@ -69,13 +67,12 @@ const H5Z_class2_t H5Z_DEFLATE[1] = {{ *------------------------------------------------------------------------- */ static size_t -H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_deflate(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf) { - void *outbuf = NULL; /* Pointer to new buffer */ - int status; /* Status from zlib operation */ - size_t ret_value = 0; /* Return value */ + void * outbuf = NULL; /* Pointer to new buffer */ + int status; /* Status from zlib operation */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -85,122 +82,122 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, HDassert(*buf); /* Check arguments */ - if (cd_nelmts!=1 || cd_values[0]>9) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level") + if (cd_nelmts != 1 || cd_values[0] > 9) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level") if (flags & H5Z_FLAG_REVERSE) { - /* Input; uncompress */ - z_stream z_strm; /* zlib parameters */ - size_t nalloc = *buf_size; /* Number of bytes for output (compressed) buffer */ + /* Input; uncompress */ + z_stream z_strm; /* zlib parameters */ + size_t nalloc = *buf_size; /* Number of bytes for output (compressed) buffer */ /* 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") + if (NULL == (outbuf = H5MM_malloc(nalloc))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression") /* Set the uncompression parameters */ - HDmemset(&z_strm, 0, sizeof(z_strm)); - z_strm.next_in = (Bytef *)*buf; + HDmemset(&z_strm, 0, sizeof(z_strm)); + z_strm.next_in = (Bytef *)*buf; H5_CHECKED_ASSIGN(z_strm.avail_in, unsigned, nbytes, size_t); - z_strm.next_out = (Bytef *)outbuf; + z_strm.next_out = (Bytef *)outbuf; H5_CHECKED_ASSIGN(z_strm.avail_out, unsigned, nalloc, size_t); /* Initialize the uncompression routines */ - if (Z_OK!=inflateInit(&z_strm)) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflateInit() failed") + if (Z_OK != inflateInit(&z_strm)) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflateInit() failed") /* Loop to uncompress the buffer */ - do { + do { /* Uncompress some data */ - status = inflate(&z_strm, Z_SYNC_FLUSH); + status = inflate(&z_strm, Z_SYNC_FLUSH); /* Check if we are done uncompressing data */ - if (Z_STREAM_END==status) - break; /*done*/ + if (Z_STREAM_END == status) + break; /*done*/ /* Check for error */ - if (Z_OK!=status) { - (void)inflateEnd(&z_strm); - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflate() failed") - } + if (Z_OK != status) { + (void)inflateEnd(&z_strm); + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflate() failed") + } else { /* If we're not done and just ran out of buffer space, get more */ - if(0 == z_strm.avail_out) { - void *new_outbuf; /* Pointer to new output buffer */ + if (0 == z_strm.avail_out) { + void *new_outbuf; /* Pointer to new output buffer */ /* Allocate a buffer twice as big */ nalloc *= 2; - if(NULL == (new_outbuf = H5MM_realloc(outbuf, nalloc))) { + if (NULL == (new_outbuf = H5MM_realloc(outbuf, nalloc))) { (void)inflateEnd(&z_strm); - 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") } /* end if */ outbuf = new_outbuf; /* Update pointers to buffer for next set of uncompressed data */ - z_strm.next_out = (unsigned char*)outbuf + z_strm.total_out; + z_strm.next_out = (unsigned char *)outbuf + z_strm.total_out; z_strm.avail_out = (uInt)(nalloc - z_strm.total_out); } /* end if */ - } /* end else */ - } while(status==Z_OK); + } /* end else */ + } while (status == Z_OK); /* Free the input buffer */ - H5MM_xfree(*buf); + H5MM_xfree(*buf); /* Set return values */ - *buf = outbuf; - outbuf = NULL; - *buf_size = nalloc; - ret_value = z_strm.total_out; + *buf = outbuf; + outbuf = NULL; + *buf_size = nalloc; + ret_value = z_strm.total_out; /* Finish uncompressing the stream */ - (void)inflateEnd(&z_strm); + (void)inflateEnd(&z_strm); } /* end if */ else { - /* - * Output; compress but fail if the result would be larger than the - * input. The library doesn't provide in-place compression, so we - * must allocate a separate buffer for the result. - */ - const Bytef *z_src = (const Bytef*)(*buf); - Bytef *z_dst; /*destination buffer */ - uLongf z_dst_nbytes = (uLongf)H5Z_DEFLATE_SIZE_ADJUST(nbytes); - uLong z_src_nbytes = (uLong)nbytes; - int aggression; /* Compression aggression setting */ + /* + * Output; compress but fail if the result would be larger than the + * input. The library doesn't provide in-place compression, so we + * must allocate a separate buffer for the result. + */ + const Bytef *z_src = (const Bytef *)(*buf); + Bytef * z_dst; /*destination buffer */ + uLongf z_dst_nbytes = (uLongf)H5Z_DEFLATE_SIZE_ADJUST(nbytes); + uLong z_src_nbytes = (uLong)nbytes; + int aggression; /* Compression aggression setting */ /* Set the compression aggression level */ H5_CHECKED_ASSIGN(aggression, int, cd_values[0], unsigned); /* Allocate output (compressed) buffer */ - if(NULL == (outbuf = H5MM_malloc(z_dst_nbytes))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer") + if (NULL == (outbuf = H5MM_malloc(z_dst_nbytes))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer") z_dst = (Bytef *)outbuf; /* Perform compression from the source to the destination buffer */ - status = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); + 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 */ - H5MM_xfree(*buf); + H5MM_xfree(*buf); /* Set return values */ - *buf = outbuf; - outbuf = NULL; - *buf_size = nbytes; - ret_value = z_dst_nbytes; - } /* end else */ - } /* end else */ + *buf = outbuf; + outbuf = NULL; + *buf_size = nbytes; + ret_value = z_dst_nbytes; + } /* end else */ + } /* end else */ done: - if(outbuf) + if (outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_FILTER_DEFLATE */ - diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index c40e9b4..f4119ac 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -16,34 +16,32 @@ * Jan 3, 2003 */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Zpkg.h" /* Data filters */ /* Local function prototypes */ -static size_t H5Z_filter_fletcher32 (unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_fletcher32(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_FLETCHER32[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_FLETCHER32, /* Filter id number */ - 1, /* encoder_present flag (set to true) */ - 1, /* decoder_present flag (set to true) */ - "fletcher32", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - H5Z_filter_fletcher32, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_FLETCHER32, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ + "fletcher32", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z_filter_fletcher32, /* The actual filter function */ }}; -#define FLETCHER_LEN 4 +#define FLETCHER_LEN 4 - /*------------------------------------------------------------------------- * Function: H5Z_filter_fletcher32 * @@ -69,32 +67,32 @@ const H5Z_class2_t H5Z_FLETCHER32[1] = {{ *------------------------------------------------------------------------- */ static size_t -H5Z_filter_fletcher32 (unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const unsigned H5_ATTR_UNUSED cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z_filter_fletcher32(unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned H5_ATTR_UNUSED cd_values[], size_t nbytes, size_t *buf_size, void **buf) { - void *outbuf = NULL; /* Pointer to new buffer */ - unsigned char *src = (unsigned char*)(*buf); - uint32_t fletcher; /* Checksum value */ - uint32_t reversed_fletcher; /* Possible wrong checksum value */ - uint8_t c[4]; - uint8_t tmp; - size_t ret_value = 0; /* Return value */ + void * outbuf = NULL; /* Pointer to new buffer */ + unsigned char *src = (unsigned char *)(*buf); + uint32_t fletcher; /* Checksum value */ + uint32_t reversed_fletcher; /* Possible wrong checksum value */ + uint8_t c[4]; + uint8_t tmp; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) - HDassert(sizeof(uint32_t)>=4); + HDassert(sizeof(uint32_t) >= 4); if (flags & H5Z_FLAG_REVERSE) { /* Read */ /* Do checksum if it's enabled for read; otherwise skip it * to save performance. */ if (!(flags & H5Z_FLAG_SKIP_EDC)) { unsigned char *tmp_src; /* Pointer to checksum in buffer */ - size_t src_nbytes = nbytes; /* Original number of bytes */ - uint32_t stored_fletcher; /* Stored checksum value */ + size_t src_nbytes = nbytes; /* Original number of bytes */ + uint32_t stored_fletcher; /* Stored checksum value */ /* Get the stored checksum */ src_nbytes -= FLETCHER_LEN; - tmp_src=src+src_nbytes; + tmp_src = src + src_nbytes; UINT32DECODE(tmp_src, stored_fletcher); /* Compute checksum (can't fail) */ @@ -121,44 +119,45 @@ H5Z_filter_fletcher32 (unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const un H5MM_memcpy(&reversed_fletcher, c, (size_t)4); /* Verify computed checksum matches stored checksum */ - if(stored_fletcher != fletcher && stored_fletcher != reversed_fletcher) - HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum") + if (stored_fletcher != fletcher && stored_fletcher != reversed_fletcher) + HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum") } /* Set return values */ /* (Re-use the input buffer, just note that the size is smaller by the size of the checksum) */ - ret_value = nbytes-FLETCHER_LEN; - } else { /* Write */ - unsigned char *dst; /* Temporary pointer to destination buffer */ + ret_value = nbytes - FLETCHER_LEN; + } + else { /* Write */ + unsigned char *dst; /* Temporary pointer to destination buffer */ /* Compute checksum (can't fail) */ fletcher = H5_checksum_fletcher32(src, nbytes); - if (NULL == (outbuf = H5MM_malloc(nbytes + FLETCHER_LEN))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate Fletcher32 checksum destination buffer") + if (NULL == (outbuf = H5MM_malloc(nbytes + FLETCHER_LEN))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, + "unable to allocate Fletcher32 checksum destination buffer") - dst = (unsigned char *) outbuf; + dst = (unsigned char *)outbuf; /* Copy raw data */ - H5MM_memcpy((void*)dst, (void*)(*buf), nbytes); + H5MM_memcpy((void *)dst, (void *)(*buf), nbytes); /* Append checksum to raw data for storage */ dst += nbytes; UINT32ENCODE(dst, fletcher); /* Free input buffer */ - H5MM_xfree(*buf); + H5MM_xfree(*buf); /* Set return values */ *buf_size = nbytes + FLETCHER_LEN; - *buf = outbuf; - outbuf = NULL; - ret_value = *buf_size; + *buf = outbuf; + outbuf = NULL; + ret_value = *buf_size; } done: - if(outbuf) + if (outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Zmodule.h b/src/H5Zmodule.h index 97e158c..c636f82 100644 --- a/src/H5Zmodule.h +++ b/src/H5Zmodule.h @@ -25,9 +25,8 @@ * reporting macros. */ #define H5Z_MODULE -#define H5_MY_PKG H5Z -#define H5_MY_PKG_ERR H5E_PLINE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5Z +#define H5_MY_PKG_ERR H5E_PLINE +#define H5_MY_PKG_INIT YES #endif /* _H5Zmodule_H */ - diff --git a/src/H5Znbit.c b/src/H5Znbit.c index 8c0e876..7a8a88c 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -11,103 +11,102 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property lists */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Zpkg.h" /* Data filters */ /* Struct of parameters needed for compressing/decompressing * one nbit atomic datatype: integer or floating-point */ typedef struct { - unsigned size; /* size of datatype */ - unsigned order; /* datatype endianness order */ - unsigned precision; /* datatype precision */ - unsigned offset; /* datatype offset */ + unsigned size; /* size of datatype */ + unsigned order; /* datatype endianness order */ + unsigned precision; /* datatype precision */ + unsigned offset; /* datatype offset */ } parms_atomic; /* Local function prototypes */ static htri_t H5Z_can_apply_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id); static herr_t H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf); -static void H5Z_calc_parms_nooptype(size_t *cd_values_actual_nparms); -static void H5Z_calc_parms_atomic(size_t *cd_values_actual_nparms); +static void H5Z_calc_parms_nooptype(size_t *cd_values_actual_nparms); +static void H5Z_calc_parms_atomic(size_t *cd_values_actual_nparms); static herr_t H5Z_calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms); static herr_t H5Z_calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms); -static herr_t H5Z_set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[]); -static herr_t H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress); -static herr_t H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress); -static herr_t H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress); +static herr_t H5Z_set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[]); +static herr_t H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress); +static herr_t H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress); +static herr_t H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress); static void H5Z_nbit_next_byte(size_t *j, size_t *buf_len); -static void H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, - size_t *buf_len, const parms_atomic *p, size_t datatype_len); +static void H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, + unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, + size_t *buf_len, const parms_atomic *p, size_t datatype_len); static void H5Z_nbit_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, - unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p, size_t datatype_len); -static void H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); -static void H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p); -static herr_t H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index); + unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, + const parms_atomic *p, size_t datatype_len); +static void H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, unsigned size); +static void H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const parms_atomic *p); +static herr_t H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const unsigned parms[], + unsigned *parms_index); static herr_t H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index); + unsigned char *buffer, size_t *j, size_t *buf_len, + const unsigned parms[], unsigned *parms_index); static herr_t H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - const unsigned parms[]); -static void H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); -static void H5Z_nbit_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p); -static void H5Z_nbit_compress_one_array(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index); -static void H5Z_nbit_compress_one_compound(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index); -static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t *buffer_size, const unsigned parms[]); + const unsigned parms[]); +static void H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, unsigned size); +static void H5Z_nbit_compress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const parms_atomic *p); +static void H5Z_nbit_compress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const unsigned parms[], + unsigned *parms_index); +static void H5Z_nbit_compress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const unsigned parms[], + unsigned *parms_index); +static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, + size_t *buffer_size, const unsigned parms[]); /* This message derives from H5Z */ H5Z_class2_t H5Z_NBIT[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_NBIT, /* Filter id number */ - 1, /* Assume encoder present: check before registering */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_NBIT, /* Filter id number */ + 1, /* Assume encoder present: check before registering */ 1, /* decoder_present flag (set to true) */ - "nbit", /* Filter name for debugging */ - H5Z_can_apply_nbit, /* The "can apply" callback */ - H5Z_set_local_nbit, /* The "set local" callback */ - H5Z_filter_nbit, /* The actual filter function */ + "nbit", /* Filter name for debugging */ + H5Z_can_apply_nbit, /* The "can apply" callback */ + H5Z_set_local_nbit, /* The "set local" callback */ + H5Z_filter_nbit, /* The actual filter function */ }}; /* Local macros */ -#define H5Z_NBIT_ATOMIC 1 /* Atomic datatype class: integer/floating-point */ -#define H5Z_NBIT_ARRAY 2 /* Array datatype class */ -#define H5Z_NBIT_COMPOUND 3 /* Compound datatype class */ -#define H5Z_NBIT_NOOPTYPE 4 /* Other datatype class: nbit does no compression */ -#define H5Z_NBIT_MAX_NPARMS 4096 /* Max number of parameters for filter */ -#define H5Z_NBIT_ORDER_LE 0 /* Little endian for datatype byte order */ -#define H5Z_NBIT_ORDER_BE 1 /* Big endian for datatype byte order */ +#define H5Z_NBIT_ATOMIC 1 /* Atomic datatype class: integer/floating-point */ +#define H5Z_NBIT_ARRAY 2 /* Array datatype class */ +#define H5Z_NBIT_COMPOUND 3 /* Compound datatype class */ +#define H5Z_NBIT_NOOPTYPE 4 /* Other datatype class: nbit does no compression */ +#define H5Z_NBIT_MAX_NPARMS 4096 /* Max number of parameters for filter */ +#define H5Z_NBIT_ORDER_LE 0 /* Little endian for datatype byte order */ +#define H5Z_NBIT_ORDER_BE 1 /* Big endian for datatype byte order */ /* Local variables */ - /*------------------------------------------------------------------------- * Function: H5Z_can_apply_nbit * @@ -127,28 +126,27 @@ H5Z_class2_t H5Z_NBIT[1] = {{ static htri_t H5Z_can_apply_nbit(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - const H5T_t *type; /* Datatype */ - htri_t ret_value = TRUE; /* Return value */ + const H5T_t *type; /* Datatype */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class, for checking the "datatype class" */ - if(H5T_get_class(type, TRUE) == H5T_NO_CLASS) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") + if (H5T_get_class(type, TRUE) == H5T_NO_CLASS) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Get datatype's size, for checking the "datatype size" */ - if(H5T_get_size(type) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if (H5T_get_size(type) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply_nbit() */ - /*------------------------------------------------------------------------- * Function: H5Z_calc_parms_nooptype * @@ -173,7 +171,6 @@ H5Z_calc_parms_nooptype(size_t *cd_values_actual_nparms) *cd_values_actual_nparms += 1; } - /*------------------------------------------------------------------------- * Function: H5Z_calc_parms_atomic * @@ -207,7 +204,6 @@ H5Z_calc_parms_atomic(size_t *cd_values_actual_nparms) *cd_values_actual_nparms += 1; } - /*------------------------------------------------------------------------- * Function: H5Z_calc_parms_array * @@ -228,9 +224,9 @@ H5Z_calc_parms_atomic(size_t *cd_values_actual_nparms) static herr_t H5Z_calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms) { - H5T_t *dtype_base = NULL; /* Array datatype's base datatype */ - H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * dtype_base = NULL; /* Array datatype's base datatype */ + H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -241,27 +237,27 @@ H5Z_calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms) *cd_values_actual_nparms += 1; /* Get array datatype's base datatype */ - if(NULL == (dtype_base = H5T_get_super(type))) + if (NULL == (dtype_base = H5T_get_super(type))) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad base datatype") /* Get base datatype's class */ - if((dtype_base_class = H5T_get_class(dtype_base, TRUE)) == H5T_NO_CLASS) + if ((dtype_base_class = H5T_get_class(dtype_base, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad base datatype class") /* Calculate number of the rest parameters according to base datatype's class */ - switch(dtype_base_class) { + switch (dtype_base_class) { case H5T_INTEGER: case H5T_FLOAT: H5Z_calc_parms_atomic(cd_values_actual_nparms); break; case H5T_ARRAY: - if(H5Z_calc_parms_array(dtype_base, cd_values_actual_nparms) == FAIL) + if (H5Z_calc_parms_array(dtype_base, cd_values_actual_nparms) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; case H5T_COMPOUND: - if(H5Z_calc_parms_compound(dtype_base, cd_values_actual_nparms) == FAIL) + if (H5Z_calc_parms_compound(dtype_base, cd_values_actual_nparms) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; @@ -285,14 +281,13 @@ H5Z_calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms) } /* end switch */ done: - if(dtype_base) - if(H5T_close_real(dtype_base) < 0) + if (dtype_base) + if (H5T_close_real(dtype_base) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close base datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_calc_parms_array() */ - /*------------------------------------------------------------------------- * Function: H5Z_calc_parms_compound * @@ -313,10 +308,10 @@ done: static herr_t H5Z_calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms) { - int nmembers; /* Compound datatype's number of members */ - H5T_t *dtype_member = NULL; /* Compound datatype's member datatype */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + int nmembers; /* Compound datatype's number of members */ + H5T_t * dtype_member = NULL; /* Compound datatype's member datatype */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -327,41 +322,41 @@ H5Z_calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms) *cd_values_actual_nparms += 1; /* Get number of members */ - if((nmembers = H5T_get_nmembers(type)) < 0) + if ((nmembers = H5T_get_nmembers(type)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype number of members") /* Store number of members */ *cd_values_actual_nparms += 1; /* For each member, calculate parameters */ - for(u = 0; u < (unsigned)nmembers; u++) { + for (u = 0; u < (unsigned)nmembers; u++) { H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */ /* Get member datatype */ - if(NULL == (dtype_member = H5T_get_member_type(type, u))) + if (NULL == (dtype_member = H5T_get_member_type(type, u))) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype") /* Get member datatype's class */ - if((dtype_member_class = H5T_get_class(dtype_member, TRUE)) == H5T_NO_CLASS) + if ((dtype_member_class = H5T_get_class(dtype_member, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype class") /* Store member offset */ *cd_values_actual_nparms += 1; /* Calculate parameters according to member's datatype class */ - switch(dtype_member_class) { + switch (dtype_member_class) { case H5T_INTEGER: case H5T_FLOAT: H5Z_calc_parms_atomic(cd_values_actual_nparms); break; case H5T_ARRAY: - if(H5Z_calc_parms_array(dtype_member, cd_values_actual_nparms) == FAIL) + if (H5Z_calc_parms_array(dtype_member, cd_values_actual_nparms) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; case H5T_COMPOUND: - if(H5Z_calc_parms_compound(dtype_member, cd_values_actual_nparms) == FAIL) + if (H5Z_calc_parms_compound(dtype_member, cd_values_actual_nparms) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; @@ -385,20 +380,19 @@ H5Z_calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms) } /* end switch */ /* Close member datatype */ - if(H5T_close_real(dtype_member) < 0) + if (H5T_close_real(dtype_member) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") dtype_member = NULL; } /* end for */ done: - if(dtype_member) - if(H5T_close_real(dtype_member) < 0) + if (dtype_member) + if (H5T_close_real(dtype_member) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_calc_params_compound */ - /*------------------------------------------------------------------------- * Function: H5Z_set_parms_nooptype * @@ -429,8 +423,8 @@ H5Z_set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, unsigned cd cd_values[(*cd_values_index)++] = H5Z_NBIT_NOOPTYPE; /* Get datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if ((dtype_size = H5T_get_size(type)) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for datatype size */ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned); @@ -440,7 +434,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_parms_nooptype() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_parms_atomic * @@ -458,15 +451,15 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress) +H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress) { - H5T_order_t dtype_order; /* Atomic datatype's endianness order */ - size_t dtype_size; /* Atomic datatype's size (in bytes) */ - size_t dtype_precision; /* Atomic datatype's precision (in bits) */ - int sdtype_offset; /* Atomic datatype's offset (in bits) */ - unsigned dtype_offset; /* Atomic datatype's offset (in bits) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_order_t dtype_order; /* Atomic datatype's endianness order */ + size_t dtype_size; /* Atomic datatype's size (in bytes) */ + size_t dtype_precision; /* Atomic datatype's precision (in bits) */ + int sdtype_offset; /* Atomic datatype's offset (in bits) */ + unsigned dtype_offset; /* Atomic datatype's offset (in bits) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -474,7 +467,7 @@ H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = H5Z_NBIT_ATOMIC; /* Get datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) + if ((dtype_size = H5T_get_size(type)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for datatype size */ @@ -482,16 +475,16 @@ H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = (unsigned)dtype_size; /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") /* Set "local" parameter for datatype endianness */ - switch(dtype_order) { - case H5T_ORDER_LE: /* Little-endian byte order */ + switch (dtype_order) { + case H5T_ORDER_LE: /* Little-endian byte order */ cd_values[(*cd_values_index)++] = H5Z_NBIT_ORDER_LE; break; - case H5T_ORDER_BE: /* Big-endian byte order */ + case H5T_ORDER_BE: /* Big-endian byte order */ cd_values[(*cd_values_index)++] = H5Z_NBIT_ORDER_BE; break; @@ -504,16 +497,16 @@ H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, } /* end switch */ /* Get datatype's precision */ - if((dtype_precision = H5T_get_precision(type)) == 0) + if ((dtype_precision = H5T_get_precision(type)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision") /* Get datatype's offset */ - if((sdtype_offset = H5T_get_offset(type)) < 0) + if ((sdtype_offset = H5T_get_offset(type)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype offset") dtype_offset = (unsigned)sdtype_offset; /* Check values of precision and offset */ - if(dtype_precision > dtype_size * 8 || (dtype_precision + dtype_offset) > dtype_size * 8) + if (dtype_precision > dtype_size * 8 || (dtype_precision + dtype_offset) > dtype_size * 8) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") /* Set "local" parameter for datatype precision */ @@ -527,14 +520,13 @@ H5Z_set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, * compress at this point. If current datatype is not full-precision, * flag need_not_compress should be set to FALSE. */ - if(*need_not_compress) /* so far no need to compress */ - if(dtype_offset != 0 || dtype_precision != dtype_size * 8) - *need_not_compress = FALSE; + if (*need_not_compress) /* so far no need to compress */ + if (dtype_offset != 0 || dtype_precision != dtype_size * 8) + *need_not_compress = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_parms_atomic() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_parms_array * @@ -552,14 +544,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress) +H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress) { - H5T_t *dtype_base = NULL; /* Array datatype's base datatype */ - H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */ - size_t dtype_size; /* Array datatype's size (in bytes) */ - htri_t is_vlstring; /* flag indicating if datatype is variable-length string */ - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t * dtype_base = NULL; /* Array datatype's base datatype */ + H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */ + size_t dtype_size; /* Array datatype's size (in bytes) */ + htri_t is_vlstring; /* flag indicating if datatype is variable-length string */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -567,49 +559,50 @@ H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = H5Z_NBIT_ARRAY; /* Get array datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if ((dtype_size = H5T_get_size(type)) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for array datatype's size */ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned); cd_values[(*cd_values_index)++] = (unsigned)dtype_size; /* Get array datatype's base datatype */ - if(NULL == (dtype_base = H5T_get_super(type))) + if (NULL == (dtype_base = H5T_get_super(type))) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad base datatype") /* Get base datatype's class */ - if((dtype_base_class = H5T_get_class(dtype_base, TRUE)) == H5T_NO_CLASS) + if ((dtype_base_class = H5T_get_class(dtype_base, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad base datatype class") /* Call appropriate function according to base datatype's class */ - switch(dtype_base_class) { + switch (dtype_base_class) { case H5T_INTEGER: case H5T_FLOAT: - if(H5Z_set_parms_atomic(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z_set_parms_atomic(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_ARRAY: - if(H5Z_set_parms_array(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z_set_parms_array(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_COMPOUND: - if(H5Z_set_parms_compound(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z_set_parms_compound(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_VLEN: /* Check if base datatype is a variable-length string */ - if((is_vlstring = H5T_is_variable_str(dtype_base)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot determine if datatype is a variable-length string") + if ((is_vlstring = H5T_is_variable_str(dtype_base)) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, + "cannot determine if datatype is a variable-length string") /* base datatype of VL or VL-string is not supported */ - if(dtype_base_class == H5T_VLEN || is_vlstring) + if (dtype_base_class == H5T_VLEN || is_vlstring) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "datatype not supported by nbit") - if(H5Z_set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0) + if (H5Z_set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; @@ -619,7 +612,7 @@ H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index, case H5T_OPAQUE: case H5T_REFERENCE: case H5T_ENUM: - if(H5Z_set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0) + if (H5Z_set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; @@ -632,14 +625,13 @@ H5Z_set_parms_array(const H5T_t *type, unsigned *cd_values_index, } /* end switch */ done: - if(dtype_base) - if(H5T_close_real(dtype_base) < 0) + if (dtype_base) + if (H5T_close_real(dtype_base) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close base datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_parms_array() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_parms_compound * @@ -657,19 +649,19 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress) +H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress) { - int snmembers; /* Compound datatype's number of members */ - unsigned nmembers; /* Compound datatype's number of members */ - H5T_t *dtype_member = NULL; /* Compound datatype's member datatype */ - H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */ - size_t dtype_member_offset; /* Compound datatype's current member datatype's offset (in bytes) */ - size_t dtype_next_member_offset;/* Compound datatype's next member datatype's offset (in bytes) */ - size_t dtype_size; /* Compound datatype's size (in bytes) */ - htri_t is_vlstring; /* flag indicating if datatype is variable-length string */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + int snmembers; /* Compound datatype's number of members */ + unsigned nmembers; /* Compound datatype's number of members */ + H5T_t * dtype_member = NULL; /* Compound datatype's member datatype */ + H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */ + size_t dtype_member_offset; /* Compound datatype's current member datatype's offset (in bytes) */ + size_t dtype_next_member_offset; /* Compound datatype's next member datatype's offset (in bytes) */ + size_t dtype_size; /* Compound datatype's size (in bytes) */ + htri_t is_vlstring; /* flag indicating if datatype is variable-length string */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -677,15 +669,15 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = H5Z_NBIT_COMPOUND; /* Get datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if ((dtype_size = H5T_get_size(type)) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for compound datatype size */ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned); cd_values[(*cd_values_index)++] = (unsigned)dtype_size; /* Get number of members */ - if((snmembers = H5T_get_nmembers(type)) < 0) + if ((snmembers = H5T_get_nmembers(type)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype number of members") nmembers = (unsigned)snmembers; @@ -693,44 +685,45 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = nmembers; /* For each member, set parameters */ - for(u = 0; u < nmembers; u++) { + for (u = 0; u < nmembers; u++) { /* Get member datatype */ - if(NULL == (dtype_member = H5T_get_member_type(type, u))) + if (NULL == (dtype_member = H5T_get_member_type(type, u))) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype") /* Get member datatype's class */ - if((dtype_member_class = H5T_get_class(dtype_member, TRUE)) < 0) + if ((dtype_member_class = H5T_get_class(dtype_member, TRUE)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype class") /* Get member offset, success if H5T_get_class() success */ - dtype_member_offset = H5T_get_member_offset(type, u); + dtype_member_offset = H5T_get_member_offset(type, u); /* Set "local" parameter for member offset */ H5_CHECK_OVERFLOW(dtype_member_offset, size_t, unsigned); cd_values[(*cd_values_index)++] = (unsigned)dtype_member_offset; /* Call appropriate function according to member's datatype class */ - switch(dtype_member_class) { + switch (dtype_member_class) { case H5T_INTEGER: case H5T_FLOAT: - if(H5Z_set_parms_atomic(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z_set_parms_atomic(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_ARRAY: - if(H5Z_set_parms_array(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z_set_parms_array(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_COMPOUND: - if(H5Z_set_parms_compound(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z_set_parms_compound(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_VLEN: /* Check if datatype is a variable-length string */ - if((is_vlstring = H5T_is_variable_str(dtype_member)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot determine if datatype is a variable-length string") + if ((is_vlstring = H5T_is_variable_str(dtype_member)) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, + "cannot determine if datatype is a variable-length string") /* Because for some no-op datatype (VL datatype and VL string datatype), its * size can not be retrieved correctly by using function call H5T_get_size, @@ -738,11 +731,11 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, * adjacent member offset is used (if alignment is present, the result can be * larger, but it does not affect the nbit filter's correctness). */ - if(dtype_member_class == H5T_VLEN || is_vlstring) { + if (dtype_member_class == H5T_VLEN || is_vlstring) { /* Set datatype class code */ cd_values[(*cd_values_index)++] = H5Z_NBIT_NOOPTYPE; - if(u != nmembers - 1) + if (u != nmembers - 1) dtype_next_member_offset = H5T_get_member_offset(type, u + 1); else /* current member is the last member */ dtype_next_member_offset = dtype_size; @@ -750,7 +743,8 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, /* Set "local" parameter for datatype size */ H5_CHECK_OVERFLOW(dtype_member_offset, size_t, unsigned); H5_CHECK_OVERFLOW(dtype_next_member_offset, size_t, unsigned); - cd_values[(*cd_values_index)++] = (unsigned)dtype_next_member_offset - (unsigned)dtype_member_offset; + cd_values[(*cd_values_index)++] = + (unsigned)dtype_next_member_offset - (unsigned)dtype_member_offset; } break; @@ -761,7 +755,7 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, case H5T_REFERENCE: case H5T_ENUM: /* other datatype that nbit does no compression */ - if(H5Z_set_parms_nooptype(dtype_member, cd_values_index, cd_values) < 0) + if (H5Z_set_parms_nooptype(dtype_member, cd_values_index, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; @@ -774,20 +768,19 @@ H5Z_set_parms_compound(const H5T_t *type, unsigned *cd_values_index, } /* end switch */ /* Close member datatype */ - if(H5T_close_real(dtype_member) < 0) + if (H5T_close_real(dtype_member) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") dtype_member = NULL; } /* end for */ done: - if(dtype_member) - if(H5T_close_real(dtype_member) < 0) + if (dtype_member) + if (H5T_close_real(dtype_member) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_params_compound */ - /*------------------------------------------------------------------------- * Function: H5Z_set_local_nbit * @@ -806,28 +799,28 @@ done: static herr_t H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - H5P_genplist_t *dcpl_plist; /* Property list pointer */ - const H5T_t *type; /* Datatype */ - const H5S_t *ds; /* Dataspace */ - unsigned flags; /* Filter flags */ - unsigned cd_values_index; /* Index of array cd_values */ - size_t cd_values_actual_nparms; /* Number of parameters in array cd_values[] */ - size_t cd_nelmts = H5Z_NBIT_USER_NPARMS; /* Number of filter parameters */ - unsigned *cd_values = NULL; /* Filter parameters */ - hssize_t npoints; /* Number of points in the dataspace */ - H5T_class_t dtype_class; /* Datatype's class */ - hbool_t need_not_compress; /* Flag if TRUE indicating no need to do nbit compression */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dcpl_plist; /* Property list pointer */ + const H5T_t * type; /* Datatype */ + const H5S_t * ds; /* Dataspace */ + unsigned flags; /* Filter flags */ + unsigned cd_values_index; /* Index of array cd_values */ + size_t cd_values_actual_nparms; /* Number of parameters in array cd_values[] */ + size_t cd_nelmts = H5Z_NBIT_USER_NPARMS; /* Number of filter parameters */ + unsigned * cd_values = NULL; /* Filter parameters */ + hssize_t npoints; /* Number of points in the dataspace */ + H5T_class_t dtype_class; /* Datatype's class */ + hbool_t need_not_compress; /* Flag if TRUE indicating no need to do nbit compression */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class */ - if((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") + if ((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Calculate how many parameters will fill the cd_values array * First three parameters reserved for: @@ -836,19 +829,19 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) * 3. number of elements in the chunk */ cd_values_actual_nparms = 3; - switch(dtype_class) { + switch (dtype_class) { case H5T_INTEGER: case H5T_FLOAT: H5Z_calc_parms_atomic(&cd_values_actual_nparms); break; case H5T_ARRAY: - if(H5Z_calc_parms_array(type, &cd_values_actual_nparms) < 0) + if (H5Z_calc_parms_array(type, &cd_values_actual_nparms) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; case H5T_COMPOUND: - if(H5Z_calc_parms_compound(type, &cd_values_actual_nparms) < 0) + if (H5Z_calc_parms_compound(type, &cd_values_actual_nparms) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; @@ -871,27 +864,28 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) } /* end switch */ /* Check if the number of parameters exceed what cd_values[] can store */ - if(cd_values_actual_nparms > H5Z_NBIT_MAX_NPARMS) + if (cd_values_actual_nparms > H5Z_NBIT_MAX_NPARMS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "datatype needs too many nbit parameters") /* Allocate memory space for cd_values[] */ - if(NULL == (cd_values = (unsigned *)H5MM_malloc(cd_values_actual_nparms * sizeof(unsigned)))) + if (NULL == (cd_values = (unsigned *)H5MM_malloc(cd_values_actual_nparms * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for cd_values[]") /* Get the plist structure */ - if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the filter's current parameters */ - if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_NBIT, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get nbit parameters") + if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_NBIT, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, + NULL) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get nbit parameters") /* Get dataspace */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Get total number of elements in the chunk */ - if((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) + if ((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get number of points in the dataspace") HDassert(npoints); @@ -906,20 +900,20 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) need_not_compress = TRUE; /* Call appropriate function according to the datatype class */ - switch(dtype_class) { + switch (dtype_class) { case H5T_INTEGER: case H5T_FLOAT: - if(H5Z_set_parms_atomic(type, &cd_values_index, cd_values, &need_not_compress) < 0) + if (H5Z_set_parms_atomic(type, &cd_values_index, cd_values, &need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_ARRAY: - if(H5Z_set_parms_array(type, &cd_values_index, cd_values, &need_not_compress) < 0) + if (H5Z_set_parms_array(type, &cd_values_index, cd_values, &need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_COMPOUND: - if(H5Z_set_parms_compound(type, &cd_values_index, cd_values, &need_not_compress) < 0) + if (H5Z_set_parms_compound(type, &cd_values_index, cd_values, &need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; @@ -950,17 +944,16 @@ H5Z_set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) cd_values[1] = (unsigned)need_not_compress; /* Modify the filter's parameters for this dataset */ - if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_NBIT, flags, cd_values_actual_nparms, cd_values) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local nbit parameters") + if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_NBIT, flags, cd_values_actual_nparms, cd_values) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local nbit parameters") done: - if(cd_values) - H5MM_xfree(cd_values); + if (cd_values) + H5MM_xfree(cd_values); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local_nbit() */ - /*------------------------------------------------------------------------- * Function: H5Z_filter_nbit * @@ -975,41 +968,41 @@ done: *------------------------------------------------------------------------- */ static size_t -H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, + void **buf) { - unsigned char *outbuf; /* pointer to new output buffer */ - size_t size_out = 0; /* size of output buffer */ - unsigned d_nelmts = 0; /* number of elements in the chunk */ - size_t ret_value = 0; /* return value */ + unsigned char *outbuf; /* pointer to new output buffer */ + size_t size_out = 0; /* size of output buffer */ + unsigned d_nelmts = 0; /* number of elements in the chunk */ + size_t ret_value = 0; /* return value */ FUNC_ENTER_NOAPI_NOINIT /* check arguments * cd_values[0] stores actual number of parameters in cd_values[] */ - if(cd_nelmts != cd_values[0]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid nbit aggression level") + if (cd_nelmts != cd_values[0]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid nbit aggression level") /* check if need to do nbit compress or decompress * cd_values[1] stores the flag if true indicating no need to compress */ - if(cd_values[1]) + if (cd_values[1]) HGOTO_DONE(*buf_size) /* copy a filter parameter to d_nelmts */ d_nelmts = cd_values[2]; /* input; decompress */ - if(flags & H5Z_FLAG_REVERSE) { + if (flags & H5Z_FLAG_REVERSE) { size_out = d_nelmts * cd_values[4]; /* cd_values[4] stores datatype size */ /* allocate memory space for decompressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for nbit decompression") /* decompress the buffer */ - if(H5Z__nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values) < 0) + if (H5Z__nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, 0, "can't decompress buffer") } /* end if */ /* output; compress */ @@ -1019,7 +1012,7 @@ H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_out = nbytes; /* allocate memory space for compressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for nbit compression") /* compress the buffer, size_out will be changed */ @@ -1030,7 +1023,7 @@ H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], H5MM_xfree(*buf); /* set return values */ - *buf = outbuf; + *buf = outbuf; *buf_size = size_out; ret_value = size_out; @@ -1049,104 +1042,110 @@ done: static void H5Z_nbit_next_byte(size_t *j, size_t *buf_len) { - ++(*j); - *buf_len = 8 * sizeof(unsigned char); + ++(*j); + *buf_len = 8 * sizeof(unsigned char); } static void -H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, - unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, - const parms_atomic *p, size_t datatype_len) +H5Z_nbit_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, + unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, + const parms_atomic *p, size_t datatype_len) { - size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ - size_t dat_offset; - unsigned char val; /* value to be copied in each data byte */ - - /* initialize value and bits of unsigned char to be copied */ - val = buffer[*j]; - dat_offset = 0; - - if(begin_i != end_i) { /* significant bits occupy >1 unsigned char */ - if(k == begin_i) - dat_len = 8 - (datatype_len - p->precision - p->offset) % 8; - else if(k == end_i) { - dat_len = 8 - p->offset % 8; - dat_offset = 8 - dat_len; - } - else - dat_len = 8; - } else { /* all significant bits in one unsigned char */ - dat_offset = p->offset % 8; - dat_len = p->precision; - } - - if(*buf_len > dat_len) { - data[data_offset + k] = (unsigned char)( - ((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len))) << dat_offset); - *buf_len -= dat_len; - } else { - data[data_offset + k] = (unsigned char)( - ((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)) << dat_offset); - dat_len -= *buf_len; - H5Z_nbit_next_byte(j, buf_len); - if(dat_len == 0) - return; - - val = buffer[*j]; - data[data_offset + k] |= (unsigned char)( - ((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len))) << dat_offset); - *buf_len -= dat_len; - } + size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ + size_t dat_offset; + unsigned char val; /* value to be copied in each data byte */ + + /* initialize value and bits of unsigned char to be copied */ + val = buffer[*j]; + dat_offset = 0; + + if (begin_i != end_i) { /* significant bits occupy >1 unsigned char */ + if (k == begin_i) + dat_len = 8 - (datatype_len - p->precision - p->offset) % 8; + else if (k == end_i) { + dat_len = 8 - p->offset % 8; + dat_offset = 8 - dat_len; + } + else + dat_len = 8; + } + else { /* all significant bits in one unsigned char */ + dat_offset = p->offset % 8; + dat_len = p->precision; + } + + if (*buf_len > dat_len) { + data[data_offset + k] = (unsigned char)(((unsigned)(val >> (*buf_len - dat_len)) & + (unsigned)(~((unsigned)(~0) << dat_len))) + << dat_offset); + *buf_len -= dat_len; + } + else { + data[data_offset + k] = + (unsigned char)(((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)) << dat_offset); + dat_len -= *buf_len; + H5Z_nbit_next_byte(j, buf_len); + if (dat_len == 0) + return; + + val = buffer[*j]; + data[data_offset + k] |= (unsigned char)(((unsigned)(val >> (*buf_len - dat_len)) & + (unsigned)(~((unsigned)(~0) << dat_len))) + << dat_offset); + *buf_len -= dat_len; + } } static void -H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size) +H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, unsigned size) { - unsigned i; /* index */ - size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - for(i = 0; i < size; i++) { - /* initialize value and bits of unsigned char to be copied */ - val = buffer[*j]; - dat_len = sizeof(unsigned char) * 8; - - data[data_offset + i] = (unsigned char)(((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len))); - dat_len -= *buf_len; - H5Z_nbit_next_byte(j, buf_len); - if(dat_len == 0) - continue; - - val = buffer[*j]; - data[data_offset + i] |= (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len))); - *buf_len -= dat_len; - } + unsigned i; /* index */ + size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + for (i = 0; i < size; i++) { + /* initialize value and bits of unsigned char to be copied */ + val = buffer[*j]; + dat_len = sizeof(unsigned char) * 8; + + data[data_offset + i] = + (unsigned char)(((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len))); + dat_len -= *buf_len; + H5Z_nbit_next_byte(j, buf_len); + if (dat_len == 0) + continue; + + val = buffer[*j]; + data[data_offset + i] |= (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & + (unsigned)(~((unsigned)(~0) << dat_len))); + *buf_len -= dat_len; + } } static void -H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p) +H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const parms_atomic *p) { /* begin_i: the index of byte having first significant bit end_i: the index of byte having last significant bit */ - int k; + int k; unsigned begin_i, end_i; - size_t datatype_len; + size_t datatype_len; datatype_len = p->size * 8; - if(p->order == H5Z_NBIT_ORDER_LE) { /* little endian */ + if (p->order == H5Z_NBIT_ORDER_LE) { /* little endian */ /* calculate begin_i and end_i */ - if((p->precision + p->offset) % 8 != 0) - begin_i = (p->precision + p->offset) / 8; + if ((p->precision + p->offset) % 8 != 0) + begin_i = (p->precision + p->offset) / 8; else - begin_i = (p->precision + p->offset) / 8 - 1; + begin_i = (p->precision + p->offset) / 8 - 1; end_i = p->offset / 8; - for(k = (int)begin_i; k >= (int)end_i; k--) - H5Z_nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, - buffer, j, buf_len, p, datatype_len); + for (k = (int)begin_i; k >= (int)end_i; k--) + H5Z_nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, buffer, j, buf_len, + p, datatype_len); } else { /* big endian */ /* Sanity check */ @@ -1154,165 +1153,160 @@ H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, /* calculate begin_i and end_i */ begin_i = ((unsigned)datatype_len - p->precision - p->offset) / 8; - if(p->offset % 8 != 0) - end_i = ((unsigned)datatype_len - p->offset) / 8; + if (p->offset % 8 != 0) + end_i = ((unsigned)datatype_len - p->offset) / 8; else - end_i = ((unsigned)datatype_len - p->offset) / 8 - 1; + end_i = ((unsigned)datatype_len - p->offset) / 8 - 1; - for(k = (int)begin_i; k <= (int)end_i; k++) - H5Z_nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, - buffer, j, buf_len, p, datatype_len); + for (k = (int)begin_i; k <= (int)end_i; k++) + H5Z_nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, buffer, j, buf_len, + p, datatype_len); } } static herr_t -H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index) +H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, total_size, base_class, base_size, n, begin_index; - parms_atomic p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - total_size = parms[(*parms_index)++]; - base_class = parms[(*parms_index)++]; - - switch(base_class) { - case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; - p.order = parms[(*parms_index)++]; - p.precision = parms[(*parms_index)++]; - p.offset = parms[(*parms_index)++]; - - /* Check values of precision and offset */ - if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") - - n = total_size / p.size; - for(i = 0; i < n; i++) - H5Z_nbit_decompress_one_atomic(data, data_offset + i * p.size, - buffer, j, buf_len, &p); - break; - - case H5Z_NBIT_ARRAY: - base_size = parms[*parms_index]; /* read in advance */ - n = total_size / base_size; /* number of base_type elements inside the array datatype */ - begin_index = *parms_index; - for(i = 0; i < n; i++) { - if(H5Z__nbit_decompress_one_array(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") - *parms_index = begin_index; - } - break; - - case H5Z_NBIT_COMPOUND: - base_size = parms[*parms_index]; /* read in advance */ - n = total_size / base_size; /* number of base_type elements inside the array datatype */ - begin_index = *parms_index; - for(i = 0; i < n; i++) { - if(H5Z__nbit_decompress_one_compound(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") - *parms_index = begin_index; - } - break; - - case H5Z_NBIT_NOOPTYPE: - (*parms_index)++; /* skip size of no-op type */ - H5Z_nbit_decompress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size); - break; - - default: - HDassert(0 && "This Should never be executed!"); - } /* end switch */ + unsigned i, total_size, base_class, base_size, n, begin_index; + parms_atomic p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + total_size = parms[(*parms_index)++]; + base_class = parms[(*parms_index)++]; + + switch (base_class) { + case H5Z_NBIT_ATOMIC: + p.size = parms[(*parms_index)++]; + p.order = parms[(*parms_index)++]; + p.precision = parms[(*parms_index)++]; + p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if (p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + + n = total_size / p.size; + for (i = 0; i < n; i++) + H5Z_nbit_decompress_one_atomic(data, data_offset + i * p.size, buffer, j, buf_len, &p); + break; + + case H5Z_NBIT_ARRAY: + base_size = parms[*parms_index]; /* read in advance */ + n = total_size / base_size; /* number of base_type elements inside the array datatype */ + begin_index = *parms_index; + for (i = 0; i < n; i++) { + if (H5Z__nbit_decompress_one_array(data, data_offset + i * base_size, buffer, j, buf_len, + parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") + *parms_index = begin_index; + } + break; + + case H5Z_NBIT_COMPOUND: + base_size = parms[*parms_index]; /* read in advance */ + n = total_size / base_size; /* number of base_type elements inside the array datatype */ + begin_index = *parms_index; + for (i = 0; i < n; i++) { + if (H5Z__nbit_decompress_one_compound(data, data_offset + i * base_size, buffer, j, buf_len, + parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") + *parms_index = begin_index; + } + break; + + case H5Z_NBIT_NOOPTYPE: + (*parms_index)++; /* skip size of no-op type */ + H5Z_nbit_decompress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size); + break; + + default: + HDassert(0 && "This Should never be executed!"); + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } static herr_t -H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index) +H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, nmembers, member_offset, member_class, member_size, used_size = 0, size; - parms_atomic p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - size = parms[(*parms_index)++]; - nmembers = parms[(*parms_index)++]; - - for(i = 0; i < nmembers; i++) { - member_offset = parms[(*parms_index)++]; - member_class = parms[(*parms_index)++]; - - /* Check for overflow */ - member_size = parms[*parms_index]; - used_size += member_size; - if(used_size > size) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "compound member offset overflowed compound size") - switch(member_class) { - case H5Z_NBIT_ATOMIC: - p.size = member_size; - /* Advance past member size */ - (*parms_index)++; - p.order = parms[(*parms_index)++]; - p.precision = parms[(*parms_index)++]; - p.offset = parms[(*parms_index)++]; - - /* Check values of precision and offset */ - if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") - - H5Z_nbit_decompress_one_atomic(data, data_offset + member_offset, - buffer, j, buf_len, &p); - break; - - case H5Z_NBIT_ARRAY: - if(H5Z__nbit_decompress_one_array(data, data_offset + member_offset, - buffer, j, buf_len, parms, parms_index) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") - break; - - case H5Z_NBIT_COMPOUND: - if(H5Z__nbit_decompress_one_compound(data, data_offset+member_offset, - buffer, j, buf_len, parms, parms_index) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") - break; - - case H5Z_NBIT_NOOPTYPE: - /* Advance past member size */ - (*parms_index)++; - H5Z_nbit_decompress_one_nooptype(data, data_offset+member_offset, - buffer, j, buf_len, member_size); - break; - - default: - HDassert(0 && "This Should never be executed!"); - } /* end switch */ - } + unsigned i, nmembers, member_offset, member_class, member_size, used_size = 0, size; + parms_atomic p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + size = parms[(*parms_index)++]; + nmembers = parms[(*parms_index)++]; + + for (i = 0; i < nmembers; i++) { + member_offset = parms[(*parms_index)++]; + member_class = parms[(*parms_index)++]; + + /* Check for overflow */ + member_size = parms[*parms_index]; + used_size += member_size; + if (used_size > size) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "compound member offset overflowed compound size") + switch (member_class) { + case H5Z_NBIT_ATOMIC: + p.size = member_size; + /* Advance past member size */ + (*parms_index)++; + p.order = parms[(*parms_index)++]; + p.precision = parms[(*parms_index)++]; + p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if (p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + + H5Z_nbit_decompress_one_atomic(data, data_offset + member_offset, buffer, j, buf_len, &p); + break; + + case H5Z_NBIT_ARRAY: + if (H5Z__nbit_decompress_one_array(data, data_offset + member_offset, buffer, j, buf_len, + parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") + break; + + case H5Z_NBIT_COMPOUND: + if (H5Z__nbit_decompress_one_compound(data, data_offset + member_offset, buffer, j, buf_len, + parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") + break; + + case H5Z_NBIT_NOOPTYPE: + /* Advance past member size */ + (*parms_index)++; + H5Z_nbit_decompress_one_nooptype(data, data_offset + member_offset, buffer, j, buf_len, + member_size); + break; + + default: + HDassert(0 && "This Should never be executed!"); + } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) } static herr_t -H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - const unsigned parms[]) +H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, const unsigned parms[]) { /* i: index of data, j: index of buffer, buf_len: number of bits to be filled in current byte */ - unsigned i; - size_t j, size; - size_t buf_len; + unsigned i; + size_t j, size; + size_t buf_len; parms_atomic p; - unsigned parms_index; /* index in array parms used by compression/decompression functions */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned parms_index; /* index in array parms used by compression/decompression functions */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1320,46 +1314,48 @@ H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buff HDmemset(data, 0, d_nelmts * parms[4]); /* initialization before the loop */ - j = 0; + j = 0; buf_len = sizeof(unsigned char) * 8; - switch(parms[3]) { - case H5Z_NBIT_ATOMIC: - p.size = parms[4]; - p.order = parms[5]; + switch (parms[3]) { + case H5Z_NBIT_ATOMIC: + p.size = parms[4]; + p.order = parms[5]; p.precision = parms[6]; - p.offset = parms[7]; + p.offset = parms[7]; /* Check values of precision and offset */ - if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + if (p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") - for(i = 0; i < d_nelmts; i++) - H5Z_nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p); + for (i = 0; i < d_nelmts; i++) + H5Z_nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p); break; - case H5Z_NBIT_ARRAY: - size = parms[4]; - parms_index = 4; /* set the index before goto function call */ - for(i = 0; i < d_nelmts; i++) { - if(H5Z__nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + case H5Z_NBIT_ARRAY: + size = parms[4]; + parms_index = 4; /* set the index before goto function call */ + for (i = 0; i < d_nelmts; i++) { + if (H5Z__nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, + &parms_index) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") parms_index = 4; } break; - case H5Z_NBIT_COMPOUND: - size = parms[4]; - parms_index = 4; /* set the index before goto function call */ - for(i = 0; i < d_nelmts; i++) { - if(H5Z__nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + case H5Z_NBIT_COMPOUND: + size = parms[4]; + parms_index = 4; /* set the index before goto function call */ + for (i = 0; i < d_nelmts; i++) { + if (H5Z__nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, + &parms_index) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") parms_index = 4; } break; - default: - HDassert(0 && "This Should never be executed!"); + default: + HDassert(0 && "This Should never be executed!"); } /* end switch */ done: @@ -1367,91 +1363,95 @@ done: } static void -H5Z_nbit_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k, - unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, - const parms_atomic *p, size_t datatype_len) +H5Z_nbit_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, + unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, + const parms_atomic *p, size_t datatype_len) { - size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - /* initialize value and bits of unsigned char to be copied */ - val = data[data_offset + k]; - if(begin_i != end_i) { /* significant bits occupy >1 unsigned char */ - if(k == begin_i) - dat_len = 8 - (datatype_len - p->precision - p->offset) % 8; - else if(k == end_i) { - dat_len = 8 - p->offset % 8; - val = (unsigned char)(val >> (8 - dat_len)); - } - else - dat_len = 8; - } else { /* all significant bits in one unsigned char */ - val = (unsigned char)(val >> (p->offset % 8)); - dat_len = p->precision; - } - - if(*buf_len > dat_len) { - buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } else { - buffer[*j] |= (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); - dat_len -= *buf_len; - H5Z_nbit_next_byte(j, buf_len); - if(dat_len == 0) - return; - - buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } + size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + /* initialize value and bits of unsigned char to be copied */ + val = data[data_offset + k]; + if (begin_i != end_i) { /* significant bits occupy >1 unsigned char */ + if (k == begin_i) + dat_len = 8 - (datatype_len - p->precision - p->offset) % 8; + else if (k == end_i) { + dat_len = 8 - p->offset % 8; + val = (unsigned char)(val >> (8 - dat_len)); + } + else + dat_len = 8; + } + else { /* all significant bits in one unsigned char */ + val = (unsigned char)(val >> (p->offset % 8)); + dat_len = p->precision; + } + + if (*buf_len > dat_len) { + buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } + else { + buffer[*j] |= + (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); + dat_len -= *buf_len; + H5Z_nbit_next_byte(j, buf_len); + if (dat_len == 0) + return; + + buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } } static void -H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size) +H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, unsigned size) { - unsigned i; /* index */ - size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - for(i = 0; i < size; i++) { - /* initialize value and bits of unsigned char to be copied */ - val = data[data_offset + i]; - dat_len = sizeof(unsigned char) * 8; - - buffer[*j] |= (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); - dat_len -= *buf_len; - H5Z_nbit_next_byte(j, buf_len); - if(dat_len == 0) - continue; - - buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } + unsigned i; /* index */ + size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + for (i = 0; i < size; i++) { + /* initialize value and bits of unsigned char to be copied */ + val = data[data_offset + i]; + dat_len = sizeof(unsigned char) * 8; + + buffer[*j] |= + (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); + dat_len -= *buf_len; + H5Z_nbit_next_byte(j, buf_len); + if (dat_len == 0) + continue; + + buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } } static void -H5Z_nbit_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p) +H5Z_nbit_compress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const parms_atomic *p) { /* begin_i: the index of byte having first significant bit end_i: the index of byte having last significant bit */ - int k; + int k; unsigned begin_i, end_i; - size_t datatype_len; + size_t datatype_len; datatype_len = p->size * 8; - if(p->order == H5Z_NBIT_ORDER_LE) { /* little endian */ + if (p->order == H5Z_NBIT_ORDER_LE) { /* little endian */ /* calculate begin_i and end_i */ - if((p->precision + p->offset) % 8 != 0) - begin_i = (p->precision + p->offset) / 8; + if ((p->precision + p->offset) % 8 != 0) + begin_i = (p->precision + p->offset) / 8; else - begin_i = (p->precision + p->offset) / 8 - 1; + begin_i = (p->precision + p->offset) / 8 - 1; end_i = p->offset / 8; - for(k = (int)begin_i; k >= (int)end_i; k--) - H5Z_nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, - buffer, j, buf_len, p, datatype_len); + for (k = (int)begin_i; k >= (int)end_i; k--) + H5Z_nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, buffer, j, buf_len, p, + datatype_len); } else { /* big endian */ /* Sanity check */ @@ -1459,131 +1459,126 @@ H5Z_nbit_compress_one_atomic(unsigned char *data, size_t data_offset, /* calculate begin_i and end_i */ begin_i = ((unsigned)datatype_len - p->precision - p->offset) / 8; - if(p->offset % 8 != 0) - end_i = ((unsigned)datatype_len - p->offset) / 8; + if (p->offset % 8 != 0) + end_i = ((unsigned)datatype_len - p->offset) / 8; else - end_i = ((unsigned)datatype_len - p->offset) / 8 - 1; + end_i = ((unsigned)datatype_len - p->offset) / 8 - 1; - for(k = (int)begin_i; k <= (int)end_i; k++) - H5Z_nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, - buffer, j, buf_len, p, datatype_len); + for (k = (int)begin_i; k <= (int)end_i; k++) + H5Z_nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, buffer, j, buf_len, p, + datatype_len); } } static void -H5Z_nbit_compress_one_array(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index) +H5Z_nbit_compress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, total_size, base_class, base_size, n, begin_index; - parms_atomic p; - - total_size = parms[(*parms_index)++]; - base_class = parms[(*parms_index)++]; - - switch(base_class) { - case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; - p.order = parms[(*parms_index)++]; - p.precision = parms[(*parms_index)++]; - p.offset = parms[(*parms_index)++]; - n = total_size / p.size; - for(i = 0; i < n; i++) - H5Z_nbit_compress_one_atomic(data, data_offset + i * p.size, - buffer, j, buf_len, &p); - break; - - case H5Z_NBIT_ARRAY: - base_size = parms[*parms_index]; /* read in advance */ - n = total_size / base_size; /* number of base_type elements inside the array datatype */ - begin_index = *parms_index; - for(i = 0; i < n; i++) { - H5Z_nbit_compress_one_array(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index); - *parms_index = begin_index; - } - break; - - case H5Z_NBIT_COMPOUND: - base_size = parms[*parms_index]; /* read in advance */ - n = total_size / base_size; /* number of base_type elements inside the array datatype */ - begin_index = *parms_index; - for(i = 0; i < n; i++) { - H5Z_nbit_compress_one_compound(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index); - *parms_index = begin_index; - } - break; - - case H5Z_NBIT_NOOPTYPE: - (*parms_index)++; /* skip size of no-op type */ - H5Z_nbit_compress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size); - break; - - default: - HDassert(0 && "This Should never be executed!"); - } /* end switch */ + unsigned i, total_size, base_class, base_size, n, begin_index; + parms_atomic p; + + total_size = parms[(*parms_index)++]; + base_class = parms[(*parms_index)++]; + + switch (base_class) { + case H5Z_NBIT_ATOMIC: + p.size = parms[(*parms_index)++]; + p.order = parms[(*parms_index)++]; + p.precision = parms[(*parms_index)++]; + p.offset = parms[(*parms_index)++]; + n = total_size / p.size; + for (i = 0; i < n; i++) + H5Z_nbit_compress_one_atomic(data, data_offset + i * p.size, buffer, j, buf_len, &p); + break; + + case H5Z_NBIT_ARRAY: + base_size = parms[*parms_index]; /* read in advance */ + n = total_size / base_size; /* number of base_type elements inside the array datatype */ + begin_index = *parms_index; + for (i = 0; i < n; i++) { + H5Z_nbit_compress_one_array(data, data_offset + i * base_size, buffer, j, buf_len, parms, + parms_index); + *parms_index = begin_index; + } + break; + + case H5Z_NBIT_COMPOUND: + base_size = parms[*parms_index]; /* read in advance */ + n = total_size / base_size; /* number of base_type elements inside the array datatype */ + begin_index = *parms_index; + for (i = 0; i < n; i++) { + H5Z_nbit_compress_one_compound(data, data_offset + i * base_size, buffer, j, buf_len, parms, + parms_index); + *parms_index = begin_index; + } + break; + + case H5Z_NBIT_NOOPTYPE: + (*parms_index)++; /* skip size of no-op type */ + H5Z_nbit_compress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size); + break; + + default: + HDassert(0 && "This Should never be executed!"); + } /* end switch */ } static void -H5Z_nbit_compress_one_compound(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index) +H5Z_nbit_compress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, nmembers, member_offset, member_class, size; - parms_atomic p; - - (*parms_index)++; /* skip size of compound datatype */ - nmembers = parms[(*parms_index)++]; - - for(i = 0; i < nmembers; i++) { - member_offset = parms[(*parms_index)++]; - member_class = parms[(*parms_index)++]; - - switch(member_class) { - case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; - p.order = parms[(*parms_index)++]; - p.precision = parms[(*parms_index)++]; - p.offset = parms[(*parms_index)++]; - H5Z_nbit_compress_one_atomic(data, data_offset + member_offset, - buffer, j, buf_len, &p); - break; - - case H5Z_NBIT_ARRAY: - H5Z_nbit_compress_one_array(data, data_offset + member_offset, - buffer, j, buf_len, parms, parms_index); - break; - - case H5Z_NBIT_COMPOUND: - H5Z_nbit_compress_one_compound(data, data_offset+member_offset, - buffer, j, buf_len, parms, parms_index); - break; - - case H5Z_NBIT_NOOPTYPE: - size = parms[(*parms_index)++]; - H5Z_nbit_compress_one_nooptype(data, data_offset+member_offset, - buffer, j, buf_len, size); - break; - - default: - HDassert(0 && "This Should never be executed!"); - } /* end switch */ - } + unsigned i, nmembers, member_offset, member_class, size; + parms_atomic p; + + (*parms_index)++; /* skip size of compound datatype */ + nmembers = parms[(*parms_index)++]; + + for (i = 0; i < nmembers; i++) { + member_offset = parms[(*parms_index)++]; + member_class = parms[(*parms_index)++]; + + switch (member_class) { + case H5Z_NBIT_ATOMIC: + p.size = parms[(*parms_index)++]; + p.order = parms[(*parms_index)++]; + p.precision = parms[(*parms_index)++]; + p.offset = parms[(*parms_index)++]; + H5Z_nbit_compress_one_atomic(data, data_offset + member_offset, buffer, j, buf_len, &p); + break; + + case H5Z_NBIT_ARRAY: + H5Z_nbit_compress_one_array(data, data_offset + member_offset, buffer, j, buf_len, parms, + parms_index); + break; + + case H5Z_NBIT_COMPOUND: + H5Z_nbit_compress_one_compound(data, data_offset + member_offset, buffer, j, buf_len, parms, + parms_index); + break; + + case H5Z_NBIT_NOOPTYPE: + size = parms[(*parms_index)++]; + H5Z_nbit_compress_one_nooptype(data, data_offset + member_offset, buffer, j, buf_len, size); + break; + + default: + HDassert(0 && "This Should never be executed!"); + } /* end switch */ + } } static void -H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t *buffer_size, const unsigned parms[]) +H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, size_t *buffer_size, + const unsigned parms[]) { /* i: index of data, new_size: index of buffer, buf_len: number of bits to be filled in current byte */ - unsigned i; - size_t size; - size_t new_size = 0; - size_t buf_len; + unsigned i; + size_t size; + size_t new_size = 0; + size_t buf_len; parms_atomic p; - unsigned parms_index; /* index in array parms used by compression/decompression functions */ + unsigned parms_index; /* index in array parms used by compression/decompression functions */ /* must initialize buffer to be zeros */ HDmemset(buffer, 0, *buffer_size); @@ -1591,31 +1586,32 @@ H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, /* initialization before the loop */ buf_len = sizeof(unsigned char) * 8; - switch(parms[3]) { - case H5Z_NBIT_ATOMIC: - p.size = parms[4]; - p.order = parms[5]; + switch (parms[3]) { + case H5Z_NBIT_ATOMIC: + p.size = parms[4]; + p.order = parms[5]; p.precision = parms[6]; - p.offset = parms[7]; + p.offset = parms[7]; - for(i = 0; i < d_nelmts; i++) + for (i = 0; i < d_nelmts; i++) H5Z_nbit_compress_one_atomic(data, i * p.size, buffer, &new_size, &buf_len, &p); break; - case H5Z_NBIT_ARRAY: - size = parms[4]; + case H5Z_NBIT_ARRAY: + size = parms[4]; parms_index = 4; - for(i = 0; i < d_nelmts; i++) { + for (i = 0; i < d_nelmts; i++) { H5Z_nbit_compress_one_array(data, i * size, buffer, &new_size, &buf_len, parms, &parms_index); parms_index = 4; } break; - case H5Z_NBIT_COMPOUND: - size = parms[4]; + case H5Z_NBIT_COMPOUND: + size = parms[4]; parms_index = 4; - for(i = 0; i < d_nelmts; i++) { - H5Z_nbit_compress_one_compound(data, i * size, buffer, &new_size, &buf_len, parms, &parms_index); + for (i = 0; i < d_nelmts; i++) { + H5Z_nbit_compress_one_compound(data, i * size, buffer, &new_size, &buf_len, parms, + &parms_index); parms_index = 4; } break; @@ -1628,4 +1624,3 @@ H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, * the last byte, increment the value by 1. */ *buffer_size = new_size + 1; } - diff --git a/src/H5Zpkg.h b/src/H5Zpkg.h index 55fca27..17fd96d 100644 --- a/src/H5Zpkg.h +++ b/src/H5Zpkg.h @@ -19,7 +19,7 @@ #define _H5Zpkg_H /* Include private header file */ -#include "H5Zprivate.h" /* Filter functions */ +#include "H5Zprivate.h" /* Filter functions */ /********************/ /* Internal filters */ @@ -55,4 +55,3 @@ H5_DLLVAR H5Z_class2_t H5Z_SZIP[1]; H5_DLL herr_t H5Z__unregister(H5Z_filter_t filter_id); #endif /* _H5Zpkg_H */ - diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index fbc6fc4..2504efb 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -25,7 +25,7 @@ typedef struct H5Z_filter_info_t H5Z_filter_info_t; #include "H5Zpublic.h" /* Private headers needed by this file */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5Tprivate.h" /* Datatypes */ /**************************/ /* Library Private Macros */ @@ -35,17 +35,17 @@ typedef struct H5Z_filter_info_t H5Z_filter_info_t; /* [These are aliases for the similar definitions in szlib.h, which we can't * include directly due to the duplication of various symbols with the zlib.h * header file] */ -#define H5_SZIP_LSB_OPTION_MASK 8 -#define H5_SZIP_MSB_OPTION_MASK 16 -#define H5_SZIP_RAW_OPTION_MASK 128 +#define H5_SZIP_LSB_OPTION_MASK 8 +#define H5_SZIP_MSB_OPTION_MASK 16 +#define H5_SZIP_RAW_OPTION_MASK 128 /* Common # of 'client data values' for filters */ /* (avoids dynamic memory allocation in most cases) */ -#define H5Z_COMMON_CD_VALUES 4 +#define H5Z_COMMON_CD_VALUES 4 /* Common size of filter name */ /* (avoids dynamic memory allocation in most cases) */ -#define H5Z_COMMON_NAME_LEN 12 +#define H5Z_COMMON_NAME_LEN 12 /****************************/ /* Library Private Typedefs */ @@ -53,20 +53,19 @@ typedef struct H5Z_filter_info_t H5Z_filter_info_t; /* Structure to store information about each filter's parameters */ struct H5Z_filter_info_t { - H5Z_filter_t id; /*filter identification number */ - unsigned flags; /*defn and invocation flags */ - char _name[H5Z_COMMON_NAME_LEN]; /*internal filter name */ - char *name; /*optional filter name */ - size_t cd_nelmts; /*number of elements in cd_values[] */ - unsigned _cd_values[H5Z_COMMON_CD_VALUES]; /*internal client data values */ - unsigned *cd_values; /*client data values */ + H5Z_filter_t id; /*filter identification number */ + unsigned flags; /*defn and invocation flags */ + char _name[H5Z_COMMON_NAME_LEN]; /*internal filter name */ + char * name; /*optional filter name */ + size_t cd_nelmts; /*number of elements in cd_values[] */ + unsigned _cd_values[H5Z_COMMON_CD_VALUES]; /*internal client data values */ + unsigned * cd_values; /*client data values */ }; /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -75,37 +74,34 @@ struct H5O_pline_t; /*forward decl*/ /* Internal API routines */ H5_DLL herr_t H5Z_init(void); H5_DLL herr_t H5Z_register(const H5Z_class2_t *cls); -H5_DLL herr_t H5Z_append(struct H5O_pline_t *pline, H5Z_filter_t filter, - unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); -H5_DLL herr_t H5Z_modify(const struct H5O_pline_t *pline, H5Z_filter_t filter, - unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); -H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, - unsigned flags, unsigned *filter_mask/*in,out*/, - H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, - size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, - void **buf/*in,out*/); +H5_DLL herr_t H5Z_append(struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned int cd_values[]); +H5_DLL herr_t H5Z_modify(const struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, + size_t cd_nelmts, const unsigned int cd_values[]); +H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, unsigned flags, unsigned *filter_mask /*in,out*/, + H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, size_t *nbytes /*in,out*/, + size_t *buf_size /*in,out*/, void **buf /*in,out*/); H5_DLL H5Z_class2_t *H5Z_find(H5Z_filter_t id); -H5_DLL herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id); -H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); -H5_DLL herr_t H5Z_can_apply_direct(const struct H5O_pline_t *pline); -H5_DLL herr_t H5Z_set_local_direct(const struct H5O_pline_t *pline); -H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, - H5Z_filter_t filter); -H5_DLL htri_t H5Z_filter_in_pline(const struct H5O_pline_t *pline, H5Z_filter_t filter); -H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline); -H5_DLL htri_t H5Z_filter_avail(H5Z_filter_t id); -H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); -H5_DLL herr_t H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); +H5_DLL herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id); +H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); +H5_DLL herr_t H5Z_can_apply_direct(const struct H5O_pline_t *pline); +H5_DLL herr_t H5Z_set_local_direct(const struct H5O_pline_t *pline); +H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, H5Z_filter_t filter); +H5_DLL htri_t H5Z_filter_in_pline(const struct H5O_pline_t *pline, H5Z_filter_t filter); +H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline); +H5_DLL htri_t H5Z_filter_avail(H5Z_filter_t id); +H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); +H5_DLL herr_t H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); /* Data Transform Functions */ typedef struct H5Z_data_xform_t H5Z_data_xform_t; /* Defined in H5Ztrans.c */ H5_DLL H5Z_data_xform_t *H5Z_xform_create(const char *expr); -H5_DLL herr_t H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop); -H5_DLL herr_t H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop); -H5_DLL herr_t H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, - size_t array_size, const H5T_t *buf_type); -H5_DLL hbool_t H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop); -H5_DLL const char *H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop); +H5_DLL herr_t H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop); +H5_DLL herr_t H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop); +H5_DLL herr_t H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, size_t array_size, + const H5T_t *buf_type); +H5_DLL hbool_t H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop); +H5_DLL const char * H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop); #endif diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index a2a44fa..9da4eaf 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -31,66 +31,65 @@ typedef int H5Z_filter_t; /* Filter IDs */ -#define H5Z_FILTER_ERROR (-1) /*no filter */ -#define H5Z_FILTER_NONE 0 /*reserved indefinitely */ -#define H5Z_FILTER_DEFLATE 1 /*deflation like gzip */ -#define H5Z_FILTER_SHUFFLE 2 /*shuffle the data */ -#define H5Z_FILTER_FLETCHER32 3 /*fletcher32 checksum of EDC */ -#define H5Z_FILTER_SZIP 4 /*szip compression */ -#define H5Z_FILTER_NBIT 5 /*nbit compression */ -#define H5Z_FILTER_SCALEOFFSET 6 /*scale+offset compression */ -#define H5Z_FILTER_RESERVED 256 /*filter ids below this value are reserved for library use */ - -#define H5Z_FILTER_MAX 65535 /*maximum filter id */ +#define H5Z_FILTER_ERROR (-1) /*no filter */ +#define H5Z_FILTER_NONE 0 /*reserved indefinitely */ +#define H5Z_FILTER_DEFLATE 1 /*deflation like gzip */ +#define H5Z_FILTER_SHUFFLE 2 /*shuffle the data */ +#define H5Z_FILTER_FLETCHER32 3 /*fletcher32 checksum of EDC */ +#define H5Z_FILTER_SZIP 4 /*szip compression */ +#define H5Z_FILTER_NBIT 5 /*nbit compression */ +#define H5Z_FILTER_SCALEOFFSET 6 /*scale+offset compression */ +#define H5Z_FILTER_RESERVED 256 /*filter ids below this value are reserved for library use */ + +#define H5Z_FILTER_MAX 65535 /*maximum filter id */ /* General macros */ -#define H5Z_FILTER_ALL 0 /* Symbol to remove all filters in H5Premove_filter */ -#define H5Z_MAX_NFILTERS 32 /* Maximum number of filters allowed in a pipeline */ - /* (should probably be allowed to be an - * unlimited amount, but currently each - * filter uses a bit in a 32-bit field, - * so the format would have to be - * changed to accommodate that) - */ +#define H5Z_FILTER_ALL 0 /* Symbol to remove all filters in H5Premove_filter */ +#define H5Z_MAX_NFILTERS 32 /* Maximum number of filters allowed in a pipeline */ + /* (should probably be allowed to be an + * unlimited amount, but currently each + * filter uses a bit in a 32-bit field, + * so the format would have to be + * changed to accommodate that) + */ /* Flags for filter definition (stored) */ -#define H5Z_FLAG_DEFMASK 0x00ff /*definition flag mask */ -#define H5Z_FLAG_MANDATORY 0x0000 /*filter is mandatory */ -#define H5Z_FLAG_OPTIONAL 0x0001 /*filter is optional */ +#define H5Z_FLAG_DEFMASK 0x00ff /*definition flag mask */ +#define H5Z_FLAG_MANDATORY 0x0000 /*filter is mandatory */ +#define H5Z_FLAG_OPTIONAL 0x0001 /*filter is optional */ /* Additional flags for filter invocation (not stored) */ -#define H5Z_FLAG_INVMASK 0xff00 /*invocation flag mask */ -#define H5Z_FLAG_REVERSE 0x0100 /*reverse direction; read */ -#define H5Z_FLAG_SKIP_EDC 0x0200 /*skip EDC filters for read */ +#define H5Z_FLAG_INVMASK 0xff00 /*invocation flag mask */ +#define H5Z_FLAG_REVERSE 0x0100 /*reverse direction; read */ +#define H5Z_FLAG_SKIP_EDC 0x0200 /*skip EDC filters for read */ /* Special parameters for szip compression */ /* [These are aliases for the similar definitions in szlib.h, which we can't * include directly due to the duplication of various symbols with the zlib.h * header file] */ -#define H5_SZIP_ALLOW_K13_OPTION_MASK 1 -#define H5_SZIP_CHIP_OPTION_MASK 2 -#define H5_SZIP_EC_OPTION_MASK 4 -#define H5_SZIP_NN_OPTION_MASK 32 -#define H5_SZIP_MAX_PIXELS_PER_BLOCK 32 +#define H5_SZIP_ALLOW_K13_OPTION_MASK 1 +#define H5_SZIP_CHIP_OPTION_MASK 2 +#define H5_SZIP_EC_OPTION_MASK 4 +#define H5_SZIP_NN_OPTION_MASK 32 +#define H5_SZIP_MAX_PIXELS_PER_BLOCK 32 /* Macros for the shuffle filter */ -#define H5Z_SHUFFLE_USER_NPARMS 0 /* Number of parameters that users can set */ -#define H5Z_SHUFFLE_TOTAL_NPARMS 1 /* Total number of parameters for filter */ +#define H5Z_SHUFFLE_USER_NPARMS 0 /* Number of parameters that users can set */ +#define H5Z_SHUFFLE_TOTAL_NPARMS 1 /* Total number of parameters for filter */ /* Macros for the szip filter */ -#define H5Z_SZIP_USER_NPARMS 2 /* Number of parameters that users can set */ -#define H5Z_SZIP_TOTAL_NPARMS 4 /* Total number of parameters for filter */ -#define H5Z_SZIP_PARM_MASK 0 /* "User" parameter for option mask */ -#define H5Z_SZIP_PARM_PPB 1 /* "User" parameter for pixels-per-block */ -#define H5Z_SZIP_PARM_BPP 2 /* "Local" parameter for bits-per-pixel */ -#define H5Z_SZIP_PARM_PPS 3 /* "Local" parameter for pixels-per-scanline */ +#define H5Z_SZIP_USER_NPARMS 2 /* Number of parameters that users can set */ +#define H5Z_SZIP_TOTAL_NPARMS 4 /* Total number of parameters for filter */ +#define H5Z_SZIP_PARM_MASK 0 /* "User" parameter for option mask */ +#define H5Z_SZIP_PARM_PPB 1 /* "User" parameter for pixels-per-block */ +#define H5Z_SZIP_PARM_BPP 2 /* "Local" parameter for bits-per-pixel */ +#define H5Z_SZIP_PARM_PPS 3 /* "Local" parameter for pixels-per-scanline */ /* Macros for the nbit filter */ -#define H5Z_NBIT_USER_NPARMS 0 /* Number of parameters that users can set */ +#define H5Z_NBIT_USER_NPARMS 0 /* Number of parameters that users can set */ /* Macros for the scale offset filter */ -#define H5Z_SCALEOFFSET_USER_NPARMS 2 /* Number of parameters that users can set */ - +#define H5Z_SCALEOFFSET_USER_NPARMS 2 /* Number of parameters that users can set */ /* Special parameters for ScaleOffset filter*/ #define H5Z_SO_INT_MINBITS_DEFAULT 0 @@ -105,10 +104,10 @@ typedef enum H5Z_SO_scale_type_t { /* Values to decide if EDC is enabled for reading data */ typedef enum H5Z_EDC_t { - H5Z_ERROR_EDC = -1, /* error value */ - H5Z_DISABLE_EDC = 0, - H5Z_ENABLE_EDC = 1, - H5Z_NO_EDC = 2 /* must be the last */ + H5Z_ERROR_EDC = -1, /* error value */ + H5Z_DISABLE_EDC = 0, + H5Z_ENABLE_EDC = 1, + H5Z_NO_EDC = 2 /* must be the last */ } H5Z_EDC_t; /* Bit flags for H5Zget_filter_info */ @@ -117,20 +116,19 @@ typedef enum H5Z_EDC_t { /* Return values for filter callback function */ typedef enum H5Z_cb_return_t { - H5Z_CB_ERROR = -1, - H5Z_CB_FAIL = 0, /* I/O should fail if filter fails. */ - H5Z_CB_CONT = 1, /* I/O continues if filter fails. */ - H5Z_CB_NO = 2 + H5Z_CB_ERROR = -1, + H5Z_CB_FAIL = 0, /* I/O should fail if filter fails. */ + H5Z_CB_CONT = 1, /* I/O continues if filter fails. */ + H5Z_CB_NO = 2 } H5Z_cb_return_t; /* Filter callback function definition */ -typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void* buf, - size_t buf_size, void* op_data); +typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void *buf, size_t buf_size, void *op_data); /* Structure for filter callback property */ typedef struct H5Z_cb_t { - H5Z_filter_func_t func; - void *op_data; + H5Z_filter_func_t func; + void * op_data; } H5Z_cb_t; #ifdef __cplusplus @@ -197,23 +195,22 @@ typedef herr_t (*H5Z_set_local_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space * buffer. If an error occurs then the function should return zero and leave * all pointer arguments unchanged. */ -typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, - const unsigned int cd_values[], size_t nbytes, - size_t *buf_size, void **buf); +typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], + size_t nbytes, size_t *buf_size, void **buf); /* * The filter table maps filter identification numbers to structs that * contain a pointers to the filter function and timing statistics. */ typedef struct H5Z_class2_t { - int version; /* Version number of the H5Z_class_t struct */ - H5Z_filter_t id; /* Filter ID number */ - unsigned encoder_present; /* Does this filter have an encoder? */ - unsigned decoder_present; /* Does this filter have a decoder? */ - const char *name; /* Comment for debugging */ - H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ - H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ - H5Z_func_t filter; /* The actual filter function */ + int version; /* Version number of the H5Z_class_t struct */ + H5Z_filter_t id; /* Filter ID number */ + unsigned encoder_present; /* Does this filter have an encoder? */ + unsigned decoder_present; /* Does this filter have a decoder? */ + const char * name; /* Comment for debugging */ + H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ + H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ + H5Z_func_t filter; /* The actual filter function */ } H5Z_class2_t; H5_DLL herr_t H5Zregister(const void *cls); @@ -232,11 +229,11 @@ H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_confi * contain a pointers to the filter function and timing statistics. */ typedef struct H5Z_class1_t { - H5Z_filter_t id; /* Filter ID number */ - const char *name; /* Comment for debugging */ + H5Z_filter_t id; /* Filter ID number */ + const char * name; /* Comment for debugging */ H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ - H5Z_func_t filter; /* The actual filter function */ + H5Z_func_t filter; /* The actual filter function */ } H5Z_class1_t; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -245,4 +242,3 @@ typedef struct H5Z_class1_t { } #endif #endif - diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 7bdc283..4046508 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -11,660 +11,730 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Zpkg.h" /* Data filters */ /* Struct of parameters needed for compressing/decompressing one atomic datatype */ typedef struct { - unsigned size; /* datatype size */ - uint32_t minbits; /* minimum bits to compress one value of such datatype */ - unsigned mem_order; /* current memory endianness order */ + unsigned size; /* datatype size */ + uint32_t minbits; /* minimum bits to compress one value of such datatype */ + unsigned mem_order; /* current memory endianness order */ } parms_atomic; -enum H5Z_scaleoffset_t {t_bad=0, t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_long, - t_schar, t_short, t_int, t_long, t_long_long, - t_float, t_double}; +enum H5Z_scaleoffset_t { + t_bad = 0, + t_uchar = 1, + t_ushort, + t_uint, + t_ulong, + t_ulong_long, + t_schar, + t_short, + t_int, + t_long, + t_long_long, + t_float, + t_double +}; /* Local function prototypes */ -static htri_t H5Z_can_apply_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static enum H5Z_scaleoffset_t H5Z_scaleoffset_get_type(unsigned dtype_class, - unsigned dtype_size, unsigned dtype_sign); -static herr_t H5Z_scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, - H5T_t *type, enum H5Z_scaleoffset_t scale_type, unsigned cd_values[], - int need_convert); -static herr_t H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); -static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size); +static htri_t H5Z_can_apply_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); +static enum H5Z_scaleoffset_t H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, + unsigned dtype_sign); +static herr_t H5Z_scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, H5T_t *type, + enum H5Z_scaleoffset_t scale_type, unsigned cd_values[], + int need_convert); +static herr_t H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); +static size_t H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], + size_t nbytes, size_t *buf_size, void **buf); +static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size); static H5_ATTR_CONST unsigned H5Z_scaleoffset_log2(unsigned long long num); -static void H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[], - uint32_t *minbits, unsigned long long *minval); -static void H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[], - uint32_t minbits, unsigned long long minval); -static herr_t H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[], - uint32_t *minbits, unsigned long long *minval, double D_val); -static herr_t H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[], - uint32_t minbits, unsigned long long minval, double D_val); -static void H5Z_scaleoffset_next_byte(size_t *j, unsigned *buf_len); -static void H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, - parms_atomic p, unsigned dtype_len); -static void H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, - parms_atomic p, unsigned dtype_len); -static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p); -static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p); -static void H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, parms_atomic p); -static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t buffer_size, parms_atomic p); +static void H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const unsigned cd_values[], uint32_t *minbits, + unsigned long long *minval); +static void H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const unsigned cd_values[], uint32_t minbits, + unsigned long long minval); +static herr_t H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const unsigned cd_values[], uint32_t *minbits, + unsigned long long *minval, double D_val); +static herr_t H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const unsigned cd_values[], + uint32_t minbits, unsigned long long minval, double D_val); +static void H5Z_scaleoffset_next_byte(size_t *j, unsigned *buf_len); +static void H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, + unsigned begin_i, unsigned char *buffer, size_t *j, + unsigned *buf_len, parms_atomic p, unsigned dtype_len); +static void H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k, + unsigned begin_i, unsigned char *buffer, size_t *j, + unsigned *buf_len, parms_atomic p, unsigned dtype_len); +static void H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p); +static void H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p); +static void H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, + parms_atomic p); +static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, + size_t buffer_size, parms_atomic p); /* This message derives from H5Z */ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_SCALEOFFSET, /* Filter id number */ - 1, /* Assume encoder present: check before registering */ - 1, /* decoder_present flag (set to true) */ - "scaleoffset", /* Filter name for debugging */ - H5Z_can_apply_scaleoffset, /* The "can apply" callback */ - H5Z_set_local_scaleoffset, /* The "set local" callback */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_SCALEOFFSET, /* Filter id number */ + 1, /* Assume encoder present: check before registering */ + 1, /* decoder_present flag (set to true) */ + "scaleoffset", /* Filter name for debugging */ + H5Z_can_apply_scaleoffset, /* The "can apply" callback */ + H5Z_set_local_scaleoffset, /* The "set local" callback */ H5Z_filter_scaleoffset, /* The actual filter function */ }}; /* Local macros */ -#define H5Z_SCALEOFFSET_TOTAL_NPARMS 20 /* Total number of parameters for filter */ -#define H5Z_SCALEOFFSET_PARM_SCALETYPE 0 /* "User" parameter for scale type */ -#define H5Z_SCALEOFFSET_PARM_SCALEFACTOR 1 /* "User" parameter for scale factor */ -#define H5Z_SCALEOFFSET_PARM_NELMTS 2 /* "Local" parameter for number of elements in the chunk */ -#define H5Z_SCALEOFFSET_PARM_CLASS 3 /* "Local" parameter for datatype class */ -#define H5Z_SCALEOFFSET_PARM_SIZE 4 /* "Local" parameter for datatype size */ -#define H5Z_SCALEOFFSET_PARM_SIGN 5 /* "Local" parameter for integer datatype sign */ -#define H5Z_SCALEOFFSET_PARM_ORDER 6 /* "Local" parameter for datatype byte order */ -#define H5Z_SCALEOFFSET_PARM_FILAVAIL 7 /* "Local" parameter for dataset fill value existence */ -#define H5Z_SCALEOFFSET_PARM_FILVAL 8 /* "Local" parameter for start location to store dataset fill value */ +#define H5Z_SCALEOFFSET_TOTAL_NPARMS 20 /* Total number of parameters for filter */ +#define H5Z_SCALEOFFSET_PARM_SCALETYPE 0 /* "User" parameter for scale type */ +#define H5Z_SCALEOFFSET_PARM_SCALEFACTOR 1 /* "User" parameter for scale factor */ +#define H5Z_SCALEOFFSET_PARM_NELMTS 2 /* "Local" parameter for number of elements in the chunk */ +#define H5Z_SCALEOFFSET_PARM_CLASS 3 /* "Local" parameter for datatype class */ +#define H5Z_SCALEOFFSET_PARM_SIZE 4 /* "Local" parameter for datatype size */ +#define H5Z_SCALEOFFSET_PARM_SIGN 5 /* "Local" parameter for integer datatype sign */ +#define H5Z_SCALEOFFSET_PARM_ORDER 6 /* "Local" parameter for datatype byte order */ +#define H5Z_SCALEOFFSET_PARM_FILAVAIL 7 /* "Local" parameter for dataset fill value existence */ +#define H5Z_SCALEOFFSET_PARM_FILVAL 8 /* "Local" parameter for start location to store dataset fill value */ -#define H5Z_SCALEOFFSET_CLS_INTEGER 0 /* Integer (datatype class) */ -#define H5Z_SCALEOFFSET_CLS_FLOAT 1 /* Floatig-point (datatype class) */ +#define H5Z_SCALEOFFSET_CLS_INTEGER 0 /* Integer (datatype class) */ +#define H5Z_SCALEOFFSET_CLS_FLOAT 1 /* Floatig-point (datatype class) */ -#define H5Z_SCALEOFFSET_SGN_NONE 0 /* Unsigned integer type */ -#define H5Z_SCALEOFFSET_SGN_2 1 /* Two's complement signed integer type */ +#define H5Z_SCALEOFFSET_SGN_NONE 0 /* Unsigned integer type */ +#define H5Z_SCALEOFFSET_SGN_2 1 /* Two's complement signed integer type */ -#define H5Z_SCALEOFFSET_ORDER_LE 0 /* Little endian (datatype byte order) */ -#define H5Z_SCALEOFFSET_ORDER_BE 1 /* Big endian (datatype byte order) */ +#define H5Z_SCALEOFFSET_ORDER_LE 0 /* Little endian (datatype byte order) */ +#define H5Z_SCALEOFFSET_ORDER_BE 1 /* Big endian (datatype byte order) */ -#define H5Z_SCALEOFFSET_FILL_UNDEFINED 0 /* Fill value is not defined */ -#define H5Z_SCALEOFFSET_FILL_DEFINED 1 /* Fill value is defined */ +#define H5Z_SCALEOFFSET_FILL_UNDEFINED 0 /* Fill value is not defined */ +#define H5Z_SCALEOFFSET_FILL_DEFINED 1 /* Fill value is defined */ /* Store fill value in cd_values[] */ -#define H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ -{ \ - unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ - uint32_t _cd_value; /* Current cd_value */ \ - char *_fv_p; /* Pointer to current byte in fill_val */ \ - size_t _copy_size = 4; /* # of bytes to copy this iteration */ \ - size_t _size_rem = sizeof(type); /* # of bytes left to copy to cd_values */ \ - \ - /* Store the fill value as the last entry in cd_values[] \ - * Store byte by byte from least significant byte to most significant byte \ - * Plenty of space left for the fill value (from index 8 to 19) \ - * H5O_pline_encode will byte-swap each individual cd value, but we still \ - * need to swap the cd values as a whole if we are on a BE machine. Note \ - * that we need to make sure to put the data only in the lowest 4 bytes of \ - * each, if sizeof(unsigned) > 4. \ - */ \ - if(H5T_native_order_g == H5T_ORDER_LE) { \ - _fv_p = (char *)&(fill_val); \ - /* Copy 4 bytes at a time to each cd value */ \ - do { \ - if(_size_rem < 4) { \ - /* Amount left to copy is smaller than a cd_value, adjust copy \ - * size and initialize cd_value as it will not be fully \ - * overwritten */ \ - _copy_size = _size_rem; \ - _cd_value = (uint32_t)0; \ - } /* end if */ \ - \ - /* Copy the value */ \ - H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \ - (cd_values)[_i] = (unsigned)_cd_value; \ - \ - /* Next field */ \ - _i++; \ - _fv_p += _copy_size; \ - _size_rem -= _copy_size; \ - } while(_size_rem); \ - } /* end if */ \ - else { \ - HDassert(H5T_native_order_g == H5T_ORDER_BE); \ - \ - /* Copy 4 bytes at a time to each cd value, but start at the end \ - * (highest address) of fill_val */ \ - _fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \ - while(_size_rem >= 4) { \ - /* Copy the value */ \ - H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \ - (cd_values)[_i] = (unsigned)_cd_value; \ - \ - /* Next field */ \ - _i++; \ - _size_rem -= 4; \ - if(_size_rem >= 4) \ - _fv_p -= 4; \ - else \ - _fv_p -= _size_rem; \ - } /* end while */ \ - \ - HDassert(_fv_p == (char *)&(fill_val)); \ - if(_size_rem) { \ - /* Amount left to copy is smaller than a cd_value, initialize \ - * _cd_value as it will not be fully overwritten and copy to the end \ - * of _cd value as it is BE. */ \ - _cd_value = (uint32_t)0; \ - H5MM_memcpy((char *)&_cd_value + 4 - _size_rem, _fv_p, _size_rem); \ - (cd_values)[_i] = (unsigned)_cd_value; \ - } /* end if */ \ - } /* end else */ \ -} +#define H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ + { \ + unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ + uint32_t _cd_value; /* Current cd_value */ \ + char * _fv_p; /* Pointer to current byte in fill_val */ \ + size_t _copy_size = 4; /* # of bytes to copy this iteration */ \ + size_t _size_rem = sizeof(type); /* # of bytes left to copy to cd_values */ \ + \ + /* Store the fill value as the last entry in cd_values[] \ + * Store byte by byte from least significant byte to most significant byte \ + * Plenty of space left for the fill value (from index 8 to 19) \ + * H5O_pline_encode will byte-swap each individual cd value, but we still \ + * need to swap the cd values as a whole if we are on a BE machine. Note \ + * that we need to make sure to put the data only in the lowest 4 bytes of \ + * each, if sizeof(unsigned) > 4. \ + */ \ + if (H5T_native_order_g == H5T_ORDER_LE) { \ + _fv_p = (char *)&(fill_val); \ + /* Copy 4 bytes at a time to each cd value */ \ + do { \ + if (_size_rem < 4) { \ + /* Amount left to copy is smaller than a cd_value, adjust copy \ + * size and initialize cd_value as it will not be fully \ + * overwritten */ \ + _copy_size = _size_rem; \ + _cd_value = (uint32_t)0; \ + } /* end if */ \ + \ + /* Copy the value */ \ + H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \ + (cd_values)[_i] = (unsigned)_cd_value; \ + \ + /* Next field */ \ + _i++; \ + _fv_p += _copy_size; \ + _size_rem -= _copy_size; \ + } while (_size_rem); \ + } /* end if */ \ + else { \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + \ + /* Copy 4 bytes at a time to each cd value, but start at the end \ + * (highest address) of fill_val */ \ + _fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \ + while (_size_rem >= 4) { \ + /* Copy the value */ \ + H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \ + (cd_values)[_i] = (unsigned)_cd_value; \ + \ + /* Next field */ \ + _i++; \ + _size_rem -= 4; \ + if (_size_rem >= 4) \ + _fv_p -= 4; \ + else \ + _fv_p -= _size_rem; \ + } /* end while */ \ + \ + HDassert(_fv_p == (char *)&(fill_val)); \ + if (_size_rem) { \ + /* Amount left to copy is smaller than a cd_value, initialize \ + * _cd_value as it will not be fully overwritten and copy to the end \ + * of _cd value as it is BE. */ \ + _cd_value = (uint32_t)0; \ + H5MM_memcpy((char *)&_cd_value + 4 - _size_rem, _fv_p, _size_rem); \ + (cd_values)[_i] = (unsigned)_cd_value; \ + } /* end if */ \ + } /* end else */ \ + } /* Set the fill value parameter in cd_values[] for unsigned integer type */ -#define H5Z_scaleoffset_set_filval_1(type, dcpl_plist, dt, cd_values, need_convert) \ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - if(need_convert) \ - H5Z_scaleoffset_convert(&fill_val, 1, sizeof(type)); \ - \ - H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ -} +#define H5Z_scaleoffset_set_filval_1(type, dcpl_plist, dt, cd_values, need_convert) \ + { \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if (H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + if (need_convert) \ + H5Z_scaleoffset_convert(&fill_val, 1, sizeof(type)); \ + \ + H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ + } /* Set the fill value parameter in cd_values[] for signed integer type */ -#define H5Z_scaleoffset_set_filval_2(type, dcpl_plist, dt, cd_values, need_convert) \ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - if(need_convert) \ - H5Z_scaleoffset_convert(&fill_val, 1, sizeof(type)); \ - \ - H5Z_scaleoffset_save_filval(unsigned type, cd_values, fill_val) \ -} +#define H5Z_scaleoffset_set_filval_2(type, dcpl_plist, dt, cd_values, need_convert) \ + { \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if (H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + if (need_convert) \ + H5Z_scaleoffset_convert(&fill_val, 1, sizeof(type)); \ + \ + H5Z_scaleoffset_save_filval(unsigned type, cd_values, fill_val) \ + } /* Set the fill value parameter in cd_values[] for character integer type */ -#define H5Z_scaleoffset_set_filval_3(type, dcpl_plist, dt, cd_values, need_convert) \ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - /* Store the fill value as the last entry in cd_values[] */ \ - (cd_values)[H5Z_SCALEOFFSET_PARM_FILVAL] = (unsigned)((unsigned char)fill_val); \ -} +#define H5Z_scaleoffset_set_filval_3(type, dcpl_plist, dt, cd_values, need_convert) \ + { \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if (H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + /* Store the fill value as the last entry in cd_values[] */ \ + (cd_values)[H5Z_SCALEOFFSET_PARM_FILVAL] = (unsigned)((unsigned char)fill_val); \ + } /* Set the fill value parameter in cd_values[] for floating-point type */ -#define H5Z_scaleoffset_set_filval_4(type, dcpl_plist, dt, cd_values, need_convert) \ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - if(need_convert) \ - H5Z_scaleoffset_convert(&fill_val, 1, sizeof(type)); \ - \ - H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ -} +#define H5Z_scaleoffset_set_filval_4(type, dcpl_plist, dt, cd_values, need_convert) \ + { \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if (H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + if (need_convert) \ + H5Z_scaleoffset_convert(&fill_val, 1, sizeof(type)); \ + \ + H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ + } /* Get the fill value for integer type */ -#define H5Z_scaleoffset_get_filval_1(type, cd_values, fill_val) \ -{ \ - unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ - uint32_t _cd_value; /* Current cd_value */ \ - char *_fv_p; /* Pointer to current byte in fill_val */ \ - size_t _copy_size = 4; /* # of bytes to copy this iteration */ \ - size_t _size_rem = sizeof(type); /* # of bytes left to copy to filval */ \ - \ - /* Retrieve the fill value from the last entry in cd_values[] \ - * Store byte by byte from least significant byte to most significant byte \ - * Plenty of space left for the fill value (from index 8 to 19) \ - * H5O_pline_encode will byte-swap each individual cd value, but we still \ - * need to swap the cd values as a whole if we are on a BE machine. Note \ - * that we need to make sure to put the data only in the lowest 4 bytes of \ - * each, if sizeof(unsigned) > 4. \ - */ \ - if(H5T_native_order_g == H5T_ORDER_LE) { \ - _fv_p = (char *)&(fill_val); \ - /* Copy 4 bytes at a time to each cd value */ \ - do { \ - if(_size_rem < 4) \ - /* Amount left to copy is smaller than a cd_value, adjust copy \ - * size and initialize cd_value as it will not be fully \ - * overwritten */ \ - _copy_size = _size_rem; \ - \ - /* Copy the value */ \ - _cd_value = (uint32_t)(cd_values)[_i]; \ - H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \ - \ - /* Next field */ \ - _i++; \ - _fv_p += _copy_size; \ - _size_rem -= _copy_size; \ - } while(_size_rem); \ - } /* end if */ \ - else { \ - HDassert(H5T_native_order_g == H5T_ORDER_BE); \ - \ - /* Copy 4 bytes at a time to each cd value, but start at the end \ - * (highest address) of fill_val */ \ - _fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \ - while(_size_rem >= 4) { \ - /* Copy the value */ \ - _cd_value = (uint32_t)(cd_values)[_i]; \ - H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \ - \ - /* Next field */ \ - _i++; \ - _size_rem -= 4; \ - if(_size_rem >=4) \ - _fv_p -= 4; \ - else \ - _fv_p -= _size_rem; \ - } /* end while */ \ - \ - HDassert(_fv_p == (char *)&(fill_val)); \ - if(_size_rem) { \ - /* Amount left to copy is smaller than a cd_value, initialize \ - * _cd_value as it will not be fully overwritten and copy to the end \ - * of _cd value as it is BE. */ \ - _cd_value = (uint32_t)(cd_values)[_i]; \ - H5MM_memcpy(_fv_p, (char *)&_cd_value + 4 - _size_rem, _size_rem); \ - } /* end if */ \ - } /* end else */ \ -} +#define H5Z_scaleoffset_get_filval_1(type, cd_values, fill_val) \ + { \ + unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ + uint32_t _cd_value; /* Current cd_value */ \ + char * _fv_p; /* Pointer to current byte in fill_val */ \ + size_t _copy_size = 4; /* # of bytes to copy this iteration */ \ + size_t _size_rem = sizeof(type); /* # of bytes left to copy to filval */ \ + \ + /* Retrieve the fill value from the last entry in cd_values[] \ + * Store byte by byte from least significant byte to most significant byte \ + * Plenty of space left for the fill value (from index 8 to 19) \ + * H5O_pline_encode will byte-swap each individual cd value, but we still \ + * need to swap the cd values as a whole if we are on a BE machine. Note \ + * that we need to make sure to put the data only in the lowest 4 bytes of \ + * each, if sizeof(unsigned) > 4. \ + */ \ + if (H5T_native_order_g == H5T_ORDER_LE) { \ + _fv_p = (char *)&(fill_val); \ + /* Copy 4 bytes at a time to each cd value */ \ + do { \ + if (_size_rem < 4) \ + /* Amount left to copy is smaller than a cd_value, adjust copy \ + * size and initialize cd_value as it will not be fully \ + * overwritten */ \ + _copy_size = _size_rem; \ + \ + /* Copy the value */ \ + _cd_value = (uint32_t)(cd_values)[_i]; \ + H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \ + \ + /* Next field */ \ + _i++; \ + _fv_p += _copy_size; \ + _size_rem -= _copy_size; \ + } while (_size_rem); \ + } /* end if */ \ + else { \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + \ + /* Copy 4 bytes at a time to each cd value, but start at the end \ + * (highest address) of fill_val */ \ + _fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \ + while (_size_rem >= 4) { \ + /* Copy the value */ \ + _cd_value = (uint32_t)(cd_values)[_i]; \ + H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \ + \ + /* Next field */ \ + _i++; \ + _size_rem -= 4; \ + if (_size_rem >= 4) \ + _fv_p -= 4; \ + else \ + _fv_p -= _size_rem; \ + } /* end while */ \ + \ + HDassert(_fv_p == (char *)&(fill_val)); \ + if (_size_rem) { \ + /* Amount left to copy is smaller than a cd_value, initialize \ + * _cd_value as it will not be fully overwritten and copy to the end \ + * of _cd value as it is BE. */ \ + _cd_value = (uint32_t)(cd_values)[_i]; \ + H5MM_memcpy(_fv_p, (char *)&_cd_value + 4 - _size_rem, _size_rem); \ + } /* end if */ \ + } /* end else */ \ + } /* Get the fill value for floating-point type */ -#define H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ -{ \ - if(sizeof(type) <= sizeof(long long)) \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ + { \ + if (sizeof(type) <= sizeof(long long)) \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval) else HGOTO_ERROR( \ + H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Find maximum and minimum values of a buffer with fill value defined for integer type */ -#define H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min)\ -{ \ - i = 0; while(i < d_nelmts && buf[i]== filval) i++; \ - if(i < d_nelmts) min = max = buf[i]; \ - for(; i < d_nelmts; i++) { \ - if(buf[i] == filval) continue; /* ignore fill value */ \ - if(buf[i] > max) max = buf[i]; \ - if(buf[i] < min) min = buf[i]; \ - } \ -} +#define H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ + { \ + i = 0; \ + while (i < d_nelmts && buf[i] == filval) \ + i++; \ + if (i < d_nelmts) \ + min = max = buf[i]; \ + for (; i < d_nelmts; i++) { \ + if (buf[i] == filval) \ + continue; /* ignore fill value */ \ + if (buf[i] > max) \ + max = buf[i]; \ + if (buf[i] < min) \ + min = buf[i]; \ + } \ + } /* Find maximum and minimum values of a buffer with fill value undefined */ -#define H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min)\ -{ \ - min = max = buf[0]; \ - for(i = 0; i < d_nelmts; i++) { \ - if(buf[i] > max) max = buf[i]; \ - if(buf[i] < min) min = buf[i]; \ - } \ -} +#define H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + { \ + min = max = buf[0]; \ + for (i = 0; i < d_nelmts; i++) { \ + if (buf[i] > max) \ + max = buf[i]; \ + if (buf[i] < min) \ + min = buf[i]; \ + } \ + } /* Find maximum and minimum values of a buffer with fill value defined for floating-point type */ -#define H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ -{ \ - i = 0; while(i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) i++; \ - if(i < d_nelmts) min = max = buf[i]; \ - for(; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \ - continue; /* ignore fill value */ \ - if(buf[i] > max) max = buf[i]; \ - if(buf[i] < min) min = buf[i]; \ - } \ -} +#define H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ + { \ + i = 0; \ + while (i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \ + i++; \ + if (i < d_nelmts) \ + min = max = buf[i]; \ + for (; i < d_nelmts; i++) { \ + if (HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \ + continue; /* ignore fill value */ \ + if (buf[i] > max) \ + max = buf[i]; \ + if (buf[i] < min) \ + min = buf[i]; \ + } \ + } /* Find minimum value of a buffer with fill value defined for integer type */ -#define H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ -{ \ - i = 0; while(i < d_nelmts && buf[i]== filval) i++; \ - if(i < d_nelmts) min = buf[i]; \ - for(; i < d_nelmts; i++) { \ - if(buf[i] == filval) continue; /* ignore fill value */ \ - if(buf[i] < min) min = buf[i]; \ - } \ -} +#define H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ + { \ + i = 0; \ + while (i < d_nelmts && buf[i] == filval) \ + i++; \ + if (i < d_nelmts) \ + min = buf[i]; \ + for (; i < d_nelmts; i++) { \ + if (buf[i] == filval) \ + continue; /* ignore fill value */ \ + if (buf[i] < min) \ + min = buf[i]; \ + } \ + } /* Find minimum value of a buffer with fill value undefined */ -#define H5Z_scaleoffset_min_2(i, d_nelmts, buf, min)\ -{ \ - min = buf[0]; \ - for(i = 0; i < d_nelmts; i++) \ - if(buf[i] < min) min = buf[i]; \ -} +#define H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ + { \ + min = buf[0]; \ + for (i = 0; i < d_nelmts; i++) \ + if (buf[i] < min) \ + min = buf[i]; \ + } /* Check and handle special situation for unsigned integer type */ -#define H5Z_scaleoffset_check_1(type, max, min, minbits) \ -{ \ - if(max - min > (type)(~(type)0 - 2)) \ - { *minbits = sizeof(type)*8; return; } \ -} +#define H5Z_scaleoffset_check_1(type, max, min, minbits) \ + { \ + if (max - min > (type)(~(type)0 - 2)) { \ + *minbits = sizeof(type) * 8; \ + return; \ + } \ + } /* Check and handle special situation for signed integer type */ -#define H5Z_scaleoffset_check_2(type, max, min, minbits) \ -{ \ - if((unsigned type)(max - min) > (unsigned type)(~(unsigned type)0 - 2)) \ - { *minbits = sizeof(type)*8; return; } \ -} +#define H5Z_scaleoffset_check_2(type, max, min, minbits) \ + { \ + if ((unsigned type)(max - min) > (unsigned type)(~(unsigned type)0 - 2)) { \ + *minbits = sizeof(type) * 8; \ + return; \ + } \ + } /* Check and handle special situation for floating-point type */ -#define H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ -{ \ - if(sizeof(type) == sizeof(int)) { \ - if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \ - > pow_fun(2.0f, (type)(sizeof(int) * 8 - 1))) { \ - *minbits = sizeof(int) * 8; \ - goto done; \ - } \ - } else if(sizeof(type) == sizeof(long)) { \ - if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \ - > pow_fun(2.0f, (type)(sizeof(long) * 8 - 1))) { \ - *minbits = sizeof(long) * 8; \ - goto done; \ - } \ - } else if(sizeof(type) == sizeof(long long)) { \ - if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \ - > pow_fun(2.0f, (type)(sizeof(long long) * 8 - 1))) { \ - *minbits = sizeof(long long) * 8; \ - goto done; \ - } \ - } else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) { \ + if (round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) > \ + pow_fun(2.0f, (type)(sizeof(int) * 8 - 1))) { \ + *minbits = sizeof(int) * 8; \ + goto done; \ + } \ + } \ + else if (sizeof(type) == sizeof(long)) { \ + if (round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) > \ + pow_fun(2.0f, (type)(sizeof(long) * 8 - 1))) { \ + *minbits = sizeof(long) * 8; \ + goto done; \ + } \ + } \ + else if (sizeof(type) == sizeof(long long)) { \ + if (round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) > \ + pow_fun(2.0f, (type)(sizeof(long long) * 8 - 1))) { \ + *minbits = sizeof(long long) * 8; \ + goto done; \ + } \ + } \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Precompress for unsigned integer type */ -#define H5Z_scaleoffset_precompress_1(type, data, d_nelmts, filavail, cd_values, minbits, minval)\ -{ \ - type *buf = (type *)data, min = 0, max = 0, span, filval = 0; \ - unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ - H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ - H5Z_scaleoffset_check_1(type, max, min, minbits) \ - span = (type)(max - min + 1); \ - *minbits = H5Z_scaleoffset_log2((unsigned long long)(span+1)); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((buf[i] == filval) ? (((type)1 << *minbits) - 1) : (buf[i] - min)); \ - } else { /* fill value undefined */ \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */ \ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_1(type, max, min, minbits) \ - span = (type)(max - min + 1); \ - *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)(buf[i] - min); \ - } \ - *minval = min; \ -} +#define H5Z_scaleoffset_precompress_1(type, data, d_nelmts, filavail, cd_values, minbits, minval) \ + { \ + type * buf = (type *)data, min = 0, max = 0, span, filval = 0; \ + unsigned i; \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, \ + filval) if (*minbits == H5Z_SO_INT_MINBITS_DEFAULT) \ + { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ + H5Z_scaleoffset_check_1(type, max, min, minbits) span = (type)(max - min + 1); \ + *minbits = H5Z_scaleoffset_log2((unsigned long long)(span + 1)); \ + } \ + else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_1( \ + i, d_nelmts, buf, filval, \ + min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) buf[i] = \ + (type)((buf[i] == filval) ? (((type)1 << *minbits) - 1) : (buf[i] - min)); \ + } \ + else { /* fill value undefined */ \ + if (*minbits == \ + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + H5Z_scaleoffset_check_1(type, max, min, minbits) span = (type)(max - min + 1); \ + *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ + } \ + else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_2( \ + i, d_nelmts, buf, \ + min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) buf[i] = (type)(buf[i] - min); \ + } \ + *minval = min; \ + } /* Precompress for signed integer type */ -#define H5Z_scaleoffset_precompress_2(type, data, d_nelmts, filavail, cd_values, minbits, minval)\ -{ \ - type *buf = (type *)data, min = 0, max = 0, filval = 0; \ - unsigned type span; unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ - H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ - H5Z_scaleoffset_check_2(type, max, min, minbits) \ - span = (unsigned type)(max - min + 1); \ - *minbits = H5Z_scaleoffset_log2((unsigned long long)(span + 1)); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ - if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) : (buf[i] - min)); \ - } else { /* fill value undefined */ \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_2(type, max, min, minbits) \ - span = (unsigned type)(max - min + 1); \ - *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ - if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)(buf[i] - min); \ - } \ - *minval = (unsigned long long)min; \ -} +#define H5Z_scaleoffset_precompress_2(type, data, d_nelmts, filavail, cd_values, minbits, minval) \ + { \ + type * buf = (type *)data, min = 0, max = 0, filval = 0; \ + unsigned type span; \ + unsigned i; \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, \ + filval) if (*minbits == H5Z_SO_INT_MINBITS_DEFAULT) \ + { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ + H5Z_scaleoffset_check_2(type, max, min, minbits) span = (unsigned type)(max - min + 1); \ + *minbits = H5Z_scaleoffset_log2((unsigned long long)(span + 1)); \ + } \ + else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_1( \ + i, d_nelmts, buf, filval, \ + min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) buf[i] = (type)( \ + (buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) : (buf[i] - min)); \ + } \ + else { /* fill value undefined */ \ + if (*minbits == \ + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + H5Z_scaleoffset_check_2(type, max, min, minbits) span = (unsigned type)(max - min + 1); \ + *minbits = H5Z_scaleoffset_log2((unsigned long long)span); \ + } \ + else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_2( \ + i, d_nelmts, buf, \ + min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) buf[i] = (type)(buf[i] - min); \ + } \ + *minval = (unsigned long long)min; \ + } /* Modify values of data in precompression if fill value defined for floating-point type */ -#define H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, filval, minbits, min, D_val) \ -{ \ - if(sizeof(type) == sizeof(int)) \ - for(i = 0; i < d_nelmts; i++) { \ - if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ - *(int *)((void *)&buf[i]) = (int)(((unsigned int)1 << *minbits) - 1); \ - else \ - *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - } \ - else if(sizeof(type) == sizeof(long)) \ - for(i = 0; i < d_nelmts; i++) { \ - if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ - *(long *)((void *)&buf[i]) = (long)(((unsigned long)1 << *minbits) - 1); \ - else \ - *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - } \ - else if(sizeof(type) == sizeof(long long)) \ - for(i = 0; i < d_nelmts; i++) { \ - if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ - *(long long *)((void *)&buf[i]) = (long long)(((unsigned long long)1 << *minbits) - 1); \ - else \ - *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - } \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, filval, \ + minbits, min, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) \ + for (i = 0; i < d_nelmts; i++) { \ + if (abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ + *(int *)((void *)&buf[i]) = (int)(((unsigned int)1 << *minbits) - 1); \ + else \ + *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)); \ + } \ + else if (sizeof(type) == sizeof(long)) \ + for (i = 0; i < d_nelmts; i++) { \ + if (abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ + *(long *)((void *)&buf[i]) = (long)(((unsigned long)1 << *minbits) - 1); \ + else \ + *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)); \ + } \ + else if (sizeof(type) == sizeof(long long)) \ + for (i = 0; i < d_nelmts; i++) { \ + if (abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ + *(long long *)((void *)&buf[i]) = (long long)(((unsigned long long)1 << *minbits) - 1); \ + else \ + *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)); \ + } \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Modify values of data in precompression if fill value undefined for floating-point type */ -#define H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, D_val) \ -{ \ - if(sizeof(type) == sizeof(int)) \ - for(i = 0; i < d_nelmts; i++) \ - *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - else if(sizeof(type) == sizeof(long)) \ - for(i = 0; i < d_nelmts; i++) \ - *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - else if(sizeof(type) == sizeof(long long)) \ - for(i = 0; i < d_nelmts; i++) \ - *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) \ + for (i = 0; i < d_nelmts; i++) \ + *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)); \ + else if (sizeof(type) == sizeof(long)) \ + for (i = 0; i < d_nelmts; i++) \ + *(long *)((void *)&buf[i]) = \ + lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ + else if (sizeof(type) == sizeof(long long)) \ + for (i = 0; i < d_nelmts; i++) \ + *(long long *)((void *)&buf[i]) = \ + llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Save the minimum value for floating-point type */ -#define H5Z_scaleoffset_save_min(i, type, minval, min) \ -{ \ - if(sizeof(type) <= sizeof(long long)) \ - /* Save min value to corresponding position \ - * byte-order will be swapped as appropriate, but be sure to \ - * account for offset in BE if sizes differ \ - */ \ - if(H5T_native_order_g == H5T_ORDER_LE) \ - H5MM_memcpy(minval, &min, sizeof(type)); \ - else { \ - HDassert(H5T_native_order_g == H5T_ORDER_BE); \ - H5MM_memcpy(((char *)minval) + (sizeof(long long) - sizeof(type)), \ - &min, sizeof(type)); \ - } /* end else */ \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_save_min(i, type, minval, min) \ + { \ + if (sizeof(type) <= sizeof(long long)) \ + /* Save min value to corresponding position \ + * byte-order will be swapped as appropriate, but be sure to \ + * account for offset in BE if sizes differ \ + */ \ + if (H5T_native_order_g == H5T_ORDER_LE) \ + H5MM_memcpy(minval, &min, sizeof(type)); \ + else { \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + H5MM_memcpy(((char *)minval) + (sizeof(long long) - sizeof(type)), &min, sizeof(type)); \ + } /* end else */ \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Precompress for floating-point type using variable-minimum-bits method */ -#define H5Z_scaleoffset_precompress_3(type, pow_fun, abs_fun, round_fun, lround_fun, llround_fun, data, d_nelmts, filavail, cd_values, \ - minbits, minval, D_val) \ -{ \ - type *buf = (type *)data, min = 0, max = 0, filval = 0; \ - unsigned long long span; \ - unsigned i; \ - \ - *minval = 0; \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ - H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ - H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ - span = (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) + 1); \ - *minbits = H5Z_scaleoffset_log2(span + 1); \ - if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, filval, minbits, min, D_val) \ - } else { /* fill value undefined */ \ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ - span = (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) + 1); \ - *minbits = H5Z_scaleoffset_log2(span); \ - if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, D_val) \ - } \ - H5Z_scaleoffset_save_min(i, type, minval, min) \ -} +#define H5Z_scaleoffset_precompress_3(type, pow_fun, abs_fun, round_fun, lround_fun, llround_fun, data, \ + d_nelmts, filavail, cd_values, minbits, minval, D_val) \ + { \ + type * buf = (type *)data, min = 0, max = 0, filval = 0; \ + unsigned long long span; \ + unsigned i; \ + \ + *minval = 0; \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ + H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ + H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) span = \ + (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)) + \ + 1); \ + *minbits = H5Z_scaleoffset_log2(span + 1); \ + if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, \ + filval, minbits, min, D_val) \ + } \ + else { /* fill value undefined */ \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) span = \ + (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)) + \ + 1); \ + *minbits = H5Z_scaleoffset_log2(span); \ + if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, \ + D_val) \ + } \ + H5Z_scaleoffset_save_min(i, type, minval, min) \ + } /* Postdecompress for unsigned integer type */ -#define H5Z_scaleoffset_postdecompress_1(type, data, d_nelmts, filavail, cd_values, minbits, minval)\ -{ \ - type *buf = (type *)data, filval = 0; unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((buf[i] == (((type)1 << minbits) - 1)) ? filval : (buf[i] + minval)); \ - } else /* fill value undefined */ \ - for(i = 0; i < d_nelmts; i++) buf[i] = (type)(buf[i] + (type)(minval)); \ -} +#define H5Z_scaleoffset_postdecompress_1(type, data, d_nelmts, filavail, cd_values, minbits, minval) \ + { \ + type * buf = (type *)data, filval = 0; \ + unsigned i; \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval) for (i = 0; i < d_nelmts; i++) buf[i] = \ + (type)((buf[i] == (((type)1 << minbits) - 1)) ? filval : (buf[i] + minval)); \ + } \ + else /* fill value undefined */ \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(buf[i] + (type)(minval)); \ + } /* Postdecompress for signed integer type */ -#define H5Z_scaleoffset_postdecompress_2(type, data, d_nelmts, filavail, cd_values, minbits, minval)\ -{ \ - type *buf = (type *)data, filval = 0; \ - unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)(((unsigned type)buf[i] == (((unsigned type)1 << minbits) - 1)) ? filval : (buf[i] + minval));\ - } else /* fill value undefined */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)(buf[i] + (type)(minval)); \ -} +#define H5Z_scaleoffset_postdecompress_2(type, data, d_nelmts, filavail, cd_values, minbits, minval) \ + { \ + type * buf = (type *)data, filval = 0; \ + unsigned i; \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval) for (i = 0; i < d_nelmts; i++) buf[i] = \ + (type)(((unsigned type)buf[i] == (((unsigned type)1 << minbits) - 1)) ? filval \ + : (buf[i] + minval)); \ + } \ + else /* fill value undefined */ \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(buf[i] + (type)(minval)); \ + } /* Retrive minimum value of floating-point type */ -#define H5Z_scaleoffset_get_min(type, minval, min) \ -{ \ - if(sizeof(type) <= sizeof(long long)) \ - /* retrieve min value from corresponding position \ - * byte-order has already been swapped as appropriate, but be sure to \ - * account for offset in BE if sizes differ \ - */ \ - if(H5T_native_order_g == H5T_ORDER_LE) \ - H5MM_memcpy(&min, &minval, sizeof(type)); \ - else { \ - HDassert(H5T_native_order_g == H5T_ORDER_BE); \ - H5MM_memcpy(&min, ((char *)&minval) + (sizeof(long long) \ - - sizeof(type)), sizeof(type)); \ - } /* end else */ \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_get_min(type, minval, min) \ + { \ + if (sizeof(type) <= sizeof(long long)) \ + /* retrieve min value from corresponding position \ + * byte-order has already been swapped as appropriate, but be sure to \ + * account for offset in BE if sizes differ \ + */ \ + if (H5T_native_order_g == H5T_ORDER_LE) \ + H5MM_memcpy(&min, &minval, sizeof(type)); \ + else { \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + H5MM_memcpy(&min, ((char *)&minval) + (sizeof(long long) - sizeof(type)), sizeof(type)); \ + } /* end else */ \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Modify values of data in postdecompression if fill value defined for floating-point type */ -#define H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ -{ \ - if(sizeof(type) == sizeof(int)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((*(int *)((void *)&buf[i]) == (int)(((unsigned int)1 << minbits) - 1)) ? \ - filval : (type)(*(int *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else if(sizeof(type) == sizeof(long)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((*(long *)((void *)&buf[i]) == (long)(((unsigned long)1 << minbits) - 1)) ? \ - filval : (type)(*(long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else if(sizeof(type) == sizeof(long long)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((*(long long *)((void *)&buf[i]) == (long long)(((unsigned long long)1 << minbits) - 1)) ? \ - filval : (type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = \ + (type)((*(int *)((void *)&buf[i]) == (int)(((unsigned int)1 << minbits) - 1)) \ + ? filval \ + : (type)(*(int *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else if (sizeof(type) == sizeof(long)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = \ + (type)((*(long *)((void *)&buf[i]) == (long)(((unsigned long)1 << minbits) - 1)) \ + ? filval \ + : (type)(*(long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else if (sizeof(type) == sizeof(long long)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)( \ + (*(long long *)((void *)&buf[i]) == (long long)(((unsigned long long)1 << minbits) - 1)) \ + ? filval \ + : (type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Modify values of data in postdecompression if fill value undefined for floating-point type */ -#define H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ -{ \ - if(sizeof(type)==sizeof(int)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(int *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else if(sizeof(type)==sizeof(long)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else if(sizeof(type)==sizeof(long long)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = ((type)(*(int *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else if (sizeof(type) == sizeof(long)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = ((type)(*(long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else if (sizeof(type) == sizeof(long long)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = ((type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Postdecompress for floating-point type using variable-minimum-bits method */ -#define H5Z_scaleoffset_postdecompress_3(type, pow_fun, data, d_nelmts, filavail, cd_values, \ - minbits, minval, D_val) \ -{ \ - type *buf = (type *)data, filval = 0, min = 0; \ - unsigned i; \ - \ - H5Z_scaleoffset_get_min(type, minval, min) \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ - H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ - } else /* fill value undefined */ \ - H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ -} - +#define H5Z_scaleoffset_postdecompress_3(type, pow_fun, data, d_nelmts, filavail, cd_values, minbits, \ + minval, D_val) \ + { \ + type * buf = (type *)data, filval = 0, min = 0; \ + unsigned i; \ + \ + H5Z_scaleoffset_get_min(type, minval, min) \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) \ + { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ + H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ + } \ + else /* fill value undefined */ \ + H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ + } /*------------------------------------------------------------------------- * Function: H5Z_can_apply_scaleoffset @@ -685,41 +755,41 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ static htri_t H5Z_can_apply_scaleoffset(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - const H5T_t *type; /* Datatype */ - H5T_class_t dtype_class; /* Datatype's class */ - H5T_order_t dtype_order; /* Datatype's endianness order */ - htri_t ret_value = TRUE; /* Return value */ + const H5T_t *type; /* Datatype */ + H5T_class_t dtype_class; /* Datatype's class */ + H5T_order_t dtype_order; /* Datatype's endianness order */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class, for checking the "datatype class" */ - if((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) + if ((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Get datatype's size, for checking the "datatype size" */ - if(H5T_get_size(type) == 0) + if (H5T_get_size(type) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") - if(dtype_class == H5T_INTEGER || dtype_class == H5T_FLOAT) { + if (dtype_class == H5T_INTEGER || dtype_class == H5T_FLOAT) { /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order") /* Range check datatype's endianness order */ - if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) + if (dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FALSE, "bad datatype endianness order") - } else + } + else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FALSE, "datatype class not supported by scaleoffset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply_scaleoffset() */ - /*------------------------------------------------------------------------- * Function: H5Z_scaleoffset_get_type * @@ -739,40 +809,52 @@ done: static enum H5Z_scaleoffset_t H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign) { - enum H5Z_scaleoffset_t type = t_bad; /* integer type */ - enum H5Z_scaleoffset_t ret_value = t_bad; /* Return value */ + enum H5Z_scaleoffset_t type = t_bad; /* integer type */ + enum H5Z_scaleoffset_t ret_value = t_bad; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) { - if(dtype_sign==H5Z_SCALEOFFSET_SGN_NONE) { /* unsigned integer */ - if (dtype_size == sizeof(unsigned char)) type = t_uchar; - else if(dtype_size == sizeof(unsigned short)) type = t_ushort; - else if(dtype_size == sizeof(unsigned int)) type = t_uint; - else if(dtype_size == sizeof(unsigned long)) type = t_ulong; + if (dtype_class == H5Z_SCALEOFFSET_CLS_INTEGER) { + if (dtype_sign == H5Z_SCALEOFFSET_SGN_NONE) { /* unsigned integer */ + if (dtype_size == sizeof(unsigned char)) + type = t_uchar; + else if (dtype_size == sizeof(unsigned short)) + type = t_ushort; + else if (dtype_size == sizeof(unsigned int)) + type = t_uint; + else if (dtype_size == sizeof(unsigned long)) + type = t_ulong; #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if(dtype_size == sizeof(unsigned long long)) type = t_ulong_long; + else if (dtype_size == sizeof(unsigned long long)) + type = t_ulong_long; #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } - if(dtype_sign==H5Z_SCALEOFFSET_SGN_2) { /* signed integer */ - if (dtype_size == sizeof(signed char)) type = t_schar; - else if(dtype_size == sizeof(short)) type = t_short; - else if(dtype_size == sizeof(int)) type = t_int; - else if(dtype_size == sizeof(long)) type = t_long; + if (dtype_sign == H5Z_SCALEOFFSET_SGN_2) { /* signed integer */ + if (dtype_size == sizeof(signed char)) + type = t_schar; + else if (dtype_size == sizeof(short)) + type = t_short; + else if (dtype_size == sizeof(int)) + type = t_int; + else if (dtype_size == sizeof(long)) + type = t_long; #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if(dtype_size == sizeof(long long)) type = t_long_long; + else if (dtype_size == sizeof(long long)) + type = t_long_long; #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } } - if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) { - if(dtype_size == sizeof(float)) type = t_float; - else if(dtype_size == sizeof(double)) type = t_double; + if (dtype_class == H5Z_SCALEOFFSET_CLS_FLOAT) { + if (dtype_size == sizeof(float)) + type = t_float; + else if (dtype_size == sizeof(double)) + type = t_double; else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } @@ -784,7 +866,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_scaleoffset_set_parms_fillval * @@ -799,44 +880,45 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5Z_scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, - H5T_t *type, enum H5Z_scaleoffset_t scale_type, - unsigned cd_values[], int need_convert) +H5Z_scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, H5T_t *type, enum H5Z_scaleoffset_t scale_type, + unsigned cd_values[], int need_convert) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if(scale_type == t_uchar) - H5Z_scaleoffset_set_filval_3(unsigned char, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_ushort) - H5Z_scaleoffset_set_filval_1(unsigned short, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_uint) - H5Z_scaleoffset_set_filval_1(unsigned int, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_ulong) - H5Z_scaleoffset_set_filval_1(unsigned long, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_ulong_long) - H5Z_scaleoffset_set_filval_1(unsigned long long, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_schar) - H5Z_scaleoffset_set_filval_3(signed char, dcpl_plist, type, cd_values, need_convertd) - else if(scale_type == t_short) - H5Z_scaleoffset_set_filval_2(short, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_int) - H5Z_scaleoffset_set_filval_2(int, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_long) - H5Z_scaleoffset_set_filval_2(long, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_long_long) - H5Z_scaleoffset_set_filval_2(long long, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_float) - H5Z_scaleoffset_set_filval_4(float, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_double) - H5Z_scaleoffset_set_filval_4(double, dcpl_plist, type, cd_values, need_convert) - -done: - FUNC_LEAVE_NOAPI(ret_value) + if (scale_type == t_uchar) + H5Z_scaleoffset_set_filval_3(unsigned char, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_ushort) + H5Z_scaleoffset_set_filval_1(unsigned short, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_uint) + H5Z_scaleoffset_set_filval_1(unsigned int, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_ulong) + H5Z_scaleoffset_set_filval_1(unsigned long, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_ulong_long) + H5Z_scaleoffset_set_filval_1(unsigned long long, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_schar) + H5Z_scaleoffset_set_filval_3(signed char, dcpl_plist, type, cd_values, + need_convertd) else if (scale_type == t_short) + H5Z_scaleoffset_set_filval_2(short, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_int) + H5Z_scaleoffset_set_filval_2(int, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_long) + H5Z_scaleoffset_set_filval_2(long, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == + t_long_long) + H5Z_scaleoffset_set_filval_2( + long long, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_float) + H5Z_scaleoffset_set_filval_4( + float, dcpl_plist, type, cd_values, + need_convert) else if (scale_type == t_double) + H5Z_scaleoffset_set_filval_4(double, dcpl_plist, type, + cd_values, need_convert) + + done : FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_scaleoffset_set_parms_fillval() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_local_scaleoffset * @@ -856,55 +938,56 @@ done: static herr_t H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - H5P_genplist_t *dcpl_plist; /* Property list pointer */ - H5T_t *type; /* Datatype */ - const H5S_t *ds; /* Dataspace */ - unsigned flags; /* Filter flags */ - size_t cd_nelmts = H5Z_SCALEOFFSET_USER_NPARMS; /* Number of filter parameters */ - unsigned cd_values[H5Z_SCALEOFFSET_TOTAL_NPARMS]; /* Filter parameters */ - hssize_t npoints; /* Number of points in the dataspace */ - H5T_class_t dtype_class; /* Datatype's class */ - H5T_order_t dtype_order; /* Datatype's endianness order */ - size_t dtype_size; /* Datatype's size (in bytes) */ - H5T_sign_t dtype_sign; /* Datatype's sign */ - enum H5Z_scaleoffset_t scale_type; /* Specific datatype */ - H5D_fill_value_t status; /* Status of fill value in property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * dcpl_plist; /* Property list pointer */ + H5T_t * type; /* Datatype */ + const H5S_t * ds; /* Dataspace */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = H5Z_SCALEOFFSET_USER_NPARMS; /* Number of filter parameters */ + unsigned cd_values[H5Z_SCALEOFFSET_TOTAL_NPARMS]; /* Filter parameters */ + hssize_t npoints; /* Number of points in the dataspace */ + H5T_class_t dtype_class; /* Datatype's class */ + H5T_order_t dtype_order; /* Datatype's endianness order */ + size_t dtype_size; /* Datatype's size (in bytes) */ + H5T_sign_t dtype_sign; /* Datatype's sign */ + enum H5Z_scaleoffset_t scale_type; /* Specific datatype */ + H5D_fill_value_t status; /* Status of fill value in property list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get the plist structure */ - if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Initialize the parameters to a known state */ HDmemset(cd_values, 0, sizeof(cd_values)); /* Get the filter's current parameters */ - if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SCALEOFFSET, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) + if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SCALEOFFSET, &flags, &cd_nelmts, cd_values, (size_t)0, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get scaleoffset parameters") /* Get dataspace */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Get total number of elements in the chunk */ - if((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) + if ((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get number of points in the dataspace") /* Set "local" parameter for this dataset's number of elements */ H5_CHECKED_ASSIGN(cd_values[H5Z_SCALEOFFSET_PARM_NELMTS], unsigned, npoints, hssize_t); /* Get datatype's class */ - if((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) + if ((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Set "local" parameter for datatype's class */ - switch(dtype_class) { + switch (dtype_class) { case H5T_INTEGER: cd_values[H5Z_SCALEOFFSET_PARM_CLASS] = H5Z_SCALEOFFSET_CLS_INTEGER; break; @@ -929,20 +1012,20 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) } /* end switch */ /* Get datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) + if ((dtype_size = H5T_get_size(type)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for datatype size */ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned); cd_values[H5Z_SCALEOFFSET_PARM_SIZE] = (unsigned)dtype_size; - if(dtype_class == H5T_INTEGER) { + if (dtype_class == H5T_INTEGER) { /* Get datatype's sign */ - if((dtype_sign = H5T_get_sign(type)) == H5T_SGN_ERROR) + if ((dtype_sign = H5T_get_sign(type)) == H5T_SGN_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype sign") /* Set "local" parameter for integer datatype sign */ - switch(dtype_sign) { + switch (dtype_sign) { case H5T_SGN_NONE: cd_values[H5Z_SCALEOFFSET_PARM_SIGN] = H5Z_SCALEOFFSET_SGN_NONE; break; @@ -956,19 +1039,19 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) default: HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad integer sign") } /* end switch */ - } /* end if */ + } /* end if */ /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") /* Set "local" parameter for datatype endianness */ - switch(dtype_order) { - case H5T_ORDER_LE: /* Little-endian byte order */ + switch (dtype_order) { + case H5T_ORDER_LE: /* Little-endian byte order */ cd_values[H5Z_SCALEOFFSET_PARM_ORDER] = H5Z_SCALEOFFSET_ORDER_LE; break; - case H5T_ORDER_BE: /* Big-endian byte order */ + case H5T_ORDER_BE: /* Big-endian byte order */ cd_values[H5Z_SCALEOFFSET_PARM_ORDER] = H5Z_SCALEOFFSET_ORDER_BE; break; @@ -981,40 +1064,41 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) } /* end switch */ /* Check whether fill value is defined for dataset */ - if(H5P_fill_value_defined(dcpl_plist, &status) < 0) + if (H5P_fill_value_defined(dcpl_plist, &status) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to determine if fill value is defined") /* Set local parameter for availability of fill value */ - if(status == H5D_FILL_VALUE_UNDEFINED) + if (status == H5D_FILL_VALUE_UNDEFINED) cd_values[H5Z_SCALEOFFSET_PARM_FILAVAIL] = H5Z_SCALEOFFSET_FILL_UNDEFINED; else { - int need_convert = FALSE; /* Flag indicating conversion of byte order */ + int need_convert = FALSE; /* Flag indicating conversion of byte order */ cd_values[H5Z_SCALEOFFSET_PARM_FILAVAIL] = H5Z_SCALEOFFSET_FILL_DEFINED; /* Check if memory byte order matches dataset datatype byte order */ - if(H5T_native_order_g != dtype_order) + if (H5T_native_order_g != dtype_order) need_convert = TRUE; /* Before getting fill value, get its type */ - if((scale_type = H5Z_scaleoffset_get_type(cd_values[H5Z_SCALEOFFSET_PARM_CLASS], - cd_values[H5Z_SCALEOFFSET_PARM_SIZE], cd_values[H5Z_SCALEOFFSET_PARM_SIGN])) == 0) + if ((scale_type = H5Z_scaleoffset_get_type(cd_values[H5Z_SCALEOFFSET_PARM_CLASS], + cd_values[H5Z_SCALEOFFSET_PARM_SIZE], + cd_values[H5Z_SCALEOFFSET_PARM_SIGN])) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot use C integer datatype for cast") /* Get dataset fill value and store in cd_values[] */ - if(H5Z_scaleoffset_set_parms_fillval(dcpl_plist, type, scale_type, cd_values, need_convert) < 0) + if (H5Z_scaleoffset_set_parms_fillval(dcpl_plist, type, scale_type, cd_values, need_convert) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "unable to set fill value") } /* end else */ /* Modify the filter's parameters for this dataset */ - if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SCALEOFFSET, flags, (size_t)H5Z_SCALEOFFSET_TOTAL_NPARMS, cd_values) < 0) + if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_SCALEOFFSET, flags, (size_t)H5Z_SCALEOFFSET_TOTAL_NPARMS, + cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local scaleoffset parameters") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local_scaleoffset() */ - /*------------------------------------------------------------------------- * Function: H5Z_filter_scaleoffset * @@ -1032,42 +1116,42 @@ done: *------------------------------------------------------------------------- */ static size_t -H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf) { - size_t ret_value = 0; /* return value */ - size_t size_out = 0; /* size of output buffer */ - unsigned d_nelmts = 0; /* number of data elements in the chunk */ - unsigned dtype_class; /* datatype class */ - unsigned dtype_sign; /* integer datatype sign */ - unsigned filavail; /* flag indicating if fill value is defined or not */ - H5Z_SO_scale_type_t scale_type = H5Z_SO_FLOAT_DSCALE;/* scale type */ - int scale_factor = 0; /* scale factor */ - double D_val = 0.0f; /* decimal scale factor */ - uint32_t minbits = 0; /* minimum number of bits to store values */ - unsigned long long minval= 0; /* minimum value of input buffer */ - enum H5Z_scaleoffset_t type; /* memory type corresponding to dataset datatype */ - int need_convert = FALSE; /* flag indicating conversion of byte order */ - unsigned char *outbuf = NULL; /* pointer to new output buffer */ - unsigned buf_offset = 21; /* buffer offset because of parameters stored in file */ - unsigned i; /* index */ - parms_atomic p; /* parameters needed for compress/decompress functions */ + size_t ret_value = 0; /* return value */ + size_t size_out = 0; /* size of output buffer */ + unsigned d_nelmts = 0; /* number of data elements in the chunk */ + unsigned dtype_class; /* datatype class */ + unsigned dtype_sign; /* integer datatype sign */ + unsigned filavail; /* flag indicating if fill value is defined or not */ + H5Z_SO_scale_type_t scale_type = H5Z_SO_FLOAT_DSCALE; /* scale type */ + int scale_factor = 0; /* scale factor */ + double D_val = 0.0f; /* decimal scale factor */ + uint32_t minbits = 0; /* minimum number of bits to store values */ + unsigned long long minval = 0; /* minimum value of input buffer */ + enum H5Z_scaleoffset_t type; /* memory type corresponding to dataset datatype */ + int need_convert = FALSE; /* flag indicating conversion of byte order */ + unsigned char * outbuf = NULL; /* pointer to new output buffer */ + unsigned buf_offset = 21; /* buffer offset because of parameters stored in file */ + unsigned i; /* index */ + parms_atomic p; /* parameters needed for compress/decompress functions */ FUNC_ENTER_NOAPI_NOINIT /* check arguments */ - if(cd_nelmts != H5Z_SCALEOFFSET_TOTAL_NPARMS) + if (cd_nelmts != H5Z_SCALEOFFSET_TOTAL_NPARMS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid scaleoffset number of parameters") /* Check if memory byte order matches dataset datatype byte order */ - switch(H5T_native_order_g) { - case H5T_ORDER_LE: /* memory is little-endian byte order */ - if(cd_values[H5Z_SCALEOFFSET_PARM_ORDER] == H5Z_SCALEOFFSET_ORDER_BE) + switch (H5T_native_order_g) { + case H5T_ORDER_LE: /* memory is little-endian byte order */ + if (cd_values[H5Z_SCALEOFFSET_PARM_ORDER] == H5Z_SCALEOFFSET_ORDER_BE) need_convert = TRUE; break; - case H5T_ORDER_BE: /* memory is big-endian byte order */ - if(cd_values[H5Z_SCALEOFFSET_PARM_ORDER] == H5Z_SCALEOFFSET_ORDER_LE) + case H5T_ORDER_BE: /* memory is big-endian byte order */ + if (cd_values[H5Z_SCALEOFFSET_PARM_ORDER] == H5Z_SCALEOFFSET_ORDER_LE) need_convert = TRUE; break; @@ -1095,33 +1179,35 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value * scale factor is the fixed minimum number of bits * H5Z_SO_INT : integer type, scale_factor is minimum number of bits */ - if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) { /* floating-point type */ - if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE) + if (dtype_class == H5Z_SCALEOFFSET_CLS_FLOAT) { /* floating-point type */ + if (scale_type != H5Z_SO_FLOAT_DSCALE && scale_type != H5Z_SO_FLOAT_ESCALE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid scale type") } - if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) { /* integer type */ - if(scale_type!=H5Z_SO_INT) + if (dtype_class == H5Z_SCALEOFFSET_CLS_INTEGER) { /* integer type */ + if (scale_type != H5Z_SO_INT) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid scale type") /* if scale_factor is less than 0 for integer, library will reset it to 0 * in this case, library will calculate the minimum-bits */ - if(scale_factor < 0) scale_factor = 0; + if (scale_factor < 0) + scale_factor = 0; } /* fixed-minimum-bits method is not implemented and is forbidden */ - if(scale_type==H5Z_SO_FLOAT_ESCALE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "E-scaling method not supported") + if (scale_type == H5Z_SO_FLOAT_ESCALE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "E-scaling method not supported") - if(scale_type==H5Z_SO_FLOAT_DSCALE) { /* floating-point type, variable-minimum-bits */ + if (scale_type == H5Z_SO_FLOAT_DSCALE) { /* floating-point type, variable-minimum-bits */ D_val = (double)scale_factor; - } else { /* integer type, or floating-point type with fixed-minimum-bits method */ - if(scale_factor > (int)(cd_values[H5Z_SCALEOFFSET_PARM_SIZE] * 8)) + } + else { /* integer type, or floating-point type with fixed-minimum-bits method */ + if (scale_factor > (int)(cd_values[H5Z_SCALEOFFSET_PARM_SIZE] * 8)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "minimum number of bits exceeds maximum") /* no need to process data */ - if(scale_factor == (int)(cd_values[H5Z_SCALEOFFSET_PARM_SIZE] * 8)) { + if (scale_factor == (int)(cd_values[H5Z_SCALEOFFSET_PARM_SIZE] * 8)) { ret_value = *buf_size; goto done; } @@ -1129,7 +1215,7 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value } /* prepare parameters to pass to compress/decompress functions */ - p.size = cd_values[H5Z_SCALEOFFSET_PARM_SIZE]; + p.size = cd_values[H5Z_SCALEOFFSET_PARM_SIZE]; p.mem_order = H5T_native_order_g; /* input; decompress */ @@ -1137,14 +1223,14 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value /* retrieve values of minbits and minval from input compressed buffer * retrieve them corresponding to how they are stored during compression */ - uint32_t minbits_mask = 0; - unsigned long long minval_mask = 0; - unsigned minval_size = 0; + uint32_t minbits_mask = 0; + unsigned long long minval_mask = 0; + unsigned minval_size = 0; minbits = 0; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { minbits_mask = ((unsigned char *)*buf)[i]; - minbits_mask <<= i*8; + minbits_mask <<= i * 8; minbits |= minbits_mask; } @@ -1152,12 +1238,12 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value * unsigned long long (datatype of minval) may change from compression * to decompression, only smaller size is used */ - minval_size = sizeof(unsigned long long) <= ((unsigned char *)*buf)[4] ? - sizeof(unsigned long long) : ((unsigned char *)*buf)[4]; + minval_size = sizeof(unsigned long long) <= ((unsigned char *)*buf)[4] ? sizeof(unsigned long long) + : ((unsigned char *)*buf)[4]; minval = 0; - for(i = 0; i < minval_size; i++) { - minval_mask = ((unsigned char *)*buf)[5+i]; - minval_mask <<= i*8; + for (i = 0; i < minval_size; i++) { + minval_mask = ((unsigned char *)*buf)[5 + i]; + minval_mask <<= i * 8; minval |= minval_mask; } @@ -1168,52 +1254,53 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value size_out = d_nelmts * p.size; /* allocate memory space for decompressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for scaleoffset decompression") + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, + "memory allocation failed for scaleoffset decompression") /* special case: minbits equal to full precision */ - if(minbits == p.size * 8) { - H5MM_memcpy(outbuf, (unsigned char*)(*buf)+buf_offset, size_out); + if (minbits == p.size * 8) { + H5MM_memcpy(outbuf, (unsigned char *)(*buf) + buf_offset, size_out); /* free the original buffer */ H5MM_xfree(*buf); /* convert to dataset datatype endianness order if needed */ - if(need_convert) + if (need_convert) H5Z_scaleoffset_convert(outbuf, d_nelmts, p.size); - *buf = outbuf; - outbuf = NULL; + *buf = outbuf; + outbuf = NULL; *buf_size = size_out; ret_value = size_out; goto done; } /* decompress the buffer if minbits not equal to zero */ - if(minbits != 0) - H5Z_scaleoffset_decompress(outbuf, d_nelmts, (unsigned char*)(*buf)+buf_offset, p); + if (minbits != 0) + H5Z_scaleoffset_decompress(outbuf, d_nelmts, (unsigned char *)(*buf) + buf_offset, p); else { /* fill value is not defined and all data elements have the same value */ - for(i = 0; i < size_out; i++) outbuf[i] = 0; + for (i = 0; i < size_out; i++) + outbuf[i] = 0; } /* before postprocess, get memory type */ - if((type = H5Z_scaleoffset_get_type(dtype_class, p.size, dtype_sign)) == 0) + if ((type = H5Z_scaleoffset_get_type(dtype_class, p.size, dtype_sign)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot use C integer datatype for cast") /* postprocess after decompression */ - if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) - H5Z_scaleoffset_postdecompress_i(outbuf, d_nelmts, type, filavail, - cd_values, minbits, minval); - - if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) - if(scale_type==0) { /* variable-minimum-bits method */ - if(H5Z_scaleoffset_postdecompress_fd(outbuf, d_nelmts, type, filavail, - cd_values, minbits, minval, D_val)==FAIL) + if (dtype_class == H5Z_SCALEOFFSET_CLS_INTEGER) + H5Z_scaleoffset_postdecompress_i(outbuf, d_nelmts, type, filavail, cd_values, minbits, minval); + + if (dtype_class == H5Z_SCALEOFFSET_CLS_FLOAT) + if (scale_type == 0) { /* variable-minimum-bits method */ + if (H5Z_scaleoffset_postdecompress_fd(outbuf, d_nelmts, type, filavail, cd_values, minbits, + minval, D_val) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "post-decompression failed") } /* after postprocess, convert to dataset datatype endianness order if needed */ - if(need_convert) + if (need_convert) H5Z_scaleoffset_convert(outbuf, d_nelmts, p.size); } /* output; compress */ @@ -1221,22 +1308,21 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value HDassert(nbytes == d_nelmts * p.size); /* before preprocess, convert to memory endianness order if needed */ - if(need_convert) + if (need_convert) H5Z_scaleoffset_convert(*buf, d_nelmts, p.size); /* before preprocess, get memory type */ - if((type = H5Z_scaleoffset_get_type(dtype_class, p.size, dtype_sign))==0) + if ((type = H5Z_scaleoffset_get_type(dtype_class, p.size, dtype_sign)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot use C integer datatype for cast") /* preprocess before compression */ - if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) - H5Z_scaleoffset_precompress_i(*buf, d_nelmts, type, filavail, - cd_values, &minbits, &minval); - - if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) - if(scale_type==0) { /* variable-minimum-bits method */ - if(H5Z_scaleoffset_precompress_fd(*buf, d_nelmts, type, filavail, - cd_values, &minbits, &minval, D_val)==FAIL) + if (dtype_class == H5Z_SCALEOFFSET_CLS_INTEGER) + H5Z_scaleoffset_precompress_i(*buf, d_nelmts, type, filavail, cd_values, &minbits, &minval); + + if (dtype_class == H5Z_SCALEOFFSET_CLS_FLOAT) + if (scale_type == 0) { /* variable-minimum-bits method */ + if (H5Z_scaleoffset_precompress_fd(*buf, d_nelmts, type, filavail, cd_values, &minbits, + &minval, D_val) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "pre-compression failed") } @@ -1246,10 +1332,10 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value * minbits and minval are stored in the front of the compressed buffer */ p.minbits = minbits; - size_out = buf_offset + nbytes * p.minbits / (p.size * 8) + 1; /* may be 1 larger */ + size_out = buf_offset + nbytes * p.minbits / (p.size * 8) + 1; /* may be 1 larger */ /* allocate memory space for compressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for scaleoffset compression") /* store minbits and minval in the front of output compressed buffer @@ -1257,13 +1343,14 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value * constant buffer size (21 bytes) is left for these two parameters * 4 bytes for minbits, 1 byte for size of minval, 16 bytes for minval */ - for(i = 0; i < 4; i++) - ((unsigned char *)outbuf)[i] = (unsigned char)((minbits & ((uint32_t)0xff << i*8)) >> i*8); + for (i = 0; i < 4; i++) + ((unsigned char *)outbuf)[i] = (unsigned char)((minbits & ((uint32_t)0xff << i * 8)) >> i * 8); ((unsigned char *)outbuf)[4] = sizeof(unsigned long long); - for(i = 0; i < sizeof(unsigned long long); i++) - ((unsigned char *)outbuf)[5+i] = (unsigned char)((minval & ((unsigned long long)0xff << i*8)) >> i*8); + for (i = 0; i < sizeof(unsigned long long); i++) + ((unsigned char *)outbuf)[5 + i] = + (unsigned char)((minval & ((unsigned long long)0xff << i * 8)) >> i * 8); /* Zero out remaining, unused bytes */ /* (Looks like an error in the original determination of how many @@ -1272,13 +1359,13 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value HDmemset(outbuf + 13, 0, (size_t)8); /* special case: minbits equal to full precision */ - if(minbits == p.size * 8) { + if (minbits == p.size * 8) { H5MM_memcpy(outbuf + buf_offset, *buf, nbytes); /* free the original buffer */ H5MM_xfree(*buf); - *buf = outbuf; - outbuf = NULL; + *buf = outbuf; + outbuf = NULL; *buf_size = size_out; ret_value = buf_offset + nbytes; goto done; @@ -1288,21 +1375,22 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value * minbits equal to zero only when fill value is not defined and * all data elements have the same value */ - if(minbits != 0) - H5Z_scaleoffset_compress((unsigned char *)*buf, d_nelmts, outbuf + buf_offset, size_out - buf_offset, p); + if (minbits != 0) + H5Z_scaleoffset_compress((unsigned char *)*buf, d_nelmts, outbuf + buf_offset, + size_out - buf_offset, p); } /* free the input buffer */ H5MM_xfree(*buf); /* set return values */ - *buf = outbuf; - outbuf = NULL; + *buf = outbuf; + outbuf = NULL; *buf_size = size_out; ret_value = size_out; done: - if(outbuf) + if (outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } @@ -1315,26 +1403,25 @@ done: * atomic datatype is treated on byte basis */ - /* change byte order of input buffer either from little-endian to big-endian * or from big-endian to little-endian 2/21/2005 */ static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size) { - if(dtype_size > 1) { - size_t i, j; - unsigned char *buffer, temp; - - buffer = (unsigned char *)buf; - for(i = 0; i < d_nelmts * dtype_size; i += dtype_size) - for(j = 0; j < dtype_size / 2; j++) { - /* swap pair of bytes */ - temp = buffer[i + j]; - buffer[i + j] = buffer[i + dtype_size - 1 - j]; - buffer[i + dtype_size - 1 - j] = temp; - } /* end for */ - } /* end if */ + if (dtype_size > 1) { + size_t i, j; + unsigned char *buffer, temp; + + buffer = (unsigned char *)buf; + for (i = 0; i < d_nelmts * dtype_size; i += dtype_size) + for (j = 0; j < dtype_size / 2; j++) { + /* swap pair of bytes */ + temp = buffer[i + j]; + buffer[i + j] = buffer[i + dtype_size - 1 - j]; + buffer[i + dtype_size - 1 - j] = temp; + } /* end for */ + } /* end if */ } /* end H5Z_scaleoffset_convert() */ /* return ceiling of floating-point log2 function @@ -1343,357 +1430,358 @@ H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size) static unsigned H5Z_scaleoffset_log2(unsigned long long num) { - unsigned v = 0; - unsigned long long lower_bound = 1; /* is power of 2, largest value <= num */ - unsigned long long val = num; - - while(val >>= 1) { - v++; - lower_bound <<= 1; - } - - if(num == lower_bound) - return v; - else - return v + 1; + unsigned v = 0; + unsigned long long lower_bound = 1; /* is power of 2, largest value <= num */ + unsigned long long val = num; + + while (val >>= 1) { + v++; + lower_bound <<= 1; + } + + if (num == lower_bound) + return v; + else + return v + 1; } /* precompress for integer type */ static void -H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, - unsigned filavail, const unsigned cd_values[], uint32_t *minbits, unsigned long long *minval) +H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, unsigned filavail, + const unsigned cd_values[], uint32_t *minbits, unsigned long long *minval) { - if(type == t_uchar) - H5Z_scaleoffset_precompress_1(unsigned char, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_ushort) - H5Z_scaleoffset_precompress_1(unsigned short, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_uint) - H5Z_scaleoffset_precompress_1(unsigned int, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_ulong) - H5Z_scaleoffset_precompress_1(unsigned long, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_ulong_long) - H5Z_scaleoffset_precompress_1(unsigned long long, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_schar) { - signed char *buf = (signed char *)data, min = 0, max = 0, filval = 0; - unsigned char span; - unsigned i; - - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ - H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval); - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ - H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) - if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) { - *minbits = sizeof(signed char)*8; - return; + if (type == t_uchar) + H5Z_scaleoffset_precompress_1(unsigned char, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_ushort) + H5Z_scaleoffset_precompress_1(unsigned short, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_uint) + H5Z_scaleoffset_precompress_1(unsigned int, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_ulong) + H5Z_scaleoffset_precompress_1(unsigned long, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_ulong_long) + H5Z_scaleoffset_precompress_1(unsigned long long, data, d_nelmts, filavail, cd_values, + minbits, minval) else if (type == t_schar) + { + signed char * buf = (signed char *)data, min = 0, max = 0, filval = 0; + unsigned char span; + unsigned i; + + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ + H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval); + if (*minbits == + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ + H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, + min) if ((unsigned char)(max - min) > + (unsigned char)(~(unsigned char)0 - 2)) + { + *minbits = sizeof(signed char) * 8; + return; + } + span = (unsigned char)(max - min + 1); + *minbits = H5Z_scaleoffset_log2((unsigned long long)(span + 1)); } - span = (unsigned char)(max - min + 1); - *minbits = H5Z_scaleoffset_log2((unsigned long long)(span+1)); - } else /* minbits already set, only calculate min */ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) - if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ - for(i = 0; i < d_nelmts; i++) - buf[i] = (signed char)((buf[i] == filval) ? (((unsigned char)1 << *minbits) - 1) : (buf[i] - min)); - } else { /* fill value undefined */ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) - if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) { - *minbits = sizeof(signed char)*8; - *minval = (unsigned long long)min; - return; + else /* minbits already set, only calculate min */ + H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, + min) if (*minbits != + sizeof(signed char) * + 8) /* change values if minbits != full precision */ + for (i = 0; i < d_nelmts; i++) buf[i] = + (signed char)((buf[i] == filval) ? (((unsigned char)1 << *minbits) - 1) + : (buf[i] - min)); + } + else { /* fill value undefined */ + if (*minbits == + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, + min) if ((unsigned char)(max - min) > + (unsigned char)(~(unsigned char)0 - 2)) + { + *minbits = sizeof(signed char) * 8; + *minval = (unsigned long long)min; + return; + } + span = (unsigned char)(max - min + 1); + *minbits = H5Z_scaleoffset_log2((unsigned long long)span); } - span = (unsigned char)(max - min + 1); - *minbits = H5Z_scaleoffset_log2((unsigned long long)span); - } else /* minbits already set, only calculate min */ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) - if(*minbits != sizeof(signed char) * 8) /* change values if minbits != full precision */ - for(i = 0; i < d_nelmts; i++) - buf[i] = (signed char)(buf[i] - min); + else /* minbits already set, only calculate min */ + H5Z_scaleoffset_min_2(i, d_nelmts, buf, + min) if (*minbits != + sizeof(signed char) * + 8) /* change values if minbits != full precision */ + for (i = 0; i < d_nelmts; i++) buf[i] = (signed char)(buf[i] - min); + } + *minval = (unsigned long long)min; } - *minval = (unsigned long long)min; - } - else if(type == t_short) - H5Z_scaleoffset_precompress_2(short, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_int) - H5Z_scaleoffset_precompress_2(int, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_long) - H5Z_scaleoffset_precompress_2(long, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_long_long) - H5Z_scaleoffset_precompress_2(long long, data, d_nelmts, - filavail, cd_values, minbits, minval) + else if (type == t_short) + H5Z_scaleoffset_precompress_2(short, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_int) + H5Z_scaleoffset_precompress_2(int, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_long) + H5Z_scaleoffset_precompress_2(long, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_long_long) + H5Z_scaleoffset_precompress_2(long long, data, d_nelmts, filavail, cd_values, minbits, + minval) } /* postdecompress for integer type */ static void H5Z_scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, - unsigned filavail, const unsigned cd_values[], uint32_t minbits, unsigned long long minval) + unsigned filavail, const unsigned cd_values[], uint32_t minbits, + unsigned long long minval) { - long long sminval = *(long long*)&minval; /* for signed integer types */ - - if(type == t_uchar) - H5Z_scaleoffset_postdecompress_1(unsigned char, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_ushort) - H5Z_scaleoffset_postdecompress_1(unsigned short, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_uint) - H5Z_scaleoffset_postdecompress_1(unsigned int, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_ulong) - H5Z_scaleoffset_postdecompress_1(unsigned long, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_ulong_long) - H5Z_scaleoffset_postdecompress_1(unsigned long long, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_schar) { - signed char *buf = (signed char *)data, filval = 0; - unsigned i; - - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ - H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval) - for(i = 0; i < d_nelmts; i++) - buf[i] = (signed char)((buf[i] == (((unsigned char)1 << minbits) - 1)) ? filval : (buf[i] + sminval)); - } else /* fill value undefined */ - for(i = 0; i < d_nelmts; i++) - buf[i] = (signed char)(buf[i] + sminval); - } - else if(type == t_short) - H5Z_scaleoffset_postdecompress_2(short, data, d_nelmts, filavail, - cd_values, minbits, sminval) - else if(type == t_int) - H5Z_scaleoffset_postdecompress_2(int, data, d_nelmts, filavail, - cd_values, minbits, sminval) - else if(type == t_long) - H5Z_scaleoffset_postdecompress_2(long, data, d_nelmts, filavail, - cd_values, minbits, sminval) - else if(type == t_long_long) - H5Z_scaleoffset_postdecompress_2(long long, data, d_nelmts, filavail, - cd_values, minbits, sminval) + long long sminval = *(long long *)&minval; /* for signed integer types */ + + if (type == t_uchar) + H5Z_scaleoffset_postdecompress_1(unsigned char, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_ushort) + H5Z_scaleoffset_postdecompress_1(unsigned short, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_uint) + H5Z_scaleoffset_postdecompress_1(unsigned int, data, d_nelmts, filavail, cd_values, minbits, + minval) else if (type == t_ulong) + H5Z_scaleoffset_postdecompress_1(unsigned long, data, d_nelmts, filavail, cd_values, + minbits, minval) else if (type == t_ulong_long) + H5Z_scaleoffset_postdecompress_1(unsigned long long, data, d_nelmts, filavail, + cd_values, minbits, minval) else if (type == t_schar) + { + signed char *buf = (signed char *)data, filval = 0; + unsigned i; + + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ + H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval) for (i = 0; i < d_nelmts; i++) + buf[i] = + (signed char)((buf[i] == (((unsigned char)1 << minbits) - 1)) ? filval + : (buf[i] + sminval)); + } + else /* fill value undefined */ + for (i = 0; i < d_nelmts; i++) + buf[i] = (signed char)(buf[i] + sminval); + } + else if (type == t_short) + H5Z_scaleoffset_postdecompress_2(short, data, d_nelmts, filavail, cd_values, minbits, + sminval) else if (type == t_int) + H5Z_scaleoffset_postdecompress_2(int, data, d_nelmts, filavail, cd_values, minbits, + sminval) else if (type == t_long) + H5Z_scaleoffset_postdecompress_2(long, data, d_nelmts, filavail, cd_values, minbits, + sminval) else if (type == t_long_long) + H5Z_scaleoffset_postdecompress_2(long long, data, d_nelmts, filavail, cd_values, minbits, + sminval) } /* precompress for floating-point type, variable-minimum-bits method success: non-negative, failure: negative 4/15/05 */ static herr_t -H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, - unsigned filavail, const unsigned cd_values[], uint32_t *minbits, - unsigned long long *minval, double D_val) +H5Z_scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, unsigned filavail, + const unsigned cd_values[], uint32_t *minbits, unsigned long long *minval, + double D_val) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if(type == t_float) + if (type == t_float) H5Z_scaleoffset_precompress_3(float, HDpowf, HDfabsf, HDroundf, HDlroundf, HDllroundf, data, d_nelmts, - filavail, cd_values, minbits, minval, D_val) - else if(type == t_double) - H5Z_scaleoffset_precompress_3(double, HDpow, HDfabs, HDround, HDlround, HDllround, data, d_nelmts, - filavail, cd_values, minbits, minval, D_val) + filavail, cd_values, minbits, minval, D_val) else if (type == t_double) + H5Z_scaleoffset_precompress_3(double, HDpow, HDfabs, HDround, HDlround, HDllround, data, d_nelmts, + filavail, cd_values, minbits, minval, D_val) -done: - FUNC_LEAVE_NOAPI(ret_value) + done : FUNC_LEAVE_NOAPI(ret_value) } /* postdecompress for floating-point type, variable-minimum-bits method success: non-negative, failure: negative 4/15/05 */ static herr_t H5Z_scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, - unsigned filavail, const unsigned cd_values[], uint32_t minbits, - unsigned long long minval, double D_val) + unsigned filavail, const unsigned cd_values[], uint32_t minbits, + unsigned long long minval, double D_val) { - long long sminval = (long long)minval; /* for signed integer types */ - herr_t ret_value=SUCCEED; /* Return value */ + long long sminval = (long long)minval; /* for signed integer types */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT - if(type == t_float) - H5Z_scaleoffset_postdecompress_3(float, HDpowf, data, d_nelmts, filavail, - cd_values, minbits, sminval, D_val) - else if(type == t_double) - H5Z_scaleoffset_postdecompress_3(double, HDpow, data, d_nelmts, filavail, - cd_values, minbits, sminval, D_val) + if (type == t_float) + H5Z_scaleoffset_postdecompress_3(float, HDpowf, data, d_nelmts, filavail, cd_values, minbits, sminval, + D_val) else if (type == t_double) + H5Z_scaleoffset_postdecompress_3(double, HDpow, data, d_nelmts, filavail, cd_values, minbits, + sminval, D_val) -done: - FUNC_LEAVE_NOAPI(ret_value) + done : FUNC_LEAVE_NOAPI(ret_value) } static void H5Z_scaleoffset_next_byte(size_t *j, unsigned *buf_len) { - ++(*j); - *buf_len = 8 * sizeof(unsigned char); + ++(*j); + *buf_len = 8 * sizeof(unsigned char); } static void -H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, - parms_atomic p, unsigned dtype_len) +H5Z_scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, + unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p, + unsigned dtype_len) { - unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - /* initialize value and bits of unsigned char to be copied */ - val = buffer[*j]; - if(k == begin_i) - dat_len = 8 - (dtype_len - p.minbits) % 8; - else - dat_len = 8; - - if(*buf_len > dat_len) { - data[data_offset + k] = (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)~0 << dat_len))); - *buf_len -= dat_len; - } /* end if */ - else { - data[data_offset + k] = (unsigned char)((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)); - dat_len -= *buf_len; - H5Z_scaleoffset_next_byte(j, buf_len); - if(dat_len == 0) - return; - - val = buffer[*j]; - data[data_offset + k] |= (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & ~((unsigned)(~0) << dat_len)); - *buf_len -= dat_len; - } /* end else */ + unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + /* initialize value and bits of unsigned char to be copied */ + val = buffer[*j]; + if (k == begin_i) + dat_len = 8 - (dtype_len - p.minbits) % 8; + else + dat_len = 8; + + if (*buf_len > dat_len) { + data[data_offset + k] = + (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)~0 << dat_len))); + *buf_len -= dat_len; + } /* end if */ + else { + data[data_offset + k] = + (unsigned char)((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)); + dat_len -= *buf_len; + H5Z_scaleoffset_next_byte(j, buf_len); + if (dat_len == 0) + return; + + val = buffer[*j]; + data[data_offset + k] |= + (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & ~((unsigned)(~0) << dat_len)); + *buf_len -= dat_len; + } /* end else */ } static void -H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p) +H5Z_scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, unsigned *buf_len, parms_atomic p) { - /* begin_i: the index of byte having first significant bit */ - unsigned begin_i; - unsigned dtype_len; - int k; + /* begin_i: the index of byte having first significant bit */ + unsigned begin_i; + unsigned dtype_len; + int k; - HDassert(p.minbits > 0); + HDassert(p.minbits > 0); - dtype_len = p.size * 8; + dtype_len = p.size * 8; - if(p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ - begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; + if (p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ + begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; - for(k = (int)begin_i; k >= 0; k--) - H5Z_scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, - buffer, j, buf_len, p, dtype_len); - } - else { /* big endian */ - HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); + for (k = (int)begin_i; k >= 0; k--) + H5Z_scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, + p, dtype_len); + } + else { /* big endian */ + HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); - begin_i = (dtype_len - p.minbits) / 8; + begin_i = (dtype_len - p.minbits) / 8; - for(k = (int)begin_i; k <= (int)(p.size - 1); k++) - H5Z_scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, - buffer, j, buf_len, p, dtype_len); - } + for (k = (int)begin_i; k <= (int)(p.size - 1); k++) + H5Z_scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, + p, dtype_len); + } } static void -H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, parms_atomic p) +H5Z_scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, parms_atomic p) { /* i: index of data, j: index of buffer, buf_len: number of bits to be filled in current byte */ - size_t i, j; + size_t i, j; unsigned buf_len; /* must initialize to zeros */ - for(i = 0; i < d_nelmts * p.size; i++) + for (i = 0; i < d_nelmts * p.size; i++) data[i] = 0; /* initialization before the loop */ - j = 0; + j = 0; buf_len = sizeof(unsigned char) * 8; /* decompress */ - for(i = 0; i < d_nelmts; i++) + for (i = 0; i < d_nelmts; i++) H5Z_scaleoffset_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, p); } static void -H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, - parms_atomic p, unsigned dtype_len) +H5Z_scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, + unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p, + unsigned dtype_len) { - unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - /* initialize value and bits of unsigned char to be copied */ - val = data[data_offset + k]; - if(k == begin_i) - dat_len = 8 - (dtype_len - p.minbits) % 8; - else - dat_len = 8; - - if(*buf_len > dat_len) { - buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } else { - buffer[*j] |= (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); - dat_len -= *buf_len; - H5Z_scaleoffset_next_byte(j, buf_len); - if(dat_len == 0) - return; - - buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } /* end else */ + unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + /* initialize value and bits of unsigned char to be copied */ + val = data[data_offset + k]; + if (k == begin_i) + dat_len = 8 - (dtype_len - p.minbits) % 8; + else + dat_len = 8; + + if (*buf_len > dat_len) { + buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } + else { + buffer[*j] |= + (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); + dat_len -= *buf_len; + H5Z_scaleoffset_next_byte(j, buf_len); + if (dat_len == 0) + return; + + buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } /* end else */ } static void -H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p) +H5Z_scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + unsigned *buf_len, parms_atomic p) { - /* begin_i: the index of byte having first significant bit */ - unsigned begin_i; - unsigned dtype_len; - int k; - - HDassert(p.minbits > 0); - - dtype_len = p.size * 8; - - if(p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ - begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; - - for(k = (int)begin_i; k >= 0; k--) - H5Z_scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, - buffer, j, buf_len, p, dtype_len); - } - else { /* big endian */ - HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); - begin_i = (dtype_len - p.minbits) / 8; - - for(k = (int)begin_i; k <= (int)(p.size - 1); k++) - H5Z_scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, - buffer, j, buf_len, p, dtype_len); - } + /* begin_i: the index of byte having first significant bit */ + unsigned begin_i; + unsigned dtype_len; + int k; + + HDassert(p.minbits > 0); + + dtype_len = p.size * 8; + + if (p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ + begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; + + for (k = (int)begin_i; k >= 0; k--) + H5Z_scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, p, + dtype_len); + } + else { /* big endian */ + HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); + begin_i = (dtype_len - p.minbits) / 8; + + for (k = (int)begin_i; k <= (int)(p.size - 1); k++) + H5Z_scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, p, + dtype_len); + } } static void -H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, size_t buffer_size, parms_atomic p) +H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, size_t buffer_size, + parms_atomic p) { - /* i: index of data, j: index of buffer, - buf_len: number of bits to be filled in current byte */ - size_t i, j; - unsigned buf_len; - - /* must initialize buffer to be zeros */ - for(j = 0; j < buffer_size; j++) - buffer[j] = 0; - - /* initialization before the loop */ - j = 0; - buf_len = sizeof(unsigned char) * 8; - - /* compress */ - for(i = 0; i < d_nelmts; i++) - H5Z_scaleoffset_compress_one_atomic(data, i * p.size, buffer, &j, &buf_len, p); -} + /* i: index of data, j: index of buffer, + buf_len: number of bits to be filled in current byte */ + size_t i, j; + unsigned buf_len; + + /* must initialize buffer to be zeros */ + for (j = 0; j < buffer_size; j++) + buffer[j] = 0; + + /* initialization before the loop */ + j = 0; + buf_len = sizeof(unsigned char) * 8; + /* compress */ + for (i = 0; i < d_nelmts; i++) + H5Z_scaleoffset_compress_one_atomic(data, i * p.size, buffer, &j, &buf_len, p); +} diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index b1d0722..e34bdf0 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -11,38 +11,36 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Zpkg.h" /* Data filters */ /* Local function prototypes */ static herr_t H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_SHUFFLE[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_SHUFFLE, /* Filter id number */ - 1, /* encoder_present flag (set to true) */ - 1, /* decoder_present flag (set to true) */ - "shuffle", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - H5Z_set_local_shuffle, /* The "set local" callback */ - H5Z_filter_shuffle, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_SHUFFLE, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ + "shuffle", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + H5Z_set_local_shuffle, /* The "set local" callback */ + H5Z_filter_shuffle, /* The actual filter function */ }}; /* Local macros */ -#define H5Z_SHUFFLE_PARM_SIZE 0 /* "Local" parameter for shuffling size */ +#define H5Z_SHUFFLE_PARM_SIZE 0 /* "Local" parameter for shuffling size */ - /*------------------------------------------------------------------------- * Function: H5Z_set_local_shuffle * @@ -62,40 +60,41 @@ const H5Z_class2_t H5Z_SHUFFLE[1] = {{ static herr_t H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - H5P_genplist_t *dcpl_plist; /* Property list pointer */ - const H5T_t *type; /* Datatype */ - unsigned flags; /* Filter flags */ - size_t cd_nelmts = H5Z_SHUFFLE_USER_NPARMS; /* Number of filter parameters */ - unsigned cd_values[H5Z_SHUFFLE_TOTAL_NPARMS]; /* Filter parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dcpl_plist; /* Property list pointer */ + const H5T_t * type; /* Datatype */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = H5Z_SHUFFLE_USER_NPARMS; /* Number of filter parameters */ + unsigned cd_values[H5Z_SHUFFLE_TOTAL_NPARMS]; /* Filter parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the plist structure */ - if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get datatype */ - if(NULL == (type = (const H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (type = (const H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get the filter's current parameters */ - if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SHUFFLE, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters") + if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SHUFFLE, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, + NULL) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters") /* Set "local" parameter for this dataset */ - if((cd_values[H5Z_SHUFFLE_PARM_SIZE] = (unsigned)H5T_get_size(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if ((cd_values[H5Z_SHUFFLE_PARM_SIZE] = (unsigned)H5T_get_size(type)) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Modify the filter's parameters for this dataset */ - if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SHUFFLE, flags, (size_t)H5Z_SHUFFLE_TOTAL_NPARMS, cd_values) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local shuffle parameters") + if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_SHUFFLE, flags, (size_t)H5Z_SHUFFLE_TOTAL_NPARMS, + cd_values) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local shuffle parameters") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local_shuffle() */ - /*------------------------------------------------------------------------- * Function: H5Z_filter_shuffle * @@ -119,170 +118,168 @@ done: *------------------------------------------------------------------------- */ static size_t -H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf) { - void *dest = NULL; /* Buffer to deposit [un]shuffled bytes into */ - unsigned char *_src=NULL; /* Alias for source buffer */ - unsigned char *_dest=NULL; /* Alias for destination buffer */ - unsigned bytesoftype; /* Number of bytes per element */ - size_t numofelements; /* Number of elements in buffer */ - size_t i; /* Local index variables */ + void * dest = NULL; /* Buffer to deposit [un]shuffled bytes into */ + unsigned char *_src = NULL; /* Alias for source buffer */ + unsigned char *_dest = NULL; /* Alias for destination buffer */ + unsigned bytesoftype; /* Number of bytes per element */ + size_t numofelements; /* Number of elements in buffer */ + size_t i; /* Local index variables */ #ifdef NO_DUFFS_DEVICE - size_t j; /* Local index variable */ -#endif /* NO_DUFFS_DEVICE */ - size_t leftover; /* Extra bytes at end of buffer */ - size_t ret_value = 0; /* Return value */ + size_t j; /* Local index variable */ +#endif /* NO_DUFFS_DEVICE */ + size_t leftover; /* Extra bytes at end of buffer */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Check arguments */ - if (cd_nelmts!=H5Z_SHUFFLE_TOTAL_NPARMS || cd_values[H5Z_SHUFFLE_PARM_SIZE]==0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid shuffle parameters") + if (cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS || cd_values[H5Z_SHUFFLE_PARM_SIZE] == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid shuffle parameters") /* Get the number of bytes per element from the parameter block */ - bytesoftype=cd_values[H5Z_SHUFFLE_PARM_SIZE]; + bytesoftype = cd_values[H5Z_SHUFFLE_PARM_SIZE]; /* Compute the number of elements in buffer */ - numofelements=nbytes/bytesoftype; + numofelements = nbytes / bytesoftype; /* Don't do anything for 1-byte elements, or "fractional" elements */ - if(bytesoftype > 1 && numofelements > 1) { + if (bytesoftype > 1 && numofelements > 1) { /* Compute the leftover bytes if there are any */ - leftover = nbytes%bytesoftype; + leftover = nbytes % bytesoftype; /* Allocate the destination buffer */ - if (NULL==(dest = H5MM_malloc(nbytes))) + if (NULL == (dest = H5MM_malloc(nbytes))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for shuffle buffer") - if(flags & H5Z_FLAG_REVERSE) { + if (flags & H5Z_FLAG_REVERSE) { /* Get the pointer to the source buffer */ - _src =(unsigned char *)(*buf); + _src = (unsigned char *)(*buf); /* Input; unshuffle */ - for(i=0; i 0) { + while (j > 0) { DUFF_GUTS; j--; } /* end for */ -#else /* NO_DUFFS_DEVICE */ - { - size_t duffs_index; /* Counting index for Duff's device */ - - duffs_index = (numofelements + 7) / 8; - switch (numofelements % 8) { - default: - HDassert(0 && "This Should never be executed!"); - break; - case 0: - do - { - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 7: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 6: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 5: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 4: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 3: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 2: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 1: - DUFF_GUTS - } while (--duffs_index > 0); - } /* end switch */ - } -#endif /* NO_DUFFS_DEVICE */ +#else /* NO_DUFFS_DEVICE */ + { + size_t duffs_index; /* Counting index for Duff's device */ + + duffs_index = (numofelements + 7) / 8; + switch (numofelements % 8) { + default: + HDassert(0 && "This Should never be executed!"); + break; + case 0: + do { + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 7: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 6: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 5: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 4: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 3: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 2: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 1: + DUFF_GUTS + } while (--duffs_index > 0); + } /* end switch */ + } +#endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS } /* end for */ /* Add leftover to the end of data */ - if(leftover>0) { + if (leftover > 0) { /* Adjust back to end of shuffled bytes */ - _dest -= (bytesoftype - 1); /*lint !e794 _dest is initialized */ - H5MM_memcpy((void*)_dest, (void*)_src, leftover); + _dest -= (bytesoftype - 1); /*lint !e794 _dest is initialized */ + H5MM_memcpy((void *)_dest, (void *)_src, leftover); } } /* end if */ else { /* Get the pointer to the destination buffer */ - _dest =(unsigned char *)dest; + _dest = (unsigned char *)dest; /* Output; shuffle */ - for(i=0; i 0) { + while (j > 0) { DUFF_GUTS; j--; } /* end for */ -#else /* NO_DUFFS_DEVICE */ - { - size_t duffs_index; /* Counting index for Duff's device */ - - duffs_index = (numofelements + 7) / 8; - switch (numofelements % 8) { - default: - HDassert(0 && "This Should never be executed!"); - break; - case 0: - do - { - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 7: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 6: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 5: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 4: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 3: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 2: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 1: - DUFF_GUTS - } while (--duffs_index > 0); - } /* end switch */ - } -#endif /* NO_DUFFS_DEVICE */ +#else /* NO_DUFFS_DEVICE */ + { + size_t duffs_index; /* Counting index for Duff's device */ + + duffs_index = (numofelements + 7) / 8; + switch (numofelements % 8) { + default: + HDassert(0 && "This Should never be executed!"); + break; + case 0: + do { + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 7: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 6: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 5: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 4: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 3: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 2: + DUFF_GUTS + H5_ATTR_FALLTHROUGH + case 1: + DUFF_GUTS + } while (--duffs_index > 0); + } /* end switch */ + } +#endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS } /* end for */ /* Add leftover to the end of data */ - if(leftover>0) { + if (leftover > 0) { /* Adjust back to end of shuffled bytes */ - _src -= (bytesoftype - 1); /*lint !e794 _src is initialized */ - H5MM_memcpy((void*)_dest, (void*)_src, leftover); + _src -= (bytesoftype - 1); /*lint !e794 _src is initialized */ + H5MM_memcpy((void *)_dest, (void *)_src, leftover); } } /* end else */ @@ -290,8 +287,8 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], H5MM_xfree(*buf); /* Set the buffer information to return */ - *buf = dest; - *buf_size=nbytes; + *buf = dest; + *buf_size = nbytes; } /* end else */ /* Set the return value */ @@ -300,4 +297,3 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], done: FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Zszip.c b/src/H5Zszip.c index 8ed173e..b3e7491 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -11,46 +11,43 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_FILTER_SZIP #ifdef H5_HAVE_SZLIB_H -# include "szlib.h" +#include "szlib.h" #endif /* Local function prototypes */ static htri_t H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id); static herr_t H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t H5Z_filter_szip (unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ H5Z_class2_t H5Z_SZIP[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_SZIP, /* Filter id number */ - 1, /* Assume encoder present: check before registering */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_SZIP, /* Filter id number */ + 1, /* Assume encoder present: check before registering */ 1, /* decoder_present flag (set to true) */ - "szip", /* Filter name for debugging */ - H5Z_can_apply_szip, /* The "can apply" callback */ - H5Z_set_local_szip, /* The "set local" callback */ - H5Z_filter_szip, /* The actual filter function */ + "szip", /* Filter name for debugging */ + H5Z_can_apply_szip, /* The "can apply" callback */ + H5Z_set_local_szip, /* The "set local" callback */ + H5Z_filter_szip, /* The actual filter function */ }}; - - /*------------------------------------------------------------------------- * Function: H5Z_can_apply_szip * @@ -75,39 +72,38 @@ H5Z_class2_t H5Z_SZIP[1] = {{ static htri_t H5Z_can_apply_szip(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - const H5T_t *type; /* Datatype */ - unsigned dtype_size; /* Datatype's size (in bits) */ - H5T_order_t dtype_order; /* Datatype's endianness order */ - htri_t ret_value = TRUE; /* Return value */ + const H5T_t *type; /* Datatype */ + unsigned dtype_size; /* Datatype's size (in bits) */ + H5T_order_t dtype_order; /* Datatype's endianness order */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's size, for checking the "bits-per-pixel" */ - if((dtype_size = (8 * H5T_get_size(type))) == 0) + if ((dtype_size = (8 * H5T_get_size(type))) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Range check datatype's size */ - if(dtype_size > 32 && dtype_size != 64) + if (dtype_size > 32 && dtype_size != 64) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size") /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order") /* Range check datatype's endianness order */ /* (Note: this may not handle non-atomic datatypes well) */ - if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) + if (dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply_szip() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_local_szip * @@ -132,52 +128,52 @@ done: static herr_t H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - H5P_genplist_t *dcpl_plist; /* Property list pointer */ - const H5T_t *type; /* Datatype */ - const H5S_t *ds; /* Dataspace */ - unsigned flags; /* Filter flags */ - size_t cd_nelmts = H5Z_SZIP_USER_NPARMS; /* Number of filter parameters */ - unsigned cd_values[H5Z_SZIP_TOTAL_NPARMS]; /* Filter parameters */ - hsize_t dims[H5O_LAYOUT_NDIMS]; /* Dataspace (i.e. chunk) dimensions */ - int ndims; /* Number of (chunk) dimensions */ - H5T_order_t dtype_order; /* Datatype's endianness order */ - size_t dtype_size; /* Datatype's size (in bits) */ - size_t dtype_precision; /* Datatype's precision (in bits) */ - size_t dtype_offset; /* Datatype's offset (in bits) */ - hsize_t scanline; /* Size of dataspace's fastest changing dimension */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dcpl_plist; /* Property list pointer */ + const H5T_t * type; /* Datatype */ + const H5S_t * ds; /* Dataspace */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = H5Z_SZIP_USER_NPARMS; /* Number of filter parameters */ + unsigned cd_values[H5Z_SZIP_TOTAL_NPARMS]; /* Filter parameters */ + hsize_t dims[H5O_LAYOUT_NDIMS]; /* Dataspace (i.e. chunk) dimensions */ + int ndims; /* Number of (chunk) dimensions */ + H5T_order_t dtype_order; /* Datatype's endianness order */ + size_t dtype_size; /* Datatype's size (in bits) */ + size_t dtype_precision; /* Datatype's precision (in bits) */ + size_t dtype_offset; /* Datatype's offset (in bits) */ + hsize_t scanline; /* Size of dataspace's fastest changing dimension */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the plist structure */ - if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get the filter's current parameters */ - if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) + if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") /* Get datatype's size, for checking the "bits-per-pixel" */ - if((dtype_size = (8 * H5T_get_size(type))) == 0) + if ((dtype_size = (8 * H5T_get_size(type))) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size"); /* Get datatype's precision, in case is less than full bits */ - if((dtype_precision = H5T_get_precision(type)) == 0) + if ((dtype_precision = H5T_get_precision(type)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision"); - if(dtype_precision < dtype_size) { + if (dtype_precision < dtype_size) { dtype_offset = H5T_get_offset(type); - if(dtype_offset != 0) + if (dtype_offset != 0) dtype_precision = dtype_size; } /* end if */ - if(dtype_precision > 24) { - if(dtype_precision <= 32) + if (dtype_precision > 24) { + if (dtype_precision <= 32) dtype_precision = 32; - else if(dtype_precision <= 64) + else if (dtype_precision <= 64) dtype_precision = 64; } /* end if */ @@ -185,11 +181,11 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) cd_values[H5Z_SZIP_PARM_BPP] = dtype_precision; /* Get dataspace */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Get dimensions for dataspace */ - if((ndims = H5S_get_simple_extent_dims(ds, dims, NULL)) < 0) + if ((ndims = H5S_get_simple_extent_dims(ds, dims, NULL)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions") /* Set "local" parameter for this dataset's "pixels-per-scanline" */ @@ -202,19 +198,20 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) SZ_MAX_BLOCKS_PER_SCANLINE blocks per scanline */ /* Check the pixels per block against the 'scanline' size */ - if(scanline < cd_values[H5Z_SZIP_PARM_PPB]) { - hssize_t npoints; /* Number of points in the dataspace */ + if (scanline < cd_values[H5Z_SZIP_PARM_PPB]) { + hssize_t npoints; /* Number of points in the dataspace */ /* Get number of elements for the dataspace; use total number of elements in the chunk to define the new 'scanline' size */ - if((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) + if ((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get number of points in the dataspace") - if(npoints < cd_values[H5Z_SZIP_PARM_PPB]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels per block greater than total number of elements in the chunk") + if (npoints < cd_values[H5Z_SZIP_PARM_PPB]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "pixels per block greater than total number of elements in the chunk") scanline = MIN((cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE), npoints); } else { - if(scanline <= SZ_MAX_PIXELS_PER_SCANLINE) + if (scanline <= SZ_MAX_PIXELS_PER_SCANLINE) scanline = MIN((cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE), scanline); else scanline = cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE; @@ -224,18 +221,18 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) H5_CHECKED_ASSIGN(cd_values[H5Z_SZIP_PARM_PPS], unsigned, scanline, hsize_t); /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") /* Set the correct endianness flag for szip */ /* (Note: this may not handle non-atomic datatypes well) */ - cd_values[H5Z_SZIP_PARM_MASK] &= ~(SZ_LSB_OPTION_MASK|SZ_MSB_OPTION_MASK); - switch(dtype_order) { - case H5T_ORDER_LE: /* Little-endian byte order */ + cd_values[H5Z_SZIP_PARM_MASK] &= ~(SZ_LSB_OPTION_MASK | SZ_MSB_OPTION_MASK); + switch (dtype_order) { + case H5T_ORDER_LE: /* Little-endian byte order */ cd_values[H5Z_SZIP_PARM_MASK] |= SZ_LSB_OPTION_MASK; break; - case H5T_ORDER_BE: /* Big-endian byte order */ + case H5T_ORDER_BE: /* Big-endian byte order */ cd_values[H5Z_SZIP_PARM_MASK] |= SZ_MSB_OPTION_MASK; break; @@ -248,14 +245,13 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) } /* end switch */ /* Modify the filter's parameters for this dataset */ - if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values) < 0) + if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local_szip() */ - /*------------------------------------------------------------------------- * Function: H5Z_filter_szip * @@ -271,29 +267,29 @@ done: *------------------------------------------------------------------------- */ static size_t -H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z_filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, + void **buf) { - size_t ret_value = 0; /* Return value */ - size_t size_out = 0; /* Size of output buffer */ - unsigned char *outbuf = NULL; /* Pointer to new output buffer */ - unsigned char *newbuf = NULL; /* Pointer to input buffer */ - SZ_com_t sz_param; /* szip parameter block */ + size_t ret_value = 0; /* Return value */ + size_t size_out = 0; /* Size of output buffer */ + unsigned char *outbuf = NULL; /* Pointer to new output buffer */ + unsigned char *newbuf = NULL; /* Pointer to input buffer */ + SZ_com_t sz_param; /* szip parameter block */ FUNC_ENTER_NOAPI(0) /* Sanity check to make certain that we haven't drifted out of date with * the mask options from the szlib.h header */ - HDassert(H5_SZIP_ALLOW_K13_OPTION_MASK==SZ_ALLOW_K13_OPTION_MASK); - HDassert(H5_SZIP_CHIP_OPTION_MASK==SZ_CHIP_OPTION_MASK); - HDassert(H5_SZIP_EC_OPTION_MASK==SZ_EC_OPTION_MASK); - HDassert(H5_SZIP_LSB_OPTION_MASK==SZ_LSB_OPTION_MASK); - HDassert(H5_SZIP_MSB_OPTION_MASK==SZ_MSB_OPTION_MASK); - HDassert(H5_SZIP_NN_OPTION_MASK==SZ_NN_OPTION_MASK); - HDassert(H5_SZIP_RAW_OPTION_MASK==SZ_RAW_OPTION_MASK); + HDassert(H5_SZIP_ALLOW_K13_OPTION_MASK == SZ_ALLOW_K13_OPTION_MASK); + HDassert(H5_SZIP_CHIP_OPTION_MASK == SZ_CHIP_OPTION_MASK); + HDassert(H5_SZIP_EC_OPTION_MASK == SZ_EC_OPTION_MASK); + HDassert(H5_SZIP_LSB_OPTION_MASK == SZ_LSB_OPTION_MASK); + HDassert(H5_SZIP_MSB_OPTION_MASK == SZ_MSB_OPTION_MASK); + HDassert(H5_SZIP_NN_OPTION_MASK == SZ_NN_OPTION_MASK); + HDassert(H5_SZIP_RAW_OPTION_MASK == SZ_RAW_OPTION_MASK); /* Check arguments */ - if (cd_nelmts!=4) + if (cd_nelmts != 4) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid number of filter parameters") /* Copy the filter parameters into the szip parameter block */ @@ -304,66 +300,65 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Input; uncompress */ if (flags & H5Z_FLAG_REVERSE) { - uint32_t stored_nalloc; /* Number of bytes the compressed block will expand into */ - size_t nalloc; /* Number of bytes the compressed block will expand into */ + uint32_t stored_nalloc; /* Number of bytes the compressed block will expand into */ + size_t nalloc; /* Number of bytes the compressed block will expand into */ /* Get the size of the uncompressed buffer */ newbuf = (unsigned char *)(*buf); - UINT32DECODE(newbuf,stored_nalloc); + UINT32DECODE(newbuf, stored_nalloc); H5_CHECKED_ASSIGN(nalloc, size_t, stored_nalloc, uint32_t); /* Allocate space for the uncompressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(nalloc))) + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for szip decompression") /* Decompress the buffer */ - size_out=nalloc; - if(SZ_BufftoBuffDecompress(outbuf, &size_out, newbuf, nbytes-4, &sz_param) != SZ_OK) + size_out = nalloc; + if (SZ_BufftoBuffDecompress(outbuf, &size_out, newbuf, nbytes - 4, &sz_param) != SZ_OK) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "szip_filter: decompression failed") - HDassert(size_out==nalloc); + HDassert(size_out == nalloc); /* Free the input buffer */ H5MM_xfree(*buf); /* Set return values */ - *buf = outbuf; - outbuf = NULL; + *buf = outbuf; + outbuf = NULL; *buf_size = nalloc; ret_value = size_out; } /* Output; compress */ else { - unsigned char *dst = NULL; /* Temporary pointer to new output buffer */ + unsigned char *dst = NULL; /* Temporary pointer to new output buffer */ /* Allocate space for the compressed buffer & header (assume data won't get bigger) */ - if(NULL == (dst=outbuf = (unsigned char *)H5MM_malloc(nbytes+4))) + if (NULL == (dst = outbuf = (unsigned char *)H5MM_malloc(nbytes + 4))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate szip destination buffer") /* Encode the uncompressed length */ - H5_CHECK_OVERFLOW(nbytes,size_t,uint32_t); - UINT32ENCODE(dst,nbytes); + H5_CHECK_OVERFLOW(nbytes, size_t, uint32_t); + UINT32ENCODE(dst, nbytes); /* Compress the buffer */ size_out = nbytes; - if(SZ_OK!= SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param)) + if (SZ_OK != SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param)) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") - HDassert(size_out<=nbytes); + HDassert(size_out <= nbytes); /* Free the input buffer */ H5MM_xfree(*buf); /* Set return values */ - *buf = outbuf; - outbuf = NULL; - *buf_size = nbytes+4; - ret_value = size_out+4; + *buf = outbuf; + outbuf = NULL; + *buf_size = nbytes + 4; + ret_value = size_out + 4; } done: - if(outbuf) + if (outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_FILTER_SZIP */ - diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 1c8d415..c0fae6e 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -11,22 +11,20 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* H5VM_array_fill */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* H5VM_array_fill */ +#include "H5Zpkg.h" /* Data filters */ /* Token types */ typedef enum { H5Z_XFORM_ERROR, H5Z_XFORM_INTEGER, /* this represents an integer type in the data transform expression */ - H5Z_XFORM_FLOAT, /* this represents a floating point type in the data transform expression */ + H5Z_XFORM_FLOAT, /* this represents a floating point type in the data transform expression */ H5Z_XFORM_SYMBOL, H5Z_XFORM_PLUS, H5Z_XFORM_MINUS, @@ -37,31 +35,29 @@ typedef enum { H5Z_XFORM_END } H5Z_token_type; - typedef struct { - unsigned int num_ptrs; - void** ptr_dat_val; + unsigned int num_ptrs; + void ** ptr_dat_val; } H5Z_datval_ptrs; - /* Used to represent values in transform expression */ typedef union { - void *dat_val; - long int_val; - double float_val; + void * dat_val; + long int_val; + double float_val; } H5Z_num_val; typedef struct H5Z_node { - struct H5Z_node *lchild; - struct H5Z_node *rchild; - H5Z_token_type type; - H5Z_num_val value; + struct H5Z_node *lchild; + struct H5Z_node *rchild; + H5Z_token_type type; + H5Z_num_val value; } H5Z_node; struct H5Z_data_xform_t { - char* xform_exp; - H5Z_node* parse_root; - H5Z_datval_ptrs* dat_val_pointers; + char * xform_exp; + H5Z_node * parse_root; + H5Z_datval_ptrs *dat_val_pointers; }; typedef struct result { @@ -69,306 +65,310 @@ typedef struct result { H5Z_num_val value; } H5Z_result; - /* The token */ typedef struct { - const char *tok_expr; /* Holds the original expression */ + const char *tok_expr; /* Holds the original expression */ /* Current token values */ - H5Z_token_type tok_type; /* The type of the current token */ - const char *tok_begin; /* The beginning of the current token */ - const char *tok_end; /* The end of the current token */ + H5Z_token_type tok_type; /* The type of the current token */ + const char * tok_begin; /* The beginning of the current token */ + const char * tok_end; /* The end of the current token */ /* Previous token values */ - H5Z_token_type tok_last_type; /* The type of the last token */ - const char *tok_last_begin; /* The beginning of the last token */ - const char *tok_last_end; /* The end of the last token */ + H5Z_token_type tok_last_type; /* The type of the last token */ + const char * tok_last_begin; /* The beginning of the last token */ + const char * tok_last_end; /* The end of the last token */ } H5Z_token; /* Local function prototypes */ static H5Z_token *H5Z_get_token(H5Z_token *current); -static H5Z_node *H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers); -static H5Z_node *H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers); -static H5Z_node *H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers); -static H5Z_node *H5Z_new_node(H5Z_token_type type); -static void H5Z_do_op(H5Z_node* tree); -static hbool_t H5Z_op_is_numbs(H5Z_node* _tree); -static hbool_t H5Z_op_is_numbs2(H5Z_node* _tree); -static hid_t H5Z_xform_find_type(const H5T_t* type); -static herr_t H5Z_xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_type, H5Z_result* res); -static void H5Z_xform_destroy_parse_tree(H5Z_node *tree); -static void* H5Z_xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers); -static void* H5Z_xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datval_ptrs* new_dat_val_pointers); -static void H5Z_xform_reduce_tree(H5Z_node* tree); +static H5Z_node * H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers); +static H5Z_node * H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers); +static H5Z_node * H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers); +static H5Z_node * H5Z_new_node(H5Z_token_type type); +static void H5Z_do_op(H5Z_node *tree); +static hbool_t H5Z_op_is_numbs(H5Z_node *_tree); +static hbool_t H5Z_op_is_numbs2(H5Z_node *_tree); +static hid_t H5Z_xform_find_type(const H5T_t *type); +static herr_t H5Z_xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_type, + H5Z_result *res); +static void H5Z_xform_destroy_parse_tree(H5Z_node *tree); +static void * H5Z_xform_parse(const char *expression, H5Z_datval_ptrs *dat_val_pointers); +static void * H5Z_xform_copy_tree(H5Z_node *tree, H5Z_datval_ptrs *dat_val_pointers, + H5Z_datval_ptrs *new_dat_val_pointers); +static void H5Z_xform_reduce_tree(H5Z_node *tree); #ifdef H5Z_XFORM_DEBUG static void H5Z_XFORM_DEBUG(H5Z_node *tree); static void H5Z_print(H5Z_node *tree, FILE *stream); -#endif /* H5Z_XFORM_DEBUG */ +#endif /* H5Z_XFORM_DEBUG */ /* PGCC (11.8-0) has trouble with the command *p++ = *p OP tree_val. It increments P first before * doing the operation. So I break down the command into two lines: * *p = *p OP tree_val; p++; * Actually, the behavior of *p++ = *p OP tree_val is undefined. (SLU - 2012/3/19) */ -#define H5Z_XFORM_DO_OP1(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - size_t u; \ - \ - if(((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type != H5Z_XFORM_SYMBOL)) \ - { \ - TYPE* p; \ - double tree_val; \ - \ - tree_val = ((RESR).type==H5Z_XFORM_INTEGER ? (double)(RESR).value.int_val : (RESR).value.float_val); \ - p = (TYPE*)(RESL).value.dat_val; \ - \ - for(u = 0; u < (SIZE); u++) { \ - *p = (TYPE)((double)*p OP tree_val); \ - p++; \ - } \ - } \ - else if(((RESR).type == H5Z_XFORM_SYMBOL) && ((RESL).type != H5Z_XFORM_SYMBOL)) \ - { \ - TYPE* p; \ - double tree_val; \ - \ - /* The case that the left operand is nothing, like -x or +x */ \ - if((RESL).type == H5Z_XFORM_ERROR) \ - tree_val = 0; \ - else \ - tree_val = ((RESL).type==H5Z_XFORM_INTEGER ? (double)(RESL).value.int_val : (RESL).value.float_val); \ - \ - p = (TYPE*)(RESR).value.dat_val; \ - for(u = 0; u < (SIZE); u++) { \ - *p = (TYPE)(tree_val OP (double)*p); \ - p++; \ - } \ - } \ - else if( ((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type == H5Z_XFORM_SYMBOL)) \ - { \ - TYPE* pl = (TYPE*)(RESL).value.dat_val; \ - TYPE* pr = (TYPE*)(RESR).value.dat_val; \ - \ - for(u = 0; u < (SIZE); u++) { \ - *pl = (TYPE)(*pl OP *pr); \ - pl++; pr++; \ - } \ - } \ - else \ - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unexpected type conversion operation") \ -} +#define H5Z_XFORM_DO_OP1(RESL, RESR, TYPE, OP, SIZE) \ + { \ + size_t u; \ + \ + if (((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type != H5Z_XFORM_SYMBOL)) { \ + TYPE * p; \ + double tree_val; \ + \ + tree_val = \ + ((RESR).type == H5Z_XFORM_INTEGER ? (double)(RESR).value.int_val : (RESR).value.float_val); \ + p = (TYPE *)(RESL).value.dat_val; \ + \ + for (u = 0; u < (SIZE); u++) { \ + *p = (TYPE)((double)*p OP tree_val); \ + p++; \ + } \ + } \ + else if (((RESR).type == H5Z_XFORM_SYMBOL) && ((RESL).type != H5Z_XFORM_SYMBOL)) { \ + TYPE * p; \ + double tree_val; \ + \ + /* The case that the left operand is nothing, like -x or +x */ \ + if ((RESL).type == H5Z_XFORM_ERROR) \ + tree_val = 0; \ + else \ + tree_val = ((RESL).type == H5Z_XFORM_INTEGER ? (double)(RESL).value.int_val \ + : (RESL).value.float_val); \ + \ + p = (TYPE *)(RESR).value.dat_val; \ + for (u = 0; u < (SIZE); u++) { \ + *p = (TYPE)(tree_val OP(double) * p); \ + p++; \ + } \ + } \ + else if (((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type == H5Z_XFORM_SYMBOL)) { \ + TYPE *pl = (TYPE *)(RESL).value.dat_val; \ + TYPE *pr = (TYPE *)(RESR).value.dat_val; \ + \ + for (u = 0; u < (SIZE); u++) { \ + *pl = (TYPE)(*pl OP * pr); \ + pl++; \ + pr++; \ + } \ + } \ + else \ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unexpected type conversion operation") \ + } #if H5_SIZEOF_LONG_DOUBLE != 0 #if CHAR_MIN >= 0 -#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - if((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LDOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ -} +#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ + { \ + if ((TYPE) == H5T_NATIVE_CHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SCHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_USHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_INT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UINT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_FLOAT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_DOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LDOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ + } #else /* CHAR_MIN >= 0 */ -#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - if((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LDOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ -} +#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ + { \ + if ((TYPE) == H5T_NATIVE_CHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UCHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_USHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_INT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UINT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_FLOAT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_DOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LDOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ + } #endif /* CHAR_MIN >= 0 */ #else #if CHAR_MIN >= 0 -#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - if((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ -} +#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ + { \ + if ((TYPE) == H5T_NATIVE_CHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SCHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_USHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_INT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UINT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_FLOAT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_DOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ + } #else /* CHAR_MIN >= 0 */ -#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - if((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ -} +#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ + { \ + if ((TYPE) == H5T_NATIVE_CHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UCHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_USHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_INT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UINT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_FLOAT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_DOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ + } #endif /* CHAR_MIN >= 0 */ #endif /*H5_SIZEOF_LONG_DOUBLE */ -#define H5Z_XFORM_DO_OP3(OP) \ -{ \ - if((tree->lchild->type == H5Z_XFORM_INTEGER) && (tree->rchild->type==H5Z_XFORM_INTEGER)) \ - { \ - tree->type = H5Z_XFORM_INTEGER; \ - tree->value.int_val = tree->lchild->value.int_val OP tree->rchild->value.int_val; \ - H5MM_xfree(tree->lchild); \ - H5MM_xfree(tree->rchild); \ - tree->lchild = NULL; \ - tree->rchild = NULL; \ - } \ - else if( ( (tree->lchild->type == H5Z_XFORM_FLOAT) || (tree->lchild->type == H5Z_XFORM_INTEGER)) && \ - ( (tree->rchild->type == H5Z_XFORM_FLOAT) || (tree->rchild->type == H5Z_XFORM_INTEGER))) \ - { \ - tree->type = H5Z_XFORM_FLOAT; \ - tree->value.float_val = ((tree->lchild->type == H5Z_XFORM_FLOAT) ? tree->lchild->value.float_val : (double)tree->lchild->value.int_val) OP \ - ((tree->rchild->type == H5Z_XFORM_FLOAT) ? tree->rchild->value.float_val : (double)tree->rchild->value.int_val); \ - H5MM_xfree(tree->lchild); \ - H5MM_xfree(tree->rchild); \ - tree->lchild = NULL; \ - tree->rchild = NULL; \ - } \ -} +#define H5Z_XFORM_DO_OP3(OP) \ + { \ + if ((tree->lchild->type == H5Z_XFORM_INTEGER) && (tree->rchild->type == H5Z_XFORM_INTEGER)) { \ + tree->type = H5Z_XFORM_INTEGER; \ + tree->value.int_val = tree->lchild->value.int_val OP tree->rchild->value.int_val; \ + H5MM_xfree(tree->lchild); \ + H5MM_xfree(tree->rchild); \ + tree->lchild = NULL; \ + tree->rchild = NULL; \ + } \ + else if (((tree->lchild->type == H5Z_XFORM_FLOAT) || (tree->lchild->type == H5Z_XFORM_INTEGER)) && \ + ((tree->rchild->type == H5Z_XFORM_FLOAT) || (tree->rchild->type == H5Z_XFORM_INTEGER))) { \ + tree->type = H5Z_XFORM_FLOAT; \ + tree->value.float_val = \ + ((tree->lchild->type == H5Z_XFORM_FLOAT) ? tree->lchild->value.float_val \ + : (double)tree->lchild->value.int_val) \ + OP((tree->rchild->type == H5Z_XFORM_FLOAT) ? tree->rchild->value.float_val \ + : (double)tree->rchild->value.int_val); \ + H5MM_xfree(tree->lchild); \ + H5MM_xfree(tree->rchild); \ + tree->lchild = NULL; \ + tree->rchild = NULL; \ + } \ + } -#define H5Z_XFORM_DO_OP4(TYPE) \ -{ \ - if ((ret_value = (H5Z_node*) H5MM_malloc(sizeof(H5Z_node))) == NULL) \ - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") \ - else \ - { \ - ret_value->type = (TYPE); \ - if(tree->lchild) \ - ret_value->lchild = (H5Z_node*) H5Z_xform_copy_tree(tree->lchild, dat_val_pointers, new_dat_val_pointers); \ - else \ - ret_value->lchild = NULL; \ - if(tree->rchild) \ - ret_value->rchild = (H5Z_node*) H5Z_xform_copy_tree(tree->rchild, dat_val_pointers, new_dat_val_pointers); \ - else \ - ret_value->rchild = NULL; \ - } \ -} +#define H5Z_XFORM_DO_OP4(TYPE) \ + { \ + if ((ret_value = (H5Z_node *)H5MM_malloc(sizeof(H5Z_node))) == NULL) \ + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") \ + else { \ + ret_value->type = (TYPE); \ + if (tree->lchild) \ + ret_value->lchild = \ + (H5Z_node *)H5Z_xform_copy_tree(tree->lchild, dat_val_pointers, new_dat_val_pointers); \ + else \ + ret_value->lchild = NULL; \ + if (tree->rchild) \ + ret_value->rchild = \ + (H5Z_node *)H5Z_xform_copy_tree(tree->rchild, dat_val_pointers, new_dat_val_pointers); \ + else \ + ret_value->rchild = NULL; \ + } \ + } -#define H5Z_XFORM_DO_OP5(TYPE, SIZE) \ -{ \ - TYPE val = ((tree->type == H5Z_XFORM_INTEGER) ? (TYPE)tree->value.int_val : (TYPE)tree->value.float_val); \ - H5VM_array_fill(array, &val, sizeof(TYPE), (SIZE)); \ -} +#define H5Z_XFORM_DO_OP5(TYPE, SIZE) \ + { \ + TYPE val = \ + ((tree->type == H5Z_XFORM_INTEGER) ? (TYPE)tree->value.int_val : (TYPE)tree->value.float_val); \ + H5VM_array_fill(array, &val, sizeof(TYPE), (SIZE)); \ + } -/* The difference of this macro from H5Z_XFORM_DO_OP3 is that it handles the operations when the left operand is empty, like -x or +x. - * The reason that it's separated from H5Z_XFORM_DO_OP3 is because compilers don't accept operations like *x or /x. So in H5Z_do_op, - * these two macros are called in different ways. (SLU 2012/3/20) +/* The difference of this macro from H5Z_XFORM_DO_OP3 is that it handles the operations when the left operand + * is empty, like -x or +x. The reason that it's separated from H5Z_XFORM_DO_OP3 is because compilers don't + * accept operations like *x or /x. So in H5Z_do_op, these two macros are called in different ways. (SLU + * 2012/3/20) */ -#define H5Z_XFORM_DO_OP6(OP) \ -{ \ - if(!tree->lchild && (tree->rchild->type==H5Z_XFORM_INTEGER)) \ - { \ - tree->type = H5Z_XFORM_INTEGER; \ - tree->value.int_val = OP tree->rchild->value.int_val; \ - H5MM_xfree(tree->rchild); \ - tree->rchild = NULL; \ - } \ - else if(!tree->lchild && (tree->rchild->type==H5Z_XFORM_FLOAT)) \ - { \ - tree->type = H5Z_XFORM_FLOAT; \ - tree->value.float_val = OP tree->rchild->value.float_val; \ - H5MM_xfree(tree->rchild); \ - tree->rchild = NULL; \ - } \ - else if((tree->lchild->type == H5Z_XFORM_INTEGER) && (tree->rchild->type==H5Z_XFORM_INTEGER)) \ - { \ - tree->type = H5Z_XFORM_INTEGER; \ - tree->value.int_val = tree->lchild->value.int_val OP tree->rchild->value.int_val; \ - H5MM_xfree(tree->lchild); \ - H5MM_xfree(tree->rchild); \ - tree->lchild = NULL; \ - tree->rchild = NULL; \ - } \ - else if( ( (tree->lchild->type == H5Z_XFORM_FLOAT) || (tree->lchild->type == H5Z_XFORM_INTEGER)) && \ - ( (tree->rchild->type == H5Z_XFORM_FLOAT) || (tree->rchild->type == H5Z_XFORM_INTEGER))) \ - { \ - tree->type = H5Z_XFORM_FLOAT; \ - tree->value.float_val = ((tree->lchild->type == H5Z_XFORM_FLOAT) ? tree->lchild->value.float_val : (double)tree->lchild->value.int_val) OP \ - ((tree->rchild->type == H5Z_XFORM_FLOAT) ? tree->rchild->value.float_val : (double)tree->rchild->value.int_val); \ - H5MM_xfree(tree->lchild); \ - H5MM_xfree(tree->rchild); \ - tree->lchild = NULL; \ - tree->rchild = NULL; \ - } \ -} +#define H5Z_XFORM_DO_OP6(OP) \ + { \ + if (!tree->lchild && (tree->rchild->type == H5Z_XFORM_INTEGER)) { \ + tree->type = H5Z_XFORM_INTEGER; \ + tree->value.int_val = OP tree->rchild->value.int_val; \ + H5MM_xfree(tree->rchild); \ + tree->rchild = NULL; \ + } \ + else if (!tree->lchild && (tree->rchild->type == H5Z_XFORM_FLOAT)) { \ + tree->type = H5Z_XFORM_FLOAT; \ + tree->value.float_val = OP tree->rchild->value.float_val; \ + H5MM_xfree(tree->rchild); \ + tree->rchild = NULL; \ + } \ + else if ((tree->lchild->type == H5Z_XFORM_INTEGER) && (tree->rchild->type == H5Z_XFORM_INTEGER)) { \ + tree->type = H5Z_XFORM_INTEGER; \ + tree->value.int_val = tree->lchild->value.int_val OP tree->rchild->value.int_val; \ + H5MM_xfree(tree->lchild); \ + H5MM_xfree(tree->rchild); \ + tree->lchild = NULL; \ + tree->rchild = NULL; \ + } \ + else if (((tree->lchild->type == H5Z_XFORM_FLOAT) || (tree->lchild->type == H5Z_XFORM_INTEGER)) && \ + ((tree->rchild->type == H5Z_XFORM_FLOAT) || (tree->rchild->type == H5Z_XFORM_INTEGER))) { \ + tree->type = H5Z_XFORM_FLOAT; \ + tree->value.float_val = \ + ((tree->lchild->type == H5Z_XFORM_FLOAT) ? tree->lchild->value.float_val \ + : (double)tree->lchild->value.int_val) \ + OP((tree->rchild->type == H5Z_XFORM_FLOAT) ? tree->rchild->value.float_val \ + : (double)tree->rchild->value.int_val); \ + H5MM_xfree(tree->lchild); \ + H5MM_xfree(tree->rchild); \ + tree->lchild = NULL; \ + tree->rchild = NULL; \ + } \ + } /* * Programmer: Bill Wendling @@ -391,7 +391,6 @@ static void H5Z_print(H5Z_node *tree, FILE *stream); * // FLOAT is a C double */ - /*------------------------------------------------------------------------- * Function: H5Z_unget_token * Purpose: Rollback the H5Z_token to the previous H5Z_token retrieved. There @@ -400,7 +399,7 @@ static void H5Z_print(H5Z_node *tree, FILE *stream); * Return: Always succeeds. * Programmer: Bill Wendling * 26. August 2003 -* + * *------------------------------------------------------------------------- */ static void @@ -411,14 +410,13 @@ H5Z_unget_token(H5Z_token *current) /* check args */ HDassert(current); - current->tok_type = current->tok_last_type; + current->tok_type = current->tok_last_type; current->tok_begin = current->tok_last_begin; - current->tok_end = current->tok_last_end; + current->tok_end = current->tok_last_end; FUNC_LEAVE_NOAPI_VOID } - /*------------------------------------------------------------------------- * Function: H5Z_get_token * @@ -448,17 +446,17 @@ H5Z_get_token(H5Z_token *current) HDassert(current); /* Save the last position for possible ungets */ - current->tok_last_type = current->tok_type; + current->tok_last_type = current->tok_type; current->tok_last_begin = current->tok_begin; - current->tok_last_end = current->tok_end; + current->tok_last_end = current->tok_end; current->tok_begin = current->tok_end; while (current->tok_begin[0] != '\0') { if (HDisspace(current->tok_begin[0])) { /* ignore whitespace */ - } else if (HDisdigit(current->tok_begin[0]) || - current->tok_begin[0] == '.') { + } + else if (HDisdigit(current->tok_begin[0]) || current->tok_begin[0] == '.') { current->tok_end = current->tok_begin; /* @@ -481,9 +479,7 @@ H5Z_get_token(H5Z_token *current) * '.' digit-sequence * exponent := [Ee] [-+]? digit-sequence */ - if (current->tok_end[0] == '.' || - current->tok_end[0] == 'e' || - current->tok_end[0] == 'E') { + if (current->tok_end[0] == '.' || current->tok_end[0] == 'e' || current->tok_end[0] == 'E') { current->tok_type = H5Z_XFORM_FLOAT; if (current->tok_end[0] == '.') @@ -491,17 +487,16 @@ H5Z_get_token(H5Z_token *current) ++current->tok_end; } while (HDisdigit(current->tok_end[0])); - if (current->tok_end[0] == 'e' || - current->tok_end[0] == 'E') { + if (current->tok_end[0] == 'e' || current->tok_end[0] == 'E') { ++current->tok_end; - if (current->tok_end[0] == '-' || - current->tok_end[0] == '+') + if (current->tok_end[0] == '-' || current->tok_end[0] == '+') ++current->tok_end; if (!HDisdigit(current->tok_end[0])) { current->tok_type = H5Z_XFORM_ERROR; - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, "Invalidly formatted floating point number") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, + "Invalidly formatted floating point number") } while (HDisdigit(current->tok_end[0])) @@ -516,27 +511,42 @@ H5Z_get_token(H5Z_token *current) } break; - } else if (HDisalpha(current->tok_begin[0])) { + } + else if (HDisalpha(current->tok_begin[0])) { /* is symbol */ current->tok_type = H5Z_XFORM_SYMBOL; - current->tok_end = current->tok_begin; + current->tok_end = current->tok_begin; while (HDisalnum(current->tok_end[0])) ++current->tok_end; break; - } else { + } + else { /* should be +, -, *, /, (, or ) */ switch (current->tok_begin[0]) { - case '+': current->tok_type = H5Z_XFORM_PLUS; break; - case '-': current->tok_type = H5Z_XFORM_MINUS; break; - case '*': current->tok_type = H5Z_XFORM_MULT; break; - case '/': current->tok_type = H5Z_XFORM_DIVIDE; break; - case '(': current->tok_type = H5Z_XFORM_LPAREN; break; - case ')': current->tok_type = H5Z_XFORM_RPAREN; break; + case '+': + current->tok_type = H5Z_XFORM_PLUS; + break; + case '-': + current->tok_type = H5Z_XFORM_MINUS; + break; + case '*': + current->tok_type = H5Z_XFORM_MULT; + break; + case '/': + current->tok_type = H5Z_XFORM_DIVIDE; + break; + case '(': + current->tok_type = H5Z_XFORM_LPAREN; + break; + case ')': + current->tok_type = H5Z_XFORM_RPAREN; + break; default: current->tok_type = H5Z_XFORM_ERROR; - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, "Unknown H5Z_token in data transform expression ") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, + "Unknown H5Z_token in data transform expression ") } current->tok_end = current->tok_begin + 1; @@ -556,7 +566,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_xform_destroy_parse_tree * Purpose: Recursively destroys the expression tree. @@ -571,18 +580,16 @@ H5Z_xform_destroy_parse_tree(H5Z_node *tree) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if (tree) - { - H5Z_xform_destroy_parse_tree(tree->lchild); - H5Z_xform_destroy_parse_tree(tree->rchild); - H5MM_xfree(tree); - tree = NULL; + if (tree) { + H5Z_xform_destroy_parse_tree(tree->lchild); + H5Z_xform_destroy_parse_tree(tree->rchild); + H5MM_xfree(tree); + tree = NULL; } FUNC_LEAVE_NOAPI_VOID } - /*------------------------------------------------------------------------- * Function: H5Z_parse * @@ -597,28 +604,27 @@ H5Z_xform_destroy_parse_tree(H5Z_node *tree) *------------------------------------------------------------------------- */ static void * -H5Z_xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers) +H5Z_xform_parse(const char *expression, H5Z_datval_ptrs *dat_val_pointers) { H5Z_token tok; - void *ret_value = NULL; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - if(!expression) + if (!expression) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "No expression provided?") /* Set up the initial H5Z_token for parsing */ tok.tok_expr = tok.tok_begin = tok.tok_end = expression; - ret_value = (void*)H5Z_parse_expression(&tok, dat_val_pointers); + ret_value = (void *)H5Z_parse_expression(&tok, dat_val_pointers); - H5Z_xform_reduce_tree((H5Z_node*)ret_value); + H5Z_xform_reduce_tree((H5Z_node *)ret_value); done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_parse_expression * Purpose: Beginning of the recursive descent parser to parse the @@ -630,14 +636,14 @@ done: * NULLure: NULL * Programmer: Bill Wendling * 26. August 2003 -* + * *------------------------------------------------------------------------- */ static H5Z_node * -H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) +H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) { H5Z_node *expr; - H5Z_node *ret_value = NULL; /* Return value */ + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -648,7 +654,7 @@ H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) current = H5Z_get_token(current); - switch(current->tok_type) { + switch (current->tok_type) { case H5Z_XFORM_PLUS: new_node = H5Z_new_node(H5Z_XFORM_PLUS); @@ -711,7 +717,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_parse_term * Purpose: Parses a term in our expression language. A term is: @@ -722,14 +727,14 @@ done: * NULLure: NULL * Programmer: Bill Wendling * 26. August 2003 -* + * *------------------------------------------------------------------------- */ static H5Z_node * -H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) +H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) { - H5Z_node *term = NULL; - H5Z_node *ret_value = NULL; /* Return value */ + H5Z_node *term = NULL; + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -770,7 +775,7 @@ H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) new_node->lchild = term; new_node->rchild = H5Z_parse_factor(current, dat_val_pointers); - term = new_node; + term = new_node; if (!new_node->rchild) { H5Z_xform_destroy_parse_tree(new_node); @@ -797,15 +802,15 @@ H5Z_parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) case H5Z_XFORM_ERROR: default: H5Z_xform_destroy_parse_tree(term); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "bad transform type passed to data transform expression") - } /* end switch */ - } /* end for */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "bad transform type passed to data transform expression") + } /* end switch */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_parse_factor * Purpose: Parses a factor in our expression language. A factor is: @@ -824,11 +829,11 @@ done: *------------------------------------------------------------------------- */ static H5Z_node * -H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) +H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) { - H5Z_node *factor=NULL; - H5Z_node *new_node; - H5Z_node *ret_value = NULL; /* Return value */ + H5Z_node *factor = NULL; + H5Z_node *new_node; + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -839,7 +844,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) factor = H5Z_new_node(H5Z_XFORM_INTEGER); if (!factor) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") HDsscanf(current->tok_begin, "%ld", &factor->value.int_val); break; @@ -847,7 +852,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) factor = H5Z_new_node(H5Z_XFORM_FLOAT); if (!factor) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") HDsscanf(current->tok_begin, "%lf", &factor->value.float_val); break; @@ -855,7 +860,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) factor = H5Z_new_node(H5Z_XFORM_SYMBOL); if (!factor) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") factor->value.dat_val = &(dat_val_pointers->ptr_dat_val[dat_val_pointers->num_ptrs]); dat_val_pointers->num_ptrs++; @@ -865,7 +870,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) factor = H5Z_parse_expression(current, dat_val_pointers); if (!factor) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") current = H5Z_get_token(current); @@ -881,80 +886,80 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Syntax error: unexpected ')' ") case H5Z_XFORM_PLUS: - /* unary + */ - new_node = H5Z_parse_factor(current, dat_val_pointers); - - if (new_node) { - if (new_node->type != H5Z_XFORM_INTEGER && new_node->type != H5Z_XFORM_FLOAT && - new_node->type != H5Z_XFORM_SYMBOL) { - H5Z_xform_destroy_parse_tree(new_node); - H5Z_xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") - } + /* unary + */ + new_node = H5Z_parse_factor(current, dat_val_pointers); - factor = new_node; - new_node = H5Z_new_node(H5Z_XFORM_PLUS); + if (new_node) { + if (new_node->type != H5Z_XFORM_INTEGER && new_node->type != H5Z_XFORM_FLOAT && + new_node->type != H5Z_XFORM_SYMBOL) { + H5Z_xform_destroy_parse_tree(new_node); + H5Z_xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") + } - if (!new_node) { - H5Z_xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") - } + factor = new_node; + new_node = H5Z_new_node(H5Z_XFORM_PLUS); - new_node->rchild = factor; - factor = new_node; - } else { + if (!new_node) { H5Z_xform_destroy_parse_tree(factor); HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") } - break; + + new_node->rchild = factor; + factor = new_node; + } + else { + H5Z_xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") + } + break; case H5Z_XFORM_MINUS: - /* unary - */ - new_node = H5Z_parse_factor(current, dat_val_pointers); - - if (new_node) { - if (new_node->type != H5Z_XFORM_INTEGER && new_node->type != H5Z_XFORM_FLOAT && - new_node->type != H5Z_XFORM_SYMBOL) { - H5Z_xform_destroy_parse_tree(new_node); - H5Z_xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") - } + /* unary - */ + new_node = H5Z_parse_factor(current, dat_val_pointers); - factor = new_node; - new_node = H5Z_new_node(H5Z_XFORM_MINUS); + if (new_node) { + if (new_node->type != H5Z_XFORM_INTEGER && new_node->type != H5Z_XFORM_FLOAT && + new_node->type != H5Z_XFORM_SYMBOL) { + H5Z_xform_destroy_parse_tree(new_node); + H5Z_xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") + } - if (!new_node) { - H5Z_xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") - } + factor = new_node; + new_node = H5Z_new_node(H5Z_XFORM_MINUS); - new_node->rchild = factor; - factor = new_node; - } else { + if (!new_node) { H5Z_xform_destroy_parse_tree(factor); HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") } - break; + + new_node->rchild = factor; + factor = new_node; + } + else { + H5Z_xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") + } + break; case H5Z_XFORM_END: - break; + break; case H5Z_XFORM_MULT: case H5Z_XFORM_DIVIDE: case H5Z_XFORM_ERROR: default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Invalid token while parsing data transform expression") - } /* Set return value */ - ret_value=factor; + ret_value = factor; done: FUNC_LEAVE_NOAPI(ret_value); } - /*------------------------------------------------------------------------- * Function: H5Z_new_node * Purpose: Create and initialize a new H5Z_node structure. @@ -968,12 +973,13 @@ done: static H5Z_node * H5Z_new_node(H5Z_token_type type) { - H5Z_node *ret_value = NULL; /* Return value */ + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if(NULL == (ret_value = (H5Z_node *)H5MM_calloc(sizeof(H5Z_node)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to allocate space for nodes in the parse tree") + if (NULL == (ret_value = (H5Z_node *)H5MM_calloc(sizeof(H5Z_node)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "Ran out of memory trying to allocate space for nodes in the parse tree") ret_value->type = type; @@ -981,7 +987,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_xform_eval * Purpose: If the transform is trivial, this function applies it. @@ -994,13 +999,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size, const H5T_t *buf_type) +H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, size_t array_size, const H5T_t *buf_type) { - H5Z_node *tree; - hid_t array_type; + H5Z_node * tree; + hid_t array_type; H5Z_result res; - size_t i; - herr_t ret_value = SUCCEED; /* Return value */ + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1009,92 +1014,94 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size tree = data_xform_prop->parse_root; /* Get the datatype ID for the buffer's type */ - if((array_type = H5Z_xform_find_type(buf_type)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Cannot perform data transform on this type.") + if ((array_type = H5Z_xform_find_type(buf_type)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Cannot perform data transform on this type.") /* After this point, we're assured that the type of the array is handled by the eval code, * so we no longer have to check for valid types */ /* If it's a trivial data transform, perform it */ - if(tree->type == H5Z_XFORM_INTEGER || tree->type == H5Z_XFORM_FLOAT) { - if(array_type == H5T_NATIVE_CHAR) + if (tree->type == H5Z_XFORM_INTEGER || tree->type == H5Z_XFORM_FLOAT) { + if (array_type == H5T_NATIVE_CHAR) H5Z_XFORM_DO_OP5(char, array_size) #if CHAR_MIN >= 0 - else if(array_type == H5T_NATIVE_SCHAR) + else if (array_type == H5T_NATIVE_SCHAR) H5Z_XFORM_DO_OP5(signed char, array_size) -#else /* CHAR_MIN >= 0 */ - else if(array_type == H5T_NATIVE_UCHAR) +#else /* CHAR_MIN >= 0 */ + else if (array_type == H5T_NATIVE_UCHAR) H5Z_XFORM_DO_OP5(unsigned char, array_size) #endif /* CHAR_MIN >= 0 */ - else if(array_type == H5T_NATIVE_SHORT) + else if (array_type == H5T_NATIVE_SHORT) H5Z_XFORM_DO_OP5(short, array_size) - else if(array_type == H5T_NATIVE_USHORT) + else if (array_type == H5T_NATIVE_USHORT) H5Z_XFORM_DO_OP5(unsigned short, array_size) - else if(array_type == H5T_NATIVE_INT) + else if (array_type == H5T_NATIVE_INT) H5Z_XFORM_DO_OP5(int, array_size) - else if(array_type == H5T_NATIVE_UINT) + else if (array_type == H5T_NATIVE_UINT) H5Z_XFORM_DO_OP5(unsigned int, array_size) - else if(array_type == H5T_NATIVE_LONG) + else if (array_type == H5T_NATIVE_LONG) H5Z_XFORM_DO_OP5(long, array_size) - else if(array_type == H5T_NATIVE_ULONG) + else if (array_type == H5T_NATIVE_ULONG) H5Z_XFORM_DO_OP5(unsigned long, array_size) - else if(array_type == H5T_NATIVE_LLONG) + else if (array_type == H5T_NATIVE_LLONG) H5Z_XFORM_DO_OP5(long long, array_size) - else if(array_type == H5T_NATIVE_ULLONG) + else if (array_type == H5T_NATIVE_ULLONG) H5Z_XFORM_DO_OP5(unsigned long long, array_size) - else if(array_type == H5T_NATIVE_FLOAT) + else if (array_type == H5T_NATIVE_FLOAT) H5Z_XFORM_DO_OP5(float, array_size) - else if(array_type == H5T_NATIVE_DOUBLE) + else if (array_type == H5T_NATIVE_DOUBLE) H5Z_XFORM_DO_OP5(double, array_size) -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if(array_type == H5T_NATIVE_LDOUBLE) +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if (array_type == H5T_NATIVE_LDOUBLE) H5Z_XFORM_DO_OP5(long double, array_size) #endif } /* end if */ /* Otherwise, do the full data transform */ else { - /* Optimization for linear transform: */ - if(data_xform_prop->dat_val_pointers->num_ptrs == 1) - data_xform_prop->dat_val_pointers->ptr_dat_val[0] = array; + /* Optimization for linear transform: */ + if (data_xform_prop->dat_val_pointers->num_ptrs == 1) + data_xform_prop->dat_val_pointers->ptr_dat_val[0] = array; - /* If it's a quadratic transform, we have no choice but to store multiple copies of the data */ - else { - for(i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) { - if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void*)H5MM_malloc(array_size * H5T_get_size((H5T_t *)H5I_object(array_type))))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "Ran out of memory trying to allocate space for data in data transform") + /* If it's a quadratic transform, we have no choice but to store multiple copies of the data */ + else { + for (i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) { + if (NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void *)H5MM_malloc( + array_size * H5T_get_size((H5T_t *)H5I_object(array_type))))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "Ran out of memory trying to allocate space for data in data transform") - H5MM_memcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); - } /* end for */ - } /* end else */ + H5MM_memcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, + array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); + } /* end for */ + } /* end else */ - if(H5Z_xform_eval_full(tree, array_size, array_type, &res) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") + if (H5Z_xform_eval_full(tree, array_size, array_type, &res) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") - if(data_xform_prop->dat_val_pointers->num_ptrs > 1) - H5MM_memcpy(array, res.value.dat_val, array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); + if (data_xform_prop->dat_val_pointers->num_ptrs > 1) + H5MM_memcpy(array, res.value.dat_val, array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); /* Free the temporary arrays we used */ - if(data_xform_prop->dat_val_pointers->num_ptrs > 1) - for(i=0; idat_val_pointers->num_ptrs; i++) + if (data_xform_prop->dat_val_pointers->num_ptrs > 1) + for (i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end else */ done: - if(ret_value < 0) { - /* If we ran out of memory above copying the array for temp storage (which we easily can for - * polynomial transforms of high order) we free those arrays which we already allocated */ - if(data_xform_prop->dat_val_pointers->num_ptrs > 1) - for(i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) - if(data_xform_prop->dat_val_pointers->ptr_dat_val[i]) - H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); + if (ret_value < 0) { + /* If we ran out of memory above copying the array for temp storage (which we easily can for + * polynomial transforms of high order) we free those arrays which we already allocated */ + if (data_xform_prop->dat_val_pointers->num_ptrs > 1) + for (i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) + if (data_xform_prop->dat_val_pointers->ptr_dat_val[i]) + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_xform_eval() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_eval_full * Purpose: Does a full evaluation of the parse tree contained in tree @@ -1109,10 +1116,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5Z_xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_type, H5Z_result *res) +H5Z_xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_type, H5Z_result *res) { H5Z_result resl, resr; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1123,47 +1130,47 @@ H5Z_xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_ HDmemset(&resr, 0, sizeof(H5Z_result)); if (tree->type == H5Z_XFORM_INTEGER) { - res->type = H5Z_XFORM_INTEGER; - res->value.int_val = tree->value.int_val; + res->type = H5Z_XFORM_INTEGER; + res->value.int_val = tree->value.int_val; } /* end if */ else if (tree->type == H5Z_XFORM_FLOAT) { - res->type = H5Z_XFORM_FLOAT; - res->value.float_val = tree->value.float_val; + res->type = H5Z_XFORM_FLOAT; + res->value.float_val = tree->value.float_val; } /* end if */ else if (tree->type == H5Z_XFORM_SYMBOL) { - res->type = H5Z_XFORM_SYMBOL; + res->type = H5Z_XFORM_SYMBOL; - /*since dat_val stores the address of the array which is really stored in the dat_val_pointers, - * here we make dat_val store a pointer to the array itself instead of the address of it so that the - * rest of the code below works normally. */ - res->value.dat_val = *((void**)(tree->value.dat_val)); + /*since dat_val stores the address of the array which is really stored in the dat_val_pointers, + * here we make dat_val store a pointer to the array itself instead of the address of it so that the + * rest of the code below works normally. */ + res->value.dat_val = *((void **)(tree->value.dat_val)); } /* end if */ else { - if(tree->lchild && H5Z_xform_eval_full(tree->lchild, array_size, array_type, &resl) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") - if(H5Z_xform_eval_full(tree->rchild, array_size, array_type, &resr) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") - - res->type = H5Z_XFORM_SYMBOL; - - /* For each type of operation: - * 1. See if "x" is on left hand side, right hand side, or if both sides are "x" - * 2. Figure out what type of data we're going to be manipulating - * 3. Do the operation on the data. */ - switch (tree->type) { - case H5Z_XFORM_PLUS: + if (tree->lchild && H5Z_xform_eval_full(tree->lchild, array_size, array_type, &resl) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") + if (H5Z_xform_eval_full(tree->rchild, array_size, array_type, &resr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") + + res->type = H5Z_XFORM_SYMBOL; + + /* For each type of operation: + * 1. See if "x" is on left hand side, right hand side, or if both sides are "x" + * 2. Figure out what type of data we're going to be manipulating + * 3. Do the operation on the data. */ + switch (tree->type) { + case H5Z_XFORM_PLUS: H5Z_XFORM_TYPE_OP(resl, resr, array_type, +, array_size) break; - case H5Z_XFORM_MINUS: + case H5Z_XFORM_MINUS: H5Z_XFORM_TYPE_OP(resl, resr, array_type, -, array_size) break; - case H5Z_XFORM_MULT: + case H5Z_XFORM_MULT: H5Z_XFORM_TYPE_OP(resl, resr, array_type, *, array_size) break; - case H5Z_XFORM_DIVIDE: + case H5Z_XFORM_DIVIDE: H5Z_XFORM_TYPE_OP(resl, resr, array_type, /, array_size) break; @@ -1174,26 +1181,25 @@ H5Z_xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_ case H5Z_XFORM_LPAREN: case H5Z_XFORM_RPAREN: case H5Z_XFORM_END: - default: + default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid expression tree") - } /* end switch */ - - /* The result stores a pointer to the new data */ - /* So, if the left hand side got its data modified, the result stores a pointers - * to the left hand side's data, ditto for rhs */ - if(resl.type == H5Z_XFORM_SYMBOL) - res->value.dat_val = resl.value.dat_val; - else if(resr.type == H5Z_XFORM_SYMBOL) - res->value.dat_val = resr.value.dat_val; - else - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error during transform evaluation") + } /* end switch */ + + /* The result stores a pointer to the new data */ + /* So, if the left hand side got its data modified, the result stores a pointers + * to the left hand side's data, ditto for rhs */ + if (resl.type == H5Z_XFORM_SYMBOL) + res->value.dat_val = resl.value.dat_val; + else if (resr.type == H5Z_XFORM_SYMBOL) + res->value.dat_val = resr.value.dat_val; + else + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error during transform evaluation") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_xform_eval_full() */ - /*------------------------------------------------------------------------- * Function: H5Z_find_type * Return: Native type of datatype that is passed in @@ -1202,81 +1208,66 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5Z_xform_find_type(const H5T_t* type) +H5Z_xform_find_type(const H5T_t *type) { - H5T_t *tmp; /* Temporary datatype */ - hid_t ret_value = SUCCEED; /* Return value */ + H5T_t *tmp; /* Temporary datatype */ + hid_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(type); /* Check for SHORT type */ - if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SHORT)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_SHORT) + if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SHORT)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_SHORT) /* Check for INT type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_INT)) - && 0 == H5T_cmp(type, tmp, FALSE)) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_INT)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_INT) /* Check for LONG type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LONG)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LONG) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LONG)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_LONG) /* Check for LONGLONG type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LLONG)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LLONG) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LLONG)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_LLONG) /* Check for UCHAR type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_UCHAR) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_UCHAR) /* Check for CHAR type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_CHAR)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_CHAR) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_CHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_CHAR) /* Check for SCHAR type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_SCHAR) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_SCHAR) /* Check for USHORT type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_USHORT)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_USHORT) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_USHORT)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_USHORT) /* Check for UINT type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UINT)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_UINT) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UINT)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_UINT) /* Check for ULONG type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULONG)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_ULONG) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULONG)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_ULONG) /* Check for ULONGLONG type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_ULLONG) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_ULLONG) /* Check for FLOAT type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_FLOAT) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_FLOAT) /* Check for DOUBLE type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_DOUBLE) -#if H5_SIZEOF_LONG_DOUBLE !=0 + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_DOUBLE) +#if H5_SIZEOF_LONG_DOUBLE != 0 /* Check for LONGDOUBLE type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LDOUBLE) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_LDOUBLE) #endif else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not find matching type") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not find matching type") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_xform_find_type() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_copy_tree * Purpose: Makes a copy of the parse tree passed in. @@ -1288,59 +1279,53 @@ done: *------------------------------------------------------------------------- */ static void * -H5Z_xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datval_ptrs* new_dat_val_pointers) +H5Z_xform_copy_tree(H5Z_node *tree, H5Z_datval_ptrs *dat_val_pointers, H5Z_datval_ptrs *new_dat_val_pointers) { - H5Z_node* ret_value=NULL; + H5Z_node *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) HDassert(tree); - if(tree->type == H5Z_XFORM_INTEGER) - { - if ((ret_value = (H5Z_node*) H5MM_malloc(sizeof(H5Z_node))) == NULL) + if (tree->type == H5Z_XFORM_INTEGER) { + if ((ret_value = (H5Z_node *)H5MM_malloc(sizeof(H5Z_node))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") - else - { - ret_value -> type = H5Z_XFORM_INTEGER; - ret_value ->value.int_val = tree->value.int_val; - ret_value -> lchild = NULL; - ret_value -> rchild = NULL; - } + else { + ret_value->type = H5Z_XFORM_INTEGER; + ret_value->value.int_val = tree->value.int_val; + ret_value->lchild = NULL; + ret_value->rchild = NULL; + } } - else if (tree->type == H5Z_XFORM_FLOAT) - { - if ((ret_value = (H5Z_node*) H5MM_malloc(sizeof(H5Z_node))) == NULL) + else if (tree->type == H5Z_XFORM_FLOAT) { + if ((ret_value = (H5Z_node *)H5MM_malloc(sizeof(H5Z_node))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") - else - { - ret_value -> type = H5Z_XFORM_FLOAT; - ret_value ->value.float_val = tree->value.float_val; - ret_value -> lchild = NULL; - ret_value -> rchild = NULL; - } + else { + ret_value->type = H5Z_XFORM_FLOAT; + ret_value->value.float_val = tree->value.float_val; + ret_value->lchild = NULL; + ret_value->rchild = NULL; + } } - else if(tree->type == H5Z_XFORM_SYMBOL) - { - if ((ret_value = (H5Z_node*) H5MM_malloc(sizeof(H5Z_node))) == NULL) + else if (tree->type == H5Z_XFORM_SYMBOL) { + if ((ret_value = (H5Z_node *)H5MM_malloc(sizeof(H5Z_node))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") - else - { - ret_value -> type = H5Z_XFORM_SYMBOL; - - ret_value -> value.dat_val = &(new_dat_val_pointers->ptr_dat_val[new_dat_val_pointers->num_ptrs]); - new_dat_val_pointers->num_ptrs++; - ret_value -> lchild = NULL; - ret_value -> rchild = NULL; - } + else { + ret_value->type = H5Z_XFORM_SYMBOL; + + ret_value->value.dat_val = &(new_dat_val_pointers->ptr_dat_val[new_dat_val_pointers->num_ptrs]); + new_dat_val_pointers->num_ptrs++; + ret_value->lchild = NULL; + ret_value->rchild = NULL; + } } - else if(tree->type == H5Z_XFORM_MULT) + else if (tree->type == H5Z_XFORM_MULT) H5Z_XFORM_DO_OP4(H5Z_XFORM_MULT) - else if(tree->type == H5Z_XFORM_PLUS) + else if (tree->type == H5Z_XFORM_PLUS) H5Z_XFORM_DO_OP4(H5Z_XFORM_PLUS) - else if(tree->type == H5Z_XFORM_MINUS) + else if (tree->type == H5Z_XFORM_MINUS) H5Z_XFORM_DO_OP4(H5Z_XFORM_MINUS) - else if(tree->type == H5Z_XFORM_DIVIDE) + else if (tree->type == H5Z_XFORM_DIVIDE) H5Z_XFORM_DO_OP4(H5Z_XFORM_DIVIDE) else HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error in parse tree while trying to copy") @@ -1349,7 +1334,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_op_is_numbs * Purpose: Internal function to facilitate the condition check in @@ -1361,7 +1345,7 @@ done: *------------------------------------------------------------------------- */ static hbool_t -H5Z_op_is_numbs(H5Z_node* _tree) +H5Z_op_is_numbs(H5Z_node *_tree) { hbool_t ret_value = FALSE; @@ -1369,13 +1353,13 @@ H5Z_op_is_numbs(H5Z_node* _tree) HDassert(_tree); - if(((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT)) && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) - ret_value = TRUE; + if (((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT)) && + ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) + ret_value = TRUE; FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_op_is_numbs2 * Purpose: Internal function to facilitate the condition check in @@ -1389,7 +1373,7 @@ H5Z_op_is_numbs(H5Z_node* _tree) *------------------------------------------------------------------------- */ static hbool_t -H5Z_op_is_numbs2(H5Z_node* _tree) +H5Z_op_is_numbs2(H5Z_node *_tree) { hbool_t ret_value = FALSE; @@ -1397,14 +1381,17 @@ H5Z_op_is_numbs2(H5Z_node* _tree) HDassert(_tree); - if((!_tree->lchild && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) || - ((_tree->lchild && ((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT))) && (_tree->rchild && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))))) - ret_value = TRUE; + if ((!_tree->lchild && + ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) || + ((_tree->lchild && + ((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT))) && + (_tree->rchild && + ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))))) + ret_value = TRUE; FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_xform_reduce_tree * Purpose: Simplifies parse tree passed in by performing any obvious @@ -1418,48 +1405,44 @@ H5Z_op_is_numbs2(H5Z_node* _tree) *------------------------------------------------------------------------- */ static void -H5Z_xform_reduce_tree(H5Z_node* tree) +H5Z_xform_reduce_tree(H5Z_node *tree) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(tree) { - if((tree->type == H5Z_XFORM_DIVIDE) || (tree->type == H5Z_XFORM_MULT)) - { - if(H5Z_op_is_numbs(tree)) + if (tree) { + if ((tree->type == H5Z_XFORM_DIVIDE) || (tree->type == H5Z_XFORM_MULT)) { + if (H5Z_op_is_numbs(tree)) H5Z_do_op(tree); - else - { + else { H5Z_xform_reduce_tree(tree->lchild); - if(H5Z_op_is_numbs(tree)) + if (H5Z_op_is_numbs(tree)) H5Z_do_op(tree); else { H5Z_xform_reduce_tree(tree->rchild); - if(H5Z_op_is_numbs(tree)) + if (H5Z_op_is_numbs(tree)) H5Z_do_op(tree); } } - } else if((tree->type == H5Z_XFORM_PLUS) || (tree->type == H5Z_XFORM_MINUS)) { - if(H5Z_op_is_numbs2(tree)) + } + else if ((tree->type == H5Z_XFORM_PLUS) || (tree->type == H5Z_XFORM_MINUS)) { + if (H5Z_op_is_numbs2(tree)) H5Z_do_op(tree); - else - { + else { H5Z_xform_reduce_tree(tree->lchild); - if(H5Z_op_is_numbs2(tree)) + if (H5Z_op_is_numbs2(tree)) H5Z_do_op(tree); else { H5Z_xform_reduce_tree(tree->rchild); - if(H5Z_op_is_numbs2(tree)) + if (H5Z_op_is_numbs2(tree)) H5Z_do_op(tree); } } } - } FUNC_LEAVE_NOAPI_VOID; } - /*------------------------------------------------------------------------- * Function: H5Z_do_op * Purpose: If the root of the tree passed in points to a simple @@ -1474,23 +1457,22 @@ H5Z_xform_reduce_tree(H5Z_node* tree) *------------------------------------------------------------------------- */ static void -H5Z_do_op(H5Z_node* tree) +H5Z_do_op(H5Z_node *tree) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(tree->type == H5Z_XFORM_DIVIDE) - H5Z_XFORM_DO_OP3(/) - else if(tree->type == H5Z_XFORM_MULT) - H5Z_XFORM_DO_OP3(*) - else if(tree->type == H5Z_XFORM_PLUS) - H5Z_XFORM_DO_OP6(+) - else if(tree->type == H5Z_XFORM_MINUS) - H5Z_XFORM_DO_OP6(-) + if (tree->type == H5Z_XFORM_DIVIDE) + H5Z_XFORM_DO_OP3(/) + else if (tree->type == H5Z_XFORM_MULT) + H5Z_XFORM_DO_OP3(*) + else if (tree->type == H5Z_XFORM_PLUS) + H5Z_XFORM_DO_OP6(+) + else if (tree->type == H5Z_XFORM_MINUS) + H5Z_XFORM_DO_OP6(-) FUNC_LEAVE_NOAPI_VOID; } - /*------------------------------------------------------------------------- * Function: H5D_xform_create * @@ -1510,74 +1492,79 @@ H5Z_data_xform_t * H5Z_xform_create(const char *expr) { H5Z_data_xform_t *data_xform_prop = NULL; - unsigned int i; - unsigned int count = 0; - H5Z_data_xform_t *ret_value = NULL; /* Return value */ + unsigned int i; + unsigned int count = 0; + H5Z_data_xform_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) HDassert(expr); /* Allocate space for the data transform information */ - if(NULL == (data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) + if (NULL == (data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for data transform info") - if(NULL == (data_xform_prop->dat_val_pointers = (H5Z_datval_ptrs *)H5MM_malloc(sizeof(H5Z_datval_ptrs)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for data transform array storage") + if (NULL == (data_xform_prop->dat_val_pointers = (H5Z_datval_ptrs *)H5MM_malloc(sizeof(H5Z_datval_ptrs)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate memory for data transform array storage") /* copy the user's string into the property */ - if(NULL == (data_xform_prop->xform_exp = (char *)H5MM_xstrdup(expr))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for data transform expression") + if (NULL == (data_xform_prop->xform_exp = (char *)H5MM_xstrdup(expr))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate memory for data transform expression") - /* Find the number of times "x" is used in this equation, and allocate room for storing that many points */ - for(i = 0; i < HDstrlen(expr); i++) - if(HDisalpha(expr[i])) - count++; + /* Find the number of times "x" is used in this equation, and allocate room for storing that many points + */ + for (i = 0; i < HDstrlen(expr); i++) + if (HDisalpha(expr[i])) + count++; /* When there are no "x"'s in the equation (ie, simple transform case), * we don't need to allocate any space since no array will have to be * stored */ - if(count > 0) - if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for pointers in transform array") + if (count > 0) + if (NULL == + (data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate memory for pointers in transform array") /* Initialize the num_ptrs field, which will be used to keep track of the number of copies * of the data we have for polynomial transforms */ data_xform_prop->dat_val_pointers->num_ptrs = 0; - /* we generate the parse tree right here and store a pointer to its root in the property. */ - if((data_xform_prop->parse_root = (H5Z_node *)H5Z_xform_parse(expr, data_xform_prop->dat_val_pointers))==NULL) + /* we generate the parse tree right here and store a pointer to its root in the property. */ + if ((data_xform_prop->parse_root = + (H5Z_node *)H5Z_xform_parse(expr, data_xform_prop->dat_val_pointers)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to generate parse tree from expression") /* Sanity check * count should be the same num_ptrs */ - if(count != data_xform_prop->dat_val_pointers->num_ptrs) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "error copying the parse tree, did not find correct number of \"variables\"") + if (count != data_xform_prop->dat_val_pointers->num_ptrs) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, + "error copying the parse tree, did not find correct number of \"variables\"") /* Assign return value */ - ret_value=data_xform_prop; - + ret_value = data_xform_prop; done: /* Clean up on error */ - if(ret_value==NULL) { - if(data_xform_prop) { - if(data_xform_prop->parse_root) + if (ret_value == NULL) { + if (data_xform_prop) { + if (data_xform_prop->parse_root) H5Z_xform_destroy_parse_tree(data_xform_prop->parse_root); - if(data_xform_prop->xform_exp) + if (data_xform_prop->xform_exp) H5MM_xfree(data_xform_prop->xform_exp); - if(count > 0 && data_xform_prop->dat_val_pointers->ptr_dat_val) - H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val); - if(data_xform_prop->dat_val_pointers) - H5MM_xfree(data_xform_prop->dat_val_pointers); + if (count > 0 && data_xform_prop->dat_val_pointers->ptr_dat_val) + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val); + if (data_xform_prop->dat_val_pointers) + H5MM_xfree(data_xform_prop->dat_val_pointers); H5MM_xfree(data_xform_prop); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_xform_create() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_destroy * @@ -1598,19 +1585,19 @@ H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(data_xform_prop) { - /* Destroy the parse tree */ + if (data_xform_prop) { + /* Destroy the parse tree */ H5Z_xform_destroy_parse_tree(data_xform_prop->parse_root); /* Free the expression */ H5MM_xfree(data_xform_prop->xform_exp); - /* Free the pointers to the temp. arrays, if there are any */ - if(data_xform_prop->dat_val_pointers->num_ptrs > 0) - H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val); + /* Free the pointers to the temp. arrays, if there are any */ + if (data_xform_prop->dat_val_pointers->num_ptrs > 0) + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val); - /* Free the data storage struct */ - H5MM_xfree(data_xform_prop->dat_val_pointers); + /* Free the data storage struct */ + H5MM_xfree(data_xform_prop->dat_val_pointers); /* Free the node */ H5MM_xfree(data_xform_prop); @@ -1619,7 +1606,6 @@ H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5Z_xform_destroy() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_copy * @@ -1642,66 +1628,75 @@ H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop) herr_t H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop) { - unsigned int i; - unsigned int count = 0; - H5Z_data_xform_t *new_data_xform_prop=NULL; - herr_t ret_value=SUCCEED; + unsigned int i; + unsigned int count = 0; + H5Z_data_xform_t *new_data_xform_prop = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - if(*data_xform_prop) { + if (*data_xform_prop) { /* Allocate new node */ - if(NULL == (new_data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) + if (NULL == (new_data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for data transform info") /* Copy string */ - if(NULL == (new_data_xform_prop->xform_exp = (char *)H5MM_xstrdup((*data_xform_prop)->xform_exp))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for data transform expression") - - if(NULL == (new_data_xform_prop->dat_val_pointers = (H5Z_datval_ptrs *)H5MM_malloc(sizeof(H5Z_datval_ptrs)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for data transform array storage") - - /* Find the number of times "x" is used in this equation, and allocate room for storing that many points */ - for(i = 0; i < HDstrlen(new_data_xform_prop->xform_exp); i++) - if(HDisalpha(new_data_xform_prop->xform_exp[i])) - count++; - - if(count > 0) - if(NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for pointers in transform array") - - /* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right amount */ - new_data_xform_prop->dat_val_pointers->num_ptrs = 0; + if (NULL == (new_data_xform_prop->xform_exp = (char *)H5MM_xstrdup((*data_xform_prop)->xform_exp))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate memory for data transform expression") + + if (NULL == + (new_data_xform_prop->dat_val_pointers = (H5Z_datval_ptrs *)H5MM_malloc(sizeof(H5Z_datval_ptrs)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate memory for data transform array storage") + + /* Find the number of times "x" is used in this equation, and allocate room for storing that many + * points */ + for (i = 0; i < HDstrlen(new_data_xform_prop->xform_exp); i++) + if (HDisalpha(new_data_xform_prop->xform_exp[i])) + count++; + + if (count > 0) + if (NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = + (void **)H5MM_calloc(count * sizeof(void *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate memory for pointers in transform array") + + /* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right + * amount */ + new_data_xform_prop->dat_val_pointers->num_ptrs = 0; /* Copy parse tree */ - if((new_data_xform_prop->parse_root = (H5Z_node*)H5Z_xform_copy_tree((*data_xform_prop)->parse_root, (*data_xform_prop)->dat_val_pointers, new_data_xform_prop->dat_val_pointers)) == NULL) + if ((new_data_xform_prop->parse_root = (H5Z_node *)H5Z_xform_copy_tree( + (*data_xform_prop)->parse_root, (*data_xform_prop)->dat_val_pointers, + new_data_xform_prop->dat_val_pointers)) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "error copying the parse tree") - /* Sanity check - * count should be the same num_ptrs */ - if(count != new_data_xform_prop->dat_val_pointers->num_ptrs) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "error copying the parse tree, did not find correct number of \"variables\"") + /* Sanity check + * count should be the same num_ptrs */ + if (count != new_data_xform_prop->dat_val_pointers->num_ptrs) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "error copying the parse tree, did not find correct number of \"variables\"") /* Copy new information on top of old information */ - *data_xform_prop=new_data_xform_prop; + *data_xform_prop = new_data_xform_prop; } /* end if */ done: /* Clean up on error */ - if(ret_value<0) { - if(new_data_xform_prop) { - if(new_data_xform_prop->parse_root) + if (ret_value < 0) { + if (new_data_xform_prop) { + if (new_data_xform_prop->parse_root) H5Z_xform_destroy_parse_tree(new_data_xform_prop->parse_root); - if(new_data_xform_prop->xform_exp) + if (new_data_xform_prop->xform_exp) H5MM_xfree(new_data_xform_prop->xform_exp); H5MM_xfree(new_data_xform_prop); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_xform_copy() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_noop * @@ -1720,16 +1715,15 @@ done: hbool_t H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - ret_value=(data_xform_prop ? FALSE : TRUE); + ret_value = (data_xform_prop ? FALSE : TRUE); FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_xform_noop() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_extract_xform_str * @@ -1756,4 +1750,3 @@ H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop) FUNC_LEAVE_NOAPI(data_xform_prop->xform_exp) } /* H5Z_xform_extract_xform_str() */ - diff --git a/src/H5api_adpt.h b/src/H5api_adpt.h index 0ff0f74..838cbf5 100644 --- a/src/H5api_adpt.h +++ b/src/H5api_adpt.h @@ -19,236 +19,235 @@ #ifndef H5API_ADPT_H #define H5API_ADPT_H - /* This will only be defined if HDF5 was built with CMake */ #ifdef H5_BUILT_AS_DYNAMIC_LIB #if defined(hdf5_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_DLL __declspec(dllexport) - #define H5_DLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_DLL __attribute__ ((visibility("default"))) - #define H5_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_DLL __declspec(dllexport) +#define H5_DLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_DLL __attribute__((visibility("default"))) +#define H5_DLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_DLL __declspec(dllimport) - #define H5_DLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_DLL __attribute__ ((visibility("default"))) - #define H5_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_DLL __declspec(dllimport) +#define H5_DLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_DLL __attribute__((visibility("default"))) +#define H5_DLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_DLL - #define H5_DLL - #define H5_DLLVAR extern +#define H5_DLL +#define H5_DLLVAR extern #endif /* _HDF5DLL_ */ #if defined(hdf5_test_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5TEST_DLL __declspec(dllexport) - #define H5TEST_DLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5TEST_DLL __attribute__ ((visibility("default"))) - #define H5TEST_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5TEST_DLL __declspec(dllexport) +#define H5TEST_DLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5TEST_DLL __attribute__((visibility("default"))) +#define H5TEST_DLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5TEST_DLL __declspec(dllimport) - #define H5TEST_DLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5TEST_DLL __attribute__ ((visibility("default"))) - #define H5TEST_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5TEST_DLL __declspec(dllimport) +#define H5TEST_DLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5TEST_DLL __attribute__((visibility("default"))) +#define H5TEST_DLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5TEST_DLL - #define H5TEST_DLL - #define H5TEST_DLLVAR extern +#define H5TEST_DLL +#define H5TEST_DLLVAR extern #endif /* H5TEST_DLL */ #if defined(hdf5_tools_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5TOOLS_DLL __declspec(dllexport) - #define H5TOOLS_DLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5TOOLS_DLL __attribute__ ((visibility("default"))) - #define H5TOOLS_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5TOOLS_DLL __declspec(dllexport) +#define H5TOOLS_DLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5TOOLS_DLL __attribute__((visibility("default"))) +#define H5TOOLS_DLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5TOOLS_DLL __declspec(dllimport) - #define H5TOOLS_DLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5TOOLS_DLL __attribute__ ((visibility("default"))) - #define H5TOOLS_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5TOOLS_DLL __declspec(dllimport) +#define H5TOOLS_DLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5TOOLS_DLL __attribute__((visibility("default"))) +#define H5TOOLS_DLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5TOOLS_DLL - #define H5TOOLS_DLL - #define H5TOOLS_DLLVAR extern +#define H5TOOLS_DLL +#define H5TOOLS_DLLVAR extern #endif /* H5TOOLS_DLL */ #if defined(hdf5_cpp_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_DLLCPP __declspec(dllexport) - #define H5_DLLCPPVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_DLLCPP __attribute__ ((visibility("default"))) - #define H5_DLLCPPVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_DLLCPP __declspec(dllexport) +#define H5_DLLCPPVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_DLLCPP __attribute__((visibility("default"))) +#define H5_DLLCPPVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_DLLCPP __declspec(dllimport) - #define H5_DLLCPPVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_DLLCPP __attribute__ ((visibility("default"))) - #define H5_DLLCPPVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_DLLCPP __declspec(dllimport) +#define H5_DLLCPPVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_DLLCPP __attribute__((visibility("default"))) +#define H5_DLLCPPVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_DLLCPP - #define H5_DLLCPP - #define H5_DLLCPPVAR extern +#define H5_DLLCPP +#define H5_DLLCPPVAR extern #endif /* H5_DLLCPP */ #if defined(hdf5_hl_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_HLDLL __declspec(dllexport) - #define H5_HLDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_HLDLL __attribute__ ((visibility("default"))) - #define H5_HLDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_HLDLL __declspec(dllexport) +#define H5_HLDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_HLDLL __attribute__((visibility("default"))) +#define H5_HLDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_HLDLL __declspec(dllimport) - #define H5_HLDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_HLDLL __attribute__ ((visibility("default"))) - #define H5_HLDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_HLDLL __declspec(dllimport) +#define H5_HLDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_HLDLL __attribute__((visibility("default"))) +#define H5_HLDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_HLDLL - #define H5_HLDLL - #define H5_HLDLLVAR extern +#define H5_HLDLL +#define H5_HLDLLVAR extern #endif /* H5_HLDLL */ #if defined(hdf5_hl_cpp_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_HLCPPDLL __declspec(dllexport) - #define H5_HLCPPDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_HLCPPDLL __attribute__ ((visibility("default"))) - #define H5_HLCPPDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_HLCPPDLL __declspec(dllexport) +#define H5_HLCPPDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_HLCPPDLL __attribute__((visibility("default"))) +#define H5_HLCPPDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_HLCPPDLL __declspec(dllimport) - #define H5_HLCPPDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_HLCPPDLL __attribute__ ((visibility("default"))) - #define H5_HLCPPDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_HLCPPDLL __declspec(dllimport) +#define H5_HLCPPDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_HLCPPDLL __attribute__((visibility("default"))) +#define H5_HLCPPDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_HLCPPDLL - #define H5_HLCPPDLL - #define H5_HLCPPDLLVAR extern +#define H5_HLCPPDLL +#define H5_HLCPPDLLVAR extern #endif /* H5_HLCPPDLL */ #if defined(hdf5_f90cstub_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_FCDLL __declspec(dllexport) - #define H5_FCDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_FCDLL __attribute__ ((visibility("default"))) - #define H5_FCDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_FCDLL __declspec(dllexport) +#define H5_FCDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_FCDLL __attribute__((visibility("default"))) +#define H5_FCDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_FCDLL __declspec(dllimport) - #define H5_FCDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_FCDLL __attribute__ ((visibility("default"))) - #define H5_FCDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_FCDLL __declspec(dllimport) +#define H5_FCDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_FCDLL __attribute__((visibility("default"))) +#define H5_FCDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_FCDLL - #define H5_FCDLL - #define H5_FCDLLVAR extern +#define H5_FCDLL +#define H5_FCDLLVAR extern #endif /* H5_FCDLL */ #if defined(hdf5_test_f90cstub_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_FCTESTDLL __declspec(dllexport) - #define H5_FCTESTDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_FCTESTDLL __attribute__ ((visibility("default"))) - #define H5_FCTESTDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_FCTESTDLL __declspec(dllexport) +#define H5_FCTESTDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_FCTESTDLL __attribute__((visibility("default"))) +#define H5_FCTESTDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_FCTESTDLL __declspec(dllimport) - #define H5_FCTESTDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_FCTESTDLL __attribute__ ((visibility("default"))) - #define H5_FCTESTDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_FCTESTDLL __declspec(dllimport) +#define H5_FCTESTDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_FCTESTDLL __attribute__((visibility("default"))) +#define H5_FCTESTDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_FCTESTDLL - #define H5_FCTESTDLL - #define H5_FCTESTDLLVAR extern +#define H5_FCTESTDLL +#define H5_FCTESTDLLVAR extern #endif /* H5_FCTESTDLL */ #if defined(hdf5_hl_f90cstub_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define HDF5_HL_F90CSTUBDLL __declspec(dllexport) - #define HDF5_HL_F90CSTUBDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define HDF5_HL_F90CSTUBDLL __attribute__ ((visibility("default"))) - #define HDF5_HL_F90CSTUBDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define HDF5_HL_F90CSTUBDLL __declspec(dllexport) +#define HDF5_HL_F90CSTUBDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define HDF5_HL_F90CSTUBDLL __attribute__((visibility("default"))) +#define HDF5_HL_F90CSTUBDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define HDF5_HL_F90CSTUBDLL __declspec(dllimport) - #define HDF5_HL_F90CSTUBDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define HDF5_HL_F90CSTUBDLL __attribute__ ((visibility("default"))) - #define HDF5_HL_F90CSTUBDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define HDF5_HL_F90CSTUBDLL __declspec(dllimport) +#define HDF5_HL_F90CSTUBDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define HDF5_HL_F90CSTUBDLL __attribute__((visibility("default"))) +#define HDF5_HL_F90CSTUBDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef HDF5_HL_F90CSTUBDLL - #define HDF5_HL_F90CSTUBDLL - #define HDF5_HL_F90CSTUBDLLVAR extern +#define HDF5_HL_F90CSTUBDLL +#define HDF5_HL_F90CSTUBDLLVAR extern #endif /* HDF5_HL_F90CSTUBDLL */ #else - #define H5_DLL - #define H5_DLLVAR extern - #define H5TEST_DLL - #define H5TEST_DLLVAR extern - #define H5TOOLS_DLL - #define H5TOOLS_DLLVAR extern - #define H5_DLLCPP - #define H5_DLLCPPVAR extern - #define H5_HLDLL - #define H5_HLDLLVAR extern - #define H5_HLCPPDLL - #define H5_HLCPPDLLVAR extern - #define H5_FCDLL - #define H5_FCDLLVAR extern - #define H5_FCTESTDLL - #define H5_FCTESTDLLVAR extern - #define HDF5_HL_F90CSTUBDLL - #define HDF5_HL_F90CSTUBDLLVAR extern +#define H5_DLL +#define H5_DLLVAR extern +#define H5TEST_DLL +#define H5TEST_DLLVAR extern +#define H5TOOLS_DLL +#define H5TOOLS_DLLVAR extern +#define H5_DLLCPP +#define H5_DLLCPPVAR extern +#define H5_HLDLL +#define H5_HLDLLVAR extern +#define H5_HLCPPDLL +#define H5_HLCPPDLLVAR extern +#define H5_FCDLL +#define H5_FCDLLVAR extern +#define H5_FCTESTDLL +#define H5_FCTESTDLLVAR extern +#define HDF5_HL_F90CSTUBDLL +#define HDF5_HL_F90CSTUBDLLVAR extern #endif /* H5_BUILT_AS_DYNAMIC_LIB */ #endif /* H5API_ADPT_H */ diff --git a/src/H5checksum.c b/src/H5checksum.c index 4e98976..5eb735e 100644 --- a/src/H5checksum.c +++ b/src/H5checksum.c @@ -26,12 +26,10 @@ /* Module Setup */ /****************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ - +#include "H5private.h" /* Generic Functions */ /****************/ /* Local Macros */ @@ -41,32 +39,26 @@ /* (same as the IEEE 802.3 (Ethernet) quotient) */ #define H5_CRC_QUOTIENT 0x04C11DB7 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -77,8 +69,6 @@ static uint32_t H5_crc_table[256]; /* Flag: has the table been computed? */ static hbool_t H5_crc_table_computed = FALSE; - - /*------------------------------------------------------------------------- * Function: H5_checksum_fletcher32 * @@ -109,9 +99,9 @@ static hbool_t H5_crc_table_computed = FALSE; uint32_t H5_checksum_fletcher32(const void *_data, size_t _len) { - const uint8_t *data = (const uint8_t *)_data; /* Pointer to the data to be summed */ - size_t len = _len / 2; /* Length in 16-bit words */ - uint32_t sum1 = 0, sum2 = 0; + const uint8_t *data = (const uint8_t *)_data; /* Pointer to the data to be summed */ + size_t len = _len / 2; /* Length in 16-bit words */ + uint32_t sum1 = 0, sum2 = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -136,7 +126,7 @@ H5_checksum_fletcher32(const void *_data, size_t _len) } /* Check for odd # of bytes */ - if(_len % 2) { + if (_len % 2) { sum1 += (uint32_t)(((uint16_t)*data) << 8); sum2 += sum1; sum1 = (sum1 & 0xffff) + (sum1 >> 16); @@ -150,7 +140,6 @@ H5_checksum_fletcher32(const void *_data, size_t _len) FUNC_LEAVE_NOAPI((sum2 << 16) | sum1) } /* end H5_checksum_fletcher32() */ - /*------------------------------------------------------------------------- * Function: H5_checksum_crc_make_table * @@ -166,16 +155,16 @@ H5_checksum_fletcher32(const void *_data, size_t _len) static void H5_checksum_crc_make_table(void) { - uint32_t c; /* Checksum for each byte value */ - unsigned n, k; /* Local index variables */ + uint32_t c; /* Checksum for each byte value */ + unsigned n, k; /* Local index variables */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Compute the checksum for each possible byte value */ - for(n = 0; n < 256; n++) { - c = (uint32_t) n; - for(k = 0; k < 8; k++) - if(c & 1) + for (n = 0; n < 256; n++) { + c = (uint32_t)n; + for (k = 0; k < 8; k++) + if (c & 1) c = H5_CRC_QUOTIENT ^ (c >> 1); else c = c >> 1; @@ -186,7 +175,6 @@ H5_checksum_crc_make_table(void) FUNC_LEAVE_NOAPI_VOID } /* end H5_checksum_crc_make_table() */ - /*------------------------------------------------------------------------- * Function: H5_checksum_crc_make_table * @@ -205,22 +193,21 @@ H5_checksum_crc_make_table(void) static uint32_t H5_checksum_crc_update(uint32_t crc, const uint8_t *buf, size_t len) { - size_t n; /* Local index variable */ + size_t n; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Initialize the CRC table if necessary */ - if(!H5_crc_table_computed) + if (!H5_crc_table_computed) H5_checksum_crc_make_table(); /* Update the CRC with the results from this buffer */ - for(n = 0; n < len; n++) + for (n = 0; n < len; n++) crc = H5_crc_table[(crc ^ buf[n]) & 0xff] ^ (crc >> 8); FUNC_LEAVE_NOAPI(crc) } /* end H5_checksum_crc_update() */ - /*------------------------------------------------------------------------- * Function: H5_checksum_crc * @@ -294,16 +281,28 @@ on, and rotates are much kinder to the top and bottom bits, so I used rotates. ------------------------------------------------------------------------------- */ -#define H5_lookup3_rot(x,k) (((x)<<(k)) ^ ((x)>>(32-(k)))) -#define H5_lookup3_mix(a,b,c) \ -{ \ - a -= c; a ^= H5_lookup3_rot(c, 4); c += b; \ - b -= a; b ^= H5_lookup3_rot(a, 6); a += c; \ - c -= b; c ^= H5_lookup3_rot(b, 8); b += a; \ - a -= c; a ^= H5_lookup3_rot(c,16); c += b; \ - b -= a; b ^= H5_lookup3_rot(a,19); a += c; \ - c -= b; c ^= H5_lookup3_rot(b, 4); b += a; \ -} +#define H5_lookup3_rot(x, k) (((x) << (k)) ^ ((x) >> (32 - (k)))) +#define H5_lookup3_mix(a, b, c) \ + { \ + a -= c; \ + a ^= H5_lookup3_rot(c, 4); \ + c += b; \ + b -= a; \ + b ^= H5_lookup3_rot(a, 6); \ + a += c; \ + c -= b; \ + c ^= H5_lookup3_rot(b, 8); \ + b += a; \ + a -= c; \ + a ^= H5_lookup3_rot(c, 16); \ + c += b; \ + b -= a; \ + b ^= H5_lookup3_rot(a, 19); \ + a += c; \ + c -= b; \ + c ^= H5_lookup3_rot(b, 4); \ + b += a; \ + } /* ------------------------------------------------------------------------------- @@ -330,16 +329,23 @@ and these came close: 11 8 15 26 3 22 24 ------------------------------------------------------------------------------- */ -#define H5_lookup3_final(a,b,c) \ -{ \ - c ^= b; c -= H5_lookup3_rot(b,14); \ - a ^= c; a -= H5_lookup3_rot(c,11); \ - b ^= a; b -= H5_lookup3_rot(a,25); \ - c ^= b; c -= H5_lookup3_rot(b,16); \ - a ^= c; a -= H5_lookup3_rot(c,4); \ - b ^= a; b -= H5_lookup3_rot(a,14); \ - c ^= b; c -= H5_lookup3_rot(b,24); \ -} +#define H5_lookup3_final(a, b, c) \ + { \ + c ^= b; \ + c -= H5_lookup3_rot(b, 14); \ + a ^= c; \ + a -= H5_lookup3_rot(c, 11); \ + b ^= a; \ + b -= H5_lookup3_rot(a, 25); \ + c ^= b; \ + c -= H5_lookup3_rot(b, 16); \ + a ^= c; \ + a -= H5_lookup3_rot(c, 4); \ + b ^= a; \ + b -= H5_lookup3_rot(a, 14); \ + c ^= b; \ + c -= H5_lookup3_rot(b, 24); \ + } /* ------------------------------------------------------------------------------- @@ -372,7 +378,7 @@ uint32_t H5_checksum_lookup3(const void *key, size_t length, uint32_t initval) { const uint8_t *k = (const uint8_t *)key; - uint32_t a, b, c; /* internal state */ + uint32_t a, b, c; /* internal state */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -384,53 +390,65 @@ H5_checksum_lookup3(const void *key, size_t length, uint32_t initval) a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ - while (length > 12) - { - a += k[0]; - a += ((uint32_t)k[1])<<8; - a += ((uint32_t)k[2])<<16; - a += ((uint32_t)k[3])<<24; - b += k[4]; - b += ((uint32_t)k[5])<<8; - b += ((uint32_t)k[6])<<16; - b += ((uint32_t)k[7])<<24; - c += k[8]; - c += ((uint32_t)k[9])<<8; - c += ((uint32_t)k[10])<<16; - c += ((uint32_t)k[11])<<24; - H5_lookup3_mix(a, b, c); - length -= 12; - k += 12; + while (length > 12) { + a += k[0]; + a += ((uint32_t)k[1]) << 8; + a += ((uint32_t)k[2]) << 16; + a += ((uint32_t)k[3]) << 24; + b += k[4]; + b += ((uint32_t)k[5]) << 8; + b += ((uint32_t)k[6]) << 16; + b += ((uint32_t)k[7]) << 24; + c += k[8]; + c += ((uint32_t)k[9]) << 8; + c += ((uint32_t)k[10]) << 16; + c += ((uint32_t)k[11]) << 24; + H5_lookup3_mix(a, b, c); + length -= 12; + k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ - switch(length) /* all the case statements fall through */ + switch (length) /* all the case statements fall through */ { - case 12: c+=((uint32_t)k[11])<<24; - H5_ATTR_FALLTHROUGH - case 11: c+=((uint32_t)k[10])<<16; - H5_ATTR_FALLTHROUGH - case 10: c+=((uint32_t)k[9])<<8; - H5_ATTR_FALLTHROUGH - case 9 : c+=k[8]; - H5_ATTR_FALLTHROUGH - case 8 : b+=((uint32_t)k[7])<<24; - H5_ATTR_FALLTHROUGH - case 7 : b+=((uint32_t)k[6])<<16; - H5_ATTR_FALLTHROUGH - case 6 : b+=((uint32_t)k[5])<<8; - H5_ATTR_FALLTHROUGH - case 5 : b+=k[4]; - H5_ATTR_FALLTHROUGH - case 4 : a+=((uint32_t)k[3])<<24; - H5_ATTR_FALLTHROUGH - case 3 : a+=((uint32_t)k[2])<<16; - H5_ATTR_FALLTHROUGH - case 2 : a+=((uint32_t)k[1])<<8; - H5_ATTR_FALLTHROUGH - case 1 : a+=k[0]; - break; - case 0 : goto done; + case 12: + c += ((uint32_t)k[11]) << 24; + H5_ATTR_FALLTHROUGH + case 11: + c += ((uint32_t)k[10]) << 16; + H5_ATTR_FALLTHROUGH + case 10: + c += ((uint32_t)k[9]) << 8; + H5_ATTR_FALLTHROUGH + case 9: + c += k[8]; + H5_ATTR_FALLTHROUGH + case 8: + b += ((uint32_t)k[7]) << 24; + H5_ATTR_FALLTHROUGH + case 7: + b += ((uint32_t)k[6]) << 16; + H5_ATTR_FALLTHROUGH + case 6: + b += ((uint32_t)k[5]) << 8; + H5_ATTR_FALLTHROUGH + case 5: + b += k[4]; + H5_ATTR_FALLTHROUGH + case 4: + a += ((uint32_t)k[3]) << 24; + H5_ATTR_FALLTHROUGH + case 3: + a += ((uint32_t)k[2]) << 16; + H5_ATTR_FALLTHROUGH + case 2: + a += ((uint32_t)k[1]) << 8; + H5_ATTR_FALLTHROUGH + case 1: + a += k[0]; + break; + case 0: + goto done; default: HDassert(0 && "This Should never be executed!"); } @@ -441,7 +459,6 @@ done: FUNC_LEAVE_NOAPI(c) } /* end H5_checksum_lookup3() */ - /*------------------------------------------------------------------------- * Function: H5_checksum_metadata * @@ -470,7 +487,6 @@ H5_checksum_metadata(const void *data, size_t len, uint32_t initval) FUNC_LEAVE_NOAPI(H5_checksum_lookup3(data, len, initval)) } /* end H5_checksum_metadata() */ - /*------------------------------------------------------------------------- * Function: H5_hash_string * @@ -490,16 +506,15 @@ uint32_t H5_hash_string(const char *str) { uint32_t hash = 5381; - int c; + int c; FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ HDassert(str); - while((c = *str++)) + while ((c = *str++)) hash = ((hash << 5) + hash) + (uint32_t)c; /* hash * 33 + c */ FUNC_LEAVE_NOAPI(hash) } /* end H5_hash_string() */ - diff --git a/src/H5dbg.c b/src/H5dbg.c index c01ad88..fe4e757 100644 --- a/src/H5dbg.c +++ b/src/H5dbg.c @@ -29,39 +29,32 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5_buffer_dump * @@ -75,10 +68,10 @@ *------------------------------------------------------------------------- */ herr_t -H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, - const uint8_t *marker, size_t buf_offset, size_t buf_size) +H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, const uint8_t *marker, size_t buf_offset, + size_t buf_size) { - size_t u, v; /* Local index variable */ + size_t u, v; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -94,50 +87,48 @@ H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, /* * Print the buffer in a VMS-style octal dump. */ - HDfprintf(stream, "%*sData follows (`__' indicates free region)...\n", - indent, ""); - for(u = 0; u < buf_size; u += 16) { - uint8_t c; + HDfprintf(stream, "%*sData follows (`__' indicates free region)...\n", indent, ""); + for (u = 0; u < buf_size; u += 16) { + uint8_t c; - HDfprintf(stream, "%*s %8d: ", indent, "", u + buf_offset); + HDfprintf(stream, "%*s %8d: ", indent, "", u + buf_offset); /* Print the hex values */ - for(v = 0; v < 16; v++) { - if(u + v < buf_size) { - if(marker[u + v]) - HDfprintf(stream, "__ "); - else { - c = buf[buf_offset + u + v]; - HDfprintf(stream, "%02x ", c); - } /* end else */ - } /* end if */ + for (v = 0; v < 16; v++) { + if (u + v < buf_size) { + if (marker[u + v]) + HDfprintf(stream, "__ "); + else { + c = buf[buf_offset + u + v]; + HDfprintf(stream, "%02x ", c); + } /* end else */ + } /* end if */ else - HDfprintf(stream, " "); - if(7 == v) - HDfputc(' ', stream); - } /* end for */ + HDfprintf(stream, " "); + if (7 == v) + HDfputc(' ', stream); + } /* end for */ HDfputc(' ', stream); /* Print the character values */ - for(v = 0; v < 16; v++) { - if(u + v < buf_size) { - if(marker[u + v]) - HDfputc(' ', stream); - else { - c = buf[buf_offset + u + v]; - if(HDisprint(c)) - HDfputc(c, stream); - else - HDfputc('.', stream); - } /* end else */ - } /* end if */ - if(7 == v) - HDfputc(' ', stream); - } /* end for */ - - HDfputc('\n', stream); + for (v = 0; v < 16; v++) { + if (u + v < buf_size) { + if (marker[u + v]) + HDfputc(' ', stream); + else { + c = buf[buf_offset + u + v]; + if (HDisprint(c)) + HDfputc(c, stream); + else + HDfputc('.', stream); + } /* end else */ + } /* end if */ + if (7 == v) + HDfputc(' ', stream); + } /* end for */ + + HDfputc('\n', stream); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5_buffer_dump() */ - diff --git a/src/H5detect.c b/src/H5detect.c index 655b05c..11a01ee 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -43,22 +43,25 @@ static const char *FileHeader = "\n\ */ #undef NDEBUG #include "H5private.h" +/* Do NOT use HDfprintf in this file as it is not linked with the library, + * which contains the H5system.c file in which the function is defined. + */ #include "H5Tpublic.h" #include "H5Rpublic.h" /* Disable warning about cast increasing the alignment of the target type, * that's _exactly_ what this code is probing. -QAK */ -H5_GCC_DIAG_OFF(cast-align) +H5_GCC_DIAG_OFF("cast-align") #if defined(__has_attribute) -# if __has_attribute(no_sanitize_address) -# define HDF_NO_UBSAN __attribute__((no_sanitize_address)) -# else -# define HDF_NO_UBSAN -# endif +#if __has_attribute(no_sanitize_address) +#define HDF_NO_UBSAN __attribute__((no_sanitize_address)) +#else +#define HDF_NO_UBSAN +#endif #else -# define HDF_NO_UBSAN +#define HDF_NO_UBSAN #endif #define MAXDETECT 64 @@ -73,80 +76,79 @@ H5_GCC_DIAG_OFF(cast-align) /* supported. */ #if defined(H5_HAVE_SIGSETJMP) && defined(H5_HAVE_SIGLONGJMP) /* Always save blocked signals to be restored by siglongjmp. */ -#define H5JMP_BUF sigjmp_buf -#define H5SETJMP(buf) HDsigsetjmp(buf, 1) -#define H5LONGJMP(buf, val) HDsiglongjmp(buf, val) -#define H5HAVE_SIGJMP /* sigsetjmp/siglongjmp are supported. */ +#define H5JMP_BUF sigjmp_buf +#define H5SETJMP(buf) HDsigsetjmp(buf, 1) +#define H5LONGJMP(buf, val) HDsiglongjmp(buf, val) +#define H5HAVE_SIGJMP /* sigsetjmp/siglongjmp are supported. */ #elif defined(H5_HAVE_LONGJMP) -#define H5JMP_BUF jmp_buf -#define H5SETJMP(buf) HDsetjmp(buf) -#define H5LONGJMP(buf, val) HDlongjmp(buf, val) +#define H5JMP_BUF jmp_buf +#define H5SETJMP(buf) HDsetjmp(buf) +#define H5LONGJMP(buf, val) HDlongjmp(buf, val) #endif /* ALIGNMENT and signal-handling status codes */ -#define STA_NoALIGNMENT 0x0001 /* No ALIGNMENT Test */ -#define STA_NoHandlerVerify 0x0002 /* No signal handler Tests */ - +#define STA_NoALIGNMENT 0x0001 /* No ALIGNMENT Test */ +#define STA_NoHandlerVerify 0x0002 /* No signal handler Tests */ /* * This structure holds information about a type that * was detected. */ typedef struct detected_t { - const char *varname; - unsigned int size; /* total byte size */ - unsigned int precision; /* meaningful bits */ - unsigned int offset; /* bit offset to meaningful bits */ - int perm[32]; /* for detection of byte order */ - hbool_t is_vax; /* for vax (float & double) only */ - unsigned int sign; /* location of sign bit */ - unsigned int mpos, msize, imp; /* information about mantissa */ - unsigned int epos, esize; /* information about exponent */ - unsigned long bias; /* exponent bias for floating pt */ - unsigned int align; /* required byte alignment */ - unsigned int comp_align; /* alignment for structure */ + const char * varname; + unsigned int size; /* total byte size */ + unsigned int precision; /* meaningful bits */ + unsigned int offset; /* bit offset to meaningful bits */ + int perm[32]; /* for detection of byte order */ + hbool_t is_vax; /* for vax (float & double) only */ + unsigned int sign; /* location of sign bit */ + unsigned int mpos, msize, imp; /* information about mantissa */ + unsigned int epos, esize; /* information about exponent */ + unsigned long bias; /* exponent bias for floating pt */ + unsigned int align; /* required byte alignment */ + unsigned int comp_align; /* alignment for structure */ } detected_t; /* This structure holds structure alignment for pointers, vlen and reference * types. */ typedef struct malign_t { - const char *name; - unsigned int comp_align; /* alignment for structure */ + const char * name; + unsigned int comp_align; /* alignment for structure */ } malign_t; -FILE *rawoutstream = NULL; +FILE *rawoutstream = NULL; /* global variables types detection code */ -H5_GCC_DIAG_OFF(larger-than=) +H5_GCC_DIAG_OFF("larger-than=") static detected_t d_g[MAXDETECT]; -H5_GCC_DIAG_ON(larger-than=) -static malign_t m_g[MAXDETECT]; +H5_GCC_DIAG_ON("larger-than=") +static malign_t m_g[MAXDETECT]; static volatile int nd_g = 0, na_g = 0; -static void print_results(int nd, detected_t *d, int na, malign_t *m); -static void iprint(detected_t *); -static int byte_cmp(int, const void *, const void *, const unsigned char *); +static void print_results(int nd, detected_t *d, int na, malign_t *m); +static void iprint(detected_t *); +static int byte_cmp(int, const void *, const void *, const unsigned char *); static unsigned int bit_cmp(unsigned int, int *, void *, void *, const unsigned char *); -static void fix_order(int, int, int *, const char **); +static void fix_order(int, int, int *, const char **); static unsigned int imp_bit(unsigned int, int *, void *, void *, const unsigned char *); static unsigned int find_bias(unsigned int, unsigned int, int *, void *); -static void precision (detected_t*); -static void print_header(void); -static void detect_C89_integers(void); -static void detect_C89_floats(void); -static void detect_C99_integers(void); -static void detect_C99_floats(void); -static void detect_C99_integers8(void); -static void detect_C99_integers16(void); -static void detect_C99_integers32(void); -static void detect_C99_integers64(void); -static void detect_alignments(void); -static unsigned int align_g[] = {1, 2, 4, 8, 16}; -static int align_status_g = 0; /* ALIGNMENT Signal Status */ -static int sigbus_handler_called_g = 0; /* how many times called */ -static int sigsegv_handler_called_g = 0; /* how many times called */ -static int sigill_handler_called_g = 0; /* how many times called */ -static int signal_handler_tested_g = 0; /* how many times tested */ +static void precision(detected_t *); +static void print_header(void); +static void detect_C89_integers(void); +static void detect_C89_floats(void); +static void detect_C99_integers(void); +static void detect_C99_floats(void); +static void detect_C99_integers8(void); +static void detect_C99_integers16(void); +static void detect_C99_integers32(void); +static void detect_C99_integers64(void); +static void detect_alignments(void); +static unsigned int align_g[] = {1, 2, 4, 8, 16}; +static int align_status_g = 0; /* ALIGNMENT Signal Status */ +static int sigbus_handler_called_g = 0; /* how many times called */ +static int sigsegv_handler_called_g = 0; /* how many times called */ +static int sigill_handler_called_g = 0; /* how many times called */ +static int signal_handler_tested_g = 0; /* how many times tested */ #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) static int verify_signal_handlers(int signum, void (*handler)(int)); #endif @@ -154,8 +156,6 @@ static int verify_signal_handlers(int signum, void (*handler)(int)); static H5JMP_BUF jbuf_g; #endif - - /*------------------------------------------------------------------------- * Function: precision * @@ -165,50 +165,49 @@ static H5JMP_BUF jbuf_g; *------------------------------------------------------------------------- */ static void -precision (detected_t *d) +precision(detected_t *d) { unsigned int n; - if(0 == d->msize) { + if (0 == d->msize) { /* * An integer. The permutation can have negative values at the * beginning or end which represent padding of bytes. We must adjust * the precision and offset accordingly. */ - if(d->perm[0] < 0) { + if (d->perm[0] < 0) { /* * Lower addresses are padded. */ - for(n = 0; n < d->size && d->perm[n] < 0; n++) + for (n = 0; n < d->size && d->perm[n] < 0; n++) /*void*/; d->precision = 8 * (d->size - n); - d->offset = 0; + d->offset = 0; } - else if(d->perm[d->size - 1] < 0) { + else if (d->perm[d->size - 1] < 0) { /* * Higher addresses are padded. */ for (n = 0; n < d->size && d->perm[d->size - (n + 1)]; n++) /*void*/; d->precision = 8 * (d->size - n); - d->offset = 8 * n; + d->offset = 8 * n; } else { /* * No padding. */ d->precision = 8 * d->size; - d->offset = 0; + d->offset = 0; } } else { /* A floating point */ - d->offset = MIN3(d->mpos, d->epos, d->sign); + d->offset = MIN3(d->mpos, d->epos, d->sign); d->precision = d->msize + d->esize + 1; } } - /*------------------------------------------------------------------------- * Function: DETECT_I/DETECT_BYTE * @@ -221,68 +220,51 @@ precision (detected_t *d) * * Return: void * - * Modifications: - * - * Robb Matzke, 4 Nov 1996 - * The INFO.perm now contains `-1' for bytes that aren't used and - * are always zero. This happens on the Cray for `short' where - * sizeof(short) is 8, but only the low-order 4 bytes are ever used. - * - * Robb Matzke, 4 Nov 1996 - * Added a `padding' field to indicate how many zero bytes appear to - * the left (N) or right (-N) of the value. - * - * Robb Matzke, 5 Nov 1996 - * Removed HFILE and CFILE arguments. - * - * Neil Fortner, 6 Sep 2013 - * Split macro into DETECT_I and DETECT_BYTE macros, extracted - * common code into DETECT_I_BYTE_CORE. This was done to remove - * "will never be executed" warnings. - * *------------------------------------------------------------------------- */ -#define DETECT_I_BYTE_CORE(TYPE,VAR,INFO,DETECT_TYPE) { \ - DETECT_TYPE _v; \ - int _i, _j; \ - unsigned char *_x; \ - \ - HDmemset(&INFO, 0, sizeof(INFO)); \ - INFO.varname = #VAR; \ - INFO.size = sizeof(TYPE); \ - \ - for(_i = sizeof(DETECT_TYPE), _v = 0; _i > 0; --_i) \ - _v = (DETECT_TYPE) ((DETECT_TYPE) (_v << 8) + (DETECT_TYPE) _i); \ - \ - for(_i = 0, _x = (unsigned char *)&_v; _i < (signed)sizeof(DETECT_TYPE); _i++) { \ - _j = (*_x++) - 1; \ - HDassert(_j < (signed)sizeof(DETECT_TYPE)); \ - INFO.perm[_i] = _j; \ - } /* end for */ \ - \ - INFO.sign = ('U' != *(#VAR)); \ - precision (&(INFO)); \ - ALIGNMENT(TYPE, INFO); \ - if(!HDstrcmp(INFO.varname, "SCHAR") || !HDstrcmp(INFO.varname, "SHORT") || \ - !HDstrcmp(INFO.varname, "INT") || !HDstrcmp(INFO.varname, "LONG") || \ - !HDstrcmp(INFO.varname, "LLONG")) { \ - COMP_ALIGNMENT(TYPE, INFO.comp_align); \ - } \ -} +#define DETECT_I_BYTE_CORE(TYPE, VAR, INFO, DETECT_TYPE) \ + { \ + DETECT_TYPE _v; \ + int _i, _j; \ + unsigned char *_x; \ + \ + HDmemset(&INFO, 0, sizeof(INFO)); \ + INFO.varname = #VAR; \ + INFO.size = sizeof(TYPE); \ + \ + for (_i = sizeof(DETECT_TYPE), _v = 0; _i > 0; --_i) \ + _v = (DETECT_TYPE)((DETECT_TYPE)(_v << 8) + (DETECT_TYPE)_i); \ + \ + for (_i = 0, _x = (unsigned char *)&_v; _i < (signed)sizeof(DETECT_TYPE); _i++) { \ + _j = (*_x++) - 1; \ + HDassert(_j < (signed)sizeof(DETECT_TYPE)); \ + INFO.perm[_i] = _j; \ + } /* end for */ \ + \ + INFO.sign = ('U' != *(#VAR)); \ + precision(&(INFO)); \ + ALIGNMENT(TYPE, INFO); \ + if (!HDstrcmp(INFO.varname, "SCHAR") || !HDstrcmp(INFO.varname, "SHORT") || \ + !HDstrcmp(INFO.varname, "INT") || !HDstrcmp(INFO.varname, "LONG") || \ + !HDstrcmp(INFO.varname, "LLONG")) { \ + COMP_ALIGNMENT(TYPE, INFO.comp_align); \ + } \ + } -#define DETECT_BYTE(TYPE,VAR,INFO) { \ - HDcompile_assert(sizeof(TYPE) == 1); \ - \ - DETECT_I_BYTE_CORE(TYPE,VAR,INFO,int) \ -} +#define DETECT_BYTE(TYPE, VAR, INFO) \ + { \ + HDcompile_assert(sizeof(TYPE) == 1); \ + \ + DETECT_I_BYTE_CORE(TYPE, VAR, INFO, int) \ + } -#define DETECT_I(TYPE,VAR,INFO) { \ - HDcompile_assert(sizeof(TYPE) > 1); \ - \ - DETECT_I_BYTE_CORE(TYPE,VAR,INFO,TYPE) \ -} +#define DETECT_I(TYPE, VAR, INFO) \ + { \ + HDcompile_assert(sizeof(TYPE) > 1); \ + \ + DETECT_I_BYTE_CORE(TYPE, VAR, INFO, TYPE) \ + } - /*------------------------------------------------------------------------- * Function: DETECT_F * @@ -293,93 +275,93 @@ precision (detected_t *d) * initializes a detected_t structure with those properties. *------------------------------------------------------------------------- */ -#define DETECT_F(TYPE,VAR,INFO) { \ - TYPE _v1, _v2, _v3; \ - unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \ - unsigned char _pad_mask[sizeof(TYPE)]; \ - unsigned char _byte_mask; \ - int _i, _j, _last = (-1); \ - const char *_mesg; \ - \ - HDmemset(&INFO, 0, sizeof(INFO)); \ - INFO.varname = #VAR; \ - INFO.size = sizeof(TYPE); \ - \ - /* Initialize padding mask */ \ - HDmemset(_pad_mask, 0, sizeof(_pad_mask)); \ - \ - /* Padding bits. Set a variable to 4.0, then flip each bit and see if \ - * the modified variable is equal ("==") to the original. Build a \ - * padding bitmask to indicate which bits in the type are padding (i.e. \ - * have no effect on the value and should be ignored by subsequent \ - * steps). This is necessary because padding bits can change arbitrarily \ - * and interfere with detection of the various properties below unless we \ - * know to ignore them. */ \ - _v1 = (TYPE)4.0L; \ - HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ - for(_i = 0; _i < (int)sizeof(TYPE); _i++) \ - for(_byte_mask = (unsigned char)1; _byte_mask; _byte_mask = (unsigned char) (_byte_mask << 1)) { \ - _buf1[_i] ^= _byte_mask; \ - HDmemcpy((void *)&_v2, (const void *)_buf1, sizeof(TYPE)); \ - H5_GCC_DIAG_OFF(float-equal) \ - if(_v1 != _v2) \ - _pad_mask[_i] |= _byte_mask; \ - H5_GCC_DIAG_ON(float-equal) \ - _buf1[_i] ^= _byte_mask; \ - } /* end for */ \ - \ - /* Byte Order */ \ - for(_i = 0, _v1 = (TYPE)0.0L, _v2 = (TYPE)1.0L; _i < (int)sizeof(TYPE); _i++) { \ - _v3 = _v1; \ - _v1 += _v2; \ - _v2 /= (TYPE)256.0L; \ - HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ - HDmemcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \ - _j = byte_cmp(sizeof(TYPE), _buf3, _buf1, _pad_mask); \ - if(_j >= 0) { \ - INFO.perm[_i] = _j; \ - _last = _i; \ - } \ - } \ - fix_order(sizeof(TYPE), _last, INFO.perm, (const char**)&_mesg); \ - \ - if(!HDstrcmp(_mesg, "VAX")) \ - INFO.is_vax = TRUE; \ - \ - /* Implicit mantissa bit */ \ - _v1 = (TYPE)0.5L; \ - _v2 = (TYPE)1.0L; \ - INFO.imp = imp_bit (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ - \ - /* Sign bit */ \ - _v1 = (TYPE)1.0L; \ - _v2 = (TYPE)-1.0L; \ - INFO.sign = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ - \ - /* Mantissa */ \ - INFO.mpos = 0; \ - \ - _v1 = (TYPE)1.0L; \ - _v2 = (TYPE)1.5L; \ - INFO.msize = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ - INFO.msize += 1 + (unsigned int) (INFO.imp ? 0 : 1) - INFO.mpos; \ - \ - /* Exponent */ \ - INFO.epos = INFO.mpos + INFO.msize; \ - \ - INFO.esize = INFO.sign - INFO.epos; \ - \ - _v1 = (TYPE)1.0L; \ - INFO.bias = find_bias (INFO.epos, INFO.esize, INFO.perm, &_v1); \ - precision (&(INFO)); \ - ALIGNMENT(TYPE, INFO); \ - if(!HDstrcmp(INFO.varname, "FLOAT") || !HDstrcmp(INFO.varname, "DOUBLE") || \ - !HDstrcmp(INFO.varname, "LDOUBLE")) { \ - COMP_ALIGNMENT(TYPE,INFO.comp_align); \ - } \ -} +#define DETECT_F(TYPE, VAR, INFO) \ + { \ + TYPE _v1, _v2, _v3; \ + unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \ + unsigned char _pad_mask[sizeof(TYPE)]; \ + unsigned char _byte_mask; \ + int _i, _j, _last = (-1); \ + const char * _mesg; \ + \ + HDmemset(&INFO, 0, sizeof(INFO)); \ + INFO.varname = #VAR; \ + INFO.size = sizeof(TYPE); \ + \ + /* Initialize padding mask */ \ + HDmemset(_pad_mask, 0, sizeof(_pad_mask)); \ + \ + /* Padding bits. Set a variable to 4.0, then flip each bit and see if \ + * the modified variable is equal ("==") to the original. Build a \ + * padding bitmask to indicate which bits in the type are padding (i.e. \ + * have no effect on the value and should be ignored by subsequent \ + * steps). This is necessary because padding bits can change arbitrarily \ + * and interfere with detection of the various properties below unless we \ + * know to ignore them. */ \ + _v1 = (TYPE)4.0L; \ + HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ + for (_i = 0; _i < (int)sizeof(TYPE); _i++) \ + for (_byte_mask = (unsigned char)1; _byte_mask; _byte_mask = (unsigned char)(_byte_mask << 1)) { \ + _buf1[_i] ^= _byte_mask; \ + HDmemcpy((void *)&_v2, (const void *)_buf1, sizeof(TYPE)); \ + H5_GCC_DIAG_OFF("float-equal") \ + if (_v1 != _v2) \ + _pad_mask[_i] |= _byte_mask; \ + H5_GCC_DIAG_ON("float-equal") \ + _buf1[_i] ^= _byte_mask; \ + } /* end for */ \ + \ + /* Byte Order */ \ + for (_i = 0, _v1 = (TYPE)0.0L, _v2 = (TYPE)1.0L; _i < (int)sizeof(TYPE); _i++) { \ + _v3 = _v1; \ + _v1 += _v2; \ + _v2 /= (TYPE)256.0L; \ + HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ + HDmemcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \ + _j = byte_cmp(sizeof(TYPE), _buf3, _buf1, _pad_mask); \ + if (_j >= 0) { \ + INFO.perm[_i] = _j; \ + _last = _i; \ + } \ + } \ + fix_order(sizeof(TYPE), _last, INFO.perm, (const char **)&_mesg); \ + \ + if (!HDstrcmp(_mesg, "VAX")) \ + INFO.is_vax = TRUE; \ + \ + /* Implicit mantissa bit */ \ + _v1 = (TYPE)0.5L; \ + _v2 = (TYPE)1.0L; \ + INFO.imp = imp_bit(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ + \ + /* Sign bit */ \ + _v1 = (TYPE)1.0L; \ + _v2 = (TYPE)-1.0L; \ + INFO.sign = bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ + \ + /* Mantissa */ \ + INFO.mpos = 0; \ + \ + _v1 = (TYPE)1.0L; \ + _v2 = (TYPE)1.5L; \ + INFO.msize = bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ + INFO.msize += 1 + (unsigned int)(INFO.imp ? 0 : 1) - INFO.mpos; \ + \ + /* Exponent */ \ + INFO.epos = INFO.mpos + INFO.msize; \ + \ + INFO.esize = INFO.sign - INFO.epos; \ + \ + _v1 = (TYPE)1.0L; \ + INFO.bias = find_bias(INFO.epos, INFO.esize, INFO.perm, &_v1); \ + precision(&(INFO)); \ + ALIGNMENT(TYPE, INFO); \ + if (!HDstrcmp(INFO.varname, "FLOAT") || !HDstrcmp(INFO.varname, "DOUBLE") || \ + !HDstrcmp(INFO.varname, "LDOUBLE")) { \ + COMP_ALIGNMENT(TYPE, INFO.comp_align); \ + } \ + } - /*------------------------------------------------------------------------- * Function: DETECT_M * @@ -389,72 +371,80 @@ precision (detected_t *d) * Return: void *------------------------------------------------------------------------- */ -#define DETECT_M(TYPE,VAR,INFO) { \ - INFO.name = #VAR; \ - COMP_ALIGNMENT(TYPE, INFO.comp_align); \ -} +#define DETECT_M(TYPE, VAR, INFO) \ + { \ + INFO.name = #VAR; \ + COMP_ALIGNMENT(TYPE, INFO.comp_align); \ + } /* Detect alignment for C structure */ -#define COMP_ALIGNMENT(TYPE,COMP_ALIGN) { \ - struct { \ - char c; \ - TYPE x; \ - } s; \ - \ - COMP_ALIGN = (unsigned int)((char*)(&(s.x)) - (char*)(&s)); \ -} +#define COMP_ALIGNMENT(TYPE, COMP_ALIGN) \ + { \ + struct { \ + char c; \ + TYPE x; \ + } s; \ + \ + COMP_ALIGN = (unsigned int)((char *)(&(s.x)) - (char *)(&s)); \ + } #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) -#define ALIGNMENT(TYPE,INFO) { \ - char *volatile _buf = NULL; \ - TYPE _val = 1, _val2; \ - volatile size_t _ano = 0; \ - void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \ - void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler);\ - void (*_handler3)(int) = HDsignal(SIGILL, sigill_handler); \ - \ - _buf = (char*)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ - if(H5SETJMP(jbuf_g)) _ano++; \ - if(_ano < NELMTS(align_g)) { \ - *((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \ - _val2 = *((TYPE*)(_buf+align_g[_ano])); /*possible SIGBUS or SEGSEGV*/\ - /* Cray Check: This section helps detect alignment on Cray's */ \ - /* vector machines (like the SV1) which mask off */ \ - /* pointer values when pointing to non-word aligned */ \ - /* locations with pointers that are supposed to be */ \ - /* word aligned. -QAK */ \ - HDmemset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \ - /*How to handle VAX types?*/ \ - if(INFO.perm[0]) /* Big-Endian */ \ - HDmemcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \ - else /* Little-Endian */ \ - HDmemcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \ - _val2 = *((TYPE*)(_buf+align_g[_ano])); \ - H5_GCC_DIAG_OFF(float-equal) \ - if(_val!=_val2) \ - H5LONGJMP(jbuf_g, 1); \ - H5_GCC_DIAG_ON(float-equal) \ - /* End Cray Check */ \ - (INFO.align)=align_g[_ano]; \ - } else { \ - (INFO.align)=0; \ - fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \ - } \ - HDfree(_buf); \ - HDsignal(SIGBUS, _handler); /*restore original handler*/ \ - HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \ - HDsignal(SIGILL, _handler3); /*restore original handler*/ \ -} +#define ALIGNMENT(TYPE, INFO) \ + { \ + char *volatile _buf = NULL; \ + TYPE _val = 1, _val2; \ + volatile size_t _ano = 0; \ + void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \ + void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler); \ + void (*_handler3)(int) = HDsignal(SIGILL, sigill_handler); \ + \ + _buf = (char *)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ + if (H5SETJMP(jbuf_g)) \ + _ano++; \ + if (_ano < NELMTS(align_g)) { \ + *((TYPE *)(_buf + align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \ + _val2 = *((TYPE *)(_buf + align_g[_ano])); /*possible SIGBUS or SEGSEGV*/ \ + /* Cray Check: This section helps detect alignment on Cray's */ \ + /* vector machines (like the SV1) which mask off */ \ + /* pointer values when pointing to non-word aligned */ \ + /* locations with pointers that are supposed to be */ \ + /* word aligned. -QAK */ \ + HDmemset(_buf, 0xff, sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ + /*How to handle VAX types?*/ \ + if (INFO.perm[0]) /* Big-Endian */ \ + HDmemcpy(_buf + align_g[_ano] + (INFO.size - ((INFO.offset + INFO.precision) / 8)), \ + ((char *)&_val) + (INFO.size - ((INFO.offset + INFO.precision) / 8)), \ + (size_t)(INFO.precision / 8)); \ + else /* Little-Endian */ \ + HDmemcpy(_buf + align_g[_ano] + (INFO.offset / 8), ((char *)&_val) + (INFO.offset / 8), \ + (size_t)(INFO.precision / 8)); \ + _val2 = *((TYPE *)(_buf + align_g[_ano])); \ + H5_GCC_DIAG_OFF("float-equal") \ + if (_val != _val2) \ + H5LONGJMP(jbuf_g, 1); \ + H5_GCC_DIAG_ON("float-equal") \ + /* End Cray Check */ \ + (INFO.align) = align_g[_ano]; \ + } \ + else { \ + (INFO.align) = 0; \ + fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \ + } \ + HDfree(_buf); \ + HDsignal(SIGBUS, _handler); /*restore original handler*/ \ + HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \ + HDsignal(SIGILL, _handler3); /*restore original handler*/ \ + } #else -#define ALIGNMENT(TYPE,INFO) { \ - align_status_g |= STA_NoALIGNMENT; \ - (INFO.align)=0; \ -} +#define ALIGNMENT(TYPE, INFO) \ + { \ + align_status_g |= STA_NoALIGNMENT; \ + (INFO.align) = 0; \ + } #endif - #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) - + /*------------------------------------------------------------------------- * Function: sigsegv_handler * @@ -485,9 +475,8 @@ sigsegv_handler(int H5_ATTR_UNUSED signo) } #endif - #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) - + /*------------------------------------------------------------------------- * Function: sigbus_handler * @@ -518,9 +507,8 @@ sigbus_handler(int H5_ATTR_UNUSED signo) } #endif - #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) - + /*------------------------------------------------------------------------- * Function: sigill_handler * @@ -551,7 +539,6 @@ sigill_handler(int H5_ATTR_UNUSED signo) } #endif - /*------------------------------------------------------------------------- * Function: print_results * @@ -563,8 +550,8 @@ sigill_handler(int H5_ATTR_UNUSED signo) static void print_results(int nd, detected_t *d, int na, malign_t *misc_align) { - int byte_order=0; /*byte order of data types*/ - int i, j; + int byte_order = 0; /*byte order of data types*/ + int i, j; /* Include files */ fprintf(rawoutstream, "\ @@ -626,7 +613,6 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) /*******************/\n\ \n"); - /* The interface initialization function */ fprintf(rawoutstream, "\n\ \n\ @@ -652,43 +638,43 @@ H5T__init_native(void)\n\ \n\ FUNC_ENTER_PACKAGE\n"); - for(i = 0; i < nd; i++) { + for (i = 0; i < nd; i++) { /* The native endianness of this machine */ /* The INFO.perm now contains `-1' for bytes that aren't used and * are always zero. This happens on the Cray for `short' where * sizeof(short) is 8, but only the low-order 4 bytes are ever used. */ - if(d[i].is_vax) /* the type is a VAX floating number */ - byte_order=-1; + if (d[i].is_vax) /* the type is a VAX floating number */ + byte_order = -1; else { - for(j=0; j<32; j++) { + for (j = 0; j < 32; j++) { /*Find the 1st containing valid data*/ - if(d[i].perm[j]>-1) { - byte_order=d[i].perm[j]; + if (d[i].perm[j] > -1) { + byte_order = d[i].perm[j]; break; } } } - /* Print a comment to describe this section of definitions. */ - fprintf(rawoutstream, "\n /*\n"); - iprint(d+i); - fprintf(rawoutstream, " */\n"); + /* Print a comment to describe this section of definitions. */ + fprintf(rawoutstream, "\n /*\n"); + iprint(d + i); + fprintf(rawoutstream, " */\n"); - /* The part common to fixed and floating types */ - fprintf(rawoutstream, "\ + /* The part common to fixed and floating types */ + fprintf(rawoutstream, "\ if(NULL == (dt = H5T__alloc()))\n\ HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, \"datatype allocation failed\")\n\ dt->shared->state = H5T_STATE_IMMUTABLE;\n\ dt->shared->type = H5T_%s;\n\ dt->shared->size = %d;\n", - d[i].msize ? "FLOAT" : "INTEGER",/*class */ - d[i].size); /*size */ + d[i].msize ? "FLOAT" : "INTEGER", /*class */ + d[i].size); /*size */ - if(byte_order==-1) + if (byte_order == -1) fprintf(rawoutstream, "\ dt->shared->u.atomic.order = H5T_ORDER_VAX;\n"); - else if(byte_order==0) + else if (byte_order == 0) fprintf(rawoutstream, "\ dt->shared->u.atomic.order = H5T_ORDER_LE;\n"); else @@ -700,19 +686,19 @@ H5T__init_native(void)\n\ dt->shared->u.atomic.prec = %d;\n\ dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\ dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;\n", - d[i].offset, /*offset */ - d[i].precision); /*precision */ - /*HDassert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */ + d[i].offset, /*offset */ + d[i].precision); /*precision */ + /*HDassert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */ - if(0 == d[i].msize) { - /* The part unique to fixed point types */ - fprintf(rawoutstream, "\ + if (0 == d[i].msize) { + /* The part unique to fixed point types */ + fprintf(rawoutstream, "\ dt->shared->u.atomic.u.i.sign = H5T_SGN_%s;\n", - d[i].sign ? "2" : "NONE"); - } - else { - /* The part unique to floating point types */ - fprintf(rawoutstream, "\ + d[i].sign ? "2" : "NONE"); + } + else { + /* The part unique to floating point types */ + fprintf(rawoutstream, "\ dt->shared->u.atomic.u.f.sign = %d;\n\ dt->shared->u.atomic.u.f.epos = %d;\n\ dt->shared->u.atomic.u.f.esize = %d;\n\ @@ -721,49 +707,52 @@ H5T__init_native(void)\n\ dt->shared->u.atomic.u.f.msize = %d;\n\ dt->shared->u.atomic.u.f.norm = H5T_NORM_%s;\n\ dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n", - d[i].sign, /*sign location */ - d[i].epos, /*exponent loc */ - d[i].esize, /*exponent size */ - (unsigned long)(d[i].bias), /*exponent bias */ - d[i].mpos, /*mantissa loc */ - d[i].msize, /*mantissa size */ - d[i].imp ? "IMPLIED" : "NONE"); /*normalization */ - } + d[i].sign, /*sign location */ + d[i].epos, /*exponent loc */ + d[i].esize, /*exponent size */ + (unsigned long)(d[i].bias), /*exponent bias */ + d[i].mpos, /*mantissa loc */ + d[i].msize, /*mantissa size */ + d[i].imp ? "IMPLIED" : "NONE"); /*normalization */ + } - /* Atomize the type */ - fprintf(rawoutstream, "\ + /* Register the type */ + fprintf(rawoutstream, "\ if((H5T_NATIVE_%s_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)\n\ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \"can't register ID for built-in datatype\")\n", - d[i].varname); - fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", - d[i].varname, (unsigned long)(d[i].align)); + d[i].varname); + fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", d[i].varname, + (unsigned long)(d[i].align)); /* Variables for alignment of compound datatype */ - if(!HDstrcmp(d[i].varname, "SCHAR") || !HDstrcmp(d[i].varname, "SHORT") || - !HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") || + if (!HDstrcmp(d[i].varname, "SCHAR") || !HDstrcmp(d[i].varname, "SHORT") || + !HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") || !HDstrcmp(d[i].varname, "LLONG") || !HDstrcmp(d[i].varname, "FLOAT") || !HDstrcmp(d[i].varname, "DOUBLE") || !HDstrcmp(d[i].varname, "LDOUBLE")) { - fprintf(rawoutstream, " H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", - d[i].varname, (unsigned long)(d[i].comp_align)); + fprintf(rawoutstream, " H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", d[i].varname, + (unsigned long)(d[i].comp_align)); } } /* Consider VAX a little-endian machine */ - if(byte_order==0 || byte_order==-1) { + if (byte_order == 0 || byte_order == -1) { fprintf(rawoutstream, "\n\ /* Set the native order for this machine */\n\ - H5T_native_order_g = H5T_ORDER_%s;\n", "LE"); + H5T_native_order_g = H5T_ORDER_%s;\n", + "LE"); } else { fprintf(rawoutstream, "\n\ /* Set the native order for this machine */\n\ - H5T_native_order_g = H5T_ORDER_%s;\n", "BE"); + H5T_native_order_g = H5T_ORDER_%s;\n", + "BE"); } /* Structure alignment for pointers, vlen and reference types */ fprintf(rawoutstream, "\n /* Structure alignment for pointers, vlen and reference types */\n"); - for(j=0; jsize - 1) / 4; ; --pass) { + for (pass = (d->size - 1) / 4;; --pass) { unsigned int i, k; /* * Print the byte ordering above the bit fields. */ fprintf(rawoutstream, " * "); - for(i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) { + for (i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) { fprintf(rawoutstream, "%4d", d->perm[i]); - if(i > pass * 4) + if (i > pass * 4) HDfputs(" ", stdout); - if(!i) + if (!i) break; } @@ -863,24 +851,24 @@ iprint(detected_t *d) * Print the bit fields */ fprintf(rawoutstream, "\n * "); - for(i = MIN(pass * 4 + 3, d->size - 1), k = MIN(pass * 32 + 31, - 8 * d->size - 1); i >= pass * 4; --i) { + for (i = MIN(pass * 4 + 3, d->size - 1), k = MIN(pass * 32 + 31, 8 * d->size - 1); i >= pass * 4; + --i) { unsigned int j; - for(j = 8; j > 0; --j) { - if(k == d->sign && d->msize) { + for (j = 8; j > 0; --j) { + if (k == d->sign && d->msize) { HDfputc('S', rawoutstream); } - else if(k >= d->epos && k < d->epos + d->esize) { + else if (k >= d->epos && k < d->epos + d->esize) { HDfputc('E', rawoutstream); } - else if(k >= d->mpos && k < d->mpos + d->msize) { + else if (k >= d->mpos && k < d->mpos + d->msize) { HDfputc('M', rawoutstream); } - else if(d->msize) { + else if (d->msize) { HDfputc('?', rawoutstream); /*unknown floating point bit */ } - else if(d->sign) { + else if (d->sign) { HDfputc('I', rawoutstream); } else { @@ -888,39 +876,37 @@ iprint(detected_t *d) } --k; } - if(i > pass * 4) + if (i > pass * 4) HDfputc(' ', rawoutstream); - if(!i) + if (!i) break; } HDfputc('\n', rawoutstream); - if(!pass) + if (!pass) break; } /* * Is there an implicit bit in the mantissa. */ - if(d->msize) { + if (d->msize) { fprintf(rawoutstream, " * Implicit bit? %s\n", d->imp ? "yes" : "no"); } /* * Alignment */ - if(0 == d->align) { + if (0 == d->align) { fprintf(rawoutstream, " * Alignment: NOT CALCULATED\n"); } - else if(1 == d->align) { + else if (1 == d->align) { fprintf(rawoutstream, " * Alignment: none\n"); } else { - fprintf(rawoutstream, " * Alignment: %lu\n", (unsigned long) (d->align)); + fprintf(rawoutstream, " * Alignment: %lu\n", (unsigned long)(d->align)); } - } - /*------------------------------------------------------------------------- * Function: byte_cmp * @@ -936,18 +922,17 @@ iprint(detected_t *d) static int byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask) { - int i; - const unsigned char *a = (const unsigned char *) _a; - const unsigned char *b = (const unsigned char *) _b; + int i; + const unsigned char *a = (const unsigned char *)_a; + const unsigned char *b = (const unsigned char *)_b; - for(i = 0; i < n; i++) - if((a[i] & pad_mask[i]) != (b[i] & pad_mask[i])) + for (i = 0; i < n; i++) + if ((a[i] & pad_mask[i]) != (b[i] & pad_mask[i])) return i; return -1; } - /*------------------------------------------------------------------------- * Function: bit_cmp * @@ -962,22 +947,22 @@ byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask) *------------------------------------------------------------------------- */ static unsigned int -bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, - const unsigned char *pad_mask) +bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, const unsigned char *pad_mask) { - unsigned int i; - unsigned char *a = (unsigned char *) _a; - unsigned char *b = (unsigned char *) _b; - unsigned char aa, bb; - - for(i = 0; i < nbytes; i++) { - HDassert(perm[i] < (int) nbytes); - if((aa = (unsigned char) (a[perm[i]] & pad_mask[perm[i]])) - != (bb = (unsigned char) (b[perm[i]] & pad_mask[perm[i]]))) { + unsigned int i; + unsigned char *a = (unsigned char *)_a; + unsigned char *b = (unsigned char *)_b; + unsigned char aa, bb; + + for (i = 0; i < nbytes; i++) { + HDassert(perm[i] < (int)nbytes); + if ((aa = (unsigned char)(a[perm[i]] & pad_mask[perm[i]])) != + (bb = (unsigned char)(b[perm[i]] & pad_mask[perm[i]]))) { unsigned int j; - for(j = 0; j < 8; j++, aa >>= 1, bb >>= 1) { - if((aa & 1) != (bb & 1)) return i * 8 + j; + for (j = 0; j < 8; j++, aa >>= 1, bb >>= 1) { + if ((aa & 1) != (bb & 1)) + return i * 8 + j; } fprintf(stderr, "INTERNAL ERROR"); HDabort(); @@ -988,7 +973,6 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, return 0; } - /*------------------------------------------------------------------------- * Function: fix_order * @@ -1006,32 +990,29 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, static void fix_order(int n, int last, int *perm, const char **mesg) { - int i; + int i; - if(last > 1) { + if (last > 1) { /* * We have at least three points to consider. */ - if(perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) { + if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) { /* * Little endian. */ - if(mesg) + if (mesg) *mesg = "Little-endian"; - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) perm[i] = i; - } - else if(perm[last] > perm[last - 1] - && perm[last - 1] > perm[last - 2]) { + else if (perm[last] > perm[last - 1] && perm[last - 1] > perm[last - 2]) { /* * Big endian. */ - if(mesg) + if (mesg) *mesg = "Big-endian"; - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) perm[i] = (n - 1) - i; - } else { /* @@ -1041,22 +1022,20 @@ fix_order(int n, int last, int *perm, const char **mesg) * case - JKM & QAK) */ HDassert(0 == n % 2); - if(mesg) + if (mesg) *mesg = "VAX"; - for(i = 0; i < n; i += 2) { - perm[i] = (n - 2) - i; + for (i = 0; i < n; i += 2) { + perm[i] = (n - 2) - i; perm[i + 1] = (n - 1) - i; } } } else { - fprintf(stderr, - "Failed to detect byte order of %d-byte floating point.\n", n); + fprintf(stderr, "Failed to detect byte order of %d-byte floating point.\n", n); HDexit(1); } } - /*------------------------------------------------------------------------- * Function: imp_bit * @@ -1087,10 +1066,10 @@ fix_order(int n, int last, int *perm, const char **mesg) static unsigned int imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_mask) { - unsigned char *a = (unsigned char *) _a; - unsigned char *b = (unsigned char *) _b; - unsigned int changed, major, minor; - unsigned int msmb; /* most significant mantissa bit */ + unsigned char *a = (unsigned char *)_a; + unsigned char *b = (unsigned char *)_b; + unsigned int changed, major, minor; + unsigned int msmb; /* most significant mantissa bit */ /* * Look for the least significant bit that has changed between @@ -1103,14 +1082,13 @@ imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_ * be the most significant bit of the mantissa. If it is non-zero * then the format does not remove the leading `1' of the mantissa. */ - msmb = changed - 1; + msmb = changed - 1; major = msmb / 8; minor = msmb % 8; return (a[perm[major]] >> minor) & 0x01 ? 0 : 1; } - /*------------------------------------------------------------------------- * Function: find_bias * @@ -1124,14 +1102,14 @@ imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_ H5_ATTR_PURE static unsigned int find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a) { - unsigned char *a = (unsigned char *) _a; - unsigned char mask; - unsigned int b, shift = 0, nbits, bias = 0; + unsigned char *a = (unsigned char *)_a; + unsigned char mask; + unsigned int b, shift = 0, nbits, bias = 0; - while(esize > 0) { + while (esize > 0) { nbits = MIN(esize, (8 - epos % 8)); - mask = (unsigned char) ((1 << nbits) - 1); - b = (unsigned int) (a[perm[epos / 8]] >> (epos % 8)) & mask; + mask = (unsigned char)((1 << nbits) - 1); + b = (unsigned int)(a[perm[epos / 8]] >> (epos % 8)) & mask; bias |= b << shift; shift += nbits; @@ -1141,7 +1119,6 @@ find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a) return bias; } - /*------------------------------------------------------------------------- * Function: print_header * @@ -1154,22 +1131,20 @@ static void print_header(void) { - time_t now = HDtime(NULL); - struct tm *tm = HDlocaltime(&now); - char real_name[30]; - char host_name[256]; - int i; - const char *s; + time_t now = HDtime(NULL); + struct tm * tm = HDlocaltime(&now); + char real_name[30]; + char host_name[256]; + int i; + const char *s; #ifdef H5_HAVE_GETPWUID struct passwd *pwd = NULL; #else - int pwd = 1; + int pwd = 1; #endif - static const char *month_name[] = - { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - static const char *purpose = "\ + static const char *month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + static const char *purpose = "\ This machine-generated source code contains\n\ information about the various integer and\n\ floating point numeric formats found on this\n\ @@ -1213,10 +1188,10 @@ bit.\n"; #ifdef H5_HAVE_GETPWUID { size_t n; - char *comma; - if((pwd = HDgetpwuid(HDgetuid()))) { - if((comma = HDstrchr(pwd->pw_gecos, ','))) { - n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos)); + char * comma; + if ((pwd = HDgetpwuid(HDgetuid()))) { + if ((comma = HDstrchr(pwd->pw_gecos, ','))) { + n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); HDstrncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; } @@ -1236,7 +1211,7 @@ bit.\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if(HDgethostname(host_name, sizeof(host_name)) < 0) { + if (HDgethostname(host_name, sizeof(host_name)) < 0) { host_name[0] = '\0'; } #else @@ -1247,27 +1222,28 @@ bit.\n"; * The file header: warning, copyright notice, build information. */ fprintf(rawoutstream, "/* Generated automatically by H5detect -- do not edit */\n\n\n"); - HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ + HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ - fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", - month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); - if(pwd || real_name[0] || host_name[0]) { + fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, + 1900 + tm->tm_year); + if (pwd || real_name[0] || host_name[0]) { fprintf(rawoutstream, " *\t\t\t"); - if(real_name[0]) + if (real_name[0]) fprintf(rawoutstream, "%s <", real_name); #ifdef H5_HAVE_GETPWUID - if(pwd) HDfputs(pwd->pw_name, rawoutstream); + if (pwd) + HDfputs(pwd->pw_name, rawoutstream); #endif - if(host_name[0]) + if (host_name[0]) fprintf(rawoutstream, "@%s", host_name); - if(real_name[0]) + if (real_name[0]) fprintf(rawoutstream, ">"); HDfputc('\n', rawoutstream); } fprintf(rawoutstream, " *\n * Purpose:\t\t"); - for(s = purpose; *s; s++) { + for (s = purpose; *s; s++) { HDfputc(*s, rawoutstream); - if('\n' == *s && s[1]) + if ('\n' == *s && s[1]) fprintf(rawoutstream, " *\t\t\t"); } @@ -1276,13 +1252,11 @@ bit.\n"; fprintf(rawoutstream, " *\tIt was generated by code in `H5detect.c'.\n"); fprintf(rawoutstream, " *\n *"); - for(i = 0; i < 73; i++) + for (i = 0; i < 73; i++) HDfputc('-', rawoutstream); fprintf(rawoutstream, "\n */\n\n"); - } - /*------------------------------------------------------------------------- * Function: detect_C89_integers * @@ -1294,17 +1268,24 @@ bit.\n"; static void HDF_NO_UBSAN detect_C89_integers(void) { - DETECT_BYTE(signed char, SCHAR, d_g[nd_g]); nd_g++; - DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]); nd_g++; - DETECT_I(short, SHORT, d_g[nd_g]); nd_g++; - DETECT_I(unsigned short, USHORT, d_g[nd_g]); nd_g++; - DETECT_I(int, INT, d_g[nd_g]); nd_g++; - DETECT_I(unsigned int, UINT, d_g[nd_g]); nd_g++; - DETECT_I(long, LONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long, ULONG, d_g[nd_g]); nd_g++; + DETECT_BYTE(signed char, SCHAR, d_g[nd_g]); + nd_g++; + DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]); + nd_g++; + DETECT_I(short, SHORT, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned short, USHORT, d_g[nd_g]); + nd_g++; + DETECT_I(int, INT, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned int, UINT, d_g[nd_g]); + nd_g++; + DETECT_I(long, LONG, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned long, ULONG, d_g[nd_g]); + nd_g++; } - /*------------------------------------------------------------------------- * Function: detect_C89_floats * @@ -1316,11 +1297,12 @@ detect_C89_integers(void) static void HDF_NO_UBSAN detect_C89_floats(void) { - DETECT_F(float, FLOAT, d_g[nd_g]); nd_g++; - DETECT_F(double, DOUBLE, d_g[nd_g]); nd_g++; + DETECT_F(float, FLOAT, d_g[nd_g]); + nd_g++; + DETECT_F(double, DOUBLE, d_g[nd_g]); + nd_g++; } - /*------------------------------------------------------------------------- * Function: detect_C99_integers8 * @@ -1332,51 +1314,62 @@ detect_C89_floats(void) static void HDF_NO_UBSAN detect_C99_integers8(void) { -#if H5_SIZEOF_INT8_T>0 - #if H5_SIZEOF_INT8_T==1 - DETECT_BYTE(int8_t, INT8, d_g[nd_g]); nd_g++; - #else - DETECT_I(int8_t, INT8, d_g[nd_g]); nd_g++; - #endif +#if H5_SIZEOF_INT8_T > 0 +#if H5_SIZEOF_INT8_T == 1 + DETECT_BYTE(int8_t, INT8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(int8_t, INT8, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT8_T>0 - #if H5_SIZEOF_UINT8_T==1 - DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]); nd_g++; - #else - DETECT_I(uint8_t, UINT8, d_g[nd_g]); nd_g++; - #endif #endif -#if H5_SIZEOF_INT_LEAST8_T>0 - #if H5_SIZEOF_INT_LEAST8_T==1 - DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; - #else - DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; - #endif +#if H5_SIZEOF_UINT8_T > 0 +#if H5_SIZEOF_UINT8_T == 1 + DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(uint8_t, UINT8, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_LEAST8_T>0 - #if H5_SIZEOF_UINT_LEAST8_T==1 - DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; - #else - DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; - #endif #endif -#if H5_SIZEOF_INT_FAST8_T>0 - #if H5_SIZEOF_INT_FAST8_T==1 - DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++; - #else - DETECT_I(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++; - #endif +#if H5_SIZEOF_INT_LEAST8_T > 0 +#if H5_SIZEOF_INT_LEAST8_T == 1 + DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); + nd_g++; +#endif +#endif +#if H5_SIZEOF_UINT_LEAST8_T > 0 +#if H5_SIZEOF_UINT_LEAST8_T == 1 + DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); + nd_g++; +#endif +#endif +#if H5_SIZEOF_INT_FAST8_T > 0 +#if H5_SIZEOF_INT_FAST8_T == 1 + DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(int_fast8_t, INT_FAST8, d_g[nd_g]); + nd_g++; +#endif +#endif +#if H5_SIZEOF_UINT_FAST8_T > 0 +#if H5_SIZEOF_UINT_FAST8_T == 1 + DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_FAST8_T>0 - #if H5_SIZEOF_UINT_FAST8_T==1 - DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; - #else - DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; - #endif #endif } - /*------------------------------------------------------------------------- * Function: detect_C99_integers16 * @@ -1388,27 +1381,32 @@ detect_C99_integers8(void) static void HDF_NO_UBSAN detect_C99_integers16(void) { -#if H5_SIZEOF_INT16_T>0 - DETECT_I(int16_t, INT16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT16_T > 0 + DETECT_I(int16_t, INT16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT16_T>0 - DETECT_I(uint16_t, UINT16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT16_T > 0 + DETECT_I(uint16_t, UINT16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_LEAST16_T>0 - DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_LEAST16_T > 0 + DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_LEAST16_T>0 - DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_LEAST16_T > 0 + DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_FAST16_T>0 - DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_FAST16_T > 0 + DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_FAST16_T>0 - DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_FAST16_T > 0 + DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); + nd_g++; #endif } - /*------------------------------------------------------------------------- * Function: detect_C99_integers32 * @@ -1420,27 +1418,32 @@ detect_C99_integers16(void) static void HDF_NO_UBSAN detect_C99_integers32(void) { -#if H5_SIZEOF_INT32_T>0 - DETECT_I(int32_t, INT32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT32_T > 0 + DETECT_I(int32_t, INT32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT32_T>0 - DETECT_I(uint32_t, UINT32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT32_T > 0 + DETECT_I(uint32_t, UINT32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_LEAST32_T>0 - DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_LEAST32_T > 0 + DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_LEAST32_T>0 - DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_LEAST32_T > 0 + DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_FAST32_T>0 - DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_FAST32_T > 0 + DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_FAST32_T>0 - DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_FAST32_T > 0 + DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); + nd_g++; #endif } - /*------------------------------------------------------------------------- * Function: detect_C99_integers64 * @@ -1453,40 +1456,49 @@ detect_C99_integers32(void) static void HDF_NO_UBSAN detect_C99_integers64(void) { -#if H5_SIZEOF_INT64_T>0 - DETECT_I(int64_t, INT64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT64_T > 0 + DETECT_I(int64_t, INT64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT64_T>0 - DETECT_I(uint64_t, UINT64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT64_T > 0 + DETECT_I(uint64_t, UINT64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_LEAST64_T>0 - DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_LEAST64_T > 0 + DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_LEAST64_T>0 - DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_LEAST64_T > 0 + DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_FAST64_T>0 - DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_FAST64_T > 0 + DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_FAST64_T>0 - DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_FAST64_T > 0 + DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_LONG_LONG>0 - DETECT_I(long long, LLONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_LONG_LONG > 0 + DETECT_I(long long, LLONG, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); + nd_g++; #else /* * This architecture doesn't support an integer type larger than `long' * so we'll just make H5T_NATIVE_LLONG the same as H5T_NATIVE_LONG since * `long long' is probably equivalent to `long' here anyway. */ - DETECT_I(long, LLONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long, ULLONG, d_g[nd_g]); nd_g++; + DETECT_I(long, LLONG, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned long, ULLONG, d_g[nd_g]); + nd_g++; #endif } - /*------------------------------------------------------------------------- * Function: detect_C99_integers * @@ -1506,7 +1518,6 @@ detect_C99_integers(void) detect_C99_integers64(); } - /*------------------------------------------------------------------------- * Function: detect_C99_floats * @@ -1525,13 +1536,14 @@ detect_C99_floats(void) * some systems and `long double' is probably the same as `double' here * anyway. */ - DETECT_F(double, LDOUBLE, d_g[nd_g]); nd_g++; -#elif H5_SIZEOF_LONG_DOUBLE !=0 - DETECT_F(long double, LDOUBLE, d_g[nd_g]); nd_g++; + DETECT_F(double, LDOUBLE, d_g[nd_g]); + nd_g++; +#elif H5_SIZEOF_LONG_DOUBLE != 0 + DETECT_F(long double, LDOUBLE, d_g[nd_g]); + nd_g++; #endif } - /*------------------------------------------------------------------------- * Function: detect_alignments * @@ -1544,21 +1556,26 @@ static void HDF_NO_UBSAN detect_alignments(void) { /* Detect structure alignment for pointers, vlen and reference types */ - DETECT_M(void *, POINTER, m_g[na_g]); na_g++; - DETECT_M(hvl_t, HVL, m_g[na_g]); na_g++; - DETECT_M(hobj_ref_t, HOBJREF, m_g[na_g]); na_g++; - DETECT_M(hdset_reg_ref_t, HDSETREGREF, m_g[na_g]); na_g++; - DETECT_M(H5R_ref_t, REF, m_g[na_g]); na_g++; + DETECT_M(void *, POINTER, m_g[na_g]); + na_g++; + DETECT_M(hvl_t, HVL, m_g[na_g]); + na_g++; + DETECT_M(hobj_ref_t, HOBJREF, m_g[na_g]); + na_g++; + DETECT_M(hdset_reg_ref_t, HDSETREGREF, m_g[na_g]); + na_g++; + DETECT_M(H5R_ref_t, REF, m_g[na_g]); + na_g++; } - #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) /* Verify the signal handler for signal signum works correctly multiple times. * One possible cause of failure is that the signal handling is blocked or * changed to SIG_DFL after H5LONGJMP. * Return 0 for success, -1 for failure. */ -static int verify_signal_handlers(int signum, void (*handler)(int)) +static int +verify_signal_handlers(int signum, void (*handler)(int)) { #if defined(__has_feature) /* Clang */ #if __has_feature(address_sanitizer) || __has_feature(thread_sanitizer) @@ -1568,15 +1585,15 @@ static int verify_signal_handlers(int signum, void (*handler)(int)) #elif defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__) /* GCC */ return 0; #endif - void (*save_handler)(int) = HDsignal(signum, handler); + void (*save_handler)(int) = HDsignal(signum, handler); volatile int i, val; - int ntries = 5; - volatile int nfailures = 0; + int ntries = 5; + volatile int nfailures = 0; volatile int nsuccesses = 0; - for(i=0;i0 || nsuccesses != ntries) { - fprintf(stderr, "verify_signal_handlers for signal %d did %d tries. " - "Found %d failures and %d successes\n", - signum, ntries, nfailures, nsuccesses); + if (nfailures > 0 || nsuccesses != ntries) { + fprintf(stderr, + "verify_signal_handlers for signal %d did %d tries. " + "Found %d failures and %d successes\n", + signum, ntries, nfailures, nsuccesses); return -1; } else { @@ -1609,7 +1627,6 @@ static int verify_signal_handlers(int signum, void (*handler)(int)) } #endif - /*------------------------------------------------------------------------- * Function: main * @@ -1617,31 +1634,25 @@ static int verify_signal_handlers(int signum, void (*handler)(int)) * * Return: Success: EXIT_SUCCESS * - * Modifications: - * Some compilers, e.g., Intel C v7.0, took a long time to compile - * with optimization when a module routine contains many code lines. - * Divide up all those types detections macros into subroutines, both - * to avoid the compiler optimization error and cleaner codes. - * *------------------------------------------------------------------------- */ int HDF_NO_UBSAN main(int argc, char *argv[]) { - char *fname = NULL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawoutstream is changed only when succeeded */ + char *fname = NULL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawoutstream is changed only when succeeded */ - if(argc > 1) + if (argc > 1) fname = argv[1]; /* First check if filename is string "NULL" */ - if(fname != NULL) { + if (fname != NULL) { /* binary output */ - if((f = HDfopen(fname, "w")) != NULL) + if ((f = HDfopen(fname, "w")) != NULL) rawoutstream = f; } - if(!rawoutstream) + if (!rawoutstream) rawoutstream = stdout; #if defined(H5_HAVE_SETSYSINFO) && defined(SSI_NVPAIRS) @@ -1650,29 +1661,25 @@ main(int argc, char *argv[]) * Make sure unaligned access generates SIGBUS and doesn't print warning * messages so that we can detect alignment constraints on the DEC Alpha. */ - int nvpairs[2]; + int nvpairs[2]; nvpairs[0] = SSIN_UACPROC; nvpairs[1] = UAC_NOPRINT | UAC_SIGBUS; - if(setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0)<0) { - fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", - HDstrerror(errno)); + if (setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0) < 0) { + fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", HDstrerror(errno)); } #endif #endif #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) /* verify the SIGBUS and SIGSEGV handlers work properly */ - if(verify_signal_handlers(SIGBUS, sigbus_handler) != 0) { - fprintf(stderr, "Signal handler %s for signal %d failed\n", - "sigbus_handler", SIGBUS); + if (verify_signal_handlers(SIGBUS, sigbus_handler) != 0) { + fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigbus_handler", SIGBUS); } - if(verify_signal_handlers(SIGSEGV, sigsegv_handler) != 0) { - fprintf(stderr, "Signal handler %s for signal %d failed\n", - "sigsegv_handler", SIGSEGV); + if (verify_signal_handlers(SIGSEGV, sigsegv_handler) != 0) { + fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigsegv_handler", SIGSEGV); } - if(verify_signal_handlers(SIGILL, sigill_handler) != 0) { - fprintf(stderr, "Signal handler %s for signal %d failed\n", - "sigill_handler", SIGILL); + if (verify_signal_handlers(SIGILL, sigill_handler) != 0) { + fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigill_handler", SIGILL); } #else align_status_g |= STA_NoHandlerVerify; @@ -1695,10 +1702,10 @@ main(int argc, char *argv[]) /* Detect structure alignment */ detect_alignments(); - print_results (nd_g, d_g, na_g, m_g); + print_results(nd_g, d_g, na_g, m_g); - if(rawoutstream && rawoutstream != stdout) { - if(HDfclose(rawoutstream)) + if (rawoutstream && rawoutstream != stdout) { + if (HDfclose(rawoutstream)) fprintf(stderr, "closing rawoutstream"); else rawoutstream = NULL; @@ -1707,4 +1714,4 @@ main(int argc, char *argv[]) return EXIT_SUCCESS; } -H5_GCC_DIAG_ON(cast-align) +H5_GCC_DIAG_ON("cast-align") diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c index 72041ed..617d1f5 100644 --- a/src/H5make_libsettings.c +++ b/src/H5make_libsettings.c @@ -42,7 +42,6 @@ static const char *FileHeader = "\n\ FILE *rawoutstream = NULL; - /*------------------------------------------------------------------------- * Function: insert_libhdf5_settings * @@ -58,11 +57,11 @@ static void insert_libhdf5_settings(FILE *flibinfo) { #ifdef H5_HAVE_EMBEDDED_LIBINFO - FILE *fsettings; /* for files libhdf5.settings */ - int inchar; - int bol = 0; /* indicates the beginning of a new line */ + FILE *fsettings; /* for files libhdf5.settings */ + int inchar; + int bol = 0; /* indicates the beginning of a new line */ - if(NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) { + if (NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) { HDperror(LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); } @@ -71,13 +70,13 @@ insert_libhdf5_settings(FILE *flibinfo) /* Do not use const else AIX strings does not show it. */ fprintf(flibinfo, "char H5libhdf5_settings[]=\n"); bol++; - while(EOF != (inchar = HDgetc(fsettings))) { - if(bol) { + while (EOF != (inchar = HDgetc(fsettings))) { + if (bol) { /* Start a new line */ fprintf(flibinfo, "\t\""); bol = 0; } - if(inchar == '\n') { + if (inchar == '\n') { /* end of a line */ fprintf(flibinfo, "\\n\"\n"); bol++; @@ -86,9 +85,9 @@ insert_libhdf5_settings(FILE *flibinfo) HDputc(inchar, flibinfo); } - if(HDfeof(fsettings)) { + if (HDfeof(fsettings)) { /* wrap up */ - if(!bol) + if (!bol) /* EOF found without a new line */ fprintf(flibinfo, "\\n\"\n"); fprintf(flibinfo, ";\n\n"); @@ -97,7 +96,7 @@ insert_libhdf5_settings(FILE *flibinfo) fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); } - if(0 != HDfclose(fsettings)) { + if (0 != HDfclose(fsettings)) { HDperror(LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); } @@ -108,7 +107,6 @@ insert_libhdf5_settings(FILE *flibinfo) #endif } /* insert_libhdf5_settings() */ - /*------------------------------------------------------------------------- * Function: make_libinfo * @@ -126,7 +124,6 @@ make_libinfo(void) insert_libhdf5_settings(rawoutstream); } - /*------------------------------------------------------------------------- * Function: print_header * @@ -138,22 +135,20 @@ make_libinfo(void) static void print_header(void) { - time_t now = HDtime(NULL); - struct tm *tm = HDlocaltime(&now); + time_t now = HDtime(NULL); + struct tm * tm = HDlocaltime(&now); char real_name[30]; char host_name[256]; - int i; - const char *s; + int i; + const char *s; #ifdef H5_HAVE_GETPWUID - struct passwd *pwd = NULL; + struct passwd *pwd = NULL; #else - int pwd = 1; + int pwd = 1; #endif - static const char *month_name[] = - { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - static const char *purpose = "\ + static const char *month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + static const char *purpose = "\ This machine-generated source code contains\n\ information about the library build configuration\n"; @@ -163,10 +158,10 @@ information about the library build configuration\n"; #ifdef H5_HAVE_GETPWUID { size_t n; - char *comma; + char * comma; - if((pwd = HDgetpwuid(HDgetuid()))) { - if((comma = HDstrchr(pwd->pw_gecos, ','))) { + if ((pwd = HDgetpwuid(HDgetuid()))) { + if ((comma = HDstrchr(pwd->pw_gecos, ','))) { n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); HDstrncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; @@ -187,7 +182,7 @@ information about the library build configuration\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if(HDgethostname(host_name, sizeof(host_name)) < 0) + if (HDgethostname(host_name, sizeof(host_name)) < 0) host_name[0] = '\0'; #else host_name[0] = '\0'; @@ -197,30 +192,30 @@ information about the library build configuration\n"; * The file header: warning, copyright notice, build information. */ fprintf(rawoutstream, "/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n"); - HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ + HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ - fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", - month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); - if(pwd || real_name[0] || host_name[0]) { + fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, + 1900 + tm->tm_year); + if (pwd || real_name[0] || host_name[0]) { fprintf(rawoutstream, " *\t\t\t"); - if(real_name[0]) + if (real_name[0]) fprintf(rawoutstream, "%s <", real_name); #ifdef H5_HAVE_GETPWUID - if(pwd) + if (pwd) HDfputs(pwd->pw_name, rawoutstream); #endif - if(host_name[0]) + if (host_name[0]) fprintf(rawoutstream, "@%s", host_name); - if(real_name[0]) + if (real_name[0]) fprintf(rawoutstream, ">"); HDfputc('\n', rawoutstream); } fprintf(rawoutstream, " *\n * Purpose:\t\t"); - for(s = purpose; *s; s++) { + for (s = purpose; *s; s++) { HDfputc(*s, rawoutstream); - if('\n' == *s && s[1]) + if ('\n' == *s && s[1]) fprintf(rawoutstream, " *\t\t\t"); } @@ -229,12 +224,11 @@ information about the library build configuration\n"; fprintf(rawoutstream, " *\tIt was generated by code in `H5make_libsettings.c'.\n"); fprintf(rawoutstream, " *\n *"); - for(i = 0; i < 73; i++) + for (i = 0; i < 73; i++) HDfputc('-', rawoutstream); fprintf(rawoutstream, "\n */\n\n"); } - /*------------------------------------------------------------------------- * Function: print_footer * @@ -249,7 +243,6 @@ print_footer(void) /* nothing */ } - /*------------------------------------------------------------------------- * Function: main * @@ -261,21 +254,21 @@ print_footer(void) int main(int argc, char *argv[]) { - char *fname = NULL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawoutstream is changed only when succeeded - */ + char *fname = NULL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawoutstream is changed only when succeeded + */ - if(argc > 1) + if (argc > 1) fname = argv[1]; /* First check if filename is string "NULL" */ - if(fname != NULL) { + if (fname != NULL) { /* binary output */ - if((f = HDfopen(fname, "w")) != NULL) + if ((f = HDfopen(fname, "w")) != NULL) rawoutstream = f; } - if(!rawoutstream) + if (!rawoutstream) rawoutstream = stdout; print_header(); @@ -285,8 +278,8 @@ main(int argc, char *argv[]) print_footer(); - if(rawoutstream && rawoutstream != stdout) { - if(HDfclose(rawoutstream)) + if (rawoutstream && rawoutstream != stdout) { + if (HDfclose(rawoutstream)) fprintf(stderr, "closing rawoutstream"); else rawoutstream = NULL; @@ -294,4 +287,3 @@ main(int argc, char *argv[]) HDexit(EXIT_SUCCESS); } - diff --git a/src/H5mpi.c b/src/H5mpi.c index 9c72fb0..c1f9132 100644 --- a/src/H5mpi.c +++ b/src/H5mpi.c @@ -16,19 +16,18 @@ * */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory Management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory Management */ #ifdef H5_HAVE_PARALLEL /****************/ /* Local Macros */ /****************/ -#define TWO_GIG_LIMIT (1 << 31) +#define TWO_GIG_LIMIT (1 << 31) #ifndef H5_MAX_MPI_COUNT -#define H5_MAX_MPI_COUNT (1 << 30) +#define H5_MAX_MPI_COUNT (1 << 30) #endif /*******************/ @@ -36,7 +35,6 @@ /*******************/ static hsize_t bigio_count = H5_MAX_MPI_COUNT; - /*------------------------------------------------------------------------- * Function: H5_mpi_set_bigio_count * @@ -55,13 +53,12 @@ H5_mpi_set_bigio_count(hsize_t new_count) { hsize_t orig_count = bigio_count; - if((new_count > 0) && (new_count < (hsize_t)TWO_GIG_LIMIT)) { - bigio_count = new_count; + if ((new_count > 0) && (new_count < (hsize_t)TWO_GIG_LIMIT)) { + bigio_count = new_count; } return orig_count; } /* end H5_mpi_set_bigio_count() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_get_bigio_count * @@ -80,7 +77,6 @@ H5_mpi_get_bigio_count(void) return bigio_count; } - /*------------------------------------------------------------------------- * Function: H5_mpi_comm_dup * @@ -98,9 +94,9 @@ H5_mpi_get_bigio_count(void) herr_t H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new) { - herr_t ret_value = SUCCEED; - MPI_Comm comm_dup = MPI_COMM_NULL; - int mpi_code; + herr_t ret_value = SUCCEED; + MPI_Comm comm_dup = MPI_COMM_NULL; + int mpi_code; FUNC_ENTER_NOAPI(FAIL) @@ -124,7 +120,6 @@ H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new) */ if (MPI_SUCCESS != (mpi_code = MPI_Comm_set_errhandler(comm_dup, MPI_ERRORS_RETURN))) HMPI_GOTO_ERROR(FAIL, "MPI_Errhandler_set failed", mpi_code) - } /* Copy the new communicator to the return argument */ @@ -140,7 +135,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpi_comm_dup() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_info_dup * @@ -159,9 +153,9 @@ done: herr_t H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new) { - herr_t ret_value = SUCCEED; - MPI_Info info_dup = MPI_INFO_NULL; - int mpi_code; + herr_t ret_value = SUCCEED; + MPI_Info info_dup = MPI_INFO_NULL; + int mpi_code; FUNC_ENTER_NOAPI(FAIL) @@ -193,7 +187,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpi_info_dup() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_comm_free * @@ -208,7 +201,7 @@ done: herr_t H5_mpi_comm_free(MPI_Comm *comm) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -225,7 +218,7 @@ H5_mpi_comm_free(MPI_Comm *comm) done: FUNC_LEAVE_NOAPI(ret_value) } /* End H5_mpi_comm_free() */ - + /*------------------------------------------------------------------------- * Function: H5_mpi_info_free * @@ -240,7 +233,7 @@ done: herr_t H5_mpi_info_free(MPI_Info *info) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -258,7 +251,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* End H5_mpi_info_free() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_comm_cmp * @@ -282,9 +274,9 @@ done: herr_t H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result) { - int mpi_code; - int mpi_result = MPI_IDENT; - herr_t ret_value = SUCCEED; + int mpi_code; + int mpi_result = MPI_IDENT; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -329,7 +321,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpi_comm_cmp() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_info_cmp * @@ -349,11 +340,11 @@ done: herr_t H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result) { - hbool_t same = FALSE; - char *key = NULL; - char *value1 = NULL; - char *value2 = NULL; - herr_t ret_value = SUCCEED; + hbool_t same = FALSE; + char * key = NULL; + char * value1 = NULL; + char * value2 = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -372,9 +363,9 @@ H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result) same = FALSE; } else { - int mpi_code; - int nkeys_1; - int nkeys_2; + int mpi_code; + int nkeys_1; + int nkeys_2; /* Check if the number of keys is the same */ if (MPI_SUCCESS != (mpi_code = MPI_Info_get_nkeys(info1, &nkeys_1))) @@ -426,8 +417,8 @@ H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result) } } /* end for */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Set the output value * @@ -450,7 +441,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpi_info_cmp() */ - /*------------------------------------------------------------------------- * Function: H5_mpio_create_large_type * @@ -466,23 +456,23 @@ done: *------------------------------------------------------------------------- */ herr_t -H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, - MPI_Datatype old_type, MPI_Datatype *new_type) +H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, MPI_Datatype old_type, + MPI_Datatype *new_type) { - int num_big_types; /* num times the 2G datatype will be repeated */ - int remaining_bytes; /* the number of bytes left that can be held in an int value */ - hsize_t leftover; - int block_len[2]; - int mpi_code; /* MPI return code */ - MPI_Datatype inner_type, outer_type, leftover_type, type[2]; - MPI_Aint disp[2], old_extent; - herr_t ret_value = SUCCEED; /* Return value */ + int num_big_types; /* num times the 2G datatype will be repeated */ + int remaining_bytes; /* the number of bytes left that can be held in an int value */ + hsize_t leftover; + int block_len[2]; + int mpi_code; /* MPI return code */ + MPI_Datatype inner_type, outer_type, leftover_type, type[2]; + MPI_Aint disp[2], old_extent; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Calculate how many Big MPI datatypes are needed to represent the buffer */ - num_big_types = (int)(num_elements/bigio_count); - leftover = (hsize_t)num_elements - (hsize_t)num_big_types * bigio_count; + num_big_types = (int)(num_elements / bigio_count); + leftover = (hsize_t)num_elements - (hsize_t)num_big_types * bigio_count; H5_CHECKED_ASSIGN(remaining_bytes, int, leftover, hsize_t); /* Create a contiguous datatype of size equal to the largest @@ -491,37 +481,38 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, * use type_hvector to create the type with the displacement provided */ if (0 == stride_bytes) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)bigio_count, old_type, &inner_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)bigio_count, old_type, &inner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)bigio_count, 1, stride_bytes, old_type, &inner_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hvector((int)bigio_count, 1, stride_bytes, old_type, &inner_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) /* Create a contiguous datatype of the buffer (minus the remaining < 2GB part) * If a stride is present, use hvector type */ - if(0 == stride_bytes) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(num_big_types, inner_type, &outer_type))) + if (0 == stride_bytes) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(num_big_types, inner_type, &outer_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(num_big_types, 1, stride_bytes, inner_type, &outer_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hvector(num_big_types, 1, stride_bytes, inner_type, &outer_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) MPI_Type_free(&inner_type); /* If there is a remaining part create a contiguous/vector datatype and then * use a struct datatype to encapsulate everything. */ - if(remaining_bytes) { - if(stride_bytes == 0) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(remaining_bytes, old_type, &leftover_type))) + if (remaining_bytes) { + if (stride_bytes == 0) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(remaining_bytes, old_type, &leftover_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)(num_elements - (hsize_t)num_big_types * bigio_count), 1, stride_bytes, old_type, &leftover_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + else if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector( + (int)(num_elements - (hsize_t)num_big_types * bigio_count), 1, + stride_bytes, old_type, &leftover_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) /* As of version 4.0, OpenMPI now turns off MPI-1 API calls by default, * so we're using the MPI-2 version even though we don't need the lb @@ -533,14 +524,14 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, } /* Set up the arguments for MPI_Type_struct constructor */ - type[0] = outer_type; - type[1] = leftover_type; + type[0] = outer_type; + type[1] = leftover_type; block_len[0] = 1; block_len[1] = 1; - disp[0] = 0; - disp[1] = (old_extent + stride_bytes) * num_big_types * (MPI_Aint)bigio_count; + disp[0] = 0; + disp[1] = (old_extent + stride_bytes) * num_big_types * (MPI_Aint)bigio_count; - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, block_len, disp, type, new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, block_len, disp, type, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) MPI_Type_free(&outer_type); @@ -551,13 +542,11 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, * the outer type created */ *new_type = outer_type; - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpio_create_large_type() */ - #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5private.h b/src/H5private.h index 3741d4a..cd1b1d2 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -24,38 +24,38 @@ #ifndef _H5private_H #define _H5private_H -#include "H5public.h" /* Include Public Definitions */ +#include "H5public.h" /* Include Public Definitions */ /* include the pthread header */ #ifdef H5_HAVE_THREADSAFE - #ifdef H5_HAVE_WIN32_API - #ifndef H5_HAVE_WIN_THREADS - #ifdef H5_HAVE_PTHREAD_H - #include - #endif /* H5_HAVE_PTHREAD_H */ - #endif /* H5_HAVE_WIN_THREADS */ - #else /* H5_HAVE_WIN32_API */ - #ifdef H5_HAVE_PTHREAD_H - #include - #endif /* H5_HAVE_PTHREAD_H */ - #endif /* H5_HAVE_WIN32_API */ +#ifdef H5_HAVE_WIN32_API +#ifndef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_PTHREAD_H +#include +#endif /* H5_HAVE_PTHREAD_H */ +#endif /* H5_HAVE_WIN_THREADS */ +#else /* H5_HAVE_WIN32_API */ +#ifdef H5_HAVE_PTHREAD_H +#include +#endif /* H5_HAVE_PTHREAD_H */ +#endif /* H5_HAVE_WIN32_API */ #endif /* H5_HAVE_THREADSAFE */ /* * Include ANSI-C header files. */ #ifdef H5_STDC_HEADERS -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif /* @@ -63,12 +63,12 @@ * compliant. Otherwise all bets are off. */ #ifdef H5_HAVE_UNISTD_H -# include -# include +#include +#include #endif #ifdef _POSIX_VERSION -# include -# include +#include +#include #endif /* @@ -76,7 +76,7 @@ */ #ifndef __cplusplus #ifdef H5_HAVE_STDINT_H -# include +#include #endif #endif @@ -86,7 +86,7 @@ * for hdf5 to compile, although only a few fields are actually used. */ #ifdef H5_HAVE_SYS_STAT_H -# include +#include #endif /* @@ -100,26 +100,26 @@ * by `AC_CHECK_HEADERS(sys/time.h)' in configure.ac. */ #if defined(H5_TIME_WITH_SYS_TIME) -# include -# include +#include +#include #elif defined(H5_HAVE_SYS_TIME_H) -# include +#include #else -# include +#include #endif /* * Longjumps are used to detect alignment constrants */ #ifdef H5_HAVE_SETJMP_H -# include +#include #endif /* * flock() in sys/file.h is used for the implementation of file locking. */ #if defined(H5_HAVE_FLOCK) && defined(H5_HAVE_SYS_FILE_H) -# include +#include #endif /* @@ -127,7 +127,7 @@ * and debugging code if available. */ #ifdef H5_HAVE_SYS_RESOURCE_H -# include +#include #endif /* @@ -135,7 +135,7 @@ * reasonable output width. */ #ifdef H5_HAVE_SYS_IOCTL_H -# include +#include #endif /* @@ -144,13 +144,13 @@ * alignment constraints in H5detect.c:main(). */ #ifdef H5_HAVE_SYS_SYSINFO_H -# include +#include #endif #ifdef H5_HAVE_SYS_PROC_H -# include +#include #endif #ifdef H5_HAVE_IO_H -# include +#include #endif /* @@ -174,50 +174,50 @@ /* Define the default VFD for this platform. * Since the removal of the Windows VFD, this is sec2 for all platforms. */ -#define H5_DEFAULT_VFD H5FD_SEC2 +#define H5_DEFAULT_VFD H5FD_SEC2 /* Define the default VOL driver */ -#define H5_DEFAULT_VOL H5VL_NATIVE +#define H5_DEFAULT_VOL H5VL_NATIVE #ifdef H5_HAVE_WIN32_API /* The following two defines must be before any windows headers are included */ -#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ -#define NOGDI /* Exclude Graphic Display Interface macros */ +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#define NOGDI /* Exclude Graphic Display Interface macros */ #ifdef H5_HAVE_WINSOCK2_H #include #endif #ifdef H5_HAVE_THREADSAFE -#include /* For _beginthread() */ +#include /* For _beginthread() */ #endif #include -#include /* For _getcwd() */ +#include /* For _getcwd() */ #endif /*H5_HAVE_WIN32_API*/ /* Various ways that inline functions can be declared */ #if defined(H5_HAVE___INLINE__) - /* GNU (alternative form) */ - #define H5_INLINE __inline__ +/* GNU (alternative form) */ +#define H5_INLINE __inline__ #elif defined(H5_HAVE___INLINE) - /* Visual Studio */ - #define H5_INLINE __inline +/* Visual Studio */ +#define H5_INLINE __inline #elif defined(H5_HAVE_INLINE) - /* GNU, C++ - * Use "inline" as a last resort on the off-chance that there will - * be C++ problems. - */ - #define H5_INLINE inline +/* GNU, C++ + * Use "inline" as a last resort on the off-chance that there will + * be C++ problems. + */ +#define H5_INLINE inline #else - #define H5_INLINE +#define H5_INLINE #endif /* inline choices */ #ifndef F_OK -# define F_OK 00 -# define W_OK 02 -# define R_OK 04 +#define F_OK 00 +#define W_OK 02 +#define R_OK 04 #endif /* @@ -237,12 +237,12 @@ * #define eventa(func_name) h5_mpe_ ## func_name ## _a * #define eventb(func_name) h5_mpe_ ## func_name ## _b */ -#define eventa(func_name) h5_mpe_eventa -#define eventb(func_name) h5_mpe_eventb -#define MPE_LOG_VARS \ - static int eventa(FUNC) = -1; \ - static int eventb(FUNC) = -1; \ - char p_event_start[128]; +#define eventa(func_name) h5_mpe_eventa +#define eventb(func_name) h5_mpe_eventb +#define MPE_LOG_VARS \ + static int eventa(FUNC) = -1; \ + static int eventb(FUNC) = -1; \ + char p_event_start[128]; /* Hardwire the color to "red", since that's what all the routines are using * now. In the future, if we want to change that color for a given routine, @@ -251,34 +251,33 @@ * color information down to the BEGIN_MPE_LOG macro (which should have a new * BEGIN_MPE_LOG_COLOR variant). -QAK */ -#define BEGIN_MPE_LOG \ - if (H5_MPEinit_g){ \ - sprintf(p_event_start, "start %s", FUNC); \ - if (eventa(FUNC) == -1 && eventb(FUNC) == -1) { \ - const char* p_color = "red"; \ - eventa(FUNC)=MPE_Log_get_event_number(); \ - eventb(FUNC)=MPE_Log_get_event_number(); \ - MPE_Describe_state(eventa(FUNC), eventb(FUNC), FUNC, p_color); \ - } \ - MPE_Log_event(eventa(FUNC), 0, p_event_start); \ +#define BEGIN_MPE_LOG \ + if (H5_MPEinit_g) { \ + sprintf(p_event_start, "start %s", FUNC); \ + if (eventa(FUNC) == -1 && eventb(FUNC) == -1) { \ + const char *p_color = "red"; \ + eventa(FUNC) = MPE_Log_get_event_number(); \ + eventb(FUNC) = MPE_Log_get_event_number(); \ + MPE_Describe_state(eventa(FUNC), eventb(FUNC), FUNC, p_color); \ + } \ + MPE_Log_event(eventa(FUNC), 0, p_event_start); \ } - /*------------------------------------------------------------------------ * Purpose: Finish the collection of MPE log information for a function. * It should be after the actual function's process. * * Programmer: Long Wang */ -#define FINISH_MPE_LOG \ - if (H5_MPEinit_g) { \ - MPE_Log_event(eventb(FUNC), 0, FUNC); \ +#define FINISH_MPE_LOG \ + if (H5_MPEinit_g) { \ + MPE_Log_event(eventb(FUNC), 0, FUNC); \ } -#else /* H5_HAVE_MPE */ -#define MPE_LOG_VARS /* void */ -#define BEGIN_MPE_LOG /* void */ -#define FINISH_MPE_LOG /* void */ +#else /* H5_HAVE_MPE */ +#define MPE_LOG_VARS /* void */ +#define BEGIN_MPE_LOG /* void */ +#define FINISH_MPE_LOG /* void */ #endif /* H5_HAVE_MPE */ @@ -296,7 +295,7 @@ * never be raised by the hdf5 library). */ #ifndef SIGBUS -# define SIGBUS SIGILL +#define SIGBUS SIGILL #endif /* @@ -311,63 +310,63 @@ * file). Be sure to update that file if the #ifdefs change here. */ #ifdef __cplusplus -# define H5_ATTR_FORMAT(X,Y,Z) /*void*/ -# define H5_ATTR_UNUSED /*void*/ -# define H5_ATTR_DEPRECATED_USED /*void*/ -# define H5_ATTR_NDEBUG_UNUSED /*void*/ -# define H5_ATTR_DEBUG_API_USED /*void*/ -# define H5_ATTR_PARALLEL_UNUSED /*void*/ -# define H5_ATTR_PARALLEL_USED /*void*/ -# define H5_ATTR_NORETURN /*void*/ -# define H5_ATTR_CONST /*void*/ -# define H5_ATTR_PURE /*void*/ -# define H5_ATTR_FALLTHROUGH /*void*/ -#else /* __cplusplus */ +#define H5_ATTR_FORMAT(X, Y, Z) /*void*/ +#define H5_ATTR_UNUSED /*void*/ +#define H5_ATTR_DEPRECATED_USED /*void*/ +#define H5_ATTR_NDEBUG_UNUSED /*void*/ +#define H5_ATTR_DEBUG_API_USED /*void*/ +#define H5_ATTR_PARALLEL_UNUSED /*void*/ +#define H5_ATTR_PARALLEL_USED /*void*/ +#define H5_ATTR_NORETURN /*void*/ +#define H5_ATTR_CONST /*void*/ +#define H5_ATTR_PURE /*void*/ +#define H5_ATTR_FALLTHROUGH /*void*/ +#else /* __cplusplus */ #if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) -# define H5_ATTR_FORMAT(X,Y,Z) __attribute__((format(X, Y, Z))) -# define H5_ATTR_UNUSED __attribute__((unused)) +#define H5_ATTR_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z))) +#define H5_ATTR_UNUSED __attribute__((unused)) #ifdef H5_HAVE_PARALLEL -# define H5_ATTR_PARALLEL_UNUSED __attribute__((unused)) -# define H5_ATTR_PARALLEL_USED /*void*/ +#define H5_ATTR_PARALLEL_UNUSED __attribute__((unused)) +#define H5_ATTR_PARALLEL_USED /*void*/ #else -# define H5_ATTR_PARALLEL_UNUSED /*void*/ -# define H5_ATTR_PARALLEL_USED __attribute__((unused)) +#define H5_ATTR_PARALLEL_UNUSED /*void*/ +#define H5_ATTR_PARALLEL_USED __attribute__((unused)) #endif #ifdef H5_NO_DEPRECATED_SYMBOLS -#define H5_ATTR_DEPRECATED_USED H5_ATTR_UNUSED -#else /* H5_NO_DEPRECATED_SYMBOLS */ -#define H5_ATTR_DEPRECATED_USED /*void*/ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +#define H5_ATTR_DEPRECATED_USED H5_ATTR_UNUSED +#else /* H5_NO_DEPRECATED_SYMBOLS */ +#define H5_ATTR_DEPRECATED_USED /*void*/ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef H5_DEBUG_API -#define H5_ATTR_DEBUG_API_USED /*void*/ -#else /* H5_DEBUG_API */ -#define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED +#define H5_ATTR_DEBUG_API_USED /*void*/ +#else /* H5_DEBUG_API */ +#define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED #endif /* H5_DEBUG_API */ #ifndef NDEBUG -#define H5_ATTR_NDEBUG_UNUSED /*void*/ -#else /* NDEBUG */ -#define H5_ATTR_NDEBUG_UNUSED H5_ATTR_UNUSED +#define H5_ATTR_NDEBUG_UNUSED /*void*/ +#else /* NDEBUG */ +#define H5_ATTR_NDEBUG_UNUSED H5_ATTR_UNUSED #endif /* NDEBUG */ -# define H5_ATTR_NORETURN __attribute__((noreturn)) -# define H5_ATTR_CONST __attribute__((const)) -# define H5_ATTR_PURE __attribute__((pure)) +#define H5_ATTR_NORETURN __attribute__((noreturn)) +#define H5_ATTR_CONST __attribute__((const)) +#define H5_ATTR_PURE __attribute__((pure)) #if defined(__GNUC__) && __GNUC__ >= 7 && !defined(__INTEL_COMPILER) -# define H5_ATTR_FALLTHROUGH __attribute__((fallthrough)); +#define H5_ATTR_FALLTHROUGH __attribute__((fallthrough)); #else -# define H5_ATTR_FALLTHROUGH /*void*/ +#define H5_ATTR_FALLTHROUGH /*void*/ #endif #else -# define H5_ATTR_FORMAT(X,Y,Z) /*void*/ -# define H5_ATTR_UNUSED /*void*/ -# define H5_ATTR_NDEBUG_UNUSED /*void*/ -# define H5_ATTR_DEBUG_API_USED /*void*/ -# define H5_ATTR_DEPRECATED_USED /*void*/ -# define H5_ATTR_PARALLEL_UNUSED /*void*/ -# define H5_ATTR_PARALLEL_USED /*void*/ -# define H5_ATTR_NORETURN /*void*/ -# define H5_ATTR_CONST /*void*/ -# define H5_ATTR_PURE /*void*/ -# define H5_ATTR_FALLTHROUGH /*void*/ +#define H5_ATTR_FORMAT(X, Y, Z) /*void*/ +#define H5_ATTR_UNUSED /*void*/ +#define H5_ATTR_NDEBUG_UNUSED /*void*/ +#define H5_ATTR_DEBUG_API_USED /*void*/ +#define H5_ATTR_DEPRECATED_USED /*void*/ +#define H5_ATTR_PARALLEL_UNUSED /*void*/ +#define H5_ATTR_PARALLEL_USED /*void*/ +#define H5_ATTR_NORETURN /*void*/ +#define H5_ATTR_CONST /*void*/ +#define H5_ATTR_PURE /*void*/ +#define H5_ATTR_FALLTHROUGH /*void*/ #endif #endif /* __cplusplus */ @@ -375,16 +374,16 @@ * Networking headers used by the mirror VFD and related tests and utilities. */ #ifdef H5_HAVE_ARPA_INET_H -# include +#include #endif #ifdef H5_HAVE_NETDB_H -# include +#include #endif #ifdef H5_HAVE_NETINET_IN_H -# include +#include #endif #ifdef H5_HAVE_SYS_SOCKET_H -# include +#include #endif /* @@ -396,9 +395,9 @@ * function, remember to compare against zero and not one of these two * values. */ -#define SUCCEED 0 +#define SUCCEED 0 #define FAIL (-1) -#define UFAIL (unsigned)(-1) +#define UFAIL (unsigned)(-1) /* The HDF5 library uses the symbol `ERR` frequently. So do * header files for libraries such as curses(3), terminfo(3), etc. @@ -410,51 +409,51 @@ /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) #endif /* minimum of two, three, or four values */ #undef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) -#define MIN2(a,b) MIN(a,b) -#define MIN3(a,b,c) MIN(a,MIN(b,c)) -#define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MIN2(a, b) MIN(a, b) +#define MIN3(a, b, c) MIN(a, MIN(b, c)) +#define MIN4(a, b, c, d) MIN(MIN(a, b), MIN(c, d)) /* maximum of two, three, or four values */ #undef MAX -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) -#define MAX2(a,b) MAX(a,b) -#define MAX3(a,b,c) MAX(a,MAX(b,c)) -#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define MAX2(a, b) MAX(a, b) +#define MAX3(a, b, c) MAX(a, MAX(b, c)) +#define MAX4(a, b, c, d) MAX(MAX(a, b), MAX(c, d)) /* limit the middle value to be within a range (inclusive) */ -#define RANGE(LO,X,HI) MAX(LO,MIN(X,HI)) +#define RANGE(LO, X, HI) MAX(LO, MIN(X, HI)) /* absolute value */ #ifndef ABS -# define ABS(a) (((a)>=0) ? (a) : -(a)) +#define ABS(a) (((a) >= 0) ? (a) : -(a)) #endif /* sign of argument */ #ifndef SIGN -# define SIGN(a) ((a)>0 ? 1 : (a)<0 ? -1 : 0) +#define SIGN(a) ((a) > 0 ? 1 : (a) < 0 ? -1 : 0) #endif /* test for number that is a power of 2 */ /* (from: http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2) */ -# define POWER_OF_TWO(n) (!(n & (n - 1)) && n) +#define POWER_OF_TWO(n) (!(n & (n - 1)) && n) /* Raise an integer to a power of 2 */ -# define H5_EXP2(n) (1 << (n)) +#define H5_EXP2(n) (1 << (n)) /* * HDF Boolean type. */ #ifndef FALSE - #define FALSE false +#define FALSE false #endif #ifndef TRUE - #define TRUE true +#define TRUE true #endif /* @@ -464,65 +463,65 @@ * be exactly one byte wide because we use it for pointer calculations to * void* memory. */ -#if H5_SIZEOF_INT8_T==0 - typedef signed char int8_t; -# undef H5_SIZEOF_INT8_T -# define H5_SIZEOF_INT8_T H5_SIZEOF_CHAR -#elif H5_SIZEOF_INT8_T==1 +#if H5_SIZEOF_INT8_T == 0 +typedef signed char int8_t; +#undef H5_SIZEOF_INT8_T +#define H5_SIZEOF_INT8_T H5_SIZEOF_CHAR +#elif H5_SIZEOF_INT8_T == 1 #else -# error "the int8_t type must be 1 byte wide" +#error "the int8_t type must be 1 byte wide" #endif -#if H5_SIZEOF_UINT8_T==0 - typedef unsigned char uint8_t; -# undef H5_SIZEOF_UINT8_T -# define H5_SIZEOF_UINT8_T H5_SIZEOF_CHAR -#elif H5_SIZEOF_UINT8_T==1 +#if H5_SIZEOF_UINT8_T == 0 +typedef unsigned char uint8_t; +#undef H5_SIZEOF_UINT8_T +#define H5_SIZEOF_UINT8_T H5_SIZEOF_CHAR +#elif H5_SIZEOF_UINT8_T == 1 #else -# error "the uint8_t type must be 1 byte wide" +#error "the uint8_t type must be 1 byte wide" #endif -#if H5_SIZEOF_INT16_T>=2 -#elif H5_SIZEOF_SHORT>=2 - typedef short int16_t; -# undef H5_SIZEOF_INT16_T -# define H5_SIZEOF_INT16_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT>=2 - typedef int int16_t; -# undef H5_SIZEOF_INT16_T -# define H5_SIZEOF_INT16_T H5_SIZEOF_INT +#if H5_SIZEOF_INT16_T >= 2 +#elif H5_SIZEOF_SHORT >= 2 +typedef short int16_t; +#undef H5_SIZEOF_INT16_T +#define H5_SIZEOF_INT16_T H5_SIZEOF_SHORT +#elif H5_SIZEOF_INT >= 2 +typedef int int16_t; +#undef H5_SIZEOF_INT16_T +#define H5_SIZEOF_INT16_T H5_SIZEOF_INT #else -# error "nothing appropriate for int16_t" +#error "nothing appropriate for int16_t" #endif -#if H5_SIZEOF_UINT16_T>=2 -#elif H5_SIZEOF_SHORT>=2 - typedef unsigned short uint16_t; -# undef H5_SIZEOF_UINT16_T -# define H5_SIZEOF_UINT16_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT>=2 - typedef unsigned uint16_t; -# undef H5_SIZEOF_UINT16_T -# define H5_SIZEOF_UINT16_T H5_SIZEOF_INT +#if H5_SIZEOF_UINT16_T >= 2 +#elif H5_SIZEOF_SHORT >= 2 +typedef unsigned short uint16_t; +#undef H5_SIZEOF_UINT16_T +#define H5_SIZEOF_UINT16_T H5_SIZEOF_SHORT +#elif H5_SIZEOF_INT >= 2 +typedef unsigned uint16_t; +#undef H5_SIZEOF_UINT16_T +#define H5_SIZEOF_UINT16_T H5_SIZEOF_INT #else -# error "nothing appropriate for uint16_t" +#error "nothing appropriate for uint16_t" #endif -#if H5_SIZEOF_INT32_T>=4 -#elif H5_SIZEOF_SHORT>=4 - typedef short int32_t; -# undef H5_SIZEOF_INT32_T -# define H5_SIZEOF_INT32_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT>=4 - typedef int int32_t; -# undef H5_SIZEOF_INT32_T -# define H5_SIZEOF_INT32_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG>=4 - typedef long int32_t; -# undef H5_SIZEOF_INT32_T -# define H5_SIZEOF_INT32_T H5_SIZEOF_LONG +#if H5_SIZEOF_INT32_T >= 4 +#elif H5_SIZEOF_SHORT >= 4 +typedef short int32_t; +#undef H5_SIZEOF_INT32_T +#define H5_SIZEOF_INT32_T H5_SIZEOF_SHORT +#elif H5_SIZEOF_INT >= 4 +typedef int int32_t; +#undef H5_SIZEOF_INT32_T +#define H5_SIZEOF_INT32_T H5_SIZEOF_INT +#elif H5_SIZEOF_LONG >= 4 +typedef long int32_t; +#undef H5_SIZEOF_INT32_T +#define H5_SIZEOF_INT32_T H5_SIZEOF_LONG #else -# error "nothing appropriate for int32_t" +#error "nothing appropriate for int32_t" #endif /* @@ -530,56 +529,55 @@ * most part. */ #ifndef LLONG_MAX -# define LLONG_MAX ((long long)(((unsigned long long)1 \ - <<(8*sizeof(long long)-1))-1)) -# define LLONG_MIN ((long long)(-LLONG_MAX)-1) +#define LLONG_MAX ((long long)(((unsigned long long)1 << (8 * sizeof(long long) - 1)) - 1)) +#define LLONG_MIN ((long long)(-LLONG_MAX) - 1) #endif #ifndef ULLONG_MAX -# define ULLONG_MAX ((unsigned long long)((long long)(-1))) +#define ULLONG_MAX ((unsigned long long)((long long)(-1))) #endif #ifndef SIZET_MAX -# define SIZET_MAX ((size_t)(ssize_t)(-1)) -# define SSIZET_MAX ((ssize_t)(((size_t)1<<(8*sizeof(ssize_t)-1))-1)) +#define SIZET_MAX ((size_t)(ssize_t)(-1)) +#define SSIZET_MAX ((ssize_t)(((size_t)1 << (8 * sizeof(ssize_t) - 1)) - 1)) #endif /* * Maximum & minimum values for our typedefs. */ -#define HSIZET_MAX ((hsize_t)ULLONG_MAX) -#define HSSIZET_MAX ((hssize_t)LLONG_MAX) -#define HSSIZET_MIN (~(HSSIZET_MAX)) +#define HSIZET_MAX ((hsize_t)ULLONG_MAX) +#define HSSIZET_MAX ((hssize_t)LLONG_MAX) +#define HSSIZET_MIN (~(HSSIZET_MAX)) /* * Types and max sizes for POSIX I/O. * OS X (Darwin) is odd since the max I/O size does not match the types. */ #if defined(H5_HAVE_WIN32_API) -# define h5_posix_io_t unsigned int -# define h5_posix_io_ret_t int -# define H5_POSIX_MAX_IO_BYTES INT_MAX +#define h5_posix_io_t unsigned int +#define h5_posix_io_ret_t int +#define H5_POSIX_MAX_IO_BYTES INT_MAX #elif defined(H5_HAVE_DARWIN) -# define h5_posix_io_t size_t -# define h5_posix_io_ret_t ssize_t -# define H5_POSIX_MAX_IO_BYTES INT_MAX +#define h5_posix_io_t size_t +#define h5_posix_io_ret_t ssize_t +#define H5_POSIX_MAX_IO_BYTES INT_MAX #else -# define h5_posix_io_t size_t -# define h5_posix_io_ret_t ssize_t -# define H5_POSIX_MAX_IO_BYTES SSIZET_MAX +#define h5_posix_io_t size_t +#define h5_posix_io_ret_t ssize_t +#define H5_POSIX_MAX_IO_BYTES SSIZET_MAX #endif /* POSIX I/O mode used as the third parameter to open/_open * when creating a new file (O_CREAT is set). */ #if defined(H5_HAVE_WIN32_API) -# define H5_POSIX_CREATE_MODE_RW (_S_IREAD | _S_IWRITE) +#define H5_POSIX_CREATE_MODE_RW (_S_IREAD | _S_IWRITE) #else -# define H5_POSIX_CREATE_MODE_RW 0666 +#define H5_POSIX_CREATE_MODE_RW 0666 #endif /* Represents an empty asynchronous request handle. * Used in the VOL code. */ -#define H5_REQUEST_NULL NULL +#define H5_REQUEST_NULL NULL /* * Methods to compare the equality of floating-point values: @@ -593,13 +591,13 @@ * It's the developer's responsibility not to pass in the value 0, which * may cause the equation to fail. */ -#define H5_FLT_ABS_EQUAL(X,Y) (HDfabsf((X)-(Y)) < FLT_EPSILON) -#define H5_DBL_ABS_EQUAL(X,Y) (HDfabs ((X)-(Y)) < DBL_EPSILON) -#define H5_LDBL_ABS_EQUAL(X,Y) (HDfabsl((X)-(Y)) < LDBL_EPSILON) +#define H5_FLT_ABS_EQUAL(X, Y) (HDfabsf((X) - (Y)) < FLT_EPSILON) +#define H5_DBL_ABS_EQUAL(X, Y) (HDfabs((X) - (Y)) < DBL_EPSILON) +#define H5_LDBL_ABS_EQUAL(X, Y) (HDfabsl((X) - (Y)) < LDBL_EPSILON) -#define H5_FLT_REL_EQUAL(X,Y,M) (HDfabsf(((Y)-(X)) / (X)) < (M)) -#define H5_DBL_REL_EQUAL(X,Y,M) (HDfabs (((Y)-(X)) / (X)) < (M)) -#define H5_LDBL_REL_EQUAL(X,Y,M) (HDfabsl(((Y)-(X)) / (X)) < (M)) +#define H5_FLT_REL_EQUAL(X, Y, M) (HDfabsf(((Y) - (X)) / (X)) < (M)) +#define H5_DBL_REL_EQUAL(X, Y, M) (HDfabs(((Y) - (X)) / (X)) < (M)) +#define H5_LDBL_REL_EQUAL(X, Y, M) (HDfabsl(((Y) - (X)) / (X)) < (M)) /* KiB, MiB, GiB, TiB, PiB, EiB - Used in profiling and timing code */ #define H5_KB (1024.0F) @@ -615,10 +613,10 @@ * with system-provided flock() calls since the values will come from the * header file. */ -#define LOCK_SH 0x01 -#define LOCK_EX 0x02 -#define LOCK_NB 0x04 -#define LOCK_UN 0x08 +#define LOCK_SH 0x01 +#define LOCK_EX 0x02 +#define LOCK_NB 0x04 +#define LOCK_UN 0x08 #endif /* H5_HAVE_FLOCK */ /* Typedefs and functions for timing certain parts of the library. */ @@ -627,47 +625,47 @@ * platform-independent timers. */ typedef struct { - double user; /* User time in seconds */ - double system; /* System time in seconds */ - double elapsed; /* Elapsed (wall clock) time in seconds */ + double user; /* User time in seconds */ + double system; /* System time in seconds */ + double elapsed; /* Elapsed (wall clock) time in seconds */ } H5_timevals_t; /* Timer structure for platform-independent timers */ typedef struct { - H5_timevals_t initial; /* Current interval start time */ - H5_timevals_t final_interval; /* Last interval elapsed time */ - H5_timevals_t total; /* Total elapsed time for all intervals */ - hbool_t is_running; /* Whether timer is running */ + H5_timevals_t initial; /* Current interval start time */ + H5_timevals_t final_interval; /* Last interval elapsed time */ + H5_timevals_t total; /* Total elapsed time for all intervals */ + hbool_t is_running; /* Whether timer is running */ } H5_timer_t; /* Returns library bandwidth as a pretty string */ -H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds); +H5_DLL void H5_bandwidth(char *buf /*out*/, double nbytes, double nseconds); /* Timer functionality */ -H5_DLL time_t H5_now(void); +H5_DLL time_t H5_now(void); H5_DLL uint64_t H5_now_usec(void); -H5_DLL herr_t H5_timer_init(H5_timer_t *timer /*in,out*/); -H5_DLL herr_t H5_timer_start(H5_timer_t *timer /*in,out*/); -H5_DLL herr_t H5_timer_stop(H5_timer_t *timer /*in,out*/); -H5_DLL herr_t H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); -H5_DLL herr_t H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); -H5_DLL char *H5_timer_get_time_string(double seconds); +H5_DLL herr_t H5_timer_init(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_start(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_stop(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); +H5_DLL herr_t H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); +H5_DLL char * H5_timer_get_time_string(double seconds); /* Depth of object copy */ typedef enum { - H5_COPY_SHALLOW, /* Shallow copy from source to destination, just copy field pointers */ - H5_COPY_DEEP /* Deep copy from source to destination, including duplicating fields pointed to */ + H5_COPY_SHALLOW, /* Shallow copy from source to destination, just copy field pointers */ + H5_COPY_DEEP /* Deep copy from source to destination, including duplicating fields pointed to */ } H5_copy_depth_t; /* Common object copying udata (right now only used for groups and datasets) */ typedef struct H5O_copy_file_ud_common_t { - struct H5O_pline_t *src_pline; /* Copy of filter pipeline for object */ + struct H5O_pline_t *src_pline; /* Copy of filter pipeline for object */ } H5O_copy_file_ud_common_t; /* Unique object "position" */ typedef struct { - unsigned long fileno; /* The unique identifier for the file of the object */ - haddr_t addr; /* The unique address of the object's header in that file */ + unsigned long fileno; /* The unique identifier for the file of the object */ + haddr_t addr; /* The unique address of the object's header in that file */ } H5_obj_t; /* @@ -677,213 +675,213 @@ typedef struct { /* Put all platform-specific definitions in the following file */ /* so that the following definitions are platform free. */ -#include "H5win32defs.h" /* For Windows-specific definitions */ +#include "H5win32defs.h" /* For Windows-specific definitions */ #ifndef HDabort - #define HDabort() abort() +#define HDabort() abort() #endif /* HDabort */ #ifndef HDabs - #define HDabs(X) abs(X) +#define HDabs(X) abs(X) #endif /* HDabs */ #ifndef HDaccept - #define HDaccept(A,B,C) accept((A),(B),(C)) /* mirror VFD */ -#endif /* HDaccept */ +#define HDaccept(A, B, C) accept((A), (B), (C)) /* mirror VFD */ +#endif /* HDaccept */ #ifndef HDaccess - #define HDaccess(F,M) access(F, M) +#define HDaccess(F, M) access(F, M) #endif /* HDaccess */ #ifndef HDacos - #define HDacos(X) acos(X) +#define HDacos(X) acos(X) #endif /* HDacos */ #ifndef HDalarm - #ifdef H5_HAVE_ALARM - #define HDalarm(N) alarm(N) - #else /* H5_HAVE_ALARM */ - #define HDalarm(N) (0) - #endif /* H5_HAVE_ALARM */ +#ifdef H5_HAVE_ALARM +#define HDalarm(N) alarm(N) +#else /* H5_HAVE_ALARM */ +#define HDalarm(N) (0) +#endif /* H5_HAVE_ALARM */ #endif /* HDalarm */ #ifndef HDasctime - #define HDasctime(T) asctime(T) +#define HDasctime(T) asctime(T) #endif /* HDasctime */ #ifndef HDasin - #define HDasin(X) asin(X) +#define HDasin(X) asin(X) #endif /* HDasin */ #ifndef HDasprintf - #define HDasprintf asprintf /*varargs*/ -#endif /* HDasprintf */ +#define HDasprintf asprintf /*varargs*/ +#endif /* HDasprintf */ #ifndef HDassert - #define HDassert(X) assert(X) +#define HDassert(X) assert(X) #endif /* HDassert */ #ifndef HDatan - #define HDatan(X) atan(X) +#define HDatan(X) atan(X) #endif /* HDatan */ #ifndef HDatan2 - #define HDatan2(X,Y) atan2(X,Y) +#define HDatan2(X, Y) atan2(X, Y) #endif /* HDatan2 */ #ifndef HDatexit - #define HDatexit(F) atexit(F) +#define HDatexit(F) atexit(F) #endif /* HDatexit */ #ifndef HDatof - #define HDatof(S) atof(S) +#define HDatof(S) atof(S) #endif /* HDatof */ #ifndef HDatoi - #define HDatoi(S) atoi(S) +#define HDatoi(S) atoi(S) #endif /* HDatoi */ #ifndef HDatol - #define HDatol(S) atol(S) +#define HDatol(S) atol(S) #endif /* HDatol */ #ifndef HDatoll - #define HDatoll(S) atoll(S) +#define HDatoll(S) atoll(S) #endif /* HDatol */ #ifndef HDbind - #define HDbind(A,B,C) bind((A),(B),(C)) /* mirror VFD */ -#endif /* HDbind */ +#define HDbind(A, B, C) bind((A), (B), (C)) /* mirror VFD */ +#endif /* HDbind */ #ifndef HDbsearch - #define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) +#define HDbsearch(K, B, N, Z, F) bsearch(K, B, N, Z, F) #endif /* HDbsearch */ #ifndef HDcalloc - #define HDcalloc(N,Z) calloc(N,Z) +#define HDcalloc(N, Z) calloc(N, Z) #endif /* HDcalloc */ #ifndef HDceil - #define HDceil(X) ceil(X) +#define HDceil(X) ceil(X) #endif /* HDceil */ #ifndef HDcfgetispeed - #define HDcfgetispeed(T) cfgetispeed(T) +#define HDcfgetispeed(T) cfgetispeed(T) #endif /* HDcfgetispeed */ #ifndef HDcfgetospeed - #define HDcfgetospeed(T) cfgetospeed(T) +#define HDcfgetospeed(T) cfgetospeed(T) #endif /* HDcfgetospeed */ #ifndef HDcfsetispeed - #define HDcfsetispeed(T,S) cfsetispeed(T,S) +#define HDcfsetispeed(T, S) cfsetispeed(T, S) #endif /* HDcfsetispeed */ #ifndef HDcfsetospeed - #define HDcfsetospeed(T,S) cfsetospeed(T,S) +#define HDcfsetospeed(T, S) cfsetospeed(T, S) #endif /* HDcfsetospeed */ #ifndef HDchdir - #define HDchdir(S) chdir(S) +#define HDchdir(S) chdir(S) #endif /* HDchdir */ #ifndef HDchmod - #define HDchmod(S,M) chmod(S,M) +#define HDchmod(S, M) chmod(S, M) #endif /* HDchmod */ #ifndef HDchown - #define HDchown(S,O,G) chown(S,O,G) +#define HDchown(S, O, G) chown(S, O, G) #endif /* HDchown */ #ifndef HDclearerr - #define HDclearerr(F) clearerr(F) +#define HDclearerr(F) clearerr(F) #endif /* HDclearerr */ #ifndef HDclock - #define HDclock() clock() +#define HDclock() clock() #endif /* HDclock */ #ifndef HDclock_gettime - #define HDclock_gettime(CID, TS) clock_gettime(CID, TS) +#define HDclock_gettime(CID, TS) clock_gettime(CID, TS) #endif /* HDclock_gettime */ #ifndef HDclose - #define HDclose(F) close(F) +#define HDclose(F) close(F) #endif /* HDclose */ #ifndef HDclosedir - #define HDclosedir(D) closedir(D) +#define HDclosedir(D) closedir(D) #endif /* HDclosedir */ #ifndef HDconnect - #define HDconnect(A,B,C) connect((A),(B),(C)) /* mirror VFD */ -#endif /* HDconnect */ +#define HDconnect(A, B, C) connect((A), (B), (C)) /* mirror VFD */ +#endif /* HDconnect */ #ifndef HDcos - #define HDcos(X) cos(X) +#define HDcos(X) cos(X) #endif /* HDcos */ #ifndef HDcosh - #define HDcosh(X) cosh(X) +#define HDcosh(X) cosh(X) #endif /* HDcosh */ #ifndef HDcreat - #define HDcreat(S,M) creat(S,M) +#define HDcreat(S, M) creat(S, M) #endif /* HDcreat */ #ifndef HDctermid - #define HDctermid(S) ctermid(S) +#define HDctermid(S) ctermid(S) #endif /* HDctermid */ #ifndef HDctime - #define HDctime(T) ctime(T) +#define HDctime(T) ctime(T) #endif /* HDctime */ #ifndef HDcuserid - #define HDcuserid(S) cuserid(S) +#define HDcuserid(S) cuserid(S) #endif /* HDcuserid */ #ifndef HDdifftime - #ifdef H5_HAVE_DIFFTIME - #define HDdifftime(X,Y) difftime(X,Y) - #else /* H5_HAVE_DIFFTIME */ - #define HDdifftime(X,Y) ((double)(X)-(double)(Y)) - #endif /* H5_HAVE_DIFFTIME */ +#ifdef H5_HAVE_DIFFTIME +#define HDdifftime(X, Y) difftime(X, Y) +#else /* H5_HAVE_DIFFTIME */ +#define HDdifftime(X, Y) ((double)(X) - (double)(Y)) +#endif /* H5_HAVE_DIFFTIME */ #endif /* HDdifftime */ #ifndef HDdiv - #define HDdiv(X,Y) div(X,Y) +#define HDdiv(X, Y) div(X, Y) #endif /* HDdiv */ #ifndef HDdup - #define HDdup(F) dup(F) +#define HDdup(F) dup(F) #endif /* HDdup */ #ifndef HDdup2 - #define HDdup2(F,I) dup2(F,I) +#define HDdup2(F, I) dup2(F, I) #endif /* HDdup2 */ /* execl() variable arguments */ /* execle() variable arguments */ /* execlp() variable arguments */ #ifndef HDexecv - #define HDexecv(S,AV) execv(S,AV) +#define HDexecv(S, AV) execv(S, AV) #endif /* HDexecv */ #ifndef HDexecve - #define HDexecve(S,AV,E) execve(S,AV,E) +#define HDexecve(S, AV, E) execve(S, AV, E) #endif /* HDexecve */ #ifndef HDexecvp - #define HDexecvp(S,AV) execvp(S,AV) +#define HDexecvp(S, AV) execvp(S, AV) #endif /* HDexecvp */ #ifndef HDexit - #define HDexit(N) exit(N) +#define HDexit(N) exit(N) #endif /* HDexit */ #ifndef HD_exit - #define HD_exit(N) _exit(N) +#define HD_exit(N) _exit(N) #endif /* HD_exit */ #ifndef HDexp - #define HDexp(X) exp(X) +#define HDexp(X) exp(X) #endif /* HDexp */ #ifndef HDexp2 - #define HDexp2(X) exp2(X) +#define HDexp2(X) exp2(X) #endif /* HDexp2 */ #ifndef HDfabs - #define HDfabs(X) fabs(X) +#define HDfabs(X) fabs(X) #endif /* HDfabs */ /* use ABS() because fabsf() fabsl() are not common yet. */ #ifndef HDfabsf - #define HDfabsf(X) ABS(X) +#define HDfabsf(X) ABS(X) #endif /* HDfabsf */ #ifndef HDfabsl - #define HDfabsl(X) ABS(X) +#define HDfabsl(X) ABS(X) #endif /* HDfabsl */ #ifndef HDfclose - #define HDfclose(F) fclose(F) +#define HDfclose(F) fclose(F) #endif /* HDfclose */ #ifdef H5_HAVE_FCNTL - #ifndef HDfcntl - #define HDfcntl(F,C,...) fcntl(F,C,__VA_ARGS__) - #endif /* HDfcntl */ +#ifndef HDfcntl +#define HDfcntl(F, C, ...) fcntl(F, C, __VA_ARGS__) +#endif /* HDfcntl */ #endif /* H5_HAVE_FCNTL */ #ifndef HDfdopen - #define HDfdopen(N,S) fdopen(N,S) +#define HDfdopen(N, S) fdopen(N, S) #endif /* HDfdopen */ #ifndef HDfeof - #define HDfeof(F) feof(F) +#define HDfeof(F) feof(F) #endif /* HDfeof */ #ifndef HDferror - #define HDferror(F) ferror(F) +#define HDferror(F) ferror(F) #endif /* HDferror */ #ifndef HDfflush - #define HDfflush(F) fflush(F) +#define HDfflush(F) fflush(F) #endif /* HDfflush */ #ifndef HDfgetc - #define HDfgetc(F) fgetc(F) +#define HDfgetc(F) fgetc(F) #endif /* HDfgetc */ #ifndef HDfgetpos - #define HDfgetpos(F,P) fgetpos(F,P) +#define HDfgetpos(F, P) fgetpos(F, P) #endif /* HDfgetpos */ #ifndef HDfgets - #define HDfgets(S,N,F) fgets(S,N,F) +#define HDfgets(S, N, F) fgets(S, N, F) #endif /* HDfgets */ #ifndef HDfileno - #define HDfileno(F) fileno(F) +#define HDfileno(F) fileno(F) #endif /* HDfileno */ /* Since flock is so prevalent, always build these functions * when possible to avoid them becoming dead code. @@ -893,772 +891,770 @@ H5_DLL int Pflock(int fd, int operation); #endif /* H5_HAVE_FCNTL */ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDflock - /* NOTE: flock(2) is not present on all POSIX systems. - * If it is not present, we try a flock() equivalent based on - * fcntl(2), then fall back to a function that always fails if - * it is not present at all (Windows uses a separate Wflock() - * function). - */ - #if defined(H5_HAVE_FLOCK) - #define HDflock(F,L) flock(F,L) - #elif defined(H5_HAVE_FCNTL) - #define HDflock(F,L) Pflock(F,L) - #else - #define HDflock(F,L) Nflock(F,L) - #endif /* H5_HAVE_FLOCK */ +/* NOTE: flock(2) is not present on all POSIX systems. + * If it is not present, we try a flock() equivalent based on + * fcntl(2), then fall back to a function that always fails if + * it is not present at all (Windows uses a separate Wflock() + * function). + */ +#if defined(H5_HAVE_FLOCK) +#define HDflock(F, L) flock(F, L) +#elif defined(H5_HAVE_FCNTL) +#define HDflock(F, L) Pflock(F, L) +#else +#define HDflock(F, L) Nflock(F, L) +#endif /* H5_HAVE_FLOCK */ #endif /* HDflock */ #ifndef HDfloor - #define HDfloor(X) floor(X) +#define HDfloor(X) floor(X) #endif /* HDfloor */ #ifndef HDfmod - #define HDfmod(X,Y) fmod(X,Y) +#define HDfmod(X, Y) fmod(X, Y) #endif /* HDfmod */ #ifndef HDfopen - #define HDfopen(S,M) fopen(S,M) +#define HDfopen(S, M) fopen(S, M) #endif /* HDfopen */ #ifndef HDfork - #define HDfork() fork() +#define HDfork() fork() #endif /* HDfork */ #ifndef HDfpathconf - #define HDfpathconf(F,N) fpathconf(F,N) +#define HDfpathconf(F, N) fpathconf(F, N) #endif /* HDfpathconf */ -H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); +H5_DLL int HDfprintf(FILE *stream, const char *fmt, ...); #ifndef HDfputc - #define HDfputc(C,F) fputc(C,F) +#define HDfputc(C, F) fputc(C, F) #endif /* HDfputc */ #ifndef HDfputs - #define HDfputs(S,F) fputs(S,F) +#define HDfputs(S, F) fputs(S, F) #endif /* HDfputs */ #ifndef HDfread - #define HDfread(M,Z,N,F) fread(M,Z,N,F) +#define HDfread(M, Z, N, F) fread(M, Z, N, F) #endif /* HDfread */ #ifndef HDfree - #define HDfree(M) free(M) +#define HDfree(M) free(M) #endif /* HDfree */ #ifndef HDfreopen - #define HDfreopen(S,M,F) freopen(S,M,F) +#define HDfreopen(S, M, F) freopen(S, M, F) #endif /* HDfreopen */ #ifndef HDfrexp - #define HDfrexp(X,N) frexp(X,N) +#define HDfrexp(X, N) frexp(X, N) #endif /* HDfrexp */ /* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ #ifndef HDfrexpf - #ifdef H5_HAVE_FREXPF - #define HDfrexpf(X,N) frexpf(X,N) - #else /* H5_HAVE_FREXPF */ - #define HDfrexpf(X,N) frexp(X,N) - #endif /* H5_HAVE_FREXPF */ +#ifdef H5_HAVE_FREXPF +#define HDfrexpf(X, N) frexpf(X, N) +#else /* H5_HAVE_FREXPF */ +#define HDfrexpf(X, N) frexp(X, N) +#endif /* H5_HAVE_FREXPF */ #endif /* HDfrexpf */ #ifndef HDfrexpl - #ifdef H5_HAVE_FREXPL - #define HDfrexpl(X,N) frexpl(X,N) - #else /* H5_HAVE_FREXPL */ - #define HDfrexpl(X,N) frexp(X,N) - #endif /* H5_HAVE_FREXPL */ +#ifdef H5_HAVE_FREXPL +#define HDfrexpl(X, N) frexpl(X, N) +#else /* H5_HAVE_FREXPL */ +#define HDfrexpl(X, N) frexp(X, N) +#endif /* H5_HAVE_FREXPL */ #endif /* HDfrexpl */ /* fscanf() variable arguments */ #ifndef HDfseek - #define HDfseek(F,O,W) fseeko(F,O,W) +#define HDfseek(F, O, W) fseeko(F, O, W) #endif /* HDfseek */ #ifndef HDfsetpos - #define HDfsetpos(F,P) fsetpos(F,P) +#define HDfsetpos(F, P) fsetpos(F, P) #endif /* HDfsetpos */ #ifndef HDfstat - #define HDfstat(F,B) fstat(F,B) +#define HDfstat(F, B) fstat(F, B) #endif /* HDfstat */ #ifndef HDlstat - #define HDlstat(S,B) lstat(S,B) +#define HDlstat(S, B) lstat(S, B) #endif /* HDlstat */ #ifndef HDstat - #define HDstat(S,B) stat(S,B) +#define HDstat(S, B) stat(S, B) #endif /* HDstat */ #ifndef H5_HAVE_WIN32_API /* These definitions differ in Windows and are defined in * H5win32defs for that platform. */ -typedef struct stat h5_stat_t; -typedef off_t h5_stat_size_t; -#define HDoff_t off_t +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t #endif /* H5_HAVE_WIN32_API */ #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T #ifndef HDftell - #define HDftell(F) ftell(F) +#define HDftell(F) ftell(F) #endif /* HDftell */ #ifndef HDftruncate - #define HDftruncate(F,L) ftruncate(F,L) +#define HDftruncate(F, L) ftruncate(F, L) #endif /* HDftruncate */ #ifndef HDfwrite - #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) +#define HDfwrite(M, Z, N, F) fwrite(M, Z, N, F) #endif /* HDfwrite */ #ifndef HDgetc - #define HDgetc(F) getc(F) +#define HDgetc(F) getc(F) #endif /* HDgetc */ #ifndef HDgetchar - #define HDgetchar() getchar() +#define HDgetchar() getchar() #endif /* HDgetchar */ #ifndef HDgetcwd - #define HDgetcwd(S,Z) getcwd(S,Z) +#define HDgetcwd(S, Z) getcwd(S, Z) #endif /* HDgetcwd */ #ifndef HDgetdcwd - #define HDgetdcwd(D,S,Z) getcwd(S,Z) +#define HDgetdcwd(D, S, Z) getcwd(S, Z) #endif /* HDgetdcwd */ #ifndef HDgetdrive - #define HDgetdrive() 0 +#define HDgetdrive() 0 #endif /* HDgetdrive */ #ifndef HDgetegid - #define HDgetegid() getegid() +#define HDgetegid() getegid() #endif /* HDgetegid() */ #ifndef HDgetenv - #define HDgetenv(S) getenv(S) +#define HDgetenv(S) getenv(S) #endif /* HDgetenv */ #ifndef HDgeteuid - #define HDgeteuid() geteuid() +#define HDgeteuid() geteuid() #endif /* HDgeteuid */ #ifndef HDgetgid - #define HDgetgid() getgid() +#define HDgetgid() getgid() #endif /* HDgetgid */ #ifndef HDgetgrgid - #define HDgetgrgid(G) getgrgid(G) +#define HDgetgrgid(G) getgrgid(G) #endif /* HDgetgrgid */ #ifndef HDgetgrnam - #define HDgetgrnam(S) getgrnam(S) +#define HDgetgrnam(S) getgrnam(S) #endif /* HDgetgrnam */ #ifndef HDgetgroups - #define HDgetgroups(Z,G) getgroups(Z,G) +#define HDgetgroups(Z, G) getgroups(Z, G) #endif /* HDgetgroups */ #ifndef HDgethostbyaddr - #define HDgethostbyaddr(A,B,C) gethostbyaddr((A),(B),(C)) /* mirror VFD */ -#endif /* HDgethostbyaddr */ +#define HDgethostbyaddr(A, B, C) gethostbyaddr((A), (B), (C)) /* mirror VFD */ +#endif /* HDgethostbyaddr */ #ifndef HDgethostname - #define HDgethostname(N,L) gethostname(N,L) +#define HDgethostname(N, L) gethostname(N, L) #endif /* HDgethostname */ #ifndef HDgetlogin - #define HDgetlogin() getlogin() +#define HDgetlogin() getlogin() #endif /* HDgetlogin */ #ifndef HDgetpgrp - #define HDgetpgrp() getpgrp() +#define HDgetpgrp() getpgrp() #endif /* HDgetpgrp */ #ifndef HDgetpid - #define HDgetpid() getpid() +#define HDgetpid() getpid() #endif /* HDgetpid */ #ifndef HDgetppid - #define HDgetppid() getppid() +#define HDgetppid() getppid() #endif /* HDgetppid */ #ifndef HDgetpwnam - #define HDgetpwnam(S) getpwnam(S) +#define HDgetpwnam(S) getpwnam(S) #endif /* HDgetpwnam */ #ifndef HDgetpwuid - #define HDgetpwuid(U) getpwuid(U) +#define HDgetpwuid(U) getpwuid(U) #endif /* HDgetpwuid */ #ifndef HDgetrusage - #define HDgetrusage(X,S) getrusage(X,S) +#define HDgetrusage(X, S) getrusage(X, S) #endif /* HDgetrusage */ /* Don't define HDgets - gets() was deprecated in C99 and removed in C11 */ #ifdef HDgets - #undef HDgets +#undef HDgets #endif /* HDgets */ #ifndef HDgettimeofday - #define HDgettimeofday(S,P) gettimeofday(S,P) +#define HDgettimeofday(S, P) gettimeofday(S, P) #endif /* HDgettimeofday */ #ifndef HDclock_gettime - #define HDclock_gettime(C,T) clock_gettime(C,T) +#define HDclock_gettime(C, T) clock_gettime(C, T) #endif /* HDclock_gettime */ #ifndef HDgetuid - #define HDgetuid() getuid() +#define HDgetuid() getuid() #endif /* HDgetuid */ #ifndef HDgmtime - #define HDgmtime(T) gmtime(T) +#define HDgmtime(T) gmtime(T) #endif /* HDgmtime */ #ifndef HDhtonl - #define HDhtonl(X) htonl((X)) /* mirror VFD */ -#endif /* HDhtonl */ +#define HDhtonl(X) htonl((X)) /* mirror VFD */ +#endif /* HDhtonl */ #ifndef HDhtons - #define HDhtons(X) htons((X)) /* mirror VFD */ -#endif /* HDhtons */ +#define HDhtons(X) htons((X)) /* mirror VFD */ +#endif /* HDhtons */ #ifndef HDinet_addr - #define HDinet_addr(C) inet_addr((C)) /* mirror VFD */ -#endif /* HDinet_addr */ +#define HDinet_addr(C) inet_addr((C)) /* mirror VFD */ +#endif /* HDinet_addr */ #ifndef HDinet_ntoa - #define HDinet_ntoa(C) inet_ntoa((C)) /* mirror VFD */ -#endif /* HDinet_ntoa */ +#define HDinet_ntoa(C) inet_ntoa((C)) /* mirror VFD */ +#endif /* HDinet_ntoa */ #ifndef HDisalnum - #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ -#endif /* HDisalnum */ +#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ +#endif /* HDisalnum */ #ifndef HDisalpha - #define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ -#endif /* HDisalpha */ +#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ +#endif /* HDisalpha */ #ifndef HDisatty - #define HDisatty(F) isatty(F) +#define HDisatty(F) isatty(F) #endif /* HDisatty */ #ifndef HDiscntrl - #define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ -#endif /* HDiscntrl */ +#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ +#endif /* HDiscntrl */ #ifndef HDisdigit - #define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ -#endif /* HDisdigit */ +#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ +#endif /* HDisdigit */ #ifndef HDisgraph - #define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ -#endif /* HDisgraph */ +#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ +#endif /* HDisgraph */ #ifndef HDislower - #define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ -#endif /* HDislower */ +#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ +#endif /* HDislower */ #ifndef HDisnan - #define HDisnan(X) isnan(X) +#define HDisnan(X) isnan(X) #endif /* HDisnan */ #ifndef HDisprint - #define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ -#endif /* HDisprint */ +#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ +#endif /* HDisprint */ #ifndef HDispunct - #define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ -#endif /* HDispunct */ +#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ +#endif /* HDispunct */ #ifndef HDisspace - #define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ -#endif /* HDisspace */ +#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ +#endif /* HDisspace */ #ifndef HDisupper - #define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ -#endif /* HDisupper */ +#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ +#endif /* HDisupper */ #ifndef HDisxdigit - #define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ -#endif /* HDisxdigit */ +#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ +#endif /* HDisxdigit */ #ifndef HDkill - #define HDkill(P,S) kill(P,S) +#define HDkill(P, S) kill(P, S) #endif /* HDkill */ #ifndef HDlabs - #define HDlabs(X) labs(X) +#define HDlabs(X) labs(X) #endif /* HDlabs */ #ifndef HDldexp - #define HDldexp(X,N) ldexp(X,N) +#define HDldexp(X, N) ldexp(X, N) #endif /* HDldexp */ #ifndef HDldiv - #define HDldiv(X,Y) ldiv(X,Y) +#define HDldiv(X, Y) ldiv(X, Y) #endif /* HDldiv */ #ifndef HDlink - #define HDlink(OLD,NEW) link(OLD,NEW) +#define HDlink(OLD, NEW) link(OLD, NEW) #endif /* HDlink */ #ifndef HDlisten - #define HDlisten(A,B) listen((A),(B)) /* mirror VFD */ -#endif /* HDlisten */ +#define HDlisten(A, B) listen((A), (B)) /* mirror VFD */ +#endif /* HDlisten */ #ifndef HDllround - #define HDllround(V) llround(V) +#define HDllround(V) llround(V) #endif /* HDround */ #ifndef HDllroundf - #define HDllroundf(V) llroundf(V) +#define HDllroundf(V) llroundf(V) #endif /* HDllroundf */ #ifndef HDllroundl - #define HDllroundl(V) llroundl(V) +#define HDllroundl(V) llroundl(V) #endif /* HDllroundl */ #ifndef HDlocaleconv - #define HDlocaleconv() localeconv() +#define HDlocaleconv() localeconv() #endif /* HDlocaleconv */ #ifndef HDlocaltime - #define HDlocaltime(T) localtime(T) +#define HDlocaltime(T) localtime(T) #endif /* HDlocaltime */ #ifndef HDlog - #define HDlog(X) log(X) +#define HDlog(X) log(X) #endif /* HDlog */ #ifndef HDlog10 - #define HDlog10(X) log10(X) +#define HDlog10(X) log10(X) #endif /* HDlog10 */ #ifndef HDlongjmp - #define HDlongjmp(J,N) longjmp(J,N) +#define HDlongjmp(J, N) longjmp(J, N) #endif /* HDlongjmp */ #ifndef HDlround - #define HDlround(V) lround(V) +#define HDlround(V) lround(V) #endif /* HDround */ #ifndef HDlroundf - #define HDlroundf(V) lroundf(V) +#define HDlroundf(V) lroundf(V) #endif /* HDlroundf */ #ifndef HDlroundl - #define HDlroundl(V) lroundl(V) +#define HDlroundl(V) lroundl(V) #endif /* HDroundl */ #ifndef HDlseek - #define HDlseek(F,O,W) lseek(F,O,W) +#define HDlseek(F, O, W) lseek(F, O, W) #endif /* HDlseek */ #ifndef HDmalloc - #define HDmalloc(Z) malloc(Z) +#define HDmalloc(Z) malloc(Z) #endif /* HDmalloc */ #ifndef HDposix_memalign - #define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) +#define HDposix_memalign(P, A, Z) posix_memalign(P, A, Z) #endif /* HDposix_memalign */ #ifndef HDmblen - #define HDmblen(S,N) mblen(S,N) +#define HDmblen(S, N) mblen(S, N) #endif /* HDmblen */ #ifndef HDmbstowcs - #define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) +#define HDmbstowcs(P, S, Z) mbstowcs(P, S, Z) #endif /* HDmbstowcs */ #ifndef HDmbtowc - #define HDmbtowc(P,S,Z) mbtowc(P,S,Z) +#define HDmbtowc(P, S, Z) mbtowc(P, S, Z) #endif /* HDmbtowc */ #ifndef HDmemchr - #define HDmemchr(S,C,Z) memchr(S,C,Z) +#define HDmemchr(S, C, Z) memchr(S, C, Z) #endif /* HDmemchr */ #ifndef HDmemcmp - #define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) +#define HDmemcmp(X, Y, Z) memcmp(X, Y, Z) #endif /* HDmemcmp */ #ifndef HDmemcpy - #define HDmemcpy(X,Y,Z) memcpy(X,Y,Z) +#define HDmemcpy(X, Y, Z) memcpy(X, Y, Z) #endif /* HDmemcpy */ #ifndef HDmemmove - #define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) +#define HDmemmove(X, Y, Z) memmove((char *)(X), (const char *)(Y), Z) #endif /* HDmemmove */ #ifndef HDmemset - #define HDmemset(X,C,Z) memset(X,C,Z) +#define HDmemset(X, C, Z) memset(X, C, Z) #endif /* HDmemset */ #ifndef HDmkdir - #define HDmkdir(S,M) mkdir(S,M) +#define HDmkdir(S, M) mkdir(S, M) #endif /* HDmkdir */ #ifndef HDmkfifo - #define HDmkfifo(S,M) mkfifo(S,M) +#define HDmkfifo(S, M) mkfifo(S, M) #endif /* HDmkfifo */ #ifndef HDmktime - #define HDmktime(T) mktime(T) +#define HDmktime(T) mktime(T) #endif /* HDmktime */ #ifndef HDmodf - #define HDmodf(X,Y) modf(X,Y) +#define HDmodf(X, Y) modf(X, Y) #endif /* HDmodf */ #ifndef HDnanosleep - #define HDnanosleep(N, O) nanosleep(N, O) +#define HDnanosleep(N, O) nanosleep(N, O) #endif /* HDnanosleep */ #ifndef HDntohl - #define HDntohl(A) ntohl((A)) /* mirror VFD */ -#endif /* HDntohl */ +#define HDntohl(A) ntohl((A)) /* mirror VFD */ +#endif /* HDntohl */ #ifndef HDntohs - #define HDntohs(A) ntohs((A)) /* mirror VFD */ -#endif /* HDntohs */ +#define HDntohs(A) ntohs((A)) /* mirror VFD */ +#endif /* HDntohs */ #ifndef HDopen - #define HDopen(F,...) open(F,__VA_ARGS__) +#define HDopen(F, ...) open(F, __VA_ARGS__) #endif /* HDopen */ #ifndef HDopendir - #define HDopendir(S) opendir(S) +#define HDopendir(S) opendir(S) #endif /* HDopendir */ #ifndef HDpathconf - #define HDpathconf(S,N) pathconf(S,N) +#define HDpathconf(S, N) pathconf(S, N) #endif /* HDpathconf */ #ifndef HDpause - #define HDpause() pause() +#define HDpause() pause() #endif /* HDpause */ #ifndef HDperror - #define HDperror(S) perror(S) +#define HDperror(S) perror(S) #endif /* HDperror */ #ifndef HDpipe - #define HDpipe(F) pipe(F) +#define HDpipe(F) pipe(F) #endif /* HDpipe */ #ifndef HDpow - #define HDpow(X,Y) pow(X,Y) +#define HDpow(X, Y) pow(X, Y) #endif /* HDpow */ #ifndef HDpowf - #define HDpowf(X,Y) powf(X,Y) +#define HDpowf(X, Y) powf(X, Y) #endif /* HDpowf */ #ifndef HDpread - #define HDpread(F,B,C,O) pread(F,B,C,O) +#define HDpread(F, B, C, O) pread(F, B, C, O) #endif /* HDpread */ #ifndef HDprintf - #define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) +#define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) #endif /* HDprintf */ #ifndef HDputc - #define HDputc(C,F) putc(C,F) +#define HDputc(C, F) putc(C, F) #endif /* HDputc*/ #ifndef HDputchar - #define HDputchar(C) putchar(C) +#define HDputchar(C) putchar(C) #endif /* HDputchar */ #ifndef HDputs - #define HDputs(S) puts(S) +#define HDputs(S) puts(S) #endif /* HDputs */ #ifndef HDpwrite - #define HDpwrite(F,B,C,O) pwrite(F,B,C,O) +#define HDpwrite(F, B, C, O) pwrite(F, B, C, O) #endif /* HDpwrite */ #ifndef HDqsort - #define HDqsort(M,N,Z,F) qsort(M,N,Z,F) +#define HDqsort(M, N, Z, F) qsort(M, N, Z, F) #endif /* HDqsort*/ #ifndef HDraise - #define HDraise(N) raise(N) +#define HDraise(N) raise(N) #endif /* HDraise */ #ifdef H5_HAVE_RAND_R - #ifndef HDrandom - #define HDrandom() HDrand() - #endif /* HDrandom */ - H5_DLL int HDrand(void); - #ifndef HDsrandom - #define HDsrandom(S) HDsrand(S) - #endif /* HDsrandom */ - H5_DLL void HDsrand(unsigned int seed); +#ifndef HDrandom +#define HDrandom() HDrand() +#endif /* HDrandom */ +H5_DLL int HDrand(void); +#ifndef HDsrandom +#define HDsrandom(S) HDsrand(S) +#endif /* HDsrandom */ +H5_DLL void HDsrand(unsigned int seed); #elif defined(H5_HAVE_RANDOM) - #ifndef HDrand - #define HDrand() random() - #endif /* HDrand */ - #ifndef HDrandom - #define HDrandom() random() - #endif /* HDrandom */ - #ifndef HDsrand - #define HDsrand(S) srandom(S) - #endif /* HDsrand */ - #ifndef HDsrandom - #define HDsrandom(S) srandom(S) - #endif /* HDsrandom */ -#else /* H5_HAVE_RANDOM */ - #ifndef HDrand - #define HDrand() rand() - #endif /* HDrand */ - #ifndef HDrandom - #define HDrandom() rand() - #endif /* HDrandom */ - #ifndef HDsrand - #define HDsrand(S) srand(S) - #endif /* HDsrand */ - #ifndef HDsrandom - #define HDsrandom(S) srand(S) - #endif /* HDsrandom */ +#ifndef HDrand +#define HDrand() random() +#endif /* HDrand */ +#ifndef HDrandom +#define HDrandom() random() +#endif /* HDrandom */ +#ifndef HDsrand +#define HDsrand(S) srandom(S) +#endif /* HDsrand */ +#ifndef HDsrandom +#define HDsrandom(S) srandom(S) +#endif /* HDsrandom */ +#else /* H5_HAVE_RANDOM */ +#ifndef HDrand +#define HDrand() rand() +#endif /* HDrand */ +#ifndef HDrandom +#define HDrandom() rand() +#endif /* HDrandom */ +#ifndef HDsrand +#define HDsrand(S) srand(S) +#endif /* HDsrand */ +#ifndef HDsrandom +#define HDsrandom(S) srand(S) +#endif /* HDsrandom */ #endif /* H5_HAVE_RANDOM */ #ifndef HDread - #define HDread(F,M,Z) read(F,M,Z) +#define HDread(F, M, Z) read(F, M, Z) #endif /* HDread */ #ifndef HDreaddir - #define HDreaddir(D) readdir(D) +#define HDreaddir(D) readdir(D) #endif /* HDreaddir */ #ifndef HDrealloc - #define HDrealloc(M,Z) realloc(M,Z) +#define HDrealloc(M, Z) realloc(M, Z) #endif /* HDrealloc */ #ifndef HDrealpath - #define HDrealpath(F1,F2) realpath(F1,F2) +#define HDrealpath(F1, F2) realpath(F1, F2) #endif /* HDrealloc */ #ifndef HDremove - #define HDremove(S) remove(S) +#define HDremove(S) remove(S) #endif /* HDremove */ #ifndef HDrename - #define HDrename(OLD,NEW) rename(OLD,NEW) +#define HDrename(OLD, NEW) rename(OLD, NEW) #endif /* HDrename */ #ifndef HDrewind - #define HDrewind(F) rewind(F) +#define HDrewind(F) rewind(F) #endif /* HDrewind */ #ifndef HDrewinddir - #define HDrewinddir(D) rewinddir(D) +#define HDrewinddir(D) rewinddir(D) #endif /* HDrewinddir */ #ifndef HDround - #define HDround(V) round(V) +#define HDround(V) round(V) #endif /* HDround */ #ifndef HDroundf - #define HDroundf(V) roundf(V) +#define HDroundf(V) roundf(V) #endif /* HDroundf */ #ifndef HDroundl - #define HDroundl(V) roundl(V) +#define HDroundl(V) roundl(V) #endif /* HDroundl */ #ifndef HDrmdir - #define HDrmdir(S) rmdir(S) +#define HDrmdir(S) rmdir(S) #endif /* HDrmdir */ /* scanf() variable arguments */ #ifndef HDselect - #define HDselect(N,RD,WR,ER,T) select(N,RD,WR,ER,T) +#define HDselect(N, RD, WR, ER, T) select(N, RD, WR, ER, T) #endif /* HDsetbuf */ #ifndef HDsetbuf - #define HDsetbuf(F,S) setbuf(F,S) +#define HDsetbuf(F, S) setbuf(F, S) #endif /* HDsetbuf */ #ifndef HDsetenv - #define HDsetenv(N,V,O) setenv(N,V,O) +#define HDsetenv(N, V, O) setenv(N, V, O) #endif /* HDsetenv */ #ifndef HDsetgid - #define HDsetgid(G) setgid(G) +#define HDsetgid(G) setgid(G) #endif /* HDsetgid */ #ifndef HDsetjmp - #define HDsetjmp(J) setjmp(J) +#define HDsetjmp(J) setjmp(J) #endif /* HDsetjmp */ #ifndef HDsetlocale - #define HDsetlocale(N,S) setlocale(N,S) +#define HDsetlocale(N, S) setlocale(N, S) #endif /* HDsetlocale */ #ifndef HDsetpgid - #define HDsetpgid(P,PG) setpgid(P,PG) +#define HDsetpgid(P, PG) setpgid(P, PG) #endif /* HDsetpgid */ #ifndef HDsetsid - #define HDsetsid() setsid() +#define HDsetsid() setsid() #endif /* HDsetsid */ #ifndef HDsetsockopt - #define HDsetsockopt(A,B,C,D,E) setsockopt((A),(B),(C),(D),(E)) /* mirror VFD */ -#endif /* HDsetsockopt */ +#define HDsetsockopt(A, B, C, D, E) setsockopt((A), (B), (C), (D), (E)) /* mirror VFD */ +#endif /* HDsetsockopt */ #ifndef HDsetuid - #define HDsetuid(U) setuid(U) +#define HDsetuid(U) setuid(U) #endif /* HDsetuid */ #ifndef HDsetvbuf - #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, Z) #endif /* HDsetvbuf */ #ifndef HDshutdown - #define HDshutdown(A, B) shutdown((A),(B)) /* mirror VFD */ -#endif /* HDshutdown */ +#define HDshutdown(A, B) shutdown((A), (B)) /* mirror VFD */ +#endif /* HDshutdown */ #ifndef HDsigaction - #define HDsigaction(S,A,O) sigaction((S),(A),(O)) +#define HDsigaction(S, A, O) sigaction((S), (A), (O)) #endif /* HDsigaction */ #ifndef HDsigaddset - #define HDsigaddset(S,N) sigaddset(S,N) +#define HDsigaddset(S, N) sigaddset(S, N) #endif /* HDsigaddset */ #ifndef HDsigdelset - #define HDsigdelset(S,N) sigdelset(S,N) +#define HDsigdelset(S, N) sigdelset(S, N) #endif /* HDsigdelset */ #ifndef HDsigemptyset - #define HDsigemptyset(S) sigemptyset(S) +#define HDsigemptyset(S) sigemptyset(S) #endif /* HDsigemptyset */ #ifndef HDsigfillset - #define HDsigfillset(S) sigfillset(S) +#define HDsigfillset(S) sigfillset(S) #endif /* HDsigfillset */ #ifndef HDsigismember - #define HDsigismember(S,N) sigismember(S,N) +#define HDsigismember(S, N) sigismember(S, N) #endif /* HDsigismember */ #ifndef HDsiglongjmp - #define HDsiglongjmp(J,N) siglongjmp(J,N) +#define HDsiglongjmp(J, N) siglongjmp(J, N) #endif /* HDsiglongjmp */ #ifndef HDsignal - #define HDsignal(N,F) signal(N,F) +#define HDsignal(N, F) signal(N, F) #endif /* HDsignal */ #ifndef HDsigpending - #define HDsigpending(S) sigpending(S) +#define HDsigpending(S) sigpending(S) #endif /* HDsigpending */ #ifndef HDsigprocmask - #define HDsigprocmask(H,S,O) sigprocmask(H,S,O) +#define HDsigprocmask(H, S, O) sigprocmask(H, S, O) #endif /* HDsigprocmask */ #ifndef HDsigsetjmp - #define HDsigsetjmp(J,N) sigsetjmp(J,N) +#define HDsigsetjmp(J, N) sigsetjmp(J, N) #endif /* HDsigsetjmp */ #ifndef HDsigsuspend - #define HDsigsuspend(S) sigsuspend(S) +#define HDsigsuspend(S) sigsuspend(S) #endif /* HDsigsuspend */ #ifndef HDsin - #define HDsin(X) sin(X) +#define HDsin(X) sin(X) #endif /* HDsin */ #ifndef HDsinh - #define HDsinh(X) sinh(X) +#define HDsinh(X) sinh(X) #endif /* HDsinh */ #ifndef HDsleep - #define HDsleep(N) sleep(N) +#define HDsleep(N) sleep(N) #endif /* HDsleep */ #ifndef HDsnprintf - #define HDsnprintf snprintf /*varargs*/ -#endif /* HDsnprintf */ +#define HDsnprintf snprintf /*varargs*/ +#endif /* HDsnprintf */ #ifndef HDsocket - #define HDsocket(A,B,C) socket((A),(B),(C)) /* mirror VFD */ -#endif /* HDsocket */ +#define HDsocket(A, B, C) socket((A), (B), (C)) /* mirror VFD */ +#endif /* HDsocket */ #ifndef HDsprintf - #define HDsprintf sprintf /*varargs*/ -#endif /* HDsprintf */ +#define HDsprintf sprintf /*varargs*/ +#endif /* HDsprintf */ #ifndef HDsqrt - #define HDsqrt(X) sqrt(X) +#define HDsqrt(X) sqrt(X) #endif /* HDsqrt */ #ifndef HDsscanf - #define HDsscanf(S,FMT,...) sscanf(S,FMT,__VA_ARGS__) +#define HDsscanf(S, FMT, ...) sscanf(S, FMT, __VA_ARGS__) #endif /* HDsscanf */ #ifndef HDstrcat - #define HDstrcat(X,Y) strcat(X,Y) +#define HDstrcat(X, Y) strcat(X, Y) #endif /* HDstrcat */ #ifndef HDstrchr - #define HDstrchr(S,C) strchr(S,C) +#define HDstrchr(S, C) strchr(S, C) #endif /* HDstrchr */ #ifndef HDstrcmp - #define HDstrcmp(X,Y) strcmp(X,Y) +#define HDstrcmp(X, Y) strcmp(X, Y) #endif /* HDstrcmp */ #ifndef HDstrcasecmp - #define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#define HDstrcasecmp(X, Y) strcasecmp(X, Y) #endif /* HDstrcasecmp */ #ifndef HDstrcoll - #define HDstrcoll(X,Y) strcoll(X,Y) +#define HDstrcoll(X, Y) strcoll(X, Y) #endif /* HDstrcoll */ #ifndef HDstrcpy - #define HDstrcpy(X,Y) strcpy(X,Y) +#define HDstrcpy(X, Y) strcpy(X, Y) #endif /* HDstrcpy */ #ifndef HDstrcspn - #define HDstrcspn(X,Y) strcspn(X,Y) +#define HDstrcspn(X, Y) strcspn(X, Y) #endif /* HDstrcspn */ #ifndef HDstrerror - #define HDstrerror(N) strerror(N) +#define HDstrerror(N) strerror(N) #endif /* HDstrerror */ #ifndef HDstrftime - #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) +#define HDstrftime(S, Z, F, T) strftime(S, Z, F, T) #endif /* HDstrftime */ #ifndef HDstrlen - #define HDstrlen(S) strlen(S) +#define HDstrlen(S) strlen(S) #endif /* HDstrlen */ #ifndef HDstrncat - #define HDstrncat(X,Y,Z) strncat(X,Y,Z) +#define HDstrncat(X, Y, Z) strncat(X, Y, Z) #endif /* HDstrncat */ #ifndef HDstrncmp - #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) +#define HDstrncmp(X, Y, Z) strncmp(X, Y, Z) #endif /* HDstrncmp */ #ifndef HDstrncpy - #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) +#define HDstrncpy(X, Y, Z) strncpy(X, Y, Z) #endif /* HDstrncpy */ #ifndef HDstrpbrk - #define HDstrpbrk(X,Y) strpbrk(X,Y) +#define HDstrpbrk(X, Y) strpbrk(X, Y) #endif /* HDstrpbrk */ #ifndef HDstrrchr - #define HDstrrchr(S,C) strrchr(S,C) +#define HDstrrchr(S, C) strrchr(S, C) #endif /* HDstrrchr */ #ifndef HDstrspn - #define HDstrspn(X,Y) strspn(X,Y) +#define HDstrspn(X, Y) strspn(X, Y) #endif /* HDstrspn */ #ifndef HDstrstr - #define HDstrstr(X,Y) strstr(X,Y) +#define HDstrstr(X, Y) strstr(X, Y) #endif /* HDstrstr */ #ifndef HDstrtod - #define HDstrtod(S,R) strtod(S,R) +#define HDstrtod(S, R) strtod(S, R) #endif /* HDstrtod */ #ifndef HDstrtok - #define HDstrtok(X,Y) strtok(X,Y) +#define HDstrtok(X, Y) strtok(X, Y) #endif /* HDstrtok */ #ifndef HDstrtok_r - #define HDstrtok_r(X,Y,Z) strtok_r(X,Y,Z) +#define HDstrtok_r(X, Y, Z) strtok_r(X, Y, Z) #endif /* HDstrtok */ #ifndef HDstrtol - #define HDstrtol(S,R,N) strtol(S,R,N) +#define HDstrtol(S, R, N) strtol(S, R, N) #endif /* HDstrtol */ #ifndef HDstrtoll - #ifdef H5_HAVE_STRTOLL - #define HDstrtoll(S,R,N) strtoll(S,R,N) - #else - H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); - #endif /* H5_HAVE_STRTOLL */ +#ifdef H5_HAVE_STRTOLL +#define HDstrtoll(S, R, N) strtoll(S, R, N) +#else +H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); +#endif /* H5_HAVE_STRTOLL */ #endif /* HDstrtoll */ #ifndef HDstrtoul - #define HDstrtoul(S,R,N) strtoul(S,R,N) +#define HDstrtoul(S, R, N) strtoul(S, R, N) #endif /* HDstrtoul */ #ifndef HDstrtoull - #define HDstrtoull(S,R,N) strtoull(S,R,N) +#define HDstrtoull(S, R, N) strtoull(S, R, N) #endif /* HDstrtoul */ #ifndef HDstrxfrm - #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) +#define HDstrxfrm(X, Y, Z) strxfrm(X, Y, Z) #endif /* HDstrxfrm */ #ifdef H5_HAVE_SYMLINK - #ifndef HDsymlink - #define HDsymlink(F1,F2) symlink(F1,F2) - #endif /* HDsymlink */ +#ifndef HDsymlink +#define HDsymlink(F1, F2) symlink(F1, F2) +#endif /* HDsymlink */ #endif /* H5_HAVE_SYMLINK */ #ifndef HDsysconf - #define HDsysconf(N) sysconf(N) +#define HDsysconf(N) sysconf(N) #endif /* HDsysconf */ #ifndef HDsystem - #define HDsystem(S) system(S) +#define HDsystem(S) system(S) #endif /* HDsystem */ #ifndef HDtan - #define HDtan(X) tan(X) +#define HDtan(X) tan(X) #endif /* HDtan */ #ifndef HDtanh - #define HDtanh(X) tanh(X) +#define HDtanh(X) tanh(X) #endif /* HDtanh */ #ifndef HDtcdrain - #define HDtcdrain(F) tcdrain(F) +#define HDtcdrain(F) tcdrain(F) #endif /* HDtcdrain */ #ifndef HDtcflow - #define HDtcflow(F,A) tcflow(F,A) +#define HDtcflow(F, A) tcflow(F, A) #endif /* HDtcflow */ #ifndef HDtcflush - #define HDtcflush(F,N) tcflush(F,N) +#define HDtcflush(F, N) tcflush(F, N) #endif /* HDtcflush */ #ifndef HDtcgetattr - #define HDtcgetattr(F,T) tcgetattr(F,T) +#define HDtcgetattr(F, T) tcgetattr(F, T) #endif /* HDtcgetattr */ #ifndef HDtcgetpgrp - #define HDtcgetpgrp(F) tcgetpgrp(F) +#define HDtcgetpgrp(F) tcgetpgrp(F) #endif /* HDtcgetpgrp */ #ifndef HDtcsendbreak - #define HDtcsendbreak(F,N) tcsendbreak(F,N) +#define HDtcsendbreak(F, N) tcsendbreak(F, N) #endif /* HDtcsendbreak */ #ifndef HDtcsetattr - #define HDtcsetattr(F,O,T) tcsetattr(F,O,T) +#define HDtcsetattr(F, O, T) tcsetattr(F, O, T) #endif /* HDtcsetattr */ #ifndef HDtcsetpgrp - #define HDtcsetpgrp(F,N) tcsetpgrp(F,N) +#define HDtcsetpgrp(F, N) tcsetpgrp(F, N) #endif /* HDtcsetpgrp */ #ifndef HDtime - #define HDtime(T) time(T) +#define HDtime(T) time(T) #endif /* HDtime */ #ifndef HDtimes - #define HDtimes(T) times(T) +#define HDtimes(T) times(T) #endif /* HDtimes*/ #ifndef HDtimespeccmp #ifdef H5_HAVE_TIMESPECCMP - #define HDtimespeccmp(tsp, usp, cmp) timespeccmp(tsp, usp, cmp) +#define HDtimespeccmp(tsp, usp, cmp) timespeccmp(tsp, usp, cmp) #else -#define HDtimespeccmp(tsp, usp, cmp) \ - (((tsp)->tv_sec == (usp)->tv_sec) ? \ - ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ - ((tsp)->tv_sec cmp (usp)->tv_sec)) +#define HDtimespeccmp(tsp, usp, cmp) \ + (((tsp)->tv_sec == (usp)->tv_sec) ? ((tsp)->tv_nsec cmp(usp)->tv_nsec) : ((tsp)->tv_sec cmp(usp)->tv_sec)) #endif #endif /* HDtimespeccmp */ #ifndef HDtmpfile - #define HDtmpfile() tmpfile() +#define HDtmpfile() tmpfile() #endif /* HDtmpfile */ #ifndef HDtmpnam - #define HDtmpnam(S) tmpnam(S) +#define HDtmpnam(S) tmpnam(S) #endif /* HDtmpnam */ #ifndef HDtolower - #define HDtolower(C) tolower(C) +#define HDtolower(C) tolower(C) #endif /* HDtolower */ #ifndef HDtoupper - #define HDtoupper(C) toupper(C) +#define HDtoupper(C) toupper(C) #endif /* HDtoupper */ #ifndef HDttyname - #define HDttyname(F) ttyname(F) +#define HDttyname(F) ttyname(F) #endif /* HDttyname */ #ifndef HDtzset - #define HDtzset() tzset() +#define HDtzset() tzset() #endif /* HDtzset */ #ifndef HDumask - #define HDumask(N) umask(N) +#define HDumask(N) umask(N) #endif /* HDumask */ #ifndef HDuname - #define HDuname(S) uname(S) +#define HDuname(S) uname(S) #endif /* HDuname */ #ifndef HDungetc - #define HDungetc(C,F) ungetc(C,F) +#define HDungetc(C, F) ungetc(C, F) #endif /* HDungetc */ #ifndef HDunlink - #define HDunlink(S) unlink(S) +#define HDunlink(S) unlink(S) #endif /* HDunlink */ #ifndef HDutime - #define HDutime(S,T) utime(S,T) +#define HDutime(S, T) utime(S, T) #endif /* HDutime */ #ifndef HDva_arg - #define HDva_arg(A,T) va_arg(A,T) +#define HDva_arg(A, T) va_arg(A, T) #endif /* HDva_arg */ #ifndef HDva_copy -#define HDva_copy(D,S) va_copy(D,S) +#define HDva_copy(D, S) va_copy(D, S) #endif /* HDva_copy */ #ifndef HDva_end - #define HDva_end(A) va_end(A) +#define HDva_end(A) va_end(A) #endif /* HDva_end */ #ifndef HDva_start - #define HDva_start(A,P) va_start(A,P) +#define HDva_start(A, P) va_start(A, P) #endif /* HDva_start */ #ifndef HDvasprintf - #define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A) +#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) #endif /* HDvasprintf */ #ifndef HDvfprintf - #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) +#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) #endif /* HDvfprintf */ #ifndef HDvprintf - #define HDvprintf(FMT,A) vprintf(FMT,A) +#define HDvprintf(FMT, A) vprintf(FMT, A) #endif /* HDvprintf */ #ifndef HDvsprintf - #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) +#define HDvsprintf(S, FMT, A) vsprintf(S, FMT, A) #endif /* HDvsprintf */ #ifndef HDvsnprintf - #define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) +#define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) #endif /* HDvsnprintf */ #ifndef HDwait - #define HDwait(W) wait(W) +#define HDwait(W) wait(W) #endif /* HDwait */ #ifndef HDwaitpid - #define HDwaitpid(P,W,O) waitpid(P,W,O) +#define HDwaitpid(P, W, O) waitpid(P, W, O) #endif /* HDwaitpid */ #ifndef HDwcstombs - #define HDwcstombs(S,P,Z) wcstombs(S,P,Z) +#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) #endif /* HDwcstombs */ #ifndef HDwctomb - #define HDwctomb(S,C) wctomb(S,C) +#define HDwctomb(S, C) wctomb(S, C) #endif /* HDwctomb */ #ifndef HDwrite - #define HDwrite(F,M,Z) write(F,M,Z) +#define HDwrite(F, M, Z) write(F, M, Z) #endif /* HDwrite */ /* @@ -1666,32 +1662,32 @@ typedef off_t h5_stat_size_t; * define these in terms of macros. */ #if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); +extern char * strdup(const char *s); #endif #ifndef HDstrdup - #define HDstrdup(S) strdup(S) +#define HDstrdup(S) strdup(S) #endif /* HDstrdup */ /* Macro for "stringizing" an integer in the C preprocessor (use H5_TOSTRING) */ /* (use H5_TOSTRING, H5_STRINGIZE is just part of the implementation) */ #define H5_STRINGIZE(x) #x -#define H5_TOSTRING(x) H5_STRINGIZE(x) +#define H5_TOSTRING(x) H5_STRINGIZE(x) /* Macro for "glueing" together items, for re-scanning macros */ -#define H5_GLUE(x,y) x##y -#define H5_GLUE3(x,y,z) x##y##z -#define H5_GLUE4(w,x,y,z) w##x##y##z +#define H5_GLUE(x, y) x##y +#define H5_GLUE3(x, y, z) x##y##z +#define H5_GLUE4(w, x, y, z) w##x##y##z /* * A macro for detecting over/under-flow when casting between types */ #ifndef NDEBUG -#define H5_CHECK_OVERFLOW(var, vartype, casttype) \ -{ \ - casttype _tmp_overflow = (casttype)(var); \ - HDassert((var) == (vartype)_tmp_overflow); \ -} +#define H5_CHECK_OVERFLOW(var, vartype, casttype) \ + { \ + casttype _tmp_overflow = (casttype)(var); \ + HDassert((var) == (vartype)_tmp_overflow); \ + } #else /* NDEBUG */ #define H5_CHECK_OVERFLOW(var, vartype, casttype) #endif /* NDEBUG */ @@ -1700,49 +1696,46 @@ extern char *strdup(const char *s); * A macro for detecting over/under-flow when assigning between types */ #ifndef NDEBUG -#define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \ -{ \ - srctype _tmp_src = (srctype)(src); \ - dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ - (dst) = _tmp_dst; \ -} - -#define ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \ - (dst) = (dsttype)(src); - -#define ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ -{ \ - srctype _tmp_src = (srctype)(src); \ - dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ - (dst) = _tmp_dst; \ -} - -#define ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ - (dst) = (dsttype)(src); - -#define ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ -{ \ - srctype _tmp_src = (srctype)(src); \ - dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_dst >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ - (dst) = _tmp_dst; \ -} - -#define ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ -{ \ - srctype _tmp_src = (srctype)(src); \ - dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ - (dst) = _tmp_dst; \ -} - -#define ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \ - (dst) = (dsttype)(src); +#define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \ + { \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + HDassert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ + } + +#define ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) (dst) = (dsttype)(src); + +#define ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ + { \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + HDassert(_tmp_src >= 0); \ + HDassert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ + } + +#define ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) (dst) = (dsttype)(src); + +#define ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ + { \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + HDassert(_tmp_dst >= 0); \ + HDassert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ + } + +#define ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ + { \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + HDassert(_tmp_src >= 0); \ + HDassert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ + } + +#define ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) (dst) = (dsttype)(src); /* Include the generated overflow header file */ #include "H5overflow.h" @@ -1759,50 +1752,49 @@ extern char *strdup(const char *s); * The preprocessor does not expand macros in w##x##y##z, so * that will always generate the expected name. */ -#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ - ASSIGN_##srctype##_TO_##dsttype(dst,dsttype,src,srctype)\ +#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ + ASSIGN_##srctype##_TO_##dsttype(dst, dsttype, src, srctype) #else /* NDEBUG */ -#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ - (dst) = (dsttype)(src); +#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) (dst) = (dsttype)(src); #endif /* NDEBUG */ #if defined(H5_HAVE_WINDOW_PATH) /* directory delimiter for Windows: slash and backslash are acceptable on Windows */ -#define H5_DIR_SLASH_SEPC '/' -#define H5_DIR_SEPC '\\' -#define H5_DIR_SEPS "\\" -#define H5_CHECK_DELIMITER(SS) ((SS == H5_DIR_SEPC) || (SS == H5_DIR_SLASH_SEPC)) -#define H5_CHECK_ABSOLUTE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':') && (H5_CHECK_DELIMITER(NAME[2]))) -#define H5_CHECK_ABS_DRIVE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':')) -#define H5_CHECK_ABS_PATH(NAME) (H5_CHECK_DELIMITER(NAME[0])) - -#define H5_GET_LAST_DELIMITER(NAME, ptr) { \ - char *slash, *backslash; \ - \ - slash = HDstrrchr(NAME, H5_DIR_SLASH_SEPC); \ - backslash = HDstrrchr(NAME, H5_DIR_SEPC); \ - if(backslash > slash) \ - (ptr = backslash); \ - else \ - (ptr = slash); \ -} +#define H5_DIR_SLASH_SEPC '/' +#define H5_DIR_SEPC '\\' +#define H5_DIR_SEPS "\\" +#define H5_CHECK_DELIMITER(SS) ((SS == H5_DIR_SEPC) || (SS == H5_DIR_SLASH_SEPC)) +#define H5_CHECK_ABSOLUTE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':') && (H5_CHECK_DELIMITER(NAME[2]))) +#define H5_CHECK_ABS_DRIVE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':')) +#define H5_CHECK_ABS_PATH(NAME) (H5_CHECK_DELIMITER(NAME[0])) + +#define H5_GET_LAST_DELIMITER(NAME, ptr) \ + { \ + char *slash, *backslash; \ + \ + slash = HDstrrchr(NAME, H5_DIR_SLASH_SEPC); \ + backslash = HDstrrchr(NAME, H5_DIR_SEPC); \ + if (backslash > slash) \ + (ptr = backslash); \ + else \ + (ptr = slash); \ + } #else /* H5_HAVE_WINDOW_PATH */ -#define H5_DIR_SEPC '/' -#define H5_DIR_SEPS "/" -#define H5_CHECK_DELIMITER(SS) (SS == H5_DIR_SEPC) -#define H5_CHECK_ABSOLUTE(NAME) (H5_CHECK_DELIMITER(*NAME)) -#define H5_CHECK_ABS_DRIVE(NAME) (0) -#define H5_CHECK_ABS_PATH(NAME) (0) -#define H5_GET_LAST_DELIMITER(NAME, ptr) ptr = HDstrrchr(NAME, H5_DIR_SEPC); +#define H5_DIR_SEPC '/' +#define H5_DIR_SEPS "/" +#define H5_CHECK_DELIMITER(SS) (SS == H5_DIR_SEPC) +#define H5_CHECK_ABSOLUTE(NAME) (H5_CHECK_DELIMITER(*NAME)) +#define H5_CHECK_ABS_DRIVE(NAME) (0) +#define H5_CHECK_ABS_PATH(NAME) (0) +#define H5_GET_LAST_DELIMITER(NAME, ptr) ptr = HDstrrchr(NAME, H5_DIR_SEPC); #endif /* H5_HAVE_WINDOW_PATH */ -#define H5_COLON_SEPC ':' - +#define H5_COLON_SEPC ':' /* Use FUNC to safely handle variations of C99 __func__ keyword handling */ #ifdef H5_HAVE_C99_FUNC @@ -1824,41 +1816,41 @@ extern char *strdup(const char *s); * information about the package in H5_init_library(). */ typedef enum { - H5_PKG_A, /* Attributes */ - H5_PKG_AC, /* Metadata cache */ - H5_PKG_B, /* B-trees */ - H5_PKG_D, /* Datasets */ - H5_PKG_E, /* Error handling */ - H5_PKG_F, /* Files */ - H5_PKG_G, /* Groups */ - H5_PKG_HG, /* Global heaps */ - H5_PKG_HL, /* Local heaps */ - H5_PKG_I, /* IDs */ - H5_PKG_M, /* Maps */ - H5_PKG_MF, /* File memory management */ - H5_PKG_MM, /* Core memory management */ - H5_PKG_O, /* Object headers */ - H5_PKG_P, /* Property lists */ - H5_PKG_S, /* Dataspaces */ - H5_PKG_T, /* Datatypes */ - H5_PKG_V, /* Vector functions */ - H5_PKG_VL, /* VOL functions */ - H5_PKG_Z, /* Raw data filters */ - H5_NPKGS /* Must be last */ + H5_PKG_A, /* Attributes */ + H5_PKG_AC, /* Metadata cache */ + H5_PKG_B, /* B-trees */ + H5_PKG_D, /* Datasets */ + H5_PKG_E, /* Error handling */ + H5_PKG_F, /* Files */ + H5_PKG_G, /* Groups */ + H5_PKG_HG, /* Global heaps */ + H5_PKG_HL, /* Local heaps */ + H5_PKG_I, /* IDs */ + H5_PKG_M, /* Maps */ + H5_PKG_MF, /* File memory management */ + H5_PKG_MM, /* Core memory management */ + H5_PKG_O, /* Object headers */ + H5_PKG_P, /* Property lists */ + H5_PKG_S, /* Dataspaces */ + H5_PKG_T, /* Datatypes */ + H5_PKG_V, /* Vector functions */ + H5_PKG_VL, /* VOL functions */ + H5_PKG_Z, /* Raw data filters */ + H5_NPKGS /* Must be last */ } H5_pkg_t; typedef struct H5_debug_open_stream_t { - FILE *stream; /* Open output stream */ - struct H5_debug_open_stream_t *next; /* Next open output stream */ + FILE * stream; /* Open output stream */ + struct H5_debug_open_stream_t *next; /* Next open output stream */ } H5_debug_open_stream_t; typedef struct H5_debug_t { - FILE *trace; /*API trace output stream */ - hbool_t ttop; /*Show only top-level calls? */ - hbool_t ttimes; /*Show trace event times? */ + FILE * trace; /*API trace output stream */ + hbool_t ttop; /*Show only top-level calls? */ + hbool_t ttimes; /*Show trace event times? */ struct { - const char *name; /*package name */ - FILE *stream; /*output stream or NULL */ + const char *name; /*package name */ + FILE * stream; /*output stream or NULL */ } pkg[H5_NPKGS]; H5_debug_open_stream_t *open_stream; /* Stack of open output streams */ } H5_debug_t; @@ -1867,8 +1859,8 @@ typedef struct H5_debug_t { extern hbool_t H5_coll_api_sanity_check_g; #endif /* H5_HAVE_PARALLEL */ -extern H5_debug_t H5_debug_g; -#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) +extern H5_debug_t H5_debug_g; +#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) /* Do not use const else AIX strings does not show it. */ extern char H5libhdf5_settings[]; /* embedded library information */ @@ -1887,80 +1879,79 @@ extern char H5libhdf5_settings[]; /* embedded library information */ */ #ifdef H5_DEBUG_API -#define H5TRACE_DECL \ - const char *RTYPE = NULL; \ - double CALLTIME; - -#define H5TRACE0(R,T) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T) -#define H5TRACE1(R,T,A0) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0) -#define H5TRACE2(R,T,A0,A1) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1) -#define H5TRACE3(R,T,A0,A1,A2) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2) -#define H5TRACE4(R,T,A0,A1,A2,A3) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3) -#define H5TRACE5(R,T,A0,A1,A2,A3,A4) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4) -#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5) -#define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6) -#define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7) -#define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7, \ - #A8,A8) -#define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7, \ - #A8,A8,#A9,A9) -#define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7, \ - #A8,A8,#A9,A9,#A10,A10) -#define H5TRACE12(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7, \ - #A8,A8,#A9,A9,#A10,A10,#A11,A11) - -#define H5TRACE_RETURN(V) \ - if (RTYPE) { \ - H5_trace(&CALLTIME, FUNC, RTYPE, NULL, V); \ - RTYPE = NULL; \ - } +#define H5TRACE_DECL \ + const char *RTYPE = NULL; \ + double CALLTIME; + +#define H5TRACE0(R, T) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T) +#define H5TRACE1(R, T, A0) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0) +#define H5TRACE2(R, T, A0, A1) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1) +#define H5TRACE3(R, T, A0, A1, A2) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2) +#define H5TRACE4(R, T, A0, A1, A2, A3) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3) +#define H5TRACE5(R, T, A0, A1, A2, A3, A4) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4) +#define H5TRACE6(R, T, A0, A1, A2, A3, A4, A5) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5) +#define H5TRACE7(R, T, A0, A1, A2, A3, A4, A5, A6) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6) +#define H5TRACE8(R, T, A0, A1, A2, A3, A4, A5, A6, A7) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, A7) +#define H5TRACE9(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, \ + A7, #A8, A8) +#define H5TRACE10(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, \ + A7, #A8, A8, #A9, A9) +#define H5TRACE11(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, \ + A7, #A8, A8, #A9, A9, #A10, A10) +#define H5TRACE12(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, \ + A7, #A8, A8, #A9, A9, #A10, A10, #A11, A11) + +#define H5TRACE_RETURN(V) \ + if (RTYPE) { \ + H5_trace(&CALLTIME, FUNC, RTYPE, NULL, V); \ + RTYPE = NULL; \ + } #else -#define H5TRACE_DECL /*void*/ -#define H5TRACE0(R,T) /*void*/ -#define H5TRACE1(R,T,A0) /*void*/ -#define H5TRACE2(R,T,A0,A1) /*void*/ -#define H5TRACE3(R,T,A0,A1,A2) /*void*/ -#define H5TRACE4(R,T,A0,A1,A2,A3) /*void*/ -#define H5TRACE5(R,T,A0,A1,A2,A3,A4) /*void*/ -#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) /*void*/ -#define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) /*void*/ -#define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) /*void*/ -#define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) /*void*/ -#define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) /*void*/ -#define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) /*void*/ -#define H5TRACE12(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) /*void*/ -#define H5TRACE_RETURN(V) /*void*/ -#endif /* H5_DEBUG_API */ +#define H5TRACE_DECL /*void*/ +#define H5TRACE0(R, T) /*void*/ +#define H5TRACE1(R, T, A0) /*void*/ +#define H5TRACE2(R, T, A0, A1) /*void*/ +#define H5TRACE3(R, T, A0, A1, A2) /*void*/ +#define H5TRACE4(R, T, A0, A1, A2, A3) /*void*/ +#define H5TRACE5(R, T, A0, A1, A2, A3, A4) /*void*/ +#define H5TRACE6(R, T, A0, A1, A2, A3, A4, A5) /*void*/ +#define H5TRACE7(R, T, A0, A1, A2, A3, A4, A5, A6) /*void*/ +#define H5TRACE8(R, T, A0, A1, A2, A3, A4, A5, A6, A7) /*void*/ +#define H5TRACE9(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8) /*void*/ +#define H5TRACE10(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) /*void*/ +#define H5TRACE11(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) /*void*/ +#define H5TRACE12(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) /*void*/ +#define H5TRACE_RETURN(V) /*void*/ +#endif /* H5_DEBUG_API */ H5_DLL double H5_trace(const double *calltime, const char *func, const char *type, ...); - /*------------------------------------------------------------------------- * Purpose: Register function entry for library initialization and code * profiling. @@ -1990,36 +1981,38 @@ H5_DLL double H5_trace(const double *calltime, const char *func, const char *typ * - Underscore at position 4 if position 3 is uppercase or a digit. * Handles H5XY_. */ -#define H5_IS_API(S) (\ - '_'!=((const char *)S)[2] /* underscore at position 2 */ \ - && '_'!=((const char *)S)[3] /* underscore at position 3 */ \ - && !( /* NOT */ \ - ((const char *)S)[4] /* pos 4 exists */ \ - && (HDisupper(S[3]) || HDisdigit(S[3])) /* pos 3 dig | uc */ \ - && '_'==((const char *)S)[4] /* pos 4 underscore */ \ - )\ -) +#define H5_IS_API(S) \ + ('_' != ((const char *)S)[2] /* underscore at position 2 */ \ + && '_' != ((const char *)S)[3] /* underscore at position 3 */ \ + && !( /* NOT */ \ + ((const char *)S)[4] /* pos 4 exists */ \ + && (HDisupper(S[3]) || HDisdigit(S[3])) /* pos 3 dig | uc */ \ + && '_' == ((const char *)S)[4] /* pos 4 underscore */ \ + )) /* `S' is the name of a function which is being tested to check if it's */ /* a public API function */ -#define H5_IS_PUB(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && HDislower(S[2])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && HDislower(S[3])) || \ - (!S[4] || ((HDisdigit(S[3]) || HDisupper(S[3])) && HDislower(S[4])))) +#define H5_IS_PUB(S) \ + (((HDisdigit(S[1]) || HDisupper(S[1])) && HDislower(S[2])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && HDislower(S[3])) || \ + (!S[4] || ((HDisdigit(S[3]) || HDisupper(S[3])) && HDislower(S[4])))) /* `S' is the name of a function which is being tested to check if it's */ /* a private library function */ -#define H5_IS_PRIV(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && HDislower(S[3])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && HDislower(S[4])) || \ - ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && HDislower(S[5]))) +#define H5_IS_PRIV(S) \ + (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && HDislower(S[3])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && HDislower(S[4])) || \ + ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && HDislower(S[5]))) /* `S' is the name of a function which is being tested to check if it's */ /* a package private function */ -#define H5_IS_PKG(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && '_' == S[3] && HDislower(S[4])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && '_' == S[4] && HDislower(S[5])) || \ - ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && '_' == S[5] && HDislower(S[6]))) +#define H5_IS_PKG(S) \ + (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && '_' == S[3] && HDislower(S[4])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && '_' == S[4] && HDislower(S[5])) || \ + ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && '_' == S[5] && HDislower(S[6]))) /* global library version information string */ -extern char H5_lib_vers_info_g[]; +extern char H5_lib_vers_info_g[]; #include "H5TSprivate.h" @@ -2028,9 +2021,9 @@ extern char H5_lib_vers_info_g[]; /* replacement structure for original global variable */ typedef struct H5_api_struct { - H5TS_mutex_t init_lock; /* API entrance mutex */ - hbool_t H5_libinit_g; /* Has the library been initialized? */ - hbool_t H5_libterm_g; /* Is the library being shutdown? */ + H5TS_mutex_t init_lock; /* API entrance mutex */ + hbool_t H5_libinit_g; /* Has the library been initialized? */ + hbool_t H5_libterm_g; /* Is the library being shutdown? */ } H5_api_t; /* Macros for accessing the global variables */ @@ -2045,17 +2038,13 @@ typedef struct H5_api_struct { #endif /* Macros for threadsafe HDF-5 Phase I locks */ -#define H5_API_LOCK \ - H5TS_mutex_lock(&H5_g.init_lock); -#define H5_API_UNLOCK \ - H5TS_mutex_unlock(&H5_g.init_lock); +#define H5_API_LOCK H5TS_mutex_lock(&H5_g.init_lock); +#define H5_API_UNLOCK H5TS_mutex_unlock(&H5_g.init_lock); /* Macros for thread cancellation-safe mechanism */ -#define H5_API_UNSET_CANCEL \ - H5TS_cancel_count_inc(); +#define H5_API_UNSET_CANCEL H5TS_cancel_count_inc(); -#define H5_API_SET_CANCEL \ - H5TS_cancel_count_dec(); +#define H5_API_SET_CANCEL H5TS_cancel_count_dec(); extern H5_api_t H5_g; @@ -2073,8 +2062,8 @@ extern H5_api_t H5_g; #define H5_API_SET_CANCEL /* extern global variables */ -extern hbool_t H5_libinit_g; /* Has the library been initialized? */ -extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ +extern hbool_t H5_libinit_g; /* Has the library been initialized? */ +extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ /* Macros for accessing the global variables */ #define H5_INIT_GLOBAL (H5_libinit_g) @@ -2087,41 +2076,41 @@ extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ /* Include required function stack header */ #include "H5CSprivate.h" -#define H5_PUSH_FUNC H5CS_push(FUNC); -#define H5_POP_FUNC H5CS_pop(); -#else /* H5_HAVE_CODESTACK */ -#define H5_PUSH_FUNC /* void */ -#define H5_POP_FUNC /* void */ -#endif /* H5_HAVE_CODESTACK */ +#define H5_PUSH_FUNC H5CS_push(FUNC); +#define H5_POP_FUNC H5CS_pop(); +#else /* H5_HAVE_CODESTACK */ +#define H5_PUSH_FUNC /* void */ +#define H5_POP_FUNC /* void */ +#endif /* H5_HAVE_CODESTACK */ #ifdef H5_HAVE_MPE -extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ +extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ #endif /* Macros for referencing package initialization symbols */ -#define H5_PACKAGE_INIT_VAR(x) H5_GLUE(x, _init_g) -#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __init_package) +#define H5_PACKAGE_INIT_VAR(x) H5_GLUE(x, _init_g) +#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __init_package) /* Macros for defining package initialization routines */ #ifdef H5_MY_PKG -#define H5_PKG_INIT_VAR H5_PACKAGE_INIT_VAR(H5_MY_PKG) -#define H5_PKG_INIT_FUNC H5_PACKAGE_INIT_FUNC(H5_MY_PKG) -#define H5_PACKAGE_YES_INIT(err) \ - /* Initialize this interface or bust */ \ - if(!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) { \ - H5_PKG_INIT_VAR = TRUE; \ - if(H5_PKG_INIT_FUNC() < 0) { \ - H5_PKG_INIT_VAR = FALSE; \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "interface initialization failed") \ - } \ +#define H5_PKG_INIT_VAR H5_PACKAGE_INIT_VAR(H5_MY_PKG) +#define H5_PKG_INIT_FUNC H5_PACKAGE_INIT_FUNC(H5_MY_PKG) +#define H5_PACKAGE_YES_INIT(err) \ + /* Initialize this interface or bust */ \ + if (!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) { \ + H5_PKG_INIT_VAR = TRUE; \ + if (H5_PKG_INIT_FUNC() < 0) { \ + H5_PKG_INIT_VAR = FALSE; \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "interface initialization failed") \ + } \ } -#define H5_PACKAGE_NO_INIT(err) \ - /* Initialize this interface or bust */ \ - if(!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) \ +#define H5_PACKAGE_NO_INIT(err) \ + /* Initialize this interface or bust */ \ + if (!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) \ H5_PKG_INIT_VAR = TRUE; -#define H5_PACKAGE_INIT(pkg_init, err) H5_GLUE3(H5_PACKAGE_, pkg_init, _INIT)(err) +#define H5_PACKAGE_INIT(pkg_init, err) H5_GLUE3(H5_PACKAGE_, pkg_init, _INIT)(err) #else /* H5_MY_PKG */ -#define H5_PKG_INIT_VAR (TRUE) +#define H5_PKG_INIT_VAR (TRUE) #define H5_PACKAGE_INIT(pkg_init, err) #endif /* H5_MY_PKG */ @@ -2131,132 +2120,136 @@ H5_DLL herr_t H5CX_push(void); H5_DLL herr_t H5CX_pop(void); #ifndef NDEBUG -#define FUNC_ENTER_CHECK_NAME(asrt) \ - { \ - static hbool_t func_check = FALSE; \ - \ - if(!func_check) { \ - /* Check function naming status */ \ - HDassert(asrt && "Function naming conventions are incorrect - check H5_IS_API|PUB|PRIV|PKG macros in H5private.h (this is usually due to an incorrect number of underscores)"); \ - \ - /* Don't check again */ \ - func_check = TRUE; \ - } /* end if */ \ - } /* end scope */ -#else /* NDEBUG */ +#define FUNC_ENTER_CHECK_NAME(asrt) \ + { \ + static hbool_t func_check = FALSE; \ + \ + if (!func_check) { \ + /* Check function naming status */ \ + HDassert(asrt && \ + "Function naming conventions are incorrect - check H5_IS_API|PUB|PRIV|PKG macros in " \ + "H5private.h (this is usually due to an incorrect number of underscores)"); \ + \ + /* Don't check again */ \ + func_check = TRUE; \ + } /* end if */ \ + } /* end scope */ +#else /* NDEBUG */ #define FUNC_ENTER_CHECK_NAME(asrt) #endif /* NDEBUG */ - -#define FUNC_ENTER_COMMON(asrt) \ - hbool_t err_occurred = FALSE; \ - \ +#define FUNC_ENTER_COMMON(asrt) \ + hbool_t err_occurred = FALSE; \ + \ FUNC_ENTER_CHECK_NAME(asrt); -#define FUNC_ENTER_COMMON_NOERR(asrt) \ - FUNC_ENTER_CHECK_NAME(asrt); +#define FUNC_ENTER_COMMON_NOERR(asrt) FUNC_ENTER_CHECK_NAME(asrt); /* Threadsafety initialization code for API routines */ -#define FUNC_ENTER_API_THREADSAFE \ - /* Initialize the thread-safe code */ \ - H5_FIRST_THREAD_INIT \ - \ - /* Grab the mutex for the library */ \ - H5_API_UNSET_CANCEL \ - H5_API_LOCK +#define FUNC_ENTER_API_THREADSAFE \ + /* Initialize the thread-safe code */ \ + H5_FIRST_THREAD_INIT \ + \ + /* Grab the mutex for the library */ \ + H5_API_UNSET_CANCEL \ + H5_API_LOCK /* Local variables for API routines */ -#define FUNC_ENTER_API_VARS \ - MPE_LOG_VARS \ +#define FUNC_ENTER_API_VARS \ + MPE_LOG_VARS \ H5TRACE_DECL -#define FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ +#define FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ FUNC_ENTER_API_THREADSAFE; -#define FUNC_ENTER_API_INIT(err) \ - /* Initialize the library */ \ - if(!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ - H5_INIT_GLOBAL = TRUE; \ - if(H5_init_library() < 0) \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "library initialization failed") \ - } /* end if */ \ - \ - /* Initialize the package, if appropriate */ \ +#define FUNC_ENTER_API_INIT(err) \ + /* Initialize the library */ \ + if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ + H5_INIT_GLOBAL = TRUE; \ + if (H5_init_library() < 0) \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "library initialization failed") \ + } /* end if */ \ + \ + /* Initialize the package, if appropriate */ \ H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) -#define FUNC_ENTER_API_PUSH(err) \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Push the API context */ \ - if(H5CX_push() < 0) \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context") \ - \ +#define FUNC_ENTER_API_PUSH(err) \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Push the API context */ \ + if (H5CX_push() < 0) \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context") \ + \ BEGIN_MPE_LOG #include "H5FDvfd_swmr_private.h" -#define VFD_SWMR_ENTER(err) \ - do { \ - /* TBD assert that the API lock is held. The API lock */ \ - /* synchronizes access to `vfd_swmr_api_entries_g` */ \ - if (vfd_swmr_api_entries_g++ > 0) \ - ; /* Do nothing: we are *re-*entering the API. */ \ - else if (TAILQ_EMPTY(&eot_queue_g)) \ - ; /* Nothing to do. */ \ - else if (H5F_vfd_swmr_process_eot_queue(true) < 0) { \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, \ - "error processing EOT queue") \ - } \ +#define VFD_SWMR_ENTER(err) \ + do { \ + /* TBD assert that the API lock is held. The API lock */ \ + /* synchronizes access to `vfd_swmr_api_entries_g` */ \ + if (vfd_swmr_api_entries_g++ > 0) \ + ; /* Do nothing: we are *re-*entering the API. */ \ + else if (TAILQ_EMPTY(&eot_queue_g)) \ + ; /* Nothing to do. */ \ + else if (H5F_vfd_swmr_process_eot_queue(true) < 0) { \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "error processing EOT queue") \ + } \ } while (0) -#define VFD_SWMR_LEAVE(err) \ - do { \ - /* TBD assert that the API lock is held. The API lock */ \ - /* synchronizes access to `vfd_swmr_api_entries_g` */ \ - if (--vfd_swmr_api_entries_g > 0) \ - ; /* Do nothing: we are still in an API call. */ \ - else if (err_occurred) \ - ; /* Do nothing: an error occurred. */ \ - else if (TAILQ_EMPTY(&eot_queue_g)) \ - ; /* Nothing to do. */ \ - else if (H5F_vfd_swmr_process_eot_queue(false) < 0) { \ - HDONE_ERROR(H5E_FUNC, H5E_CANTSET, err, \ - "error processing EOT queue") \ - } \ +#define VFD_SWMR_LEAVE(err) \ + do { \ + /* TBD assert that the API lock is held. The API lock */ \ + /* synchronizes access to `vfd_swmr_api_entries_g` */ \ + if (--vfd_swmr_api_entries_g > 0) \ + ; /* Do nothing: we are still in an API call. */ \ + else if (err_occurred) \ + ; /* Do nothing: an error occurred. */ \ + else if (TAILQ_EMPTY(&eot_queue_g)) \ + ; /* Nothing to do. */ \ + else if (H5F_vfd_swmr_process_eot_queue(false) < 0) { \ + HDONE_ERROR(H5E_FUNC, H5E_CANTSET, err, "error processing EOT queue") \ + } \ } while (0) /* Use this macro for all "normal" API functions */ -#define FUNC_ENTER_API(err) {{ \ - FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_INIT(err); \ - FUNC_ENTER_API_PUSH(err); \ - VFD_SWMR_ENTER(err); \ - /* Clear thread error stack entering public functions */ \ - H5E_clear_stack(NULL); \ - { +#define FUNC_ENTER_API(err) \ + { \ + { \ + FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_INIT(err); \ + FUNC_ENTER_API_PUSH(err); \ + VFD_SWMR_ENTER(err); \ + /* Clear thread error stack entering public functions */ \ + H5E_clear_stack(NULL); \ + { /* Use this macro when VFD SWMR EOT is not used on entering an API function */ -#define FUNC_ENTER_API_NO_EOT(err) {{ \ - FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_INIT(err); \ - FUNC_ENTER_API_PUSH(err); \ - /* Clear thread error stack entering public functions */ \ - H5E_clear_stack(NULL); \ - { +#define FUNC_ENTER_API_NO_EOT(err) \ + { \ + { \ + FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_INIT(err); \ + FUNC_ENTER_API_PUSH(err); \ + /* Clear thread error stack entering public functions */ \ + H5E_clear_stack(NULL); \ + { /* * Use this macro for API functions that shouldn't clear the error stack * like H5Eprint and H5Ewalk. */ -#define FUNC_ENTER_API_NOCLEAR(err) {{ \ - FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_INIT(err); \ - FUNC_ENTER_API_PUSH(err); \ - VFD_SWMR_ENTER(err); \ - { +#define FUNC_ENTER_API_NOCLEAR(err) \ + { \ + { \ + FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_INIT(err); \ + FUNC_ENTER_API_PUSH(err); \ + VFD_SWMR_ENTER(err); \ + { /* * Use this macro for API functions that shouldn't perform _any_ initialization @@ -2265,11 +2258,14 @@ H5_DLL herr_t H5CX_pop(void); * wrappers (e.g. H5VLfile_create, H5VLdataset_read, etc.), etc. * */ -#define FUNC_ENTER_API_NOINIT {{{ \ - FUNC_ENTER_API_COMMON \ - H5_PUSH_FUNC \ - BEGIN_MPE_LOG \ - { +#define FUNC_ENTER_API_NOINIT \ + { \ + { \ + { \ + FUNC_ENTER_API_COMMON \ + H5_PUSH_FUNC \ + BEGIN_MPE_LOG \ + { /* * Use this macro for API functions that shouldn't perform _any_ initialization @@ -2278,12 +2274,16 @@ H5_DLL herr_t H5CX_pop(void); * are: H5close, H5check_version, etc. * */ -#define FUNC_ENTER_API_NOINIT_NOERR_NOFS {{{{ \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ - FUNC_ENTER_API_THREADSAFE; \ - BEGIN_MPE_LOG \ - { +#define FUNC_ENTER_API_NOINIT_NOERR_NOFS \ + { \ + { \ + { \ + { \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ + FUNC_ENTER_API_THREADSAFE; \ + BEGIN_MPE_LOG \ + { /* * Use this macro for API functions that should only perform initialization @@ -2291,31 +2291,38 @@ H5_DLL herr_t H5CX_pop(void); * function name, start MPE logging, etc) examples are: H5open. * */ -#define FUNC_ENTER_API_NOPUSH(err) {{{{{ \ - FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ - FUNC_ENTER_API_THREADSAFE; \ - FUNC_ENTER_API_INIT(err); \ - { +#define FUNC_ENTER_API_NOPUSH(err) \ + { \ + { \ + { \ + { \ + { \ + FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ + FUNC_ENTER_API_THREADSAFE; \ + FUNC_ENTER_API_INIT(err); \ + { /* Note: this macro only works when there's _no_ interface initialization routine for the module */ -#define FUNC_ENTER_NOAPI_INIT(err) \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ - \ - /* Push the name of this function on the function stack */ \ +#define FUNC_ENTER_NOAPI_INIT(err) \ + /* Initialize the package, if appropriate */ \ + H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ + \ + /* Push the name of this function on the function stack */ \ H5_PUSH_FUNC /* Use this macro for all "normal" non-API functions */ -#define FUNC_ENTER_NOAPI(err) { \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - FUNC_ENTER_NOAPI_INIT(err) \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI(err) \ + { \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + FUNC_ENTER_NOAPI_INIT(err) \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for all non-API functions, which propagate errors, but don't issue them */ -#define FUNC_ENTER_NOAPI_NOERR { \ - FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ - FUNC_ENTER_NOAPI_INIT(-) \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOERR \ + { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ + FUNC_ENTER_NOAPI_INIT(-) \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* * Use this macro for non-API functions which fall into these categories: @@ -2325,10 +2332,11 @@ H5_DLL herr_t H5CX_pop(void); * - functions which are called during library shutdown, since we don't * want to re-initialize the library. */ -#define FUNC_ENTER_NOAPI_NOINIT { \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOINIT \ + { \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* * Use this macro for non-API functions which fall into these categories: @@ -2339,10 +2347,11 @@ H5_DLL herr_t H5CX_pop(void); * want to re-initialize the library. * - functions that propagate, but don't issue errors */ -#define FUNC_ENTER_NOAPI_NOINIT_NOERR { \ - FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOINIT_NOERR \ + { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* * Use this macro for non-API functions which fall into these categories: @@ -2350,12 +2359,13 @@ H5_DLL herr_t H5CX_pop(void); * (so far, just the H5CS routines themselves) * */ -#define FUNC_ENTER_NOAPI_NOFS { \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOFS \ + { \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + \ + /* Initialize the package, if appropriate */ \ + H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* * Use this macro for non-API functions which fall into these categories: @@ -2366,79 +2376,88 @@ H5_DLL herr_t H5CX_pop(void); * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack) * */ -#define FUNC_ENTER_NOAPI_NOERR_NOFS { \ - FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOERR_NOFS \ + { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use the following two macros as replacements for the FUNC_ENTER_NOAPI * and FUNC_ENTER_NOAPI_NOINIT macros when the function needs to set * up a metadata tag. */ -#define FUNC_ENTER_NOAPI_TAG(tag, err) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - H5AC_tag(tag, &prev_tag); \ - FUNC_ENTER_NOAPI_INIT(err) \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { - -#define FUNC_ENTER_NOAPI_NOINIT_TAG(tag) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - H5AC_tag(tag, &prev_tag); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_TAG(tag, err) \ + { \ + haddr_t prev_tag = HADDR_UNDEF; \ + \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + H5AC_tag(tag, &prev_tag); \ + FUNC_ENTER_NOAPI_INIT(err) \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + +#define FUNC_ENTER_NOAPI_NOINIT_TAG(tag) \ + { \ + haddr_t prev_tag = HADDR_UNDEF; \ + \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + H5AC_tag(tag, &prev_tag); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for all "normal" package-level functions */ -#define FUNC_ENTER_PACKAGE { \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_PACKAGE \ + { \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for package-level functions which propgate errors, but don't issue them */ -#define FUNC_ENTER_PACKAGE_NOERR { \ - FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_PACKAGE_NOERR \ + { \ + FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use the following macro as replacement for the FUNC_ENTER_PACKAGE * macro when the function needs to set up a metadata tag. */ -#define FUNC_ENTER_PACKAGE_TAG(tag) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - H5AC_tag(tag, &prev_tag); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_PACKAGE_TAG(tag) \ + { \ + haddr_t prev_tag = HADDR_UNDEF; \ + \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5AC_tag(tag, &prev_tag); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for all "normal" staticly-scoped functions */ -#define FUNC_ENTER_STATIC { \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_STATIC \ + { \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for staticly-scoped functions which propgate errors, but don't issue them */ -#define FUNC_ENTER_STATIC_NOERR { \ - FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_STATIC_NOERR \ + { \ + FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for staticly-scoped functions which propgate errors, but don't issue them */ /* And that shouldn't push their name on the function stack */ -#define FUNC_ENTER_STATIC_NOERR_NOFS { \ - FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_STATIC_NOERR_NOFS \ + { \ + FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use the following macro as replacement for the FUNC_ENTER_STATIC * macro when the function needs to set up a metadata tag. */ -#define FUNC_ENTER_STATIC_TAG(tag) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - H5AC_tag(tag, &prev_tag); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { - +#define FUNC_ENTER_STATIC_TAG(tag) \ + { \ + haddr_t prev_tag = HADDR_UNDEF; \ + \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5AC_tag(tag, &prev_tag); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /*------------------------------------------------------------------------- * Purpose: Register function exit for code profiling. This should be @@ -2449,142 +2468,152 @@ H5_DLL herr_t H5CX_pop(void); *------------------------------------------------------------------------- */ /* Threadsafety termination code for API routines */ -#define FUNC_LEAVE_API_THREADSAFE \ - H5_API_UNLOCK \ +#define FUNC_LEAVE_API_THREADSAFE \ + H5_API_UNLOCK \ H5_API_SET_CANCEL -#define FUNC_LEAVE_API_COMMON(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - FINISH_MPE_LOG \ +#define FUNC_LEAVE_API_COMMON(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + FINISH_MPE_LOG \ H5TRACE_RETURN(ret_value); -#define FUNC_LEAVE_API(ret_value) \ - VFD_SWMR_LEAVE(ret_value); \ - FUNC_LEAVE_API_COMMON(ret_value); \ - (void)H5CX_pop(); \ - H5_POP_FUNC \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API(ret_value) \ + VFD_SWMR_LEAVE(ret_value); \ + FUNC_LEAVE_API_COMMON(ret_value); \ + (void)H5CX_pop(); \ + H5_POP_FUNC \ + if (err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro when VFD SWMR EOT is not used on leaving an API function */ -#define FUNC_LEAVE_API_NO_EOT(ret_value) \ - FUNC_LEAVE_API_COMMON(ret_value); \ - (void)H5CX_pop(); \ - H5_POP_FUNC \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API_NO_EOT(ret_value) \ + FUNC_LEAVE_API_COMMON(ret_value); \ + (void)H5CX_pop(); \ + H5_POP_FUNC \ + if (err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOINIT macro */ -#define FUNC_LEAVE_API_NOINIT(ret_value) \ - FUNC_LEAVE_API_COMMON(ret_value); \ - H5_POP_FUNC \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}}} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API_NOINIT(ret_value) \ + FUNC_LEAVE_API_COMMON(ret_value); \ + H5_POP_FUNC \ + if (err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOINIT_NOERR_NOFS macro */ -#define FUNC_LEAVE_API_NOFS(ret_value) \ - FUNC_LEAVE_API_COMMON(ret_value); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}}}} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API_NOFS(ret_value) \ + FUNC_LEAVE_API_COMMON(ret_value); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOPUSH macro */ -#define FUNC_LEAVE_API_NOPUSH(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}}}}} /*end scope from beginning of FUNC_ENTER*/ - -#define FUNC_LEAVE_NOAPI(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - H5_POP_FUNC \ - return(ret_value); \ -} /*end scope from beginning of FUNC_ENTER*/ - -#define FUNC_LEAVE_NOAPI_VOID \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - H5_POP_FUNC \ - return; \ -} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API_NOPUSH(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + if (err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } \ + } \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ + +#define FUNC_LEAVE_NOAPI(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + H5_POP_FUNC \ + return (ret_value); \ + } /*end scope from beginning of FUNC_ENTER*/ + +#define FUNC_LEAVE_NOAPI_VOID \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + H5_POP_FUNC \ + return; \ + } /*end scope from beginning of FUNC_ENTER*/ /* * Use this macro for non-API functions which fall into these categories: * - functions which didn't push their name on the function stack * (so far, just the H5CS routines themselves) */ -#define FUNC_LEAVE_NOAPI_NOFS(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - return(ret_value); \ -} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_NOAPI_NOFS(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + return (ret_value); \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro when exiting a function that set up a metadata tag */ -#define FUNC_LEAVE_NOAPI_TAG(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - H5AC_tag(prev_tag, NULL); \ - H5_POP_FUNC \ - return(ret_value); \ -} /*end scope from beginning of FUNC_ENTER*/ - +#define FUNC_LEAVE_NOAPI_TAG(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + H5AC_tag(prev_tag, NULL); \ + H5_POP_FUNC \ + return (ret_value); \ + } /*end scope from beginning of FUNC_ENTER*/ /****************************************/ /* Revisions to FUNC_ENTER/LEAVE Macros */ /****************************************/ /* Macros to check if a package is initialized */ -#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); +#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); #define H5_CHECK_PACKAGE_INIT_REG_NO(asrt) #define H5_CHECK_PACKAGE_INIT_INIT_YES(asrt) #define H5_CHECK_PACKAGE_INIT_INIT_NO(asrt) -#define H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) +#define H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) /* Macros to initialize package, if a package initialization routine is defined */ -#define H5_PKG_YES_INIT(pkg) \ - if(!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) { \ - H5_PACKAGE_INIT_VAR(pkg) = TRUE; \ - if(H5_PACKAGE_INIT_FUNC(pkg)() < 0) { \ - H5_PACKAGE_INIT_VAR(pkg) = FALSE; \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ -#define H5_PKG_NO_INIT(pkg) \ - if(!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) \ +#define H5_PKG_YES_INIT(pkg) \ + if (!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) { \ + H5_PACKAGE_INIT_VAR(pkg) = TRUE; \ + if (H5_PACKAGE_INIT_FUNC(pkg)() < 0) { \ + H5_PACKAGE_INIT_VAR(pkg) = FALSE; \ + /* (Can't use H5E_THROW here) */ \ + H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ + ret_value = fail_value; \ + goto func_init_failed; \ + } /* end if */ \ + } /* end if */ +#define H5_PKG_NO_INIT(pkg) \ + if (!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) \ H5_PACKAGE_INIT_VAR(pkg) = TRUE; -#define H5_PKG_INIT(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) +#define H5_PKG_INIT(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) /* Macros to declare package initialization function, if a package initialization routine is defined */ #ifdef H5_PKG_SINGLE_SOURCE #define H5_PKG_DECLARE_YES_FUNC(pkg) static herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#else /* H5_PKG_SINGLE_SOURCE */ +#else /* H5_PKG_SINGLE_SOURCE */ #define H5_PKG_DECLARE_YES_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); #endif /* H5_PKG_SINGLE_SOURCE */ #define H5_PKG_DECLARE_NO_FUNC(pkg) /* Declare package initialization symbols (if in a package) */ #ifdef H5_PKG_SINGLE_SOURCE -#define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); -#else /* H5_PKG_SINGLE_SOURCE */ -#define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); -#endif /* H5_PKG_SINGLE_SOURCE */ +#define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); +#else /* H5_PKG_SINGLE_SOURCE */ +#define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); +#endif /* H5_PKG_SINGLE_SOURCE */ #define H5_PKG_DECLARE_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_DECLARE_, pkg_init, _FUNC)(pkg) #ifdef H5_MY_PKG H5_PKG_DECLARE_VAR(H5_MY_PKG) @@ -2592,84 +2621,87 @@ H5_PKG_DECLARE_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) #endif /* H5_MY_PKG */ /* API re-entrance variable */ -extern hbool_t H5_api_entered_g; /* Has library already been entered through API? */ +extern hbool_t H5_api_entered_g; /* Has library already been entered through API? */ /* Macros for entering different scopes of routines */ -#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PKG(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* This interface should be initialized already */ \ - /* (except for package initialization routines :-) */ \ - H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ +#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \ + FUNC_ENTER_CHECK_NAME(H5_IS_PKG(FUNC)) \ + \ + /* The library should be initialized already */ \ + HDassert(H5_INIT_GLOBAL); \ + \ + /* This interface should be initialized already */ \ + /* (except for package initialization routines :-) */ \ + H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ { -#define H5_PRIVATE_ENTER(pkg, pkg_init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PRIV(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* Initialize this interface if desired */ \ - H5_PKG_INIT(pkg_init, pkg) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - {{ - -#define H5_PUBLIC_ENTER(pkg, pkg_init) \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_API_THREADSAFE; \ - FUNC_ENTER_CHECK_NAME(H5_IS_PUB(FUNC)) \ - \ - /* Clear thread error stack when entering public functions */ \ - H5E_clear_stack(NULL); \ - \ - /* Initialize the library or bust */ \ - if(!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ - H5_INIT_GLOBAL = TRUE; \ - if(H5_init_library() < 0) { \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ \ - \ - /* Initialize this interface if desired */ \ - H5_PKG_INIT(pkg_init, pkg) \ - \ - /* Check for re-entering API routine */ \ - HDassert(!H5_api_entered_g); \ - H5_api_entered_g = TRUE; \ - \ - /* Start logging MPI's MPE information */ \ - BEGIN_MPE_LOG \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - {{{ +#define H5_PRIVATE_ENTER(pkg, pkg_init) \ + FUNC_ENTER_CHECK_NAME(H5_IS_PRIV(FUNC)) \ + \ + /* The library should be initialized already */ \ + HDassert(H5_INIT_GLOBAL); \ + \ + /* Initialize this interface if desired */ \ + H5_PKG_INIT(pkg_init, pkg) \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ + { \ + { + +#define H5_PUBLIC_ENTER(pkg, pkg_init) \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_API_THREADSAFE; \ + FUNC_ENTER_CHECK_NAME(H5_IS_PUB(FUNC)) \ + \ + /* Clear thread error stack when entering public functions */ \ + H5E_clear_stack(NULL); \ + \ + /* Initialize the library or bust */ \ + if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ + H5_INIT_GLOBAL = TRUE; \ + if (H5_init_library() < 0) { \ + /* (Can't use H5E_THROW here) */ \ + H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ + ret_value = fail_value; \ + goto func_init_failed; \ + } /* end if */ \ + } /* end if */ \ + \ + /* Initialize this interface if desired */ \ + H5_PKG_INIT(pkg_init, pkg) \ + \ + /* Check for re-entering API routine */ \ + HDassert(!H5_api_entered_g); \ + H5_api_entered_g = TRUE; \ + \ + /* Start logging MPI's MPE information */ \ + BEGIN_MPE_LOG \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ + { \ + { \ + { /* Macros for substituting the package name */ #define FUNC_ENT_STATIC(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) -#define FUNC_ENT_PKGINIT(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, INIT) -#define FUNC_ENT_PKG(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) +#define FUNC_ENT_PKGINIT(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, INIT) +#define FUNC_ENT_PKG(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) #define FUNC_ENT_PRIV(pkg, pkg_init) H5_PRIVATE_ENTER(pkg, pkg_init) -#define FUNC_ENT_PUB(pkg, pkg_init) H5_PUBLIC_ENTER(pkg, pkg_init) +#define FUNC_ENT_PUB(pkg, pkg_init) H5_PUBLIC_ENTER(pkg, pkg_init) /* Macros for substituting a function prefix */ -#define FUNC_PREFIX_STATIC static +#define FUNC_PREFIX_STATIC static #define FUNC_PREFIX_PKGINIT #define FUNC_PREFIX_PKG #define FUNC_PREFIX_PRIV @@ -2677,134 +2709,134 @@ extern hbool_t H5_api_entered_g; /* Has library already been entered through /* Macros for declaring error variables */ /* Function can detect errors and has a specific error return value */ -#define FUNC_ERR_VAR_ERR(ret_typ, err) \ - hbool_t past_catch = FALSE; \ +#define FUNC_ERR_VAR_ERR(ret_typ, err) \ + hbool_t past_catch = FALSE; \ ret_typ fail_value = err; /* Function can detect errors but cannot return an error value (Cleanup only) */ -#define FUNC_ERR_VAR_ERRCATCH(ret_typ, err) \ - hbool_t past_catch = FALSE; +#define FUNC_ERR_VAR_ERRCATCH(ret_typ, err) hbool_t past_catch = FALSE; /* Function has no need to detect or clean up from errors */ #define FUNC_ERR_VAR_NOERR(ret_typ, err) /* Use this macro when entering all functions */ -#define BEGIN_FUNC(scope, use_err, ret_typ, ret_init, err, func) \ -H5_GLUE(FUNC_PREFIX_, scope) \ -ret_typ \ -func \ -/* Open function */ \ -{ \ - ret_typ ret_value = ret_init; \ - H5_GLUE(FUNC_ERR_VAR_, use_err)(ret_typ, err) \ - H5_GLUE(FUNC_ENT_, scope)(H5_MY_PKG, H5_MY_PKG_INIT) +#define BEGIN_FUNC(scope, use_err, ret_typ, ret_init, err, func) \ + H5_GLUE(FUNC_PREFIX_, scope) \ + ret_typ func \ + /* Open function */ \ + { \ + ret_typ ret_value = ret_init; \ + H5_GLUE(FUNC_ERR_VAR_, use_err)(ret_typ, err) H5_GLUE(FUNC_ENT_, scope)(H5_MY_PKG, H5_MY_PKG_INIT) /* Use this macro when entering functions that have no return value */ -#define BEGIN_FUNC_VOID(scope, use_err, func) \ -H5_GLUE(FUNC_PREFIX_, scope) \ -void \ -func \ -/* Open function */ \ -{ \ - H5_GLUE(FUNC_ERR_VAR_, use_err)(void, -, -) \ - H5_GLUE(FUNC_ENT_, scope) +#define BEGIN_FUNC_VOID(scope, use_err, func) \ + H5_GLUE(FUNC_PREFIX_, scope) \ + void func \ + /* Open function */ \ + { \ + H5_GLUE(FUNC_ERR_VAR_, use_err)(void, -, -) H5_GLUE(FUNC_ENT_, scope) /* Macros for label when a function initialization can fail */ -#define H5_PRIV_YES_FUNC_INIT_FAILED func_init_failed: +#define H5_PRIV_YES_FUNC_INIT_FAILED \ +func_init_failed: #define H5_PRIV_NO_FUNC_INIT_FAILED #define H5_PRIV_FUNC_INIT_FAILED(pkg_init) H5_GLUE3(H5_PRIV_, pkg_init, _FUNC_INIT_FAILED) /* Macros for leaving different scopes of routines */ -#define FUNC_LEAVE_PKGINIT \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PKGINIT \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_STATIC \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_STATIC \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PKG \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PKG \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PRIV \ - /* Leave scope for this type of function */ \ - }} \ - \ - /* Label for errors during FUNC_ENTER */ \ - H5_PRIV_FUNC_INIT_FAILED(H5_MY_PKG_INIT) \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PRIV \ + /* Leave scope for this type of function */ \ + } \ + } \ + \ + /* Label for errors during FUNC_ENTER */ \ + H5_PRIV_FUNC_INIT_FAILED(H5_MY_PKG_INIT) \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PUB \ - /* Leave scope for this type of function */ \ - }}} \ - \ - /* Label for errors during FUNC_ENTER */ \ -func_init_failed: \ - \ - /* Dump error stack if an error occurred during API routine */ \ - if(ret_value == fail_value) \ - (void)H5E_dump_api_stack(TRUE); \ - \ - /* Finish the API tracing info */ \ - H5TRACE_RETURN(ret_value); \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC \ - \ - /* Finish the MPE tracing info */ \ - FINISH_MPE_LOG \ - \ - /* Check for leaving API routine */ \ - HDassert(H5_api_entered_g); \ - H5_api_entered_g = FALSE; \ - \ - /* Release thread-safety semaphore */ \ +#define FUNC_LEAVE_PUB \ + /* Leave scope for this type of function */ \ + } \ + } \ + } \ + \ + /* Label for errors during FUNC_ENTER */ \ +func_init_failed: \ + \ + /* Dump error stack if an error occurred during API routine */ \ + if (ret_value == fail_value) \ + (void)H5E_dump_api_stack(TRUE); \ + \ + /* Finish the API tracing info */ \ + H5TRACE_RETURN(ret_value); \ + \ + /* Pop the name of this function off the function stack */ \ + H5_POP_FUNC \ + \ + /* Finish the MPE tracing info */ \ + FINISH_MPE_LOG \ + \ + /* Check for leaving API routine */ \ + HDassert(H5_api_entered_g); \ + H5_api_entered_g = FALSE; \ + \ + /* Release thread-safety semaphore */ \ FUNC_LEAVE_API_THREADSAFE /* Use this macro when leaving all functions */ -#define END_FUNC(scope) \ - /* Scope-specific function conclusion */ \ - H5_GLUE(FUNC_LEAVE_, scope) \ - \ - /* Leave routine */ \ - return(ret_value); \ - \ - /* Close Function */ \ -} +#define END_FUNC(scope) \ + /* Scope-specific function conclusion */ \ + H5_GLUE(FUNC_LEAVE_, scope) \ + \ + /* Leave routine */ \ + return (ret_value); \ + \ + /* Close Function */ \ + } /* Use this macro when leaving void functions */ -#define END_FUNC_VOID(scope) \ - /* Scope-specific function conclusion */ \ - H5_GLUE(FUNC_LEAVE_, scope) \ - \ - /* Leave routine */ \ - return; \ - \ - /* Close Function */ \ -} +#define END_FUNC_VOID(scope) \ + /* Scope-specific function conclusion */ \ + H5_GLUE(FUNC_LEAVE_, scope) \ + \ + /* Leave routine */ \ + return; \ + \ + /* Close Function */ \ + } /* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient). * Make sure to use HGOTO_ERROR_TAG and HGOTO_DONE_TAG between these macros! */ -#define H5_BEGIN_TAG(tag) { \ - haddr_t prv_tag = HADDR_UNDEF; \ - H5AC_tag(tag, &prv_tag); \ +#define H5_BEGIN_TAG(tag) \ + { \ + haddr_t prv_tag = HADDR_UNDEF; \ + H5AC_tag(tag, &prv_tag); -#define H5_END_TAG \ - H5AC_tag(prv_tag, NULL); \ -} +#define H5_END_TAG \ + H5AC_tag(prv_tag, NULL); \ + } /* Compile-time "assert" macro */ -#define HDcompile_assert(e) ((void)sizeof(char[ !!(e) ? 1 : -1])) +#define HDcompile_assert(e) ((void)sizeof(char[!!(e) ? 1 : -1])) /* Variants that are correct, but generate compile-time warnings in some circumstances: #define HDcompile_assert(e) do { enum { compile_assert__ = 1 / (e) }; } while(0) #define HDcompile_assert(e) do { typedef struct { unsigned int b: (e); } x; } while(0) @@ -2812,7 +2844,7 @@ func_init_failed: \ /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5_init_library(void); -H5_DLL void H5_term_library(void); +H5_DLL void H5_term_library(void); /* Functions to terminate interfaces */ H5_DLL int H5A_term_package(void); @@ -2853,32 +2885,31 @@ H5_DLL uint32_t H5_hash_string(const char *str); /* Time related routines */ H5_DLL time_t H5_make_time(struct tm *tm); -H5_DLL void H5_nanosleep(uint64_t nanosec); +H5_DLL void H5_nanosleep(uint64_t nanosec); H5_DLL double H5_get_time(void); /* Functions for building paths, etc. */ -H5_DLL herr_t H5_build_extpath(const char *name, char **extpath /*out*/); -H5_DLL herr_t H5_combine_path(const char *path1, const char *path2, char **full_name /*out*/); -H5_DLL herr_t H5_dirname(const char *path, char **dirname/*out*/); -H5_DLL herr_t H5_basename(const char *path, char **basename/*out*/); +H5_DLL herr_t H5_build_extpath(const char *name, char **extpath /*out*/); +H5_DLL herr_t H5_combine_path(const char *path1, const char *path2, char **full_name /*out*/); +H5_DLL herr_t H5_dirname(const char *path, char **dirname /*out*/); +H5_DLL herr_t H5_basename(const char *path, char **basename /*out*/); #ifdef H5_HAVE_PARALLEL /* Generic MPI functions */ -H5_DLL hsize_t H5_mpi_set_bigio_count(hsize_t new_count); -H5_DLL hsize_t H5_mpi_get_bigio_count(void); -H5_DLL herr_t H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new); -H5_DLL herr_t H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new); -H5_DLL herr_t H5_mpi_comm_free(MPI_Comm *comm); -H5_DLL herr_t H5_mpi_info_free(MPI_Info *info); -H5_DLL herr_t H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result); -H5_DLL herr_t H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result); -H5_DLL herr_t H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, - MPI_Datatype old_type, MPI_Datatype *new_type); +H5_DLL hsize_t H5_mpi_set_bigio_count(hsize_t new_count); +H5_DLL hsize_t H5_mpi_get_bigio_count(void); +H5_DLL herr_t H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new); +H5_DLL herr_t H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new); +H5_DLL herr_t H5_mpi_comm_free(MPI_Comm *comm); +H5_DLL herr_t H5_mpi_info_free(MPI_Info *info); +H5_DLL herr_t H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result); +H5_DLL herr_t H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result); +H5_DLL herr_t H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, MPI_Datatype old_type, + MPI_Datatype *new_type); #endif /* H5_HAVE_PARALLEL */ /* Functions for debugging */ -H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, - const uint8_t *marker, size_t buf_offset, size_t buf_size); +H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, const uint8_t *marker, + size_t buf_offset, size_t buf_size); #endif /* _H5private_H */ - diff --git a/src/H5public.h b/src/H5public.h index 3a3de88..7df8ae6 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -26,47 +26,46 @@ * it via H5public.h. The #ifndef _H5public_H guard above would * prevent repeated include. */ -#include "H5pubconf.h" /*from configure */ +#include "H5pubconf.h" /*from configure */ /* API Version macro wrapper definitions */ #include "H5version.h" #ifdef H5_HAVE_FEATURES_H -#include /*for setting POSIX, BSD, etc. compatibility */ +#include /*for setting POSIX, BSD, etc. compatibility */ #endif #ifdef H5_HAVE_SYS_TYPES_H #include #endif #ifdef H5_STDC_HEADERS -# include /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */ -# include /*for variadic functions in H5VLpublic.h */ +#include /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */ +#include /*for variadic functions in H5VLpublic.h */ #endif #ifndef __cplusplus -# ifdef H5_HAVE_STDINT_H -# include /*for C9x types */ -# endif +#ifdef H5_HAVE_STDINT_H +#include /*for C9x types */ +#endif #else -# ifdef H5_HAVE_STDINT_H_CXX -# include /*for C9x types when include from C++ */ -# endif +#ifdef H5_HAVE_STDINT_H_CXX +#include /*for C9x types when include from C++ */ +#endif #endif #ifdef H5_HAVE_INTTYPES_H -# include /* C99/POSIX.1 header for uint64_t, PRIu64 */ +#include /* C99/POSIX.1 header for uint64_t, PRIu64 */ #endif #ifdef H5_HAVE_STDDEF_H -# include +#include #endif #ifdef H5_HAVE_PARALLEL /* Don't link against MPI C++ bindings */ -# define MPICH_SKIP_MPICXX 1 -# define OMPI_SKIP_MPICXX 1 -# include -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ -# include +#define MPICH_SKIP_MPICXX 1 +#define OMPI_SKIP_MPICXX 1 +#include +#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ +#include #endif #endif - /* Include the Windows API adapter header early */ #include "H5api_adpt.h" @@ -81,39 +80,35 @@ extern "C" { */ /* These pragmas are only implemented usefully in gcc 4.6+ */ #if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 - #define H5_GCC_DIAG_STR(s) #s - #define H5_GCC_DIAG_JOINSTR(x,y) H5_GCC_DIAG_STR(x ## y) - #define H5_GCC_DIAG_DO_PRAGMA(x) _Pragma (#x) - #define H5_GCC_DIAG_PRAGMA(x) H5_GCC_DIAG_DO_PRAGMA(GCC diagnostic x) +#define H5_GCC_DIAG_JOINSTR(x, y) x y +#define H5_GCC_DIAG_DO_PRAGMA(x) _Pragma(#x) +#define H5_GCC_DIAG_PRAGMA(x) H5_GCC_DIAG_DO_PRAGMA(GCC diagnostic x) - #define H5_GCC_DIAG_OFF(x) H5_GCC_DIAG_PRAGMA(push) H5_GCC_DIAG_PRAGMA(ignored H5_GCC_DIAG_JOINSTR(-W,x)) - #define H5_GCC_DIAG_ON(x) H5_GCC_DIAG_PRAGMA(pop) +#define H5_GCC_DIAG_OFF(x) H5_GCC_DIAG_PRAGMA(push) H5_GCC_DIAG_PRAGMA(ignored H5_GCC_DIAG_JOINSTR("-W", x)) +#define H5_GCC_DIAG_ON(x) H5_GCC_DIAG_PRAGMA(pop) #else - #define H5_GCC_DIAG_OFF(x) - #define H5_GCC_DIAG_ON(x) +#define H5_GCC_DIAG_OFF(x) +#define H5_GCC_DIAG_ON(x) #endif /* Version numbers */ -#define H5_VERS_MAJOR 1 /* For major interface/format changes */ -#define H5_VERS_MINOR 13 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 0 /* For tweaks, bug-fixes, or development */ -#define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ - /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.13.0" /* Full version string */ +#define H5_VERS_MAJOR 1 /* For major interface/format changes */ +#define H5_VERS_MINOR 13 /* For minor interface/format changes */ +#define H5_VERS_RELEASE 0 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ + /* Empty string for real releases. */ +#define H5_VERS_INFO "HDF5 library version: 1.13.0" /* Full version string */ -#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ - H5_VERS_RELEASE) +#define H5check() H5check_version(H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE) /* macros for comparing the version */ -#define H5_VERSION_GE(Maj,Min,Rel) \ - (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE>=Rel)) || \ - ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR>Min)) || \ - (H5_VERS_MAJOR>Maj)) +#define H5_VERSION_GE(Maj, Min, Rel) \ + (((H5_VERS_MAJOR == Maj) && (H5_VERS_MINOR == Min) && (H5_VERS_RELEASE >= Rel)) || \ + ((H5_VERS_MAJOR == Maj) && (H5_VERS_MINOR > Min)) || (H5_VERS_MAJOR > Maj)) -#define H5_VERSION_LE(Maj,Min,Rel) \ - (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE<=Rel)) || \ - ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR +#include #else /* H5_HAVE_STDBOOL_H */ - #ifndef __cplusplus - #if defined(H5_SIZEOF_BOOL) && (H5_SIZEOF_BOOL != 0) - #define bool _Bool - #else - #define bool unsigned int - #endif - #define true 1 - #define false 0 - #endif /* __cplusplus */ +#ifndef __cplusplus +#if defined(H5_SIZEOF_BOOL) && (H5_SIZEOF_BOOL != 0) +#define bool _Bool +#else +#define bool unsigned int +#endif +#define true 1 +#define false 0 +#endif /* __cplusplus */ #endif /* H5_HAVE_STDBOOL_H */ typedef bool hbool_t; -typedef int htri_t; +typedef int htri_t; /* Define the ssize_t type if it not is defined */ -#if H5_SIZEOF_SSIZE_T==0 +#if H5_SIZEOF_SSIZE_T == 0 /* Undefine this size, we will re-define it in one of the sections below */ #undef H5_SIZEOF_SSIZE_T -#if H5_SIZEOF_SIZE_T==H5_SIZEOF_INT +#if H5_SIZEOF_SIZE_T == H5_SIZEOF_INT typedef int ssize_t; -# define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT -#elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG +#define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT +#elif H5_SIZEOF_SIZE_T == H5_SIZEOF_LONG typedef long ssize_t; -# define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG -#elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG_LONG +#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG +#elif H5_SIZEOF_SIZE_T == H5_SIZEOF_LONG_LONG typedef long long ssize_t; -# define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG +#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG #else /* Can't find matching type for ssize_t */ -# error "nothing appropriate for ssize_t" +#error "nothing appropriate for ssize_t" #endif #endif /* int64_t type is used for creation order field for links. It may be * defined in Posix.1g, otherwise it is defined here. */ -#if H5_SIZEOF_INT64_T>=8 -#elif H5_SIZEOF_INT>=8 - typedef int int64_t; -# undef H5_SIZEOF_INT64_T -# define H5_SIZEOF_INT64_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG>=8 - typedef long int64_t; -# undef H5_SIZEOF_INT64_T -# define H5_SIZEOF_INT64_T H5_SIZEOF_LONG -#elif H5_SIZEOF_LONG_LONG>=8 - typedef long long int64_t; -# undef H5_SIZEOF_INT64_T -# define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG +#if H5_SIZEOF_INT64_T >= 8 +#elif H5_SIZEOF_INT >= 8 +typedef int int64_t; +#undef H5_SIZEOF_INT64_T +#define H5_SIZEOF_INT64_T H5_SIZEOF_INT +#elif H5_SIZEOF_LONG >= 8 +typedef long int64_t; +#undef H5_SIZEOF_INT64_T +#define H5_SIZEOF_INT64_T H5_SIZEOF_LONG +#elif H5_SIZEOF_LONG_LONG >= 8 +typedef long long int64_t; +#undef H5_SIZEOF_INT64_T +#define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG #else -# error "nothing appropriate for int64_t" +#error "nothing appropriate for int64_t" #endif /* uint64_t type is used for fields for H5O_info_t. It may be * defined in Posix.1g, otherwise it is defined here. */ -#if H5_SIZEOF_UINT64_T>=8 -#elif H5_SIZEOF_INT>=8 - typedef unsigned uint64_t; -# undef H5_SIZEOF_UINT64_T -# define H5_SIZEOF_UINT64_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG>=8 - typedef unsigned long uint64_t; -# undef H5_SIZEOF_UINT64_T -# define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG -#elif H5_SIZEOF_LONG_LONG>=8 - typedef unsigned long long uint64_t; -# undef H5_SIZEOF_UINT64_T -# define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG +#if H5_SIZEOF_UINT64_T >= 8 +#elif H5_SIZEOF_INT >= 8 +typedef unsigned uint64_t; +#undef H5_SIZEOF_UINT64_T +#define H5_SIZEOF_UINT64_T H5_SIZEOF_INT +#elif H5_SIZEOF_LONG >= 8 +typedef unsigned long uint64_t; +#undef H5_SIZEOF_UINT64_T +#define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG +#elif H5_SIZEOF_LONG_LONG >= 8 +typedef unsigned long long uint64_t; +#undef H5_SIZEOF_UINT64_T +#define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG #else -# error "nothing appropriate for uint64_t" +#error "nothing appropriate for uint64_t" #endif /* * The sizes of file objects have their own types defined here, use a 64-bit * type. */ -typedef uint64_t hsize_t; -typedef int64_t hssize_t; -#define PRIXHSIZE PRIX64 -#define PRIdHSIZE PRId64 -#define PRIiHSIZE PRIi64 -#define PRIoHSIZE PRIo64 -#define PRIuHSIZE PRIu64 -#define PRIxHSIZE PRIx64 -#define H5_SIZEOF_HSIZE_T H5_SIZEOF_UINT64_T -#define H5_SIZEOF_HSSIZE_T H5_SIZEOF_INT64_T -#define HSIZE_UNDEF UINT64_MAX +typedef uint64_t hsize_t; +typedef int64_t hssize_t; +#define PRIXHSIZE PRIX64 +#define PRIdHSIZE PRId64 +#define PRIiHSIZE PRIi64 +#define PRIoHSIZE PRIo64 +#define PRIuHSIZE PRIu64 +#define PRIxHSIZE PRIx64 +#define H5_SIZEOF_HSIZE_T H5_SIZEOF_UINT64_T +#define H5_SIZEOF_HSSIZE_T H5_SIZEOF_INT64_T +#define HSIZE_UNDEF UINT64_MAX /* * File addresses have their own types. */ #if H5_SIZEOF_INT >= 8 - typedef unsigned haddr_t; -# define HADDR_UNDEF UINT_MAX -# define H5_SIZEOF_HADDR_T H5_SIZEOF_INT -# ifdef H5_HAVE_PARALLEL -# define HADDR_AS_MPI_TYPE MPI_UNSIGNED -# endif /* H5_HAVE_PARALLEL */ +typedef unsigned haddr_t; +#define HADDR_UNDEF UINT_MAX +#define H5_SIZEOF_HADDR_T H5_SIZEOF_INT +#ifdef H5_HAVE_PARALLEL +#define HADDR_AS_MPI_TYPE MPI_UNSIGNED +#endif /* H5_HAVE_PARALLEL */ #elif H5_SIZEOF_LONG >= 8 - typedef unsigned long haddr_t; -# define HADDR_UNDEF ULONG_MAX -# define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG -# ifdef H5_HAVE_PARALLEL -# define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG -# endif /* H5_HAVE_PARALLEL */ +typedef unsigned long haddr_t; +#define HADDR_UNDEF ULONG_MAX +#define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG +#ifdef H5_HAVE_PARALLEL +#define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG +#endif /* H5_HAVE_PARALLEL */ #elif H5_SIZEOF_LONG_LONG >= 8 - typedef unsigned long long haddr_t; -# define HADDR_UNDEF ULLONG_MAX -# define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG -# ifdef H5_HAVE_PARALLEL -# define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT -# endif /* H5_HAVE_PARALLEL */ +typedef unsigned long long haddr_t; +#define HADDR_UNDEF ULLONG_MAX +#define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG +#ifdef H5_HAVE_PARALLEL +#define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT +#endif /* H5_HAVE_PARALLEL */ #else -# error "nothing appropriate for haddr_t" +#error "nothing appropriate for haddr_t" #endif #if H5_SIZEOF_HADDR_T == H5_SIZEOF_INT -# define PRIXHADDR "X" -# define PRIoHADDR "o" -# define PRIuHADDR "u" -# define PRIxHADDR "x" +#define PRIXHADDR "X" +#define PRIoHADDR "o" +#define PRIuHADDR "u" +#define PRIxHADDR "x" #elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG -# define PRIXHADDR "lX" -# define PRIoHADDR "lo" -# define PRIuHADDR "lu" -# define PRIxHADDR "lx" +#define PRIXHADDR "lX" +#define PRIoHADDR "lo" +#define PRIuHADDR "lu" +#define PRIxHADDR "lx" #elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG_LONG -# define PRIXHADDR H5_PRINTF_LL_WIDTH "X" -# define PRIoHADDR H5_PRINTF_LL_WIDTH "o" -# define PRIuHADDR H5_PRINTF_LL_WIDTH "u" -# define PRIxHADDR H5_PRINTF_LL_WIDTH "x" +#define PRIXHADDR H5_PRINTF_LL_WIDTH "X" +#define PRIoHADDR H5_PRINTF_LL_WIDTH "o" +#define PRIuHADDR H5_PRINTF_LL_WIDTH "u" +#define PRIxHADDR H5_PRINTF_LL_WIDTH "x" #else -# error "nothing appropriate for H5_PRINTF_HADDR_FMT" +#error "nothing appropriate for H5_PRINTF_HADDR_FMT" #endif -#define H5_PRINTF_HADDR_FMT "%" PRIuHADDR -#define HADDR_MAX (HADDR_UNDEF-1) +#define H5_PRINTF_HADDR_FMT "%" PRIuHADDR +#define HADDR_MAX (HADDR_UNDEF - 1) /* uint32_t type is used for creation order field for messages. It may be * defined in Posix.1g, otherwise it is defined here. */ -#if H5_SIZEOF_UINT32_T>=4 -#elif H5_SIZEOF_SHORT>=4 - typedef short uint32_t; -# undef H5_SIZEOF_UINT32_T -# define H5_SIZEOF_UINT32_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT>=4 - typedef unsigned int uint32_t; -# undef H5_SIZEOF_UINT32_T -# define H5_SIZEOF_UINT32_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG>=4 - typedef unsigned long uint32_t; -# undef H5_SIZEOF_UINT32_T -# define H5_SIZEOF_UINT32_T H5_SIZEOF_LONG +#if H5_SIZEOF_UINT32_T >= 4 +#elif H5_SIZEOF_SHORT >= 4 +typedef short uint32_t; +#undef H5_SIZEOF_UINT32_T +#define H5_SIZEOF_UINT32_T H5_SIZEOF_SHORT +#elif H5_SIZEOF_INT >= 4 +typedef unsigned int uint32_t; +#undef H5_SIZEOF_UINT32_T +#define H5_SIZEOF_UINT32_T H5_SIZEOF_INT +#elif H5_SIZEOF_LONG >= 4 +typedef unsigned long uint32_t; +#undef H5_SIZEOF_UINT32_T +#define H5_SIZEOF_UINT32_T H5_SIZEOF_LONG #else -# error "nothing appropriate for uint32_t" +#error "nothing appropriate for uint32_t" #endif /* Common iteration orders */ typedef enum { - H5_ITER_UNKNOWN = -1, /* Unknown order */ - H5_ITER_INC, /* Increasing order */ - H5_ITER_DEC, /* Decreasing order */ - H5_ITER_NATIVE, /* No particular order, whatever is fastest */ - H5_ITER_N /* Number of iteration orders */ + H5_ITER_UNKNOWN = -1, /* Unknown order */ + H5_ITER_INC, /* Increasing order */ + H5_ITER_DEC, /* Decreasing order */ + H5_ITER_NATIVE, /* No particular order, whatever is fastest */ + H5_ITER_N /* Number of iteration orders */ } H5_iter_order_t; /* Iteration callback values */ /* (Actually, any positive value will cause the iterator to stop and pass back * that positive value to the function that called the iterator) */ -#define H5_ITER_ERROR (-1) -#define H5_ITER_CONT (0) -#define H5_ITER_STOP (1) +#define H5_ITER_ERROR (-1) +#define H5_ITER_CONT (0) +#define H5_ITER_STOP (1) /* * The types of indices on links in groups/attributes on objects. @@ -324,18 +318,18 @@ typedef enum { * links in groups/attributes on objects. */ typedef enum H5_index_t { - H5_INDEX_UNKNOWN = -1, /* Unknown index type */ - H5_INDEX_NAME, /* Index on names */ - H5_INDEX_CRT_ORDER, /* Index on creation order */ - H5_INDEX_N /* Number of indices defined */ + H5_INDEX_UNKNOWN = -1, /* Unknown index type */ + H5_INDEX_NAME, /* Index on names */ + H5_INDEX_CRT_ORDER, /* Index on creation order */ + H5_INDEX_N /* Number of indices defined */ } H5_index_t; /* * Storage info struct used by H5O_info_t and H5F_info_t */ typedef struct H5_ih_info_t { - hsize_t index_size; /* btree and/or list */ - hsize_t heap_size; + hsize_t index_size; /* btree and/or list */ + hsize_t heap_size; } H5_ih_info_t; static inline const char * @@ -353,7 +347,7 @@ htri_to_string(htri_t v) * used to reference HDF5 objects in a container. */ /* The maximum size allowed for tokens */ -#define H5O_MAX_TOKEN_SIZE (16) /* Allows for 128-bit tokens */ +#define H5O_MAX_TOKEN_SIZE (16) /* Allows for 128-bit tokens */ /* Type for object tokens */ /* (Hoisted here, since it's used by both the H5Lpublic.h and H5Opublic.h headers) */ @@ -365,13 +359,13 @@ typedef struct H5O_token_t { * Allocation statistics info struct */ typedef struct H5_alloc_stats_t { - unsigned long long total_alloc_bytes; /* Running count of total # of bytes allocated */ - size_t curr_alloc_bytes; /* Current # of bytes allocated */ - size_t peak_alloc_bytes; /* Peak # of bytes allocated */ - size_t max_block_size; /* Largest block allocated */ - size_t total_alloc_blocks_count; /* Running count of total # of blocks allocated */ - size_t curr_alloc_blocks_count; /* Current # of blocks allocated */ - size_t peak_alloc_blocks_count; /* Peak # of blocks allocated */ + unsigned long long total_alloc_bytes; /* Running count of total # of bytes allocated */ + size_t curr_alloc_bytes; /* Current # of bytes allocated */ + size_t peak_alloc_bytes; /* Peak # of bytes allocated */ + size_t max_block_size; /* Largest block allocated */ + size_t total_alloc_blocks_count; /* Running count of total # of blocks allocated */ + size_t curr_alloc_blocks_count; /* Current # of blocks allocated */ + size_t peak_alloc_blocks_count; /* Peak # of blocks allocated */ } H5_alloc_stats_t; /* Functions in H5.c */ @@ -379,24 +373,18 @@ H5_DLL herr_t H5open(void); H5_DLL herr_t H5close(void); H5_DLL herr_t H5dont_atexit(void); H5_DLL herr_t H5garbage_collect(void); -H5_DLL herr_t H5set_free_list_limits (int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, - int blk_list_lim); -H5_DLL herr_t H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, - size_t *blk_size, size_t *fac_size); +H5_DLL herr_t H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, + int arr_list_lim, int blk_global_lim, int blk_list_lim); +H5_DLL herr_t H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size); H5_DLL herr_t H5get_alloc_stats(H5_alloc_stats_t *stats); -H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, - unsigned *relnum); -H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, - unsigned relnum); +H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum); +H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum); H5_DLL herr_t H5is_library_threadsafe(hbool_t *is_ts); H5_DLL herr_t H5free_memory(void *mem); -H5_DLL void *H5allocate_memory(size_t size, hbool_t clear); -H5_DLL void *H5resize_memory(void *mem, size_t size); +H5_DLL void * H5allocate_memory(size_t size, hbool_t clear); +H5_DLL void * H5resize_memory(void *mem, size_t size); #ifdef __cplusplus } #endif #endif /* _H5public_H */ - - diff --git a/src/H5queue.h b/src/H5queue.h index bef7ef7..e90fb8b 100644 --- a/src/H5queue.h +++ b/src/H5queue.h @@ -31,8 +31,8 @@ * @(#)queue.h 8.5 (Berkeley) 8/20/94 */ -#ifndef H5queue_H_ -#define H5queue_H_ +#ifndef H5queue_H_ +#define H5queue_H_ /* This is a copy of netBSD's sys/queue.h header for use in HDF5. We've copied * it here instead of using the system's version to avoid incompatibilities. @@ -43,7 +43,6 @@ * this file to discourage their use. */ - /* On MacOS, sys/file.h (needed for flock(3)) includes sys.queue.h, so we * can't just use an alternative BSD queue implementation without running * into symbol redefinition errors. @@ -113,570 +112,561 @@ #endif #if defined(QUEUEDEBUG) -# if defined(_KERNEL) -# define QUEUEDEBUG_ABORT(...) panic(__VA_ARGS__) -# else -# include -# define QUEUEDEBUG_ABORT(...) err(1, __VA_ARGS__) -# endif +#if defined(_KERNEL) +#define QUEUEDEBUG_ABORT(...) panic(__VA_ARGS__) +#else +#include +#define QUEUEDEBUG_ABORT(...) err(1, __VA_ARGS__) +#endif #endif /* * Singly-linked List definitions. */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} +#define SLIST_HEAD(name, type) \ + struct name { \ + struct type *slh_first; /* first element */ \ + } -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } +#define SLIST_HEAD_INITIALIZER(head) \ + { \ + NULL \ + } -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} +#define SLIST_ENTRY(type) \ + struct { \ + struct type *sle_next; /* next element */ \ + } /* * Singly-linked List access methods. */ -#define SLIST_FIRST(head) ((head)->slh_first) -#define SLIST_END(head) NULL -#define SLIST_EMPTY(head) ((head)->slh_first == NULL) -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) - -#define SLIST_FOREACH(var, head, field) \ - for((var) = (head)->slh_first; \ - (var) != SLIST_END(head); \ - (var) = (var)->field.sle_next) - -#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) != SLIST_END(head) && \ - ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_END(head) NULL +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +#define SLIST_FOREACH(var, head, field) \ + for ((var) = (head)->slh_first; (var) != SLIST_END(head); (var) = (var)->field.sle_next) + +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SLIST_FIRST((head)); (var) != SLIST_END(head) && ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) /* * Singly-linked List functions. */ -#define SLIST_INIT(head) do { \ - (head)->slh_first = SLIST_END(head); \ -} while (/*CONSTCOND*/0) - -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - (elm)->field.sle_next = (slistelm)->field.sle_next; \ - (slistelm)->field.sle_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.sle_next = (head)->slh_first; \ - (head)->slh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE_AFTER(slistelm, field) do { \ - (slistelm)->field.sle_next = \ - SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE_HEAD(head, field) do { \ - (head)->slh_first = (head)->slh_first->field.sle_next; \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE(head, elm, type, field) do { \ - if ((head)->slh_first == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = (head)->slh_first; \ - while(curelm->field.sle_next != (elm)) \ - curelm = curelm->field.sle_next; \ - curelm->field.sle_next = \ - curelm->field.sle_next->field.sle_next; \ - } \ -} while (/*CONSTCOND*/0) - +#define SLIST_INIT(head) \ + do { \ + (head)->slh_first = SLIST_END(head); \ + } while (/*CONSTCOND*/ 0) + +#define SLIST_INSERT_AFTER(slistelm, elm, field) \ + do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ + } while (/*CONSTCOND*/ 0) + +#define SLIST_INSERT_HEAD(head, elm, field) \ + do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ + } while (/*CONSTCOND*/ 0) + +#define SLIST_REMOVE_AFTER(slistelm, field) \ + do { \ + (slistelm)->field.sle_next = SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ + } while (/*CONSTCOND*/ 0) + +#define SLIST_REMOVE_HEAD(head, field) \ + do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ + } while (/*CONSTCOND*/ 0) + +#define SLIST_REMOVE(head, elm, type, field) \ + do { \ + if ((head)->slh_first == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->slh_first; \ + while (curelm->field.sle_next != (elm)) \ + curelm = curelm->field.sle_next; \ + curelm->field.sle_next = curelm->field.sle_next->field.sle_next; \ + } \ + } while (/*CONSTCOND*/ 0) /* * List definitions. */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} +#define LIST_HEAD(name, type) \ + struct name { \ + struct type *lh_first; /* first element */ \ + } + +#define LIST_HEAD_INITIALIZER(head) \ + { \ + NULL \ + } + +#define LIST_ENTRY(type) \ + struct { \ + struct type * le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ + } /* * List access methods. */ -#define LIST_FIRST(head) ((head)->lh_first) -#define LIST_END(head) NULL -#define LIST_EMPTY(head) ((head)->lh_first == LIST_END(head)) -#define LIST_NEXT(elm, field) ((elm)->field.le_next) - -#define LIST_FOREACH(var, head, field) \ - for ((var) = ((head)->lh_first); \ - (var) != LIST_END(head); \ - (var) = ((var)->field.le_next)) - -#define LIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) != LIST_END(head) && \ - ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_MOVE(head1, head2, field) do { \ - LIST_INIT((head2)); \ - if (!LIST_EMPTY((head1))) { \ - (head2)->lh_first = (head1)->lh_first; \ - (head2)->lh_first->field.le_prev = &(head2)->lh_first; \ - LIST_INIT((head1)); \ - } \ -} while (/*CONSTCOND*/0) +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_END(head) NULL +#define LIST_EMPTY(head) ((head)->lh_first == LIST_END(head)) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); (var) != LIST_END(head); (var) = ((var)->field.le_next)) + +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)); (var) != LIST_END(head) && ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define LIST_MOVE(head1, head2, field) \ + do { \ + LIST_INIT((head2)); \ + if (!LIST_EMPTY((head1))) { \ + (head2)->lh_first = (head1)->lh_first; \ + (head2)->lh_first->field.le_prev = &(head2)->lh_first; \ + LIST_INIT((head1)); \ + } \ + } while (/*CONSTCOND*/ 0) /* * List functions. */ #if defined(QUEUEDEBUG) -#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ - if ((head)->lh_first && \ - (head)->lh_first->field.le_prev != &(head)->lh_first) \ - QUEUEDEBUG_ABORT("LIST_INSERT_HEAD %p %s:%d", (head), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_LIST_OP(elm, field) \ - if ((elm)->field.le_next && \ - (elm)->field.le_next->field.le_prev != \ - &(elm)->field.le_next) \ - QUEUEDEBUG_ABORT("LIST_* forw %p %s:%d", (elm), \ - __FILE__, __LINE__); \ - if (*(elm)->field.le_prev != (elm)) \ - QUEUEDEBUG_ABORT("LIST_* back %p %s:%d", (elm), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ - (elm)->field.le_next = (void *)1L; \ - (elm)->field.le_prev = (void *)1L; +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ + if ((head)->lh_first && (head)->lh_first->field.le_prev != &(head)->lh_first) \ + QUEUEDEBUG_ABORT("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_OP(elm, field) \ + if ((elm)->field.le_next && (elm)->field.le_next->field.le_prev != &(elm)->field.le_next) \ + QUEUEDEBUG_ABORT("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__); \ + if (*(elm)->field.le_prev != (elm)) \ + QUEUEDEBUG_ABORT("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ + (elm)->field.le_next = (void *)1L; \ + (elm)->field.le_prev = (void *)1L; #else -#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) -#define QUEUEDEBUG_LIST_OP(elm, field) -#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_LIST_OP(elm, field) +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) #endif -#define LIST_INIT(head) do { \ - (head)->lh_first = LIST_END(head); \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - QUEUEDEBUG_LIST_OP((listelm), field) \ - if (((elm)->field.le_next = (listelm)->field.le_next) != \ - LIST_END(head)) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - QUEUEDEBUG_LIST_OP((listelm), field) \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - (elm)->field.le_next = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &(elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_HEAD(head, elm, field) do { \ - QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ - if (((elm)->field.le_next = (head)->lh_first) != LIST_END(head))\ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} while (/*CONSTCOND*/0) - -#define LIST_REMOVE(elm, field) do { \ - QUEUEDEBUG_LIST_OP((elm), field) \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ - QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ -} while (/*CONSTCOND*/0) - -#define LIST_REPLACE(elm, elm2, field) do { \ - if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ - (elm2)->field.le_next->field.le_prev = \ - &(elm2)->field.le_next; \ - (elm2)->field.le_prev = (elm)->field.le_prev; \ - *(elm2)->field.le_prev = (elm2); \ - QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ -} while (/*CONSTCOND*/0) +#define LIST_INIT(head) \ + do { \ + (head)->lh_first = LIST_END(head); \ + } while (/*CONSTCOND*/ 0) + +#define LIST_INSERT_AFTER(listelm, elm, field) \ + do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + if (((elm)->field.le_next = (listelm)->field.le_next) != LIST_END(head)) \ + (listelm)->field.le_next->field.le_prev = &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ + } while (/*CONSTCOND*/ 0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) \ + do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ + } while (/*CONSTCOND*/ 0) + +#define LIST_INSERT_HEAD(head, elm, field) \ + do { \ + QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.le_next = (head)->lh_first) != LIST_END(head)) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next; \ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ + } while (/*CONSTCOND*/ 0) + +#define LIST_REMOVE(elm, field) \ + do { \ + QUEUEDEBUG_LIST_OP((elm), field) \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ + } while (/*CONSTCOND*/ 0) + +#define LIST_REPLACE(elm, elm2, field) \ + do { \ + if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ + (elm2)->field.le_next->field.le_prev = &(elm2)->field.le_next; \ + (elm2)->field.le_prev = (elm)->field.le_prev; \ + *(elm2)->field.le_prev = (elm2); \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ + } while (/*CONSTCOND*/ 0) /* * Tail queue definitions. */ -#define _TAILQ_HEAD(name, type, qual) \ -struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last; /* addr of last next element */ \ -} -#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) - -#define TAILQ_HEAD_INITIALIZER(head) \ - { TAILQ_END(head), &(head).tqh_first } - -#define _TAILQ_ENTRY(type, qual) \ -struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev; /* address of previous next element */\ -} -#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) +#define _TAILQ_HEAD(name, type, qual) \ + struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ + } +#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type, ) + +#define TAILQ_HEAD_INITIALIZER(head) \ + { \ + TAILQ_END(head), &(head).tqh_first \ + } + +#define _TAILQ_ENTRY(type, qual) \ + struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */ \ + } +#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type, ) /* * Tail queue access methods. */ -#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_END(head) (NULL) -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)(void *)((head)->tqh_last))->tqh_last)) -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)(void *)((elm)->field.tqe_prev))->tqh_last)) -#define TAILQ_EMPTY(head) (TAILQ_FIRST(head) == TAILQ_END(head)) - - -#define TAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->tqh_first); \ - (var) != TAILQ_END(head); \ - (var) = ((var)->field.tqe_next)) - -#define TAILQ_FOREACH_SAFE(var, head, field, next) \ - for ((var) = ((head)->tqh_first); \ - (var) != TAILQ_END(head) && \ - ((next) = TAILQ_NEXT(var, field), 1); (var) = (next)) - -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) != TAILQ_END(head); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) != TAILQ_END(head) && \ - ((prev) = TAILQ_PREV((var), headname, field), 1); (var) = (prev)) +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_END(head) (NULL) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_LAST(head, headname) (*(((struct headname *)(void *)((head)->tqh_last))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) (*(((struct headname *)(void *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_EMPTY(head) (TAILQ_FIRST(head) == TAILQ_END(head)) + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); (var) != TAILQ_END(head); (var) = ((var)->field.tqe_next)) + +#define TAILQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->tqh_first); (var) != TAILQ_END(head) && ((next) = TAILQ_NEXT(var, field), 1); \ + (var) = (next)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); (var) != TAILQ_END(head); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) != TAILQ_END(head) && ((prev) = TAILQ_PREV((var), headname, field), 1); (var) = (prev)) /* * Tail queue functions. */ #if defined(QUEUEDEBUG) -#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ - if ((head)->tqh_first && \ - (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ - QUEUEDEBUG_ABORT("TAILQ_INSERT_HEAD %p %s:%d", (head), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ - if (*(head)->tqh_last != NULL) \ - QUEUEDEBUG_ABORT("TAILQ_INSERT_TAIL %p %s:%d", (head), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_TAILQ_OP(elm, field) \ - if ((elm)->field.tqe_next && \ - (elm)->field.tqe_next->field.tqe_prev != \ - &(elm)->field.tqe_next) \ - QUEUEDEBUG_ABORT("TAILQ_* forw %p %s:%d", (elm), \ - __FILE__, __LINE__); \ - if (*(elm)->field.tqe_prev != (elm)) \ - QUEUEDEBUG_ABORT("TAILQ_* back %p %s:%d", (elm), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ - if ((elm)->field.tqe_next == NULL && \ - (head)->tqh_last != &(elm)->field.tqe_next) \ - QUEUEDEBUG_ABORT("TAILQ_PREREMOVE head %p elm %p %s:%d",\ - (head), (elm), __FILE__, __LINE__); -#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ - (elm)->field.tqe_next = (void *)1L; \ - (elm)->field.tqe_prev = (void *)1L; +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ + if ((head)->tqh_first && (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ + QUEUEDEBUG_ABORT("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ + if (*(head)->tqh_last != NULL) \ + QUEUEDEBUG_ABORT("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_OP(elm, field) \ + if ((elm)->field.tqe_next && (elm)->field.tqe_next->field.tqe_prev != &(elm)->field.tqe_next) \ + QUEUEDEBUG_ABORT("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__); \ + if (*(elm)->field.tqe_prev != (elm)) \ + QUEUEDEBUG_ABORT("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ + if ((elm)->field.tqe_next == NULL && (head)->tqh_last != &(elm)->field.tqe_next) \ + QUEUEDEBUG_ABORT("TAILQ_PREREMOVE head %p elm %p %s:%d", (head), (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ + (elm)->field.tqe_next = (void *)1L; \ + (elm)->field.tqe_prev = (void *)1L; #else -#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) -#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) -#define QUEUEDEBUG_TAILQ_OP(elm, field) -#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) -#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) +#define QUEUEDEBUG_TAILQ_OP(elm, field) +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) #endif -#define TAILQ_INIT(head) do { \ - (head)->tqh_first = TAILQ_END(head); \ - (head)->tqh_last = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ - if (((elm)->field.tqe_next = (head)->tqh_first) != TAILQ_END(head))\ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ - (elm)->field.tqe_next = TAILQ_END(head); \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - QUEUEDEBUG_TAILQ_OP((listelm), field) \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != \ - TAILQ_END(head)) \ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - QUEUEDEBUG_TAILQ_OP((listelm), field) \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_REMOVE(head, elm, field) do { \ - QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ - QUEUEDEBUG_TAILQ_OP((elm), field) \ - if (((elm)->field.tqe_next) != TAILQ_END(head)) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ - QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ -} while (/*CONSTCOND*/0) - -#define TAILQ_REPLACE(head, elm, elm2, field) do { \ - if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != \ - TAILQ_END(head)) \ - (elm2)->field.tqe_next->field.tqe_prev = \ - &(elm2)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm2)->field.tqe_next; \ - (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ - *(elm2)->field.tqe_prev = (elm2); \ - QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ -} while (/*CONSTCOND*/0) - -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) +#define TAILQ_INIT(head) \ + do { \ + (head)->tqh_first = TAILQ_END(head); \ + (head)->tqh_last = &(head)->tqh_first; \ + } while (/*CONSTCOND*/ 0) + +#define TAILQ_INSERT_HEAD(head, elm, field) \ + do { \ + QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.tqe_next = (head)->tqh_first) != TAILQ_END(head)) \ + (head)->tqh_first->field.tqe_prev = &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ + } while (/*CONSTCOND*/ 0) + +#define TAILQ_INSERT_TAIL(head, elm, field) \ + do { \ + QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ + (elm)->field.tqe_next = TAILQ_END(head); \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + } while (/*CONSTCOND*/ 0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) \ + do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != TAILQ_END(head)) \ + (elm)->field.tqe_next->field.tqe_prev = &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ + } while (/*CONSTCOND*/ 0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) \ + do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ + } while (/*CONSTCOND*/ 0) + +#define TAILQ_REMOVE(head, elm, field) \ + do { \ + QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ + QUEUEDEBUG_TAILQ_OP((elm), field) \ + if (((elm)->field.tqe_next) != TAILQ_END(head)) \ + (elm)->field.tqe_next->field.tqe_prev = (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ + } while (/*CONSTCOND*/ 0) + +#define TAILQ_REPLACE(head, elm, elm2, field) \ + do { \ + if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != TAILQ_END(head)) \ + (elm2)->field.tqe_next->field.tqe_prev = &(elm2)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm2)->field.tqe_next; \ + (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ + *(elm2)->field.tqe_prev = (elm2); \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ + } while (/*CONSTCOND*/ 0) + +#define TAILQ_CONCAT(head1, head2, field) \ + do { \ + if (!TAILQ_EMPTY(head2)) { \ + *(head1)->tqh_last = (head2)->tqh_first; \ + (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_INIT((head2)); \ + } \ + } while (/*CONSTCOND*/ 0) /* * Singly-linked Tail queue declarations. */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first; /* first element */ \ - struct type **stqh_last; /* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} +#define STAILQ_HEAD(name, type) \ + struct name { \ + struct type * stqh_first; /* first element */ \ + struct type **stqh_last; /* addr of last next element */ \ + } + +#define STAILQ_HEAD_INITIALIZER(head) \ + { \ + NULL, &(head).stqh_first \ + } + +#define STAILQ_ENTRY(type) \ + struct { \ + struct type *stqe_next; /* next element */ \ + } /* * Singly-linked Tail queue access methods. */ -#define STAILQ_FIRST(head) ((head)->stqh_first) -#define STAILQ_END(head) NULL -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) -#define STAILQ_EMPTY(head) (STAILQ_FIRST(head) == STAILQ_END(head)) +#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_END(head) NULL +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) +#define STAILQ_EMPTY(head) (STAILQ_FIRST(head) == STAILQ_END(head)) /* * Singly-linked Tail queue functions. */ -#define STAILQ_INIT(head) do { \ - (head)->stqh_first = NULL; \ - (head)->stqh_last = &(head)->stqh_first; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (head)->stqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.stqe_next = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &(elm)->field.stqe_next; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (listelm)->field.stqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ - (head)->stqh_last = &(head)->stqh_first; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_REMOVE(head, elm, type, field) do { \ - if ((head)->stqh_first == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->stqh_first; \ - while (curelm->field.stqe_next != (elm)) \ - curelm = curelm->field.stqe_next; \ - if ((curelm->field.stqe_next = \ - curelm->field.stqe_next->field.stqe_next) == NULL) \ - (head)->stqh_last = &(curelm)->field.stqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define STAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->stqh_first); \ - (var); \ - (var) = ((var)->field.stqe_next)) - -#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = STAILQ_FIRST((head)); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_CONCAT(head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -#define STAILQ_LAST(head, type, field) \ - (STAILQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->stqh_last) - offsetof(struct type, field)))) +#define STAILQ_INIT(head) \ + do { \ + (head)->stqh_first = NULL; \ + (head)->stqh_last = &(head)->stqh_first; \ + } while (/*CONSTCOND*/ 0) + +#define STAILQ_INSERT_HEAD(head, elm, field) \ + do { \ + if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (head)->stqh_first = (elm); \ + } while (/*CONSTCOND*/ 0) + +#define STAILQ_INSERT_TAIL(head, elm, field) \ + do { \ + (elm)->field.stqe_next = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &(elm)->field.stqe_next; \ + } while (/*CONSTCOND*/ 0) + +#define STAILQ_INSERT_AFTER(head, listelm, elm, field) \ + do { \ + if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (listelm)->field.stqe_next = (elm); \ + } while (/*CONSTCOND*/ 0) + +#define STAILQ_REMOVE_HEAD(head, field) \ + do { \ + if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ + (head)->stqh_last = &(head)->stqh_first; \ + } while (/*CONSTCOND*/ 0) + +#define STAILQ_REMOVE(head, elm, type, field) \ + do { \ + if ((head)->stqh_first == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->stqh_first; \ + while (curelm->field.stqe_next != (elm)) \ + curelm = curelm->field.stqe_next; \ + if ((curelm->field.stqe_next = curelm->field.stqe_next->field.stqe_next) == NULL) \ + (head)->stqh_last = &(curelm)->field.stqe_next; \ + } \ + } while (/*CONSTCOND*/ 0) + +#define STAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->stqh_first); (var); (var) = ((var)->field.stqe_next)) + +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST((head)); (var) && ((tvar) = STAILQ_NEXT((var), field), 1); (var) = (tvar)) + +#define STAILQ_CONCAT(head1, head2) \ + do { \ + if (!STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last = (head2)->stqh_first; \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_INIT((head2)); \ + } \ + } while (/*CONSTCOND*/ 0) + +#define STAILQ_LAST(head, type, field) \ + (STAILQ_EMPTY((head)) \ + ? NULL \ + : ((struct type *)(void *)((char *)((head)->stqh_last) - offsetof(struct type, field)))) #endif /* defined(__APPLE__) */ /* * Simple queue definitions. */ -#define SIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define SIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define SIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} +#define SIMPLEQ_HEAD(name, type) \ + struct name { \ + struct type * sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ + } + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { \ + NULL, &(head).sqh_first \ + } + +#define SIMPLEQ_ENTRY(type) \ + struct { \ + struct type *sqe_next; /* next element */ \ + } /* * Simple queue access methods. */ -#define SIMPLEQ_FIRST(head) ((head)->sqh_first) -#define SIMPLEQ_END(head) NULL -#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head)) -#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - -#define SIMPLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->sqh_first); \ - (var) != SIMPLEQ_END(head); \ - (var) = ((var)->field.sqe_next)) - -#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \ - for ((var) = ((head)->sqh_first); \ - (var) != SIMPLEQ_END(head) && \ - ((next = ((var)->field.sqe_next)), 1); \ - (var) = (next)) +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head)) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); (var) != SIMPLEQ_END(head); (var) = ((var)->field.sqe_next)) + +#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->sqh_first); (var) != SIMPLEQ_END(head) && ((next = ((var)->field.sqe_next)), 1); \ + (var) = (next)) /* * Simple queue functions. */ -#define SIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ - if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ - if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \ - == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ - if ((head)->sqh_first == (elm)) { \ - SIMPLEQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->sqh_first; \ - while (curelm->field.sqe_next != (elm)) \ - curelm = curelm->field.sqe_next; \ - if ((curelm->field.sqe_next = \ - curelm->field.sqe_next->field.sqe_next) == NULL) \ - (head)->sqh_last = &(curelm)->field.sqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_CONCAT(head1, head2) do { \ - if (!SIMPLEQ_EMPTY((head2))) { \ - *(head1)->sqh_last = (head2)->sqh_first; \ - (head1)->sqh_last = (head2)->sqh_last; \ - SIMPLEQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_LAST(head, type, field) \ - (SIMPLEQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->sqh_last) - offsetof(struct type, field)))) - -#endif /* H5queue_H_ */ +#define SIMPLEQ_INIT(head) \ + do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ + } while (/*CONSTCOND*/ 0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) \ + do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ + } while (/*CONSTCOND*/ 0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) \ + do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + } while (/*CONSTCOND*/ 0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) \ + do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ + } while (/*CONSTCOND*/ 0) + +#define SIMPLEQ_REMOVE_HEAD(head, field) \ + do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ + } while (/*CONSTCOND*/ 0) + +#define SIMPLEQ_REMOVE_AFTER(head, elm, field) \ + do { \ + if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + } while (/*CONSTCOND*/ 0) + +#define SIMPLEQ_REMOVE(head, elm, type, field) \ + do { \ + if ((head)->sqh_first == (elm)) { \ + SIMPLEQ_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ + } while (/*CONSTCOND*/ 0) + +#define SIMPLEQ_CONCAT(head1, head2) \ + do { \ + if (!SIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + SIMPLEQ_INIT((head2)); \ + } \ + } while (/*CONSTCOND*/ 0) + +#define SIMPLEQ_LAST(head, type, field) \ + (SIMPLEQ_EMPTY((head)) \ + ? NULL \ + : ((struct type *)(void *)((char *)((head)->sqh_last) - offsetof(struct type, field)))) + +#endif /* H5queue_H_ */ diff --git a/src/H5retry_private.h b/src/H5retry_private.h index 45ba8d2..96d9fa8 100644 --- a/src/H5retry_private.h +++ b/src/H5retry_private.h @@ -18,20 +18,20 @@ /* State for a retry loop. No user-serviceable parts inside. */ typedef struct h5_retry_t { - uint64_t maxival; /* maximum sleep interval (nanoseconds) */ - unsigned maxtries; /* maximum permissible tries */ - unsigned tries; /* remaining tries */ - uint64_t ival; /* nanoseconds sleep interval before clamping to - * maxival - */ + uint64_t maxival; /* maximum sleep interval (nanoseconds) */ + unsigned maxtries; /* maximum permissible tries */ + unsigned tries; /* remaining tries */ + uint64_t ival; /* nanoseconds sleep interval before clamping to + * maxival + */ } h5_retry_t; /* Default minimum/maximum retry intervals: 1/10s minimum, 1s maximum. */ -#define H5_RETRY_DEFAULT_MINIVAL ( 100ULL * 1000ULL * 1000ULL) -#define H5_RETRY_DEFAULT_MAXIVAL ( 1000ULL * 1000ULL * 1000ULL) +#define H5_RETRY_DEFAULT_MINIVAL (100ULL * 1000ULL * 1000ULL) +#define H5_RETRY_DEFAULT_MAXIVAL (1000ULL * 1000ULL * 1000ULL) /* One hour: */ -#define H5_RETRY_ONE_SECOND (1000ULL * 1000ULL * 1000ULL) -#define H5_RETRY_ONE_HOUR (3600ULL * H5_RETRY_ONE_SECOND) +#define H5_RETRY_ONE_SECOND (1000ULL * 1000ULL * 1000ULL) +#define H5_RETRY_ONE_HOUR (3600ULL * H5_RETRY_ONE_SECOND) /* If any tries remain, decrease the number of remaining tries and * return true. Otherwise, return false. @@ -53,7 +53,7 @@ h5_retry_decrement(struct h5_retry_t *r) * increase to `maxival` nanoseconds or twice the previous sleep time, * whichever is less. * - * `h5_retry_init` always returns true. This is to help one use + * `h5_retry_init` always returns true. This is to help one use * it in a loop like this: * * for (do_try = h5_retry_init(&r, 100, H5_RETRY_DEFAULT_MINIVAL, @@ -69,15 +69,14 @@ h5_retry_decrement(struct h5_retry_t *r) * than 101 times: once for an initial try, and then 100 times for retries. */ static inline bool -h5_retry_init(struct h5_retry_t *r, unsigned int maxtries, uint64_t minival, - uint64_t maxival) +h5_retry_init(struct h5_retry_t *r, unsigned int maxtries, uint64_t minival, uint64_t maxival) { memset(r, '\0', sizeof(*r)); assert(0 < maxtries); assert(0 < minival && minival <= maxival); r->tries = r->maxtries = maxtries; - r->ival = minival; - r->maxival = maxival; + r->ival = minival; + r->maxival = maxival; return h5_retry_decrement(r); } diff --git a/src/H5system.c b/src/H5system.c index 1ece733..feb1af6 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -26,46 +26,38 @@ /* Module Setup */ /****************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -73,7 +65,6 @@ /* Track whether tzset routine was called */ static hbool_t H5_ntzset = FALSE; - /*------------------------------------------------------------------------- * Function: HDfprintf * @@ -107,47 +98,48 @@ static hbool_t H5_ntzset = FALSE; * format_templ in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") int HDfprintf(FILE *stream, const char *fmt, ...) { - int n=0, nout = 0; - int fwidth, prec; - int zerofill; - int leftjust; - int plussign; - int ldspace; - int prefix; - char modifier[8]; - int conv; - char *rest, format_templ[128]; - int len; - const char *s; - va_list ap; + int n = 0, nout = 0; + int fwidth, prec; + int zerofill; + int leftjust; + int plussign; + int ldspace; + int prefix; + char modifier[8]; + int conv; + char * rest, format_templ[128]; + int len; + const char *s; + va_list ap; HDassert(stream); HDassert(fmt); - HDva_start (ap, fmt); + HDva_start(ap, fmt); while (*fmt) { fwidth = prec = 0; - zerofill = 0; - leftjust = 0; - plussign = 0; - prefix = 0; - ldspace = 0; - modifier[0] = '\0'; - - if ('%'==fmt[0] && '%'==fmt[1]) { - HDputc ('%', stream); + zerofill = 0; + leftjust = 0; + plussign = 0; + prefix = 0; + ldspace = 0; + modifier[0] = '\0'; + + if ('%' == fmt[0] && '%' == fmt[1]) { + HDputc('%', stream); fmt += 2; nout++; - } else if ('%'==fmt[0]) { + } + else if ('%' == fmt[0]) { s = fmt + 1; /* Flags */ - while(HDstrchr("-+ #", *s)) { - switch(*s) { + while (HDstrchr("-+ #", *s)) { + switch (*s) { case '-': leftjust = 1; break; @@ -171,43 +163,44 @@ HDfprintf(FILE *stream, const char *fmt, ...) } /* end while */ /* Field width */ - if(HDisdigit(*s)) { + if (HDisdigit(*s)) { zerofill = ('0' == *s); - fwidth = (int)HDstrtol (s, &rest, 10); - s = rest; + fwidth = (int)HDstrtol(s, &rest, 10); + s = rest; } /* end if */ - else if ('*'==*s) { + else if ('*' == *s) { fwidth = HDva_arg(ap, int); - if(fwidth < 0) { + if (fwidth < 0) { leftjust = 1; - fwidth = -fwidth; + fwidth = -fwidth; } s++; } /* Precision */ - if('.'==*s) { + if ('.' == *s) { s++; - if(HDisdigit(*s)) { + if (HDisdigit(*s)) { prec = (int)HDstrtol(s, &rest, 10); - s = rest; - } else if('*'==*s) { + s = rest; + } + else if ('*' == *s) { prec = HDva_arg(ap, int); s++; } - if(prec < 1) + if (prec < 1) prec = 1; } /* Extra type modifiers */ - if(HDstrchr("zZHhlqLI", *s)) { - switch(*s) { + if (HDstrchr("zZHhlqLI", *s)) { + switch (*s) { /*lint --e{506} Don't issue warnings about constant value booleans */ /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ case 'H': - if(sizeof(hsize_t) < sizeof(long)) + if (sizeof(hsize_t) < sizeof(long)) modifier[0] = '\0'; - else if(sizeof(hsize_t) == sizeof(long)) { + else if (sizeof(hsize_t) == sizeof(long)) { HDstrncpy(modifier, "l", sizeof(modifier)); modifier[sizeof(modifier) - 1] = '\0'; } /* end if */ @@ -219,9 +212,9 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'Z': case 'z': - if(sizeof(size_t) < sizeof(long)) + if (sizeof(size_t) < sizeof(long)) modifier[0] = '\0'; - else if(sizeof(size_t) == sizeof(long)) { + else if (sizeof(size_t) == sizeof(long)) { HDstrncpy(modifier, "l", sizeof(modifier)); modifier[sizeof(modifier) - 1] = '\0'; } /* end if */ @@ -233,26 +226,26 @@ HDfprintf(FILE *stream, const char *fmt, ...) default: /* Handle 'I64' modifier for Microsoft's "__int64" type */ - if(*s=='I' && *(s+1)=='6' && *(s+2)=='4') { + if (*s == 'I' && *(s + 1) == '6' && *(s + 2) == '4') { modifier[0] = *s; - modifier[1] = *(s+1); - modifier[2] = *(s+2); + modifier[1] = *(s + 1); + modifier[2] = *(s + 2); modifier[3] = '\0'; s += 2; /* Increment over 'I6', the '4' is taken care of below */ - } /* end if */ + } /* end if */ else { /* Handle 'll' for long long types */ - if(*s=='l' && *(s+1)=='l') { + if (*s == 'l' && *(s + 1) == 'l') { modifier[0] = *s; modifier[1] = *s; modifier[2] = '\0'; s++; /* Increment over first 'l', second is taken care of below */ - } /* end if */ + } /* end if */ else { modifier[0] = *s; modifier[1] = '\0'; } /* end else */ - } /* end else */ + } /* end else */ break; } s++; @@ -263,33 +256,39 @@ HDfprintf(FILE *stream, const char *fmt, ...) /* Create the format template */ len = 0; - len += HDsnprintf(format_templ, (sizeof(format_templ) - (size_t)(len + 1)), "%%%s%s%s%s%s", (leftjust ? "-" : ""), - (plussign ? "+" : ""), (ldspace ? " " : ""), - (prefix ? "#" : ""), (zerofill ? "0" : "")); - if(fwidth > 0) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%d", fwidth); - if(prec > 0) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), ".%d", prec); - if(*modifier) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%s", modifier); + len += HDsnprintf(format_templ, (sizeof(format_templ) - (size_t)(len + 1)), "%%%s%s%s%s%s", + (leftjust ? "-" : ""), (plussign ? "+" : ""), (ldspace ? " " : ""), + (prefix ? "#" : ""), (zerofill ? "0" : "")); + if (fwidth > 0) + len += + HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%d", fwidth); + if (prec > 0) + len += + HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), ".%d", prec); + if (*modifier) + len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%s", + modifier); HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%c", conv); /* Conversion */ switch (conv) { case 'd': case 'i': - if(!HDstrcmp(modifier, "h")) { + if (!HDstrcmp(modifier, "h")) { short x = (short)HDva_arg(ap, int); - n = fprintf(stream, format_templ, x); - } else if(!*modifier) { + n = fprintf(stream, format_templ, x); + } + else if (!*modifier) { int x = HDva_arg(ap, int); - n = fprintf(stream, format_templ, x); - } else if(!HDstrcmp(modifier, "l")) { + n = fprintf(stream, format_templ, x); + } + else if (!HDstrcmp(modifier, "l")) { long x = HDva_arg(ap, long); - n = fprintf(stream, format_templ, x); - } else { + n = fprintf(stream, format_templ, x); + } + else { int64_t x = HDva_arg(ap, int64_t); - n = fprintf(stream, format_templ, x); + n = fprintf(stream, format_templ, x); } break; @@ -297,18 +296,21 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'u': case 'x': case 'X': - if(!HDstrcmp(modifier, "h")) { + if (!HDstrcmp(modifier, "h")) { unsigned short x = (unsigned short)HDva_arg(ap, unsigned int); - n = fprintf(stream, format_templ, x); - } else if(!*modifier) { + n = fprintf(stream, format_templ, x); + } + else if (!*modifier) { unsigned int x = HDva_arg(ap, unsigned int); - n = fprintf(stream, format_templ, x); - } else if(!HDstrcmp(modifier, "l")) { + n = fprintf(stream, format_templ, x); + } + else if (!HDstrcmp(modifier, "l")) { unsigned long x = HDva_arg(ap, unsigned long); - n = fprintf(stream, format_templ, x); - } else { + n = fprintf(stream, format_templ, x); + } + else { uint64_t x = HDva_arg(ap, uint64_t); - n = fprintf(stream, format_templ, x); + n = fprintf(stream, format_templ, x); } break; @@ -317,145 +319,133 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'E': case 'g': case 'G': - if(!HDstrcmp(modifier, "h")) { + if (!HDstrcmp(modifier, "h")) { float x = (float)HDva_arg(ap, double); - n = fprintf(stream, format_templ, (double)x); - } else if(!*modifier || !HDstrcmp(modifier, "l")) { + n = fprintf(stream, format_templ, (double)x); + } + else if (!*modifier || !HDstrcmp(modifier, "l")) { double x = HDva_arg(ap, double); - n = fprintf(stream, format_templ, x); - } else { - /* - * Some compilers complain when `long double' and - * `double' are the same thing. - */ + n = fprintf(stream, format_templ, x); + } + else { + /* + * Some compilers complain when `long double' and + * `double' are the same thing. + */ #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE long double x = HDva_arg(ap, long double); - n = fprintf(stream, format_templ, x); + n = fprintf(stream, format_templ, x); #else double x = HDva_arg(ap, double); - n = fprintf(stream, format_templ, x); + n = fprintf(stream, format_templ, x); #endif } break; - case 'a': - { - haddr_t x = HDva_arg(ap, haddr_t); - - if(H5F_addr_defined(x)) { - len = 0; - len += HDsnprintf(format_templ, (sizeof(format_templ) - (size_t)(len + 1)), "%%%s%s%s%s%s", - (leftjust ? "-" : ""), (plussign ? "+" : ""), - (ldspace ? " " : ""), (prefix ? "#" : ""), - (zerofill ? "0" : "")); - if(fwidth > 0) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%d", fwidth); - - /*lint --e{506} Don't issue warnings about constant value booleans */ - /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ - if(sizeof(x) == H5_SIZEOF_INT) { - HDstrncat(format_templ, "u", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - } /* end if */ - else if(sizeof(x) == H5_SIZEOF_LONG) { - HDstrncat(format_templ, "lu", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - } /* end if */ - else if(sizeof(x) == H5_SIZEOF_LONG_LONG) { - HDstrncat(format_templ, H5_PRINTF_LL_WIDTH, (sizeof(format_templ) - (size_t)(len + 1))); - len += (int)sizeof(H5_PRINTF_LL_WIDTH); - HDstrncat(format_templ, "u", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - } - n = fprintf(stream, format_templ, x); - } else { - len = 0; - HDstrncpy(format_templ, "%", (sizeof(format_templ) - (size_t)(len + 1))); + case 'a': { + haddr_t x = HDva_arg(ap, haddr_t); + + if (H5F_addr_defined(x)) { + len = 0; + len += HDsnprintf(format_templ, (sizeof(format_templ) - (size_t)(len + 1)), + "%%%s%s%s%s%s", (leftjust ? "-" : ""), (plussign ? "+" : ""), + (ldspace ? " " : ""), (prefix ? "#" : ""), (zerofill ? "0" : "")); + if (fwidth > 0) + len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), + "%d", fwidth); + + /*lint --e{506} Don't issue warnings about constant value booleans */ + /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true + */ + if (sizeof(x) == H5_SIZEOF_INT) { + HDstrncat(format_templ, "u", (sizeof(format_templ) - (size_t)(len + 1))); + len++; + } /* end if */ + else if (sizeof(x) == H5_SIZEOF_LONG) { + HDstrncat(format_templ, "lu", (sizeof(format_templ) - (size_t)(len + 1))); + len++; + } /* end if */ + else if (sizeof(x) == H5_SIZEOF_LONG_LONG) { + HDstrncat(format_templ, H5_PRINTF_LL_WIDTH, + (sizeof(format_templ) - (size_t)(len + 1))); + len += (int)sizeof(H5_PRINTF_LL_WIDTH); + HDstrncat(format_templ, "u", (sizeof(format_templ) - (size_t)(len + 1))); len++; - if(leftjust) { - HDstrncat(format_templ, "-", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - } /* end if */ - if(fwidth) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%d", fwidth); - HDstrncat(format_templ, "s", (sizeof(format_templ) - (size_t)(len + 1))); - n = fprintf(stream, format_templ, "UNDEF"); } - } - break; - - case 'c': - { - char x = (char)HDva_arg(ap, int); n = fprintf(stream, format_templ, x); } - break; + else { + len = 0; + HDstrncpy(format_templ, "%", (sizeof(format_templ) - (size_t)(len + 1))); + len++; + if (leftjust) { + HDstrncat(format_templ, "-", (sizeof(format_templ) - (size_t)(len + 1))); + len++; + } /* end if */ + if (fwidth) + len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), + "%d", fwidth); + HDstrncat(format_templ, "s", (sizeof(format_templ) - (size_t)(len + 1))); + n = fprintf(stream, format_templ, "UNDEF"); + } + } break; + + case 'c': { + char x = (char)HDva_arg(ap, int); + n = fprintf(stream, format_templ, x); + } break; case 's': - case 'p': - { - char *x = HDva_arg(ap, char*); - n = fprintf(stream, format_templ, x); - } - break; + case 'p': { + char *x = HDva_arg(ap, char *); + n = fprintf(stream, format_templ, x); + } break; case 'n': format_templ[HDstrlen(format_templ) - 1] = 'u'; - n = fprintf(stream, format_templ, nout); + n = fprintf(stream, format_templ, nout); break; - case 't': - { - htri_t tri_var = HDva_arg(ap, htri_t); - - if(tri_var > 0) - n = fprintf(stream, "TRUE"); - else if(!tri_var) - n = fprintf(stream, "FALSE"); - else - n = fprintf(stream, "FAIL(%d)", (int)tri_var); - } - break; - - case 'T': /* Elapsed time, in seconds */ - { - double seconds = HDva_arg(ap, double); - char *time_string = H5_timer_get_time_string(seconds); - - if(time_string) { - n = fprintf(stream, format_templ, time_string); - HDfree(time_string); - } /* end if */ - else - n = fprintf(stream, format_templ, "(error)"); - } - break; - - case 'k': - { - H5O_token_t token = HDva_arg(ap, H5O_token_t); - - /* Print the raw token. */ - n = fprintf(stream, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - (unsigned char)token.__data[15], - (unsigned char)token.__data[14], - (unsigned char)token.__data[13], - (unsigned char)token.__data[12], - (unsigned char)token.__data[11], - (unsigned char)token.__data[10], - (unsigned char)token.__data[9], - (unsigned char)token.__data[8], - (unsigned char)token.__data[7], - (unsigned char)token.__data[6], - (unsigned char)token.__data[5], - (unsigned char)token.__data[4], - (unsigned char)token.__data[3], - (unsigned char)token.__data[2], - (unsigned char)token.__data[1], - (unsigned char)token.__data[0] - ); - } - break; + case 't': { + htri_t tri_var = HDva_arg(ap, htri_t); + + if (tri_var > 0) + n = fprintf(stream, "TRUE"); + else if (!tri_var) + n = fprintf(stream, "FALSE"); + else + n = fprintf(stream, "FAIL(%d)", (int)tri_var); + } break; + + case 'T': /* Elapsed time, in seconds */ + { + double seconds = HDva_arg(ap, double); + char * time_string = H5_timer_get_time_string(seconds); + + if (time_string) { + n = fprintf(stream, format_templ, time_string); + HDfree(time_string); + } /* end if */ + else + n = fprintf(stream, format_templ, "(error)"); + } break; + + case 'k': { + H5O_token_t token = HDva_arg(ap, H5O_token_t); + + /* Print the raw token. */ + n = fprintf( + stream, + "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + (unsigned char)token.__data[15], (unsigned char)token.__data[14], + (unsigned char)token.__data[13], (unsigned char)token.__data[12], + (unsigned char)token.__data[11], (unsigned char)token.__data[10], + (unsigned char)token.__data[9], (unsigned char)token.__data[8], + (unsigned char)token.__data[7], (unsigned char)token.__data[6], + (unsigned char)token.__data[5], (unsigned char)token.__data[4], + (unsigned char)token.__data[3], (unsigned char)token.__data[2], + (unsigned char)token.__data[1], (unsigned char)token.__data[0]); + } break; default: HDfputs(format_templ, stream); @@ -464,7 +454,8 @@ HDfprintf(FILE *stream, const char *fmt, ...) } nout += n; fmt = s; - } else { + } + else { HDputc(*fmt, stream); fmt++; nout++; @@ -473,9 +464,8 @@ HDfprintf(FILE *stream, const char *fmt, ...) HDva_end(ap); return nout; } /* end HDfprintf() */ -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - /*------------------------------------------------------------------------- * Function: HDstrtoll * @@ -516,69 +506,67 @@ H5_GCC_DIAG_ON(format-nonliteral) * Programmer: Robb Matzke * Thursday, April 9, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ #ifndef HDstrtoll int64_t HDstrtoll(const char *s, const char **rest, int base) { - int64_t sign=1, acc=0; - hbool_t overflow = FALSE; + int64_t sign = 1, acc = 0; + hbool_t overflow = FALSE; errno = 0; - if (!s || (base && (base<2 || base>36))) { + if (!s || (base && (base < 2 || base > 36))) { if (rest) *rest = s; return 0; } /* Skip white space */ - while (HDisspace (*s)) s++; + while (HDisspace(*s)) + s++; /* Optional minus or plus sign */ - if ('+'==*s) { + if ('+' == *s) { s++; } - else if ('-'==*s) { + else if ('-' == *s) { sign = -1; s++; } /* Zero base prefix */ - if (0==base && '0'==*s && ('x'==s[1] || 'X'==s[1])) { + if (0 == base && '0' == *s && ('x' == s[1] || 'X' == s[1])) { base = 16; s += 2; } - else if (0==base && '0'==*s) { + else if (0 == base && '0' == *s) { base = 8; s++; } - else if (0==base) { + else if (0 == base) { base = 10; } /* Digits */ - while ((base<=10 && *s>='0' && *s<'0'+base) || - (base>10 && ((*s>='0' && *s<='9') || - (*s>='a' && *s<'a'+base-10) || - (*s>='A' && *s<'A'+base-10)))) { + while ((base <= 10 && *s >= '0' && *s < '0' + base) || + (base > 10 && ((*s >= '0' && *s <= '9') || (*s >= 'a' && *s < 'a' + base - 10) || + (*s >= 'A' && *s < 'A' + base - 10)))) { if (!overflow) { int64_t digit = 0; - if (*s>='0' && *s<='9') + if (*s >= '0' && *s <= '9') digit = *s - '0'; - else if (*s>='a' && *s<='z') - digit = (*s-'a')+10; + else if (*s >= 'a' && *s <= 'z') + digit = (*s - 'a') + 10; else - digit = (*s-'A')+10; + digit = (*s - 'A') + 10; - if (acc*base+digit < acc) { + if (acc * base + digit < acc) { overflow = TRUE; } else { - acc = acc*base + digit; + acc = acc * base + digit; } } s++; @@ -586,11 +574,11 @@ HDstrtoll(const char *s, const char **rest, int base) /* Overflow */ if (overflow) { - if (sign>0) { - acc = ((uint64_t)1<<(8*sizeof(int64_t)-1))-1; + if (sign > 0) { + acc = ((uint64_t)1 << (8 * sizeof(int64_t) - 1)) - 1; } else { - acc = (int64_t)((uint64_t)1<<(8*sizeof(int64_t)-1)); + acc = (int64_t)((uint64_t)1 << (8 * sizeof(int64_t) - 1)); } errno = ERANGE; } @@ -602,7 +590,7 @@ HDstrtoll(const char *s, const char **rest, int base) return acc; } /* end HDstrtoll() */ #endif - + /*------------------------------------------------------------------------- * Function: HDrand/HDsrand * @@ -626,19 +614,19 @@ HDstrtoll(const char *s, const char **rest, int base) static unsigned int g_seed = 42; -int HDrand(void) +int +HDrand(void) { return rand_r(&g_seed); } -void HDsrand(unsigned int seed) +void +HDsrand(unsigned int seed) { g_seed = seed; } #endif /* H5_HAVE_RAND_R */ - - /*------------------------------------------------------------------------- * Function: Pflock * @@ -655,26 +643,27 @@ void HDsrand(unsigned int seed) */ #ifdef H5_HAVE_FCNTL int -Pflock(int fd, int operation) { +Pflock(int fd, int operation) +{ - struct flock flk; + struct flock flk; /* Set the lock type */ - if(operation & LOCK_UN) + if (operation & LOCK_UN) flk.l_type = F_UNLCK; - else if(operation & LOCK_SH) + else if (operation & LOCK_SH) flk.l_type = F_RDLCK; else flk.l_type = F_WRLCK; /* Set the other flock struct values */ flk.l_whence = SEEK_SET; - flk.l_start = 0; - flk.l_len = 0; /* to EOF */ - flk.l_pid = 0; /* not used with set */ + flk.l_start = 0; + flk.l_len = 0; /* to EOF */ + flk.l_pid = 0; /* not used with set */ /* Lock or unlock */ - if(HDfcntl(fd, F_SETLK, &flk) < 0) + if (HDfcntl(fd, F_SETLK, &flk) < 0) return -1; return 0; @@ -682,7 +671,6 @@ Pflock(int fd, int operation) { } /* end Pflock() */ #endif /* H5_HAVE_FCNTL */ - /*------------------------------------------------------------------------- * Function: Nflock * @@ -694,12 +682,12 @@ Pflock(int fd, int operation) { *------------------------------------------------------------------------- */ int H5_ATTR_CONST -Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) { +Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) +{ /* just fail */ return -1; } /* end Nflock() */ - /*------------------------------------------------------------------------- * Function: H5_make_time * @@ -722,15 +710,15 @@ Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) { time_t H5_make_time(struct tm *tm) { - time_t the_time; /* The converted time */ -#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */ + time_t the_time; /* The converted time */ +#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */ /* In gcc and in Visual Studio prior to VS 2015 'timezone' is a global * variable declared in time.h. That variable was deprecated and in * VS 2015 is removed, with _get_timezone replacing it. */ long timezone = 0; -#endif /* defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) */ - time_t ret_value; /* Return value */ +#endif /* defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) */ + time_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -738,21 +726,21 @@ H5_make_time(struct tm *tm) HDassert(tm); /* Initialize timezone information */ - if(!H5_ntzset) { + if (!H5_ntzset) { HDtzset(); H5_ntzset = TRUE; } /* end if */ /* Perform base conversion */ - if((time_t)-1 == (the_time = HDmktime(tm))) + if ((time_t)-1 == (the_time = HDmktime(tm))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCONVERT, FAIL, "badly formatted modification time message") - /* Adjust for timezones */ + /* Adjust for timezones */ #if defined(H5_HAVE_TM_GMTOFF) /* BSD-like systems */ the_time += tm->tm_gmtoff; #elif defined(H5_HAVE_TIMEZONE) -#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */ +#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */ /* In gcc and in Visual Studio prior to VS 2015 'timezone' is a global * variable declared in time.h. That variable was deprecated and in * VS 2015 is removed, with _get_timezone replacing it. @@ -784,7 +772,6 @@ done: /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosecond units */ #define _W32_FT_OFFSET (116444736000000000ULL) - /*------------------------------------------------------------------------- * Function: Wgettimeofday * @@ -809,34 +796,33 @@ done: int Wgettimeofday(struct timeval *tv, struct timezone *tz) { - union { - unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */ - FILETIME ft; - } _now; + union { + unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */ + FILETIME ft; + } _now; static int tzsetflag; - if(tv) { - GetSystemTimeAsFileTime (&_now.ft); - tv->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL ); - tv->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); + if (tv) { + GetSystemTimeAsFileTime(&_now.ft); + tv->tv_usec = (long)((_now.ns100 / 10ULL) % 1000000ULL); + tv->tv_sec = (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); } - if(tz) { - if(!tzsetflag) { + if (tz) { + if (!tzsetflag) { _tzset(); tzsetflag = 1; } tz->tz_minuteswest = _timezone / 60; - tz->tz_dsttime = _daylight; + tz->tz_dsttime = _daylight; } - /* Always return 0 as per Open Group Base Specifications Issue 6. - Do not set errno on error. */ - return 0; + /* Always return 0 as per Open Group Base Specifications Issue 6. + Do not set errno on error. */ + return 0; } /* end Wgettimeofday() */ - /*------------------------------------------------------------------------- * Function: Wsetenv * @@ -855,14 +841,14 @@ Wgettimeofday(struct timeval *tv, struct timezone *tz) int Wsetenv(const char *name, const char *value, int overwrite) { - size_t bufsize; + size_t bufsize; errno_t err; /* If we're not overwriting, check if the environment variable exists. * If it does (i.e.: the required buffer size to store the variable's * value is non-zero), then return an error code. */ - if(!overwrite) { + if (!overwrite) { err = getenv_s(&bufsize, NULL, 0, name); if (err || bufsize) return (int)err; @@ -875,7 +861,6 @@ Wsetenv(const char *name, const char *value, int overwrite) #pragma comment(lib, "advapi32.lib") #endif - /*------------------------------------------------------------------------- * Function: H5_get_win32_times * @@ -894,25 +879,25 @@ Wsetenv(const char *name, const char *value, int overwrite) int H5_get_win32_times(H5_timevals_t *tvs /*in,out*/) { - static HANDLE process_handle; - ULARGE_INTEGER kernel_start; - ULARGE_INTEGER user_start; - FILETIME KernelTime; - FILETIME UserTime; - FILETIME CreationTime; - FILETIME ExitTime; - LARGE_INTEGER counts_start; + static HANDLE process_handle; + ULARGE_INTEGER kernel_start; + ULARGE_INTEGER user_start; + FILETIME KernelTime; + FILETIME UserTime; + FILETIME CreationTime; + FILETIME ExitTime; + LARGE_INTEGER counts_start; static LARGE_INTEGER counts_freq; - static hbool_t is_initialized = FALSE; - BOOL err; + static hbool_t is_initialized = FALSE; + BOOL err; HDassert(tvs); - if(!is_initialized) { + if (!is_initialized) { /* NOTE: This is just a pseudo handle and does not need to be closed. */ process_handle = GetCurrentProcess(); - err = QueryPerformanceFrequency(&counts_freq); - if(0 == err) + err = QueryPerformanceFrequency(&counts_freq); + if (0 == err) return -1; is_initialized = TRUE; } /* end if */ @@ -921,28 +906,27 @@ H5_get_win32_times(H5_timevals_t *tvs /*in,out*/) * System and user times * *************************/ - err = GetProcessTimes(process_handle, &CreationTime, &ExitTime, &KernelTime, - &UserTime); - if(0 == err) + err = GetProcessTimes(process_handle, &CreationTime, &ExitTime, &KernelTime, &UserTime); + if (0 == err) return -1; /* The 1.0E7 factor seems strange but it's due to the clock * ticking in 100 ns increments. */ kernel_start.HighPart = KernelTime.dwHighDateTime; - kernel_start.LowPart = KernelTime.dwLowDateTime; - tvs->system = (double)(kernel_start.QuadPart / 1.0E7F); + kernel_start.LowPart = KernelTime.dwLowDateTime; + tvs->system = (double)(kernel_start.QuadPart / 1.0E7F); user_start.HighPart = UserTime.dwHighDateTime; - user_start.LowPart = UserTime.dwLowDateTime; - tvs->user = (double)(user_start.QuadPart / 1.0E7F); + user_start.LowPart = UserTime.dwLowDateTime; + tvs->user = (double)(user_start.QuadPart / 1.0E7F); /**************** * Elapsed time * ****************/ err = QueryPerformanceCounter(&counts_start); - if(0 == err) + if (0 == err) return -1; tvs->elapsed = (double)(counts_start.QuadPart) / (double)counts_freq.QuadPart; @@ -954,8 +938,7 @@ H5_get_win32_times(H5_timevals_t *tvs /*in,out*/) #define WloginBuffer_count 256 static char Wlogin_buffer[WloginBuffer_count]; - -char* +char * Wgetlogin(void) { @@ -968,7 +951,6 @@ Wgetlogin(void) return NULL; } - /*------------------------------------------------------------------------- * Function: Wflock * @@ -980,7 +962,8 @@ Wgetlogin(void) *------------------------------------------------------------------------- */ int -Wflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) { +Wflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) +{ /* This is a no-op while we implement a Win32 VFD */ #if 0 @@ -1017,44 +1000,44 @@ Wflock(int fd, int operation) { } /* end Wflock() */ /*------------------------------------------------------------------------- -* Function: H5_get_utf16_str -* -* Purpose: Gets a UTF-16 string from an UTF-8 (or ASCII) string. -* -* Return: Success: A pointer to a UTF-16 string -* This must be freed by the caller using H5MM_xfree() -* Failure: NULL -* -* Programmer: Dana Robinson -* Spring 2019 -* -*------------------------------------------------------------------------- -*/ + * Function: H5_get_utf16_str + * + * Purpose: Gets a UTF-16 string from an UTF-8 (or ASCII) string. + * + * Return: Success: A pointer to a UTF-16 string + * This must be freed by the caller using H5MM_xfree() + * Failure: NULL + * + * Programmer: Dana Robinson + * Spring 2019 + * + *------------------------------------------------------------------------- + */ const wchar_t * H5_get_utf16_str(const char *s) { - int nwchars = -1; /* Length of the UTF-16 buffer */ - wchar_t *ret_s = NULL; /* UTF-16 version of the string */ + int nwchars = -1; /* Length of the UTF-16 buffer */ + wchar_t *ret_s = NULL; /* UTF-16 version of the string */ /* Get the number of UTF-16 characters needed */ - if(0 == (nwchars = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0))) + if (0 == (nwchars = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0))) goto error; /* Allocate a buffer for the UTF-16 string */ - if(NULL == (ret_s = (wchar_t *)H5MM_calloc(sizeof(wchar_t) * (size_t)nwchars))) + if (NULL == (ret_s = (wchar_t *)H5MM_calloc(sizeof(wchar_t) * (size_t)nwchars))) goto error; /* Convert the input UTF-8 string to UTF-16 */ - if(0 == MultiByteToWideChar(CP_UTF8, 0, s, -1, ret_s, nwchars)) + if (0 == MultiByteToWideChar(CP_UTF8, 0, s, -1, ret_s, nwchars)) goto error; return ret_s; error: - if(ret_s) + if (ret_s) H5MM_xfree((void *)ret_s); return NULL; -} /* end H5_get_utf16_str() */ +} /* end H5_get_utf16_str() */ /*------------------------------------------------------------------------- * Function: Wopen_utf8 @@ -1074,22 +1057,22 @@ error: int Wopen_utf8(const char *path, int oflag, ...) { - int fd = -1; /* POSIX file descriptor to be returned */ - wchar_t *wpath = NULL; /* UTF-16 version of the path */ - int pmode = 0; /* mode (optionally set via variable args) */ + int fd = -1; /* POSIX file descriptor to be returned */ + wchar_t *wpath = NULL; /* UTF-16 version of the path */ + int pmode = 0; /* mode (optionally set via variable args) */ /* Convert the input UTF-8 path to UTF-16 */ - if(NULL == (wpath = H5_get_utf16_str(path))) + if (NULL == (wpath = H5_get_utf16_str(path))) goto done; /* _O_BINARY must be set in Windows to avoid CR-LF <-> LF EOL - * transformations when performing I/O. Note that this will - * produce Unix-style text files, though. - */ + * transformations when performing I/O. Note that this will + * produce Unix-style text files, though. + */ oflag |= _O_BINARY; /* Get the mode, if O_CREAT was specified */ - if(oflag & O_CREAT) { + if (oflag & O_CREAT) { va_list vl; HDva_start(vl, oflag); @@ -1101,11 +1084,11 @@ Wopen_utf8(const char *path, int oflag, ...) fd = _wopen(wpath, oflag, pmode); done: - if(wpath) + if (wpath) H5MM_xfree((void *)wpath); return fd; -} /* end Wopen_utf8() */ +} /* end Wopen_utf8() */ /*------------------------------------------------------------------------- * Function: Wremove_utf8 @@ -1125,26 +1108,25 @@ done: int Wremove_utf8(const char *path) { - wchar_t *wpath = NULL; /* UTF-16 version of the path */ - int ret; + wchar_t *wpath = NULL; /* UTF-16 version of the path */ + int ret; /* Convert the input UTF-8 path to UTF-16 */ - if(NULL == (wpath = H5_get_utf16_str(path))) + if (NULL == (wpath = H5_get_utf16_str(path))) goto done; /* Open the file */ ret = _wremove(wpath); done: - if(wpath) + if (wpath) H5MM_xfree((void *)wpath); return ret; -} /* end Wremove_utf8() */ +} /* end Wremove_utf8() */ #endif /* H5_HAVE_WIN32_API */ - /*------------------------------------------------------------------------- * Function: H5_build_extpath * @@ -1161,15 +1143,15 @@ done: * *------------------------------------------------------------------------- */ -#define MAX_PATH_LEN 1024 +#define MAX_PATH_LEN 1024 herr_t H5_build_extpath(const char *name, char **extpath /*out*/) { - char *full_path = NULL; /* Pointer to the full path, as built or passed in */ - char *cwdpath = NULL; /* Pointer to the current working directory path */ - char *new_name = NULL; /* Pointer to the name of the file */ - herr_t ret_value = SUCCEED; /* Return value */ + char * full_path = NULL; /* Pointer to the full path, as built or passed in */ + char * cwdpath = NULL; /* Pointer to the current working directory path */ + char * new_name = NULL; /* Pointer to the name of the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1184,19 +1166,19 @@ H5_build_extpath(const char *name, char **extpath /*out*/) * Unix: name[0] is a "/" * Windows: name[0-2] is ":\" or ":/" */ - if(H5_CHECK_ABSOLUTE(name)) { - if(NULL == (full_path = (char *)H5MM_strdup(name))) + if (H5_CHECK_ABSOLUTE(name)) { + if (NULL == (full_path = (char *)H5MM_strdup(name))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") - } /* end if */ + } /* end if */ else { /* relative pathname */ - char *retcwd; + char * retcwd; size_t name_len; - int drive; + int drive; - if(NULL == (cwdpath = (char *)H5MM_malloc(MAX_PATH_LEN))) + if (NULL == (cwdpath = (char *)H5MM_malloc(MAX_PATH_LEN))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") name_len = HDstrlen(name) + 1; - if(NULL == (new_name = (char *)H5MM_malloc(name_len))) + if (NULL == (new_name = (char *)H5MM_malloc(name_len))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") /* @@ -1204,17 +1186,17 @@ H5_build_extpath(const char *name, char **extpath /*out*/) * Get current working directory on the drive specified in NAME * Unix: does not apply */ - if(H5_CHECK_ABS_DRIVE(name)) { - drive = HDtoupper(name[0]) - 'A' + 1; + if (H5_CHECK_ABS_DRIVE(name)) { + drive = HDtoupper(name[0]) - 'A' + 1; retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN); HDstrncpy(new_name, &name[2], name_len); } /* end if */ - /* - * Windows: name[0] is a '/' or '\' - * Get current drive - * Unix: does not apply - */ - else if(H5_CHECK_ABS_PATH(name) && (0 != (drive = HDgetdrive()))) { + /* + * Windows: name[0] is a '/' or '\' + * Get current drive + * Unix: does not apply + */ + else if (H5_CHECK_ABS_PATH(name) && (0 != (drive = HDgetdrive()))) { HDsnprintf(cwdpath, MAX_PATH_LEN, "%c:%c", (drive + 'A' - 1), name[0]); retcwd = cwdpath; HDstrncpy(new_name, &name[1], name_len); @@ -1225,7 +1207,7 @@ H5_build_extpath(const char *name, char **extpath /*out*/) HDstrncpy(new_name, name, name_len); } /* end if */ - if(retcwd != NULL) { + if (retcwd != NULL) { size_t cwdlen; size_t path_len; @@ -1234,37 +1216,36 @@ H5_build_extpath(const char *name, char **extpath /*out*/) HDassert(cwdlen); HDassert(new_name); path_len = cwdlen + HDstrlen(new_name) + 2; - if(NULL == (full_path = (char *)H5MM_malloc(path_len))) + if (NULL == (full_path = (char *)H5MM_malloc(path_len))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrncpy(full_path, cwdpath, cwdlen + 1); - if(!H5_CHECK_DELIMITER(cwdpath[cwdlen - 1])) + if (!H5_CHECK_DELIMITER(cwdpath[cwdlen - 1])) HDstrncat(full_path, H5_DIR_SEPS, HDstrlen(H5_DIR_SEPS)); HDstrncat(full_path, new_name, HDstrlen(new_name)); } /* end if */ - } /* end else */ + } /* end else */ /* strip out the last component (the file name itself) from the path */ - if(full_path) { + if (full_path) { char *ptr = NULL; H5_GET_LAST_DELIMITER(full_path, ptr) HDassert(ptr); - *++ptr = '\0'; + *++ptr = '\0'; *extpath = full_path; } /* end if */ done: /* Release resources */ - if(cwdpath) + if (cwdpath) H5MM_xfree(cwdpath); - if(new_name) + if (new_name) H5MM_xfree(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5_build_extpath() */ - /*-------------------------------------------------------------------------- * Function: H5_combine_path * @@ -1279,35 +1260,35 @@ done: *-------------------------------------------------------------------------- */ herr_t -H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) +H5_combine_path(const char *path1, const char *path2, char **full_name /*out*/) { - size_t path1_len; /* length of path1 */ - size_t path2_len; /* length of path2 */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t path1_len; /* length of path1 */ + size_t path2_len; /* length of path2 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(path2); - if(path1) + if (path1) path1_len = HDstrlen(path1); path2_len = HDstrlen(path2); - if(path1 == NULL || *path1 == '\0' || H5_CHECK_ABSOLUTE(path2)) { + if (path1 == NULL || *path1 == '\0' || H5_CHECK_ABSOLUTE(path2)) { /* If path1 is empty or path2 is absolute, simply use path2 */ - if(NULL == (*full_name = (char *)H5MM_strdup(path2))) + if (NULL == (*full_name = (char *)H5MM_strdup(path2))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ - else if(H5_CHECK_ABS_PATH(path2)) { + else if (H5_CHECK_ABS_PATH(path2)) { /* On windows path2 is a path absolute name */ if (H5_CHECK_ABSOLUTE(path1) || H5_CHECK_ABS_DRIVE(path1)) { /* path1 is absolute or drive absolute and path2 is path absolute. * Use the drive letter of path1 + path2 */ - if(NULL == (*full_name = (char *)H5MM_malloc(path2_len + 3))) + if (NULL == (*full_name = (char *)H5MM_malloc(path2_len + 3))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate path2 buffer") HDsnprintf(*full_name, (path2_len + 3), "%c:%s", path1[0], path2); } /* end if */ @@ -1316,7 +1297,7 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) * path1 does not have a drive letter (i.e. is "a\b" or "\a\b"). * Use path2. */ - if(NULL == (*full_name = (char *)H5MM_strdup(path2))) + if (NULL == (*full_name = (char *)H5MM_strdup(path2))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end else */ @@ -1327,11 +1308,14 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) * Allocate a buffer to hold path1 + path2 + possibly the delimiter * + terminating null byte */ - if(NULL == (*full_name = (char *)H5MM_malloc(path1_len + path2_len + 2 + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ + if (NULL == + (*full_name = (char *)H5MM_malloc(path1_len + path2_len + 2 + + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate filename buffer") /* Compose the full file name */ - HDsnprintf(*full_name, (path1_len + path2_len + 2 + 2), "%s%s%s", path1, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ + HDsnprintf(*full_name, (path1_len + path2_len + 2 + 2), "%s%s%s", + path1, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ (H5_CHECK_DELIMITER(path1[path1_len - 1]) ? "" : H5_DIR_SEPS), path2); } /* end else */ @@ -1339,7 +1323,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5_combine_path() */ - /*-------------------------------------------------------------------------- * Function: H5_nanosleep * @@ -1352,8 +1335,8 @@ void H5_nanosleep(uint64_t nanosec) { #ifndef H5_HAVE_WIN32_API - const uint64_t nanosec_per_sec = 1000 * 1000 * 1000; - struct timespec sleeptime; /* Struct to hold time to sleep */ + const uint64_t nanosec_per_sec = 1000 * 1000 * 1000; + struct timespec sleeptime; /* Struct to hold time to sleep */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1364,7 +1347,7 @@ H5_nanosleep(uint64_t nanosec) * * It's harder to be sure that we don't overflow time_t. */ - sleeptime.tv_sec = (time_t)(nanosec / nanosec_per_sec); + sleeptime.tv_sec = (time_t)(nanosec / nanosec_per_sec); sleeptime.tv_nsec = (long)(nanosec % nanosec_per_sec); /* Sleep for up to `sleeptime` and, in the event of an interruption, @@ -1398,9 +1381,8 @@ H5_nanosleep(uint64_t nanosec) #ifdef H5_HAVE_WIN32_API -#define H5_WIN32_ENV_VAR_BUFFER_SIZE 32767 +#define H5_WIN32_ENV_VAR_BUFFER_SIZE 32767 - /*------------------------------------------------------------------------- * Function: H5_expand_windows_env_vars() * @@ -1414,9 +1396,9 @@ H5_nanosleep(uint64_t nanosec) herr_t H5_expand_windows_env_vars(char **env_var) { - long n_chars = 0; - char *temp_buf = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + long n_chars = 0; + char * temp_buf = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1425,7 +1407,8 @@ H5_expand_windows_env_vars(char **env_var) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for expanded path") /* Expand the environment variable string */ - if ((n_chars = ExpandEnvironmentStringsA(*env_var, temp_buf, H5_WIN32_ENV_VAR_BUFFER_SIZE)) > H5_WIN32_ENV_VAR_BUFFER_SIZE) + if ((n_chars = ExpandEnvironmentStringsA(*env_var, temp_buf, H5_WIN32_ENV_VAR_BUFFER_SIZE)) > + H5_WIN32_ENV_VAR_BUFFER_SIZE) HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "expanded path is too long") if (0 == n_chars) @@ -1442,7 +1425,6 @@ done: } /* end H5_expand_windows_env_vars() */ #endif /* H5_HAVE_WIN32_API */ - /* dirname() and basename() are not easily ported to Windows and basename * behavior varies depending on if you get POSIX vs. GNU. As a more * platform-indpendent work-around, we've implemented H5_ versions of @@ -1472,9 +1454,9 @@ done: */ #ifdef H5_HAVE_WIN32_API -#define H5_FILE_SEPARATOR '\\' +#define H5_FILE_SEPARATOR '\\' #else -#define H5_FILE_SEPARATOR '/' +#define H5_FILE_SEPARATOR '/' #endif static size_t @@ -1499,12 +1481,12 @@ H5__find_last_file_separator(const char *path, size_t len, hbool_t *no_separator herr_t H5_dirname(const char *path, char **dirname) { - size_t path_len; - size_t pos; - size_t out_len; - char *out = NULL; + size_t path_len; + size_t pos; + size_t out_len; + char * out = NULL; hbool_t no_separator = FALSE; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1516,7 +1498,7 @@ H5_dirname(const char *path, char **dirname) path_len = HDstrlen(path); pos = H5__find_last_file_separator(path, path_len, &no_separator); - + /* Special case of no path separator */ if (no_separator) out_len = 2; @@ -1545,12 +1527,12 @@ done: herr_t H5_basename(const char *path, char **basename) { - size_t path_len; - size_t pos; - size_t out_len; - char *out = NULL; + size_t path_len; + size_t pos; + size_t out_len; + char * out = NULL; hbool_t no_separator = FALSE; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1560,7 +1542,7 @@ H5_basename(const char *path, char **basename) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dirname can't be NULL") path_len = HDstrlen(path); - pos = H5__find_last_file_separator(path, path_len, &no_separator); + pos = H5__find_last_file_separator(path, path_len, &no_separator); if (no_separator) out_len = path_len; diff --git a/src/H5timer.c b/src/H5timer.c index cef7bf9..6a2b6df 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -25,12 +25,10 @@ /* Module Setup */ /****************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ - +#include "H5private.h" /* Generic Functions */ /****************/ /* Local Macros */ @@ -47,38 +45,30 @@ #define H5_SEC_PER_HOUR (double)(60.0F * 60.0F) #define H5_SEC_PER_MIN (double)(60.0F) - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5_bandwidth * @@ -105,45 +95,50 @@ *------------------------------------------------------------------------- */ void -H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) +H5_bandwidth(char *buf /*out*/, double nbytes, double nseconds) { - double bw; + double bw; - if(nseconds <= (double)0.0F) + if (nseconds <= (double)0.0F) HDstrcpy(buf, " NaN"); else { bw = nbytes / nseconds; - if(H5_DBL_ABS_EQUAL(bw, (double)0.0F)) + if (H5_DBL_ABS_EQUAL(bw, (double)0.0F)) HDstrcpy(buf, "0.000 B/s"); - else if(bw < (double)1.0F) + else if (bw < (double)1.0F) HDsprintf(buf, "%10.4e", bw); - else if(bw < (double)H5_KB) { + else if (bw < (double)H5_KB) { HDsprintf(buf, "%05.4f", bw); HDstrcpy(buf + 5, " B/s"); - } else if(bw < (double)H5_MB) { + } + else if (bw < (double)H5_MB) { HDsprintf(buf, "%05.4f", bw / (double)H5_KB); HDstrcpy(buf + 5, " kB/s"); - } else if(bw < (double)H5_GB) { + } + else if (bw < (double)H5_GB) { HDsprintf(buf, "%05.4f", bw / (double)H5_MB); HDstrcpy(buf + 5, " MB/s"); - } else if(bw < (double)H5_TB) { + } + else if (bw < (double)H5_TB) { HDsprintf(buf, "%05.4f", bw / (double)H5_GB); HDstrcpy(buf + 5, " GB/s"); - } else if(bw < (double)H5_PB) { + } + else if (bw < (double)H5_PB) { HDsprintf(buf, "%05.4f", bw / (double)H5_TB); HDstrcpy(buf + 5, " TB/s"); - } else if(bw < (double)H5_EB) { + } + else if (bw < (double)H5_EB) { HDsprintf(buf, "%05.4f", bw / (double)H5_PB); HDstrcpy(buf + 5, " PB/s"); - } else { + } + else { HDsprintf(buf, "%10.4e", bw); - if(HDstrlen(buf) > 10) + if (HDstrlen(buf) > 10) HDsprintf(buf, "%10.3e", bw); } /* end else-if */ - } /* end else */ + } /* end else */ } /* end H5_bandwidth() */ - /*------------------------------------------------------------------------- * Function: H5_now * @@ -159,7 +154,7 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) time_t H5_now(void) { - time_t now; /* Current time */ + time_t now; /* Current time */ #ifdef H5_HAVE_GETTIMEOFDAY { @@ -168,14 +163,13 @@ H5_now(void) HDgettimeofday(&now_tv, NULL); now = now_tv.tv_sec; } -#else /* H5_HAVE_GETTIMEOFDAY */ +#else /* H5_HAVE_GETTIMEOFDAY */ now = HDtime(NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ - return(now); + return (now); } /* end H5_now() */ - /*------------------------------------------------------------------------- * Function: H5_now_usec * @@ -191,7 +185,7 @@ H5_now(void) uint64_t H5_now_usec(void) { - uint64_t now; /* Current time, in microseconds */ + uint64_t now; /* Current time, in microseconds */ #if defined(H5_HAVE_CLOCK_GETTIME) { @@ -207,14 +201,13 @@ H5_now_usec(void) HDgettimeofday(&now_tv, NULL); now = (uint64_t)(now_tv.tv_sec * (1000 * 1000)) + (uint64_t)now_tv.tv_usec; } -#else /* H5_HAVE_GETTIMEOFDAY */ - now = (uint64_t)(HDtime(NULL) * (1000 * 1000)); +#else /* H5_HAVE_GETTIMEOFDAY */ + now = (uint64_t)(HDtime(NULL) * (1000 * 1000)); #endif /* H5_HAVE_GETTIMEOFDAY */ - return(now); + return (now); } /* end H5_now_usec() */ - /*-------------------------------------------------------------------------- * Function: H5_get_time * @@ -255,8 +248,6 @@ H5_get_time(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_get_time() */ - - /*------------------------------------------------------------------------- * Function: H5__timer_get_timevals * @@ -279,10 +270,10 @@ H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) /* Windows call handles both system/user and elapsed times */ #ifdef H5_HAVE_WIN32_API - if(H5_get_win32_times(times) < 0) { - times->elapsed = -1.0; - times->system = -1.0; - times->user = -1.0; + if (H5_get_win32_times(times) < 0) { + times->elapsed = -1.0; + times->system = -1.0; + times->user = -1.0; return -1; } /* end if */ @@ -292,14 +283,14 @@ H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) * System and user times * *************************/ #if defined(H5_HAVE_GETRUSAGE) -{ - struct rusage res; + { + struct rusage res; - if(HDgetrusage(RUSAGE_SELF, &res) < 0) - return -1; - times->system = (double)res.ru_stime.tv_sec + ((double)res.ru_stime.tv_usec / (double)1.0E6F); - times->user = (double)res.ru_utime.tv_sec + ((double)res.ru_utime.tv_usec / (double)1.0E6F); -} + if (HDgetrusage(RUSAGE_SELF, &res) < 0) + return -1; + times->system = (double)res.ru_stime.tv_sec + ((double)res.ru_stime.tv_usec / (double)1.0E6F); + times->user = (double)res.ru_utime.tv_sec + ((double)res.ru_utime.tv_usec / (double)1.0E6F); + } #else /* No suitable way to get system/user times */ /* This is not an error condition, they just won't be available */ @@ -318,7 +309,6 @@ H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) return 0; } /* end H5__timer_get_timevals() */ - /*------------------------------------------------------------------------- * Function: H5_timer_init * @@ -384,7 +374,6 @@ H5_timer_init(H5_timer_t *timer /*in,out*/) return 0; } /* end H5_timer_init() */ - /*------------------------------------------------------------------------- * Function: H5_timer_start * @@ -407,7 +396,7 @@ H5_timer_start(H5_timer_t *timer /*in,out*/) /* Start the timer * This sets the "initial" times to the system-defined start times. */ - if(H5__timer_get_timevals(&(timer->initial)) < 0) + if (H5__timer_get_timevals(&(timer->initial)) < 0) return -1; timer->is_running = TRUE; @@ -415,7 +404,6 @@ H5_timer_start(H5_timer_t *timer /*in,out*/) return 0; } /* end H5_timer_start() */ - /*------------------------------------------------------------------------- * Function: H5_timer_stop * @@ -436,27 +424,26 @@ H5_timer_stop(H5_timer_t *timer /*in,out*/) HDassert(timer); /* Stop the timer */ - if(H5__timer_get_timevals(&(timer->final_interval)) < 0) + if (H5__timer_get_timevals(&(timer->final_interval)) < 0) return -1; /* The "final" times are stored as intervals (final - initial) * for more useful reporting to the user. */ timer->final_interval.elapsed = timer->final_interval.elapsed - timer->initial.elapsed; - timer->final_interval.system = timer->final_interval.system - timer->initial.system; - timer->final_interval.user = timer->final_interval.user - timer->initial.user; + timer->final_interval.system = timer->final_interval.system - timer->initial.system; + timer->final_interval.user = timer->final_interval.user - timer->initial.user; /* Add the intervals to the elapsed time */ timer->total.elapsed += timer->final_interval.elapsed; - timer->total.system += timer->final_interval.system; - timer->total.user += timer->final_interval.user; + timer->total.system += timer->final_interval.system; + timer->total.user += timer->final_interval.user; timer->is_running = FALSE; return 0; } /* end H5_timer_stop() */ - /*------------------------------------------------------------------------- * Function: H5_timer_get_times * @@ -487,18 +474,18 @@ H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) /* Sanity check */ HDassert(times); - if(timer.is_running) { - H5_timevals_t now; + if (timer.is_running) { + H5_timevals_t now; /* Get the current times and report the current intervals without * stopping the timer. */ - if(H5__timer_get_timevals(&now) < 0) + if (H5__timer_get_timevals(&now) < 0) return -1; times->elapsed = now.elapsed - timer.initial.elapsed; - times->system = now.system - timer.initial.system; - times->user = now.user - timer.initial.user; + times->system = now.system - timer.initial.system; + times->user = now.user - timer.initial.user; } /* end if */ else { times->elapsed = timer.final_interval.elapsed; @@ -509,7 +496,6 @@ H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) return 0; } /* end H5_timer_get_times() */ - /*------------------------------------------------------------------------- * Function: H5_timer_get_total_times * @@ -543,18 +529,18 @@ H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) /* Sanity check */ HDassert(times); - if(timer.is_running) { - H5_timevals_t now; + if (timer.is_running) { + H5_timevals_t now; /* Get the current times and report the current totals without * stopping the timer. */ - if(H5__timer_get_timevals(&now) < 0) + if (H5__timer_get_timevals(&now) < 0) return -1; times->elapsed = timer.total.elapsed + (now.elapsed - timer.initial.elapsed); - times->system = timer.total.system + (now.system - timer.initial.system); - times->user = timer.total.user + (now.user - timer.initial.user); + times->system = timer.total.system + (now.system - timer.initial.system); + times->user = timer.total.user + (now.user - timer.initial.user); } /* end if */ else { times->elapsed = timer.total.elapsed; @@ -565,7 +551,6 @@ H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) return 0; } /* end H5_timer_get_total_times() */ - /*------------------------------------------------------------------------- * Function: H5_timer_get_time_string * @@ -594,7 +579,7 @@ H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) char * H5_timer_get_time_string(double seconds) { - char *s; /* output string */ + char *s; /* output string */ /* Used when the time is greater than 59 seconds */ double days; @@ -603,7 +588,7 @@ H5_timer_get_time_string(double seconds) double remainder_sec; /* Extract larger time units from count of seconds */ - if(seconds > (double)60.0F) { + if (seconds > (double)60.0F) { /* Set initial # of seconds */ remainder_sec = seconds; @@ -623,7 +608,7 @@ H5_timer_get_time_string(double seconds) } /* end if */ /* Allocate */ - if(NULL == (s = (char *)HDcalloc(H5TIMER_TIME_STRING_LEN, sizeof(char)))) + if (NULL == (s = (char *)HDcalloc(H5TIMER_TIME_STRING_LEN, sizeof(char)))) return NULL; /* Do we need a format string? Some people might like a certain @@ -631,26 +616,26 @@ H5_timer_get_time_string(double seconds) * time unit. Perhaps this could be passed as an integer. * (name? round_up_size? ?) */ - if(seconds < (double)0.0F) + if (seconds < (double)0.0F) HDsprintf(s, "N/A"); - else if(H5_DBL_ABS_EQUAL((double)0.0F, seconds)) + else if (H5_DBL_ABS_EQUAL((double)0.0F, seconds)) HDsprintf(s, "0.0 s"); - else if(seconds < (double)1.0E-6F) + else if (seconds < (double)1.0E-6F) /* t < 1 us, Print time in ns */ HDsprintf(s, "%.f ns", seconds * (double)1.0E9F); - else if(seconds < (double)1.0E-3F) + else if (seconds < (double)1.0E-3F) /* t < 1 ms, Print time in us */ HDsprintf(s, "%.1f us", seconds * (double)1.0E6F); - else if(seconds < (double)1.0F) + else if (seconds < (double)1.0F) /* t < 1 s, Print time in ms */ HDsprintf(s, "%.1f ms", seconds * (double)1.0E3F); - else if(seconds < H5_SEC_PER_MIN) + else if (seconds < H5_SEC_PER_MIN) /* t < 1 m, Print time in s */ HDsprintf(s, "%.2f s", seconds); - else if(seconds < H5_SEC_PER_HOUR) + else if (seconds < H5_SEC_PER_HOUR) /* t < 1 h, Print time in m and s */ HDsprintf(s, "%.f m %.f s", minutes, remainder_sec); - else if(seconds < H5_SEC_PER_DAY) + else if (seconds < H5_SEC_PER_DAY) /* t < 1 d, Print time in h, m and s */ HDsprintf(s, "%.f h %.f m %.f s", hours, minutes, remainder_sec); else @@ -659,4 +644,3 @@ H5_timer_get_time_string(double seconds) return s; } /* end H5_timer_get_time_string() */ - diff --git a/src/H5trace.c b/src/H5trace.c index db33673..d3bda4a 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -25,62 +25,53 @@ /****************/ /* Module Setup */ /****************/ -#define H5I_FRIEND /*suppress error about including H5Ipkg */ +#define H5I_FRIEND /*suppress error about including H5Ipkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Rprivate.h" /* References */ -#include "H5Ipkg.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Rprivate.h" /* References */ +#include "H5Ipkg.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #ifdef H5_HAVE_PARALLEL /* datatypes of predefined drivers needed by H5_trace() */ #include "H5FDmpio.h" #endif /* H5_HAVE_PARALLEL */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5_trace * @@ -119,52 +110,52 @@ double H5_trace(const double *returning, const char *func, const char *type, ...) { - va_list ap; - char buf[64], *rest; - const char *argname; - int argno = 0, ptr, asize_idx; - hssize_t asize[16]; - hssize_t i; - void *vp = NULL; - FILE *out = H5_debug_g.trace; - static hbool_t is_first_invocation = TRUE; - H5_timer_t function_timer; - H5_timevals_t function_times; - static H5_timer_t running_timer; - H5_timevals_t running_times; - static int current_depth = 0; - static int last_call_depth = 0; + va_list ap; + char buf[64], *rest; + const char * argname; + int argno = 0, ptr, asize_idx; + hssize_t asize[16]; + hssize_t i; + void * vp = NULL; + FILE * out = H5_debug_g.trace; + static hbool_t is_first_invocation = TRUE; + H5_timer_t function_timer; + H5_timevals_t function_times; + static H5_timer_t running_timer; + H5_timevals_t running_times; + static int current_depth = 0; + static int last_call_depth = 0; /* FUNC_ENTER() should not be called */ - if(!out) - return 0.0F; /*tracing is off*/ + if (!out) + return 0.0F; /*tracing is off*/ HDva_start(ap, type); - if(H5_debug_g.ttop) { - if(returning) { - if(current_depth > 1) { + if (H5_debug_g.ttop) { + if (returning) { + if (current_depth > 1) { --current_depth; return 0.0F; } /* end if */ - } /* end if */ + } /* end if */ else { - if(current_depth > 0) { + if (current_depth > 0) { /*do not update last_call_depth*/ current_depth++; return 0.0F; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Get time for event if the trace times flag is set */ - if(is_first_invocation && H5_debug_g.ttimes) { + if (is_first_invocation && H5_debug_g.ttimes) { /* start the library-wide timer */ is_first_invocation = FALSE; H5_timer_init(&running_timer); H5_timer_start(&running_timer); } /* end if */ - if(H5_debug_g.ttimes) { + if (H5_debug_g.ttimes) { /* start the timer for this function */ H5_timer_init(&function_timer); H5_timer_start(&function_timer); @@ -176,12 +167,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) * function return and no other calls have been made to H5_trace() * since the one for the function call, then we're continuing * the same line. */ - if(returning) { + if (returning) { HDassert(current_depth > 0); --current_depth; - if(current_depth < last_call_depth) { + if (current_depth < last_call_depth) { /* We are at the beginning of a line */ - if(H5_debug_g.ttimes) { + if (H5_debug_g.ttimes) { char tmp[320]; H5_timer_get_times(function_timer, &function_times); @@ -189,47 +180,48 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDsprintf(tmp, "%.6f", (function_times.elapsed - running_times.elapsed)); HDfprintf(out, " %*s ", (int)HDstrlen(tmp), ""); } /* end if */ - for(i = 0; i < current_depth; i++) + for (i = 0; i < current_depth; i++) HDfputc('+', out); - HDfprintf(out, "%*s%s = ", 2*current_depth, "", func); + HDfprintf(out, "%*s%s = ", 2 * current_depth, "", func); } /* end if */ else { /* Continue current line with return value */ HDfprintf(out, " = "); } /* end else */ - } /* end if */ + } /* end if */ else { - if(current_depth>last_call_depth) + if (current_depth > last_call_depth) HDfputs(" = \n", out); - if(H5_debug_g.ttimes) { + if (H5_debug_g.ttimes) { H5_timer_get_times(function_timer, &function_times); H5_timer_get_times(running_timer, &running_times); HDfprintf(out, "@%.6f ", (function_times.elapsed - running_times.elapsed)); } /* end if */ - for(i = 0; i < current_depth; i++) + for (i = 0; i < current_depth; i++) HDfputc('+', out); - HDfprintf(out, "%*s%s(", 2*current_depth, "", func); + HDfprintf(out, "%*s%s(", 2 * current_depth, "", func); } /* end else */ /* Clear array sizes */ - for(i = 0; i < (hssize_t)NELMTS(asize); i++) + for (i = 0; i < (hssize_t)NELMTS(asize); i++) asize[i] = -1; /* Parse the argument types */ - for(argno = 0; *type; argno++, type += (HDisupper(*type) ? 2 : 1)) { + for (argno = 0; *type; argno++, type += (HDisupper(*type) ? 2 : 1)) { /* Count levels of indirection */ - for(ptr = 0; '*' == *type; type++) + for (ptr = 0; '*' == *type; type++) ptr++; - if('[' == *type) { - if('a' == type[1]) { + if ('[' == *type) { + if ('a' == type[1]) { asize_idx = (int)HDstrtol(type + 2, &rest, 10); - HDassert(0 <= asize_idx && asize_idx < (int) NELMTS(asize)); - HDassert(']'==*rest); + HDassert(0 <= asize_idx && asize_idx < (int)NELMTS(asize)); + HDassert(']' == *rest); type = rest + 1; - } else { + } + else { rest = (char *)HDstrchr(type, ']'); HDassert(rest); - type = rest + 1; + type = rest + 1; asize_idx = -1; } } /* end if */ @@ -242,26 +234,26 @@ H5_trace(const double *returning, const char *func, const char *type, ...) * following `='. This is used for return values. */ argname = HDva_arg(ap, char *); - if(argname) { - unsigned n = (unsigned)MAX (0, (int)HDstrlen(argname) - 3); + if (argname) { + unsigned n = (unsigned)MAX(0, (int)HDstrlen(argname) - 3); - if(!HDstrcmp(argname + n, "_id")) { + if (!HDstrcmp(argname + n, "_id")) { HDstrncpy(buf, argname, (size_t)MIN((int)sizeof(buf) - 1, n)); buf[MIN((int)sizeof(buf) - 1, n)] = '\0'; - argname = buf; + argname = buf; } /* end if */ - HDfprintf(out, "%s%s=", argno?", ":"", argname); + HDfprintf(out, "%s%s=", argno ? ", " : "", argname); } /* end if */ else argname = ""; /* The value */ - if(ptr) + if (ptr) vp = HDva_arg(ap, void *); - switch(type[0]) { + switch (type[0]) { case 'a': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -274,18 +266,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'b': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); - } /* end if */ + } /* end if */ else { /* Can't pass hbool_t to HDva_arg() */ hbool_t bool_var = (hbool_t)HDva_arg(ap, int); - if(TRUE == bool_var) + if (TRUE == bool_var) HDfprintf(out, "TRUE"); - else if(!bool_var) + else if (!bool_var) HDfprintf(out, "FALSE"); else HDfprintf(out, "TRUE(%u)", (unsigned)bool_var); @@ -293,8 +285,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'd': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -307,10 +299,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'D': - switch(type[1]) { + switch (type[1]) { case 'a': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -318,7 +310,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5D_alloc_time_t alloc_time = (H5D_alloc_time_t)HDva_arg(ap, int); - switch(alloc_time) { + switch (alloc_time) { case H5D_ALLOC_TIME_ERROR: HDfprintf(out, "H5D_ALLOC_TIME_ERROR"); break; @@ -343,494 +335,503 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)alloc_time); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_collective_opt_t opt = (H5FD_mpio_collective_opt_t)HDva_arg(ap, int); - switch(opt) { + switch (opt) { case H5FD_MPIO_COLLECTIVE_IO: - HDfprintf(out, "H5FD_MPIO_COLLECTIVE_IO"); + HDfprintf(out, "H5FD_MPIO_COLLECTIVE_IO"); break; case H5FD_MPIO_INDIVIDUAL_IO: - HDfprintf(out, "H5FD_MPIO_INDIVIDUAL_IO"); + HDfprintf(out, "H5FD_MPIO_INDIVIDUAL_IO"); break; default: - HDfprintf(out, "%ld", (long)opt); + HDfprintf(out, "%ld", (long)opt); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'f': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_fill_time_t fill_time = (H5D_fill_time_t)HDva_arg(ap, int); - switch(fill_time) { + switch (fill_time) { case H5D_FILL_TIME_ERROR: - HDfprintf(out, "H5D_FILL_TIME_ERROR"); + HDfprintf(out, "H5D_FILL_TIME_ERROR"); break; case H5D_FILL_TIME_ALLOC: - HDfprintf(out, "H5D_FILL_TIME_ALLOC"); + HDfprintf(out, "H5D_FILL_TIME_ALLOC"); break; case H5D_FILL_TIME_NEVER: - HDfprintf(out, "H5D_FILL_TIME_NEVER"); + HDfprintf(out, "H5D_FILL_TIME_NEVER"); break; case H5D_FILL_TIME_IFSET: - HDfprintf(out, "H5D_FILL_TIME_IFSET"); + HDfprintf(out, "H5D_FILL_TIME_IFSET"); break; default: - HDfprintf(out, "%ld", (long)fill_time); + HDfprintf(out, "%ld", (long)fill_time); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'F': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_fill_value_t fill_value = (H5D_fill_value_t)HDva_arg(ap, int); - switch(fill_value) { + switch (fill_value) { case H5D_FILL_VALUE_ERROR: - HDfprintf(out, "H5D_FILL_VALUE_ERROR"); + HDfprintf(out, "H5D_FILL_VALUE_ERROR"); break; case H5D_FILL_VALUE_UNDEFINED: - HDfprintf(out, "H5D_FILL_VALUE_UNDEFINED"); + HDfprintf(out, "H5D_FILL_VALUE_UNDEFINED"); break; case H5D_FILL_VALUE_DEFAULT: - HDfprintf(out, "H5D_FILL_VALUE_DEFAULT"); + HDfprintf(out, "H5D_FILL_VALUE_DEFAULT"); break; case H5D_FILL_VALUE_USER_DEFINED: - HDfprintf(out, "H5D_FILL_VALUE_USER_DEFINED"); + HDfprintf(out, "H5D_FILL_VALUE_USER_DEFINED"); break; default: - HDfprintf(out, "%ld", (long)fill_value); + HDfprintf(out, "%ld", (long)fill_value); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'h': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_chunk_opt_t opt = (H5FD_mpio_chunk_opt_t)HDva_arg(ap, int); - switch(opt) { + switch (opt) { case H5FD_MPIO_CHUNK_DEFAULT: - HDfprintf(out, "H5FD_MPIO_CHUNK_DEFAULT"); + HDfprintf(out, "H5FD_MPIO_CHUNK_DEFAULT"); break; case H5FD_MPIO_CHUNK_ONE_IO: - HDfprintf(out, "H5FD_MPIO_CHUNK_ONE_IO"); + HDfprintf(out, "H5FD_MPIO_CHUNK_ONE_IO"); break; case H5FD_MPIO_CHUNK_MULTI_IO: - HDfprintf(out, "H5FD_MPIO_CHUNK_MULTI_IO"); + HDfprintf(out, "H5FD_MPIO_CHUNK_MULTI_IO"); break; default: - HDfprintf(out, "%ld", (long)opt); + HDfprintf(out, "%ld", (long)opt); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'i': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_actual_io_mode_t actual_io_mode = (H5D_mpio_actual_io_mode_t)HDva_arg(ap, int); + H5D_mpio_actual_io_mode_t actual_io_mode = + (H5D_mpio_actual_io_mode_t)HDva_arg(ap, int); - switch(actual_io_mode) { + switch (actual_io_mode) { case H5D_MPIO_NO_COLLECTIVE: - HDfprintf(out, "H5D_MPIO_NO_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_NO_COLLECTIVE"); break; case H5D_MPIO_CHUNK_INDEPENDENT: - HDfprintf(out, "H5D_MPIO_CHUNK_INDEPENDENT"); + HDfprintf(out, "H5D_MPIO_CHUNK_INDEPENDENT"); break; case H5D_MPIO_CHUNK_COLLECTIVE: - HDfprintf(out, "H5D_MPIO_CHUNK_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_CHUNK_COLLECTIVE"); break; case H5D_MPIO_CHUNK_MIXED: - HDfprintf(out, "H5D_MPIO_CHUNK_MIXED"); + HDfprintf(out, "H5D_MPIO_CHUNK_MIXED"); break; case H5D_MPIO_CONTIGUOUS_COLLECTIVE: - HDfprintf(out, "H5D_MPIO_CONTIGUOUS_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_CONTIGUOUS_COLLECTIVE"); break; default: - HDfprintf(out, "%ld", (long)actual_io_mode); + HDfprintf(out, "%ld", (long)actual_io_mode); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'k': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_chunk_index_t idx = (H5D_chunk_index_t)HDva_arg(ap, int); - switch(idx) { + switch (idx) { case H5D_CHUNK_IDX_BTREE: - HDfprintf(out, "H5D_CHUNK_IDX_BTREE"); + HDfprintf(out, "H5D_CHUNK_IDX_BTREE"); break; case H5D_CHUNK_IDX_NONE: - HDfprintf(out, "H5D_CHUNK_IDX_NONE"); + HDfprintf(out, "H5D_CHUNK_IDX_NONE"); break; case H5D_CHUNK_IDX_FARRAY: - HDfprintf(out, "H5D_CHUNK_IDX_FARRAY"); + HDfprintf(out, "H5D_CHUNK_IDX_FARRAY"); break; case H5D_CHUNK_IDX_EARRAY: - HDfprintf(out, "H5D_CHUNK_IDX_EARRAY"); + HDfprintf(out, "H5D_CHUNK_IDX_EARRAY"); break; case H5D_CHUNK_IDX_BT2: - HDfprintf(out, "H5D_CHUNK_IDX_BT2"); + HDfprintf(out, "H5D_CHUNK_IDX_BT2"); break; case H5D_CHUNK_IDX_SINGLE: - HDfprintf(out, "H5D_CHUNK_IDX_SINGLE"); + HDfprintf(out, "H5D_CHUNK_IDX_SINGLE"); break; case H5D_CHUNK_IDX_NTYPES: - HDfprintf(out, "ERROR: H5D_CHUNK_IDX_NTYPES (invalid value)"); + HDfprintf(out, "ERROR: H5D_CHUNK_IDX_NTYPES (invalid value)"); break; default: - HDfprintf(out, "UNKNOWN VALUE: %ld", (long)idx); + HDfprintf(out, "UNKNOWN VALUE: %ld", (long)idx); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'l': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_layout_t layout = (H5D_layout_t)HDva_arg(ap, int); - switch(layout) { + switch (layout) { case H5D_LAYOUT_ERROR: - HDfprintf(out, "H5D_LAYOUT_ERROR"); + HDfprintf(out, "H5D_LAYOUT_ERROR"); break; case H5D_COMPACT: - HDfprintf(out, "H5D_COMPACT"); + HDfprintf(out, "H5D_COMPACT"); break; case H5D_CONTIGUOUS: - HDfprintf(out, "H5D_CONTIGUOUS"); + HDfprintf(out, "H5D_CONTIGUOUS"); break; case H5D_CHUNKED: - HDfprintf(out, "H5D_CHUNKED"); + HDfprintf(out, "H5D_CHUNKED"); break; case H5D_VIRTUAL: - HDfprintf(out, "H5D_VIRTUAL"); + HDfprintf(out, "H5D_VIRTUAL"); break; case H5D_NLAYOUTS: - HDfprintf(out, "H5D_NLAYOUTS"); + HDfprintf(out, "H5D_NLAYOUTS"); break; default: - HDfprintf(out, "%ld", (long)layout); + HDfprintf(out, "%ld", (long)layout); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'n': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_no_collective_cause_t nocol_cause_mode = (H5D_mpio_no_collective_cause_t)HDva_arg(ap, int); + H5D_mpio_no_collective_cause_t nocol_cause_mode = + (H5D_mpio_no_collective_cause_t)HDva_arg(ap, int); hbool_t flag_already_displayed = FALSE; /* Check for all bit-flags which might be set */ - if(nocol_cause_mode & H5D_MPIO_COLLECTIVE) { - HDfprintf(out, "H5D_MPIO_COLLECTIVE"); + if (nocol_cause_mode & H5D_MPIO_COLLECTIVE) { + HDfprintf(out, "H5D_MPIO_COLLECTIVE"); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_SET_INDEPENDENT) { - HDfprintf(out, "%sH5D_MPIO_SET_INDEPENDENT", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_SET_INDEPENDENT) { + HDfprintf(out, "%sH5D_MPIO_SET_INDEPENDENT", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_DATATYPE_CONVERSION) { - HDfprintf(out, "%sH5D_MPIO_DATATYPE_CONVERSION", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_DATATYPE_CONVERSION) { + HDfprintf(out, "%sH5D_MPIO_DATATYPE_CONVERSION", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_DATA_TRANSFORMS) { - HDfprintf(out, "%sH5D_MPIO_DATA_TRANSFORMS", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_DATA_TRANSFORMS) { + HDfprintf(out, "%sH5D_MPIO_DATA_TRANSFORMS", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED) { - HDfprintf(out, "%sH5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED) { + HDfprintf(out, "%sH5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES) { - HDfprintf(out, "%sH5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES) { + HDfprintf(out, "%sH5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET) { - HDfprintf(out, "%sH5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET) { + HDfprintf(out, "%sH5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ /* Display '' if there's no flags set */ - if(!flag_already_displayed) - HDfprintf(out, ""); + if (!flag_already_displayed) + HDfprintf(out, ""); } /* end else */ break; case 'o': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = (H5D_mpio_actual_chunk_opt_mode_t)HDva_arg(ap, int); + H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = + (H5D_mpio_actual_chunk_opt_mode_t)HDva_arg(ap, int); - switch(chunk_opt_mode) { + switch (chunk_opt_mode) { case H5D_MPIO_NO_CHUNK_OPTIMIZATION: - HDfprintf(out, "H5D_MPIO_NO_CHUNK_OPTIMIZATION"); + HDfprintf(out, "H5D_MPIO_NO_CHUNK_OPTIMIZATION"); break; case H5D_MPIO_LINK_CHUNK: - HDfprintf(out, "H5D_MPIO_LINK_CHUNK"); + HDfprintf(out, "H5D_MPIO_LINK_CHUNK"); break; case H5D_MPIO_MULTI_CHUNK: - HDfprintf(out, "H5D_MPIO_MULTI_CHUNK"); + HDfprintf(out, "H5D_MPIO_MULTI_CHUNK"); break; default: - HDfprintf(out, "%ld", (long)chunk_opt_mode); + HDfprintf(out, "%ld", (long)chunk_opt_mode); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_space_status_t space_status = (H5D_space_status_t)HDva_arg(ap, int); - switch(space_status) { + switch (space_status) { case H5D_SPACE_STATUS_NOT_ALLOCATED: - HDfprintf(out, "H5D_SPACE_STATUS_NOT_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_NOT_ALLOCATED"); break; case H5D_SPACE_STATUS_PART_ALLOCATED: - HDfprintf(out, "H5D_SPACE_STATUS_PART_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_PART_ALLOCATED"); break; case H5D_SPACE_STATUS_ALLOCATED: - HDfprintf(out, "H5D_SPACE_STATUS_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_ALLOCATED"); break; case H5D_SPACE_STATUS_ERROR: - HDfprintf(out, "H5D_SPACE_STATUS_ERROR"); + HDfprintf(out, "H5D_SPACE_STATUS_ERROR"); break; default: - HDfprintf(out, "%ld", (long)space_status); + HDfprintf(out, "%ld", (long)space_status); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_xfer_t transfer = (H5FD_mpio_xfer_t)HDva_arg(ap, int); - switch(transfer) { + switch (transfer) { case H5FD_MPIO_INDEPENDENT: - HDfprintf(out, "H5FD_MPIO_INDEPENDENT"); + HDfprintf(out, "H5FD_MPIO_INDEPENDENT"); break; case H5FD_MPIO_COLLECTIVE: - HDfprintf(out, "H5FD_MPIO_COLLECTIVE"); + HDfprintf(out, "H5FD_MPIO_COLLECTIVE"); break; default: - HDfprintf(out, "%ld", (long)transfer); + HDfprintf(out, "%ld", (long)transfer); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'v': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_vds_view_t view = (H5D_vds_view_t)HDva_arg(ap, int); - switch(view) { + switch (view) { case H5D_VDS_ERROR: - HDfprintf(out, "H5D_VDS_ERROR"); + HDfprintf(out, "H5D_VDS_ERROR"); break; case H5D_VDS_FIRST_MISSING: - HDfprintf(out, "H5D_VDS_FIRST_MISSING"); + HDfprintf(out, "H5D_VDS_FIRST_MISSING"); break; case H5D_VDS_LAST_AVAILABLE: - HDfprintf(out, "H5D_VDS_LAST_AVAILABLE"); + HDfprintf(out, "H5D_VDS_LAST_AVAILABLE"); break; default: - HDfprintf(out, "%ld", (long)view); + HDfprintf(out, "%ld", (long)view); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: - HDfprintf(out, "BADTYPE(D%c)", type[1]); + HDfprintf(out, "BADTYPE(D%c)", type[1]); goto error; } /* end switch */ break; case 'e': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { herr_t status = HDva_arg(ap, herr_t); - if(status >= 0) - HDfprintf(out, "SUCCEED"); + if (status >= 0) + HDfprintf(out, "SUCCEED"); else - HDfprintf(out, "FAIL"); + HDfprintf(out, "FAIL"); } /* end else */ break; case 'E': - switch(type[1]) { + switch (type[1]) { case 'd': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_direction_t direction = (H5E_direction_t)HDva_arg(ap, int); - switch(direction) { + switch (direction) { case H5E_WALK_UPWARD: - HDfprintf(out, "H5E_WALK_UPWARD"); + HDfprintf(out, "H5E_WALK_UPWARD"); break; case H5E_WALK_DOWNWARD: - HDfprintf(out, "H5E_WALK_DOWNWARD"); + HDfprintf(out, "H5E_WALK_DOWNWARD"); break; default: - HDfprintf(out, "%ld", (long)direction); + HDfprintf(out, "%ld", (long)direction); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'e': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_error2_t *error = HDva_arg(ap, H5E_error2_t *); - HDfprintf(out, "0x%p", error); + HDfprintf(out, "0x%p", error); } /* end else */ break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -838,7 +839,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5ES_status_t status = (H5ES_status_t)HDva_arg(ap, int); - switch(status) { + switch (status) { case H5ES_STATUS_IN_PROGRESS: HDfprintf(out, "H5ES_STATUS_IN_PROGRESS"); break; @@ -856,209 +857,209 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)status); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_type_t etype = (H5E_type_t)HDva_arg(ap, int); - switch(etype) { + switch (etype) { case H5E_MAJOR: - HDfprintf(out, "H5E_MAJOR"); + HDfprintf(out, "H5E_MAJOR"); break; case H5E_MINOR: - HDfprintf(out, "H5E_MINOR"); + HDfprintf(out, "H5E_MINOR"); break; default: - HDfprintf(out, "%ld", (long)etype); + HDfprintf(out, "%ld", (long)etype); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: - HDfprintf(out, "BADTYPE(E%c)", type[1]); + HDfprintf(out, "BADTYPE(E%c)", type[1]); goto error; } /* end switch */ break; case 'F': - switch(type[1]) { + switch (type[1]) { case 'd': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_close_degree_t degree = (H5F_close_degree_t)HDva_arg(ap, int); - switch(degree) { + switch (degree) { case H5F_CLOSE_DEFAULT: - HDfprintf(out, "H5F_CLOSE_DEFAULT"); + HDfprintf(out, "H5F_CLOSE_DEFAULT"); break; case H5F_CLOSE_WEAK: - HDfprintf(out, "H5F_CLOSE_WEAK"); + HDfprintf(out, "H5F_CLOSE_WEAK"); break; case H5F_CLOSE_SEMI: - HDfprintf(out, "H5F_CLOSE_SEMI"); + HDfprintf(out, "H5F_CLOSE_SEMI"); break; case H5F_CLOSE_STRONG: - HDfprintf(out, "H5F_CLOSE_STRONG"); + HDfprintf(out, "H5F_CLOSE_STRONG"); break; default: - HDfprintf(out, "%ld", (long)degree); + HDfprintf(out, "%ld", (long)degree); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'f': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_fspace_strategy_t fs_strategy = (H5F_fspace_strategy_t)HDva_arg(ap, int); - switch(fs_strategy) { + switch (fs_strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: - HDfprintf(out, "H5F_FSPACE_STRATEGY_FSM_AGGR"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_FSM_AGGR"); break; case H5F_FSPACE_STRATEGY_PAGE: - HDfprintf(out, "H5F_FSPACE_STRATEGY_PAGE"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_PAGE"); break; case H5F_FSPACE_STRATEGY_AGGR: - HDfprintf(out, "H5F_FSPACE_STRATEGY_AGGR"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_AGGR"); break; case H5F_FSPACE_STRATEGY_NONE: - HDfprintf(out, "H5F_FSPACE_STRATEGY_NONE"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_NONE"); break; case H5F_FSPACE_STRATEGY_NTYPES: default: - HDfprintf(out, "%ld", (long)fs_strategy); + HDfprintf(out, "%ld", (long)fs_strategy); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'm': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_mem_t mem_type = (H5F_mem_t)HDva_arg(ap, int); - switch(mem_type) { + switch (mem_type) { case H5FD_MEM_NOLIST: - HDfprintf(out, "H5FD_MEM_NOLIST"); + HDfprintf(out, "H5FD_MEM_NOLIST"); break; case H5FD_MEM_DEFAULT: - HDfprintf(out, "H5FD_MEM_DEFAULT"); + HDfprintf(out, "H5FD_MEM_DEFAULT"); break; case H5FD_MEM_SUPER: - HDfprintf(out, "H5FD_MEM_SUPER"); + HDfprintf(out, "H5FD_MEM_SUPER"); break; case H5FD_MEM_BTREE: - HDfprintf(out, "H5FD_MEM_BTREE"); + HDfprintf(out, "H5FD_MEM_BTREE"); break; case H5FD_MEM_DRAW: - HDfprintf(out, "H5FD_MEM_DRAW"); + HDfprintf(out, "H5FD_MEM_DRAW"); break; case H5FD_MEM_GHEAP: - HDfprintf(out, "H5FD_MEM_GHEAP"); + HDfprintf(out, "H5FD_MEM_GHEAP"); break; case H5FD_MEM_LHEAP: - HDfprintf(out, "H5FD_MEM_LHEAP"); + HDfprintf(out, "H5FD_MEM_LHEAP"); break; case H5FD_MEM_OHDR: - HDfprintf(out, "H5FD_MEM_OHDR"); + HDfprintf(out, "H5FD_MEM_OHDR"); break; case H5FD_MEM_NTYPES: default: - HDfprintf(out, "%ld", (long)mem_type); + HDfprintf(out, "%ld", (long)mem_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_scope_t scope = (H5F_scope_t)HDva_arg(ap, int); - switch(scope) { + switch (scope) { case H5F_SCOPE_LOCAL: - HDfprintf(out, "H5F_SCOPE_LOCAL"); + HDfprintf(out, "H5F_SCOPE_LOCAL"); break; case H5F_SCOPE_GLOBAL: - HDfprintf(out, "H5F_SCOPE_GLOBAL"); + HDfprintf(out, "H5F_SCOPE_GLOBAL"); break; default: - HDfprintf(out, "%ld", (long)scope); + HDfprintf(out, "%ld", (long)scope); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ break; case 'v': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_libver_t libver_vers = (H5F_libver_t)HDva_arg(ap, int); - switch(libver_vers) { + switch (libver_vers) { case H5F_LIBVER_EARLIEST: HDfprintf(out, "H5F_LIBVER_EARLIEST"); break; @@ -1086,7 +1087,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)libver_vers); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1096,11 +1097,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'G': - switch(type[1]) { + switch (type[1]) { #ifndef H5_NO_DEPRECATED_SYMBOLS case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1108,7 +1109,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5G_obj_t obj_type = (H5G_obj_t)HDva_arg(ap, int); - switch(obj_type) { + switch (obj_type) { case H5G_UNKNOWN: HDfprintf(out, "H5G_UNKNOWN"); break; @@ -1143,18 +1144,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)obj_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t*); + H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t *); HDfprintf(out, "0x%p", statbuf); } @@ -1168,52 +1169,52 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'h': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { hsize_t *p = (hsize_t *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) { - if(H5S_UNLIMITED == p[i]) + for (i = 0; i < asize[asize_idx]; i++) { + if (H5S_UNLIMITED == p[i]) HDfprintf(out, "%sH5S_UNLIMITED", (i ? ", " : "")); else HDfprintf(out, "%s%Hu", (i ? ", " : ""), p[i]); } /* end for */ HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ else { hsize_t hsize = HDva_arg(ap, hsize_t); - if(H5S_UNLIMITED == hsize) + if (H5S_UNLIMITED == hsize) HDfprintf(out, "H5S_UNLIMITED"); else { HDfprintf(out, "%Hu", hsize); asize[argno] = (hssize_t)hsize; } /* end else */ - } /* end else */ + } /* end else */ break; case 'H': - switch(type[1]) { + switch (type[1]) { case 's': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { hssize_t *p = (hssize_t *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) + for (i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%Hd", (i ? ", " : ""), p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -1232,8 +1233,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'i': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1241,12 +1242,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { hid_t obj = HDva_arg(ap, hid_t); - if(H5P_DEFAULT == obj) + if (H5P_DEFAULT == obj) HDfprintf(out, "H5P_DEFAULT"); - else if(obj < 0) + else if (obj < 0) HDfprintf(out, "FAIL"); else { - switch(H5I_TYPE(obj)) { /* Use internal H5I macro instead of function call */ + switch (H5I_TYPE(obj)) { /* Use internal H5I macro instead of function call */ case H5I_UNINIT: HDfprintf(out, "%ld (uninit - error)", (long)obj); break; @@ -1264,93 +1265,93 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case H5I_DATATYPE: - if(obj == H5T_NATIVE_SCHAR_g) + if (obj == H5T_NATIVE_SCHAR_g) HDfprintf(out, "H5T_NATIVE_SCHAR"); - else if(obj == H5T_NATIVE_UCHAR_g) + else if (obj == H5T_NATIVE_UCHAR_g) HDfprintf(out, "H5T_NATIVE_UCHAR"); - else if(obj == H5T_NATIVE_SHORT_g) + else if (obj == H5T_NATIVE_SHORT_g) HDfprintf(out, "H5T_NATIVE_SHORT"); - else if(obj == H5T_NATIVE_USHORT_g) + else if (obj == H5T_NATIVE_USHORT_g) HDfprintf(out, "H5T_NATIVE_USHORT"); - else if(obj == H5T_NATIVE_INT_g) + else if (obj == H5T_NATIVE_INT_g) HDfprintf(out, "H5T_NATIVE_INT"); - else if(obj == H5T_NATIVE_UINT_g) + else if (obj == H5T_NATIVE_UINT_g) HDfprintf(out, "H5T_NATIVE_UINT"); - else if(obj == H5T_NATIVE_LONG_g) + else if (obj == H5T_NATIVE_LONG_g) HDfprintf(out, "H5T_NATIVE_LONG"); - else if(obj == H5T_NATIVE_ULONG_g) + else if (obj == H5T_NATIVE_ULONG_g) HDfprintf(out, "H5T_NATIVE_ULONG"); - else if(obj == H5T_NATIVE_LLONG_g) + else if (obj == H5T_NATIVE_LLONG_g) HDfprintf(out, "H5T_NATIVE_LLONG"); - else if(obj == H5T_NATIVE_ULLONG_g) + else if (obj == H5T_NATIVE_ULLONG_g) HDfprintf(out, "H5T_NATIVE_ULLONG"); - else if(obj == H5T_NATIVE_FLOAT_g) + else if (obj == H5T_NATIVE_FLOAT_g) HDfprintf(out, "H5T_NATIVE_FLOAT"); - else if(obj == H5T_NATIVE_DOUBLE_g) + else if (obj == H5T_NATIVE_DOUBLE_g) HDfprintf(out, "H5T_NATIVE_DOUBLE"); -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if(obj == H5T_NATIVE_LDOUBLE_g) +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if (obj == H5T_NATIVE_LDOUBLE_g) HDfprintf(out, "H5T_NATIVE_LDOUBLE"); #endif - else if(obj == H5T_IEEE_F32BE_g) + else if (obj == H5T_IEEE_F32BE_g) HDfprintf(out, "H5T_IEEE_F32BE"); - else if(obj == H5T_IEEE_F32LE_g) + else if (obj == H5T_IEEE_F32LE_g) HDfprintf(out, "H5T_IEEE_F32LE"); - else if(obj == H5T_IEEE_F64BE_g) + else if (obj == H5T_IEEE_F64BE_g) HDfprintf(out, "H5T_IEEE_F64BE"); - else if(obj == H5T_IEEE_F64LE_g) + else if (obj == H5T_IEEE_F64LE_g) HDfprintf(out, "H5T_IEEE_F64LE"); - else if(obj == H5T_STD_I8BE_g) + else if (obj == H5T_STD_I8BE_g) HDfprintf(out, "H5T_STD_I8BE"); - else if(obj == H5T_STD_I8LE_g) + else if (obj == H5T_STD_I8LE_g) HDfprintf(out, "H5T_STD_I8LE"); - else if(obj == H5T_STD_I16BE_g) + else if (obj == H5T_STD_I16BE_g) HDfprintf(out, "H5T_STD_I16BE"); - else if(obj == H5T_STD_I16LE_g) + else if (obj == H5T_STD_I16LE_g) HDfprintf(out, "H5T_STD_I16LE"); - else if(obj == H5T_STD_I32BE_g) + else if (obj == H5T_STD_I32BE_g) HDfprintf(out, "H5T_STD_I32BE"); - else if(obj == H5T_STD_I32LE_g) + else if (obj == H5T_STD_I32LE_g) HDfprintf(out, "H5T_STD_I32LE"); - else if(obj == H5T_STD_I64BE_g) + else if (obj == H5T_STD_I64BE_g) HDfprintf(out, "H5T_STD_I64BE"); - else if(obj == H5T_STD_I64LE_g) + else if (obj == H5T_STD_I64LE_g) HDfprintf(out, "H5T_STD_I64LE"); - else if(obj == H5T_STD_U8BE_g) + else if (obj == H5T_STD_U8BE_g) HDfprintf(out, "H5T_STD_U8BE"); - else if(obj == H5T_STD_U8LE_g) + else if (obj == H5T_STD_U8LE_g) HDfprintf(out, "H5T_STD_U8LE"); - else if(obj == H5T_STD_U16BE_g) + else if (obj == H5T_STD_U16BE_g) HDfprintf(out, "H5T_STD_U16BE"); - else if(obj == H5T_STD_U16LE_g) + else if (obj == H5T_STD_U16LE_g) HDfprintf(out, "H5T_STD_U16LE"); - else if(obj == H5T_STD_U32BE_g) + else if (obj == H5T_STD_U32BE_g) HDfprintf(out, "H5T_STD_U32BE"); - else if(obj == H5T_STD_U32LE_g) + else if (obj == H5T_STD_U32LE_g) HDfprintf(out, "H5T_STD_U32LE"); - else if(obj == H5T_STD_U64BE_g) + else if (obj == H5T_STD_U64BE_g) HDfprintf(out, "H5T_STD_U64BE"); - else if(obj == H5T_STD_U64LE_g) + else if (obj == H5T_STD_U64LE_g) HDfprintf(out, "H5T_STD_U64LE"); - else if(obj == H5T_STD_B8BE_g) + else if (obj == H5T_STD_B8BE_g) HDfprintf(out, "H5T_STD_B8BE"); - else if(obj == H5T_STD_B8LE_g) + else if (obj == H5T_STD_B8LE_g) HDfprintf(out, "H5T_STD_B8LE"); - else if(obj == H5T_STD_B16BE_g) + else if (obj == H5T_STD_B16BE_g) HDfprintf(out, "H5T_STD_B16BE"); - else if(obj == H5T_STD_B16LE_g) + else if (obj == H5T_STD_B16LE_g) HDfprintf(out, "H5T_STD_B16LE"); - else if(obj == H5T_STD_B32BE_g) + else if (obj == H5T_STD_B32BE_g) HDfprintf(out, "H5T_STD_B32BE"); - else if(obj == H5T_STD_B32LE_g) + else if (obj == H5T_STD_B32LE_g) HDfprintf(out, "H5T_STD_B32LE"); - else if(obj == H5T_STD_B64BE_g) + else if (obj == H5T_STD_B64BE_g) HDfprintf(out, "H5T_STD_B64BE"); - else if(obj == H5T_STD_B64LE_g) + else if (obj == H5T_STD_B64LE_g) HDfprintf(out, "H5T_STD_B64LE"); - else if(obj == H5T_C_S1_g) + else if (obj == H5T_C_S1_g) HDfprintf(out, "H5T_C_S1"); - else if(obj == H5T_FORTRAN_S1_g) + else if (obj == H5T_FORTRAN_S1_g) HDfprintf(out, "H5T_FORTRAN_S1"); else HDfprintf(out, "%ld (dtype)", (long)obj); @@ -1363,8 +1364,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) { H5S_t *space; - if(NULL != (space = (H5S_t *)H5I_object(obj))) - if(H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space)) + if (NULL != (space = (H5S_t *)H5I_object(obj))) + if (H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space)) asize[argno] = H5S_GET_EXTENT_NDIMS(space); } break; @@ -1421,15 +1422,15 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld (unknown class)", (long)obj); break; } /* end switch */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ break; case 'I': switch (type[1]) { case 'i': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1437,7 +1438,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5_index_t idx_type = (H5_index_t)HDva_arg(ap, int); - switch(idx_type) { + switch (idx_type) { case H5_INDEX_UNKNOWN: HDfprintf(out, "H5_INDEX_UNKNOWN"); break; @@ -1458,12 +1459,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)idx_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1471,7 +1472,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5_iter_order_t order = (H5_iter_order_t)HDva_arg(ap, int); - switch(order) { + switch (order) { case H5_ITER_UNKNOWN: HDfprintf(out, "H5_ITER_UNKNOWN"); break; @@ -1496,22 +1497,22 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)order); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { - int *p = (int*)vp; + if (asize_idx >= 0 && asize[asize_idx] >= 0) { + int *p = (int *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) + for (i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%d", (i ? ", " : ""), p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -1524,8 +1525,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1610,22 +1611,22 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)id_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'u': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { - unsigned *p = (unsigned*)vp; + if (asize_idx >= 0 && asize[asize_idx] >= 0) { + unsigned *p = (unsigned *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%u", i?", ":"", p[i]); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%u", i ? ", " : "", p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -1644,15 +1645,15 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'k': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5O_token_t token = HDva_arg(ap, H5O_token_t); - int j; + int j; for (j = 0; j < H5O_MAX_TOKEN_SIZE; j++) HDfprintf(out, "%02x", token.__data[j]); @@ -1660,10 +1661,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'L': - switch(type[1]) { + switch (type[1]) { case 'l': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1671,7 +1672,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5L_type_t link_type = (H5L_type_t)HDva_arg(ap, int); - switch(link_type) { + switch (link_type) { case H5L_TYPE_ERROR: HDfprintf(out, "H5L_TYPE_ERROR"); break; @@ -1696,7 +1697,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)link_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1706,10 +1707,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'M': - switch(type[1]) { + switch (type[1]) { case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1720,12 +1721,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)comm); } /* end else */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ break; case 'i': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1736,12 +1737,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)info); } /* end else */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1749,7 +1750,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5FD_mem_t mt = (H5FD_mem_t)HDva_arg(ap, int); - switch(mt) { + switch (mt) { case H5FD_MEM_NOLIST: HDfprintf(out, "H5FD_MEM_NOLIST"); break; @@ -1790,7 +1791,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)mt); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1799,8 +1800,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1813,10 +1814,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'O': - switch(type[1]) { + switch (type[1]) { case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1824,7 +1825,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5O_type_t objtype = (H5O_type_t)HDva_arg(ap, int); - switch(objtype) { + switch (objtype) { case H5O_TYPE_UNKNOWN: HDfprintf(out, "H5O_TYPE_UNKNOWN"); break; @@ -1853,7 +1854,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "BADTYPE(%ld)", (long)objtype); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1863,21 +1864,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'p': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - hid_t pclass_id = HDva_arg(ap, hid_t); - char *class_name = NULL; + hid_t pclass_id = HDva_arg(ap, hid_t); + char * class_name = NULL; H5P_genclass_t *pclass; /* Get the class name and print it */ /* (This may generate recursive call to the library... -QAK) */ - if(NULL != (pclass = (H5P_genclass_t *)H5I_object(pclass_id)) && - NULL != (class_name = H5P_get_class_name(pclass))) { + if (NULL != (pclass = (H5P_genclass_t *)H5I_object(pclass_id)) && + NULL != (class_name = H5P_get_class_name(pclass))) { HDfprintf(out, "%s", class_name); H5MM_xfree(class_name); } /* end if */ @@ -1887,11 +1888,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'R': - switch(type[1]) { + switch (type[1]) { case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1904,8 +1905,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'd': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1918,8 +1919,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'r': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1932,8 +1933,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1941,7 +1942,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5R_type_t reftype = (H5R_type_t)HDva_arg(ap, int); - switch(reftype) { + switch (reftype) { case H5R_BADTYPE: HDfprintf(out, "H5R_BADTYPE"); break; @@ -1974,7 +1975,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "BADTYPE(%ld)", (long)reftype); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1984,10 +1985,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'S': - switch(type[1]) { + switch (type[1]) { case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1995,7 +1996,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5S_class_t cls = (H5S_class_t)HDva_arg(ap, int); - switch(cls) { + switch (cls) { case H5S_NO_CLASS: HDfprintf(out, "H5S_NO_CLASS"); break; @@ -2016,12 +2017,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)cls); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2029,7 +2030,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5S_seloper_t so = (H5S_seloper_t)HDva_arg(ap, int); - switch(so) { + switch (so) { case H5S_SELECT_NOOP: HDfprintf(out, "H5S_NOOP"); break; @@ -2074,12 +2075,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)so); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2087,7 +2088,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5S_sel_type st = (H5S_sel_type)HDva_arg(ap, int); - switch(st) { + switch (st) { case H5S_SEL_ERROR: HDfprintf(out, "H5S_SEL_ERROR"); break; @@ -2116,7 +2117,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)st); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -2126,8 +2127,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2140,10 +2141,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'T': - switch(type[1]) { + switch (type[1]) { case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2151,7 +2152,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_cset_t cset = (H5T_cset_t)HDva_arg(ap, int); - switch(cset) { + switch (cset) { case H5T_CSET_ERROR: HDfprintf(out, "H5T_CSET_ERROR"); break; @@ -2185,12 +2186,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)cset); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'd': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2198,7 +2199,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_direction_t direct = (H5T_direction_t)HDva_arg(ap, int); - switch(direct) { + switch (direct) { case H5T_DIR_DEFAULT: HDfprintf(out, "H5T_DIR_DEFAULT"); break; @@ -2215,12 +2216,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)direct); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'e': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2228,7 +2229,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_pers_t pers = (H5T_pers_t)HDva_arg(ap, int); - switch(pers) { + switch (pers) { case H5T_PERS_DONTCARE: HDfprintf(out, "H5T_PERS_DONTCARE"); break; @@ -2245,12 +2246,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)pers); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'n': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2258,7 +2259,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_norm_t norm = (H5T_norm_t)HDva_arg(ap, int); - switch(norm) { + switch (norm) { case H5T_NORM_ERROR: HDfprintf(out, "H5T_NORM_ERROR"); break; @@ -2279,12 +2280,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)norm); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2292,7 +2293,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_order_t order = (H5T_order_t)HDva_arg(ap, int); - switch(order) { + switch (order) { case H5T_ORDER_ERROR: HDfprintf(out, "H5T_ORDER_ERROR"); break; @@ -2321,12 +2322,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)order); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'p': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2334,7 +2335,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_pad_t pad = (H5T_pad_t)HDva_arg(ap, int); - switch(pad) { + switch (pad) { case H5T_PAD_ERROR: HDfprintf(out, "H5T_PAD_ERROR"); break; @@ -2359,12 +2360,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)pad); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2372,7 +2373,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_sign_t sign = (H5T_sign_t)HDva_arg(ap, int); - switch(sign) { + switch (sign) { case H5T_SGN_ERROR: HDfprintf(out, "H5T_SGN_ERROR"); break; @@ -2393,12 +2394,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)sign); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2406,7 +2407,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_class_t type_class = (H5T_class_t)HDva_arg(ap, int); - switch(type_class) { + switch (type_class) { case H5T_NO_CLASS: HDfprintf(out, "H5T_NO_CLASS"); break; @@ -2463,12 +2464,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)type_class); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'z': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2476,7 +2477,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_str_t str = (H5T_str_t)HDva_arg(ap, int); - switch(str) { + switch (str) { case H5T_STR_ERROR: HDfprintf(out, "H5T_STR_ERROR"); break; @@ -2506,14 +2507,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: - HDfprintf(out, "H5T_STR_RESERVED(%ld)",(long)str); + HDfprintf(out, "H5T_STR_RESERVED(%ld)", (long)str); break; default: HDfprintf(out, "%ld", (long)str); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -2523,18 +2524,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - htri_t tri_var = HDva_arg (ap, htri_t); + htri_t tri_var = HDva_arg(ap, htri_t); - if(tri_var>0) + if (tri_var > 0) HDfprintf(out, "TRUE"); - else if(!tri_var) + else if (!tri_var) HDfprintf(out, "FALSE"); else HDfprintf(out, "FAIL(%d)", (int)tri_var); @@ -2542,20 +2543,20 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'U': - switch(type[1]) { + switch (type[1]) { case 'l': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long *p = (unsigned long *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%lu", i?", ":"", p[i]); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%lu", i ? ", " : "", p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -2568,18 +2569,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'L': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long long *p = (unsigned long long *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%llu", i?", ":"", p[i]); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%llu", i ? ", " : "", p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -2598,10 +2599,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'V': - switch(type[1]) { + switch (type[1]) { case 'a': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2609,7 +2610,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_attr_get_t get = (H5VL_attr_get_t)HDva_arg(ap, int); - switch(get) { + switch (get) { case H5VL_ATTR_GET_SPACE: HDfprintf(out, "H5VL_ATTR_GET_SPACE"); break; @@ -2632,12 +2633,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)get); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'A': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2645,17 +2646,17 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_blob_optional_t optional = (H5VL_blob_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { default: HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'b': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2663,7 +2664,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_attr_specific_t specific = (H5VL_attr_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_ATTR_DELETE: HDfprintf(out, "H5VL_ATTR_DELETE"); break; @@ -2680,12 +2681,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'B': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2693,7 +2694,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_blob_specific_t specific = (H5VL_blob_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_BLOB_DELETE: HDfprintf(out, "H5VL_BLOB_DELETE"); break; @@ -2710,20 +2711,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'C': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_class_value_t class_val = (H5VL_class_value_t)HDva_arg(ap, H5VL_class_value_t); + H5VL_class_value_t class_val = + (H5VL_class_value_t)HDva_arg(ap, H5VL_class_value_t); - if(H5_VOL_NATIVE == class_val) + if (H5_VOL_NATIVE == class_val) HDfprintf(out, "H5_VOL_NATIVE"); else HDfprintf(out, "%ld", (long)class_val); @@ -2731,8 +2733,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2740,7 +2742,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_dataset_get_t get = (H5VL_dataset_get_t)HDva_arg(ap, int); - switch(get) { + switch (get) { case H5VL_DATASET_GET_SPACE: HDfprintf(out, "H5VL_DATASET_GET_SPACE"); break; @@ -2763,12 +2765,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)get); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'd': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2776,7 +2778,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_dataset_specific_t specific = (H5VL_dataset_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_DATASET_SET_EXTENT: HDfprintf(out, "H5VL_DATASET_SET_EXTENT"); break; @@ -2790,12 +2792,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'e': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2803,7 +2805,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_datatype_get_t get = (H5VL_datatype_get_t)HDva_arg(ap, int); - switch(get) { + switch (get) { case H5VL_DATATYPE_GET_BINARY: HDfprintf(out, "H5VL_DATATYPE_GET_BINARY"); break; @@ -2814,12 +2816,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)get); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'f': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2827,7 +2829,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_datatype_specific_t specific = (H5VL_datatype_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_DATATYPE_FLUSH: HDfprintf(out, "H5VL_DATATYPE_FLUSH"); break; @@ -2838,12 +2840,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'g': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2851,7 +2853,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_file_get_t get = (H5VL_file_get_t)HDva_arg(ap, int); - switch(get) { + switch (get) { case H5VL_FILE_GET_CONT_INFO: HDfprintf(out, "H5VL_FILE_GET_CONT_INFO"); break; @@ -2880,12 +2882,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)get); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'h': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2893,7 +2895,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_file_specific_t specific = (H5VL_file_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_FILE_FLUSH: HDfprintf(out, "H5VL_FILE_FLUSH"); break; @@ -2919,12 +2921,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'i': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2932,7 +2934,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_group_get_t get = (H5VL_group_get_t)HDva_arg(ap, int); - switch(get) { + switch (get) { case H5VL_GROUP_GET_GCPL: HDfprintf(out, "H5VL_GROUP_GET_GCPL"); break; @@ -2943,12 +2945,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)get); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'j': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2956,7 +2958,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_group_specific_t specific = (H5VL_group_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_GROUP_FLUSH: HDfprintf(out, "H5VL_GROUP_FLUSH"); break; @@ -2967,12 +2969,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'k': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2980,7 +2982,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_link_create_type_t create = (H5VL_link_create_type_t)HDva_arg(ap, int); - switch(create) { + switch (create) { case H5VL_LINK_CREATE_HARD: HDfprintf(out, "H5VL_LINK_CREATE_HARD"); break; @@ -2994,12 +2996,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)create); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'l': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3007,7 +3009,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_link_get_t get = (H5VL_link_get_t)HDva_arg(ap, int); - switch(get) { + switch (get) { case H5VL_LINK_GET_INFO: HDfprintf(out, "H5VL_LINK_GET_INFO"); break; @@ -3021,12 +3023,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)get); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'L': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3034,7 +3036,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_get_conn_lvl_t get = (H5VL_get_conn_lvl_t)HDva_arg(ap, int); - switch(get) { + switch (get) { case H5VL_GET_CONN_LVL_CURR: HDfprintf(out, "H5VL_GET_CONN_LVL_CURR"); break; @@ -3045,12 +3047,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)get); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'm': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3058,7 +3060,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_link_specific_t specific = (H5VL_link_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_LINK_DELETE: HDfprintf(out, "H5VL_LINK_DELETE"); break; @@ -3072,12 +3074,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'n': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3085,7 +3087,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_object_get_t get = (H5VL_object_get_t)HDva_arg(ap, int); - switch(get) { + switch (get) { case H5VL_OBJECT_GET_FILE: HDfprintf(out, "H5VL_OBJECT_GET_FILE"); break; @@ -3102,12 +3104,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)get); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3115,7 +3117,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_object_specific_t specific = (H5VL_object_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_OBJECT_CHANGE_REF_COUNT: HDfprintf(out, "H5VL_OBJECT_CHANGE_REF_COUNT"); break; @@ -3138,12 +3140,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'r': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3151,7 +3153,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_request_specific_t specific = (H5VL_request_specific_t)HDva_arg(ap, int); - switch(specific) { + switch (specific) { case H5VL_REQUEST_WAITANY: HDfprintf(out, "H5VL_REQUEST_WAITANY"); break; @@ -3165,12 +3167,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)specific); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3178,7 +3180,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_attr_optional_t optional = (H5VL_attr_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { #ifndef H5_NO_DEPRECATED_SYMBOLS case H5VL_NATIVE_ATTR_ITERATE_OLD: HDfprintf(out, "H5VL_NATIVE_ATTR_ITERATE_OLD"); @@ -3188,12 +3190,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'S': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3201,7 +3203,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_subclass_t subclass = (H5VL_subclass_t)HDva_arg(ap, int); - switch(subclass) { + switch (subclass) { case H5VL_SUBCLS_NONE: HDfprintf(out, "H5VL_SUBCLS_NONE"); break; @@ -3245,12 +3247,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)subclass); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3258,7 +3260,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_dataset_optional_t optional = (H5VL_dataset_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { case H5VL_NATIVE_DATASET_FORMAT_CONVERT: HDfprintf(out, "H5VL_NATIVE_DATASET_FORMAT_CONVERT"); break; @@ -3293,12 +3295,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'u': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3306,17 +3308,17 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_datatype_optional_t optional = (H5VL_datatype_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { default: HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'v': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3324,7 +3326,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_file_optional_t optional = (H5VL_file_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: HDfprintf(out, "H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE"); break; @@ -3416,12 +3418,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'w': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3429,7 +3431,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_group_optional_t optional = (H5VL_group_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { #ifndef H5_NO_DEPRECATED_SYMBOLS case H5VL_NATIVE_GROUP_ITERATE_OLD: HDfprintf(out, "H5VL_NATIVE_GROUP_ITERATE_OLD"); @@ -3442,12 +3444,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'x': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3455,17 +3457,17 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_link_optional_t optional = (H5VL_link_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { default: HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'y': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3473,7 +3475,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_object_optional_t optional = (H5VL_object_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { case H5VL_NATIVE_OBJECT_GET_COMMENT: HDfprintf(out, "H5VL_NATIVE_OBJECT_GET_COMMENT"); break; @@ -3496,12 +3498,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'z': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3509,12 +3511,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5VL_request_optional_t optional = (H5VL_request_optional_t)HDva_arg(ap, int); - switch(optional) { + switch (optional) { default: HDfprintf(out, "%ld", (long)optional); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -3524,29 +3526,29 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'x': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { - void **p = (void**)vp; + if (asize_idx >= 0 && asize[asize_idx] >= 0) { + void **p = (void **)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) { - if(p[i]) + for (i = 0; i < asize[asize_idx]; i++) { + if (p[i]) HDfprintf(out, "%s0x%p", (i ? ", " : ""), p[i]); else HDfprintf(out, "%sNULL", (i ? ", " : "")); } /* end for */ HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ else { - vp = HDva_arg (ap, void *); + vp = HDva_arg(ap, void *); - if(vp) + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3554,18 +3556,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'z': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { size_t *p = (size_t *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) + for (i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%Zu", (i ? ", " : ""), p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -3580,8 +3582,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'Z': switch (type[1]) { case 'a': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3589,7 +3591,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5Z_SO_scale_type_t scale_type = (H5Z_SO_scale_type_t)HDva_arg(ap, int); - switch(scale_type) { + switch (scale_type) { case H5Z_SO_FLOAT_DSCALE: HDfprintf(out, "H5Z_SO_FLOAT_DSCALE"); break; @@ -3606,26 +3608,26 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)scale_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t*); + H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t *); HDfprintf(out, "0x%p", filter); } /* end else */ break; case 'e': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3633,7 +3635,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5Z_EDC_t edc = (H5Z_EDC_t)HDva_arg(ap, int); - if(H5Z_DISABLE_EDC == edc) + if (H5Z_DISABLE_EDC == edc) HDfprintf(out, "H5Z_DISABLE_EDC"); else if (H5Z_ENABLE_EDC == edc) HDfprintf(out, "H5Z_ENABLE_EDC"); @@ -3643,8 +3645,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'f': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -3652,7 +3654,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5Z_filter_t id = HDva_arg(ap, H5Z_filter_t); - if(H5Z_FILTER_DEFLATE == id) + if (H5Z_FILTER_DEFLATE == id) HDfprintf(out, "H5Z_FILTER_DEFLATE"); else HDfprintf(out, "%ld", (long)id); @@ -3660,18 +3662,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 's': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { ssize_t *p = (ssize_t *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) + for (i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%Zd", (i ? ", " : ""), p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -3690,25 +3692,25 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; default: - if(HDisupper(type[0])) + if (HDisupper(type[0])) HDfprintf(out, "BADTYPE(%c%c)", type[0], type[1]); else HDfprintf(out, "BADTYPE(%c)", type[0]); goto error; } /* end switch */ - } /* end for */ + } /* end for */ /* Display event time for return */ - if(returning && H5_debug_g.ttimes) { + if (returning && H5_debug_g.ttimes) { H5_timer_get_times(function_timer, &function_times); H5_timer_get_times(running_timer, &running_times); HDfprintf(out, " @%.6f [dt=%.6f]", (function_times.elapsed - running_times.elapsed), - (function_times.elapsed - *returning)); + (function_times.elapsed - *returning)); } /* end if */ error: HDva_end(ap); - if(returning) + if (returning) HDfprintf(out, ";\n"); else { last_call_depth = current_depth++; @@ -3716,9 +3718,8 @@ error: } /* end else */ HDfflush(out); - if(H5_debug_g.ttimes) + if (H5_debug_g.ttimes) return function_times.elapsed; else return 0.0F; } /* end H5_trace() */ - diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 0296a54..7d6cb12 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -27,37 +27,37 @@ * *may* provide these definitions. */ #ifdef _WIN64 -# define PRIdPTR "lld" -# define PRIoPTR "llo" -# define PRIuPTR "llu" -# define PRIxPTR "llx" +#define PRIdPTR "lld" +#define PRIoPTR "llo" +#define PRIuPTR "llu" +#define PRIxPTR "llx" #else /* _WIN64 */ -# define PRIdPTR "ld" -# define PRIoPTR "lo" -# define PRIuPTR "lu" -# define PRIxPTR "lx" +#define PRIdPTR "ld" +#define PRIoPTR "lo" +#define PRIuPTR "lu" +#define PRIxPTR "lx" #endif /* _WIN64 */ -# define PRId8 "d" -# define PRIo8 "o" -# define PRIu8 "u" -# define PRIx8 "x" -# define PRId16 "d" -# define PRIo16 "o" -# define PRIu16 "u" -# define PRIx16 "x" -# define PRId32 "d" -# define PRIo32 "o" -# define PRIu32 "u" -# define PRIx32 "x" -# define PRId64 "lld" -# define PRIo64 "llo" -# define PRIu64 "llu" -# define PRIx64 "llx" -# define PRIdMAX "lld" -# define PRIoMAX "llo" -# define PRIuMAX "llu" -# define PRIxMAX "llx" +#define PRId8 "d" +#define PRIo8 "o" +#define PRIu8 "u" +#define PRIx8 "x" +#define PRId16 "d" +#define PRIo16 "o" +#define PRIu16 "u" +#define PRIx16 "x" +#define PRId32 "d" +#define PRIo32 "o" +#define PRIu32 "u" +#define PRIx32 "x" +#define PRId64 "lld" +#define PRIo64 "llo" +#define PRIu64 "llu" +#define PRIx64 "llx" +#define PRIdMAX "lld" +#define PRIoMAX "llo" +#define PRIuMAX "llu" +#define PRIxMAX "llx" #endif /* @@ -67,54 +67,54 @@ */ #ifdef H5_HAVE_WIN32_API -typedef struct _stati64 h5_stat_t; -typedef __int64 h5_stat_size_t; - -#define HDaccess(F,M) _access(F,M) -#define HDchdir(S) _chdir(S) -#define HDclose(F) _close(F) -#define HDcreat(S,M) Wopen_utf8(S,O_CREAT|O_TRUNC|O_RDWR,M) -#define HDdup(F) _dup(F) -#define HDfdopen(N,S) _fdopen(N,S) -#define HDfileno(F) _fileno(F) -#define HDfstat(F,B) _fstati64(F,B) -#define HDisatty(F) _isatty(F) - -#define HDgetcwd(S,Z) _getcwd(S,Z) -#define HDgetdcwd(D,S,Z) _getdcwd(D,S,Z) -#define HDgetdrive() _getdrive() -#define HDlseek(F,O,W) _lseeki64(F,O,W) -#define HDlstat(S,B) _lstati64(S,B) -#define HDmkdir(S,M) _mkdir(S) -#define HDoff_t __int64 +typedef struct _stati64 h5_stat_t; +typedef __int64 h5_stat_size_t; + +#define HDaccess(F, M) _access(F, M) +#define HDchdir(S) _chdir(S) +#define HDclose(F) _close(F) +#define HDcreat(S, M) Wopen_utf8(S, O_CREAT | O_TRUNC | O_RDWR, M) +#define HDdup(F) _dup(F) +#define HDfdopen(N, S) _fdopen(N, S) +#define HDfileno(F) _fileno(F) +#define HDfstat(F, B) _fstati64(F, B) +#define HDisatty(F) _isatty(F) + +#define HDgetcwd(S, Z) _getcwd(S, Z) +#define HDgetdcwd(D, S, Z) _getdcwd(D, S, Z) +#define HDgetdrive() _getdrive() +#define HDlseek(F, O, W) _lseeki64(F, O, W) +#define HDlstat(S, B) _lstati64(S, B) +#define HDmkdir(S, M) _mkdir(S) +#define HDoff_t __int64 /* Note that the variadic HDopen macro is using a VC++ extension * where the comma is dropped if nothing is passed to the ellipsis. */ #ifndef H5_HAVE_MINGW -#define HDopen(S,F,...) Wopen_utf8(S,F,__VA_ARGS__) +#define HDopen(S, F, ...) Wopen_utf8(S, F, __VA_ARGS__) #else -#define HDopen(S,F,...) Wopen_utf8(S,F,##__VA_ARGS__) +#define HDopen(S, F, ...) Wopen_utf8(S, F, ##__VA_ARGS__) #endif -#define HDread(F,M,Z) _read(F,M,Z) -#define HDremove(S) Wremove_utf8(S) -#define HDrmdir(S) _rmdir(S) -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) -#define HDsleep(S) Sleep(S*1000) -#define HDstat(S,B) _stati64(S,B) -#define HDstrcasecmp(A,B) _stricmp(A,B) -#define HDstrdup(S) _strdup(S) -#define HDstrtok_r(X,Y,Z) strtok_s(X,Y,Z) -#define HDtzset() _tzset() -#define HDunlink(S) _unlink(S) -#define HDwrite(F,M,Z) _write(F,M,Z) +#define HDread(F, M, Z) _read(F, M, Z) +#define HDremove(S) Wremove_utf8(S) +#define HDrmdir(S) _rmdir(S) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2)) +#define HDsleep(S) Sleep(S * 1000) +#define HDstat(S, B) _stati64(S, B) +#define HDstrcasecmp(A, B) _stricmp(A, B) +#define HDstrdup(S) _strdup(S) +#define HDstrtok_r(X, Y, Z) strtok_s(X, Y, Z) +#define HDtzset() _tzset() +#define HDunlink(S) _unlink(S) +#define HDwrite(F, M, Z) _write(F, M, Z) #ifdef H5_HAVE_VISUAL_STUDIO /* * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO */ -#define HDmemset(X,C,Z) memset((void*)(X),C,Z) +#define HDmemset(X, C, Z) memset((void *)(X), C, Z) struct timezone { int tz_minuteswest; @@ -123,34 +123,32 @@ struct timezone { #endif /* H5_HAVE_VISUAL_STUDIO */ - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); - H5_DLL int Wsetenv(const char *name, const char *value, int overwrite); - H5_DLL int Wflock(int fd, int operation); - H5_DLL char* Wgetlogin(void); - H5_DLL herr_t H5_expand_windows_env_vars(char **env_var); - H5_DLL const wchar_t *H5_get_utf16_str(const char *s); - H5_DLL int Wopen_utf8(const char *path, int oflag, ...); - H5_DLL int Wremove_utf8(const char *path); - H5_DLL int H5_get_win32_times(H5_timevals_t* tvs); +H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +H5_DLL int Wsetenv(const char *name, const char *value, int overwrite); +H5_DLL int Wflock(int fd, int operation); +H5_DLL char * Wgetlogin(void); +H5_DLL herr_t H5_expand_windows_env_vars(char **env_var); +H5_DLL const wchar_t *H5_get_utf16_str(const char *s); +H5_DLL int Wopen_utf8(const char *path, int oflag, ...); +H5_DLL int Wremove_utf8(const char *path); +H5_DLL int H5_get_win32_times(H5_timevals_t *tvs); #ifdef __cplusplus } #endif /* __cplusplus */ -#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) -#define HDsetenv(N,V,O) Wsetenv(N,V,O) -#define HDflock(F,L) Wflock(F,L) -#define HDgetlogin() Wgetlogin() +#define HDgettimeofday(V, Z) Wgettimeofday(V, Z) +#define HDsetenv(N, V, O) Wsetenv(N, V, O) +#define HDflock(F, L) Wflock(F, L) +#define HDgetlogin() Wgetlogin() /* Non-POSIX functions */ #ifndef H5_HAVE_MINGW -#define HDftruncate(F,L) _chsize_s(F,L) -#define HDfseek(F,O,W) _fseeki64(F,O,W) +#define HDftruncate(F, L) _chsize_s(F, L) +#define HDfseek(F, O, W) _fseeki64(F, O, W) #endif /* H5_HAVE_MINGW */ #endif /* H5_HAVE_WIN32_API */ - diff --git a/src/hdf5.h b/src/hdf5.h index 7df67f7..1c258f8 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -20,46 +20,46 @@ #define _HDF5_H #include "H5public.h" -#include "H5Apublic.h" /* Attributes */ -#include "H5ACpublic.h" /* Metadata cache */ -#include "H5Dpublic.h" /* Datasets */ -#include "H5Epublic.h" /* Errors */ -#include "H5Fpublic.h" /* Files */ -#include "H5FDpublic.h" /* File drivers */ -#include "H5Gpublic.h" /* Groups */ -#include "H5Ipublic.h" /* ID management */ -#include "H5Lpublic.h" /* Links */ -#include "H5Mpublic.h" /* Maps */ -#include "H5MMpublic.h" /* Memory management */ -#include "H5Opublic.h" /* Object headers */ -#include "H5Ppublic.h" /* Property lists */ -#include "H5PLpublic.h" /* Plugins */ -#include "H5Rpublic.h" /* References */ -#include "H5Spublic.h" /* Dataspaces */ -#include "H5Tpublic.h" /* Datatypes */ -#include "H5VLpublic.h" /* Virtual Object Layer */ -#include "H5Zpublic.h" /* Data filters */ +#include "H5Apublic.h" /* Attributes */ +#include "H5ACpublic.h" /* Metadata cache */ +#include "H5Dpublic.h" /* Datasets */ +#include "H5Epublic.h" /* Errors */ +#include "H5Fpublic.h" /* Files */ +#include "H5FDpublic.h" /* File drivers */ +#include "H5Gpublic.h" /* Groups */ +#include "H5Ipublic.h" /* ID management */ +#include "H5Lpublic.h" /* Links */ +#include "H5Mpublic.h" /* Maps */ +#include "H5MMpublic.h" /* Memory management */ +#include "H5Opublic.h" /* Object headers */ +#include "H5Ppublic.h" /* Property lists */ +#include "H5PLpublic.h" /* Plugins */ +#include "H5Rpublic.h" /* References */ +#include "H5Spublic.h" /* Dataspaces */ +#include "H5Tpublic.h" /* Datatypes */ +#include "H5VLpublic.h" /* Virtual Object Layer */ +#include "H5Zpublic.h" /* Data filters */ /* Predefined file drivers */ -#include "H5FDcore.h" /* Files stored entirely in memory */ -#include "H5FDdirect.h" /* Linux direct I/O */ -#include "H5FDfamily.h" /* File families */ -#include "H5FDhdfs.h" /* Hadoop HDFS */ -#include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ -#include "H5FDmirror.h" /* Mirror VFD and IPC definitions */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5FDmulti.h" /* Usage-partitioned file family */ -#include "H5FDros3.h" /* R/O S3 "file" I/O */ -#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ -#include "H5FDsplitter.h" /* Twin-channel (R/W & R/O) I/O passthrough */ -#include "H5FDstdio.h" /* Standard C buffered I/O */ -#include "H5FDvfd_swmr.h" /* VFD SWMR reader VFD */ +#include "H5FDcore.h" /* Files stored entirely in memory */ +#include "H5FDdirect.h" /* Linux direct I/O */ +#include "H5FDfamily.h" /* File families */ +#include "H5FDhdfs.h" /* Hadoop HDFS */ +#include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ +#include "H5FDmirror.h" /* Mirror VFD and IPC definitions */ +#include "H5FDmpi.h" /* MPI-based file drivers */ +#include "H5FDmulti.h" /* Usage-partitioned file family */ +#include "H5FDros3.h" /* R/O S3 "file" I/O */ +#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ +#include "H5FDsplitter.h" /* Twin-channel (R/W & R/O) I/O passthrough */ +#include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDvfd_swmr.h" /* VFD SWMR reader VFD */ #ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Win32 I/O */ +#include "H5FDwindows.h" /* Win32 I/O */ #endif /* Virtual object layer (VOL) connectors */ -#include "H5VLnative.h" /* Native VOL connector */ -#include "H5VLpassthru.h" /* Pass-through VOL connector */ +#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLpassthru.h" /* Pass-through VOL connector */ #endif diff --git a/test/H5srcdir.h b/test/H5srcdir.h index 019cfda..07ab90d 100644 --- a/test/H5srcdir.h +++ b/test/H5srcdir.h @@ -34,4 +34,3 @@ H5TEST_DLL const char *H5_get_srcdir_filename(const char *filename); #endif #endif /* _H5SRCDIR_H */ - diff --git a/test/accum.c b/test/accum.c index 8b0d026..53c18d5 100644 --- a/test/accum.c +++ b/test/accum.c @@ -10,9 +10,9 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* Programmer: Mike McGreevy - * October 7, 2010 - */ +/* Programmer: Mike McGreevy + * October 7, 2010 + */ #include "h5test.h" #define H5F_FRIEND /*suppress error about including H5Fpkg */ @@ -25,9 +25,9 @@ #include "H5Iprivate.h" #include "H5VLprivate.h" /* Virtual Object Layer */ - /* Filename */ - /* (The file names are the same as the define in accum_swmr_reader.c) */ -const char* FILENAME[] = { "accum", "accum_swmr_big", NULL }; +/* Filename */ +/* (The file names are the same as the define in accum_swmr_reader.c) */ +const char *FILENAME[] = {"accum", "accum_swmr_big", NULL}; /* The reader forked by test_swmr_write_big() */ #define SWMR_READER "accum_swmr_reader" @@ -42,22 +42,22 @@ const char* FILENAME[] = { "accum", "accum_swmr_big", NULL }; #define RANDOM_BASE_OFF (1024 * 1024) /* Function Prototypes */ -unsigned test_write_read(H5F_t* f); -unsigned test_write_read_nonacc_front(H5F_t* f); -unsigned test_write_read_nonacc_end(H5F_t* f); -unsigned test_accum_overlap(H5F_t* f); -unsigned test_accum_overlap_clean(H5F_t* f); -unsigned test_accum_overlap_size(H5F_t* f); -unsigned test_accum_non_overlap_size(H5F_t* f); -unsigned test_accum_adjust(H5F_t* f); -unsigned test_read_after(H5F_t* f); -unsigned test_free(H5F_t* f); -unsigned test_big(H5F_t* f); -unsigned test_random_write(H5F_t* f); +unsigned test_write_read(H5F_t *f); +unsigned test_write_read_nonacc_front(H5F_t *f); +unsigned test_write_read_nonacc_end(H5F_t *f); +unsigned test_accum_overlap(H5F_t *f); +unsigned test_accum_overlap_clean(H5F_t *f); +unsigned test_accum_overlap_size(H5F_t *f); +unsigned test_accum_non_overlap_size(H5F_t *f); +unsigned test_accum_adjust(H5F_t *f); +unsigned test_read_after(H5F_t *f); +unsigned test_free(H5F_t *f); +unsigned test_big(H5F_t *f); +unsigned test_random_write(H5F_t *f); unsigned test_swmr_write_big(hbool_t newest_format); /* Helper Function Prototypes */ -void accum_printf(const H5F_t* f); +void accum_printf(const H5F_t *f); /* Private Test H5Faccum Function Wrappers */ #define accum_write(a, s, b) H5F_block_write(f, H5FD_MEM_DEFAULT, (haddr_t)(a), (size_t)(s), (b)) @@ -86,12 +86,12 @@ void accum_printf(const H5F_t* f); int main(void) { - unsigned nerrors = 0; /* track errors */ + unsigned nerrors = 0; /* track errors */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - hid_t fid = -1; - hid_t fapl = -1; /* File access property list */ + hid_t fid = -1; + hid_t fapl = -1; /* File access property list */ char filename[1024]; - H5F_t* f = NULL; /* File for all tests */ + H5F_t * f = NULL; /* File for all tests */ /* Test Setup */ HDputs("Testing the metadata accumulator"); @@ -100,32 +100,32 @@ main(void) h5_reset(); if ((fapl = h5_fileaccess()) < 0) FAIL_STACK_ERROR - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Create a test file */ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - /* Push API context */ - if (H5CX_push() < 0) - FAIL_STACK_ERROR - api_ctx_pushed = TRUE; + /* Push API context */ + if (H5CX_push() < 0) + FAIL_STACK_ERROR + api_ctx_pushed = TRUE; /* Get H5F_t * to internal file structure */ - if (NULL == (f = (H5F_t*)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR - /* We'll be writing lots of garbage data, so extend the - file a ways. 10MB should do. */ - if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_DEFAULT, (haddr_t)(1024 * 1024 * 10)) < 0) - FAIL_STACK_ERROR + /* We'll be writing lots of garbage data, so extend the + file a ways. 10MB should do. */ + if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_DEFAULT, (haddr_t)(1024 * 1024 * 10)) < 0) + FAIL_STACK_ERROR - /* Reset metadata accumulator for the file */ - if (accum_reset(f) < 0) - FAIL_STACK_ERROR + /* Reset metadata accumulator for the file */ + if (accum_reset(f) < 0) + FAIL_STACK_ERROR - /* Test Functions */ - nerrors += test_write_read(f); + /* Test Functions */ + nerrors += test_write_read(f); nerrors += test_write_read_nonacc_front(f); nerrors += test_write_read_nonacc_end(f); nerrors += test_accum_overlap(f); @@ -141,14 +141,14 @@ main(void) /* Pop API context */ if (api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR - api_ctx_pushed = FALSE; + api_ctx_pushed = FALSE; /* End of test code, close and delete file */ if (H5Fclose(fid) < 0) TEST_ERROR - /* This test uses a different file */ - nerrors += test_swmr_write_big(TRUE); + /* This test uses a different file */ + nerrors += test_swmr_write_big(TRUE); nerrors += test_swmr_write_big(FALSE); if (nerrors) @@ -184,17 +184,17 @@ error: *------------------------------------------------------------------------- */ unsigned -test_write_read(H5F_t* f) +test_write_read(H5F_t *f) { int i = 0; - int* write_buf, * read_buf; + int *write_buf, *read_buf; TESTING("simple write/read to/from metadata accumulator"); /* Allocate buffers */ - write_buf = (int*)HDmalloc(1024 * sizeof(int)); + write_buf = (int *)HDmalloc(1024 * sizeof(int)); HDassert(write_buf); - read_buf = (int*)HDcalloc((size_t)1024, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)1024, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -243,17 +243,17 @@ error: *------------------------------------------------------------------------- */ unsigned -test_write_read_nonacc_front(H5F_t* f) +test_write_read_nonacc_front(H5F_t *f) { int i = 0; - int* write_buf, * read_buf; + int *write_buf, *read_buf; TESTING("simple write/read to/from before metadata accumulator"); /* Allocate buffers */ - write_buf = (int*)HDmalloc(2048 * sizeof(int)); + write_buf = (int *)HDmalloc(2048 * sizeof(int)); HDassert(write_buf); - read_buf = (int*)HDcalloc((size_t)2048, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)2048, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -308,17 +308,17 @@ error: *------------------------------------------------------------------------- */ unsigned -test_write_read_nonacc_end(H5F_t* f) +test_write_read_nonacc_end(H5F_t *f) { int i = 0; - int* write_buf, * read_buf; + int *write_buf, *read_buf; TESTING("simple write/read to/from after metadata accumulator"); /* Allocate buffers */ - write_buf = (int*)HDmalloc(2048 * sizeof(int)); + write_buf = (int *)HDmalloc(2048 * sizeof(int)); HDassert(write_buf); - read_buf = (int*)HDcalloc((size_t)2048, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)2048, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -373,21 +373,21 @@ error: *------------------------------------------------------------------------- */ unsigned -test_free(H5F_t* f) +test_free(H5F_t *f) { - int i = 0; - int32_t* wbuf = NULL; - int32_t* rbuf = NULL; - int32_t* expect = NULL; + int i = 0; + int32_t *wbuf = NULL; + int32_t *rbuf = NULL; + int32_t *expect = NULL; TESTING("simple freeing metadata accumulator"); /* Write and free the whole accumulator. */ - wbuf = (int32_t*)HDmalloc(256 * sizeof(int32_t)); + wbuf = (int32_t *)HDmalloc(256 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t*)HDmalloc(256 * sizeof(int32_t)); + rbuf = (int32_t *)HDmalloc(256 * sizeof(int32_t)); HDassert(rbuf); - expect = (int32_t*)HDmalloc(256 * sizeof(int32_t)); + expect = (int32_t *)HDmalloc(256 * sizeof(int32_t)); HDassert(expect); /* Fill buffer with data */ @@ -606,17 +606,17 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_overlap(H5F_t* f) +test_accum_overlap(H5F_t *f) { int i = 0; - int32_t* wbuf, * rbuf; + int32_t *wbuf, *rbuf; TESTING("overlapping write to metadata accumulator"); /* Allocate buffers */ - wbuf = (int32_t*)HDmalloc(4096 * sizeof(int32_t)); + wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t*)HDcalloc((size_t)4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -813,17 +813,17 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_overlap_clean(H5F_t* f) +test_accum_overlap_clean(H5F_t *f) { int i = 0; - int32_t* wbuf, * rbuf; + int32_t *wbuf, *rbuf; TESTING("overlapping write to partially clean metadata accumulator"); /* Allocate buffers */ - wbuf = (int32_t*)HDmalloc(4096 * sizeof(int32_t)); + wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t*)HDcalloc((size_t)4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -855,8 +855,8 @@ test_accum_overlap_clean(H5F_t* f) /* Case 3: Start of new piece aligns with start of accumulated data, * completely encloses dirty section of accumulator */ - /* Write 6 3's at address 20 */ - /* @0:| 333333111111111| */ + /* Write 6 3's at address 20 */ + /* @0:| 333333111111111| */ for (i = 0; i < 6; i++) wbuf[i] = 3; if (accum_write(20, 6 * sizeof(int32_t), wbuf) < 0) @@ -868,8 +868,8 @@ test_accum_overlap_clean(H5F_t* f) /* Case 4: New piece completely within accumulated data, overlaps * end of dirty section of accumulator */ - /* Write 2 4's at address 40 */ - /* @0:| 333334411111111| */ + /* Write 2 4's at address 40 */ + /* @0:| 333334411111111| */ for (i = 0; i < 2; i++) wbuf[i] = 4; if (accum_write(40, 2 * sizeof(int32_t), wbuf) < 0) @@ -881,8 +881,8 @@ test_accum_overlap_clean(H5F_t* f) /* Case 5: New piece completely within accumulated data, completely * after dirty section of accumulator */ - /* Write 2 5's at address 52 */ - /* @0:| 333334415511111| */ + /* Write 2 5's at address 52 */ + /* @0:| 333334415511111| */ for (i = 0; i < 2; i++) wbuf[i] = 5; if (accum_write(52, 2 * sizeof(int32_t), wbuf) < 0) @@ -922,8 +922,8 @@ test_accum_overlap_clean(H5F_t* f) /* Case 8: New piece overlaps start of accumulated data, completely * encloses dirty section of accumulator */ - /* Write 4 8's at address 12 */ - /* @0:| 88883334666511111| */ + /* Write 4 8's at address 12 */ + /* @0:| 88883334666511111| */ for (i = 0; i < 4; i++) wbuf[i] = 8; if (accum_write(12, 4 * sizeof(int32_t), wbuf) < 0) @@ -963,8 +963,8 @@ test_accum_overlap_clean(H5F_t* f) /* Case 11: New piece overlaps end of accumulated data, completely encloses * dirty section of accumulator */ - /* Write 4 7's at address 84 */ - /* @0:| 8888333466651111197777| */ + /* Write 4 7's at address 84 */ + /* @0:| 8888333466651111197777| */ for (i = 0; i < 4; i++) wbuf[i] = 7; if (accum_write(84, 4 * sizeof(int32_t), wbuf) < 0) @@ -1032,17 +1032,17 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_non_overlap_size(H5F_t* f) +test_accum_non_overlap_size(H5F_t *f) { int i = 0; - int32_t* wbuf, * rbuf; + int32_t *wbuf, *rbuf; TESTING("non-overlapping write to accumulator larger then accum_size"); /* Allocate buffers */ - wbuf = (int*)HDmalloc(4096 * sizeof(int32_t)); + wbuf = (int *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int*)HDcalloc((size_t)4096, sizeof(int32_t)); + rbuf = (int *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -1106,17 +1106,17 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_overlap_size(H5F_t* f) +test_accum_overlap_size(H5F_t *f) { int i = 0; - int32_t* wbuf, * rbuf; + int32_t *wbuf, *rbuf; TESTING("overlapping write to accumulator larger then accum_size"); /* Allocate buffers */ - wbuf = (int32_t*)HDmalloc(4096 * sizeof(int32_t)); + wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t*)HDcalloc((size_t)4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -1190,18 +1190,18 @@ error: *------------------------------------------------------------------------- */ unsigned -test_accum_adjust(H5F_t* f) +test_accum_adjust(H5F_t *f) { int i = 0; int s = 1048576; /* size of buffer */ - int32_t* wbuf, * rbuf; + int32_t *wbuf, *rbuf; TESTING("accumulator adjustments after append/prepend of data"); /* Allocate buffers */ - wbuf = (int32_t*)HDmalloc((size_t)s * sizeof(int32_t)); + wbuf = (int32_t *)HDmalloc((size_t)s * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t*)HDcalloc((size_t)s, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)s, sizeof(int32_t)); HDassert(rbuf); /* Fill up write buffer */ @@ -1297,15 +1297,15 @@ test_accum_adjust(H5F_t* f) if (accum_flush(f) < 0) FAIL_STACK_ERROR - /* Write a small (1KB) block to the end of the accumulator */ - /* ==> Accumulator will need more buffer space */ - /* ==> Accumulator will try to resize, but see that it's getting too big */ - /* ==> Size of new block is larger than half maximum size of accumulator */ - /* ==> New block being appended to accumulator */ - /* ==> Accumulator is NOT dirty */ - /* ==> Since we're appending, need to adjust location of accumulator */ - if (accum_write((1024 * 1024) - 1, 1024, wbuf) < 0) - FAIL_STACK_ERROR; + /* Write a small (1KB) block to the end of the accumulator */ + /* ==> Accumulator will need more buffer space */ + /* ==> Accumulator will try to resize, but see that it's getting too big */ + /* ==> Size of new block is larger than half maximum size of accumulator */ + /* ==> New block being appended to accumulator */ + /* ==> Accumulator is NOT dirty */ + /* ==> Since we're appending, need to adjust location of accumulator */ + if (accum_write((1024 * 1024) - 1, 1024, wbuf) < 0) + FAIL_STACK_ERROR; /* Write a piece of metadata outside current accumulator to force write to disk */ @@ -1339,9 +1339,9 @@ test_accum_adjust(H5F_t* f) if (accum_flush(f) < 0) FAIL_STACK_ERROR - /* write to part of the accumulator so just the start of it is dirty */ - if (accum_write(0, 5, wbuf) < 0) - FAIL_STACK_ERROR; + /* write to part of the accumulator so just the start of it is dirty */ + if (accum_write(0, 5, wbuf) < 0) + FAIL_STACK_ERROR; /* Write a small (~340KB) piece of data to the other end of the accumulator */ /* ==> Accumulator will need more buffer space */ @@ -1384,10 +1384,10 @@ test_accum_adjust(H5F_t* f) if (accum_flush(f) < 0) FAIL_STACK_ERROR - /* write to part of the accumulator so it's dirty, but not entirely dirty */ - /* (just the begging few bytes will be clean) */ - if (accum_write(10, (1024 * 1024) - 15, wbuf) < 0) - FAIL_STACK_ERROR; + /* write to part of the accumulator so it's dirty, but not entirely dirty */ + /* (just the begging few bytes will be clean) */ + if (accum_write(10, (1024 * 1024) - 15, wbuf) < 0) + FAIL_STACK_ERROR; /* Write a small piece of data to the dirty end of the accumulator */ /* ==> Accumulator will need more buffer space */ @@ -1488,18 +1488,18 @@ error: *------------------------------------------------------------------------- */ unsigned -test_read_after(H5F_t* f) +test_read_after(H5F_t *f) { int i = 0; int s = 128; /* size of buffer */ - int32_t* wbuf, * rbuf; + int32_t *wbuf, *rbuf; TESTING("reading data from both accumulator and disk"); /* Allocate buffers */ - wbuf = (int32_t*)HDmalloc((size_t)s * sizeof(int32_t)); + wbuf = (int32_t *)HDmalloc((size_t)s * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t*)HDcalloc((size_t)s, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)s, sizeof(int32_t)); HDassert(rbuf); /* Fill up write buffer with 1s */ @@ -1573,24 +1573,24 @@ error: *------------------------------------------------------------------------- */ unsigned -test_big(H5F_t* f) +test_big(H5F_t *f) { - uint8_t* wbuf, * wbuf2, * rbuf, * zbuf; /* Buffers for reading & writing, etc */ + uint8_t *wbuf, *wbuf2, *rbuf, *zbuf; /* Buffers for reading & writing, etc */ unsigned u; /* Local index variable */ /* Allocate space for the write & read buffers */ - wbuf = (uint8_t*)HDmalloc((size_t)BIG_BUF_SIZE); + wbuf = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE); HDassert(wbuf); - wbuf2 = (uint8_t*)HDmalloc((size_t)BIG_BUF_SIZE); + wbuf2 = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE); HDassert(wbuf2); - rbuf = (uint8_t*)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); + rbuf = (uint8_t *)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); HDassert(rbuf); - zbuf = (uint8_t*)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); + zbuf = (uint8_t *)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); HDassert(zbuf); /* Initialize write buffers */ for (u = 0; u < BIG_BUF_SIZE; u++) { - wbuf[u] = (uint8_t)u; + wbuf[u] = (uint8_t)u; wbuf2[u] = (uint8_t)(u + 1); } /* end for */ @@ -1938,21 +1938,21 @@ error: *------------------------------------------------------------------------- */ unsigned -test_random_write(H5F_t* f) +test_random_write(H5F_t *f) { - uint8_t* wbuf, * rbuf; /* Buffers for reading & writing */ + uint8_t *wbuf, *rbuf; /* Buffers for reading & writing */ unsigned seed = 0; /* Random # seed */ - size_t* off; /* Offset of buffer segments to write */ - size_t* len; /* Size of buffer segments to write */ + size_t * off; /* Offset of buffer segments to write */ + size_t * len; /* Size of buffer segments to write */ size_t cur_off; /* Current offset */ size_t nsegments; /* Number of segments to write */ size_t swap; /* Position to swap with */ unsigned u; /* Local index variable */ /* Allocate space for the write & read buffers */ - wbuf = (uint8_t*)HDmalloc((size_t)RANDOM_BUF_SIZE); + wbuf = (uint8_t *)HDmalloc((size_t)RANDOM_BUF_SIZE); HDassert(wbuf); - rbuf = (uint8_t*)HDcalloc((size_t)RANDOM_BUF_SIZE, (size_t)1); + rbuf = (uint8_t *)HDcalloc((size_t)RANDOM_BUF_SIZE, (size_t)1); HDassert(rbuf); /* Initialize write buffer */ @@ -1970,9 +1970,9 @@ test_random_write(H5F_t* f) HDsrandom(seed); /* Allocate space for the segment length buffer */ - off = (size_t*)HDmalloc(MAX_RANDOM_SEGMENTS * sizeof(size_t)); + off = (size_t *)HDmalloc(MAX_RANDOM_SEGMENTS * sizeof(size_t)); HDassert(off); - len = (size_t*)HDmalloc(MAX_RANDOM_SEGMENTS * sizeof(size_t)); + len = (size_t *)HDmalloc(MAX_RANDOM_SEGMENTS * sizeof(size_t)); HDassert(len); /* Randomly choose lengths of segments */ @@ -2019,11 +2019,11 @@ test_random_write(H5F_t* f) swap = nsegments - 1; /* Swap values */ - tmp = off[u]; - off[u] = off[swap]; + tmp = off[u]; + off[u] = off[swap]; off[swap] = tmp; - tmp = len[u]; - len[u] = len[swap]; + tmp = len[u]; + len[u] = len[swap]; len[swap] = tmp; } /* end for */ @@ -2094,16 +2094,16 @@ unsigned test_swmr_write_big(hbool_t newest_format) { - hid_t fid = -1; /* File ID */ + hid_t fid = -1; /* File ID */ hid_t fapl = -1; /* File access property list */ - H5F_t* rf = NULL; /* File pointer */ + H5F_t * rf = NULL; /* File pointer */ char filename[1024]; - uint8_t* wbuf2 = NULL, * rbuf = NULL; /* Buffers for reading & writing */ + uint8_t *wbuf2 = NULL, *rbuf = NULL; /* Buffers for reading & writing */ uint8_t wbuf[1024]; /* Buffer for reading & writing */ unsigned u; /* Local index variable */ hbool_t process_success = FALSE; - char* driver = NULL; /* VFD string (from env variable) */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + char * driver = NULL; /* VFD string (from env variable) */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ if (newest_format) TESTING("SWMR write of large metadata: with latest format") @@ -2112,16 +2112,16 @@ test_swmr_write_big(hbool_t newest_format) #if !defined(H5_HAVE_UNISTD_H) && !defined(H5_HAVE_WIN32_API) - /* Not a Windows or POSIX system */ - SKIPPED(); + /* Not a Windows or POSIX system */ + SKIPPED(); HDputs(" Test skipped: Not a Windows or POSIX system."); return 0; #else - /* Skip this test if SWMR I/O is not supported for the VFD specified - * by the environment variable. - */ - driver = HDgetenv("HDF5_DRIVER"); + /* Skip this test if SWMR I/O is not supported for the VFD specified + * by the environment variable. + */ + driver = HDgetenv("HDF5_DRIVER"); if (!H5FD__supports_swmr_test(driver)) { SKIPPED(); HDputs(" Test skipped due to VFD not supporting SWMR I/O."); @@ -2131,15 +2131,15 @@ test_swmr_write_big(hbool_t newest_format) /* File access property list */ if ((fapl = h5_fileaccess()) < 0) FAIL_STACK_ERROR - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); + h5_fixname(FILENAME[1], fapl, filename, sizeof filename); /* Both cases will result in v3 superblock and version 2 object header for SWMR */ if (newest_format) { /* latest format */ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR - if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR } else { /* non-latest-format */ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) @@ -2150,35 +2150,35 @@ test_swmr_write_big(hbool_t newest_format) if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - /* Open the file with SWMR_WRITE */ - if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) - FAIL_STACK_ERROR + /* Open the file with SWMR_WRITE */ + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) + FAIL_STACK_ERROR - /* Push API context */ - if (H5CX_push() < 0) - FAIL_STACK_ERROR - api_ctx_pushed = TRUE; + /* Push API context */ + if (H5CX_push() < 0) + FAIL_STACK_ERROR + api_ctx_pushed = TRUE; /* Get H5F_t * to internal file structure */ - if (NULL == (rf = (H5F_t*)H5VL_object(fid))) + if (NULL == (rf = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR - /* We'll be writing lots of garbage data, so extend the - file a ways. 10MB should do. */ - if (H5FD_set_eoa(rf->shared->lf, H5FD_MEM_DEFAULT, (haddr_t)(1024 * 1024 * 10)) < 0) - FAIL_STACK_ERROR + /* We'll be writing lots of garbage data, so extend the + file a ways. 10MB should do. */ + if (H5FD_set_eoa(rf->shared->lf, H5FD_MEM_DEFAULT, (haddr_t)(1024 * 1024 * 10)) < 0) + FAIL_STACK_ERROR - if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) - FAIL_STACK_ERROR; + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + FAIL_STACK_ERROR; /* Reset metadata accumulator for the file */ if (accum_reset(rf) < 0) FAIL_STACK_ERROR; /* Allocate space for the write & read buffers */ - if ((wbuf2 = (uint8_t*)HDmalloc((size_t)BIG_BUF_SIZE)) == NULL) + if ((wbuf2 = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE)) == NULL) FAIL_STACK_ERROR; - if ((rbuf = (uint8_t*)HDmalloc((size_t)BIG_BUF_SIZE)) == NULL) + if ((rbuf = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE)) == NULL) FAIL_STACK_ERROR; /* Initialize wbuf with "0, 1, 2...1024"*/ @@ -2269,7 +2269,7 @@ test_swmr_write_big(hbool_t newest_format) * NULL at argv[0], so we follow the convention unconditionally. */ char swmr_reader[] = SWMR_READER; - char* const new_argv[] = { swmr_reader, NULL }; + char *const new_argv[] = {swmr_reader, NULL}; /* Run the reader */ status = HDexecv(SWMR_READER, new_argv); HDprintf("errno from execv = %s\n", HDstrerror(errno)); @@ -2290,9 +2290,9 @@ test_swmr_write_big(hbool_t newest_format) if (!process_success) FAIL_PUTS_ERROR("child process exited abnormally") - /* Flush the accumulator */ - if (accum_reset(rf) < 0) - FAIL_STACK_ERROR; + /* Flush the accumulator */ + if (accum_reset(rf) < 0) + FAIL_STACK_ERROR; /* Close and remove the file */ if (H5Fclose(fid) < 0) @@ -2305,7 +2305,7 @@ test_swmr_write_big(hbool_t newest_format) /* Pop API context */ if (api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR - api_ctx_pushed = FALSE; + api_ctx_pushed = FALSE; /* Release memory */ if (wbuf2) @@ -2351,9 +2351,9 @@ error: *------------------------------------------------------------------------- */ void -accum_printf(const H5F_t* f) +accum_printf(const H5F_t *f) { - H5F_meta_accum_t* accum = &f->shared->accum; + H5F_meta_accum_t *accum = &f->shared->accum; HDprintf("\n"); HDprintf("Current contents of accumulator:\n"); @@ -2371,14 +2371,14 @@ accum_printf(const H5F_t* f) HDfprintf(stdout, " start of accumulated data, loc = %" PRIuHADDR "\n", accum->loc); if (accum->dirty) { HDfprintf(stdout, " start of dirty region, loc = %" PRIuHADDR "\n", - (haddr_t)(accum->loc + accum->dirty_off)); + (haddr_t)(accum->loc + accum->dirty_off)); HDfprintf(stdout, " end of dirty region, loc = %" PRIuHADDR "\n", - (haddr_t)(accum->loc + accum->dirty_off + accum->dirty_len)); + (haddr_t)(accum->loc + accum->dirty_off + accum->dirty_len)); } /* end if */ HDfprintf(stdout, " end of accumulated data, loc = %" PRIuHADDR "\n", - (haddr_t)(accum->loc + accum->size)); + (haddr_t)(accum->loc + accum->size)); HDfprintf(stdout, " end of accumulator allocation, loc = %" PRIuHADDR "\n", - (haddr_t)(accum->loc + accum->alloc_size)); + (haddr_t)(accum->loc + accum->alloc_size)); HDprintf("=====================================================\n"); } HDprintf("\n\n"); diff --git a/test/accum_swmr_reader.c b/test/accum_swmr_reader.c index c3be09a..1d48d43 100644 --- a/test/accum_swmr_reader.c +++ b/test/accum_swmr_reader.c @@ -11,26 +11,20 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "h5test.h" -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING #include "H5Fpkg.h" #include "H5FDpkg.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Iprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Filename: this is the same as the define in accum.c used by test_swmr_write_big() */ -const char *FILENAME[] = { - "accum", - "accum_swmr_big", - NULL -}; +const char *FILENAME[] = {"accum", "accum_swmr_big", NULL}; - - /*------------------------------------------------------------------------- * Function: main * @@ -49,73 +43,77 @@ const char *FILENAME[] = { int main(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* file access property list ID */ - H5F_t *f = NULL; /* File pointer */ - char filename[1024]; - unsigned u; /* Local index variable */ - uint8_t rbuf[1024]; /* Buffer for reading */ - uint8_t buf[1024]; /* Buffer for holding the expected data */ - char *driver = NULL; /* VFD string (from env variable) */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* file access property list ID */ + H5F_t * f = NULL; /* File pointer */ + char filename[1024]; + unsigned u; /* Local index variable */ + uint8_t rbuf[1024]; /* Buffer for reading */ + uint8_t buf[1024]; /* Buffer for holding the expected data */ + char * driver = NULL; /* VFD string (from env variable) */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Skip this test if SWMR I/O is not supported for the VFD specified * by the environment variable. */ driver = HDgetenv("HDF5_DRIVER"); - if(!H5FD__supports_swmr_test(driver)) + if (!H5FD__supports_swmr_test(driver)) return EXIT_SUCCESS; /* Initialize buffers */ - for(u = 0; u < 1024; u++) { - rbuf[u] = 0; /* The buffer for reading */ - buf[u] = 1; /* The expected data should be all 1s */ + for (u = 0; u < 1024; u++) { + rbuf[u] = 0; /* The buffer for reading */ + buf[u] = 1; /* The expected data should be all 1s */ } - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) FAIL_STACK_ERROR h5_fixname(FILENAME[1], fapl, filename, sizeof filename); /* Open the file with SWMR_READ */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Get H5F_t * to internal file structure */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR /* Should read in [1024, 2024] with buf data */ - if(H5F_block_read(f, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, rbuf) < 0) + if (H5F_block_read(f, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data read is correct */ - if(HDmemcmp(buf, rbuf, (size_t)1024) != 0) + if (HDmemcmp(buf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* CLose the file */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); return EXIT_FAILURE; } /* end main() */ - diff --git a/test/app_ref.c b/test/app_ref.c index a4853fa..275f60b 100644 --- a/test/app_ref.c +++ b/test/app_ref.c @@ -20,22 +20,22 @@ */ #include "h5test.h" -#define APPREF_DSET "test_dset" -#define APPREF_ATTR "test_attr" +#define APPREF_DSET "test_dset" +#define APPREF_ATTR "test_attr" #define APPREF_GROUP "test_grp" -#define ERR_WIDTH 40 /* Width of output for the SIGABRT handler */ -#define MAX_NINC 16 /* Maximum increments of a reference count */ +#define ERR_WIDTH 40 /* Width of output for the SIGABRT handler */ +#define MAX_NINC 16 /* Maximum increments of a reference count */ /* Macro to increment the reference count on id a random number of times (from * 1 to MAX_NINC). Assumes integers i and ninc are in scope. */ -#define RAND_INC(id) \ - ninc = (HDrand() % MAX_NINC) + 1; \ - \ - for (i=0; i 1"); + TESTING("library shutdown with reference count > 1"); /* Create the file */ - if ((ids[T_FILE] = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT)) < 0) + if ((ids[T_FILE] = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - RAND_INC (T_FILE) + RAND_INC(T_FILE) /* Create the property list */ if ((ids[T_PLIST] = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - RAND_INC (T_PLIST) + RAND_INC(T_PLIST) /* Create a property class */ - if ((ids[T_PCLASS] = H5Pcreate_class (H5P_DATASET_CREATE, "foo", NULL, NULL, - NULL, NULL, NULL, NULL)) < 0) + if ((ids[T_PCLASS] = H5Pcreate_class(H5P_DATASET_CREATE, "foo", NULL, NULL, NULL, NULL, NULL, NULL)) < 0) TEST_ERROR - RAND_INC (T_PCLASS) + RAND_INC(T_PCLASS) /* Create a datatype */ - if ((ids[T_TYPE] = H5Tcreate (H5T_OPAQUE, (size_t) 16)) < 0) + if ((ids[T_TYPE] = H5Tcreate(H5T_OPAQUE, (size_t)16)) < 0) TEST_ERROR - RAND_INC (T_TYPE) + RAND_INC(T_TYPE) /* Create a dataspace */ - if ((ids[T_SPACE] = H5Screate (H5S_SCALAR)) < 0) + if ((ids[T_SPACE] = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR - RAND_INC (T_SPACE) + RAND_INC(T_SPACE) /* Create a dataset */ - if ((ids[T_DSET] = H5Dcreate2 (ids[T_FILE], APPREF_DSET, H5T_NATIVE_INT, - ids[T_SPACE], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((ids[T_DSET] = H5Dcreate2(ids[T_FILE], APPREF_DSET, H5T_NATIVE_INT, ids[T_SPACE], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - RAND_INC (T_DSET) + RAND_INC(T_DSET) /* Create an attribute */ - if ((ids[T_ATTR] = H5Acreate2 (ids[T_DSET], APPREF_ATTR, H5T_NATIVE_INT, - ids[T_SPACE], H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((ids[T_ATTR] = H5Acreate2(ids[T_DSET], APPREF_ATTR, H5T_NATIVE_INT, ids[T_SPACE], H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - RAND_INC (T_ATTR) + RAND_INC(T_ATTR) /* Create a group */ - if ((ids[T_GROUP] = H5Gcreate2 (ids[T_FILE], APPREF_GROUP, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((ids[T_GROUP] = H5Gcreate2(ids[T_FILE], APPREF_GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - RAND_INC (T_GROUP) + RAND_INC(T_GROUP) /* Create an error class */ - if ((ids[T_ECLASS] = H5Eregister_class("foo","bar","baz")) < 0) + if ((ids[T_ECLASS] = H5Eregister_class("foo", "bar", "baz")) < 0) TEST_ERROR - RAND_INC (T_ECLASS) + RAND_INC(T_ECLASS) /* Create an error message */ - if ((ids[T_EMSG] = H5Ecreate_msg(ids[T_ECLASS],H5E_MAJOR,"mumble")) < 0) + if ((ids[T_EMSG] = H5Ecreate_msg(ids[T_ECLASS], H5E_MAJOR, "mumble")) < 0) TEST_ERROR - RAND_INC (T_EMSG) + RAND_INC(T_EMSG) /* Create an error stack */ if ((ids[T_ESTACK] = H5Eget_current_stack()) < 0) TEST_ERROR - RAND_INC (T_ESTACK) + RAND_INC(T_ESTACK) - HDsignal (SIGABRT, &Abrt_Handler); + HDsignal(SIGABRT, &Abrt_Handler); if (H5close() < 0) TEST_ERROR @@ -188,8 +172,8 @@ main (void) /* Clean up any file(s) created */ h5_reset(); - fapl = H5Pcreate (H5P_FILE_ACCESS); - h5_cleanup (FILENAME, fapl); + fapl = H5Pcreate(H5P_FILE_ACCESS); + h5_cleanup(FILENAME, fapl); return 0; diff --git a/test/atomic_reader.c b/test/atomic_reader.c index 5c1241f..d849631 100644 --- a/test/atomic_reader.c +++ b/test/atomic_reader.c @@ -42,7 +42,7 @@ /* Local Macros */ /****************/ -#define FILENAME "atomic_data" +#define FILENAME "atomic_data" #define READ_TRIES 20 #define OPEN_TRIES 50 @@ -51,10 +51,8 @@ /********************/ static void usage(void); -int verify(int fd, unsigned int k); -void print_info(int *info, unsigned int lastr, unsigned iteration); - - +int verify(int fd, unsigned int k); +void print_info(int *info, unsigned int lastr, unsigned iteration); /*------------------------------------------------------------------------- * Function: usage @@ -78,7 +76,6 @@ usage(void) printf("\n"); } /* usage() */ - /*------------------------------------------------------------------------- * Function: verify * @@ -106,66 +103,64 @@ usage(void) int verify(int fd, unsigned int k) { - unsigned int i; /* local index variable */ - ssize_t bytes_read; /* the number of bytes read */ - unsigned int *buf = NULL; /* buffer to hold data read */ + unsigned int i; /* local index variable */ + ssize_t bytes_read; /* the number of bytes read */ + unsigned int *buf = NULL; /* buffer to hold data read */ /* Allocate buffer for data read */ - if((buf = (unsigned int *)malloc(k * sizeof(unsigned int))) == NULL) { + if ((buf = (unsigned int *)malloc(k * sizeof(unsigned int))) == NULL) { printf("READER: error from malloc\n"); goto error; } /* end if */ /* Position the file at the beginning */ - if(lseek(fd, (off_t)0, SEEK_SET) < 0) { + if (lseek(fd, (off_t)0, SEEK_SET) < 0) { printf("READER: error from lseek\n"); goto error; } /* end if */ /* Read the whole file */ - if((bytes_read = read(fd, buf, (k * sizeof(unsigned int)))) < 0) { + if ((bytes_read = read(fd, buf, (k * sizeof(unsigned int)))) < 0) { printf("READER: error from read\n"); goto error; } /* end if */ /* Verify the bytes read are correct */ - if(bytes_read != (ssize_t)(k*sizeof(unsigned int))) { + if (bytes_read != (ssize_t)(k * sizeof(unsigned int))) { printf("READER: error from bytes read=%lu\n", (unsigned long)bytes_read); goto error; } /* end if */ /* Verify data read */ - for(i=0; i < k; i++) { - if(buf[i] != i) + for (i = 0; i < k; i++) { + if (buf[i] != i) break; } /* end for */ - if(i < k) { + if (i < k) { /* Compare the beginning and ending sentinel values */ - if(buf[k-1] != (i-1)) { - printf("FAIL IN READER: ...beginning sentinel value=%u, i=%u\n", (i-1), i); - printf("FAIL IN READER: buf[%u]=%u\n", i-1, buf[i-1]); + if (buf[k - 1] != (i - 1)) { + printf("FAIL IN READER: ...beginning sentinel value=%u, i=%u\n", (i - 1), i); + printf("FAIL IN READER: buf[%u]=%u\n", i - 1, buf[i - 1]); printf("FAIL IN READER: buf[%u]=%u\n", i, buf[i]); - printf("FAIL IN READER: buf[%u]=%u\n", i+1, buf[i+1]); - printf("FAIL IN READER: ...ending sentinel value=%u\n", buf[k-1]); + printf("FAIL IN READER: buf[%u]=%u\n", i + 1, buf[i + 1]); + printf("FAIL IN READER: ...ending sentinel value=%u\n", buf[k - 1]); goto error; } /* end if */ - } /* end if */ + } /* end if */ /* Free the buffer */ - if(buf) + if (buf) free(buf); return 0; error: /* Free the buffer */ - if(buf) + if (buf) free(buf); return -1; } /* end verify() */ - - /*------------------------------------------------------------------------- * Function: print_info * @@ -183,17 +178,16 @@ error: void print_info(int *info, unsigned int lastr, unsigned iteration) { - unsigned j; /* local index variable */ + unsigned j; /* local index variable */ printf("--------statistics for %u reads (iteration %u)--------\n", lastr, iteration); - for(j = 0; j <= READ_TRIES; j++) + for (j = 0; j <= READ_TRIES; j++) printf("# of %u re-tries = %u\n", j, info[j]); printf("--------end statistics for %u reads (iteration %u)--------\n", lastr, iteration); } /* print_info() */ - /*------------------------------------------------------------------------- * Function: main * @@ -222,32 +216,32 @@ print_info(int *info, unsigned int lastr, unsigned iteration) int main(int argc, char *argv[]) { - int fd = -1; /* file descriptor */ - unsigned int j=0, i=0, m=0; /* local index variables */ - int temp; /* temporary variable */ - unsigned int iterations = 0; /* the input for "-i" */ - unsigned num = 0; /* the input for "-n" */ - int opt = 0; /* option char */ - int info[READ_TRIES+1]; /* re-tries statistics */ + int fd = -1; /* file descriptor */ + unsigned int j = 0, i = 0, m = 0; /* local index variables */ + int temp; /* temporary variable */ + unsigned int iterations = 0; /* the input for "-i" */ + unsigned num = 0; /* the input for "-n" */ + int opt = 0; /* option char */ + int info[READ_TRIES + 1]; /* re-tries statistics */ /* Ensure the expected # of arguments */ - if(argc != 5) { + if (argc != 5) { usage(); exit(EXIT_FAILURE); } /* end if */ /* Parse command line options */ - while((opt = getopt(argc, argv, "n:i:")) != -1) { - switch(opt) { + while ((opt = getopt(argc, argv, "n:i:")) != -1) { + switch (opt) { case 'n': - if((temp = atoi(optarg)) < 0) { + if ((temp = atoi(optarg)) < 0) { usage(); exit(EXIT_FAILURE); } /* end if */ num = (unsigned int)temp; break; case 'i': - if((temp = atoi(optarg)) < 0) { + if ((temp = atoi(optarg)) < 0) { usage(); exit(EXIT_FAILURE); } /* end if */ @@ -257,35 +251,36 @@ main(int argc, char *argv[]) printf("Invalid option encountered\n"); break; } /* end switch */ - } /* end while */ + } /* end while */ printf("READER: number of integers to read = %u; # of iterations = %d\n", num, iterations); printf("\n"); - for(i = 1; i <= iterations; i++) { + for (i = 1; i <= iterations; i++) { unsigned opens = OPEN_TRIES; printf("READER: *****start iteration %u*****\n", i); /* Ensure open and file size are done properly */ - while(opens--) { + while (opens--) { struct stat sinfo; memset(&sinfo, 0, sizeof(sinfo)); - if((fd = open(FILENAME, O_RDONLY, 0644)) < 0) { + if ((fd = open(FILENAME, O_RDONLY, 0644)) < 0) { printf("READER: error from open--retry open again\n"); - } else { + } + else { printf("READER: open succeed\n"); - if((fstat(fd, &sinfo) == 0) && - (sinfo.st_size == (off_t)(num * sizeof(unsigned int)))) { + if ((fstat(fd, &sinfo) == 0) && (sinfo.st_size == (off_t)(num * sizeof(unsigned int)))) { printf("READER: file size is correct--%u\n", (unsigned int)sinfo.st_size); break; } /* end if */ - printf("READER: error from fstat or file size of %u is incorrect--retry open again\n", (unsigned int)sinfo.st_size); - if(close(fd) < 0) { + printf("READER: error from fstat or file size of %u is incorrect--retry open again\n", + (unsigned int)sinfo.st_size); + if (close(fd) < 0) { printf("READER: error from close\n"); return EXIT_FAILURE; } /* end if */ @@ -294,38 +289,41 @@ main(int argc, char *argv[]) } /* end while */ - if(fd < 0) { - printf("READER: *****open failure/incorrect file size for all %u tries, continue next iteration*****\n\n", OPEN_TRIES); + if (fd < 0) { + printf("READER: *****open failure/incorrect file size for all %u tries, continue next " + "iteration*****\n\n", + OPEN_TRIES); continue; } /* end if */ memset(info, 0, sizeof(info)); /* Read and verify data */ - for(j = 1; j <= num; j++) { + for (j = 1; j <= num; j++) { printf("READER: doing read %u\n", j); - if(verify(fd, num) < 0) { + if (verify(fd, num) < 0) { printf("READER: error from read %u\n", j); /* Perform re-read to see if correct data is obtained */ - for(m = 1; m <= READ_TRIES; m++) { + for (m = 1; m <= READ_TRIES; m++) { printf("READER: ===============going to do re-read try %u\n", m); - if(verify(fd, num) < 0) + if (verify(fd, num) < 0) printf("READER: ===============error from re-read try %u\n", m); else { ++info[m]; printf("READER: ===============SUCCESS from re-read try %u\n", m); break; } /* end else */ - } /* end for */ + } /* end for */ - if(m > READ_TRIES) { + if (m > READ_TRIES) { printf("READER: ===============error from all re-read tries: %u\n", READ_TRIES); printf("READER:*****ERROR--stop on read %u\n", j); break; } /* end if */ - } else { + } + else { ++info[0]; printf("READER: success from read %u\n", j); } /* end else */ @@ -333,10 +331,10 @@ main(int argc, char *argv[]) } /* end for */ /* Print the statistics for re-reads */ - print_info(info, j-1, i); + print_info(info, j - 1, i); /* Close the file */ - if(close(fd) < 0) { + if (close(fd) < 0) { printf("READER: error from close\n"); return EXIT_FAILURE; } /* end if */ @@ -358,4 +356,3 @@ main(void) } /* end main() */ #endif /* WIN32 / MINGW32 */ - diff --git a/test/atomic_writer.c b/test/atomic_writer.c index b9ea03a..0f86f7b 100644 --- a/test/atomic_writer.c +++ b/test/atomic_writer.c @@ -53,7 +53,6 @@ static void usage(void); - /*------------------------------------------------------------------------- * Function: usage * @@ -76,8 +75,6 @@ usage(void) printf("\n"); } /* usage() */ - - /*------------------------------------------------------------------------- * Function: main * @@ -114,33 +111,33 @@ usage(void) int main(int argc, char *argv[]) { - int fd = -1; /* file descriptor */ - ssize_t bytes_wrote; /* the nubmer of bytes written */ - unsigned int *buf = NULL; /* buffer to hold written data */ - unsigned int n, u, i; /* local index variable */ - int temp; /* temporary variable */ - unsigned int iterations = 0; /* the input for "-i" */ - unsigned int num = 0; /* the input for "-n" */ - int opt = 0; /* option char */ + int fd = -1; /* file descriptor */ + ssize_t bytes_wrote; /* the nubmer of bytes written */ + unsigned int *buf = NULL; /* buffer to hold written data */ + unsigned int n, u, i; /* local index variable */ + int temp; /* temporary variable */ + unsigned int iterations = 0; /* the input for "-i" */ + unsigned int num = 0; /* the input for "-n" */ + int opt = 0; /* option char */ /* Ensure the # of arguments is as expected */ - if(argc != 5) { + if (argc != 5) { usage(); exit(EXIT_FAILURE); } /* end if */ /* Parse command line options */ - while((opt = getopt(argc, argv, "n:i:")) != -1) { - switch(opt) { + while ((opt = getopt(argc, argv, "n:i:")) != -1) { + switch (opt) { case 'n': - if((temp = atoi(optarg)) < 0) { + if ((temp = atoi(optarg)) < 0) { usage(); exit(EXIT_FAILURE); } /* end if */ num = (unsigned int)temp; break; case 'i': - if((temp = atoi(optarg)) < 0) { + if ((temp = atoi(optarg)) < 0) { usage(); exit(EXIT_FAILURE); } /* end if */ @@ -150,78 +147,79 @@ main(int argc, char *argv[]) printf("Invalid option encountered\n"); break; } /* end switch */ - } /* end while */ + } /* end while */ printf("WRITER: # of integers to write = %u; # of iterations = %d\n", num, iterations); /* Remove existing data file if needed */ - if(remove(FILENAME) < 0) { - if(errno == ENOENT) + if (remove(FILENAME) < 0) { + if (errno == ENOENT) printf("WRITER: remove %s--%s\n", FILENAME, strerror(errno)); else { printf("WRITER: error from remove: %d--%s\n", errno, strerror(errno)); goto error; } /* end else */ - } else + } + else printf("WRITER: %s is removed\n", FILENAME); /* Create the data file */ - if((fd = open(FILENAME, O_RDWR|O_TRUNC|O_CREAT, 0664)) < 0) { + if ((fd = open(FILENAME, O_RDWR | O_TRUNC | O_CREAT, 0664)) < 0) { printf("WRITER: error from open\n"); goto error; } /* end if */ /* Allocate buffer for holding data to be written */ - if((buf = (unsigned int *)malloc(num * sizeof(unsigned int))) == NULL) { + if ((buf = (unsigned int *)malloc(num * sizeof(unsigned int))) == NULL) { printf("WRITER: error from malloc\n"); - if(fd >= 0 && close(fd) < 0) + if (fd >= 0 && close(fd) < 0) printf("WRITER: error from close\n"); goto error; } /* end if */ printf("\n"); - for(i = 1; i <= iterations; i++) { + for (i = 1; i <= iterations; i++) { printf("WRITER: *****start iteration %u*****\n", i); /* Write the series of integers to the file */ - for(n = 0; n < num; n++) { + for (n = 0; n < num; n++) { /* Set up data to be written */ - for(u=0; u < num; u++) + for (u = 0; u < num; u++) buf[u] = n; /* Position the file to the proper location */ - if(lseek(fd, (off_t)(n*sizeof(unsigned int)), SEEK_SET) < 0) { + if (lseek(fd, (off_t)(n * sizeof(unsigned int)), SEEK_SET) < 0) { printf("WRITER: error from lseek\n"); goto error; } /* end if */ /* Write the data */ - if((bytes_wrote = write(fd, buf, ((num-n) * sizeof(unsigned int)))) < 0) { + if ((bytes_wrote = write(fd, buf, ((num - n) * sizeof(unsigned int)))) < 0) { printf("WRITER: error from write\n"); goto error; } /* end if */ /* Verify the bytes written is correct */ - if(bytes_wrote != (ssize_t)((num-n) * sizeof(unsigned int))) { + if (bytes_wrote != (ssize_t)((num - n) * sizeof(unsigned int))) { printf("WRITER: error from bytes written\n"); goto error; } /* end if */ - } /* end for */ + } /* end for */ printf("WRITER: *****end iteration %u*****\n\n", i); } /* end for */ /* Close the file */ - if(close(fd) < 0) { + if (close(fd) < 0) { printf("WRITER: error from close\n"); goto error; } /* end if */ /* Free the buffer */ - if(buf) + if (buf) free(buf); return EXIT_SUCCESS; @@ -240,4 +238,3 @@ main(void) } /* end main() */ #endif /* WIN32 / MINGW32 */ - diff --git a/test/big.c b/test/big.c index a2f07af..33b61ea 100644 --- a/test/big.c +++ b/test/big.c @@ -12,10 +12,10 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, April 8, 1998 - * Modified: Albert Cheng - * September 11, 2010 + * Modified: Albert Cheng + * September 11, 2010 */ /* * The purpose of this test is to verify if a virtual file driver can handle: @@ -53,50 +53,45 @@ */ #include "h5test.h" -#define DNAME "big.data" +#define DNAME "big.data" -#define WRT_N 50 -#define WRT_SIZE 4*1024 -#define FAMILY_SIZE 1024*1024*1024 +#define WRT_N 50 +#define WRT_SIZE 4 * 1024 +#define FAMILY_SIZE 1024 * 1024 * 1024 #define GB (HDoff_t)0x40000000L -#define MAX_TRIES 100 +#define MAX_TRIES 100 #if H5_SIZEOF_LONG_LONG >= 8 -# define GB8LL ((unsigned long long)8*1024*1024*1024) +#define GB8LL ((unsigned long long)8 * 1024 * 1024 * 1024) #else -# define GB8LL 0 /*cannot do the test*/ +#define GB8LL 0 /*cannot do the test*/ #endif /* Define Small, Large, Extra Large, Huge File which * corrspond to less than 2GB, 2GB, 4GB, and tens of GB file size. * NO_FILE stands for "no file" to be tested. */ -typedef enum fsizes_t { SFILE, LFILE, XLFILE, HUGEFILE, NO_FILE} fsizes_t; -fsizes_t file_size= NO_FILE; - -const char *FILENAME[] = { - "big", - "sec2", - "stdio", - NULL -}; -int cflag=1; /* check file system before test */ -int sparse_support=0; /* sparse file supported, default false */ -int have_space=0; /* enough space for huge file test, default false */ -hsize_t family_size_def=FAMILY_SIZE; /* default family file size */ +typedef enum fsizes_t { SFILE, LFILE, XLFILE, HUGEFILE, NO_FILE } fsizes_t; +fsizes_t file_size = NO_FILE; + +const char *FILENAME[] = {"big", "sec2", "stdio", NULL}; +int cflag = 1; /* check file system before test */ +int sparse_support = 0; /* sparse file supported, default false */ +int have_space = 0; /* enough space for huge file test, default false */ +hsize_t family_size_def = FAMILY_SIZE; /* default family file size */ /* Prototypes */ static void usage(void); -static int test_sec2(hid_t fapl); -static int test_stdio(hid_t fapl); -static int test_family(hid_t fapl); +static int test_sec2(hid_t fapl); +static int test_stdio(hid_t fapl); +static int test_family(hid_t fapl); /* Array used to record all addresses at which data has been written */ /* so far. Used to prevent overlapping writes. */ static hsize_t values_used[WRT_N]; - + /*------------------------------------------------------------------------- * Function: randll * @@ -118,36 +113,33 @@ static hsize_t values_used[WRT_N]; static hsize_t randll(hsize_t limit, int current_index) { - hsize_t acc = 0; - int overlap = 1; - int i; - int tries = 0; + hsize_t acc = 0; + int overlap = 1; + int i; + int tries = 0; /* Generate up to MAX_TRIES random numbers until one of them */ /* does not overlap with any previous writes */ - while(overlap != 0 && tries < MAX_TRIES) - { + while (overlap != 0 && tries < MAX_TRIES) { acc = (hsize_t)HDrandom(); acc *= (hsize_t)HDrandom(); - acc = acc % limit; + acc = acc % limit; overlap = 0; - for(i = 0; i < current_index; i++) - { - if((acc >= values_used[i]) && (acc < values_used[i]+WRT_SIZE)) + for (i = 0; i < current_index; i++) { + if ((acc >= values_used[i]) && (acc < values_used[i] + WRT_SIZE)) overlap = 1; - if((acc+WRT_SIZE >= values_used[i]) && (acc+WRT_SIZE < values_used[i]+WRT_SIZE)) + if ((acc + WRT_SIZE >= values_used[i]) && (acc + WRT_SIZE < values_used[i] + WRT_SIZE)) overlap = 1; } tries++; } - values_used[current_index]=acc; + values_used[current_index] = acc; return acc; } - /*------------------------------------------------------------------------- * Function: is_sparse * @@ -169,23 +161,28 @@ randll(hsize_t limit, int current_index) static int is_sparse(void) { - int fd; - h5_stat_t sb; - - if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; - if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; - if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; - if (HDclose(fd) < 0) return 0; - if (HDstat("x.h5", &sb) < 0) return 0; - if (HDremove("x.h5") < 0) return 0; + int fd; + h5_stat_t sb; + + if ((fd = HDopen("x.h5", O_RDWR | O_TRUNC | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) + return 0; + if (HDlseek(fd, (off_t)(1024 * 1024), SEEK_SET) != 1024 * 1024) + return 0; + if (5 != HDwrite(fd, "hello", (size_t)5)) + return 0; + if (HDclose(fd) < 0) + return 0; + if (HDstat("x.h5", &sb) < 0) + return 0; + if (HDremove("x.h5") < 0) + return 0; #ifdef H5_HAVE_STAT_ST_BLOCKS - return ((unsigned long)sb.st_blocks*512 < (unsigned long)sb.st_size); + return ((unsigned long)sb.st_blocks * 512 < (unsigned long)sb.st_size); #else return (0); #endif } - /*------------------------------------------------------------------------- * Function: supports_big * @@ -207,56 +204,55 @@ is_sparse(void) static fsizes_t supports_big(void) { - int fd = -1; - fsizes_t fsize = NO_FILE; + int fd = -1; + fsizes_t fsize = NO_FILE; - if((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd = HDopen("y.h5", O_RDWR | O_TRUNC | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write a few byte at the beginning */ - if(5!=HDwrite(fd, "hello", (size_t)5)) + if (5 != HDwrite(fd, "hello", (size_t)5)) goto quit; fsize = SFILE; /* Write a few bytes at 2GB */ - if(HDlseek(fd, 2*GB, SEEK_SET)!=2*GB) + if (HDlseek(fd, 2 * GB, SEEK_SET) != 2 * GB) goto quit; - if(5!=HDwrite(fd, "hello", (size_t)5)) + if (5 != HDwrite(fd, "hello", (size_t)5)) goto quit; fsize = LFILE; /* Write a few bytes at 4GB */ - if(HDlseek(fd, 4*GB, SEEK_SET) != 4*GB) + if (HDlseek(fd, 4 * GB, SEEK_SET) != 4 * GB) goto quit; - if(5!=HDwrite(fd, "hello", (size_t)5)) + if (5 != HDwrite(fd, "hello", (size_t)5)) goto quit; fsize = XLFILE; /* If this supports sparse_file, write a few bytes at 32GB */ - if(!sparse_support) + if (!sparse_support) goto quit; - if(HDlseek(fd, 32*GB, SEEK_SET) != 32*GB) + if (HDlseek(fd, 32 * GB, SEEK_SET) != 32 * GB) goto quit; - if(5!=HDwrite(fd, "hello", (size_t)5)) + if (5 != HDwrite(fd, "hello", (size_t)5)) goto quit; fsize = HUGEFILE; quit: - if(HDclose(fd) < 0) + if (HDclose(fd) < 0) goto error; - if(HDremove("y.h5") < 0) + if (HDremove("y.h5") < 0) goto error; return fsize; error: - if(fd >= 0){ + if (fd >= 0) { HDclose(fd); HDremove("y.h5"); } return fsize; } - /*------------------------------------------------------------------------- * Function: enough_room * @@ -281,50 +277,50 @@ error: * 'name' in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static int enough_room(hid_t fapl) { - int ret_value=0; - int fd[68]; - size_t i, size = (size_t)1 << 30; - char filename[1024], name[1024]; + int ret_value = 0; + int fd[68]; + size_t i, size = (size_t)1 << 30; + char filename[1024], name[1024]; /* Initialize file descriptors */ - for (i=0; i=0; i++) { + for (i = 0; i < NELMTS(fd) && fd[i] >= 0; i++) { HDsnprintf(name, sizeof(name), filename, i); - if(HDclose(fd[i]) < 0) - ret_value=0; + if (HDclose(fd[i]) < 0) + ret_value = 0; HDremove(name); } return ret_value; } -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - /*------------------------------------------------------------------------- * Function: writer * @@ -344,68 +340,68 @@ H5_GCC_DIAG_ON(format-nonliteral) *------------------------------------------------------------------------- */ static int -writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) +writer(char *filename, hid_t fapl, fsizes_t testsize, int wrt_n) { - hsize_t size1[4] = {8, 1024, 1024, 1024}; - hsize_t size2[1] = {GB8LL}; - hsize_t hs_start[1]; - hsize_t hs_size[1]; - hid_t file=-1, space1=-1, space2=-1, mem_space=-1, d1=-1, d2=-1; - int *buf = (int*)HDmalloc (sizeof(int) * WRT_SIZE); - int i, j; - FILE *out = HDfopen(DNAME, "w"); - hid_t dcpl; - - switch(testsize){ - case LFILE: - TESTING("Large dataset write(2GB)"); - /* reduce size1 to produce a 2GB dataset */ - size1[1] = 1024/16; - size2[0] /= 16; - break; - - case XLFILE: - TESTING("Extra large dataset write(4GB)"); - /* reduce size1 to produce a 4GB dataset */ - size1[1] = 1024/8; - size2[0] /= 8; - break; - - case HUGEFILE: - TESTING("Huge dataset write"); - /* Leave size1 as 32GB */ - break; - - case SFILE: - TESTING("small dataset write(1GB)"); - /* reduce size1 to produce a 1GB dataset */ - size1[1] = 1024/32; - size2[0] /= 32; - break; - - case NO_FILE: - /* what to do?? */ - HDfprintf(stdout, "Unexpected file size of NO_FILE\n"); - goto error; - break; + hsize_t size1[4] = {8, 1024, 1024, 1024}; + hsize_t size2[1] = {GB8LL}; + hsize_t hs_start[1]; + hsize_t hs_size[1]; + hid_t file = -1, space1 = -1, space2 = -1, mem_space = -1, d1 = -1, d2 = -1; + int * buf = (int *)HDmalloc(sizeof(int) * WRT_SIZE); + int i, j; + FILE * out = HDfopen(DNAME, "w"); + hid_t dcpl; + + switch (testsize) { + case LFILE: + TESTING("Large dataset write(2GB)"); + /* reduce size1 to produce a 2GB dataset */ + size1[1] = 1024 / 16; + size2[0] /= 16; + break; - default: - HDfprintf(stdout, "Unexpected file size(%d)\n", testsize); - goto error; - break; + case XLFILE: + TESTING("Extra large dataset write(4GB)"); + /* reduce size1 to produce a 4GB dataset */ + size1[1] = 1024 / 8; + size2[0] /= 8; + break; + + case HUGEFILE: + TESTING("Huge dataset write"); + /* Leave size1 as 32GB */ + break; + + case SFILE: + TESTING("small dataset write(1GB)"); + /* reduce size1 to produce a 1GB dataset */ + size1[1] = 1024 / 32; + size2[0] /= 32; + break; + + case NO_FILE: + /* what to do?? */ + HDfprintf(stdout, "Unexpected file size of NO_FILE\n"); + goto error; + break; + + default: + HDfprintf(stdout, "Unexpected file size(%d)\n", testsize); + goto error; + break; } /* * We might be on a machine that has 32-bit files, so create an HDF5 file * which is a family of files. Each member of the family will be 1GB */ - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { goto error; } /* Create simple data spaces according to the size specified above. */ - if ((space1 = H5Screate_simple (4, size1, size1)) < 0 || - (space2 = H5Screate_simple (1, size2, size2)) < 0) { + if ((space1 = H5Screate_simple(4, size1, size1)) < 0 || + (space2 = H5Screate_simple(1, size2, size2)) < 0) { goto error; } @@ -421,54 +417,63 @@ writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) dcpl = H5Pcreate(H5P_DATASET_CREATE); H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER); - if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, space1, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 || - (d2 = H5Dcreate2(file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, space1, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 || + (d2 = H5Dcreate2(file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { goto error; } - /* Write some things to them randomly */ hs_size[0] = WRT_SIZE; - if ((mem_space = H5Screate_simple (1, hs_size, hs_size)) < 0) goto error; - for (i=0; i}\n" - "\t-h\tPrint the help page\n" - "\t-c\tFile system Checking skipped. Caution: this test generates\n" - "\t\tmany big files and may fill up the file system.\n" - "\t-fsize\tChange family size default to where is\n" - "\t\ta positive float point number. Default value is %Hu.\n" - "Examples:\n" - "\tbig -fsize 2.1e9 \t# test with file size just under 2GB\n" - "\tbig -fsize 2.2e9 \t# test with file size just above 2GB\n" - "\tBe sure the file system can support the file size requested\n" - , (hsize_t)FAMILY_SIZE); + "Usage: big [-h] [-c] [-fsize }\n" + "\t-h\tPrint the help page\n" + "\t-c\tFile system Checking skipped. Caution: this test generates\n" + "\t\tmany big files and may fill up the file system.\n" + "\t-fsize\tChange family size default to where is\n" + "\t\ta positive float point number. Default value is %Hu.\n" + "Examples:\n" + "\tbig -fsize 2.1e9 \t# test with file size just under 2GB\n" + "\tbig -fsize 2.2e9 \t# test with file size just above 2GB\n" + "\tBe sure the file system can support the file size requested\n", + (hsize_t)FAMILY_SIZE); } static int test_sec2(hid_t fapl) { - char filename[1024]; - fsizes_t testsize; + char filename[1024]; + fsizes_t testsize; testsize = supports_big(); - if(testsize == NO_FILE) { + if (testsize == NO_FILE) { HDfprintf(stdout, "Test for sec2 is skipped because file system does not support big files.\n"); goto quit; } @@ -614,9 +629,9 @@ test_sec2(hid_t fapl) h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if(writer(filename, fapl, testsize, WRT_N)) + if (writer(filename, fapl, testsize, WRT_N)) goto error; - if(reader(filename, fapl)) + if (reader(filename, fapl)) goto error; HDputs("Test passed with the SEC2 Driver."); @@ -636,11 +651,11 @@ error: static int test_stdio(hid_t fapl) { - char filename[1024]; - fsizes_t testsize; + char filename[1024]; + fsizes_t testsize; testsize = supports_big(); - if(testsize == NO_FILE) { + if (testsize == NO_FILE) { HDfprintf(stdout, "Test for stdio is skipped because file system does not support big files.\n"); goto quit; } @@ -648,9 +663,9 @@ test_stdio(hid_t fapl) h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if(writer(filename, fapl, testsize, WRT_N)) + if (writer(filename, fapl, testsize, WRT_N)) goto error; - if(reader(filename, fapl)) + if (reader(filename, fapl)) goto error; HDputs("Test passed with the STDIO Driver."); @@ -675,34 +690,34 @@ error: static int test_family(hid_t fapl) { - char filename[1024]; + char filename[1024]; /* Test huge file with the family driver */ HDputs("Testing big file with the Family Driver "); - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_fapl_family(fapl, family_size_def, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fapl, family_size_def, H5P_DEFAULT) < 0) goto error; - if(cflag){ + if (cflag) { /* * We shouldn't run this test if the file system doesn't support holes * because we would generate multi-gigabyte files. */ HDputs("Checking if file system is adequate for this test..."); - if(sizeof(long long) < 8 || 0 == GB8LL) { + if (sizeof(long long) < 8 || 0 == GB8LL) { HDputs("Test skipped because sizeof(long long) is too small. This"); HDputs("hardware apparently doesn't support 64-bit integer types."); usage(); goto quit; } - if(!sparse_support) { + if (!sparse_support) { HDputs("Test skipped because file system does not support holes."); usage(); goto quit; } - if(!enough_room(fapl)) { + if (!enough_room(fapl)) { HDputs("Test skipped because of quota (file size or num open files)."); usage(); goto quit; @@ -712,9 +727,9 @@ test_family(hid_t fapl) /* Do the test with the Family Driver */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if(writer(filename, fapl, HUGEFILE, WRT_N)) + if (writer(filename, fapl, HUGEFILE, WRT_N)) goto error; - if(reader(filename, fapl)) + if (reader(filename, fapl)) goto error; HDputs("Test passed with the Family Driver."); @@ -731,7 +746,6 @@ error: return 1; } /* end test_family() */ - /*------------------------------------------------------------------------- * Function: main * @@ -756,70 +770,72 @@ error: *------------------------------------------------------------------------- */ int -main (int ac, char **av) +main(int ac, char **av) { - unsigned long seed = 0; /* Random # seed */ - hid_t fapl = -1; - hid_t driver = -1; + unsigned long seed = 0; /* Random # seed */ + hid_t fapl = -1; + hid_t driver = -1; /* parameters setup */ - while (--ac > 0){ + while (--ac > 0) { av++; - if (HDstrcmp("-fsize", *av)==0){ + if (HDstrcmp("-fsize", *av) == 0) { /* specify a different family file size */ - ac--; av++; + ac--; + av++; if (ac > 0) { family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0); } - else{ + else { HDprintf("***Missing fsize value***\n"); usage(); return 1; } } - else if (HDstrcmp("-c", *av)==0){ + else if (HDstrcmp("-c", *av) == 0) { /* turn off file system check before test */ - cflag=0; + cflag = 0; } - else if (HDstrcmp("-h", *av)==0){ + else if (HDstrcmp("-h", *av) == 0) { usage(); return 0; - }else{ + } + else { usage(); return 1; } } /* check VFD to see if this is one we test */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) goto error; - if((driver = H5Pget_driver(fapl)) < 0) + if ((driver = H5Pget_driver(fapl)) < 0) goto error; /* check sparse file support unless cflag is not set. */ - if(cflag) + if (cflag) sparse_support = is_sparse(); /* Choose random # seed */ seed = (unsigned long)HDtime(NULL); -#ifdef QAK +#if 0 /* seed = (unsigned long)1155438845; */ HDfprintf(stderr, "Random # seed was: %lu\n", seed); -#endif /* QAK */ +#endif HDsrandom((unsigned)seed); /* run VFD-specific test */ - if(H5FD_SEC2 == driver) { - if(test_sec2(fapl) != 0) + if (H5FD_SEC2 == driver) { + if (test_sec2(fapl) != 0) goto error; } - else if(H5FD_STDIO == driver) { - if(test_stdio(fapl) != 0) + else if (H5FD_STDIO == driver) { + if (test_stdio(fapl) != 0) goto error; } - else if(H5FD_FAMILY == driver) { - if(test_family(fapl) != 0) + else if (H5FD_FAMILY == driver) { + if (test_family(fapl) != 0) goto error; } else @@ -831,8 +847,7 @@ main (int ac, char **av) error: HDputs("*** TEST FAILED ***"); - if(fapl > 0) + if (fapl > 0) H5Pclose(fapl); return 1; } - diff --git a/test/bittests.c b/test/bittests.c index 046528a..4415600 100644 --- a/test/bittests.c +++ b/test/bittests.c @@ -19,12 +19,11 @@ */ #include "h5test.h" -#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#define H5T_FRIEND /*suppress error about including H5Tpkg */ #include "H5Tpkg.h" -#define NTESTS 100000 +#define NTESTS 100000 - /*------------------------------------------------------------------------- * Function: test_find * @@ -44,108 +43,106 @@ *------------------------------------------------------------------------- */ static herr_t -test_find (void) +test_find(void) { - uint8_t v1[8]; - int i; - ssize_t n; + uint8_t v1[8]; + int i; + ssize_t n; TESTING("bit search operations"); /* The zero length buffer */ HDmemset(v1, 0xaa, sizeof v1); n = H5T__bit_find(v1, (size_t)0, (size_t)0, H5T_BIT_LSB, TRUE); - if(-1 != n) { - H5_FAILED(); - HDputs (" Zero length test failed (lsb)!"); - goto failed; + if (-1 != n) { + H5_FAILED(); + HDputs(" Zero length test failed (lsb)!"); + goto failed; } n = H5T__bit_find(v1, (size_t)0, (size_t)0, H5T_BIT_MSB, TRUE); - if(-1 != n) { - H5_FAILED(); - HDputs (" Zero length test failed (msb)!"); - goto failed; + if (-1 != n) { + H5_FAILED(); + HDputs(" Zero length test failed (msb)!"); + goto failed; } - /* The zero buffer */ HDmemset(v1, 0, sizeof v1); n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, TRUE); - if(-1 != n) { - H5_FAILED(); - HDputs (" Zero buffer test failed (lsb)!"); - goto failed; + if (-1 != n) { + H5_FAILED(); + HDputs(" Zero buffer test failed (lsb)!"); + goto failed; } n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, TRUE); - if(-1 != n) { - H5_FAILED(); - HDputs (" Zero buffer test failed (msb)!"); - goto failed; + if (-1 != n) { + H5_FAILED(); + HDputs(" Zero buffer test failed (msb)!"); + goto failed; } /* Try all combinations of one byte */ - for(i = 0; i < 8 * (int)sizeof(v1); i++) { - HDmemset(v1, 0, sizeof v1); - v1[i / 8] = (uint8_t)(1 << (i % 8)); - n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, TRUE); - if((ssize_t)i != n) { - H5_FAILED(); - HDprintf (" Test for set bit %d failed (lsb)!\n", i); - goto failed; - } - n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, TRUE); - if((ssize_t)i != n) { - H5_FAILED(); - HDprintf (" Test for set bit %d failed (msb)!\n", i); - goto failed; - } + for (i = 0; i < 8 * (int)sizeof(v1); i++) { + HDmemset(v1, 0, sizeof v1); + v1[i / 8] = (uint8_t)(1 << (i % 8)); + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, TRUE); + if ((ssize_t)i != n) { + H5_FAILED(); + HDprintf(" Test for set bit %d failed (lsb)!\n", i); + goto failed; + } + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, TRUE); + if ((ssize_t)i != n) { + H5_FAILED(); + HDprintf(" Test for set bit %d failed (msb)!\n", i); + goto failed; + } } /* The one buffer */ HDmemset(v1, 0xff, sizeof v1); n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, FALSE); - if(-1 != n) { - H5_FAILED(); - HDputs (" One buffer test failed (lsb)!"); - goto failed; + if (-1 != n) { + H5_FAILED(); + HDputs(" One buffer test failed (lsb)!"); + goto failed; } n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, FALSE); - if(-1 != n) { - H5_FAILED(); - HDputs (" One buffer test failed (msb)!"); - goto failed; + if (-1 != n) { + H5_FAILED(); + HDputs(" One buffer test failed (msb)!"); + goto failed; } /* Try all combinations of one byte */ - for (i=0; i<8*(int)sizeof(v1); i++) { - HDmemset(v1, 0xff, sizeof v1); - v1[i / 8] &= (uint8_t)~(1 << (i % 8)); - n = H5T__bit_find (v1, (size_t)0, 8*sizeof(v1), H5T_BIT_LSB, FALSE); - if ((ssize_t)i!=n) { - H5_FAILED(); - HDprintf (" Test for clear bit %d failed (lsb)!\n", i); - goto failed; - } - n = H5T__bit_find (v1, (size_t)0, 8*sizeof(v1), H5T_BIT_MSB, FALSE); - if ((ssize_t)i!=n) { - H5_FAILED(); - HDprintf (" Test for clear bit %d failed (lsb)!\n", i); - goto failed; - } + for (i = 0; i < 8 * (int)sizeof(v1); i++) { + HDmemset(v1, 0xff, sizeof v1); + v1[i / 8] &= (uint8_t) ~(1 << (i % 8)); + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, FALSE); + if ((ssize_t)i != n) { + H5_FAILED(); + HDprintf(" Test for clear bit %d failed (lsb)!\n", i); + goto failed; + } + n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_MSB, FALSE); + if ((ssize_t)i != n) { + H5_FAILED(); + HDprintf(" Test for clear bit %d failed (lsb)!\n", i); + goto failed; + } } - PASSED(); return 0; - failed: - HDprintf (" v = 0x"); - for (i=0; i<(int)sizeof(v1); i++) HDprintf ("%02x", v1[i]); - HDprintf ("\n"); +failed: + HDprintf(" v = 0x"); + for (i = 0; i < (int)sizeof(v1); i++) + HDprintf("%02x", v1[i]); + HDprintf("\n"); return -1; } - /*------------------------------------------------------------------------- * Function: test_copy * @@ -163,111 +160,115 @@ test_find (void) *------------------------------------------------------------------------- */ static herr_t -test_copy (void) +test_copy(void) { - uint8_t v1[8], v2[8]; - size_t s_offset, d_offset, size; - int i, j; - ssize_t n; + uint8_t v1[8], v2[8]; + size_t s_offset, d_offset, size; + int i, j; + ssize_t n; TESTING("bit copy operations"); - for (i=0; i0 && j>=(int)sizeof(v2)) { - H5_FAILED(); - HDputs (" Unabled to find copied region in destination"); - goto failed; - } - if (0==size && j<(int)sizeof(v2)) { - H5_FAILED(); - HDputs (" Found copied bits when we shouldn't have"); - goto failed; - } - - - /* Look for the zeros and ones */ - n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 1); - if (size>0 && n!=(ssize_t)d_offset) { - H5_FAILED(); - HDprintf (" Unable to find first copied bit in destination " - "(n=%d)\n", (int)n); - goto failed; - } - if (0==size && n>=0) { - H5_FAILED(); - HDputs (" Found copied bits and shouldn't have!"); - goto failed; - } - n = H5T__bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0); - if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { - H5_FAILED(); - HDprintf (" Unable to find last copied bit in destination " - "(n=%d)\n", (int)n); - goto failed; - } - if (d_offset+size==8*sizeof(v2) && n>=0) { - H5_FAILED(); - HDputs (" High-order zeros are present and shouldn't be!"); - goto failed; - } - - /* - * Look for zeros and ones in reverse order. This is only to test - * that reverse searches work as expected. - */ - n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 1); - if (size>0 && (size_t)(n+1)!=d_offset+size) { - H5_FAILED(); - HDprintf (" Unable to find last copied bit in destination " - "(reverse, n=%d)\n", (int)n); - goto failed; - } - if (0==size && n>=0) { - H5_FAILED(); - HDputs (" Found copied bits but shouldn't have (reverse)!"); - goto failed; - } - n = H5T__bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 0); - if (d_offset>0 && n+1!=(ssize_t)d_offset) { - H5_FAILED(); - HDprintf (" Unable to find beginning of copied data " - "(reverse, n=%d)\n", (int)n); - goto failed; - } - if (0==d_offset && n>=0) { - H5_FAILED(); - HDputs (" Found leading original data but shouldn't have!"); - goto failed; - } - + for (i = 0; i < NTESTS; i++) { + s_offset = (size_t)HDrand() % (8 * sizeof v1); + d_offset = (size_t)HDrand() % (8 * sizeof v2); + size = (unsigned)HDrand() % MIN(8 * sizeof(v1), 8 * sizeof(v2)); + size = MIN3(size, 8 * sizeof(v1) - s_offset, 8 * sizeof(v2) - d_offset); + HDmemset(v1, 0xff, sizeof v1); + HDmemset(v2, 0x00, sizeof v2); + + /* Copy some bits to v2 and make sure something was copied */ + H5T__bit_copy(v2, d_offset, v1, s_offset, size); + for (j = 0; j < (int)sizeof(v2); j++) + if (v2[j]) + break; + if (size > 0 && j >= (int)sizeof(v2)) { + H5_FAILED(); + HDputs(" Unabled to find copied region in destination"); + goto failed; + } + if (0 == size && j < (int)sizeof(v2)) { + H5_FAILED(); + HDputs(" Found copied bits when we shouldn't have"); + goto failed; + } + + /* Look for the zeros and ones */ + n = H5T__bit_find(v2, (size_t)0, 8 * sizeof(v2), H5T_BIT_LSB, 1); + if (size > 0 && n != (ssize_t)d_offset) { + H5_FAILED(); + HDprintf(" Unable to find first copied bit in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + if (0 == size && n >= 0) { + H5_FAILED(); + HDputs(" Found copied bits and shouldn't have!"); + goto failed; + } + n = H5T__bit_find(v2, d_offset, 8 * sizeof(v2) - d_offset, H5T_BIT_LSB, 0); + if (d_offset + size < 8 * sizeof(v2) && n != (ssize_t)size) { + H5_FAILED(); + HDprintf(" Unable to find last copied bit in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + if (d_offset + size == 8 * sizeof(v2) && n >= 0) { + H5_FAILED(); + HDputs(" High-order zeros are present and shouldn't be!"); + goto failed; + } + + /* + * Look for zeros and ones in reverse order. This is only to test + * that reverse searches work as expected. + */ + n = H5T__bit_find(v2, (size_t)0, 8 * sizeof(v2), H5T_BIT_MSB, 1); + if (size > 0 && (size_t)(n + 1) != d_offset + size) { + H5_FAILED(); + HDprintf(" Unable to find last copied bit in destination " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } + if (0 == size && n >= 0) { + H5_FAILED(); + HDputs(" Found copied bits but shouldn't have (reverse)!"); + goto failed; + } + n = H5T__bit_find(v2, (size_t)0, d_offset + size, H5T_BIT_MSB, 0); + if (d_offset > 0 && n + 1 != (ssize_t)d_offset) { + H5_FAILED(); + HDprintf(" Unable to find beginning of copied data " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } + if (0 == d_offset && n >= 0) { + H5_FAILED(); + HDputs(" Found leading original data but shouldn't have!"); + goto failed; + } } PASSED(); return 0; - failed: - HDprintf (" i=%d, s_offset=%lu, d_offset=%lu, size=%lu\n", - i, (unsigned long)s_offset, (unsigned long)d_offset, - (unsigned long)size); - HDprintf (" s = 0x"); - for (j=sizeof(v1)-1; j>=0; --j) HDprintf ("%02x", v1[j]); - HDprintf ("\n d = 0x"); - for (j=sizeof(v2)-1; j>=0; --j) HDprintf ("%02x", v2[j]); - HDprintf ("\n"); +failed: + HDprintf(" i=%d, s_offset=%lu, d_offset=%lu, size=%lu\n", i, (unsigned long)s_offset, + (unsigned long)d_offset, (unsigned long)size); + HDprintf(" s = 0x"); + for (j = sizeof(v1) - 1; j >= 0; --j) + HDprintf("%02x", v1[j]); + HDprintf("\n d = 0x"); + for (j = sizeof(v2) - 1; j >= 0; --j) + HDprintf("%02x", v2[j]); + HDprintf("\n"); return -1; } - /*------------------------------------------------------------------------- * Function: test_shift * @@ -285,122 +286,128 @@ test_copy (void) *------------------------------------------------------------------------- */ static herr_t -test_shift (void) +test_shift(void) { - uint8_t vector[8]; - size_t offset, size; - int i, j; - ssize_t shift_dist, n; + uint8_t vector[8]; + size_t offset, size; + int i, j; + ssize_t shift_dist, n; TESTING("bit shift operations"); - for (i=0; i= 0) { - H5_FAILED(); - HDprintf (" Unable to verify all bits are zero in destination(LSB) " - "(n=%d)\n", (int)n); - goto failed; - } + /* Supposed to fail to find any ones */ + n = H5T__bit_find(vector, (size_t)0, 8 * sizeof(vector), H5T_BIT_LSB, 1); + if (n >= 0) { + H5_FAILED(); + HDprintf(" Unable to verify all bits are zero in destination(LSB) " + "(n=%d)\n", + (int)n); + goto failed; + } /* Look from the other direction */ - n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); - if (n >= 0) { - H5_FAILED(); - HDprintf (" Unable to verify all bits are zero in destination(MSB) " - "(n=%d)\n", (int)n); - goto failed; - } + n = H5T__bit_find(vector, (size_t)0, 8 * sizeof(vector), H5T_BIT_MSB, 1); + if (n >= 0) { + H5_FAILED(); + HDprintf(" Unable to verify all bits are zero in destination(MSB) " + "(n=%d)\n", + (int)n); + goto failed; + } } PASSED(); return 0; - failed: - HDprintf (" i=%d, offset=%lu, size=%lu, shift_dist=%lu\n", - i, (unsigned long)offset, (unsigned long)size, - (unsigned long)shift_dist); - for (j=sizeof(vector)-1; j>=0; --j) HDprintf ("%02x", vector[j]); - HDprintf ("\n"); +failed: + HDprintf(" i=%d, offset=%lu, size=%lu, shift_dist=%lu\n", i, (unsigned long)offset, + (unsigned long)size, (unsigned long)shift_dist); + for (j = sizeof(vector) - 1; j >= 0; --j) + HDprintf("%02x", vector[j]); + HDprintf("\n"); return -1; } - /*------------------------------------------------------------------------- * Function: test_increment * @@ -418,76 +425,80 @@ test_shift (void) *------------------------------------------------------------------------- */ static herr_t -test_increment (void) +test_increment(void) { - uint8_t vector[8]; - size_t offset, size; - int i, j; - ssize_t n; + uint8_t vector[8]; + size_t offset, size; + int i, j; + ssize_t n; TESTING("bit increment operations"); - for (i=0; i1) /* if size=6, make a sequence like 011111 */ - H5T__bit_set (vector, offset, size-1, 1); - else /* if size=1, just set this one bit to 1 */ - H5T__bit_set (vector, offset, size, 1); - - /* Increment the sequence by one */ - H5T__bit_inc (vector, offset, size); - - /* Look for the one */ - n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); - if (size!=1 && (size_t)n!=offset+size-1) { - H5_FAILED(); - HDprintf (" Unable to find first bit in destination " - "(n=%d)\n", (int)n); - goto failed; - } - if(size==1 && n>=0) { - H5_FAILED(); - HDprintf (" Unable to verify all-zero bit in destination " - "(n=%d)\n", (int)n); - goto failed; - } - - /* - * Look for one in reverse order. This is only to test - * that reverse searches work as expected. - */ - n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); - if (size!=1 && n!=(ssize_t)(offset+size-1)) { - H5_FAILED(); - HDprintf (" Unable to find last bit in destination " - "(reverse, n=%d)\n", (int)n); - goto failed; - } - if(size==1 && n>=0) { - H5_FAILED(); - HDprintf (" Unable to verify all-zero bit in destination " - "(reverse, n=%d)\n", (int)n); - goto failed; - } + if (size == 0) + continue; + + HDmemset(vector, 0x00, sizeof vector); + if (size > 1) /* if size=6, make a sequence like 011111 */ + H5T__bit_set(vector, offset, size - 1, 1); + else /* if size=1, just set this one bit to 1 */ + H5T__bit_set(vector, offset, size, 1); + + /* Increment the sequence by one */ + H5T__bit_inc(vector, offset, size); + + /* Look for the one */ + n = H5T__bit_find(vector, (size_t)0, 8 * sizeof(vector), H5T_BIT_LSB, 1); + if (size != 1 && (size_t)n != offset + size - 1) { + H5_FAILED(); + HDprintf(" Unable to find first bit in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + if (size == 1 && n >= 0) { + H5_FAILED(); + HDprintf(" Unable to verify all-zero bit in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + + /* + * Look for one in reverse order. This is only to test + * that reverse searches work as expected. + */ + n = H5T__bit_find(vector, (size_t)0, 8 * sizeof(vector), H5T_BIT_MSB, 1); + if (size != 1 && n != (ssize_t)(offset + size - 1)) { + H5_FAILED(); + HDprintf(" Unable to find last bit in destination " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } + if (size == 1 && n >= 0) { + H5_FAILED(); + HDprintf(" Unable to verify all-zero bit in destination " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } } PASSED(); return 0; - failed: - HDprintf (" i=%d, offset=%lu, size=%lu\n", - i, (unsigned long)offset, (unsigned long)size); - for (j=sizeof(vector)-1; j>=0; --j) HDprintf ("%02x", vector[j]); - HDprintf ("\n"); +failed: + HDprintf(" i=%d, offset=%lu, size=%lu\n", i, (unsigned long)offset, (unsigned long)size); + for (j = sizeof(vector) - 1; j >= 0; --j) + HDprintf("%02x", vector[j]); + HDprintf("\n"); return -1; } - /*------------------------------------------------------------------------- * Function: test_decrement * @@ -505,61 +516,63 @@ test_increment (void) *------------------------------------------------------------------------- */ static herr_t -test_decrement (void) +test_decrement(void) { - uint8_t vector[8]; - size_t offset, size; - int i, j; - ssize_t n; + uint8_t vector[8]; + size_t offset, size; + int i, j; + ssize_t n; TESTING("bit decrement operations"); - for (i=0; i=0; --j) HDprintf ("%02x", vector[j]); - HDprintf ("\n"); +failed: + HDprintf(" i=%d, offset=%lu, size=%lu\n", i, (unsigned long)offset, (unsigned long)size); + for (j = sizeof(vector) - 1; j >= 0; --j) + HDprintf("%02x", vector[j]); + HDprintf("\n"); return -1; } - /*------------------------------------------------------------------------- * Function: test_negate * @@ -577,89 +590,93 @@ test_decrement (void) *------------------------------------------------------------------------- */ static herr_t -test_negate (void) +test_negate(void) { - uint8_t vector[8]; - size_t offset, size; - int i, j; - ssize_t n; + uint8_t vector[8]; + size_t offset, size; + int i, j; + ssize_t n; TESTING("bit negate operations"); - for (i=0; i=0) { - H5_FAILED(); - HDprintf (" Unable to verify all-zero bits in destination " - "(n=%d)\n", (int)n); - goto failed; - } - - /* - * Look for ones in reverse order. This is only to test - * that reverse searches work as expected. - */ - n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); - if (n>=0) { - H5_FAILED(); - HDprintf (" Unable to verify all-zero bits in destination " - "(reverse, n=%d)\n", (int)n); - goto failed; - } + HDmemset(vector, 0x00, sizeof vector); + H5T__bit_set(vector, offset, size, 1); + + /* negate the sequence */ + H5T__bit_neg(vector, offset, size); + + /* Look for the ones */ + n = H5T__bit_find(vector, (size_t)0, 8 * sizeof(vector), H5T_BIT_LSB, 1); + if (n >= 0) { + H5_FAILED(); + HDprintf(" Unable to verify all-zero bits in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + + /* + * Look for ones in reverse order. This is only to test + * that reverse searches work as expected. + */ + n = H5T__bit_find(vector, (size_t)0, 8 * sizeof(vector), H5T_BIT_MSB, 1); + if (n >= 0) { + H5_FAILED(); + HDprintf(" Unable to verify all-zero bits in destination " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } } PASSED(); return 0; - failed: - HDprintf (" i=%d, offset=%lu, size=%lu\n", - i, (unsigned long)offset, (unsigned long)size); - for (j=sizeof(vector)-1; j>=0; --j) HDprintf ("%02x", vector[j]); - HDprintf ("\n"); +failed: + HDprintf(" i=%d, offset=%lu, size=%lu\n", i, (unsigned long)offset, (unsigned long)size); + for (j = sizeof(vector) - 1; j >= 0; --j) + HDprintf("%02x", vector[j]); + HDprintf("\n"); return -1; } - /*------------------------------------------------------------------------- * Function: test_set * @@ -677,106 +694,109 @@ test_negate (void) *------------------------------------------------------------------------- */ static herr_t -test_set (void) +test_set(void) { - uint8_t v2[8]; - size_t d_offset, size; - int i, j; - ssize_t n; + uint8_t v2[8]; + size_t d_offset, size; + int i, j; + ssize_t n; TESTING("bit set operations"); - for (i=0; i0 && j>=(int)sizeof(v2)) { - H5_FAILED(); - HDputs (" Unabled to find set region in buffer"); - goto failed; - } - if (0==size && j<(int)sizeof(v2)) { - H5_FAILED(); - HDputs (" Found set bits when we shouldn't have"); - goto failed; - } - - - /* Look for the zeros and ones */ - n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 1); - if (size>0 && n!=(ssize_t)d_offset) { - H5_FAILED(); - HDprintf (" Unable to find first set bit in destination " - "(n=%d)\n", (int)n); - goto failed; - } - if (0==size && n>=0) { - H5_FAILED(); - HDputs (" Found set bits and shouldn't have!"); - goto failed; - } - n = H5T__bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0); - if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { - H5_FAILED(); - HDprintf (" Unable to find last set bit in destination " - "(n=%d)\n", (int)n); - goto failed; - } - if (d_offset+size==8*sizeof(v2) && n>=0) { - H5_FAILED(); - HDputs (" High-order zeros are present and shouldn't be!"); - goto failed; - } - - /* - * Look for zeros and ones in reverse order. This is only to test - * that reverse searches work as expected. - */ - n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 1); - if (size>0 && (size_t)(n+1)!=d_offset+size) { - H5_FAILED(); - HDprintf (" Unable to find last set bit in destination " - "(reverse, n=%d)\n", (int)n); - goto failed; - } - if (0==size && n>=0) { - H5_FAILED(); - HDputs (" Found set bits but shouldn't have (reverse)!"); - goto failed; - } - n = H5T__bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 0); - if (d_offset>0 && n+1!=(ssize_t)d_offset) { - H5_FAILED(); - HDprintf (" Unable to find beginning of set bit region " - "(reverse, n=%d)\n", (int)n); - goto failed; - } - if (0==d_offset && n>=0) { - H5_FAILED(); - HDputs (" Found leading zeros but shouldn't have!"); - goto failed; - } - + for (i = 0; i < NTESTS; i++) { + d_offset = (size_t)HDrand() % (8 * sizeof v2); + size = (size_t)HDrand() % (8 * sizeof(v2)); + size = MIN(size, 8 * sizeof(v2) - d_offset); + HDmemset(v2, 0x00, sizeof v2); + + /* Set some bits in v2 */ + H5T__bit_set(v2, d_offset, size, TRUE); + for (j = 0; j < (int)sizeof(v2); j++) + if (v2[j]) + break; + if (size > 0 && j >= (int)sizeof(v2)) { + H5_FAILED(); + HDputs(" Unabled to find set region in buffer"); + goto failed; + } + if (0 == size && j < (int)sizeof(v2)) { + H5_FAILED(); + HDputs(" Found set bits when we shouldn't have"); + goto failed; + } + + /* Look for the zeros and ones */ + n = H5T__bit_find(v2, (size_t)0, 8 * sizeof(v2), H5T_BIT_LSB, 1); + if (size > 0 && n != (ssize_t)d_offset) { + H5_FAILED(); + HDprintf(" Unable to find first set bit in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + if (0 == size && n >= 0) { + H5_FAILED(); + HDputs(" Found set bits and shouldn't have!"); + goto failed; + } + n = H5T__bit_find(v2, d_offset, 8 * sizeof(v2) - d_offset, H5T_BIT_LSB, 0); + if (d_offset + size < 8 * sizeof(v2) && n != (ssize_t)size) { + H5_FAILED(); + HDprintf(" Unable to find last set bit in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + if (d_offset + size == 8 * sizeof(v2) && n >= 0) { + H5_FAILED(); + HDputs(" High-order zeros are present and shouldn't be!"); + goto failed; + } + + /* + * Look for zeros and ones in reverse order. This is only to test + * that reverse searches work as expected. + */ + n = H5T__bit_find(v2, (size_t)0, 8 * sizeof(v2), H5T_BIT_MSB, 1); + if (size > 0 && (size_t)(n + 1) != d_offset + size) { + H5_FAILED(); + HDprintf(" Unable to find last set bit in destination " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } + if (0 == size && n >= 0) { + H5_FAILED(); + HDputs(" Found set bits but shouldn't have (reverse)!"); + goto failed; + } + n = H5T__bit_find(v2, (size_t)0, d_offset + size, H5T_BIT_MSB, 0); + if (d_offset > 0 && n + 1 != (ssize_t)d_offset) { + H5_FAILED(); + HDprintf(" Unable to find beginning of set bit region " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } + if (0 == d_offset && n >= 0) { + H5_FAILED(); + HDputs(" Found leading zeros but shouldn't have!"); + goto failed; + } } PASSED(); return 0; - failed: - HDprintf (" i=%d, d_offset=%lu, size=%lu\n", - i, (unsigned long)d_offset, (unsigned long)size); - HDprintf (" d = 0x"); - for (j=sizeof(v2)-1; j>=0; --j) HDprintf ("%02x", v2[j]); - HDprintf ("\n"); +failed: + HDprintf(" i=%d, d_offset=%lu, size=%lu\n", i, (unsigned long)d_offset, (unsigned long)size); + HDprintf(" d = 0x"); + for (j = sizeof(v2) - 1; j >= 0; --j) + HDprintf("%02x", v2[j]); + HDprintf("\n"); return -1; } - /*------------------------------------------------------------------------- * Function: test_clear * @@ -794,106 +814,109 @@ test_set (void) *------------------------------------------------------------------------- */ static herr_t -test_clear (void) +test_clear(void) { - uint8_t v2[8]; - size_t d_offset, size; - int i, j; - ssize_t n; + uint8_t v2[8]; + size_t d_offset, size; + int i, j; + ssize_t n; TESTING("bit clear operations"); - for (i=0; i0 && j>=(int)sizeof(v2)) { - H5_FAILED(); - HDputs (" Unabled to find cleared region in buffer"); - goto failed; - } - if (0==size && j<(int)sizeof(v2)) { - H5_FAILED(); - HDputs (" Found cleared bits when we shouldn't have"); - goto failed; - } - - - /* Look for the zeros and ones */ - n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_LSB, 0); - if (size>0 && n!=(ssize_t)d_offset) { - H5_FAILED(); - HDprintf (" Unable to find first cleared bit in destination " - "(n=%d)\n", (int)n); - goto failed; - } - if (0==size && n>=0) { - H5_FAILED(); - HDputs (" Found cleared bits and shouldn't have!"); - goto failed; - } - n = H5T__bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 1); - if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { - H5_FAILED(); - HDprintf (" Unable to find last cleared bit in destination " - "(n=%d)\n", (int)n); - goto failed; - } - if (d_offset+size==8*sizeof(v2) && n>=0) { - H5_FAILED(); - HDputs (" High-order ones are present and shouldn't be!"); - goto failed; - } - - /* - * Look for zeros and ones in reverse order. This is only to test - * that reverse searches work as expected. - */ - n = H5T__bit_find (v2, (size_t)0, 8*sizeof(v2), H5T_BIT_MSB, 0); - if (size>0 && (size_t)(n+1)!=d_offset+size) { - H5_FAILED(); - HDprintf (" Unable to find last cleared bit in destination " - "(reverse, n=%d)\n", (int)n); - goto failed; - } - if (0==size && n>=0) { - H5_FAILED(); - HDputs (" Found cleared bits but shouldn't have (reverse)!"); - goto failed; - } - n = H5T__bit_find (v2, (size_t)0, d_offset+size, H5T_BIT_MSB, 1); - if (d_offset>0 && n+1!=(ssize_t)d_offset) { - H5_FAILED(); - HDprintf (" Unable to find beginning of cleared bit region " - "(reverse, n=%d)\n", (int)n); - goto failed; - } - if (0==d_offset && n>=0) { - H5_FAILED(); - HDputs (" Found leading ones but shouldn't have!"); - goto failed; - } - + for (i = 0; i < NTESTS; i++) { + d_offset = (size_t)HDrand() % (8 * sizeof v2); + size = (size_t)HDrand() % (8 * sizeof(v2)); + size = MIN(size, 8 * sizeof(v2) - d_offset); + HDmemset(v2, 0xff, sizeof v2); + + /* Clear some bits in v2 */ + H5T__bit_set(v2, d_offset, size, FALSE); + for (j = 0; j < (int)sizeof(v2); j++) + if (0xff != v2[j]) + break; + if (size > 0 && j >= (int)sizeof(v2)) { + H5_FAILED(); + HDputs(" Unabled to find cleared region in buffer"); + goto failed; + } + if (0 == size && j < (int)sizeof(v2)) { + H5_FAILED(); + HDputs(" Found cleared bits when we shouldn't have"); + goto failed; + } + + /* Look for the zeros and ones */ + n = H5T__bit_find(v2, (size_t)0, 8 * sizeof(v2), H5T_BIT_LSB, 0); + if (size > 0 && n != (ssize_t)d_offset) { + H5_FAILED(); + HDprintf(" Unable to find first cleared bit in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + if (0 == size && n >= 0) { + H5_FAILED(); + HDputs(" Found cleared bits and shouldn't have!"); + goto failed; + } + n = H5T__bit_find(v2, d_offset, 8 * sizeof(v2) - d_offset, H5T_BIT_LSB, 1); + if (d_offset + size < 8 * sizeof(v2) && n != (ssize_t)size) { + H5_FAILED(); + HDprintf(" Unable to find last cleared bit in destination " + "(n=%d)\n", + (int)n); + goto failed; + } + if (d_offset + size == 8 * sizeof(v2) && n >= 0) { + H5_FAILED(); + HDputs(" High-order ones are present and shouldn't be!"); + goto failed; + } + + /* + * Look for zeros and ones in reverse order. This is only to test + * that reverse searches work as expected. + */ + n = H5T__bit_find(v2, (size_t)0, 8 * sizeof(v2), H5T_BIT_MSB, 0); + if (size > 0 && (size_t)(n + 1) != d_offset + size) { + H5_FAILED(); + HDprintf(" Unable to find last cleared bit in destination " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } + if (0 == size && n >= 0) { + H5_FAILED(); + HDputs(" Found cleared bits but shouldn't have (reverse)!"); + goto failed; + } + n = H5T__bit_find(v2, (size_t)0, d_offset + size, H5T_BIT_MSB, 1); + if (d_offset > 0 && n + 1 != (ssize_t)d_offset) { + H5_FAILED(); + HDprintf(" Unable to find beginning of cleared bit region " + "(reverse, n=%d)\n", + (int)n); + goto failed; + } + if (0 == d_offset && n >= 0) { + H5_FAILED(); + HDputs(" Found leading ones but shouldn't have!"); + goto failed; + } } PASSED(); return 0; - failed: - HDprintf (" i=%d, d_offset=%lu, size=%lu\n", - i, (unsigned long)d_offset, (unsigned long)size); - HDprintf (" d = 0x"); - for (j=sizeof(v2)-1; j>=0; --j) HDprintf ("%02x", v2[j]); - HDprintf ("\n"); +failed: + HDprintf(" i=%d, d_offset=%lu, size=%lu\n", i, (unsigned long)d_offset, (unsigned long)size); + HDprintf(" d = 0x"); + for (j = sizeof(v2) - 1; j >= 0; --j) + HDprintf("%02x", v2[j]); + HDprintf("\n"); return -1; } - /*------------------------------------------------------------------------- * Function: main * @@ -925,9 +948,8 @@ main(void) nerrors += test_decrement() < 0 ? 1 : 0; nerrors += test_negate() < 0 ? 1 : 0; - if(nerrors) { - HDprintf("***** %u FAILURE%s! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + if (nerrors) { + HDprintf("***** %u FAILURE%s! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } HDprintf("All bit tests passed.\n"); @@ -936,4 +958,3 @@ main(void) HDexit(EXIT_SUCCESS); } /* end main() */ - diff --git a/test/btree2.c b/test/btree2.c index c4c5530..fda9268 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -20,37 +20,32 @@ * This file needs to access private datatypes from the H5B2 package. * This file also needs to access the v2 B-tree testing code. */ -#define H5B2_FRIEND /*suppress error about including H5B2pkg */ +#define H5B2_FRIEND /*suppress error about including H5B2pkg */ #define H5B2_TESTING #include "H5B2pkg.h" /* Other private headers that this test requires */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - -const char *FILENAME[] = { - "btree2", - "btree2_tmp", - NULL -}; - -#define INSERT_SPLIT_ROOT_NREC 63 -#define INSERT_SPLIT_ROOT_NREC_REC 64 -#define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2700 * 1000) -#define FIND_MANY (INSERT_MANY / 100) -#define FIND_MANY_REC (INSERT_MANY_REC / 100) -#define FIND_NEIGHBOR 2000 -#define DELETE_SMALL 20 -#define DELETE_MEDIUM 200 -#define DELETE_LARGE 2000 +#include "H5CXprivate.h" /* API Contexts */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +const char *FILENAME[] = {"btree2", "btree2_tmp", NULL}; + +#define INSERT_SPLIT_ROOT_NREC 63 +#define INSERT_SPLIT_ROOT_NREC_REC 64 +#define INSERT_MANY (1000 * 1000) +#define INSERT_MANY_REC (2700 * 1000) +#define FIND_MANY (INSERT_MANY / 100) +#define FIND_MANY_REC (INSERT_MANY_REC / 100) +#define FIND_NEIGHBOR 2000 +#define DELETE_SMALL 20 +#define DELETE_MEDIUM 200 +#define DELETE_LARGE 2000 /* Testing parameters */ typedef struct bt2_test_param_t { - hbool_t reopen_btree; /* Whether to re-open the B-tree during the test */ + hbool_t reopen_btree; /* Whether to re-open the B-tree during the test */ } bt2_test_param_t; - /*------------------------------------------------------------------------- * Function: init_cparam * @@ -71,9 +66,9 @@ init_cparam(H5B2_create_t *cparam, H5B2_create_t *cparam2) HDmemset(cparam, 0, sizeof(*cparam)); /* General parameters */ - cparam->cls = H5B2_TEST; - cparam->node_size = (size_t)512; - cparam->rrec_size = (size_t)8; + cparam->cls = H5B2_TEST; + cparam->node_size = (size_t)512; + cparam->rrec_size = (size_t)8; cparam->split_percent = 100; cparam->merge_percent = 40; @@ -81,16 +76,15 @@ init_cparam(H5B2_create_t *cparam, H5B2_create_t *cparam2) HDmemset(cparam2, 0, sizeof(*cparam2)); /* General parameters */ - cparam2->cls = H5B2_TEST2; - cparam2->node_size = (size_t)1024; - cparam2->rrec_size = (size_t)16; + cparam2->cls = H5B2_TEST2; + cparam2->node_size = (size_t)1024; + cparam2->rrec_size = (size_t)16; cparam2->split_percent = 100; cparam2->merge_percent = 40; - return(0); + return (0); } /* init_cparam() */ - /*------------------------------------------------------------------------- * Function: create_file * @@ -107,31 +101,30 @@ init_cparam(H5B2_create_t *cparam, H5B2_create_t *cparam2) static int create_file(hid_t *file, H5F_t **f, hid_t fapl) { - char filename[1024]; /* Filename to use */ + char filename[1024]; /* Filename to use */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((*file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((*file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5VL_object(*file))) + if (NULL == (*f = (H5F_t *)H5VL_object(*file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) + if (H5AC_ignore_tags(*f) < 0) STACK_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end create_file() */ - /*------------------------------------------------------------------------- * Function: create_btree * @@ -146,25 +139,23 @@ error: *------------------------------------------------------------------------- */ static int -create_btree(H5F_t *f, const H5B2_create_t *cparam, - H5B2_t **bt2, haddr_t *bt2_addr) +create_btree(H5F_t *f, const H5B2_create_t *cparam, H5B2_t **bt2, haddr_t *bt2_addr) { /* Create the v2 B-tree & get its address */ - if(NULL == (*bt2 = H5B2_create(f, cparam, f))) + if (NULL == (*bt2 = H5B2_create(f, cparam, f))) FAIL_STACK_ERROR - if(H5B2_get_addr(*bt2, bt2_addr/*out*/) < 0) + if (H5B2_get_addr(*bt2, bt2_addr /*out*/) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(*bt2_addr)) + if (!H5F_addr_defined(*bt2_addr)) FAIL_STACK_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end create_btree() */ - /*------------------------------------------------------------------------- * Function: reopen_file * @@ -181,31 +172,30 @@ error: static int reopen_file(hid_t *file, H5F_t **f, hid_t fapl) { - char filename[1024]; /* Filename to use */ + char filename[1024]; /* Filename to use */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5VL_object(*file))) + if (NULL == (*f = (H5F_t *)H5VL_object(*file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) + if (H5AC_ignore_tags(*f) < 0) STACK_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end create_file() */ - /*------------------------------------------------------------------------- * Function: reopen_btree * @@ -220,28 +210,26 @@ error: *------------------------------------------------------------------------- */ static int -reopen_btree(H5F_t *f, H5B2_t **bt2, haddr_t bt2_addr, - const bt2_test_param_t *tparam) +reopen_btree(H5F_t *f, H5B2_t **bt2, haddr_t bt2_addr, const bt2_test_param_t *tparam) { /* Check for closing & re-opening the B-tree */ - if(tparam->reopen_btree) { + if (tparam->reopen_btree) { /* Close (empty) v2 B-tree */ - if(H5B2_close(*bt2) < 0) + if (H5B2_close(*bt2) < 0) FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (*bt2 = H5B2_open(f, bt2_addr, f))) + if (NULL == (*bt2 = H5B2_open(f, bt2_addr, f))) FAIL_STACK_ERROR } /* end if */ /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end reopen_btree() */ - /*------------------------------------------------------------------------- * Function: check_stats * @@ -258,24 +246,23 @@ error: static int check_stats(H5B2_t *bt2, const H5B2_stat_t *expected) { - H5B2_stat_t actual; /* Actual stats retrieved about v2 B-tree */ + H5B2_stat_t actual; /* Actual stats retrieved about v2 B-tree */ /* Get current stats */ - if(H5B2_stat_info(bt2, &actual) < 0) + if (H5B2_stat_info(bt2, &actual) < 0) FAIL_STACK_ERROR - if(actual.depth != expected->depth) + if (actual.depth != expected->depth) TEST_ERROR - if(actual.nrecords != expected->nrecords) + if (actual.nrecords != expected->nrecords) TEST_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end check_stats() */ - /*------------------------------------------------------------------------- * Function: check_node_depth * @@ -292,21 +279,20 @@ error: static int check_node_depth(H5B2_t *bt2, void *record, unsigned depth) { - int rec_depth; /* Depth of record in B-tree */ + int rec_depth; /* Depth of record in B-tree */ - if((rec_depth = H5B2__get_node_depth_test(bt2, record)) < 0) + if ((rec_depth = H5B2__get_node_depth_test(bt2, record)) < 0) FAIL_STACK_ERROR - if((unsigned)rec_depth != depth) + if ((unsigned)rec_depth != depth) TEST_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end check_node_depth() */ - /*------------------------------------------------------------------------- * Function: check_node_info * @@ -321,26 +307,24 @@ error: *------------------------------------------------------------------------- */ static int -check_node_info(H5B2_t *bt2, hsize_t record, - H5B2_node_info_test_t *ninfo) +check_node_info(H5B2_t *bt2, hsize_t record, H5B2_node_info_test_t *ninfo) { - H5B2_node_info_test_t rec_ninfo; /* Node info for record in B-tree */ + H5B2_node_info_test_t rec_ninfo; /* Node info for record in B-tree */ - if(H5B2__get_node_info_test(bt2, &record, &rec_ninfo) < 0) + if (H5B2__get_node_info_test(bt2, &record, &rec_ninfo) < 0) FAIL_STACK_ERROR - if(rec_ninfo.depth != ninfo->depth) + if (rec_ninfo.depth != ninfo->depth) TEST_ERROR - if(rec_ninfo.nrec != ninfo->nrec) + if (rec_ninfo.nrec != ninfo->nrec) TEST_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end check_node_info() */ - /*------------------------------------------------------------------------- * Function: iter_cb * @@ -358,16 +342,15 @@ static int iter_cb(const void *_record, void *_op_data) { const hsize_t *record = (const hsize_t *)_record; - hsize_t *idx = (hsize_t *)_op_data; + hsize_t * idx = (hsize_t *)_op_data; - if(*record != *idx) - return(H5_ITER_ERROR); + if (*record != *idx) + return (H5_ITER_ERROR); (*idx)++; - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /* end iter_cb() */ - /*------------------------------------------------------------------------- * Function: iter_rec_cb * @@ -385,19 +368,18 @@ static int iter_rec_cb(const void *_record, void *_op_data) { const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; - H5B2_test_rec_t *idx = (H5B2_test_rec_t *)_op_data; + H5B2_test_rec_t * idx = (H5B2_test_rec_t *)_op_data; - if(record->key != idx->key) - return(H5_ITER_ERROR); - if(record->val != idx->val) - return(H5_ITER_ERROR); + if (record->key != idx->key) + return (H5_ITER_ERROR); + if (record->val != idx->val) + return (H5_ITER_ERROR); idx->key++; idx->val += 2; - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /* end iter_rec_cb() */ - /*------------------------------------------------------------------------- * Function: find_cb * @@ -415,15 +397,14 @@ static int find_cb(const void *_record, void *_op_data) { const hsize_t *record = (const hsize_t *)_record; - hsize_t *search = (hsize_t *)_op_data; + hsize_t * search = (hsize_t *)_op_data; - if(*record != *search) - return(FALSE); + if (*record != *search) + return (FALSE); - return(TRUE); + return (TRUE); } /* end find_cb() */ - /*------------------------------------------------------------------------- * Function: find_rec_cb * @@ -441,16 +422,15 @@ static int find_rec_cb(const void *_record, void *_op_data) { const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; - H5B2_test_rec_t *search = (H5B2_test_rec_t *)_op_data; + H5B2_test_rec_t * search = (H5B2_test_rec_t *)_op_data; - if(record->key != search->key) - return(FALSE); + if (record->key != search->key) + return (FALSE); search->val = record->val; - return(TRUE); + return (TRUE); } /* end find_rec_cb() */ - /*------------------------------------------------------------------------- * Function: find_dec_cb * @@ -470,15 +450,14 @@ static int find_dec_cb(const void *_record, void *_op_data) { const hsize_t *record = (const hsize_t *)_record; - hsize_t *search = (hsize_t *)_op_data; + hsize_t * search = (hsize_t *)_op_data; - if(*record != (INSERT_MANY - (*search + 1))) - return(-1); + if (*record != (INSERT_MANY - (*search + 1))) + return (-1); - return(0); + return (0); } /* end find_dec_cb() */ - /*------------------------------------------------------------------------- * Function: index_rec_cb * @@ -496,17 +475,16 @@ static int index_rec_cb(const void *_record, void *_op_data) { const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; - H5B2_test_rec_t *search = (H5B2_test_rec_t *)_op_data; + H5B2_test_rec_t * search = (H5B2_test_rec_t *)_op_data; HDassert(record); HDassert(search); search->key = record->key; search->val = record->val; - return(TRUE); + return (TRUE); } /* end index_rec_cb() */ - /*------------------------------------------------------------------------- * Function: neighbor_cb * @@ -525,14 +503,13 @@ static int neighbor_cb(const void *_record, void *_op_data) { const hsize_t *record = (const hsize_t *)_record; - hsize_t *search = (hsize_t *)_op_data; + hsize_t * search = (hsize_t *)_op_data; *search = *record; - return(0); + return (0); } /* end neighbor_cb() */ - /*------------------------------------------------------------------------- * Function: modify_cb * @@ -553,13 +530,12 @@ modify_cb(void *_record, void *_op_data, hbool_t *changed) hsize_t *record = (hsize_t *)_record; hsize_t *modify = (hsize_t *)_op_data; - *record = *modify; + *record = *modify; *changed = TRUE; - return(0); + return (0); } /* end modify_cb() */ - /*------------------------------------------------------------------------- * Function: modify_rec_cb * @@ -581,12 +557,11 @@ modify_rec_cb(void *_record, void *_op_data, hbool_t *changed) HDassert(record->key == modify->key); record->val = modify->val; - *changed = TRUE; + *changed = TRUE; - return(0); + return (0); } /* end modify_rec_cb() */ - /*------------------------------------------------------------------------- * Function: no_modify_cb * @@ -602,15 +577,13 @@ modify_rec_cb(void *_record, void *_op_data, hbool_t *changed) *------------------------------------------------------------------------- */ static int -no_modify_cb(void H5_ATTR_UNUSED *_record, void H5_ATTR_UNUSED *_op_data, - hbool_t *changed) +no_modify_cb(void H5_ATTR_UNUSED *_record, void H5_ATTR_UNUSED *_op_data, hbool_t *changed) { *changed = FALSE; - return(1); + return (1); } /* end no_modify_cb() */ - /*------------------------------------------------------------------------- * Function: remove_cb * @@ -628,15 +601,14 @@ no_modify_cb(void H5_ATTR_UNUSED *_record, void H5_ATTR_UNUSED *_op_data, static int remove_cb(const void *_record, void *_op_data) { - const hsize_t *record = (const hsize_t *)_record; - hsize_t *rrecord = (hsize_t *)_op_data; + const hsize_t *record = (const hsize_t *)_record; + hsize_t * rrecord = (hsize_t *)_op_data; *rrecord = *record; - return(0); + return (0); } /* end remove_cb() */ - /*------------------------------------------------------------------------- * Function: test_insert_basic * @@ -651,16 +623,15 @@ remove_cb(const void *_record, void *_op_data) *------------------------------------------------------------------------- */ static unsigned -test_insert_basic(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_basic(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t idx; /* Index within B-tree, for iterator */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t idx; /* Index within B-tree, for iterator */ + herr_t ret; /* Generic error return value */ /* * Test v2 B-tree creation @@ -668,11 +639,11 @@ test_insert_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree creation"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR PASSED(); @@ -683,29 +654,31 @@ test_insert_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree iteration: empty B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to iterate over a B-tree with no records */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index hasn't changed */ - if(idx != 0) + if (idx != 0) TEST_ERROR /* Attempt to find record in B-tree with no records */ idx = 0; - if(H5B2_find(bt2, &idx, find_cb, NULL) != FALSE) + if (H5B2_find(bt2, &idx, find_cb, NULL) != FALSE) TEST_ERROR /* Attempt to index record in B-tree with no records */ idx = 0; - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, find_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, find_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR PASSED(); @@ -716,45 +689,47 @@ test_insert_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: first record"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR record = 42; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Attempt to find non-existant record in B-tree with 1 record */ /* (Should not be found, but not fail) */ idx = 41; - if(H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) TEST_ERROR /* Try again with NULL 'op' */ /* (Should not be found, but not fail) */ - if(H5B2_find(bt2, &idx, NULL, NULL) != FALSE) + if (H5B2_find(bt2, &idx, NULL, NULL) != FALSE) TEST_ERROR /* Attempt to find existant record in B-tree with 1 record */ idx = 42; - if(H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) TEST_ERROR /* Try again with NULL 'op' */ - if(H5B2_find(bt2, &idx, NULL, NULL) != TRUE) + if (H5B2_find(bt2, &idx, NULL, NULL) != TRUE) TEST_ERROR /* Attempt to index non-existant record in B-tree with 1 record */ idx = 0; - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, find_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, find_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in B-tree with 1 record */ idx = 42; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0) TEST_ERROR PASSED(); @@ -765,88 +740,91 @@ test_insert_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: several records"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* * Test inserting second record into v2 B-tree, before all other records */ record = 34; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* * Test inserting third record into v2 B-tree, after all other records */ record = 56; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* * Test inserting fourth record into v2 B-tree, in the middle of other records */ record = 38; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Attempt to find non-existant record in level-0 B-tree with several records */ /* (Should not be found, but not fail) */ idx = 41; - if(H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) TEST_ERROR /* Attempt to find existant record in level-0 B-tree with several record */ idx = 56; - if(H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) TEST_ERROR /* Attempt to index non-existant record in B-tree with several records */ idx = 0; - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)4, find_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)4, find_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in B-tree with several records */ idx = 34; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0) TEST_ERROR idx = 38; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, find_cb, &idx) < 0) TEST_ERROR idx = 42; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)2, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)2, find_cb, &idx) < 0) TEST_ERROR idx = 56; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)3, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)3, find_cb, &idx) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); /* All tests passed */ - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_insert_basic() */ - /*------------------------------------------------------------------------- * Function: test_insert_split_root * @@ -864,18 +842,17 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t idx; /* Index within B-tree, for iterator */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ /* * Test inserting enough records into v2 B-tree to split the root node @@ -883,129 +860,129 @@ test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split root"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert records to fill root leaf node */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC - 1); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC - 1); u++) { record = u + 2; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 0; + bt2_stat.depth = 0; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC - 1); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (hsize_t)33; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert record to split root leaf node */ record = INSERT_SPLIT_ROOT_NREC + 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (hsize_t)33; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Insert a couple more records, on the left side of the B-tree */ record = 0; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR record = 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC + 2); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (hsize_t)33; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != (INSERT_SPLIT_ROOT_NREC + 2)) + if (idx != (INSERT_SPLIT_ROOT_NREC + 2)) TEST_ERROR /* Attempt to find non-existant record in level-1 B-tree */ /* (Should not be found, but not fail) */ idx = INSERT_SPLIT_ROOT_NREC + 10; - if(H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) TEST_ERROR /* Attempt to find existant record in root of level-1 B-tree */ idx = 33; - if(H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) FAIL_STACK_ERROR /* Attempt to find existant record in leaf of level-1 B-tree */ idx = 56; - if(H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) FAIL_STACK_ERROR /* Attempt to index non-existant record in level-1 B-tree */ idx = 0; - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC+2), find_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC + 2), find_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in root of level-1 B-tree */ idx = 33; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)33, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)33, find_cb, &idx) < 0) FAIL_STACK_ERROR /* Attempt to index existing record in left leaf of level-1 B-tree */ idx = 0; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, find_cb, &idx) < 0) FAIL_STACK_ERROR /* Attempt to index existing record in right leaf of level-1 B-tree */ idx = 50; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)50, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)50, find_cb, &idx) < 0) FAIL_STACK_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -1013,15 +990,16 @@ test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_split_root() */ - /*------------------------------------------------------------------------- * Function: test_insert_level1_2leaf_redistrib * @@ -1040,16 +1018,15 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -1057,52 +1034,51 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redistribute 2 leaves in level 1 B-tree (l->r)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { - record = u + (INSERT_SPLIT_ROOT_NREC/2) + 1; - if(H5B2_insert(bt2, &record) < 0) + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + record = u + (INSERT_SPLIT_ROOT_NREC / 2) + 1; + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (hsize_t)INSERT_SPLIT_ROOT_NREC; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Force redistribution from left node into right node */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; @@ -1114,52 +1090,52 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redistribute 2 leaves in level 1 B-tree (r->l)"); /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (hsize_t)(INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force redistribution from left node into right node */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) { record = u + INSERT_SPLIT_ROOT_NREC; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -1167,15 +1143,16 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level1_2leaf_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_insert_level1_side_split * @@ -1194,16 +1171,15 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -1211,54 +1187,54 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split side leaf into 2 leaves in level 1 B-tree (l->r)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u + INSERT_SPLIT_ROOT_NREC; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force left node to split */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 31; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 63; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; @@ -1270,55 +1246,55 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split side leaf into 2 leaves in level 1 B-tree (r->l)"); /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force right node to split */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u + INSERT_SPLIT_ROOT_NREC; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 62; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 94; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -1326,15 +1302,16 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level1_side_split() */ - /*------------------------------------------------------------------------- * Function: test_insert_level1_3leaf_redistrib * @@ -1355,17 +1332,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -1373,95 +1349,95 @@ test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redistribute 3 leaves in level 1 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u + (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1); - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (2 * INSERT_SPLIT_ROOT_NREC); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force left node to split */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert records to force middle node to redistribute */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC / 2) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC / 2) + 1); u++) { record = u + INSERT_SPLIT_ROOT_NREC; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = (2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 52; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 105; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 2) + (INSERT_SPLIT_ROOT_NREC / 2) + 1)) + if (idx != ((INSERT_SPLIT_ROOT_NREC * 2) + (INSERT_SPLIT_ROOT_NREC / 2) + 1)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -1469,15 +1445,16 @@ test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level1_3leaf_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_insert_level1_middle_split * @@ -1497,17 +1474,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -1515,75 +1491,75 @@ test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split middle leaf into 2 leaves in level 1 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u + (INSERT_SPLIT_ROOT_NREC * 2); - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force split from left node into right node */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = 3 * INSERT_SPLIT_ROOT_NREC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 62; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 94; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 126; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != (INSERT_SPLIT_ROOT_NREC * 3)) + if (idx != (INSERT_SPLIT_ROOT_NREC * 3)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); @@ -1591,15 +1567,16 @@ test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level1_middle_split() */ - /*------------------------------------------------------------------------- * Function: test_insert_make_level2 * @@ -1615,18 +1592,17 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ /* * Test inserting many records into v2 B-tree @@ -1634,135 +1610,136 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: make level 2 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 internal nodes */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 9); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 9); u++) { record = u + 2; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ - for(; u < ((INSERT_SPLIT_ROOT_NREC * 29) + 1); u++) { + for (; u < ((INSERT_SPLIT_ROOT_NREC * 29) + 1); u++) { record = u + 4; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 948; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Add some extra records to left-most leaf */ record = 0; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR record = 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Add some extra records to middle leaf */ record = (INSERT_SPLIT_ROOT_NREC * 9) + 2; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR record = (INSERT_SPLIT_ROOT_NREC * 9) + 3; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 29) + 5)) + if (idx != ((INSERT_SPLIT_ROOT_NREC * 29) + 5)) TEST_ERROR /* Attempt to find non-existant record in level-2 B-tree */ /* (Should not be found, but not fail) */ idx = INSERT_SPLIT_ROOT_NREC * 30; - if(H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) TEST_ERROR /* Attempt to find existant record in root of level-2 B-tree */ idx = 948; - if(H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) FAIL_STACK_ERROR /* Check with B-tree */ record = 948; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR /* Attempt to find existant record in internal node of level-2 B-tree */ idx = 505; - if(H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) FAIL_STACK_ERROR /* Check with B-tree */ record = 505; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Attempt to find existant record in leaf of level-2 B-tree */ idx = 555; - if(H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) FAIL_STACK_ERROR /* Check with B-tree */ record = 555; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Attempt to index non-existant record in level-2 B-tree */ idx = 0; - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC * 30), find_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC * 30), find_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in root of level-2 B-tree */ idx = 948; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)948, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)948, find_cb, &idx) < 0) FAIL_STACK_ERROR /* Attempt to index existing record in internal node of level-2 B-tree */ idx = 505; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)505, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)505, find_cb, &idx) < 0) FAIL_STACK_ERROR /* Attempt to index existing record in leaf of level-2 B-tree */ idx = 555; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)555, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)555, find_cb, &idx) < 0) FAIL_STACK_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -1770,15 +1747,16 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_make_level2() */ - /*------------------------------------------------------------------------- * Function: test_insert_level2_leaf_redistrib * @@ -1796,17 +1774,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -1814,63 +1791,63 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redistrib right-most leaf in level 2 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 internal nodes */ /* And fill rightmost leaf */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 8); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 8); u++) { record = u + (INSERT_SPLIT_ROOT_NREC / 2) + 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ - for(; u < ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2)); u++) { + for (; u < ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2)); u++) { record = u + INSERT_SPLIT_ROOT_NREC + 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1008; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR record = 1859; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 1921; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert record to force redistribution of rightmost leaf */ record = u + INSERT_SPLIT_ROOT_NREC + 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1008; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR record = 1875; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 1922; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1878,46 +1855,46 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redistrib left-most leaf in level 2 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1008; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR record = 94; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 32; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Add more records to left-most leaf, to force a 2->1 split and then a * 2 node redistribution on left leaf */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1008; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR record = 47; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = 0; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1925,72 +1902,72 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redistrib middle leaf in level 2 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1008; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) /* Record in root node */ TEST_ERROR record = 535; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) /* Record in middle node before insertion point */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) /* Record in middle node before insertion point */ TEST_ERROR record = 630; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) /* Record in middle node after insertion point */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) /* Record in middle node after insertion point */ TEST_ERROR record = 568; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ TEST_ERROR /* Add more records to middle leaf, to force a split and a 3 node redistribution on middle leaf */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC / 2) + 1; u++) { record = u + (INSERT_SPLIT_ROOT_NREC * 8) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + (INSERT_SPLIT_ROOT_NREC / 2) + 2; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1008; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) /* Record in root node */ TEST_ERROR record = 524; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) /* Record in middle node before insertion point */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) /* Record in middle node before insertion point */ TEST_ERROR record = 577; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) /* Record in middle node after insertion point */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) /* Record in middle node after insertion point */ TEST_ERROR record = 568; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 30) + (INSERT_SPLIT_ROOT_NREC / 2) + 2)) + if (idx != ((INSERT_SPLIT_ROOT_NREC * 30) + (INSERT_SPLIT_ROOT_NREC / 2) + 2)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); @@ -1998,15 +1975,16 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level2_leaf_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_insert_level2_leaf_split * @@ -2024,17 +2002,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -2042,67 +2019,67 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split right-most leaf in level 2 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 internal nodes */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 8); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 8); u++) { record = u + 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ - for(; u < ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2)); u++) { + for (; u < ((INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2)); u++) { record = u + 2; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 946; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 946; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 1797; /* Right-most record in right internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 1797; /* Right-most record in right internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 1859; /* Right-most record in right-most leaf */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 1859; /* Right-most record in right-most leaf */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert enough records to force right-most leaf to split */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC / 2) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC / 2) + 1); u++) { record = u + (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 2; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 30; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 946; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 946; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 1828; /* Next-to-right-most record in right-most internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 1828; /* Next-to-right-most record in right-most internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 1860; /* Right-most record in right-most internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 1860; /* Right-most record in right-most internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 1891; /* Right-most record in right-most leaf */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 1891; /* Right-most record in right-most leaf */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -2110,45 +2087,45 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split left-most leaf in level 2 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 30; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 946; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 946; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 63; /* Left-most record in left-most internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 63; /* Left-most record in left-most internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 1; /* Left-most record in left-most leaf */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 1; /* Left-most record in left-most leaf */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Add another record to left-most leaf, to force a 1->2 node split on left leaf */ record = 0; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 946; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 946; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 63; /* Left-most record in left-most internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 63; /* Left-most record in left-most internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 32; /* Left-most record in left internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 32; /* Left-most record in left internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 0; /* Left-most record in left-most leaf */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 0; /* Left-most record in left-most leaf */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -2156,73 +2133,73 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split middle leaf in level 2 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 946; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 946; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 504; /* Record in internal node just before insertion point */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 504; /* Record in internal node just before insertion point */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 568; /* Record in internal node just after insertion point */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 568; /* Record in internal node just after insertion point */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 506; /* Record in leaf node just after insertion point */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 506; /* Record in leaf node just after insertion point */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Add another record to middle leaf, to force a node split on middle leaf */ record = (INSERT_SPLIT_ROOT_NREC * 8) + 1; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 2; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 946; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 946; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 504; /* Left-most record of split in left internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 504; /* Left-most record of split in left internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 537; /* Middle record of split in left internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 537; /* Middle record of split in left internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 568; /* Right-most record of split in left internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 568; /* Right-most record of split in left internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 506; /* Record in leaf node just after insertion point */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 506; /* Record in leaf node just after insertion point */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 30) + 2)) + if (idx != ((INSERT_SPLIT_ROOT_NREC * 30) + 2)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2230,15 +2207,16 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level2_leaf_split() */ - /*------------------------------------------------------------------------- * Function: test_insert_level2_2internal_redistrib * @@ -2258,16 +2236,16 @@ error: */ static unsigned test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -2275,58 +2253,58 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redist. 2 internal (r->l) in level 2 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 internal nodes */ /* And fill up right internal node, to just before to redistribute it */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 44); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 44); u++) { record = u + (INSERT_SPLIT_ROOT_NREC * 6) - 4; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 44; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1318; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1318; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3114; /* Right-most record in right internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 3114; /* Right-most record in right internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 3145; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 3145; /* Right-most record in right leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert record to redistribute right-most internal node */ record = u + (INSERT_SPLIT_ROOT_NREC * 6) - 4; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 44 + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1822; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1822; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3114; /* Right-most record in right internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 3114; /* Right-most record in right internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 3146; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 3146; /* Right-most record in right leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -2334,66 +2312,66 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redist. 2 internal (l->r) in level 2 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 44 + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1822; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1822; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 436; /* Left-most record in left internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 436; /* Left-most record in left internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 374; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 374; /* Left-most record in left leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Force left-most internal node to redistribute */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 6) - 4); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 6) - 4); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 50) - 3; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1570; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1570; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 61; /* Left-most record in left internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 61; /* Left-most record in left internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 0; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 0; /* Left-most record in left leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 50) - 3)) + if (idx != ((INSERT_SPLIT_ROOT_NREC * 50) - 3)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -2401,15 +2379,16 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level2_2internal_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_insert_level2_2internal_split * @@ -2428,17 +2407,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -2446,61 +2424,61 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split side internal node to 2 in level 2 B-tree (r->l)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 internal nodes */ /* (And fill up two child internal nodes) */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 59); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 59); u++) { record = u + (INSERT_SPLIT_ROOT_NREC * 14) - (INSERT_SPLIT_ROOT_NREC / 4) + 3; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 59; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 2759; /* Record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 2759; /* Record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 4555; /* Right-most record in right internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 4555; /* Right-most record in right internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 4586; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 4586; /* Right-most record in right leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert record to split right-most internal node */ record = u + (INSERT_SPLIT_ROOT_NREC * 14) - (INSERT_SPLIT_ROOT_NREC / 4) + 3; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 59) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 2759; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 2759; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3704; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 3704; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 4555; /* Right-most record in right internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 4555; /* Right-most record in right internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 4387; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 4387; /* Right-most record in right leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -2508,69 +2486,69 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split side internal node to 2 in level 2 B-tree (l->2)"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 59) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 2759; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 2759; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 932; /* Left-most record in left internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 932; /* Left-most record in left internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 870; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 870; /* Left-most record in left leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Force left-most internal node to split */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 14) - (INSERT_SPLIT_ROOT_NREC / 4) + 3); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 14) - (INSERT_SPLIT_ROOT_NREC / 4) + 3); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 73) - (INSERT_SPLIT_ROOT_NREC / 4) + 4; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 870; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 870; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 1814; /* Next-to-left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1814; /* Next-to-left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 61; /* Left-most record in left internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 61; /* Left-most record in left internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 0; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 0; /* Left-most record in left leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 73) - (INSERT_SPLIT_ROOT_NREC / 4) + 4)) + if (idx != ((INSERT_SPLIT_ROOT_NREC * 73) - (INSERT_SPLIT_ROOT_NREC / 4) + 4)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); @@ -2578,15 +2556,16 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level2_2internal_split() */ - /*------------------------------------------------------------------------- * Function: test_insert_level2_3internal_redistrib * @@ -2607,16 +2586,16 @@ error: */ static unsigned test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -2624,130 +2603,130 @@ test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: redistrib 3 internals in level 2 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 3 internal nodes */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 36); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 36); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ - for(; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u + (INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 59) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 3703; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 2267; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 2267; /* Record to left of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 3199; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 3199; /* Record to right of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 3137; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 3137; /* Record just above insertion point in leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert records to fill up middle internal node */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) { record = u + (INSERT_SPLIT_ROOT_NREC * 36); - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 3703; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3104; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 3104; /* Record to left of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 3137; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 3137; /* Record to right of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 3135; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 3135; /* Record just above insertion point in leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert another record, forcing the middle internal node to redistribute */ record = u + (INSERT_SPLIT_ROOT_NREC * 36); - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 4; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1574; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1574; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3104; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 3104; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR #ifdef NONE - record = 2862; /* Record to left of insertion point in right internal node (now) */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 2862; /* Record to left of insertion point in right internal node (now) */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR -#endif /* NONE */ - record = 3137; /* Record to right of insertion point in right internal node (now) */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) +#endif /* NONE */ + record = 3137; /* Record to right of insertion point in right internal node (now) */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 3135; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 3135; /* Record just above insertion point in leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 4)) + if (idx != ((INSERT_SPLIT_ROOT_NREC * 72) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 4)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); @@ -2755,15 +2734,16 @@ test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level2_3internal_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_insert_level2_3internal_split * @@ -2783,17 +2763,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_level2_3internal_split(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_level2_3internal_split(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -2801,134 +2780,134 @@ test_insert_level2_3internal_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree insert: split 3 internals to 4 in level 2 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 3 internal nodes */ /* (and fill right internal node) */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 31); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 31); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ - for(; u < (INSERT_SPLIT_ROOT_NREC * 74); u++) { + for (; u < (INSERT_SPLIT_ROOT_NREC * 74); u++) { record = u + ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3); - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 74; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 3703; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 1952; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 1952; /* Record to left of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 2884; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 2884; /* Record to right of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 2822; /* Record just after insertion point in leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 2822; /* Record just after insertion point in leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Insert records to fill up middle internal node */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) { record = u + (INSERT_SPLIT_ROOT_NREC * 31); - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 3703; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 2789; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 2789; /* Record to left of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 2822; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 2822; /* Record to right of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 2823; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 2823; /* Record just above insertion point in leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert record to split middle internal node */ record = u + (INSERT_SPLIT_ROOT_NREC * 31); - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 2789; /* Middle record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 2789; /* Middle record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 3703; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR #ifdef NONE - record = 3049; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 3049; /* Record to left of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR -#endif /* NONE */ - record = 2822; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) +#endif /* NONE */ + record = 2822; /* Record to right of insertion point in middle internal node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 2823; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + record = 2823; /* Record just above insertion point in leaf node */ + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3)) + if (idx != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2936,15 +2915,16 @@ test_insert_level2_3internal_split(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_insert_level2_3internal_split() */ - /*------------------------------------------------------------------------- * Function: test_insert_lots * @@ -2961,30 +2941,29 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_insert_lots(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_insert_lots(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[1024]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t idx; /* Index within B-tree, for iterator */ - time_t curr_time; /* Current time, for seeding random number generator */ - hsize_t *records; /* Record #'s for random insertion */ - unsigned u; /* Local index variable */ - unsigned swap_idx; /* Location to swap with when shuffling */ - hsize_t temp_rec; /* Temporary record */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t nrec; /* Number of records in B-tree */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + char filename[1024]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t idx; /* Index within B-tree, for iterator */ + time_t curr_time; /* Current time, for seeding random number generator */ + hsize_t * records; /* Record #'s for random insertion */ + unsigned u; /* Local index variable */ + unsigned swap_idx; /* Location to swap with when shuffling */ + hsize_t temp_rec; /* Temporary record */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t nrec; /* Number of records in B-tree */ + herr_t ret; /* Generic error return value */ /* Initialize random number seed */ - curr_time=HDtime(NULL); + curr_time = HDtime(NULL); #ifdef QAK -curr_time=1109170019; -HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); + curr_time = 1109170019; + HDfprintf(stderr, "curr_time=%lu\n", (unsigned long)curr_time); #endif /* QAK */ HDsrandom((unsigned)curr_time); @@ -2994,18 +2973,18 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); TESTING("B-tree insert: create random level 4 B-tree"); /* Allocate space for the records */ - if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY))) + if (NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY))) TEST_ERROR /* Initialize record #'s */ - for(u = 0; u < INSERT_MANY; u++) + for (u = 0; u < INSERT_MANY; u++) records[u] = u; /* Shuffle record #'s */ - for(u = 0; u < INSERT_MANY; u++) { - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; - temp_rec = records[u]; - records[u] = records[swap_idx]; + for (u = 0; u < INSERT_MANY; u++) { + swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + temp_rec = records[u]; + records[u] = records[swap_idx]; records[swap_idx] = temp_rec; } /* end for */ @@ -3013,117 +2992,121 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert random records */ - for(u = 0; u < INSERT_MANY; u++) { + for (u = 0; u < INSERT_MANY; u++) { record = records[u]; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 4; + bt2_stat.depth = 4; bt2_stat.nrecords = INSERT_MANY; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, f))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, f))) FAIL_STACK_ERROR /* Check up on B-tree after re-open */ - bt2_stat.depth = 4; + bt2_stat.depth = 4; bt2_stat.nrecords = INSERT_MANY; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx = 0; - if(H5B2_iterate(bt2, iter_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != INSERT_MANY) + if (idx != INSERT_MANY) TEST_ERROR /* Attempt to find non-existant record in level-4 B-tree */ /* (Should not be found, but not fail) */ idx = INSERT_MANY * 2; - if(H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != FALSE) TEST_ERROR /* Find random records */ - for(u = 0; u < FIND_MANY; u++) { + for (u = 0; u < FIND_MANY; u++) { /* Pick random record */ - idx = (hsize_t)(HDrandom()%INSERT_MANY); + idx = (hsize_t)(HDrandom() % INSERT_MANY); /* Attempt to find existant record in root of level-4 B-tree */ - if(H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) + if (H5B2_find(bt2, &idx, find_cb, &idx) != TRUE) FAIL_STACK_ERROR } /* end for */ /* Attempt to index non-existant record in level-4 B-tree, in increasing & decreasing order */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_MANY * 3), find_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_DEC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_DEC, (hsize_t)(INSERT_MANY * 3), find_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Find random records */ - for(u = 0; u < FIND_MANY; u++) { + for (u = 0; u < FIND_MANY; u++) { /* Pick random record */ idx = (hsize_t)(HDrandom() % INSERT_MANY); /* Attempt to find existant record in root of level-4 B-tree */ /* (in increasing order) */ - if(H5B2_index(bt2, H5_ITER_INC, idx, find_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_INC, idx, find_cb, &idx) < 0) FAIL_STACK_ERROR /* Attempt to find existant record in root of level-4 B-tree */ /* (in decreasing order) */ - if(H5B2_index(bt2, H5_ITER_DEC, idx, find_dec_cb, &idx) < 0) + if (H5B2_index(bt2, H5_ITER_DEC, idx, find_dec_cb, &idx) < 0) FAIL_STACK_ERROR } /* end for */ @@ -3132,32 +3115,34 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); TESTING("B-tree insert: attempt duplicate record in level 4 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR record = INSERT_MANY / 2; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5B2_insert(bt2, &record); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != INSERT_MANY) + if (nrec != INSERT_MANY) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -3167,16 +3152,17 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; HDfree(records); return 1; } /* test_insert_lots() */ - /*------------------------------------------------------------------------- * Function: test_update_basic * @@ -3191,24 +3177,23 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_update_basic(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_update_basic(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - H5B2_test_rec_t record; /* Record to insert into tree */ - H5B2_test_rec_t modify; /* Modified value */ - H5B2_test_rec_t find; /* Record to find */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + herr_t ret; /* Generic error return value */ /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* @@ -3217,136 +3202,138 @@ test_update_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: inserting first record in empty B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR record.key = 42; record.val = 72; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Attempt to find non-existant record in B-tree with 1 record */ /* (Should not be found, but not fail) */ find.key = 10; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) FAIL_STACK_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Try again with NULL 'op' */ /* (Should not be found, but not fail) */ - if(H5B2_find(bt2, &find, NULL, NULL) != FALSE) + if (H5B2_find(bt2, &find, NULL, NULL) != FALSE) FAIL_STACK_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to find existant record in B-tree with 1 record */ find.key = 42; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != 72) + if (find.val != 72) TEST_ERROR /* Try again with NULL 'op' */ find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, NULL, NULL) != TRUE) + if (H5B2_find(bt2, &find, NULL, NULL) != TRUE) FAIL_STACK_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to index non-existant record in B-tree with 1 record */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, index_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, index_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in B-tree with 1 record */ find.key = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 42) + if (find.key != 42) TEST_ERROR - if(find.val != 72) + if (find.val != 72) TEST_ERROR PASSED(); - /* * Test update only record into v2 B-tree */ TESTING("B-tree update: update only record in B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR modify.key = 42; modify.val = 43; - if(H5B2_update(bt2, &modify, modify_rec_cb, &modify) < 0) + if (H5B2_update(bt2, &modify, modify_rec_cb, &modify) < 0) FAIL_STACK_ERROR /* Attempt to find non-existant record in B-tree with 1 record */ /* (Should not be found, but not fail) */ find.key = 10; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) FAIL_STACK_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Try again with NULL 'op' */ /* (Should not be found, but not fail) */ - if(H5B2_find(bt2, &find, NULL, NULL) != FALSE) + if (H5B2_find(bt2, &find, NULL, NULL) != FALSE) FAIL_STACK_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to find modified record in B-tree with 1 record */ find.key = 42; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != 43) + if (find.val != 43) TEST_ERROR /* Try again with NULL 'op' */ find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, NULL, NULL) != TRUE) + if (H5B2_find(bt2, &find, NULL, NULL) != TRUE) FAIL_STACK_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to index non-existant record in B-tree with 1 record */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, index_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, index_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in B-tree with 1 record */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 42) + if (find.key != 42) TEST_ERROR - if(find.val != 43) + if (find.val != 43) TEST_ERROR PASSED(); - /* * Test inserting more records into v2 B-tree */ TESTING("B-tree update: insert several records"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* @@ -3354,7 +3341,7 @@ test_update_basic(hid_t fapl, const H5B2_create_t *cparam, */ record.key = 34; record.val = 11; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* @@ -3362,7 +3349,7 @@ test_update_basic(hid_t fapl, const H5B2_create_t *cparam, */ record.key = 56; record.val = 12; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* @@ -3370,70 +3357,71 @@ test_update_basic(hid_t fapl, const H5B2_create_t *cparam, */ record.key = 38; record.val = 13; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Attempt to find non-existant record in level-0 B-tree with several records */ /* (Should not be found, but not fail) */ find.key = 10; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to find existant record in level-0 B-tree with several records */ find.key = 56; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) TEST_ERROR - if(find.val != 12) + if (find.val != 12) TEST_ERROR /* Attempt to index non-existant record in B-tree with several records */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)4, index_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)4, index_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in B-tree with several records */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) TEST_ERROR - if(find.key != 34) + if (find.key != 34) TEST_ERROR - if(find.val != 11) + if (find.val != 11) TEST_ERROR find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, index_rec_cb, &find) < 0) TEST_ERROR - if(find.key != 38) + if (find.key != 38) TEST_ERROR - if(find.val != 13) + if (find.val != 13) TEST_ERROR find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)2, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)2, index_rec_cb, &find) < 0) TEST_ERROR - if(find.key != 42) + if (find.key != 42) TEST_ERROR - if(find.val != 43) + if (find.val != 43) TEST_ERROR find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)3, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)3, index_rec_cb, &find) < 0) TEST_ERROR - if(find.key != 56) + if (find.key != 56) TEST_ERROR - if(find.val != 12) + if (find.val != 12) TEST_ERROR PASSED(); - /* * Test updating all existing records in v2 B-tree */ @@ -3442,107 +3430,109 @@ test_update_basic(hid_t fapl, const H5B2_create_t *cparam, record.key = 34; modify.key = 34; modify.val = 21; - if(H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) + if (H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) FAIL_STACK_ERROR record.key = 38; modify.key = 38; modify.val = 23; - if(H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) + if (H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) FAIL_STACK_ERROR record.key = 42; modify.key = 42; modify.val = 24; - if(H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) + if (H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) FAIL_STACK_ERROR record.key = 56; modify.key = 56; modify.val = 22; - if(H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) + if (H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) FAIL_STACK_ERROR /* Attempt to find non-existant record in level-0 B-tree with several records */ /* (Should not be found, but not fail) */ find.key = 41; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to find existant record in level-0 B-tree with several record */ find.key = 56; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) TEST_ERROR - if(find.val != 22) + if (find.val != 22) TEST_ERROR /* Attempt to index non-existant record in B-tree with several records */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)4, index_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)4, index_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in B-tree with several records */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) TEST_ERROR - if(find.key != 34) + if (find.key != 34) TEST_ERROR - if(find.val != 21) + if (find.val != 21) TEST_ERROR find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)1, index_rec_cb, &find) < 0) TEST_ERROR - if(find.key != 38) + if (find.key != 38) TEST_ERROR - if(find.val != 23) + if (find.val != 23) TEST_ERROR find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)2, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)2, index_rec_cb, &find) < 0) TEST_ERROR - if(find.key != 42) + if (find.key != 42) TEST_ERROR - if(find.val != 24) + if (find.val != 24) TEST_ERROR find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)3, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)3, index_rec_cb, &find) < 0) TEST_ERROR - if(find.key != 56) + if (find.key != 56) TEST_ERROR - if(find.val != 22) + if (find.val != 22) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); - /* All tests passed */ - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_update_basic() */ - /*------------------------------------------------------------------------- * Function: test_update_split_root * @@ -3560,20 +3550,19 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_update_split_root(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_update_split_root(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - H5B2_test_rec_t record; /* Record to insert into tree */ - H5B2_test_rec_t modify; /* Modified value */ - H5B2_test_rec_t find; /* Record to find */ - H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ /* * Test inserting enough records into v2 B-tree to split the root node @@ -3581,203 +3570,203 @@ test_update_split_root(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: split root"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert records to fill root leaf node */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC - 1); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC - 1); u++) { record.key = u + 2; record.val = u * 2 + 4; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 0; + bt2_stat.depth = 0; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC - 1); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 33; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert record to split root leaf node */ record.key = INSERT_SPLIT_ROOT_NREC_REC + 1; record.val = (INSERT_SPLIT_ROOT_NREC_REC - 1) * 2 + 4; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 33; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx.key = 2; idx.val = 4; - if(H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + if (idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Modify all records */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u + 2; modify.key = u + 2; modify.val = u * 2 + 5; - if(H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) + if (H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 33; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx.key = 2; idx.val = 5; - if(H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + if (idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) TEST_ERROR - /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert a couple more records, on the left side of the B-tree */ record.key = 0; record.val = 1; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR record.key = 1; record.val = 3; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC + 2); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 33; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Iterate over B-tree to check records have been inserted correctly */ idx.key = 0; idx.val = 1; - if(H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + if (idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) TEST_ERROR /* Attempt to find non-existant record in level-1 B-tree */ /* (Should not be found, but not fail) */ find.key = 800; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to find existant record in root of level-1 B-tree */ find.key = 33; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.key != 33) + if (find.key != 33) TEST_ERROR - if(find.val != 67) + if (find.val != 67) TEST_ERROR /* Attempt to find existant record in leaf of level-1 B-tree */ find.key = 56; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.key != 56) + if (find.key != 56) TEST_ERROR - if(find.val != 113) + if (find.val != 113) TEST_ERROR /* Attempt to index non-existant record in level-1 B-tree */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC + 2), index_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC + 2), index_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in root of level-1 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)33, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)33, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 33) + if (find.key != 33) TEST_ERROR - if(find.val != 67) + if (find.val != 67) TEST_ERROR /* Attempt to index existing record in left leaf of level-1 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 0) + if (find.key != 0) TEST_ERROR - if(find.val != 1) + if (find.val != 1) TEST_ERROR /* Attempt to index existing record in right leaf of level-1 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)50, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)50, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 50) + if (find.key != 50) TEST_ERROR - if(find.val != 101) + if (find.val != 101) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -3785,15 +3774,16 @@ test_update_split_root(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_update_split_root() */ - /*------------------------------------------------------------------------- * Function: test_update_level1_2leaf_redistrib * @@ -3812,16 +3802,15 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_update_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_update_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - H5B2_test_rec_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -3829,54 +3818,53 @@ test_update_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: redistribute 2 leaves in level 1 B-tree (l->r)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; record.val = u + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 10; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = INSERT_SPLIT_ROOT_NREC_REC; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Force redistribution from left node into right node */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; u++) { record.key = u; record.val = u + 9; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) + (INSERT_SPLIT_ROOT_NREC_REC / 4); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; @@ -3888,54 +3876,54 @@ test_update_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: redistribute 2 leaves in level 1 B-tree (r->l)"); /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u; record.val = u + 9; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force redistribution from left node into right node */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; u++) { record.key = u + INSERT_SPLIT_ROOT_NREC_REC; record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 9; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) + (INSERT_SPLIT_ROOT_NREC_REC / 4) - 1; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -3943,15 +3931,16 @@ test_update_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_update_level1_2leaf_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_update_level1_side_split * @@ -3970,16 +3959,15 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_update_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_update_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - H5B2_test_rec_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -3987,56 +3975,56 @@ test_update_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: split side leaf into 2 leaves in level 1 B-tree (l->r)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u + INSERT_SPLIT_ROOT_NREC_REC; record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 10; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force left node to split */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u; record.val = u + 10; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 31; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record.key = 64; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; @@ -4048,57 +4036,57 @@ test_update_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: split side leaf into 2 leaves in level 1 B-tree (r->l)"); /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u; record.val = u + 10; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force right node to split */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u + INSERT_SPLIT_ROOT_NREC_REC; record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 10; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 63; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record.key = 95; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -4106,15 +4094,16 @@ test_update_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_update_level1_side_split() */ - /*------------------------------------------------------------------------- * Function: test_update_level1_3leaf_redistrib * @@ -4135,17 +4124,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_update_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_update_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - H5B2_test_rec_t record; /* Record to insert into tree */ - H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -4153,99 +4141,99 @@ test_update_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: redistribute 3 leaves in level 1 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u + (INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = (2 * INSERT_SPLIT_ROOT_NREC_REC); - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force left node to split */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record.key = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert records to force middle node to redistribute */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); u++) { record.key = u + INSERT_SPLIT_ROOT_NREC_REC; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = (2 * INSERT_SPLIT_ROOT_NREC_REC) + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 52; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record.key = 107; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx.key = 0; idx.val = 0; - if(H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 2) + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1)) + if (idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 2) + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -4253,15 +4241,16 @@ test_update_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_update_level1_3leaf_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_update_level1_middle_split * @@ -4281,17 +4270,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_update_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_update_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - H5B2_test_rec_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ /* * Test inserting many records into v2 B-tree @@ -4299,78 +4287,78 @@ test_update_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: split middle leaf into 2 leaves in level 1 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { record.key = u + (INSERT_SPLIT_ROOT_NREC_REC * 2); record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = (2 * INSERT_SPLIT_ROOT_NREC_REC) + (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Force split from left node into right node */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 2); u++) { record.key = u; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 1; + bt2_stat.depth = 1; bt2_stat.nrecords = 3 * INSERT_SPLIT_ROOT_NREC_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 63; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record.key = 95; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record.key = 128; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ idx.key = 0; idx.val = 0; - if(H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC * 3)) + if (idx.key != (INSERT_SPLIT_ROOT_NREC_REC * 3)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); @@ -4378,15 +4366,16 @@ test_update_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_update_level1_middle_split() */ - /*------------------------------------------------------------------------- * Function: test_update_make_level2 * @@ -4402,19 +4391,18 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_update_make_level2(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_update_make_level2(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - H5B2_test_rec_t record; /* Record to insert into tree */ - H5B2_test_rec_t find; /* Record to find */ - H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ /* * Test inserting many records into v2 B-tree @@ -4422,508 +4410,509 @@ test_update_make_level2(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree update: make level 2 B-tree (l->r)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 internal nodes */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { - record.key = u + 2; /* Leave a gap for later insertion */ + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + record.key = u + 2; /* Leave a gap for later insertion */ record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ - for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { - record.key = u + 4; /* Leave a gap for later insertion */ + for (; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = u + 4; /* Leave a gap for later insertion */ record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 1347; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Add some extra records to left-most leaf */ record.key = 0; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR record.key = 1; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Add some extra records to middle leaf */ record.key = (INSERT_SPLIT_ROOT_NREC_REC * 9) + 2; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR record.key = (INSERT_SPLIT_ROOT_NREC_REC * 9) + 3; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Iterate over B-tree to check records have been inserted correctly */ idx.key = 0; idx.val = 0; - if(H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 4)) + if (idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 4)) TEST_ERROR /* Attempt to find non-existant record in level-2 B-tree */ /* (Should not be found, but not fail) */ find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to find existant record in root of level-2 B-tree */ find.key = 1347; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (1347 * 2)) + if (find.val != (1347 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 1347; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR /* Attempt to find existant record in internal node of level-2 B-tree */ find.key = 513; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (513 * 2)) + if (find.val != (513 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 513; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Attempt to find existant record in leaf of level-2 B-tree */ find.key = 555; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (555 * 2)) + if (find.val != (555 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 555; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Attempt to index non-existant record in level-2 B-tree */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in root of level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)1347, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)1347, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 1347) + if (find.key != 1347) TEST_ERROR - if(find.val != (1347 * 2)) + if (find.val != (1347 * 2)) TEST_ERROR /* Attempt to index existing record in internal node of level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)513, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)513, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 513) + if (find.key != 513) TEST_ERROR - if(find.val != (513 * 2)) + if (find.val != (513 * 2)) TEST_ERROR /* Attempt to index existing record in leaf of level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 555) + if (find.key != 555) TEST_ERROR - if(find.val != (555 * 2)) + if (find.val != (555 * 2)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; PASSED(); - /* * Test inserting many records into v2 B-tree */ TESTING("B-tree update: make level 2 B-tree (r->l)"); /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 internal nodes */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 1) - u; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ - for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { - record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 1) - (u +2); /* Leave a gap for later insertion */ + for (; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 1) - (u + 2); /* Leave a gap for later insertion */ record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 1344; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Add some extra records to right-most leaf */ record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 2; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 3; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Add some extra records to middle leaf */ record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)); record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 1; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Iterate over B-tree to check records have been inserted correctly */ idx.key = 0; idx.val = 0; - if(H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 4)) + if (idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 4)) TEST_ERROR /* Attempt to find non-existant record in level-2 B-tree */ /* (Should not be found, but not fail) */ find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to find existant record in root of level-2 B-tree */ find.key = 1344; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (1344 * 2)) + if (find.val != (1344 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 1344; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR /* Attempt to find existant record in internal node of level-2 B-tree */ find.key = 512; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (512 * 2)) + if (find.val != (512 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 512; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Attempt to find existant record in leaf of level-2 B-tree */ find.key = 555; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (555 * 2)) + if (find.val != (555 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 555; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Attempt to index non-existant record in level-2 B-tree */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in root of level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)1344, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)1344, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 1344) + if (find.key != 1344) TEST_ERROR - if(find.val != (1344 * 2)) + if (find.val != (1344 * 2)) TEST_ERROR /* Attempt to index existing record in internal node of level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)512, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)512, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 512) + if (find.key != 512) TEST_ERROR - if(find.val != (512 * 2)) + if (find.val != (512 * 2)) TEST_ERROR /* Attempt to index existing record in leaf of level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 555) + if (find.key != 555) TEST_ERROR - if(find.val != (555 * 2)) + if (find.val != (555 * 2)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; PASSED(); - /* * Test inserting many records into v2 B-tree */ TESTING("B-tree update: make level 2 B-tree (l+r->middle)"); /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert enough records to force root to split into 2 internal nodes */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 3) - u; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ - for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { - record.key = u - ((INSERT_SPLIT_ROOT_NREC_REC * 9) - 2); /* Leave a gap for later insertion */ + for (; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = u - ((INSERT_SPLIT_ROOT_NREC_REC * 9) - 2); /* Leave a gap for later insertion */ record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 2; + bt2_stat.depth = 2; bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record.key = 1345; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Add some extra records to right-most leaf */ record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 4; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 5; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Add some extra records to middle leaf */ record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 2; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 3; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Add some extra records to left-most leaf */ record.key = 0; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR record.key = 1; record.val = record.key * 2; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Iterate over B-tree to check records have been inserted correctly */ idx.key = 0; idx.val = 0; - if(H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 6)) + if (idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 6)) TEST_ERROR /* Attempt to find non-existant record in level-2 B-tree */ /* (Should not be found, but not fail) */ find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Attempt to find existant record in root of level-2 B-tree */ find.key = 1345; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (1345 * 2)) + if (find.val != (1345 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 1345; - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR /* Attempt to find existant record in internal node of level-2 B-tree */ find.key = 513; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (513 * 2)) + if (find.val != (513 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 513; - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Attempt to find existant record in leaf of level-2 B-tree */ find.key = 555; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (555 * 2)) + if (find.val != (555 * 2)) TEST_ERROR /* Check with B-tree */ record.key = 555; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR /* Attempt to index non-existant record in level-2 B-tree */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Attempt to index existing record in level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)1345, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)1345, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 1345) + if (find.key != 1345) TEST_ERROR - if(find.val != (1345 * 2)) + if (find.val != (1345 * 2)) TEST_ERROR /* Attempt to index existing record in internal node of level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)513, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)513, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 513) + if (find.key != 513) TEST_ERROR - if(find.val != (513 * 2)) + if (find.val != (513 * 2)) TEST_ERROR /* Attempt to index existing record in leaf of level-2 B-tree */ find.key = (hsize_t)-1; find.val = (hsize_t)-1; - if(H5B2_index(bt2, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != 555) + if (find.key != 555) TEST_ERROR - if(find.val != (555 * 2)) + if (find.val != (555 * 2)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -4931,15 +4920,16 @@ test_update_make_level2(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_update_make_level2() */ - /*------------------------------------------------------------------------- * Function: test_update_lots * @@ -4955,29 +4945,28 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_update_lots(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_update_lots(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - time_t curr_time; /* Current time, for seeding random number generator */ - H5B2_test_rec_t *records; /* Record #'s for random insertion */ - H5B2_test_rec_t record; /* Record to insert into tree */ - H5B2_test_rec_t modify; /* Modified value */ - H5B2_test_rec_t find; /* Record to find */ - H5B2_test_rec_t iter; /* Index within B-tree, for iterator */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - hsize_t nrec; /* Number of records in B-tree */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + time_t curr_time; /* Current time, for seeding random number generator */ + H5B2_test_rec_t *records; /* Record #'s for random insertion */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t iter; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t nrec; /* Number of records in B-tree */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ /* Initialize random number seed */ curr_time = HDtime(NULL); #ifdef QAK -curr_time = 1451342093; -HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); + curr_time = 1451342093; + HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); #endif /* QAK */ HDsrandom((unsigned)curr_time); @@ -4987,120 +4976,124 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); TESTING("B-tree update: create random level 4 B-tree"); /* Allocate space for the records */ - if(NULL == (records = (H5B2_test_rec_t *)HDmalloc(sizeof(H5B2_test_rec_t) * INSERT_MANY_REC))) + if (NULL == (records = (H5B2_test_rec_t *)HDmalloc(sizeof(H5B2_test_rec_t) * INSERT_MANY_REC))) TEST_ERROR /* Initialize record #'s */ - for(u = 0; u < INSERT_MANY_REC; u++) { + for (u = 0; u < INSERT_MANY_REC; u++) { records[u].key = u; records[u].val = u * 2; } /* end for */ /* Shuffle record #'s */ - for(u = 0; u < INSERT_MANY_REC; u++) { - H5B2_test_rec_t temp_rec; /* Temporary record */ - unsigned swap_idx; /* Location to swap with when shuffling */ + for (u = 0; u < INSERT_MANY_REC; u++) { + H5B2_test_rec_t temp_rec; /* Temporary record */ + unsigned swap_idx; /* Location to swap with when shuffling */ - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY_REC - u)) + u; - temp_rec = records[u]; - records[u] = records[swap_idx]; + swap_idx = ((unsigned)HDrandom() % (INSERT_MANY_REC - u)) + u; + temp_rec = records[u]; + records[u] = records[swap_idx]; records[swap_idx] = temp_rec; } /* end for */ /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert random records */ - for(u = 0; u < INSERT_MANY_REC; u++) { + for (u = 0; u < INSERT_MANY_REC; u++) { record = records[u]; - if(H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) + if (H5B2_update(bt2, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - bt2_stat.depth = 4; + bt2_stat.depth = 4; bt2_stat.nrecords = INSERT_MANY_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR file = -1; /* Re-open the file for the test */ - if(reopen_file(&file, &f, fapl) < 0) + if (reopen_file(&file, &f, fapl) < 0) TEST_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, f))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, f))) FAIL_STACK_ERROR /* Check up on B-tree after re-open */ - bt2_stat.depth = 4; + bt2_stat.depth = 4; bt2_stat.nrecords = INSERT_MANY_REC; - if(check_stats(bt2, &bt2_stat) < 0) + if (check_stats(bt2, &bt2_stat) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ iter.key = 0; iter.val = 0; - if(H5B2_iterate(bt2, iter_rec_cb, &iter) < 0) + if (H5B2_iterate(bt2, iter_rec_cb, &iter) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(iter.key != INSERT_MANY_REC) + if (iter.key != INSERT_MANY_REC) TEST_ERROR /* Attempt to find non-existant record in level-4 B-tree */ /* (Should not be found, but not fail) */ find.key = INSERT_MANY_REC * 2; find.val = (hsize_t)-1; - if(H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - if(find.val != (hsize_t)-1) + if (find.val != (hsize_t)-1) TEST_ERROR /* Find random records */ - for(u = 0; u < FIND_MANY_REC; u++) { + for (u = 0; u < FIND_MANY_REC; u++) { /* Pick random record */ find.key = (hsize_t)(HDrandom() % INSERT_MANY_REC); find.val = (hsize_t)-1; /* Attempt to find existant record in level-4 B-tree */ - if(H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) + if (H5B2_find(bt2, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR - if(find.val != (find.key * 2)) + if (find.val != (find.key * 2)) TEST_ERROR } /* end for */ /* Attempt to index non-existant record in level-4 B-tree, in increasing & decreasing order */ - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_MANY_REC * 3), find_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_INC, (hsize_t)(INSERT_MANY_REC * 3), find_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR - H5E_BEGIN_TRY { - ret = H5B2_index(bt2, H5_ITER_DEC, (hsize_t)(INSERT_MANY_REC * 3), find_rec_cb, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_index(bt2, H5_ITER_DEC, (hsize_t)(INSERT_MANY_REC * 3), find_rec_cb, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Find random records */ - for(u = 0; u < FIND_MANY_REC; u++) { - hsize_t idx; /* Record index */ + for (u = 0; u < FIND_MANY_REC; u++) { + hsize_t idx; /* Record index */ /* Pick random record */ idx = (hsize_t)(HDrandom() % INSERT_MANY_REC); @@ -5111,11 +5104,11 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Attempt to find existant record in level-4 B-tree */ /* (in increasing order) */ - if(H5B2_index(bt2, H5_ITER_INC, idx, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_INC, idx, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != idx) + if (find.key != idx) TEST_ERROR - if(find.val != (find.key * 2)) + if (find.val != (find.key * 2)) TEST_ERROR /* Reset find record */ @@ -5124,11 +5117,11 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); /* Attempt to find existant record in level-4 B-tree */ /* (in decreasing order) */ - if(H5B2_index(bt2, H5_ITER_DEC, idx, index_rec_cb, &find) < 0) + if (H5B2_index(bt2, H5_ITER_DEC, idx, index_rec_cb, &find) < 0) FAIL_STACK_ERROR - if(find.key != (INSERT_MANY_REC - (idx + 1))) + if (find.key != (INSERT_MANY_REC - (idx + 1))) TEST_ERROR - if(find.val != (find.key * 2)) + if (find.val != (find.key * 2)) TEST_ERROR } /* end for */ @@ -5137,30 +5130,30 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); TESTING("B-tree update: update record in level 4 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR record.key = INSERT_MANY_REC / 2; modify.key = INSERT_MANY_REC / 2; modify.val = record.key * 3; - if(H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) + if (H5B2_update(bt2, &record, modify_rec_cb, &modify) < 0) FAIL_STACK_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != INSERT_MANY_REC) + if (nrec != INSERT_MANY_REC) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -5171,17 +5164,18 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); error: HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; HDfree(records); return 1; } /* test_update_lots() */ - /*------------------------------------------------------------------------- * Function: test_remove_basic * @@ -5196,45 +5190,46 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_basic(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_basic(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + herr_t ret; /* Generic error return value */ /* Record removal tests */ TESTING("B-tree remove: record from empty B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != 0) + if (nrec != 0) TEST_ERROR /* Attempt to remove a record from a B-tree with no records */ record = 0; - H5E_BEGIN_TRY { - ret = H5B2_remove(bt2, &record, NULL, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_remove(bt2, &record, NULL, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR PASSED(); @@ -5242,37 +5237,39 @@ test_remove_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: non-existant record from 1 record B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert one record into B-tree */ record = 42; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != 1) + if (nrec != 1) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Attempt to remove a non-existant record from a B-tree with 1 record */ record = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5B2_remove(bt2, &record, NULL, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR PASSED(); @@ -5281,32 +5278,32 @@ test_remove_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: existant record from 1 record B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - record = 42; + record = 42; rrecord = 0; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 42) + if (rrecord != 42) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != 0) + if (nrec != 0) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the root node has been freed */ - if(H5F_addr_defined(root_addr)) + if (H5F_addr_defined(root_addr)) TEST_ERROR PASSED(); @@ -5315,29 +5312,29 @@ test_remove_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: adding records to B-tree after removal"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Insert several records into B-tree again */ record = 42; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR record = 34; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR record = 56; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR record = 38; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != 4) + if (nrec != 4) TEST_ERROR PASSED(); @@ -5346,15 +5343,17 @@ test_remove_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: non-existant record from level-0 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR record = 0; - H5E_BEGIN_TRY { - ret = H5B2_remove(bt2, &record, NULL, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_remove(bt2, &record, NULL, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR PASSED(); @@ -5363,116 +5362,116 @@ test_remove_basic(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: mult. existant records from level-0 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - record = 42; + record = 42; rrecord = 0; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 42) + if (rrecord != 42) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != 3) + if (nrec != 3) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the root node has not been freed */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR - record = 34; + record = 34; rrecord = 0; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 34) + if (rrecord != 34) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != 2) + if (nrec != 2) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the root node has not been freed */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR - record = 56; + record = 56; rrecord = 0; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 56) + if (rrecord != 56) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != 1) + if (nrec != 1) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the root node has not been freed */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR - record = 38; + record = 38; rrecord = 0; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 38) + if (rrecord != 38) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != 0) + if (nrec != 0) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the root node has been freed */ - if(H5F_addr_defined(root_addr)) + if (H5F_addr_defined(root_addr)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -5480,15 +5479,16 @@ test_remove_basic(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_basic() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_noredistrib * @@ -5503,69 +5503,70 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ /* B-tree record removal tests */ TESTING("B-tree remove: non-existant record from level-1 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 3 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Attempt to remove a non-existant record from a B-tree with 1 record */ record = (INSERT_SPLIT_ROOT_NREC * 2) + 1; - H5E_BEGIN_TRY { - ret = H5B2_remove(bt2, &record, NULL, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_remove(bt2, &record, NULL, NULL); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC*2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR PASSED(); @@ -5574,42 +5575,42 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: record from right leaf of level-1 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 94; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 94; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC * 2) - 2; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 0; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - 2)) + if (rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - 2)) TEST_ERROR /* Make certain that the leaf nodes didn't redistribute */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 94; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 94; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - 1)) TEST_ERROR PASSED(); @@ -5618,36 +5619,36 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: record from left leaf of level-1 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ record = 0; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 1; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 0) + if (rrecord != 0) TEST_ERROR /* Make certain that the leaf nodes didn't redistribute */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 94; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 94; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - 2)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - 2)) TEST_ERROR PASSED(); @@ -5656,45 +5657,45 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: record from middle leaf of level-1 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check up on B-tree */ record = INSERT_SPLIT_ROOT_NREC; - if(check_node_depth(bt2, &record, (unsigned)0) < 0) + if (check_node_depth(bt2, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 0; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != INSERT_SPLIT_ROOT_NREC) + if (rrecord != INSERT_SPLIT_ROOT_NREC) TEST_ERROR /* Make certain that the leaf nodes didn't redistribute */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 94; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 94; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - 3)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - 3)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -5702,15 +5703,16 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_noredistrib() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_redistrib * @@ -5725,91 +5727,90 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + unsigned u; /* Local index variable */ /* More complex record removals */ TESTING("B-tree remove: redistribute 2 leaves in level-1 B-tree (r->l)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 3 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 94; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 94; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove enough records from right leaf of a level-1 B-tree to force redistribution */ - for(u = 0; u < 8; u++) { - record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); + for (u = 0; u < 8; u++) { + record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 90; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 90; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR PASSED(); @@ -5818,34 +5819,34 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: redistribute 2 leaves in level-1 B-tree (l->r)"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - for(u = 0; u < 39; u++) { - record = u; + for (u = 0; u < 39; u++) { + record = u; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != u) + if (rrecord != u) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 2) - 8) - (u + 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 2) - 8) - (u + 1))) TEST_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 64; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 64; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 90; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 90; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR PASSED(); @@ -5854,43 +5855,43 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: redistribute 3 leaves in level-1 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - for(u = 0; u < 2; u++) { - record = INSERT_SPLIT_ROOT_NREC + 2 + u; + for (u = 0; u < 2; u++) { + record = INSERT_SPLIT_ROOT_NREC + 2 + u; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (INSERT_SPLIT_ROOT_NREC + 2 + u)) + if (rrecord != (INSERT_SPLIT_ROOT_NREC + 2 + u)) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((((INSERT_SPLIT_ROOT_NREC * 2) - 47)) - (u + 1))) + if (nrec != ((((INSERT_SPLIT_ROOT_NREC * 2) - 47)) - (u + 1))) TEST_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 64; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 64; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 91; /* Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 91; /* Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -5898,15 +5899,16 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_2leaf_merge * @@ -5921,92 +5923,91 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: merge 2 leaves to 1 in level-1 B-tree (r->l)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 3 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 94; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 94; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove enough records from right leaf of a level-1 B-tree to force redistribution */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 4); u++) { - record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC / 4); u++) { + record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR } /* end for */ /* Check record values in root of B-tree */ ninfo.depth = 1; - ninfo.nrec = 1; - record = 62; /* Left record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 62; /* Left record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR PASSED(); @@ -6015,60 +6016,60 @@ test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: merge 2 leaves to 1 in level-1 B-tree (l->r)"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Fill B-tree back up */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC / 4); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC / 4); u++) { record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 94; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 94; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Remove records */ - for(u = 0; u < ((3 * INSERT_SPLIT_ROOT_NREC) / 4) - 1; u++) { - record = u; + for (u = 0; u < ((3 * INSERT_SPLIT_ROOT_NREC) / 4) - 1; u++) { + record = u; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != u) + if (rrecord != u) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR } /* end for */ /* Check record values in root of B-tree */ ninfo.depth = 1; - ninfo.nrec = 1; - record = 94; /* Left record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 94; /* Left record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -6076,15 +6077,16 @@ test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_2leaf_merge() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_3leaf_merge * @@ -6099,101 +6101,100 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level1_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level1_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: merge 3 leaves to 2 in level-1 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 3 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 94; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 94; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove enough records from middle leaf of a level-1 B-tree to force merge */ - for(u = 0; u < ((5 * INSERT_SPLIT_ROOT_NREC) / 6) - 1; u++) { - record = ((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1); + for (u = 0; u < ((5 * INSERT_SPLIT_ROOT_NREC) / 6) - 1; u++) { + record = ((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1))) + if (rrecord != (((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR } /* end for */ /* Check record values in root of B-tree */ ninfo.depth = 1; - ninfo.nrec = 1; - record = 37; /* Only record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 37; /* Only record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -6201,15 +6202,16 @@ test_remove_level1_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_3leaf_merge() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_promote * @@ -6224,105 +6226,104 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from right leaf of level-1 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 5 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 4); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 4); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 125; /* Center-Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 188; /* Center-Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 4; - record = 220; /* Right-most record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 4; + record = 220; /* Right-most record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 4)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 4)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove record from root node of a level-1 B-tree to force promotion from right leaf */ - record = 220; + record = 220; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 220) + if (rrecord != 220) TEST_ERROR /* Check record values in root of B-tree */ - record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 125; /* Center-Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 188; /* Center-Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 4; - record = 221; /* Right-most record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 4; + record = 221; /* Right-most record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 4) - 1) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 4) - 1) TEST_ERROR PASSED(); @@ -6335,40 +6336,40 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: promote from left leaf of level-1 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - record = 62; + record = 62; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 62) + if (rrecord != 62) TEST_ERROR /* Check record values in root of B-tree */ - record = 63; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 63; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 125; /* Center-Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 188; /* Center-Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 4; - record = 221; /* Right-most record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 4; + record = 221; /* Right-most record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 4) - 2) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 4) - 2) TEST_ERROR PASSED(); @@ -6377,49 +6378,49 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: promote from middle leaf of level-1 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - record = 125; + record = 125; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 125) + if (rrecord != 125) TEST_ERROR /* Check record values in root of B-tree */ - record = 63; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 63; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 126; /* Center-Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 126; /* Center-Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR - record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 188; /* Center-Right record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 4; - record = 221; /* Right-most record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 4; + record = 221; /* Right-most record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 4) - 3) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 4) - 3) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -6427,15 +6428,16 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_promote() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_promote_2leaf_redistrib * @@ -6451,122 +6453,122 @@ error: */ static unsigned test_remove_level1_promote_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from leaf of level-1 B-tree w/2 node redistrib"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 3 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 94; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 94; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove record from root node of a level-1 B-tree to force promotion from right leaf */ /* Remove records from right leaf until its ready to redistribute */ - for(u = 0; u < 7; u++) { - record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); + for (u = 0; u < 7; u++) { + record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR } /* end for */ - record = 94; + record = 94; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 94) + if (rrecord != 94) TEST_ERROR /* Check record values in root of B-tree */ - record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 90; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 90; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 8) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 8) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -6574,15 +6576,16 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_promote_2leaf_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_promote_3leaf_redistrib * @@ -6598,122 +6601,122 @@ error: */ static unsigned test_remove_level1_promote_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from leaf of level-1 B-tree w/3 node redistrib"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 3 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 94; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 94; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove record from root node of a level-1 B-tree to force promotion from middle leaf */ /* Remove records from right leaf until its ready to redistribute */ - for(u = 0; u < 7; u++) { - record = 63 + u; + for (u = 0; u < 7; u++) { + record = 63 + u; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (63 + u)) + if (rrecord != (63 + u)) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR } /* end for */ - record = 62; + record = 62; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 62) + if (rrecord != 62) TEST_ERROR /* Check record values in root of B-tree */ - record = 39; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 39; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 86; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 86; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 8) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 8) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -6721,15 +6724,16 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_promote_3leaf_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_promote_2leaf_merge * @@ -6745,119 +6749,119 @@ error: */ static unsigned test_remove_level1_promote_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from leaf of level-1 B-tree w/2->1 merge"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 3 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 94; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 94; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove record from root node of a level-1 B-tree to force promotion from right leaf */ /* Remove records from right leaf until its ready to merge */ - for(u = 0; u < 14; u++) { - record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); + for (u = 0; u < 14; u++) { + record = (INSERT_SPLIT_ROOT_NREC * 2) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (rrecord != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR } /* end for */ - record = 87; + record = 87; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 87) + if (rrecord != 87) TEST_ERROR /* Check record values in root of B-tree */ ninfo.depth = 1; - ninfo.nrec = 1; - record = 62; /* Middle record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 62; /* Middle record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 15) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 15) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -6865,15 +6869,16 @@ test_remove_level1_promote_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_promote_2leaf_merge() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_promote_3leaf_merge * @@ -6889,119 +6894,119 @@ error: */ static unsigned test_remove_level1_promote_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from leaf of level-1 B-tree w/3->2 merge"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 leaves */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 2); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, &record, (unsigned)1) < 0) + record = 62; /* Left-most record in root node */ + if (check_node_depth(bt2, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; - ninfo.nrec = 2; - record = 94; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 94; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove record from root node of a level-1 B-tree to force promotion from middle leaf */ /* Remove records from middle leaf until it's ready to merge */ - for(u = 0; u < 50; u++) { - record = ((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1); + for (u = 0; u < 50; u++) { + record = ((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1))) + if (rrecord != (((3 * INSERT_SPLIT_ROOT_NREC) / 2) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 2) - (u + 1))) TEST_ERROR } /* end for */ - record = 25; + record = 25; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 25) + if (rrecord != 25) TEST_ERROR /* Check record values in root of B-tree */ ninfo.depth = 1; - ninfo.nrec = 1; - record = 37; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 37; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 51) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 2) - 51) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -7009,15 +7014,16 @@ test_remove_level1_promote_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_promote_3leaf_merge() */ - /*------------------------------------------------------------------------- * Function: test_remove_level1_collapse * @@ -7032,114 +7038,113 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: collapse level-1 B-tree back to level-0"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-1 B-tree with 2 leaves */ - for(u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { + for (u = 0; u < INSERT_SPLIT_ROOT_NREC; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ ninfo.depth = 1; - ninfo.nrec = 1; - record = 31; /* Middle record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 31; /* Middle record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != INSERT_SPLIT_ROOT_NREC) + if (nrec != INSERT_SPLIT_ROOT_NREC) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove records from B-tree to force a single leaf for the B-tree */ - for(u = 0; u < 14; u++) { - record = INSERT_SPLIT_ROOT_NREC - (u + 1); + for (u = 0; u < 14; u++) { + record = INSERT_SPLIT_ROOT_NREC - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (INSERT_SPLIT_ROOT_NREC - (u + 1))) + if (rrecord != (INSERT_SPLIT_ROOT_NREC - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC - (u + 1))) + if (nrec != (INSERT_SPLIT_ROOT_NREC - (u + 1))) TEST_ERROR } /* end for */ /* Check record values in root of B-tree */ ninfo.depth = 0; - ninfo.nrec = (uint16_t)(INSERT_SPLIT_ROOT_NREC - u); - record = 31; /* Middle record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = (uint16_t)(INSERT_SPLIT_ROOT_NREC - u); + record = 31; /* Middle record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC - u)) + if (nrec != (INSERT_SPLIT_ROOT_NREC - u)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -7147,15 +7152,16 @@ test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level1_collapse() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_promote * @@ -7170,97 +7176,96 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from right internal of level-2 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check information about record in right internal node */ ninfo.depth = 1; - ninfo.nrec = 14; - record = 2960; /* Record in right internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 14; + record = 2960; /* Record in right internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Attempt to remove record from right internal node of a level-2 B-tree to force promotion */ - record = 2960; + record = 2960; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 2960) + if (rrecord != 2960) TEST_ERROR /* Check information about record promoted into right internal node */ ninfo.depth = 1; - ninfo.nrec = 14; - record = 2961; /* Record in right internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 14; + record = 2961; /* Record in right internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59)) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59)) TEST_ERROR PASSED(); @@ -7269,38 +7274,38 @@ test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: promote from left internal of level-2 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check information about record in left internal node */ ninfo.depth = 1; - ninfo.nrec = 29; - record = 1133; /* Record in left internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 29; + record = 1133; /* Record in left internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR - record = 1133; + record = 1133; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 1133) + if (rrecord != 1133) TEST_ERROR /* Check information about record in left internal node */ ninfo.depth = 1; - ninfo.nrec = 29; - record = 1134; /* Record in left internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 29; + record = 1134; /* Record in left internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 1) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 1) TEST_ERROR PASSED(); @@ -7309,38 +7314,38 @@ test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: promote from middle internal of level-2 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check information about record in middle internal node */ ninfo.depth = 1; - ninfo.nrec = 14; - record = 2267; /* Record in middle internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 14; + record = 2267; /* Record in middle internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR - record = 2267; + record = 2267; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 2267) + if (rrecord != 2267) TEST_ERROR /* Check information about record in middle internal node */ ninfo.depth = 1; - ninfo.nrec = 14; - record = 2268; /* Record in middle internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 14; + record = 2268; /* Record in middle internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 2) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 2) TEST_ERROR PASSED(); @@ -7349,82 +7354,82 @@ test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree remove: promote record from root of level-2 B-tree"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check information about record in root node */ ninfo.depth = 2; - ninfo.nrec = 2; - record = 1889; /* Left record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 1889; /* Left record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR - record = 1889; + record = 1889; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 1889) + if (rrecord != 1889) TEST_ERROR /* Check information about record in root node */ ninfo.depth = 2; - ninfo.nrec = 2; - record = 1890; /* Left record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 1890; /* Left record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 3) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 3) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check information about record in root node */ ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR - record = 2834; + record = 2834; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 2834) + if (rrecord != 2834) TEST_ERROR /* Check information about record in root node */ ninfo.depth = 2; - ninfo.nrec = 2; - record = 2835; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2835; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 4) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 4) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -7432,15 +7437,16 @@ test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_promote() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_promote_2internal_redistrib * @@ -7456,124 +7462,125 @@ error: */ static unsigned test_remove_level2_promote_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from right internal of level-2 B-tree w/redistrib"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 1; - ninfo.nrec = 14; - record = 3685; /* Right-most record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 14; + record = 3685; /* Right-most record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR - /* Attempt to remove record from right internal node of a level-2 B-tree to force promotion w/redistribution */ - for(u = 0; u < 8; u++) { - record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1); + /* Attempt to remove record from right internal node of a level-2 B-tree to force promotion + * w/redistribution */ + for (u = 0; u < 8; u++) { + record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (((INSERT_SPLIT_ROOT_NREC * 59) + 1)- (u + 1))) + if (rrecord != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR } /* end for */ - record = 3685; + record = 3685; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 3685) + if (rrecord != 3685) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 1; - ninfo.nrec = 14; - record = 3681; /* Right-most record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 14; + record = 3681; /* Right-most record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 8) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 8) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -7581,15 +7588,16 @@ test_remove_level2_promote_2internal_redistrib(hid_t fapl, const H5B2_create_t * return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_promote_2internal_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_3promote_internal_redistrib * @@ -7605,124 +7613,125 @@ error: */ static unsigned test_remove_level2_promote_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from left internal of level-2 B-tree w/redistrib"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 1; - ninfo.nrec = 29; - record = 62; /* Left-most record in left node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 29; + record = 62; /* Left-most record in left node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR - /* Attempt to remove record from left internal node of a level-2 B-tree to force promotion w/redistribution */ - for(u = 0; u < 38; u++) { - record = 63 + u; + /* Attempt to remove record from left internal node of a level-2 B-tree to force promotion + * w/redistribution */ + for (u = 0; u < 38; u++) { + record = 63 + u; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (63 + u)) + if (rrecord != (63 + u)) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR } /* end for */ - record = 62; + record = 62; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 62) + if (rrecord != 62) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 1; - ninfo.nrec = 29; - record = 49; /* Left-most record in left node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 29; + record = 49; /* Left-most record in left node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 38) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 38) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -7730,15 +7739,16 @@ test_remove_level2_promote_3internal_redistrib(hid_t fapl, const H5B2_create_t * return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_promote_3internal_redistrib() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_promote_2internal_merge * @@ -7754,125 +7764,126 @@ error: */ static unsigned test_remove_level2_promote_2internal_merge(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from right internal of level-2 B-tree w/merge"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check information about record in right internal node */ ninfo.depth = 1; - ninfo.nrec = 14; - record = 3685; /* Right-most record in right internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 14; + record = 3685; /* Right-most record in right internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR - /* Attempt to remove record from right internal node of a level-2 B-tree to force promotion w/redistribution */ - for(u = 0; u < 15; u++) { - record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1); + /* Attempt to remove record from right internal node of a level-2 B-tree to force promotion + * w/redistribution */ + for (u = 0; u < 15; u++) { + record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (((INSERT_SPLIT_ROOT_NREC * 59) + 1)- (u + 1))) + if (rrecord != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR } /* end for */ /* Force merge by promoting current right-most record */ - record = 3678; + record = 3678; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 3678) + if (rrecord != 3678) TEST_ERROR /* Check information about record in right internal node */ ninfo.depth = 1; - ninfo.nrec = 13; - record = 3653; /* Right-most record in right internal node (now) */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 13; + record = 3653; /* Right-most record in right internal node (now) */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 15) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 15) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -7880,15 +7891,16 @@ test_remove_level2_promote_2internal_merge(hid_t fapl, const H5B2_create_t *cpar return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_promote_2internal_merge() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_3promote_internal_merge * @@ -7904,125 +7916,126 @@ error: */ static unsigned test_remove_level2_promote_3internal_merge(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: promote from middle internal of level-2 B-tree w/merge"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check information about record in left internal node */ ninfo.depth = 1; - ninfo.nrec = 29; - record = 62; /* Left-most record in left internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 29; + record = 62; /* Left-most record in left internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR - /* Attempt to remove record from left internal node of a level-2 B-tree to force promotion w/redistribution */ - for(u = 0; u < 112; u++) { - record = 48 + u; + /* Attempt to remove record from left internal node of a level-2 B-tree to force promotion + * w/redistribution */ + for (u = 0; u < 112; u++) { + record = 48 + u; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (48 + u)) + if (rrecord != (48 + u)) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR } /* end for */ /* Force merge of left-most internal nodes by promotion */ - record = 25; + record = 25; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != 25) + if (rrecord != 25) TEST_ERROR /* Check information about record in left internal node */ ninfo.depth = 1; - ninfo.nrec = 28; - record = 37; /* Left-most record in left internal node (now) */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 28; + record = 37; /* Left-most record in left internal node (now) */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 112) + if (nrec != (INSERT_SPLIT_ROOT_NREC * 59) - 112) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -8030,15 +8043,16 @@ test_remove_level2_promote_3internal_merge(hid_t fapl, const H5B2_create_t *cpar return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_promote_3internal_merge() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_2internal_merge_left * @@ -8054,100 +8068,100 @@ error: */ static unsigned test_remove_level2_2internal_merge_left(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: merge 2 internal nodes to 1 in level-2 B-tree (l->r)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove records from a level-2 B-tree to force 2 internal nodes to merge */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 21) + 15); u++) { - record = u; + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 21) + 15); u++) { + record = u; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != u) + if (rrecord != u) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR } /* end for */ /* Check status of B-tree */ ninfo.depth = 2; - ninfo.nrec = 1; - record = 2834; /* Middle record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 2834; /* Middle record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -8155,15 +8169,16 @@ test_remove_level2_2internal_merge_left(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_2internal_merge_left() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_2internal_merge_right * @@ -8179,100 +8194,100 @@ error: */ static unsigned test_remove_level2_2internal_merge_right(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) + const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: merge 2 internal nodes to 1 in level-2 B-tree (r->l)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove records from a level-2 B-tree to force 2 internal nodes to merge */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 5) + 17); u++) { - record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1); + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 5) + 17); u++) { + record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (rrecord != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u+ 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR } /* end for */ /* Check status of B-tree */ ninfo.depth = 2; - ninfo.nrec = 1; - record = 1889; /* Middle record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 1889; /* Middle record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -8280,15 +8295,16 @@ test_remove_level2_2internal_merge_right(hid_t fapl, const H5B2_create_t *cparam return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_2internal_merge_right() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_3internal_merge * @@ -8303,101 +8319,101 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level2_3internal_merge(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level2_3internal_merge(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: merge 3 internal nodes to 2 in level-2 B-tree"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Attempt to remove record from middle internal node of a level-2 B-tree to force promotion w/redistribution */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 23) + 15); u++) { - record = (INSERT_SPLIT_ROOT_NREC * 20) + u; + /* Attempt to remove record from middle internal node of a level-2 B-tree to force promotion + * w/redistribution */ + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 23) + 15); u++) { + record = (INSERT_SPLIT_ROOT_NREC * 20) + u; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != ((INSERT_SPLIT_ROOT_NREC * 20) + u)) + if (rrecord != ((INSERT_SPLIT_ROOT_NREC * 20) + u)) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR } /* end for */ /* Check status of B-tree */ ninfo.depth = 2; - ninfo.nrec = 1; - record = 1196; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 1196; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -8405,15 +8421,16 @@ test_remove_level2_3internal_merge(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_3internal_merge() */ - /*------------------------------------------------------------------------- * Function: test_remove_level2_collapse_right * @@ -8428,101 +8445,100 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_remove_level2_collapse_right(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_remove_level2_collapse_right(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - hsize_t nrec; /* Number of records in B-tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + hsize_t nrec; /* Number of records in B-tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ TESTING("B-tree remove: collapse level-2 B-tree back to level-1 (r->l)"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check record values in root of B-tree */ - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, &record, (unsigned)2) < 0) + record = 1889; /* Left record in root node */ + if (check_node_depth(bt2, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; - ninfo.nrec = 2; - record = 2834; /* Right record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 2834; /* Right record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) + if (nrec != ((INSERT_SPLIT_ROOT_NREC * 59) + 1)) TEST_ERROR /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(!H5F_addr_defined(root_addr)) + if (!H5F_addr_defined(root_addr)) TEST_ERROR /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to remove records from a level-2 B-tree to force back to level-1 */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 34) + 17; u++) { - record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1); + for (u = 0; u < (INSERT_SPLIT_ROOT_NREC * 34) + 17; u++) { + record = ((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1); rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(record != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (record != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) + if (nrec != (((INSERT_SPLIT_ROOT_NREC * 59) + 1) - (u + 1))) TEST_ERROR } /* end for */ /* Check up on B-tree */ - if(H5B2_stat_info(bt2, &bt2_stat) < 0) + if (H5B2_stat_info(bt2, &bt2_stat) < 0) FAIL_STACK_ERROR - if(bt2_stat.depth != 1) + if (bt2_stat.depth != 1) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -8530,15 +8546,16 @@ test_remove_level2_collapse_right(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_remove_level2_collapse_right() */ - /*------------------------------------------------------------------------- * Function: gen_l4_btree2 * @@ -8553,67 +8570,68 @@ error: *------------------------------------------------------------------------- */ static unsigned -gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam, - haddr_t *bt2_addr, const hsize_t *records) +gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam, haddr_t *bt2_addr, + const hsize_t *records) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - hsize_t record; /* Record to insert into tree */ - unsigned u; /* Local index variable */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + hsize_t record; /* Record to insert into tree */ + unsigned u; /* Local index variable */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, bt2_addr) < 0) TEST_ERROR /* Insert random records */ - for(u = 0; u < INSERT_MANY; u++) { + for (u = 0; u < INSERT_MANY; u++) { record = records[u]; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - if(H5B2_stat_info(bt2, &bt2_stat) < 0) + if (H5B2_stat_info(bt2, &bt2_stat) < 0) FAIL_STACK_ERROR - if(bt2_stat.depth != 4) + if (bt2_stat.depth != 4) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* gen_l4_btree2() */ - /*------------------------------------------------------------------------- * Function: test_remove_lots * @@ -8632,29 +8650,29 @@ error: static unsigned test_remove_lots(const char *env_h5_drvr, hid_t fapl, const H5B2_create_t *cparam) { - hid_t file = -1; /* File ID */ - char filename[1024]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - int fd = -1; /* File descriptor */ - h5_stat_t sb; /* Stat buffer for file */ - void *file_data = NULL; /* Copy of file data */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t rrecord; /* Record to remove from tree */ - haddr_t root_addr; /* Address of root of B-tree created */ - time_t curr_time; /* Current time, for seeding random number generator */ - hsize_t *records; /* Record #'s for random insertion */ - unsigned u; /* Local index variable */ - unsigned rem_idx; /* Location to remove */ - hsize_t nrec; /* Number of records in B-tree */ - hbool_t single_file_vfd; /* Whether VFD used stores data in a single file */ + hid_t file = -1; /* File ID */ + char filename[1024]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + int fd = -1; /* File descriptor */ + h5_stat_t sb; /* Stat buffer for file */ + void * file_data = NULL; /* Copy of file data */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t rrecord; /* Record to remove from tree */ + haddr_t root_addr; /* Address of root of B-tree created */ + time_t curr_time; /* Current time, for seeding random number generator */ + hsize_t * records; /* Record #'s for random insertion */ + unsigned u; /* Local index variable */ + unsigned rem_idx; /* Location to remove */ + hsize_t nrec; /* Number of records in B-tree */ + hbool_t single_file_vfd; /* Whether VFD used stores data in a single file */ /* Initialize random number seed */ curr_time = HDtime(NULL); #ifdef QAK -curr_time = 1163537969; -HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); + curr_time = 1163537969; + HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); #endif /* QAK */ HDsrandom((unsigned)curr_time); @@ -8663,53 +8681,54 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); */ /* Allocate space for the records */ - if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY))) + if (NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY))) TEST_ERROR /* Initialize record #'s */ - for(u = 0; u < INSERT_MANY; u++) + for (u = 0; u < INSERT_MANY; u++) records[u] = u; /* Shuffle record #'s */ - for(u = 0; u < INSERT_MANY; u++) { - hsize_t temp_rec; /* Temporary record */ - unsigned swap_idx; /* Location to swap with when shuffling */ + for (u = 0; u < INSERT_MANY; u++) { + hsize_t temp_rec; /* Temporary record */ + unsigned swap_idx; /* Location to swap with when shuffling */ - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; - temp_rec = records[u]; - records[u] = records[swap_idx]; + swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + temp_rec = records[u]; + records[u] = records[swap_idx]; records[swap_idx] = temp_rec; } /* end for */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Generate the v2 B-tree to test */ - if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records)) + if (gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records)) TEST_ERROR /* Check for VFD which stores data in multiple files */ - single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")); - if(single_file_vfd) { + single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && + HDstrcmp(env_h5_drvr, "family")); + if (single_file_vfd) { /* Make a copy of the file in memory, in order to speed up deletion testing */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDONLY)) < 0) + if ((fd = HDopen(filename, O_RDONLY)) < 0) TEST_ERROR /* Retrieve the file's size */ - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) TEST_ERROR /* Allocate space for the file data */ - if(NULL == (file_data = HDmalloc((size_t)sb.st_size))) + if (NULL == (file_data = HDmalloc((size_t)sb.st_size))) TEST_ERROR /* Read file's data into memory */ - if(HDread(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size) + if (HDread(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size) TEST_ERROR /* Close the file */ - if(HDclose(fd) < 0) + if (HDclose(fd) < 0) TEST_ERROR fd = -1; } /* end if */ @@ -8718,353 +8737,345 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); TESTING("B-tree remove: create random level 4 B-tree and delete all records in random order"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Re-shuffle record #'s */ - for(u = 0; u < INSERT_MANY; u++) { - hsize_t temp_rec; /* Temporary record */ - unsigned swap_idx; /* Location to swap with when shuffling */ + for (u = 0; u < INSERT_MANY; u++) { + hsize_t temp_rec; /* Temporary record */ + unsigned swap_idx; /* Location to swap with when shuffling */ - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; - temp_rec = records[u]; - records[u] = records[swap_idx]; + swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + temp_rec = records[u]; + records[u] = records[swap_idx]; records[swap_idx] = temp_rec; } /* end for */ /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, f))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ - for(u = 0; u < INSERT_MANY; u++) { - record = records[u]; + for (u = 0; u < INSERT_MANY; u++) { + record = records[u]; rrecord = HSIZET_MAX; - if(H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) + if (H5B2_remove(bt2, &record, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != records[u]) + if (rrecord != records[u]) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_MANY - (u + 1))) + if (nrec != (INSERT_MANY - (u + 1))) TEST_ERROR } /* end for */ /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(H5F_addr_defined(root_addr)) + if (H5F_addr_defined(root_addr)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); - - /* Check for VFD which stores data in multiple files */ - if(single_file_vfd) { + if (single_file_vfd) { /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ - if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size) + if (HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size) TEST_ERROR /* Close the file */ - if(HDclose(fd) < 0) + if (HDclose(fd) < 0) TEST_ERROR fd = -1; } /* end if */ else { /* Re-generate the v2 B-tree to test */ - if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records)) + if (gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records)) TEST_ERROR } /* end else */ - /* Print banner for this test */ TESTING("B-tree remove: create random level 4 B-tree and delete all records by index, in random order"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, f))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ - for(u = 0; u < INSERT_MANY; u++) { + for (u = 0; u < INSERT_MANY; u++) { /* Pick a record index to remove from randomly */ rem_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)); rrecord = HSIZET_MAX; /* Remove random record */ - if(H5B2_remove_by_idx(bt2, H5_ITER_INC, (hsize_t)rem_idx, remove_cb, &rrecord) < 0) + if (H5B2_remove_by_idx(bt2, H5_ITER_INC, (hsize_t)rem_idx, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord >= INSERT_MANY) + if (rrecord >= INSERT_MANY) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_MANY - (u + 1))) + if (nrec != (INSERT_MANY - (u + 1))) TEST_ERROR } /* end for */ /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(H5F_addr_defined(root_addr)) + if (H5F_addr_defined(root_addr)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); - - /* Check for VFD which stores data in multiple files */ - if(single_file_vfd) { + if (single_file_vfd) { /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ - if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size) + if (HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size) TEST_ERROR /* Close the file */ - if(HDclose(fd) < 0) + if (HDclose(fd) < 0) TEST_ERROR fd = -1; } /* end if */ else { /* Re-generate the v2 B-tree to test */ - if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records)) + if (gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records)) TEST_ERROR } /* end else */ - - /* Print banner for this test */ - TESTING("B-tree remove: create random level 4 B-tree and delete all records by index, in increasing order"); + TESTING( + "B-tree remove: create random level 4 B-tree and delete all records by index, in increasing order"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, f))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ - for(u = 0; u < INSERT_MANY; u++) { + for (u = 0; u < INSERT_MANY; u++) { /* Remove first record */ rrecord = HSIZET_MAX; - if(H5B2_remove_by_idx(bt2, H5_ITER_INC, (hsize_t)0, remove_cb, &rrecord) < 0) + if (H5B2_remove_by_idx(bt2, H5_ITER_INC, (hsize_t)0, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != u) + if (rrecord != u) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_MANY - (u + 1))) + if (nrec != (INSERT_MANY - (u + 1))) TEST_ERROR } /* end for */ /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(H5F_addr_defined(root_addr)) + if (H5F_addr_defined(root_addr)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); - - /* Check for VFD which stores data in multiple files */ - if(single_file_vfd) { + if (single_file_vfd) { /* Re-write the file's data with the copy in memory */ /* Open the file just created */ - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) TEST_ERROR /* Write file's data from memory */ - if(HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size) + if (HDwrite(fd, file_data, (size_t)sb.st_size) < (ssize_t)sb.st_size) TEST_ERROR /* Close the file */ - if(HDclose(fd) < 0) + if (HDclose(fd) < 0) TEST_ERROR fd = -1; } /* end if */ else { /* Re-generate the v2 B-tree to test */ - if(gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records)) + if (gen_l4_btree2(filename, fapl, cparam, &bt2_addr, records)) TEST_ERROR } /* end else */ - - /* Print banner for this test */ - TESTING("B-tree remove: create random level 4 B-tree and delete all records by index, in decreasing order"); + TESTING( + "B-tree remove: create random level 4 B-tree and delete all records by index, in decreasing order"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, f))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ - for(u = 0; u < INSERT_MANY; u++) { + for (u = 0; u < INSERT_MANY; u++) { /* Remove last record */ rrecord = HSIZET_MAX; - if(H5B2_remove_by_idx(bt2, H5_ITER_DEC, (hsize_t)0, remove_cb, &rrecord) < 0) + if (H5B2_remove_by_idx(bt2, H5_ITER_DEC, (hsize_t)0, remove_cb, &rrecord) < 0) FAIL_STACK_ERROR /* Make certain that the record value is correct */ - if(rrecord != (INSERT_MANY - (u + 1))) + if (rrecord != (INSERT_MANY - (u + 1))) TEST_ERROR /* Query the number of records in the B-tree */ - if(H5B2_get_nrec(bt2, &nrec) < 0) + if (H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != (INSERT_MANY - (u + 1))) + if (nrec != (INSERT_MANY - (u + 1))) TEST_ERROR } /* end for */ /* Query the address of the root node in the B-tree */ - if(H5B2__get_root_addr_test(bt2, &root_addr) < 0) + if (H5B2__get_root_addr_test(bt2, &root_addr) < 0) FAIL_STACK_ERROR /* Make certain that the address of the root node is defined */ - if(H5F_addr_defined(root_addr)) + if (H5F_addr_defined(root_addr)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); - if(records) + if (records) HDfree(records); - if(file_data) + if (file_data) HDfree(file_data); return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; - if(fd > 0) + if (fd > 0) HDclose(fd); - if(records) + if (records) HDfree(records); - if(file_data) + if (file_data) HDfree(file_data); return 1; } /* test_remove_lots() */ - /*------------------------------------------------------------------------- * Function: test_find_neighbor * @@ -9080,26 +9091,25 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_find_neighbor(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_find_neighbor(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t search; /* Search value */ - hsize_t *records; /* Record #'s for random insertion */ - unsigned u; /* Local index variable */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t search; /* Search value */ + hsize_t * records; /* Record #'s for random insertion */ + unsigned u; /* Local index variable */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + herr_t ret; /* Generic error return value */ /* Allocate space for the records */ - if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * FIND_NEIGHBOR))) + if (NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * FIND_NEIGHBOR))) TEST_ERROR /* Initialize record #'s */ - for(u = 0; u < FIND_NEIGHBOR; u++) + for (u = 0; u < FIND_NEIGHBOR; u++) records[u] = u * 2; /* @@ -9108,85 +9118,87 @@ test_find_neighbor(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree find: nearest neighbor less than a value"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert records */ - for(u = 0; u < FIND_NEIGHBOR; u++) { + for (u = 0; u < FIND_NEIGHBOR; u++) { record = records[u]; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Attempt to find record B-tree less than a value */ search = 0; - H5E_BEGIN_TRY { - ret = H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR search = 1; - if(H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 0) + if (record != 0) TEST_ERROR search = 2; - if(H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 0) + if (record != 0) TEST_ERROR search = 3; - if(H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 2) + if (record != 2) TEST_ERROR search = 4; - if(H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 2) + if (record != 2) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 1; - ninfo.nrec = 14; - record = 250; /* Record in left internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 14; + record = 250; /* Record in left internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Neighbor is in internal node */ search = 251; - if(H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 250) + if (record != 250) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 2; - ninfo.nrec = 1; - record = 1888; /* Record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 1; + record = 1888; /* Record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Neighbor is in root node */ search = 1889; - if(H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 1888) + if (record != 1888) TEST_ERROR search = (FIND_NEIGHBOR * 2) + 1; - if(H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_LESS, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != ((FIND_NEIGHBOR - 1) * 2)) + if (record != ((FIND_NEIGHBOR - 1) * 2)) TEST_ERROR PASSED(); @@ -9197,76 +9209,78 @@ test_find_neighbor(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree find: nearest neighbor greater than a value"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Attempt to find record B-tree less than a value */ search = (FIND_NEIGHBOR * 2) + 1; - H5E_BEGIN_TRY { - ret = H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR search = 0; - if(H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 2) + if (record != 2) TEST_ERROR search = 1; - if(H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 2) + if (record != 2) TEST_ERROR search = 2; - if(H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 4) + if (record != 4) TEST_ERROR search = 3; - if(H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 4) + if (record != 4) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 1; - ninfo.nrec = 16; - record = 2896; /* Record in right internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 16; + record = 2896; /* Record in right internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Neighbor is in internal node */ search = 2895; - if(H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 2896) + if (record != 2896) TEST_ERROR /* Neighbor is in root node */ search = 1887; - if(H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != 1888) + if (record != 1888) TEST_ERROR search = ((FIND_NEIGHBOR - 1) * 2) - 1; - if(H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) + if (H5B2_neighbor(bt2, H5B2_COMPARE_GREATER, &search, neighbor_cb, &record) < 0) FAIL_STACK_ERROR - if(record != ((FIND_NEIGHBOR - 1) * 2)) + if (record != ((FIND_NEIGHBOR - 1) * 2)) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR PASSED(); @@ -9276,16 +9290,17 @@ test_find_neighbor(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; HDfree(records); return 1; } /* test_find_neighbor() */ - /*------------------------------------------------------------------------- * Function: test_delete * @@ -9303,73 +9318,73 @@ error: static unsigned test_delete(hid_t fapl, const H5B2_create_t *cparam) { - hid_t file = -1; /* File ID */ - char filename[1024]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t empty_size; /* Size of an empty file */ - h5_stat_size_t file_size; /* Size of each file created */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[1024]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t empty_size; /* Size of an empty file */ + h5_stat_size_t file_size; /* Size of each file created */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Attempt to delete empty B-tree */ TESTING("B-tree delete: delete empty B-tree"); -/* Create empty file for size comparisons later */ + /* Create empty file for size comparisons later */ /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR /* Get the size of an empty file */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* * Delete v2 B-tree */ - if(H5B2_delete(f, bt2_addr, f, NULL, NULL) < 0) + if (H5B2_delete(f, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -9378,55 +9393,55 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) TESTING("B-tree delete: delete level-0 B-tree"); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert records */ - for(u = 0; u < DELETE_SMALL; u++) { + for (u = 0; u < DELETE_SMALL; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - if(H5B2_stat_info(bt2, &bt2_stat) < 0) + if (H5B2_stat_info(bt2, &bt2_stat) < 0) FAIL_STACK_ERROR - if(bt2_stat.depth != 0) + if (bt2_stat.depth != 0) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* * Delete v2 B-tree */ - if(H5B2_delete(f, bt2_addr, f, NULL, NULL) < 0) + if (H5B2_delete(f, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -9435,55 +9450,55 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) TESTING("B-tree delete: delete level-1 B-tree"); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert records */ - for(u = 0; u < DELETE_MEDIUM; u++) { + for (u = 0; u < DELETE_MEDIUM; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - if(H5B2_stat_info(bt2, &bt2_stat) < 0) + if (H5B2_stat_info(bt2, &bt2_stat) < 0) FAIL_STACK_ERROR - if(bt2_stat.depth != 1) + if (bt2_stat.depth != 1) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* * Delete v2 B-tree */ - if(H5B2_delete(f, bt2_addr, f, NULL, NULL) < 0) + if (H5B2_delete(f, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -9492,55 +9507,55 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) TESTING("B-tree delete: delete level-2 B-tree"); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert records */ - for(u = 0; u < DELETE_LARGE; u++) { + for (u = 0; u < DELETE_LARGE; u++) { record = u; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - if(H5B2_stat_info(bt2, &bt2_stat) < 0) + if (H5B2_stat_info(bt2, &bt2_stat) < 0) FAIL_STACK_ERROR - if(bt2_stat.depth != 2) + if (bt2_stat.depth != 2) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* * Delete v2 B-tree */ - if(H5B2_delete(f, bt2_addr, f, NULL, NULL) < 0) + if (H5B2_delete(f, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -9548,15 +9563,16 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_delete() */ - /*------------------------------------------------------------------------- * Function: test_modify * @@ -9572,20 +9588,19 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_modify(hid_t fapl, const H5B2_create_t *cparam, - const bt2_test_param_t *tparam) +test_modify(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t modify; /* Modified value */ - hsize_t found; /* Found value */ - H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ - H5B2_node_info_test_t ninfo; /* B-tree node info */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic error return value */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5B2_t * bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t modify; /* Modified value */ + hsize_t found; /* Found value */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + H5B2_node_info_test_t ninfo; /* B-tree node info */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ /* * Test modifying records @@ -9593,34 +9608,36 @@ test_modify(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree modify: attempt to modify non-existant record"); /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + if (create_file(&file, &f, fapl) < 0) TEST_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Create level-2 B-tree with 3 internal nodes */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { + for (u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 59) + 1); u++) { record = u * 5; - if(H5B2_insert(bt2, &record) < 0) + if (H5B2_insert(bt2, &record) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ - if(H5B2_stat_info(bt2, &bt2_stat) < 0) + if (H5B2_stat_info(bt2, &bt2_stat) < 0) FAIL_STACK_ERROR - if(bt2_stat.depth != 2) + if (bt2_stat.depth != 2) TEST_ERROR /* Attempt to modify a non-existant record */ record = 3; modify = 4; - H5E_BEGIN_TRY { - ret = H5B2_modify(bt2, &record, modify_cb, &modify); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5B2_modify(bt2, &record, modify_cb, &modify); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR PASSED(); @@ -9628,45 +9645,47 @@ test_modify(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree modify: modify record in leaf node"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 0; - ninfo.nrec = 62; - record = 4330; /* Record in leaf node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 62; + record = 4330; /* Record in leaf node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Attempt to modify a record in a leaf node */ record = 4330; modify = 4331; - if(H5B2_modify(bt2, &record, modify_cb, &modify) < 0) + if (H5B2_modify(bt2, &record, modify_cb, &modify) < 0) FAIL_STACK_ERROR /* Check status of B-tree */ ninfo.depth = 0; - ninfo.nrec = 62; - record = 4331; /* Record in leaf node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 62; + record = 4331; /* Record in leaf node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Attempt to find modified record */ record = 4331; - found = 4331; - if(H5B2_find(bt2, &record, find_cb, &found) != TRUE) + found = 4331; + if (H5B2_find(bt2, &record, find_cb, &found) != TRUE) FAIL_STACK_ERROR - if(found != 4331) + if (found != 4331) TEST_ERROR /* Attempt to find original record */ record = 4330; - found = HSIZET_MAX; - H5E_BEGIN_TRY { - ret = H5B2_modify(bt2, &record, modify_cb, &modify); - } H5E_END_TRY; + found = HSIZET_MAX; + H5E_BEGIN_TRY + { + ret = H5B2_modify(bt2, &record, modify_cb, &modify); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR PASSED(); @@ -9674,45 +9693,47 @@ test_modify(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree modify: modify record in internal node"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 1; - ninfo.nrec = 29; - record = 5350; /* Record in internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 29; + record = 5350; /* Record in internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Attempt to modify a record in an internal node */ record = 5350; modify = 5352; - if(H5B2_modify(bt2, &record, modify_cb, &modify) < 0) + if (H5B2_modify(bt2, &record, modify_cb, &modify) < 0) FAIL_STACK_ERROR /* Check status of B-tree */ ninfo.depth = 1; - ninfo.nrec = 29; - record = 5352; /* Record in internal node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 29; + record = 5352; /* Record in internal node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Attempt to find modified record */ record = 5352; - found = 5352; - if(H5B2_find(bt2, &record, find_cb, &found) != TRUE) + found = 5352; + if (H5B2_find(bt2, &record, find_cb, &found) != TRUE) STACK_ERROR - if(found != 5352) + if (found != 5352) TEST_ERROR /* Attempt to find original record */ record = 5350; - found = 5350; - H5E_BEGIN_TRY { - ret = H5B2_modify(bt2, &record, modify_cb, &modify); - } H5E_END_TRY; + found = 5350; + H5E_BEGIN_TRY + { + ret = H5B2_modify(bt2, &record, modify_cb, &modify); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR PASSED(); @@ -9720,54 +9741,56 @@ test_modify(hid_t fapl, const H5B2_create_t *cparam, TESTING("B-tree modify: modify record in root node"); /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, &bt2, bt2_addr, tparam) < 0) + if (reopen_btree(f, &bt2, bt2_addr, tparam) < 0) TEST_ERROR /* Check status of B-tree */ ninfo.depth = 2; - ninfo.nrec = 2; - record = 9445; /* Record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 9445; /* Record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Attempt to modify a record in a root node */ record = 9445; modify = 9448; - if(H5B2_modify(bt2, &record, modify_cb, &modify) < 0) + if (H5B2_modify(bt2, &record, modify_cb, &modify) < 0) FAIL_STACK_ERROR /* Check status of B-tree */ ninfo.depth = 2; - ninfo.nrec = 2; - record = 9448; /* Record in root node */ - if(check_node_info(bt2, record, &ninfo) < 0) + ninfo.nrec = 2; + record = 9448; /* Record in root node */ + if (check_node_info(bt2, record, &ninfo) < 0) TEST_ERROR /* Attempt to find modified record */ record = 9448; - found = 9448; - if(H5B2_find(bt2, &record, find_cb, &found) != TRUE) + found = 9448; + if (H5B2_find(bt2, &record, find_cb, &found) != TRUE) STACK_ERROR - if(found != 9448) + if (found != 9448) TEST_ERROR /* Attempt to find original record */ record = 9445; - found = 9445; - H5E_BEGIN_TRY { - ret = H5B2_modify(bt2, &record, modify_cb, &modify); - } H5E_END_TRY; + found = 9445; + H5E_BEGIN_TRY + { + ret = H5B2_modify(bt2, &record, modify_cb, &modify); + } + H5E_END_TRY; /* Should fail */ - if(ret != FAIL) + if (ret != FAIL) TEST_ERROR /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR PASSED(); @@ -9775,15 +9798,16 @@ test_modify(hid_t fapl, const H5B2_create_t *cparam, return 0; error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_modify() */ - /*------------------------------------------------------------------------- * Function: test_open_twice_diff * @@ -9802,17 +9826,17 @@ error: static unsigned test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) { - char filename[1024]; /* Filename to use */ - char filename_tmp[1024]; /* Temporary file name */ - hid_t file = -1; /* File ID */ - hid_t file2 = -1; /* File ID */ - hid_t file0 = -1; /* File ID */ - hid_t file00 = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5F_t *f2 = NULL; /* Internal file object pointer */ - H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ - H5B2_t *bt2_2 = NULL; /* Second v2 B-tree wrapper */ - haddr_t bt2_addr; /* Address of B-tree created */ + char filename[1024]; /* Filename to use */ + char filename_tmp[1024]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5F_t * f2 = NULL; /* Internal file object pointer */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + H5B2_t *bt2_2 = NULL; /* Second v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); @@ -9822,27 +9846,27 @@ test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) TESTING("open B-tree twice, through different file handles"); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) FAIL_STACK_ERROR /* Create the v2 B-tree & get its address */ - if(create_btree(f, cparam, &bt2, &bt2_addr) < 0) + if (create_btree(f, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2_2 = H5B2_open(f, bt2_addr, f))) + if (NULL == (bt2_2 = H5B2_open(f, bt2_addr, f))) FAIL_STACK_ERROR /* Close the second v2 B-tree wrapper */ - if(H5B2_close(bt2_2) < 0) + if (H5B2_close(bt2_2) < 0) FAIL_STACK_ERROR bt2_2 = NULL; @@ -9850,11 +9874,11 @@ test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) /* (So that there is something holding the file open when the extensible * array is closed) */ - if((file0 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file0 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Close the first v2 B-tree wrapper */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) FAIL_STACK_ERROR bt2 = NULL; @@ -9862,7 +9886,7 @@ test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) /* (close before second file, to detect error on internal B-tree header's * shared file information) */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR file = -1; @@ -9872,57 +9896,58 @@ test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) * header stale) */ h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); - if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Re-open the file with the v2 B-tree array */ - if((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f2 = (H5F_t *)H5VL_object(file2))) + if (NULL == (f2 = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Open the B-tree through the second file handle */ - if(NULL == (bt2_2 = H5B2_open(f2, bt2_addr, f2))) + if (NULL == (bt2_2 = H5B2_open(f2, bt2_addr, f2))) FAIL_STACK_ERROR /* Close the extra file handles */ - if(H5Fclose(file0) < 0) + if (H5Fclose(file0) < 0) FAIL_STACK_ERROR - if(H5Fclose(file00) < 0) + if (H5Fclose(file00) < 0) FAIL_STACK_ERROR /* Close the second v2 B-tree */ - if(H5B2_close(bt2_2) < 0) + if (H5B2_close(bt2_2) < 0) FAIL_STACK_ERROR bt2_2 = NULL; /* Close file */ - if(H5Fclose(file2) < 0) + if (H5Fclose(file2) < 0) FAIL_STACK_ERROR /* All tests passed */ PASSED(); /* All tests passed */ - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(bt2) + H5E_BEGIN_TRY + { + if (bt2) H5B2_close(bt2); - if(bt2) + if (bt2) H5B2_close(bt2_2); - H5Fclose(file); - H5Fclose(file2); - H5Fclose(file0); - H5Fclose(file00); - } H5E_END_TRY; - return(1); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } + H5E_END_TRY; + return (1); } /* test_open_twice_diff() */ - /*------------------------------------------------------------------------- * Function: main * @@ -9940,36 +9965,37 @@ error: int main(void) { - H5B2_create_t cparam, cparam2; /* Creation parameters for v2 B-tree */ - bt2_test_param_t tparam; /* Test parameters for v2 B-tree */ - hid_t fapl = -1; /* File access property list for data files */ - unsigned nerrors = 0; /* Cumulative error count */ - unsigned reopen; /* Whether to reopen B-tree during tests */ - int ExpressMode; - const char *envval = NULL; - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + H5B2_create_t cparam, cparam2; /* Creation parameters for v2 B-tree */ + bt2_test_param_t tparam; /* Test parameters for v2 B-tree */ + hid_t fapl = -1; /* File access property list for data files */ + unsigned nerrors = 0; /* Cumulative error count */ + unsigned reopen; /* Whether to reopen B-tree during tests */ + int ExpressMode; + const char * envval = NULL; + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL) + if (envval == NULL) envval = "nomatch"; /* Reset library */ h5_reset(); - fapl = h5_fileaccess(); + fapl = h5_fileaccess(); ExpressMode = GetTestExpress(); - if(ExpressMode > 1) + if (ExpressMode > 1) HDprintf("***Express test mode on. Some tests may be skipped\n"); /* Initialize v2 B-tree creation parameters */ init_cparam(&cparam, &cparam2); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Loop over re-opening B-tree during tests */ - for(reopen = FALSE; reopen <= TRUE; reopen++) { - if(reopen) { + for (reopen = FALSE; reopen <= TRUE; reopen++) { + if (reopen) { HDfprintf(stdout, "Testing with reopening B-tree:\n"); tparam.reopen_btree = TRUE; } /* end if */ @@ -9993,7 +10019,7 @@ main(void) nerrors += test_insert_level2_2internal_split(fapl, &cparam, &tparam); nerrors += test_insert_level2_3internal_redistrib(fapl, &cparam, &tparam); nerrors += test_insert_level2_3internal_split(fapl, &cparam, &tparam); - if(ExpressMode > 1) + if (ExpressMode > 1) HDprintf("***Express test mode on. test_insert_lots skipped\n"); else nerrors += test_insert_lots(fapl, &cparam, &tparam); @@ -10007,7 +10033,7 @@ main(void) nerrors += test_update_level1_3leaf_redistrib(fapl, &cparam2, &tparam); nerrors += test_update_level1_middle_split(fapl, &cparam2, &tparam); nerrors += test_update_make_level2(fapl, &cparam2, &tparam); - if(ExpressMode > 1) + if (ExpressMode > 1) HDprintf("***Express test mode on. test_update_lots skipped\n"); else nerrors += test_update_lots(fapl, &cparam2, &tparam); @@ -10034,7 +10060,7 @@ main(void) nerrors += test_remove_level2_2internal_merge_right(fapl, &cparam, &tparam); nerrors += test_remove_level2_3internal_merge(fapl, &cparam, &tparam); nerrors += test_remove_level2_collapse_right(fapl, &cparam, &tparam); - if(ExpressMode > 1) + if (ExpressMode > 1) HDprintf("***Express test mode on. test_remove_lots skipped\n"); else nerrors += test_remove_lots(envval, fapl, &cparam); @@ -10056,10 +10082,11 @@ main(void) nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; - if(nerrors) + if (nerrors) goto error; puts("All v2 B-tree tests passed."); @@ -10071,12 +10098,14 @@ main(void) error: puts("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); return 1; } /* end main() */ - diff --git a/test/cache.c b/test/cache.c index bb18728..24328d5 100644 --- a/test/cache.c +++ b/test/cache.c @@ -20,17 +20,16 @@ #include "cache_common.h" #include "H5MFprivate.h" +H5C_t *saved_cache = NULL; /* store the pointer to the instance of + * of H5C_t created by H5Fcreate() + * here between test cache setup and + * shutdown. + */ -H5C_t * saved_cache = NULL; /* store the pointer to the instance of - * of H5C_t created by H5Fcreate() - * here between test cache setup and - * shutdown. - */ - -haddr_t saved_actual_base_addr = HADDR_UNDEF; /* Store the address of the - * space allocated for cache items in the file between - * cache setup & takedown - */ +haddr_t saved_actual_base_addr = HADDR_UNDEF; /* Store the address of the + * space allocated for cache items in the file between + * cache setup & takedown + */ hid_t saved_fapl_id = H5P_DEFAULT; /* store the fapl id here between * cache setup and takedown. Note @@ -46,94 +45,84 @@ hid_t saved_fcpl_id = H5P_DEFAULT; /* store the fcpl id here between * close. */ -hid_t saved_fid = -1; /* store the file id here between cache setup - * and takedown. - */ -hbool_t write_permitted = TRUE; -hbool_t try_core_file_driver = FALSE; +hid_t saved_fid = -1; /* store the file id here between cache setup + * and takedown. + */ +hbool_t write_permitted = TRUE; +hbool_t try_core_file_driver = FALSE; hbool_t core_file_driver_failed = FALSE; - /* global variable declarations: */ -const char *FILENAME[] = { - "cache_test", - NULL -}; +const char *FILENAME[] = {"cache_test", NULL}; /* private typedef declarations: */ -struct flush_cache_test_spec -{ - int entry_num; - int entry_type; - int entry_index; - hbool_t insert_flag; - unsigned int flags; - hbool_t expected_deserialized; - hbool_t expected_serialized; - hbool_t expected_destroyed; +struct flush_cache_test_spec { + int entry_num; + int entry_type; + int entry_index; + hbool_t insert_flag; + unsigned int flags; + hbool_t expected_deserialized; + hbool_t expected_serialized; + hbool_t expected_destroyed; }; -struct pe_flush_cache_test_spec -{ - int entry_num; - int entry_type; - int entry_index; - hbool_t insert_flag; - unsigned int flags; - int num_pins; - int pin_type[MAX_PINS]; - int pin_idx[MAX_PINS]; - hbool_t expected_deserialized; - hbool_t expected_serialized; - hbool_t expected_destroyed; +struct pe_flush_cache_test_spec { + int entry_num; + int entry_type; + int entry_index; + hbool_t insert_flag; + unsigned int flags; + int num_pins; + int pin_type[MAX_PINS]; + int pin_idx[MAX_PINS]; + hbool_t expected_deserialized; + hbool_t expected_serialized; + hbool_t expected_destroyed; }; -struct fo_flush_entry_check -{ - int entry_num; - int entry_type; - int entry_index; - size_t expected_size; - hbool_t in_cache; - hbool_t at_main_addr; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - hbool_t expected_deserialized; - hbool_t expected_serialized; - hbool_t expected_destroyed; +struct fo_flush_entry_check { + int entry_num; + int entry_type; + int entry_index; + size_t expected_size; + hbool_t in_cache; + hbool_t at_main_addr; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + hbool_t expected_deserialized; + hbool_t expected_serialized; + hbool_t expected_destroyed; }; -struct fo_flush_cache_test_spec -{ - int entry_num; - int entry_type; - int entry_index; - hbool_t insert_flag; - unsigned int flags; - hbool_t resize_flag; - size_t new_size; - int num_pins; - int pin_type[MAX_PINS]; - int pin_idx[MAX_PINS]; - int num_flush_ops; - struct flush_op flush_ops[MAX_FLUSH_OPS]; - hbool_t expected_deserialized; - hbool_t expected_serialized; - hbool_t expected_destroyed; +struct fo_flush_cache_test_spec { + int entry_num; + int entry_type; + int entry_index; + hbool_t insert_flag; + unsigned int flags; + hbool_t resize_flag; + size_t new_size; + int num_pins; + int pin_type[MAX_PINS]; + int pin_idx[MAX_PINS]; + int num_flush_ops; + struct flush_op flush_ops[MAX_FLUSH_OPS]; + hbool_t expected_deserialized; + hbool_t expected_serialized; + hbool_t expected_destroyed; }; -struct move_entry_test_spec -{ - int entry_type; - int entry_index; - hbool_t is_pinned; - hbool_t is_protected; +struct move_entry_test_spec { + int entry_type; + int entry_index; + hbool_t is_pinned; + hbool_t is_protected; }; - /* private function declarations: */ static unsigned smoke_check_1(int express_test, unsigned paged); @@ -149,61 +138,36 @@ static unsigned smoke_check_10(int express_test, unsigned paged); static unsigned write_permitted_check(int express_test, unsigned paged); static unsigned check_insert_entry(unsigned paged); static unsigned check_flush_cache(unsigned paged); -static void check_flush_cache__empty_cache(H5F_t * file_ptr); -static void check_flush_cache__multi_entry(H5F_t * file_ptr); -static void check_flush_cache__multi_entry_test(H5F_t * file_ptr, - int test_num, - unsigned int flush_flags, - unsigned int spec_size, - struct flush_cache_test_spec spec[]); -static void check_flush_cache__pe_multi_entry_test(H5F_t * file_ptr, - int test_num, - unsigned int flush_flags, - unsigned int spec_size, - struct pe_flush_cache_test_spec spec[]); -static void check_flush_cache__single_entry(H5F_t * file_ptr); -static void check_flush_cache__single_entry_test(H5F_t * file_ptr, - int test_num, - int entry_type, - int entry_idx, - hbool_t insert_flag, - unsigned int flags, - unsigned int flush_flags, - hbool_t expected_deserialized, - hbool_t expected_serialized, - hbool_t expected_destroyed); -static void check_flush_cache__pinned_single_entry_test(H5F_t * file_ptr, - int test_num, - int entry_type, - int entry_idx, - hbool_t unprot_dirty_flag, - hbool_t mark_dirty, - hbool_t pop_mark_dirty_prot, - hbool_t pop_mark_dirty_pinned, - hbool_t unprotect_unpin, - unsigned int flags, - unsigned int flush_flags, - hbool_t expected_serialized, - hbool_t expected_destroyed); -static void check_flush_cache__flush_ops(H5F_t * file_ptr); -static void check_flush_cache__flush_op_test(H5F_t * file_ptr, - int test_num, - unsigned int flush_flags, - int spec_size, - const struct fo_flush_cache_test_spec spec[], - unsigned init_expected_index_len, - size_t init_expected_index_size, - unsigned expected_index_len, - size_t expected_index_size, - int check_size, - struct fo_flush_entry_check check[]); -static void check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr); +static void check_flush_cache__empty_cache(H5F_t *file_ptr); +static void check_flush_cache__multi_entry(H5F_t *file_ptr); +static void check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, + unsigned int spec_size, struct flush_cache_test_spec spec[]); +static void check_flush_cache__pe_multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, + unsigned int spec_size, + struct pe_flush_cache_test_spec spec[]); +static void check_flush_cache__single_entry(H5F_t *file_ptr); +static void check_flush_cache__single_entry_test(H5F_t *file_ptr, int test_num, int entry_type, int entry_idx, + hbool_t insert_flag, unsigned int flags, + unsigned int flush_flags, hbool_t expected_deserialized, + hbool_t expected_serialized, hbool_t expected_destroyed); +static void check_flush_cache__pinned_single_entry_test( + H5F_t *file_ptr, int test_num, int entry_type, int entry_idx, hbool_t unprot_dirty_flag, + hbool_t mark_dirty, hbool_t pop_mark_dirty_prot, hbool_t pop_mark_dirty_pinned, hbool_t unprotect_unpin, + unsigned int flags, unsigned int flush_flags, hbool_t expected_serialized, hbool_t expected_destroyed); +static void check_flush_cache__flush_ops(H5F_t *file_ptr); +static void check_flush_cache__flush_op_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, + int spec_size, const struct fo_flush_cache_test_spec spec[], + unsigned init_expected_index_len, + size_t init_expected_index_size, unsigned expected_index_len, + size_t expected_index_size, int check_size, + struct fo_flush_entry_check check[]); +static void check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr); static unsigned check_get_entry_status(unsigned paged); static unsigned check_expunge_entry(unsigned paged); static unsigned check_multiple_read_protect(unsigned paged); static unsigned check_move_entry(unsigned paged); -static void check_move_entry__run_test(H5F_t * file_ptr, unsigned test_num, - struct move_entry_test_spec * spec_ptr); +static void check_move_entry__run_test(H5F_t *file_ptr, unsigned test_num, + struct move_entry_test_spec *spec_ptr); static unsigned check_pin_protected_entry(unsigned paged); static unsigned check_resize_entry(unsigned paged); static unsigned check_evictions_enabled(unsigned paged); @@ -236,21 +200,18 @@ static unsigned check_flush_deps_order(unsigned paged); static unsigned check_notify_cb(unsigned paged); static unsigned check_metadata_cork(hbool_t fill_via_insertion, unsigned paged); static unsigned check_entry_deletions_during_scans(unsigned paged); -static void cedds__expunge_dirty_entry_in_flush_test(H5F_t * file_ptr); -static void cedds__H5C_make_space_in_cache(H5F_t * file_ptr); -static void cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr); -static void cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr); +static void cedds__expunge_dirty_entry_in_flush_test(H5F_t *file_ptr); +static void cedds__H5C_make_space_in_cache(H5F_t *file_ptr); +static void cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *file_ptr); +static void cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t *file_ptr); static unsigned check_stats(unsigned paged); #if H5C_COLLECT_CACHE_STATS -static void check_stats__smoke_check_1(H5F_t * file_ptr); +static void check_stats__smoke_check_1(H5F_t *file_ptr); #endif /* H5C_COLLECT_CACHE_STATS */ - static H5F_t *setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged); -static void takedown_cache(H5F_t * file_ptr, - hbool_t dump_stats, - hbool_t dump_detailed_stats); +static void takedown_cache(H5F_t *file_ptr, hbool_t dump_stats, hbool_t dump_detailed_stats); /**************************************************************************/ /**************************************************************************/ @@ -276,67 +237,63 @@ static void takedown_cache(H5F_t * file_ptr, static unsigned smoke_check_1(int express_test, unsigned paged) { - hbool_t show_progress = FALSE; - int dirty_unprotects = FALSE; - int dirty_destroys = FALSE; - hbool_t display_stats = FALSE; - int32_t lag = 10; - int32_t max_index = (10 * 1024) - 1; - int mile_stone = 1; - H5F_t * file_ptr = NULL; - - if(paged) + hbool_t show_progress = FALSE; + int dirty_unprotects = FALSE; + int dirty_destroys = FALSE; + hbool_t display_stats = FALSE; + int32_t lag = 10; + int32_t max_index = (10 * 1024) - 1; + int mile_stone = 1; + H5F_t * file_ptr = NULL; + + if (paged) TESTING("smoke check #1P -- all clean, ins, dest, ren, 4/2 MB cache") else TESTING("smoke check #1 -- all clean, ins, dest, ren, 4/2 MB cache") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -346,13 +303,12 @@ smoke_check_1(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ TRUE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -365,16 +321,15 @@ smoke_check_1(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ TRUE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -384,13 +339,12 @@ smoke_check_1(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -399,12 +353,11 @@ smoke_check_1(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -413,9 +366,8 @@ smoke_check_1(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -424,12 +376,11 @@ smoke_check_1(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -438,32 +389,33 @@ smoke_check_1(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_1() */ - /*------------------------------------------------------------------------- * Function: smoke_check_2() * @@ -483,67 +435,63 @@ smoke_check_1(int express_test, unsigned paged) static unsigned smoke_check_2(int express_test, unsigned paged) { - hbool_t show_progress = FALSE; - int dirty_unprotects = TRUE; - int dirty_destroys = TRUE; - hbool_t display_stats = FALSE; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t * file_ptr = NULL; - - if(paged) + hbool_t show_progress = FALSE; + int dirty_unprotects = TRUE; + int dirty_destroys = TRUE; + hbool_t display_stats = FALSE; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t * file_ptr = NULL; + + if (paged) TESTING("smoke check #2P -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache") else TESTING("smoke check #2 -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -553,13 +501,12 @@ smoke_check_2(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ TRUE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -572,16 +519,15 @@ smoke_check_2(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ TRUE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -591,13 +537,12 @@ smoke_check_2(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -606,12 +551,11 @@ smoke_check_2(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -620,9 +564,8 @@ smoke_check_2(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -631,12 +574,11 @@ smoke_check_2(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -645,32 +587,33 @@ smoke_check_2(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_2() */ - /*------------------------------------------------------------------------- * Function: smoke_check_3() * @@ -689,67 +632,63 @@ smoke_check_2(int express_test, unsigned paged) static unsigned smoke_check_3(int express_test, unsigned paged) { - hbool_t show_progress = FALSE; - int dirty_unprotects = FALSE; - int dirty_destroys = FALSE; - hbool_t display_stats = FALSE; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t * file_ptr = NULL; - - if(paged) + hbool_t show_progress = FALSE; + int dirty_unprotects = FALSE; + int dirty_destroys = FALSE; + hbool_t display_stats = FALSE; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t * file_ptr = NULL; + + if (paged) TESTING("smoke check #3P -- all clean, ins, dest, ren, 2/1 KB cache") else TESTING("smoke check #3 -- all clean, ins, dest, ren, 2/1 KB cache") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -759,13 +698,12 @@ smoke_check_3(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ TRUE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -778,16 +716,15 @@ smoke_check_3(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ TRUE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -797,13 +734,12 @@ smoke_check_3(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -812,12 +748,11 @@ smoke_check_3(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -826,9 +761,8 @@ smoke_check_3(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -837,12 +771,11 @@ smoke_check_3(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -851,32 +784,33 @@ smoke_check_3(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_3() */ - /*------------------------------------------------------------------------- * Function: smoke_check_4() * @@ -896,67 +830,63 @@ smoke_check_3(int express_test, unsigned paged) static unsigned smoke_check_4(int express_test, unsigned paged) { - hbool_t show_progress = FALSE; - int dirty_unprotects = TRUE; - int dirty_destroys = TRUE; - hbool_t display_stats = FALSE; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t * file_ptr = NULL; - - if(paged) + hbool_t show_progress = FALSE; + int dirty_unprotects = TRUE; + int dirty_destroys = TRUE; + hbool_t display_stats = FALSE; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t * file_ptr = NULL; + + if (paged) TESTING("smoke check #4P -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache") else TESTING("smoke check #4 -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -966,13 +896,12 @@ smoke_check_4(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ TRUE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -985,16 +914,15 @@ smoke_check_4(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ TRUE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -1004,13 +932,12 @@ smoke_check_4(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -1019,12 +946,11 @@ smoke_check_4(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -1033,9 +959,8 @@ smoke_check_4(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -1044,12 +969,11 @@ smoke_check_4(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -1058,32 +982,33 @@ smoke_check_4(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_4() */ - /*------------------------------------------------------------------------- * Function: smoke_check_5() * @@ -1103,16 +1028,15 @@ smoke_check_4(int express_test, unsigned paged) static unsigned smoke_check_5(int express_test, unsigned paged) { - herr_t result; - hbool_t show_progress = FALSE; - int dirty_unprotects = FALSE; - hbool_t display_stats = FALSE; - int32_t max_index = 1024; - int mile_stone = 1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_auto_size_ctl_t auto_size_ctl = - { + herr_t result; + hbool_t show_progress = FALSE; + int dirty_unprotects = FALSE; + hbool_t display_stats = FALSE; + int32_t max_index = 1024; + int mile_stone = 1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_auto_size_ctl_t auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, #if 1 /* H5C_auto_resize_report_fcn rpt_fcn = */ NULL, @@ -1129,7 +1053,6 @@ smoke_check_5(int express_test, unsigned paged) /* int64_t epoch_length = */ 50000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -1140,10 +1063,9 @@ smoke_check_5(int express_test, unsigned paged) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, @@ -1160,67 +1082,63 @@ smoke_check_5(int express_test, unsigned paged) /* double empty_reserve = */ 0.5f }; - if(paged) + if (paged) TESTING("smoke check #5P -- all clean, ins, prot, unprot, AR cache 1") else TESTING("smoke check #5 -- all clean, ins, prot, unprot, AR cache 1") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1230,9 +1148,8 @@ smoke_check_5(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ FALSE); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1242,9 +1159,8 @@ smoke_check_5(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ FALSE); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1254,9 +1170,8 @@ smoke_check_5(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ TRUE); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -1265,9 +1180,8 @@ smoke_check_5(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_col_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1278,9 +1192,8 @@ smoke_check_5(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -1289,9 +1202,8 @@ smoke_check_5(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_col_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1302,32 +1214,33 @@ smoke_check_5(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_5() */ - /*------------------------------------------------------------------------- * Function: smoke_check_6() * @@ -1347,16 +1260,15 @@ smoke_check_5(int express_test, unsigned paged) static unsigned smoke_check_6(int express_test, unsigned paged) { - herr_t result; - hbool_t show_progress = FALSE; - int dirty_unprotects = FALSE; - hbool_t display_stats = FALSE; - int mile_stone = 1; - int32_t max_index = 1024; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_auto_size_ctl_t auto_size_ctl = - { + herr_t result; + hbool_t show_progress = FALSE; + int dirty_unprotects = FALSE; + hbool_t display_stats = FALSE; + int mile_stone = 1; + int32_t max_index = 1024; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_auto_size_ctl_t auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, #if 1 /* H5C_auto_resize_report_fcn rpt_fcn = */ NULL, @@ -1373,7 +1285,6 @@ smoke_check_6(int express_test, unsigned paged) /* int64_t epoch_length = */ 50000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -1384,10 +1295,9 @@ smoke_check_6(int express_test, unsigned paged) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, @@ -1404,67 +1314,63 @@ smoke_check_6(int express_test, unsigned paged) /* double empty_reserve = */ 0.05f }; - if(paged) + if (paged) TESTING("smoke check #6P -- ~1/2 dirty, ins, prot, unprot, AR cache 1") else TESTING("smoke check #6 -- ~1/2 dirty, ins, prot, unprot, AR cache 1") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } pass = TRUE; - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1474,9 +1380,8 @@ smoke_check_6(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ FALSE); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1486,9 +1391,8 @@ smoke_check_6(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ FALSE); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1498,9 +1402,8 @@ smoke_check_6(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ TRUE); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -1509,9 +1412,8 @@ smoke_check_6(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_col_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1522,9 +1424,8 @@ smoke_check_6(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -1533,9 +1434,8 @@ smoke_check_6(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_col_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1546,32 +1446,33 @@ smoke_check_6(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_6() */ - /*------------------------------------------------------------------------- * Function: smoke_check_7() * @@ -1591,16 +1492,15 @@ smoke_check_6(int express_test, unsigned paged) static unsigned smoke_check_7(int express_test, unsigned paged) { - herr_t result; - hbool_t show_progress = FALSE; - int dirty_unprotects = FALSE; - hbool_t display_stats = FALSE; - int mile_stone = 1; - int32_t max_index = 1024; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_auto_size_ctl_t auto_size_ctl = - { + herr_t result; + hbool_t show_progress = FALSE; + int dirty_unprotects = FALSE; + hbool_t display_stats = FALSE; + int mile_stone = 1; + int32_t max_index = 1024; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_auto_size_ctl_t auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, #if 1 /* H5C_auto_resize_report_fcn rpt_fcn = */ NULL, @@ -1617,7 +1517,6 @@ smoke_check_7(int express_test, unsigned paged) /* int64_t epoch_length = */ 100000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -1628,13 +1527,12 @@ smoke_check_7(int express_test, unsigned paged) /* size_t max_increment = */ (8 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ - H5C_decr__age_out_with_threshold, + H5C_decr__age_out_with_threshold, /* double upper_hr_threshold = */ 0.995f, @@ -1649,67 +1547,63 @@ smoke_check_7(int express_test, unsigned paged) /* double empty_reserve = */ 0.1f }; - if(paged) + if (paged) TESTING("smoke check #7P -- all clean, ins, prot, unprot, AR cache 2") else TESTING("smoke check #7 -- all clean, ins, prot, unprot, AR cache 2") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1719,9 +1613,8 @@ smoke_check_7(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ FALSE); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1731,9 +1624,8 @@ smoke_check_7(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ FALSE); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1743,9 +1635,8 @@ smoke_check_7(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ TRUE); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -1754,9 +1645,8 @@ smoke_check_7(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_col_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1767,9 +1657,8 @@ smoke_check_7(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -1778,9 +1667,8 @@ smoke_check_7(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_col_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1791,32 +1679,33 @@ smoke_check_7(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_7() */ - /*------------------------------------------------------------------------- * Function: smoke_check_8() * @@ -1836,16 +1725,15 @@ smoke_check_7(int express_test, unsigned paged) static unsigned smoke_check_8(int express_test, unsigned paged) { - herr_t result; - hbool_t show_progress = FALSE; - int dirty_unprotects = FALSE; - hbool_t display_stats = FALSE; - int mile_stone = 1; - int32_t max_index = 1024; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_auto_size_ctl_t auto_size_ctl = - { + herr_t result; + hbool_t show_progress = FALSE; + int dirty_unprotects = FALSE; + hbool_t display_stats = FALSE; + int mile_stone = 1; + int32_t max_index = 1024; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_auto_size_ctl_t auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, #if 1 /* H5C_auto_resize_report_fcn rpt_fcn = */ NULL, @@ -1862,7 +1750,6 @@ smoke_check_8(int express_test, unsigned paged) /* int64_t epoch_length = */ 100000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -1873,13 +1760,12 @@ smoke_check_8(int express_test, unsigned paged) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ - H5C_decr__age_out_with_threshold, + H5C_decr__age_out_with_threshold, /* double upper_hr_threshold = */ 0.995f, @@ -1894,67 +1780,63 @@ smoke_check_8(int express_test, unsigned paged) /* double empty_reserve = */ 0.1f }; - if(paged) + if (paged) TESTING("smoke check #8P -- ~1/2 dirty, ins, prot, unprot, AR cache 2") else TESTING("smoke check #8 -- ~1/2 dirty, ins, prot, unprot, AR cache 2") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1964,9 +1846,8 @@ smoke_check_8(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ FALSE); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1976,9 +1857,8 @@ smoke_check_8(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ FALSE); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -1988,9 +1868,8 @@ smoke_check_8(int express_test, unsigned paged) /* display_detailed_stats */ FALSE, /* do_inserts */ TRUE); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -1999,9 +1878,8 @@ smoke_check_8(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_col_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -2012,9 +1890,8 @@ smoke_check_8(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -2023,9 +1900,8 @@ smoke_check_8(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); hl_col_major_scan_backward(/* file_ptr */ file_ptr, /* max_index */ max_index, @@ -2036,32 +1912,33 @@ smoke_check_8(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_8() */ - /*------------------------------------------------------------------------- * Function: smoke_check_9() * @@ -2088,88 +1965,83 @@ smoke_check_8(int express_test, unsigned paged) static unsigned smoke_check_9(int express_test, unsigned paged) { - herr_t result; - hbool_t show_progress = FALSE; - int dirty_unprotects = FALSE; - int dirty_destroys = FALSE; - hbool_t display_stats = FALSE; + herr_t result; + hbool_t show_progress = FALSE; + int dirty_unprotects = FALSE; + int dirty_destroys = FALSE; + hbool_t display_stats = FALSE; hbool_t display_detailed_stats = FALSE; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; - if(paged) + if (paged) TESTING("smoke check #9P -- all clean, ins, dest, ren, 4/2 MB, corked") else TESTING("smoke check #9 -- all clean, ins, dest, ren, 4/2 MB, corked") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); + file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); cache_ptr = file_ptr->shared->cache; /* disable evictions */ - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't disable evictions 1.\n"; - } + pass = FALSE; + failure_mssg = "can't disable evictions 1.\n"; + } } - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2179,33 +2051,31 @@ smoke_check_9(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ TRUE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); /* enable evictions */ - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't enable evictions 1.\n"; - } + pass = FALSE; + failure_mssg = "can't enable evictions 1.\n"; + } } - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled \n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled \n", FUNC, mile_stone++, (int)pass); row_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2215,31 +2085,29 @@ smoke_check_9(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ TRUE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't disable evictions 2.\n"; - } + pass = FALSE; + failure_mssg = "can't disable evictions 2.\n"; + } } - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled \n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled \n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2249,28 +2117,26 @@ smoke_check_9(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't enable evictions 2.\n"; - } + pass = FALSE; + failure_mssg = "can't enable evictions 2.\n"; + } } - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled \n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled \n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -2279,27 +2145,25 @@ smoke_check_9(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't disable evictions 3.\n"; - } + pass = FALSE; + failure_mssg = "can't disable evictions 3.\n"; + } } - if(show_progress) /* 12 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 12 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", FUNC, mile_stone++, (int)pass); col_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2308,9 +2172,8 @@ smoke_check_9(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 13 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 13 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -2319,27 +2182,25 @@ smoke_check_9(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 14 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 14 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't enable evictions 3.\n"; - } + pass = FALSE; + failure_mssg = "can't enable evictions 3.\n"; + } } - if(show_progress) /* 15 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 15 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", FUNC, mile_stone++, (int)pass); col_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2348,48 +2209,47 @@ smoke_check_9(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 16 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 16 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't disable evictions 4.\n"; - } + pass = FALSE; + failure_mssg = "can't disable evictions 4.\n"; + } } - - if(show_progress) /* 17 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 17 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 18 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 18 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_9() */ - /*------------------------------------------------------------------------- * Function: smoke_check_10() * @@ -2416,71 +2276,67 @@ smoke_check_9(int express_test, unsigned paged) static unsigned smoke_check_10(int express_test, unsigned paged) { - herr_t result; - hbool_t show_progress = FALSE; - int dirty_unprotects = TRUE; - int dirty_destroys = TRUE; - hbool_t display_stats = FALSE; + herr_t result; + hbool_t show_progress = FALSE; + int dirty_unprotects = TRUE; + int dirty_destroys = TRUE; + hbool_t display_stats = FALSE; hbool_t display_detailed_stats = FALSE; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; - if(paged) + if (paged) TESTING("smoke check #10P -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked") else TESTING("smoke check #10 -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked") - if ( paged && ( express_test > 0 ) ) { + if (paged && (express_test > 0)) { SKIPPED(); - return(0); + return (0); } - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); + file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); cache_ptr = file_ptr->shared->cache; - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2490,31 +2346,29 @@ smoke_check_10(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ TRUE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't disable evictions 1.\n"; - } + pass = FALSE; + failure_mssg = "can't disable evictions 1.\n"; + } } - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", FUNC, mile_stone++, (int)pass); row_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2524,31 +2378,29 @@ smoke_check_10(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ TRUE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't enable evictions 1.\n"; - } + pass = FALSE; + failure_mssg = "can't enable evictions 1.\n"; + } } - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2558,28 +2410,26 @@ smoke_check_10(int express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't disable evictions 2.\n"; - } + pass = FALSE; + failure_mssg = "can't disable evictions 2.\n"; + } } - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -2588,27 +2438,25 @@ smoke_check_10(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't enable evictions 2.\n"; - } + pass = FALSE; + failure_mssg = "can't enable evictions 2.\n"; + } } - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", FUNC, mile_stone++, (int)pass); col_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2617,24 +2465,22 @@ smoke_check_10(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 12 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 12 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't disable evictions 3.\n"; - } + pass = FALSE; + failure_mssg = "can't disable evictions 3.\n"; + } } - if(show_progress) /* 13 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 13 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", FUNC, mile_stone++, (int)pass); /* flush all entries in the cache: */ @@ -2643,27 +2489,25 @@ smoke_check_10(int express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 14 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 14 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't enable evictions 3.\n"; - } + pass = FALSE; + failure_mssg = "can't enable evictions 3.\n"; + } } - if(show_progress) /* 15 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 15 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", FUNC, mile_stone++, (int)pass); col_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2672,47 +2516,47 @@ smoke_check_10(int express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ dirty_unprotects); - if(show_progress) /* 16 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 16 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result < 0) { + if (result < 0) { - pass = FALSE; - failure_mssg = "can't disable evictions 4.\n"; - } + pass = FALSE; + failure_mssg = "can't disable evictions 4.\n"; + } } - if(show_progress) /* 17 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 17 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 18 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 18 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* smoke_check_10() */ - /*------------------------------------------------------------------------- * Function: write_permitted_check() * @@ -2734,70 +2578,67 @@ smoke_check_10(int express_test, unsigned paged) static unsigned write_permitted_check(int #if !H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -express_test, unsigned paged) + express_test, + unsigned paged) { #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS hbool_t show_progress = FALSE; hbool_t display_stats = FALSE; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t * file_ptr = NULL; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t * file_ptr = NULL; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - if(paged) + if (paged) TESTING("write permitted check -- 1/0 MB cache (paged aggregation)") else TESTING("write permitted check -- 1/0 MB cache") #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - switch (express_test) - { - case 0: - max_index = (10 * 1024) - 1; - break; + switch (express_test) { + case 0: + max_index = (10 * 1024) - 1; + break; - case 1: - max_index = (1 * 1024) - 1; - break; + case 1: + max_index = (1 * 1024) - 1; + break; - case 2: - max_index = (512) - 1; - break; + case 2: + max_index = (512) - 1; + break; - default: + default: SKIPPED(); HDfprintf(stdout, " Long tests disabled.\n"); - return 0; /* <========== note return */ - break; + return 0; /* <========== note return */ + break; } pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); reset_entries(); - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); file_ptr = setup_cache((size_t)(1 * 1024 * 1024), (size_t)0, paged); - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2807,18 +2648,17 @@ express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ TRUE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ TRUE, /* dirty_unprotects */ TRUE); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); write_permitted = FALSE; row_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2828,18 +2668,17 @@ express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ TRUE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ FALSE, /* dirty_unprotects */ NO_CHANGE); - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); write_permitted = TRUE; row_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2849,13 +2688,12 @@ express_test, unsigned paged) /* do_moves */ TRUE, /* move_to_main_addr */ FALSE, /* do_destroys */ FALSE, - /* do_mult_ro_protects */ TRUE, + /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ TRUE, /* dirty_unprotects */ TRUE); - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* flush and destroy all entries in the cache: */ @@ -2864,12 +2702,11 @@ express_test, unsigned paged) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); col_major_scan_forward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2878,14 +2715,13 @@ express_test, unsigned paged) /* do_inserts */ TRUE, /* dirty_unprotects */ TRUE); - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); write_permitted = FALSE; col_major_scan_backward(/* file_ptr */ file_ptr, - /* max_index */ max_index, + /* max_index */ max_index, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, @@ -2896,25 +2732,27 @@ express_test, unsigned paged) write_permitted = TRUE; - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); takedown_cache(file_ptr, display_stats, TRUE); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); verify_clean(); verify_unprotected(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ @@ -2929,7 +2767,6 @@ express_test, unsigned paged) } /* write_permitted_check() */ - /*------------------------------------------------------------------------- * Function: check_insert_entry() * @@ -2954,21 +2791,21 @@ express_test, unsigned paged) static unsigned check_insert_entry(unsigned paged) { - int entry_type = PICO_ENTRY_TYPE; - int i; - herr_t result; - hbool_t in_cache; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - size_t entry_size; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - test_entry_t * base_addr; - test_entry_t * entry_ptr; - struct H5C_cache_entry_t * search_ptr; - - if(paged) + int entry_type = PICO_ENTRY_TYPE; + int i; + herr_t result; + hbool_t in_cache; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + size_t entry_size; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + struct H5C_cache_entry_t *search_ptr; + + if (paged) TESTING("H5C_insert_entry() functionality (paged aggregation)") else TESTING("H5C_insert_entry() functionality") @@ -2985,15 +2822,15 @@ check_insert_entry(unsigned paged) * used to be the case.) */ - if(pass) { + if (pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); cache_ptr = file_ptr->shared->cache; } - if(pass) { + if (pass) { insert_entry(file_ptr, entry_type, 0, H5C__NO_FLAGS_SET); insert_entry(file_ptr, entry_type, 1, H5C__SET_FLUSH_MARKER_FLAG); @@ -3003,147 +2840,137 @@ check_insert_entry(unsigned paged) /* Verify that the entries are inserted as desired. */ - i = 0; + i = 0; base_addr = entries[0]; - while(pass && (i < 4)) - { - entry_ptr = &(base_addr[i]); + while (pass && (i < 4)) { + entry_ptr = &(base_addr[i]); - /* Start by checking everything we can via H5C_get_entry_status() */ + /* Start by checking everything we can via H5C_get_entry_status() */ - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_entry_status() reports failure."; } - if(pass) { + if (pass) { - /* check the universals */ - if((!in_cache) || (!is_dirty) || (is_protected) || - (entry_size != entry_sizes[entry_type])) { + /* check the universals */ + if ((!in_cache) || (!is_dirty) || (is_protected) || (entry_size != entry_sizes[entry_type])) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 1."; } - } + } - if(pass) { + if (pass) { /* verify that the pinned flag got set correctly */ - if((i == 2) || (i == 3)) { + if ((i == 2) || (i == 3)) { - if(!is_pinned) { + if (!is_pinned) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 2."; - } - } else if(is_pinned) { + } + } + else if (is_pinned) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 3."; + } + else if (is_pinned != ((entry_ptr->header).is_pinned)) { - } else if(is_pinned != ((entry_ptr->header).is_pinned)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 4."; } - } + } - /* Thats all we can get from H5C_get_entry_status(). - * Now start looking at the cache data structures directly. - */ + /* Thats all we can get from H5C_get_entry_status(). + * Now start looking at the cache data structures directly. + */ - if(pass) { + if (pass) { /* Verify that the flush marker got set correctly */ - if((i == 1) || (i == 3)) { + if ((i == 1) || (i == 3)) { - if(!((entry_ptr->header).flush_marker)) { + if (!((entry_ptr->header).flush_marker)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 5."; - } - } else if((entry_ptr->header).flush_marker) { + } + } + else if ((entry_ptr->header).flush_marker) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 6."; + } } - } - if(pass) { + if (pass) { - /* Verify that pinned entries are in the pinned entry list */ - if((entry_ptr->header).is_pinned) { + /* Verify that pinned entries are in the pinned entry list */ + if ((entry_ptr->header).is_pinned) { - search_ptr = cache_ptr->pel_head_ptr; + search_ptr = cache_ptr->pel_head_ptr; - while((search_ptr != NULL) && - (search_ptr != - (struct H5C_cache_entry_t *)entry_ptr)) - { - search_ptr = search_ptr->next; - } + while ((search_ptr != NULL) && (search_ptr != (struct H5C_cache_entry_t *)entry_ptr)) { + search_ptr = search_ptr->next; + } - if(search_ptr == NULL) { + if (search_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 7."; + } + } } - } - } - if(pass) { + if (pass) { - /* Verify that unpinned entries are in the LRU list */ - if(!((entry_ptr->header).is_pinned)) { + /* Verify that unpinned entries are in the LRU list */ + if (!((entry_ptr->header).is_pinned)) { - search_ptr = cache_ptr->LRU_head_ptr; + search_ptr = cache_ptr->LRU_head_ptr; - while((search_ptr != NULL) && - (search_ptr != - (struct H5C_cache_entry_t *)entry_ptr)) - { - search_ptr = search_ptr->next; - } + while ((search_ptr != NULL) && (search_ptr != (struct H5C_cache_entry_t *)entry_ptr)) { + search_ptr = search_ptr->next; + } - if(search_ptr == NULL) { + if (search_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 8."; + } + } } - } - } #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - if(pass) { + if (pass) { - /* Verify that unpinned entries are in the dirty LRU list */ - if(!((entry_ptr->header).is_pinned)) { + /* Verify that unpinned entries are in the dirty LRU list */ + if (!((entry_ptr->header).is_pinned)) { - search_ptr = cache_ptr->dLRU_head_ptr; + search_ptr = cache_ptr->dLRU_head_ptr; - while((search_ptr != NULL) && - (search_ptr != - (struct H5C_cache_entry_t *)entry_ptr)) - { - search_ptr = search_ptr->aux_next; - } + while ((search_ptr != NULL) && (search_ptr != (struct H5C_cache_entry_t *)entry_ptr)) { + search_ptr = search_ptr->aux_next; + } - if(search_ptr == NULL) { + if (search_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 9."; + } + } } - } - } #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - i++; + i++; } /* while */ @@ -3152,83 +2979,74 @@ check_insert_entry(unsigned paged) * as expected. */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 4) || - (cache_ptr->index_size != 4 * entry_sizes[entry_type]) || - (cache_ptr->slist_len != 4) || - (cache_ptr->slist_size != 4 * entry_sizes[entry_type]) || - (cache_ptr->pl_len != 0) || - (cache_ptr->pl_size != (size_t)0) || - (cache_ptr->pel_len != 2) || - (cache_ptr->pel_size != 2 * entry_sizes[entry_type]) || - (cache_ptr->LRU_list_len != 2) || - (cache_ptr->LRU_list_size != 2 * entry_sizes[entry_type]) + if ((cache_ptr->index_len != 4) || (cache_ptr->index_size != 4 * entry_sizes[entry_type]) || + (cache_ptr->slist_len != 4) || (cache_ptr->slist_size != 4 * entry_sizes[entry_type]) || + (cache_ptr->pl_len != 0) || (cache_ptr->pl_size != (size_t)0) || (cache_ptr->pel_len != 2) || + (cache_ptr->pel_size != 2 * entry_sizes[entry_type]) || (cache_ptr->LRU_list_len != 2) || + (cache_ptr->LRU_list_size != 2 * entry_sizes[entry_type]) #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - || (cache_ptr->dLRU_list_len != 2) || - (cache_ptr->dLRU_list_size != 2 * entry_sizes[entry_type]) || - (cache_ptr->cLRU_list_len != 0) || - (cache_ptr->cLRU_list_size != (size_t)0) + || (cache_ptr->dLRU_list_len != 2) || + (cache_ptr->dLRU_list_size != 2 * entry_sizes[entry_type]) || (cache_ptr->cLRU_list_len != 0) || + (cache_ptr->cLRU_list_size != (size_t)0) #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - ) { + ) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected insert results 10."; - } + } } /* Finally, if stats collection is enabled, verify that the expected * stats are collected. */ #if H5C_COLLECT_CACHE_STATS - if(pass) { - - if((cache_ptr->insertions[entry_type] != 4) || - (cache_ptr->pinned_insertions[entry_type] != 2) || - (cache_ptr->pins[entry_type] != 2) || - (cache_ptr->unpins[entry_type] != 0) || - (cache_ptr->dirty_pins[entry_type] != 0) || - (cache_ptr->max_index_len != 4) || - (cache_ptr->max_index_size != 4 * entry_sizes[entry_type]) || - (cache_ptr->max_slist_len != 4) || - (cache_ptr->max_slist_size != 4 * entry_sizes[entry_type]) || - (cache_ptr->max_pl_len != 0) || - (cache_ptr->max_pl_size != (size_t)0) || - (cache_ptr->max_pel_len != 2) || - (cache_ptr->max_pel_size != 2 * entry_sizes[entry_type])) { + if (pass) { - pass = FALSE; + if ((cache_ptr->insertions[entry_type] != 4) || (cache_ptr->pinned_insertions[entry_type] != 2) || + (cache_ptr->pins[entry_type] != 2) || (cache_ptr->unpins[entry_type] != 0) || + (cache_ptr->dirty_pins[entry_type] != 0) || (cache_ptr->max_index_len != 4) || + (cache_ptr->max_index_size != 4 * entry_sizes[entry_type]) || (cache_ptr->max_slist_len != 4) || + (cache_ptr->max_slist_size != 4 * entry_sizes[entry_type]) || (cache_ptr->max_pl_len != 0) || + (cache_ptr->max_pl_size != (size_t)0) || (cache_ptr->max_pel_len != 2) || + (cache_ptr->max_pel_size != 2 * entry_sizes[entry_type])) { + + pass = FALSE; failure_mssg = "Unexpected insert results 11."; - } + } } #endif /* H5C_COLLECT_CACHE_STATS */ /* Unpin the pinned entries so we can take down the cache cleanly. */ - if(pass) { + if (pass) { unpin_entry(entry_type, 2); - unpin_entry(entry_type, 3); + unpin_entry(entry_type, 3); } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } - - if(!pass) { - - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } + + if (!pass) { + + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_insert_entry() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache() * @@ -3248,9 +3066,9 @@ check_insert_entry(unsigned paged) static unsigned check_flush_cache(unsigned paged) { - H5F_t * file_ptr = NULL; + H5F_t *file_ptr = NULL; - if(paged) + if (paged) TESTING("H5C_flush_cache() functionality (paged aggregation)") else TESTING("H5C_flush_cache() functionality") @@ -3262,7 +3080,7 @@ check_flush_cache(unsigned paged) * place. */ - if(pass) { + if (pass) { reset_entries(); @@ -3273,7 +3091,7 @@ check_flush_cache(unsigned paged) * checking in this case, so simply check the return values. */ - if(pass) { + if (pass) { check_flush_cache__empty_cache(file_ptr); } @@ -3282,39 +3100,42 @@ check_flush_cache(unsigned paged) * Start with a clean entry, with no flags set. */ - if(pass) { + if (pass) { check_flush_cache__single_entry(file_ptr); } - if(pass) { + if (pass) { check_flush_cache__multi_entry(file_ptr); } - if(pass) { + if (pass) { - check_flush_cache__flush_ops(file_ptr); + check_flush_cache__flush_ops(file_ptr); } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_flush_cache() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__empty_cache() * @@ -3332,76 +3153,72 @@ check_flush_cache(unsigned paged) */ static void -check_flush_cache__empty_cache(H5F_t * file_ptr) +check_flush_cache__empty_cache(H5F_t *file_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; - herr_t result; + H5C_t *cache_ptr = file_ptr->shared->cache; + herr_t result; - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache_ptr NULL on entry to empty cache case."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not empty at beginning of empty cache case."; } - /* Test behaviour on an empty cache. Can't do much sanity * checking in this case, so simply check the return values. */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "flush with flags = 0x00 failed on empty cache.\n"; } } - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "flush with flags = 0x04 failed on empty cache.\n"; } } - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_CLEAR_ONLY_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "flush with flags = 0x08 failed on empty cache.\n"; } } - - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_MARKED_ENTRIES_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "flush with flags = 0x10 failed on empty cache.\n"; } } } /* check_flush_cache__empty_cache() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__multi_entry() * @@ -3422,874 +3239,679 @@ check_flush_cache__empty_cache(H5F_t * file_ptr) */ static void -check_flush_cache__multi_entry(H5F_t * file_ptr) +check_flush_cache__multi_entry(H5F_t *file_ptr) { H5C_t *cache_ptr = file_ptr->shared->cache; - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache_ptr NULL on entry to multi entry case."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not empty at beginning of multi entry case."; } - if(pass) - { - int test_num = 1; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 2; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 3; - unsigned int flush_flags = H5C__FLUSH_CLEAR_ONLY_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 4; - unsigned int flush_flags = H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 5; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 6; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 7; - unsigned int flush_flags = H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG; + if (pass) { + int test_num = 1; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 2; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 3; + unsigned int flush_flags = H5C__FLUSH_CLEAR_ONLY_FLAG; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 4; + unsigned int flush_flags = H5C__FLUSH_MARKED_ENTRIES_FLAG; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 5; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 6; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 8; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG; + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 7; + unsigned int flush_flags = H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 8; + unsigned int flush_flags = + H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); } - /* verify that all other flags are ignored */ - if(pass) - { - int test_num = 9; - unsigned int flush_flags = (unsigned) - ~(H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG); - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); + if (pass) { + int test_num = 9; + unsigned int flush_flags = (unsigned)~(H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG); + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); } /* Now do pinned entry tests: @@ -4298,664 +3920,508 @@ check_flush_cache__multi_entry(H5F_t * file_ptr) * of the flush routine to unravel collections of pinned entries. */ - if(pass) - { - int test_num = 1; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 2, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 3, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 4, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 5, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 6, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, 20, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 7, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, 20, 30, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 2; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 2, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 3, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, - -1, -1, -1, -1 -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {10, -1, -1, -1 -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 2, - /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {10, 20, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 3, - /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, - -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {10, 20, 30, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - if(pass) - { - int test_num = 3; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 4; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 4, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 4, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - PICO_ENTRY_TYPE, - -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); - } - - - if(pass) - { - int test_num = 5; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ TRUE, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, - -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, - flush_flags, spec_size, spec); + if (pass) { + int test_num = 1; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + unsigned int spec_size = 8; + struct pe_flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 2, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 3, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 4, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 5, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, + -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 6, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, + MONSTER_ENTRY_TYPE, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, 20, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 7, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, + MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, 20, 30, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 2; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + unsigned int spec_size = 8; + struct pe_flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 2, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 3, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, -1, -1, -1, -1 - 1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {10, -1, -1, -1 - 1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 2, + /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {10, 20, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 3, + /* pin_type[MAX_PINS] = */ + {MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {10, 20, 30, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 3; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG; + unsigned int spec_size = 8; + struct pe_flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 4; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; + unsigned int spec_size = 8; + struct pe_flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 4, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 4, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 5; + unsigned int flush_flags = + H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; + unsigned int spec_size = 8; + struct pe_flush_cache_test_spec spec[8] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ TRUE, + /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); } return; } /* check_flush_cache__multi_entry() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__multi_entry_test() * @@ -4972,86 +4438,69 @@ check_flush_cache__multi_entry(H5F_t * file_ptr) */ static void -check_flush_cache__multi_entry_test(H5F_t * file_ptr, - int test_num, - unsigned int flush_flags, - unsigned int spec_size, - struct flush_cache_test_spec spec[]) +check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, + unsigned int spec_size, struct flush_cache_test_spec spec[]) { - H5C_t * cache_ptr = file_ptr->shared->cache; - static char msg[128]; - herr_t result; - unsigned u; - size_t total_entry_size = 0; - test_entry_t * base_addr; - test_entry_t * entry_ptr; - -#if 0 /* JRM */ + H5C_t * cache_ptr = file_ptr->shared->cache; + static char msg[128]; + herr_t result; + unsigned u; + size_t total_entry_size = 0; + test_entry_t *base_addr; + test_entry_t *entry_ptr; + +#if 0 /* JRM */ /* This gets used a lot, so lets leave it in. */ HDfprintf(stdout, "check_flush_cache__multi_entry_test: test %d\n", test_num); #endif /* JRM */ - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache_ptr NULL on entry to single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache_ptr NULL on entry to single entry test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache not empty at beginning of multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache not empty at beginning of multi entry test #%d.", test_num); failure_mssg = msg; } - else if((spec_size < 1) || (spec == NULL)) { + else if ((spec_size < 1) || (spec == NULL)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "missing/bad test spec on entry to multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "missing/bad test spec on entry to multi entry test #%d.", test_num); failure_mssg = msg; } u = 0; - while(pass && (u < spec_size)) - { - if(((unsigned)spec[u].entry_num != u) || - (spec[u].entry_type < 0) || - (spec[u].entry_type >= NUMBER_OF_ENTRY_TYPES) || - (spec[u].entry_index < 0) || - (spec[u].entry_index > max_indices[spec[u].entry_type])) { + while (pass && (u < spec_size)) { + if (((unsigned)spec[u].entry_num != u) || (spec[u].entry_type < 0) || + (spec[u].entry_type >= NUMBER_OF_ENTRY_TYPES) || (spec[u].entry_index < 0) || + (spec[u].entry_index > max_indices[spec[u].entry_type])) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "bad data in spec[%u] on entry to multi entry test #%d.", - u, test_num); + HDsnprintf(msg, (size_t)128, "bad data in spec[%u] on entry to multi entry test #%d.", u, + test_num); failure_mssg = msg; } u++; } u = 0; - while(pass && (u < spec_size)) - { - if(spec[u].insert_flag) { - - insert_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, - spec[u].flags); + while (pass && (u < spec_size)) { + if (spec[u].insert_flag) { - } else { + insert_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); + } + else { protect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index); - unprotect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, - spec[u].flags); + unprotect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); } total_entry_size += entry_sizes[spec[u].entry_type]; @@ -5059,29 +4508,27 @@ check_flush_cache__multi_entry_test(H5F_t * file_ptr, u++; } - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, flush_flags); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "flush with flags 0x%x failed in multi entry test #%d.", - flush_flags, test_num); + HDsnprintf(msg, (size_t)128, "flush with flags 0x%x failed in multi entry test #%d.", flush_flags, + test_num); failure_mssg = msg; } } u = 0; - while(pass && (u < spec_size)) - { + while (pass && (u < spec_size)) { base_addr = entries[spec[u].entry_type]; entry_ptr = &(base_addr[spec[u].entry_index]); - if((entry_ptr->deserialized != spec[u].expected_deserialized) || - (entry_ptr->serialized != spec[u].expected_serialized) || - (entry_ptr->destroyed != spec[u].expected_destroyed)) { + if ((entry_ptr->deserialized != spec[u].expected_deserialized) || + (entry_ptr->serialized != spec[u].expected_serialized) || + (entry_ptr->destroyed != spec[u].expected_destroyed)) { #if 0 /* This is useful debugging code. Lets keep it around. */ @@ -5097,69 +4544,49 @@ check_flush_cache__multi_entry_test(H5F_t * file_ptr, #endif pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Bad status on entry %u after flush in multi entry test #%d.", - u, test_num); + HDsnprintf(msg, (size_t)128, "Bad status on entry %u after flush in multi entry test #%d.", u, + test_num); failure_mssg = msg; } u++; } - if(pass) { - - if((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) - && - ((cache_ptr->index_len != spec_size) - || - (cache_ptr->index_size != total_entry_size) - ) - ) - || - (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) - && - ((cache_ptr->index_len != 0) - || - (cache_ptr->index_size != 0) - ) - ) - ) { + if (pass) { + + if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && + ((cache_ptr->index_len != spec_size) || (cache_ptr->index_size != total_entry_size))) || + (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && + ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after flush in multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Unexpected cache len/size after flush in multi entry test #%d.", + test_num); failure_mssg = msg; } } /* clean up the cache to prep for the next test */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Flush failed on cleanup in multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Flush failed on cleanup in multi entry test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after cleanup in multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Unexpected cache len/size after cleanup in multi entry test #%d.", + test_num); failure_mssg = msg; - } } u = 0; - while(pass && (u < spec_size)) - { + while (pass && (u < spec_size)) { base_addr = entries[spec[u].entry_type]; entry_ptr = &(base_addr[spec[u].entry_index]); @@ -5174,7 +4601,6 @@ check_flush_cache__multi_entry_test(H5F_t * file_ptr, } /* check_flush_cache__multi_entry_test() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__pe_multi_entry_test() * @@ -5191,128 +4617,104 @@ check_flush_cache__multi_entry_test(H5F_t * file_ptr, */ static void -check_flush_cache__pe_multi_entry_test(H5F_t * file_ptr, - int test_num, - unsigned int flush_flags, - unsigned int spec_size, - struct pe_flush_cache_test_spec spec[]) +check_flush_cache__pe_multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, + unsigned int spec_size, struct pe_flush_cache_test_spec spec[]) { - H5C_t *cache_ptr = file_ptr->shared->cache; - static char msg[128]; - herr_t result; - unsigned u; - int j; - size_t total_entry_size = 0; - test_entry_t * base_addr; - test_entry_t * entry_ptr; - -#if 0 /* JRM */ + H5C_t * cache_ptr = file_ptr->shared->cache; + static char msg[128]; + herr_t result; + unsigned u; + int j; + size_t total_entry_size = 0; + test_entry_t *base_addr; + test_entry_t *entry_ptr; + +#if 0 /* JRM */ /* This is useful debugging code. Leave it in for now. */ HDfprintf(stdout, "check_flush_cache__pe_multi_entry_test: test %d\n", test_num); #endif /* JRM */ - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache_ptr NULL on entry to pe multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache_ptr NULL on entry to pe multi entry test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache not empty at beginning of pe multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache not empty at beginning of pe multi entry test #%d.", test_num); failure_mssg = msg; } - else if((spec_size < 1) || (spec == NULL)) { + else if ((spec_size < 1) || (spec == NULL)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "missing/bad test spec on entry to pe multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "missing/bad test spec on entry to pe multi entry test #%d.", test_num); failure_mssg = msg; } u = 0; - while(pass && (u < spec_size)) - { - if(((unsigned)spec[u].entry_num != u) || - (spec[u].entry_type < 0) || - (spec[u].entry_type >= NUMBER_OF_ENTRY_TYPES) || - (spec[u].entry_index < 0) || - (spec[u].entry_index > max_indices[spec[u].entry_type]) || - (spec[u].num_pins < 0) || - (spec[u].num_pins > MAX_PINS)) { + while (pass && (u < spec_size)) { + if (((unsigned)spec[u].entry_num != u) || (spec[u].entry_type < 0) || + (spec[u].entry_type >= NUMBER_OF_ENTRY_TYPES) || (spec[u].entry_index < 0) || + (spec[u].entry_index > max_indices[spec[u].entry_type]) || (spec[u].num_pins < 0) || + (spec[u].num_pins > MAX_PINS)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "bad data in spec[%u] on entry to pe multi entry test #%d.", - u, test_num); + HDsnprintf(msg, (size_t)128, "bad data in spec[%u] on entry to pe multi entry test #%d.", u, + test_num); failure_mssg = msg; } u++; } u = 0; - while(pass && (u < spec_size)) - { - if(spec[u].insert_flag) { + while (pass && (u < spec_size)) { + if (spec[u].insert_flag) { - insert_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, - spec[u].flags); - - } else { + insert_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); + } + else { protect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index); - unprotect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, - spec[u].flags); + unprotect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); } total_entry_size += entry_sizes[spec[u].entry_type]; - for (j = 0; j < spec[u].num_pins; j++) - { - create_pinned_entry_dependency(file_ptr, - spec[u].entry_type, - spec[u].entry_index, - spec[u].pin_type[j], - spec[u].pin_idx[j]); - } + for (j = 0; j < spec[u].num_pins; j++) { + create_pinned_entry_dependency(file_ptr, spec[u].entry_type, spec[u].entry_index, + spec[u].pin_type[j], spec[u].pin_idx[j]); + } u++; } - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, flush_flags); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "flush with flags 0x%x failed in pe multi entry test #%d.", - flush_flags, test_num); + HDsnprintf(msg, (size_t)128, "flush with flags 0x%x failed in pe multi entry test #%d.", + flush_flags, test_num); failure_mssg = msg; } } u = 0; - while(pass && (u < spec_size)) - { + while (pass && (u < spec_size)) { base_addr = entries[spec[u].entry_type]; entry_ptr = &(base_addr[spec[u].entry_index]); - if((entry_ptr->deserialized != spec[u].expected_deserialized) || - (entry_ptr->serialized != spec[u].expected_serialized) || - (entry_ptr->destroyed != spec[u].expected_destroyed)) { + if ((entry_ptr->deserialized != spec[u].expected_deserialized) || + (entry_ptr->serialized != spec[u].expected_serialized) || + (entry_ptr->destroyed != spec[u].expected_destroyed)) { #if 0 /* This is useful debugging code. Lets keep it around. */ @@ -5328,69 +4730,49 @@ check_flush_cache__pe_multi_entry_test(H5F_t * file_ptr, #endif pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Bad status on entry %u after flush in pe multi entry test #%d.", - u, test_num); + HDsnprintf(msg, (size_t)128, "Bad status on entry %u after flush in pe multi entry test #%d.", u, + test_num); failure_mssg = msg; } u++; } - if(pass) { - - if((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) - && - ((cache_ptr->index_len != spec_size) - || - (cache_ptr->index_size != total_entry_size) - ) - ) - || - (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) - && - ((cache_ptr->index_len != 0) - || - (cache_ptr->index_size != 0) - ) - ) - ) { + if (pass) { + + if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && + ((cache_ptr->index_len != spec_size) || (cache_ptr->index_size != total_entry_size))) || + (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && + ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after flush in pe multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Unexpected cache len/size after flush in pe multi entry test #%d.", + test_num); failure_mssg = msg; } } /* clean up the cache to prep for the next test */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Flush failed on cleanup in pe multi entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Flush failed on cleanup in pe multi entry test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after cleanup in pe multi entry test #%d.", - test_num); + "Unexpected cache len/size after cleanup in pe multi entry test #%d.", test_num); failure_mssg = msg; - } } u = 0; - while(pass && (u < spec_size)) - { + while (pass && (u < spec_size)) { base_addr = entries[spec[u].entry_type]; entry_ptr = &(base_addr[spec[u].entry_index]); @@ -5405,7 +4787,6 @@ check_flush_cache__pe_multi_entry_test(H5F_t * file_ptr, } /* check_flush_cache__pe_multi_entry_test() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__flush_ops() * @@ -5428,3746 +4809,3172 @@ check_flush_cache__pe_multi_entry_test(H5F_t * file_ptr, */ static void -check_flush_cache__flush_ops(H5F_t * file_ptr) +check_flush_cache__flush_ops(H5F_t *file_ptr) { H5C_t *cache_ptr = file_ptr->shared->cache; - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache_ptr NULL on entry to flush ops test."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not empty at beginning of flush ops test."; } - if(pass) /* test #1 */ - { - /* start with a very simple test, in which there are two entries - * resident in cache, and the second entry dirties the first in - * the flush callback. No size changes, and no flush flags. - */ - int test_num = 1; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 2; - unsigned init_expected_index_len = 2; - size_t init_expected_index_size = 2 * PICO_ENTRY_SIZE; - unsigned expected_index_len = 2; - size_t expected_index_size = 2 * PICO_ENTRY_SIZE; - struct fo_flush_cache_test_spec spec[2] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ 0, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - - if(pass) /* test #2 */ - { - /* Same as test 1, only this time set the flush invalidate flag. - * Note that we must repeat all tests with the flush invalidate flag - * as this triggers a different set of code to execute the flush. - * - * Create two entries resident in cache, and have the second entry - * dirty the first in the flush callback. - */ - int test_num = 2; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 2; - unsigned init_expected_index_len = 2; - size_t init_expected_index_size = 2 * PICO_ENTRY_SIZE; - unsigned expected_index_len = 0; - size_t expected_index_size = 0; - struct fo_flush_cache_test_spec spec[2] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr*/ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - - if(pass) /* test #3 */ - { - /* Single entry test verifying that the cache can handle the case in - * which the call back function resizes the entry for which it has - * been called. - */ - int test_num = 3; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 4; - unsigned expected_index_len = 1; - size_t expected_index_size = VARIABLE_ENTRY_SIZE / 2; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr:*/ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - - if(pass) /* test #4 */ - { - /* Repeat test #4 with the flush invalidate flag. - * - * Single entry test verifying that the cache can handle the case in - * which the call back function resizes the entry for which it has - * been called. - */ - int test_num = 4; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 4; - unsigned expected_index_len = 0; - size_t expected_index_size = 0; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - - if(pass) /* test #5 & #6 */ + if (pass) /* test #1 */ { - /* Single entry test verifying that the cache can handle the case in - * which the call back function first resizes and then moves the - * entry for which it has been called. - * - * Run this entry twice, as the first run moves the entry to its - * alternate address, and the second moves it back. + /* start with a very simple test, in which there are two entries + * resident in cache, and the second entry dirties the first in + * the flush callback. No size changes, and no flush flags. + */ + int test_num = 1; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 2; + unsigned init_expected_index_len = 2; + size_t init_expected_index_size = 2 * PICO_ENTRY_SIZE; + unsigned expected_index_len = 2; + size_t expected_index_size = 2 * PICO_ENTRY_SIZE; + struct fo_flush_cache_test_spec spec[2] = { + {/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ 0, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #2 */ + { + /* Same as test 1, only this time set the flush invalidate flag. + * Note that we must repeat all tests with the flush invalidate flag + * as this triggers a different set of code to execute the flush. + * + * Create two entries resident in cache, and have the second entry + * dirty the first in the flush callback. + */ + int test_num = 2; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 2; + unsigned init_expected_index_len = 2; + size_t init_expected_index_size = 2 * PICO_ENTRY_SIZE; + unsigned expected_index_len = 0; + size_t expected_index_size = 0; + struct fo_flush_cache_test_spec spec[2] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr*/ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #3 */ + { + /* Single entry test verifying that the cache can handle the case in + * which the call back function resizes the entry for which it has + * been called. + */ + int test_num = 3; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 4; + unsigned expected_index_len = 1; + size_t expected_index_size = VARIABLE_ENTRY_SIZE / 2; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr:*/ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #4 */ + { + /* Repeat test #4 with the flush invalidate flag. + * + * Single entry test verifying that the cache can handle the case in + * which the call back function resizes the entry for which it has + * been called. + */ + int test_num = 4; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 4; + unsigned expected_index_len = 0; + size_t expected_index_size = 0; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #5 & #6 */ + { + /* Single entry test verifying that the cache can handle the case in + * which the call back function first resizes and then moves the + * entry for which it has been called. + * + * Run this entry twice, as the first run moves the entry to its + * alternate address, and the second moves it back. * * 10/8/07 -- JRM * Added a resize operation to this test to satisfy the new * requiremnt that any resize of an entry on flush will always * be accompanied by a resize. Note that as a result, this * test becomes redundant with later tests. - */ - int test_num = 5; /* and 6 */ - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 1; - size_t expected_index_size = VARIABLE_ENTRY_SIZE / 2; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 2, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE + */ + int test_num = 5; /* and 6 */ + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 1; + size_t expected_index_size = VARIABLE_ENTRY_SIZE / 2; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 2, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + + /* this change forces the move to move the target entry back to its + * main address. The first test moved it to its alternate address. + * + * Note that these two tests are not the same, as in the first test, + * the moved entry is moved forward in the slist. In the second + * it is moved backwards. + * + * Since there is only one entry in the cache, this doesn't really + * matter in this case. But we will do similar tests later with + * other entries in the cache. + */ + if (pass) { + + spec[0].flush_ops[1].flag = TRUE; + test_num = 6; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } } - }; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - - /* this change forces the move to move the target entry back to its - * main address. The first test moved it to its alternate address. - * - * Note that these two tests are not the same, as in the first test, - * the moved entry is moved forward in the slist. In the second - * it is moved backwards. - * - * Since there is only one entry in the cache, this doesn't really - * matter in this case. But we will do similar tests later with - * other entries in the cache. - */ - if(pass) { - - spec[0].flush_ops[1].flag = TRUE; - test_num = 6; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - } - - if(pass) /* test #7 & #8 */ + if (pass) /* test #7 & #8 */ { - /* Run tests 5 & 6 again, using the flush invalidate flag on the - * second test. - * - * Single entry test verifying that the cache can handle the case in - * which the call back function moves the entry for which it has - * been called. - * - * Run this entry twice, as the first run moves the entry to its - * alternate address, and the second moves it back. + /* Run tests 5 & 6 again, using the flush invalidate flag on the + * second test. + * + * Single entry test verifying that the cache can handle the case in + * which the call back function moves the entry for which it has + * been called. + * + * Run this entry twice, as the first run moves the entry to its + * alternate address, and the second moves it back. * * 10/8/07 -- JRM * Added a resize operation to this test to satisfy the new * requiremnt that any resize of an entry on flush will always * be accompanied by a resize. Note that as a result, this * test becomes redundant with later tests. - */ - int test_num = 7; /* and 8 */ - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 1; - size_t expected_index_size = VARIABLE_ENTRY_SIZE / 2; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 2, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE + */ + int test_num = 7; /* and 8 */ + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 1; + size_t expected_index_size = VARIABLE_ENTRY_SIZE / 2; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 2, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + + /* this change forces the move to move the target entry back to its + * main address. The first test moved it to its alternate address. + * + * Note that these two tests are not the same, as in the first test, + * the moved entry is moved forward in the slist. In the second + * it is moved backwards. + * + * Since there is only one entry in the cache, this doesn't really + * matter in this case. But we will do similar tests later with + * other entries in the cache. + */ + + if (pass) { + + test_num = 8; + flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + expected_index_len = 0; + expected_index_size = 0; + spec[0].flush_ops[1].flag = TRUE; + spec[0].expected_destroyed = TRUE; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } } - }; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - - /* this change forces the move to move the target entry back to its - * main address. The first test moved it to its alternate address. - * - * Note that these two tests are not the same, as in the first test, - * the moved entry is moved forward in the slist. In the second - * it is moved backwards. - * - * Since there is only one entry in the cache, this doesn't really - * matter in this case. But we will do similar tests later with - * other entries in the cache. - */ - - if(pass) { - - test_num = 8; - flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - expected_index_len = 0; - expected_index_size = 0; - spec[0].flush_ops[1].flag = TRUE; - spec[0].expected_destroyed = TRUE; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - } - - if(pass) /* test #9 & #10 */ + if (pass) /* test #9 & #10 */ { - /* Single entry test verifying that the cache can handle the case in - * which the call back function both resizes and moves the entry - * for which it has been called. - * - * Again, we run this entry twice, as the first run moves the entry + /* Single entry test verifying that the cache can handle the case in + * which the call back function both resizes and moves the entry + * for which it has been called. + * + * Again, we run this entry twice, as the first run moves the entry * to its alternate address, and the second moves it back. - */ - int test_num = 9; /* and 10 */ - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 2; - unsigned expected_index_len = 1; - size_t expected_index_size = VARIABLE_ENTRY_SIZE / 4; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 2, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 2, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; + */ + int test_num = 9; /* and 10 */ + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 2; + unsigned expected_index_len = 1; + size_t expected_index_size = VARIABLE_ENTRY_SIZE / 4; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 2, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 2, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + + /* this change forces the move to move the target entry back to its + * main address. The first test moved it to its alternate address. + * + * Note that these two tests are not the same, as in the first test, + * the moved entry is moved forward in the slist. In the second + * it is moved backwards. + * + * Since there is only one entry in the cache, this doesn't really + * matter in this case. But we will do similar tests later with + * other entries in the cache. + */ + if (pass) { - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - - /* this change forces the move to move the target entry back to its - * main address. The first test moved it to its alternate address. - * - * Note that these two tests are not the same, as in the first test, - * the moved entry is moved forward in the slist. In the second - * it is moved backwards. - * - * Since there is only one entry in the cache, this doesn't really - * matter in this case. But we will do similar tests later with - * other entries in the cache. - */ - if(pass) { - - spec[0].flush_ops[1].flag = TRUE; - test_num = 10; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - } - - if(pass) /* test #11 & #12 */ - { - /* Repeat the previous test with the flush invalidate flag on the - * second test. - * - * Single entry test verifying that the cache can handle the case in - * which the call back function both resizes and moves the entry - * for which it has been called. - * - * Again, we run this entry twice, as the first run moves the entry to its - * alternate address, and the second moves it back. - */ - int test_num = 11; /* and 12 */ - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 2; - unsigned expected_index_len = 1; - size_t expected_index_size = VARIABLE_ENTRY_SIZE / 4; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 2, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 2, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; + spec[0].flush_ops[1].flag = TRUE; + test_num = 10; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - - /* this change forces the move to move the target entry back to its - * main address. The first test moved it to its alternate address. - * - * Note that these two tests are not the same, as in the first test, - * the moved entry is moved forward in the slist. In the second - * it is moved backwards. - * - * Since there is only one entry in the cache, this doesn't really - * matter in this case. But we will do similar tests later with - * other entries in the cache. - */ - if(pass) { - - test_num = 12; - flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - expected_index_len = 0; - expected_index_size = 0; - spec[0].flush_ops[1].flag = TRUE; - spec[0].expected_destroyed = TRUE; - - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - } - - if(pass) /* test #13 */ - { - /* Test the ability of the cache to handle the case in which - * the flush function of an entry that is resident in cache - * dirties two entries that are not in cache. No size - * changes. - * - * At present, I am assured that this case will never occur, but - * lets make sure we can handle it regardless. - */ - int test_num = 13; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = 1 * PICO_ENTRY_SIZE; - unsigned expected_index_len = 3; - size_t expected_index_size = 3 * PICO_ENTRY_SIZE; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 2, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, 0, 2, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 2; - struct fo_flush_entry_check checks[2] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ PICO_ENTRY_SIZE, - /* in_cache = */ TRUE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ PICO_ENTRY_SIZE, - /* in_cache = */ TRUE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } } - if(pass) /* test #14 */ - { - /* Repeat previous test with the flush invalidate flag. - * - * Test the ability of the cache to handle the case in which - * the flush function of an entry that is resident in cache - * dirties two entries that are not in cache. No size - * changes. - * - * At present, I am assured that this case will never occur, but - * lets make sure we can handle it regardless. - */ - int test_num = 14; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = 1 * PICO_ENTRY_SIZE; - unsigned expected_index_len = 0; - size_t expected_index_size = (size_t)0; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 2, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, 0, 2, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - int check_size = 2; - struct fo_flush_entry_check checks[2] = + if (pass) /* test #11 & #12 */ { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ PICO_ENTRY_SIZE, - /* in_cache = */ FALSE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ PICO_ENTRY_SIZE, - /* in_cache = */ FALSE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } + /* Repeat the previous test with the flush invalidate flag on the + * second test. + * + * Single entry test verifying that the cache can handle the case in + * which the call back function both resizes and moves the entry + * for which it has been called. + * + * Again, we run this entry twice, as the first run moves the entry to its + * alternate address, and the second moves it back. + */ + int test_num = 11; /* and 12 */ + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = VARIABLE_ENTRY_SIZE / 2; + unsigned expected_index_len = 1; + size_t expected_index_size = VARIABLE_ENTRY_SIZE / 4; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 2, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 2, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + + /* this change forces the move to move the target entry back to its + * main address. The first test moved it to its alternate address. + * + * Note that these two tests are not the same, as in the first test, + * the moved entry is moved forward in the slist. In the second + * it is moved backwards. + * + * Since there is only one entry in the cache, this doesn't really + * matter in this case. But we will do similar tests later with + * other entries in the cache. + */ + if (pass) { - if(pass) /* test #15 */ - { - /* Test the ability of the cache to handle the case in which - * the flush function of an entry that is resident in cache - * resizes and dirties two entries that are not in cache. - * - * At present, I am assured that this case will never occur, but - * lets make sure we can handle it regardless. - */ - int test_num = 15; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 3; - size_t expected_index_size = VARIABLE_ENTRY_SIZE + - (VARIABLE_ENTRY_SIZE / 4) + - (VARIABLE_ENTRY_SIZE / 2); - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 4, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 2; - struct fo_flush_entry_check checks[2] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ TRUE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ TRUE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; + test_num = 12; + flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + expected_index_len = 0; + expected_index_size = 0; + spec[0].flush_ops[1].flag = TRUE; + spec[0].expected_destroyed = TRUE; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } } - if(pass) /* test #16 */ - { - /* Repeat previous test with the flush invalidate flag. - * - * Test the ability of the cache to handle the case in which - * the flush function of an entry that is resident in cache - * resizes and dirties two entries that are not in cache. - * - * At present, I am assured that this case will never occur, but - * lets make sure we can handle it regardless. - */ - int test_num = 16; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 0; - size_t expected_index_size = (size_t)0; - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 4, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - int check_size = 2; - struct fo_flush_entry_check checks[2] = + if (pass) /* test #13 */ { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ FALSE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ FALSE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; + /* Test the ability of the cache to handle the case in which + * the flush function of an entry that is resident in cache + * dirties two entries that are not in cache. No size + * changes. + * + * At present, I am assured that this case will never occur, but + * lets make sure we can handle it regardless. + */ + int test_num = 13; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = 1 * PICO_ENTRY_SIZE; + unsigned expected_index_len = 3; + size_t expected_index_size = 3 * PICO_ENTRY_SIZE; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 2, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, 0, 2, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 2; + struct fo_flush_entry_check checks[2] = {{/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ PICO_ENTRY_SIZE, + /* in_cache = */ TRUE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ PICO_ENTRY_SIZE, + /* in_cache = */ TRUE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #14 */ + { + /* Repeat previous test with the flush invalidate flag. + * + * Test the ability of the cache to handle the case in which + * the flush function of an entry that is resident in cache + * dirties two entries that are not in cache. No size + * changes. + * + * At present, I am assured that this case will never occur, but + * lets make sure we can handle it regardless. + */ + int test_num = 14; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = 1 * PICO_ENTRY_SIZE; + unsigned expected_index_len = 0; + size_t expected_index_size = (size_t)0; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 2, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, 0, 2, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + int check_size = 2; + struct fo_flush_entry_check checks[2] = {{/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ PICO_ENTRY_SIZE, + /* in_cache = */ FALSE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ PICO_ENTRY_SIZE, + /* in_cache = */ FALSE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #15 */ + { + /* Test the ability of the cache to handle the case in which + * the flush function of an entry that is resident in cache + * resizes and dirties two entries that are not in cache. + * + * At present, I am assured that this case will never occur, but + * lets make sure we can handle it regardless. + */ + int test_num = 15; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 3; + size_t expected_index_size = + VARIABLE_ENTRY_SIZE + (VARIABLE_ENTRY_SIZE / 4) + (VARIABLE_ENTRY_SIZE / 2); + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 4, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 2; + struct fo_flush_entry_check checks[2] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ TRUE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ TRUE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #16 */ + { + /* Repeat previous test with the flush invalidate flag. + * + * Test the ability of the cache to handle the case in which + * the flush function of an entry that is resident in cache + * resizes and dirties two entries that are not in cache. + * + * At present, I am assured that this case will never occur, but + * lets make sure we can handle it regardless. + */ + int test_num = 16; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 0; + size_t expected_index_size = (size_t)0; + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 4, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + int check_size = 2; + struct fo_flush_entry_check checks[2] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ FALSE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ FALSE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #17 & #18 */ + { + /* Test the ability of the cache to handle the case in which + * the flush function of an entry that is resident in cache + * resizes, dirties, and moves two entries that are not in cache. + * + * At present, I am assured that this case will never occur, but + * lets make sure we can handle it regardless. + */ + int test_num = 17; /* and 18 */ + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 3; + size_t expected_index_size = + VARIABLE_ENTRY_SIZE + (VARIABLE_ENTRY_SIZE / 4) + (VARIABLE_ENTRY_SIZE / 2); + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 6, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 2; + struct fo_flush_entry_check checks[2] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + + /* this change forces the moves to move the target entries back to + * their main address. The first test moved them to their alternate + * address. + * + * Note that these two tests are not the same, as in the first test, + * the moved entries are moved forward in the slist. In the second + * they are moved backwards. + */ + if (pass) { - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } + test_num = 18; + spec[0].flush_ops[2].flag = TRUE; + spec[0].flush_ops[5].flag = TRUE; + checks[0].at_main_addr = TRUE; + checks[1].at_main_addr = TRUE; - if(pass) /* test #17 & #18 */ - { - /* Test the ability of the cache to handle the case in which - * the flush function of an entry that is resident in cache - * resizes, dirties, and moves two entries that are not in cache. - * - * At present, I am assured that this case will never occur, but - * lets make sure we can handle it regardless. - */ - int test_num = 17; /* and 18 */ - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 3; - size_t expected_index_size = VARIABLE_ENTRY_SIZE + - (VARIABLE_ENTRY_SIZE / 4) + - (VARIABLE_ENTRY_SIZE / 2); - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 2; - struct fo_flush_entry_check checks[2] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } } - }; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - - /* this change forces the moves to move the target entries back to - * their main address. The first test moved them to their alternate - * address. - * - * Note that these two tests are not the same, as in the first test, - * the moved entries are moved forward in the slist. In the second - * they are moved backwards. - */ - if(pass) { - - test_num = 18; - spec[0].flush_ops[2].flag = TRUE; - spec[0].flush_ops[5].flag = TRUE; - checks[0].at_main_addr = TRUE; - checks[1].at_main_addr = TRUE; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - } - - if(pass) /* test #19 & #20 */ - { - /* Repeat the above test with the flush invalidate flag on the - * second test. - * - * Test the ability of the cache to handle the case in which - * the flush function of an entry that is resident in cache - * resizes, dirties, and moves two entries that are not in cache. - * - * At present, I am assured that this case will never occur, but - * lets make sure we can handle it regardless. - */ - int test_num = 19; /* and 20 */ - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 1; - unsigned init_expected_index_len = 1; - size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 3; - size_t expected_index_size = VARIABLE_ENTRY_SIZE + - (VARIABLE_ENTRY_SIZE / 4) + - (VARIABLE_ENTRY_SIZE / 2); - struct fo_flush_cache_test_spec spec[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 2; - struct fo_flush_entry_check checks[2] = + if (pass) /* test #19 & #20 */ { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; + /* Repeat the above test with the flush invalidate flag on the + * second test. + * + * Test the ability of the cache to handle the case in which + * the flush function of an entry that is resident in cache + * resizes, dirties, and moves two entries that are not in cache. + * + * At present, I am assured that this case will never occur, but + * lets make sure we can handle it regardless. + */ + int test_num = 19; /* and 20 */ + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 1; + unsigned init_expected_index_len = 1; + size_t init_expected_index_size = 1 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 3; + size_t expected_index_size = + VARIABLE_ENTRY_SIZE + (VARIABLE_ENTRY_SIZE / 4) + (VARIABLE_ENTRY_SIZE / 2); + struct fo_flush_cache_test_spec spec[1] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 6, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 2; + struct fo_flush_entry_check checks[2] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + + /* this change forces the moves to move the target entries back to + * their main address. The first test moved them to their alternate + * address. + * + * Note that these two tests are not the same, as in the first test, + * the moved entries are moved forward in the slist. In the second + * they are moved backwards. + */ + if (pass) { - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - - /* this change forces the moves to move the target entries back to - * their main address. The first test moved them to their alternate - * address. - * - * Note that these two tests are not the same, as in the first test, - * the moved entries are moved forward in the slist. In the second - * they are moved backwards. - */ - if(pass) { - - test_num = 20; - flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - expected_index_len = 0; - expected_index_size = (size_t)0; - spec[0].expected_destroyed = TRUE; - spec[0].flush_ops[2].flag = TRUE; - spec[0].flush_ops[5].flag = TRUE; - checks[0].at_main_addr = TRUE; - checks[0].in_cache = FALSE; - checks[0].expected_destroyed = TRUE; - checks[1].at_main_addr = TRUE; - checks[1].in_cache = FALSE; - checks[1].expected_destroyed = TRUE; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - } - - if(pass) /* test #21 */ - { - /* Now mix things up a bit. - * - * Load several entries, two of which have flush functions that - * resize, dirty, and move two entries that are not in the - * cache. Mark only one of these entries, and then flush the - * cache with the flush marked entries flag. - * - * This is the only test in which we test the - * H5C__FLUSH_MARKED_ENTRIES_FLAG. The hope is that since - * we test the two features extensively by themselves, so - * it should be sufficient to verify that they play together - * as expected. - */ - int test_num = 21; - unsigned int flush_flags = H5C__FLUSH_MARKED_ENTRIES_FLAG; - int spec_size = 4; - unsigned init_expected_index_len = 4; - size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (2 * PICO_ENTRY_SIZE); - unsigned expected_index_len = 6; - size_t expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + - (VARIABLE_ENTRY_SIZE / 4) + - (VARIABLE_ENTRY_SIZE / 2) + - (2 * PICO_ENTRY_SIZE); - struct fo_flush_cache_test_spec spec[4] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 11, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 4; - struct fo_flush_entry_check checks[4] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ TRUE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ TRUE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 10, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ FALSE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 12, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ FALSE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; + test_num = 20; + flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + expected_index_len = 0; + expected_index_size = (size_t)0; + spec[0].expected_destroyed = TRUE; + spec[0].flush_ops[2].flag = TRUE; + spec[0].flush_ops[5].flag = TRUE; + checks[0].at_main_addr = TRUE; + checks[0].in_cache = FALSE; + checks[0].expected_destroyed = TRUE; + checks[1].at_main_addr = TRUE; + checks[1].in_cache = FALSE; + checks[1].expected_destroyed = TRUE; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - reset_entries(); + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } } - if(pass) /* test #22 */ - { - /* Mix things up some more. - * - * Load lots of entries, some of which have flush functions that - * resize, dirty, and move two entries that are not in the - * cache. - * - * Also load entries that have flush ops on entries that are in - * cache. - */ - int test_num = 22; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 6; - unsigned init_expected_index_len = 6; - size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (4 * PICO_ENTRY_SIZE); - unsigned expected_index_len = 10; - size_t expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + - (2 * (VARIABLE_ENTRY_SIZE / 4)) + - (2 * (VARIABLE_ENTRY_SIZE / 2)) + - (4 * PICO_ENTRY_SIZE); - struct fo_flush_cache_test_spec spec[6] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 11, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,0,FALSE,0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 5, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,0,FALSE,0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 4; - struct fo_flush_entry_check checks[4] = + if (pass) /* test #21 */ { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 10, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 12, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - reset_entries(); + /* Now mix things up a bit. + * + * Load several entries, two of which have flush functions that + * resize, dirty, and move two entries that are not in the + * cache. Mark only one of these entries, and then flush the + * cache with the flush marked entries flag. + * + * This is the only test in which we test the + * H5C__FLUSH_MARKED_ENTRIES_FLAG. The hope is that since + * we test the two features extensively by themselves, so + * it should be sufficient to verify that they play together + * as expected. + */ + int test_num = 21; + unsigned int flush_flags = H5C__FLUSH_MARKED_ENTRIES_FLAG; + int spec_size = 4; + unsigned init_expected_index_len = 4; + size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (2 * PICO_ENTRY_SIZE); + unsigned expected_index_len = 6; + size_t expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (VARIABLE_ENTRY_SIZE / 4) + + (VARIABLE_ENTRY_SIZE / 2) + (2 * PICO_ENTRY_SIZE); + struct fo_flush_cache_test_spec spec[4] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 6, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 11, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 6, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + int check_size = 4; + struct fo_flush_entry_check checks[4] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ TRUE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ TRUE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 10, + /* expected_size = */ VARIABLE_ENTRY_SIZE, + /* in_cache = */ FALSE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 12, + /* expected_size = */ VARIABLE_ENTRY_SIZE, + /* in_cache = */ FALSE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + reset_entries(); } - if(pass) /* test #23 */ + if (pass) /* test #22 */ { - /* Repeat test #23 with the flush invalidate flag set. - * - * Mix things up some more. - * - * Load lots of entries, some of which have flush functions that - * resize, dirty, and move two entries that are not in the - * cache. - * - * Also load entries that have flush ops on entries that are in - * cache. - */ - int test_num = 23; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 6; - unsigned init_expected_index_len = 6; - size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (4 * PICO_ENTRY_SIZE); - unsigned expected_index_len = 0; - size_t expected_index_size = 0; - struct fo_flush_cache_test_spec spec[6] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 11, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,0,FALSE,0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,0,FALSE,0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - int check_size = 4; - struct fo_flush_entry_check checks[4] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 10, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 12, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE + /* Mix things up some more. + * + * Load lots of entries, some of which have flush functions that + * resize, dirty, and move two entries that are not in the + * cache. + * + * Also load entries that have flush ops on entries that are in + * cache. + */ + int test_num = 22; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 6; + unsigned init_expected_index_len = 6; + size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (4 * PICO_ENTRY_SIZE); + unsigned expected_index_len = 10; + size_t expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (2 * (VARIABLE_ENTRY_SIZE / 4)) + + (2 * (VARIABLE_ENTRY_SIZE / 2)) + (4 * PICO_ENTRY_SIZE); + struct fo_flush_cache_test_spec spec[6] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 6, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 11, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 6, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 5, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 4; + struct fo_flush_entry_check checks[4] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 10, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 12, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + reset_entries(); } - }; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - reset_entries(); + if (pass) /* test #23 */ + { + /* Repeat test #23 with the flush invalidate flag set. + * + * Mix things up some more. + * + * Load lots of entries, some of which have flush functions that + * resize, dirty, and move two entries that are not in the + * cache. + * + * Also load entries that have flush ops on entries that are in + * cache. + */ + int test_num = 23; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 6; + unsigned init_expected_index_len = 6; + size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (4 * PICO_ENTRY_SIZE); + unsigned expected_index_len = 0; + size_t expected_index_size = 0; + struct fo_flush_cache_test_spec spec[6] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 6, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 11, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 6, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 10, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 12, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 0, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 1, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + int check_size = 4; + struct fo_flush_entry_check checks[4] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 0, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 10, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 12, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + reset_entries(); } /* So much for tests involving only flush operations. * * Now create some tests mixing flush ops and pins. */ - if(pass) /* test #24 */ - { - /* Pico entries 50 and 150 pin pico entry 100, and also dirty - * pico entry 100 on flush. - */ - int test_num = 24; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 3; - unsigned init_expected_index_len = 3; - size_t init_expected_index_size = 3 * PICO_ENTRY_SIZE; - unsigned expected_index_len = 3; - size_t expected_index_size = 3 * PICO_ENTRY_SIZE; - struct fo_flush_cache_test_spec spec[3] = + if (pass) /* test #24 */ { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 1, - /* pin_type = */ {PICO_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,100,FALSE,0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 150, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 1, - /* pin_type = */ {PICO_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,100,FALSE,0, NULL }, - { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - - if(pass) /* test #25 */ - { - /* Repeat the previous test with the flush invalidate flag. - * - * Pico entries 50 and 150 pin pico entry 100, and also dirty - * pico entry 100 on flush. - */ - int test_num = 25; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 3; - unsigned init_expected_index_len = 3; - size_t init_expected_index_size = 3 * PICO_ENTRY_SIZE; - unsigned expected_index_len = 0; - size_t expected_index_size = (size_t)0; - struct fo_flush_cache_test_spec spec[3] = - { - { - /* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 1, - /* pin_type = */ {PICO_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,100,FALSE,0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 150, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 1, - /* pin_type = */ {PICO_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, PICO_ENTRY_TYPE,100,FALSE,0, NULL }, - { FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ (size_t)0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); - } - - if(pass) /* test #26 */ - { - /* This one is complex. - * - * In the following overvies table, VET stands for - * VARIABLE_ENTRY_TYPE. - * - * In trying to follow what happens when we flush the - * set of entries constructed below, recall that each - * flush operation is executed the first time the - * entry is flushed, and then not executed again. - * This may be a weakness in the tests, but that - * is the way it is for now. - * - * After thinking about it for a while, I'm not sure that - * the interaction between pins and flush operations needs - * all that much testing, as the two are essentially - * orthoginal. Thus this is a bit of a smoke check to - * verify that we get the expected results. - * - * (VET, 100) initially not resident in cache - * - * (VET, 200) initially clean and resident in cache - * - * (VET, 300) initially not resident in cache - * - * (VET, 2100) initially clean and resident in cache - * - * (VET, 2200) initially not resident in cache - * - * (VET, 2300) initially clean and resident in cache - * - * (VET, 1000) initially clean, and in cache - * dirties (VET, 100) - * resizes (VET, 200) - * dirty (VET, 300) -- dirty first to bring into cache. - * moves (VET, 300) - * - * (VET, 2000) initially clean, and in cache - * dirties (VET, 2100) - * resizes (VET, 2200) - * moves (VET, 2300) - * - * (VET, 350) initially clean, and in cache - * pins (VET, 1000) - * dirties (VET, 1000) - * resizes (VET, 350) - * pins (VET, 2000) - * dirties (VET, 2000) - * - * (VET, 450) initially dirty, and in cache - * pins (VET, 1000) - * dirties (VET, 1000) - * moves (VET, 450) - * pins (VET, 2000) - * dirties (VET, 2000) - * - * (VET, 650) initially clean, and in cache - * pins (VET, 1000) - * dirties (VET, 1000) - * resizes (VET, 650) - * pins (VET, 2000) - * dirties (VET, 2000) - * - * (VET, 750) initially dirty, and in cache - * pins (VET, 1000) - * dirties (VET, 1000) - * resizes (VET, 750) - * pins (VET, 2000) - * dirties (VET, 2000) - * - * (VET, 500) initially dirty, and in cache - * dirties (VET, 350) - * dirties (VET, 450) - * dirties (VET, 650) - * dirties (VET, 750) - */ - int test_num = 26; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 10; - unsigned init_expected_index_len = 10; - size_t init_expected_index_size = 10 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 13; - size_t expected_index_size = 9 * VARIABLE_ENTRY_SIZE; - struct fo_flush_cache_test_spec spec[10] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 200, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2300, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1000, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 4, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2000, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2100, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2300, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 5, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 350, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 350, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 6, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 450, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 450, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 7, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 650, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 8, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 750, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 9, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 500, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 4, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 3; - struct fo_flush_entry_check checks[3] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 100, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ TRUE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 300, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ TRUE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2200, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ TRUE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } + /* Pico entries 50 and 150 pin pico entry 100, and also dirty + * pico entry 100 on flush. + */ + int test_num = 24; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 3; + unsigned init_expected_index_len = 3; + size_t init_expected_index_size = 3 * PICO_ENTRY_SIZE; + unsigned expected_index_len = 3; + size_t expected_index_size = 3 * PICO_ENTRY_SIZE; + struct fo_flush_cache_test_spec spec[3] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 1, + /* pin_type = */ {PICO_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 150, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 1, + /* pin_type = */ {PICO_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #25 */ + { + /* Repeat the previous test with the flush invalidate flag. + * + * Pico entries 50 and 150 pin pico entry 100, and also dirty + * pico entry 100 on flush. + */ + int test_num = 25; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 3; + unsigned init_expected_index_len = 3; + size_t init_expected_index_size = 3 * PICO_ENTRY_SIZE; + unsigned expected_index_len = 0; + size_t expected_index_size = (size_t)0; + struct fo_flush_cache_test_spec spec[3] = { + {/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 1, + /* pin_type = */ {PICO_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 150, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 1, + /* pin_type = */ {PICO_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ (size_t)0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); + } + + if (pass) /* test #26 */ + { + /* This one is complex. + * + * In the following overvies table, VET stands for + * VARIABLE_ENTRY_TYPE. + * + * In trying to follow what happens when we flush the + * set of entries constructed below, recall that each + * flush operation is executed the first time the + * entry is flushed, and then not executed again. + * This may be a weakness in the tests, but that + * is the way it is for now. + * + * After thinking about it for a while, I'm not sure that + * the interaction between pins and flush operations needs + * all that much testing, as the two are essentially + * orthoginal. Thus this is a bit of a smoke check to + * verify that we get the expected results. + * + * (VET, 100) initially not resident in cache + * + * (VET, 200) initially clean and resident in cache + * + * (VET, 300) initially not resident in cache + * + * (VET, 2100) initially clean and resident in cache + * + * (VET, 2200) initially not resident in cache + * + * (VET, 2300) initially clean and resident in cache + * + * (VET, 1000) initially clean, and in cache + * dirties (VET, 100) + * resizes (VET, 200) + * dirty (VET, 300) -- dirty first to bring into cache. + * moves (VET, 300) + * + * (VET, 2000) initially clean, and in cache + * dirties (VET, 2100) + * resizes (VET, 2200) + * moves (VET, 2300) + * + * (VET, 350) initially clean, and in cache + * pins (VET, 1000) + * dirties (VET, 1000) + * resizes (VET, 350) + * pins (VET, 2000) + * dirties (VET, 2000) + * + * (VET, 450) initially dirty, and in cache + * pins (VET, 1000) + * dirties (VET, 1000) + * moves (VET, 450) + * pins (VET, 2000) + * dirties (VET, 2000) + * + * (VET, 650) initially clean, and in cache + * pins (VET, 1000) + * dirties (VET, 1000) + * resizes (VET, 650) + * pins (VET, 2000) + * dirties (VET, 2000) + * + * (VET, 750) initially dirty, and in cache + * pins (VET, 1000) + * dirties (VET, 1000) + * resizes (VET, 750) + * pins (VET, 2000) + * dirties (VET, 2000) + * + * (VET, 500) initially dirty, and in cache + * dirties (VET, 350) + * dirties (VET, 450) + * dirties (VET, 650) + * dirties (VET, 750) + */ + int test_num = 26; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 10; + unsigned init_expected_index_len = 10; + size_t init_expected_index_size = 10 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 13; + size_t expected_index_size = 9 * VARIABLE_ENTRY_SIZE; + struct fo_flush_cache_test_spec spec[10] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 200, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2300, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1000, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 4, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2000, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2100, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2300, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 5, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 350, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 350, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 6, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 450, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 450, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 7, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 650, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 8, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 750, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 9, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 500, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 4, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 3; + struct fo_flush_entry_check checks[3] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 100, + /* expected_size = */ VARIABLE_ENTRY_SIZE, + /* in_cache = */ TRUE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 300, + /* expected_size = */ VARIABLE_ENTRY_SIZE, + /* in_cache = */ TRUE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2200, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ TRUE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE} - }; + }; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); - reset_entries(); + reset_entries(); } - if(pass) /* test #27 */ - { - /* Repeat test #26 with the flush invalidate flag. - * - * In the following overview table, VET stands for - * VARIABLE_ENTRY_TYPE. - * - * In trying to follow what happens when we flush the - * set of entries constructed below, recall that each - * flush operation is executed the first time the - * entry is flushed, and then not executed again. - * This may be a weakness in the tests, but that - * is the way it is for now. - * - * After thinking about it for a while, I'm not sure that - * the interaction between pins and flush operations needs - * all that much testing, as the two are essentially - * orthoginal. The big thing is to verify that flushes of - * pinned entries with flush ops result in the expected - * updates of the cache. - * - * Thus this is a bit of a smoke check to * verify that we - * get the expected results. - * - * (VET, 100) initially not resident in cache - * - * (VET, 200) initially clean and resident in cache - * - * (VET, 300) initially not resident in cache - * - * (VET, 2100) initially clean and resident in cache - * - * (VET, 2200) initially not resident in cache - * - * (VET, 2300) initially clean and resident in cache - * - * (VET, 1000) initially clean, and in cache - * dirties (VET, 100) - * resizes (VET, 200) - * dirty (VET, 300) -- dirty first to bring into cache. - * moves (VET, 300) - * - * (VET, 2000) initially clean, and in cache - * dirties (VET, 2100) - * resizes (VET, 2200) - * moves (VET, 2300) - * - * (VET, 350) initially clean, and in cache - * pins (VET, 1000) - * dirties (VET, 1000) - * resizes (VET, 350) - * pins (VET, 2000) - * dirties (VET, 2000) - * - * (VET, 450) initially dirty, and in cache - * pins (VET, 1000) - * dirties (VET, 1000) - * moves (VET, 450) - * pins (VET, 2000) - * dirties (VET, 2000) - * - * (VET, 650) initially clean, and in cache - * pins (VET, 1000) - * dirties (VET, 1000) - * resizes (VET, 650) - * pins (VET, 2000) - * dirties (VET, 2000) - * - * (VET, 750) initially dirty, and in cache - * pins (VET, 1000) - * dirties (VET, 1000) - * resizes (VET, 750) - * pins (VET, 2000) - * dirties (VET, 2000) - * - * (VET, 500) initially dirty, and in cache - * dirties (VET, 350) - * dirties (VET, 450) - * dirties (VET, 650) - * dirties (VET, 750) - */ - int test_num = 27; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 10; - unsigned init_expected_index_len = 10; - size_t init_expected_index_size = 10 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 0; - size_t expected_index_size = (size_t)0; - struct fo_flush_cache_test_spec spec[10] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 200, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2300, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1000, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 4, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2000, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2100, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2300, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 5, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 350, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 350, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 6, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 450, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 450, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 7, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 650, - /* insert_flag = */ TRUE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 8, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 750, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 9, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 500, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 4, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, FALSE, 0, NULL }, - { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - int check_size = 3; - struct fo_flush_entry_check checks[3] = - { + if (pass) /* test #27 */ { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 100, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ FALSE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 300, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2200, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ FALSE, - /* at_main_addr = */ TRUE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } + /* Repeat test #26 with the flush invalidate flag. + * + * In the following overview table, VET stands for + * VARIABLE_ENTRY_TYPE. + * + * In trying to follow what happens when we flush the + * set of entries constructed below, recall that each + * flush operation is executed the first time the + * entry is flushed, and then not executed again. + * This may be a weakness in the tests, but that + * is the way it is for now. + * + * After thinking about it for a while, I'm not sure that + * the interaction between pins and flush operations needs + * all that much testing, as the two are essentially + * orthoginal. The big thing is to verify that flushes of + * pinned entries with flush ops result in the expected + * updates of the cache. + * + * Thus this is a bit of a smoke check to * verify that we + * get the expected results. + * + * (VET, 100) initially not resident in cache + * + * (VET, 200) initially clean and resident in cache + * + * (VET, 300) initially not resident in cache + * + * (VET, 2100) initially clean and resident in cache + * + * (VET, 2200) initially not resident in cache + * + * (VET, 2300) initially clean and resident in cache + * + * (VET, 1000) initially clean, and in cache + * dirties (VET, 100) + * resizes (VET, 200) + * dirty (VET, 300) -- dirty first to bring into cache. + * moves (VET, 300) + * + * (VET, 2000) initially clean, and in cache + * dirties (VET, 2100) + * resizes (VET, 2200) + * moves (VET, 2300) + * + * (VET, 350) initially clean, and in cache + * pins (VET, 1000) + * dirties (VET, 1000) + * resizes (VET, 350) + * pins (VET, 2000) + * dirties (VET, 2000) + * + * (VET, 450) initially dirty, and in cache + * pins (VET, 1000) + * dirties (VET, 1000) + * moves (VET, 450) + * pins (VET, 2000) + * dirties (VET, 2000) + * + * (VET, 650) initially clean, and in cache + * pins (VET, 1000) + * dirties (VET, 1000) + * resizes (VET, 650) + * pins (VET, 2000) + * dirties (VET, 2000) + * + * (VET, 750) initially dirty, and in cache + * pins (VET, 1000) + * dirties (VET, 1000) + * resizes (VET, 750) + * pins (VET, 2000) + * dirties (VET, 2000) + * + * (VET, 500) initially dirty, and in cache + * dirties (VET, 350) + * dirties (VET, 450) + * dirties (VET, 650) + * dirties (VET, 750) + */ + int test_num = 27; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 10; + unsigned init_expected_index_len = 10; + size_t init_expected_index_size = 10 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 0; + size_t expected_index_size = (size_t)0; + struct fo_flush_cache_test_spec spec[10] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 200, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2300, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 1000, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 4, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2000, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2100, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2200, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2300, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 5, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 350, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 350, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 6, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 450, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 450, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 7, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 650, + /* insert_flag = */ TRUE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 8, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 750, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, FALSE, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 9, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 500, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 4, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, FALSE, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + int check_size = 3; + struct fo_flush_entry_check checks[3] = {{/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 100, + /* expected_size = */ VARIABLE_ENTRY_SIZE, + /* in_cache = */ FALSE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 300, + /* expected_size = */ VARIABLE_ENTRY_SIZE, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2200, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ FALSE, + /* at_main_addr = */ TRUE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE} - }; + }; - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); - reset_entries(); + reset_entries(); } - if(pass) /* test #28 */ - { - /* Test the expected fheap case, in which an entry dirties - * and resizes itself, and dirties an entry which it has - * pinned. - */ - int test_num = 28; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 5; - unsigned init_expected_index_len = 5; - size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 5; - size_t expected_index_size = 4 * VARIABLE_ENTRY_SIZE; - struct fo_flush_cache_test_spec spec[5] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 200, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 2, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 200, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, + if (pass) /* test #28 */ { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 300, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 400, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - }, - { - /* entry_num = */ 4, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 500, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 500, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ FALSE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ 0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); + /* Test the expected fheap case, in which an entry dirties + * and resizes itself, and dirties an entry which it has + * pinned. + */ + int test_num = 28; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 5; + unsigned init_expected_index_len = 5; + size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 5; + size_t expected_index_size = 4 * VARIABLE_ENTRY_SIZE; + struct fo_flush_cache_test_spec spec[5] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 200, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 2, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 200, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 300, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 400, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}, + {/* entry_num = */ 4, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 500, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 500, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ FALSE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ 0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); - reset_entries(); + reset_entries(); } - if(pass) /* test #29 */ - { - /* Repeat test #28 with the flush invalidate flag. - * - * Test the expected fheap case, in which an entry dirties - * and resizes itself, and dirties an entry which it has - * pinned. - */ - int test_num = 29; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 5; - unsigned init_expected_index_len = 5; - size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 0; - size_t expected_index_size = 0; - struct fo_flush_cache_test_spec spec[5] = - { - { - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 200, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 2, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 200, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 300, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, + if (pass) /* test #29 */ { - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 400, - /* insert_flag = */ FALSE, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ FALSE, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - }, - { - /* entry_num = */ 4, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 500, - /* insert_flag = */ FALSE, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ TRUE, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - { { FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL }, - { FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL }, - { FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 500, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL }, - { FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL } }, - /* expected_deserialized = */ TRUE, - /* expected_serialized = */ TRUE, - /* expected_destroyed = */ TRUE - } - }; - int check_size = 0; - struct fo_flush_entry_check checks[1] = - { - { - /* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ 0, - /* in_cache = */ FALSE, - /* at_main_addr = */ FALSE, - /* is_dirty = */ FALSE, - /* is_protected = */ FALSE, - /* is_pinned = */ FALSE, - /* expected_deserialized = */ FALSE, - /* expected_serialized = */ FALSE, - /* expected_destroyed = */ FALSE - } - }; - - check_flush_cache__flush_op_test(file_ptr, - test_num, - flush_flags, - spec_size, - spec, - init_expected_index_len, - init_expected_index_size, - expected_index_len, - expected_index_size, - check_size, - checks); + /* Repeat test #28 with the flush invalidate flag. + * + * Test the expected fheap case, in which an entry dirties + * and resizes itself, and dirties an entry which it has + * pinned. + */ + int test_num = 29; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 5; + unsigned init_expected_index_len = 5; + size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 0; + size_t expected_index_size = 0; + struct fo_flush_cache_test_spec spec[5] = { + {/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 200, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 2, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, FALSE, VARIABLE_ENTRY_SIZE, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 200, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 300, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 400, + /* insert_flag = */ FALSE, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ FALSE, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}, + {/* entry_num = */ 4, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 500, + /* insert_flag = */ FALSE, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ TRUE, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, FALSE, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, FALSE, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 500, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, FALSE, 0, NULL}}, + /* expected_deserialized = */ TRUE, + /* expected_serialized = */ TRUE, + /* expected_destroyed = */ TRUE}}; + int check_size = 0; + struct fo_flush_entry_check checks[1] = {{/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ 0, + /* in_cache = */ FALSE, + /* at_main_addr = */ FALSE, + /* is_dirty = */ FALSE, + /* is_protected = */ FALSE, + /* is_pinned = */ FALSE, + /* expected_deserialized = */ FALSE, + /* expected_serialized = */ FALSE, + /* expected_destroyed = */ FALSE}}; + + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); - reset_entries(); + reset_entries(); } /* finally finish up with the flush ops eviction test */ @@ -9177,7 +7984,6 @@ check_flush_cache__flush_ops(H5F_t * file_ptr) } /* check_flush_cache__flush_ops() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__flush_op_test() * @@ -9195,202 +8001,150 @@ check_flush_cache__flush_ops(H5F_t * file_ptr) */ static void -check_flush_cache__flush_op_test(H5F_t * file_ptr, - int test_num, - unsigned int flush_flags, - int spec_size, +check_flush_cache__flush_op_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, int spec_size, const struct fo_flush_cache_test_spec spec[], - unsigned init_expected_index_len, - size_t init_expected_index_size, - unsigned expected_index_len, - size_t expected_index_size, - int check_size, - struct fo_flush_entry_check check[]) + unsigned init_expected_index_len, size_t init_expected_index_size, + unsigned expected_index_len, size_t expected_index_size, int check_size, + struct fo_flush_entry_check check[]) { H5C_t * cache_ptr = file_ptr->shared->cache; - static char msg[128]; - herr_t result; - int i; - int j; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + static char msg[128]; + herr_t result; + int i; + int j; + test_entry_t *base_addr; + test_entry_t *entry_ptr; #if 0 /* This is useful debugging code -- lets keep it around. */ HDfprintf(stdout, "check_flush_cache__flush_op_test: test %d\n", test_num); #endif - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache_ptr NULL on entry to flush op test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache_ptr NULL on entry to flush op test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache not empty at beginning of flush op test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache not empty at beginning of flush op test #%d.", test_num); failure_mssg = msg; } - else if((spec_size < 1) || (spec == NULL)) { + else if ((spec_size < 1) || (spec == NULL)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "missing/bad test spec on entry to flush op test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "missing/bad test spec on entry to flush op test #%d.", test_num); failure_mssg = msg; } i = 0; - while(pass && (i < spec_size)) - { - if((spec[i].entry_num != i) || - (spec[i].entry_type < 0) || - (spec[i].entry_type >= NUMBER_OF_ENTRY_TYPES) || - (spec[i].entry_index < 0) || - (spec[i].entry_index > max_indices[spec[i].entry_type]) || - (spec[i].num_pins < 0) || - (spec[i].num_pins > MAX_PINS) || - (spec[i].num_flush_ops < 0) || - (spec[i].num_flush_ops > MAX_FLUSH_OPS)) { + while (pass && (i < spec_size)) { + if ((spec[i].entry_num != i) || (spec[i].entry_type < 0) || + (spec[i].entry_type >= NUMBER_OF_ENTRY_TYPES) || (spec[i].entry_index < 0) || + (spec[i].entry_index > max_indices[spec[i].entry_type]) || (spec[i].num_pins < 0) || + (spec[i].num_pins > MAX_PINS) || (spec[i].num_flush_ops < 0) || + (spec[i].num_flush_ops > MAX_FLUSH_OPS)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "bad data in spec[%d] on entry to flush op test #%d.", - i, test_num); + HDsnprintf(msg, (size_t)128, "bad data in spec[%d] on entry to flush op test #%d.", i, test_num); failure_mssg = msg; } i++; } i = 0; - while(pass && (i < check_size)) - { - if((check[i].entry_num != i) || - (check[i].entry_type < 0) || - (check[i].entry_type >= NUMBER_OF_ENTRY_TYPES) || - (check[i].entry_index < 0) || - (check[i].entry_index > max_indices[check[i].entry_type]) || + while (pass && (i < check_size)) { + if ((check[i].entry_num != i) || (check[i].entry_type < 0) || + (check[i].entry_type >= NUMBER_OF_ENTRY_TYPES) || (check[i].entry_index < 0) || + (check[i].entry_index > max_indices[check[i].entry_type]) || #ifndef H5_HAVE_STDBOOL_H - /* Check for nonsense values if hbool_t is an integral - * type instead of a real Boolean. - */ - ((check[i].in_cache != TRUE) && - (check[i].in_cache != FALSE)) || - ((check[i].at_main_addr != TRUE) && - (check[i].at_main_addr != FALSE)) || - ((check[i].is_dirty != TRUE) && - (check[i].is_dirty != FALSE)) || - ((check[i].is_protected != TRUE) && - (check[i].is_protected != FALSE)) || - ((check[i].is_pinned != TRUE) && - (check[i].is_pinned != FALSE)) || - ((check[i].expected_deserialized != TRUE) && - (check[i].expected_deserialized != FALSE)) || - ((check[i].expected_serialized != TRUE) && - (check[i].expected_serialized != FALSE)) || - ((check[i].expected_destroyed != TRUE) && - (check[i].expected_destroyed != FALSE)) || + /* Check for nonsense values if hbool_t is an integral + * type instead of a real Boolean. + */ + ((check[i].in_cache != TRUE) && (check[i].in_cache != FALSE)) || + ((check[i].at_main_addr != TRUE) && (check[i].at_main_addr != FALSE)) || + ((check[i].is_dirty != TRUE) && (check[i].is_dirty != FALSE)) || + ((check[i].is_protected != TRUE) && (check[i].is_protected != FALSE)) || + ((check[i].is_pinned != TRUE) && (check[i].is_pinned != FALSE)) || + ((check[i].expected_deserialized != TRUE) && (check[i].expected_deserialized != FALSE)) || + ((check[i].expected_serialized != TRUE) && (check[i].expected_serialized != FALSE)) || + ((check[i].expected_destroyed != TRUE) && (check[i].expected_destroyed != FALSE)) || #endif /* H5_HAVE_STDBOOL_H */ - (check[i].expected_size <= (size_t)0) - ) { + (check[i].expected_size <= (size_t)0)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "bad data in check[%d] on entry to flush op test #%d.", - i, test_num); + HDsnprintf(msg, (size_t)128, "bad data in check[%d] on entry to flush op test #%d.", i, test_num); failure_mssg = msg; } i++; } i = 0; - while(pass && (i < spec_size)) - { - if(spec[i].insert_flag) { - - insert_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, - spec[i].flags); + while (pass && (i < spec_size)) { + if (spec[i].insert_flag) { - } else { + insert_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].flags); + } + else { protect_entry(file_ptr, spec[i].entry_type, spec[i].entry_index); - if(spec[i].resize_flag) - resize_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, - spec[i].new_size, TRUE); + if (spec[i].resize_flag) + resize_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].new_size, TRUE); - unprotect_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, - spec[i].flags); + unprotect_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].flags); } - for (j = 0; j < spec[i].num_pins; j++) - { - create_pinned_entry_dependency(file_ptr, - spec[i].entry_type, - spec[i].entry_index, - spec[i].pin_type[j], - spec[i].pin_idx[j]); - } + for (j = 0; j < spec[i].num_pins; j++) { + create_pinned_entry_dependency(file_ptr, spec[i].entry_type, spec[i].entry_index, + spec[i].pin_type[j], spec[i].pin_idx[j]); + } - for (j = 0; j < spec[i].num_flush_ops; j++) - { - add_flush_op(spec[i].entry_type, - spec[i].entry_index, - spec[i].flush_ops[j].op_code, - spec[i].flush_ops[j].type, - spec[i].flush_ops[j].idx, - spec[i].flush_ops[j].flag, - spec[i].flush_ops[j].size, - spec[i].flush_ops[j].order_ptr); - } + for (j = 0; j < spec[i].num_flush_ops; j++) { + add_flush_op(spec[i].entry_type, spec[i].entry_index, spec[i].flush_ops[j].op_code, + spec[i].flush_ops[j].type, spec[i].flush_ops[j].idx, spec[i].flush_ops[j].flag, + spec[i].flush_ops[j].size, spec[i].flush_ops[j].order_ptr); + } i++; } - if(pass) { + if (pass) { - if((cache_ptr->index_len != init_expected_index_len) || - (cache_ptr->index_size != init_expected_index_size)) { + if ((cache_ptr->index_len != init_expected_index_len) || + (cache_ptr->index_size != init_expected_index_size)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size before flush in flush op test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Unexpected cache len/size before flush in flush op test #%d.", + test_num); failure_mssg = msg; } } - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, flush_flags); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "flush with flags 0x%x failed in flush op test #%d.", - flush_flags, test_num); + HDsnprintf(msg, (size_t)128, "flush with flags 0x%x failed in flush op test #%d.", flush_flags, + test_num); failure_mssg = msg; } } - i = 0; - while(pass && (i < spec_size)) - { + while (pass && (i < spec_size)) { base_addr = entries[spec[i].entry_type]; entry_ptr = &(base_addr[spec[i].entry_index]); - if((entry_ptr->deserialized != spec[i].expected_deserialized) || - (entry_ptr->serialized != spec[i].expected_serialized) || - (entry_ptr->destroyed != spec[i].expected_destroyed)) { + if ((entry_ptr->deserialized != spec[i].expected_deserialized) || + (entry_ptr->serialized != spec[i].expected_serialized) || + (entry_ptr->destroyed != spec[i].expected_destroyed)) { #if 0 /* This is useful debugging code. Lets keep it around. */ @@ -9408,47 +8162,40 @@ check_flush_cache__flush_op_test(H5F_t * file_ptr, #endif pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Bad status on entry %d after flush op test #%d.", - i, test_num); + HDsnprintf(msg, (size_t)128, "Bad status on entry %d after flush op test #%d.", i, test_num); failure_mssg = msg; } i++; } - if(pass) { + if (pass) { i = 0; - while(pass && (i < check_size)) - { - if(check[i].in_cache != entry_in_cache(cache_ptr, - check[i].entry_type, - check[i].entry_index)) { + while (pass && (i < check_size)) { + if (check[i].in_cache != entry_in_cache(cache_ptr, check[i].entry_type, check[i].entry_index)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Check1 failed on entry %d after flush op test #%d.", - i, test_num); + HDsnprintf(msg, (size_t)128, "Check1 failed on entry %d after flush op test #%d.", i, + test_num); failure_mssg = msg; - } + } base_addr = entries[check[i].entry_type]; entry_ptr = &(base_addr[check[i].entry_index]); - if((entry_ptr->size != check[i].expected_size) || - ((!entry_ptr->header.destroy_in_progress) && - (check[i].in_cache) && - (entry_ptr->header.size != check[i].expected_size)) || - (entry_ptr->at_main_addr != check[i].at_main_addr) || - (entry_ptr->is_dirty != check[i].is_dirty) || - (entry_ptr->header.is_dirty != check[i].is_dirty) || - (entry_ptr->is_protected != check[i].is_protected) || - (entry_ptr->header.is_protected != check[i].is_protected) || - (entry_ptr->is_pinned != check[i].is_pinned) || - (entry_ptr->header.is_pinned != check[i].is_pinned) || - (entry_ptr->deserialized != check[i].expected_deserialized) || - (entry_ptr->serialized != check[i].expected_serialized) || - (entry_ptr->destroyed != check[i].expected_destroyed)) { + if ((entry_ptr->size != check[i].expected_size) || + ((!entry_ptr->header.destroy_in_progress) && (check[i].in_cache) && + (entry_ptr->header.size != check[i].expected_size)) || + (entry_ptr->at_main_addr != check[i].at_main_addr) || + (entry_ptr->is_dirty != check[i].is_dirty) || + (entry_ptr->header.is_dirty != check[i].is_dirty) || + (entry_ptr->is_protected != check[i].is_protected) || + (entry_ptr->header.is_protected != check[i].is_protected) || + (entry_ptr->is_pinned != check[i].is_pinned) || + (entry_ptr->header.is_pinned != check[i].is_pinned) || + (entry_ptr->deserialized != check[i].expected_deserialized) || + (entry_ptr->serialized != check[i].expected_serialized) || + (entry_ptr->destroyed != check[i].expected_destroyed)) { #if 0 /* This is useful debugging code. Lets keep it around for a while. */ @@ -9522,76 +8269,56 @@ check_flush_cache__flush_op_test(H5F_t * file_ptr, } #endif pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Check2 failed on entry %d after flush op test #%d.", - i, test_num); + HDsnprintf(msg, (size_t)128, "Check2 failed on entry %d after flush op test #%d.", i, + test_num); failure_mssg = msg; - } - i++; + } + i++; } } - if(pass) { + if (pass) { - if((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) - && - ((cache_ptr->index_len != expected_index_len) - || - (cache_ptr->index_size != expected_index_size) - ) - ) - || - (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) - && - ((cache_ptr->index_len != 0) - || - (cache_ptr->index_size != 0) - ) - ) - ) { + if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && + ((cache_ptr->index_len != expected_index_len) || + (cache_ptr->index_size != expected_index_size))) || + (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && + ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after flush in flush op test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Unexpected cache len/size after flush in flush op test #%d.", + test_num); failure_mssg = msg; } } /* clean up the cache to prep for the next test */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Flush failed on cleanup in flush op test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Flush failed on cleanup in flush op test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->clean_index_size != 0) || - (cache_ptr->dirty_index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || + (cache_ptr->clean_index_size != 0) || (cache_ptr->dirty_index_size != 0)) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size/cs/ds after cleanup in flush op test #%d.", - test_num); + "Unexpected cache len/size/cs/ds after cleanup in flush op test #%d.", test_num); failure_mssg = msg; - } } i = 0; - while(pass && (i < spec_size)) - { + while (pass && (i < spec_size)) { base_addr = entries[spec[i].entry_type]; entry_ptr = &(base_addr[spec[i].entry_index]); - entry_ptr->size = entry_sizes[spec[i].entry_type]; + entry_ptr->size = entry_sizes[spec[i].entry_type]; entry_ptr->deserialized = FALSE; entry_ptr->serialized = FALSE; @@ -9601,12 +8328,11 @@ check_flush_cache__flush_op_test(H5F_t * file_ptr, } i = 0; - while(pass && (i < check_size)) - { + while (pass && (i < check_size)) { base_addr = entries[check[i].entry_type]; entry_ptr = &(base_addr[check[i].entry_index]); - entry_ptr->size = entry_sizes[check[i].entry_type]; + entry_ptr->size = entry_sizes[check[i].entry_type]; entry_ptr->deserialized = FALSE; entry_ptr->serialized = FALSE; @@ -9619,7 +8345,6 @@ check_flush_cache__flush_op_test(H5F_t * file_ptr, } /* check_flush_cache__flush_op_test() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__flush_op_eviction_test() * @@ -9644,865 +8369,1719 @@ check_flush_cache__flush_op_test(H5F_t * file_ptr, */ static void -check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) +check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; - int i; - int num_variable_entries = 10; - int num_monster_entries = 31; - int num_large_entries = 0; - herr_t result; - test_entry_t * entry_ptr; - test_entry_t * base_addr; - struct expected_entry_status expected[10 + 31 + 14] = - { - /* the expected array is used to maintain a table of the expected status of every - * entry used in this test. Note that since the function that processes this - * array only processes as much of it as it is told to, we don't have to - * worry about maintaining the status of entries that we haven't used yet. - */ - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { VARIABLE_ENTRY_TYPE, 0, VARIABLE_ENTRY_SIZE/4, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 1, VARIABLE_ENTRY_SIZE/4, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 2, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 3, VARIABLE_ENTRY_SIZE/4, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 4, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_SIZE/4, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 6, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 7, VARIABLE_ENTRY_SIZE/2, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 8, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { VARIABLE_ENTRY_TYPE, 9, VARIABLE_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 0, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 1, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 2, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 3, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 4, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 5, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 6, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 7, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 8, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 9, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 10, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 11, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 12, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 13, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 14, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 15, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 16, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 17, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 18, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 19, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 20, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 21, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 22, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 23, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 24, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 25, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 26, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 27, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 28, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 29, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 30, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 0, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 1, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 2, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 3, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 4, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 5, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 6, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 7, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 8, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 9, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 10, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 11, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 12, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { LARGE_ENTRY_TYPE, 13, LARGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE} - }; - - if(pass) { - - if(cache_ptr == NULL) { - - pass = FALSE; + H5C_t * cache_ptr = file_ptr->shared->cache; + int i; + int num_variable_entries = 10; + int num_monster_entries = 31; + int num_large_entries = 0; + herr_t result; + test_entry_t * entry_ptr; + test_entry_t * base_addr; + struct expected_entry_status expected[10 + 31 + 14] = { + /* the expected array is used to maintain a table of the expected status of every + * entry used in this test. Note that since the function that processes this + * array only processes as much of it as it is told to, we don't have to + * worry about maintaining the status of entries that we haven't used yet. + */ + /* entry entry in at main flush dep flush dep child flush flush + flush */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ + {VARIABLE_ENTRY_TYPE, + 0, + VARIABLE_ENTRY_SIZE / 4, + TRUE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 1, + VARIABLE_ENTRY_SIZE / 4, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 2, + VARIABLE_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 3, + VARIABLE_ENTRY_SIZE / 4, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 4, + VARIABLE_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 5, + VARIABLE_ENTRY_SIZE / 4, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 6, + VARIABLE_ENTRY_SIZE / 2, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 7, + VARIABLE_ENTRY_SIZE / 2, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 8, + VARIABLE_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {VARIABLE_ENTRY_TYPE, + 9, + VARIABLE_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 0, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 1, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 2, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 3, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 4, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 5, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 6, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 7, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 8, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 9, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 10, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 11, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 12, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 13, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 14, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 15, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 16, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 17, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 18, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 19, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 20, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 21, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 22, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 23, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 24, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 25, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 26, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 27, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 28, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 29, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 30, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 0, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 1, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 2, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 3, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 4, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 5, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 6, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 7, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 8, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 9, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 10, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 11, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 12, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {LARGE_ENTRY_TYPE, + 13, + LARGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}}; + + if (pass) { + + if (cache_ptr == NULL) { + + pass = FALSE; failure_mssg = "cache_ptr NULL on entry to flush ops test."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not empty at start of flush ops eviction test."; } - else if((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + else if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; - failure_mssg = - "unexpected cache config at start of flush op eviction test."; - - } else { + pass = FALSE; + failure_mssg = "unexpected cache config at start of flush op eviction test."; + } + else { /* set min clean size to zero for this test as it simplifies - * computing the expected cache size after each operation. - */ + * computing the expected cache size after each operation. + */ cache_ptr->min_clean_size = 0; } } - if(pass) { + if (pass) { /* the basic idea in this test is to insert a bunch of entries * with flush operations associated with them, and then load * other entries into the cache until the cache is full. At * that point, load yet more entries into the cache, and see * if the flush operations are performed as expected. - * - * To make things a bit more interesting, we also include a - * couple of pins. + * + * To make things a bit more interesting, we also include a + * couple of pins. */ - /* reset the stats before we start. If stats are enabled, we will - * check to see if they are as expected at the end. - */ - H5C_stats__reset(cache_ptr); + /* reset the stats before we start. If stats are enabled, we will + * check to see if they are as expected at the end. + */ + H5C_stats__reset(cache_ptr); + /* load a few entries with pin relationships and flush ops. + * Start by just loading the entries. + */ - /* load a few entries with pin relationships and flush ops. - * Start by just loading the entries. - */ + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0, (VARIABLE_ENTRY_SIZE / 4), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0, H5C__DIRTIED_FLAG); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0, - (VARIABLE_ENTRY_SIZE / 4), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1, (VARIABLE_ENTRY_SIZE / 4), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1, H5C__DIRTIED_FLAG); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1, - (VARIABLE_ENTRY_SIZE / 4), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 2); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 2, H5C__NO_FLAGS_SET); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 2); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 2, H5C__NO_FLAGS_SET); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3, (VARIABLE_ENTRY_SIZE / 4), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3, H5C__DIRTIED_FLAG); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3, - (VARIABLE_ENTRY_SIZE / 4), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 4); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 4, H5C__NO_FLAGS_SET); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 4); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 4, H5C__NO_FLAGS_SET); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5, (VARIABLE_ENTRY_SIZE / 4), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5, H5C__DIRTIED_FLAG); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5, - (VARIABLE_ENTRY_SIZE / 4), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6, (VARIABLE_ENTRY_SIZE / 2), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6, H5C__DIRTIED_FLAG); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6, - (VARIABLE_ENTRY_SIZE / 2), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7, (VARIABLE_ENTRY_SIZE / 2), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7, H5C__DIRTIED_FLAG); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7, - (VARIABLE_ENTRY_SIZE / 2), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__NO_FLAGS_SET); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__NO_FLAGS_SET); + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9, H5C__NO_FLAGS_SET); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9, H5C__NO_FLAGS_SET); + if ((cache_ptr->index_len != 10) || + (cache_ptr->index_size != + (4 * (VARIABLE_ENTRY_SIZE / 4)) + (2 * (VARIABLE_ENTRY_SIZE / 2)) + (4 * VARIABLE_ENTRY_SIZE))) { - if((cache_ptr->index_len != 10) || - (cache_ptr->index_size != (4 * (VARIABLE_ENTRY_SIZE / 4)) + - (2 * (VARIABLE_ENTRY_SIZE / 2)) + - (4 * VARIABLE_ENTRY_SIZE))) { + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 1."; + } + } - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 1."; - } - } - - if(pass) { - - /* Now set up the pinning relationships: - * - * Briefly, (VET, 0) is pinned by (VET, 1), (VET, 3), and (VET, 5) - * (VET, 9) is pinned by (VET, 5), and (VET, 7) - */ - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 1, - VARIABLE_ENTRY_TYPE, 0); - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 3, - VARIABLE_ENTRY_TYPE, 0); - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 5, - VARIABLE_ENTRY_TYPE, 0); - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 5, - VARIABLE_ENTRY_TYPE, 9); - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 7, - VARIABLE_ENTRY_TYPE, 9); - - /* Next, set up the flush operations: - * - * Briefly, (VET, 1) dirties (VET, 0) - * resizes (VET, 0) to 3/4 VARIABLE_ENTRY_SIZE - * - * (VET, 3) dirties (VET, 0) - * resizes (VET, 0) to VARIABLE_ENTRY_SIZE - * moves (VET, 0) to its alternate address - * - * (VET, 5) dirties (VET, 0) - * resizes itself to VARIABLE_ENTRY_SIZE / 2 + if (pass) { + + /* Now set up the pinning relationships: + * + * Briefly, (VET, 0) is pinned by (VET, 1), (VET, 3), and (VET, 5) + * (VET, 9) is pinned by (VET, 5), and (VET, 7) + */ + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 1, VARIABLE_ENTRY_TYPE, 0); + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 3, VARIABLE_ENTRY_TYPE, 0); + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_TYPE, 0); + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_TYPE, 9); + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 7, VARIABLE_ENTRY_TYPE, 9); + + /* Next, set up the flush operations: + * + * Briefly, (VET, 1) dirties (VET, 0) + * resizes (VET, 0) to 3/4 VARIABLE_ENTRY_SIZE + * + * (VET, 3) dirties (VET, 0) + * resizes (VET, 0) to VARIABLE_ENTRY_SIZE + * moves (VET, 0) to its alternate address + * + * (VET, 5) dirties (VET, 0) + * resizes itself to VARIABLE_ENTRY_SIZE / 2 * * (VET, 7) dirties (VET, 9) - * - * (VET, 9) dirties (VET, 8) - */ - add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__DIRTY, - VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); - add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__RESIZE, - VARIABLE_ENTRY_TYPE, 0, TRUE, - 3 * VARIABLE_ENTRY_SIZE / 4, NULL); - - add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__DIRTY, - VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); - add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__RESIZE, - VARIABLE_ENTRY_TYPE, 0, TRUE, VARIABLE_ENTRY_SIZE, NULL); - add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__MOVE, - VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); - - add_flush_op(VARIABLE_ENTRY_TYPE, 5, FLUSH_OP__DIRTY, - VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); - add_flush_op(VARIABLE_ENTRY_TYPE, 5, FLUSH_OP__RESIZE, - VARIABLE_ENTRY_TYPE, 5, TRUE, VARIABLE_ENTRY_SIZE / 2, NULL); - - add_flush_op(VARIABLE_ENTRY_TYPE, 7, FLUSH_OP__DIRTY, - VARIABLE_ENTRY_TYPE, 9, FALSE, (size_t)0, NULL); - - add_flush_op(VARIABLE_ENTRY_TYPE, 9, FLUSH_OP__DIRTY, - VARIABLE_ENTRY_TYPE, 8, FALSE, (size_t)0, NULL); - } - - if(pass) { - - /* to summarize, at present the following variable size entries - * are in cache with the following characteristics: - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 2.5 KB Y Y - - - * - * (VET, 1) Y 2.5 KB Y N 0 dirty (VET, 0), - * resize (VET, 0) to 7.5 KB - * - * (VET, 2) Y 10 KB N N - - - * - * - * (VET, 3) Y 2.5 KB N N 0 dirty (VET, 0) - * resize (VET, 0) to 10 KB - * move (VET, 0) to its alternate address - * - * (VET, 4) Y 10 KB N N - - - * - * - * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) - * resize (VET, 5) to 5 KB - * - * (VET, 6) Y 5 KB Y N - - - * - * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) - * - * (VET, 8) Y 10 KB N N - - - * - * (VET, 9) Y 10 KB N N - dirty (VET, 8) - * - * Recall that in this test bed, flush operations are excuted the - * first time the associated entry is flushed, and are then - * deleted. - */ + * + * (VET, 9) dirties (VET, 8) + */ + add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); + add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, TRUE, + 3 * VARIABLE_ENTRY_SIZE / 4, NULL); + + add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); + add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, TRUE, + VARIABLE_ENTRY_SIZE, NULL); + add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); + + add_flush_op(VARIABLE_ENTRY_TYPE, 5, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); + add_flush_op(VARIABLE_ENTRY_TYPE, 5, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 5, TRUE, + VARIABLE_ENTRY_SIZE / 2, NULL); + + add_flush_op(VARIABLE_ENTRY_TYPE, 7, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 9, FALSE, (size_t)0, NULL); + + add_flush_op(VARIABLE_ENTRY_TYPE, 9, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 8, FALSE, (size_t)0, NULL); + } + + if (pass) { + + /* to summarize, at present the following variable size entries + * are in cache with the following characteristics: + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 2.5 KB Y Y - - + * + * (VET, 1) Y 2.5 KB Y N 0 dirty (VET, 0), + * resize (VET, 0) to 7.5 KB + * + * (VET, 2) Y 10 KB N N - - + * + * + * (VET, 3) Y 2.5 KB N N 0 dirty (VET, 0) + * resize (VET, 0) to 10 KB + * move (VET, 0) to its alternate address + * + * (VET, 4) Y 10 KB N N - - + * + * + * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) + * resize (VET, 5) to 5 KB + * + * (VET, 6) Y 5 KB Y N - - + * + * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) + * + * (VET, 8) Y 10 KB N N - - + * + * (VET, 9) Y 10 KB N N - dirty (VET, 8) + * + * Recall that in this test bed, flush operations are excuted the + * first time the associated entry is flushed, and are then + * deleted. + */ /* Now fill up the cache with other, unrelated entries */ - for (i = 0; i < 31; i++) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + for (i = 0; i < 31; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } + + for (i = 0; i < 1; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } + + /* The cache should now be exactly full */ + if ((cache_ptr->index_len != 42) || (cache_ptr->index_size != 2 * 1024 * 1024) || + (cache_ptr->index_size != + ((4 * VARIABLE_ENTRY_SIZE / 4) + (2 * VARIABLE_ENTRY_SIZE / 2) + (4 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (1 * LARGE_ENTRY_SIZE)))) { + + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 2."; + } + else { + + /* verify the expected status of all entries we have loaded to date: */ + num_large_entries = 1; + verify_entry_status(cache_ptr, 0, + (num_variable_entries + num_monster_entries + num_large_entries), expected); + } } - for (i = 0; i < 1; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + if (pass) { + + /* Now load a large entry. This should result in the eviction + * of (VET,2), and the increase in the size of (VET, 0) from .25 + * VARIABLE_ENTRY_SIZE to .75 VARIABLE_ENTRY_SIZE. + * + * The following table illustrates the intended state of affairs + * after the eviction: + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 7.5 KB Y Y - - + * + * (VET, 1) Y 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) Y 2.5 KB Y N 0 dirty (VET, 0) + * resize (VET, 0) to 10 KB + * move (VET, 0) to its alternate address + * + * (VET, 4) Y 10 KB N N - - + * + * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) + * resize (VET, 5) to 5 KB + * + * (VET, 6) Y 5 KB Y N - - + * + * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) + * + * (VET, 8) Y 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ + expected[0].size = 3 * VARIABLE_ENTRY_SIZE / 4; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[2].in_cache = FALSE; + expected[2].destroyed = TRUE; - /* The cache should now be exactly full */ - if((cache_ptr->index_len != 42) || - (cache_ptr->index_size != 2 * 1024 * 1024) || - (cache_ptr->index_size != ((4 * VARIABLE_ENTRY_SIZE / 4) + - (2 * VARIABLE_ENTRY_SIZE / 2) + - (4 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (1 * LARGE_ENTRY_SIZE)))) { + num_large_entries = 2; - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 2."; + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, H5C__DIRTIED_FLAG); - } else { + if ((cache_ptr->index_len != 42) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (VARIABLE_ENTRY_SIZE) + (VARIABLE_ENTRY_SIZE / 2) + (LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((1 * (3 * VARIABLE_ENTRY_SIZE / 4)) + (3 * VARIABLE_ENTRY_SIZE / 4) + + (2 * VARIABLE_ENTRY_SIZE / 2) + (3 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (2 * LARGE_ENTRY_SIZE)))) { + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 3."; + } - /* verify the expected status of all entries we have loaded to date: */ - num_large_entries = 1; - verify_entry_status(cache_ptr, - 0, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); - } - } - - if(pass) { - - /* Now load a large entry. This should result in the eviction - * of (VET,2), and the increase in the size of (VET, 0) from .25 - * VARIABLE_ENTRY_SIZE to .75 VARIABLE_ENTRY_SIZE. - * - * The following table illustrates the intended state of affairs - * after the eviction: - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 7.5 KB Y Y - - - * - * (VET, 1) Y 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) Y 2.5 KB Y N 0 dirty (VET, 0) - * resize (VET, 0) to 10 KB - * move (VET, 0) to its alternate address - * - * (VET, 4) Y 10 KB N N - - - * - * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) - * resize (VET, 5) to 5 KB - * - * (VET, 6) Y 5 KB Y N - - - * - * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) - * - * (VET, 8) Y 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - expected[0].size = 3 * VARIABLE_ENTRY_SIZE / 4; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[2].in_cache = FALSE; - expected[2].destroyed = TRUE; + /* verify entry status */ + verify_entry_status(cache_ptr, 1, (num_variable_entries + num_monster_entries + num_large_entries), + expected); + } - num_large_entries = 2; + if (pass) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, H5C__DIRTIED_FLAG); - - if((cache_ptr->index_len != 42) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (VARIABLE_ENTRY_SIZE) + - (VARIABLE_ENTRY_SIZE / 2) + - (LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((1 * (3 * VARIABLE_ENTRY_SIZE / 4)) + - (3 * VARIABLE_ENTRY_SIZE / 4) + - (2 * VARIABLE_ENTRY_SIZE / 2) + - (3 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (2 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 3."; - } - - /* verify entry status */ - verify_entry_status(cache_ptr, - 1, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); - } - - if(pass) { - - /* Now load another large entry. This should result in the eviction - * of (VET, 4), the increase in the size of (VET, 0) from .75 - * VARIABLE_ENTRY_SIZE to 1.0 VARIABLE_ENTRY_SIZE, and the renaming - * of (VET, 0) to its alternate address. - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y Y - - - * - * (VET, 1) Y 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) Y 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) - * resize (VET, 5) to 5 KB - * - * (VET, 6) Y 5 KB Y N - - - * - * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) - * - * (VET, 8) Y 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - expected[0].size = VARIABLE_ENTRY_SIZE; - expected[0].at_main_addr = FALSE; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[4].in_cache = FALSE; - expected[4].destroyed = TRUE; + /* Now load another large entry. This should result in the eviction + * of (VET, 4), the increase in the size of (VET, 0) from .75 + * VARIABLE_ENTRY_SIZE to 1.0 VARIABLE_ENTRY_SIZE, and the renaming + * of (VET, 0) to its alternate address. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y Y - - + * + * (VET, 1) Y 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) Y 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) + * resize (VET, 5) to 5 KB + * + * (VET, 6) Y 5 KB Y N - - + * + * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) + * + * (VET, 8) Y 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ + expected[0].size = VARIABLE_ENTRY_SIZE; + expected[0].at_main_addr = FALSE; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[4].in_cache = FALSE; + expected[4].destroyed = TRUE; num_large_entries = 3; - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, H5C__DIRTIED_FLAG); - if((cache_ptr->index_len != 42) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (2 * VARIABLE_ENTRY_SIZE) + - (3 * VARIABLE_ENTRY_SIZE / 4) + - (2 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((3 * VARIABLE_ENTRY_SIZE / 4) + - (2 * VARIABLE_ENTRY_SIZE / 2) + - (3 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (3 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 42) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (2 * VARIABLE_ENTRY_SIZE) + + (3 * VARIABLE_ENTRY_SIZE / 4) + (2 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((3 * VARIABLE_ENTRY_SIZE / 4) + (2 * VARIABLE_ENTRY_SIZE / 2) + (3 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (3 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 4."; - } + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 4."; + } - /* verify entry status */ - verify_entry_status(cache_ptr, - 2, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); + /* verify entry status */ + verify_entry_status(cache_ptr, 2, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } - if(pass) { + if (pass) { - /* load two more large entries. This should result in (VET, 5) being - * flushed, and increasing its size from 1/4 VARIABLE_ENTRY_SIZE to - * VARIABLE_ENTRY_SIZE. - * - * As a result of this size increase, the cache will have to look - * for another entry to evict. After flushing (VET, 6) and (VET, 7), - * it should evict (VET, 8), yielding the needed memory and dirtying + /* load two more large entries. This should result in (VET, 5) being + * flushed, and increasing its size from 1/4 VARIABLE_ENTRY_SIZE to + * VARIABLE_ENTRY_SIZE. + * + * As a result of this size increase, the cache will have to look + * for another entry to evict. After flushing (VET, 6) and (VET, 7), + * it should evict (VET, 8), yielding the needed memory and dirtying * (VET, 9). - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y Y - - - * - * (VET, 1) Y 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) Y 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) Y 5 KB N N 0, 9 - - * - * (VET, 6) Y 5 KB N N - - - * - * (VET, 7) Y 5 KB N N 9 - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - - expected[5].size = VARIABLE_ENTRY_SIZE / 2; - expected[5].is_dirty = FALSE; - expected[5].serialized = TRUE; - expected[6].is_dirty = FALSE; - expected[6].serialized = TRUE; - expected[7].is_dirty = FALSE; - expected[7].serialized = TRUE; - expected[8].in_cache = FALSE; - expected[8].destroyed = TRUE; - expected[9].is_dirty = TRUE; + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y Y - - + * + * (VET, 1) Y 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) Y 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) Y 5 KB N N 0, 9 - + * + * (VET, 6) Y 5 KB N N - - + * + * (VET, 7) Y 5 KB N N 9 - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ + + expected[5].size = VARIABLE_ENTRY_SIZE / 2; + expected[5].is_dirty = FALSE; + expected[5].serialized = TRUE; + expected[6].is_dirty = FALSE; + expected[6].serialized = TRUE; + expected[7].is_dirty = FALSE; + expected[7].serialized = TRUE; + expected[8].in_cache = FALSE; + expected[8].destroyed = TRUE; + expected[9].is_dirty = TRUE; num_large_entries = 5; - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, H5C__DIRTIED_FLAG); - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 4); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 4, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 4); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 4, H5C__DIRTIED_FLAG); /* verify cache size */ - if((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (3 * VARIABLE_ENTRY_SIZE) + - (1 * VARIABLE_ENTRY_SIZE / 4) + - (3 * VARIABLE_ENTRY_SIZE / 4) + - (4 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE / 4) + - (3 * VARIABLE_ENTRY_SIZE / 2) + - (2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (5 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) + + (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + + (4 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((2 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (5 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 5."; - } + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 5."; + } - /* verify entry status */ - verify_entry_status(cache_ptr, - 3, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); + /* verify entry status */ + verify_entry_status(cache_ptr, 3, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } - if(pass) { + if (pass) { /* now touch all the non VARIABLE_ENTRY_TYPE entries in the - * cache to bring all the VARIABLE_ENTRY_TYPE entries to the - * end of the LRU list. - * - * Note that we don't have to worry about (VET, 0) and (VET, 9) - * as they are pinned and thus not in the LRU list to begin with. - */ - for (i = 0; i < 31; i++) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + * cache to bring all the VARIABLE_ENTRY_TYPE entries to the + * end of the LRU list. + * + * Note that we don't have to worry about (VET, 0) and (VET, 9) + * as they are pinned and thus not in the LRU list to begin with. + */ + for (i = 0; i < 31; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } - for (i = 0; i < 5; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 0; i < 5; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } /* verify cache size */ - if((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (3 * VARIABLE_ENTRY_SIZE) + - (1 * VARIABLE_ENTRY_SIZE / 4) + - (3 * VARIABLE_ENTRY_SIZE / 4) + - (4 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE / 4) + - (3 * VARIABLE_ENTRY_SIZE / 2) + - (2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (5 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) + + (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + + (4 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((2 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (5 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 6."; - } + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 6."; + } - /* verify entry status */ - verify_entry_status(cache_ptr, - 4, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); + /* verify entry status */ + verify_entry_status(cache_ptr, 4, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } - if(pass) { + if (pass) { - /* Now load three more large entries. This should result - * in the evictions of (VET, 1), (VET, 3), and (VET, 5), and the + /* Now load three more large entries. This should result + * in the evictions of (VET, 1), (VET, 3), and (VET, 5), and the * unpinning of (VET, 0) - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y N - - - * - * (VET, 1) N 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) N 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) N 5 KB N N - - - * - * (VET, 6) Y 5 KB N N - - - * - * (VET, 7) Y 5 KB N N 9 - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - - expected[0].is_pinned = FALSE; - expected[1].in_cache = FALSE; - expected[1].destroyed = TRUE; - expected[3].in_cache = FALSE; - expected[3].destroyed = TRUE; - expected[5].in_cache = FALSE; - expected[5].destroyed = TRUE; + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) Y 5 KB N N - - + * + * (VET, 7) Y 5 KB N N 9 - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ + + expected[0].is_pinned = FALSE; + expected[1].in_cache = FALSE; + expected[1].destroyed = TRUE; + expected[3].in_cache = FALSE; + expected[3].destroyed = TRUE; + expected[5].in_cache = FALSE; + expected[5].destroyed = TRUE; num_large_entries = 8; - for (i = 5; i < 8; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 5; i < 8; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } /* verify cache size */ - if((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (4 * VARIABLE_ENTRY_SIZE) + - (1 * VARIABLE_ENTRY_SIZE / 4) + - (3 * VARIABLE_ENTRY_SIZE / 4) + - (7 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE / 2) + - (2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (8 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + + (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + + (7 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (8 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 7."; - } - - /* verify entry status */ - verify_entry_status(cache_ptr, - 5, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); - } - - if(pass) { - - /* load another large entry. (VET, 6) should be evicted. - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y N - - - * - * (VET, 1) N 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) N 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) N 5 KB N N - - - * - * (VET, 6) N 5 KB N N - - - * - * (VET, 7) Y 5 KB N N 9 - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - - expected[6].in_cache = FALSE; - expected[6].destroyed = TRUE; + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 7."; + } + + /* verify entry status */ + verify_entry_status(cache_ptr, 5, (num_variable_entries + num_monster_entries + num_large_entries), + expected); + } + + if (pass) { + + /* load another large entry. (VET, 6) should be evicted. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) N 5 KB N N - - + * + * (VET, 7) Y 5 KB N N 9 - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ + + expected[6].in_cache = FALSE; + expected[6].destroyed = TRUE; num_large_entries = 9; - for (i = 8; i < 9; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 8; i < 9; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } /* verify cache size */ - if((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (3 * VARIABLE_ENTRY_SIZE) - - (VARIABLE_ENTRY_SIZE / 2) + - (8 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((1 * VARIABLE_ENTRY_SIZE / 2) + - (2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (9 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) - + (VARIABLE_ENTRY_SIZE / 2) + (8 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((1 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 8."; - } - - /* verify entry status */ - verify_entry_status(cache_ptr, - 6, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); - } - - if(pass) { - - /* Load another large entry. - * - * (VET, 7) should be evicted, and (VET, 9) should be unpinned. - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y N - - - * - * (VET, 1) N 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) N 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) N 5 KB N N - - - * - * (VET, 6) N 5 KB N N - - - * - * (VET, 7) N 5 KB N N - - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) Y 10 KB Y N - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - - expected[7].in_cache = FALSE; - expected[7].destroyed = TRUE; - expected[9].is_pinned = FALSE; + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 8."; + } + + /* verify entry status */ + verify_entry_status(cache_ptr, 6, (num_variable_entries + num_monster_entries + num_large_entries), + expected); + } + + if (pass) { + + /* Load another large entry. + * + * (VET, 7) should be evicted, and (VET, 9) should be unpinned. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) N 5 KB N N - - + * + * (VET, 7) N 5 KB N N - - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) Y 10 KB Y N - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ + + expected[7].in_cache = FALSE; + expected[7].destroyed = TRUE; + expected[9].is_pinned = FALSE; num_large_entries = 10; - for (i = 9; i < 10; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 9; i < 10; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } /* verify cache size */ - if((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (4 * VARIABLE_ENTRY_SIZE) + - (9 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (10 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((2 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (10 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 9."; - } + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 9."; + } - /* verify entry status */ - verify_entry_status(cache_ptr, - 7, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); + /* verify entry status */ + verify_entry_status(cache_ptr, 7, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } - if(pass) { + if (pass) { /* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the - * cache to bring all the VARIABLE_ENTRY_TYPE entries to the - * end of the LRU list. - * - * Both (VET, 0) and (VET, 7) have been unpinned, so they are - * now in the LRU list. - */ - for (i = 0; i < 31; i++) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + * cache to bring all the VARIABLE_ENTRY_TYPE entries to the + * end of the LRU list. + * + * Both (VET, 0) and (VET, 7) have been unpinned, so they are + * now in the LRU list. + */ + for (i = 0; i < 31; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } - for (i = 0; i < 10; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 0; i < 10; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } /* verify cache size */ - if((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (4 * VARIABLE_ENTRY_SIZE) + - (9 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (10 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((2 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (10 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 10."; - } + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 10."; + } - /* verify entry status */ - verify_entry_status(cache_ptr, - 8, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); + /* verify entry status */ + verify_entry_status(cache_ptr, 8, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } - if(pass) { + if (pass) { - /* load two more large entries. Things get a bit complicated here, - * so I'll go through the operation step by step. + /* load two more large entries. Things get a bit complicated here, + * so I'll go through the operation step by step. * * Initially, the cache has 4 KB of empty space, so the first entry - * (LET, 10) is loaded via calls to H5C_protect() H5C_unprotect() - * without causing any evictions. + * (LET, 10) is loaded via calls to H5C_protect() H5C_unprotect() + * without causing any evictions. * * However, this is not the case for the call of H5C_protect() on - * (LET, 11). + * (LET, 11). * * Before inserting (LET, 11), H5C_protect(LET, 11) must try to - * free up at least 4 KB of space. To do this, it starts scanning - * up the LRU list to find entries to evict. + * free up at least 4 KB of space. To do this, it starts scanning + * up the LRU list to find entries to evict. * * (VET, 0) is at the bottom of the LRU list, and thus is the first - * entry considered. However, it is dirty, so it flushed to disk, + * entry considered. However, it is dirty, so it flushed to disk, * moved to the top of the LRU list, and marked clean. * * (VET, 9) is the next entry on the bottom of the LRU list. It is - * dirty too, calls its serialize callback function to construct an + * dirty too, calls its serialize callback function to construct an * on disk image of the entry, and moves it to the top of the LRU * list after the serialize callback returns. * * However, (VET 9)'s serialize function needs to modify (VET, 8), * which is currently not in cache. Thus it calls H5C_protect(VET, 8) - * to gain access to it. H5C_protect(VET, 8) loads (VET, 8), and - * then attempts to evict entries to make space for it. + * to gain access to it. H5C_protect(VET, 8) loads (VET, 8), and + * then attempts to evict entries to make space for it. * * However, H5C_make_space_in_cache() now exits without taking * any action on re-entrant calls. Thus H5C_protect(VET, 8) simply @@ -10521,12 +10100,12 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * and are therefore flushed and moved to the head of the LRU list. * * The next entry on the bottom of the LRU list is (VET, 0), which - * is clean, and is therefore evicted, leaving H5C_make_space_in_cache() + * is clean, and is therefore evicted, leaving H5C_make_space_in_cache() * with 4 KB of space to create. * - * This space is sufficient, so H5C_protect(VET, 8) inserts - * (VET, 8) into the cache's index, marks it as protected, and - * returns to the serialize function for (VET, 9). + * This space is sufficient, so H5C_protect(VET, 8) inserts + * (VET, 8) into the cache's index, marks it as protected, and + * returns to the serialize function for (VET, 9). * * When the serialize function for (VET, 9) is done with (VET, 8), it * calls H5C_unprotect(VET, 8), which markes (VET, 8) as dirty and @@ -10536,104 +10115,95 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * evicted -- leaving 6 KB of free space after (LET, 11) is inserted * into the cache. * - * H5C_unprotect(LET, 11) marks (LET, 11) as unprotected, and then - * returns as well. - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) N 10 KB N N - - - * - * (VET, 1) N 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) N 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) N 5 KB N N - - - * - * (VET, 6) N 5 KB N N - - - * - * (VET, 7) N 5 KB N N - - - * - * (VET, 8) Y 10 KB N N - - - * - * (VET, 9) N 10 KB N N - - - * - * Start by updating the expected table for the expected changes in - * entry status: - * - * Note that we reset the loaded, flushed, and destroyed - * fields of (VET,8) so we can track what is happening. - */ - base_addr = entries[VARIABLE_ENTRY_TYPE]; - entry_ptr = &(base_addr[8]); - entry_ptr->deserialized = FALSE; - entry_ptr->deserialized = FALSE; - entry_ptr->destroyed = FALSE; - - expected[0].in_cache = FALSE; - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].destroyed = TRUE; - expected[8].in_cache = TRUE; - expected[8].is_dirty = FALSE; - expected[8].deserialized = TRUE; - expected[8].serialized = TRUE; - expected[8].destroyed = FALSE; - expected[9].in_cache = FALSE; - expected[9].is_dirty = FALSE; - expected[9].serialized = TRUE; - expected[9].destroyed = TRUE; - - expected[10].in_cache = TRUE; - expected[10].is_dirty = FALSE; - expected[10].serialized = TRUE; - expected[10].destroyed = FALSE; + * H5C_unprotect(LET, 11) marks (LET, 11) as unprotected, and then + * returns as well. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) N 10 KB N N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) N 5 KB N N - - + * + * (VET, 7) N 5 KB N N - - + * + * (VET, 8) Y 10 KB N N - - + * + * (VET, 9) N 10 KB N N - - + * + * Start by updating the expected table for the expected changes in + * entry status: + * + * Note that we reset the loaded, flushed, and destroyed + * fields of (VET,8) so we can track what is happening. + */ + base_addr = entries[VARIABLE_ENTRY_TYPE]; + entry_ptr = &(base_addr[8]); + entry_ptr->deserialized = FALSE; + entry_ptr->deserialized = FALSE; + entry_ptr->destroyed = FALSE; + + expected[0].in_cache = FALSE; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].destroyed = TRUE; + expected[8].in_cache = TRUE; + expected[8].is_dirty = FALSE; + expected[8].deserialized = TRUE; + expected[8].serialized = TRUE; + expected[8].destroyed = FALSE; + expected[9].in_cache = FALSE; + expected[9].is_dirty = FALSE; + expected[9].serialized = TRUE; + expected[9].destroyed = TRUE; + + expected[10].in_cache = TRUE; + expected[10].is_dirty = FALSE; + expected[10].serialized = TRUE; + expected[10].destroyed = FALSE; num_large_entries = 12; - for (i = num_variable_entries; - i < num_variable_entries + num_monster_entries + num_large_entries - 1; - i++) - { + for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; + i++) { expected[i].is_dirty = FALSE; - expected[i].serialized = TRUE; - } + expected[i].serialized = TRUE; + } - for (i = 10; i < 12; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 10; i < 12; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } /* verify cache size */ - if((cache_ptr->index_len != 44) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (2 * 1024) - - (1 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((1 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (12 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 44) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (2 * 1024) - (1 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((1 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (12 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 11."; - } + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 11."; + } - /* verify entry status */ - verify_entry_status(cache_ptr, - 9, - (num_variable_entries + num_monster_entries + - num_large_entries), - expected); + /* verify entry status */ + verify_entry_status(cache_ptr, 9, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } - if(pass) { + if (pass) { /* protect and unprotect VET 9 to evict MET 0 */ protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9); @@ -10643,92 +10213,81 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * top of the LRU. Since we are dirtying it again, reset its * serialized flag. */ - base_addr = entries[VARIABLE_ENTRY_TYPE]; - entry_ptr = &(base_addr[8]); + base_addr = entries[VARIABLE_ENTRY_TYPE]; + entry_ptr = &(base_addr[8]); entry_ptr->serialized = FALSE; protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__DIRTIED_FLAG); - /* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the - * cache to evict VET 9 and move VET 8 to the bottom of the LRU. + * cache to evict VET 9 and move VET 8 to the bottom of the LRU. * * Must do this twice to get the desired result. - */ - + */ /* skip MET 0 in first pass so that we evict VET 9 when we * reload MET 0 * * Since we are reloading MET 0, reset its destroyed flag. */ - base_addr = entries[MONSTER_ENTRY_TYPE]; - entry_ptr = &(base_addr[0]); + base_addr = entries[MONSTER_ENTRY_TYPE]; + entry_ptr = &(base_addr[0]); entry_ptr->destroyed = FALSE; - for (i = 1; i < num_monster_entries; i++) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + for (i = 1; i < num_monster_entries; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } - for (i = 0; i < num_large_entries; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 0; i < num_large_entries; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } - for (i = 0; i < num_monster_entries; i++) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + for (i = 0; i < num_monster_entries; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } - for (i = 0; i < num_large_entries; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 0; i < num_large_entries; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } - /* update the expected array to mark all these entries dirty again. */ - for (i = num_variable_entries; - i < num_variable_entries + num_monster_entries + num_large_entries - 1; - i++) - { + /* update the expected array to mark all these entries dirty again. */ + for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; + i++) { expected[i].is_dirty = TRUE; - } + } /* update MET 0 to set its in cache flag, and reset * its destroyed flag */ - expected[10].in_cache = TRUE; + expected[10].in_cache = TRUE; /* pass through non variable entries will flush VET 8, and evict VET 9. * Update accordingly. */ - expected[8].in_cache = TRUE; - expected[8].is_dirty = TRUE; - expected[8].serialized = FALSE; - expected[8].destroyed = FALSE; - expected[9].in_cache = FALSE; - expected[9].is_dirty = FALSE; - expected[9].serialized = TRUE; - expected[9].destroyed = TRUE; - + expected[8].in_cache = TRUE; + expected[8].is_dirty = TRUE; + expected[8].serialized = FALSE; + expected[8].destroyed = FALSE; + expected[9].in_cache = FALSE; + expected[9].is_dirty = FALSE; + expected[9].serialized = TRUE; + expected[9].destroyed = TRUE; /* verify cache size */ - if((cache_ptr->index_len != 44) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (5 * VARIABLE_ENTRY_SIZE) + - (11 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((1 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + - (12 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 44) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (5 * VARIABLE_ENTRY_SIZE) + (11 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((1 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (12 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 12."; - } + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 12."; + } /* modifications to the H5C__flush_single_entry() function have * changed the behavior of the cache slightly, causing @@ -10736,88 +10295,81 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * fix if all goes well. */ - /* verify entry status */ - verify_entry_status(cache_ptr, - 10, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); - } - - if(pass) { - - /* Load two more large entries. - * - * Since (VET, 8) is dirty, at first this will just cause (VET, 8) - * to be flushed. - * - * But all other entries in the cache are dirty, so the cache will - * flush them all, and then evict (VET, 8) on the second pass. - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) N 10 KB N N - - - * - * (VET, 1) N 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) N 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) N 5 KB N N - - - * - * (VET, 6) N 5 KB N N - - - * - * (VET, 7) N 5 KB N N - - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) N 10 KB N N - - - * - * Start by updating the expected table for the expected changes in - * entry status: - */ - - expected[8].in_cache = FALSE; - expected[8].is_dirty = FALSE; - expected[8].serialized = TRUE; - expected[8].destroyed = TRUE; + /* verify entry status */ + verify_entry_status(cache_ptr, 10, (num_variable_entries + num_monster_entries + num_large_entries), + expected); + } + + if (pass) { + + /* Load two more large entries. + * + * Since (VET, 8) is dirty, at first this will just cause (VET, 8) + * to be flushed. + * + * But all other entries in the cache are dirty, so the cache will + * flush them all, and then evict (VET, 8) on the second pass. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) N 10 KB N N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) N 5 KB N N - - + * + * (VET, 7) N 5 KB N N - - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) N 10 KB N N - - + * + * Start by updating the expected table for the expected changes in + * entry status: + */ + + expected[8].in_cache = FALSE; + expected[8].is_dirty = FALSE; + expected[8].serialized = TRUE; + expected[8].destroyed = TRUE; num_large_entries = 14; - /* a newly loaded entry is not inserted in the cache until after - * space has been made for it. Thus (LET, 13) will not be flushed. - */ - for (i = num_variable_entries; - i < num_variable_entries + num_monster_entries + num_large_entries - 1; - i++) - { + /* a newly loaded entry is not inserted in the cache until after + * space has been made for it. Thus (LET, 13) will not be flushed. + */ + for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; + i++) { expected[i].is_dirty = FALSE; - expected[i].serialized = TRUE; - } + expected[i].serialized = TRUE; + } - for (i = 12; i < 14; i++) - { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + for (i = 12; i < 14; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + } /* verify cache size */ - if((cache_ptr->index_len != 45) || - (cache_ptr->index_size != (2 * 1024 * 1024) - - (6 * VARIABLE_ENTRY_SIZE) + - (13 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((31 * MONSTER_ENTRY_SIZE) + - (14 * LARGE_ENTRY_SIZE)))) { + if ((cache_ptr->index_len != 45) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (6 * VARIABLE_ENTRY_SIZE) + (13 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((31 * MONSTER_ENTRY_SIZE) + (14 * LARGE_ENTRY_SIZE)))) { - pass = FALSE; - failure_mssg = "unexpected size/len in flush op eviction test 13."; - } + pass = FALSE; + failure_mssg = "unexpected size/len in flush op eviction test 13."; + } /* modifications to the H5C__flush_single_entry() function have * changed the behavior of the cache slightly, causing @@ -10825,11 +10377,9 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * fix if all goes well. */ - /* verify entry status */ - verify_entry_status(cache_ptr, - 11, - (num_variable_entries + num_monster_entries + num_large_entries), - expected); + /* verify entry status */ + verify_entry_status(cache_ptr, 11, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } /* at this point we have cycled all the variable size entries through @@ -10838,21 +10388,19 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * flush the cache and end the test. */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Cache flush invalidate failed after flush op eviction test"; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache len/size after cleanup of flush op eviction test"; - } } @@ -10865,95 +10413,89 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * to start testing the stats whenever it is convenient to do * so. */ - if(pass) { - - if((cache_ptr->insertions[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->clears[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[VARIABLE_ENTRY_TYPE] != 9) || - (cache_ptr->evictions[VARIABLE_ENTRY_TYPE] != 12) || - (cache_ptr->take_ownerships[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->moves[VARIABLE_ENTRY_TYPE] != 1) || - (cache_ptr->entry_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->pins[VARIABLE_ENTRY_TYPE] != 2) || - (cache_ptr->unpins[VARIABLE_ENTRY_TYPE] != 2) || - (cache_ptr->dirty_pins[VARIABLE_ENTRY_TYPE] != 2) || - (cache_ptr->pinned_flushes[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[VARIABLE_ENTRY_TYPE] != 3) || - (cache_ptr->size_decreases[VARIABLE_ENTRY_TYPE] != 6) || - (cache_ptr->entry_flush_size_changes[VARIABLE_ENTRY_TYPE] != 1) || - (cache_ptr->cache_flush_size_changes[VARIABLE_ENTRY_TYPE] != 0)) { - - pass = FALSE; - failure_mssg = "Unexpected variable size entry stats in check_flush_cache__flush_op_eviction_test()."; - } - } - - if(pass) { - - if((cache_ptr->insertions[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->clears[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[LARGE_ENTRY_TYPE] != 25) || - (cache_ptr->evictions[LARGE_ENTRY_TYPE] != 14) || - (cache_ptr->take_ownerships[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->moves[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->pins[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[LARGE_ENTRY_TYPE] != 0)) { + if (pass) { + + if ((cache_ptr->insertions[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->clears[VARIABLE_ENTRY_TYPE] != 0) || (cache_ptr->flushes[VARIABLE_ENTRY_TYPE] != 9) || + (cache_ptr->evictions[VARIABLE_ENTRY_TYPE] != 12) || + (cache_ptr->take_ownerships[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->moves[VARIABLE_ENTRY_TYPE] != 1) || + (cache_ptr->entry_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->pins[VARIABLE_ENTRY_TYPE] != 2) || (cache_ptr->unpins[VARIABLE_ENTRY_TYPE] != 2) || + (cache_ptr->dirty_pins[VARIABLE_ENTRY_TYPE] != 2) || + (cache_ptr->pinned_flushes[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[VARIABLE_ENTRY_TYPE] != 3) || + (cache_ptr->size_decreases[VARIABLE_ENTRY_TYPE] != 6) || + (cache_ptr->entry_flush_size_changes[VARIABLE_ENTRY_TYPE] != 1) || + (cache_ptr->cache_flush_size_changes[VARIABLE_ENTRY_TYPE] != 0)) { pass = FALSE; + failure_mssg = + "Unexpected variable size entry stats in check_flush_cache__flush_op_eviction_test()."; + } + } + + if (pass) { + + if ((cache_ptr->insertions[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->clears[LARGE_ENTRY_TYPE] != 0) || (cache_ptr->flushes[LARGE_ENTRY_TYPE] != 25) || + (cache_ptr->evictions[LARGE_ENTRY_TYPE] != 14) || + (cache_ptr->take_ownerships[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->moves[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->pins[LARGE_ENTRY_TYPE] != 0) || (cache_ptr->unpins[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[LARGE_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected large entry stats in check_flush_cache__flush_op_eviction_test()."; } } - if(pass) { - - if((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 62) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + if (pass) { - pass = FALSE; + if ((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 62) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster entry stats in check_flush_cache__flush_op_eviction_test()."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) { + if (pass) { - reset_entries(); + reset_entries(); } return; } /* check_flush_cache__flush_op_eviction_test() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__single_entry() * @@ -10978,26 +10520,24 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) */ static void -check_flush_cache__single_entry(H5F_t * file_ptr) +check_flush_cache__single_entry(H5F_t *file_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; + H5C_t *cache_ptr = file_ptr->shared->cache; - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache_ptr NULL on entry to single entry case."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not empty at beginning of single entry case."; } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 1, /* entry_type */ PICO_ENTRY_TYPE, @@ -11007,14 +10547,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 2, /* entry_type */ PICO_ENTRY_TYPE, @@ -11024,14 +10562,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ TRUE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 3, /* entry_type */ PICO_ENTRY_TYPE, @@ -11041,14 +10577,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 4, /* entry_type */ PICO_ENTRY_TYPE, @@ -11058,14 +10592,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 5, /* entry_type */ PICO_ENTRY_TYPE, @@ -11075,14 +10607,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 6, /* entry_type */ PICO_ENTRY_TYPE, @@ -11092,14 +10622,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 7, /* entry_type */ PICO_ENTRY_TYPE, @@ -11109,14 +10637,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 8, /* entry_type */ PICO_ENTRY_TYPE, @@ -11126,160 +10652,134 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 9, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 10, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 11, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 12, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 13, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_INVALIDATE_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 14, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_INVALIDATE_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 15, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 16, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 17, /* entry_type */ PICO_ENTRY_TYPE, @@ -11289,14 +10789,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 18, /* entry_type */ PICO_ENTRY_TYPE, @@ -11306,14 +10804,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ TRUE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 19, /* entry_type */ PICO_ENTRY_TYPE, @@ -11323,14 +10819,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 20, /* entry_type */ PICO_ENTRY_TYPE, @@ -11340,14 +10834,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 21, /* entry_type */ PICO_ENTRY_TYPE, @@ -11357,14 +10849,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 22, /* entry_type */ PICO_ENTRY_TYPE, @@ -11374,14 +10864,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 23, /* entry_type */ PICO_ENTRY_TYPE, @@ -11391,14 +10879,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 24, /* entry_type */ PICO_ENTRY_TYPE, @@ -11408,160 +10894,134 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 25, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 26, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 27, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 28, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 29, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_INVALIDATE_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 30, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_INVALIDATE_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 31, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 32, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ FALSE, /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ TRUE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 33, /* entry_type */ PICO_ENTRY_TYPE, @@ -11571,14 +11031,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 34, /* entry_type */ PICO_ENTRY_TYPE, @@ -11588,14 +11046,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 35, /* entry_type */ PICO_ENTRY_TYPE, @@ -11605,14 +11061,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 36, /* entry_type */ PICO_ENTRY_TYPE, @@ -11622,14 +11076,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 37, /* entry_type */ PICO_ENTRY_TYPE, @@ -11639,14 +11091,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 38, /* entry_type */ PICO_ENTRY_TYPE, @@ -11656,14 +11106,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 39, /* entry_type */ PICO_ENTRY_TYPE, @@ -11673,14 +11121,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 40, /* entry_type */ PICO_ENTRY_TYPE, @@ -11690,160 +11136,134 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 41, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 42, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 43, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 44, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 45, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_INVALIDATE_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 46, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_INVALIDATE_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 47, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 48, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 49, /* entry_type */ PICO_ENTRY_TYPE, @@ -11853,14 +11273,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 50, /* entry_type */ PICO_ENTRY_TYPE, @@ -11870,14 +11288,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 51, /* entry_type */ PICO_ENTRY_TYPE, @@ -11887,14 +11303,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 52, /* entry_type */ PICO_ENTRY_TYPE, @@ -11904,14 +11318,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 53, /* entry_type */ PICO_ENTRY_TYPE, @@ -11921,14 +11333,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 54, /* entry_type */ PICO_ENTRY_TYPE, @@ -11938,14 +11348,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 55, /* entry_type */ PICO_ENTRY_TYPE, @@ -11955,14 +11363,12 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 56, /* entry_type */ PICO_ENTRY_TYPE, @@ -11972,157 +11378,131 @@ check_flush_cache__single_entry(H5F_t * file_ptr) /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 57, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 58, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 59, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 60, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ FALSE - ); + /* expected_destroyed */ FALSE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 61, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_INVALIDATE_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 62, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_INVALIDATE_FLAG, + /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ TRUE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 63, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - if(pass) { + if (pass) { - check_flush_cache__single_entry_test - ( + check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, /* test_num */ 64, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ TRUE, /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__FLUSH_MARKED_ENTRIES_FLAG, /* expected_deserialized */ FALSE, /* expected_serialized */ FALSE, - /* expected_destroyed */ TRUE - ); + /* expected_destroyed */ TRUE); } - /* Now run single entry tests for pinned entries. Test all combinations * of: * @@ -12182,314 +11562,565 @@ check_flush_cache__single_entry(H5F_t * file_ptr) * H5C__SET_FLUSH_MARKER_FLAG apply here as well. */ - if(pass) { - - int i; - struct pinned_single_entry_test_spec - { - int test_num; - int entry_type; - int entry_idx; - hbool_t dirty_flag; - hbool_t mark_dirty; - hbool_t pop_mark_dirty_prot; - hbool_t pop_mark_dirty_pinned; - hbool_t unprotect_unpin; - unsigned int flags; - unsigned int flush_flags; - hbool_t expected_serialized; - hbool_t expected_destroyed; - } spec[256] = - /* pop pop - * ent unprot mark mark - * test entry -ry dirty mark dirty dirty unprot flush expect expect - * num type idx flag dirty prot pinned unpin flags flags srlzd destroy - */ - { { 1, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, FALSE, FALSE }, - { 2, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, FALSE, FALSE }, - { 3, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 4, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 5, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 6, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 7, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 8, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 9, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 10, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 11, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 12, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 13, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 14, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 15, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 16, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 17, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 18, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 19, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 20, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 21, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 22, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 23, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 24, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 25, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 26, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 27, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 28, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 29, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 30, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 31, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 32, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 33, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, FALSE, FALSE }, - { 34, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, FALSE, FALSE }, - { 35, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 36, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 37, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 38, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 39, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 40, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 41, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 42, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 43, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 44, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 45, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 46, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 47, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 48, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 49, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 50, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 51, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 52, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 53, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 54, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 55, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 56, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 57, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 58, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 59, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 60, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 61, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 62, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 63, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 64, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__NO_FLAGS_SET, TRUE, FALSE }, - { 65, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 66, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 67, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 68, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 69, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 70, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 71, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 72, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 73, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 74, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 75, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 76, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 77, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 78, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 79, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 80, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 81, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 82, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 83, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 84, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 85, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 86, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 87, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 88, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 89, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 90, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 91, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 92, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 93, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 94, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 95, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 96, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 97, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 98, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 99, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 100, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 101, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 102, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 103, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 104, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 105, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 106, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 107, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 108, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE }, - { 109, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 110, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 111, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 112, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 113, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 114, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 115, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 116, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 117, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 118, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 119, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 120, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 121, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 122, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 123, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 124, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 125, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 126, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 127, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 128, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE }, - { 129, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 130, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 131, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 132, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 133, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 134, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 135, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 136, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 137, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 138, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 139, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 140, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 141, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 142, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 143, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 144, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 145, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 146, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 147, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 148, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 149, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 150, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 151, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 152, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 153, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 154, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 155, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 156, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 157, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 158, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 159, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 160, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 161, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 162, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 163, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 164, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 165, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 166, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 167, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 168, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 169, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 170, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 171, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 172, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 173, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 174, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 175, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 176, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 177, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 178, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 179, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 180, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 181, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 182, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 183, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 184, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 185, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 186, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 187, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 188, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 189, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 190, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 191, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 192, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 193, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 194, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 195, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 196, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 197, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 198, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 199, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 200, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 201, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 202, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 203, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 204, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 205, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 206, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 207, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 208, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 209, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 210, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 211, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 212, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 213, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 214, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 215, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 216, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 217, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 218, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 219, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 220, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 221, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 222, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 223, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 224, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 225, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 226, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 227, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 228, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 229, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 230, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 231, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 232, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 233, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 234, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 235, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 236, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 237, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 238, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 239, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 240, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 241, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 242, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 243, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 244, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 245, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 246, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 247, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 248, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 249, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 250, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 251, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 252, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 253, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 254, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 255, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE }, - { 256, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE } }; + if (pass) { + + int i; + struct pinned_single_entry_test_spec { + int test_num; + int entry_type; + int entry_idx; + hbool_t dirty_flag; + hbool_t mark_dirty; + hbool_t pop_mark_dirty_prot; + hbool_t pop_mark_dirty_pinned; + hbool_t unprotect_unpin; + unsigned int flags; + unsigned int flush_flags; + hbool_t expected_serialized; + hbool_t expected_destroyed; + } spec[256] = + /* pop pop + * ent unprot mark mark + * test entry -ry dirty mark dirty dirty unprot flush expect expect num type + * idx flag dirty prot pinned unpin flags flags srlzd destroy + */ + {{1, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + FALSE, FALSE}, + {2, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + FALSE, FALSE}, + {3, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {4, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {5, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {6, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {7, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {8, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {9, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {10, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {11, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {12, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {13, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {14, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {15, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {16, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {17, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {18, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {19, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {20, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {21, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {22, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {23, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {24, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {25, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {26, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {27, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {28, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {29, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {30, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {31, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {32, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, H5C__NO_FLAGS_SET, + TRUE, FALSE}, + {33, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, FALSE, FALSE}, + {34, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, FALSE, FALSE}, + {35, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {36, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {37, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {38, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {39, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {40, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {41, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {42, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {43, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {44, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {45, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {46, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {47, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {48, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {49, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {50, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {51, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {52, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {53, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {54, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {55, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {56, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {57, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {58, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {59, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {60, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {61, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {62, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {63, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {64, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__NO_FLAGS_SET, TRUE, FALSE}, + {65, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {66, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {67, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {68, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {69, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {70, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {71, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {72, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {73, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {74, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {75, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {76, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {77, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {78, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {79, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {80, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {81, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {82, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {83, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {84, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {85, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {86, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {87, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {88, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {89, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {90, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {91, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {92, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {93, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {94, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {95, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {96, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {97, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {98, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {99, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {100, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {101, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {102, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {103, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {104, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {105, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {106, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {107, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {108, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, FALSE, FALSE}, + {109, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {110, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {111, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {112, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {113, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {114, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {115, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {116, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {117, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {118, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {119, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {120, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {121, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {122, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {123, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {124, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {125, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {126, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {127, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {128, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG, TRUE, FALSE}, + {129, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {130, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {131, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {132, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {133, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {134, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {135, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {136, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {137, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {138, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {139, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {140, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {141, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {142, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {143, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {144, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {145, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {146, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {147, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {148, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {149, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {150, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {151, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {152, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {153, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {154, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {155, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {156, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {157, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {158, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {159, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {160, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {161, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {162, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {163, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {164, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {165, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {166, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {167, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {168, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {169, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {170, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {171, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {172, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {173, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {174, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {175, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {176, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {177, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {178, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {179, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {180, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {181, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {182, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {183, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {184, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {185, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {186, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {187, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {188, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {189, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {190, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {191, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {192, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {193, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {194, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {195, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {196, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {197, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {198, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {199, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {200, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {201, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {202, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {203, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {204, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {205, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {206, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {207, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {208, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {209, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {210, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {211, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {212, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {213, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {214, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {215, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {216, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {217, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {218, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {219, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {220, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {221, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {222, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {223, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {224, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__NO_FLAGS_SET, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {225, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {226, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {227, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {228, PICO_ENTRY_TYPE, 0, FALSE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {229, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {230, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {231, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {232, PICO_ENTRY_TYPE, 0, FALSE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {233, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {234, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {235, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {236, PICO_ENTRY_TYPE, 0, FALSE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {237, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {238, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {239, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {240, PICO_ENTRY_TYPE, 0, FALSE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {241, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {242, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {243, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {244, PICO_ENTRY_TYPE, 0, TRUE, FALSE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {245, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {246, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {247, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {248, PICO_ENTRY_TYPE, 0, TRUE, FALSE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {249, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {250, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {251, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {252, PICO_ENTRY_TYPE, 0, TRUE, TRUE, FALSE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {253, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {254, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, FALSE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {255, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, FALSE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}, + {256, PICO_ENTRY_TYPE, 0, TRUE, TRUE, TRUE, TRUE, TRUE, H5C__SET_FLUSH_MARKER_FLAG, + H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, FALSE, FALSE}}; - i = 0; - while(pass && (i < 256)) - { - check_flush_cache__pinned_single_entry_test - ( + i = 0; + while (pass && (i < 256)) { + check_flush_cache__pinned_single_entry_test( /* file_ptr */ file_ptr, /* test_num */ spec[i].test_num, /* entry_type */ spec[i].entry_type, /* entry_idx */ spec[i].entry_idx, /* dirty_flag */ spec[i].dirty_flag, - /* mark_dirty */ spec[i].mark_dirty, + /* mark_dirty */ spec[i].mark_dirty, /* pop_mark_dirty_prot */ spec[i].pop_mark_dirty_prot, /* pop_mark_dirty_pinned */ spec[i].pop_mark_dirty_pinned, - /* unprotect_unpin */ spec[i].unprotect_unpin, + /* unprotect_unpin */ spec[i].unprotect_unpin, /* flags */ spec[i].flags, /* flush_flags */ spec[i].flush_flags, /* expected_serialized */ spec[i].expected_serialized, - /* expected_destroyed */ spec[i].expected_destroyed - ); - i++; - } + /* expected_destroyed */ spec[i].expected_destroyed); + i++; + } } return; } /* check_flush_cache__single_entry() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__single_entry_test() * @@ -12506,60 +12137,47 @@ check_flush_cache__single_entry(H5F_t * file_ptr) */ static void -check_flush_cache__single_entry_test(H5F_t * file_ptr, - int test_num, - int entry_type, - int entry_idx, - hbool_t insert_flag, - unsigned int flags, - unsigned int flush_flags, - hbool_t expected_deserialized, - hbool_t expected_serialized, +check_flush_cache__single_entry_test(H5F_t *file_ptr, int test_num, int entry_type, int entry_idx, + hbool_t insert_flag, unsigned int flags, unsigned int flush_flags, + hbool_t expected_deserialized, hbool_t expected_serialized, hbool_t expected_destroyed) { - H5C_t * cache_ptr = file_ptr->shared->cache; - static char msg[128]; - herr_t result; - test_entry_t * base_addr; - test_entry_t * entry_ptr = NULL; + H5C_t * cache_ptr = file_ptr->shared->cache; + static char msg[128]; + herr_t result; + test_entry_t *base_addr; + test_entry_t *entry_ptr = NULL; - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache_ptr NULL on entry to single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache_ptr NULL on entry to single entry test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache not empty at beginning of single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache not empty at beginning of single entry test #%d.", test_num); failure_mssg = msg; } - else if((entry_type < 0) || (entry_type >= NUMBER_OF_ENTRY_TYPES) || - (entry_idx < 0) || (entry_idx > max_indices[entry_type])) { + else if ((entry_type < 0) || (entry_type >= NUMBER_OF_ENTRY_TYPES) || (entry_idx < 0) || + (entry_idx > max_indices[entry_type])) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Bad parameters on entry to single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Bad parameters on entry to single entry test #%d.", test_num); failure_mssg = msg; } - if(pass) { + if (pass) { base_addr = entries[entry_type]; entry_ptr = &(base_addr[entry_idx]); - if(insert_flag) { + if (insert_flag) { insert_entry(file_ptr, entry_type, entry_idx, flags); - - } else { + } + else { protect_entry(file_ptr, entry_type, entry_idx); @@ -12567,21 +12185,20 @@ check_flush_cache__single_entry_test(H5F_t * file_ptr, } } - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, flush_flags); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "flush with flags 0x%x failed in single entry test #%d.", + HDsnprintf(msg, (size_t)128, "flush with flags 0x%x failed in single entry test #%d.", flush_flags, test_num); failure_mssg = msg; } - else if((entry_ptr->deserialized != expected_deserialized) || - (entry_ptr->serialized != expected_serialized) || - (entry_ptr->destroyed != expected_destroyed)) { + else if ((entry_ptr->deserialized != expected_deserialized) || + (entry_ptr->serialized != expected_serialized) || + (entry_ptr->destroyed != expected_destroyed)) { #if 0 /* This is useful debugging code -- lets keep it for a while */ HDfprintf(stdout, @@ -12594,60 +12211,41 @@ check_flush_cache__single_entry_test(H5F_t * file_ptr, (int)expected_destroyed); #endif pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected entry status after flush in single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Unexpected entry status after flush in single entry test #%d.", + test_num); failure_mssg = msg; } - else if((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) - && - ((cache_ptr->index_len != 1) - || - (cache_ptr->index_size != entry_sizes[entry_type]) - ) - ) - || - (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) - && - ((cache_ptr->index_len != 0) - || - (cache_ptr->index_size != 0) - ) - ) - ) { + else if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && + ((cache_ptr->index_len != 1) || (cache_ptr->index_size != entry_sizes[entry_type]))) || + (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && + ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after flush in single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Unexpected cache len/size after flush in single entry test #%d.", + test_num); failure_mssg = msg; } } - /* clean up the cache to prep for the next test */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Flush failed on cleanup in single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Flush failed on cleanup in single entry test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after cleanup in single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Unexpected cache len/size after cleanup in single entry test #%d.", + test_num); failure_mssg = msg; - - } else { + } + else { entry_ptr->deserialized = FALSE; entry_ptr->serialized = FALSE; @@ -12659,7 +12257,6 @@ check_flush_cache__single_entry_test(H5F_t * file_ptr, } /* check_flush_cache__single_entry_test() */ - /*------------------------------------------------------------------------- * Function: check_flush_cache__pinned_single_entry_test() * @@ -12684,96 +12281,82 @@ check_flush_cache__single_entry_test(H5F_t * file_ptr, */ static void -check_flush_cache__pinned_single_entry_test(H5F_t * file_ptr, - int test_num, - int entry_type, - int entry_idx, - hbool_t unprot_dirty_flag, - hbool_t mark_dirty, - hbool_t pop_mark_dirty_prot, - hbool_t pop_mark_dirty_pinned, - hbool_t unprotect_unpin, - unsigned int flags, - unsigned int flush_flags, - hbool_t expected_serialized, +check_flush_cache__pinned_single_entry_test(H5F_t *file_ptr, int test_num, int entry_type, int entry_idx, + hbool_t unprot_dirty_flag, hbool_t mark_dirty, + hbool_t pop_mark_dirty_prot, hbool_t pop_mark_dirty_pinned, + hbool_t unprotect_unpin, unsigned int flags, + unsigned int flush_flags, hbool_t expected_serialized, hbool_t expected_destroyed) { H5C_t * cache_ptr = file_ptr->shared->cache; - static char msg[128]; - hbool_t expected_deserialized = TRUE; - herr_t result; - test_entry_t * base_addr; - test_entry_t * entry_ptr = NULL; + static char msg[128]; + hbool_t expected_deserialized = TRUE; + herr_t result; + test_entry_t *base_addr; + test_entry_t *entry_ptr = NULL; - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache_ptr NULL on entry to pinned single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache_ptr NULL on entry to pinned single entry test #%d.", test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache not empty at beginning of pinned single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "cache not empty at beginning of pinned single entry test #%d.", + test_num); failure_mssg = msg; } - else if((entry_type < 0) || (entry_type >= NUMBER_OF_ENTRY_TYPES) || - (entry_idx < 0) || (entry_idx > max_indices[entry_type])) { + else if ((entry_type < 0) || (entry_type >= NUMBER_OF_ENTRY_TYPES) || (entry_idx < 0) || + (entry_idx > max_indices[entry_type])) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Bad parameters on entry to pinned single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Bad parameters on entry to pinned single entry test #%d.", test_num); failure_mssg = msg; } - if(pass) { + if (pass) { base_addr = entries[entry_type]; entry_ptr = &(base_addr[entry_idx]); protect_entry(file_ptr, entry_type, entry_idx); - if(pop_mark_dirty_prot) { + if (pop_mark_dirty_prot) { - mark_entry_dirty(entry_type, entry_idx); - } + mark_entry_dirty(entry_type, entry_idx); + } unprotect_entry(file_ptr, entry_type, entry_idx, - (unprot_dirty_flag ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET) | - (flags | H5C__PIN_ENTRY_FLAG)); + (unprot_dirty_flag ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET) | + (flags | H5C__PIN_ENTRY_FLAG)); - if(mark_dirty) { + if (mark_dirty) { mark_entry_dirty(entry_type, entry_idx); - } + } - if(pop_mark_dirty_pinned) { + if (pop_mark_dirty_pinned) { - mark_entry_dirty(entry_type, entry_idx); - } + mark_entry_dirty(entry_type, entry_idx); + } } - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, flush_flags); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "flush with flags 0x%x failed in pinned single entry test #%d.", - flush_flags, test_num); + HDsnprintf(msg, (size_t)128, "flush with flags 0x%x failed in pinned single entry test #%d.", + flush_flags, test_num); failure_mssg = msg; } - else if((entry_ptr->deserialized != expected_deserialized) || - (entry_ptr->serialized != expected_serialized) || - (entry_ptr->destroyed != expected_destroyed)) { + else if ((entry_ptr->deserialized != expected_deserialized) || + (entry_ptr->serialized != expected_serialized) || + (entry_ptr->destroyed != expected_destroyed)) { #if 0 /* this is useful debugging code -- keep it around */ HDfprintf(stdout, "desrlzd = %d(%d), srlzd = %d(%d), dest = %d(%d)\n", @@ -12786,76 +12369,57 @@ check_flush_cache__pinned_single_entry_test(H5F_t * file_ptr, #endif pass = FALSE; HDsnprintf(msg, (size_t)128, - "Unexpected entry status after flush in pinned single entry test #%d.", - test_num); + "Unexpected entry status after flush in pinned single entry test #%d.", test_num); failure_mssg = msg; } - else if((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) - && - ((cache_ptr->index_len != 1) - || - (cache_ptr->index_size != entry_sizes[entry_type]) - ) - ) - || - (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) - && - ((cache_ptr->index_len != 0) - || - (cache_ptr->index_size != 0) - ) - ) - ) { + else if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && + ((cache_ptr->index_len != 1) || (cache_ptr->index_size != entry_sizes[entry_type]))) || + (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && + ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after flush in pinned single entry test #%d.", - test_num); + "Unexpected cache len/size after flush in pinned single entry test #%d.", test_num); failure_mssg = msg; } } - /* clean up the cache to prep for the next test */ - if(pass) { + if (pass) { - if(unprotect_unpin) { + if (unprotect_unpin) { protect_entry(file_ptr, entry_type, entry_idx); unprotect_entry(file_ptr, entry_type, entry_idx, - (unprot_dirty_flag ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET) | - H5C__UNPIN_ENTRY_FLAG); - - } else { + (unprot_dirty_flag ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET) | + H5C__UNPIN_ENTRY_FLAG); + } + else { unpin_entry(entry_type, entry_idx); - } } - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Flush failed on cleanup in pinned single entry test #%d.", - test_num); + HDsnprintf(msg, (size_t)128, "Flush failed on cleanup in pinned single entry test #%d.", + test_num); failure_mssg = msg; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "Unexpected cache len/size after cleanup in pinned single entry test #%d.", - test_num); + "Unexpected cache len/size after cleanup in pinned single entry test #%d.", test_num); failure_mssg = msg; - - } else { + } + else { entry_ptr->deserialized = FALSE; entry_ptr->serialized = FALSE; @@ -12867,7 +12431,6 @@ check_flush_cache__pinned_single_entry_test(H5F_t * file_ptr, } /* check_flush_cache__pinned_single_entry_test() */ - /*------------------------------------------------------------------------- * Function: check_get_entry_status() * @@ -12888,59 +12451,56 @@ check_get_entry_status(unsigned paged) { static char msg[128]; herr_t result; - hbool_t in_cache; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - size_t entry_size; - H5F_t * file_ptr = NULL; - test_entry_t * base_addr = NULL; - test_entry_t * entry_ptr = NULL; + hbool_t in_cache; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + size_t entry_size; + H5F_t * file_ptr = NULL; + test_entry_t *base_addr = NULL; + test_entry_t *entry_ptr = NULL; - if(paged) + if (paged) TESTING("H5C_get_entry_status() functionality (paged aggregation)") else TESTING("H5C_get_entry_status() functionality") pass = TRUE; - if(pass) { + if (pass) { reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); - if(file_ptr == NULL) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "file_ptr NULL from setup_cache."; - } else { base_addr = entries[0]; entry_ptr = &(base_addr[0]); - } } - if(pass) { + if (pass) { /* entry not in cache -- only in_cache should be touched by * the call. Thus, only check that boolean. */ - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 1."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 1."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 1."); @@ -12948,27 +12508,25 @@ check_get_entry_status(unsigned paged) } } - if(pass) { + if (pass) { protect_entry(file_ptr, 0, 0); unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 2."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 2."); failure_mssg = msg; - - } else if(!in_cache || is_dirty || is_protected || is_pinned) { + } + else if (!in_cache || is_dirty || is_protected || is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 2."); @@ -12976,25 +12534,23 @@ check_get_entry_status(unsigned paged) } } - if(pass) { + if (pass) { protect_entry(file_ptr, 0, 0); - } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 3."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 3."); failure_mssg = msg; - - } else if(!in_cache || is_dirty || !is_protected || is_pinned) { + } + else if (!in_cache || is_dirty || !is_protected || is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 3."); @@ -13002,25 +12558,23 @@ check_get_entry_status(unsigned paged) } } - if(pass) { + if (pass) { unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); - } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 4."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 4."); failure_mssg = msg; - - } else if(!in_cache || is_dirty || is_protected || !is_pinned) { + } + else if (!in_cache || is_dirty || is_protected || !is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 4."); @@ -13028,25 +12582,23 @@ check_get_entry_status(unsigned paged) } } - if(pass) { + if (pass) { mark_entry_dirty(0, 0); - } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 5."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 5."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || !is_pinned) { + } + else if (!in_cache || !is_dirty || is_protected || !is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 5."); @@ -13054,25 +12606,23 @@ check_get_entry_status(unsigned paged) } } - if(pass) { + if (pass) { unpin_entry(0, 0); - } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 6."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 6."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || is_pinned) { + } + else if (!in_cache || !is_dirty || is_protected || is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 6."); @@ -13080,24 +12630,27 @@ check_get_entry_status(unsigned paged) } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_get_entry_status() */ - /*------------------------------------------------------------------------- * Function: check_expunge_entry() * @@ -13119,23 +12672,23 @@ check_expunge_entry(unsigned paged) { static char msg[128]; herr_t result; - hbool_t in_cache; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - size_t entry_size; + hbool_t in_cache; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + size_t entry_size; H5F_t * file_ptr = NULL; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("H5C_expunge_entry() functionality (paged aggregation)") else TESTING("H5C_expunge_entry() functionality") pass = TRUE; - if(pass) { + if (pass) { reset_entries(); @@ -13145,122 +12698,107 @@ check_expunge_entry(unsigned paged) entry_ptr = &(base_addr[0]); } - if(pass) { + if (pass) { /* entry not in cache -- only in_cache should be touched by * the status call. Thus, only check that boolean. */ - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 1."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 1."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 1."); failure_mssg = msg; - - } else if((entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); failure_mssg = msg; - - } + } } /* protect an entry to force the cache to load it, and then unprotect * it without marking it dirty. */ - if(pass) { + if (pass) { protect_entry(file_ptr, 0, 0); unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 2."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 2."); failure_mssg = msg; - - } else if(!in_cache || is_dirty || is_protected || is_pinned) { + } + else if (!in_cache || is_dirty || is_protected || is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 2."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); failure_mssg = msg; - - } + } } /* Expunge the entry and then verify that it is no longer in the cache. * Also verify that the entry was loaded and destroyed, but * not flushed. */ - if(pass) { + if (pass) { expunge_entry(file_ptr, 0, 0); - } - if(pass) { + if (pass) { /* entry shouldn't be in cache -- only in_cache should be touched - * by the status call. Thus, only check that boolean. + * by the status call. Thus, only check that boolean. */ - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 3."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 3."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 3."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); failure_mssg = msg; - - } + } } /* now repeat the process with a different entry. On unprotect @@ -13270,144 +12808,130 @@ check_expunge_entry(unsigned paged) base_addr = entries[0]; entry_ptr = &(base_addr[1]); - if(pass) { + if (pass) { /* entry not in cache -- only in_cache should be touched by * the status call. Thus, only check that boolean. */ - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 4."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 4."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 4."); failure_mssg = msg; - - } else if((entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); failure_mssg = msg; - - } + } } /* protect the entry to force the cache to load it, and then unprotect * it with the dirty flag set. */ - if(pass) { + if (pass) { protect_entry(file_ptr, 0, 1); unprotect_entry(file_ptr, 0, 1, H5C__DIRTIED_FLAG); - } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 5."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 5."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || is_pinned) { + } + else if (!in_cache || !is_dirty || is_protected || is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 5."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); failure_mssg = msg; - - } + } } /* Expunge the entry and then verify that it is no longer in the cache. * Also verify that the entry was loaded and destroyed, but not * flushed. */ - if(pass) { + if (pass) { expunge_entry(file_ptr, 0, 1); - } - if(pass) { + if (pass) { /* entry shouldn't be in cache -- only in_cache should be touched - * by the status call. Thus, only check that boolean. + * by the status call. Thus, only check that boolean. */ - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 6."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 6."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 6."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 6."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_expunge_entry() */ - /*------------------------------------------------------------------------- * Function: check_multiple_read_protect() * @@ -13428,13 +12952,13 @@ check_expunge_entry(unsigned paged) static unsigned check_multiple_read_protect(unsigned paged) { - H5F_t * file_ptr = NULL; + H5F_t *file_ptr = NULL; #if H5C_COLLECT_CACHE_STATS - H5C_t * cache_ptr = NULL; + H5C_t *cache_ptr = NULL; #endif /* H5C_COLLECT_CACHE_STATS */ - test_entry_t * entry_ptr; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("multiple read only protects on a single entry (paged aggr)") else TESTING("multiple read only protects on a single entry") @@ -13462,7 +12986,7 @@ check_multiple_read_protect(unsigned paged) * Also, verify internal state of read protects at every step. */ - if(pass) { + if (pass) { reset_entries(); @@ -13473,261 +12997,227 @@ check_multiple_read_protect(unsigned paged) entry_ptr = &((entries[0])[0]); - if((entry_ptr->header.is_protected) || - (entry_ptr->header.is_read_only) || - (entry_ptr->header.ro_ref_count != 0)) { + if ((entry_ptr->header.is_protected) || (entry_ptr->header.is_read_only) || + (entry_ptr->header.ro_ref_count != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 1.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 0) || - (cache_ptr->max_read_protects[0] != 0)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 0) || + (cache_ptr->max_read_protects[0] != 0)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 1.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 1.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { protect_entry_ro(file_ptr, 0, 0); - if((!(entry_ptr->header.is_protected)) || - (!(entry_ptr->header.is_read_only)) || - (entry_ptr->header.ro_ref_count != 1)) { + if ((!(entry_ptr->header.is_protected)) || (!(entry_ptr->header.is_read_only)) || + (entry_ptr->header.ro_ref_count != 1)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 2.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 1) || - (cache_ptr->max_read_protects[0] != 1)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 1) || + (cache_ptr->max_read_protects[0] != 1)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 2.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 2.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { protect_entry_ro(file_ptr, 0, 0); - if((!(entry_ptr->header.is_protected)) || - (!(entry_ptr->header.is_read_only)) || - (entry_ptr->header.ro_ref_count != 2)) { + if ((!(entry_ptr->header.is_protected)) || (!(entry_ptr->header.is_read_only)) || + (entry_ptr->header.ro_ref_count != 2)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 3.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 2) || - (cache_ptr->max_read_protects[0] != 2)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 2) || + (cache_ptr->max_read_protects[0] != 2)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 3.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 3.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - if((!(entry_ptr->header.is_protected)) || - (!(entry_ptr->header.is_read_only)) || - (entry_ptr->header.ro_ref_count != 1)) { + if ((!(entry_ptr->header.is_protected)) || (!(entry_ptr->header.is_read_only)) || + (entry_ptr->header.ro_ref_count != 1)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 4.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 2) || - (cache_ptr->max_read_protects[0] != 2)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 2) || + (cache_ptr->max_read_protects[0] != 2)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 4.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 4.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { protect_entry_ro(file_ptr, 0, 0); - if((!(entry_ptr->header.is_protected)) || - (!(entry_ptr->header.is_read_only)) || - (entry_ptr->header.ro_ref_count != 2)) { + if ((!(entry_ptr->header.is_protected)) || (!(entry_ptr->header.is_read_only)) || + (entry_ptr->header.ro_ref_count != 2)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 5.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 3) || - (cache_ptr->max_read_protects[0] != 2)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 3) || + (cache_ptr->max_read_protects[0] != 2)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 5.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 5.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { protect_entry_ro(file_ptr, 0, 0); - if((!(entry_ptr->header.is_protected)) || - (!(entry_ptr->header.is_read_only)) || - (entry_ptr->header.ro_ref_count != 3)) { + if ((!(entry_ptr->header.is_protected)) || (!(entry_ptr->header.is_read_only)) || + (entry_ptr->header.ro_ref_count != 3)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 6.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 4) || - (cache_ptr->max_read_protects[0] != 3)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 4) || + (cache_ptr->max_read_protects[0] != 3)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 6.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 6.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - if((!(entry_ptr->header.is_protected)) || - (!(entry_ptr->header.is_read_only)) || - (entry_ptr->header.ro_ref_count != 2)) { + if ((!(entry_ptr->header.is_protected)) || (!(entry_ptr->header.is_read_only)) || + (entry_ptr->header.ro_ref_count != 2)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 7.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 4) || - (cache_ptr->max_read_protects[0] != 3)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 4) || + (cache_ptr->max_read_protects[0] != 3)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 7.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 7.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - if((!(entry_ptr->header.is_protected)) || - (!(entry_ptr->header.is_read_only)) || - (entry_ptr->header.ro_ref_count != 1)) { + if ((!(entry_ptr->header.is_protected)) || (!(entry_ptr->header.is_read_only)) || + (entry_ptr->header.ro_ref_count != 1)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 8.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 4) || - (cache_ptr->max_read_protects[0] != 3)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 4) || + (cache_ptr->max_read_protects[0] != 3)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 8.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 8.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - if((entry_ptr->header.is_protected) || - (entry_ptr->header.is_read_only) || - (entry_ptr->header.ro_ref_count != 0)) { + if ((entry_ptr->header.is_protected) || (entry_ptr->header.is_read_only) || + (entry_ptr->header.ro_ref_count != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 9.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 0) || - (cache_ptr->read_protects[0] != 4) || - (cache_ptr->max_read_protects[0] != 3)) { + if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 4) || + (cache_ptr->max_read_protects[0] != 3)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 9.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 9.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - /* If we get this far, do a write protect and unprotect to verify * that the stats are getting collected properly here as well. */ - if(pass) - { + if (pass) { protect_entry(file_ptr, 0, 0); - if((!(entry_ptr->header.is_protected)) || - (entry_ptr->header.is_read_only) || - (entry_ptr->header.ro_ref_count != 0)) { + if ((!(entry_ptr->header.is_protected)) || (entry_ptr->header.is_read_only) || + (entry_ptr->header.ro_ref_count != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 10.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 1) || - (cache_ptr->read_protects[0] != 4) || - (cache_ptr->max_read_protects[0] != 3)) { + if ((cache_ptr->write_protects[0] != 1) || (cache_ptr->read_protects[0] != 4) || + (cache_ptr->max_read_protects[0] != 3)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 10.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 10.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) - { + if (pass) { unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - if((entry_ptr->header.is_protected) || - (entry_ptr->header.is_read_only) || - (entry_ptr->header.ro_ref_count != 0)) { + if ((entry_ptr->header.is_protected) || (entry_ptr->header.is_read_only) || + (entry_ptr->header.ro_ref_count != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected ro protected status 11.\n"; } } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 1) || - (cache_ptr->read_protects[0] != 4) || - (cache_ptr->max_read_protects[0] != 3)) { + if ((cache_ptr->write_protects[0] != 1) || (cache_ptr->read_protects[0] != 4) || + (cache_ptr->max_read_protects[0] != 3)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 11.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 11.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - /* Finally, mix things up a little, using a mix of reads and * and writes on different entries. Also include a pin to verify * that it works as well. @@ -13736,104 +13226,103 @@ check_multiple_read_protect(unsigned paged) * at the end to ensure that all is at it should be. */ - if(pass) { - - protect_entry(file_ptr, 0, 2); /* (0,2) write */ - protect_entry_ro(file_ptr, 0, 4); /* (0,4) read only (1) */ - protect_entry(file_ptr, 0, 6); /* (0,6) write */ + if (pass) { - unprotect_entry(file_ptr, 0, 2, /* (0,2) unprotect */ - H5C__NO_FLAGS_SET); + protect_entry(file_ptr, 0, 2); /* (0,2) write */ + protect_entry_ro(file_ptr, 0, 4); /* (0,4) read only (1) */ + protect_entry(file_ptr, 0, 6); /* (0,6) write */ - protect_entry_ro(file_ptr, 0, 2); /* (0,2) read only (1) */ - protect_entry(file_ptr, 0, 1); /* (0,1) write */ - protect_entry_ro(file_ptr, 0, 4); /* (0,4) read only (2) */ - protect_entry(file_ptr, 0, 0); /* (0,0) write */ - protect_entry_ro(file_ptr, 0, 2); /* (0,2) read only (2) */ + unprotect_entry(file_ptr, 0, 2, /* (0,2) unprotect */ + H5C__NO_FLAGS_SET); - unprotect_entry(file_ptr, 0, 2, /* (0,2) read only (1) pin */ - H5C__PIN_ENTRY_FLAG); - unprotect_entry(file_ptr, 0, 6, /* (0,6) unprotect */ - H5C__NO_FLAGS_SET); + protect_entry_ro(file_ptr, 0, 2); /* (0,2) read only (1) */ + protect_entry(file_ptr, 0, 1); /* (0,1) write */ + protect_entry_ro(file_ptr, 0, 4); /* (0,4) read only (2) */ + protect_entry(file_ptr, 0, 0); /* (0,0) write */ + protect_entry_ro(file_ptr, 0, 2); /* (0,2) read only (2) */ - protect_entry_ro(file_ptr, 0, 4); /* (0,4) read only (3) */ + unprotect_entry(file_ptr, 0, 2, /* (0,2) read only (1) pin */ + H5C__PIN_ENTRY_FLAG); + unprotect_entry(file_ptr, 0, 6, /* (0,6) unprotect */ + H5C__NO_FLAGS_SET); - unprotect_entry(file_ptr, 0, 2, /* (0,2) unprotect */ - H5C__NO_FLAGS_SET); - unprotect_entry(file_ptr, 0, 1, /* (0,1) unprotect */ - H5C__NO_FLAGS_SET); + protect_entry_ro(file_ptr, 0, 4); /* (0,4) read only (3) */ - if(pass) { + unprotect_entry(file_ptr, 0, 2, /* (0,2) unprotect */ + H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, 0, 1, /* (0,1) unprotect */ + H5C__NO_FLAGS_SET); - entry_ptr = &((entries[0])[4]); + if (pass) { - if(H5C_pin_protected_entry((void *)entry_ptr) < 0) { + entry_ptr = &((entries[0])[4]); - pass = FALSE; - failure_mssg = "H5C_pin_protected_entry() failed.\n"; - - } else if(!(entry_ptr->header.is_pinned)) { - - pass = FALSE; - failure_mssg = "entry (0,4) not pinned.\n"; + if (H5C_pin_protected_entry((void *)entry_ptr) < 0) { - } else { + pass = FALSE; + failure_mssg = "H5C_pin_protected_entry() failed.\n"; + } + else if (!(entry_ptr->header.is_pinned)) { - /* keep test bed sanity checks happy */ - entry_ptr->is_pinned = TRUE; + pass = FALSE; + failure_mssg = "entry (0,4) not pinned.\n"; + } + else { + /* keep test bed sanity checks happy */ + entry_ptr->is_pinned = TRUE; + } } - } - unprotect_entry(file_ptr, 0, 4, /* (0,4) read only (2) */ - H5C__NO_FLAGS_SET); - unprotect_entry(file_ptr, 0, 4, /* (0,4) read only (1) */ - H5C__UNPIN_ENTRY_FLAG); + unprotect_entry(file_ptr, 0, 4, /* (0,4) read only (2) */ + H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, 0, 4, /* (0,4) read only (1) */ + H5C__UNPIN_ENTRY_FLAG); - if(pass && (entry_ptr->header.is_pinned)) { + if (pass && (entry_ptr->header.is_pinned)) { - pass = FALSE; + pass = FALSE; failure_mssg = "enty (0,4) still pinned.\n"; + } - } - - unprotect_entry(file_ptr, 0, 4, /* (0,4) unprotect */ - H5C__NO_FLAGS_SET); - unprotect_entry(file_ptr, 0, 0, /* (0,0) unprotect */ - H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, 0, 4, /* (0,4) unprotect */ + H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, 0, 0, /* (0,0) unprotect */ + H5C__NO_FLAGS_SET); - unpin_entry(0, 2); + unpin_entry(0, 2); } #if H5C_COLLECT_CACHE_STATS - if((cache_ptr->write_protects[0] != 5) || - (cache_ptr->read_protects[0] != 9) || - (cache_ptr->max_read_protects[0] != 3)) { + if ((cache_ptr->write_protects[0] != 5) || (cache_ptr->read_protects[0] != 9) || + (cache_ptr->max_read_protects[0] != 3)) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 11.\n"; + pass = FALSE; + failure_mssg = "Unexpected protect stats 11.\n"; } #endif /* H5C_COLLECT_CACHE_STATS */ - - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_multiple_read_protect() */ - /*------------------------------------------------------------------------- * Function: check_move_entry() * @@ -13852,37 +13341,28 @@ check_multiple_read_protect(unsigned paged) static unsigned check_move_entry(unsigned paged) { - unsigned u; - H5F_t * file_ptr = NULL; - struct move_entry_test_spec test_specs[4] = - { - { - /* int entry_type = */ PICO_ENTRY_TYPE, - /* int entry_index = */ 10, - /* hbool_t is_pinned = */ FALSE, - /* hbool_t is_protected = */ FALSE - }, - { - /* int entry_type = */ PICO_ENTRY_TYPE, - /* int entry_index = */ 20, - /* hbool_t is_pinned = */ TRUE, - /* hbool_t is_protected = */ FALSE - }, - { - /* int entry_type = */ PICO_ENTRY_TYPE, - /* int entry_index = */ 30, - /* hbool_t is_pinned = */ FALSE, - /* hbool_t is_protected = */ TRUE - }, - { - /* int entry_type = */ PICO_ENTRY_TYPE, - /* int entry_index = */ 40, - /* hbool_t is_pinned = */ TRUE, - /* hbool_t is_protected = */ TRUE - }, + unsigned u; + H5F_t * file_ptr = NULL; + struct move_entry_test_spec test_specs[4] = { + {/* int entry_type = */ PICO_ENTRY_TYPE, + /* int entry_index = */ 10, + /* hbool_t is_pinned = */ FALSE, + /* hbool_t is_protected = */ FALSE}, + {/* int entry_type = */ PICO_ENTRY_TYPE, + /* int entry_index = */ 20, + /* hbool_t is_pinned = */ TRUE, + /* hbool_t is_protected = */ FALSE}, + {/* int entry_type = */ PICO_ENTRY_TYPE, + /* int entry_index = */ 30, + /* hbool_t is_pinned = */ FALSE, + /* hbool_t is_protected = */ TRUE}, + {/* int entry_type = */ PICO_ENTRY_TYPE, + /* int entry_index = */ 40, + /* hbool_t is_pinned = */ TRUE, + /* hbool_t is_protected = */ TRUE}, }; - if(paged) + if (paged) TESTING("H5C_move_entry() functionality (paged aggregation)") else TESTING("H5C_move_entry() functionality") @@ -13914,7 +13394,7 @@ check_move_entry(unsigned paged) * list. */ - if(pass) { + if (pass) { reset_entries(); @@ -13922,28 +13402,25 @@ check_move_entry(unsigned paged) } u = 0; - while(pass && (u < NELMTS(test_specs))) - { + while (pass && (u < NELMTS(test_specs))) { check_move_entry__run_test(file_ptr, u, &(test_specs[u])); - u++; + u++; } - if(pass) + if (pass) takedown_cache(file_ptr, FALSE, FALSE); - if(pass) + if (pass) PASSED(); else H5_FAILED() - if(!pass) - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); return (unsigned)!pass; } /* check_move_entry() */ - /*------------------------------------------------------------------------- * Function: check_move_entry__run_test() * @@ -13964,143 +13441,121 @@ check_move_entry(unsigned paged) */ static void -check_move_entry__run_test(H5F_t * file_ptr, - unsigned test_num, - struct move_entry_test_spec * spec_ptr) +check_move_entry__run_test(H5F_t *file_ptr, unsigned test_num, struct move_entry_test_spec *spec_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; - static char msg[128]; - unsigned int flags = H5C__NO_FLAGS_SET; - test_entry_t * base_addr; - test_entry_t * entry_ptr = NULL; - H5C_cache_entry_t * test_ptr = NULL; + H5C_t * cache_ptr = file_ptr->shared->cache; + static char msg[128]; + unsigned int flags = H5C__NO_FLAGS_SET; + test_entry_t * base_addr; + test_entry_t * entry_ptr = NULL; + H5C_cache_entry_t *test_ptr = NULL; - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache_ptr NULL on entry to move test #%u.", - test_num); + HDsnprintf(msg, (size_t)128, "cache_ptr NULL on entry to move test #%u.", test_num); failure_mssg = msg; - - } else if(spec_ptr == NULL) { + } + else if (spec_ptr == NULL) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "spec_ptr NULL on entry to move test #%u.", - test_num); + HDsnprintf(msg, (size_t)128, "spec_ptr NULL on entry to move test #%u.", test_num); failure_mssg = msg; - } - if(pass) { + if (pass) { base_addr = entries[spec_ptr->entry_type]; entry_ptr = &(base_addr[spec_ptr->entry_index]); - if((entry_ptr->self != entry_ptr) || - ((entry_ptr->cache_ptr != cache_ptr) && - (entry_ptr->cache_ptr != NULL)) || - (!(entry_ptr->at_main_addr)) || - (entry_ptr->addr != entry_ptr->main_addr)) { + if ((entry_ptr->self != entry_ptr) || + ((entry_ptr->cache_ptr != cache_ptr) && (entry_ptr->cache_ptr != NULL)) || + (!(entry_ptr->at_main_addr)) || (entry_ptr->addr != entry_ptr->main_addr)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "bad entry_ptr in move test #%u.", - test_num); + HDsnprintf(msg, (size_t)128, "bad entry_ptr in move test #%u.", test_num); failure_mssg = msg; - } } - if(pass) { + if (pass) { protect_entry(file_ptr, spec_ptr->entry_type, spec_ptr->entry_index); - if(spec_ptr->is_pinned) + if (spec_ptr->is_pinned) pin_entry(spec_ptr->entry_type, spec_ptr->entry_index); - if(!spec_ptr->is_protected) + if (!spec_ptr->is_protected) unprotect_entry(file_ptr, spec_ptr->entry_type, spec_ptr->entry_index, flags); move_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, FALSE); - } - if(pass) { + if (pass) { /* verify that the move took place, and that the cache's internal * structures are as expected. Note that some sanity checking is * done by move_entry(), so we don't have to repeat it here. */ - if(spec_ptr->is_pinned) { + if (spec_ptr->is_pinned) { - if(!(entry_ptr->header.is_pinned)) { + if (!(entry_ptr->header.is_pinned)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Pinned entry not pinned after move in test #%u.", - test_num); + HDsnprintf(msg, (size_t)128, "Pinned entry not pinned after move in test #%u.", test_num); failure_mssg = msg; } - if(pass) { + if (pass) { - if(spec_ptr->is_protected) { + if (spec_ptr->is_protected) { } /* end if */ else { /* Scan through the pinned entry list, looking for the entry */ test_ptr = cache_ptr->pel_head_ptr; - while((test_ptr != NULL) && - (test_ptr != (H5C_cache_entry_t *)entry_ptr)) + while ((test_ptr != NULL) && (test_ptr != (H5C_cache_entry_t *)entry_ptr)) test_ptr = test_ptr->next; - if(test_ptr == NULL) { + if (test_ptr == NULL) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Pinned entry not in pel after move in test #%u.", - test_num); + HDsnprintf(msg, (size_t)128, "Pinned entry not in pel after move in test #%u.", + test_num); failure_mssg = msg; } } /* end else */ } unpin_entry(spec_ptr->entry_type, spec_ptr->entry_index); + } + else { - } else { - - if(entry_ptr->header.is_pinned) { + if (entry_ptr->header.is_pinned) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unpinned entry pinned after move in test #%u.", - test_num); + HDsnprintf(msg, (size_t)128, "Unpinned entry pinned after move in test #%u.", test_num); failure_mssg = msg; } - if(spec_ptr->is_protected) { + if (spec_ptr->is_protected) { } /* end if */ else { - if((entry_ptr->header.prev != NULL) || - (cache_ptr->LRU_head_ptr != (H5C_cache_entry_t *)entry_ptr)) - { + if ((entry_ptr->header.prev != NULL) || + (cache_ptr->LRU_head_ptr != (H5C_cache_entry_t *)entry_ptr)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Entry not at head of LRU after move in test #%u.", + HDsnprintf(msg, (size_t)128, "Entry not at head of LRU after move in test #%u.", test_num); failure_mssg = msg; } } /* end else */ } - if(spec_ptr->is_protected) { - if(!(entry_ptr->header.is_protected)) { + if (spec_ptr->is_protected) { + if (!(entry_ptr->header.is_protected)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Protected entry not protected after move in test #%u.", + HDsnprintf(msg, (size_t)128, "Protected entry not protected after move in test #%u.", test_num); failure_mssg = msg; } @@ -14109,11 +13564,10 @@ check_move_entry__run_test(H5F_t * file_ptr, } /* end if */ else { - if(entry_ptr->header.is_protected) { + if (entry_ptr->header.is_protected) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unprotected entry not unprotected after move in test #%u.", + HDsnprintf(msg, (size_t)128, "Unprotected entry not unprotected after move in test #%u.", test_num); failure_mssg = msg; } @@ -14127,7 +13581,6 @@ check_move_entry__run_test(H5F_t * file_ptr, } /* check_move_entry__run_test() */ - /*------------------------------------------------------------------------- * Function: check_pin_protected_entry() * @@ -14149,10 +13602,10 @@ check_pin_protected_entry(unsigned paged) static char msg[128]; herr_t result; H5F_t * file_ptr = NULL; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("H5C_pin_protected_entry() functionality (paged aggregation)") else TESTING("H5C_pin_protected_entry() functionality") @@ -14164,72 +13617,72 @@ check_pin_protected_entry(unsigned paged) * to unpin it, and then destroy the cache. */ - if(pass) { + if (pass) { reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); - if(file_ptr == NULL) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "file_ptr NULL from setup_cache."; - } } - if(pass) { + if (pass) { protect_entry(file_ptr, 0, 0); - } - if(pass) { + if (pass) { base_addr = entries[0]; entry_ptr = &(base_addr[0]); - result = H5C_pin_protected_entry((void *)entry_ptr); + result = H5C_pin_protected_entry((void *)entry_ptr); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_pin_protected_entry() reports failure."); + HDsnprintf(msg, (size_t)128, "H5C_pin_protected_entry() reports failure."); failure_mssg = msg; - - } else if(!(entry_ptr->header.is_pinned)) { + } + else if (!(entry_ptr->header.is_pinned)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "entry not pinned when it should be."); failure_mssg = msg; + } + else { - } else { - - entry_ptr->is_pinned = TRUE; - } + entry_ptr->is_pinned = TRUE; + } } unprotect_entry(file_ptr, 0, 0, H5C__UNPIN_ENTRY_FLAG); - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_pin_protected_entry() */ - /*------------------------------------------------------------------------- * Function: check_resize_entry() * @@ -14247,20 +13700,20 @@ check_pin_protected_entry(unsigned paged) static unsigned check_resize_entry(unsigned paged) { - static char msg[128]; - herr_t result; + static char msg[128]; + herr_t result; hbool_t in_cache; hbool_t is_dirty; hbool_t is_protected; hbool_t is_pinned; - size_t entry_size; - size_t reported_entry_size; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - test_entry_t * base_addr; - test_entry_t * entry_ptr = NULL; - - if(paged) + size_t entry_size; + size_t reported_entry_size; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + test_entry_t *base_addr; + test_entry_t *entry_ptr = NULL; + + if (paged) TESTING("entry resize functionality (paged aggregation)") else TESTING("entry resize functionality") @@ -14298,460 +13751,386 @@ check_resize_entry(unsigned paged) /* tests with only one entry in the cache: */ - if(pass) { + if (pass) { reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); - if(file_ptr == NULL) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "file_ptr NULL from setup_cache."; - } - else - { + else { cache_ptr = file_ptr->shared->cache; - base_addr = entries[LARGE_ENTRY_TYPE]; - entry_ptr = &(base_addr[0]); + base_addr = entries[LARGE_ENTRY_TYPE]; + entry_ptr = &(base_addr[0]); entry_size = LARGE_ENTRY_SIZE; } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->slist_len != 0) || - (cache_ptr->slist_size != 0)) { + if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || (cache_ptr->slist_len != 0) || + (cache_ptr->slist_size != 0)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 1."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); - } - if(pass) { - - if((cache_ptr->index_len != 1) || - (cache_ptr->index_size != LARGE_ENTRY_SIZE) || - (cache_ptr->slist_len != 0) || - (cache_ptr->slist_size != 0)) { + if (pass) { + if ((cache_ptr->index_len != 1) || (cache_ptr->index_size != LARGE_ENTRY_SIZE) || + (cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 2."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 1."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 1."); failure_mssg = msg; - - } else if(!in_cache || is_dirty || !is_protected || is_pinned) { + } + else if (!in_cache || is_dirty || !is_protected || is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 1."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { result = H5C_resize_entry((void *)entry_ptr, (LARGE_ENTRY_SIZE / 2)); - if(result < 0) { + if (result < 0) { pass = FALSE; HDsnprintf(msg, (size_t)128, "error(s) in H5C_resize_entry()."); failure_mssg = msg; + } + else { - } else { - - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 1."); failure_mssg = msg; - - } else { + } + else { /* tidy up so we play nice with the standard protect / unprotect * calls. */ entry_ptr->is_protected = FALSE; - entry_ptr->is_dirty = TRUE; - entry_ptr->size = LARGE_ENTRY_SIZE / 2; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE / 2; } } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 1) || - (cache_ptr->index_size != (LARGE_ENTRY_SIZE / 2)) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 2))) { + if ((cache_ptr->index_len != 1) || (cache_ptr->index_size != (LARGE_ENTRY_SIZE / 2)) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 2))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 3."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 2."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 2."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || is_pinned || - (reported_entry_size != (LARGE_ENTRY_SIZE / 2))) { + } + else if (!in_cache || !is_dirty || is_protected || is_pinned || + (reported_entry_size != (LARGE_ENTRY_SIZE / 2))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 2."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); - } - if(pass) { + if (pass) { result = H5C_resize_entry((void *)entry_ptr, LARGE_ENTRY_SIZE); - if(result < 0) { + if (result < 0) { pass = FALSE; HDsnprintf(msg, (size_t)128, "error(s) in H5C_resize_entry()."); failure_mssg = msg; + } + else { - } else { - - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 2."); failure_mssg = msg; - - } else { + } + else { /* tidy up so we play nice with the standard protect / unprotect * calls. */ entry_ptr->is_protected = FALSE; - entry_ptr->is_dirty = TRUE; - entry_ptr->size = LARGE_ENTRY_SIZE; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE; } } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 1) || - (cache_ptr->index_size != LARGE_ENTRY_SIZE) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { + if ((cache_ptr->index_len != 1) || (cache_ptr->index_size != LARGE_ENTRY_SIZE) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 4."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 3."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 3."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || is_pinned || - (reported_entry_size != LARGE_ENTRY_SIZE)) { + } + else if (!in_cache || !is_dirty || is_protected || is_pinned || + (reported_entry_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 3."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, H5C__PIN_ENTRY_FLAG); - } - if(pass) { + if (pass) { result = H5C_resize_entry((void *)entry_ptr, (LARGE_ENTRY_SIZE / 4)); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_resize_entry() reports failure 1."); + HDsnprintf(msg, (size_t)128, "H5C_resize_entry() reports failure 1."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 1) || - (cache_ptr->index_size != (LARGE_ENTRY_SIZE / 4)) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 4))) { + if ((cache_ptr->index_len != 1) || (cache_ptr->index_size != (LARGE_ENTRY_SIZE / 4)) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 4))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 5."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 4."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 4."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || !is_pinned || - (reported_entry_size != (LARGE_ENTRY_SIZE / 4))) { + } + else if (!in_cache || !is_dirty || is_protected || !is_pinned || + (reported_entry_size != (LARGE_ENTRY_SIZE / 4))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 4."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { result = H5C_resize_entry((void *)entry_ptr, LARGE_ENTRY_SIZE); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_resize_entry() reports failure 2."); + HDsnprintf(msg, (size_t)128, "H5C_resize_entry() reports failure 2."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 1) || - (cache_ptr->index_size != LARGE_ENTRY_SIZE) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { + if ((cache_ptr->index_len != 1) || (cache_ptr->index_size != LARGE_ENTRY_SIZE) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 6."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 5."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 5."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || !is_pinned || - (reported_entry_size != LARGE_ENTRY_SIZE)) { + } + else if (!in_cache || !is_dirty || is_protected || !is_pinned || + (reported_entry_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 5."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, - H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); - + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 6."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 6."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 6."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 6."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->slist_len != 0) || - (cache_ptr->slist_size != 0)) { + if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || (cache_ptr->slist_len != 0) || + (cache_ptr->slist_size != 0)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 7."); failure_mssg = msg; - - } + } } - /* now repeat the above tests with several entries in the cache: */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->slist_len != 0) || - (cache_ptr->slist_size != 0)) { + if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || (cache_ptr->slist_len != 0) || + (cache_ptr->slist_size != 0)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 8."); failure_mssg = msg; - - } - base_addr = entries[LARGE_ENTRY_TYPE]; - entry_ptr = &(base_addr[3]); - entry_size = LARGE_ENTRY_SIZE; + } + base_addr = entries[LARGE_ENTRY_TYPE]; + entry_ptr = &(base_addr[3]); + entry_size = LARGE_ENTRY_SIZE; } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); @@ -14761,426 +14140,356 @@ check_resize_entry(unsigned paged) protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, H5C__NO_FLAGS_SET); - } - if(pass) { - - if((cache_ptr->index_len != 3) || - (cache_ptr->index_size != 3 * LARGE_ENTRY_SIZE) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { + if (pass) { + if ((cache_ptr->index_len != 3) || (cache_ptr->index_size != 3 * LARGE_ENTRY_SIZE) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 9."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); - } - if(pass) { - - if((cache_ptr->index_len != 4) || - (cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { + if (pass) { + if ((cache_ptr->index_len != 4) || (cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 10."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 7."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 7."); failure_mssg = msg; - - } else if(!in_cache || is_dirty || !is_protected || is_pinned) { + } + else if (!in_cache || is_dirty || !is_protected || is_pinned) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 7."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 7."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { result = H5C_resize_entry((void *)entry_ptr, (LARGE_ENTRY_SIZE / 2)); - if(result < 0) { + if (result < 0) { pass = FALSE; HDsnprintf(msg, (size_t)128, "error(s) in H5C_resize_entry()."); failure_mssg = msg; + } + else { - } else { - - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 3."); failure_mssg = msg; - - } else { + } + else { /* tidy up so we play nice with the standard protect / unprotect * calls. */ entry_ptr->is_protected = FALSE; - entry_ptr->is_dirty = TRUE; - entry_ptr->size = LARGE_ENTRY_SIZE / 2; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE / 2; } } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 4) || - (cache_ptr->index_size != - ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 2))) || - (cache_ptr->slist_len != 2) || - (cache_ptr->slist_size != - (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 2)))) { + if ((cache_ptr->index_len != 4) || + (cache_ptr->index_size != ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 2))) || + (cache_ptr->slist_len != 2) || + (cache_ptr->slist_size != (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 2)))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 11."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 8."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 8."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || is_pinned || - (reported_entry_size != (LARGE_ENTRY_SIZE / 2))) { + } + else if (!in_cache || !is_dirty || is_protected || is_pinned || + (reported_entry_size != (LARGE_ENTRY_SIZE / 2))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 8."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 8."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); - } - if(pass) { + if (pass) { result = H5C_resize_entry((void *)entry_ptr, LARGE_ENTRY_SIZE); - if(result < 0) { + if (result < 0) { pass = FALSE; HDsnprintf(msg, (size_t)128, "error(s) in H5C_resize_entry()."); failure_mssg = msg; + } + else { - } else { - - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); - if(result < 0) { + if (result < 0) { pass = FALSE; HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 4."); failure_mssg = msg; - - } else { + } + else { /* tidy up so we play nice with the standard protect / unprotect * calls. */ entry_ptr->is_protected = FALSE; - entry_ptr->is_dirty = TRUE; - entry_ptr->size = LARGE_ENTRY_SIZE; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE; } } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 4) || - (cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE) || - (cache_ptr->slist_len != 2) || - (cache_ptr->slist_size != 2 * LARGE_ENTRY_SIZE)) { + if ((cache_ptr->index_len != 4) || (cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE) || + (cache_ptr->slist_len != 2) || (cache_ptr->slist_size != 2 * LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 12."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 9."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 9."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || is_pinned || - (reported_entry_size != LARGE_ENTRY_SIZE)) { + } + else if (!in_cache || !is_dirty || is_protected || is_pinned || + (reported_entry_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 9."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 9."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, H5C__PIN_ENTRY_FLAG); - } - if(pass) { + if (pass) { result = H5C_resize_entry((void *)entry_ptr, (LARGE_ENTRY_SIZE / 4)); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_resize_entry() reports failure 3."); + HDsnprintf(msg, (size_t)128, "H5C_resize_entry() reports failure 3."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 4) || - (cache_ptr->index_size != - ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 4))) || - (cache_ptr->slist_len != 2) || - (cache_ptr->slist_size != - (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 4)))) { + if ((cache_ptr->index_len != 4) || + (cache_ptr->index_size != ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 4))) || + (cache_ptr->slist_len != 2) || + (cache_ptr->slist_size != (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 4)))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 13."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 10."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 10."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || !is_pinned || - (reported_entry_size != (LARGE_ENTRY_SIZE / 4))) { + } + else if (!in_cache || !is_dirty || is_protected || !is_pinned || + (reported_entry_size != (LARGE_ENTRY_SIZE / 4))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 10."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 10."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { result = H5C_resize_entry((void *)entry_ptr, LARGE_ENTRY_SIZE); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_resize_entry() reports failure 4."); + HDsnprintf(msg, (size_t)128, "H5C_resize_entry() reports failure 4."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 4) || - (cache_ptr->index_size != (4 * LARGE_ENTRY_SIZE)) || - (cache_ptr->slist_len != 2) || - (cache_ptr->slist_size != (2 * LARGE_ENTRY_SIZE))) { + if ((cache_ptr->index_len != 4) || (cache_ptr->index_size != (4 * LARGE_ENTRY_SIZE)) || + (cache_ptr->slist_len != 2) || (cache_ptr->slist_size != (2 * LARGE_ENTRY_SIZE))) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 14."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 11."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 11."); failure_mssg = msg; - - } else if(!in_cache || !is_dirty || is_protected || !is_pinned || - (reported_entry_size != LARGE_ENTRY_SIZE)) { + } + else if (!in_cache || !is_dirty || is_protected || !is_pinned || + (reported_entry_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 11."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 11."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, - H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); - + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); } - if(pass) { + if (pass) { - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, + &is_protected, &is_pinned, NULL, NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 12."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 12."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 12."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 12."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 3) || - (cache_ptr->index_size != (3 * LARGE_ENTRY_SIZE)) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { + if ((cache_ptr->index_len != 3) || (cache_ptr->index_size != (3 * LARGE_ENTRY_SIZE)) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != LARGE_ENTRY_SIZE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 15."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, H5C__DELETED_FLAG); @@ -15190,41 +14499,40 @@ check_resize_entry(unsigned paged) protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, H5C__DELETED_FLAG); - } - if(pass) { + if (pass) { - if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->slist_len != 0) || - (cache_ptr->slist_size != 0)) { + if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || (cache_ptr->slist_len != 0) || + (cache_ptr->slist_size != 0)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 16."); failure_mssg = msg; - - } + } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_resize_entry() */ - /*------------------------------------------------------------------------- * Function: check_evictions_enabled() * @@ -15245,19 +14553,19 @@ check_resize_entry(unsigned paged) static unsigned check_evictions_enabled(unsigned paged) { - static char msg[128]; - herr_t result; + static char msg[128]; + herr_t result; hbool_t show_progress = FALSE; hbool_t evictions_enabled; hbool_t in_cache; - int i; + int i; int mile_stone = 1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - test_entry_t * base_addr = NULL; - test_entry_t * entry_ptr; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + test_entry_t *base_addr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("evictions enabled/disabled functionality (paged aggregation)") else TESTING("evictions enabled/disabled functionality") @@ -15299,669 +14607,570 @@ check_evictions_enabled(unsigned paged) pass = TRUE; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* create the cache */ - if(pass) { + if (pass) { reset_entries(); file_ptr = setup_cache((size_t)(1 * 1024 * 1024), (size_t)(512 * 1024), paged); - if(file_ptr == NULL) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "file_ptr NULL from setup_cache."; - } - else - { + else { cache_ptr = file_ptr->shared->cache; base_addr = entries[MONSTER_ENTRY_TYPE]; } } - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that it is empty */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->slist_len != 0) || - (cache_ptr->slist_size != 0) || - (cache_ptr->evictions_enabled != TRUE)) { + if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || (cache_ptr->slist_len != 0) || + (cache_ptr->slist_size != 0) || (cache_ptr->evictions_enabled != TRUE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 1."); failure_mssg = msg; - - } + } } - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that H5C_get_evictions_enabled() returns the expected value */ - if(pass) { + if (pass) { result = H5C_get_evictions_enabled(cache_ptr, &evictions_enabled); - if((result != SUCCEED) || (evictions_enabled != TRUE)) { + if ((result != SUCCEED) || (evictions_enabled != TRUE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected evictions enabled 1."); failure_mssg = msg; - } + } } - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* fill the cache */ - for (i = 0; i < 16 ; i++) - { + for (i = 0; i < 16; i++) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } - } - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that the cache is full */ - if(pass) { - - if((cache_ptr->index_len != 16) || - (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 0) || - (cache_ptr->slist_size != 0) || - (cache_ptr->evictions_enabled != TRUE)) { + if (pass) { + if ((cache_ptr->index_len != 16) || (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0) || + (cache_ptr->evictions_enabled != TRUE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 2."); failure_mssg = msg; - - } + } } - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* protect and unprotect another entry */ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16, H5C__NO_FLAGS_SET); - } - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that an entry has been evicted */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 16) || - (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 0) || - (cache_ptr->slist_size != 0) || - (cache_ptr->evictions_enabled != TRUE)) { + if ((cache_ptr->index_len != 16) || (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0) || + (cache_ptr->evictions_enabled != TRUE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 3."); failure_mssg = msg; - - } + } } - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { entry_ptr = &(base_addr[0]); - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL, - NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 1."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 1."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 1."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); failure_mssg = msg; - - } + } } - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* insert an entry */ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 17, H5C__NO_FLAGS_SET); - } - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that another entry has been evicted */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 16) || - (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != MONSTER_ENTRY_SIZE) || - (cache_ptr->evictions_enabled != TRUE)) { + if ((cache_ptr->index_len != 16) || (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != MONSTER_ENTRY_SIZE) || + (cache_ptr->evictions_enabled != TRUE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 4."); failure_mssg = msg; - - } + } } - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { entry_ptr = &(base_addr[1]); - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 2."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 2."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 2."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); failure_mssg = msg; - - } + } } - if(show_progress) /* 12 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 12 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* disable evictions */ - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result != SUCCEED) { + if (result != SUCCEED) { pass = FALSE; HDsnprintf(msg, (size_t)128, "can't disable evictions 1."); failure_mssg = msg; - } + } } - if(show_progress) /* 13 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 13 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that evictions are disabled */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 16) || - (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != MONSTER_ENTRY_SIZE) || - (cache_ptr->evictions_enabled != FALSE)) { + if ((cache_ptr->index_len != 16) || (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != MONSTER_ENTRY_SIZE) || + (cache_ptr->evictions_enabled != FALSE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 5."); failure_mssg = msg; - - } + } } - if(show_progress) /* 14 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 14 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* protect and unprotect another entry */ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18, H5C__NO_FLAGS_SET); - } - if(show_progress) /* 15 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 15 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that no entry has been evicted */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 17) || - (cache_ptr->index_size != 17 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 1) || - (cache_ptr->slist_size != MONSTER_ENTRY_SIZE) || - (cache_ptr->evictions_enabled != FALSE)) { + if ((cache_ptr->index_len != 17) || (cache_ptr->index_size != 17 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 1) || (cache_ptr->slist_size != MONSTER_ENTRY_SIZE) || + (cache_ptr->evictions_enabled != FALSE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 6."); failure_mssg = msg; - - } + } } - if(show_progress) /* 16 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 16 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* insert another entry */ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, H5C__NO_FLAGS_SET); - } - if(show_progress) /* 17 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 17 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that no entry has been evicted */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 18) || - (cache_ptr->index_size != 18 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 2) || - (cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE) || - (cache_ptr->evictions_enabled != FALSE)) { + if ((cache_ptr->index_len != 18) || (cache_ptr->index_size != 18 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 2) || (cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE) || + (cache_ptr->evictions_enabled != FALSE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 7."); failure_mssg = msg; - - } + } } - if(show_progress) /* 18 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 18 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* re-enable evictions */ - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result != SUCCEED) { + if (result != SUCCEED) { pass = FALSE; HDsnprintf(msg, (size_t)128, "can't enable evictions 1."); failure_mssg = msg; - } + } } - if(show_progress) /* 19 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 19 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* protect and unprotect an entry that is in the cache */ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, H5C__NO_FLAGS_SET); - } - if(show_progress) /* 20 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 20 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that no entries have been evicted */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 18) || - (cache_ptr->index_size != 18 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 2) || - (cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE) || - (cache_ptr->evictions_enabled != TRUE)) { + if ((cache_ptr->index_len != 18) || (cache_ptr->index_size != 18 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 2) || (cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE) || + (cache_ptr->evictions_enabled != TRUE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 8."); failure_mssg = msg; - - } + } } - if(show_progress) /* 21 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 21 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* protect and unprotect an entry that isn't in the cache */ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20, H5C__NO_FLAGS_SET); - } - if(show_progress) /* 22 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 22 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that the entries have been evicted to bring the * cache back down to its normal size. */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 16) || - (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 2) || - (cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE) || - (cache_ptr->evictions_enabled != TRUE)) { + if ((cache_ptr->index_len != 16) || (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 2) || (cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE) || + (cache_ptr->evictions_enabled != TRUE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 9."); failure_mssg = msg; - - } + } } - if(show_progress) /* 23 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 23 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { entry_ptr = &(base_addr[2]); - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 3."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 3."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 3."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); failure_mssg = msg; - - } + } } - if(show_progress) /* 24 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 24 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { entry_ptr = &(base_addr[3]); - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 4."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 4."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 4."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - (entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); failure_mssg = msg; - - } + } } - if(show_progress) /* 25 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 25 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* disable evictions again */ - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result != SUCCEED) { + if (result != SUCCEED) { pass = FALSE; HDsnprintf(msg, (size_t)128, "can't disable evictions 2."); failure_mssg = msg; - } + } } - if(show_progress) /* 26 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 26 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* protect and unprotect an entry that isn't in the cache, forcing * the cache to grow. */ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21, H5C__NO_FLAGS_SET); - } - if(show_progress) /* 27 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 27 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that the cache has grown */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 17) || - (cache_ptr->index_size != 17 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 2) || - (cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE) || - (cache_ptr->evictions_enabled != FALSE)) { + if ((cache_ptr->index_len != 17) || (cache_ptr->index_size != 17 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 2) || (cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE) || + (cache_ptr->evictions_enabled != FALSE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 10."); failure_mssg = msg; - - } + } } - if(show_progress) /* 28 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 28 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* re-enable evictions again */ - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result != SUCCEED) { + if (result != SUCCEED) { pass = FALSE; HDsnprintf(msg, (size_t)128, "can't enable evictions 2."); failure_mssg = msg; - } + } } - if(show_progress) /* 29 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 29 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* insert an entry */ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 22, H5C__NO_FLAGS_SET); - } - if(show_progress) /* 30 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 30 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* verify that the cache has returned to its maximum size */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 16) || - (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || - (cache_ptr->slist_len != 3) || - (cache_ptr->slist_size != 3 * MONSTER_ENTRY_SIZE) || - (cache_ptr->evictions_enabled != TRUE)) { + if ((cache_ptr->index_len != 16) || (cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE) || + (cache_ptr->slist_len != 3) || (cache_ptr->slist_size != 3 * MONSTER_ENTRY_SIZE) || + (cache_ptr->evictions_enabled != TRUE)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected cache status 11."); failure_mssg = msg; - - } + } } - if(show_progress) /* 31 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 31 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { entry_ptr = &(base_addr[4]); - result = H5C_get_entry_status(file_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); - if(result < 0) { + if (result < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_get_entry_status() reports failure 5."); + HDsnprintf(msg, (size_t)128, "H5C_get_entry_status() reports failure 5."); failure_mssg = msg; - - } else if(in_cache) { + } + else if (in_cache) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 5."); failure_mssg = msg; - - } else if((!entry_ptr->deserialized) || - ( entry_ptr->serialized) || - (!entry_ptr->destroyed)) { + } + else if ((!entry_ptr->deserialized) || (entry_ptr->serialized) || (!entry_ptr->destroyed)) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); failure_mssg = msg; - - } + } } - if(show_progress) /* 32 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 32 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* disable evictions one last time before we shut down */ - if(pass) { + if (pass) { result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if(result != SUCCEED) { + if (result != SUCCEED) { pass = FALSE; HDsnprintf(msg, (size_t)128, "can't disable evictions 3."); failure_mssg = msg; - } + } } - if(show_progress) /* 33 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 33 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(show_progress) /* 34 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 34 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_evictions_enabled() */ - /*------------------------------------------------------------------------- * Function: check_flush_protected_err() * @@ -15981,9 +15190,9 @@ check_evictions_enabled(unsigned paged) static unsigned check_flush_protected_err(unsigned paged) { - H5F_t * file_ptr = NULL; + H5F_t *file_ptr = NULL; - if(paged) + if (paged) TESTING("flush cache with protected entry error (paged aggregation)") else TESTING("flush cache with protected entry error") @@ -15995,7 +15204,7 @@ check_flush_protected_err(unsigned paged) * succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16003,40 +15212,43 @@ check_flush_protected_err(unsigned paged) protect_entry(file_ptr, 0, 0); - if(H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET) >= 0) { + if (H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET) >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "flush succeeded on cache with protected entry.\n"; - - } else { + } + else { unprotect_entry(file_ptr, 0, 0, H5C__DIRTIED_FLAG); - if(H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET) < 0) { + if (H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "flush failed after unprotect.\n"; - - } else { + } + else { takedown_cache(file_ptr, FALSE, FALSE); } } } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_flush_protected_err() */ - /*------------------------------------------------------------------------- * Function: check_destroy_pinned_err() * @@ -16057,9 +15269,9 @@ check_flush_protected_err(unsigned paged) static unsigned check_destroy_pinned_err(unsigned paged) { - H5F_t * file_ptr = NULL; + H5F_t *file_ptr = NULL; - if(paged) + if (paged) TESTING("destroy cache with permanently pinned entry error (pgd aggr)") else TESTING("destroy cache with permanently pinned entry error") @@ -16070,57 +15282,61 @@ check_destroy_pinned_err(unsigned paged) * should fail. Unpin the entry and flush destroy again -- should * succeed. */ - if(pass) { + if (pass) { reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); protect_entry(file_ptr, 0, 0); - unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); + unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); - if(H5C_prep_for_file_close(file_ptr) < 0) { - pass = FALSE; + if (H5C_prep_for_file_close(file_ptr) < 0) { + pass = FALSE; failure_mssg = "unexpected failure of prep for file close.\n"; } /* end if */ - if(H5C_dest(file_ptr) >= 0) { - pass = FALSE; + if (H5C_dest(file_ptr) >= 0) { + pass = FALSE; failure_mssg = "destroy succeeded on cache with pinned entry.\n"; } /* end if */ - else { - unpin_entry(0, 0); + else { + unpin_entry(0, 0); - if(H5C_dest(file_ptr) < 0) { - pass = FALSE; + if (H5C_dest(file_ptr) < 0) { + pass = FALSE; failure_mssg = "destroy failed after unpin.\n"; } /* end if */ else file_ptr->shared->cache = NULL; } /* end else */ - if(saved_cache != NULL) { + if (saved_cache != NULL) { file_ptr->shared->cache = saved_cache; - saved_cache = NULL; + saved_cache = NULL; } /* end if */ - /* call takedown_cache() with a NULL file_ptr parameter. - * This causes the function to close and delete the file, - * while skipping the call to H5C_dest(). - */ - takedown_cache(NULL, FALSE, FALSE); + /* call takedown_cache() with a NULL file_ptr parameter. + * This causes the function to close and delete the file, + * while skipping the call to H5C_dest(). + */ + takedown_cache(NULL, FALSE, FALSE); } /* end if */ - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) + if (!pass) HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); return (unsigned)!pass; } /* check_destroy_pinned_err() */ - /*------------------------------------------------------------------------- * Function: check_destroy_protected_err() * @@ -16140,9 +15356,9 @@ check_destroy_pinned_err(unsigned paged) static unsigned check_destroy_protected_err(unsigned paged) { - H5F_t * file_ptr = NULL; + H5F_t *file_ptr = NULL; - if(paged) + if (paged) TESTING("destroy cache with protected entry error (paged aggregation)") else TESTING("destroy cache with protected entry error") @@ -16154,7 +15370,7 @@ check_destroy_protected_err(unsigned paged) * succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16169,50 +15385,54 @@ check_destroy_protected_err(unsigned paged) * we are trying to test, put the call to H5C_prep_for_file_close() * prior to the final protect call. */ - if(H5C_prep_for_file_close(file_ptr) < 0) { - pass = FALSE; + if (H5C_prep_for_file_close(file_ptr) < 0) { + pass = FALSE; failure_mssg = "unexpected failure of prep for file close.\n"; } /* end if */ protect_entry(file_ptr, 0, 0); - if(H5C_dest(file_ptr) >= 0) { - pass = FALSE; + if (H5C_dest(file_ptr) >= 0) { + pass = FALSE; failure_mssg = "destroy succeeded on cache with protected entry.\n"; } /* end if */ - else { + else { unprotect_entry(file_ptr, 0, 0, H5C__DIRTIED_FLAG); - if(H5C_dest(file_ptr) < 0) { - pass = FALSE; + if (H5C_dest(file_ptr) < 0) { + pass = FALSE; failure_mssg = "destroy failed after unprotect.\n"; } /* end if */ - else { + else { file_ptr->shared->cache = NULL; - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ - if(saved_cache != NULL) { + if (saved_cache != NULL) { file_ptr->shared->cache = saved_cache; - saved_cache = NULL; + saved_cache = NULL; } /* end if */ - /* call takedown_cache() with a NULL file_ptr parameter. - * This causes the function to close and delete the file, - * while skipping the call to H5C_dest(). - */ - takedown_cache(NULL, FALSE, FALSE); + /* call takedown_cache() with a NULL file_ptr parameter. + * This causes the function to close and delete the file, + * while skipping the call to H5C_dest(). + */ + takedown_cache(NULL, FALSE, FALSE); } /* end if */ - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) + if (!pass) HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); return (unsigned)!pass; } /* check_destroy_protected_err() */ - /*------------------------------------------------------------------------- * Function: check_duplicate_insert_err() * @@ -16232,12 +15452,12 @@ check_destroy_protected_err(unsigned paged) static unsigned check_duplicate_insert_err(unsigned paged) { - herr_t result = -1; - H5F_t * file_ptr = NULL; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + herr_t result = -1; + H5F_t * file_ptr = NULL; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("duplicate entry insertion error (paged aggregation)") else TESTING("duplicate entry insertion error") @@ -16249,7 +15469,7 @@ check_duplicate_insert_err(unsigned paged) * destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16257,21 +15477,20 @@ check_duplicate_insert_err(unsigned paged) protect_entry(file_ptr, 0, 0); - if(pass) { + if (pass) { base_addr = entries[0]; entry_ptr = &(base_addr[0]); - result = H5C_insert_entry(file_ptr, - types[0], entry_ptr->addr, - (void *)entry_ptr, H5C__NO_FLAGS_SET); + result = + H5C_insert_entry(file_ptr, types[0], entry_ptr->addr, (void *)entry_ptr, H5C__NO_FLAGS_SET); - if(result >= 0) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "insert of duplicate entry succeeded.\n"; - - } else { + } + else { unprotect_entry(file_ptr, 0, 0, H5C__DIRTIED_FLAG); @@ -16280,19 +15499,22 @@ check_duplicate_insert_err(unsigned paged) } } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_duplicate_insert_err() */ - /*------------------------------------------------------------------------- * Function: check_double_pin_err() * @@ -16314,11 +15536,11 @@ check_duplicate_insert_err(unsigned paged) static unsigned check_double_pin_err(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("pin a pinned entry error (paged aggregation)") else TESTING("pin a pinned entry error") @@ -16331,7 +15553,7 @@ check_double_pin_err(unsigned paged) * -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16346,41 +15568,42 @@ check_double_pin_err(unsigned paged) entry_ptr = &((entries[0])[0]); } - if(pass) { - - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__PIN_ENTRY_FLAG); + if (pass) { - if(result > 0) { + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__PIN_ENTRY_FLAG); - pass = FALSE; - failure_mssg = - "attempt to pin a pinned entry succeeded.\n"; + if (result > 0) { - } else { + pass = FALSE; + failure_mssg = "attempt to pin a pinned entry succeeded.\n"; + } + else { - unprotect_entry(file_ptr, 0, 0, H5C__UNPIN_ENTRY_FLAG); - } + unprotect_entry(file_ptr, 0, 0, H5C__UNPIN_ENTRY_FLAG); + } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_double_pin_err() */ - /*------------------------------------------------------------------------- * Function: check_double_unpin_err() * @@ -16402,11 +15625,11 @@ check_double_pin_err(unsigned paged) static unsigned check_double_unpin_err(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("unpin an unpinned entry error (paged aggregation)") else TESTING("unpin an unpinned entry error") @@ -16421,7 +15644,7 @@ check_double_unpin_err(unsigned paged) * Destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16432,54 +15655,53 @@ check_double_unpin_err(unsigned paged) entry_ptr = &((entries[0])[0]); } - if(pass) { + if (pass) { - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__UNPIN_ENTRY_FLAG); + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__UNPIN_ENTRY_FLAG); - if(result > 0) { + if (result > 0) { - pass = FALSE; - failure_mssg = - "attempt to unpin an unpinned entry succeeded 1.\n"; - - } else { + pass = FALSE; + failure_mssg = "attempt to unpin an unpinned entry succeeded 1.\n"; + } + else { - unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - } + unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); + } } - if(pass) { - - result = H5C_unpin_entry((void *)entry_ptr); + if (pass) { - if(result > 0) { + result = H5C_unpin_entry((void *)entry_ptr); - pass = FALSE; - failure_mssg = - "attempt to unpin an unpinned entry succeeded 2.\n"; + if (result > 0) { + pass = FALSE; + failure_mssg = "attempt to unpin an unpinned entry succeeded 2.\n"; } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_double_unpin_err() */ - /*------------------------------------------------------------------------- * Function: check_pin_entry_errs() * @@ -16501,11 +15723,11 @@ check_double_unpin_err(unsigned paged) static unsigned check_pin_entry_errs(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("pin entry related errors (paged aggregation)") else TESTING("pin entry related errors") @@ -16524,7 +15746,7 @@ check_pin_entry_errs(unsigned paged) * Destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16532,66 +15754,66 @@ check_pin_entry_errs(unsigned paged) protect_entry(file_ptr, 0, 0); - unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); entry_ptr = &((entries[0])[0]); } - if(pass) { + if (pass) { result = H5C_pin_protected_entry((void *)entry_ptr); - if(result > 0) { - - pass = FALSE; - failure_mssg = - "attempt to pin an unprotected entry succeeded.\n"; + if (result > 0) { - } else { + pass = FALSE; + failure_mssg = "attempt to pin an unprotected entry succeeded.\n"; + } + else { protect_entry(file_ptr, 0, 0); - unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); + unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); protect_entry(file_ptr, 0, 0); - } + } } - if(pass) { + if (pass) { result = H5C_pin_protected_entry((void *)entry_ptr); - if(result > 0) { - - pass = FALSE; - failure_mssg = - "attempt to pin a pinned, protected entry succeeded.\n"; + if (result > 0) { - } else { - - unprotect_entry(file_ptr, 0, 0, H5C__UNPIN_ENTRY_FLAG); + pass = FALSE; + failure_mssg = "attempt to pin a pinned, protected entry succeeded.\n"; + } + else { - } + unprotect_entry(file_ptr, 0, 0, H5C__UNPIN_ENTRY_FLAG); + } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_pin_entry_errs() */ - /*------------------------------------------------------------------------- * Function: check_double_protect_err() * @@ -16609,11 +15831,11 @@ check_pin_entry_errs(unsigned paged) static unsigned check_double_protect_err(unsigned paged) { - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; - H5C_cache_entry_t * cache_entry_ptr; + H5F_t * file_ptr = NULL; + test_entry_t * entry_ptr; + H5C_cache_entry_t *cache_entry_ptr; - if(paged) + if (paged) TESTING("protect a protected entry error (paged aggregation)") else TESTING("protect a protected entry error") @@ -16625,7 +15847,7 @@ check_double_protect_err(unsigned paged) * destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16636,42 +15858,44 @@ check_double_protect_err(unsigned paged) entry_ptr = &((entries[0])[0]); } - if(pass) { + if (pass) { - cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, - types[0], entry_ptr->addr, - &entry_ptr->addr, H5C__NO_FLAGS_SET); + cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, types[0], entry_ptr->addr, + &entry_ptr->addr, H5C__NO_FLAGS_SET); - if(cache_entry_ptr != NULL) { + if (cache_entry_ptr != NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "attempt to protect a protected entry succeeded.\n"; } } - if(pass) { + if (pass) { unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_double_protect_err() */ - /*------------------------------------------------------------------------- * Function: check_double_unprotect_err() * @@ -16689,11 +15913,11 @@ check_double_protect_err(unsigned paged) static unsigned check_double_unprotect_err(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("unprotect an unprotected entry error (paged aggregation)") else TESTING("unprotect an unprotected entry error") @@ -16705,7 +15929,7 @@ check_double_unprotect_err(unsigned paged) * -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16718,37 +15942,38 @@ check_double_unprotect_err(unsigned paged) entry_ptr = &((entries[0])[0]); } - if(pass) { + if (pass) { - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__NO_FLAGS_SET); + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__NO_FLAGS_SET); - if(result > 0) { + if (result > 0) { - pass = FALSE; - failure_mssg = - "attempt to unprotect an unprotected entry succeeded 1.\n"; + pass = FALSE; + failure_mssg = "attempt to unprotect an unprotected entry succeeded 1.\n"; } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_double_unprotect_err() */ - /*------------------------------------------------------------------------- * Function: check_mark_entry_dirty_errs() * @@ -16769,11 +15994,11 @@ check_double_unprotect_err(unsigned paged) static unsigned check_mark_entry_dirty_errs(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("mark entry dirty related errors (paged aggregation)") else TESTING("mark entry dirty related errors") @@ -16786,7 +16011,7 @@ check_mark_entry_dirty_errs(unsigned paged) * Destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16794,42 +16019,43 @@ check_mark_entry_dirty_errs(unsigned paged) protect_entry(file_ptr, 0, 0); - unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); entry_ptr = &((entries[0])[0]); } - if(pass) { + if (pass) { - result = H5C_mark_entry_dirty((void *)entry_ptr); + result = H5C_mark_entry_dirty((void *)entry_ptr); + if (result > 0) { - if(result > 0) { - - pass = FALSE; - failure_mssg = - "attempt to dirty a unpinned and unprotected entry succeeded.\n"; + pass = FALSE; + failure_mssg = "attempt to dirty a unpinned and unprotected entry succeeded.\n"; } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_mark_entry_dirty_errs() */ - /*------------------------------------------------------------------------- * Function: check_expunge_entry_errs() * @@ -16851,11 +16077,11 @@ check_mark_entry_dirty_errs(unsigned paged) static unsigned check_expunge_entry_errs(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("expunge entry related errors (paged aggregation)") else TESTING("expunge entry related errors") @@ -16874,7 +16100,7 @@ check_expunge_entry_errs(unsigned paged) * Destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -16883,78 +16109,70 @@ check_expunge_entry_errs(unsigned paged) entry_ptr = &((entries[0])[0]); protect_entry(file_ptr, 0, 0); - } - if(pass) { + if (pass) { - result = H5C_expunge_entry(file_ptr, - types[0], entry_ptr->addr, H5C__NO_FLAGS_SET); - - if(result > 0) { - - pass = FALSE; - failure_mssg = - "attempt to expunge a protected entry succeeded.\n"; + result = H5C_expunge_entry(file_ptr, types[0], entry_ptr->addr, H5C__NO_FLAGS_SET); - } else { + if (result > 0) { - unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); + pass = FALSE; + failure_mssg = "attempt to expunge a protected entry succeeded.\n"; + } + else { + unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); + } } - } - - if(pass) { - result = H5C_expunge_entry(file_ptr, - types[0], entry_ptr->addr, H5C__NO_FLAGS_SET); + if (pass) { - if(result > 0) { - - pass = FALSE; - failure_mssg = - "attempt to expunge a pinned entry succeeded.\n"; + result = H5C_expunge_entry(file_ptr, types[0], entry_ptr->addr, H5C__NO_FLAGS_SET); - } else { + if (result > 0) { - unpin_entry(0, 0); + pass = FALSE; + failure_mssg = "attempt to expunge a pinned entry succeeded.\n"; + } + else { - } + unpin_entry(0, 0); + } } - if(pass) { + if (pass) { - result = H5C_expunge_entry(file_ptr, - types[0], entry_ptr->addr, H5C__NO_FLAGS_SET); + result = H5C_expunge_entry(file_ptr, types[0], entry_ptr->addr, H5C__NO_FLAGS_SET); - if(result < 0) { - - pass = FALSE; - failure_mssg = - "attempt to expunge an unpinned and unprotected entry failed.\n"; + if (result < 0) { + pass = FALSE; + failure_mssg = "attempt to expunge an unpinned and unprotected entry failed.\n"; + } } - } - - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_expunge_entry_errs() */ - /*------------------------------------------------------------------------- * Function: check_move_entry_errs() * @@ -16971,15 +16189,15 @@ check_expunge_entry_errs(unsigned paged) static unsigned check_move_entry_errs(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - test_entry_t * entry_ptr = NULL; - test_entry_t * entry_0_0_ptr; - test_entry_t * entry_0_1_ptr; - test_entry_t * entry_1_0_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + test_entry_t *entry_ptr = NULL; + test_entry_t *entry_0_0_ptr; + test_entry_t *entry_0_1_ptr; + test_entry_t *entry_1_0_ptr; - if(paged) + if (paged) TESTING("move entry related errors (paged aggregation)") else TESTING("move entry related errors") @@ -16991,10 +16209,10 @@ check_move_entry_errs(unsigned paged) * fail. Destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; insert_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); @@ -17006,25 +16224,25 @@ check_move_entry_errs(unsigned paged) entry_1_0_ptr = &((entries[1])[0]); } /* end if */ - if(pass) { + if (pass) { result = H5C_move_entry(cache_ptr, types[0], entry_0_0_ptr->addr, entry_0_1_ptr->addr); - if(result >= 0) { - pass = FALSE; + if (result >= 0) { + pass = FALSE; failure_mssg = "move to addr of same type succeeded.\n"; } /* end if */ - } /* end if */ + } /* end if */ - if(pass) { + if (pass) { result = H5C_move_entry(cache_ptr, types[0], entry_0_0_ptr->addr, entry_1_0_ptr->addr); - if(result >= 0) { - pass = FALSE; + if (result >= 0) { + pass = FALSE; failure_mssg = "move to addr of different type succeeded.\n"; } /* end if */ - } /* end if */ + } /* end if */ - if(pass) + if (pass) takedown_cache(file_ptr, FALSE, FALSE); /* Allocate a cache, protect an entry R/O, and then call @@ -17034,10 +16252,10 @@ check_move_entry_errs(unsigned paged) * This should succeed. */ - if(pass) { + if (pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; insert_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); @@ -17046,21 +16264,21 @@ check_move_entry_errs(unsigned paged) entry_ptr = &((entries[0])[0]); } /* end if */ - if(pass) { - result = H5C_move_entry(cache_ptr, types[0], entry_ptr->header.addr, entry_ptr->header.addr + 10); + if (pass) { + result = H5C_move_entry(cache_ptr, types[0], entry_ptr->header.addr, entry_ptr->header.addr + 10); - if(result >= 0) { - pass = FALSE; + if (result >= 0) { + pass = FALSE; failure_mssg = "Call to H5C_move_entry on a R/O protected entry succeeded.\n"; } /* end if */ else unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); } /* end if */ - if(pass) + if (pass) takedown_cache(file_ptr, FALSE, FALSE); - if(pass) + if (pass) PASSED(); else { H5_FAILED() @@ -17071,7 +16289,6 @@ check_move_entry_errs(unsigned paged) return (unsigned)!pass; } /* check_move_entry_errs() */ - /*------------------------------------------------------------------------- * Function: check_resize_entry_errs() * @@ -17089,11 +16306,11 @@ check_move_entry_errs(unsigned paged) static unsigned check_resize_entry_errs(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("resize entry related errors (paged aggregation)") else TESTING("resize entry related errors") @@ -17111,7 +16328,7 @@ check_resize_entry_errs(unsigned paged) * This should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -17120,61 +16337,59 @@ check_resize_entry_errs(unsigned paged) entry_ptr = &((entries[0])[0]); protect_entry(file_ptr, 0, 0); - } - if(pass) { - - result = H5C_resize_entry((void *)entry_ptr, (size_t)1); + if (pass) { - if(result < 0) { + result = H5C_resize_entry((void *)entry_ptr, (size_t)1); - pass = FALSE; - failure_mssg = - "Call to H5C_resize_entry on a protected entry failed.\n"; + if (result < 0) { - } else { - - unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); + pass = FALSE; + failure_mssg = "Call to H5C_resize_entry on a protected entry failed.\n"; + } + else { - } + unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); + } } - if(pass) { + if (pass) { - result = H5C_resize_entry((void *)entry_ptr, (size_t)0); - - if(result >= 0) { - - pass = FALSE; - failure_mssg = - "Call to H5C_resize_entry with 0 new size succeeded.\n"; + result = H5C_resize_entry((void *)entry_ptr, (size_t)0); - } else { + if (result >= 0) { - unpin_entry(0, 0); + pass = FALSE; + failure_mssg = "Call to H5C_resize_entry with 0 new size succeeded.\n"; + } + else { - } + unpin_entry(0, 0); + } } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_resize_entry_errs() */ - /*------------------------------------------------------------------------- * Function: check_unprotect_ro_dirty_err() * @@ -17192,11 +16407,11 @@ check_resize_entry_errs(unsigned paged) static unsigned check_unprotect_ro_dirty_err(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; + herr_t result; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; - if(paged) + if (paged) TESTING("unprotect a read only entry dirty error (paged aggregation)") else TESTING("unprotect a read only entry dirty error") @@ -17208,7 +16423,7 @@ check_unprotect_ro_dirty_err(unsigned paged) * -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -17219,26 +16434,23 @@ check_unprotect_ro_dirty_err(unsigned paged) entry_ptr = &((entries[0])[0]); } - if(pass) { + if (pass) { - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); - if(result >= 0) { + if (result >= 0) { - pass = FALSE; - failure_mssg = - "attempt to unprotect a ro entry dirty succeeded 1.\n"; + pass = FALSE; + failure_mssg = "attempt to unprotect a ro entry dirty succeeded 1.\n"; } } - if(pass) { - - unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); + if (pass) { + unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } @@ -17249,7 +16461,7 @@ check_unprotect_ro_dirty_err(unsigned paged) * This should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -17261,44 +16473,44 @@ check_unprotect_ro_dirty_err(unsigned paged) entry_ptr = &((entries[0])[0]); } - if(pass) { + if (pass) { - result = H5C_unprotect(file_ptr, - entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); + result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, H5C__DIRTIED_FLAG); - if(result > 0) { + if (result > 0) { - pass = FALSE; - failure_mssg = - "attempt to unprotect a ro entry dirty succeeded 2.\n"; + pass = FALSE; + failure_mssg = "attempt to unprotect a ro entry dirty succeeded 2.\n"; } } - if(pass) { - - unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); - unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); + if (pass) { + unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_unprotect_ro_dirty_err() */ - /*------------------------------------------------------------------------- * Function: check_protect_ro_rw_err() * @@ -17320,11 +16532,11 @@ check_unprotect_ro_dirty_err(unsigned paged) static unsigned check_protect_ro_rw_err(unsigned paged) { - H5F_t * file_ptr = NULL; - test_entry_t * entry_ptr; - void * thing_ptr = NULL; + H5F_t * file_ptr = NULL; + test_entry_t *entry_ptr; + void * thing_ptr = NULL; - if(paged) + if (paged) TESTING("protect a read only entry rw error (paged aggregation)") else TESTING("protect a read only entry rw error") @@ -17337,7 +16549,7 @@ check_protect_ro_rw_err(unsigned paged) * Unprotect the entry and destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); @@ -17348,42 +16560,44 @@ check_protect_ro_rw_err(unsigned paged) entry_ptr = &((entries[0])[0]); } - if(pass) { + if (pass) { - thing_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, - types[0], entry_ptr->addr, - &entry_ptr->addr, H5C__NO_FLAGS_SET); + thing_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, types[0], entry_ptr->addr, &entry_ptr->addr, + H5C__NO_FLAGS_SET); - if(thing_ptr != NULL) { + if (thing_ptr != NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "attempt to protect a ro entry rw succeeded.\n"; } } - if(pass) { + if (pass) { - unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); } - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_protect_ro_rw_err() */ - /*------------------------------------------------------------------------- * Function: check_protect_retries() * @@ -17399,15 +16613,15 @@ check_protect_ro_rw_err(unsigned paged) static unsigned check_protect_retries(unsigned paged) { - H5F_t * file_ptr = NULL; - H5C_t *cache_ptr = NULL; - test_entry_t *base_addr = NULL; - test_entry_t *entry_ptr = NULL; - H5C_cache_entry_t * cache_entry_ptr = NULL; - int32_t type; - int32_t idx; - - if(paged) + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr = NULL; + test_entry_t * entry_ptr = NULL; + H5C_cache_entry_t *cache_entry_ptr = NULL; + int32_t type; + int32_t idx; + + if (paged) TESTING("protect an entry to verify retries (paged aggregation)") else TESTING("protect an entry to verify retries") @@ -17415,58 +16629,54 @@ check_protect_retries(unsigned paged) pass = TRUE; /* Set up the cache */ - if(pass) { + if (pass) { reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); - /* Set up read attempts for verifying checksum */ - file_ptr->shared->read_attempts = 10; + /* Set up read attempts for verifying checksum */ + file_ptr->shared->read_attempts = 10; file_ptr->shared->retries_nbins = 1; } /* Test only for this type which has a speculative load */ type = VARIABLE_ENTRY_TYPE; - idx = 0; + idx = 0; - if(pass) { + if (pass) { - cache_ptr = file_ptr->shared->cache; - base_addr = entries[type]; + cache_ptr = file_ptr->shared->cache; + base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - /* test case (1): - * --actual_len is smaller the initial length from get_load_size() - * --verify_chksum() returns TRUE after max_verify_ct is reached - * - */ - entry_ptr->actual_len = entry_ptr->size/2; + /* test case (1): + * --actual_len is smaller the initial length from get_load_size() + * --verify_chksum() returns TRUE after max_verify_ct is reached + * + */ + entry_ptr->actual_len = entry_ptr->size / 2; entry_ptr->max_verify_ct = 3; - entry_ptr->verify_ct = 0; + entry_ptr->verify_ct = 0; - cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, - types[type], entry_ptr->addr, &entry_ptr->addr, H5C__READ_ONLY_FLAG); + cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, types[type], entry_ptr->addr, + &entry_ptr->addr, H5C__READ_ONLY_FLAG); - if((cache_entry_ptr != (void *)entry_ptr) || - (!(entry_ptr->header.is_protected)) || - (!(entry_ptr->header.is_read_only)) || - (entry_ptr->header.ro_ref_count <= 0) || - (entry_ptr->header.type != types[type]) || - (entry_ptr->size != entry_ptr->header.size) || - (entry_ptr->addr != entry_ptr->header.addr) || - (entry_ptr->verify_ct != entry_ptr->max_verify_ct)) { + if ((cache_entry_ptr != (void *)entry_ptr) || (!(entry_ptr->header.is_protected)) || + (!(entry_ptr->header.is_read_only)) || (entry_ptr->header.ro_ref_count <= 0) || + (entry_ptr->header.type != types[type]) || (entry_ptr->size != entry_ptr->header.size) || + (entry_ptr->addr != entry_ptr->header.addr) || + (entry_ptr->verify_ct != entry_ptr->max_verify_ct)) { - pass = FALSE; + pass = FALSE; failure_mssg = "error from H5C_protect()."; + } + else { - } else { - - HDassert((entry_ptr->cache_ptr == NULL) || - (entry_ptr->cache_ptr == cache_ptr)); + HDassert((entry_ptr->cache_ptr == NULL) || (entry_ptr->cache_ptr == cache_ptr)); - entry_ptr->cache_ptr = cache_ptr; - entry_ptr->file_ptr = file_ptr; + entry_ptr->cache_ptr = cache_ptr; + entry_ptr->file_ptr = file_ptr; entry_ptr->is_protected = TRUE; entry_ptr->is_read_only = TRUE; entry_ptr->ro_ref_count++; @@ -17475,46 +16685,48 @@ check_protect_retries(unsigned paged) HDassert(((entry_ptr->header).type)->id == type); } - if(pass) - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, idx, H5C__NO_FLAGS_SET); + if (pass) + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, idx, H5C__NO_FLAGS_SET); - if(pass) { + if (pass) { entry_ptr = &(base_addr[++idx]); - /* test case (2): - * --actual_len is greater the initial length from get_load_size() - * --verify_chksum() returns FALSE even after all tries is reached - * (file_ptr->shared->read_attempts is smaller then max_verify_ct) - */ - entry_ptr->actual_len = entry_ptr->size*2; + /* test case (2): + * --actual_len is greater the initial length from get_load_size() + * --verify_chksum() returns FALSE even after all tries is reached + * (file_ptr->shared->read_attempts is smaller then max_verify_ct) + */ + entry_ptr->actual_len = entry_ptr->size * 2; entry_ptr->max_verify_ct = 11; - entry_ptr->verify_ct = 0; + entry_ptr->verify_ct = 0; - cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, - types[type], entry_ptr->addr, &entry_ptr->addr, H5C__READ_ONLY_FLAG); + cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, types[type], entry_ptr->addr, + &entry_ptr->addr, H5C__READ_ONLY_FLAG); - /* H5C_protect() should fail after all retries fail */ - if(cache_entry_ptr != NULL) - pass = FALSE; + /* H5C_protect() should fail after all retries fail */ + if (cache_entry_ptr != NULL) + pass = FALSE; } - takedown_cache(file_ptr, FALSE, FALSE); reset_entries(); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_msg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_msg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_protect_retries() */ - /*------------------------------------------------------------------------- * Function: check_evictions_enabled_err() * @@ -17536,12 +16748,12 @@ check_protect_retries(unsigned paged) static unsigned check_check_evictions_enabled_err(unsigned paged) { - herr_t result; + herr_t result; hbool_t evictions_enabled; - H5F_t * file_ptr = NULL; + H5F_t * file_ptr = NULL; H5C_t * cache_ptr = NULL; - if(paged) + if (paged) TESTING("get/set evictions enabled errors (paged aggregation)") else TESTING("get/set evictions enabled errors") @@ -17561,100 +16773,100 @@ check_check_evictions_enabled_err(unsigned paged) * Unprotect the entry and destroy the cache -- should succeed. */ - if(pass) { + if (pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } - if(pass) { + if (pass) { - result = H5C_get_evictions_enabled(NULL, &evictions_enabled); + result = H5C_get_evictions_enabled(NULL, &evictions_enabled); - if(result == SUCCEED) { + if (result == SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_evictions_enabled succeeded() 1.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_evictions_enabled(cache_ptr, NULL); + result = H5C_get_evictions_enabled(cache_ptr, NULL); - if(result == SUCCEED) { + if (result == SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_evictions_enabled succeeded() 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_set_evictions_enabled(cache_ptr, TRUE); + result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_evictions_enabled failed().\n"; - - } + } } - if(pass) { + if (pass) { (cache_ptr->resize_ctl).incr_mode = H5C_incr__threshold; - result = H5C_get_evictions_enabled(cache_ptr, FALSE); + result = H5C_get_evictions_enabled(cache_ptr, FALSE); - if(result == SUCCEED) { + if (result == SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_evictions_enabled succeeded() 1.\n"; - - } else if(cache_ptr->evictions_enabled == TRUE) { - - } + } + else if (cache_ptr->evictions_enabled == TRUE) { + } (cache_ptr->resize_ctl).incr_mode = H5C_incr__off; } - if(pass) { + if (pass) { (cache_ptr->resize_ctl).decr_mode = H5C_decr__threshold; - result = H5C_get_evictions_enabled(cache_ptr, FALSE); + result = H5C_get_evictions_enabled(cache_ptr, FALSE); - if(result == SUCCEED) { + if (result == SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_evictions_enabled succeeded() 2.\n"; } (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; } - - if(cache_ptr) { + if (cache_ptr) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_evictions_enabled_err() */ - /*------------------------------------------------------------------------- * Function: check_auto_cache_resize() * @@ -17671,33 +16883,29 @@ check_check_evictions_enabled_err(unsigned paged) *------------------------------------------------------------------------- */ -hbool_t rpt_fcn_called = FALSE; +hbool_t rpt_fcn_called = FALSE; enum H5C_resize_status rpt_status; -static void test_rpt_fcn(H5_ATTR_UNUSED H5C_t * cache_ptr, - H5_ATTR_UNUSED int32_t version, - H5_ATTR_UNUSED double hit_rate, - enum H5C_resize_status status, - H5_ATTR_UNUSED size_t old_max_cache_size, - H5_ATTR_UNUSED size_t new_max_cache_size, - H5_ATTR_UNUSED size_t old_min_clean_size, - H5_ATTR_UNUSED size_t new_min_clean_size) +static void +test_rpt_fcn(H5_ATTR_UNUSED H5C_t *cache_ptr, H5_ATTR_UNUSED int32_t version, H5_ATTR_UNUSED double hit_rate, + enum H5C_resize_status status, H5_ATTR_UNUSED size_t old_max_cache_size, + H5_ATTR_UNUSED size_t new_max_cache_size, H5_ATTR_UNUSED size_t old_min_clean_size, + H5_ATTR_UNUSED size_t new_min_clean_size) { rpt_fcn_called = TRUE; - rpt_status = status; + rpt_status = status; } static unsigned check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) { - hbool_t show_progress = FALSE; - herr_t result; - int32_t i; - int32_t checkpoint = 0; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_auto_size_ctl_t auto_size_ctl = - { + hbool_t show_progress = FALSE; + herr_t result; + int32_t i; + int32_t checkpoint = 0; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_auto_size_ctl_t auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* H5C_auto_resize_report_fcn rpt_fcn = */ test_rpt_fcn, @@ -17711,7 +16919,6 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) /* int64_t epoch_length = */ 1000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -17722,10 +16929,9 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, @@ -17739,839 +16945,805 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) /* int32_t epochs_before_eviction = */ 3, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f - }; + /* double empty_reserve = */ 0.05f}; - if(paged) + if (paged) TESTING("automatic cache resizing (paged aggregation)") else TESTING("automatic cache resizing") pass = TRUE; - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* allocate a cache, enable automatic cache resizing, and then force * the cache through all its operational modes. Verify that all * performs as expected. */ - if(pass) { + if (pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(pass) { - if((cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024))) { + if (pass) { + if ((cache_ptr->max_cache_size != (512 * 1024)) || (cache_ptr->min_clean_size != (256 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after initialization.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache not full -- should result in not * full status. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, PICO_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, PICO_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != not_full) || - (cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != not_full) || (cache_ptr->max_cache_size != (512 * 1024)) || + (cache_ptr->min_clean_size != (256 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 1.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full -- should result in increase * of cache size from .5 to 1 meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (1 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (1 * 1024 * 1024)) || (cache_ptr->min_clean_size != (512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 2.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache not full -- should result in not * full status. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, PICO_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, PICO_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != not_full) || - (cache_ptr->max_cache_size != (1 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != not_full) || + (cache_ptr->max_cache_size != (1 * 1024 * 1024)) || (cache_ptr->min_clean_size != (512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 3.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full again -- should result in increase * of cache size from 1 to 2 meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 4.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full again -- should result in increase * of cache size from 2 to 4 meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 5.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full again -- should result in increase * of cache size from 4 to 8 meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 6.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full again -- should result in increase * of cache size from 8 to 12 meg. Note that max increase reduced the * size of the increase. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (12 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (6 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (12 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (6 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 7.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full again -- should result in increase * of cache size from 12 to 14 meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (14 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (7 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (14 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (7 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 8.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full and at maximum size -- should * in no change in size and a result of at_max_size. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (14 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (7 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (14 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (7 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 9.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate with cache full and at maximum size -- should * result in a decrease from 14 to 13 Meg -- note that max decrease * reduced the size of the reduction */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (13 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (6 * 1024 * 1024 + 512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (13 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (6 * 1024 * 1024 + 512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 10.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* the current cache configuration is inconvenient for testing cache * size reduction, so lets change it some something easier to work * with. */ - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1000 * 1000 + 10; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1000 * 1000 + 10; - auto_size_ctl.min_clean_fraction = 0.1f; + auto_size_ctl.min_clean_fraction = 0.1f; - auto_size_ctl.max_size = 8 * 1000 * 1000; - auto_size_ctl.min_size = 500 * 1000; + auto_size_ctl.max_size = 8 * 1000 * 1000; + auto_size_ctl.min_size = 500 * 1000; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1000 * 1000); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1000 * 1000); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1000 * 1000); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1000 * 1000); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 2.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1000 * 1000 + 10)) || - (cache_ptr->min_clean_size != (400 * 1000 + 1))) { + if ((cache_ptr->max_cache_size != (4 * 1000 * 1000 + 10)) || + (cache_ptr->min_clean_size != (400 * 1000 + 1))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 1.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should result in a decrease from ~4 to ~3 * M -- note that max decrease reduces the size of the reduction */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (3 * 1000 * 1000 + 10)) || - (cache_ptr->min_clean_size != (300 * 1000 + 1))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (3 * 1000 * 1000 + 10)) || + (cache_ptr->min_clean_size != (300 * 1000 + 1))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 11.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate again -- should result in a decrease from ~3 * to ~2 M -- again note that max decrease reduces the size of the * reduction. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2 * 1000 * 1000 + 10)) || - (cache_ptr->min_clean_size != (200 * 1000 + 1))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (2 * 1000 * 1000 + 10)) || + (cache_ptr->min_clean_size != (200 * 1000 + 1))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 12.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate again -- should result in a decrease from ~2 * to ~1 M -- again note that max decrease reduces the size of the * reduction, but only by five bites. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (1 * 1000 * 1000 + 10)) || - (cache_ptr->min_clean_size != (100 * 1000 + 1))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (1 * 1000 * 1000 + 10)) || + (cache_ptr->min_clean_size != (100 * 1000 + 1))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 13.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate again -- should result in a decrease from ~1 * to ~0.5 M -- max decrease is no longer a factor. New size is five * bytes above the minimum. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (500 * 1000 + 5)) || - (cache_ptr->min_clean_size != (50 * 1000))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (500 * 1000 + 5)) || (cache_ptr->min_clean_size != (50 * 1000))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 14.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate again -- should result in a decrease of five * bytes to the minimum cache size. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (500 * 1000)) || - (cache_ptr->min_clean_size != (50 * 1000))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (500 * 1000)) || + (cache_ptr->min_clean_size != (50 * 1000))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 15.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate again -- Already at minimum size so no change in * cache size and result should be at_min_size. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_min_size) || - (cache_ptr->max_cache_size != (500 * 1000)) || - (cache_ptr->min_clean_size != (50 * 1000))) { + if ((!rpt_fcn_called) || (rpt_status != at_min_size) || (cache_ptr->max_cache_size != (500 * 1000)) || + (cache_ptr->min_clean_size != (50 * 1000))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 16.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force in range hit rate -- should be no change in cache size, * and result should be in_spec. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 900)) - { + i = 0; + while (pass && (i < 900)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - while(pass && (i < 1000)) - { + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i + 1000); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i + 1000, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (500 * 1000)) || - (cache_ptr->min_clean_size != (50 * 1000))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (500 * 1000)) || + (cache_ptr->min_clean_size != (50 * 1000))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 17.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full -- should * increase cache size from .5 to 1 M. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (1 * 1000 * 1000)) || - (cache_ptr->min_clean_size != (100 * 1000))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (1 * 1000 * 1000)) || (cache_ptr->min_clean_size != (100 * 1000))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 18.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should result in a decrease to the * minimum cache size. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (500 * 1000)) || + (cache_ptr->min_clean_size != (50 * 1000))) { - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (500 * 1000)) || - (cache_ptr->min_clean_size != (50 * 1000))) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 19.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /****************************************************************** * now do some tests with the maximum increase and decrease sizes * disabled. ******************************************************************/ - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 4.0f; - auto_size_ctl.increment = 4.0f; + auto_size_ctl.apply_max_increment = FALSE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.apply_max_increment = FALSE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.25f; - auto_size_ctl.decrement = 0.25f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 3.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 2.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should result in a decrease to the * minimum cache size. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (1 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (1 * 1024 * 1024)) || (cache_ptr->min_clean_size != (512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 20.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full -- should increase cache size * from 1 to 4 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 21.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate again with cache full -- should increase cache * size from 4 to 16 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (16 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (8 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (16 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (8 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 22.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should result in a decrease cache size from * 16 to 4 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 23.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /****************************************************************** * We have tested the threshold increment and decrement modes. @@ -18580,72 +17752,70 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) * Reconfigure the cache for this testing. ******************************************************************/ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__age_out; - auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = FALSE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = FALSE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 4.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 3.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(cork_ageout) - cork_entry_type(file_ptr, MEDIUM_ENTRY_TYPE); + if (cork_ageout) + cork_entry_type(file_ptr, MEDIUM_ENTRY_TYPE); /* fill the cache with 1024 byte entries -- nothing should happen * for three epochs while the markers are inserted into the cache @@ -18654,380 +17824,365 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) * increase its size. Since we are already at max size, it will * not be able to. */ - if(pass) { /* first epoch */ + if (pass) { /* first epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 24.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* second epoch */ + if (pass) { /* second epoch */ rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 25.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* third epoch */ + if (pass) { /* third epoch */ rpt_fcn_called = FALSE; - i = 2000; - while(pass && (i < 3000)) { + i = 2000; + while (pass && (i < 3000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 26.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fourth epoch -- If the hit rate were above the lower threshold, * we would see cache size reduction now. However, nothing will * happen until we get the hit rate above the lower threshold. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 27.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fifth epoch -- force the hit rate to 100%. We should see cache size * reduction now. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2001 * 1024)) || - (cache_ptr->min_clean_size != (int)(2001 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (2001 * 1024)) || + (cache_ptr->min_clean_size != (int)(2001 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 28.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* sixth epoch -- force the hit rate to 100% again. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (1001 * 1024)) || - (cache_ptr->min_clean_size != (int)(1001 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (1001 * 1024)) || + (cache_ptr->min_clean_size != (int)(1001 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 29.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* seventh epoch -- force the hit rate to 100% again. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (1000 * 1024)) || - (cache_ptr->min_clean_size != (int)(1000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (1000 * 1024)) || + (cache_ptr->min_clean_size != (int)(1000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 30.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* eigth epoch -- force the hit rate to 100% again -- should be steady * state. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (1000 * 1024)) || - (cache_ptr->min_clean_size != (int)(1000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (1000 * 1024)) || + (cache_ptr->min_clean_size != (int)(1000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 31.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* now just bang on one entry -- after three epochs, this should * get all entries other than the one evicted, and the cache size * should be decreased to the minimum. */ - if(pass) { /* ninth epoch */ + if (pass) { /* ninth epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (1000 * 1024)) || - (cache_ptr->min_clean_size != (int)(1000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (1000 * 1024)) || + (cache_ptr->min_clean_size != (int)(1000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 32.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* tenth epoch */ + if (pass) { /* tenth epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (1000 * 1024)) || - (cache_ptr->min_clean_size != (int)(1000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (1000 * 1024)) || + (cache_ptr->min_clean_size != (int)(1000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 33.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* eleventh epoch -- cache size reduction */ + if (pass) { /* eleventh epoch -- cache size reduction */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != - MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (512 * 1024)) || + (cache_ptr->min_clean_size != (256 * 1024)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 34.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* twelth epoch -- at minimum size so no more ageouts */ + if (pass) { /* twelth epoch -- at minimum size so no more ageouts */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_min_size) || - (cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != - MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { + if ((!rpt_fcn_called) || (rpt_status != at_min_size) || (cache_ptr->max_cache_size != (512 * 1024)) || + (cache_ptr->min_clean_size != (256 * 1024)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 35.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - - if(cork_ageout) - uncork_entry_type(file_ptr, MEDIUM_ENTRY_TYPE); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); + if (cork_ageout) + uncork_entry_type(file_ptr, MEDIUM_ENTRY_TYPE); /* repeat the above test, but with max_decrement enabled to see * if that features works as it should. Note that this will change * the structure of the test a bit. */ - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.upper_hr_threshold = 0.995f; - - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = FALSE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = FALSE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 5.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 4.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fill the cache with 1024 byte entries -- nothing should happen * for three epochs while the markers are inserted into the cache @@ -19036,510 +18191,480 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) * increase its size. Since we are already at max size, it will * not be able to. */ - if(pass) { /* first epoch */ + if (pass) { /* first epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 36.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* second epoch */ + if (pass) { /* second epoch */ rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) - { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 37.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* third epoch */ + if (pass) { /* third epoch */ rpt_fcn_called = FALSE; - i = 2000; - while(pass && (i < 3000)) - { + i = 2000; + while (pass && (i < 3000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 38.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fourth epoch -- If the hit rate were above the lower threshold, * we would see cache size reduction now. However, nothing will * happen until we get the hit rate above the lower threshold. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 39.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fifth epoch -- force the hit rate to 100%. We should see cache size * reduction now. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (7 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (7 * 512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (7 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (7 * 512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 40.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* sixth epoch -- force the hit rate to 100% again. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 2000; - while(pass && (i < 3000)) - { + i = 2000; + while (pass && (i < 3000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (6 * 512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (6 * 512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 41.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* seventh epoch -- keep hit rate at 100%, and keep 2K entries active. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (5 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (5 * 512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (5 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (5 * 512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 42.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* eigth epoch -- still 100% hit rate */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 2000; - while(pass && (i < 3000)) - { + i = 2000; + while (pass && (i < 3000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 43.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* ninth epoch --hit rate at 100%. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (3 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (3 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 44.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* tenth epoch -- still 100% hit rate */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 2000; - while(pass && (i < 3000)) - { + i = 2000; + while (pass && (i < 3000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 512 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 45.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* eleventh epoch -- hit rate at 100% -- starting to stableize */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2000 * 1024)) || - (cache_ptr->min_clean_size != (int)(2000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (2000 * 1024)) || + (cache_ptr->min_clean_size != (int)(2000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 46.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* twelth epoch -- force the hit rate to 100% again -- should be steady * state. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 2000; - while(pass && (i < 3000)) - { + i = 2000; + while (pass && (i < 3000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (2000 * 1024)) || - (cache_ptr->min_clean_size != (int)(2000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (2000 * 1024)) || + (cache_ptr->min_clean_size != (int)(2000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 47.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* now just bang on one entry -- after three epochs, this should * get all entries other than the one evicted, and the cache size * should be decreased to the minimum. */ - if(pass) { /* thirteenth epoch */ + if (pass) { /* thirteenth epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (2000 * 1024)) || - (cache_ptr->min_clean_size != (int)(2000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (2000 * 1024)) || + (cache_ptr->min_clean_size != (int)(2000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 48.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* fourteenth epoch */ + if (pass) { /* fourteenth epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != - (1001 * 1024 + MONSTER_ENTRY_SIZE)) || - (cache_ptr->min_clean_size != - (1001 * 512 + MONSTER_ENTRY_SIZE / 2))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (1001 * 1024 + MONSTER_ENTRY_SIZE)) || + (cache_ptr->min_clean_size != (1001 * 512 + MONSTER_ENTRY_SIZE / 2))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 49.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* fifteenth epoch -- cache size reduction */ + if (pass) { /* fifteenth epoch -- cache size reduction */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != - MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (512 * 1024)) || + (cache_ptr->min_clean_size != (256 * 1024)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 50.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* sixteenth epoch -- at minimum size so no more ageouts */ + if (pass) { /* sixteenth epoch -- at minimum size so no more ageouts */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_min_size) || - (cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != - MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { + if ((!rpt_fcn_called) || (rpt_status != at_min_size) || (cache_ptr->max_cache_size != (512 * 1024)) || + (cache_ptr->min_clean_size != (256 * 1024)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 51.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* repeat the test yet again, this time with empty reserve enabled. * Again, some structural changes in the test are necessary. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__age_out; - auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.5f; /* for ease of testing */ + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.5f; /* for ease of testing */ result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 6.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 5.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fill the cache with 1024 byte entries -- nothing should happen * for three epochs while the markers are inserted into the cache @@ -19548,330 +18673,305 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) * increase its size. Since we are already at max size, it will * not be able to. */ - if(pass) { /* first epoch */ + if (pass) { /* first epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 52.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* second epoch */ + if (pass) { /* second epoch */ rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) - { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 53.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* third epoch */ + if (pass) { /* third epoch */ rpt_fcn_called = FALSE; - i = 2000; - while(pass && (i < 3000)) - { + i = 2000; + while (pass && (i < 3000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 54.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fourth epoch -- If the hit rate were above the lower threshold, * we would see cache size reduction now. However, nothing will * happen until we get the hit rate above the lower threshold. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 55.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fifth epoch -- force the hit rate to 100%. We should see cache size * reduction now. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (4002 * 1024)) || - (cache_ptr->min_clean_size != (int)(4002 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (4002 * 1024)) || + (cache_ptr->min_clean_size != (int)(4002 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 56.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* sixth epoch -- force the hit rate to 100% again. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2002 * 1024)) || - (cache_ptr->min_clean_size != (int)(2002 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (2002 * 1024)) || + (cache_ptr->min_clean_size != (int)(2002 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 57.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* seventh epoch -- force the hit rate to 100% again. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2000 * 1024)) || - (cache_ptr->min_clean_size != (int)(2000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (2000 * 1024)) || + (cache_ptr->min_clean_size != (int)(2000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 58.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* eigth epoch -- force the hit rate to 100% again -- should be steady * state. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 3000; - while(pass && (i < 4000)) - { + i = 3000; + while (pass && (i < 4000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (2000 * 1024)) || - (cache_ptr->min_clean_size != (int)(2000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (2000 * 1024)) || + (cache_ptr->min_clean_size != (int)(2000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 59.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* now just bang on one entry -- after three epochs, this should * get all entries other than the one evicted, and the cache size * should be decreased to the minimum. */ - if(pass) { /* ninth epoch */ + if (pass) { /* ninth epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (2000 * 1024)) || - (cache_ptr->min_clean_size != (int)(2000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (2000 * 1024)) || + (cache_ptr->min_clean_size != (int)(2000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 60.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* tenth epoch */ + if (pass) { /* tenth epoch */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (2000 * 1024)) || - (cache_ptr->min_clean_size != (2000 * 512))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->max_cache_size != (2000 * 1024)) || + (cache_ptr->min_clean_size != (2000 * 512))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 61.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* eleventh epoch -- cache size reduction */ + if (pass) { /* eleventh epoch -- cache size reduction */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != - MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (512 * 1024)) || + (cache_ptr->min_clean_size != (256 * 1024)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 62.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* twelth epoch -- at minimum size so no more ageouts */ + if (pass) { /* twelth epoch -- at minimum size so no more ageouts */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_min_size) || - (cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != - MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { + if ((!rpt_fcn_called) || (rpt_status != at_min_size) || (cache_ptr->max_cache_size != (512 * 1024)) || + (cache_ptr->min_clean_size != (256 * 1024)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != MONSTER_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 63.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Repeat the test again, this time using the age out with threshold * mode. To simplify the testing, set epochs to eviction to 1. @@ -19879,379 +18979,366 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) * Again, there are some minor structural changes in the test. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; - - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + if (pass) { - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; - auto_size_ctl.incr_mode = H5C_incr__off; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.incr_mode = H5C_incr__off; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.increment = 2.0f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; /* NOTE: upper_hr_threshold MUST be type double (not float) * or the cache test will fail on 64-bit systems. */ - auto_size_ctl.upper_hr_threshold = 0.999; /* for ease of testing */ + auto_size_ctl.upper_hr_threshold = 0.999; /* for ease of testing */ - auto_size_ctl.decrement = 0.5f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 1; /* for ease of testing */ - auto_size_ctl.apply_empty_reserve = FALSE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = FALSE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 7.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 6.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fill the cache with 4K byte entries -- increment mode is off, * so cache size reduction should kick in as soon as we get the * hit rate above .999. */ - if(pass) { /* first epoch -- hit rate 0 */ + if (pass) { /* first epoch -- hit rate 0 */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 64.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* second epoch -- hit rate 0 */ + if (pass) { /* second epoch -- hit rate 0 */ rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) - { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 65.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* third epoch -- hit rate 1.0 -- should see decrease */ + if (pass) { /* third epoch -- hit rate 1.0 -- should see decrease */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (1001 * LARGE_ENTRY_SIZE)) || - (cache_ptr->min_clean_size != (1001 * LARGE_ENTRY_SIZE / 2))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (1001 * LARGE_ENTRY_SIZE)) || + (cache_ptr->min_clean_size != (1001 * LARGE_ENTRY_SIZE / 2))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 66.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fourth epoch -- load up the cache again -- hit rate 0 */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (1001 * LARGE_ENTRY_SIZE)) || - (cache_ptr->min_clean_size != (1001 * LARGE_ENTRY_SIZE / 2))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (1001 * LARGE_ENTRY_SIZE)) || + (cache_ptr->min_clean_size != (1001 * LARGE_ENTRY_SIZE / 2))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 67.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fifth epoch -- still loading up the cache -- hit rate 0 */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) - { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (1001 * LARGE_ENTRY_SIZE)) || - (cache_ptr->min_clean_size != (1001 * LARGE_ENTRY_SIZE / 2))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (1001 * LARGE_ENTRY_SIZE)) || + (cache_ptr->min_clean_size != (1001 * LARGE_ENTRY_SIZE / 2))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 68.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* sixth epoch -- force hit rate to .998 -- should be no reduction */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 1002; - while(pass && (i < 2002)) - { + i = 1002; + while (pass && (i < 2002)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (1001 * LARGE_ENTRY_SIZE)) || - (cache_ptr->min_clean_size != (1001 * LARGE_ENTRY_SIZE / 2))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (1001 * LARGE_ENTRY_SIZE)) || + (cache_ptr->min_clean_size != (1001 * LARGE_ENTRY_SIZE / 2))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 69.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* seventh epoch -- force hit rate to .999 -- should see reduction */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 1003; - while(pass && (i < 2003)) - { + i = 1003; + while (pass && (i < 2003)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (1000 * MEDIUM_ENTRY_SIZE)) || - (cache_ptr->min_clean_size != (1000 * MEDIUM_ENTRY_SIZE / 2))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (1000 * MEDIUM_ENTRY_SIZE)) || + (cache_ptr->min_clean_size != (1000 * MEDIUM_ENTRY_SIZE / 2))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 70.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* We have now tested all the major ageout modes individually. * Lets try them all together to look for unexpected interactions * and/or bugs. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; - - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1000 * 1024; + if (pass) { - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.max_size = 8 * 1000 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1000 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.max_size = 8 * 1000 * 1024; + auto_size_ctl.min_size = 512 * 1024; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.increment = 2.0f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; - auto_size_ctl.upper_hr_threshold = 0.999f; /* for ease of testing */ + auto_size_ctl.upper_hr_threshold = 0.999f; /* for ease of testing */ - auto_size_ctl.decrement = 0.5f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1000 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1000 * 1024); auto_size_ctl.epochs_before_eviction = 1; /* for ease of testing */ - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.5f; /* for ease of testing */ + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.5f; /* for ease of testing */ result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 8.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024))) { + if ((cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 7.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fill the cache with 4K byte entries -- increment mode is threshold, * so the decrease code will not be executed until the hit rate exceeds * .75. */ - if(pass) { /* first epoch -- hit rate 0 */ + if (pass) { /* first epoch -- hit rate 0 */ rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 71.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { /* second epoch -- hit rate 0 */ + if (pass) { /* second epoch -- hit rate 0 */ rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) - { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 72.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* third epoch -- force the hit rate to 1.0. Should be no change * in the cache size due to the combination of the empty reserve @@ -20261,407 +19348,392 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) * * In this epoch, all we should see is a reduction in the index size. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || - (cache_ptr->index_size != (7 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || + (cache_ptr->index_size != (7 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 73.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fourth epoch -- hit rate still 1.0. Index size should decrease, * but otherwise no change expected. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || - (cache_ptr->index_size != (6 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || + (cache_ptr->index_size != (6 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 74.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fifth epoch -- hit rate still 1.0. Index size should decrease, * but otherwise no change expected. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || - (cache_ptr->index_size != (5 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || + (cache_ptr->index_size != (5 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 75.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* sixth epoch -- hit rate still 1.0. Index size should decrease, * but otherwise no change expected. Note that the cache size is * now just on the edge of meeting the clean reserve. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || - (cache_ptr->index_size != (4 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || + (cache_ptr->index_size != (4 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 76.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* seventh epoch -- hit rate still 1.0. No change in index size expected. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || - (cache_ptr->index_size != (4 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || + (cache_ptr->index_size != (4 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 77.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* eighth epoch -- start loading 1 KB entries. Hit rate 0 so * decrease code shouldn't be called. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != at_max_size) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || - (cache_ptr->index_size != (5 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != at_max_size) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || + (cache_ptr->index_size != (5 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 78.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* ninth epoch -- access the 1 KB entries again, driving the hit rate * to 1.0. Decrease code should be triggered, but the max decrease * should prevent the empty reserve from being met in this epoch. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || - (cache_ptr->index_size != (4 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1000 * 1024)) || + (cache_ptr->index_size != (4 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 79.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* tenth epoch -- access the 1 KB entries yet again, forcing hit rate * to 1.0. Decrease code should be triggered, and the empty reserve * should finally be met. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (7 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (7 * 1000 * 1024 / 2)) || - (cache_ptr->index_size != (3 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (7 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (7 * 1000 * 1024 / 2)) || + (cache_ptr->index_size != (3 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 80.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* eleventh epoch -- access the 1 KB entries yet again, forcing hit rate * to 1.0. Decrease code should be triggered, and the empty reserve * should be met again. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (6 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1000 * 1024)) || - (cache_ptr->index_size != (2 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (6 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1000 * 1024)) || + (cache_ptr->index_size != (2 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 81.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* twelth epoch -- hit rate 1.0 -- decrease as before. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (5 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (5 * 1000 * 1024 / 2)) || - (cache_ptr->index_size != (1 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (5 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (5 * 1000 * 1024 / 2)) || + (cache_ptr->index_size != (1 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 82.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* thirteenth epoch -- hit rate 1.0 -- decrease as before. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (4 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1000 * 1024)) || - (cache_ptr->index_size != (1 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (4 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1000 * 1024)) || + (cache_ptr->index_size != (1 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 83.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fourteenth epoch -- hit rate 1.0 -- decrease as before. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (3 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1000 * 1024 / 2)) || - (cache_ptr->index_size != (1 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (3 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1000 * 1024 / 2)) || + (cache_ptr->index_size != (1 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 84.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* fifteenth epoch -- hit rate 1.0 -- decrease as before. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1000 * 1024)) || - (cache_ptr->index_size != (1 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (2 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1000 * 1024)) || + (cache_ptr->index_size != (1 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 85.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* sixteenth epoch -- hit rate 1.0 -- should be stable now */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (2 * 1000 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1000 * 1024)) || - (cache_ptr->index_size != (1 * 1000 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (2 * 1000 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1000 * 1024)) || + (cache_ptr->index_size != (1 * 1000 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 86.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* now test the flash cache size increment code. At least at present, * there should be no interaction between the regular auto-resize @@ -20674,7 +19746,8 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) * code increases the cache size when and as expected. */ - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Place the cache in a known state via a flush-destroy on the cache * to clear out all entries, and then a reset on all the entries. @@ -20683,366 +19756,344 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) * modes. Verify that all perform as expected. */ - if(pass) { + if (pass) { flush_cache(file_ptr, TRUE, FALSE, FALSE); - reset_entries(); + reset_entries(); } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* now repeat the above tests using the add space flash cache size * increment algorithm. */ - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 64 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 64 * 1024; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.max_size = 1024 * 1024; - auto_size_ctl.min_size = 5 * 1024; + auto_size_ctl.max_size = 1024 * 1024; + auto_size_ctl.min_size = 5 * 1024; - auto_size_ctl.epoch_length = 100; + auto_size_ctl.epoch_length = 100; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (32 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (32 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__add_space; + auto_size_ctl.flash_multiple = 1.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__add_space; - auto_size_ctl.flash_multiple = 1.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + auto_size_ctl.upper_hr_threshold = 0.999f; /* for ease of testing */ - auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.upper_hr_threshold = 0.999f; /* for ease of testing */ - - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1000 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1000 * 1024); auto_size_ctl.epochs_before_eviction = 1; /* for ease of testing */ - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.5f; /* for ease of testing */ + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.5f; /* for ease of testing */ result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 12.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (64 * 1024)) || - (cache_ptr->min_clean_size != (32 * 1024)) || - (cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->cache_accesses != 0)) { + if ((cache_ptr->max_cache_size != (64 * 1024)) || (cache_ptr->min_clean_size != (32 * 1024)) || + (cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || (cache_ptr->cache_accesses != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (0).\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Load a huge entry into the cache */ - if(pass) { + if (pass) { protect_entry(file_ptr, HUGE_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, HUGE_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (64 * 1024)) || - (cache_ptr->min_clean_size != (32 * 1024)) || - (cache_ptr->index_len != 1) || - (cache_ptr->index_size != HUGE_ENTRY_SIZE) || - (cache_ptr->cache_accesses != 1)))) { + if (pass && (((cache_ptr->max_cache_size != (64 * 1024)) || + (cache_ptr->min_clean_size != (32 * 1024)) || (cache_ptr->index_len != 1) || + (cache_ptr->index_size != HUGE_ENTRY_SIZE) || (cache_ptr->cache_accesses != 1)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (1).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now load a monster entry. Since a monster entry is larger than * half the size of the cache, and there is not sufficient space * for a monster entry in the cache, we will add space to the * cache to make room for the entry. */ - if(pass) { + if (pass) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (80 * 1024)) || - (cache_ptr->min_clean_size != (40 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != (HUGE_ENTRY_SIZE + - MONSTER_ENTRY_SIZE)) || - (cache_ptr->cache_accesses != 1)))) { + if (pass && (((cache_ptr->max_cache_size != (80 * 1024)) || + (cache_ptr->min_clean_size != (40 * 1024)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != (HUGE_ENTRY_SIZE + MONSTER_ENTRY_SIZE)) || + (cache_ptr->cache_accesses != 1)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (2).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Load a second monster entry. Since the monster entry is larger * than half the size of the cache yet again, and there is not * sufficient space for the monster entry in the cache, we again * add space to the cache to make space for the entry. */ - if(pass) { + if (pass) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 1); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 1, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (144 * 1024)) || - (cache_ptr->min_clean_size != (72 * 1024)) || - (cache_ptr->index_len != 3) || - (cache_ptr->index_size != ((2 * MONSTER_ENTRY_SIZE) + - HUGE_ENTRY_SIZE)) || - (cache_ptr->cache_accesses != 1)))) { + if (pass && (((cache_ptr->max_cache_size != (144 * 1024)) || + (cache_ptr->min_clean_size != (72 * 1024)) || (cache_ptr->index_len != 3) || + (cache_ptr->index_size != ((2 * MONSTER_ENTRY_SIZE) + HUGE_ENTRY_SIZE)) || + (cache_ptr->cache_accesses != 1)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (3).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Load a third moster entry. Should be no cache size increase this * time. */ - if(pass) { + if (pass) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 2); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 2, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (144 * 1024)) || - (cache_ptr->min_clean_size != (72 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != (2 * MONSTER_ENTRY_SIZE)) || - (cache_ptr->cache_accesses != 2)))) { + if (pass && + (((cache_ptr->max_cache_size != (144 * 1024)) || (cache_ptr->min_clean_size != (72 * 1024)) || + (cache_ptr->index_len != 2) || (cache_ptr->index_size != (2 * MONSTER_ENTRY_SIZE)) || + (cache_ptr->cache_accesses != 2)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (4).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* delete existing entries to prepare for next test, and reset * the size of the cache. */ - if(pass) { + if (pass) { - expunge_entry(file_ptr, MONSTER_ENTRY_TYPE, 1); - expunge_entry(file_ptr, MONSTER_ENTRY_TYPE, 2); + expunge_entry(file_ptr, MONSTER_ENTRY_TYPE, 1); + expunge_entry(file_ptr, MONSTER_ENTRY_TYPE, 2); - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 13.\n"; - } + } } - if(pass && - (((cache_ptr->max_cache_size != (64 * 1024)) || - (cache_ptr->min_clean_size != (32 * 1024)) || - (cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (64 * 1024)) || + (cache_ptr->min_clean_size != (32 * 1024)) || (cache_ptr->index_len != 0) || + (cache_ptr->index_size != 0) || (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (5).\n"; - } + } } /* repeat the above basic test, only this time, use inserts to add * entries to the cache, not protects. */ - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* insert a huge entry into the cache */ - if(pass) { + if (pass) { insert_entry(file_ptr, HUGE_ENTRY_TYPE, 1, H5C__NO_FLAGS_SET); - /* protect and unprotect a couple times to increment cache_accesses */ + /* protect and unprotect a couple times to increment cache_accesses */ protect_entry(file_ptr, HUGE_ENTRY_TYPE, 1); unprotect_entry(file_ptr, HUGE_ENTRY_TYPE, 1, H5C__NO_FLAGS_SET); protect_entry(file_ptr, HUGE_ENTRY_TYPE, 1); unprotect_entry(file_ptr, HUGE_ENTRY_TYPE, 1, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (64 * 1024)) || - (cache_ptr->min_clean_size != (32 * 1024)) || - (cache_ptr->index_len != 1) || - (cache_ptr->index_size != HUGE_ENTRY_SIZE) || - (cache_ptr->cache_accesses != 2)))) { + if (pass && (((cache_ptr->max_cache_size != (64 * 1024)) || + (cache_ptr->min_clean_size != (32 * 1024)) || (cache_ptr->index_len != 1) || + (cache_ptr->index_size != HUGE_ENTRY_SIZE) || (cache_ptr->cache_accesses != 2)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (6).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now insert a monster entry. Since a monster entry is larger than * half the size of the cache, and there is not sufficient space * for a monster entry in the cache, we will add space to the * cache to make room for the entry. */ - if(pass) { + if (pass) { insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 4, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (80 * 1024)) || - (cache_ptr->min_clean_size != (40 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != - HUGE_ENTRY_SIZE + MONSTER_ENTRY_SIZE) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (80 * 1024)) || + (cache_ptr->min_clean_size != (40 * 1024)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != HUGE_ENTRY_SIZE + MONSTER_ENTRY_SIZE) || + (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (7).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Insert a second monster entry. Cache size should increase again. */ - if(pass) { + if (pass) { insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 5, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (144 * 1024)) || - (cache_ptr->min_clean_size != (72 * 1024)) || - (cache_ptr->index_len != 3) || - (cache_ptr->index_size != - 2 * MONSTER_ENTRY_SIZE + HUGE_ENTRY_SIZE) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (144 * 1024)) || + (cache_ptr->min_clean_size != (72 * 1024)) || (cache_ptr->index_len != 3) || + (cache_ptr->index_size != 2 * MONSTER_ENTRY_SIZE + HUGE_ENTRY_SIZE) || + (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (8).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Insert a third monster entry. Should be no cache size increase this * time. */ - if(pass) { + if (pass) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 6); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 6, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (144 * 1024)) || - (cache_ptr->min_clean_size != (72 * 1024)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != (2 * MONSTER_ENTRY_SIZE)) || - (cache_ptr->cache_accesses != 1)))) { + if (pass && + (((cache_ptr->max_cache_size != (144 * 1024)) || (cache_ptr->min_clean_size != (72 * 1024)) || + (cache_ptr->index_len != 2) || (cache_ptr->index_size != (2 * MONSTER_ENTRY_SIZE)) || + (cache_ptr->cache_accesses != 1)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (9).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* delete existing entries to prepare for next test, and reset * the size of the cache. We must also change the size of the needed * variable entries before we run the test, so will protect and * unprotect them now so as to get the correct initial size. */ - if(pass) { + if (pass) { - expunge_entry(file_ptr, MONSTER_ENTRY_TYPE, 5); - expunge_entry(file_ptr, MONSTER_ENTRY_TYPE, 6); + expunge_entry(file_ptr, MONSTER_ENTRY_TYPE, 5); + expunge_entry(file_ptr, MONSTER_ENTRY_TYPE, 6); protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, 1024, TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, 1024, TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, 1024, TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, 1024, TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__DIRTIED_FLAG); protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, 1024, TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, 1024, TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__DIRTIED_FLAG); protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13, 1024, TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13, H5C__DIRTIED_FLAG); - - flush_cache(file_ptr, TRUE, FALSE, FALSE); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13, 1024, TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13, H5C__DIRTIED_FLAG); + flush_cache(file_ptr, TRUE, FALSE, FALSE); - if(pass) { + if (pass) { - auto_size_ctl.initial_size = 6 * 1024; - result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); + auto_size_ctl.initial_size = 6 * 1024; + result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 13.\n"; - } + } } - if(pass && - (((cache_ptr->max_cache_size != (6 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024)) || - (cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (6 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024)) || (cache_ptr->index_len != 0) || + (cache_ptr->index_size != 0) || (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (10).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now load the variable entries into the cache */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__NO_FLAGS_SET); @@ -21056,245 +20107,221 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (6 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 4 * 1024) || - (cache_ptr->cache_accesses != 4)))) { + if (pass && (((cache_ptr->max_cache_size != (6 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 4 * 1024) || (cache_ptr->cache_accesses != 4)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (11).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* protect a variable entry, and re-size it to 3K. Should be * no effect on the size of the cache. */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, (3 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, (3 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); + if (pass && (((cache_ptr->max_cache_size != (6 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 6 * 1024) || (cache_ptr->cache_accesses != 5)))) { - if(pass && - (((cache_ptr->max_cache_size != (6 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 6 * 1024) || - (cache_ptr->cache_accesses != 5)))) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (12).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* protect the variable entry again, and re-size it to 10K. Should * resize the cache to 13 KB. Note that cache_accesses will be 0 * in this case, since cache_accesses is incremented on the protect. */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, (10 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, (10 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); + if (pass && (((cache_ptr->max_cache_size != (13 * 1024)) || + (cache_ptr->min_clean_size != (13 * 512)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 13 * 1024) || (cache_ptr->cache_accesses != 0)))) { - if(pass && - (((cache_ptr->max_cache_size != (13 * 1024)) || - (cache_ptr->min_clean_size != (13 * 512)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 13 * 1024) || - (cache_ptr->cache_accesses != 0)))) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (13).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* protect a second variable entry, and re-size it to 10K. Should * resize to 22 KB. */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, (10 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, (10 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__DIRTIED_FLAG); + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 22 * 1024) || (cache_ptr->cache_accesses != 0)))) { - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 22 * 1024) || - (cache_ptr->cache_accesses != 0)))) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (14).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* protect a third variable entry, and re-size it to 10K. Should * be no change in cache size. */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, (10 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, (10 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__DIRTIED_FLAG); + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 31 * 1024) || (cache_ptr->cache_accesses != 1)))) { - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 31 * 1024) || - (cache_ptr->cache_accesses != 1)))) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (15).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* re-size the variable entries back down to their initial size, and * restore the cache to its initial size as well, in preparation * for the next test. */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, (1 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, (1 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, (1 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, (1 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__DIRTIED_FLAG); protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, (1 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, (1 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__DIRTIED_FLAG); - if(pass) { + if (pass) { - auto_size_ctl.initial_size = 6 * 1024; - result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); + auto_size_ctl.initial_size = 6 * 1024; + result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 14.\n"; - } + } } - if(pass && - (((cache_ptr->max_cache_size != (6 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 4 * 1024) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (6 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 4 * 1024) || (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (16).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now test flash cache resizes with pinned entries... */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__PIN_ENTRY_FLAG); resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, 2 * 1024, TRUE); - if(pass && - (((cache_ptr->max_cache_size != (6 * 1024)) || - (cache_ptr->min_clean_size != (6 * 512)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 5 * 1024) || - (cache_ptr->cache_accesses != 1)))) { + if (pass && (((cache_ptr->max_cache_size != (6 * 1024)) || (cache_ptr->min_clean_size != (6 * 512)) || + (cache_ptr->index_len != 4) || (cache_ptr->index_size != 5 * 1024) || + (cache_ptr->cache_accesses != 1)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (17).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, 10 * 1024, TRUE); - if(pass && - (((cache_ptr->max_cache_size != (13 * 1024)) || - (cache_ptr->min_clean_size != (13 * 512)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 13 * 1024) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (13 * 1024)) || + (cache_ptr->min_clean_size != (13 * 512)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 13 * 1024) || (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (18).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__PIN_ENTRY_FLAG); resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, 10 * 1024, TRUE); - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 22 * 1024) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 22 * 1024) || (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (19).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__PIN_ENTRY_FLAG); resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, 10 * 1024, TRUE); - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 31 * 1024) || - (cache_ptr->cache_accesses != 1)))) { + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 31 * 1024) || (cache_ptr->cache_accesses != 1)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (20).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Unpin the entries. Note that no entries are evicted as we don't * load any entries. */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__UNPIN_ENTRY_FLAG); @@ -21305,144 +20332,131 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__UNPIN_ENTRY_FLAG); - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 31 * 1024) || - (cache_ptr->cache_accesses != 4)))) { + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 31 * 1024) || (cache_ptr->cache_accesses != 4)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (21).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* re-size the variable entries back down to their initial size, and * restore the cache to its initial size as well, in preparation * for the next test. */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, (1 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, (1 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__DIRTIED_FLAG); protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, (1 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, (1 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__DIRTIED_FLAG); protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, (1 * 1024), TRUE); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__DIRTIED_FLAG); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, (1 * 1024), TRUE); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__DIRTIED_FLAG); - if(pass) { + if (pass) { - auto_size_ctl.initial_size = 6 * 1024; - result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); + auto_size_ctl.initial_size = 6 * 1024; + result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 15.\n"; - } + } } - if(pass && - (((cache_ptr->max_cache_size != (6 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 4 * 1024) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (6 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 4 * 1024) || (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (22).\n"; - } + } } - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__PIN_ENTRY_FLAG); resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, 2 * 1024, TRUE); - if(pass && - (((cache_ptr->max_cache_size != (6 * 1024)) || - (cache_ptr->min_clean_size != (6 * 512)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 5 * 1024) || - (cache_ptr->cache_accesses != 1)))) { + if (pass && (((cache_ptr->max_cache_size != (6 * 1024)) || (cache_ptr->min_clean_size != (6 * 512)) || + (cache_ptr->index_len != 4) || (cache_ptr->index_size != 5 * 1024) || + (cache_ptr->cache_accesses != 1)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (23).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, 10 * 1024, TRUE); - if(pass && - (((cache_ptr->max_cache_size != (13 * 1024)) || - (cache_ptr->min_clean_size != (13 * 512)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 13 * 1024) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (13 * 1024)) || + (cache_ptr->min_clean_size != (13 * 512)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 13 * 1024) || (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (24).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, H5C__PIN_ENTRY_FLAG); resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11, 10 * 1024, TRUE); - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 22 * 1024) || - (cache_ptr->cache_accesses != 0)))) { + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 22 * 1024) || (cache_ptr->cache_accesses != 0)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (25).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__PIN_ENTRY_FLAG); resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, 10 * 1024, TRUE); - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 31 * 1024) || - (cache_ptr->cache_accesses != 1)))) { + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 31 * 1024) || (cache_ptr->cache_accesses != 1)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (26).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Unpin the entries. Note that no entries are evicted as we don't * load any entries. */ - if(pass) { + if (pass) { protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10, H5C__UNPIN_ENTRY_FLAG); @@ -21453,169 +20467,156 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12, H5C__UNPIN_ENTRY_FLAG); - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 4) || - (cache_ptr->index_size != 31 * 1024) || - (cache_ptr->cache_accesses != 4)))) { + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 4) || + (cache_ptr->index_size != 31 * 1024) || (cache_ptr->cache_accesses != 4)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (27).\n"; - } + } } /* We have finished a basic check of the flash cache size increment * code. Tidy up for a more extensive test... */ - if(pass) { + if (pass) { - expunge_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); - expunge_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11); - expunge_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); - expunge_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13); + expunge_entry(file_ptr, VARIABLE_ENTRY_TYPE, 10); + expunge_entry(file_ptr, VARIABLE_ENTRY_TYPE, 11); + expunge_entry(file_ptr, VARIABLE_ENTRY_TYPE, 12); + expunge_entry(file_ptr, VARIABLE_ENTRY_TYPE, 13); - if(pass && - (((cache_ptr->max_cache_size != (22 * 1024)) || - (cache_ptr->min_clean_size != (11 * 1024)) || - (cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->cache_accesses != 4)))) { + if (pass && (((cache_ptr->max_cache_size != (22 * 1024)) || + (cache_ptr->min_clean_size != (11 * 1024)) || (cache_ptr->index_len != 0) || + (cache_ptr->index_size != 0) || (cache_ptr->cache_accesses != 4)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (28).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* ...and then reconfigure. Note that we change the flash_multiple * and flash_threshold just to make sure that such changed perform * as expected. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024; - auto_size_ctl.max_size = 20 * 1024; - auto_size_ctl.min_size = 4 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 100; + auto_size_ctl.max_size = 20 * 1024; + auto_size_ctl.min_size = 4 * 1024; + auto_size_ctl.epoch_length = 100; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__add_space; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.4f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__add_space; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.4f; + auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; - auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + auto_size_ctl.upper_hr_threshold = 0.999f; /* for ease of testing */ - auto_size_ctl.upper_hr_threshold = 0.999f; /* for ease of testing */ + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (2 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (2 * 1024); auto_size_ctl.epochs_before_eviction = 1; /* for ease of testing */ - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.5f; /* for ease of testing */ + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.5f; /* for ease of testing */ result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { - pass = FALSE; + if (result != SUCCEED) { + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 15.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024)) || - (cache_ptr->min_clean_size != (4 * 512)) || - (cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0) || - (cache_ptr->cache_accesses != 0)) { + if ((cache_ptr->max_cache_size != (4 * 1024)) || (cache_ptr->min_clean_size != (4 * 512)) || + (cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || (cache_ptr->cache_accesses != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache after initialization 15.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* protect and unprotect a large entry -- no change in cache size since * a large entry will just fill the available space in the cache. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (4 * 1024)) || - (cache_ptr->min_clean_size != (4 * 512)) || - (cache_ptr->index_len != 1) || - (cache_ptr->index_size != LARGE_ENTRY_SIZE) || - (cache_ptr->cache_accesses != 1) || - (rpt_fcn_called == TRUE)))) { + if (pass && (((cache_ptr->max_cache_size != (4 * 1024)) || (cache_ptr->min_clean_size != (4 * 512)) || + (cache_ptr->index_len != 1) || (cache_ptr->index_size != LARGE_ENTRY_SIZE) || + (cache_ptr->cache_accesses != 1) || (rpt_fcn_called == TRUE)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (29).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* protect and unprotect another a large entry -- should trigger a * flash cache size increase to 12 KB (remember that flash_multiple is * set to 2.0). */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (12 * 1024)) || - (cache_ptr->min_clean_size != (12 * 512)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != 2 * LARGE_ENTRY_SIZE) || - (cache_ptr->cache_accesses != 1) || - (rpt_fcn_called != TRUE)))) { + if (pass && + (((cache_ptr->max_cache_size != (12 * 1024)) || (cache_ptr->min_clean_size != (12 * 512)) || + (cache_ptr->index_len != 2) || (cache_ptr->index_size != 2 * LARGE_ENTRY_SIZE) || + (cache_ptr->cache_accesses != 1) || (rpt_fcn_called != TRUE)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (30).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* protect and unprotect two more large entries -- shouldnt trigger a * flash cache size increase. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; @@ -21624,122 +20625,112 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (12 * 1024)) || - (cache_ptr->min_clean_size != (12 * 512)) || - (cache_ptr->index_len != 3) || - (cache_ptr->index_size != 3 * LARGE_ENTRY_SIZE) || - (cache_ptr->cache_accesses != 3) || - (rpt_fcn_called != FALSE)))) { + if (pass && + (((cache_ptr->max_cache_size != (12 * 1024)) || (cache_ptr->min_clean_size != (12 * 512)) || + (cache_ptr->index_len != 3) || (cache_ptr->index_size != 3 * LARGE_ENTRY_SIZE) || + (cache_ptr->cache_accesses != 3) || (rpt_fcn_called != FALSE)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (31).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* do many accesses of a single entry to talk the cache into reducing * its size to the minimum. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, TINY_ENTRY_TYPE, 0); - if(pass) + if (pass) unprotect_entry(file_ptr, TINY_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); i++; } - if((!rpt_fcn_called) || - (cache_ptr->max_cache_size != (4 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024)) || - (cache_ptr->index_size != (1 * TINY_ENTRY_SIZE))) { + if ((!rpt_fcn_called) || (cache_ptr->max_cache_size != (4 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024)) || (cache_ptr->index_size != (1 * TINY_ENTRY_SIZE))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (32).\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Force another flash increase */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (4 * 1024 + 128)) || - (cache_ptr->min_clean_size != (2 * 1024 + 64)) || - (cache_ptr->index_len != 2) || - (cache_ptr->index_size != - LARGE_ENTRY_SIZE + TINY_ENTRY_SIZE) || - (cache_ptr->cache_accesses != 1) || - (rpt_fcn_called == FALSE) || - (rpt_status != flash_increase)))) { + if (pass && (((cache_ptr->max_cache_size != (4 * 1024 + 128)) || + (cache_ptr->min_clean_size != (2 * 1024 + 64)) || (cache_ptr->index_len != 2) || + (cache_ptr->index_size != LARGE_ENTRY_SIZE + TINY_ENTRY_SIZE) || + (cache_ptr->cache_accesses != 1) || (rpt_fcn_called == FALSE) || + (rpt_status != flash_increase)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (33).\n"; - } + } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force regular size increase up to maximum */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 500)) - { + i = 0; + while (pass && (i < 500)) { protect_entry(file_ptr, TINY_ENTRY_TYPE, i); - if(pass) + if (pass) unprotect_entry(file_ptr, TINY_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); i++; } - if((cache_ptr->max_cache_size != (20 * 1024)) || - (cache_ptr->min_clean_size != (10 * 1024)) || - (rpt_fcn_called == FALSE) || - (rpt_status != at_max_size)) { + if ((cache_ptr->max_cache_size != (20 * 1024)) || (cache_ptr->min_clean_size != (10 * 1024)) || + (rpt_fcn_called == FALSE) || (rpt_status != at_max_size)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache config (34).\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { PASSED(); } /* end if */ else { H5_FAILED(); } /* end else */ - if(!pass) + if (!pass) HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return (unsigned)!pass; } /* check_auto_cache_resize() */ - /*------------------------------------------------------------------------- * Function: check_auto_cache_resize_disable() * @@ -21763,14 +20754,13 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) static unsigned check_auto_cache_resize_disable(unsigned paged) { - hbool_t show_progress = FALSE; - herr_t result; - int32_t i; - int32_t checkpoint = 0; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_auto_size_ctl_t auto_size_ctl = - { + hbool_t show_progress = FALSE; + herr_t result; + int32_t i; + int32_t checkpoint = 0; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_auto_size_ctl_t auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* H5C_auto_resize_report_fcn rpt_fcn = */ test_rpt_fcn, @@ -21784,7 +20774,6 @@ check_auto_cache_resize_disable(unsigned paged) /* int64_t epoch_length = */ 1000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -21795,11 +20784,10 @@ check_auto_cache_resize_disable(unsigned paged) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, + /* flash_incr_mode = */ H5C_flash_incr__off, /* double flash_multiple = */ 1.0f, /* double flash_threshold = */ 0.25f, - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, /* double upper_hr_threshold = */ 0.995f, @@ -21812,34 +20800,33 @@ check_auto_cache_resize_disable(unsigned paged) /* int32_t epochs_before_eviction = */ 3, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f - }; + /* double empty_reserve = */ 0.05f}; - if(paged) + if (paged) TESTING("automatic cache resize disable (paged aggregation)") else TESTING("automatic cache resize disable") pass = TRUE; - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* allocate a cache, enable automatic cache resizing, and then force * the cache through all its operational modes. Verify that all * performs as expected. */ - if(pass) { + if (pass) { reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); - if(file_ptr == NULL) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "file_ptr NULL from setup_cache."; - } else { @@ -21847,29 +20834,28 @@ check_auto_cache_resize_disable(unsigned paged) } } - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024))) { + if ((cache_ptr->max_cache_size != (512 * 1024)) || (cache_ptr->min_clean_size != (256 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after initialization.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /****************************************************************** * So far, we have forced the auto cache resize through all modes @@ -21878,1399 +20864,1346 @@ check_auto_cache_resize_disable(unsigned paged) * modes. ******************************************************************/ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 1.0f; /* disable size increases */ + auto_size_ctl.increment = 1.0f; /* disable size increases */ - auto_size_ctl.apply_max_increment = FALSE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.apply_max_increment = FALSE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 2.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 1.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full -- increase disabled so should * be no change in cache size, and result should be increase_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_increase_possible) || - (rpt_status != increase_disabled) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_increase_possible) || (rpt_status != increase_disabled) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 1.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- make sure that we haven't disabled decreases. * should result in a decrease cache size from 4 to 2 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 2.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate again -- increase disabled so should * be no change in cache size, and result should be increase_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_increase_possible) || - (rpt_status != increase_disabled) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_increase_possible) || (rpt_status != increase_disabled) || + (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 3.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Repeat the above tests, disabling increase through the lower * threshold instead of the increment. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.0f; /* disable size increases */ + auto_size_ctl.lower_hr_threshold = 0.0f; /* disable size increases */ - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = FALSE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.apply_max_increment = FALSE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 3.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 2.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full -- increase disabled so should * be no change in cache size, and result should be in_spec. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_increase_possible) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_increase_possible) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 4.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- make sure that we haven't disabled decreases. * should result in a decrease cache size from 4 to 2 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 5.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate again -- increase disabled so should * be no change in cache size, and result should be increase_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_increase_possible) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_increase_possible) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 6.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Repeat the above tests yet again, disabling increase through the * incr_mode. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__off; + auto_size_ctl.incr_mode = H5C_incr__off; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = FALSE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.apply_max_increment = FALSE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 4.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 3.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate with cache full -- increase disabled so should * be no change in cache size, and result should be in_spec. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_increase_possible) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_increase_possible) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 7.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- make sure that we haven't disabled decreases. * should result in a decrease cache size from 4 to 2 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 8.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate again -- increase disabled so should * be no change in cache size, and result should be increase_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_increase_possible) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_increase_possible) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 9.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now, disable size decreases, and repeat the above tests. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 1.0f; /* disable size decreases */ - auto_size_ctl.decrement = 1.0f; /* disable size decreases */ - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 5.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 4.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no change in cache size, * and result should be decrease_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease_disabled) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease_disabled) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 10.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- cache size should increase from 4 to 6 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 11.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate again -- should be no change in cache size, * and result should be decrease_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease_disabled) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != decrease_disabled) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 12.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Repeat the above tests, disabling decrease through the upper * threshold instead of the decrement. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 1.0f; /* disable size decreases */ - auto_size_ctl.upper_hr_threshold = 1.0f; /* disable size decreases */ + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 6.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 5.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no change in cache size, * and result should be in_spec. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 13.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- cache size should increase from 4 to 6 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 14.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate again -- should be no change in cache size, * and result should be in_spec. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 15.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Repeat the above tests, disabling decrease through the decr_mode. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__off; - auto_size_ctl.decr_mode = H5C_decr__off; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 7.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 6.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no change in cache size, * and result should be in_spec. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 16.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- cache size should increase from 4 to 6 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 17.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate again -- should be no change in cache size, * and result should be in_spec. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 18.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now do tests disabling size decrement in age out mode. * * Start by disabling size decrement by setting max_decrement to zero. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__age_out; - auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = 0; /* disable decrement */ + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = 0; /* disable decrement */ auto_size_ctl.epochs_before_eviction = 1; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 8.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 7.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { /* flush the cache and destroy all entries so we start from a known point */ flush_cache(file_ptr, TRUE, FALSE, FALSE); - } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* load up the cache with small entries. Note that it will take an * epoch for the ageout code to initialize itself if it is enabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != not_full) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != not_full) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 19.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Load up some more small entries. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) - { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != not_full) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != not_full) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 20.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now force a high hit rate so that the size increase code is * is satisfied. We would see a decrease here if decrease were * possible. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != decrease_disabled) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != decrease_disabled) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 21.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- cache size should increase from 4 to 6 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 22.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* just bang on a single entry. This will see to it that there are * many entries that could be aged out were decreases enabled. * Should be no change in cache size, and result should be * decrease_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != decrease_disabled) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != decrease_disabled) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 23.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now disable size decrement in age out mode via the empty reserve. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__age_out; - auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 1; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 1.0f; /* disable decrement */ + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 1.0f; /* disable decrement */ result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 9.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 8.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { /* flush the cache and destroy all entries so we start from a known point */ flush_cache(file_ptr, TRUE, FALSE, FALSE); - } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* load up the cache with small entries. Note that it will take an * epoch for the ageout code to initialize itself if it is enabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != not_full) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != not_full) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 24.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Load up some more small entries. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) - { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != not_full) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != not_full) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 25.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now force a high hit rate so that the size increase code is * is satisfied. We would see a decrease here if decrease were * possible. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != decrease_disabled) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != decrease_disabled) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 26.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- cache size should increase from 4 to 6 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 27.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* just bang on a single entry. This will see to it that there are * many entries that could be aged out were decreases enabled. * Should be no change in cache size, and result should be * decrease_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != decrease_disabled) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != decrease_disabled) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 28.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now work with age out with threshold. One can argue that we should * repeat the above age out tests with age out with threshold, but the @@ -23282,138 +22215,133 @@ check_auto_cache_resize_disable(unsigned paged) * to 1.0. Test this now. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; - auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + auto_size_ctl.upper_hr_threshold = 1.0f; - auto_size_ctl.upper_hr_threshold = 1.0f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 1; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 10.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 9.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { /* flush the cache and destroy all entries so we start from a known point */ flush_cache(file_ptr, TRUE, FALSE, FALSE); - } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* load up the cache with small entries. Note that it will take an * epoch for the ageout code to initialize itself if it is enabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != not_full) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != not_full) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 29.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Load up some more small entries. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 1000; - while(pass && (i < 2000)) - { + i = 1000; + while (pass && (i < 2000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != not_full) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != not_full) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 30.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now force a high hit rate so that the size increase code is * is satisfied. We would see a decrease here if decrease were @@ -23421,62 +22349,58 @@ check_auto_cache_resize_disable(unsigned paged) * * rpt_status should be decrease_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != decrease_disabled) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024)) || - (cache_ptr->index_len != 2000) || - (cache_ptr->index_size != 2000 * SMALL_ENTRY_SIZE)) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != decrease_disabled) || + (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024)) || (cache_ptr->index_len != 2000) || + (cache_ptr->index_size != 2000 * SMALL_ENTRY_SIZE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 31.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- cache size should increase from 4 to 6 Meg. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != increase) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (rpt_status != increase) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 32.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* just bang on a single entry. This keeps the hit rate high, and sees * to it that there are many entries that could be aged out were @@ -23485,33 +22409,30 @@ check_auto_cache_resize_disable(unsigned paged) * Should be no change in cache size, and result should be * decrease_disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 999); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 999, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (cache_ptr->size_decrease_possible) || - (rpt_status != decrease_disabled) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((!rpt_fcn_called) || (cache_ptr->size_decrease_possible) || (rpt_status != decrease_disabled) || + (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 33.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /********************************************************************* * Finally, use the auto cache resize code to set the size of the @@ -23520,770 +22441,725 @@ check_auto_cache_resize_disable(unsigned paged) * check them all. *********************************************************************/ - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 2 * 1024 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 2 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.0f; /* disable size increases */ - auto_size_ctl.lower_hr_threshold = 0.0f; /* disable size increases */ + auto_size_ctl.increment = 2.0f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 1.0f; /* disable size decreases */ - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.upper_hr_threshold = 1.0f; /* disable size decreases */ - - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 11.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 10.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 34.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 35.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.25f; + auto_size_ctl.min_clean_fraction = 0.25f; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 1.0f; /* disable size increment */ - auto_size_ctl.increment = 1.0f; /* disable size increment */ + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.decrement = 1.0f; /* disable size decrement */ - auto_size_ctl.upper_hr_threshold = 0.995f; - - auto_size_ctl.decrement = 1.0f; /* disable size decrement */ - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 12.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 11.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 36.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 37.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = FALSE; - auto_size_ctl.initial_size = 2 * 1024 * 1024; + auto_size_ctl.set_initial_size = FALSE; + auto_size_ctl.initial_size = 2 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.max_size = 6 * 1024 * 1024; /* no resize */ - auto_size_ctl.min_size = 6 * 1024 * 1024; /* no resize */ + auto_size_ctl.max_size = 6 * 1024 * 1024; /* no resize */ + auto_size_ctl.min_size = 6 * 1024 * 1024; /* no resize */ - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.upper_hr_threshold = 0.995f; - - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 13.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 12.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 38.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (6 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (3 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 39.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.25f; + auto_size_ctl.min_clean_fraction = 0.25f; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 1.0f; /* disable size increment */ - auto_size_ctl.increment = 1.0f; /* disable size increment */ + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 1.0f; /* disable size decrement */ - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.upper_hr_threshold = 1.0f; /* disable size decrement */ - - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 14.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 13.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 40.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 41.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.lower_hr_threshold = 0.0f; /* disable size increment */ - auto_size_ctl.lower_hr_threshold = 0.0f; /* disable size increment */ + auto_size_ctl.increment = 2.0f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.decrement = 1.0f; /* disable size decrement */ - auto_size_ctl.upper_hr_threshold = 0.995f; - - auto_size_ctl.decrement = 1.0f; /* disable size decrement */ - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; - + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 15.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 14.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 42.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 43.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - - if(pass) { + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 4 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 4 * 1024 * 1024; - auto_size_ctl.max_size = 16 * 1024 * 1024; - auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 16 * 1024 * 1024; + auto_size_ctl.min_size = 1 * 1024 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__off; + auto_size_ctl.incr_mode = H5C_incr__off; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__off; - auto_size_ctl.decr_mode = H5C_decr__off; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; - + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 16.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 15.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force low hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 44.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* force high hit rate -- should be no response as the auto-resize * code should be disabled. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } i++; } - if((rpt_fcn_called) || - (cache_ptr->resize_enabled) || - (cache_ptr->size_increase_possible) || - (cache_ptr->size_decrease_possible) || - (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { + if ((rpt_fcn_called) || (cache_ptr->resize_enabled) || (cache_ptr->size_increase_possible) || + (cache_ptr->size_decrease_possible) || (cache_ptr->max_cache_size != (4 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (2 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 45.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now test the flash cache size increment code to verify that it * is disabled when it should be. @@ -24312,66 +23188,62 @@ check_auto_cache_resize_disable(unsigned paged) * code enabled. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 64 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 64 * 1024; - auto_size_ctl.max_size = 256 * 1024; - auto_size_ctl.min_size = 32 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 256 * 1024; + auto_size_ctl.min_size = 32 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__threshold; + auto_size_ctl.incr_mode = H5C_incr__threshold; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (2 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (2 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 1.0f; - auto_size_ctl.flash_threshold = 0.25f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 1.0f; + auto_size_ctl.flash_threshold = 0.25f; + auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; - auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = TRUE; - auto_size_ctl.max_decrement = (1 * 1024); + auto_size_ctl.apply_max_decrement = TRUE; + auto_size_ctl.max_decrement = (1 * 1024); auto_size_ctl.epochs_before_eviction = 3; - auto_size_ctl.apply_empty_reserve = TRUE; - auto_size_ctl.empty_reserve = 0.05f; - + auto_size_ctl.apply_empty_reserve = TRUE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 17.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (64 * 1024)) || - (cache_ptr->min_clean_size != (32 * 1024))) { + if ((cache_ptr->max_cache_size != (64 * 1024)) || (cache_ptr->min_clean_size != (32 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 16.\n"; } } @@ -24380,37 +23252,30 @@ check_auto_cache_resize_disable(unsigned paged) * size. Protect and unprotect an entry to allow the cache to evict * entries and get within bounds */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (64 * 1024)) || - (cache_ptr->min_clean_size != (32 * 1024)) || - (cache_ptr->index_len != 1) || - (cache_ptr->index_size != LARGE_ENTRY_SIZE) || - (rpt_fcn_called != FALSE)))) { - - HDfprintf(stdout, "\nmax_cache_size = %ld.\n", - (long)(cache_ptr->max_cache_size)); - HDfprintf(stdout, "min_clean_size = %ld.\n", - (long)(cache_ptr->min_clean_size)); - HDfprintf(stdout, "index_len = %ld.\n", - (long)(cache_ptr->index_len)); - HDfprintf(stdout, "index_size = %ld.\n", - (long)(cache_ptr->index_size)); - HDfprintf(stdout, "rpt_fcn_called = %ld.\n", - (long)(rpt_fcn_called)); + if (pass && (((cache_ptr->max_cache_size != (64 * 1024)) || + (cache_ptr->min_clean_size != (32 * 1024)) || (cache_ptr->index_len != 1) || + (cache_ptr->index_size != LARGE_ENTRY_SIZE) || (rpt_fcn_called != FALSE)))) { - pass = FALSE; + HDfprintf(stdout, "\nmax_cache_size = %ld.\n", (long)(cache_ptr->max_cache_size)); + HDfprintf(stdout, "min_clean_size = %ld.\n", (long)(cache_ptr->min_clean_size)); + HDfprintf(stdout, "index_len = %ld.\n", (long)(cache_ptr->index_len)); + HDfprintf(stdout, "index_size = %ld.\n", (long)(cache_ptr->index_size)); + HDfprintf(stdout, "rpt_fcn_called = %ld.\n", (long)(rpt_fcn_called)); + + pass = FALSE; failure_mssg = "Unexpected cache size change results 46.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now protect and unprotect a monster entry. If the flash cache * size increment code was active, this would trigger an increase. @@ -24419,58 +23284,55 @@ check_auto_cache_resize_disable(unsigned paged) * This finishes the additional tests needed for the flash cache * size increase code. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); - if(pass && - (((cache_ptr->max_cache_size != (64 * 1024)) || - (cache_ptr->min_clean_size != (32 * 1024)) || - (cache_ptr->index_len != 1) || - (cache_ptr->index_size != MONSTER_ENTRY_SIZE) || - (rpt_fcn_called != FALSE)))) { - - HDfprintf(stdout, "\nmax_cache_size = %ld.\n", - (long)(cache_ptr->max_cache_size)); - HDfprintf(stdout, "min_clean_size = %ld.\n", - (long)(cache_ptr->min_clean_size)); - HDfprintf(stdout, "index_len = %ld.\n", - (long)(cache_ptr->index_len)); - HDfprintf(stdout, "index_size = %ld.\n", - (long)(cache_ptr->index_size)); - HDfprintf(stdout, "rpt_fcn_called = %ld.\n", - (long)(rpt_fcn_called)); + if (pass && (((cache_ptr->max_cache_size != (64 * 1024)) || + (cache_ptr->min_clean_size != (32 * 1024)) || (cache_ptr->index_len != 1) || + (cache_ptr->index_size != MONSTER_ENTRY_SIZE) || (rpt_fcn_called != FALSE)))) { - pass = FALSE; + HDfprintf(stdout, "\nmax_cache_size = %ld.\n", (long)(cache_ptr->max_cache_size)); + HDfprintf(stdout, "min_clean_size = %ld.\n", (long)(cache_ptr->min_clean_size)); + HDfprintf(stdout, "index_len = %ld.\n", (long)(cache_ptr->index_len)); + HDfprintf(stdout, "index_size = %ld.\n", (long)(cache_ptr->index_size)); + HDfprintf(stdout, "rpt_fcn_called = %ld.\n", (long)(rpt_fcn_called)); + + pass = FALSE; failure_mssg = "Unexpected cache size change results 47.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_auto_cache_resize_disable() */ - /*------------------------------------------------------------------------- * Function: check_auto_cache_resize_epoch_markers() * @@ -24490,15 +23352,14 @@ check_auto_cache_resize_disable(unsigned paged) static unsigned check_auto_cache_resize_epoch_markers(unsigned paged) { - hbool_t show_progress = FALSE; - herr_t result; - int32_t i; - int32_t j; - int32_t checkpoint = 0; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_auto_size_ctl_t auto_size_ctl = - { + hbool_t show_progress = FALSE; + herr_t result; + int32_t i; + int32_t j; + int32_t checkpoint = 0; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_auto_size_ctl_t auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* H5C_auto_resize_report_fcn rpt_fcn = */ test_rpt_fcn, @@ -24512,7 +23373,6 @@ check_auto_cache_resize_epoch_markers(unsigned paged) /* int64_t epoch_length = */ 1000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -24523,10 +23383,9 @@ check_auto_cache_resize_epoch_markers(unsigned paged) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, @@ -24540,182 +23399,174 @@ check_auto_cache_resize_epoch_markers(unsigned paged) /* int32_t epochs_before_eviction = */ 3, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f - }; + /* double empty_reserve = */ 0.05f}; - if(paged) + if (paged) TESTING("automatic cache resize epoch marker management (paged aggr)") else TESTING("automatic cache resize epoch marker management") pass = TRUE; - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024))) { + if ((cache_ptr->max_cache_size != (512 * 1024)) || (cache_ptr->min_clean_size != (256 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after initialization.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Now make sure that we are managing the epoch markers correctly. */ - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__off; - auto_size_ctl.incr_mode = H5C_incr__off; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.upper_hr_threshold = 0.995f; - - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 10; - auto_size_ctl.apply_empty_reserve = FALSE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = FALSE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 2.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 1.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Since we just created the cache, there should be no epoch markers * active. Verify that this is true. */ - if(pass) { + if (pass) { - if(cache_ptr->epoch_markers_active != 0) { + if (cache_ptr->epoch_markers_active != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 1.\n"; } } - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, MEDIUM_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024)) || - (cache_ptr->index_size != (1 * 1000 * MEDIUM_ENTRY_SIZE))) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || + (cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024)) || + (cache_ptr->index_size != (1 * 1000 * MEDIUM_ENTRY_SIZE))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 0.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); - + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { j = 2; - while(pass && (j <= 10)) - { + while (pass && (j <= 10)) { rpt_fcn_called = FALSE; - i = (j - 2) * 1000; - while(pass && (i < (j - 1) * 1000)) - { + i = (j - 2) * 1000; + while (pass && (i < (j - 1) * 1000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->epoch_markers_active != j)) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->epoch_markers_active != j)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 2.\n"; } @@ -24723,116 +23574,112 @@ check_auto_cache_resize_epoch_markers(unsigned paged) } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* we now have a full complement of epoch markers -- see if * we get the expected reduction. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 9000; - while(pass && (i < 10000)) - { + i = 9000; + while (pass && (i < 10000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != - (10 * 1000 * SMALL_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) || - (cache_ptr->min_clean_size != - ((10 * 1000 * SMALL_ENTRY_SIZE + MEDIUM_ENTRY_SIZE) / 2)) || - (cache_ptr->index_size != - (10 * 1000 * SMALL_ENTRY_SIZE + MEDIUM_ENTRY_SIZE))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || + (cache_ptr->max_cache_size != (10 * 1000 * SMALL_ENTRY_SIZE + MEDIUM_ENTRY_SIZE)) || + (cache_ptr->min_clean_size != ((10 * 1000 * SMALL_ENTRY_SIZE + MEDIUM_ENTRY_SIZE) / 2)) || + (cache_ptr->index_size != (10 * 1000 * SMALL_ENTRY_SIZE + MEDIUM_ENTRY_SIZE))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 1.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* now reduce the epochs before eviction, and see if the cache * deletes the extra markers */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; - - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + if (pass) { - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; - auto_size_ctl.incr_mode = H5C_incr__off; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.incr_mode = H5C_incr__off; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.increment = 2.0f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.decr_mode = H5C_decr__age_out; + auto_size_ctl.decr_mode = H5C_decr__age_out; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decrement = 0.5f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 1; - auto_size_ctl.apply_empty_reserve = FALSE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = FALSE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 3.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 2.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* There should be exactly one active epoch marker at present. */ - if(pass) { + if (pass) { - if(cache_ptr->epoch_markers_active != 1) { + if (cache_ptr->epoch_markers_active != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 3.\n"; } } @@ -24841,40 +23688,38 @@ check_auto_cache_resize_epoch_markers(unsigned paged) * not accessed in this epoch gets evicted, and the cache size * is reduced. */ - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 9000; - while(pass && (i < 10000)) - { + i = 9000; + while (pass && (i < 10000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != decrease) || - (cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024)) || - (cache_ptr->index_size != (1 * 1000 * SMALL_ENTRY_SIZE))) { + if ((!rpt_fcn_called) || (rpt_status != decrease) || (cache_ptr->max_cache_size != (512 * 1024)) || + (cache_ptr->min_clean_size != (256 * 1024)) || + (cache_ptr->index_size != (1 * 1000 * SMALL_ENTRY_SIZE))) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 2.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* There should be exactly one active epoch marker at present... */ - if(pass) { + if (pass) { - if(cache_ptr->epoch_markers_active != 1) { + if (cache_ptr->epoch_markers_active != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 4.\n"; } } @@ -24882,175 +23727,169 @@ check_auto_cache_resize_epoch_markers(unsigned paged) /* shift the decrement mode to threshold, and verify that we remove * all epoch markers. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + if (pass) { - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.incr_mode = H5C_incr__off; + auto_size_ctl.incr_mode = H5C_incr__off; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__threshold; - auto_size_ctl.decr_mode = H5C_decr__threshold; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 1; - auto_size_ctl.apply_empty_reserve = FALSE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = FALSE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 4.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { + if ((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after set resize re-config 3.\n"; } } /* ... and now there should be none. */ - if(pass) { + if (pass) { - if(cache_ptr->epoch_markers_active != 0) { + if (cache_ptr->epoch_markers_active != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 5.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* shift the decrement mode to age out with threshold. Set epochs * before eviction to 10 again. */ - if(pass) { - - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; - - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + if (pass) { - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; - auto_size_ctl.incr_mode = H5C_incr__off; + auto_size_ctl.epoch_length = 1000; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.incr_mode = H5C_incr__off; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.increment = 2.0f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; - auto_size_ctl.upper_hr_threshold = 0.995f; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decrement = 0.5f; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 10; - auto_size_ctl.apply_empty_reserve = FALSE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = FALSE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 5.\n"; } } /* Verify that there are no active epoch markers. */ - if(pass) { + if (pass) { - if(cache_ptr->epoch_markers_active != 0) { + if (cache_ptr->epoch_markers_active != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 6.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* build up a full set of epoch markers. */ - if(pass) { + if (pass) { j = 1; - while(pass && (j <= 10)) - { + while (pass && (j <= 10)) { rpt_fcn_called = FALSE; - i = (j - 1) * 1000; - while(pass && (i < j * 1000)) - { + i = (j - 1) * 1000; + while (pass && (i < j * 1000)) { protect_entry(file_ptr, SMALL_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, SMALL_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } i++; } - if((!rpt_fcn_called) || - (rpt_status != in_spec) || - (cache_ptr->epoch_markers_active != j)) { + if ((!rpt_fcn_called) || (rpt_status != in_spec) || (cache_ptr->epoch_markers_active != j)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 7.\n"; } @@ -25058,15 +23897,16 @@ check_auto_cache_resize_epoch_markers(unsigned paged) } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* Verify that there are now 10 active epoch markers. */ - if(pass) { + if (pass) { - if(cache_ptr->epoch_markers_active != 10) { + if (cache_ptr->epoch_markers_active != 10) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 8.\n"; } } @@ -25074,109 +23914,112 @@ check_auto_cache_resize_epoch_markers(unsigned paged) /* shift the decrement mode to off. This should cause all epoch * markers to be removed. */ - if(pass) { + if (pass) { - auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - auto_size_ctl.rpt_fcn = test_rpt_fcn; + auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + auto_size_ctl.rpt_fcn = test_rpt_fcn; - auto_size_ctl.set_initial_size = TRUE; - auto_size_ctl.initial_size = 8 * 1024 * 1024; + auto_size_ctl.set_initial_size = TRUE; + auto_size_ctl.initial_size = 8 * 1024 * 1024; - auto_size_ctl.min_clean_fraction = 0.5f; + auto_size_ctl.min_clean_fraction = 0.5f; - auto_size_ctl.max_size = 8 * 1024 * 1024; - auto_size_ctl.min_size = 512 * 1024; + auto_size_ctl.max_size = 8 * 1024 * 1024; + auto_size_ctl.min_size = 512 * 1024; - auto_size_ctl.epoch_length = 1000; + auto_size_ctl.epoch_length = 1000; + auto_size_ctl.incr_mode = H5C_incr__off; - auto_size_ctl.incr_mode = H5C_incr__off; + auto_size_ctl.lower_hr_threshold = 0.75f; - auto_size_ctl.lower_hr_threshold = 0.75f; + auto_size_ctl.increment = 2.0f; - auto_size_ctl.increment = 2.0f; + auto_size_ctl.apply_max_increment = TRUE; + auto_size_ctl.max_increment = (4 * 1024 * 1024); - auto_size_ctl.apply_max_increment = TRUE; - auto_size_ctl.max_increment = (4 * 1024 * 1024); + auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + auto_size_ctl.flash_multiple = 2.0f; + auto_size_ctl.flash_threshold = 0.5f; - auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - auto_size_ctl.flash_multiple = 2.0f; - auto_size_ctl.flash_threshold = 0.5f; + auto_size_ctl.decr_mode = H5C_decr__off; + auto_size_ctl.upper_hr_threshold = 0.995f; - auto_size_ctl.decr_mode = H5C_decr__off; + auto_size_ctl.decrement = 0.5f; - auto_size_ctl.upper_hr_threshold = 0.995f; - - auto_size_ctl.decrement = 0.5f; - - auto_size_ctl.apply_max_decrement = FALSE; - auto_size_ctl.max_decrement = (1 * 1024 * 1024); + auto_size_ctl.apply_max_decrement = FALSE; + auto_size_ctl.max_decrement = (1 * 1024 * 1024); auto_size_ctl.epochs_before_eviction = 10; - auto_size_ctl.apply_empty_reserve = FALSE; - auto_size_ctl.empty_reserve = 0.05f; + auto_size_ctl.apply_empty_reserve = FALSE; + auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 6.\n"; } } /* Verify that there are now no active epoch markers. */ - if(pass) { + if (pass) { - if(cache_ptr->epoch_markers_active != 0) { + if (cache_ptr->epoch_markers_active != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected # of epoch markers 9.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); /* verify that we still have the expected number of entries in the cache, * and that the cache is of the expected size. */ - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (4 * 1024 * 1024))|| - (cache_ptr->index_size != (10 * 1000 * SMALL_ENTRY_SIZE)) || - (cache_ptr->index_len != 10000)) { + if ((cache_ptr->max_cache_size != (8 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (4 * 1024 * 1024)) || + (cache_ptr->index_size != (10 * 1000 * SMALL_ENTRY_SIZE)) || (cache_ptr->index_len != 10000)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache size change results 3.\n"; } } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(show_progress) HDfprintf(stderr, "check point %d\n", checkpoint++); + if (show_progress) + HDfprintf(stderr, "check point %d\n", checkpoint++); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_auto_cache_resize_epoch_markers() */ - /*------------------------------------------------------------------------- * Function: check_auto_cache_resize_input_errs() * @@ -25201,11 +24044,10 @@ check_auto_cache_resize_epoch_markers(unsigned paged) static unsigned check_auto_cache_resize_input_errs(unsigned paged) { - herr_t result; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_auto_size_ctl_t ref_auto_size_ctl = - { + herr_t result; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_auto_size_ctl_t ref_auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* H5C_auto_resize_report_fcn rpt_fcn = */ test_rpt_fcn, @@ -25219,7 +24061,6 @@ check_auto_cache_resize_input_errs(unsigned paged) /* int64_t epoch_length = */ 1000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -25230,10 +24071,9 @@ check_auto_cache_resize_input_errs(unsigned paged) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, @@ -25247,13 +24087,12 @@ check_auto_cache_resize_input_errs(unsigned paged) /* int32_t epochs_before_eviction = */ 3, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f - }; + /* double empty_reserve = */ 0.05f}; H5C_auto_size_ctl_t invalid_auto_size_ctl; H5C_auto_size_ctl_t test_auto_size_ctl; - if(paged) + if (paged) TESTING("automatic cache resize input errors (paged aggregation)") else TESTING("automatic cache resize input errors") @@ -25266,2326 +24105,2153 @@ check_auto_cache_resize_input_errs(unsigned paged) * and that the configuration is not modified. */ - if(pass) { + if (pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &ref_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (512 * 1024)) || - (cache_ptr->min_clean_size != (256 * 1024))) { + if ((cache_ptr->max_cache_size != (512 * 1024)) || (cache_ptr->min_clean_size != (256 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after initialization.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 1."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 1."; } } - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; - - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + if (pass) { - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.lower_hr_threshold = 0.7f; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.lower_hr_threshold = 0.7f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decrement = 0.5f; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(NULL, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted NULL cache_ptr.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted NULL cache_ptr.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 2."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 2."; } } - /* check bad version rejection. */ - if(pass) { - - invalid_auto_size_ctl.version = -1; /* INVALID */ - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = -1; /* INVALID */ + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.7f; + invalid_auto_size_ctl.lower_hr_threshold = 0.7f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad version.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad version.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 3."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 3."; } } - /* check bad initial size rejection */ - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 16 * 1024 * 1024 + 1; - /* INVALID */ + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 16 * 1024 * 1024 + 1; + /* INVALID */ - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad init size 1.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad init size 1.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 4."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 4."; } } - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 1 * 1024 * 1024 - 1; - /* INVALID */ + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 1 * 1024 * 1024 - 1; + /* INVALID */ - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad init size 2.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad init size 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 5."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 5."; } } - /* test for invalid min clean fraction rejection. */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 1.00001f; /* INVALID */ + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 1.00001f; /* INVALID */ - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad min clean frac 1.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad min clean frac 1.\n"; } } - if(pass) { - - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + if (pass) { - if(result != SUCCEED) { + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - pass = FALSE; - failure_mssg = "H5C_get_cache_auto_resize_config failed 6."; + if (result != SUCCEED) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { + pass = FALSE; + failure_mssg = "H5C_get_cache_auto_resize_config failed 6."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 6."; } } - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = -0.00001f; /* INVALID */ + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = -0.00001f; /* INVALID */ - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad min clean frac 2.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad min clean frac 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 7."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 7."; } } - /* test for invalid max_size and/or min_size rejection */ - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.max_size = H5C__MAX_MAX_CACHE_SIZE + 1; - /* INVALID */ - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = H5C__MAX_MAX_CACHE_SIZE + 1; + /* INVALID */ + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad max_size.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad max_size.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 8."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 8."; } } - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.max_size = 1 * 1024 * 1024;/* INVALID */ - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024 + 1;/*PAIR */ + invalid_auto_size_ctl.max_size = 1 * 1024 * 1024; /* INVALID */ + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024 + 1; /*PAIR */ - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad size pair.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad size pair.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 9."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 9."; } } - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = H5C__MIN_MAX_CACHE_SIZE - 1; - /* INVALID */ - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = H5C__MIN_MAX_CACHE_SIZE - 1; + /* INVALID */ + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad min_size.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad min_size.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 10."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 10."; } } - /* test for invalid epoch_length rejection */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = H5C__MAX_AR_EPOCH_LENGTH + 1; - /* INVALID */ + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.epoch_length = H5C__MAX_AR_EPOCH_LENGTH + 1; + /* INVALID */ - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decrement = 0.9f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad epoch len 1.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad epoch len 1.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 11."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 11."; } } - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = H5C__MIN_AR_EPOCH_LENGTH - 1; - /* INVALID */ + invalid_auto_size_ctl.epoch_length = H5C__MIN_AR_EPOCH_LENGTH - 1; + /* INVALID */ - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad epoch len 2.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad epoch len 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 12."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 12."; } } - /* test for bad incr_mode rejection */ - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = (enum H5C_cache_incr_mode) - 1; /* INVALID */ - invalid_auto_size_ctl.incr_mode = - (enum H5C_cache_incr_mode) -1; /* INVALID */ + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad incr_mode 1.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad incr_mode 1.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 13."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 13."; } } - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = (enum H5C_cache_incr_mode)2; /* INVALID */ - invalid_auto_size_ctl.incr_mode = - (enum H5C_cache_incr_mode) 2; /* INVALID */ + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad incr_mode 2.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad incr_mode 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 14."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 14."; } } - /* check for bad upper and/or lower threshold rejection */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.7f; + invalid_auto_size_ctl.lower_hr_threshold = 0.7f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 1.01f; /* INVALID */ - invalid_auto_size_ctl.upper_hr_threshold = 1.01f; /* INVALID */ + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad upper threshold.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad upper threshold.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 15."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 15."; } } - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.8f; /* INVALID */ + invalid_auto_size_ctl.lower_hr_threshold = 0.8f; /* INVALID */ - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.7f; /* INVALID */ - invalid_auto_size_ctl.upper_hr_threshold = 0.7f; /* INVALID */ + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad threshold pair.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad threshold pair.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 16."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 16."; } } - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.5f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.5f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = -0.0001f; /* INVALID */ + invalid_auto_size_ctl.lower_hr_threshold = -0.0001f; /* INVALID */ - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.decrement = 0.5f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad lower threshold.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad lower threshold.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 17."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 17."; } } - /* test for bad increment rejection */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; - - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + if (pass) { - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.increment = 0.99999f; /* INVALID */ + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.increment = 0.99999f; /* INVALID */ - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decrement = 0.5f; + invalid_auto_size_ctl.decrement = 0.5f; - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; - + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad increment.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad increment.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 18."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 18."; } } /* test for bad flash_incr_mode rejection */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = - (enum H5C_cache_flash_incr_mode) -1; /* INVALID */ - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = (enum H5C_cache_flash_incr_mode) - 1; /* INVALID */ + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad flash_incr_mode.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad flash_incr_mode.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 19."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 19."; } } /* test for bad flash_multiple rejection */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = - H5C_flash_incr__add_space; - invalid_auto_size_ctl.flash_multiple = 0.09f; /* INVALID */ - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__add_space; + invalid_auto_size_ctl.flash_multiple = 0.09f; /* INVALID */ + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad flash_multiple(1).\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad flash_multiple(1).\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 20."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 20."; } } - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = - H5C_flash_incr__add_space; - invalid_auto_size_ctl.flash_multiple = 10.01f; /* INVALID */ - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__add_space; + invalid_auto_size_ctl.flash_multiple = 10.01f; /* INVALID */ + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad flash_multiple(2).\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad flash_multiple(2).\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 21."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 21."; } } /* test for bad flash_threshold rejection */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = - H5C_flash_incr__add_space; - invalid_auto_size_ctl.flash_multiple = 1.0f; - invalid_auto_size_ctl.flash_threshold = 0.09f; /* INVALID */ + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__add_space; + invalid_auto_size_ctl.flash_multiple = 1.0f; + invalid_auto_size_ctl.flash_threshold = 0.09f; /* INVALID */ + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad flash_threshold(1).\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad flash_threshold(1).\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 22."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 22."; } } - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = - H5C_flash_incr__add_space; - invalid_auto_size_ctl.flash_multiple = 1.0f; - invalid_auto_size_ctl.flash_threshold = 1.001f; /* INVALID */ + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__add_space; + invalid_auto_size_ctl.flash_multiple = 1.0f; + invalid_auto_size_ctl.flash_threshold = 1.001f; /* INVALID */ + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad flash_threshold(2).\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad flash_threshold(2).\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 23."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 23."; } } - /* test for bad decr_mode rejection */ - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = (enum H5C_cache_decr_mode) - 1; /* INVALID */ + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = - (enum H5C_cache_decr_mode) -1; /* INVALID */ + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad decr_mode 1.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad decr_mode 1.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 24."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 24."; } } - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = (enum H5C_cache_decr_mode)4; /* INVALID */ + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = - (enum H5C_cache_decr_mode) 4; /* INVALID */ + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad decr_mode 2.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad decr_mode 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 25."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 25."; } } - /* check for bad decrement rejection */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 1.000001f; /* INVALID */ - invalid_auto_size_ctl.decrement = 1.000001f; /* INVALID */ - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad decrement 1.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad decrement 1.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 26."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 26."; } } - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = -0.000001f; /* INVALID */ - invalid_auto_size_ctl.decrement = -0.000001f; /* INVALID */ - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_set_cache_auto_resize_config accepted bad decrement 2.\n"; + pass = FALSE; + failure_mssg = "H5C_set_cache_auto_resize_config accepted bad decrement 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 27."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 27."; } } - /* check for rejection of bad epochs_before_eviction */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; - - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + if (pass) { - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.decr_mode = H5C_decr__age_out; + invalid_auto_size_ctl.decr_mode = H5C_decr__age_out; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decrement = 0.9f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 0; /* INVALID */ - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config accepted bad epochs_before_eviction 1.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 28."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 28."; } } - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; - invalid_auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.decrement = 0.9f; + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.epochs_before_eviction = H5C__MAX_EPOCH_MARKERS + 1; /* INVALID */ - invalid_auto_size_ctl.epochs_before_eviction = - H5C__MAX_EPOCH_MARKERS + 1; /* INVALID */ - - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config accepted bad epochs_before_eviction 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 29."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 29."; } } - /* Check for bad apply_empty_reserve rejection */ - if(pass) { - - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + if (pass) { - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.epoch_length = 5000; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__age_out; - invalid_auto_size_ctl.decr_mode = H5C_decr__age_out; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.decrement = 0.9f; - - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); invalid_auto_size_ctl.epochs_before_eviction = 3; - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = -0.0000001f; /* INVALID */ + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = -0.0000001f; /* INVALID */ result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config accepted bad empty_reserve 1.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 30."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 30."; } } - if(pass) { + if (pass) { - invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - invalid_auto_size_ctl.rpt_fcn = NULL; + invalid_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + invalid_auto_size_ctl.rpt_fcn = NULL; - invalid_auto_size_ctl.set_initial_size = TRUE; - invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; + invalid_auto_size_ctl.set_initial_size = TRUE; + invalid_auto_size_ctl.initial_size = 4 * 1024 * 1024; - invalid_auto_size_ctl.min_clean_fraction = 0.1f; + invalid_auto_size_ctl.min_clean_fraction = 0.1f; - invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; - invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; + invalid_auto_size_ctl.max_size = 16 * 1024 * 1024; + invalid_auto_size_ctl.min_size = 1 * 1024 * 1024; - invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.epoch_length = 5000; + invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; - invalid_auto_size_ctl.incr_mode = H5C_incr__threshold; + invalid_auto_size_ctl.lower_hr_threshold = 0.75f; - invalid_auto_size_ctl.lower_hr_threshold = 0.75f; + invalid_auto_size_ctl.increment = 2.0f; - invalid_auto_size_ctl.increment = 2.0f; + invalid_auto_size_ctl.apply_max_increment = TRUE; + invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); - invalid_auto_size_ctl.apply_max_increment = TRUE; - invalid_auto_size_ctl.max_increment = (2 * 1024 * 1024); + invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; + invalid_auto_size_ctl.flash_multiple = 2.0f; + invalid_auto_size_ctl.flash_threshold = 0.5f; - invalid_auto_size_ctl.flash_incr_mode = H5C_flash_incr__off; - invalid_auto_size_ctl.flash_multiple = 2.0f; - invalid_auto_size_ctl.flash_threshold = 0.5f; + invalid_auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + invalid_auto_size_ctl.upper_hr_threshold = 0.999f; - invalid_auto_size_ctl.decr_mode = H5C_decr__age_out_with_threshold; + invalid_auto_size_ctl.decrement = 0.9f; - invalid_auto_size_ctl.upper_hr_threshold = 0.999f; + invalid_auto_size_ctl.apply_max_decrement = TRUE; + invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); - invalid_auto_size_ctl.decrement = 0.9f; + invalid_auto_size_ctl.epochs_before_eviction = H5C__MAX_EPOCH_MARKERS + 1; /* INVALID */ - invalid_auto_size_ctl.apply_max_decrement = TRUE; - invalid_auto_size_ctl.max_decrement = (1 * 1024 * 1024); - - invalid_auto_size_ctl.epochs_before_eviction = - H5C__MAX_EPOCH_MARKERS + 1; /* INVALID */ - - invalid_auto_size_ctl.apply_empty_reserve = TRUE; - invalid_auto_size_ctl.empty_reserve = 0.05f; + invalid_auto_size_ctl.apply_empty_reserve = TRUE; + invalid_auto_size_ctl.empty_reserve = 0.05f; result = H5C_set_cache_auto_resize_config(cache_ptr, &invalid_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config accepted bad empty_reserve 2.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config(cache_ptr, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed 31."; + } + else if (!resize_configs_are_equal(&test_auto_size_ctl, &ref_auto_size_ctl, FALSE)) { - } else if(!resize_configs_are_equal(&test_auto_size_ctl, \ - &ref_auto_size_ctl, FALSE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected auto resize config 31."; } } - /* finally, before we finish, try feeding * H5C_get_cache_auto_resize_config invalid data. */ - if(pass) { + if (pass) { result = H5C_get_cache_auto_resize_config(NULL, &test_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_get_cache_auto_resize_config accepted NULL cache_ptr.\n"; + pass = FALSE; + failure_mssg = "H5C_get_cache_auto_resize_config accepted NULL cache_ptr.\n"; } } - if(pass) { + if (pass) { - result = H5C_get_cache_auto_resize_config((const H5C_t *)&test_auto_size_ctl, - &test_auto_size_ctl); + result = H5C_get_cache_auto_resize_config((const H5C_t *)&test_auto_size_ctl, &test_auto_size_ctl); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_get_cache_auto_resize_config accepted bad cache_ptr.\n"; + pass = FALSE; + failure_mssg = "H5C_get_cache_auto_resize_config accepted bad cache_ptr.\n"; } } - if(pass) { + if (pass) { result = H5C_get_cache_auto_resize_config(cache_ptr, NULL); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; - failure_mssg = - "H5C_get_cache_auto_resize_config accepted NULL config ptr.\n"; + pass = FALSE; + failure_mssg = "H5C_get_cache_auto_resize_config accepted NULL config ptr.\n"; } } - if(cache_ptr) { + if (cache_ptr) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_auto_cache_resize_input_errs() */ - /*------------------------------------------------------------------------- * Function: check_auto_cache_resize_aux_fcns() * @@ -27610,17 +26276,16 @@ check_auto_cache_resize_input_errs(unsigned paged) static unsigned check_auto_cache_resize_aux_fcns(unsigned paged) { - herr_t result; - int32_t i; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - double hit_rate; - size_t max_size; - size_t min_clean_size; - size_t cur_size; - uint32_t cur_num_entries; - H5C_auto_size_ctl_t auto_size_ctl = - { + herr_t result; + int32_t i; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + double hit_rate; + size_t max_size; + size_t min_clean_size; + size_t cur_size; + uint32_t cur_num_entries; + H5C_auto_size_ctl_t auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, #if 1 /* H5C_auto_resize_report_fcn rpt_fcn = */ NULL, @@ -27637,7 +26302,6 @@ check_auto_cache_resize_aux_fcns(unsigned paged) /* int64_t epoch_length = */ 50000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, /* double lower_hr_threshold = */ 0.75f, @@ -27648,10 +26312,9 @@ check_auto_cache_resize_aux_fcns(unsigned paged) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, @@ -27668,8 +26331,7 @@ check_auto_cache_resize_aux_fcns(unsigned paged) /* double empty_reserve = */ 0.5f }; - - if(paged) + if (paged) TESTING("automatic cache resize auxilary functions (paged aggregation)") else TESTING("automatic cache resize auxilary functions") @@ -27679,31 +26341,30 @@ check_auto_cache_resize_aux_fcns(unsigned paged) /* allocate a cache, and then test the various auxilary functions. */ - if(pass) { + if (pass) { reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; } - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(pass) { + if (pass) { - if((cache_ptr->max_cache_size != (1 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (512 * 1024))) { + if ((cache_ptr->max_cache_size != (1 * 1024 * 1024)) || (cache_ptr->min_clean_size != (512 * 1024))) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad cache size after initialization.\n"; } } @@ -27712,42 +26373,40 @@ check_auto_cache_resize_aux_fcns(unsigned paged) * H5C_reset_cache_hit_rate_stats() pair. */ - if(pass) { + if (pass) { - if((H5C_get_cache_hit_rate(NULL, &hit_rate) != FAIL) || - (H5C_get_cache_hit_rate(cache_ptr, NULL) != FAIL)) { + if ((H5C_get_cache_hit_rate(NULL, &hit_rate) != FAIL) || + (H5C_get_cache_hit_rate(cache_ptr, NULL) != FAIL)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate accepts bad params.\n"; } } - if(pass) { + if (pass) { result = H5C_get_cache_hit_rate(cache_ptr, &hit_rate); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate failed.\n"; + } + else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f)) { /* i.e. hit_rate != 0.0 */ - } else if(!H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f)) { /* i.e. hit_rate != 0.0 */ - - pass = FALSE; - failure_mssg = - "H5C_get_cache_hit_rate returned unexpected hit rate 1.\n"; + pass = FALSE; + failure_mssg = "H5C_get_cache_hit_rate returned unexpected hit rate 1.\n"; } } - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, PICO_ENTRY_TYPE, i); - if(pass) { + if (pass) { unprotect_entry(file_ptr, PICO_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } @@ -27755,44 +26414,40 @@ check_auto_cache_resize_aux_fcns(unsigned paged) } } - if(pass) { + if (pass) { result = H5C_get_cache_hit_rate(cache_ptr, &hit_rate); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate failed.\n"; + } + else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f)) { /* i.e. hit_rate != 0.0 */ - } else if(!H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f)) { /* i.e. hit_rate != 0.0 */ - - pass = FALSE; - failure_mssg = - "H5C_get_cache_hit_rate returned unexpected hit rate 2.\n"; - - } else if((cache_ptr->cache_accesses != 1000) || - (cache_ptr->cache_hits != 0)) { + pass = FALSE; + failure_mssg = "H5C_get_cache_hit_rate returned unexpected hit rate 2.\n"; + } + else if ((cache_ptr->cache_accesses != 1000) || (cache_ptr->cache_hits != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache hit rate stats.\n"; + } + else if (rpt_fcn_called) { - } else if(rpt_fcn_called) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Report function called?.\n"; - } } - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, PICO_ENTRY_TYPE, 0); - if(pass) { + if (pass) { unprotect_entry(file_ptr, PICO_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } @@ -27800,81 +26455,72 @@ check_auto_cache_resize_aux_fcns(unsigned paged) } } - if(pass) { + if (pass) { result = H5C_get_cache_hit_rate(cache_ptr, &hit_rate); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate failed.\n"; + } + else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.5f)) { /* i.e. hit_rate != 0.5 */ - } else if(!H5_DBL_ABS_EQUAL(hit_rate, (double)0.5f)) { /* i.e. hit_rate != 0.5 */ - - pass = FALSE; - failure_mssg = - "H5C_get_cache_hit_rate returned unexpected hit rate 3.\n"; - - } else if((cache_ptr->cache_accesses != 2000) || - (cache_ptr->cache_hits != 1000)) { + pass = FALSE; + failure_mssg = "H5C_get_cache_hit_rate returned unexpected hit rate 3.\n"; + } + else if ((cache_ptr->cache_accesses != 2000) || (cache_ptr->cache_hits != 1000)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache hit rate stats.\n"; + } + else if (rpt_fcn_called) { - } else if(rpt_fcn_called) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Report function called?.\n"; - } } - if(pass) { + if (pass) { result = H5C_reset_cache_hit_rate_stats(NULL); - if(result != FAIL) { - - pass = FALSE; - failure_mssg = - "H5C_reset_cache_hit_rate_stats accepted NULL cache_ptr.\n"; + if (result != FAIL) { - } else if((cache_ptr->cache_accesses != 2000) || - (cache_ptr->cache_hits != 1000)) { + pass = FALSE; + failure_mssg = "H5C_reset_cache_hit_rate_stats accepted NULL cache_ptr.\n"; + } + else if ((cache_ptr->cache_accesses != 2000) || (cache_ptr->cache_hits != 1000)) { - pass = FALSE; - failure_mssg = - "Failed call to H5C_reset_cache_hit_rate_stats altered stats?\n"; + pass = FALSE; + failure_mssg = "Failed call to H5C_reset_cache_hit_rate_stats altered stats?\n"; } } - if(pass) { + if (pass) { result = H5C_reset_cache_hit_rate_stats(cache_ptr); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_reset_cache_hit_rate_stats failed.\n"; + } + else if ((cache_ptr->cache_accesses != 0) || (cache_ptr->cache_hits != 0)) { - } else if((cache_ptr->cache_accesses != 0) || - (cache_ptr->cache_hits != 0)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache hit rate stats.\n"; - } } - if(pass) { + if (pass) { rpt_fcn_called = FALSE; - i = 0; - while(pass && (i < 1000)) - { + i = 0; + while (pass && (i < 1000)) { protect_entry(file_ptr, PICO_ENTRY_TYPE, i + 500); - if(pass) { + if (pass) { unprotect_entry(file_ptr, PICO_ENTRY_TYPE, i + 500, H5C__NO_FLAGS_SET); } @@ -27882,33 +26528,29 @@ check_auto_cache_resize_aux_fcns(unsigned paged) } } - - if(pass) { + if (pass) { result = H5C_get_cache_hit_rate(cache_ptr, &hit_rate); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate failed.\n"; + } + else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.5F)) { /* i.e. hit_rate != 0.5 */ - } else if(!H5_DBL_ABS_EQUAL(hit_rate, (double)0.5F)) { /* i.e. hit_rate != 0.5 */ - - pass = FALSE; - failure_mssg = - "H5C_get_cache_hit_rate returned unexpected hit rate 4.\n"; - - } else if((cache_ptr->cache_accesses != 1000) || - (cache_ptr->cache_hits != 500)) { + pass = FALSE; + failure_mssg = "H5C_get_cache_hit_rate returned unexpected hit rate 4.\n"; + } + else if ((cache_ptr->cache_accesses != 1000) || (cache_ptr->cache_hits != 500)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache hit rate stats.\n"; + } + else if (rpt_fcn_called) { - } else if(rpt_fcn_called) { - - pass = FALSE; + pass = FALSE; failure_mssg = "Report function called?.\n"; - } } @@ -27918,214 +26560,194 @@ check_auto_cache_resize_aux_fcns(unsigned paged) * H5C_get_cache_size(). ***************************************************/ - if(pass) { + if (pass) { - result = H5C_get_cache_size(NULL, &max_size, &min_clean_size, - &cur_size, &cur_num_entries); + result = H5C_get_cache_size(NULL, &max_size, &min_clean_size, &cur_size, &cur_num_entries); - if(result != FAIL) { + if (result != FAIL) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_size accepted NULL cache_ptr.\n"; } } - if(pass) { + if (pass) { max_size = 0; min_clean_size = 0; cur_size = 0; cur_num_entries = 0; - result = H5C_get_cache_size(cache_ptr, &max_size, &min_clean_size, - &cur_size, &cur_num_entries); + result = H5C_get_cache_size(cache_ptr, &max_size, &min_clean_size, &cur_size, &cur_num_entries); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_size failed 1.\n"; + } + else if (max_size != (1 * 1024 * 1024)) { - } else if(max_size != (1 * 1024 * 1024)) { - - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected max_size 1.\n"; - - } else if(min_clean_size != (512 * 1024)) { - - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected min_clean_size 1.\n"; - - } else if(cur_size != (1500 * PICO_ENTRY_SIZE)) { + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected max_size 1.\n"; + } + else if (min_clean_size != (512 * 1024)) { - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected cur_size 1.\n"; + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected min_clean_size 1.\n"; + } + else if (cur_size != (1500 * PICO_ENTRY_SIZE)) { - } else if(cur_num_entries != 1500) { + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected cur_size 1.\n"; + } + else if (cur_num_entries != 1500) { - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected cur_num_entries 1.\n"; + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected cur_num_entries 1.\n"; } } /* read a larger entry so that cur_size and cur_num_entries will be * different. */ - if(pass) { + if (pass) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); } - if(pass) { + if (pass) { unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__NO_FLAGS_SET); } - if(pass) { + if (pass) { max_size = 0; min_clean_size = 0; cur_size = 0; cur_num_entries = 0; - result = H5C_get_cache_size(cache_ptr, &max_size, &min_clean_size, - &cur_size, &cur_num_entries); + result = H5C_get_cache_size(cache_ptr, &max_size, &min_clean_size, &cur_size, &cur_num_entries); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_size failed 2.\n"; + } + else if (max_size != (1 * 1024 * 1024)) { - } else if(max_size != (1 * 1024 * 1024)) { - - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected max_size 2.\n"; - - } else if(min_clean_size != (512 * 1024)) { - - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected min_clean_size 2.\n"; - - } else if(cur_size != - ((1500 * PICO_ENTRY_SIZE) + MONSTER_ENTRY_SIZE)) { + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected max_size 2.\n"; + } + else if (min_clean_size != (512 * 1024)) { - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected cur_size 2.\n"; + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected min_clean_size 2.\n"; + } + else if (cur_size != ((1500 * PICO_ENTRY_SIZE) + MONSTER_ENTRY_SIZE)) { - } else if(cur_num_entries != 1501) { + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected cur_size 2.\n"; + } + else if (cur_num_entries != 1501) { - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected cur_num_entries 2.\n"; + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected cur_num_entries 2.\n"; } } - if(pass) { + if (pass) { - max_size = 0; + max_size = 0; result = H5C_get_cache_size(cache_ptr, &max_size, NULL, NULL, NULL); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_size failed 3.\n"; + } + else if (max_size != (1 * 1024 * 1024)) { - } else if(max_size != (1 * 1024 * 1024)) { - - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected max_size 3.\n"; - + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected max_size 3.\n"; } } - if(pass) { + if (pass) { - min_clean_size = 0; + min_clean_size = 0; - result = H5C_get_cache_size(cache_ptr, NULL, &min_clean_size, - NULL, NULL); + result = H5C_get_cache_size(cache_ptr, NULL, &min_clean_size, NULL, NULL); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_size failed 4.\n"; + } + else if (min_clean_size != (512 * 1024)) { - } else if(min_clean_size != (512 * 1024)) { - - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected min_clean_size 4.\n"; - + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected min_clean_size 4.\n"; } } - if(pass) { + if (pass) { - cur_size = 0; + cur_size = 0; result = H5C_get_cache_size(cache_ptr, NULL, NULL, &cur_size, NULL); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_size failed 5.\n"; + } + else if (cur_size != ((1500 * PICO_ENTRY_SIZE) + MONSTER_ENTRY_SIZE)) { - } else if(cur_size != - ((1500 * PICO_ENTRY_SIZE) + MONSTER_ENTRY_SIZE)) { - - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected cur_size 5.\n"; - + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected cur_size 5.\n"; } } - if(pass) { + if (pass) { cur_num_entries = 0; - result = H5C_get_cache_size(cache_ptr, NULL, NULL, NULL, - &cur_num_entries); + result = H5C_get_cache_size(cache_ptr, NULL, NULL, NULL, &cur_num_entries); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_size failed 6.\n"; + } + else if (cur_num_entries != 1501) { - } else if(cur_num_entries != 1501) { - - pass = FALSE; - failure_mssg = - "H5C_get_cache_size reports unexpected cur_num_entries 2.\n"; - + pass = FALSE; + failure_mssg = "H5C_get_cache_size reports unexpected cur_num_entries 2.\n"; } } - if(cache_ptr) { + if (cache_ptr) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_auto_cache_resize_aux_fcns() */ - /*------------------------------------------------------------------------- * Function: check_metadata_blizzard_absence() * @@ -28157,200 +26779,2750 @@ check_auto_cache_resize_aux_fcns(unsigned paged) static unsigned check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) { - int entry_type = HUGE_ENTRY_TYPE; - size_t entry_size = HUGE_ENTRY_SIZE; /* 16 KB */ - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + int entry_type = HUGE_ENTRY_TYPE; + size_t entry_size = HUGE_ENTRY_SIZE; /* 16 KB */ + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; hbool_t show_progress = FALSE; - int32_t checkpoint = 0; - int32_t entry_idx = 0; + int32_t checkpoint = 0; + int32_t entry_idx = 0; int32_t i; /* Expected deserialized status of entries depends on how they get into * the cache. Insertions = not deserialized, protect/unprotect = deserialized. */ - hbool_t deserialized = (hbool_t)!(fill_via_insertion); + hbool_t deserialized = (hbool_t) !(fill_via_insertion); /* Set up the expected array. This is used to maintain a table of the * expected status of every entry used in this test. */ - struct expected_entry_status expected[150] = - { - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { HUGE_ENTRY_TYPE, 0, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 1, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 2, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 3, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 4, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 5, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 6, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 7, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 8, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 9, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 10, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 11, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 12, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 13, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 14, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 15, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 16, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 17, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 18, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 19, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 20, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 21, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 22, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 23, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 24, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 25, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 26, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 27, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 28, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 29, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 30, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 31, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 32, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 33, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 34, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 35, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 36, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 37, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 38, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 39, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 40, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 41, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 42, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 43, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 44, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 45, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 46, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 47, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 48, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 49, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 50, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 51, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 52, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 53, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 54, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 55, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 56, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 57, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 58, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 59, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 60, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 61, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 62, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 63, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 64, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 65, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 66, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 67, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 68, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 69, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 70, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 71, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 72, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 73, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 74, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 75, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 76, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 77, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 78, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 79, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 80, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 81, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 82, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 83, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 84, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 85, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 86, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 87, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 88, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 89, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 90, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 91, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 92, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 93, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 94, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 95, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 96, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 97, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 98, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 99, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 100, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 101, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 102, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 103, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 104, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 105, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 106, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 107, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 108, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 109, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 110, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 111, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 112, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 113, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 114, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 115, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 116, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 117, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 118, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 119, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 120, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 121, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 122, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 123, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 124, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 125, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 126, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 127, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 128, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 129, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 130, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 131, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 132, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 133, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 134, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 135, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 136, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 137, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 138, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 139, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 140, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 141, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 142, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 143, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 144, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 145, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 146, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 147, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 148, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 149, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE} - }; + struct expected_entry_status expected[150] = { + /* entry entry in at main flush + dep flush dep child flush flush flush */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ + {HUGE_ENTRY_TYPE, + 0, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 1, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 2, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 3, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 4, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 5, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 6, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 7, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 8, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 9, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 10, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 11, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 12, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 13, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 14, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 15, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 16, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 17, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 18, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 19, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 20, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 21, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 22, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 23, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 24, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 25, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 26, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 27, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 28, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 29, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 30, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 31, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 32, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 33, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 34, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 35, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 36, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 37, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 38, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 39, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 40, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 41, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 42, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 43, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 44, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 45, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 46, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 47, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 48, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 49, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 50, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 51, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 52, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 53, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 54, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 55, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 56, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 57, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 58, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 59, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 60, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 61, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 62, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 63, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 64, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 65, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 66, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 67, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 68, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 69, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 70, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 71, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 72, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 73, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 74, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 75, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 76, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 77, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 78, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 79, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 80, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 81, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 82, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 83, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 84, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 85, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 86, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 87, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 88, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 89, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 90, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 91, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 92, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 93, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 94, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 95, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 96, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 97, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 98, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 99, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 100, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 101, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 102, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 103, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 104, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 105, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 106, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 107, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 108, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 109, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 110, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 111, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 112, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 113, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 114, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 115, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 116, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 117, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 118, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 119, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 120, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 121, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 122, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 123, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 124, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 125, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 126, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 127, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 128, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 129, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 130, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 131, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 132, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 133, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 134, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 135, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 136, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 137, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 138, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 139, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 140, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 141, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 142, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 143, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 144, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 145, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 146, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 147, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 148, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 149, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}}; pass = TRUE; reset_entries(); - if(fill_via_insertion) { - if(paged) + if (fill_via_insertion) { + if (paged) TESTING("to ensure metadata blizzard absence when inserting (pgd aggr)") else TESTING("to ensure metadata blizzard absence when inserting") } /* end if */ else { - if(paged) + if (paged) TESTING("to ensure metadata blizzard absence on protect/unprotect (pa)") else TESTING("to ensure metadata blizzard absence on protect/unprotect") } /* end else */ - if(show_progress) /* 0 */ - HDfprintf(stdout, "\n%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); + if (show_progress) /* 0 */ + HDfprintf(stdout, "\n%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - if(pass) { + if (pass) { /* Set up the cache. * @@ -28359,19 +29531,17 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) */ file_ptr = setup_cache((size_t)(50 * entry_size), (size_t)(25 * entry_size), paged); - if(file_ptr == NULL) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad return from cache intialization.\n"; - } else cache_ptr = file_ptr->shared->cache; } - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); /* ======================================================================== * ======================================================================== @@ -28389,7 +29559,7 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) * ======================================================================== */ - if(pass) { + if (pass) { /* Insert 26 entries (indexes 0 through 25) into the cache. * @@ -28402,28 +29572,28 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) for (entry_idx = 0; entry_idx < 26; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - - } else { + entry_type, /* int32_t type */ + entry_idx, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* Change expected values, and verify the status of the entries * after each insertion */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; expected[entry_idx].deserialized = (unsigned char)deserialized; verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -28433,9 +29603,8 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) } } - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); /* ======================================================================== * ======================================================================== @@ -28453,7 +29622,7 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) * ======================================================================== */ - if(pass) { + if (pass) { /* Insert the 27th entry (index = 26) into the cache. * @@ -28461,19 +29630,20 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) * before the insertion because it doesn't satisfy the min_clean_size * constraint. */ - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + entry_type, /* int32_t type */ + entry_idx++, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ + entry_idx++, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } @@ -28488,13 +29658,13 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) */ /* entry w/ index 0 has now been flushed and is now clean. */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; /* entry w/ index 26 is now in the cache and dirty. */ - expected[26].in_cache = TRUE; - expected[26].is_dirty = TRUE; - expected[26].deserialized = (unsigned char)deserialized; + expected[26].in_cache = TRUE; + expected[26].is_dirty = TRUE; + expected[26].deserialized = (unsigned char)deserialized; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -28503,11 +29673,10 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) expected); /* expected */ } - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - if(pass) { + if (pass) { /* Insert the 28th entry (index = 27) into the cache. * @@ -28515,17 +29684,18 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) * recently used entry before the insertion as it again does not * satisfy the min_clean_size constraint. */ - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + entry_type, /* int32_t type */ + entry_idx++, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ entry_idx++, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ @@ -28542,13 +29712,13 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) */ /* entry w/ index 1 has now been flushed and is now clean. */ - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; /* entry w/ index 27 is now in the cache and dirty. */ - expected[27].in_cache = TRUE; - expected[27].is_dirty = TRUE; - expected[27].deserialized = (unsigned char)deserialized; + expected[27].in_cache = TRUE; + expected[27].is_dirty = TRUE; + expected[27].deserialized = (unsigned char)deserialized; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -28557,29 +29727,29 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) expected); /* expected */ } - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - if(pass) { + if (pass) { /* Fill out the rest of the cache with entries */ /* Verify expected status of entries after each insertion */ for (entry_idx = entry_idx; entry_idx < 50; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + entry_type, /* int32_t type */ + entry_idx, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } @@ -28588,12 +29758,12 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) * entry currently getting inserted is now in the cache and * dirty. */ - expected[entry_idx - 26].is_dirty = FALSE; + expected[entry_idx - 26].is_dirty = FALSE; expected[entry_idx - 26].serialized = TRUE; - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; - expected[entry_idx].deserialized = (unsigned char)deserialized; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].deserialized = (unsigned char)deserialized; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -28603,16 +29773,15 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) } /* Verify that the cache is now full */ - if(cache_ptr->cache_full != TRUE) { + if (cache_ptr->cache_full != TRUE) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not completely filled.\n"; } } - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); /* ======================================================================== * ======================================================================== @@ -28632,24 +29801,25 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) * ======================================================================== */ - if(pass) { + if (pass) { /* Insert the 51st entry (index = 50) into the cache. * * The cache is full prior to the insertion, so it will * have to evict in order to make room for the new entry. */ - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + entry_type, /* int32_t type */ + entry_idx++, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ entry_idx++, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ @@ -28664,19 +29834,19 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) */ /* entry w/ index 0 has been evicted. */ - expected[0].in_cache = FALSE; - expected[0].destroyed = TRUE; + expected[0].in_cache = FALSE; + expected[0].destroyed = TRUE; /* entries w/ indices 24,25 have now been flushed and are clean. */ - expected[24].is_dirty = FALSE; - expected[24].serialized = TRUE; - expected[25].is_dirty = FALSE; - expected[25].serialized = TRUE; + expected[24].is_dirty = FALSE; + expected[24].serialized = TRUE; + expected[25].is_dirty = FALSE; + expected[25].serialized = TRUE; /* entry w/ index 50 is now in the cache and dirty */ - expected[50].in_cache = TRUE; - expected[50].is_dirty = TRUE; - expected[50].deserialized = (unsigned char)deserialized; + expected[50].in_cache = TRUE; + expected[50].is_dirty = TRUE; + expected[50].deserialized = (unsigned char)deserialized; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -28685,12 +29855,10 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) expected); /* expected */ } - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - - if(pass) { + if (pass) { /* Insert 49 more entries (indices 51-99) into the cache. * @@ -28702,38 +29870,39 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) */ for (entry_idx = entry_idx; entry_idx < 100; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ + entry_type, /* int32_t type */ entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* This past inserted entry is now in the cache and dirty */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; - expected[entry_idx].deserialized = (unsigned char)deserialized; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].deserialized = (unsigned char)deserialized; /* The entry inserted 50 insertions ago has been evicted */ - expected[entry_idx - 50].in_cache = FALSE; - expected[entry_idx - 50].destroyed = TRUE; + expected[entry_idx - 50].in_cache = FALSE; + expected[entry_idx - 50].destroyed = TRUE; /* If the newly inserted entry is among the first 24 * insertions in this loop, then the insertion will * have resulted in a flush of the entry inserted * 25 insertions ago. */ - if(entry_idx < 75) { + if (entry_idx < 75) { - expected[entry_idx - 25].is_dirty = FALSE; + expected[entry_idx - 25].is_dirty = FALSE; expected[entry_idx - 25].serialized = TRUE; } /* If the newly inserted entry is among the last @@ -28745,7 +29914,7 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) * flush-then-evict, it switches to evict-then-flush. */ else { - expected[entry_idx - 26].is_dirty = FALSE; + expected[entry_idx - 26].is_dirty = FALSE; expected[entry_idx - 26].serialized = TRUE; } @@ -28757,9 +29926,8 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) } } - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); /* ======================================================================== * ======================================================================== @@ -28782,7 +29950,7 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) * ======================================================================== */ - if(pass) { + if (pass) { /* Flush the cache. * @@ -28792,9 +29960,9 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) */ flush_cache(file_ptr, /* H5F_t * file_ptr */ - FALSE, /* hbool_t destory_entries */ - FALSE, /* hbool_t dump_stats */ - FALSE); /* hbool_t dump_detailed_stats */ + FALSE, /* hbool_t destory_entries */ + FALSE, /* hbool_t dump_stats */ + FALSE); /* hbool_t dump_detailed_stats */ /* Verify that the cache is clean */ verify_clean(); @@ -28808,7 +29976,7 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) /* entries w/ indices 74-99 have been flushed. */ for (i = 74; i < 100; i++) { - expected[i].is_dirty = FALSE; + expected[i].is_dirty = FALSE; expected[i].serialized = TRUE; } verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -28817,11 +29985,10 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) expected); /* expected */ } - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - if(pass) { + if (pass) { /* Insert 26 entries (indexes 100 through 125) into the cache. * @@ -28832,31 +29999,31 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) for (entry_idx = 100; entry_idx < 126; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - - } else { + entry_type, /* int32_t type */ + entry_idx, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* This past inserted entry is now in the cache and dirty */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; - expected[entry_idx].deserialized = (unsigned char)deserialized; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].deserialized = (unsigned char)deserialized; /* The entry with ID minus 50 will have been evicted */ - expected[entry_idx - 50].in_cache = FALSE; - expected[entry_idx - 50].destroyed = TRUE; + expected[entry_idx - 50].in_cache = FALSE; + expected[entry_idx - 50].destroyed = TRUE; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -28866,26 +30033,26 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) } } - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - if(pass) { + if (pass) { /* Insert the 127th entry (index = 126) into the cache. */ - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + entry_type, /* int32_t type */ + entry_idx++, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ + entry_idx++, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } @@ -28898,62 +30065,61 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) */ /* entry w/ index 76 has been evicted. */ - expected[76].in_cache = FALSE; - expected[76].destroyed = TRUE; + expected[76].in_cache = FALSE; + expected[76].destroyed = TRUE; /* entry w/ index 100 has now been flushed and is now clean. */ - expected[100].is_dirty = FALSE; - expected[100].serialized = TRUE; + expected[100].is_dirty = FALSE; + expected[100].serialized = TRUE; /* entry w/ index 26 is now in the cache and dirty. */ - expected[126].in_cache = TRUE; - expected[126].is_dirty = TRUE; - expected[126].deserialized = (unsigned char)deserialized; + expected[126].in_cache = TRUE; + expected[126].is_dirty = TRUE; + expected[126].deserialized = (unsigned char)deserialized; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - 126, /* int tag */ + 126, /* int tag */ 150, /* int num_entries */ expected); /* expected */ } - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - if(pass) { + if (pass) { /* Insert entries w/ indices 127 through 149 into the cache */ for (entry_idx = 127; entry_idx < 150; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - - } else { + entry_type, /* int32_t type */ + entry_idx, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* This past inserted entry is now in the cache and dirty */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; - expected[entry_idx].deserialized = (unsigned char)deserialized; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].deserialized = (unsigned char)deserialized; /* The entry with ID minus 50 will have been evicted */ - expected[entry_idx - 50].in_cache = FALSE; - expected[entry_idx - 50].destroyed = TRUE; + expected[entry_idx - 50].in_cache = FALSE; + expected[entry_idx - 50].destroyed = TRUE; /* The entry with ID minus 26 will now be clean */ - expected[entry_idx - 26].is_dirty = FALSE; + expected[entry_idx - 26].is_dirty = FALSE; expected[entry_idx - 26].serialized = TRUE; /* verify the status */ @@ -28962,31 +30128,32 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) 150, /* int num_entries */ expected); /* struct expected_entry_staus[] */ } - } - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - if(cache_ptr) { + if (cache_ptr) { /* We're done with testing. We can take down the cache. */ takedown_cache(file_ptr, FALSE, FALSE); reset_entries(); } - if(show_progress) /* 12 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - FUNC, checkpoint++, pass); + if (show_progress) /* 12 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", FUNC, checkpoint++, pass); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } return (unsigned)!pass; } /* check_metadata_blizzard_absence() */ - /*------------------------------------------------------------------------- * Function: check_flush_deps() * @@ -29003,23 +30170,108 @@ check_metadata_blizzard_absence(hbool_t fill_via_insertion, unsigned paged) static unsigned check_flush_deps(unsigned paged) { - H5F_t * file_ptr = NULL; /* File for this test */ - H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ - test_entry_t *base_addr; /* Base address of entries for test */ - int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ - unsigned u; /* Local index variable */ - struct expected_entry_status expected[5] = - { - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { PICO_ENTRY_TYPE, 0, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { PICO_ENTRY_TYPE, 1, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { PICO_ENTRY_TYPE, 2, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { PICO_ENTRY_TYPE, 3, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { PICO_ENTRY_TYPE, 4, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE} - }; - - if(paged) + H5F_t * file_ptr = NULL; /* File for this test */ + H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ + test_entry_t *base_addr; /* Base address of entries for test */ + int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ + unsigned u; /* Local index variable */ + struct expected_entry_status expected[5] = { + /* entry entry in at main flush dep flush dep child flush flush flush + */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ + {PICO_ENTRY_TYPE, + 0, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {PICO_ENTRY_TYPE, + 1, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {PICO_ENTRY_TYPE, + 2, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {PICO_ENTRY_TYPE, + 3, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {PICO_ENTRY_TYPE, + 4, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}}; + + if (paged) TESTING("flush dependencies (paged aggregation)") else TESTING("flush dependencies") @@ -29031,16 +30283,18 @@ check_flush_deps(unsigned paged) */ reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; base_addr = entries[entry_type]; - if(!pass) CACHE_ERROR("setup_cache failed") + if (!pass) + CACHE_ERROR("setup_cache failed") /* Insert entries to work with into the cache */ - for(u = 0; u < 5; u++) { + for (u = 0; u < 5; u++) { insert_entry(file_ptr, entry_type, (int32_t)u, H5C__NO_FLAGS_SET); - if(!pass) CACHE_ERROR("insert_entry failed") + if (!pass) + CACHE_ERROR("insert_entry failed") /* Change expected values, and verify the status of the entries * after each insertion @@ -29049,836 +30303,927 @@ check_flush_deps(unsigned paged) expected[u].is_dirty = TRUE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)u, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)u, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* end for */ -/* Test Case #1 - Single flush dependency relationship */ + /* Test Case #1 - Single flush dependency relationship */ /* Create flush dependency between entries 0 (child) & 1 (parent) */ { - hbool_t in_cache, is_flush_dep_parent, is_flush_dep_child; - test_entry_t * entry_ptr; + hbool_t in_cache, is_flush_dep_parent, is_flush_dep_child; + test_entry_t *entry_ptr; protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") /* Check the parent's entry status */ - entry_ptr = &(base_addr[1]); - if(H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, - NULL, NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child, NULL) < 0) + entry_ptr = &(base_addr[1]); + if (H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + &is_flush_dep_parent, &is_flush_dep_child, NULL) < 0) CACHE_ERROR("H5C_get_entry_status() failed") - if(!in_cache || is_flush_dep_parent || is_flush_dep_child) + if (!in_cache || is_flush_dep_parent || is_flush_dep_child) CACHE_ERROR("invalid entry status") /* Check the child's entry status */ - entry_ptr = &(base_addr[0]); - if(H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, - NULL, NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child, NULL) < 0) + entry_ptr = &(base_addr[0]); + if (H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + &is_flush_dep_parent, &is_flush_dep_child, NULL) < 0) CACHE_ERROR("H5C_get_entry_status() failed") - if(!in_cache || is_flush_dep_parent || is_flush_dep_child) + if (!in_cache || is_flush_dep_parent || is_flush_dep_child) CACHE_ERROR("invalid entry status") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Check the parent's entry status */ - entry_ptr = &(base_addr[1]); - if(H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, - NULL, NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child, NULL) < 0) + entry_ptr = &(base_addr[1]); + if (H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + &is_flush_dep_parent, &is_flush_dep_child, NULL) < 0) CACHE_ERROR("H5C_get_entry_status() failed") - if(!in_cache || !is_flush_dep_parent || is_flush_dep_child) + if (!in_cache || !is_flush_dep_parent || is_flush_dep_child) CACHE_ERROR("invalid entry status") /* Check the child's entry status */ - entry_ptr = &(base_addr[0]); - if(H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, - NULL, NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child, NULL) < 0) + entry_ptr = &(base_addr[0]); + if (H5C_get_entry_status(file_ptr, entry_ptr->addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + &is_flush_dep_parent, &is_flush_dep_child, NULL) < 0) CACHE_ERROR("H5C_get_entry_status() failed") - if(!in_cache || is_flush_dep_parent || !is_flush_dep_child) + if (!in_cache || is_flush_dep_parent || !is_flush_dep_child) CACHE_ERROR("invalid entry status") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries 0 (child) & 1 (parent) */ { destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; - expected[1].flush_dep_ndirty_chd =0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; + expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #2 - Multiple children for one parent flush dependency relationship */ + /* Test Case #2 - Multiple children for one parent flush dependency relationship */ /* Create flush dependency between entries 0, 1 (children) & 2 (parent) */ { protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 2; - expected[0].flush_dep_npar = 1; + expected[0].flush_dep_par_idx[0] = 2; + expected[0].flush_dep_npar = 1; expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 2; - expected[2].flush_dep_ndirty_chd = 2; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 2; + expected[2].flush_dep_ndirty_chd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries 0, 1 (children) & 2 (parent) */ { destroy_flush_dependency(entry_type, 2, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].flush_dep_npar = 0; - expected[2].is_protected = FALSE; - expected[2].is_pinned = FALSE; - expected[2].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].flush_dep_npar = 0; + expected[2].is_protected = FALSE; + expected[2].is_pinned = FALSE; + expected[2].flush_dep_nchd = 0; expected[2].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #3a1 - Single chain of flush dependencies, 4 entries tall - * created from the "bottom up" and destroyed from the "top down" - */ + /* Test Case #3a1 - Single chain of flush dependencies, 4 entries tall + * created from the "bottom up" and destroyed from the "top down" + */ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; - expected[2].flush_dep_ndirty_chd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; + expected[2].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 3); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 3; - expected[2].flush_dep_npar = 1; - expected[3].is_protected = TRUE; - expected[3].is_pinned = TRUE; - expected[3].flush_dep_nchd = 1; - expected[3].flush_dep_ndirty_chd = 1; + expected[2].flush_dep_par_idx[0] = 3; + expected[2].flush_dep_npar = 1; + expected[3].is_protected = TRUE; + expected[3].is_pinned = TRUE; + expected[3].flush_dep_nchd = 1; + expected[3].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, from the "top down" */ { destroy_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 3, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[2].flush_dep_npar = 0; - expected[3].is_protected = FALSE; - expected[3].is_pinned = FALSE; - expected[3].flush_dep_nchd = 0; + expected[2].flush_dep_npar = 0; + expected[3].is_protected = FALSE; + expected[3].is_pinned = FALSE; + expected[3].flush_dep_nchd = 0; expected[3].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[1].flush_dep_npar = 0; - expected[2].is_protected = FALSE; - expected[2].is_pinned = FALSE; - expected[2].flush_dep_nchd = 0; + expected[1].flush_dep_npar = 0; + expected[2].is_protected = FALSE; + expected[2].is_pinned = FALSE; + expected[2].flush_dep_nchd = 0; expected[2].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #3a2 - Single chain of flush dependencies, 4 entries tall - * created from the "bottom up" and destroyed from the "bottom up" - */ + /* Test Case #3a2 - Single chain of flush dependencies, 4 entries tall + * created from the "bottom up" and destroyed from the "bottom up" + */ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; - expected[2].flush_dep_ndirty_chd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; + expected[2].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 3); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 3; - expected[2].flush_dep_npar = 1; - expected[3].is_protected = TRUE; - expected[3].is_pinned = TRUE; - expected[3].flush_dep_nchd = 1; - expected[3].flush_dep_ndirty_chd = 1; + expected[2].flush_dep_par_idx[0] = 3; + expected[2].flush_dep_npar = 1; + expected[3].is_protected = TRUE; + expected[3].is_pinned = TRUE; + expected[3].flush_dep_nchd = 1; + expected[3].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, from the "bottom up" */ { destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[1].flush_dep_npar = 0; - expected[2].is_protected = FALSE; - expected[2].is_pinned = FALSE; - expected[2].flush_dep_nchd = 0; + expected[1].flush_dep_npar = 0; + expected[2].is_protected = FALSE; + expected[2].is_pinned = FALSE; + expected[2].flush_dep_nchd = 0; expected[2].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 3, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[2].flush_dep_npar = 0; - expected[3].is_protected = FALSE; - expected[3].is_pinned = FALSE; - expected[3].flush_dep_nchd = 0; + expected[2].flush_dep_npar = 0; + expected[3].is_protected = FALSE; + expected[3].is_pinned = FALSE; + expected[3].flush_dep_nchd = 0; expected[3].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #3b1 - Single chain of flush dependencies, 4 entries tall - * created from the "top down" and destroyed from the "top down" - */ + /* Test Case #3b1 - Single chain of flush dependencies, 4 entries tall + * created from the "top down" and destroyed from the "top down" + */ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */ { protect_entry(file_ptr, entry_type, 3); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 3; - expected[2].flush_dep_npar = 1; - expected[3].is_protected = TRUE; - expected[3].is_pinned = TRUE; - expected[3].flush_dep_nchd = 1; - expected[3].flush_dep_ndirty_chd = 1; + expected[2].flush_dep_par_idx[0] = 3; + expected[2].flush_dep_npar = 1; + expected[3].is_protected = TRUE; + expected[3].is_pinned = TRUE; + expected[3].flush_dep_nchd = 1; + expected[3].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; - expected[2].flush_dep_ndirty_chd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; + expected[2].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, from the "top down" */ { destroy_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 3, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[2].flush_dep_npar = 0; - expected[3].is_protected = FALSE; - expected[3].is_pinned = FALSE; - expected[3].flush_dep_nchd = 0; + expected[2].flush_dep_npar = 0; + expected[3].is_protected = FALSE; + expected[3].is_pinned = FALSE; + expected[3].flush_dep_nchd = 0; expected[3].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[1].flush_dep_npar = 0; - expected[2].is_protected = FALSE; - expected[2].is_pinned = FALSE; - expected[2].flush_dep_nchd = 0; + expected[1].flush_dep_npar = 0; + expected[2].is_protected = FALSE; + expected[2].is_pinned = FALSE; + expected[2].flush_dep_nchd = 0; expected[2].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #3b2 - Single chain of flush dependencies, 4 entries tall - * created from the "top down" and destroyed from the "bottom up" - */ + /* Test Case #3b2 - Single chain of flush dependencies, 4 entries tall + * created from the "top down" and destroyed from the "bottom up" + */ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */ { protect_entry(file_ptr, entry_type, 3); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 3; - expected[2].flush_dep_npar = 1; - expected[3].is_protected = TRUE; - expected[3].is_pinned = TRUE; - expected[3].flush_dep_nchd = 1; - expected[3].flush_dep_ndirty_chd = 1; + expected[2].flush_dep_par_idx[0] = 3; + expected[2].flush_dep_npar = 1; + expected[3].is_protected = TRUE; + expected[3].is_pinned = TRUE; + expected[3].flush_dep_nchd = 1; + expected[3].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; - expected[2].flush_dep_ndirty_chd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; + expected[2].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, from the "bottom up" */ { destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[1].flush_dep_npar = 0; - expected[2].is_protected = FALSE; - expected[2].is_pinned = FALSE; - expected[2].flush_dep_nchd = 0; + expected[1].flush_dep_npar = 0; + expected[2].is_protected = FALSE; + expected[2].is_pinned = FALSE; + expected[2].flush_dep_nchd = 0; expected[2].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 3, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[2].flush_dep_npar = 0; - expected[3].is_protected = FALSE; - expected[3].is_pinned = FALSE; - expected[3].flush_dep_nchd = 0; + expected[2].flush_dep_npar = 0; + expected[3].is_protected = FALSE; + expected[3].is_pinned = FALSE; + expected[3].flush_dep_nchd = 0; expected[3].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #4 - Multiple children for a single parent */ + /* Test Case #4 - Multiple children for a single parent */ /* Create flush dependency between entries (child) 0,1,2,3->4 (parent) */ { protect_entry(file_ptr, entry_type, 4); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { create_flush_dependency(entry_type, 4, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[u].flush_dep_par_type[0] = entry_type; - expected[u].flush_dep_par_idx[0] = 4; - expected[u].flush_dep_npar = 1; - expected[4].is_protected = TRUE; - expected[4].is_pinned = TRUE; + expected[u].flush_dep_par_idx[0] = 4; + expected[u].flush_dep_npar = 1; + expected[4].is_protected = TRUE; + expected[4].is_pinned = TRUE; expected[4].flush_dep_nchd++; expected[4].flush_dep_ndirty_chd++; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* end for */ } /* Destroy flush dependency between entries */ { - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { destroy_flush_dependency(entry_type, 4, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -29888,834 +31233,923 @@ check_flush_deps(unsigned paged) expected[4].flush_dep_ndirty_chd--; /* Check for destroying flush dependency on last entry */ - if(3 == u) { - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + if (3 == u) { + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 4, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[4].is_protected = FALSE; - expected[4].is_pinned = FALSE; + expected[4].is_pinned = FALSE; } /* end if */ /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* end for */ } -/* Test Case #5a - Join two flush dependency chains together, creating a single - * un-forked dependency chain - */ + /* Test Case #5a - Join two flush dependency chains together, creating a single + * un-forked dependency chain + */ /* Create flush dependency between entries (child) 0->1 and 3->4 (parent) * then add entry 4 as a child of 0 */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 4); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[0] = entry_type; - expected[3].flush_dep_par_idx[0] = 4; - expected[3].flush_dep_npar = 1; - expected[4].is_protected = TRUE; - expected[4].is_pinned = TRUE; - expected[4].flush_dep_nchd = 1; - expected[4].flush_dep_ndirty_chd = 1; + expected[3].flush_dep_par_idx[0] = 4; + expected[3].flush_dep_npar = 1; + expected[4].is_protected = TRUE; + expected[4].is_pinned = TRUE; + expected[4].flush_dep_nchd = 1; + expected[4].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 4); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[4].flush_dep_par_type[0] = entry_type; - expected[4].flush_dep_par_idx[0] = 0; - expected[4].flush_dep_npar = 1; - expected[0].is_protected = TRUE; - expected[0].is_pinned = TRUE; - expected[0].flush_dep_nchd = 1; - expected[0].flush_dep_ndirty_chd = 1; + expected[4].flush_dep_par_idx[0] = 0; + expected[4].flush_dep_npar = 1; + expected[0].is_protected = TRUE; + expected[0].is_pinned = TRUE; + expected[0].flush_dep_nchd = 1; + expected[0].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") - + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, detaching 3->4 from 0 first */ { destroy_flush_dependency(entry_type, 0, entry_type, 4); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[4].flush_dep_npar = 0; - expected[0].is_protected = FALSE; - expected[0].is_pinned = FALSE; - expected[0].flush_dep_nchd = 0; + expected[4].flush_dep_npar = 0; + expected[0].is_protected = FALSE; + expected[0].is_pinned = FALSE; + expected[0].flush_dep_nchd = 0; expected[0].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 4, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[3].flush_dep_npar = 0; - expected[4].is_protected = FALSE; - expected[4].is_pinned = FALSE; - expected[4].flush_dep_nchd = 0; + expected[3].flush_dep_npar = 0; + expected[4].is_protected = FALSE; + expected[4].is_pinned = FALSE; + expected[4].flush_dep_nchd = 0; expected[4].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #5b - Join two flush dependency chains together, creating a - * forked dependency chain - */ + /* Test Case #5b - Join two flush dependency chains together, creating a + * forked dependency chain + */ /* Create flush dependency between entries (child) 0->1->2 and 3->4 (parent) * then add entry 4 as a child of 1 */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5F_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5F_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; - expected[2].flush_dep_ndirty_chd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; + expected[2].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 4); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[0] = entry_type; - expected[3].flush_dep_par_idx[0] = 4; - expected[3].flush_dep_npar = 1; - expected[4].is_protected = TRUE; - expected[4].is_pinned = TRUE; - expected[4].flush_dep_nchd = 1; - expected[4].flush_dep_ndirty_chd = 1; + expected[3].flush_dep_par_idx[0] = 4; + expected[3].flush_dep_npar = 1; + expected[4].is_protected = TRUE; + expected[4].is_pinned = TRUE; + expected[4].flush_dep_nchd = 1; + expected[4].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 1, entry_type, 4); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[4].flush_dep_par_type[0] = entry_type; - expected[4].flush_dep_par_idx[0] = 1; - expected[4].flush_dep_npar = 1; - expected[1].flush_dep_nchd = 2; - expected[1].flush_dep_ndirty_chd = 2; + expected[4].flush_dep_par_idx[0] = 1; + expected[4].flush_dep_npar = 1; + expected[1].flush_dep_nchd = 2; + expected[1].flush_dep_ndirty_chd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") - + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, detaching 3->4 from 1 first */ { destroy_flush_dependency(entry_type, 1, entry_type, 4); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[4].flush_dep_npar = 0; - expected[1].flush_dep_nchd = 1; + expected[4].flush_dep_npar = 0; + expected[1].flush_dep_nchd = 1; expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 4, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[3].flush_dep_npar = 0; - expected[4].is_protected = FALSE; - expected[4].is_pinned = FALSE; - expected[4].flush_dep_nchd = 0; + expected[3].flush_dep_npar = 0; + expected[4].is_protected = FALSE; + expected[4].is_pinned = FALSE; + expected[4].flush_dep_nchd = 0; expected[4].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[1].flush_dep_npar = 0; - expected[2].is_protected = FALSE; - expected[2].is_pinned = FALSE; - expected[2].flush_dep_nchd = 0; + expected[1].flush_dep_npar = 0; + expected[2].is_protected = FALSE; + expected[2].is_pinned = FALSE; + expected[2].flush_dep_nchd = 0; expected[2].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #5c - Join two flush dependency chains together, creating a - * forked dependency chain - */ + /* Test Case #5c - Join two flush dependency chains together, creating a + * forked dependency chain + */ /* Create flush dependency between entries (child) 0->1->2 and 3->4 (parent) * then add entry 4 as a child of 2 */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; - expected[2].flush_dep_ndirty_chd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; + expected[2].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 4); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[0] = entry_type; - expected[3].flush_dep_par_idx[0] = 4; - expected[3].flush_dep_npar = 1; - expected[4].is_protected = TRUE; - expected[4].is_pinned = TRUE; - expected[4].flush_dep_nchd = 1; - expected[4].flush_dep_ndirty_chd = 1; + expected[3].flush_dep_par_idx[0] = 4; + expected[3].flush_dep_npar = 1; + expected[4].is_protected = TRUE; + expected[4].is_pinned = TRUE; + expected[4].flush_dep_nchd = 1; + expected[4].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 2, entry_type, 4); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[4].flush_dep_par_type[0] = entry_type; - expected[4].flush_dep_par_idx[0] = 2; - expected[4].flush_dep_npar = 1; - expected[2].flush_dep_nchd = 2; - expected[2].flush_dep_ndirty_chd = 2; + expected[4].flush_dep_par_idx[0] = 2; + expected[4].flush_dep_npar = 1; + expected[2].flush_dep_nchd = 2; + expected[2].flush_dep_ndirty_chd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") - + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, detaching 3->4 from 2 first */ { destroy_flush_dependency(entry_type, 2, entry_type, 4); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[4].flush_dep_npar = 0; - expected[2].flush_dep_nchd = 1; + expected[4].flush_dep_npar = 0; + expected[2].flush_dep_nchd = 1; expected[2].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 4, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[3].flush_dep_npar = 0; - expected[4].is_protected = FALSE; - expected[4].is_pinned = FALSE; - expected[4].flush_dep_nchd = 0; + expected[3].flush_dep_npar = 0; + expected[4].is_protected = FALSE; + expected[4].is_pinned = FALSE; + expected[4].flush_dep_nchd = 0; expected[4].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[1].flush_dep_npar = 0; - expected[2].is_protected = FALSE; - expected[2].is_pinned = FALSE; - expected[2].flush_dep_nchd = 0; + expected[1].flush_dep_npar = 0; + expected[2].is_protected = FALSE; + expected[2].is_pinned = FALSE; + expected[2].flush_dep_nchd = 0; expected[2].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #6a - Make certain that flush dependency relationship with parent - * already pinned works (unpin ater destroying flush dependency) - */ + /* Test Case #6a - Make certain that flush dependency relationship with parent + * already pinned works (unpin ater destroying flush dependency) + */ /* Create flush dependency between entries 0 (child) & 1 (parent) */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") pin_entry(entry_type, 1); - if(!pass) CACHE_ERROR("pin_entry failed") + if (!pass) + CACHE_ERROR("pin_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Unpin entry & destroy flush dependency between entries 0 (child) & 1 (parent) */ { destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") unpin_entry(entry_type, 1); - if(!pass) CACHE_ERROR("unpin_entry failed") + if (!pass) + CACHE_ERROR("unpin_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #6b - Make certain that flush dependency relationship with parent - * already pinned works (unpin before destroying flush dependency) - */ + /* Test Case #6b - Make certain that flush dependency relationship with parent + * already pinned works (unpin before destroying flush dependency) + */ /* Create flush dependency between entries 0 (child) & 1 (parent) */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") pin_entry(entry_type, 1); - if(!pass) CACHE_ERROR("pin_entry failed") + if (!pass) + CACHE_ERROR("pin_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Unpin entry & destroy flush dependency between entries 0 (child) & 1 (parent) */ { unpin_entry(entry_type, 1); - if(!pass) CACHE_ERROR("unpin_entry failed") + if (!pass) + CACHE_ERROR("unpin_entry failed") /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].flush_dep_npar = 0; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #7 - Simple multiple parents - */ + /* Test Case #7 - Simple multiple parents + */ /* Create flush dependency between entries (child) 0 and 1, 2 (parents) */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[1] = entry_type; - expected[0].flush_dep_par_idx[1] = 2; - expected[0].flush_dep_npar = 2; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; - expected[2].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[1] = 2; + expected[0].flush_dep_npar = 2; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; + expected[2].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries */ { destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 2; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = FALSE; - expected[1].is_pinned = FALSE; - expected[1].flush_dep_nchd = 0; - expected[1].flush_dep_ndirty_chd = 0; + expected[0].flush_dep_par_idx[0] = 2; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].flush_dep_nchd = 0; + expected[1].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].flush_dep_npar = 0; - expected[2].is_protected = FALSE; - expected[2].is_pinned = FALSE; - expected[2].flush_dep_nchd = 0; + expected[0].flush_dep_npar = 0; + expected[2].is_protected = FALSE; + expected[2].is_pinned = FALSE; + expected[2].flush_dep_nchd = 0; expected[2].flush_dep_ndirty_chd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } - done: - if(file_ptr) + if (file_ptr) takedown_cache(file_ptr, FALSE, FALSE); - if(pass) + if (pass) PASSED(); else { H5_FAILED(); @@ -30725,7 +32159,6 @@ done: return (unsigned)!pass; } /* check_flush_deps() */ - /*------------------------------------------------------------------------- * Function: check_flush_deps_err() * @@ -30742,11 +32175,11 @@ done: static unsigned check_flush_deps_err(unsigned paged) { - H5F_t * file_ptr = NULL; /* File for this test */ - int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ - unsigned test_count; /* Test iteration variable */ + H5F_t * file_ptr = NULL; /* File for this test */ + int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ + unsigned test_count; /* Test iteration variable */ - if(paged) + if (paged) TESTING("flush dependency errors (paged aggregation)") else TESTING("flush dependency errors") @@ -30756,172 +32189,216 @@ check_flush_deps_err(unsigned paged) /* Loop over test cases, check for various errors in configuring flush * dependencies. Verify that all performs as expected. */ - for(test_count = 0; test_count < 7; test_count++) { - unsigned u; /* Local index variable */ - herr_t result; /* Generic return value */ + for (test_count = 0; test_count < 7; test_count++) { + unsigned u; /* Local index variable */ + herr_t result; /* Generic return value */ /* Allocate a cache */ reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); - if(!pass) CACHE_ERROR("setup_cache failed") + if (!pass) + CACHE_ERROR("setup_cache failed") /* Insert entries to work with into the cache */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { insert_entry(file_ptr, entry_type, (int32_t)u, H5C__NO_FLAGS_SET); - if(!pass) CACHE_ERROR("insert_entry failed") + if (!pass) + CACHE_ERROR("insert_entry failed") } /* end for */ /* Various test cases */ - switch(test_count) { + switch (test_count) { /* Verify that parent entry in flush dependency must be protected */ case 0: - result = H5C_create_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[1])); - if(result != FAIL) CACHE_ERROR("Creating flush dependency with unprotected entry succeeded") + result = + H5C_create_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[1])); + if (result != FAIL) + CACHE_ERROR("Creating flush dependency with unprotected entry succeeded") break; /* Verify that entry can't have flush dependency on itself */ case 1: protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") - result = H5C_create_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[0])); - if(result != FAIL) CACHE_ERROR("Creating flush dependency with parent == child") + result = + H5C_create_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[0])); + if (result != FAIL) + CACHE_ERROR("Creating flush dependency with parent == child") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") break; /* Verify that parent entry must be protected */ case 2: - result = H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[1])); - if(result != FAIL) CACHE_ERROR("Destroying [non-existant] dependency when parent isn't protected") + result = + H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[1])); + if (result != FAIL) + CACHE_ERROR("Destroying [non-existant] dependency when parent isn't protected") break; /* Verify that parent entry has flush dependency */ case 3: protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") - result = H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[1])); - if(result != FAIL) CACHE_ERROR("Destroying dependency when parent isn't in relationship") + result = + H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[1])); + if (result != FAIL) + CACHE_ERROR("Destroying dependency when parent isn't in relationship") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") break; /* Verify that child entry is in flush dependency relationship */ case 4: protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") - result = H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[2])); - if(result != FAIL) CACHE_ERROR("Destroying dependency when child isn't in relationship") + result = + H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[2])); + if (result != FAIL) + CACHE_ERROR("Destroying dependency when child isn't in relationship") destroy_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") break; /* Verify that parent has child as direct descendant */ case 5: protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") protect_entry(file_ptr, entry_type, 3); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 3, entry_type, 4); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") - result = H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[4])); - if(result != FAIL) CACHE_ERROR("Destroying dependency when child is not a direct descendant has no children at child's height") + result = + H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[4])); + if (result != FAIL) + CACHE_ERROR("Destroying dependency when child is not a direct descendant has no children " + "at child's height") destroy_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") destroy_flush_dependency(entry_type, 1, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") destroy_flush_dependency(entry_type, 3, entry_type, 4); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 3, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") break; - /* Verify that child entry is child of parent */ case 6: protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") - result = H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[3])); - if(result != FAIL) CACHE_ERROR("Destroying dependency when child isn't in relationship") + result = + H5C_destroy_flush_dependency(&((entries[entry_type])[0]), &((entries[entry_type])[3])); + if (result != FAIL) + CACHE_ERROR("Destroying dependency when child isn't in relationship") destroy_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") destroy_flush_dependency(entry_type, 2, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") break; default: @@ -30929,16 +32406,16 @@ check_flush_deps_err(unsigned paged) } /* end switch */ takedown_cache(file_ptr, FALSE, FALSE); - if(!pass) CACHE_ERROR("takedown_cache failed") + if (!pass) + CACHE_ERROR("takedown_cache failed") file_ptr = NULL; } /* end for */ - done: - if(file_ptr) + if (file_ptr) takedown_cache(file_ptr, FALSE, FALSE); - if(pass) + if (pass) PASSED(); else { H5_FAILED(); @@ -30948,7 +32425,6 @@ done: return (unsigned)!pass; } /* check_flush_deps_err() */ - /*------------------------------------------------------------------------- * Function: check_flush_deps_order() * @@ -30966,23 +32442,108 @@ done: static unsigned check_flush_deps_order(unsigned paged) { - H5F_t * file_ptr = NULL; /* File for this test */ - H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ - int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ - unsigned u; /* Local index variable */ - struct expected_entry_status expected[5] = - { - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { PICO_ENTRY_TYPE, 0, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { PICO_ENTRY_TYPE, 1, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { PICO_ENTRY_TYPE, 2, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { PICO_ENTRY_TYPE, 3, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { PICO_ENTRY_TYPE, 4, PICO_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE} - }; - unsigned flush_order; /* Index for tracking flush order */ - - if(paged) + H5F_t * file_ptr = NULL; /* File for this test */ + H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ + int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ + unsigned u; /* Local index variable */ + struct expected_entry_status expected[5] = { + /* entry entry in at main flush dep flush dep child flush flush flush + */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ + {PICO_ENTRY_TYPE, + 0, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {PICO_ENTRY_TYPE, + 1, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {PICO_ENTRY_TYPE, + 2, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {PICO_ENTRY_TYPE, + 3, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {PICO_ENTRY_TYPE, + 4, + PICO_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}}; + unsigned flush_order; /* Index for tracking flush order */ + + if (paged) TESTING("flush dependencies flush order (paged aggregation)") else TESTING("flush dependencies flush order") @@ -30994,15 +32555,17 @@ check_flush_deps_order(unsigned paged) */ reset_entries(); - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; - if(!pass) CACHE_ERROR("setup_cache failed") + if (!pass) + CACHE_ERROR("setup_cache failed") /* Insert entries to work with into the cache */ - for(u = 0; u < 5; u++) { + for (u = 0; u < 5; u++) { insert_entry(file_ptr, entry_type, (int32_t)u, H5C__NO_FLAGS_SET); - if(!pass) CACHE_ERROR("insert_entry failed") + if (!pass) + CACHE_ERROR("insert_entry failed") /* Change expected values, and verify the status of the entries * after each insertion @@ -31011,917 +32574,980 @@ check_flush_deps_order(unsigned paged) expected[u].is_dirty = TRUE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)u, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)u, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* end for */ -/* Test Case #1a - Single flush dependency relationship, increasing addr order */ + /* Test Case #1a - Single flush dependency relationship, increasing addr order */ /* Create flush dependency between entries 0 (child) & 1 (parent) */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; - expected[1].flush_dep_ndirty_chd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; + expected[1].flush_dep_ndirty_chd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ + herr_t result; /* Generic return value */ - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 0; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 1; - expected[1].is_protected = FALSE; - expected[1].flush_dep_ndirty_chd =0; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[4].is_dirty = FALSE; - expected[4].serialized = TRUE; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 0; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 1; + expected[1].is_protected = FALSE; + expected[1].flush_dep_ndirty_chd = 0; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[4].is_dirty = FALSE; + expected[4].serialized = TRUE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries 0 (child) & 1 (parent) */ { destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ expected[0].flush_dep_npar = 0; - expected[1].is_pinned = FALSE; + expected[1].is_pinned = FALSE; expected[1].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #1b - Single flush dependency relationship, decreasing addr order */ + /* Test Case #1b - Single flush dependency relationship, decreasing addr order */ /* Create flush dependency between entries 0 (child) & 1 (parent) */ { protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ - expected[0].is_protected = TRUE; - expected[0].is_pinned = TRUE; - expected[0].flush_dep_nchd = 1; + expected[0].is_protected = TRUE; + expected[0].is_pinned = TRUE; + expected[0].flush_dep_nchd = 1; expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 0; - expected[1].flush_dep_npar = 1; + expected[1].flush_dep_par_idx[0] = 0; + expected[1].flush_dep_npar = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ + herr_t result; /* Generic return value */ - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0 & 1 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, TRUE); dirty_entry(file_ptr, entry_type, 1, FALSE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 1; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 1; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 0; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries 0 (child) & 1 (parent) */ { destroy_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_pinned = FALSE; + expected[0].is_pinned = FALSE; expected[0].flush_dep_nchd = 0; expected[1].flush_dep_npar = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #2a - Multiple children for one parent flush dependency relationship - * increasing addr order - */ + /* Test Case #2a - Multiple children for one parent flush dependency relationship + * increasing addr order + */ /* Create flush dependency between entries 0, 1 (children) & 2 (parent) */ { protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 2; - expected[0].flush_dep_npar = 1; + expected[0].flush_dep_par_idx[0] = 2; + expected[0].flush_dep_npar = 1; expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 2; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ + herr_t result; /* Generic return value */ - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0, 1 & 2 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, FALSE); dirty_entry(file_ptr, entry_type, 1, FALSE); dirty_entry(file_ptr, entry_type, 2, TRUE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 0; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 1; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 2; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 0; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 1; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 2; expected[2].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries 0, 1 (children) & 2 (parent) */ { destroy_flush_dependency(entry_type, 2, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ expected[0].flush_dep_npar = 0; expected[1].flush_dep_npar = 0; - expected[2].is_pinned = FALSE; + expected[2].is_pinned = FALSE; expected[2].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #2b - Multiple children for one parent flush dependency relationship - * decreasing addr order - */ + /* Test Case #2b - Multiple children for one parent flush dependency relationship + * decreasing addr order + */ /* Create flush dependency between entries 1, 2 (children) & 0 (parent) */ { protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") create_flush_dependency(entry_type, 0, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ - expected[0].is_protected = TRUE; - expected[0].is_pinned = TRUE; - expected[0].flush_dep_nchd = 2; + expected[0].is_protected = TRUE; + expected[0].is_pinned = TRUE; + expected[0].flush_dep_nchd = 2; expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 0; - expected[1].flush_dep_npar = 1; + expected[1].flush_dep_par_idx[0] = 0; + expected[1].flush_dep_npar = 1; expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 0; - expected[2].flush_dep_npar = 1; + expected[2].flush_dep_par_idx[0] = 0; + expected[2].flush_dep_npar = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ + herr_t result; /* Generic return value */ - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0, 1 & 2 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, TRUE); dirty_entry(file_ptr, entry_type, 1, FALSE); dirty_entry(file_ptr, entry_type, 2, FALSE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 2; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 2; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 0; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 1; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 0; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries 1, 2 (children) & 0 (parent) */ { destroy_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") destroy_flush_dependency(entry_type, 0, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_pinned = FALSE; + expected[0].is_pinned = FALSE; expected[0].flush_dep_nchd = 0; expected[1].flush_dep_npar = 0; expected[2].flush_dep_npar = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #3a - Single chain of flush dependencies, 4 entries tall, - * increasing addr order - */ + /* Test Case #3a - Single chain of flush dependencies, 4 entries tall, + * increasing addr order + */ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 3); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 3; - expected[2].flush_dep_npar = 1; - expected[3].is_protected = TRUE; - expected[3].is_pinned = TRUE; - expected[3].flush_dep_nchd = 1; + expected[2].flush_dep_par_idx[0] = 3; + expected[2].flush_dep_npar = 1; + expected[3].is_protected = TRUE; + expected[3].is_pinned = TRUE; + expected[3].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ - - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + herr_t result; /* Generic return value */ + + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 3, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0-3 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, FALSE); dirty_entry(file_ptr, entry_type, 1, TRUE); dirty_entry(file_ptr, entry_type, 2, TRUE); dirty_entry(file_ptr, entry_type, 3, TRUE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 0; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 1; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 0; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 1; expected[1].is_protected = FALSE; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 2; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 2; expected[2].is_protected = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 3; + expected[3].serialized = TRUE; + expected[3].flush_order = 3; expected[3].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, from the "top down" */ { destroy_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[2].flush_dep_npar = 0; - expected[3].is_pinned = FALSE; + expected[3].is_pinned = FALSE; expected[3].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[1].flush_dep_npar = 0; - expected[2].is_pinned = FALSE; + expected[2].is_pinned = FALSE; expected[2].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[0].flush_dep_npar = 0; - expected[1].is_pinned = FALSE; + expected[1].is_pinned = FALSE; expected[1].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #3b - Single chain of flush dependencies, 4 entries tall - * decreasing addr order - */ + /* Test Case #3b - Single chain of flush dependencies, 4 entries tall + * decreasing addr order + */ /* Create flush dependency between entries (child) 0->1->2->3 (parent) */ { protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ - expected[0].is_protected = TRUE; - expected[0].is_pinned = TRUE; - expected[0].flush_dep_nchd = 1; + expected[0].is_protected = TRUE; + expected[0].is_pinned = TRUE; + expected[0].flush_dep_nchd = 1; expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 0; - expected[1].flush_dep_npar = 1; + expected[1].flush_dep_par_idx[0] = 0; + expected[1].flush_dep_npar = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 1; - expected[2].flush_dep_npar = 1; + expected[2].flush_dep_par_idx[0] = 1; + expected[2].flush_dep_npar = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; expected[3].flush_dep_par_type[0] = entry_type; - expected[3].flush_dep_par_idx[0] = 2; - expected[3].flush_dep_npar = 1; + expected[3].flush_dep_par_idx[0] = 2; + expected[3].flush_dep_npar = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ - - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + herr_t result; /* Generic return value */ + + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0-3 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, TRUE); dirty_entry(file_ptr, entry_type, 1, TRUE); dirty_entry(file_ptr, entry_type, 2, TRUE); dirty_entry(file_ptr, entry_type, 3, FALSE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 3; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 3; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 2; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 2; expected[1].is_protected = FALSE; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 1; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 1; expected[2].is_protected = FALSE; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 0; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[3].flush_order = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, from the "bottom up" */ { destroy_flush_dependency(entry_type, 2, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[2].is_pinned = FALSE; + expected[2].is_pinned = FALSE; expected[2].flush_dep_nchd = 0; expected[3].flush_dep_npar = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[1].is_pinned = FALSE; + expected[1].is_pinned = FALSE; expected[1].flush_dep_nchd = 0; expected[2].flush_dep_npar = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ - expected[0].is_pinned = FALSE; + expected[0].is_pinned = FALSE; expected[0].flush_dep_nchd = 0; expected[1].flush_dep_npar = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #4a - Multiple children for a single parent, increasing addr order */ + /* Test Case #4a - Multiple children for a single parent, increasing addr order */ /* Create flush dependency between entries (child) 0,1,2,3->4 (parent) */ { protect_entry(file_ptr, entry_type, 4); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { create_flush_dependency(entry_type, 4, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[u].flush_dep_par_type[0] = entry_type; - expected[u].flush_dep_par_idx[0] = 4; - expected[u].flush_dep_npar = 1; - expected[4].is_protected = TRUE; - expected[4].is_pinned = TRUE; - expected[4].flush_dep_nchd = u + 1; + expected[u].flush_dep_par_idx[0] = 4; + expected[u].flush_dep_npar = 1; + expected[4].is_protected = TRUE; + expected[4].is_pinned = TRUE; + expected[4].flush_dep_nchd = u + 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* end for */ } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ - - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 4, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + herr_t result; /* Generic return value */ + + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 4, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 4, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0-4 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, FALSE); @@ -31929,59 +33555,63 @@ check_flush_deps_order(unsigned paged) dirty_entry(file_ptr, entry_type, 2, FALSE); dirty_entry(file_ptr, entry_type, 3, FALSE); dirty_entry(file_ptr, entry_type, 4, TRUE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; - expected[4].serialized = FALSE; + expected[4].serialized = FALSE; expected[4].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 0; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 1; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 2; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 3; - expected[4].is_dirty = FALSE; - expected[4].serialized = TRUE; - expected[4].flush_order = 4; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 0; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 1; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 2; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[3].flush_order = 3; + expected[4].is_dirty = FALSE; + expected[4].serialized = TRUE; + expected[4].flush_order = 4; expected[4].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries */ { - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { destroy_flush_dependency(entry_type, 4, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -31990,7 +33620,7 @@ check_flush_deps_order(unsigned paged) expected[4].flush_dep_nchd = 3 - u; /* Check for destroying flush dependency on last entry */ - if(3 == u) { + if (3 == u) { /* Change expected values, and verify the status of the entries * after destroying flush dependency */ @@ -31998,64 +33628,64 @@ check_flush_deps_order(unsigned paged) } /* end if */ /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* end for */ } -/* Test Case #4b - Multiple children for a single parent, decreasing addr order */ + /* Test Case #4b - Multiple children for a single parent, decreasing addr order */ /* Create flush dependency between entries (child) 0,1,2,3->4 (parent) */ { protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") - for(u = 1; u < 5; u++) { + for (u = 1; u < 5; u++) { create_flush_dependency(entry_type, 0, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[u].flush_dep_par_type[0] = entry_type; - expected[u].flush_dep_par_idx[0] = 0; - expected[u].flush_dep_npar = 1; - expected[0].is_protected = TRUE; - expected[0].is_pinned = TRUE; - expected[0].flush_dep_nchd = u; + expected[u].flush_dep_par_idx[0] = 0; + expected[u].flush_dep_npar = 1; + expected[0].is_protected = TRUE; + expected[0].is_pinned = TRUE; + expected[0].flush_dep_nchd = u; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* end for */ } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ - - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 4, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + herr_t result; /* Generic return value */ + + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 4, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0-4 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, TRUE); @@ -32063,59 +33693,63 @@ check_flush_deps_order(unsigned paged) dirty_entry(file_ptr, entry_type, 2, FALSE); dirty_entry(file_ptr, entry_type, 3, FALSE); dirty_entry(file_ptr, entry_type, 4, FALSE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; - expected[4].serialized = FALSE; + expected[4].serialized = FALSE; expected[4].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 4; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 4; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 0; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 1; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 2; - expected[4].is_dirty = FALSE; - expected[4].serialized = TRUE; - expected[4].flush_order = 3; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 0; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 1; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[3].flush_order = 2; + expected[4].is_dirty = FALSE; + expected[4].serialized = TRUE; + expected[4].flush_order = 3; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries */ { - for(u = 1; u < 5; u++) { + for (u = 1; u < 5; u++) { destroy_flush_dependency(entry_type, 0, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -32124,7 +33758,7 @@ check_flush_deps_order(unsigned paged) expected[0].flush_dep_nchd = 4 - u; /* Check for destroying flush dependency on last entry */ - if(4 == u) { + if (4 == u) { /* Change expected values, and verify the status of the entries * after destroying flush dependency */ @@ -32132,362 +33766,387 @@ check_flush_deps_order(unsigned paged) } /* end if */ /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* end for */ } -/* Test Case #5a - Join two flush dependency chains together, creating a single - * un-forked dependency chain - */ + /* Test Case #5a - Join two flush dependency chains together, creating a single + * un-forked dependency chain + */ /* Create flush dependency between entries (child) 0->1 and 3->4 (parent) * then add entry 4 as a child of 0 */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 4); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[0] = entry_type; - expected[3].flush_dep_par_idx[0] = 4; - expected[3].flush_dep_npar = 1; - expected[4].is_protected = TRUE; - expected[4].is_pinned = TRUE; - expected[4].flush_dep_nchd = 1; + expected[3].flush_dep_par_idx[0] = 4; + expected[3].flush_dep_npar = 1; + expected[4].is_protected = TRUE; + expected[4].is_pinned = TRUE; + expected[4].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 4); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[4].flush_dep_par_type[0] = entry_type; - expected[4].flush_dep_par_idx[0] = 0; - expected[4].flush_dep_npar = 1; - expected[0].is_protected = TRUE; - expected[0].is_pinned = TRUE; - expected[0].flush_dep_nchd = 1; + expected[4].flush_dep_par_idx[0] = 0; + expected[4].flush_dep_npar = 1; + expected[0].is_protected = TRUE; + expected[0].is_pinned = TRUE; + expected[0].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") - + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ + herr_t result; /* Generic return value */ - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 4, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 4, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 4, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0 & 1, 3 & 4 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, TRUE); dirty_entry(file_ptr, entry_type, 1, TRUE); dirty_entry(file_ptr, entry_type, 3, FALSE); dirty_entry(file_ptr, entry_type, 4, TRUE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; - expected[4].serialized = FALSE; + expected[4].serialized = FALSE; expected[4].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 2; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 2; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 3; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 3; expected[1].is_protected = FALSE; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 0; - expected[4].is_dirty = FALSE; - expected[4].serialized = TRUE; - expected[4].flush_order = 1; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[3].flush_order = 0; + expected[4].is_dirty = FALSE; + expected[4].serialized = TRUE; + expected[4].flush_order = 1; expected[4].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, detaching 3->4 from 0 first */ { destroy_flush_dependency(entry_type, 0, entry_type, 4); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[4].flush_dep_npar = 0; - expected[0].is_pinned = FALSE; + expected[0].is_pinned = FALSE; expected[0].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[3].flush_dep_npar = 0; - expected[4].is_pinned = FALSE; + expected[4].is_pinned = FALSE; expected[4].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[0].flush_dep_npar = 0; - expected[1].is_pinned = FALSE; + expected[1].is_pinned = FALSE; expected[1].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #5b - Join two flush dependency chains together, creating a - * forked dependency chain - */ + /* Test Case #5b - Join two flush dependency chains together, creating a + * forked dependency chain + */ /* Create flush dependency between entries (child) 0->1->2 and 3->4 (parent) * then add entry 4 as a child of 1 */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 4); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[0] = entry_type; - expected[3].flush_dep_par_idx[0] = 4; - expected[3].flush_dep_npar = 1; - expected[4].is_protected = TRUE; - expected[4].is_pinned = TRUE; - expected[4].flush_dep_nchd = 1; + expected[3].flush_dep_par_idx[0] = 4; + expected[3].flush_dep_npar = 1; + expected[4].is_protected = TRUE; + expected[4].is_pinned = TRUE; + expected[4].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 1, entry_type, 4); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[4].flush_dep_par_type[0] = entry_type; - expected[4].flush_dep_par_idx[0] = 1; - expected[4].flush_dep_npar = 1; - expected[1].flush_dep_nchd = 2; + expected[4].flush_dep_par_idx[0] = 1; + expected[4].flush_dep_npar = 1; + expected[1].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") - + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ - - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 4, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + herr_t result; /* Generic return value */ + + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 4, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 4, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0-4 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, FALSE); @@ -32495,61 +34154,65 @@ check_flush_deps_order(unsigned paged) dirty_entry(file_ptr, entry_type, 2, TRUE); dirty_entry(file_ptr, entry_type, 3, FALSE); dirty_entry(file_ptr, entry_type, 4, TRUE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; - expected[4].serialized = FALSE; + expected[4].serialized = FALSE; expected[4].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 0; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 0; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 3; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 3; expected[1].is_protected = FALSE; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 4; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 4; expected[2].is_protected = FALSE; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 1; - expected[4].is_dirty = FALSE; - expected[4].serialized = TRUE; - expected[4].flush_order = 2; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[3].flush_order = 1; + expected[4].is_dirty = FALSE; + expected[4].serialized = TRUE; + expected[4].flush_order = 2; expected[4].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, detaching 3->4 from 1 first */ { destroy_flush_dependency(entry_type, 1, entry_type, 4); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -32558,193 +34221,208 @@ check_flush_deps_order(unsigned paged) expected[1].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[3].flush_dep_npar = 0; - expected[4].is_pinned = FALSE; + expected[4].is_pinned = FALSE; expected[4].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[1].flush_dep_npar = 0; - expected[2].is_pinned = FALSE; + expected[2].is_pinned = FALSE; expected[2].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[0].flush_dep_npar = 0; - expected[1].is_pinned = FALSE; + expected[1].is_pinned = FALSE; expected[1].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #5c - Join two flush dependency chains together, creating a - * forked dependency chain - */ + /* Test Case #5c - Join two flush dependency chains together, creating a + * forked dependency chain + */ /* Create flush dependency between entries (child) 0->1->2 and 3->4 (parent) * then add entry 4 as a child of 2 */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 4); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[0] = entry_type; - expected[3].flush_dep_par_idx[0] = 4; - expected[3].flush_dep_npar = 1; - expected[4].is_protected = TRUE; - expected[4].is_pinned = TRUE; - expected[4].flush_dep_nchd = 1; + expected[3].flush_dep_par_idx[0] = 4; + expected[3].flush_dep_npar = 1; + expected[4].is_protected = TRUE; + expected[4].is_pinned = TRUE; + expected[4].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 2, entry_type, 4); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[4].flush_dep_par_type[0] = entry_type; - expected[4].flush_dep_par_idx[0] = 2; - expected[4].flush_dep_npar = 1; - expected[2].flush_dep_nchd = 2; + expected[4].flush_dep_par_idx[0] = 2; + expected[4].flush_dep_npar = 1; + expected[2].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") - + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ - - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 4, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + herr_t result; /* Generic return value */ + + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 4, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 4, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0-4 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, FALSE); @@ -32752,61 +34430,65 @@ check_flush_deps_order(unsigned paged) dirty_entry(file_ptr, entry_type, 2, TRUE); dirty_entry(file_ptr, entry_type, 3, FALSE); dirty_entry(file_ptr, entry_type, 4, TRUE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'serialized' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; - expected[4].serialized = FALSE; + expected[4].serialized = FALSE; expected[4].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 0; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 0; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 1; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 1; expected[1].is_protected = FALSE; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 4; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 4; expected[2].is_protected = FALSE; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 2; - expected[4].is_dirty = FALSE; - expected[4].serialized = TRUE; - expected[4].flush_order = 3; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[3].flush_order = 2; + expected[4].is_dirty = FALSE; + expected[4].serialized = TRUE; + expected[4].flush_order = 3; expected[4].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, detaching 3->4 from 2 first */ { destroy_flush_dependency(entry_type, 2, entry_type, 4); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -32815,282 +34497,306 @@ check_flush_deps_order(unsigned paged) expected[2].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 4, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[3].flush_dep_npar = 0; - expected[4].is_pinned = FALSE; + expected[4].is_pinned = FALSE; expected[4].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[1].flush_dep_npar = 0; - expected[2].is_pinned = FALSE; + expected[2].is_pinned = FALSE; expected[2].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[0].flush_dep_npar = 0; - expected[1].is_pinned = FALSE; + expected[1].is_pinned = FALSE; expected[1].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #6a - Interlocked multiple parents, increasing addr order - */ + /* Test Case #6a - Interlocked multiple parents, increasing addr order + */ /* Create flush dependencies between entries 0-3, with each entry a child * of every entry with a higher number. */ { protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[0] = entry_type; - expected[0].flush_dep_par_idx[0] = 1; - expected[0].flush_dep_npar = 1; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; + expected[0].flush_dep_par_idx[0] = 1; + expected[0].flush_dep_npar = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[1] = entry_type; - expected[0].flush_dep_par_idx[1] = 2; - expected[0].flush_dep_npar = 2; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; + expected[0].flush_dep_par_idx[1] = 2; + expected[0].flush_dep_npar = 2; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 2; - expected[1].flush_dep_npar = 1; - expected[2].flush_dep_nchd = 2; + expected[1].flush_dep_par_idx[0] = 2; + expected[1].flush_dep_npar = 1; + expected[2].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 3); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 3, entry_type, 0); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[0].flush_dep_par_type[2] = entry_type; - expected[0].flush_dep_par_idx[2] = 3; - expected[0].flush_dep_npar = 3; - expected[3].is_protected = TRUE; - expected[3].is_pinned = TRUE; - expected[3].flush_dep_nchd = 1; + expected[0].flush_dep_par_idx[2] = 3; + expected[0].flush_dep_npar = 3; + expected[3].is_protected = TRUE; + expected[3].is_pinned = TRUE; + expected[3].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 3, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[1] = entry_type; - expected[1].flush_dep_par_idx[1] = 3; - expected[1].flush_dep_npar = 2; - expected[3].flush_dep_nchd = 2; + expected[1].flush_dep_par_idx[1] = 3; + expected[1].flush_dep_npar = 2; + expected[3].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 3; - expected[2].flush_dep_npar = 1; - expected[3].flush_dep_nchd = 3; + expected[2].flush_dep_par_idx[0] = 3; + expected[2].flush_dep_npar = 1; + expected[3].flush_dep_nchd = 3; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") - + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ - - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + herr_t result; /* Generic return value */ + + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 3, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0-3 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, FALSE); dirty_entry(file_ptr, entry_type, 1, TRUE); dirty_entry(file_ptr, entry_type, 2, TRUE); dirty_entry(file_ptr, entry_type, 3, FALSE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'flushed' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 0; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 0; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 1; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 1; expected[1].is_protected = FALSE; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 2; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 2; expected[2].is_protected = FALSE; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 3; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[3].flush_order = 3; expected[3].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, in reverse order */ { destroy_flush_dependency(entry_type, 3, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -33099,14 +34805,16 @@ check_flush_deps_order(unsigned paged) expected[3].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 3, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -33115,31 +34823,35 @@ check_flush_deps_order(unsigned paged) expected[3].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 3, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[0].flush_dep_npar = 2; - expected[3].is_pinned = FALSE; + expected[3].is_pinned = FALSE; expected[3].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -33148,265 +34860,287 @@ check_flush_deps_order(unsigned paged) expected[2].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[0].flush_dep_npar = 1; - expected[2].is_pinned = FALSE; + expected[2].is_pinned = FALSE; expected[2].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 0); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[0].flush_dep_npar = 0; - expected[1].is_pinned = FALSE; + expected[1].is_pinned = FALSE; expected[1].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } -/* Test Case #6b - Interlocked multiple parents, decreasing addr order - */ + /* Test Case #6b - Interlocked multiple parents, decreasing addr order + */ /* Create flush dependencies between entries 0-3, with each entry a parent * of every entry with a higher number. */ { protect_entry(file_ptr, entry_type, 2); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 2, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[0] = entry_type; - expected[3].flush_dep_par_idx[0] = 2; - expected[3].flush_dep_npar = 1; - expected[2].is_protected = TRUE; - expected[2].is_pinned = TRUE; - expected[2].flush_dep_nchd = 1; + expected[3].flush_dep_par_idx[0] = 2; + expected[3].flush_dep_npar = 1; + expected[2].is_protected = TRUE; + expected[2].is_pinned = TRUE; + expected[2].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 1); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 1, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[1] = entry_type; - expected[3].flush_dep_par_idx[1] = 1; - expected[3].flush_dep_npar = 2; - expected[1].is_protected = TRUE; - expected[1].is_pinned = TRUE; - expected[1].flush_dep_nchd = 1; + expected[3].flush_dep_par_idx[1] = 1; + expected[3].flush_dep_npar = 2; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 1, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[2].flush_dep_par_type[0] = entry_type; - expected[2].flush_dep_par_idx[0] = 1; - expected[2].flush_dep_npar = 1; - expected[1].flush_dep_nchd = 2; + expected[2].flush_dep_par_idx[0] = 1; + expected[2].flush_dep_npar = 1; + expected[1].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") protect_entry(file_ptr, entry_type, 0); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") create_flush_dependency(entry_type, 0, entry_type, 3); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[3].flush_dep_par_type[2] = entry_type; - expected[3].flush_dep_par_idx[2] = 0; - expected[3].flush_dep_npar = 3; - expected[0].is_protected = TRUE; - expected[0].is_pinned = TRUE; - expected[0].flush_dep_nchd = 1; + expected[3].flush_dep_par_idx[2] = 0; + expected[3].flush_dep_npar = 3; + expected[0].is_protected = TRUE; + expected[0].is_pinned = TRUE; + expected[0].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 0, entry_type, 2); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[2].flush_dep_par_type[1] = entry_type; - expected[2].flush_dep_par_idx[1] = 0; - expected[2].flush_dep_npar = 2; - expected[0].flush_dep_nchd = 2; + expected[2].flush_dep_par_idx[1] = 0; + expected[2].flush_dep_npar = 2; + expected[0].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") create_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("create_flush_dependency failed") + if (!pass) + CACHE_ERROR("create_flush_dependency failed") /* Change expected values, and verify the status of the entries * after creating flush dependency */ expected[1].flush_dep_par_type[0] = entry_type; - expected[1].flush_dep_par_idx[0] = 0; - expected[1].flush_dep_npar = 1; - expected[0].flush_dep_nchd = 3; + expected[1].flush_dep_par_idx[0] = 0; + expected[1].flush_dep_npar = 1; + expected[0].flush_dep_nchd = 3; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") - + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Flush the cache and verify that the entries were flushed in correct order */ { - herr_t result; /* Generic return value */ - - add_flush_op(entry_type, 0, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 1, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 2, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - add_flush_op(entry_type, 3, FLUSH_OP__ORDER, - entry_type, 0, FALSE, (size_t)0, &flush_order); - - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + herr_t result; /* Generic return value */ + + add_flush_op(entry_type, 0, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 1, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 2, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + add_flush_op(entry_type, 3, FLUSH_OP__ORDER, entry_type, 0, FALSE, (size_t)0, &flush_order); + + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 0, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 1, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ 2, /* int32_t idx */ H5C__NO_FLAGS_SET); /* unsigned int flags */ - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Mark entries 0-3 dirty, so they are flushed */ dirty_entry(file_ptr, entry_type, 0, FALSE); dirty_entry(file_ptr, entry_type, 1, TRUE); dirty_entry(file_ptr, entry_type, 2, TRUE); dirty_entry(file_ptr, entry_type, 3, FALSE); - if(!pass) CACHE_ERROR("dirty_entry failed") + if (!pass) + CACHE_ERROR("dirty_entry failed") /* Reset 'flushed' flag & 'flush_order' value in expected array */ - expected[0].serialized = FALSE; + expected[0].serialized = FALSE; expected[0].flush_order = -1; - expected[1].serialized = FALSE; + expected[1].serialized = FALSE; expected[1].flush_order = -1; - expected[2].serialized = FALSE; + expected[2].serialized = FALSE; expected[2].flush_order = -1; - expected[3].serialized = FALSE; + expected[3].serialized = FALSE; expected[3].flush_order = -1; /* Reset index for tracking flush order */ flush_order = 0; result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(result < 0) CACHE_ERROR("flushing entries with flush dependendices") + if (result < 0) + CACHE_ERROR("flushing entries with flush dependendices") /* Change expected values, and verify the status of the entries * after destroy flush dependency */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; - expected[0].flush_order = 3; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; + expected[0].flush_order = 3; expected[0].is_protected = FALSE; - expected[1].is_dirty = FALSE; - expected[1].serialized = TRUE; - expected[1].flush_order = 2; + expected[1].is_dirty = FALSE; + expected[1].serialized = TRUE; + expected[1].flush_order = 2; expected[1].is_protected = FALSE; - expected[2].is_dirty = FALSE; - expected[2].serialized = TRUE; - expected[2].flush_order = 1; + expected[2].is_dirty = FALSE; + expected[2].serialized = TRUE; + expected[2].flush_order = 1; expected[2].is_protected = FALSE; - expected[3].is_dirty = FALSE; - expected[3].serialized = TRUE; - expected[3].flush_order = 0; + expected[3].is_dirty = FALSE; + expected[3].serialized = TRUE; + expected[3].flush_order = 0; expected[3].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } /* Destroy flush dependency between entries, in reverse order */ { destroy_flush_dependency(entry_type, 0, entry_type, 1); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -33415,14 +35149,16 @@ check_flush_deps_order(unsigned paged) expected[0].flush_dep_nchd = 2; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 0, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -33431,31 +35167,35 @@ check_flush_deps_order(unsigned paged) expected[0].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 0, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[3].flush_dep_npar = 2; - expected[0].is_pinned = FALSE; + expected[0].is_pinned = FALSE; expected[0].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 2); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency @@ -33464,53 +35204,57 @@ check_flush_deps_order(unsigned paged) expected[1].flush_dep_nchd = 1; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 1, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[3].flush_dep_npar = 1; - expected[1].is_pinned = FALSE; + expected[1].is_pinned = FALSE; expected[1].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") destroy_flush_dependency(entry_type, 2, entry_type, 3); - if(!pass) CACHE_ERROR("destroy_flush_dependency failed") + if (!pass) + CACHE_ERROR("destroy_flush_dependency failed") /* Change expected values, and verify the status of the entries * after destroying flush dependency */ expected[3].flush_dep_npar = 0; - expected[2].is_pinned = FALSE; + expected[2].is_pinned = FALSE; expected[2].flush_dep_nchd = 0; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)0, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") } - done: - if(file_ptr) + if (file_ptr) takedown_cache(file_ptr, FALSE, FALSE); - if(pass) + if (pass) PASSED(); else { H5_FAILED(); @@ -33520,7 +35264,6 @@ done: return (unsigned)!pass; } /* check_flush_deps_order() */ - /*------------------------------------------------------------------------- * Function: check_notify_cb() * @@ -33537,24 +35280,109 @@ done: static unsigned check_notify_cb(unsigned paged) { - H5F_t * file_ptr = NULL; /* File for this test */ - H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ + H5F_t * file_ptr = NULL; /* File for this test */ + H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ test_entry_t *base_addr; /* Base address of entries for test */ - test_entry_t * entry_ptr; /* Cache entry to examine/manipulate */ - int entry_type = NOTIFY_ENTRY_TYPE; /* Use entry w/notify callback (size of entries doesn't matter) */ - unsigned u; /* Local index variable */ - struct expected_entry_status expected[5] = - { - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { NOTIFY_ENTRY_TYPE, 0, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { NOTIFY_ENTRY_TYPE, 1, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { NOTIFY_ENTRY_TYPE, 2, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { NOTIFY_ENTRY_TYPE, 3, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { NOTIFY_ENTRY_TYPE, 4, NOTIFY_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE} - }; - - if(paged) + test_entry_t *entry_ptr; /* Cache entry to examine/manipulate */ + int entry_type = NOTIFY_ENTRY_TYPE; /* Use entry w/notify callback (size of entries doesn't matter) */ + unsigned u; /* Local index variable */ + struct expected_entry_status expected[5] = { + /* entry entry in at main flush + dep flush dep child flush flush flush */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ + {NOTIFY_ENTRY_TYPE, + 0, + NOTIFY_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {NOTIFY_ENTRY_TYPE, + 1, + NOTIFY_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {NOTIFY_ENTRY_TYPE, + 2, + NOTIFY_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {NOTIFY_ENTRY_TYPE, + 3, + NOTIFY_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {NOTIFY_ENTRY_TYPE, + 4, + NOTIFY_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}}; + + if (paged) TESTING("'notify' callback (paged)") else TESTING("'notify' callback") @@ -33567,16 +35395,19 @@ check_notify_cb(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); - if(!file_ptr) CACHE_ERROR("setup_cache returned NULL") + if (!file_ptr) + CACHE_ERROR("setup_cache returned NULL") cache_ptr = file_ptr->shared->cache; base_addr = entries[entry_type]; - if(!pass) CACHE_ERROR("setup_cache failed") + if (!pass) + CACHE_ERROR("setup_cache failed") /* Insert entries to work with into the cache */ - for(u = 0; u < 5; u++) { + for (u = 0; u < 5; u++) { insert_entry(file_ptr, entry_type, (int32_t)u, H5C__NO_FLAGS_SET); - if(!pass) CACHE_ERROR("insert_entry failed") + if (!pass) + CACHE_ERROR("insert_entry failed") /* Change expected values, and verify the status of the entries * after each insertion @@ -33585,135 +35416,144 @@ check_notify_cb(unsigned paged) expected[u].is_dirty = TRUE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)u, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)u, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") /* Check the entry's 'after insert' count */ - entry_ptr = &(base_addr[u]); - if(1 != entry_ptr->notify_after_insert_count) + entry_ptr = &(base_addr[u]); + if (1 != entry_ptr->notify_after_insert_count) CACHE_ERROR("invalid notify after insert count") - if(0 != entry_ptr->notify_before_evict_count) + if (0 != entry_ptr->notify_before_evict_count) CACHE_ERROR("invalid notify before evict count") } /* end for */ /* Remove entries from the cache */ - for(u = 0; u < 5; u++) { + for (u = 0; u < 5; u++) { expunge_entry(file_ptr, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("expunge_entry failed") + if (!pass) + CACHE_ERROR("expunge_entry failed") /* Change expected values, and verify the status of the entries * after each expunge */ - expected[u].in_cache = FALSE; - expected[u].is_dirty = TRUE; + expected[u].in_cache = FALSE; + expected[u].is_dirty = TRUE; expected[u].serialized = FALSE; - expected[u].destroyed = TRUE; + expected[u].destroyed = TRUE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)u, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)u, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") /* Check the entry's 'before evict' count */ - entry_ptr = &(base_addr[u]); - if(1 != entry_ptr->notify_after_insert_count) + entry_ptr = &(base_addr[u]); + if (1 != entry_ptr->notify_after_insert_count) CACHE_ERROR("invalid notify after insert count") - if(1 != entry_ptr->notify_before_evict_count) + if (1 != entry_ptr->notify_before_evict_count) CACHE_ERROR("invalid notify before evict count") } /* end for */ /* Protect entries to bring them into the cache */ - for(u = 0; u < 5; u++) { + for (u = 0; u < 5; u++) { protect_entry(file_ptr, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("protect_entry failed") + if (!pass) + CACHE_ERROR("protect_entry failed") /* Change expected values, and verify the status of the entries * after each insertion */ - expected[u].in_cache = TRUE; - expected[u].is_dirty = FALSE; + expected[u].in_cache = TRUE; + expected[u].is_dirty = FALSE; expected[u].is_protected = TRUE; expected[u].deserialized = TRUE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)u, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)u, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") /* Check the entry's 'after insert' count */ - entry_ptr = &(base_addr[u]); - if(2 != entry_ptr->notify_after_insert_count) + entry_ptr = &(base_addr[u]); + if (2 != entry_ptr->notify_after_insert_count) CACHE_ERROR("invalid notify after insert count") - if(1 != entry_ptr->notify_before_evict_count) + if (1 != entry_ptr->notify_before_evict_count) CACHE_ERROR("invalid notify before evict count") } /* end for */ /* Unprotect entries, evicting them from the cache */ - for(u = 0; u < 5; u++) { + for (u = 0; u < 5; u++) { unprotect_entry(file_ptr, entry_type, (int32_t)u, H5C__DIRTIED_FLAG); - if(!pass) CACHE_ERROR("unprotect_entry failed") + if (!pass) + CACHE_ERROR("unprotect_entry failed") /* Change expected values, and verify the status of the entries * after each insertion */ - expected[u].in_cache = TRUE; - expected[u].is_dirty = TRUE; + expected[u].in_cache = TRUE; + expected[u].is_dirty = TRUE; expected[u].is_protected = FALSE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)u, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)u, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") /* Check the entry's 'after insert' count */ - entry_ptr = &(base_addr[u]); - if(2 != entry_ptr->notify_after_insert_count) + entry_ptr = &(base_addr[u]); + if (2 != entry_ptr->notify_after_insert_count) CACHE_ERROR("invalid notify after insert count") - if(1 != entry_ptr->notify_before_evict_count) + if (1 != entry_ptr->notify_before_evict_count) CACHE_ERROR("invalid notify before evict count") } /* end for */ /* Remove entries from the cache */ - for(u = 0; u < 5; u++) { + for (u = 0; u < 5; u++) { expunge_entry(file_ptr, entry_type, (int32_t)u); - if(!pass) CACHE_ERROR("expunge_entry failed") + if (!pass) + CACHE_ERROR("expunge_entry failed") /* Change expected values, and verify the status of the entries * after each expunge */ - expected[u].in_cache = FALSE; - expected[u].is_dirty = TRUE; + expected[u].in_cache = FALSE; + expected[u].is_dirty = TRUE; expected[u].serialized = FALSE; - expected[u].destroyed = TRUE; + expected[u].destroyed = TRUE; /* Verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - (int)u, /* int tag */ - (int)5, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ - if(!pass) CACHE_ERROR("verify_entry_status failed") + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)u, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if (!pass) + CACHE_ERROR("verify_entry_status failed") /* Check the entry's 'before evict' count */ - entry_ptr = &(base_addr[u]); - if(2 != entry_ptr->notify_after_insert_count) + entry_ptr = &(base_addr[u]); + if (2 != entry_ptr->notify_after_insert_count) CACHE_ERROR("invalid notify after insert count") - if(2 != entry_ptr->notify_before_evict_count) + if (2 != entry_ptr->notify_before_evict_count) CACHE_ERROR("invalid notify before evict count") } /* end for */ done: takedown_cache(file_ptr, FALSE, FALSE); - if(pass) + if (pass) PASSED(); else { H5_FAILED(); @@ -33723,7 +35563,6 @@ done: return (unsigned)!pass; } /* check_notify_cb() */ - /*------------------------------------------------------------------------- * Function: check_metadata_cork * @@ -33741,194 +35580,2743 @@ done: static unsigned check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) { - const char * fcn_name = "check_metadata_cork"; - int entry_type = HUGE_ENTRY_TYPE; - size_t entry_size = HUGE_ENTRY_SIZE; /* 16 KB */ - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - hbool_t show_progress = FALSE; - int32_t checkpoint = 0; - int32_t entry_idx = 0; - int32_t i; + const char *fcn_name = "check_metadata_cork"; + int entry_type = HUGE_ENTRY_TYPE; + size_t entry_size = HUGE_ENTRY_SIZE; /* 16 KB */ + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + hbool_t show_progress = FALSE; + int32_t checkpoint = 0; + int32_t entry_idx = 0; + int32_t i; /* Expected deserialized status of entries depends on how they get into * the cache. Insertions = not deserialized, protect/unprotect = deserialized. */ - hbool_t deserialized = (hbool_t)!(fill_via_insertion); + hbool_t deserialized = (hbool_t) !(fill_via_insertion); /* Set up the expected array. This is used to maintain a table of the * expected status of every entry used in this test. */ - struct expected_entry_status expected[150] = - { - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { HUGE_ENTRY_TYPE, 0, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 1, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 2, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 3, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 4, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 5, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 6, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 7, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 8, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 9, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 10, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 11, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 12, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 13, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 14, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 15, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 16, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 17, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 18, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 19, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 20, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 21, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 22, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 23, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 24, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 25, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 26, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 27, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 28, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 29, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 30, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 31, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 32, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 33, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 34, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 35, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 36, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 37, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 38, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 39, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 40, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 41, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 42, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 43, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 44, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 45, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 46, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 47, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 48, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 49, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 50, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 51, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 52, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 53, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 54, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 55, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 56, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 57, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 58, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 59, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 60, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 61, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 62, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 63, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 64, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 65, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 66, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 67, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 68, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 69, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 70, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 71, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 72, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 73, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 74, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 75, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 76, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 77, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 78, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 79, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 80, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 81, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 82, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 83, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 84, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 85, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 86, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 87, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 88, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 89, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 90, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 91, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 92, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 93, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 94, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 95, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 96, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 97, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 98, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 99, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 100, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 101, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 102, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 103, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 104, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 105, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 106, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 107, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 108, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 109, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 110, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 111, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 112, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 113, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 114, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 115, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 116, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 117, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 118, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 119, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 120, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 121, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 122, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 123, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 124, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 125, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 126, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 127, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 128, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 129, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 130, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 131, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 132, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 133, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 134, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 135, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 136, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 137, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 138, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 139, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 140, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 141, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 142, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 143, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 144, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 145, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 146, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 147, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 148, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 149, HUGE_ENTRY_SIZE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE} - } ; + struct expected_entry_status expected[150] = { + /* entry entry in at main flush + dep flush dep child flush flush flush */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ + {HUGE_ENTRY_TYPE, + 0, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 1, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 2, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 3, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 4, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 5, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 6, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 7, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 8, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 9, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 10, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 11, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 12, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 13, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 14, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 15, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 16, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 17, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 18, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 19, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 20, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 21, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 22, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 23, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 24, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 25, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 26, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 27, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 28, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 29, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 30, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 31, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 32, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 33, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 34, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 35, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 36, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 37, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 38, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 39, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 40, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 41, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 42, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 43, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 44, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 45, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 46, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 47, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 48, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 49, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 50, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 51, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 52, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 53, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 54, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 55, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 56, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 57, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 58, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 59, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 60, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 61, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 62, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 63, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 64, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 65, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 66, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 67, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 68, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 69, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 70, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 71, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 72, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 73, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 74, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 75, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 76, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 77, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 78, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 79, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 80, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 81, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 82, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 83, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 84, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 85, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 86, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 87, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 88, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 89, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 90, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 91, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 92, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 93, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 94, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 95, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 96, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 97, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 98, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 99, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 100, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 101, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 102, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 103, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 104, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 105, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 106, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 107, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 108, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 109, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 110, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 111, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 112, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 113, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 114, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 115, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 116, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 117, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 118, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 119, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 120, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 121, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 122, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 123, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 124, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 125, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 126, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 127, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 128, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 129, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 130, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 131, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 132, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 133, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 134, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 135, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 136, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 137, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 138, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 139, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 140, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 141, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 142, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 143, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 144, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 145, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 146, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 147, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 148, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 149, + HUGE_ENTRY_SIZE, + FALSE, + TRUE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}}; pass = TRUE; reset_entries(); - if(fill_via_insertion) + if (fill_via_insertion) TESTING("to ensure cork/uncork metadata when inserting") else TESTING("to ensure cork/uncork metadata on protect/unprotect") - if(show_progress) /* 0 */ - HDfprintf(stdout, "\n%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); + if (show_progress) /* 0 */ + HDfprintf(stdout, "\n%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(pass) { + if (pass) { /* Set up the cache. * @@ -33937,11 +38325,10 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) */ file_ptr = setup_cache((size_t)(50 * entry_size), (size_t)(25 * entry_size), paged); - if(file_ptr == NULL) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "bad return from cache intialization.\n"; - } else cache_ptr = file_ptr->shared->cache; @@ -33950,9 +38337,8 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) /* Cork the cache entry type */ cork_entry_type(file_ptr, entry_type); - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); /* ======================================================================== * ======================================================================== @@ -33967,35 +38353,35 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) * ======================================================================== */ - if(pass) { + if (pass) { /* Insert 26 entries (indexes 0 through 25) into the cache. */ for (entry_idx = 0; entry_idx < 26; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - - } else { + entry_type, /* int32_t type */ + entry_idx, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* Change expected values, and verify the status of the entries * after each insertion */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; expected[entry_idx].deserialized = (unsigned char)deserialized; - expected[entry_idx].is_corked = TRUE; + expected[entry_idx].is_corked = TRUE; verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ entry_idx, /* int tag */ @@ -34004,9 +38390,8 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) } } - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); /* ======================================================================== * ======================================================================== @@ -34021,22 +38406,23 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) * ======================================================================== */ - if(pass) { + if (pass) { /* Insert the 27th entry (index = 26) into the cache. */ - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + entry_type, /* int32_t type */ + entry_idx++, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ + entry_idx++, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } @@ -34044,14 +38430,14 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) * * Expected status is that there are 27 entries in the cache, and * all entries remain the same as before since they are all corked - * and dirty + * and dirty */ /* entry w/ index 26 is now in the cache and dirty. */ - expected[26].in_cache = TRUE; - expected[26].is_dirty = TRUE; - expected[26].deserialized = (unsigned char)deserialized; - expected[26].is_corked = TRUE; + expected[26].in_cache = TRUE; + expected[26].is_dirty = TRUE; + expected[26].deserialized = (unsigned char)deserialized; + expected[26].is_corked = TRUE; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -34060,25 +38446,24 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) expected); /* expected */ } + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); - - if(pass) { + if (pass) { /* Insert the 28th entry (index = 27) into the cache. */ - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx++, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + entry_type, /* int32_t type */ + entry_idx++, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ entry_idx++, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ @@ -34090,10 +38475,10 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) * all entries are dirty corked entries. * */ - expected[27].in_cache = TRUE; - expected[27].is_dirty = TRUE; - expected[27].deserialized = (unsigned char)deserialized; - expected[27].is_corked = TRUE; + expected[27].in_cache = TRUE; + expected[27].is_dirty = TRUE; + expected[27].deserialized = (unsigned char)deserialized; + expected[27].is_corked = TRUE; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -34102,40 +38487,39 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) expected); /* expected */ } + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); - - if(pass) { + if (pass) { /* Fill out the rest of the cache with entries */ /* Verify expected status of entries after each insertion */ for (entry_idx = entry_idx; entry_idx < 50; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + entry_type, /* int32_t type */ + entry_idx, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* - * Expected status: all entries are dirty corked entries. + * Expected status: all entries are dirty corked entries. */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; - expected[entry_idx].deserialized = (unsigned char)deserialized; - expected[entry_idx].is_corked = TRUE; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].deserialized = (unsigned char)deserialized; + expected[entry_idx].is_corked = TRUE; /* Verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -34145,16 +38529,15 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) } /* Verify that the cache is now full */ - if(cache_ptr->cache_full != TRUE) { + if (cache_ptr->cache_full != TRUE) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not completely filled.\n"; } } - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); /* ======================================================================== * ======================================================================== @@ -34166,36 +38549,36 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) * ======================================================================== */ - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(pass) { + if (pass) { /* Insert 50 more entries (indices 50-99) into the cache. */ for (entry_idx = entry_idx; entry_idx < 100; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ + entry_type, /* int32_t type */ entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* This past inserted entry is now in the cache: dirty and corked */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; - expected[entry_idx].deserialized = (unsigned char)deserialized; - expected[entry_idx].is_corked = TRUE; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].deserialized = (unsigned char)deserialized; + expected[entry_idx].is_corked = TRUE; /* Verify this expected status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -34205,10 +38588,8 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) } } - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); - + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); /* ======================================================================== * ======================================================================== @@ -34221,7 +38602,7 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) * ======================================================================== */ - if(pass) { + if (pass) { /* Flush the cache. * @@ -34231,19 +38612,19 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) */ flush_cache(file_ptr, /* H5F_t * file_ptr */ - FALSE, /* hbool_t destory_entries */ - FALSE, /* hbool_t dump_stats */ - FALSE); /* hbool_t dump_detailed_stats */ + FALSE, /* hbool_t destory_entries */ + FALSE, /* hbool_t dump_stats */ + FALSE); /* hbool_t dump_detailed_stats */ /* Verify that the cache is clean */ verify_clean(); /* Verify the status of the entries. */ - /* All entries are flushed, clean but still corked */ + /* All entries are flushed, clean but still corked */ for (i = 0; i < 100; i++) { expected[i].serialized = TRUE; - expected[i].is_dirty = FALSE; - expected[i].is_corked = TRUE; + expected[i].is_dirty = FALSE; + expected[i].is_corked = TRUE; } verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ 0, /* int tag */ @@ -34251,178 +38632,168 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) expected); /* expected */ } - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); - + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(pass) { + if (pass) { - /* Will evict 50 clean "corked" entries all at once when inserting the 100th entry */ - for(i = 0; i < 51; i++) { - expected[i].in_cache = FALSE; - expected[i].destroyed = TRUE; - expected[i].is_corked = TRUE; - } - - /* Insert the 100th entry */ - if(fill_via_insertion) { - insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - 100, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - - } else { - protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - 100); /* int32-t idx */ + /* Will evict 50 clean "corked" entries all at once when inserting the 100th entry */ + for (i = 0; i < 51; i++) { + expected[i].in_cache = FALSE; + expected[i].destroyed = TRUE; + expected[i].is_corked = TRUE; + } - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - 100, /* int32_t idx */ - H5C__DIRTIED_FLAG); /* unsigned int flags */ - } + /* Insert the 100th entry */ + if (fill_via_insertion) { + insert_entry(file_ptr, /* H5F_t * file_ptr */ + entry_type, /* int32_t type */ + 100, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { + protect_entry(file_ptr, /* H5F_t * file_ptr */ + entry_type, /* int32_t type */ + 100); /* int32-t idx */ - /* The 100th inserted entry is now in the cache and dirty */ - expected[100].in_cache = TRUE; - expected[100].is_dirty = TRUE; - expected[100].deserialized = (unsigned char)deserialized; - expected[100].is_corked = TRUE; + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + entry_type, /* int32_t type */ + 100, /* int32_t idx */ + H5C__DIRTIED_FLAG); /* unsigned int flags */ + } - /* verify the status */ - verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - 100, /* int tag */ - 150, /* int num_entries */ - expected); /* struct expected_entry_staus[] */ + /* The 100th inserted entry is now in the cache and dirty */ + expected[100].in_cache = TRUE; + expected[100].is_dirty = TRUE; + expected[100].deserialized = (unsigned char)deserialized; + expected[100].is_corked = TRUE; + /* verify the status */ + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + 100, /* int tag */ + 150, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ } - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(pass) { + if (pass) { /* Insert 25 more corked entries (indexes 101 through 125) into the cache. */ - /* Clean entry will be evicted one a time */ + /* Clean entry will be evicted one a time */ for (entry_idx = 101; entry_idx < 126; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - - } else { + entry_type, /* int32_t type */ + entry_idx, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* The inserted entry is now in the cache and dirty */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; - expected[entry_idx].deserialized = (unsigned char)deserialized; - expected[entry_idx].is_corked = TRUE; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].deserialized = (unsigned char)deserialized; + expected[entry_idx].is_corked = TRUE; - expected[entry_idx - 50].in_cache = FALSE; - expected[entry_idx - 50].destroyed = TRUE; - expected[entry_idx - 50].is_corked = TRUE; + expected[entry_idx - 50].in_cache = FALSE; + expected[entry_idx - 50].destroyed = TRUE; + expected[entry_idx - 50].is_corked = TRUE; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ entry_idx, /* int tag */ 150, /* int num_entries */ expected); /* struct expected_entry_staus[] */ - } /* end for */ - + } /* end for */ } + if (show_progress) /* 10 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(show_progress) /* 10 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); - - - if(pass) { + if (pass) { /* Insert the 127th entry (index = 126) into the cache. */ - if(fill_via_insertion) { - insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - 126, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - } else { - protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ + if (fill_via_insertion) { + insert_entry(file_ptr, /* H5F_t * file_ptr */ + entry_type, /* int32_t type */ + 126, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { + protect_entry(file_ptr, /* H5F_t * file_ptr */ + entry_type, /* int32_t type */ 126); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - 126, /* int32_t idx */ + 126, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* Verify the status of the entries. */ - expected[126].in_cache = TRUE; - expected[126].is_dirty = TRUE; - expected[126].deserialized = (unsigned char)deserialized; - expected[126].is_corked = TRUE; + expected[126].in_cache = TRUE; + expected[126].is_dirty = TRUE; + expected[126].deserialized = (unsigned char)deserialized; + expected[126].is_corked = TRUE; - expected[126 - 50].in_cache = FALSE; - expected[126 - 50].destroyed = TRUE; - expected[126 - 50].is_corked = TRUE; + expected[126 - 50].in_cache = FALSE; + expected[126 - 50].destroyed = TRUE; + expected[126 - 50].is_corked = TRUE; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ - 126, /* int tag */ + 126, /* int tag */ 150, /* int num_entries */ expected); /* expected */ } + if (show_progress) /* 11 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(show_progress) /* 11 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); - - - if(pass) { + if (pass) { /* Insert entries w/ indices 127 through 149 into the cache */ for (entry_idx = 127; entry_idx < 150; entry_idx++) { - if(fill_via_insertion) { + if (fill_via_insertion) { insert_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - - } else { + entry_type, /* int32_t type */ + entry_idx, /* int32_t idx */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + } + else { protect_entry(file_ptr, /* H5F_t * file_ptr */ - entry_type, /* int32_t type */ - entry_idx); /* int32-t idx */ + entry_type, /* int32_t type */ + entry_idx); /* int32-t idx */ - unprotect_entry(file_ptr, /* H5F_t * file_ptr */ + unprotect_entry(file_ptr, /* H5F_t * file_ptr */ entry_type, /* int32_t type */ - entry_idx, /* int32_t idx */ + entry_idx, /* int32_t idx */ H5C__DIRTIED_FLAG); /* unsigned int flags */ } /* This past inserted entry is now in the cache, dirty and corked */ - expected[entry_idx].in_cache = TRUE; - expected[entry_idx].is_dirty = TRUE; - expected[entry_idx].deserialized = (unsigned char)deserialized; - expected[entry_idx].is_corked = TRUE; + expected[entry_idx].in_cache = TRUE; + expected[entry_idx].is_dirty = TRUE; + expected[entry_idx].deserialized = (unsigned char)deserialized; + expected[entry_idx].is_corked = TRUE; - /* Entry that is 50 entries away will be evicted since it is clean even though corked */ - expected[entry_idx - 50].in_cache = FALSE; - expected[entry_idx - 50].destroyed = TRUE; - expected[entry_idx - 50].is_corked = TRUE; + /* Entry that is 50 entries away will be evicted since it is clean even though corked */ + expected[entry_idx - 50].in_cache = FALSE; + expected[entry_idx - 50].destroyed = TRUE; + expected[entry_idx - 50].is_corked = TRUE; /* verify the status */ verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ @@ -34430,29 +38801,29 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) 150, /* int num_entries */ expected); /* struct expected_entry_staus[] */ } - } - if(show_progress) /* 12 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); - + if (show_progress) /* 12 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); /* We're done with testing. We can take down the cache. */ takedown_cache(file_ptr, FALSE, FALSE); reset_entries(); - if(show_progress) /* 13 */ - HDfprintf(stdout, "%s: check point %d -- pass %d\n", - fcn_name, checkpoint++, pass); + if (show_progress) /* 13 */ + HDfprintf(stdout, "%s: check point %d -- pass %d\n", fcn_name, checkpoint++, pass); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } return (unsigned)!pass; } /* check_metadata_cork() */ - /*------------------------------------------------------------------------- * Function: check_entry_deletions_during_scans() * @@ -34486,9 +38857,9 @@ check_metadata_cork(hbool_t fill_via_insertion, unsigned paged) static unsigned check_entry_deletions_during_scans(unsigned paged) { - H5F_t * file_ptr = NULL; + H5F_t *file_ptr = NULL; - if(paged) + if (paged) TESTING("entry deletion during list scan detection and adaption (par)") else TESTING("entry deletion during list scan detection and adaption") @@ -34500,7 +38871,7 @@ check_entry_deletions_during_scans(unsigned paged) * place. */ - if(pass) { + if (pass) { reset_entries(); @@ -34513,43 +38884,44 @@ check_entry_deletions_during_scans(unsigned paged) * a different entry could cause problems. */ - if(pass) { + if (pass) { cedds__expunge_dirty_entry_in_flush_test(file_ptr); } - if(pass) { + if (pass) { cedds__H5C_make_space_in_cache(file_ptr); } - if(pass) { + if (pass) { cedds__H5C__autoadjust__ageout__evict_aged_out_entries(file_ptr); } - if(pass) { + if (pass) { cedds__H5C_flush_invalidate_cache__bucket_scan(file_ptr); } - - takedown_cache(file_ptr, FALSE, FALSE); - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } return (unsigned)!pass; } /* check_entry_deletions_during_scans() */ - /*------------------------------------------------------------------------- * Function: cedds__expunge_dirty_entry_in_flush_test() * @@ -34580,149 +38952,210 @@ check_entry_deletions_during_scans(unsigned paged) */ static void -cedds__expunge_dirty_entry_in_flush_test(H5F_t * file_ptr) +cedds__expunge_dirty_entry_in_flush_test(H5F_t *file_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; - int i; - herr_t result; - struct expected_entry_status expected[36] = - { - /* the expected array is used to maintain a table of the expected status of every - * entry used in this test. Note that since the function that processes this - * array only processes as much of it as it is told to, we don't have to - * worry about maintaining the status of entries that we haven't used yet. - */ - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { HUGE_ENTRY_TYPE, 0, HUGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 1, HUGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 2, HUGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 3, HUGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE} - }; - - if(pass) { - - if(cache_ptr == NULL) { - - pass = FALSE; + H5C_t * cache_ptr = file_ptr->shared->cache; + int i; + herr_t result; + struct expected_entry_status expected[36] = { + /* the expected array is used to maintain a table of the expected status of every + * entry used in this test. Note that since the function that processes this + * array only processes as much of it as it is told to, we don't have to + * worry about maintaining the status of entries that we haven't used yet. + */ + /* entry entry in at main flush dep flush dep child flush flush + flush */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: + */ + {HUGE_ENTRY_TYPE, + 0, + HUGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 1, + HUGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 2, + HUGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 3, + HUGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}}; + + if (pass) { + + if (cache_ptr == NULL) { + + pass = FALSE; failure_mssg = "cache_ptr NULL on entry to cedds expunge dirty entry in flush test."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not empty on entry to cedds expunge dirty entry in flush test."; } - else if((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - - pass = FALSE; - failure_mssg = - "unexpected cache config at start of cedds expunge dirty entry in flush test."; + else if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - } else { + pass = FALSE; + failure_mssg = "unexpected cache config at start of cedds expunge dirty entry in flush test."; + } + else { /* set min clean size to zero for this test as it simplifies - * computing the expected cache size after each operation. - */ + * computing the expected cache size after each operation. + */ cache_ptr->min_clean_size = 0; } } - if(pass) { + if (pass) { - /* The basic idea of this test is to setup the cache such - * that: - * - * 1) the cache contains several dirty entries. - * - * 2) the first entry on the slist is dirty, and has a flush - * operation that will remove the second entry on the + /* The basic idea of this test is to setup the cache such + * that: + * + * 1) the cache contains several dirty entries. + * + * 2) the first entry on the slist is dirty, and has a flush + * operation that will remove the second entry on the * slist. * * Then load flush the cache. Cache should handle the - * removal of the next entry in the slist scan gracefully. + * removal of the next entry in the slist scan gracefully. */ - /* reset the stats before we start. If stats are enabled, we will - * check to see if they are as expected at the end. - */ - H5C_stats__reset(cache_ptr); - + /* reset the stats before we start. If stats are enabled, we will + * check to see if they are as expected at the end. + */ + H5C_stats__reset(cache_ptr); - /* Load four huge entries into the cache. Recall that huge entries + /* Load four huge entries into the cache. Recall that huge entries * are one fourth the size of monster entries (16 KB vs. 64 KB). */ - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { - protect_entry(file_ptr, HUGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, HUGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, HUGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, HUGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); } - if((cache_ptr->index_len != 4) || - (cache_ptr->index_size != (4 * HUGE_ENTRY_SIZE))) { + if ((cache_ptr->index_len != 4) || (cache_ptr->index_size != (4 * HUGE_ENTRY_SIZE))) { pass = FALSE; - failure_mssg = "unexpected size/len in cedds expunge dirty entry in flush test (1)"; - } + failure_mssg = "unexpected size/len in cedds expunge dirty entry in flush test (1)"; + } } - if(pass) { - - /* Next, set up the flush operation: - * - * (HET, 0) expunges (HET, 1) - * - */ - add_flush_op(HUGE_ENTRY_TYPE, 0, FLUSH_OP__EXPUNGE, - HUGE_ENTRY_TYPE, 1, FALSE, (size_t)0, NULL); + if (pass) { + /* Next, set up the flush operation: + * + * (HET, 0) expunges (HET, 1) + * + */ + add_flush_op(HUGE_ENTRY_TYPE, 0, FLUSH_OP__EXPUNGE, HUGE_ENTRY_TYPE, 1, FALSE, (size_t)0, NULL); } - if(pass) { + if (pass) { - /* to summarize, at present the following entries - * are in cache with the following characteristics: - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (HET, 0) Y 16 KB Y N - expunge (HET 1) - * - * (HET, 1) Y 16 KB Y N - - + /* to summarize, at present the following entries + * are in cache with the following characteristics: + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (HET, 0) Y 16 KB Y N - expunge (HET 1) + * + * (HET, 1) Y 16 KB Y N - - * - * (HET, 2) Y 16 KB Y N - - + * (HET, 2) Y 16 KB Y N - - * - * (HET, 3) Y 16 KB Y N - - - * - * Recall that in this test bed, flush operations are excuted the - * first time the associated entry is flushed, and are then - * deleted. - */ + * (HET, 3) Y 16 KB Y N - - + * + * Recall that in this test bed, flush operations are excuted the + * first time the associated entry is flushed, and are then + * deleted. + */ - /* verify the expected status of all entries we have loaded to date: */ - verify_entry_status(cache_ptr, 0, 4, expected); + /* verify the expected status of all entries we have loaded to date: */ + verify_entry_status(cache_ptr, 0, 4, expected); } /* flush the cache to run the test. In the process, clean up after test. */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Cache flush invalidate failed in cedds expunge dirty entry in flush test"; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache len/size after cedds expunge dirty entry in flush test"; - } } @@ -34730,43 +39163,38 @@ cedds__expunge_dirty_entry_in_flush_test(H5F_t * file_ptr) /* If we are collecting stats, check to see if we get the expected * values. */ - if(pass) - if((cache_ptr->insertions[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->clears[HUGE_ENTRY_TYPE] != 1) || - (cache_ptr->flushes[HUGE_ENTRY_TYPE] != 3) || - (cache_ptr->evictions[HUGE_ENTRY_TYPE] != 4) || - (cache_ptr->take_ownerships[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->moves[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->pins[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[HUGE_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->insertions[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->clears[HUGE_ENTRY_TYPE] != 1) || (cache_ptr->flushes[HUGE_ENTRY_TYPE] != 3) || + (cache_ptr->evictions[HUGE_ENTRY_TYPE] != 4) || + (cache_ptr->take_ownerships[HUGE_ENTRY_TYPE] != 0) || (cache_ptr->moves[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[HUGE_ENTRY_TYPE] != 0) || (cache_ptr->pins[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->unpins[HUGE_ENTRY_TYPE] != 0) || (cache_ptr->dirty_pins[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[HUGE_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected huge size entry stats in cedds__expunge_dirty_entry_in_flush_test()."; } /* end if */ - if(pass) - if((cache_ptr->slist_scan_restarts != 1) || - (cache_ptr->LRU_scan_restarts != 0) || - (cache_ptr->index_scan_restarts != 0)) { - pass = FALSE; + if (pass) + if ((cache_ptr->slist_scan_restarts != 1) || (cache_ptr->LRU_scan_restarts != 0) || + (cache_ptr->index_scan_restarts != 0)) { + pass = FALSE; failure_mssg = "unexpected scan restart stats in cedds__expunge_dirty_entry_in_flush_test()."; } /* end if */ -#endif /* H5C_COLLECT_CACHE_STATS */ +#endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) + if (pass) reset_entries(); - if(pass) + if (pass) /* reset cache min clean size to its expected value */ cache_ptr->min_clean_size = (1 * 1024 * 1024); @@ -34774,7 +39202,6 @@ cedds__expunge_dirty_entry_in_flush_test(H5F_t * file_ptr) } /* cedds__expunge_dirty_entry_in_flush_test() */ - /*------------------------------------------------------------------------- * Function: cedds__H5C_make_space_in_cache() * @@ -34807,199 +39234,803 @@ cedds__expunge_dirty_entry_in_flush_test(H5F_t * file_ptr) */ static void -cedds__H5C_make_space_in_cache(H5F_t * file_ptr) +cedds__H5C_make_space_in_cache(H5F_t *file_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; - int i; - const int num_huge_entries = 4; - const int num_monster_entries = 32; - herr_t result; - struct expected_entry_status expected[36] = - { - /* the expected array is used to maintain a table of the expected status of every - * entry used in this test. Note that since the function that processes this - * array only processes as much of it as it is told to, we don't have to - * worry about maintaining the status of entries that we haven't used yet. - */ - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { HUGE_ENTRY_TYPE, 0, HUGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 1, HUGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 2, HUGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { HUGE_ENTRY_TYPE, 3, HUGE_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 0, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 1, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 2, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 3, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 4, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 5, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 6, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 7, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 8, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 9, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 10, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 11, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 12, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 13, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 14, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 15, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 16, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 17, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 18, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 19, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 20, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 21, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 22, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 23, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 24, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 25, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 26, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 27, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 28, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 29, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 30, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 31, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, + H5C_t * cache_ptr = file_ptr->shared->cache; + int i; + const int num_huge_entries = 4; + const int num_monster_entries = 32; + herr_t result; + struct expected_entry_status expected[36] = { + /* the expected array is used to maintain a table of the expected status of every + * entry used in this test. Note that since the function that processes this + * array only processes as much of it as it is told to, we don't have to + * worry about maintaining the status of entries that we haven't used yet. + */ + /* entry entry in at main flush dep flush dep child flush flush + flush */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ + {HUGE_ENTRY_TYPE, + 0, + HUGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 1, + HUGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 2, + HUGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {HUGE_ENTRY_TYPE, + 3, + HUGE_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 0, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 1, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 2, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 3, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 4, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 5, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 6, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 7, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 8, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 9, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 10, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 11, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 12, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 13, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 14, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 15, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 16, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 17, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 18, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 19, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 20, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 21, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 22, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 23, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 24, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 25, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 26, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 27, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 28, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 29, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 30, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 31, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, }; - if(pass) { + if (pass) { - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache_ptr NULL on entry to cedds for H5C__make_space_in_cache() test."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not empty at start of flush ops eviction test."; } - else if((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + else if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; - failure_mssg = - "unexpected cache config at start of cedds H5C__make_space_in_cache() test."; - - } else { + pass = FALSE; + failure_mssg = "unexpected cache config at start of cedds H5C__make_space_in_cache() test."; + } + else { /* set min clean size to zero for this test as it simplifies - * computing the expected cache size after each operation. - */ + * computing the expected cache size after each operation. + */ cache_ptr->min_clean_size = 0; } } - if(pass) { + if (pass) { - /* The basic idea of this test is to setup the cache such - * that: - * - * 1) the cache is full - * - * 2) the last entry on the LRU is dirty, and has a flush - * operation that will remove the second to last entry + /* The basic idea of this test is to setup the cache such + * that: + * + * 1) the cache is full + * + * 2) the last entry on the LRU is dirty, and has a flush + * operation that will remove the second to last entry * on the LRU from the cache. * * Then load another entry into the cache. See if - * H5C__make_space_in_cache() detects the removal of - * the next item in the scan, and restarts the scan + * H5C__make_space_in_cache() detects the removal of + * the next item in the scan, and restarts the scan * from the bottom of the LRU. Note that the newly * loaded entry must be large enough to require that * the scan continue after the entry is expunged. */ - /* reset the stats before we start. If stats are enabled, we will - * check to see if they are as expected at the end. - */ - H5C_stats__reset(cache_ptr); - + /* reset the stats before we start. If stats are enabled, we will + * check to see if they are as expected at the end. + */ + H5C_stats__reset(cache_ptr); - /* Load four huge entries into the cache. Recall that huge entries + /* Load four huge entries into the cache. Recall that huge entries * are one fourth the size of monster entries (16 KB vs. 64 KB). */ - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { - protect_entry(file_ptr, HUGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, HUGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, HUGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, HUGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); } - if((cache_ptr->index_len != 4) || - (cache_ptr->index_size != (4 * HUGE_ENTRY_SIZE))) { + if ((cache_ptr->index_len != 4) || (cache_ptr->index_size != (4 * HUGE_ENTRY_SIZE))) { pass = FALSE; - failure_mssg = "unexpected size/len in H5C__make_space_in_cache() test (1)"; - } + failure_mssg = "unexpected size/len in H5C__make_space_in_cache() test (1)"; + } } - if(pass) { - - /* Next, set up the flush operation: - * - * (HET, 0) expunges (HET, 1) - * - */ - add_flush_op(HUGE_ENTRY_TYPE, 0, FLUSH_OP__EXPUNGE, - HUGE_ENTRY_TYPE, 1, FALSE, (size_t)0, NULL); + if (pass) { + /* Next, set up the flush operation: + * + * (HET, 0) expunges (HET, 1) + * + */ + add_flush_op(HUGE_ENTRY_TYPE, 0, FLUSH_OP__EXPUNGE, HUGE_ENTRY_TYPE, 1, FALSE, (size_t)0, NULL); } - if(pass) { + if (pass) { - /* to summarize, at present the following entries - * are in cache with the following characteristics: - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (HET, 0) Y 16 KB Y N - expunge (HET 1) - * - * (HET, 1) Y 16 KB N N - - + /* to summarize, at present the following entries + * are in cache with the following characteristics: * - * (HET, 2) Y 16 KB N N - - + * in + * entry: cache? size: dirty? pinned? pins: flush operations: * - * (HET, 3) Y 16 KB N N - - - * - * Recall that in this test bed, flush operations are excuted the - * first time the associated entry is flushed, and are then - * deleted. - */ + * (HET, 0) Y 16 KB Y N - expunge (HET 1) + * + * (HET, 1) Y 16 KB N N - - + * + * (HET, 2) Y 16 KB N N - - + * + * (HET, 3) Y 16 KB N N - - + * + * Recall that in this test bed, flush operations are excuted the + * first time the associated entry is flushed, and are then + * deleted. + */ /* Now fill up the cache with other, unrelated entries. Recall * that the cache size is 2 MB and 31 * 64 KB + 4 * 16 KP == 2 MB. */ - for (i = 0; i < 31; i++) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + for (i = 0; i < 31; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } - - /* The cache should now be exactly full */ - if((cache_ptr->index_len != 35) || - (cache_ptr->index_size != 2 * 1024 * 1024) || - (cache_ptr->index_size != ((4 * HUGE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE)))) { + } - pass = FALSE; - failure_mssg = "unexpected size/len in H5C__make_space_in_cache() test (2)"; + /* The cache should now be exactly full */ + if ((cache_ptr->index_len != 35) || (cache_ptr->index_size != 2 * 1024 * 1024) || + (cache_ptr->index_size != ((4 * HUGE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE)))) { - } else { + pass = FALSE; + failure_mssg = "unexpected size/len in H5C__make_space_in_cache() test (2)"; + } + else { - /* verify the expected status of all entries we have loaded to date: */ - verify_entry_status(cache_ptr, 0, 35, expected); - } + /* verify the expected status of all entries we have loaded to date: */ + verify_entry_status(cache_ptr, 0, 35, expected); + } } - if(pass) { + if (pass) { /* now load another monster entry. This should cause - * H5C__make_space_in_cache() to be called. (HET 0) is dirty, and is at - * the bottom of the LRU. * Thus it will be flushed, and moved to the - * head of the LRU. However, during the flush, (HET 1) should be expunged - * from the cache. Since (MET 1) is the next item in - * H5C__make_space_in_cache(), must detect its removal from the cache, + * H5C__make_space_in_cache() to be called. (HET 0) is dirty, and is at + * the bottom of the LRU. * Thus it will be flushed, and moved to the + * head of the LRU. However, during the flush, (HET 1) should be expunged + * from the cache. Since (MET 1) is the next item in + * H5C__make_space_in_cache(), must detect its removal from the cache, * and refrain from trying to flush it. * * Since all entries in the cache are dirty, all entries will be flushed, @@ -35014,7 +40045,7 @@ cedds__H5C_make_space_in_cache(H5F_t * file_ptr) protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31); } - if(pass) { + if (pass) { /* if the protect succeeded, unprotect and verify that all is at * it should be. @@ -35022,59 +40053,54 @@ cedds__H5C_make_space_in_cache(H5F_t * file_ptr) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31, H5C__DIRTIED_FLAG); - /* The cache should now be exactly full */ - if((cache_ptr->index_len != 32) || - (cache_ptr->index_size != 2 * 1024 * 1024) || - (cache_ptr->index_size != (32 * MONSTER_ENTRY_SIZE))) { + /* The cache should now be exactly full */ + if ((cache_ptr->index_len != 32) || (cache_ptr->index_size != 2 * 1024 * 1024) || + (cache_ptr->index_size != (32 * MONSTER_ENTRY_SIZE))) { - pass = FALSE; - failure_mssg = "unexpected size/len in H5C__make_space_in_cache() test (3)"; - - } else { + pass = FALSE; + failure_mssg = "unexpected size/len in H5C__make_space_in_cache() test (3)"; + } + else { - /* modify the expected table to match the new situation, and + /* modify the expected table to match the new situation, and * then call verify_entry_status(). */ - for (i = 0; i < num_huge_entries; i++) - { - expected[i].in_cache = FALSE; - expected[i].is_dirty = FALSE; - expected[i].serialized = TRUE; - expected[i].destroyed = TRUE; + for (i = 0; i < num_huge_entries; i++) { + expected[i].in_cache = FALSE; + expected[i].is_dirty = FALSE; + expected[i].serialized = TRUE; + expected[i].destroyed = TRUE; } /* (HET, 1) was expunged, so touch its entry up accordingly */ - expected[1].is_dirty = TRUE; - expected[1].serialized = FALSE; + expected[1].is_dirty = TRUE; + expected[1].serialized = FALSE; - for (i = num_huge_entries; i < num_huge_entries + num_monster_entries - 1; i++) - { - expected[i].is_dirty = FALSE; - expected[i].serialized = TRUE; + for (i = num_huge_entries; i < num_huge_entries + num_monster_entries - 1; i++) { + expected[i].is_dirty = FALSE; + expected[i].serialized = TRUE; } - /* verify the expected status of all entries: */ - verify_entry_status(cache_ptr, 0, 36, expected); + /* verify the expected status of all entries: */ + verify_entry_status(cache_ptr, 0, 36, expected); } } /* flush the cache and end the test. */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Cache flush invalidate failed after flush op eviction test"; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache len/size after cleanup of flush op eviction test"; - } } @@ -35083,71 +40109,64 @@ cedds__H5C_make_space_in_cache(H5F_t * file_ptr) * values. */ - if(pass) { - - if((cache_ptr->insertions[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->clears[HUGE_ENTRY_TYPE] != 1) || - (cache_ptr->flushes[HUGE_ENTRY_TYPE] != 3) || - (cache_ptr->evictions[HUGE_ENTRY_TYPE] != 4) || - (cache_ptr->take_ownerships[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->moves[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->pins[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[HUGE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[HUGE_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if (pass) { + + if ((cache_ptr->insertions[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->clears[HUGE_ENTRY_TYPE] != 1) || (cache_ptr->flushes[HUGE_ENTRY_TYPE] != 3) || + (cache_ptr->evictions[HUGE_ENTRY_TYPE] != 4) || + (cache_ptr->take_ownerships[HUGE_ENTRY_TYPE] != 0) || (cache_ptr->moves[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[HUGE_ENTRY_TYPE] != 0) || (cache_ptr->pins[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->unpins[HUGE_ENTRY_TYPE] != 0) || (cache_ptr->dirty_pins[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[HUGE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[HUGE_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected large entry stats in cedds__H5C_make_space_in_cache()."; } } - if(pass) - if((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster entry stats in cedds__H5C_make_space_in_cache()."; } /* end if */ - if(pass) - if((cache_ptr->slist_scan_restarts != 0) || - (cache_ptr->LRU_scan_restarts != 1) || - (cache_ptr->index_scan_restarts != 0)) { + if (pass) + if ((cache_ptr->slist_scan_restarts != 0) || (cache_ptr->LRU_scan_restarts != 1) || + (cache_ptr->index_scan_restarts != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected scan restart stats in cedds__H5C_make_space_in_cache()."; } /* end if */ #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) + if (pass) reset_entries(); - if(pass) + if (pass) /* reset cache min clean size to its expected value */ cache_ptr->min_clean_size = (1 * 1024 * 1024); @@ -35155,7 +40174,6 @@ cedds__H5C_make_space_in_cache(H5F_t * file_ptr) } /* cedds__H5C_make_space_in_cache() */ - /*------------------------------------------------------------------------- * Function: cedds__H5C__autoadjust__ageout__evict_aged_out_entries() * @@ -35188,56 +40206,600 @@ cedds__H5C_make_space_in_cache(H5F_t * file_ptr) */ static void -cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) +cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *file_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; - int i; - herr_t result; - struct expected_entry_status expected[36] = - { - /* the expected array is used to maintain a table of the expected status of every - * entry used in this test. Note that since the function that processes this - * array only processes as much of it as it is told to, we don't have to - * worry about maintaining the status of entries that we haven't used yet. - */ - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { MONSTER_ENTRY_TYPE, 0, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 1, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 2, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 3, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 4, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 5, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 6, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 7, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 8, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 9, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 10, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 11, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 12, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 13, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 14, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 15, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 16, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 17, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 18, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 19, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 20, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 21, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 22, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 23, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 24, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 25, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 26, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 27, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 28, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 29, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 30, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 31, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, 0, 0, 0, -1, FALSE}, + H5C_t * cache_ptr = file_ptr->shared->cache; + int i; + herr_t result; + struct expected_entry_status expected[36] = { + /* the expected array is used to maintain a table of the expected status of every + * entry used in this test. Note that since the function that processes this + * array only processes as much of it as it is told to, we don't have to + * worry about maintaining the status of entries that we haven't used yet. + */ + /* entry entry in at main flush dep flush dep child flush flush + flush */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ + {MONSTER_ENTRY_TYPE, + 0, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 1, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 2, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 3, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 4, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 5, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 6, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 7, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 8, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 9, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 10, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 11, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 12, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 13, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 14, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 15, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 16, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 17, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 18, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 19, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 20, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 21, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 22, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 23, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 24, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 25, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 26, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 27, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 28, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 29, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 30, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 31, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1}, + 0, + 0, + 0, + -1, + FALSE}, }; H5C_auto_size_ctl_t saved_auto_size_ctl; - H5C_auto_size_ctl_t test_auto_size_ctl = - { + H5C_auto_size_ctl_t test_auto_size_ctl = { /* int32_t version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* H5C_auto_resize_report_fcn rpt_fcn = */ test_rpt_fcn, @@ -35251,7 +40813,6 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) /* int64_t epoch_length = */ 1000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, /* double lower_hr_threshold = */ 0.75f, @@ -35262,10 +40823,9 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out, @@ -35279,151 +40839,145 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) /* int32_t epochs_before_eviction = */ 1, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f - }; + /* double empty_reserve = */ 0.05f}; - if(pass) { + if (pass) { - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { - pass = FALSE; - failure_mssg = "cache_ptr NULL on entry to cedds for H5C__autoadjust__ageout__evict_aged_out_entries() test."; + pass = FALSE; + failure_mssg = "cache_ptr NULL on entry to cedds for " + "H5C__autoadjust__ageout__evict_aged_out_entries() test."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - failure_mssg = "cache not empty at start cedds for H5C__autoadjust__ageout__evict_aged_out_entries() test."; + failure_mssg = + "cache not empty at start cedds for H5C__autoadjust__ageout__evict_aged_out_entries() test."; } - else if((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + else if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; - failure_mssg = - "unexpected cache config at start of cedds H5C__autoadjust__ageout__evict_aged_out_entries() test."; - - } else { + pass = FALSE; + failure_mssg = "unexpected cache config at start of cedds " + "H5C__autoadjust__ageout__evict_aged_out_entries() test."; + } + else { /* set min clean size to zero for this test as it simplifies - * computing the expected cache size after each operation. - */ + * computing the expected cache size after each operation. + */ cache_ptr->min_clean_size = 0; } } /* save the initial resize configuration so we can restore it later */ - if(pass) { + if (pass) { saved_auto_size_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; - result = H5C_get_cache_auto_resize_config(cache_ptr, - &saved_auto_size_ctl); + result = H5C_get_cache_auto_resize_config(cache_ptr, &saved_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_get_cache_auto_resize_config failed."; - } } /* set the resize configuration we will be using in the test */ - if(pass) { + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &test_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 1.\n"; } } - if(pass) { + if (pass) { - /* The basic idea of this test is to setup the cache such - * that: - * - * 1) the cache is full - * - * 2) the last entry on the LRU is dirty, and has a flush - * operation that will remove the second to last entry + /* The basic idea of this test is to setup the cache such + * that: + * + * 1) the cache is full + * + * 2) the last entry on the LRU is dirty, and has a flush + * operation that will remove the second to last entry * on the LRU from the cache. * * Then access the first item in the LRU until the epoch - * and H5C__autoadjust__ageout__evict_aged_out_entries() + * and H5C__autoadjust__ageout__evict_aged_out_entries() * is invoked. Verify that the function deals with the - * deletion of the next item in its scan cleanly. + * deletion of the next item in its scan cleanly. */ - /* reset the stats before we start. If stats are enabled, we will - * check to see if they are as expected at the end. - */ - H5C_stats__reset(cache_ptr); - + /* reset the stats before we start. If stats are enabled, we will + * check to see if they are as expected at the end. + */ + H5C_stats__reset(cache_ptr); /* load the first entry -- mark it dirty */ - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__DIRTIED_FLAG); /* Then load the rest of the entries to fill the cache: * * Recall that the cache size is 2 MB and 32 * 64 KB == 2 MB. */ - for (i = 1; i < 32; i++) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + for (i = 1; i < 32; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); + } } - } - - if(pass) { - /* Next, set up the flush operation: - * - * (MET, 0) expunges (MET, 1) - * - */ - add_flush_op(MONSTER_ENTRY_TYPE, 0, FLUSH_OP__EXPUNGE, - MONSTER_ENTRY_TYPE, 1, FALSE, (size_t)0, NULL); + if (pass) { + /* Next, set up the flush operation: + * + * (MET, 0) expunges (MET, 1) + * + */ + add_flush_op(MONSTER_ENTRY_TYPE, 0, FLUSH_OP__EXPUNGE, MONSTER_ENTRY_TYPE, 1, FALSE, (size_t)0, NULL); } - if(pass) { + if (pass) { - /* to summarize, at present the following entries - * are in cache with the following characteristics: - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (MET, 0) Y 64 KB Y N - expunge (MET 1) - * - * (MET, 1-31) Y 64 KB N N - - - * - * Recall that in this test bed, flush operations are excuted the - * first time the associated entry is flushed, and are then - * deleted. - */ + /* to summarize, at present the following entries + * are in cache with the following characteristics: + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (MET, 0) Y 64 KB Y N - expunge (MET 1) + * + * (MET, 1-31) Y 64 KB N N - - + * + * Recall that in this test bed, flush operations are excuted the + * first time the associated entry is flushed, and are then + * deleted. + */ - /* The cache should now be exactly full */ - if((cache_ptr->index_len != 32) || - (cache_ptr->index_size != 2 * 1024 * 1024) || - (cache_ptr->index_size != (32 * MONSTER_ENTRY_SIZE))) { + /* The cache should now be exactly full */ + if ((cache_ptr->index_len != 32) || (cache_ptr->index_size != 2 * 1024 * 1024) || + (cache_ptr->index_size != (32 * MONSTER_ENTRY_SIZE))) { pass = FALSE; - failure_mssg = "unexpected size/len in H5C__autoadjust__ageout__evict_aged_out_entries() test (1)"; - - } else { + failure_mssg = + "unexpected size/len in H5C__autoadjust__ageout__evict_aged_out_entries() test (1)"; + } + else { - /* verify the expected status of all entries we have loaded to date: */ - verify_entry_status(cache_ptr, 0, 32, expected); - } + /* verify the expected status of all entries we have loaded to date: */ + verify_entry_status(cache_ptr, 0, 32, expected); + } } /* protect and unprotect (MET, 31) repeatedly until the end of the first epoch */ - while(pass && (cache_ptr->cache_accesses > 0)) { + while (pass && (cache_ptr->cache_accesses > 0)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31, H5C__NO_FLAGS_SET); @@ -35431,7 +40985,7 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) /* at this point, an epoch marker entry should have been inserted into the LRU */ - if(pass) { + if (pass) { /* protect and unprotect (MET, 31) again to get cache_accesses > 0 */ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31); @@ -35439,7 +40993,7 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) } /* protect and unprotect (MET, 31) repeatedly until the end of the second epoch */ - while(pass && (cache_ptr->cache_accesses > 0)) { + while (pass && (cache_ptr->cache_accesses > 0)) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31, H5C__NO_FLAGS_SET); @@ -35451,66 +41005,63 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) * moved to the head of the LRU by the ageout algorithm.) */ - if(pass) { + if (pass) { - if((cache_ptr->index_len != 2) || - (cache_ptr->index_size != 2 * MONSTER_ENTRY_SIZE)) { + if ((cache_ptr->index_len != 2) || (cache_ptr->index_size != 2 * MONSTER_ENTRY_SIZE)) { pass = FALSE; - failure_mssg = "unexpected size/len in H5C__autoadjust__ageout__evict_aged_out_entries() test (2)"; - - } else { + failure_mssg = + "unexpected size/len in H5C__autoadjust__ageout__evict_aged_out_entries() test (2)"; + } + else { /* update the expected table to reflect the expected values at * this point, and then verify. */ - expected[0].is_dirty = FALSE; - expected[0].serialized = TRUE; + expected[0].is_dirty = FALSE; + expected[0].serialized = TRUE; - for (i = 1; i < 31; i++) - { - expected[i].in_cache = FALSE; - expected[i].is_dirty = FALSE; - expected[i].destroyed = TRUE; + for (i = 1; i < 31; i++) { + expected[i].in_cache = FALSE; + expected[i].is_dirty = FALSE; + expected[i].destroyed = TRUE; } - verify_entry_status(cache_ptr, 0, 32, expected); - } + verify_entry_status(cache_ptr, 0, 32, expected); + } } /* restore the initial resize configuration */ - if(pass) { + if (pass) { saved_auto_size_ctl.set_initial_size = TRUE; saved_auto_size_ctl.initial_size = 2 * 1024 * 1024; result = H5C_set_cache_auto_resize_config(cache_ptr, &saved_auto_size_ctl); - if(result != SUCCEED) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_set_cache_auto_resize_config failed 2.\n"; } } /* flush the cache and end the test. */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Cache flush invalidate failed after flush op eviction test"; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache len/size after cleanup of flush op eviction test"; - } } @@ -35519,45 +41070,44 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) * values. */ - if(pass) - if((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + if (pass) + if ((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { pass = FALSE; - failure_mssg = "Unexpected monster entry stats in cedds__H5C__autoadjust__ageout__evict_aged_out_entries()."; + failure_mssg = + "Unexpected monster entry stats in cedds__H5C__autoadjust__ageout__evict_aged_out_entries()."; } /* end if */ - if(pass) - if((cache_ptr->slist_scan_restarts != 0) || - (cache_ptr->LRU_scan_restarts != 1) || - (cache_ptr->index_scan_restarts != 0)) { + if (pass) + if ((cache_ptr->slist_scan_restarts != 0) || (cache_ptr->LRU_scan_restarts != 1) || + (cache_ptr->index_scan_restarts != 0)) { pass = FALSE; - failure_mssg = "unexpected scan restart stats in cedds__H5C__autoadjust__ageout__evict_aged_out_entries()."; + failure_mssg = + "unexpected scan restart stats in cedds__H5C__autoadjust__ageout__evict_aged_out_entries()."; } /* end if */ #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) + if (pass) reset_entries(); - if(pass) + if (pass) /* reset cache min clean size to its expected value */ cache_ptr->min_clean_size = (1 * 1024 * 1024); @@ -35565,7 +41115,6 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) } /* cedds__H5C__autoadjust__ageout__evict_aged_out_entries() */ - /*------------------------------------------------------------------------- * Function: cedds__H5C_flush_invalidate_cache__bucket_scan() * @@ -35659,91 +41208,176 @@ cedds__H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * file_ptr) */ static void -cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr) +cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t *file_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; - int i; - int expected_hash_bucket = 0; - herr_t result; - haddr_t entry_addr; - test_entry_t * entry_ptr; - test_entry_t * base_addr = NULL; - struct H5C_cache_entry_t * scan_ptr; - struct expected_entry_status expected[5] = - { - /* the expected array is used to maintain a table of the expected status of every - * entry used in this test. Note that since the function that processes this - * array only processes as much of it as it is told to, we don't have to - * worry about maintaining the status of entries that we haven't used yet. - */ - /* entry entry in at main flush dep flush dep child flush flush flush */ - /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: */ - { MONSTER_ENTRY_TYPE, 0, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, {-1,0,0,0,0,0,0,0}, {-1,0,0,0,0,0,0,0}, 0, 1, 1, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 8, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,0,0,0,0,0,0,0}, {-1,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 16, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,0,0,0,0,0,0,0}, {-1,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 24, MONSTER_ENTRY_SIZE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, {-1,0,0,0,0,0,0,0}, {-1,0,0,0,0,0,0,0}, 0, 0, 0, -1, FALSE}, - { MONSTER_ENTRY_TYPE, 31, MONSTER_ENTRY_SIZE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, {MONSTER_ENTRY_TYPE,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 1, 0, 0, -1, FALSE}, + H5C_t * cache_ptr = file_ptr->shared->cache; + int i; + int expected_hash_bucket = 0; + herr_t result; + haddr_t entry_addr; + test_entry_t * entry_ptr; + test_entry_t * base_addr = NULL; + struct H5C_cache_entry_t * scan_ptr; + struct expected_entry_status expected[5] = { + /* the expected array is used to maintain a table of the expected status of every + * entry used in this test. Note that since the function that processes this + * array only processes as much of it as it is told to, we don't have to + * worry about maintaining the status of entries that we haven't used yet. + */ + /* entry entry in at main flush dep flush dep child flush flush + flush */ + /* type: index: size: cache: addr: dirty: prot: pinned: dsrlzd: + srlzd: dest: par type[]: par idx[]: dep npart: dep nchd: dep ndirty chd: order: corked: + */ + {MONSTER_ENTRY_TYPE, + 0, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + TRUE, + TRUE, + FALSE, + FALSE, + {-1, 0, 0, 0, 0, 0, 0, 0}, + {-1, 0, 0, 0, 0, 0, 0, 0}, + 0, + 1, + 1, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 8, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, 0, 0, 0, 0, 0, 0, 0}, + {-1, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 16, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, 0, 0, 0, 0, 0, 0, 0}, + {-1, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 24, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + FALSE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {-1, 0, 0, 0, 0, 0, 0, 0}, + {-1, 0, 0, 0, 0, 0, 0, 0}, + 0, + 0, + 0, + -1, + FALSE}, + {MONSTER_ENTRY_TYPE, + 31, + MONSTER_ENTRY_SIZE, + TRUE, + TRUE, + TRUE, + FALSE, + FALSE, + TRUE, + FALSE, + FALSE, + {MONSTER_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + 1, + 0, + 0, + -1, + FALSE}, }; - if(pass) { + if (pass) { - if(cache_ptr == NULL) { + if (cache_ptr == NULL) { pass = FALSE; - failure_mssg = "cache_ptr NULL on entry to cedds for cedds__H5C_flush_invalidate_cache__bucket_scan() test."; + failure_mssg = + "cache_ptr NULL on entry to cedds for cedds__H5C_flush_invalidate_cache__bucket_scan() test."; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = FALSE; - failure_mssg = "cache not empty at start cedds for cedds__H5C_flush_invalidate_cache__bucket_scan() test."; + failure_mssg = + "cache not empty at start cedds for cedds__H5C_flush_invalidate_cache__bucket_scan() test."; } - else if((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + else if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; - failure_mssg = - "unexpected cache config at start of cedds cedds__H5C_flush_invalidate_cache__bucket_scan() test."; - - } else { + pass = FALSE; + failure_mssg = "unexpected cache config at start of cedds " + "cedds__H5C_flush_invalidate_cache__bucket_scan() test."; + } + else { /* set min clean size to zero for this test as it simplifies - * computing the expected cache size after each operation. - */ + * computing the expected cache size after each operation. + */ cache_ptr->min_clean_size = 0; } } + if (pass) { - if(pass) { - - /* reset the stats before we start. If stats are enabled, we will - * check to see if they are as expected at the end. - */ - - H5C_stats__reset(cache_ptr); + /* reset the stats before we start. If stats are enabled, we will + * check to see if they are as expected at the end. + */ + H5C_stats__reset(cache_ptr); - /* load one dirty and three clean entries that should hash to the + /* load one dirty and three clean entries that should hash to the * same hash bucket. */ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__DIRTIED_FLAG); - for (i = 8; i <= 24; i += 8) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + for (i = 8; i <= 24; i += 8) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); - } + } } - if(pass) { + if (pass) { /* verify that the above entries hash to the same bucket */ - base_addr = entries[MONSTER_ENTRY_TYPE]; - entry_ptr = &(base_addr[0]); + base_addr = entries[MONSTER_ENTRY_TYPE]; + entry_ptr = &(base_addr[0]); entry_addr = entry_ptr->header.addr; HDassert(entry_addr == entry_ptr->addr); @@ -35752,87 +41386,84 @@ cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr) for (i = 8; i <= 24; i += 8) { - entry_ptr = &(base_addr[i]); + entry_ptr = &(base_addr[i]); entry_addr = entry_ptr->header.addr; - if(expected_hash_bucket != H5C__HASH_FCN(entry_addr)) { + if (expected_hash_bucket != H5C__HASH_FCN(entry_addr)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Test entries don't map to same bucket -- hash table size or hash fcn change?"; } } } - if(pass) { + if (pass) { - /* setup the expunge flush operation: - * - * (MET, 0) expunges (MET, 8) - * - */ - add_flush_op(MONSTER_ENTRY_TYPE, 0, FLUSH_OP__EXPUNGE, - MONSTER_ENTRY_TYPE, 8, FALSE, (size_t)0, NULL); + /* setup the expunge flush operation: + * + * (MET, 0) expunges (MET, 8) + * + */ + add_flush_op(MONSTER_ENTRY_TYPE, 0, FLUSH_OP__EXPUNGE, MONSTER_ENTRY_TYPE, 8, FALSE, (size_t)0, NULL); } - if(pass) { + if (pass) { /* load the entry that will have a flush dependencey with (MET, 0), * thus preventing it from being flushed on the first pass through * the skip list. */ - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 31, H5C__DIRTIED_FLAG); } - if(pass) { + if (pass) { /* verify that the dirty entry doesn't map to the same * hash bucket as the clean entries. */ - entry_ptr = &(base_addr[31]); + entry_ptr = &(base_addr[31]); entry_addr = entry_ptr->header.addr; - if(expected_hash_bucket == H5C__HASH_FCN(entry_addr)) { + if (expected_hash_bucket == H5C__HASH_FCN(entry_addr)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Dirty entry maps to same hash bucket as clean entries?!?!"; } } - if(pass) { + if (pass) { - /* Next, create the flush dependency requiring (MET, 31) to + /* Next, create the flush dependency requiring (MET, 31) to * be flushed prior to (MET, 0). - */ + */ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0); create_flush_dependency(MONSTER_ENTRY_TYPE, 0, MONSTER_ENTRY_TYPE, 31); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 0, H5C__DIRTIED_FLAG); - } - if(pass) { + if (pass) { /* Then, setup the flush operation to take down the flush * dependency when (MET, 31) is flushed. - * - * (MET, 31) destroys flush dependency with (MET, 8) - * + * + * (MET, 31) destroys flush dependency with (MET, 8) + * */ - add_flush_op(MONSTER_ENTRY_TYPE, 31, FLUSH_OP__DEST_FLUSH_DEP, - MONSTER_ENTRY_TYPE, 0, FALSE, (size_t)0, NULL); - + add_flush_op(MONSTER_ENTRY_TYPE, 31, FLUSH_OP__DEST_FLUSH_DEP, MONSTER_ENTRY_TYPE, 0, FALSE, + (size_t)0, NULL); } - if(pass) { + if (pass) { - /* verify the expected status of all entries we have loaded to date: */ + /* verify the expected status of all entries we have loaded to date: */ verify_entry_status(cache_ptr, 0, 5, expected); } - if(pass) { + if (pass) { /* now do some protect / unprotect cycles to force the * entries into the desired order in the hash bucket. @@ -35840,14 +41471,13 @@ cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr) * hash bucket list on lookup. */ - for (i = 24; i >= 0; i -= 8) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + for (i = 24; i >= 0; i -= 8) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); - } + } } - if(pass) { + if (pass) { /* scan the hash bucket to verify that the expected entries appear * in the expected order. @@ -35856,48 +41486,43 @@ cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr) i = 0; - while(pass && (i <= 24)) - { + while (pass && (i <= 24)) { entry_ptr = &(base_addr[i]); - if(scan_ptr == NULL) { + if (scan_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "premature end of hash bucket list?!?!"; + } + else if ((scan_ptr == NULL) || (scan_ptr != &(entry_ptr->header))) { - } else if((scan_ptr == NULL) || - (scan_ptr != &(entry_ptr->header))) { - - pass = FALSE; + pass = FALSE; failure_mssg = "bad test hash bucket setup?!?!"; } - if(pass) { + if (pass) { scan_ptr = scan_ptr->ht_next; i += 8; } - } + } } - /* test setup complete -- flush the cache to run and end the test. */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Cache flush invalidate failed after flush op eviction test"; } - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache len/size after cleanup of flush op eviction test"; - } } @@ -35906,48 +41531,47 @@ cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr) * values. */ - if(pass) - if((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 2) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 5) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + if (pass) + if ((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 2) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 5) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 1) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { pass = FALSE; - failure_mssg = "Unexpected monster entry stats in cedds__H5C_flush_invalidate_cache__bucket_scan()."; + failure_mssg = + "Unexpected monster entry stats in cedds__H5C_flush_invalidate_cache__bucket_scan()."; } /* end if */ - if(pass) + if (pass) /* as this test is now checking for index list scan restarts, * the following has been modified to check this instead of * hash bucket scan restarts. */ - if((cache_ptr->slist_scan_restarts != 0) || - (cache_ptr->LRU_scan_restarts != 0) || - (cache_ptr->index_scan_restarts != 1)) { + if ((cache_ptr->slist_scan_restarts != 0) || (cache_ptr->LRU_scan_restarts != 0) || + (cache_ptr->index_scan_restarts != 1)) { pass = FALSE; - failure_mssg = "unexpected scan restart stats in cedds__H5C_flush_invalidate_cache__bucket_scan()."; + failure_mssg = + "unexpected scan restart stats in cedds__H5C_flush_invalidate_cache__bucket_scan()."; } #endif /* H5C_COLLECT_CACHE_STATS */ - if(pass) + if (pass) reset_entries(); - if(pass) + if (pass) /* reset cache min clean size to its expected value */ cache_ptr->min_clean_size = (1 * 1024 * 1024); @@ -35955,7 +41579,6 @@ cedds__H5C_flush_invalidate_cache__bucket_scan(H5F_t * file_ptr) } /* cedds__H5C_flush_invalidate_cache__bucket_scan() */ - /*------------------------------------------------------------------------- * Function: check_stats() * @@ -35983,11 +41606,11 @@ check_stats(unsigned paged) #if H5C_COLLECT_CACHE_STATS - H5F_t * file_ptr = NULL; + H5F_t *file_ptr = NULL; #endif /* H5C_COLLECT_CACHE_STATS */ - if(paged) + if (paged) TESTING("metadata cache statistics collection (paged aggregation)") else TESTING("metadata cache statistics collection") @@ -36000,24 +41623,26 @@ check_stats(unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); - if(pass) { + if (pass) { check_stats__smoke_check_1(file_ptr); } - - - if(pass) { + if (pass) { takedown_cache(file_ptr, FALSE, FALSE); } - if(pass) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if(!pass) { + if (!pass) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", FUNC, failure_mssg); } #else /* H5C_COLLECT_CACHE_STATS */ @@ -36032,7 +41657,6 @@ check_stats(unsigned paged) } /* check_stats() */ - /*------------------------------------------------------------------------- * Function: check_stats__smoke_check_1() * @@ -36061,206 +41685,176 @@ check_stats(unsigned paged) */ #if H5C_COLLECT_CACHE_STATS static void -check_stats__smoke_check_1(H5F_t * file_ptr) +check_stats__smoke_check_1(H5F_t *file_ptr) { - H5C_t * cache_ptr = file_ptr->shared->cache; - int i; - herr_t result; + H5C_t *cache_ptr = file_ptr->shared->cache; + int i; + herr_t result; - if(pass) { - if(cache_ptr == NULL) { + if (pass) { + if (cache_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache_ptr NULL on entry to check_stats__smoke_check_1()."; } /* end if */ - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache not empty on entry to check_stats__smoke_check_1()."; } /* end else-if */ - else if((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + else if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { - pass = FALSE; - failure_mssg = "unexpected cache config at start of check_stats__smoke_check_1()."; + pass = FALSE; + failure_mssg = "unexpected cache config at start of check_stats__smoke_check_1()."; } /* end else-if */ - else { + else { /* set min clean size to zero for this test as it simplifies - * computing the expected cache size after each operation. - */ + * computing the expected cache size after each operation. + */ cache_ptr->min_clean_size = 0; } /* end else */ - } /* end if */ + } /* end if */ - if(pass) + if (pass) /* first fill the cache with monster entryies via insertion */ - for(i = 0; i < 32; i++) + for (i = 0; i < 32; i++) insert_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); - if(pass) - if((cache_ptr->hits[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->misses[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->write_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->read_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_read_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->hits[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->misses[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->write_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->read_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_read_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster size entry stats in check_stats__smoke_check_1(1)."; } /* end if */ - if(pass) - if((cache_ptr->total_ht_insertions != 32) || - (cache_ptr->total_ht_deletions != 0) || - (cache_ptr->successful_ht_searches != 0) || - (cache_ptr->total_successful_ht_search_depth != 0) || - (cache_ptr->failed_ht_searches != 32) || - (cache_ptr->total_failed_ht_search_depth != 48) || - (cache_ptr->max_index_len != 32) || - (cache_ptr->max_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_clean_index_size != 0) || - (cache_ptr->max_dirty_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_slist_len != 32) || - (cache_ptr->max_slist_size != 2 * 1024 * 1024) || - (cache_ptr->max_pl_len != 0) || - (cache_ptr->max_pl_size != 0) || - (cache_ptr->max_pel_len != 0) || - (cache_ptr->max_pel_size != 0) || - (cache_ptr->calls_to_msic != 0) || - (cache_ptr->total_entries_skipped_in_msic != 0) || - (cache_ptr->total_entries_scanned_in_msic != 0) || - (cache_ptr->max_entries_skipped_in_msic != 0) || - (cache_ptr->max_entries_scanned_in_msic != 0) || - (cache_ptr->entries_scanned_to_make_space != 0) || - (cache_ptr->slist_scan_restarts != 0) || - (cache_ptr->LRU_scan_restarts != 0) || - (cache_ptr->index_scan_restarts != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->total_ht_insertions != 32) || (cache_ptr->total_ht_deletions != 0) || + (cache_ptr->successful_ht_searches != 0) || (cache_ptr->total_successful_ht_search_depth != 0) || + (cache_ptr->failed_ht_searches != 32) || (cache_ptr->total_failed_ht_search_depth != 48) || + (cache_ptr->max_index_len != 32) || (cache_ptr->max_index_size != 2 * 1024 * 1024) || + (cache_ptr->max_clean_index_size != 0) || (cache_ptr->max_dirty_index_size != 2 * 1024 * 1024) || + (cache_ptr->max_slist_len != 32) || (cache_ptr->max_slist_size != 2 * 1024 * 1024) || + (cache_ptr->max_pl_len != 0) || (cache_ptr->max_pl_size != 0) || (cache_ptr->max_pel_len != 0) || + (cache_ptr->max_pel_size != 0) || (cache_ptr->calls_to_msic != 0) || + (cache_ptr->total_entries_skipped_in_msic != 0) || + (cache_ptr->total_entries_scanned_in_msic != 0) || + (cache_ptr->max_entries_skipped_in_msic != 0) || (cache_ptr->max_entries_scanned_in_msic != 0) || + (cache_ptr->entries_scanned_to_make_space != 0) || (cache_ptr->slist_scan_restarts != 0) || + (cache_ptr->LRU_scan_restarts != 0) || (cache_ptr->index_scan_restarts != 0)) { + + pass = FALSE; failure_mssg = "Unexpected cache stats in check_stats__smoke_check_1(1)."; } /* end if */ #if H5C_COLLECT_CACHE_ENTRY_STATS - if(pass) + if (pass) /* Note that most entry level stats are only updated on entry eviction */ - if((cache_ptr->max_accesses[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->min_accesses[MONSTER_ENTRY_TYPE] != 1000000) || /* initial value */ - (cache_ptr->max_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_size[MONSTER_ENTRY_TYPE] != 64 * 1024) || - (cache_ptr->max_pins[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if ((cache_ptr->max_accesses[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->min_accesses[MONSTER_ENTRY_TYPE] != 1000000) || /* initial value */ + (cache_ptr->max_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_size[MONSTER_ENTRY_TYPE] != 64 * 1024) || + (cache_ptr->max_pins[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster entry level stats in check_stats__smoke_check_1(1)."; } /* end if */ -#endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ +#endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ - if(pass) + if (pass) /* protect and unprotect each entry once. Note * that all entries are already dirty, as they * entered the cache via insertion */ - for(i = 0; i < 32; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); + for (i = 0; i < 32; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__NO_FLAGS_SET); } /* end for */ - if(pass) - if((cache_ptr->hits[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->misses[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->write_protects[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->read_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_read_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->hits[MONSTER_ENTRY_TYPE] != 32) || (cache_ptr->misses[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->write_protects[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->read_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_read_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster size entry stats in check_stats__smoke_check_1(2)."; } /* end if */ - if(pass) - if((cache_ptr->total_ht_insertions != 32) || - (cache_ptr->total_ht_deletions != 0) || - (cache_ptr->successful_ht_searches != 32) || - (cache_ptr->total_successful_ht_search_depth != 96) || - (cache_ptr->failed_ht_searches != 32) || - (cache_ptr->total_failed_ht_search_depth != 48) || - (cache_ptr->max_index_len != 32) || - (cache_ptr->max_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_clean_index_size != 0) || - (cache_ptr->max_dirty_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_slist_len != 32) || - (cache_ptr->max_slist_size != 2 * 1024 * 1024) || - (cache_ptr->max_pl_len != 1) || - (cache_ptr->max_pl_size != 64 * 1024) || - (cache_ptr->max_pel_len != 0) || - (cache_ptr->max_pel_size != 0) || - (cache_ptr->calls_to_msic != 0) || - (cache_ptr->total_entries_skipped_in_msic != 0) || - (cache_ptr->total_entries_scanned_in_msic != 0) || - (cache_ptr->max_entries_skipped_in_msic != 0) || - (cache_ptr->max_entries_scanned_in_msic != 0) || - (cache_ptr->entries_scanned_to_make_space != 0) || - (cache_ptr->slist_scan_restarts != 0) || - (cache_ptr->LRU_scan_restarts != 0) || - (cache_ptr->index_scan_restarts != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->total_ht_insertions != 32) || (cache_ptr->total_ht_deletions != 0) || + (cache_ptr->successful_ht_searches != 32) || + (cache_ptr->total_successful_ht_search_depth != 96) || (cache_ptr->failed_ht_searches != 32) || + (cache_ptr->total_failed_ht_search_depth != 48) || (cache_ptr->max_index_len != 32) || + (cache_ptr->max_index_size != 2 * 1024 * 1024) || (cache_ptr->max_clean_index_size != 0) || + (cache_ptr->max_dirty_index_size != 2 * 1024 * 1024) || (cache_ptr->max_slist_len != 32) || + (cache_ptr->max_slist_size != 2 * 1024 * 1024) || (cache_ptr->max_pl_len != 1) || + (cache_ptr->max_pl_size != 64 * 1024) || (cache_ptr->max_pel_len != 0) || + (cache_ptr->max_pel_size != 0) || (cache_ptr->calls_to_msic != 0) || + (cache_ptr->total_entries_skipped_in_msic != 0) || + (cache_ptr->total_entries_scanned_in_msic != 0) || + (cache_ptr->max_entries_skipped_in_msic != 0) || (cache_ptr->max_entries_scanned_in_msic != 0) || + (cache_ptr->entries_scanned_to_make_space != 0) || (cache_ptr->slist_scan_restarts != 0) || + (cache_ptr->LRU_scan_restarts != 0) || (cache_ptr->index_scan_restarts != 0)) { + + pass = FALSE; failure_mssg = "Unexpected cache stats in check_stats__smoke_check_1(2)."; } /* end if */ #if H5C_COLLECT_CACHE_ENTRY_STATS - if(pass) + if (pass) /* Note that most entry level stats are only updated on entry eviction */ - if((cache_ptr->max_accesses[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->min_accesses[MONSTER_ENTRY_TYPE] != 1000000) || /* initial value */ - (cache_ptr->max_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_size[MONSTER_ENTRY_TYPE] != 64 * 1024) || - (cache_ptr->max_pins[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if ((cache_ptr->max_accesses[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->min_accesses[MONSTER_ENTRY_TYPE] != 1000000) || /* initial value */ + (cache_ptr->max_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_size[MONSTER_ENTRY_TYPE] != 64 * 1024) || + (cache_ptr->max_pins[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster entry level stats in check_stats__smoke_check_1(2)."; } /* end if */ -#endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ +#endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ - if(pass) { + if (pass) { /* protect and unprotect an entry that is not currently * in the cache. Since the cache is full and all entries * are dirty, this will force a flush of each entry, and @@ -36270,83 +41864,70 @@ check_stats__smoke_check_1(H5F_t * file_ptr) unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 32, H5C__DIRTIED_FLAG); } /* end if */ - if(pass) - if((cache_ptr->hits[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->misses[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->write_protects[MONSTER_ENTRY_TYPE] != 33) || - (cache_ptr->read_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_read_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->hits[MONSTER_ENTRY_TYPE] != 32) || (cache_ptr->misses[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->write_protects[MONSTER_ENTRY_TYPE] != 33) || + (cache_ptr->read_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_read_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster size entry stats in check_stats__smoke_check_1(3)."; } /* end if */ - if(pass) - if((cache_ptr->total_ht_insertions != 33) || - (cache_ptr->total_ht_deletions != 1) || - (cache_ptr->successful_ht_searches != 32) || - (cache_ptr->total_successful_ht_search_depth != 96) || - (cache_ptr->failed_ht_searches != 33) || - (cache_ptr->total_failed_ht_search_depth != 52) || - (cache_ptr->max_index_len != 32) || - (cache_ptr->max_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_clean_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_dirty_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_slist_len != 32) || - (cache_ptr->max_slist_size != 2 * 1024 * 1024) || - (cache_ptr->max_pl_len != 1) || - (cache_ptr->max_pl_size != 64 * 1024) || - (cache_ptr->max_pel_len != 0) || - (cache_ptr->max_pel_size != 0) || - (cache_ptr->calls_to_msic != 1) || - (cache_ptr->total_entries_skipped_in_msic != 0) || - (cache_ptr->total_entries_scanned_in_msic != 33) || - (cache_ptr->max_entries_skipped_in_msic != 0) || - (cache_ptr->max_entries_scanned_in_msic != 33) || - (cache_ptr->entries_scanned_to_make_space != 33) || - (cache_ptr->slist_scan_restarts != 0) || - (cache_ptr->LRU_scan_restarts != 0) || - (cache_ptr->index_scan_restarts != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->total_ht_insertions != 33) || (cache_ptr->total_ht_deletions != 1) || + (cache_ptr->successful_ht_searches != 32) || + (cache_ptr->total_successful_ht_search_depth != 96) || (cache_ptr->failed_ht_searches != 33) || + (cache_ptr->total_failed_ht_search_depth != 52) || (cache_ptr->max_index_len != 32) || + (cache_ptr->max_index_size != 2 * 1024 * 1024) || + (cache_ptr->max_clean_index_size != 2 * 1024 * 1024) || + (cache_ptr->max_dirty_index_size != 2 * 1024 * 1024) || (cache_ptr->max_slist_len != 32) || + (cache_ptr->max_slist_size != 2 * 1024 * 1024) || (cache_ptr->max_pl_len != 1) || + (cache_ptr->max_pl_size != 64 * 1024) || (cache_ptr->max_pel_len != 0) || + (cache_ptr->max_pel_size != 0) || (cache_ptr->calls_to_msic != 1) || + (cache_ptr->total_entries_skipped_in_msic != 0) || + (cache_ptr->total_entries_scanned_in_msic != 33) || + (cache_ptr->max_entries_skipped_in_msic != 0) || (cache_ptr->max_entries_scanned_in_msic != 33) || + (cache_ptr->entries_scanned_to_make_space != 33) || (cache_ptr->slist_scan_restarts != 0) || + (cache_ptr->LRU_scan_restarts != 0) || (cache_ptr->index_scan_restarts != 0)) { + + pass = FALSE; failure_mssg = "Unexpected cache stats in check_stats__smoke_check_1(3)."; } /* end if */ #if H5C_COLLECT_CACHE_ENTRY_STATS - if(pass) + if (pass) /* Note that most entry level stats are only updated on entry eviction */ - if((cache_ptr->max_accesses[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->min_accesses[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->max_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_flushes[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->max_size[MONSTER_ENTRY_TYPE] != 64 * 1024) || - (cache_ptr->max_pins[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if ((cache_ptr->max_accesses[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->min_accesses[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->max_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_flushes[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->max_size[MONSTER_ENTRY_TYPE] != 64 * 1024) || + (cache_ptr->max_pins[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster entry level stats in check_stats__smoke_check_1(3)."; } /* end if */ #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ - if(pass) { + if (pass) { /* protect and unprotect dirty (MET, 1), and then flush destroy * the cache. */ @@ -36356,104 +41937,90 @@ check_stats__smoke_check_1(H5F_t * file_ptr) /* flush the cache to end the test and collect all entry stats */ - if(pass) { + if (pass) { result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); - if(result < 0) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "Cache flush invalidate failed in check_stats__smoke_check_1()"; } /* end if */ - else if((cache_ptr->index_len != 0) || - (cache_ptr->index_size != 0)) { + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected cache len/size after check_stats__smoke_check_1()"; } /* end else-if */ - } /* end if */ - - if(pass) - if((cache_ptr->hits[MONSTER_ENTRY_TYPE] != 33) || - (cache_ptr->misses[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->write_protects[MONSTER_ENTRY_TYPE] != 34) || - (cache_ptr->read_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_read_protects[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 34) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 33) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + } /* end if */ + + if (pass) + if ((cache_ptr->hits[MONSTER_ENTRY_TYPE] != 33) || (cache_ptr->misses[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->write_protects[MONSTER_ENTRY_TYPE] != 34) || + (cache_ptr->read_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_read_protects[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 34) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 33) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster size entry stats in check_stats__smoke_check_1(4)."; } /* end if */ - if(pass) - if((cache_ptr->total_ht_insertions != 33) || - (cache_ptr->total_ht_deletions != 33) || - (cache_ptr->successful_ht_searches != 33) || - (cache_ptr->total_successful_ht_search_depth != 99) || - (cache_ptr->failed_ht_searches != 33) || - (cache_ptr->total_failed_ht_search_depth != 52) || - (cache_ptr->max_index_len != 32) || - (cache_ptr->max_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_clean_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_dirty_index_size != 2 * 1024 * 1024) || - (cache_ptr->max_slist_len != 32) || - (cache_ptr->max_slist_size != 2 * 1024 * 1024) || - (cache_ptr->max_pl_len != 1) || - (cache_ptr->max_pl_size != 64 * 1024) || - (cache_ptr->max_pel_len != 0) || - (cache_ptr->max_pel_size != 0) || - (cache_ptr->calls_to_msic != 1) || - (cache_ptr->total_entries_skipped_in_msic != 0) || - (cache_ptr->total_entries_scanned_in_msic != 33) || - (cache_ptr->max_entries_skipped_in_msic != 0) || - (cache_ptr->max_entries_scanned_in_msic != 33) || - (cache_ptr->entries_scanned_to_make_space != 33) || - (cache_ptr->slist_scan_restarts != 0) || - (cache_ptr->LRU_scan_restarts != 0) || - (cache_ptr->index_scan_restarts != 0)) { - - pass = FALSE; + if (pass) + if ((cache_ptr->total_ht_insertions != 33) || (cache_ptr->total_ht_deletions != 33) || + (cache_ptr->successful_ht_searches != 33) || + (cache_ptr->total_successful_ht_search_depth != 99) || (cache_ptr->failed_ht_searches != 33) || + (cache_ptr->total_failed_ht_search_depth != 52) || (cache_ptr->max_index_len != 32) || + (cache_ptr->max_index_size != 2 * 1024 * 1024) || + (cache_ptr->max_clean_index_size != 2 * 1024 * 1024) || + (cache_ptr->max_dirty_index_size != 2 * 1024 * 1024) || (cache_ptr->max_slist_len != 32) || + (cache_ptr->max_slist_size != 2 * 1024 * 1024) || (cache_ptr->max_pl_len != 1) || + (cache_ptr->max_pl_size != 64 * 1024) || (cache_ptr->max_pel_len != 0) || + (cache_ptr->max_pel_size != 0) || (cache_ptr->calls_to_msic != 1) || + (cache_ptr->total_entries_skipped_in_msic != 0) || + (cache_ptr->total_entries_scanned_in_msic != 33) || + (cache_ptr->max_entries_skipped_in_msic != 0) || (cache_ptr->max_entries_scanned_in_msic != 33) || + (cache_ptr->entries_scanned_to_make_space != 33) || (cache_ptr->slist_scan_restarts != 0) || + (cache_ptr->LRU_scan_restarts != 0) || (cache_ptr->index_scan_restarts != 0)) { + + pass = FALSE; failure_mssg = "Unexpected cache stats in check_stats__smoke_check_1(4)."; } /* end if */ #if H5C_COLLECT_CACHE_ENTRY_STATS - if(pass) + if (pass) /* Note that most entry level stats are only updated on entry eviction */ - if((cache_ptr->max_accesses[MONSTER_ENTRY_TYPE] != 2) || - (cache_ptr->min_accesses[MONSTER_ENTRY_TYPE] != 1) || - (cache_ptr->max_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->max_flushes[MONSTER_ENTRY_TYPE] != 2) || - (cache_ptr->max_size[MONSTER_ENTRY_TYPE] != 64 * 1024) || - (cache_ptr->max_pins[MONSTER_ENTRY_TYPE] != 0)) { - - pass = FALSE; + if ((cache_ptr->max_accesses[MONSTER_ENTRY_TYPE] != 2) || + (cache_ptr->min_accesses[MONSTER_ENTRY_TYPE] != 1) || + (cache_ptr->max_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->max_flushes[MONSTER_ENTRY_TYPE] != 2) || + (cache_ptr->max_size[MONSTER_ENTRY_TYPE] != 64 * 1024) || + (cache_ptr->max_pins[MONSTER_ENTRY_TYPE] != 0)) { + + pass = FALSE; failure_mssg = "Unexpected monster entry level stats in check_stats__smoke_check_1(4)."; } /* end if */ #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ - if(pass) + if (pass) reset_entries(); - if(pass) + if (pass) /* reset cache min clean size to its expected value */ cache_ptr->min_clean_size = (1 * 1024 * 1024); @@ -36463,10 +42030,8 @@ check_stats__smoke_check_1(H5F_t * file_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ - /* Call back functions: */ - /*------------------------------------------------------------------------- * * Function: check_if_write_permitted @@ -36489,14 +42054,13 @@ check_stats__smoke_check_1(H5F_t * file_ptr) static herr_t check_write_permitted(const H5F_t H5_ATTR_UNUSED *f, hbool_t *write_permitted_ptr) { - HDassert( write_permitted_ptr ); + HDassert(write_permitted_ptr); *write_permitted_ptr = write_permitted; - return(SUCCEED); + return (SUCCEED); } /* check_write_permitted() */ - /***************************************************************************** * * Function: setup_cache() @@ -36530,146 +42094,140 @@ check_write_permitted(const H5F_t H5_ATTR_UNUSED *f, hbool_t *write_permitted_pt *****************************************************************************/ H5F_t * -setup_cache(size_t max_cache_size, - size_t min_clean_size, - unsigned paged) +setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged) { - char filename[512]; + char filename[512]; hbool_t show_progress = FALSE; - hbool_t verbose = TRUE; - int mile_stone = 1; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5F_t * ret_val = NULL; + hbool_t verbose = TRUE; + int mile_stone = 1; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5F_t * ret_val = NULL; haddr_t actual_base_addr; - hid_t fapl_id = H5P_DEFAULT; - hid_t fcpl_id = H5P_DEFAULT; + hid_t fapl_id = H5P_DEFAULT; + hid_t fcpl_id = H5P_DEFAULT; - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); saved_fid = -1; - if(pass) { - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) == FAIL) { - pass = FALSE; + if (pass) { + if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) == FAIL) { + pass = FALSE; failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; } } - if(pass && paged) { + if (pass && paged) { /* Set up paged aggregation strategy */ - if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) == FAIL) { - pass = FALSE; + if (H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) == FAIL) { + pass = FALSE; failure_mssg = "H5Pset_file_space_strategy() failed.\n"; H5Pclose(fcpl_id); - fcpl_id = H5P_DEFAULT; + fcpl_id = H5P_DEFAULT; } } - if(pass && paged) { + if (pass && paged) { /* Set up file space page size to BASE_ADDR */ - if(H5Pset_file_space_page_size(fcpl_id, (hsize_t)BASE_ADDR) == FAIL) { - pass = FALSE; + if (H5Pset_file_space_page_size(fcpl_id, (hsize_t)BASE_ADDR) == FAIL) { + pass = FALSE; failure_mssg = "H5Pset_file_space_page_size() failed.\n"; H5Pclose(fcpl_id); - fcpl_id = H5P_DEFAULT; + fcpl_id = H5P_DEFAULT; } } - if(pass) + if (pass) saved_fcpl_id = fcpl_id; /* setup the file name */ - if(pass) { - if(NULL == h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename))) { - pass = FALSE; + if (pass) { + if (NULL == h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename))) { + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass && try_core_file_driver) { - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; + if (pass && try_core_file_driver) { + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; } - else if(H5Pset_fapl_core(fapl_id, MAX_ADDR, FALSE) < 0) { - H5Pclose(fapl_id); - fapl_id = H5P_DEFAULT; - pass = FALSE; - failure_mssg = "H5P_set_fapl_core() failed.\n"; + else if (H5Pset_fapl_core(fapl_id, MAX_ADDR, FALSE) < 0) { + H5Pclose(fapl_id); + fapl_id = H5P_DEFAULT; + pass = FALSE; + failure_mssg = "H5P_set_fapl_core() failed.\n"; } - else if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) { - core_file_driver_failed = TRUE; + else if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) { + core_file_driver_failed = TRUE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: H5Fcreate() with CFD failed.\n", FUNC); - } else { - saved_fapl_id = fapl_id; - } + } + else { + saved_fapl_id = fapl_id; + } } - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); /* if we either aren't using the core file driver, or a create * with the core file driver failed, try again with a regular file. * If this fails, we are cooked. */ - if(pass && fid < 0) { - fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); + if (pass && fid < 0) { + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); saved_fid = fid; - if(fid < 0) { - pass = FALSE; + if (fid < 0) { + pass = FALSE; failure_mssg = "H5Fcreate() failed."; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: H5Fcreate() failed.\n", FUNC); } /* end if */ - } /* end if */ + } /* end if */ /* Push API context */ H5CX_push(); - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { HDassert(fid >= 0); saved_fid = fid; - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { - pass = FALSE; + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { + pass = FALSE; failure_mssg = "H5Fflush() failed."; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); } else { file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE); - if(file_ptr == NULL) { - pass = FALSE; + if (file_ptr == NULL) { + pass = FALSE; failure_mssg = "Can't get file_ptr."; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); } } } - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* A bit of fancy footwork here: * @@ -36700,75 +42258,67 @@ setup_cache(size_t max_cache_size, */ HDassert(saved_cache == NULL); - saved_cache = file_ptr->shared->cache; + saved_cache = file_ptr->shared->cache; file_ptr->shared->cache = NULL; - cache_ptr = H5C_create(max_cache_size, - min_clean_size, - (NUMBER_OF_ENTRY_TYPES - 1), - types, - check_write_permitted, - TRUE, - NULL, - NULL); + cache_ptr = H5C_create(max_cache_size, min_clean_size, (NUMBER_OF_ENTRY_TYPES - 1), types, + check_write_permitted, TRUE, NULL, NULL); file_ptr->shared->cache = cache_ptr; } - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { - if(cache_ptr == NULL) { - pass = FALSE; + if (pass) { + if (cache_ptr == NULL) { + pass = FALSE; failure_mssg = "H5C_create() failed."; - if(verbose) - HDfprintf(stdout, "%s: H5C_create() failed.\n", FUNC); + if (verbose) + HDfprintf(stdout, "%s: H5C_create() failed.\n", FUNC); } - else if(cache_ptr->magic != H5C__H5C_T_MAGIC) { - pass = FALSE; + else if (cache_ptr->magic != H5C__H5C_T_MAGIC) { + pass = FALSE; failure_mssg = "Bad cache_ptr magic."; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Bad cache_ptr magic.\n", FUNC); } } - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { /* allocate space for test entries */ + if (pass) { /* allocate space for test entries */ actual_base_addr = H5MF_alloc(file_ptr, H5FD_MEM_DEFAULT, (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); - if(actual_base_addr == HADDR_UNDEF) { - pass = FALSE; - failure_mssg = "H5MF_alloc() failed."; + if (actual_base_addr == HADDR_UNDEF) { + pass = FALSE; + failure_mssg = "H5MF_alloc() failed."; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: H5MF_alloc() failed.\n", FUNC); - } else if(actual_base_addr > BASE_ADDR) { - /* If this happens, must increase BASE_ADDR so that the - * actual_base_addr is <= BASE_ADDR. This should only happen - * if the size of the superblock is increase. - */ - pass = FALSE; - failure_mssg = "actual_base_addr > BASE_ADDR"; + } + else if (actual_base_addr > BASE_ADDR) { + /* If this happens, must increase BASE_ADDR so that the + * actual_base_addr is <= BASE_ADDR. This should only happen + * if the size of the superblock is increase. + */ + pass = FALSE; + failure_mssg = "actual_base_addr > BASE_ADDR"; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: actual_base_addr > BASE_ADDR.\n", FUNC); } saved_actual_base_addr = actual_base_addr; } - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - if(pass) { + if (pass) { /* Need to set this else all cache tests will fail */ cache_ptr->ignore_tags = TRUE; @@ -36776,14 +42326,12 @@ setup_cache(size_t max_cache_size, ret_val = file_ptr; } - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); + if (show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", FUNC, mile_stone++, (int)pass); - return(ret_val); + return (ret_val); } /* setup_cache() */ - /*------------------------------------------------------------------------- * Function: takedown_cache() * @@ -36802,23 +42350,21 @@ setup_cache(size_t max_cache_size, */ void -takedown_cache(H5F_t * file_ptr, - hbool_t dump_stats, - hbool_t dump_detailed_stats) +takedown_cache(H5F_t *file_ptr, hbool_t dump_stats, hbool_t dump_detailed_stats) { char filename[512]; - if ( file_ptr != NULL ) { - H5C_t * cache_ptr = file_ptr->shared->cache; + if (file_ptr != NULL) { + H5C_t *cache_ptr = file_ptr->shared->cache; - if ( dump_stats ) { + if (dump_stats) { H5C_stats(cache_ptr, "test cache", dump_detailed_stats); } - if ( H5C_prep_for_file_close(file_ptr) < 0 ) { + if (H5C_prep_for_file_close(file_ptr) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected failure of prep for file close.\n"; } @@ -36826,67 +42372,63 @@ takedown_cache(H5F_t * file_ptr, H5C_dest(file_ptr); - if ( saved_cache != NULL ) { + if (saved_cache != NULL) { file_ptr->shared->cache = saved_cache; - saved_cache = NULL; + saved_cache = NULL; } - } - if ( saved_fapl_id != H5P_DEFAULT ) { + if (saved_fapl_id != H5P_DEFAULT) { H5Pclose(saved_fapl_id); saved_fapl_id = H5P_DEFAULT; } - if ( saved_fcpl_id != H5P_DEFAULT ) { + if (saved_fcpl_id != H5P_DEFAULT) { H5Pclose(saved_fcpl_id); saved_fcpl_id = H5P_DEFAULT; } - if ( saved_fid != -1 ) { + if (saved_fid != -1) { - if ( H5F_addr_defined(saved_actual_base_addr) ) { + if (H5F_addr_defined(saved_actual_base_addr)) { - if ( NULL == file_ptr ) { + if (NULL == file_ptr) { file_ptr = (H5F_t *)H5VL_object_verify(saved_fid, H5I_FILE); - HDassert ( file_ptr ); + HDassert(file_ptr); } H5MF_xfree(file_ptr, H5FD_MEM_DEFAULT, saved_actual_base_addr, - (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); + (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); saved_actual_base_addr = HADDR_UNDEF; } - if ( H5Fclose(saved_fid) < 0 ) { + if (H5Fclose(saved_fid) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "couldn't close test file."; - - } else { + } + else { saved_fid = -1; - } /* Pop API context */ H5CX_pop(); - if ( ( ! try_core_file_driver ) || ( core_file_driver_failed ) ) { + if ((!try_core_file_driver) || (core_file_driver_failed)) { - if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "couldn't delete test file."; - } } } @@ -36911,7 +42453,7 @@ main(void) { unsigned nerrs = 0; unsigned paged; - int express_test; + int express_test; H5open(); @@ -36922,7 +42464,7 @@ main(void) HDprintf(" express_test = %d\n", express_test); HDprintf("=========================================\n"); - if(create_entry_arrays() < 0) { + if (create_entry_arrays() < 0) { HDprintf("ERROR: Unable to create entries arrays. Aborting.\n"); return EXIT_FAILURE; @@ -36930,14 +42472,13 @@ main(void) /* Test with paged aggregation enabled or not */ /* Each test will call setup_cache() which set up the file space strategy according to "paged" */ - for(paged = FALSE; paged <= TRUE; paged++) { + for (paged = FALSE; paged <= TRUE; paged++) { - if ( paged ) { + if (paged) { - HDfprintf(stdout, - "\n\nRe-running tests with paged aggregation:\n"); + HDfprintf(stdout, "\n\nRe-running tests with paged aggregation:\n"); - if ( express_test > 0 ) + if (express_test > 0) HDfprintf(stdout, " Skipping smoke checks.\n"); HDfprintf(stdout, "\n"); @@ -37001,10 +42542,9 @@ main(void) /* can't fail, returns void */ free_entry_arrays(); - if(nerrs > 0) + if (nerrs > 0) return EXIT_FAILURE; else return EXIT_SUCCESS; } /* main() */ - diff --git a/test/cache_api.c b/test/cache_api.c index ca2e0ca..03c96dc 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -24,23 +24,18 @@ /* global variable declarations: */ -const char *FILENAME[] = { - "cache_api_test", - NULL -}; +const char *FILENAME[] = {"cache_api_test", NULL}; /* macro definitions */ /* private function declarations: */ -static hbool_t check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id); -static hbool_t check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id); -static hbool_t mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id); -static H5AC_cache_config_t * init_invalid_configs(void); -static hbool_t check_fapl_mdc_api_errs(void); -static hbool_t check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id); - - +static hbool_t check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id); +static hbool_t check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id); +static hbool_t mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id); +static H5AC_cache_config_t *init_invalid_configs(void); +static hbool_t check_fapl_mdc_api_errs(void); +static hbool_t check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id); /**************************************************************************/ /**************************************************************************/ @@ -69,54 +64,52 @@ static hbool_t check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id); static hbool_t check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) { - char filename[512]; - herr_t result; - hid_t fapl_id = -1; - hid_t test_fapl_id = -1; - hid_t file_id = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + char filename[512]; + herr_t result; + hid_t fapl_id = -1; + hid_t test_fapl_id = -1; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG; - H5AC_cache_config_t mod_config = - { - /* int version = */ H5AC__CURR_CACHE_CONFIG_VERSION, - /* hbool_t rpt_fcn_enabled = */ FALSE, - /* hbool_t open_trace_file = */ FALSE, - /* hbool_t close_trace_file = */ FALSE, - /* char trace_file_name[] = */ "", - /* hbool_t evictions_enabled = */ TRUE, - /* hbool_t set_initial_size = */ TRUE, - /* size_t initial_size = */ (1 * 1024 * 1024 + 1), - /* double min_clean_fraction = */ 0.2f, - /* size_t max_size = */ (16 * 1024 * 1024 + 1), - /* size_t min_size = */ ( 1 * 1024 * 1024 + 1), - /* long int epoch_length = */ 50001, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, - /* double lower_hr_threshold = */ 0.91f, - /* double increment = */ 2.1f, - /* hbool_t apply_max_increment = */ TRUE, - /* size_t max_increment = */ (4 * 1024 * 1024 + 1), - /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out, - /* double upper_hr_threshold = */ 0.998f, - /* double decrement = */ 0.91f, - /* hbool_t apply_max_decrement = */ TRUE, - /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), - /* int epochs_before_eviction = */ 4, - /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, - /* int dirty_bytes_threshold = */ (256 * 1024), - /* int metadata_write_strategy = */ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY - }; + H5AC_cache_config_t mod_config = { + /* int version = */ H5AC__CURR_CACHE_CONFIG_VERSION, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024 + 1), + /* double min_clean_fraction = */ 0.2f, + /* size_t max_size = */ (16 * 1024 * 1024 + 1), + /* size_t min_size = */ (1 * 1024 * 1024 + 1), + /* long int epoch_length = */ 50001, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, + /* double lower_hr_threshold = */ 0.91f, + /* double increment = */ 2.1f, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (4 * 1024 * 1024 + 1), + /* enum H5C_cache_flash_incr_mode */ + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out, + /* double upper_hr_threshold = */ 0.998f, + /* double decrement = */ 0.91f, + /* hbool_t apply_max_decrement = */ TRUE, + /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), + /* int epochs_before_eviction = */ 4, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.05f, + /* int dirty_bytes_threshold = */ (256 * 1024), + /* int metadata_write_strategy = */ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; H5AC_cache_config_t scratch; H5C_auto_size_ctl_t default_auto_size_ctl; H5C_auto_size_ctl_t mod_auto_size_ctl; - if(paged) + if (paged) TESTING("MDC/FAPL related API calls for paged aggregation strategy") else TESTING("MDC/FAPL related API calls") @@ -130,74 +123,73 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) * initial mdc configuration */ - if ( pass ) { + if (pass) { fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if ( fapl_id < 0 ) { + if (fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; } } - if ( pass ) { + if (pass) { scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; result = H5Pget_mdc_config(fapl_id, &scratch); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_config() failed.\n"; + } + else if (!CACHE_CONFIGS_EQUAL(default_config, scratch, TRUE, TRUE)) { - } else if (!CACHE_CONFIGS_EQUAL(default_config, scratch, TRUE, TRUE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "retrieved config doesn't match default."; } } - /* Modify the initial mdc configuration in a FAPL, and verify that * the changes can be read back */ - if ( pass ) { + if (pass) { result = H5Pset_mdc_config(fapl_id, &mod_config); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_config() failed.\n"; } } - if ( pass ) { + if (pass) { scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; result = H5Pget_mdc_config(fapl_id, &scratch); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_config() failed.\n"; + } + else if (!CACHE_CONFIGS_EQUAL(mod_config, scratch, TRUE, TRUE)) { - } else if ( ! CACHE_CONFIGS_EQUAL(mod_config, scratch, TRUE, TRUE) ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "retrieved config doesn't match mod config."; } } - if ( pass ) { + if (pass) { - if ( H5Pclose(fapl_id) < 0 ) { + if (H5Pclose(fapl_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pclose() failed.\n"; } } @@ -210,75 +202,72 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) */ /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } /* create the file using the default FAPL */ - if ( pass ) { + if (pass) { file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fcreate() failed.\n"; } } /* get a pointer to the files internal data structure */ - if ( pass ) { + if (pass) { file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr.\n"; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } /* verify that we can access the internal version of the cache config */ - if ( pass ) { + if (pass) { - if ( ( cache_ptr == NULL ) || - ( cache_ptr->magic != H5C__H5C_T_MAGIC ) || - ( cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER ) ){ + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || + (cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't access cache resize_ctl.\n"; } } /* conpare the cache's internal configuration with the expected value */ - if ( pass ) { + if (pass) { - if ( ! resize_configs_are_equal(&default_auto_size_ctl, \ - &cache_ptr->resize_ctl, TRUE) ) { + if (!resize_configs_are_equal(&default_auto_size_ctl, &cache_ptr->resize_ctl, TRUE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected value(s) in cache resize_ctl 1.\n"; } } /* get a copy of the files FAPL */ - if ( pass ) { + if (pass) { fapl_id = H5Fget_access_plist(file_id); - if ( fapl_id < 0 ) { + if (fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_access_plist() failed.\n"; } } @@ -286,45 +275,44 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* compare the initial cache config from the copy of the file's FAPL * to the expected value. If all goes well, close the copy of the FAPL. */ - if ( pass ) { + if (pass) { scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; result = H5Pget_mdc_config(fapl_id, &scratch); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_config() failed.\n"; + } + else if (!CACHE_CONFIGS_EQUAL(default_config, scratch, TRUE, TRUE)) { - } else if (!CACHE_CONFIGS_EQUAL(default_config, scratch, TRUE, TRUE)) { - - pass = FALSE; + pass = FALSE; failure_mssg = "config retrieved from file doesn't match default."; + } + else if (H5Pclose(fapl_id) < 0) { - } else if ( H5Pclose(fapl_id) < 0 ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pclose() failed.\n"; } } /* close the file and delete it */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; + } + else if (HDremove(filename) < 0) { - } else if ( HDremove(filename) < 0 ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - /* Open a file using a FAPL with a modified initial metadata cache * configuration. Verify that the resulting metadata cache uses the * modified configuration as well. Get a copy of the FAPL from the @@ -333,100 +321,97 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) */ /* Create a FAPL */ - if ( pass ) { + if (pass) { fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if ( fapl_id < 0 ) { + if (fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; } } /* Modify the initial mdc configuration in the FAPL. */ - if ( pass ) { + if (pass) { result = H5Pset_mdc_config(fapl_id, &mod_config); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_config() failed.\n"; } } /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } /* create the file using the modified FAPL */ - if ( pass ) { + if (pass) { file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fcreate() failed.\n"; } } /* get a pointer to the files internal data structure */ - if ( pass ) { + if (pass) { file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr.\n"; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } /* verify that we can access the internal version of the cache config */ - if ( pass ) { + if (pass) { - if ( ( cache_ptr == NULL ) || - ( cache_ptr->magic != H5C__H5C_T_MAGIC ) || - ( cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER ) ){ + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || + (cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't access cache resize_ctl.\n"; } } /* conpare the cache's internal configuration with the expected value */ - if ( pass ) { + if (pass) { - if ( ! resize_configs_are_equal(&mod_auto_size_ctl, \ - &cache_ptr->resize_ctl, TRUE) ) { + if (!resize_configs_are_equal(&mod_auto_size_ctl, &cache_ptr->resize_ctl, TRUE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected value(s) in cache resize_ctl 2.\n"; } } /* get a copy of the files FAPL */ - if ( pass ) { + if (pass) { test_fapl_id = H5Fget_access_plist(file_id); - if ( test_fapl_id < 0 ) { + if (test_fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_access_plist() failed.\n"; } } @@ -434,64 +419,64 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* compare the initial cache config from the copy of the file's FAPL * to the expected value. If all goes well, close the copy of the FAPL. */ - if ( pass ) { + if (pass) { scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; result = H5Pget_mdc_config(test_fapl_id, &scratch); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_config() failed.\n"; + } + else if (!CACHE_CONFIGS_EQUAL(mod_config, scratch, TRUE, TRUE)) { - } else if ( ! CACHE_CONFIGS_EQUAL(mod_config, scratch, TRUE, TRUE) ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "config retrieved from file doesn't match."; + } + else if (H5Pclose(test_fapl_id) < 0) { - } else if ( H5Pclose(test_fapl_id) < 0 ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pclose() failed.\n"; } } /* close the fapl used to create the file */ - if ( pass ) { + if (pass) { - if ( H5Pclose(fapl_id) < 0 ) { + if (H5Pclose(fapl_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pclose() failed.\n"; } } /* close the file and delete it */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; + } + else if (HDremove(filename) < 0) { - } else if ( HDremove(filename) < 0 ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { + if (pass) { PASSED(); - - } else { + } + else { H5_FAILED(); } - if ( ! pass ) { + if (!pass) { HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } @@ -500,7 +485,6 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) } /* check_fapl_mdc_api_calls() */ - /*------------------------------------------------------------------------- * Function: check_file_mdc_api_calls() * @@ -525,157 +509,149 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) static hbool_t check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) { - char filename[512]; - hid_t file_id = -1; - size_t max_size; - size_t min_clean_size; - size_t cur_size; - int cur_num_entries; - double hit_rate; + char filename[512]; + hid_t file_id = -1; + size_t max_size; + size_t min_clean_size; + size_t cur_size; + int cur_num_entries; + double hit_rate; H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG; - H5AC_cache_config_t mod_config_1 = - { - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, - /* hbool_t rpt_fcn_enabled = */ FALSE, - /* hbool_t open_trace_file = */ FALSE, - /* hbool_t close_trace_file = */ FALSE, - /* char trace_file_name[] = */ "", - /* hbool_t evictions_enabled = */ TRUE, - /* hbool_t set_initial_size = */ TRUE, - /* size_t initial_size = */ (1 * 1024 * 1024 + 1), - /* double min_clean_fraction = */ 0.2f, - /* size_t max_size = */ (16 * 1024 * 1024 + 1), - /* size_t min_size = */ ( 1 * 1024 * 1024 + 1), - /* long int epoch_length = */ 50001, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, - /* double lower_hr_threshold = */ 0.91f, - /* double increment = */ 2.1f, - /* hbool_t apply_max_increment = */ TRUE, - /* size_t max_increment = */ (4 * 1024 * 1024 + 1), - /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out, - /* double upper_hr_threshold = */ 0.998f, - /* double decrement = */ 0.91f, - /* hbool_t apply_max_decrement = */ TRUE, - /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), - /* int epochs_before_eviction = */ 4, - /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, - /* int dirty_bytes_threshold = */ (256 * 1024), - /* int metadata_write_strategy = */ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY - }; - H5AC_cache_config_t mod_config_2 = - { - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, - /* hbool_t rpt_fcn_enabled = */ TRUE, - /* hbool_t open_trace_file = */ FALSE, - /* hbool_t close_trace_file = */ FALSE, - /* char trace_file_name[] = */ "", - /* hbool_t evictions_enabled = */ TRUE, - /* hbool_t set_initial_size = */ TRUE, - /* size_t initial_size = */ (512 * 1024), - /* double min_clean_fraction = */ 0.1f, - /* size_t max_size = */ ( 8 * 1024 * 1024), - /* size_t min_size = */ ( 512 * 1024), - /* long int epoch_length = */ 25000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, - /* double lower_hr_threshold = */ 0.9f, - /* double increment = */ 2.0f, - /* hbool_t apply_max_increment = */ TRUE, - /* size_t max_increment = */ (2 * 1024 * 1024), - /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 1.5f, - /* double flash_threshold = */ 0.4f, - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, - /* double upper_hr_threshold = */ 0.9995f, - /* double decrement = */ 0.95f, - /* hbool_t apply_max_decrement = */ TRUE, - /* size_t max_decrement = */ (512 * 1024), - /* int epochs_before_eviction = */ 4, - /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, - /* int dirty_bytes_threshold = */ (256 * 1024), - /* int metadata_write_strategy = */ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY - }; - H5AC_cache_config_t mod_config_3 = - { - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, - /* hbool_t rpt_fcn_enabled = */ FALSE, - /* hbool_t open_trace_file = */ FALSE, - /* hbool_t close_trace_file = */ FALSE, - /* char trace_file_name[] = */ "", - /* hbool_t evictions_enabled = */ TRUE, - /* hbool_t set_initial_size = */ TRUE, - /* size_t initial_size = */ (1 * 1024 * 1024), - /* double min_clean_fraction = */ 0.2f, - /* size_t max_size = */ (16 * 1024 * 1024), - /* size_t min_size = */ ( 1 * 1024 * 1024), - /* long int epoch_length = */ 50000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, - /* double lower_hr_threshold = */ 0.90f, - /* double increment = */ 2.0f, - /* hbool_t apply_max_increment = */ TRUE, - /* size_t max_increment = */ (4 * 1024 * 1024), - /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.1f, - /* double flash_threshold = */ 0.6f, - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, - /* hbool_t apply_max_decrement = */ FALSE, - /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), - /* int epochs_before_eviction = */ 3, - /* hbool_t apply_empty_reserve = */ FALSE, - /* double empty_reserve = */ 0.05f, - /* int dirty_bytes_threshold = */ (256 * 1024), - /* int metadata_write_strategy = */ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY - }; - H5AC_cache_config_t mod_config_4 = - { - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, - /* hbool_t rpt_fcn_enabled = */ FALSE, - /* hbool_t open_trace_file = */ FALSE, - /* hbool_t close_trace_file = */ FALSE, - /* char trace_file_name[] = */ "", - /* hbool_t evictions_enabled = */ TRUE, - /* hbool_t set_initial_size = */ TRUE, - /* size_t initial_size = */ (1 * 1024 * 1024), - /* double min_clean_fraction = */ 0.15f, - /* size_t max_size = */ (20 * 1024 * 1024), - /* size_t min_size = */ ( 1 * 1024 * 1024), - /* long int epoch_length = */ 75000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, - /* double lower_hr_threshold = */ 0.9f, - /* double increment = */ 2.0f, - /* hbool_t apply_max_increment = */ TRUE, - /* size_t max_increment = */ (2 * 1024 * 1024), - /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 1.1f, - /* double flash_threshold = */ 0.3f, - /* enum H5C_cache_decr_mode decr_mode = */ - H5C_decr__age_out_with_threshold, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, - /* hbool_t apply_max_decrement = */ TRUE, - /* size_t max_decrement = */ (1 * 1024 * 1024), - /* int epochs_before_eviction = */ 3, - /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.1f, - /* int dirty_bytes_threshold = */ (256 * 1024), - /* int metadata_write_strategy = */ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY - }; - - if(paged) + H5AC_cache_config_t mod_config_1 = { + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024 + 1), + /* double min_clean_fraction = */ 0.2f, + /* size_t max_size = */ (16 * 1024 * 1024 + 1), + /* size_t min_size = */ (1 * 1024 * 1024 + 1), + /* long int epoch_length = */ 50001, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, + /* double lower_hr_threshold = */ 0.91f, + /* double increment = */ 2.1f, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (4 * 1024 * 1024 + 1), + /* enum H5C_cache_flash_incr_mode */ + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out, + /* double upper_hr_threshold = */ 0.998f, + /* double decrement = */ 0.91f, + /* hbool_t apply_max_decrement = */ TRUE, + /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), + /* int epochs_before_eviction = */ 4, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.05f, + /* int dirty_bytes_threshold = */ (256 * 1024), + /* int metadata_write_strategy = */ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + H5AC_cache_config_t mod_config_2 = { + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ TRUE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (512 * 1024), + /* double min_clean_fraction = */ 0.1f, + /* size_t max_size = */ (8 * 1024 * 1024), + /* size_t min_size = */ (512 * 1024), + /* long int epoch_length = */ 25000, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, + /* double lower_hr_threshold = */ 0.9f, + /* double increment = */ 2.0f, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (2 * 1024 * 1024), + /* enum H5C_cache_flash_incr_mode */ + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 1.5f, + /* double flash_threshold = */ 0.4f, + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, + /* double upper_hr_threshold = */ 0.9995f, + /* double decrement = */ 0.95f, + /* hbool_t apply_max_decrement = */ TRUE, + /* size_t max_decrement = */ (512 * 1024), + /* int epochs_before_eviction = */ 4, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.05f, + /* int dirty_bytes_threshold = */ (256 * 1024), + /* int metadata_write_strategy = */ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + H5AC_cache_config_t mod_config_3 = { + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024), + /* double min_clean_fraction = */ 0.2f, + /* size_t max_size = */ (16 * 1024 * 1024), + /* size_t min_size = */ (1 * 1024 * 1024), + /* long int epoch_length = */ 50000, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, + /* double lower_hr_threshold = */ 0.90f, + /* double increment = */ 2.0f, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (4 * 1024 * 1024), + /* enum H5C_cache_flash_incr_mode */ + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.1f, + /* double flash_threshold = */ 0.6f, + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, + /* double upper_hr_threshold = */ 0.999f, + /* double decrement = */ 0.9f, + /* hbool_t apply_max_decrement = */ FALSE, + /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), + /* int epochs_before_eviction = */ 3, + /* hbool_t apply_empty_reserve = */ FALSE, + /* double empty_reserve = */ 0.05f, + /* int dirty_bytes_threshold = */ (256 * 1024), + /* int metadata_write_strategy = */ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + H5AC_cache_config_t mod_config_4 = { + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024), + /* double min_clean_fraction = */ 0.15f, + /* size_t max_size = */ (20 * 1024 * 1024), + /* size_t min_size = */ (1 * 1024 * 1024), + /* long int epoch_length = */ 75000, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, + /* double lower_hr_threshold = */ 0.9f, + /* double increment = */ 2.0f, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (2 * 1024 * 1024), + /* enum H5C_cache_flash_incr_mode */ + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 1.1f, + /* double flash_threshold = */ 0.3f, + /* enum H5C_cache_decr_mode decr_mode = */ + H5C_decr__age_out_with_threshold, + /* double upper_hr_threshold = */ 0.999f, + /* double decrement = */ 0.9f, + /* hbool_t apply_max_decrement = */ TRUE, + /* size_t max_decrement = */ (1 * 1024 * 1024), + /* int epochs_before_eviction = */ 3, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.1f, + /* int dirty_bytes_threshold = */ (256 * 1024), + /* int metadata_write_strategy = */ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + + if (paged) TESTING("MDC/FILE related API calls for paged aggregation strategy") else TESTING("MDC/FILE related API calls") @@ -691,24 +667,23 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) */ /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } /* create the file using the default FAPL */ - if ( pass ) { + if (pass) { file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fcreate() failed.\n"; } } @@ -717,11 +692,11 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) validate_mdc_config(file_id, &default_config, TRUE, 1); /* set alternate config 1 */ - if ( pass ) { + if (pass) { - if ( H5Fset_mdc_config(file_id, &mod_config_1) < 0 ) { + if (H5Fset_mdc_config(file_id, &mod_config_1) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() failed 1.\n"; } } @@ -730,11 +705,11 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) validate_mdc_config(file_id, &mod_config_1, TRUE, 2); /* set alternate config 2 */ - if ( pass ) { + if (pass) { - if ( H5Fset_mdc_config(file_id, &mod_config_2) < 0 ) { + if (H5Fset_mdc_config(file_id, &mod_config_2) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() failed 2.\n"; } } @@ -743,11 +718,11 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) validate_mdc_config(file_id, &mod_config_2, TRUE, 3); /* set alternate config 3 */ - if ( pass ) { + if (pass) { - if ( H5Fset_mdc_config(file_id, &mod_config_3) < 0 ) { + if (H5Fset_mdc_config(file_id, &mod_config_3) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() failed 3.\n"; } } @@ -756,11 +731,11 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) validate_mdc_config(file_id, &mod_config_3, TRUE, 4); /* set alternate config 4 */ - if ( pass ) { + if (pass) { - if ( H5Fset_mdc_config(file_id, &mod_config_4) < 0 ) { + if (H5Fset_mdc_config(file_id, &mod_config_4) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() failed 4.\n"; } } @@ -768,25 +743,22 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* verify that the cache is now set to the alternate config */ validate_mdc_config(file_id, &mod_config_4, TRUE, 5); - /* Run some quick smoke checks on the cache status monitoring * calls -- no interesting data as the cache hasn't had a * chance to do much yet. */ - if ( pass ) { + if (pass) { - if ( H5Fget_mdc_hit_rate(file_id, &hit_rate) < 0 ) { + if (H5Fget_mdc_hit_rate(file_id, &hit_rate) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_hit_rate() failed 1.\n"; + } + else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f)) { - } else if ( !H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f) ) { - - pass = FALSE; - failure_mssg = - "H5Fget_mdc_hit_rate() returned unexpected hit rate.\n"; - + pass = FALSE; + failure_mssg = "H5Fget_mdc_hit_rate() returned unexpected hit rate.\n"; } #if 0 /* this may be useful now and then -- keep it around */ else { @@ -798,21 +770,18 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) #endif } - if ( pass ) { + if (pass) { - if ( H5Fget_mdc_size(file_id, &max_size, &min_clean_size, - &cur_size, &cur_num_entries) < 0 ) { + if (H5Fget_mdc_size(file_id, &max_size, &min_clean_size, &cur_size, &cur_num_entries) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_size() failed 1.\n"; + } + else if ((mod_config_4.initial_size != max_size) || + (min_clean_size != (size_t)((double)max_size * mod_config_4.min_clean_fraction))) { - } else if ( ( mod_config_4.initial_size != max_size ) || - ( min_clean_size != (size_t) - ((double)max_size * mod_config_4.min_clean_fraction) ) ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_size() returned unexpected value(s).\n"; - } #if 0 /* this may be useful now and then -- keep it around */ else { @@ -827,30 +796,30 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) } /* close the file and delete it */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; + } + else if (HDremove(filename) < 0) { - } else if ( HDremove(filename) < 0 ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { + if (pass) { PASSED(); - - } else { + } + else { H5_FAILED(); } - if ( ! pass ) { + if (!pass) { HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } @@ -859,7 +828,6 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) } /* check_file_mdc_api_calls() */ - /*------------------------------------------------------------------------- * Function: mdc_api_call_smoke_check() * @@ -877,149 +845,143 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) *------------------------------------------------------------------------- */ -#define CHUNK_SIZE 2 -#define DSET_SIZE (200 * CHUNK_SIZE) -#define NUM_DSETS 6 -#define NUM_RANDOM_ACCESSES 200000 +#define CHUNK_SIZE 2 +#define DSET_SIZE (200 * CHUNK_SIZE) +#define NUM_DSETS 6 +#define NUM_RANDOM_ACCESSES 200000 static hbool_t mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) { - char filename[512]; - hbool_t valid_chunk; - hbool_t dump_hit_rate = FALSE; - int64_t min_accesses = 1000; - double min_hit_rate = 0.90f; - hbool_t dump_cache_size = FALSE; - hid_t file_id = -1; - hid_t dataspace_id = -1; - hid_t filespace_ids[NUM_DSETS]; - hid_t memspace_id = -1; - hid_t dataset_ids[NUM_DSETS]; - hid_t properties = -1; - char dset_name[64]; - int i, j, k, l, m, n; - herr_t status; - hsize_t dims[2]; - hsize_t a_size[2]; - hsize_t offset[2]; - hsize_t chunk_size[2]; - int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; + char filename[512]; + hbool_t valid_chunk; + hbool_t dump_hit_rate = FALSE; + int64_t min_accesses = 1000; + double min_hit_rate = 0.90f; + hbool_t dump_cache_size = FALSE; + hid_t file_id = -1; + hid_t dataspace_id = -1; + hid_t filespace_ids[NUM_DSETS]; + hid_t memspace_id = -1; + hid_t dataset_ids[NUM_DSETS]; + hid_t properties = -1; + char dset_name[64]; + int i, j, k, l, m, n; + herr_t status; + hsize_t dims[2]; + hsize_t a_size[2]; + hsize_t offset[2]; + hsize_t chunk_size[2]; + int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG; - H5AC_cache_config_t mod_config_1 = - { - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, - /* hbool_t rpt_fcn_enabled = */ FALSE, - /* hbool_t open_trace_file = */ FALSE, - /* hbool_t close_trace_file = */ FALSE, - /* char trace_file_name[] = */ "", - /* hbool_t evictions_enabled = */ TRUE, - /* hbool_t set_initial_size = */ TRUE, - /* size_t initial_size = */ 500000, - /* double min_clean_fraction = */ 0.1f, - /* size_t max_size = */ 16000000, - /* size_t min_size = */ 250000, - /* long int epoch_length = */ 50000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, - /* double lower_hr_threshold = */ 0.95f, - /* double increment = */ 2.0f, - /* hbool_t apply_max_increment = */ FALSE, - /* size_t max_increment = */ 4000000, - /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, - /* hbool_t apply_max_decrement = */ FALSE, - /* size_t max_decrement = */ 1000000, - /* int epochs_before_eviction = */ 2, - /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, - /* int dirty_bytes_threshold = */ (256 * 1024), - /* int metadata_write_strategy = */ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY - }; - H5AC_cache_config_t mod_config_2 = - { - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, - /* hbool_t rpt_fcn_enabled = */ FALSE, - /* hbool_t open_trace_file = */ FALSE, - /* hbool_t close_trace_file = */ FALSE, - /* char trace_file_name[] = */ "", - /* hbool_t evictions_enabled = */ TRUE, - /* hbool_t set_initial_size = */ TRUE, - /* size_t initial_size = */ 12000000, - /* double min_clean_fraction = */ 0.1f, - /* size_t max_size = */ 16000000, - /* size_t min_size = */ 250000, - /* long int epoch_length = */ 50000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, - /* double lower_hr_threshold = */ 0.95f, - /* double increment = */ 2.0f, - /* hbool_t apply_max_increment = */ FALSE, - /* size_t max_increment = */ 4000000, - /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, - /* hbool_t apply_max_decrement = */ FALSE, - /* size_t max_decrement = */ 1000000, - /* int epochs_before_eviction = */ 2, - /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, - /* int dirty_bytes_threshold = */ (256 * 1024), - /* int metadata_write_strategy = */ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY - }; - H5AC_cache_config_t mod_config_3 = - { - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, - /* hbool_t rpt_fcn_enabled = */ FALSE, - /* hbool_t open_trace_file = */ FALSE, - /* hbool_t close_trace_file = */ FALSE, - /* char trace_file_name[] = */ "", - /* hbool_t evictions_enabled = */ TRUE, - /* hbool_t set_initial_size = */ TRUE, - /* size_t initial_size = */ 2000000, - /* double min_clean_fraction = */ 0.1f, - /* size_t max_size = */ 16000000, - /* size_t min_size = */ 250000, - /* long int epoch_length = */ 50000, - /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, - /* double lower_hr_threshold = */ 0.95f, - /* double increment = */ 2.0f, - /* hbool_t apply_max_increment = */ FALSE, - /* size_t max_increment = */ 4000000, - /* enum H5C_cache_flash_incr_mode */ - /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, - /* hbool_t apply_max_decrement = */ FALSE, - /* size_t max_decrement = */ 1000000, - /* int epochs_before_eviction = */ 2, - /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, - /* int dirty_bytes_threshold = */ (256 * 1024), - /* int metadata_write_strategy = */ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY - }; - - if(paged) + H5AC_cache_config_t mod_config_1 = { + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ 500000, + /* double min_clean_fraction = */ 0.1f, + /* size_t max_size = */ 16000000, + /* size_t min_size = */ 250000, + /* long int epoch_length = */ 50000, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, + /* double lower_hr_threshold = */ 0.95f, + /* double increment = */ 2.0f, + /* hbool_t apply_max_increment = */ FALSE, + /* size_t max_increment = */ 4000000, + /* enum H5C_cache_flash_incr_mode */ + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, + /* double upper_hr_threshold = */ 0.999f, + /* double decrement = */ 0.9f, + /* hbool_t apply_max_decrement = */ FALSE, + /* size_t max_decrement = */ 1000000, + /* int epochs_before_eviction = */ 2, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.05f, + /* int dirty_bytes_threshold = */ (256 * 1024), + /* int metadata_write_strategy = */ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + H5AC_cache_config_t mod_config_2 = { + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ 12000000, + /* double min_clean_fraction = */ 0.1f, + /* size_t max_size = */ 16000000, + /* size_t min_size = */ 250000, + /* long int epoch_length = */ 50000, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, + /* double lower_hr_threshold = */ 0.95f, + /* double increment = */ 2.0f, + /* hbool_t apply_max_increment = */ FALSE, + /* size_t max_increment = */ 4000000, + /* enum H5C_cache_flash_incr_mode */ + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, + /* double upper_hr_threshold = */ 0.999f, + /* double decrement = */ 0.9f, + /* hbool_t apply_max_decrement = */ FALSE, + /* size_t max_decrement = */ 1000000, + /* int epochs_before_eviction = */ 2, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.05f, + /* int dirty_bytes_threshold = */ (256 * 1024), + /* int metadata_write_strategy = */ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + H5AC_cache_config_t mod_config_3 = { + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ 2000000, + /* double min_clean_fraction = */ 0.1f, + /* size_t max_size = */ 16000000, + /* size_t min_size = */ 250000, + /* long int epoch_length = */ 50000, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, + /* double lower_hr_threshold = */ 0.95f, + /* double increment = */ 2.0f, + /* hbool_t apply_max_increment = */ FALSE, + /* size_t max_increment = */ 4000000, + /* enum H5C_cache_flash_incr_mode */ + /* flash_incr_mode = */ H5C_flash_incr__off, + /* double flash_multiple = */ 2.0f, + /* double flash_threshold = */ 0.5f, + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, + /* double upper_hr_threshold = */ 0.999f, + /* double decrement = */ 0.9f, + /* hbool_t apply_max_decrement = */ FALSE, + /* size_t max_decrement = */ 1000000, + /* int epochs_before_eviction = */ 2, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.05f, + /* int dirty_bytes_threshold = */ (256 * 1024), + /* int metadata_write_strategy = */ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + + if (paged) TESTING("MDC API smoke check for paged aggregation strategy") else TESTING("MDC API smoke check") pass = TRUE; - if ( express_test > 0 ) { + if (express_test > 0) { SKIPPED(); @@ -1037,24 +999,23 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) */ /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } /* create the file using the default FAPL */ - if ( pass ) { + if (pass) { file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fcreate() failed.\n"; } } @@ -1063,11 +1024,11 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) validate_mdc_config(file_id, &default_config, TRUE, 1); /* set alternate config 1 */ - if ( pass ) { + if (pass) { - if ( H5Fset_mdc_config(file_id, &mod_config_1) < 0 ) { + if (H5Fset_mdc_config(file_id, &mod_config_1) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() failed 1.\n"; } } @@ -1076,20 +1037,19 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) validate_mdc_config(file_id, &mod_config_1, TRUE, 2); /* create the datasets */ - if ( pass ) { + if (pass) { i = 0; - while ( ( pass ) && ( i < NUM_DSETS ) ) - { + while ((pass) && (i < NUM_DSETS)) { /* create a dataspace for the chunked dataset */ - dims[0] = DSET_SIZE; - dims[1] = DSET_SIZE; + dims[0] = DSET_SIZE; + dims[1] = DSET_SIZE; dataspace_id = H5Screate_simple(2, dims, NULL); - if ( dataspace_id < 0 ) { + if (dataspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } @@ -1097,50 +1057,50 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) * to be partioned into 10X10 element chunks. */ - if ( pass ) { + if (pass) { chunk_size[0] = CHUNK_SIZE; chunk_size[1] = CHUNK_SIZE; - properties = H5Pcreate(H5P_DATASET_CREATE); + properties = H5Pcreate(H5P_DATASET_CREATE); - if ( properties < 0 ) { + if (properties < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate() failed."; } } - if ( pass ) { + if (pass) { - if ( H5Pset_chunk(properties, 2, chunk_size) < 0 ) { + if (H5Pset_chunk(properties, 2, chunk_size) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_chunk() failed."; } } /* create the dataset */ - if ( pass ) { + if (pass) { HDsprintf(dset_name, "/dset%03d", i); - dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, - dataspace_id, H5P_DEFAULT, properties, H5P_DEFAULT); + dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, + properties, H5P_DEFAULT); - if ( dataset_ids[i] < 0 ) { + if (dataset_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dcreate2() failed."; } } /* get the file space ID */ - if ( pass ) { + if (pass) { filespace_ids[i] = H5Dget_space(dataset_ids[i]); - if ( filespace_ids[i] < 0 ) { + if (filespace_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dget_space() failed."; } } @@ -1150,32 +1110,31 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) } /* create the mem space to be used to read and write chunks */ - if ( pass ) { + if (pass) { - dims[0] = CHUNK_SIZE; - dims[1] = CHUNK_SIZE; + dims[0] = CHUNK_SIZE; + dims[1] = CHUNK_SIZE; memspace_id = H5Screate_simple(2, dims, NULL); - if ( memspace_id < 0 ) { + if (memspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } /* select in memory hyperslab */ - if ( pass ) { + if (pass) { - offset[0] = 0; /*offset of hyperslab in memory*/ + offset[0] = 0; /*offset of hyperslab in memory*/ offset[1] = 0; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, - a_size, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed."; } } @@ -1183,45 +1142,38 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* initialize all datasets on a round robin basis */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { m = 0; - while ( ( pass ) && ( m < NUM_DSETS ) ) - { + while ((pass) && (m < NUM_DSETS)) { /* initialize the slab */ - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l; + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l; } } /* select on disk hyperslab */ offset[0] = (hsize_t)i; /*offset of hyperslab in file*/ offset[1] = (hsize_t)j; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "disk H5Sselect_hyperslab() failed."; } /* write the chunk to file */ - status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, - filespace_ids[m], H5P_DEFAULT, data_chunk); + status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, + data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dwrite() failed."; } m++; @@ -1238,25 +1190,22 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) * similarly, check cache size. */ - if ( ( pass ) && ( i % (DSET_SIZE / 4) == 0 ) ) { + if ((pass) && (i % (DSET_SIZE / 4) == 0)) { - check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, - min_accesses, min_hit_rate); + check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, min_accesses, min_hit_rate); - check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, - dump_cache_size); + check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, dump_cache_size); } i += CHUNK_SIZE; - } /* set alternate config 2 */ - if ( pass ) { + if (pass) { - if ( H5Fset_mdc_config(file_id, &mod_config_2) < 0 ) { + if (H5Fset_mdc_config(file_id, &mod_config_2) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() failed 2.\n"; } } @@ -1266,8 +1215,7 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* do random reads on all datasets */ n = 0; - while ( ( pass ) && ( n < NUM_RANDOM_ACCESSES ) ) - { + while ((pass) && (n < NUM_RANDOM_ACCESSES)) { m = rand() % NUM_DSETS; i = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; j = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; @@ -1275,44 +1223,38 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* select on disk hyperslab */ offset[0] = (hsize_t)i; /*offset of hyperslab in file*/ offset[1] = (hsize_t)j; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, - filespace_ids[m], H5P_DEFAULT, data_chunk); + status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, + data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - if ( data_chunk[k][l] - != - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l) ) { - - valid_chunk = FALSE; + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + if (data_chunk[k][l] != ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)) { + + valid_chunk = FALSE; #if 0 /* this will be useful from time to time -- lets keep it*/ HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", @@ -1327,61 +1269,54 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) } } - if ( ! valid_chunk ) { + if (!valid_chunk) { #if 1 - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; #else /* as above */ - HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", - i, j, m); + HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", i, j, m); #endif } } - if ( ( pass ) && ( n % (NUM_RANDOM_ACCESSES / 4) == 0 ) ) { + if ((pass) && (n % (NUM_RANDOM_ACCESSES / 4) == 0)) { - check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, - min_accesses, min_hit_rate); + check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, min_accesses, min_hit_rate); - check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, - dump_cache_size); + check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, dump_cache_size); } n++; } - /* close the file spaces we are done with */ i = 1; - while ( ( pass ) && ( i < NUM_DSETS ) ) - { - if ( H5Sclose(filespace_ids[i]) < 0 ) { + while ((pass) && (i < NUM_DSETS)) { + if (H5Sclose(filespace_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose() failed."; } i++; } - /* close the datasets we are done with */ i = 1; - while ( ( pass ) && ( i < NUM_DSETS ) ) - { - if ( H5Dclose(dataset_ids[i]) < 0 ) { + while ((pass) && (i < NUM_DSETS)) { + if (H5Dclose(dataset_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose() failed."; } i++; } /* set alternate config 3 */ - if ( pass ) { + if (pass) { - if ( H5Fset_mdc_config(file_id, &mod_config_3) < 0 ) { + if (H5Fset_mdc_config(file_id, &mod_config_3) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() failed 3.\n"; } } @@ -1392,53 +1327,46 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* do random reads on data set 0 only */ m = 0; n = 0; - while ( ( pass ) && ( n < NUM_RANDOM_ACCESSES ) ) - { + while ((pass) && (n < NUM_RANDOM_ACCESSES)) { i = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; j = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; /* select on disk hyperslab */ offset[0] = (hsize_t)i; /*offset of hyperslab in file*/ offset[1] = (hsize_t)j; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, - filespace_ids[m], H5P_DEFAULT, data_chunk); + status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, + data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - if ( data_chunk[k][l] - != - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l) ) { - - valid_chunk = FALSE; - } + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + if (data_chunk[k][l] != ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)) { + + valid_chunk = FALSE; + } #if 0 /* this will be useful from time to time -- lets keep it */ HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", k, l, data_chunk[k][l], @@ -1448,9 +1376,9 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) } } - if ( ! valid_chunk ) { + if (!valid_chunk) { - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; #if 0 /* as above */ HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", @@ -1459,84 +1387,81 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) } } - if ( ( pass ) && ( n % (NUM_RANDOM_ACCESSES / 4) == 0 ) ) { + if ((pass) && (n % (NUM_RANDOM_ACCESSES / 4) == 0)) { - check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, - min_accesses, min_hit_rate); + check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, min_accesses, min_hit_rate); - check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, - dump_cache_size); + check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, dump_cache_size); } n++; } /* close file space 0 */ - if ( pass ) { + if (pass) { - if ( H5Sclose(filespace_ids[0]) < 0 ) { + if (H5Sclose(filespace_ids[0]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(filespace_ids[0]) failed."; } } /* close the data space */ - if ( pass ) { + if (pass) { - if ( H5Sclose(dataspace_id) < 0 ) { + if (H5Sclose(dataspace_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(dataspace) failed."; } } /* close the mem space */ - if ( pass ) { + if (pass) { - if ( H5Sclose(memspace_id) < 0 ) { + if (H5Sclose(memspace_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(memspace_id) failed."; } } /* close dataset 0 */ - if ( pass ) { + if (pass) { - if ( H5Dclose(dataset_ids[0]) < 0 ) { + if (H5Dclose(dataset_ids[0]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose(dataset_ids[0]) failed."; } } /* close the file and delete it */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } - else if ( HDremove(filename) < 0 ) { + else if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { + if (pass) { PASSED(); - - } else { + } + else { H5_FAILED(); } - if ( ! pass ) { + if (!pass) { HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } @@ -1545,8 +1470,6 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) } /* mdc_api_call_smoke_check() */ - - /*------------------------------------------------------------------------- * Function: init_invalid_configs() * @@ -1566,183 +1489,183 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) *------------------------------------------------------------------------- */ -#define NUM_INVALID_CONFIGS 36 -static H5AC_cache_config_t * invalid_configs = NULL; +#define NUM_INVALID_CONFIGS 36 +static H5AC_cache_config_t *invalid_configs = NULL; static H5AC_cache_config_t * -init_invalid_configs(void) { +init_invalid_configs(void) +{ - int i; - H5AC_cache_config_t * configs = NULL; + int i; + H5AC_cache_config_t *configs = NULL; /* Allocate memory */ - if ( NULL == (configs = (H5AC_cache_config_t *)HDcalloc( - NUM_INVALID_CONFIGS, sizeof(H5AC_cache_config_t) ) ) ) { + if (NULL == + (configs = (H5AC_cache_config_t *)HDcalloc(NUM_INVALID_CONFIGS, sizeof(H5AC_cache_config_t)))) { return NULL; } /* Set defaults for all configs */ - for ( i = 0; i < NUM_INVALID_CONFIGS; i++ ) { + for (i = 0; i < NUM_INVALID_CONFIGS; i++) { - configs[i].version = H5C__CURR_AUTO_SIZE_CTL_VER; - configs[i].rpt_fcn_enabled = FALSE; - configs[i].open_trace_file = FALSE; - configs[i].close_trace_file = FALSE; + configs[i].version = H5C__CURR_AUTO_SIZE_CTL_VER; + configs[i].rpt_fcn_enabled = FALSE; + configs[i].open_trace_file = FALSE; + configs[i].close_trace_file = FALSE; /* trace file name set to all ASCII NUL by calloc() */ - configs[i].evictions_enabled = TRUE; - configs[i].set_initial_size = TRUE; - configs[i].initial_size = (1 * 1024 * 1024); - configs[i].min_clean_fraction = 0.25F; - configs[i].max_size = (16 * 1024 * 1024); - configs[i].min_size = (1 * 1024 * 1024); - configs[i].epoch_length = 50000; - configs[i].incr_mode = H5C_incr__threshold; - configs[i].lower_hr_threshold = 0.9F; - configs[i].increment = 2.0F; - configs[i].apply_max_increment = TRUE; - configs[i].max_increment = (4 * 1024 * 1024); - configs[i].flash_incr_mode = H5C_flash_incr__off; - configs[i].flash_multiple = 2.0F; - configs[i].flash_threshold = 0.5F; - configs[i].decr_mode = H5C_decr__age_out_with_threshold; - configs[i].upper_hr_threshold = 0.999F; - configs[i].decrement = 0.9F; - configs[i].apply_max_decrement = TRUE; - configs[i].max_decrement = (1 * 1024 * 1024); - configs[i].epochs_before_eviction = 3; - configs[i].apply_empty_reserve = TRUE; - configs[i].empty_reserve = 0.1F; - configs[i].dirty_bytes_threshold = (256 * 1024); - configs[i].metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; + configs[i].evictions_enabled = TRUE; + configs[i].set_initial_size = TRUE; + configs[i].initial_size = (1 * 1024 * 1024); + configs[i].min_clean_fraction = 0.25F; + configs[i].max_size = (16 * 1024 * 1024); + configs[i].min_size = (1 * 1024 * 1024); + configs[i].epoch_length = 50000; + configs[i].incr_mode = H5C_incr__threshold; + configs[i].lower_hr_threshold = 0.9F; + configs[i].increment = 2.0F; + configs[i].apply_max_increment = TRUE; + configs[i].max_increment = (4 * 1024 * 1024); + configs[i].flash_incr_mode = H5C_flash_incr__off; + configs[i].flash_multiple = 2.0F; + configs[i].flash_threshold = 0.5F; + configs[i].decr_mode = H5C_decr__age_out_with_threshold; + configs[i].upper_hr_threshold = 0.999F; + configs[i].decrement = 0.9F; + configs[i].apply_max_decrement = TRUE; + configs[i].max_decrement = (1 * 1024 * 1024); + configs[i].epochs_before_eviction = 3; + configs[i].apply_empty_reserve = TRUE; + configs[i].empty_reserve = 0.1F; + configs[i].dirty_bytes_threshold = (256 * 1024); + configs[i].metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; } /* Set badness for each config */ /* 0 -- bad version */ - configs[0].version = -1; + configs[0].version = -1; /* 1 -- open_trace_file == TRUE and empty trace_file_name */ - configs[1].open_trace_file = TRUE; + configs[1].open_trace_file = TRUE; /* trace file name set to all ASCII NUL by calloc() */ /* 2 -- max_size too big */ - configs[2].max_size = H5C__MAX_MAX_CACHE_SIZE + 1; + configs[2].max_size = H5C__MAX_MAX_CACHE_SIZE + 1; /* 3 -- min_size too small */ - configs[3].min_size = H5C__MIN_MAX_CACHE_SIZE - 1; + configs[3].min_size = H5C__MIN_MAX_CACHE_SIZE - 1; /* 4 -- min_size > max_size */ - configs[4].max_size = (16 * 1024 * 1024); - configs[4].min_size = (16 * 1024 * 1024 + 1); + configs[4].max_size = (16 * 1024 * 1024); + configs[4].min_size = (16 * 1024 * 1024 + 1); /* 5 -- initial size out of range (too big) */ - configs[5].initial_size = (16 * 1024 * 1024 + 1); + configs[5].initial_size = (16 * 1024 * 1024 + 1); /* 6 -- initial_size out of range (too small) */ - configs[6].initial_size = (1 * 1024 * 1024 - 1); + configs[6].initial_size = (1 * 1024 * 1024 - 1); /* 7 -- min_clean_fraction too big */ - configs[7].min_clean_fraction = 1.000001f; + configs[7].min_clean_fraction = 1.000001f; /* 8 -- min_clean_fraction too small */ - configs[8].min_clean_fraction = -0.00000001f; + configs[8].min_clean_fraction = -0.00000001f; /* 9 -- epoch_length too small */ - configs[9].epoch_length = H5C__MIN_AR_EPOCH_LENGTH - 1; + configs[9].epoch_length = H5C__MIN_AR_EPOCH_LENGTH - 1; /* 10 -- epoch_length too big */ - configs[10].epoch_length = H5C__MAX_AR_EPOCH_LENGTH + 1; + configs[10].epoch_length = H5C__MAX_AR_EPOCH_LENGTH + 1; /* 11 -- invalid incr_mode */ - configs[11].incr_mode = (enum H5C_cache_incr_mode)-1; + configs[11].incr_mode = (enum H5C_cache_incr_mode) - 1; /* 12 -- lower_hr_threshold too small */ - configs[12].lower_hr_threshold = -0.000001f; + configs[12].lower_hr_threshold = -0.000001f; /* 13 -- lower_hr_threshold too big */ - configs[13].lower_hr_threshold = 1.00000001f; + configs[13].lower_hr_threshold = 1.00000001f; /* 14 -- increment too small */ - configs[14].increment = 0.999999999999; + configs[14].increment = 0.999999999999; /* 15 -- invalid flash_incr_mode */ - configs[15].flash_incr_mode = (enum H5C_cache_flash_incr_mode)-1; + configs[15].flash_incr_mode = (enum H5C_cache_flash_incr_mode) - 1; /* 16 -- flash_multiple too small */ - configs[16].flash_incr_mode = H5C_flash_incr__add_space; - configs[16].flash_multiple = 0.09f; + configs[16].flash_incr_mode = H5C_flash_incr__add_space; + configs[16].flash_multiple = 0.09f; /* 17 -- flash_multiple too big */ - configs[17].flash_incr_mode = H5C_flash_incr__add_space; - configs[17].flash_multiple = 10.001f; + configs[17].flash_incr_mode = H5C_flash_incr__add_space; + configs[17].flash_multiple = 10.001f; /* 18 -- flash_threshold too small */ - configs[18].flash_incr_mode = H5C_flash_incr__add_space; - configs[18].flash_threshold = 0.099f; + configs[18].flash_incr_mode = H5C_flash_incr__add_space; + configs[18].flash_threshold = 0.099f; /* 19 -- flash_threshold too big */ - configs[19].flash_incr_mode = H5C_flash_incr__add_space; - configs[19].flash_threshold = 1.001f; + configs[19].flash_incr_mode = H5C_flash_incr__add_space; + configs[19].flash_threshold = 1.001f; /* 20 -- bad decr_mode */ - configs[20].decr_mode = (enum H5C_cache_decr_mode)-1; + configs[20].decr_mode = (enum H5C_cache_decr_mode) - 1; /* 21 -- upper_hr_threshold too big */ - configs[21].upper_hr_threshold = 1.00001f; + configs[21].upper_hr_threshold = 1.00001f; /* 22 -- decrement too small */ - configs[22].decr_mode = H5C_decr__threshold; - configs[22].decrement = -0.0000000001f; + configs[22].decr_mode = H5C_decr__threshold; + configs[22].decrement = -0.0000000001f; /* 23 -- decrement too big */ - configs[23].decr_mode = H5C_decr__threshold; - configs[23].decrement = 1.0000000001; + configs[23].decr_mode = H5C_decr__threshold; + configs[23].decrement = 1.0000000001; /* 24 -- epochs_before_eviction too small */ - configs[24].epochs_before_eviction = 0; + configs[24].epochs_before_eviction = 0; /* 25 -- epochs_before_eviction too big */ - configs[25].epochs_before_eviction = H5C__MAX_EPOCH_MARKERS + 1; + configs[25].epochs_before_eviction = H5C__MAX_EPOCH_MARKERS + 1; /* 26 -- empty_reserve too small */ - configs[26].empty_reserve = -0.0000000001f; + configs[26].empty_reserve = -0.0000000001f; /* 27 -- empty_reserve too big */ - configs[27].empty_reserve = 1.00000000001; + configs[27].empty_reserve = 1.00000000001; /* 28 -- upper_hr_threshold too small */ - configs[28].upper_hr_threshold = -0.000000001f; + configs[28].upper_hr_threshold = -0.000000001f; /* 29 -- upper_hr_threshold too big */ - configs[29].upper_hr_threshold = 1.00000001; + configs[29].upper_hr_threshold = 1.00000001; /* 30 -- upper_hr_threshold <= lower_hr_threshold */ - configs[30].lower_hr_threshold = 0.9f; - configs[30].upper_hr_threshold = 0.9f; + configs[30].lower_hr_threshold = 0.9f; + configs[30].upper_hr_threshold = 0.9f; /* 31 -- dirty_bytes_threshold too small */ - configs[31].dirty_bytes_threshold = (H5C__MIN_MAX_CACHE_SIZE / 2) - 1; + configs[31].dirty_bytes_threshold = (H5C__MIN_MAX_CACHE_SIZE / 2) - 1; /* 32 -- dirty_bytes_threshold too big */ - configs[32].dirty_bytes_threshold = (H5C__MAX_MAX_CACHE_SIZE / 4) + 1; + configs[32].dirty_bytes_threshold = (H5C__MAX_MAX_CACHE_SIZE / 4) + 1; /* 33 -- attempt to disable evictions when auto incr enabled */ - configs[33].evictions_enabled = FALSE; - configs[33].decr_mode = H5C_decr__off; + configs[33].evictions_enabled = FALSE; + configs[33].decr_mode = H5C_decr__off; /* 34 -- attempt to disable evictions when auto decr enabled */ - configs[34].evictions_enabled = FALSE; - configs[34].decr_mode = H5C_decr__age_out; + configs[34].evictions_enabled = FALSE; + configs[34].decr_mode = H5C_decr__age_out; /* 35 -- unknown metadata write strategy */ - configs[35].metadata_write_strategy = -1; + configs[35].metadata_write_strategy = -1; return configs; } /* initialize_invalid_configs() */ - /*------------------------------------------------------------------------- * Function: check_fapl_mdc_api_errs() * @@ -1759,10 +1682,10 @@ init_invalid_configs(void) { static hbool_t check_fapl_mdc_api_errs(void) { - static char msg[128]; - int i; - herr_t result; - hid_t fapl_id = -1; + static char msg[128]; + int i; + herr_t result; + hid_t fapl_id = -1; H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG; H5AC_cache_config_t scratch; @@ -1774,15 +1697,17 @@ check_fapl_mdc_api_errs(void) */ scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; - if ( pass ) { + if (pass) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Pget_mdc_config((hid_t)-1, &scratch); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_config() accepted invalid plist_id."; } } @@ -1791,35 +1716,36 @@ check_fapl_mdc_api_errs(void) * default MDC configuration. */ - if ( pass ) { + if (pass) { fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if ( fapl_id < 0 ) { + if (fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; } } scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; - if ( ( pass ) && - ( ( H5Pget_mdc_config(fapl_id, &scratch) < 0) || - ( !CACHE_CONFIGS_EQUAL(default_config, scratch, TRUE, TRUE) ) ) ) { + if ((pass) && ((H5Pget_mdc_config(fapl_id, &scratch) < 0) || + (!CACHE_CONFIGS_EQUAL(default_config, scratch, TRUE, TRUE)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "New FAPL has unexpected metadata cache config?!?!?.\n"; } - if ( pass ) { + if (pass) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Pget_mdc_config(fapl_id, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_config() accepted NULL config_ptr."; } } @@ -1827,62 +1753,67 @@ check_fapl_mdc_api_errs(void) /* one last test for H5Pget_mdc_config() */ scratch.version = -1; /* a convenient, invalid value */ - if ( pass ) { + if (pass) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Pget_mdc_config(fapl_id, &scratch); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_config() accepted bad config version."; } } - /* now test H5Pset_mdc_config() */ scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; - if ( pass ) { + if (pass) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Pset_mdc_config((hid_t)-1, &default_config); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_config() accepted bad invalid plist_id."; } } - if ( pass ) { + if (pass) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Pset_mdc_config(fapl_id, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_config() accepted NULL config_ptr."; } } i = 0; - while ( ( pass ) && ( i < NUM_INVALID_CONFIGS ) ) - { - H5E_BEGIN_TRY { + while ((pass) && (i < NUM_INVALID_CONFIGS)) { + H5E_BEGIN_TRY + { result = H5Pset_mdc_config(fapl_id, &(invalid_configs[i])); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5Pset_mdc_config() accepted invalid_configs[%d].", i); + HDsnprintf(msg, (size_t)128, "H5Pset_mdc_config() accepted invalid_configs[%d].", i); failure_mssg = msg; } i++; @@ -1892,24 +1823,23 @@ check_fapl_mdc_api_errs(void) * the configuration in the FAPL. */ scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; - if ( ( pass ) && - ( ( H5Pget_mdc_config(fapl_id, &scratch) < 0 ) || - ( !CACHE_CONFIGS_EQUAL(default_config, scratch, TRUE, TRUE) ) ) ) { + if ((pass) && ((H5Pget_mdc_config(fapl_id, &scratch) < 0) || + (!CACHE_CONFIGS_EQUAL(default_config, scratch, TRUE, TRUE)))) { - pass = FALSE; + pass = FALSE; failure_mssg = "FAPL metadata cache config changed???.\n"; } - if ( pass ) { + if (pass) { PASSED(); - - } else { + } + else { H5_FAILED(); } - if ( ! pass ) { + if (!pass) { HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } @@ -1918,7 +1848,6 @@ check_fapl_mdc_api_errs(void) } /* check_fapl_mdc_api_errs() */ - /*------------------------------------------------------------------------- * Function: check_file_mdc_api_errs() * @@ -1935,21 +1864,21 @@ check_fapl_mdc_api_errs(void) static hbool_t check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id) { - char filename[512]; - static char msg[128]; - hbool_t show_progress = FALSE; - int i; - herr_t result; - hid_t file_id = -1; - size_t max_size; - size_t min_clean_size; - size_t cur_size; - int cur_num_entries; - double hit_rate; + char filename[512]; + static char msg[128]; + hbool_t show_progress = FALSE; + int i; + herr_t result; + hid_t file_id = -1; + size_t max_size; + size_t min_clean_size; + size_t cur_size; + int cur_num_entries; + double hit_rate; H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG; H5AC_cache_config_t scratch; - if(paged) + if (paged) TESTING("MDC/FILE related API input errors for paged aggregation strategy") else TESTING("MDC/FILE related API input errors") @@ -1961,157 +1890,162 @@ check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id) */ /* setup the file name */ - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: calling h5_fixname().\n", FUNC); } - if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: calling H5Fcreate().\n", FUNC); } file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fcreate() failed.\n"; } } validate_mdc_config(file_id, &default_config, TRUE, 1); - /* test H5Fget_mdc_config(). */ scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: testing H5Fget_mdc_config() 1.\n", FUNC); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Fget_mdc_config((hid_t)-1, &scratch); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_config() accepted invalid file_id."; } } - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: testing H5Fget_mdc_config() 2.\n", FUNC); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Fget_mdc_config(file_id, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_config() accepted NULL config_ptr."; } } scratch.version = -1; /* a convenient, invalid value */ - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: testing H5Fget_mdc_config() 3.\n", FUNC); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Fget_mdc_config(file_id, &scratch); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_config() accepted bad config version."; } } - /* test H5Fset_mdc_config() */ scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: testing H5Fset_mdc_config() 1.\n", FUNC); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Fset_mdc_config((hid_t)-1, &default_config); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() accepted bad invalid file_id."; } } - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: testing H5Fset_mdc_config() 2.\n", FUNC); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Fset_mdc_config(file_id, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fset_mdc_config() accepted NULL config_ptr."; } } i = 0; - while ( ( pass ) && ( i < NUM_INVALID_CONFIGS ) ) - { - if ( show_progress ) { + while ((pass) && (i < NUM_INVALID_CONFIGS)) { + if (show_progress) { - HDfprintf(stdout, - "%s: testing H5Fset_mdc_config() with invalid config %d.\n", - FUNC, i); + HDfprintf(stdout, "%s: testing H5Fset_mdc_config() with invalid config %d.\n", FUNC, i); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Fset_mdc_config(file_id, &(invalid_configs[i])); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5Fset_mdc_config() accepted invalid_configs[%d].", i); + HDsnprintf(msg, (size_t)128, "H5Fset_mdc_config() accepted invalid_configs[%d].", i); failure_mssg = msg; } i++; @@ -2122,140 +2056,137 @@ check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id) */ validate_mdc_config(file_id, &default_config, TRUE, 2); - /* test H5Fget_mdc_hit_rate() */ - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { - HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 1.\n", - FUNC); + HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 1.\n", FUNC); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Fget_mdc_hit_rate((hid_t)-1, &hit_rate); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_hit_rate() accepted bad file_id."; } } - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { - HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 2.\n", - FUNC); + HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 2.\n", FUNC); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Fget_mdc_hit_rate(file_id, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_hit_rate() accepted NULL hit_rate_ptr."; } } - /* test H5Freset_mdc_hit_rate_stats() */ - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { - HDfprintf(stdout, "%s: testing H5Freset_mdc_hit_rate_stats().\n", - FUNC); + HDfprintf(stdout, "%s: testing H5Freset_mdc_hit_rate_stats().\n", FUNC); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { result = H5Freset_mdc_hit_rate_stats((hid_t)-1); - } H5E_END_TRY; + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; - failure_mssg = - "H5Freset_mdc_hit_rate_stats() accepted bad file_id."; + pass = FALSE; + failure_mssg = "H5Freset_mdc_hit_rate_stats() accepted bad file_id."; } } - /* test H5Fget_mdc_size() */ - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: testing H5Fget_mdc_size() 1.\n", FUNC); } - H5E_BEGIN_TRY { - result = H5Fget_mdc_size((hid_t)-1, &max_size, &min_clean_size, - &cur_size, &cur_num_entries); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + result = H5Fget_mdc_size((hid_t)-1, &max_size, &min_clean_size, &cur_size, &cur_num_entries); + } + H5E_END_TRY; - if ( result >= 0 ) { + if (result >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_size() accepted bad file_id."; } } - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: testing H5Fget_mdc_size() 2.\n", FUNC); } - if ( ( H5Fget_mdc_size(file_id, &max_size, NULL, NULL, NULL) < 0 ) || - ( H5Fget_mdc_size(file_id, NULL, &min_clean_size, - NULL, NULL) < 0 ) || - ( H5Fget_mdc_size(file_id, NULL, NULL, &cur_size, NULL) < 0 ) || - ( H5Fget_mdc_size(file_id, NULL, NULL, NULL, - &cur_num_entries) < 0 ) || - ( H5Fget_mdc_size(file_id, NULL, NULL, NULL, NULL) < 0 ) ) { + if ((H5Fget_mdc_size(file_id, &max_size, NULL, NULL, NULL) < 0) || + (H5Fget_mdc_size(file_id, NULL, &min_clean_size, NULL, NULL) < 0) || + (H5Fget_mdc_size(file_id, NULL, NULL, &cur_size, NULL) < 0) || + (H5Fget_mdc_size(file_id, NULL, NULL, NULL, &cur_num_entries) < 0) || + (H5Fget_mdc_size(file_id, NULL, NULL, NULL, NULL) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_size() failed to handle NULL params."; } } - /* close the file and delete it */ - if ( pass ) { + if (pass) { - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: cleaning up from tests.\n", FUNC); } - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; + } + else if (HDremove(filename) < 0) { - } else if ( HDremove(filename) < 0 ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { + if (pass) { PASSED(); - - } else { + } + else { H5_FAILED(); } - if ( ! pass ) { + if (!pass) { HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); } @@ -2264,7 +2195,6 @@ check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id) } /* check_file_mdc_api_errs() */ - /*------------------------------------------------------------------------- * Function: main * @@ -2281,9 +2211,9 @@ int main(void) { unsigned nerrs = 0; - int express_test; - hid_t fcpl_id = -1; - hid_t fcpl2_id = -1; + int express_test; + hid_t fcpl_id = -1; + hid_t fcpl2_id = -1; unsigned paged; H5open(); @@ -2295,30 +2225,29 @@ main(void) HDprintf(" express_test = %d\n", express_test); HDprintf("===================================\n"); - /* Initialize invalid configurations. */ invalid_configs = init_invalid_configs(); - if ( NULL == invalid_configs ) { + if (NULL == invalid_configs) { failure_mssg = "Unable to allocate memory for invalid configs."; HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return EXIT_FAILURE; } /* end if */ - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) { + if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) { failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return EXIT_FAILURE; } /* end if */ /* Set file space strategy to default or paged aggregation strategy */ - if((fcpl2_id = H5Pcopy(fcpl_id)) < 0) { + if ((fcpl2_id = H5Pcopy(fcpl_id)) < 0) { failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return EXIT_FAILURE; } /* end if */ - if(H5Pset_file_space_strategy(fcpl2_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) < 0) { + if (H5Pset_file_space_strategy(fcpl2_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) < 0) { failure_mssg = "H5Pset_file_space_strategy() failed.\n"; HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return EXIT_FAILURE; @@ -2326,40 +2255,39 @@ main(void) /* Test with paged aggregation enabled or not */ /* The "my_fcpl" passed to each test has the paged or non-paged strategy set up accordinly */ - for(paged = FALSE; paged <= TRUE; paged++) { + for (paged = FALSE; paged <= TRUE; paged++) { hid_t my_fcpl = fcpl_id; - if(paged) + if (paged) my_fcpl = fcpl2_id; - if(!check_fapl_mdc_api_calls(paged, my_fcpl)) + if (!check_fapl_mdc_api_calls(paged, my_fcpl)) nerrs += 1; - if(!check_file_mdc_api_calls(paged, my_fcpl)) + if (!check_file_mdc_api_calls(paged, my_fcpl)) nerrs += 1; - if(!mdc_api_call_smoke_check(express_test, paged, my_fcpl)) + if (!mdc_api_call_smoke_check(express_test, paged, my_fcpl)) nerrs += 1; - if(!check_file_mdc_api_errs(paged, my_fcpl)) + if (!check_file_mdc_api_errs(paged, my_fcpl)) nerrs += 1; } /* end for paged */ - if(!check_fapl_mdc_api_errs()) + if (!check_fapl_mdc_api_errs()) nerrs += 1; - if(invalid_configs) + if (invalid_configs) HDfree(invalid_configs); - if(H5Pclose(fcpl_id) < 0 ) { + if (H5Pclose(fcpl_id) < 0) { failure_mssg = "H5Pclose() failed.\n"; HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return EXIT_FAILURE; } /* end if */ - if(nerrs > 0) + if (nerrs > 0) return EXIT_FAILURE; else return EXIT_SUCCESS; } /* main() */ - diff --git a/test/cache_common.c b/test/cache_common.c index 1be6fd2..b58923e 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -18,26 +18,26 @@ * implemented in H5C.c */ #include "H5private.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5MMprivate.h" #include "cache_common.h" -hbool_t pass = TRUE; /* set to false on error */ -const char *failure_mssg = NULL; +hbool_t pass = TRUE; /* set to false on error */ +const char *failure_mssg = NULL; const char *last_failure_mssg = ""; -static test_entry_t *pico_entries = NULL, *orig_pico_entries = NULL; -static test_entry_t *nano_entries = NULL, *orig_nano_entries = NULL; -static test_entry_t *micro_entries = NULL, *orig_micro_entries = NULL; -static test_entry_t *tiny_entries = NULL, *orig_tiny_entries = NULL; -static test_entry_t *small_entries = NULL, *orig_small_entries = NULL; -static test_entry_t *medium_entries = NULL, *orig_medium_entries = NULL; -static test_entry_t *large_entries = NULL, *orig_large_entries = NULL; -static test_entry_t *huge_entries = NULL, *orig_huge_entries = NULL; -static test_entry_t *monster_entries = NULL, *orig_monster_entries = NULL; -static test_entry_t *variable_entries = NULL, *orig_variable_entries = NULL; -static test_entry_t *notify_entries = NULL, *orig_notify_entries = NULL; +static test_entry_t *pico_entries = NULL, *orig_pico_entries = NULL; +static test_entry_t *nano_entries = NULL, *orig_nano_entries = NULL; +static test_entry_t *micro_entries = NULL, *orig_micro_entries = NULL; +static test_entry_t *tiny_entries = NULL, *orig_tiny_entries = NULL; +static test_entry_t *small_entries = NULL, *orig_small_entries = NULL; +static test_entry_t *medium_entries = NULL, *orig_medium_entries = NULL; +static test_entry_t *large_entries = NULL, *orig_large_entries = NULL; +static test_entry_t *huge_entries = NULL, *orig_huge_entries = NULL; +static test_entry_t *monster_entries = NULL, *orig_monster_entries = NULL; +static test_entry_t *variable_entries = NULL, *orig_variable_entries = NULL; +static test_entry_t *notify_entries = NULL, *orig_notify_entries = NULL; hbool_t orig_entry_arrays_init = FALSE; @@ -53,33 +53,22 @@ static herr_t monster_get_initial_load_size(void *udata_ptr, size_t *image_len_p static herr_t variable_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr); static herr_t notify_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr); -static herr_t variable_get_final_load_size(const void *image, size_t image_len, - void *udata, size_t *actual_len); +static herr_t variable_get_final_load_size(const void *image, size_t image_len, void *udata, + size_t *actual_len); static htri_t variable_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void *pico_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *nano_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *micro_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *tiny_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *small_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *medium_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *large_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *huge_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *monster_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *variable_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); -static void *notify_deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr); +static void *pico_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *nano_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *micro_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *tiny_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *small_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *medium_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *large_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *huge_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *monster_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *variable_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); +static void *notify_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); static herr_t pico_image_len(const void *thing, size_t *image_len_ptr); static herr_t nano_image_len(const void *thing, size_t *image_len_ptr); @@ -93,62 +82,40 @@ static herr_t monster_image_len(const void *thing, size_t *image_len_ptr); static herr_t variable_image_len(const void *thing, size_t *image_len_ptr); static herr_t notify_image_len(const void *thing, size_t *image_len_ptr); -static herr_t pico_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t nano_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t micro_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t tiny_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t small_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t medium_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t large_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t huge_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t monster_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t variable_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); -static herr_t notify_pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, - size_t *new_len_ptr, unsigned *flags_ptr); - -static herr_t pico_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t nano_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t micro_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t tiny_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t small_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t medium_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t large_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t huge_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t monster_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t variable_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t notify_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); +static herr_t pico_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t nano_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t micro_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t tiny_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t small_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t medium_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t large_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t huge_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t monster_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t variable_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t notify_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); + +static herr_t pico_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t nano_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t micro_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t tiny_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t small_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t medium_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t large_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t huge_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t monster_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t variable_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t notify_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); static herr_t pico_free_icr(void *thing); static herr_t nano_free_icr(void *thing); @@ -162,97 +129,50 @@ static herr_t monster_free_icr(void *thing); static herr_t variable_free_icr(void *thing); static herr_t notify_free_icr(void *thing); - static herr_t notify_notify(H5C_notify_action_t action, void *thing); -static void mark_flush_dep_dirty(test_entry_t * entry_ptr); -static void mark_flush_dep_clean(test_entry_t * entry_ptr); +static void mark_flush_dep_dirty(test_entry_t *entry_ptr); +static void mark_flush_dep_clean(test_entry_t *entry_ptr); /* Generic callback routines */ -static herr_t get_initial_load_size(void *udata_ptr, size_t *image_len_ptr, - int32_t entry_type); -static herr_t get_final_load_size(const void *image, size_t image_len, - void *udata, size_t *actual_len, int32_t entry_type); -static void *deserialize(const void *image_ptr, size_t len, void *udata_ptr, - hbool_t *dirty_ptr, int32_t entry_type); +static herr_t get_initial_load_size(void *udata_ptr, size_t *image_len_ptr, int32_t entry_type); +static herr_t get_final_load_size(const void *image, size_t image_len, void *udata, size_t *actual_len, + int32_t entry_type); +static void * deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr, + int32_t entry_type); static herr_t image_len(const void *thing, size_t *image_len_ptr, int32_t entry_type); -static herr_t pre_serialize(H5F_t *f, void *thing, - haddr_t addr, size_t len, haddr_t *new_addr_ptr, size_t *new_len_ptr, - unsigned *flags_ptr); -static herr_t serialize(const H5F_t *f, void *image_ptr, size_t len, - void *thing); -static herr_t notify(H5C_notify_action_t action, void *thing, int32_t - entry_type); +static herr_t pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr); +static herr_t serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t notify(H5C_notify_action_t action, void *thing, int32_t entry_type); static herr_t free_icr(test_entry_t *entry, int32_t entry_type); /* Local routines */ -static void execute_flush_op(H5F_t *file_ptr, struct test_entry_t *entry_ptr, - struct flush_op *op_ptr, unsigned *flags_ptr); +static void execute_flush_op(H5F_t *file_ptr, struct test_entry_t *entry_ptr, struct flush_op *op_ptr, + unsigned *flags_ptr); test_entry_t *entries[NUMBER_OF_ENTRY_TYPES]; test_entry_t *orig_entries[NUMBER_OF_ENTRY_TYPES]; -const int32_t max_indices[NUMBER_OF_ENTRY_TYPES] = -{ - NUM_PICO_ENTRIES - 1, - NUM_NANO_ENTRIES - 1, - NUM_MICRO_ENTRIES - 1, - NUM_TINY_ENTRIES - 1, - NUM_SMALL_ENTRIES - 1, - NUM_MEDIUM_ENTRIES - 1, - NUM_LARGE_ENTRIES - 1, - NUM_HUGE_ENTRIES - 1, - NUM_MONSTER_ENTRIES - 1, - NUM_VARIABLE_ENTRIES - 1, - NUM_NOTIFY_ENTRIES - 1 -}; - -const size_t entry_sizes[NUMBER_OF_ENTRY_TYPES] = -{ - PICO_ENTRY_SIZE, - NANO_ENTRY_SIZE, - MICRO_ENTRY_SIZE, - TINY_ENTRY_SIZE, - SMALL_ENTRY_SIZE, - MEDIUM_ENTRY_SIZE, - LARGE_ENTRY_SIZE, - HUGE_ENTRY_SIZE, - MONSTER_ENTRY_SIZE, - VARIABLE_ENTRY_SIZE, - NOTIFY_ENTRY_SIZE -}; - -const haddr_t base_addrs[NUMBER_OF_ENTRY_TYPES] = -{ - PICO_BASE_ADDR, - NANO_BASE_ADDR, - MICRO_BASE_ADDR, - TINY_BASE_ADDR, - SMALL_BASE_ADDR, - MEDIUM_BASE_ADDR, - LARGE_BASE_ADDR, - HUGE_BASE_ADDR, - MONSTER_BASE_ADDR, - VARIABLE_BASE_ADDR, - NOTIFY_BASE_ADDR -}; - -const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES] = -{ - PICO_ALT_BASE_ADDR, - NANO_ALT_BASE_ADDR, - MICRO_ALT_BASE_ADDR, - TINY_ALT_BASE_ADDR, - SMALL_ALT_BASE_ADDR, - MEDIUM_ALT_BASE_ADDR, - LARGE_ALT_BASE_ADDR, - HUGE_ALT_BASE_ADDR, - MONSTER_ALT_BASE_ADDR, - VARIABLE_ALT_BASE_ADDR, - NOTIFY_ALT_BASE_ADDR -}; +const int32_t max_indices[NUMBER_OF_ENTRY_TYPES] = { + NUM_PICO_ENTRIES - 1, NUM_NANO_ENTRIES - 1, NUM_MICRO_ENTRIES - 1, NUM_TINY_ENTRIES - 1, + NUM_SMALL_ENTRIES - 1, NUM_MEDIUM_ENTRIES - 1, NUM_LARGE_ENTRIES - 1, NUM_HUGE_ENTRIES - 1, + NUM_MONSTER_ENTRIES - 1, NUM_VARIABLE_ENTRIES - 1, NUM_NOTIFY_ENTRIES - 1}; + +const size_t entry_sizes[NUMBER_OF_ENTRY_TYPES] = {PICO_ENTRY_SIZE, NANO_ENTRY_SIZE, MICRO_ENTRY_SIZE, + TINY_ENTRY_SIZE, SMALL_ENTRY_SIZE, MEDIUM_ENTRY_SIZE, + LARGE_ENTRY_SIZE, HUGE_ENTRY_SIZE, MONSTER_ENTRY_SIZE, + VARIABLE_ENTRY_SIZE, NOTIFY_ENTRY_SIZE}; +const haddr_t base_addrs[NUMBER_OF_ENTRY_TYPES] = { + PICO_BASE_ADDR, NANO_BASE_ADDR, MICRO_BASE_ADDR, TINY_BASE_ADDR, SMALL_BASE_ADDR, MEDIUM_BASE_ADDR, + LARGE_BASE_ADDR, HUGE_BASE_ADDR, MONSTER_BASE_ADDR, VARIABLE_BASE_ADDR, NOTIFY_BASE_ADDR}; + +const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES] = { + PICO_ALT_BASE_ADDR, NANO_ALT_BASE_ADDR, MICRO_ALT_BASE_ADDR, TINY_ALT_BASE_ADDR, + SMALL_ALT_BASE_ADDR, MEDIUM_ALT_BASE_ADDR, LARGE_ALT_BASE_ADDR, HUGE_ALT_BASE_ADDR, + MONSTER_ALT_BASE_ADDR, VARIABLE_ALT_BASE_ADDR, NOTIFY_ALT_BASE_ADDR}; /* Callback classes */ static const H5C_class_t pico_class[1] = {{ @@ -455,23 +375,12 @@ static const H5C_class_t notify_class[1] = {{ /* callback table declaration */ -const H5C_class_t *types[NUMBER_OF_ENTRY_TYPES] = { - pico_class, - nano_class, - micro_class, - tiny_class, - small_class, - medium_class, - large_class, - huge_class, - monster_class, - variable_class, - notify_class -}; +const H5C_class_t *types[NUMBER_OF_ENTRY_TYPES] = {pico_class, nano_class, micro_class, tiny_class, + small_class, medium_class, large_class, huge_class, + monster_class, variable_class, notify_class}; /* address translation functions: */ - /*------------------------------------------------------------------------- * Function: addr_to_type_and_index * @@ -486,72 +395,63 @@ const H5C_class_t *types[NUMBER_OF_ENTRY_TYPES] = { *------------------------------------------------------------------------- */ void -addr_to_type_and_index(haddr_t addr, - int32_t *type_ptr, - int32_t *index_ptr) +addr_to_type_and_index(haddr_t addr, int32_t *type_ptr, int32_t *index_ptr) { - int i; + int i; int32_t type; int32_t idx; - HDassert( type_ptr ); - HDassert( index_ptr ); + HDassert(type_ptr); + HDassert(index_ptr); /* we only have a small number of entry types, so just do a * linear search. If NUMBER_OF_ENTRY_TYPES grows, we may want * to do a binary search instead. */ i = 1; - if ( addr >= PICO_ALT_BASE_ADDR ) { + if (addr >= PICO_ALT_BASE_ADDR) { - while ( ( i < NUMBER_OF_ENTRY_TYPES ) && - ( addr >= alt_base_addrs[i] ) ) - { + while ((i < NUMBER_OF_ENTRY_TYPES) && (addr >= alt_base_addrs[i])) { i++; } + } + else { - } else { - - while ( ( i < NUMBER_OF_ENTRY_TYPES ) && - ( addr >= base_addrs[i] ) ) - { + while ((i < NUMBER_OF_ENTRY_TYPES) && (addr >= base_addrs[i])) { i++; } } type = i - 1; - HDassert( ( type >= 0 ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); + HDassert((type >= 0) && (type < NUMBER_OF_ENTRY_TYPES)); - if ( addr >= PICO_ALT_BASE_ADDR ) { + if (addr >= PICO_ALT_BASE_ADDR) { idx = (int32_t)((addr - alt_base_addrs[type]) / entry_sizes[type]); - HDassert( ( idx >= 0 ) && ( idx <= max_indices[type] ) ); - HDassert( !((entries[type])[idx].at_main_addr) ); - HDassert( addr == (entries[type])[idx].alt_addr ); - - } else { + HDassert((idx >= 0) && (idx <= max_indices[type])); + HDassert(!((entries[type])[idx].at_main_addr)); + HDassert(addr == (entries[type])[idx].alt_addr); + } + else { idx = (int32_t)((addr - base_addrs[type]) / entry_sizes[type]); - HDassert( ( idx >= 0 ) && ( idx <= max_indices[type] ) ); - HDassert( (entries[type])[idx].at_main_addr ); - HDassert( addr == (entries[type])[idx].main_addr ); + HDassert((idx >= 0) && (idx <= max_indices[type])); + HDassert((entries[type])[idx].at_main_addr); + HDassert(addr == (entries[type])[idx].main_addr); } - HDassert( addr == (entries[type])[idx].addr ); + HDassert(addr == (entries[type])[idx].addr); - *type_ptr = type; + *type_ptr = type; *index_ptr = idx; return; } /* addr_to_type_and_index() */ - /* Call back functions: */ - - /*------------------------------------------------------------------------- * Function: get_initial_load_size & friends * @@ -570,14 +470,14 @@ get_initial_load_size(void *udata, size_t *image_length, int32_t H5_ATTR_NDEBUG_ { test_entry_t *entry; test_entry_t *base_addr; - haddr_t addr = *(const haddr_t *)udata; - int32_t type; - int32_t idx; + haddr_t addr = *(const haddr_t *)udata; + int32_t type; + int32_t idx; addr_to_type_and_index(addr, &type, &idx); base_addr = entries[type]; - entry = &(base_addr[idx]); + entry = &(base_addr[idx]); HDassert(entry->type >= 0); HDassert(entry->type == type); @@ -591,7 +491,7 @@ get_initial_load_size(void *udata, size_t *image_length, int32_t H5_ATTR_NDEBUG_ *image_length = entry->size; - return(SUCCEED); + return (SUCCEED); } /* get_initial_load_size() */ static herr_t @@ -660,7 +560,6 @@ notify_get_initial_load_size(void *udata, size_t *image_length) return get_initial_load_size(udata, image_length, NOTIFY_ENTRY_TYPE); } - /*------------------------------------------------------------------------- * Function: get_final_load_size & friends * @@ -675,19 +574,19 @@ notify_get_initial_load_size(void *udata, size_t *image_length) *------------------------------------------------------------------------- */ static herr_t -get_final_load_size(const void H5_ATTR_UNUSED *image, size_t H5_ATTR_UNUSED image_len, - void *udata, size_t *actual_len, int32_t H5_ATTR_NDEBUG_UNUSED entry_type) +get_final_load_size(const void H5_ATTR_UNUSED *image, size_t H5_ATTR_UNUSED image_len, void *udata, + size_t *actual_len, int32_t H5_ATTR_NDEBUG_UNUSED entry_type) { test_entry_t *entry; test_entry_t *base_addr; - haddr_t addr = *(const haddr_t *)udata; - int32_t type; - int32_t idx; + haddr_t addr = *(const haddr_t *)udata; + int32_t type; + int32_t idx; addr_to_type_and_index(addr, &type, &idx); base_addr = entries[type]; - entry = &(base_addr[idx]); + entry = &(base_addr[idx]); HDassert(entry->type >= 0); HDassert(entry->type == type); @@ -701,24 +600,22 @@ get_final_load_size(const void H5_ATTR_UNUSED *image, size_t H5_ATTR_UNUSED imag HDassert(type == VARIABLE_ENTRY_TYPE); /* Simulate SPECULATIVE read with a specified actual_len */ - if(entry->actual_len) { + if (entry->actual_len) { *actual_len = entry->actual_len; entry->size = entry->actual_len; } /* end if */ else *actual_len = entry->size; - return(SUCCEED); + return (SUCCEED); } /* get_final_load_size() */ static herr_t -variable_get_final_load_size(const void *image, size_t image_len, - void *udata, size_t *actual_len) +variable_get_final_load_size(const void *image, size_t image_len, void *udata, size_t *actual_len) { return get_final_load_size(image, image_len, udata, actual_len, VARIABLE_ENTRY_TYPE); } - /*------------------------------------------------------------------------- * Function: verify_chksum & friends * (only done for VARIABLE_ENTRY_TYPE which has a speculative read) @@ -737,18 +634,18 @@ variable_get_final_load_size(const void *image, size_t image_len, static htri_t verify_chksum(const void H5_ATTR_UNUSED *image, size_t H5_ATTR_UNUSED len, void *udata, - int32_t H5_ATTR_NDEBUG_UNUSED entry_type) + int32_t H5_ATTR_NDEBUG_UNUSED entry_type) { test_entry_t *entry; test_entry_t *base_addr; - haddr_t addr = *(const haddr_t *)udata; - int32_t type; - int32_t idx; + haddr_t addr = *(const haddr_t *)udata; + int32_t type; + int32_t idx; addr_to_type_and_index(addr, &type, &idx); base_addr = entries[type]; - entry = &(base_addr[idx]); + entry = &(base_addr[idx]); HDassert(entry->type >= 0); HDassert(entry->type == type); @@ -761,10 +658,10 @@ verify_chksum(const void H5_ATTR_UNUSED *image, size_t H5_ATTR_UNUSED len, void HDassert(entry == entry->self); HDassert(entry->addr == addr); - if(++entry->verify_ct >= entry->max_verify_ct) - return(TRUE); + if (++entry->verify_ct >= entry->max_verify_ct) + return (TRUE); else - return(FALSE); + return (FALSE); } /* verify_chksum() */ @@ -774,7 +671,6 @@ variable_verify_chksum(const void *image, size_t len, void *udata) return verify_chksum(image, len, udata, VARIABLE_ENTRY_TYPE); } - /*------------------------------------------------------------------------- * Function: deserialize & friends * @@ -791,18 +687,18 @@ variable_verify_chksum(const void *image, size_t len, void *udata) */ static void * deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *udata, hbool_t *dirty, - int32_t H5_ATTR_NDEBUG_UNUSED entry_type) + int32_t H5_ATTR_NDEBUG_UNUSED entry_type) { test_entry_t *entry; test_entry_t *base_addr; - haddr_t addr = *(haddr_t *)udata; - int32_t type; - int32_t idx; + haddr_t addr = *(haddr_t *)udata; + int32_t type; + int32_t idx; addr_to_type_and_index(addr, &type, &idx); base_addr = entries[type]; - entry = &(base_addr[idx]); + entry = &(base_addr[idx]); HDassert(entry->type >= 0); HDassert(entry->type == type); @@ -816,52 +712,43 @@ deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *udata, hb HDassert(entry->size == len); HDassert((entry->type == VARIABLE_ENTRY_TYPE) || (entry->size == entry_sizes[type])); HDassert(dirty != NULL); - HDassert( entry->flush_dep_npar == 0 ); - HDassert( entry->flush_dep_nchd == 0 ); + HDassert(entry->flush_dep_npar == 0); + HDassert(entry->flush_dep_nchd == 0); /* for now *dirty will always be FALSE */ *dirty = FALSE; /* verify that the image contains the expected data. */ HDassert(image != NULL); - if((entry->at_main_addr && entry->written_to_main_addr) || - (!entry->at_main_addr && entry->written_to_alt_addr)) { - if((type == PICO_ENTRY_TYPE) || (type == VARIABLE_ENTRY_TYPE) || - (type == NOTIFY_ENTRY_TYPE)) { - if((*((const char *)image)) != (char)(idx & 0xFF)) { - HDfprintf(stdout, "type = %d, idx = %d, addr = 0x%lx.\n", - type, idx, (long)addr); - HDfprintf(stdout, "*image = 0x%x\n", - (int)(*((const char *)image))); - HDfprintf(stdout, "expected *image = 0x%x\n", - (int)(idx & 0xFF)); + if ((entry->at_main_addr && entry->written_to_main_addr) || + (!entry->at_main_addr && entry->written_to_alt_addr)) { + if ((type == PICO_ENTRY_TYPE) || (type == VARIABLE_ENTRY_TYPE) || (type == NOTIFY_ENTRY_TYPE)) { + if ((*((const char *)image)) != (char)(idx & 0xFF)) { + HDfprintf(stdout, "type = %d, idx = %d, addr = 0x%lx.\n", type, idx, (long)addr); + HDfprintf(stdout, "*image = 0x%x\n", (int)(*((const char *)image))); + HDfprintf(stdout, "expected *image = 0x%x\n", (int)(idx & 0xFF)); } /* end if */ - HDassert((*((const char *)image)) == (char)(idx & 0xFF)); + HDassert((*((const char *)image)) == (char)(idx & 0xFF)); } /* end if */ else { - if((*(((const char *)image) + 2)) != (char)(idx & 0xFF)) { - HDfprintf(stdout, "type = %d, idx = %d, addr = 0x%lx.\n", - type, idx, (long)addr); - HDfprintf(stdout, "*image = 0x%x 0x%x 0x%x\n", - (int)(*((const char *)image)), - (int)(*(((const char *)image) + 1)), - (int)(*(((const char *)image) + 2))); - HDfprintf(stdout, "expected *image = 0x%x\n", - (int)(idx & 0xFF), - (int)((idx & 0xFF00) >> 8)); + if ((*(((const char *)image) + 2)) != (char)(idx & 0xFF)) { + HDfprintf(stdout, "type = %d, idx = %d, addr = 0x%lx.\n", type, idx, (long)addr); + HDfprintf(stdout, "*image = 0x%x 0x%x 0x%x\n", (int)(*((const char *)image)), + (int)(*(((const char *)image) + 1)), (int)(*(((const char *)image) + 2))); + HDfprintf(stdout, "expected *image = 0x%x\n", (int)(idx & 0xFF), (int)((idx & 0xFF00) >> 8)); } /* end if */ - HDassert((*((const char *)image)) == (char)(type & 0xFF)); - HDassert((*(((const char *)image) + 1)) == (char)((idx & 0xFF00) >> 8)); - HDassert((*(((const char *)image) + 2)) == (char)(idx & 0xFF)); + HDassert((*((const char *)image)) == (char)(type & 0xFF)); + HDassert((*(((const char *)image) + 1)) == (char)((idx & 0xFF00) >> 8)); + HDassert((*(((const char *)image) + 2)) == (char)(idx & 0xFF)); } /* end else */ - } /* end if */ + } /* end if */ - entry->deserialized = TRUE; + entry->deserialized = TRUE; entry->header.is_dirty = FALSE; - entry->is_dirty = FALSE; + entry->is_dirty = FALSE; (entry->deserializes)++; - return((void *)entry); + return ((void *)entry); } /* deserialize() */ void * @@ -930,7 +817,6 @@ notify_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty) return deserialize(image, len, udata, dirty, NOTIFY_ENTRY_TYPE); } - /*------------------------------------------------------------------------- * Function: image_len & friends * @@ -950,7 +836,7 @@ herr_t image_len(const void *thing, size_t *image_length, int32_t H5_ATTR_NDEBUG_UNUSED entry_type) { const test_entry_t *entry; - int32_t type; + int32_t type; HDassert(thing); HDassert(image_length); @@ -967,16 +853,16 @@ image_len(const void *thing, size_t *image_length, int32_t H5_ATTR_NDEBUG_UNUSED HDassert(entry == &(entries[type][entry->index])); - if(type != VARIABLE_ENTRY_TYPE) - HDassert(entry->size == entry_sizes[type]); + if (type != VARIABLE_ENTRY_TYPE) + HDassert(entry->size == entry_sizes[type]); else { - HDassert(entry->size <= entry_sizes[type]); - HDassert(entry->size > 0); + HDassert(entry->size <= entry_sizes[type]); + HDassert(entry->size > 0); } /* end else */ *image_length = entry->size; - return(SUCCEED); + return (SUCCEED); } /* image_len() */ herr_t @@ -1045,7 +931,6 @@ notify_image_len(const void *thing, size_t *image_length) return image_len(thing, image_length, NOTIFY_ENTRY_TYPE); } - /*------------------------------------------------------------------------- * Function: pre_serialize & friends * @@ -1065,16 +950,12 @@ notify_image_len(const void *thing, size_t *image_length) *------------------------------------------------------------------------- */ herr_t -pre_serialize(H5F_t H5_ATTR_NDEBUG_UNUSED *f, - void *thing, - haddr_t H5_ATTR_NDEBUG_UNUSED addr, - size_t H5_ATTR_NDEBUG_UNUSED len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, +pre_serialize(H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *thing, haddr_t H5_ATTR_NDEBUG_UNUSED addr, + size_t H5_ATTR_NDEBUG_UNUSED len, haddr_t *new_addr_ptr, size_t *new_len_ptr, unsigned *flags_ptr) { test_entry_t *entry; - int32_t i; + int32_t i; HDassert(f); HDassert(thing); @@ -1099,14 +980,13 @@ pre_serialize(H5F_t H5_ATTR_NDEBUG_UNUSED *f, HDassert(entry->num_flush_ops >= 0); HDassert(entry->num_flush_ops < MAX_FLUSH_OPS); - if(entry->num_flush_ops > 0) { - for(i = 0; i < entry->num_flush_ops; i++ ) { + if (entry->num_flush_ops > 0) { + for (i = 0; i < entry->num_flush_ops; i++) { HDassert(entry->file_ptr); - execute_flush_op(entry->file_ptr, entry, - &((entry->flush_ops)[i]), flags_ptr); + execute_flush_op(entry->file_ptr, entry, &((entry->flush_ops)[i]), flags_ptr); } /* end for */ - entry->num_flush_ops = 0; + entry->num_flush_ops = 0; entry->flush_op_self_resize_in_progress = FALSE; /* This looks wrong, but it isn't -- *flags_ptr will be modified @@ -1114,7 +994,7 @@ pre_serialize(H5F_t H5_ATTR_NDEBUG_UNUSED *f, * and the flags set will accumulate over the set of calls in * the for loop. */ - if(pass && (((*flags_ptr) & H5C__SERIALIZE_RESIZED_FLAG) != 0)) { + if (pass && (((*flags_ptr) & H5C__SERIALIZE_RESIZED_FLAG) != 0)) { /* set *new_len_ptr to the new length. */ @@ -1125,164 +1005,96 @@ pre_serialize(H5F_t H5_ATTR_NDEBUG_UNUSED *f, *new_len_ptr = entry->size; } /* end if */ - if(((*flags_ptr) & H5C__SERIALIZE_MOVED_FLAG) != 0) { + if (((*flags_ptr) & H5C__SERIALIZE_MOVED_FLAG) != 0) { HDassert(((*flags_ptr) | H5C__SERIALIZE_RESIZED_FLAG) != 0); /* place the new address in *new_addr */ *new_addr_ptr = entry->addr; } /* end if */ - } /* end if */ + } /* end if */ - return(SUCCEED); + return (SUCCEED); } /* pre_serialize() */ herr_t -pico_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +pico_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -nano_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +nano_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -micro_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +micro_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -tiny_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +tiny_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -small_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +small_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -medium_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +medium_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -large_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +large_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -huge_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +huge_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -monster_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +monster_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -variable_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +variable_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } herr_t -notify_pre_serialize(H5F_t *f, - void *thing, - haddr_t addr, - size_t len, - haddr_t *new_addr_ptr, - size_t *new_len_ptr, - unsigned *flags_ptr) +notify_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr_ptr, + size_t *new_len_ptr, unsigned *flags_ptr) { - return pre_serialize(f, thing, addr, len, - new_addr_ptr, new_len_ptr, flags_ptr); + return pre_serialize(f, thing, addr, len, new_addr_ptr, new_len_ptr, flags_ptr); } - - /*------------------------------------------------------------------------- * Function: serialize & friends * @@ -1307,7 +1119,7 @@ herr_t serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void *thing) { test_entry_t *entry; - int32_t type; + int32_t type; HDassert(image_ptr); HDassert(thing); @@ -1332,16 +1144,15 @@ serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void *thin /* null out the image to avoid spurious failures */ HDmemset(image_ptr, 0, len); - if((type == PICO_ENTRY_TYPE) || (type == VARIABLE_ENTRY_TYPE) || - (type == NOTIFY_ENTRY_TYPE )) { - HDassert(entry->size >= PICO_ENTRY_SIZE); - *((char *)image_ptr) = (char)((entry->index) & 0xFF); + if ((type == PICO_ENTRY_TYPE) || (type == VARIABLE_ENTRY_TYPE) || (type == NOTIFY_ENTRY_TYPE)) { + HDassert(entry->size >= PICO_ENTRY_SIZE); + *((char *)image_ptr) = (char)((entry->index) & 0xFF); } /* end if */ else { - HDassert(entry->size >= NANO_ENTRY_SIZE); - *((char *)image_ptr) = (char)((entry->type) & 0xFF); - *(((char *)image_ptr) + 1) = (char)(((entry->index) & 0xFF00) >> 8); - *(((char *)image_ptr) + 2) = (char)((entry->index) & 0xFF); + HDassert(entry->size >= NANO_ENTRY_SIZE); + *((char *)image_ptr) = (char)((entry->type) & 0xFF); + *(((char *)image_ptr) + 1) = (char)(((entry->index) & 0xFF00) >> 8); + *(((char *)image_ptr) + 2) = (char)((entry->index) & 0xFF); } /* end else */ /* We no longer do the actual write through an callback -- this is @@ -1350,24 +1161,24 @@ serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void *thin */ entry->is_dirty = FALSE; - if(entry->flush_dep_npar > 0) { - HDassert(entry->flush_dep_ndirty_chd == 0); + if (entry->flush_dep_npar > 0) { + HDassert(entry->flush_dep_ndirty_chd == 0); mark_flush_dep_clean(entry); } /* end if */ /* since the entry is about to be written to disk, we can mark it * as initialized. */ - if(entry->at_main_addr) - entry->written_to_main_addr = TRUE; + if (entry->at_main_addr) + entry->written_to_main_addr = TRUE; else - entry->written_to_alt_addr = TRUE; + entry->written_to_alt_addr = TRUE; /* do book keeping */ (entry->serializes)++; entry->serialized = TRUE; - return(SUCCEED); + return (SUCCEED); } /* serialize() */ herr_t @@ -1401,8 +1212,7 @@ small_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void } herr_t -medium_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, - void *thing) +medium_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void *thing) { return serialize(f, image_ptr, len, thing); } @@ -1420,27 +1230,23 @@ huge_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void } herr_t -monster_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, - void *thing) +monster_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void *thing) { return serialize(f, image_ptr, len, thing); } herr_t -variable_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, - void *thing) +variable_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void *thing) { return serialize(f, image_ptr, len, thing); } herr_t -notify_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, - void *thing) +notify_serialize(const H5F_t H5_ATTR_UNUSED *f, void *image_ptr, size_t len, void *thing) { return serialize(f, image_ptr, len, thing); } - /*------------------------------------------------------------------------- * Function: notify & friends * @@ -1470,15 +1276,14 @@ notify(H5C_notify_action_t action, void *thing, int32_t H5_ATTR_NDEBUG_UNUSED en HDassert(entry->type == entry_type); HDassert(entry == &(entries[entry->type][entry->index])); HDassert(entry == entry->self); - if(!(action == H5C_NOTIFY_ACTION_ENTRY_DIRTIED && entry->action == TEST_ENTRY_ACTION_MOVE)) + if (!(action == H5C_NOTIFY_ACTION_ENTRY_DIRTIED && entry->action == TEST_ENTRY_ACTION_MOVE)) HDassert(entry->header.addr == entry->addr); - HDassert((entry->type == VARIABLE_ENTRY_TYPE) || \ - (entry->size == entry_sizes[entry->type])); + HDassert((entry->type == VARIABLE_ENTRY_TYPE) || (entry->size == entry_sizes[entry->type])); /* Increment count for appropriate action */ - switch(action) { - case H5C_NOTIFY_ACTION_AFTER_INSERT: /* Entry has been added */ - case H5C_NOTIFY_ACTION_AFTER_LOAD: /* to the cache. */ + switch (action) { + case H5C_NOTIFY_ACTION_AFTER_INSERT: /* Entry has been added */ + case H5C_NOTIFY_ACTION_AFTER_LOAD: /* to the cache. */ entry->notify_after_insert_count++; break; @@ -1489,10 +1294,10 @@ notify(H5C_notify_action_t action, void *thing, int32_t H5_ATTR_NDEBUG_UNUSED en case H5C_NOTIFY_ACTION_CHILD_CLEANED: case H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5C_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; - case H5C_NOTIFY_ACTION_BEFORE_EVICT: /* Entry is about to be evicted from cache */ + case H5C_NOTIFY_ACTION_BEFORE_EVICT: /* Entry is about to be evicted from cache */ entry->notify_before_evict_count++; break; @@ -1500,16 +1305,15 @@ notify(H5C_notify_action_t action, void *thing, int32_t H5_ATTR_NDEBUG_UNUSED en HDassert(0 && "Unknown notify action!?!"); } /* end switch */ - return(SUCCEED); + return (SUCCEED); } /* notify() */ herr_t notify_notify(H5C_notify_action_t action, void *thing) { - return(notify(action, thing, NOTIFY_ENTRY_TYPE)); + return (notify(action, thing, NOTIFY_ENTRY_TYPE)); } - /*------------------------------------------------------------------------- * Function: free_icr & friends * @@ -1544,54 +1348,52 @@ free_icr(test_entry_t *entry, int32_t H5_ATTR_NDEBUG_UNUSED entry_type) HDassert(entry == entry->self); HDassert(entry->cache_ptr != NULL); HDassert(entry->cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert((entry->header.destroy_in_progress) || - (entry->header.addr == entry->addr)); + HDassert((entry->header.destroy_in_progress) || (entry->header.addr == entry->addr)); HDassert(entry->header.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); HDassert(entry->header.size == entry->size); - HDassert((entry->type == VARIABLE_ENTRY_TYPE) || - (entry->size == entry_sizes[entry->type])); + HDassert((entry->type == VARIABLE_ENTRY_TYPE) || (entry->size == entry_sizes[entry->type])); HDassert(entry->header.tl_next == NULL); HDassert(entry->header.tl_prev == NULL); - if(entry->num_pins > 0) { + if (entry->num_pins > 0) { int i; - for(i = 0; i < entry->num_pins; i++) { + for (i = 0; i < entry->num_pins; i++) { test_entry_t *pinned_entry; test_entry_t *pinned_base_addr; - pinned_base_addr = entries[entry->pin_type[i]]; - pinned_entry = &(pinned_base_addr[entry->pin_idx[i]]); + pinned_base_addr = entries[entry->pin_type[i]]; + pinned_entry = &(pinned_base_addr[entry->pin_idx[i]]); - HDassert(0 <= pinned_entry->type); + HDassert(0 <= pinned_entry->type); HDassert(pinned_entry->type < NUMBER_OF_ENTRY_TYPES); - HDassert(pinned_entry->type == entry->pin_type[i]); - HDassert(pinned_entry->index >= 0); - HDassert(pinned_entry->index <= max_indices[pinned_entry->type]); - HDassert(pinned_entry->index == entry->pin_idx[i]); - HDassert(pinned_entry == pinned_entry->self); - HDassert(pinned_entry->header.is_pinned); - HDassert(pinned_entry->is_pinned); - HDassert(pinned_entry->pinning_ref_count > 0); - - pinned_entry->pinning_ref_count--; - - if(pinned_entry->pinning_ref_count <= 0) { + HDassert(pinned_entry->type == entry->pin_type[i]); + HDassert(pinned_entry->index >= 0); + HDassert(pinned_entry->index <= max_indices[pinned_entry->type]); + HDassert(pinned_entry->index == entry->pin_idx[i]); + HDassert(pinned_entry == pinned_entry->self); + HDassert(pinned_entry->header.is_pinned); + HDassert(pinned_entry->is_pinned); + HDassert(pinned_entry->pinning_ref_count > 0); + + pinned_entry->pinning_ref_count--; + + if (pinned_entry->pinning_ref_count <= 0) { HDassert(pinned_entry->file_ptr); - unpin_entry(pinned_entry->type, pinned_entry->index); - } /* end if */ + unpin_entry(pinned_entry->type, pinned_entry->index); + } /* end if */ - entry->pin_type[i] = -1; - entry->pin_idx[i] = -1; - } /* end if */ - entry->num_pins = 0; + entry->pin_type[i] = -1; + entry->pin_idx[i] = -1; + } /* end if */ + entry->num_pins = 0; } /* end if */ entry->destroyed = TRUE; entry->cache_ptr = NULL; - return(SUCCEED); + return (SUCCEED); } /* free_icr() */ herr_t @@ -1660,7 +1462,6 @@ notify_free_icr(void *thing) return free_icr((test_entry_t *)thing, NOTIFY_ENTRY_TYPE); } - /**************************************************************************/ /**************************************************************************/ /************************** test utility functions: ***********************/ @@ -1684,60 +1485,50 @@ notify_free_icr(void *thing) */ void -add_flush_op(int target_type, - int target_idx, - int op_code, - int type, - int idx, - hbool_t flag, - size_t new_size, - unsigned * order_ptr) +add_flush_op(int target_type, int target_idx, int op_code, int type, int idx, hbool_t flag, size_t new_size, + unsigned *order_ptr) { - int i; - test_entry_t * target_base_addr; - test_entry_t * target_entry_ptr; - - HDassert( ( 0 <= target_type ) && ( target_type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= target_idx ) && - ( target_idx <= max_indices[target_type] ) ); - HDassert( ( 0 <= op_code ) && ( op_code <= FLUSH_OP__MAX_OP ) ); - HDassert( ( op_code != FLUSH_OP__RESIZE ) || - ( type == VARIABLE_ENTRY_TYPE ) ); - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); - HDassert( new_size <= VARIABLE_ENTRY_SIZE ); + int i; + test_entry_t *target_base_addr; + test_entry_t *target_entry_ptr; + + HDassert((0 <= target_type) && (target_type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= target_idx) && (target_idx <= max_indices[target_type])); + HDassert((0 <= op_code) && (op_code <= FLUSH_OP__MAX_OP)); + HDassert((op_code != FLUSH_OP__RESIZE) || (type == VARIABLE_ENTRY_TYPE)); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); + HDassert(new_size <= VARIABLE_ENTRY_SIZE); #ifndef H5_HAVE_STDBOOL_H /* Check for TRUE or FALSE if we're using an integer type instead * of a real Boolean type. */ - HDassert( ( flag == TRUE ) || ( flag == FALSE ) ); + HDassert((flag == TRUE) || (flag == FALSE)); #endif /* H5_HAVE_STDBOOL_H */ - if ( pass ) { + if (pass) { target_base_addr = entries[target_type]; target_entry_ptr = &(target_base_addr[target_idx]); - HDassert( target_entry_ptr->index == target_idx ); - HDassert( target_entry_ptr->type == target_type ); - HDassert( target_entry_ptr == target_entry_ptr->self ); - HDassert( target_entry_ptr->num_flush_ops < MAX_FLUSH_OPS ); - - i = (target_entry_ptr->num_flush_ops)++; - (target_entry_ptr->flush_ops)[i].op_code = op_code; - (target_entry_ptr->flush_ops)[i].type = type; - (target_entry_ptr->flush_ops)[i].idx = idx; - (target_entry_ptr->flush_ops)[i].flag = flag; - (target_entry_ptr->flush_ops)[i].size = new_size; - (target_entry_ptr->flush_ops)[i].order_ptr = order_ptr; - + HDassert(target_entry_ptr->index == target_idx); + HDassert(target_entry_ptr->type == target_type); + HDassert(target_entry_ptr == target_entry_ptr->self); + HDassert(target_entry_ptr->num_flush_ops < MAX_FLUSH_OPS); + + i = (target_entry_ptr->num_flush_ops)++; + (target_entry_ptr->flush_ops)[i].op_code = op_code; + (target_entry_ptr->flush_ops)[i].type = type; + (target_entry_ptr->flush_ops)[i].idx = idx; + (target_entry_ptr->flush_ops)[i].flag = flag; + (target_entry_ptr->flush_ops)[i].size = new_size; + (target_entry_ptr->flush_ops)[i].order_ptr = order_ptr; } return; } /* add_flush_op() */ - /*------------------------------------------------------------------------- * Function: create_pinned_entry_dependency * @@ -1761,27 +1552,20 @@ add_flush_op(int target_type, */ void -create_pinned_entry_dependency(H5F_t * file_ptr, - int pinning_type, - int pinning_idx, - int pinned_type, - int pinned_idx) +create_pinned_entry_dependency(H5F_t *file_ptr, int pinning_type, int pinning_idx, int pinned_type, + int pinned_idx) { - test_entry_t * pinning_base_addr; - test_entry_t * pinning_entry_ptr; - test_entry_t * pinned_base_addr; - test_entry_t * pinned_entry_ptr; - - if ( pass ) { - - HDassert( ( 0 <= pinning_type ) && - ( pinning_type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= pinning_idx ) && - ( pinning_idx <= max_indices[pinning_type] ) ); - HDassert( ( 0 <= pinned_type ) && - ( pinned_type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= pinned_idx ) && - ( pinned_idx <= max_indices[pinned_type] ) ); + test_entry_t *pinning_base_addr; + test_entry_t *pinning_entry_ptr; + test_entry_t *pinned_base_addr; + test_entry_t *pinned_entry_ptr; + + if (pass) { + + HDassert((0 <= pinning_type) && (pinning_type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= pinning_idx) && (pinning_idx <= max_indices[pinning_type])); + HDassert((0 <= pinned_type) && (pinned_type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= pinned_idx) && (pinned_idx <= max_indices[pinned_type])); pinning_base_addr = entries[pinning_type]; pinning_entry_ptr = &(pinning_base_addr[pinning_idx]); @@ -1789,34 +1573,33 @@ create_pinned_entry_dependency(H5F_t * file_ptr, pinned_base_addr = entries[pinned_type]; pinned_entry_ptr = &(pinned_base_addr[pinned_idx]); - HDassert( pinning_entry_ptr->index == pinning_idx ); - HDassert( pinning_entry_ptr->type == pinning_type ); - HDassert( pinning_entry_ptr == pinning_entry_ptr->self ); - HDassert( pinning_entry_ptr->num_pins < MAX_PINS ); + HDassert(pinning_entry_ptr->index == pinning_idx); + HDassert(pinning_entry_ptr->type == pinning_type); + HDassert(pinning_entry_ptr == pinning_entry_ptr->self); + HDassert(pinning_entry_ptr->num_pins < MAX_PINS); - HDassert( pinning_entry_ptr->index == pinning_idx ); - HDassert( pinning_entry_ptr->type == pinning_type ); - HDassert( pinning_entry_ptr == pinning_entry_ptr->self ); - HDassert( ! ( pinning_entry_ptr->is_protected ) ); + HDassert(pinning_entry_ptr->index == pinning_idx); + HDassert(pinning_entry_ptr->type == pinning_type); + HDassert(pinning_entry_ptr == pinning_entry_ptr->self); + HDassert(!(pinning_entry_ptr->is_protected)); - pinning_entry_ptr->pin_type[pinning_entry_ptr->num_pins] = pinned_type; - pinning_entry_ptr->pin_idx[pinning_entry_ptr->num_pins] = pinned_idx; - (pinning_entry_ptr->num_pins)++; + pinning_entry_ptr->pin_type[pinning_entry_ptr->num_pins] = pinned_type; + pinning_entry_ptr->pin_idx[pinning_entry_ptr->num_pins] = pinned_idx; + (pinning_entry_ptr->num_pins)++; - if ( pinned_entry_ptr->pinning_ref_count == 0 ) { + if (pinned_entry_ptr->pinning_ref_count == 0) { - protect_entry(file_ptr, pinned_type, pinned_idx); - unprotect_entry(file_ptr, pinned_type, pinned_idx, H5C__PIN_ENTRY_FLAG); - } + protect_entry(file_ptr, pinned_type, pinned_idx); + unprotect_entry(file_ptr, pinned_type, pinned_idx, H5C__PIN_ENTRY_FLAG); + } - (pinned_entry_ptr->pinning_ref_count)++; + (pinned_entry_ptr->pinning_ref_count)++; } return; } /* create_pinned_entry_dependency() */ - /*------------------------------------------------------------------------- * Function: dirty_entry * @@ -1839,62 +1622,58 @@ create_pinned_entry_dependency(H5F_t * file_ptr, */ void -dirty_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx, - hbool_t dirty_pin) +dirty_entry(H5F_t *file_ptr, int32_t type, int32_t idx, hbool_t dirty_pin) { - test_entry_t * base_addr; - test_entry_t * entry_ptr; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - HDassert( file_ptr ); - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + HDassert(file_ptr); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); - if ( pass ) { + if (pass) { - if ( dirty_pin ) { + if (dirty_pin) { H5C_t *cache_ptr = file_ptr->shared->cache; HDassert(cache_ptr); - if ( ! entry_in_cache(cache_ptr, type, idx) ) { + if (!entry_in_cache(cache_ptr, type, idx)) { - pass = FALSE; + pass = FALSE; failure_mssg = "entry to be dirty pinned is not in cache."; - - } else { + } + else { base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); - if ( ! ( (entry_ptr->header).is_pinned ) ) { + if (!((entry_ptr->header).is_pinned)) { - pass = FALSE; + pass = FALSE; failure_mssg = "entry to be dirty pinned is not pinned."; + } + else { - } else { - - mark_entry_dirty(type, idx); - - } + mark_entry_dirty(type, idx); + } + } } - } else { + else { - protect_entry(file_ptr, type, idx); + protect_entry(file_ptr, type, idx); unprotect_entry(file_ptr, type, idx, H5C__DIRTIED_FLAG); - } + } } return; } /* dirty_entry() */ - /*------------------------------------------------------------------------- * Function: execute_flush_op * @@ -1912,150 +1691,134 @@ dirty_entry(H5F_t * file_ptr, */ void -execute_flush_op(H5F_t * file_ptr, - struct test_entry_t * entry_ptr, - struct flush_op * op_ptr, - unsigned * flags_ptr) +execute_flush_op(H5F_t *file_ptr, struct test_entry_t *entry_ptr, struct flush_op *op_ptr, + unsigned *flags_ptr) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; - HDassert( file_ptr ); + HDassert(file_ptr); cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr != NULL ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( entry_ptr != NULL ); - HDassert( entry_ptr = entry_ptr->self ); - HDassert( entry_ptr->header.addr == entry_ptr->addr ); - HDassert( ( entry_ptr->flush_op_self_resize_in_progress ) || - ( entry_ptr->header.size == entry_ptr->size ) ); - HDassert( op_ptr != NULL ); - HDassert( ( 0 <= entry_ptr->type ) && - ( entry_ptr->type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= entry_ptr->index ) && - ( entry_ptr->index <= max_indices[entry_ptr->type] ) ); - HDassert( ( 0 <= op_ptr->type ) && - ( op_ptr->type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= op_ptr->idx ) && - ( op_ptr->idx <= max_indices[op_ptr->type] ) ); - HDassert( flags_ptr != NULL ); + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(entry_ptr != NULL); + HDassert(entry_ptr = entry_ptr->self); + HDassert(entry_ptr->header.addr == entry_ptr->addr); + HDassert((entry_ptr->flush_op_self_resize_in_progress) || (entry_ptr->header.size == entry_ptr->size)); + HDassert(op_ptr != NULL); + HDassert((0 <= entry_ptr->type) && (entry_ptr->type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= entry_ptr->index) && (entry_ptr->index <= max_indices[entry_ptr->type])); + HDassert((0 <= op_ptr->type) && (op_ptr->type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= op_ptr->idx) && (op_ptr->idx <= max_indices[op_ptr->type])); + HDassert(flags_ptr != NULL); #ifndef H5_HAVE_STDBOOL_H /* Check for TRUE or FALSE if we're using an integer type instead * of a real Boolean type. */ - HDassert( ( op_ptr->flag == FALSE ) || ( op_ptr->flag == TRUE ) ); + HDassert((op_ptr->flag == FALSE) || (op_ptr->flag == TRUE)); #endif /* H5_HAVE_STDBOOL_H */ - if ( pass ) { + if (pass) { - switch ( op_ptr->op_code ) - { - case FLUSH_OP__NO_OP: - break; + switch (op_ptr->op_code) { + case FLUSH_OP__NO_OP: + break; - case FLUSH_OP__DIRTY: - HDassert( ( entry_ptr->type != op_ptr->type ) || - ( entry_ptr->index != op_ptr->idx ) ); + case FLUSH_OP__DIRTY: + HDassert((entry_ptr->type != op_ptr->type) || (entry_ptr->index != op_ptr->idx)); - dirty_entry(file_ptr, op_ptr->type, op_ptr->idx, op_ptr->flag); - break; + dirty_entry(file_ptr, op_ptr->type, op_ptr->idx, op_ptr->flag); + break; case FLUSH_OP__RESIZE: - if ( ( entry_ptr->type == op_ptr->type ) && - ( entry_ptr->index == op_ptr->idx ) ) { + if ((entry_ptr->type == op_ptr->type) && (entry_ptr->index == op_ptr->idx)) { /* the flush operation is acting on the entry to - * which it is attached. Handle this here: - */ - HDassert( entry_ptr->type == VARIABLE_ENTRY_TYPE ); - HDassert( op_ptr->size > 0 ); - HDassert( op_ptr->size <= VARIABLE_ENTRY_SIZE ); + * which it is attached. Handle this here: + */ + HDassert(entry_ptr->type == VARIABLE_ENTRY_TYPE); + HDassert(op_ptr->size > 0); + HDassert(op_ptr->size <= VARIABLE_ENTRY_SIZE); entry_ptr->size = op_ptr->size; - (*flags_ptr) |= H5C__SERIALIZE_RESIZED_FLAG; - - entry_ptr->flush_op_self_resize_in_progress = TRUE; + (*flags_ptr) |= H5C__SERIALIZE_RESIZED_FLAG; - } else { + entry_ptr->flush_op_self_resize_in_progress = TRUE; + } + else { - /* change the size of some other entry */ + /* change the size of some other entry */ - resize_entry(file_ptr, op_ptr->type, op_ptr->idx, - op_ptr->size, op_ptr->flag); - } - break; + resize_entry(file_ptr, op_ptr->type, op_ptr->idx, op_ptr->size, op_ptr->flag); + } + break; - case FLUSH_OP__MOVE: - if((entry_ptr->type == op_ptr->type) && - (entry_ptr->index == op_ptr->idx)) { + case FLUSH_OP__MOVE: + if ((entry_ptr->type == op_ptr->type) && (entry_ptr->index == op_ptr->idx)) { /* the flush operation is acting on the entry to - * which it is attached. Handle this here: - */ + * which it is attached. Handle this here: + */ - HDassert(((*flags_ptr) & H5C__SERIALIZE_RESIZED_FLAG) != 0); + HDassert(((*flags_ptr) & H5C__SERIALIZE_RESIZED_FLAG) != 0); (*flags_ptr) |= H5C__SERIALIZE_MOVED_FLAG; - if(op_ptr->flag) { + if (op_ptr->flag) { HDassert(entry_ptr->addr == entry_ptr->alt_addr); - entry_ptr->addr = entry_ptr->main_addr; + entry_ptr->addr = entry_ptr->main_addr; entry_ptr->at_main_addr = TRUE; } /* end if */ else { HDassert(entry_ptr->addr == entry_ptr->main_addr); - entry_ptr->addr = entry_ptr->alt_addr; + entry_ptr->addr = entry_ptr->alt_addr; entry_ptr->at_main_addr = FALSE; } /* end else */ - } /* end if */ + } /* end if */ else - move_entry(cache_ptr, op_ptr->type, op_ptr->idx, op_ptr->flag); - break; + move_entry(cache_ptr, op_ptr->type, op_ptr->idx, op_ptr->flag); + break; - case FLUSH_OP__ORDER: - HDassert( op_ptr->order_ptr ); + case FLUSH_OP__ORDER: + HDassert(op_ptr->order_ptr); entry_ptr->flush_order = *op_ptr->order_ptr; (*op_ptr->order_ptr)++; - break; - - case FLUSH_OP__EXPUNGE: - /* the expunge flush op exists to allow us to simulate the - * case in which an entry is removed from the cashe as the - * the result of the flush of a second entry. At present, - * this can only happen via the take ownership flag, but - * we will make this test feature more general to as to make - * tests easier to write. - * - * When this operation is executed, the target entry is - * removed from the cache without being flushed if dirty - * via the expunge_entry() test function (which calls - * H5C_expunge_entry()). Note that this flush operation - * must always be executed on an entry other than the - * entry being flushed. - */ - HDassert( ( entry_ptr->type != op_ptr->type ) || - ( entry_ptr->index != op_ptr->idx ) ); - expunge_entry(file_ptr, op_ptr->type, op_ptr->idx); - break; - - case FLUSH_OP__DEST_FLUSH_DEP: - HDassert( ( entry_ptr->type != op_ptr->type ) || - ( entry_ptr->index != op_ptr->idx ) ); - destroy_flush_dependency(op_ptr->type, op_ptr->idx, - entry_ptr->type, entry_ptr->index); break; - default: - pass = FALSE; + case FLUSH_OP__EXPUNGE: + /* the expunge flush op exists to allow us to simulate the + * case in which an entry is removed from the cashe as the + * the result of the flush of a second entry. At present, + * this can only happen via the take ownership flag, but + * we will make this test feature more general to as to make + * tests easier to write. + * + * When this operation is executed, the target entry is + * removed from the cache without being flushed if dirty + * via the expunge_entry() test function (which calls + * H5C_expunge_entry()). Note that this flush operation + * must always be executed on an entry other than the + * entry being flushed. + */ + HDassert((entry_ptr->type != op_ptr->type) || (entry_ptr->index != op_ptr->idx)); + expunge_entry(file_ptr, op_ptr->type, op_ptr->idx); + break; + + case FLUSH_OP__DEST_FLUSH_DEP: + HDassert((entry_ptr->type != op_ptr->type) || (entry_ptr->index != op_ptr->idx)); + destroy_flush_dependency(op_ptr->type, op_ptr->idx, entry_ptr->type, entry_ptr->index); + break; + + default: + pass = FALSE; failure_mssg = "Undefined flush op code."; - break; - } + break; + } } return; } /* execute_flush_op() */ - /*------------------------------------------------------------------------- * Function: entry_in_cache * @@ -2071,40 +1834,37 @@ execute_flush_op(H5F_t * file_ptr, */ hbool_t -entry_in_cache(H5C_t * cache_ptr, - int32_t type, - int32_t idx) +entry_in_cache(H5C_t *cache_ptr, int32_t type, int32_t idx) { - hbool_t in_cache = FALSE; /* will set to TRUE if necessary */ - test_entry_t * base_addr; - test_entry_t * entry_ptr; - H5C_cache_entry_t * test_ptr = NULL; + hbool_t in_cache = FALSE; /* will set to TRUE if necessary */ + test_entry_t * base_addr; + test_entry_t * entry_ptr; + H5C_cache_entry_t *test_ptr = NULL; - HDassert( cache_ptr ); - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + HDassert(cache_ptr); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); H5C_TEST__SEARCH_INDEX(cache_ptr, entry_ptr->addr, test_ptr) - if ( test_ptr != NULL ) { + if (test_ptr != NULL) { in_cache = TRUE; - HDassert( test_ptr == (H5C_cache_entry_t *)entry_ptr ); - HDassert( entry_ptr->addr == entry_ptr->header.addr ); + HDassert(test_ptr == (H5C_cache_entry_t *)entry_ptr); + HDassert(entry_ptr->addr == entry_ptr->header.addr); } - return(in_cache); + return (in_cache); } /* entry_in_cache() */ - /*------------------------------------------------------------------------- * Function: create_entry_arrays * @@ -2123,93 +1883,94 @@ create_entry_arrays(void) { /* pico entries */ - if(NULL == (pico_entries = (test_entry_t *)HDcalloc(NUM_PICO_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (pico_entries = (test_entry_t *)HDcalloc(NUM_PICO_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_pico_entries = (test_entry_t *)HDcalloc(NUM_PICO_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_pico_entries = (test_entry_t *)HDcalloc(NUM_PICO_ENTRIES, sizeof(test_entry_t)))) goto error; /* nano entries */ - if(NULL == (nano_entries = (test_entry_t *)HDcalloc(NUM_NANO_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (nano_entries = (test_entry_t *)HDcalloc(NUM_NANO_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_nano_entries = (test_entry_t *)HDcalloc(NUM_NANO_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_nano_entries = (test_entry_t *)HDcalloc(NUM_NANO_ENTRIES, sizeof(test_entry_t)))) goto error; /* micro entries */ - if(NULL == (micro_entries = (test_entry_t *)HDcalloc(NUM_MICRO_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (micro_entries = (test_entry_t *)HDcalloc(NUM_MICRO_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_micro_entries = (test_entry_t *)HDcalloc(NUM_MICRO_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_micro_entries = (test_entry_t *)HDcalloc(NUM_MICRO_ENTRIES, sizeof(test_entry_t)))) goto error; /* tiny entries */ - if(NULL == (tiny_entries = (test_entry_t *)HDcalloc(NUM_TINY_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (tiny_entries = (test_entry_t *)HDcalloc(NUM_TINY_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_tiny_entries = (test_entry_t *)HDcalloc(NUM_TINY_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_tiny_entries = (test_entry_t *)HDcalloc(NUM_TINY_ENTRIES, sizeof(test_entry_t)))) goto error; /* small entries */ - if(NULL == (small_entries = (test_entry_t *)HDcalloc(NUM_SMALL_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (small_entries = (test_entry_t *)HDcalloc(NUM_SMALL_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_small_entries = (test_entry_t *)HDcalloc(NUM_SMALL_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_small_entries = (test_entry_t *)HDcalloc(NUM_SMALL_ENTRIES, sizeof(test_entry_t)))) goto error; /* medium entries */ - if(NULL == (medium_entries = (test_entry_t *)HDcalloc(NUM_MEDIUM_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (medium_entries = (test_entry_t *)HDcalloc(NUM_MEDIUM_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_medium_entries = (test_entry_t *)HDcalloc(NUM_MEDIUM_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_medium_entries = (test_entry_t *)HDcalloc(NUM_MEDIUM_ENTRIES, sizeof(test_entry_t)))) goto error; /* large entries */ - if(NULL == (large_entries = (test_entry_t *)HDcalloc(NUM_LARGE_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (large_entries = (test_entry_t *)HDcalloc(NUM_LARGE_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_large_entries = (test_entry_t *)HDcalloc(NUM_LARGE_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_large_entries = (test_entry_t *)HDcalloc(NUM_LARGE_ENTRIES, sizeof(test_entry_t)))) goto error; /* huge entries */ - if(NULL == (huge_entries = (test_entry_t *)HDcalloc(NUM_HUGE_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (huge_entries = (test_entry_t *)HDcalloc(NUM_HUGE_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_huge_entries = (test_entry_t *)HDcalloc(NUM_HUGE_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_huge_entries = (test_entry_t *)HDcalloc(NUM_HUGE_ENTRIES, sizeof(test_entry_t)))) goto error; /* monster entries */ - if(NULL == (monster_entries = (test_entry_t *)HDcalloc(NUM_MONSTER_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (monster_entries = (test_entry_t *)HDcalloc(NUM_MONSTER_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_monster_entries = (test_entry_t *)HDcalloc(NUM_MONSTER_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_monster_entries = (test_entry_t *)HDcalloc(NUM_MONSTER_ENTRIES, sizeof(test_entry_t)))) goto error; /* variable entries */ - if(NULL == (variable_entries = (test_entry_t *)HDcalloc(NUM_VARIABLE_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (variable_entries = (test_entry_t *)HDcalloc(NUM_VARIABLE_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_variable_entries = (test_entry_t *)HDcalloc(NUM_VARIABLE_ENTRIES, sizeof(test_entry_t)))) + if (NULL == + (orig_variable_entries = (test_entry_t *)HDcalloc(NUM_VARIABLE_ENTRIES, sizeof(test_entry_t)))) goto error; /* notify entries */ - if(NULL == (notify_entries = (test_entry_t *)HDcalloc(NUM_NOTIFY_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (notify_entries = (test_entry_t *)HDcalloc(NUM_NOTIFY_ENTRIES, sizeof(test_entry_t)))) goto error; - if(NULL == (orig_notify_entries = (test_entry_t *)HDcalloc(NUM_NOTIFY_ENTRIES, sizeof(test_entry_t)))) + if (NULL == (orig_notify_entries = (test_entry_t *)HDcalloc(NUM_NOTIFY_ENTRIES, sizeof(test_entry_t)))) goto error; - entries[0] = pico_entries; - entries[1] = nano_entries; - entries[2] = micro_entries; - entries[3] = tiny_entries; - entries[4] = small_entries; - entries[5] = medium_entries; - entries[6] = large_entries; - entries[7] = huge_entries; - entries[8] = monster_entries; - entries[9] = variable_entries; + entries[0] = pico_entries; + entries[1] = nano_entries; + entries[2] = micro_entries; + entries[3] = tiny_entries; + entries[4] = small_entries; + entries[5] = medium_entries; + entries[6] = large_entries; + entries[7] = huge_entries; + entries[8] = monster_entries; + entries[9] = variable_entries; entries[10] = notify_entries; - orig_entries[0] = orig_pico_entries; - orig_entries[1] = orig_nano_entries; - orig_entries[2] = orig_micro_entries; - orig_entries[3] = orig_tiny_entries; - orig_entries[4] = orig_small_entries; - orig_entries[5] = orig_medium_entries; - orig_entries[6] = orig_large_entries; - orig_entries[7] = orig_huge_entries; - orig_entries[8] = orig_monster_entries; - orig_entries[9] = orig_variable_entries; + orig_entries[0] = orig_pico_entries; + orig_entries[1] = orig_nano_entries; + orig_entries[2] = orig_micro_entries; + orig_entries[3] = orig_tiny_entries; + orig_entries[4] = orig_small_entries; + orig_entries[5] = orig_medium_entries; + orig_entries[6] = orig_large_entries; + orig_entries[7] = orig_huge_entries; + orig_entries[8] = orig_monster_entries; + orig_entries[9] = orig_variable_entries; orig_entries[10] = orig_notify_entries; return SUCCEED; @@ -2220,7 +1981,6 @@ error: } /* create_entry_arrays() */ - /*------------------------------------------------------------------------- * Function: free_entry_arrays * @@ -2286,7 +2046,6 @@ free_entry_arrays(void) } /* free_entry_arrays() */ - /*------------------------------------------------------------------------- * Function: reset_entries * @@ -2304,31 +2063,28 @@ void reset_entries(void) { - int i; - int32_t max_index; - test_entry_t * base_addr; - test_entry_t * orig_base_addr; + int i; + int32_t max_index; + test_entry_t *base_addr; + test_entry_t *orig_base_addr; - if( !orig_entry_arrays_init) - { - haddr_t addr = PICO_BASE_ADDR; + if (!orig_entry_arrays_init) { + haddr_t addr = PICO_BASE_ADDR; haddr_t alt_addr = PICO_ALT_BASE_ADDR; - size_t entry_size; + size_t entry_size; - for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ ) - { + for (i = 0; i < NUMBER_OF_ENTRY_TYPES; i++) { int j; - entry_size = entry_sizes[i]; - max_index = max_indices[i]; - base_addr = entries[i]; + entry_size = entry_sizes[i]; + max_index = max_indices[i]; + base_addr = entries[i]; orig_base_addr = orig_entries[i]; - HDassert( base_addr ); - HDassert( orig_base_addr ); + HDassert(base_addr); + HDassert(orig_base_addr); - for ( j = 0; j <= max_index; j++ ) - { + for (j = 0; j <= max_index; j++) { int k; /* one can argue that we should fill the header with garbage. @@ -2337,108 +2093,104 @@ reset_entries(void) * enough. */ - base_addr[j].header.addr = (haddr_t)0; - base_addr[j].header.size = (size_t)0; - base_addr[j].header.type = NULL; - base_addr[j].header.is_dirty = FALSE; + base_addr[j].header.addr = (haddr_t)0; + base_addr[j].header.size = (size_t)0; + base_addr[j].header.type = NULL; + base_addr[j].header.is_dirty = FALSE; base_addr[j].header.is_protected = FALSE; base_addr[j].header.is_read_only = FALSE; base_addr[j].header.ro_ref_count = FALSE; - base_addr[j].header.next = NULL; - base_addr[j].header.prev = NULL; + base_addr[j].header.next = NULL; + base_addr[j].header.prev = NULL; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS base_addr[j].header.aux_next = NULL; base_addr[j].header.aux_prev = NULL; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - base_addr[j].self = &(base_addr[j]); - base_addr[j].cache_ptr = NULL; + base_addr[j].self = &(base_addr[j]); + base_addr[j].cache_ptr = NULL; base_addr[j].written_to_main_addr = FALSE; - base_addr[j].written_to_alt_addr = FALSE; - base_addr[j].addr = addr; - base_addr[j].at_main_addr = TRUE; - base_addr[j].main_addr = addr; - base_addr[j].alt_addr = alt_addr; - base_addr[j].size = entry_size; - base_addr[j].type = i; - base_addr[j].index = j; - base_addr[j].serializes = 0; - base_addr[j].deserializes = 0; - base_addr[j].is_dirty = FALSE; - base_addr[j].is_protected = FALSE; - base_addr[j].is_read_only = FALSE; - base_addr[j].ro_ref_count = FALSE; + base_addr[j].written_to_alt_addr = FALSE; + base_addr[j].addr = addr; + base_addr[j].at_main_addr = TRUE; + base_addr[j].main_addr = addr; + base_addr[j].alt_addr = alt_addr; + base_addr[j].size = entry_size; + base_addr[j].type = i; + base_addr[j].index = j; + base_addr[j].serializes = 0; + base_addr[j].deserializes = 0; + base_addr[j].is_dirty = FALSE; + base_addr[j].is_protected = FALSE; + base_addr[j].is_read_only = FALSE; + base_addr[j].ro_ref_count = FALSE; base_addr[j].is_corked = FALSE; - base_addr[j].is_pinned = FALSE; + base_addr[j].is_pinned = FALSE; base_addr[j].pinning_ref_count = 0; - base_addr[j].num_pins = 0; - for ( k = 0; k < MAX_PINS; k++ ) - { + base_addr[j].num_pins = 0; + for (k = 0; k < MAX_PINS; k++) { base_addr[j].pin_type[k] = -1; - base_addr[j].pin_idx[k] = -1; + base_addr[j].pin_idx[k] = -1; } base_addr[j].num_flush_ops = 0; - for ( k = 0; k < MAX_FLUSH_OPS; k++ ) - { + for (k = 0; k < MAX_FLUSH_OPS; k++) { base_addr[j].flush_ops[k].op_code = FLUSH_OP__NO_OP; - base_addr[j].flush_ops[k].type = -1; - base_addr[j].flush_ops[k].idx = -1; - base_addr[j].flush_ops[k].flag = FALSE; - base_addr[j].flush_ops[k].size = 0; + base_addr[j].flush_ops[k].type = -1; + base_addr[j].flush_ops[k].idx = -1; + base_addr[j].flush_ops[k].flag = FALSE; + base_addr[j].flush_ops[k].size = 0; } base_addr[j].flush_op_self_resize_in_progress = FALSE; base_addr[j].deserialized = FALSE; - base_addr[j].serialized = FALSE; - base_addr[j].destroyed = FALSE; - base_addr[j].expunged = FALSE; + base_addr[j].serialized = FALSE; + base_addr[j].destroyed = FALSE; + base_addr[j].expunged = FALSE; - base_addr[j].flush_dep_npar = 0; - base_addr[j].flush_dep_nchd = 0; + base_addr[j].flush_dep_npar = 0; + base_addr[j].flush_dep_nchd = 0; base_addr[j].flush_dep_ndirty_chd = 0; - base_addr[j].pinned_from_client = FALSE; - base_addr[j].pinned_from_cache = FALSE; + base_addr[j].pinned_from_client = FALSE; + base_addr[j].pinned_from_cache = FALSE; base_addr[j].flush_order = 0; base_addr[j].notify_after_insert_count = 0; base_addr[j].notify_before_evict_count = 0; - base_addr[j].actual_len = 0; + base_addr[j].actual_len = 0; base_addr[j].max_verify_ct = 0; - base_addr[j].verify_ct = 0; + base_addr[j].verify_ct = 0; addr += (haddr_t)entry_size; alt_addr += (haddr_t)entry_size; } /* end for */ /* Make copy of entries in base_addr for later */ - HDmemcpy(orig_base_addr, base_addr, (size_t)(max_index + 1) * sizeof( *base_addr )); + HDmemcpy(orig_base_addr, base_addr, (size_t)(max_index + 1) * sizeof(*base_addr)); } /* end for */ /* Indicate that we've made a copy for later */ orig_entry_arrays_init = TRUE; } /* end if */ else { - for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ ) - { - max_index = max_indices[i]; - base_addr = entries[i]; + for (i = 0; i < NUMBER_OF_ENTRY_TYPES; i++) { + max_index = max_indices[i]; + base_addr = entries[i]; orig_base_addr = orig_entries[i]; /* Make copy of entries in base_addr for later */ - HDmemcpy(base_addr, orig_base_addr, (size_t)(max_index + 1) * sizeof( *base_addr )); + HDmemcpy(base_addr, orig_base_addr, (size_t)(max_index + 1) * sizeof(*base_addr)); } /* end for */ - } /* end else */ + } /* end else */ return; } /* reset_entries() */ - /*------------------------------------------------------------------------- * Function: resize_entry * @@ -2459,84 +2211,79 @@ reset_entries(void) */ void -resize_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx, - size_t new_size, - hbool_t in_cache) +resize_entry(H5F_t *file_ptr, int32_t type, int32_t idx, size_t new_size, hbool_t in_cache) { - test_entry_t * base_addr; - test_entry_t * entry_ptr; - herr_t result; + test_entry_t *base_addr; + test_entry_t *entry_ptr; + herr_t result; - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( type == VARIABLE_ENTRY_TYPE ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); - HDassert( ( 0 < new_size ) && ( new_size <= entry_sizes[type] ) ); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert(type == VARIABLE_ENTRY_TYPE); + HDassert((0 <= idx) && (idx <= max_indices[type])); + HDassert((0 < new_size) && (new_size <= entry_sizes[type])); - if ( pass ) { + if (pass) { - if ( in_cache ) { + if (in_cache) { H5C_t *cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr ); + HDassert(cache_ptr); - if ( ! entry_in_cache(cache_ptr, type, idx) ) { + if (!entry_in_cache(cache_ptr, type, idx)) { - pass = FALSE; + pass = FALSE; failure_mssg = "entry to be resized pinned is not in cache."; - - } else { + } + else { base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr->cache_ptr == cache_ptr ); - HDassert( entry_ptr == entry_ptr->self ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr->cache_ptr == cache_ptr); + HDassert(entry_ptr == entry_ptr->self); - if ( ! ( entry_ptr->header.is_pinned || entry_ptr->header.is_protected ) ) { + if (!(entry_ptr->header.is_pinned || entry_ptr->header.is_protected)) { - pass = FALSE; + pass = FALSE; failure_mssg = "entry to be resized is not pinned or protected."; - - } else { + } + else { hbool_t was_dirty = entry_ptr->is_dirty; entry_ptr->size = new_size; - result = H5C_resize_entry((void *)entry_ptr, new_size); + result = H5C_resize_entry((void *)entry_ptr, new_size); entry_ptr->is_dirty = TRUE; - if(entry_ptr->flush_dep_npar > 0 && !was_dirty) + if (entry_ptr->flush_dep_npar > 0 && !was_dirty) mark_flush_dep_dirty(entry_ptr); - if ( result != SUCCEED ) { + if (result != SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "error(s) in H5C_resize_entry()."; + } + else { - } else { - - HDassert( entry_ptr->size = (entry_ptr->header).size ); - + HDassert(entry_ptr->size = (entry_ptr->header).size); } } } - } else { + } + else { - protect_entry(file_ptr, type, idx); + protect_entry(file_ptr, type, idx); resize_entry(file_ptr, type, idx, new_size, TRUE); - unprotect_entry(file_ptr, type, idx, H5C__DIRTIED_FLAG); - } + unprotect_entry(file_ptr, type, idx, H5C__DIRTIED_FLAG); + } } return; } /* resize_entry() */ - /*------------------------------------------------------------------------- * Function: verify_clean * @@ -2557,34 +2304,31 @@ void verify_clean(void) { - int i; - int j; - int dirty_count = 0; - int32_t max_index; - test_entry_t * base_addr; + int i; + int j; + int dirty_count = 0; + int32_t max_index; + test_entry_t *base_addr; - if ( pass ) { + if (pass) { - for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ ) - { + for (i = 0; i < NUMBER_OF_ENTRY_TYPES; i++) { max_index = max_indices[i]; base_addr = entries[i]; - HDassert( base_addr ); + HDassert(base_addr); - for ( j = 0; j <= max_index; j++ ) - { - if ( ( base_addr[j].header.is_dirty ) || - ( base_addr[j].is_dirty ) ) { + for (j = 0; j <= max_index; j++) { + if ((base_addr[j].header.is_dirty) || (base_addr[j].is_dirty)) { dirty_count++; } } } - if ( dirty_count > 0 ) { + if (dirty_count > 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "verify_clean() found dirty entry(s)."; } } @@ -2593,7 +2337,6 @@ verify_clean(void) } /* verify_clean() */ - /*------------------------------------------------------------------------- * Function: verify_entry_status * @@ -2612,238 +2355,178 @@ verify_clean(void) */ void -verify_entry_status(H5C_t * cache_ptr, - int tag, - int num_entries, - struct expected_entry_status expected[]) +verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_entry_status expected[]) { - static char msg[256]; - int i; + static char msg[256]; + int i; i = 0; - while ( ( pass ) && ( i < num_entries ) ) - { - test_entry_t * base_addr = entries[expected[i].entry_type]; - test_entry_t * entry_ptr = &(base_addr[expected[i].entry_index]); - hbool_t in_cache = FALSE; /* will set to TRUE if necessary */ - unsigned u; /* Local index variable */ + while ((pass) && (i < num_entries)) { + test_entry_t *base_addr = entries[expected[i].entry_type]; + test_entry_t *entry_ptr = &(base_addr[expected[i].entry_index]); + hbool_t in_cache = FALSE; /* will set to TRUE if necessary */ + unsigned u; /* Local index variable */ - if ( ( ! expected[i].in_cache ) && - ( ( expected[i].is_protected ) || ( expected[i].is_pinned ) ) ) { + if ((!expected[i].in_cache) && ((expected[i].is_protected) || (expected[i].is_pinned))) { - pass = FALSE; - HDsprintf(msg, "%d: Contradictory data in expected[%d].\n", tag, i); - failure_mssg = msg; - } + pass = FALSE; + HDsprintf(msg, "%d: Contradictory data in expected[%d].\n", tag, i); + failure_mssg = msg; + } - if ( ( ! expected[i].in_cache ) && - ( expected[i].is_dirty ) && - ( ! entry_ptr->expunged ) ) { + if ((!expected[i].in_cache) && (expected[i].is_dirty) && (!entry_ptr->expunged)) { - pass = FALSE; - HDsprintf(msg, - "%d: expected[%d] specs non-expunged, dirty, non-resident.\n", - tag, i); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d: expected[%d] specs non-expunged, dirty, non-resident.\n", tag, i); + failure_mssg = msg; } - if ( pass ) { + if (pass) { - in_cache = entry_in_cache(cache_ptr, expected[i].entry_type, - expected[i].entry_index); + in_cache = entry_in_cache(cache_ptr, expected[i].entry_type, expected[i].entry_index); - if ( in_cache != expected[i].in_cache ) { + if (in_cache != expected[i].in_cache) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) in cache actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)in_cache, - (int)expected[i].in_cache); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) in cache actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, (int)in_cache, + (int)expected[i].in_cache); + failure_mssg = msg; + } } - } - if ( pass ) { + if (pass) { - if ( entry_ptr->size != expected[i].size ) { + if (entry_ptr->size != expected[i].size) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) size actual/expected = %ld/%ld.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (long)(entry_ptr->size), - (long)expected[i].size); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) size actual/expected = %ld/%ld.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, (long)(entry_ptr->size), + (long)expected[i].size); + failure_mssg = msg; + } } - } - if ( ( pass ) && ( in_cache ) ) { + if ((pass) && (in_cache)) { - if ( entry_ptr->header.size != expected[i].size ) { + if (entry_ptr->header.size != expected[i].size) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) header size actual/expected = %ld/%ld.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (long)(entry_ptr->header.size), - (long)expected[i].size); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) header size actual/expected = %ld/%ld.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (long)(entry_ptr->header.size), (long)expected[i].size); + failure_mssg = msg; + } } - } - if ( pass ) { + if (pass) { - if ( entry_ptr->at_main_addr != expected[i].at_main_addr ) { + if (entry_ptr->at_main_addr != expected[i].at_main_addr) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) at main addr actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->at_main_addr), - (int)expected[i].at_main_addr); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) at main addr actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->at_main_addr), (int)expected[i].at_main_addr); + failure_mssg = msg; + } } - } - if ( pass ) { + if (pass) { - if ( entry_ptr->is_dirty != expected[i].is_dirty ) { + if (entry_ptr->is_dirty != expected[i].is_dirty) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) is_dirty actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->is_dirty), - (int)expected[i].is_dirty); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) is_dirty actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->is_dirty), (int)expected[i].is_dirty); + failure_mssg = msg; + } } - } - if ( ( pass ) && ( in_cache ) ) { + if ((pass) && (in_cache)) { - if ( entry_ptr->header.is_dirty != expected[i].is_dirty ) { + if (entry_ptr->header.is_dirty != expected[i].is_dirty) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) header is_dirty actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->header.is_dirty), - (int)expected[i].is_dirty); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) header is_dirty actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->header.is_dirty), (int)expected[i].is_dirty); + failure_mssg = msg; + } } - } - if ( pass ) { + if (pass) { - if ( entry_ptr->is_protected != expected[i].is_protected ) { + if (entry_ptr->is_protected != expected[i].is_protected) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) is_protected actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->is_protected), - (int)expected[i].is_protected); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) is_protected actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->is_protected), (int)expected[i].is_protected); + failure_mssg = msg; + } } - } - if ( ( pass ) && ( in_cache ) ) { + if ((pass) && (in_cache)) { - if ( entry_ptr->header.is_protected != expected[i].is_protected ) { + if (entry_ptr->header.is_protected != expected[i].is_protected) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) header is_protected actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->header.is_protected), - (int)expected[i].is_protected); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) header is_protected actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->header.is_protected), (int)expected[i].is_protected); + failure_mssg = msg; + } } - } - if ( pass ) { + if (pass) { - if ( entry_ptr->is_pinned != expected[i].is_pinned ) { + if (entry_ptr->is_pinned != expected[i].is_pinned) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) is_pinned actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->is_pinned), - (int)expected[i].is_pinned); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) is_pinned actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->is_pinned), (int)expected[i].is_pinned); + failure_mssg = msg; + } } - } - if ( pass ) { + if (pass) { - if ( entry_ptr->is_corked != expected[i].is_corked) { + if (entry_ptr->is_corked != expected[i].is_corked) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) is_corked actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->is_corked), - (int)expected[i].is_corked); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) is_corked actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->is_corked), (int)expected[i].is_corked); + failure_mssg = msg; + } } - } - if ( ( pass ) && ( in_cache ) ) { + if ((pass) && (in_cache)) { - if ( entry_ptr->header.is_pinned != expected[i].is_pinned ) { + if (entry_ptr->header.is_pinned != expected[i].is_pinned) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) header is_pinned actual/expected = %d/%d.\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->header.is_pinned), - (int)expected[i].is_pinned); - failure_mssg = msg; + pass = FALSE; + HDsprintf(msg, "%d entry (%d, %d) header is_pinned actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->header.is_pinned), (int)expected[i].is_pinned); + failure_mssg = msg; + } } - } - if ( pass ) { + if (pass) { - if ( ( entry_ptr->deserialized != expected[i].deserialized ) || - ( entry_ptr->serialized != expected[i].serialized ) || - ( entry_ptr->destroyed != expected[i].destroyed ) ) { + if ((entry_ptr->deserialized != expected[i].deserialized) || + (entry_ptr->serialized != expected[i].serialized) || + (entry_ptr->destroyed != expected[i].destroyed)) { - pass = FALSE; - HDsprintf(msg, - "%d entry (%d,%d) deserialized = %d(%d), serialized = %d(%d), dest = %d(%d)\n", - tag, - (int)expected[i].entry_type, - (int)expected[i].entry_index, - (int)(entry_ptr->deserialized), - (int)(expected[i].deserialized), - (int)(entry_ptr->serialized), - (int)(expected[i].serialized), - (int)(entry_ptr->destroyed), - (int)(expected[i].destroyed)); + pass = FALSE; + HDsprintf(msg, "%d entry (%d,%d) deserialized = %d(%d), serialized = %d(%d), dest = %d(%d)\n", + tag, (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->deserialized), (int)(expected[i].deserialized), + (int)(entry_ptr->serialized), (int)(expected[i].serialized), + (int)(entry_ptr->destroyed), (int)(expected[i].destroyed)); failure_mssg = msg; } } @@ -2851,136 +2534,99 @@ verify_entry_status(H5C_t * cache_ptr, /* Check flush dependency fields */ /* # of flush dependency parents */ - if ( pass ) { - if ( entry_ptr->flush_dep_npar != expected[i].flush_dep_npar ) { + if (pass) { + if (entry_ptr->flush_dep_npar != expected[i].flush_dep_npar) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) flush_dep_npar actual/expected = %u/%u.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - entry_ptr->flush_dep_npar, - expected[i].flush_dep_npar); + HDsprintf(msg, "%d entry (%d, %d) flush_dep_npar actual/expected = %u/%u.\n", tag, + expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_npar, + expected[i].flush_dep_npar); failure_mssg = msg; } /* end if */ - } /* end if */ - if ( ( pass ) && ( in_cache ) ) { - if ( entry_ptr->header.flush_dep_nparents != expected[i].flush_dep_npar ) { + } /* end if */ + if ((pass) && (in_cache)) { + if (entry_ptr->header.flush_dep_nparents != expected[i].flush_dep_npar) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) header flush_dep_nparents actual/expected = %u/%u.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - entry_ptr->header.flush_dep_nparents, - expected[i].flush_dep_npar); + HDsprintf(msg, "%d entry (%d, %d) header flush_dep_nparents actual/expected = %u/%u.\n", tag, + expected[i].entry_type, expected[i].entry_index, + entry_ptr->header.flush_dep_nparents, expected[i].flush_dep_npar); failure_mssg = msg; } /* end if */ - } /* end if */ + } /* end if */ /* Flush dependency parent type & index. Note this algorithm assumes * that the parents in both arrays are in the same order. */ - if ( pass ) { - for ( u = 0; u < entry_ptr->flush_dep_npar; u++ ) { - if ( entry_ptr->flush_dep_par_type[u] != expected[i].flush_dep_par_type[u] ) { + if (pass) { + for (u = 0; u < entry_ptr->flush_dep_npar; u++) { + if (entry_ptr->flush_dep_par_type[u] != expected[i].flush_dep_par_type[u]) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) flush_dep_par_type[%u] actual/expected = %d/%d.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - u, - entry_ptr->flush_dep_par_type[u], - expected[i].flush_dep_par_type[u]); + HDsprintf(msg, "%d entry (%d, %d) flush_dep_par_type[%u] actual/expected = %d/%d.\n", tag, + expected[i].entry_type, expected[i].entry_index, u, + entry_ptr->flush_dep_par_type[u], expected[i].flush_dep_par_type[u]); failure_mssg = msg; } /* end if */ - } /* end for */ - } /* end if */ - if ( pass ) { - for ( u = 0; u < entry_ptr->flush_dep_npar; u++ ) { - if ( entry_ptr->flush_dep_par_idx[u] != expected[i].flush_dep_par_idx[u] ) { + } /* end for */ + } /* end if */ + if (pass) { + for (u = 0; u < entry_ptr->flush_dep_npar; u++) { + if (entry_ptr->flush_dep_par_idx[u] != expected[i].flush_dep_par_idx[u]) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) flush_dep_par_idx[%u] actual/expected = %d/%d.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - u, - entry_ptr->flush_dep_par_idx[u], - expected[i].flush_dep_par_idx[u]); + HDsprintf(msg, "%d entry (%d, %d) flush_dep_par_idx[%u] actual/expected = %d/%d.\n", tag, + expected[i].entry_type, expected[i].entry_index, u, + entry_ptr->flush_dep_par_idx[u], expected[i].flush_dep_par_idx[u]); failure_mssg = msg; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* # of flush dependency children and dirty children */ - if ( pass ) { - if ( entry_ptr->flush_dep_nchd != expected[i].flush_dep_nchd ) { + if (pass) { + if (entry_ptr->flush_dep_nchd != expected[i].flush_dep_nchd) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) flush_dep_nchd actual/expected = %u/%u.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - entry_ptr->flush_dep_nchd, - expected[i].flush_dep_nchd); + HDsprintf(msg, "%d entry (%d, %d) flush_dep_nchd actual/expected = %u/%u.\n", tag, + expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_nchd, + expected[i].flush_dep_nchd); failure_mssg = msg; } /* end if */ - } /* end if */ - if ( ( pass ) && ( in_cache ) ) { - if ( entry_ptr->header.flush_dep_nchildren != expected[i].flush_dep_nchd ) { + } /* end if */ + if ((pass) && (in_cache)) { + if (entry_ptr->header.flush_dep_nchildren != expected[i].flush_dep_nchd) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) header flush_dep_nchildren actual/expected = %u/%u.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - entry_ptr->header.flush_dep_nchildren, - expected[i].flush_dep_nchd); + HDsprintf(msg, "%d entry (%d, %d) header flush_dep_nchildren actual/expected = %u/%u.\n", tag, + expected[i].entry_type, expected[i].entry_index, + entry_ptr->header.flush_dep_nchildren, expected[i].flush_dep_nchd); failure_mssg = msg; } /* end if */ - } /* end if */ - if ( pass ) { - if ( entry_ptr->flush_dep_ndirty_chd != expected[i].flush_dep_ndirty_chd ) { + } /* end if */ + if (pass) { + if (entry_ptr->flush_dep_ndirty_chd != expected[i].flush_dep_ndirty_chd) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) flush_dep_ndirty_chd actual/expected = %u/%u.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - entry_ptr->flush_dep_ndirty_chd, - expected[i].flush_dep_ndirty_chd); + HDsprintf(msg, "%d entry (%d, %d) flush_dep_ndirty_chd actual/expected = %u/%u.\n", tag, + expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_ndirty_chd, + expected[i].flush_dep_ndirty_chd); failure_mssg = msg; } /* end if */ - } /* end if */ - if ( ( pass ) && ( in_cache ) ) { - if ( entry_ptr->header.flush_dep_ndirty_children != expected[i].flush_dep_ndirty_chd ) { + } /* end if */ + if ((pass) && (in_cache)) { + if (entry_ptr->header.flush_dep_ndirty_children != expected[i].flush_dep_ndirty_chd) { pass = FALSE; HDsprintf(msg, - "%d entry (%d, %d) header flush_dep_ndirty_children actual/expected = %u/%u.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - entry_ptr->header.flush_dep_ndirty_children, - expected[i].flush_dep_ndirty_chd); + "%d entry (%d, %d) header flush_dep_ndirty_children actual/expected = %u/%u.\n", + tag, expected[i].entry_type, expected[i].entry_index, + entry_ptr->header.flush_dep_ndirty_children, expected[i].flush_dep_ndirty_chd); failure_mssg = msg; } /* end if */ - } /* end if */ + } /* end if */ /* Flush dependency flush order */ - if ( pass ) { - if ( expected[i].flush_order >= 0 && entry_ptr->flush_order != (unsigned)expected[i].flush_order ) { + if (pass) { + if (expected[i].flush_order >= 0 && entry_ptr->flush_order != (unsigned)expected[i].flush_order) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) flush_order actual/expected = %u/%d.\n", - tag, - expected[i].entry_type, - expected[i].entry_index, - entry_ptr->flush_order, - expected[i].flush_order); + HDsprintf(msg, "%d entry (%d, %d) flush_order actual/expected = %u/%d.\n", tag, + expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_order, + expected[i].flush_order); failure_mssg = msg; } /* end if */ - } /* end if */ + } /* end if */ i++; } /* while */ @@ -2989,7 +2635,6 @@ verify_entry_status(H5C_t * cache_ptr, } /* verify_entry_status() */ - /*------------------------------------------------------------------------- * Function: verify_unprotected * @@ -3010,37 +2655,33 @@ void verify_unprotected(void) { - int i; - int j; - int protected_count = 0; - int32_t max_index; - test_entry_t * base_addr; + int i; + int j; + int protected_count = 0; + int32_t max_index; + test_entry_t *base_addr; - if ( pass ) { + if (pass) { - for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ ) - { + for (i = 0; i < NUMBER_OF_ENTRY_TYPES; i++) { max_index = max_indices[i]; base_addr = entries[i]; - HDassert( base_addr ); + HDassert(base_addr); - for ( j = 0; j <= max_index; j++ ) - { - HDassert( base_addr[j].header.is_protected == - base_addr[j].is_protected ); + for (j = 0; j <= max_index; j++) { + HDassert(base_addr[j].header.is_protected == base_addr[j].is_protected); - if ( ( base_addr[j].header.is_protected ) || - ( base_addr[j].is_protected ) ) { + if ((base_addr[j].header.is_protected) || (base_addr[j].is_protected)) { protected_count++; } } } - if ( protected_count > 0 ) { + if (protected_count > 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "verify_unprotected() found protected entry(s)."; } } @@ -3049,8 +2690,6 @@ verify_unprotected(void) } /* verify_unprotected() */ - - /*------------------------------------------------------------------------- * Function: expunge_entry() * @@ -3071,46 +2710,44 @@ verify_unprotected(void) */ void -expunge_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx) +expunge_entry(H5F_t *file_ptr, int32_t type, int32_t idx) { - herr_t result; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + herr_t result; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - if ( pass ) { + if (pass) { #ifndef NDEBUG - H5C_t * cache_ptr = file_ptr->shared->cache; + H5C_t *cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr ); + HDassert(cache_ptr); #endif /* NDEBUG */ - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); - HDassert( entry_ptr->cache_ptr == cache_ptr ); - HDassert( ! ( entry_ptr->header.is_protected ) ); - HDassert( ! ( entry_ptr->is_protected ) ); - HDassert( ! ( entry_ptr->header.is_pinned ) ); - HDassert( ! ( entry_ptr->is_pinned ) ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); + HDassert(entry_ptr->cache_ptr == cache_ptr); + HDassert(!(entry_ptr->header.is_protected)); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->header.is_pinned)); + HDassert(!(entry_ptr->is_pinned)); result = H5C_expunge_entry(file_ptr, types[type], entry_ptr->addr, H5C__NO_FLAGS_SET); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "error in H5C_expunge_entry()."; + } + else { - } else { - - entry_ptr->expunged = TRUE; + entry_ptr->expunged = TRUE; } } @@ -3118,7 +2755,6 @@ expunge_entry(H5F_t * file_ptr, } /* expunge_entry() */ - /*------------------------------------------------------------------------- * Function: flush_cache() * @@ -3134,51 +2770,43 @@ expunge_entry(H5F_t * file_ptr, */ void -flush_cache(H5F_t * file_ptr, - hbool_t destroy_entries, - hbool_t dump_stats, - hbool_t dump_detailed_stats) +flush_cache(H5F_t *file_ptr, hbool_t destroy_entries, hbool_t dump_stats, hbool_t dump_detailed_stats) { hbool_t verbose = FALSE; verify_unprotected(); - if(pass) { - H5C_t * cache_ptr; + if (pass) { + H5C_t *cache_ptr; herr_t result = 0; HDassert(file_ptr); cache_ptr = file_ptr->shared->cache; - if(destroy_entries) + if (destroy_entries) result = H5C_flush_cache(file_ptr, H5C__FLUSH_INVALIDATE_FLAG); else result = H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET); - if(dump_stats) + if (dump_stats) H5C_stats(cache_ptr, "test cache", dump_detailed_stats); - if(result < 0) { - pass = FALSE; + if (result < 0) { + pass = FALSE; failure_mssg = "error in H5C_flush_cache()."; } - else if((destroy_entries) && ((cache_ptr->index_len != 0) - || (cache_ptr->index_size != 0) - || (cache_ptr->clean_index_size != 0) - || (cache_ptr->dirty_index_size != 0))) { - - if(verbose) { - HDfprintf(stdout, - "%s: unexpected il/is/cis/dis = %lld/%lld/%lld/%lld.\n", - FUNC, - (long long)(cache_ptr->index_len), - (long long)(cache_ptr->index_size), - (long long)(cache_ptr->clean_index_size), - (long long)(cache_ptr->dirty_index_size)); + else if ((destroy_entries) && + ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || + (cache_ptr->clean_index_size != 0) || (cache_ptr->dirty_index_size != 0))) { + + if (verbose) { + HDfprintf(stdout, "%s: unexpected il/is/cis/dis = %lld/%lld/%lld/%lld.\n", FUNC, + (long long)(cache_ptr->index_len), (long long)(cache_ptr->index_size), + (long long)(cache_ptr->clean_index_size), (long long)(cache_ptr->dirty_index_size)); } - pass = FALSE; + pass = FALSE; failure_mssg = "non zero index len/sizes after H5C_flush_cache() with invalidate."; } } @@ -3187,7 +2815,6 @@ flush_cache(H5F_t * file_ptr, } /* flush_cache() */ - /*------------------------------------------------------------------------- * Function: cork_entry_type() * @@ -3205,8 +2832,8 @@ flush_cache(H5F_t * file_ptr, void cork_entry_type(H5F_t *file_ptr, int32_t type) { - if(pass) { - H5C_t *cache_ptr; + if (pass) { + H5C_t * cache_ptr; haddr_t baddrs; cache_ptr = file_ptr->shared->cache; @@ -3215,15 +2842,14 @@ cork_entry_type(H5F_t *file_ptr, int32_t type) HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); baddrs = base_addrs[type]; - if(H5C_cork(cache_ptr, baddrs, H5C__SET_CORK, NULL) < 0) { - pass = FALSE; + if (H5C_cork(cache_ptr, baddrs, H5C__SET_CORK, NULL) < 0) { + pass = FALSE; failure_mssg = "error in H5C_cork()."; } /* end if */ - } /* end if */ + } /* end if */ } /* cork_entry_type() */ - /*------------------------------------------------------------------------- * Function: uncork_entry_type() * @@ -3241,8 +2867,8 @@ cork_entry_type(H5F_t *file_ptr, int32_t type) void uncork_entry_type(H5F_t *file_ptr, int32_t type) { - if(pass) { - H5C_t *cache_ptr; + if (pass) { + H5C_t * cache_ptr; haddr_t baddrs; cache_ptr = file_ptr->shared->cache; @@ -3251,15 +2877,14 @@ uncork_entry_type(H5F_t *file_ptr, int32_t type) HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); baddrs = base_addrs[type]; - if(H5C_cork(cache_ptr, baddrs, H5C__UNCORK, NULL) < 0) { - pass = FALSE; + if (H5C_cork(cache_ptr, baddrs, H5C__UNCORK, NULL) < 0) { + pass = FALSE; failure_mssg = "error in H5C_cork()."; } /* end if */ - } /* end if */ + } /* end if */ } /* uncork_entry_type() */ - /*------------------------------------------------------------------------- * Function: insert_entry() * @@ -3276,38 +2901,35 @@ uncork_entry_type(H5F_t *file_ptr, int32_t type) */ void -insert_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx, - unsigned int flags) +insert_entry(H5F_t *file_ptr, int32_t type, int32_t idx, unsigned int flags) { - H5C_t * cache_ptr; - herr_t result; - hbool_t insert_pinned; - test_entry_t * base_addr; - test_entry_t * entry_ptr; - haddr_t baddrs; + H5C_t * cache_ptr; + herr_t result; + hbool_t insert_pinned; + test_entry_t *base_addr; + test_entry_t *entry_ptr; + haddr_t baddrs; - if ( pass ) { + if (pass) { cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr ); - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + HDassert(cache_ptr); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - baddrs = base_addrs[type]; + baddrs = base_addrs[type]; - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); - HDassert( !(entry_ptr->is_protected) ); - HDassert( entry_ptr->flush_dep_npar == 0 ); - HDassert( entry_ptr->flush_dep_nchd == 0 ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); + HDassert(!(entry_ptr->is_protected)); + HDassert(entry_ptr->flush_dep_npar == 0); + HDassert(entry_ptr->flush_dep_nchd == 0); - insert_pinned = (hbool_t)((flags & H5C__PIN_ENTRY_FLAG) != 0 ); + insert_pinned = (hbool_t)((flags & H5C__PIN_ENTRY_FLAG) != 0); entry_ptr->is_dirty = TRUE; @@ -3317,13 +2939,10 @@ insert_entry(H5F_t * file_ptr, result = H5C_insert_entry(file_ptr, types[type], entry_ptr->addr, (void *)entry_ptr, flags); - if ( ( result < 0 ) || - ( entry_ptr->header.is_protected ) || - ( entry_ptr->header.type != types[type] ) || - ( entry_ptr->size != entry_ptr->header.size ) || - ( entry_ptr->addr != entry_ptr->header.addr ) ) { + if ((result < 0) || (entry_ptr->header.is_protected) || (entry_ptr->header.type != types[type]) || + (entry_ptr->size != entry_ptr->header.size) || (entry_ptr->addr != entry_ptr->header.addr)) { - pass = FALSE; + pass = FALSE; failure_mssg = "error in H5C_insert()."; #if 0 /* This is useful debugging code. Lets keep it around. */ @@ -3344,17 +2963,17 @@ insert_entry(H5F_t * file_ptr, } /* end if */ HDassert(entry_ptr->cache_ptr == NULL); - entry_ptr->file_ptr = file_ptr; + entry_ptr->file_ptr = file_ptr; entry_ptr->cache_ptr = cache_ptr; - if(insert_pinned) + if (insert_pinned) HDassert(entry_ptr->header.is_pinned); else HDassert(!(entry_ptr->header.is_pinned)); - entry_ptr->is_pinned = insert_pinned; + entry_ptr->is_pinned = insert_pinned; entry_ptr->pinned_from_client = insert_pinned; - if(entry_ptr->header.tag_info && entry_ptr->header.tag_info->corked) + if (entry_ptr->header.tag_info && entry_ptr->header.tag_info->corked) entry_ptr->is_corked = TRUE; HDassert(entry_ptr->header.is_dirty); @@ -3365,7 +2984,6 @@ insert_entry(H5F_t * file_ptr, } /* insert_entry() */ - /*------------------------------------------------------------------------- * Function: mark_entry_dirty() * @@ -3382,58 +3000,51 @@ insert_entry(H5F_t * file_ptr, */ void -mark_entry_dirty(int32_t type, - int32_t idx) +mark_entry_dirty(int32_t type, int32_t idx) { - herr_t result; - test_entry_t * base_addr; - test_entry_t * entry_ptr; - hbool_t was_dirty; + herr_t result; + test_entry_t *base_addr; + test_entry_t *entry_ptr; + hbool_t was_dirty; - if ( pass ) { + if (pass) { - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); - HDassert( entry_ptr->header.is_protected || - entry_ptr->header.is_pinned ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); + HDassert(entry_ptr->header.is_protected || entry_ptr->header.is_pinned); - was_dirty = entry_ptr->is_dirty; - entry_ptr->is_dirty = TRUE; + was_dirty = entry_ptr->is_dirty; + entry_ptr->is_dirty = TRUE; - if(entry_ptr->flush_dep_npar > 0 && !was_dirty) + if (entry_ptr->flush_dep_npar > 0 && !was_dirty) mark_flush_dep_dirty(entry_ptr); result = H5C_mark_entry_dirty((void *)entry_ptr); - if ( ( result < 0 ) || - ( !entry_ptr->header.is_protected && !entry_ptr->header.is_pinned ) || - ( entry_ptr->header.is_protected && !entry_ptr->header.dirtied ) || - ( !entry_ptr->header.is_protected && !entry_ptr->header.is_dirty ) || - ( entry_ptr->header.type != types[type] ) || - ( entry_ptr->size != entry_ptr->header.size ) || - ( entry_ptr->addr != entry_ptr->header.addr ) ) { + if ((result < 0) || (!entry_ptr->header.is_protected && !entry_ptr->header.is_pinned) || + (entry_ptr->header.is_protected && !entry_ptr->header.dirtied) || + (!entry_ptr->header.is_protected && !entry_ptr->header.is_dirty) || + (entry_ptr->header.type != types[type]) || (entry_ptr->size != entry_ptr->header.size) || + (entry_ptr->addr != entry_ptr->header.addr)) { - pass = FALSE; + pass = FALSE; failure_mssg = "error in H5C_mark_entry_dirty()."; - } - HDassert( ((entry_ptr->header).type)->id == type ); - + HDassert(((entry_ptr->header).type)->id == type); } return; } /* mark_entry_dirty() */ - /*------------------------------------------------------------------------- * Function: move_entry() * @@ -3450,96 +3061,90 @@ mark_entry_dirty(int32_t type, */ void -move_entry(H5C_t * cache_ptr, - int32_t type, - int32_t idx, - hbool_t main_addr) +move_entry(H5C_t *cache_ptr, int32_t type, int32_t idx, hbool_t main_addr) { - herr_t result; - hbool_t done = TRUE; /* will set to FALSE if we have work to do */ - haddr_t old_addr = HADDR_UNDEF; - haddr_t new_addr = HADDR_UNDEF; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + herr_t result; + hbool_t done = TRUE; /* will set to FALSE if we have work to do */ + haddr_t old_addr = HADDR_UNDEF; + haddr_t new_addr = HADDR_UNDEF; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - if ( pass ) { + if (pass) { - HDassert( cache_ptr ); - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + HDassert(cache_ptr); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); - HDassert( entry_ptr->cache_ptr == cache_ptr ); - HDassert( !entry_ptr->is_read_only ); - HDassert( !entry_ptr->header.is_read_only ); - + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); + HDassert(entry_ptr->cache_ptr == cache_ptr); + HDassert(!entry_ptr->is_read_only); + HDassert(!entry_ptr->header.is_read_only); - if ( entry_ptr->at_main_addr && !main_addr ) { + if (entry_ptr->at_main_addr && !main_addr) { /* move to alt addr */ - HDassert( entry_ptr->addr == entry_ptr->main_addr ); + HDassert(entry_ptr->addr == entry_ptr->main_addr); - done = FALSE; + done = FALSE; old_addr = entry_ptr->addr; new_addr = entry_ptr->alt_addr; - - } else if ( !(entry_ptr->at_main_addr) && main_addr ) { + } + else if (!(entry_ptr->at_main_addr) && main_addr) { /* move to main addr */ - HDassert( entry_ptr->addr == entry_ptr->alt_addr ); + HDassert(entry_ptr->addr == entry_ptr->alt_addr); - done = FALSE; + done = FALSE; old_addr = entry_ptr->addr; new_addr = entry_ptr->main_addr; } - if ( ! done ) { + if (!done) { hbool_t was_dirty = entry_ptr->is_dirty; entry_ptr->is_dirty = TRUE; - if(entry_ptr->flush_dep_npar > 0 && !was_dirty) + if (entry_ptr->flush_dep_npar > 0 && !was_dirty) mark_flush_dep_dirty(entry_ptr); entry_ptr->action = TEST_ENTRY_ACTION_MOVE; - result = H5C_move_entry(cache_ptr, types[type], old_addr, new_addr); + result = H5C_move_entry(cache_ptr, types[type], old_addr, new_addr); entry_ptr->action = TEST_ENTRY_ACTION_NUL; } - if ( ! done ) { + if (!done) { - if ( ( result < 0 ) || - ( ( ! ( entry_ptr->header.destroy_in_progress ) ) && - ( entry_ptr->header.addr != new_addr ) ) ) { + if ((result < 0) || + ((!(entry_ptr->header.destroy_in_progress)) && (entry_ptr->header.addr != new_addr))) { - pass = FALSE; + pass = FALSE; failure_mssg = "error in H5C_move_entry()."; + } + else { - } else { - - entry_ptr->addr = new_addr; + entry_ptr->addr = new_addr; entry_ptr->at_main_addr = main_addr; } } - HDassert( ((entry_ptr->header).type)->id == type ); + HDassert(((entry_ptr->header).type)->id == type); - HDassert( entry_ptr->header.is_dirty ); - HDassert( entry_ptr->is_dirty ); + HDassert(entry_ptr->header.is_dirty); + HDassert(entry_ptr->is_dirty); } return; } /* move_entry() */ - /*------------------------------------------------------------------------- * Function: protect_entry() * @@ -3555,15 +3160,15 @@ move_entry(H5C_t * cache_ptr, *------------------------------------------------------------------------- */ void -protect_entry(H5F_t * file_ptr, int32_t type, int32_t idx) +protect_entry(H5F_t *file_ptr, int32_t type, int32_t idx) { - H5C_t * cache_ptr; - test_entry_t * base_addr; - test_entry_t * entry_ptr; - haddr_t baddrs; - H5C_cache_entry_t * cache_entry_ptr; + H5C_t * cache_ptr; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + haddr_t baddrs; + H5C_cache_entry_t *cache_entry_ptr; - if(pass) { + if (pass) { cache_ptr = file_ptr->shared->cache; HDassert(cache_ptr); @@ -3572,7 +3177,7 @@ protect_entry(H5F_t * file_ptr, int32_t type, int32_t idx) base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - baddrs = base_addrs[type]; + baddrs = base_addrs[type]; HDassert(entry_ptr->index == idx); HDassert(entry_ptr->type == type); @@ -3583,15 +3188,12 @@ protect_entry(H5F_t * file_ptr, int32_t type, int32_t idx) /* Use to cork entries for the object */ H5AC_tag(baddrs, NULL); - cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, - types[type], entry_ptr->addr, &entry_ptr->addr, - H5C__NO_FLAGS_SET); + cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, types[type], entry_ptr->addr, + &entry_ptr->addr, H5C__NO_FLAGS_SET); - if ( ( cache_entry_ptr != (void *)entry_ptr ) || - ( !(entry_ptr->header.is_protected) ) || - ( entry_ptr->header.type != types[type] ) || - ( entry_ptr->size != entry_ptr->header.size ) || - ( entry_ptr->addr != entry_ptr->header.addr ) ) { + if ((cache_entry_ptr != (void *)entry_ptr) || (!(entry_ptr->header.is_protected)) || + (entry_ptr->header.type != types[type]) || (entry_ptr->size != entry_ptr->header.size) || + (entry_ptr->addr != entry_ptr->header.addr)) { #if 0 /* I've written the following debugging code several times @@ -3619,30 +3221,28 @@ protect_entry(H5F_t * file_ptr, int32_t type, int32_t idx) entry_ptr->verify_ct, entry_ptr->max_verify_ct); H5Eprint2(H5E_DEFAULT, stdout); #endif - pass = FALSE; + pass = FALSE; failure_mssg = "error in H5C_protect()."; } /* end if */ else { - HDassert( ( entry_ptr->cache_ptr == NULL ) || - ( entry_ptr->cache_ptr == cache_ptr ) ); + HDassert((entry_ptr->cache_ptr == NULL) || (entry_ptr->cache_ptr == cache_ptr)); - entry_ptr->cache_ptr = cache_ptr; - entry_ptr->file_ptr = file_ptr; + entry_ptr->cache_ptr = cache_ptr; + entry_ptr->file_ptr = file_ptr; entry_ptr->is_protected = TRUE; } /* end else */ - if(entry_ptr->header.tag_info && entry_ptr->header.tag_info->corked) - entry_ptr->is_corked = TRUE; + if (entry_ptr->header.tag_info && entry_ptr->header.tag_info->corked) + entry_ptr->is_corked = TRUE; HDassert(((entry_ptr->header).type)->id == type); } /* end if */ } /* protect_entry() */ - /*------------------------------------------------------------------------- * Function: protect_entry_ro() * @@ -3660,67 +3260,59 @@ protect_entry(H5F_t * file_ptr, int32_t type, int32_t idx) */ void -protect_entry_ro(H5F_t * file_ptr, - int32_t type, - int32_t idx) +protect_entry_ro(H5F_t *file_ptr, int32_t type, int32_t idx) { - H5C_t *cache_ptr; - test_entry_t *base_addr; - test_entry_t *entry_ptr; - H5C_cache_entry_t * cache_entry_ptr; + H5C_t * cache_ptr; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + H5C_cache_entry_t *cache_entry_ptr; - if ( pass ) { + if (pass) { cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr ); - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + HDassert(cache_ptr); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); - HDassert( ( ! ( entry_ptr->is_protected ) ) || - ( ( entry_ptr->is_read_only ) && - ( entry_ptr->ro_ref_count > 0 ) ) ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); + HDassert((!(entry_ptr->is_protected)) || + ((entry_ptr->is_read_only) && (entry_ptr->ro_ref_count > 0))); - cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, - types[type], entry_ptr->addr, &entry_ptr->addr, H5C__READ_ONLY_FLAG); + cache_entry_ptr = (H5C_cache_entry_t *)H5C_protect(file_ptr, types[type], entry_ptr->addr, + &entry_ptr->addr, H5C__READ_ONLY_FLAG); - if ( ( cache_entry_ptr != (void *)entry_ptr ) || - ( !(entry_ptr->header.is_protected) ) || - ( !(entry_ptr->header.is_read_only) ) || - ( entry_ptr->header.ro_ref_count <= 0 ) || - ( entry_ptr->header.type != types[type] ) || - ( entry_ptr->size != entry_ptr->header.size ) || - ( entry_ptr->addr != entry_ptr->header.addr ) ) { + if ((cache_entry_ptr != (void *)entry_ptr) || (!(entry_ptr->header.is_protected)) || + (!(entry_ptr->header.is_read_only)) || (entry_ptr->header.ro_ref_count <= 0) || + (entry_ptr->header.type != types[type]) || (entry_ptr->size != entry_ptr->header.size) || + (entry_ptr->addr != entry_ptr->header.addr)) { - pass = FALSE; + pass = FALSE; failure_mssg = "error in read only H5C_protect()."; + } + else { - } else { - - HDassert( ( entry_ptr->cache_ptr == NULL ) || - ( entry_ptr->cache_ptr == cache_ptr ) ); + HDassert((entry_ptr->cache_ptr == NULL) || (entry_ptr->cache_ptr == cache_ptr)); - entry_ptr->cache_ptr = cache_ptr; - entry_ptr->file_ptr = file_ptr; + entry_ptr->cache_ptr = cache_ptr; + entry_ptr->file_ptr = file_ptr; entry_ptr->is_protected = TRUE; - entry_ptr->is_read_only = TRUE; - entry_ptr->ro_ref_count++; + entry_ptr->is_read_only = TRUE; + entry_ptr->ro_ref_count++; } - HDassert( ((entry_ptr->header).type)->id == type ); + HDassert(((entry_ptr->header).type)->id == type); } return; } /* protect_entry_ro() */ - /*------------------------------------------------------------------------- * Function: pin_entry() * @@ -3737,51 +3329,48 @@ protect_entry_ro(H5F_t * file_ptr, */ void -pin_entry(int32_t type, - int32_t idx) +pin_entry(int32_t type, int32_t idx) { - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); - if ( pass ) { - test_entry_t * base_addr; - test_entry_t * entry_ptr; - herr_t result; + if (pass) { + test_entry_t *base_addr; + test_entry_t *entry_ptr; + herr_t result; base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); - HDassert( entry_ptr->is_protected ); - HDassert( !(entry_ptr->pinned_from_client) ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); + HDassert(entry_ptr->is_protected); + HDassert(!(entry_ptr->pinned_from_client)); - result = H5C_pin_protected_entry((void *)entry_ptr); + result = H5C_pin_protected_entry((void *)entry_ptr); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5C_pin_protected_entry() reports failure."; + } + else if (!(entry_ptr->header.is_pinned)) { - } else if ( ! ( entry_ptr->header.is_pinned ) ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "entry not pinned when it should be."; - - } else { + } + else { entry_ptr->pinned_from_client = TRUE; - entry_ptr->is_pinned = TRUE; - - } + entry_ptr->is_pinned = TRUE; + } } /* end if */ return; } /* pin_entry() */ - /*------------------------------------------------------------------------- * Function: unpin_entry() * @@ -3798,55 +3387,49 @@ pin_entry(int32_t type, */ void -unpin_entry(int32_t type, - int32_t idx) +unpin_entry(int32_t type, int32_t idx) { - herr_t result; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + herr_t result; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - if ( pass ) { - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + if (pass) { + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); - HDassert( entry_ptr->header.is_pinned ); - HDassert( entry_ptr->header.pinned_from_client ); - HDassert( entry_ptr->is_pinned ); - HDassert( entry_ptr->pinned_from_client ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); + HDassert(entry_ptr->header.is_pinned); + HDassert(entry_ptr->header.pinned_from_client); + HDassert(entry_ptr->is_pinned); + HDassert(entry_ptr->pinned_from_client); result = H5C_unpin_entry(entry_ptr); - if ( ( result < 0 ) || - ( entry_ptr->header.pinned_from_client ) || - ( entry_ptr->header.is_pinned && !entry_ptr->header.pinned_from_cache ) || - ( entry_ptr->header.type != types[type] ) || - ( entry_ptr->size != entry_ptr->header.size ) || - ( entry_ptr->addr != entry_ptr->header.addr ) ) { + if ((result < 0) || (entry_ptr->header.pinned_from_client) || + (entry_ptr->header.is_pinned && !entry_ptr->header.pinned_from_cache) || + (entry_ptr->header.type != types[type]) || (entry_ptr->size != entry_ptr->header.size) || + (entry_ptr->addr != entry_ptr->header.addr)) { - pass = FALSE; + pass = FALSE; failure_mssg = "error in H5C_unpin()."; - } entry_ptr->pinned_from_client = FALSE; - entry_ptr->is_pinned = entry_ptr->pinned_from_cache; - - HDassert( ((entry_ptr->header).type)->id == type ); + entry_ptr->is_pinned = entry_ptr->pinned_from_cache; + HDassert(((entry_ptr->header).type)->id == type); } return; } /* unpin_entry() */ - /*------------------------------------------------------------------------- * Function: unprotect_entry() * @@ -3863,112 +3446,101 @@ unpin_entry(int32_t type, */ void -unprotect_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx, - unsigned int flags) +unprotect_entry(H5F_t *file_ptr, int32_t type, int32_t idx, unsigned int flags) { - herr_t result; - hbool_t pin_flag_set; - hbool_t unpin_flag_set; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + herr_t result; + hbool_t pin_flag_set; + hbool_t unpin_flag_set; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - if ( pass ) { - HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + if (pass) { + HDassert((0 <= type) && (type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= idx) && (idx <= max_indices[type])); base_addr = entries[type]; entry_ptr = &(base_addr[idx]); - HDassert( entry_ptr->index == idx ); - HDassert( entry_ptr->type == type ); - HDassert( entry_ptr == entry_ptr->self ); - HDassert( entry_ptr->header.is_protected ); - HDassert( entry_ptr->is_protected ); + HDassert(entry_ptr->index == idx); + HDassert(entry_ptr->type == type); + HDassert(entry_ptr == entry_ptr->self); + HDassert(entry_ptr->header.is_protected); + HDassert(entry_ptr->is_protected); - pin_flag_set = (hbool_t)((flags & H5C__PIN_ENTRY_FLAG) != 0); - unpin_flag_set = (hbool_t)((flags & H5C__UNPIN_ENTRY_FLAG) != 0); + pin_flag_set = (hbool_t)((flags & H5C__PIN_ENTRY_FLAG) != 0); + unpin_flag_set = (hbool_t)((flags & H5C__UNPIN_ENTRY_FLAG) != 0); - HDassert ( ! ( pin_flag_set && unpin_flag_set ) ); - HDassert ( ( ! pin_flag_set ) || ( ! (entry_ptr->is_pinned) ) ); - HDassert ( ( ! unpin_flag_set ) || ( entry_ptr->is_pinned ) ); + HDassert(!(pin_flag_set && unpin_flag_set)); + HDassert((!pin_flag_set) || (!(entry_ptr->is_pinned))); + HDassert((!unpin_flag_set) || (entry_ptr->is_pinned)); - if(flags & H5C__DIRTIED_FLAG) { + if (flags & H5C__DIRTIED_FLAG) { hbool_t was_dirty = entry_ptr->is_dirty; entry_ptr->is_dirty = TRUE; - if(entry_ptr->flush_dep_npar > 0 && !was_dirty) + if (entry_ptr->flush_dep_npar > 0 && !was_dirty) mark_flush_dep_dirty(entry_ptr); } /* end if */ result = H5C_unprotect(file_ptr, entry_ptr->addr, (void *)entry_ptr, flags); - if ( ( result < 0 ) || - ( ( entry_ptr->header.is_protected ) && - ( ( ! ( entry_ptr->is_read_only ) ) || - ( entry_ptr->ro_ref_count <= 0 ) ) ) || - ( entry_ptr->header.type != types[type] ) || - ( entry_ptr->size != entry_ptr->header.size ) || - ( entry_ptr->addr != entry_ptr->header.addr ) ) { + if ((result < 0) || + ((entry_ptr->header.is_protected) && + ((!(entry_ptr->is_read_only)) || (entry_ptr->ro_ref_count <= 0))) || + (entry_ptr->header.type != types[type]) || (entry_ptr->size != entry_ptr->header.size) || + (entry_ptr->addr != entry_ptr->header.addr)) { - pass = FALSE; + pass = FALSE; failure_mssg = "error in H5C_unprotect()."; - } - else - { - if ( entry_ptr->ro_ref_count > 1 ) { - - entry_ptr->ro_ref_count--; - - } else if ( entry_ptr->ro_ref_count == 1 ) { - - entry_ptr->is_protected = FALSE; - entry_ptr->is_read_only = FALSE; - entry_ptr->ro_ref_count = 0; - - } else { - - entry_ptr->is_protected = FALSE; + else { + if (entry_ptr->ro_ref_count > 1) { - } + entry_ptr->ro_ref_count--; + } + else if (entry_ptr->ro_ref_count == 1) { - if ( pin_flag_set ) { + entry_ptr->is_protected = FALSE; + entry_ptr->is_read_only = FALSE; + entry_ptr->ro_ref_count = 0; + } + else { - HDassert(entry_ptr->header.is_pinned); - entry_ptr->pinned_from_client = TRUE; - entry_ptr->is_pinned = TRUE; + entry_ptr->is_protected = FALSE; + } - } else if ( unpin_flag_set ) { + if (pin_flag_set) { - HDassert(entry_ptr->header.is_pinned == entry_ptr->header.pinned_from_cache); - entry_ptr->pinned_from_client = FALSE; - entry_ptr->is_pinned = entry_ptr->pinned_from_cache; + HDassert(entry_ptr->header.is_pinned); + entry_ptr->pinned_from_client = TRUE; + entry_ptr->is_pinned = TRUE; + } + else if (unpin_flag_set) { + HDassert(entry_ptr->header.is_pinned == entry_ptr->header.pinned_from_cache); + entry_ptr->pinned_from_client = FALSE; + entry_ptr->is_pinned = entry_ptr->pinned_from_cache; } } - HDassert( ((entry_ptr->header).type)->id == type ); + HDassert(((entry_ptr->header).type)->id == type); - if ( ( flags & H5C__DIRTIED_FLAG ) != 0 - && ( (flags & H5C__DELETED_FLAG) == 0 ) ) { + if ((flags & H5C__DIRTIED_FLAG) != 0 && ((flags & H5C__DELETED_FLAG) == 0)) { - HDassert( entry_ptr->header.is_dirty ); - HDassert( entry_ptr->is_dirty ); + HDassert(entry_ptr->header.is_dirty); + HDassert(entry_ptr->is_dirty); } - HDassert( entry_ptr->header.is_protected == entry_ptr->is_protected ); - HDassert( entry_ptr->header.is_read_only == entry_ptr->is_read_only ); - HDassert( entry_ptr->header.ro_ref_count == entry_ptr->ro_ref_count ); + HDassert(entry_ptr->header.is_protected == entry_ptr->is_protected); + HDassert(entry_ptr->header.is_read_only == entry_ptr->is_read_only); + HDassert(entry_ptr->header.ro_ref_count == entry_ptr->ro_ref_count); } return; } /* unprotect_entry() */ - /*------------------------------------------------------------------------- * Function: row_major_scan_forward() * @@ -3984,263 +3556,243 @@ unprotect_entry(H5F_t * file_ptr, *------------------------------------------------------------------------- */ void -row_major_scan_forward(H5F_t * file_ptr, - int32_t max_index, - int32_t lag, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, - hbool_t do_moves, - hbool_t move_to_main_addr, - hbool_t do_destroys, - hbool_t do_mult_ro_protects, - int dirty_destroys, - int dirty_unprotects) +row_major_scan_forward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t verbose, hbool_t reset_stats, + hbool_t display_stats, hbool_t display_detailed_stats, hbool_t do_inserts, + hbool_t do_moves, hbool_t move_to_main_addr, hbool_t do_destroys, + hbool_t do_mult_ro_protects, int dirty_destroys, int dirty_unprotects) { H5C_t * cache_ptr = NULL; - int32_t type = 0; + int32_t type = 0; int32_t idx; int32_t local_max_index; - if(verbose) + if (verbose) HDfprintf(stdout, "%s(): entering.\n", FUNC); - if(pass) { + if (pass) { cache_ptr = file_ptr->shared->cache; HDassert(cache_ptr != NULL); HDassert(lag >= 10); - if(reset_stats) + if (reset_stats) H5C_stats__reset(cache_ptr); } /* end if */ - while(pass && type < NUMBER_OF_ENTRY_TYPES) { + while (pass && type < NUMBER_OF_ENTRY_TYPES) { idx = -lag; local_max_index = MIN(max_index, max_indices[type]); - while(pass && idx <= (local_max_index + lag)) { + while (pass && idx <= (local_max_index + lag)) { int32_t tmp_idx; - if(verbose) + if (verbose) HDfprintf(stdout, "%d:%d: ", type, idx); tmp_idx = idx + lag; - if(pass && do_inserts && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && - ((tmp_idx % 2) == 0 ) && !entry_in_cache(cache_ptr, type, tmp_idx)) { + if (pass && do_inserts && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && + ((tmp_idx % 2) == 0) && !entry_in_cache(cache_ptr, type, tmp_idx)) { - if(verbose) + if (verbose) HDfprintf(stdout, "1(i, %d, %d) ", type, tmp_idx); insert_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ tmp_idx--; - if(pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && - (tmp_idx % 3) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && (tmp_idx % 3) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "2(p, %d, %d) ", type, tmp_idx); protect_entry(file_ptr, type, tmp_idx); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ tmp_idx--; - if(pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && - (tmp_idx % 3) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && (tmp_idx % 3) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "3(u, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ /* (don't decrement tmp_idx) */ - if(pass && do_moves && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && - (tmp_idx % 3) == 0) { + if (pass && do_moves && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && (tmp_idx % 3) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "4(r, %d, %d, %d) ", type, tmp_idx, (int)move_to_main_addr); move_entry(cache_ptr, type, tmp_idx, move_to_main_addr); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ tmp_idx--; - if(pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && - (tmp_idx % 5) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && (tmp_idx % 5) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "5(p, %d, %d) ", type, tmp_idx); protect_entry(file_ptr, type, tmp_idx); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ tmp_idx -= 2; - if(pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && - (tmp_idx % 5) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && (tmp_idx % 5) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "6(u, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ - if(do_mult_ro_protects) { + if (do_mult_ro_protects) { /* (don't decrement tmp_idx) */ - if(pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && - (tmp_idx % 9) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 9) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "7(p-ro, %d, %d) ", type, tmp_idx); - protect_entry_ro(file_ptr, type, tmp_idx); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); - } /* end if */ + protect_entry_ro(file_ptr, type, tmp_idx); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + } /* end if */ tmp_idx--; - if(pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && - (tmp_idx % 11) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 11) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "8(p-ro, %d, %d) ", type, tmp_idx); - protect_entry_ro(file_ptr, type, tmp_idx); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); - } /* end if */ + protect_entry_ro(file_ptr, type, tmp_idx); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + } /* end if */ tmp_idx--; - if(pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && - (tmp_idx % 13) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 13) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "9(p-ro, %d, %d) ", type, tmp_idx); - protect_entry_ro(file_ptr, type, tmp_idx); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); - } /* end if */ + protect_entry_ro(file_ptr, type, tmp_idx); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + } /* end if */ /* (don't decrement tmp_idx) */ - if(pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && - (tmp_idx % 9) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 9) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "10(u-ro, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); - } /* end if */ + unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + } /* end if */ tmp_idx--; - if(pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && - (tmp_idx % 11) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 11) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "11(u-ro, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); - } /* end if */ + unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + } /* end if */ tmp_idx--; - if(pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && - (tmp_idx % 13) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 13) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "12(u-ro, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); - } /* end if */ - } /* if ( do_mult_ro_protects ) */ + unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + } /* end if */ + } /* if ( do_mult_ro_protects ) */ - if(pass && (idx >= 0) && (idx <= local_max_index)) { - if(verbose) + if (pass && (idx >= 0) && (idx <= local_max_index)) { + if (verbose) HDfprintf(stdout, "13(p, %d, %d) ", type, idx); protect_entry(file_ptr, type, idx); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ tmp_idx = idx - lag + 2; - if(pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && - (tmp_idx % 7) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && (tmp_idx % 7) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "14(u, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ tmp_idx--; - if(pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && - (tmp_idx % 7) == 0) { + if (pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && (tmp_idx % 7) == 0) { - if(verbose) + if (verbose) HDfprintf(stdout, "15(p, %d, %d) ", type, tmp_idx); protect_entry(file_ptr, type, tmp_idx); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ - if(do_destroys) { + if (do_destroys) { tmp_idx = idx - lag; - if(pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index)) { - switch(tmp_idx % 4) { + if (pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index)) { + switch (tmp_idx % 4) { case 0: /* we just did an insert */ - if(verbose) + if (verbose) HDfprintf(stdout, "16(u, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); break; case 1: - if((entries[type])[tmp_idx].is_dirty) { - if(verbose) + if ((entries[type])[tmp_idx].is_dirty) { + if (verbose) HDfprintf(stdout, "17(u, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ else { - if(verbose) + if (verbose) HDfprintf(stdout, "18(u, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + unprotect_entry(file_ptr, type, tmp_idx, + (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end else */ break; case 2: /* we just did an insert */ - if(verbose) + if (verbose) HDfprintf(stdout, "19(u-del, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__DELETED_FLAG); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); break; case 3: - if((entries[type])[tmp_idx].is_dirty) { - if(verbose) + if ((entries[type])[tmp_idx].is_dirty) { + if (verbose) HDfprintf(stdout, "20(u-del, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__DELETED_FLAG); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ else { - if(verbose) + if (verbose) HDfprintf(stdout, "21(u-del, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, (dirty_destroys ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET) | H5C__DELETED_FLAG); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + unprotect_entry(file_ptr, type, tmp_idx, + (dirty_destroys ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET) | + H5C__DELETED_FLAG); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end else */ break; @@ -4248,20 +3800,21 @@ row_major_scan_forward(H5F_t * file_ptr, HDassert(0); /* this can't happen... */ break; } /* end switch */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { tmp_idx = idx - lag; - if(pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index)) { - if(verbose) + if (pass && (tmp_idx >= 0) && (tmp_idx <= local_max_index)) { + if (verbose) HDfprintf(stdout, "22(u, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); - HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); + unprotect_entry(file_ptr, type, tmp_idx, + (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); + HDassert(cache_ptr->slist_size == cache_ptr->dirty_index_size); } /* end if */ - } /* end elsef */ + } /* end elsef */ - if(verbose) + if (verbose) HDfprintf(stdout, "\n"); idx++; @@ -4270,12 +3823,11 @@ row_major_scan_forward(H5F_t * file_ptr, type++; } /* end while */ - if(pass && display_stats) + if (pass && display_stats) H5C_stats(cache_ptr, "test cache", display_detailed_stats); } /* row_major_scan_forward() */ - /*------------------------------------------------------------------------- * Function: hl_row_major_scan_forward() * @@ -4292,53 +3844,44 @@ row_major_scan_forward(H5F_t * file_ptr, */ void -hl_row_major_scan_forward(H5F_t * file_ptr, - int32_t max_index, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts) +hl_row_major_scan_forward(H5F_t *file_ptr, int32_t max_index, hbool_t verbose, hbool_t reset_stats, + hbool_t display_stats, hbool_t display_detailed_stats, hbool_t do_inserts) { H5C_t * cache_ptr = NULL; - int32_t type = 0; + int32_t type = 0; int32_t idx; int32_t i; int32_t lag = 100; int32_t local_max_index; - if ( verbose ) + if (verbose) HDfprintf(stdout, "%s(): entering.\n", FUNC); - if ( pass ) { + if (pass) { cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr != NULL ); - HDassert( lag > 5 ); - HDassert( max_index >= 200 ); - HDassert( max_index <= MAX_ENTRIES ); + HDassert(cache_ptr != NULL); + HDassert(lag > 5); + HDassert(max_index >= 200); + HDassert(max_index <= MAX_ENTRIES); - if ( reset_stats ) { + if (reset_stats) { H5C_stats__reset(cache_ptr); } } - while ( ( pass ) && ( type < NUMBER_OF_ENTRY_TYPES ) ) - { + while ((pass) && (type < NUMBER_OF_ENTRY_TYPES)) { idx = -lag; local_max_index = MIN(max_index, max_indices[type]); - while ( ( pass ) && ( idx <= (local_max_index + lag) ) ) - { - if ( ( pass ) && ( do_inserts ) && ( (idx + lag) >= 0 ) && - ( (idx + lag) <= max_indices[type] ) && - ( ((idx + lag) % 2) == 0 ) && - ( ! entry_in_cache(cache_ptr, type, (idx + lag)) ) ) { + while ((pass) && (idx <= (local_max_index + lag))) { + if ((pass) && (do_inserts) && ((idx + lag) >= 0) && ((idx + lag) <= max_indices[type]) && + (((idx + lag) % 2) == 0) && (!entry_in_cache(cache_ptr, type, (idx + lag)))) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(i, %d, %d) ", type, (idx + lag)); insert_entry(file_ptr, type, (idx + lag), H5C__NO_FLAGS_SET); @@ -4346,16 +3889,15 @@ hl_row_major_scan_forward(H5F_t * file_ptr, i = idx; - while ( ( pass ) && ( i >= idx - lag ) && ( i >= 0 ) ) - { - if ( ( pass ) && ( i >= 0 ) && ( i <= local_max_index ) ) { + while ((pass) && (i >= idx - lag) && (i >= 0)) { + if ((pass) && (i >= 0) && (i <= local_max_index)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, i); protect_entry(file_ptr, type, i); - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, i); unprotect_entry(file_ptr, type, i, H5C__NO_FLAGS_SET); @@ -4363,7 +3905,7 @@ hl_row_major_scan_forward(H5F_t * file_ptr, i--; } - if ( verbose ) + if (verbose) HDfprintf(stdout, "\n"); idx++; @@ -4371,7 +3913,7 @@ hl_row_major_scan_forward(H5F_t * file_ptr, type++; } - if ( ( pass ) && ( display_stats ) ) { + if ((pass) && (display_stats)) { H5C_stats(cache_ptr, "test cache", display_detailed_stats); } @@ -4380,7 +3922,6 @@ hl_row_major_scan_forward(H5F_t * file_ptr, } /* hl_row_major_scan_forward() */ - /*------------------------------------------------------------------------- * Function: row_major_scan_backward() * @@ -4397,235 +3938,193 @@ hl_row_major_scan_forward(H5F_t * file_ptr, */ void -row_major_scan_backward(H5F_t * file_ptr, - int32_t max_index, - int32_t lag, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, - hbool_t do_moves, - hbool_t move_to_main_addr, - hbool_t do_destroys, - hbool_t do_mult_ro_protects, - int dirty_destroys, - int dirty_unprotects) +row_major_scan_backward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t verbose, hbool_t reset_stats, + hbool_t display_stats, hbool_t display_detailed_stats, hbool_t do_inserts, + hbool_t do_moves, hbool_t move_to_main_addr, hbool_t do_destroys, + hbool_t do_mult_ro_protects, int dirty_destroys, int dirty_unprotects) { H5C_t * cache_ptr = NULL; - int32_t type = NUMBER_OF_ENTRY_TYPES - 1; + int32_t type = NUMBER_OF_ENTRY_TYPES - 1; int32_t idx; int32_t local_max_index; - if ( verbose ) + if (verbose) HDfprintf(stdout, "%s(): Entering.\n", FUNC); - if ( pass ) { + if (pass) { cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr != NULL ); - HDassert( lag >= 10 ); + HDassert(cache_ptr != NULL); + HDassert(lag >= 10); - if ( reset_stats ) { + if (reset_stats) { H5C_stats__reset(cache_ptr); } } - while ( ( pass ) && ( type >= 0 ) ) - { + while ((pass) && (type >= 0)) { local_max_index = MIN(max_index, max_indices[type]); idx = local_max_index + lag; - while ( ( pass ) && ( idx >= -lag ) ) - { + while ((pass) && (idx >= -lag)) { int32_t tmp_idx; tmp_idx = idx - lag; - if ( ( pass ) && ( do_inserts ) && ( tmp_idx >= 0 ) && - ( tmp_idx <= local_max_index ) && - ( (tmp_idx % 2) == 1 ) && - ( ! entry_in_cache(cache_ptr, type, tmp_idx) ) ) { + if ((pass) && (do_inserts) && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && + ((tmp_idx % 2) == 1) && (!entry_in_cache(cache_ptr, type, tmp_idx))) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(i, %d, %d) ", type, tmp_idx); insert_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); } tmp_idx++; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx <= local_max_index ) && - ( ( tmp_idx % 3 ) == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && ((tmp_idx % 3) == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, tmp_idx); protect_entry(file_ptr, type, tmp_idx); } tmp_idx++; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx <= local_max_index ) && - ( ( tmp_idx % 3 ) == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && ((tmp_idx % 3) == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); } /* (don't increment tmp_idx) */ - if ( ( pass ) && ( do_moves ) && ( tmp_idx >= 0 ) && - ( tmp_idx <= local_max_index ) && - ( ( tmp_idx % 3 ) == 0 ) ) { + if ((pass) && (do_moves) && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && + ((tmp_idx % 3) == 0)) { - if ( verbose ) - HDfprintf(stdout, "(r, %d, %d, %d) ", - type, tmp_idx, (int)move_to_main_addr); + if (verbose) + HDfprintf(stdout, "(r, %d, %d, %d) ", type, tmp_idx, (int)move_to_main_addr); move_entry(cache_ptr, type, tmp_idx, move_to_main_addr); } tmp_idx++; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx <= local_max_index ) && - ( ( tmp_idx % 5 ) == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && ((tmp_idx % 5) == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, tmp_idx); protect_entry(file_ptr, type, (idx - lag + 3)); } tmp_idx += 2; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx <= local_max_index ) && - ( ( tmp_idx % 5 ) == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && ((tmp_idx % 5) == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); } /* (don't increment tmp_idx) */ - if ( do_mult_ro_protects ) - { - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx < local_max_index ) && - ( tmp_idx % 9 == 0 ) ) { + if (do_mult_ro_protects) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 9 == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p-ro, %d, %d) ", type, tmp_idx); - protect_entry_ro(file_ptr, type, tmp_idx); - } + protect_entry_ro(file_ptr, type, tmp_idx); + } tmp_idx++; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx < local_max_index ) && - ( tmp_idx % 11 == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 11 == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p-ro, %d, %d) ", type, tmp_idx); - protect_entry_ro(file_ptr, type, tmp_idx); - } + protect_entry_ro(file_ptr, type, tmp_idx); + } tmp_idx++; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx < local_max_index ) && - ( tmp_idx % 13 == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 13 == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p-ro, %d, %d) ", type, tmp_idx); - protect_entry_ro(file_ptr, type, tmp_idx); - } + protect_entry_ro(file_ptr, type, tmp_idx); + } /* (don't increment tmp_idx) */ - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx < local_max_index ) && - ( tmp_idx % 9 == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 9 == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u-ro, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - } + unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); + } tmp_idx++; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx < local_max_index ) && - ( tmp_idx % 11 == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 11 == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u-ro, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - } + unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); + } tmp_idx++; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx < local_max_index ) && - ( tmp_idx % 13 == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx < local_max_index) && (tmp_idx % 13 == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u-ro, %d, %d) ", type, tmp_idx); - unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); - } - } /* if ( do_mult_ro_protects ) */ + unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); + } + } /* if ( do_mult_ro_protects ) */ - if ( ( pass ) && ( idx >= 0 ) && ( idx <= local_max_index ) ) { + if ((pass) && (idx >= 0) && (idx <= local_max_index)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, idx); protect_entry(file_ptr, type, idx); } tmp_idx = idx + lag - 2; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx <= local_max_index ) && - ( ( tmp_idx % 7 ) == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && ((tmp_idx % 7) == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, tmp_idx); unprotect_entry(file_ptr, type, tmp_idx, H5C__NO_FLAGS_SET); } tmp_idx++; - if ( ( pass ) && ( tmp_idx >= 0 ) && - ( tmp_idx <= local_max_index ) && - ( ( tmp_idx % 7 ) == 0 ) ) { + if ((pass) && (tmp_idx >= 0) && (tmp_idx <= local_max_index) && ((tmp_idx % 7) == 0)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, tmp_idx); protect_entry(file_ptr, type, tmp_idx); } + if (do_destroys) { - if ( do_destroys ) { + if ((pass) && ((idx + lag) >= 0) && ((idx + lag) <= local_max_index)) { - if ( ( pass ) && ( (idx + lag) >= 0 ) && - ( ( idx + lag) <= local_max_index ) ) { - - switch ( (idx + lag) % 4 ) { + switch ((idx + lag) % 4) { case 0: - if ( (entries[type])[idx+lag].is_dirty ) { + if ((entries[type])[idx + lag].is_dirty) { unprotect_entry(file_ptr, type, idx + lag, H5C__NO_FLAGS_SET); - } else { + } + else { unprotect_entry(file_ptr, type, idx + lag, - (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); + (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); } break; @@ -4634,14 +4133,15 @@ row_major_scan_backward(H5F_t * file_ptr, break; case 2: - if ( (entries[type])[idx + lag].is_dirty ) { + if ((entries[type])[idx + lag].is_dirty) { unprotect_entry(file_ptr, type, idx + lag, H5C__DELETED_FLAG); - } else { + } + else { unprotect_entry(file_ptr, type, idx + lag, - (dirty_destroys ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET) - | H5C__DELETED_FLAG); + (dirty_destroys ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET) | + H5C__DELETED_FLAG); } break; @@ -4654,20 +4154,20 @@ row_major_scan_backward(H5F_t * file_ptr, break; } } - } else { + } + else { - if ( ( pass ) && ( (idx + lag) >= 0 ) && - ( ( idx + lag) <= local_max_index ) ) { + if ((pass) && ((idx + lag) >= 0) && ((idx + lag) <= local_max_index)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag)); unprotect_entry(file_ptr, type, idx + lag, - (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); + (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); } } - if ( verbose ) + if (verbose) HDfprintf(stdout, "\n"); idx--; @@ -4675,7 +4175,7 @@ row_major_scan_backward(H5F_t * file_ptr, type--; } - if ( ( pass ) && ( display_stats ) ) { + if ((pass) && (display_stats)) { H5C_stats(cache_ptr, "test cache", display_detailed_stats); } @@ -4684,7 +4184,6 @@ row_major_scan_backward(H5F_t * file_ptr, } /* row_major_scan_backward() */ - /*------------------------------------------------------------------------- * Function: hl_row_major_scan_backward() * @@ -4701,53 +4200,44 @@ row_major_scan_backward(H5F_t * file_ptr, */ void -hl_row_major_scan_backward(H5F_t * file_ptr, - int32_t max_index, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts) +hl_row_major_scan_backward(H5F_t *file_ptr, int32_t max_index, hbool_t verbose, hbool_t reset_stats, + hbool_t display_stats, hbool_t display_detailed_stats, hbool_t do_inserts) { H5C_t * cache_ptr = NULL; - int32_t type = NUMBER_OF_ENTRY_TYPES - 1; + int32_t type = NUMBER_OF_ENTRY_TYPES - 1; int32_t idx; int32_t i; int32_t lag = 100; int32_t local_max_index; - if ( verbose ) + if (verbose) HDfprintf(stdout, "%s(): entering.\n", FUNC); - if ( pass ) { + if (pass) { cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr != NULL ); - HDassert( lag > 5 ); - HDassert( max_index >= 200 ); - HDassert( max_index <= MAX_ENTRIES ); + HDassert(cache_ptr != NULL); + HDassert(lag > 5); + HDassert(max_index >= 200); + HDassert(max_index <= MAX_ENTRIES); - if ( reset_stats ) { + if (reset_stats) { H5C_stats__reset(cache_ptr); } } - while ( ( pass ) && ( type >= 0 ) ) - { + while ((pass) && (type >= 0)) { idx = max_indices[type] + lag; local_max_index = MIN(max_index, max_indices[type]); - while ( ( pass ) && ( idx >= -lag ) ) - { - if ( ( pass ) && ( do_inserts ) && ( (idx + lag) >= 0 ) && - ( (idx + lag) <= local_max_index ) && - ( ((idx + lag) % 2) == 0 ) && - ( ! entry_in_cache(cache_ptr, type, (idx + lag)) ) ) { + while ((pass) && (idx >= -lag)) { + if ((pass) && (do_inserts) && ((idx + lag) >= 0) && ((idx + lag) <= local_max_index) && + (((idx + lag) % 2) == 0) && (!entry_in_cache(cache_ptr, type, (idx + lag)))) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(i, %d, %d) ", type, (idx + lag)); insert_entry(file_ptr, type, (idx + lag), H5C__NO_FLAGS_SET); @@ -4755,16 +4245,15 @@ hl_row_major_scan_backward(H5F_t * file_ptr, i = idx; - while ( ( pass ) && ( i >= idx - lag ) && ( i >= 0 ) ) - { - if ( ( pass ) && ( i >= 0 ) && ( i <= local_max_index ) ) { + while ((pass) && (i >= idx - lag) && (i >= 0)) { + if ((pass) && (i >= 0) && (i <= local_max_index)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, i); protect_entry(file_ptr, type, i); - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, i); unprotect_entry(file_ptr, type, i, H5C__NO_FLAGS_SET); @@ -4772,7 +4261,7 @@ hl_row_major_scan_backward(H5F_t * file_ptr, i--; } - if ( verbose ) + if (verbose) HDfprintf(stdout, "\n"); idx--; @@ -4780,7 +4269,7 @@ hl_row_major_scan_backward(H5F_t * file_ptr, type--; } - if ( ( pass ) && ( display_stats ) ) { + if ((pass) && (display_stats)) { H5C_stats(cache_ptr, "test cache", display_detailed_stats); } @@ -4789,7 +4278,6 @@ hl_row_major_scan_backward(H5F_t * file_ptr, } /* hl_row_major_scan_backward() */ - /*------------------------------------------------------------------------- * Function: col_major_scan_forward() * @@ -4806,35 +4294,29 @@ hl_row_major_scan_backward(H5F_t * file_ptr, */ void -col_major_scan_forward(H5F_t * file_ptr, - int32_t max_index, - int32_t lag, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, +col_major_scan_forward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t verbose, hbool_t reset_stats, + hbool_t display_stats, hbool_t display_detailed_stats, hbool_t do_inserts, int dirty_unprotects) { H5C_t * cache_ptr = NULL; - int32_t type = 0; + int32_t type = 0; int32_t idx; int32_t local_max_index[NUMBER_OF_ENTRY_TYPES]; - if ( verbose ) + if (verbose) HDfprintf(stdout, "%s: entering.\n", FUNC); - if ( pass ) { + if (pass) { int i; cache_ptr = file_ptr->shared->cache; - for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ ) + for (i = 0; i < NUMBER_OF_ENTRY_TYPES; i++) local_max_index[i] = MIN(max_index, max_indices[i]); - HDassert( lag > 5 ); + HDassert(lag > 5); - if ( reset_stats ) { + if (reset_stats) { H5C_stats__reset(cache_ptr); } @@ -4842,44 +4324,37 @@ col_major_scan_forward(H5F_t * file_ptr, idx = -lag; - while ( ( pass ) && ( (idx - lag) <= MAX_ENTRIES ) ) - { + while ((pass) && ((idx - lag) <= MAX_ENTRIES)) { type = 0; - while ( ( pass ) && ( type < NUMBER_OF_ENTRY_TYPES ) ) - { - if ( ( pass ) && ( do_inserts ) && ( (idx + lag) >= 0 ) && - ( (idx + lag) <= local_max_index[type] ) && - ( ((idx + lag) % 3) == 0 ) && - ( ! entry_in_cache(cache_ptr, type, (idx + lag)) ) ) { + while ((pass) && (type < NUMBER_OF_ENTRY_TYPES)) { + if ((pass) && (do_inserts) && ((idx + lag) >= 0) && ((idx + lag) <= local_max_index[type]) && + (((idx + lag) % 3) == 0) && (!entry_in_cache(cache_ptr, type, (idx + lag)))) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(i, %d, %d) ", type, (idx + lag)); insert_entry(file_ptr, type, (idx + lag), H5C__NO_FLAGS_SET); } - if ( ( pass ) && - ( idx >= 0 ) && - ( idx <= local_max_index[type] ) ) { + if ((pass) && (idx >= 0) && (idx <= local_max_index[type])) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, idx); protect_entry(file_ptr, type, idx); } - if ( ( pass ) && ( (idx - lag) >= 0 ) && - ( (idx - lag) <= local_max_index[type] ) ) { + if ((pass) && ((idx - lag) >= 0) && ((idx - lag) <= local_max_index[type])) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag)); unprotect_entry(file_ptr, type, idx - lag, - (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); + (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); } - if ( verbose ) + if (verbose) HDfprintf(stdout, "\n"); type++; @@ -4888,7 +4363,7 @@ col_major_scan_forward(H5F_t * file_ptr, idx++; } - if ( ( pass ) && ( display_stats ) ) { + if ((pass) && (display_stats)) { H5C_stats(cache_ptr, "test cache", display_detailed_stats); } @@ -4897,7 +4372,6 @@ col_major_scan_forward(H5F_t * file_ptr, } /* col_major_scan_forward() */ - /*------------------------------------------------------------------------- * Function: hl_col_major_scan_forward() * @@ -4914,35 +4388,30 @@ col_major_scan_forward(H5F_t * file_ptr, */ void -hl_col_major_scan_forward(H5F_t * file_ptr, - int32_t max_index, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, +hl_col_major_scan_forward(H5F_t *file_ptr, int32_t max_index, hbool_t verbose, hbool_t reset_stats, + hbool_t display_stats, hbool_t display_detailed_stats, hbool_t do_inserts, int dirty_unprotects) { H5C_t * cache_ptr = NULL; - int32_t type = 0; + int32_t type = 0; int32_t idx; int32_t lag = 200; int32_t i; int32_t local_max_index; - if ( verbose ) + if (verbose) HDfprintf(stdout, "%s: entering.\n", FUNC); - if ( pass ) { + if (pass) { cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr != NULL ); - HDassert( lag > 5 ); - HDassert( max_index >= 500 ); - HDassert( max_index <= MAX_ENTRIES ); + HDassert(cache_ptr != NULL); + HDassert(lag > 5); + HDassert(max_index >= 500); + HDassert(max_index <= MAX_ENTRIES); - if ( reset_stats ) { + if (reset_stats) { H5C_stats__reset(cache_ptr); } @@ -4952,47 +4421,42 @@ hl_col_major_scan_forward(H5F_t * file_ptr, local_max_index = MIN(max_index, MAX_ENTRIES); - while ( ( pass ) && ( idx <= local_max_index ) ) - { + while ((pass) && (idx <= local_max_index)) { i = idx; - while ( ( pass ) && ( i >= 0 ) && ( i >= (idx - lag) ) ) { + while ((pass) && (i >= 0) && (i >= (idx - lag))) { type = 0; - while ( ( pass ) && ( type < NUMBER_OF_ENTRY_TYPES ) ) - { - if ( ( pass ) && ( do_inserts ) && ( i == idx ) && - ( i <= local_max_index ) && - ( (i % 3) == 0 ) && - ( ! entry_in_cache(cache_ptr, type, i) ) ) { + while ((pass) && (type < NUMBER_OF_ENTRY_TYPES)) { + if ((pass) && (do_inserts) && (i == idx) && (i <= local_max_index) && ((i % 3) == 0) && + (!entry_in_cache(cache_ptr, type, i))) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(i, %d, %d) ", type, i); insert_entry(file_ptr, type, i, H5C__NO_FLAGS_SET); } - if ( ( pass ) && ( i >= 0 ) && ( i <= local_max_index ) ) { + if ((pass) && (i >= 0) && (i <= local_max_index)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, i); protect_entry(file_ptr, type, i); } - if ( ( pass ) && ( i >= 0 ) && - ( i <= local_max_index ) ) { + if ((pass) && (i >= 0) && (i <= local_max_index)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, i); unprotect_entry(file_ptr, type, i, - (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); + (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); } - if ( verbose ) + if (verbose) HDfprintf(stdout, "\n"); type++; @@ -5004,7 +4468,7 @@ hl_col_major_scan_forward(H5F_t * file_ptr, idx++; } - if ( ( pass ) && ( display_stats ) ) { + if ((pass) && (display_stats)) { H5C_stats(cache_ptr, "test cache", display_detailed_stats); } @@ -5013,7 +4477,6 @@ hl_col_major_scan_forward(H5F_t * file_ptr, } /* hl_col_major_scan_forward() */ - /*------------------------------------------------------------------------- * Function: col_major_scan_backward() * @@ -5030,38 +4493,32 @@ hl_col_major_scan_forward(H5F_t * file_ptr, */ void -col_major_scan_backward(H5F_t * file_ptr, - int32_t max_index, - int32_t lag, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, +col_major_scan_backward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t verbose, hbool_t reset_stats, + hbool_t display_stats, hbool_t display_detailed_stats, hbool_t do_inserts, int dirty_unprotects) { - H5C_t * cache_ptr = NULL; - int mile_stone = 1; + H5C_t * cache_ptr = NULL; + int mile_stone = 1; int32_t type; int32_t idx; int32_t local_max_index[NUMBER_OF_ENTRY_TYPES]; - if ( verbose ) + if (verbose) HDfprintf(stdout, "%s: entering.\n", FUNC); - if ( pass ) { + if (pass) { int i; cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr != NULL ); + HDassert(cache_ptr != NULL); - for ( i = 0; i < NUMBER_OF_ENTRY_TYPES; i++ ) + for (i = 0; i < NUMBER_OF_ENTRY_TYPES; i++) local_max_index[i] = MIN(max_index, max_indices[i]); - HDassert( lag > 5 ); + HDassert(lag > 5); - if ( reset_stats ) { + if (reset_stats) { H5C_stats__reset(cache_ptr); } @@ -5069,48 +4526,40 @@ col_major_scan_backward(H5F_t * file_ptr, idx = local_max_index[NUMBER_OF_ENTRY_TYPES - 1] + lag; - if ( verbose ) /* 1 */ + if (verbose) /* 1 */ HDfprintf(stdout, "%s: point %d.\n", FUNC, mile_stone++); - - while ( ( pass ) && ( (idx + lag) >= 0 ) ) - { + while ((pass) && ((idx + lag) >= 0)) { type = NUMBER_OF_ENTRY_TYPES - 1; - while ( ( pass ) && ( type >= 0 ) ) - { - if ( ( pass ) && ( do_inserts) && ( (idx - lag) >= 0 ) && - ( (idx - lag) <= local_max_index[type] ) && - ( ((idx - lag) % 3) == 0 ) && - ( ! entry_in_cache(cache_ptr, type, (idx - lag)) ) ) { + while ((pass) && (type >= 0)) { + if ((pass) && (do_inserts) && ((idx - lag) >= 0) && ((idx - lag) <= local_max_index[type]) && + (((idx - lag) % 3) == 0) && (!entry_in_cache(cache_ptr, type, (idx - lag)))) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(i, %d, %d) ", type, (idx - lag)); insert_entry(file_ptr, type, (idx - lag), H5C__NO_FLAGS_SET); } - if ( ( pass ) && - ( idx >= 0 ) && - ( idx <= local_max_index[type] ) ) { + if ((pass) && (idx >= 0) && (idx <= local_max_index[type])) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, idx); protect_entry(file_ptr, type, idx); } - if ( ( pass ) && ( (idx + lag) >= 0 ) && - ( (idx + lag) <= local_max_index[type] ) ) { + if ((pass) && ((idx + lag) >= 0) && ((idx + lag) <= local_max_index[type])) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag)); unprotect_entry(file_ptr, type, idx + lag, - (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); + (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); } - if ( verbose ) + if (verbose) HDfprintf(stdout, "\n"); type--; @@ -5119,22 +4568,21 @@ col_major_scan_backward(H5F_t * file_ptr, idx--; } - if ( verbose ) /* 2 */ + if (verbose) /* 2 */ HDfprintf(stdout, "%s: point %d.\n", FUNC, mile_stone++); - if ( ( pass ) && ( display_stats ) ) { + if ((pass) && (display_stats)) { H5C_stats(cache_ptr, "test cache", display_detailed_stats); } - if ( verbose ) + if (verbose) HDfprintf(stdout, "%s: exiting.\n", FUNC); return; } /* col_major_scan_backward() */ - /*------------------------------------------------------------------------- * Function: hl_col_major_scan_backward() * @@ -5151,37 +4599,32 @@ col_major_scan_backward(H5F_t * file_ptr, */ void -hl_col_major_scan_backward(H5F_t * file_ptr, - int32_t max_index, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, +hl_col_major_scan_backward(H5F_t *file_ptr, int32_t max_index, hbool_t verbose, hbool_t reset_stats, + hbool_t display_stats, hbool_t display_detailed_stats, hbool_t do_inserts, int dirty_unprotects) { H5C_t * cache_ptr = NULL; - int32_t type = 0; - int32_t idx = -1; - int32_t lag = 50; + int32_t type = 0; + int32_t idx = -1; + int32_t lag = 50; int32_t i; int32_t local_max_index = -1; - if ( verbose ) + if (verbose) HDfprintf(stdout, "%s: entering.\n", FUNC); - if ( pass ) { + if (pass) { cache_ptr = file_ptr->shared->cache; - HDassert( cache_ptr != NULL ); - HDassert( lag > 5 ); - HDassert( max_index >= 500 ); - HDassert( max_index <= MAX_ENTRIES ); + HDassert(cache_ptr != NULL); + HDassert(lag > 5); + HDassert(max_index >= 500); + HDassert(max_index <= MAX_ENTRIES); local_max_index = MIN(max_index, MAX_ENTRIES); - if ( reset_stats ) { + if (reset_stats) { H5C_stats__reset(cache_ptr); } @@ -5189,46 +4632,42 @@ hl_col_major_scan_backward(H5F_t * file_ptr, idx = local_max_index; } - while ( ( pass ) && ( idx >= 0 ) ) - { + while ((pass) && (idx >= 0)) { i = idx; - while ( ( pass ) && ( i <= local_max_index ) && ( i <= (idx + lag) ) ) { + while ((pass) && (i <= local_max_index) && (i <= (idx + lag))) { type = 0; - while ( ( pass ) && ( type < NUMBER_OF_ENTRY_TYPES ) ) - { - if ( ( pass ) && ( do_inserts ) && ( i == idx ) && - ( i <= local_max_index ) && - ( ! entry_in_cache(cache_ptr, type, i) ) ) { + while ((pass) && (type < NUMBER_OF_ENTRY_TYPES)) { + if ((pass) && (do_inserts) && (i == idx) && (i <= local_max_index) && + (!entry_in_cache(cache_ptr, type, i))) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(i, %d, %d) ", type, i); insert_entry(file_ptr, type, i, H5C__NO_FLAGS_SET); } - if ( ( pass ) && ( i >= 0 ) && ( i <= local_max_index ) ) { + if ((pass) && (i >= 0) && (i <= local_max_index)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(p, %d, %d) ", type, i); protect_entry(file_ptr, type, i); } - if ( ( pass ) && ( i >= 0 ) && - ( i <= local_max_index ) ) { + if ((pass) && (i >= 0) && (i <= local_max_index)) { - if ( verbose ) + if (verbose) HDfprintf(stdout, "(u, %d, %d) ", type, i); unprotect_entry(file_ptr, type, i, - (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); + (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)); } - if ( verbose ) + if (verbose) HDfprintf(stdout, "\n"); type++; @@ -5240,7 +4679,7 @@ hl_col_major_scan_backward(H5F_t * file_ptr, idx--; } - if ( ( pass ) && ( display_stats ) ) { + if ((pass) && (display_stats)) { H5C_stats(cache_ptr, "test cache", display_detailed_stats); } @@ -5249,7 +4688,6 @@ hl_col_major_scan_backward(H5F_t * file_ptr, } /* hl_col_major_scan_backward() */ - /*------------------------------------------------------------------------- * Function: create_flush_dependency() * @@ -5266,23 +4704,20 @@ hl_col_major_scan_backward(H5F_t * file_ptr, */ void -create_flush_dependency(int32_t par_type, - int32_t par_idx, - int32_t chd_type, - int32_t chd_idx) +create_flush_dependency(int32_t par_type, int32_t par_idx, int32_t chd_type, int32_t chd_idx) { - HDassert( ( 0 <= par_type ) && ( par_type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= par_idx ) && ( par_idx <= max_indices[par_type] ) ); - HDassert( ( 0 <= chd_type ) && ( chd_type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= chd_idx ) && ( chd_idx <= max_indices[chd_type] ) ); - - if ( pass ) { - test_entry_t * par_base_addr; /* Base entry of parent's entry array */ - test_entry_t * par_entry_ptr; /* Parent entry */ - test_entry_t * chd_base_addr; /* Base entry of child's entry array */ - test_entry_t * chd_entry_ptr; /* Child entry */ - hbool_t par_is_pinned; /* Whether parent is already pinned */ - herr_t result; /* API routine status */ + HDassert((0 <= par_type) && (par_type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= par_idx) && (par_idx <= max_indices[par_type])); + HDassert((0 <= chd_type) && (chd_type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= chd_idx) && (chd_idx <= max_indices[chd_type])); + + if (pass) { + test_entry_t *par_base_addr; /* Base entry of parent's entry array */ + test_entry_t *par_entry_ptr; /* Parent entry */ + test_entry_t *chd_base_addr; /* Base entry of child's entry array */ + test_entry_t *chd_entry_ptr; /* Child entry */ + hbool_t par_is_pinned; /* Whether parent is already pinned */ + herr_t result; /* API routine status */ /* Get parent entry */ par_base_addr = entries[par_type]; @@ -5290,47 +4725,45 @@ create_flush_dependency(int32_t par_type, par_is_pinned = par_entry_ptr->header.is_pinned; /* Sanity check parent entry */ - HDassert( par_entry_ptr->index == par_idx ); - HDassert( par_entry_ptr->type == par_type ); - HDassert( par_entry_ptr->header.is_protected ); - HDassert( par_entry_ptr == par_entry_ptr->self ); + HDassert(par_entry_ptr->index == par_idx); + HDassert(par_entry_ptr->type == par_type); + HDassert(par_entry_ptr->header.is_protected); + HDassert(par_entry_ptr == par_entry_ptr->self); /* Get parent entry */ chd_base_addr = entries[chd_type]; chd_entry_ptr = &(chd_base_addr[chd_idx]); /* Sanity check child entry */ - HDassert( chd_entry_ptr->index == chd_idx ); - HDassert( chd_entry_ptr->type == chd_type ); - HDassert( chd_entry_ptr == chd_entry_ptr->self ); + HDassert(chd_entry_ptr->index == chd_idx); + HDassert(chd_entry_ptr->type == chd_type); + HDassert(chd_entry_ptr == chd_entry_ptr->self); result = H5C_create_flush_dependency(par_entry_ptr, chd_entry_ptr); - if ( ( result < 0 ) || - ( !par_entry_ptr->header.is_pinned ) || - ( !(par_entry_ptr->header.flush_dep_nchildren > 0) ) ) { + if ((result < 0) || (!par_entry_ptr->header.is_pinned) || + (!(par_entry_ptr->header.flush_dep_nchildren > 0))) { - pass = FALSE; + pass = FALSE; failure_mssg = "error in H5C_create_flush_dependency()."; } /* end if */ /* Update information about entries */ - HDassert( chd_entry_ptr->flush_dep_npar < MAX_FLUSH_DEP_PARS ); + HDassert(chd_entry_ptr->flush_dep_npar < MAX_FLUSH_DEP_PARS); chd_entry_ptr->flush_dep_par_type[chd_entry_ptr->flush_dep_npar] = par_type; - chd_entry_ptr->flush_dep_par_idx[chd_entry_ptr->flush_dep_npar] = par_idx; + chd_entry_ptr->flush_dep_par_idx[chd_entry_ptr->flush_dep_npar] = par_idx; chd_entry_ptr->flush_dep_npar++; par_entry_ptr->flush_dep_nchd++; - if(chd_entry_ptr->is_dirty || chd_entry_ptr->flush_dep_ndirty_chd > 0) { + if (chd_entry_ptr->is_dirty || chd_entry_ptr->flush_dep_ndirty_chd > 0) { HDassert(par_entry_ptr->flush_dep_ndirty_chd < par_entry_ptr->flush_dep_nchd); par_entry_ptr->flush_dep_ndirty_chd++; } /* end if */ par_entry_ptr->pinned_from_cache = TRUE; - if( !par_is_pinned ) + if (!par_is_pinned) par_entry_ptr->is_pinned = TRUE; } /* end if */ } /* create_flush_dependency() */ - /*------------------------------------------------------------------------- * Function: destroy_flush_dependency() * @@ -5347,81 +4780,72 @@ create_flush_dependency(int32_t par_type, */ void -destroy_flush_dependency(int32_t par_type, - int32_t par_idx, - int32_t chd_type, - int32_t chd_idx) +destroy_flush_dependency(int32_t par_type, int32_t par_idx, int32_t chd_type, int32_t chd_idx) { - HDassert( ( 0 <= par_type ) && ( par_type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= par_idx ) && ( par_idx <= max_indices[par_type] ) ); - HDassert( ( 0 <= chd_type ) && ( chd_type < NUMBER_OF_ENTRY_TYPES ) ); - HDassert( ( 0 <= chd_idx ) && ( chd_idx <= max_indices[chd_type] ) ); - - if ( pass ) { - test_entry_t * par_base_addr; /* Base entry of parent's entry array */ - test_entry_t * par_entry_ptr; /* Parent entry */ - test_entry_t * chd_base_addr; /* Base entry of child's entry array */ - test_entry_t * chd_entry_ptr; /* Child entry */ - unsigned i; /* Local index variable */ + HDassert((0 <= par_type) && (par_type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= par_idx) && (par_idx <= max_indices[par_type])); + HDassert((0 <= chd_type) && (chd_type < NUMBER_OF_ENTRY_TYPES)); + HDassert((0 <= chd_idx) && (chd_idx <= max_indices[chd_type])); + + if (pass) { + test_entry_t *par_base_addr; /* Base entry of parent's entry array */ + test_entry_t *par_entry_ptr; /* Parent entry */ + test_entry_t *chd_base_addr; /* Base entry of child's entry array */ + test_entry_t *chd_entry_ptr; /* Child entry */ + unsigned i; /* Local index variable */ /* Get parent entry */ par_base_addr = entries[par_type]; par_entry_ptr = &(par_base_addr[par_idx]); /* Sanity check parent entry */ - HDassert( par_entry_ptr->is_pinned ); - HDassert( par_entry_ptr->pinned_from_cache ); - HDassert( par_entry_ptr->flush_dep_nchd > 0 ); - HDassert( par_entry_ptr == par_entry_ptr->self ); + HDassert(par_entry_ptr->is_pinned); + HDassert(par_entry_ptr->pinned_from_cache); + HDassert(par_entry_ptr->flush_dep_nchd > 0); + HDassert(par_entry_ptr == par_entry_ptr->self); /* Get parent entry */ chd_base_addr = entries[chd_type]; chd_entry_ptr = &(chd_base_addr[chd_idx]); /* Sanity check child entry */ - HDassert( chd_entry_ptr->index == chd_idx ); - HDassert( chd_entry_ptr->type == chd_type ); - HDassert( chd_entry_ptr->flush_dep_npar > 0 ); - HDassert( chd_entry_ptr == chd_entry_ptr->self ); + HDassert(chd_entry_ptr->index == chd_idx); + HDassert(chd_entry_ptr->type == chd_type); + HDassert(chd_entry_ptr->flush_dep_npar > 0); + HDassert(chd_entry_ptr == chd_entry_ptr->self); - if ( H5C_destroy_flush_dependency(par_entry_ptr, chd_entry_ptr) < 0 ) { - pass = FALSE; + if (H5C_destroy_flush_dependency(par_entry_ptr, chd_entry_ptr) < 0) { + pass = FALSE; failure_mssg = "error in H5C_destroy_flush_dependency()."; } /* end if */ /* Update information about entries */ - for(i=0; iflush_dep_npar; i++) - if(chd_entry_ptr->flush_dep_par_type[i] == par_type - && chd_entry_ptr->flush_dep_par_idx[i] == par_idx) + for (i = 0; i < chd_entry_ptr->flush_dep_npar; i++) + if (chd_entry_ptr->flush_dep_par_type[i] == par_type && + chd_entry_ptr->flush_dep_par_idx[i] == par_idx) break; HDassert(i < chd_entry_ptr->flush_dep_npar); - if(i < chd_entry_ptr->flush_dep_npar - 1) - HDmemmove(&chd_entry_ptr->flush_dep_par_type[i], - &chd_entry_ptr->flush_dep_par_type[i+1], - (chd_entry_ptr->flush_dep_npar - i - 1) - * sizeof(chd_entry_ptr->flush_dep_par_type[0])); - if(i < chd_entry_ptr->flush_dep_npar - 1) - HDmemmove(&chd_entry_ptr->flush_dep_par_idx[i], - &chd_entry_ptr->flush_dep_par_idx[i+1], - (chd_entry_ptr->flush_dep_npar - i - 1) - * sizeof(chd_entry_ptr->flush_dep_par_idx[0])); + if (i < chd_entry_ptr->flush_dep_npar - 1) + HDmemmove(&chd_entry_ptr->flush_dep_par_type[i], &chd_entry_ptr->flush_dep_par_type[i + 1], + (chd_entry_ptr->flush_dep_npar - i - 1) * sizeof(chd_entry_ptr->flush_dep_par_type[0])); + if (i < chd_entry_ptr->flush_dep_npar - 1) + HDmemmove(&chd_entry_ptr->flush_dep_par_idx[i], &chd_entry_ptr->flush_dep_par_idx[i + 1], + (chd_entry_ptr->flush_dep_npar - i - 1) * sizeof(chd_entry_ptr->flush_dep_par_idx[0])); chd_entry_ptr->flush_dep_npar--; par_entry_ptr->flush_dep_nchd--; - if(par_entry_ptr->flush_dep_nchd == 0) { + if (par_entry_ptr->flush_dep_nchd == 0) { par_entry_ptr->pinned_from_cache = FALSE; - par_entry_ptr->is_pinned = par_entry_ptr->pinned_from_client; + par_entry_ptr->is_pinned = par_entry_ptr->pinned_from_client; } /* end if */ - if(chd_entry_ptr->is_dirty || chd_entry_ptr->flush_dep_ndirty_chd > 0) { + if (chd_entry_ptr->is_dirty || chd_entry_ptr->flush_dep_ndirty_chd > 0) { HDassert(par_entry_ptr->flush_dep_ndirty_chd > 0); par_entry_ptr->flush_dep_ndirty_chd--; - if(!par_entry_ptr->is_dirty - && par_entry_ptr->flush_dep_ndirty_chd == 0) + if (!par_entry_ptr->is_dirty && par_entry_ptr->flush_dep_ndirty_chd == 0) mark_flush_dep_clean(par_entry_ptr); } /* end if */ - } /* end if */ + } /* end if */ } /* destroy_flush_dependency() */ - /*------------------------------------------------------------------------- * Function: mark_flush_dep_dirty() * @@ -5438,33 +4862,31 @@ destroy_flush_dependency(int32_t par_type, *------------------------------------------------------------------------- */ static void -mark_flush_dep_dirty(test_entry_t * entry_ptr) +mark_flush_dep_dirty(test_entry_t *entry_ptr) { /* Sanity checks */ HDassert(entry_ptr); /* Iterate over the parent entries */ - if(entry_ptr->flush_dep_npar) { - test_entry_t *par_base_addr; /* Base entry of parent's entry array */ - test_entry_t *par_entry_ptr; /* Parent entry */ - unsigned u; /* Local index variable */ + if (entry_ptr->flush_dep_npar) { + test_entry_t *par_base_addr; /* Base entry of parent's entry array */ + test_entry_t *par_entry_ptr; /* Parent entry */ + unsigned u; /* Local index variable */ - for(u = 0; u < entry_ptr->flush_dep_npar; u++) { + for (u = 0; u < entry_ptr->flush_dep_npar; u++) { /* Get parent entry */ par_base_addr = entries[entry_ptr->flush_dep_par_type[u]]; par_entry_ptr = &(par_base_addr[entry_ptr->flush_dep_par_idx[u]]); /* Sanity check */ - HDassert(par_entry_ptr->flush_dep_ndirty_chd - < par_entry_ptr->flush_dep_nchd); + HDassert(par_entry_ptr->flush_dep_ndirty_chd < par_entry_ptr->flush_dep_nchd); /* Adjust the parent's number of dirty children */ par_entry_ptr->flush_dep_ndirty_chd++; } /* end for */ - } /* end if */ + } /* end if */ } /* end mark_flush_dep_dirty() */ - /*------------------------------------------------------------------------- * Function: mark_flush_dep_clean() * @@ -5481,19 +4903,19 @@ mark_flush_dep_dirty(test_entry_t * entry_ptr) *------------------------------------------------------------------------- */ static void -mark_flush_dep_clean(test_entry_t * entry_ptr) +mark_flush_dep_clean(test_entry_t *entry_ptr) { /* Sanity checks */ HDassert(entry_ptr); HDassert(!entry_ptr->is_dirty && entry_ptr->flush_dep_ndirty_chd == 0); /* Iterate over the parent entries */ - if(entry_ptr->flush_dep_npar) { - test_entry_t *par_base_addr; /* Base entry of parent's entry array */ - test_entry_t *par_entry_ptr; /* Parent entry */ - unsigned u; /* Local index variable */ + if (entry_ptr->flush_dep_npar) { + test_entry_t *par_base_addr; /* Base entry of parent's entry array */ + test_entry_t *par_entry_ptr; /* Parent entry */ + unsigned u; /* Local index variable */ - for(u = 0; u < entry_ptr->flush_dep_npar; u++) { + for (u = 0; u < entry_ptr->flush_dep_npar; u++) { /* Get parent entry */ par_base_addr = entries[entry_ptr->flush_dep_par_type[u]]; par_entry_ptr = &(par_base_addr[entry_ptr->flush_dep_par_idx[u]]); @@ -5504,13 +4926,11 @@ mark_flush_dep_clean(test_entry_t * entry_ptr) /* Adjust the parent's number of dirty children */ par_entry_ptr->flush_dep_ndirty_chd--; } /* end for */ - } /* end if */ + } /* end if */ } /* end mark_flush_dep_clean() */ - /*** H5AC level utility functions ***/ - /*------------------------------------------------------------------------- * Function: check_and_validate_cache_hit_rate() * @@ -5538,115 +4958,106 @@ mark_flush_dep_clean(test_entry_t * entry_ptr) */ void -check_and_validate_cache_hit_rate(hid_t file_id, - double * hit_rate_ptr, - hbool_t dump_data, - int64_t min_accesses, - double min_hit_rate) +check_and_validate_cache_hit_rate(hid_t file_id, double *hit_rate_ptr, hbool_t dump_data, + int64_t min_accesses, double min_hit_rate) { - herr_t result; - int64_t cache_hits = 0; + herr_t result; + int64_t cache_hits = 0; int64_t cache_accesses = 0; - double expected_hit_rate; - double hit_rate; - H5F_t * file_ptr = NULL; + double expected_hit_rate; + double hit_rate; + H5F_t * file_ptr = NULL; H5C_t * cache_ptr = NULL; /* get a pointer to the files internal data structure */ - if ( pass ) { + if (pass) { file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr."; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } /* verify that we can access the cache data structure */ - if ( pass ) { + if (pass) { - if ( ( cache_ptr == NULL ) || - ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't access cache resize_ctl."; } } /* compare the cache's internal configuration with the expected value */ - if ( pass ) { + if (pass) { cache_hits = cache_ptr->cache_hits; cache_accesses = cache_ptr->cache_accesses; - if ( cache_accesses > 0 ) { + if (cache_accesses > 0) { expected_hit_rate = ((double)cache_hits) / ((double)cache_accesses); - - } else { + } + else { expected_hit_rate = 0.0F; } result = H5Fget_mdc_hit_rate(file_id, &hit_rate); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_hit_rate() failed."; + } + else if (!H5_DBL_ABS_EQUAL(hit_rate, expected_hit_rate)) { - } else if ( ! H5_DBL_ABS_EQUAL(hit_rate, expected_hit_rate) ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected hit rate."; - } } - if ( pass ) { /* reset the hit rate */ + if (pass) { /* reset the hit rate */ result = H5Freset_mdc_hit_rate_stats(file_id); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Freset_mdc_hit_rate_stats() failed."; } } /* set *hit_rate_ptr if appropriate */ - if ( ( pass ) && ( hit_rate_ptr != NULL ) ) { + if ((pass) && (hit_rate_ptr != NULL)) { *hit_rate_ptr = hit_rate; } /* dump data to stdout if requested */ - if ( ( pass ) && ( dump_data ) ) { + if ((pass) && (dump_data)) { - HDfprintf(stdout, - "cache_hits: %ld, cache_accesses: %ld, hit_rate: %lf\n", - (long)cache_hits, (long)cache_accesses, hit_rate); + HDfprintf(stdout, "cache_hits: %ld, cache_accesses: %ld, hit_rate: %lf\n", (long)cache_hits, + (long)cache_accesses, hit_rate); } - if ( ( pass ) && - ( cache_accesses > min_accesses ) && - ( hit_rate < min_hit_rate ) ) { + if ((pass) && (cache_accesses > min_accesses) && (hit_rate < min_hit_rate)) { - pass = FALSE; - failure_mssg = "Unexpectedly low hit rate."; + pass = FALSE; + failure_mssg = "Unexpectedly low hit rate."; } return; } /* check_and_validate_cache_hit_rate() */ - /*------------------------------------------------------------------------- * Function: check_and_validate_cache_size() * @@ -5670,111 +5081,96 @@ check_and_validate_cache_hit_rate(hid_t file_id, */ void -check_and_validate_cache_size(hid_t file_id, - size_t * max_size_ptr, - size_t * min_clean_size_ptr, - size_t * cur_size_ptr, - int32_t * cur_num_entries_ptr, - hbool_t dump_data) +check_and_validate_cache_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, int32_t *cur_num_entries_ptr, hbool_t dump_data) { - herr_t result; - size_t expected_max_size; - size_t max_size; - size_t expected_min_clean_size; - size_t min_clean_size; - size_t expected_cur_size; - size_t cur_size; + herr_t result; + size_t expected_max_size; + size_t max_size; + size_t expected_min_clean_size; + size_t min_clean_size; + size_t expected_cur_size; + size_t cur_size; uint32_t expected_cur_num_entries; - int cur_num_entries; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + int cur_num_entries; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; /* get a pointer to the files internal data structure */ - if ( pass ) { + if (pass) { file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr."; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } /* verify that we can access the cache data structure */ - if ( pass ) { + if (pass) { - if ( ( cache_ptr == NULL ) || - ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't access cache data structure."; } } /* compare the cache's internal configuration with the expected value */ - if ( pass ) { + if (pass) { expected_max_size = cache_ptr->max_cache_size; expected_min_clean_size = cache_ptr->min_clean_size; expected_cur_size = cache_ptr->index_size; expected_cur_num_entries = cache_ptr->index_len; - result = H5Fget_mdc_size(file_id, - &max_size, - &min_clean_size, - &cur_size, - &cur_num_entries); + result = H5Fget_mdc_size(file_id, &max_size, &min_clean_size, &cur_size, &cur_num_entries); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_size() failed."; + } + else if ((max_size != expected_max_size) || (min_clean_size != expected_min_clean_size) || + (cur_size != expected_cur_size) || (cur_num_entries != (int)expected_cur_num_entries)) { - } else if ( ( max_size != expected_max_size ) || - ( min_clean_size != expected_min_clean_size ) || - ( cur_size != expected_cur_size ) || - ( cur_num_entries != (int)expected_cur_num_entries ) ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_mdc_size() returned unexpected value(s)."; - } } /* return size values if requested */ - if ( ( pass ) && ( max_size_ptr != NULL ) ) { + if ((pass) && (max_size_ptr != NULL)) { *max_size_ptr = max_size; } - if ( ( pass ) && ( min_clean_size_ptr != NULL ) ) { + if ((pass) && (min_clean_size_ptr != NULL)) { *min_clean_size_ptr = min_clean_size; } - if ( ( pass ) && ( cur_size_ptr != NULL ) ) { + if ((pass) && (cur_size_ptr != NULL)) { *cur_size_ptr = cur_size; } - if ( ( pass ) && ( cur_num_entries_ptr != NULL ) ) { + if ((pass) && (cur_num_entries_ptr != NULL)) { *cur_num_entries_ptr = cur_num_entries; } - /* dump data to stdout if requested */ - if ( ( pass ) && ( dump_data ) ) { + if ((pass) && (dump_data)) { - HDfprintf(stdout, - "max_sz: %ld, min_clean_sz: %ld, cur_sz: %ld, cur_ent: %ld\n", - (long)max_size, (long)min_clean_size, (long)cur_size, - (long)cur_num_entries); + HDfprintf(stdout, "max_sz: %ld, min_clean_sz: %ld, cur_sz: %ld, cur_ent: %ld\n", (long)max_size, + (long)min_clean_size, (long)cur_size, (long)cur_num_entries); } return; @@ -5782,62 +5178,59 @@ check_and_validate_cache_size(hid_t file_id, } /* check_and_validate_cache_size() */ H5_ATTR_PURE hbool_t -resize_configs_are_equal(const H5C_auto_size_ctl_t *a, - const H5C_auto_size_ctl_t *b, - hbool_t compare_init) +resize_configs_are_equal(const H5C_auto_size_ctl_t *a, const H5C_auto_size_ctl_t *b, hbool_t compare_init) { - if(a->version != b->version) - return(FALSE); - else if(a->rpt_fcn != b->rpt_fcn) - return(FALSE); - else if(compare_init && (a->set_initial_size != b->set_initial_size)) - return(FALSE); - else if(compare_init && (a->initial_size != b->initial_size)) - return(FALSE); - else if(!H5_DBL_ABS_EQUAL(a->min_clean_fraction, b->min_clean_fraction)) - return(FALSE); - else if(a->max_size != b->max_size) - return(FALSE); - else if(a->min_size != b->min_size) - return(FALSE); - else if(a->epoch_length != b->epoch_length) - return(FALSE); - else if(a->incr_mode != b->incr_mode) - return(FALSE); - else if(!H5_DBL_ABS_EQUAL(a->lower_hr_threshold, b->lower_hr_threshold)) - return(FALSE); - else if(!H5_DBL_ABS_EQUAL(a->increment, b->increment)) - return(FALSE); - else if(a->apply_max_increment != b->apply_max_increment) - return(FALSE); - else if(a->max_increment != b->max_increment) - return(FALSE); - else if(a->flash_incr_mode != b->flash_incr_mode) - return(FALSE); - else if(!H5_DBL_ABS_EQUAL(a->flash_multiple, b->flash_multiple)) - return(FALSE); - else if(!H5_DBL_ABS_EQUAL(a->flash_threshold, b->flash_threshold)) - return(FALSE); - else if(a->decr_mode != b->decr_mode) - return(FALSE); - else if(!H5_DBL_ABS_EQUAL(a->upper_hr_threshold, b->upper_hr_threshold)) - return(FALSE); - else if(!H5_DBL_ABS_EQUAL(a->decrement, b->decrement)) - return(FALSE); - else if(a->apply_max_decrement != b->apply_max_decrement) - return(FALSE); - else if(a->max_decrement != b->max_decrement) - return(FALSE); - else if(a->epochs_before_eviction != b->epochs_before_eviction) - return(FALSE); - else if(a->apply_empty_reserve != b->apply_empty_reserve) - return(FALSE); - else if(!H5_DBL_ABS_EQUAL(a->empty_reserve, b->empty_reserve)) - return(FALSE); - return(TRUE); + if (a->version != b->version) + return (FALSE); + else if (a->rpt_fcn != b->rpt_fcn) + return (FALSE); + else if (compare_init && (a->set_initial_size != b->set_initial_size)) + return (FALSE); + else if (compare_init && (a->initial_size != b->initial_size)) + return (FALSE); + else if (!H5_DBL_ABS_EQUAL(a->min_clean_fraction, b->min_clean_fraction)) + return (FALSE); + else if (a->max_size != b->max_size) + return (FALSE); + else if (a->min_size != b->min_size) + return (FALSE); + else if (a->epoch_length != b->epoch_length) + return (FALSE); + else if (a->incr_mode != b->incr_mode) + return (FALSE); + else if (!H5_DBL_ABS_EQUAL(a->lower_hr_threshold, b->lower_hr_threshold)) + return (FALSE); + else if (!H5_DBL_ABS_EQUAL(a->increment, b->increment)) + return (FALSE); + else if (a->apply_max_increment != b->apply_max_increment) + return (FALSE); + else if (a->max_increment != b->max_increment) + return (FALSE); + else if (a->flash_incr_mode != b->flash_incr_mode) + return (FALSE); + else if (!H5_DBL_ABS_EQUAL(a->flash_multiple, b->flash_multiple)) + return (FALSE); + else if (!H5_DBL_ABS_EQUAL(a->flash_threshold, b->flash_threshold)) + return (FALSE); + else if (a->decr_mode != b->decr_mode) + return (FALSE); + else if (!H5_DBL_ABS_EQUAL(a->upper_hr_threshold, b->upper_hr_threshold)) + return (FALSE); + else if (!H5_DBL_ABS_EQUAL(a->decrement, b->decrement)) + return (FALSE); + else if (a->apply_max_decrement != b->apply_max_decrement) + return (FALSE); + else if (a->max_decrement != b->max_decrement) + return (FALSE); + else if (a->epochs_before_eviction != b->epochs_before_eviction) + return (FALSE); + else if (a->apply_empty_reserve != b->apply_empty_reserve) + return (FALSE); + else if (!H5_DBL_ABS_EQUAL(a->empty_reserve, b->empty_reserve)) + return (FALSE); + return (TRUE); } - /*------------------------------------------------------------------------- * Function: validate_mdc_config() * @@ -5858,78 +5251,70 @@ resize_configs_are_equal(const H5C_auto_size_ctl_t *a, */ void -validate_mdc_config(hid_t file_id, - H5AC_cache_config_t * ext_config_ptr, - hbool_t compare_init, - int test_num) +validate_mdc_config(hid_t file_id, H5AC_cache_config_t *ext_config_ptr, hbool_t compare_init, int test_num) { - static char msg[256]; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + static char msg[256]; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; H5AC_cache_config_t scratch; H5C_auto_size_ctl_t int_config; XLATE_EXT_TO_INT_MDC_CONFIG(int_config, (*ext_config_ptr)) /* get a pointer to the files internal data structure */ - if ( pass ) { + if (pass) { file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Can't get file_ptr #%d.", test_num); failure_mssg = msg; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } /* verify that we can access the internal version of the cache config */ - if ( pass ) { + if (pass) { - if ( ( cache_ptr == NULL ) || - ( cache_ptr->magic != H5C__H5C_T_MAGIC ) || - ( cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER ) ){ + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || + (cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Can't access cache resize_ctl #%d.", test_num); + HDsnprintf(msg, (size_t)128, "Can't access cache resize_ctl #%d.", test_num); failure_mssg = msg; } } /* compare the cache's internal configuration with the expected value */ - if ( pass ) { + if (pass) { - if ( ! resize_configs_are_equal(&int_config, &cache_ptr->resize_ctl, - compare_init) ) { + if (!resize_configs_are_equal(&int_config, &cache_ptr->resize_ctl, compare_init)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected internal config #%d.", test_num); + HDsnprintf(msg, (size_t)128, "Unexpected internal config #%d.", test_num); failure_mssg = msg; } } /* obtain external cache config */ - if ( pass ) { + if (pass) { scratch.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if ( H5Fget_mdc_config(file_id, &scratch) < 0 ) { + if (H5Fget_mdc_config(file_id, &scratch) < 0) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5Fget_mdc_config() failed #%d.", test_num); + HDsnprintf(msg, (size_t)128, "H5Fget_mdc_config() failed #%d.", test_num); failure_mssg = msg; } } - if ( pass ) { + if (pass) { /* Recall that in any configuration supplied by the cache * at run time, the set_initial_size field will always @@ -5942,12 +5327,10 @@ validate_mdc_config(hid_t file_id, * Depending on circumstances, this may or may not match * the original. Hence the compare_init parameter. */ - if ( ! CACHE_CONFIGS_EQUAL((*ext_config_ptr), scratch, \ - FALSE, compare_init) ) { + if (!CACHE_CONFIGS_EQUAL((*ext_config_ptr), scratch, FALSE, compare_init)) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unexpected external config #%d.", test_num); + HDsnprintf(msg, (size_t)128, "Unexpected external config #%d.", test_num); failure_mssg = msg; } } @@ -5956,7 +5339,6 @@ validate_mdc_config(hid_t file_id, } /* validate_mdc_config() */ - #if 0 /* debugging functions -- normally commented out */ /*------------------------------------------------------------------------- * Function: dump_LRU diff --git a/test/cache_common.h b/test/cache_common.h index 0d6f153..16c8350 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -20,8 +20,8 @@ #ifndef _CACHE_COMMON_H #define _CACHE_COMMON_H -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /* Include library header files */ #include "H5ACprivate.h" @@ -29,340 +29,324 @@ #include "H5Cpkg.h" #include "H5Fpkg.h" #include "H5Iprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Include test header files */ #include "h5test.h" /* Macro to make error reporting easier */ -#define CACHE_ERROR(s) {failure_mssg = "Line #" H5_TOSTRING(__LINE__) ": " s ; pass = FALSE; goto done;} +#define CACHE_ERROR(s) \ + { \ + failure_mssg = "Line #" H5_TOSTRING(__LINE__) ": " s; \ + pass = FALSE; \ + goto done; \ + } -#define NO_CHANGE -1 +#define NO_CHANGE -1 /* with apologies for the abuse of terminology... */ -#define PICO_ENTRY_TYPE 0 -#define NANO_ENTRY_TYPE 1 +#define PICO_ENTRY_TYPE 0 +#define NANO_ENTRY_TYPE 1 #define MICRO_ENTRY_TYPE 2 -#define TINY_ENTRY_TYPE 3 +#define TINY_ENTRY_TYPE 3 #define SMALL_ENTRY_TYPE 4 -#define MEDIUM_ENTRY_TYPE 5 +#define MEDIUM_ENTRY_TYPE 5 #define LARGE_ENTRY_TYPE 6 -#define HUGE_ENTRY_TYPE 7 -#define MONSTER_ENTRY_TYPE 8 -#define VARIABLE_ENTRY_TYPE 9 -#define NOTIFY_ENTRY_TYPE 10 +#define HUGE_ENTRY_TYPE 7 +#define MONSTER_ENTRY_TYPE 8 +#define VARIABLE_ENTRY_TYPE 9 +#define NOTIFY_ENTRY_TYPE 10 -#define NUMBER_OF_ENTRY_TYPES 11 +#define NUMBER_OF_ENTRY_TYPES 11 -#define PICO_ENTRY_SIZE (size_t)1 -#define NANO_ENTRY_SIZE (size_t)4 +#define PICO_ENTRY_SIZE (size_t)1 +#define NANO_ENTRY_SIZE (size_t)4 #define MICRO_ENTRY_SIZE (size_t)16 -#define TINY_ENTRY_SIZE (size_t)64 +#define TINY_ENTRY_SIZE (size_t)64 #define SMALL_ENTRY_SIZE (size_t)256 -#define MEDIUM_ENTRY_SIZE (size_t)1024 +#define MEDIUM_ENTRY_SIZE (size_t)1024 #define LARGE_ENTRY_SIZE (size_t)(4 * 1024) -#define HUGE_ENTRY_SIZE (size_t)(16 * 1024) -#define MONSTER_ENTRY_SIZE (size_t)(64 * 1024) -#define VARIABLE_ENTRY_SIZE (size_t)(10 * 1024) -#define NOTIFY_ENTRY_SIZE (size_t)1 +#define HUGE_ENTRY_SIZE (size_t)(16 * 1024) +#define MONSTER_ENTRY_SIZE (size_t)(64 * 1024) +#define VARIABLE_ENTRY_SIZE (size_t)(10 * 1024) +#define NOTIFY_ENTRY_SIZE (size_t)1 -#define NUM_PICO_ENTRIES (10 * 1024) -#define NUM_NANO_ENTRIES (10 * 1024) +#define NUM_PICO_ENTRIES (10 * 1024) +#define NUM_NANO_ENTRIES (10 * 1024) #define NUM_MICRO_ENTRIES (10 * 1024) -#define NUM_TINY_ENTRIES (10 * 1024) +#define NUM_TINY_ENTRIES (10 * 1024) #define NUM_SMALL_ENTRIES (10 * 1024) -#define NUM_MEDIUM_ENTRIES (10 * 1024) +#define NUM_MEDIUM_ENTRIES (10 * 1024) #define NUM_LARGE_ENTRIES (10 * 1024) -#define NUM_HUGE_ENTRIES (10 * 1024) -#define NUM_MONSTER_ENTRIES (10 * 1024) -#define NUM_VARIABLE_ENTRIES (10 * 1024) -#define NUM_NOTIFY_ENTRIES (10 * 1024) - -#define MAX_ENTRIES (10 * 1024) +#define NUM_HUGE_ENTRIES (10 * 1024) +#define NUM_MONSTER_ENTRIES (10 * 1024) +#define NUM_VARIABLE_ENTRIES (10 * 1024) +#define NUM_NOTIFY_ENTRIES (10 * 1024) +#define MAX_ENTRIES (10 * 1024) /* The choice of the BASE_ADDR below is arbitrary -- it just has to be * larger than the superblock. */ -#define BASE_ADDR (haddr_t)1024 -#define PICO_BASE_ADDR BASE_ADDR -#define NANO_BASE_ADDR (haddr_t)(PICO_BASE_ADDR + \ - (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES)) -#define MICRO_BASE_ADDR (haddr_t)(NANO_BASE_ADDR + \ - (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES)) -#define TINY_BASE_ADDR (haddr_t)(MICRO_BASE_ADDR + \ - (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) -#define SMALL_BASE_ADDR (haddr_t)(TINY_BASE_ADDR + \ - (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES)) -#define MEDIUM_BASE_ADDR (haddr_t)(SMALL_BASE_ADDR + \ - (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES)) -#define LARGE_BASE_ADDR (haddr_t)(MEDIUM_BASE_ADDR + \ - (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES)) -#define HUGE_BASE_ADDR (haddr_t)(LARGE_BASE_ADDR + \ - (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES)) -#define MONSTER_BASE_ADDR (haddr_t)(HUGE_BASE_ADDR + \ - (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES)) -#define VARIABLE_BASE_ADDR (haddr_t)(MONSTER_BASE_ADDR + \ - (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) -#define NOTIFY_BASE_ADDR (haddr_t)(VARIABLE_BASE_ADDR + \ - (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) - -#define PICO_ALT_BASE_ADDR (haddr_t)(NOTIFY_BASE_ADDR + \ - (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) -#define NANO_ALT_BASE_ADDR (haddr_t)(PICO_ALT_BASE_ADDR + \ - (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES)) -#define MICRO_ALT_BASE_ADDR (haddr_t)(NANO_ALT_BASE_ADDR + \ - (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES)) -#define TINY_ALT_BASE_ADDR (haddr_t)(MICRO_ALT_BASE_ADDR + \ - (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) -#define SMALL_ALT_BASE_ADDR (haddr_t)(TINY_ALT_BASE_ADDR + \ - (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES)) -#define MEDIUM_ALT_BASE_ADDR (haddr_t)(SMALL_ALT_BASE_ADDR + \ - (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES)) -#define LARGE_ALT_BASE_ADDR (haddr_t)(MEDIUM_ALT_BASE_ADDR + \ - (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES)) -#define HUGE_ALT_BASE_ADDR (haddr_t)(LARGE_ALT_BASE_ADDR + \ - (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES)) -#define MONSTER_ALT_BASE_ADDR (haddr_t)(HUGE_ALT_BASE_ADDR + \ - (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES)) -#define VARIABLE_ALT_BASE_ADDR (haddr_t)(MONSTER_ALT_BASE_ADDR + \ - (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) -#define NOTIFY_ALT_BASE_ADDR (haddr_t)(VARIABLE_ALT_BASE_ADDR + \ - (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) -#define MAX_ADDR (haddr_t)(NOTIFY_ALT_BASE_ADDR + \ - (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) +#define BASE_ADDR (haddr_t)1024 +#define PICO_BASE_ADDR BASE_ADDR +#define NANO_BASE_ADDR (haddr_t)(PICO_BASE_ADDR + (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES)) +#define MICRO_BASE_ADDR (haddr_t)(NANO_BASE_ADDR + (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES)) +#define TINY_BASE_ADDR (haddr_t)(MICRO_BASE_ADDR + (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) +#define SMALL_BASE_ADDR (haddr_t)(TINY_BASE_ADDR + (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES)) +#define MEDIUM_BASE_ADDR (haddr_t)(SMALL_BASE_ADDR + (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES)) +#define LARGE_BASE_ADDR (haddr_t)(MEDIUM_BASE_ADDR + (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES)) +#define HUGE_BASE_ADDR (haddr_t)(LARGE_BASE_ADDR + (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES)) +#define MONSTER_BASE_ADDR (haddr_t)(HUGE_BASE_ADDR + (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES)) +#define VARIABLE_BASE_ADDR (haddr_t)(MONSTER_BASE_ADDR + (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) +#define NOTIFY_BASE_ADDR (haddr_t)(VARIABLE_BASE_ADDR + (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) + +#define PICO_ALT_BASE_ADDR (haddr_t)(NOTIFY_BASE_ADDR + (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) +#define NANO_ALT_BASE_ADDR (haddr_t)(PICO_ALT_BASE_ADDR + (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES)) +#define MICRO_ALT_BASE_ADDR (haddr_t)(NANO_ALT_BASE_ADDR + (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES)) +#define TINY_ALT_BASE_ADDR (haddr_t)(MICRO_ALT_BASE_ADDR + (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) +#define SMALL_ALT_BASE_ADDR (haddr_t)(TINY_ALT_BASE_ADDR + (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES)) +#define MEDIUM_ALT_BASE_ADDR (haddr_t)(SMALL_ALT_BASE_ADDR + (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES)) +#define LARGE_ALT_BASE_ADDR (haddr_t)(MEDIUM_ALT_BASE_ADDR + (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES)) +#define HUGE_ALT_BASE_ADDR (haddr_t)(LARGE_ALT_BASE_ADDR + (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES)) +#define MONSTER_ALT_BASE_ADDR (haddr_t)(HUGE_ALT_BASE_ADDR + (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES)) +#define VARIABLE_ALT_BASE_ADDR (haddr_t)(MONSTER_ALT_BASE_ADDR + (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) +#define NOTIFY_ALT_BASE_ADDR (haddr_t)(VARIABLE_ALT_BASE_ADDR + (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) +#define MAX_ADDR (haddr_t)(NOTIFY_ALT_BASE_ADDR + (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) #define ADDR_SPACE_SIZE (haddr_t)(MAX_ADDR - BASE_ADDR) -#define MAX_PINS 8 /* Maximum number of entries that can be - * directly pinned by a single entry. - */ +#define MAX_PINS \ + 8 /* Maximum number of entries that can be \ + * directly pinned by a single entry. \ + */ -#define FLUSH_OP__NO_OP 0 -#define FLUSH_OP__DIRTY 1 -#define FLUSH_OP__RESIZE 2 -#define FLUSH_OP__MOVE 3 -#define FLUSH_OP__ORDER 4 +#define FLUSH_OP__NO_OP 0 +#define FLUSH_OP__DIRTY 1 +#define FLUSH_OP__RESIZE 2 +#define FLUSH_OP__MOVE 3 +#define FLUSH_OP__ORDER 4 #define FLUSH_OP__EXPUNGE 5 -#define FLUSH_OP__DEST_FLUSH_DEP 6 -#define FLUSH_OP__MAX_OP 6 - -#define MAX_FLUSH_OPS 10 /* Maximum number of flush operations - * that can be associated with a - * cache entry. - */ - -#define MAX_FLUSH_DEP_PARS 8 /* Maximum number of flush dependency - * parents in the test */ - -typedef struct flush_op -{ - int op_code; /* integer op code indicating the - * operation to be performed. At - * present it must be one of: - * - * FLUSH_OP__NO_OP - * FLUSH_OP__DIRTY - * FLUSH_OP__RESIZE - * FLUSH_OP__MOVE - * FLUSH_OP__ORDER - */ - int type; /* type code of the cache entry that - * is the target of the operation. - * This value is passed into the - * function implementing the flush - * operation. - */ - int idx; /* index of the cache entry that - * is the target of the operation. - * This value is passed into the - * function implementing the flush - * operation. - */ - hbool_t flag; /* boolean flag passed into the - * function implementing the flush - * operation. The meaning of the - * flag is dependent upon the flush - * operation: - * - * FLUSH_OP__DIRTY: TRUE iff the - * target is pinned, and is to - * be dirtied via the - * H5C_mark_entry_dirty() - * call. - * - * FLUSH_OP__RESIZE: TRUE iff the - * target is pinned, and is to - * be resized via the - * H5C_resize_entry() - * call. - * - * FLUSH_OP__MOVE: TRUE iff the - * target is to be moved to - * its main address. - */ - size_t size; /* New target size in the - * FLUSH_OP__MOVE operation. - * Unused elsewhere. - */ - unsigned * order_ptr; /* Pointer to outside counter for - * recording the order of entries - * flushed. - */ +#define FLUSH_OP__DEST_FLUSH_DEP 6 +#define FLUSH_OP__MAX_OP 6 + +#define MAX_FLUSH_OPS \ + 10 /* Maximum number of flush operations \ + * that can be associated with a \ + * cache entry. \ + */ + +#define MAX_FLUSH_DEP_PARS \ + 8 /* Maximum number of flush dependency \ + * parents in the test */ + +typedef struct flush_op { + int op_code; /* integer op code indicating the + * operation to be performed. At + * present it must be one of: + * + * FLUSH_OP__NO_OP + * FLUSH_OP__DIRTY + * FLUSH_OP__RESIZE + * FLUSH_OP__MOVE + * FLUSH_OP__ORDER + */ + int type; /* type code of the cache entry that + * is the target of the operation. + * This value is passed into the + * function implementing the flush + * operation. + */ + int idx; /* index of the cache entry that + * is the target of the operation. + * This value is passed into the + * function implementing the flush + * operation. + */ + hbool_t flag; /* boolean flag passed into the + * function implementing the flush + * operation. The meaning of the + * flag is dependent upon the flush + * operation: + * + * FLUSH_OP__DIRTY: TRUE iff the + * target is pinned, and is to + * be dirtied via the + * H5C_mark_entry_dirty() + * call. + * + * FLUSH_OP__RESIZE: TRUE iff the + * target is pinned, and is to + * be resized via the + * H5C_resize_entry() + * call. + * + * FLUSH_OP__MOVE: TRUE iff the + * target is to be moved to + * its main address. + */ + size_t size; /* New target size in the + * FLUSH_OP__MOVE operation. + * Unused elsewhere. + */ + unsigned *order_ptr; /* Pointer to outside counter for + * recording the order of entries + * flushed. + */ } flush_op; typedef enum test_entry_action_t { - TEST_ENTRY_ACTION_NUL = 0, /* No action on entry */ - TEST_ENTRY_ACTION_MOVE /* Entry is beging moved */ + TEST_ENTRY_ACTION_NUL = 0, /* No action on entry */ + TEST_ENTRY_ACTION_MOVE /* Entry is beging moved */ } test_entry_action_t; -typedef struct test_entry_t -{ - H5C_cache_entry_t header; /* entry data used by the cache - * -- must be first - */ - struct test_entry_t * self; /* pointer to this entry -- used for - * sanity checking. - */ - test_entry_action_t action; /* Action being performed on a test entry */ - H5F_t * file_ptr; /* pointer to the file in which the - * entry resides, or NULL if the entry - * is not in a file. - */ - H5C_t * cache_ptr; /* pointer to the cache in which - * the entry resides, or NULL if the - * entry is not in cache. - */ - hbool_t written_to_main_addr; - /* Flag indicating whether an image - * of the entry has been written to - * its main address. Since we no - * longer have a flush callback, we - * set this field to true whenever the - * entry is serialized while at its - * main address. - */ - hbool_t written_to_alt_addr; - /* Flag indicating whether an image - * of the entry has been written to - * its alternate address. Since we no - * longer have a flush callback, we - * set this field to true whenever the - * entry is serialized while at its - * alternate address. - */ - haddr_t addr; /* where the cache thinks this entry - * is located - */ - hbool_t at_main_addr; /* boolean flag indicating whether - * the entry is supposed to be at - * either its main or alternate - * address. - */ - haddr_t main_addr; /* initial location of the entry - */ - haddr_t alt_addr; /* location to which the entry - * can be relocated or "moved" - */ - size_t size; /* how big the cache thinks this - * entry is - */ - int32_t type; /* indicates which entry array this - * entry is in - */ - int32_t index; /* index in its entry array - */ - int32_t serializes; /* number of times this entry has - * been serialized. - */ - int32_t deserializes; /* number of times this entry has - * been deserialized - */ - hbool_t is_dirty; /* entry has been modified since - * last write - */ - hbool_t is_protected; /* entry should currently be on - * the cache's protected list. - */ - hbool_t is_read_only; /* TRUE iff the entry should be - * protected read only. - */ - int ro_ref_count; /* Number of outstanding read only - * protects on the entry. - */ - hbool_t is_pinned; /* entry is currently pinned in - * the cache. - */ - haddr_t tag; /* the base_addr as tag for corking entries */ - hbool_t is_corked; /* entry is currently corked or not */ - int pinning_ref_count; /* Number of entries that - * pin this entry in the cache. - * When this count drops to zero, - * this entry should be unpinned. - */ - int num_pins; /* Number of entries that this - * entry pins in the cache. This - * value must be in the range - * [0, MAX_PINS]. - */ - int pin_type[MAX_PINS]; /* array of the types of entries - * pinned by this entry. - */ - int pin_idx[MAX_PINS]; /* array of the indicies of - * entries pinned by this entry. - */ - int num_flush_ops; /* integer field containing the - * number of flush operations to - * be executed when the entry is - * flushed. This value must lie in - * the closed interval - * [0, MAX_FLUSH_OPS]. - */ - struct flush_op flush_ops[MAX_FLUSH_OPS]; /* Array of instances - * of struct flush_op detailing the - * flush operations (if any) that - * are to be executed when the entry - * is flushed from the cache. - * - * num_flush_ops contains the number - * of valid entries in this array. - */ - hbool_t flush_op_self_resize_in_progress; /* Boolean flag - * that is set to TRUE iff this - * entry is being flushed, it has - * been resized by a resize flush - * op, and the flush function has - * not yet returned, This field is - * used to turn off overactive santity - * checking code that would otherwise - * cause a false test failure. - */ - hbool_t deserialized; /* entry has been deserialized since - * the last time it was reset. - */ - hbool_t serialized; /* entry has been serialized since the - * last time it was reset. - */ - hbool_t destroyed; /* entry has been destroyed since the - * last time it was reset. - */ - hbool_t expunged; /* entry has been expunged since the - * last time it was reset. - */ - int flush_dep_par_type[MAX_FLUSH_DEP_PARS]; /* Entry types of flush dependency parents */ - int flush_dep_par_idx[MAX_FLUSH_DEP_PARS]; /* Indices of flush dependency parents */ - unsigned flush_dep_npar; /* Number of flush dependency parents */ - unsigned flush_dep_nchd; /* Number of flush dependency children */ - unsigned flush_dep_ndirty_chd; /* Number of dirty flush dependency children (including granchildren, etc.) */ - hbool_t pinned_from_client; /* entry was pinned by client call */ - hbool_t pinned_from_cache; /* entry was pinned by cache internally */ - unsigned flush_order; /* Order that entry was flushed in */ - - unsigned notify_after_insert_count; /* Count of times that entry was inserted in cache */ - unsigned notify_before_evict_count; /* Count of times that entry was removed in cache */ - size_t actual_len; /* Simulate the entry's actual size for a speculative load */ - unsigned max_verify_ct; /* Maximum # of times to verify an entry's checksum */ - unsigned verify_ct; /* Count the # of checksum verification for an entry */ +typedef struct test_entry_t { + H5C_cache_entry_t header; /* entry data used by the cache + * -- must be first + */ + struct test_entry_t *self; /* pointer to this entry -- used for + * sanity checking. + */ + test_entry_action_t action; /* Action being performed on a test entry */ + H5F_t * file_ptr; /* pointer to the file in which the + * entry resides, or NULL if the entry + * is not in a file. + */ + H5C_t *cache_ptr; /* pointer to the cache in which + * the entry resides, or NULL if the + * entry is not in cache. + */ + hbool_t written_to_main_addr; + /* Flag indicating whether an image + * of the entry has been written to + * its main address. Since we no + * longer have a flush callback, we + * set this field to true whenever the + * entry is serialized while at its + * main address. + */ + hbool_t written_to_alt_addr; + /* Flag indicating whether an image + * of the entry has been written to + * its alternate address. Since we no + * longer have a flush callback, we + * set this field to true whenever the + * entry is serialized while at its + * alternate address. + */ + haddr_t addr; /* where the cache thinks this entry + * is located + */ + hbool_t at_main_addr; /* boolean flag indicating whether + * the entry is supposed to be at + * either its main or alternate + * address. + */ + haddr_t main_addr; /* initial location of the entry + */ + haddr_t alt_addr; /* location to which the entry + * can be relocated or "moved" + */ + size_t size; /* how big the cache thinks this + * entry is + */ + int32_t type; /* indicates which entry array this + * entry is in + */ + int32_t index; /* index in its entry array + */ + int32_t serializes; /* number of times this entry has + * been serialized. + */ + int32_t deserializes; /* number of times this entry has + * been deserialized + */ + hbool_t is_dirty; /* entry has been modified since + * last write + */ + hbool_t is_protected; /* entry should currently be on + * the cache's protected list. + */ + hbool_t is_read_only; /* TRUE iff the entry should be + * protected read only. + */ + int ro_ref_count; /* Number of outstanding read only + * protects on the entry. + */ + hbool_t is_pinned; /* entry is currently pinned in + * the cache. + */ + haddr_t tag; /* the base_addr as tag for corking entries */ + hbool_t is_corked; /* entry is currently corked or not */ + int pinning_ref_count; /* Number of entries that + * pin this entry in the cache. + * When this count drops to zero, + * this entry should be unpinned. + */ + int num_pins; /* Number of entries that this + * entry pins in the cache. This + * value must be in the range + * [0, MAX_PINS]. + */ + int pin_type[MAX_PINS]; /* array of the types of entries + * pinned by this entry. + */ + int pin_idx[MAX_PINS]; /* array of the indicies of + * entries pinned by this entry. + */ + int num_flush_ops; /* integer field containing the + * number of flush operations to + * be executed when the entry is + * flushed. This value must lie in + * the closed interval + * [0, MAX_FLUSH_OPS]. + */ + struct flush_op flush_ops[MAX_FLUSH_OPS]; /* Array of instances + * of struct flush_op detailing the + * flush operations (if any) that + * are to be executed when the entry + * is flushed from the cache. + * + * num_flush_ops contains the number + * of valid entries in this array. + */ + hbool_t flush_op_self_resize_in_progress; /* Boolean flag + * that is set to TRUE iff this + * entry is being flushed, it has + * been resized by a resize flush + * op, and the flush function has + * not yet returned, This field is + * used to turn off overactive santity + * checking code that would otherwise + * cause a false test failure. + */ + hbool_t deserialized; /* entry has been deserialized since + * the last time it was reset. + */ + hbool_t serialized; /* entry has been serialized since the + * last time it was reset. + */ + hbool_t destroyed; /* entry has been destroyed since the + * last time it was reset. + */ + hbool_t expunged; /* entry has been expunged since the + * last time it was reset. + */ + int flush_dep_par_type[MAX_FLUSH_DEP_PARS]; /* Entry types of flush dependency parents */ + int flush_dep_par_idx[MAX_FLUSH_DEP_PARS]; /* Indices of flush dependency parents */ + unsigned flush_dep_npar; /* Number of flush dependency parents */ + unsigned flush_dep_nchd; /* Number of flush dependency children */ + unsigned + flush_dep_ndirty_chd; /* Number of dirty flush dependency children (including granchildren, etc.) */ + hbool_t pinned_from_client; /* entry was pinned by client call */ + hbool_t pinned_from_cache; /* entry was pinned by cache internally */ + unsigned flush_order; /* Order that entry was flushed in */ + + unsigned notify_after_insert_count; /* Count of times that entry was inserted in cache */ + unsigned notify_before_evict_count; /* Count of times that entry was removed in cache */ + size_t actual_len; /* Simulate the entry's actual size for a speculative load */ + unsigned max_verify_ct; /* Maximum # of times to verify an entry's checksum */ + unsigned verify_ct; /* Count the # of checksum verification for an entry */ } test_entry_t; /* The following are cut down test versions of the hash table manipulation @@ -371,181 +355,149 @@ typedef struct test_entry_t * updated as necessary. */ -#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) - -#define H5C_TEST__PRE_HT_SEARCH_SC(cache_ptr, Addr) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( ! H5F_addr_defined(Addr) ) || \ - ( H5C__HASH_FCN(Addr) < 0 ) || \ - ( H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN ) ) { \ - HDfprintf(stdout, "Pre HT search SC failed.\n"); \ -} - -#define H5C_TEST__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len < 1 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( ((cache_ptr)->index)[k] == NULL ) || \ - ( ( ((cache_ptr)->index)[k] != (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev == NULL ) ) || \ - ( ( ((cache_ptr)->index)[k] == (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev != NULL ) ) || \ - ( ( (entry_ptr)->ht_prev != NULL ) && \ - ( (entry_ptr)->ht_prev->ht_next != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->ht_next != NULL ) && \ - ( (entry_ptr)->ht_next->ht_prev != (entry_ptr) ) ) ) { \ - HDfprintf(stdout, "Post successful HT search SC failed.\n"); \ -} - -#define H5C_TEST__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k) \ -if ( ( (cache_ptr) == NULL ) || \ - ( ((cache_ptr)->index)[k] != (entry_ptr) ) || \ - ( (entry_ptr)->ht_prev != NULL ) ) { \ - HDfprintf(stdout, "Post HT shift to front failed.\n"); \ -} - -#define H5C_TEST__SEARCH_INDEX(cache_ptr, Addr, entry_ptr) \ -{ \ - int k; \ - H5C_TEST__PRE_HT_SEARCH_SC(cache_ptr, Addr) \ - k = H5C__HASH_FCN(Addr); \ - entry_ptr = ((cache_ptr)->index)[k]; \ - while ( entry_ptr ) \ - { \ - if ( H5F_addr_eq(Addr, (entry_ptr)->addr) ) \ - { \ - H5C_TEST__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k) \ - if ( entry_ptr != ((cache_ptr)->index)[k] ) \ - { \ - if ( (entry_ptr)->ht_next ) \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - HDassert( (entry_ptr)->ht_prev != NULL ); \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ - (entry_ptr)->ht_prev = NULL; \ - ((cache_ptr)->index)[k] = (entry_ptr); \ - H5C_TEST__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k) \ - } \ - break; \ - } \ - (entry_ptr) = (entry_ptr)->ht_next; \ - } \ -} - +#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) + +#define H5C_TEST__PRE_HT_SEARCH_SC(cache_ptr, Addr) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + (!H5F_addr_defined(Addr)) || (H5C__HASH_FCN(Addr) < 0) || \ + (H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN)) { \ + HDfprintf(stdout, "Pre HT search SC failed.\n"); \ + } + +#define H5C_TEST__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k) \ + if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((cache_ptr)->index_len < 1) || \ + ((entry_ptr) == NULL) || ((cache_ptr)->index_size < (entry_ptr)->size) || \ + ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ + ((entry_ptr)->size <= 0) || (((cache_ptr)->index)[k] == NULL) || \ + ((((cache_ptr)->index)[k] != (entry_ptr)) && ((entry_ptr)->ht_prev == NULL)) || \ + ((((cache_ptr)->index)[k] == (entry_ptr)) && ((entry_ptr)->ht_prev != NULL)) || \ + (((entry_ptr)->ht_prev != NULL) && ((entry_ptr)->ht_prev->ht_next != (entry_ptr))) || \ + (((entry_ptr)->ht_next != NULL) && ((entry_ptr)->ht_next->ht_prev != (entry_ptr)))) { \ + HDfprintf(stdout, "Post successful HT search SC failed.\n"); \ + } + +#define H5C_TEST__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k) \ + if (((cache_ptr) == NULL) || (((cache_ptr)->index)[k] != (entry_ptr)) || \ + ((entry_ptr)->ht_prev != NULL)) { \ + HDfprintf(stdout, "Post HT shift to front failed.\n"); \ + } + +#define H5C_TEST__SEARCH_INDEX(cache_ptr, Addr, entry_ptr) \ + { \ + int k; \ + H5C_TEST__PRE_HT_SEARCH_SC(cache_ptr, Addr) \ + k = H5C__HASH_FCN(Addr); \ + entry_ptr = ((cache_ptr)->index)[k]; \ + while (entry_ptr) { \ + if (H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ + H5C_TEST__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k) \ + if (entry_ptr != ((cache_ptr)->index)[k]) { \ + if ((entry_ptr)->ht_next) \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + HDassert((entry_ptr)->ht_prev != NULL); \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ + (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ + (entry_ptr)->ht_prev = NULL; \ + ((cache_ptr)->index)[k] = (entry_ptr); \ + H5C_TEST__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k) \ + } \ + break; \ + } \ + (entry_ptr) = (entry_ptr)->ht_next; \ + } \ + } /* Macros used in H5AC level tests */ -#define CACHE_CONFIGS_EQUAL(a, b, cmp_set_init, cmp_init_size) \ - ( ( (a).version == (b).version ) && \ - ( (a).rpt_fcn_enabled == (b).rpt_fcn_enabled ) && \ - ( (a).open_trace_file == (b).open_trace_file ) && \ - ( (a).close_trace_file == (b).close_trace_file ) && \ - ( ( (a).open_trace_file == FALSE ) || \ - ( strcmp((a).trace_file_name, (b).trace_file_name) == 0 ) ) && \ - ( (a).evictions_enabled == (b).evictions_enabled ) && \ - ( ( ! cmp_set_init ) || \ - ( (a).set_initial_size == (b).set_initial_size ) ) && \ - ( ( ! cmp_init_size ) || \ - ( (a).initial_size == (b).initial_size ) ) && \ - ( H5_DBL_ABS_EQUAL((a).min_clean_fraction, (b).min_clean_fraction) ) && \ - ( (a).max_size == (b).max_size ) && \ - ( (a).min_size == (b).min_size ) && \ - ( (a).epoch_length == (b).epoch_length ) && \ - ( (a).incr_mode == (b).incr_mode ) && \ - ( H5_DBL_ABS_EQUAL((a).lower_hr_threshold, (b).lower_hr_threshold) ) && \ - ( H5_DBL_ABS_EQUAL((a).increment, (b).increment) ) && \ - ( (a).apply_max_increment == (b).apply_max_increment ) && \ - ( (a).max_increment == (b).max_increment ) && \ - ( (a).flash_incr_mode == (b).flash_incr_mode ) && \ - ( H5_DBL_ABS_EQUAL((a).flash_multiple, (b).flash_multiple) ) && \ - ( H5_DBL_ABS_EQUAL((a).flash_threshold, (b).flash_threshold) ) && \ - ( (a).decr_mode == (b).decr_mode ) && \ - ( H5_DBL_ABS_EQUAL((a).upper_hr_threshold, (b).upper_hr_threshold) ) && \ - ( H5_DBL_ABS_EQUAL((a).decrement, (b).decrement) ) && \ - ( (a).apply_max_decrement == (b).apply_max_decrement ) && \ - ( (a).max_decrement == (b).max_decrement ) && \ - ( (a).epochs_before_eviction == (b).epochs_before_eviction ) && \ - ( (a).apply_empty_reserve == (b).apply_empty_reserve ) && \ - ( H5_DBL_ABS_EQUAL((a).empty_reserve, (b).empty_reserve) ) && \ - ( (a).dirty_bytes_threshold == (b).dirty_bytes_threshold ) && \ - ( (a).metadata_write_strategy == (b).metadata_write_strategy ) ) - -#define XLATE_EXT_TO_INT_MDC_CONFIG(i, e) \ -{ \ - (i).version = H5C__CURR_AUTO_SIZE_CTL_VER; \ - if ( (e).rpt_fcn_enabled ) \ - (i).rpt_fcn = H5C_def_auto_resize_rpt_fcn; \ - else \ - (i).rpt_fcn = NULL; \ - (i).set_initial_size = (e).set_initial_size; \ - (i).initial_size = (e).initial_size; \ - (i).min_clean_fraction = (e).min_clean_fraction; \ - (i).max_size = (e).max_size; \ - (i).min_size = (e).min_size; \ - (i).epoch_length = (long int)((e).epoch_length); \ - (i).incr_mode = (e).incr_mode; \ - (i).lower_hr_threshold = (e).lower_hr_threshold; \ - (i).increment = (e).increment; \ - (i).apply_max_increment = (e).apply_max_increment; \ - (i).max_increment = (e).max_increment; \ - (i).flash_incr_mode = (e).flash_incr_mode; \ - (i).flash_multiple = (e).flash_multiple; \ - (i).flash_threshold = (e).flash_threshold; \ - (i).decr_mode = (e).decr_mode; \ - (i).upper_hr_threshold = (e).upper_hr_threshold; \ - (i).decrement = (e).decrement; \ - (i).apply_max_decrement = (e).apply_max_decrement; \ - (i).max_decrement = (e).max_decrement; \ - (i).epochs_before_eviction = (int)((e).epochs_before_eviction); \ - (i).apply_empty_reserve = (e).apply_empty_reserve; \ - (i).empty_reserve = (e).empty_reserve; \ -} - +#define CACHE_CONFIGS_EQUAL(a, b, cmp_set_init, cmp_init_size) \ + (((a).version == (b).version) && ((a).rpt_fcn_enabled == (b).rpt_fcn_enabled) && \ + ((a).open_trace_file == (b).open_trace_file) && ((a).close_trace_file == (b).close_trace_file) && \ + (((a).open_trace_file == FALSE) || (strcmp((a).trace_file_name, (b).trace_file_name) == 0)) && \ + ((a).evictions_enabled == (b).evictions_enabled) && \ + ((!cmp_set_init) || ((a).set_initial_size == (b).set_initial_size)) && \ + ((!cmp_init_size) || ((a).initial_size == (b).initial_size)) && \ + (H5_DBL_ABS_EQUAL((a).min_clean_fraction, (b).min_clean_fraction)) && ((a).max_size == (b).max_size) && \ + ((a).min_size == (b).min_size) && ((a).epoch_length == (b).epoch_length) && \ + ((a).incr_mode == (b).incr_mode) && \ + (H5_DBL_ABS_EQUAL((a).lower_hr_threshold, (b).lower_hr_threshold)) && \ + (H5_DBL_ABS_EQUAL((a).increment, (b).increment)) && \ + ((a).apply_max_increment == (b).apply_max_increment) && ((a).max_increment == (b).max_increment) && \ + ((a).flash_incr_mode == (b).flash_incr_mode) && \ + (H5_DBL_ABS_EQUAL((a).flash_multiple, (b).flash_multiple)) && \ + (H5_DBL_ABS_EQUAL((a).flash_threshold, (b).flash_threshold)) && ((a).decr_mode == (b).decr_mode) && \ + (H5_DBL_ABS_EQUAL((a).upper_hr_threshold, (b).upper_hr_threshold)) && \ + (H5_DBL_ABS_EQUAL((a).decrement, (b).decrement)) && \ + ((a).apply_max_decrement == (b).apply_max_decrement) && ((a).max_decrement == (b).max_decrement) && \ + ((a).epochs_before_eviction == (b).epochs_before_eviction) && \ + ((a).apply_empty_reserve == (b).apply_empty_reserve) && \ + (H5_DBL_ABS_EQUAL((a).empty_reserve, (b).empty_reserve)) && \ + ((a).dirty_bytes_threshold == (b).dirty_bytes_threshold) && \ + ((a).metadata_write_strategy == (b).metadata_write_strategy)) + +#define XLATE_EXT_TO_INT_MDC_CONFIG(i, e) \ + { \ + (i).version = H5C__CURR_AUTO_SIZE_CTL_VER; \ + if ((e).rpt_fcn_enabled) \ + (i).rpt_fcn = H5C_def_auto_resize_rpt_fcn; \ + else \ + (i).rpt_fcn = NULL; \ + (i).set_initial_size = (e).set_initial_size; \ + (i).initial_size = (e).initial_size; \ + (i).min_clean_fraction = (e).min_clean_fraction; \ + (i).max_size = (e).max_size; \ + (i).min_size = (e).min_size; \ + (i).epoch_length = (long int)((e).epoch_length); \ + (i).incr_mode = (e).incr_mode; \ + (i).lower_hr_threshold = (e).lower_hr_threshold; \ + (i).increment = (e).increment; \ + (i).apply_max_increment = (e).apply_max_increment; \ + (i).max_increment = (e).max_increment; \ + (i).flash_incr_mode = (e).flash_incr_mode; \ + (i).flash_multiple = (e).flash_multiple; \ + (i).flash_threshold = (e).flash_threshold; \ + (i).decr_mode = (e).decr_mode; \ + (i).upper_hr_threshold = (e).upper_hr_threshold; \ + (i).decrement = (e).decrement; \ + (i).apply_max_decrement = (e).apply_max_decrement; \ + (i).max_decrement = (e).max_decrement; \ + (i).epochs_before_eviction = (int)((e).epochs_before_eviction); \ + (i).apply_empty_reserve = (e).apply_empty_reserve; \ + (i).empty_reserve = (e).empty_reserve; \ + } /* misc type definitions */ -struct expected_entry_status -{ - int entry_type; - int entry_index; - size_t size; - hbool_t in_cache; - hbool_t at_main_addr; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - hbool_t deserialized; - hbool_t serialized; - hbool_t destroyed; - int flush_dep_par_type[MAX_FLUSH_DEP_PARS]; /* Entry types of flush dependency parents */ - int flush_dep_par_idx[MAX_FLUSH_DEP_PARS]; /* Indices of flush dependency parents */ - unsigned flush_dep_npar; /* Number of flush dependency parents */ - unsigned flush_dep_nchd; /* Number of flush dependency children */ - unsigned flush_dep_ndirty_chd; /* Number of dirty flush dependency children */ - int flush_order; /* flush order of entry */ - unsigned char is_corked; /* cork status of entry */ +struct expected_entry_status { + int entry_type; + int entry_index; + size_t size; + hbool_t in_cache; + hbool_t at_main_addr; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + hbool_t deserialized; + hbool_t serialized; + hbool_t destroyed; + int flush_dep_par_type[MAX_FLUSH_DEP_PARS]; /* Entry types of flush dependency parents */ + int flush_dep_par_idx[MAX_FLUSH_DEP_PARS]; /* Indices of flush dependency parents */ + unsigned flush_dep_npar; /* Number of flush dependency parents */ + unsigned flush_dep_nchd; /* Number of flush dependency children */ + unsigned flush_dep_ndirty_chd; /* Number of dirty flush dependency children */ + int flush_order; /* flush order of entry */ + unsigned char is_corked; /* cork status of entry */ }; - - - /* global variable externs: */ -H5TEST_DLLVAR hbool_t pass; /* set to false on error */ +H5TEST_DLLVAR hbool_t pass; /* set to false on error */ H5TEST_DLLVAR const char *failure_mssg; H5TEST_DLLVAR const char *last_failure_mssg; -H5TEST_DLLVAR test_entry_t * entries[NUMBER_OF_ENTRY_TYPES]; +H5TEST_DLLVAR test_entry_t *entries[NUMBER_OF_ENTRY_TYPES]; H5TEST_DLLVAR const int32_t max_indices[NUMBER_OF_ENTRY_TYPES]; -H5TEST_DLLVAR const size_t entry_sizes[NUMBER_OF_ENTRY_TYPES]; +H5TEST_DLLVAR const size_t entry_sizes[NUMBER_OF_ENTRY_TYPES]; H5TEST_DLLVAR const haddr_t base_addrs[NUMBER_OF_ENTRY_TYPES]; H5TEST_DLLVAR const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES]; @@ -553,74 +505,42 @@ H5TEST_DLLVAR const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES]; H5TEST_DLLVAR const H5C_class_t *types[NUMBER_OF_ENTRY_TYPES]; - #ifdef __cplusplus extern "C" { #endif /* function declarations: */ -H5TEST_DLL void add_flush_op(int target_type, - int target_idx, - int op_code, - int type, - int idx, - hbool_t flag, - size_t size, - unsigned * order); +H5TEST_DLL void add_flush_op(int target_type, int target_idx, int op_code, int type, int idx, hbool_t flag, + size_t size, unsigned *order); - -H5TEST_DLL void addr_to_type_and_index(haddr_t addr, - int32_t * type_ptr, - int32_t * index_ptr); +H5TEST_DLL void addr_to_type_and_index(haddr_t addr, int32_t *type_ptr, int32_t *index_ptr); #if 0 /* keep this for a while -- it may be useful */ H5TEST_DLL haddr_t type_and_index_to_addr(int32_t type, int32_t idx); #endif -H5TEST_DLL void dirty_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx, - hbool_t dirty_pin); +H5TEST_DLL void dirty_entry(H5F_t *file_ptr, int32_t type, int32_t idx, hbool_t dirty_pin); -H5TEST_DLL void expunge_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx); +H5TEST_DLL void expunge_entry(H5F_t *file_ptr, int32_t type, int32_t idx); -H5TEST_DLL void insert_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx, - unsigned int flags); +H5TEST_DLL void insert_entry(H5F_t *file_ptr, int32_t type, int32_t idx, unsigned int flags); -H5TEST_DLL void mark_entry_dirty(int32_t type, - int32_t idx); +H5TEST_DLL void mark_entry_dirty(int32_t type, int32_t idx); -H5TEST_DLL void move_entry(H5C_t * cache_ptr, - int32_t type, - int32_t idx, - hbool_t main_addr); +H5TEST_DLL void move_entry(H5C_t *cache_ptr, int32_t type, int32_t idx, hbool_t main_addr); -H5TEST_DLL void protect_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx); +H5TEST_DLL void protect_entry(H5F_t *file_ptr, int32_t type, int32_t idx); -H5TEST_DLL void protect_entry_ro(H5F_t * file_ptr, - int32_t type, - int32_t idx); +H5TEST_DLL void protect_entry_ro(H5F_t *file_ptr, int32_t type, int32_t idx); -H5TEST_DLL void pin_entry(int32_t type, - int32_t idx); +H5TEST_DLL void pin_entry(int32_t type, int32_t idx); -H5TEST_DLL hbool_t entry_in_cache(H5C_t * cache_ptr, - int32_t type, - int32_t idx); +H5TEST_DLL hbool_t entry_in_cache(H5C_t *cache_ptr, int32_t type, int32_t idx); -H5TEST_DLL void create_pinned_entry_dependency(H5F_t * file_ptr, - int pinning_type, - int pinning_idx, - int pinned_type, - int pinned_idx); +H5TEST_DLL void create_pinned_entry_dependency(H5F_t *file_ptr, int pinning_type, int pinning_idx, + int pinned_type, int pinned_idx); H5TEST_DLL herr_t create_entry_arrays(void); @@ -628,154 +548,87 @@ H5TEST_DLL void free_entry_arrays(void); H5TEST_DLL void reset_entries(void); -H5TEST_DLL void cork_entry_type(H5F_t * file_ptr, int32_t type); - -H5TEST_DLL void uncork_entry_type(H5F_t * file_ptr, int32_t type); - -H5TEST_DLL void resize_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx, - size_t new_size, - hbool_t in_cache); - -H5TEST_DLL void row_major_scan_forward(H5F_t * file_ptr, - int32_t max_index, - int32_t lag, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, - hbool_t do_moves, - hbool_t move_to_main_addr, - hbool_t do_destroys, - hbool_t do_mult_ro_protects, - int dirty_destroys, - int dirty_unprotects); - -H5TEST_DLL void hl_row_major_scan_forward(H5F_t * file_ptr, - int32_t max_index, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts); - -H5TEST_DLL void row_major_scan_backward(H5F_t * file_ptr, - int32_t max_index, - int32_t lag, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, - hbool_t do_moves, - hbool_t move_to_main_addr, - hbool_t do_destroys, - hbool_t do_mult_ro_protects, - int dirty_destroys, - int dirty_unprotects); - -H5TEST_DLL void hl_row_major_scan_backward(H5F_t * file_ptr, - int32_t max_index, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts); - -H5TEST_DLL void col_major_scan_forward(H5F_t * file_ptr, - int32_t max_index, - int32_t lag, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, - int dirty_unprotects); - -H5TEST_DLL void hl_col_major_scan_forward(H5F_t * file_ptr, - int32_t max_index, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, - int dirty_unprotects); - -H5TEST_DLL void col_major_scan_backward(H5F_t * file_ptr, - int32_t max_index, - int32_t lag, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, - int dirty_unprotects); - -H5TEST_DLL void hl_col_major_scan_backward(H5F_t * file_ptr, - int32_t max_index, - hbool_t verbose, - hbool_t reset_stats, - hbool_t display_stats, - hbool_t display_detailed_stats, - hbool_t do_inserts, - int dirty_unprotects); - -H5TEST_DLL void flush_cache(H5F_t * file_ptr, - hbool_t destroy_entries, - hbool_t dump_stats, - hbool_t dump_detailed_stats); - -H5TEST_DLL void unpin_entry(int32_t type, - int32_t idx); - -H5TEST_DLL void unprotect_entry(H5F_t * file_ptr, - int32_t type, - int32_t idx, - unsigned int flags); +H5TEST_DLL void cork_entry_type(H5F_t *file_ptr, int32_t type); + +H5TEST_DLL void uncork_entry_type(H5F_t *file_ptr, int32_t type); + +H5TEST_DLL void resize_entry(H5F_t *file_ptr, int32_t type, int32_t idx, size_t new_size, hbool_t in_cache); + +H5TEST_DLL void row_major_scan_forward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t verbose, + hbool_t reset_stats, hbool_t display_stats, + hbool_t display_detailed_stats, hbool_t do_inserts, hbool_t do_moves, + hbool_t move_to_main_addr, hbool_t do_destroys, + hbool_t do_mult_ro_protects, int dirty_destroys, int dirty_unprotects); + +H5TEST_DLL void hl_row_major_scan_forward(H5F_t *file_ptr, int32_t max_index, hbool_t verbose, + hbool_t reset_stats, hbool_t display_stats, + hbool_t display_detailed_stats, hbool_t do_inserts); + +H5TEST_DLL void row_major_scan_backward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t verbose, + hbool_t reset_stats, hbool_t display_stats, + hbool_t display_detailed_stats, hbool_t do_inserts, hbool_t do_moves, + hbool_t move_to_main_addr, hbool_t do_destroys, + hbool_t do_mult_ro_protects, int dirty_destroys, + int dirty_unprotects); + +H5TEST_DLL void hl_row_major_scan_backward(H5F_t *file_ptr, int32_t max_index, hbool_t verbose, + hbool_t reset_stats, hbool_t display_stats, + hbool_t display_detailed_stats, hbool_t do_inserts); + +H5TEST_DLL void col_major_scan_forward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t verbose, + hbool_t reset_stats, hbool_t display_stats, + hbool_t display_detailed_stats, hbool_t do_inserts, + int dirty_unprotects); + +H5TEST_DLL void hl_col_major_scan_forward(H5F_t *file_ptr, int32_t max_index, hbool_t verbose, + hbool_t reset_stats, hbool_t display_stats, + hbool_t display_detailed_stats, hbool_t do_inserts, + int dirty_unprotects); + +H5TEST_DLL void col_major_scan_backward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t verbose, + hbool_t reset_stats, hbool_t display_stats, + hbool_t display_detailed_stats, hbool_t do_inserts, + int dirty_unprotects); + +H5TEST_DLL void hl_col_major_scan_backward(H5F_t *file_ptr, int32_t max_index, hbool_t verbose, + hbool_t reset_stats, hbool_t display_stats, + hbool_t display_detailed_stats, hbool_t do_inserts, + int dirty_unprotects); + +H5TEST_DLL void flush_cache(H5F_t *file_ptr, hbool_t destroy_entries, hbool_t dump_stats, + hbool_t dump_detailed_stats); + +H5TEST_DLL void unpin_entry(int32_t type, int32_t idx); + +H5TEST_DLL void unprotect_entry(H5F_t *file_ptr, int32_t type, int32_t idx, unsigned int flags); H5TEST_DLL void verify_clean(void); -H5TEST_DLL void verify_entry_status(H5C_t * cache_ptr, - int tag, - int num_entries, - struct expected_entry_status expected[]); +H5TEST_DLL void verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, + struct expected_entry_status expected[]); H5TEST_DLL void verify_unprotected(void); -H5TEST_DLL void create_flush_dependency(int32_t parent_type, - int32_t parent_idx, - int32_t child_type, - int32_t child_idx); +H5TEST_DLL void create_flush_dependency(int32_t parent_type, int32_t parent_idx, int32_t child_type, + int32_t child_idx); -H5TEST_DLL void destroy_flush_dependency(int32_t parent_type, - int32_t parent_idx, - int32_t child_type, - int32_t child_idx); +H5TEST_DLL void destroy_flush_dependency(int32_t parent_type, int32_t parent_idx, int32_t child_type, + int32_t child_idx); /*** H5AC level utility functions ***/ -H5TEST_DLL hbool_t resize_configs_are_equal(const H5C_auto_size_ctl_t *a, - const H5C_auto_size_ctl_t *b, hbool_t compare_init); +H5TEST_DLL hbool_t resize_configs_are_equal(const H5C_auto_size_ctl_t *a, const H5C_auto_size_ctl_t *b, + hbool_t compare_init); -H5TEST_DLL void check_and_validate_cache_hit_rate(hid_t file_id, - double * hit_rate_ptr, - hbool_t dump_data, - int64_t min_accesses, - double min_hit_rate); +H5TEST_DLL void check_and_validate_cache_hit_rate(hid_t file_id, double *hit_rate_ptr, hbool_t dump_data, + int64_t min_accesses, double min_hit_rate); -H5TEST_DLL void check_and_validate_cache_size(hid_t file_id, - size_t * max_size_ptr, - size_t * min_clean_size_ptr, - size_t * cur_size_ptr, - int32_t * cur_num_entries_ptr, - hbool_t dump_data); +H5TEST_DLL void check_and_validate_cache_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, int32_t *cur_num_entries_ptr, + hbool_t dump_data); -H5TEST_DLL void validate_mdc_config(hid_t file_id, - H5AC_cache_config_t * ext_config_ptr, - hbool_t compare_init, - int test_num); +H5TEST_DLL void validate_mdc_config(hid_t file_id, H5AC_cache_config_t *ext_config_ptr, hbool_t compare_init, + int test_num); /** Debugging functions -- normally commented out ***/ #if 0 @@ -787,4 +640,3 @@ H5TEST_DLL void dump_LRU(H5F_t * file_ptr); #endif #endif /* _CACHE_COMMON_H */ - diff --git a/test/cache_image.c b/test/cache_image.c index 5716f07..96263f8 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -22,22 +22,19 @@ /* global variable declarations: */ -const char *FILENAMES[] = { - "cache_image_test", - NULL -}; +const char *FILENAMES[] = {"cache_image_test", NULL}; static struct timespec lastmsgtime = {.tv_sec = 0, .tv_nsec = 0}; /* local utility function declarations */ static void create_datasets(hid_t file_id, int min_dset, int max_dset); static void delete_datasets(hid_t file_id, int min_dset, int max_dset); -static void open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, - hbool_t read_only, hbool_t set_mdci_fapl, hbool_t config_fsm, - hbool_t set_eoc, const char *hdf_file_name, unsigned cache_image_flags, - hid_t *file_id_ptr, H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr); -static void attempt_swmr_open_hdf5_file(hbool_t create_file, - hbool_t set_mdci_fapl, const char *hdf_file_name); +static void open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, hbool_t read_only, + hbool_t set_mdci_fapl, hbool_t config_fsm, hbool_t set_eoc, + const char *hdf_file_name, unsigned cache_image_flags, hid_t *file_id_ptr, + H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr); +static void attempt_swmr_open_hdf5_file(hbool_t create_file, hbool_t set_mdci_fapl, + const char *hdf_file_name); static void verify_datasets(hid_t file_id, int min_dset, int max_dset); /* local test function declarations */ @@ -63,7 +60,6 @@ static unsigned cache_image_api_error_check_4(hbool_t single_file_vfd); static unsigned get_free_sections_test(hbool_t single_file_vfd); static unsigned evict_on_close_test(hbool_t single_file_vfd); - /****************************************************************************/ /***************************** Utility Functions ****************************/ /****************************************************************************/ @@ -90,33 +86,34 @@ static unsigned evict_on_close_test(hbool_t single_file_vfd); *------------------------------------------------------------------------- */ -#define CHUNK_SIZE 10 -#define DSET_SIZE (40 * CHUNK_SIZE) -#define MAX_NUM_DSETS 256 +#define CHUNK_SIZE 10 +#define DSET_SIZE (40 * CHUNK_SIZE) +#define MAX_NUM_DSETS 256 static void create_datasets(hid_t file_id, int min_dset, int max_dset) { - const char * fcn_name = "create_datasets()"; - char dset_name[64]; - hbool_t show_progress = FALSE; - hbool_t valid_chunk; - hbool_t verbose = FALSE; - int cp = 0; - int i, j, k, l, m; - int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; - herr_t status; - hid_t dataspace_id = -1; - hid_t filespace_ids[MAX_NUM_DSETS]; - hid_t memspace_id = -1; - hid_t dataset_ids[MAX_NUM_DSETS]; - hid_t properties = -1; - hsize_t dims[2]; - hsize_t a_size[2]; - hsize_t offset[2]; - hsize_t chunk_size[2]; - - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + const char *fcn_name = "create_datasets()"; + char dset_name[64]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l, m; + int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; + herr_t status; + hid_t dataspace_id = -1; + hid_t filespace_ids[MAX_NUM_DSETS]; + hid_t memspace_id = -1; + hid_t dataset_ids[MAX_NUM_DSETS]; + hid_t properties = -1; + hsize_t dims[2]; + hsize_t a_size[2]; + hsize_t offset[2]; + hsize_t chunk_size[2]; + + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); HDassert(0 <= min_dset); HDassert(min_dset <= max_dset); @@ -124,20 +121,19 @@ create_datasets(hid_t file_id, int min_dset, int max_dset) /* create the datasets */ - if ( pass ) { + if (pass) { i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { + while ((pass) && (i <= max_dset)) { /* create a dataspace for the chunked dataset */ - dims[0] = DSET_SIZE; - dims[1] = DSET_SIZE; + dims[0] = DSET_SIZE; + dims[1] = DSET_SIZE; dataspace_id = H5Screate_simple(2, dims, NULL); - if ( dataspace_id < 0 ) { + if (dataspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } @@ -145,51 +141,50 @@ create_datasets(hid_t file_id, int min_dset, int max_dset) * to be partioned into 10X10 element chunks. */ - if ( pass ) { + if (pass) { chunk_size[0] = CHUNK_SIZE; chunk_size[1] = CHUNK_SIZE; - properties = H5Pcreate(H5P_DATASET_CREATE); + properties = H5Pcreate(H5P_DATASET_CREATE); - if ( properties < 0 ) { + if (properties < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate() failed."; } } - if ( pass ) { + if (pass) { - if ( H5Pset_chunk(properties, 2, chunk_size) < 0 ) { + if (H5Pset_chunk(properties, 2, chunk_size) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_chunk() failed."; } } /* create the dataset */ - if ( pass ) { + if (pass) { HDsprintf(dset_name, "/dset%03d", i); - dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, - dataspace_id, H5P_DEFAULT, + dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, properties, H5P_DEFAULT); - if ( dataset_ids[i] < 0 ) { + if (dataset_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dcreate() failed."; } } /* get the file space ID */ - if ( pass ) { + if (pass) { filespace_ids[i] = H5Dget_space(dataset_ids[i]); - if ( filespace_ids[i] < 0 ) { + if (filespace_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dget_space() failed."; } } @@ -198,84 +193,79 @@ create_datasets(hid_t file_id, int min_dset, int max_dset) } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* create the mem space to be used to read and write chunks */ - if ( pass ) { + if (pass) { - dims[0] = CHUNK_SIZE; - dims[1] = CHUNK_SIZE; + dims[0] = CHUNK_SIZE; + dims[1] = CHUNK_SIZE; memspace_id = H5Screate_simple(2, dims, NULL); - if ( memspace_id < 0 ) { + if (memspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* select in memory hyperslab */ - if ( pass ) { + if (pass) { - offset[0] = 0; /*offset of hyperslab in memory*/ + offset[0] = 0; /*offset of hyperslab in memory*/ offset[1] = 0; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, - a_size, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* initialize all datasets on a round robin basis */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { m = min_dset; - while ( ( pass ) && ( m <= max_dset ) ) - { + while ((pass) && (m <= max_dset)) { /* initialize the slab */ - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l; + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l; } } /* select on disk hyperslab */ offset[0] = (hsize_t)i; /*offset of hyperslab in file*/ offset[1] = (hsize_t)j; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "disk H5Sselect_hyperslab() failed."; } /* write the chunk to file */ - status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, - filespace_ids[m], H5P_DEFAULT, data_chunk); + status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, + data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dwrite() failed."; } m++; @@ -286,88 +276,75 @@ create_datasets(hid_t file_id, int min_dset, int max_dset) i += CHUNK_SIZE; } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* read data from datasets and validate it */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { m = min_dset; - while ( ( pass ) && ( m <= max_dset ) ) - { + while ((pass) && (m <= max_dset)) { /* select on disk hyperslab */ offset[0] = (hsize_t)i; /* offset of hyperslab in file */ offset[1] = (hsize_t)j; a_size[0] = CHUNK_SIZE; /* size of hyperslab */ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, - memspace_id, filespace_ids[m], + status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - if ( data_chunk[k][l] - != - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l) ) { + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + if (data_chunk[k][l] != + ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)) { valid_chunk = FALSE; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "data_chunk[%0d][%0d] = %0d, expect %0d.\n", - k, l, data_chunk[k][l], - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l)); - HDfprintf(stdout, - "m = %d, i = %d, j = %d, k = %d, l = %d\n", - m, i, j, k, l); - } + HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", k, l, + data_chunk[k][l], + ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)); + HDfprintf(stdout, "m = %d, i = %d, j = %d, k = %d, l = %d\n", m, i, j, k, + l); + } } } } - if ( ! valid_chunk ) { + if (!valid_chunk) { - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "Chunk (%0d, %0d) in /dset%03d is invalid.\n", - i, j, m); - } + HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", i, j, m); + } } } m++; @@ -377,39 +354,37 @@ create_datasets(hid_t file_id, int min_dset, int max_dset) i += CHUNK_SIZE; } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* close the file spaces */ i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { - if ( H5Sclose(filespace_ids[i]) < 0 ) { + while ((pass) && (i <= max_dset)) { + if (H5Sclose(filespace_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose() failed."; } i++; } - /* close the datasets */ i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { - if ( H5Dclose(dataset_ids[i]) < 0 ) { + while ((pass) && (i <= max_dset)) { + if (H5Dclose(dataset_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose() failed."; } i++; } /* close the mem space */ - if ( pass ) { + if (pass) { - if ( H5Sclose(memspace_id) < 0 ) { + if (H5Sclose(memspace_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(memspace_id) failed."; } } @@ -418,7 +393,6 @@ create_datasets(hid_t file_id, int min_dset, int max_dset) } /* create_datasets() */ - /*------------------------------------------------------------------------- * Function: delete_datasets() * @@ -445,51 +419,53 @@ create_datasets(hid_t file_id, int min_dset, int max_dset) static void delete_datasets(hid_t file_id, int min_dset, int max_dset) { - const char * fcn_name = "delete_datasets()"; - char dset_name[64]; - hbool_t show_progress = FALSE; - int cp = 0; - int i; + const char *fcn_name = "delete_datasets()"; + char dset_name[64]; + hbool_t show_progress = FALSE; + int cp = 0; + int i; - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); HDassert(0 <= min_dset); HDassert(min_dset <= max_dset); HDassert(max_dset < MAX_NUM_DSETS); - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* first, verify the contents of the target dataset(s) */ verify_datasets(file_id, min_dset, max_dset); - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* now delete the target datasets */ - if ( pass ) { + if (pass) { i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { + while ((pass) && (i <= max_dset)) { HDsprintf(dset_name, "/dset%03d", i); - if ( H5Ldelete(file_id, dset_name, H5P_DEFAULT) < 0) { + if (H5Ldelete(file_id, dset_name, H5P_DEFAULT) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Ldelete() failed."; - } + } i++; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); return; } /* delete_datasets() */ - /*------------------------------------------------------------------------- * Function: open_hdf5_file() * @@ -533,179 +509,169 @@ delete_datasets(hid_t file_id, int min_dset, int max_dset) */ static void -open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, - hbool_t read_only, hbool_t set_mdci_fapl, hbool_t config_fsm, - hbool_t set_eoc, const char *hdf_file_name, unsigned cache_image_flags, - hid_t *file_id_ptr, H5F_t ** file_ptr_ptr, H5C_t ** cache_ptr_ptr) +open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, hbool_t read_only, hbool_t set_mdci_fapl, + hbool_t config_fsm, hbool_t set_eoc, const char *hdf_file_name, unsigned cache_image_flags, + hid_t *file_id_ptr, H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr) { - const char * fcn_name = "open_hdf5_file()"; - hbool_t show_progress = FALSE; - hbool_t verbose = FALSE; - int cp = 0; - hid_t fapl_id = -1; - hid_t fcpl_id = -1; - hid_t file_id = -1; - herr_t result; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_cache_image_ctl_t image_ctl; - H5AC_cache_image_config_t cache_image_config = { - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, - FALSE, - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; - - if ( pass ) - { - /* opening the file both read only and with a cache image + const char * fcn_name = "open_hdf5_file()"; + hbool_t show_progress = FALSE; + hbool_t verbose = FALSE; + int cp = 0; + hid_t fapl_id = -1; + hid_t fcpl_id = -1; + hid_t file_id = -1; + herr_t result; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_cache_image_ctl_t image_ctl; + H5AC_cache_image_config_t cache_image_config = {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + + if (pass) { + /* opening the file both read only and with a cache image * requested is a contradiction. We resolve it by ignoring * the cache image request silently. */ - if ( ( create_file && mdci_sbem_expected ) || - ( create_file && read_only ) || - ( config_fsm && !create_file ) || - ( hdf_file_name == NULL ) || - ( ( set_mdci_fapl ) && ( cache_image_flags == 0 ) ) || - ( ( set_mdci_fapl ) && - ( (cache_image_flags & ~H5C_CI__ALL_FLAGS) != 0 ) ) || - ( file_id_ptr == NULL ) || - ( file_ptr_ptr == NULL ) || - ( cache_ptr_ptr == NULL ) ) { + if ((create_file && mdci_sbem_expected) || (create_file && read_only) || + (config_fsm && !create_file) || (hdf_file_name == NULL) || + ((set_mdci_fapl) && (cache_image_flags == 0)) || + ((set_mdci_fapl) && ((cache_image_flags & ~H5C_CI__ALL_FLAGS) != 0)) || (file_id_ptr == NULL) || + (file_ptr_ptr == NULL) || (cache_ptr_ptr == NULL)) { - failure_mssg = - "Bad param(s) on entry to open_hdf5_file().\n"; - pass = FALSE; - } else if ( verbose ) { + failure_mssg = "Bad param(s) on entry to open_hdf5_file().\n"; + pass = FALSE; + } + else if (verbose) { - HDfprintf(stdout, "%s: HDF file name = \"%s\".\n", - fcn_name, hdf_file_name); + HDfprintf(stdout, "%s: HDF file name = \"%s\".\n", fcn_name, hdf_file_name); } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* create a file access propertly list. */ - if ( pass ) { + if (pass) { fapl_id = h5_fileaccess(); - if ( fapl_id < 0 ) { + if (fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fileaccess() failed.\n"; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* call H5Pset_libver_bounds() on the fapl_id */ - if ( pass ) { + if (pass) { - if ( H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, - H5F_LIBVER_LATEST) < 0 ) { + if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_libver_bounds() failed.\n"; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* get metadata cache image config -- verify that it is the default */ - if ( pass ) { + if (pass) { result = H5Pget_mdc_image_config(fapl_id, &cache_image_config); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_image_config() failed.\n"; } - if ( ( cache_image_config.version != - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || - ( cache_image_config.generate_image != FALSE ) || - ( cache_image_config.save_resize_status != FALSE ) || - ( cache_image_config.entry_ageout != - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) ) { + if ((cache_image_config.version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) || + (cache_image_config.generate_image != FALSE) || + (cache_image_config.save_resize_status != FALSE) || + (cache_image_config.entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected default cache image config.\n"; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* set metadata cache image fapl entry if indicated */ - if ( ( pass ) && ( set_mdci_fapl ) ) { + if ((pass) && (set_mdci_fapl)) { /* set cache image config fields to taste */ - cache_image_config.generate_image = TRUE; + cache_image_config.generate_image = TRUE; cache_image_config.save_resize_status = FALSE; - cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; + cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; result = H5Pset_mdc_image_config(fapl_id, &cache_image_config); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_image_config() failed.\n"; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* setup the persistent free space manager if indicated */ - if ( ( pass ) && ( config_fsm ) ) { + if ((pass) && (config_fsm)) { - fcpl_id = H5Pcreate(H5P_FILE_CREATE); + fcpl_id = H5Pcreate(H5P_FILE_CREATE); - if ( fcpl_id <= 0 ) { + if (fcpl_id <= 0) { - pass = FALSE; - failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed."; - } + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed."; + } } - if ( ( pass ) && ( config_fsm ) ) { - if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, - TRUE, (hsize_t)1) < 0) { - pass = FALSE; + if ((pass) && (config_fsm)) { + if (H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) { + pass = FALSE; failure_mssg = "H5Pset_file_space_strategy() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* set evict on close if indicated */ - if ( ( pass ) && ( set_eoc ) ) { + if ((pass) && (set_eoc)) { - if ( H5Pset_evict_on_close(fapl_id, TRUE) < 0 ) { + if (H5Pset_evict_on_close(fapl_id, TRUE) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_evict_on_close() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* open the file */ - if ( pass ) { + if (pass) { - if ( create_file ) { + if (create_file) { - if ( fcpl_id != -1 ) + if (fcpl_id != -1) - file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, - fcpl_id, fapl_id); - else - - file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, - H5P_DEFAULT, fapl_id); + file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, fcpl_id, fapl_id); + else - } else { + file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + } + else { - if ( read_only ) + if (read_only) file_id = H5Fopen(hdf_file_name, H5F_ACC_RDONLY, fapl_id); @@ -717,46 +683,48 @@ open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, /* tidy up */ H5Pclose(fapl_id); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fcreate() or H5Fopen() failed.\n"; - - } else { + } + else { file_ptr = (struct H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr."; - if ( verbose ) { + if (verbose) { HDfprintf(stdout, "%s: Can't get file_ptr.\n", fcn_name); } } } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* get a pointer to the files internal data structure and then * to the cache structure */ - if ( pass ) { + if (pass) { - if ( file_ptr->shared->cache == NULL ) { + if (file_ptr->shared->cache == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "can't get cache pointer(1).\n"; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* verify expected metadata cache status */ @@ -765,134 +733,129 @@ open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, * * Then set the flags in this structure to the specified value. */ - if ( pass ) { + if (pass) { - if ( H5C_get_cache_image_config(cache_ptr, &image_ctl) < 0 ) { + if (H5C_get_cache_image_config(cache_ptr, &image_ctl) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "error returned by H5C_get_cache_image_config()."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); - if ( pass ) { + if (pass) { - if ( set_mdci_fapl ) { + if (set_mdci_fapl) { - if ( read_only ) { + if (read_only) { - if ( ( image_ctl.version != - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || - ( image_ctl.generate_image != FALSE ) || - ( image_ctl.save_resize_status != FALSE ) || - ( image_ctl.entry_ageout != - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || - ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + if ((image_ctl.version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) || + (image_ctl.generate_image != FALSE) || (image_ctl.save_resize_status != FALSE) || + (image_ctl.entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) || + (image_ctl.flags != H5C_CI__ALL_FLAGS)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected image_ctl values(1).\n"; } - } else { + } + else { - if ( ( image_ctl.version != - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || - ( image_ctl.generate_image != TRUE ) || - ( image_ctl.save_resize_status != FALSE ) || - ( image_ctl.entry_ageout != - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || - ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + if ((image_ctl.version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) || + (image_ctl.generate_image != TRUE) || (image_ctl.save_resize_status != FALSE) || + (image_ctl.entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) || + (image_ctl.flags != H5C_CI__ALL_FLAGS)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected image_ctl values(2).\n"; } } - } else { + } + else { - if ( ( image_ctl.version != - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || - ( image_ctl.generate_image != FALSE ) || - ( image_ctl.save_resize_status != FALSE ) || - ( image_ctl.entry_ageout != - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || - ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + if ((image_ctl.version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) || + (image_ctl.generate_image != FALSE) || (image_ctl.save_resize_status != FALSE) || + (image_ctl.entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) || + (image_ctl.flags != H5C_CI__ALL_FLAGS)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected image_ctl values(3).\n"; } } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); - if ( ( pass ) && ( set_mdci_fapl ) ) { + if ((pass) && (set_mdci_fapl)) { image_ctl.flags = cache_image_flags; - if ( H5C_set_cache_image_config(file_ptr, cache_ptr, &image_ctl) < 0 ) { + if (H5C_set_cache_image_config(file_ptr, cache_ptr, &image_ctl) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "error returned by H5C_set_cache_image_config()."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); - if ( pass ) { + if (pass) { - if ( cache_ptr->close_warning_received == TRUE ) { + if (cache_ptr->close_warning_received == TRUE) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected value of close_warning_received.\n"; } - if ( mdci_sbem_expected ) { + if (mdci_sbem_expected) { - if ( read_only ) { + if (read_only) { - if ( ( cache_ptr->load_image != TRUE ) || - ( cache_ptr->delete_image != FALSE ) ) { + if ((cache_ptr->load_image != TRUE) || (cache_ptr->delete_image != FALSE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "mdci sb extension message not present?\n"; } - } else { + } + else { - if ( ( cache_ptr->load_image != TRUE ) || - ( cache_ptr->delete_image != TRUE ) ) { + if ((cache_ptr->load_image != TRUE) || (cache_ptr->delete_image != TRUE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "mdci sb extension message not present?\n"; } + } } - } else { + else { - if ( ( cache_ptr->load_image == TRUE ) || - ( cache_ptr->delete_image == TRUE ) ) { + if ((cache_ptr->load_image == TRUE) || (cache_ptr->delete_image == TRUE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "mdci sb extension message present?\n"; - } + } } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); - if ( pass ) { + if (pass) { - *file_id_ptr = file_id; - *file_ptr_ptr = file_ptr; + *file_id_ptr = file_id; + *file_ptr_ptr = file_ptr; *cache_ptr_ptr = cache_ptr; } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d -- exiting.\n", fcn_name, cp++); return; } /* open_hdf5_file() */ - /*------------------------------------------------------------------------- * Function: attempt_swmr_open_hdf5_file() * @@ -913,99 +876,99 @@ open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, */ static void -attempt_swmr_open_hdf5_file(const hbool_t create_file, - const hbool_t set_mdci_fapl, - const char * hdf_file_name) +attempt_swmr_open_hdf5_file(const hbool_t create_file, const hbool_t set_mdci_fapl, const char *hdf_file_name) { - const char * fcn_name = "attempt_swmr_open_hdf5_file()"; - hbool_t show_progress = FALSE; - int cp = 0; - hid_t fapl_id = -1; - hid_t file_id = -1; - herr_t result; - H5AC_cache_image_config_t cache_image_config = { - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, - FALSE, - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + const char * fcn_name = "attempt_swmr_open_hdf5_file()"; + hbool_t show_progress = FALSE; + int cp = 0; + hid_t fapl_id = -1; + hid_t file_id = -1; + herr_t result; + H5AC_cache_image_config_t cache_image_config = {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; /* create a file access propertly list. */ - if ( pass ) { + if (pass) { fapl_id = h5_fileaccess(); - if ( fapl_id < 0 ) { + if (fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fileaccess() failed.\n"; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* call H5Pset_libver_bounds() on the fapl_id */ - if ( pass ) { + if (pass) { - if ( H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) - < 0 ) { + if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_libver_bounds() failed.\n"; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* set metadata cache image fapl entry if indicated */ - if ( ( pass ) && ( set_mdci_fapl ) ) { + if ((pass) && (set_mdci_fapl)) { /* set cache image config fields to taste */ - cache_image_config.generate_image = TRUE; + cache_image_config.generate_image = TRUE; cache_image_config.save_resize_status = FALSE; - cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; + cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; result = H5Pset_mdc_image_config(fapl_id, &cache_image_config); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_image_config() failed.\n"; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* open the file */ - if ( pass ) { + if (pass) { - if ( create_file ) { + if (create_file) { - H5E_BEGIN_TRY { - file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, - H5P_DEFAULT, fapl_id); - } H5E_END_TRY; - } else { + H5E_BEGIN_TRY + { + file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl_id); + } + H5E_END_TRY; + } + else { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(hdf_file_name, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; } - if ( file_id >= 0 ) { + if (file_id >= 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "SWMR H5Fcreate() or H5Fopen() succeeded.\n"; - } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); return; } /* attempt_swmr_open_hdf5_file() */ - /*------------------------------------------------------------------------- * Function: verify_datasets() * @@ -1033,23 +996,24 @@ attempt_swmr_open_hdf5_file(const hbool_t create_file, static void verify_datasets(hid_t file_id, int min_dset, int max_dset) { - const char * fcn_name = "verify_datasets()"; - char dset_name[64]; - hbool_t show_progress = FALSE; - hbool_t valid_chunk; - hbool_t verbose = FALSE; - int cp = 0; - int i, j, k, l, m; - int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; - herr_t status; - hid_t filespace_ids[MAX_NUM_DSETS]; - hid_t memspace_id = -1; - hid_t dataset_ids[MAX_NUM_DSETS]; - hsize_t dims[2]; - hsize_t a_size[2]; - hsize_t offset[2]; - - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + const char *fcn_name = "verify_datasets()"; + char dset_name[64]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l, m; + int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; + herr_t status; + hid_t filespace_ids[MAX_NUM_DSETS]; + hid_t memspace_id = -1; + hid_t dataset_ids[MAX_NUM_DSETS]; + hsize_t dims[2]; + hsize_t a_size[2]; + hsize_t offset[2]; + + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); HDassert(0 <= min_dset); HDassert(min_dset <= max_dset); @@ -1057,33 +1021,32 @@ verify_datasets(hid_t file_id, int min_dset, int max_dset) /* open the datasets */ - if ( pass ) { + if (pass) { i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { + while ((pass) && (i <= max_dset)) { /* open the dataset */ - if ( pass ) { + if (pass) { HDsprintf(dset_name, "/dset%03d", i); dataset_ids[i] = H5Dopen2(file_id, dset_name, H5P_DEFAULT); - if ( dataset_ids[i] < 0 ) { + if (dataset_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dopen2() failed."; } } /* get the file space ID */ - if ( pass ) { + if (pass) { filespace_ids[i] = H5Dget_space(dataset_ids[i]); - if ( filespace_ids[i] < 0 ) { + if (filespace_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dget_space() failed."; } } @@ -1092,124 +1055,111 @@ verify_datasets(hid_t file_id, int min_dset, int max_dset) } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* create the mem space to be used to read and write chunks */ - if ( pass ) { + if (pass) { - dims[0] = CHUNK_SIZE; - dims[1] = CHUNK_SIZE; + dims[0] = CHUNK_SIZE; + dims[1] = CHUNK_SIZE; memspace_id = H5Screate_simple(2, dims, NULL); - if ( memspace_id < 0 ) { + if (memspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* select in memory hyperslab */ - if ( pass ) { + if (pass) { - offset[0] = 0; /*offset of hyperslab in memory*/ + offset[0] = 0; /*offset of hyperslab in memory*/ offset[1] = 0; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, - a_size, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); - + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* read data from datasets and validate it */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { m = min_dset; - while ( ( pass ) && ( m <= max_dset ) ) - { + while ((pass) && (m <= max_dset)) { /* select on disk hyperslab */ offset[0] = (hsize_t)i; /* offset of hyperslab in file */ offset[1] = (hsize_t)j; a_size[0] = CHUNK_SIZE; /* size of hyperslab */ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, - memspace_id, filespace_ids[m], + status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - if ( data_chunk[k][l] - != - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l) ) { + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + if (data_chunk[k][l] != + ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)) { valid_chunk = FALSE; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "data_chunk[%0d][%0d] = %0d, expect %0d.\n", - k, l, data_chunk[k][l], - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l)); - HDfprintf(stdout, - "m = %d, i = %d, j = %d, k = %d, l = %d\n", - m, i, j, k, l); - } + HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", k, l, + data_chunk[k][l], + ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)); + HDfprintf(stdout, "m = %d, i = %d, j = %d, k = %d, l = %d\n", m, i, j, k, + l); + } } } } - if ( ! valid_chunk ) { + if (!valid_chunk) { - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "Chunk (%0d, %0d) in /dset%03d is invalid.\n", - i, j, m); - } + HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", i, j, m); + } } } m++; @@ -1219,39 +1169,37 @@ verify_datasets(hid_t file_id, int min_dset, int max_dset) i += CHUNK_SIZE; } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* close the file spaces */ i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { - if ( H5Sclose(filespace_ids[i]) < 0 ) { + while ((pass) && (i <= max_dset)) { + if (H5Sclose(filespace_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose() failed."; } i++; } - /* close the datasets */ i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { - if ( H5Dclose(dataset_ids[i]) < 0 ) { + while ((pass) && (i <= max_dset)) { + if (H5Dclose(dataset_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose() failed."; } i++; } /* close the mem space */ - if ( pass ) { + if (pass) { - if ( H5Sclose(memspace_id) < 0 ) { + if (H5Sclose(memspace_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(memspace_id) failed."; } } @@ -1260,7 +1208,6 @@ verify_datasets(hid_t file_id, int min_dset, int max_dset) } /* verify_datasets() */ - /****************************************************************************/ /******************************* Test Functions *****************************/ /****************************************************************************/ @@ -1335,18 +1282,18 @@ verify_datasets(hid_t file_id, int min_dset, int max_dset) static unsigned check_cache_image_ctl_flow_1(hbool_t single_file_vfd) { - const char * fcn_name = "check_cache_image_ctl_flow_1()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "check_cache_image_ctl_flow_1()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image control flow test 1"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -1354,25 +1301,22 @@ check_cache_image_ctl_flow_1(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -1381,14 +1325,14 @@ check_cache_image_ctl_flow_1(hbool_t single_file_vfd) * extension message only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__GEN_MDCI_SBE_MESG, /* file_id_ptr */ &file_id, @@ -1396,37 +1340,33 @@ check_cache_image_ctl_flow_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some datasets in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file. * * Verify that the metadata cache is instructed to load the @@ -1435,14 +1375,14 @@ check_cache_image_ctl_flow_1(hbool_t single_file_vfd) * indicate that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -1450,61 +1390,58 @@ check_cache_image_ctl_flow_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open and close a dataset. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } - if ( pass ) { + if (pass) { /* think on how to verify that the superblock extension has been * deleted, and if it is necessary to verify this directly. */ } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -1512,47 +1449,48 @@ check_cache_image_ctl_flow_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* check_cache_image_ctl_flow_1() */ - /*------------------------------------------------------------------------- * Function: check_cache_image_ctl_flow_2() * @@ -1621,18 +1559,18 @@ check_cache_image_ctl_flow_1(hbool_t single_file_vfd) static unsigned check_cache_image_ctl_flow_2(hbool_t single_file_vfd) { - const char * fcn_name = "check_cache_image_ctl_flow_2()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "check_cache_image_ctl_flow_2()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image control flow test 2"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -1640,24 +1578,22 @@ check_cache_image_ctl_flow_2(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -1666,14 +1602,14 @@ check_cache_image_ctl_flow_2(hbool_t single_file_vfd) * extension message only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__GEN_MDCI_SBE_MESG, /* file_id_ptr */ &file_id, @@ -1681,26 +1617,23 @@ check_cache_image_ctl_flow_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Open the file. * * Verify that the metadata cache is instructed to load the @@ -1709,14 +1642,14 @@ check_cache_image_ctl_flow_2(hbool_t single_file_vfd) * indicate that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -1724,39 +1657,37 @@ check_cache_image_ctl_flow_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -1764,47 +1695,48 @@ check_cache_image_ctl_flow_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* check_cache_image_ctl_flow_2() */ - /*------------------------------------------------------------------------- * Function: check_cache_image_ctl_flow_3() * @@ -1891,18 +1823,18 @@ check_cache_image_ctl_flow_2(hbool_t single_file_vfd) static unsigned check_cache_image_ctl_flow_3(hbool_t single_file_vfd) { - const char * fcn_name = "check_cache_image_ctl_flow_3()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "check_cache_image_ctl_flow_3()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image control flow test 3"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -1910,21 +1842,20 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) /* 0 */ + if (show_progress) /* 0 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) /* 1 */ + if (show_progress) /* 1 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 1) Create a HDF5 file WITHOUT the cache image FAPL entry. @@ -1933,14 +1864,14 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) * FAPL entry. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -1948,25 +1879,23 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 2 */ + if (show_progress) /* 2 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 3 */ + if (show_progress) /* 3 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Open the file WITH the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -1975,14 +1904,14 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) * extension message only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__GEN_MDCI_SBE_MESG, /* file_id_ptr */ &file_id, @@ -1990,36 +1919,33 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 4 */ + if (show_progress) /* 4 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Create some datasets. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } - if ( show_progress ) /* 5 */ + if (show_progress) /* 5 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 6 */ + if (show_progress) /* 6 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Open the file READ ONLY. * * Verify that the metadata cache is instructed @@ -2029,14 +1955,14 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) * that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -2044,36 +1970,33 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 7 */ + if (show_progress) /* 7 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Verify the contents of the datasets. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } - if ( show_progress ) /* 8 */ + if (show_progress) /* 8 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 9 */ + if (show_progress) /* 9 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Open the file READ/WRITE. * * Verify that the metadata cache is instructed @@ -2083,14 +2006,14 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) * that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -2098,50 +2021,47 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 10 */ + if (show_progress) /* 10 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Verify the contents of the datasets. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } - if ( show_progress ) /* 11 */ + if (show_progress) /* 11 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 12 */ + if (show_progress) /* 12 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Open the file * * Verify that the file doesn't contain a metadata cache * image superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -2149,48 +2069,48 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 13 */ + if (show_progress) /* 13 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 14 */ + if (show_progress) /* 14 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Delete the file. */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( pass ) { PASSED(); } else { H5_FAILED(); } - - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* check_cache_image_ctl_flow_3() */ - /*------------------------------------------------------------------------- * Function: check_cache_image_ctl_flow_4() * @@ -2269,18 +2189,18 @@ check_cache_image_ctl_flow_3(hbool_t single_file_vfd) static unsigned check_cache_image_ctl_flow_4(hbool_t single_file_vfd) { - const char * fcn_name = "check_cache_image_ctl_flow_4()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "check_cache_image_ctl_flow_4()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image control flow test 4"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -2288,21 +2208,20 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) /* 0 */ + if (show_progress) /* 0 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) /* 1 */ + if (show_progress) /* 1 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 1) Create a HDF5 file WITHOUT the cache image FAPL entry. @@ -2311,14 +2230,14 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) * FAPL entry. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -2326,25 +2245,23 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 2 */ + if (show_progress) /* 2 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 3 */ + if (show_progress) /* 3 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Open the file WITH the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -2353,14 +2270,14 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) * extension message only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__GEN_MDCI_SBE_MESG, /* file_id_ptr */ &file_id, @@ -2368,25 +2285,23 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 4 */ + if (show_progress) /* 4 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 5 */ + if (show_progress) /* 5 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open the file READ ONLY. * * Verify that the metadata cache is instructed @@ -2396,14 +2311,14 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) * that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -2411,25 +2326,23 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 6 */ + if (show_progress) /* 6 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 7 */ + if (show_progress) /* 7 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Open the file READ/WRITE. * * Verify that the metadata cache is instructed @@ -2439,14 +2352,14 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) * that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -2454,39 +2367,37 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 8 */ + if (show_progress) /* 8 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 9 */ + if (show_progress) /* 9 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Open the file * * Verify that the file doesn't contain a metadata cache * image superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -2494,48 +2405,48 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 10 */ + if (show_progress) /* 10 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 11 */ + if (show_progress) /* 11 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Delete the file. */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( pass ) { PASSED(); } else { H5_FAILED(); } - - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* check_cache_image_ctl_flow_4() */ - /*------------------------------------------------------------------------- * Function: check_cache_image_ctl_flow_5() * @@ -2607,18 +2518,18 @@ check_cache_image_ctl_flow_4(hbool_t single_file_vfd) static unsigned check_cache_image_ctl_flow_5(hbool_t single_file_vfd) { - const char * fcn_name = "check_cache_image_ctl_flow_5()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "check_cache_image_ctl_flow_5()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image control flow test 5"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -2626,24 +2537,22 @@ check_cache_image_ctl_flow_5(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) /* 0 */ + if (show_progress) /* 0 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) /* 1 */ + if (show_progress) /* 1 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -2652,14 +2561,14 @@ check_cache_image_ctl_flow_5(hbool_t single_file_vfd) * super block extension message only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__GEN_MDCI_SBE_MESG, /* file_id_ptr */ &file_id, @@ -2667,36 +2576,33 @@ check_cache_image_ctl_flow_5(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 2 */ + if (show_progress) /* 2 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some datasets. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } - if ( show_progress ) /* 3 */ + if (show_progress) /* 3 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 4 */ + if (show_progress) /* 4 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file WITH the cache image FAPL entry. * * Verify that the metadata cache is instructed @@ -2712,14 +2618,14 @@ check_cache_image_ctl_flow_5(hbool_t single_file_vfd) * super block extension message only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__GEN_MDCI_SBE_MESG, /* file_id_ptr */ &file_id, @@ -2727,35 +2633,33 @@ check_cache_image_ctl_flow_5(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 5 */ + if (show_progress) /* 5 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 5) Verify the contents of the datasets. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } - if ( show_progress ) /* 6 */ + if (show_progress) /* 6 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 7 */ + if (show_progress) /* 7 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Open the file. * * Verify that the metadata cache is instructed @@ -2765,14 +2669,14 @@ check_cache_image_ctl_flow_5(hbool_t single_file_vfd) * that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -2780,58 +2684,58 @@ check_cache_image_ctl_flow_5(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 8 */ + if (show_progress) /* 8 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 8) Verify the contents of the datasets. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } - if ( show_progress ) /* 9 */ + if (show_progress) /* 9 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 10 */ + if (show_progress) /* 10 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Delete the file. */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( pass ) { PASSED(); } else { H5_FAILED(); } - - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* check_cache_image_ctl_flow_5() */ - /*------------------------------------------------------------------------- * Function: check_cache_image_ctl_flow_6() * @@ -2895,18 +2799,18 @@ check_cache_image_ctl_flow_5(hbool_t single_file_vfd) static unsigned check_cache_image_ctl_flow_6(hbool_t single_file_vfd) { - const char * fcn_name = "check_cache_image_ctl_flow_6()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "check_cache_image_ctl_flow_6()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image control flow test 6"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -2914,24 +2818,22 @@ check_cache_image_ctl_flow_6(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) /* 0 */ + if (show_progress) /* 0 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) /* 1 */ + if (show_progress) /* 1 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -2940,14 +2842,14 @@ check_cache_image_ctl_flow_6(hbool_t single_file_vfd) * super block extension message only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__GEN_MDCI_SBE_MESG, /* file_id_ptr */ &file_id, @@ -2955,25 +2857,23 @@ check_cache_image_ctl_flow_6(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 2 */ + if (show_progress) /* 2 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 3 */ + if (show_progress) /* 3 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file WITH the cache image FAPL entry. * * Verify that the metadata cache is instructed @@ -2989,14 +2889,14 @@ check_cache_image_ctl_flow_6(hbool_t single_file_vfd) * super block extension message only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__GEN_MDCI_SBE_MESG, /* file_id_ptr */ &file_id, @@ -3004,25 +2904,23 @@ check_cache_image_ctl_flow_6(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 4 */ + if (show_progress) /* 4 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 5 */ + if (show_progress) /* 5 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open the file. * * Verify that the metadata cache is instructed @@ -3032,14 +2930,14 @@ check_cache_image_ctl_flow_6(hbool_t single_file_vfd) * that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -3047,48 +2945,48 @@ check_cache_image_ctl_flow_6(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) /* 6 */ + if (show_progress) /* 6 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) /* 7 */ + if (show_progress) /* 7 */ HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Delete the file. */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( pass ) { PASSED(); } else { H5_FAILED(); } - - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* check_cache_image_ctl_flow_6() */ - /*------------------------------------------------------------------------- * Function: cache_image_smoke_check_1() * @@ -3187,18 +3085,18 @@ check_cache_image_ctl_flow_6(hbool_t single_file_vfd) static unsigned cache_image_smoke_check_1(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_smoke_check_1()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "cache_image_smoke_check_1()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image smoke check 1"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -3206,25 +3104,22 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -3232,14 +3127,14 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) * Set flags forcing full function of the cache image feature. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -3247,50 +3142,44 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some datasets in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file. * * Verify that the metadata cache is instructed to load the @@ -3299,14 +3188,14 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) * indicate that the metadata image block doesn't exist. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -3314,65 +3203,62 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open and close a dataset. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -3380,66 +3266,62 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Open and close a dataset. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Open the file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image * FAPL entry. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -3447,42 +3329,40 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Close the file. Since there has been no access to * any entries that would be included in the cache image, * there should be no cache image. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Open the file. * * Verify that the file doesn't contain a metadata cache * image superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -3490,73 +3370,72 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Open a dataset. * * Verify that it contains the expected data. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(3)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_smoke_check_1() */ - /*------------------------------------------------------------------------- * Function: cache_image_smoke_check_2() * @@ -3617,18 +3496,18 @@ cache_image_smoke_check_1(hbool_t single_file_vfd) static unsigned cache_image_smoke_check_2(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_smoke_check_2()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "cache_image_smoke_check_2()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image smoke check 2"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -3636,25 +3515,22 @@ cache_image_smoke_check_2(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -3662,14 +3538,14 @@ cache_image_smoke_check_2(hbool_t single_file_vfd) * Set flags forcing full function of the cache image feature. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -3677,46 +3553,42 @@ cache_image_smoke_check_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some datasets in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 4) Open the file. @@ -3725,14 +3597,14 @@ cache_image_smoke_check_2(hbool_t single_file_vfd) * metadata cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -3746,39 +3618,37 @@ cache_image_smoke_check_2(hbool_t single_file_vfd) * incremented just before the cache is shut down. */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -3786,62 +3656,62 @@ cache_image_smoke_check_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Open and close a dataset. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_smoke_check_2() */ - /*------------------------------------------------------------------------- * Function: cache_image_smoke_check_3() * @@ -3924,18 +3794,18 @@ cache_image_smoke_check_2(hbool_t single_file_vfd) static unsigned cache_image_smoke_check_3(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_smoke_check_3()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "cache_image_smoke_check_3()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image smoke check 3"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -3943,25 +3813,22 @@ cache_image_smoke_check_3(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -3969,14 +3836,14 @@ cache_image_smoke_check_3(hbool_t single_file_vfd) * Set flags forcing full function of the cache image feature. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -3984,62 +3851,58 @@ cache_image_smoke_check_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some datasets in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file read only. * * Verify that the metadata cache is instructed to load the * metadata cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -4047,65 +3910,62 @@ cache_image_smoke_check_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open and close a dataset. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Open the file. * * Verify that the file contains a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -4113,63 +3973,59 @@ cache_image_smoke_check_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Open and close a dataset. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - /* 10) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -4177,74 +4033,73 @@ cache_image_smoke_check_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Open and close a dataset. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_smoke_check_3() */ - /*------------------------------------------------------------------------- * Function: cache_image_smoke_check_4() * @@ -4316,20 +4171,20 @@ cache_image_smoke_check_3(hbool_t single_file_vfd) static unsigned cache_image_smoke_check_4(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_smoke_check_4()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; - int min_dset = 0; - int max_dset = 0; + const char *fcn_name = "cache_image_smoke_check_4()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; + int min_dset = 0; + int max_dset = 0; TESTING("metadata cache image smoke check 4"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -4337,25 +4192,22 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -4363,14 +4215,14 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) * Set flags forcing full function of the cache image feature. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -4378,49 +4230,45 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create a dataset in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, min_dset++, max_dset++); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - while ( ( pass ) && ( max_dset < MAX_NUM_DSETS ) ) - { + while ((pass) && (max_dset < MAX_NUM_DSETS)) { /* 4) Open the file. * @@ -4428,14 +4276,14 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) * metadata cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -4443,67 +4291,60 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) - HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp, max_dset, pass); - + if (show_progress) + HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp, max_dset, pass); /* 5) Create a dataset in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, min_dset++, max_dset++); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) - HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp + 1, max_dset, pass); - + if (show_progress) + HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp + 1, max_dset, pass); /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) - HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp + 2, max_dset, pass); + if (show_progress) + HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp + 2, max_dset, pass); } /* end while */ cp += 3; - /* 7) Open the file. * * Verify that the file contains a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -4511,63 +4352,59 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Open and close all datasets. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, max_dset - 1); + verify_datasets(file_id, 0, max_dset - 1); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - /* 10) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -4575,72 +4412,72 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Open and close all datasets. * * Verify that the metadata cache image superblock * extension message has been deleted. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, max_dset - 1); + verify_datasets(file_id, 0, max_dset - 1); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 13) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_smoke_check_4() */ - /*------------------------------------------------------------------------- * Function: cache_image_smoke_check_5() * @@ -4727,23 +4564,23 @@ cache_image_smoke_check_4(hbool_t single_file_vfd) static unsigned cache_image_smoke_check_5(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_smoke_check_5()"; - char filename[512]; - char process_group_name[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - hid_t proc_gid = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; - int i; - int min_group = 0; - int max_group = 0; + const char *fcn_name = "cache_image_smoke_check_5()"; + char filename[512]; + char process_group_name[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + hid_t proc_gid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; + int i; + int min_group = 0; + int max_group = 0; TESTING("metadata cache image smoke check 5"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -4751,29 +4588,26 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { hid_t fapl_id = h5_fileaccess(); - if ( h5_fixname(FILENAMES[0], fapl_id, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], fapl_id, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } H5Pclose(fapl_id); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -4781,14 +4615,14 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) * Set flags forcing full function of the cache image feature. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -4796,76 +4630,71 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create a process specific group. */ - if ( pass ) { + if (pass) { HDsprintf(process_group_name, "/process_%d", min_group); - proc_gid = H5Gcreate2(file_id, process_group_name, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + proc_gid = H5Gcreate2(file_id, process_group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( proc_gid < 0 ) { + if (proc_gid < 0) { - pass = FALSE; - failure_mssg = "H5Gcreate2() failed (1).\n"; + pass = FALSE; + failure_mssg = "H5Gcreate2() failed (1).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Construct a "zoo" in the above group, and validate it. */ - if ( pass ) - pass = create_zoo(file_id, process_group_name, &lastmsgtime, - (zoo_config_t){.proc_num = min_group, .skip_varlen = false, - .skip_compact = false, .msgival = {0, 0}}); + if (pass) + pass = create_zoo( + file_id, process_group_name, &lastmsgtime, + (zoo_config_t){ + .proc_num = min_group, .skip_varlen = false, .skip_compact = false, .msgival = {0, 0}}); #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Gclose(proc_gid) < 0 ) { + if (H5Gclose(proc_gid) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Gclose(proc_gid) failed. (1)"; } } - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - while ( ( pass ) && ( max_group < MAX_NUM_GROUPS ) ) - { + while ((pass) && (max_group < MAX_NUM_GROUPS)) { /* 5) Open the file. * @@ -4873,14 +4702,14 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) * metadata cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -4888,91 +4717,86 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) - HDfprintf(stdout, "%s:L1 cp = %d, max_group = %d, pass = %d.\n", - fcn_name, cp, max_group, pass); - + if (show_progress) + HDfprintf(stdout, "%s:L1 cp = %d, max_group = %d, pass = %d.\n", fcn_name, cp, max_group, pass); /* 6) Validate the "zoo" created in the previous file open. */ - if ( pass ) { - pass = validate_zoo(file_id, process_group_name, &lastmsgtime, - (zoo_config_t){.proc_num = max_group, .skip_varlen = false, - .skip_compact = false, .msgival = {0, 0}}); + if (pass) { + pass = validate_zoo( + file_id, process_group_name, &lastmsgtime, + (zoo_config_t){ + .proc_num = max_group, .skip_varlen = false, .skip_compact = false, .msgival = {0, 0}}); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) - HDfprintf(stdout, "%s:L2 cp = %d, max_group = %d, pass = %d.\n", - fcn_name, cp + 1, max_group, pass); - + if (show_progress) + HDfprintf(stdout, "%s:L2 cp = %d, max_group = %d, pass = %d.\n", fcn_name, cp + 1, max_group, + pass); - /* 7) Create a process specific group for this file open */ - if ( pass ) { + /* 7) Create a process specific group for this file open */ + if (pass) { - max_group++; - HDsprintf(process_group_name, "/process_%d", max_group); + max_group++; + HDsprintf(process_group_name, "/process_%d", max_group); - proc_gid = H5Gcreate2(file_id, process_group_name, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + proc_gid = H5Gcreate2(file_id, process_group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( proc_gid < 0 ) { + if (proc_gid < 0) { - pass = FALSE; - failure_mssg = "H5Gcreate2() failed (2).\n"; + pass = FALSE; + failure_mssg = "H5Gcreate2() failed (2).\n"; } } - if ( show_progress ) - HDfprintf(stdout, "%s:L3 cp = %d, max_group = %d, pass = %d.\n", - fcn_name, cp + 2, max_group, pass); + if (show_progress) + HDfprintf(stdout, "%s:L3 cp = %d, max_group = %d, pass = %d.\n", fcn_name, cp + 2, max_group, + pass); - - /* 8) Construct a "zoo" in the above group, and validate it. */ - if ( pass ) { - pass = create_zoo(file_id, process_group_name, &lastmsgtime, - (zoo_config_t){.proc_num = max_group, .skip_varlen = false, - .skip_compact = false, .msgival = {0, 0}}); + /* 8) Construct a "zoo" in the above group, and validate it. */ + if (pass) { + pass = create_zoo( + file_id, process_group_name, &lastmsgtime, + (zoo_config_t){ + .proc_num = max_group, .skip_varlen = false, .skip_compact = false, .msgival = {0, 0}}); } - if ( show_progress ) - HDfprintf(stdout, "%s:L4 cp = %d, max_group = %d, pass = %d.\n", - fcn_name, cp + 3, max_group, pass); - + if (show_progress) + HDfprintf(stdout, "%s:L4 cp = %d, max_group = %d, pass = %d.\n", fcn_name, cp + 3, max_group, + pass); /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Gclose(proc_gid) < 0 ) { + if (H5Gclose(proc_gid) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Gclose(process_gid) failed. (2)"; } } - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) - HDfprintf(stdout, "%s:L5 cp = %d, max_group = %d, pass = %d.\n", - fcn_name, cp + 4, max_group, pass); + if (show_progress) + HDfprintf(stdout, "%s:L5 cp = %d, max_group = %d, pass = %d.\n", fcn_name, cp + 4, max_group, + pass); } /* end while */ cp += 5; @@ -4981,13 +4805,13 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) * Verify that the file contains a metadata cache image * superblock extension message. */ - if(pass) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -4995,35 +4819,34 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if(show_progress) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Validate all the zoos. */ i = min_group; - while(pass && i <= max_group) { + while (pass && i <= max_group) { HDsprintf(process_group_name, "/process_%d", i); - pass = validate_zoo(file_id, process_group_name, &lastmsgtime, - (zoo_config_t){.proc_num = i++, .skip_varlen = false, - .skip_compact = false, .msgival = {0, 0}}); + pass = validate_zoo( + file_id, process_group_name, &lastmsgtime, + (zoo_config_t){.proc_num = i++, .skip_varlen = false, .skip_compact = false, .msgival = {0, 0}}); } #if H5C_COLLECT_CACHE_STATS - if( pass) { - if(cache_ptr->images_loaded == 0) { - pass = FALSE; + if (pass) { + if (cache_ptr->images_loaded == 0) { + pass = FALSE; failure_mssg = "metadata cache image block not loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if(show_progress) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 12) Close the file. */ - if(pass) { - if(H5Fclose(file_id) < 0) { - pass = FALSE; + if (pass) { + if (H5Fclose(file_id) < 0) { + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } @@ -5034,14 +4857,14 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -5049,62 +4872,58 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Validate all the zoos. */ i = min_group; - while ( ( pass ) && ( i <= max_group ) ) { + while ((pass) && (i <= max_group)) { HDsprintf(process_group_name, "/process_%d", i); - pass = validate_zoo(file_id, process_group_name, &lastmsgtime, - (zoo_config_t){.proc_num = i++, .skip_varlen = false, - .skip_compact = false, .msgival = {0, 0}}); + pass = validate_zoo( + file_id, process_group_name, &lastmsgtime, + (zoo_config_t){.proc_num = i++, .skip_varlen = false, .skip_compact = false, .msgival = {0, 0}}); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - /* 16) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -5112,77 +4931,75 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 17) Validate all the zoos. * * Verify that the metadata cache image superblock * extension message has been deleted. */ i = min_group; - while ( ( pass ) && ( i <= max_group ) ) { + while ((pass) && (i <= max_group)) { HDsprintf(process_group_name, "/process_%d", i); - pass = validate_zoo(file_id, process_group_name, &lastmsgtime, - (zoo_config_t){.proc_num = i++, .skip_varlen = false, - .skip_compact = false, .msgival = {0, 0}}); + pass = validate_zoo( + file_id, process_group_name, &lastmsgtime, + (zoo_config_t){.proc_num = i++, .skip_varlen = false, .skip_compact = false, .msgival = {0, 0}}); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 18) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 19) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( pass ) { PASSED(); } else { H5_FAILED(); } - - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_smoke_check_5() */ - /*------------------------------------------------------------------------- * Function: cache_image_smoke_check_6() * @@ -5266,21 +5083,21 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) static unsigned cache_image_smoke_check_6(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_smoke_check_6()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; + const char * fcn_name = "cache_image_smoke_check_6()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; h5_stat_size_t file_size; - int cp = 0; - int min_dset = 0; - int max_dset = 0; + int cp = 0; + int min_dset = 0; + int max_dset = 0; TESTING("metadata cache image smoke check 6"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -5288,25 +5105,22 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -5314,14 +5128,14 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) * Set flags forcing full function of the cache image feature. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -5329,49 +5143,45 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create a dataset in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, min_dset++, max_dset++); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - while ( ( pass ) && ( max_dset < MAX_NUM_DSETS ) ) - { + while ((pass) && (max_dset < MAX_NUM_DSETS)) { /* 4) Open the file. * @@ -5379,14 +5189,14 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) * metadata cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -5394,78 +5204,69 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) - HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp, max_dset, pass); - + if (show_progress) + HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp, max_dset, pass); /* 5) Create a dataset in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, min_dset++, max_dset++); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) - HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp + 1, max_dset, pass); + if (show_progress) + HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp + 1, max_dset, pass); + /* 6) Verify and delete the old dataset. */ + if (pass) { - /* 6) Verify and delete the old dataset. */ - if ( pass ) { - - delete_datasets(file_id, min_dset - 2, max_dset - 2); - } - - if ( show_progress ) - HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp + 2, max_dset, pass); + delete_datasets(file_id, min_dset - 2, max_dset - 2); + } + if (show_progress) + HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp + 2, max_dset, pass); /* 7) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) - HDfprintf(stdout, "%s:L4 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp + 3, max_dset, pass); + if (show_progress) + HDfprintf(stdout, "%s:L4 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp + 3, max_dset, pass); } /* end while */ cp += 4; - /* 8) Open the file. * * Verify that the file contains a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -5473,59 +5274,55 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Verify the last dataset created. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, min_dset - 1, max_dset - 1); + verify_datasets(file_id, min_dset - 1, max_dset - 1); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - /* 11) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -5533,48 +5330,44 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Verify and delete the last dataset. * * Verify that a metadata cache image is not loaded. */ - if ( pass ) { + if (pass) { - delete_datasets(file_id, min_dset - 1, max_dset - 1); + delete_datasets(file_id, min_dset - 1, max_dset - 1); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - /* 13) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Get the size of the file. Verify that it is less * than 20 KB. Without deletions and persistent free * space managers, size size is about 167 MB, so this @@ -5586,42 +5379,44 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) * with and without paged allocation, we must leave some * extra space for the paged allocation case. */ - if(pass) { - if((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) { - pass = FALSE; + if (pass) { + if ((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) { + pass = FALSE; failure_mssg = "h5_get_file_size() failed.\n"; - } else if(file_size > 20 * 1024) { - pass = FALSE; + } + else if (file_size > 20 * 1024) { + pass = FALSE; failure_mssg = "unexpectedly large file size.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( pass ) { PASSED(); } else { H5_FAILED(); } - - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_smoke_check_6() */ - /*------------------------------------------------------------------------- * Function: cache_image_api_error_check_1() * @@ -5683,18 +5478,18 @@ cache_image_smoke_check_6(hbool_t single_file_vfd) static unsigned cache_image_api_error_check_1(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_api_error_check_1()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "cache_image_api_error_check_1()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image api error check 1"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -5702,35 +5497,32 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -5738,60 +5530,54 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some datasets in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file read only with a cache image FAPL entry requested. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ TRUE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -5799,10 +5585,9 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open and close a dataset. * * Verify that it contains the expected data. @@ -5810,51 +5595,49 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) * Verify that the cache image was not loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Open the file read only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -5862,10 +5645,9 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Open and close a dataset. * * Verify that it contains the expected data. @@ -5873,52 +5655,49 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) * Verify that the cache image was not loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(3)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Open the file read / write. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -5926,7 +5705,7 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 11) Open and close a dataset. @@ -5936,63 +5715,64 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) * Verify that the cache image was not loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(4)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_api_error_check_1() */ - /*------------------------------------------------------------------------- * Function: cache_image_api_error_check_2() * @@ -6066,18 +5846,18 @@ cache_image_api_error_check_1(hbool_t single_file_vfd) static unsigned cache_image_api_error_check_2(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_api_error_check_2()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "cache_image_api_error_check_2()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image api error check 2"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -6085,35 +5865,32 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with a cache image requested. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -6121,60 +5898,54 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some datasets in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file read only with a cache image FAPL entry requested. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -6182,10 +5953,9 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open and close a dataset. * * Verify that it contains the expected data. @@ -6193,51 +5963,49 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) * Verify that the cache image was loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block was not loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Open the file read only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ 0, /* file_id_ptr */ &file_id, @@ -6245,10 +6013,9 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Open and close a dataset. * * Verify that it contains the expected data. @@ -6256,52 +6023,49 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) * Verify that the cache image was loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block was not loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Open the file read / write. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ TRUE, + /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -6309,7 +6073,7 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 11) Open and close a dataset. @@ -6319,51 +6083,49 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) * Verify that the cache image was loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block was not loaded(3)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Open the file read / write. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -6371,7 +6133,7 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 14) Open and close a dataset. @@ -6381,63 +6143,64 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) * Verify that the cache image was not loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block was loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_api_error_check_2() */ - /*------------------------------------------------------------------------- * Function: cache_image_api_error_check_3() * @@ -6484,18 +6247,18 @@ cache_image_api_error_check_2(hbool_t single_file_vfd) static unsigned cache_image_api_error_check_3(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_api_error_check_3()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "cache_image_api_error_check_3()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; TESTING("metadata cache image api error check 3"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -6503,35 +6266,32 @@ cache_image_api_error_check_3(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with a cache image requested. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -6539,64 +6299,61 @@ cache_image_api_error_check_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Try to start SWMR write -- should fail. */ - if ( pass ) { + if (pass) { - H5E_BEGIN_TRY { - if ( H5Fstart_swmr_write(file_id) == SUCCEED ) { + H5E_BEGIN_TRY + { + if (H5Fstart_swmr_write(file_id) == SUCCEED) { - pass = FALSE; + pass = FALSE; failure_mssg = "SWMR start succeeded in file with cache image."; } - } H5E_END_TRY; + } + H5E_END_TRY; } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Discard the file if necessary */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Attempt to create a HDF5 file with SWMR write * access and cache image requested -- should fail. */ - attempt_swmr_open_hdf5_file(/* create_file */ TRUE, - /* set_mdci_fapl */ TRUE, - /* hdf_file_name */ filename); + attempt_swmr_open_hdf5_file(/* create_file */ TRUE, + /* set_mdci_fapl */ TRUE, + /* hdf_file_name */ filename); - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Discard the file if necessary */ - if ( pass ) { + if (pass) { /* file probably doesn't exist, so don't * error check the remove call. @@ -6604,20 +6361,19 @@ cache_image_api_error_check_3(hbool_t single_file_vfd) HDremove(filename); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Create a HDF5 file with a cache image requested. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -6625,84 +6381,81 @@ cache_image_api_error_check_3(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Create some datasets in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Attempt to open the file with SWMR write access -- should fail. */ attempt_swmr_open_hdf5_file(/* create_file */ FALSE, /* set_mdci_fapl */ TRUE, /* hdf_file_name */ filename); - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Discard the file if necessary. */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( pass ) { PASSED(); } else { H5_FAILED(); } - - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_api_error_check_3() */ - /*------------------------------------------------------------------------- * Function: cache_image_api_error_check_4() * @@ -6775,20 +6528,20 @@ cache_image_api_error_check_3(hbool_t single_file_vfd) static unsigned cache_image_api_error_check_4(hbool_t single_file_vfd) { - const char * fcn_name = "cache_image_api_error_check_4()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t fapl_id = -1; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char * fcn_name = "cache_image_api_error_check_4()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t fapl_id = -1; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; H5AC_cache_image_config_t cache_image_config; TESTING("metadata cache image api error check 4"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -6796,157 +6549,149 @@ cache_image_api_error_check_4(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 1) Create a FAPL requesting a cache image, but WITHOUT * specifying the latest file format. */ - if ( pass ) { + if (pass) { fapl_id = h5_fileaccess(); - if ( fapl_id < 0 ) { + if (fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fileaccess() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { /* set cache image config fields to taste */ - cache_image_config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION; - cache_image_config.generate_image = TRUE; + cache_image_config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION; + cache_image_config.generate_image = TRUE; cache_image_config.save_resize_status = FALSE; - cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; + cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; - if ( H5Pset_mdc_image_config(fapl_id, &cache_image_config) < 0 ) { + if (H5Pset_mdc_image_config(fapl_id, &cache_image_config) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_image_config() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create a HDF5 file using the above FAPL. */ - if ( pass ) { + if (pass) { file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fcreate() failed.\n"; - - } else { + } + else { file_ptr = (struct H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr."; - } } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* get a pointer to the files internal data structure and then * to the cache structure */ - if ( pass ) { + if (pass) { - if ( file_ptr->shared->cache == NULL ) { + if (file_ptr->shared->cache == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "can't get cache pointer(1).\n"; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Create some datasets in the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { HDassert(cache_ptr); - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Open the file read only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -6954,254 +6699,240 @@ cache_image_api_error_check_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Verify that the datasets exist and contain the * expected data */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Open the file R/W using the FAPL defined in 1) above. * * Verify that the file does not contain a cache image. */ - if ( pass ) { + if (pass) { file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fopen() failed.\n"; - - } else { + } + else { file_ptr = (struct H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr."; - } } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* get a pointer to the files internal data structure and then * to the cache structure */ - if ( pass ) { + if (pass) { - if ( file_ptr->shared->cache == NULL ) { + if (file_ptr->shared->cache == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "can't get cache pointer(1).\n"; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { - if ( ( cache_ptr->load_image == TRUE ) || - ( cache_ptr->delete_image == TRUE ) ) { + if ((cache_ptr->load_image == TRUE) || (cache_ptr->delete_image == TRUE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "mdci sb extension message present?\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - - /* 10) Open the file R/W using the FAPL defined in 1) above. * Verify that the file does not contain a cache image. */ - if ( pass ) { + if (pass) { file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fopen() failed.\n"; - - } else { + } + else { file_ptr = (struct H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr."; - } } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* get a pointer to the files internal data structure and then * to the cache structure */ - if ( pass ) { + if (pass) { - if ( file_ptr->shared->cache == NULL ) { + if (file_ptr->shared->cache == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "can't get cache pointer(1).\n"; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { - if ( ( cache_ptr->load_image == TRUE ) || - ( cache_ptr->delete_image == TRUE ) ) { + if ((cache_ptr->load_image == TRUE) || (cache_ptr->delete_image == TRUE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "mdci sb extension message present?\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Verify that the data sets contain the expected data * * Verify that a cache image was not loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 5); + verify_datasets(file_id, 0, 5); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Create several more data sets. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 6, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Open the file read write. * * Verify that the file does not contain a cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, - /* mdci_sbem_expected */ FALSE, + /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -7209,81 +6940,79 @@ cache_image_api_error_check_4(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Verify the data sets exist and contain the expected data. * * Verify that a cache image was not loaded. */ - if ( pass ) { + if (pass) { - verify_datasets(file_id, 0, 10); + verify_datasets(file_id, 0, 10); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 16) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 17) Delete the file */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* tidy up */ - if ( fapl_id != -1 ) + if (fapl_id != -1) H5Pclose(fapl_id); + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( pass ) { PASSED(); } else { H5_FAILED(); } - - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* cache_image_api_error_check_4() */ - /*------------------------------------------------------------------------- * Function: get_free_sections_test() * @@ -7371,19 +7100,19 @@ cache_image_api_error_check_4(hbool_t single_file_vfd) static unsigned get_free_sections_test(hbool_t single_file_vfd) { - const char * fcn_name = "get_free_sections_test()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; + const char * fcn_name = "get_free_sections_test()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; h5_stat_size_t file_size; - int cp = 0; + int cp = 0; TESTING("Cache image / H5Fget_free_sections() interaction"); /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -7391,37 +7120,34 @@ get_free_sections_test(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with a cache image requested * and persistent free space managers enabled. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -7429,65 +7155,61 @@ get_free_sections_test(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some data sets, and then delete some of * of those near the beginning of the file. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 1, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { verify_datasets(file_id, 1, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { delete_datasets(file_id, 1, 5); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed (1).\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file read only. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -7495,120 +7217,108 @@ get_free_sections_test(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Verify that a cache image exists, and has not been loaded. */ - if ( pass ) { + if (pass) { - if ( ( ! file_ptr->shared->cache->load_image ) || - ( file_ptr->shared->cache->image_loaded ) ) { + if ((!file_ptr->shared->cache->load_image) || (file_ptr->shared->cache->image_loaded)) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected cache image status.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Verify that one or more self referential FSMs * have been stored at the end of the file just * before the cache image. */ - if ( pass ) { + if (pass) { /* file_ptr->shared->first_alloc_dealloc is set to FALSE if the * file is opened R/O. */ - if ( ( ! H5F_addr_defined(file_ptr->shared->eoa_fsm_fsalloc) ) || - ( ! H5F_addr_defined(file_ptr->shared->cache->image_addr) ) || - ( H5F_addr_gt(file_ptr->shared->eoa_fsm_fsalloc, - file_ptr->shared->cache->image_addr) ) ) { + if ((!H5F_addr_defined(file_ptr->shared->eoa_fsm_fsalloc)) || + (!H5F_addr_defined(file_ptr->shared->cache->image_addr)) || + (H5F_addr_gt(file_ptr->shared->eoa_fsm_fsalloc, file_ptr->shared->cache->image_addr))) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected cache image status (1).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Call H5Fget_free_sections(). */ - if ( pass ) { + if (pass) { - if ( H5Fget_free_sections(file_id, H5FD_MEM_DEFAULT, (size_t)0, NULL) - < 0 ){ + if (H5Fget_free_sections(file_id, H5FD_MEM_DEFAULT, (size_t)0, NULL) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_free_sections() failed (1).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Verify that the cache image has been loaded and * that the self referential FSMs have been floated. */ - if ( pass ) { + if (pass) { - if ( ! file_ptr->shared->cache->image_loaded ) { + if (!file_ptr->shared->cache->image_loaded) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache image not loaded (1).\n"; - } - } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Verify that the remaining data sets contain the expected data. */ - if ( pass ) { + if (pass) { verify_datasets(file_id, 6, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed (2).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Open the file R/W. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -7616,162 +7326,151 @@ get_free_sections_test(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Verify that a cache image exists, and has not been loaded. */ - if ( pass ) { + if (pass) { - if ( ( ! file_ptr->shared->cache->load_image ) || - ( file_ptr->shared->cache->image_loaded ) ) { + if ((!file_ptr->shared->cache->load_image) || (file_ptr->shared->cache->image_loaded)) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected cache image status.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Verify that one or more self referential FSMs * have been stored at the end of the file just * before the cache image. */ - if ( pass ) { + if (pass) { - if ( ( ! H5F_addr_defined(file_ptr->shared->eoa_fsm_fsalloc) ) || - ( ! H5F_addr_defined(file_ptr->shared->cache->image_addr) ) || - ( H5F_addr_gt(file_ptr->shared->eoa_fsm_fsalloc, - file_ptr->shared->cache->image_addr) ) ) { + if ((!H5F_addr_defined(file_ptr->shared->eoa_fsm_fsalloc)) || + (!H5F_addr_defined(file_ptr->shared->cache->image_addr)) || + (H5F_addr_gt(file_ptr->shared->eoa_fsm_fsalloc, file_ptr->shared->cache->image_addr))) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected cache image status (2).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Call H5Fget_free_sections(). */ - if ( pass ) { + if (pass) { - if ( H5Fget_free_sections(file_id, H5FD_MEM_DEFAULT, (size_t)0, NULL) - < 0 ){ + if (H5Fget_free_sections(file_id, H5FD_MEM_DEFAULT, (size_t)0, NULL) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fget_free_sections() failed (2).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Verify that the cache image has been loaded and * that the self referential FSMs have been floated. */ - if ( pass ) { + if (pass) { - if ( ! file_ptr->shared->cache->image_loaded ) { + if (!file_ptr->shared->cache->image_loaded) { - pass = FALSE; + pass = FALSE; failure_mssg = "cache image not loaded (2).\n"; - } - } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 16) Verify that the remaining data sets contain the expected data. */ - if ( pass ) { + if (pass) { verify_datasets(file_id, 6, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 17) Delete the remaining data sets. */ - if ( pass ) { + if (pass) { delete_datasets(file_id, 6, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 18) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed (3).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 19) Verify that file space has been reclaimed. */ - if ( pass ) { + if (pass) { - if((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) { + if ((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_get_file_size() failed.\n"; + } + else if (file_size > 20 * 1024) { - } else if ( file_size > 20 * 1024 ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "unexpectedly large file size.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 20) Discard the file. */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; } /* get_free_sections_test() */ - /*------------------------------------------------------------------------- * Function: evict_on_close_test() * @@ -7843,14 +7542,14 @@ static unsigned evict_on_close_test(hbool_t single_file_vfd) { #ifndef H5_HAVE_PARALLEL - const char * fcn_name = "evict_on_close_test()"; - char filename[512]; - hbool_t show_progress = FALSE; - hbool_t verbose = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "evict_on_close_test()"; + char filename[512]; + hbool_t show_progress = FALSE; + hbool_t verbose = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; #endif /* H5_HAVE_PARALLEL */ TESTING("Cache image / evict on close interaction"); @@ -7862,7 +7561,7 @@ evict_on_close_test(hbool_t single_file_vfd) #else /* Check for VFD that is a single file */ - if(!single_file_vfd) { + if (!single_file_vfd) { SKIPPED(); HDputs(" Cache image not supported with the current VFD."); return 0; @@ -7870,36 +7569,33 @@ evict_on_close_test(hbool_t single_file_vfd) pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file without a cache image requested * and persistent free space managers enabled. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ TRUE, - /* set_eoc */ FALSE, + /* config_fsm */ TRUE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -7907,55 +7603,51 @@ evict_on_close_test(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create some data sets and verify them. */ - if ( pass ) { + if (pass) { create_datasets(file_id, 1, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { verify_datasets(file_id, 1, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed (1).\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file R/W, and with cache image requested. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, - /* set_eoc */ FALSE, + /* config_fsm */ FALSE, + /* set_eoc */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -7963,78 +7655,73 @@ evict_on_close_test(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Verify the datasets created in 2) above. This will * force their (clean) metadata into the metadata cache, * and hence into the cache image. */ - if ( pass ) { + if (pass) { verify_datasets(file_id, 1, 10); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Create some more datasets and verify them */ - if ( pass ) { + if (pass) { create_datasets(file_id, 11, 20); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { verify_datasets(file_id, 11, 20); } - if ( verbose ) { + if (verbose) { HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDfprintf(stdout, "index size / index dirty size = %lld / %lld\n", - (long long)(cache_ptr->index_size), + HDfprintf(stdout, "index size / index dirty size = %lld / %lld\n", (long long)(cache_ptr->index_size), (long long)(cache_ptr->dirty_index_size)); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed (2).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Open the file R/O and with evict on close enabled. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ TRUE, + /* config_fsm */ FALSE, + /* set_eoc */ TRUE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -8042,54 +7729,51 @@ evict_on_close_test(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s*: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Verify all datasets twice */ - if ( pass ) { + if (pass) { verify_datasets(file_id, 1, 20); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { verify_datasets(file_id, 1, 20); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed (3).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Open the file R/w and with evict on close enabled. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, - /* set_eoc */ TRUE, + /* config_fsm */ FALSE, + /* set_eoc */ TRUE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, /* file_id_ptr */ &file_id, @@ -8097,70 +7781,70 @@ evict_on_close_test(hbool_t single_file_vfd) /* cache_ptr_ptr */ &cache_ptr); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s*: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Verify all datasets twice */ - if ( pass ) { + if (pass) { verify_datasets(file_id, 1, 20); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { verify_datasets(file_id, 1, 20); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed (3).\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Discard the file. */ - if ( pass ) { + if (pass) { - if ( HDremove(filename) < 0 ) { + if (HDremove(filename) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if (pass) { + PASSED(); + } + else { + H5_FAILED(); + } - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", - FUNC, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", FUNC, failure_mssg); return !pass; #endif /* H5_HAVE_PARALLEL */ } /* evict_on_close_test() */ - /*------------------------------------------------------------------------- * Function: main * @@ -8178,14 +7862,14 @@ evict_on_close_test(hbool_t single_file_vfd) int main(void) { - const char *env_h5_drvr; /* File driver value from environment */ - hbool_t single_file_vfd; /* Whether VFD used stores data in a single file */ - unsigned nerrs = 0; - int express_test; + const char *env_h5_drvr; /* File driver value from environment */ + hbool_t single_file_vfd; /* Whether VFD used stores data in a single file */ + unsigned nerrs = 0; + int express_test; /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; H5open(); @@ -8198,7 +7882,8 @@ main(void) HDprintf("=========================================\n"); /* Check for VFD which stores data in multiple files */ - single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")); + single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && + HDstrcmp(env_h5_drvr, "family")); nerrs += check_cache_image_ctl_flow_1(single_file_vfd); nerrs += check_cache_image_ctl_flow_2(single_file_vfd); @@ -8222,7 +7907,6 @@ main(void) nerrs += get_free_sections_test(single_file_vfd); nerrs += evict_on_close_test(single_file_vfd); - return(nerrs > 0); + return (nerrs > 0); } /* main() */ - diff --git a/test/cache_logging.c b/test/cache_logging.c index c43609b..baf84f8 100644 --- a/test/cache_logging.c +++ b/test/cache_logging.c @@ -32,20 +32,20 @@ static herr_t test_logging_api(void) { - hid_t fapl = -1; - hbool_t is_enabled; - hbool_t is_enabled_out; - hbool_t start_on_access; - hbool_t start_on_access_out; - char *location = NULL; - size_t size; - - hid_t fid = -1; - hid_t gid = -1; - hbool_t is_currently_logging; - char group_name[12]; - char filename[1024]; - int i; + hid_t fapl = -1; + hbool_t is_enabled; + hbool_t is_enabled_out; + hbool_t start_on_access; + hbool_t start_on_access_out; + char * location = NULL; + size_t size; + + hid_t fid = -1; + hid_t gid = -1; + hbool_t is_currently_logging; + char group_name[12]; + char filename[1024]; + int i; TESTING("metadata cache log api calls"); @@ -53,85 +53,78 @@ test_logging_api(void) h5_fixname(FILE_NAME, fapl, filename, sizeof filename); /* Set up metadata cache logging */ - is_enabled = TRUE; + is_enabled = TRUE; start_on_access = FALSE; - if(H5Pset_mdc_log_options(fapl, is_enabled, LOG_LOCATION, start_on_access) < 0) + if (H5Pset_mdc_log_options(fapl, is_enabled, LOG_LOCATION, start_on_access) < 0) TEST_ERROR; /* Check to make sure that the property list getter returns the correct * location string buffer size; */ - is_enabled_out = FALSE; + is_enabled_out = FALSE; start_on_access_out = TRUE; - location = NULL; - size = 999; - if(H5Pget_mdc_log_options(fapl, &is_enabled_out, location, &size, - &start_on_access_out) < 0) + location = NULL; + size = 999; + if (H5Pget_mdc_log_options(fapl, &is_enabled_out, location, &size, &start_on_access_out) < 0) TEST_ERROR; - if(size != HDstrlen(LOG_LOCATION) + 1) + if (size != HDstrlen(LOG_LOCATION) + 1) TEST_ERROR; /* Check to make sure that the property list getter works */ - if(NULL == (location = (char *)HDcalloc(size, sizeof(char)))) + if (NULL == (location = (char *)HDcalloc(size, sizeof(char)))) TEST_ERROR; - if(H5Pget_mdc_log_options(fapl, &is_enabled_out, location, &size, - &start_on_access_out) < 0) + if (H5Pget_mdc_log_options(fapl, &is_enabled_out, location, &size, &start_on_access_out) < 0) TEST_ERROR; - if((is_enabled != is_enabled_out) - || (start_on_access != start_on_access_out) - || HDstrcmp(LOG_LOCATION, location)) + if ((is_enabled != is_enabled_out) || (start_on_access != start_on_access_out) || + HDstrcmp(LOG_LOCATION, location)) TEST_ERROR; /* Create a file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; - /* Check to see if the logging flags were set correctly */ - is_enabled = FALSE; + is_enabled = FALSE; is_currently_logging = TRUE; - if((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0) - || (is_enabled != TRUE) - || (is_currently_logging != FALSE)) + if ((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0) || (is_enabled != TRUE) || + (is_currently_logging != FALSE)) TEST_ERROR; /* Turn on logging and check flags */ - if(H5Fstart_mdc_logging(fid) < 0) + if (H5Fstart_mdc_logging(fid) < 0) TEST_ERROR; - is_enabled = FALSE; + is_enabled = FALSE; is_currently_logging = FALSE; - if((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0) - || (is_enabled != TRUE) - || (is_currently_logging != TRUE)) + if ((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0) || (is_enabled != TRUE) || + (is_currently_logging != TRUE)) TEST_ERROR; /* Perform some manipulations */ - for(i = 0; i < N_GROUPS; i++) { + for (i = 0; i < N_GROUPS; i++) { HDmemset(group_name, 0, sizeof(group_name)); HDsnprintf(group_name, sizeof(group_name), "%d", i); - if((gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR; } /* Turn off logging and check flags */ - if(H5Fstop_mdc_logging(fid) < 0) + if (H5Fstop_mdc_logging(fid) < 0) TEST_ERROR; - is_enabled = FALSE; + is_enabled = FALSE; is_currently_logging = TRUE; - if((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0) - || (is_enabled != TRUE) - || (is_currently_logging != FALSE)) + if ((H5Fget_mdc_logging_status(fid, &is_enabled, &is_currently_logging) < 0) || (is_enabled != TRUE) || + (is_currently_logging != FALSE)) TEST_ERROR; /* Clean up */ HDfree(location); - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; PASSED(); @@ -139,7 +132,7 @@ test_logging_api(void) error: return 1; - } /* test_logging_api() */ +} /* test_logging_api() */ /*------------------------------------------------------------------------- * Function: main @@ -163,9 +156,8 @@ main(void) nerrors += test_logging_api(); - if(nerrors) { - HDprintf("***** %d Metadata cache logging TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + if (nerrors) { + HDprintf("***** %d Metadata cache logging TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); HDexit(EXIT_FAILURE); } @@ -173,4 +165,3 @@ main(void) HDexit(EXIT_SUCCESS); } - diff --git a/test/cache_tagging.c b/test/cache_tagging.c index ddd63e4..02bdb5f 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -15,14 +15,14 @@ * * This file contains tests for metadata tagging. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING #include "H5Fpkg.h" #include "testhdf5.h" #include "cache_common.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5HLprivate.h" #include "H5VLnative_private.h" /* Native VOL connector */ @@ -30,23 +30,23 @@ /* Test Defines */ /* ============ */ -#define FILENAME "tagging_test.h5" -#define FILENAME2 "tagging_ext_test.h5" -#define GROUPNAME "Group" +#define FILENAME "tagging_test.h5" +#define FILENAME2 "tagging_ext_test.h5" +#define GROUPNAME "Group" #define GROUPNAMEPATH "/Group" #define GROUPNAMECOPY "GroupCopy" -#define ATTRNAME "Attribute 1" -#define ATTRNAME3 "Attribute 3" -#define DATASETNAME "Dataset" -#define DATASETNAME2 "Dataset2" -#define LINKNAME "Link" -#define RANK 2 -#define DIMS 32 +#define ATTRNAME "Attribute 1" +#define ATTRNAME3 "Attribute 3" +#define DATASETNAME "Dataset" +#define DATASETNAME2 "Dataset2" +#define LINKNAME "Link" +#define RANK 2 +#define DIMS 32 #define MULTIGROUPS 10 -#define TEST_DEFAULT 0 -#define TEST_SHMESG 1 +#define TEST_DEFAULT 0 +#define TEST_SHMESG 1 #define NUM_TEST_TYPES 2 /* ===================== */ @@ -92,12 +92,10 @@ static unsigned check_dense_attribute_tags(void); static unsigned check_link_iteration_tags(void); static unsigned check_invalid_tag_application(void); - /* ================ */ /* Helper Functions */ /* ================ */ - #ifndef NDEBUG /*------------------------------------------------------------------------- @@ -115,16 +113,17 @@ static unsigned check_invalid_tag_application(void); * *------------------------------------------------------------------------- */ -static int dump_cache(hid_t fid) +static int +dump_cache(hid_t fid) { - H5F_t *f; /* File Pointer */ + H5F_t *f; /* File Pointer */ /* Get Internal File / Cache Pointers */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR; /* Dump the cache */ - if(H5AC_dump_cache(f) < 0) + if (H5AC_dump_cache(f) < 0) TEST_ERROR; return 0; @@ -134,7 +133,6 @@ error: } /* dump_cache */ #endif /* NDEBUG */ /* end debugging functions */ - /*------------------------------------------------------------------------- * Function: verify_no_unknown_tags() * @@ -155,26 +153,26 @@ static int verify_no_unknown_tags(hid_t fid) { - H5F_t *f; /* File Pointer */ - H5C_t *cache_ptr; /* Cache Pointer */ - int i; /* Iterator */ + H5F_t *f; /* File Pointer */ + H5C_t *cache_ptr; /* Cache Pointer */ + int i; /* Iterator */ /* Get Internal File / Cache Pointers */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR; cache_ptr = f->shared->cache; - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) { - H5C_cache_entry_t *entry_ptr; /* entry pointer */ + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { + H5C_cache_entry_t *entry_ptr; /* entry pointer */ entry_ptr = cache_ptr->index[i]; - while(entry_ptr != NULL) { - if(!entry_ptr->dirtied) + while (entry_ptr != NULL) { + if (!entry_ptr->dirtied) TEST_ERROR; entry_ptr = entry_ptr->ht_next; } /* end if */ - } /* end for */ + } /* end for */ return 0; @@ -182,7 +180,6 @@ error: return -1; } /* verify_no_unknown_tags */ - /*------------------------------------------------------------------------- * Function: mark_all_entries_investigated() * @@ -203,26 +200,26 @@ error: static int mark_all_entries_investigated(hid_t fid) { - H5F_t *f; /* File Pointer */ - H5C_t *cache_ptr; /* Cache Pointer */ - int i; /* Iterator */ + H5F_t *f; /* File Pointer */ + H5C_t *cache_ptr; /* Cache Pointer */ + int i; /* Iterator */ /* Get Internal File / Cache Pointers */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR; cache_ptr = f->shared->cache; - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) { - H5C_cache_entry_t *entry_ptr; /* entry pointer */ + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { + H5C_cache_entry_t *entry_ptr; /* entry pointer */ entry_ptr = cache_ptr->index[i]; - while(entry_ptr != NULL) { - if(!entry_ptr->dirtied) + while (entry_ptr != NULL) { + if (!entry_ptr->dirtied) entry_ptr->dirtied = TRUE; entry_ptr = entry_ptr->ht_next; } /* end if */ - } /* end for */ + } /* end for */ return 0; @@ -230,7 +227,6 @@ error: return -1; } /* mark_all_entries_investigated */ - /*------------------------------------------------------------------------- * Function: reset_all_entries_investigated() * @@ -249,26 +245,26 @@ error: static int reset_all_entries_investigated(hid_t fid) { - H5F_t *f; /* File Pointer */ - H5C_t *cache_ptr; /* Cache Pointer */ - int i; /* Iterator */ + H5F_t *f; /* File Pointer */ + H5C_t *cache_ptr; /* Cache Pointer */ + int i; /* Iterator */ /* Get Internal File / Cache Pointers */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR; cache_ptr = f->shared->cache; - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) { - H5C_cache_entry_t *entry_ptr; /* entry pointer */ + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { + H5C_cache_entry_t *entry_ptr; /* entry pointer */ entry_ptr = cache_ptr->index[i]; - while(entry_ptr != NULL) { - if(entry_ptr->dirtied) + while (entry_ptr != NULL) { + if (entry_ptr->dirtied) entry_ptr->dirtied = FALSE; entry_ptr = entry_ptr->ht_next; } /* end if */ - } /* end for */ + } /* end for */ return 0; @@ -276,7 +272,6 @@ error: return -1; } /* reset_all_entries_investigated */ - /*------------------------------------------------------------------------- * Function: verify_tag() * @@ -297,22 +292,22 @@ error: static int verify_tag(hid_t fid, int id, haddr_t tag) { - H5F_t *f; /* File Pointer */ - H5C_t *cache_ptr; /* Cache Pointer */ - int i; /* Iterator */ + H5F_t *f; /* File Pointer */ + H5C_t *cache_ptr; /* Cache Pointer */ + int i; /* Iterator */ /* Get Internal File / Cache Pointers */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR; cache_ptr = f->shared->cache; - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) { + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { H5C_cache_entry_t *entry_ptr; /* entry pointer */ entry_ptr = cache_ptr->index[i]; - while(entry_ptr != NULL) { - if(entry_ptr->type->id == id && !entry_ptr->dirtied) { - if(entry_ptr->tag_info->tag != tag) + while (entry_ptr != NULL) { + if (entry_ptr->type->id == id && !entry_ptr->dirtied) { + if (entry_ptr->tag_info->tag != tag) TEST_ERROR; /* Mark the entry/tag pair as found */ @@ -324,7 +319,7 @@ verify_tag(hid_t fid, int id, haddr_t tag) entry_ptr = entry_ptr->ht_next; } /* end if */ - } /* end for */ + } /* end for */ /* Didn't find the tagged entry, throw an error */ TEST_ERROR; @@ -339,18 +334,18 @@ error: static int evict_entries(hid_t fid) { - H5F_t *f; /* File Pointer */ + H5F_t *f; /* File Pointer */ /* Get Internal File / Cache Pointers */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR; /* Mark all entries investigated */ mark_all_entries_investigated(fid); /* Evict all we can from the cache to examine full tag creation tree */ - /* This function will likely return failure since the root group - * is still protected. Thus, don't check its return value. */ + /* This function will likely return failure since the root group + * is still protected. Thus, don't check its return value. */ H5C_flush_cache(f, H5C__FLUSH_INVALIDATE_FLAG); return 0; @@ -359,7 +354,6 @@ error: return -1; } /* evict entries */ - /*------------------------------------------------------------------------- * Function: get_object_header_tag() * @@ -375,14 +369,14 @@ error: static int get_object_header_tag(hid_t loc_id, haddr_t *tag) { - H5O_info2_t oinfo; /* Object info */ + H5O_info2_t oinfo; /* Object info */ /* Retrieve the info for the object */ - if(H5Oget_info3(loc_id, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(loc_id, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR; /* Set the tag to return */ - if(H5VLnative_token_to_addr(loc_id, oinfo.token, tag) < 0) + if (H5VLnative_token_to_addr(loc_id, oinfo.token, tag) < 0) TEST_ERROR; return 0; @@ -391,7 +385,6 @@ error: return -1; } /* get_object_header_tag */ - /*------------------------------------------------------------------------- * Function: get_sbe_tag() * @@ -409,7 +402,7 @@ static int get_sbe_tag(hid_t fid, haddr_t *tag) { /* Retrieve the superblock extension's object header address for the file */ - if(H5F__get_sbe_addr_test(fid, tag) < 0) + if (H5F__get_sbe_addr_test(fid, tag) < 0) TEST_ERROR; return 0; @@ -422,7 +415,6 @@ error: /* Test Functions */ /* ============== */ - /*------------------------------------------------------------------------- * Function: check_file_creation_tags * @@ -440,69 +432,85 @@ static unsigned check_file_creation_tags(hid_t fcpl_id, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ + hid_t fid = -1; /* File Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose test outout */ + int verbose = FALSE; /* verbose test outout */ #endif - hid_t fapl = -1; /* File access prop list */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; - haddr_t sbe_tag = 0; + haddr_t sbe_tag = 0; /* Testing Macro */ TESTING("tag application during file creation"); /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; #ifndef NDEBUG /* if verbose, print cache index to screen before verification . */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* verify there is a superblock entry with superblock tag */ - if ( verify_tag(fid, H5AC_SUPERBLOCK_ID, H5AC__SUPERBLOCK_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SUPERBLOCK_ID, H5AC__SUPERBLOCK_TAG) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* determine tag value of superblock extension object header */ - if ( get_sbe_tag(fid, &sbe_tag) < 0 ) TEST_ERROR; + if (get_sbe_tag(fid, &sbe_tag) < 0) + TEST_ERROR; /* verify object header belonging to superblock extension */ - if ( verify_tag(fid, H5AC_OHDR_ID, sbe_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, sbe_tag) < 0) + TEST_ERROR; /* verify sohm master table with sohm tag */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify object header chunk belonging to superblock extension */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, sbe_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, sbe_tag) < 0) + TEST_ERROR; - } /* end if */ + } /* end if */ /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* verify object header belonging to superblock extension */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; /* verify local heap prefix belonging to root group */ - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; /* verify b-tree node belonging to root group */ - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* verify no other cache entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* Close the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; PASSED(); return 0; @@ -511,7 +519,6 @@ error: return 1; } /* check_file_creation_tags */ - /*------------------------------------------------------------------------- * Function: check_file_open_tags * @@ -529,13 +536,13 @@ static unsigned check_file_open_tags(hid_t fcpl, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ + hid_t fid = -1; /* File Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag; /* Root Group Tag */ - haddr_t sbe_tag; /* Sblock Extension Tag */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag; /* Root Group Tag */ + haddr_t sbe_tag; /* Sblock Extension Tag */ /* Testing Macro */ TESTING("tag application during file open"); @@ -545,74 +552,90 @@ check_file_open_tags(hid_t fcpl, int type) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Retrieve various tags */ - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* determine tag value of superblock extension object header */ - if ( get_sbe_tag(fid, &sbe_tag) < 0 ) TEST_ERROR; + if (get_sbe_tag(fid, &sbe_tag) < 0) + TEST_ERROR; } /* end if */ /* Close the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* =================== */ /* TEST: Open The File */ /* =================== */ - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen before verification . */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* verify there is a superblock entry with superblock tag. */ - if ( verify_tag(fid, H5AC_SUPERBLOCK_ID, H5AC__SUPERBLOCK_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SUPERBLOCK_ID, H5AC__SUPERBLOCK_TAG) < 0) + TEST_ERROR; /* Verify test-type-dependent tags */ - if ( type == TEST_DEFAULT ) { + if (type == TEST_DEFAULT) { /* verify there is an object header belonging to the root group. */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - - } else if ( type == TEST_SHMESG ) { + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + } + else if (type == TEST_SHMESG) { /* verify there is a superblock extension object header. */ - if ( verify_tag(fid, H5AC_OHDR_ID, sbe_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, sbe_tag) < 0) + TEST_ERROR; /* verify sohm master table with sohm tag */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify object header chunk belonging to superblock extension */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, sbe_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, sbe_tag) < 0) + TEST_ERROR; } /* end if */ /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* ========== */ /* Close file */ /* ========== */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -625,7 +648,6 @@ error: return 1; } /* check_file_open_tags */ - /*------------------------------------------------------------------------- * Function: check_group_creation_tags * @@ -643,14 +665,14 @@ static unsigned check_group_creation_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t gid = -1; /* Group Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t gid = -1; /* Group Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = HADDR_UNDEF; /* Root Group Tag */ - haddr_t g_tag; /* Group Tag */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = HADDR_UNDEF; /* Root Group Tag */ + haddr_t g_tag; /* Group Tag */ /* Testing Macro */ TESTING("tag application during group creation"); @@ -660,62 +682,83 @@ check_group_creation_tags(void) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ==================== */ /* TEST: Create a Group */ /* ==================== */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* Verify new group's tagged metadata */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, g_tag) < 0) + TEST_ERROR; /* verify no other cache entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -728,7 +771,6 @@ error: return 1; } /* check_group_creation_tags */ - /*------------------------------------------------------------------------- * Function: check_multi_group_creation_tags * @@ -746,34 +788,38 @@ static unsigned check_multi_group_creation_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t gid = -1; /* Group Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t gid = -1; /* Group Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - char gname[16]; /* group name buffer */ - int i = 0; /* iterator */ - hid_t fapl = -1; /* File access prop list */ - haddr_t g_tag = 0; /* Group tag value */ - haddr_t root_tag = 0; /* Root group tag value */ + char gname[16]; /* group name buffer */ + int i = 0; /* iterator */ + hid_t fapl = -1; /* File access prop list */ + haddr_t g_tag = 0; /* Group tag value */ + haddr_t root_tag = 0; /* Root group tag value */ /* Testing Macro */ TESTING("tag application during multiple group creation"); /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Set latest version of library */ - if ( H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 ) TEST_ERROR; + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR; /* =========== */ /* Create File */ /* =========== */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Clear Metadata Tags (don't care about them for this test) */ mark_all_entries_investigated(fid); @@ -785,8 +831,10 @@ check_multi_group_creation_tags(void) for (i = 0; i < MULTIGROUPS; i++) { HDsprintf(gname, "%d", i); - if ( (gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Gclose(gid) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; } /* end for */ @@ -796,7 +844,8 @@ check_multi_group_creation_tags(void) #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify there is an object header for each group */ @@ -804,48 +853,63 @@ check_multi_group_creation_tags(void) /* Re-open the group */ HDsprintf(gname, "%d", i); - if ( (gid = H5Gopen2(fid, gname, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gopen2(fid, gname, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Verify object header for root group */ /* ('dirtied' flag on entry gets cleared with each open operation) */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; /* Retrieve the object address for the group */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Verify object header for group */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; /* Close the group */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; } /* end for */ /* Verify free space header and section info */ - if ( verify_tag(fid, H5AC_FSPACE_SINFO_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FSPACE_SINFO_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_FSPACE_HDR_ID, root_tag) < 0) + TEST_ERROR; /* verify fractal heap header belonging to root group */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, root_tag) < 0) + TEST_ERROR; /* verify fractal heap direct block belonging to root group */ - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, root_tag) < 0) + TEST_ERROR; /* verify btree header and leaf node belonging to root group */ - if ( verify_tag(fid, H5AC_BT2_HDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_HDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, root_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -858,7 +922,6 @@ error: return 1; } /* check_multi_group_creation_tags */ - /*------------------------------------------------------------------------- * Function: check_link_iteration_tags * @@ -876,49 +939,59 @@ static unsigned check_link_iteration_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t sid = -1; /* Group Identifier */ - hid_t did = -1; /* Group Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t sid = -1; /* Group Identifier */ + hid_t did = -1; /* Group Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - int i = 0; /* iterator */ - haddr_t root_tag = 0; /* Root Group Tag Value */ - char dsetname[500]; /* Name of dataset */ - H5G_info_t ginfo; /* Group Info Struct */ - hid_t fapl = -1; /* File access prop list */ - hid_t root_group = -1; /* Root Group Identifier */ + int i = 0; /* iterator */ + haddr_t root_tag = 0; /* Root Group Tag Value */ + char dsetname[500]; /* Name of dataset */ + H5G_info_t ginfo; /* Group Info Struct */ + hid_t fapl = -1; /* File access prop list */ + hid_t root_group = -1; /* Root Group Identifier */ /* Testing Macro */ TESTING("tag application during iteration over links in a group"); /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* =========== */ /* Create File */ /* =========== */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* Get root group tag */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create dataspace */ - if ( (sid = H5Screate(H5S_SCALAR)) < 0 ) TEST_ERROR; + if ((sid = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR; /* Create many datasets in root group */ - for (i=0;i<500;i++) { + for (i = 0; i < 500; i++) { HDsprintf(dsetname, "Dset %d", i); - if ( (did = H5Dcreate2(fid, dsetname, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Dclose(did) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, dsetname, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; } /* Close and Reopen the file (to clear cache) */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR; /* clear remaining metadata tags */ mark_all_entries_investigated(fid); @@ -928,44 +1001,55 @@ check_link_iteration_tags(void) /* ================================ */ /* Open root group */ - if ( (root_group = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((root_group = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + TEST_ERROR; /* Get root group info (will iterate over all links in group) */ - if ( H5Gget_info(root_group, &ginfo) < 0 ) TEST_ERROR; + if (H5Gget_info(root_group, &ginfo) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; /* Verify 112 symbol table nodes belonging to the root group */ for (i = 0; i < 112; i++) - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; /* Verify 9 b-tree nodes belonging to the root group */ for (i = 0; i < 9; i++) - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Sclose(sid) < 0 ) TEST_ERROR; - if ( H5Gclose(root_group) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Sclose(sid) < 0) + TEST_ERROR; + if (H5Gclose(root_group) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -978,7 +1062,6 @@ error: return 1; } /* check_link_iteration_tags */ - /*------------------------------------------------------------------------- * Function: check_dense_attribute_tags * @@ -996,49 +1079,59 @@ static unsigned check_dense_attribute_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t aid = -1; /* File Identifier */ - hid_t sid = -1; /* Group Identifier */ - hid_t did = -1; /* Group Identifier */ - hid_t dcpl = -1; /* Group Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t aid = -1; /* File Identifier */ + hid_t sid = -1; /* Group Identifier */ + hid_t did = -1; /* Group Identifier */ + hid_t dcpl = -1; /* Group Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - int i = 0; /* iterator */ - hid_t fapl = -1; /* File access property list */ - haddr_t d_tag = 0; /* Dataset tag value */ - haddr_t root_tag = 0; /* Root group tag value */ - char attrname[500]; /* Name of attribute */ + int i = 0; /* iterator */ + hid_t fapl = -1; /* File access property list */ + haddr_t d_tag = 0; /* Dataset tag value */ + haddr_t root_tag = 0; /* Root group tag value */ + char attrname[500]; /* Name of attribute */ /* Testing Macro */ TESTING("tag application during dense attribute manipulation"); /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; - if ( H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR; /* Create Dcpl */ - if ( (dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0 ) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* =========== */ /* Create File */ /* =========== */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create dataspace */ - if ( (sid = H5Screate(H5S_SCALAR)) < 0 ) TEST_ERROR; + if ((sid = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR; /* Create dataset */ - if ( (did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* get dataset object header */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* Clear Metadata Tags (don't care about them for this test */ mark_all_entries_investigated(fid); @@ -1047,12 +1140,15 @@ check_dense_attribute_tags(void) /* Create Many attributes, triggering dense storage */ /* ================================================ */ - for (i=0;i<50;i++) { + for (i = 0; i < 50; i++) { HDsprintf(attrname, "attr %d", i); - if ( (aid = H5Acreate2(did, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0 ) TEST_ERROR; - if ( H5Aclose(aid) < 0 ) TEST_ERROR; + if ((aid = H5Acreate2(did, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; } /* end for */ @@ -1062,48 +1158,65 @@ check_dense_attribute_tags(void) #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify free space header and section info */ - if ( verify_tag(fid, H5AC_FSPACE_SINFO_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FSPACE_SINFO_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_FSPACE_HDR_ID, d_tag) < 0) + TEST_ERROR; /* verify object header belonging to dataset */ - if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0) + TEST_ERROR; /* verify fractal heap header belonging to dataset */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, d_tag) < 0) + TEST_ERROR; /* verify fractal heap direct block belonging to root group */ - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, d_tag) < 0) + TEST_ERROR; /* verify btree header and leaf node belonging to dataset */ - if ( verify_tag(fid, H5AC_BT2_HDR_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_INT_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_HDR_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_INT_ID, d_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ======================= */ /* Reopen file and dataset */ /* ======================= */ - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( (did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Clear Metadata Tags (don't care about them for this test */ mark_all_entries_investigated(fid); @@ -1112,47 +1225,64 @@ check_dense_attribute_tags(void) /* Open attribute by index */ /* ======================= */ - if ( (aid = H5Aopen_by_idx(did, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((aid = H5Aopen_by_idx(did, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* verify object header belonging to dataset */ - if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0) + TEST_ERROR; /* verify fractal heap header belonging to dataset */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, d_tag) < 0) + TEST_ERROR; /* verify fractal heap direct block belonging to root group */ - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FHEAP_IBLOCK_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_IBLOCK_ID, d_tag) < 0) + TEST_ERROR; /* verify btree header and leaf node belonging to dataset */ - if ( verify_tag(fid, H5AC_BT2_HDR_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, d_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_INT_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_HDR_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, d_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_INT_ID, d_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Aclose(aid) < 0 ) TEST_ERROR; - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -1165,7 +1295,6 @@ error: return 1; } /* check_dense_attribute_tags */ - /*------------------------------------------------------------------------- * Function: check_group_open_tags * @@ -1183,12 +1312,12 @@ static unsigned check_group_open_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t gid = -1; /* Group Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t gid = -1; /* Group Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file output */ + int verbose = FALSE; /* verbose file output */ #endif - hid_t fapl = -1; /* File access prop list */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = HADDR_UNDEF; haddr_t g_tag; @@ -1200,68 +1329,89 @@ check_group_open_tags(void) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Close Group */ - if (H5Gclose(gid) < 0) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ================ */ /* TEST: Open Group */ /* ================ */ - if ( (gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* Verify opened group metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -1274,7 +1424,6 @@ error: return 1; } /* check_group_open_tags */ - /*------------------------------------------------------------------------- * Function: check_attribute_creation_tags * @@ -1292,17 +1441,17 @@ static unsigned check_attribute_creation_tags(hid_t fcpl, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t aid = -1; /* Attribute Identifier */ - hid_t gid = -1; /* Group Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t aid = -1; /* Attribute Identifier */ + hid_t gid = -1; /* Group Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; /* Root group tag */ - haddr_t g_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; /* Root group tag */ + haddr_t g_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ /* Testing Macro */ @@ -1313,91 +1462,121 @@ check_attribute_creation_tags(hid_t fcpl, int type) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Close and Reopen the file and group */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( (gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ========================= */ /* Create Attribute on Group */ /* ========================= */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; - if ( (aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* verify object header belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; /* verify object header chunk belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* verify (another) object header chunk belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0) + TEST_ERROR; /* verify shared message index tagged with sohm */ - if ( verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify fractal heap header belonging to group */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify fractal heap direct block belonging to group */ - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* Verify free space header and free space section */ - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FSPACE_SINFO_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_FSPACE_SINFO_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify btree header and leaf node belonging to group */ - if ( verify_tag(fid, H5AC_BT2_HDR_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_HDR_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; } /* end if */ /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Aclose(aid) < 0 ) TEST_ERROR; - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -1410,7 +1589,6 @@ error: return 1; } /* check_attribute_creation_tags */ - /*------------------------------------------------------------------------- * Function: check_attribute_open_tags * @@ -1428,17 +1606,17 @@ static unsigned check_attribute_open_tags(hid_t fcpl, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t aid = -1; /* Attribute Identifier */ - hid_t gid = -1; /* Group Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t aid = -1; /* Attribute Identifier */ + hid_t gid = -1; /* Group Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t g_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t g_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ /* Testing Macro */ @@ -1449,94 +1627,123 @@ check_attribute_open_tags(hid_t fcpl, int type) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Create attribute dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create attribute on group */ - if ( (aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Close attribute */ - if ( H5Aclose(aid) < 0 ) TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; /* Close and Reopen the file and group */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( (gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ========================= */ /* Open Attribute of Group */ /* ========================= */ - if ( (aid = H5Aopen(gid, ATTRNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((aid = H5Aopen(gid, ATTRNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* verify object header belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; /* verify object header chunk belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* verify (another) object header chunk belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0) + TEST_ERROR; /* verify shared header message master table */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify fractal heap header belonging to group */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, g_tag) < 0) + TEST_ERROR; /* verify fractal heap direct block belonging to group */ - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, g_tag) < 0) + TEST_ERROR; /* verify btree header and leaf node belonging to group */ - if ( verify_tag(fid, H5AC_BT2_HDR_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_HDR_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, g_tag) < 0) + TEST_ERROR; } /* end if */ /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Aclose(aid) < 0 ) TEST_ERROR; - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -1549,7 +1756,6 @@ error: return 1; } /* check_attribute_open_tags */ - /*------------------------------------------------------------------------- * Function: check_attribute_rename_tags * @@ -1567,20 +1773,20 @@ static unsigned check_attribute_rename_tags(hid_t fcpl, int type) { /* Variable declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t gid = -1; /* Group Identifier */ - hid_t aid = -1; /* Attribute Identifier */ - hid_t sid = -1; /* Dataset Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t gid = -1; /* Group Identifier */ + hid_t aid = -1; /* Attribute Identifier */ + hid_t sid = -1; /* Dataset Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - int *data = NULL; /* data buffer */ - int i,j,k = 0; /* iterators */ - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t g_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ + int * data = NULL; /* data buffer */ + int i, j, k = 0; /* iterators */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t g_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ hbool_t persistent_fsms = FALSE; /* Testing Macro */ @@ -1591,125 +1797,162 @@ check_attribute_rename_tags(hid_t fcpl, int type) /* ===== */ /* check to see if the FCPL specified persistent free space managers */ - if(H5Pget_file_space_strategy(fcpl, NULL, &persistent_fsms, NULL) < 0) + if (H5Pget_file_space_strategy(fcpl, NULL, &persistent_fsms, NULL) < 0) TEST_ERROR; /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Set up attribute dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create attribute */ - if ( (aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* fill out data buffer */ - for(i = 0; i < DIMS; i++) - for(j = 0; j < DIMS; j++) + for (i = 0; i < DIMS; i++) + for (j = 0; j < DIMS; j++) data[(DIMS * i) + j] = k++; /* Write to attribute */ - if ( H5Awrite(aid, H5T_NATIVE_INT, data) < 0 ) TEST_ERROR; + if (H5Awrite(aid, H5T_NATIVE_INT, data) < 0) + TEST_ERROR; /* Close Attribute */ - if ( H5Aclose(aid) < 0 ) TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; /* Close and Reopen the file and group */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( (gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ========================= */ /* Rename Attribute of Group */ /* ========================= */ - if ( H5Arename_by_name(fid, GROUPNAME, ATTRNAME, ATTRNAME3, H5P_DEFAULT) < 0 ) TEST_ERROR; + if (H5Arename_by_name(fid, GROUPNAME, ATTRNAME, ATTRNAME3, H5P_DEFAULT) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* verify object header belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; /* verify object header chunk belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* verify (another) object header chunk belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0) + TEST_ERROR; /* verify shared header message master table */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify fractal heap header belonging to group */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, g_tag) < 0) + TEST_ERROR; /* verify fractal heap direct block belonging to group */ - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, g_tag) < 0) + TEST_ERROR; /* verify shared header message stored as a list */ - if ( verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* * one freespace header tag for H5FD_MEM_DRAW manager, * one freespace header tag for H5FD_MEM_SUPER manager */ - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0) + TEST_ERROR; /* verify btree header and leaf node belonging to group */ - if ( verify_tag(fid, H5AC_BT2_HDR_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_HDR_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, g_tag) < 0) + TEST_ERROR; } /* end if */ /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -1721,12 +1964,11 @@ check_attribute_rename_tags(hid_t fcpl, int type) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_attribute_rename_tags */ - /*------------------------------------------------------------------------- * Function: check_attribute_delete_tags * @@ -1744,20 +1986,20 @@ static unsigned check_attribute_delete_tags(hid_t fcpl, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t gid = -1; /* Group Identifier */ - hid_t aid = -1; /* Attribute Identifier */ - hid_t sid = -1; /* Dataset Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t gid = -1; /* Group Identifier */ + hid_t aid = -1; /* Attribute Identifier */ + hid_t sid = -1; /* Dataset Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - int *data = NULL; /* data buffer */ - int i,j,k = 0; /* iterators */ - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t g_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ + int * data = NULL; /* data buffer */ + int i, j, k = 0; /* iterators */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t g_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ hbool_t persistent_fsms = FALSE; /* Testing Macro */ @@ -1768,77 +2010,97 @@ check_attribute_delete_tags(hid_t fcpl, int type) /* ===== */ /* check to see if the FCPL specified persistent free space managers */ - if ( H5Pget_file_space_strategy(fcpl, NULL, &persistent_fsms, NULL) < 0 ) + if (H5Pget_file_space_strategy(fcpl, NULL, &persistent_fsms, NULL) < 0) TEST_ERROR; /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Set up attribute dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create attribute */ - if ( (aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* fill out data buffer */ - for(i = 0;i < DIMS; i++) - for(j = 0;j < DIMS; j++) + for (i = 0; i < DIMS; i++) + for (j = 0; j < DIMS; j++) data[(DIMS * i) + j] = k++; /* Write to attribute */ - if ( (H5Awrite(aid, H5T_NATIVE_INT, data)) < 0 ) TEST_ERROR; + if ((H5Awrite(aid, H5T_NATIVE_INT, data)) < 0) + TEST_ERROR; /* Close Attribute */ - if ( H5Aclose(aid) < 0 ) TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; /* Close and Reopen the file and group */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( (gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ========================= */ /* Delete Attribute of Group */ /* ========================= */ - if ( (H5Adelete(gid, ATTRNAME)) < 0 ) TEST_ERROR; + if ((H5Adelete(gid, ATTRNAME)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* verify object header belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* verify shared header message master table */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* * 2 calls to verify_tag() for verifying free space: @@ -1846,11 +2108,11 @@ check_attribute_delete_tags(hid_t fcpl, int type) * one freespace header tag for free-space section info raw data * one freespace header tag for free-space header metadata */ - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) + if (verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0) TEST_ERROR; - if ( verify_tag(fid, H5AC_FSPACE_SINFO_ID, H5AC__FREESPACE_TAG) < 0 ) + if (verify_tag(fid, H5AC_FSPACE_SINFO_ID, H5AC__FREESPACE_TAG) < 0) TEST_ERROR; - if ( verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0 ) + if (verify_tag(fid, H5AC_FSPACE_HDR_ID, H5AC__FREESPACE_TAG) < 0) TEST_ERROR; #if 0 @@ -1868,17 +2130,21 @@ check_attribute_delete_tags(hid_t fcpl, int type) } /* end if */ /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -1890,12 +2156,11 @@ check_attribute_delete_tags(hid_t fcpl, int type) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_attribute_delete_tags */ - /*------------------------------------------------------------------------- * Function: check_dataset_creation_tags * @@ -1913,19 +2178,19 @@ static unsigned check_dataset_creation_tags(hid_t fcpl, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ /* Testing Macro */ @@ -1936,21 +2201,28 @@ check_dataset_creation_tags(hid_t fcpl, int type) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ============================ */ /* Create Dataset in Root Group */ @@ -1960,64 +2232,83 @@ check_dataset_creation_tags(hid_t fcpl, int type) dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Enable chunking */ - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; /* Set up a fill value */ - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create Dataset */ - if (( did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* Get dataset's object header address */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* Verify object header for group */ - if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* verify shared header message master table */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* Verify dataset's tagged metadata */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* Verify shared object header message tags */ - if ( verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; } /* end if */ /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -2030,7 +2321,6 @@ error: return 1; } /* check_dataset_creation_tags */ - /*------------------------------------------------------------------------- * Function: check_dataset_creation_earlyalloc_tags * @@ -2048,21 +2338,21 @@ static unsigned check_dataset_creation_earlyalloc_tags(hid_t fcpl, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ - int i = 0; /* iterator */ + int i = 0; /* iterator */ /* Testing Macro */ TESTING("tag application during dataset creation with early allocation"); @@ -2072,21 +2362,28 @@ check_dataset_creation_earlyalloc_tags(hid_t fcpl, int type) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ============================ */ /* Create Dataset in Root Group */ @@ -2094,69 +2391,90 @@ check_dataset_creation_earlyalloc_tags(hid_t fcpl, int type) dcpl = H5Pcreate(H5P_DATASET_CREATE); - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set early allocation time */ - if ( H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0 ) TEST_ERROR; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; - if (( did = H5Dcreate2(fid, DATASETNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* Get dataset's object header address */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* Verify object header for group */ - if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* verify shared header message master table */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* Verify dataset's tagged metadata */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* Verify shared object header message tags */ - if ( verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; } /* end if */ /* Verify 19 b-tree nodes belonging to dataset */ - for (i=0; i<19; i++) - if ( verify_tag(fid, H5AC_BT_ID, d_tag) < 0 ) TEST_ERROR; + for (i = 0; i < 19; i++) + if (verify_tag(fid, H5AC_BT_ID, d_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -2169,7 +2487,6 @@ error: return 1; } /* check_dataset_creation_earlyalloc_tags */ - /*------------------------------------------------------------------------- * Function: check_dataset_open_tags * @@ -2187,19 +2504,19 @@ static unsigned check_dataset_open_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ /* Testing Macro */ @@ -2210,81 +2527,106 @@ check_dataset_open_tags(void) /* ========= */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Set up creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Enable chunking */ - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; /* Set up a fill value */ - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create Dataset */ - if (( did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* Retrieve tag associated with this dataset */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* Close Dataset */ - if (H5Dclose(did) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ========================== */ /* Open Dataset in Root Group */ /* ========================== */ - if (( did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* Verify dataset's object header */ - if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -2297,7 +2639,6 @@ error: return 1; } /* check_dataset_open_tags */ - /*------------------------------------------------------------------------- * Function: check_dataset_write_tags * @@ -2315,22 +2656,22 @@ static unsigned check_dataset_write_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ - int i,j,k = 0; /* iterators */ - int *data = NULL; /* data buffer */ + int i, j, k = 0; /* iterators */ + int * data = NULL; /* data buffer */ /* Testing Macro */ TESTING("tag application during dataset write"); @@ -2340,90 +2681,114 @@ check_dataset_write_tags(void) /* ===== */ /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Set up creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Enable chunking */ - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; /* Set up a fill value */ - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create Dataset */ - if (( did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* Retrieve tag associated with this dataset */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* Close and Reopen the file and dataset */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if (( did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ============================== */ /* Write to Dataset in Root Group */ /* ============================== */ /* fill out data buffer */ - for(i = 0;i < DIMS; i++) { - for(j = 0;j < DIMS; j++) { + for (i = 0; i < DIMS; i++) { + for (j = 0; j < DIMS; j++) { - data[(DIMS *i) + j] = k++; + data[(DIMS * i) + j] = k++; } /* end for */ - } /* end for */ + } /* end for */ /* Write to dataset */ - if( (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0 ) TEST_ERROR; + if ((H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify 10 b-tree nodes belonging to dataset */ - for (i=0; i<10; i++) - if ( verify_tag(fid, H5AC_BT_ID, d_tag) < 0 ) TEST_ERROR; + for (i = 0; i < 10; i++) + if (verify_tag(fid, H5AC_BT_ID, d_tag) < 0) + TEST_ERROR; /* Verify object header for dataset */ - if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -2435,12 +2800,11 @@ check_dataset_write_tags(void) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_dataset_write_tags */ - /*------------------------------------------------------------------------- * Function: check_attribute_write_tags * @@ -2458,19 +2822,19 @@ static unsigned check_attribute_write_tags(hid_t fcpl, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t gid = -1; /* Group Identifier */ - hid_t aid = -1; /* Attribute Identifier */ - hid_t sid = -1; /* Dataset Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t gid = -1; /* Group Identifier */ + hid_t aid = -1; /* Attribute Identifier */ + hid_t sid = -1; /* Dataset Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - int *data = NULL; /* data buffer */ - int i,j,k = 0; /* iterators */ - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t g_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + int * data = NULL; /* data buffer */ + int i, j, k = 0; /* iterators */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t g_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ /* Testing Macro */ @@ -2481,105 +2845,137 @@ check_attribute_write_tags(hid_t fcpl, int type) /* ===== */ /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Create attribute dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create attribute on group */ - if ( (aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Close and Reopen the file, group, and attribute */ - if ( H5Aclose(aid) < 0 ) TEST_ERROR; - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( (gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( (aid = H5Aopen(gid, ATTRNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((aid = H5Aopen(gid, ATTRNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* =========================== */ /* Write to Attribute in Group */ /* =========================== */ /* fill out data buffer */ - for(i = 0; i < DIMS; i++) - for(j = 0;j < DIMS; j++) + for (i = 0; i < DIMS; i++) + for (j = 0; j < DIMS; j++) data[(DIMS * i) + j] = k++; /* Write attribute */ - if ( (H5Awrite(aid, H5T_NATIVE_INT, data)) < 0 ) TEST_ERROR; + if ((H5Awrite(aid, H5T_NATIVE_INT, data)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify object header of group */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; /* verify object header chunk belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* verify (another) object header chunk belonging to group */ - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, g_tag) < 0) + TEST_ERROR; /* verify shared header message master table and list */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify fractal heap header belonging to group */ - if ( verify_tag(fid, H5AC_FHEAP_HDR_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_HDR_ID, g_tag) < 0) + TEST_ERROR; /* verify fractal heap direct block belonging to group */ - if ( verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_FHEAP_DBLOCK_ID, g_tag) < 0) + TEST_ERROR; /* Verify SOHM list */ - if ( verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_LIST_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; /* verify btree header and leaf node belonging to group */ - if ( verify_tag(fid, H5AC_BT2_HDR_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT2_LEAF_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_HDR_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT2_LEAF_ID, g_tag) < 0) + TEST_ERROR; } /* end if */ /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Aclose(aid) < 0 ) TEST_ERROR; - if ( H5Gclose(gid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -2591,12 +2987,11 @@ check_attribute_write_tags(hid_t fcpl, int type) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_attribute_write_tags */ - /*------------------------------------------------------------------------- * Function: check_dataset_read_tags * @@ -2614,22 +3009,22 @@ static unsigned check_dataset_read_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ - int i,j,k = 0; /* iterators */ - int *data = NULL; /* data buffer */ + int i, j, k = 0; /* iterators */ + int * data = NULL; /* data buffer */ /* Testing Macro */ TESTING("tag application during dataset read"); @@ -2639,86 +3034,110 @@ check_dataset_read_tags(void) /* ===== */ /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Set up creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Enable chunking */ - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; /* Set up a fill value */ - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create Dataset */ - if (( did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* Retrieve tag associated with this dataset */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* fill out data buffer */ - for(i = 0; i < DIMS; i++) - for(j = 0; j < DIMS; j++) + for (i = 0; i < DIMS; i++) + for (j = 0; j < DIMS; j++) data[(DIMS * i) + j] = k++; /* Write to dataset */ - if( (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0 ) TEST_ERROR; + if ((H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0) + TEST_ERROR; /* Close and Reopen the file and dataset */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if (( did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ===================================== */ /* TEST: Read from Dataset in Root Group */ /* ===================================== */ - if( (H5Dread(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0 ) TEST_ERROR; + if ((H5Dread(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify 19 b-tree nodes belonging to dataset */ - for (i=0; i<19; i++) - if ( verify_tag(fid, H5AC_BT_ID, d_tag) < 0 ) TEST_ERROR; + for (i = 0; i < 19; i++) + if (verify_tag(fid, H5AC_BT_ID, d_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -2730,12 +3149,11 @@ check_dataset_read_tags(void) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_dataset_read_tags */ - /*------------------------------------------------------------------------- * Function: check_dataset_size_retrieval * @@ -2753,22 +3171,22 @@ static unsigned check_dataset_size_retrieval(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ - int i,j,k = 0; /* iterators */ - int *data = NULL; /* data buffer */ + int i, j, k = 0; /* iterators */ + int * data = NULL; /* data buffer */ hsize_t dsize = 0; /* Testing Macro */ @@ -2779,86 +3197,110 @@ check_dataset_size_retrieval(void) /* ===== */ /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Set up creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Enable chunking */ - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; /* Set up a fill value */ - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create Dataset */ - if (( did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* Retrieve tag associated with this dataset */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* fill out data buffer */ - for(i = 0; i < DIMS; i++) - for(j = 0; j < DIMS; j++) + for (i = 0; i < DIMS; i++) + for (j = 0; j < DIMS; j++) data[(DIMS * i) + j] = k++; /* Write to dataset */ - if( (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0 ) TEST_ERROR; + if ((H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0) + TEST_ERROR; /* Close and Reopen the file and dataset */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if (( did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ========================================= */ /* Get storage size of dataset in Root Group */ /* ========================================= */ - if ( (dsize = H5Dget_storage_size(did)) == 0 ) TEST_ERROR; + if ((dsize = H5Dget_storage_size(did)) == 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify 19 b-tree nodes belonging to dataset */ - for (i=0; i<19; i++) - if ( verify_tag(fid, H5AC_BT_ID, d_tag) < 0 ) TEST_ERROR; + for (i = 0; i < 19; i++) + if (verify_tag(fid, H5AC_BT_ID, d_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -2870,12 +3312,11 @@ check_dataset_size_retrieval(void) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_dataset_size_retrieval */ - /*------------------------------------------------------------------------- * Function: check_dataset_extend_tags * @@ -2894,23 +3335,23 @@ check_dataset_extend_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ - int i,j,k = 0; /* iterators */ - int *data = NULL; /* data buffer */ - hsize_t newdims[2] = {DIMS*2, DIMS}; /* dimensions */ + int i, j, k = 0; /* iterators */ + int * data = NULL; /* data buffer */ + hsize_t newdims[2] = {DIMS * 2, DIMS}; /* dimensions */ /* Testing Macro */ TESTING("tag application during dataset extend"); @@ -2920,86 +3361,110 @@ check_dataset_extend_tags(void) /* ===== */ /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Set up creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Enable chunking */ - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; /* Set up a fill value */ - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create Dataset */ - if (( did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* Retrieve tag associated with this dataset */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* fill out data buffer */ - for(i = 0; i < DIMS; i++) - for(j = 0; j < DIMS; j++) + for (i = 0; i < DIMS; i++) + for (j = 0; j < DIMS; j++) data[(DIMS * i) + j] = k++; /* Write to dataset */ - if( (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0 ) TEST_ERROR; + if ((H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0) + TEST_ERROR; /* Close and Reopen the file and dataset */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if (( did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((did = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ================== */ /* Set Dataset extent */ /* ================== */ - if ( H5Dset_extent(did, newdims) < 0 ) TEST_ERROR; + if (H5Dset_extent(did, newdims) < 0) + TEST_ERROR; - if ( H5Dclose(did) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, d_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -3011,12 +3476,11 @@ check_dataset_extend_tags(void) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_dataset_extend_tags */ - /*------------------------------------------------------------------------- * Function: check_object_info_tags * @@ -3034,15 +3498,15 @@ static unsigned check_object_info_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t gid = -1; /* Group Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t gid = -1; /* Group Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file output */ + int verbose = FALSE; /* verbose file output */ #endif - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = HADDR_UNDEF; - haddr_t g_tag; - H5O_native_info_t ninfo; /* Native object info struct */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = HADDR_UNDEF; + haddr_t g_tag; + H5O_native_info_t ninfo; /* Native object info struct */ /* Testing Macro */ TESTING("tag application during object info retrieval"); @@ -3052,31 +3516,41 @@ check_object_info_tags(void) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Close Group */ - if (H5Gclose(gid) < 0) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ===================================== */ /* Get information on an object by name */ @@ -3085,39 +3559,51 @@ check_object_info_tags(void) /* Even though we do nothing with this, touching the internal * data structures is needed for the test to pass. */ - if ( H5Oget_native_info_by_name(fid, GROUPNAME, &ninfo, H5O_NATIVE_INFO_ALL, H5P_DEFAULT) < 0 ) TEST_ERROR; + if (H5Oget_native_info_by_name(fid, GROUPNAME, &ninfo, H5O_NATIVE_INFO_ALL, H5P_DEFAULT) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* Verify dataset's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, g_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -3130,7 +3616,6 @@ error: return 1; } /* check_object_info_tags */ - /*------------------------------------------------------------------------- * Function: check_object_copy_tags * @@ -3148,12 +3633,12 @@ static unsigned check_object_copy_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t gid = -1; /* Group Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t gid = -1; /* Group Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file output */ + int verbose = FALSE; /* verbose file output */ #endif - hid_t fapl = -1; /* File access prop list */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = HADDR_UNDEF; haddr_t g_tag; haddr_t copy_tag; @@ -3166,79 +3651,107 @@ check_object_copy_tags(void) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Close Group */ - if (H5Gclose(gid) < 0) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* =========== */ /* Copy Group */ /* =========== */ - if ( H5Ocopy(fid, GROUPNAME, fid, GROUPNAMECOPY, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; + if (H5Ocopy(fid, GROUPNAME, fid, GROUPNAMECOPY, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR; /* Get tag for copied group */ - if ( (gid = H5Gopen2(fid, GROUPNAMECOPY, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( get_object_header_tag(gid, ©_tag) < 0 ) TEST_ERROR; - if (H5Gclose(gid) < 0) TEST_ERROR; + if ((gid = H5Gopen2(fid, GROUPNAMECOPY, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (get_object_header_tag(gid, ©_tag) < 0) + TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* Verify group's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, g_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, g_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, g_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, g_tag) < 0) + TEST_ERROR; /* Verify copied group's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, copy_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, copy_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, copy_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, copy_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, copy_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, copy_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -3251,7 +3764,6 @@ error: return 1; } /* check_object_copy_tags */ - /*------------------------------------------------------------------------- * Function: check_link_removal_tags * @@ -3269,24 +3781,24 @@ static unsigned check_link_removal_tags(hid_t fcpl, int type) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ - hid_t gid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ + hid_t gid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - haddr_t g_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + haddr_t g_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ - int i,j,k = 0; /* iterators */ - int *data = NULL; /* data buffer */ + int i, j, k = 0; /* iterators */ + int * data = NULL; /* data buffer */ /* Testing Macro */ TESTING("tag application during link removal"); @@ -3296,105 +3808,134 @@ check_link_removal_tags(hid_t fcpl, int type) /* ===== */ /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Close Group */ - if (H5Gclose(gid) < 0) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; /* Set up creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Enable chunking */ - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; /* Set up a fill value */ - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create Dataset */ - if (( did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* Retrieve tag associated with this dataset */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* fill out data buffer */ - for(i = 0; i < DIMS; i++) - for(j = 0; j < DIMS; j++) + for (i = 0; i < DIMS; i++) + for (j = 0; j < DIMS; j++) data[(DIMS * i) + j] = k++; /* Write to dataset */ - if( (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0 ) TEST_ERROR; + if ((H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0) + TEST_ERROR; /* Close Dataset */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; /* Close and Reopen the file and dataset */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ================================ */ /* Remove link to group and dataset */ /* ================================ */ - if ( (H5Ldelete(fid, GROUPNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((H5Ldelete(fid, GROUPNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - if ( (H5Ldelete(fid, DATASETNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((H5Ldelete(fid, DATASETNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; - if ( type == TEST_SHMESG ) { + if (type == TEST_SHMESG) { /* verify shared header message master table */ - if ( verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_SOHM_TABLE_ID, H5AC__SOHM_TAG) < 0) + TEST_ERROR; } /* end if */ /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -3406,12 +3947,11 @@ check_link_removal_tags(hid_t fcpl, int type) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_link_removal_tags */ - /*------------------------------------------------------------------------- * Function: check_link_getname_tags * @@ -3429,25 +3969,25 @@ static unsigned check_link_getname_tags(void) { /* Variable Declarations */ - char name[500]; - hid_t fid = -1; /* File Identifier */ - hid_t did = -1; /* Dataset Identifier */ - hid_t sid = -1; /* Dataspace Identifier */ - hid_t gid = -1; /* Dataspace Identifier */ + char name[500]; + hid_t fid = -1; /* File Identifier */ + hid_t did = -1; /* Dataset Identifier */ + hid_t sid = -1; /* Dataspace Identifier */ + hid_t gid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t dcpl = -1; /* dataset creation pl */ - hsize_t cdims[2] = {1,1}; /* chunk dimensions */ - int fillval = 0; - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t d_tag = 0; - haddr_t g_tag = 0; - hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ + hid_t dcpl = -1; /* dataset creation pl */ + hsize_t cdims[2] = {1, 1}; /* chunk dimensions */ + int fillval = 0; + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t d_tag = 0; + haddr_t g_tag = 0; + hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dimensions */ - int i,j,k = 0; /* iterators */ - int *data = NULL; /* data buffer */ + int i, j, k = 0; /* iterators */ + int * data = NULL; /* data buffer */ /* Testing Macro */ TESTING("tag application during link name retrieval"); @@ -3457,64 +3997,83 @@ check_link_getname_tags(void) /* ===== */ /* Allocate array */ - if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + if ((NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int))))) + TEST_ERROR; /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create group */ - if ( (gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Retrieve group tag */ - if ( get_object_header_tag(gid, &g_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(gid, &g_tag) < 0) + TEST_ERROR; /* Close Group */ - if (H5Gclose(gid) < 0) TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; /* Set up creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); /* Enable chunking */ - if ( H5Pset_chunk(dcpl, RANK, cdims) < 0 ) TEST_ERROR; + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) + TEST_ERROR; /* Set up a fill value */ - if ( H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0 ) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; /* Set up dataset dataspace */ - if ( (sid = H5Screate_simple(2, dims1, maxdims)) < 0 ) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims1, maxdims)) < 0) + TEST_ERROR; /* Create Dataset */ - if (( did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( H5Pclose(dcpl) < 0 ) TEST_ERROR; + if ((did = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* Retrieve tag associated with this dataset */ - if ( get_object_header_tag(did, &d_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(did, &d_tag) < 0) + TEST_ERROR; /* fill out data buffer */ - for(i = 0; i < DIMS; i++) - for(j = 0; j < DIMS; j++) + for (i = 0; i < DIMS; i++) + for (j = 0; j < DIMS; j++) data[(DIMS * i) + j] = k++; /* Write to dataset */ - if( (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0 ) TEST_ERROR; + if ((H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data)) < 0) + TEST_ERROR; /* Close Dataset */ - if ( H5Dclose(did) < 0 ) TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; /* Close and Reopen the file and dataset */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* =========================== */ /* Get name by index location. */ @@ -3528,26 +4087,34 @@ check_link_getname_tags(void) #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group's tagged metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_SNODE_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -3559,12 +4126,11 @@ check_link_getname_tags(void) return 0; error: - if(data) + if (data) HDfree(data); return 1; } /* check_link_getname_tags */ - /*------------------------------------------------------------------------- * Function: check_external_link_creation_tags * @@ -3582,13 +4148,13 @@ static unsigned check_external_link_creation_tags(void) { /* Variable Declarations */ - hid_t fid = -1; /* File Identifier */ - hid_t fid2 = -1; /* File Identifier */ - hid_t gid = -1; /* Dataspace Identifier */ + hid_t fid = -1; /* File Identifier */ + hid_t fid2 = -1; /* File Identifier */ + hid_t gid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - hid_t fapl = -1; /* File access prop list */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; /* Testing Macro */ @@ -3599,65 +4165,85 @@ check_external_link_creation_tags(void) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* Create a second file */ - if ( (fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* Create group in second file */ - if ( (gid = H5Gcreate2(fid2, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid2, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Close out second file */ - if ( (H5Gclose(gid)) < 0 ) TEST_ERROR; - if ( (H5Fclose(fid2)) < 0 ) TEST_ERROR; + if ((H5Gclose(gid)) < 0) + TEST_ERROR; + if ((H5Fclose(fid2)) < 0) + TEST_ERROR; /* ==================== */ /* Create External Link */ /* ==================== */ - if (H5Lcreate_external(FILENAME2, GROUPNAMEPATH, fid, LINKNAME, H5P_DEFAULT, H5P_DEFAULT) < 0 ) TEST_ERROR; + if (H5Lcreate_external(FILENAME2, GROUPNAMEPATH, fid, LINKNAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* Verify root group metadata */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_BT_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_LHEAP_PRFX_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_BT_ID, root_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -3670,7 +4256,6 @@ error: return 1; } /* check_external_link_creation_tags */ - /*------------------------------------------------------------------------- * Function: check_external_link_open_tags * @@ -3688,18 +4273,18 @@ static unsigned check_external_link_open_tags(void) { /* Variable Declarations */ - haddr_t link_tag = 0; /* link tag */ - hid_t fid = -1; /* File Identifier */ - hid_t fid2 = -1; /* File Identifier */ - hid_t gid = -1; /* Dataspace Identifier */ - hid_t xid = -1; /* Dataspace Identifier */ + haddr_t link_tag = 0; /* link tag */ + hid_t fid = -1; /* File Identifier */ + hid_t fid2 = -1; /* File Identifier */ + hid_t gid = -1; /* Dataspace Identifier */ + hid_t xid = -1; /* Dataspace Identifier */ #ifndef NDEBUG - int verbose = FALSE; /* verbose file outout */ + int verbose = FALSE; /* verbose file outout */ #endif - H5O_native_info_t ninfo; /* Native object info struct */ - hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag = 0; - haddr_t root2_tag = 0; + H5O_native_info_t ninfo; /* Native object info struct */ + hid_t fapl = -1; /* File access prop list */ + haddr_t root_tag = 0; + haddr_t root2_tag = 0; /* Testing Macro */ TESTING("tag application during external link open"); @@ -3709,93 +4294,128 @@ check_external_link_open_tags(void) /* ===== */ /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid, &root_tag) < 0) + TEST_ERROR; /* Create a second file */ - if ( (fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* determine tag value of root group's object header */ - if ( get_object_header_tag(fid2, &root2_tag) < 0 ) TEST_ERROR; + if (get_object_header_tag(fid2, &root2_tag) < 0) + TEST_ERROR; /* Create group in second file */ - if ( (gid = H5Gcreate2(fid2, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ((gid = H5Gcreate2(fid2, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Close out second file */ - if ( (H5Gclose(gid)) < 0 ) TEST_ERROR; - if ( (H5Fclose(fid2)) < 0 ) TEST_ERROR; + if ((H5Gclose(gid)) < 0) + TEST_ERROR; + if ((H5Fclose(fid2)) < 0) + TEST_ERROR; /* Create external link to second file */ - if ( H5Lcreate_external(FILENAME2, GROUPNAMEPATH, fid, LINKNAME, H5P_DEFAULT, H5P_DEFAULT) < 0 ) TEST_ERROR; + if (H5Lcreate_external(FILENAME2, GROUPNAMEPATH, fid, LINKNAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR; /* Close and Reopen the file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl)) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ - if ( evict_entries(fid) < 0 ) TEST_ERROR; + if (evict_entries(fid) < 0) + TEST_ERROR; /* ================== */ /* Open External Link */ /* ================== */ - if ( (xid = H5Gopen2(fid, LINKNAME, H5P_DEFAULT)) < 0 ) TEST_ERROR; - if ( (fid2 = H5Iget_file_id(xid)) < 0) TEST_ERROR; - if ( get_object_header_tag(xid, &link_tag) < 0 ) TEST_ERROR; + if ((xid = H5Gopen2(fid, LINKNAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((fid2 = H5Iget_file_id(xid)) < 0) + TEST_ERROR; + if (get_object_header_tag(xid, &link_tag) < 0) + TEST_ERROR; /* Even though we do nothing with this, touching the internal * data structures is needed for the test to pass. */ - if ( H5Oget_native_info(xid, &ninfo, H5O_NATIVE_INFO_ALL) < 0 ) TEST_ERROR; + if (H5Oget_native_info(xid, &ninfo, H5O_NATIVE_INFO_ALL) < 0) + TEST_ERROR; - /* =================================== */ - /* Verification of Metadata Tag Values */ - /* =================================== */ + /* =================================== */ + /* Verification of Metadata Tag Values */ + /* =================================== */ #ifndef NDEBUG /* if verbose, print cache index to screen for visual verification */ - if ( verbose ) dump_cache(fid); + if (verbose) + dump_cache(fid); #endif /* NDEBUG */ /* end debugging functions */ /* verify tag value of first file's root group */ - if ( verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid, H5AC_OHDR_CHK_ID, root_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_ID, root_tag) < 0) + TEST_ERROR; + if (verify_tag(fid, H5AC_OHDR_CHK_ID, root_tag) < 0) + TEST_ERROR; /* verify there is a superblock entry with superblock tag. */ - if ( verify_tag(fid2, H5AC_SUPERBLOCK_ID, H5AC__SUPERBLOCK_TAG) < 0 ) TEST_ERROR; + if (verify_tag(fid2, H5AC_SUPERBLOCK_ID, H5AC__SUPERBLOCK_TAG) < 0) + TEST_ERROR; /* verify tag value of linked file's root group */ - if ( verify_tag(fid2, H5AC_OHDR_ID, root2_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid2, H5AC_LHEAP_PRFX_ID, root2_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid2, H5AC_BT_ID, root2_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid2, H5AC_SNODE_ID, root2_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid2, H5AC_OHDR_ID, root2_tag) < 0) + TEST_ERROR; + if (verify_tag(fid2, H5AC_LHEAP_PRFX_ID, root2_tag) < 0) + TEST_ERROR; + if (verify_tag(fid2, H5AC_BT_ID, root2_tag) < 0) + TEST_ERROR; + if (verify_tag(fid2, H5AC_SNODE_ID, root2_tag) < 0) + TEST_ERROR; /* verify tag value of linked group's object header */ - if ( verify_tag(fid2, H5AC_OHDR_ID, link_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid2, H5AC_LHEAP_PRFX_ID, link_tag) < 0 ) TEST_ERROR; - if ( verify_tag(fid2, H5AC_BT_ID, link_tag) < 0 ) TEST_ERROR; + if (verify_tag(fid2, H5AC_OHDR_ID, link_tag) < 0) + TEST_ERROR; + if (verify_tag(fid2, H5AC_LHEAP_PRFX_ID, link_tag) < 0) + TEST_ERROR; + if (verify_tag(fid2, H5AC_BT_ID, link_tag) < 0) + TEST_ERROR; /* verify no other entries present */ - if ( verify_no_unknown_tags(fid) < 0 ) TEST_ERROR; - if ( verify_no_unknown_tags(fid2) < 0 ) TEST_ERROR; + if (verify_no_unknown_tags(fid) < 0) + TEST_ERROR; + if (verify_no_unknown_tags(fid2) < 0) + TEST_ERROR; /* Reset the changes we've made to the cache's data structures */ - if(reset_all_entries_investigated(fid) < 0) TEST_ERROR; - if(reset_all_entries_investigated(fid2) < 0) TEST_ERROR; + if (reset_all_entries_investigated(fid) < 0) + TEST_ERROR; + if (reset_all_entries_investigated(fid2) < 0) + TEST_ERROR; /* =========================== */ /* Close open objects and file */ /* =========================== */ - if ( H5Gclose(xid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( H5Fclose(fid2) < 0 ) TEST_ERROR; + if (H5Gclose(xid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + if (H5Fclose(fid2) < 0) + TEST_ERROR; /* ========================================== */ /* Finished Test. Print status and return. */ @@ -3808,7 +4428,6 @@ error: return 1; } /* check_external_link_open_tags */ - /*------------------------------------------------------------------------- * Function: check_invalid_tag_application * @@ -3828,65 +4447,77 @@ check_invalid_tag_application(void) { #if H5C_DO_TAGGING_SANITY_CHECKS /* Variables */ - H5F_t * f = NULL; - hid_t fid = -1; + H5F_t * f = NULL; + hid_t fid = -1; haddr_t addr; - H5HL_t * lheap = NULL; - hid_t fapl = -1; /* File access prop list */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ -#endif /* H5C_DO_TAGGING_SANITY_CHECKS */ + H5HL_t *lheap = NULL; + hid_t fapl = -1; /* File access prop list */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ +#endif /* H5C_DO_TAGGING_SANITY_CHECKS */ /* Testing Macro */ TESTING("failure on invalid tag application"); #if H5C_DO_TAGGING_SANITY_CHECKS /* Create Fapl */ - if ( (fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0 ) TEST_ERROR; + if ((fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR; /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; - if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; /* Push API context */ - if(H5CX_push() < 0) TEST_ERROR + if (H5CX_push() < 0) + TEST_ERROR api_ctx_pushed = TRUE; /* Get internal file pointer*/ - if ( NULL == (f = (H5F_t *)H5VL_object(fid)) ) TEST_ERROR; + if (NULL == (f = (H5F_t *)H5VL_object(fid))) + TEST_ERROR; /* Call H5HL_create, an internal function that calls H5AC_insert_entry without setting up a tag */ /* Ensure this returns FAILURE, as a tag has not been set up. */ - if ( H5HL_create(f, (size_t)1024, &addr) >= 0) TEST_ERROR; + if (H5HL_create(f, (size_t)1024, &addr) >= 0) + TEST_ERROR; /* Now set up a tag in the API context */ H5AC_tag((haddr_t)25, NULL); /* Verify the same call to H5HL_create now works as intended, with a tag set up. */ - if ( H5HL_create(f, (size_t)1024, &addr) < 0) TEST_ERROR; + if (H5HL_create(f, (size_t)1024, &addr) < 0) + TEST_ERROR; /* Reset API context to use invalid tag. */ H5AC_tag(H5AC__INVALID_TAG, NULL); /* Call H5HL_protect to protect the local heap created above. */ /* This should fail as no tag is set up during the protect call */ - if (( lheap = H5HL_protect(f, addr, H5AC__NO_FLAGS_SET)) != NULL ) TEST_ERROR; + if ((lheap = H5HL_protect(f, addr, H5AC__NO_FLAGS_SET)) != NULL) + TEST_ERROR; /* Again, set up a valid tag in the API context */ H5AC_tag((haddr_t)25, NULL); /* Call H5HL_protect again to protect the local heap. This should succeed. */ - if (( lheap = H5HL_protect(f, addr, H5AC__NO_FLAGS_SET)) == NULL ) TEST_ERROR; + if ((lheap = H5HL_protect(f, addr, H5AC__NO_FLAGS_SET)) == NULL) + TEST_ERROR; /* Now unprotect the heap, as we're done with the test. */ - if ( H5HL_unprotect(lheap) < 0 ) TEST_ERROR; + if (H5HL_unprotect(lheap) < 0) + TEST_ERROR; /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) TEST_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + TEST_ERROR api_ctx_pushed = FALSE; /* Close open objects and file */ - if ( H5Fclose(fid) < 0 ) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* Finished Test. Print status and return. */ PASSED(); @@ -3899,13 +4530,13 @@ check_invalid_tag_application(void) #if H5C_DO_TAGGING_SANITY_CHECKS error: - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); #endif /* H5C_DO_TAGGING_SANITY_CHECKS */ return 1; } /* check_invalid_tag_application */ - /*------------------------------------------------------------------------- * Function: main * @@ -3922,11 +4553,11 @@ int main(void) { /* Variable Declarations */ - hid_t fcpl_default = -1; /* file creation prop list */ - hid_t fcpl_shmesg_all = -1; /* file creation prop list */ - hid_t fcpl = -1; /* file creation prop list */ - unsigned nerrs = 0; /* Error Encountered */ - int test_type = 0; /* test type iterator */ + hid_t fcpl_default = -1; /* file creation prop list */ + hid_t fcpl_shmesg_all = -1; /* file creation prop list */ + hid_t fcpl = -1; /* file creation prop list */ + unsigned nerrs = 0; /* Error Encountered */ + int test_type = 0; /* test type iterator */ /* Open the HDF5 Library */ H5open(); @@ -3948,54 +4579,83 @@ main(void) /* Run Tests */ /* ========= */ - for (test_type=0; test_type NUM_CHUNKS_WRITTEN. should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dget_chunk_info(dset, dspace, chk_index, out_offset, &read_flt_msk, &addr, &size); - } H5E_END_TRY; - if(ret != FAIL) + } + H5E_END_TRY; + if (ret != FAIL) FAIL_PUTS_ERROR(" Attempted to get info of a chunk using an out-of-range index."); /* Attempt to get info of empty chunks, verify the returned address and size */ offset[0] = 0; offset[1] = 0; - if(verify_empty_chunk_info(dset, offset) == FAIL) + if (verify_empty_chunk_info(dset, offset) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on empty chunk failed\n"); offset[0] = 3 * CHUNK_NX; offset[1] = 3 * CHUNK_NY; - if(verify_empty_chunk_info(dset, offset) == FAIL) + if (verify_empty_chunk_info(dset, offset) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on empty chunk failed\n"); /* Read and verify values of selected chunks */ - if(verify_selected_chunks(dset, H5P_DEFAULT, start, end) < 0) + if (verify_selected_chunks(dset, H5P_DEFAULT, start, end) < 0) - /* Release resourse */ - if(H5Dclose(dset) < 0) TEST_ERROR - if(H5Sclose(dspace) < 0) TEST_ERROR - if(H5Fclose(chunkfile) < 0) TEST_ERROR + /* Release resourse */ + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Sclose(dspace) < 0) + TEST_ERROR + if (H5Fclose(chunkfile) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(dspace); H5Pclose(cparms); H5Fclose(chunkfile); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; @@ -1138,118 +1205,129 @@ error: static herr_t test_chunk_info_extensible_array(const char *filename, hid_t fapl) { - hid_t chunkfile = H5I_INVALID_HID; /* File ID */ - hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ - hid_t dset = H5I_INVALID_HID; /* Dataset ID */ - hid_t cparms = H5I_INVALID_HID; /* Creation plist */ - hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ - hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, NY}; /* One unlimited dimension */ - unsigned flt_msk = 0; /* Filter mask */ - unsigned read_flt_msk = 0; /* Filter mask after direct read */ - hsize_t offset[2]; /* Offset coordinates of a chunk */ - hsize_t start[2] = {START_CHK_X, START_CHK_Y}; /* Start position */ - hsize_t end[2] = {END_CHK_X, END_CHK_Y}; /* End position */ - hsize_t out_offset[2] = {0, 0}; /* Buffer to get offset coordinates */ - hsize_t size = 0; /* Size of an allocated/written chunk */ - hsize_t nchunks = 0; /* Number of chunks */ - haddr_t addr = 0; /* Address of an allocated/written chunk */ - hsize_t chk_index = 0; /* Index of a chunk */ - hsize_t ii, jj; /* Array indices */ - herr_t ret; /* Temporary returned value for verifying failure */ + hid_t chunkfile = H5I_INVALID_HID; /* File ID */ + hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t cparms = H5I_INVALID_HID; /* Creation plist */ + hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ + hsize_t maxdims[2] = {H5S_UNLIMITED, NY}; /* One unlimited dimension */ + unsigned flt_msk = 0; /* Filter mask */ + unsigned read_flt_msk = 0; /* Filter mask after direct read */ + hsize_t offset[2]; /* Offset coordinates of a chunk */ + hsize_t start[2] = {START_CHK_X, START_CHK_Y}; /* Start position */ + hsize_t end[2] = {END_CHK_X, END_CHK_Y}; /* End position */ + hsize_t out_offset[2] = {0, 0}; /* Buffer to get offset coordinates */ + hsize_t size = 0; /* Size of an allocated/written chunk */ + hsize_t nchunks = 0; /* Number of chunks */ + haddr_t addr = 0; /* Address of an allocated/written chunk */ + hsize_t chk_index = 0; /* Index of a chunk */ + hsize_t ii, jj; /* Array indices */ + herr_t ret; /* Temporary returned value for verifying failure */ TESTING(" Extensible Array index"); /* Open the file for reading/writing */ - if((chunkfile = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((chunkfile = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create dataspace */ - if((dspace = H5Screate_simple(RANK, dims, maxdims)) < 0) + if ((dspace = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR /* Enable chunking */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(cparms, RANK, chunk_dims) < 0) + if (H5Pset_chunk(cparms, RANK, chunk_dims) < 0) TEST_ERROR /* Create a new dataset using cparms creation properties */ - dset = H5Dcreate2(chunkfile, EXT_ARR_INDEX_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, H5P_DEFAULT); - if(dset < 0) TEST_ERROR + dset = H5Dcreate2(chunkfile, EXT_ARR_INDEX_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, + H5P_DEFAULT); + if (dset < 0) + TEST_ERROR /* Close the dataset */ - if(H5Dclose(dset) < 0) TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR /* Open the dataset again to test getting chunk info */ - if((dset = H5Dopen2(chunkfile, EXT_ARR_INDEX_DSET_NAME, H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(chunkfile, EXT_ARR_INDEX_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR /* Verify chunk indexing scheme and number of chunks */ - if(verify_idx_nchunks(dset, dspace, H5D_CHUNK_IDX_EARRAY, NO_CHUNK_WRITTEN) == FAIL) + if (verify_idx_nchunks(dset, dspace, H5D_CHUNK_IDX_EARRAY, NO_CHUNK_WRITTEN) == FAIL) FAIL_PUTS_ERROR("Verification and write failed\n"); /* Write NUM_CHUNKS_WRITTEN chunks at the following logical coords: (0,2) (0,3) (1,2) (1,3) */ - if(write_selected_chunks(dset, H5P_DEFAULT, start, end, flt_msk) == FAIL) + if (write_selected_chunks(dset, H5P_DEFAULT, start, end, flt_msk) == FAIL) FAIL_PUTS_ERROR("Writing to selected chunks failed\n"); /* Get and verify the number of chunks written */ - if(H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR + if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) + TEST_ERROR VERIFY(nchunks, NUM_CHUNKS_WRITTEN, "H5Dget_num_chunks, number of chunks"); /* Get and verify info of each written chunk */ chk_index = 0; - for(ii = START_CHK_X; ii < END_CHK_X; ii++) - for(jj = START_CHK_Y; jj < END_CHK_Y; jj++, chk_index++) { + for (ii = START_CHK_X; ii < END_CHK_X; ii++) + for (jj = START_CHK_Y; jj < END_CHK_Y; jj++, chk_index++) { offset[0] = ii * CHUNK_NX; offset[1] = jj * CHUNK_NY; - if(verify_get_chunk_info(dset, dspace, chk_index, CHK_SIZE, offset, flt_msk) == FAIL) + if (verify_get_chunk_info(dset, dspace, chk_index, CHK_SIZE, offset, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info failed\n"); - if(verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) + if (verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord failed\n"); } /* Attempt to get info using an out-of-range index, should fail */ chk_index = OUTOFRANGE_CHK_INDEX; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dget_chunk_info(dset, dspace, chk_index, out_offset, &read_flt_msk, &addr, &size); - } H5E_END_TRY; - if(ret != FAIL) + } + H5E_END_TRY; + if (ret != FAIL) FAIL_PUTS_ERROR(" Attempted to get info of a chunk using an out-of-range index."); /* Attempt to get info of empty chunks, verify the returned address and size */ offset[0] = 0; offset[1] = 0; - if(verify_empty_chunk_info(dset, offset) == FAIL) + if (verify_empty_chunk_info(dset, offset) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on empty chunk failed\n"); offset[0] = 3 * CHUNK_NX; offset[1] = 3 * CHUNK_NY; - if(verify_empty_chunk_info(dset, offset) == FAIL) + if (verify_empty_chunk_info(dset, offset) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on empty chunk failed\n"); /* Read and verify values of selected chunks */ - if(verify_selected_chunks(dset, H5P_DEFAULT, start, end) < 0) + if (verify_selected_chunks(dset, H5P_DEFAULT, start, end) < 0) - /* Release resourse */ - if(H5Dclose(dset) < 0) TEST_ERROR - if(H5Sclose(dspace) < 0) TEST_ERROR - if(H5Fclose(chunkfile) < 0) TEST_ERROR + /* Release resourse */ + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Sclose(dspace) < 0) + TEST_ERROR + if (H5Fclose(chunkfile) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(dspace); H5Pclose(cparms); H5Fclose(chunkfile); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; @@ -1275,118 +1353,129 @@ error: static herr_t test_chunk_info_version2_btrees(const char *filename, hid_t fapl) { - hid_t chunkfile = H5I_INVALID_HID; /* File ID */ - hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ - hid_t dset = H5I_INVALID_HID; /* Dataset ID */ - hid_t cparms = H5I_INVALID_HID; /* Creation plist */ - hsize_t dims[2] = {NX, NY};/* Dataset dimensions */ - hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Two unlimited dims */ - unsigned flt_msk = 0; /* Filter mask */ - unsigned read_flt_msk = 0; /* Filter mask after direct read */ - hsize_t offset[2]; /* Offset coordinates of a chunk */ - hsize_t start[2] = {START_CHK_X, START_CHK_Y}; /* Start position */ - hsize_t end[2] = {END_CHK_X, END_CHK_Y}; /* End position */ - hsize_t out_offset[2] = {0, 0}; /* Buffer to get offset coordinates */ - hsize_t size = 0; /* Size of an allocated/written chunk */ - hsize_t nchunks = 0; /* Number of chunks */ - haddr_t addr = 0; /* Address of an allocated/written chunk */ - hsize_t chk_index = 0; /* Index of a chunk */ - hsize_t ii, jj; /* Array indices */ + hid_t chunkfile = H5I_INVALID_HID; /* File ID */ + hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t cparms = H5I_INVALID_HID; /* Creation plist */ + hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Two unlimited dims */ + unsigned flt_msk = 0; /* Filter mask */ + unsigned read_flt_msk = 0; /* Filter mask after direct read */ + hsize_t offset[2]; /* Offset coordinates of a chunk */ + hsize_t start[2] = {START_CHK_X, START_CHK_Y}; /* Start position */ + hsize_t end[2] = {END_CHK_X, END_CHK_Y}; /* End position */ + hsize_t out_offset[2] = {0, 0}; /* Buffer to get offset coordinates */ + hsize_t size = 0; /* Size of an allocated/written chunk */ + hsize_t nchunks = 0; /* Number of chunks */ + haddr_t addr = 0; /* Address of an allocated/written chunk */ + hsize_t chk_index = 0; /* Index of a chunk */ + hsize_t ii, jj; /* Array indices */ herr_t ret; /* Temporary returned value for verifying failure */ TESTING(" Version 2 B-trees index"); /* Open the file for reading/writing */ - if((chunkfile = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((chunkfile = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create dataspace */ - if((dspace = H5Screate_simple(RANK, dims, maxdims)) < 0) + if ((dspace = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR /* Enable chunking */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(cparms, RANK, chunk_dims) < 0) + if (H5Pset_chunk(cparms, RANK, chunk_dims) < 0) TEST_ERROR /* Create a new dataset using cparms creation properties */ - dset = H5Dcreate2(chunkfile, V2_BTREE_INDEX_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, H5P_DEFAULT); - if(dset < 0) TEST_ERROR + dset = H5Dcreate2(chunkfile, V2_BTREE_INDEX_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, + H5P_DEFAULT); + if (dset < 0) + TEST_ERROR /* Close the dataset */ - if(H5Dclose(dset) < 0) TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR /* Open the dataset again to test getting chunk info */ - if((dset = H5Dopen2(chunkfile, V2_BTREE_INDEX_DSET_NAME, H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(chunkfile, V2_BTREE_INDEX_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR /* Verify chunk indexing scheme and number of chunks */ - if(verify_idx_nchunks(dset, dspace, H5D_CHUNK_IDX_BT2, NO_CHUNK_WRITTEN) == FAIL) + if (verify_idx_nchunks(dset, dspace, H5D_CHUNK_IDX_BT2, NO_CHUNK_WRITTEN) == FAIL) FAIL_PUTS_ERROR("Verification and write failed\n"); /* Write NUM_CHUNKS_WRITTEN chunks at the following logical coords: (0,2) (0,3) (1,2) (1,3) */ - if(write_selected_chunks(dset, H5P_DEFAULT, start, end, flt_msk) == FAIL) + if (write_selected_chunks(dset, H5P_DEFAULT, start, end, flt_msk) == FAIL) FAIL_PUTS_ERROR("Writing to selected chunks failed\n"); /* Get and verify the number of chunks written */ - if(H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR + if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) + TEST_ERROR VERIFY(nchunks, NUM_CHUNKS_WRITTEN, "H5Dget_num_chunks, number of chunks"); /* Go through all written chunks, get their info and verify the values */ chk_index = 0; - for(ii = START_CHK_X; ii < END_CHK_X; ii++) - for(jj = START_CHK_Y; jj < END_CHK_Y; jj++, chk_index++) { + for (ii = START_CHK_X; ii < END_CHK_X; ii++) + for (jj = START_CHK_Y; jj < END_CHK_Y; jj++, chk_index++) { offset[0] = ii * CHUNK_NX; offset[1] = jj * CHUNK_NY; - if(verify_get_chunk_info(dset, dspace, chk_index, CHK_SIZE, offset, flt_msk) == FAIL) + if (verify_get_chunk_info(dset, dspace, chk_index, CHK_SIZE, offset, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info failed\n"); - if(verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) + if (verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord failed\n"); } /* Attempt to provide out-of-range offsets, should fail */ chk_index = OUTOFRANGE_CHK_INDEX; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dget_chunk_info(dset, dspace, chk_index, out_offset, &read_flt_msk, &addr, &size); - } H5E_END_TRY; - if(ret != FAIL) + } + H5E_END_TRY; + if (ret != FAIL) FAIL_PUTS_ERROR(" Attempted to get info of a chunk using an out-of-range index."); /* Attempt to get info of empty chunks, verify the returned address and size */ offset[0] = 0; offset[1] = 0; - if(verify_empty_chunk_info(dset, offset) == FAIL) + if (verify_empty_chunk_info(dset, offset) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on empty chunk failed\n"); offset[0] = 3 * CHUNK_NX; offset[1] = 3 * CHUNK_NY; - if(verify_empty_chunk_info(dset, offset) == FAIL) + if (verify_empty_chunk_info(dset, offset) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on empty chunk failed\n"); /* Read and verify values of selected chunks */ - if(verify_selected_chunks(dset, H5P_DEFAULT, start, end) < 0) + if (verify_selected_chunks(dset, H5P_DEFAULT, start, end) < 0) - /* Release resourse */ - if(H5Dclose(dset) < 0) TEST_ERROR - if(H5Sclose(dspace) < 0) TEST_ERROR - if(H5Fclose(chunkfile) < 0) TEST_ERROR + /* Release resourse */ + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Sclose(dspace) < 0) + TEST_ERROR + if (H5Fclose(chunkfile) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(dspace); H5Pclose(cparms); H5Fclose(chunkfile); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; @@ -1412,24 +1501,24 @@ error: static herr_t test_basic_query(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; /* File name */ - hid_t basicfile = H5I_INVALID_HID; /* File ID */ - hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ - hid_t dset = H5I_INVALID_HID; /* Dataset ID */ - hid_t cparms = H5I_INVALID_HID; /* Creation plist */ - hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ - hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ - int direct_buf[CHUNK_NX][CHUNK_NY];/* Data in chunks */ - unsigned flt_msk = 0; /* Filter mask */ - unsigned read_flt_msk = 0; /* Filter mask after direct read */ - hsize_t offset[2]; /* Offset coordinates of a chunk */ - hsize_t out_offset[2] = {0, 0}; /* Buffer to get offset coordinates */ - hsize_t size = 0; /* Size of an allocated/written chunk */ - hsize_t nchunks = 0; /* Number of chunks */ - haddr_t addr = 0; /* Address of an allocated/written chunk */ - hsize_t chk_index = 0; /* Index of a chunk */ - hsize_t ii, jj; /* Array indices */ - herr_t ret; /* Temporary returned value for verifying failure */ + char filename[FILENAME_BUF_SIZE]; /* File name */ + hid_t basicfile = H5I_INVALID_HID; /* File ID */ + hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t cparms = H5I_INVALID_HID; /* Creation plist */ + hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ + int direct_buf[CHUNK_NX][CHUNK_NY]; /* Data in chunks */ + unsigned flt_msk = 0; /* Filter mask */ + unsigned read_flt_msk = 0; /* Filter mask after direct read */ + hsize_t offset[2]; /* Offset coordinates of a chunk */ + hsize_t out_offset[2] = {0, 0}; /* Buffer to get offset coordinates */ + hsize_t size = 0; /* Size of an allocated/written chunk */ + hsize_t nchunks = 0; /* Number of chunks */ + haddr_t addr = 0; /* Address of an allocated/written chunk */ + hsize_t chk_index = 0; /* Index of a chunk */ + hsize_t ii, jj; /* Array indices */ + herr_t ret; /* Temporary returned value for verifying failure */ TESTING("basic operations"); @@ -1437,104 +1526,115 @@ test_basic_query(hid_t fapl) h5_fixname(BASIC_FILE, fapl, filename, sizeof filename); /* Create a new file. */ - if((basicfile = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((basicfile = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create dataspace */ - if((dspace = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((dspace = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR /* Enable chunking */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(cparms, RANK, chunk_dims) < 0) + if (H5Pset_chunk(cparms, RANK, chunk_dims) < 0) TEST_ERROR /* Create a new dataset using cparms creation properties */ - dset = H5Dcreate2(basicfile, SIMPLE_CHUNKED_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, H5P_DEFAULT); - if(dset < 0) TEST_ERROR + dset = H5Dcreate2(basicfile, SIMPLE_CHUNKED_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, + H5P_DEFAULT); + if (dset < 0) + TEST_ERROR /* Get the number of chunks and verify that no chunk has been written */ - if(H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR + if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) + TEST_ERROR VERIFY(nchunks, NO_CHUNK_WRITTEN, "H5Dget_num_chunks, number of chunks"); /* Initialize the array of chunk data for the single chunk */ - for(ii = 0; ii < CHUNK_NX; ii++) - for(jj = 0; jj < CHUNK_NY; jj++) - direct_buf[ii][jj] = (int)(ii*jj); + for (ii = 0; ii < CHUNK_NX; ii++) + for (jj = 0; jj < CHUNK_NY; jj++) + direct_buf[ii][jj] = (int)(ii * jj); /* Write the chunk of data */ offset[0] = CHUNK_NX; offset[1] = CHUNK_NY; - if(H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, CHK_SIZE, direct_buf) < 0) + if (H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, CHK_SIZE, direct_buf) < 0) TEST_ERROR; /* Get and verify that one chunk had been written */ - if(H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR + if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) + TEST_ERROR VERIFY(nchunks, ONE_CHUNK_WRITTEN, "H5Dget_num_chunks, number of chunks"); /* Get and verify info of the first and only chunk */ - if(verify_get_chunk_info(dset, H5S_ALL, 0, CHK_SIZE, offset, flt_msk) == FAIL) + if (verify_get_chunk_info(dset, H5S_ALL, 0, CHK_SIZE, offset, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification H5Dget_chunk_info failed\n"); /* Get and verify info of the chunk at the offset (CHUNK_NX,CHUNK_NY) */ - if(verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) + if (verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord failed\n"); /* Attempt to get chunk info given an invalid chunk index and verify * that failure occurs */ chk_index = INVALID_CHK_INDEX; reinit_vars(&read_flt_msk, &addr, &size); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dget_chunk_info(dset, dspace, chk_index, out_offset, &read_flt_msk, &addr, &size); - } H5E_END_TRY; - if(ret != FAIL) + } + H5E_END_TRY; + if (ret != FAIL) TEST_ERROR /* Write the chunk of data to another location */ offset[0] = 0; offset[1] = 0; - if(H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, CHK_SIZE, direct_buf) < 0) + if (H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, CHK_SIZE, direct_buf) < 0) TEST_ERROR; /* Get and verify that two chunks had been written */ - if(H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR + if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) + TEST_ERROR VERIFY(nchunks, TWO_CHUNKS_WRITTEN, "H5Dget_num_chunks, number of chunks"); /* Get and verify info of the first written chunk in the dataset, its offset should be (0,0) */ - if(verify_get_chunk_info(dset, H5S_ALL, 0, CHK_SIZE, offset, flt_msk) == FAIL) + if (verify_get_chunk_info(dset, H5S_ALL, 0, CHK_SIZE, offset, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification H5Dget_chunk_info failed\n"); /* Get and verify info of the chunk at the offset (0,0) */ - if(verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) + if (verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord failed\n"); /* Get and verify info of the second written chunk in the dataset, its offset should be (CHUNK_NX, CHUNK_NY) */ offset[0] = CHUNK_NX; offset[1] = CHUNK_NY; - if(verify_get_chunk_info(dset, H5S_ALL, 1, CHK_SIZE, offset, flt_msk) == FAIL) + if (verify_get_chunk_info(dset, H5S_ALL, 1, CHK_SIZE, offset, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification H5Dget_chunk_info failed\n"); /* Get and verify info of the chunk at the offset (CHUNK_NX, CHUNK_NY) */ - if(verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) + if (verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord failed\n"); /* Get and verify info of an empty chunk, at offset (2*CHUNK_NX, 2*CHUNK_NY) */ - offset[0] = 2*CHUNK_NX; - offset[1] = 2*CHUNK_NY; + offset[0] = 2 * CHUNK_NX; + offset[1] = 2 * CHUNK_NY; /* Get and verify info of the chunk at the offset (CHUNK_NX, CHUNK_NY) */ - if(verify_empty_chunk_info(dset, offset) == FAIL) + if (verify_empty_chunk_info(dset, offset) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord on empty chunk failed\n"); /* Release resourse */ - if(H5Dclose(dset) < 0) TEST_ERROR - if(H5Sclose(dspace) < 0) TEST_ERROR - if(H5Pclose(cparms) < 0) TEST_ERROR - if(H5Fclose(basicfile) < 0) TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Sclose(dspace) < 0) + TEST_ERROR + if (H5Pclose(cparms) < 0) + TEST_ERROR + if (H5Fclose(basicfile) < 0) + TEST_ERROR /* Remove the test file */ remove(filename); @@ -1543,12 +1643,14 @@ test_basic_query(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(dspace); H5Pclose(cparms); H5Fclose(basicfile); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; @@ -1573,91 +1675,105 @@ error: static herr_t test_failed_attempts(const char *filename, hid_t fapl) { - hid_t chunkfile = H5I_INVALID_HID; /* File ID */ - hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ - hid_t dset = H5I_INVALID_HID; /* Dataset ID */ - hsize_t dims[2] = {NX, NY};/* Dataset dimensions */ - int data_buf[NX][NY]; /* Input buffer */ - unsigned read_flt_msk = 0; /* Filter mask after direct read */ - hsize_t offset[2]; /* Offset coordinates of a chunk */ - hsize_t out_offset[2] = {0, 0}; /* Buffer to get offset coordinates */ - hsize_t size = 0; /* Size of an allocated/written chunk */ - hsize_t nchunks = 0; /* Number of chunks */ - haddr_t addr = 0; /* Address of an allocated/written chunk */ - hsize_t chk_index = 0; /* Index of a chunk */ - hsize_t ii, jj; /* Array indices */ - herr_t ret; /* Temporary returned value for verifying failure */ + hid_t chunkfile = H5I_INVALID_HID; /* File ID */ + hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dset = H5I_INVALID_HID; /* Dataset ID */ + hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ + int data_buf[NX][NY]; /* Input buffer */ + unsigned read_flt_msk = 0; /* Filter mask after direct read */ + hsize_t offset[2]; /* Offset coordinates of a chunk */ + hsize_t out_offset[2] = {0, 0}; /* Buffer to get offset coordinates */ + hsize_t size = 0; /* Size of an allocated/written chunk */ + hsize_t nchunks = 0; /* Number of chunks */ + haddr_t addr = 0; /* Address of an allocated/written chunk */ + hsize_t chk_index = 0; /* Index of a chunk */ + hsize_t ii, jj; /* Array indices */ + herr_t ret; /* Temporary returned value for verifying failure */ TESTING(" Invalid Operations"); /* Open the file for reading/writing */ - if((chunkfile = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((chunkfile = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create dataspace */ - if((dspace = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((dspace = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR /* Create a contiguous dataset */ - dset = H5Dcreate2(chunkfile, CONTIGUOUS_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset < 0) TEST_ERROR + dset = H5Dcreate2(chunkfile, CONTIGUOUS_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); + if (dset < 0) + TEST_ERROR /* Initialize the array of data */ - for(ii = 0; ii < NX; ii++) - for(jj = 0; jj < NY; jj++) - data_buf[ii][jj] = (int)(ii*jj); + for (ii = 0; ii < NX; ii++) + for (jj = 0; jj < NY; jj++) + data_buf[ii][jj] = (int)(ii * jj); /* Write the data */ - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_buf) < 0) + if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_buf) < 0) TEST_ERROR /* Close the dataset */ - if(H5Dclose(dset) < 0) TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR /* Open it again to test the chunk query functions on contiguous dataset */ - if((dset = H5Dopen2(chunkfile, CONTIGUOUS_DSET_NAME, H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(chunkfile, CONTIGUOUS_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR /* Attempt to get the number of chunks on contiguous dataset, should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dget_num_chunks(dset, dspace, &nchunks); - } H5E_END_TRY; - if(ret != FAIL) + } + H5E_END_TRY; + if (ret != FAIL) FAIL_PUTS_ERROR(" Attempt a chunk query function on a contiguous dataset.") /* Attempt to get chunk info on contiguous data, should fail */ chk_index = 0; reinit_vars(&read_flt_msk, &addr, &size); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dget_chunk_info(dset, dspace, chk_index, out_offset, &read_flt_msk, &addr, &size); - } H5E_END_TRY; - if(ret != FAIL) + } + H5E_END_TRY; + if (ret != FAIL) FAIL_PUTS_ERROR(" Attempt a chunk query function on a contiguous dataset.") /* Attempt to get chunk info at logical coordinates (0,0) on contiguous * dataset, should fail */ offset[0] = 0; offset[1] = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dget_chunk_info_by_coord(dset, offset, &read_flt_msk, &addr, &size); - } H5E_END_TRY; - if(ret != FAIL) + } + H5E_END_TRY; + if (ret != FAIL) FAIL_PUTS_ERROR(" Attempt a chunk query function on a contiguous dataset.") /* Release resourse */ - if(H5Dclose(dset) < 0) TEST_ERROR - if(H5Sclose(dspace) < 0) TEST_ERROR - if(H5Fclose(chunkfile) < 0) TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Sclose(dspace) < 0) + TEST_ERROR + if (H5Fclose(chunkfile) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(dspace); H5Fclose(chunkfile); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; @@ -1687,9 +1803,9 @@ error: static herr_t test_get_chunk_info_v110(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; /* File name */ - hid_t chunkfile = H5I_INVALID_HID; /* File ID */ - H5F_libver_t low, high; /* File format bounds */ + char filename[FILENAME_BUF_SIZE]; /* File name */ + hid_t chunkfile = H5I_INVALID_HID; /* File ID */ + H5F_libver_t low, high; /* File format bounds */ TESTING("getting chunk information in file with versions 1.10 and later"); HDprintf("\n"); /* to list sub-tests */ @@ -1698,42 +1814,44 @@ test_get_chunk_info_v110(hid_t fapl) high = H5F_LIBVER_LATEST; /* Test getting info of chunked datasets in version combo up to 1.10 */ - for(low = H5F_LIBVER_V110; low <= H5F_LIBVER_LATEST; low++) { + for (low = H5F_LIBVER_V110; low <= H5F_LIBVER_LATEST; low++) { /* Set version bounds for creating file */ - if(H5Pset_libver_bounds(fapl, low, high) < 0) + if (H5Pset_libver_bounds(fapl, low, high) < 0) TEST_ERROR /* Create the file */ h5_fixname(FILENAME[low], fapl, filename, sizeof filename); chunkfile = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(chunkfile < 0) TEST_ERROR + if (chunkfile < 0) + TEST_ERROR /* Close the file, individual tests will re-open the file with different libvers via the fapl */ - if(H5Fclose(chunkfile) < 0) TEST_ERROR + if (H5Fclose(chunkfile) < 0) + TEST_ERROR /* Test getting chunk info when Single Chunk index type is used */ - if(test_chunk_info_single_chunk(filename, fapl) < 0) + if (test_chunk_info_single_chunk(filename, fapl) < 0) TEST_ERROR /* Test getting chunk info when Implicit index type is used */ - if(test_chunk_info_implicit(filename, fapl) < 0) + if (test_chunk_info_implicit(filename, fapl) < 0) TEST_ERROR /* Test getting chunk info when Fixed Array index type is used */ - if(test_chunk_info_fixed_array(filename, fapl) < 0) + if (test_chunk_info_fixed_array(filename, fapl) < 0) TEST_ERROR /* Test getting chunk info when Extensible Array index type is used */ - if(test_chunk_info_extensible_array(filename, fapl) < 0) + if (test_chunk_info_extensible_array(filename, fapl) < 0) TEST_ERROR /* Test getting chunk info when Version 2 B-trees index type is used */ - if(test_chunk_info_version2_btrees(filename, fapl) < 0) + if (test_chunk_info_version2_btrees(filename, fapl) < 0) TEST_ERROR /* Test various attempts to use the functions incorrectly */ - if(test_failed_attempts(filename, fapl) < 0) + if (test_failed_attempts(filename, fapl) < 0) TEST_ERROR } /* for low libver bound */ @@ -1760,31 +1878,31 @@ error: static herr_t test_flt_msk_with_skip_compress(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; /* File name */ - hid_t filter_file = H5I_INVALID_HID; /* File ID for filter mask */ - hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ - hid_t mem_space = H5I_INVALID_HID; /* Dataspace ID */ - hid_t dset = H5I_INVALID_HID; /* Dataset ID */ - hid_t cparms = H5I_INVALID_HID; /* Creation plist */ - hid_t dxpl = H5I_INVALID_HID; /* Transfer plist */ - hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* 2 unlimited dims */ - hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ - int direct_buf[CHUNK_NX][CHUNK_NY]; /* One chunk of data */ - int check_chunk[CHUNK_NX][CHUNK_NY]; /* Buffer to read data in */ - int read_direct_buf[CHUNK_NX][CHUNK_NY]; /* Buffer to read a chunk */ - hsize_t read_buf_size = 0; /* buf size */ - unsigned flt_msk = 0; /* Filter mask */ - unsigned read_flt_msk = 0; /* Filter mask after direct read */ - hsize_t offset[2] = {0, 0}; /* Offset coordinates of a chunk */ - hsize_t nchunks = 0; /* Number of chunks */ - hsize_t chk_index = 0; /* Index of a chunk */ - int aggression = 9; /* Compression aggression setting */ - hsize_t start[2]; /* Start of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Block count */ - hsize_t block[2]; /* Block sizes */ - int ii, jj; /* Array indices */ + char filename[FILENAME_BUF_SIZE]; /* File name */ + hid_t filter_file = H5I_INVALID_HID; /* File ID for filter mask */ + hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ + hid_t mem_space = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t cparms = H5I_INVALID_HID; /* Creation plist */ + hid_t dxpl = H5I_INVALID_HID; /* Transfer plist */ + hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* 2 unlimited dims */ + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ + int direct_buf[CHUNK_NX][CHUNK_NY]; /* One chunk of data */ + int check_chunk[CHUNK_NX][CHUNK_NY]; /* Buffer to read data in */ + int read_direct_buf[CHUNK_NX][CHUNK_NY]; /* Buffer to read a chunk */ + hsize_t read_buf_size = 0; /* buf size */ + unsigned flt_msk = 0; /* Filter mask */ + unsigned read_flt_msk = 0; /* Filter mask after direct read */ + hsize_t offset[2] = {0, 0}; /* Offset coordinates of a chunk */ + hsize_t nchunks = 0; /* Number of chunks */ + hsize_t chk_index = 0; /* Index of a chunk */ + int aggression = 9; /* Compression aggression setting */ + hsize_t start[2]; /* Start of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Block count */ + hsize_t block[2]; /* Block sizes */ + int ii, jj; /* Array indices */ TESTING("getting filter mask when compression filter is skipped"); @@ -1792,40 +1910,41 @@ test_flt_msk_with_skip_compress(hid_t fapl) h5_fixname(FILTERMASK_FILE, fapl, filename, sizeof filename); /* Create a new file. */ - if((filter_file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((filter_file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create file data space with unlimited dimensions. */ - if((dspace = H5Screate_simple(RANK, dims, maxdims)) < 0) + if ((dspace = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR; /* Create memory data space. */ - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) TEST_ERROR; /* Create dataset create property list with chunking and compression enabled. */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if(H5Pset_chunk( cparms, RANK, chunk_dims) < 0) + if (H5Pset_chunk(cparms, RANK, chunk_dims) < 0) TEST_ERROR; - if(H5Pset_deflate( cparms, (unsigned ) aggression) < 0) + if (H5Pset_deflate(cparms, (unsigned)aggression) < 0) TEST_ERROR; /* Create a new dataset using cparms creation properties. */ - if((dset = H5Dcreate2(filter_file, SKIP_FILTER_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(filter_file, SKIP_FILTER_DSET_NAME, H5T_NATIVE_INT, dspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; /* Create transfer property list for writing */ - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; /* Initialize data for one chunk */ - for(ii = 0; ii < CHUNK_NX; ii++) - for(jj = 0; jj < CHUNK_NY; jj++) - direct_buf[ii][jj] = (int)(ii*jj); + for (ii = 0; ii < CHUNK_NX; ii++) + for (jj = 0; jj < CHUNK_NY; jj++) + direct_buf[ii][jj] = (int)(ii * jj); /* Indicate the compression filter is to be skipped. */ flt_msk = 0x00000001; @@ -1833,34 +1952,38 @@ test_flt_msk_with_skip_compress(hid_t fapl) /* Write a chunk of uncompressed data */ offset[0] = CHUNK_NX; offset[1] = CHUNK_NY; - if(H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, CHK_SIZE, direct_buf) < 0) + if (H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, CHK_SIZE, direct_buf) < 0) TEST_ERROR; - if(H5Fflush(dset, H5F_SCOPE_LOCAL) < 0) + if (H5Fflush(dset, H5F_SCOPE_LOCAL) < 0) TEST_ERROR; /* Close and re-open the dataset */ - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) TEST_ERROR; - if((dset = H5Dopen2(filter_file, SKIP_FILTER_DSET_NAME, H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(filter_file, SKIP_FILTER_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Select hyperslab for the chunk just written in the file */ - start[0] = CHUNK_NX; start[1] = CHUNK_NY; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = CHUNK_NX; block[1] = CHUNK_NY; - if(H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, stride, count, block) < 0) + start[0] = CHUNK_NX; + start[1] = CHUNK_NY; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = CHUNK_NX; + block[1] = CHUNK_NY; + if (H5Sselect_hyperslab(dspace, H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR; /* Read the chunk back */ - if(H5Dread(dset, H5T_NATIVE_INT, mem_space, dspace, H5P_DEFAULT, check_chunk) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, mem_space, dspace, H5P_DEFAULT, check_chunk) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(ii = 0; ii < CHUNK_NX; ii++) - for(jj = 0; jj < CHUNK_NY; jj++) - if(direct_buf[ii][jj] != check_chunk[ii][jj]) { + for (ii = 0; ii < CHUNK_NX; ii++) + for (jj = 0; jj < CHUNK_NY; jj++) + if (direct_buf[ii][jj] != check_chunk[ii][jj]) { HDprintf(" 1. Read different values than written."); HDprintf(" At index %d,%d\n", ii, jj); HDprintf(" direct_buf=%d, check_chunk=%d\n", direct_buf[ii][jj], check_chunk[ii][jj]); @@ -1868,50 +1991,58 @@ test_flt_msk_with_skip_compress(hid_t fapl) } /* Query chunk storage size */ - if(H5Dget_chunk_storage_size(dset, offset, &read_buf_size) < 0) + if (H5Dget_chunk_storage_size(dset, offset, &read_buf_size) < 0) TEST_ERROR; - if(read_buf_size != CHK_SIZE) + if (read_buf_size != CHK_SIZE) TEST_ERROR; /* Read the raw chunk back with H5Dread_chunk */ HDmemset(&read_direct_buf, 0, sizeof(read_direct_buf)); - if(H5Dread_chunk(dset, H5P_DEFAULT, offset, &read_flt_msk, read_direct_buf) < 0) + if (H5Dread_chunk(dset, H5P_DEFAULT, offset, &read_flt_msk, read_direct_buf) < 0) TEST_ERROR; - if(read_flt_msk != flt_msk) + if (read_flt_msk != flt_msk) TEST_ERROR; /* Check that the direct chunk read is the same as the chunk written */ - for(ii = 0; ii < CHUNK_NX; ii++) - for(jj = 0; jj < CHUNK_NY; jj++) - if(direct_buf[ii][jj] != read_direct_buf[ii][jj]) { + for (ii = 0; ii < CHUNK_NX; ii++) + for (jj = 0; jj < CHUNK_NY; jj++) + if (direct_buf[ii][jj] != read_direct_buf[ii][jj]) { HDprintf(" 1. Read different values than written."); HDprintf(" At index %d,%d\n", ii, jj); - HDprintf(" direct_buf=%d, read_direct_buf=%d\n", direct_buf[ii][jj], read_direct_buf[ii][jj]); + HDprintf(" direct_buf=%d, read_direct_buf=%d\n", direct_buf[ii][jj], + read_direct_buf[ii][jj]); TEST_ERROR; } /* Get and verify the number of chunks written */ - if(H5Dget_num_chunks(dset, H5S_ALL, &nchunks) < 0) TEST_ERROR + if (H5Dget_num_chunks(dset, H5S_ALL, &nchunks) < 0) + TEST_ERROR VERIFY(nchunks, ONE_CHUNK_WRITTEN, "H5Dget_num_chunks, number of chunks"); /* Get and verify info of the first and only chunk */ chk_index = 0; offset[0] = CHUNK_NX; offset[1] = CHUNK_NY; - if(verify_get_chunk_info(dset, H5S_ALL, chk_index, CHK_SIZE, offset, flt_msk) == FAIL) + if (verify_get_chunk_info(dset, H5S_ALL, chk_index, CHK_SIZE, offset, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info failed\n"); /* Get info of the chunk at the specified offsets and verify its info */ - if(verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) + if (verify_get_chunk_info_by_coord(dset, offset, CHK_SIZE, flt_msk) == FAIL) FAIL_PUTS_ERROR("Verification of H5Dget_chunk_info_by_coord failed\n"); /* Release resourse */ - if(H5Dclose(dset) < 0) TEST_ERROR - if(H5Sclose(mem_space) < 0) TEST_ERROR - if(H5Sclose(dspace) < 0) TEST_ERROR - if(H5Pclose(cparms) < 0) TEST_ERROR - if(H5Pclose(dxpl) < 0) TEST_ERROR - if(H5Fclose(filter_file) < 0) TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Sclose(mem_space) < 0) + TEST_ERROR + if (H5Sclose(dspace) < 0) + TEST_ERROR + if (H5Pclose(cparms) < 0) + TEST_ERROR + if (H5Pclose(dxpl) < 0) + TEST_ERROR + if (H5Fclose(filter_file) < 0) + TEST_ERROR /* Remove the test file */ remove(filename); @@ -1920,14 +2051,16 @@ test_flt_msk_with_skip_compress(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(mem_space); H5Sclose(dspace); H5Pclose(cparms); H5Pclose(dxpl); H5Fclose(filter_file); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; @@ -1948,13 +2081,14 @@ error: int main(void) { - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - int nerrors = 0; /* Number of errors so far */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + int nerrors = 0; /* Number of errors so far */ h5_reset(); /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR /* Test basic operations on the chunk query functions */ nerrors += test_basic_query(fapl) < 0 ? 1 : 0; @@ -1968,7 +2102,7 @@ main(void) /* Tests getting filter mask when compression filter is skipped */ nerrors += test_flt_msk_with_skip_compress(fapl) < 0 ? 1 : 0; - if(nerrors) + if (nerrors) goto error; HDprintf("All chunk query tests passed.\n"); @@ -1979,8 +2113,7 @@ main(void) error: nerrors = MAX(1, nerrors); - HDprintf("***** %d QUERY CHUNK INFO TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d QUERY CHUNK INFO TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return EXIT_FAILURE; } diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index ff3767c..25fa3f0 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -19,26 +19,16 @@ /* See H5private.h for how to include headers */ #undef NDEBUG -#define H5T_FRIEND /*suppress error about including H5Tpkg */ -#include "H5Tpkg.h" /*to turn off hardware conversions*/ +#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#include "H5Tpkg.h" /*to turn off hardware conversions*/ #include "H5Iprivate.h" #include "h5test.h" -const char *FILENAME[] = { - "cmpd_dset", - "src_subset", - "dst_subset", - NULL -}; - -const char *DSET_NAME[] = { - "contig_src_subset", - "chunk_src_subset", - "contig_dst_subset", - "chunk_dst_subset", - NULL -}; +const char *FILENAME[] = {"cmpd_dset", "src_subset", "dst_subset", NULL}; + +const char *DSET_NAME[] = {"contig_src_subset", "chunk_src_subset", "contig_dst_subset", "chunk_dst_subset", + NULL}; /* The first dataset */ typedef struct s1_t { @@ -96,16 +86,16 @@ typedef struct s6_t { /* Structures for testing the optimization for the Chicago company. */ typedef struct { - int a, b, c[8], d, e; - float f, g, h[16], i, j; + int a, b, c[8], d, e; + float f, g, h[16], i, j; double k, l, m, n; } stype1; typedef struct { - int a, b, c[8], d, e; - float f, g, h[16], i, j; + int a, b, c[8], d, e; + float f, g, h[16], i, j; double k, l, m, n; - long o, p, q; + long o, p, q; } stype2; typedef struct { @@ -113,17 +103,16 @@ typedef struct { } stype3; typedef struct { - int a, b, c[8], d, e; - float f, g, h[16], i, j; - double k, l, m, n; - long o, p, q; + int a, b, c[8], d, e; + float f, g, h[16], i, j; + double k, l, m, n; + long o, p, q; long long r, s, t; } stype4; -#define NX 100u -#define NY 2000u -#define PACK_NMEMBS 100 - +#define NX 100u +#define NY 2000u +#define PACK_NMEMBS 100 /*------------------------------------------------------------------------- * Function: test_compound @@ -149,92 +138,97 @@ typedef struct { *------------------------------------------------------------------------- */ static unsigned -test_compound (char *filename, hid_t fapl) +test_compound(char *filename, hid_t fapl) { /* First dataset */ - s1_t *s1 = NULL; - hid_t s1_tid; + s1_t *s1 = NULL; + hid_t s1_tid; /* Second dataset */ - s2_t *s2 = NULL; - hid_t s2_tid; + s2_t *s2 = NULL; + hid_t s2_tid; /* Third dataset */ - s3_t *s3 = NULL; - hid_t s3_tid; + s3_t *s3 = NULL; + hid_t s3_tid; /* Fourth dataset */ - s4_t *s4 = NULL; - hid_t s4_tid; + s4_t *s4 = NULL; + hid_t s4_tid; /* Fifth dataset */ - s5_t *s5 = NULL; - hid_t s5_tid; + s5_t *s5 = NULL; + hid_t s5_tid; /* Sixth dataset */ - s6_t *s6 = NULL; - hid_t s6_tid; + s6_t *s6 = NULL; + hid_t s6_tid; /* Seventh dataset */ - hid_t s7_sid; + hid_t s7_sid; /* Eighth dataset */ - s1_t *s8 = NULL; - hid_t s8_f_sid; /*file data space */ - hid_t s8_m_sid; /*memory data space */ + s1_t *s8 = NULL; + hid_t s8_f_sid; /*file data space */ + hid_t s8_m_sid; /*memory data space */ /* Ninth dataset */ /* Tenth dataset */ /* Eleventh dataset */ - s4_t *s11 = NULL; + s4_t *s11 = NULL; /* Other variables */ - unsigned int i, j; - hid_t file, dataset, space, PRESERVE; - hid_t array_dt; - static hsize_t dim[] = {NX, NY}; - hsize_t f_offset[2]; /*offset of hyperslab in file */ - hsize_t h_size[2]; /*size of hyperslab */ + unsigned int i, j; + hid_t file, dataset, space, PRESERVE; + hid_t array_dt; + static hsize_t dim[] = {NX, NY}; + hsize_t f_offset[2]; /*offset of hyperslab in file */ + hsize_t h_size[2]; /*size of hyperslab */ hsize_t memb_size[1] = {4}; int ret_code; /* Allocate buffers for datasets */ - if(NULL == (s1 = (s1_t *)HDmalloc(sizeof(s1_t) * NX * NY))) + if (NULL == (s1 = (s1_t *)HDmalloc(sizeof(s1_t) * NX * NY))) goto error; - if(NULL == (s2 = (s2_t *)HDmalloc(sizeof(s2_t) * NX * NY))) + if (NULL == (s2 = (s2_t *)HDmalloc(sizeof(s2_t) * NX * NY))) goto error; - if(NULL == (s3 = (s3_t *)HDmalloc(sizeof(s3_t) * NX * NY))) + if (NULL == (s3 = (s3_t *)HDmalloc(sizeof(s3_t) * NX * NY))) goto error; - if(NULL == (s4 = (s4_t *)HDmalloc(sizeof(s4_t) * NX * NY))) + if (NULL == (s4 = (s4_t *)HDmalloc(sizeof(s4_t) * NX * NY))) goto error; - if(NULL == (s5 = (s5_t *)HDmalloc(sizeof(s5_t) * NX * NY))) + if (NULL == (s5 = (s5_t *)HDmalloc(sizeof(s5_t) * NX * NY))) goto error; - if(NULL == (s6 = (s6_t *)HDmalloc(sizeof(s6_t) * NX * NY))) + if (NULL == (s6 = (s6_t *)HDmalloc(sizeof(s6_t) * NX * NY))) goto error; /* Create the file */ - if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { + goto error; } /* Create the data space */ - if ((space = H5Screate_simple (2, dim, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, dim, NULL)) < 0) + goto error; /* Create xfer properties to preserve initialized data */ /* Also verify H5Pset_preserve is initially 0 and then is set to 1. */ - if ((PRESERVE = H5Pcreate (H5P_DATASET_XFER))<0) goto error; - if ((ret_code=H5Pget_preserve (PRESERVE)) != 0){ - HDprintf("Preserve status of dataset transfer property list should be" - " 0 (FALSE), got %d\n", ret_code); - goto error; + if ((PRESERVE = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if ((ret_code = H5Pget_preserve(PRESERVE)) != 0) { + HDprintf("Preserve status of dataset transfer property list should be" + " 0 (FALSE), got %d\n", + ret_code); + goto error; } - if (H5Pset_preserve (PRESERVE, 1)<0) goto error; - if ((ret_code=H5Pget_preserve (PRESERVE)) != 1){ - HDprintf("Preserve status of dataset transfer property list should be" - " 1 (TRUE), got %d\n", ret_code); - goto error; + if (H5Pset_preserve(PRESERVE, 1) < 0) + goto error; + if ((ret_code = H5Pget_preserve(PRESERVE)) != 1) { + HDprintf("Preserve status of dataset transfer property list should be" + " 1 (TRUE), got %d\n", + ret_code); + goto error; } /* @@ -244,36 +238,36 @@ test_compound (char *filename, hid_t fapl) TESTING("basic compound write"); /* Initialize the dataset */ - for (i=0; ia != ps1->a || - ps8->b != ps1->b || - ps8->c[0] != ps1->c[0] || - ps8->c[1] != ps1->c[1] || - ps8->c[2] != ps1->c[2] || - ps8->c[3] != ps1->c[3] || - ps8->d != ps1->d || - ps8->e != ps1->e) { - H5_FAILED(); - puts(" Incorrect values read from file"); - goto error; + for (i = 0; i < h_size[0]; i++) { + for (j = 0; j < h_size[1]; j++) { + s1_t *ps1 = s1 + (f_offset[0] + i) * NY + f_offset[1] + j; + s1_t *ps8 = s8 + i * h_size[1] + j; + + if (ps8->a != ps1->a || ps8->b != ps1->b || ps8->c[0] != ps1->c[0] || ps8->c[1] != ps1->c[1] || + ps8->c[2] != ps1->c[2] || ps8->c[3] != ps1->c[3] || ps8->d != ps1->d || ps8->e != ps1->e) { + H5_FAILED(); + puts(" Incorrect values read from file"); + goto error; + } } } - } - HDfree (s8); + HDfree(s8); s8 = NULL; PASSED(); - /* *###################################################################### * STEP 10. Read a hyperslab of the file into a hyperslab of memory. The @@ -667,52 +622,41 @@ test_compound (char *filename, hid_t fapl) TESTING("hyperslab partial read to another hyperslab"); /* Initialize */ - for (i=0; i=f_offset[0] && - i=f_offset[1] && - ja != ps1->a || - ps2->b != ps1->b || - ps2->c[0] != ps1->c[0] || - ps2->c[1] != ps1->c[1] || - ps2->c[2] != ps1->c[2] || - ps2->c[3] != ps1->c[3] || - ps2->d != ps1->d || - ps2->e != ps1->e) { - H5_FAILED(); - puts(" Memory values clobbered"); - goto error; + for (i = 0; i < NX; i++) { + for (j = 0; j < NY; j++) { + s1_t *ps1 = s1 + i * NY + j; + s2_t *ps2 = s2 + i * NY + j; + if (i >= f_offset[0] && i < f_offset[0] + h_size[0] && j >= f_offset[1] && + j < f_offset[1] + h_size[1]) { + if (ps2->a != ps1->a || ps2->b != ps1->b || ps2->c[0] != ps1->c[0] || + ps2->c[1] != ps1->c[1] || ps2->c[2] != ps1->c[2] || ps2->c[3] != ps1->c[3] || + ps2->d != ps1->d || ps2->e != ps1->e) { + H5_FAILED(); + puts(" Memory values clobbered"); + goto error; + } + } + else { + if (ps2->a != (unsigned)(-1) || ps2->b != (unsigned)(-1) || ps2->c[0] != (unsigned)(-1) || + ps2->c[1] != (unsigned)(-1) || ps2->c[2] != (unsigned)(-1) || + ps2->c[3] != (unsigned)(-1) || ps2->d != (unsigned)(-1) || ps2->e != (unsigned)(-1)) { + H5_FAILED(); + puts(" Incorrect values read from file"); + goto error; + } + } } - } else { - if (ps2->a != (unsigned)(-1) || - ps2->b != (unsigned)(-1) || - ps2->c[0] != (unsigned)(-1) || - ps2->c[1] != (unsigned)(-1) || - ps2->c[2] != (unsigned)(-1) || - ps2->c[3] != (unsigned)(-1) || - ps2->d != (unsigned)(-1) || - ps2->e != (unsigned)(-1)) { - H5_FAILED(); - puts(" Incorrect values read from file"); - goto error; - } - } - } } PASSED(); @@ -724,62 +668,46 @@ test_compound (char *filename, hid_t fapl) TESTING("hyperslab to hyperslab part initialized read"); /* Initialize */ - for (i=0; i=f_offset[0] && - i=f_offset[1] && - jpre != (unsigned)(-1) || - ps5->a != ps1->a || - ps5->b != ps1->b || - ps5->mid1 != (unsigned)(-1) || - ps5->c[0] != ps1->c[0] || - ps5->c[1] != ps1->c[1] || - ps5->c[2] != ps1->c[2] || - ps5->c[3] != ps1->c[3] || - ps5->mid2 != (unsigned)(-1) || - ps5->d != ps1->d || - ps5->e != ps1->e || - ps5->post != (unsigned)(-1)) { - H5_FAILED(); - puts(" Memory values clobbered"); - goto error; - } - } else { - if (ps5->pre != (unsigned)(-1) || - ps5->a != (unsigned)(-1) || - ps5->b != (unsigned)(-1) || - ps5->mid1 != (unsigned)(-1) || - ps5->c[0] != (unsigned)(-1) || - ps5->c[1] != (unsigned)(-1) || - ps5->c[2] != (unsigned)(-1) || - ps5->c[3] != (unsigned)(-1) || - ps5->mid2 != (unsigned)(-1) || - ps5->d != (unsigned)(-1) || - ps5->e != (unsigned)(-1) || - ps5->post != (unsigned)(-1)) { - H5_FAILED(); - puts(" Incorrect values read from file"); - goto error; - } + for (i = 0; i < NX; i++) { + for (j = 0; j < NY; j++) { + s1_t *ps1 = s1 + i * NY + j; + s5_t *ps5 = s5 + i * NY + j; + if (i >= f_offset[0] && i < f_offset[0] + h_size[0] && j >= f_offset[1] && + j < f_offset[1] + h_size[1]) { + if (ps5->pre != (unsigned)(-1) || ps5->a != ps1->a || ps5->b != ps1->b || + ps5->mid1 != (unsigned)(-1) || ps5->c[0] != ps1->c[0] || ps5->c[1] != ps1->c[1] || + ps5->c[2] != ps1->c[2] || ps5->c[3] != ps1->c[3] || ps5->mid2 != (unsigned)(-1) || + ps5->d != ps1->d || ps5->e != ps1->e || ps5->post != (unsigned)(-1)) { + H5_FAILED(); + puts(" Memory values clobbered"); + goto error; + } + } + else { + if (ps5->pre != (unsigned)(-1) || ps5->a != (unsigned)(-1) || ps5->b != (unsigned)(-1) || + ps5->mid1 != (unsigned)(-1) || ps5->c[0] != (unsigned)(-1) || + ps5->c[1] != (unsigned)(-1) || ps5->c[2] != (unsigned)(-1) || + ps5->c[3] != (unsigned)(-1) || ps5->mid2 != (unsigned)(-1) || ps5->d != (unsigned)(-1) || + ps5->e != (unsigned)(-1) || ps5->post != (unsigned)(-1)) { + H5_FAILED(); + puts(" Incorrect values read from file"); + goto error; + } + } } } - } PASSED(); /* @@ -790,73 +718,67 @@ test_compound (char *filename, hid_t fapl) TESTING("hyperslab part initialized write"); /* Create the memory array and initialize all fields to zero */ - f_offset[0] = NX/3; - f_offset[1] = NY/3; - h_size[0] = 2*NX/3 - f_offset[0]; - h_size[1] = 2*NY/3 - f_offset[1]; - s11 = (s4_t *) HDmalloc ((size_t)h_size[0]*(size_t)h_size[1]*sizeof(s4_t)); - assert (s11); + f_offset[0] = NX / 3; + f_offset[1] = NY / 3; + h_size[0] = 2 * NX / 3 - f_offset[0]; + h_size[1] = 2 * NY / 3 - f_offset[1]; + s11 = (s4_t *)HDmalloc((size_t)h_size[0] * (size_t)h_size[1] * sizeof(s4_t)); + assert(s11); /* Initialize */ - for (i=0; ia != 8*(i*NY+j)+0 || - ps1->c[0] != 8*(i*NY+j)+2 || - ps1->c[1] != 8*(i*NY+j)+3 || - ps1->c[2] != 8*(i*NY+j)+4 || - ps1->c[3] != 8*(i*NY+j)+5 || - ps1->e != 8*(i*NY+j)+7) { - H5_FAILED(); - puts(" Write clobbered values"); - goto error; - } - - if (i>=f_offset[0] && - i=f_offset[1] && - jb != (unsigned)(-1) || - ps1->d != (unsigned)(-1)) { - H5_FAILED(); - puts(" Wrong values written or read"); - goto error; - } - } else { - if (ps1->b != 8*(i*NY+j)+1 || - ps1->d != 8*(i*NY+j)+6) { - H5_FAILED(); - puts(" Write clobbered values"); - goto error; + for (i = 0; i < NX; i++) { + for (j = 0; j < NY; j++) { + s1_t *ps1 = s1 + i * NY + j; + + if (ps1->a != 8 * (i * NY + j) + 0 || ps1->c[0] != 8 * (i * NY + j) + 2 || + ps1->c[1] != 8 * (i * NY + j) + 3 || ps1->c[2] != 8 * (i * NY + j) + 4 || + ps1->c[3] != 8 * (i * NY + j) + 5 || ps1->e != 8 * (i * NY + j) + 7) { + H5_FAILED(); + puts(" Write clobbered values"); + goto error; + } + + if (i >= f_offset[0] && i < f_offset[0] + h_size[0] && j >= f_offset[1] && + j < f_offset[1] + h_size[1]) { + if (ps1->b != (unsigned)(-1) || ps1->d != (unsigned)(-1)) { + H5_FAILED(); + puts(" Wrong values written or read"); + goto error; + } + } + else { + if (ps1->b != 8 * (i * NY + j) + 1 || ps1->d != 8 * (i * NY + j) + 6) { + H5_FAILED(); + puts(" Write clobbered values"); + goto error; + } + } } - } - } } /* * Release resources. */ - H5Pclose (PRESERVE); - H5Dclose (dataset); - H5Fclose (file); + H5Pclose(PRESERVE); + H5Dclose(dataset); + H5Fclose(file); /* Release buffers */ HDfree(s1); @@ -873,23 +795,22 @@ error: puts("*** DATASET TESTS FAILED ***"); /* Release resources */ - if(s1) + if (s1) HDfree(s1); - if(s2) + if (s2) HDfree(s2); - if(s3) + if (s3) HDfree(s3); - if(s4) + if (s4) HDfree(s4); - if(s5) + if (s5) HDfree(s5); - if(s6) + if (s6) HDfree(s6); return 1; } - /*------------------------------------------------------------------------- * Function: initialize_stype1 * @@ -906,33 +827,32 @@ error: static void initialize_stype1(unsigned char *buf, size_t num) { - int i, j; + int i, j; stype1 *s_ptr; - for(i = 0; i < (int)num; i++) { - s_ptr = (stype1 *)((void *)buf) + i; - s_ptr->a = i * 8 + 0; - s_ptr->b = i * 8 + 1; - for(j = 0; j < 8; j++) - s_ptr->c[j] = i * 8 + j; - s_ptr->d = i * 8 + 6; - s_ptr->e = i * 8 + 7; - - s_ptr->f = (float)(i * 2 / 3); - s_ptr->g = (float)(i * 2 / 3 + 1); - for(j = 0; j < 16; j++) - s_ptr->h[j] = (float)(i * j / 5 + j); - s_ptr->i = (float)(i * 2 / 3 + 2); - s_ptr->j = (float)(i * 2 / 3 + 3); - - s_ptr->k = i / 7 + 1; - s_ptr->l = i / 7 + 2; - s_ptr->m = i / 7 + 3; - s_ptr->n = i / 7 + 4; + for (i = 0; i < (int)num; i++) { + s_ptr = (stype1 *)((void *)buf) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + for (j = 0; j < 8; j++) + s_ptr->c[j] = i * 8 + j; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; + + s_ptr->f = (float)(i * 2 / 3); + s_ptr->g = (float)(i * 2 / 3 + 1); + for (j = 0; j < 16; j++) + s_ptr->h[j] = (float)(i * j / 5 + j); + s_ptr->i = (float)(i * 2 / 3 + 2); + s_ptr->j = (float)(i * 2 / 3 + 3); + + s_ptr->k = i / 7 + 1; + s_ptr->l = i / 7 + 2; + s_ptr->m = i / 7 + 3; + s_ptr->n = i / 7 + 4; } } - /*------------------------------------------------------------------------- * Function: initialize_stype2 * @@ -949,37 +869,36 @@ initialize_stype1(unsigned char *buf, size_t num) static void initialize_stype2(unsigned char *buf, size_t num) { - size_t i, j; + size_t i, j; stype2 *s_ptr; - for(i = 0; i < num; i++) { - s_ptr = (stype2 *)((void *)buf) + i; - s_ptr->a = (int)(i * 8 + 0); - s_ptr->b = (int)(i * 8 + 1); - for(j = 0; j < 8; j++) - s_ptr->c[j] = (int)(i * 8 + j); - s_ptr->d = (int)(i * 8 + 6); - s_ptr->e = (int)(i * 8 + 7); - - s_ptr->f = (float)(i * 2 / 3); - s_ptr->g = (float)(i * 2 / 3 + 1); - for(j = 0; j < 16; j++) - s_ptr->h[j] = (float)(i * j / 5 + j); - s_ptr->i = (float)(i * 2 / 3 + 2); - s_ptr->j = (float)(i * 2 / 3 + 3); - - s_ptr->k = (double)(i / 7 + 1); - s_ptr->l = (double)(i / 7 + 2); - s_ptr->m = (double)(i / 7 + 3); - s_ptr->n = (double)(i / 7 + 4); - - s_ptr->o = (long)(i * 3 + 0); - s_ptr->p = (long)(i * 3 + 1); - s_ptr->q = (long)(i * 3 + 2); + for (i = 0; i < num; i++) { + s_ptr = (stype2 *)((void *)buf) + i; + s_ptr->a = (int)(i * 8 + 0); + s_ptr->b = (int)(i * 8 + 1); + for (j = 0; j < 8; j++) + s_ptr->c[j] = (int)(i * 8 + j); + s_ptr->d = (int)(i * 8 + 6); + s_ptr->e = (int)(i * 8 + 7); + + s_ptr->f = (float)(i * 2 / 3); + s_ptr->g = (float)(i * 2 / 3 + 1); + for (j = 0; j < 16; j++) + s_ptr->h[j] = (float)(i * j / 5 + j); + s_ptr->i = (float)(i * 2 / 3 + 2); + s_ptr->j = (float)(i * 2 / 3 + 3); + + s_ptr->k = (double)(i / 7 + 1); + s_ptr->l = (double)(i / 7 + 2); + s_ptr->m = (double)(i / 7 + 3); + s_ptr->n = (double)(i / 7 + 4); + + s_ptr->o = (long)(i * 3 + 0); + s_ptr->p = (long)(i * 3 + 1); + s_ptr->q = (long)(i * 3 + 2); } } - /*------------------------------------------------------------------------- * Function: initialize_stype3 * @@ -996,21 +915,20 @@ initialize_stype2(unsigned char *buf, size_t num) static void initialize_stype3(unsigned char *buf, size_t num) { - int i, j; + int i, j; stype3 *s_ptr; - for(i = 0; i < (int)num; i++) { - s_ptr = (stype3 *)((void *)buf) + i; - s_ptr->a = i * 8 + 0; - s_ptr->b = i * 8 + 1; - for(j = 0; j < 8; j++) - s_ptr->c[j] = i * 8 + j; - s_ptr->d = i * 8 + 6; - s_ptr->e = i * 8 + 7; + for (i = 0; i < (int)num; i++) { + s_ptr = (stype3 *)((void *)buf) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + for (j = 0; j < 8; j++) + s_ptr->c[j] = i * 8 + j; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; } } - /*------------------------------------------------------------------------- * Function: initialize_stype4 * @@ -1027,41 +945,40 @@ initialize_stype3(unsigned char *buf, size_t num) static void initialize_stype4(unsigned char *buf, size_t num) { - size_t i, j; + size_t i, j; stype4 *s_ptr; - for(i = 0; i < num; i++) { - s_ptr = (stype4 *)((void *)buf) + i; - s_ptr->a = (int)(i * 8 + 0); - s_ptr->b = (int)(i * 8 + 1); - for(j = 0; j < 8; j++) - s_ptr->c[j] = (int)(i * 8 + j); - s_ptr->d = (int)(i * 8 + 6); - s_ptr->e = (int)(i * 8 + 7); - - s_ptr->f = (float)(i * 2 / 3); - s_ptr->g = (float)(i * 2 / 3 + 1); - for(j = 0; j < 16; j++) - s_ptr->h[j] = (float)(i * j / 5 + j); - s_ptr->i = (float)(i * 2 / 3 + 2); - s_ptr->j = (float)(i * 2 / 3 + 3); - - s_ptr->k = (double)(i / 7 + 1); - s_ptr->l = (double)(i / 7 + 2); - s_ptr->m = (double)(i / 7 + 3); - s_ptr->n = (double)(i / 7 + 4); - - s_ptr->o = (long)(i * 3 + 0); - s_ptr->p = (long)(i * 3 + 1); - s_ptr->q = (long)(i * 3 + 2); - - s_ptr->r = (long long)(i * 5 + 1); - s_ptr->s = (long long)(i * 5 + 2); - s_ptr->t = (long long)(i * 5 + 3); + for (i = 0; i < num; i++) { + s_ptr = (stype4 *)((void *)buf) + i; + s_ptr->a = (int)(i * 8 + 0); + s_ptr->b = (int)(i * 8 + 1); + for (j = 0; j < 8; j++) + s_ptr->c[j] = (int)(i * 8 + j); + s_ptr->d = (int)(i * 8 + 6); + s_ptr->e = (int)(i * 8 + 7); + + s_ptr->f = (float)(i * 2 / 3); + s_ptr->g = (float)(i * 2 / 3 + 1); + for (j = 0; j < 16; j++) + s_ptr->h[j] = (float)(i * j / 5 + j); + s_ptr->i = (float)(i * 2 / 3 + 2); + s_ptr->j = (float)(i * 2 / 3 + 3); + + s_ptr->k = (double)(i / 7 + 1); + s_ptr->l = (double)(i / 7 + 2); + s_ptr->m = (double)(i / 7 + 3); + s_ptr->n = (double)(i / 7 + 4); + + s_ptr->o = (long)(i * 3 + 0); + s_ptr->p = (long)(i * 3 + 1); + s_ptr->q = (long)(i * 3 + 2); + + s_ptr->r = (long long)(i * 5 + 1); + s_ptr->s = (long long)(i * 5 + 2); + s_ptr->t = (long long)(i * 5 + 3); } } - /*------------------------------------------------------------------------- * Function: create_stype1 * @@ -1080,35 +997,35 @@ initialize_stype4(unsigned char *buf, size_t num) static hid_t create_stype1(void) { - hid_t array_dt1, array_dt2, tid; - const hsize_t eight = 8, sixteen = 16; + hid_t array_dt1, array_dt2, tid; + const hsize_t eight = 8, sixteen = 16; /* Build hdf5 datatypes */ - if((array_dt1 = H5Tarray_create2(H5T_NATIVE_INT,1, &eight)) < 0) + if ((array_dt1 = H5Tarray_create2(H5T_NATIVE_INT, 1, &eight)) < 0) goto error; - if((array_dt2 = H5Tarray_create2(H5T_NATIVE_FLOAT,1, &sixteen)) < 0) + if ((array_dt2 = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &sixteen)) < 0) goto error; - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(stype1))) < 0 || - H5Tinsert(tid, "a", HOFFSET(stype1, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "b", HOFFSET(stype1, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "c", HOFFSET(stype1, c), array_dt1) < 0 || - H5Tinsert(tid, "d", HOFFSET(stype1, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "e", HOFFSET(stype1, e), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "f", HOFFSET(stype1, f), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "g", HOFFSET(stype1, g), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "h", HOFFSET(stype1, h), array_dt2) < 0 || - H5Tinsert(tid, "i", HOFFSET(stype1, i), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "j", HOFFSET(stype1, j), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "k", HOFFSET(stype1, k), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "l", HOFFSET(stype1, l), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "m", HOFFSET(stype1, m), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "n", HOFFSET(stype1, n), H5T_NATIVE_DOUBLE) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(stype1))) < 0 || + H5Tinsert(tid, "a", HOFFSET(stype1, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "b", HOFFSET(stype1, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "c", HOFFSET(stype1, c), array_dt1) < 0 || + H5Tinsert(tid, "d", HOFFSET(stype1, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "e", HOFFSET(stype1, e), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "f", HOFFSET(stype1, f), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "g", HOFFSET(stype1, g), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "h", HOFFSET(stype1, h), array_dt2) < 0 || + H5Tinsert(tid, "i", HOFFSET(stype1, i), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "j", HOFFSET(stype1, j), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "k", HOFFSET(stype1, k), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "l", HOFFSET(stype1, l), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "m", HOFFSET(stype1, m), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "n", HOFFSET(stype1, n), H5T_NATIVE_DOUBLE) < 0) goto error; - if(H5Tclose(array_dt1) < 0) + if (H5Tclose(array_dt1) < 0) goto error; - if(H5Tclose(array_dt2) < 0) + if (H5Tclose(array_dt2) < 0) goto error; return tid; @@ -1117,7 +1034,6 @@ error: return FAIL; } - /*------------------------------------------------------------------------- * Function: create_stype2 * @@ -1136,38 +1052,38 @@ error: static hid_t create_stype2(void) { - hid_t array_dt1, array_dt2, tid; - const hsize_t eight = 8, sixteen = 16; + hid_t array_dt1, array_dt2, tid; + const hsize_t eight = 8, sixteen = 16; /* Build hdf5 datatypes */ - if((array_dt1 = H5Tarray_create2(H5T_NATIVE_INT,1, &eight)) < 0) + if ((array_dt1 = H5Tarray_create2(H5T_NATIVE_INT, 1, &eight)) < 0) goto error; - if((array_dt2 = H5Tarray_create2(H5T_NATIVE_FLOAT,1, &sixteen)) < 0) + if ((array_dt2 = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &sixteen)) < 0) goto error; - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(stype2))) < 0 || - H5Tinsert(tid, "a", HOFFSET(stype2, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "b", HOFFSET(stype2, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "c", HOFFSET(stype2, c), array_dt1) < 0 || - H5Tinsert(tid, "d", HOFFSET(stype2, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "e", HOFFSET(stype2, e), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "f", HOFFSET(stype2, f), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "g", HOFFSET(stype2, g), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "h", HOFFSET(stype2, h), array_dt2) < 0 || - H5Tinsert(tid, "i", HOFFSET(stype2, i), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "j", HOFFSET(stype2, j), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "k", HOFFSET(stype2, k), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "l", HOFFSET(stype2, l), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "m", HOFFSET(stype2, m), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "n", HOFFSET(stype2, n), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "o", HOFFSET(stype2, o), H5T_NATIVE_LONG) < 0 || - H5Tinsert(tid, "p", HOFFSET(stype2, p), H5T_NATIVE_LONG) < 0 || - H5Tinsert(tid, "q", HOFFSET(stype2, q), H5T_NATIVE_LONG) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(stype2))) < 0 || + H5Tinsert(tid, "a", HOFFSET(stype2, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "b", HOFFSET(stype2, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "c", HOFFSET(stype2, c), array_dt1) < 0 || + H5Tinsert(tid, "d", HOFFSET(stype2, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "e", HOFFSET(stype2, e), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "f", HOFFSET(stype2, f), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "g", HOFFSET(stype2, g), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "h", HOFFSET(stype2, h), array_dt2) < 0 || + H5Tinsert(tid, "i", HOFFSET(stype2, i), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "j", HOFFSET(stype2, j), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "k", HOFFSET(stype2, k), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "l", HOFFSET(stype2, l), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "m", HOFFSET(stype2, m), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "n", HOFFSET(stype2, n), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "o", HOFFSET(stype2, o), H5T_NATIVE_LONG) < 0 || + H5Tinsert(tid, "p", HOFFSET(stype2, p), H5T_NATIVE_LONG) < 0 || + H5Tinsert(tid, "q", HOFFSET(stype2, q), H5T_NATIVE_LONG) < 0) goto error; - if(H5Tclose(array_dt1) < 0) + if (H5Tclose(array_dt1) < 0) goto error; - if(H5Tclose(array_dt2) < 0) + if (H5Tclose(array_dt2) < 0) goto error; return tid; @@ -1176,7 +1092,6 @@ error: return FAIL; } - /*------------------------------------------------------------------------- * Function: create_stype3 * @@ -1195,22 +1110,22 @@ error: static hid_t create_stype3(void) { - hid_t array_dt1, tid; - const hsize_t eight = 8; + hid_t array_dt1, tid; + const hsize_t eight = 8; /* Build hdf5 datatypes */ - if((array_dt1 = H5Tarray_create2(H5T_NATIVE_INT,1, &eight)) < 0) + if ((array_dt1 = H5Tarray_create2(H5T_NATIVE_INT, 1, &eight)) < 0) goto error; - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(stype3))) < 0 || - H5Tinsert(tid, "a", HOFFSET(stype3, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "b", HOFFSET(stype3, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "c", HOFFSET(stype3, c), array_dt1) < 0 || - H5Tinsert(tid, "d", HOFFSET(stype3, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "e", HOFFSET(stype3, e), H5T_NATIVE_INT) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(stype3))) < 0 || + H5Tinsert(tid, "a", HOFFSET(stype3, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "b", HOFFSET(stype3, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "c", HOFFSET(stype3, c), array_dt1) < 0 || + H5Tinsert(tid, "d", HOFFSET(stype3, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "e", HOFFSET(stype3, e), H5T_NATIVE_INT) < 0) goto error; - if(H5Tclose(array_dt1) < 0) + if (H5Tclose(array_dt1) < 0) goto error; return tid; @@ -1219,7 +1134,6 @@ error: return FAIL; } - /*------------------------------------------------------------------------- * Function: create_stype4 * @@ -1238,41 +1152,41 @@ error: static hid_t create_stype4(void) { - hid_t array_dt1, array_dt2, tid; - const hsize_t eight = 8, sixteen = 16; + hid_t array_dt1, array_dt2, tid; + const hsize_t eight = 8, sixteen = 16; /* Build hdf5 datatypes */ - if((array_dt1 = H5Tarray_create2(H5T_NATIVE_INT,1, &eight)) < 0) + if ((array_dt1 = H5Tarray_create2(H5T_NATIVE_INT, 1, &eight)) < 0) goto error; - if((array_dt2 = H5Tarray_create2(H5T_NATIVE_FLOAT,1, &sixteen)) < 0) + if ((array_dt2 = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &sixteen)) < 0) goto error; - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(stype4))) < 0 || - H5Tinsert(tid, "a", HOFFSET(stype4, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "b", HOFFSET(stype4, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "c", HOFFSET(stype4, c), array_dt1) < 0 || - H5Tinsert(tid, "d", HOFFSET(stype4, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "e", HOFFSET(stype4, e), H5T_NATIVE_INT) < 0 || - H5Tinsert(tid, "f", HOFFSET(stype4, f), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "g", HOFFSET(stype4, g), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "h", HOFFSET(stype4, h), array_dt2) < 0 || - H5Tinsert(tid, "i", HOFFSET(stype4, i), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "j", HOFFSET(stype4, j), H5T_NATIVE_FLOAT) < 0 || - H5Tinsert(tid, "k", HOFFSET(stype4, k), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "l", HOFFSET(stype4, l), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "m", HOFFSET(stype4, m), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "n", HOFFSET(stype4, n), H5T_NATIVE_DOUBLE) < 0 || - H5Tinsert(tid, "o", HOFFSET(stype4, o), H5T_NATIVE_LONG) < 0 || - H5Tinsert(tid, "p", HOFFSET(stype4, p), H5T_NATIVE_LONG) < 0 || - H5Tinsert(tid, "q", HOFFSET(stype4, q), H5T_NATIVE_LONG) < 0 || - H5Tinsert(tid, "r", HOFFSET(stype4, r), H5T_NATIVE_LLONG) < 0 || - H5Tinsert(tid, "s", HOFFSET(stype4, s), H5T_NATIVE_LLONG) < 0 || - H5Tinsert(tid, "t", HOFFSET(stype4, t), H5T_NATIVE_LLONG) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(stype4))) < 0 || + H5Tinsert(tid, "a", HOFFSET(stype4, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "b", HOFFSET(stype4, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "c", HOFFSET(stype4, c), array_dt1) < 0 || + H5Tinsert(tid, "d", HOFFSET(stype4, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "e", HOFFSET(stype4, e), H5T_NATIVE_INT) < 0 || + H5Tinsert(tid, "f", HOFFSET(stype4, f), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "g", HOFFSET(stype4, g), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "h", HOFFSET(stype4, h), array_dt2) < 0 || + H5Tinsert(tid, "i", HOFFSET(stype4, i), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "j", HOFFSET(stype4, j), H5T_NATIVE_FLOAT) < 0 || + H5Tinsert(tid, "k", HOFFSET(stype4, k), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "l", HOFFSET(stype4, l), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "m", HOFFSET(stype4, m), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "n", HOFFSET(stype4, n), H5T_NATIVE_DOUBLE) < 0 || + H5Tinsert(tid, "o", HOFFSET(stype4, o), H5T_NATIVE_LONG) < 0 || + H5Tinsert(tid, "p", HOFFSET(stype4, p), H5T_NATIVE_LONG) < 0 || + H5Tinsert(tid, "q", HOFFSET(stype4, q), H5T_NATIVE_LONG) < 0 || + H5Tinsert(tid, "r", HOFFSET(stype4, r), H5T_NATIVE_LLONG) < 0 || + H5Tinsert(tid, "s", HOFFSET(stype4, s), H5T_NATIVE_LLONG) < 0 || + H5Tinsert(tid, "t", HOFFSET(stype4, t), H5T_NATIVE_LLONG) < 0) goto error; - if(H5Tclose(array_dt1) < 0) + if (H5Tclose(array_dt1) < 0) goto error; - if(H5Tclose(array_dt2) < 0) + if (H5Tclose(array_dt2) < 0) goto error; return tid; @@ -1281,7 +1195,6 @@ error: return FAIL; } - /*------------------------------------------------------------------------- * Function: compare_data * @@ -1300,57 +1213,53 @@ error: static int compare_data(void *src_data, void *dst_data, hbool_t src_subset) { - stype1 *s_ptr; - stype2 *d_ptr; + stype1 *s_ptr; + stype2 *d_ptr; int i; - for(i = 0; i < (int)(NX * NY); i++) { - if(src_subset) { - s_ptr = ((stype1 *)src_data) + i; - d_ptr = ((stype2 *)dst_data) + i; - } else { - s_ptr = (stype1 *)(((stype2 *)src_data) + i); - d_ptr = (stype2 *)(((stype1 *)dst_data) + i); + for (i = 0; i < (int)(NX * NY); i++) { + if (src_subset) { + s_ptr = ((stype1 *)src_data) + i; + d_ptr = ((stype2 *)dst_data) + i; + } + else { + s_ptr = (stype1 *)(((stype2 *)src_data) + i); + d_ptr = (stype2 *)(((stype1 *)dst_data) + i); } - if (s_ptr->a != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e || - !H5_FLT_ABS_EQUAL(s_ptr->f, d_ptr->f) || - !H5_FLT_ABS_EQUAL(s_ptr->g, d_ptr->g) || - !H5_FLT_ABS_EQUAL(s_ptr->h[0], d_ptr->h[0]) || - !H5_FLT_ABS_EQUAL(s_ptr->h[1], d_ptr->h[1]) || - !H5_FLT_ABS_EQUAL(s_ptr->i, d_ptr->i) || - !H5_FLT_ABS_EQUAL(s_ptr->j, d_ptr->j) || - !H5_DBL_ABS_EQUAL(s_ptr->k, d_ptr->k) || - !H5_DBL_ABS_EQUAL(s_ptr->l, d_ptr->l) || - !H5_DBL_ABS_EQUAL(s_ptr->m, d_ptr->m) || - !H5_DBL_ABS_EQUAL(s_ptr->n, d_ptr->n) ) { - - H5_FAILED(); - HDprintf(" i=%d\n", i); - HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d,%d,%d,%d,%d], d=%d, e=%d, f=%f, g=%f, h=[%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f], i=%f, j=%f, k=%f, l=%f, m=%f, n=%f}\n", - s_ptr->a, s_ptr->b, s_ptr->c[0], s_ptr->c[1], s_ptr->c[2], - s_ptr->c[3], s_ptr->c[4], s_ptr->c[5], s_ptr->c[6], s_ptr->c[7], - s_ptr->d, s_ptr->e, (double)s_ptr->f, (double)s_ptr->g,(double)s_ptr->h[0],(double)s_ptr->h[1],(double)s_ptr->h[2], - (double)s_ptr->h[3],(double)s_ptr->h[4],(double)s_ptr->h[5],(double)s_ptr->h[6],(double)s_ptr->h[7],(double)s_ptr->h[8], - (double)s_ptr->h[9],(double)s_ptr->h[10],(double)s_ptr->h[11],(double)s_ptr->h[12],(double)s_ptr->h[13],(double)s_ptr->h[14], - (double)s_ptr->h[15], (double)s_ptr->i,(double)s_ptr->j,s_ptr->k,s_ptr->l,s_ptr->m,s_ptr->n); - HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d,%d,%d,%d,%d], d=%d, e=%d, f=%f, g=%f, h=[%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f], i=%f, j=%f, k=%f, l=%f, m=%f, n=%f}\n", - d_ptr->a, d_ptr->b, d_ptr->c[0], d_ptr->c[1], d_ptr->c[2], - d_ptr->c[3], d_ptr->c[4], d_ptr->c[5], d_ptr->c[6], d_ptr->c[7], - d_ptr->d, d_ptr->e, (double)d_ptr->f, (double)d_ptr->g,(double)d_ptr->h[0],(double)d_ptr->h[1],(double)d_ptr->h[2], - (double)d_ptr->h[3],(double)d_ptr->h[4],(double)d_ptr->h[5],(double)d_ptr->h[6],(double)d_ptr->h[7],(double)d_ptr->h[8], - (double)d_ptr->h[9],(double)d_ptr->h[10],(double)d_ptr->h[11],(double)d_ptr->h[12],(double)d_ptr->h[13], - (double)d_ptr->h[14],(double)d_ptr->h[15],(double)d_ptr->i,(double)d_ptr->j,d_ptr->k,d_ptr->l, - d_ptr->m,d_ptr->n); - goto error; - } + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e || !H5_FLT_ABS_EQUAL(s_ptr->f, d_ptr->f) || + !H5_FLT_ABS_EQUAL(s_ptr->g, d_ptr->g) || !H5_FLT_ABS_EQUAL(s_ptr->h[0], d_ptr->h[0]) || + !H5_FLT_ABS_EQUAL(s_ptr->h[1], d_ptr->h[1]) || !H5_FLT_ABS_EQUAL(s_ptr->i, d_ptr->i) || + !H5_FLT_ABS_EQUAL(s_ptr->j, d_ptr->j) || !H5_DBL_ABS_EQUAL(s_ptr->k, d_ptr->k) || + !H5_DBL_ABS_EQUAL(s_ptr->l, d_ptr->l) || !H5_DBL_ABS_EQUAL(s_ptr->m, d_ptr->m) || + !H5_DBL_ABS_EQUAL(s_ptr->n, d_ptr->n)) { + + H5_FAILED(); + HDprintf(" i=%d\n", i); + HDprintf( + " src={a=%d, b=%d, c=[%d,%d,%d,%d,%d,%d,%d,%d], d=%d, e=%d, f=%f, g=%f, " + "h=[%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f], i=%f, j=%f, k=%f, l=%f, m=%f, n=%f}\n", + s_ptr->a, s_ptr->b, s_ptr->c[0], s_ptr->c[1], s_ptr->c[2], s_ptr->c[3], s_ptr->c[4], + s_ptr->c[5], s_ptr->c[6], s_ptr->c[7], s_ptr->d, s_ptr->e, (double)s_ptr->f, (double)s_ptr->g, + (double)s_ptr->h[0], (double)s_ptr->h[1], (double)s_ptr->h[2], (double)s_ptr->h[3], + (double)s_ptr->h[4], (double)s_ptr->h[5], (double)s_ptr->h[6], (double)s_ptr->h[7], + (double)s_ptr->h[8], (double)s_ptr->h[9], (double)s_ptr->h[10], (double)s_ptr->h[11], + (double)s_ptr->h[12], (double)s_ptr->h[13], (double)s_ptr->h[14], (double)s_ptr->h[15], + (double)s_ptr->i, (double)s_ptr->j, s_ptr->k, s_ptr->l, s_ptr->m, s_ptr->n); + HDprintf( + " dst={a=%d, b=%d, c=[%d,%d,%d,%d,%d,%d,%d,%d], d=%d, e=%d, f=%f, g=%f, " + "h=[%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f], i=%f, j=%f, k=%f, l=%f, m=%f, n=%f}\n", + d_ptr->a, d_ptr->b, d_ptr->c[0], d_ptr->c[1], d_ptr->c[2], d_ptr->c[3], d_ptr->c[4], + d_ptr->c[5], d_ptr->c[6], d_ptr->c[7], d_ptr->d, d_ptr->e, (double)d_ptr->f, (double)d_ptr->g, + (double)d_ptr->h[0], (double)d_ptr->h[1], (double)d_ptr->h[2], (double)d_ptr->h[3], + (double)d_ptr->h[4], (double)d_ptr->h[5], (double)d_ptr->h[6], (double)d_ptr->h[7], + (double)d_ptr->h[8], (double)d_ptr->h[9], (double)d_ptr->h[10], (double)d_ptr->h[11], + (double)d_ptr->h[12], (double)d_ptr->h[13], (double)d_ptr->h[14], (double)d_ptr->h[15], + (double)d_ptr->i, (double)d_ptr->j, d_ptr->k, d_ptr->l, d_ptr->m, d_ptr->n); + goto error; + } } return SUCCEED; @@ -1359,7 +1268,6 @@ error: return FAIL; } - /*------------------------------------------------------------------------- * Function: test_hdf5_src_subset * @@ -1388,45 +1296,44 @@ error: static unsigned test_hdf5_src_subset(char *filename, hid_t fapl) { - hid_t file; - hid_t rew_tid, src_tid, dst_tid; - hid_t dataset; - hid_t space; - hid_t dcpl, dxpl; - hsize_t dims[2] = {NX, NY}; - hsize_t chunk_dims[2] = {NX/10, NY/10}; - unsigned char *orig=NULL, *rew_buf=NULL, *rbuf=NULL; + hid_t file; + hid_t rew_tid, src_tid, dst_tid; + hid_t dataset; + hid_t space; + hid_t dcpl, dxpl; + hsize_t dims[2] = {NX, NY}; + hsize_t chunk_dims[2] = {NX / 10, NY / 10}; + unsigned char *orig = NULL, *rew_buf = NULL, *rbuf = NULL; /* Create the file for this test */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; /* Build hdf5 datatypes */ - if ((src_tid=create_stype1()) < 0) + if ((src_tid = create_stype1()) < 0) goto error; - if ((dst_tid=create_stype2()) < 0) + if ((dst_tid = create_stype2()) < 0) goto error; - if ((rew_tid=create_stype3()) < 0) + if ((rew_tid = create_stype3()) < 0) goto error; /* Create the data space */ - if((space = H5Screate_simple(2, dims, NULL)) < 0) - goto error; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; /* Allocate space and initialize data */ - orig = (unsigned char*)HDmalloc(NX * NY * sizeof(stype1)); - initialize_stype1(orig, (size_t)NX*NY); - - rbuf = (unsigned char*)HDmalloc(NX * NY * sizeof(stype2)); + orig = (unsigned char *)HDmalloc(NX * NY * sizeof(stype1)); + initialize_stype1(orig, (size_t)NX * NY); - rew_buf = (unsigned char*)HDmalloc(NX * NY * sizeof(stype3)); - initialize_stype3(rew_buf, (size_t)NX*NY); + rbuf = (unsigned char *)HDmalloc(NX * NY * sizeof(stype2)); + rew_buf = (unsigned char *)HDmalloc(NX * NY * sizeof(stype3)); + initialize_stype3(rew_buf, (size_t)NX * NY); /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* @@ -1436,29 +1343,29 @@ test_hdf5_src_subset(char *filename, hid_t fapl) TESTING("writing data to contiguous and chunked datasets"); /* Create contiguous data set */ - if((dataset = H5Dcreate2(file, DSET_NAME[0], src_tid, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_NAME[0], src_tid, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, src_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig) < 0) - goto error; + if (H5Dwrite(dataset, src_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig) < 0) + goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; /* Set chunking */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) goto error; /* Create chunked data set */ - if((dataset = H5Dcreate2(file, DSET_NAME[1], src_tid, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_NAME[1], src_tid, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, src_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig) < 0) - goto error; + if (H5Dwrite(dataset, src_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig) < 0) + goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; PASSED(); @@ -1470,32 +1377,32 @@ test_hdf5_src_subset(char *filename, hid_t fapl) TESTING("rewriting data with a subset of original data type"); /* Create xfer properties to preserve initialized data */ - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - FAIL_STACK_ERROR + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + FAIL_STACK_ERROR - if(H5Pset_preserve(dxpl, TRUE) < 0) - FAIL_STACK_ERROR + if (H5Pset_preserve(dxpl, TRUE) < 0) + FAIL_STACK_ERROR /* Rewrite contiguous data set */ - if((dataset = H5Dopen2(file, DSET_NAME[0], H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_NAME[0], H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write the data to the dataset */ - if(H5Dwrite(dataset, rew_tid, H5S_ALL, H5S_ALL, dxpl, rew_buf) < 0) - FAIL_STACK_ERROR + if (H5Dwrite(dataset, rew_tid, H5S_ALL, H5S_ALL, dxpl, rew_buf) < 0) + FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR /* Rewrite chunked data set */ - if((dataset = H5Dopen2(file, DSET_NAME[1], H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_NAME[1], H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write the data to the dataset */ - if(H5Dwrite(dataset, rew_tid, H5S_ALL, H5S_ALL, dxpl, rew_buf) < 0) - FAIL_STACK_ERROR + if (H5Dwrite(dataset, rew_tid, H5S_ALL, H5S_ALL, dxpl, rew_buf) < 0) + FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR PASSED(); @@ -1507,48 +1414,48 @@ test_hdf5_src_subset(char *filename, hid_t fapl) TESTING("reading data with a subset of original data type"); /* Check contiguous data set */ - if((dataset = H5Dopen2(file, DSET_NAME[0], H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_NAME[0], H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0) + if (H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0) FAIL_STACK_ERROR - if(compare_data(orig, rbuf, TRUE) < 0) + if (compare_data(orig, rbuf, TRUE) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR /* Check chunked data set */ - if((dataset = H5Dopen2(file, DSET_NAME[1], H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_NAME[1], H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0) + if (H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0) FAIL_STACK_ERROR - if(compare_data(orig, rbuf, TRUE) < 0) + if (compare_data(orig, rbuf, TRUE) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR /* Finishing test and release resources */ - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(dxpl) < 0) + if (H5Pclose(dxpl) < 0) FAIL_STACK_ERROR - if(H5Tclose(src_tid) < 0) + if (H5Tclose(src_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(dst_tid) < 0) + if (H5Tclose(dst_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(rew_tid) < 0) + if (H5Tclose(rew_tid) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR HDfree(orig); @@ -1563,7 +1470,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_hdf5_dst_subset * @@ -1593,44 +1499,44 @@ error: static unsigned test_hdf5_dst_subset(char *filename, hid_t fapl) { - hid_t file; - hid_t rew_tid, src_tid, dst_tid; - hid_t dataset; - hid_t space; - hid_t dcpl, dxpl; - hsize_t dims[2] = {NX, NY}; - hsize_t chunk_dims[2] = {NX/10, NY/10}; - unsigned char *orig=NULL, *rew_buf=NULL, *rbuf=NULL; + hid_t file; + hid_t rew_tid, src_tid, dst_tid; + hid_t dataset; + hid_t space; + hid_t dcpl, dxpl; + hsize_t dims[2] = {NX, NY}; + hsize_t chunk_dims[2] = {NX / 10, NY / 10}; + unsigned char *orig = NULL, *rew_buf = NULL, *rbuf = NULL; /* Create the file for this test */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; /* Build hdf5 datatypes */ - if ((src_tid=create_stype2()) < 0) + if ((src_tid = create_stype2()) < 0) goto error; - if ((dst_tid=create_stype1()) < 0) + if ((dst_tid = create_stype1()) < 0) goto error; - if ((rew_tid=create_stype4()) < 0) + if ((rew_tid = create_stype4()) < 0) goto error; /* Create the data space */ - if((space = H5Screate_simple(2, dims, NULL)) < 0) - goto error; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; /* Allocate space and initialize data */ - orig = (unsigned char*)HDmalloc(NX * NY * sizeof(stype2)); - initialize_stype2(orig, (size_t)NX*NY); + orig = (unsigned char *)HDmalloc(NX * NY * sizeof(stype2)); + initialize_stype2(orig, (size_t)NX * NY); - rbuf = (unsigned char*)HDmalloc(NX * NY * sizeof(stype1)); + rbuf = (unsigned char *)HDmalloc(NX * NY * sizeof(stype1)); - rew_buf = (unsigned char*)HDmalloc(NX * NY * sizeof(stype4)); - initialize_stype4(rew_buf, (size_t)NX*NY); + rew_buf = (unsigned char *)HDmalloc(NX * NY * sizeof(stype4)); + initialize_stype4(rew_buf, (size_t)NX * NY); /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* @@ -1640,29 +1546,29 @@ test_hdf5_dst_subset(char *filename, hid_t fapl) TESTING("writing data to contiguous and chunked datasets"); /* Create contiguous data set */ - if((dataset = H5Dcreate2(file, DSET_NAME[2], src_tid, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_NAME[2], src_tid, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, src_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig) < 0) - goto error; + if (H5Dwrite(dataset, src_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig) < 0) + goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; /* Set chunking */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) goto error; /* Create chunked data set */ - if((dataset = H5Dcreate2(file, DSET_NAME[3], src_tid, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_NAME[3], src_tid, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, src_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig) < 0) - goto error; + if (H5Dwrite(dataset, src_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig) < 0) + goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; PASSED(); @@ -1674,32 +1580,32 @@ test_hdf5_dst_subset(char *filename, hid_t fapl) TESTING("rewriting data with a subset of original data type"); /* Create xfer properties to preserve initialized data */ - if((dxpl = H5Pcreate (H5P_DATASET_XFER)) < 0) - goto error; + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; - if(H5Pset_preserve(dxpl, TRUE) < 0) - goto error; + if (H5Pset_preserve(dxpl, TRUE) < 0) + goto error; /* Rewrite contiguous data set */ - if((dataset = H5Dopen2(file, DSET_NAME[2], H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_NAME[2], H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, rew_tid, H5S_ALL, H5S_ALL, dxpl, rew_buf) < 0) - goto error; + if (H5Dwrite(dataset, rew_tid, H5S_ALL, H5S_ALL, dxpl, rew_buf) < 0) + goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; /* Rewrite chunked data set */ - if((dataset = H5Dopen2(file, DSET_NAME[3], H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_NAME[3], H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, rew_tid, H5S_ALL, H5S_ALL, dxpl, rew_buf) < 0) - goto error; + if (H5Dwrite(dataset, rew_tid, H5S_ALL, H5S_ALL, dxpl, rew_buf) < 0) + goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; PASSED(); @@ -1711,48 +1617,48 @@ test_hdf5_dst_subset(char *filename, hid_t fapl) TESTING("reading data with a subset of original data type"); /* Check contiguous data set */ - if((dataset = H5Dopen2(file, DSET_NAME[2], H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_NAME[2], H5P_DEFAULT)) < 0) goto error; - if(H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0) + if (H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0) goto error; - if(compare_data(orig, rbuf, FALSE) < 0) + if (compare_data(orig, rbuf, FALSE) < 0) goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; /* Check chunked data set */ - if((dataset = H5Dopen2(file, DSET_NAME[3], H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_NAME[3], H5P_DEFAULT)) < 0) goto error; - if(H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0) + if (H5Dread(dataset, dst_tid, H5S_ALL, H5S_ALL, dxpl, rbuf) < 0) goto error; - if(compare_data(orig, rbuf, FALSE) < 0) + if (compare_data(orig, rbuf, FALSE) < 0) goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; /* Finishing test and release resources */ - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Pclose(dxpl) < 0) + if (H5Pclose(dxpl) < 0) goto error; - if(H5Tclose(src_tid) < 0) + if (H5Tclose(src_tid) < 0) goto error; - if(H5Tclose(dst_tid) < 0) + if (H5Tclose(dst_tid) < 0) goto error; - if(H5Tclose(rew_tid) < 0) + if (H5Tclose(rew_tid) < 0) goto error; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; HDfree(orig); @@ -1769,18 +1675,18 @@ error: /* Error macro that outputs the state of the randomly generated variables so the * failure can be reproduced */ -#define PACK_OOO_ERROR \ -{ \ - int _i; \ - H5_FAILED(); AT(); \ - HDprintf(" Insertion order ="); \ - for(_i=0; _ishared->u.compnd.packed) PACK_OOO_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(cmpd, H5I_DATATYPE))) + PACK_OOO_ERROR + if (dt->shared->u.compnd.packed) + PACK_OOO_ERROR /* Close the main compound */ - if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR + if (H5Tclose(cmpd) < 0) + PACK_OOO_ERROR PASSED(); TESTING("random member insertion with full compound subtype"); /* Complete the inner compound type */ - if(H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR + if (H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) + PACK_OOO_ERROR /* Recreate main compound type */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR + if ((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) + PACK_OOO_ERROR /* Insert the compound members in the random order previously generated */ - for(i=0; ishared->u.compnd.packed != !extra_space) PACK_OOO_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(cmpd, H5I_DATATYPE))) + PACK_OOO_ERROR + if (dt->shared->u.compnd.packed != !extra_space) + PACK_OOO_ERROR /* Close */ - if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR - if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR + if (H5Tclose(cmpd) < 0) + PACK_OOO_ERROR + if (H5Tclose(sub_cmpd) < 0) + PACK_OOO_ERROR PASSED(); TESTING("reverse member insertion with empty compound subtype"); /* Create inner compound type. It will be empty for the first run */ - if((sub_cmpd = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) PACK_OOO_ERROR + if ((sub_cmpd = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) + PACK_OOO_ERROR /* Create main compound type, with extra space at the end */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR + if ((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) + PACK_OOO_ERROR /* Insert the compound members in reverse order, with compound last */ - for(i=0; ishared->u.compnd.packed) PACK_OOO_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(cmpd, H5I_DATATYPE))) + PACK_OOO_ERROR + if (dt->shared->u.compnd.packed) + PACK_OOO_ERROR /* Close the main compound */ - if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR + if (H5Tclose(cmpd) < 0) + PACK_OOO_ERROR PASSED(); TESTING("reverse member insertion with full compound subtype"); /* Complete the inner compound type */ - if(H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR + if (H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) + PACK_OOO_ERROR /* Recreate main compound type */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR + if ((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) + PACK_OOO_ERROR /* Insert the compound members in reverse order, with compound last */ - for(i=0; ishared->u.compnd.packed != !extra_space) PACK_OOO_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(cmpd, H5I_DATATYPE))) + PACK_OOO_ERROR + if (dt->shared->u.compnd.packed != !extra_space) + PACK_OOO_ERROR /* Close */ - if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR - if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR + if (H5Tclose(cmpd) < 0) + PACK_OOO_ERROR + if (H5Tclose(sub_cmpd) < 0) + PACK_OOO_ERROR PASSED(); TESTING("forward member insertion with empty compound subtype"); /* Create inner compound type. It will be empty for the first run */ - if((sub_cmpd = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) PACK_OOO_ERROR + if ((sub_cmpd = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) + PACK_OOO_ERROR /* Create main compound type, with extra space at the end */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR + if ((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) + PACK_OOO_ERROR /* Insert the compound members in forward order, with compound first */ - for(i=0; ishared->u.compnd.packed) PACK_OOO_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(cmpd, H5I_DATATYPE))) + PACK_OOO_ERROR + if (dt->shared->u.compnd.packed) + PACK_OOO_ERROR /* Close the main compound */ - if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR + if (H5Tclose(cmpd) < 0) + PACK_OOO_ERROR PASSED(); TESTING("forward member insertion with full compound subtype"); /* Complete the inner compound type */ - if(H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR + if (H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) + PACK_OOO_ERROR /* Recreate main compound type */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR + if ((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) + PACK_OOO_ERROR /* Insert the compound members in forward order */ - for(i=0; ishared->u.compnd.packed != !extra_space) PACK_OOO_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(cmpd, H5I_DATATYPE))) + PACK_OOO_ERROR + if (dt->shared->u.compnd.packed != !extra_space) + PACK_OOO_ERROR /* Close */ - if(H5Tclose(cmpd) < 0) PACK_OOO_ERROR - if(H5Tclose(sub_cmpd) < 0) PACK_OOO_ERROR + if (H5Tclose(cmpd) < 0) + PACK_OOO_ERROR + if (H5Tclose(sub_cmpd) < 0) + PACK_OOO_ERROR PASSED(); } /* end for */ @@ -2007,11 +1958,10 @@ test_pack_ooo(void) return 0; error: -HDputs("*** DATASET TESTS FAILED ***"); + HDputs("*** DATASET TESTS FAILED ***"); return 1; } - /*------------------------------------------------------------------------- * Function: test_ooo_order * @@ -2034,160 +1984,228 @@ HDputs("*** DATASET TESTS FAILED ***"); static unsigned test_ooo_order(char *filename, hid_t fapl_id) { - hid_t file = -1; /* File ID */ - hid_t dtype = -1; /* Datatype IDs */ - hid_t dtype_tmp = -1; /* Temp Datatype ID */ - H5T_t *dt = NULL; /* Datatype pointer */ + hid_t file = -1; /* File ID */ + hid_t dtype = -1; /* Datatype IDs */ + hid_t dtype_tmp = -1; /* Temp Datatype ID */ + H5T_t *dt = NULL; /* Datatype pointer */ TESTING("that compound member insertion order is preserved") /* Create the file */ - if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR /* Create the compound */ - if((dtype = H5Tcreate(H5T_COMPOUND, (size_t)20)) < 0) TEST_ERROR - if(H5Tinsert(dtype, "A", (size_t)8, H5T_STD_I32LE) < 0) TEST_ERROR - if(H5Tinsert(dtype, "B", (size_t)12, H5T_STD_I32LE) < 0) TEST_ERROR - if(H5Tinsert(dtype, "C", (size_t)0, H5T_STD_I32LE) < 0) TEST_ERROR - if(H5Tinsert(dtype, "D", (size_t)16, H5T_STD_I32LE) < 0) TEST_ERROR + if ((dtype = H5Tcreate(H5T_COMPOUND, (size_t)20)) < 0) + TEST_ERROR + if (H5Tinsert(dtype, "A", (size_t)8, H5T_STD_I32LE) < 0) + TEST_ERROR + if (H5Tinsert(dtype, "B", (size_t)12, H5T_STD_I32LE) < 0) + TEST_ERROR + if (H5Tinsert(dtype, "C", (size_t)0, H5T_STD_I32LE) < 0) + TEST_ERROR + if (H5Tinsert(dtype, "D", (size_t)16, H5T_STD_I32LE) < 0) + TEST_ERROR /* Verify that the compound is not packed */ - if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype, H5I_DATATYPE))) + TEST_ERROR + if (dt->shared->u.compnd.packed) TEST_ERROR - if(dt->shared->u.compnd.packed) TEST_ERROR /* Verify that the order is the same as the insertion order */ - if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR - if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR - if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR - if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR + if (H5Tget_member_offset(dtype, 0) != 8) + TEST_ERROR + if (H5Tget_member_offset(dtype, 1) != 12) + TEST_ERROR + if (H5Tget_member_offset(dtype, 2) != 0) + TEST_ERROR + if (H5Tget_member_offset(dtype, 3) != 16) + TEST_ERROR /* Commit the datatype */ - if(H5Tcommit2(file, "dtype", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(file, "dtype", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close and reopen the file */ - if(H5Tclose(dtype)) TEST_ERROR - if(H5Fclose(file)) TEST_ERROR - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR + if (H5Tclose(dtype)) + TEST_ERROR + if (H5Fclose(file)) + TEST_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + TEST_ERROR /* Open the type */ - if((dtype_tmp = H5Topen2(file, "dtype", H5P_DEFAULT)) < 0) TEST_ERROR + if ((dtype_tmp = H5Topen2(file, "dtype", H5P_DEFAULT)) < 0) + TEST_ERROR /* Verify that the compound is not packed */ - if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype_tmp, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype_tmp, H5I_DATATYPE))) + TEST_ERROR + if (dt->shared->u.compnd.packed) TEST_ERROR - if(dt->shared->u.compnd.packed) TEST_ERROR /* Verify that the order is the same as the insertion order */ - if(H5Tget_member_offset(dtype_tmp, 0) != 8) TEST_ERROR - if(H5Tget_member_offset(dtype_tmp, 1) != 12) TEST_ERROR - if(H5Tget_member_offset(dtype_tmp, 2) != 0) TEST_ERROR - if(H5Tget_member_offset(dtype_tmp, 3) != 16) TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 0) != 8) + TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 1) != 12) + TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 2) != 0) + TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 3) != 16) + TEST_ERROR /* Copy the datatype */ - if((dtype = H5Tcopy(dtype_tmp)) < 0) TEST_ERROR + if ((dtype = H5Tcopy(dtype_tmp)) < 0) + TEST_ERROR /* Verify that the compound is not packed */ - if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype, H5I_DATATYPE))) + TEST_ERROR + if (dt->shared->u.compnd.packed) TEST_ERROR - if(dt->shared->u.compnd.packed) TEST_ERROR /* Verify that the order is the same as the insertion order */ - if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR - if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR - if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR - if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR + if (H5Tget_member_offset(dtype, 0) != 8) + TEST_ERROR + if (H5Tget_member_offset(dtype, 1) != 12) + TEST_ERROR + if (H5Tget_member_offset(dtype, 2) != 0) + TEST_ERROR + if (H5Tget_member_offset(dtype, 3) != 16) + TEST_ERROR /* Insert the last member */ - if(H5Tinsert(dtype, "E", (size_t)4, H5T_STD_I32LE) < 0) TEST_ERROR + if (H5Tinsert(dtype, "E", (size_t)4, H5T_STD_I32LE) < 0) + TEST_ERROR /* Verify that the compound is packed */ - if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype, H5I_DATATYPE))) + TEST_ERROR + if (!dt->shared->u.compnd.packed) TEST_ERROR - if(!dt->shared->u.compnd.packed) TEST_ERROR /* Verify that the order is the same as the insertion order */ - if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR - if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR - if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR - if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR - if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR + if (H5Tget_member_offset(dtype, 0) != 8) + TEST_ERROR + if (H5Tget_member_offset(dtype, 1) != 12) + TEST_ERROR + if (H5Tget_member_offset(dtype, 2) != 0) + TEST_ERROR + if (H5Tget_member_offset(dtype, 3) != 16) + TEST_ERROR + if (H5Tget_member_offset(dtype, 4) != 4) + TEST_ERROR /* Commit the modified datatype */ - if(H5Tcommit2(file, "dtype2", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(file, "dtype2", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close and reopen the file */ - if(H5Tclose(dtype_tmp)) TEST_ERROR - if(H5Tclose(dtype)) TEST_ERROR - if(H5Fclose(file)) TEST_ERROR - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id)) < 0) TEST_ERROR + if (H5Tclose(dtype_tmp)) + TEST_ERROR + if (H5Tclose(dtype)) + TEST_ERROR + if (H5Fclose(file)) + TEST_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id)) < 0) + TEST_ERROR /* Open the type, and verify status */ - if((dtype_tmp = H5Topen2(file, "dtype2", H5P_DEFAULT)) < 0) TEST_ERROR - if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype_tmp, H5I_DATATYPE))) + if ((dtype_tmp = H5Topen2(file, "dtype2", H5P_DEFAULT)) < 0) + TEST_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype_tmp, H5I_DATATYPE))) + TEST_ERROR + if (!dt->shared->u.compnd.packed) + TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 0) != 8) + TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 1) != 12) + TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 2) != 0) + TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 3) != 16) + TEST_ERROR + if (H5Tget_member_offset(dtype_tmp, 4) != 4) TEST_ERROR - if(!dt->shared->u.compnd.packed) TEST_ERROR - if(H5Tget_member_offset(dtype_tmp, 0) != 8) TEST_ERROR - if(H5Tget_member_offset(dtype_tmp, 1) != 12) TEST_ERROR - if(H5Tget_member_offset(dtype_tmp, 2) != 0) TEST_ERROR - if(H5Tget_member_offset(dtype_tmp, 3) != 16) TEST_ERROR - if(H5Tget_member_offset(dtype_tmp, 4) != 4) TEST_ERROR /* Copy the datatype, and verify status */ - if((dtype = H5Tcopy(dtype_tmp)) < 0) TEST_ERROR - if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) + if ((dtype = H5Tcopy(dtype_tmp)) < 0) + TEST_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype, H5I_DATATYPE))) + TEST_ERROR + if (!dt->shared->u.compnd.packed) + TEST_ERROR + if (H5Tget_member_offset(dtype, 0) != 8) + TEST_ERROR + if (H5Tget_member_offset(dtype, 1) != 12) + TEST_ERROR + if (H5Tget_member_offset(dtype, 2) != 0) + TEST_ERROR + if (H5Tget_member_offset(dtype, 3) != 16) + TEST_ERROR + if (H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR - if(!dt->shared->u.compnd.packed) TEST_ERROR - if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR - if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR - if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR - if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR - if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR /* Expand the type, and verify that it became unpacked */ - if(H5Tset_size(dtype, (size_t)21) < 0) TEST_ERROR - if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) + if (H5Tset_size(dtype, (size_t)21) < 0) + TEST_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype, H5I_DATATYPE))) + TEST_ERROR + if (dt->shared->u.compnd.packed) + TEST_ERROR + if (H5Tget_member_offset(dtype, 0) != 8) + TEST_ERROR + if (H5Tget_member_offset(dtype, 1) != 12) + TEST_ERROR + if (H5Tget_member_offset(dtype, 2) != 0) + TEST_ERROR + if (H5Tget_member_offset(dtype, 3) != 16) + TEST_ERROR + if (H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR - if(dt->shared->u.compnd.packed) TEST_ERROR - if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR - if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR - if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR - if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR - if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR /* Shrink the type, and verify that it became packed */ - if(H5Tset_size(dtype, (size_t)20) < 0) TEST_ERROR - if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) + if (H5Tset_size(dtype, (size_t)20) < 0) + TEST_ERROR + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype, H5I_DATATYPE))) + TEST_ERROR + if (!dt->shared->u.compnd.packed) + TEST_ERROR + if (H5Tget_member_offset(dtype, 0) != 8) + TEST_ERROR + if (H5Tget_member_offset(dtype, 1) != 12) + TEST_ERROR + if (H5Tget_member_offset(dtype, 2) != 0) + TEST_ERROR + if (H5Tget_member_offset(dtype, 3) != 16) + TEST_ERROR + if (H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR - if(!dt->shared->u.compnd.packed) TEST_ERROR - if(H5Tget_member_offset(dtype, 0) != 8) TEST_ERROR - if(H5Tget_member_offset(dtype, 1) != 12) TEST_ERROR - if(H5Tget_member_offset(dtype, 2) != 0) TEST_ERROR - if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR - if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR /* Close */ - if(H5Tclose(dtype_tmp)) TEST_ERROR - if(H5Tclose(dtype)) TEST_ERROR - if(H5Fclose(file)) TEST_ERROR + if (H5Tclose(dtype_tmp)) + TEST_ERROR + if (H5Tclose(dtype)) + TEST_ERROR + if (H5Fclose(file)) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(dtype_tmp); H5Tclose(dtype); H5Fclose(file); - } H5E_END_TRY + } + H5E_END_TRY HDputs("*** DATASET TESTS FAILED ***"); return 1; } /* test_ooo_order */ - /*------------------------------------------------------------------------- * Function: main * @@ -2205,21 +2223,22 @@ error: *------------------------------------------------------------------------- */ int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { hid_t fapl_id; - char fname[256]; - unsigned nerrors = 0; + char fname[256]; + unsigned nerrors = 0; h5_reset(); /* Turn off optimized compound converter? */ - if (argc>1) { - if (argc>2 || strcmp("--noopt", argv[1])) { - HDfprintf(stderr, "usage: %s [--noopt]\n", argv[0]); - HDexit(EXIT_FAILURE); - } - H5Tunregister(H5T_PERS_DONTCARE, NULL, (hid_t)-1, (hid_t)-1, (H5T_conv_t)((void (*) (void))H5T__conv_struct_opt)); + if (argc > 1) { + if (argc > 2 || strcmp("--noopt", argv[1])) { + HDfprintf(stderr, "usage: %s [--noopt]\n", argv[0]); + HDexit(EXIT_FAILURE); + } + H5Tunregister(H5T_PERS_DONTCARE, NULL, (hid_t)-1, (hid_t)-1, + (H5T_conv_t)((void (*)(void))H5T__conv_struct_opt)); } /* Create the file */ @@ -2248,8 +2267,7 @@ main (int argc, char *argv[]) nerrors += (h5_verify_cached_stabs(FILENAME, fapl_id) < 0 ? 1 : 0); if (nerrors) { - HDprintf("***** %u FAILURE%s! *****\n", - nerrors, 1==nerrors?"":"S"); + HDprintf("***** %u FAILURE%s! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } diff --git a/test/cork.c b/test/cork.c index 125c53e..5f12347 100644 --- a/test/cork.c +++ b/test/cork.c @@ -24,41 +24,39 @@ * This file needs to access private information from the H5C package. * This file also needs to access the metadata cache testing code. */ -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5C_TESTING /*suppress warning about H5C testing funcs*/ -#include "H5Cpkg.h" /* Cache */ - +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5C_TESTING /*suppress warning about H5C testing funcs*/ +#include "H5Cpkg.h" /* Cache */ /* ============ */ /* Test Defines */ /* ============ */ -#define FILENAME "test_cork.h5" -#define ATTR "ATTR" -#define DSET "DSET" -#define DSET_BT1 "DSET_BT1" -#define DSET_COMPACT "DSET_COMPACT" -#define DSET_CONTIG "DSET_CONTIG" -#define DSET_EA "DSET_EA" -#define DSET_BT2 "DSET_BT2" -#define DSET_FA "DSET_FA" -#define DSET_NONE "DSET_NONE" -#define GRP "GRP" -#define GRP2 "GRP2" -#define GRP3 "GRP3" -#define DT "DT" -#define DT2 "DT2" -#define DT3 "DT3" -#define GRP_ATTR "GRP_ATTR" -#define DSET_ATTR "DSET_ATTR" -#define DT_ATTR "DT_ATTR" - -#define RANK 2 -#define DIM0 5 -#define DIM1 10 -#define DIMS0 50 -#define DIMS1 100 - +#define FILENAME "test_cork.h5" +#define ATTR "ATTR" +#define DSET "DSET" +#define DSET_BT1 "DSET_BT1" +#define DSET_COMPACT "DSET_COMPACT" +#define DSET_CONTIG "DSET_CONTIG" +#define DSET_EA "DSET_EA" +#define DSET_BT2 "DSET_BT2" +#define DSET_FA "DSET_FA" +#define DSET_NONE "DSET_NONE" +#define GRP "GRP" +#define GRP2 "GRP2" +#define GRP3 "GRP3" +#define DT "DT" +#define DT2 "DT2" +#define DT3 "DT3" +#define GRP_ATTR "GRP_ATTR" +#define DSET_ATTR "DSET_ATTR" +#define DT_ATTR "DT_ATTR" + +#define RANK 2 +#define DIM0 5 +#define DIM1 10 +#define DIMS0 50 +#define DIMS1 100 /* ===================== */ /* Function Declarations */ @@ -74,7 +72,6 @@ static unsigned verify_group_cork(hbool_t swmr); static unsigned verify_named_cork(hbool_t swmr); static unsigned verify_multiple_cork(hbool_t swmr); - /*------------------------------------------------------------------------- * Function: verify_old_dset_cork * @@ -92,165 +89,165 @@ static unsigned verify_old_dset_cork(void) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */ - hid_t dcpl = -1, dcpl2 = -1, dcpl3 = -1; /* Dataset creation property lists */ - hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ - hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ - hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ - hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - int **buf = NULL; /* Data bufer (pointers to fake 2D array) */ - int *buf_data = NULL; /* Data buffer (actual data) */ - int i = 0, j = 0; /* Local index variables */ - H5O_info2_t oinfo, oinfo2, oinfo3; /* Object metadata information */ - hsize_t dims2[2] = {8, 16}; /* Dataset dimension sizes */ + hid_t fid = -1; /* File ID */ + hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */ + hid_t dcpl = -1, dcpl2 = -1, dcpl3 = -1; /* Dataset creation property lists */ + hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ + hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ + hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ + int ** buf = NULL; /* Data bufer (pointers to fake 2D array) */ + int * buf_data = NULL; /* Data buffer (actual data) */ + int i = 0, j = 0; /* Local index variables */ + H5O_info2_t oinfo, oinfo2, oinfo3; /* Object metadata information */ + hsize_t dims2[2] = {8, 16}; /* Dataset dimension sizes */ /* Testing Macro */ TESTING("cork status for datasets with old format"); /* Create the file */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create dcpl */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* Set to use chunked dataset */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR /* Create chunked dataset with v1-btree indexing: DSET_BT1 */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, DSET_BT1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_BT1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Get dataset object header address: DSET_BT1 */ - if(H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR /* Cork the dataset: DSET_BT1 */ - if(H5Odisable_mdc_flushes(did) < 0) + if (H5Odisable_mdc_flushes(did) < 0) TEST_ERROR /* Verify cork status */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR /* Set up data array */ - if(NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) + if (NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) TEST_ERROR; - if(NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) + if (NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) TEST_ERROR; for (i = 0; i < 100; i++) buf[i] = buf_data + (i * 20); /* Initialize data buffer */ - for(i = 0; i < (int)dims[0]; i++) - for(j = 0; j < (int)dims[1]; j++) + for (i = 0; i < (int)dims[0]; i++) + for (j = 0; j < (int)dims[1]; j++) buf[i][j] = (i + 1) * (j + 1); /* Write to the dataset: DSET_BT1 */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_BT1 */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR /* Create compact dataset: DSET_COMPACT */ - if((sid2 = H5Screate_simple(2, dims2, NULL)) < 0) + if ((sid2 = H5Screate_simple(2, dims2, NULL)) < 0) FAIL_STACK_ERROR - if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_layout(dcpl2, H5D_COMPACT) < 0) + if (H5Pset_layout(dcpl2, H5D_COMPACT) < 0) FAIL_STACK_ERROR - if(H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0) + if (H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0) FAIL_STACK_ERROR - if((did2 = H5Dcreate2(fid, DSET_COMPACT, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_COMPACT, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get dataset object address */ - if(H5Oget_info3(did2, &oinfo2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did2, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR /* Cork the dataset: DSET_COMPACT */ - if(H5Odisable_mdc_flushes(did2) < 0) + if (H5Odisable_mdc_flushes(did2) < 0) TEST_ERROR /* Verify cork status */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) TEST_ERROR /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) TEST_ERROR - if(H5Sclose(sid2) < 0) + if (H5Sclose(sid2) < 0) TEST_ERROR - if(H5Pclose(dcpl2) < 0) + if (H5Pclose(dcpl2) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Reopen the file */ - if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR /* Open and write to the dataset: DSET_BT1 */ - if((did = H5Dopen2(fid, DSET_BT1, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DSET_BT1, H5P_DEFAULT)) < 0) TEST_ERROR /* Create contiguous dataset: DSET_CONTIG */ - if((sid3 = H5Screate_simple(2, dims2, NULL)) < 0) + if ((sid3 = H5Screate_simple(2, dims2, NULL)) < 0) FAIL_STACK_ERROR - if((dcpl3 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl3 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_layout(dcpl3, H5D_CONTIGUOUS) < 0) + if (H5Pset_layout(dcpl3, H5D_CONTIGUOUS) < 0) FAIL_STACK_ERROR - if((did3 = H5Dcreate2(fid, DSET_CONTIG, H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl3, H5P_DEFAULT)) < 0) + if ((did3 = H5Dcreate2(fid, DSET_CONTIG, H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl3, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get dataset object address: DSET_CONTIG */ - if(H5Oget_info3(did3, &oinfo3, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did3, &oinfo3, H5O_INFO_BASIC) < 0) TEST_ERROR /* Cork the dataset: DSET_CONTIG */ - if(H5Odisable_mdc_flushes(did3) < 0) + if (H5Odisable_mdc_flushes(did3) < 0) TEST_ERROR /* Verify the cork status for DSET_CONTIG */ - if(H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) TEST_ERROR /* Verify the cork status for DSET_BT1 */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) TEST_ERROR /* Un-cork the dataset: DSET_CONTIG */ - if(H5Oenable_mdc_flushes(did3) < 0) + if (H5Oenable_mdc_flushes(did3) < 0) TEST_ERROR /* Verify the cork status for DSET_CONTIG */ - if(H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) TEST_ERROR /* Closing */ - if(H5Dclose(did3) < 0) + if (H5Dclose(did3) < 0) TEST_ERROR - if(H5Pclose(dcpl3) < 0) + if (H5Pclose(dcpl3) < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR HDfree(buf); @@ -260,7 +257,8 @@ verify_old_dset_cork(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Sclose(sid2); H5Sclose(sid3); @@ -271,7 +269,8 @@ error: H5Pclose(dcpl2); H5Pclose(dcpl3); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); HDfree(buf_data); @@ -279,7 +278,6 @@ error: return 1; } /* verify_old_dset_cork */ - /*------------------------------------------------------------------------- * Function: verify_obj_dset_cork * @@ -297,176 +295,179 @@ static unsigned verify_obj_dset_cork(hbool_t swmr) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t aid = -1; /* Attribute ID */ - hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t oid = -1; /* Object ID */ - hid_t dcpl2; /* Dataset creation property list */ - int i = 0; /* Local index variable */ - hsize_t dim[1] = {100}; /* Dataset dimension size */ - hsize_t chunk_dim[1] = {7}; /* Dataset chunk dimension size */ - H5O_info2_t oinfo, oinfo2; /* Object metadata information */ - char attrname[500]; /* Name of attribute */ - unsigned flags; /* File access flags */ - - if(swmr) { + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t aid = -1; /* Attribute ID */ + hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t oid = -1; /* Object ID */ + hid_t dcpl2; /* Dataset creation property list */ + int i = 0; /* Local index variable */ + hsize_t dim[1] = {100}; /* Dataset dimension size */ + hsize_t chunk_dim[1] = {7}; /* Dataset chunk dimension size */ + H5O_info2_t oinfo, oinfo2; /* Object metadata information */ + char attrname[500]; /* Name of attribute */ + unsigned flags; /* File access flags */ + + if (swmr) { TESTING("cork status for dataset objects with attributes (SWMR)"); - } else { + } + else { TESTING("cork status for dataset objects with attributes"); } /* Create fapl */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set to use latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR /* Create the file with/without SWMR access */ flags = H5F_ACC_TRUNC; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR /* Create dataset: DSET */ - if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Get dataset object header address */ - if(H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR /* Verify cork status of the dataset: DSET */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) TEST_ERROR /* Cork the dataset: DSET */ - if(H5Odisable_mdc_flushes(did) < 0) + if (H5Odisable_mdc_flushes(did) < 0) TEST_ERROR /* Attach and write to an attribute to the dataset: DSET */ - if((aid = H5Acreate2(did, ATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, ATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Verify cork status of the dataset: DSET */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR /* Close the attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR /* Verify cork status of the dataset: DSET */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR /* Create dcpl */ - if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Set to early allocation for dataset space */ - if(H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0) + if (H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR /* Create chunked dataset with implicit indexing: DSET_NONE */ - if(H5Pset_chunk(dcpl2, 1, chunk_dim) < 0) + if (H5Pset_chunk(dcpl2, 1, chunk_dim) < 0) FAIL_STACK_ERROR - if((sid2 = H5Screate_simple(1, dim, NULL)) < 0) + if ((sid2 = H5Screate_simple(1, dim, NULL)) < 0) TEST_ERROR - if((did2 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) TEST_ERROR /* Get dataset object header address */ - if(H5Oget_info3(did2, &oinfo2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did2, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR /* Cork the dataset: DSET_NONE */ - if(H5Odisable_mdc_flushes(did2) < 0) + if (H5Odisable_mdc_flushes(did2) < 0) TEST_ERROR /* Attach 8 attributes to the dataset */ - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { HDsprintf(attrname, "attr %d", i); - if((aid = H5Acreate2(did2, attrname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did2, attrname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_NATIVE_INT, &i) < 0) + if (H5Awrite(aid, H5T_NATIVE_INT, &i) < 0) TEST_ERROR - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR } /* end for */ /* Verify cork status of the dataset: DSET_NONE */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) TEST_ERROR /* Closing */ - if(H5Oclose(did) < 0) + if (H5Oclose(did) < 0) TEST_ERROR - if(H5Oclose(did2) < 0) + if (H5Oclose(did2) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR - if(H5Sclose(sid2) < 0) + if (H5Sclose(sid2) < 0) TEST_ERROR - if(H5Pclose(dcpl2) < 0) + if (H5Pclose(dcpl2) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Re-open the file */ flags = H5F_ACC_RDWR; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fopen(FILENAME, flags, fapl)) < 0) + if ((fid = H5Fopen(FILENAME, flags, fapl)) < 0) TEST_ERROR /* Open the dataset object: DSET_NONE */ - if((oid = H5Oopen(fid, DSET_NONE, H5P_DEFAULT)) < 0) + if ((oid = H5Oopen(fid, DSET_NONE, H5P_DEFAULT)) < 0) TEST_ERROR /* Verify cork status of the dataset: DSET */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, FALSE) < 0) TEST_ERROR /* Open the attribute attached to the dataset object: DSET_NONE */ - if((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT)) < + 0) TEST_ERROR /* Cork the dataset: DSET_NONE */ - if(H5Odisable_mdc_flushes(oid) < 0) + if (H5Odisable_mdc_flushes(oid) < 0) TEST_ERROR /* Verify cork status of the dataset: DSET_NONE */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) TEST_ERROR /* Close the attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR /* Verify cork status of the dataset: DSET */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR /* Closing */ - if(H5Oclose(oid) < 0) + if (H5Oclose(oid) < 0) TEST_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Sclose(sid); H5Sclose(sid2); @@ -476,11 +477,11 @@ error: H5Pclose(dcpl2); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* verify_obj_dset_cork */ - /*------------------------------------------------------------------------- * Function: verify_dset_cork * @@ -499,215 +500,218 @@ static unsigned verify_dset_cork(hbool_t swmr, hbool_t new_format) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ - hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ - hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ - hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - int **buf = NULL; /* Data bufer (pointers to fake 2D array) */ - int *buf_data = NULL; /* Data buffer (actual data) */ - int i = 0, j = 0; /* Local index variables */ - H5O_info2_t oinfo, oinfo2, oinfo3; /* Object metadata information */ - unsigned flags; /* File access flags */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ + hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ + hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ + int ** buf = NULL; /* Data bufer (pointers to fake 2D array) */ + int * buf_data = NULL; /* Data buffer (actual data) */ + int i = 0, j = 0; /* Local index variables */ + H5O_info2_t oinfo, oinfo2, oinfo3; /* Object metadata information */ + unsigned flags; /* File access flags */ /* Testing Macro */ - if(swmr) { - if(new_format) { + if (swmr) { + if (new_format) { TESTING("cork status for chunked datasets with different indexing types (SWMR & latest)"); - } else { + } + else { TESTING("cork status for chunked datasets with different indexing types (SWMR & non-latest)"); } /* end if */ - } else { - if(new_format) { + } + else { + if (new_format) { TESTING("cork status for chunked datasets with different indexing types (non-SWMR & latest)"); - } else { + } + else { TESTING("cork status for chunked datasets with different indexing types (non-SWMR & non-latest)"); } /* end if */ - } /* end if */ + } /* end if */ /* Create fapl */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR - if(new_format) { + if (new_format) { /* Set to use latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR } /* end if */ /* Create the file */ flags = H5F_ACC_TRUNC; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create dcpl */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* Set to use chunked dataset */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR /* Create chunked dataset with extensive array indexing: DSET_EA */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Get dataset object header address: DSET_EA */ - if(H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR /* Cork the dataset: DSET_EA */ - if(H5Odisable_mdc_flushes(did) < 0) + if (H5Odisable_mdc_flushes(did) < 0) TEST_ERROR /* Verify cork status */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR /* Create chunked dataset with fixed array indexing: DSET_FA */ - if((sid2 = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid2 = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((did2 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Get dataset object header address: DSET_FA */ - if(H5Oget_info3(did2, &oinfo2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did2, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR /* Cork the dataset: DSET_FA */ - if(H5Odisable_mdc_flushes(did2) < 0) + if (H5Odisable_mdc_flushes(did2) < 0) TEST_ERROR /* Uncork the dataset: DSET_EA */ - if(H5Oenable_mdc_flushes(did) < 0) + if (H5Oenable_mdc_flushes(did) < 0) TEST_ERROR /* Verify the cork status for DSET_FA */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) TEST_ERROR /* Verify the cork status for DSET_EA */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) TEST_ERROR /* Create chunked dataset with v2-Btree indexing */ max_dims[0] = H5S_UNLIMITED; - if((sid3 = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid3 = H5Screate_simple(2, dims, max_dims)) < 0) TEST_ERROR - if((did3 = H5Dcreate2(fid, DSET_BT2, H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did3 = H5Dcreate2(fid, DSET_BT2, H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Get dataset object header address: DSET_BT2 */ - if(H5Oget_info3(did3, &oinfo3, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did3, &oinfo3, H5O_INFO_BASIC) < 0) TEST_ERROR /* Cork the dataset: DSET_BT2 */ - if(H5Odisable_mdc_flushes(did3) < 0) + if (H5Odisable_mdc_flushes(did3) < 0) TEST_ERROR /* Verify the cork status for DSET_BT2 */ - if(H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) TEST_ERROR /* Closing */ - if(H5Dclose(did3) < 0) + if (H5Dclose(did3) < 0) TEST_ERROR - if(H5Sclose(sid3) < 0) + if (H5Sclose(sid3) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) TEST_ERROR - if(H5Sclose(sid2) < 0) + if (H5Sclose(sid2) < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Reopen the file */ flags = H5F_ACC_RDWR; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fopen(FILENAME, flags, fapl)) < 0) + if ((fid = H5Fopen(FILENAME, flags, fapl)) < 0) TEST_ERROR /* Set up data array */ - if(NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) + if (NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) TEST_ERROR; - if(NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) + if (NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) TEST_ERROR; for (i = 0; i < 100; i++) buf[i] = buf_data + (i * 20); /* Initialize data buffer */ - for(i = 0; i < (int)dims[0]; i++) - for(j = 0; j < (int)dims[1]; j++) + for (i = 0; i < (int)dims[0]; i++) + for (j = 0; j < (int)dims[1]; j++) buf[i][j] = (i + 1) * (j + 1); /* Open and write to the dataset: DSET_EA */ - if((did = H5Dopen2(fid, DSET_EA, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DSET_EA, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_EA */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) TEST_ERROR /* Open and write to the dataset: DSET_FA */ - if((did2 = H5Dopen2(fid, DSET_FA, H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(fid, DSET_FA, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Cork the dataset: DSET_FA */ - if(H5Odisable_mdc_flushes(did2) < 0) + if (H5Odisable_mdc_flushes(did2) < 0) TEST_ERROR /* Verify the cork status for DSET_FA */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) TEST_ERROR /* Open and write to the dataset: DSET_BT2 */ - if((did3 = H5Dopen2(fid, DSET_BT2, H5P_DEFAULT)) < 0) + if ((did3 = H5Dopen2(fid, DSET_BT2, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) + if (H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_BT2 */ - if(H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) TEST_ERROR /* Cork the dataset: DSET_BT2 */ - if(H5Odisable_mdc_flushes(did3) < 0) + if (H5Odisable_mdc_flushes(did3) < 0) TEST_ERROR /* Verify the cork status for DSET_BT2 */ - if(H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) TEST_ERROR /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) TEST_ERROR - if(H5Dclose(did3) < 0) + if (H5Dclose(did3) < 0) TEST_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR HDfree(buf); @@ -717,7 +721,8 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Sclose(sid2); H5Sclose(sid3); @@ -727,7 +732,8 @@ error: H5Pclose(dcpl); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); HDfree(buf_data); @@ -735,8 +741,6 @@ error: return 1; } /* verify_dset_cork */ - - /*------------------------------------------------------------------------- * Function: verify_group_cork * @@ -754,156 +758,158 @@ static unsigned verify_group_cork(hbool_t swmr) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t gid = -1, gid2 = -1, gid3 = -1; /* Group IDs */ - H5O_info2_t oinfo, oinfo2, oinfo3; /* Object metadata information */ - hid_t aid; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - char attrname[500]; /* Name of attribute */ - unsigned flags; /* File access flags */ - int i = 0; /* Local index variable */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t gid = -1, gid2 = -1, gid3 = -1; /* Group IDs */ + H5O_info2_t oinfo, oinfo2, oinfo3; /* Object metadata information */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + char attrname[500]; /* Name of attribute */ + unsigned flags; /* File access flags */ + int i = 0; /* Local index variable */ /* Testing Macro */ - if(swmr) { + if (swmr) { TESTING("cork status for groups (SWMR)"); - } else { + } + else { TESTING("cork status for groups"); } /* Create fapl */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set to use latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR /* Create the file */ flags = H5F_ACC_TRUNC; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create 3 groups */ - if((gid = H5Gcreate2(fid, GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(gid, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(gid, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid3 = H5Gcreate2(gid2, GRP3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid3 = H5Gcreate2(gid2, GRP3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Cork the second group: GRP2 */ - if(H5Odisable_mdc_flushes(gid2) < 0) + if (H5Odisable_mdc_flushes(gid2) < 0) TEST_ERROR /* Get group object header addresses */ - if(H5Oget_info3(gid, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(gid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(gid2, &oinfo2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(gid2, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(gid3, &oinfo3, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(gid3, &oinfo3, H5O_INFO_BASIC) < 0) TEST_ERROR /* Verify cork status of the groups */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) TEST_ERROR /* Close the second group: GRP2 */ - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR /* Re-open the second group: GRP2 */ - if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Verify cork status of the second group: GRP2 */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, FALSE) < 0) TEST_ERROR /* Closing */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid3) < 0) + if (H5Gclose(gid3) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Re-open the file and the three groups */ flags = H5F_ACC_RDWR; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fopen(FILENAME, flags, fapl)) < 0) + if ((fid = H5Fopen(FILENAME, flags, fapl)) < 0) FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, GRP, H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, GRP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gid3 = H5Gopen2(gid2, GRP3, H5P_DEFAULT)) < 0) + if ((gid3 = H5Gopen2(gid2, GRP3, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR /* Attach 8 attributes to the third group: GRP3 */ - for(i = 0;i < 8; i++) { + for (i = 0; i < 8; i++) { HDsprintf(attrname, "attr %d", i); - if((aid = H5Acreate2(gid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(gid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0) + if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0) TEST_ERROR /* Cork the third group while attaching attributes */ - if(i == 3) { - if(H5Odisable_mdc_flushes(gid3) < 0) + if (i == 3) { + if (H5Odisable_mdc_flushes(gid3) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) TEST_ERROR } - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR } /* end for */ /* Verify cork status of the third group: GRP3 */ - if(H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) TEST_ERROR /* Closing */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid3) < 0) + if (H5Gclose(gid3) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gid); - H5Gclose(gid2); - H5Gclose(gid3); - H5Sclose(sid); + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Gclose(gid2); + H5Gclose(gid3); + H5Sclose(sid); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* verify_group_cork */ - /*------------------------------------------------------------------------- * Function: verify_named_cork * @@ -921,263 +927,264 @@ static unsigned verify_named_cork(hbool_t swmr) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t tid = -1, tid2 = -1, tid3 = -1; /* Datatype IDs */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5O_info2_t oinfo, oinfo2, oinfo3, oinfo4; /* Object metadata information */ - hid_t aid = -1; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - hid_t did; /* Dataset ID */ - char attrname[500]; /* Name of attribute */ - unsigned flags; /* File access flags */ - int i = 0; /* Local index variable */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t tid = -1, tid2 = -1, tid3 = -1; /* Datatype IDs */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5O_info2_t oinfo, oinfo2, oinfo3, oinfo4; /* Object metadata information */ + hid_t aid = -1; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ + char attrname[500]; /* Name of attribute */ + unsigned flags; /* File access flags */ + int i = 0; /* Local index variable */ /* Testing Macro */ - if(swmr) { + if (swmr) { TESTING("cork status for named datatypes (SWMR)"); - } else { + } + else { TESTING("cork status for named datatypes"); } /* Create fapl */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set to use latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR /* Create the file */ flags = H5F_ACC_TRUNC; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create 3 copies of datatypes */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if((tid2 = H5Tcopy(H5T_NATIVE_LONG)) < 0) + if ((tid2 = H5Tcopy(H5T_NATIVE_LONG)) < 0) TEST_ERROR - if((tid3 = H5Tcopy(H5T_NATIVE_CHAR)) < 0) + if ((tid3 = H5Tcopy(H5T_NATIVE_CHAR)) < 0) TEST_ERROR /* Commit datatype /DT */ - if(H5Tcommit2(fid, DT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(fid, DT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create /GRP */ - if((gid = H5Gcreate2(fid, GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Commit datatype /GRP/DT2 */ - if(H5Tcommit2(gid, DT2, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(gid, DT2, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create /GRP/GRP2 */ - if((gid2 = H5Gcreate2(gid, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(gid, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Commit datatype /GRP/GRP2/DT3 */ - if(H5Tcommit2(gid2, DT3, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(gid2, DT3, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Cork 2 named datatypes: /DT and /GRP/GRP2/DT3 */ - if(H5Odisable_mdc_flushes(tid) < 0) + if (H5Odisable_mdc_flushes(tid) < 0) TEST_ERROR - if(H5Odisable_mdc_flushes(tid3) < 0) + if (H5Odisable_mdc_flushes(tid3) < 0) TEST_ERROR /* Get named datatype object header addresses */ - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(tid2, &oinfo2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(tid2, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(tid3, &oinfo3, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(tid3, &oinfo3, H5O_INFO_BASIC) < 0) TEST_ERROR /* Verify cork status of the named datatypes */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid, oinfo2.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, FALSE) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) TEST_ERROR /* Close the datatypes */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) TEST_ERROR - if(H5Tclose(tid3) < 0) + if (H5Tclose(tid3) < 0) TEST_ERROR /* Re-open the named datatypes */ - if((tid = H5Topen2(fid, DT, H5P_DEFAULT)) < 0) + if ((tid = H5Topen2(fid, DT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid2 = H5Topen2(gid, DT2, H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(gid, DT2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid3 = H5Topen2(gid2, DT3, H5P_DEFAULT)) < 0) + if ((tid3 = H5Topen2(gid2, DT3, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Verify cork status of the named datatypes */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid, oinfo2.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, FALSE) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) TEST_ERROR /* Closing */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) TEST_ERROR - if(H5Tclose(tid3) < 0) + if (H5Tclose(tid3) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR - /* Re-open the file and the three groups */ flags = H5F_ACC_RDWR; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fopen(FILENAME, flags, fapl)) < 0) + if ((fid = H5Fopen(FILENAME, flags, fapl)) < 0) FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, GRP, H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, GRP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Re-open the named datatypes */ - if((tid = H5Topen2(fid, DT, H5P_DEFAULT)) < 0) + if ((tid = H5Topen2(fid, DT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid2 = H5Topen2(gid, DT2, H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(gid, DT2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid3 = H5Topen2(gid2, DT3, H5P_DEFAULT)) < 0) + if ((tid3 = H5Topen2(gid2, DT3, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Cork the datatype: DT2 */ - if(H5Odisable_mdc_flushes(tid2) < 0) + if (H5Odisable_mdc_flushes(tid2) < 0) TEST_ERROR /* Create dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR /* Attach 8 attributes to datatype: DT3 */ - for(i = 0;i < 8; i++) { + for (i = 0; i < 8; i++) { HDsprintf(attrname, "attr %d", i); - if((aid = H5Acreate2(tid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(tid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0) + if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0) TEST_ERROR /* Cork the datatype while attaching attributes */ - if(i == 3) { - if(H5Odisable_mdc_flushes(tid3) < 0) + if (i == 3) { + if (H5Odisable_mdc_flushes(tid3) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) TEST_ERROR } - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR } /* end for */ /* Create a dataset with named datatype: DT */ - if((did = H5Dcreate2(fid, DSET, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get dataset object header address */ - if(H5Oget_info3(did, &oinfo4, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oinfo4, H5O_INFO_BASIC) < 0) TEST_ERROR /* Cork the dataset: DSET */ - if(H5Odisable_mdc_flushes(did) < 0) + if (H5Odisable_mdc_flushes(did) < 0) TEST_ERROR /* Verify cork status of the datatype: DT */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, FALSE) < 0) TEST_ERROR /* Verify cork status of the datatype: DT2 */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) TEST_ERROR /* Verify cork status of the datatype: DT3 */ - if(H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, TRUE) < 0) TEST_ERROR /* Un-cork the datatype: DT3 */ - if(H5Oenable_mdc_flushes(tid3) < 0) + if (H5Oenable_mdc_flushes(tid3) < 0) TEST_ERROR /* Verify cork status of the datatype: DT3 */ - if(H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo3.token, FALSE) < 0) TEST_ERROR /* Cork the datatype: DT */ - if(H5Odisable_mdc_flushes(tid) < 0) + if (H5Odisable_mdc_flushes(tid) < 0) TEST_ERROR /* Verify cork status of the datatype: DT */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR /* Verify cork status of the datatype: DT2 */ - if(H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo2.token, TRUE) < 0) TEST_ERROR /* Verify cork status of the dataset: DSET */ - if(H5C__verify_cork_tag_test(fid, oinfo4.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo4.token, TRUE) < 0) TEST_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR /* Verify cork status of the datatype: DT */ - if(H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo.token, TRUE) < 0) TEST_ERROR /* Verify cork status of the dataset: DSET */ - if(H5C__verify_cork_tag_test(fid, oinfo4.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid, oinfo4.token, FALSE) < 0) TEST_ERROR /* Closing */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) TEST_ERROR - if(H5Tclose(tid3) < 0) + if (H5Tclose(tid3) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Tclose(tid); - H5Tclose(tid2); - H5Tclose(tid3); - H5Gclose(gid); - H5Gclose(gid2); - H5Dclose(did); + H5E_BEGIN_TRY + { + H5Tclose(tid); + H5Tclose(tid2); + H5Tclose(tid3); + H5Gclose(gid); + H5Gclose(gid2); + H5Dclose(did); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* verify_named_cork */ - /*------------------------------------------------------------------------- * Function: verify_multiple_cork * @@ -1197,332 +1204,344 @@ static unsigned verify_multiple_cork(hbool_t swmr) { /* Variable Declarations */ - hid_t fid1 = -1, fid2 = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */ - hid_t gid1 = -1, gid2 = -1; /* Group IDs */ - hid_t did1 = -1, did2 = -1; /* Dataset ID */ - hid_t aidg1 = -1, aidg2 = -1; /* Attribute ID */ - hid_t aidd1 = -1, aidd2 = -1; /* Attribute ID */ - hid_t aidt1 = -1, aidt2 = -1; /* Attribute ID */ - hid_t sid = -1; /* Dataspace ID */ - H5O_info2_t oinfo1, oinfo2, oinfo3; /* Object metadata information */ - hsize_t dim[1] = {5}; /* Dimension sizes */ - unsigned flags; /* File access flags */ - hbool_t corked; /* Cork status */ - herr_t ret; /* Return value */ + hid_t fid1 = -1, fid2 = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */ + hid_t gid1 = -1, gid2 = -1; /* Group IDs */ + hid_t did1 = -1, did2 = -1; /* Dataset ID */ + hid_t aidg1 = -1, aidg2 = -1; /* Attribute ID */ + hid_t aidd1 = -1, aidd2 = -1; /* Attribute ID */ + hid_t aidt1 = -1, aidt2 = -1; /* Attribute ID */ + hid_t sid = -1; /* Dataspace ID */ + H5O_info2_t oinfo1, oinfo2, oinfo3; /* Object metadata information */ + hsize_t dim[1] = {5}; /* Dimension sizes */ + unsigned flags; /* File access flags */ + hbool_t corked; /* Cork status */ + herr_t ret; /* Return value */ /* Testing Macro */ - if(swmr) { + if (swmr) { TESTING("cork status for multiple opens (SWMR)"); - } else { + } + else { TESTING("cork status for multiple opens"); } /* Create fapl */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set to use latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR /* Create the file */ flags = H5F_ACC_TRUNC; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid1 = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) + if ((fid1 = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Open root group */ - if((gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) + if ((gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) TEST_ERROR /* Create and commit datatype */ - if((tid1 = H5Tcopy(H5T_STD_I32LE)) < 0) + if ((tid1 = H5Tcopy(H5T_STD_I32LE)) < 0) TEST_ERROR - if(H5Tcommit2(fid1, DT, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(fid1, DT, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create dataset */ - if((sid = H5Screate_simple(1, dim, NULL)) < 0) + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) TEST_ERROR - if((did1 = H5Dcreate2(fid1, DSET, tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid1, DSET, tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create attribute on root group */ - if((aidg1 = H5Acreate2(gid1, GRP_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aidg1 = H5Acreate2(gid1, GRP_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create attribute on dataset */ - if((aidd1 = H5Acreate2(did1, DSET_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aidd1 = H5Acreate2(did1, DSET_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create attribute on datatype */ - if((aidt1 = H5Acreate2(tid1, DT_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aidt1 = H5Acreate2(tid1, DT_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Closing */ - if(H5Aclose(aidt1) < 0) + if (H5Aclose(aidt1) < 0) TEST_ERROR - if(H5Aclose(aidd1) < 0) + if (H5Aclose(aidd1) < 0) TEST_ERROR - if(H5Aclose(aidg1) < 0) + if (H5Aclose(aidg1) < 0) TEST_ERROR - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) TEST_ERROR - if(H5Tclose(tid1) < 0) + if (H5Tclose(tid1) < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /* Open the file twice: fid1, fid2 */ flags = H5F_ACC_RDWR; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid1 = H5Fopen(FILENAME, flags, fapl)) < 0) + if ((fid1 = H5Fopen(FILENAME, flags, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fopen(FILENAME, flags, fapl)) < 0) + if ((fid2 = H5Fopen(FILENAME, flags, fapl)) < 0) TEST_ERROR /* Open the root group twice: gid1, gid2 */ - if((gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) + if ((gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) TEST_ERROR - if((gid2 = H5Gopen2(fid2, "/", H5P_DEFAULT)) < 0) + if ((gid2 = H5Gopen2(fid2, "/", H5P_DEFAULT)) < 0) TEST_ERROR /* Open the root group attribute twice: aidg1, aidg2 */ - if((aidg1 = H5Aopen(gid1, GRP_ATTR, H5P_DEFAULT)) < 0) + if ((aidg1 = H5Aopen(gid1, GRP_ATTR, H5P_DEFAULT)) < 0) TEST_ERROR - if((aidg2 = H5Aopen(gid2, GRP_ATTR, H5P_DEFAULT)) < 0) + if ((aidg2 = H5Aopen(gid2, GRP_ATTR, H5P_DEFAULT)) < 0) TEST_ERROR /* Cork the group: gid2 */ - if(H5Odisable_mdc_flushes(gid2) < 0) + if (H5Odisable_mdc_flushes(gid2) < 0) TEST_ERROR /* Verify cork status of the group: gid2 */ - if(H5Oget_info3(gid2, &oinfo1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(gid2, &oinfo1, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid2, oinfo1.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid2, oinfo1.token, TRUE) < 0) TEST_ERROR /* Check cork status of the group: gid1 */ - if(H5Oare_mdc_flushes_disabled(gid1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Open the dataset twice: did1, did2 */ - if((did1 = H5Dopen2(fid1, DSET, H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(fid1, DSET, H5P_DEFAULT)) < 0) TEST_ERROR - if((did2 = H5Dopen2(fid2, DSET, H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(fid2, DSET, H5P_DEFAULT)) < 0) TEST_ERROR /* Open the dataset attribute twice: aidd1, aidd2 */ - if((aidd1 = H5Aopen(did1, DSET_ATTR, H5P_DEFAULT)) < 0) + if ((aidd1 = H5Aopen(did1, DSET_ATTR, H5P_DEFAULT)) < 0) TEST_ERROR - if((aidd2 = H5Aopen(did2, DSET_ATTR, H5P_DEFAULT)) < 0) + if ((aidd2 = H5Aopen(did2, DSET_ATTR, H5P_DEFAULT)) < 0) TEST_ERROR /* Cork the dataset: did1 */ - if(H5Odisable_mdc_flushes(did1) < 0) + if (H5Odisable_mdc_flushes(did1) < 0) TEST_ERROR /* Verify cork status of the dataset: did1 */ - if(H5Oget_info3(did1, &oinfo2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did1, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid1, oinfo2.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid1, oinfo2.token, TRUE) < 0) TEST_ERROR /* Check cork status of the dataset: did2 */ - if(H5Oare_mdc_flushes_disabled(did2, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did2, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Open the datatype twice: tid1, tid2 */ - if((tid1 = H5Topen2(fid1, DT, H5P_DEFAULT)) < 0) + if ((tid1 = H5Topen2(fid1, DT, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid2 = H5Topen2(fid2, DT, H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(fid2, DT, H5P_DEFAULT)) < 0) TEST_ERROR /* Open the datatype attribute twice: aidt1, aidt2 */ - if((aidt1 = H5Aopen(tid1, DT_ATTR, H5P_DEFAULT)) < 0) + if ((aidt1 = H5Aopen(tid1, DT_ATTR, H5P_DEFAULT)) < 0) TEST_ERROR - if((aidt2 = H5Aopen(tid2, DT_ATTR, H5P_DEFAULT)) < 0) + if ((aidt2 = H5Aopen(tid2, DT_ATTR, H5P_DEFAULT)) < 0) TEST_ERROR /* Cork the datatype: tid2 */ - if(H5Odisable_mdc_flushes(tid2) < 0) + if (H5Odisable_mdc_flushes(tid2) < 0) TEST_ERROR /* Verify cork status of the datatype: tid2 */ - if(H5Oget_info3(tid2, &oinfo3, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(tid2, &oinfo3, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid2, oinfo3.token, TRUE) < 0) + if (H5C__verify_cork_tag_test(fid2, oinfo3.token, TRUE) < 0) TEST_ERROR /* Check cork status of the datatype: tid1 */ - if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Uncork the group: gid1 */ - if(H5Oenable_mdc_flushes(gid1) < 0) + if (H5Oenable_mdc_flushes(gid1) < 0) TEST_ERROR /* Verify cork status of the group: gid1 */ - if(H5Oget_info3(gid1, &oinfo1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(gid1, &oinfo1, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid1, oinfo1.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid1, oinfo1.token, FALSE) < 0) TEST_ERROR /* Check cork status of the group: gid2 */ - if(H5Oare_mdc_flushes_disabled(gid2, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid2, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Close the group: gid2 */ - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR /* Check cork status of the group: gid1 */ - if(H5Oare_mdc_flushes_disabled(gid1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid1, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Verify cork status of the group: gid1 */ - if(H5C__verify_cork_tag_test(fid1, oinfo1.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid1, oinfo1.token, FALSE) < 0) TEST_ERROR /* Close the group: gid1 */ - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) TEST_ERROR /* Uncork the dataset: gid2 */ - if(H5Oenable_mdc_flushes(did2) < 0) + if (H5Oenable_mdc_flushes(did2) < 0) TEST_ERROR /* Verify cork status of the dataset: did2 */ - if(H5Oget_info3(did2, &oinfo2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did2, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5C__verify_cork_tag_test(fid2, oinfo2.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid2, oinfo2.token, FALSE) < 0) TEST_ERROR /* Check cork status of the dataset: did1 */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Close the dataset: did2 */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) TEST_ERROR /* Check cork status of the dataset: did1 */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Verify cork status of the dataset: did1 */ - if(H5C__verify_cork_tag_test(fid1, oinfo2.token, FALSE) < 0) + if (H5C__verify_cork_tag_test(fid1, oinfo2.token, FALSE) < 0) TEST_ERROR /* Close the dataset: did1 */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) TEST_ERROR /* Check cork status of the datatype: tid1 */ - if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close datatype: tid1 */ - if(H5Tclose(tid1) < 0) + if (H5Tclose(tid1) < 0) TEST_ERROR /* Check cork status of the datatype: tid2 */ - if(H5Oare_mdc_flushes_disabled(tid2, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid2, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close datatype: tid2 */ - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) TEST_ERROR /* Should fail to cork the attribute: aidg2; not an object */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Odisable_mdc_flushes(aidg2); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Should fail to uncork the attribute: aidd1; not an object */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Odisable_mdc_flushes(aidd1); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Should fail to check cork status of the attribute: aidt2; not an object */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oare_mdc_flushes_disabled(aidt2, &corked); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close all attributes */ - if(H5Aclose(aidg1) < 0) + if (H5Aclose(aidg1) < 0) TEST_ERROR - if(H5Aclose(aidg2) < 0) + if (H5Aclose(aidg2) < 0) TEST_ERROR - if(H5Aclose(aidd1) < 0) + if (H5Aclose(aidd1) < 0) TEST_ERROR - if(H5Aclose(aidd2) < 0) + if (H5Aclose(aidd2) < 0) TEST_ERROR - if(H5Aclose(aidt1) < 0) + if (H5Aclose(aidt1) < 0) TEST_ERROR - if(H5Aclose(aidt2) < 0) + if (H5Aclose(aidt2) < 0) TEST_ERROR /* Should fail to cork the file: fid1; not an object */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oare_mdc_flushes_disabled(fid1, &corked); ret = H5Odisable_mdc_flushes(fid1); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Should fail to uncork the file: fid2; not an object */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oenable_mdc_flushes(fid2); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Closing */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid1); H5Tclose(tid2); H5Gclose(gid1); @@ -1538,15 +1557,17 @@ error: H5Pclose(fapl); H5Fclose(fid1); H5Fclose(fid1); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* verify_multiple_cork */ /*------------------------------------------------------------------------- * Function: test_objs_cork * - * Purpose: This function verifies H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled public - * routines are working as specified. + * Purpose: This function verifies + *H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled public routines are working as + *specified. * * Return: 0 on Success, 1 on Failure * @@ -1557,264 +1578,280 @@ error: static unsigned test_objs_cork(hbool_t swmr, hbool_t new_format) { - hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - hid_t gid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; /* Object IDs */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hid_t aid = H5I_INVALID_HID; /* Attribute ID */ - hsize_t dims[RANK]; /* Dataset dimension sizes */ - hbool_t corked; /* Cork status of an object */ - unsigned flags; /* File access flags */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t gid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; /* Object IDs */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hsize_t dims[RANK]; /* Dataset dimension sizes */ + hbool_t corked; /* Cork status of an object */ + unsigned flags; /* File access flags */ + herr_t ret; /* Return value */ /* Testing Macro */ - if(new_format) { - if(swmr) { - TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (new library format) (SWMR)"); + if (new_format) { + if (swmr) { + TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (new library " + "format) (SWMR)"); } /* end if */ else { - TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (new library format)"); + TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (new library " + "format)"); } /* end else */ - } else { - if(swmr) { - TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (old library format) (SWMR)"); + } + else { + if (swmr) { + TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (old library " + "format) (SWMR)"); } /* end if */ else { - TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (old library format)"); + TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (old library " + "format)"); } /* end else */ - } /* end else */ + } /* end else */ /* Create fapl */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set to use latest format */ - if(new_format) { - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (new_format) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR } /* end if */ /* Create the file with/without SWMR access */ flags = H5F_ACC_TRUNC; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create group */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Check cork status of the group: not corked */ - if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Cork the group: an object */ - if(H5Odisable_mdc_flushes(gid) < 0) + if (H5Odisable_mdc_flushes(gid) < 0) TEST_ERROR /* Check cork status of the group: corked */ - if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR /* Create a transient copy of a native type */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR /* Should fail to cork the datatype: not an object */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Odisable_mdc_flushes(tid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Create a named datatype */ - if(H5Tcommit2(fid, "group/datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(fid, "group/datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Check cork status of the named datatype: not corked */ - if(H5Oare_mdc_flushes_disabled(tid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Cork the named datatype: an object */ - if(H5Odisable_mdc_flushes(tid) < 0) + if (H5Odisable_mdc_flushes(tid) < 0) TEST_ERROR /* Check cork status of the named datatype: corked */ - if(H5Oare_mdc_flushes_disabled(tid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close the named datatype */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) TEST_ERROR /* Create dataspace */ dims[0] = DIM0; dims[1] = DIM1; - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR /* Should fail to uncork the dataspace: not an object */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oenable_mdc_flushes(sid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Create dataset. */ - if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create attribute on the dataset */ - if((aid = H5Acreate2(did, "attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Should fail to check cork status of the attribute: not an object */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oare_mdc_flushes_disabled(aid, &corked); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Check cork status of the dataset: not corked */ - if(H5Oare_mdc_flushes_disabled(did, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Cork the dataset: an object */ - if(H5Odisable_mdc_flushes(did) < 0) + if (H5Odisable_mdc_flushes(did) < 0) TEST_ERROR /* Check cork status of the dataset: corked */ - if(H5Oare_mdc_flushes_disabled(did, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close the dataset and dataspace */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR /* Open the group */ - if((gid = H5Oopen(fid, "group", H5P_DEFAULT)) < 0) + if ((gid = H5Oopen(fid, "group", H5P_DEFAULT)) < 0) TEST_ERROR /* Check cork status of the group */ - if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Cork the group */ - if(H5Odisable_mdc_flushes(gid) < 0) + if (H5Odisable_mdc_flushes(gid) < 0) TEST_ERROR /* Should fail to cork the group again */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Odisable_mdc_flushes(gid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Check cork status of the group */ - if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Open the named datatype */ - if((tid = H5Oopen(fid, "group/datatype", H5P_DEFAULT)) < 0) + if ((tid = H5Oopen(fid, "group/datatype", H5P_DEFAULT)) < 0) TEST_ERROR /* Check cork status of the named datatype */ - if(H5Oare_mdc_flushes_disabled(tid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Should fail to un-cork the named datatype that is not corked yet */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oenable_mdc_flushes(tid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Cork the named datatype */ - if(H5Odisable_mdc_flushes(tid) < 0) + if (H5Odisable_mdc_flushes(tid) < 0) TEST_ERROR /* Check cork status of the named datatype */ - if(H5Oare_mdc_flushes_disabled(tid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Open the dataset */ - if((did = H5Oopen(fid, "/dataset", H5P_DEFAULT)) < 0) + if ((did = H5Oopen(fid, "/dataset", H5P_DEFAULT)) < 0) TEST_ERROR /* Check cork status of the dataset */ - if(H5Oare_mdc_flushes_disabled(did, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Cork the dataset */ - if(H5Odisable_mdc_flushes(did) < 0) + if (H5Odisable_mdc_flushes(did) < 0) TEST_ERROR /* Check cork status of dataset */ - if(H5Oare_mdc_flushes_disabled(did, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Un-cork the dataset */ - if(H5Oenable_mdc_flushes(did) < 0) + if (H5Oenable_mdc_flushes(did) < 0) TEST_ERROR /* Check cork status of the dataset */ - if(H5Oare_mdc_flushes_disabled(did, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Closing */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Dclose(did); @@ -1822,16 +1859,17 @@ error: H5Tclose(tid); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_objs_cork() */ - /*------------------------------------------------------------------------- * Function: test_dset_cork * - * Purpose: This function verifies H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled are - * working as specified when manipulating datasets. + * Purpose: This function verifies + *H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled are working as specified when + *manipulating datasets. * * Return: 0 on Success, 1 on Failure * @@ -1842,309 +1880,314 @@ error: static unsigned test_dset_cork(hbool_t swmr, hbool_t new_format) { - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - hid_t gid; /* Groupd ID */ - hid_t did1, did2; /* Dataset IDs */ - hid_t tid1, tid2; /* Datatype IDs */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataset creation property list */ - hsize_t dims[RANK]; /* Dataset dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dataset dimensions */ - hsize_t cdims[RANK] = {2,2}; /* Chunk dimensions */ - int fillval = 0; /* Fill value */ - int i, j, k = 0; /* Local index variables */ - int **wbuf = NULL; /* Data buffer for writes (pointers to fake 2D array) */ - int *wbuf_data = NULL; /* Data buffer for writes (real data) */ - int *rbuf_data = NULL; /* Data buffer for reads (real data) */ - hbool_t corked; /* Cork status of an object */ - unsigned flags; /* File access flags */ + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + hid_t gid; /* Groupd ID */ + hid_t did1, did2; /* Dataset IDs */ + hid_t tid1, tid2; /* Datatype IDs */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataset creation property list */ + hsize_t dims[RANK]; /* Dataset dimensions */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dataset dimensions */ + hsize_t cdims[RANK] = {2, 2}; /* Chunk dimensions */ + int fillval = 0; /* Fill value */ + int i, j, k = 0; /* Local index variables */ + int ** wbuf = NULL; /* Data buffer for writes (pointers to fake 2D array) */ + int * wbuf_data = NULL; /* Data buffer for writes (real data) */ + int * rbuf_data = NULL; /* Data buffer for reads (real data) */ + hbool_t corked; /* Cork status of an object */ + unsigned flags; /* File access flags */ /* Testing Macro */ - if(new_format) { - if(swmr) { - TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets (new library format) (SWMR)"); + if (new_format) { + if (swmr) { + TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets " + "(new library format) (SWMR)"); } /* end if */ else { - TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets (new library format)"); + TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets " + "(new library format)"); } /* end else */ - } else { - if(swmr) { - TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets (old library format) (SWMR)"); + } + else { + if (swmr) { + TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets " + "(old library format) (SWMR)"); } /* end if */ else { - TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets (old library format)"); + TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets " + "(old library format)"); } /* end else */ - } /* end if */ + } /* end if */ /* Create fapl */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set to use latest format */ - if(new_format) { - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (new_format) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR } /* end if */ /* Create the file with/without SWMR access */ flags = H5F_ACC_TRUNC; - if(swmr) + if (swmr) flags |= H5F_ACC_SWMR_WRITE; - if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create a group */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Commit the datatype with the group */ - if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(gid, "datatype", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(gid, "datatype", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Cork the named datatype */ - if(H5Odisable_mdc_flushes(tid1) < 0) + if (H5Odisable_mdc_flushes(tid1) < 0) TEST_ERROR /* Set up dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Enable chunking */ - if(H5Pset_chunk(dcpl, RANK, cdims) < 0) + if (H5Pset_chunk(dcpl, RANK, cdims) < 0) TEST_ERROR /* Set up a fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) TEST_ERROR /* Create dataspace */ dims[0] = DIMS0; dims[1] = DIMS1; - if((sid = H5Screate_simple(RANK, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR /* Create the dataset inside the group with the named datatype */ - if((did1 = H5Dcreate2(gid, "dataset", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(gid, "dataset", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Check cork status of the named datatype */ - if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Cork the dataset */ - if(H5Odisable_mdc_flushes(did1) < 0) + if (H5Odisable_mdc_flushes(did1) < 0) TEST_ERROR /* Check cork status of the dataset */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Check cork status of the group */ - if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Set up data array */ - if(NULL == (wbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) + if (NULL == (wbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) TEST_ERROR; - if(NULL == (wbuf = (int **)HDcalloc(DIMS0, sizeof(wbuf_data)))) + if (NULL == (wbuf = (int **)HDcalloc(DIMS0, sizeof(wbuf_data)))) TEST_ERROR; for (i = 0; i < DIMS0; i++) wbuf[i] = wbuf_data + (i * DIMS1); /* Initialize the buffer */ - for(i = 0; i < DIMS0;i++) - for(j = 0;j < DIMS1;j++) + for (i = 0; i < DIMS0; i++) + for (j = 0; j < DIMS1; j++) wbuf[i][j] = k++; /* Write to the dataset */ - if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) + if (H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) TEST_ERROR /* Flush the dataset */ - if(H5Oflush(did1) < 0) + if (H5Oflush(did1) < 0) TEST_ERROR /* Check cork status of the dataset */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Check cork status of the named datatype */ - if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close the dataset */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) TEST_ERROR /* Open the dataset again */ - if((did1 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0) TEST_ERROR /* Check cork status of dataset */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Set up data array */ - if(NULL == (rbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) + if (NULL == (rbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) TEST_ERROR; /* Read from the dataset */ - if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_data) < 0) + if (H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_data) < 0) TEST_ERROR /* Cork the dataset */ - if(H5Odisable_mdc_flushes(did1) < 0) + if (H5Odisable_mdc_flushes(did1) < 0) TEST_ERROR /* Delete the dataset */ - if(H5Ldelete(gid, "dataset", H5P_DEFAULT) < 0) + if (H5Ldelete(gid, "dataset", H5P_DEFAULT) < 0) TEST_ERROR /* Check cork status of the dataset */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close the dataset */ - if(H5Oclose(did1) < 0) + if (H5Oclose(did1) < 0) TEST_ERROR /* Create the dataset again */ - if((did1 = H5Dcreate2(gid, "dataset", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(gid, "dataset", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Cork the dataset */ - if(H5Odisable_mdc_flushes(did1) < 0) + if (H5Odisable_mdc_flushes(did1) < 0) TEST_ERROR /* Write to the dataset */ - if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) + if (H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) TEST_ERROR /* Refresh the dataset */ - if(H5Drefresh(did1) < 0) + if (H5Drefresh(did1) < 0) TEST_ERROR /* Check cork status of the dataset */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close the dataset */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) TEST_ERROR /* First open of the dataset */ - if((did1 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0) TEST_ERROR /* Second open of the dataset */ - if((did2 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0) TEST_ERROR /* Cork the first opened dataset */ - if(H5Odisable_mdc_flushes(did1) < 0) + if (H5Odisable_mdc_flushes(did1) < 0) TEST_ERROR /* Check cork status of the first opened dataset */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Check cork status of the second opened dataset */ - if(H5Oare_mdc_flushes_disabled(did2, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did2, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close the second opened dataset */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) TEST_ERROR /* Check cork status of the first opened dataset */ - if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(did1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Close the first opened dastaset */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) TEST_ERROR /* Check cork status of the named datatype */ - if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Second open of the named datatype */ - if((tid2 = H5Topen2(gid, "datatype", H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(gid, "datatype", H5P_DEFAULT)) < 0) TEST_ERROR /* Check cork status of the second opened named datatype */ - if(H5Oare_mdc_flushes_disabled(tid2, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid2, &corked) < 0) TEST_ERROR - if(!corked) + if (!corked) TEST_ERROR /* Uncork the second opened named datatype */ - if(H5Oenable_mdc_flushes(tid2) < 0) + if (H5Oenable_mdc_flushes(tid2) < 0) TEST_ERROR /* Check cork status of the second opened named datatype */ - if(H5Oare_mdc_flushes_disabled(tid2, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid2, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Check cork status of the first opened named datatype */ - if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(tid1, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Close the first opened datatype */ - if(H5Tclose(tid1) < 0) + if (H5Tclose(tid1) < 0) TEST_ERROR /* Close the second opened datatype */ - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) TEST_ERROR /* Check cork status of the group */ - if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0) + if (H5Oare_mdc_flushes_disabled(gid, &corked) < 0) TEST_ERROR - if(corked) + if (corked) TEST_ERROR /* Closing */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR HDfree(wbuf); @@ -2155,7 +2198,8 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Dclose(did1); H5Dclose(did2); @@ -2165,7 +2209,8 @@ error: H5Gclose(gid); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(wbuf); HDfree(wbuf_data); @@ -2175,8 +2220,6 @@ error: } /* test_dset_cork() */ - - /*------------------------------------------------------------------------- * Function: main * @@ -2193,13 +2236,13 @@ error: int main(void) { - unsigned swmr; /* Loop over SWMR/non-SWMR */ - unsigned nerrs = 0; /* Error Encountered */ + unsigned swmr; /* Loop over SWMR/non-SWMR */ + unsigned nerrs = 0; /* Error Encountered */ /* Test for dataset created with old library format */ nerrs += verify_old_dset_cork(); - for(swmr = 0; swmr <= 1; swmr++) { + for (swmr = 0; swmr <= 1; swmr++) { /* Tests with new/old library format */ /* This is the test moved from th5o.c: test_h5o_cork() */ nerrs += test_objs_cork(swmr, TRUE); @@ -2221,6 +2264,5 @@ main(void) HDremove(FILENAME); /* Return Errors */ - return(nerrs > 0); + return (nerrs > 0); } /* main */ - diff --git a/test/cross_read.c b/test/cross_read.c index c16ddbc..0edaa0f 100644 --- a/test/cross_read.c +++ b/test/cross_read.c @@ -22,45 +22,39 @@ #include "h5test.h" #include "H5srcdir.h" -const char *FILENAME[] = { - "vms_data", - "le_data", - "be_data", - NULL -}; - -#define DATASETNAME "Array_le" -#define DATASETNAME1 "Array_be" -#define DATASETNAME2 "Scale_offset_float_data_le" -#define DATASETNAME3 "Scale_offset_float_data_be" -#define DATASETNAME4 "Scale_offset_double_data_le" -#define DATASETNAME5 "Scale_offset_double_data_be" -#define DATASETNAME6 "Scale_offset_char_data_le" -#define DATASETNAME7 "Scale_offset_char_data_be" -#define DATASETNAME8 "Scale_offset_short_data_le" -#define DATASETNAME9 "Scale_offset_short_data_be" -#define DATASETNAME10 "Scale_offset_int_data_le" -#define DATASETNAME11 "Scale_offset_int_data_be" -#define DATASETNAME12 "Scale_offset_long_long_data_le" -#define DATASETNAME13 "Scale_offset_long_long_data_be" - -#define DATASETNAME14 "Fletcher_float_data_le" -#define DATASETNAME15 "Fletcher_float_data_be" -#define DATASETNAME16 "Deflate_float_data_le" -#define DATASETNAME17 "Deflate_float_data_be" +const char *FILENAME[] = {"vms_data", "le_data", "be_data", NULL}; + +#define DATASETNAME "Array_le" +#define DATASETNAME1 "Array_be" +#define DATASETNAME2 "Scale_offset_float_data_le" +#define DATASETNAME3 "Scale_offset_float_data_be" +#define DATASETNAME4 "Scale_offset_double_data_le" +#define DATASETNAME5 "Scale_offset_double_data_be" +#define DATASETNAME6 "Scale_offset_char_data_le" +#define DATASETNAME7 "Scale_offset_char_data_be" +#define DATASETNAME8 "Scale_offset_short_data_le" +#define DATASETNAME9 "Scale_offset_short_data_be" +#define DATASETNAME10 "Scale_offset_int_data_le" +#define DATASETNAME11 "Scale_offset_int_data_be" +#define DATASETNAME12 "Scale_offset_long_long_data_le" +#define DATASETNAME13 "Scale_offset_long_long_data_be" + +#define DATASETNAME14 "Fletcher_float_data_le" +#define DATASETNAME15 "Fletcher_float_data_be" +#define DATASETNAME16 "Deflate_float_data_le" +#define DATASETNAME17 "Deflate_float_data_be" #ifdef H5_HAVE_FILTER_SZIP -#define DATASETNAME18 "Szip_float_data_le" -#define DATASETNAME19 "Szip_float_data_be" +#define DATASETNAME18 "Szip_float_data_le" +#define DATASETNAME19 "Szip_float_data_be" #endif /* H5_HAVE_FILTER_SZIP */ -#define DATASETNAME20 "Shuffle_float_data_le" -#define DATASETNAME21 "Shuffle_float_data_be" -#define DATASETNAME22 "Nbit_float_data_le" -#define DATASETNAME23 "Nbit_float_data_be" +#define DATASETNAME20 "Shuffle_float_data_le" +#define DATASETNAME21 "Shuffle_float_data_be" +#define DATASETNAME22 "Nbit_float_data_le" +#define DATASETNAME23 "Nbit_float_data_be" -#define NX 6 -#define NY 6 +#define NX 6 +#define NY 6 - /*------------------------------------------------------------------------- * Function: check_data_i * @@ -77,49 +71,49 @@ const char *FILENAME[] = { static int check_data_i(const char *dsetname, hid_t fid) { - hid_t did = -1; /* dataset ID */ - long long data_in[NX+1][NY]; /* input buffer */ - long long data_out[NX+1][NY]; /* output buffer */ - int i, j; /* iterators */ - int nerrors = 0; /* # errors in dataset values */ + hid_t did = -1; /* dataset ID */ + long long data_in[NX + 1][NY]; /* input buffer */ + long long data_out[NX + 1][NY]; /* output buffer */ + int i, j; /* iterators */ + int nerrors = 0; /* # errors in dataset values */ /* Open the dataset. */ - if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Initialization. */ /* Input (last row is different) */ - for(i = 0; i < NX; i++) - for(j = 0; j < NY; j++) + for (i = 0; i < NX; i++) + for (j = 0; j < NY; j++) data_in[i][j] = i + j; - for(i = 0; i < NY; i++) + for (i = 0; i < NY; i++) data_in[NX][i] = -2; /* Output */ - HDmemset(data_out, 0, (NX+1) * NY * sizeof(long long)); + HDmemset(data_out, 0, (NX + 1) * NY * sizeof(long long)); /* Read data from hyperslab in the file into the hyperslab in * memory and display. */ - if(H5Dread(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_out) < 0) + if (H5Dread(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_out) < 0) FAIL_STACK_ERROR; /* Check results */ - for(i = 0; i < (NX + 1); i++) - for(j = 0; j < NY; j++) - if(data_out[i][j] != data_in[i][j]) - if(!nerrors++) { + for (i = 0; i < (NX + 1); i++) + for (j = 0; j < NY; j++) + if (data_out[i][j] != data_in[i][j]) + if (!nerrors++) { H5_FAILED(); - HDprintf("element [%d][%d] is %lld but should have been %lld\n", - (int)i, (int)j, data_out[i][j], data_in[i][j]); + HDprintf("element [%d][%d] is %lld but should have been %lld\n", (int)i, (int)j, + data_out[i][j], data_in[i][j]); } /* end if */ /* Close/release resources. */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Failure */ - if(nerrors) { - HDprintf("total of %d errors out of %d elements\n", nerrors, (int)(NX*NY)); + if (nerrors) { + HDprintf("total of %d errors out of %d elements\n", nerrors, (int)(NX * NY)); return 1; } /* end if */ @@ -127,13 +121,14 @@ check_data_i(const char *dsetname, hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end check_data_i() */ - /*------------------------------------------------------------------------- * Function: check_data_f * @@ -150,49 +145,49 @@ error: static int check_data_f(const char *dsetname, hid_t fid) { - hid_t did = -1; /* dataset ID */ - double data_in[NX+1][NY]; /* input buffer */ - double data_out[NX+1][NY]; /* output buffer */ - int i, j; /* iterators */ - int nerrors = 0; /* # of errors in dataset values */ + hid_t did = -1; /* dataset ID */ + double data_in[NX + 1][NY]; /* input buffer */ + double data_out[NX + 1][NY]; /* output buffer */ + int i, j; /* iterators */ + int nerrors = 0; /* # of errors in dataset values */ /* Open the dataset. */ - if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Initialization. */ /* Input (last row is different) */ - for(i = 0; i < NX; i++) - for(j = 0; j < NY; j++) + for (i = 0; i < NX; i++) + for (j = 0; j < NY; j++) data_in[i][j] = ((double)(i + j + 1)) / (double)3.0F; - for(i = 0; i < NY; i++) + for (i = 0; i < NY; i++) data_in[NX][i] = -2.2F; /* Output */ - HDmemset(data_out, 0, (NX+1) * NY * sizeof(double)); + HDmemset(data_out, 0, (NX + 1) * NY * sizeof(double)); /* Read data from hyperslab in the file into the hyperslab in * memory and display. */ - if(H5Dread(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_out) < 0) + if (H5Dread(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_out) < 0) FAIL_STACK_ERROR; /* Check results */ - for(i = 0; i < (NX + 1); i++) - for(j = 0; j < NY; j++) - if(!H5_DBL_REL_EQUAL(data_out[i][j], data_in[i][j], (double)0.001F)) - if(!nerrors++) { + for (i = 0; i < (NX + 1); i++) + for (j = 0; j < NY; j++) + if (!H5_DBL_REL_EQUAL(data_out[i][j], data_in[i][j], (double)0.001F)) + if (!nerrors++) { H5_FAILED(); - HDprintf("element [%d][%d] is %g but should have been %g\n", - (int)i, (int)j, data_out[i][j], data_in[i][j]); + HDprintf("element [%d][%d] is %g but should have been %g\n", (int)i, (int)j, + data_out[i][j], data_in[i][j]); } /* end if */ /* Close/release resources. */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Failure */ - if(nerrors) { - HDprintf("total of %d errors out of %d elements\n", nerrors, (int)(NX*NY)); + if (nerrors) { + HDprintf("total of %d errors out of %d elements\n", nerrors, (int)(NX * NY)); return 1; } /* end if */ @@ -200,13 +195,14 @@ check_data_f(const char *dsetname, hid_t fid) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end check_data_f() */ - /*------------------------------------------------------------------------- * Function: check_file * @@ -223,15 +219,15 @@ error: static int check_file(char *filename) { - const char *pathname = H5_get_srcdir_filename(filename); /* Corrected test file name */ - hid_t fid = -1; /* file ID */ - int nerrors = 0; /* # of datasets with errors */ + const char *pathname = H5_get_srcdir_filename(filename); /* Corrected test file name */ + hid_t fid = -1; /* file ID */ + int nerrors = 0; /* # of datasets with errors */ #if !defined(H5_HAVE_FILTER_DEFLATE) || !defined(H5_HAVE_FILTER_SZIP) - const char *not_supported= " filter is not enabled."; /* no filter message */ + const char *not_supported = " filter is not enabled."; /* no filter message */ #endif /* Open the file. */ - if((fid = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; TESTING("regular dataset of LE DOUBLE"); @@ -285,7 +281,7 @@ check_file(char *filename) TESTING("dataset of LE FLOAT with Deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE nerrors += check_data_f(DATASETNAME16, fid); -#else /*H5_HAVE_FILTER_DEFLATE*/ +#else /*H5_HAVE_FILTER_DEFLATE*/ SKIPPED(); HDputs(not_supported); #endif /*H5_HAVE_FILTER_DEFLATE*/ @@ -293,7 +289,7 @@ check_file(char *filename) TESTING("dataset of BE FLOAT with Deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE nerrors += check_data_f(DATASETNAME17, fid); -#else /*H5_HAVE_FILTER_DEFLATE*/ +#else /*H5_HAVE_FILTER_DEFLATE*/ SKIPPED(); HDputs(not_supported); #endif /*H5_HAVE_FILTER_DEFLATE*/ @@ -301,7 +297,7 @@ check_file(char *filename) TESTING("dataset of LE FLOAT with Szip filter"); #ifdef H5_HAVE_FILTER_SZIP nerrors += check_data_f(DATASETNAME18, fid); -#else /*H5_HAVE_FILTER_SZIP*/ +#else /*H5_HAVE_FILTER_SZIP*/ SKIPPED(); HDputs(not_supported); #endif /*H5_HAVE_FILTER_SZIP*/ @@ -309,7 +305,7 @@ check_file(char *filename) TESTING("dataset of BE FLOAT with Szip filter"); #ifdef H5_HAVE_FILTER_SZIP nerrors += check_data_f(DATASETNAME19, fid); -#else /*H5_HAVE_FILTER_SZIP*/ +#else /*H5_HAVE_FILTER_SZIP*/ SKIPPED(); HDputs(not_supported); #endif /*H5_HAVE_FILTER_SZIP*/ @@ -326,18 +322,19 @@ check_file(char *filename) TESTING("dataset of BE FLOAT with Nbit filter"); nerrors += check_data_f(DATASETNAME23, fid); - if(H5Fclose(fid)) + if (H5Fclose(fid)) FAIL_STACK_ERROR return nerrors; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return nerrors; } /* end check_file() */ - /*------------------------------------------------------------------------- * Function: main * @@ -353,8 +350,8 @@ error: int main(void) { - char filename[1024]; - int nerrors = 0; + char filename[1024]; + int nerrors = 0; h5_reset(); @@ -368,7 +365,7 @@ main(void) h5_fixname(FILENAME[2], H5P_DEFAULT, filename, sizeof(filename)); nerrors += check_file(filename); - if(nerrors) { + if (nerrors) { HDprintf("***** %d FAILURE%s! *****\n", nerrors, 1 == nerrors ? "" : "S"); return EXIT_FAILURE; } /* end if */ @@ -376,4 +373,3 @@ main(void) HDprintf("All data type tests passed.\n"); return EXIT_SUCCESS; } /* end main() */ - diff --git a/test/dangle.c b/test/dangle.c index 9f30f10..d241a4a 100644 --- a/test/dangle.c +++ b/test/dangle.c @@ -19,18 +19,14 @@ */ #include "h5test.h" -const char *FILENAME[] = { - "dangle", - NULL -}; +const char *FILENAME[] = {"dangle", NULL}; -#define MAX_DANGLE 1000 - -#define DSETNAME "Dataset" -#define GROUPNAME "Group" -#define TYPENAME "Type" -#define ATTRNAME "Attribute" +#define MAX_DANGLE 1000 +#define DSETNAME "Dataset" +#define GROUPNAME "Group" +#define TYPENAME "Type" +#define ATTRNAME "Attribute" /*------------------------------------------------------------------------- * Function: test_dangle_dataset @@ -51,70 +47,74 @@ const char *FILENAME[] = { static int test_dangle_dataset(H5F_close_degree_t degree) { - char filename[1024]; - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - hid_t dsid; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - unsigned u; /* Local index variable */ + char filename[1024]; + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + hid_t dsid; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + unsigned u; /* Local index variable */ TESTING(" dangling dataset IDs"); - if(H5open() < 0) + if (H5open() < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set file close degree */ - if(H5Pset_fclose_degree(fapl, degree) < 0) + if (H5Pset_fclose_degree(fapl, degree) < 0) TEST_ERROR; h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR; - if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) TEST_ERROR; /* Try creating duplicate dataset */ - H5E_BEGIN_TRY { - if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) + H5E_BEGIN_TRY + { + if ((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= + 0) TEST_ERROR; - } H5E_END_TRY; + } + H5E_END_TRY; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; /* Leave open a _lot_ of objects */ - for(u = 0; u < MAX_DANGLE; u++) - if((dsid = H5Dopen2(fid, DSETNAME, H5P_DEFAULT)) < 0) + for (u = 0; u < MAX_DANGLE; u++) + if ((dsid = H5Dopen2(fid, DSETNAME, H5P_DEFAULT)) < 0) TEST_ERROR; - if(degree == H5F_CLOSE_SEMI) { - H5E_BEGIN_TRY { - if(H5Fclose(fid) >= 0) + if (degree == H5F_CLOSE_SEMI) { + H5E_BEGIN_TRY + { + if (H5Fclose(fid) >= 0) TEST_ERROR; - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ - else - if(H5Fclose(fid) < 0) - TEST_ERROR; + else if (H5Fclose(fid) < 0) + TEST_ERROR; - if(h5_get_file_size(filename, fapl) < 0) + if (h5_get_file_size(filename, fapl) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; - if(H5close() < 0) + if (H5close() < 0) TEST_ERROR; /* Clean up temporary file */ @@ -127,7 +127,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_dangle_group * @@ -147,65 +146,70 @@ error: static int test_dangle_group(H5F_close_degree_t degree) { - char filename[1024]; - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - hid_t gid; /* Group ID */ - unsigned u; /* Local index variable */ + char filename[1024]; + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + hid_t gid; /* Group ID */ + unsigned u; /* Local index variable */ TESTING(" dangling group IDs"); - if(H5open() < 0) + if (H5open() < 0) TEST_ERROR; /* Create file access property list */ - if((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set file close degree */ - if(H5Pset_fclose_degree(fapl,degree) < 0) + if (H5Pset_fclose_degree(fapl, degree) < 0) TEST_ERROR; h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - if((fid = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR; /* Try creating duplicate group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(gid >= 0) TEST_ERROR + } + H5E_END_TRY; + if (gid >= 0) + TEST_ERROR /* Leave open a _lot_ of objects */ - for(u = 0; u < MAX_DANGLE; u++) - if((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) + for (u = 0; u < MAX_DANGLE; u++) + if ((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, GROUPNAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(degree==H5F_CLOSE_SEMI) { - H5E_BEGIN_TRY { - if(H5Fclose(fid)>=0) + if (degree == H5F_CLOSE_SEMI) { + H5E_BEGIN_TRY + { + if (H5Fclose(fid) >= 0) TEST_ERROR; - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ - else - if(H5Fclose(fid) < 0) - TEST_ERROR; + else if (H5Fclose(fid) < 0) + TEST_ERROR; - if(h5_get_file_size(filename, fapl) < 0) + if (h5_get_file_size(filename, fapl) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; - if(H5close() < 0) + if (H5close() < 0) TEST_ERROR; /* Clean up temporary file */ @@ -218,7 +222,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_dangle_datatype1 * @@ -238,70 +241,73 @@ error: static int test_dangle_datatype1(H5F_close_degree_t degree) { - char filename[1024]; - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - hid_t tid; /* Datatype ID */ - unsigned u; /* Local index variable */ + char filename[1024]; + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + hid_t tid; /* Datatype ID */ + unsigned u; /* Local index variable */ TESTING(" dangling named datatype IDs"); - if(H5open() < 0) + if (H5open() < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set file close degree */ - if(H5Pset_fclose_degree(fapl, degree) < 0) + if (H5Pset_fclose_degree(fapl, degree) < 0) TEST_ERROR; h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR; - if(H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) TEST_ERROR; /* Try creating duplicate named datatype */ - if((tid = H5Tcopy (H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR; - H5E_BEGIN_TRY { - if(H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) >= 0) + H5E_BEGIN_TRY + { + if (H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR; - } H5E_END_TRY; - if(H5Tclose(tid) < 0) + } + H5E_END_TRY; + if (H5Tclose(tid) < 0) TEST_ERROR; /* Leave open a _lot_ of objects */ - for(u = 0; u < MAX_DANGLE; u++) - if((tid = H5Topen2(fid, TYPENAME, H5P_DEFAULT)) < 0) + for (u = 0; u < MAX_DANGLE; u++) + if ((tid = H5Topen2(fid, TYPENAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(degree == H5F_CLOSE_SEMI) { - H5E_BEGIN_TRY { - if(H5Fclose(fid) >= 0) + if (degree == H5F_CLOSE_SEMI) { + H5E_BEGIN_TRY + { + if (H5Fclose(fid) >= 0) TEST_ERROR; - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ - else - if(H5Fclose(fid) < 0) - TEST_ERROR; + else if (H5Fclose(fid) < 0) + TEST_ERROR; - if(h5_get_file_size(filename, fapl) < 0) + if (h5_get_file_size(filename, fapl) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; - if(H5close() < 0) + if (H5close() < 0) TEST_ERROR; /* Clean up temporary file */ @@ -314,7 +320,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_dangle_datatype2 * @@ -334,61 +339,62 @@ error: static int test_dangle_datatype2(H5F_close_degree_t degree) { - char filename[1024]; - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ + char filename[1024]; + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ TESTING(" dangling named datatype ID used by dataset"); - if(H5open() < 0) + if (H5open() < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set file close degree */ - if(H5Pset_fclose_degree(fapl, degree) < 0) + if (H5Pset_fclose_degree(fapl, degree) < 0) TEST_ERROR; h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR; - if(H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* Create a dataset that uses the named datatype & leave it open */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR; - if((did = H5Dcreate2(fid, DSETNAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSETNAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(degree == H5F_CLOSE_SEMI) { - H5E_BEGIN_TRY { - if(H5Fclose(fid) >= 0) + if (degree == H5F_CLOSE_SEMI) { + H5E_BEGIN_TRY + { + if (H5Fclose(fid) >= 0) TEST_ERROR; - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ - else - if(H5Fclose(fid) < 0) - TEST_ERROR; + else if (H5Fclose(fid) < 0) + TEST_ERROR; - if(h5_get_file_size(filename, fapl) < 0) + if (h5_get_file_size(filename, fapl) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; - if(H5close() < 0) + if (H5close() < 0) TEST_ERROR; /* Clean up temporary file */ @@ -401,7 +407,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_dangle_attribute * @@ -421,81 +426,84 @@ error: static int test_dangle_attribute(H5F_close_degree_t degree) { - char filename[1024]; - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - hid_t dsid; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t aid; /* Attribute ID */ - unsigned u; /* Local index variable */ + char filename[1024]; + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + hid_t dsid; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t aid; /* Attribute ID */ + unsigned u; /* Local index variable */ TESTING(" dangling attribute IDs"); - if(H5open() < 0) + if (H5open() < 0) TEST_ERROR; /* Create file access property list */ - if((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set file close degree */ - if(H5Pset_fclose_degree(fapl,degree) < 0) + if (H5Pset_fclose_degree(fapl, degree) < 0) TEST_ERROR; h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR; - if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create an attribute on the dataset */ - if((aid = H5Acreate2(dsid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Don't worry about writing the attribute - it will have a fill value */ /* Close the attribute on the dataset */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR; /* Try creating duplicate attribute */ - H5E_BEGIN_TRY { - if((aid = H5Acreate2(dsid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) >= 0) + H5E_BEGIN_TRY + { + if ((aid = H5Acreate2(dsid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) >= 0) TEST_ERROR; - } H5E_END_TRY; + } + H5E_END_TRY; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; /* Leave open a _lot_ of objects */ - for(u = 0; u < MAX_DANGLE; u++) - if((aid = H5Aopen(dsid, ATTRNAME, H5P_DEFAULT)) < 0) + for (u = 0; u < MAX_DANGLE; u++) + if ((aid = H5Aopen(dsid, ATTRNAME, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) TEST_ERROR - if(degree == H5F_CLOSE_SEMI) { - H5E_BEGIN_TRY { - if(H5Fclose(fid) >= 0) + if (degree == H5F_CLOSE_SEMI) { + H5E_BEGIN_TRY + { + if (H5Fclose(fid) >= 0) TEST_ERROR; - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ - else - if(H5Fclose(fid) < 0) - TEST_ERROR; + else if (H5Fclose(fid) < 0) + TEST_ERROR; - if(h5_get_file_size(filename, fapl) < 0) + if (h5_get_file_size(filename, fapl) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; - if(H5close() < 0) + if (H5close() < 0) TEST_ERROR; /* Clean up temporary file */ @@ -508,7 +516,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_dangle_force * @@ -527,97 +534,97 @@ static int test_dangle_force(void) { char filename[1024]; - hid_t fid; /* File ID */ - hid_t gid, gid2; /* Group IDs */ - hid_t dsid, dsid2; /* Dataset IDs */ - hid_t sid; /* Dataspace ID */ - hid_t aid, aid2; /* Attribute IDs */ - hid_t tid, tid2; /* Named datatype IDs */ - ssize_t count; /* Count of open objects */ - hid_t *objs = NULL; /* Pointer to list of open objects */ - size_t u; /* Local index variable */ + hid_t fid; /* File ID */ + hid_t gid, gid2; /* Group IDs */ + hid_t dsid, dsid2; /* Dataset IDs */ + hid_t sid; /* Dataspace ID */ + hid_t aid, aid2; /* Attribute IDs */ + hid_t tid, tid2; /* Named datatype IDs */ + ssize_t count; /* Count of open objects */ + hid_t * objs = NULL; /* Pointer to list of open objects */ + size_t u; /* Local index variable */ TESTING("force dangling IDs to close, from API routines"); h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create a dataspace for the dataset & attribute to use */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR /* Create a dataset */ - if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Re-open the dataset */ - if((dsid2 = H5Dopen2(fid, DSETNAME, H5P_DEFAULT)) < 0) + if ((dsid2 = H5Dopen2(fid, DSETNAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create an attribute on the dataset */ - if((aid = H5Acreate2(dsid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Re-open the attribute */ - if((aid2 = H5Aopen(dsid, ATTRNAME, H5P_DEFAULT)) < 0) + if ((aid2 = H5Aopen(dsid, ATTRNAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close the dataspace ID */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR /* Open a group ID */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Open group again */ - if((gid2 = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + if ((gid2 = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create a named datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR - if(H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Re-open the named datatype */ - if((tid2 = H5Topen2(fid, TYPENAME, H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(fid, TYPENAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Increment the ref count on all the "second" objects */ - if(H5Iinc_ref(dsid2) < 0) + if (H5Iinc_ref(dsid2) < 0) FAIL_STACK_ERROR - if(H5Iinc_ref(aid2) < 0) + if (H5Iinc_ref(aid2) < 0) FAIL_STACK_ERROR - if(H5Iinc_ref(gid2) < 0) + if (H5Iinc_ref(gid2) < 0) FAIL_STACK_ERROR - if(H5Iinc_ref(aid2) < 0) + if (H5Iinc_ref(aid2) < 0) FAIL_STACK_ERROR /* Get the number of open objects */ - if((count = H5Fget_obj_count((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL)) < 0) + if ((count = H5Fget_obj_count((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL)) < 0) FAIL_STACK_ERROR - if(0 == count) + if (0 == count) TEST_ERROR; /* Allocate the array of object IDs */ - if(NULL == (objs = (hid_t *)HDcalloc((size_t)count, sizeof(hid_t)))) + if (NULL == (objs = (hid_t *)HDcalloc((size_t)count, sizeof(hid_t)))) TEST_ERROR; /* Get the list of open IDs */ - if(H5Fget_obj_ids((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)count, objs) < 0) + if (H5Fget_obj_ids((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)count, objs) < 0) FAIL_STACK_ERROR /* Close all open IDs */ - for(u = 0; u < (size_t)count; u++) - while(H5Iget_type(objs[u]) != H5I_BADID && H5Iget_ref(objs[u]) > 0) + for (u = 0; u < (size_t)count; u++) + while (H5Iget_type(objs[u]) != H5I_BADID && H5Iget_ref(objs[u]) > 0) H5Idec_ref(objs[u]); /* Get the number of open objects */ - if((count = H5Fget_obj_count((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL)) < 0) + if ((count = H5Fget_obj_count((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL)) < 0) FAIL_STACK_ERROR - if(0 != count) + if (0 != count) TEST_ERROR; /* Clean up temporary file */ @@ -630,12 +637,11 @@ test_dangle_force(void) return 0; error: - if(objs) + if (objs) HDfree(objs); return 1; } - /*------------------------------------------------------------------------- * Function: main * @@ -654,7 +660,7 @@ error: int main(void) { - int nerrors=0; + int nerrors = 0; /* Run tests w/weak file close */ puts("Testing dangling objects with weak file close:"); @@ -694,4 +700,3 @@ error: puts("***** DANGLING ID TESTS FAILED *****"); return 1; } - diff --git a/test/del_many_dense_attrs.c b/test/del_many_dense_attrs.c index 6f48901..95b5854 100644 --- a/test/del_many_dense_attrs.c +++ b/test/del_many_dense_attrs.c @@ -17,16 +17,12 @@ * (See HDFFV-10659). */ - #include "h5test.h" /* The test file name */ -const char *FILENAME[] = { - "del_many_dense_attrs", - NULL -}; +const char *FILENAME[] = {"del_many_dense_attrs", NULL}; -#define ATTR_COUNT 64 /* The number of attributes */ +#define ATTR_COUNT 64 /* The number of attributes */ /*------------------------------------------------------------------------- * Function: catch_signal @@ -39,12 +35,12 @@ const char *FILENAME[] = { * *------------------------------------------------------------------------- */ -static void catch_signal(int H5_ATTR_UNUSED signo) +static void +catch_signal(int H5_ATTR_UNUSED signo) { HDexit(EXIT_FAILURE); } /* catch_signal() */ - /*------------------------------------------------------------------------- * Function: main * @@ -62,108 +58,108 @@ static void catch_signal(int H5_ATTR_UNUSED signo) int main(void) { - hid_t fid = -1; /* HDF5 File ID */ - hid_t gid = -1; /* Group ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t fapl = -1; /* File access property lists */ - hid_t gcpl = -1; /* Group creation property list */ - char aname[50]; /* Name of attribute */ - const char *basename="attr"; /* Name prefix for attribute */ - char filename[100]; /* File name */ - int i; /* Local index variable */ + hid_t fid = -1; /* HDF5 File ID */ + hid_t gid = -1; /* Group ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t fapl = -1; /* File access property lists */ + hid_t gcpl = -1; /* Group creation property list */ + char aname[50]; /* Name of attribute */ + const char *basename = "attr"; /* Name prefix for attribute */ + char filename[100]; /* File name */ + int i; /* Local index variable */ /* Testing setup */ h5_reset(); /* To exit from the file for SIGABRT signal */ - if(HDsignal(SIGABRT, catch_signal) == SIG_ERR) - TEST_ERROR + if (HDsignal(SIGABRT, catch_signal) == SIG_ERR) + TEST_ERROR fapl = h5_fileaccess(); h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Set to latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR /* Create the file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR - /* Re-open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + /* Re-open the file */ + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create the group creation property list */ - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + if ((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR /* Set to use dense storage for all attributes on the group */ - if(H5Pset_attr_phase_change(gcpl, 0, 0) < 0) + if (H5Pset_attr_phase_change(gcpl, 0, 0) < 0) TEST_ERROR /* Create the group in the file */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Create dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR /* Get a copy of the datatype */ - if((tid = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) TEST_ERROR /* Create attributes in the group */ - for(i = ATTR_COUNT; i >= 0; i--) { + for (i = ATTR_COUNT; i >= 0; i--) { /* Set up the attribute name */ HDsprintf(aname, "%s%d", basename, i); /* Create the attribute */ - if((aid = H5Acreate2(gid, aname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(gid, aname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Write to the attribute */ - if(H5Awrite(aid, tid, &i) < 0) + if (H5Awrite(aid, tid, &i) < 0) TEST_ERROR /* Close the attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR } /* Close the datatype */ - if(H5Tclose(tid) < 0) - TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Close the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl) < 0) + if (H5Pclose(gcpl) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Re-open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Open the group */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) TEST_ERROR /* Delete the attributes */ @@ -172,24 +168,25 @@ main(void) HDsprintf(aname, "%s%d", basename, i); /* Delete the attribute */ - if(H5Adelete(gid, aname) < 0) + if (H5Adelete(gid, aname) < 0) TEST_ERROR } /* end for */ /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR h5_cleanup(FILENAME, fapl); - return(EXIT_SUCCESS); + return (EXIT_SUCCESS); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Sclose(sid); H5Tclose(tid); @@ -197,7 +194,8 @@ error: H5Fclose(fid); H5Pclose(gcpl); H5Pclose(fapl); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } diff --git a/test/direct_chunk.c b/test/direct_chunk.c index 2e6cc68..a860b81 100644 --- a/test/direct_chunk.c +++ b/test/direct_chunk.c @@ -1,62 +1,62 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "h5test.h" #if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) -# define H5_ZLIB_HEADER "zlib.h" +#define H5_ZLIB_HEADER "zlib.h" #endif #if defined(H5_ZLIB_HEADER) -# include H5_ZLIB_HEADER /* "zlib.h" */ +#include H5_ZLIB_HEADER /* "zlib.h" */ #endif #define FILE_NAME "direct_chunk.h5" /* Datasets for Direct Write tests */ -#define DATASETNAME1 "direct_write" -#define DATASETNAME2 "skip_one_filter" -#define DATASETNAME3 "skip_two_filters" -#define DATASETNAME4 "data_conv" -#define DATASETNAME5 "contiguous_dset" -#define DATASETNAME6 "invalid_argue" -#define DATASETNAME7 "overwrite_chunk" +#define DATASETNAME1 "direct_write" +#define DATASETNAME2 "skip_one_filter" +#define DATASETNAME3 "skip_two_filters" +#define DATASETNAME4 "data_conv" +#define DATASETNAME5 "contiguous_dset" +#define DATASETNAME6 "invalid_argue" +#define DATASETNAME7 "overwrite_chunk" /* Datasets for Direct Read tests */ -#define DATASETNAME8 "disabled_chunk_cache" -#define DATASETNAME9 "flush_chunk_cache" -#define DATASETNAME10 "read_w_valid_cache" -#define DATASETNAME11 "unallocated_chunk" -#define DATASETNAME12 "unfiltered_data" +#define DATASETNAME8 "disabled_chunk_cache" +#define DATASETNAME9 "flush_chunk_cache" +#define DATASETNAME10 "read_w_valid_cache" +#define DATASETNAME11 "unallocated_chunk" +#define DATASETNAME12 "unfiltered_data" -#define RANK 2 -#define NX 16 -#define NY 16 -#define CHUNK_NX 4 -#define CHUNK_NY 4 +#define RANK 2 +#define NX 16 +#define NY 16 +#define CHUNK_NX 4 +#define CHUNK_NY 4 -#define DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s))*1.001)+12.0) +#define DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * 1.001) + 12.0) /* Temporary filter IDs used for testing */ -#define H5Z_FILTER_BOGUS1 305 -#define H5Z_FILTER_BOGUS2 306 +#define H5Z_FILTER_BOGUS1 305 +#define H5Z_FILTER_BOGUS2 306 #define ADD_ON 7 #define FACTOR 3 /* Constants for the overwrite test */ -#define OVERWRITE_NDIMS 3 -#define OVERWRITE_CHUNK_NX 3 -#define OVERWRITE_CHUNK_2NX 6 -#define OVERWRITE_CHUNK_NY 2 -#define OVERWRITE_VALUE 42 +#define OVERWRITE_NDIMS 3 +#define OVERWRITE_CHUNK_NX 3 +#define OVERWRITE_CHUNK_2NX 6 +#define OVERWRITE_CHUNK_NY 2 +#define OVERWRITE_VALUE 42 /* Test configurations */ #define CONFIG_LATEST 0x01 @@ -67,38 +67,38 @@ #define CONFIG_END 0x20 /* Defines used in test_single_chunk_latest() */ -#define FILE "single_latest.h5" -#define DATASET "dataset" -#define DIM0 4 -#define DIM1 32 -#define CHUNK0 DIM0 -#define CHUNK1 DIM1 +#define FILE "single_latest.h5" +#define DATASET "dataset" +#define DIM0 4 +#define DIM1 32 +#define CHUNK0 DIM0 +#define CHUNK1 DIM1 /* Local prototypes for filter functions */ -static size_t filter_bogus1(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); -static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus1(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS1[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS1, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "bogus1", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_bogus1, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS1, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus1", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_bogus1, /* The actual filter function */ }}; const H5Z_class2_t H5Z_BOGUS2[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS2, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "bogus2", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_bogus2, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS2, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus2", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_bogus2, /* The actual filter function */ }}; /*------------------------------------------------------------------------- @@ -116,31 +116,31 @@ const H5Z_class2_t H5Z_BOGUS2[1] = {{ */ #ifdef H5_HAVE_FILTER_DEFLATE static int -test_direct_chunk_write (hid_t file) +test_direct_chunk_write(hid_t file) { - hid_t dataspace = -1, dataset = -1; - hid_t mem_space = -1; - hid_t cparms = -1, dxpl = -1; - hsize_t dims[2] = {NX, NY}; - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY}; - herr_t status; - int ret; - int data[NX][NY]; - int i, j, n; - - unsigned filter_mask = 0; - int direct_buf[CHUNK_NX][CHUNK_NY]; - int check_chunk[CHUNK_NX][CHUNK_NY]; - hsize_t offset[2] = {0, 0}; - size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int); - - const Bytef *z_src = (const Bytef*)(direct_buf); - Bytef *z_dst = NULL; /*destination buffer */ - uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); - uLong z_src_nbytes = (uLong)buf_size; - int aggression = 9; /* Compression aggression setting */ - void *outbuf = NULL; /* Pointer to new buffer */ + hid_t dataspace = -1, dataset = -1; + hid_t mem_space = -1; + hid_t cparms = -1, dxpl = -1; + hsize_t dims[2] = {NX, NY}; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; + herr_t status; + int ret; + int data[NX][NY]; + int i, j, n; + + unsigned filter_mask = 0; + int direct_buf[CHUNK_NX][CHUNK_NY]; + int check_chunk[CHUNK_NX][CHUNK_NY]; + hsize_t offset[2] = {0, 0}; + size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int); + + const Bytef *z_src = (const Bytef *)(direct_buf); + Bytef * z_dst = NULL; /*destination buffer */ + uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); + uLong z_src_nbytes = (uLong)buf_size; + int aggression = 9; /* Compression aggression setting */ + void * outbuf = NULL; /* Pointer to new buffer */ hsize_t start[2]; /* Start of hyperslab */ hsize_t stride[2]; /* Stride of hyperslab */ @@ -152,76 +152,77 @@ test_direct_chunk_write (hid_t file) /* * Create the data space with unlimited dimensions. */ - if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) goto error; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) goto error; /* * Modify dataset creation properties, i.e. enable chunking and compression */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) + if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0) goto error; - if((status = H5Pset_deflate( cparms, (unsigned) aggression)) < 0) + if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0) goto error; /* * Create a new dataset within the file using cparms * creation properties. */ - if((dataset = H5Dcreate2(file, DATASETNAME1, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, DATASETNAME1, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) goto error; /* Initialize the dataset */ - for(i = n = 0; i < NX; i++) - for(j = 0; j < NY; j++) - data[i][j] = n++; + for (i = n = 0; i < NX; i++) + for (j = 0; j < NY; j++) + data[i][j] = n++; - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; /* * Write the data for the dataset. It should stay in the chunk cache. * It will be evicted from the cache by the H5Dwrite_chunk calls. */ - if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl, data)) < 0) + if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, data)) < 0) goto error; /* Initialize data for one chunk */ - for(i = n = 0; i < CHUNK_NX; i++) - for(j = 0; j < CHUNK_NY; j++) - direct_buf[i][j] = n++; + for (i = n = 0; i < CHUNK_NX; i++) + for (j = 0; j < CHUNK_NY; j++) + direct_buf[i][j] = n++; /* Allocate output (compressed) buffer */ outbuf = HDmalloc(z_dst_nbytes); - z_dst = (Bytef *)outbuf; + z_dst = (Bytef *)outbuf; /* Perform compression from the source to the destination buffer */ ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); /* Check for various zlib errors */ - if(Z_BUF_ERROR == ret) { + if (Z_BUF_ERROR == ret) { HDfprintf(stderr, "overflow"); goto error; - } else if(Z_MEM_ERROR == ret) { + } + else if (Z_MEM_ERROR == ret) { HDfprintf(stderr, "deflate memory error"); goto error; - } else if(Z_OK != ret) { + } + else if (Z_OK != ret) { HDfprintf(stderr, "other deflate error"); goto error; } /* Write the compressed chunk data repeatedly to cover all the chunks in the * dataset, using the direct writing function. */ - for(i=0; i0) { + while (buf_left > 0) { *int_ptr++ -= (int)ADD_ON; buf_left -= sizeof(int); - } /* end while */ - } /* end if */ + } /* 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++ += (int)ADD_ON; buf_left -= sizeof(int); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* filter_bogus1() */ @@ -694,26 +710,25 @@ filter_bogus1(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, */ static size_t filter_bogus2(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t *buf_size, void **buf) + const unsigned int H5_ATTR_UNUSED *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 */ - if(flags & H5Z_FLAG_REVERSE) { /* read */ + 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++ /= (int)FACTOR; buf_left -= sizeof(int); - } /* end while */ - } /* end if */ + } /* 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++ *= (int)FACTOR; buf_left -= sizeof(int); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* filter_bogus2() */ @@ -735,87 +750,87 @@ filter_bogus2(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, static int test_skip_compress_write2(hid_t file) { - hid_t dataspace = -1, dataset = -1; - hid_t mem_space = -1; - hid_t cparms = -1, dxpl = -1; - hsize_t dims[2] = {NX, NY}; - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY}; - herr_t status; - int i, j, n; - - unsigned filter_mask = 0; /* orig filter mask */ - int origin_direct_buf[CHUNK_NX][CHUNK_NY]; - int direct_buf[CHUNK_NX][CHUNK_NY]; - int check_chunk[CHUNK_NX][CHUNK_NY]; - hsize_t offset[2] = {0, 0}; - size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int); - int aggression = 9; /* Compression aggression setting */ - - unsigned read_filter_mask = 0; /* filter mask after direct read */ - int read_direct_buf[CHUNK_NX][CHUNK_NY]; - hsize_t read_buf_size = 0; /* buf size */ - - hsize_t start[2]; /* Start of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Block count */ - hsize_t block[2]; /* Block sizes */ + hid_t dataspace = -1, dataset = -1; + hid_t mem_space = -1; + hid_t cparms = -1, dxpl = -1; + hsize_t dims[2] = {NX, NY}; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; + herr_t status; + int i, j, n; + + unsigned filter_mask = 0; /* orig filter mask */ + int origin_direct_buf[CHUNK_NX][CHUNK_NY]; + int direct_buf[CHUNK_NX][CHUNK_NY]; + int check_chunk[CHUNK_NX][CHUNK_NY]; + hsize_t offset[2] = {0, 0}; + size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int); + int aggression = 9; /* Compression aggression setting */ + + unsigned read_filter_mask = 0; /* filter mask after direct read */ + int read_direct_buf[CHUNK_NX][CHUNK_NY]; + hsize_t read_buf_size = 0; /* buf size */ + + hsize_t start[2]; /* Start of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Block count */ + hsize_t block[2]; /* Block sizes */ TESTING("skipping compression filters but keep two other filters"); /* * Create the data space with unlimited dimensions. */ - if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) goto error; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) goto error; /* * Modify dataset creation properties, i.e. enable chunking and compression. * The order of filters is bogus 1 + deflate + bogus 2. */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) + if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0) goto error; /* Register and enable first bogus filter */ - if(H5Zregister (H5Z_BOGUS1) < 0) + if (H5Zregister(H5Z_BOGUS1) < 0) goto error; - if(H5Pset_filter(cparms, H5Z_FILTER_BOGUS1, 0, (size_t)0, NULL) < 0) + if (H5Pset_filter(cparms, H5Z_FILTER_BOGUS1, 0, (size_t)0, NULL) < 0) goto error; /* Enable compression filter */ - if((status = H5Pset_deflate( cparms, (unsigned) aggression)) < 0) + if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0) goto error; /* Register and enable second bogus filter */ - if(H5Zregister (H5Z_BOGUS2) < 0) + if (H5Zregister(H5Z_BOGUS2) < 0) goto error; - if(H5Pset_filter(cparms, H5Z_FILTER_BOGUS2, 0, (size_t)0, NULL) < 0) + if (H5Pset_filter(cparms, H5Z_FILTER_BOGUS2, 0, (size_t)0, NULL) < 0) goto error; /* * Create a new dataset within the file using cparms * creation properties. */ - if((dataset = H5Dcreate2(file, DATASETNAME3, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, DATASETNAME3, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) goto error; - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; /* Initialize data for one chunk. Apply operations of two bogus filters to the chunk */ - for(i = n = 0; i < CHUNK_NX; i++) - for(j = 0; j < CHUNK_NY; j++) { + for (i = n = 0; i < CHUNK_NX; i++) + for (j = 0; j < CHUNK_NY; j++) { origin_direct_buf[i][j] = n++; - direct_buf[i][j] = (origin_direct_buf[i][j] + ADD_ON) * FACTOR; + direct_buf[i][j] = (origin_direct_buf[i][j] + ADD_ON) * FACTOR; } /* write the uncompressed chunk data repeatedly to dataset, using the direct writing function. @@ -826,61 +841,66 @@ test_skip_compress_write2(hid_t file) /* compression filter is the middle one to be skipped */ filter_mask = 0x00000002; - if((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0) + if ((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0) goto error; - if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) + if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; - if((dataset = H5Dopen2(file, DATASETNAME3, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DATASETNAME3, H5P_DEFAULT)) < 0) goto error; /* * Select hyperslab for one chunk in the file */ - start[0] = CHUNK_NX; start[1] = CHUNK_NY; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = CHUNK_NX; block[1] = CHUNK_NY; - if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) + start[0] = CHUNK_NX; + start[1] = CHUNK_NY; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = CHUNK_NX; + block[1] = CHUNK_NY; + if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) goto error; /* Read the chunk back */ - if((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0) + if ((status = H5Dread(dataset, H5T_NATIVE_INT, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i = 0; i < CHUNK_NX; i++) { - for(j = 0; j < CHUNK_NY; j++) { - if(origin_direct_buf[i][j] != check_chunk[i][j]) { + for (i = 0; i < CHUNK_NX; i++) { + for (j = 0; j < CHUNK_NY; j++) { + if (origin_direct_buf[i][j] != check_chunk[i][j]) { HDprintf(" 1. Read different values than written."); HDprintf(" At index %d,%d\n", i, j); - HDprintf(" origin_direct_buf=%d, check_chunk=%d\n", origin_direct_buf[i][j], check_chunk[i][j]); + HDprintf(" origin_direct_buf=%d, check_chunk=%d\n", origin_direct_buf[i][j], + check_chunk[i][j]); goto error; } } } /* Query chunk storage size */ - if((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0) + if ((status = H5Dget_chunk_storage_size(dataset, offset, &read_buf_size)) < 0) goto error; - if(read_buf_size != buf_size) + if (read_buf_size != buf_size) goto error; /* Read the raw chunk back */ HDmemset(&read_direct_buf, 0, sizeof(read_direct_buf)); - if((status = H5Dread_chunk(dataset, H5P_DEFAULT, offset, &read_filter_mask, read_direct_buf)) < 0) + if ((status = H5Dread_chunk(dataset, H5P_DEFAULT, offset, &read_filter_mask, read_direct_buf)) < 0) goto error; - if(read_filter_mask != filter_mask) + if (read_filter_mask != filter_mask) goto error; /* Check that the direct chunk read is the same as the chunk written */ - for(i = 0; i < CHUNK_NX; i++) { - for(j = 0; j < CHUNK_NY; j++) { - if(direct_buf[i][j] != read_direct_buf[i][j]) { + for (i = 0; i < CHUNK_NX; i++) { + for (j = 0; j < CHUNK_NY; j++) { + if (direct_buf[i][j] != read_direct_buf[i][j]) { HDprintf(" 1. Read different values than written."); HDprintf(" At index %d,%d\n", i, j); HDprintf(" direct_buf=%d, read_direct_buf=%d\n", direct_buf[i][j], read_direct_buf[i][j]); @@ -902,13 +922,15 @@ test_skip_compress_write2(hid_t file) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(mem_space); H5Sclose(dataspace); H5Pclose(cparms); H5Pclose(dxpl); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return 1; @@ -934,28 +956,28 @@ test_data_conv(hid_t file) int a, b, c[4], d, e; } src_type_t; typedef struct { - int a, c[4], e; + int a, c[4], e; } dst_type_t; - hid_t dataspace = -1, dataset = -1; - hid_t mem_space = -1; - hid_t cparms = -1, dxpl = -1; - hsize_t dims[2] = {NX, NY}; - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY}; - herr_t status; - int i, j, n; - const hsize_t four = 4; - hid_t st=-1, dt=-1; - hid_t array_dt; - - unsigned filter_mask = 0; - src_type_t direct_buf[CHUNK_NX][CHUNK_NY]; - dst_type_t check_chunk[CHUNK_NX][CHUNK_NY]; - src_type_t read_chunk[CHUNK_NX][CHUNK_NY]; /* For H5Dread_chunk */ - - hsize_t offset[2] = {0, 0}; - size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(src_type_t); + hid_t dataspace = -1, dataset = -1; + hid_t mem_space = -1; + hid_t cparms = -1, dxpl = -1; + hsize_t dims[2] = {NX, NY}; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; + herr_t status; + int i, j, n; + const hsize_t four = 4; + hid_t st = -1, dt = -1; + hid_t array_dt; + + unsigned filter_mask = 0; + src_type_t direct_buf[CHUNK_NX][CHUNK_NY]; + dst_type_t check_chunk[CHUNK_NX][CHUNK_NY]; + src_type_t read_chunk[CHUNK_NX][CHUNK_NY]; /* For H5Dread_chunk */ + + hsize_t offset[2] = {0, 0}; + size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(src_type_t); hsize_t start[2]; /* Start of hyperslab */ hsize_t stride[2]; /* Stride of hyperslab */ @@ -967,66 +989,65 @@ test_data_conv(hid_t file) /* * Create the data space with unlimited dimensions. */ - if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) goto error; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) goto error; /* * Modify dataset creation properties, i.e. enable chunking */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) + if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0) goto error; /* Build hdf5 datatypes */ array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); - if((st = H5Tcreate(H5T_COMPOUND, sizeof(src_type_t))) < 0 || - H5Tinsert(st, "a", HOFFSET(src_type_t, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "b", HOFFSET(src_type_t, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "c", HOFFSET(src_type_t, c), array_dt) < 0 || - H5Tinsert(st, "d", HOFFSET(src_type_t, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "e", HOFFSET(src_type_t, e), H5T_NATIVE_INT) < 0) + if ((st = H5Tcreate(H5T_COMPOUND, sizeof(src_type_t))) < 0 || + H5Tinsert(st, "a", HOFFSET(src_type_t, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "b", HOFFSET(src_type_t, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "c", HOFFSET(src_type_t, c), array_dt) < 0 || + H5Tinsert(st, "d", HOFFSET(src_type_t, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "e", HOFFSET(src_type_t, e), H5T_NATIVE_INT) < 0) goto error; - if(H5Tclose(array_dt) < 0) + if (H5Tclose(array_dt) < 0) goto error; array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); - if((dt = H5Tcreate(H5T_COMPOUND, sizeof(dst_type_t))) < 0 || - H5Tinsert(dt, "a", HOFFSET(dst_type_t, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(dt, "c", HOFFSET(dst_type_t, c), array_dt) < 0 || - H5Tinsert(dt, "e", HOFFSET(dst_type_t, e), H5T_NATIVE_INT) < 0) + if ((dt = H5Tcreate(H5T_COMPOUND, sizeof(dst_type_t))) < 0 || + H5Tinsert(dt, "a", HOFFSET(dst_type_t, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(dt, "c", HOFFSET(dst_type_t, c), array_dt) < 0 || + H5Tinsert(dt, "e", HOFFSET(dst_type_t, e), H5T_NATIVE_INT) < 0) goto error; - if(H5Tclose(array_dt) < 0) + if (H5Tclose(array_dt) < 0) goto error; /* * Create a new dataset within the file using cparms * creation properties. */ - if((dataset = H5Dcreate2(file, DATASETNAME4, st, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DATASETNAME4, st, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) goto error; - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; /* Initialize data for one chunk */ - for(i = n = 0; i < CHUNK_NX; i++) { - for(j = 0; j < CHUNK_NY; j++) { - (direct_buf[i][j]).a = i*j+0; - (direct_buf[i][j]).b = i*j+1; - (direct_buf[i][j]).c[0] = i*j+2; - (direct_buf[i][j]).c[1] = i*j+3; - (direct_buf[i][j]).c[2] = i*j+4; - (direct_buf[i][j]).c[3] = i*j+5; - (direct_buf[i][j]).d = i*j+6; - (direct_buf[i][j]).e = i*j+7; + for (i = n = 0; i < CHUNK_NX; i++) { + for (j = 0; j < CHUNK_NY; j++) { + (direct_buf[i][j]).a = i * j + 0; + (direct_buf[i][j]).b = i * j + 1; + (direct_buf[i][j]).c[0] = i * j + 2; + (direct_buf[i][j]).c[1] = i * j + 3; + (direct_buf[i][j]).c[2] = i * j + 4; + (direct_buf[i][j]).c[3] = i * j + 5; + (direct_buf[i][j]).d = i * j + 6; + (direct_buf[i][j]).e = i * j + 7; } } @@ -1035,43 +1056,45 @@ test_data_conv(hid_t file) offset[0] = CHUNK_NX; offset[1] = CHUNK_NY; - if((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0) + if ((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) < 0) goto error; - if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) + if (H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0) goto error; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; - if((dataset = H5Dopen2(file, DATASETNAME4, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DATASETNAME4, H5P_DEFAULT)) < 0) goto error; /* Use H5Dread_chunk() to read the uncompressed data */ - if((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, read_chunk)) < 0) + if ((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, read_chunk)) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i = 0; i < CHUNK_NX; i++) { - for(j = 0; j < CHUNK_NY; j++) { - if ((direct_buf[i][j]).a != (read_chunk[i][j]).a || - (direct_buf[i][j]).b != (read_chunk[i][j]).b || + for (i = 0; i < CHUNK_NX; i++) { + for (j = 0; j < CHUNK_NY; j++) { + if ((direct_buf[i][j]).a != (read_chunk[i][j]).a || + (direct_buf[i][j]).b != (read_chunk[i][j]).b || (direct_buf[i][j]).c[0] != (read_chunk[i][j]).c[0] || (direct_buf[i][j]).c[1] != (read_chunk[i][j]).c[1] || (direct_buf[i][j]).c[2] != (read_chunk[i][j]).c[2] || (direct_buf[i][j]).c[3] != (read_chunk[i][j]).c[3] || - (direct_buf[i][j]).d != (read_chunk[i][j]).d || - (direct_buf[i][j]).e != (read_chunk[i][j]).e) { - HDprintf(" 1. Read different values than written."); - HDprintf(" At index %d,%d\n", i, j); - HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", - (direct_buf[i][j]).a, (direct_buf[i][j]).b, (direct_buf[i][j]).c[0], (direct_buf[i][j]).c[1], - (direct_buf[i][j]).c[2], (direct_buf[i][j]).c[3], (direct_buf[i][j]).d, (direct_buf[i][j]).e); - HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", - (read_chunk[i][j]).a, (read_chunk[i][j]).b, (read_chunk[i][j]).c[0], (read_chunk[i][j]).c[1], - (read_chunk[i][j]).c[2], (read_chunk[i][j]).c[3], (read_chunk[i][j]).d, (read_chunk[i][j]).e); - - goto error; + (direct_buf[i][j]).d != (read_chunk[i][j]).d || + (direct_buf[i][j]).e != (read_chunk[i][j]).e) { + HDprintf(" 1. Read different values than written."); + HDprintf(" At index %d,%d\n", i, j); + HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", (direct_buf[i][j]).a, + (direct_buf[i][j]).b, (direct_buf[i][j]).c[0], (direct_buf[i][j]).c[1], + (direct_buf[i][j]).c[2], (direct_buf[i][j]).c[3], (direct_buf[i][j]).d, + (direct_buf[i][j]).e); + HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", (read_chunk[i][j]).a, + (read_chunk[i][j]).b, (read_chunk[i][j]).c[0], (read_chunk[i][j]).c[1], + (read_chunk[i][j]).c[2], (read_chunk[i][j]).c[3], (read_chunk[i][j]).d, + (read_chunk[i][j]).e); + + goto error; } } } @@ -1079,36 +1102,41 @@ test_data_conv(hid_t file) /* * Select hyperslab for the chunk just written in the file */ - start[0] = CHUNK_NX; start[1] = CHUNK_NY; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = CHUNK_NX; block[1] = CHUNK_NY; - if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) + start[0] = CHUNK_NX; + start[1] = CHUNK_NY; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = CHUNK_NX; + block[1] = CHUNK_NY; + if ((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) goto error; /* Read the chunk back. Data should be converted */ - if((status = H5Dread(dataset, dt, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0) + if ((status = H5Dread(dataset, dt, mem_space, dataspace, H5P_DEFAULT, check_chunk)) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i = 0; i < CHUNK_NX; i++) { - for(j = 0; j < CHUNK_NY; j++) { - if ((direct_buf[i][j]).a != (check_chunk[i][j]).a || + for (i = 0; i < CHUNK_NX; i++) { + for (j = 0; j < CHUNK_NY; j++) { + if ((direct_buf[i][j]).a != (check_chunk[i][j]).a || (direct_buf[i][j]).c[0] != (check_chunk[i][j]).c[0] || (direct_buf[i][j]).c[1] != (check_chunk[i][j]).c[1] || (direct_buf[i][j]).c[2] != (check_chunk[i][j]).c[2] || (direct_buf[i][j]).c[3] != (check_chunk[i][j]).c[3] || - (direct_buf[i][j]).e != (check_chunk[i][j]).e) { - HDprintf(" 1. Read different values than written."); - HDprintf(" At index %d,%d\n", i, j); - HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", - (direct_buf[i][j]).a, (direct_buf[i][j]).b, (direct_buf[i][j]).c[0], (direct_buf[i][j]).c[1], - (direct_buf[i][j]).c[2], (direct_buf[i][j]).c[3], (direct_buf[i][j]).d, (direct_buf[i][j]).e); - HDprintf(" dst={a=%d, c=[%d,%d,%d,%d], e=%d\n", - (check_chunk[i][j]).a, (check_chunk[i][j]).c[0], (check_chunk[i][j]).c[1], (check_chunk[i][j]).c[2], - (check_chunk[i][j]).c[3], (check_chunk[i][j]).e); - - goto error; + (direct_buf[i][j]).e != (check_chunk[i][j]).e) { + HDprintf(" 1. Read different values than written."); + HDprintf(" At index %d,%d\n", i, j); + HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", (direct_buf[i][j]).a, + (direct_buf[i][j]).b, (direct_buf[i][j]).c[0], (direct_buf[i][j]).c[1], + (direct_buf[i][j]).c[2], (direct_buf[i][j]).c[3], (direct_buf[i][j]).d, + (direct_buf[i][j]).e); + HDprintf(" dst={a=%d, c=[%d,%d,%d,%d], e=%d\n", (check_chunk[i][j]).a, + (check_chunk[i][j]).c[0], (check_chunk[i][j]).c[1], (check_chunk[i][j]).c[2], + (check_chunk[i][j]).c[3], (check_chunk[i][j]).e); + + goto error; } } } @@ -1128,7 +1156,8 @@ test_data_conv(hid_t file) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(mem_space); H5Sclose(dataspace); @@ -1136,7 +1165,8 @@ error: H5Pclose(dxpl); H5Tclose(st); H5Tclose(dt); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return 1; @@ -1158,52 +1188,52 @@ error: static int test_invalid_parameters(hid_t file) { - hid_t dataspace = -1, dataset = -1; - hid_t mem_space = -1; - hid_t cparms = -1, dxpl = -1; - hsize_t dims[2] = {NX, NY}; - hsize_t chunk_dims[2] ={CHUNK_NX, CHUNK_NY}; - herr_t status; - int i, j, n; - - unsigned filter_mask = 0; - int direct_buf[CHUNK_NX][CHUNK_NY]; - hsize_t offset[2] = {0, 0}; - size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int); - int aggression = 9; /* Compression aggression setting */ - - hsize_t chunk_nbytes; /* Chunk size */ + hid_t dataspace = -1, dataset = -1; + hid_t mem_space = -1; + hid_t cparms = -1, dxpl = -1; + hsize_t dims[2] = {NX, NY}; + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; + herr_t status; + int i, j, n; + + unsigned filter_mask = 0; + int direct_buf[CHUNK_NX][CHUNK_NY]; + hsize_t offset[2] = {0, 0}; + size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int); + int aggression = 9; /* Compression aggression setting */ + + hsize_t chunk_nbytes; /* Chunk size */ TESTING("invalid parameters for H5Dwrite_chunk/H5Dread_chunk"); /* * Create the data space with unlimited dimensions. */ - if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) goto error; /* * Modify dataset creation properties */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* * Create a new contiguous dataset to verify H5Dwrite_chunk/H5Dread_chunk doesn't work */ - if((dataset = H5Dcreate2(file, DATASETNAME5, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, DATASETNAME5, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) goto error; - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; /* Initialize data for one chunk */ - for(i = n = 0; i < CHUNK_NX; i++) - for(j = 0; j < CHUNK_NY; j++) { + for (i = n = 0; i < CHUNK_NX; i++) + for (j = 0; j < CHUNK_NY; j++) { direct_buf[i][j] = n++; } @@ -1211,123 +1241,154 @@ test_invalid_parameters(hid_t file) offset[0] = CHUNK_NX; offset[1] = CHUNK_NY; - H5E_BEGIN_TRY { - if((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Try to get chunk size for a contiguous dataset. It should fail */ - H5E_BEGIN_TRY { - if((status = H5Dget_chunk_storage_size(dataset, offset, &chunk_nbytes)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dget_chunk_storage_size(dataset, offset, &chunk_nbytes)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Try to H5Dread_chunk from the contiguous dataset. It should fail */ - H5E_BEGIN_TRY { - if((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; - /* Create a chunked dataset with compression filter */ - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) + if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0) goto error; - if((status = H5Pset_deflate( cparms, (unsigned ) aggression)) < 0) + if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0) goto error; /* * Create a new dataset within the file using cparms * creation properties. */ - if((dataset = H5Dcreate2(file, DATASETNAME6, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, DATASETNAME6, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) goto error; /* Check invalid dataset ID for H5Dwrite_chunk and H5Dread_chunk */ - H5E_BEGIN_TRY { - if((status = H5Dwrite_chunk((hid_t)-1, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dwrite_chunk((hid_t)-1, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; - H5E_BEGIN_TRY { - if((status = H5Dread_chunk((hid_t)-1, dxpl, offset, &filter_mask, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dread_chunk((hid_t)-1, dxpl, offset, &filter_mask, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Check invalid DXPL ID for H5Dwrite_chunk and H5Dread_chunk */ - H5E_BEGIN_TRY { - if((status = H5Dwrite_chunk(dataset, (hid_t)-1, filter_mask, offset, buf_size, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dwrite_chunk(dataset, (hid_t)-1, filter_mask, offset, buf_size, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; - H5E_BEGIN_TRY { - if((status = H5Dread_chunk(dataset, (hid_t)-1, offset, &filter_mask, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dread_chunk(dataset, (hid_t)-1, offset, &filter_mask, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Check invalid OFFSET for H5Dwrite_chunk and H5Dread_chunk */ - H5E_BEGIN_TRY { - if((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, NULL, buf_size, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, NULL, buf_size, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; - H5E_BEGIN_TRY { - if((status = H5Dread_chunk(dataset, dxpl, NULL, &filter_mask, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dread_chunk(dataset, dxpl, NULL, &filter_mask, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Check when OFFSET is out of dataset range for H5Dwrite_chunk and H5Dread_chunk */ offset[0] = NX + 1; offset[1] = NY; - H5E_BEGIN_TRY { - if((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; - H5E_BEGIN_TRY { - if((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Check when OFFSET is not on chunk boundary for H5Dwrite_chunk and H5Dread_chunk */ offset[0] = CHUNK_NX; offset[1] = CHUNK_NY + 1; - H5E_BEGIN_TRY { - if((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; - H5E_BEGIN_TRY { - if((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Check invalid buffer size for H5Dwrite_chunk only */ offset[0] = CHUNK_NX; offset[1] = CHUNK_NY; - buf_size = 0; - H5E_BEGIN_TRY { - if((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) + buf_size = 0; + H5E_BEGIN_TRY + { + if ((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, direct_buf)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Check invalid data buffer for H5Dwrite_chunk and H5Dread_chunk */ - buf_size = CHUNK_NX*CHUNK_NY*sizeof(int); - H5E_BEGIN_TRY { - if((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, NULL)) != FAIL) + buf_size = CHUNK_NX * CHUNK_NY * sizeof(int); + H5E_BEGIN_TRY + { + if ((status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, buf_size, NULL)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; - H5E_BEGIN_TRY { - if((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, NULL)) != FAIL) + H5E_BEGIN_TRY + { + if ((status = H5Dread_chunk(dataset, dxpl, offset, &filter_mask, NULL)) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) goto error; /* @@ -1342,13 +1403,15 @@ test_invalid_parameters(hid_t file) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(mem_space); H5Sclose(dataspace); H5Pclose(cparms); H5Pclose(dxpl); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return 1; @@ -1370,31 +1433,31 @@ error: */ #ifdef H5_HAVE_FILTER_DEFLATE static int -test_direct_chunk_read_no_cache (hid_t file) +test_direct_chunk_read_no_cache(hid_t file) { - hid_t dataspace = -1, dataset = -1; - hid_t mem_space = -1; - hid_t cparms = -1, dxpl = -1, dapl = -1; - hsize_t dims[2] = {NX, NY}; - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; - herr_t status; /* status from H5 function calls */ - int ret; /* deflate return status */ - int data[NX][NY]; - int i, j, k, l, n; /* local index variables */ - - unsigned filter_mask = 0; /* filter mask returned from H5Dread_chunk */ - int direct_buf[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread and manually decompressed */ - int check_chunk[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread */ - hsize_t offset[2]; /* chunk offset used for H5Dread_chunk */ - size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int); - - Bytef *z_src = NULL; /* source buffer */ - uLongf z_src_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); - Bytef *z_dst = (Bytef*)(direct_buf); - uLong z_dst_nbytes = (uLong)buf_size; - int aggression = 9; /* Compression aggression setting */ - void *outbuf = NULL; /* Pointer to new buffer */ + hid_t dataspace = -1, dataset = -1; + hid_t mem_space = -1; + hid_t cparms = -1, dxpl = -1, dapl = -1; + hsize_t dims[2] = {NX, NY}; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; + herr_t status; /* status from H5 function calls */ + int ret; /* deflate return status */ + int data[NX][NY]; + int i, j, k, l, n; /* local index variables */ + + unsigned filter_mask = 0; /* filter mask returned from H5Dread_chunk */ + int direct_buf[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread and manually decompressed */ + int check_chunk[CHUNK_NX][CHUNK_NY]; /* chunk read with H5Dread */ + hsize_t offset[2]; /* chunk offset used for H5Dread_chunk */ + size_t buf_size = CHUNK_NX * CHUNK_NY * sizeof(int); + + Bytef *z_src = NULL; /* source buffer */ + uLongf z_src_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); + Bytef *z_dst = (Bytef *)(direct_buf); + uLong z_dst_nbytes = (uLong)buf_size; + int aggression = 9; /* Compression aggression setting */ + void * outbuf = NULL; /* Pointer to new buffer */ hsize_t start[2]; /* Start of hyperslab */ hsize_t stride[2]; /* Stride of hyperslab */ @@ -1404,96 +1467,104 @@ test_direct_chunk_read_no_cache (hid_t file) TESTING("basic functionality of H5Dread_chunk (chunk cache disabled)"); /* Create the data space with unlimited dimensions. */ - if((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, maxdims)) < 0) goto error; - if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + if ((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) goto error; /* Modify dataset creation properties, i.e. enable chunking and compression */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if((status = H5Pset_chunk( cparms, RANK, chunk_dims)) < 0) + if ((status = H5Pset_chunk(cparms, RANK, chunk_dims)) < 0) goto error; - if((status = H5Pset_deflate( cparms, (unsigned) aggression)) < 0) + if ((status = H5Pset_deflate(cparms, (unsigned)aggression)) < 0) goto error; - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) goto error; /* Disable chunk cache by setting number of slots to 0 */ - if((status = H5Pset_chunk_cache(dapl, 0, H5D_CHUNK_CACHE_NBYTES_DEFAULT, H5D_CHUNK_CACHE_W0_DEFAULT)) < 0) + if ((status = H5Pset_chunk_cache(dapl, 0, H5D_CHUNK_CACHE_NBYTES_DEFAULT, H5D_CHUNK_CACHE_W0_DEFAULT)) < + 0) goto error; /* Create a new dataset within the file using cparms creation properties. */ - if((dataset = H5Dcreate2(file, DATASETNAME8, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, dapl)) < 0) + if ((dataset = H5Dcreate2(file, DATASETNAME8, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, dapl)) < 0) goto error; /* Initialize the dataset */ - for(i = n = 0; i < NX; i++) - for(j = 0; j < NY; j++) + for (i = n = 0; i < NX; i++) + for (j = 0; j < NY; j++) data[i][j] = n++; - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; /* Write the data for the dataset. * Data will skip chunk cache and go directly to disk. */ - if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl, data)) < 0) + if ((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, data)) < 0) goto error; /* Allocate output (compressed) buffer */ outbuf = HDmalloc(z_src_nbytes); - z_src = (Bytef *)outbuf; + z_src = (Bytef *)outbuf; /* For each chunk in the dataset, compare the result of H5Dread and H5Dread_chunk. */ - for(i=0; i"); - if(config & CONFIG_LATEST) { - if(need_comma) + if (config & CONFIG_LATEST) { + if (need_comma) HDprintf(", "); HDprintf("latest format"); need_comma = TRUE; } /* end if */ - if(config & CONFIG_REOPEN_FILE) { - if(need_comma) + if (config & CONFIG_REOPEN_FILE) { + if (need_comma) HDprintf(", "); HDprintf("reopen file"); need_comma = TRUE; } /* end if */ - else if(config & CONFIG_REOPEN_DSET) { - if(need_comma) + else if (config & CONFIG_REOPEN_DSET) { + if (need_comma) HDprintf(", "); HDprintf("reopen dataset"); need_comma = TRUE; } /* end if */ - if(config & CONFIG_DIRECT_WRITE) { - if(need_comma) + if (config & CONFIG_DIRECT_WRITE) { + if (need_comma) HDprintf(", "); HDprintf("direct write"); need_comma = TRUE; } /* end if */ - if(config & CONFIG_DIRECT_READ) { - if(need_comma) + if (config & CONFIG_DIRECT_READ) { + if (need_comma) HDprintf(", "); HDprintf("direct read"); need_comma = TRUE; @@ -2231,7 +2331,7 @@ int main( void ) nerrors += test_single_chunk(config); } /* end for */ - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) goto error; /* check for errors */ @@ -2245,4 +2345,3 @@ error: HDputs("*** TESTS FAILED ***"); return EXIT_FAILURE; } - diff --git a/test/dsets.c b/test/dsets.c index 4ab3efa..9a345c5 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -17,117 +17,115 @@ * * Purpose: Tests the dataset interface (H5D) */ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ #define H5D_TESTING -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING -#define H5Z_FRIEND /*suppress error about including H5Zpkg */ +#define H5Z_FRIEND /*suppress error about including H5Zpkg */ #include "testhdf5.h" #include "H5srcdir.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Iprivate.h" #include "H5Pprivate.h" -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ -#define H5S_FRIEND /*suppress error about including H5Spkg */ -#include "H5Spkg.h" /* Dataspace */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ +#include "H5Spkg.h" /* Dataspace */ -#define H5T_FRIEND /*suppress error about including H5Tpkg */ -#include "H5Tpkg.h" /* Datatype */ +#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#include "H5Tpkg.h" /* Datatype */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Apkg.h" /* Attributes */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Apkg.h" /* Attributes */ /* Use in version bound test */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5Opkg.h" /* Object headers */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Opkg.h" /* Object headers */ #include "H5Dpkg.h" #include "H5FDpkg.h" #include "H5VMprivate.h" #include "H5Zpkg.h" #ifdef H5_HAVE_SZLIB_H -# include "szlib.h" +#include "szlib.h" #endif -const char *FILENAME[] = { - "dataset", /* 0 */ - "compact_dataset", /* 1 */ - "dset_offset", /* 2 */ - "max_compact_dataset", /* 3 */ - "simple", /* 4 */ - "set_local", /* 5 */ - "random_chunks", /* 6 */ - "huge_chunks", /* 7 */ - "chunk_cache", /* 8 */ - "big_chunk", /* 9 */ - "chunk_fast", /* 10 */ - "chunk_expand", /* 11 */ - "chunk_fixed", /* 12 */ - "copy_dcpl_newfile",/* 13 */ - "partial_chunks", /* 14 */ - "layout_extend", /* 15 */ - "zero_chunk", /* 16 */ - "chunk_single", /* 17 */ - "swmr_non_latest", /* 18 */ - "earray_hdr_fd", /* 19 */ - "farray_hdr_fd", /* 20 */ - "bt2_hdr_fd", /* 21 */ - "storage_size", /* 22 */ - "dls_01_strings", /* 23 */ - "power2up", /* 24 */ - "version_bounds", /* 25 */ - "alloc_0sized", /* 26 */ - NULL -}; +const char *FILENAME[] = {"dataset", /* 0 */ + "compact_dataset", /* 1 */ + "dset_offset", /* 2 */ + "max_compact_dataset", /* 3 */ + "simple", /* 4 */ + "set_local", /* 5 */ + "random_chunks", /* 6 */ + "huge_chunks", /* 7 */ + "chunk_cache", /* 8 */ + "big_chunk", /* 9 */ + "chunk_fast", /* 10 */ + "chunk_expand", /* 11 */ + "chunk_fixed", /* 12 */ + "copy_dcpl_newfile", /* 13 */ + "partial_chunks", /* 14 */ + "layout_extend", /* 15 */ + "zero_chunk", /* 16 */ + "chunk_single", /* 17 */ + "swmr_non_latest", /* 18 */ + "earray_hdr_fd", /* 19 */ + "farray_hdr_fd", /* 20 */ + "bt2_hdr_fd", /* 21 */ + "storage_size", /* 22 */ + "dls_01_strings", /* 23 */ + "power2up", /* 24 */ + "version_bounds", /* 25 */ + "alloc_0sized", /* 26 */ + NULL}; #define OHMIN_FILENAME_A "ohdr_min_a" -#define FILENAME_BUF_SIZE 1024 -#define KB 1024 +#define FILENAME_BUF_SIZE 1024 +#define KB 1024 -#define FILE_DEFLATE_NAME "deflate.h5" +#define FILE_DEFLATE_NAME "deflate.h5" /* Dataset names for testing filters */ -#define DSET_DEFAULT_NAME "default" -#define DSET_CHUNKED_NAME "chunked" -#define DSET_COMPACT_NAME "compact" -#define DSET_SIMPLE_IO_NAME "simple_io" -#define DSET_USERBLOCK_IO_NAME "userblock_io" -#define DSET_COMPACT_IO_NAME "compact_io" -#define DSET_COMPACT_MAX_NAME "max_compact" -#define DSET_COMPACT_MAX2_NAME "max_compact_2" -#define DSET_CONV_BUF_NAME "conv_buf" -#define DSET_TCONV_NAME "tconv" -#define DSET_DEFLATE_NAME "deflate" -#define DSET_SHUFFLE_NAME "shuffle" -#define DSET_FLETCHER32_NAME "fletcher32" -#define DSET_FLETCHER32_NAME_2 "fletcher32_2" -#define DSET_FLETCHER32_NAME_3 "fletcher32_3" -#define DSET_SHUF_DEF_FLET_NAME "shuffle+deflate+fletcher32" -#define DSET_SHUF_DEF_FLET_NAME_2 "shuffle+deflate+fletcher32_2" +#define DSET_DEFAULT_NAME "default" +#define DSET_CHUNKED_NAME "chunked" +#define DSET_COMPACT_NAME "compact" +#define DSET_SIMPLE_IO_NAME "simple_io" +#define DSET_USERBLOCK_IO_NAME "userblock_io" +#define DSET_COMPACT_IO_NAME "compact_io" +#define DSET_COMPACT_MAX_NAME "max_compact" +#define DSET_COMPACT_MAX2_NAME "max_compact_2" +#define DSET_CONV_BUF_NAME "conv_buf" +#define DSET_TCONV_NAME "tconv" +#define DSET_DEFLATE_NAME "deflate" +#define DSET_SHUFFLE_NAME "shuffle" +#define DSET_FLETCHER32_NAME "fletcher32" +#define DSET_FLETCHER32_NAME_2 "fletcher32_2" +#define DSET_FLETCHER32_NAME_3 "fletcher32_3" +#define DSET_SHUF_DEF_FLET_NAME "shuffle+deflate+fletcher32" +#define DSET_SHUF_DEF_FLET_NAME_2 "shuffle+deflate+fletcher32_2" #ifdef H5_HAVE_FILTER_SZIP -#define DSET_SZIP_NAME "szip" -#define DSET_SHUF_SZIP_FLET_NAME "shuffle+szip+fletcher32" -#define DSET_SHUF_SZIP_FLET_NAME_2 "shuffle+szip+fletcher32_2" +#define DSET_SZIP_NAME "szip" +#define DSET_SHUF_SZIP_FLET_NAME "shuffle+szip+fletcher32" +#define DSET_SHUF_SZIP_FLET_NAME_2 "shuffle+szip+fletcher32_2" #endif /* H5_HAVE_FILTER_SZIP */ -#define DSET_BOGUS_NAME "bogus" -#define DSET_MISSING_NAME "missing" -#define DSET_CAN_APPLY_NAME "can_apply" -#define DSET_CAN_APPLY_NAME2 "can_apply2" +#define DSET_BOGUS_NAME "bogus" +#define DSET_MISSING_NAME "missing" +#define DSET_CAN_APPLY_NAME "can_apply" +#define DSET_CAN_APPLY_NAME2 "can_apply2" #ifdef H5_HAVE_FILTER_SZIP -#define DSET_CAN_APPLY_SZIP_NAME "can_apply_szip" +#define DSET_CAN_APPLY_SZIP_NAME "can_apply_szip" #endif /* H5_HAVE_FILTER_SZIP */ -#define DSET_SET_LOCAL_NAME "set_local" -#define DSET_SET_LOCAL_NAME_2 "set_local_2" -#define DSET_ONEBYTE_SHUF_NAME "onebyte_shuffle" +#define DSET_SET_LOCAL_NAME "set_local" +#define DSET_SET_LOCAL_NAME_2 "set_local_2" +#define DSET_ONEBYTE_SHUF_NAME "onebyte_shuffle" #define DSET_NBIT_INT_NAME "nbit_int" #define DSET_NBIT_FLOAT_NAME "nbit_float" #define DSET_NBIT_DOUBLE_NAME "nbit_double" @@ -149,74 +147,74 @@ const char *FILENAME[] = { #define DSET_COPY_DCPL_NAME_2 "copy_dcpl_2" #define COPY_DCPL_EXTFILE_NAME "ext_file" #ifndef H5_NO_DEPRECATED_SYMBOLS -#define DSET_DEPREC_NAME "deprecated" -#define DSET_DEPREC_NAME_CHUNKED "deprecated_chunked" -#define DSET_DEPREC_NAME_COMPACT "deprecated_compact" -#define DSET_DEPREC_NAME_FILTER "deprecated_filter" +#define DSET_DEPREC_NAME "deprecated" +#define DSET_DEPREC_NAME_CHUNKED "deprecated_chunked" +#define DSET_DEPREC_NAME_COMPACT "deprecated_compact" +#define DSET_DEPREC_NAME_FILTER "deprecated_filter" #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Dataset names for testing Fixed Array Indexing */ -#define DSET_FIXED_MAX "DSET_FIXED_MAX" -#define DSET_FIXED_NOMAX "DSET_FIXED_NOMAX" -#define DSET_FIXED_BIG "DSET_FIXED_BIG" -#define POINTS 72 -#define POINTS_BIG 2500 +#define DSET_FIXED_MAX "DSET_FIXED_MAX" +#define DSET_FIXED_NOMAX "DSET_FIXED_NOMAX" +#define DSET_FIXED_BIG "DSET_FIXED_BIG" +#define POINTS 72 +#define POINTS_BIG 2500 /* Dataset names used for testing header flush dependencies */ -#define DSET_EARRAY_HDR_FD "earray_hdr_fd" -#define DSET_FARRAY_HDR_FD "farray_hdr_fd" -#define DSET_BT2_HDR_FD "bt2_hdr_fd" +#define DSET_EARRAY_HDR_FD "earray_hdr_fd" +#define DSET_FARRAY_HDR_FD "farray_hdr_fd" +#define DSET_BT2_HDR_FD "bt2_hdr_fd" /* Dataset names for testing Implicit Indexing */ -#define DSET_SINGLE_MAX "DSET_SINGLE_MAX" -#define DSET_SINGLE_NOMAX "DSET_SINGLE_NOMAX" +#define DSET_SINGLE_MAX "DSET_SINGLE_MAX" +#define DSET_SINGLE_NOMAX "DSET_SINGLE_NOMAX" -#define USER_BLOCK 1024 -#define SIXTY_FOUR_KB 65536 +#define USER_BLOCK 1024 +#define SIXTY_FOUR_KB 65536 /* Temporary filter IDs used for testing */ -#define H5Z_FILTER_BOGUS 305 -#define H5Z_FILTER_CORRUPT 306 -#define H5Z_FILTER_CAN_APPLY_TEST 307 -#define H5Z_FILTER_SET_LOCAL_TEST 308 +#define H5Z_FILTER_BOGUS 305 +#define H5Z_FILTER_CORRUPT 306 +#define H5Z_FILTER_CAN_APPLY_TEST 307 +#define H5Z_FILTER_SET_LOCAL_TEST 308 #ifndef H5_NO_DEPRECATED_SYMBOLS -#define H5Z_FILTER_DEPREC 309 +#define H5Z_FILTER_DEPREC 309 #endif /* H5_NO_DEPRECATED_SYMBOLS */ -#define H5Z_FILTER_EXPAND 310 -#define H5Z_FILTER_CAN_APPLY_TEST2 311 -#define H5Z_FILTER_COUNT 312 +#define H5Z_FILTER_EXPAND 310 +#define H5Z_FILTER_CAN_APPLY_TEST2 311 +#define H5Z_FILTER_COUNT 312 /* Flags for testing filters */ -#define DISABLE_FLETCHER32 0 -#define ENABLE_FLETCHER32 1 -#define DATA_CORRUPTED 1 -#define DATA_NOT_CORRUPTED 0 +#define DISABLE_FLETCHER32 0 +#define ENABLE_FLETCHER32 1 +#define DATA_CORRUPTED 1 +#define DATA_NOT_CORRUPTED 0 /* Parameters for the "set local" test */ -#define BOGUS2_PERM_NPARMS 2 /* Number of "permanent" parameters */ -#define BOGUS2_PARAM_1 13 /* (No particular meaning, just for checking value) */ -#define BOGUS2_PARAM_2 35 /* (No particular meaning, just for checking value) */ -#define BOGUS2_ALL_NPARMS 4 /* Total number of parameter = permanent + "local" parameters */ +#define BOGUS2_PERM_NPARMS 2 /* Number of "permanent" parameters */ +#define BOGUS2_PARAM_1 13 /* (No particular meaning, just for checking value) */ +#define BOGUS2_PARAM_2 35 /* (No particular meaning, just for checking value) */ +#define BOGUS2_ALL_NPARMS 4 /* Total number of parameter = permanent + "local" parameters */ /* Dimensionality for conversion buffer test */ -#define DIM1 100 /* Dim. Size of data member # 1 */ -#define DIM2 5000 /* Dim. Size of data member # 2 */ -#define DIM3 10 /* Dim. Size of data member # 3 */ +#define DIM1 100 /* Dim. Size of data member # 1 */ +#define DIM2 5000 /* Dim. Size of data member # 2 */ +#define DIM3 10 /* Dim. Size of data member # 3 */ /* Parameters for internal filter test */ -#define FILTER_CHUNK_DIM1 2 -#define FILTER_CHUNK_DIM2 25 -#define FILTER_HS_OFFSET1 7 -#define FILTER_HS_OFFSET2 30 -#define FILTER_HS_SIZE1 4 -#define FILTER_HS_SIZE2 50 +#define FILTER_CHUNK_DIM1 2 +#define FILTER_CHUNK_DIM2 25 +#define FILTER_HS_OFFSET1 7 +#define FILTER_HS_OFFSET2 30 +#define FILTER_HS_SIZE1 4 +#define FILTER_HS_SIZE2 50 /* Names for noencoder test */ #ifdef H5_HAVE_FILTER_SZIP -#define NOENCODER_FILENAME "noencoder.h5" -#define NOENCODER_COPY_FILENAME "noencoder.h5.copy" -#define NOENCODER_TEST_DATASET "noencoder_tdset.h5" -#define NOENCODER_SZIP_DATASET "noencoder_szip_dset.h5" +#define NOENCODER_FILENAME "noencoder.h5" +#define NOENCODER_COPY_FILENAME "noencoder.h5.copy" +#define NOENCODER_TEST_DATASET "noencoder_tdset.h5" +#define NOENCODER_SZIP_DATASET "noencoder_szip_dset.h5" #define NOENCODER_SZIP_SHUFF_FLETCH_DATASET "noencoder_szip_shuffle_fletcher_dset.h5" #endif /* H5_HAVE_FILTER_SZIP */ @@ -225,46 +223,46 @@ const char *FILENAME[] = { #define ZERODIM_DATASET2 "zerodim2" /* Parameters for zero-dim test */ -#define MISSING_CHUNK_DATASET "missing_chunk" -#define MISSING_CHUNK_DATASET2 "missing_chunk2" -#define MISSING_CHUNK_DIM 100 +#define MISSING_CHUNK_DATASET "missing_chunk" +#define MISSING_CHUNK_DATASET2 "missing_chunk2" +#define MISSING_CHUNK_DIM 100 /* Names for random chunks test */ -#define NPOINTS 50 +#define NPOINTS 50 /* Parameters for huge chunks test */ -#define HUGE_DATASET "Dataset" -#define HUGE_DIM ((hsize_t)16 * 1024 * 1024 * 1024) -#define HUGE_CHUNK_DIM ((hsize_t)2 * 1024 * 1024 * 1024) -#define TOO_HUGE_CHUNK_DIM ((hsize_t)4 * 1024 * 1024 * 1024) -#define HUGE_DATASET2 "Dataset2" -#define HUGE_DIM2_0 ((hsize_t)16 * 1024) -#define HUGE_DIM2_1 ((hsize_t)16 * 1024) -#define HUGE_DIM2_2 ((hsize_t)16 * 1024) -#define HUGE_CHUNK_DIM2_0 ((hsize_t)2 * 1024) -#define HUGE_CHUNK_DIM2_1 ((hsize_t)1024) -#define HUGE_CHUNK_DIM2_2 ((hsize_t)1024) -#define TOO_HUGE_CHUNK_DIM2_0 ((hsize_t)4 * 1024) -#define TOO_HUGE_CHUNK_DIM2_1 ((hsize_t)1024) -#define TOO_HUGE_CHUNK_DIM2_2 ((hsize_t)1024) +#define HUGE_DATASET "Dataset" +#define HUGE_DIM ((hsize_t)16 * 1024 * 1024 * 1024) +#define HUGE_CHUNK_DIM ((hsize_t)2 * 1024 * 1024 * 1024) +#define TOO_HUGE_CHUNK_DIM ((hsize_t)4 * 1024 * 1024 * 1024) +#define HUGE_DATASET2 "Dataset2" +#define HUGE_DIM2_0 ((hsize_t)16 * 1024) +#define HUGE_DIM2_1 ((hsize_t)16 * 1024) +#define HUGE_DIM2_2 ((hsize_t)16 * 1024) +#define HUGE_CHUNK_DIM2_0 ((hsize_t)2 * 1024) +#define HUGE_CHUNK_DIM2_1 ((hsize_t)1024) +#define HUGE_CHUNK_DIM2_2 ((hsize_t)1024) +#define TOO_HUGE_CHUNK_DIM2_0 ((hsize_t)4 * 1024) +#define TOO_HUGE_CHUNK_DIM2_1 ((hsize_t)1024) +#define TOO_HUGE_CHUNK_DIM2_2 ((hsize_t)1024) /* Parameters for testing bypassing chunk cache */ -#define BYPASS_DATASET1 "Dset1" -#define BYPASS_DATASET2 "Dset2" +#define BYPASS_DATASET1 "Dset1" +#define BYPASS_DATASET2 "Dset2" -#define T_BYPASS_DATASET1 "T_Dset1" -#define T_BYPASS_DATASET2 "T_Dset2" +#define T_BYPASS_DATASET1 "T_Dset1" +#define T_BYPASS_DATASET2 "T_Dset2" -#define BYPASS_DIM 1000 -#define BYPASS_CHUNK_DIM 500 -#define BYPASS_FILL_VALUE 7 +#define BYPASS_DIM 1000 +#define BYPASS_CHUNK_DIM 500 +#define BYPASS_FILL_VALUE 7 /* Parameters for testing extensible array chunk indices */ -#define EARRAY_MAX_RANK 3 -#define EARRAY_DSET_DIM 15 -#define EARRAY_CHUNK_DIM 3 -#define EARRAY_EXTEND_INCR 15 -#define EARRAY_MAX_EXTEND 75 +#define EARRAY_MAX_RANK 3 +#define EARRAY_DSET_DIM 15 +#define EARRAY_CHUNK_DIM 3 +#define EARRAY_EXTEND_INCR 15 +#define EARRAY_MAX_EXTEND 75 /* Parameters for datasets in query storage size tests */ #define STORAGE_SIZE_DIM1 12 @@ -275,60 +273,59 @@ const char *FILENAME[] = { #define STORAGE_SIZE_CHUNK_DIM2 5 /* Shared global arrays */ -#define DSET_DIM1 100 -#define DSET_DIM2 200 -int **points = NULL; -int *points_data = NULL; -double **points_dbl = NULL; -double *points_dbl_data = NULL; -int **check = NULL; -int *check_data = NULL; -double **check_dbl = NULL; -double *check_dbl_data = NULL; -size_t count_nbytes_read = 0; -size_t count_nbytes_written = 0; +#define DSET_DIM1 100 +#define DSET_DIM2 200 +int ** points = NULL; +int * points_data = NULL; +double **points_dbl = NULL; +double * points_dbl_data = NULL; +int ** check = NULL; +int * check_data = NULL; +double **check_dbl = NULL; +double * check_dbl_data = NULL; +size_t count_nbytes_read = 0; +size_t count_nbytes_written = 0; /* Temporary buffer dimensions */ -#define DSET_TMP_DIM1 50 -#define DSET_TMP_DIM2 100 +#define DSET_TMP_DIM1 50 +#define DSET_TMP_DIM2 100 /* Declarations for test_idx_compatible() */ -#define DSET "dset" -#define DSET_FILTER "dset_filter" -const char *OLD_FILENAME[] = { /* Files created under 1.6 branch and 1.8 branch */ +#define DSET "dset" +#define DSET_FILTER "dset_filter" +const char *OLD_FILENAME[] = { + /* Files created under 1.6 branch and 1.8 branch */ "btree_idx_1_6.h5", /* 1.6 HDF5 file */ "btree_idx_1_8.h5" /* 1.8 HDF5 file */ }; - /* Local prototypes for filter functions */ -static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); static htri_t can_apply_bogus(hid_t dcpl_id, hid_t type_id, hid_t space_id); static herr_t set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); -static size_t filter_bogus3(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); -static size_t filter_corrupt(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); -static size_t filter_expand(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); -static size_t filter_count(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus3(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_corrupt(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_expand(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_count(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_COUNT[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_COUNT, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "count", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_count, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_COUNT, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "count", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_count, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: filter_count * @@ -342,10 +339,10 @@ const H5Z_class2_t H5Z_COUNT[1] = {{ */ static size_t filter_count(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { - if(flags & H5Z_FLAG_REVERSE) + if (flags & H5Z_FLAG_REVERSE) count_nbytes_read += nbytes; else count_nbytes_written += nbytes; @@ -353,7 +350,6 @@ filter_count(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, return nbytes; } /* end filter_count() */ - /*------------------------------------------------------------------------- * Function: test_create * @@ -366,50 +362,55 @@ filter_count(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, static herr_t test_create(hid_t file) { - hid_t dataset, space, small_space, create_parms; - hsize_t dims[2], small_dims[2]; - herr_t status; - hsize_t csize[2]; + hid_t dataset, space, small_space, create_parms; + hsize_t dims[2], small_dims[2]; + herr_t status; + hsize_t csize[2]; TESTING("create, open, close"); /* Create the data space */ dims[0] = 256; dims[1] = 512; - space = H5Screate_simple(2, dims, NULL); - assert(space>=0); + space = H5Screate_simple(2, dims, NULL); + assert(space >= 0); /* Create a small data space for compact dataset */ small_dims[0] = 16; small_dims[1] = 8; - small_space = H5Screate_simple(2, small_dims, NULL); - assert(space>=0); + small_space = H5Screate_simple(2, small_dims, NULL); + assert(space >= 0); /* * Create a dataset using the default dataset creation properties. We're * not sure what they are, so we won't check. */ - dataset = H5Dcreate2(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dataset < 0) goto error; + dataset = + H5Dcreate2(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dataset < 0) + goto error; /* Close the dataset */ - if(H5Dclose(dataset) < 0) goto error; + if (H5Dclose(dataset) < 0) + goto error; /* Add a comment to the dataset */ status = H5Oset_comment_by_name(file, DSET_DEFAULT_NAME, "This is a dataset", H5P_DEFAULT); - if(status < 0) goto error; + if (status < 0) + goto error; /* * Try creating a dataset that already exists. This should fail since a * dataset can only be created once. Temporarily turn off error * reporting. */ - H5E_BEGIN_TRY { - dataset = H5Dcreate2(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(dataset >= 0) { + H5E_BEGIN_TRY + { + dataset = H5Dcreate2(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); + } + H5E_END_TRY; + if (dataset >= 0) { H5_FAILED(); HDputs(" Library allowed overwrite of existing dataset."); goto error; @@ -419,19 +420,24 @@ test_create(hid_t file) * Open the dataset we created above and then close it. This is how * existing datasets are accessed. */ - if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) goto error; - if((dataset = H5Dopen2(file, DSET_DEFAULT_NAME, H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) + goto error; + if ((dataset = H5Dopen2(file, DSET_DEFAULT_NAME, H5P_DEFAULT)) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; /* * Try opening a non-existent dataset. This should fail since new datasets * cannot be created with this function. Temporarily turn off error * reporting. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dataset = H5Dopen2(file, "does_not_exist", H5P_DEFAULT); - } H5E_END_TRY; - if(dataset >= 0) { + } + H5E_END_TRY; + if (dataset >= 0) { H5_FAILED(); HDputs(" Opened a non-existent dataset."); goto error; @@ -445,15 +451,17 @@ test_create(hid_t file) assert(create_parms >= 0); /* Attempt to create a dataset with invalid chunk sizes */ - csize[0] = dims[0]*2; - csize[1] = dims[1]*2; - status = H5Pset_chunk(create_parms, 2, csize); + csize[0] = dims[0] * 2; + csize[1] = dims[1] * 2; + status = H5Pset_chunk(create_parms, 2, csize); assert(status >= 0); - H5E_BEGIN_TRY { - dataset = H5Dcreate2(file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT, create_parms, H5P_DEFAULT); - } H5E_END_TRY; - if(dataset >= 0) { + H5E_BEGIN_TRY + { + dataset = H5Dcreate2(file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, create_parms, + H5P_DEFAULT); + } + H5E_END_TRY; + if (dataset >= 0) { H5_FAILED(); HDputs(" Opened a dataset with incorrect chunking parameters."); goto error; @@ -461,21 +469,24 @@ test_create(hid_t file) csize[0] = 5; csize[1] = 100; - status = H5Pset_chunk(create_parms, 2, csize); + status = H5Pset_chunk(create_parms, 2, csize); assert(status >= 0); - dataset = H5Dcreate2(file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT, create_parms, H5P_DEFAULT); - if(dataset < 0) goto error; + dataset = + H5Dcreate2(file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, create_parms, H5P_DEFAULT); + if (dataset < 0) + goto error; H5Pclose(create_parms); /* Test dataset address. Should be undefined. */ - if(H5Dget_offset(dataset)!=HADDR_UNDEF) goto error; + if (H5Dget_offset(dataset) != HADDR_UNDEF) + goto error; /* * Close the chunked dataset. */ - if(H5Dclose(dataset) < 0) goto error; + if (H5Dclose(dataset) < 0) + goto error; /* * Create a compact dataset, then close it. @@ -487,20 +498,21 @@ test_create(hid_t file) status = H5Pset_alloc_time(create_parms, H5D_ALLOC_TIME_EARLY); assert(status >= 0); - dataset = H5Dcreate2(file, DSET_COMPACT_NAME, H5T_NATIVE_DOUBLE, - small_space, H5P_DEFAULT, create_parms, H5P_DEFAULT); - if(dataset < 0) goto error; + dataset = H5Dcreate2(file, DSET_COMPACT_NAME, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, create_parms, + H5P_DEFAULT); + if (dataset < 0) + goto error; H5Pclose(create_parms); - if(H5Dclose(dataset) < 0) goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); return SUCCEED; - error: +error: return FAIL; } /* end test_create() */ - /*------------------------------------------------------------------------- * Function: test_simple_io * @@ -515,75 +527,81 @@ test_create(hid_t file) static herr_t test_simple_io(const char *env_h5_drvr, hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t file = -1, dataset = -1, space = -1, xfer = -1; - int i, j, n; - hsize_t dims[2]; - void *tconv_buf = NULL; - int f = -1; - haddr_t offset; - int **rdata = NULL; - int *rdata_bytes = NULL; + char filename[FILENAME_BUF_SIZE]; + hid_t file = -1, dataset = -1, space = -1, xfer = -1; + int i, j, n; + hsize_t dims[2]; + void * tconv_buf = NULL; + int f = -1; + haddr_t offset; + int ** rdata = NULL; + int * rdata_bytes = NULL; TESTING("simple I/O"); /* Can't run this test with multi-file VFDs because of HDopen/read/seek the file directly */ - if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { + if (HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { h5_fixname(FILENAME[4], fapl, filename, sizeof filename); /* Set up data array */ - if(NULL == (rdata_bytes = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + if (NULL == (rdata_bytes = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) TEST_ERROR; - if(NULL == (rdata = (int **)HDcalloc(DSET_DIM1, sizeof(rdata_bytes)))) + if (NULL == (rdata = (int **)HDcalloc(DSET_DIM1, sizeof(rdata_bytes)))) TEST_ERROR; for (i = 0; i < DSET_DIM1; i++) rdata[i] = rdata_bytes + (i * DSET_DIM2); /* Initialize the dataset */ - for(i = n = 0; i < DSET_DIM1; i++) - for(j = 0; j < DSET_DIM2; j++) + for (i = n = 0; i < DSET_DIM1; i++) + for (j = 0; j < DSET_DIM2; j++) points[i][j] = n++; - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Create the data space */ dims[0] = DSET_DIM1; dims[1] = DSET_DIM2; - if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; /* Create a small conversion buffer to test strip mining */ tconv_buf = HDmalloc((size_t)1000); - xfer = H5Pcreate(H5P_DATASET_XFER); - assert(xfer>=0); - if(H5Pset_buffer (xfer, (size_t)1000, tconv_buf, NULL) < 0) goto error; + xfer = H5Pcreate(H5P_DATASET_XFER); + assert(xfer >= 0); + if (H5Pset_buffer(xfer, (size_t)1000, tconv_buf, NULL) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Sclose(space) < 0) TEST_ERROR + if ((dataset = H5Dcreate2(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + goto error; + if (H5Sclose(space) < 0) + TEST_ERROR space = -1; /* Test dataset address. Should be undefined. */ - if(H5Dget_offset(dataset) != HADDR_UNDEF) goto error; + if (H5Dget_offset(dataset) != HADDR_UNDEF) + goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points_data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points_data) < 0) goto error; /* Test dataset address in file. Open the same file as a C file, seek * the data position as H5Dget_offset points to, read the dataset, and * compare it with the data written in.*/ - if((offset=H5Dget_offset(dataset))==HADDR_UNDEF) goto error; + if ((offset = H5Dget_offset(dataset)) == HADDR_UNDEF) + goto error; /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check_data) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check_data) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i = 0; i < DSET_DIM1; i++) { - for(j = 0; j < DSET_DIM2; j++) { - if(points[i][j] != check[i][j]) { + for (i = 0; i < DSET_DIM1; i++) { + for (j = 0; j < DSET_DIM2; j++) { + if (points[i][j] != check[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -592,22 +610,25 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) } } - if(H5Pclose (xfer) < 0) goto error; - xfer = -1; - if(H5Dclose(dataset) < 0) goto error; - dataset = -1; - if(H5Fclose(file) < 0) goto error; - file = -1; + if (H5Pclose(xfer) < 0) + goto error; + xfer = -1; + if (H5Dclose(dataset) < 0) + goto error; + dataset = -1; + if (H5Fclose(file) < 0) + goto error; + file = -1; f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); - if(HDread(f, rdata_bytes, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + if (HDread(f, rdata_bytes, sizeof(int) * DSET_DIM1 * DSET_DIM2) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i = 0; i < DSET_DIM1; i++) { - for(j = 0; j < DSET_DIM2; j++) { - if(points[i][j] != rdata[i][j]) { + for (i = 0; i < DSET_DIM1; i++) { + for (j = 0; j < DSET_DIM2; j++) { + if (points[i][j] != rdata[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -633,15 +654,19 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) return SUCCEED; error: - if(space > 0) - if(H5Sclose(space) < 0) TEST_ERROR - if(xfer > 0) - if(H5Pclose(xfer) < 0) TEST_ERROR - if(dataset > 0) - if(H5Dclose(dataset) < 0) TEST_ERROR - if(file > 0) - if(H5Fclose(file) < 0) TEST_ERROR - if(f > 0) + if (space > 0) + if (H5Sclose(space) < 0) + TEST_ERROR + if (xfer > 0) + if (H5Pclose(xfer) < 0) + TEST_ERROR + if (dataset > 0) + if (H5Dclose(dataset) < 0) + TEST_ERROR + if (file > 0) + if (H5Fclose(file) < 0) + TEST_ERROR + if (f > 0) HDclose(f); HDfree(tconv_buf); @@ -651,7 +676,6 @@ error: return FAIL; } /* end test_simple_io() */ - /*------------------------------------------------------------------------- * Function: test_userblock_offset * @@ -664,74 +688,83 @@ error: static herr_t test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - char filename[FILENAME_BUF_SIZE]; - hid_t file = -1, fcpl = -1, dataset = -1, space = -1; - int i, j; - hsize_t dims[2]; - int f = -1; - haddr_t offset; - int **rdata = NULL; - int *rdata_bytes = NULL; + char filename[FILENAME_BUF_SIZE]; + hid_t file = -1, fcpl = -1, dataset = -1, space = -1; + int i, j; + hsize_t dims[2]; + int f = -1; + haddr_t offset; + int ** rdata = NULL; + int * rdata_bytes = NULL; TESTING("dataset offset with user block"); /* Can't run this test with multi-file VFDs because of HDopen/read/seek the file directly */ - if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { + if (HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { h5_fixname(FILENAME[2], fapl, filename, sizeof filename); /* Set up data array */ - if(NULL == (rdata_bytes = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + if (NULL == (rdata_bytes = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) TEST_ERROR; - if(NULL == (rdata = (int **)HDcalloc(DSET_DIM1, sizeof(rdata_bytes)))) + if (NULL == (rdata = (int **)HDcalloc(DSET_DIM1, sizeof(rdata_bytes)))) TEST_ERROR; for (i = 0; i < DSET_DIM1; i++) rdata[i] = rdata_bytes + (i * DSET_DIM2); - if((fcpl=H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; - if(H5Pset_userblock(fcpl, (hsize_t)USER_BLOCK) < 0) goto error; - if(new_format) - if(H5Pset_file_space_page_size(fcpl, (hsize_t)USER_BLOCK) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + if (H5Pset_userblock(fcpl, (hsize_t)USER_BLOCK) < 0) + goto error; + if (new_format) + if (H5Pset_file_space_page_size(fcpl, (hsize_t)USER_BLOCK) < 0) goto error; - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; - if(H5Pclose(fcpl) < 0) TEST_ERROR + if (H5Pclose(fcpl) < 0) + TEST_ERROR fcpl = -1; /* Create the data space */ dims[0] = DSET_DIM1; dims[1] = DSET_DIM2; - if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_USERBLOCK_IO_NAME, H5T_NATIVE_INT, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Sclose(space) < 0) TEST_ERROR + if ((dataset = H5Dcreate2(file, DSET_USERBLOCK_IO_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Sclose(space) < 0) + TEST_ERROR space = -1; /* Write the data to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) goto error; /* Test dataset address in file. Open the same file as a C file, seek * the data position as H5Dget_offset points to, read the dataset, and * compare it with the data written in.*/ - if((offset = H5Dget_offset(dataset)) == HADDR_UNDEF) goto error; + if ((offset = H5Dget_offset(dataset)) == HADDR_UNDEF) + goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Dclose(dataset) < 0) + goto error; dataset = -1; - if(H5Fclose(file) < 0) goto error; + if (H5Fclose(file) < 0) + goto error; file = -1; f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); - if(HDread(f, rdata_bytes, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + if (HDread(f, rdata_bytes, sizeof(int) * DSET_DIM1 * DSET_DIM2) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i = 0; i < DSET_DIM1; i++) { - for(j = 0; j < DSET_DIM2; j++) { - if(points[i][j] != rdata[i][j]) { + for (i = 0; i < DSET_DIM1; i++) { + for (j = 0; j < DSET_DIM2; j++) { + if (points[i][j] != rdata[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -756,15 +789,19 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) return SUCCEED; error: - if(space > 0) - if(H5Sclose(space) < 0) TEST_ERROR - if(fcpl > 0) - if(H5Pclose(fcpl) < 0) TEST_ERROR - if(dataset > 0) - if(H5Dclose(dataset) < 0) TEST_ERROR - if(file > 0) - if(H5Fclose(file) < 0) TEST_ERROR - if(f > 0) + if (space > 0) + if (H5Sclose(space) < 0) + TEST_ERROR + if (fcpl > 0) + if (H5Pclose(fcpl) < 0) + TEST_ERROR + if (dataset > 0) + if (H5Dclose(dataset) < 0) + TEST_ERROR + if (file > 0) + if (H5Fclose(file) < 0) + TEST_ERROR + if (f > 0) HDclose(f); HDfree(rdata_bytes); @@ -773,7 +810,6 @@ error: return FAIL; } /* end test_userblock_offset() */ - /*------------------------------------------------------------------------- * Function: test_compact_io * @@ -789,129 +825,146 @@ error: static herr_t test_compact_io(hid_t fapl) { - hid_t file, dataset, space, plist; - hid_t verfile = -1, new_fapl = -1; - hsize_t dims[2]; - int wbuf[16][8], rbuf[16][8]; - char filename[FILENAME_BUF_SIZE]; - H5F_libver_t low, high; /* File format bounds */ - H5F_t *fp; /* Internal file pointer */ - H5D_t *dsetp; /* Internal dataset pointer */ - int i, j, n; /* Indices */ - herr_t ret; /* Generic return value */ + hid_t file, dataset, space, plist; + hid_t verfile = -1, new_fapl = -1; + hsize_t dims[2]; + int wbuf[16][8], rbuf[16][8]; + char filename[FILENAME_BUF_SIZE]; + H5F_libver_t low, high; /* File format bounds */ + H5F_t * fp; /* Internal file pointer */ + H5D_t * dsetp; /* Internal dataset pointer */ + int i, j, n; /* Indices */ + herr_t ret; /* Generic return value */ TESTING("compact dataset I/O"); /* Initialize data */ n = 0; - for(i = 0; i < 16; i++) - for(j = 0; j < 8; j++) + for (i = 0; i < 16; i++) + for (j = 0; j < 8; j++) wbuf[i][j] = n++; /* Create a small data space for compact dataset */ dims[0] = 16; dims[1] = 8; - if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR /* Create a file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create property list for compact dataset creation */ - if((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_layout(plist, H5D_COMPACT) < 0) TEST_ERROR - if(H5Pset_alloc_time(plist, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + if ((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_layout(plist, H5D_COMPACT) < 0) + TEST_ERROR + if (H5Pset_alloc_time(plist, H5D_ALLOC_TIME_EARLY) < 0) + TEST_ERROR /* Create and write to a compact dataset */ - if((dataset = H5Dcreate2(file, DSET_COMPACT_IO_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_COMPACT_IO_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, + H5P_DEFAULT)) < 0) TEST_ERROR /* Test dataset address. Should be undefined. */ - if(H5Dget_offset(dataset) != HADDR_UNDEF) TEST_ERROR + if (H5Dget_offset(dataset) != HADDR_UNDEF) + TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR /* Test dataset address. Should be undefined. */ - if(H5Dget_offset(dataset)!=HADDR_UNDEF) TEST_ERROR + if (H5Dget_offset(dataset) != HADDR_UNDEF) + TEST_ERROR /* Close file */ - if(H5Dclose(dataset) < 0) TEST_ERROR - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Dclose(dataset) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR /* * Open the file and check data */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((dataset = H5Dopen2(file, DSET_COMPACT_IO_NAME, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_COMPACT_IO_NAME, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR - /* Check that the values read are the same as the values written */ - for(i = 0; i < 16; i++) - for(j = 0; j < 8; j++) - if(rbuf[i][j] != wbuf[i][j]) { - H5_FAILED(); - HDprintf(" Read different values than written.\n"); - HDprintf(" At index %d,%d\n", i, j); - HDprintf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); - HDprintf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); - goto error; - } /* end */ + /* Check that the values read are the same as the values written */ + for (i = 0; i < 16; i++) + for (j = 0; j < 8; j++) + if (rbuf[i][j] != wbuf[i][j]) { + H5_FAILED(); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %d,%d\n", i, j); + HDprintf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); + HDprintf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); + goto error; + } /* end */ - if(H5Dclose(dataset) < 0) TEST_ERROR - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Dclose(dataset) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR /************************************** * Additional test for version bounds * **************************************/ /* Create a copy of file access property list */ - if((new_fapl = h5_fileaccess()) < 0) TEST_ERROR + if ((new_fapl = h5_fileaccess()) < 0) + TEST_ERROR /* Loop through all the combinations of low/high library format bounds, skipping invalid combinations. - Create a file, create and write a compact dataset, and verify its data - Verify the dataset's layout and fill message versions */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Set version bounds */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ continue; /* Create a file */ h5_fixname(FILENAME[25], new_fapl, filename, sizeof filename); - if((verfile = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, new_fapl)) < 0) + if ((verfile = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, new_fapl)) < 0) TEST_ERROR /* Create the compact dataset */ - dataset = H5Dcreate2(verfile, DSET_DEFAULT_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, H5P_DEFAULT); - if(dataset < 0) TEST_ERROR + dataset = H5Dcreate2(verfile, DSET_DEFAULT_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, + H5P_DEFAULT); + if (dataset < 0) + TEST_ERROR /* Write the same data as of DSET_COMPACT_IO_NAME */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR /* Close DSET_DEFAULT_NAME, then reopen it to read and verify the data */ - if(H5Dclose(dataset) < 0) TEST_ERROR - if((dataset = H5Dopen2(verfile, DSET_DEFAULT_NAME, H5P_DEFAULT)) < 0) + if (H5Dclose(dataset) < 0) + TEST_ERROR + if ((dataset = H5Dopen2(verfile, DSET_DEFAULT_NAME, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR /* Check that the values read are the same as the values written */ - for(i = 0; i < 16; i++) - for(j = 0; j < 8; j++) - if(rbuf[i][j] != wbuf[i][j]) { + for (i = 0; i < 16; i++) + for (j = 0; j < 8; j++) + if (rbuf[i][j] != wbuf[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -921,52 +974,63 @@ test_compact_io(hid_t fapl) } /* end */ /* Get the internal file pointer */ - if((fp = (H5F_t *)H5VL_object(verfile)) == NULL) TEST_ERROR + if ((fp = (H5F_t *)H5VL_object(verfile)) == NULL) + TEST_ERROR /* Get the internal dataset pointer */ - if((dsetp = (H5D_t *)H5VL_object(dataset)) == NULL) TEST_ERROR + if ((dsetp = (H5D_t *)H5VL_object(dataset)) == NULL) + TEST_ERROR /* Verify the dataset's layout and fill message versions */ - if(fp->shared->low_bound == H5F_LIBVER_EARLIEST) { + if (fp->shared->low_bound == H5F_LIBVER_EARLIEST) { VERIFY(dsetp->shared->layout.version, H5O_LAYOUT_VERSION_DEFAULT, "layout_ver_bounds"); VERIFY(dsetp->shared->dcpl_cache.fill.version, H5O_FILL_VERSION_2, "fill_ver_bounds"); - } else { - VERIFY(dsetp->shared->layout.version, H5O_layout_ver_bounds[fp->shared->low_bound], "layout_ver_bounds"); - VERIFY(dsetp->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[fp->shared->low_bound], "fill_ver_bounds"); + } + else { + VERIFY(dsetp->shared->layout.version, H5O_layout_ver_bounds[fp->shared->low_bound], + "layout_ver_bounds"); + VERIFY(dsetp->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[fp->shared->low_bound], + "fill_ver_bounds"); } /* Close the dataset and delete from the file */ - if(H5Dclose(dataset) < 0) TEST_ERROR - if(H5Ldelete(verfile, DSET_DEFAULT_NAME, H5P_DEFAULT) < 0) + if (H5Dclose(dataset) < 0) + TEST_ERROR + if (H5Ldelete(verfile, DSET_DEFAULT_NAME, H5P_DEFAULT) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(verfile) < 0) TEST_ERROR + if (H5Fclose(verfile) < 0) + TEST_ERROR } /* end for high */ - } /* end for low */ + } /* end for low */ - if(H5Pclose(new_fapl) < 0) TEST_ERROR - if(H5Sclose(space) < 0) TEST_ERROR - if(H5Pclose(plist) < 0) TEST_ERROR + if (H5Pclose(new_fapl) < 0) + TEST_ERROR + if (H5Sclose(space) < 0) + TEST_ERROR + if (H5Pclose(plist) < 0) + TEST_ERROR PASSED(); return SUCCEED; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Sclose(space); H5Pclose(plist); H5Pclose(new_fapl); H5Dclose(dataset); H5Fclose(file); H5Fclose(verfile); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_compact_io() */ - /*------------------------------------------------------------------------- * Function: test_max_compact * @@ -979,17 +1043,17 @@ test_compact_io(hid_t fapl) static herr_t test_max_compact(hid_t fapl) { - hid_t file = -1; - hid_t dataset = -1; - hid_t space = -1; - hid_t plist = -1; - hsize_t dims[1]; - size_t compact_size; - int *wbuf = NULL; - int *rbuf = NULL; - char filename[FILENAME_BUF_SIZE]; - int n; - size_t u; + hid_t file = -1; + hid_t dataset = -1; + hid_t space = -1; + hid_t plist = -1; + hsize_t dims[1]; + size_t compact_size; + int * wbuf = NULL; + int * rbuf = NULL; + char filename[FILENAME_BUF_SIZE]; + int n; + size_t u; TESTING("compact dataset of maximal size"); @@ -998,128 +1062,132 @@ test_max_compact(hid_t fapl) /* Initialize data */ compact_size = (SIXTY_FOUR_KB - 64) / sizeof(int); - if(NULL == (wbuf = (int *)HDmalloc(sizeof(int) * compact_size))) + if (NULL == (wbuf = (int *)HDmalloc(sizeof(int) * compact_size))) TEST_ERROR - if(NULL == (rbuf = (int *)HDmalloc(sizeof(int) * compact_size))) + if (NULL == (rbuf = (int *)HDmalloc(sizeof(int) * compact_size))) TEST_ERROR n = 0; - for(u = 0; u < compact_size; u++) + for (u = 0; u < compact_size; u++) wbuf[u] = n++; /* Create a small data space for compact dataset */ dims[0] = (hsize_t)compact_size; - if((space = H5Screate_simple(1, dims, NULL)) < 0) + if ((space = H5Screate_simple(1, dims, NULL)) < 0) FAIL_STACK_ERROR /* Create a file */ h5_fixname(FILENAME[3], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create property list for compact dataset creation */ - if((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_layout(plist, H5D_COMPACT) < 0) + if (H5Pset_layout(plist, H5D_COMPACT) < 0) FAIL_STACK_ERROR /* Create and write to a compact dataset */ - if((dataset = H5Dcreate2(file, DSET_COMPACT_MAX_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_COMPACT_MAX_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, + H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Pclose(plist) < 0) + if (H5Pclose(plist) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* * Open the file and check data */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR - if((dataset = H5Dopen2(file, DSET_COMPACT_MAX_NAME, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DSET_COMPACT_MAX_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR /* Check that the values read are the same as the values written */ - for(u = 0; u < compact_size; u++) - if(rbuf[u] != wbuf[u]) { + for (u = 0; u < compact_size; u++) + if (rbuf[u] != wbuf[u]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %u\n", (unsigned)u); goto error; } /* end if */ - if(H5Dclose(dataset) < 0) - FAIL_STACK_ERROR - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - HDfree(wbuf); - wbuf = NULL; - HDfree(rbuf); - rbuf = NULL; - - /* Test compact dataset of size 64KB */ - - /* Create a data space for compact dataset */ - compact_size = SIXTY_FOUR_KB / sizeof(int); - dims[0] = (hsize_t)compact_size; - if((space = H5Screate_simple(1, dims, NULL)) < 0) - FAIL_STACK_ERROR - - /* Open file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - goto error; - - /* Create property list for compact dataset creation */ - if((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR - if(H5Pset_layout(plist, H5D_COMPACT) < 0) - FAIL_STACK_ERROR - - /* Create and write to a compact dataset */ - H5E_BEGIN_TRY { - H5Dcreate2(file, DSET_COMPACT_MAX2_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, H5P_DEFAULT); - } H5E_END_TRY; - - /* Close file */ - if(H5Sclose(space) < 0) - FAIL_STACK_ERROR - if(H5Pclose(plist) < 0) - FAIL_STACK_ERROR - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - - PASSED(); - return SUCCEED; + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR + HDfree(wbuf); + wbuf = NULL; + HDfree(rbuf); + rbuf = NULL; + + /* Test compact dataset of size 64KB */ + + /* Create a data space for compact dataset */ + compact_size = SIXTY_FOUR_KB / sizeof(int); + dims[0] = (hsize_t)compact_size; + if ((space = H5Screate_simple(1, dims, NULL)) < 0) + FAIL_STACK_ERROR + + /* Open file */ + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + goto error; + + /* Create property list for compact dataset creation */ + if ((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_layout(plist, H5D_COMPACT) < 0) + FAIL_STACK_ERROR + + /* Create and write to a compact dataset */ + H5E_BEGIN_TRY + { + H5Dcreate2(file, DSET_COMPACT_MAX2_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, H5P_DEFAULT); + } + H5E_END_TRY; + + /* Close file */ + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Pclose(plist) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + return SUCCEED; error: - if(wbuf) + if (wbuf) HDfree(wbuf); - if(rbuf) + if (rbuf) HDfree(rbuf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { /* Close file */ H5Sclose(space); H5Pclose(plist); H5Dclose(dataset); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; - return FAIL; + return FAIL; } /* end test_max_compact() */ - /*------------------------------------------------------------------------- * Function: test_layout_extend * @@ -1137,98 +1205,121 @@ error: static herr_t test_layout_extend(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; /* File name */ - hid_t fid = -1; /* File id */ - hid_t sid_fix = -1, sid_unlim = -1; /* Dataspace id */ - hid_t dcpl_compact = -1, dcpl_contig = -1, dcpl_chunked = -1; /* Dataset creation property list id */ - hid_t did_fixed = -1, did_unlim = -1; /* Dataset id */ - hsize_t cur_size[1] = {10}; /* Current size of dataspace */ - hsize_t max_unlim[1] = {H5S_UNLIMITED}; /* Maximum size of dataspace (unlimited) */ - hsize_t max_fix[1] = {100}; /* Maximum size of dataspace (fixed) */ + char filename[FILENAME_BUF_SIZE]; /* File name */ + hid_t fid = -1; /* File id */ + hid_t sid_fix = -1, sid_unlim = -1; /* Dataspace id */ + hid_t dcpl_compact = -1, dcpl_contig = -1, dcpl_chunked = -1; /* Dataset creation property list id */ + hid_t did_fixed = -1, did_unlim = -1; /* Dataset id */ + hsize_t cur_size[1] = {10}; /* Current size of dataspace */ + hsize_t max_unlim[1] = {H5S_UNLIMITED}; /* Maximum size of dataspace (unlimited) */ + hsize_t max_fix[1] = {100}; /* Maximum size of dataspace (fixed) */ hsize_t chunk_dim[1] = {10}; /* Chunk size */ TESTING("extendible dataset with various layout"); /* Create a file */ h5_fixname(FILENAME[15], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create dataspace */ - if((sid_fix = H5Screate_simple(1, cur_size, max_fix)) < 0) + if ((sid_fix = H5Screate_simple(1, cur_size, max_fix)) < 0) FAIL_STACK_ERROR - if((sid_unlim = H5Screate_simple(1, cur_size, max_unlim)) < 0) + if ((sid_unlim = H5Screate_simple(1, cur_size, max_unlim)) < 0) FAIL_STACK_ERROR /* Create property list for compact dataset creation */ - if((dcpl_compact = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_compact = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_layout(dcpl_compact, H5D_COMPACT) < 0) + if (H5Pset_layout(dcpl_compact, H5D_COMPACT) < 0) FAIL_STACK_ERROR /* Create dataset with extendible dataspace (fixed max_dims) should fail */ - H5E_BEGIN_TRY { - if(H5Dcreate2(fid, "compact", H5T_NATIVE_INT, sid_fix, H5P_DEFAULT, dcpl_compact, H5P_DEFAULT) != FAIL) - TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Dcreate2(fid, "compact", H5T_NATIVE_INT, sid_fix, H5P_DEFAULT, dcpl_compact, H5P_DEFAULT) != + FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Create dataset with extendible dataspace (unlimited max_dims) should fail */ - H5E_BEGIN_TRY { - if(H5Dcreate2(fid, "compact", H5T_NATIVE_INT, sid_unlim, H5P_DEFAULT, dcpl_compact, H5P_DEFAULT) != FAIL) - TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Dcreate2(fid, "compact", H5T_NATIVE_INT, sid_unlim, H5P_DEFAULT, dcpl_compact, H5P_DEFAULT) != + FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Create property list for contiguous dataset creation */ - if((dcpl_contig = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_contig = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if((H5Pset_layout(dcpl_contig, H5D_CONTIGUOUS)) < 0) + if ((H5Pset_layout(dcpl_contig, H5D_CONTIGUOUS)) < 0) FAIL_STACK_ERROR /* Create dataset with extendible dataspace (fixed max_dims) should fail */ - H5E_BEGIN_TRY { - if(H5Dcreate2(fid, "contig", H5T_NATIVE_INT, sid_fix, H5P_DEFAULT, dcpl_contig, H5P_DEFAULT) != FAIL) - TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Dcreate2(fid, "contig", H5T_NATIVE_INT, sid_fix, H5P_DEFAULT, dcpl_contig, H5P_DEFAULT) != FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Create dataset with extendible dataspace (unlimited max_dims) should fail*/ - H5E_BEGIN_TRY { - if(H5Dcreate2(fid, "contig", H5T_NATIVE_INT, sid_unlim, H5P_DEFAULT, dcpl_contig, H5P_DEFAULT) != FAIL) - TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Dcreate2(fid, "contig", H5T_NATIVE_INT, sid_unlim, H5P_DEFAULT, dcpl_contig, H5P_DEFAULT) != + FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Create property list for chunked dataset creation */ - if((dcpl_chunked = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_chunked = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_layout(dcpl_chunked, H5D_CHUNKED) < 0) FAIL_STACK_ERROR - if(H5Pset_layout(dcpl_chunked, H5D_CHUNKED) < 0) + if (H5Pset_chunk(dcpl_chunked, 1, chunk_dim) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl_chunked, 1, chunk_dim) < 0) FAIL_STACK_ERROR /* Create dataset with extendible dataspace (fixed max_dims) should succeed */ - if((did_fixed = H5Dcreate2(fid, "chunked_fixed", H5T_NATIVE_INT, sid_fix, H5P_DEFAULT, dcpl_chunked, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did_fixed = H5Dcreate2(fid, "chunked_fixed", H5T_NATIVE_INT, sid_fix, H5P_DEFAULT, dcpl_chunked, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create dataset with extendible dataspace (unlimited max_dims) should succeed */ - if((did_unlim = H5Dcreate2(fid, "chunked_unlim", H5T_NATIVE_INT, sid_unlim, H5P_DEFAULT, dcpl_chunked, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did_unlim = H5Dcreate2(fid, "chunked_unlim", H5T_NATIVE_INT, sid_unlim, H5P_DEFAULT, dcpl_chunked, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Closing */ - if(H5Sclose(sid_fix) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid_unlim) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid_fix) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid_unlim) < 0) + FAIL_STACK_ERROR - if(H5Pclose(dcpl_compact) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl_contig) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl_chunked) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl_compact) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl_contig) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl_chunked) < 0) + FAIL_STACK_ERROR - if(H5Dclose(did_fixed) < 0) FAIL_STACK_ERROR - if(H5Dclose(did_unlim) < 0) FAIL_STACK_ERROR + if (H5Dclose(did_fixed) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did_unlim) < 0) + FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid_fix); H5Sclose(sid_unlim); H5Pclose(dcpl_compact); @@ -1237,12 +1328,12 @@ error: H5Dclose(did_fixed); H5Dclose(did_unlim); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; - return FAIL; + return FAIL; } /* end test_layout_extend() */ - /*------------------------------------------------------------------------- * Function: test_conv_buffer * @@ -1255,135 +1346,160 @@ error: static herr_t test_conv_buffer(hid_t fid) { - typedef struct - { - int a[DIM1][DIM2][DIM3]; - float b[DIM2]; - double c[DIM3]; + typedef struct { + int a[DIM1][DIM2][DIM3]; + float b[DIM2]; + double c[DIM3]; } CmpField; - typedef struct - { - float b[DIM2]; - double c[DIM3]; + typedef struct { + float b[DIM2]; + double c[DIM3]; } CmpFieldR; - herr_t status = -1; - int j, k, l; - - CmpField *cf = NULL; - CmpFieldR *cfrR = NULL; - - hid_t dataset = H5I_INVALID_HID; /* dataset ID */ - hid_t space = H5I_INVALID_HID; /* data space ID */ - hid_t ctype1 = H5I_INVALID_HID, - ctype2 = H5I_INVALID_HID; /* data type ID */ - hid_t arr_type1 = H5I_INVALID_HID, - arr_type2 = H5I_INVALID_HID, - arr_type3 = H5I_INVALID_HID, - arr_type4 = H5I_INVALID_HID, - arr_type5 = H5I_INVALID_HID; - hsize_t dimsa[3]; - hsize_t dimsb[1]; - hsize_t dimsc[1]; - hid_t xfer_list = H5I_INVALID_HID; - size_t size; + herr_t status = -1; + int j, k, l; + + CmpField * cf = NULL; + CmpFieldR *cfrR = NULL; + + hid_t dataset = H5I_INVALID_HID; /* dataset ID */ + hid_t space = H5I_INVALID_HID; /* data space ID */ + hid_t ctype1 = H5I_INVALID_HID, ctype2 = H5I_INVALID_HID; /* data type ID */ + hid_t arr_type1 = H5I_INVALID_HID, arr_type2 = H5I_INVALID_HID, arr_type3 = H5I_INVALID_HID, + arr_type4 = H5I_INVALID_HID, arr_type5 = H5I_INVALID_HID; + hsize_t dimsa[3]; + hsize_t dimsb[1]; + hsize_t dimsc[1]; + hid_t xfer_list = H5I_INVALID_HID; + size_t size; TESTING("data type conversion buffer size"); - if ((cf = (CmpField *)HDcalloc((size_t)1, sizeof(CmpField))) == 0) goto error; + if ((cf = (CmpField *)HDcalloc((size_t)1, sizeof(CmpField))) == 0) + goto error; /* Populate the data members */ - for(j = 0; j < DIM1; j++) - for(k = 0; k < DIM2; k++) - for(l = 0; l < DIM3; l++) - cf->a[j][k][l] = 10*(j+1) + l + k; - - for(j = 0; j < DIM2; j++) - cf->b[j] = 100.0f * (float)(j+1) + 0.01f * (float)j; - - for(j = 0; j < DIM3; j++) - cf->c[j] = 100.0f * (float)(j+1) + 0.02f * (float)j; - - - /* Create data space */ - if((space=H5Screate(H5S_SCALAR)) < 0) goto error; - - /* Add members to the compound data type */ - dimsa[0] = DIM1; - dimsa[1] = DIM2; - dimsa[2] = DIM3; - dimsb[0] = DIM2; - dimsc[0] = DIM3; - - /* Create the memory data type */ - if((ctype1 = H5Tcreate(H5T_COMPOUND, sizeof (CmpField))) < 0) goto error; - - if((arr_type1 = H5Tarray_create2(H5T_NATIVE_INT, 3, dimsa)) < 0) goto error; - if((arr_type2 = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, dimsb)) < 0) goto error; - if((arr_type3 = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, dimsc)) < 0) goto error; - - if(H5Tinsert(ctype1, "A", HOFFSET(CmpField, a), arr_type1) < 0) goto error; - if(H5Tinsert(ctype1, "B", HOFFSET(CmpField, b), arr_type2) < 0) goto error; - if(H5Tinsert(ctype1, "C", HOFFSET(CmpField, c), arr_type3) < 0) goto error; - - /* Create the dataset */ - if((dataset = H5Dcreate2(fid, DSET_CONV_BUF_NAME, ctype1, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(dataset, ctype1, H5S_ALL, H5S_ALL, H5P_DEFAULT, cf) < 0) goto error; - - if((ctype2 = H5Tcreate(H5T_COMPOUND, sizeof (CmpFieldR))) < 0) goto error; - - if((arr_type4 = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, dimsb)) < 0) goto error; - if((arr_type5 = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, dimsc)) < 0) goto error; - - if(H5Tinsert(ctype2, "B", HOFFSET(CmpFieldR, b), arr_type4) < 0) goto error; - if(H5Tinsert(ctype2, "C", HOFFSET(CmpFieldR, c), arr_type5) < 0) goto error; - - /* Read should succeed since library will set conversion buffer big enough */ - if ((cfrR = (CmpFieldR *)HDcalloc((size_t)1, sizeof(CmpFieldR))) == 0) goto error; - if(H5Dread(dataset, ctype2, H5S_ALL, H5S_ALL, H5P_DEFAULT, cfrR) < 0) goto error; - - /* Read should fail since conversion buffer isn't big enough */ - xfer_list = H5Pcreate(H5P_DATASET_XFER); - size = (DIM2 * DIM3 * (sizeof(int))+ DIM2 * (sizeof(float))+ - DIM3 * (sizeof(double))); - if(H5Pset_buffer(xfer_list, size, NULL, NULL) < 0) goto error; - - H5E_BEGIN_TRY { - status = H5Dread(dataset, ctype2, H5S_ALL, H5S_ALL, xfer_list, cfrR); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Library shouldn't allow conversion buffer too small"); - goto error; - } - - /* Read will succeed since conversion buffer is big enough */ - size = (DIM1 * DIM2 * DIM3 * (sizeof(int))+ DIM2 * (sizeof(float))+ - DIM3 * (sizeof(double))); - if(H5Pset_buffer(xfer_list, size, NULL, NULL) < 0) goto error; - - if(H5Dread(dataset, ctype2, H5S_ALL, H5S_ALL, xfer_list, cfrR) < 0) goto error; - - - if(H5Pclose(xfer_list) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Tclose(arr_type1) < 0) goto error; - if(H5Tclose(arr_type2) < 0) goto error; - if(H5Tclose(arr_type3) < 0) goto error; - if(H5Tclose(ctype1) < 0) goto error; - if(H5Tclose(ctype2) < 0) goto error; - if(H5Tclose(arr_type4) < 0) goto error; - if(H5Tclose(arr_type5) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; - - HDfree(cf); - HDfree(cfrR); - HDputs(" PASSED"); - return SUCCEED; + for (j = 0; j < DIM1; j++) + for (k = 0; k < DIM2; k++) + for (l = 0; l < DIM3; l++) + cf->a[j][k][l] = 10 * (j + 1) + l + k; + + for (j = 0; j < DIM2; j++) + cf->b[j] = 100.0f * (float)(j + 1) + 0.01f * (float)j; + + for (j = 0; j < DIM3; j++) + cf->c[j] = 100.0f * (float)(j + 1) + 0.02f * (float)j; + + /* Create data space */ + if ((space = H5Screate(H5S_SCALAR)) < 0) + goto error; + + /* Add members to the compound data type */ + dimsa[0] = DIM1; + dimsa[1] = DIM2; + dimsa[2] = DIM3; + dimsb[0] = DIM2; + dimsc[0] = DIM3; + + /* Create the memory data type */ + if ((ctype1 = H5Tcreate(H5T_COMPOUND, sizeof(CmpField))) < 0) + goto error; + + if ((arr_type1 = H5Tarray_create2(H5T_NATIVE_INT, 3, dimsa)) < 0) + goto error; + if ((arr_type2 = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, dimsb)) < 0) + goto error; + if ((arr_type3 = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, dimsc)) < 0) + goto error; + + if (H5Tinsert(ctype1, "A", HOFFSET(CmpField, a), arr_type1) < 0) + goto error; + if (H5Tinsert(ctype1, "B", HOFFSET(CmpField, b), arr_type2) < 0) + goto error; + if (H5Tinsert(ctype1, "C", HOFFSET(CmpField, c), arr_type3) < 0) + goto error; + + /* Create the dataset */ + if ((dataset = + H5Dcreate2(fid, DSET_CONV_BUF_NAME, ctype1, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Dwrite(dataset, ctype1, H5S_ALL, H5S_ALL, H5P_DEFAULT, cf) < 0) + goto error; + + if ((ctype2 = H5Tcreate(H5T_COMPOUND, sizeof(CmpFieldR))) < 0) + goto error; + + if ((arr_type4 = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, dimsb)) < 0) + goto error; + if ((arr_type5 = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, dimsc)) < 0) + goto error; + + if (H5Tinsert(ctype2, "B", HOFFSET(CmpFieldR, b), arr_type4) < 0) + goto error; + if (H5Tinsert(ctype2, "C", HOFFSET(CmpFieldR, c), arr_type5) < 0) + goto error; + + /* Read should succeed since library will set conversion buffer big enough */ + if ((cfrR = (CmpFieldR *)HDcalloc((size_t)1, sizeof(CmpFieldR))) == 0) + goto error; + if (H5Dread(dataset, ctype2, H5S_ALL, H5S_ALL, H5P_DEFAULT, cfrR) < 0) + goto error; + + /* Read should fail since conversion buffer isn't big enough */ + xfer_list = H5Pcreate(H5P_DATASET_XFER); + size = (DIM2 * DIM3 * (sizeof(int)) + DIM2 * (sizeof(float)) + DIM3 * (sizeof(double))); + if (H5Pset_buffer(xfer_list, size, NULL, NULL) < 0) + goto error; + + H5E_BEGIN_TRY + { + status = H5Dread(dataset, ctype2, H5S_ALL, H5S_ALL, xfer_list, cfrR); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Library shouldn't allow conversion buffer too small"); + goto error; + } + + /* Read will succeed since conversion buffer is big enough */ + size = (DIM1 * DIM2 * DIM3 * (sizeof(int)) + DIM2 * (sizeof(float)) + DIM3 * (sizeof(double))); + if (H5Pset_buffer(xfer_list, size, NULL, NULL) < 0) + goto error; + + if (H5Dread(dataset, ctype2, H5S_ALL, H5S_ALL, xfer_list, cfrR) < 0) + goto error; + + if (H5Pclose(xfer_list) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Tclose(arr_type1) < 0) + goto error; + if (H5Tclose(arr_type2) < 0) + goto error; + if (H5Tclose(arr_type3) < 0) + goto error; + if (H5Tclose(ctype1) < 0) + goto error; + if (H5Tclose(ctype2) < 0) + goto error; + if (H5Tclose(arr_type4) < 0) + goto error; + if (H5Tclose(arr_type5) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; + + HDfree(cf); + HDfree(cfrR); + HDputs(" PASSED"); + return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(xfer_list); H5Sclose(space); H5Tclose(arr_type1); @@ -1394,12 +1510,12 @@ error: H5Tclose(arr_type4); H5Tclose(arr_type5); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; - return FAIL; + return FAIL; } /* end test_conv_buffer() */ - /*------------------------------------------------------------------------- * Function: test_tconv * @@ -1412,10 +1528,10 @@ error: static herr_t test_tconv(hid_t file) { - char *out = NULL, *in = NULL; - hsize_t dims[1]; - hid_t space = -1, dataset = -1; - int i; + char * out = NULL, *in = NULL; + hsize_t dims[1]; + hid_t space = -1, dataset = -1; + int i; if ((out = (char *)HDmalloc((size_t)(4 * 1000 * 1000))) == NULL) goto error; @@ -1425,7 +1541,7 @@ test_tconv(hid_t file) TESTING("data type conversion"); /* Initialize the dataset */ - for(i = 0; i < 1000000; i++) { + for (i = 0; i < 1000000; i++) { out[i * 4 + 0] = 0x11; out[i * 4 + 1] = 0x22; out[i * 4 + 2] = 0x33; @@ -1434,35 +1550,36 @@ test_tconv(hid_t file) /* Create the data space */ dims[0] = 1000000; - if((space = H5Screate_simple (1, dims, NULL)) < 0) goto error; + if ((space = H5Screate_simple(1, dims, NULL)) < 0) + goto error; /* Create the data set */ - if((dataset = H5Dcreate2(file, DSET_TCONV_NAME, H5T_STD_I32LE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_TCONV_NAME, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, out) < 0) + if (H5Dwrite(dataset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, out) < 0) goto error; /* Read data with byte order conversion */ - if(H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, H5P_DEFAULT, in) < 0) + if (H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, H5P_DEFAULT, in) < 0) goto error; /* Check */ - for(i = 0; i < 1000000; i++) { - if(in[4 * i + 0] != out[4 * i + 3] || - in[4 * i + 1] != out[4 * i + 2] || - in[4 * i + 2] != out[4 * i + 1] || - in[4 * i + 3] != out[4 * i + 0]) { + for (i = 0; i < 1000000; i++) { + if (in[4 * i + 0] != out[4 * i + 3] || in[4 * i + 1] != out[4 * i + 2] || + in[4 * i + 2] != out[4 * i + 1] || in[4 * i + 3] != out[4 * i + 0]) { H5_FAILED(); HDputs(" Read with byte order conversion failed."); goto error; } } - if(H5Dclose(dataset) < 0) goto error; - if(H5Sclose(space) < 0) goto error; + if (H5Dclose(dataset) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; HDfree(out); HDfree(in); @@ -1470,31 +1587,32 @@ test_tconv(hid_t file) return SUCCEED; error: - if(out) + if (out) HDfree(out); - if(in) + if (in) HDfree(in); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(space); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_tconv() */ /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_bogus, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_bogus, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: can_apply_bogus * @@ -1508,15 +1626,14 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ static htri_t can_apply_bogus(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - if(H5Tequal(type_id,H5T_NATIVE_DOUBLE)) + if (H5Tequal(type_id, H5T_NATIVE_DOUBLE)) return 0; - else if(H5Tequal(type_id,H5T_NATIVE_INT)) + else if (H5Tequal(type_id, H5T_NATIVE_INT)) return 1; else return -1; } /* end can_apply_bogus() */ - /*------------------------------------------------------------------------- * Function: filter_bogus * @@ -1528,13 +1645,12 @@ can_apply_bogus(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSE */ static size_t filter_bogus(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { return nbytes; } /* end filter_bogus() */ - /*------------------------------------------------------------------------- * Function: set_local_bogus2 * @@ -1549,38 +1665,37 @@ filter_bogus(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, static herr_t set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - unsigned add_on=0; /* Value to add to data going through */ - unsigned flags; /* Filter flags */ - size_t cd_nelmts=BOGUS2_PERM_NPARMS; /* Number of filter parameters */ - unsigned cd_values[4]; /* Filter parameters */ + unsigned add_on = 0; /* Value to add to data going through */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = BOGUS2_PERM_NPARMS; /* Number of filter parameters */ + unsigned cd_values[4]; /* Filter parameters */ /* Check for native integer datatype and set private property */ - if(H5Tequal(type_id,H5T_NATIVE_INT)>0) - add_on=(unsigned)H5Tget_size(type_id); + if (H5Tequal(type_id, H5T_NATIVE_INT) > 0) + add_on = (unsigned)H5Tget_size(type_id); /* Get the filter's current parameters */ - if(H5Pget_filter_by_id2(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) - return(FAIL); + if (H5Pget_filter_by_id2(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, &flags, &cd_nelmts, cd_values, (size_t)0, + NULL, NULL) < 0) + return (FAIL); /* Check that the parameter values were passed along correctly */ - if(cd_values[0]!=BOGUS2_PARAM_1) - return(FAIL); - if(cd_values[1]!=BOGUS2_PARAM_2) - return(FAIL); + if (cd_values[0] != BOGUS2_PARAM_1) + return (FAIL); + if (cd_values[1] != BOGUS2_PARAM_2) + return (FAIL); /* Set "local" parameters for this dataset */ - cd_values[2]=(unsigned)(add_on>0); /* Flag to indicate data is modified */ - cd_values[3]=add_on; /* Amount the data was modified by */ + cd_values[2] = (unsigned)(add_on > 0); /* Flag to indicate data is modified */ + cd_values[3] = add_on; /* Amount the data was modified by */ /* Modify the filter's parameters for this dataset */ - if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, flags, (size_t)BOGUS2_ALL_NPARMS, - cd_values) < 0) - return(FAIL); + if (H5Pmodify_filter(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, flags, (size_t)BOGUS2_ALL_NPARMS, cd_values) < 0) + return (FAIL); - return(SUCCEED); + return (SUCCEED); } /* end set_local_bogus2() */ - /*------------------------------------------------------------------------- * Function: filter_bogus2 * @@ -1594,47 +1709,45 @@ set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) *------------------------------------------------------------------------- */ static size_t -filter_bogus2(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +filter_bogus2(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { /* Check for the correct number of parameters */ - if(cd_nelmts!=BOGUS2_ALL_NPARMS) - return(0); + if (cd_nelmts != BOGUS2_ALL_NPARMS) + return (0); /* Check that permanent parameters are set correctly */ - if(cd_values[0]!=BOGUS2_PARAM_1) - return(0); - if(cd_values[1]!=BOGUS2_PARAM_2) - return(0); + if (cd_values[0] != BOGUS2_PARAM_1) + return (0); + if (cd_values[1] != BOGUS2_PARAM_2) + return (0); /* Check if this filter is supposed to do something */ - if(cd_values[2]>0) { + if (cd_values[2] > 0) { /* Check whether we are "uncompressing" */ - if(flags & H5Z_FLAG_REVERSE) { + if (flags & H5Z_FLAG_REVERSE) { /* Do nothing */ } /* end if */ /* "Compressing" */ else { - unsigned add_on=cd_values[3]; /* Get "add on" value */ - int *int_ptr=(int *)*buf; /* Pointer to the data values */ - size_t buf_left=*buf_size; /* Amount of data buffer left to process */ + unsigned add_on = cd_values[3]; /* Get "add on" value */ + int * int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ /* Add the "add on" value to all the data values */ - while(buf_left>0) { + while (buf_left > 0) { *int_ptr++ += (int)add_on; buf_left -= sizeof(int); } /* end while */ - } /* end else */ + } /* end else */ - return(nbytes); + return (nbytes); } /* end if */ /* Filter is "no op" */ else - return(nbytes); + return (nbytes); } /* end filter_bogus2() */ - /*------------------------------------------------------------------------- * Function: filter_bogus3 * @@ -1646,24 +1759,23 @@ filter_bogus2(unsigned int flags, size_t cd_nelmts, */ static size_t filter_bogus3(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t H5_ATTR_UNUSED nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) + const unsigned int H5_ATTR_UNUSED *cd_values, size_t H5_ATTR_UNUSED nbytes, + size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) { return 0; } /* end filter_bogus3() */ /* This message derives from H5Z */ const H5Z_class2_t H5Z_CORRUPT[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_CORRUPT, /* Filter id number */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_CORRUPT, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "corrupt", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_corrupt, /* The actual filter function */ + "corrupt", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_corrupt, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: filter_corrupt * @@ -1672,42 +1784,41 @@ const H5Z_class2_t H5Z_CORRUPT[1] = {{ * fail. * * Return: Success: Data chunk size - * Failure: 0 + * Failure: 0 *------------------------------------------------------------------------- */ static size_t -filter_corrupt(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +filter_corrupt(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - void *data = NULL; - unsigned char *dst = (unsigned char*)(*buf); + void * data = NULL; + unsigned char *dst = (unsigned char *)(*buf); unsigned int offset; unsigned int length; unsigned int value; size_t ret_value = 0; - if(cd_nelmts != 3 || !cd_values) + if (cd_nelmts != 3 || !cd_values) TEST_ERROR offset = cd_values[0]; length = cd_values[1]; value = cd_values[2]; - if(offset > nbytes || (offset + length) > nbytes || length < sizeof(unsigned int)) + if (offset > nbytes || (offset + length) > nbytes || length < sizeof(unsigned int)) TEST_ERROR - if(NULL == (data = HDmalloc((size_t)length))) + if (NULL == (data = HDmalloc((size_t)length))) TEST_ERROR HDmemset(data, (int)value, (size_t)length); - if(flags & H5Z_FLAG_REVERSE) { /* Varify data is actually corrupted during read */ + if (flags & H5Z_FLAG_REVERSE) { /* Varify data is actually corrupted during read */ dst += offset; - if(HDmemcmp(data, dst, (size_t)length) != 0) + if (HDmemcmp(data, dst, (size_t)length) != 0) TEST_ERROR else { *buf_size = nbytes; ret_value = nbytes; - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Write corrupted data */ dst += offset; HDmemcpy(dst, data, (size_t)length); @@ -1716,13 +1827,12 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts, } /* end else */ error: - if(data) + if (data) HDfree(data); return ret_value; } /* end filter_corrupt() */ - /*------------------------------------------------------------------------- * Function: filter_cb_cont * @@ -1733,15 +1843,14 @@ error: */ static H5Z_cb_return_t filter_cb_cont(H5Z_filter_t filter, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNUSED buf_size, - void H5_ATTR_UNUSED *op_data) + void H5_ATTR_UNUSED *op_data) { - if(H5Z_FILTER_FLETCHER32==filter) - return H5Z_CB_CONT; + if (H5Z_FILTER_FLETCHER32 == filter) + return H5Z_CB_CONT; else return H5Z_CB_FAIL; } /* end filter_cb_cont() */ - /*------------------------------------------------------------------------- * Function: filter_cb_fail * @@ -1752,15 +1861,14 @@ filter_cb_cont(H5Z_filter_t filter, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNU */ static H5Z_cb_return_t filter_cb_fail(H5Z_filter_t filter, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNUSED buf_size, - void H5_ATTR_UNUSED *op_data) + void H5_ATTR_UNUSED *op_data) { - if(H5Z_FILTER_FLETCHER32==filter) - return H5Z_CB_FAIL; + if (H5Z_FILTER_FLETCHER32 == filter) + return H5Z_CB_FAIL; else - return H5Z_CB_CONT; + return H5Z_CB_CONT; } /* end filter_cb_fail() */ - /*------------------------------------------------------------------------- * Function: test_filter_internal * @@ -1774,51 +1882,55 @@ filter_cb_fail(H5Z_filter_t filter, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNU *------------------------------------------------------------------------- */ static herr_t -test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, - int corrupted, hsize_t *dset_size) +test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, int corrupted, + hsize_t *dset_size) { - hid_t dataset; /* Dataset ID */ - hid_t dxpl; /* Dataset xfer property list ID */ - hid_t write_dxpl; /* Dataset xfer property list ID for writing */ - hid_t sid; /* Dataspace ID */ - const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ - const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */ - const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */ - void *tconv_buf = NULL; /* Temporary conversion buffer */ - size_t i, j, n; /* Local index variables */ - herr_t status; /* Error status */ + hid_t dataset; /* Dataset ID */ + hid_t dxpl; /* Dataset xfer property list ID */ + hid_t write_dxpl; /* Dataset xfer property list ID for writing */ + hid_t sid; /* Dataspace ID */ + const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ + const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */ + const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */ + void * tconv_buf = NULL; /* Temporary conversion buffer */ + size_t i, j, n; /* Local index variables */ + herr_t status; /* Error status */ /* Create the data space */ - if((sid = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((sid = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* * Create a small conversion buffer to test strip mining. We * might as well test all we can! */ - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; tconv_buf = HDmalloc((size_t)1000); - if(H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) goto error; - if((write_dxpl = H5Pcopy(dxpl)) < 0) TEST_ERROR; + if (H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) + goto error; + if ((write_dxpl = H5Pcopy(dxpl)) < 0) + TEST_ERROR; - if(if_fletcher32==DISABLE_FLETCHER32) { - if(H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC) < 0) + if (if_fletcher32 == DISABLE_FLETCHER32) { + if (H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC) < 0) goto error; - if(H5Z_DISABLE_EDC != H5Pget_edc_check(dxpl)) + if (H5Z_DISABLE_EDC != H5Pget_edc_check(dxpl)) goto error; } TESTING(" filters (setup)"); /* Check if all the filters are available */ - if(H5Pall_filters_avail(dcpl)!=TRUE) { + if (H5Pall_filters_avail(dcpl) != TRUE) { H5_FAILED(); - HDprintf(" Line %d: Incorrect filter availability\n",__LINE__); + HDprintf(" Line %d: Incorrect filter availability\n", __LINE__); goto error; } /* end if */ /* Create the dataset */ - if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, - dcpl, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; PASSED(); @@ -1828,20 +1940,19 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, */ TESTING(" filters (uninitialized read)"); - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) - TEST_ERROR; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) + TEST_ERROR; - for(i=0; i<(size_t)size[0]; i++) { - for(j=0; j<(size_t)size[1]; j++) { - if(0!=check[i][j]) { - H5_FAILED(); - HDprintf(" Read a non-zero value.\n"); - HDprintf(" At index %lu,%lu\n", - (unsigned long)i, (unsigned long)j); - goto error; + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { + if (0 != check[i][j]) { + H5_FAILED(); + HDprintf(" Read a non-zero value.\n"); + HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); + goto error; + } } } - } PASSED(); /*---------------------------------------------------------------------- @@ -1851,16 +1962,17 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, */ TESTING(" filters (write)"); - for(i=n=0; i=0) TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) + if (H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) + TEST_ERROR; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ - if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; + if (H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) + TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ - H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); - } H5E_END_TRY; - if(status>=0) TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR; } else { - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i=0; i=0) TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) + if (H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) + TEST_ERROR; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ - if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; + if (H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) + TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ - H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); - } H5E_END_TRY; - if(status>=0) TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR; } else { /* Read the dataset back and check it */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i=0; i= 0) TEST_ERROR; + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) + if (H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) + TEST_ERROR; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ - if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; + if (H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) + TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); - } H5E_END_TRY; - if(status >= 0) TEST_ERROR; + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR; } /* end if */ else { - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i = 0; i < size[0]; i++) - for(j = 0; j < size[1]; j++) - if(points[i][j] != check[i][j]) { + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + if (points[i][j] != check[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); - HDprintf(" At index %lu,%lu\n", - (unsigned long)i, (unsigned long)j); + HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } /* end if */ - } /* end else */ + } /* end else */ PASSED(); - /*---------------------------------------------------------------------- * STEP 6: Test partial I/O by writing to and then reading from a * hyperslab of the dataset. The hyperslab does not line up on chunk @@ -2033,56 +2169,64 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, */ TESTING(" filters (partial I/O)"); - for(i=0; i<(size_t)hs_size[0]; i++) { - for(j=0; j<(size_t)hs_size[1]; j++) { - points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] = (int)HDrandom(); + for (i = 0; i < (size_t)hs_size[0]; i++) { + for (j = 0; j < (size_t)hs_size[1]; j++) { + points[(size_t)hs_offset[0] + i][(size_t)hs_offset[1] + j] = (int)HDrandom(); } } - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, - NULL) < 0) TEST_ERROR; - /* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */ - if(H5Dwrite (dataset, H5T_NATIVE_INT, sid, sid, dxpl, points_data) < 0) - TEST_ERROR; + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + TEST_ERROR; + /* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) + */ + if (H5Dwrite(dataset, H5T_NATIVE_INT, sid, sid, dxpl, points_data) < 0) + TEST_ERROR; - if(corrupted) { + if (corrupted) { /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ - H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); - } H5E_END_TRY; - if(status>=0) TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) + if (H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) + TEST_ERROR; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ - if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; + if (H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) + TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ - H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); - } H5E_END_TRY; - if(status>=0) TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR; } else { - if(H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check_data) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, sid, sid, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)hs_size[0]; i++) { - for(j=0; j<(size_t)hs_size[1]; j++) { - if(points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] != - check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]) { + for (i = 0; i < (size_t)hs_size[0]; i++) { + for (j = 0; j < (size_t)hs_size[1]; j++) { + if (points[(size_t)hs_offset[0] + i][(size_t)hs_offset[1] + j] != + check[(size_t)hs_offset[0] + i][(size_t)hs_offset[1] + j]) { H5_FAILED(); - HDfprintf(stderr," Read different values than written.\n"); - HDfprintf(stderr," At index %lu,%lu\n", - (unsigned long)((size_t)hs_offset[0]+i), - (unsigned long)((size_t)hs_offset[1]+j)); - HDfprintf(stderr," At original: %d\n", - (int)points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]); - HDfprintf(stderr," At returned: %d\n", - (int)check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]); + HDfprintf(stderr, " Read different values than written.\n"); + HDfprintf(stderr, " At index %lu,%lu\n", (unsigned long)((size_t)hs_offset[0] + i), + (unsigned long)((size_t)hs_offset[1] + j)); + HDfprintf(stderr, " At original: %d\n", + (int)points[(size_t)hs_offset[0] + i][(size_t)hs_offset[1] + j]); + HDfprintf(stderr, " At returned: %d\n", + (int)check[(size_t)hs_offset[0] + i][(size_t)hs_offset[1] + j]); goto error; } } @@ -2090,22 +2234,27 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } /* Get the storage size of the dataset */ - if((*dset_size=H5Dget_storage_size(dataset))==0) goto error; + if ((*dset_size = H5Dget_storage_size(dataset)) == 0) + goto error; PASSED(); /* Clean up objects used for this test */ - if(H5Dclose (dataset) < 0) goto error; - if(H5Sclose (sid) < 0) goto error; - if(H5Pclose (dxpl) < 0) goto error; - if(H5Pclose (write_dxpl) < 0) goto error; - HDfree (tconv_buf); + if (H5Dclose(dataset) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Pclose(dxpl) < 0) + goto error; + if (H5Pclose(write_dxpl) < 0) + goto error; + HDfree(tconv_buf); return SUCCEED; error: - if(tconv_buf) - HDfree (tconv_buf); + if (tconv_buf) + HDfree(tconv_buf); return FAIL; } /* end test_filter_internal() */ @@ -2124,16 +2273,16 @@ error: static herr_t test_filter_noencoder(const char *dset_name) { - hid_t file_id = -1; - hid_t dset_id = -1; - hid_t test_dset_id = -1; - hid_t dcpl_id = -1; - hid_t space_id = -1; - hsize_t dims = 10; - herr_t err; - int test_ints[10] = { 12 }; - int read_buf[10]; - int i; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t test_dset_id = -1; + hid_t dcpl_id = -1; + hid_t space_id = -1; + hsize_t dims = 10; + herr_t err; + int test_ints[10] = {12}; + int read_buf[10]; + int i; /* Make a local copy of the file since this test writes to the data file from svn. */ @@ -2142,22 +2291,26 @@ test_filter_noencoder(const char *dset_name) /* Open file */ file_id = H5Fopen(NOENCODER_COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - if(file_id < 0) goto error; + if (file_id < 0) + goto error; dset_id = H5Dopen2(file_id, dset_name, H5P_DEFAULT); - if(dset_id < 0) goto error; + if (dset_id < 0) + goto error; space_id = H5Screate_simple(1, &dims, NULL); - if(space_id < 0) goto error; + if (space_id < 0) + goto error; TESTING(" decoding without encoder"); /* Read the dataset and make sure the decoder is working correctly */ err = H5Dread(dset_id, H5T_NATIVE_INT, space_id, space_id, H5P_DEFAULT, read_buf); - if(err < 0) goto error; + if (err < 0) + goto error; - for(i = 0; i < 10; i++) - if(read_buf[i] != i) + for (i = 0; i < 10; i++) + if (read_buf[i] != i) goto error; H5Sclose(space_id); @@ -2171,36 +2324,48 @@ test_filter_noencoder(const char *dset_name) TESTING(" trying to write without encoder"); dcpl_id = H5Dget_create_plist(dset_id); - if(dcpl_id < 0) goto error; + if (dcpl_id < 0) + goto error; space_id = H5Screate_simple(1, &dims, NULL); - if(space_id < 0) goto error; + if (space_id < 0) + goto error; - H5E_BEGIN_TRY{ - test_dset_id = H5Dcreate2(file_id, NOENCODER_TEST_DATASET, H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); - }H5E_END_TRY + H5E_BEGIN_TRY + { + test_dset_id = H5Dcreate2(file_id, NOENCODER_TEST_DATASET, H5T_NATIVE_INT, space_id, H5P_DEFAULT, + dcpl_id, H5P_DEFAULT); + } + H5E_END_TRY - if(test_dset_id >= 0) goto error; + if (test_dset_id >= 0) + goto error; /* Attempt to extend the dataset. This should fail because * the dataset has a fill value and is instructed to fill on * allocation. */ dims = 20; /* Dataset is originally of size 10 */ - H5E_BEGIN_TRY{ + H5E_BEGIN_TRY + { err = H5Dset_extent(dset_id, &dims); - }H5E_END_TRY + } + H5E_END_TRY - if(err >= 0) goto error; + if (err >= 0) + goto error; /* Attempt to write to the dataset. This should fail because * the filter does not have an encoder. */ - H5E_BEGIN_TRY{ + H5E_BEGIN_TRY + { err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, test_ints); - }H5E_END_TRY + } + H5E_END_TRY - if(err >= 0) goto error; + if (err >= 0) + goto error; H5Fclose(file_id); H5Dclose(dset_id); @@ -2213,15 +2378,15 @@ test_filter_noencoder(const char *dset_name) error: H5_FAILED(); - if(dset_id != -1) + if (dset_id != -1) H5Dclose(dset_id); - if(test_dset_id != -1) + if (test_dset_id != -1) H5Dclose(test_dset_id); - if(space_id != -1) + if (space_id != -1) H5Sclose(space_id); - if(dcpl_id != -1) + if (dcpl_id != -1) H5Pclose(dcpl_id); - if(file_id != -1) + if (file_id != -1) H5Fclose(file_id); return FAIL; @@ -2240,61 +2405,68 @@ error: static herr_t test_get_filter_info(void) { - unsigned int flags; /* flags returned from H5Zget_filter_info */ - herr_t err; + unsigned int flags; /* flags returned from H5Zget_filter_info */ + herr_t err; - TESTING("H5Zget_filter_info"); + TESTING("H5Zget_filter_info"); - /* Verify that each filter is reported as having the right combination - * of encoder and decoder. - */ - if(H5Zget_filter_info(H5Z_FILTER_FLETCHER32, &flags) < 0) TEST_ERROR + /* Verify that each filter is reported as having the right combination + * of encoder and decoder. + */ + if (H5Zget_filter_info(H5Z_FILTER_FLETCHER32, &flags) < 0) + TEST_ERROR - if(((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || - ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) - TEST_ERROR + if (((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || + ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) + TEST_ERROR - if(H5Zget_filter_info(H5Z_FILTER_SHUFFLE, &flags) < 0) TEST_ERROR + if (H5Zget_filter_info(H5Z_FILTER_SHUFFLE, &flags) < 0) + TEST_ERROR - if(((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || - ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) - TEST_ERROR + if (((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || + ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) + TEST_ERROR #ifdef H5_HAVE_FILTER_DEFLATE - if(H5Zget_filter_info(H5Z_FILTER_DEFLATE, &flags) < 0) TEST_ERROR + if (H5Zget_filter_info(H5Z_FILTER_DEFLATE, &flags) < 0) + TEST_ERROR - if(((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || - ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) - TEST_ERROR + if (((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || + ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) + TEST_ERROR #endif #ifdef H5_HAVE_FILTER_SZIP - if(H5Zget_filter_info(H5Z_FILTER_SZIP, &flags) < 0) TEST_ERROR + if (H5Zget_filter_info(H5Z_FILTER_SZIP, &flags) < 0) + TEST_ERROR - if(H5Z_SZIP->encoder_present) { - if(((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || - ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) + if (H5Z_SZIP->encoder_present) { + if (((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || + ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) TEST_ERROR } /* end if */ else { - if(((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) != 0) || - ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) + if (((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) != 0) || + ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) TEST_ERROR - } /* end else */ + } /* end else */ #endif /* H5_HAVE_FILTER_SZIP */ - /* Verify that get_filter_info throws an error when given a bad filter */ - /* (Depends on 1.6 compatibility flag) */ - H5E_BEGIN_TRY { - err = H5Zget_filter_info(-1, &flags); - } H5E_END_TRY; - if(err >= 0) TEST_ERROR + /* Verify that get_filter_info throws an error when given a bad filter */ + /* (Depends on 1.6 compatibility flag) */ + H5E_BEGIN_TRY + { + err = H5Zget_filter_info(-1, &flags); + } + H5E_END_TRY; + if (err >= 0) + TEST_ERROR - PASSED(); - return SUCCEED; + PASSED(); + return SUCCEED; error: - return FAIL; + return FAIL; } /* end test_get_filter_info() */ /*------------------------------------------------------------------------- @@ -2309,63 +2481,76 @@ error: static herr_t test_filters(hid_t file, hid_t #ifndef H5_HAVE_FILTER_SZIP -H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_FILTER_SZIP */ - fapl) + fapl) { - hid_t dc; /* Dataset creation property list ID */ - const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ - hsize_t null_size; /* Size of dataset with null filter */ + hid_t dc; /* Dataset creation property list ID */ + const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ + hsize_t null_size; /* Size of dataset with null filter */ - hsize_t fletcher32_size; /* Size of dataset with Fletcher32 checksum */ - unsigned data_corrupt[3]; /* position and length of data to be corrupted */ + hsize_t fletcher32_size; /* Size of dataset with Fletcher32 checksum */ + unsigned data_corrupt[3]; /* position and length of data to be corrupted */ #ifdef H5_HAVE_FILTER_DEFLATE - hsize_t deflate_size; /* Size of dataset with deflate filter */ -#endif /* H5_HAVE_FILTER_DEFLATE */ + hsize_t deflate_size; /* Size of dataset with deflate filter */ +#endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SZIP - hsize_t szip_size; /* Size of dataset with szip filter */ - unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block = 4; + hsize_t szip_size; /* Size of dataset with szip filter */ + unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block = 4; #endif /* H5_HAVE_FILTER_SZIP */ - hsize_t shuffle_size; /* Size of dataset with shuffle filter */ + hsize_t shuffle_size; /* Size of dataset with shuffle filter */ #if defined(H5_HAVE_FILTER_DEFLATE) || defined(H5_HAVE_FILTER_SZIP) - hsize_t combo_size; /* Size of dataset with multiple filters */ -#endif /* defined(H5_HAVE_FILTER_DEFLATE) || defined(H5_HAVE_FILTER_SZIP) */ + hsize_t combo_size; /* Size of dataset with multiple filters */ +#endif /* defined(H5_HAVE_FILTER_DEFLATE) || defined(H5_HAVE_FILTER_SZIP) */ /* test the H5Zget_filter_info function */ - if(test_get_filter_info() < 0) goto error; + if (test_get_filter_info() < 0) + goto error; /*---------------------------------------------------------- * STEP 0: Test null I/O filter by itself. *---------------------------------------------------------- */ HDputs("Testing 'null' filter"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Zregister (H5Z_BOGUS) < 0) goto error; - if(H5Pset_filter(dc, H5Z_FILTER_BOGUS, 0, (size_t)0, NULL) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Zregister(H5Z_BOGUS) < 0) + goto error; + if (H5Pset_filter(dc, H5Z_FILTER_BOGUS, 0, (size_t)0, NULL) < 0) + goto error; - if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size) < 0) goto error; + if (test_filter_internal(file, DSET_BOGUS_NAME, dc, DISABLE_FLETCHER32, DATA_NOT_CORRUPTED, &null_size) < + 0) + goto error; /* Clean up objects used for this test */ - if(H5Pclose (dc) < 0) goto error; + if (H5Pclose(dc) < 0) + goto error; /*---------------------------------------------------------- * STEP 1: Test Fletcher32 Checksum by itself. *---------------------------------------------------------- */ HDputs("Testing Fletcher32 checksum(enabled for read)"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Pset_filter(dc, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_filter(dc, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL) < 0) + goto error; /* Enable checksum during read */ - if(test_filter_internal(file,DSET_FLETCHER32_NAME,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&fletcher32_size) < 0) goto error; - if(fletcher32_size<=null_size) { + if (test_filter_internal(file, DSET_FLETCHER32_NAME, dc, ENABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &fletcher32_size) < 0) + goto error; + if (fletcher32_size <= null_size) { H5_FAILED(); HDputs(" Size after checksumming is incorrect."); goto error; @@ -2373,8 +2558,10 @@ H5_ATTR_UNUSED /* Disable checksum during read */ HDputs("Testing Fletcher32 checksum(disabled for read)"); - if(test_filter_internal(file,DSET_FLETCHER32_NAME_2,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&fletcher32_size) < 0) goto error; - if(fletcher32_size<=null_size) { + if (test_filter_internal(file, DSET_FLETCHER32_NAME_2, dc, DISABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &fletcher32_size) < 0) + goto error; + if (fletcher32_size <= null_size) { H5_FAILED(); HDputs(" Size after checksumming is incorrect."); goto error; @@ -2386,52 +2573,68 @@ H5_ATTR_UNUSED data_corrupt[1] = 33; data_corrupt[2] = 27; - if(H5Zregister (H5Z_CORRUPT) < 0) goto error; - if(H5Pset_filter(dc, H5Z_FILTER_CORRUPT, 0, (size_t)3, data_corrupt) < 0) goto error; - if(test_filter_internal(file,DSET_FLETCHER32_NAME_3,dc,DISABLE_FLETCHER32,DATA_CORRUPTED,&fletcher32_size) < 0) goto error; - if(fletcher32_size<=null_size) { + if (H5Zregister(H5Z_CORRUPT) < 0) + goto error; + if (H5Pset_filter(dc, H5Z_FILTER_CORRUPT, 0, (size_t)3, data_corrupt) < 0) + goto error; + if (test_filter_internal(file, DSET_FLETCHER32_NAME_3, dc, DISABLE_FLETCHER32, DATA_CORRUPTED, + &fletcher32_size) < 0) + goto error; + if (fletcher32_size <= null_size) { H5_FAILED(); HDputs(" Size after checksumming is incorrect."); goto error; } /* end if */ /* Clean up objects used for this test */ - if(H5Pclose (dc) < 0) goto error; - + if (H5Pclose(dc) < 0) + goto error; - /*---------------------------------------------------------- - * STEP 2: Test deflation by itself. - *---------------------------------------------------------- - */ + /*---------------------------------------------------------- + * STEP 2: Test deflation by itself. + *---------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_DEFLATE HDputs("Testing deflate filter"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Pset_deflate (dc, 6) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_deflate(dc, 6) < 0) + goto error; - if(test_filter_internal(file,DSET_DEFLATE_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&deflate_size) < 0) goto error; + if (test_filter_internal(file, DSET_DEFLATE_NAME, dc, DISABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &deflate_size) < 0) + goto error; /* Clean up objects used for this test */ - if(H5Pclose (dc) < 0) goto error; -#else /* H5_HAVE_FILTER_DEFLATE */ + if (H5Pclose(dc) < 0) + goto error; +#else /* H5_HAVE_FILTER_DEFLATE */ TESTING("deflate filter"); SKIPPED(); HDputs(" Deflate filter not enabled"); #endif /* H5_HAVE_FILTER_DEFLATE */ - /*---------------------------------------------------------- - * STEP 3: Test szip compression by itself. - *---------------------------------------------------------- - */ + /*---------------------------------------------------------- + * STEP 3: Test szip compression by itself. + *---------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_SZIP TESTING("szip filter (with encoder)"); - if( h5_szip_can_encode() == 1) { - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; + if (h5_szip_can_encode() == 1) { + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; - HDputs(""); - if(H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block) < 0) goto error; - if(test_filter_internal(file,DSET_SZIP_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&szip_size) < 0) goto error; - if(H5Pclose (dc) < 0) goto error; + HDputs(""); + if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block) < 0) + goto error; + if (test_filter_internal(file, DSET_SZIP_NAME, dc, DISABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &szip_size) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; } else { SKIPPED(); @@ -2439,15 +2642,16 @@ H5_ATTR_UNUSED TESTING("szip filter (without encoder)"); - if( h5_szip_can_encode() != 1) { + if (h5_szip_can_encode() != 1) { HDputs(""); - if(test_filter_noencoder(NOENCODER_SZIP_DATASET) < 0) goto error; + if (test_filter_noencoder(NOENCODER_SZIP_DATASET) < 0) + goto error; } else { SKIPPED(); } -#else /* H5_HAVE_FILTER_SZIP */ +#else /* H5_HAVE_FILTER_SZIP */ TESTING("szip filter"); SKIPPED(); HDputs(" Szip filter not enabled"); @@ -2458,71 +2662,100 @@ H5_ATTR_UNUSED *---------------------------------------------------------- */ HDputs("Testing shuffle filter"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Pset_shuffle (dc) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_shuffle(dc) < 0) + goto error; - if(test_filter_internal(file,DSET_SHUFFLE_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&shuffle_size) < 0) goto error; - if(shuffle_size!=null_size) { + if (test_filter_internal(file, DSET_SHUFFLE_NAME, dc, DISABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &shuffle_size) < 0) + goto error; + if (shuffle_size != null_size) { H5_FAILED(); HDputs(" Shuffled size not the same as uncompressed size."); goto error; } /* end if */ /* Clean up objects used for this test */ - if(H5Pclose (dc) < 0) goto error; + if (H5Pclose(dc) < 0) + goto error; - /*---------------------------------------------------------- - * STEP 5: Test shuffle + deflate + checksum in any order. - *---------------------------------------------------------- - */ + /*---------------------------------------------------------- + * STEP 5: Test shuffle + deflate + checksum in any order. + *---------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_DEFLATE HDputs("Testing shuffle+deflate+checksum filters(checksum first)"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Pset_fletcher32 (dc) < 0) goto error; - if(H5Pset_shuffle (dc) < 0) goto error; - if(H5Pset_deflate (dc, 6) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_fletcher32(dc) < 0) + goto error; + if (H5Pset_shuffle(dc) < 0) + goto error; + if (H5Pset_deflate(dc, 6) < 0) + goto error; - if(test_filter_internal(file,DSET_SHUF_DEF_FLET_NAME,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size) < 0) goto error; + if (test_filter_internal(file, DSET_SHUF_DEF_FLET_NAME, dc, ENABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &combo_size) < 0) + goto error; /* Clean up objects used for this test */ - if(H5Pclose (dc) < 0) goto error; + if (H5Pclose(dc) < 0) + goto error; HDputs("Testing shuffle+deflate+checksum filters(checksum last)"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Pset_shuffle (dc) < 0) goto error; - if(H5Pset_deflate (dc, 6) < 0) goto error; - if(H5Pset_fletcher32 (dc) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_shuffle(dc) < 0) + goto error; + if (H5Pset_deflate(dc, 6) < 0) + goto error; + if (H5Pset_fletcher32(dc) < 0) + goto error; - if(test_filter_internal(file,DSET_SHUF_DEF_FLET_NAME_2,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size) < 0) goto error; + if (test_filter_internal(file, DSET_SHUF_DEF_FLET_NAME_2, dc, ENABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &combo_size) < 0) + goto error; /* Clean up objects used for this test */ - if(H5Pclose (dc) < 0) goto error; -#else /* H5_HAVE_FILTER_DEFLATE */ + if (H5Pclose(dc) < 0) + goto error; +#else /* H5_HAVE_FILTER_DEFLATE */ TESTING("shuffle+deflate+fletcher32 filters"); SKIPPED(); HDputs(" Deflate filter not enabled"); #endif /* H5_HAVE_FILTER_DEFLATE */ - /*---------------------------------------------------------- - * STEP 6: Test shuffle + szip + checksum in any order. - *---------------------------------------------------------- - */ + /*---------------------------------------------------------- + * STEP 6: Test shuffle + szip + checksum in any order. + *---------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_SZIP TESTING("shuffle+szip+checksum filters(checksum first, with encoder)"); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Pset_fletcher32 (dc) < 0) goto error; - if(H5Pset_shuffle (dc) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_fletcher32(dc) < 0) + goto error; + if (H5Pset_shuffle(dc) < 0) + goto error; /* Make sure encoding is enabled */ - if( h5_szip_can_encode() == 1) { + if (h5_szip_can_encode() == 1) { HDputs(""); - if(H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block) < 0) goto error; - if(test_filter_internal(file,DSET_SHUF_SZIP_FLET_NAME,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size) < 0) goto error; + if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block) < 0) + goto error; + if (test_filter_internal(file, DSET_SHUF_SZIP_FLET_NAME, dc, ENABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &combo_size) < 0) + goto error; } else { SKIPPED(); @@ -2530,38 +2763,48 @@ H5_ATTR_UNUSED TESTING("shuffle+szip+checksum filters(checksum first, without encoder)"); - if( h5_szip_can_encode() != 1) { + if (h5_szip_can_encode() != 1) { HDputs(""); - if(test_filter_noencoder(NOENCODER_SZIP_SHUFF_FLETCH_DATASET) < 0) goto error; + if (test_filter_noencoder(NOENCODER_SZIP_SHUFF_FLETCH_DATASET) < 0) + goto error; } else { SKIPPED(); } /* Clean up objects used for this test */ - if(H5Pclose (dc) < 0) goto error; + if (H5Pclose(dc) < 0) + goto error; TESTING("shuffle+szip+checksum filters(checksum last, with encoder)"); /* Make sure encoding is enabled */ - if( h5_szip_can_encode() == 1) { + if (h5_szip_can_encode() == 1) { HDputs(""); - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Pset_shuffle (dc) < 0) goto error; - if(H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block) < 0) goto error; - if(H5Pset_fletcher32 (dc) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_shuffle(dc) < 0) + goto error; + if (H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block) < 0) + goto error; + if (H5Pset_fletcher32(dc) < 0) + goto error; - if(test_filter_internal(file,DSET_SHUF_SZIP_FLET_NAME_2,dc,ENABLE_FLETCHER32,DATA_NOT_CORRUPTED,&combo_size) < 0) goto error; + if (test_filter_internal(file, DSET_SHUF_SZIP_FLET_NAME_2, dc, ENABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &combo_size) < 0) + goto error; /* Clean up objects used for this test */ - if(H5Pclose (dc) < 0) goto error; + if (H5Pclose(dc) < 0) + goto error; } else { SKIPPED(); } -#else /* H5_HAVE_FILTER_SZIP */ +#else /* H5_HAVE_FILTER_SZIP */ TESTING("shuffle+szip+fletcher32 filters"); SKIPPED(); HDputs(" szip filter not enabled"); @@ -2572,7 +2815,6 @@ error: return FAIL; } /* end test_filters() */ - /*------------------------------------------------------------------------- * Function: test_missing_filter * @@ -2584,242 +2826,247 @@ error: static herr_t test_missing_filter(hid_t file) { - hid_t fid; /* File ID */ - hid_t dsid; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataspace creation property list ID */ - const hsize_t dims[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ - const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ - hsize_t dset_size; /* Dataset size */ - size_t i,j; /* Local index variables */ - herr_t ret; /* Generic return value */ - const char *testfile = H5_get_srcdir_filename(FILE_DEFLATE_NAME); /* Corrected test file name */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t fid; /* File ID */ + hid_t dsid; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataspace creation property list ID */ + const hsize_t dims[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ + const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ + hsize_t dset_size; /* Dataset size */ + size_t i, j; /* Local index variables */ + herr_t ret; /* Generic return value */ + const char * testfile = H5_get_srcdir_filename(FILE_DEFLATE_NAME); /* Corrected test file name */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ TESTING("dataset access with missing filter"); /* Unregister the deflate filter */ #ifdef H5_HAVE_FILTER_DEFLATE - /* Verify deflate filter is registered currently */ - if(H5Zfilter_avail(H5Z_FILTER_DEFLATE)!=TRUE) { - H5_FAILED(); - HDprintf(" Line %d: Deflate filter not available\n",__LINE__); - goto error; - } /* end if */ + /* Verify deflate filter is registered currently */ + if (H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) { + H5_FAILED(); + HDprintf(" Line %d: Deflate filter not available\n", __LINE__); + goto error; + } /* end if */ - /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR - api_ctx_pushed = TRUE; + /* Push API context */ + if (H5CX_push() < 0) + FAIL_STACK_ERROR + api_ctx_pushed = TRUE; - /* Unregister deflate filter */ - /* (Use private routine, to avoid range checking on filter ID) */ - if(H5Z__unregister(H5Z_FILTER_DEFLATE) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't unregister deflate filter\n",__LINE__); - goto error; - } /* end if */ + /* Unregister deflate filter */ + /* (Use private routine, to avoid range checking on filter ID) */ + if (H5Z__unregister(H5Z_FILTER_DEFLATE) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't unregister deflate filter\n", __LINE__); + goto error; + } /* end if */ #endif /* H5_HAVE_FILTER_DEFLATE */ - /* Verify deflate filter is not registered currently */ - if(H5Zfilter_avail(H5Z_FILTER_DEFLATE)!=FALSE) { - H5_FAILED(); - HDprintf(" Line %d: Deflate filter available\n",__LINE__); - goto error; - } /* end if */ + /* Verify deflate filter is not registered currently */ + if (H5Zfilter_avail(H5Z_FILTER_DEFLATE) != FALSE) { + H5_FAILED(); + HDprintf(" Line %d: Deflate filter available\n", __LINE__); + goto error; + } /* end if */ /* Create dcpl with deflate filter */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't create dcpl\n",__LINE__); + HDprintf(" Line %d: Can't create dcpl\n", __LINE__); goto error; } /* end if */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); + HDprintf(" Line %d: Can't set chunk sizes\n", __LINE__); goto error; } /* end if */ - if(H5Pset_deflate(dcpl, 9) < 0) { + if (H5Pset_deflate(dcpl, 9) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't set deflate filter\n",__LINE__); + HDprintf(" Line %d: Can't set deflate filter\n", __LINE__); goto error; } /* end if */ /* Check if all the filters are available */ - ret=H5Pall_filters_avail(dcpl); - if(ret<0) { + ret = H5Pall_filters_avail(dcpl); + if (ret < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't check filter availability\n",__LINE__); + HDprintf(" Line %d: Can't check filter availability\n", __LINE__); goto error; } /* end if */ - if(ret!=FALSE) { + if (ret != FALSE) { H5_FAILED(); - HDprintf(" Line %d: Filter shouldn't be available\n",__LINE__); + HDprintf(" Line %d: Filter shouldn't be available\n", __LINE__); goto error; } /* end if */ /* Create the data space */ - if((sid = H5Screate_simple(2, dims, NULL)) < 0) { + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't open dataspace\n",__LINE__); + HDprintf(" Line %d: Can't open dataspace\n", __LINE__); goto error; } /* end if */ /* Create new dataset */ - if((dsid = H5Dcreate2(file, DSET_MISSING_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((dsid = H5Dcreate2(file, DSET_MISSING_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) { H5_FAILED(); - HDprintf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n", __LINE__); goto error; } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { + if (H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n", __LINE__); goto error; } /* end if */ /* Flush the file (to clear the cache) */ - if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) { + if (H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error flushing file\n",__LINE__); + HDprintf(" Line %d: Error flushing file\n", __LINE__); goto error; } /* end if */ /* Query the dataset's size on disk */ - if(0 == (dset_size = H5Dget_storage_size(dsid))) { + if (0 == (dset_size = H5Dget_storage_size(dsid))) { H5_FAILED(); - HDprintf(" Line %d: Error querying dataset size, dset_size=%lu\n",__LINE__,(unsigned long)dset_size); + HDprintf(" Line %d: Error querying dataset size, dset_size=%lu\n", __LINE__, + (unsigned long)dset_size); goto error; } /* end if */ /* Verify that the size indicates data is uncompressed */ /* (i.e. the deflation filter we asked for was silently ignored) */ - if((H5Tget_size(H5T_NATIVE_INT) * DSET_DIM1 * DSET_DIM2) != dset_size) { + if ((H5Tget_size(H5T_NATIVE_INT) * DSET_DIM1 * DSET_DIM2) != dset_size) { H5_FAILED(); - HDprintf(" Line %d: Incorrect dataset size: %lu\n",__LINE__,(unsigned long)dset_size); + HDprintf(" Line %d: Incorrect dataset size: %lu\n", __LINE__, (unsigned long)dset_size); goto error; } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { + if (H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error reading dataset data\n",__LINE__); + HDprintf(" Line %d: Error reading dataset data\n", __LINE__); goto error; } /* end if */ /* Compare data */ /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)dims[0]; i++) { - for(j=0; j<(size_t)dims[1]; j++) { - if(points[i][j] != check[i][j]) { + for (i = 0; i < (size_t)dims[0]; i++) { + for (j = 0; j < (size_t)dims[1]; j++) { + if (points[i][j] != check[i][j]) { H5_FAILED(); - HDprintf(" Line %d: Read different values than written.\n",__LINE__); + HDprintf(" Line %d: Read different values than written.\n", __LINE__); HDprintf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); - HDprintf(" At original: %d\n",points[i][j]); - HDprintf(" At returned: %d\n",check[i][j]); + HDprintf(" At original: %d\n", points[i][j]); + HDprintf(" At returned: %d\n", check[i][j]); goto error; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close dataset */ - if(H5Dclose(dsid) < 0) { + if (H5Dclose(dsid) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n", __LINE__); goto error; } /* end if */ /* Close dataspace */ - if(H5Sclose(sid) < 0) { + if (H5Sclose(sid) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dataspace\n",__LINE__); + HDprintf(" Line %d: Can't close dataspace\n", __LINE__); goto error; } /* end if */ /* Close dataset creation property list */ - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dcpl\n",__LINE__); + HDprintf(" Line %d: Can't close dcpl\n", __LINE__); goto error; } /* end if */ - /* Try reading existing dataset with deflate filter */ /* Open existing file */ - if((fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + if ((fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't open existing deflated file\n", __LINE__); goto error; } /* end if */ /* Open dataset */ - if((dsid = H5Dopen2(fid, "Dataset1", H5P_DEFAULT)) < 0) { + if ((dsid = H5Dopen2(fid, "Dataset1", H5P_DEFAULT)) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't open dataset\n", __LINE__); goto error; } /* end if */ /* Read data (should fail, since deflate filter is missing) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data); - } H5E_END_TRY; - if(ret>=0) { + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf(" Line %d: Should not be able to read dataset data\n", __LINE__); goto error; } /* end if */ /* Close dataset */ - if(H5Dclose(dsid) < 0) { + if (H5Dclose(dsid) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't close dataset\n", __LINE__); goto error; } /* end if */ /* Close existing file */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't close file\n", __LINE__); goto error; } /* end if */ /* Re-register the deflate filter */ - /* Verify deflate filter is not registered currently */ - if(H5Zfilter_avail(H5Z_FILTER_DEFLATE)!=FALSE) { - H5_FAILED(); - HDprintf(" Line %d: Deflate filter available\n",__LINE__); - goto error; - } /* end if */ + /* Verify deflate filter is not registered currently */ + if (H5Zfilter_avail(H5Z_FILTER_DEFLATE) != FALSE) { + H5_FAILED(); + HDprintf(" Line %d: Deflate filter available\n", __LINE__); + goto error; + } /* end if */ #ifdef H5_HAVE_FILTER_DEFLATE - /* Register deflate filter (use internal function to avoid range checks) */ - if(H5Z_register(H5Z_DEFLATE) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't unregister deflate filter\n",__LINE__); - goto error; - } /* end if */ + /* Register deflate filter (use internal function to avoid range checks) */ + if (H5Z_register(H5Z_DEFLATE) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't unregister deflate filter\n", __LINE__); + goto error; + } /* end if */ - /* Verify deflate filter is registered currently */ - if(H5Zfilter_avail(H5Z_FILTER_DEFLATE)!=TRUE) { - H5_FAILED(); - HDprintf(" Line %d: Deflate filter not available\n",__LINE__); - goto error; - } /* end if */ + /* Verify deflate filter is registered currently */ + if (H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) { + H5_FAILED(); + HDprintf(" Line %d: Deflate filter not available\n", __LINE__); + goto error; + } /* end if */ #endif /* H5_HAVE_FILTER_DEFLATE */ /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; PASSED(); return SUCCEED; error: - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); return FAIL; } /* end test_missing_filter() */ - /*------------------------------------------------------------------------- * Function: test_onebyte_shuffle * @@ -2834,29 +3081,34 @@ error: static herr_t test_onebyte_shuffle(hid_t file) { - hid_t dataset, space,dc; - const hsize_t size[2] = {10, 20}; - const hsize_t chunk_size[2] = {10, 20}; - unsigned char orig_data[10][20]; - unsigned char new_data[10][20]; - size_t i, j; + hid_t dataset, space, dc; + const hsize_t size[2] = {10, 20}; + const hsize_t chunk_size[2] = {10, 20}; + unsigned char orig_data[10][20]; + unsigned char new_data[10][20]; + size_t i, j; TESTING("8-bit shuffling (setup)"); /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Use shuffling algorithm with 8-bit */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error; - if(H5Pset_shuffle (dc) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_shuffle(dc) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_ONEBYTE_SHUF_NAME, H5T_NATIVE_UCHAR, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate2(file, DSET_ONEBYTE_SHUF_NAME, H5T_NATIVE_UCHAR, space, H5P_DEFAULT, dc, + H5P_DEFAULT)) < 0) + goto error; - for(i= 0;i< 10; i++) - for(j = 0; j < 20; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 20; j++) orig_data[i][j] = (unsigned char)HDrandom(); PASSED(); @@ -2868,7 +3120,7 @@ test_onebyte_shuffle(hid_t file) */ TESTING("8-bit shuffling (write)"); - if(H5Dwrite(dataset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) goto error; PASSED(); @@ -2880,17 +3132,16 @@ test_onebyte_shuffle(hid_t file) TESTING("8-bit shuffling (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + if (H5Dread(dataset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)size[0]; i++) { - for(j=0; j<(size_t)size[1]; j++) { - if(new_data[i][j] != orig_data[i][j]) { + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { + if (new_data[i][j] != orig_data[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); - HDprintf(" At index %lu,%lu\n", - (unsigned long)i, (unsigned long)j); + HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); goto error; } } @@ -2900,8 +3151,10 @@ test_onebyte_shuffle(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Pclose (dc) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -2911,7 +3164,6 @@ error: return FAIL; } /* end test_onebyte_shuffle() */ - /*------------------------------------------------------------------------- * Function: test_nbit_int * @@ -2924,52 +3176,59 @@ error: static herr_t test_nbit_int(hid_t file) { - hid_t dataset, datatype, mem_datatype, space, dc; - hsize_t size[2] = {2, 5}; - hsize_t chunk_size[2] = {2,5}; - int orig_data[2][5]; - int new_data[2][5]; - unsigned int mask; - size_t precision, offset; - double power; - size_t i, j; + hid_t dataset, datatype, mem_datatype, space, dc; + hsize_t size[2] = {2, 5}; + hsize_t chunk_size[2] = {2, 5}; + int orig_data[2][5]; + int new_data[2][5]; + unsigned int mask; + size_t precision, offset; + double power; + size_t i, j; HDputs("Testing nbit filter"); TESTING(" nbit int (setup)"); /* Define dataset datatype (integer), and set precision, offset */ - datatype = H5Tcopy(H5T_NATIVE_INT); + datatype = H5Tcopy(H5T_NATIVE_INT); precision = 17; /* precision includes sign bit */ - if(H5Tset_precision(datatype,precision) < 0) goto error; + if (H5Tset_precision(datatype, precision) < 0) + goto error; offset = 4; - if(H5Tset_offset(datatype,offset) < 0) goto error; + if (H5Tset_offset(datatype, offset) < 0) + goto error; /* Copy to memory datatype before setting order */ mem_datatype = H5Tcopy(datatype); /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) goto error; + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) + goto error; /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Use nbit filter */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dc, 2, chunk_size) < 0) goto error; - if(H5Pset_nbit(dc) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_nbit(dc) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_NBIT_INT_NAME, datatype, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate2(file, DSET_NBIT_INT_NAME, datatype, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) + goto error; /* Initialize data, assuming size of long long >= size of int */ - for(i= 0;i< (size_t)size[0]; i++) - for(j = 0; j < (size_t)size[1]; j++) { - power = HDpow(2.0f, (double)(precision - 1)); + for (i = 0; i < (size_t)size[0]; i++) + for (j = 0; j < (size_t)size[1]; j++) { + power = HDpow(2.0f, (double)(precision - 1)); orig_data[i][j] = (int)(((long long)HDrandom() % (long long)power) << offset); /* even-numbered values are negtive */ - if((i*size[1]+j+1)%2 == 0) + if ((i * size[1] + j + 1) % 2 == 0) orig_data[i][j] = -orig_data[i][j]; } @@ -2982,7 +3241,7 @@ test_nbit_int(hid_t file) */ TESTING(" nbit int (write)"); - if(H5Dwrite(dataset, mem_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + if (H5Dwrite(dataset, mem_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) goto error; PASSED(); @@ -2993,16 +3252,16 @@ test_nbit_int(hid_t file) TESTING(" nbit int (read)"); /* Read the dataset back */ - if(H5Dread(dataset, mem_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + if (H5Dread(dataset, mem_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) goto error; /* Check that the values read are the same as the values written * Use mask for checking the significant bits, ignoring the padding bits */ mask = ~((unsigned)~0 << (precision + offset)) & ((unsigned)~0 << offset); - for(i=0; i<(size_t)size[0]; i++) { - for(j=0; j<(size_t)size[1]; j++) { - if(((unsigned)new_data[i][j] & mask) != ((unsigned)orig_data[i][j] & mask)) { + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { + if (((unsigned)new_data[i][j] & mask) != ((unsigned)orig_data[i][j] & mask)) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); @@ -3015,11 +3274,16 @@ test_nbit_int(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) goto error; - if(H5Tclose(mem_datatype) < 0) goto error; - if(H5Pclose(dc) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Tclose(datatype) < 0) + goto error; + if (H5Tclose(mem_datatype) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -3029,7 +3293,6 @@ error: return FAIL; } /* end test_nbit_int() */ - /*------------------------------------------------------------------------- * Function: test_nbit_float * @@ -3042,49 +3305,49 @@ error: static herr_t test_nbit_float(hid_t file) { - hid_t dataset, datatype, space, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2, 5}; + hid_t dataset, datatype, space, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; /* orig_data[] are initialized to be within the range that can be represented by * dataset datatype (no precision loss during datatype conversion) */ - float orig_data[2][5] = {{188384.0f, 19.103516f, -1.0831790e9f, -84.242188f, 5.2045898f}, - {-49140.0f, 2350.25f, -3.2110596e-1f, 6.4998865e-5f, -0.0f}}; - float new_data[2][5]; - size_t precision, offset; - size_t i, j; + float orig_data[2][5] = {{188384.0f, 19.103516f, -1.0831790e9f, -84.242188f, 5.2045898f}, + {-49140.0f, 2350.25f, -3.2110596e-1f, 6.4998865e-5f, -0.0f}}; + float new_data[2][5]; + size_t precision, offset; + size_t i, j; TESTING(" nbit float (setup)"); /* Define user-defined single-precision floating-point type for dataset */ datatype = H5Tcopy(H5T_IEEE_F32BE); - if(H5Tset_fields(datatype, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) + if (H5Tset_fields(datatype, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) FAIL_STACK_ERROR offset = 7; - if(H5Tset_offset(datatype,offset) < 0) + if (H5Tset_offset(datatype, offset) < 0) FAIL_STACK_ERROR precision = 20; - if(H5Tset_precision(datatype,precision) < 0) + if (H5Tset_precision(datatype, precision) < 0) FAIL_STACK_ERROR - if(H5Tset_size(datatype, (size_t)4) < 0) + if (H5Tset_size(datatype, (size_t)4) < 0) FAIL_STACK_ERROR - if(H5Tset_ebias(datatype, (size_t)31) < 0) + if (H5Tset_ebias(datatype, (size_t)31) < 0) FAIL_STACK_ERROR /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) + if ((space = H5Screate_simple(2, size, NULL)) < 0) FAIL_STACK_ERROR /* Use nbit filter */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dc, 2, chunk_size) < 0) + if (H5Pset_chunk(dc, 2, chunk_size) < 0) FAIL_STACK_ERROR - if(H5Pset_nbit(dc) < 0) + if (H5Pset_nbit(dc) < 0) FAIL_STACK_ERROR /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_NBIT_FLOAT_NAME, datatype, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_NBIT_FLOAT_NAME, datatype, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR PASSED(); @@ -3095,7 +3358,7 @@ test_nbit_float(hid_t file) */ TESTING(" nbit float (write)"); - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) FAIL_STACK_ERROR PASSED(); @@ -3107,17 +3370,17 @@ test_nbit_float(hid_t file) TESTING(" nbit float (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + if (H5Dread(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) FAIL_STACK_ERROR /* Check that the values read are the same as the values written * Assume size of int = size of float */ - for(i = 0; i < (size_t)size[0]; i++) { - for(j = 0; j < (size_t)size[1]; j++) { - if(HDisnan(orig_data[i][j])) - continue; /* skip if value is NaN */ - if(!H5_FLT_ABS_EQUAL(new_data[i][j], orig_data[i][j])) { + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { + if (HDisnan(orig_data[i][j])) + continue; /* skip if value is NaN */ + if (!H5_FLT_ABS_EQUAL(new_data[i][j], orig_data[i][j])) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); @@ -3130,13 +3393,13 @@ test_nbit_float(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) + if (H5Tclose(datatype) < 0) FAIL_STACK_ERROR - if(H5Pclose(dc) < 0) + if (H5Pclose(dc) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR PASSED(); @@ -3147,7 +3410,6 @@ error: return FAIL; } /* end test_nbit_float() */ - /*------------------------------------------------------------------------- * Function: test_nbit_double * @@ -3160,63 +3422,54 @@ error: static herr_t test_nbit_double(hid_t file) { -/* assume unsigned int and float has the same number of bytes */ - hid_t dataset, datatype, space, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2, 5}; + /* assume unsigned int and float has the same number of bytes */ + hid_t dataset, datatype, space, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; /* orig_data[] are initialized to be within the range that can be represented by * dataset datatype (no precision loss during datatype conversion) */ - double orig_data[2][5] = { - { - (double)1.6081706885101836e+60L, - -255.32099170994480f, - (double)1.2677579992621376e-61L, - 64568.289448797700f, - (double)-1.0619721778839084e-75L - }, - { - (double)2.1499497833454840e+56L, - 6.6562295504670740e-3f, - -1.5747263393432150f, - 1.0711093225222612f, - -9.8971679387636870e-1f - }}; - double new_data[2][5]; - size_t precision, offset; - size_t i, j; + double orig_data[2][5] = {{(double)1.6081706885101836e+60L, -255.32099170994480f, + (double)1.2677579992621376e-61L, 64568.289448797700f, + (double)-1.0619721778839084e-75L}, + {(double)2.1499497833454840e+56L, 6.6562295504670740e-3f, -1.5747263393432150f, + 1.0711093225222612f, -9.8971679387636870e-1f}}; + double new_data[2][5]; + size_t precision, offset; + size_t i, j; TESTING(" nbit double (setup)"); /* Define user-defined doule-precision floating-point type for dataset */ datatype = H5Tcopy(H5T_IEEE_F64BE); - if(H5Tset_fields(datatype, (size_t)55, (size_t)46, (size_t)9, (size_t)5, (size_t)41) < 0) + if (H5Tset_fields(datatype, (size_t)55, (size_t)46, (size_t)9, (size_t)5, (size_t)41) < 0) FAIL_STACK_ERROR offset = 5; - if(H5Tset_offset(datatype,offset) < 0) + if (H5Tset_offset(datatype, offset) < 0) FAIL_STACK_ERROR precision = 51; - if(H5Tset_precision(datatype,precision) < 0) + if (H5Tset_precision(datatype, precision) < 0) FAIL_STACK_ERROR - if(H5Tset_size(datatype, (size_t)8) < 0) + if (H5Tset_size(datatype, (size_t)8) < 0) FAIL_STACK_ERROR - if(H5Tset_ebias(datatype, (size_t)255) < 0) + if (H5Tset_ebias(datatype, (size_t)255) < 0) FAIL_STACK_ERROR /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) + if ((space = H5Screate_simple(2, size, NULL)) < 0) FAIL_STACK_ERROR /* Use nbit filter */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dc, 2, chunk_size) < 0) + if (H5Pset_chunk(dc, 2, chunk_size) < 0) FAIL_STACK_ERROR - if(H5Pset_nbit(dc) < 0) + if (H5Pset_nbit(dc) < 0) FAIL_STACK_ERROR /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_NBIT_DOUBLE_NAME, datatype, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_NBIT_DOUBLE_NAME, datatype, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < + 0) FAIL_STACK_ERROR PASSED(); @@ -3228,7 +3481,7 @@ test_nbit_double(hid_t file) */ TESTING(" nbit double (write)"); - if(H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) FAIL_STACK_ERROR PASSED(); @@ -3239,17 +3492,17 @@ test_nbit_double(hid_t file) TESTING(" nbit double (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + if (H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) FAIL_STACK_ERROR /* Check that the values read are the same as the values written * Assume size of long long = size of double */ - for(i = 0; i < (size_t)size[0]; i++) { - for(j = 0; j < (size_t)size[1]; j++) { - if(HDisnan(orig_data[i][j])) - continue; /* skip if value is NaN */ - if(!H5_DBL_ABS_EQUAL(new_data[i][j], orig_data[i][j])) { + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { + if (HDisnan(orig_data[i][j])) + continue; /* skip if value is NaN */ + if (!H5_DBL_ABS_EQUAL(new_data[i][j], orig_data[i][j])) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); @@ -3262,13 +3515,13 @@ test_nbit_double(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) + if (H5Tclose(datatype) < 0) FAIL_STACK_ERROR - if(H5Pclose(dc) < 0) + if (H5Pclose(dc) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR PASSED(); @@ -3279,7 +3532,6 @@ error: return FAIL; } /* end test_nbit_double() */ - /*------------------------------------------------------------------------- * Function: test_nbit_array * @@ -3292,31 +3544,34 @@ error: static herr_t test_nbit_array(hid_t file) { - hid_t dataset, base_datatype, array_datatype, space, dc; - hid_t mem_base_datatype, mem_array_datatype; - const hsize_t size[2] = {2, 5}; - const hsize_t adims[2] = {3, 2}; - const hsize_t chunk_size[2] = {2,5}; - unsigned int orig_data[2][5][3][2]; - unsigned int new_data[2][5][3][2]; - size_t precision, offset; - double power; - size_t i, j, m, n; + hid_t dataset, base_datatype, array_datatype, space, dc; + hid_t mem_base_datatype, mem_array_datatype; + const hsize_t size[2] = {2, 5}; + const hsize_t adims[2] = {3, 2}; + const hsize_t chunk_size[2] = {2, 5}; + unsigned int orig_data[2][5][3][2]; + unsigned int new_data[2][5][3][2]; + size_t precision, offset; + double power; + size_t i, j, m, n; TESTING(" nbit array (setup)"); /* Define dataset array datatype's base datatype and set precision, offset */ base_datatype = H5Tcopy(H5T_NATIVE_UINT); - precision = 22; - if(H5Tset_precision(base_datatype,precision) < 0) goto error; + precision = 22; + if (H5Tset_precision(base_datatype, precision) < 0) + goto error; offset = 7; - if(H5Tset_offset(base_datatype,offset) < 0) goto error; + if (H5Tset_offset(base_datatype, offset) < 0) + goto error; /* Copy to memory array datatype's base datatype before setting order */ mem_base_datatype = H5Tcopy(base_datatype); /* Set order of dataset array datatype's base datatype */ - if(H5Tset_order(base_datatype, H5T_ORDER_BE) < 0) goto error; + if (H5Tset_order(base_datatype, H5T_ORDER_BE) < 0) + goto error; /* Create dataset array datatype */ array_datatype = H5Tarray_create2(base_datatype, 2, adims); @@ -3325,26 +3580,31 @@ test_nbit_array(hid_t file) mem_array_datatype = H5Tarray_create2(mem_base_datatype, 2, adims); /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Use nbit filter */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dc, 2, chunk_size) < 0) goto error; - if(H5Pset_nbit(dc) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_nbit(dc) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_NBIT_ARRAY_NAME, array_datatype, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = + H5Dcreate2(file, DSET_NBIT_ARRAY_NAME, array_datatype, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) + goto error; /* Initialize data, assuming size of long long >= size of unsigned int */ - for(i= 0;i< (size_t)size[0]; i++) - for(j = 0; j < (size_t)size[1]; j++) - for(m = 0; m < (size_t)adims[0]; m++) - for(n = 0; n < (size_t)adims[1]; n++) { - power = HDpow(2.0F, (double)precision); - orig_data[i][j][m][n] = (unsigned int)(((long long)HDrandom() % - (long long)power) << offset); - } /* end for */ + for (i = 0; i < (size_t)size[0]; i++) + for (j = 0; j < (size_t)size[1]; j++) + for (m = 0; m < (size_t)adims[0]; m++) + for (n = 0; n < (size_t)adims[1]; n++) { + power = HDpow(2.0F, (double)precision); + orig_data[i][j][m][n] = + (unsigned int)(((long long)HDrandom() % (long long)power) << offset); + } /* end for */ PASSED(); /*---------------------------------------------------------------------- @@ -3354,8 +3614,7 @@ test_nbit_array(hid_t file) */ TESTING(" nbit array (write)"); - if(H5Dwrite(dataset, mem_array_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, - orig_data) < 0) + if (H5Dwrite(dataset, mem_array_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) goto error; PASSED(); @@ -3367,36 +3626,42 @@ test_nbit_array(hid_t file) TESTING(" nbit array (read)"); /* Read the dataset back */ - if(H5Dread(dataset, mem_array_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, - new_data) < 0) + if (H5Dread(dataset, mem_array_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)size[0]; i++) - for(j=0; j<(size_t)size[1]; j++) - for(m = 0; m < (size_t)adims[0]; m++) - for(n = 0; n < (size_t)adims[1]; n++) { - if(new_data[i][j][m][n]!= orig_data[i][j][m][n]) { - H5_FAILED(); - HDprintf(" Read different values than written.\n"); - HDprintf(" At index %lu,%lu,%lu,%lu\n", - (unsigned long)i, (unsigned long)j, (unsigned long)m, (unsigned long)n); - goto error; - } - } + for (i = 0; i < (size_t)size[0]; i++) + for (j = 0; j < (size_t)size[1]; j++) + for (m = 0; m < (size_t)adims[0]; m++) + for (n = 0; n < (size_t)adims[1]; n++) { + if (new_data[i][j][m][n] != orig_data[i][j][m][n]) { + H5_FAILED(); + HDprintf(" Read different values than written.\n"); + HDprintf(" At index %lu,%lu,%lu,%lu\n", (unsigned long)i, (unsigned long)j, + (unsigned long)m, (unsigned long)n); + goto error; + } + } /*---------------------------------------------------------------------- * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(array_datatype) < 0) goto error; - if(H5Tclose(base_datatype) < 0) goto error; - if(H5Tclose(mem_array_datatype) < 0) goto error; - if(H5Tclose(mem_base_datatype) < 0) goto error; - if(H5Pclose(dc) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Tclose(array_datatype) < 0) + goto error; + if (H5Tclose(base_datatype) < 0) + goto error; + if (H5Tclose(mem_array_datatype) < 0) + goto error; + if (H5Tclose(mem_base_datatype) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -3406,7 +3671,6 @@ error: return FAIL; } /* end test_nbit_array() */ - /*------------------------------------------------------------------------- * Function: test_nbit_compound * @@ -3424,125 +3688,125 @@ error: static herr_t test_nbit_compound(hid_t file) { - typedef struct { /* Struct with atomic fields */ - int i; - char c; + typedef struct { /* Struct with atomic fields */ + int i; + char c; short s; float f; } atomic; - hid_t i_tid, c_tid, s_tid, f_tid; - hid_t cmpd_tid; /* atomic compound datatype */ - hid_t mem_cmpd_tid; /* memory atomic compound datatype */ - size_t precision[3] = {15, 7, 10}; - size_t offset[3] = {9, 0, 3}; - hid_t dataset, space, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2, 5}; - const float float_val[2][5] = {{188384.0F, 19.103516F, -1.0831790e9F, -84.242188F, 5.2045898F}, - {-49140.0F, 2350.25F, -3.2110596e-1F, 6.4998865e-5F, -0.0F}}; - atomic orig_data[2][5]; - atomic new_data[2][5]; - unsigned int i_mask, s_mask, c_mask; - double power; - size_t i, j; - + hid_t i_tid, c_tid, s_tid, f_tid; + hid_t cmpd_tid; /* atomic compound datatype */ + hid_t mem_cmpd_tid; /* memory atomic compound datatype */ + size_t precision[3] = {15, 7, 10}; + size_t offset[3] = {9, 0, 3}; + hid_t dataset, space, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; + const float float_val[2][5] = {{188384.0F, 19.103516F, -1.0831790e9F, -84.242188F, 5.2045898F}, + {-49140.0F, 2350.25F, -3.2110596e-1F, 6.4998865e-5F, -0.0F}}; + atomic orig_data[2][5]; + atomic new_data[2][5]; + unsigned int i_mask, s_mask, c_mask; + double power; + size_t i, j; TESTING(" nbit compound (setup)"); /* Define datatypes of members of compound datatype */ - if((i_tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((i_tid = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR - if((c_tid = H5Tcopy(H5T_NATIVE_CHAR)) < 0) + if ((c_tid = H5Tcopy(H5T_NATIVE_CHAR)) < 0) FAIL_STACK_ERROR - if((s_tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0) + if ((s_tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0) FAIL_STACK_ERROR - if((f_tid = H5Tcopy(H5T_IEEE_F32BE)) < 0) + if ((f_tid = H5Tcopy(H5T_IEEE_F32BE)) < 0) FAIL_STACK_ERROR /* Set precision and offset etc. */ - if(H5Tset_precision(i_tid,precision[0]) < 0) + if (H5Tset_precision(i_tid, precision[0]) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(i_tid,offset[0]) < 0) + if (H5Tset_offset(i_tid, offset[0]) < 0) FAIL_STACK_ERROR - if(H5Tset_precision(c_tid,precision[1]) < 0) + if (H5Tset_precision(c_tid, precision[1]) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(c_tid,offset[1]) < 0) + if (H5Tset_offset(c_tid, offset[1]) < 0) FAIL_STACK_ERROR - if(H5Tset_precision(s_tid,precision[2]) < 0) + if (H5Tset_precision(s_tid, precision[2]) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(s_tid,offset[2]) < 0) + if (H5Tset_offset(s_tid, offset[2]) < 0) FAIL_STACK_ERROR - if(H5Tset_fields(f_tid, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) + if (H5Tset_fields(f_tid, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(f_tid, (size_t)7) < 0) + if (H5Tset_offset(f_tid, (size_t)7) < 0) FAIL_STACK_ERROR - if(H5Tset_precision(f_tid, (size_t)20) < 0) + if (H5Tset_precision(f_tid, (size_t)20) < 0) FAIL_STACK_ERROR - if(H5Tset_size(f_tid, (size_t)4) < 0) + if (H5Tset_size(f_tid, (size_t)4) < 0) FAIL_STACK_ERROR - if(H5Tset_ebias(f_tid, (size_t)31) < 0) + if (H5Tset_ebias(f_tid, (size_t)31) < 0) FAIL_STACK_ERROR /* Create a memory compound datatype before setting the order */ - if((mem_cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(atomic))) < 0) + if ((mem_cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(atomic))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid, "i", HOFFSET(atomic, i), i_tid) < 0) + if (H5Tinsert(mem_cmpd_tid, "i", HOFFSET(atomic, i), i_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid, "c", HOFFSET(atomic, c), c_tid) < 0) + if (H5Tinsert(mem_cmpd_tid, "c", HOFFSET(atomic, c), c_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid, "s", HOFFSET(atomic, s), s_tid) < 0) + if (H5Tinsert(mem_cmpd_tid, "s", HOFFSET(atomic, s), s_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid, "f", HOFFSET(atomic, f), H5T_NATIVE_FLOAT) < 0) + if (H5Tinsert(mem_cmpd_tid, "f", HOFFSET(atomic, f), H5T_NATIVE_FLOAT) < 0) FAIL_STACK_ERROR /* Create a dataset compound datatype and insert some atomic types */ - if((cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(atomic))) < 0) + if ((cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(atomic))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid, "i", HOFFSET(atomic, i), i_tid) < 0) + if (H5Tinsert(cmpd_tid, "i", HOFFSET(atomic, i), i_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid, "c", HOFFSET(atomic, c), c_tid) < 0) + if (H5Tinsert(cmpd_tid, "c", HOFFSET(atomic, c), c_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid, "s", HOFFSET(atomic, s), s_tid) < 0) + if (H5Tinsert(cmpd_tid, "s", HOFFSET(atomic, s), s_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid, "f", HOFFSET(atomic, f), f_tid) < 0) + if (H5Tinsert(cmpd_tid, "f", HOFFSET(atomic, f), f_tid) < 0) FAIL_STACK_ERROR /* Set order of dataset compound datatype */ - if(H5Tset_order(cmpd_tid, H5T_ORDER_BE) < 0) + if (H5Tset_order(cmpd_tid, H5T_ORDER_BE) < 0) FAIL_STACK_ERROR /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) + if ((space = H5Screate_simple(2, size, NULL)) < 0) FAIL_STACK_ERROR /* Use nbit filter */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dc, 2, chunk_size) < 0) + if (H5Pset_chunk(dc, 2, chunk_size) < 0) FAIL_STACK_ERROR - if(H5Pset_nbit(dc) < 0) + if (H5Pset_nbit(dc) < 0) FAIL_STACK_ERROR /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_NBIT_COMPOUND_NAME, cmpd_tid, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_NBIT_COMPOUND_NAME, cmpd_tid, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < + 0) FAIL_STACK_ERROR /* Initialize data, assuming size of long long >= size of member datatypes */ - for(i = 0; i < (size_t)size[0]; i++) - for(j = 0; j < (size_t)size[1]; j++) { - power = HDpow(2.0F, (double)(precision[0]-1)); + for (i = 0; i < (size_t)size[0]; i++) + for (j = 0; j < (size_t)size[1]; j++) { + power = HDpow(2.0F, (double)(precision[0] - 1)); orig_data[i][j].i = (int)(((long long)HDrandom() % (long long)power) << offset[0]); - power = HDpow(2.0F, (double)(precision[1]-1)); + power = HDpow(2.0F, (double)(precision[1] - 1)); orig_data[i][j].c = (char)(((long long)HDrandom() % (long long)power) << offset[1]); - power = HDpow(2.0F, (double)(precision[2]-1)); + power = HDpow(2.0F, (double)(precision[2] - 1)); orig_data[i][j].s = (short)(((long long)HDrandom() % (long long)power) << offset[2]); orig_data[i][j].f = float_val[i][j]; /* some even-numbered integer values are negtive */ - if((i * size[1] + j + 1) % 2 == 0) { + if ((i * size[1] + j + 1) % 2 == 0) { orig_data[i][j].i = -orig_data[i][j].i; orig_data[i][j].s = (short)-orig_data[i][j].s; } @@ -3557,7 +3821,7 @@ test_nbit_compound(hid_t file) */ TESTING(" nbit compound (write)"); - if(H5Dwrite(dataset, mem_cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + if (H5Dwrite(dataset, mem_cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) FAIL_STACK_ERROR PASSED(); @@ -3568,7 +3832,7 @@ test_nbit_compound(hid_t file) TESTING(" nbit compound (read)"); /* Read the dataset back */ - if(H5Dread(dataset, mem_cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + if (H5Dread(dataset, mem_cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) FAIL_STACK_ERROR /* Check that the values read are the same as the values written @@ -3577,13 +3841,12 @@ test_nbit_compound(hid_t file) i_mask = ~((unsigned)~0 << (precision[0] + offset[0])) & ((unsigned)~0 << offset[0]); c_mask = ~((unsigned)~0 << (precision[1] + offset[1])) & ((unsigned)~0 << offset[1]); s_mask = ~((unsigned)~0 << (precision[2] + offset[2])) & ((unsigned)~0 << offset[2]); - for(i = 0; i < size[0]; i++) { - for(j = 0; j < size[1]; j++) { - if(((unsigned)new_data[i][j].i & i_mask) != ((unsigned)orig_data[i][j].i & i_mask) || + for (i = 0; i < size[0]; i++) { + for (j = 0; j < size[1]; j++) { + if (((unsigned)new_data[i][j].i & i_mask) != ((unsigned)orig_data[i][j].i & i_mask) || ((unsigned)new_data[i][j].c & c_mask) != ((unsigned)orig_data[i][j].c & c_mask) || ((unsigned)new_data[i][j].s & s_mask) != ((unsigned)orig_data[i][j].s & s_mask) || - (!HDisnan(orig_data[i][j].f) && !H5_FLT_ABS_EQUAL(new_data[i][j].f, orig_data[i][j].f))) - { + (!HDisnan(orig_data[i][j].f) && !H5_FLT_ABS_EQUAL(new_data[i][j].f, orig_data[i][j].f))) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); @@ -3596,23 +3859,23 @@ test_nbit_compound(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(i_tid) < 0) + if (H5Tclose(i_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(c_tid) < 0) + if (H5Tclose(c_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(s_tid) < 0) + if (H5Tclose(s_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(f_tid) < 0) + if (H5Tclose(f_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(cmpd_tid) < 0) + if (H5Tclose(cmpd_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(mem_cmpd_tid) < 0) + if (H5Tclose(mem_cmpd_tid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dc) < 0) + if (H5Pclose(dc) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR PASSED(); @@ -3623,7 +3886,6 @@ error: return FAIL; } /* end test_nbit_compound() */ - /*------------------------------------------------------------------------- * Function: test_nbit_compound_2 * @@ -3641,210 +3903,213 @@ error: static herr_t test_nbit_compound_2(hid_t file) { - typedef struct { /* Struct with atomic fields */ - int i; - char c; + typedef struct { /* Struct with atomic fields */ + int i; + char c; short s; float f; } atomic; - typedef struct { /* Struct with complex fields */ - atomic a; + typedef struct { /* Struct with complex fields */ + atomic a; unsigned int v; - char b[2][2]; - atomic d[2][2]; + char b[2][2]; + atomic d[2][2]; } complex; - hid_t i_tid, c_tid, s_tid, f_tid, v_tid; - hid_t cmpd_tid1; /* atomic compound datatype */ - hid_t cmpd_tid2; /* complex compound datatype */ - hid_t mem_cmpd_tid1; /* memory atomic compound datatype */ - hid_t mem_cmpd_tid2; /* memory complex compound datatype */ - hid_t base_tid; /* simple array datatype's base datatype */ - hid_t array_tid; /* simple array datatype */ - hid_t array_cmplx_tid; /* complex array datatype */ - hid_t mem_array_cmplx_tid; /* memory complex array datatype */ - const hsize_t array_dims[2] = {2, 2}; - size_t precision[5] = {31, 8, 10, 23, 8}; - size_t offset[5] = {1, 0, 3, 5, 0}; - hid_t dataset, space, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2, 5}; - const float float_val[2][5] = {{188384.0F, 19.103516F, -1.0831790e9F, -84.242188F, 5.2045898F}, - {-49140.0F, 2350.25F, -3.2110596e-1F, 6.4998865e-5F, -0.0F}}; - complex orig_data[2][5]; - complex new_data[2][5]; - unsigned int i_mask, s_mask, c_mask, b_mask; - double power; - size_t i, j, m, n, b_failed, d_failed; - + hid_t i_tid, c_tid, s_tid, f_tid, v_tid; + hid_t cmpd_tid1; /* atomic compound datatype */ + hid_t cmpd_tid2; /* complex compound datatype */ + hid_t mem_cmpd_tid1; /* memory atomic compound datatype */ + hid_t mem_cmpd_tid2; /* memory complex compound datatype */ + hid_t base_tid; /* simple array datatype's base datatype */ + hid_t array_tid; /* simple array datatype */ + hid_t array_cmplx_tid; /* complex array datatype */ + hid_t mem_array_cmplx_tid; /* memory complex array datatype */ + const hsize_t array_dims[2] = {2, 2}; + size_t precision[5] = {31, 8, 10, 23, 8}; + size_t offset[5] = {1, 0, 3, 5, 0}; + hid_t dataset, space, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; + const float float_val[2][5] = {{188384.0F, 19.103516F, -1.0831790e9F, -84.242188F, 5.2045898F}, + {-49140.0F, 2350.25F, -3.2110596e-1F, 6.4998865e-5F, -0.0F}}; + complex orig_data[2][5]; + complex new_data[2][5]; + unsigned int i_mask, s_mask, c_mask, b_mask; + double power; + size_t i, j, m, n, b_failed, d_failed; TESTING(" nbit compound complex (setup)"); /* Define datatypes of members of compound datatype */ - if((i_tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((i_tid = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR - if((c_tid = H5Tcopy(H5T_NATIVE_CHAR)) < 0) + if ((c_tid = H5Tcopy(H5T_NATIVE_CHAR)) < 0) FAIL_STACK_ERROR - if((s_tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0) + if ((s_tid = H5Tcopy(H5T_NATIVE_SHORT)) < 0) FAIL_STACK_ERROR - if((v_tid = H5Tcopy(H5T_NATIVE_UINT)) < 0) + if ((v_tid = H5Tcopy(H5T_NATIVE_UINT)) < 0) FAIL_STACK_ERROR - if((f_tid = H5Tcopy(H5T_IEEE_F32BE)) < 0) + if ((f_tid = H5Tcopy(H5T_IEEE_F32BE)) < 0) FAIL_STACK_ERROR /* Set precision and offset etc. of atomic compound datatype members */ - if(H5Tset_precision(i_tid,precision[0]) < 0) + if (H5Tset_precision(i_tid, precision[0]) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(i_tid,offset[0]) < 0) + if (H5Tset_offset(i_tid, offset[0]) < 0) FAIL_STACK_ERROR - if(H5Tset_precision(c_tid,precision[1]) < 0) + if (H5Tset_precision(c_tid, precision[1]) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(c_tid,offset[1]) < 0) + if (H5Tset_offset(c_tid, offset[1]) < 0) FAIL_STACK_ERROR - if(H5Tset_precision(s_tid,precision[2]) < 0) + if (H5Tset_precision(s_tid, precision[2]) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(s_tid,offset[2]) < 0) + if (H5Tset_offset(s_tid, offset[2]) < 0) FAIL_STACK_ERROR - if(H5Tset_fields(f_tid, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) + if (H5Tset_fields(f_tid, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(f_tid, (size_t)7) < 0) + if (H5Tset_offset(f_tid, (size_t)7) < 0) FAIL_STACK_ERROR - if(H5Tset_precision(f_tid, (size_t)20) < 0) + if (H5Tset_precision(f_tid, (size_t)20) < 0) FAIL_STACK_ERROR - if(H5Tset_size(f_tid, (size_t)4) < 0) + if (H5Tset_size(f_tid, (size_t)4) < 0) FAIL_STACK_ERROR - if(H5Tset_ebias(f_tid, (size_t)31) < 0) + if (H5Tset_ebias(f_tid, (size_t)31) < 0) FAIL_STACK_ERROR /* Create a memory atomic compound datatype before setting the order */ - if((mem_cmpd_tid1 = H5Tcreate(H5T_COMPOUND, sizeof(atomic))) < 0) + if ((mem_cmpd_tid1 = H5Tcreate(H5T_COMPOUND, sizeof(atomic))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid1, "i", HOFFSET(atomic, i), i_tid) < 0) + if (H5Tinsert(mem_cmpd_tid1, "i", HOFFSET(atomic, i), i_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid1, "c", HOFFSET(atomic, c), c_tid) < 0) + if (H5Tinsert(mem_cmpd_tid1, "c", HOFFSET(atomic, c), c_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid1, "s", HOFFSET(atomic, s), s_tid) < 0) + if (H5Tinsert(mem_cmpd_tid1, "s", HOFFSET(atomic, s), s_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid1, "f", HOFFSET(atomic, f), H5T_NATIVE_FLOAT) < 0) + if (H5Tinsert(mem_cmpd_tid1, "f", HOFFSET(atomic, f), H5T_NATIVE_FLOAT) < 0) FAIL_STACK_ERROR /* Create a dataset atomic compound datatype and insert some atomic types */ - if((cmpd_tid1 = H5Tcreate(H5T_COMPOUND, sizeof(atomic))) < 0) + if ((cmpd_tid1 = H5Tcreate(H5T_COMPOUND, sizeof(atomic))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid1, "i", HOFFSET(atomic, i), i_tid) < 0) + if (H5Tinsert(cmpd_tid1, "i", HOFFSET(atomic, i), i_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid1, "c", HOFFSET(atomic, c), c_tid) < 0) + if (H5Tinsert(cmpd_tid1, "c", HOFFSET(atomic, c), c_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid1, "s", HOFFSET(atomic, s), s_tid) < 0) + if (H5Tinsert(cmpd_tid1, "s", HOFFSET(atomic, s), s_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid1, "f", HOFFSET(atomic, f), f_tid) < 0) + if (H5Tinsert(cmpd_tid1, "f", HOFFSET(atomic, f), f_tid) < 0) FAIL_STACK_ERROR /* Set order of dataset compound datatype */ - if(H5Tset_order(cmpd_tid1, H5T_ORDER_BE) < 0) + if (H5Tset_order(cmpd_tid1, H5T_ORDER_BE) < 0) FAIL_STACK_ERROR /* Set precision and offset of the other data member */ - if(H5Tset_precision(v_tid,precision[3]) < 0) + if (H5Tset_precision(v_tid, precision[3]) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(v_tid,offset[3]) < 0) + if (H5Tset_offset(v_tid, offset[3]) < 0) FAIL_STACK_ERROR /* Create the simple array datatype */ - if((base_tid = H5Tcopy(H5T_NATIVE_CHAR)) < 0) + if ((base_tid = H5Tcopy(H5T_NATIVE_CHAR)) < 0) FAIL_STACK_ERROR - if(H5Tset_precision(base_tid,precision[4]) < 0) + if (H5Tset_precision(base_tid, precision[4]) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(base_tid,offset[4]) < 0) + if (H5Tset_offset(base_tid, offset[4]) < 0) FAIL_STACK_ERROR - if((array_tid = H5Tarray_create2(base_tid, 2, array_dims)) < 0) + if ((array_tid = H5Tarray_create2(base_tid, 2, array_dims)) < 0) FAIL_STACK_ERROR /* Create the complex memory and dataset array datatype */ - if((array_cmplx_tid = H5Tarray_create2(cmpd_tid1, 2, array_dims)) < 0) + if ((array_cmplx_tid = H5Tarray_create2(cmpd_tid1, 2, array_dims)) < 0) FAIL_STACK_ERROR - if((mem_array_cmplx_tid = H5Tarray_create2(mem_cmpd_tid1, 2, array_dims)) < 0) + if ((mem_array_cmplx_tid = H5Tarray_create2(mem_cmpd_tid1, 2, array_dims)) < 0) FAIL_STACK_ERROR /* Create a memory complex compound datatype before setting the order */ - if((mem_cmpd_tid2 = H5Tcreate(H5T_COMPOUND, sizeof(complex))) < 0) + if ((mem_cmpd_tid2 = H5Tcreate(H5T_COMPOUND, sizeof(complex))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid2, "a", HOFFSET(complex, a), mem_cmpd_tid1) < 0) + if (H5Tinsert(mem_cmpd_tid2, "a", HOFFSET(complex, a), mem_cmpd_tid1) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid2, "v", HOFFSET(complex, v), v_tid) < 0) + if (H5Tinsert(mem_cmpd_tid2, "v", HOFFSET(complex, v), v_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid2, "b", HOFFSET(complex, b), array_tid) < 0) + if (H5Tinsert(mem_cmpd_tid2, "b", HOFFSET(complex, b), array_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(mem_cmpd_tid2, "d", HOFFSET(complex, d), mem_array_cmplx_tid) < 0) + if (H5Tinsert(mem_cmpd_tid2, "d", HOFFSET(complex, d), mem_array_cmplx_tid) < 0) FAIL_STACK_ERROR /* Set order of dataset other complex compound member datatype */ - if(H5Tset_order(v_tid, H5T_ORDER_BE) < 0) + if (H5Tset_order(v_tid, H5T_ORDER_BE) < 0) FAIL_STACK_ERROR /* Create a dataset complex compound datatype and insert members */ - if((cmpd_tid2 = H5Tcreate(H5T_COMPOUND, sizeof(complex))) < 0) + if ((cmpd_tid2 = H5Tcreate(H5T_COMPOUND, sizeof(complex))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid2, "a", HOFFSET(complex, a), cmpd_tid1) < 0) + if (H5Tinsert(cmpd_tid2, "a", HOFFSET(complex, a), cmpd_tid1) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid2, "v", HOFFSET(complex, v), v_tid) < 0) + if (H5Tinsert(cmpd_tid2, "v", HOFFSET(complex, v), v_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid2, "b", HOFFSET(complex, b), array_tid) < 0) + if (H5Tinsert(cmpd_tid2, "b", HOFFSET(complex, b), array_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd_tid2, "d", HOFFSET(complex, d), array_cmplx_tid) < 0) + if (H5Tinsert(cmpd_tid2, "d", HOFFSET(complex, d), array_cmplx_tid) < 0) FAIL_STACK_ERROR /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) + if ((space = H5Screate_simple(2, size, NULL)) < 0) FAIL_STACK_ERROR /* Use nbit filter */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dc, 2, chunk_size) < 0) + if (H5Pset_chunk(dc, 2, chunk_size) < 0) FAIL_STACK_ERROR - if(H5Pset_nbit(dc) < 0) + if (H5Pset_nbit(dc) < 0) FAIL_STACK_ERROR /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_NBIT_COMPOUND_NAME_2, cmpd_tid2, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, DSET_NBIT_COMPOUND_NAME_2, cmpd_tid2, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize data, assuming size of long long >= size of member datatypes */ - for(i= 0;i< (size_t)size[0]; i++) - for(j = 0; j < (size_t)size[1]; j++) { - power = HDpow(2.0F, (double)(precision[0]-1)); + for (i = 0; i < (size_t)size[0]; i++) + for (j = 0; j < (size_t)size[1]; j++) { + power = HDpow(2.0F, (double)(precision[0] - 1)); orig_data[i][j].a.i = (int)(((long long)HDrandom() % (long long)power) << offset[0]); - power = HDpow(2.0F, (double)(precision[1]-1)); + power = HDpow(2.0F, (double)(precision[1] - 1)); orig_data[i][j].a.c = (char)(((long long)HDrandom() % (long long)power) << offset[1]); - power = HDpow(2.0F, (double)(precision[2]-1)); + power = HDpow(2.0F, (double)(precision[2] - 1)); orig_data[i][j].a.s = (short)(-((long long)HDrandom() % (long long)power) << offset[2]); orig_data[i][j].a.f = float_val[i][j]; - power = HDpow(2.0F, (double)precision[3]); + power = HDpow(2.0F, (double)precision[3]); orig_data[i][j].v = (unsigned int)(((long long)HDrandom() % (long long)power) << offset[3]); - for(m = 0; m < (size_t)array_dims[0]; m++) - for(n = 0; n < (size_t)array_dims[1]; n++) { - power = HDpow(2.0F, (double)(precision[4]-1)); + for (m = 0; m < (size_t)array_dims[0]; m++) + for (n = 0; n < (size_t)array_dims[1]; n++) { + power = HDpow(2.0F, (double)(precision[4] - 1)); orig_data[i][j].b[m][n] = (char)(((long long)HDrandom() % (long long)power) << offset[4]); } /* end for */ - for(m = 0; m < (size_t)array_dims[0]; m++) - for(n = 0; n < (size_t)array_dims[1]; n++) { - power = HDpow(2.0F, (double)(precision[0]-1)); - orig_data[i][j].d[m][n].i = (int)(-((long long)HDrandom() % (long long)power) << offset[0]); - power = HDpow(2.0F, (double)(precision[1]-1)); - orig_data[i][j].d[m][n].c = (char)(((long long)HDrandom() % (long long)power) << offset[1]); - power = HDpow(2.0F, (double)(precision[2]-1)); - orig_data[i][j].d[m][n].s = (short)(((long long)HDrandom() % (long long)power) << offset[2]); + for (m = 0; m < (size_t)array_dims[0]; m++) + for (n = 0; n < (size_t)array_dims[1]; n++) { + power = HDpow(2.0F, (double)(precision[0] - 1)); + orig_data[i][j].d[m][n].i = + (int)(-((long long)HDrandom() % (long long)power) << offset[0]); + power = HDpow(2.0F, (double)(precision[1] - 1)); + orig_data[i][j].d[m][n].c = + (char)(((long long)HDrandom() % (long long)power) << offset[1]); + power = HDpow(2.0F, (double)(precision[2] - 1)); + orig_data[i][j].d[m][n].s = + (short)(((long long)HDrandom() % (long long)power) << offset[2]); orig_data[i][j].d[m][n].f = float_val[i][j]; } /* end for */ - } /* end for */ + } /* end for */ PASSED(); @@ -3855,7 +4120,7 @@ test_nbit_compound_2(hid_t file) */ TESTING(" nbit compound complex (write)"); - if(H5Dwrite(dataset, mem_cmpd_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + if (H5Dwrite(dataset, mem_cmpd_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) FAIL_STACK_ERROR PASSED(); @@ -3866,7 +4131,7 @@ test_nbit_compound_2(hid_t file) TESTING(" nbit compound complex (read)"); /* Read the dataset back */ - if(H5Dread(dataset, mem_cmpd_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + if (H5Dread(dataset, mem_cmpd_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) FAIL_STACK_ERROR /* Check that the values read are the same as the values written @@ -3878,7 +4143,7 @@ test_nbit_compound_2(hid_t file) * discovered it using clang compiler with -fcatch-undefined-behavior option (see Issue 7674 * in Jira). So I changed it in a funny way as below to avoid it. SLU - 2011/8/11 */ - if(sizeof(unsigned) > 4) + if (sizeof(unsigned) > 4) i_mask = ~((unsigned)~0 << (precision[0] + offset[0])) & ((unsigned)~0 << offset[0]); else { i_mask = 0xffffffff; @@ -3887,34 +4152,39 @@ test_nbit_compound_2(hid_t file) c_mask = ~((unsigned)~0 << (precision[1] + offset[1])) & ((unsigned)~0 << offset[1]); s_mask = ~((unsigned)~0 << (precision[2] + offset[2])) & ((unsigned)~0 << offset[2]); b_mask = ~((unsigned)~0 << (precision[4] + offset[4])) & ((unsigned)~0 << offset[4]); - for(i=0; i<(size_t)size[0]; i++) { - for(j=0; j<(size_t)size[1]; j++) { + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { b_failed = 0; d_failed = 0; - for(m = 0; m < (size_t)array_dims[0]; m++) - for(n = 0; n < (size_t)array_dims[1]; n++) - if(((unsigned)new_data[i][j].b[m][n] & b_mask)!=((unsigned)orig_data[i][j].b[m][n] & b_mask)) { - b_failed = 1; - goto out; - } + for (m = 0; m < (size_t)array_dims[0]; m++) + for (n = 0; n < (size_t)array_dims[1]; n++) + if (((unsigned)new_data[i][j].b[m][n] & b_mask) != + ((unsigned)orig_data[i][j].b[m][n] & b_mask)) { + b_failed = 1; + goto out; + } - for(m = 0; m < (size_t)array_dims[0]; m++) - for(n = 0; n < (size_t)array_dims[1]; n++) - if(((unsigned)new_data[i][j].d[m][n].i & i_mask) != ((unsigned)orig_data[i][j].d[m][n].i & i_mask)|| - ((unsigned)new_data[i][j].d[m][n].c & c_mask) != ((unsigned)orig_data[i][j].d[m][n].c & c_mask)|| - ((unsigned)new_data[i][j].d[m][n].s & s_mask) != ((unsigned)orig_data[i][j].d[m][n].s & s_mask)|| - (!HDisnan(new_data[i][j].d[m][n].f) && !H5_FLT_ABS_EQUAL(new_data[i][j].d[m][n].f, new_data[i][j].d[m][n].f))) { + for (m = 0; m < (size_t)array_dims[0]; m++) + for (n = 0; n < (size_t)array_dims[1]; n++) + if (((unsigned)new_data[i][j].d[m][n].i & i_mask) != + ((unsigned)orig_data[i][j].d[m][n].i & i_mask) || + ((unsigned)new_data[i][j].d[m][n].c & c_mask) != + ((unsigned)orig_data[i][j].d[m][n].c & c_mask) || + ((unsigned)new_data[i][j].d[m][n].s & s_mask) != + ((unsigned)orig_data[i][j].d[m][n].s & s_mask) || + (!HDisnan(new_data[i][j].d[m][n].f) && + !H5_FLT_ABS_EQUAL(new_data[i][j].d[m][n].f, new_data[i][j].d[m][n].f))) { d_failed = 1; goto out; } out: - if(((unsigned)new_data[i][j].a.i & i_mask) != ((unsigned)orig_data[i][j].a.i & i_mask)|| - ((unsigned)new_data[i][j].a.c & c_mask) != ((unsigned)orig_data[i][j].a.c & c_mask)|| - ((unsigned)new_data[i][j].a.s & s_mask) != ((unsigned)orig_data[i][j].a.s & s_mask)|| - (!HDisnan(new_data[i][j].a.f) && !H5_FLT_ABS_EQUAL(new_data[i][j].a.f, new_data[i][j].a.f)) || - new_data[i][j].v != orig_data[i][j].v || b_failed || d_failed) { + if (((unsigned)new_data[i][j].a.i & i_mask) != ((unsigned)orig_data[i][j].a.i & i_mask) || + ((unsigned)new_data[i][j].a.c & c_mask) != ((unsigned)orig_data[i][j].a.c & c_mask) || + ((unsigned)new_data[i][j].a.s & s_mask) != ((unsigned)orig_data[i][j].a.s & s_mask) || + (!HDisnan(new_data[i][j].a.f) && !H5_FLT_ABS_EQUAL(new_data[i][j].a.f, new_data[i][j].a.f)) || + new_data[i][j].v != orig_data[i][j].v || b_failed || d_failed) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); @@ -3927,37 +4197,37 @@ out: * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(i_tid) < 0) + if (H5Tclose(i_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(c_tid) < 0) + if (H5Tclose(c_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(s_tid) < 0) + if (H5Tclose(s_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(f_tid) < 0) + if (H5Tclose(f_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(v_tid) < 0) + if (H5Tclose(v_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(cmpd_tid2) < 0) + if (H5Tclose(cmpd_tid2) < 0) FAIL_STACK_ERROR - if(H5Tclose(cmpd_tid1) < 0) + if (H5Tclose(cmpd_tid1) < 0) FAIL_STACK_ERROR - if(H5Tclose(mem_cmpd_tid2) < 0) + if (H5Tclose(mem_cmpd_tid2) < 0) FAIL_STACK_ERROR - if(H5Tclose(mem_cmpd_tid1) < 0) + if (H5Tclose(mem_cmpd_tid1) < 0) FAIL_STACK_ERROR - if(H5Tclose(array_tid) < 0) + if (H5Tclose(array_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(base_tid) < 0) + if (H5Tclose(base_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(array_cmplx_tid) < 0) + if (H5Tclose(array_cmplx_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(mem_array_cmplx_tid) < 0) + if (H5Tclose(mem_array_cmplx_tid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dc) < 0) + if (H5Pclose(dc) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR PASSED(); @@ -3968,7 +4238,6 @@ error: return FAIL; } /* end test_nbit_compound_2() */ - /*------------------------------------------------------------------------- * Function: test_nbit_compound_3 * @@ -3986,83 +4255,103 @@ error: static herr_t test_nbit_compound_3(hid_t file) { - typedef struct { /* Struct with some no-op type fields */ - int i; /* integer field, NOT a no-op type */ - char str[30]; /* fixed-length string, no-op type */ - char *vl_str; /* varible-length string, no-op type */ - hvl_t v; /* VL datatype field, no-op type */ - hobj_ref_t r; /* Object reference field, no-op type */ - unsigned char o[5]; /* Opaque field, no-op type */ + typedef struct { /* Struct with some no-op type fields */ + int i; /* integer field, NOT a no-op type */ + char str[30]; /* fixed-length string, no-op type */ + char * vl_str; /* varible-length string, no-op type */ + hvl_t v; /* VL datatype field, no-op type */ + hobj_ref_t r; /* Object reference field, no-op type */ + unsigned char o[5]; /* Opaque field, no-op type */ } atomic; - hid_t i_tid, str_tid, vl_str_tid, v_tid, o_tid; - hid_t cmpd_tid; /* atomic compound datatype */ - hid_t dataset, space, dc, obj_ref_dataset = -1; - const hsize_t size[1] = {5}; - const hsize_t chunk_size[1] = {5}; - atomic orig_data[5]; - atomic new_data[5]; - double power; - size_t i, k, j; - + hid_t i_tid, str_tid, vl_str_tid, v_tid, o_tid; + hid_t cmpd_tid; /* atomic compound datatype */ + hid_t dataset, space, dc, obj_ref_dataset = -1; + const hsize_t size[1] = {5}; + const hsize_t chunk_size[1] = {5}; + atomic orig_data[5]; + atomic new_data[5]; + double power; + size_t i, k, j; TESTING(" nbit compound with no-op type (setup)"); /* Define datatypes of members of compound datatype */ - i_tid=H5Tcopy(H5T_NATIVE_INT); - if(H5Tset_precision(i_tid, (size_t)17) < 0) goto error; + i_tid = H5Tcopy(H5T_NATIVE_INT); + if (H5Tset_precision(i_tid, (size_t)17) < 0) + goto error; - str_tid=H5Tcopy(H5T_C_S1); - if(H5Tset_size(str_tid, (size_t)30) < 0) goto error; + str_tid = H5Tcopy(H5T_C_S1); + if (H5Tset_size(str_tid, (size_t)30) < 0) + goto error; vl_str_tid = H5Tcopy(H5T_C_S1); - if(H5Tset_size(vl_str_tid,H5T_VARIABLE) < 0) goto error; + if (H5Tset_size(vl_str_tid, H5T_VARIABLE) < 0) + goto error; - if((v_tid = H5Tvlen_create(H5T_NATIVE_UINT)) < 0) goto error; + if ((v_tid = H5Tvlen_create(H5T_NATIVE_UINT)) < 0) + goto error; - if((o_tid = H5Tcreate(H5T_OPAQUE, (size_t)5)) < 0) goto error; - if(H5Tset_tag(o_tid, "testing opaque field") < 0) goto error; + if ((o_tid = H5Tcreate(H5T_OPAQUE, (size_t)5)) < 0) + goto error; + if (H5Tset_tag(o_tid, "testing opaque field") < 0) + goto error; /* Create a dataset compound datatype and insert some atomic types */ cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(atomic)); - if(H5Tinsert(cmpd_tid, "i", HOFFSET(atomic, i), i_tid) < 0) goto error; - if(H5Tinsert(cmpd_tid, "str", HOFFSET(atomic, str), str_tid) < 0) goto error; - if(H5Tinsert(cmpd_tid, "vl_str", HOFFSET(atomic, vl_str), vl_str_tid) < 0) goto error; - if(H5Tinsert(cmpd_tid, "v", HOFFSET(atomic, v), v_tid) < 0) goto error; - if(H5Tinsert(cmpd_tid, "r", HOFFSET(atomic, r), H5T_STD_REF_OBJ) < 0) goto error; - if(H5Tinsert(cmpd_tid, "o", HOFFSET(atomic, o), o_tid) < 0) goto error; + if (H5Tinsert(cmpd_tid, "i", HOFFSET(atomic, i), i_tid) < 0) + goto error; + if (H5Tinsert(cmpd_tid, "str", HOFFSET(atomic, str), str_tid) < 0) + goto error; + if (H5Tinsert(cmpd_tid, "vl_str", HOFFSET(atomic, vl_str), vl_str_tid) < 0) + goto error; + if (H5Tinsert(cmpd_tid, "v", HOFFSET(atomic, v), v_tid) < 0) + goto error; + if (H5Tinsert(cmpd_tid, "r", HOFFSET(atomic, r), H5T_STD_REF_OBJ) < 0) + goto error; + if (H5Tinsert(cmpd_tid, "o", HOFFSET(atomic, o), o_tid) < 0) + goto error; /* Create the data space */ - if((space = H5Screate_simple(1, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(1, size, NULL)) < 0) + goto error; /* Use nbit filter */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dc, 1, chunk_size) < 0) goto error; - if(H5Pset_nbit(dc) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dc, 1, chunk_size) < 0) + goto error; + if (H5Pset_nbit(dc) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_NBIT_COMPOUND_NAME_3, cmpd_tid, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = + H5Dcreate2(file, DSET_NBIT_COMPOUND_NAME_3, cmpd_tid, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) + goto error; /* Create the dataset object reference points to */ - if((obj_ref_dataset = H5Dcreate2(file, "nbit_obj_ref", H5T_NATIVE_INT, - space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((obj_ref_dataset = H5Dcreate2(file, "nbit_obj_ref", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + goto error; /* Initialize data */ - for(i = 0; i < (size_t)size[0]; i++) { + for (i = 0; i < (size_t)size[0]; i++) { power = HDpow(2.0F, 17.0F - 1.0F); HDmemset(&orig_data[i], 0, sizeof(orig_data[i])); orig_data[i].i = (int)(HDrandom() % (long)power); HDstrcpy(orig_data[i].str, "fixed-length C string"); orig_data[i].vl_str = HDstrdup("variable-length C string"); - orig_data[i].v.p = HDmalloc((size_t)(i+1)*sizeof(unsigned int)); - orig_data[i].v.len = (size_t)i+1; - for(k = 0; k < (i+1); k++) ((unsigned int *)orig_data[i].v.p)[k] = (unsigned int)(i*100 + k); + orig_data[i].v.p = HDmalloc((size_t)(i + 1) * sizeof(unsigned int)); + orig_data[i].v.len = (size_t)i + 1; + for (k = 0; k < (i + 1); k++) + ((unsigned int *)orig_data[i].v.p)[k] = (unsigned int)(i * 100 + k); /* Create reference to the dataset "nbit_obj_ref" */ - if(H5Rcreate(&orig_data[i].r, file, "nbit_obj_ref", H5R_OBJECT, (hid_t)-1) < 0) goto error; + if (H5Rcreate(&orig_data[i].r, file, "nbit_obj_ref", H5R_OBJECT, (hid_t)-1) < 0) + goto error; - for(j = 0; j < 5; j++) orig_data[i].o[j] = (unsigned char)(i + j); + for (j = 0; j < 5; j++) + orig_data[i].o[j] = (unsigned char)(i + j); } PASSED(); @@ -4074,8 +4363,7 @@ test_nbit_compound_3(hid_t file) */ TESTING(" nbit compound with no-op type (write)"); - if(H5Dwrite(dataset, cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, - orig_data) < 0) + if (H5Dwrite(dataset, cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) goto error; PASSED(); @@ -4086,36 +4374,30 @@ test_nbit_compound_3(hid_t file) TESTING(" nbit compound with no-op type (read)"); /* Read the dataset back */ - if(H5Dread(dataset, cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, - new_data) < 0) + if (H5Dread(dataset, cmpd_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) goto error; /* Check that the values read are the same as the values written */ - for(i = 0; i < (size_t)size[0]; i++) { - if(new_data[i].i != orig_data[i].i || - strcmp(new_data[i].str, orig_data[i].str) !=0 || - strcmp(new_data[i].vl_str, orig_data[i].vl_str) !=0 || - new_data[i].v.len != orig_data[i].v.len || - new_data[i].r != orig_data[i].r) - { + for (i = 0; i < (size_t)size[0]; i++) { + if (new_data[i].i != orig_data[i].i || strcmp(new_data[i].str, orig_data[i].str) != 0 || + strcmp(new_data[i].vl_str, orig_data[i].vl_str) != 0 || new_data[i].v.len != orig_data[i].v.len || + new_data[i].r != orig_data[i].r) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu\n", (unsigned long)i); goto error; } - for(k=0; k DSET_DIM1*DSET_DIM2*(precision/8) + 1*KB) { + if ((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1 * DSET_DIM2 * (precision / 8) || + dset_size > DSET_DIM1 * DSET_DIM2 * (precision / 8) + 1 * KB) { H5_FAILED(); - HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n",__LINE__, dset_size); + HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n", __LINE__, dset_size); goto error; } @@ -4330,7 +4621,6 @@ error: return FAIL; } /* end test_nbit_int_size() */ - /*------------------------------------------------------------------------- * Function: test_nbit_flt_size * @@ -4352,8 +4642,8 @@ test_nbit_flt_size(hid_t file) hid_t dataspace, dataset, datatype, dset_create_props; hsize_t dims[2], chunk_size[2]; hsize_t dset_size = 0; - float **orig = NULL; - float *orig_data = NULL; + float **orig = NULL; + float * orig_data = NULL; int i, j; size_t precision, offset; size_t spos, epos, esize, mpos, msize; @@ -4361,180 +4651,177 @@ test_nbit_flt_size(hid_t file) TESTING(" nbit floating-number dataset size"); /* Set up data array */ - if(NULL == (orig_data = (float *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(float)))) + if (NULL == (orig_data = (float *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(float)))) TEST_ERROR; - if(NULL == (orig = (float **)HDcalloc(DSET_DIM1, sizeof(orig_data)))) + if (NULL == (orig = (float **)HDcalloc(DSET_DIM1, sizeof(orig_data)))) TEST_ERROR; for (i = 0; i < DSET_DIM1; i++) orig[i] = orig_data + (i * DSET_DIM2); - /* Define floating-point type for dataset - *------------------------------------------------------------------- - * size=4 byte, precision=16 bits, offset=8 bits, - * mantissa size=9 bits, mantissa position=8, - * exponent size=6 bits, exponent position=17, - * exponent bias=31. - * It can be illustrated in little-endian order as: - * (S - sign bit, E - exponent bit, M - mantissa bit, - * ? - padding bit) - * - * 3 2 1 0 - * ???????? SEEEEEEM MMMMMMMM ???????? - * - * To create a new floating-point type, the following - * properties must be set in the order of - * set fields -> set offset -> set precision -> set size. - * All these properties must be set before the type can function. - * Other properties can be set anytime. Derived type size cannot - * be expanded bigger than original size but can be decreased. - * There should be no holes among the significant bits. Exponent - * bias usually is set 2^(n-1)-1, where n is the exponent size. - *-------------------------------------------------------------------*/ - if((datatype = H5Tcopy(H5T_IEEE_F32LE)) < 0) { - H5_FAILED(); - HDprintf(" line %d: H5Tcopy failed\n",__LINE__); - goto error; - } /* end if */ - - msize = 9; - spos = 23; - epos = 17; - esize = 6; - mpos = 8; - offset = 8; - precision = 16; - - if(H5Tset_fields(datatype, spos, epos, esize, mpos, msize)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Tset_fields failed\n",__LINE__); - goto error; - } /* end if */ - - if(H5Tset_offset(datatype,offset)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Tset_offset failed\n",__LINE__); - goto error; - } /* end if */ - - if(H5Tset_precision(datatype,precision)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Tset_precision failed\n",__LINE__); - goto error; - } /* end if */ - - if(H5Tset_size(datatype, 4)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_size failed\n",__LINE__); - goto error; - } /* end if */ - - /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE)<0) { + /* Define floating-point type for dataset + *------------------------------------------------------------------- + * size=4 byte, precision=16 bits, offset=8 bits, + * mantissa size=9 bits, mantissa position=8, + * exponent size=6 bits, exponent position=17, + * exponent bias=31. + * It can be illustrated in little-endian order as: + * (S - sign bit, E - exponent bit, M - mantissa bit, + * ? - padding bit) + * + * 3 2 1 0 + * ???????? SEEEEEEM MMMMMMMM ???????? + * + * To create a new floating-point type, the following + * properties must be set in the order of + * set fields -> set offset -> set precision -> set size. + * All these properties must be set before the type can function. + * Other properties can be set anytime. Derived type size cannot + * be expanded bigger than original size but can be decreased. + * There should be no holes among the significant bits. Exponent + * bias usually is set 2^(n-1)-1, where n is the exponent size. + *-------------------------------------------------------------------*/ + if ((datatype = H5Tcopy(H5T_IEEE_F32LE)) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Tcopy failed\n", __LINE__); + goto error; + } /* end if */ + + msize = 9; + spos = 23; + epos = 17; + esize = 6; + mpos = 8; + offset = 8; + precision = 16; + + if (H5Tset_fields(datatype, spos, epos, esize, mpos, msize) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Tset_fields failed\n", __LINE__); + goto error; + } /* end if */ + + if (H5Tset_offset(datatype, offset) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Tset_offset failed\n", __LINE__); + goto error; + } /* end if */ + + if (H5Tset_precision(datatype, precision) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Tset_precision failed\n", __LINE__); + goto error; + } /* end if */ + + if (H5Tset_size(datatype, 4) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_size failed\n", __LINE__); + goto error; + } /* end if */ + + /* Set order of dataset datatype */ + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_order failed\n", __LINE__); + goto error; + } /* end if */ + + if (H5Tset_ebias(datatype, 31) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_size failed\n", __LINE__); + goto error; + } /* end if */ + + /* + * Initiliaze data buffer with random data + */ + for (i = 0; i < DSET_DIM1; i++) + for (j = 0; j < DSET_DIM2; j++) + orig[i][j] = (float)(HDrandom() % 1234567) / 2; + + /* Describe the dataspace. */ + dims[0] = DSET_DIM1; + dims[1] = DSET_DIM2; + if ((dataspace = H5Screate_simple(2, dims, NULL)) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Pcreate failed\n", __LINE__); + goto error; + } /* end if */ + + /* + * Set the dataset creation property list to specify the chunks + */ + chunk_size[0] = DSET_DIM1 / 10; + chunk_size[1] = DSET_DIM2 / 10; + if ((dset_create_props = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Pcreate failed\n", __LINE__); + goto error; + } /* end if */ + + if (H5Pset_chunk(dset_create_props, 2, chunk_size) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_chunk failed\n", __LINE__); + goto error; + } /* end if */ + + /* + * Set for n-bit compression + */ + if (H5Pset_nbit(dset_create_props) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_nbit failed\n", __LINE__); + goto error; + } /* end if */ + + /* + * Create a new dataset within the file. + */ + if ((dataset = H5Dcreate2(file, DSET_NBIT_FLT_SIZE_NAME, datatype, dataspace, H5P_DEFAULT, + dset_create_props, H5P_DEFAULT)) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5dwrite failed\n", __LINE__); + goto error; + } /* end if */ + + /* + * Write the array to the file. + */ + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) { + H5_FAILED(); + HDprintf(" Line %d: H5Dwrite failed\n", __LINE__); + goto error; + } /* end if */ + + /* + * Get the precision of the data type + */ + if ((precision = H5Tget_precision(datatype)) == 0) { + H5_FAILED(); + HDprintf(" Line %d: wrong precision size: %zu\n", __LINE__, precision); + goto error; + } /* end if */ + + /* + * The size of the dataset after compression should around 2 * DSET_DIM1 * DSET_DIM2 + */ + if ((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1 * DSET_DIM2 * (precision / 8) || + dset_size > DSET_DIM1 * DSET_DIM2 * (precision / 8) + 1 * KB) { H5_FAILED(); - HDprintf(" line %d: H5Pset_order failed\n",__LINE__); - goto error; - } /* end if */ - - if(H5Tset_ebias(datatype, 31)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_size failed\n",__LINE__); - goto error; - } /* end if */ - - /* - * Initiliaze data buffer with random data - */ - for (i=0; i < DSET_DIM1; i++) - for (j=0; j < DSET_DIM2; j++) - orig[i][j] = (float)(HDrandom() % 1234567) / 2; - - - /* Describe the dataspace. */ - dims[0] = DSET_DIM1; - dims[1] = DSET_DIM2; - if((dataspace = H5Screate_simple (2, dims, NULL))<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pcreate failed\n",__LINE__); - goto error; - } /* end if */ - - /* - * Set the dataset creation property list to specify the chunks - */ - chunk_size[0] = DSET_DIM1/10; - chunk_size[1] = DSET_DIM2/10; - if((dset_create_props = H5Pcreate (H5P_DATASET_CREATE))<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pcreate failed\n",__LINE__); - goto error; - } /* end if */ - - if(H5Pset_chunk (dset_create_props, 2, chunk_size)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_chunk failed\n",__LINE__); - goto error; - } /* end if */ - - /* - * Set for n-bit compression - */ - if(H5Pset_nbit (dset_create_props)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_nbit failed\n",__LINE__); - goto error; - } /* end if */ - - /* - * Create a new dataset within the file. - */ - if((dataset = H5Dcreate2 (file, DSET_NBIT_FLT_SIZE_NAME, datatype, - dataspace, H5P_DEFAULT, - dset_create_props, H5P_DEFAULT))<0) { - H5_FAILED(); - HDprintf(" line %d: H5dwrite failed\n",__LINE__); - goto error; - } /* end if */ - - /* - * Write the array to the file. - */ - if(H5Dwrite (dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, orig_data)<0) { - H5_FAILED(); - HDprintf(" Line %d: H5Dwrite failed\n",__LINE__); - goto error; - } /* end if */ - - /* - * Get the precision of the data type - */ - if((precision = H5Tget_precision(datatype)) == 0) { - H5_FAILED(); - HDprintf(" Line %d: wrong precision size: %zu\n",__LINE__, precision); - goto error; - } /* end if */ - - /* - * The size of the dataset after compression should around 2 * DSET_DIM1 * DSET_DIM2 - */ - if((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1*DSET_DIM2*(precision/8) || - dset_size > DSET_DIM1*DSET_DIM2*(precision/8) + 1*KB) { - H5_FAILED(); - HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n",__LINE__, dset_size); - goto error; - } /* end if */ - - H5Tclose (datatype); - H5Dclose (dataset); - H5Sclose (dataspace); - H5Pclose (dset_create_props); + HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n", __LINE__, dset_size); + goto error; + } /* end if */ + + H5Tclose(datatype); + H5Dclose(dataset); + H5Sclose(dataspace); + H5Pclose(dset_create_props); PASSED(); HDfree(orig); HDfree(orig_data); - return SUCCEED; + return SUCCEED; error: HDfree(orig); HDfree(orig_data); @@ -4560,12 +4847,12 @@ error: static herr_t test_scaleoffset_int(hid_t file) { - hid_t dataset, datatype, space, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2,5}; - int orig_data[2][5]; - int new_data[2][5]; - size_t i, j; + hid_t dataset, datatype, space, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; + int orig_data[2][5]; + int new_data[2][5]; + size_t i, j; HDputs("Testing scaleoffset filter"); TESTING(" scaleoffset int without fill value (setup)"); @@ -4573,34 +4860,41 @@ test_scaleoffset_int(hid_t file) datatype = H5Tcopy(H5T_NATIVE_INT); /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) goto error; + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) + goto error; /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Create the dataset property list */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* Fill value undefined */ - if(H5Pset_fill_value(dc, datatype, NULL) < 0) goto error; + if (H5Pset_fill_value(dc, datatype, NULL) < 0) + goto error; /* Set up to use scaleoffset filter, let library calculate minbits */ - if(H5Pset_chunk(dc, 2, chunk_size) < 0) goto error; - if(H5Pset_scaleoffset(dc, H5Z_SO_INT,H5Z_SO_INT_MINBITS_DEFAULT) < 0) goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_INT_NAME, datatype, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = + H5Dcreate2(file, DSET_SCALEOFFSET_INT_NAME, datatype, space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) + goto error; /* Initialize data */ - for(i= 0;i< (size_t)size[0]; i++) - for(j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j] = HDrandom() % 10000; + for (i = 0; i < (size_t)size[0]; i++) + for (j = 0; j < (size_t)size[1]; j++) { + orig_data[i][j] = HDrandom() % 10000; - /* even-numbered values are negtive */ - if((i*size[1]+j+1)%2 == 0) - orig_data[i][j] = -orig_data[i][j]; - } + /* even-numbered values are negtive */ + if ((i * size[1] + j + 1) % 2 == 0) + orig_data[i][j] = -orig_data[i][j]; + } PASSED(); @@ -4611,8 +4905,8 @@ test_scaleoffset_int(hid_t file) */ TESTING(" scaleoffset int without fill value (write)"); - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - orig_data) < 0) goto error; + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + goto error; PASSED(); /*---------------------------------------------------------------------- @@ -4622,13 +4916,13 @@ test_scaleoffset_int(hid_t file) TESTING(" scaleoffset int without fill value (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - new_data) < 0) goto error; + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + goto error; /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)size[0]; i++) { - for(j=0; j<(size_t)size[1]; j++) { - if(new_data[i][j] != orig_data[i][j]) { + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { + if (new_data[i][j] != orig_data[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); @@ -4641,10 +4935,14 @@ test_scaleoffset_int(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) goto error; - if(H5Pclose(dc) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Tclose(datatype) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -4653,7 +4951,6 @@ error: return FAIL; } /* end test_scaleoffset_int() */ - /*------------------------------------------------------------------------- * Function: test_scaleoffset_int_2 * @@ -4672,62 +4969,74 @@ error: static herr_t test_scaleoffset_int_2(hid_t file) { - hid_t dataset, datatype, space, mspace, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2,5}; - int orig_data[2][5]; - int new_data[2][5]; - hsize_t start[2]; /* Start of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Block count */ - hsize_t block[2]; /* Block sizes */ - int fillval; - size_t j; + hid_t dataset, datatype, space, mspace, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; + int orig_data[2][5]; + int new_data[2][5]; + hsize_t start[2]; /* Start of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Block count */ + hsize_t block[2]; /* Block sizes */ + int fillval; + size_t j; TESTING(" scaleoffset int with fill value (setup)"); datatype = H5Tcopy(H5T_NATIVE_INT); /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) goto error; + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) + goto error; /* Create the data space for the dataset */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Create the dataset property list */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* Set fill value */ fillval = 10000; - if(H5Pset_fill_value(dc, H5T_NATIVE_INT, &fillval) < 0) goto error; + if (H5Pset_fill_value(dc, H5T_NATIVE_INT, &fillval) < 0) + goto error; /* Set up to use scaleoffset filter, let library calculate minbits */ - if(H5Pset_chunk(dc, 2, chunk_size) < 0) goto error; - if(H5Pset_scaleoffset(dc, H5Z_SO_INT,H5Z_SO_INT_MINBITS_DEFAULT) < 0) goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_INT_NAME_2, datatype, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_INT_NAME_2, datatype, space, H5P_DEFAULT, dc, + H5P_DEFAULT)) < 0) + goto error; /* Create the memory data space */ - if((mspace = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((mspace = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Select hyperslab for data to write, using 1x5 blocks, * (1,1) stride and (1,1) count starting at the position (0,0). */ - start[0] = 0; start[1] = 0; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 1; block[1] = 5; - if(H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, - stride, count, block) < 0) goto error; + start[0] = 0; + start[1] = 0; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 5; + if (H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, stride, count, block) < 0) + goto error; /* Initialize data of hyperslab */ - for(j = 0; j < (size_t)size[1]; j++) { + for (j = 0; j < (size_t)size[1]; j++) { orig_data[0][j] = (int)HDrandom() % 10000; /* even-numbered values are negtive */ - if((j+1)%2 == 0) + if ((j + 1) % 2 == 0) orig_data[0][j] = -orig_data[0][j]; } @@ -4741,8 +5050,8 @@ test_scaleoffset_int_2(hid_t file) TESTING(" scaleoffset int with fill value (write)"); /* only data in the hyperslab will be written, other value should be fill value */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mspace, mspace, H5P_DEFAULT, - orig_data) < 0) goto error; + if (H5Dwrite(dataset, H5T_NATIVE_INT, mspace, mspace, H5P_DEFAULT, orig_data) < 0) + goto error; PASSED(); /*---------------------------------------------------------------------- @@ -4752,12 +5061,12 @@ test_scaleoffset_int_2(hid_t file) TESTING(" scaleoffset int with fill value (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_INT, mspace, mspace, H5P_DEFAULT, - new_data) < 0) goto error; + if (H5Dread(dataset, H5T_NATIVE_INT, mspace, mspace, H5P_DEFAULT, new_data) < 0) + goto error; /* Check that the values read are the same as the values written */ - for(j=0; j<(size_t)size[1]; j++) { - if(new_data[0][j] != orig_data[0][j]) { + for (j = 0; j < (size_t)size[1]; j++) { + if (new_data[0][j] != orig_data[0][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); @@ -4769,10 +5078,14 @@ test_scaleoffset_int_2(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) goto error; - if(H5Pclose(dc) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Tclose(datatype) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -4781,7 +5094,6 @@ error: return FAIL; } /* end test_scaleoffset_int_2() */ - /*------------------------------------------------------------------------- * Function: test_scaleoffset_float * @@ -4800,48 +5112,55 @@ error: static herr_t test_scaleoffset_float(hid_t file) { - hid_t dataset, datatype, space, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2,5}; - float orig_data[2][5]; - float new_data[2][5]; - size_t i, j; + hid_t dataset, datatype, space, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; + float orig_data[2][5]; + float new_data[2][5]; + size_t i, j; TESTING(" scaleoffset float without fill value, D-scaling (setup)"); datatype = H5Tcopy(H5T_NATIVE_FLOAT); /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) goto error; + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) + goto error; /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Create the dataset property list */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* Fill value undefined */ - if(H5Pset_fill_value(dc, datatype, NULL) < 0) goto error; + if (H5Pset_fill_value(dc, datatype, NULL) < 0) + goto error; /* Set up to use scaleoffset filter, decimal scale factor is 3, * use variable-minimum-bits method */ - if(H5Pset_chunk(dc, 2, chunk_size) < 0) goto error; - if(H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE,3) < 0) goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE, 3) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_FLOAT_NAME, datatype, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_FLOAT_NAME, datatype, space, H5P_DEFAULT, dc, + H5P_DEFAULT)) < 0) + goto error; /* Initialize data */ - for(i= 0;i< (size_t)size[0]; i++) - for(j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j] = (float)(HDrandom() % 100000) / 1000.0F; + for (i = 0; i < (size_t)size[0]; i++) + for (j = 0; j < (size_t)size[1]; j++) { + orig_data[i][j] = (float)(HDrandom() % 100000) / 1000.0F; - /* even-numbered values are negtive */ - if((i*size[1]+j+1)%2 == 0) - orig_data[i][j] = -orig_data[i][j]; - } + /* even-numbered values are negtive */ + if ((i * size[1] + j + 1) % 2 == 0) + orig_data[i][j] = -orig_data[i][j]; + } PASSED(); @@ -4852,8 +5171,8 @@ test_scaleoffset_float(hid_t file) */ TESTING(" scaleoffset float without fill value, D-scaling (write)"); - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - orig_data) < 0) goto error; + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + goto error; PASSED(); /*---------------------------------------------------------------------- @@ -4863,13 +5182,13 @@ test_scaleoffset_float(hid_t file) TESTING(" scaleoffset float without fill value, D-scaling (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - new_data) < 0) goto error; + if (H5Dread(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + goto error; /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)size[0]; i++) { - for(j=0; j<(size_t)size[1]; j++) { - if(HDfabs(new_data[i][j]-orig_data[i][j]) > HDpow(10.0F, -3.0F)) { + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { + if (HDfabs(new_data[i][j] - orig_data[i][j]) > HDpow(10.0F, -3.0F)) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); @@ -4882,10 +5201,14 @@ test_scaleoffset_float(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) goto error; - if(H5Pclose(dc) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Tclose(datatype) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -4894,7 +5217,6 @@ error: return FAIL; } /* end test_scaleoffset_float() */ - /*------------------------------------------------------------------------- * Function: test_scaleoffset_float_2 * @@ -4913,64 +5235,76 @@ error: static herr_t test_scaleoffset_float_2(hid_t file) { - hid_t dataset, datatype, space, mspace, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2,5}; - float orig_data[2][5]; - float new_data[2][5]; - float fillval; - hsize_t start[2]; /* Start of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Block count */ - hsize_t block[2]; /* Block sizes */ - size_t j; + hid_t dataset, datatype, space, mspace, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; + float orig_data[2][5]; + float new_data[2][5]; + float fillval; + hsize_t start[2]; /* Start of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Block count */ + hsize_t block[2]; /* Block sizes */ + size_t j; TESTING(" scaleoffset float with fill value, D-scaling (setup)"); datatype = H5Tcopy(H5T_NATIVE_FLOAT); /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) goto error; + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) + goto error; /* Create the data space for the dataset */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Create the dataset property list */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* Set fill value */ fillval = 10000.0F; - if(H5Pset_fill_value(dc, H5T_NATIVE_FLOAT, &fillval) < 0) goto error; + if (H5Pset_fill_value(dc, H5T_NATIVE_FLOAT, &fillval) < 0) + goto error; /* Set up to use scaleoffset filter, decimal scale factor is 3, * use variable-minimum-bits method */ - if(H5Pset_chunk(dc, 2, chunk_size) < 0) goto error; - if(H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE,3) < 0) goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE, 3) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_FLOAT_NAME_2, datatype, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_FLOAT_NAME_2, datatype, space, H5P_DEFAULT, dc, + H5P_DEFAULT)) < 0) + goto error; /* Create the memory data space */ - if((mspace = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((mspace = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Select hyperslab for data to write, using 1x5 blocks, * (1,1) stride and (1,1) count starting at the position (0,0). */ - start[0] = 0; start[1] = 0; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 1; block[1] = 5; - if(H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, - stride, count, block) < 0) goto error; + start[0] = 0; + start[1] = 0; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 5; + if (H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, stride, count, block) < 0) + goto error; /* Initialize data of hyperslab */ - for(j = 0; j < (size_t)size[1]; j++) { + for (j = 0; j < (size_t)size[1]; j++) { orig_data[0][j] = (float)(HDrandom() % 100000) / 1000.0F; /* even-numbered values are negtive */ - if((j + 1) % 2 == 0) + if ((j + 1) % 2 == 0) orig_data[0][j] = -orig_data[0][j]; } @@ -4984,8 +5318,8 @@ test_scaleoffset_float_2(hid_t file) TESTING(" scaleoffset float with fill value, D-scaling (write)"); /* only data in the hyperslab will be written, other value should be fill value */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, mspace, mspace, H5P_DEFAULT, - orig_data) < 0) goto error; + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, mspace, mspace, H5P_DEFAULT, orig_data) < 0) + goto error; PASSED(); /*---------------------------------------------------------------------- @@ -4995,12 +5329,12 @@ test_scaleoffset_float_2(hid_t file) TESTING(" scaleoffset float with fill value, D-scaling (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_FLOAT, mspace, mspace, H5P_DEFAULT, - new_data) < 0) goto error; + if (H5Dread(dataset, H5T_NATIVE_FLOAT, mspace, mspace, H5P_DEFAULT, new_data) < 0) + goto error; /* Check that the values read are the same as the values written */ - for(j=0; j<(size_t)size[1]; j++) { - if(HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10.0F, -3.0F)) { + for (j = 0; j < (size_t)size[1]; j++) { + if (HDfabs(new_data[0][j] - orig_data[0][j]) > HDpow(10.0F, -3.0F)) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); @@ -5011,10 +5345,14 @@ test_scaleoffset_float_2(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) goto error; - if(H5Pclose(dc) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Tclose(datatype) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -5023,7 +5361,6 @@ error: return FAIL; } /* end test_scaleoffset_float_2() */ - /*------------------------------------------------------------------------- * Function: test_scaleoffset_double * @@ -5042,48 +5379,55 @@ error: static herr_t test_scaleoffset_double(hid_t file) { - hid_t dataset, datatype, space, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2,5}; - double orig_data[2][5]; - double new_data[2][5]; - size_t i, j; + hid_t dataset, datatype, space, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; + double orig_data[2][5]; + double new_data[2][5]; + size_t i, j; TESTING(" scaleoffset double without fill value, D-scaling (setup)"); datatype = H5Tcopy(H5T_NATIVE_DOUBLE); /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) goto error; + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) + goto error; /* Create the data space */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Create the dataset property list */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* Fill value undefined */ - if(H5Pset_fill_value(dc, datatype, NULL) < 0) goto error; + if (H5Pset_fill_value(dc, datatype, NULL) < 0) + goto error; /* Set up to use scaleoffset filter, decimal scale factor is 7, * use variable-minimum-bits method */ - if(H5Pset_chunk(dc, 2, chunk_size) < 0) goto error; - if(H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE,7) < 0) goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE, 7) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_DOUBLE_NAME, datatype, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_DOUBLE_NAME, datatype, space, H5P_DEFAULT, dc, + H5P_DEFAULT)) < 0) + goto error; /* Initialize data */ - for(i= 0;i< (size_t)size[0]; i++) - for(j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j] = (float)(HDrandom() % 10000000) / 10000000.0F; + for (i = 0; i < (size_t)size[0]; i++) + for (j = 0; j < (size_t)size[1]; j++) { + orig_data[i][j] = (float)(HDrandom() % 10000000) / 10000000.0F; - /* even-numbered values are negtive */ - if((i* size[1] + j + 1) % 2 == 0) - orig_data[i][j] = -orig_data[i][j]; - } + /* even-numbered values are negtive */ + if ((i * size[1] + j + 1) % 2 == 0) + orig_data[i][j] = -orig_data[i][j]; + } PASSED(); @@ -5094,8 +5438,8 @@ test_scaleoffset_double(hid_t file) */ TESTING(" scaleoffset double without fill value, D-scaling (write)"); - if(H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - orig_data) < 0) goto error; + if (H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) + goto error; PASSED(); /*---------------------------------------------------------------------- @@ -5105,13 +5449,13 @@ test_scaleoffset_double(hid_t file) TESTING(" scaleoffset double without fill value, D-scaling (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - new_data) < 0) goto error; + if (H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) + goto error; /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)size[0]; i++) { - for(j=0; j<(size_t)size[1]; j++) { - if(HDfabs(new_data[i][j]-orig_data[i][j]) > HDpow(10.0F, -7.0F)) { + for (i = 0; i < (size_t)size[0]; i++) { + for (j = 0; j < (size_t)size[1]; j++) { + if (HDfabs(new_data[i][j] - orig_data[i][j]) > HDpow(10.0F, -7.0F)) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); @@ -5124,10 +5468,14 @@ test_scaleoffset_double(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) goto error; - if(H5Pclose(dc) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Tclose(datatype) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -5136,7 +5484,6 @@ error: return FAIL; } /* end test_scaleoffset_double() */ - /*------------------------------------------------------------------------- * Function: test_scaleoffset_double_2 * @@ -5155,64 +5502,76 @@ error: static herr_t test_scaleoffset_double_2(hid_t file) { - hid_t dataset, datatype, space, mspace, dc; - const hsize_t size[2] = {2, 5}; - const hsize_t chunk_size[2] = {2,5}; - double orig_data[2][5]; - double new_data[2][5]; - double fillval; - hsize_t start[2]; /* Start of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Block count */ - hsize_t block[2]; /* Block sizes */ - size_t j; + hid_t dataset, datatype, space, mspace, dc; + const hsize_t size[2] = {2, 5}; + const hsize_t chunk_size[2] = {2, 5}; + double orig_data[2][5]; + double new_data[2][5]; + double fillval; + hsize_t start[2]; /* Start of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Block count */ + hsize_t block[2]; /* Block sizes */ + size_t j; TESTING(" scaleoffset double with fill value, D-scaling (setup)"); datatype = H5Tcopy(H5T_NATIVE_DOUBLE); /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) goto error; + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) + goto error; /* Create the data space for the dataset */ - if((space = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((space = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Create the dataset property list */ - if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* Set fill value */ fillval = 10000.0F; - if(H5Pset_fill_value(dc, H5T_NATIVE_DOUBLE, &fillval) < 0) goto error; + if (H5Pset_fill_value(dc, H5T_NATIVE_DOUBLE, &fillval) < 0) + goto error; /* Set up to use scaleoffset filter, decimal scale factor is 7, * use variable-minimum-bits method */ - if(H5Pset_chunk(dc, 2, chunk_size) < 0) goto error; - if(H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE,7) < 0) goto error; + if (H5Pset_chunk(dc, 2, chunk_size) < 0) + goto error; + if (H5Pset_scaleoffset(dc, H5Z_SO_FLOAT_DSCALE, 7) < 0) + goto error; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_DOUBLE_NAME_2, datatype, - space, H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate2(file, DSET_SCALEOFFSET_DOUBLE_NAME_2, datatype, space, H5P_DEFAULT, dc, + H5P_DEFAULT)) < 0) + goto error; /* Create the memory data space */ - if((mspace = H5Screate_simple(2, size, NULL)) < 0) goto error; + if ((mspace = H5Screate_simple(2, size, NULL)) < 0) + goto error; /* Select hyperslab for data to write, using 1x5 blocks, * (1,1) stride and (1,1) count starting at the position (0,0). */ - start[0] = 0; start[1] = 0; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 1; block[1] = 5; - if(H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, - stride, count, block) < 0) goto error; + start[0] = 0; + start[1] = 0; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 5; + if (H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, stride, count, block) < 0) + goto error; /* Initialize data of hyperslab */ - for(j = 0; j < (size_t)size[1]; j++) { + for (j = 0; j < (size_t)size[1]; j++) { orig_data[0][j] = (float)(HDrandom() % 10000000) / 10000000.0F; /* even-numbered values are negtive */ - if((j + 1) % 2 == 0) + if ((j + 1) % 2 == 0) orig_data[0][j] = -orig_data[0][j]; } @@ -5226,8 +5585,8 @@ test_scaleoffset_double_2(hid_t file) TESTING(" scaleoffset double with fill value, D-scaling (write)"); /* only data in the hyperslab will be written, other value should be fill value */ - if(H5Dwrite(dataset, H5T_NATIVE_DOUBLE, mspace, mspace, H5P_DEFAULT, - orig_data) < 0) goto error; + if (H5Dwrite(dataset, H5T_NATIVE_DOUBLE, mspace, mspace, H5P_DEFAULT, orig_data) < 0) + goto error; PASSED(); /*---------------------------------------------------------------------- @@ -5237,12 +5596,12 @@ test_scaleoffset_double_2(hid_t file) TESTING(" scaleoffset double with fill value, D-scaling (read)"); /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_DOUBLE, mspace, mspace, H5P_DEFAULT, - new_data) < 0) goto error; + if (H5Dread(dataset, H5T_NATIVE_DOUBLE, mspace, mspace, H5P_DEFAULT, new_data) < 0) + goto error; /* Check that the values read are the same as the values written */ - for(j=0; j<(size_t)size[1]; j++) { - if(HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10.0F, -7.0F)) { + for (j = 0; j < (size_t)size[1]; j++) { + if (HDfabs(new_data[0][j] - orig_data[0][j]) > HDpow(10.0F, -7.0F)) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); @@ -5254,10 +5613,14 @@ test_scaleoffset_double_2(hid_t file) * Cleanup *---------------------------------------------------------------------- */ - if(H5Tclose(datatype) < 0) goto error; - if(H5Pclose(dc) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if (H5Tclose(datatype) < 0) + goto error; + if (H5Pclose(dc) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; PASSED(); @@ -5266,7 +5629,6 @@ error: return FAIL; } /* end test_scaleoffset_double_2() */ - /*------------------------------------------------------------------------- * Function: test_multiopen * @@ -5285,55 +5647,69 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_multiopen (hid_t file) +test_multiopen(hid_t file) { - hid_t dcpl = -1, space = -1, dset1 = -1, dset2 = -1; - hsize_t cur_size[1] = {10}; - hsize_t tmp_size[1]; + hid_t dcpl = -1, space = -1, dset1 = -1, dset2 = -1; + hsize_t cur_size[1] = {10}; + hsize_t tmp_size[1]; static hsize_t max_size[1] = {H5S_UNLIMITED}; TESTING("multi-open with extending"); /* Create the dataset and open it twice */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 1, cur_size) < 0) goto error; - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) goto error; - if((dset1 = H5Dcreate2(file, "multiopen", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((dset2 = H5Dopen2(dset1, ".", H5P_DEFAULT)) < 0) goto error; - if(H5Sclose(space) < 0) goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dcpl, 1, cur_size) < 0) + goto error; + if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) + goto error; + if ((dset1 = H5Dcreate2(file, "multiopen", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if ((dset2 = H5Dopen2(dset1, ".", H5P_DEFAULT)) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; /* Extend with the first handle */ cur_size[0] = 20; - if(H5Dset_extent(dset1, cur_size) < 0) goto error; + if (H5Dset_extent(dset1, cur_size) < 0) + goto error; /* Get the size from the second handle */ - if((space = H5Dget_space(dset2)) < 0) goto error; - if(H5Sget_simple_extent_dims(space, tmp_size, NULL) < 0) goto error; - if(cur_size[0] != tmp_size[0]) { + if ((space = H5Dget_space(dset2)) < 0) + goto error; + if (H5Sget_simple_extent_dims(space, tmp_size, NULL) < 0) + goto error; + if (cur_size[0] != tmp_size[0]) { H5_FAILED(); HDprintf(" Got %d instead of %d!\n", (int)tmp_size[0], (int)cur_size[0]); goto error; } /* end if */ - if(H5Dclose(dset1) < 0) goto error; - if(H5Dclose(dset2) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset1) < 0) + goto error; + if (H5Dclose(dset2) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; PASSED(); return SUCCEED; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Dclose(dset1); H5Dclose(dset2); H5Sclose(space); H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_multiopen() */ - /*------------------------------------------------------------------------- * Function: test_types * @@ -5351,96 +5727,109 @@ test_multiopen (hid_t file) static herr_t test_types(hid_t file) { - hid_t grp=-1, type=-1, space=-1, dset=-1; + hid_t grp = -1, type = -1, space = -1, dset = -1; size_t i; - hsize_t nelmts; - unsigned char buf[32]; + hsize_t nelmts; + unsigned char buf[32]; TESTING("various datatypes"); - if((grp = H5Gcreate2(file, "typetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((grp = H5Gcreate2(file, "typetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* bitfield_1 */ nelmts = sizeof(buf); - if((type=H5Tcopy(H5T_STD_B8LE)) < 0 || - (space=H5Screate_simple(1, &nelmts, NULL)) < 0 || - (dset=H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - for(i=0; i=0) { + } + H5E_END_TRY; + if (dsid >= 0) { H5_FAILED(); - HDprintf(" Line %d: Shouldn't have created dataset!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have created dataset!\n", __LINE__); H5Dclose(dsid); goto error; } /* end if */ /* (Should fail because the 'can apply' function should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dsid = H5Dcreate2(file, DSET_CAN_APPLY_NAME, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dsid >=0) { + } + H5E_END_TRY; + if (dsid >= 0) { H5_FAILED(); - HDprintf(" Line %d: Shouldn't have created dataset!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have created dataset!\n", __LINE__); H5Dclose(dsid); goto error; } /* end if */ /* Create new dataset */ - if((dsid = H5Dcreate2(file, DSET_CAN_APPLY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((dsid = H5Dcreate2(file, DSET_CAN_APPLY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) { H5_FAILED(); - HDprintf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n", __LINE__); goto error; } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { + if (H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n", __LINE__); goto error; } /* end if */ /* Flush the file (to clear the cache) */ - if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) { + if (H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error flushing file\n",__LINE__); + HDprintf(" Line %d: Error flushing file\n", __LINE__); goto error; } /* end if */ /* Query the dataset's size on disk */ - if((dset_size=H5Dget_storage_size(dsid))==0) { + if ((dset_size = H5Dget_storage_size(dsid)) == 0) { H5_FAILED(); - HDprintf(" Line %d: Error querying dataset size\n",__LINE__); + HDprintf(" Line %d: Error querying dataset size\n", __LINE__); goto error; } /* end if */ /* Verify that the size indicates data is uncompressed */ - if((H5Tget_size(H5T_NATIVE_INT)*dims[0]*dims[1])!=dset_size) { + if ((H5Tget_size(H5T_NATIVE_INT) * dims[0] * dims[1]) != dset_size) { H5_FAILED(); - HDprintf(" Line %d: Incorrect dataset size: %lu\n",__LINE__,(unsigned long)dset_size); + HDprintf(" Line %d: Incorrect dataset size: %lu\n", __LINE__, (unsigned long)dset_size); goto error; } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { + if (H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error reading dataset data\n",__LINE__); + HDprintf(" Line %d: Error reading dataset data\n", __LINE__); goto error; } /* end if */ /* Compare data */ /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)dims[0]; i++) { - for(j=0; j<(size_t)dims[1]; j++) { - if(points[i][j] != check[i][j]) { - H5_FAILED(); - HDprintf(" Line %d: Read different values than written.\n",__LINE__); - HDprintf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); - HDprintf(" At original: %d\n",points[i][j]); - HDprintf(" At returned: %d\n",check[i][j]); - goto error; - } /* end if */ - } /* end for */ - } /* end for */ + for (i = 0; i < (size_t)dims[0]; i++) { + for (j = 0; j < (size_t)dims[1]; j++) { + if (points[i][j] != check[i][j]) { + H5_FAILED(); + HDprintf(" Line %d: Read different values than written.\n", __LINE__); + HDprintf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); + HDprintf(" At original: %d\n", points[i][j]); + HDprintf(" At returned: %d\n", check[i][j]); + goto error; + } /* end if */ + } /* end for */ + } /* end for */ /* Close dataset */ - if(H5Dclose(dsid) < 0) { + if (H5Dclose(dsid) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n", __LINE__); goto error; } /* end if */ /* Close dataspace */ - if(H5Sclose(sid) < 0) { + if (H5Sclose(sid) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dataspace\n",__LINE__); + HDprintf(" Line %d: Can't close dataspace\n", __LINE__); goto error; } /* end if */ /* Close dataset creation property list */ - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dcpl\n",__LINE__); + HDprintf(" Line %d: Can't close dcpl\n", __LINE__); goto error; } /* end if */ - PASSED(); return SUCCEED; @@ -5612,16 +6005,13 @@ error: /* This message derives from H5Z */ const H5Z_class2_t H5Z_CAN_APPLY_TEST2[1] = {{ - H5Z_CLASS_T_VERS, - H5Z_FILTER_CAN_APPLY_TEST2, /* Filter id number */ - 1, 1, - "can_apply_test", /* Filter name for debugging */ - can_apply_bogus, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_bogus3, /* The actual filter function */ + H5Z_CLASS_T_VERS, H5Z_FILTER_CAN_APPLY_TEST2, /* Filter id number */ + 1, 1, "can_apply_test", /* Filter name for debugging */ + can_apply_bogus, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_bogus3, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: test_can_apply2 * @@ -5643,125 +6033,125 @@ const H5Z_class2_t H5Z_CAN_APPLY_TEST2[1] = {{ static herr_t test_can_apply2(hid_t file) { - hid_t dsid; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataspace creation property list ID */ - const hsize_t dims[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ - const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ - hsize_t dset_size; /* Dataset size */ - size_t i,j; /* Local index variables */ + hid_t dsid; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataspace creation property list ID */ + const hsize_t dims[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ + const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ + hsize_t dset_size; /* Dataset size */ + size_t i, j; /* Local index variables */ TESTING("dataset filter 'can apply' callback second"); /* Create dcpl with special filter */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't create dcpl\n",__LINE__); + HDprintf(" Line %d: Can't create dcpl\n", __LINE__); goto error; } /* end if */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); + HDprintf(" Line %d: Can't set chunk sizes\n", __LINE__); goto error; } /* end if */ - if(H5Zregister (H5Z_CAN_APPLY_TEST2) < 0) { + if (H5Zregister(H5Z_CAN_APPLY_TEST2) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't register 'can apply' filter\n",__LINE__); + HDprintf(" Line %d: Can't register 'can apply' filter\n", __LINE__); goto error; } /* The filter is optional. */ - if(H5Pset_filter(dcpl, H5Z_FILTER_CAN_APPLY_TEST2, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) { + if (H5Pset_filter(dcpl, H5Z_FILTER_CAN_APPLY_TEST2, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't set bogus filter\n",__LINE__); + HDprintf(" Line %d: Can't set bogus filter\n", __LINE__); goto error; } /* Create the data space */ - if((sid = H5Screate_simple(2, dims, NULL)) < 0) { + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't open dataspace\n",__LINE__); + HDprintf(" Line %d: Can't open dataspace\n", __LINE__); goto error; } /* end if */ /* Create new dataset */ - if((dsid = H5Dcreate2(file, DSET_CAN_APPLY_NAME2, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((dsid = H5Dcreate2(file, DSET_CAN_APPLY_NAME2, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n", __LINE__); goto error; } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { + if (H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n", __LINE__); goto error; } /* end if */ /* Flush the file (to clear the cache) */ - if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) { + if (H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error flushing file\n",__LINE__); + HDprintf(" Line %d: Error flushing file\n", __LINE__); goto error; } /* end if */ /* Query the dataset's size on disk */ - if((dset_size=H5Dget_storage_size(dsid))==0) { + if ((dset_size = H5Dget_storage_size(dsid)) == 0) { H5_FAILED(); - HDprintf(" Line %d: Error querying dataset size\n",__LINE__); + HDprintf(" Line %d: Error querying dataset size\n", __LINE__); goto error; } /* end if */ /* Verify that the size indicates data is uncompressed */ - if((H5Tget_size(H5T_NATIVE_DOUBLE)*dims[0]*dims[1])!=dset_size) { + if ((H5Tget_size(H5T_NATIVE_DOUBLE) * dims[0] * dims[1]) != dset_size) { H5_FAILED(); - HDprintf(" Line %d: Incorrect dataset size: %lu\n",__LINE__,(unsigned long)dset_size); + HDprintf(" Line %d: Incorrect dataset size: %lu\n", __LINE__, (unsigned long)dset_size); goto error; } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { + if (H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error reading dataset data\n",__LINE__); + HDprintf(" Line %d: Error reading dataset data\n", __LINE__); goto error; } /* end if */ /* Compare data */ /* Check that the values read are the same as the values written */ - for(i=0; i<(size_t)dims[0]; i++) { - for(j=0; j<(size_t)dims[1]; j++) { - if(points[i][j] != check[i][j]) { - H5_FAILED(); - HDprintf(" Line %d: Read different values than written.\n",__LINE__); - HDprintf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); - HDprintf(" At original: %d\n",points[i][j]); - HDprintf(" At returned: %d\n",check[i][j]); - goto error; - } /* end if */ - } /* end for */ - } /* end for */ + for (i = 0; i < (size_t)dims[0]; i++) { + for (j = 0; j < (size_t)dims[1]; j++) { + if (points[i][j] != check[i][j]) { + H5_FAILED(); + HDprintf(" Line %d: Read different values than written.\n", __LINE__); + HDprintf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); + HDprintf(" At original: %d\n", points[i][j]); + HDprintf(" At returned: %d\n", check[i][j]); + goto error; + } /* end if */ + } /* end for */ + } /* end for */ /* Close dataset */ - if(H5Dclose(dsid) < 0) { + if (H5Dclose(dsid) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n", __LINE__); goto error; } /* end if */ /* Close dataspace */ - if(H5Sclose(sid) < 0) { + if (H5Sclose(sid) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dataspace\n",__LINE__); + HDprintf(" Line %d: Can't close dataspace\n", __LINE__); goto error; } /* end if */ /* Close dataset creation property list */ - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dcpl\n",__LINE__); + HDprintf(" Line %d: Can't close dcpl\n", __LINE__); goto error; } /* end if */ - PASSED(); return SUCCEED; @@ -5769,8 +6159,6 @@ error: return FAIL; } /* end test_can_apply2() */ - - /*------------------------------------------------------------------------- * Function: test_can_apply_szip * @@ -5788,170 +6176,180 @@ error: static herr_t test_can_apply_szip(hid_t #ifndef H5_HAVE_FILTER_SZIP -H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_FILTER_SZIP */ -file) + file) { #ifdef H5_HAVE_FILTER_SZIP - hid_t dsid; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataspace creation property list ID */ - unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block; - const hsize_t dims[2] = {500, 4096}; /* Dataspace dimensions */ - const hsize_t dims2[2] = {4, 2}; /* Dataspace dimensions */ - const hsize_t chunk_dims[2] = {250, 2048}; /* Chunk dimensions */ + hid_t dsid; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataspace creation property list ID */ + unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block; + const hsize_t dims[2] = {500, 4096}; /* Dataspace dimensions */ + const hsize_t dims2[2] = {4, 2}; /* Dataspace dimensions */ + const hsize_t chunk_dims[2] = {250, 2048}; /* Chunk dimensions */ const hsize_t chunk_dims2[2] = {2, 1}; /* Chunk dimensions */ - herr_t ret; /* Status value */ -#endif /* H5_HAVE_FILTER_SZIP */ + herr_t ret; /* Status value */ +#endif /* H5_HAVE_FILTER_SZIP */ TESTING("dataset szip filter 'can apply' callback"); #ifdef H5_HAVE_FILTER_SZIP - if(h5_szip_can_encode() == 1) { - /* Create the data space */ - if((sid = H5Screate_simple(2, dims, NULL)) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't open dataspace\n",__LINE__); - goto error; - } /* end if */ - - /* Create dcpl with special filter */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't create dcpl\n",__LINE__); - goto error; - } /* end if */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); - goto error; - } /* end if */ + if (h5_szip_can_encode() == 1) { + /* Create the data space */ + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't open dataspace\n", __LINE__); + goto error; + } /* end if */ - /* Set (invalid at property set time) szip parameters */ - szip_pixels_per_block=3; - H5E_BEGIN_TRY { - ret=H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block); - } H5E_END_TRY; - if(ret>=0) { - H5_FAILED(); - HDprintf(" Line %d: Shouldn't be able to set szip filter\n",__LINE__); - goto error; - } + /* Create dcpl with special filter */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't create dcpl\n", __LINE__); + goto error; + } /* end if */ + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't set chunk sizes\n", __LINE__); + goto error; + } /* end if */ - /* Set (invalid at property set time) szip parameters */ - szip_pixels_per_block=512; - H5E_BEGIN_TRY { - ret=H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block); - } H5E_END_TRY; - if(ret>=0) { - H5_FAILED(); - HDprintf(" Line %d: Shouldn't be able to set szip filter\n",__LINE__); - goto error; - } + /* Set (invalid at property set time) szip parameters */ + szip_pixels_per_block = 3; + H5E_BEGIN_TRY + { + ret = H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block); + } + H5E_END_TRY; + if (ret >= 0) { + H5_FAILED(); + HDprintf(" Line %d: Shouldn't be able to set szip filter\n", __LINE__); + goto error; + } - /* Set (invalid at dataset creation time) szip parameters */ - szip_pixels_per_block=2; - if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't set szip filter\n",__LINE__); - goto error; - } + /* Set (invalid at property set time) szip parameters */ + szip_pixels_per_block = 512; + H5E_BEGIN_TRY + { + ret = H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block); + } + H5E_END_TRY; + if (ret >= 0) { + H5_FAILED(); + HDprintf(" Line %d: Shouldn't be able to set szip filter\n", __LINE__); + goto error; + } - /* Create new dataset */ - /* (Should succeed; according to the new algorithm, scanline should be reset - to 2*128 satisfying 'maximum blocks per scanline' condition) */ - H5E_BEGIN_TRY { - dsid = H5Dcreate2(file, DSET_CAN_APPLY_SZIP_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dsid <=0) { - H5_FAILED(); - HDprintf(" Line %d: Should have created dataset!\n",__LINE__); - goto error; - } /* end if */ + /* Set (invalid at dataset creation time) szip parameters */ + szip_pixels_per_block = 2; + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't set szip filter\n", __LINE__); + goto error; + } - /* Close dataset */ - if(H5Dclose(dsid) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't close dataset\n",__LINE__); - goto error; - } /* end if */ + /* Create new dataset */ + /* (Should succeed; according to the new algorithm, scanline should be reset + to 2*128 satisfying 'maximum blocks per scanline' condition) */ + H5E_BEGIN_TRY + { + dsid = H5Dcreate2(file, DSET_CAN_APPLY_SZIP_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT); + } + H5E_END_TRY; + if (dsid <= 0) { + H5_FAILED(); + HDprintf(" Line %d: Should have created dataset!\n", __LINE__); + goto error; + } /* end if */ - /* Close dataspace */ - if(H5Sclose(sid) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't close dataspace\n",__LINE__); - goto error; - } /* end if */ + /* Close dataset */ + if (H5Dclose(dsid) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't close dataset\n", __LINE__); + goto error; + } /* end if */ - /* Close dataset creation property list */ - if(H5Pclose(dcpl) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't close dcpl\n",__LINE__); - goto error; - } /* end if */ + /* Close dataspace */ + if (H5Sclose(sid) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't close dataspace\n", __LINE__); + goto error; + } /* end if */ - /* Create another data space */ - if((sid = H5Screate_simple(2, dims2, NULL)) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't open dataspace\n",__LINE__); - goto error; - } /* end if */ + /* Close dataset creation property list */ + if (H5Pclose(dcpl) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't close dcpl\n", __LINE__); + goto error; + } /* end if */ - /* Create dcpl with special filter */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't create dcpl\n",__LINE__); - goto error; - } /* end if */ - if(H5Pset_chunk(dcpl, 2, chunk_dims2) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); - goto error; - } /* end if */ + /* Create another data space */ + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't open dataspace\n", __LINE__); + goto error; + } /* end if */ - /* Set (invalid at dataset creation time) szip parameters */ - szip_pixels_per_block=32; - if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't set szip filter\n",__LINE__); - goto error; - } + /* Create dcpl with special filter */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't create dcpl\n", __LINE__); + goto error; + } /* end if */ + if (H5Pset_chunk(dcpl, 2, chunk_dims2) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't set chunk sizes\n", __LINE__); + goto error; + } /* end if */ - /* Create new dataset */ - /* (Should fail because the 'can apply' filter should indicate inappropriate combination) */ - H5E_BEGIN_TRY { - dsid = H5Dcreate2(file, DSET_CAN_APPLY_SZIP_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dsid >=0) { - H5_FAILED(); - HDprintf(" Line %d: Shouldn't have created dataset!\n",__LINE__); - H5Dclose(dsid); - goto error; - } /* end if */ + /* Set (invalid at dataset creation time) szip parameters */ + szip_pixels_per_block = 32; + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't set szip filter\n", __LINE__); + goto error; + } - /* Close dataspace */ - if(H5Sclose(sid) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't close dataspace\n",__LINE__); - goto error; - } /* end if */ + /* Create new dataset */ + /* (Should fail because the 'can apply' filter should indicate inappropriate combination) */ + H5E_BEGIN_TRY + { + dsid = H5Dcreate2(file, DSET_CAN_APPLY_SZIP_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT); + } + H5E_END_TRY; + if (dsid >= 0) { + H5_FAILED(); + HDprintf(" Line %d: Shouldn't have created dataset!\n", __LINE__); + H5Dclose(dsid); + goto error; + } /* end if */ - /* Close dataset creation property list */ - if(H5Pclose(dcpl) < 0) { - H5_FAILED(); - HDprintf(" Line %d: Can't close dcpl\n",__LINE__); - goto error; - } /* end if */ + /* Close dataspace */ + if (H5Sclose(sid) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't close dataspace\n", __LINE__); + goto error; + } /* end if */ + /* Close dataset creation property list */ + if (H5Pclose(dcpl) < 0) { + H5_FAILED(); + HDprintf(" Line %d: Can't close dcpl\n", __LINE__); + goto error; + } /* end if */ - PASSED(); -} else { - SKIPPED(); - HDputs(" Szip encoding is not enabled."); -} -#else /* H5_HAVE_FILTER_SZIP */ + PASSED(); + } + else { + SKIPPED(); + HDputs(" Szip encoding is not enabled."); + } +#else /* H5_HAVE_FILTER_SZIP */ SKIPPED(); HDputs(" Szip filter is not enabled."); #endif /* H5_HAVE_FILTER_SZIP */ @@ -5963,19 +6361,15 @@ error: #endif /* H5_HAVE_FILTER_SZIP */ } /* end test_can_apply_szip() */ - /* This message derives from H5Z */ const H5Z_class2_t H5Z_SET_LOCAL_TEST[1] = {{ - H5Z_CLASS_T_VERS, - H5Z_FILTER_SET_LOCAL_TEST, /* Filter id number */ - 1, 1, - "set_local_test", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - set_local_bogus2, /* The "set local" callback */ - filter_bogus2, /* The actual filter function */ + H5Z_CLASS_T_VERS, H5Z_FILTER_SET_LOCAL_TEST, /* Filter id number */ + 1, 1, "set_local_test", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + set_local_bogus2, /* The "set local" callback */ + filter_bogus2, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: test_set_local * @@ -5992,160 +6386,162 @@ const H5Z_class2_t H5Z_SET_LOCAL_TEST[1] = {{ static herr_t test_set_local(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t file; /* File ID */ - hid_t dsid; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataspace creation property list ID */ - const hsize_t dims[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ - const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ - hsize_t dset_size; /* Dataset size */ - unsigned cd_values[2]={BOGUS2_PARAM_1, BOGUS2_PARAM_2}; /* Parameters for Bogus2 filter */ - size_t i,j; /* Local index variables */ - double n; /* Local index variables */ + char filename[FILENAME_BUF_SIZE]; + hid_t file; /* File ID */ + hid_t dsid; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataspace creation property list ID */ + const hsize_t dims[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ + const hsize_t chunk_dims[2] = {2, 25}; /* Chunk dimensions */ + hsize_t dset_size; /* Dataset size */ + unsigned cd_values[2] = {BOGUS2_PARAM_1, BOGUS2_PARAM_2}; /* Parameters for Bogus2 filter */ + size_t i, j; /* Local index variables */ + double n; /* Local index variables */ TESTING("dataset filter 'set local' callback"); h5_fixname(FILENAME[5], fapl, filename, sizeof filename); /* Initialize the integer & floating-point dataset */ - n=1.0F; - for(i = 0; i < DSET_DIM1; i++) - for(j = 0; j < DSET_DIM2; j++) { - points[i][j] = (int)n++; - points_dbl[i][j] = (double)1.5F*n++; - } + n = 1.0F; + for (i = 0; i < DSET_DIM1; i++) + for (j = 0; j < DSET_DIM2; j++) { + points[i][j] = (int)n++; + points_dbl[i][j] = (double)1.5F * n++; + } /* Open file */ - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't open file\n",__LINE__); - goto error; + HDprintf(" Line %d: Can't open file\n", __LINE__); + goto error; } /* Create dcpl with special filter */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't create dcpl\n",__LINE__); + HDprintf(" Line %d: Can't create dcpl\n", __LINE__); goto error; } /* end if */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't set chunk sizes\n",__LINE__); + HDprintf(" Line %d: Can't set chunk sizes\n", __LINE__); goto error; } /* end if */ - if(H5Zregister (H5Z_SET_LOCAL_TEST) < 0) { + if (H5Zregister(H5Z_SET_LOCAL_TEST) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't register 'set local' filter\n",__LINE__); + HDprintf(" Line %d: Can't register 'set local' filter\n", __LINE__); goto error; } - if(H5Pset_filter(dcpl, H5Z_FILTER_SET_LOCAL_TEST, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) { + if (H5Pset_filter(dcpl, H5Z_FILTER_SET_LOCAL_TEST, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't set bogus2 filter\n",__LINE__); + HDprintf(" Line %d: Can't set bogus2 filter\n", __LINE__); goto error; } /* Create the data space */ - if((sid = H5Screate_simple(2, dims, NULL)) < 0) { + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't open dataspace\n",__LINE__); + HDprintf(" Line %d: Can't open dataspace\n", __LINE__); goto error; } /* end if */ /* Create new dataset */ - if((dsid = H5Dcreate2(file, DSET_SET_LOCAL_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((dsid = H5Dcreate2(file, DSET_SET_LOCAL_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) { H5_FAILED(); - HDprintf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n", __LINE__); goto error; } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { + if (H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n", __LINE__); goto error; } /* end if */ /* Close dataset */ - if(H5Dclose(dsid) < 0) { + if (H5Dclose(dsid) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n", __LINE__); goto error; } /* end if */ /* Create new dataset */ /* (Shouldn't get modified by output filter) */ - if((dsid = H5Dcreate2(file, DSET_SET_LOCAL_NAME_2, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + if ((dsid = H5Dcreate2(file, DSET_SET_LOCAL_NAME_2, H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT)) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't create dataset\n",__LINE__); + HDprintf(" Line %d: Can't create dataset\n", __LINE__); goto error; } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_dbl_data) < 0) { + if (H5Dwrite(dsid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_dbl_data) < 0) { H5_FAILED(); - HDprintf(" Line %d: Error writing dataset data\n",__LINE__); + HDprintf(" Line %d: Error writing dataset data\n", __LINE__); goto error; } /* end if */ /* Close dataset */ - if(H5Dclose(dsid) < 0) { + if (H5Dclose(dsid) < 0) { H5_FAILED(); - HDprintf(" Line %d: Can't close dataset\n",__LINE__); + HDprintf(" Line %d: Can't close dataset\n", __LINE__); goto error; } /* end if */ /* Close dataspace */ - if(H5Sclose(sid) < 0) { + if (H5Sclose(sid) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't close dataspace\n", __LINE__); goto error; } /* end if */ /* Close dataset creation property list */ - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't close dcpl\n", __LINE__); goto error; } /* end if */ /* Close file (flushes & empties cache) */ - if(H5Fclose(file) < 0) { + if (H5Fclose(file) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't close file\n", __LINE__); goto error; } /* end if */ /* Open file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) { + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't open file\n", __LINE__); goto error; } /* Re-open dataset */ - if((dsid = H5Dopen2(file, DSET_SET_LOCAL_NAME, H5P_DEFAULT)) < 0) { + if ((dsid = H5Dopen2(file, DSET_SET_LOCAL_NAME, H5P_DEFAULT)) < 0) { H5_FAILED(); HDprintf(" Line %d: Can't open dataset\n", __LINE__); goto error; } /* end if */ /* Query the dataset's size on disk */ - if((dset_size = H5Dget_storage_size(dsid)) == 0) { + if ((dset_size = H5Dget_storage_size(dsid)) == 0) { H5_FAILED(); HDprintf(" Line %d: Error querying dataset size\n", __LINE__); goto error; } /* end if */ /* Verify that the size indicates data is uncompressed */ - if((H5Tget_size(H5T_NATIVE_INT) * dims[0] * dims[1]) != dset_size) { + if ((H5Tget_size(H5T_NATIVE_INT) * dims[0] * dims[1]) != dset_size) { H5_FAILED(); HDprintf(" Line %d: Incorrect dataset size: %lu\n", __LINE__, (unsigned long)dset_size); goto error; } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { + if (H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error reading dataset data\n", __LINE__); goto error; @@ -6153,49 +6549,49 @@ test_set_local(hid_t fapl) /* Compare data */ /* Check that the values read are the modified version of what was written */ - for(i=0; i=0) { + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); - HDprintf(" Line %d: Shouldn't have deleted filter!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have deleted filter!\n", __LINE__); goto error; } /* end if */ /* try to delete the deflate filter again */ - H5E_BEGIN_TRY { - ret=H5Premove_filter(dcpl1,H5Z_FILTER_DEFLATE); - } H5E_END_TRY; - if(ret >=0) { + H5E_BEGIN_TRY + { + ret = H5Premove_filter(dcpl1, H5Z_FILTER_DEFLATE); + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); - HDprintf(" Line %d: Shouldn't have deleted filter!\n",__LINE__); + HDprintf(" Line %d: Shouldn't have deleted filter!\n", __LINE__); goto error; } /* end if */ - /*---------------------------------------------------------------------- - * delete all filters - *---------------------------------------------------------------------- - */ + /*---------------------------------------------------------------------- + * delete all filters + *---------------------------------------------------------------------- + */ /* delete all filters */ - if(H5Premove_filter(dcpl1,H5Z_FILTER_ALL) < 0) goto error; + if (H5Premove_filter(dcpl1, H5Z_FILTER_ALL) < 0) + goto error; /* get information about filters */ - if((nfilters = H5Pget_nfilters(dcpl1)) < 0) goto error; + if ((nfilters = H5Pget_nfilters(dcpl1)) < 0) + goto error; /* check if filters were deleted */ - if(nfilters)goto error; + if (nfilters) + goto error; - /*---------------------------------------------------------------------- - * close - *---------------------------------------------------------------------- - */ + /*---------------------------------------------------------------------- + * close + *---------------------------------------------------------------------- + */ /* clean up objects used for this test */ - if(H5Pclose (dcpl) < 0) goto error; - if(H5Pclose (dcpl1) < 0) goto error; - if(H5Dclose (dsid) < 0) goto error; - if(H5Sclose (sid) < 0) goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Pclose(dcpl1) < 0) + goto error; + if (H5Dclose(dsid) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; PASSED(); #else @@ -6574,17 +7037,17 @@ test_filter_delete(hid_t file) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(dcpl1); H5Dclose(dsid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_filter_delete() */ - - /*------------------------------------------------------------------------- * Function: auxread_fdata * @@ -6601,74 +7064,75 @@ error: static herr_t auxread_fdata(hid_t fid, const char *name) { - hid_t dset_id=-1; /* dataset ID */ - hid_t dcpl_id=-1; /* dataset creation property list ID */ - hid_t space_id=-1; /* space ID */ - hid_t ftype_id=-1; /* file data type ID */ - hid_t mtype_id=-1; /* memory data type ID */ - size_t msize; /* memory size of memory type */ - void *buf=NULL; /* data buffer */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ - int i; + hid_t dset_id = -1; /* dataset ID */ + hid_t dcpl_id = -1; /* dataset creation property list ID */ + hid_t space_id = -1; /* space ID */ + hid_t ftype_id = -1; /* file data type ID */ + hid_t mtype_id = -1; /* memory data type ID */ + size_t msize; /* memory size of memory type */ + void * buf = NULL; /* data buffer */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ + int i; - if((dset_id = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) goto error; - if((space_id = H5Dget_space(dset_id)) < 0) + if ((space_id = H5Dget_space(dset_id)) < 0) goto error; - if((ftype_id = H5Dget_type(dset_id)) < 0) + if ((ftype_id = H5Dget_type(dset_id)) < 0) goto error; - if((dcpl_id = H5Dget_create_plist(dset_id)) < 0) + if ((dcpl_id = H5Dget_create_plist(dset_id)) < 0) goto error; - if((rank = H5Sget_simple_extent_ndims(space_id)) < 0) + if ((rank = H5Sget_simple_extent_ndims(space_id)) < 0) goto error; HDmemset(dims, 0, sizeof dims); - if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) goto error; nelmts = 1; - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) nelmts *= dims[i]; - if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) + if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) goto error; - if((msize = H5Tget_size(mtype_id)) == 0) + if ((msize = H5Tget_size(mtype_id)) == 0) goto error; - if(nelmts) { + if (nelmts) { buf = (void *)HDmalloc((size_t)(nelmts * msize)); - if(buf == NULL) { - HDprintf( "cannot read into memory\n" ); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); goto error; } - if(H5Dread(dset_id, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dread(dset_id, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; } - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) goto error; - if(H5Sclose(space_id) < 0) + if (H5Sclose(space_id) < 0) goto error; - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) goto error; - if(buf) + if (buf) HDfree(buf); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl_id); H5Sclose(space_id); H5Dclose(dset_id); H5Tclose(ftype_id); H5Tclose(mtype_id); - if(buf) + if (buf) HDfree(buf); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end auxread_fdata() */ - /*------------------------------------------------------------------------- * Function: test_filters_endianess * @@ -6685,60 +7149,67 @@ error: static herr_t test_filters_endianess(void) { - hid_t fid=-1; /* file ID */ - hid_t dsid=-1; /* dataset ID */ - hid_t sid=-1; /* dataspace ID */ - hid_t dcpl=-1; /* dataset creation property list ID */ + hid_t fid = -1; /* file ID */ + hid_t dsid = -1; /* dataset ID */ + hid_t sid = -1; /* dataspace ID */ + hid_t dcpl = -1; /* dataset creation property list ID */ const char *data_file = H5_get_srcdir_filename("test_filters_le.h5"); /* Corrected test file name */ TESTING("filters with big-endian/little-endian data"); - /*------------------------------------------------------------------------- - * step 1: open a file written on a little-endian machine - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * step 1: open a file written on a little-endian machine + *------------------------------------------------------------------------- + */ /* open */ - if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* read */ - if(auxread_fdata(fid,"dset") < 0) TEST_ERROR + if (auxread_fdata(fid, "dset") < 0) + TEST_ERROR /* close */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR - /*------------------------------------------------------------------------- - * step 2: open a file written on a big-endian machine - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * step 2: open a file written on a big-endian machine + *------------------------------------------------------------------------- + */ /* compose the name of the file to open, using the srcdir, if appropriate */ data_file = H5_get_srcdir_filename("test_filters_be.h5"); /* Corrected test file name */ /* open */ - if((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(data_file, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* read */ - if(auxread_fdata(fid,"dset") < 0) TEST_ERROR + if (auxread_fdata(fid, "dset") < 0) + TEST_ERROR /* close */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dsid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_filters_endianess() */ - /*------------------------------------------------------------------------- * Function: test_zero_dims * @@ -6755,140 +7226,185 @@ error: static herr_t test_zero_dims(hid_t file) { - hid_t s = -1, d = -1, dcpl = -1; - hid_t s2 = -1, d2 = -1, dcpl2 = -1; - hsize_t dzero = 0, dmax = H5S_UNLIMITED, csize = 5; - hsize_t dzero2[2] = {0, 0}; - hsize_t dmax2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t csize2[2] = {5, 5}; - hid_t fapl; /* File access property list */ + hid_t s = -1, d = -1, dcpl = -1; + hid_t s2 = -1, d2 = -1, dcpl2 = -1; + hsize_t dzero = 0, dmax = H5S_UNLIMITED, csize = 5; + hsize_t dzero2[2] = {0, 0}; + hsize_t dmax2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t csize2[2] = {5, 5}; + hid_t fapl; /* File access property list */ H5D_chunk_index_t idx_type; /* Dataset chunk index type */ - H5F_libver_t low; /* File format low bound */ - herr_t ret; + H5F_libver_t low; /* File format low bound */ + herr_t ret; TESTING("I/O on datasets with zero-sized dims"); /* Get the file's file access property list */ - if((fapl = H5Fget_access_plist(file)) < 0) FAIL_STACK_ERROR + if ((fapl = H5Fget_access_plist(file)) < 0) + FAIL_STACK_ERROR /* Get library format */ - if(H5Pget_libver_bounds(fapl, &low, NULL) < 0) FAIL_STACK_ERROR + if (H5Pget_libver_bounds(fapl, &low, NULL) < 0) + FAIL_STACK_ERROR /* Close FAPL */ - if(H5Pclose(fapl) < 0) TEST_ERROR + if (H5Pclose(fapl) < 0) + TEST_ERROR /* * One-dimensional dataset */ - if((s = H5Screate_simple(1, &dzero, &dmax)) < 0) FAIL_STACK_ERROR + if ((s = H5Screate_simple(1, &dzero, &dmax)) < 0) + FAIL_STACK_ERROR /* Try creating chunked dataset with undefined chunk dimensions */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_layout(dcpl, H5D_CHUNKED) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_layout(dcpl, H5D_CHUNKED) < 0) + FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { d = H5Dcreate2(file, ZERODIM_DATASET, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(d > 0) { + } + H5E_END_TRY; + if (d > 0) { H5Dclose(d); FAIL_PUTS_ERROR("created dataset with undefined chunk dimensions") } /* end if */ /* Try creating chunked dataset with zero-sized chunk dimensions */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_chunk(dcpl, 1, &dzero); - } H5E_END_TRY; - if(ret > 0) + } + H5E_END_TRY; + if (ret > 0) FAIL_PUTS_ERROR("set zero-sized chunk dimensions") - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR /* Create the zero-sized extendible dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 1, &csize) < 0) FAIL_STACK_ERROR - if((d = H5Dcreate2(file, ZERODIM_DATASET, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, 1, &csize) < 0) + FAIL_STACK_ERROR + if ((d = H5Dcreate2(file, ZERODIM_DATASET, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the chunk index type */ - if(H5D__layout_idx_type_test(d, &idx_type) < 0) FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(d, &idx_type) < 0) + FAIL_STACK_ERROR /* Verify index type */ - if(low == H5F_LIBVER_LATEST) { - if(idx_type != H5D_CHUNK_IDX_EARRAY) - FAIL_PUTS_ERROR("should be using extensible array as index"); - } else if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (low == H5F_LIBVER_LATEST) { + if (idx_type != H5D_CHUNK_IDX_EARRAY) + FAIL_PUTS_ERROR("should be using extensible array as index"); + } + else if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); /* Various no-op writes */ - if(H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, (void*)911) < 0) FAIL_STACK_ERROR - if(H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, NULL) < 0) FAIL_STACK_ERROR - if(H5Dwrite(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void*)911) < 0) FAIL_STACK_ERROR - if(H5Dwrite(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, NULL) < 0) FAIL_STACK_ERROR + if (H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, (void *)911) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, NULL) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)911) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, NULL) < 0) + FAIL_STACK_ERROR /* Various no-op reads */ - if(H5Dread(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, (void*)911) < 0) FAIL_STACK_ERROR - if(H5Dread(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, NULL) < 0) FAIL_STACK_ERROR - if(H5Dread(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void*)911) < 0) FAIL_STACK_ERROR - if(H5Dread(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, NULL) < 0) FAIL_STACK_ERROR + if (H5Dread(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, (void *)911) < 0) + FAIL_STACK_ERROR + if (H5Dread(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, NULL) < 0) + FAIL_STACK_ERROR + if (H5Dread(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)911) < 0) + FAIL_STACK_ERROR + if (H5Dread(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, NULL) < 0) + FAIL_STACK_ERROR - if(H5Dclose(d) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(s) < 0) FAIL_STACK_ERROR + if (H5Dclose(d) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Sclose(s) < 0) + FAIL_STACK_ERROR /* * Two-dimensional dataset */ - if((s2 = H5Screate_simple(2, dzero2, dmax2)) < 0) FAIL_STACK_ERROR + if ((s2 = H5Screate_simple(2, dzero2, dmax2)) < 0) + FAIL_STACK_ERROR /* Try creating chunked dataset with undefined chunk dimensions */ - if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_layout(dcpl2, H5D_CHUNKED) < 0) FAIL_STACK_ERROR + if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_layout(dcpl2, H5D_CHUNKED) < 0) + FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { d2 = H5Dcreate2(file, ZERODIM_DATASET2, H5T_NATIVE_INT, s2, H5P_DEFAULT, dcpl2, H5P_DEFAULT); - } H5E_END_TRY; - if(d2 > 0) { + } + H5E_END_TRY; + if (d2 > 0) { H5Dclose(d2); FAIL_PUTS_ERROR("created dataset with undefined chunk dimensions") } /* end if */ /* Try creating chunked dataset with zero-sized chunk dimensions */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_chunk(dcpl2, 2, dzero2); - } H5E_END_TRY; - if(ret > 0) + } + H5E_END_TRY; + if (ret > 0) FAIL_PUTS_ERROR("set zero-sized chunk dimensions") - if(H5Pclose(dcpl2) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl2) < 0) + FAIL_STACK_ERROR /* Write to the zero-sized extendible dataset */ - if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl2, 2, csize2) < 0) FAIL_STACK_ERROR + if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl2, 2, csize2) < 0) + FAIL_STACK_ERROR /* Create the dataset */ - if((d2 = H5Dcreate2(file, ZERODIM_DATASET2, H5T_NATIVE_INT, s2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((d2 = H5Dcreate2(file, ZERODIM_DATASET2, H5T_NATIVE_INT, s2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the chunk index type */ - if(H5D__layout_idx_type_test(d2, &idx_type) < 0) FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(d2, &idx_type) < 0) + FAIL_STACK_ERROR /* Verify index type */ - if(low == H5F_LIBVER_LATEST) { - if(idx_type != H5D_CHUNK_IDX_BT2) - FAIL_PUTS_ERROR("should be using v2 B-tree as index"); - } else if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (low == H5F_LIBVER_LATEST) { + if (idx_type != H5D_CHUNK_IDX_BT2) + FAIL_PUTS_ERROR("should be using v2 B-tree as index"); + } + else if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); /* Just a no-op */ - if(H5Dwrite(d2, H5T_NATIVE_INT, s2, s2, H5P_DEFAULT, (void*)911) < 0) FAIL_STACK_ERROR + if (H5Dwrite(d2, H5T_NATIVE_INT, s2, s2, H5P_DEFAULT, (void *)911) < 0) + FAIL_STACK_ERROR - if(H5Dclose(d2) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl2) < 0) FAIL_STACK_ERROR - if(H5Sclose(s2) < 0) FAIL_STACK_ERROR + if (H5Dclose(d2) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl2) < 0) + FAIL_STACK_ERROR + if (H5Sclose(s2) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(dcpl); @@ -6898,11 +7414,11 @@ error: H5Pclose(dcpl2); H5Dclose(d2); H5Sclose(s2); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_zero_dims() */ - /*------------------------------------------------------------------------- * Function: test_missing_chunk * @@ -6921,183 +7437,212 @@ error: static herr_t test_missing_chunk(hid_t file) { - hid_t d = -1, did2 = -1; /* Dataset IDs */ - hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property IDs */ - hid_t s = -1, sid2 = -1; /* Dataspace ID */ - hsize_t hs_start[1], hs_stride[1], hs_count[1], hs_block[1]; /* Hyperslab setting */ - hsize_t hs_start2[2], hs_stride2[2], hs_count2[2], hs_block2[2];/* Hyperslab setting */ + hid_t d = -1, did2 = -1; /* Dataset IDs */ + hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property IDs */ + hid_t s = -1, sid2 = -1; /* Dataspace ID */ + hsize_t hs_start[1], hs_stride[1], hs_count[1], hs_block[1]; /* Hyperslab setting */ + hsize_t hs_start2[2], hs_stride2[2], hs_count2[2], hs_block2[2]; /* Hyperslab setting */ /* Buffers for reading/writing dataset */ - int *wdata = NULL; - int *rdata = NULL; - int **wdata2 = NULL; - int **rdata2 = NULL; - int *wdata2_bytes = NULL; - int *rdata2_bytes = NULL; + int * wdata = NULL; + int * rdata = NULL; + int **wdata2 = NULL; + int **rdata2 = NULL; + int * wdata2_bytes = NULL; + int * rdata2_bytes = NULL; /* Setting for 1-D dataset */ - hsize_t dsize=100, dmax=H5S_UNLIMITED; - hsize_t csize=5; + hsize_t dsize = 100, dmax = H5S_UNLIMITED; + hsize_t csize = 5; /* Setting for 2-D dataset */ - hsize_t dsize2[2] = {100, 100}, dmax2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t csize2[2] = {5, 5}; - size_t u, i, j; /* Local Index variable */ + hsize_t dsize2[2] = {100, 100}, dmax2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t csize2[2] = {5, 5}; + size_t u, i, j; /* Local Index variable */ - hid_t fapl; /* File access property list */ - H5F_libver_t low; /* File format low bound */ - H5D_chunk_index_t idx_type, idx_type2; /* Dataset chunk index types */ + hid_t fapl; /* File access property list */ + H5F_libver_t low; /* File format low bound */ + H5D_chunk_index_t idx_type, idx_type2; /* Dataset chunk index types */ TESTING("Read dataset with unwritten chunk & undefined fill value"); /* Set up data arrays */ - if(NULL == (wdata = (int *)HDcalloc(MISSING_CHUNK_DIM, sizeof(int)))) + if (NULL == (wdata = (int *)HDcalloc(MISSING_CHUNK_DIM, sizeof(int)))) TEST_ERROR; - if(NULL == (rdata = (int *)HDcalloc(MISSING_CHUNK_DIM, sizeof(int)))) + if (NULL == (rdata = (int *)HDcalloc(MISSING_CHUNK_DIM, sizeof(int)))) TEST_ERROR; - if(NULL == (wdata2_bytes = (int *)HDcalloc(MISSING_CHUNK_DIM * MISSING_CHUNK_DIM, sizeof(int)))) + if (NULL == (wdata2_bytes = (int *)HDcalloc(MISSING_CHUNK_DIM * MISSING_CHUNK_DIM, sizeof(int)))) TEST_ERROR; - if(NULL == (wdata2 = (int **)HDcalloc(MISSING_CHUNK_DIM, sizeof(wdata2_bytes)))) + if (NULL == (wdata2 = (int **)HDcalloc(MISSING_CHUNK_DIM, sizeof(wdata2_bytes)))) TEST_ERROR; for (i = 0; i < MISSING_CHUNK_DIM; i++) wdata2[i] = wdata2_bytes + (i * MISSING_CHUNK_DIM); - if(NULL == (rdata2_bytes = (int *)HDcalloc(MISSING_CHUNK_DIM * MISSING_CHUNK_DIM, sizeof(int)))) + if (NULL == (rdata2_bytes = (int *)HDcalloc(MISSING_CHUNK_DIM * MISSING_CHUNK_DIM, sizeof(int)))) TEST_ERROR; - if(NULL == (rdata2 = (int **)HDcalloc(MISSING_CHUNK_DIM, sizeof(rdata2_bytes)))) + if (NULL == (rdata2 = (int **)HDcalloc(MISSING_CHUNK_DIM, sizeof(rdata2_bytes)))) TEST_ERROR; for (i = 0; i < MISSING_CHUNK_DIM; i++) rdata2[i] = rdata2_bytes + (i * MISSING_CHUNK_DIM); /* Get the file's file access property list */ - if((fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; + if ((fapl = H5Fget_access_plist(file)) < 0) + TEST_ERROR; /* Get library format */ - if(H5Pget_libver_bounds(fapl, &low, NULL) < 0) TEST_ERROR; + if (H5Pget_libver_bounds(fapl, &low, NULL) < 0) + TEST_ERROR; /* Close FAPL */ - if(H5Pclose(fapl) < 0) TEST_ERROR + if (H5Pclose(fapl) < 0) + TEST_ERROR /* Initialize data for 1-D dataset */ - for(u = 0; u < MISSING_CHUNK_DIM; u++) { + for (u = 0; u < MISSING_CHUNK_DIM; u++) { wdata[u] = (int)u; rdata[u] = 911; } /* end for */ /* Initialize data for 2-D dataset */ - for(i = 0; i < MISSING_CHUNK_DIM; i++) { - for(j = 0; j < MISSING_CHUNK_DIM; j++) { + for (i = 0; i < MISSING_CHUNK_DIM; i++) { + for (j = 0; j < MISSING_CHUNK_DIM; j++) { wdata2[i][j] = (int)(j + (i * MISSING_CHUNK_DIM)); rdata2[i][j] = 911; } } /* end for */ /* Create dataspace */ - if((s = H5Screate_simple(1, &dsize, &dmax)) < 0) TEST_ERROR; - if((sid2 = H5Screate_simple(2, dsize2, dmax2)) < 0) TEST_ERROR; + if ((s = H5Screate_simple(1, &dsize, &dmax)) < 0) + TEST_ERROR; + if ((sid2 = H5Screate_simple(2, dsize2, dmax2)) < 0) + TEST_ERROR; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set to chunked */ - if(H5Pset_chunk(dcpl, 1, &csize) < 0) TEST_ERROR; - if(H5Pset_chunk(dcpl2, 2, csize2) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 1, &csize) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl2, 2, csize2) < 0) + TEST_ERROR; /* Undefine fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, NULL) < 0) TEST_ERROR; - if(H5Pset_fill_value(dcpl2, H5T_NATIVE_INT, NULL) < 0) TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, NULL) < 0) + TEST_ERROR; + if (H5Pset_fill_value(dcpl2, H5T_NATIVE_INT, NULL) < 0) + TEST_ERROR; /* Create the 1-D & 2-D datasets */ - if((d = H5Dcreate2(file, MISSING_CHUNK_DATASET, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; - if((did2 = H5Dcreate2(file, MISSING_CHUNK_DATASET2, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((d = H5Dcreate2(file, MISSING_CHUNK_DATASET, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; + if ((did2 = H5Dcreate2(file, MISSING_CHUNK_DATASET2, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, + H5P_DEFAULT)) < 0) + TEST_ERROR; /* Get the chunk index types */ - if(H5D__layout_idx_type_test(d, &idx_type) < 0) TEST_ERROR; - if(H5D__layout_idx_type_test(did2, &idx_type2) < 0) TEST_ERROR; + if (H5D__layout_idx_type_test(d, &idx_type) < 0) + TEST_ERROR; + if (H5D__layout_idx_type_test(did2, &idx_type2) < 0) + TEST_ERROR; /* Verify index type */ - if(low == H5F_LIBVER_LATEST) { - if(idx_type != H5D_CHUNK_IDX_EARRAY) + if (low == H5F_LIBVER_LATEST) { + if (idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using Extensible Array as index"); - if(idx_type2 != H5D_CHUNK_IDX_BT2) + if (idx_type2 != H5D_CHUNK_IDX_BT2) FAIL_PUTS_ERROR("should be using v2 B-tree as index"); - } else { - if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - if(idx_type2 != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + } + else { + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (idx_type2 != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); } /* Select elements in every other chunk for 1-D dataset */ - hs_start[0]=0; - hs_stride[0]=10; - hs_count[0]=10; - hs_block[0]=5; - if(H5Sselect_hyperslab(s, H5S_SELECT_SET, hs_start, hs_stride, hs_count, - hs_block) < 0) TEST_ERROR; + hs_start[0] = 0; + hs_stride[0] = 10; + hs_count[0] = 10; + hs_block[0] = 5; + if (H5Sselect_hyperslab(s, H5S_SELECT_SET, hs_start, hs_stride, hs_count, hs_block) < 0) + TEST_ERROR; /* Select elements in every other chunk for 2-D dataset */ hs_start2[0] = hs_start2[1] = 0; hs_stride2[0] = hs_stride2[1] = 10; hs_count2[0] = hs_count2[1] = 10; hs_block2[0] = hs_block2[1] = 5; - if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_start2, hs_stride2, hs_count2, - hs_block2) < 0) TEST_ERROR; + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_start2, hs_stride2, hs_count2, hs_block2) < 0) + TEST_ERROR; /* Write selected data to the datasets */ - if(H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, wdata) < 0) TEST_ERROR; - if(H5Dwrite(did2, H5T_NATIVE_INT, sid2, sid2, H5P_DEFAULT, wdata2_bytes) < 0) TEST_ERROR; + if (H5Dwrite(d, H5T_NATIVE_INT, s, s, H5P_DEFAULT, wdata) < 0) + TEST_ERROR; + if (H5Dwrite(did2, H5T_NATIVE_INT, sid2, sid2, H5P_DEFAULT, wdata2_bytes) < 0) + TEST_ERROR; /* Read all data from the datasets */ - if(H5Dread(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR; - if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata2_bytes) < 0) TEST_ERROR; + if (H5Dread(d, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) + TEST_ERROR; + if (H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata2_bytes) < 0) + TEST_ERROR; /* Validata values read for the 1-D dataset */ - for(u=0; u=5) { - if(rdata[u]!=911) { - HDprintf(" Line %d: Incorrect value, rdata[%u]=%d\n",__LINE__,(unsigned)u,rdata[u]); + for (u = 0; u < MISSING_CHUNK_DIM; u++) { + if ((u % 10) >= 5) { + if (rdata[u] != 911) { + HDprintf(" Line %d: Incorrect value, rdata[%u]=%d\n", __LINE__, (unsigned)u, rdata[u]); TEST_ERROR; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rdata[u]!=wdata[u]) { - HDprintf(" Line %d: Incorrect value, wdata[%u]=%d, rdata[%u]=%d\n",__LINE__,(unsigned)u,wdata[u],(unsigned)u,rdata[u]); + if (rdata[u] != wdata[u]) { + HDprintf(" Line %d: Incorrect value, wdata[%u]=%d, rdata[%u]=%d\n", __LINE__, (unsigned)u, + wdata[u], (unsigned)u, rdata[u]); TEST_ERROR; } /* end if */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ /* Validata values read for the 2-D dataset */ - for(i = 0; i < MISSING_CHUNK_DIM; i++) { - for(j = 0; j < MISSING_CHUNK_DIM; j++) { - - if((i % 10) >= 5 || (j % 10) >= 5) { - if(rdata2[i][j] != 911) { - HDprintf(" Line %d: Incorrect value, rdata2[%u][%u] = %d\n", - __LINE__,(unsigned)i, (unsigned)j, rdata2[i][j]); - TEST_ERROR; - } /* end if */ - } /* end if */ - else { - if(rdata2[i][j] != wdata2[i][j]) { - HDprintf(" Line %d: Incorrect value, wdata2[%u][%u] = %d, rdata2[%u][%u] = %d\n", - __LINE__,(unsigned)i, (unsigned)j, wdata2[i][j],(unsigned)i, (unsigned)j, rdata2[i][j]); - TEST_ERROR; - } /* end if */ - } /* end else */ - } /* end for */ - } /* end for */ + for (i = 0; i < MISSING_CHUNK_DIM; i++) { + for (j = 0; j < MISSING_CHUNK_DIM; j++) { + + if ((i % 10) >= 5 || (j % 10) >= 5) { + if (rdata2[i][j] != 911) { + HDprintf(" Line %d: Incorrect value, rdata2[%u][%u] = %d\n", __LINE__, (unsigned)i, + (unsigned)j, rdata2[i][j]); + TEST_ERROR; + } /* end if */ + } /* end if */ + else { + if (rdata2[i][j] != wdata2[i][j]) { + HDprintf(" Line %d: Incorrect value, wdata2[%u][%u] = %d, rdata2[%u][%u] = %d\n", + __LINE__, (unsigned)i, (unsigned)j, wdata2[i][j], (unsigned)i, (unsigned)j, + rdata2[i][j]); + TEST_ERROR; + } /* end if */ + } /* end else */ + } /* end for */ + } /* end for */ /* Close everything */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Pclose(dcpl2) < 0) TEST_ERROR; - if(H5Sclose(s) < 0) TEST_ERROR; - if(H5Sclose(sid2) < 0) TEST_ERROR; - if(H5Dclose(d) < 0) TEST_ERROR; - if(H5Dclose(did2) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Pclose(dcpl2) < 0) + TEST_ERROR; + if (H5Sclose(s) < 0) + TEST_ERROR; + if (H5Sclose(sid2) < 0) + TEST_ERROR; + if (H5Dclose(d) < 0) + TEST_ERROR; + if (H5Dclose(did2) < 0) + TEST_ERROR; HDfree(rdata); HDfree(wdata); @@ -7110,7 +7655,8 @@ test_missing_chunk(hid_t file) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(dcpl); @@ -7119,7 +7665,8 @@ error: H5Dclose(did2); H5Sclose(s); H5Sclose(sid2); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(rdata); HDfree(wdata); @@ -7148,10 +7695,11 @@ gcd(long l0, long r0) do { if (l < r) { - r = r % l; + r = r % l; remainder = r; - } else /* r <= l */ { - l = l % r; + } + else /* r <= l */ { + l = l % r; remainder = l; } } while (remainder != 0); @@ -7214,23 +7762,22 @@ make_random_offset_and_increment(long nelts, long *offsetp, long *incp) static herr_t test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t s=-1, m=-1, d=-1, dcpl=-1, file=-1; - int wbuf[NPOINTS], - rbuf[NPOINTS], - check2[20][20]; - hsize_t coord[NPOINTS][2]; - const hsize_t dsize[2]={100,100}, dmax[2]={H5S_UNLIMITED, H5S_UNLIMITED}, csize[2]={10,10}, nsize[2]={200,200}; - hsize_t fixed_dmax[2] = {1000, 1000}; - hsize_t msize[1]={NPOINTS}; - const char dname[]="dataset"; - int chunk_row, chunk_col; - size_t i, j; + char filename[FILENAME_BUF_SIZE]; + hid_t s = -1, m = -1, d = -1, dcpl = -1, file = -1; + int wbuf[NPOINTS], rbuf[NPOINTS], check2[20][20]; + hsize_t coord[NPOINTS][2]; + const hsize_t dsize[2] = {100, 100}, dmax[2] = {H5S_UNLIMITED, H5S_UNLIMITED}, csize[2] = {10, 10}, + nsize[2] = {200, 200}; + hsize_t fixed_dmax[2] = {1000, 1000}; + hsize_t msize[1] = {NPOINTS}; + const char dname[] = "dataset"; + int chunk_row, chunk_col; + size_t i, j; H5D_chunk_index_t idx_type; /* Dataset chunk index type */ - H5F_libver_t low; /* File format low bound */ - long ofs, inc; - long rows; - long cols; + H5F_libver_t low; /* File format low bound */ + long ofs, inc; + long rows; + long cols; TESTING(testname); @@ -7238,157 +7785,197 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) h5_fixname(FILENAME[6], fapl, filename, sizeof filename); - if(H5Pget_libver_bounds(fapl, &low, NULL) < 0) TEST_ERROR; + if (H5Pget_libver_bounds(fapl, &low, NULL) < 0) + TEST_ERROR; /* Create file for first test */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* Create dataspace */ - if((s = H5Screate_simple(2, dsize, NULL)) < 0) TEST_ERROR; + if ((s = H5Screate_simple(2, dsize, NULL)) < 0) + TEST_ERROR; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set chunked layout */ - if(H5Pset_chunk(dcpl, 2, csize) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, csize) < 0) + TEST_ERROR; /* Set early allocation time for one dataset; the other dataset is using default alloc time */ - if(early_alloc) - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR; + if (early_alloc) + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + TEST_ERROR; /* Create dataset */ - if((d = H5Dcreate2(file, dname, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((d = H5Dcreate2(file, dname, H5T_NATIVE_INT, s, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Initialization of check array for repeated coordinates */ - for(i=0; i=0); + space = H5Screate_simple(2, dims, NULL); + assert(space >= 0); /* Create a small data space for compact dataset */ small_dims[0] = 16; small_dims[1] = 8; - small_space = H5Screate_simple(2, small_dims, NULL); - assert(space>=0); + small_space = H5Screate_simple(2, small_dims, NULL); + assert(space >= 0); /* * Create a dataset using the default dataset creation properties. We're * not sure what they are, so we won't check. */ - if((dataset = H5Dcreate1(file, DSET_DEPREC_NAME, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT)) < 0) goto error; + if ((dataset = H5Dcreate1(file, DSET_DEPREC_NAME, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT)) < 0) + goto error; /* Close the dataset */ - if(H5Dclose(dataset) < 0) goto error; + if (H5Dclose(dataset) < 0) + goto error; /* * Try creating a dataset that already exists. This should fail since a * dataset can only be created once. Temporarily turn off error * reporting. */ - H5E_BEGIN_TRY { - dataset = H5Dcreate1(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT); - } H5E_END_TRY; - if(dataset >= 0) { - H5_FAILED(); - HDputs(" Library allowed overwrite of existing dataset."); - goto error; + H5E_BEGIN_TRY + { + dataset = H5Dcreate1(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT); + } + H5E_END_TRY; + if (dataset >= 0) { + H5_FAILED(); + HDputs(" Library allowed overwrite of existing dataset."); + goto error; } /* * Open the dataset we created above and then close it. This is how * existing datasets are accessed. */ - if((dataset = H5Dopen1(file, DSET_DEPREC_NAME)) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if ((dataset = H5Dopen1(file, DSET_DEPREC_NAME)) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; /* * Try opening a non-existent dataset. This should fail since new datasets * cannot be created with this function. Temporarily turn off error * reporting. */ - H5E_BEGIN_TRY { - dataset = H5Dopen1(file, "does_not_exist"); - } H5E_END_TRY; - if(dataset >= 0) { - H5_FAILED(); - HDputs(" Opened a non-existent dataset."); - goto error; + H5E_BEGIN_TRY + { + dataset = H5Dopen1(file, "does_not_exist"); + } + H5E_END_TRY; + if (dataset >= 0) { + H5_FAILED(); + HDputs(" Opened a non-existent dataset."); + goto error; } /* @@ -7729,66 +8372,73 @@ test_deprec(hid_t file) /* Add the deflate filter, if available */ #if defined H5_HAVE_FILTER_DEFLATE -{ - H5Z_filter_t filtn; /* filter identification number */ - size_t cd_nelmts = 1; /* Number of filter parameters */ - unsigned cd_value; /* Filter parameter */ + { + H5Z_filter_t filtn; /* filter identification number */ + size_t cd_nelmts = 1; /* Number of filter parameters */ + unsigned cd_value; /* Filter parameter */ - if(H5Pset_deflate(create_parms, 6) < 0) goto error; + if (H5Pset_deflate(create_parms, 6) < 0) + goto error; - /* Check for the deflate filter */ - filtn = H5Pget_filter1(create_parms, (unsigned)0, NULL, &cd_nelmts, &cd_value, (size_t)0, NULL); - if(H5Z_FILTER_DEFLATE != filtn) - goto error; - if(1 != cd_nelmts) - goto error; - if(6 != cd_value) - goto error; + /* Check for the deflate filter */ + filtn = H5Pget_filter1(create_parms, (unsigned)0, NULL, &cd_nelmts, &cd_value, (size_t)0, NULL); + if (H5Z_FILTER_DEFLATE != filtn) + goto error; + if (1 != cd_nelmts) + goto error; + if (6 != cd_value) + goto error; - /* Check for the deflate filter */ - if(H5Pget_filter_by_id1(create_parms, H5Z_FILTER_DEFLATE, NULL, &cd_nelmts, &cd_value, (size_t)0, NULL) < 0) goto error; - if(1 != cd_nelmts) - goto error; - if(6 != cd_value) - goto error; -} + /* Check for the deflate filter */ + if (H5Pget_filter_by_id1(create_parms, H5Z_FILTER_DEFLATE, NULL, &cd_nelmts, &cd_value, (size_t)0, + NULL) < 0) + goto error; + if (1 != cd_nelmts) + goto error; + if (6 != cd_value) + goto error; + } #endif /* H5_HAVE_FILTER_DEFLATE */ /* Attempt to create a dataset with invalid chunk sizes */ - csize[0] = dims[0]*2; - csize[1] = dims[1]*2; - status = H5Pset_chunk(create_parms, 2, csize); + csize[0] = dims[0] * 2; + csize[1] = dims[1] * 2; + status = H5Pset_chunk(create_parms, 2, csize); assert(status >= 0); - H5E_BEGIN_TRY { - dataset = H5Dcreate1(file, DSET_DEPREC_NAME_CHUNKED, H5T_NATIVE_DOUBLE, space, - create_parms); - } H5E_END_TRY; - if(dataset >= 0) { - H5_FAILED(); - HDputs(" Opened a dataset with incorrect chunking parameters."); - goto error; + H5E_BEGIN_TRY + { + dataset = H5Dcreate1(file, DSET_DEPREC_NAME_CHUNKED, H5T_NATIVE_DOUBLE, space, create_parms); + } + H5E_END_TRY; + if (dataset >= 0) { + H5_FAILED(); + HDputs(" Opened a dataset with incorrect chunking parameters."); + goto error; } csize[0] = 5; csize[1] = 100; - status = H5Pset_chunk(create_parms, 2, csize); + status = H5Pset_chunk(create_parms, 2, csize); assert(status >= 0); - if((dataset = H5Dcreate1(file, DSET_DEPREC_NAME_CHUNKED, H5T_NATIVE_DOUBLE, space, create_parms)) < 0) goto error; + if ((dataset = H5Dcreate1(file, DSET_DEPREC_NAME_CHUNKED, H5T_NATIVE_DOUBLE, space, create_parms)) < 0) + goto error; H5Pclose(create_parms); /* * Close the chunked dataset. */ - if(H5Dclose(dataset) < 0) goto error; - + if (H5Dclose(dataset) < 0) + goto error; /* * Open the dataset we created above and then close it. This is how * existing datasets are accessed. */ - if((dataset = H5Dopen1(file, DSET_DEPREC_NAME_CHUNKED)) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if ((dataset = H5Dopen1(file, DSET_DEPREC_NAME_CHUNKED)) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; /* * Create a compact dataset, then close it. @@ -7800,36 +8450,47 @@ test_deprec(hid_t file) status = H5Pset_alloc_time(create_parms, H5D_ALLOC_TIME_EARLY); assert(status >= 0); - if((dataset = H5Dcreate1(file, DSET_DEPREC_NAME_COMPACT, H5T_NATIVE_DOUBLE, small_space, create_parms)) < 0) goto error; + if ((dataset = H5Dcreate1(file, DSET_DEPREC_NAME_COMPACT, H5T_NATIVE_DOUBLE, small_space, create_parms)) < + 0) + goto error; H5Pclose(create_parms); - if(H5Dclose(dataset) < 0) goto error; + if (H5Dclose(dataset) < 0) + goto error; /* * Open the dataset we created above and then close it. This is how * existing datasets are accessed. */ - if((dataset = H5Dopen1(file, DSET_DEPREC_NAME_COMPACT)) < 0) goto error; - if(H5Dclose(dataset) < 0) goto error; + if ((dataset = H5Dopen1(file, DSET_DEPREC_NAME_COMPACT)) < 0) + goto error; + if (H5Dclose(dataset) < 0) + goto error; /* Test H5Zregister with deprecated H5Z_class1_t */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, csize) < 0) goto error; - if(H5Zregister(H5Z_DEPREC) < 0) goto error; - if(H5Pset_filter(dcpl, H5Z_FILTER_DEPREC, 0, (size_t)0, NULL) < 0) goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dcpl, 2, csize) < 0) + goto error; + if (H5Zregister(H5Z_DEPREC) < 0) + goto error; + if (H5Pset_filter(dcpl, H5Z_FILTER_DEPREC, 0, (size_t)0, NULL) < 0) + goto error; HDputs(""); - if(test_filter_internal(file,DSET_DEPREC_NAME_FILTER,dcpl,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&deprec_size) < 0) goto error; + if (test_filter_internal(file, DSET_DEPREC_NAME_FILTER, dcpl, DISABLE_FLETCHER32, DATA_NOT_CORRUPTED, + &deprec_size) < 0) + goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Pclose(dcpl) < 0) + goto error; return SUCCEED; - error: +error: return FAIL; } /* end test_deprec() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: test_huge_chunks * @@ -7846,102 +8507,120 @@ test_deprec(hid_t file) static herr_t test_huge_chunks(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dsid = -1; /* Dataset ID */ - hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ - hsize_t dim2[3], chunk_dim2[3]; /* Dataset and chunk dimensions */ - herr_t ret; /* Generic return value */ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ + hsize_t dim2[3], chunk_dim2[3]; /* Dataset and chunk dimensions */ + herr_t ret; /* Generic return value */ TESTING("creating dataset with >4GB chunks"); h5_fixname(FILENAME[7], fapl, filename, sizeof filename); /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Try to set too large of a chunk for 1-D dataset (# of elements) */ chunk_dim = TOO_HUGE_CHUNK_DIM; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_chunk(dcpl, 1, &chunk_dim); - } H5E_END_TRY; - if(ret >= 0) - FAIL_PUTS_ERROR(" Set chunk size with too large of chunk dimensions.") + } + H5E_END_TRY; + if (ret >= 0) + FAIL_PUTS_ERROR(" Set chunk size with too large of chunk dimensions.") /* Try to set too large of a chunk for n-D dataset (# of elements) */ chunk_dim2[0] = TOO_HUGE_CHUNK_DIM2_0; chunk_dim2[1] = TOO_HUGE_CHUNK_DIM2_1; chunk_dim2[2] = TOO_HUGE_CHUNK_DIM2_2; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_chunk(dcpl, 3, chunk_dim2); - } H5E_END_TRY; - if(ret >= 0) - FAIL_PUTS_ERROR(" Set chunk size with too large of chunk dimensions.") + } + H5E_END_TRY; + if (ret >= 0) + FAIL_PUTS_ERROR(" Set chunk size with too large of chunk dimensions.") /* Set 1-D chunk size */ chunk_dim = HUGE_CHUNK_DIM; - if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) + FAIL_STACK_ERROR /* Create 1-D dataspace */ dim = HUGE_DIM; - if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(1, &dim, NULL)) < 0) + FAIL_STACK_ERROR /* Try to create dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dsid = H5Dcreate2(fid, HUGE_DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dsid >= 0) - FAIL_PUTS_ERROR(" 1-D Dataset with too large of chunk dimensions created.") + } + H5E_END_TRY; + if (dsid >= 0) + FAIL_PUTS_ERROR(" 1-D Dataset with too large of chunk dimensions created.") /* Close 1-D dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR /* Set n-D chunk size */ chunk_dim2[0] = HUGE_CHUNK_DIM2_0; chunk_dim2[1] = HUGE_CHUNK_DIM2_1; chunk_dim2[2] = HUGE_CHUNK_DIM2_2; - if(H5Pset_chunk(dcpl, 3, chunk_dim2) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, 3, chunk_dim2) < 0) + FAIL_STACK_ERROR /* Create n-D dataspace */ dim2[0] = HUGE_DIM2_0; dim2[1] = HUGE_DIM2_1; dim2[2] = HUGE_DIM2_2; - if((sid = H5Screate_simple(3, dim2, NULL)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(3, dim2, NULL)) < 0) + FAIL_STACK_ERROR /* Try to create dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dsid = H5Dcreate2(fid, HUGE_DATASET2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dsid >= 0) - FAIL_PUTS_ERROR(" n-D Dataset with too large of chunk dimensions created.") + } + H5E_END_TRY; + if (dsid >= 0) + FAIL_PUTS_ERROR(" n-D Dataset with too large of chunk dimensions created.") /* Close n-D dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR /* Close everything else */ - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dsid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_huge_chunks() */ - /*------------------------------------------------------------------------- * Function: test_chunk_cache * @@ -7959,184 +8638,227 @@ error: static herr_t test_chunk_cache(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t fapl_local = -1; /* Local fapl */ - hid_t fapl_def = -1; /* Default fapl */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t dapl1 = -1; /* Dataset access property list ID */ - hid_t dapl2 = -1; /* Dataset access property list ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dsid = -1; /* Dataset ID */ - hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ - size_t nslots_1, nslots_2, nslots_3, nslots_4; /* rdcc number of elements */ - size_t nbytes_1, nbytes_2, nbytes_3, nbytes_4; /* rdcc number of bytes */ - size_t nlinks; /* Number of link traversals */ - double w0_1, w0_2, w0_3, w0_4; /* rdcc preemption policy */ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t fapl_local = -1; /* Local fapl */ + hid_t fapl_def = -1; /* Default fapl */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t dapl1 = -1; /* Dataset access property list ID */ + hid_t dapl2 = -1; /* Dataset access property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ + size_t nslots_1, nslots_2, nslots_3, nslots_4; /* rdcc number of elements */ + size_t nbytes_1, nbytes_2, nbytes_3, nbytes_4; /* rdcc number of bytes */ + size_t nlinks; /* Number of link traversals */ + double w0_1, w0_2, w0_3, w0_4; /* rdcc preemption policy */ TESTING("dataset chunk cache configuration"); /* Create a default fapl and dapl */ - if ((fapl_def = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR - if ((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR + if ((fapl_def = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR + if ((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR /* Verify that H5Pget_chunk_cache(dapl) returns the same values as are in * the default fapl. */ - if (H5Pget_cache(fapl_def, NULL, &nslots_1, &nbytes_1, &w0_1) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl1, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if (H5Pget_cache(fapl_def, NULL, &nslots_1, &nbytes_1, &w0_1) < 0) + FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl1, &nslots_4, &nbytes_4, &w0_4) < 0) + FAIL_STACK_ERROR if ((nslots_1 != nslots_4) || (nbytes_1 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_1, w0_4)) FAIL_PUTS_ERROR(" Cache values from default dapl do not match those from fapl.") /* Set a lapl property on dapl1 (to verify inheritance) */ - if (H5Pset_nlinks(dapl1, (size_t)134) < 0) FAIL_STACK_ERROR - if (H5Pget_nlinks(dapl1, &nlinks) < 0) FAIL_STACK_ERROR + if (H5Pset_nlinks(dapl1, (size_t)134) < 0) + FAIL_STACK_ERROR + if (H5Pget_nlinks(dapl1, &nlinks) < 0) + FAIL_STACK_ERROR if (nlinks != 134) FAIL_PUTS_ERROR(" nlinks parameter not set properly on dapl.") /* Copy fapl passed to this function (as we will be modifying it) */ - if ((fapl_local = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + if ((fapl_local = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR /* Set new rdcc settings on fapl */ nslots_2 = nslots_1 * 2; nbytes_2 = nbytes_1 * 2; - w0_2 = w0_1 / (double)2.0F; - if (H5Pset_cache(fapl_local, 0, nslots_2, nbytes_2, w0_2) < 0) FAIL_STACK_ERROR + w0_2 = w0_1 / (double)2.0F; + if (H5Pset_cache(fapl_local, 0, nslots_2, nbytes_2, w0_2) < 0) + FAIL_STACK_ERROR h5_fixname(FILENAME[8], fapl, filename, sizeof filename); /* Create file */ - if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 0) + FAIL_STACK_ERROR /* Create dataset creation property list */ - if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Set chunking */ chunk_dim = 10; - if (H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) + FAIL_STACK_ERROR /* Create 1-D dataspace */ dim = 100; - if ((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(1, &dim, NULL)) < 0) + FAIL_STACK_ERROR /* Create dataset with default dapl */ if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl1)) < 0) FAIL_STACK_ERROR /* Retrieve dapl from dataset, verfiy cache values are the same as on fapl_local */ - if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) + FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) + FAIL_STACK_ERROR if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_2, w0_4)) FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.") - if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) + FAIL_STACK_ERROR /* Set new values on dapl1. nbytes will be set to default, so the file * property will override this setting */ nslots_3 = nslots_2 * 2; nbytes_3 = H5D_CHUNK_CACHE_NBYTES_DEFAULT; - w0_3 = w0_2 / 2; - if (H5Pset_chunk_cache(dapl1, nslots_3, nbytes_3, w0_3) < 0) FAIL_STACK_ERROR + w0_3 = w0_2 / 2; + if (H5Pset_chunk_cache(dapl1, nslots_3, nbytes_3, w0_3) < 0) + FAIL_STACK_ERROR /* Close dataset, reopen with dapl1. Note the use of a dapl with H5Oopen */ - if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if ((dsid = H5Oopen(fid, "dset", dapl1)) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if ((dsid = H5Oopen(fid, "dset", dapl1)) < 0) + FAIL_STACK_ERROR /* Retrieve dapl from dataset, verfiy cache values are the same as on dapl1 */ /* Note we rely on the knowledge that H5Pget_chunk_cache retrieves these * values directly from the dataset structure, and not from a copy of the * dapl used to open the dataset (which is not preserved). */ - if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) + FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) + FAIL_STACK_ERROR if ((nslots_3 != nslots_4) || (nbytes_2 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_3, w0_4)) FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from dapl1.") - if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) + FAIL_STACK_ERROR /* Close dataset, reopen with H5P_DEFAULT as dapl */ - if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if ((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Retrieve dapl from dataset, verfiy cache values are the same on fapl_local */ - if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) + FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) + FAIL_STACK_ERROR if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_2, w0_4)) FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.") - if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) + FAIL_STACK_ERROR /* Similary, test use of H5Dcreate2 with H5P_DEFAULT */ - if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR if ((dsid = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) + FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) + FAIL_STACK_ERROR if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_2, w0_4)) FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.") /* Don't close dapl2, we will use it in the next section */ /* Modify cache values on fapl_local */ nbytes_3 = nbytes_2 * 2; - if (H5Pset_cache(fapl_local, 0, nslots_3, nbytes_3, w0_3) < 0) FAIL_STACK_ERROR + if (H5Pset_cache(fapl_local, 0, nslots_3, nbytes_3, w0_3) < 0) + FAIL_STACK_ERROR /* Close and reopen file with new fapl_local */ - if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_local)) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_local)) < 0) + FAIL_STACK_ERROR /* Verify that dapl2 retrieved earlier (using values from the old fapl) * sets its values in the new file (test use of H5Dopen2 with a dapl) */ - if ((dsid = H5Dopen2(fid, "dset", dapl2)) < 0) FAIL_STACK_ERROR - if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR /* Close dapl2, to avoid id leak */ - if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR - if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_2, w0_4)) - FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from dapl2.") + if ((dsid = H5Dopen2(fid, "dset", dapl2)) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) + FAIL_STACK_ERROR /* Close dapl2, to avoid id leak */ + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) + FAIL_STACK_ERROR if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) + FAIL_STACK_ERROR if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || + !H5_DBL_ABS_EQUAL(w0_2, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from dapl2.") - /* Test H5D_CHUNK_CACHE_NSLOTS_DEFAULT and H5D_CHUNK_CACHE_W0_DEFAULT */ - nslots_2 = H5D_CHUNK_CACHE_NSLOTS_DEFAULT; + /* Test H5D_CHUNK_CACHE_NSLOTS_DEFAULT and H5D_CHUNK_CACHE_W0_DEFAULT */ + nslots_2 = H5D_CHUNK_CACHE_NSLOTS_DEFAULT; w0_2 = H5D_CHUNK_CACHE_W0_DEFAULT; - if (H5Pset_chunk_cache(dapl2, nslots_2, nbytes_2, w0_2) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk_cache(dapl2, nslots_2, nbytes_2, w0_2) < 0) + FAIL_STACK_ERROR - if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if ((dsid = H5Dopen2(fid, "dset", dapl2)) < 0) FAIL_STACK_ERROR - if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR /* Close dapl2, to avoid id leak */ - if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR - if ((nslots_3 != nslots_4) || (nbytes_2 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_3, w0_4)) - FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those expected.") - if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR - - /* Verify that the file has indeed started using the new cache values (test - * use of H5Oopen with H5P_DEFAULT) */ - if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if ((dsid = H5Oopen(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR - if ((nslots_3 != nslots_4) || (nbytes_3 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_3, w0_4)) - FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.") - if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR - - /* Verify functionality of H5Pcopy with a dapl */ - if ((dapl2 = H5Pcopy(dapl1)) < 0) FAIL_STACK_ERROR - if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR - if ((nslots_3 != nslots_4) || (nbytes_1 != nbytes_4) || !H5_DBL_ABS_EQUAL(w0_3, w0_4)) - FAIL_PUTS_ERROR(" Cache values from dapl2 do not match those from dapl1.") - - /* Close */ - if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - if (H5Pclose(fapl_local) < 0) FAIL_STACK_ERROR - if (H5Pclose(fapl_def) < 0) FAIL_STACK_ERROR - if (H5Pclose(dapl1) < 0) FAIL_STACK_ERROR - if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR - if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if (H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset", dapl2)) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) + FAIL_STACK_ERROR /* Close dapl2, to avoid id leak */ + if ((dapl2 = H5Dget_access_plist(dsid)) < + 0) FAIL_STACK_ERROR if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < + 0) FAIL_STACK_ERROR if ((nslots_3 != nslots_4) || + (nbytes_2 != nbytes_4) || + !H5_DBL_ABS_EQUAL(w0_3, w0_4)) + FAIL_PUTS_ERROR( + " Cache values from retrieved dapl do not match those expected.") if (H5Pclose(dapl2) < + 0) + FAIL_STACK_ERROR - PASSED(); + /* Verify that the file has indeed started using the new cache values (test + * use of H5Oopen with H5P_DEFAULT) */ + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR if ((dsid = H5Oopen(fid, "dset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR if ((dapl2 = H5Dget_access_plist(dsid)) < 0) + FAIL_STACK_ERROR if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) + FAIL_STACK_ERROR if ((nslots_3 != nslots_4) || (nbytes_3 != nbytes_4) || + !H5_DBL_ABS_EQUAL(w0_3, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from " + "fapl.") if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + + /* Verify functionality of H5Pcopy with a dapl */ + if ((dapl2 = H5Pcopy(dapl1)) < 0) + FAIL_STACK_ERROR if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) + FAIL_STACK_ERROR if ((nslots_3 != nslots_4) || (nbytes_1 != nbytes_4) || + !H5_DBL_ABS_EQUAL(w0_3, w0_4)) + FAIL_PUTS_ERROR(" Cache values from dapl2 do not match those from dapl1.") + + /* Close */ + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR if (H5Pclose(fapl_local) < 0) FAIL_STACK_ERROR if (H5Pclose(fapl_def) < 0) + FAIL_STACK_ERROR if (H5Pclose(dapl1) < 0) FAIL_STACK_ERROR if (H5Pclose(dapl2) < 0) + FAIL_STACK_ERROR if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR + + PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_local); H5Pclose(fapl_def); H5Pclose(dapl1); @@ -8145,11 +8867,11 @@ error: H5Dclose(dsid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_chunk_cache() */ - /*------------------------------------------------------------------------- * Function: test_big_chunks_bypass_cache * @@ -8171,121 +8893,145 @@ error: static herr_t test_big_chunks_bypass_cache(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t fapl_local = -1; /* File access property list ID */ - hid_t dcpl = -1, t_dcpl = -1; /* Dataset creation property list ID */ - hid_t sid = -1, t_sid = -1; /* Dataspace ID */ - hid_t mid; /* Memory space ID */ - hid_t dsid = -1, t_dsid = -1; /* Dataset ID */ - hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ - hsize_t t_dim[2], t_max[2], t_chunk_dim[2]; /* Dataset and chunk dimensions */ - size_t rdcc_nelmts, rdcc_nbytes; /* Chunk cache parameters */ - int fvalue = BYPASS_FILL_VALUE; /* Fill value */ - hsize_t count, stride, offset, block; /* Setting for hyperslab (1-D) */ - hsize_t t_count[2], t_stride[2], t_offset[2], t_block[2]; /* Setting for hyperslab (2-D) */ - /* Buffers for reading and writing data (1-D) */ - int *wdata = NULL, *rdata1 = NULL, *rdata2 = NULL; - /* Buffers for reading and writing data (2-D) */ - int **t_wdata = NULL; - int **t_rdata1 = NULL; - int **t_rdata2 = NULL; - int *t_wdata_bytes = NULL; - int *t_rdata1_bytes = NULL; - int *t_rdata2_bytes = NULL; - int i, j; /* Local index variables */ - H5F_libver_t low; /* File format low bound */ - H5D_chunk_index_t idx_type, t_idx_type; /* Dataset chunk index types */ - + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t fapl_local = -1; /* File access property list ID */ + hid_t dcpl = -1, t_dcpl = -1; /* Dataset creation property list ID */ + hid_t sid = -1, t_sid = -1; /* Dataspace ID */ + hid_t mid; /* Memory space ID */ + hid_t dsid = -1, t_dsid = -1; /* Dataset ID */ + hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ + hsize_t t_dim[2], t_max[2], t_chunk_dim[2]; /* Dataset and chunk dimensions */ + size_t rdcc_nelmts, rdcc_nbytes; /* Chunk cache parameters */ + int fvalue = BYPASS_FILL_VALUE; /* Fill value */ + hsize_t count, stride, offset, block; /* Setting for hyperslab (1-D) */ + hsize_t t_count[2], t_stride[2], t_offset[2], t_block[2]; /* Setting for hyperslab (2-D) */ + /* Buffers for reading and writing data (1-D) */ + int *wdata = NULL, *rdata1 = NULL, *rdata2 = NULL; + /* Buffers for reading and writing data (2-D) */ + int ** t_wdata = NULL; + int ** t_rdata1 = NULL; + int ** t_rdata2 = NULL; + int * t_wdata_bytes = NULL; + int * t_rdata1_bytes = NULL; + int * t_rdata2_bytes = NULL; + int i, j; /* Local index variables */ + H5F_libver_t low; /* File format low bound */ + H5D_chunk_index_t idx_type, t_idx_type; /* Dataset chunk index types */ TESTING("big chunks bypassing the cache"); h5_fixname(FILENAME[9], fapl, filename, sizeof filename); /* Set up data arrays */ - if(NULL == (t_wdata_bytes = (int *)HDcalloc((BYPASS_CHUNK_DIM/2) * (BYPASS_CHUNK_DIM/2), sizeof(int)))) + if (NULL == + (t_wdata_bytes = (int *)HDcalloc((BYPASS_CHUNK_DIM / 2) * (BYPASS_CHUNK_DIM / 2), sizeof(int)))) TEST_ERROR; - if(NULL == (t_wdata = (int **)HDcalloc((BYPASS_CHUNK_DIM/2), sizeof(t_wdata_bytes)))) + if (NULL == (t_wdata = (int **)HDcalloc((BYPASS_CHUNK_DIM / 2), sizeof(t_wdata_bytes)))) TEST_ERROR; - for (i = 0; i < (BYPASS_CHUNK_DIM/2); i++) - t_wdata[i] = t_wdata_bytes + (i * (BYPASS_CHUNK_DIM/2)); + for (i = 0; i < (BYPASS_CHUNK_DIM / 2); i++) + t_wdata[i] = t_wdata_bytes + (i * (BYPASS_CHUNK_DIM / 2)); - if(NULL == (t_rdata1_bytes = (int *)HDcalloc(BYPASS_DIM * BYPASS_DIM, sizeof(int)))) + if (NULL == (t_rdata1_bytes = (int *)HDcalloc(BYPASS_DIM * BYPASS_DIM, sizeof(int)))) TEST_ERROR; - if(NULL == (t_rdata1 = (int **)HDcalloc(BYPASS_DIM, sizeof(t_rdata1_bytes)))) + if (NULL == (t_rdata1 = (int **)HDcalloc(BYPASS_DIM, sizeof(t_rdata1_bytes)))) TEST_ERROR; for (i = 0; i < BYPASS_DIM; i++) t_rdata1[i] = t_rdata1_bytes + (i * BYPASS_DIM); - if(NULL == (t_rdata2_bytes = (int *)HDcalloc((BYPASS_CHUNK_DIM/2) * (BYPASS_CHUNK_DIM/2), sizeof(int)))) + if (NULL == + (t_rdata2_bytes = (int *)HDcalloc((BYPASS_CHUNK_DIM / 2) * (BYPASS_CHUNK_DIM / 2), sizeof(int)))) TEST_ERROR; - if(NULL == (t_rdata2 = (int **)HDcalloc((BYPASS_CHUNK_DIM/2), sizeof(t_rdata2_bytes)))) + if (NULL == (t_rdata2 = (int **)HDcalloc((BYPASS_CHUNK_DIM / 2), sizeof(t_rdata2_bytes)))) TEST_ERROR; - for (i = 0; i < (BYPASS_CHUNK_DIM/2); i++) - t_rdata2[i] = t_rdata2_bytes + (i * (BYPASS_CHUNK_DIM/2)); + for (i = 0; i < (BYPASS_CHUNK_DIM / 2); i++) + t_rdata2[i] = t_rdata2_bytes + (i * (BYPASS_CHUNK_DIM / 2)); - - /* Check if we are using the latest version of the format */ - if(H5Pget_libver_bounds(fapl, &low, NULL) < 0) FAIL_STACK_ERROR + /* Check if we are using the latest version of the format */ + if (H5Pget_libver_bounds(fapl, &low, NULL) < 0) + FAIL_STACK_ERROR /* Copy fapl passed to this function (as we will be modifying it) */ - if((fapl_local = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + if ((fapl_local = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR /* Define cache size to be smaller than chunk size */ - rdcc_nelmts = BYPASS_CHUNK_DIM/5; - rdcc_nbytes = sizeof(int)*BYPASS_CHUNK_DIM/5; - if(H5Pset_cache(fapl_local, 0, rdcc_nelmts, rdcc_nbytes, 0.0F) < 0) FAIL_STACK_ERROR + rdcc_nelmts = BYPASS_CHUNK_DIM / 5; + rdcc_nbytes = sizeof(int) * BYPASS_CHUNK_DIM / 5; + if (H5Pset_cache(fapl_local, 0, rdcc_nelmts, rdcc_nbytes, 0.0F) < 0) + FAIL_STACK_ERROR /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 0) + FAIL_STACK_ERROR /* Create 1-D & 2-D dataspace */ dim = t_dim[0] = t_dim[1] = BYPASS_DIM; t_max[0] = t_max[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR - if((t_sid = H5Screate_simple(2, t_dim, t_max)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(1, &dim, NULL)) < 0) + FAIL_STACK_ERROR + if ((t_sid = H5Screate_simple(2, t_dim, t_max)) < 0) + FAIL_STACK_ERROR /* Create 1-D & 2-D dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if((t_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if ((t_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Define chunk size. */ /* There will be 2 chunks in 1-D dataset & 4 chunks in the 2-D dataset */ chunk_dim = t_chunk_dim[0] = t_chunk_dim[1] = BYPASS_CHUNK_DIM; - if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(t_dcpl, 2, t_chunk_dim) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) + FAIL_STACK_ERROR + if (H5Pset_chunk(t_dcpl, 2, t_chunk_dim) < 0) + FAIL_STACK_ERROR /* Define fill value, fill time, and chunk allocation time */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fvalue) < 0) FAIL_STACK_ERROR - if(H5Pset_fill_value(t_dcpl, H5T_NATIVE_INT, &fvalue) < 0) FAIL_STACK_ERROR + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fvalue) < 0) + FAIL_STACK_ERROR + if (H5Pset_fill_value(t_dcpl, H5T_NATIVE_INT, &fvalue) < 0) + FAIL_STACK_ERROR - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) FAIL_STACK_ERROR - if(H5Pset_fill_time(t_dcpl, H5D_FILL_TIME_IFSET) < 0) FAIL_STACK_ERROR + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) + FAIL_STACK_ERROR + if (H5Pset_fill_time(t_dcpl, H5D_FILL_TIME_IFSET) < 0) + FAIL_STACK_ERROR - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR) < 0) FAIL_STACK_ERROR - if(H5Pset_alloc_time(t_dcpl, H5D_ALLOC_TIME_INCR) < 0) FAIL_STACK_ERROR + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR) < 0) + FAIL_STACK_ERROR + if (H5Pset_alloc_time(t_dcpl, H5D_ALLOC_TIME_INCR) < 0) + FAIL_STACK_ERROR /* Create the first 1-D dataset */ - if((dsid = H5Dcreate2(fid, BYPASS_DATASET1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, BYPASS_DATASET1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create the first 2-D dataset */ - if((t_dsid = H5Dcreate2(fid, T_BYPASS_DATASET1, H5T_NATIVE_INT, t_sid, H5P_DEFAULT, t_dcpl, H5P_DEFAULT)) < 0) + if ((t_dsid = + H5Dcreate2(fid, T_BYPASS_DATASET1, H5T_NATIVE_INT, t_sid, H5P_DEFAULT, t_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get the chunk index types for 1-D and 2-d datasets */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR - if(H5D__layout_idx_type_test(t_dsid, &t_idx_type) < 0) FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(dsid, &idx_type) < 0) + FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(t_dsid, &t_idx_type) < 0) + FAIL_STACK_ERROR /* Chunk index type expected depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST) { - /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_FARRAY) FAIL_PUTS_ERROR("should be using Fixed Array as index"); - if(t_idx_type != H5D_CHUNK_IDX_BT2) FAIL_PUTS_ERROR("should be using v2 B-tree as index"); - } else { - /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - if(t_idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (low == H5F_LIBVER_LATEST) { + /* Verify index type */ + if (idx_type != H5D_CHUNK_IDX_FARRAY) + FAIL_PUTS_ERROR("should be using Fixed Array as index"); + if (t_idx_type != H5D_CHUNK_IDX_BT2) + FAIL_PUTS_ERROR("should be using v2 B-tree as index"); + } + else { + /* Verify index type */ + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (t_idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); } /* end else */ /* Select first chunk to write the data */ @@ -8293,27 +9039,27 @@ test_big_chunks_bypass_cache(hid_t fapl) count = t_count[0] = t_count[1] = 1; stride = t_stride[0] = t_stride[1] = 1; block = t_block[0] = t_block[1] = BYPASS_CHUNK_DIM / 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &offset, &stride, &count, &block) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, &offset, &stride, &count, &block) < 0) FAIL_STACK_ERROR - if(H5Sselect_hyperslab(t_sid, H5S_SELECT_SET, t_offset, t_stride, t_count, t_block) < 0) + if (H5Sselect_hyperslab(t_sid, H5S_SELECT_SET, t_offset, t_stride, t_count, t_block) < 0) FAIL_STACK_ERROR /* Allocate buffers */ - if(NULL == (wdata = (int *)HDmalloc(sizeof(int) * (BYPASS_CHUNK_DIM / 2)))) + if (NULL == (wdata = (int *)HDmalloc(sizeof(int) * (BYPASS_CHUNK_DIM / 2)))) TEST_ERROR - if(NULL == (rdata1 = (int *)HDmalloc(sizeof(int) * BYPASS_DIM))) + if (NULL == (rdata1 = (int *)HDmalloc(sizeof(int) * BYPASS_DIM))) TEST_ERROR - if(NULL == (rdata2 = (int *)HDmalloc(sizeof(int) * (BYPASS_CHUNK_DIM / 2)))) + if (NULL == (rdata2 = (int *)HDmalloc(sizeof(int) * (BYPASS_CHUNK_DIM / 2)))) TEST_ERROR /* Initialize data to write for 1-D dataset */ - for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) + for (i = 0; i < BYPASS_CHUNK_DIM / 2; i++) wdata[i] = i; /* Initialize data to write for 2-D dataset */ - for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) - for(j = 0; j < BYPASS_CHUNK_DIM / 2; j++) + for (i = 0; i < BYPASS_CHUNK_DIM / 2; i++) + for (j = 0; j < BYPASS_CHUNK_DIM / 2; j++) t_wdata[i][j] = j; /* Set up memory space for the 2-D dataset */ @@ -8321,125 +9067,149 @@ test_big_chunks_bypass_cache(hid_t fapl) /* Write to the first 1-D & 2-D datasets */ /* This write should go through the cache because fill value is used. */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, wdata) < 0) + if (H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, wdata) < 0) FAIL_STACK_ERROR - if(H5Dwrite(t_dsid, H5T_NATIVE_INT, mid, t_sid, H5P_DEFAULT, t_wdata_bytes) < 0) + if (H5Dwrite(t_dsid, H5T_NATIVE_INT, mid, t_sid, H5P_DEFAULT, t_wdata_bytes) < 0) FAIL_STACK_ERROR /* Close the first 1-D & 2-D datasets */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Dclose(t_dsid) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(t_dsid) < 0) + FAIL_STACK_ERROR /* Reopen the first 1-D & 2-D datasets */ - if((dsid = H5Dopen2(fid, BYPASS_DATASET1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((t_dsid = H5Dopen2(fid, T_BYPASS_DATASET1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, BYPASS_DATASET1, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((t_dsid = H5Dopen2(fid, T_BYPASS_DATASET1, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Reads both 2 chunks. Reading the second chunk should bypass the cache because the * chunk is bigger than the cache size and it isn't allocated on disk. */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata1) < 0) + if (H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata1) < 0) FAIL_STACK_ERROR - if(H5Dread(t_dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, t_rdata1_bytes) < 0) + if (H5Dread(t_dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, t_rdata1_bytes) < 0) FAIL_STACK_ERROR /* Verify data for the first 1-D dataset */ - for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) - if(rdata1[i] != i) { + for (i = 0; i < BYPASS_CHUNK_DIM / 2; i++) + if (rdata1[i] != i) { HDprintf(" Read different values than written in the 1st chunk.\n"); - HDprintf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], i); + HDprintf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], + i); TEST_ERROR } /* end if */ - for(j = BYPASS_CHUNK_DIM / 2; j < BYPASS_DIM; j++) - if(rdata1[j] != fvalue) { + for (j = BYPASS_CHUNK_DIM / 2; j < BYPASS_DIM; j++) + if (rdata1[j] != fvalue) { HDprintf(" Read different values than written in the 2nd chunk.\n"); - HDprintf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], fvalue); + HDprintf(" At line %d and index %d, rdata1 = %d. It should be %d.\n", __LINE__, i, rdata1[i], + fvalue); TEST_ERROR } /* end if */ /* Verify data for the first 2-D dataset */ - for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) - for(j = 0; j < BYPASS_CHUNK_DIM / 2; j++) - if(t_rdata1[i][j] != j) { - HDprintf(" Read different values than written in the 1st chunk.\n"); - HDprintf(" At line %d and index (%d, %d), t_rdata1 = %d. It should be %d.\n", - __LINE__, i, j, t_rdata1[i][j], j); - TEST_ERROR - } /* end if */ + for (i = 0; i < BYPASS_CHUNK_DIM / 2; i++) + for (j = 0; j < BYPASS_CHUNK_DIM / 2; j++) + if (t_rdata1[i][j] != j) { + HDprintf(" Read different values than written in the 1st chunk.\n"); + HDprintf(" At line %d and index (%d, %d), t_rdata1 = %d. It should be %d.\n", __LINE__, i, + j, t_rdata1[i][j], j); + TEST_ERROR + } /* end if */ - for(i = BYPASS_CHUNK_DIM / 2; i < BYPASS_DIM; i++) - for(j = BYPASS_CHUNK_DIM / 2; j < BYPASS_DIM; j++) - if(t_rdata1[i][j] != fvalue) { - HDprintf(" Read different values than written in the 2nd chunk.\n"); - HDprintf(" At line %d and index (%d, %d), t_rdata1 = %d. It should be %d.\n", - __LINE__, i, j, t_rdata1[i][j], fvalue); - TEST_ERROR - } /* end if */ + for (i = BYPASS_CHUNK_DIM / 2; i < BYPASS_DIM; i++) + for (j = BYPASS_CHUNK_DIM / 2; j < BYPASS_DIM; j++) + if (t_rdata1[i][j] != fvalue) { + HDprintf(" Read different values than written in the 2nd chunk.\n"); + HDprintf(" At line %d and index (%d, %d), t_rdata1 = %d. It should be %d.\n", __LINE__, i, + j, t_rdata1[i][j], fvalue); + TEST_ERROR + } /* end if */ /* Close the first 1-D & 2-D datasets */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Dclose(t_dsid) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(t_dsid) < 0) + FAIL_STACK_ERROR /* Create a second dataset without fill value. This time, both write * and read should bypass the cache because the chunk is bigger than the * cache size and it's not allocated on disk. */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) FAIL_STACK_ERROR - if(H5Pset_fill_time(t_dcpl, H5D_FILL_TIME_NEVER) < 0) FAIL_STACK_ERROR + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + FAIL_STACK_ERROR + if (H5Pset_fill_time(t_dcpl, H5D_FILL_TIME_NEVER) < 0) + FAIL_STACK_ERROR /* Create a second 1-D & 2-D dataset */ - if((dsid = H5Dcreate2(fid, BYPASS_DATASET2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, BYPASS_DATASET2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((t_dsid = H5Dcreate2(fid, T_BYPASS_DATASET2, H5T_NATIVE_INT, t_sid, H5P_DEFAULT, t_dcpl, H5P_DEFAULT)) < 0) + if ((t_dsid = + H5Dcreate2(fid, T_BYPASS_DATASET2, H5T_NATIVE_INT, t_sid, H5P_DEFAULT, t_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write to the second 1-D & 2-D dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, wdata) < 0) + if (H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, wdata) < 0) FAIL_STACK_ERROR - if(H5Dwrite(t_dsid, H5T_NATIVE_INT, mid, t_sid, H5P_DEFAULT, t_wdata_bytes) < 0) + if (H5Dwrite(t_dsid, H5T_NATIVE_INT, mid, t_sid, H5P_DEFAULT, t_wdata_bytes) < 0) FAIL_STACK_ERROR /* Close the second 1-D & 2-D dataset */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Dclose(t_dsid) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(t_dsid) < 0) + FAIL_STACK_ERROR /* Reopen the second 1-d dataset and 2-d dataset */ - if((dsid = H5Dopen2(fid, BYPASS_DATASET2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((t_dsid = H5Dopen2(fid, T_BYPASS_DATASET2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, BYPASS_DATASET2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((t_dsid = H5Dopen2(fid, T_BYPASS_DATASET2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Read back only the part that was written to the file. Reading the * half chunk should bypass the cache because the chunk is bigger than * the cache size. */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rdata2) < 0) - FAIL_STACK_ERROR - if(H5Dread(t_dsid, H5T_NATIVE_INT, mid, t_sid, H5P_DEFAULT, t_rdata2_bytes) < 0) - FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rdata2) < 0) + FAIL_STACK_ERROR + if (H5Dread(t_dsid, H5T_NATIVE_INT, mid, t_sid, H5P_DEFAULT, t_rdata2_bytes) < 0) + FAIL_STACK_ERROR /* Verify data for the second 1-D dataset */ - for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) - if(rdata2[i] != i) { + for (i = 0; i < BYPASS_CHUNK_DIM / 2; i++) + if (rdata2[i] != i) { HDprintf(" Read different values than written in the chunk.\n"); - HDprintf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], i); + HDprintf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], + i); TEST_ERROR } /* end if */ /* Verify data for the second 2-D dataset */ - for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) - for(j = 0; j < BYPASS_CHUNK_DIM / 2; j++) - if(t_rdata2[i][j] != j) { - HDprintf(" Read different values than written in the chunk.\n"); - HDprintf(" At line %d and index (%d, %d), t_rdata2 = %d. It should be %d.\n", - __LINE__, i, j, t_rdata2[i][j], j); - TEST_ERROR - } /* end if */ + for (i = 0; i < BYPASS_CHUNK_DIM / 2; i++) + for (j = 0; j < BYPASS_CHUNK_DIM / 2; j++) + if (t_rdata2[i][j] != j) { + HDprintf(" Read different values than written in the chunk.\n"); + HDprintf(" At line %d and index (%d, %d), t_rdata2 = %d. It should be %d.\n", __LINE__, i, + j, t_rdata2[i][j], j); + TEST_ERROR + } /* end if */ /* Close IDs */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(t_sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Dclose(t_dsid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(t_dcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl_local) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(t_sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(t_dsid) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(t_dcpl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(fapl_local) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Release buffers */ HDfree(wdata); @@ -8456,7 +9226,8 @@ test_big_chunks_bypass_cache(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(t_dcpl); H5Pclose(fapl_local); @@ -8465,7 +9236,8 @@ error: H5Sclose(sid); H5Sclose(t_sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(wdata); HDfree(rdata1); @@ -8480,7 +9252,6 @@ error: return FAIL; } /* end test_big_chunks_bypass_cache() */ - /*------------------------------------------------------------------------- * Function: test_chunk_fast * @@ -8497,43 +9268,48 @@ error: static herr_t test_chunk_fast(const char *env_h5_driver, hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t my_fapl = -1; /* File access property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t scalar_sid = -1;/* Scalar dataspace ID */ - hid_t dsid = -1; /* Dataset ID */ - hsize_t fill; /* Temporary value, for filling arrays */ - hsize_t hs_size[EARRAY_MAX_RANK]; /* Hyperslab size */ - hsize_t chunk_dim[EARRAY_MAX_RANK]; /* Chunk dimensions */ - H5F_libver_t low; /* File format low bound */ - unsigned swmr; /* Whether file should be written with SWMR access enabled */ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t my_fapl = -1; /* File access property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t scalar_sid = -1; /* Scalar dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t fill; /* Temporary value, for filling arrays */ + hsize_t hs_size[EARRAY_MAX_RANK]; /* Hyperslab size */ + hsize_t chunk_dim[EARRAY_MAX_RANK]; /* Chunk dimensions */ + H5F_libver_t low; /* File format low bound */ + unsigned swmr; /* Whether file should be written with SWMR access enabled */ TESTING("datasets w/extensible array as chunk index"); h5_fixname(FILENAME[10], fapl, filename, sizeof filename); /* Copy the file access property list */ - if((my_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + if ((my_fapl = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR - /* Turn on the chunk cache again */ - { - int mdc_nelmts; /* # of elements in metadata cache */ - size_t rdcc_nelmts; /* # of chunks in chunk cache */ - size_t rdcc_nbytes; /* # of bytes in chunk cache */ - double rdcc_w0; /* write-ratio for chunk cache */ + /* Turn on the chunk cache again */ + { + int mdc_nelmts; /* # of elements in metadata cache */ + size_t rdcc_nelmts; /* # of chunks in chunk cache */ + size_t rdcc_nbytes; /* # of bytes in chunk cache */ + double rdcc_w0; /* write-ratio for chunk cache */ - if(H5Pget_cache(my_fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) FAIL_STACK_ERROR - rdcc_nbytes = 1048576; - if(H5Pset_cache(my_fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) FAIL_STACK_ERROR - } /* end block */ + if (H5Pget_cache(my_fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) + FAIL_STACK_ERROR + rdcc_nbytes = 1048576; + if (H5Pset_cache(my_fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + FAIL_STACK_ERROR + } /* end block */ /* Check if we are using the latest version of the format */ - if(H5Pget_libver_bounds(my_fapl, &low, NULL) < 0) FAIL_STACK_ERROR + if (H5Pget_libver_bounds(my_fapl, &low, NULL) < 0) + FAIL_STACK_ERROR /* Create scalar dataspace */ - if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + if ((scalar_sid = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR /* Initialize chunk dimensions */ fill = EARRAY_CHUNK_DIM; @@ -8544,8 +9320,8 @@ test_chunk_fast(const char *env_h5_driver, hid_t fapl) H5VM_array_fill(hs_size, &fill, sizeof(fill), EARRAY_MAX_RANK); /* Loop over using SWMR access to write */ - for(swmr = 0; swmr <= 1; swmr++) { - int compress; /* Whether chunks should be compressed */ + for (swmr = 0; swmr <= 1; swmr++) { + int compress; /* Whether chunks should be compressed */ /* SWMR is now supported with/without latest format: */ /* (1) write+latest-format (2) SWMR-write+non-latest-format */ @@ -8553,59 +9329,67 @@ test_chunk_fast(const char *env_h5_driver, hid_t fapl) /* Skip this iteration if SWMR I/O is not supported for the VFD specified * by the environment variable. */ - if(swmr && !H5FD__supports_swmr_test(env_h5_driver)) + if (swmr && !H5FD__supports_swmr_test(env_h5_driver)) continue; #ifdef H5_HAVE_FILTER_DEFLATE /* Loop over compressing chunks */ - for(compress = 0; compress <= 1; compress++) + for (compress = 0; compress <= 1; compress++) #else /* Loop over without compression */ - for(compress = 0; compress <= 0; compress++) + for (compress = 0; compress <= 0; compress++) #endif /* H5_HAVE_FILTER_DEFLATE */ { - H5D_alloc_time_t alloc_time; /* Storage allocation time */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ /* Loop over storage allocation time */ - for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { - unsigned ndims; /* Current # of dims to test */ + for (alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + unsigned ndims; /* Current # of dims to test */ /* Loop over dataspace ranks to test */ - for(ndims = 1; ndims < (EARRAY_MAX_RANK + 1); ndims++) { + for (ndims = 1; ndims < (EARRAY_MAX_RANK + 1); ndims++) { unsigned unlim_dim; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Set chunking & chunk dims */ - if(H5Pset_chunk(dcpl, (int)ndims, chunk_dim) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, (int)ndims, chunk_dim) < 0) + FAIL_STACK_ERROR #ifdef H5_HAVE_FILTER_DEFLATE /* Check if we should compress the chunks */ - if(compress) - if(H5Pset_deflate(dcpl, 9) < 0) FAIL_STACK_ERROR + if (compress) + if (H5Pset_deflate(dcpl, 9) < 0) + FAIL_STACK_ERROR #endif /* H5_HAVE_FILTER_DEFLATE */ /* Set fill time */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + FAIL_STACK_ERROR /* Set allocation time */ - if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR + if (H5Pset_alloc_time(dcpl, alloc_time) < 0) + FAIL_STACK_ERROR /* Loop over which dimension is unlimited */ - for(unlim_dim = 0; unlim_dim < ndims; unlim_dim++) { - H5D_chunk_index_t idx_type; /* Dataset chunk index type */ + for (unlim_dim = 0; unlim_dim < ndims; unlim_dim++) { + H5D_chunk_index_t idx_type; /* Dataset chunk index type */ hsize_t dim[EARRAY_MAX_RANK], max_dim[EARRAY_MAX_RANK]; /* Dataset dimensions */ - hsize_t swizzled_dim[EARRAY_MAX_RANK]; /* Dimensions, with unlimited dimension moved to rank 0 */ - hsize_t down[EARRAY_MAX_RANK]; /* 'down' sizes, for computing array index */ - hsize_t hs_offset[EARRAY_MAX_RANK]; /* Hyperslab offset */ - hssize_t snpoints; /* # of points in dataspace extent (signed) */ - hsize_t npoints; /* # of points in dataspace extent */ - unsigned write_elem, read_elem; /* Element written/read */ - hsize_t u; /* Local index variable */ + hsize_t swizzled_dim[EARRAY_MAX_RANK]; /* Dimensions, with unlimited dimension moved + to rank 0 */ + hsize_t down[EARRAY_MAX_RANK]; /* 'down' sizes, for computing array index */ + hsize_t hs_offset[EARRAY_MAX_RANK]; /* Hyperslab offset */ + hssize_t snpoints; /* # of points in dataspace extent (signed) */ + hsize_t npoints; /* # of points in dataspace extent */ + unsigned write_elem, read_elem; /* Element written/read */ + hsize_t u; /* Local index variable */ /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (swmr ? H5F_ACC_SWMR_WRITE : 0), H5P_DEFAULT, my_fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (swmr ? H5F_ACC_SWMR_WRITE : 0), + H5P_DEFAULT, my_fapl)) < 0) + FAIL_STACK_ERROR /* Create n-D dataspace */ fill = EARRAY_DSET_DIM; @@ -8613,112 +9397,143 @@ test_chunk_fast(const char *env_h5_driver, hid_t fapl) fill = EARRAY_DSET_DIM; H5VM_array_fill(max_dim, &fill, sizeof(fill), EARRAY_MAX_RANK); max_dim[unlim_dim] = H5S_UNLIMITED; - fill = EARRAY_DSET_DIM; + fill = EARRAY_DSET_DIM; H5VM_array_fill(swizzled_dim, &fill, sizeof(fill), EARRAY_MAX_RANK); - if((sid = H5Screate_simple((int)ndims, dim, max_dim)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple((int)ndims, dim, max_dim)) < 0) + FAIL_STACK_ERROR /* Get the number of points in the dataspace */ - if((snpoints = H5Sget_simple_extent_npoints(sid)) < 0) FAIL_STACK_ERROR + if ((snpoints = H5Sget_simple_extent_npoints(sid)) < 0) + FAIL_STACK_ERROR npoints = (hsize_t)snpoints; /* Compute the "down" dimension values */ - if(H5VM_array_down(ndims, dim, down) < 0) FAIL_STACK_ERROR + if (H5VM_array_down(ndims, dim, down) < 0) + FAIL_STACK_ERROR /* Create chunked dataset */ - if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get the chunk index type */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(dsid, &idx_type) < 0) + FAIL_STACK_ERROR - /* Chunk index type expected depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST || swmr) { + /* Chunk index type expected depends on whether we are using the latest version of the + * format */ + if (low == H5F_LIBVER_LATEST || swmr) { /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index"); + if (idx_type != H5D_CHUNK_IDX_EARRAY) + FAIL_PUTS_ERROR("should be using extensible array as index"); } /* end if */ else { /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); } /* end else */ /* Fill existing elements */ - for(u = 0; u < npoints; u++) { + for (u = 0; u < npoints; u++) { /* Compute the coordinate from the linear offset */ - if(H5VM_array_calc_pre(u, ndims, down, hs_offset) < 0) FAIL_STACK_ERROR + if (H5VM_array_calc_pre(u, ndims, down, hs_offset) < 0) + FAIL_STACK_ERROR /* Un-swizzle hyperslab offset in same way as swizzled dimensions */ H5VM_unswizzle_coords(hsize_t, hs_offset, unlim_dim); /* Select a single element in the dataset */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + FAIL_STACK_ERROR /* Read (unwritten) element from dataset */ read_elem = 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR /* Verify unwritten element is fill value (0) */ - if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); + if (read_elem != 0) + FAIL_PUTS_ERROR("invalid unwritten element read"); /* Write element to dataset */ write_elem = (unsigned)u; - if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < + 0) + FAIL_STACK_ERROR /* Read element from dataset */ read_elem = write_elem + 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR /* Verify written element is read in */ - if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); + if (read_elem != write_elem) + FAIL_PUTS_ERROR("invalid written element read"); } /* end for */ /* Incrementally extend dataset and verify write/reads */ - while(dim[unlim_dim] < EARRAY_MAX_EXTEND) { - hssize_t snew_npoints; /* # of points in dataspace extent (signed) */ - hsize_t new_npoints; /* # of points in dataspace extent */ + while (dim[unlim_dim] < EARRAY_MAX_EXTEND) { + hssize_t snew_npoints; /* # of points in dataspace extent (signed) */ + hsize_t new_npoints; /* # of points in dataspace extent */ /* Extend dataset */ dim[unlim_dim] += EARRAY_EXTEND_INCR; swizzled_dim[0] += EARRAY_EXTEND_INCR; - if(H5Dset_extent(dsid, dim) < 0) FAIL_STACK_ERROR + if (H5Dset_extent(dsid, dim) < 0) + FAIL_STACK_ERROR /* Close old dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR /* Get dataspace for dataset now */ - if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR + if ((sid = H5Dget_space(dsid)) < 0) + FAIL_STACK_ERROR /* Get the new number of points in the dataspace */ - if((snew_npoints = H5Sget_simple_extent_npoints(sid)) < 0) FAIL_STACK_ERROR + if ((snew_npoints = H5Sget_simple_extent_npoints(sid)) < 0) + FAIL_STACK_ERROR new_npoints = (hsize_t)snew_npoints; /* Fill new elements */ - for(u = npoints; u < new_npoints; u++) { + for (u = npoints; u < new_npoints; u++) { /* Compute the coordinate from the linear offset */ - if(H5VM_array_calc(u, ndims, swizzled_dim, hs_offset) < 0) FAIL_STACK_ERROR + if (H5VM_array_calc(u, ndims, swizzled_dim, hs_offset) < 0) + FAIL_STACK_ERROR /* Un-swizzle hyperslab offset in same way as swizzled dimensions */ H5VM_unswizzle_coords(hsize_t, hs_offset, unlim_dim); /* Select a single element in the dataset */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < + 0) + FAIL_STACK_ERROR /* Read (unwritten) element from dataset */ read_elem = 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < + 0) + FAIL_STACK_ERROR /* Verify unwritten element is fill value (0) */ - if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); + if (read_elem != 0) + FAIL_PUTS_ERROR("invalid unwritten element read"); /* Write element to dataset */ write_elem = (unsigned)u; - if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, + &write_elem) < 0) + FAIL_STACK_ERROR /* Read element from dataset */ read_elem = write_elem + 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < + 0) + FAIL_STACK_ERROR /* Verify written element is read in */ - if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); + if (read_elem != write_elem) + FAIL_PUTS_ERROR("invalid written element read"); } /* end for */ /* Update the number of points in the dataspace */ @@ -8726,108 +9541,134 @@ test_chunk_fast(const char *env_h5_driver, hid_t fapl) } /* end while */ /* Close everything */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Re-open file & dataset */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY | (swmr ? H5F_ACC_SWMR_READ : 0), my_fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | (swmr ? H5F_ACC_SWMR_READ : 0), + my_fapl)) < 0) + FAIL_STACK_ERROR /* Open dataset */ - if((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the chunk index type */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(dsid, &idx_type) < 0) + FAIL_STACK_ERROR - /* Chunk index tyepe expected depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST || swmr) { + /* Chunk index tyepe expected depends on whether we are using the latest version of + * the format */ + if (low == H5F_LIBVER_LATEST || swmr) { /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index"); + if (idx_type != H5D_CHUNK_IDX_EARRAY) + FAIL_PUTS_ERROR("should be using extensible array as index"); } /* end if */ else { /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); } /* end else */ /* Get dataspace for dataset now */ - if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR + if ((sid = H5Dget_space(dsid)) < 0) + FAIL_STACK_ERROR /* Get the number of points in the dataspace */ - if((snpoints = H5Sget_simple_extent_npoints(sid)) < 0) FAIL_STACK_ERROR + if ((snpoints = H5Sget_simple_extent_npoints(sid)) < 0) + FAIL_STACK_ERROR npoints = (hsize_t)snpoints; /* Get the current dimensions into swizzled_dim array */ - if(H5Sget_simple_extent_dims(sid, swizzled_dim, NULL) < 0) FAIL_STACK_ERROR + if (H5Sget_simple_extent_dims(sid, swizzled_dim, NULL) < 0) + FAIL_STACK_ERROR /* Generate the swizzled dimensions */ H5VM_swizzle_coords(hsize_t, swizzled_dim, unlim_dim); /* Compute the "down" dimension values */ - if(H5VM_array_down(ndims, swizzled_dim, down) < 0) FAIL_STACK_ERROR + if (H5VM_array_down(ndims, swizzled_dim, down) < 0) + FAIL_STACK_ERROR /* Read elements */ - for(u = 0; u < npoints; u++) { + for (u = 0; u < npoints; u++) { /* Compute the coordinate from the linear offset */ - if(H5VM_array_calc_pre(u, ndims, down, hs_offset) < 0) FAIL_STACK_ERROR + if (H5VM_array_calc_pre(u, ndims, down, hs_offset) < 0) + FAIL_STACK_ERROR /* Unswizzle hyperslab offset in same way as swizzled dimensions */ H5VM_unswizzle_coords(hsize_t, hs_offset, unlim_dim); /* Select a single element in the dataset */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + FAIL_STACK_ERROR /* Read written element from dataset */ read_elem = (unsigned)(u + 1); - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR /* Verify written element is correct */ - if(read_elem != u) FAIL_PUTS_ERROR("invalid element read"); + if (read_elem != u) + FAIL_PUTS_ERROR("invalid element read"); } /* end for */ /* Close everything */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Re-open file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, my_fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, my_fapl)) < 0) + FAIL_STACK_ERROR /* Delete dataset */ - if(H5Ldelete(fid, "dset", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "dset", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close everything */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close everything */ - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR } /* end for */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Close everything */ - if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR - if(H5Pclose(my_fapl) < 0) FAIL_STACK_ERROR + if (H5Sclose(scalar_sid) < 0) + FAIL_STACK_ERROR + if (H5Pclose(my_fapl) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dsid); H5Sclose(sid); H5Sclose(scalar_sid); H5Fclose(fid); H5Pclose(my_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_chunk_fast() */ - /*------------------------------------------------------------------------- * Function: test_reopen_chunk_fast * @@ -8849,90 +9690,104 @@ error: static herr_t test_reopen_chunk_fast(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t scalar_sid = -1;/* Scalar dataspace ID */ - hid_t dsid = -1; /* Dataset ID */ - hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */ - hsize_t hs_offset; /* Hyperslab offset */ - hsize_t hs_size; /* Hyperslab size */ - H5D_alloc_time_t alloc_time; /* Storage allocation time */ - unsigned write_elem, read_elem; /* Element written/read */ - unsigned u; /* Local index variable */ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t scalar_sid = -1; /* Scalar dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */ + hsize_t hs_offset; /* Hyperslab offset */ + hsize_t hs_size; /* Hyperslab size */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ + unsigned write_elem, read_elem; /* Element written/read */ + unsigned u; /* Local index variable */ TESTING("datasets w/extensible array open/reopen with read/write"); h5_fixname(FILENAME[10], fapl, filename, sizeof filename); /* Loop over storage allocation time */ - for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { - /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + for (alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + /* Create file */ + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + /* Create dataset creation property list */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR - /* Set chunking */ - chunk_dim = 10; - if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR + /* Set chunking */ + chunk_dim = 10; + if (H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) + FAIL_STACK_ERROR - /* Set fill time */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR + /* Set fill time */ + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + FAIL_STACK_ERROR - /* Set allocation time */ - if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR + /* Set allocation time */ + if (H5Pset_alloc_time(dcpl, alloc_time) < 0) + FAIL_STACK_ERROR - /* Create scalar dataspace */ - if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + /* Create scalar dataspace */ + if ((scalar_sid = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR - /* Create 1-D dataspace */ - dim = 100; - max_dim = H5S_UNLIMITED; - if((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) FAIL_STACK_ERROR + /* Create 1-D dataspace */ + dim = 100; + max_dim = H5S_UNLIMITED; + if ((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) + FAIL_STACK_ERROR - /* Create chunked dataset */ - if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + /* Create chunked dataset */ + if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - /* Fill existing elements */ - hs_size = 1; - for(u = 0; u < 100; u++) { - /* Select a single element in the dataset */ - hs_offset = u; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) - FAIL_STACK_ERROR - /* Write element to dataset */ - write_elem = u; - if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) - FAIL_STACK_ERROR - } /* end for */ + /* Fill existing elements */ + hs_size = 1; + for (u = 0; u < 100; u++) { + /* Select a single element in the dataset */ + hs_offset = u; + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) + FAIL_STACK_ERROR + /* Write element to dataset */ + write_elem = u; + if (H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) + FAIL_STACK_ERROR + } /* end for */ - /* Close everything */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + /* Close everything */ + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR - /* Reopen the dataset */ - if((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + /* Reopen the dataset */ + if ((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR hs_size = 1; - /* Read from dataset */ - for(u = 0; u < 100; u++) { - /* Select a single element in the dataset */ - hs_offset = u; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) - FAIL_STACK_ERROR + /* Read from dataset */ + for (u = 0; u < 100; u++) { + /* Select a single element in the dataset */ + hs_offset = u; + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) + FAIL_STACK_ERROR - /* Read element from dataset */ - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) - FAIL_STACK_ERROR - } /* end for */ + /* Read element from dataset */ + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR + } /* end for */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(scalar_sid) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR } /* end for */ @@ -8940,17 +9795,18 @@ test_reopen_chunk_fast(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dsid); H5Sclose(sid); H5Sclose(scalar_sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_reopen_chunk_fast() */ - /*------------------------------------------------------------------------- * Function: test_chunk_fast_bug1 * @@ -8971,99 +9827,110 @@ error: static herr_t test_chunk_fast_bug1(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dsid = -1; /* Dataset ID */ - hsize_t dim[2], max_dim[2], chunk_dim[2]; /* Dataset and chunk dimensions */ - H5D_alloc_time_t alloc_time; /* Storage allocation time */ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t dim[2], max_dim[2], chunk_dim[2]; /* Dataset and chunk dimensions */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ - unsigned **wbuf = NULL; - unsigned **rbuf = NULL; - unsigned *wbuf_bytes = NULL; - unsigned *rbuf_bytes = NULL; + unsigned **wbuf = NULL; + unsigned **rbuf = NULL; + unsigned * wbuf_bytes = NULL; + unsigned * rbuf_bytes = NULL; - unsigned i, j; /* Local index variables */ + unsigned i, j; /* Local index variables */ TESTING("datasets w/extensible array chunk indexing bug"); h5_fixname(FILENAME[10], fapl, filename, sizeof filename); /* Set up data array */ - if(NULL == (wbuf_bytes = (unsigned *)HDcalloc(40 * 20, sizeof(unsigned)))) + if (NULL == (wbuf_bytes = (unsigned *)HDcalloc(40 * 20, sizeof(unsigned)))) TEST_ERROR; - if(NULL == (wbuf = (unsigned **)HDcalloc(40, sizeof(wbuf_bytes)))) + if (NULL == (wbuf = (unsigned **)HDcalloc(40, sizeof(wbuf_bytes)))) TEST_ERROR; for (i = 0; i < 40; i++) wbuf[i] = wbuf_bytes + (i * 20); - if(NULL == (rbuf_bytes = (unsigned *)HDcalloc(40 * 20, sizeof(unsigned)))) + if (NULL == (rbuf_bytes = (unsigned *)HDcalloc(40 * 20, sizeof(unsigned)))) TEST_ERROR; - if(NULL == (rbuf = (unsigned **)HDcalloc(40, sizeof(rbuf_bytes)))) + if (NULL == (rbuf = (unsigned **)HDcalloc(40, sizeof(rbuf_bytes)))) TEST_ERROR; for (i = 0; i < 40; i++) rbuf[i] = rbuf_bytes + (i * 20); /* Initialize write buffer */ - for(i=0; i<40; i++) - for(j=0; j<20; j++) + for (i = 0; i < 40; i++) + for (j = 0; j < 20; j++) wbuf[i][j] = (i * 20) + j; /* Create 2-D dataspace */ - dim[0] = 40; - dim[1] = 20; + dim[0] = 40; + dim[1] = 20; max_dim[0] = 40; max_dim[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dim, max_dim)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(2, dim, max_dim)) < 0) + FAIL_STACK_ERROR /* Loop over storage allocation time */ - for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + for (alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Set chunking */ chunk_dim[0] = 20; chunk_dim[1] = 10; - if(H5Pset_chunk(dcpl, 2, chunk_dim) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, 2, chunk_dim) < 0) + FAIL_STACK_ERROR /* Set allocation time */ - if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR + if (H5Pset_alloc_time(dcpl, alloc_time) < 0) + FAIL_STACK_ERROR /* Create chunked dataset */ - if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write buffer to dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_UINT, sid, sid, H5P_DEFAULT, wbuf_bytes) < 0) + if (H5Dwrite(dsid, H5T_NATIVE_UINT, sid, sid, H5P_DEFAULT, wbuf_bytes) < 0) FAIL_STACK_ERROR /* Close everything */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Reopen the dataset */ - if((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Read from dataset */ - if(H5Dread(dsid, H5T_NATIVE_UINT, sid, sid, H5P_DEFAULT, rbuf_bytes) < 0) + if (H5Dread(dsid, H5T_NATIVE_UINT, sid, sid, H5P_DEFAULT, rbuf_bytes) < 0) FAIL_STACK_ERROR /* Verify read data */ - for(i=0; i<40; i++) - for(j=0; j<20; j++) - if(wbuf[i][j] != rbuf[i][j]) + for (i = 0; i < 40; i++) + for (j = 0; j < 20; j++) + if (wbuf[i][j] != rbuf[i][j]) FAIL_PUTS_ERROR("invalid element read"); - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR } /* end for */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR HDfree(wbuf); HDfree(rbuf); @@ -9074,12 +9941,14 @@ test_chunk_fast_bug1(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dsid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(wbuf); HDfree(rbuf); @@ -9091,19 +9960,18 @@ error: /* This message derives from H5Z */ const H5Z_class2_t H5Z_EXPAND[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_EXPAND, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "expand", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_expand, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_EXPAND, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "expand", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_expand, /* The actual filter function */ }}; /* Global "expansion factor" for filter_expand() routine */ static size_t filter_expand_factor_g = 0; - /*------------------------------------------------------------------------- * Function: filter_expand * @@ -9125,19 +9993,19 @@ static size_t filter_expand_factor_g = 0; */ static size_t filter_expand(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t *buf_size, void H5_ATTR_UNUSED **buf) + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t *buf_size, + void H5_ATTR_UNUSED **buf) { - size_t ret_value = 0; + size_t ret_value = 0; - if(flags & H5Z_FLAG_REVERSE) { + if (flags & H5Z_FLAG_REVERSE) { /* Don't do anything when filter is applied in reverse */ *buf_size = nbytes; ret_value = nbytes; } /* end if */ else { /* Check for expanding the chunk */ - if(filter_expand_factor_g > 0) { + if (filter_expand_factor_g > 0) { /* Expand the buffer size beyond what can be encoded */ *buf_size = nbytes * 256 * 256 * 256 * filter_expand_factor_g; ret_value = *buf_size; @@ -9147,12 +10015,11 @@ filter_expand(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, *buf_size = nbytes; ret_value = nbytes; } /* end else */ - } /* end else */ + } /* end else */ return ret_value; } /* end filter_expand() */ - /*------------------------------------------------------------------------- * Function: test_chunk_expand * @@ -9170,364 +10037,495 @@ filter_expand(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, static herr_t test_chunk_expand(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property list ID */ - hid_t sid = -1, sid2 = -1; /* Dataspace ID */ - hid_t scalar_sid = -1; /* Scalar dataspace ID */ - hid_t dsid = -1, dsid2 = -1; /* Dataset ID */ - hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */ - hsize_t dim2[2], max_dim2[2], chunk_dim2[2]; /* Dataset and chunk dimensions */ - H5D_chunk_index_t idx_type, idx_type2; /* Dataset chunk index type */ - H5F_libver_t low, high; /* File format bounds */ - hsize_t hs_offset, hs_offset2[2]; /* Hyperslab offset */ - hsize_t hs_size, hs_size2[2]; /* Hyperslab size */ - H5D_alloc_time_t alloc_time; /* Storage allocation time */ - unsigned write_elem, read_elem; /* Element written/read */ - unsigned write_elem2, read_elem2; /* Element written/read */ - unsigned u; /* Local index variable */ - herr_t status; /* Generic return value */ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property list ID */ + hid_t sid = -1, sid2 = -1; /* Dataspace ID */ + hid_t scalar_sid = -1; /* Scalar dataspace ID */ + hid_t dsid = -1, dsid2 = -1; /* Dataset ID */ + hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */ + hsize_t dim2[2], max_dim2[2], chunk_dim2[2]; /* Dataset and chunk dimensions */ + H5D_chunk_index_t idx_type, idx_type2; /* Dataset chunk index type */ + H5F_libver_t low, high; /* File format bounds */ + hsize_t hs_offset, hs_offset2[2]; /* Hyperslab offset */ + hsize_t hs_size, hs_size2[2]; /* Hyperslab size */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ + unsigned write_elem, read_elem; /* Element written/read */ + unsigned write_elem2, read_elem2; /* Element written/read */ + unsigned u; /* Local index variable */ + herr_t status; /* Generic return value */ TESTING("filter expanding chunks too much"); h5_fixname(FILENAME[11], fapl, filename, sizeof filename); /* Check if we are using the latest version of the format */ - if(H5Pget_libver_bounds(fapl, &low, &high) < 0) FAIL_STACK_ERROR + if (H5Pget_libver_bounds(fapl, &low, &high) < 0) + FAIL_STACK_ERROR - if(sizeof(size_t) <= 4 && low != H5F_LIBVER_LATEST) { - SKIPPED(); - HDputs(" Current machine can't test for error w/old file format"); + if (sizeof(size_t) <= 4 && low != H5F_LIBVER_LATEST) { + SKIPPED(); + HDputs(" Current machine can't test for error w/old file format"); } /* end if */ else { /* Register "expansion" filter */ - if(H5Zregister(H5Z_EXPAND) < 0) FAIL_STACK_ERROR + if (H5Zregister(H5Z_EXPAND) < 0) + FAIL_STACK_ERROR /* Check that the filter was registered */ - if(TRUE != H5Zfilter_avail(H5Z_FILTER_EXPAND)) FAIL_STACK_ERROR + if (TRUE != H5Zfilter_avail(H5Z_FILTER_EXPAND)) + FAIL_STACK_ERROR /* Loop over storage allocation time */ - for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + for (alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Set chunking */ chunk_dim = chunk_dim2[0] = chunk_dim2[1] = 10; - if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl2, 2, chunk_dim2) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) + FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl2, 2, chunk_dim2) < 0) + FAIL_STACK_ERROR /* Set fill time */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR - if(H5Pset_fill_time(dcpl2, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + FAIL_STACK_ERROR + if (H5Pset_fill_time(dcpl2, H5D_FILL_TIME_ALLOC) < 0) + FAIL_STACK_ERROR /* Set allocation time */ - if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR - if(H5Pset_alloc_time(dcpl2, alloc_time) < 0) FAIL_STACK_ERROR + if (H5Pset_alloc_time(dcpl, alloc_time) < 0) + FAIL_STACK_ERROR + if (H5Pset_alloc_time(dcpl2, alloc_time) < 0) + FAIL_STACK_ERROR /* Set "expand" filter */ - if(H5Pset_filter(dcpl, H5Z_FILTER_EXPAND, 0, (size_t)0, NULL) < 0) FAIL_STACK_ERROR - if(H5Pset_filter(dcpl2, H5Z_FILTER_EXPAND, 0, (size_t)0, NULL) < 0) FAIL_STACK_ERROR + if (H5Pset_filter(dcpl, H5Z_FILTER_EXPAND, 0, (size_t)0, NULL) < 0) + FAIL_STACK_ERROR + if (H5Pset_filter(dcpl2, H5Z_FILTER_EXPAND, 0, (size_t)0, NULL) < 0) + FAIL_STACK_ERROR /* Create scalar dataspace */ - if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + if ((scalar_sid = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR /* Create 1-D and 2-D dataspace */ dim = dim2[0] = dim2[1] = 100; - max_dim = max_dim2[0] = max_dim2[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) FAIL_STACK_ERROR - if((sid2 = H5Screate_simple(2, dim2, max_dim2)) < 0) FAIL_STACK_ERROR + max_dim = max_dim2[0] = max_dim2[1] = H5S_UNLIMITED; + if ((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) + FAIL_STACK_ERROR + if ((sid2 = H5Screate_simple(2, dim2, max_dim2)) < 0) + FAIL_STACK_ERROR /* Create 1-D & 2-D chunked datasets */ - if(H5D_ALLOC_TIME_EARLY == alloc_time) { + if (H5D_ALLOC_TIME_EARLY == alloc_time) { /* Make the expansion factor large enough to cause failure right away */ filter_expand_factor_g = 8; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dsid >= 0) FAIL_PUTS_ERROR("should fail to create dataset when allocation time is early"); + } + H5E_END_TRY; + if (dsid >= 0) + FAIL_PUTS_ERROR("should fail to create dataset when allocation time is early"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dsid2 = H5Dcreate2(fid, "dset2", H5T_NATIVE_UINT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT); - } H5E_END_TRY; - if(dsid2 >= 0) FAIL_PUTS_ERROR("should fail to create dataset when allocation time is early"); + } + H5E_END_TRY; + if (dsid2 >= 0) + FAIL_PUTS_ERROR("should fail to create dataset when allocation time is early"); } /* end if */ else { - if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) FAIL_STACK_ERROR - if((dsid2 = H5Dcreate2(fid, "dset2", H5T_NATIVE_UINT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) + if ((dsid2 = H5Dcreate2(fid, "dset2", H5T_NATIVE_UINT, sid2, H5P_DEFAULT, dcpl2, + H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get the chunk index type */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR - if(H5D__layout_idx_type_test(dsid2, &idx_type2) < 0) FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(dsid, &idx_type) < 0) + FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(dsid2, &idx_type2) < 0) + FAIL_STACK_ERROR - /* Chunk index type expected depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST) { + /* Chunk index type expected depends on whether we are using the latest version of the format + */ + if (low == H5F_LIBVER_LATEST) { /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index"); - if(idx_type2 != H5D_CHUNK_IDX_BT2) FAIL_PUTS_ERROR("should be using v2 B-tree as index"); + if (idx_type != H5D_CHUNK_IDX_EARRAY) + FAIL_PUTS_ERROR("should be using extensible array as index"); + if (idx_type2 != H5D_CHUNK_IDX_BT2) + FAIL_PUTS_ERROR("should be using v2 B-tree as index"); } /* end if */ else { /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - if(idx_type2 != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (idx_type2 != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); } /* end else */ /* Fill elements */ hs_size = hs_size2[0] = hs_size2[1] = 1; - for(u = 0; u < 100; u++) { + for (u = 0; u < 100; u++) { hs_offset = hs_offset2[0] = hs_offset2[1] = u; /* Select a single element in the 1-D dataset */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) + FAIL_STACK_ERROR /* Select a single element in the 2-D dataset; NOT every element is selected */ - if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) + FAIL_STACK_ERROR /* Read (unwritten) element from dataset */ read_elem = read_elem2 = 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR - if(H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR + if (H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) + FAIL_STACK_ERROR /* Verify unwritten element is fill value (0) */ - if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); - if(read_elem2 != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); + if (read_elem != 0) + FAIL_PUTS_ERROR("invalid unwritten element read"); + if (read_elem2 != 0) + FAIL_PUTS_ERROR("invalid unwritten element read"); /* Don't expand chunks yet */ filter_expand_factor_g = 0; /* Write element to the datasets */ write_elem = write_elem2 = u; - if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR - if(H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2) < 0) + FAIL_STACK_ERROR /* Read element from the datasets */ - read_elem = write_elem + 1; + read_elem = write_elem + 1; read_elem2 = write_elem2 + 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR - if(H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR + if (H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) + FAIL_STACK_ERROR /* Verify written element is read in */ - if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); - if(read_elem2 != write_elem2) FAIL_PUTS_ERROR("invalid written element read"); + if (read_elem != write_elem) + FAIL_PUTS_ERROR("invalid written element read"); + if (read_elem2 != write_elem2) + FAIL_PUTS_ERROR("invalid written element read"); /* Expand chunks now */ filter_expand_factor_g = 8; /* Write element to the datasets */ write_elem = write_elem2 = u; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem); - } H5E_END_TRY; - if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); - - H5E_BEGIN_TRY { - status = H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2); - } H5E_END_TRY; - if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); + + H5E_BEGIN_TRY + { + status = + H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); } /* end for */ /* Incrementally extend dataset and verify write/reads */ - while(dim < 1000) { + while (dim < 1000) { /* Extend the datasets */ dim += 100; dim2[0] += 100; dim2[1] += 100; - if(H5Dset_extent(dsid, &dim) < 0) FAIL_STACK_ERROR - if(H5Dset_extent(dsid2, dim2) < 0) FAIL_STACK_ERROR + if (H5Dset_extent(dsid, &dim) < 0) + FAIL_STACK_ERROR + if (H5Dset_extent(dsid2, dim2) < 0) + FAIL_STACK_ERROR /* Close old dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid2) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid2) < 0) + FAIL_STACK_ERROR /* Get dataspace for the datasets now */ - if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR - if((sid2 = H5Dget_space(dsid2)) < 0) FAIL_STACK_ERROR + if ((sid = H5Dget_space(dsid)) < 0) + FAIL_STACK_ERROR + if ((sid2 = H5Dget_space(dsid2)) < 0) + FAIL_STACK_ERROR /* Fill new elements */ hs_size = hs_size2[0] = hs_size2[1] = 1; - for(u = 0; u < 100; u++) { + for (u = 0; u < 100; u++) { /* Select a single element in the datasets */ - hs_offset = (dim + u) - 100; + hs_offset = (dim + u) - 100; hs_offset2[0] = (dim2[0] + u) - 100; hs_offset2[1] = (dim2[1] + u) - 100; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR - if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) + FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) + FAIL_STACK_ERROR /* Read (unwritten) element from the datasets */ read_elem = read_elem2 = 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR - if(H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR + if (H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) + FAIL_STACK_ERROR /* Verify unwritten element is fill value (0) */ - if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); - if(read_elem2 != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); + if (read_elem != 0) + FAIL_PUTS_ERROR("invalid unwritten element read"); + if (read_elem2 != 0) + FAIL_PUTS_ERROR("invalid unwritten element read"); /* Don't expand chunks yet */ filter_expand_factor_g = 0; /* Write element to the datasets */ write_elem = write_elem2 = u; - if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR - if(H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2) < 0) + FAIL_STACK_ERROR /* Read element from the datasets */ - read_elem = write_elem + 1; + read_elem = write_elem + 1; read_elem2 = write_elem2 + 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR - if(H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR + if (H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) + FAIL_STACK_ERROR /* Verify written element is read in */ - if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); - if(read_elem2 != write_elem2) FAIL_PUTS_ERROR("invalid written element read"); + if (read_elem != write_elem) + FAIL_PUTS_ERROR("invalid written element read"); + if (read_elem2 != write_elem2) + FAIL_PUTS_ERROR("invalid written element read"); /* Expand chunks now */ filter_expand_factor_g = 8; /* Write element to the datasets */ write_elem = write_elem2 = u; - H5E_BEGIN_TRY { - status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem); - } H5E_END_TRY; - if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); - - H5E_BEGIN_TRY { - status = H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2); - } H5E_END_TRY; - if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); + H5E_BEGIN_TRY + { + status = + H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR( + "should fail to write to dataset when allocation time is not early"); + + H5E_BEGIN_TRY + { + status = + H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR( + "should fail to write to dataset when allocation time is not early"); } /* end for */ - } /* end while */ + } /* end while */ /* Close the datasets */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid2) < 0) FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid2) < 0) + FAIL_STACK_ERROR } /* end else */ /* Close everything */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid2) < 0) FAIL_STACK_ERROR - if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid2) < 0) + FAIL_STACK_ERROR + if (H5Sclose(scalar_sid) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* If the dataset was created, do some extra testing */ - if(H5D_ALLOC_TIME_EARLY != alloc_time) { + if (H5D_ALLOC_TIME_EARLY != alloc_time) { /* Re-open file & datasets */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Open the datasets */ - if((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((dsid2 = H5Dopen2(fid, "dset2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((dsid2 = H5Dopen2(fid, "dset2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the chunk index type for the two datasets */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR - if(H5D__layout_idx_type_test(dsid2, &idx_type2) < 0) FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(dsid, &idx_type) < 0) + FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(dsid2, &idx_type2) < 0) + FAIL_STACK_ERROR - /* Chunk index type expected depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST) { + /* Chunk index type expected depends on whether we are using the latest version of the format + */ + if (low == H5F_LIBVER_LATEST) { /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index"); - if(idx_type2 != H5D_CHUNK_IDX_BT2) FAIL_PUTS_ERROR("should be using v2 B-tree as index"); + if (idx_type != H5D_CHUNK_IDX_EARRAY) + FAIL_PUTS_ERROR("should be using extensible array as index"); + if (idx_type2 != H5D_CHUNK_IDX_BT2) + FAIL_PUTS_ERROR("should be using v2 B-tree as index"); } /* end if */ else { /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - if(idx_type2 != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + if (idx_type2 != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); } /* end else */ /* Create scalar dataspace */ - if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + if ((scalar_sid = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR /* Get dataspace for the datasets now */ - if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR - if((sid2 = H5Dget_space(dsid2)) < 0) FAIL_STACK_ERROR + if ((sid = H5Dget_space(dsid)) < 0) + FAIL_STACK_ERROR + if ((sid2 = H5Dget_space(dsid2)) < 0) + FAIL_STACK_ERROR /* Read elements */ hs_size = hs_size2[0] = hs_size2[1] = 1; - for(u = 0; u < 1000; u++) { + for (u = 0; u < 1000; u++) { /* Select a single element in the datasets */ hs_offset = hs_offset2[0] = hs_offset2[1] = u; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR - if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) + FAIL_STACK_ERROR + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) + FAIL_STACK_ERROR /* Read element from the datasets */ read_elem = read_elem2 = u + 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR - if(H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR + if (H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) + FAIL_STACK_ERROR /* Verify unwritten element is proper value */ - if(read_elem != (u % 100)) FAIL_PUTS_ERROR("invalid element read"); - if(read_elem2 != (u % 100)) FAIL_PUTS_ERROR("invalid element read"); + if (read_elem != (u % 100)) + FAIL_PUTS_ERROR("invalid element read"); + if (read_elem2 != (u % 100)) + FAIL_PUTS_ERROR("invalid element read"); /* Don't expand chunks yet */ filter_expand_factor_g = 0; /* Write element to the datasets */ write_elem = write_elem2 = u % 100; - if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR - if(H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2) < 0) + FAIL_STACK_ERROR /* Read element from the datasets */ - read_elem = write_elem + 1; + read_elem = write_elem + 1; read_elem2 = write_elem2 + 1; - if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR - if(H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) FAIL_STACK_ERROR + if (H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) + FAIL_STACK_ERROR + if (H5Dread(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &read_elem2) < 0) + FAIL_STACK_ERROR /* Verify written element is read in */ - if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); - if(read_elem2 != write_elem2) FAIL_PUTS_ERROR("invalid written element read"); + if (read_elem != write_elem) + FAIL_PUTS_ERROR("invalid written element read"); + if (read_elem2 != write_elem2) + FAIL_PUTS_ERROR("invalid written element read"); /* Expand chunks now */ filter_expand_factor_g = 8; /* Write element to the datasets */ write_elem = write_elem2 = u % 100; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem); - } H5E_END_TRY; - if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); - - H5E_BEGIN_TRY { - status = H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2); - } H5E_END_TRY; - if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); + + H5E_BEGIN_TRY + { + status = + H5Dwrite(dsid2, H5T_NATIVE_UINT, scalar_sid, sid2, H5P_DEFAULT, &write_elem2); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); } /* end for */ /* Close everything */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid2) < 0) FAIL_STACK_ERROR - if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid2) < 0) + FAIL_STACK_ERROR + if (H5Sclose(scalar_sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Re-open file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Delete the datasets */ - if(H5Ldelete(fid, "dset", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "dset2", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "dset", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "dset2", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close everything */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR } /* end if */ - } /* end for */ + } /* end for */ /* Unregister "expansion" filter */ - if(H5Zunregister(H5Z_FILTER_EXPAND) < 0) FAIL_STACK_ERROR + if (H5Zunregister(H5Z_FILTER_EXPAND) < 0) + FAIL_STACK_ERROR /* Check that the filter was unregistered */ - if(FALSE != H5Zfilter_avail(H5Z_FILTER_EXPAND)) FAIL_STACK_ERROR + if (FALSE != H5Zfilter_avail(H5Z_FILTER_EXPAND)) + FAIL_STACK_ERROR PASSED(); } /* end else */ @@ -9535,7 +10533,8 @@ test_chunk_expand(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(dcpl2); H5Dclose(dsid); @@ -9544,11 +10543,11 @@ error: H5Sclose(sid2); H5Sclose(scalar_sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_chunk_expand() */ - /*------------------------------------------------------------------------- * Function: test_fixed_array * @@ -9582,413 +10581,474 @@ error: static herr_t test_fixed_array(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; /* File name */ - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ + char filename[FILENAME_BUF_SIZE]; /* File name */ + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t sid = -1; /* Dataspace ID for dataset with fixed dimensions */ - hid_t sid_big = -1; /* Dataspate ID for big dataset */ - hid_t sid_max = -1; /* Dataspace ID for dataset with maximum dimensions set */ + hid_t sid = -1; /* Dataspace ID for dataset with fixed dimensions */ + hid_t sid_big = -1; /* Dataspate ID for big dataset */ + hid_t sid_max = -1; /* Dataspace ID for dataset with maximum dimensions set */ - hid_t dsid = -1; /* Dataset ID for dataset with fixed dimensions */ - hid_t dsid_big = -1; /* Dataset ID for big dataset with fixed dimensions */ - hid_t dsid_max = -1; /* Dataset ID for dataset with maximum dimensions set */ + hid_t dsid = -1; /* Dataset ID for dataset with fixed dimensions */ + hid_t dsid_big = -1; /* Dataset ID for big dataset with fixed dimensions */ + hid_t dsid_max = -1; /* Dataset ID for dataset with maximum dimensions set */ - hsize_t dim2[2] = {48, 18}; /* Dataset dimensions */ - const hsize_t dim2_big[2] = {500, 60}; /* Big dataset dimensions */ - hsize_t dim2_max[2] = {120, 50}; /* Maximum dataset dimensions */ + hsize_t dim2[2] = {48, 18}; /* Dataset dimensions */ + const hsize_t dim2_big[2] = {500, 60}; /* Big dataset dimensions */ + hsize_t dim2_max[2] = {120, 50}; /* Maximum dataset dimensions */ - hid_t mem_id; /* Memory space ID */ - hid_t big_mem_id; /* Memory space ID for big dataset */ + hid_t mem_id; /* Memory space ID */ + hid_t big_mem_id; /* Memory space ID for big dataset */ - hsize_t msize[1] = {POINTS}; /* Size of memory space */ - hsize_t msize_big[1] = {POINTS_BIG}; /* Size of memory space for big dataset */ + hsize_t msize[1] = {POINTS}; /* Size of memory space */ + hsize_t msize_big[1] = {POINTS_BIG}; /* Size of memory space for big dataset */ - int wbuf[POINTS]; /* write buffer */ - int *wbuf_big = NULL; /* write buffer for big dataset */ - int rbuf[POINTS]; /* read buffer */ - int *rbuf_big = NULL; /* read buffer for big dataset */ + int wbuf[POINTS]; /* write buffer */ + int *wbuf_big = NULL; /* write buffer for big dataset */ + int rbuf[POINTS]; /* read buffer */ + int *rbuf_big = NULL; /* read buffer for big dataset */ - const hsize_t chunk_dim2[2] = {4, 3}; /* Chunk dimensions */ + const hsize_t chunk_dim2[2] = {4, 3}; /* Chunk dimensions */ - int **chunks = NULL; /* # of chunks for dataset dimensions */ - int **chunks_big = NULL; /* # of chunks for big dataset dimensions */ - int *chunks_bytes = NULL; - int *chunks_big_bytes = NULL; + int **chunks = NULL; /* # of chunks for dataset dimensions */ + int **chunks_big = NULL; /* # of chunks for big dataset dimensions */ + int * chunks_bytes = NULL; + int * chunks_big_bytes = NULL; - int chunk_row; /* chunk row index */ - int chunk_col; /* chunk column index */ + int chunk_row; /* chunk row index */ + int chunk_col; /* chunk column index */ - hsize_t **coord = NULL; /* datdaset coordinates */ - hsize_t **coord_big = NULL; /* big datdaset coordinates */ - hsize_t *coord_bytes = NULL; - hsize_t *coord_big_bytes = NULL; + hsize_t **coord = NULL; /* datdaset coordinates */ + hsize_t **coord_big = NULL; /* big datdaset coordinates */ + hsize_t * coord_bytes = NULL; + hsize_t * coord_big_bytes = NULL; - H5D_chunk_index_t idx_type; /* Dataset chunk index type */ - H5F_libver_t low, high; /* File format bounds */ - H5D_alloc_time_t alloc_time; /* Storage allocation time */ + H5D_chunk_index_t idx_type; /* Dataset chunk index type */ + H5F_libver_t low, high; /* File format bounds */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ #ifdef H5_HAVE_FILTER_DEFLATE - unsigned compress; /* Whether chunks should be compressed */ -#endif /* H5_HAVE_FILTER_DEFLATE */ + unsigned compress; /* Whether chunks should be compressed */ +#endif /* H5_HAVE_FILTER_DEFLATE */ - h5_stat_size_t empty_size; /* Size of an empty file */ - h5_stat_size_t file_size; /* Size of each file created */ + h5_stat_size_t empty_size; /* Size of an empty file */ + h5_stat_size_t file_size; /* Size of each file created */ - size_t i, j; /* local index variables */ - herr_t ret; /* Generic return value */ - long ofs, inc; - long rows; - long cols; + size_t i, j; /* local index variables */ + herr_t ret; /* Generic return value */ + long ofs, inc; + long rows; + long cols; TESTING("datasets w/fixed array as chunk index"); h5_fixname(FILENAME[12], fapl, filename, sizeof filename); /* Set up 2D data arrays */ - if(NULL == (chunks_bytes = (int *)HDcalloc(12 * 6, sizeof(int)))) + if (NULL == (chunks_bytes = (int *)HDcalloc(12 * 6, sizeof(int)))) TEST_ERROR; - if(NULL == (chunks = (int **)HDcalloc(12, sizeof(chunks_bytes)))) + if (NULL == (chunks = (int **)HDcalloc(12, sizeof(chunks_bytes)))) TEST_ERROR; for (i = 0; i < 12; i++) chunks[i] = chunks_bytes + (i * 6); - if(NULL == (chunks_big_bytes = (int *)HDcalloc(125 * 20, sizeof(int)))) + if (NULL == (chunks_big_bytes = (int *)HDcalloc(125 * 20, sizeof(int)))) TEST_ERROR; - if(NULL == (chunks_big = (int **)HDcalloc(125, sizeof(chunks_big_bytes)))) + if (NULL == (chunks_big = (int **)HDcalloc(125, sizeof(chunks_big_bytes)))) TEST_ERROR; for (i = 0; i < 125; i++) chunks_big[i] = chunks_big_bytes + (i * 20); - if(NULL == (coord_bytes = (hsize_t *)HDcalloc(POINTS * 2, sizeof(hsize_t)))) + if (NULL == (coord_bytes = (hsize_t *)HDcalloc(POINTS * 2, sizeof(hsize_t)))) TEST_ERROR; - if(NULL == (coord = (hsize_t **)HDcalloc(POINTS, sizeof(coord_bytes)))) + if (NULL == (coord = (hsize_t **)HDcalloc(POINTS, sizeof(coord_bytes)))) TEST_ERROR; for (i = 0; i < POINTS; i++) coord[i] = coord_bytes + (i * 2); - if(NULL == (coord_big_bytes = (hsize_t *)HDcalloc(POINTS_BIG * 2, sizeof(hsize_t)))) + if (NULL == (coord_big_bytes = (hsize_t *)HDcalloc(POINTS_BIG * 2, sizeof(hsize_t)))) TEST_ERROR; - if(NULL == (coord_big = (hsize_t **)HDcalloc(POINTS_BIG, sizeof(coord_big_bytes)))) + if (NULL == (coord_big = (hsize_t **)HDcalloc(POINTS_BIG, sizeof(coord_big_bytes)))) TEST_ERROR; for (i = 0; i < POINTS_BIG; i++) coord_big[i] = coord_big_bytes + (i * 2); /* Check if we are using the latest version of the format */ - if(H5Pget_libver_bounds(fapl, &low, &high) < 0) FAIL_STACK_ERROR + if (H5Pget_libver_bounds(fapl, &low, &high) < 0) + FAIL_STACK_ERROR /* Create and close the file to get the file size */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) STACK_ERROR /* Get the size of the empty file */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Allocate the "big" buffers */ - if(NULL == (wbuf_big = (int *)HDmalloc(sizeof(int) * POINTS_BIG))) + if (NULL == (wbuf_big = (int *)HDmalloc(sizeof(int) * POINTS_BIG))) TEST_ERROR - if(NULL == (rbuf_big = (int *)HDmalloc(sizeof(int) * POINTS_BIG))) + if (NULL == (rbuf_big = (int *)HDmalloc(sizeof(int) * POINTS_BIG))) TEST_ERROR #ifdef H5_HAVE_FILTER_DEFLATE /* Loop over compressing chunks */ - for(compress = FALSE; compress <= TRUE; compress++) { + for (compress = FALSE; compress <= TRUE; compress++) { #endif /* H5_HAVE_FILTER_DEFLATE */ /* Loop over storage allocation time */ - for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + for (alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Set chunking */ - if((ret = H5Pset_chunk(dcpl, 2, chunk_dim2)) < 0) - FAIL_PUTS_ERROR(" Problem with setting chunk.") + if ((ret = H5Pset_chunk(dcpl, 2, chunk_dim2)) < 0) + FAIL_PUTS_ERROR(" Problem with setting chunk.") #ifdef H5_HAVE_FILTER_DEFLATE /* Check if we should compress the chunks */ - if(compress) - if(H5Pset_deflate(dcpl, 9) < 0) FAIL_STACK_ERROR + if (compress) + if (H5Pset_deflate(dcpl, 9) < 0) + FAIL_STACK_ERROR #endif /* H5_HAVE_FILTER_DEFLATE */ /* Set fill time */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + FAIL_STACK_ERROR /* Set allocation time */ - if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR - - /* Initialization of chunk array for repeated coordinates */ - for(i = 0; i < dim2[0]/chunk_dim2[0]; i++) - for(j = 0; j < dim2[1]/chunk_dim2[1]; j++) - chunks[i][j] = 0; - - rows = (long)(dim2[0]/chunk_dim2[0]); - cols = (long)(dim2[1]/chunk_dim2[1]); - make_random_offset_and_increment(rows * cols, &ofs, &inc); - - /* Generate random point coordinates. Only one point is selected per chunk */ - for(i = 0; i < POINTS; i++){ - H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); - H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); - ofs = (ofs + inc) % (rows * cols); - HDassert(!chunks[chunk_row][chunk_col]); - - wbuf[i] = chunks[chunk_row][chunk_col] = chunk_row+chunk_col+1; - coord[i][0] = (hsize_t)chunk_row * chunk_dim2[0]; - coord[i][1] = (hsize_t)chunk_col * chunk_dim2[1]; - } /* end for */ + if (H5Pset_alloc_time(dcpl, alloc_time) < 0) + FAIL_STACK_ERROR - /* Create first dataset with cur and max dimensions */ - if((sid_max = H5Screate_simple(2, dim2, dim2_max)) < 0) FAIL_STACK_ERROR - dsid_max = H5Dcreate2(fid, DSET_FIXED_MAX, H5T_NATIVE_INT, sid_max, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dsid_max < 0) - FAIL_PUTS_ERROR(" Creating Chunked Dataset with maximum dimensions.") + /* Initialization of chunk array for repeated coordinates */ + for (i = 0; i < dim2[0] / chunk_dim2[0]; i++) + for (j = 0; j < dim2[1] / chunk_dim2[1]; j++) + chunks[i][j] = 0; + + rows = (long)(dim2[0] / chunk_dim2[0]); + cols = (long)(dim2[1] / chunk_dim2[1]); + make_random_offset_and_increment(rows * cols, &ofs, &inc); + + /* Generate random point coordinates. Only one point is selected per chunk */ + for (i = 0; i < POINTS; i++) { + H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); + H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); + ofs = (ofs + inc) % (rows * cols); + HDassert(!chunks[chunk_row][chunk_col]); + + wbuf[i] = chunks[chunk_row][chunk_col] = chunk_row + chunk_col + 1; + coord[i][0] = (hsize_t)chunk_row * chunk_dim2[0]; + coord[i][1] = (hsize_t)chunk_col * chunk_dim2[1]; + } /* end for */ - /* Get the chunk index type */ - if(H5D__layout_idx_type_test(dsid_max, &idx_type) < 0) FAIL_STACK_ERROR + /* Create first dataset with cur and max dimensions */ + if ((sid_max = H5Screate_simple(2, dim2, dim2_max)) < 0) + FAIL_STACK_ERROR + dsid_max = + H5Dcreate2(fid, DSET_FIXED_MAX, H5T_NATIVE_INT, sid_max, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dsid_max < 0) + FAIL_PUTS_ERROR(" Creating Chunked Dataset with maximum dimensions.") - /* Chunk index type depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST) { - if(alloc_time == H5D_ALLOC_TIME_EARLY + /* Get the chunk index type */ + if (H5D__layout_idx_type_test(dsid_max, &idx_type) < 0) + FAIL_STACK_ERROR + + /* Chunk index type depends on whether we are using the latest version of the format */ + if (low == H5F_LIBVER_LATEST) { + if (alloc_time == H5D_ALLOC_TIME_EARLY #ifdef H5_HAVE_FILTER_DEFLATE - && !compress + && !compress #endif /* H5_HAVE_FILTER_DEFLATE */ - ) { - if(idx_type != H5D_CHUNK_IDX_NONE) - FAIL_PUTS_ERROR("should be using Non Index as index"); - } else if (idx_type != H5D_CHUNK_IDX_FARRAY) - FAIL_PUTS_ERROR("should be using Fixed Array as index"); - } /* end if */ - else { - if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - } /* end else */ - - /* Create dataspace for write buffer */ - if((mem_id = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; + ) { + if (idx_type != H5D_CHUNK_IDX_NONE) + FAIL_PUTS_ERROR("should be using Non Index as index"); + } + else if (idx_type != H5D_CHUNK_IDX_FARRAY) + FAIL_PUTS_ERROR("should be using Fixed Array as index"); + } /* end if */ + else { + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + } /* end else */ - /* Select the random points for writing */ - if(H5Sselect_elements(sid_max, H5S_SELECT_SET, POINTS, (const hsize_t *)coord_bytes) < 0) - TEST_ERROR; + /* Create dataspace for write buffer */ + if ((mem_id = H5Screate_simple(1, msize, NULL)) < 0) + TEST_ERROR; - /* Write into dataset */ - if(H5Dwrite(dsid_max, H5T_NATIVE_INT, mem_id, sid_max, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; + /* Select the random points for writing */ + if (H5Sselect_elements(sid_max, H5S_SELECT_SET, POINTS, (const hsize_t *)coord_bytes) < 0) + TEST_ERROR; - /* Closing */ - if(H5Dclose(dsid_max) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid_max) < 0) FAIL_STACK_ERROR - if(H5Sclose(mem_id) < 0) FAIL_STACK_ERROR + /* Write into dataset */ + if (H5Dwrite(dsid_max, H5T_NATIVE_INT, mem_id, sid_max, H5P_DEFAULT, wbuf) < 0) + TEST_ERROR; + /* Closing */ + if (H5Dclose(dsid_max) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid_max) < 0) + FAIL_STACK_ERROR + if (H5Sclose(mem_id) < 0) + FAIL_STACK_ERROR - /* Create second dataset with curr dim but NULL max dim */ - if((sid = H5Screate_simple(2, dim2, NULL)) < 0) FAIL_STACK_ERROR - dsid = H5Dcreate2(fid, DSET_FIXED_NOMAX, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dsid < 0) - FAIL_PUTS_ERROR(" Creating Chunked Dataset.") + /* Create second dataset with curr dim but NULL max dim */ + if ((sid = H5Screate_simple(2, dim2, NULL)) < 0) + FAIL_STACK_ERROR + dsid = H5Dcreate2(fid, DSET_FIXED_NOMAX, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dsid < 0) + FAIL_PUTS_ERROR(" Creating Chunked Dataset.") - /* Get the chunk index type */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR + /* Get the chunk index type */ + if (H5D__layout_idx_type_test(dsid, &idx_type) < 0) + FAIL_STACK_ERROR - /* Chunk index type depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST) { - if(alloc_time == H5D_ALLOC_TIME_EARLY + /* Chunk index type depends on whether we are using the latest version of the format */ + if (low == H5F_LIBVER_LATEST) { + if (alloc_time == H5D_ALLOC_TIME_EARLY #ifdef H5_HAVE_FILTER_DEFLATE - && !compress + && !compress #endif /* H5_HAVE_FILTER_DEFLATE */ - ) { - if(idx_type != H5D_CHUNK_IDX_NONE) - FAIL_PUTS_ERROR("should be using Non Index as index"); - } else if(idx_type != H5D_CHUNK_IDX_FARRAY) - FAIL_PUTS_ERROR("should be using Fixed Array as index"); - } else { - if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - } /* end else */ + ) { + if (idx_type != H5D_CHUNK_IDX_NONE) + FAIL_PUTS_ERROR("should be using Non Index as index"); + } + else if (idx_type != H5D_CHUNK_IDX_FARRAY) + FAIL_PUTS_ERROR("should be using Fixed Array as index"); + } + else { + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + } /* end else */ - /* Create dataspace for write buffer */ - if((mem_id = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; + /* Create dataspace for write buffer */ + if ((mem_id = H5Screate_simple(1, msize, NULL)) < 0) + TEST_ERROR; - /* Select the random points for writing */ - if(H5Sselect_elements(sid, H5S_SELECT_SET, POINTS, (const hsize_t *)coord_bytes) < 0) - TEST_ERROR; + /* Select the random points for writing */ + if (H5Sselect_elements(sid, H5S_SELECT_SET, POINTS, (const hsize_t *)coord_bytes) < 0) + TEST_ERROR; - /* Write into dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, mem_id, sid, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; + /* Write into dataset */ + if (H5Dwrite(dsid, H5T_NATIVE_INT, mem_id, sid, H5P_DEFAULT, wbuf) < 0) + TEST_ERROR; - /* Closing */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(mem_id) < 0) FAIL_STACK_ERROR + /* Closing */ + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(mem_id) < 0) + FAIL_STACK_ERROR - /* Create the third dataset with bigger size and both curr & max dimensions are the same */ - if((sid_big = H5Screate_simple(2, dim2_big, dim2_big)) < 0) FAIL_STACK_ERROR - dsid_big = H5Dcreate2(fid, DSET_FIXED_BIG, H5T_NATIVE_INT, sid_big, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dsid_big < 0) - FAIL_PUTS_ERROR(" Creating Big Chunked Dataset.") + /* Create the third dataset with bigger size and both curr & max dimensions are the same */ + if ((sid_big = H5Screate_simple(2, dim2_big, dim2_big)) < 0) + FAIL_STACK_ERROR + dsid_big = + H5Dcreate2(fid, DSET_FIXED_BIG, H5T_NATIVE_INT, sid_big, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dsid_big < 0) + FAIL_PUTS_ERROR(" Creating Big Chunked Dataset.") - /* Get the chunk index type */ - if(H5D__layout_idx_type_test(dsid_big, &idx_type) < 0) FAIL_STACK_ERROR + /* Get the chunk index type */ + if (H5D__layout_idx_type_test(dsid_big, &idx_type) < 0) + FAIL_STACK_ERROR - /* Chunk index type depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST) { - if(alloc_time == H5D_ALLOC_TIME_EARLY + /* Chunk index type depends on whether we are using the latest version of the format */ + if (low == H5F_LIBVER_LATEST) { + if (alloc_time == H5D_ALLOC_TIME_EARLY #ifdef H5_HAVE_FILTER_DEFLATE - && !compress + && !compress #endif /* H5_HAVE_FILTER_DEFLATE */ - ) { - if(idx_type != H5D_CHUNK_IDX_NONE) - FAIL_PUTS_ERROR("should be using Non Index as index"); - } else if(idx_type != H5D_CHUNK_IDX_FARRAY) - FAIL_PUTS_ERROR("should be using Fixed Array as index"); - } /* end if */ - else { - if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - } /* end else */ - - /* Initialization of chunk array for repeated coordinates */ - for(i = 0; i < dim2_big[0]/chunk_dim2[0]; i++) - for(j = 0; j < dim2_big[1]/chunk_dim2[1]; j++) - chunks_big[i][j] = 0; - - rows = (long)(dim2_big[0]/chunk_dim2[0]); - cols = (long)(dim2_big[1]/chunk_dim2[1]); - make_random_offset_and_increment(rows * cols, &ofs, &inc); - - /* Generate random point coordinates. Only one point is selected per chunk */ - for(i = 0; i < POINTS_BIG; i++){ - H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); - H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); - ofs = (ofs + inc) % (rows * cols); - HDassert(!chunks_big[chunk_row][chunk_col]); - - wbuf_big[i] = chunks_big[chunk_row][chunk_col] = chunk_row+chunk_col+1; - coord_big[i][0] = (hsize_t)chunk_row * chunk_dim2[0]; - coord_big[i][1] = (hsize_t)chunk_col * chunk_dim2[1]; - } /* end for */ + ) { + if (idx_type != H5D_CHUNK_IDX_NONE) + FAIL_PUTS_ERROR("should be using Non Index as index"); + } + else if (idx_type != H5D_CHUNK_IDX_FARRAY) + FAIL_PUTS_ERROR("should be using Fixed Array as index"); + } /* end if */ + else { + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + } /* end else */ - /* Create dataspace for write buffer */ - if((big_mem_id = H5Screate_simple(1, msize_big, NULL)) < 0) TEST_ERROR; + /* Initialization of chunk array for repeated coordinates */ + for (i = 0; i < dim2_big[0] / chunk_dim2[0]; i++) + for (j = 0; j < dim2_big[1] / chunk_dim2[1]; j++) + chunks_big[i][j] = 0; + + rows = (long)(dim2_big[0] / chunk_dim2[0]); + cols = (long)(dim2_big[1] / chunk_dim2[1]); + make_random_offset_and_increment(rows * cols, &ofs, &inc); + + /* Generate random point coordinates. Only one point is selected per chunk */ + for (i = 0; i < POINTS_BIG; i++) { + H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); + H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); + ofs = (ofs + inc) % (rows * cols); + HDassert(!chunks_big[chunk_row][chunk_col]); + + wbuf_big[i] = chunks_big[chunk_row][chunk_col] = chunk_row + chunk_col + 1; + coord_big[i][0] = (hsize_t)chunk_row * chunk_dim2[0]; + coord_big[i][1] = (hsize_t)chunk_col * chunk_dim2[1]; + } /* end for */ - /* Select the random points for writing */ - if(H5Sselect_elements(sid_big, H5S_SELECT_SET, POINTS_BIG, (const hsize_t *)coord_big_bytes) < 0) - TEST_ERROR; + /* Create dataspace for write buffer */ + if ((big_mem_id = H5Screate_simple(1, msize_big, NULL)) < 0) + TEST_ERROR; - /* Write into dataset */ - if(H5Dwrite(dsid_big, H5T_NATIVE_INT, big_mem_id, sid_big, H5P_DEFAULT, wbuf_big) < 0) TEST_ERROR; + /* Select the random points for writing */ + if (H5Sselect_elements(sid_big, H5S_SELECT_SET, POINTS_BIG, (const hsize_t *)coord_big_bytes) < 0) + TEST_ERROR; - /* Closing */ - if(H5Dclose(dsid_big) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid_big) < 0) FAIL_STACK_ERROR - if(H5Sclose(big_mem_id) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + /* Write into dataset */ + if (H5Dwrite(dsid_big, H5T_NATIVE_INT, big_mem_id, sid_big, H5P_DEFAULT, wbuf_big) < 0) + TEST_ERROR; - /* Open the first dataset */ - if((dsid = H5Dopen2(fid, DSET_FIXED_MAX, H5P_DEFAULT)) < 0) TEST_ERROR; + /* Closing */ + if (H5Dclose(dsid_big) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid_big) < 0) + FAIL_STACK_ERROR + if (H5Sclose(big_mem_id) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR - /* Get dataset dataspace */ - if((sid = H5Dget_space(dsid)) < 0) TEST_ERROR; + /* Open the first dataset */ + if ((dsid = H5Dopen2(fid, DSET_FIXED_MAX, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* Create dataspace for read buffer */ - if((mem_id = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; + /* Get dataset dataspace */ + if ((sid = H5Dget_space(dsid)) < 0) + TEST_ERROR; - /* Select the random points for reading */ - if(H5Sselect_elements (sid, H5S_SELECT_SET, POINTS, (const hsize_t *)coord_bytes) < 0) TEST_ERROR; + /* Create dataspace for read buffer */ + if ((mem_id = H5Screate_simple(1, msize, NULL)) < 0) + TEST_ERROR; - /* Read from dataset */ - if(H5Dread(dsid, H5T_NATIVE_INT, mem_id, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; + /* Select the random points for reading */ + if (H5Sselect_elements(sid, H5S_SELECT_SET, POINTS, (const hsize_t *)coord_bytes) < 0) + TEST_ERROR; - /* Verify that written and read data are the same */ - for(i = 0; i < POINTS; i++) - if(rbuf[i] != wbuf[i]){ - HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", - __LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); - TEST_ERROR; - } /* end if */ + /* Read from dataset */ + if (H5Dread(dsid, H5T_NATIVE_INT, mem_id, sid, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR; - /* Closing */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(mem_id) < 0) FAIL_STACK_ERROR + /* Verify that written and read data are the same */ + for (i = 0; i < POINTS; i++) + if (rbuf[i] != wbuf[i]) { + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", __LINE__, + (unsigned)i, wbuf[i], (unsigned)i, rbuf[i]); + TEST_ERROR; + } /* end if */ - /* Open the second dataset */ - if((dsid = H5Dopen2(fid, DSET_FIXED_NOMAX, H5P_DEFAULT)) < 0) TEST_ERROR; + /* Closing */ + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(mem_id) < 0) + FAIL_STACK_ERROR - /* Get dataset dataspace */ - if((sid = H5Dget_space(dsid)) < 0) TEST_ERROR; + /* Open the second dataset */ + if ((dsid = H5Dopen2(fid, DSET_FIXED_NOMAX, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* Create dataspace for read buffer */ - if((mem_id = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; + /* Get dataset dataspace */ + if ((sid = H5Dget_space(dsid)) < 0) + TEST_ERROR; - /* Select the random points for reading */ - if(H5Sselect_elements (sid, H5S_SELECT_SET, POINTS, (const hsize_t *)coord_bytes) < 0) TEST_ERROR; + /* Create dataspace for read buffer */ + if ((mem_id = H5Screate_simple(1, msize, NULL)) < 0) + TEST_ERROR; - /* Read from dataset */ - if(H5Dread(dsid, H5T_NATIVE_INT, mem_id, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; + /* Select the random points for reading */ + if (H5Sselect_elements(sid, H5S_SELECT_SET, POINTS, (const hsize_t *)coord_bytes) < 0) + TEST_ERROR; - /* Verify that written and read data are the same */ - for(i = 0; i < POINTS; i++) - if(rbuf[i] != wbuf[i]){ - HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", - __LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); - TEST_ERROR; - } /* end if */ + /* Read from dataset */ + if (H5Dread(dsid, H5T_NATIVE_INT, mem_id, sid, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR; - /* Closing */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(mem_id) < 0) FAIL_STACK_ERROR + /* Verify that written and read data are the same */ + for (i = 0; i < POINTS; i++) + if (rbuf[i] != wbuf[i]) { + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", __LINE__, + (unsigned)i, wbuf[i], (unsigned)i, rbuf[i]); + TEST_ERROR; + } /* end if */ - /* Open the third dataset */ - if((dsid_big = H5Dopen2(fid, DSET_FIXED_BIG, H5P_DEFAULT)) < 0) TEST_ERROR; - /* Get dataset dataspace */ - if((sid_big = H5Dget_space(dsid_big)) < 0) TEST_ERROR; + /* Closing */ + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(mem_id) < 0) + FAIL_STACK_ERROR - /* Create dataspace for read buffer */ - if((big_mem_id = H5Screate_simple(1, msize_big, NULL)) < 0) TEST_ERROR; + /* Open the third dataset */ + if ((dsid_big = H5Dopen2(fid, DSET_FIXED_BIG, H5P_DEFAULT)) < 0) + TEST_ERROR; + /* Get dataset dataspace */ + if ((sid_big = H5Dget_space(dsid_big)) < 0) + TEST_ERROR; - /* Select the random points for reading */ - if(H5Sselect_elements (sid_big, H5S_SELECT_SET, POINTS_BIG, (const hsize_t *)coord_big_bytes) < 0) TEST_ERROR; - /* Read from dataset */ - if(H5Dread(dsid_big, H5T_NATIVE_INT, big_mem_id, sid_big, H5P_DEFAULT, rbuf_big) < 0) TEST_ERROR; + /* Create dataspace for read buffer */ + if ((big_mem_id = H5Screate_simple(1, msize_big, NULL)) < 0) + TEST_ERROR; - /* Verify that written and read data are the same */ - for(i = 0; i < POINTS_BIG; i++) - if(rbuf_big[i] != wbuf_big[i]) { - HDprintf(" Line %d: Incorrect value, wbuf_bif[%u]=%d, rbuf_big[%u]=%d\n", - __LINE__,(unsigned)i,wbuf_big[i],(unsigned)i,rbuf_big[i]); - TEST_ERROR; - } /* end if */ + /* Select the random points for reading */ + if (H5Sselect_elements(sid_big, H5S_SELECT_SET, POINTS_BIG, (const hsize_t *)coord_big_bytes) < 0) + TEST_ERROR; + /* Read from dataset */ + if (H5Dread(dsid_big, H5T_NATIVE_INT, big_mem_id, sid_big, H5P_DEFAULT, rbuf_big) < 0) + TEST_ERROR; - /* Closing */ - if(H5Dclose(dsid_big) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid_big) < 0) FAIL_STACK_ERROR - if(H5Sclose(big_mem_id) < 0) FAIL_STACK_ERROR + /* Verify that written and read data are the same */ + for (i = 0; i < POINTS_BIG; i++) + if (rbuf_big[i] != wbuf_big[i]) { + HDprintf(" Line %d: Incorrect value, wbuf_bif[%u]=%d, rbuf_big[%u]=%d\n", __LINE__, + (unsigned)i, wbuf_big[i], (unsigned)i, rbuf_big[i]); + TEST_ERROR; + } /* end if */ + + /* Closing */ + if (H5Dclose(dsid_big) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid_big) < 0) + FAIL_STACK_ERROR + if (H5Sclose(big_mem_id) < 0) + FAIL_STACK_ERROR /* Delete datasets */ - if(H5Ldelete(fid, DSET_FIXED_BIG, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, DSET_FIXED_NOMAX, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, DSET_FIXED_MAX, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, DSET_FIXED_BIG, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, DSET_FIXED_NOMAX, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, DSET_FIXED_MAX, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close everything */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) - TEST_ERROR + /* Get the size of the file */ + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR - /* Verify the file is correct size */ - if(file_size != empty_size) - TEST_ERROR + /* Verify the file is correct size */ + if (file_size != empty_size) + TEST_ERROR } /* end for */ #ifdef H5_HAVE_FILTER_DEFLATE - } /* end for */ + } /* end for */ #endif /* H5_HAVE_FILTER_DEFLATE */ /* Release buffers */ @@ -10008,13 +11068,15 @@ test_fixed_array(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dsid); H5Sclose(sid); H5Sclose(mem_id); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(wbuf_big); HDfree(rbuf_big); @@ -10030,7 +11092,6 @@ error: return FAIL; } /* end test_fixed_array() */ - /*------------------------------------------------------------------------- * Function: test_single_chunk * @@ -10059,211 +11120,241 @@ error: static herr_t test_single_chunk(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; /* File name */ - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t t_dcpl = -1; /* Dataset creation property list ID */ - - hid_t sid = -1, sid_max = -1; /* Dataspace ID for dataset with fixed dimensions */ - hid_t did = -1, did_max = -1; /* Dataset ID for dataset with fixed dimensions */ - hsize_t dim2[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ - hsize_t t_dim2[2] = {DSET_TMP_DIM1, DSET_TMP_DIM2}; /* Dataset dimensions */ - int *wbuf = NULL; /* write buffer */ - int *t_wbuf = NULL; /* write buffer */ - int *rbuf = NULL; /* read buffer */ - int *t_rbuf = NULL; /* read buffer */ - - H5D_chunk_index_t idx_type; /* Dataset chunk index type */ - H5F_libver_t low, high; /* File format bounds */ - H5D_alloc_time_t alloc_time; /* Storage allocation time */ + char filename[FILENAME_BUF_SIZE]; /* File name */ + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t t_dcpl = -1; /* Dataset creation property list ID */ + + hid_t sid = -1, sid_max = -1; /* Dataspace ID for dataset with fixed dimensions */ + hid_t did = -1, did_max = -1; /* Dataset ID for dataset with fixed dimensions */ + hsize_t dim2[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ + hsize_t t_dim2[2] = {DSET_TMP_DIM1, DSET_TMP_DIM2}; /* Dataset dimensions */ + int * wbuf = NULL; /* write buffer */ + int * t_wbuf = NULL; /* write buffer */ + int * rbuf = NULL; /* read buffer */ + int * t_rbuf = NULL; /* read buffer */ + + H5D_chunk_index_t idx_type; /* Dataset chunk index type */ + H5F_libver_t low, high; /* File format bounds */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ #ifdef H5_HAVE_FILTER_DEFLATE - unsigned compress; /* Whether chunks should be compressed */ -#endif /* H5_HAVE_FILTER_DEFLATE */ + unsigned compress; /* Whether chunks should be compressed */ +#endif /* H5_HAVE_FILTER_DEFLATE */ - size_t n, i; /* local index variables */ - herr_t ret; /* Generic return value */ - h5_stat_size_t empty_size; /* Size of an empty file */ - h5_stat_size_t file_size; /* Size of each file created */ + size_t n, i; /* local index variables */ + herr_t ret; /* Generic return value */ + h5_stat_size_t empty_size; /* Size of an empty file */ + h5_stat_size_t file_size; /* Size of each file created */ TESTING("datasets w/Single Chunk indexing"); h5_fixname(FILENAME[17], fapl, filename, sizeof filename); /* Check if we are using the latest version of the format */ - if(H5Pget_libver_bounds(fapl, &low, &high) < 0) FAIL_STACK_ERROR + if (H5Pget_libver_bounds(fapl, &low, &high) < 0) + FAIL_STACK_ERROR /* Create and close the file to get the file size */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) STACK_ERROR /* Get the size of the empty file */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Allocate the buffers */ - if(NULL == (wbuf = (int *)HDmalloc(sizeof(int) * (DSET_DIM1 * DSET_DIM2)))) + if (NULL == (wbuf = (int *)HDmalloc(sizeof(int) * (DSET_DIM1 * DSET_DIM2)))) TEST_ERROR - if(NULL == (rbuf = (int *)HDmalloc(sizeof(int) * (DSET_DIM1 * DSET_DIM2)))) + if (NULL == (rbuf = (int *)HDmalloc(sizeof(int) * (DSET_DIM1 * DSET_DIM2)))) TEST_ERROR - if(NULL == (t_wbuf = (int *)HDmalloc(sizeof(int) * (DSET_TMP_DIM1 * DSET_TMP_DIM2)))) + if (NULL == (t_wbuf = (int *)HDmalloc(sizeof(int) * (DSET_TMP_DIM1 * DSET_TMP_DIM2)))) TEST_ERROR - if(NULL == (t_rbuf = (int *)HDmalloc(sizeof(int) * (DSET_TMP_DIM1 * DSET_TMP_DIM2)))) + if (NULL == (t_rbuf = (int *)HDmalloc(sizeof(int) * (DSET_TMP_DIM1 * DSET_TMP_DIM2)))) TEST_ERROR - for(i = n = 0; i < (DSET_DIM1 * DSET_DIM2); i++) - wbuf[i] = (int)n++; + for (i = n = 0; i < (DSET_DIM1 * DSET_DIM2); i++) + wbuf[i] = (int)n++; - for(i = n = 0; i < (DSET_TMP_DIM1* DSET_TMP_DIM2); i++) - t_wbuf[i] = (int)n++; + for (i = n = 0; i < (DSET_TMP_DIM1 * DSET_TMP_DIM2); i++) + t_wbuf[i] = (int)n++; #ifdef H5_HAVE_FILTER_DEFLATE /* Loop over compressing chunks */ - for(compress = FALSE; compress <= TRUE; compress++) { + for (compress = FALSE; compress <= TRUE; compress++) { #endif /* H5_HAVE_FILTER_DEFLATE */ /* Loop over storage allocation time */ - for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + for (alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if((t_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if ((t_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Set chunking */ - if((ret = H5Pset_chunk(dcpl, 2, dim2)) < 0) - FAIL_PUTS_ERROR(" Problem with setting chunk.") + if ((ret = H5Pset_chunk(dcpl, 2, dim2)) < 0) + FAIL_PUTS_ERROR(" Problem with setting chunk.") - if((ret = H5Pset_chunk(t_dcpl, 2, t_dim2)) < 0) - FAIL_PUTS_ERROR(" Problem with setting chunk.") + if ((ret = H5Pset_chunk(t_dcpl, 2, t_dim2)) < 0) + FAIL_PUTS_ERROR(" Problem with setting chunk.") #ifdef H5_HAVE_FILTER_DEFLATE /* Check if we should compress the chunks */ - if(compress) { - if(H5Pset_deflate(dcpl, 9) < 0) FAIL_STACK_ERROR - if(H5Pset_deflate(t_dcpl, 9) < 0) FAIL_STACK_ERROR - } + if (compress) { + if (H5Pset_deflate(dcpl, 9) < 0) + FAIL_STACK_ERROR + if (H5Pset_deflate(t_dcpl, 9) < 0) + FAIL_STACK_ERROR + } #endif /* H5_HAVE_FILTER_DEFLATE */ /* Set fill time */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR - if(H5Pset_fill_time(t_dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + FAIL_STACK_ERROR + if (H5Pset_fill_time(t_dcpl, H5D_FILL_TIME_ALLOC) < 0) + FAIL_STACK_ERROR /* Set allocation time */ - if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR - if(H5Pset_alloc_time(t_dcpl, alloc_time) < 0) FAIL_STACK_ERROR + if (H5Pset_alloc_time(dcpl, alloc_time) < 0) + FAIL_STACK_ERROR + if (H5Pset_alloc_time(t_dcpl, alloc_time) < 0) + FAIL_STACK_ERROR - /* Create first dataset with cur and max dimensions */ - if((sid_max = H5Screate_simple(2, dim2, dim2)) < 0) FAIL_STACK_ERROR - did_max = H5Dcreate2(fid, DSET_SINGLE_MAX, H5T_NATIVE_INT, sid_max, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(did_max < 0) - FAIL_PUTS_ERROR(" Creating Chunked Dataset with maximum dimensions.") + /* Create first dataset with cur and max dimensions */ + if ((sid_max = H5Screate_simple(2, dim2, dim2)) < 0) + FAIL_STACK_ERROR + did_max = + H5Dcreate2(fid, DSET_SINGLE_MAX, H5T_NATIVE_INT, sid_max, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (did_max < 0) + FAIL_PUTS_ERROR(" Creating Chunked Dataset with maximum dimensions.") - /* Get the chunk index type */ - if(H5D__layout_idx_type_test(did_max, &idx_type) < 0) FAIL_STACK_ERROR + /* Get the chunk index type */ + if (H5D__layout_idx_type_test(did_max, &idx_type) < 0) + FAIL_STACK_ERROR - /* Chunk index type depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST) { - if(idx_type != H5D_CHUNK_IDX_SINGLE) - FAIL_PUTS_ERROR("should be using Single Chunk indexing"); - } /* end if */ - else { - if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - } /* end else */ + /* Chunk index type depends on whether we are using the latest version of the format */ + if (low == H5F_LIBVER_LATEST) { + if (idx_type != H5D_CHUNK_IDX_SINGLE) + FAIL_PUTS_ERROR("should be using Single Chunk indexing"); + } /* end if */ + else { + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + } /* end else */ - /* Write into dataset */ - if(H5Dwrite(did_max, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; + /* Write into dataset */ + if (H5Dwrite(did_max, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + TEST_ERROR; - /* Closing */ - if(H5Dclose(did_max) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid_max) < 0) FAIL_STACK_ERROR + /* Closing */ + if (H5Dclose(did_max) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid_max) < 0) + FAIL_STACK_ERROR - /* Create second dataset with curr dim but NULL max dim */ - if((sid = H5Screate_simple(2, t_dim2, NULL)) < 0) FAIL_STACK_ERROR - did = H5Dcreate2(fid, DSET_SINGLE_NOMAX, H5T_NATIVE_INT, sid, H5P_DEFAULT, t_dcpl, H5P_DEFAULT); - if(did < 0) - FAIL_PUTS_ERROR(" Creating Chunked Dataset.") + /* Create second dataset with curr dim but NULL max dim */ + if ((sid = H5Screate_simple(2, t_dim2, NULL)) < 0) + FAIL_STACK_ERROR + did = H5Dcreate2(fid, DSET_SINGLE_NOMAX, H5T_NATIVE_INT, sid, H5P_DEFAULT, t_dcpl, H5P_DEFAULT); + if (did < 0) + FAIL_PUTS_ERROR(" Creating Chunked Dataset.") - /* Get the chunk index type */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) FAIL_STACK_ERROR - - /* Chunk index type depends on whether we are using the latest version of the format */ - if(low == H5F_LIBVER_LATEST) { - if(idx_type != H5D_CHUNK_IDX_SINGLE) - FAIL_PUTS_ERROR("should be using Single Chunk indexing"); - } else { - if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index"); - } /* end else */ + /* Get the chunk index type */ + if (H5D__layout_idx_type_test(did, &idx_type) < 0) + FAIL_STACK_ERROR - /* Write into dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, t_wbuf) < 0) TEST_ERROR; + /* Chunk index type depends on whether we are using the latest version of the format */ + if (low == H5F_LIBVER_LATEST) { + if (idx_type != H5D_CHUNK_IDX_SINGLE) + FAIL_PUTS_ERROR("should be using Single Chunk indexing"); + } + else { + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index"); + } /* end else */ - /* Closing */ - if(H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + /* Write into dataset */ + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, t_wbuf) < 0) + TEST_ERROR; - /* Open the first dataset */ - if((did_max = H5Dopen2(fid, DSET_SINGLE_MAX, H5P_DEFAULT)) < 0) TEST_ERROR; + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR - /* Read from dataset */ - if(H5Dread(did_max, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; + /* Open the first dataset */ + if ((did_max = H5Dopen2(fid, DSET_SINGLE_MAX, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* Verify that written and read data are the same */ - for(i = 0; i < (DSET_DIM1 * DSET_DIM2); i++) - if(rbuf[i] != wbuf[i]){ - HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", - __LINE__,(unsigned)i,wbuf[i],(unsigned)i,rbuf[i]); - TEST_ERROR; - } /* end if */ + /* Read from dataset */ + if (H5Dread(did_max, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR; - /* Closing */ - if(H5Dclose(did_max) < 0) FAIL_STACK_ERROR + /* Verify that written and read data are the same */ + for (i = 0; i < (DSET_DIM1 * DSET_DIM2); i++) + if (rbuf[i] != wbuf[i]) { + HDprintf(" Line %d: Incorrect value, wbuf[%u]=%d, rbuf[%u]=%d\n", __LINE__, + (unsigned)i, wbuf[i], (unsigned)i, rbuf[i]); + TEST_ERROR; + } /* end if */ - /* Open the second dataset */ - if((did = H5Dopen2(fid, DSET_SINGLE_NOMAX, H5P_DEFAULT)) < 0) TEST_ERROR; + /* Closing */ + if (H5Dclose(did_max) < 0) + FAIL_STACK_ERROR - HDmemset(rbuf, 0, sizeof(int) * (DSET_DIM1 * DSET_DIM2)); + /* Open the second dataset */ + if ((did = H5Dopen2(fid, DSET_SINGLE_NOMAX, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* Read from dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, t_rbuf) < 0) TEST_ERROR; + HDmemset(rbuf, 0, sizeof(int) * (DSET_DIM1 * DSET_DIM2)); - /* Verify that written and read data are the same */ - for(i = 0; i < (DSET_TMP_DIM1* DSET_TMP_DIM2); i++) - if(t_rbuf[i] != t_wbuf[i]) { - HDprintf(" Line %d: Incorrect value, t_wbuf[%u]=%d, t_rbuf[%u]=%d\n", - __LINE__,(unsigned)i,t_wbuf[i],(unsigned)i,t_rbuf[i]); - TEST_ERROR; - } /* end if */ + /* Read from dataset */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, t_rbuf) < 0) + TEST_ERROR; + + /* Verify that written and read data are the same */ + for (i = 0; i < (DSET_TMP_DIM1 * DSET_TMP_DIM2); i++) + if (t_rbuf[i] != t_wbuf[i]) { + HDprintf(" Line %d: Incorrect value, t_wbuf[%u]=%d, t_rbuf[%u]=%d\n", __LINE__, + (unsigned)i, t_wbuf[i], (unsigned)i, t_rbuf[i]); + TEST_ERROR; + } /* end if */ - /* Closing */ - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + /* Closing */ + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR - /* Delete datasets */ - if(H5Ldelete(fid, DSET_SINGLE_NOMAX, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, DSET_SINGLE_MAX, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + /* Delete datasets */ + if (H5Ldelete(fid, DSET_SINGLE_NOMAX, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, DSET_SINGLE_MAX, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close everything */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + /* Get the size of the file */ + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR } /* end for */ #ifdef H5_HAVE_FILTER_DEFLATE - } /* end for */ + } /* end for */ #endif /* H5_HAVE_FILTER_DEFLATE */ - /* Release buffers */ HDfree(wbuf); HDfree(rbuf); @@ -10274,7 +11365,8 @@ test_single_chunk(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(t_dcpl); H5Dclose(did); @@ -10282,19 +11374,19 @@ error: H5Sclose(sid); H5Sclose(sid_max); H5Fclose(fid); - } H5E_END_TRY; - if(wbuf) + } + H5E_END_TRY; + if (wbuf) HDfree(wbuf); - if(rbuf) + if (rbuf) HDfree(rbuf); - if(t_wbuf) + if (t_wbuf) HDfree(t_wbuf); - if(t_rbuf) + if (t_rbuf) HDfree(t_rbuf); return FAIL; } /* end test_single_chunk() */ - /*------------------------------------------------------------------------- * * test_idx_compatible(): @@ -10308,62 +11400,69 @@ error: static herr_t test_idx_compatible(void) { - hid_t fid = -1; /* File id */ - hid_t did = -1; /* Dataset id */ - const char *filename = NULL; /* old test file name */ - unsigned j; /* Local index variable */ - H5D_chunk_index_t idx_type; /* Chunked dataset index type */ + hid_t fid = -1; /* File id */ + hid_t did = -1; /* Dataset id */ + const char * filename = NULL; /* old test file name */ + unsigned j; /* Local index variable */ + H5D_chunk_index_t idx_type; /* Chunked dataset index type */ /* Output message about test being performed */ TESTING("compatibility for 1.6/1.8 datasets that use B-tree indexing"); - for(j = 0; j < NELMTS(OLD_FILENAME); j++) { + for (j = 0; j < NELMTS(OLD_FILENAME); j++) { - /* Generate correct name for test file by prepending the source path */ - filename = H5_get_srcdir_filename(OLD_FILENAME[j]); + /* Generate correct name for test file by prepending the source path */ + filename = H5_get_srcdir_filename(OLD_FILENAME[j]); - /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - TEST_ERROR + /* Open the file */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR - /* Should be able to read the dataset w/o filter created under 1.8/1.6 */ - if((did = H5Dopen2(fid, DSET, H5P_DEFAULT)) < 0) - TEST_ERROR + /* Should be able to read the dataset w/o filter created under 1.8/1.6 */ + if ((did = H5Dopen2(fid, DSET, H5P_DEFAULT)) < 0) + TEST_ERROR - /* Get the chunk index type */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) FAIL_STACK_ERROR + /* Get the chunk index type */ + if (H5D__layout_idx_type_test(did, &idx_type) < 0) + FAIL_STACK_ERROR - /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index") + /* Verify index type */ + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index") - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR - /* Should be able to read the dataset w/ filter created under 1.8/1.6 */ - if((did = H5Dopen2(fid, DSET_FILTER, H5P_DEFAULT)) < 0) - TEST_ERROR + /* Should be able to read the dataset w/ filter created under 1.8/1.6 */ + if ((did = H5Dopen2(fid, DSET_FILTER, H5P_DEFAULT)) < 0) + TEST_ERROR - /* Get the chunk index type */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) FAIL_STACK_ERROR + /* Get the chunk index type */ + if (H5D__layout_idx_type_test(did, &idx_type) < 0) + FAIL_STACK_ERROR - /* Verify index type */ - if(idx_type != H5D_CHUNK_IDX_BTREE) - FAIL_PUTS_ERROR("should be using v1 B-tree as index") + /* Verify index type */ + if (idx_type != H5D_CHUNK_IDX_BTREE) + FAIL_PUTS_ERROR("should be using v1 B-tree as index") - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR - /* Close the file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + /* Close the file */ + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR } PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); - H5Fclose(fid); - } H5E_END_TRY; + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end test_idx_compatible() */ @@ -10380,17 +11479,17 @@ error: static herr_t test_unfiltered_edge_chunks(hid_t fapl) { - hid_t fid = -1; /* File id */ - hid_t did = -1; /* Dataset id */ - hid_t sid = -1; /* Dataspace id */ - hid_t dcpl = -1; /* DCPL id */ - hsize_t dim[2] = {4, 3}; /* Dataset dimensions */ - hsize_t cdim[2] = {2, 2}; /* Chunk dimension */ - char wbuf[4][3]; /* Write buffer */ - char rbuf[4][3]; /* Read buffer */ - char filename[FILENAME_BUF_SIZE] = ""; /* old test file name */ - unsigned opts; /* Chunk options */ - unsigned i, j; /* Local index variables */ + hid_t fid = -1; /* File id */ + hid_t did = -1; /* Dataset id */ + hid_t sid = -1; /* Dataspace id */ + hid_t dcpl = -1; /* DCPL id */ + hsize_t dim[2] = {4, 3}; /* Dataset dimensions */ + hsize_t cdim[2] = {2, 2}; /* Chunk dimension */ + char wbuf[4][3]; /* Write buffer */ + char rbuf[4][3]; /* Read buffer */ + char filename[FILENAME_BUF_SIZE] = ""; /* old test file name */ + unsigned opts; /* Chunk options */ + unsigned i, j; /* Local index variables */ /* Output message about test being performed */ TESTING("disabled partial chunk filters"); @@ -10398,116 +11497,116 @@ test_unfiltered_edge_chunks(hid_t fapl) h5_fixname(FILENAME[14], fapl, filename, sizeof filename); /* Create the file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Register byte-counting filter */ - if(H5Zregister(H5Z_COUNT) < 0) + if (H5Zregister(H5Z_COUNT) < 0) TEST_ERROR /* Create dataspace */ - if((sid = H5Screate_simple(2, dim, NULL)) < 0) + if ((sid = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Set chunk dimensions */ - if(H5Pset_chunk(dcpl, 2, cdim) < 0) + if (H5Pset_chunk(dcpl, 2, cdim) < 0) TEST_ERROR /* Add "count" filter */ - if(H5Pset_filter(dcpl, H5Z_FILTER_COUNT, 0u, (size_t)0, NULL) < 0) + if (H5Pset_filter(dcpl, H5Z_FILTER_COUNT, 0u, (size_t)0, NULL) < 0) TEST_ERROR /* Disable filters on partial chunks */ - if(H5Pget_chunk_opts(dcpl, &opts) < 0) + if (H5Pget_chunk_opts(dcpl, &opts) < 0) TEST_ERROR opts |= H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS; - if(H5Pset_chunk_opts(dcpl, opts) < 0) + if (H5Pset_chunk_opts(dcpl, opts) < 0) TEST_ERROR /* Initialize write buffer */ - for(i=0; i current dims (but not unlimited) */ - dims[0] = STORAGE_SIZE_DIM1; - dims[1] = STORAGE_SIZE_DIM2; + dims[0] = STORAGE_SIZE_DIM1; + dims[1] = STORAGE_SIZE_DIM2; max_dims[0] = STORAGE_SIZE_MAX_DIM1; max_dims[1] = STORAGE_SIZE_MAX_DIM2; - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) + FAIL_STACK_ERROR /* Create chunked dataset */ - if((dsid = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize buffer to zeroes */ HDmemset(wdata, 0, sizeof(wdata)); /* write elements to dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Extend dataset's dimensions */ new_dims[0] = STORAGE_SIZE_DIM1 * 2; new_dims[1] = STORAGE_SIZE_DIM2 * 2; - if(H5Dset_extent(dsid, new_dims) < 0) FAIL_STACK_ERROR + if (H5Dset_extent(dsid, new_dims) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close dataset & dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Copy the dataset */ - if(H5Ocopy(fid, "dset2", fid, "dset2_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ocopy(fid, "dset2", fid, "dset2_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the copied dataset */ - if((dsid = H5Dopen2(fid, "dset2_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset2_copy", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close copied dataset */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Create 2D dataspace with max dims > current dims (but not unlimited) */ - dims[0] = STORAGE_SIZE_DIM1; - dims[1] = STORAGE_SIZE_DIM2; + dims[0] = STORAGE_SIZE_DIM1; + dims[1] = STORAGE_SIZE_DIM2; max_dims[0] = STORAGE_SIZE_MAX_DIM1; max_dims[1] = STORAGE_SIZE_MAX_DIM2; - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) + FAIL_STACK_ERROR /* Create chunked dataset, w/early allocation */ - if((dsid = H5Dcreate2(fid, "dset2a", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset2a", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize buffer to zeroes */ HDmemset(wdata, 0, sizeof(wdata)); /* write elements to dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Extend dataset's dimensions */ new_dims[0] = STORAGE_SIZE_DIM1 * 2; new_dims[1] = STORAGE_SIZE_DIM2 * 2; - if(H5Dset_extent(dsid, new_dims) < 0) FAIL_STACK_ERROR + if (H5Dset_extent(dsid, new_dims) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close dataset & dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Copy the dataset */ - if(H5Ocopy(fid, "dset2a", fid, "dset2a_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ocopy(fid, "dset2a", fid, "dset2a_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the copied dataset */ - if((dsid = H5Dopen2(fid, "dset2a_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset2a_copy", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close copied dataset */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Create 2D dataspace with max dims > current dims (and 1 unlimited dim) */ - dims[0] = STORAGE_SIZE_DIM1; - dims[1] = STORAGE_SIZE_DIM2; + dims[0] = STORAGE_SIZE_DIM1; + dims[1] = STORAGE_SIZE_DIM2; max_dims[0] = H5S_UNLIMITED; max_dims[1] = STORAGE_SIZE_MAX_DIM2; - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) + FAIL_STACK_ERROR /* Create chunked dataset */ - if((dsid = H5Dcreate2(fid, "dset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize buffer to zeroes */ HDmemset(wdata, 0, sizeof(wdata)); /* write elements to dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Extend dataset's dimensions */ new_dims[0] = STORAGE_SIZE_DIM1 * 2; new_dims[1] = STORAGE_SIZE_DIM2 * 2; - if(H5Dset_extent(dsid, new_dims) < 0) FAIL_STACK_ERROR + if (H5Dset_extent(dsid, new_dims) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close dataset & dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Copy the dataset */ - if(H5Ocopy(fid, "dset3", fid, "dset3_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ocopy(fid, "dset3", fid, "dset3_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the copied dataset */ - if((dsid = H5Dopen2(fid, "dset3_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset3_copy", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close copied dataset */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Create 2D dataspace with max dims > current dims (and 1 unlimited dim) */ - dims[0] = STORAGE_SIZE_DIM1; - dims[1] = STORAGE_SIZE_DIM2; + dims[0] = STORAGE_SIZE_DIM1; + dims[1] = STORAGE_SIZE_DIM2; max_dims[0] = H5S_UNLIMITED; max_dims[1] = STORAGE_SIZE_MAX_DIM2; - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) + FAIL_STACK_ERROR /* Create chunked dataset, w/early allocation */ - if((dsid = H5Dcreate2(fid, "dset3a", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset3a", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize buffer to zeroes */ HDmemset(wdata, 0, sizeof(wdata)); /* write elements to dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Extend dataset's dimensions */ new_dims[0] = STORAGE_SIZE_DIM1 * 2; new_dims[1] = STORAGE_SIZE_DIM2 * 2; - if(H5Dset_extent(dsid, new_dims) < 0) FAIL_STACK_ERROR + if (H5Dset_extent(dsid, new_dims) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close dataset & dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Copy the dataset */ - if(H5Ocopy(fid, "dset3a", fid, "dset3a_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ocopy(fid, "dset3a", fid, "dset3a_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the copied dataset */ - if((dsid = H5Dopen2(fid, "dset3a_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset3a_copy", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close copied dataset */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Create 2D dataspace with max dims > current dims (and 2 unlimited dims) */ - dims[0] = STORAGE_SIZE_DIM1; - dims[1] = STORAGE_SIZE_DIM2; + dims[0] = STORAGE_SIZE_DIM1; + dims[1] = STORAGE_SIZE_DIM2; max_dims[0] = H5S_UNLIMITED; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) + FAIL_STACK_ERROR /* Create chunked dataset */ - if((dsid = H5Dcreate2(fid, "dset4", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset4", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize buffer to zeroes */ HDmemset(wdata, 0, sizeof(wdata)); /* write elements to dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Extend dataset's dimensions */ new_dims[0] = STORAGE_SIZE_DIM1 * 2; new_dims[1] = STORAGE_SIZE_DIM2 * 2; - if(H5Dset_extent(dsid, new_dims) < 0) FAIL_STACK_ERROR + if (H5Dset_extent(dsid, new_dims) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close dataset & dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Copy the dataset */ - if(H5Ocopy(fid, "dset4", fid, "dset4_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ocopy(fid, "dset4", fid, "dset4_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the copied dataset */ - if((dsid = H5Dopen2(fid, "dset4_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset4_copy", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close copied dataset */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Create 2D dataspace with max dims > current dims (and 2 unlimited dims) */ - dims[0] = STORAGE_SIZE_DIM1; - dims[1] = STORAGE_SIZE_DIM2; + dims[0] = STORAGE_SIZE_DIM1; + dims[1] = STORAGE_SIZE_DIM2; max_dims[0] = H5S_UNLIMITED; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) + FAIL_STACK_ERROR /* Create chunked dataset, w/early allocation */ - if((dsid = H5Dcreate2(fid, "dset4a", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, "dset4a", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize buffer to zeroes */ HDmemset(wdata, 0, sizeof(wdata)); /* write elements to dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, wdata) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 6 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Extend dataset's dimensions */ new_dims[0] = STORAGE_SIZE_DIM1 * 2; new_dims[1] = STORAGE_SIZE_DIM2 * 2; - if(H5Dset_extent(dsid, new_dims) < 0) FAIL_STACK_ERROR + if (H5Dset_extent(dsid, new_dims) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close dataset & dataspace */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Copy the dataset */ - if(H5Ocopy(fid, "dset4a", fid, "dset4a_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ocopy(fid, "dset4a", fid, "dset4a_copy", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the copied dataset */ - if((dsid = H5Dopen2(fid, "dset4a_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset4a_copy", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the storage size */ - if(0 == (ssize = H5Dget_storage_size(dsid))) FAIL_STACK_ERROR - if((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) TEST_ERROR + if (0 == (ssize = H5Dget_storage_size(dsid))) + FAIL_STACK_ERROR + if ((sizeof(int) * 15 * STORAGE_SIZE_CHUNK_DIM1 * STORAGE_SIZE_CHUNK_DIM2) != ssize) + TEST_ERROR /* Close copied dataset */ - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dsid) < 0) + FAIL_STACK_ERROR /* Close rest */ - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(dcpl2); H5Dclose(dsid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_storage_size() */ - /*------------------------------------------------------------------------- * Function: test_power2up * @@ -11738,79 +12991,83 @@ error: static herr_t test_power2up(hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hsize_t dims[2]; /* Dataset dimension sizes */ - hsize_t max_dims[2]; /* Maximum dimension sizes */ - hsize_t chunk_dims[2]; /* Chunk dimensions */ - hsize_t ext_dims[2]; /* Extended dimension sizes */ - herr_t status; /* Error status */ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hsize_t dims[2]; /* Dataset dimension sizes */ + hsize_t max_dims[2]; /* Maximum dimension sizes */ + hsize_t chunk_dims[2]; /* Chunk dimensions */ + hsize_t ext_dims[2]; /* Extended dimension sizes */ + herr_t status; /* Error status */ TESTING("the next power of 2"); h5_fixname(FILENAME[24], fapl, filename, sizeof filename); /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Set dims[1] to ((2^63) -1) */ - dims[0] = 0; - dims[1] = ((hsize_t)1 << ((sizeof(hsize_t) * CHAR_BIT) -1)) - 1; + dims[0] = 0; + dims[1] = ((hsize_t)1 << ((sizeof(hsize_t) * CHAR_BIT) - 1)) - 1; max_dims[0] = max_dims[1] = H5S_UNLIMITED; - sid = H5Screate_simple(2, dims, max_dims); + sid = H5Screate_simple(2, dims, max_dims); /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - TEST_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR /* Set chunk size */ chunk_dims[0] = chunk_dims[1] = 1; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - TEST_ERROR + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + TEST_ERROR /* Create chunked dataset */ - if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT64, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - TEST_ERROR + if ((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT64, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR ext_dims[0] = 1; ext_dims[1] = dims[1] + 5; /* Extend to (2^63)+ */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Dset_extent(did, ext_dims); - } H5E_END_TRY; - if(status >= 0) - TEST_ERROR + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR /* Closing */ - if(H5Dclose(did) < 0) - TEST_ERROR - if(H5Sclose(sid) < 0) - TEST_ERROR - if(H5Pclose(dcpl) < 0) - TEST_ERROR - if(H5Fclose(fid) < 0) - TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR + if (H5Pclose(dcpl) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(did); H5Sclose(sid); H5Pclose(dcpl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_power2up() */ - /*------------------------------------------------------------------------- * Function: test_scatter * @@ -11826,34 +13083,35 @@ error: *------------------------------------------------------------------------- */ typedef struct scatter_info_t { - int *src_buf; /* Source data buffer */ + int * src_buf; /* Source data buffer */ size_t block; /* Maximum number of elements to return to H5Dscatter() */ size_t size; /* Remaining number of elements to return */ } scatter_info_t; -#define TEST_SCATTER_CHECK_ARR(ARR, EXP) \ - for(i=0; i<(int)(sizeof(ARR)/sizeof(ARR[0])); i++) \ - for(j=0; j<(int)(sizeof(ARR[0])/sizeof(ARR[0][0])); j++) \ - for(k=0; k<(int)(sizeof(ARR[0][0])/sizeof(ARR[0][0][0])); k++) \ - if(ARR[i][j][k] != EXP[i][j][k]) { \ - H5_FAILED(); AT(); \ - HDprintf(" " #ARR "[%d][%d][%d] == %d, " #EXP "[%d][%d][%d] == %d\n", i, j, k, ARR[i][j][k], i, j, k, EXP[i][j][k]); \ - goto error; \ +#define TEST_SCATTER_CHECK_ARR(ARR, EXP) \ + for (i = 0; i < (int)(sizeof(ARR) / sizeof(ARR[0])); i++) \ + for (j = 0; j < (int)(sizeof(ARR[0]) / sizeof(ARR[0][0])); j++) \ + for (k = 0; k < (int)(sizeof(ARR[0][0]) / sizeof(ARR[0][0][0])); k++) \ + if (ARR[i][j][k] != EXP[i][j][k]) { \ + H5_FAILED(); \ + AT(); \ + HDprintf(" " #ARR "[%d][%d][%d] == %d, " #EXP "[%d][%d][%d] == %d\n", i, j, k, \ + ARR[i][j][k], i, j, k, EXP[i][j][k]); \ + goto error; \ } static herr_t -scatter_cb(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, - void *_scatter_info) +scatter_cb(void **src_buf /*out*/, size_t *src_buf_bytes_used /*out*/, void *_scatter_info) { scatter_info_t *scatter_info = (scatter_info_t *)_scatter_info; - size_t nelmts; /* Number of elements to return in src_buf */ + size_t nelmts; /* Number of elements to return in src_buf */ /* Calculate number of elements */ nelmts = MIN(scatter_info->block, scatter_info->size); HDassert(nelmts > 0); /* Set output variables */ - *src_buf = (void *)scatter_info->src_buf; + *src_buf = (void *)scatter_info->src_buf; *src_buf_bytes_used = nelmts * sizeof(scatter_info->src_buf[0]); /* Update scatter_info */ @@ -11866,32 +13124,32 @@ scatter_cb(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, static herr_t test_scatter(void) { - hid_t sid = -1; /* Dataspace ID */ - hsize_t dim[3] = {8, 5, 8}; /* Dataspace dimensions */ - hsize_t start[3] = {0, 0, 0}; - hsize_t stride[3] = {0, 0, 0}; - hsize_t count[3] = {0, 0, 0}; - hsize_t block[3] = {0, 0, 0}; - hsize_t start2[3] = {0, 0, 0}; - hsize_t count2[3] = {0, 0, 0}; - hsize_t point[4][3] = {{2, 3, 2}, {3, 0, 2}, {7, 2, 0}, {0, 1, 5}}; - size_t src_buf_size; - int src_buf[36]; /* Source data buffer */ - int dst_buf[8][5][8]; /* Destination data buffer */ - int expect_dst_buf[8][5][8]; /* Expected destination data buffer */ - scatter_info_t scatter_info; /* Operator data for callback */ - int i, j, k, src_i; /* Local index variables */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim[3] = {8, 5, 8}; /* Dataspace dimensions */ + hsize_t start[3] = {0, 0, 0}; + hsize_t stride[3] = {0, 0, 0}; + hsize_t count[3] = {0, 0, 0}; + hsize_t block[3] = {0, 0, 0}; + hsize_t start2[3] = {0, 0, 0}; + hsize_t count2[3] = {0, 0, 0}; + hsize_t point[4][3] = {{2, 3, 2}, {3, 0, 2}, {7, 2, 0}, {0, 1, 5}}; + size_t src_buf_size; + int src_buf[36]; /* Source data buffer */ + int dst_buf[8][5][8]; /* Destination data buffer */ + int expect_dst_buf[8][5][8]; /* Expected destination data buffer */ + scatter_info_t scatter_info; /* Operator data for callback */ + int i, j, k, src_i; /* Local index variables */ TESTING("H5Dscatter()"); /* Create dataspace */ - if((sid = H5Screate_simple(3, dim, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(3, dim, NULL)) < 0) + TEST_ERROR /* Initialize src_buf */ - for(i=0; i<(int)(sizeof(src_buf)/sizeof(src_buf[0])); i++) + for (i = 0; i < (int)(sizeof(src_buf) / sizeof(src_buf[0])); i++) src_buf[i] = i + 1; - /* * Test 1: Simple case */ @@ -11899,33 +13157,32 @@ test_scatter(void) count[0] = 1; count[1] = 1; count[2] = 8; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - /* Initialize dst_buf and expect_dst_buf */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); - for(i=0; i<8; i++) + /* Initialize dst_buf and expect_dst_buf */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + for (i = 0; i < 8; i++) expect_dst_buf[0][0][i] = src_buf[i]; /* Loop over buffer sizes */ - for(src_buf_size=1; src_buf_size<=9; src_buf_size++) { + for (src_buf_size = 1; src_buf_size <= 9; src_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Set up scatter info */ scatter_info.src_buf = src_buf; - scatter_info.block = src_buf_size; - scatter_info.size = 8; + scatter_info.block = src_buf_size; + scatter_info.size = 8; /* Scatter data */ - if(H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) + if (H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) TEST_ERROR /* Verify data */ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf) } /* end for */ - /* * Test 2: Single block in dataset */ @@ -11936,94 +13193,89 @@ test_scatter(void) count[0] = 2; count[1] = 3; count[2] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + /* Initialize expect_dst_buf */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); src_i = 0; - for(i=3; i<5; i++) - for(j=2; j<5; j++) - for(k=4; k<6; k++) + for (i = 3; i < 5; i++) + for (j = 2; j < 5; j++) + for (k = 4; k < 6; k++) expect_dst_buf[i][j][k] = src_buf[src_i++]; /* Loop over buffer sizes */ - for(src_buf_size=1; src_buf_size<=13; src_buf_size++) { + for (src_buf_size = 1; src_buf_size <= 13; src_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Set up scatter info */ scatter_info.src_buf = src_buf; - scatter_info.block = src_buf_size; - scatter_info.size = 12; + scatter_info.block = src_buf_size; + scatter_info.size = 12; /* Scatter data */ - if(H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) + if (H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) TEST_ERROR /* Verify data */ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf) } /* end for */ - /* * Test 3: Multiple blocks */ /* Select hyperslab */ - start[0] = 1; - start[1] = 1; - start[2] = 1; + start[0] = 1; + start[1] = 1; + start[2] = 1; stride[0] = 3; stride[1] = 4; stride[2] = 5; - count[0] = 3; - count[1] = 1; - count[2] = 2; - block[0] = 1; - block[1] = 3; - block[2] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride ,count, block) < 0) + count[0] = 3; + count[1] = 1; + count[2] = 2; + block[0] = 1; + block[1] = 3; + block[2] = 2; + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - /* Iterate over block containing selection, checking if each element is in - * selection. Note that the algorithm used here (if statement) would not - * work for overlapping hyperslabs. */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + /* Initialize expect_dst_buf */ + /* Iterate over block containing selection, checking if each element is in + * selection. Note that the algorithm used here (if statement) would not + * work for overlapping hyperslabs. */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); src_i = 0; - for(i=1; i<8; i++) - for(j=1; j<4; j++) - for(k=1; k<8; k++) - if((hsize_t)i >= start[0] - && ((hsize_t)i - start[0]) % stride[0] < block[0] - && ((hsize_t)i - start[0]) / stride[0] < count[0] - && (hsize_t)j >= start[1] - && ((hsize_t)j - start[1]) % stride[1] < block[1] - && ((hsize_t)j - start[1]) / stride[1] < count[1] - && (hsize_t)k >= start[2] - && ((hsize_t)k - start[2]) % stride[2] < block[2] - && ((hsize_t)k - start[2]) / stride[2] < count[2]) + for (i = 1; i < 8; i++) + for (j = 1; j < 4; j++) + for (k = 1; k < 8; k++) + if ((hsize_t)i >= start[0] && ((hsize_t)i - start[0]) % stride[0] < block[0] && + ((hsize_t)i - start[0]) / stride[0] < count[0] && (hsize_t)j >= start[1] && + ((hsize_t)j - start[1]) % stride[1] < block[1] && + ((hsize_t)j - start[1]) / stride[1] < count[1] && (hsize_t)k >= start[2] && + ((hsize_t)k - start[2]) % stride[2] < block[2] && + ((hsize_t)k - start[2]) / stride[2] < count[2]) expect_dst_buf[i][j][k] = src_buf[src_i++]; /* Loop over buffer sizes */ - for(src_buf_size=1; src_buf_size<=37; src_buf_size++) { + for (src_buf_size = 1; src_buf_size <= 37; src_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Set up scatter info */ scatter_info.src_buf = src_buf; - scatter_info.block = src_buf_size; - scatter_info.size = 36; + scatter_info.block = src_buf_size; + scatter_info.size = 36; /* Scatter data */ - if(H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) + if (H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) TEST_ERROR /* Verify data */ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf) } /* end for */ - /* * Test 4: Compound selection */ @@ -12034,7 +13286,7 @@ test_scatter(void) count[0] = 2; count[1] = 3; count[2] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start2[0] = 1; start2[1] = 2; @@ -12042,93 +13294,92 @@ test_scatter(void) count2[0] = 3; count2[1] = 2; count2[2] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_XOR, start2, NULL ,count2, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_XOR, start2, NULL, count2, NULL) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - /* Iterate over block containing selection, checking if each element is in - * selection. */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + /* Initialize expect_dst_buf */ + /* Iterate over block containing selection, checking if each element is in + * selection. */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); src_i = 0; - for(i=1; i<4; i++) - for(j=1; j<4; j++) - for(k=1; k<4; k++) - if(!(((hsize_t)i >= start[0] && (hsize_t)i < start[0] + count[0]) - && ((hsize_t)j >= start[1] && (hsize_t)j < start[1] + count[1]) - && ((hsize_t)k >= start[2] && (hsize_t)k < start[2] + count[2])) - != !(((hsize_t)i >= start2[0] && (hsize_t)i < start2[0] + count2[0]) - && ((hsize_t)j >= start2[1] && (hsize_t)j < start2[1] + count2[1]) - && ((hsize_t)k >= start2[2] && (hsize_t)k < start2[2] + count2[2]))) + for (i = 1; i < 4; i++) + for (j = 1; j < 4; j++) + for (k = 1; k < 4; k++) + if (!(((hsize_t)i >= start[0] && (hsize_t)i < start[0] + count[0]) && + ((hsize_t)j >= start[1] && (hsize_t)j < start[1] + count[1]) && + ((hsize_t)k >= start[2] && (hsize_t)k < start[2] + count[2])) != + !(((hsize_t)i >= start2[0] && (hsize_t)i < start2[0] + count2[0]) && + ((hsize_t)j >= start2[1] && (hsize_t)j < start2[1] + count2[1]) && + ((hsize_t)k >= start2[2] && (hsize_t)k < start2[2] + count2[2]))) expect_dst_buf[i][j][k] = src_buf[src_i++]; /* Loop over buffer sizes */ - for(src_buf_size=1; src_buf_size<=17; src_buf_size++) { + for (src_buf_size = 1; src_buf_size <= 17; src_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Set up scatter info */ scatter_info.src_buf = src_buf; - scatter_info.block = src_buf_size; - scatter_info.size = 16; + scatter_info.block = src_buf_size; + scatter_info.size = 16; /* Scatter data */ - if(H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) + if (H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) TEST_ERROR /* Verify data */ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf) } /* end for */ - /* * Test 5: Point selection */ /* Select hyperslabs */ - if(H5Sselect_elements(sid, H5S_SELECT_SET, sizeof(point) / sizeof(point[0]), (hsize_t *)point) < 0) + if (H5Sselect_elements(sid, H5S_SELECT_SET, sizeof(point) / sizeof(point[0]), (hsize_t *)point) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - /* Iterate over block containing selection, checking if each element is in - * selection. */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); - for(i=0; i<(int)(sizeof(point) / sizeof(point[0])); i++) - expect_dst_buf[point[i][0]][point[i][1]][point[i][2]] - = src_buf[i]; + /* Initialize expect_dst_buf */ + /* Iterate over block containing selection, checking if each element is in + * selection. */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + for (i = 0; i < (int)(sizeof(point) / sizeof(point[0])); i++) + expect_dst_buf[point[i][0]][point[i][1]][point[i][2]] = src_buf[i]; /* Loop over buffer sizes */ - for(src_buf_size=1; src_buf_size<=5; src_buf_size++) { + for (src_buf_size = 1; src_buf_size <= 5; src_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Set up scatter info */ scatter_info.src_buf = src_buf; - scatter_info.block = src_buf_size; - scatter_info.size = 4; + scatter_info.block = src_buf_size; + scatter_info.size = 4; /* Scatter data */ - if(H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) + if (H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) TEST_ERROR /* Verify data */ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf) } /* end for */ - /* Close everything */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_scatter() */ - /*------------------------------------------------------------------------- * Function: test_gather * @@ -12144,18 +13395,17 @@ error: *------------------------------------------------------------------------- */ typedef struct gather_info_t { - int *expect_dst_buf; /* Expected destination data buffer */ - size_t max_nelmts; /* Maximum number of elements passed to callback */ - hbool_t last_call; /* Whether this should be the last time the callback is called */ + int * expect_dst_buf; /* Expected destination data buffer */ + size_t max_nelmts; /* Maximum number of elements passed to callback */ + hbool_t last_call; /* Whether this should be the last time the callback is called */ } gather_info_t; static herr_t -gather_cb(const void *dst_buf, size_t dst_buf_bytes_used, - void *_gather_info) +gather_cb(const void *dst_buf, size_t dst_buf_bytes_used, void *_gather_info) { gather_info_t *gather_info = (gather_info_t *)_gather_info; - size_t nelmts; /* Number of elements in src_buf */ - int i; /* Local index variable */ + size_t nelmts; /* Number of elements in src_buf */ + int i; /* Local index variable */ HDassert(dst_buf_bytes_used > 0); @@ -12163,24 +13413,24 @@ gather_cb(const void *dst_buf, size_t dst_buf_bytes_used, nelmts = dst_buf_bytes_used / sizeof(gather_info->expect_dst_buf[0]); /* Make sure the number of bytes is a multiple of the number of elements */ - if(nelmts * sizeof(gather_info->expect_dst_buf[0]) != dst_buf_bytes_used) + if (nelmts * sizeof(gather_info->expect_dst_buf[0]) != dst_buf_bytes_used) TEST_ERROR /* Make sure we weren't passed more data than we requested to be passed at * once */ - if(nelmts > gather_info->max_nelmts) + if (nelmts > gather_info->max_nelmts) TEST_ERROR /* If we were passed less data than requested, make sure this is the last * time the callback was called */ - if(gather_info->last_call) + if (gather_info->last_call) TEST_ERROR - if(nelmts < gather_info->max_nelmts) + if (nelmts < gather_info->max_nelmts) gather_info->last_call = TRUE; /* Compare data and expected data */ - for(i=0; i<(int)nelmts; i++) - if(((const int *)dst_buf)[i] != *((gather_info->expect_dst_buf)++)) + for (i = 0; i < (int)nelmts; i++) + if (((const int *)dst_buf)[i] != *((gather_info->expect_dst_buf)++)) TEST_ERROR return SUCCEED; @@ -12192,35 +13442,34 @@ error: static herr_t test_gather(void) { - hid_t sid = -1; /* Dataspace ID */ - hsize_t dim[3] = {8, 5, 8}; /* Dataspace dimensions */ - hsize_t start[3] = {0, 0, 0}; - hsize_t stride[3] = {0, 0, 0}; - hsize_t count[3] = {0, 0, 0}; - hsize_t block[3] = {0, 0, 0}; - hsize_t start2[3] = {0, 0, 0}; - hsize_t count2[3] = {0, 0, 0}; - hsize_t point[4][3] = {{2, 3, 2}, {3, 0, 2}, {7, 2, 0}, {0, 1, 5}}; - size_t dst_buf_size; - int src_buf[8][5][8]; /* Source data buffer */ - int dst_buf[36]; /* Destination data buffer */ - int expect_dst_buf[36]; /* Expected destination data buffer */ - gather_info_t gather_info; /* Operator data for callback */ - int i, j, k, dst_i; /* Local index variables */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim[3] = {8, 5, 8}; /* Dataspace dimensions */ + hsize_t start[3] = {0, 0, 0}; + hsize_t stride[3] = {0, 0, 0}; + hsize_t count[3] = {0, 0, 0}; + hsize_t block[3] = {0, 0, 0}; + hsize_t start2[3] = {0, 0, 0}; + hsize_t count2[3] = {0, 0, 0}; + hsize_t point[4][3] = {{2, 3, 2}, {3, 0, 2}, {7, 2, 0}, {0, 1, 5}}; + size_t dst_buf_size; + int src_buf[8][5][8]; /* Source data buffer */ + int dst_buf[36]; /* Destination data buffer */ + int expect_dst_buf[36]; /* Expected destination data buffer */ + gather_info_t gather_info; /* Operator data for callback */ + int i, j, k, dst_i; /* Local index variables */ TESTING("H5Dgather()"); /* Create dataspace */ - if((sid = H5Screate_simple(3, dim, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(3, dim, NULL)) < 0) + TEST_ERROR /* Initialize src_buf */ - for(i=0; i<(int)(sizeof(src_buf)/sizeof(src_buf[0])); i++) - for(j=0; j<(int)(sizeof(src_buf[0])/sizeof(src_buf[0][0])); j++) - for(k=0; k<(int)(sizeof(src_buf[0][0])/sizeof(src_buf[0][0][0])); k++) - src_buf[i][j][k] = 1 + k - + (int)(sizeof(src_buf[0][0]) / sizeof(src_buf[0][0][0])) * j - + (int)(sizeof(src_buf[0]) / sizeof(src_buf[0][0][0])) * i; - + for (i = 0; i < (int)(sizeof(src_buf) / sizeof(src_buf[0])); i++) + for (j = 0; j < (int)(sizeof(src_buf[0]) / sizeof(src_buf[0][0])); j++) + for (k = 0; k < (int)(sizeof(src_buf[0][0]) / sizeof(src_buf[0][0][0])); k++) + src_buf[i][j][k] = 1 + k + (int)(sizeof(src_buf[0][0]) / sizeof(src_buf[0][0][0])) * j + + (int)(sizeof(src_buf[0]) / sizeof(src_buf[0][0][0])) * i; /* * Test 1: Simple case @@ -12229,45 +13478,48 @@ test_gather(void) count[0] = 1; count[1] = 1; count[2] = 8; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); - for(i=0; i<8; i++) + /* Initialize expect_dst_buf */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + for (i = 0; i < 8; i++) expect_dst_buf[i] = src_buf[0][0][i]; /* Loop over buffer sizes */ - for(dst_buf_size=1; dst_buf_size<=9; dst_buf_size++) { + for (dst_buf_size = 1; dst_buf_size <= 9; dst_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Initialize gather_info */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.max_nelmts = dst_buf_size; - gather_info.last_call = FALSE; + gather_info.max_nelmts = dst_buf_size; + gather_info.last_call = FALSE; /* Gather data */ - if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0) + if (H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, + &gather_info) < 0) TEST_ERROR /* Verify that all data has been gathered (and verified) */ - if(gather_info.expect_dst_buf - expect_dst_buf != 8) TEST_ERROR + if (gather_info.expect_dst_buf - expect_dst_buf != 8) + TEST_ERROR } /* end for */ /* Test without a callback */ /* Loop over buffer sizes */ - for(dst_buf_size=8; dst_buf_size<=9; dst_buf_size++) { + for (dst_buf_size = 8; dst_buf_size <= 9; dst_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Gather data */ - if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, NULL, NULL) < 0) + if (H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, NULL, NULL) < + 0) TEST_ERROR /* Verify data */ - for(i=0; i<(int)(sizeof(dst_buf)/sizeof(dst_buf[0])); i++) - if(dst_buf[i] != expect_dst_buf[i]) + for (i = 0; i < (int)(sizeof(dst_buf) / sizeof(dst_buf[0])); i++) + if (dst_buf[i] != expect_dst_buf[i]) TEST_ERROR } /* end for */ @@ -12278,16 +13530,17 @@ test_gather(void) /* Initialize gather_info */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.max_nelmts = dst_buf_size - 1; - gather_info.last_call = FALSE; + gather_info.max_nelmts = dst_buf_size - 1; + gather_info.last_call = FALSE; /* Gather data */ - if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]) - 1, dst_buf, gather_cb, &gather_info) < 0) + if (H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]) - 1, dst_buf, gather_cb, + &gather_info) < 0) TEST_ERROR /* Verify that all data has been gathered (and verified) */ - if(gather_info.expect_dst_buf - expect_dst_buf != 8) TEST_ERROR - + if (gather_info.expect_dst_buf - expect_dst_buf != 8) + TEST_ERROR /* * Test 2: Single block in dataset @@ -12299,94 +13552,93 @@ test_gather(void) count[0] = 2; count[1] = 3; count[2] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + /* Initialize expect_dst_buf */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); dst_i = 0; - for(i=3; i<5; i++) - for(j=2; j<5; j++) - for(k=4; k<6; k++) + for (i = 3; i < 5; i++) + for (j = 2; j < 5; j++) + for (k = 4; k < 6; k++) expect_dst_buf[dst_i++] = src_buf[i][j][k]; /* Loop over buffer sizes */ - for(dst_buf_size=1; dst_buf_size<=13; dst_buf_size++) { + for (dst_buf_size = 1; dst_buf_size <= 13; dst_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Initialize gather_info */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.max_nelmts = dst_buf_size; - gather_info.last_call = FALSE; + gather_info.max_nelmts = dst_buf_size; + gather_info.last_call = FALSE; /* Gather data */ - if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0) + if (H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, + &gather_info) < 0) TEST_ERROR /* Verify that all data has been gathered (and verified) */ - if(gather_info.expect_dst_buf - expect_dst_buf != 12) TEST_ERROR + if (gather_info.expect_dst_buf - expect_dst_buf != 12) + TEST_ERROR } /* end for */ - /* * Test 3: Multiple blocks */ /* Select hyperslab */ - start[0] = 1; - start[1] = 1; - start[2] = 1; + start[0] = 1; + start[1] = 1; + start[2] = 1; stride[0] = 3; stride[1] = 4; stride[2] = 5; - count[0] = 3; - count[1] = 1; - count[2] = 2; - block[0] = 1; - block[1] = 3; - block[2] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride ,count, block) < 0) + count[0] = 3; + count[1] = 1; + count[2] = 2; + block[0] = 1; + block[1] = 3; + block[2] = 2; + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - /* Iterate over block containing selection, checking if each element is in - * selection. Note that the algorithm used here (if statement) would not - * work for overlapping hyperslabs. */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + /* Initialize expect_dst_buf */ + /* Iterate over block containing selection, checking if each element is in + * selection. Note that the algorithm used here (if statement) would not + * work for overlapping hyperslabs. */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); dst_i = 0; - for(i=1; i<8; i++) - for(j=1; j<4; j++) - for(k=1; k<8; k++) - if((hsize_t)i >= start[0] - && ((hsize_t)i - start[0]) % stride[0] < block[0] - && ((hsize_t)i - start[0]) / stride[0] < count[0] - && (hsize_t)j >= start[1] - && ((hsize_t)j - start[1]) % stride[1] < block[1] - && ((hsize_t)j - start[1]) / stride[1] < count[1] - && (hsize_t)k >= start[2] - && ((hsize_t)k - start[2]) % stride[2] < block[2] - && ((hsize_t)k - start[2]) / stride[2] < count[2]) + for (i = 1; i < 8; i++) + for (j = 1; j < 4; j++) + for (k = 1; k < 8; k++) + if ((hsize_t)i >= start[0] && ((hsize_t)i - start[0]) % stride[0] < block[0] && + ((hsize_t)i - start[0]) / stride[0] < count[0] && (hsize_t)j >= start[1] && + ((hsize_t)j - start[1]) % stride[1] < block[1] && + ((hsize_t)j - start[1]) / stride[1] < count[1] && (hsize_t)k >= start[2] && + ((hsize_t)k - start[2]) % stride[2] < block[2] && + ((hsize_t)k - start[2]) / stride[2] < count[2]) expect_dst_buf[dst_i++] = src_buf[i][j][k]; /* Loop over buffer sizes */ - for(dst_buf_size=1; dst_buf_size<=37; dst_buf_size++) { + for (dst_buf_size = 1; dst_buf_size <= 37; dst_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Initialize gather_info */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.max_nelmts = dst_buf_size; - gather_info.last_call = FALSE; + gather_info.max_nelmts = dst_buf_size; + gather_info.last_call = FALSE; /* Gather data */ - if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0) + if (H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, + &gather_info) < 0) TEST_ERROR /* Verify that all data has been gathered (and verified) */ - if(gather_info.expect_dst_buf - expect_dst_buf != 36) TEST_ERROR + if (gather_info.expect_dst_buf - expect_dst_buf != 36) + TEST_ERROR } /* end for */ - /* * Test 4: Compound selection */ @@ -12397,7 +13649,7 @@ test_gather(void) count[0] = 2; count[1] = 3; count[2] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start2[0] = 1; start2[1] = 2; @@ -12405,92 +13657,96 @@ test_gather(void) count2[0] = 3; count2[1] = 2; count2[2] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_XOR, start2, NULL ,count2, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_XOR, start2, NULL, count2, NULL) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - /* Iterate over block containing selection, checking if each element is in - * selection. */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + /* Initialize expect_dst_buf */ + /* Iterate over block containing selection, checking if each element is in + * selection. */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); dst_i = 0; - for(i=1; i<4; i++) - for(j=1; j<4; j++) - for(k=1; k<4; k++) - if(!(((hsize_t)i >= start[0] && (hsize_t)i < start[0] + count[0]) - && ((hsize_t)j >= start[1] && (hsize_t)j < start[1] + count[1]) - && ((hsize_t)k >= start[2] && (hsize_t)k < start[2] + count[2])) - != !(((hsize_t)i >= start2[0] && (hsize_t)i < start2[0] + count2[0]) - && ((hsize_t)j >= start2[1] && (hsize_t)j < start2[1] + count2[1]) - && ((hsize_t)k >= start2[2] && (hsize_t)k < start2[2] + count2[2]))) + for (i = 1; i < 4; i++) + for (j = 1; j < 4; j++) + for (k = 1; k < 4; k++) + if (!(((hsize_t)i >= start[0] && (hsize_t)i < start[0] + count[0]) && + ((hsize_t)j >= start[1] && (hsize_t)j < start[1] + count[1]) && + ((hsize_t)k >= start[2] && (hsize_t)k < start[2] + count[2])) != + !(((hsize_t)i >= start2[0] && (hsize_t)i < start2[0] + count2[0]) && + ((hsize_t)j >= start2[1] && (hsize_t)j < start2[1] + count2[1]) && + ((hsize_t)k >= start2[2] && (hsize_t)k < start2[2] + count2[2]))) expect_dst_buf[dst_i++] = src_buf[i][j][k]; /* Loop over buffer sizes */ - for(dst_buf_size=1; dst_buf_size<=17; dst_buf_size++) { + for (dst_buf_size = 1; dst_buf_size <= 17; dst_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Initialize gather_info */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.max_nelmts = dst_buf_size; - gather_info.last_call = FALSE; + gather_info.max_nelmts = dst_buf_size; + gather_info.last_call = FALSE; /* Gather data */ - if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0) + if (H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, + &gather_info) < 0) TEST_ERROR /* Verify that all data has been gathered (and verified) */ - if(gather_info.expect_dst_buf - expect_dst_buf != 16) TEST_ERROR + if (gather_info.expect_dst_buf - expect_dst_buf != 16) + TEST_ERROR } /* end for */ - /* * Test 5: Point selection */ /* Select hyperslabs */ - if(H5Sselect_elements(sid, H5S_SELECT_SET, sizeof(point) / sizeof(point[0]), (hsize_t *)point) < 0) + if (H5Sselect_elements(sid, H5S_SELECT_SET, sizeof(point) / sizeof(point[0]), (hsize_t *)point) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - /* Iterate over block containing selection, checking if each element is in - * selection. */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); - for(i=0; i<(int)(sizeof(point) / sizeof(point[0])); i++) + /* Initialize expect_dst_buf */ + /* Iterate over block containing selection, checking if each element is in + * selection. */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + for (i = 0; i < (int)(sizeof(point) / sizeof(point[0])); i++) expect_dst_buf[i] = src_buf[point[i][0]][point[i][1]][point[i][2]]; /* Loop over buffer sizes */ - for(dst_buf_size=1; dst_buf_size<=5; dst_buf_size++) { + for (dst_buf_size = 1; dst_buf_size <= 5; dst_buf_size++) { /* Reset dst_buf */ (void)HDmemset(dst_buf, 0, sizeof(dst_buf)); /* Initialize gather_info */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.max_nelmts = dst_buf_size; - gather_info.last_call = FALSE; + gather_info.max_nelmts = dst_buf_size; + gather_info.last_call = FALSE; /* Gather data */ - if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0) + if (H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, + &gather_info) < 0) TEST_ERROR /* Verify that all data has been gathered (and verified) */ - if(gather_info.expect_dst_buf - expect_dst_buf != 4) TEST_ERROR + if (gather_info.expect_dst_buf - expect_dst_buf != 4) + TEST_ERROR } /* end for */ - /* Close everything */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_gather() */ - /*------------------------------------------------------------------------- * Function: test_scatter_error * @@ -12506,47 +13762,45 @@ error: *------------------------------------------------------------------------- */ static herr_t -scatter_error_cb_fail(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, - void *_scatter_info) +scatter_error_cb_fail(void **src_buf /*out*/, size_t *src_buf_bytes_used /*out*/, void *_scatter_info) { scatter_info_t *scatter_info = (scatter_info_t *)_scatter_info; - size_t nelmts; /* Number of elements to return in src_buf */ + size_t nelmts; /* Number of elements to return in src_buf */ /* Calculate number of elements */ nelmts = MIN(scatter_info->block, scatter_info->size); HDassert(nelmts > 0); /* Set output variables */ - *src_buf = (void *)scatter_info->src_buf; + *src_buf = (void *)scatter_info->src_buf; *src_buf_bytes_used = nelmts * sizeof(scatter_info->src_buf[0]); return FAIL; } /* end scatter_error_cb_fail() */ static herr_t -scatter_error_cb_null(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, - void *_scatter_info) +scatter_error_cb_null(void **src_buf /*out*/, size_t *src_buf_bytes_used /*out*/, void *_scatter_info) { scatter_info_t *scatter_info = (scatter_info_t *)_scatter_info; - size_t nelmts; /* Number of elements to return in src_buf */ + size_t nelmts; /* Number of elements to return in src_buf */ /* Calculate number of elements */ nelmts = MIN(scatter_info->block, scatter_info->size); HDassert(nelmts > 0); /* Set output variables */ - *src_buf = NULL; + *src_buf = NULL; *src_buf_bytes_used = nelmts * sizeof(scatter_info->src_buf[0]); return SUCCEED; } /* end scatter_error_cb_null() */ static herr_t -scatter_error_cb_unalign(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, - void *_src_buf_bytes_used) +scatter_error_cb_unalign(void **src_buf /*out*/, size_t *src_buf_bytes_used /*out*/, + void *_src_buf_bytes_used) { /* Set output variables */ - *src_buf = _src_buf_bytes_used; + *src_buf = _src_buf_bytes_used; *src_buf_bytes_used = *(size_t *)_src_buf_bytes_used; return SUCCEED; @@ -12555,145 +13809,177 @@ scatter_error_cb_unalign(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out* static herr_t test_scatter_error(void) { - hid_t sid = -1; /* Dataspace ID */ - hsize_t dim[1] = {10}; /* Dataspace dimensions */ - hsize_t start[3] = {2}; - hsize_t count[3] = {6}; - int src_buf[7]; /* Source data buffer */ - int dst_buf[10]; /* Destination data buffer */ - scatter_info_t scatter_info; /* Operator data for callback */ - size_t cb_unalign_nbytes; /* Number of bytes to return for unaligned test */ - herr_t ret; /* Return value */ - int i; /* Local index variable */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim[1] = {10}; /* Dataspace dimensions */ + hsize_t start[3] = {2}; + hsize_t count[3] = {6}; + int src_buf[7]; /* Source data buffer */ + int dst_buf[10]; /* Destination data buffer */ + scatter_info_t scatter_info; /* Operator data for callback */ + size_t cb_unalign_nbytes; /* Number of bytes to return for unaligned test */ + herr_t ret; /* Return value */ + int i; /* Local index variable */ TESTING("H5Dscatter() error conditions"); /* Create dataspace */ - if((sid = H5Screate_simple(1, dim, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) + TEST_ERROR /* Initialize src_buf */ - for(i=0; i<(int)(sizeof(src_buf)/sizeof(src_buf[0])); i++) + for (i = 0; i < (int)(sizeof(src_buf) / sizeof(src_buf[0])); i++) src_buf[i] = i + 1; /* Select hyperslab */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Verify that base configuration passes */ scatter_info.src_buf = src_buf; - scatter_info.block = sizeof(src_buf)/sizeof(src_buf[0]); - scatter_info.size = 6; - if(H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) + scatter_info.block = sizeof(src_buf) / sizeof(src_buf[0]); + scatter_info.size = 6; + if (H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0) TEST_ERROR - /* * Test invalid parameters */ scatter_info.src_buf = src_buf; - scatter_info.size = 6; - H5E_BEGIN_TRY { + scatter_info.size = 6; + H5E_BEGIN_TRY + { ret = H5Dscatter(NULL, NULL, H5T_NATIVE_INT, sid, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR scatter_info.src_buf = src_buf; - scatter_info.size = 6; - H5E_BEGIN_TRY { + scatter_info.size = 6; + H5E_BEGIN_TRY + { ret = H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, sid, sid, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR scatter_info.src_buf = src_buf; - scatter_info.size = 6; - H5E_BEGIN_TRY { - ret = H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, H5T_NATIVE_INT, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + scatter_info.size = 6; + H5E_BEGIN_TRY + { + ret = H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, H5T_NATIVE_INT, + dst_buf); + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR scatter_info.src_buf = src_buf; - scatter_info.size = 6; - H5E_BEGIN_TRY { + scatter_info.size = 6; + H5E_BEGIN_TRY + { ret = H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, NULL); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR - + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR /* * Test returning too many elements in callback */ scatter_info.src_buf = src_buf; - scatter_info.size = 7; - H5E_BEGIN_TRY { + scatter_info.size = 7; + H5E_BEGIN_TRY + { ret = H5Dscatter((H5D_scatter_func_t)scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR - + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR /* * Test callback returns failure */ scatter_info.src_buf = src_buf; - scatter_info.size = 6; - H5E_BEGIN_TRY { - ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_fail, &scatter_info, H5T_NATIVE_INT, sid, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR - + scatter_info.size = 6; + H5E_BEGIN_TRY + { + ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_fail, &scatter_info, H5T_NATIVE_INT, sid, + dst_buf); + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR /* * Test callback returns NULL buffer */ scatter_info.src_buf = src_buf; - scatter_info.size = 6; - H5E_BEGIN_TRY { - ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_null, &scatter_info, H5T_NATIVE_INT, sid, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR - + scatter_info.size = 6; + H5E_BEGIN_TRY + { + ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_null, &scatter_info, H5T_NATIVE_INT, sid, + dst_buf); + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR /* * Test callback returns 0 for src_buf_bytes_used */ cb_unalign_nbytes = 0; - H5E_BEGIN_TRY { - ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, sid, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR - + H5E_BEGIN_TRY + { + ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, + sid, dst_buf); + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR /* * Test callback returns src_buf_bytes_used that is not a multiple of * datatype size */ cb_unalign_nbytes = sizeof(src_buf[0]) - 1; - H5E_BEGIN_TRY { - ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, sid, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, + sid, dst_buf); + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR cb_unalign_nbytes = sizeof(src_buf[0]) + 1; - H5E_BEGIN_TRY { - ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, sid, dst_buf); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR - + H5E_BEGIN_TRY + { + ret = H5Dscatter((H5D_scatter_func_t)scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, + sid, dst_buf); + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR /* Close everything */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_scatter_error() */ - /*------------------------------------------------------------------------- * Function: test_gather_error * @@ -12709,8 +13995,8 @@ error: *------------------------------------------------------------------------- */ static herr_t -gather_error_cb_fail(const void H5_ATTR_UNUSED *dst_buf, - size_t H5_ATTR_UNUSED dst_buf_bytes_used, void H5_ATTR_UNUSED *op_data) +gather_error_cb_fail(const void H5_ATTR_UNUSED *dst_buf, size_t H5_ATTR_UNUSED dst_buf_bytes_used, + void H5_ATTR_UNUSED *op_data) { return FAIL; } /* end gather_error_cb_fail() */ @@ -12718,117 +14004,145 @@ gather_error_cb_fail(const void H5_ATTR_UNUSED *dst_buf, static herr_t test_gather_error(void) { - hid_t sid = -1; /* Dataspace ID */ - hsize_t dim[1] = {10}; /* Dataspace dimensions */ - hsize_t start[1] = {2}; - hsize_t count[1] = {6}; - int src_buf[10]; /* Source data buffer */ - int dst_buf[6]; /* Destination data buffer */ - int expect_dst_buf[6]; /* Expected destination data buffer */ - gather_info_t gather_info; /* Operator data for callback */ - herr_t ret; /* Return value */ - int i; /* Local index variable */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim[1] = {10}; /* Dataspace dimensions */ + hsize_t start[1] = {2}; + hsize_t count[1] = {6}; + int src_buf[10]; /* Source data buffer */ + int dst_buf[6]; /* Destination data buffer */ + int expect_dst_buf[6]; /* Expected destination data buffer */ + gather_info_t gather_info; /* Operator data for callback */ + herr_t ret; /* Return value */ + int i; /* Local index variable */ TESTING("H5Dgather() error conditions"); /* Create dataspace */ - if((sid = H5Screate_simple(1, dim, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) + TEST_ERROR /* Initialize src_buf */ - for(i=0; i<(int)(sizeof(src_buf)/sizeof(src_buf[0])); i++) + for (i = 0; i < (int)(sizeof(src_buf) / sizeof(src_buf[0])); i++) src_buf[i] = 1 + i; /* Select hyperslab */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - /* Initialize expect_dst_buf */ - (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); - for(i=0; i<6; i++) + /* Initialize expect_dst_buf */ + (void) HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf)); + for (i = 0; i < 6; i++) expect_dst_buf[i] = src_buf[i + 2]; /* Verify that base configuration passes */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.max_nelmts = 6; - gather_info.last_call = FALSE; - if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0) + gather_info.max_nelmts = 6; + gather_info.last_call = FALSE; + if (H5Dgather(sid, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0) TEST_ERROR /* * Test invalid parameters */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.last_call = FALSE; - H5E_BEGIN_TRY { - ret = H5Dgather(H5T_NATIVE_INT, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + gather_info.last_call = FALSE; + H5E_BEGIN_TRY + { + ret = H5Dgather(H5T_NATIVE_INT, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, + &gather_info); + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR gather_info.expect_dst_buf = expect_dst_buf; - gather_info.last_call = FALSE; - H5E_BEGIN_TRY { + gather_info.last_call = FALSE; + H5E_BEGIN_TRY + { ret = H5Dgather(sid, NULL, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR gather_info.expect_dst_buf = expect_dst_buf; - gather_info.last_call = FALSE; - H5E_BEGIN_TRY { + gather_info.last_call = FALSE; + H5E_BEGIN_TRY + { ret = H5Dgather(sid, src_buf, sid, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR gather_info.expect_dst_buf = expect_dst_buf; - gather_info.last_call = FALSE; - H5E_BEGIN_TRY { + gather_info.last_call = FALSE; + H5E_BEGIN_TRY + { ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 0, dst_buf, gather_cb, &gather_info); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR gather_info.expect_dst_buf = expect_dst_buf; - gather_info.last_call = FALSE; - H5E_BEGIN_TRY { + gather_info.last_call = FALSE; + H5E_BEGIN_TRY + { ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 1, dst_buf, gather_cb, &gather_info); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR gather_info.expect_dst_buf = expect_dst_buf; - gather_info.last_call = FALSE; - H5E_BEGIN_TRY { + gather_info.last_call = FALSE; + H5E_BEGIN_TRY + { ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), NULL, gather_cb, &gather_info); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR gather_info.expect_dst_buf = expect_dst_buf; - gather_info.last_call = FALSE; - H5E_BEGIN_TRY { + gather_info.last_call = FALSE; + H5E_BEGIN_TRY + { ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 5 * sizeof(dst_buf[0]), dst_buf, NULL, &gather_info); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR - + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR /* * Test callback returns failure */ gather_info.expect_dst_buf = expect_dst_buf; - gather_info.last_call = FALSE; - H5E_BEGIN_TRY { - ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_error_cb_fail, NULL); - } H5E_END_TRY - if(ret >= 0) TEST_ERROR - + gather_info.last_call = FALSE; + H5E_BEGIN_TRY + { + ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_error_cb_fail, + NULL); + } + H5E_END_TRY + if (ret >= 0) + TEST_ERROR /* Close everything */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_gather_error() */ @@ -12915,55 +14229,65 @@ error: *------------------------------------------------------------------------- */ -#define DLS_01_DATASET "data" -#define DLS_01_STR_SIZE 256 -#define DLS_01_CHUNK_SIZE 8 -#define DLS_01_DIMS 4 +#define DLS_01_DATASET "data" +#define DLS_01_STR_SIZE 256 +#define DLS_01_CHUNK_SIZE 8 +#define DLS_01_DIMS 4 -static herr_t dls_01_setup_file( hid_t fid ); -static herr_t dls_01_write_data( hid_t fid, char* buffer ); -static herr_t dls_01_read_stuff( hid_t fid ); -static herr_t dls_01_main( void ); +static herr_t dls_01_setup_file(hid_t fid); +static herr_t dls_01_write_data(hid_t fid, char *buffer); +static herr_t dls_01_read_stuff(hid_t fid); +static herr_t dls_01_main(void); static herr_t -dls_01_setup_file( hid_t fid ) +dls_01_setup_file(hid_t fid) { - int status = 0; - hid_t sid = 0, did = 0, tid = 0, dcpl = 0; - int ndims = 1; - hsize_t max_shape[1] = {H5S_UNLIMITED}; + int status = 0; + hid_t sid = 0, did = 0, tid = 0, dcpl = 0; + int ndims = 1; + hsize_t max_shape[1] = {H5S_UNLIMITED}; hsize_t initial_shape[1] = {0}; - hsize_t chunks[1] = {DLS_01_CHUNK_SIZE}; + hsize_t chunks[1] = {DLS_01_CHUNK_SIZE}; - sid = H5Screate_simple( ndims, initial_shape, max_shape ); - if ( sid <= 0 ) TEST_ERROR + sid = H5Screate_simple(ndims, initial_shape, max_shape); + if (sid <= 0) + TEST_ERROR - tid = H5Tcopy( H5T_C_S1 ); - if ( tid <= 0 ) TEST_ERROR + tid = H5Tcopy(H5T_C_S1); + if (tid <= 0) + TEST_ERROR - status = H5Tset_size( tid, DLS_01_STR_SIZE ); - if ( status != 0 ) TEST_ERROR + status = H5Tset_size(tid, DLS_01_STR_SIZE); + if (status != 0) + TEST_ERROR - dcpl = H5Pcreate( H5P_DATASET_CREATE ); - if ( dcpl <= 0 ) TEST_ERROR + dcpl = H5Pcreate(H5P_DATASET_CREATE); + if (dcpl <= 0) + TEST_ERROR - status = H5Pset_chunk( dcpl, ndims, chunks ); - if ( status != 0 ) TEST_ERROR + status = H5Pset_chunk(dcpl, ndims, chunks); + if (status != 0) + TEST_ERROR - did = H5Dcreate2( fid, DLS_01_DATASET, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT ); - if ( did <= 0 ) TEST_ERROR + did = H5Dcreate2(fid, DLS_01_DATASET, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (did <= 0) + TEST_ERROR - status = H5Dclose( did ); - if ( status != 0 ) TEST_ERROR + status = H5Dclose(did); + if (status != 0) + TEST_ERROR - status = H5Pclose( dcpl ); - if ( status != 0 ) TEST_ERROR + status = H5Pclose(dcpl); + if (status != 0) + TEST_ERROR - status = H5Tclose( tid ); - if ( status != 0 ) TEST_ERROR + status = H5Tclose(tid); + if (status != 0) + TEST_ERROR - status = H5Sclose( sid ); - if ( status != 0 ) TEST_ERROR + status = H5Sclose(sid); + if (status != 0) + TEST_ERROR return SUCCEED; @@ -12972,32 +14296,39 @@ error: } /* end dls_01_setup_file() */ static herr_t -dls_01_write_data( hid_t fid, char* buffer ) +dls_01_write_data(hid_t fid, char *buffer) { - int status = 0; - hid_t did = 0, tid = 0; + int status = 0; + hid_t did = 0, tid = 0; hsize_t extent[1] = {4}; - did = H5Dopen2( fid, DLS_01_DATASET, H5P_DEFAULT ); - if ( did <= 0 ) TEST_ERROR + did = H5Dopen2(fid, DLS_01_DATASET, H5P_DEFAULT); + if (did <= 0) + TEST_ERROR - tid = H5Dget_type( did ); - if ( tid <= 0 ) TEST_ERROR + tid = H5Dget_type(did); + if (tid <= 0) + TEST_ERROR - status = H5Dset_extent( did, extent ); - if ( status != 0 ) TEST_ERROR + status = H5Dset_extent(did, extent); + if (status != 0) + TEST_ERROR - status = H5Dwrite( did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer ); - if ( status != 0 ) TEST_ERROR + status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer); + if (status != 0) + TEST_ERROR - status = H5Fflush( fid, H5F_SCOPE_LOCAL ); - if ( status != 0 ) TEST_ERROR + status = H5Fflush(fid, H5F_SCOPE_LOCAL); + if (status != 0) + TEST_ERROR - status = H5Tclose( tid ); - if ( status != 0 ) TEST_ERROR + status = H5Tclose(tid); + if (status != 0) + TEST_ERROR - status = H5Dclose( did ); - if ( status != 0 ) TEST_ERROR + status = H5Dclose(did); + if (status != 0) + TEST_ERROR return SUCCEED; @@ -13008,20 +14339,20 @@ error: static herr_t dls_01_read_stuff(hid_t fid) { - int status = 0; - hid_t did = 0; + int status = 0; + hid_t did = 0; H5O_info2_t info; did = H5Dopen2(fid, DLS_01_DATASET, H5P_DEFAULT); - if(did <= 0) + if (did <= 0) TEST_ERROR status = H5Oget_info3(did, &info, H5O_INFO_BASIC); - if(status != 0) + if (status != 0) TEST_ERROR status = H5Dclose(did); - if(status != 0) + if (status != 0) TEST_ERROR return SUCCEED; @@ -13031,59 +14362,64 @@ error: } /* end dls_01_read_stuff() */ static herr_t -dls_01_main( void ) +dls_01_main(void) { - char filename[512]; - int status = 0; - hid_t fapl = 0, fid = 0; - const char* strings[DLS_01_DIMS] = - { "String 1", "Test string 2", "Another string", "Final String" }; - char* buffer = NULL; + char filename[512]; + int status = 0; + hid_t fapl = 0, fid = 0; + const char *strings[DLS_01_DIMS] = {"String 1", "Test string 2", "Another string", "Final String"}; + char * buffer = NULL; TESTING("Testing DLS bugfix 1"); - if ( NULL == h5_fixname(FILENAME[23], H5P_DEFAULT, filename, - sizeof(filename)) ) - TEST_ERROR + if (NULL == h5_fixname(FILENAME[23], H5P_DEFAULT, filename, sizeof(filename))) + TEST_ERROR - buffer = (char *)HDcalloc( DLS_01_DIMS, DLS_01_STR_SIZE ); - if ( NULL == buffer ) + buffer = (char *)HDcalloc(DLS_01_DIMS, DLS_01_STR_SIZE); + if (NULL == buffer) TEST_ERROR - HDstrcpy( buffer, strings[0] ); - HDstrcpy( buffer + DLS_01_STR_SIZE, strings[1] ); - HDstrcpy( buffer + DLS_01_STR_SIZE * 2, strings[2] ); - HDstrcpy( buffer + DLS_01_STR_SIZE * 3, strings[3] ); + HDstrcpy(buffer, strings[0]); + HDstrcpy(buffer + DLS_01_STR_SIZE, strings[1]); + HDstrcpy(buffer + DLS_01_STR_SIZE * 2, strings[2]); + HDstrcpy(buffer + DLS_01_STR_SIZE * 3, strings[3]); - fapl = H5Pcreate( H5P_FILE_ACCESS ); - if ( fapl <= 0 ) TEST_ERROR + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (fapl <= 0) + TEST_ERROR - status = H5Pset_libver_bounds( fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST ); - if ( status != 0 ) TEST_ERROR + status = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + if (status != 0) + TEST_ERROR - fid = H5Fcreate( filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ); - if ( fid <= 0 ) TEST_ERROR + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + if (fid <= 0) + TEST_ERROR - if ( 0 != dls_01_setup_file( fid ) ) - goto error; + if (0 != dls_01_setup_file(fid)) + goto error; - if ( 0 != dls_01_write_data( fid, buffer ) ) - goto error; + if (0 != dls_01_write_data(fid, buffer)) + goto error; - status = H5Fclose( fid ); - if ( status != 0 ) TEST_ERROR + status = H5Fclose(fid); + if (status != 0) + TEST_ERROR - fid = H5Fopen( filename, H5F_ACC_RDONLY, fapl ); - if ( fid <= 0 ) TEST_ERROR + fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); + if (fid <= 0) + TEST_ERROR - if ( 0 != dls_01_read_stuff( fid ) ) - goto error; + if (0 != dls_01_read_stuff(fid)) + goto error; - status = H5Fclose( fid ); - if ( status != 0 ) TEST_ERROR + status = H5Fclose(fid); + if (status != 0) + TEST_ERROR - status = H5Pclose( fapl ); - if ( status != 0 ) TEST_ERROR + status = H5Pclose(fapl); + if (status != 0) + TEST_ERROR HDfree(buffer); @@ -13092,7 +14428,8 @@ dls_01_main( void ) return SUCCEED; error: - if ( buffer ) HDfree(buffer); + if (buffer) + HDfree(buffer); return FAIL; } /* end dls_01_main() */ @@ -13117,104 +14454,108 @@ error: static herr_t test_compact_open_close_dirty(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* Dataset creation property list */ - hsize_t dims[1] = {10}; /* Dimension */ - int wbuf[10]; /* Data buffer */ - char filename[FILENAME_BUF_SIZE]; /* Filename */ - int i; /* Local index variable */ - hbool_t dirty; /* The dirty flag */ + hid_t fid = -1; /* File ID */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + hsize_t dims[1] = {10}; /* Dimension */ + int wbuf[10]; /* Data buffer */ + char filename[FILENAME_BUF_SIZE]; /* Filename */ + int i; /* Local index variable */ + hbool_t dirty; /* The dirty flag */ TESTING("compact dataset repeated open/close and dirty flag"); /* Create a file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Initialize data */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) wbuf[i] = i; /* Create dataspace */ - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR /* Set compact layout */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_layout(dcpl, H5D_COMPACT) < 0) + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) TEST_ERROR - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR /* Create a compact dataset */ - if((did = H5Dcreate2(fid, DSET_COMPACT_MAX_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_COMPACT_MAX_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) TEST_ERROR /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR /* Verify the repeated open/close of the dataset will not fail */ - for(i = 0; i < 20;i++) { - H5E_BEGIN_TRY { - did = H5Dopen2 (fid, DSET_COMPACT_MAX_NAME, H5P_DEFAULT); - } H5E_END_TRY; - if(did < 0) + for (i = 0; i < 20; i++) { + H5E_BEGIN_TRY + { + did = H5Dopen2(fid, DSET_COMPACT_MAX_NAME, H5P_DEFAULT); + } + H5E_END_TRY; + if (did < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR } /* Open the dataset */ - if((did = H5Dopen2(fid, DSET_COMPACT_MAX_NAME, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DSET_COMPACT_MAX_NAME, H5P_DEFAULT)) < 0) TEST_ERROR /* Retrieve the "dirty" flag from the compact dataset layout */ - if(H5D__layout_compact_dirty_test(did, &dirty) < 0) + if (H5D__layout_compact_dirty_test(did, &dirty) < 0) TEST_ERROR /* Verify that the "dirty" flag is false */ - if(dirty) + if (dirty) TEST_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR /* Close the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /* Close the dataset creation property list */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR - PASSED(); - return SUCCEED; + PASSED(); + return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Pclose(dcpl); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_compact_open_close_dirty() */ - /*------------------------------------------------------------------------- * Function: test_versionbounds * @@ -13231,129 +14572,140 @@ error: * *------------------------------------------------------------------------- */ -#define VDS_FNAME1 "virtual_file1" -#define VDS_FNAME2 "virtual_file2" -#define SRC_FNAME "source_file" -#define SRC_DSET "src_dset" -#define V_DSET "v_dset" +#define VDS_FNAME1 "virtual_file1" +#define VDS_FNAME2 "virtual_file2" +#define SRC_FNAME "source_file" +#define SRC_DSET "src_dset" +#define V_DSET "v_dset" static herr_t test_versionbounds(void) { - hid_t fapl = -1; - hid_t srcfile = -1; /* Files with source dsets */ - hid_t vfile = -1; /* File with virtual dset */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t srcspace = -1; /* Source dataspaces */ - hid_t vspace = -1; /* Virtual dset dataspaces */ - hid_t srcdset = -1; /* Source datset */ - hid_t vdset = -1; /* Virtual dataset */ - hsize_t dims[1] = {3}; /* Data space current size */ - char srcfilename[FILENAME_BUF_SIZE]; - char vfilename1[FILENAME_BUF_SIZE]; - char vfilename2[FILENAME_BUF_SIZE]; - H5F_libver_t low, high; /* File format bounds */ - herr_t ret; /* Generic return value */ + hid_t fapl = -1; + hid_t srcfile = -1; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t srcspace = -1; /* Source dataspaces */ + hid_t vspace = -1; /* Virtual dset dataspaces */ + hid_t srcdset = -1; /* Source datset */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[1] = {3}; /* Data space current size */ + char srcfilename[FILENAME_BUF_SIZE]; + char vfilename1[FILENAME_BUF_SIZE]; + char vfilename2[FILENAME_BUF_SIZE]; + H5F_libver_t low, high; /* File format bounds */ + herr_t ret; /* Generic return value */ TESTING("version bounds of datasets"); /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR h5_fixname(VDS_FNAME1, fapl, vfilename1, sizeof vfilename1); h5_fixname(VDS_FNAME2, fapl, vfilename2, sizeof vfilename2); h5_fixname(SRC_FNAME, fapl, srcfilename, sizeof srcfilename); /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create source dataspace */ - if((srcspace = H5Screate_simple(1, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace = H5Screate_simple(1, dims, NULL)) < 0) + if ((vspace = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace, srcfilename, SRC_DSET, srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace, srcfilename, SRC_DSET, srcspace) < 0) TEST_ERROR /* Loop through all the combinations of low/high library format bounds */ /* Create a source file and a dataset in it. Create a virtual file and virtual dataset. Creation of virtual dataset should only succeed in H5F_LIBVER_V110 */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Set version bounds, skip for invalid low/high combination */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ continue; /* Create a source file and dataset */ - if((srcfile = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((srcfile = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((srcdset = H5Dcreate2(srcfile, SRC_DSET, H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset = H5Dcreate2(srcfile, SRC_DSET, H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR /* Create a virtual file */ - if((vfile = H5Fcreate(vfilename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create the virtual dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { vdset = H5Dcreate2(vfile, V_DSET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; if (vdset > 0) /* dataset created successfully */ { /* Virtual dataset is only available starting in V110 */ VERIFY(high >= H5F_LIBVER_V110, TRUE, "virtual dataset"); - if(H5Dclose(vdset) < 0) TEST_ERROR + if (H5Dclose(vdset) < 0) + TEST_ERROR vdset = -1; } /* Close virtual file */ - if(H5Fclose(vfile) < 0) TEST_ERROR + if (H5Fclose(vfile) < 0) + TEST_ERROR vfile = -1; /* Close srcdset and srcfile */ - if(H5Dclose(srcdset) < 0) TEST_ERROR + if (H5Dclose(srcdset) < 0) + TEST_ERROR srcdset = -1; - if(H5Fclose(srcfile) < 0) TEST_ERROR + if (H5Fclose(srcfile) < 0) + TEST_ERROR srcfile = -1; } /* for high */ - } /* for low */ + } /* for low */ /* Close dataspaces and properties */ - if(H5Sclose(srcspace) < 0) + if (H5Sclose(srcspace) < 0) TEST_ERROR srcspace = -1; - if(H5Sclose(vspace) < 0) + if (H5Sclose(vspace) < 0) TEST_ERROR vspace = -1; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR fapl = -1; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR dcpl = -1; PASSED(); return SUCCEED; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Sclose(srcspace); H5Sclose(vspace); H5Pclose(dcpl); @@ -13362,11 +14714,11 @@ test_versionbounds(void) H5Dclose(vdset); H5Fclose(srcfile); H5Fclose(vfile); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_versionbounds() */ - /*----------------------------------------------------------------------------- * Function: test_object_header_minimization_dcpl * @@ -13385,11 +14737,11 @@ test_versionbounds(void) static herr_t test_object_header_minimization_dcpl(void) { - hid_t dcpl_id = -1; - hid_t file_id = -1; - char filename[FILENAME_BUF_SIZE] = ""; - hbool_t minimize = FALSE; - herr_t ret; + hid_t dcpl_id = -1; + hid_t file_id = -1; + char filename[FILENAME_BUF_SIZE] = ""; + hbool_t minimize = FALSE; + herr_t ret; TESTING("dcpl flags to minimize dataset object header"); @@ -13397,7 +14749,7 @@ test_object_header_minimization_dcpl(void) /* SETUP */ /*********/ - if(NULL == h5_fixname(OHMIN_FILENAME_A, H5P_DEFAULT, filename, sizeof(filename))) + if (NULL == h5_fixname(OHMIN_FILENAME_A, H5P_DEFAULT, filename, sizeof(filename))) TEST_ERROR file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -13439,52 +14791,59 @@ test_object_header_minimization_dcpl(void) /* error cases */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pget_dset_no_attrs_hint(-1, &minimize); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret == SUCCEED) TEST_ERROR /* Invalid DCPL ID should fail */ - H5E_BEGIN_TRY { - ret = H5Pset_dset_no_attrs_hint(-1, FALSE); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5Pset_dset_no_attrs_hint(-1, FALSE); + } + H5E_END_TRY; if (ret == SUCCEED) TEST_ERROR /* Invalid DCPL ID should fail */ - H5E_BEGIN_TRY { - ret = H5Pset_dset_no_attrs_hint(-1, TRUE); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5Pset_dset_no_attrs_hint(-1, TRUE); + } + H5E_END_TRY; if (ret == SUCCEED) TEST_ERROR /* Invalid DCPL ID should fail */ - H5E_BEGIN_TRY { - ret = H5Pget_dset_no_attrs_hint(dcpl_id, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5Pget_dset_no_attrs_hint(dcpl_id, NULL); + } + H5E_END_TRY; if (ret == SUCCEED) TEST_ERROR /* NULL out pointer should fail */ - /************/ - /* TEARDOWN */ - /************/ + /************/ + /* TEARDOWN */ + /************/ - if (H5Fclose(file_id) == FAIL) - TEST_ERROR + if (H5Fclose(file_id) == FAIL) TEST_ERROR - if (H5Pclose(dcpl_id) == FAIL) - TEST_ERROR + if (H5Pclose(dcpl_id) == FAIL) TEST_ERROR - PASSED(); + PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_object_header_minimization_dcpl() */ - /*----------------------------------------------------------------------------- * Function: test_0sized_dset_metadata_alloc * @@ -13501,15 +14860,15 @@ error: static herr_t test_0sized_dset_metadata_alloc(hid_t fapl_id) { - char filename[FILENAME_BUF_SIZE] = ""; - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id_copy = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t dcpl_id_copy = H5I_INVALID_HID; - hid_t dset_space_id = H5I_INVALID_HID; - hid_t buf_space_id = H5I_INVALID_HID; - unsigned new_format; /* Whether to use latest file format */ + char filename[FILENAME_BUF_SIZE] = ""; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id_copy = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dcpl_id_copy = H5I_INVALID_HID; + hid_t dset_space_id = H5I_INVALID_HID; + hid_t buf_space_id = H5I_INVALID_HID; + unsigned new_format; /* Whether to use latest file format */ TESTING("allocation of metadata for 0-sized datasets"); @@ -13517,144 +14876,146 @@ test_0sized_dset_metadata_alloc(hid_t fapl_id) /* SETUP */ /*********/ - if(NULL == h5_fixname(FILENAME[26], fapl_id, filename, sizeof(filename))) + if (NULL == h5_fixname(FILENAME[26], fapl_id, filename, sizeof(filename))) FAIL_STACK_ERROR /* Create DCPL for the dataset */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - /*************/ /* RUN TESTS */ /*************/ /* Iterate over file format versions */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - H5D_layout_t layout; /* Dataset layout type */ - H5D_alloc_time_t alloc_time; /* Storage allocation time */ + for (new_format = FALSE; new_format <= TRUE; new_format++) { + H5D_layout_t layout; /* Dataset layout type */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ /* Copy the file access property list */ - if((fapl_id_copy = H5Pcopy(fapl_id)) < 0) + if ((fapl_id_copy = H5Pcopy(fapl_id)) < 0) FAIL_STACK_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(new_format) - if(H5Pset_libver_bounds(fapl_id_copy, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (new_format) + if (H5Pset_libver_bounds(fapl_id_copy, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create test file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id_copy)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id_copy)) < 0) FAIL_STACK_ERROR /* Close the copy of the FAPL */ - if(H5Pclose(fapl_id_copy) < 0) + if (H5Pclose(fapl_id_copy) < 0) FAIL_STACK_ERROR /* Iterate over combinations of testing parameters */ - for(layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { - for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { - const hsize_t dims[1] = {0}; /* Dataset dimensions */ - const hsize_t max_dims[1] = {H5S_UNLIMITED}; /* Maximum dataset dimensions */ - const hsize_t chunk_dims[1] = {100}; /* Chunk dimensions */ - char dset_name[32]; /* Dataset name */ - H5O_native_info_t nat_info; /* Information about the dataset */ + for (layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { + for (alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + const hsize_t dims[1] = {0}; /* Dataset dimensions */ + const hsize_t max_dims[1] = {H5S_UNLIMITED}; /* Maximum dataset dimensions */ + const hsize_t chunk_dims[1] = {100}; /* Chunk dimensions */ + char dset_name[32]; /* Dataset name */ + H5O_native_info_t nat_info; /* Information about the dataset */ /* Compact storage must have early allocation */ - if(H5D_COMPACT == layout && H5D_ALLOC_TIME_EARLY != alloc_time) + if (H5D_COMPACT == layout && H5D_ALLOC_TIME_EARLY != alloc_time) continue; /* Compose dataset name */ - HDsnprintf(dset_name, sizeof(dset_name), "/Dataset-%u-%u", (unsigned)alloc_time, (unsigned)layout); + HDsnprintf(dset_name, sizeof(dset_name), "/Dataset-%u-%u", (unsigned)alloc_time, + (unsigned)layout); /* Set up DCPL */ - if((dcpl_id_copy = H5Pcopy(dcpl_id)) < 0) + if ((dcpl_id_copy = H5Pcopy(dcpl_id)) < 0) FAIL_STACK_ERROR - if(H5Pset_alloc_time(dcpl_id_copy, alloc_time) < 0) + if (H5Pset_alloc_time(dcpl_id_copy, alloc_time) < 0) FAIL_STACK_ERROR - if(H5Pset_layout(dcpl_id_copy, layout) < 0) + if (H5Pset_layout(dcpl_id_copy, layout) < 0) FAIL_STACK_ERROR - if(H5D_CHUNKED == layout) - if(H5Pset_chunk(dcpl_id_copy, 1, chunk_dims) < 0) + if (H5D_CHUNKED == layout) + if (H5Pset_chunk(dcpl_id_copy, 1, chunk_dims) < 0) FAIL_STACK_ERROR /* Create the dataspace for the dataset */ - if((dset_space_id = H5Screate_simple(1, dims, (H5D_CHUNKED == layout ? max_dims : NULL))) < 0) + if ((dset_space_id = H5Screate_simple(1, dims, (H5D_CHUNKED == layout ? max_dims : NULL))) < + 0) FAIL_STACK_ERROR /* Create the dataset with the appropriate parameters */ - if((dset_id = H5Dcreate2(file_id, dset_name, H5T_NATIVE_INT, dset_space_id, H5P_DEFAULT, dcpl_id_copy, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2(file_id, dset_name, H5T_NATIVE_INT, dset_space_id, H5P_DEFAULT, + dcpl_id_copy, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close objects used to create dataset */ - if(H5Pclose(dcpl_id_copy) < 0) + if (H5Pclose(dcpl_id_copy) < 0) FAIL_STACK_ERROR - if(H5Sclose(dset_space_id) < 0) + if (H5Sclose(dset_space_id) < 0) FAIL_STACK_ERROR /* Retrieve & verify the dataset's index info */ HDmemset(&nat_info, 0, sizeof(nat_info)); - if(H5Oget_native_info(dset_id, &nat_info, H5O_NATIVE_INFO_META_SIZE) < 0) + if (H5Oget_native_info(dset_id, &nat_info, H5O_NATIVE_INFO_META_SIZE) < 0) FAIL_STACK_ERROR - if(0 != nat_info.meta_size.obj.index_size) + if (0 != nat_info.meta_size.obj.index_size) FAIL_PUTS_ERROR("dataset index allocation size is non-zero") /* If chunked, try extending and verify that the index is allocated */ - if(H5D_CHUNKED == layout) { + if (H5D_CHUNKED == layout) { const hsize_t new_dims[1] = {1500}; /* New dataset dimensions */ - const hsize_t mem_dims[1] = {1}; /* Memory buffer dataset dimensions */ - const hsize_t coord = 0; /* Dataset selection coordinate */ - int val = 0; /* Data value */ + const hsize_t mem_dims[1] = {1}; /* Memory buffer dataset dimensions */ + const hsize_t coord = 0; /* Dataset selection coordinate */ + int val = 0; /* Data value */ /* Extend dataset */ - if(H5Dset_extent(dset_id, new_dims) < 0) + if (H5Dset_extent(dset_id, new_dims) < 0) FAIL_STACK_ERROR /* Get the dataspace for the dataset & set single point selection */ - if((dset_space_id = H5Dget_space(dset_id)) < 0) + if ((dset_space_id = H5Dget_space(dset_id)) < 0) FAIL_STACK_ERROR - if(H5Sselect_elements(dset_space_id, H5S_SELECT_SET, (size_t)1, (const hsize_t *)&coord) < 0) + if (H5Sselect_elements(dset_space_id, H5S_SELECT_SET, (size_t)1, + (const hsize_t *)&coord) < 0) FAIL_STACK_ERROR /* Create memory dataspace, with only one element */ - if((buf_space_id = H5Screate_simple(1, mem_dims, NULL)) < 0) + if ((buf_space_id = H5Screate_simple(1, mem_dims, NULL)) < 0) FAIL_STACK_ERROR /* Write the data to the dataset */ - if(H5Dwrite(dset_id, H5T_NATIVE_INT, buf_space_id, dset_space_id, H5P_DEFAULT, &val) < 0) + if (H5Dwrite(dset_id, H5T_NATIVE_INT, buf_space_id, dset_space_id, H5P_DEFAULT, &val) < 0) FAIL_STACK_ERROR /* Close objects used to perform I/O */ - if(H5Sclose(dset_space_id) < 0) + if (H5Sclose(dset_space_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(buf_space_id) < 0) + if (H5Sclose(buf_space_id) < 0) FAIL_STACK_ERROR /* Retrieve & verify the dataset's index info */ HDmemset(&nat_info, 0, sizeof(nat_info)); - if(H5Oget_native_info(dset_id, &nat_info, H5O_NATIVE_INFO_META_SIZE) < 0) + if (H5Oget_native_info(dset_id, &nat_info, H5O_NATIVE_INFO_META_SIZE) < 0) FAIL_STACK_ERROR - if(0 == nat_info.meta_size.obj.index_size) + if (0 == nat_info.meta_size.obj.index_size) FAIL_PUTS_ERROR("dataset index allocation size is zero") } /* end if */ /* Close dataset */ - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) FAIL_STACK_ERROR } /* end for */ - } /* end for */ + } /* end for */ /* Close test file */ - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR } /* end for */ - /************/ /* TEARDOWN */ /************/ - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) FAIL_STACK_ERROR PASSED(); @@ -13662,7 +15023,8 @@ test_0sized_dset_metadata_alloc(hid_t fapl_id) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dset_space_id); H5Pclose(buf_space_id); H5Pclose(fapl_id_copy); @@ -13670,12 +15032,12 @@ error: H5Pclose(dcpl_id); H5Dclose(dset_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_0sized_dset_metadata_alloc() */ - /*------------------------------------------------------------------------- * Function: main * @@ -13691,24 +15053,24 @@ error: int main(void) { - char filename[FILENAME_BUF_SIZE]; - hid_t file, grp, fapl, fapl2; - hid_t fcpl = -1, fcpl2 = -1; - unsigned new_format; - unsigned paged; - unsigned minimized_ohdr; - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - int nerrors = 0; + char filename[FILENAME_BUF_SIZE]; + hid_t file, grp, fapl, fapl2; + hid_t fcpl = -1, fcpl2 = -1; + unsigned new_format; + unsigned paged; + unsigned minimized_ohdr; + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + int nerrors = 0; const char *envval; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - int i; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + int i; /* Don't run this test using certain file drivers */ envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL) + if (envval == NULL) envval = "nomatch"; /* Current VFD that does not support contigous address space */ @@ -13719,33 +15081,33 @@ main(void) /* Initialize global arrays */ /* points */ - if(NULL == (points_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + if (NULL == (points_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) TEST_ERROR; - if(NULL == (points = (int **)HDcalloc(DSET_DIM1, sizeof(points_data)))) + if (NULL == (points = (int **)HDcalloc(DSET_DIM1, sizeof(points_data)))) TEST_ERROR; for (i = 0; i < DSET_DIM1; i++) points[i] = points_data + (i * DSET_DIM2); /* check */ - if(NULL == (check_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + if (NULL == (check_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) TEST_ERROR; - if(NULL == (check = (int **)HDcalloc(DSET_DIM1, sizeof(check_data)))) + if (NULL == (check = (int **)HDcalloc(DSET_DIM1, sizeof(check_data)))) TEST_ERROR; for (i = 0; i < DSET_DIM1; i++) check[i] = check_data + (i * DSET_DIM2); /* points_dbl */ - if(NULL == (points_dbl_data = (double *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(double)))) + if (NULL == (points_dbl_data = (double *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(double)))) TEST_ERROR; - if(NULL == (points_dbl = (double **)HDcalloc(DSET_DIM1, sizeof(points_dbl_data)))) + if (NULL == (points_dbl = (double **)HDcalloc(DSET_DIM1, sizeof(points_dbl_data)))) TEST_ERROR; for (i = 0; i < DSET_DIM1; i++) points_dbl[i] = points_dbl_data + (i * DSET_DIM2); /* check_dbl */ - if(NULL == (check_dbl_data = (double *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(double)))) + if (NULL == (check_dbl_data = (double *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(double)))) TEST_ERROR; - if(NULL == (check_dbl = (double **)HDcalloc(DSET_DIM1, sizeof(check_dbl_data)))) + if (NULL == (check_dbl = (double **)HDcalloc(DSET_DIM1, sizeof(check_dbl_data)))) TEST_ERROR; for (i = 0; i < DSET_DIM1; i++) check_dbl[i] = check_dbl_data + (i * DSET_DIM2); @@ -13755,67 +15117,72 @@ main(void) fapl = h5_fileaccess(); /* Turn off the chunk cache, so all the chunks are immediately written to disk */ - if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) + if (H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) goto error; rdcc_nbytes = 0; - if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + if (H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) goto error; /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR /* create a file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + if ((fcpl2 = H5Pcopy(fcpl)) < 0) TEST_ERROR - if((fcpl2 = H5Pcopy(fcpl)) < 0) TEST_ERROR /* Set file space strategy to paged aggregation and persisting free-space */ - if(H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) TEST_ERROR h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Test with paged aggregation enabled or not */ - for(paged = FALSE; paged <= TRUE; paged++) { + for (paged = FALSE; paged <= TRUE; paged++) { /* Temporary: skip testing for multi/split drivers: fail file create when persisting free-space or using paged aggregation strategy */ - if(!contig_addr_vfd && paged) + if (!contig_addr_vfd && paged) continue; - for(minimized_ohdr = FALSE; minimized_ohdr <= TRUE; minimized_ohdr++) { + for (minimized_ohdr = FALSE; minimized_ohdr <= TRUE; minimized_ohdr++) { /* Test with old & new format groups */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl, my_fcpl; /* Set the FAPL for the type of format */ - if(new_format) { + if (new_format) { my_fapl = fapl2; - if(paged) { + if (paged) { my_fcpl = fcpl2; HDputs("\nTesting with new file format and paged aggregation"); - } else { + } + else { my_fcpl = fcpl; HDputs("\nTesting with new file format and non-paged aggregation"); } } /* end if */ else { my_fapl = fapl; - if(paged) { + if (paged) { my_fcpl = fcpl2; HDputs("Testing with old file format and paged aggregation:"); - } else { + } + else { my_fcpl = fcpl; HDputs("Testing with old file format and non-paged aggregation:"); } } /* end else */ /* Create the file for this test */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, my_fcpl, my_fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, my_fcpl, my_fapl)) < 0) goto error; if (TRUE == minimized_ohdr) { @@ -13825,109 +15192,112 @@ main(void) } /* Cause the library to emit initial messages */ - if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Oset_comment(grp, "Causes diagnostic messages to be emitted") < 0) + if (H5Oset_comment(grp, "Causes diagnostic messages to be emitted") < 0) goto error; - if(H5Gclose(grp) < 0) + if (H5Gclose(grp) < 0) goto error; - nerrors += (test_create(file) < 0 ? 1 : 0); - nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); - nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); - nerrors += (test_compact_open_close_dirty(my_fapl) < 0 ? 1 : 0); - nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); - nerrors += (test_tconv(file) < 0 ? 1 : 0); - nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); - nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int(file) < 0 ? 1 : 0); - nerrors += (test_nbit_float(file) < 0 ? 1 : 0); - nerrors += (test_nbit_double(file) < 0 ? 1 : 0); - nerrors += (test_nbit_array(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); - nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); - nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); - nerrors += (test_multiopen (file) < 0 ? 1 : 0); - nerrors += (test_types(file) < 0 ? 1 : 0); - nerrors += (test_userblock_offset(envval, my_fapl, new_format) < 0 ? 1 : 0); - nerrors += (test_missing_filter(file) < 0 ? 1 : 0); - nerrors += (test_can_apply(file) < 0 ? 1 : 0); - nerrors += (test_can_apply2(file) < 0 ? 1 : 0); - nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); - nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); - nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); - nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); - nerrors += (test_filter_delete(file) < 0 ? 1 : 0); - nerrors += (test_filters_endianess() < 0 ? 1 : 0); - nerrors += (test_zero_dims(file) < 0 ? 1 : 0); - nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); - nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_create(file) < 0 ? 1 : 0); + nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); + nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); + nerrors += (test_compact_open_close_dirty(my_fapl) < 0 ? 1 : 0); + nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); + nerrors += (test_tconv(file) < 0 ? 1 : 0); + nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int(file) < 0 ? 1 : 0); + nerrors += (test_nbit_float(file) < 0 ? 1 : 0); + nerrors += (test_nbit_double(file) < 0 ? 1 : 0); + nerrors += (test_nbit_array(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); + nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); + nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); + nerrors += (test_multiopen(file) < 0 ? 1 : 0); + nerrors += (test_types(file) < 0 ? 1 : 0); + nerrors += (test_userblock_offset(envval, my_fapl, new_format) < 0 ? 1 : 0); + nerrors += (test_missing_filter(file) < 0 ? 1 : 0); + nerrors += (test_can_apply(file) < 0 ? 1 : 0); + nerrors += (test_can_apply2(file) < 0 ? 1 : 0); + nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); + nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); + nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); + nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_filter_delete(file) < 0 ? 1 : 0); + nerrors += (test_filters_endianess() < 0 ? 1 : 0); + nerrors += (test_zero_dims(file) < 0 ? 1 : 0); + nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); + nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += (test_deprec(file) < 0 ? 1 : 0); + nerrors += (test_deprec(file) < 0 ? 1 : 0); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); - nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_fast(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_reopen_chunk_fast(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_fast_bug1(my_fapl) < 0 ? 1 : 0); - nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); - nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); - nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); - nerrors += (test_idx_compatible() < 0 ? 1 : 0); - nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); - nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); - nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); - nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); - nerrors += (test_storage_size(my_fapl) < 0 ? 1 : 0); - nerrors += (test_power2up(my_fapl) < 0 ? 1 : 0); - - nerrors += (test_swmr_non_latest(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_earray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_farray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - nerrors += (test_bt2_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); - - if(H5Fclose(file) < 0) + nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); + nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_fast(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_reopen_chunk_fast(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_fast_bug1(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); + nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); + nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); + nerrors += (test_idx_compatible() < 0 ? 1 : 0); + nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); + nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); + nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); + nerrors += (test_storage_size(my_fapl) < 0 ? 1 : 0); + nerrors += (test_power2up(my_fapl) < 0 ? 1 : 0); + + nerrors += (test_swmr_non_latest(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_earray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_farray_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_bt2_hdr_fd(envval, my_fapl) < 0 ? 1 : 0); + + if (H5Fclose(file) < 0) goto error; } /* end for new_format */ - } /* end for minimized_ohdr */ - } /* end for paged */ + } /* end for minimized_ohdr */ + } /* end for paged */ /* Close property lists */ - if(H5Pclose(fapl2) < 0) TEST_ERROR - if(H5Pclose(fcpl) < 0) TEST_ERROR - if(H5Pclose(fcpl2) < 0) TEST_ERROR + if (H5Pclose(fapl2) < 0) + TEST_ERROR + if (H5Pclose(fcpl) < 0) + TEST_ERROR + if (H5Pclose(fcpl2) < 0) + TEST_ERROR /* Tests that do not use files */ - nerrors += (test_scatter() < 0 ? 1 : 0); - nerrors += (test_gather() < 0 ? 1 : 0); - nerrors += (test_scatter_error() < 0 ? 1 : 0); - nerrors += (test_gather_error() < 0 ? 1 : 0); + nerrors += (test_scatter() < 0 ? 1 : 0); + nerrors += (test_gather() < 0 ? 1 : 0); + nerrors += (test_scatter_error() < 0 ? 1 : 0); + nerrors += (test_gather_error() < 0 ? 1 : 0); /* Tests version bounds using its own file */ - nerrors += (test_versionbounds() < 0 ? 1 : 0); + nerrors += (test_versionbounds() < 0 ? 1 : 0); nerrors += (test_object_header_minimization_dcpl() < 0 ? 1 : 0); /* Run misc tests */ - nerrors += (dls_01_main() < 0 ? 1 : 0); - nerrors += (test_0sized_dset_metadata_alloc(fapl) < 0 ? 1 : 0); + nerrors += (dls_01_main() < 0 ? 1 : 0); + nerrors += (test_0sized_dset_metadata_alloc(fapl) < 0 ? 1 : 0); /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if(nerrors) + if (nerrors) goto error; HDprintf("All dataset tests passed.\n"); #ifdef H5_HAVE_FILTER_SZIP @@ -13960,8 +15330,6 @@ error: HDfree(check_dbl_data); nerrors = MAX(1, nerrors); - HDprintf("***** %d DATASET TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d DATASET TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/dt_arith.c b/test/dt_arith.c index 8d04770..c425db0 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -21,7 +21,7 @@ #include "h5test.h" /* Number of elements in each random test */ -#define NTESTELEM 10000 +#define NTESTELEM 10000 /* Epsilon for floating-point comparisons */ #define FP_EPSILON 0.000001F @@ -30,7 +30,7 @@ * Offset from alinged memory returned by malloc(). This can be used to test * that type conversions handle non-aligned buffers correctly. */ -#define ALIGNMENT 1 +#define ALIGNMENT 1 /* * Define if you want to test alignment code on a machine that doesn't @@ -41,29 +41,34 @@ /* Alignment test stuff */ #ifdef TEST_ALIGNMENT -#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#define H5T_FRIEND /*suppress error about including H5Tpkg */ #include "H5Tpkg.h" #endif -#define SET_ALIGNMENT(TYPE,VAL) \ - H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) +#define SET_ALIGNMENT(TYPE, VAL) H5T_NATIVE_##TYPE##_ALIGN_g = MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) -const char *FILENAME[] = { - "dt_arith1", - "dt_arith2", - NULL -}; +const char *FILENAME[] = {"dt_arith1", "dt_arith2", NULL}; /* * Count up or down depending on whether the machine is big endian or little * endian. If local variable `endian' is H5T_ORDER_BE then the result will * be I, otherwise the result will be Z-(I+1). */ -#define ENDIAN(Z,I,E) (H5T_ORDER_BE==E?(I):(Z)-((I)+1)) +#define ENDIAN(Z, I, E) (H5T_ORDER_BE == E ? (I) : (Z) - ((I) + 1)) typedef enum dtype_t { - INT_SCHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, - INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, FLT_FLOAT, FLT_DOUBLE, -#if H5_SIZEOF_LONG_DOUBLE !=0 + INT_SCHAR, + INT_UCHAR, + INT_SHORT, + INT_USHORT, + INT_INT, + INT_UINT, + INT_LONG, + INT_ULONG, + INT_LLONG, + INT_ULLONG, + FLT_FLOAT, + FLT_DOUBLE, +#if H5_SIZEOF_LONG_DOUBLE != 0 FLT_LDOUBLE, #endif OTHER @@ -87,311 +92,313 @@ static int skip_overflow_tests_g = 0; * Decide what values of floating-point number we want to test. They are * 1 - normalized; 2 - denormalized; 3 - special. */ -#define TEST_NOOP 0 -#define TEST_NORMAL 1 -#define TEST_DENORM 2 -#define TEST_SPECIAL 3 +#define TEST_NOOP 0 +#define TEST_NORMAL 1 +#define TEST_DENORM 2 +#define TEST_SPECIAL 3 /* Temporary buffer sizes */ -#define TMP_BUF_DIM1 32 -#define TMP_BUF_DIM2 100 +#define TMP_BUF_DIM1 32 +#define TMP_BUF_DIM2 100 /* Don't use hardware conversions if set */ static int without_hardware_g = 0; /* Allocates memory aligned on a certain boundary. */ -#define aligned_malloc(Z) ((void*)((char*)HDmalloc(ALIGNMENT+Z)+ALIGNMENT)) -#define aligned_free(M) HDfree((char*)(M)-ALIGNMENT) +#define aligned_malloc(Z) ((void *)((char *)HDmalloc(ALIGNMENT + Z) + ALIGNMENT)) +#define aligned_free(M) HDfree((char *)(M)-ALIGNMENT) /* Initialize source buffer of integer for integer->integer and integer->floating-point conversion test. * This algorithm is mainly to avoid any casting and comparison between source and destination types * for compiler, because we're testing conversions. */ -#define INIT_INTEGER(TYPE, SRC_MAX, SRC_MIN, SRC_SIZE, DST_SIZE, SRC_PREC, BUF, SAVED, NELMTS) \ -{ \ - unsigned char *buf_p, *saved_p; \ - unsigned int n; \ - TYPE value1 = 1; \ - TYPE value2 = 0; \ - \ - /* Allocate buffers */ \ - NELMTS=SRC_PREC*3; \ - BUF = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - SAVED = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - HDmemset(BUF, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - HDmemset(SAVED, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - \ - buf_p = BUF; \ - saved_p = SAVED; \ - \ - /*positive values, ascending order. VALUE1 starts from 00000001, to 00000010, until 10000000*/ \ - /*VALUE2 ascends from 00000000, to 00000011, 00000111,..., until 11111111.*/ \ - for(n=0; n=100 && SRC_MAX_10_EXP<400) { /*for double*/ \ - factor = 2; \ - multiply = 10000; \ - } else { /*for long double*/ \ - factor = 3; \ - multiply = 100000000; \ - } \ - \ - /*The number of values if multiplied by 10 for each step.*/ \ - num_norm = (SRC_MAX_10_EXP - SRC_MIN_10_EXP); \ - /*Reduce the number of values by 2^factor. MULTIPLY=10^(2^factor). Using this algorithm \ - *instead of arithmatic operation to avoid any conversion*/ \ - num_norm >>= factor; \ - \ - /*Total number of values*/ \ - NELMTS = 2 * /*both positive and negative*/ \ - (num_norm + /*number of normalized values*/ \ - 1); /*maximal normalized value*/ \ - \ - /* Allocate buffers */ \ - BUF = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - SAVED = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - HDmemset(BUF, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - HDmemset(SAVED, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - \ - buf_p = BUF; \ - saved_p = SAVED; \ - \ - /*Normalized values*/ \ - value1 = SRC_MIN; \ - value2 = -SRC_MIN; \ - for(n=0; n-SRC_MAX) { /*negative*/ \ - HDmemcpy(buf_p, &value2, SRC_SIZE); \ - HDmemcpy(saved_p, &value2, SRC_SIZE); \ - value2 *= multiply; \ - buf_p += SRC_SIZE; \ - saved_p += SRC_SIZE; \ - } \ - } \ - \ - value1 = SRC_MAX; /*maximal value*/ \ - HDmemcpy(buf_p, &value1, SRC_SIZE); \ - HDmemcpy(saved_p, &value1, SRC_SIZE); \ - buf_p += SRC_SIZE; \ - saved_p += SRC_SIZE; \ - \ - value2 = -SRC_MAX; /*negative value*/ \ - HDmemcpy(buf_p, &value2, SRC_SIZE); \ - HDmemcpy(saved_p, &value2, SRC_SIZE); \ - buf_p += SRC_SIZE; \ - saved_p += SRC_SIZE; \ -} +#define INIT_FP_NORM(TYPE, SRC_MAX, SRC_MIN, SRC_MAX_10_EXP, SRC_MIN_10_EXP, SRC_SIZE, DST_SIZE, BUF, SAVED, \ + NELMTS) \ + { \ + unsigned char *buf_p, *saved_p; \ + size_t num_norm, factor, n; \ + TYPE value1, value2; \ + TYPE multiply; \ + \ + /*Determine the number of normalized values and increment pace. The values start from \ + *minimal normalized value and are multiplied by MULTIPLY each step until reach to maximal \ + *normalized value.*/ \ + if (SRC_MAX_10_EXP < 100) { /*for float*/ \ + factor = 0; \ + multiply = 10; \ + } \ + else if (SRC_MAX_10_EXP >= 100 && SRC_MAX_10_EXP < 400) { /*for double*/ \ + factor = 2; \ + multiply = 10000; \ + } \ + else { /*for long double*/ \ + factor = 3; \ + multiply = 100000000; \ + } \ + \ + /*The number of values if multiplied by 10 for each step.*/ \ + num_norm = (SRC_MAX_10_EXP - SRC_MIN_10_EXP); \ + /*Reduce the number of values by 2^factor. MULTIPLY=10^(2^factor). Using this algorithm \ + *instead of arithmatic operation to avoid any conversion*/ \ + num_norm >>= factor; \ + \ + /*Total number of values*/ \ + NELMTS = 2 * /*both positive and negative*/ \ + (num_norm + /*number of normalized values*/ \ + 1); /*maximal normalized value*/ \ + \ + /* Allocate buffers */ \ + BUF = (unsigned char *)aligned_malloc(NELMTS * MAX(SRC_SIZE, DST_SIZE)); \ + SAVED = (unsigned char *)aligned_malloc(NELMTS * MAX(SRC_SIZE, DST_SIZE)); \ + HDmemset(BUF, 0, NELMTS *MAX(SRC_SIZE, DST_SIZE)); \ + HDmemset(SAVED, 0, NELMTS *MAX(SRC_SIZE, DST_SIZE)); \ + \ + buf_p = BUF; \ + saved_p = SAVED; \ + \ + /*Normalized values*/ \ + value1 = SRC_MIN; \ + value2 = -SRC_MIN; \ + for (n = 0; n < num_norm; n++) { \ + if (value1 < SRC_MAX) { /*positive*/ \ + HDmemcpy(buf_p, &value1, SRC_SIZE); \ + HDmemcpy(saved_p, &value1, SRC_SIZE); \ + value1 *= multiply; \ + buf_p += SRC_SIZE; \ + saved_p += SRC_SIZE; \ + } \ + if (value2 > -SRC_MAX) { /*negative*/ \ + HDmemcpy(buf_p, &value2, SRC_SIZE); \ + HDmemcpy(saved_p, &value2, SRC_SIZE); \ + value2 *= multiply; \ + buf_p += SRC_SIZE; \ + saved_p += SRC_SIZE; \ + } \ + } \ + \ + value1 = SRC_MAX; /*maximal value*/ \ + HDmemcpy(buf_p, &value1, SRC_SIZE); \ + HDmemcpy(saved_p, &value1, SRC_SIZE); \ + buf_p += SRC_SIZE; \ + saved_p += SRC_SIZE; \ + \ + value2 = -SRC_MAX; /*negative value*/ \ + HDmemcpy(buf_p, &value2, SRC_SIZE); \ + HDmemcpy(saved_p, &value2, SRC_SIZE); \ + buf_p += SRC_SIZE; \ + saved_p += SRC_SIZE; \ + } /* Allocate buffer and initialize it with floating-point denormalized values. * It's for conversion test of floating-point as the source. */ -#define INIT_FP_DENORM(TYPE, SRC_MANT_DIG, SRC_SIZE, SRC_PREC, SRC_ORDR, DST_SIZE, \ - BUF, SAVED, NELMTS) \ -{ \ - unsigned char *buf_p, *saved_p; \ - unsigned char *tmp1, *tmp2; \ - size_t n; \ - \ - /*Total number of values*/ \ - NELMTS = 2 * /*both positive and negative*/ \ - (SRC_MANT_DIG - 1); /*number of denormalized values*/ \ - \ - /* Allocate buffers */ \ - BUF = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - SAVED = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - HDmemset(BUF, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - HDmemset(SAVED, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ - \ - tmp1 = (unsigned char*)HDcalloc((size_t)1, (size_t)SRC_SIZE); \ - tmp2 = (unsigned char*)HDcalloc((size_t)1, (size_t)SRC_SIZE); \ - \ - buf_p = BUF; \ - saved_p = SAVED; \ - \ - /*Denormalized values. Exponent is 0. Let mantissa starts from 00000001, 00000011, \ - *00000111,..., until 11111111.*/ \ - HDmemset(tmp1, 0, SRC_SIZE); \ - HDmemset(tmp2, 0, SRC_SIZE); \ - H5T__bit_set (tmp2, SRC_PREC-1, (size_t)1, TRUE); /*the negative value*/ \ - for(n=0; n integer conversions"); - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { H5_FAILED(); HDprintf("Can't create data transfer property list\n"); goto error; } /* Test conversion from double (the value is SCHAR_MAX) to signed char. */ - endian = H5Tget_order(H5T_NATIVE_DOUBLE); - src_size1 = H5Tget_size(H5T_NATIVE_DOUBLE); - dst_size1 = H5Tget_size(H5T_NATIVE_SCHAR); - buf1 = (unsigned char*)HDcalloc((size_t)1, (size_t)MAX(src_size1, dst_size1)); - saved_buf1 = (unsigned char*)HDcalloc((size_t)1, (size_t)MAX(src_size1, dst_size1)); + endian = H5Tget_order(H5T_NATIVE_DOUBLE); + src_size1 = H5Tget_size(H5T_NATIVE_DOUBLE); + dst_size1 = H5Tget_size(H5T_NATIVE_SCHAR); + buf1 = (unsigned char *)HDcalloc((size_t)1, (size_t)MAX(src_size1, dst_size1)); + saved_buf1 = (unsigned char *)HDcalloc((size_t)1, (size_t)MAX(src_size1, dst_size1)); HDmemcpy(buf1, &src_d, src_size1); HDmemcpy(saved_buf1, &src_d, src_size1); /* Register exception handling function and signal the destination is "signed char". */ flag = 1; - if(H5Pset_type_conv_cb(dxpl_id, expt_handle, &flag) < 0) { + if (H5Pset_type_conv_cb(dxpl_id, expt_handle, &flag) < 0) { H5_FAILED(); HDprintf("Can't register conversion callback\n"); goto error; } /* Do conversion */ - if(H5Tconvert(H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR, (size_t)1, buf1, NULL, dxpl_id) < 0) { + if (H5Tconvert(H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR, (size_t)1, buf1, NULL, dxpl_id) < 0) { H5_FAILED(); HDprintf("Can't convert data\n"); goto error; @@ -769,23 +774,23 @@ static int test_particular_fp_integer(void) HDmemcpy(&dst_c, buf1, dst_size1); /* Print errors */ - if(dst_c != SCHAR_MAX) { - double x = 0.; - signed char y; + if (dst_c != SCHAR_MAX) { + double x = 0.; + signed char y; - if(0 == fails_this_test++) + if (0 == fails_this_test++) H5_FAILED(); HDprintf(" test double to signed char:\n"); HDprintf(" src = "); - for (j=0; j derived floating-point conversions"); - HDprintf("%-70s", str); - HDfflush(stdout); + if (0 == fails_this_test++) { + HDsnprintf(str, sizeof(str), + "\nTesting random sw derived floating-point -> derived floating-point conversions"); + HDprintf("%-70s", str); + HDfflush(stdout); H5_FAILED(); } HDprintf(" test %u elmt %u: \n", 1, (unsigned)i); HDprintf(" src = "); - for (j=0; j=max_fails) { + if (fails_this_test >= max_fails) { HDputs(" maximum failures reached, aborting test..."); goto error; } @@ -1106,9 +1113,9 @@ test_derived_flt(void) HDfree(buf); HDfree(saved_buf); HDfree(aligned); - buf = NULL; + buf = NULL; saved_buf = NULL; - aligned = NULL; + aligned = NULL; /*-------------------------------------------------------------------------- * 2nd floating-point type @@ -1119,77 +1126,77 @@ test_derived_flt(void) * 2 1 0 * SEEEEEEE MMMMMMMM MMMMMMMM *--------------------------------------------------------------------------*/ - if(H5Tset_fields(tid2, (size_t)23, (size_t)16, (size_t)7, (size_t)0, (size_t)16) < 0) { + if (H5Tset_fields(tid2, (size_t)23, (size_t)16, (size_t)7, (size_t)0, (size_t)16) < 0) { H5_FAILED(); HDprintf("Can't set fields\n"); goto error; } - if(H5Tset_offset(tid2, (size_t)0) < 0) { + if (H5Tset_offset(tid2, (size_t)0) < 0) { H5_FAILED(); HDprintf("Can't set offset\n"); goto error; } - if(H5Tset_precision(tid2, (size_t)24) < 0) { + if (H5Tset_precision(tid2, (size_t)24) < 0) { H5_FAILED(); HDprintf("Can't set precision 2\n"); goto error; } - if(H5Tset_size(tid2, (size_t)3) < 0) { + if (H5Tset_size(tid2, (size_t)3) < 0) { H5_FAILED(); HDprintf("Can't set size\n"); goto error; } - if(H5Tset_ebias(tid2, (size_t)63) < 0) { + if (H5Tset_ebias(tid2, (size_t)63) < 0) { H5_FAILED(); HDprintf("Can't set size\n"); goto error; } - if(H5Tset_pad(tid2, H5T_PAD_ZERO, H5T_PAD_ZERO) < 0) { + if (H5Tset_pad(tid2, H5T_PAD_ZERO, H5T_PAD_ZERO) < 0) { H5_FAILED(); HDprintf("Can't set padding\n"); goto error; } - if(H5Tcommit2(file, "new float type 2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(file, "new float type 2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Can't set inpad\n"); goto error; } - if(H5Tclose(tid2) < 0) { + if (H5Tclose(tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } - if((tid2 = H5Topen2(file, "new float type 2", H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(file, "new float type 2", H5P_DEFAULT)) < 0) FAIL_PUTS_ERROR("Can't open datatype") - if(H5Tget_fields(tid2, &spos, &epos, &esize, &mpos, &msize) < 0) { + if (H5Tget_fields(tid2, &spos, &epos, &esize, &mpos, &msize) < 0) { H5_FAILED(); HDprintf("Can't get fields\n"); goto error; } - if(spos != 23 || epos != 16 || esize != 7 || mpos != 0 || msize != 16) { + if (spos != 23 || epos != 16 || esize != 7 || mpos != 0 || msize != 16) { H5_FAILED(); HDprintf("Wrong field values\n"); goto error; } - if(H5Tget_precision(tid2) != 24) { + if (H5Tget_precision(tid2) != 24) { H5_FAILED(); HDprintf("Can't get precision or wrong precision\n"); goto error; } - if(H5Tget_offset(tid2)!=0) { + if (H5Tget_offset(tid2) != 0) { H5_FAILED(); HDprintf("Can't get offset or wrong offset\n"); goto error; } - if((size = H5Tget_size(tid2))!=3) { + if ((size = H5Tget_size(tid2)) != 3) { H5_FAILED(); HDprintf("Can't get size or wrong size\n"); goto error; } - if(H5Tget_ebias(tid2)!=63) { + if (H5Tget_ebias(tid2) != 63) { H5_FAILED(); HDprintf("Can't get exponent bias or wrong bias\n"); goto error; @@ -1199,95 +1206,98 @@ test_derived_flt(void) * Then convert data from the 1st type back to the 2nd type. * Compare the final data with the original data. */ - src_size = H5Tget_size(tid2); - dst_size = H5Tget_size(tid1); - endian = H5Tget_order(tid2); - buf = (unsigned char *)HDmalloc(nelmts * (MAX(src_size, dst_size))); + src_size = H5Tget_size(tid2); + dst_size = H5Tget_size(tid1); + endian = H5Tget_order(tid2); + buf = (unsigned char *)HDmalloc(nelmts * (MAX(src_size, dst_size))); saved_buf = (unsigned char *)HDmalloc(nelmts * src_size); HDmemset(buf, 0, nelmts * MAX(src_size, dst_size)); - HDmemset(saved_buf, 0, nelmts*src_size); + HDmemset(saved_buf, 0, nelmts * src_size); - for(i=0; i derived floating-point conversions"); - HDprintf("%-70s", str); - HDfflush(stdout); + if (0 == fails_this_test++) { + HDsnprintf(str, sizeof(str), + "\nTesting random sw derived floating-point -> derived floating-point conversions"); + HDprintf("%-70s", str); + HDfflush(stdout); H5_FAILED(); } HDprintf(" test %u elmt %u: \n", 1, (unsigned)i); HDprintf(" src = "); - for (j=0; j=max_fails) { + if (fails_this_test >= max_fails) { HDputs(" maximum failures reached, aborting test..."); goto error; } } - if (buf) HDfree(buf); - if (saved_buf) HDfree(saved_buf); + if (buf) + HDfree(buf); + if (saved_buf) + HDfree(saved_buf); - if(H5Tclose(tid1) < 0) { + if (H5Tclose(tid1) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } - if(H5Tclose(tid2) < 0) { + if (H5Tclose(tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } - if(H5Pclose(dxpl_id) < 0) { + if (H5Pclose(dxpl_id) < 0) { H5_FAILED(); HDprintf("Can't close property list\n"); goto error; } - if(H5Fclose(file) < 0) { + if (H5Fclose(file) < 0) { H5_FAILED(); HDprintf("Can't close file\n"); goto error; @@ -1298,21 +1308,26 @@ test_derived_flt(void) /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - reset_hdf5(); /*print statistics*/ + reset_hdf5(); /*print statistics*/ return 0; - error: - if (buf) HDfree(buf); - if (saved_buf) HDfree(saved_buf); - if (aligned) HDfree(aligned); +error: + if (buf) + HDfree(buf); + if (saved_buf) + HDfree(saved_buf); + if (aligned) + HDfree(aligned); HDfflush(stdout); - H5E_BEGIN_TRY { - H5Tclose (tid1); - H5Tclose (tid2); - H5Pclose (dxpl_id); - H5Fclose (file); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Tclose(tid1); + H5Tclose(tid2); + H5Pclose(dxpl_id); + H5Fclose(file); + } + H5E_END_TRY; /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); @@ -1322,7 +1337,6 @@ test_derived_flt(void) return MAX((int)fails_this_test, 1); } - /*------------------------------------------------------------------------- * Function: test_derived_integer * @@ -1342,41 +1356,41 @@ test_derived_flt(void) static int test_derived_integer(void) { - hid_t file=-1, tid1=-1, tid2=-1; - hid_t dxpl_id=-1; - char filename[1024]; - size_t src_size, dst_size; - unsigned char *buf=NULL, *saved_buf=NULL; - int endian; /*endianess */ - size_t nelmts = NTESTELEM; - unsigned int fails_this_test = 0; - const size_t max_fails=40; /*max number of failures*/ - char str[256]; /*message string */ - unsigned int i, j; + hid_t file = -1, tid1 = -1, tid2 = -1; + hid_t dxpl_id = -1; + char filename[1024]; + size_t src_size, dst_size; + unsigned char *buf = NULL, *saved_buf = NULL; + int endian; /*endianess */ + size_t nelmts = NTESTELEM; + unsigned int fails_this_test = 0; + const size_t max_fails = 40; /*max number of failures*/ + char str[256]; /*message string */ + unsigned int i, j; TESTING("user-define and query functions of integer types"); /* Create File */ h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); HDprintf("Can't create file\n"); goto error; } - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { H5_FAILED(); HDprintf("Can't create data transfer property list\n"); goto error; } - if((tid1 = H5Tcopy(H5T_STD_I32LE)) < 0) { + if ((tid1 = H5Tcopy(H5T_STD_I32LE)) < 0) { H5_FAILED(); HDprintf("Can't copy data type\n"); goto error; } - if((tid2 = H5Tcopy(H5T_STD_U64LE)) < 0) { + if ((tid2 = H5Tcopy(H5T_STD_U64LE)) < 0) { H5_FAILED(); HDprintf("Can't copy data type\n"); goto error; @@ -1394,60 +1408,60 @@ test_derived_integer(void) * of a new integer type, H5Tset_precision, H5Tset_offset, H5Tset_size, * H5Tset_order, H5Tset_pad, H5Tset_sign. *--------------------------------------------------------------------------*/ - if(H5Tset_offset(tid1, (size_t)0) < 0) { + if (H5Tset_offset(tid1, (size_t)0) < 0) { H5_FAILED(); HDprintf("Can't set offset\n"); goto error; } - if(H5Tset_size(tid1, (size_t)3) < 0) { + if (H5Tset_size(tid1, (size_t)3) < 0) { H5_FAILED(); HDprintf("Can't set size\n"); goto error; } - if(H5Tset_precision(tid1, (size_t)24) < 0) { + if (H5Tset_precision(tid1, (size_t)24) < 0) { H5_FAILED(); HDprintf("Can't set precision\n"); goto error; } - if(H5Tset_order(tid1, H5T_ORDER_BE) < 0) { + if (H5Tset_order(tid1, H5T_ORDER_BE) < 0) { H5_FAILED(); HDprintf("Can't set order\n"); goto error; } - if(H5Tcommit2(file, "new integer type 1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(file, "new integer type 1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Can't commit data type\n"); goto error; } - if(H5Tclose(tid1) < 0) { + if (H5Tclose(tid1) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } - if((tid1 = H5Topen2(file, "new integer type 1", H5P_DEFAULT)) < 0) + if ((tid1 = H5Topen2(file, "new integer type 1", H5P_DEFAULT)) < 0) FAIL_PUTS_ERROR("Can't open datatype") - if(H5Tget_precision(tid1) != 24) { + if (H5Tget_precision(tid1) != 24) { H5_FAILED(); HDprintf("Can't get precision or wrong precision\n"); goto error; } - if(H5Tget_offset(tid1) != 0) { + if (H5Tget_offset(tid1) != 0) { H5_FAILED(); HDprintf("Can't get offset or wrong offset\n"); goto error; } - if(H5Tget_size(tid1) != 3) { + if (H5Tget_size(tid1) != 3) { H5_FAILED(); HDprintf("Can't get size or wrong size\n"); goto error; } - if(H5Tget_order(tid1)!=H5T_ORDER_BE) { + if (H5Tget_order(tid1) != H5T_ORDER_BE) { H5_FAILED(); HDprintf("Can't get order or wrong order\n"); goto error; @@ -1461,54 +1475,54 @@ test_derived_integer(void) * 7 6 5 4 3 2 1 0 * ??????SI IIIIIIII IIIIIIII IIIIIIII IIIIIIII IIIIIIII IIIIII?? ???????? *--------------------------------------------------------------------------*/ - if(H5Tset_precision(tid2, (size_t)48) < 0) { + if (H5Tset_precision(tid2, (size_t)48) < 0) { H5_FAILED(); HDprintf("Can't set precision\n"); goto error; } - if(H5Tset_offset(tid2, (size_t)10) < 0) { + if (H5Tset_offset(tid2, (size_t)10) < 0) { H5_FAILED(); HDprintf("Can't set offset\n"); goto error; } - if(H5Tset_sign(tid2, H5T_SGN_2) < 0) { + if (H5Tset_sign(tid2, H5T_SGN_2) < 0) { H5_FAILED(); HDprintf("Can't set offset\n"); goto error; } - if(H5Tcommit2(file, "new integer type 2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(file, "new integer type 2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Can't commit data type\n"); goto error; } - if(H5Tclose(tid2) < 0) { + if (H5Tclose(tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } - if((tid2 = H5Topen2(file, "new integer type 2", H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(file, "new integer type 2", H5P_DEFAULT)) < 0) FAIL_PUTS_ERROR("Can't open datatype") - if(H5Tget_precision(tid2) != 48) { + if (H5Tget_precision(tid2) != 48) { H5_FAILED(); HDprintf("Can't get precision or wrong precision\n"); goto error; } - if(H5Tget_offset(tid2) != 10) { + if (H5Tget_offset(tid2) != 10) { H5_FAILED(); HDprintf("Can't get offset or wrong offset\n"); goto error; } - if(H5Tget_size(tid2) != 8) { + if (H5Tget_size(tid2) != 8) { H5_FAILED(); HDprintf("Can't get size or wrong size\n"); goto error; } - if(H5Tget_sign(tid2)!=H5T_SGN_2) { + if (H5Tget_sign(tid2) != H5T_SGN_2) { H5_FAILED(); HDprintf("Can't get sign or wrong sign\n"); goto error; @@ -1518,84 +1532,85 @@ test_derived_integer(void) * Then convert data from the 2nd type back to the 1st type. * Compare the final data with the original data. */ - src_size = H5Tget_size(tid1); - dst_size = H5Tget_size(tid2); - endian = H5Tget_order(tid1); - buf = (unsigned char *)HDmalloc(nelmts*(MAX(src_size, dst_size))); - saved_buf = (unsigned char *)HDmalloc(nelmts*src_size); + src_size = H5Tget_size(tid1); + dst_size = H5Tget_size(tid2); + endian = H5Tget_order(tid1); + buf = (unsigned char *)HDmalloc(nelmts * (MAX(src_size, dst_size))); + saved_buf = (unsigned char *)HDmalloc(nelmts * src_size); HDmemset(buf, 0, nelmts * MAX(src_size, dst_size)); - HDmemset(saved_buf, 0, nelmts*src_size); + HDmemset(saved_buf, 0, nelmts * src_size); - for(i=0; i derived integer conversions"); - HDprintf("%-70s", str); - HDfflush(stdout); + if (0 == fails_this_test++) { + HDsnprintf(str, sizeof(str), + "\nTesting random sw derived integer -> derived integer conversions"); + HDprintf("%-70s", str); + HDfflush(stdout); H5_FAILED(); } HDprintf(" test %u elmt %u: \n", 1, (unsigned)i); HDprintf(" src = "); - for (j=0; j=max_fails) { + if (fails_this_test >= max_fails) { HDputs(" maximum failures reached, aborting test..."); goto error; } } - if(H5Tclose(tid1) < 0) { + if (H5Tclose(tid1) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } - if(H5Tclose(tid2) < 0) { + if (H5Tclose(tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } - if(H5Pclose(dxpl_id) < 0) { + if (H5Pclose(dxpl_id) < 0) { H5_FAILED(); HDprintf("Can't close property list\n"); goto error; } - if(H5Fclose(file) < 0) { + if (H5Fclose(file) < 0) { H5_FAILED(); HDprintf("Can't close file\n"); goto error; @@ -1609,20 +1624,24 @@ test_derived_integer(void) /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - reset_hdf5(); /*print statistics*/ + reset_hdf5(); /*print statistics*/ return 0; - error: - if (buf) HDfree(buf); - if (saved_buf) HDfree(saved_buf); +error: + if (buf) + HDfree(buf); + if (saved_buf) + HDfree(saved_buf); HDfflush(stdout); - H5E_BEGIN_TRY { - H5Tclose (tid1); - H5Tclose (tid2); - H5Pclose (dxpl_id); - H5Fclose (file); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Tclose(tid1); + H5Tclose(tid2); + H5Pclose(dxpl_id); + H5Fclose(file); + } + H5E_END_TRY; /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); @@ -1632,7 +1651,6 @@ test_derived_integer(void) return MAX((int)fails_this_test, 1); } - /*------------------------------------------------------------------------- * Function: test_conv_int_1 * @@ -1659,160 +1677,189 @@ test_derived_integer(void) static int test_conv_int_1(const char *name, hid_t src, hid_t dst) { - size_t nelmts=0; /*num values per test */ - const size_t max_fails=8; /*max number of failures*/ - size_t fails_all_tests=0; /*number of failures */ - size_t fails_this_test; /*fails for this test */ - char str[256]; /*hello string */ - dtype_t src_type, dst_type; /*data types */ - const char *src_type_name=NULL; /*source type name */ - const char *dst_type_name=NULL; /*destination type name */ - int endian; /*machine endianess */ - size_t src_size, dst_size; /*type sizes */ - unsigned char *buf=NULL; /*buffer for conversion */ - unsigned char *saved=NULL; /*original values */ - size_t j, k; /*counters */ - unsigned char *hw=NULL; /*hardware conv result */ - unsigned char src_bits[32]; /*src value in LE order */ - unsigned char dst_bits[32]; /*dest value in LE order*/ - size_t src_nbits; /*source length in bits */ - size_t dst_nbits; /*dst length in bits */ - H5T_sign_t src_sign; /*source sign type */ - H5T_sign_t dst_sign; /*dst sign type */ - void *aligned=NULL; /*aligned temp buffer */ + size_t nelmts = 0; /*num values per test */ + const size_t max_fails = 8; /*max number of failures*/ + size_t fails_all_tests = 0; /*number of failures */ + size_t fails_this_test; /*fails for this test */ + char str[256]; /*hello string */ + dtype_t src_type, dst_type; /*data types */ + const char * src_type_name = NULL; /*source type name */ + const char * dst_type_name = NULL; /*destination type name */ + int endian; /*machine endianess */ + size_t src_size, dst_size; /*type sizes */ + unsigned char * buf = NULL; /*buffer for conversion */ + unsigned char * saved = NULL; /*original values */ + size_t j, k; /*counters */ + unsigned char * hw = NULL; /*hardware conv result */ + unsigned char src_bits[32]; /*src value in LE order */ + unsigned char dst_bits[32]; /*dest value in LE order*/ + size_t src_nbits; /*source length in bits */ + size_t dst_nbits; /*dst length in bits */ + H5T_sign_t src_sign; /*source sign type */ + H5T_sign_t dst_sign; /*dst sign type */ + void * aligned = NULL; /*aligned temp buffer */ signed char hw_char; - unsigned char hw_uchar; - short hw_short; - unsigned short hw_ushort; - int hw_int; - unsigned hw_uint; - long hw_long; - unsigned long hw_ulong; - long long hw_llong; - unsigned long long hw_ullong; + unsigned char hw_uchar; + short hw_short; + unsigned short hw_ushort; + int hw_int; + unsigned hw_uint; + long hw_long; + unsigned long hw_ulong; + long long hw_llong; + unsigned long long hw_ullong; /* What are the names of the source and destination types */ if (H5Tequal(src, H5T_NATIVE_SCHAR)) { - src_type_name = "signed char"; - src_type = INT_SCHAR; - } else if (H5Tequal(src, H5T_NATIVE_UCHAR)) { - src_type_name = "unsigned char"; - src_type = INT_UCHAR; - } else if (H5Tequal(src, H5T_NATIVE_SHORT)) { - src_type_name = "short"; - src_type = INT_SHORT; - } else if (H5Tequal(src, H5T_NATIVE_USHORT)) { - src_type_name = "unsigned short"; - src_type = INT_USHORT; - } else if (H5Tequal(src, H5T_NATIVE_INT)) { - src_type_name = "int"; - src_type = INT_INT; - } else if (H5Tequal(src, H5T_NATIVE_UINT)) { - src_type_name = "unsigned int"; - src_type = INT_UINT; - } else if (H5Tequal(src, H5T_NATIVE_LONG)) { - src_type_name = "long"; - src_type = INT_LONG; - } else if (H5Tequal(src, H5T_NATIVE_ULONG)) { - src_type_name = "unsigned long"; - src_type = INT_ULONG; - } else if (H5Tequal(src, H5T_NATIVE_LLONG)) { - src_type_name = "long long"; - src_type = INT_LLONG; - } else if (H5Tequal(src, H5T_NATIVE_ULLONG)) { - src_type_name = "unsigned long long"; - src_type = INT_ULLONG; - } else { - src_type_name = "UNKNOWN"; - src_type = OTHER; + src_type_name = "signed char"; + src_type = INT_SCHAR; + } + else if (H5Tequal(src, H5T_NATIVE_UCHAR)) { + src_type_name = "unsigned char"; + src_type = INT_UCHAR; + } + else if (H5Tequal(src, H5T_NATIVE_SHORT)) { + src_type_name = "short"; + src_type = INT_SHORT; + } + else if (H5Tequal(src, H5T_NATIVE_USHORT)) { + src_type_name = "unsigned short"; + src_type = INT_USHORT; + } + else if (H5Tequal(src, H5T_NATIVE_INT)) { + src_type_name = "int"; + src_type = INT_INT; + } + else if (H5Tequal(src, H5T_NATIVE_UINT)) { + src_type_name = "unsigned int"; + src_type = INT_UINT; + } + else if (H5Tequal(src, H5T_NATIVE_LONG)) { + src_type_name = "long"; + src_type = INT_LONG; + } + else if (H5Tequal(src, H5T_NATIVE_ULONG)) { + src_type_name = "unsigned long"; + src_type = INT_ULONG; + } + else if (H5Tequal(src, H5T_NATIVE_LLONG)) { + src_type_name = "long long"; + src_type = INT_LLONG; + } + else if (H5Tequal(src, H5T_NATIVE_ULLONG)) { + src_type_name = "unsigned long long"; + src_type = INT_ULLONG; + } + else { + src_type_name = "UNKNOWN"; + src_type = OTHER; } if (H5Tequal(dst, H5T_NATIVE_SCHAR)) { - dst_type_name = "signed char"; - dst_type = INT_SCHAR; - } else if (H5Tequal(dst, H5T_NATIVE_UCHAR)) { - dst_type_name = "unsigned char"; - dst_type = INT_UCHAR; - } else if (H5Tequal(dst, H5T_NATIVE_SHORT)) { - dst_type_name = "short"; - dst_type = INT_SHORT; - } else if (H5Tequal(dst, H5T_NATIVE_USHORT)) { - dst_type_name = "unsigned short"; - dst_type = INT_USHORT; - } else if (H5Tequal(dst, H5T_NATIVE_INT)) { - dst_type_name = "int"; - dst_type = INT_INT; - } else if (H5Tequal(dst, H5T_NATIVE_UINT)) { - dst_type_name = "unsigned int"; - dst_type = INT_UINT; - } else if (H5Tequal(dst, H5T_NATIVE_LONG)) { - dst_type_name = "long"; - dst_type = INT_LONG; - } else if (H5Tequal(dst, H5T_NATIVE_ULONG)) { - dst_type_name = "unsigned long"; - dst_type = INT_ULONG; - } else if (H5Tequal(dst, H5T_NATIVE_LLONG)) { - dst_type_name = "long long"; - dst_type = INT_LLONG; - } else if (H5Tequal(dst, H5T_NATIVE_ULLONG)) { - dst_type_name = "unsigned long long"; - dst_type = INT_ULLONG; - } else { - dst_type_name = "UNKNOWN"; - dst_type = OTHER; + dst_type_name = "signed char"; + dst_type = INT_SCHAR; + } + else if (H5Tequal(dst, H5T_NATIVE_UCHAR)) { + dst_type_name = "unsigned char"; + dst_type = INT_UCHAR; + } + else if (H5Tequal(dst, H5T_NATIVE_SHORT)) { + dst_type_name = "short"; + dst_type = INT_SHORT; + } + else if (H5Tequal(dst, H5T_NATIVE_USHORT)) { + dst_type_name = "unsigned short"; + dst_type = INT_USHORT; + } + else if (H5Tequal(dst, H5T_NATIVE_INT)) { + dst_type_name = "int"; + dst_type = INT_INT; + } + else if (H5Tequal(dst, H5T_NATIVE_UINT)) { + dst_type_name = "unsigned int"; + dst_type = INT_UINT; + } + else if (H5Tequal(dst, H5T_NATIVE_LONG)) { + dst_type_name = "long"; + dst_type = INT_LONG; + } + else if (H5Tequal(dst, H5T_NATIVE_ULONG)) { + dst_type_name = "unsigned long"; + dst_type = INT_ULONG; + } + else if (H5Tequal(dst, H5T_NATIVE_LLONG)) { + dst_type_name = "long long"; + dst_type = INT_LLONG; + } + else if (H5Tequal(dst, H5T_NATIVE_ULLONG)) { + dst_type_name = "unsigned long long"; + dst_type = INT_ULLONG; + } + else { + dst_type_name = "UNKNOWN"; + dst_type = OTHER; } /* Sanity checks */ - if (OTHER==src_type || OTHER==dst_type) { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - HDprintf("%-70s", str); - H5_FAILED(); - HDputs(" Unknown data type."); - goto error; - } else { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); + if (OTHER == src_type || OTHER == dst_type) { + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" Unknown data type."); + goto error; + } + else { + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); HDprintf("%-70s", str); HDfflush(stdout); - fails_this_test=0; + fails_this_test = 0; } /* Some information about datatypes */ - endian = H5Tget_order(H5T_NATIVE_INT); - src_size = H5Tget_size(src); - dst_size = H5Tget_size(dst); + endian = H5Tget_order(H5T_NATIVE_INT); + src_size = H5Tget_size(src); + dst_size = H5Tget_size(dst); src_nbits = H5Tget_precision(src); /* not 8*src_size, esp on J90 - QAK */ dst_nbits = H5Tget_precision(dst); /* not 8*dst_size, esp on J90 - QAK */ - src_sign = H5Tget_sign(src); - dst_sign = H5Tget_sign(dst); - aligned = HDcalloc((size_t)1, sizeof(long long)); + src_sign = H5Tget_sign(src); + dst_sign = H5Tget_sign(dst); + aligned = HDcalloc((size_t)1, sizeof(long long)); /* Allocate and initialize the source buffer through macro INIT_INTEGER. The BUF * will be used for the conversion while the SAVED buffer will be * used for the comparison later. */ - if(src_type == INT_SCHAR) { + if (src_type == INT_SCHAR) { INIT_INTEGER(signed char, SCHAR_MAX, SCHAR_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_UCHAR) { + } + else if (src_type == INT_UCHAR) { INIT_INTEGER(unsigned char, UCHAR_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_SHORT) { + } + else if (src_type == INT_SHORT) { INIT_INTEGER(short, SHRT_MAX, SHRT_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_USHORT) { + } + else if (src_type == INT_USHORT) { INIT_INTEGER(unsigned short, USHRT_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_INT) { + } + else if (src_type == INT_INT) { INIT_INTEGER(int, INT_MAX, INT_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_UINT) { + } + else if (src_type == INT_UINT) { INIT_INTEGER(unsigned int, UINT_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_LONG) { + } + else if (src_type == INT_LONG) { INIT_INTEGER(long, LONG_MAX, LONG_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_ULONG) { + } + else if (src_type == INT_ULONG) { INIT_INTEGER(unsigned long, ULONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_LLONG) { + } + else if (src_type == INT_LLONG) { INIT_INTEGER(long long, LLONG_MAX, LLONG_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_ULLONG) { + } + else if (src_type == INT_ULLONG) { INIT_INTEGER(unsigned long long, ULLONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else + } + else goto error; /* Perform the conversion */ @@ -1820,49 +1867,700 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) goto error; /* Check the results from the library against hardware */ - for (j=0; j dst_nbits) { + if (0 == H5T__bit_get_d(src_bits, src_nbits - 1, (size_t)1) && + H5T__bit_find(src_bits, dst_nbits - 1, (src_nbits - dst_nbits), H5T_BIT_MSB, 1) >= 0) { + /* + * Source is positive and the magnitude is too large for + * the destination. The destination should be set to the + * maximum possible value: 0x7f...f + */ + if (0 == H5T__bit_get_d(dst_bits, dst_nbits - 1, (size_t)1) && + H5T__bit_find(dst_bits, (size_t)0, dst_nbits - 1, H5T_BIT_LSB, 0) < 0) + continue; /*no error*/ + } + else if (1 == H5T__bit_get_d(src_bits, src_nbits - 1, (size_t)1) && + H5T__bit_find(src_bits, (size_t)0, src_nbits - 1, H5T_BIT_MSB, 0) + 1 >= + (ssize_t)dst_nbits) { + /* + * Source is negative but the magnitude is too large for + * the destination. The destination should be set to the + * smallest possible value: 0x80...0 + */ + if (1 == H5T__bit_get_d(dst_bits, dst_nbits - 1, (size_t)1) && + H5T__bit_find(dst_bits, (size_t)0, dst_nbits - 1, H5T_BIT_LSB, 1) < 0) + continue; /*no error*/ + } + } + else if (src_nbits < dst_nbits) { + /* Source is smaller than the destination */ + if (0 == H5T__bit_get_d(src_bits, src_nbits - 1, (size_t)1)) { + /* + * Source is positive, so the excess bits in the + * destination should be set to 0's. + */ + if (0 == H5T__bit_get_d(dst_bits, src_nbits - 1, (size_t)1) && + H5T__bit_find(dst_bits, src_nbits, dst_nbits - src_nbits, H5T_BIT_LSB, 1) < 0) + continue; /*no error*/ + } + else { + /* + * Source is negative, so the excess bits in the + * destination should be set to 1's. + */ + if (1 == H5T__bit_get_d(dst_bits, src_nbits - 1, (size_t)1) && + H5T__bit_find(dst_bits, src_nbits, dst_nbits - src_nbits, H5T_BIT_LSB, 0) < 0) + continue; /*no error*/ + } + } + } + else if (H5T_SGN_2 == src_sign && H5T_SGN_NONE == dst_sign) { + if (H5T__bit_get_d(src_bits, src_nbits - 1, (size_t)1)) { + /* + * The source is negative so the result should be zero. + * The source is negative if the most significant bit is + * set. The destination is zero if all bits are zero. + */ + if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 1) < 0) + continue; /*no error*/ + } + else if (src_nbits > dst_nbits && + H5T__bit_find(src_bits, dst_nbits - 1, src_nbits - dst_nbits, H5T_BIT_LSB, 1) >= 0) { + /* + * The source is a value with a magnitude too large for + * the destination. The destination should be the + * largest possible value: 0xff...f + */ + if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) + continue; /*no error*/ + } + } + else if (H5T_SGN_NONE == src_sign && H5T_SGN_2 == dst_sign) { + if (src_nbits >= dst_nbits && + H5T__bit_find(src_bits, dst_nbits - 1, (src_nbits - dst_nbits) + 1, H5T_BIT_LSB, 1) >= 0) { + /* + * The source value has a magnitude that is larger than + * the destination can handle. The destination should be + * set to the largest possible positive value: 0x7f...f + */ + if (0 == H5T__bit_get_d(dst_bits, dst_nbits - 1, (size_t)1) && + H5T__bit_find(dst_bits, (size_t)0, dst_nbits - 1, H5T_BIT_LSB, 0) < 0) + continue; /*no error*/ + } + } + else { + if (src_nbits > dst_nbits && + H5T__bit_find(src_bits, dst_nbits, src_nbits - dst_nbits, H5T_BIT_LSB, 1) >= 0) { + /* + * The unsigned source has a value which is too large for + * the unsigned destination. The destination should be + * set to the largest possible value: 0xff...f + */ + if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) + continue; /*no error*/ + } + } + + /* Print errors */ + if (0 == fails_this_test++) + H5_FAILED(); + HDprintf(" elmt %u\n", (unsigned)j); + + HDprintf(" src = "); + for (k = 0; k < src_size; k++) + HDprintf(" %02x", saved[j * src_size + ENDIAN(src_size, k, endian)]); + HDprintf("%*s", (int)(3 * MAX(0, (ssize_t)dst_size - (ssize_t)src_size)), ""); + switch (src_type) { case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char)); - hw_char = (signed char)(*((signed char*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(signed char), sizeof(signed char)); + HDprintf(" %29d\n", (int)*((signed char *)aligned)); break; case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_char = (signed char)(*((unsigned char*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(unsigned char), sizeof(unsigned char)); + HDprintf(" %29u\n", (unsigned)*((unsigned char *)aligned)); break; case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_char = (signed char)(*((short*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(short), sizeof(short)); + HDprintf(" %29hd\n", *((short *)aligned)); break; case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_char = (signed char)(*((unsigned short*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(unsigned short), sizeof(unsigned short)); + HDprintf(" %29hu\n", *((unsigned short *)aligned)); break; case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_char = (signed char)(*((int*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(int), sizeof(int)); + HDprintf(" %29d\n", *((int *)aligned)); break; case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_char = (signed char)(*((unsigned*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(unsigned), sizeof(unsigned)); + HDprintf(" %29u\n", *((unsigned *)aligned)); break; case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_char = (signed char)(*((long*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(long), sizeof(long)); + HDprintf(" %29ld\n", *((long *)aligned)); break; case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_char = (signed char)(*((unsigned long*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(unsigned long), sizeof(unsigned long)); + HDprintf(" %29lu\n", *((unsigned long *)aligned)); break; case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_char = (signed char)(*((long long*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(long long), sizeof(long long)); + HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)aligned)); break; case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_char = (signed char)(*((unsigned long long*)aligned)); + HDmemcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); + HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "u\n", *((unsigned long long *)aligned)); break; case FLT_FLOAT: case FLT_DOUBLE: @@ -1871,49 +2569,52 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) default: HDassert(0 && "Unknown type"); break; - } - } else if (INT_UCHAR==dst_type) { - hw = (unsigned char*)&hw_uchar; - switch (src_type) { + } + + HDprintf(" dst = "); + for (k = 0; k < dst_size; k++) + HDprintf(" %02x", buf[j * dst_size + ENDIAN(dst_size, k, endian)]); + HDprintf("%*s", (int)(3 * MAX(0, (ssize_t)src_size - (ssize_t)dst_size)), ""); + switch (dst_type) { case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char)); - hw_uchar = (unsigned char)(*((signed char*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(signed char), sizeof(signed char)); + HDprintf(" %29d\n", (int)*((signed char *)aligned)); break; case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_uchar = (unsigned char)(*((unsigned char*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(unsigned char), sizeof(unsigned char)); + HDprintf(" %29u\n", (unsigned)*((unsigned char *)aligned)); break; case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_uchar = (unsigned char)(*((short*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(short), sizeof(short)); + HDprintf(" %29hd\n", *((short *)aligned)); break; case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_uchar = (unsigned char)(*((unsigned short*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(unsigned short), sizeof(unsigned short)); + HDprintf(" %29hu\n", *((unsigned short *)aligned)); break; case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_uchar = (unsigned char)(*((int*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(int), sizeof(int)); + HDprintf(" %29d\n", *((int *)aligned)); break; case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_uchar = (unsigned char)(*((unsigned*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(unsigned), sizeof(unsigned)); + HDprintf(" %29u\n", *((unsigned *)aligned)); break; case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_uchar = (unsigned char)(*((long*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(long), sizeof(long)); + HDprintf(" %29ld\n", *((long *)aligned)); break; case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_uchar = (unsigned char)(*((unsigned long*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(unsigned long), sizeof(unsigned long)); + HDprintf(" %29lu\n", *((unsigned long *)aligned)); break; case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_uchar = (unsigned char)(*((long long*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(long long), sizeof(long long)); + HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)aligned)); break; case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_uchar = (unsigned char)(*((unsigned long long*)aligned)); + HDmemcpy(aligned, buf + j * sizeof(long long), sizeof(unsigned long long)); + HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "u\n", *((unsigned long long *)aligned)); break; case FLT_FLOAT: case FLT_DOUBLE: @@ -1922,684 +2623,42 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) default: HDassert(0 && "Unknown type"); break; - } - } else if (INT_SHORT==dst_type) { - hw = (unsigned char*)&hw_short; - switch (src_type) { + } + + HDprintf(" ans = "); + for (k = 0; k < dst_size; k++) + HDprintf(" %02x", hw[ENDIAN(dst_size, k, endian)]); + HDprintf("%*s", (int)(3 * MAX(0, (ssize_t)src_size - (ssize_t)dst_size)), ""); + switch (dst_type) { case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(char), sizeof(char)); - hw_short = (short)(*((char*)aligned)); + HDprintf(" %29d\n", (int)*((signed char *)((void *)hw))); break; case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_short = (short)(*((unsigned char*)aligned)); + HDprintf(" %29u\n", (unsigned)*((unsigned char *)((void *)hw))); break; case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_short = (short)(*((short*)aligned)); + HDprintf(" %29hd\n", *((short *)((void *)hw))); break; case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_short = (short)(*((unsigned short*)aligned)); + HDprintf(" %29hu\n", *((unsigned short *)((void *)hw))); break; case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_short = (short)(*((int*)aligned)); + HDprintf(" %29d\n", *((int *)((void *)hw))); break; case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_short = (short)(*((unsigned*)aligned)); + HDprintf(" %29u\n", *((unsigned *)((void *)hw))); break; case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_short = (short)(*((long*)aligned)); + HDprintf(" %29ld\n", *((long *)((void *)hw))); break; case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_short = (short)(*((unsigned long*)aligned)); + HDprintf(" %29lu\n", *((unsigned long *)((void *)hw))); break; case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_short = (short)(*((long long*)aligned)); + HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)((void *)hw))); break; case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_short = (short)(*((unsigned long long*)aligned)); - break; - - case FLT_FLOAT: - case FLT_DOUBLE: - case FLT_LDOUBLE: - case OTHER: - default: - HDassert(0 && "Unknown type"); - break; - } - } else if (INT_USHORT==dst_type) { - hw = (unsigned char*)&hw_ushort; - switch (src_type) { - case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char)); - hw_ushort = (unsigned short)(*((signed char*)aligned)); - break; - case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_ushort = (unsigned short)(*((unsigned char*)aligned)); - break; - case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_ushort = (unsigned short)(*((short*)aligned)); - break; - case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_ushort = (unsigned short)(*((unsigned short*)aligned)); - break; - case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_ushort = (unsigned short)(*((int*)aligned)); - break; - case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_ushort = (unsigned short)(*((unsigned*)aligned)); - break; - case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_ushort = (unsigned short)(*((long*)aligned)); - break; - case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_ushort = (unsigned short)(*((unsigned long*)aligned)); - break; - case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_ushort = (unsigned short)(*((long long*)aligned)); - break; - case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_ushort = (unsigned short)(*((unsigned long long*)aligned)); - break; - case FLT_FLOAT: - case FLT_DOUBLE: - case FLT_LDOUBLE: - case OTHER: - default: - HDassert(0 && "Unknown type"); - break; - } - } else if (INT_INT==dst_type) { - hw = (unsigned char*)&hw_int; - switch (src_type) { - case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char)); - hw_int = (int)(*((signed char*)aligned)); - break; - case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_int = (int)(*((unsigned char*)aligned)); - break; - case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_int = (int)(*((short*)aligned)); - break; - case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_int = (int)(*((unsigned short*)aligned)); - break; - case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_int = (int)(*((int*)aligned)); - break; - case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_int = (int)(*((unsigned*)aligned)); - break; - case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_int = (int)(*((long*)aligned)); - break; - case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_int = (int)(*((unsigned long*)aligned)); - break; - case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_int = (int)(*((long long*)aligned)); - break; - case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_int = (int)(*((unsigned long long*)aligned)); - break; - case FLT_FLOAT: - case FLT_DOUBLE: - case FLT_LDOUBLE: - case OTHER: - default: - HDassert(0 && "Unknown type"); - break; - } - } else if (INT_UINT==dst_type) { - hw = (unsigned char*)&hw_uint; - switch (src_type) { - case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char)); - hw_uint = (unsigned int)(*((signed char*)aligned)); - break; - case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_uint = (unsigned int)(*((unsigned char*)aligned)); - break; - case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_uint = (unsigned int)(*((short*)aligned)); - break; - case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_uint = (unsigned int)(*((unsigned short*)aligned)); - break; - case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_uint = (unsigned int)(*((int*)aligned)); - break; - case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_uint = (unsigned int)(*((unsigned*)aligned)); - break; - case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_uint = (unsigned int)(*((long*)aligned)); - break; - case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_uint = (unsigned int)(*((unsigned long*)aligned)); - break; - case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_uint = (unsigned int)(*((long long*)aligned)); - break; - case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_uint = (unsigned int)(*((unsigned long long*)aligned)); - break; - case FLT_FLOAT: - case FLT_DOUBLE: - case FLT_LDOUBLE: - case OTHER: - default: - HDassert(0 && "Unknown type"); - break; - } - } else if (INT_LONG==dst_type) { - hw = (unsigned char*)&hw_long; - switch (src_type) { - case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char)); - hw_long = (long int)(*((signed char*)aligned)); - break; - case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_long = (long int)(*((unsigned char*)aligned)); - break; - case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_long = (long int)(*((short*)aligned)); - break; - case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_long = (long int)(*((unsigned short*)aligned)); - break; - case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_long = (long int)(*((int*)aligned)); - break; - case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_long = (long int)(*((unsigned*)aligned)); - break; - case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_long = (long int)(*((long*)aligned)); - break; - case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_long = (long int)(*((unsigned long*)aligned)); - break; - case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_long = (long int)(*((long long*)aligned)); - break; - case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_long = (long int)(*((unsigned long long*)aligned)); - break; - case FLT_FLOAT: - case FLT_DOUBLE: - case FLT_LDOUBLE: - case OTHER: - default: - HDassert(0 && "Unknown type"); - break; - } - } else if (INT_ULONG==dst_type) { - hw = (unsigned char*)&hw_ulong; - switch (src_type) { - case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char)); - hw_ulong = (unsigned long)(*((signed char*)aligned)); - break; - case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_ulong = (unsigned long)(*((unsigned char*)aligned)); - break; - case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_ulong = (unsigned long)(*((short*)aligned)); - break; - case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_ulong = (unsigned long)(*((unsigned short*)aligned)); - break; - case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_ulong = (unsigned long)(*((int*)aligned)); - break; - case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_ulong = (unsigned long)(*((unsigned*)aligned)); - break; - case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_ulong = (unsigned long)(*((long*)aligned)); - break; - case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_ulong = (unsigned long)(*((unsigned long*)aligned)); - break; - case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_ulong = (unsigned long)(*((long long*)aligned)); - break; - case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_ulong = (unsigned long)(*((unsigned long long*)aligned)); - break; - case FLT_FLOAT: - case FLT_DOUBLE: - case FLT_LDOUBLE: - case OTHER: - default: - HDassert(0 && "Unknown type"); - break; - } - } else if (INT_LLONG==dst_type) { - hw = (unsigned char*)&hw_llong; - switch (src_type) { - case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(char), sizeof(char)); - hw_llong = (long long)(*((char*)aligned)); - break; - case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_llong = (long long)(*((unsigned char*)aligned)); - break; - case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_llong = (long long)(*((short*)aligned)); - break; - case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_llong = (long long)(*((unsigned short*)aligned)); - break; - case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_llong = (long long)(*((int*)aligned)); - break; - case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_llong = (long long)(*((unsigned*)aligned)); - break; - case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_llong = (long long)(*((long*)aligned)); - break; - case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_llong = (long long)(*((unsigned long*)aligned)); - break; - case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_llong = (long long)(*((long long*)aligned)); - break; - case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_llong = (long long)(*((unsigned long long*)aligned)); - break; - case FLT_FLOAT: - case FLT_DOUBLE: - case FLT_LDOUBLE: - case OTHER: - default: - HDassert(0 && "Unknown type"); - break; - } - } else if (INT_ULLONG==dst_type) { - hw = (unsigned char*)&hw_ullong; - switch (src_type) { - case INT_SCHAR: - HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char)); - hw_ullong = (unsigned long long)(*((signed char*)aligned)); - break; - case INT_UCHAR: - HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char)); - hw_ullong = (unsigned long long)(*((unsigned char*)aligned)); - break; - case INT_SHORT: - HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short)); - hw_ullong = (unsigned long long)(*((short*)aligned)); - break; - case INT_USHORT: - HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short)); - hw_ullong = (unsigned long long)(*((unsigned short*)aligned)); - break; - case INT_INT: - HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int)); - hw_ullong = (unsigned long long)(*((int*)aligned)); - break; - case INT_UINT: - HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned)); - hw_ullong = (unsigned long long)(*((unsigned*)aligned)); - break; - case INT_LONG: - HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long)); - hw_ullong = (unsigned long long)(*((long*)aligned)); - break; - case INT_ULONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long)); - hw_ullong = (unsigned long long)(*((unsigned long*)aligned)); - break; - case INT_LLONG: - HDmemcpy(aligned, saved+j*sizeof(long long), sizeof(long long)); - hw_ullong = (unsigned long long)(*((long long*)aligned)); - break; - case INT_ULLONG: - HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); - hw_ullong = (unsigned long long)(*((unsigned long long*)aligned)); - break; - case FLT_FLOAT: - case FLT_DOUBLE: - case FLT_LDOUBLE: - case OTHER: - default: - HDassert(0 && "Unknown type"); - break; - } - } - - /* Make certain that there isn't some weird number of destination bits */ - assert(dst_nbits%8==0); - - /* Are the two results the same? */ - for (k=(dst_size-(dst_nbits/8)); kdst_nbits) { - if(0==H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1) && - H5T__bit_find(src_bits, dst_nbits-1, (src_nbits-dst_nbits), - H5T_BIT_MSB, 1)>=0) { - /* - * Source is positive and the magnitude is too large for - * the destination. The destination should be set to the - * maximum possible value: 0x7f...f - */ - if (0==H5T__bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && - H5T__bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) - continue; /*no error*/ - } else if (1==H5T__bit_get_d(src_bits, src_nbits-1, (size_t)1) && - H5T__bit_find(src_bits, (size_t)0, src_nbits-1, H5T_BIT_MSB, - 0)+1>=(ssize_t)dst_nbits) { - /* - * Source is negative but the magnitude is too large for - * the destination. The destination should be set to the - * smallest possible value: 0x80...0 - */ - if (1==H5T__bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && - H5T__bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 1) < 0) - continue; /*no error*/ - } - } else if(src_nbitsdst_nbits && - H5T__bit_find(src_bits, dst_nbits-1, - src_nbits-dst_nbits, H5T_BIT_LSB, 1)>=0) { - /* - * The source is a value with a magnitude too large for - * the destination. The destination should be the - * largest possible value: 0xff...f - */ - if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) - continue; /*no error*/ - } - } else if (H5T_SGN_NONE==src_sign && H5T_SGN_2==dst_sign) { - if (src_nbits>=dst_nbits && - H5T__bit_find(src_bits, dst_nbits-1, (src_nbits-dst_nbits)+1, - H5T_BIT_LSB, 1)>=0) { - /* - * The source value has a magnitude that is larger than - * the destination can handle. The destination should be - * set to the largest possible positive value: 0x7f...f - */ - if (0==H5T__bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && - H5T__bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) - continue; /*no error*/ - } - } else { - if (src_nbits>dst_nbits && - H5T__bit_find(src_bits, dst_nbits, src_nbits-dst_nbits, - H5T_BIT_LSB, 1)>=0) { - /* - * The unsigned source has a value which is too large for - * the unsigned destination. The destination should be - * set to the largest possible value: 0xff...f - */ - if (H5T__bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) - continue; /*no error*/ - } - } - - /* Print errors */ - if (0==fails_this_test++) - H5_FAILED(); - HDprintf(" elmt %u\n", (unsigned)j); - - HDprintf(" src = "); - for (k=0; k=max_fails) { + if (++fails_all_tests >= max_fails) { HDputs(" maximum failures reached, aborting test..."); HDputs(" (dst is library's conversion output. ans is compiler's conversion output.)"); goto done; @@ -2619,33 +2678,38 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) PASSED(); done: - if (buf) aligned_free(buf); - if (saved) aligned_free(saved); - if (aligned) HDfree(aligned); + if (buf) + aligned_free(buf); + if (saved) + aligned_free(saved); + if (aligned) + HDfree(aligned); HDfflush(stdout); /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - reset_hdf5(); /*print statistics*/ + reset_hdf5(); /*print statistics*/ return (int)fails_all_tests; error: - if (buf) aligned_free(buf); - if (saved) aligned_free(saved); - if (aligned) HDfree(aligned); + if (buf) + aligned_free(buf); + if (saved) + aligned_free(saved); + if (aligned) + HDfree(aligned); HDfflush(stdout); /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - reset_hdf5(); /*print statistics*/ + reset_hdf5(); /*print statistics*/ return MAX((int)fails_all_tests, 1); } - /*------------------------------------------------------------------------- * Function: test_conv_int_2 * @@ -2666,9 +2730,9 @@ error: static int test_conv_int_2(void) { - int i, j; - hid_t src_type, dst_type; - char *buf; + int i, j; + hid_t src_type, dst_type; + char *buf; HDprintf("%-70s", "Testing overlap calculations"); HDfflush(stdout); @@ -2676,32 +2740,31 @@ test_conv_int_2(void) buf = (char *)HDcalloc(TMP_BUF_DIM1, TMP_BUF_DIM2); HDassert(buf); - for(i = 1; i <= TMP_BUF_DIM1; i++) { - for(j = 1; j <= TMP_BUF_DIM1; j++) { + for (i = 1; i <= TMP_BUF_DIM1; i++) { + for (j = 1; j <= TMP_BUF_DIM1; j++) { - /* Source type */ - src_type = H5Tcopy(H5T_NATIVE_CHAR); - H5Tset_size(src_type, (size_t)i); + /* Source type */ + src_type = H5Tcopy(H5T_NATIVE_CHAR); + H5Tset_size(src_type, (size_t)i); - /* Destination type */ - dst_type = H5Tcopy(H5T_NATIVE_CHAR); - H5Tset_size(dst_type, (size_t)j); + /* Destination type */ + dst_type = H5Tcopy(H5T_NATIVE_CHAR); + H5Tset_size(dst_type, (size_t)j); - /* - * Conversion. If overlap calculations aren't right then an - * assertion will fail in H5T__conv_i_i() - */ - H5Tconvert(src_type, dst_type, (size_t)TMP_BUF_DIM2, buf, NULL, H5P_DEFAULT); - H5Tclose(src_type); - H5Tclose(dst_type); - } + /* + * Conversion. If overlap calculations aren't right then an + * assertion will fail in H5T__conv_i_i() + */ + H5Tconvert(src_type, dst_type, (size_t)TMP_BUF_DIM2, buf, NULL, H5P_DEFAULT); + H5Tclose(src_type); + H5Tclose(dst_type); + } } PASSED(); HDfree(buf); return 0; } - /*------------------------------------------------------------------------- * Function: my_isnan * @@ -2719,25 +2782,28 @@ test_conv_int_2(void) static int my_isnan(dtype_t type, void *val) { - int retval = 0; + int retval = 0; char s[256]; - if (FLT_FLOAT==type) { - float x = 0.; - HDmemcpy(&x, val, sizeof(float)); - retval = (x!=x); - } else if (FLT_DOUBLE==type) { - double x = 0.; - HDmemcpy(&x, val, sizeof(double)); - retval = (x!=x); -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if (FLT_LDOUBLE==type) { - long double x = 0.; - HDmemcpy(&x, val, sizeof(long double)); - retval = (x!=x); + if (FLT_FLOAT == type) { + float x = 0.; + HDmemcpy(&x, val, sizeof(float)); + retval = (x != x); + } + else if (FLT_DOUBLE == type) { + double x = 0.; + HDmemcpy(&x, val, sizeof(double)); + retval = (x != x); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (FLT_LDOUBLE == type) { + long double x = 0.; + HDmemcpy(&x, val, sizeof(long double)); + retval = (x != x); #endif - } else { - return 0; + } + else { + return 0; } /* @@ -2745,34 +2811,36 @@ my_isnan(dtype_t type, void *val) * the result contains a NaN string. */ if (!retval) { - if (FLT_FLOAT==type) { - float x = 0.; + if (FLT_FLOAT == type) { + float x = 0.; - HDmemcpy(&x, val, sizeof(float)); - HDsnprintf(s, sizeof(s), "%g", (double)x); - } else if (FLT_DOUBLE==type) { - double x = 0.; + HDmemcpy(&x, val, sizeof(float)); + HDsnprintf(s, sizeof(s), "%g", (double)x); + } + else if (FLT_DOUBLE == type) { + double x = 0.; - HDmemcpy(&x, val, sizeof(double)); - HDsnprintf(s, sizeof(s), "%g", x); -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if (FLT_LDOUBLE==type) { - long double x = 0.; + HDmemcpy(&x, val, sizeof(double)); + HDsnprintf(s, sizeof(s), "%g", x); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (FLT_LDOUBLE == type) { + long double x = 0.; - HDmemcpy(&x, val, sizeof(long double)); - HDsnprintf(s, sizeof(s), "%Lg", x); + HDmemcpy(&x, val, sizeof(long double)); + HDsnprintf(s, sizeof(s), "%Lg", x); #endif - } else { - return 0; - } - if (HDstrstr(s, "NaN") || HDstrstr(s, "NAN") || HDstrstr(s, "nan")) - retval = 1; + } + else { + return 0; + } + if (HDstrstr(s, "NaN") || HDstrstr(s, "NAN") || HDstrstr(s, "nan")) + retval = 1; } return retval; } - /*------------------------------------------------------------------------- * Function: my_isinf * @@ -2788,20 +2856,19 @@ my_isnan(dtype_t type, void *val) *------------------------------------------------------------------------- */ static int -my_isinf(int endian, unsigned char *val, size_t size, - size_t mpos, size_t msize, size_t epos, size_t esize) +my_isinf(int endian, unsigned char *val, size_t size, size_t mpos, size_t msize, size_t epos, size_t esize) { unsigned char *bits; - int retval = 0; - size_t i; + int retval = 0; + size_t i; - bits = (unsigned char*)HDcalloc((size_t)1, size); + bits = (unsigned char *)HDcalloc((size_t)1, size); - for (i=0; i0) { - while (child_pid!=waitpid(child_pid, &status, 0)) /*void*/; - if (WIFEXITED(status) && 255==WEXITSTATUS(status)) { - return 0; /*child exit after catching SIGFPE*/ - } else if (WIFEXITED(status)) { - return WEXITSTATUS(status); - } else if (WIFSIGNALED(status)) { - HDsnprintf(str, sizeof(str), " Child caught signal %d.", WTERMSIG(status)); - HDputs(str); - return 1; /*child exit after catching non-SIGFPE signal */ - } else { - HDputs(" Child didn't exit normally."); + if ((child_pid = fork()) < 0) { + HDperror("fork"); return 1; } + else if (child_pid > 0) { + while (child_pid != waitpid(child_pid, &status, 0)) /*void*/ + ; + if (WIFEXITED(status) && 255 == WEXITSTATUS(status)) { + return 0; /*child exit after catching SIGFPE*/ + } + else if (WIFEXITED(status)) { + return WEXITSTATUS(status); + } + else if (WIFSIGNALED(status)) { + HDsnprintf(str, sizeof(str), " Child caught signal %d.", WTERMSIG(status)); + HDputs(str); + return 1; /*child exit after catching non-SIGFPE signal */ + } + else { + HDputs(" Child didn't exit normally."); + return 1; + } } #endif @@ -2906,75 +2977,82 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) * The remainder of this function is executed only by the child if * HANDLE_SIGFPE is defined. */ - HDsignal(SIGFPE,fpe_handler); + HDsignal(SIGFPE, fpe_handler); /* What are the names of the source and destination types */ if (H5Tequal(src, H5T_NATIVE_FLOAT)) { - src_type_name = "float"; - src_type = FLT_FLOAT; - } else if (H5Tequal(src, H5T_NATIVE_DOUBLE)) { - src_type_name = "double"; - src_type = FLT_DOUBLE; -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if (H5Tequal(src, H5T_NATIVE_LDOUBLE)) { - src_type_name = "long double"; - src_type = FLT_LDOUBLE; + src_type_name = "float"; + src_type = FLT_FLOAT; + } + else if (H5Tequal(src, H5T_NATIVE_DOUBLE)) { + src_type_name = "double"; + src_type = FLT_DOUBLE; +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (H5Tequal(src, H5T_NATIVE_LDOUBLE)) { + src_type_name = "long double"; + src_type = FLT_LDOUBLE; #endif - } else { - src_type_name = "UNKNOWN"; - src_type = OTHER; + } + else { + src_type_name = "UNKNOWN"; + src_type = OTHER; } if (H5Tequal(dst, H5T_NATIVE_FLOAT)) { - dst_type_name = "float"; - dst_type = FLT_FLOAT; - } else if (H5Tequal(dst, H5T_NATIVE_DOUBLE)) { - dst_type_name = "double"; - dst_type = FLT_DOUBLE; -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if (H5Tequal(dst, H5T_NATIVE_LDOUBLE)) { - dst_type_name = "long double"; - dst_type = FLT_LDOUBLE; + dst_type_name = "float"; + dst_type = FLT_FLOAT; + } + else if (H5Tequal(dst, H5T_NATIVE_DOUBLE)) { + dst_type_name = "double"; + dst_type = FLT_DOUBLE; +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (H5Tequal(dst, H5T_NATIVE_LDOUBLE)) { + dst_type_name = "long double"; + dst_type = FLT_LDOUBLE; #endif - } else { - dst_type_name = "UNKNOWN"; - dst_type = OTHER; + } + else { + dst_type_name = "UNKNOWN"; + dst_type = OTHER; } /* Sanity checks */ - if(sizeof(float)==sizeof(double)) + if (sizeof(float) == sizeof(double)) HDputs("Sizeof(float)==sizeof(double) - some tests may not be sensible."); - if (OTHER==src_type || OTHER==dst_type) { - if(!strcmp(name, "noop")) - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - else if(run_test==TEST_SPECIAL) - HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", - name, src_type_name, dst_type_name); - else if(run_test==TEST_NORMAL) - HDsnprintf(str, sizeof(str), "Testing %s normalized %s -> %s conversions", - name, src_type_name, dst_type_name); - else if(run_test==TEST_DENORM) - HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", - name, src_type_name, dst_type_name); - - HDprintf("%-70s", str); - H5_FAILED(); - HDputs(" Unknown data type."); - goto error; - } else { - if(!strcmp(name, "noop")) - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - else if(run_test==TEST_SPECIAL) - HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", - name, src_type_name, dst_type_name); - else if(run_test==TEST_NORMAL) - HDsnprintf(str, sizeof(str), "Testing %s normalized %s -> %s conversions", - name, src_type_name, dst_type_name); - else if(run_test==TEST_DENORM) - HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", - name, src_type_name, dst_type_name); + if (OTHER == src_type || OTHER == dst_type) { + if (!strcmp(name, "noop")) + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, + dst_type_name); + else if (run_test == TEST_SPECIAL) + HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", name, src_type_name, + dst_type_name); + else if (run_test == TEST_NORMAL) + HDsnprintf(str, sizeof(str), "Testing %s normalized %s -> %s conversions", name, src_type_name, + dst_type_name); + else if (run_test == TEST_DENORM) + HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", name, src_type_name, + dst_type_name); + + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" Unknown data type."); + goto error; + } + else { + if (!strcmp(name, "noop")) + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, + dst_type_name); + else if (run_test == TEST_SPECIAL) + HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", name, src_type_name, + dst_type_name); + else if (run_test == TEST_NORMAL) + HDsnprintf(str, sizeof(str), "Testing %s normalized %s -> %s conversions", name, src_type_name, + dst_type_name); + else if (run_test == TEST_DENORM) + HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", name, src_type_name, + dst_type_name); HDprintf("%-70s", str); HDfflush(stdout); @@ -2982,13 +3060,13 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) } /* Get "interesting" values */ - src_size = H5Tget_size(src); - dst_size = H5Tget_size(dst); + src_size = H5Tget_size(src); + dst_size = H5Tget_size(dst); src_nbits = H5Tget_precision(src); /* not 8*src_size, esp on J90 - QAK */ dst_nbits = H5Tget_precision(dst); /* not 8*dst_size, esp on J90 - QAK */ - dst_ebias=H5Tget_ebias(dst); - H5Tget_fields(src,NULL,&src_epos,&src_esize,NULL,NULL); - H5Tget_fields(dst,NULL,&dst_epos,&dst_esize,&dst_mpos,&dst_msize); + dst_ebias = H5Tget_ebias(dst); + H5Tget_fields(src, NULL, &src_epos, &src_esize, NULL, NULL); + H5Tget_fields(dst, NULL, &dst_epos, &dst_esize, &dst_mpos, &dst_msize); sendian = H5Tget_order(src); dendian = H5Tget_order(dst); @@ -3004,51 +3082,57 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) switch (run_test) { case TEST_NOOP: case TEST_NORMAL: - if(src_type == FLT_FLOAT) { - INIT_FP_NORM(float, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, - src_size, dst_size, buf, saved, nelmts); - } else if(src_type == FLT_DOUBLE) { - INIT_FP_NORM(double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, - src_size, dst_size, buf, saved, nelmts); -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if(src_type == FLT_LDOUBLE) { - INIT_FP_NORM(long double, LDBL_MAX, LDBL_MIN, LDBL_MAX_10_EXP, LDBL_MIN_10_EXP, - src_size, dst_size, buf, saved, nelmts); + if (src_type == FLT_FLOAT) { + INIT_FP_NORM(float, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, src_size, dst_size, buf, + saved, nelmts); + } + else if (src_type == FLT_DOUBLE) { + INIT_FP_NORM(double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, src_size, dst_size, + buf, saved, nelmts); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (src_type == FLT_LDOUBLE) { + INIT_FP_NORM(long double, LDBL_MAX, LDBL_MIN, LDBL_MAX_10_EXP, LDBL_MIN_10_EXP, src_size, + dst_size, buf, saved, nelmts); #endif - } else + } + else goto error; break; case TEST_DENORM: - if(src_type == FLT_FLOAT) { - INIT_FP_DENORM(float, FLT_MANT_DIG, src_size, src_nbits, sendian, dst_size, - buf, saved, nelmts); - } else if(src_type == FLT_DOUBLE) { - INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, - buf, saved, nelmts); -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if(src_type == FLT_LDOUBLE) { - INIT_FP_DENORM(long double, LDBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, - buf, saved, nelmts); + if (src_type == FLT_FLOAT) { + INIT_FP_DENORM(float, FLT_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, + nelmts); + } + else if (src_type == FLT_DOUBLE) { + INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, + nelmts); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (src_type == FLT_LDOUBLE) { + INIT_FP_DENORM(long double, LDBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, + nelmts); #endif - } else + } + else goto error; break; case TEST_SPECIAL: - if(src_type == FLT_FLOAT) { - INIT_FP_SPECIAL(src_size, src_nbits, sendian, FLT_MANT_DIG, dst_size, - buf, saved, nelmts); - } else if(src_type == FLT_DOUBLE) { - INIT_FP_SPECIAL(src_size, src_nbits, sendian, DBL_MANT_DIG, dst_size, - buf, saved, nelmts); -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if(src_type == FLT_LDOUBLE) { - INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, - buf, saved, nelmts); + if (src_type == FLT_FLOAT) { + INIT_FP_SPECIAL(src_size, src_nbits, sendian, FLT_MANT_DIG, dst_size, buf, saved, nelmts); + } + else if (src_type == FLT_DOUBLE) { + INIT_FP_SPECIAL(src_size, src_nbits, sendian, DBL_MANT_DIG, dst_size, buf, saved, nelmts); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (src_type == FLT_LDOUBLE) { + INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts); #endif - } else + } + else goto error; break; @@ -3061,66 +3145,74 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) goto error; /* Check the software results against the hardware */ - for (j=0; j (double)FLT_MAX; - } else if (FLT_DOUBLE==dst_type) { - hw_d = *((double*)aligned); - hw = (unsigned char*)&hw_d; -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE - } else { - hw_ld = *((double*)aligned); - hw = (unsigned char*)&hw_ld; + } + else if (FLT_DOUBLE == src_type) { + HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); + if (FLT_FLOAT == dst_type) { + hw_f = (float)(*((double *)aligned)); + hw = (unsigned char *)&hw_f; + underflow = HDfabs(*((double *)aligned)) < (double)FLT_MIN; + overflow = HDfabs(*((double *)aligned)) > (double)FLT_MAX; + } + else if (FLT_DOUBLE == dst_type) { + hw_d = *((double *)aligned); + hw = (unsigned char *)&hw_d; +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE + } + else { + hw_ld = *((double *)aligned); + hw = (unsigned char *)&hw_ld; #endif } -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE - } else { - HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double)); - if (FLT_FLOAT==dst_type) { - hw_f = (float)*((long double*)aligned); - hw = (unsigned char*)&hw_f; - underflow = HDfabsl(*((long double*)aligned)) < FLT_MIN; - overflow = HDfabsl(*((long double*)aligned)) > FLT_MAX; - } else if (FLT_DOUBLE==dst_type) { - hw_d = (double)*((long double*)aligned); - hw = (unsigned char*)&hw_d; - underflow = HDfabsl(*((long double*)aligned)) < DBL_MIN; - overflow = HDfabsl(*((long double*)aligned)) > DBL_MAX; - } else { - hw_ld = *((long double*)aligned); - hw = (unsigned char*)&hw_ld; +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE + } + else { + HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); + if (FLT_FLOAT == dst_type) { + hw_f = (float)*((long double *)aligned); + hw = (unsigned char *)&hw_f; + underflow = HDfabsl(*((long double *)aligned)) < FLT_MIN; + overflow = HDfabsl(*((long double *)aligned)) > FLT_MAX; + } + else if (FLT_DOUBLE == dst_type) { + hw_d = (double)*((long double *)aligned); + hw = (unsigned char *)&hw_d; + underflow = HDfabsl(*((long double *)aligned)) < DBL_MIN; + overflow = HDfabsl(*((long double *)aligned)) > DBL_MAX; + } + else { + hw_ld = *((long double *)aligned); + hw = (unsigned char *)&hw_ld; } #endif } - if (underflow){ + if (underflow) { uflow++; } @@ -3130,43 +3222,40 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) * last few unused bytes may have garbage in them. Clean them out with * 0s before compare the values. */ -#if H5_SIZEOF_LONG_DOUBLE !=0 - if(sendian == H5T_ORDER_LE && dst_type == FLT_LDOUBLE) { +#if H5_SIZEOF_LONG_DOUBLE != 0 + if (sendian == H5T_ORDER_LE && dst_type == FLT_LDOUBLE) { size_t q; - for(q = dst_nbits / 8; q < dst_size; q++) { + for (q = dst_nbits / 8; q < dst_size; q++) { buf[j * dst_size + q] = 0x00; - hw[q] = 0x00; + hw[q] = 0x00; } } #endif /* Are the two results the same? */ - for (k=(dst_size-(dst_nbits/8)); k=max_fails) { - if(run_test==TEST_NORMAL) + if (++fails_all_tests >= max_fails) { + if (run_test == TEST_NORMAL) HDputs(" maximum failures reached, aborting test..."); - else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL) + else if (run_test == TEST_DENORM || run_test == TEST_SPECIAL) HDputs(" maximum warnings reached, aborting test..."); HDputs(" (dst is library's conversion output. ans is compiler's conversion output.)"); @@ -3326,18 +3421,21 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) } } - if(!fails_all_tests) + if (!fails_all_tests) PASSED(); done: - if (buf) aligned_free(buf); - if (saved) aligned_free(saved); - if (aligned) HDfree(aligned); + if (buf) + aligned_free(buf); + if (saved) + aligned_free(saved); + if (aligned) + HDfree(aligned); HDfflush(stdout); #ifdef HANDLE_SIGFPE - if(run_test==TEST_NOOP || run_test==TEST_NORMAL) + if (run_test == TEST_NOOP || run_test == TEST_NORMAL) HDexit(MIN((int)fails_all_tests, 254)); - else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL) + else if (run_test == TEST_DENORM || run_test == TEST_SPECIAL) HDexit(EXIT_SUCCESS); HDassert(0 && "Should not reach this point!"); return 1; @@ -3349,21 +3447,24 @@ done: /* If the source is normalized values, treat the failures as error; * if it is denormalized or special values, treat the failure as warning.*/ - if(run_test==TEST_NOOP || run_test==TEST_NORMAL) + if (run_test == TEST_NOOP || run_test == TEST_NORMAL) return (int)fails_all_tests; - else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL) + else if (run_test == TEST_DENORM || run_test == TEST_SPECIAL) return 0; #endif error: - if (buf) aligned_free(buf); - if (saved) aligned_free(saved); - if (aligned) HDfree(aligned); + if (buf) + aligned_free(buf); + if (saved) + aligned_free(saved); + if (aligned) + HDfree(aligned); HDfflush(stdout); #ifdef HANDLE_SIGFPE - if(run_test==TEST_NOOP || run_test==TEST_NORMAL) + if (run_test == TEST_NOOP || run_test == TEST_NORMAL) HDexit(MIN(MAX((int)fails_all_tests, 1), 254)); - else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL) + else if (run_test == TEST_DENORM || run_test == TEST_SPECIAL) HDexit(EXIT_FAILURE); HDassert(0 && "Should not reach this point!"); return 1; @@ -3373,14 +3474,13 @@ error: reset_hdf5(); - if(run_test==TEST_NOOP || run_test==TEST_NORMAL) + if (run_test == TEST_NOOP || run_test == TEST_NORMAL) return MAX((int)fails_all_tests, 1); - else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL) + else if (run_test == TEST_DENORM || run_test == TEST_SPECIAL) return 1; #endif } - /*------------------------------------------------------------------------- * Function: test_conv_int_fp * @@ -3407,216 +3507,236 @@ error: static int test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) { - hid_t dxpl_id; /*dataset transfer property list*/ - int fill_value=9; /*fill value for conversion exception*/ - H5T_conv_except_func_t op; /*returned callback function for conversion exception*/ - void *user_data; /*returned pointer to user data passed in to the callback*/ - hbool_t except_set = FALSE; /*whether user's exception handling is set*/ - size_t nelmts=0; /*num values per test */ - const size_t max_fails=40; /*max number of failures*/ - size_t fails_all_tests=0; /*number of failures */ - size_t fails_this_test; /*fails for this test */ - char str[256]; /*hello string */ - dtype_t src_type; /*data types */ - dtype_t dst_type; /*data types */ - const char *src_type_name=NULL; /*source type name */ - const char *dst_type_name=NULL; /*destination type name */ - int sendian; /*source endianess */ - int dendian; /*destination endianess */ - size_t src_size, dst_size; /*type sizes */ - unsigned char *buf=NULL; /*buffer for conversion */ - unsigned char *saved=NULL; /*original values */ - size_t j, k; /*counters */ - unsigned char *hw=NULL; /*hardware conv result */ - unsigned char src_bits[32]; /*src value in LE order */ - unsigned char dst_bits[32]; /*dest value in LE order*/ - size_t src_nbits; /*source length in bits */ - size_t dst_nbits; /*dst length in bits */ - void *aligned=NULL; /*aligned temp buffer */ - float hw_float=0; - double hw_double=0; - long double hw_ldouble=0; - signed char hw_schar=0; - unsigned char hw_uchar=0; - short hw_short=0; - unsigned short hw_ushort=0; - int hw_int=0; - unsigned hw_uint=0; - long hw_long=0; - unsigned long hw_ulong=0; - long long hw_llong=0; - unsigned long long hw_ullong=0; + hid_t dxpl_id; /*dataset transfer property list*/ + int fill_value = 9; /*fill value for conversion exception*/ + H5T_conv_except_func_t op; /*returned callback function for conversion exception*/ + void * user_data; /*returned pointer to user data passed in to the callback*/ + hbool_t except_set = FALSE; /*whether user's exception handling is set*/ + size_t nelmts = 0; /*num values per test */ + const size_t max_fails = 40; /*max number of failures*/ + size_t fails_all_tests = 0; /*number of failures */ + size_t fails_this_test; /*fails for this test */ + char str[256]; /*hello string */ + dtype_t src_type; /*data types */ + dtype_t dst_type; /*data types */ + const char * src_type_name = NULL; /*source type name */ + const char * dst_type_name = NULL; /*destination type name */ + int sendian; /*source endianess */ + int dendian; /*destination endianess */ + size_t src_size, dst_size; /*type sizes */ + unsigned char * buf = NULL; /*buffer for conversion */ + unsigned char * saved = NULL; /*original values */ + size_t j, k; /*counters */ + unsigned char * hw = NULL; /*hardware conv result */ + unsigned char src_bits[32]; /*src value in LE order */ + unsigned char dst_bits[32]; /*dest value in LE order*/ + size_t src_nbits; /*source length in bits */ + size_t dst_nbits; /*dst length in bits */ + void * aligned = NULL; /*aligned temp buffer */ + float hw_float = 0; + double hw_double = 0; + long double hw_ldouble = 0; + signed char hw_schar = 0; + unsigned char hw_uchar = 0; + short hw_short = 0; + unsigned short hw_ushort = 0; + int hw_int = 0; + unsigned hw_uint = 0; + long hw_long = 0; + unsigned long hw_ulong = 0; + long long hw_llong = 0; + unsigned long long hw_ullong = 0; /* What is the name of the source type */ if (H5Tequal(src, H5T_NATIVE_SCHAR)) { - src_type_name = "signed char"; - src_type = INT_SCHAR; - } else if (H5Tequal(src, H5T_NATIVE_UCHAR)) { - src_type_name = "unsigned char"; - src_type = INT_UCHAR; - } else if (H5Tequal(src, H5T_NATIVE_SHORT)) { - src_type_name = "short"; - src_type = INT_SHORT; - } else if (H5Tequal(src, H5T_NATIVE_USHORT)) { - src_type_name = "unsigned short"; - src_type = INT_USHORT; - } else if (H5Tequal(src, H5T_NATIVE_INT)) { - src_type_name = "int"; - src_type = INT_INT; - } else if (H5Tequal(src, H5T_NATIVE_UINT)) { - src_type_name = "unsigned int"; - src_type = INT_UINT; - } else if (H5Tequal(src, H5T_NATIVE_LONG)) { - src_type_name = "long"; - src_type = INT_LONG; - } else if (H5Tequal(src, H5T_NATIVE_ULONG)) { - src_type_name = "unsigned long"; - src_type = INT_ULONG; - } else if (H5Tequal(src, H5T_NATIVE_LLONG)) { - src_type_name = "long long"; - src_type = INT_LLONG; - } else if (H5Tequal(src, H5T_NATIVE_ULLONG)) { - src_type_name = "unsigned long long"; - src_type = INT_ULLONG; - } else if (H5Tequal(src, H5T_NATIVE_FLOAT)) { - src_type_name = "float"; - src_type = FLT_FLOAT; - } else if (H5Tequal(src, H5T_NATIVE_DOUBLE)) { - src_type_name = "double"; - src_type = FLT_DOUBLE; -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if (H5Tequal(src, H5T_NATIVE_LDOUBLE)) { - src_type_name = "long double"; - src_type = FLT_LDOUBLE; + src_type_name = "signed char"; + src_type = INT_SCHAR; + } + else if (H5Tequal(src, H5T_NATIVE_UCHAR)) { + src_type_name = "unsigned char"; + src_type = INT_UCHAR; + } + else if (H5Tequal(src, H5T_NATIVE_SHORT)) { + src_type_name = "short"; + src_type = INT_SHORT; + } + else if (H5Tequal(src, H5T_NATIVE_USHORT)) { + src_type_name = "unsigned short"; + src_type = INT_USHORT; + } + else if (H5Tequal(src, H5T_NATIVE_INT)) { + src_type_name = "int"; + src_type = INT_INT; + } + else if (H5Tequal(src, H5T_NATIVE_UINT)) { + src_type_name = "unsigned int"; + src_type = INT_UINT; + } + else if (H5Tequal(src, H5T_NATIVE_LONG)) { + src_type_name = "long"; + src_type = INT_LONG; + } + else if (H5Tequal(src, H5T_NATIVE_ULONG)) { + src_type_name = "unsigned long"; + src_type = INT_ULONG; + } + else if (H5Tequal(src, H5T_NATIVE_LLONG)) { + src_type_name = "long long"; + src_type = INT_LLONG; + } + else if (H5Tequal(src, H5T_NATIVE_ULLONG)) { + src_type_name = "unsigned long long"; + src_type = INT_ULLONG; + } + else if (H5Tequal(src, H5T_NATIVE_FLOAT)) { + src_type_name = "float"; + src_type = FLT_FLOAT; + } + else if (H5Tequal(src, H5T_NATIVE_DOUBLE)) { + src_type_name = "double"; + src_type = FLT_DOUBLE; +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (H5Tequal(src, H5T_NATIVE_LDOUBLE)) { + src_type_name = "long double"; + src_type = FLT_LDOUBLE; #endif - } else { - src_type_name = "UNKNOWN"; - src_type = OTHER; + } + else { + src_type_name = "UNKNOWN"; + src_type = OTHER; } /* What is the name of the destination type */ if (H5Tequal(dst, H5T_NATIVE_SCHAR)) { - dst_type_name = "signed char"; - dst_type = INT_SCHAR; - } else if (H5Tequal(dst, H5T_NATIVE_UCHAR)) { - dst_type_name = "unsigned char"; - dst_type = INT_UCHAR; - } else if (H5Tequal(dst, H5T_NATIVE_SHORT)) { - dst_type_name = "short"; - dst_type = INT_SHORT; - } else if (H5Tequal(dst, H5T_NATIVE_USHORT)) { - dst_type_name = "unsigned short"; - dst_type = INT_USHORT; - } else if (H5Tequal(dst, H5T_NATIVE_INT)) { - dst_type_name = "int"; - dst_type = INT_INT; - } else if (H5Tequal(dst, H5T_NATIVE_UINT)) { - dst_type_name = "unsigned int"; - dst_type = INT_UINT; - } else if (H5Tequal(dst, H5T_NATIVE_LONG)) { - dst_type_name = "long"; - dst_type = INT_LONG; - } else if (H5Tequal(dst, H5T_NATIVE_ULONG)) { - dst_type_name = "unsigned long"; - dst_type = INT_ULONG; - } else if (H5Tequal(dst, H5T_NATIVE_LLONG)) { - dst_type_name = "long long"; - dst_type = INT_LLONG; - } else if (H5Tequal(dst, H5T_NATIVE_ULLONG)) { - dst_type_name = "unsigned long long"; - dst_type = INT_ULLONG; - } else if (H5Tequal(dst, H5T_NATIVE_FLOAT)) { - dst_type_name = "float"; - dst_type = FLT_FLOAT; - } else if (H5Tequal(dst, H5T_NATIVE_DOUBLE)) { - dst_type_name = "double"; - dst_type = FLT_DOUBLE; -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if (H5Tequal(dst, H5T_NATIVE_LDOUBLE)) { - dst_type_name = "long double"; - dst_type = FLT_LDOUBLE; + dst_type_name = "signed char"; + dst_type = INT_SCHAR; + } + else if (H5Tequal(dst, H5T_NATIVE_UCHAR)) { + dst_type_name = "unsigned char"; + dst_type = INT_UCHAR; + } + else if (H5Tequal(dst, H5T_NATIVE_SHORT)) { + dst_type_name = "short"; + dst_type = INT_SHORT; + } + else if (H5Tequal(dst, H5T_NATIVE_USHORT)) { + dst_type_name = "unsigned short"; + dst_type = INT_USHORT; + } + else if (H5Tequal(dst, H5T_NATIVE_INT)) { + dst_type_name = "int"; + dst_type = INT_INT; + } + else if (H5Tequal(dst, H5T_NATIVE_UINT)) { + dst_type_name = "unsigned int"; + dst_type = INT_UINT; + } + else if (H5Tequal(dst, H5T_NATIVE_LONG)) { + dst_type_name = "long"; + dst_type = INT_LONG; + } + else if (H5Tequal(dst, H5T_NATIVE_ULONG)) { + dst_type_name = "unsigned long"; + dst_type = INT_ULONG; + } + else if (H5Tequal(dst, H5T_NATIVE_LLONG)) { + dst_type_name = "long long"; + dst_type = INT_LLONG; + } + else if (H5Tequal(dst, H5T_NATIVE_ULLONG)) { + dst_type_name = "unsigned long long"; + dst_type = INT_ULLONG; + } + else if (H5Tequal(dst, H5T_NATIVE_FLOAT)) { + dst_type_name = "float"; + dst_type = FLT_FLOAT; + } + else if (H5Tequal(dst, H5T_NATIVE_DOUBLE)) { + dst_type_name = "double"; + dst_type = FLT_DOUBLE; +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (H5Tequal(dst, H5T_NATIVE_LDOUBLE)) { + dst_type_name = "long double"; + dst_type = FLT_LDOUBLE; #endif - } else { - dst_type_name = "UNKNOWN"; - dst_type = OTHER; + } + else { + dst_type_name = "UNKNOWN"; + dst_type = OTHER; } /* Sanity checks */ - if (OTHER==src_type || OTHER==dst_type) { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - HDprintf("%-70s", str); - H5_FAILED(); - HDputs(" Unknown data type."); - goto error; - } - - if ((INT_SCHAR==src_type || INT_UCHAR==src_type || INT_SHORT==src_type || - INT_USHORT==src_type || INT_INT==src_type || INT_UINT==src_type || - INT_LONG==src_type || INT_ULONG==src_type || INT_LLONG==src_type || - INT_ULLONG==src_type) && - (FLT_FLOAT!=dst_type && FLT_DOUBLE!=dst_type -#if H5_SIZEOF_LONG_DOUBLE !=0 - && FLT_LDOUBLE!=dst_type + if (OTHER == src_type || OTHER == dst_type) { + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" Unknown data type."); + goto error; + } + + if ((INT_SCHAR == src_type || INT_UCHAR == src_type || INT_SHORT == src_type || INT_USHORT == src_type || + INT_INT == src_type || INT_UINT == src_type || INT_LONG == src_type || INT_ULONG == src_type || + INT_LLONG == src_type || INT_ULLONG == src_type) && + (FLT_FLOAT != dst_type && FLT_DOUBLE != dst_type +#if H5_SIZEOF_LONG_DOUBLE != 0 + && FLT_LDOUBLE != dst_type #endif - )) { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - HDprintf("%-70s", str); - H5_FAILED(); - HDputs(" 1. Not an integer-float conversion."); - goto error; - } - - if ((FLT_FLOAT==src_type || FLT_DOUBLE==src_type -#if H5_SIZEOF_LONG_DOUBLE !=0 - || FLT_LDOUBLE==src_type + )) { + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" 1. Not an integer-float conversion."); + goto error; + } + + if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type +#if H5_SIZEOF_LONG_DOUBLE != 0 + || FLT_LDOUBLE == src_type #endif - ) - && (INT_SCHAR!=dst_type && INT_UCHAR!=dst_type && INT_SHORT!=dst_type - && INT_USHORT!=dst_type && INT_INT!=dst_type && INT_UINT!=dst_type - && INT_LONG!=dst_type && INT_ULONG!=dst_type && INT_LLONG!=dst_type - && INT_ULLONG!=dst_type)) { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); - HDprintf("%-70s", str); - H5_FAILED(); - HDputs(" 2. Not a float-integer conversion."); - goto error; - } - - if (INT_SCHAR==src_type || INT_UCHAR==src_type || INT_SHORT==src_type || - INT_USHORT==src_type || INT_INT==src_type || INT_UINT==src_type || - INT_LONG==src_type || INT_ULONG==src_type || INT_LLONG==src_type || - INT_ULLONG==src_type) { - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, src_type_name, dst_type_name); + ) && + (INT_SCHAR != dst_type && INT_UCHAR != dst_type && INT_SHORT != dst_type && INT_USHORT != dst_type && + INT_INT != dst_type && INT_UINT != dst_type && INT_LONG != dst_type && INT_ULONG != dst_type && + INT_LLONG != dst_type && INT_ULLONG != dst_type)) { + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); + HDprintf("%-70s", str); + H5_FAILED(); + HDputs(" 2. Not a float-integer conversion."); + goto error; + } + + if (INT_SCHAR == src_type || INT_UCHAR == src_type || INT_SHORT == src_type || INT_USHORT == src_type || + INT_INT == src_type || INT_UINT == src_type || INT_LONG == src_type || INT_ULONG == src_type || + INT_LLONG == src_type || INT_ULLONG == src_type) { + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); HDprintf("%-70s", str); HDfflush(stdout); - fails_this_test=0; - } else { - if(run_test==TEST_NORMAL) - HDsnprintf(str, sizeof(str), "Testing %s normalized %s -> %s conversions", - name, src_type_name, dst_type_name); - else if(run_test==TEST_DENORM) - HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", - name, src_type_name, dst_type_name); + fails_this_test = 0; + } + else { + if (run_test == TEST_NORMAL) + HDsnprintf(str, sizeof(str), "Testing %s normalized %s -> %s conversions", name, src_type_name, + dst_type_name); + else if (run_test == TEST_DENORM) + HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", name, src_type_name, + dst_type_name); else - HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", - name, src_type_name, dst_type_name); + HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", name, src_type_name, + dst_type_name); HDprintf("%-70s", str); HDfflush(stdout); - fails_this_test=0; + fails_this_test = 0; } /* Some information about datatypes */ - sendian = H5Tget_order(src); - dendian = H5Tget_order(dst); - src_size = H5Tget_size(src); - dst_size = H5Tget_size(dst); + sendian = H5Tget_order(src); + dendian = H5Tget_order(dst); + src_size = H5Tget_size(src); + dst_size = H5Tget_size(dst); src_nbits = H5Tget_precision(src); /* not 8*src_size, esp on J90 - QAK */ dst_nbits = H5Tget_precision(dst); /* not 8*dst_size, esp on J90 - QAK */ - aligned = HDcalloc((size_t)1, MAX(sizeof(long double), sizeof(long long))); + aligned = HDcalloc((size_t)1, MAX(sizeof(long double), sizeof(long long))); #ifdef SHOW_OVERFLOWS noverflows_g = 0; #endif @@ -3633,22 +3753,20 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * conversion exception happens. We only test (unsigned) int - float * and float - (unsigned) int conversions, which should cover more cases. */ - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if((src_type == INT_INT && dst_type == FLT_FLOAT) || - (src_type == INT_UINT && dst_type == FLT_FLOAT) || - (src_type == FLT_FLOAT && dst_type == INT_UINT) || - (src_type == FLT_FLOAT && dst_type == INT_INT)) { - if(H5Pset_type_conv_cb(dxpl_id, except_func, &fill_value) < 0) + if ((src_type == INT_INT && dst_type == FLT_FLOAT) || (src_type == INT_UINT && dst_type == FLT_FLOAT) || + (src_type == FLT_FLOAT && dst_type == INT_UINT) || (src_type == FLT_FLOAT && dst_type == INT_INT)) { + if (H5Pset_type_conv_cb(dxpl_id, except_func, &fill_value) < 0) goto error; else except_set = TRUE; - if(H5Pget_type_conv_cb(dxpl_id, &op, &user_data) < 0) + if (H5Pget_type_conv_cb(dxpl_id, &op, &user_data) < 0) goto error; - if(op != except_func || *(int*)user_data != fill_value) + if (op != except_func || *(int *)user_data != fill_value) goto error; } @@ -3656,554 +3774,583 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * INIT_FP_NORM if floating-point. The BUF will be used for the conversion while the SAVED buffer will be * used for the comparison later. */ - if(src_type == INT_SCHAR) { + if (src_type == INT_SCHAR) { INIT_INTEGER(signed char, SCHAR_MAX, SCHAR_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_UCHAR) { + } + else if (src_type == INT_UCHAR) { INIT_INTEGER(unsigned char, UCHAR_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_SHORT) { + } + else if (src_type == INT_SHORT) { INIT_INTEGER(short, SHRT_MAX, SHRT_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_USHORT) { + } + else if (src_type == INT_USHORT) { INIT_INTEGER(unsigned short, USHRT_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_INT) { + } + else if (src_type == INT_INT) { INIT_INTEGER(int, INT_MAX, INT_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_UINT) { + } + else if (src_type == INT_UINT) { INIT_INTEGER(unsigned int, UINT_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_LONG) { + } + else if (src_type == INT_LONG) { INIT_INTEGER(long, LONG_MAX, LONG_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_ULONG) { + } + else if (src_type == INT_ULONG) { INIT_INTEGER(unsigned long, ULONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_LLONG) { + } + else if (src_type == INT_LLONG) { INIT_INTEGER(long long, LLONG_MAX, LLONG_MIN, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == INT_ULLONG) { + } + else if (src_type == INT_ULLONG) { INIT_INTEGER(unsigned long long, ULLONG_MAX, 0, src_size, dst_size, src_nbits, buf, saved, nelmts); - } else if(src_type == FLT_FLOAT) { - if(run_test==TEST_NORMAL) { - INIT_FP_NORM(float, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, - src_size, dst_size, buf, saved, nelmts); - } else if(run_test==TEST_DENORM) { - INIT_FP_DENORM(float, FLT_MANT_DIG, src_size, src_nbits, sendian, dst_size, - buf, saved, nelmts); - } else { + } + else if (src_type == FLT_FLOAT) { + if (run_test == TEST_NORMAL) { + INIT_FP_NORM(float, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, src_size, dst_size, buf, + saved, nelmts); + } + else if (run_test == TEST_DENORM) { + INIT_FP_DENORM(float, FLT_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); + } + else { INIT_FP_SPECIAL(src_size, src_nbits, sendian, FLT_MANT_DIG, dst_size, buf, saved, nelmts); } - } else if(src_type == FLT_DOUBLE) { - if(run_test==TEST_NORMAL) { - INIT_FP_NORM(double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, - src_size, dst_size, buf, saved, nelmts); - } else if(run_test==TEST_DENORM) { - INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, - buf, saved, nelmts); - } else { + } + else if (src_type == FLT_DOUBLE) { + if (run_test == TEST_NORMAL) { + INIT_FP_NORM(double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, src_size, dst_size, buf, + saved, nelmts); + } + else if (run_test == TEST_DENORM) { + INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); + } + else { INIT_FP_SPECIAL(src_size, src_nbits, sendian, DBL_MANT_DIG, dst_size, buf, saved, nelmts); } -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 - } else if(src_type == FLT_LDOUBLE) { - if(run_test==TEST_NORMAL) { - INIT_FP_NORM(long double, LDBL_MAX, LDBL_MIN, LDBL_MAX_10_EXP, LDBL_MIN_10_EXP, - src_size, dst_size, buf, saved, nelmts); - } else if(run_test==TEST_DENORM) { - INIT_FP_DENORM(long double, LDBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, - buf, saved, nelmts); - } else { - INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (src_type == FLT_LDOUBLE) { + if (run_test == TEST_NORMAL) { + INIT_FP_NORM(long double, LDBL_MAX, LDBL_MIN, LDBL_MAX_10_EXP, LDBL_MIN_10_EXP, src_size, + dst_size, buf, saved, nelmts); } -#endif - } else - goto error; - - /* Perform the conversion */ - if(H5Tconvert(src, dst, nelmts, buf, NULL, dxpl_id) < 0) - goto error; - - /* Check the results from the library against hardware */ - for (j=0; j=max_fails) { - if(run_test==TEST_NORMAL) + if (++fails_all_tests >= max_fails) { + if (run_test == TEST_NORMAL) HDputs(" maximum failures reached, aborting test..."); - else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL) + else if (run_test == TEST_DENORM || run_test == TEST_SPECIAL) HDputs(" maximum warnings reached, aborting test..."); HDputs(" (dst is library's conversion output. ans is compiler's conversion output.)"); @@ -4538,46 +4693,51 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) } } - if(!fails_all_tests) + if (!fails_all_tests) PASSED(); - done: - if (buf) aligned_free(buf); - if (saved) aligned_free(saved); - if (aligned) HDfree(aligned); +done: + if (buf) + aligned_free(buf); + if (saved) + aligned_free(saved); + if (aligned) + HDfree(aligned); HDfflush(stdout); /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - reset_hdf5(); /*print statistics*/ + reset_hdf5(); /*print statistics*/ /* If the source is normalized floating values, treat the failures as error; * if it is denormalized or special floating values, treat the failure as warning.*/ - if(run_test==TEST_NORMAL) + if (run_test == TEST_NORMAL) return (int)fails_all_tests; - else if(run_test==TEST_DENORM || run_test==TEST_SPECIAL) + else if (run_test == TEST_DENORM || run_test == TEST_SPECIAL) return 0; - error: - if (buf) aligned_free(buf); - if (saved) aligned_free(saved); - if (aligned) HDfree(aligned); +error: + if (buf) + aligned_free(buf); + if (saved) + aligned_free(saved); + if (aligned) + HDfree(aligned); HDfflush(stdout); /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - reset_hdf5(); /*print statistics*/ + reset_hdf5(); /*print statistics*/ - if(run_test==TEST_NORMAL) + if (run_test == TEST_NORMAL) return MAX((int)fails_all_tests, 1); else { - HDassert(run_test==TEST_DENORM || run_test==TEST_SPECIAL); + HDassert(run_test == TEST_DENORM || run_test == TEST_SPECIAL); return 1; } } - /*------------------------------------------------------------------------- * Function: overflows * @@ -4599,14 +4759,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) static hbool_t overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits) { - hbool_t ret_value=FALSE; - hsize_t expt; - size_t mant_digits=0, expt_digits=0, bias=0; - size_t epos, mpos; - size_t src_prec=0; /*source type precision in bits*/ - H5T_norm_t norm; - ssize_t indx; - unsigned char bits[32], mant_bits[32]; + hbool_t ret_value = FALSE; + hsize_t expt; + size_t mant_digits = 0, expt_digits = 0, bias = 0; + size_t epos, mpos; + size_t src_prec = 0; /*source type precision in bits*/ + H5T_norm_t norm; + ssize_t indx; + unsigned char bits[32], mant_bits[32]; HDmemset(bits, 0, (size_t)32); HDmemset(mant_bits, 0, (size_t)32); @@ -4621,55 +4781,53 @@ overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits) bias = H5Tget_ebias(src_id); norm = H5Tget_norm(src_id); - HDmemcpy(bits, origin_bits, src_prec/8+1); + HDmemcpy(bits, origin_bits, src_prec / 8 + 1); /*Check for special cases: +Inf, -Inf*/ - if (H5T__bit_find (bits, mpos, mant_digits, H5T_BIT_LSB, TRUE) < 0) { - if (H5T__bit_find (bits, epos, expt_digits, H5T_BIT_LSB, FALSE) < 0) { - ret_value=TRUE; + if (H5T__bit_find(bits, mpos, mant_digits, H5T_BIT_LSB, TRUE) < 0) { + if (H5T__bit_find(bits, epos, expt_digits, H5T_BIT_LSB, FALSE) < 0) { + ret_value = TRUE; goto done; } - } else if (H5T_NORM_NONE==norm && H5T__bit_find (bits, mpos, mant_digits-1, - H5T_BIT_LSB, TRUE) < 0 && H5T__bit_find (bits, epos, expt_digits, - H5T_BIT_LSB, FALSE) < 0) { + } + else if (H5T_NORM_NONE == norm && H5T__bit_find(bits, mpos, mant_digits - 1, H5T_BIT_LSB, TRUE) < 0 && + H5T__bit_find(bits, epos, expt_digits, H5T_BIT_LSB, FALSE) < 0) { /*This is a special case for the source of no implied mantissa bit. *If the exponent bits are all 1s and only the 1st bit of mantissa *is set to 1. It's infinity. The Intel-Linux "long double" is this case.*/ - ret_value=TRUE; - goto done; + ret_value = TRUE; + goto done; } /* get exponent */ expt = H5T__bit_get_d(bits, mant_digits, expt_digits) - bias; - if(expt>=(dst_num_bits-1)) { - ret_value=TRUE; - goto done; + if (expt >= (dst_num_bits - 1)) { + ret_value = TRUE; + goto done; } /* get significand */ - H5T__bit_copy (mant_bits, (size_t)0, bits, (size_t)0, mant_digits); - + H5T__bit_copy(mant_bits, (size_t)0, bits, (size_t)0, mant_digits); /* restore implicit bit if normalization is implied*/ - if(norm == H5T_NORM_IMPLIED) { + if (norm == H5T_NORM_IMPLIED) { H5T__bit_inc(mant_bits, mant_digits, (size_t)1); mant_digits++; } /* shift significand */ - H5T__bit_shift (mant_bits, (ssize_t)(expt-expt_digits), (size_t)0, (size_t)(32 * 8)); + H5T__bit_shift(mant_bits, (ssize_t)(expt - expt_digits), (size_t)0, (size_t)(32 * 8)); indx = H5T__bit_find(mant_bits, (size_t)0, (size_t)(32 * 8), H5T_BIT_MSB, 1); - if((size_t)indx>=dst_num_bits) - ret_value=TRUE; + if ((size_t)indx >= dst_num_bits) + ret_value = TRUE; done: return ret_value; } - /*------------------------------------------------------------------------- * Function: run_integer_tests * @@ -4687,18 +4845,18 @@ done: static int run_integer_tests(const char *name) { - int nerrors = 0; + int nerrors = 0; nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_UCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_SHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_USHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_INT); nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_UINT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_LONG); nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_ULONG); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_LLONG); nerrors += test_conv_int_1(name, H5T_NATIVE_SCHAR, H5T_NATIVE_ULLONG); #endif @@ -4708,11 +4866,11 @@ run_integer_tests(const char *name) nerrors += test_conv_int_1(name, H5T_NATIVE_UCHAR, H5T_NATIVE_USHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_UCHAR, H5T_NATIVE_INT); nerrors += test_conv_int_1(name, H5T_NATIVE_UCHAR, H5T_NATIVE_UINT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_UCHAR, H5T_NATIVE_LONG); nerrors += test_conv_int_1(name, H5T_NATIVE_UCHAR, H5T_NATIVE_ULONG); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_UCHAR, H5T_NATIVE_LLONG); nerrors += test_conv_int_1(name, H5T_NATIVE_UCHAR, H5T_NATIVE_ULLONG); #endif @@ -4722,11 +4880,11 @@ run_integer_tests(const char *name) nerrors += test_conv_int_1(name, H5T_NATIVE_SHORT, H5T_NATIVE_USHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_SHORT, H5T_NATIVE_INT); nerrors += test_conv_int_1(name, H5T_NATIVE_SHORT, H5T_NATIVE_UINT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_SHORT, H5T_NATIVE_LONG); nerrors += test_conv_int_1(name, H5T_NATIVE_SHORT, H5T_NATIVE_ULONG); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_SHORT, H5T_NATIVE_LLONG); nerrors += test_conv_int_1(name, H5T_NATIVE_SHORT, H5T_NATIVE_ULLONG); #endif @@ -4736,11 +4894,11 @@ run_integer_tests(const char *name) nerrors += test_conv_int_1(name, H5T_NATIVE_USHORT, H5T_NATIVE_SHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_USHORT, H5T_NATIVE_INT); nerrors += test_conv_int_1(name, H5T_NATIVE_USHORT, H5T_NATIVE_UINT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_USHORT, H5T_NATIVE_LONG); nerrors += test_conv_int_1(name, H5T_NATIVE_USHORT, H5T_NATIVE_ULONG); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_USHORT, H5T_NATIVE_LLONG); nerrors += test_conv_int_1(name, H5T_NATIVE_USHORT, H5T_NATIVE_ULLONG); #endif @@ -4750,11 +4908,11 @@ run_integer_tests(const char *name) nerrors += test_conv_int_1(name, H5T_NATIVE_INT, H5T_NATIVE_SHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_INT, H5T_NATIVE_USHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_INT, H5T_NATIVE_UINT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_INT, H5T_NATIVE_LONG); nerrors += test_conv_int_1(name, H5T_NATIVE_INT, H5T_NATIVE_ULONG); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_INT, H5T_NATIVE_LLONG); nerrors += test_conv_int_1(name, H5T_NATIVE_INT, H5T_NATIVE_ULLONG); #endif @@ -4764,16 +4922,16 @@ run_integer_tests(const char *name) nerrors += test_conv_int_1(name, H5T_NATIVE_UINT, H5T_NATIVE_SHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_UINT, H5T_NATIVE_USHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_UINT, H5T_NATIVE_INT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_UINT, H5T_NATIVE_LONG); nerrors += test_conv_int_1(name, H5T_NATIVE_UINT, H5T_NATIVE_ULONG); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_UINT, H5T_NATIVE_LLONG); nerrors += test_conv_int_1(name, H5T_NATIVE_UINT, H5T_NATIVE_ULLONG); #endif -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_LONG, H5T_NATIVE_SCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_LONG, H5T_NATIVE_UCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_LONG, H5T_NATIVE_SHORT); @@ -4781,13 +4939,13 @@ run_integer_tests(const char *name) nerrors += test_conv_int_1(name, H5T_NATIVE_LONG, H5T_NATIVE_INT); nerrors += test_conv_int_1(name, H5T_NATIVE_LONG, H5T_NATIVE_UINT); nerrors += test_conv_int_1(name, H5T_NATIVE_LONG, H5T_NATIVE_ULONG); -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_LONG, H5T_NATIVE_LLONG); nerrors += test_conv_int_1(name, H5T_NATIVE_LONG, H5T_NATIVE_ULLONG); #endif #endif -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_ULONG, H5T_NATIVE_SCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_ULONG, H5T_NATIVE_UCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_ULONG, H5T_NATIVE_SHORT); @@ -4795,34 +4953,34 @@ run_integer_tests(const char *name) nerrors += test_conv_int_1(name, H5T_NATIVE_ULONG, H5T_NATIVE_INT); nerrors += test_conv_int_1(name, H5T_NATIVE_ULONG, H5T_NATIVE_UINT); nerrors += test_conv_int_1(name, H5T_NATIVE_ULONG, H5T_NATIVE_LONG); -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_ULONG, H5T_NATIVE_LLONG); nerrors += test_conv_int_1(name, H5T_NATIVE_ULONG, H5T_NATIVE_ULLONG); #endif #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_SCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_UCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_SHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_USHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_INT); nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_UINT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_LONG); nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_ULONG); #endif nerrors += test_conv_int_1(name, H5T_NATIVE_LLONG, H5T_NATIVE_ULLONG); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_1(name, H5T_NATIVE_ULLONG, H5T_NATIVE_SCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_ULLONG, H5T_NATIVE_UCHAR); nerrors += test_conv_int_1(name, H5T_NATIVE_ULLONG, H5T_NATIVE_SHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_ULLONG, H5T_NATIVE_USHORT); nerrors += test_conv_int_1(name, H5T_NATIVE_ULLONG, H5T_NATIVE_INT); nerrors += test_conv_int_1(name, H5T_NATIVE_ULLONG, H5T_NATIVE_UINT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_1(name, H5T_NATIVE_ULLONG, H5T_NATIVE_LONG); nerrors += test_conv_int_1(name, H5T_NATIVE_ULLONG, H5T_NATIVE_ULONG); #endif @@ -4832,7 +4990,6 @@ run_integer_tests(const char *name) return nerrors; } - /*------------------------------------------------------------------------- * Function: run_fp_tests * @@ -4850,12 +5007,12 @@ run_integer_tests(const char *name) static int run_fp_tests(const char *name) { - int nerrors = 0; + int nerrors = 0; - if(!strcmp(name, "noop")) { + if (!strcmp(name, "noop")) { nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_FLOAT, H5T_NATIVE_FLOAT); nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_DOUBLE, H5T_NATIVE_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LDOUBLE); #endif goto done; @@ -4864,7 +5021,7 @@ run_fp_tests(const char *name) /*Test normalized values. TEST_NORMAL indicates normalized values.*/ nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT); -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_FLOAT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_LDOUBLE); nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_LDOUBLE, H5T_NATIVE_FLOAT); @@ -4874,20 +5031,20 @@ run_fp_tests(const char *name) /*Test denormalized values. TEST_DENORM indicates denormalized values.*/ nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT); -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_DOUBLE, H5T_NATIVE_LDOUBLE); #ifndef H5_DISABLE_SOME_LDOUBLE_CONV nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_LDOUBLE, H5T_NATIVE_FLOAT); #else { - char str[256]; /*string */ + char str[256]; /*string */ - HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", - name, "long double", "float"); + HDsnprintf(str, sizeof(str), "Testing %s denormalized %s -> %s conversions", name, "long double", + "float"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); #else HDputs(" Test skipped due to disabled long double."); @@ -4901,7 +5058,7 @@ run_fp_tests(const char *name) /*Test special values, +/-0, +/-infinity, +/-QNaN, +/-SNaN.*/ nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT); -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_LDOUBLE); #ifndef H5_DISABLE_SOME_LDOUBLE_CONV @@ -4909,13 +5066,13 @@ run_fp_tests(const char *name) nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_LDOUBLE, H5T_NATIVE_DOUBLE); #else { - char str[256]; /*string */ + char str[256]; /*string */ - HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", - name, "long double", "float or double"); + HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", name, "long double", + "float or double"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); #else HDputs(" Test skipped due to disabled long double."); @@ -4928,7 +5085,6 @@ done: return nerrors; } - /*------------------------------------------------------------------------- * Function: run_int_fp_conv * @@ -4946,7 +5102,7 @@ done: static int run_int_fp_conv(const char *name) { - int nerrors = 0; + int nerrors = 0; nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SCHAR, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SCHAR, H5T_NATIVE_DOUBLE); @@ -4966,7 +5122,7 @@ run_int_fp_conv(const char *name) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UINT, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UINT, H5T_NATIVE_DOUBLE); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_DOUBLE); @@ -4974,7 +5130,7 @@ run_int_fp_conv(const char *name) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_DOUBLE); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_DOUBLE); @@ -4982,26 +5138,26 @@ run_int_fp_conv(const char *name) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULLONG, H5T_NATIVE_DOUBLE); #endif -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SCHAR, H5T_NATIVE_LDOUBLE); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UCHAR, H5T_NATIVE_LDOUBLE); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SHORT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_USHORT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_INT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UINT, H5T_NATIVE_LDOUBLE); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT #if !defined(H5_LONG_TO_LDOUBLE_SPECIAL) && !defined(H5_DISABLE_SOME_LDOUBLE_CONV) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_LDOUBLE); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_LDOUBLE); #else { - char str[256]; /*string */ + char str[256]; /*string */ - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, "(unsigned) long", "long double"); + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "(unsigned) long", + "long double"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the special algorithm of hardware conversion."); #else HDputs(" Test skipped due to disabled long double."); @@ -5009,15 +5165,14 @@ run_int_fp_conv(const char *name) } #endif #endif /* H5_SIZEOF_LONG!=H5_SIZEOF_INT */ -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG #if H5_LLONG_TO_LDOUBLE_CORRECT nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_LDOUBLE); -#else /* H5_LLONG_TO_LDOUBLE_CORRECT */ +#else /* H5_LLONG_TO_LDOUBLE_CORRECT */ { - char str[256]; /*hello string */ + char str[256]; /*hello string */ - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, "long long", "long double"); + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long long", "long double"); HDprintf("%-70s", str); SKIPPED(); HDputs(" Test skipped due to compiler error in handling conversion."); @@ -5025,12 +5180,12 @@ run_int_fp_conv(const char *name) #endif /* H5_LLONG_TO_LDOUBLE_CORRECT */ #if H5_LLONG_TO_LDOUBLE_CORRECT nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULLONG, H5T_NATIVE_LDOUBLE); -#else /* H5_LLONG_TO_LDOUBLE_CORRECT */ +#else /* H5_LLONG_TO_LDOUBLE_CORRECT */ { - char str[256]; /*hello string */ + char str[256]; /*hello string */ - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, "unsigned long long", "long double"); + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "unsigned long long", + "long double"); HDprintf("%-70s", str); SKIPPED(); HDputs(" Test skipped due to compiler not handling conversion."); @@ -5042,7 +5197,6 @@ run_int_fp_conv(const char *name) return nerrors; } - /*------------------------------------------------------------------------- * Function: run_fp_int_conv * @@ -5060,10 +5214,10 @@ run_int_fp_conv(const char *name) static int run_fp_int_conv(const char *name) { - int nerrors = 0; - int test_values; + int nerrors = 0; + int test_values; - for(test_values = TEST_NORMAL; test_values <= TEST_SPECIAL; test_values++) { + for (test_values = TEST_NORMAL; test_values <= TEST_SPECIAL; test_values++) { nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR); @@ -5083,7 +5237,7 @@ run_fp_int_conv(const char *name) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UINT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UINT); -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LONG); @@ -5091,11 +5245,12 @@ run_fp_int_conv(const char *name) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULONG); #endif -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG - if(!strcmp(name, "hw")) { /* Hardware conversion */ +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG + if (!strcmp(name, "hw")) { /* Hardware conversion */ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG); - } else { /* Software conversion */ + } + else { /* Software conversion */ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG); } @@ -5103,42 +5258,44 @@ run_fp_int_conv(const char *name) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULLONG); #endif -#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE - if(test_values != TEST_SPECIAL) { - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE + if (test_values != TEST_SPECIAL) { + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_INT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT); - } else { + } + else { #ifndef H5_DISABLE_SOME_LDOUBLE_CONV - nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_INT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT); #else - char str[256]; /*string */ + char str[256]; /*string */ - HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", - name, "long double", "signed and unsigned char, short, int, long"); + HDsnprintf(str, sizeof(str), "Testing %s special %s -> %s conversions", name, "long double", + "signed and unsigned char, short, int, long"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); #else HDputs(" Test skipped due to disabled long double."); #endif #endif } -#if H5_SIZEOF_LONG!=H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG != H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE != 0 #ifndef H5_LDOUBLE_TO_LONG_SPECIAL - if(test_values != TEST_SPECIAL && test_values != TEST_NORMAL) { + if (test_values != TEST_SPECIAL && test_values != TEST_NORMAL) { nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULONG); - } else { + } + else { #ifndef H5_DISABLE_SOME_LDOUBLE_CONV nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULONG); @@ -5146,13 +5303,13 @@ run_fp_int_conv(const char *name) } #else { - char str[256]; /*string */ + char str[256]; /*string */ - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, "long double", "(unsigned) long"); + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long double", + "(unsigned) long"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the special algorithm of hardware conversion."); #else HDputs(" Test skipped due to disabled long double."); @@ -5161,18 +5318,17 @@ run_fp_int_conv(const char *name) #endif #endif /*H5_SIZEOF_LONG!=H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE!=0 */ -#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG && H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG && H5_SIZEOF_LONG_DOUBLE != 0 #ifdef H5_LDOUBLE_TO_LLONG_ACCURATE nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LLONG); #else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ { - char str[256]; /*string */ + char str[256]; /*string */ - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, "long double", "long long"); + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long double", "long long"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to hardware conversion error."); #else HDputs(" Test skipped due to disabled long double."); @@ -5183,13 +5339,13 @@ run_fp_int_conv(const char *name) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULLONG); #else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ { - char str[256]; /*string */ + char str[256]; /*string */ - HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", - name, "long double", "unsigned long long"); + HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long double", + "unsigned long long"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to hardware conversion error."); #else HDputs(" Test skipped due to disabled long double."); @@ -5203,7 +5359,6 @@ run_fp_int_conv(const char *name) return nerrors; } - /*------------------------------------------------------------------------- * Function: main * @@ -5227,7 +5382,7 @@ run_fp_int_conv(const char *name) int main(void) { - unsigned long nerrors = 0; + unsigned long nerrors = 0; /* Set the random # seed */ HDsrandom((unsigned)HDtime(NULL)); @@ -5235,7 +5390,7 @@ main(void) reset_hdf5(); if (ALIGNMENT) - HDprintf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT); + HDprintf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT); /* Do the tests */ @@ -5304,11 +5459,9 @@ main(void) h5_restore_err(); if (nerrors) { - HDprintf("***** %lu FAILURE%s! *****\n", - nerrors, 1==nerrors?"":"S"); + HDprintf("***** %lu FAILURE%s! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } HDprintf("All data type tests passed.\n"); return 0; } - diff --git a/test/dtransform.c b/test/dtransform.c index bc61232..4035b11 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -13,8 +13,8 @@ #include "h5test.h" -#define ROWS 12 -#define COLS 18 +#define ROWS 12 +#define COLS 18 #define FLOAT_TOL 0.0001F static int init_test(hid_t file_id); @@ -26,266 +26,324 @@ static int test_set(void); static int test_getset(const hid_t dxpl_id_simple); /* These are needed for multiple tests, so are declared here globally and are init'ed in init_test */ -hid_t dset_id_int = -1; -hid_t dset_id_float = -1; -hid_t dset_id_int_chunk = -1; +hid_t dset_id_int = -1; +hid_t dset_id_float = -1; +hid_t dset_id_int_chunk = -1; hid_t dset_id_float_chunk = -1; - -const float windchillFfloat[ROWS][COLS] = - { {36.0f, 31.0f, 25.0f, 19.0f, 13.0f, 7.0f, 1.0f, -5.0f, -11.0f, -16.0f, -22.0f, -28.0f, -34.0f, -40.0f, -46.0f, -52.0f, -57.0f, -63.0f}, - {34.0f, 27.0f, 21.0f, 15.0f, 9.0f, 3.0f, -4.0f, -10.0f, -16.0f, -22.0f, -28.0f, -35.0f, -41.0f, -47.0f, -53.0f, -59.0f, -66.0f, -72.0f} , - {32.0f, 25.0f, 19.0f, 13.0f, 6.0f, 0.0f, -7.0f, -13.0f, -19.0f, -26.0f, -32.0f, -39.0f, -45.0f, -51.0f, -58.0f, -64.0f, -71.0f, -77.0f}, - {30.0f, 24.0f, 17.0f, 11.0f, 4.0f, -2.0f, -9.0f, -15.0f, -22.0f, -29.0f, -35.0f, -42.0f, -48.0f, -55.0f, -61.0f, -68.0f, -74.0f, -81.0f}, - {29.0f, 23.0f, 16.0f, 9.0f, 3.0f, -4.0f, -11.0f, -17.0f, -24.0f, -31.0f, -37.0f, -44.0f, -51.0f, -58.0f, -64.0f, -71.0f, -78.0f, -84.0f}, - {28.0f, 22.0f, 15.0f, 8.0f, 1.0f, -5.0f, -12.0f, -19.0f, -26.0f, -33.0f, -39.0f, -46.0f, -53.0f, -60.0f, -67.0f, -73.0f, -80.0f, -87.0f}, - {28.0f, 21.0f, 14.0f, 7.0f, 0.0f, -7.0f, -14.0f, -21.0f, -27.0f, -34.0f, -41.0f, -48.0f, -55.0f, -62.0f, -69.0f, -76.0f, -82.0f, -89.0f}, - {27.0f, 20.0f, 13.0f, 6.0f, -1.0f, -8.0f, -15.0f, -22.0f, -29.0f, -36.0f, -43.0f, -50.0f, -57.0f, -64.0f, -71.0f, -78.0f, -84.0f, -91.0f}, - {26.0f, 19.0f, 12.0f, 5.0f, -2.0f, -9.0f, -16.0f, -23.0f, -30.0f, -37.0f, -44.0f, -51.0f, -58.0f, -65.0f, -72.0f, -79.0f, -86.0f, -93.0f}, - {26.0f, 19.0f, 12.0f, 4.0f, -3.0f, -10.0f, -17.0f, -24.0f, -31.0f, -38.0f, -45.0f, -52.0f, -60.0f, -67.0f, -74.0f, -81.0f, -88.0f, -95.0f}, - {25.0f, 18.0f, 11.0f, 4.0f, -3.0f, -11.0f, -18.0f, -25.0f, -32.0f, -39.0f, -46.0f, -54.0f, -61.0f, -68.0f, -75.0f, -82.0f, -89.0f, -97.0f}, - {25.0f, 17.0f, 10.0f, 3.0f, -4.0f, -11.0f, -19.0f, -26.0f, -33.0f, -40.0f, -48.0f, -55.0f, -62.0f, -69.0f, -76.0f, -84.0f, -91.0f, -98.0f} - }; - -const int transformData[ROWS][COLS] = - { {36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63 }, - {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 1 } , - {32, 25, 19, 13, 6, 2, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 }, - {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9 }, - {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12 }, - {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15 }, - {28, 21, 14, 7, 6, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 }, - {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19 }, - {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 5, 7, 14, 21 }, - {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23}, - {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25}, - {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26} - }; - -#define UCOMPARE(TYPE,VAR1,VAR2,TOL) \ -{ \ - size_t i,j; \ - \ - for(i=0; i= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] - TOL) < (TYPE)((VAR2)[i][j]))) || ( ((VAR1)[i][j] <= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] + TOL) > (TYPE)((VAR2)[i][j]))))) \ - { \ - H5_FAILED(); \ - HDfprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \ - goto error; \ - } \ - } \ - PASSED(); \ -} - -#define COMPARE(TYPE,VAR1,VAR2,TOL) \ -{ \ - size_t i,j; \ - \ - for(i=0; i= ((TYPE)(VAR2)[i][j] - TOL))) ) \ - { \ - H5_FAILED(); \ - HDfprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \ - goto error; \ - } \ - } \ - PASSED(); \ -} - -#define COMPARE_INT(VAR1,VAR2) \ -{ \ - size_t i,j; \ - \ - for(i=0; i"TEST_STR")") \ - \ - if(H5Dread(dset, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \ - if(SIGNED) \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - else \ - UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ - \ - TESTING("contiguous, byte order conversion ("TEST_STR"->"TEST_STR")") \ - \ - if(H5Dread(dset_nn, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \ - if(SIGNED) \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - else \ - UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ - \ - if(SIGNED) \ - { \ - TESTING("contiguous, with type conversion (float->"TEST_STR")") \ - \ - if(H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - } \ - \ - if(H5Dclose(dset) < 0) TEST_ERROR; \ - if(H5Sclose(dataspace) < 0) TEST_ERROR; \ -} - -#define TEST_TYPE_CHUNK(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \ -{ \ - TYPE array[ROWS][COLS]; \ - const char* f_to_c = "(5/9.0)*(x-32)"; \ - /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */ \ - const char* utrans = "((x+100)/4)*3"; \ - \ - hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, memspace, dset_chunk, filespace; \ - hsize_t dim[2] = {ROWS, COLS}; \ - hsize_t offset[2] = {0, 0}; \ - \ - \ - if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR; \ - \ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; \ - if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR; \ - \ - if((dset_chunk = H5Dcreate2(file_id, "/transformtest_chunk_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR; \ - if((filespace = H5Dget_space(dset_chunk)) < 0) TEST_ERROR \ - if((memspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR \ - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR; \ - \ - if(SIGNED) \ - { \ - if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \ - if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR; \ - if(H5Dwrite(dset_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \ - if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \ - } \ - else \ - { \ - if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \ - if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR; \ - if(H5Dwrite(dset_chunk, H5T_NATIVE_INT, dataspace, filespace, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \ - if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \ - } \ - \ - \ - TESTING("chunked, no data type conversion ("TEST_STR"->"TEST_STR")") \ - \ - if(H5Dread(dset_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \ - if(SIGNED) \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - else \ - UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ - \ - if(SIGNED) \ - { \ - TESTING("chunked, with type conversion (float->"TEST_STR")") \ - \ - if(H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - } \ - \ - \ - if(H5Pclose(cparms) < 0) TEST_ERROR; \ - if(H5Dclose(dset_chunk) < 0) TEST_ERROR; \ - if(H5Sclose(dataspace) < 0) TEST_ERROR; \ - if(H5Sclose(memspace) < 0) TEST_ERROR; \ -} - -#define INVALID_SET_TEST(TRANSFORM) \ -{ \ - if(H5Pset_data_transform(dxpl_id, TRANSFORM) < 0) \ - { \ - PASSED(); \ - } \ - else \ - { \ - H5_FAILED(); \ - HDfprintf(stderr, " ERROR: Data transform allowed invalid TRANSFORM transform to be set\n"); \ - goto error; \ - } \ -} - -int main(void) +const float windchillFfloat[ROWS][COLS] = { + {36.0f, 31.0f, 25.0f, 19.0f, 13.0f, 7.0f, 1.0f, -5.0f, -11.0f, -16.0f, -22.0f, -28.0f, -34.0f, -40.0f, + -46.0f, -52.0f, -57.0f, -63.0f}, + {34.0f, 27.0f, 21.0f, 15.0f, 9.0f, 3.0f, -4.0f, -10.0f, -16.0f, -22.0f, -28.0f, -35.0f, -41.0f, -47.0f, + -53.0f, -59.0f, -66.0f, -72.0f}, + {32.0f, 25.0f, 19.0f, 13.0f, 6.0f, 0.0f, -7.0f, -13.0f, -19.0f, -26.0f, -32.0f, -39.0f, -45.0f, -51.0f, + -58.0f, -64.0f, -71.0f, -77.0f}, + {30.0f, 24.0f, 17.0f, 11.0f, 4.0f, -2.0f, -9.0f, -15.0f, -22.0f, -29.0f, -35.0f, -42.0f, -48.0f, -55.0f, + -61.0f, -68.0f, -74.0f, -81.0f}, + {29.0f, 23.0f, 16.0f, 9.0f, 3.0f, -4.0f, -11.0f, -17.0f, -24.0f, -31.0f, -37.0f, -44.0f, -51.0f, -58.0f, + -64.0f, -71.0f, -78.0f, -84.0f}, + {28.0f, 22.0f, 15.0f, 8.0f, 1.0f, -5.0f, -12.0f, -19.0f, -26.0f, -33.0f, -39.0f, -46.0f, -53.0f, -60.0f, + -67.0f, -73.0f, -80.0f, -87.0f}, + {28.0f, 21.0f, 14.0f, 7.0f, 0.0f, -7.0f, -14.0f, -21.0f, -27.0f, -34.0f, -41.0f, -48.0f, -55.0f, -62.0f, + -69.0f, -76.0f, -82.0f, -89.0f}, + {27.0f, 20.0f, 13.0f, 6.0f, -1.0f, -8.0f, -15.0f, -22.0f, -29.0f, -36.0f, -43.0f, -50.0f, -57.0f, -64.0f, + -71.0f, -78.0f, -84.0f, -91.0f}, + {26.0f, 19.0f, 12.0f, 5.0f, -2.0f, -9.0f, -16.0f, -23.0f, -30.0f, -37.0f, -44.0f, -51.0f, -58.0f, -65.0f, + -72.0f, -79.0f, -86.0f, -93.0f}, + {26.0f, 19.0f, 12.0f, 4.0f, -3.0f, -10.0f, -17.0f, -24.0f, -31.0f, -38.0f, -45.0f, -52.0f, -60.0f, -67.0f, + -74.0f, -81.0f, -88.0f, -95.0f}, + {25.0f, 18.0f, 11.0f, 4.0f, -3.0f, -11.0f, -18.0f, -25.0f, -32.0f, -39.0f, -46.0f, -54.0f, -61.0f, -68.0f, + -75.0f, -82.0f, -89.0f, -97.0f}, + {25.0f, 17.0f, 10.0f, 3.0f, -4.0f, -11.0f, -19.0f, -26.0f, -33.0f, -40.0f, -48.0f, -55.0f, -62.0f, -69.0f, + -76.0f, -84.0f, -91.0f, -98.0f}}; + +const int transformData[ROWS][COLS] = {{36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63}, + {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 1}, + {32, 25, 19, 13, 6, 2, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5}, + {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9}, + {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12}, + {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15}, + {28, 21, 14, 7, 6, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17}, + {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19}, + {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 5, 7, 14, 21}, + {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23}, + {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25}, + {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26}}; + +#define UCOMPARE(TYPE, VAR1, VAR2, TOL) \ + { \ + size_t i, j; \ + \ + for (i = 0; i < ROWS; i++) \ + for (j = 0; j < COLS; j++) { \ + if (!((((VAR1)[i][j] >= (TYPE)((VAR2)[i][j])) && \ + (((VAR1)[i][j] - TOL) < (TYPE)((VAR2)[i][j]))) || \ + (((VAR1)[i][j] <= (TYPE)((VAR2)[i][j])) && \ + (((VAR1)[i][j] + TOL) > (TYPE)((VAR2)[i][j]))))) { \ + H5_FAILED(); \ + HDfprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \ + goto error; \ + } \ + } \ + PASSED(); \ + } + +#define COMPARE(TYPE, VAR1, VAR2, TOL) \ + { \ + size_t i, j; \ + \ + for (i = 0; i < ROWS; i++) \ + for (j = 0; j < COLS; j++) { \ + if (!(((VAR1)[i][j] <= ((TYPE)(VAR2)[i][j] + TOL)) && \ + ((VAR1)[i][j] >= ((TYPE)(VAR2)[i][j] - TOL)))) { \ + H5_FAILED(); \ + HDfprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \ + goto error; \ + } \ + } \ + PASSED(); \ + } + +#define COMPARE_INT(VAR1, VAR2) \ + { \ + size_t i, j; \ + \ + for (i = 0; i < ROWS; i++) \ + for (j = 0; j < COLS; j++) { \ + if ((VAR1)[i][j] != (VAR2)[i][j]) { \ + H5_FAILED(); \ + HDfprintf(stderr, " ERROR: data failed to match computed data\n"); \ + goto error; \ + } \ + } \ + } + +#define TEST_TYPE_CONTIG(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \ + { \ + TYPE array[ROWS][COLS]; \ + const char *f_to_c = "(5/9.0)*(x-32)"; \ + /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to \ + * fit into uchar */ \ + const char *utrans = "((x+100)/4)*3"; \ + \ + hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset, dset_nn, dt_nn; \ + H5T_order_t order; \ + hsize_t dim[2] = {ROWS, COLS}; \ + \ + if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0) \ + TEST_ERROR; \ + if ((dset = H5Dcreate2(file_id, "/transformtest_" TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, \ + H5P_DEFAULT, H5P_DEFAULT)) < 0) \ + TEST_ERROR; \ + \ + if ((dt_nn = H5Tcopy(HDF_TYPE)) < 0) \ + TEST_ERROR \ + if ((order = H5Tget_order(dt_nn)) == H5T_ORDER_ERROR) \ + TEST_ERROR \ + if (H5Tset_order(dt_nn, order == H5T_ORDER_LE ? H5T_ORDER_BE : H5T_ORDER_LE) < 0) \ + TEST_ERROR \ + if ((dset_nn = H5Dcreate2(file_id, "/nonnative_transformtest_" TEST_STR, dt_nn, dataspace, \ + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) \ + TEST_ERROR \ + if (H5Tclose(dt_nn) < 0) \ + TEST_ERROR \ + \ + if (SIGNED) { \ + if ((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) \ + TEST_ERROR; \ + if (H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) \ + TEST_ERROR; \ + if (H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) \ + TEST_ERROR; \ + if (H5Dwrite(dset_nn, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) \ + TEST_ERROR; \ + if (H5Pclose(dxpl_id_f_to_c) < 0) \ + TEST_ERROR; \ + } \ + else { \ + if ((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) \ + TEST_ERROR; \ + if (H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) \ + TEST_ERROR; \ + if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) \ + TEST_ERROR; \ + if (H5Dwrite(dset_nn, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) \ + TEST_ERROR; \ + if (H5Pclose(dxpl_id_utrans) < 0) \ + TEST_ERROR; \ + } \ + \ + TESTING("contiguous, no data type conversion (" TEST_STR "->" TEST_STR ")") \ + \ + if (H5Dread(dset, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) \ + TEST_ERROR; \ + if (SIGNED) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ + else \ + UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + \ + TESTING("contiguous, byte order conversion (" TEST_STR "->" TEST_STR ")") \ + \ + if (H5Dread(dset_nn, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) \ + TEST_ERROR; \ + if (SIGNED) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ + else \ + UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + \ + if (SIGNED) { \ + TESTING("contiguous, with type conversion (float->" TEST_STR ")") \ + \ + if (H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) \ + TEST_ERROR; \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ + } \ + \ + if (H5Dclose(dset) < 0) \ + TEST_ERROR; \ + if (H5Sclose(dataspace) < 0) \ + TEST_ERROR; \ + } + +#define TEST_TYPE_CHUNK(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \ + { \ + TYPE array[ROWS][COLS]; \ + const char *f_to_c = "(5/9.0)*(x-32)"; \ + /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to \ + * fit into uchar */ \ + const char *utrans = "((x+100)/4)*3"; \ + \ + hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, memspace, dset_chunk, filespace; \ + hsize_t dim[2] = {ROWS, COLS}; \ + hsize_t offset[2] = {0, 0}; \ + \ + if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0) \ + TEST_ERROR; \ + \ + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) \ + TEST_ERROR; \ + if (H5Pset_chunk(cparms, 2, dim) < 0) \ + TEST_ERROR; \ + \ + if ((dset_chunk = H5Dcreate2(file_id, "/transformtest_chunk_" TEST_STR, HDF_TYPE, dataspace, \ + H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) \ + TEST_ERROR; \ + if ((filespace = H5Dget_space(dset_chunk)) < 0) \ + TEST_ERROR \ + if ((memspace = H5Screate_simple(2, dim, NULL)) < 0) \ + TEST_ERROR \ + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) \ + TEST_ERROR; \ + \ + if (SIGNED) { \ + if ((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) \ + TEST_ERROR; \ + if (H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) \ + TEST_ERROR; \ + if (H5Dwrite(dset_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, \ + windchillFfloat) < 0) \ + TEST_ERROR; \ + if (H5Pclose(dxpl_id_f_to_c) < 0) \ + TEST_ERROR; \ + } \ + else { \ + if ((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) \ + TEST_ERROR; \ + if (H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) \ + TEST_ERROR; \ + if (H5Dwrite(dset_chunk, H5T_NATIVE_INT, dataspace, filespace, dxpl_id_utrans, transformData) < \ + 0) \ + TEST_ERROR; \ + if (H5Pclose(dxpl_id_utrans) < 0) \ + TEST_ERROR; \ + } \ + \ + TESTING("chunked, no data type conversion (" TEST_STR "->" TEST_STR ")") \ + \ + if (H5Dread(dset_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) \ + TEST_ERROR; \ + if (SIGNED) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ + else \ + UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + \ + if (SIGNED) { \ + TESTING("chunked, with type conversion (float->" TEST_STR ")") \ + \ + if (H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) \ + TEST_ERROR; \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ + } \ + \ + if (H5Pclose(cparms) < 0) \ + TEST_ERROR; \ + if (H5Dclose(dset_chunk) < 0) \ + TEST_ERROR; \ + if (H5Sclose(dataspace) < 0) \ + TEST_ERROR; \ + if (H5Sclose(memspace) < 0) \ + TEST_ERROR; \ + } + +#define INVALID_SET_TEST(TRANSFORM) \ + { \ + if (H5Pset_data_transform(dxpl_id, TRANSFORM) < 0) { \ + PASSED(); \ + } \ + else { \ + H5_FAILED(); \ + HDfprintf(stderr, " ERROR: Data transform allowed invalid TRANSFORM transform to be set\n"); \ + goto error; \ + } \ + } + +int +main(void) { - hid_t dxpl_id_c_to_f = -1; - hid_t dxpl_id_c_to_f_copy = 1; - hid_t dxpl_id_simple = -1; - hid_t dxpl_id_polynomial = -1; + hid_t dxpl_id_c_to_f = -1; + hid_t dxpl_id_c_to_f_copy = 1; + hid_t dxpl_id_simple = -1; + hid_t dxpl_id_polynomial = -1; hid_t dxpl_id_polynomial_copy = -1; - hid_t dxpl_id_utrans_inv = -1; - hid_t file_id = -1; + hid_t dxpl_id_utrans_inv = -1; + hid_t file_id = -1; - const char* c_to_f = "(9/5.0)*x + 32"; - const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ - const char* polynomial = "(2+x)* ((x-8)/2)"; + const char *c_to_f = "(9/5.0)*x + 32"; + const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ + const char *polynomial = "(2+x)* ((x-8)/2)"; /* inverses the utrans transform in init_test to get back original array */ - const char* utrans_inv = "(x/3)*4 - 100"; - - if((file_id = H5Fcreate("dtransform.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - - if((dxpl_id_c_to_f = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; - if((dxpl_id_simple = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; - if((dxpl_id_utrans_inv = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; - if((dxpl_id_polynomial = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; - if(H5Pset_data_transform(dxpl_id_c_to_f, c_to_f) < 0) TEST_ERROR; - if(H5Pset_data_transform(dxpl_id_polynomial, polynomial) < 0) TEST_ERROR; - if(H5Pset_data_transform(dxpl_id_simple, simple) < 0) TEST_ERROR; - if(H5Pset_data_transform(dxpl_id_utrans_inv, utrans_inv) < 0) TEST_ERROR; - if((dxpl_id_polynomial_copy = H5Pcopy(dxpl_id_polynomial)) < 0) TEST_ERROR; - if((dxpl_id_c_to_f_copy = H5Pcopy(dxpl_id_c_to_f)) < 0) TEST_ERROR; + const char *utrans_inv = "(x/3)*4 - 100"; + + if ((file_id = H5Fcreate("dtransform.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if ((dxpl_id_c_to_f = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + if ((dxpl_id_simple = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + if ((dxpl_id_utrans_inv = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + if ((dxpl_id_polynomial = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + if (H5Pset_data_transform(dxpl_id_c_to_f, c_to_f) < 0) + TEST_ERROR; + if (H5Pset_data_transform(dxpl_id_polynomial, polynomial) < 0) + TEST_ERROR; + if (H5Pset_data_transform(dxpl_id_simple, simple) < 0) + TEST_ERROR; + if (H5Pset_data_transform(dxpl_id_utrans_inv, utrans_inv) < 0) + TEST_ERROR; + if ((dxpl_id_polynomial_copy = H5Pcopy(dxpl_id_polynomial)) < 0) + TEST_ERROR; + if ((dxpl_id_c_to_f_copy = H5Pcopy(dxpl_id_c_to_f)) < 0) + TEST_ERROR; /* Run all the tests */ - if(init_test(file_id) < 0) TEST_ERROR; - if(test_set() < 0) TEST_ERROR; + if (init_test(file_id) < 0) + TEST_ERROR; + if (test_set() < 0) + TEST_ERROR; TEST_TYPE_CONTIG(dxpl_id_utrans_inv, char, H5T_NATIVE_CHAR, "char", transformData, 0); TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned char, H5T_NATIVE_UCHAR, "uchar", transformData, 0); TEST_TYPE_CONTIG(dxpl_id_c_to_f, signed char, H5T_NATIVE_SCHAR, "schar", windchillFfloat, 1); @@ -299,7 +357,7 @@ int main(void) TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0); TEST_TYPE_CONTIG(dxpl_id_c_to_f, float, H5T_NATIVE_FLOAT, "float", windchillFfloat, 1); TEST_TYPE_CONTIG(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 TEST_TYPE_CONTIG(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1); #endif @@ -316,34 +374,50 @@ int main(void) TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0); TEST_TYPE_CHUNK(dxpl_id_c_to_f, float, H5T_NATIVE_FLOAT, "float", windchillFfloat, 1); TEST_TYPE_CHUNK(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1); -#if H5_SIZEOF_LONG_DOUBLE!=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 TEST_TYPE_CHUNK(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1); #endif - if(test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy) < 0) TEST_ERROR; - if(test_trivial(dxpl_id_simple) < 0) TEST_ERROR; - if(test_poly(dxpl_id_polynomial) < 0) TEST_ERROR; - if(test_getset(dxpl_id_c_to_f) < 0) TEST_ERROR; - if(test_specials(file_id) < 0) TEST_ERROR; + if (test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy) < 0) + TEST_ERROR; + if (test_trivial(dxpl_id_simple) < 0) + TEST_ERROR; + if (test_poly(dxpl_id_polynomial) < 0) + TEST_ERROR; + if (test_getset(dxpl_id_c_to_f) < 0) + TEST_ERROR; + if (test_specials(file_id) < 0) + TEST_ERROR; /* Close the objects we opened/created */ - if(H5Dclose(dset_id_int) < 0) TEST_ERROR; - if(H5Dclose(dset_id_int_chunk) < 0) TEST_ERROR; - if(H5Dclose(dset_id_float) < 0) TEST_ERROR; - if(H5Dclose(dset_id_float_chunk) < 0) TEST_ERROR; - if(H5Fclose(file_id) < 0) TEST_ERROR; - if(H5Pclose(dxpl_id_c_to_f) < 0) TEST_ERROR; - if(H5Pclose(dxpl_id_c_to_f_copy) < 0) TEST_ERROR; - if(H5Pclose(dxpl_id_polynomial) < 0) TEST_ERROR; - if(H5Pclose(dxpl_id_polynomial_copy) < 0) TEST_ERROR; - if(H5Pclose(dxpl_id_simple) < 0) TEST_ERROR; - if(H5Pclose(dxpl_id_utrans_inv) < 0) TEST_ERROR; - + if (H5Dclose(dset_id_int) < 0) + TEST_ERROR; + if (H5Dclose(dset_id_int_chunk) < 0) + TEST_ERROR; + if (H5Dclose(dset_id_float) < 0) + TEST_ERROR; + if (H5Dclose(dset_id_float_chunk) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5Pclose(dxpl_id_c_to_f) < 0) + TEST_ERROR; + if (H5Pclose(dxpl_id_c_to_f_copy) < 0) + TEST_ERROR; + if (H5Pclose(dxpl_id_polynomial) < 0) + TEST_ERROR; + if (H5Pclose(dxpl_id_polynomial_copy) < 0) + TEST_ERROR; + if (H5Pclose(dxpl_id_simple) < 0) + TEST_ERROR; + if (H5Pclose(dxpl_id_utrans_inv) < 0) + TEST_ERROR; - return 0; + return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset_id_int); H5Dclose(dset_id_int_chunk); H5Dclose(dset_id_float); @@ -355,86 +429,86 @@ error: H5Pclose(dxpl_id_polynomial_copy); H5Pclose(dxpl_id_simple); H5Pclose(dxpl_id_utrans_inv); - } H5E_END_TRY - return -1; + } + H5E_END_TRY + return -1; } static int init_test(hid_t file_id) { - const char* f_to_c = "(5/9.0)*(x-32)"; - /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */ - const char* utrans = "((x+100)/4)*3"; + const char *f_to_c = "(5/9.0)*(x-32)"; + /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit + * into uchar */ + const char *utrans = "((x+100)/4)*3"; - hid_t dataspace = -1; + hid_t dataspace = -1; hid_t dxpl_id_f_to_c = -1; hid_t dxpl_id_utrans = -1; - hid_t cparms = -1; - hid_t filespace = -1; - hsize_t dim[2] = { ROWS, COLS }; - hsize_t offset[2] = { 0, 0 }; + hid_t cparms = -1; + hid_t filespace = -1; + hsize_t dim[2] = {ROWS, COLS}; + hsize_t offset[2] = {0, 0}; - if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) + if (H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR - if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) + if (H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR cparms = H5Pcreate(H5P_DATASET_CREATE); - if(H5Pset_chunk(cparms, 2, dim) < 0) + if (H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR - if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) + if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR TESTING("Intializing test...") - if((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, - dxpl_id_f_to_c, windchillFfloat) < 0) + if (H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR - if((dset_id_float = H5Dcreate2(file_id, "/default_float", - H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id_float = H5Dcreate2(file_id, "/default_float", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, - dxpl_id_f_to_c, windchillFfloat) < 0) + if (H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR - if((dset_id_int_chunk = H5Dcreate2(file_id, "/default_chunk_int", - H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) + if ((dset_id_int_chunk = H5Dcreate2(file_id, "/default_chunk_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, + cparms, H5P_DEFAULT)) < 0) TEST_ERROR - if((filespace = H5Dget_space(dset_id_int_chunk)) < 0) + if ((filespace = H5Dget_space(dset_id_int_chunk)) < 0) TEST_ERROR - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR - if(H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, - dxpl_id_f_to_c, windchillFfloat) < 0) + if (H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < + 0) TEST_ERROR - if((dset_id_float_chunk = H5Dcreate2(file_id, "/default_chunk_float", - H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) + if ((dset_id_float_chunk = H5Dcreate2(file_id, "/default_chunk_float", H5T_NATIVE_FLOAT, dataspace, + H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, - dxpl_id_f_to_c, windchillFfloat) < 0) + if (H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, + windchillFfloat) < 0) TEST_ERROR - if(H5Pclose(cparms) < 0) + if (H5Pclose(cparms) < 0) TEST_ERROR - if(H5Pclose(dxpl_id_f_to_c) < 0) + if (H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR - if(H5Pclose(dxpl_id_utrans) < 0) + if (H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR - if(H5Sclose(dataspace) < 0) + if (H5Sclose(dataspace) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR PASSED(); @@ -442,13 +516,15 @@ init_test(hid_t file_id) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(cparms); H5Pclose(dxpl_id_f_to_c); H5Pclose(dxpl_id_utrans); H5Sclose(dataspace); H5Sclose(filespace); - } H5E_END_TRY + } + H5E_END_TRY return -1; } @@ -457,33 +533,31 @@ static int test_poly(const hid_t dxpl_id_polynomial) { float polyflres[ROWS][COLS]; - int polyintread[ROWS][COLS]; + int polyintread[ROWS][COLS]; float polyflread[ROWS][COLS]; - int windchillC; - int row, col; + int windchillC; + int row, col; - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) { - windchillC = (int) ((5.0f / 9.0f) * (windchillFfloat[row][col] - 32)); + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) { + windchillC = (int)((5.0f / 9.0f) * (windchillFfloat[row][col] - 32)); polyflres[row][col] = ((2.0f + (float)windchillC) * (((float)windchillC - 8.0f) / 2.0f)); } TESTING("data transform, polynomial transform (int->float)") - if(H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, - dxpl_id_polynomial, polyflread) < 0) + if (H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyflread) < 0) TEST_ERROR COMPARE(float, polyflread, polyflres, 2.0f) - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) { - windchillC = (int) ((5.0f / 9.0f) * (windchillFfloat[row][col] - 32)); - polyflres[row][col] = (float) ((2 + windchillC) * ((windchillC - 8) / 2)); + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) { + windchillC = (int)((5.0f / 9.0f) * (windchillFfloat[row][col] - 32)); + polyflres[row][col] = (float)((2 + windchillC) * ((windchillC - 8) / 2)); } TESTING("data transform, polynomial transform (float->int)") - if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id_polynomial, polyintread) < 0) + if (H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyintread) < 0) TEST_ERROR COMPARE(int, polyintread, polyflres, 4) @@ -491,188 +565,181 @@ test_poly(const hid_t dxpl_id_polynomial) return 0; error: - return -1; + return -1; } static int test_specials(hid_t file) { - hid_t dxpl_id, dset_id, dataspace; - hsize_t dim[2] = { ROWS, COLS }; - int read_buf[ROWS][COLS]; - int data_res[ROWS][COLS]; - int row, col; - const char* special1 = "x*-100"; - const char* special2 = "100-x"; - const char* special3 = "1000/x"; - const char* special4 = "-x"; - const char* special5 = "+x"; + hid_t dxpl_id, dset_id, dataspace; + hsize_t dim[2] = {ROWS, COLS}; + int read_buf[ROWS][COLS]; + int data_res[ROWS][COLS]; + int row, col; + const char *special1 = "x*-100"; + const char *special2 = "100-x"; + const char *special3 = "1000/x"; + const char *special4 = "-x"; + const char *special5 = "+x"; TESTING("data transform of some special cases") - if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) + if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; /*----------------------------- * Operation 1: x*-100 *----------------------------*/ - if(H5Pset_data_transform(dxpl_id, special1) < 0) TEST_ERROR; + if (H5Pset_data_transform(dxpl_id, special1) < 0) + TEST_ERROR; - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) data_res[row][col] = transformData[row][col] * -100; - if((dset_id = H5Dcreate2(file, "/special1", H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2(file, "/special1", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id, transformData) < 0) + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0) TEST_ERROR - if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, read_buf) < 0) + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0) TEST_ERROR COMPARE_INT(read_buf, data_res) - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) TEST_ERROR /*----------------------------- * Operation 2: 100-x *----------------------------*/ - if(H5Pset_data_transform(dxpl_id, special2) < 0) TEST_ERROR; + if (H5Pset_data_transform(dxpl_id, special2) < 0) + TEST_ERROR; - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) data_res[row][col] = 100 - transformData[row][col]; - if((dset_id = H5Dcreate2(file, "/special2", H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2(file, "/special2", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id, transformData) < 0) + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0) TEST_ERROR - if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, read_buf) < 0) + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0) TEST_ERROR COMPARE_INT(read_buf, data_res) - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) TEST_ERROR /*----------------------------- * Operation 3: 1000/x *----------------------------*/ - if(H5Pset_data_transform(dxpl_id, special3) < 0) TEST_ERROR; + if (H5Pset_data_transform(dxpl_id, special3) < 0) + TEST_ERROR; - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) data_res[row][col] = 1000 / transformData[row][col]; - if((dset_id = H5Dcreate2(file, "/special3", H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2(file, "/special3", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id, transformData) < 0) + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0) TEST_ERROR - if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, read_buf) < 0) + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0) TEST_ERROR COMPARE_INT(read_buf, data_res) - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) TEST_ERROR /*----------------------------- * Operation 4: -x *----------------------------*/ - if(H5Pset_data_transform(dxpl_id, special4) < 0) TEST_ERROR; + if (H5Pset_data_transform(dxpl_id, special4) < 0) + TEST_ERROR; - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) data_res[row][col] = -1 * transformData[row][col]; - if((dset_id = H5Dcreate2(file, "/special4", H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2(file, "/special4", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id, transformData) < 0) + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0) TEST_ERROR - if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, read_buf) < 0) + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0) TEST_ERROR COMPARE_INT(read_buf, data_res) - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) TEST_ERROR /*----------------------------- * Operation 5: +x *----------------------------*/ - if(H5Pset_data_transform(dxpl_id, special5) < 0) TEST_ERROR; + if (H5Pset_data_transform(dxpl_id, special5) < 0) + TEST_ERROR; - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) data_res[row][col] = transformData[row][col]; - if((dset_id = H5Dcreate2(file, "/special5", H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2(file, "/special5", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id, transformData) < 0) + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0) TEST_ERROR - if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, read_buf) < 0) + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0) TEST_ERROR COMPARE_INT(read_buf, data_res) - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) TEST_ERROR - - if(H5Pclose(dxpl_id) < 0) + if (H5Pclose(dxpl_id) < 0) TEST_ERROR - if(H5Sclose(dataspace) < 0) + if (H5Sclose(dataspace) < 0) TEST_ERROR PASSED(); return 0; error: - return -1; + return -1; } static int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy) { - int windchillC; + int windchillC; float polyflres[ROWS][COLS]; - int polyintread[ROWS][COLS]; - int windchillFintread[ROWS][COLS]; - int row, col; - - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) { - windchillC = (int) ((5.0f / 9.0f) * (windchillFfloat[row][col] - 32)); - polyflres[row][col] = (float) ((2 + windchillC) * ((windchillC - 8) / 2)); + int polyintread[ROWS][COLS]; + int windchillFintread[ROWS][COLS]; + int row, col; + + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) { + windchillC = (int)((5.0f / 9.0f) * (windchillFfloat[row][col] - 32)); + polyflres[row][col] = (float)((2 + windchillC) * ((windchillC - 8) / 2)); } TESTING("data transform, linear transform w/ copied property") - if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id_c_to_f_copy, windchillFintread) < 0) + if (H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f_copy, windchillFintread) < 0) TEST_ERROR COMPARE(int, windchillFintread, windchillFfloat, 2) TESTING("data transform, polynomial transform w/ copied property") - if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id_polynomial_copy, polyintread) < 0) + if (H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial_copy, polyintread) < 0) TEST_ERROR COMPARE(int, polyintread, polyflres, 2) @@ -687,28 +754,26 @@ static int test_trivial(const hid_t dxpl_id_simple) { float windchillFfloatread[ROWS][COLS]; - int windchillFintread[ROWS][COLS]; - int row, col; + int windchillFintread[ROWS][COLS]; + int row, col; TESTING("data transform, trivial transform, without type conversion") - if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, - dxpl_id_simple, windchillFfloatread) < 0) + if (H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFfloatread) < 0) TEST_ERROR - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) { - if((windchillFfloatread[row][col] - 4.8f) > FLOAT_TOL) + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) { + if ((windchillFfloatread[row][col] - 4.8f) > FLOAT_TOL) FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n"); } PASSED(); TESTING("data transform, trivial transform, with type conversion") - if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - dxpl_id_simple, windchillFintread) < 0) + if (H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFintread) < 0) TEST_ERROR - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) { - if(windchillFintread[row][col] != 4) + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) { + if (windchillFintread[row][col] != 4) FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n") } @@ -725,18 +790,18 @@ test_getset(const hid_t dxpl_id_c_to_f) int row; int col; float windchillFfloatread[ROWS][COLS]; - const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ - const char *c_to_f = "(9/5.0)*x + 32"; - char *ptrgetTest = NULL; + const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ + const char *c_to_f = "(9/5.0)*x + 32"; + char * ptrgetTest = NULL; TESTING("H5Pget_data_transform") - if(NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(simple) + 1))) + if (NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(simple) + 1))) TEST_ERROR - if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f) + 1) < 0) + if (H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f) + 1) < 0) TEST_ERROR - if(HDstrcmp(c_to_f, ptrgetTest) != 0) + if (HDstrcmp(c_to_f, ptrgetTest) != 0) FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n") PASSED(); @@ -746,16 +811,15 @@ test_getset(const hid_t dxpl_id_c_to_f) TESTING("data transform, read after resetting of transform property") - if(H5Pset_data_transform(dxpl_id_c_to_f, simple) < 0) + if (H5Pset_data_transform(dxpl_id_c_to_f, simple) < 0) TEST_ERROR - if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, - dxpl_id_c_to_f, windchillFfloatread) < 0) + if (H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread) < 0) TEST_ERROR - for(row = 0; row < ROWS; row++) - for(col = 0; col < COLS; col++) { - if((windchillFfloatread[row][col] - 4.8f) > FLOAT_TOL) + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) { + if ((windchillFfloatread[row][col] - 4.8f) > FLOAT_TOL) FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n") } @@ -763,11 +827,11 @@ test_getset(const hid_t dxpl_id_c_to_f) TESTING("H5Pget_data_transform, after resetting transform property") - if(NULL == (ptrgetTest = (char *)HDcalloc((size_t)1, HDstrlen(simple) + 1))) + if (NULL == (ptrgetTest = (char *)HDcalloc((size_t)1, HDstrlen(simple) + 1))) TEST_ERROR - if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(simple) + 1) < 0) + if (H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(simple) + 1) < 0) TEST_ERROR - if(HDstrcmp(simple, ptrgetTest) != 0) + if (HDstrcmp(simple, ptrgetTest) != 0) FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n") PASSED(); @@ -778,7 +842,7 @@ test_getset(const hid_t dxpl_id_c_to_f) return 0; error: - if(ptrgetTest) + if (ptrgetTest) HDfree(ptrgetTest); return -1; @@ -787,17 +851,17 @@ error: static int test_set(void) { - hid_t dxpl_id = -1; + hid_t dxpl_id = -1; H5E_auto2_t func; - const char *str = "(9/5.0)*x + 32"; - char *ptrgetTest = NULL; + const char *str = "(9/5.0)*x + 32"; + char * ptrgetTest = NULL; TESTING("H5Pget_data_transform (get before set)") - if(NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(str) + 1))) + if (NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(str) + 1))) TEST_ERROR - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR /* Test get before set */ @@ -805,7 +869,7 @@ test_set(void) H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - if(H5Pget_data_transform(dxpl_id, ptrgetTest, HDstrlen(str) + 1) < 0) + if (H5Pget_data_transform(dxpl_id, ptrgetTest, HDstrlen(str) + 1) < 0) PASSED(); else FAIL_PUTS_ERROR(" ERROR: Data transform get before set succeeded (it shouldn't have)\n"); @@ -842,18 +906,19 @@ test_set(void) H5Eset_auto2(H5E_DEFAULT, func, NULL); - if(H5Pclose(dxpl_id) < 0) + if (H5Pclose(dxpl_id) < 0) TEST_ERROR return 0; error: - if(ptrgetTest) + if (ptrgetTest) HDfree(ptrgetTest); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dxpl_id); - } H5E_END_TRY + } + H5E_END_TRY return -1; } - diff --git a/test/dtypes.c b/test/dtypes.c index 6dfc47d..cbbd1e5 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -20,19 +20,19 @@ #include "testhdf5.h" #include "H5srcdir.h" -#include "H5Iprivate.h" /* For checking that datatype id's don't leak */ +#include "H5Iprivate.h" /* For checking that datatype id's don't leak */ /* Number of elements in each test */ -#define NTESTELEM 100000 +#define NTESTELEM 100000 /* For test_compound_8 and test_compound_10 */ -#define ARRAY_DIM 4 +#define ARRAY_DIM 4 /* * Offset from alinged memory returned by malloc(). This can be used to test * that type conversions handle non-aligned buffers correctly. */ -#define ALIGNMENT 1 +#define ALIGNMENT 1 /* * Define if you want to test alignment code on a machine that doesn't @@ -43,103 +43,93 @@ /* Alignment test stuff */ #ifdef TEST_ALIGNMENT -#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#define H5T_FRIEND /*suppress error about including H5Tpkg */ #include "H5Tpkg.h" #endif /* Use in version bound test */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ /* Use in version bound test */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5Opkg.h" /* Object headers */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Opkg.h" /* Object headers */ -#define SET_ALIGNMENT(TYPE,VAL) \ - H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) +#define SET_ALIGNMENT(TYPE, VAL) H5T_NATIVE_##TYPE##_ALIGN_g = MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) /* * Macro for checking that the correct number of datatype ids are present. Be * careful as the call to H5Tunregister removes *ALL* compound conversions from * the soft conversion list. One must call reset_hdf5() after this. */ -#define CHECK_NMEMBS(NMEMBS,SRC_ID,DST_ID) \ - if(H5Tunregister(H5T_PERS_SOFT, NULL, SRC_ID, DST_ID, NULL) < 0) \ - FAIL_STACK_ERROR \ - if(H5Tclose(SRC_ID) < 0 || ((SRC_ID) != (DST_ID) && H5Tclose(DST_ID) < 0)) \ - FAIL_STACK_ERROR \ - if((NMEMBS) != H5I_nmembers(H5I_DATATYPE)) { \ - H5_FAILED(); \ - HDprintf(" #dtype ids expected: %lld; found: %lld\n", \ - (long long)NMEMBS, (long long)H5I_nmembers(H5I_DATATYPE)); \ - goto error; \ - } - -const char *FILENAME[] = { - "dtypes0", - "dtypes1", - "dtypes2", - "dtypes3", - "dtypes4", - "dtypes5", - "dtypes6", - "dtypes7", - "dtypes8", - "dtypes9", - "dtypes10", - NULL -}; - -#define TESTFILE "bad_compound.h5" +#define CHECK_NMEMBS(NMEMBS, SRC_ID, DST_ID) \ + if (H5Tunregister(H5T_PERS_SOFT, NULL, SRC_ID, DST_ID, NULL) < 0) \ + FAIL_STACK_ERROR \ + if (H5Tclose(SRC_ID) < 0 || ((SRC_ID) != (DST_ID) && H5Tclose(DST_ID) < 0)) \ + FAIL_STACK_ERROR \ + if ((NMEMBS) != H5I_nmembers(H5I_DATATYPE)) { \ + H5_FAILED(); \ + HDprintf(" #dtype ids expected: %lld; found: %lld\n", (long long)NMEMBS, \ + (long long)H5I_nmembers(H5I_DATATYPE)); \ + goto error; \ + } + +const char *FILENAME[] = {"dtypes0", "dtypes1", "dtypes2", "dtypes3", "dtypes4", "dtypes5", + "dtypes6", "dtypes7", "dtypes8", "dtypes9", "dtypes10", NULL}; + +#define TESTFILE "bad_compound.h5" typedef struct complex_t { - double re; - double im; + double re; + double im; } complex_t; typedef enum dtype_t { - INT_SCHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, - INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, FLT_FLOAT, FLT_DOUBLE, - FLT_LDOUBLE, OTHER + INT_SCHAR, + INT_UCHAR, + INT_SHORT, + INT_USHORT, + INT_INT, + INT_UINT, + INT_LONG, + INT_ULONG, + INT_LLONG, + INT_ULLONG, + FLT_FLOAT, + FLT_DOUBLE, + FLT_LDOUBLE, + OTHER } dtype_t; /* This doesn't seem to be used anywhere... -BMR */ -typedef enum { - E1_RED, - E1_GREEN, - E1_BLUE, - E1_ORANGE, - E1_YELLOW -} color_t; +typedef enum { E1_RED, E1_GREEN, E1_BLUE, E1_ORANGE, E1_YELLOW } color_t; /* Constant for size of conversion buffer for int <-> float exception test */ -#define CONVERT_SIZE 4 +#define CONVERT_SIZE 4 /* Constants for compound_13 test */ -#define COMPOUND13_ARRAY_SIZE 256 -#define COMPOUND13_ATTR_NAME "attr" +#define COMPOUND13_ARRAY_SIZE 256 +#define COMPOUND13_ATTR_NAME "attr" /* Constants for delete_obj_named test */ -#define DEL_OBJ_NAMED_DATASET "/Dataset" -#define DEL_OBJ_NAMED_NAMED_DTYPE "/Dtype" -#define DEL_OBJ_NAMED_ATTRIBUTE "Attr" +#define DEL_OBJ_NAMED_DATASET "/Dataset" +#define DEL_OBJ_NAMED_NAMED_DTYPE "/Dtype" +#define DEL_OBJ_NAMED_ATTRIBUTE "Attr" /* Constant for testing conversion of UTF-8 characters */ -#define UTF8_DATASET "utf8" -#define UTF8_DATASET2 "2nd_utf8" -#define ASCII_DATASET "ascii" -#define ASCII_DATASET2 "2nd_ascii" +#define UTF8_DATASET "utf8" +#define UTF8_DATASET2 "2nd_utf8" +#define ASCII_DATASET "ascii" +#define ASCII_DATASET2 "2nd_ascii" /* Count opaque conversions */ static int num_opaque_conversions_g = 0; -static int opaque_check(int tag_it); -static herr_t convert_opaque(hid_t st, hid_t dt, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, - void *bkg, hid_t dset_xfer_plid); -static int opaque_long(void); -static int opaque_funcs(void); - +static int opaque_check(int tag_it); +static herr_t convert_opaque(hid_t st, hid_t dt, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plid); +static int opaque_long(void); +static int opaque_funcs(void); /*------------------------------------------------------------------------- * Function: reset_hdf5 @@ -158,26 +148,24 @@ reset_hdf5(void) { h5_reset(); #ifdef TEST_ALIGNMENT - SET_ALIGNMENT(SCHAR, H5_SIZEOF_CHAR); - SET_ALIGNMENT(UCHAR, H5_SIZEOF_CHAR); - SET_ALIGNMENT(SHORT, H5_SIZEOF_SHORT); - SET_ALIGNMENT(USHORT, H5_SIZEOF_SHORT); - SET_ALIGNMENT(INT, H5_SIZEOF_INT); - SET_ALIGNMENT(UINT, H5_SIZEOF_INT); - SET_ALIGNMENT(LONG, H5_SIZEOF_LONG); - SET_ALIGNMENT(ULONG, H5_SIZEOF_LONG); - SET_ALIGNMENT(LLONG, H5_SIZEOF_LONG_LONG); - SET_ALIGNMENT(ULLONG, H5_SIZEOF_LONG_LONG); - SET_ALIGNMENT(FLOAT, H5_SIZEOF_FLOAT); - SET_ALIGNMENT(DOUBLE, H5_SIZEOF_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE !=0 + SET_ALIGNMENT(SCHAR, H5_SIZEOF_CHAR); + SET_ALIGNMENT(UCHAR, H5_SIZEOF_CHAR); + SET_ALIGNMENT(SHORT, H5_SIZEOF_SHORT); + SET_ALIGNMENT(USHORT, H5_SIZEOF_SHORT); + SET_ALIGNMENT(INT, H5_SIZEOF_INT); + SET_ALIGNMENT(UINT, H5_SIZEOF_INT); + SET_ALIGNMENT(LONG, H5_SIZEOF_LONG); + SET_ALIGNMENT(ULONG, H5_SIZEOF_LONG); + SET_ALIGNMENT(LLONG, H5_SIZEOF_LONG_LONG); + SET_ALIGNMENT(ULLONG, H5_SIZEOF_LONG_LONG); + SET_ALIGNMENT(FLOAT, H5_SIZEOF_FLOAT); + SET_ALIGNMENT(DOUBLE, H5_SIZEOF_DOUBLE); +#if H5_SIZEOF_LONG_DOUBLE != 0 SET_ALIGNMENT(LDOUBLE, H5_SIZEOF_LONG_DOUBLE); #endif #endif - } - /*------------------------------------------------------------------------- * Function: test_classes * @@ -193,88 +181,111 @@ reset_hdf5(void) static int test_classes(void) { - struct complex { /* Struct with complex fields */ + struct complex { /* Struct with complex fields */ hvl_t vl_c; hvl_t vl_s; }; - hid_t cmpd_id; /* Compound datatype */ - hid_t vlc_id; /* VL type of char */ - hid_t vls_id; /* VL string */ - hid_t memb_id; /* Compound member datatype */ - H5T_class_t memb_cls; - H5T_class_t tcls; - int nmembs; - unsigned u; + hid_t cmpd_id; /* Compound datatype */ + hid_t vlc_id; /* VL type of char */ + hid_t vls_id; /* VL string */ + hid_t memb_id; /* Compound member datatype */ + H5T_class_t memb_cls; + H5T_class_t tcls; + int nmembs; + unsigned u; TESTING("H5Tget_class()"); /*------------------------------------------------------------- * Check class of some atomic types. *-----------------------------------------------------------*/ - if((tcls = H5Tget_class(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5T_INTEGER != tcls) TEST_ERROR + if ((tcls = H5Tget_class(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5T_INTEGER != tcls) + TEST_ERROR - if((tcls = H5Tget_class(H5T_NATIVE_DOUBLE)) < 0) TEST_ERROR - if(H5T_FLOAT != tcls) TEST_ERROR + if ((tcls = H5Tget_class(H5T_NATIVE_DOUBLE)) < 0) + TEST_ERROR + if (H5T_FLOAT != tcls) + TEST_ERROR /* Create a VL datatype of char. It should be a VL, not a string class. */ - if((vlc_id = H5Tvlen_create(H5T_NATIVE_CHAR)) < 0) TEST_ERROR + if ((vlc_id = H5Tvlen_create(H5T_NATIVE_CHAR)) < 0) + TEST_ERROR /* Make certain that the correct classes can be detected */ - if((tcls = H5Tget_class(vlc_id)) < 0) TEST_ERROR - if(H5T_VLEN != tcls) TEST_ERROR + if ((tcls = H5Tget_class(vlc_id)) < 0) + TEST_ERROR + if (H5T_VLEN != tcls) + TEST_ERROR /* Make certain that an incorrect class is not detected */ - if(H5T_STRING == tcls) TEST_ERROR + if (H5T_STRING == tcls) + TEST_ERROR /* Create a VL string. It should be a string, not a VL class. */ - if((vls_id = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR - if(H5Tset_size(vls_id, H5T_VARIABLE) < 0) TEST_ERROR; + if ((vls_id = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR + if (H5Tset_size(vls_id, H5T_VARIABLE) < 0) + TEST_ERROR; /* Make certain that the correct classes can be detected */ - if((tcls = H5Tget_class(vls_id)) < 0) TEST_ERROR - if(H5T_STRING != tcls) TEST_ERROR + if ((tcls = H5Tget_class(vls_id)) < 0) + TEST_ERROR + if (H5T_STRING != tcls) + TEST_ERROR /* Make certain that an incorrect class is not detected */ - if(H5T_VLEN == tcls) TEST_ERROR + if (H5T_VLEN == tcls) + TEST_ERROR /*------------------------------------------------------------- * Check class for member types of compound type. *-----------------------------------------------------------*/ /* Create a compound datatype and insert some complex types */ - if((cmpd_id = H5Tcreate(H5T_COMPOUND, sizeof(struct complex))) < 0) TEST_ERROR - if(H5Tinsert(cmpd_id, "vl_c", HOFFSET(struct complex, vl_c), vlc_id) < 0) TEST_ERROR - if(H5Tinsert(cmpd_id, "vl_s", HOFFSET(struct complex, vl_s), vls_id) < 0) TEST_ERROR + if ((cmpd_id = H5Tcreate(H5T_COMPOUND, sizeof(struct complex))) < 0) + TEST_ERROR + if (H5Tinsert(cmpd_id, "vl_c", HOFFSET(struct complex, vl_c), vlc_id) < 0) + TEST_ERROR + if (H5Tinsert(cmpd_id, "vl_s", HOFFSET(struct complex, vl_s), vls_id) < 0) + TEST_ERROR - if((nmembs = H5Tget_nmembers(cmpd_id)) < 0) TEST_ERROR + if ((nmembs = H5Tget_nmembers(cmpd_id)) < 0) + TEST_ERROR - for(u = 0; u < (unsigned)nmembs; u++) { + for (u = 0; u < (unsigned)nmembs; u++) { /* Get member type ID */ - if((memb_id = H5Tget_member_type(cmpd_id, u)) < 0) TEST_ERROR + if ((memb_id = H5Tget_member_type(cmpd_id, u)) < 0) + TEST_ERROR /* Get member type class */ - if((memb_cls = H5Tget_member_class (cmpd_id, u)) < 0) TEST_ERROR + if ((memb_cls = H5Tget_member_class(cmpd_id, u)) < 0) + TEST_ERROR /* Verify member class */ - if(H5Tdetect_class(memb_id, memb_cls) < 0) TEST_ERROR + if (H5Tdetect_class(memb_id, memb_cls) < 0) + TEST_ERROR /* Close member type ID */ - if(H5Tclose(memb_id) < 0) TEST_ERROR + if (H5Tclose(memb_id) < 0) + TEST_ERROR } /* end for */ /* Close datatypes */ - if(H5Tclose(cmpd_id) < 0) TEST_ERROR - if(H5Tclose(vlc_id) < 0) TEST_ERROR - if(H5Tclose(vls_id) < 0) TEST_ERROR + if (H5Tclose(cmpd_id) < 0) + TEST_ERROR + if (H5Tclose(vlc_id) < 0) + TEST_ERROR + if (H5Tclose(vls_id) < 0) + TEST_ERROR PASSED(); return 0; - error: +error: return 1; } - /*------------------------------------------------------------------------- * Function: test_copy * @@ -290,32 +301,35 @@ test_classes(void) static int test_copy(void) { - hid_t a_copy; - herr_t status; + hid_t a_copy; + herr_t status; TESTING("H5Tcopy()"); - if ((a_copy = H5Tcopy(H5T_NATIVE_SHORT)) < 0) goto error; - if (H5Tclose(a_copy) < 0) goto error; + if ((a_copy = H5Tcopy(H5T_NATIVE_SHORT)) < 0) + goto error; + if (H5Tclose(a_copy) < 0) + goto error; /* We should not be able to close a built-in byte */ - H5E_BEGIN_TRY { - status = H5Tclose (H5T_NATIVE_SCHAR); - } H5E_END_TRY; - if (status>=0) { + H5E_BEGIN_TRY + { + status = H5Tclose(H5T_NATIVE_SCHAR); + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); - HDputs (" Should not be able to close a predefined type!"); + HDputs(" Should not be able to close a predefined type!"); goto error; } PASSED(); return 0; - error: +error: return 1; } - /*------------------------------------------------------------------------- * Function: test_detect * @@ -338,29 +352,29 @@ test_copy(void) static int test_detect(void) { - struct atomic { /* Struct with atomic fields */ - int i; - float f; - char c; + struct atomic { /* Struct with atomic fields */ + int i; + float f; + char c; double d; - short s; + short s; }; - struct complex { /* Struct with complex fields */ + struct complex { /* Struct with complex fields */ hobj_ref_t arr_r[3][3]; - int i; - hvl_t vl_f; - hvl_t vl_s; - char c; - short s; + int i; + hvl_t vl_f; + hvl_t vl_s; + char c; + short s; }; - hid_t atom_cmpd_id; /* Atomic Compound datatype */ - hid_t atom_arr_id; /* Atomic Array datatype */ - hid_t atom_vlf_id; /* Atomic VL datatype of float */ - hid_t atom_vlc_id; /* Atomic VL datatype of char */ - hid_t atom_vls_id; /* Atomic VL string datatype */ - hid_t cplx_cmpd_id; /* Complex Compound datatype */ - unsigned rank = 2; /* Rank for array datatype */ - hsize_t dims[2] = {3,3}; /* Dimensions for array datatype */ + hid_t atom_cmpd_id; /* Atomic Compound datatype */ + hid_t atom_arr_id; /* Atomic Array datatype */ + hid_t atom_vlf_id; /* Atomic VL datatype of float */ + hid_t atom_vlc_id; /* Atomic VL datatype of char */ + hid_t atom_vls_id; /* Atomic VL string datatype */ + hid_t cplx_cmpd_id; /* Complex Compound datatype */ + unsigned rank = 2; /* Rank for array datatype */ + hsize_t dims[2] = {3, 3}; /* Dimensions for array datatype */ TESTING("H5Tdetect_class()"); @@ -368,121 +382,176 @@ test_detect(void) * Test class of some atomic types. *------------------------------------------------------------------------------*/ /* Native integers should be in the integer class */ - if(H5Tdetect_class(H5T_NATIVE_INT,H5T_INTEGER)!=TRUE) TEST_ERROR + if (H5Tdetect_class(H5T_NATIVE_INT, H5T_INTEGER) != TRUE) + TEST_ERROR /* Native integers should _not_ be in other classes */ - if(H5Tdetect_class(H5T_NATIVE_INT,H5T_FLOAT)!=FALSE) TEST_ERROR - if(H5Tdetect_class(H5T_NATIVE_INT,H5T_ARRAY)!=FALSE) TEST_ERROR - if(H5Tdetect_class(H5T_NATIVE_INT,H5T_ENUM)!=FALSE) TEST_ERROR + if (H5Tdetect_class(H5T_NATIVE_INT, H5T_FLOAT) != FALSE) + TEST_ERROR + if (H5Tdetect_class(H5T_NATIVE_INT, H5T_ARRAY) != FALSE) + TEST_ERROR + if (H5Tdetect_class(H5T_NATIVE_INT, H5T_ENUM) != FALSE) + TEST_ERROR /*-------------------------------------------------------------------------------- * Test class of a compound type with some atomic types as fields. *------------------------------------------------------------------------------*/ /* Create a compound datatype and insert some atomic types */ - if ((atom_cmpd_id = H5Tcreate(H5T_COMPOUND, sizeof(struct atomic))) < 0) TEST_ERROR - if (H5Tinsert(atom_cmpd_id, "i", HOFFSET(struct atomic, i), H5T_NATIVE_INT) < 0) TEST_ERROR - if (H5Tinsert(atom_cmpd_id, "f", HOFFSET(struct atomic, f), H5T_NATIVE_FLOAT) < 0) TEST_ERROR - if (H5Tinsert(atom_cmpd_id, "c", HOFFSET(struct atomic, c), H5T_NATIVE_CHAR) < 0) TEST_ERROR - if (H5Tinsert(atom_cmpd_id, "d", HOFFSET(struct atomic, d), H5T_NATIVE_DOUBLE) < 0) TEST_ERROR - if (H5Tinsert(atom_cmpd_id, "s", HOFFSET(struct atomic, s), H5T_NATIVE_SHORT) < 0) TEST_ERROR + if ((atom_cmpd_id = H5Tcreate(H5T_COMPOUND, sizeof(struct atomic))) < 0) + TEST_ERROR + if (H5Tinsert(atom_cmpd_id, "i", HOFFSET(struct atomic, i), H5T_NATIVE_INT) < 0) + TEST_ERROR + if (H5Tinsert(atom_cmpd_id, "f", HOFFSET(struct atomic, f), H5T_NATIVE_FLOAT) < 0) + TEST_ERROR + if (H5Tinsert(atom_cmpd_id, "c", HOFFSET(struct atomic, c), H5T_NATIVE_CHAR) < 0) + TEST_ERROR + if (H5Tinsert(atom_cmpd_id, "d", HOFFSET(struct atomic, d), H5T_NATIVE_DOUBLE) < 0) + TEST_ERROR + if (H5Tinsert(atom_cmpd_id, "s", HOFFSET(struct atomic, s), H5T_NATIVE_SHORT) < 0) + TEST_ERROR /* Make certain that the correct classes can be detected */ - if(H5Tdetect_class(atom_cmpd_id,H5T_COMPOUND)!=TRUE) TEST_ERROR - if(H5Tdetect_class(atom_cmpd_id,H5T_INTEGER)!=TRUE) TEST_ERROR - if(H5Tdetect_class(atom_cmpd_id,H5T_FLOAT)!=TRUE) TEST_ERROR + if (H5Tdetect_class(atom_cmpd_id, H5T_COMPOUND) != TRUE) + TEST_ERROR + if (H5Tdetect_class(atom_cmpd_id, H5T_INTEGER) != TRUE) + TEST_ERROR + if (H5Tdetect_class(atom_cmpd_id, H5T_FLOAT) != TRUE) + TEST_ERROR /* Make certain that an incorrect class is not detected */ - if(H5Tdetect_class(atom_cmpd_id,H5T_VLEN)!=FALSE) TEST_ERROR + if (H5Tdetect_class(atom_cmpd_id, H5T_VLEN) != FALSE) + TEST_ERROR /*-------------------------------------------------------------------------------- * Test class of some complex types. *------------------------------------------------------------------------------*/ /* Create an array datatype with an atomic base type */ - if((atom_arr_id = H5Tarray_create2(H5T_STD_REF_OBJ, rank, dims)) < 0) TEST_ERROR + if ((atom_arr_id = H5Tarray_create2(H5T_STD_REF_OBJ, rank, dims)) < 0) + TEST_ERROR /* Make certain that the correct classes can be detected */ - if(H5Tdetect_class(atom_arr_id,H5T_ARRAY)!=TRUE) TEST_ERROR - if(H5Tdetect_class(atom_arr_id,H5T_REFERENCE)!=TRUE) TEST_ERROR + if (H5Tdetect_class(atom_arr_id, H5T_ARRAY) != TRUE) + TEST_ERROR + if (H5Tdetect_class(atom_arr_id, H5T_REFERENCE) != TRUE) + TEST_ERROR /* Make certain that an incorrect class is not detected */ - if(H5Tdetect_class(atom_arr_id,H5T_VLEN)!=FALSE) TEST_ERROR - if(H5Tdetect_class(atom_arr_id,H5T_FLOAT)!=FALSE) TEST_ERROR - if(H5Tdetect_class(atom_arr_id,H5T_INTEGER)!=FALSE) TEST_ERROR + if (H5Tdetect_class(atom_arr_id, H5T_VLEN) != FALSE) + TEST_ERROR + if (H5Tdetect_class(atom_arr_id, H5T_FLOAT) != FALSE) + TEST_ERROR + if (H5Tdetect_class(atom_arr_id, H5T_INTEGER) != FALSE) + TEST_ERROR /* Create a VL datatype with an atomic base type of float*/ - if((atom_vlf_id=H5Tvlen_create(H5T_NATIVE_FLOAT)) < 0) TEST_ERROR + if ((atom_vlf_id = H5Tvlen_create(H5T_NATIVE_FLOAT)) < 0) + TEST_ERROR /* Make certain that the correct classes can be detected */ - if(H5Tdetect_class(atom_vlf_id,H5T_VLEN)!=TRUE) TEST_ERROR - if(H5Tdetect_class(atom_vlf_id,H5T_FLOAT)!=TRUE) TEST_ERROR + if (H5Tdetect_class(atom_vlf_id, H5T_VLEN) != TRUE) + TEST_ERROR + if (H5Tdetect_class(atom_vlf_id, H5T_FLOAT) != TRUE) + TEST_ERROR /* Make certain that an incorrect class is not detected */ - if(H5Tdetect_class(atom_vlf_id,H5T_COMPOUND)!=FALSE) TEST_ERROR - if(H5Tdetect_class(atom_vlf_id,H5T_INTEGER)!=FALSE) TEST_ERROR + if (H5Tdetect_class(atom_vlf_id, H5T_COMPOUND) != FALSE) + TEST_ERROR + if (H5Tdetect_class(atom_vlf_id, H5T_INTEGER) != FALSE) + TEST_ERROR /* Create a VL datatype with an atomic base type of char. It should be a VL * but not a string class. */ - if((atom_vlc_id=H5Tvlen_create(H5T_NATIVE_CHAR)) < 0) TEST_ERROR + if ((atom_vlc_id = H5Tvlen_create(H5T_NATIVE_CHAR)) < 0) + TEST_ERROR /* Make certain that the correct classes can be detected */ - if(H5Tdetect_class(atom_vlc_id,H5T_VLEN)!=TRUE) TEST_ERROR - if(H5Tdetect_class(atom_vlc_id,H5T_INTEGER)!=TRUE) TEST_ERROR + if (H5Tdetect_class(atom_vlc_id, H5T_VLEN) != TRUE) + TEST_ERROR + if (H5Tdetect_class(atom_vlc_id, H5T_INTEGER) != TRUE) + TEST_ERROR /* Make certain that an incorrect class is not detected */ - if(H5Tdetect_class(atom_vlc_id,H5T_STRING)!=FALSE) TEST_ERROR + if (H5Tdetect_class(atom_vlc_id, H5T_STRING) != FALSE) + TEST_ERROR /* Create a VL string. It should be a string, not a VL class. */ - if((atom_vls_id=H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR - if(H5Tset_size(atom_vls_id, H5T_VARIABLE) < 0) TEST_ERROR; + if ((atom_vls_id = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR + if (H5Tset_size(atom_vls_id, H5T_VARIABLE) < 0) + TEST_ERROR; /* Make certain that the correct classes can be detected */ - if(H5Tdetect_class(atom_vls_id,H5T_STRING)!=TRUE) TEST_ERROR + if (H5Tdetect_class(atom_vls_id, H5T_STRING) != TRUE) + TEST_ERROR /* Make certain that an incorrect class is not detected */ - if(H5Tdetect_class(atom_vls_id,H5T_VLEN)!=FALSE) TEST_ERROR + if (H5Tdetect_class(atom_vls_id, H5T_VLEN) != FALSE) + TEST_ERROR /*-------------------------------------------------------------------------------- * Test class of a compound type with some complex types as fields. *------------------------------------------------------------------------------*/ /* Create a compound datatype and insert some complex types */ - if ((cplx_cmpd_id = H5Tcreate(H5T_COMPOUND, sizeof(struct complex))) < 0) TEST_ERROR - if (H5Tinsert(cplx_cmpd_id, "arr_r", HOFFSET(struct complex, arr_r), atom_arr_id) < 0) TEST_ERROR - if (H5Tinsert(cplx_cmpd_id, "i", HOFFSET(struct complex, i), H5T_NATIVE_INT) < 0) TEST_ERROR - if (H5Tinsert(cplx_cmpd_id, "vl_f", HOFFSET(struct complex, vl_f), atom_vlf_id) < 0) TEST_ERROR - if (H5Tinsert(cplx_cmpd_id, "vl_s", HOFFSET(struct complex, vl_s), atom_vls_id) < 0) TEST_ERROR - if (H5Tinsert(cplx_cmpd_id, "c", HOFFSET(struct complex, c), H5T_NATIVE_CHAR) < 0) TEST_ERROR - if (H5Tinsert(cplx_cmpd_id, "s", HOFFSET(struct complex, s), H5T_NATIVE_SHORT) < 0) TEST_ERROR + if ((cplx_cmpd_id = H5Tcreate(H5T_COMPOUND, sizeof(struct complex))) < 0) + TEST_ERROR + if (H5Tinsert(cplx_cmpd_id, "arr_r", HOFFSET(struct complex, arr_r), atom_arr_id) < 0) + TEST_ERROR + if (H5Tinsert(cplx_cmpd_id, "i", HOFFSET(struct complex, i), H5T_NATIVE_INT) < 0) + TEST_ERROR + if (H5Tinsert(cplx_cmpd_id, "vl_f", HOFFSET(struct complex, vl_f), atom_vlf_id) < 0) + TEST_ERROR + if (H5Tinsert(cplx_cmpd_id, "vl_s", HOFFSET(struct complex, vl_s), atom_vls_id) < 0) + TEST_ERROR + if (H5Tinsert(cplx_cmpd_id, "c", HOFFSET(struct complex, c), H5T_NATIVE_CHAR) < 0) + TEST_ERROR + if (H5Tinsert(cplx_cmpd_id, "s", HOFFSET(struct complex, s), H5T_NATIVE_SHORT) < 0) + TEST_ERROR /* Make certain that the correct classes can be detected */ - if(H5Tdetect_class(cplx_cmpd_id,H5T_COMPOUND)!=TRUE) TEST_ERROR - if(H5Tdetect_class(cplx_cmpd_id,H5T_ARRAY)!=TRUE) TEST_ERROR - if(H5Tdetect_class(cplx_cmpd_id,H5T_REFERENCE)!=TRUE) TEST_ERROR - if(H5Tdetect_class(cplx_cmpd_id,H5T_INTEGER)!=TRUE) TEST_ERROR - if(H5Tdetect_class(cplx_cmpd_id,H5T_FLOAT)!=TRUE) TEST_ERROR - if(H5Tdetect_class(cplx_cmpd_id,H5T_STRING)!=TRUE) TEST_ERROR - if(H5Tdetect_class(cplx_cmpd_id,H5T_VLEN)!=TRUE) TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_COMPOUND) != TRUE) + TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_ARRAY) != TRUE) + TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_REFERENCE) != TRUE) + TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_INTEGER) != TRUE) + TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_FLOAT) != TRUE) + TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_STRING) != TRUE) + TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_VLEN) != TRUE) + TEST_ERROR /* Make certain that an incorrect class is not detected */ - if(H5Tdetect_class(cplx_cmpd_id,H5T_TIME)!=FALSE) TEST_ERROR - if(H5Tdetect_class(cplx_cmpd_id,H5T_ENUM)!=FALSE) TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_TIME) != FALSE) + TEST_ERROR + if (H5Tdetect_class(cplx_cmpd_id, H5T_ENUM) != FALSE) + TEST_ERROR /* Close complex compound datatype */ - if(H5Tclose(cplx_cmpd_id) < 0) TEST_ERROR + if (H5Tclose(cplx_cmpd_id) < 0) + TEST_ERROR /* Close atomic VL datatype of float */ - if(H5Tclose(atom_vlf_id) < 0) TEST_ERROR + if (H5Tclose(atom_vlf_id) < 0) + TEST_ERROR /* Close atomic VL datatype of char */ - if(H5Tclose(atom_vlc_id) < 0) TEST_ERROR + if (H5Tclose(atom_vlc_id) < 0) + TEST_ERROR /* Close atomic VL string datatype */ - if(H5Tclose(atom_vls_id) < 0) TEST_ERROR + if (H5Tclose(atom_vls_id) < 0) + TEST_ERROR /* Close atomic array datatype */ - if(H5Tclose(atom_arr_id) < 0) TEST_ERROR + if (H5Tclose(atom_arr_id) < 0) + TEST_ERROR /* Close atomic compound datatype */ - if(H5Tclose(atom_cmpd_id) < 0) TEST_ERROR + if (H5Tclose(atom_cmpd_id) < 0) + TEST_ERROR PASSED(); return 0; @@ -491,7 +560,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_compound_1 * @@ -507,18 +575,18 @@ error: static int test_compound_1(void) { - hid_t complex_id; - hid_t super; - size_t size; - H5T_pad_t lsb, msb; - H5T_cset_t cset; - H5T_str_t strpad; - H5T_order_t order; - H5T_sign_t sign; - char *tag = NULL; - int offset; - herr_t ret; - int retval = 1; + hid_t complex_id; + hid_t super; + size_t size; + H5T_pad_t lsb, msb; + H5T_cset_t cset; + H5T_str_t strpad; + H5T_order_t order; + H5T_sign_t sign; + char * tag = NULL; + int offset; + herr_t ret; + int retval = 1; TESTING("compound datatypes"); @@ -527,131 +595,156 @@ test_compound_1(void) goto error; /* Try to shrink and expand the size */ - if(H5Tset_size(complex_id, sizeof(double)) < 0) + if (H5Tset_size(complex_id, sizeof(double)) < 0) goto error; - if(H5Tset_size(complex_id, sizeof(complex_t)) < 0) + if (H5Tset_size(complex_id, sizeof(complex_t)) < 0) goto error; /* Attempt to add the new compound datatype as a field within itself */ - H5E_BEGIN_TRY { - ret=H5Tinsert(complex_id, "compound", (size_t)0, complex_id); - } H5E_END_TRY; - if (ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tinsert(complex_id, "compound", (size_t)0, complex_id); + } + H5E_END_TRY; + if (ret >= 0) { FAIL_PUTS_ERROR("Inserted compound datatype into itself?"); } /* end if */ /* Add a couple fields */ - if(H5Tinsert(complex_id, "real", HOFFSET(complex_t, re), H5T_NATIVE_DOUBLE) < 0) + if (H5Tinsert(complex_id, "real", HOFFSET(complex_t, re), H5T_NATIVE_DOUBLE) < 0) goto error; - if(H5Tinsert(complex_id, "imaginary", HOFFSET(complex_t, im), H5T_NATIVE_DOUBLE) < 0) + if (H5Tinsert(complex_id, "imaginary", HOFFSET(complex_t, im), H5T_NATIVE_DOUBLE) < 0) goto error; /* Test some functions that aren't supposed to work for compound type */ /* Tries to shrink the size and trail the last member */ - H5E_BEGIN_TRY { - ret=H5Tset_size(complex_id, sizeof(double)); - } H5E_END_TRY; - if (ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tset_size(complex_id, sizeof(double)); + } + H5E_END_TRY; + if (ret >= 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { - size=H5Tget_precision(complex_id); - } H5E_END_TRY; - if (size>0) { + H5E_BEGIN_TRY + { + size = H5Tget_precision(complex_id); + } + H5E_END_TRY; + if (size > 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ size = 128; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tset_precision(complex_id, size); - } H5E_END_TRY; - if (ret>=0) { + } + H5E_END_TRY; + if (ret >= 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tget_pad(complex_id, &lsb, &msb); - } H5E_END_TRY; - if (ret>=0) { + } + H5E_END_TRY; + if (ret >= 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { size = H5Tget_ebias(complex_id); - } H5E_END_TRY; - if (size>0) { + } + H5E_END_TRY; + if (size > 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { lsb = H5Tget_inpad(complex_id); - } H5E_END_TRY; - if (lsb>=0) { + } + H5E_END_TRY; + if (lsb >= 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { cset = H5Tget_cset(complex_id); - } H5E_END_TRY; - if (cset>-1) { + } + H5E_END_TRY; + if (cset > -1) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { strpad = H5Tget_strpad(complex_id); - } H5E_END_TRY; - if (strpad>-1) { + } + H5E_END_TRY; + if (strpad > -1) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { offset = H5Tget_offset(complex_id); - } H5E_END_TRY; - if (offset>=0) { + } + H5E_END_TRY; + if (offset >= 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ /* We started to support this function for compound type in 1.8.6 release. */ - if((order = H5Tget_order(complex_id)) == H5T_ORDER_ERROR) + if ((order = H5Tget_order(complex_id)) == H5T_ORDER_ERROR) FAIL_PUTS_ERROR("Can't get order for compound type."); - if(order != H5T_ORDER_LE && order != H5T_ORDER_BE) + if (order != H5T_ORDER_LE && order != H5T_ORDER_BE) FAIL_PUTS_ERROR("Wrong order for this type."); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { sign = H5Tget_sign(complex_id); - } H5E_END_TRY; - if (sign>-1) { + } + H5E_END_TRY; + if (sign > -1) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tag = H5Tget_tag(complex_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (tag) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { super = H5Tget_super(complex_id); - } H5E_END_TRY; - if (super>=0) { + } + H5E_END_TRY; + if (super >= 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - if (H5Tclose (complex_id) < 0) + if (H5Tclose(complex_id) < 0) goto error; PASSED(); retval = 0; error: - if(tag) + if (tag) H5free_memory(tag); return retval; } - /*------------------------------------------------------------------------- * Function: test_compound_2 * @@ -671,18 +764,18 @@ test_compound_2(void) { struct st { int a, b, c[4], d, e; - } *s_ptr; + } * s_ptr; struct dt { int e, d, c[4], b, a; - } *d_ptr; + } * d_ptr; - const size_t nelmts = NTESTELEM; - const hsize_t four = 4; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; - hid_t st=-1, dt=-1; - hid_t array_dt; - int64_t nmembs; - int i; + const size_t nelmts = NTESTELEM; + const hsize_t four = 4; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + hid_t st = -1, dt = -1; + hid_t array_dt; + int64_t nmembs; + int i; TESTING("compound element reordering"); @@ -690,66 +783,60 @@ test_compound_2(void) FAIL_STACK_ERROR /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(struct dt)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(struct st)); - for (i=0; i<(int)nelmts; i++) { - s_ptr = ((struct st*)((void *)orig)) + i; - s_ptr->a = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; - } - HDmemcpy(buf, orig, nelmts*sizeof(struct st)); + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)); + for (i = 0; i < (int)nelmts; i++) { + s_ptr = ((struct st *)((void *)orig)) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; + } + HDmemcpy(buf, orig, nelmts * sizeof(struct st)); /* Build hdf5 datatypes */ - array_dt = H5Tarray_create2(H5T_NATIVE_INT,1, &four); - if((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || - H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || - H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT) < 0) + array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); + if ((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || + H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || + H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT) < 0) goto error; H5Tclose(array_dt); array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); - if((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || - H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || - H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT) < 0) + if ((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || + H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || + H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT) < 0) goto error; H5Tclose(array_dt); /* Perform the conversion */ - if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT) < 0) + goto error; /* Compare results */ - for (i=0; i<(int)nelmts; i++) { - s_ptr = ((struct st*)((void *)orig)) + i; - d_ptr = ((struct dt*)((void *)buf)) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) { + for (i = 0; i < (int)nelmts; i++) { + s_ptr = ((struct st *)((void *)orig)) + i; + d_ptr = ((struct dt *)((void *)buf)) + i; + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { H5_FAILED(); HDprintf(" i=%d\n", i); - HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", - s_ptr->a, s_ptr->b, s_ptr->c[0], s_ptr->c[1], s_ptr->c[2], - s_ptr->c[3], s_ptr->d, s_ptr->e); - HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", - d_ptr->a, d_ptr->b, d_ptr->c[0], d_ptr->c[1], d_ptr->c[2], - d_ptr->c[3], d_ptr->d, d_ptr->e); + HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", s_ptr->a, s_ptr->b, s_ptr->c[0], + s_ptr->c[1], s_ptr->c[2], s_ptr->c[3], s_ptr->d, s_ptr->e); + HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", d_ptr->a, d_ptr->b, d_ptr->c[0], + d_ptr->c[1], d_ptr->c[2], d_ptr->c[3], d_ptr->d, d_ptr->e); goto error; } } @@ -758,7 +845,7 @@ test_compound_2(void) HDfree(buf); HDfree(bkg); HDfree(orig); - CHECK_NMEMBS(nmembs , st, dt) + CHECK_NMEMBS(nmembs, st, dt) PASSED(); @@ -778,7 +865,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_compound_3 * @@ -798,16 +884,16 @@ test_compound_3(void) { struct st { int a, b, c[4], d, e; - } *s_ptr; - struct dt { - int a, c[4], e; - } *d_ptr; - - const size_t nelmts = NTESTELEM; - const hsize_t four = 4; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; - hid_t st=-1, dt=-1; - hid_t array_dt; + } * s_ptr; + struct dt { + int a, c[4], e; + } * d_ptr; + + const size_t nelmts = NTESTELEM; + const hsize_t four = 4; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + hid_t st = -1, dt = -1; + hid_t array_dt; int64_t nmembs; int i; @@ -817,38 +903,38 @@ test_compound_3(void) FAIL_STACK_ERROR /* Initialize */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(struct dt)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(struct st)); - for (i=0; i<(int)nelmts; i++) { - s_ptr = ((struct st*)((void *)orig)) + i; - s_ptr->a = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; - } - HDmemcpy(buf, orig, nelmts*sizeof(struct st)); + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)); + for (i = 0; i < (int)nelmts; i++) { + s_ptr = ((struct st *)((void *)orig)) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; + } + HDmemcpy(buf, orig, nelmts * sizeof(struct st)); /* Build hdf5 datatypes */ array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); - if((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || - H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || - H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT) < 0) + if ((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || + H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || + H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT) < 0) goto error; H5Tclose(array_dt); array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); - if((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || - H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || - H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT) < 0) + if ((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || + H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || + H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT) < 0) goto error; H5Tclose(array_dt); @@ -857,23 +943,17 @@ test_compound_3(void) goto error; /* Compare results */ - for (i=0; i<(int)nelmts; i++) { - s_ptr = ((struct st*)((void *)orig)) + i; - d_ptr = ((struct dt*)((void *)buf)) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->e != d_ptr->e) { + for (i = 0; i < (int)nelmts; i++) { + s_ptr = ((struct st *)((void *)orig)) + i; + d_ptr = ((struct dt *)((void *)buf)) + i; + if (s_ptr->a != d_ptr->a || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] || + s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->e != d_ptr->e) { H5_FAILED(); HDprintf(" i=%d\n", i); - HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", - s_ptr->a, s_ptr->b, s_ptr->c[0], s_ptr->c[1], s_ptr->c[2], - s_ptr->c[3], s_ptr->d, s_ptr->e); - HDprintf(" dst={a=%d, c=[%d,%d,%d,%d], e=%d\n", - d_ptr->a, d_ptr->c[0], d_ptr->c[1], d_ptr->c[2], - d_ptr->c[3], d_ptr->e); + HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", s_ptr->a, s_ptr->b, s_ptr->c[0], + s_ptr->c[1], s_ptr->c[2], s_ptr->c[3], s_ptr->d, s_ptr->e); + HDprintf(" dst={a=%d, c=[%d,%d,%d,%d], e=%d\n", d_ptr->a, d_ptr->c[0], d_ptr->c[1], + d_ptr->c[2], d_ptr->c[3], d_ptr->e); goto error; } } @@ -901,7 +981,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_compound_4 * @@ -922,19 +1001,19 @@ test_compound_4(void) struct st { int a, b, c[4], d, e; - } *s_ptr; + } * s_ptr; struct dt { short b; - int a, c[4]; + int a, c[4]; short d; - int e; - } *d_ptr; - - const size_t nelmts = NTESTELEM; - const hsize_t four = 4; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; - hid_t st=-1, dt=-1; - hid_t array_dt; + int e; + } * d_ptr; + + const size_t nelmts = NTESTELEM; + const hsize_t four = 4; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + hid_t st = -1, dt = -1; + hid_t array_dt; int64_t nmembs; int i; @@ -944,40 +1023,40 @@ test_compound_4(void) FAIL_STACK_ERROR /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(struct dt)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(struct st)); - for (i=0; i<(int)nelmts; i++) { - s_ptr = ((struct st*)((void *)orig)) + i; - s_ptr->a = i*8+0; - s_ptr->b = (i*8+1) & 0x7fff; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = (i*8+6) & 0x7fff; - s_ptr->e = i*8+7; - } - HDmemcpy(buf, orig, nelmts*sizeof(struct st)); + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)); + for (i = 0; i < (int)nelmts; i++) { + s_ptr = ((struct st *)((void *)orig)) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = (i * 8 + 1) & 0x7fff; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = (i * 8 + 6) & 0x7fff; + s_ptr->e = i * 8 + 7; + } + HDmemcpy(buf, orig, nelmts * sizeof(struct st)); /* Build hdf5 datatypes */ array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); - if((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || - H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || - H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT) < 0 || - H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT) < 0) + if ((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || + H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || + H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_INT) < 0 || + H5Tinsert(st, "e", HOFFSET(struct st, e), H5T_NATIVE_INT) < 0) goto error; H5Tclose(array_dt); array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); - if((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || - H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || - H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_SHORT) < 0 || - H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || - H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_SHORT) < 0 || - H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT) < 0) + if ((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || + H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || + H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_SHORT) < 0 || + H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || + H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_SHORT) < 0 || + H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT) < 0) goto error; H5Tclose(array_dt); @@ -986,25 +1065,18 @@ test_compound_4(void) goto error; /* Compare results */ - for (i=0; i<(int)nelmts; i++) { - s_ptr = ((struct st*)((void *)orig)) + i; - d_ptr = ((struct dt*)((void *)buf)) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) { + for (i = 0; i < (int)nelmts; i++) { + s_ptr = ((struct st *)((void *)orig)) + i; + d_ptr = ((struct dt *)((void *)buf)) + i; + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { H5_FAILED(); HDprintf(" i=%d\n", i); - HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", - s_ptr->a, s_ptr->b, s_ptr->c[0], s_ptr->c[1], s_ptr->c[2], - s_ptr->c[3], s_ptr->d, s_ptr->e); - HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", - d_ptr->a, d_ptr->b, d_ptr->c[0], d_ptr->c[1], d_ptr->c[2], - d_ptr->c[3], d_ptr->d, d_ptr->e); + HDprintf(" src={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", s_ptr->a, s_ptr->b, s_ptr->c[0], + s_ptr->c[1], s_ptr->c[2], s_ptr->c[3], s_ptr->d, s_ptr->e); + HDprintf(" dst={a=%d, b=%d, c=[%d,%d,%d,%d], d=%d, e=%d\n", d_ptr->a, d_ptr->b, d_ptr->c[0], + d_ptr->c[1], d_ptr->c[2], d_ptr->c[3], d_ptr->d, d_ptr->e); goto error; } } @@ -1032,7 +1104,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_compound_5 * @@ -1052,38 +1123,37 @@ static int test_compound_5(void) { typedef struct { - char name[16]; - short tdim; - short coll_ids[4]; + char name[16]; + short tdim; + short coll_ids[4]; } src_type_t; typedef struct { - char name[16]; - short tdim; - int coll_ids[4]; + char name[16]; + short tdim; + int coll_ids[4]; } dst_type_t; - hsize_t dims[1] = {4}; - hid_t src_type, dst_type, short_array, int_array, string; - hid_t array_dt; - src_type_t src[2] = {{"one", 102, {104, 105, 106, 107}}, - {"two", 202, {204, 205, 206, 207}}}; + hsize_t dims[1] = {4}; + hid_t src_type, dst_type, short_array, int_array, string; + hid_t array_dt; + src_type_t src[2] = {{"one", 102, {104, 105, 106, 107}}, {"two", 202, {204, 205, 206, 207}}}; - dst_type_t *dst; - void *buf = HDcalloc((size_t)2, sizeof(dst_type_t)); - void *bkg = HDcalloc((size_t)2, sizeof(dst_type_t)); - int retval = 1; + dst_type_t *dst; + void * buf = HDcalloc((size_t)2, sizeof(dst_type_t)); + void * bkg = HDcalloc((size_t)2, sizeof(dst_type_t)); + int retval = 1; TESTING("optimized struct converter"); /* Build datatypes */ - short_array = H5Tcreate(H5T_COMPOUND, 4*sizeof(short)); - array_dt = H5Tarray_create2(H5T_NATIVE_SHORT, 1, dims); + short_array = H5Tcreate(H5T_COMPOUND, 4 * sizeof(short)); + array_dt = H5Tarray_create2(H5T_NATIVE_SHORT, 1, dims); H5Tinsert(short_array, "_", (size_t)0, array_dt); H5Tclose(array_dt); - int_array = H5Tcreate(H5T_COMPOUND, 4*sizeof(int)); - array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, dims); + int_array = H5Tcreate(H5T_COMPOUND, 4 * sizeof(int)); + array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, dims); H5Tinsert(int_array, "_", (size_t)0, array_dt); H5Tclose(array_dt); @@ -1091,19 +1161,19 @@ test_compound_5(void) H5Tset_size(string, (size_t)16); src_type = H5Tcreate(H5T_COMPOUND, sizeof(src_type_t)); - H5Tinsert(src_type, "name", HOFFSET(src_type_t, name), string ); - H5Tinsert(src_type, "tdim", HOFFSET(src_type_t, tdim), H5T_NATIVE_SHORT); - H5Tinsert(src_type, "coll_ids", HOFFSET(src_type_t, coll_ids), short_array ); + H5Tinsert(src_type, "name", HOFFSET(src_type_t, name), string); + H5Tinsert(src_type, "tdim", HOFFSET(src_type_t, tdim), H5T_NATIVE_SHORT); + H5Tinsert(src_type, "coll_ids", HOFFSET(src_type_t, coll_ids), short_array); dst_type = H5Tcreate(H5T_COMPOUND, sizeof(dst_type_t)); - H5Tinsert(dst_type, "name", HOFFSET(dst_type_t, name), string ); - H5Tinsert(dst_type, "tdim", HOFFSET(dst_type_t, tdim), H5T_NATIVE_SHORT); - H5Tinsert(dst_type, "coll_ids", HOFFSET(dst_type_t, coll_ids), int_array ); + H5Tinsert(dst_type, "name", HOFFSET(dst_type_t, name), string); + H5Tinsert(dst_type, "tdim", HOFFSET(dst_type_t, tdim), H5T_NATIVE_SHORT); + H5Tinsert(dst_type, "coll_ids", HOFFSET(dst_type_t, coll_ids), int_array); /* Convert data */ HDmemcpy(buf, src, sizeof(src)); H5Tconvert(src_type, dst_type, (size_t)2, buf, bkg, H5P_DEFAULT); - dst = (dst_type_t*)buf; + dst = (dst_type_t *)buf; /* Cleanup */ H5Tclose(src_type); @@ -1112,15 +1182,10 @@ test_compound_5(void) H5Tclose(short_array); H5Tclose(int_array); - - /* Check results */ - if (HDmemcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || - src[1].tdim!=dst[1].tdim || - src[1].coll_ids[0]!=dst[1].coll_ids[0] || - src[1].coll_ids[1]!=dst[1].coll_ids[1] || - src[1].coll_ids[2]!=dst[1].coll_ids[2] || - src[1].coll_ids[3]!=dst[1].coll_ids[3]) { + if (HDmemcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || src[1].tdim != dst[1].tdim || + src[1].coll_ids[0] != dst[1].coll_ids[0] || src[1].coll_ids[1] != dst[1].coll_ids[1] || + src[1].coll_ids[2] != dst[1].coll_ids[2] || src[1].coll_ids[3] != dst[1].coll_ids[3]) { H5_FAILED(); } else { @@ -1134,7 +1199,6 @@ test_compound_5(void) return retval; } - /*------------------------------------------------------------------------- * Function: test_compound_6 * @@ -1156,15 +1220,15 @@ test_compound_6(void) struct st { short b; short d; - } *s_ptr; + } * s_ptr; struct dt { long b; long d; - } *d_ptr; + } * d_ptr; - const size_t nelmts = NTESTELEM; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; - hid_t st=-1, dt=-1; + const size_t nelmts = NTESTELEM; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + hid_t st = -1, dt = -1; int64_t nmembs; int i; @@ -1174,27 +1238,27 @@ test_compound_6(void) FAIL_STACK_ERROR /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(struct dt)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(struct st)); - for (i=0; i<(int)nelmts; i++) { - s_ptr = ((struct st*)((void *)orig)) + i; - s_ptr->b = (int16_t)((i*8+1) & 0x7fff); - s_ptr->d = (int16_t)((i*8+6) & 0x7fff); + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st)); + for (i = 0; i < (int)nelmts; i++) { + s_ptr = ((struct st *)((void *)orig)) + i; + s_ptr->b = (int16_t)((i * 8 + 1) & 0x7fff); + s_ptr->d = (int16_t)((i * 8 + 6) & 0x7fff); } - HDmemcpy(buf, orig, nelmts*sizeof(struct st)); + HDmemcpy(buf, orig, nelmts * sizeof(struct st)); /* Build hdf5 datatypes */ - if ((st=H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || - H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_SHORT) < 0 || - H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_SHORT) < 0) { + if ((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || + H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_SHORT) < 0 || + H5Tinsert(st, "d", HOFFSET(struct st, d), H5T_NATIVE_SHORT) < 0) { H5_FAILED(); goto error; } - if ((dt=H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || - H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_LONG) < 0 || - H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_LONG) < 0) { + if ((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || + H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_LONG) < 0 || + H5Tinsert(dt, "d", HOFFSET(struct dt, d), H5T_NATIVE_LONG) < 0) { H5_FAILED(); goto error; } @@ -1206,17 +1270,14 @@ test_compound_6(void) } /* Compare results */ - for (i=0; i<(int)nelmts; i++) { - s_ptr = ((struct st*)((void *)orig)) + i; - d_ptr = ((struct dt*)((void *)buf)) + i; - if (s_ptr->b != d_ptr->b || - s_ptr->d != d_ptr->d) { + for (i = 0; i < (int)nelmts; i++) { + s_ptr = ((struct st *)((void *)orig)) + i; + d_ptr = ((struct dt *)((void *)buf)) + i; + if (s_ptr->b != d_ptr->b || s_ptr->d != d_ptr->d) { H5_FAILED(); HDprintf(" i=%d\n", i); - HDprintf(" src={b=%d, d=%d\n", - (int)s_ptr->b, (int)s_ptr->d); - HDprintf(" dst={b=%ld, d=%ld\n", - d_ptr->b, d_ptr->d); + HDprintf(" src={b=%d, d=%d\n", (int)s_ptr->b, (int)s_ptr->d); + HDprintf(" dst={b=%ld, d=%ld\n", d_ptr->b, d_ptr->d); goto error; } } @@ -1268,99 +1329,103 @@ static int test_compound_7(void) { struct s1 { - int a; + int a; float b; - long c; + long c; }; struct s2 { - int a; - float b; - long c; + int a; + float b; + long c; double d; }; - hid_t tid1,tid2; + hid_t tid1, tid2; herr_t ret; TESTING("compound element insertion"); - if((tid1= H5Tcreate( H5T_COMPOUND, sizeof(struct s1))) < 0) { + if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) { H5_FAILED(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(tid1,"a",HOFFSET(struct s1,a),H5T_NATIVE_INT) < 0) { + if (H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0) { H5_FAILED(); HDprintf("Can't insert field 'a'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1,"b",HOFFSET(struct s1,b),H5T_NATIVE_FLOAT) < 0) { + if (H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0) { H5_FAILED(); HDprintf("Can't insert field 'b'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1,"c",HOFFSET(struct s1,c),H5T_NATIVE_LONG) < 0) { + if (H5Tinsert(tid1, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0) { H5_FAILED(); HDprintf("Can't insert field 'c'\n"); goto error; } /* end if */ - if(H5Tget_size(tid1)!=sizeof(struct s1)) { + if (H5Tget_size(tid1) != sizeof(struct s1)) { H5_FAILED(); HDprintf("Incorrect size for struct 1\n"); goto error; } /* end if */ - if((tid2= H5Tcopy(tid1)) < 0) { + if ((tid2 = H5Tcopy(tid1)) < 0) { H5_FAILED(); HDprintf("Can't copy datatype\n"); goto error; } /* end if */ - if(H5Tget_size(tid2)==sizeof(struct s2)) { + if (H5Tget_size(tid2) == sizeof(struct s2)) { H5_FAILED(); HDprintf("Incorrect size for struct 2\n"); goto error; } /* end if */ /* Should not be able to insert field past end of compound datatype */ - H5E_BEGIN_TRY { - ret=H5Tinsert(tid2,"d",HOFFSET(struct s2,d),H5T_NATIVE_DOUBLE); - } H5E_END_TRY; - if(ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tinsert(tid2, "d", HOFFSET(struct s2, d), H5T_NATIVE_DOUBLE); + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf("Inserted field 'd'?\n"); goto error; } /* end if */ /* Should not be able to shrink size of compound datatype */ - H5E_BEGIN_TRY { - ret=H5Tset_size(tid2, sizeof(struct s1)/2); - } H5E_END_TRY; - if(ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tset_size(tid2, sizeof(struct s1) / 2); + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf("Shrunk compound type?\n"); goto error; } /* end if */ /* Increase compound type size and try inserting field again */ - if(H5Tset_size(tid2, sizeof(struct s2)) < 0) { + if (H5Tset_size(tid2, sizeof(struct s2)) < 0) { H5_FAILED(); HDprintf("Can't increase size for compound type\n"); goto error; } /* end if */ - if( H5Tinsert(tid2,"d",HOFFSET(struct s2,d),H5T_NATIVE_DOUBLE) < 0) { + if (H5Tinsert(tid2, "d", HOFFSET(struct s2, d), H5T_NATIVE_DOUBLE) < 0) { H5_FAILED(); HDprintf("Can't expand compound datatype\n"); goto error; } /* end if */ - if(H5Tget_size(tid2)!=sizeof(struct s2)) { + if (H5Tget_size(tid2) != sizeof(struct s2)) { H5_FAILED(); HDprintf("Incorrect size for struct 2\n"); goto error; @@ -1390,7 +1455,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_compound_8 * @@ -1414,18 +1478,18 @@ static int test_compound_8(void) { typedef struct s1 { - char a; - int b; + char a; + int b; } s1; typedef struct s2 { - char c; - s1 d; + char c; + s1 d; } s2; - hid_t tid1, tid1_copy, tid2, tid2_copy, tid3, arr_tid; - size_t tsize; + hid_t tid1, tid1_copy, tid2, tid2_copy, tid3, arr_tid; + size_t tsize; hsize_t dims[1] = {ARRAY_DIM}; - herr_t ret; + herr_t ret; TESTING("packing compound datatypes"); @@ -1433,60 +1497,69 @@ test_compound_8(void) * Test H5Tpack for compound type */ /* Create first compound datatype */ - if((tid1 = H5Tcreate( H5T_COMPOUND, sizeof(struct s1))) < 0) { - H5_FAILED(); AT(); + if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(tid1,"a",HOFFSET(struct s1,a),H5T_NATIVE_CHAR) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_CHAR) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'a'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1,"b",HOFFSET(struct s1,b),H5T_NATIVE_INT) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_INT) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'b'\n"); goto error; } /* end if */ /* Make a copy of the type for later use */ - if((tid1_copy = H5Tcopy(tid1)) < 0) { - H5_FAILED(); AT(); + if ((tid1_copy = H5Tcopy(tid1)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't copy type #1\n"); goto error; } /* end if */ /* Test H5Tpack for the first compound type */ - if(H5Tpack(tid1) < 0) { - H5_FAILED(); AT(); + if (H5Tpack(tid1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't pack the compound datatype\n"); goto error; } /* end if */ - if(H5Tlock(tid1) < 0) { - H5_FAILED(); AT(); + if (H5Tlock(tid1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't lock the compound datatype\n"); goto error; } /* end if */ /* If the type is already packed, packing a locked type is OK */ - if(H5Tpack(tid1) < 0) { - H5_FAILED(); AT(); + if (H5Tpack(tid1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't pack the compound datatype for second time\n"); goto error; } /* end if */ /* Verify the size of packed compound type */ - if((tsize = H5Tget_size(tid1)) == 0) { - H5_FAILED(); AT(); + if ((tsize = H5Tget_size(tid1)) == 0) { + H5_FAILED(); + AT(); HDprintf("Can't get size of the compound datatype\n"); goto error; } /* end if */ - if(tsize != (sizeof(char) + sizeof(int))) { - H5_FAILED(); AT(); + if (tsize != (sizeof(char) + sizeof(int))) { + H5_FAILED(); + AT(); HDprintf("The size of the packed compound datatype is incorrect\n"); goto error; } /* end if */ @@ -1495,85 +1568,99 @@ test_compound_8(void) * Test H5Tpack for nested compound type */ /* Create second compound datatype */ - if((tid2 = H5Tcreate( H5T_COMPOUND, sizeof(struct s2))) < 0) { - H5_FAILED(); AT(); + if ((tid2 = H5Tcreate(H5T_COMPOUND, sizeof(struct s2))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(tid2,"c",HOFFSET(struct s2,c),H5T_NATIVE_CHAR) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(tid2, "c", HOFFSET(struct s2, c), H5T_NATIVE_CHAR) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c'\n"); goto error; } /* end if */ /* Insert the member of unpacked compound type */ - if(H5Tinsert(tid2,"d",HOFFSET(struct s2,d),tid1_copy) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(tid2, "d", HOFFSET(struct s2, d), tid1_copy) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'd'\n"); goto error; } /* end if */ /* Make a copy of the type for later */ - if((tid3=H5Tcopy(tid2)) < 0) { - H5_FAILED(); AT(); + if ((tid3 = H5Tcopy(tid2)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't copy type #2\n"); goto error; } /* end if */ /* Make a copy of the type for later */ - if((tid2_copy = H5Tcopy(tid2)) < 0) { - H5_FAILED(); AT(); + if ((tid2_copy = H5Tcopy(tid2)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't copy type #2\n"); goto error; } /* end if */ /* Test H5Tpack for the second compound type */ - if(H5Tpack(tid2) < 0) { - H5_FAILED(); AT(); + if (H5Tpack(tid2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't pack the compound datatype\n"); goto error; } /* end if */ - if(H5Tlock(tid2) < 0) { - H5_FAILED(); AT(); + if (H5Tlock(tid2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't lock the compound datatype\n"); goto error; } /* end if */ /* If the type is already packed, packing a locked type is OK */ - if(H5Tpack(tid2) < 0) { - H5_FAILED(); AT(); + if (H5Tpack(tid2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't pack the compound datatype for second time\n"); goto error; } /* end if */ /* Lock unpacked type */ - if(H5Tlock(tid3) < 0) { - H5_FAILED(); AT(); + if (H5Tlock(tid3) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't lock the compound datatype\n"); goto error; } /* end if */ /* If the type is not packed, packing a locked type shouldn't work */ - H5E_BEGIN_TRY { - ret=H5Tpack(tid3); - } H5E_END_TRY; - if(ret>=0) { - H5_FAILED(); AT(); + H5E_BEGIN_TRY + { + ret = H5Tpack(tid3); + } + H5E_END_TRY; + if (ret >= 0) { + H5_FAILED(); + AT(); HDprintf("Packing locked datatype worked?\n"); goto error; } /* end if */ /* Verify the size of packed compound type */ - if((tsize = H5Tget_size(tid2)) == 0) { - H5_FAILED(); AT(); + if ((tsize = H5Tget_size(tid2)) == 0) { + H5_FAILED(); + AT(); HDprintf("Can't get size of the compound datatype\n"); goto error; } /* end if */ - if(tsize != (sizeof(char) + sizeof(char) + sizeof(int))) { - H5_FAILED(); AT(); + if (tsize != (sizeof(char) + sizeof(char) + sizeof(int))) { + H5_FAILED(); + AT(); HDprintf("The size of the packed compound datatype is incorrect: tsize = %zu\n", tsize); goto error; } /* end if */ @@ -1582,47 +1669,53 @@ test_compound_8(void) * Test H5Tpack for array type of nested compound type */ /* Create an array type of compound type */ - if((arr_tid = H5Tarray_create2(tid2_copy, 1, dims)) < 0) { - H5_FAILED(); AT(); + if ((arr_tid = H5Tarray_create2(tid2_copy, 1, dims)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create an array datatype\n"); goto error; } /* end if */ /* Test H5Tpack for the array type */ - if(H5Tpack(arr_tid) < 0) { - H5_FAILED(); AT(); + if (H5Tpack(arr_tid) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't pack the array datatype\n"); goto error; } /* end if */ /* Verify the size of packed compound type */ - if((tsize = H5Tget_size(arr_tid)) == 0) { - H5_FAILED(); AT(); + if ((tsize = H5Tget_size(arr_tid)) == 0) { + H5_FAILED(); + AT(); HDprintf("Can't get size of the array datatype\n"); goto error; } /* end if */ - if(tsize != ARRAY_DIM * (sizeof(char) + sizeof(char) + sizeof(int))) { - H5_FAILED(); AT(); + if (tsize != ARRAY_DIM * (sizeof(char) + sizeof(char) + sizeof(int))) { + H5_FAILED(); + AT(); HDprintf("The size of the packed array datatype is incorrect\n"); goto error; } /* end if */ - - if(H5Tclose(tid1_copy) < 0) { - H5_FAILED(); AT(); + if (H5Tclose(tid1_copy) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't close the compound datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid2_copy) < 0) { - H5_FAILED(); AT(); + if (H5Tclose(tid2_copy) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't close the compound datatype\n"); goto error; } /* end if */ - if(H5Tclose(arr_tid) < 0) { - H5_FAILED(); AT(); + if (H5Tclose(arr_tid) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't close the array datatype\n"); goto error; } /* end if */ @@ -1632,11 +1725,10 @@ test_compound_8(void) PASSED(); return 0; - error: +error: return 1; } - /*------------------------------------------------------------------------- * Function: test_compound_9 * @@ -1654,214 +1746,238 @@ static int test_compound_9(void) { typedef struct cmpd_struct_w { - int i1; - const char* str; - int i2; + int i1; + const char *str; + int i2; } cmpd_struct_w; typedef struct cmpd_struct_r { - int i1; - char* str; - int i2; + int i1; + char *str; + int i2; } cmpd_struct_r; cmpd_struct_w wdata = {11, "variable-length string", 22}; cmpd_struct_r rdata; - hid_t file; - hid_t cmpd_tid, str_id, dup_tid; - hid_t space_id; - hid_t dset_id; - hsize_t dim1[1]; - char filename[1024]; + hid_t file; + hid_t cmpd_tid, str_id, dup_tid; + hid_t space_id; + hid_t dset_id; + hsize_t dim1[1]; + char filename[1024]; TESTING("compound datatype with VL string"); /* Create File */ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create file!\n"); goto error; } /* end if */ /* Create first compound datatype */ - if((cmpd_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct_w))) < 0) { - H5_FAILED(); AT(); + if ((cmpd_tid = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd_struct_w))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_tid, "i1", HOFFSET(struct cmpd_struct_w, i1), H5T_NATIVE_INT) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_tid, "i1", HOFFSET(struct cmpd_struct_w, i1), H5T_NATIVE_INT) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'i1'\n"); goto error; } /* end if */ str_id = H5Tcopy(H5T_C_S1); - if(H5Tset_size(str_id,H5T_VARIABLE) < 0) { - H5_FAILED(); AT(); + if (H5Tset_size(str_id, H5T_VARIABLE) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't set size for VL string\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_tid, "vl_string", HOFFSET(cmpd_struct_w, str), str_id) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_tid, "vl_string", HOFFSET(cmpd_struct_w, str), str_id) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'i1'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_tid, "i2", HOFFSET(struct cmpd_struct_w, i2), H5T_NATIVE_INT) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_tid, "i2", HOFFSET(struct cmpd_struct_w, i2), H5T_NATIVE_INT) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'i2'\n"); goto error; } /* end if */ - if(H5Tcommit2(file, "compound", cmpd_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { - H5_FAILED(); AT(); + if (H5Tcommit2(file, "compound", cmpd_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't commit datatype\n"); goto error; } /* end if */ - if(H5Tclose(cmpd_tid) < 0) { - H5_FAILED(); AT(); + if (H5Tclose(cmpd_tid) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if((cmpd_tid = H5Topen2(file, "compound", H5P_DEFAULT)) < 0) + if ((cmpd_tid = H5Topen2(file, "compound", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((dup_tid = H5Tcopy(cmpd_tid)) < 0) { - H5_FAILED(); AT(); + if ((dup_tid = H5Tcopy(cmpd_tid)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't copy datatype\n"); goto error; } /* end if */ dim1[0] = 1; - if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) { - H5_FAILED(); AT(); + if ((space_id = H5Screate_simple(1, dim1, NULL)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create space\n"); goto error; } /* end if */ - if((dset_id = H5Dcreate2(file, "Dataset", dup_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((dset_id = H5Dcreate2(file, "Dataset", dup_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) { + H5_FAILED(); + AT(); HDprintf("Can't create dataset\n"); goto error; } /* end if */ - if(H5Dwrite(dset_id, dup_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) { - H5_FAILED(); AT(); + if (H5Dwrite(dset_id, dup_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't write data\n"); goto error; } /* end if */ - if(H5Dread(dset_id, dup_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { - H5_FAILED(); AT(); + if (H5Dread(dset_id, dup_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ - if(rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) { - H5_FAILED(); AT(); + if (rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) { + H5_FAILED(); + AT(); HDprintf("incorrect read data\n"); goto error; } /* end if */ - if(H5Treclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { - H5_FAILED(); AT(); + if (H5Treclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't reclaim read data\n"); goto error; } /* end if */ rdata.str = NULL; - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) goto error; - if(H5Tclose(cmpd_tid) < 0) + if (H5Tclose(cmpd_tid) < 0) goto error; - if(H5Tclose(dup_tid) < 0) + if (H5Tclose(dup_tid) < 0) goto error; - if(H5Tclose(str_id) < 0) + if (H5Tclose(str_id) < 0) goto error; - if(H5Sclose(space_id) < 0) + if (H5Sclose(space_id) < 0) goto error; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; - - if((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("cannot open file\n"); goto error; } /* end if */ - if((dset_id = H5Dopen2(file, "Dataset", H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((dset_id = H5Dopen2(file, "Dataset", H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("cannot open dataset\n"); goto error; } /* end if */ - if((space_id = H5Dget_space(dset_id)) < 0) { - H5_FAILED(); AT(); + if ((space_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't get space\n"); goto error; } /* end if */ - if((cmpd_tid = H5Dget_type(dset_id)) < 0) { - H5_FAILED(); AT(); + if ((cmpd_tid = H5Dget_type(dset_id)) < 0) { + H5_FAILED(); + AT(); HDprintf("cannot open dataset\n"); goto error; } /* end if */ - if((dup_tid = H5Tcopy(cmpd_tid)) < 0) { - H5_FAILED(); AT(); + if ((dup_tid = H5Tcopy(cmpd_tid)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't copy datatype\n"); goto error; } /* end if */ rdata.i1 = rdata.i2 = 0; - if(rdata.str) HDfree(rdata.str); + if (rdata.str) + HDfree(rdata.str); - if(H5Dread(dset_id, dup_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { - H5_FAILED(); AT(); + if (H5Dread(dset_id, dup_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ - if(rdata.i1!=wdata.i1 || rdata.i2!=wdata.i2 || strcmp(rdata.str, wdata.str)) { - H5_FAILED(); AT(); + if (rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || strcmp(rdata.str, wdata.str)) { + H5_FAILED(); + AT(); HDprintf("incorrect read data\n"); goto error; } /* end if */ - if(H5Treclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { - H5_FAILED(); AT(); + if (H5Treclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ rdata.str = NULL; - if(rdata.str) HDfree(rdata.str); + if (rdata.str) + HDfree(rdata.str); - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) goto error; - if(H5Sclose(space_id) < 0) + if (H5Sclose(space_id) < 0) goto error; - if(H5Tclose(cmpd_tid) < 0) + if (H5Tclose(cmpd_tid) < 0) goto error; - if(H5Tclose(dup_tid) < 0) + if (H5Tclose(dup_tid) < 0) goto error; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; PASSED(); return 0; - error: +error: return 1; } - /*------------------------------------------------------------------------- * Function: test_compound_10 * @@ -1882,10 +1998,10 @@ static int test_compound_10(void) { typedef struct cmpd_struct { - int i1; - char* str; - hvl_t text; - int i2; + int i1; + char *str; + hvl_t text; + int i2; } cmpd_struct; cmpd_struct wdata[ARRAY_DIM]; @@ -1894,168 +2010,186 @@ test_compound_10(void) hid_t arr_tid, cmpd_tid, cstr_id, vlstr_id; hid_t space_id; hid_t dset_id; - hsize_t arr_dim[1] = {ARRAY_DIM}; /* Array dimensions */ + hsize_t arr_dim[1] = {ARRAY_DIM}; /* Array dimensions */ hsize_t dim1[1]; - void *t1, *t2; + void * t1, *t2; char filename[1024]; size_t len; int i; TESTING("array datatype of compound type with VL string"); - for(i=0; i=0) { + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); puts(" Tries to cut off the last member. Should have failed."); goto error; } - if (H5Tclose (complex_id) < 0) goto error; + if (H5Tclose(complex_id) < 0) + goto error; PASSED(); return 0; - error: +error: return 1; } - /*------------------------------------------------------------------------- * Function: test_compound_13 * @@ -2403,78 +2590,110 @@ test_compound_13(void) { struct s1 { unsigned char x[COMPOUND13_ARRAY_SIZE + 1]; - float y; + float y; }; - struct s1 data_out, data_in; - hid_t fileid, grpid, dtypeid, array1_tid, spaceid, attid; - hid_t fapl_id; - hsize_t dims[1] = {COMPOUND13_ARRAY_SIZE + 1}; - char filename[1024]; - unsigned u; + struct s1 data_out, data_in; + hid_t fileid, grpid, dtypeid, array1_tid, spaceid, attid; + hid_t fapl_id; + hsize_t dims[1] = {COMPOUND13_ARRAY_SIZE + 1}; + char filename[1024]; + unsigned u; TESTING("compound datatypes of boundary size with latest format"); /* Create some phony data. */ HDmemset(&data_out, 0, sizeof(data_out)); - for(u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++) + for (u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++) data_out.x[u] = (unsigned char)u; data_out.y = 99.99f; /* Set latest_format in access propertly list to enable the latest * compound datatype format. */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR - if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR + if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR /* Open file and get root group. */ h5_fixname(FILENAME[4], H5P_DEFAULT, filename, sizeof filename); - if((fileid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) FAIL_STACK_ERROR - if((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fileid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + FAIL_STACK_ERROR + if ((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a compound type. */ - if((dtypeid = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) FAIL_STACK_ERROR - if((array1_tid = H5Tarray_create2(H5T_NATIVE_UCHAR, 1, dims)) < 0) FAIL_STACK_ERROR - if(H5Tinsert(dtypeid, "x", HOFFSET(struct s1, x), array1_tid) < 0) FAIL_STACK_ERROR - if(H5Tinsert(dtypeid, "y", HOFFSET(struct s1, y), H5T_NATIVE_FLOAT) < 0) FAIL_STACK_ERROR + if ((dtypeid = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) + FAIL_STACK_ERROR + if ((array1_tid = H5Tarray_create2(H5T_NATIVE_UCHAR, 1, dims)) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(dtypeid, "x", HOFFSET(struct s1, x), array1_tid) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(dtypeid, "y", HOFFSET(struct s1, y), H5T_NATIVE_FLOAT) < 0) + FAIL_STACK_ERROR /* Create a space. */ - if((spaceid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + if ((spaceid = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR /* Create an attribute of this compound type. */ - if((attid = H5Acreate2(grpid, COMPOUND13_ATTR_NAME, dtypeid, spaceid, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((attid = H5Acreate2(grpid, COMPOUND13_ATTR_NAME, dtypeid, spaceid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Write some data. */ - if(H5Awrite(attid, dtypeid, &data_out) < 0) FAIL_STACK_ERROR + if (H5Awrite(attid, dtypeid, &data_out) < 0) + FAIL_STACK_ERROR /* Release all resources. */ - if(H5Aclose(attid) < 0) FAIL_STACK_ERROR - if(H5Tclose(array1_tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(dtypeid) < 0) FAIL_STACK_ERROR - if(H5Sclose(spaceid) < 0) FAIL_STACK_ERROR - if(H5Gclose(grpid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileid) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl_id) < 0) FAIL_STACK_ERROR + if (H5Aclose(attid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(array1_tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(dtypeid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(spaceid) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grpid) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fileid) < 0) + FAIL_STACK_ERROR + if (H5Pclose(fapl_id) < 0) + FAIL_STACK_ERROR /* Now open the file and read it. */ - if((fileid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((attid = H5Aopen(grpid, COMPOUND13_ATTR_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((dtypeid = H5Aget_type(attid)) < 0) FAIL_STACK_ERROR - if(H5Tget_class(dtypeid) != H5T_COMPOUND) FAIL_STACK_ERROR - if(HOFFSET(struct s1, x) != H5Tget_member_offset(dtypeid, 0)) TEST_ERROR - if(HOFFSET(struct s1, y) != H5Tget_member_offset(dtypeid, 1)) TEST_ERROR - if(H5Aread(attid, dtypeid, &data_in) < 0) FAIL_STACK_ERROR + if ((fileid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((attid = H5Aopen(grpid, COMPOUND13_ATTR_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((dtypeid = H5Aget_type(attid)) < 0) + FAIL_STACK_ERROR + if (H5Tget_class(dtypeid) != H5T_COMPOUND) + FAIL_STACK_ERROR + if (HOFFSET(struct s1, x) != H5Tget_member_offset(dtypeid, 0)) + TEST_ERROR + if (HOFFSET(struct s1, y) != H5Tget_member_offset(dtypeid, 1)) + TEST_ERROR + if (H5Aread(attid, dtypeid, &data_in) < 0) + FAIL_STACK_ERROR /* Check the data. */ for (u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++) - if(data_out.x[u] != data_in.x[u]) TEST_ERROR - if(!H5_FLT_ABS_EQUAL(data_out.y, data_in.y)) TEST_ERROR + if (data_out.x[u] != data_in.x[u]) + TEST_ERROR + if (!H5_FLT_ABS_EQUAL(data_out.y, data_in.y)) + TEST_ERROR /* Release all resources. */ - if(H5Aclose(attid) < 0) FAIL_STACK_ERROR - if(H5Tclose(dtypeid) < 0) FAIL_STACK_ERROR - if(H5Gclose(grpid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileid) < 0) FAIL_STACK_ERROR + if (H5Aclose(attid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(dtypeid) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grpid) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fileid) < 0) + FAIL_STACK_ERROR PASSED(); return 0; @@ -2483,7 +2702,6 @@ error: return 1; } /* end test_compound_13() */ - /*------------------------------------------------------------------------- * Function: test_compound_14 * @@ -2507,390 +2725,440 @@ static int test_compound_14(void) { typedef struct cmpd_struct_1_w { - char c1; - char c2; - const char* str; + char c1; + char c2; + const char *str; } cmpd_struct_1_w; typedef struct cmpd_struct_1_r { - char c1; - char c2; - char* str; + char c1; + char c2; + char *str; } cmpd_struct_1_r; typedef struct cmpd_struct_2_w { - char c1; - char c2; - const char* str; - long l1; - long l2; - long l3; - long l4; + char c1; + char c2; + const char *str; + long l1; + long l2; + long l3; + long l4; } cmpd_struct_2_w; typedef struct cmpd_struct_2_r { - char c1; - char c2; - char* str; - long l1; - long l2; - long l3; - long l4; + char c1; + char c2; + char *str; + long l1; + long l2; + long l3; + long l4; } cmpd_struct_2_r; cmpd_struct_1_w wdata1 = {'A', 'B', "variable-length string"}; cmpd_struct_1_r rdata1; cmpd_struct_2_w wdata2 = {'C', 'D', "another vlen!", 1, 2, -1, 9001}; cmpd_struct_2_r rdata2; - hid_t file; - hid_t cmpd_m1_tid, cmpd_f1_tid, cmpd_m2_tid, cmpd_f2_tid, str_id; - hid_t space_id; - hid_t dset1_id, dset2_id; - hsize_t dim1[1]; - char filename[1024]; + hid_t file; + hid_t cmpd_m1_tid, cmpd_f1_tid, cmpd_m2_tid, cmpd_f2_tid, str_id; + hid_t space_id; + hid_t dset1_id, dset2_id; + hsize_t dim1[1]; + char filename[1024]; TESTING("unaligned VL strings in compound"); /* Create File */ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create file!\n"); goto error; } /* end if */ /* Create memory compound datatype 1 */ - if((cmpd_m1_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct_1_w))) < 0) { - H5_FAILED(); AT(); + if ((cmpd_m1_tid = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd_struct_1_w))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m1_tid,"c1",HOFFSET(struct cmpd_struct_1_w, c1), H5T_NATIVE_CHAR) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m1_tid, "c1", HOFFSET(struct cmpd_struct_1_w, c1), H5T_NATIVE_CHAR) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c1'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m1_tid,"c2",HOFFSET(struct cmpd_struct_1_w, c2), H5T_NATIVE_CHAR) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m1_tid, "c2", HOFFSET(struct cmpd_struct_1_w, c2), H5T_NATIVE_CHAR) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c2'\n"); goto error; } /* end if */ str_id = H5Tcopy(H5T_C_S1); - if(H5Tset_size(str_id,H5T_VARIABLE) < 0) { - H5_FAILED(); AT(); + if (H5Tset_size(str_id, H5T_VARIABLE) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't set size for VL string\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m1_tid, "vl_string", HOFFSET(cmpd_struct_1_w, str), str_id) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m1_tid, "vl_string", HOFFSET(cmpd_struct_1_w, str), str_id) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'vl_string'\n"); goto error; } /* end if */ /* Create file compound datatype 1 */ - if((cmpd_f1_tid = H5Tcreate( H5T_COMPOUND, 8 + 1 + sizeof(hvl_t))) < 0) { - H5_FAILED(); AT(); + if ((cmpd_f1_tid = H5Tcreate(H5T_COMPOUND, 8 + 1 + sizeof(hvl_t))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f1_tid,"c1",(size_t)0,H5T_STD_I64BE) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f1_tid, "c1", (size_t)0, H5T_STD_I64BE) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c1'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f1_tid,"c2",(size_t)8,H5T_NATIVE_CHAR) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f1_tid, "c2", (size_t)8, H5T_NATIVE_CHAR) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c2'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f1_tid, "vl_string",(size_t)(8 + 1), str_id) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f1_tid, "vl_string", (size_t)(8 + 1), str_id) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'vl_string'\n"); goto error; } /* end if */ /* Create memory compound datatype 2 */ - if((cmpd_m2_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct_2_w))) < 0) { - H5_FAILED(); AT(); + if ((cmpd_m2_tid = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd_struct_2_w))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m2_tid,"c1",HOFFSET(struct cmpd_struct_2_w, c1), H5T_NATIVE_CHAR) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m2_tid, "c1", HOFFSET(struct cmpd_struct_2_w, c1), H5T_NATIVE_CHAR) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c1'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m2_tid,"c2",HOFFSET(struct cmpd_struct_2_w, c2), H5T_NATIVE_CHAR) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m2_tid, "c2", HOFFSET(struct cmpd_struct_2_w, c2), H5T_NATIVE_CHAR) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c2'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m2_tid, "vl_string", HOFFSET(cmpd_struct_2_w, str), str_id) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m2_tid, "vl_string", HOFFSET(cmpd_struct_2_w, str), str_id) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'vl_string'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m2_tid,"l1",HOFFSET(struct cmpd_struct_2_w, l1), H5T_NATIVE_LONG) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m2_tid, "l1", HOFFSET(struct cmpd_struct_2_w, l1), H5T_NATIVE_LONG) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'l1'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m2_tid,"l2",HOFFSET(struct cmpd_struct_2_w, l2), H5T_NATIVE_LONG) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m2_tid, "l2", HOFFSET(struct cmpd_struct_2_w, l2), H5T_NATIVE_LONG) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'l2'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m2_tid,"l3",HOFFSET(struct cmpd_struct_2_w, l3), H5T_NATIVE_LONG) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m2_tid, "l3", HOFFSET(struct cmpd_struct_2_w, l3), H5T_NATIVE_LONG) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'l3'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m2_tid,"l4",HOFFSET(struct cmpd_struct_2_w, l4), H5T_NATIVE_LONG) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m2_tid, "l4", HOFFSET(struct cmpd_struct_2_w, l4), H5T_NATIVE_LONG) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'l4'\n"); goto error; } /* end if */ /* Create file compound datatype 2 */ - if((cmpd_f2_tid = H5Tcreate( H5T_COMPOUND, 8 + 1 + sizeof(hvl_t) + 4*sizeof(long))) < 0) { - H5_FAILED(); AT(); + if ((cmpd_f2_tid = H5Tcreate(H5T_COMPOUND, 8 + 1 + sizeof(hvl_t) + 4 * sizeof(long))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f2_tid,"c1",(size_t)0,H5T_STD_I64BE) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f2_tid, "c1", (size_t)0, H5T_STD_I64BE) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c1'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f2_tid,"c2",(size_t)8,H5T_NATIVE_CHAR) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f2_tid, "c2", (size_t)8, H5T_NATIVE_CHAR) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'c2'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f2_tid, "vl_string", (size_t)(8 + 1), str_id) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f2_tid, "vl_string", (size_t)(8 + 1), str_id) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'vl_string'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f2_tid,"l1",8 + 1 + sizeof(hvl_t),H5T_NATIVE_LONG) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f2_tid, "l1", 8 + 1 + sizeof(hvl_t), H5T_NATIVE_LONG) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'l1'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f2_tid,"l2",8 + 1 + sizeof(hvl_t) + sizeof(long),H5T_NATIVE_LONG) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f2_tid, "l2", 8 + 1 + sizeof(hvl_t) + sizeof(long), H5T_NATIVE_LONG) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'l2'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f2_tid,"l3",8 + 1 + sizeof(hvl_t) + 2*sizeof(long),H5T_NATIVE_LONG) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f2_tid, "l3", 8 + 1 + sizeof(hvl_t) + 2 * sizeof(long), H5T_NATIVE_LONG) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'l3'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f2_tid,"l4",8 + 1 + sizeof(hvl_t) + 3*sizeof(long),H5T_NATIVE_LONG) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f2_tid, "l4", 8 + 1 + sizeof(hvl_t) + 3 * sizeof(long), H5T_NATIVE_LONG) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'l4'\n"); goto error; } /* end if */ dim1[0] = 1; - if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) { - H5_FAILED(); AT(); + if ((space_id = H5Screate_simple(1, dim1, NULL)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create space\n"); goto error; } /* end if */ - if((dset1_id = H5Dcreate2(file, "Dataset1", cmpd_f1_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((dset1_id = H5Dcreate2(file, "Dataset1", cmpd_f1_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create dataset\n"); goto error; } /* end if */ - if((dset2_id = H5Dcreate2(file, "Dataset2", cmpd_f2_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((dset2_id = H5Dcreate2(file, "Dataset2", cmpd_f2_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create dataset\n"); goto error; } /* end if */ - if(H5Dwrite(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) { - H5_FAILED(); AT(); + if (H5Dwrite(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't write data\n"); goto error; } /* end if */ - if(H5Dwrite(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata2) < 0) { - H5_FAILED(); AT(); + if (H5Dwrite(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't write data\n"); goto error; } /* end if */ - if(H5Dread(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata1) < 0) { - H5_FAILED(); AT(); + if (H5Dread(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ - if(H5Dread(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata2) < 0) { - H5_FAILED(); AT(); + if (H5Dread(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ - if(rdata1.c1 != wdata1.c1 || rdata1.c2 != wdata1.c2 || HDstrcmp(rdata1.str, wdata1.str)) { - H5_FAILED(); AT(); + if (rdata1.c1 != wdata1.c1 || rdata1.c2 != wdata1.c2 || HDstrcmp(rdata1.str, wdata1.str)) { + H5_FAILED(); + AT(); HDprintf("incorrect read data\n"); goto error; } /* end if */ - if(rdata2.c1 != wdata2.c1 || rdata2.c2 != wdata2.c2 || HDstrcmp(rdata2.str, wdata2.str) || - rdata2.l1 != wdata2.l1 || rdata2.l2 != wdata2.l2 || rdata2.l3 != wdata2.l3 || rdata2.l4 != wdata2.l4) { - H5_FAILED(); AT(); + if (rdata2.c1 != wdata2.c1 || rdata2.c2 != wdata2.c2 || HDstrcmp(rdata2.str, wdata2.str) || + rdata2.l1 != wdata2.l1 || rdata2.l2 != wdata2.l2 || rdata2.l3 != wdata2.l3 || + rdata2.l4 != wdata2.l4) { + H5_FAILED(); + AT(); HDprintf("incorrect read data\n"); goto error; } /* end if */ - if(H5Treclaim(cmpd_m1_tid, space_id, H5P_DEFAULT, &rdata1) < 0) { - H5_FAILED(); AT(); + if (H5Treclaim(cmpd_m1_tid, space_id, H5P_DEFAULT, &rdata1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't reclaim read data\n"); goto error; } /* end if */ rdata1.str = NULL; - if(H5Treclaim(cmpd_m2_tid, space_id, H5P_DEFAULT, &rdata2) < 0) { - H5_FAILED(); AT(); + if (H5Treclaim(cmpd_m2_tid, space_id, H5P_DEFAULT, &rdata2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't reclaim read data\n"); goto error; } /* end if */ rdata2.str = NULL; - if(H5Dclose(dset1_id) < 0) + if (H5Dclose(dset1_id) < 0) goto error; - if(H5Dclose(dset2_id) < 0) + if (H5Dclose(dset2_id) < 0) goto error; - if(H5Tclose(cmpd_f1_tid) < 0) + if (H5Tclose(cmpd_f1_tid) < 0) goto error; - if(H5Tclose(cmpd_f2_tid) < 0) + if (H5Tclose(cmpd_f2_tid) < 0) goto error; - if(H5Tclose(str_id) < 0) + if (H5Tclose(str_id) < 0) goto error; - if(H5Sclose(space_id) < 0) + if (H5Sclose(space_id) < 0) goto error; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; - - if((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("cannot open file\n"); goto error; } /* end if */ - if((dset1_id = H5Dopen2(file, "Dataset1", H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((dset1_id = H5Dopen2(file, "Dataset1", H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("cannot open dataset\n"); goto error; } /* end if */ - if((dset2_id = H5Dopen2(file, "Dataset2", H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((dset2_id = H5Dopen2(file, "Dataset2", H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("cannot open dataset\n"); goto error; } /* end if */ - if((space_id = H5Dget_space(dset2_id)) < 0) { - H5_FAILED(); AT(); + if ((space_id = H5Dget_space(dset2_id)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't get space\n"); goto error; } /* end if */ rdata1.c1 = rdata1.c2 = 0; - if(rdata1.str) HDfree(rdata1.str); + if (rdata1.str) + HDfree(rdata1.str); rdata2.c1 = rdata2.c2 = 0; rdata2.l1 = rdata2.l2 = rdata2.l3 = rdata2.l4 = 0; - if(rdata2.str) { + if (rdata2.str) { HDfree(rdata2.str); rdata2.str = NULL; } /* end if */ - if(H5Dread(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata1) < 0) { - H5_FAILED(); AT(); + if (H5Dread(dset1_id, cmpd_m1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ - if(H5Dread(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata2) < 0) { - H5_FAILED(); AT(); + if (H5Dread(dset2_id, cmpd_m2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ - if(rdata1.c1!=wdata1.c1 || rdata1.c2!=wdata1.c2 || strcmp(rdata1.str, wdata1.str)) { - H5_FAILED(); AT(); + if (rdata1.c1 != wdata1.c1 || rdata1.c2 != wdata1.c2 || strcmp(rdata1.str, wdata1.str)) { + H5_FAILED(); + AT(); HDprintf("incorrect read data\n"); goto error; } /* end if */ - if(rdata2.c1 != wdata2.c1 || rdata2.c2 != wdata2.c2 || HDstrcmp(rdata2.str, wdata2.str) || - rdata2.l1 != wdata2.l1 || rdata2.l2 != wdata2.l2 || rdata2.l3 != wdata2.l3 || rdata2.l4 != wdata2.l4) { - H5_FAILED(); AT(); + if (rdata2.c1 != wdata2.c1 || rdata2.c2 != wdata2.c2 || HDstrcmp(rdata2.str, wdata2.str) || + rdata2.l1 != wdata2.l1 || rdata2.l2 != wdata2.l2 || rdata2.l3 != wdata2.l3 || + rdata2.l4 != wdata2.l4) { + H5_FAILED(); + AT(); HDprintf("incorrect read data\n"); goto error; } /* end if */ - if(H5Treclaim(cmpd_m1_tid, space_id, H5P_DEFAULT, &rdata1) < 0) { - H5_FAILED(); AT(); + if (H5Treclaim(cmpd_m1_tid, space_id, H5P_DEFAULT, &rdata1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't reclaim read data\n"); goto error; } /* end if */ rdata1.str = NULL; - if(H5Treclaim(cmpd_m2_tid, space_id, H5P_DEFAULT, &rdata2) < 0) { - H5_FAILED(); AT(); + if (H5Treclaim(cmpd_m2_tid, space_id, H5P_DEFAULT, &rdata2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't reclaim read data\n"); goto error; } /* end if */ rdata2.str = NULL; - if(H5Dclose(dset1_id) < 0) + if (H5Dclose(dset1_id) < 0) goto error; - if(H5Dclose(dset2_id) < 0) + if (H5Dclose(dset2_id) < 0) goto error; - if(H5Sclose(space_id) < 0) + if (H5Sclose(space_id) < 0) goto error; - if(H5Tclose(cmpd_m1_tid) < 0) + if (H5Tclose(cmpd_m1_tid) < 0) goto error; - if(H5Tclose(cmpd_m2_tid) < 0) + if (H5Tclose(cmpd_m2_tid) < 0) goto error; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; PASSED(); return 0; - error: +error: return 1; } /* end test_compound_14() */ - /*------------------------------------------------------------------------- * Function: test_compound_15 * @@ -2913,8 +3181,8 @@ static int test_compound_15(void) { typedef struct cmpd_struct { - int i1; - int i2; + int i1; + int i2; } cmpd_struct; cmpd_struct wdata1 = {1254, 5471}; @@ -2931,82 +3199,95 @@ test_compound_15(void) /* Create File */ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create file!\n"); goto error; } /* end if */ /* Create file compound datatype */ - if((cmpd_f_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) { - H5_FAILED(); AT(); + if ((cmpd_f_tid = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f_tid,"i1",HOFFSET(struct cmpd_struct,i1),H5T_NATIVE_INT) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f_tid, "i1", HOFFSET(struct cmpd_struct, i1), H5T_NATIVE_INT) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'i1'\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_f_tid,"i2",HOFFSET(struct cmpd_struct,i2),H5T_NATIVE_INT) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_f_tid, "i2", HOFFSET(struct cmpd_struct, i2), H5T_NATIVE_INT) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'i2'\n"); goto error; } /* end if */ /* Create memory compound datatype */ - if((cmpd_m_tid = H5Tcreate( H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) { - H5_FAILED(); AT(); + if ((cmpd_m_tid = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(cmpd_m_tid,"i1",(size_t)0,H5T_NATIVE_INT) < 0) { - H5_FAILED(); AT(); + if (H5Tinsert(cmpd_m_tid, "i1", (size_t)0, H5T_NATIVE_INT) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't insert field 'i1'\n"); goto error; } /* end if */ /* Create space, dataset, write wdata1 */ dim1[0] = 1; - if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) { - H5_FAILED(); AT(); + if ((space_id = H5Screate_simple(1, dim1, NULL)) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't create space\n"); goto error; } /* end if */ - if((dset_id = H5Dcreate2(file, "Dataset", cmpd_f_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5_FAILED(); AT(); + if ((dset_id = H5Dcreate2(file, "Dataset", cmpd_f_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) { + H5_FAILED(); + AT(); HDprintf("Can't create dataset\n"); goto error; } /* end if */ - if(H5Dwrite(dset_id, cmpd_f_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) { - H5_FAILED(); AT(); + if (H5Dwrite(dset_id, cmpd_f_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't write data\n"); goto error; } /* end if */ /* Write wdata2. The use of cmpd_m_tid here should cause only the first * element of wdata2 to be written. */ - if(H5Dwrite(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata2) < 0) { - H5_FAILED(); AT(); + if (H5Dwrite(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata2) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't write data\n"); goto error; } /* end if */ /* Read data */ - if(H5Dread(dset_id, cmpd_f_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { - H5_FAILED(); AT(); + if (H5Dread(dset_id, cmpd_f_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ /* Check for correctness of read data */ - if(rdata.i1 != wdata2[0] || rdata.i2 != wdata1.i2) { - H5_FAILED(); AT(); + if (rdata.i1 != wdata2[0] || rdata.i2 != wdata1.i2) { + H5_FAILED(); + AT(); HDprintf("incorrect read data\n"); goto error; } /* end if */ @@ -3017,39 +3298,40 @@ test_compound_15(void) rdata.i2 = wdata2[1]; /* Read data */ - if(H5Dread(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { - H5_FAILED(); AT(); + if (H5Dread(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); + AT(); HDprintf("Can't read data\n"); goto error; } /* end if */ /* Check for correctness of read data */ - if(rdata.i1 != wdata2[0] || rdata.i2 != wdata2[1]) { - H5_FAILED(); AT(); + if (rdata.i1 != wdata2[0] || rdata.i2 != wdata2[1]) { + H5_FAILED(); + AT(); HDprintf("incorrect read data\n"); goto error; } /* end if */ /* Close */ - if(H5Dclose(dset_id) < 0) + if (H5Dclose(dset_id) < 0) goto error; - if(H5Tclose(cmpd_f_tid) < 0) + if (H5Tclose(cmpd_f_tid) < 0) goto error; - if(H5Tclose(cmpd_m_tid) < 0) + if (H5Tclose(cmpd_m_tid) < 0) goto error; - if(H5Sclose(space_id) < 0) + if (H5Sclose(space_id) < 0) goto error; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; PASSED(); return 0; - error: +error: return 1; } /* end test_compound_15() */ - /*------------------------------------------------------------------------- * Function: test_compound_16 * @@ -3072,8 +3354,8 @@ static int test_compound_16(void) { typedef struct cmpd_struct { - int i1; - int i2; + int i1; + int i2; } cmpd_struct; cmpd_struct wdata1 = {1254, 5471}; @@ -3083,56 +3365,78 @@ test_compound_16(void) hid_t space_id; hid_t dset_id; hid_t open_dtypes[2] = {0, 0}; - hsize_t dim1[1] = {1}; + hsize_t dim1[1] = {1}; char filename[1024]; TESTING("visibility of internally registered type ids"); /* Create File */ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Copy and commit integer datatype */ - if((int_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(file, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if ((int_id = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(file, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create file compound datatype */ - if((cmpd_f_tid = H5Tcreate(H5T_COMPOUND, 2 * sizeof(int) + 2)) < 0) TEST_ERROR - if(H5Tinsert(cmpd_f_tid, "i1", (size_t)0, int_id) < 0) TEST_ERROR - if(H5Tinsert(cmpd_f_tid, "i2", sizeof(int) + 1, int_id) < 0) TEST_ERROR + if ((cmpd_f_tid = H5Tcreate(H5T_COMPOUND, 2 * sizeof(int) + 2)) < 0) + TEST_ERROR + if (H5Tinsert(cmpd_f_tid, "i1", (size_t)0, int_id) < 0) + TEST_ERROR + if (H5Tinsert(cmpd_f_tid, "i2", sizeof(int) + 1, int_id) < 0) + TEST_ERROR /* Create memory compound datatype */ - if((cmpd_m_tid = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) TEST_ERROR - if(H5Tinsert(cmpd_m_tid, "i1", HOFFSET(struct cmpd_struct, i1), int_id) < 0) TEST_ERROR - if(H5Tinsert(cmpd_m_tid, "i2", HOFFSET(struct cmpd_struct, i2), int_id) < 0) TEST_ERROR + if ((cmpd_m_tid = H5Tcreate(H5T_COMPOUND, sizeof(struct cmpd_struct))) < 0) + TEST_ERROR + if (H5Tinsert(cmpd_m_tid, "i1", HOFFSET(struct cmpd_struct, i1), int_id) < 0) + TEST_ERROR + if (H5Tinsert(cmpd_m_tid, "i2", HOFFSET(struct cmpd_struct, i2), int_id) < 0) + TEST_ERROR /* Create space, dataset, write wdata1 */ - if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) TEST_ERROR - if((dset_id = H5Dcreate2(file, "Dataset", cmpd_f_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(1, dim1, NULL)) < 0) + TEST_ERROR + if ((dset_id = H5Dcreate2(file, "Dataset", cmpd_f_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Dwrite(dset_id, cmpd_m_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata1) < 0) + TEST_ERROR /* Check behavior of H5Fget_obj_count */ - if((obj_count = H5Fget_obj_count(file, H5F_OBJ_DATATYPE)) != 1) { - H5_FAILED(); AT(); + if ((obj_count = H5Fget_obj_count(file, H5F_OBJ_DATATYPE)) != 1) { + H5_FAILED(); + AT(); HDprintf(" H5Fget_obj_count returned: %zd; expected: 1\n", obj_count); goto error; } /* Check behavior of H5Fget_obj_ids */ - if(H5Fget_obj_ids(file, H5F_OBJ_DATATYPE, (size_t)2, open_dtypes) < 0) TEST_ERROR - if(open_dtypes[1]) { - H5_FAILED(); AT(); + if (H5Fget_obj_ids(file, H5F_OBJ_DATATYPE, (size_t)2, open_dtypes) < 0) + TEST_ERROR + if (open_dtypes[1]) { + H5_FAILED(); + AT(); HDprintf(" H5Fget_obj_ids returned as second id: %lld; expected: 0\n", (long long)open_dtypes[1]); goto error; } /* Close */ - if(H5Dclose(dset_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Tclose(cmpd_f_tid) < 0) TEST_ERROR - if(H5Tclose(cmpd_m_tid) < 0) TEST_ERROR - if(H5Tclose(int_id) < 0) TEST_ERROR - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Dclose(dset_id) < 0) + TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (H5Tclose(cmpd_f_tid) < 0) + TEST_ERROR + if (H5Tclose(cmpd_m_tid) < 0) + TEST_ERROR + if (H5Tclose(int_id) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR PASSED(); return 0; @@ -3141,7 +3445,6 @@ error: return 1; } /* end test_compound_16() */ - /*------------------------------------------------------------------------- * Function: test_compound_17 * @@ -3164,98 +3467,134 @@ error: static int test_compound_17(void) { - hid_t file; - hid_t cmpd_int, arr_int, cmpd_ext, arr_ext, tmp_dt; - hsize_t dims[1] = {2}; - char filename[1024]; + hid_t file; + hid_t cmpd_int, arr_int, cmpd_ext, arr_ext, tmp_dt; + hsize_t dims[1] = {2}; + char filename[1024]; TESTING("that H5Tpack removes trailing bytes"); /* Create inner compound datatype. This type will be "packed" according * to the internal field, but will have trailing space at the end. */ - if((cmpd_int = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) TEST_ERROR - if(H5Tinsert(cmpd_int, "c", (size_t)0, H5T_NATIVE_CHAR) < 0) TEST_ERROR + if ((cmpd_int = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) + TEST_ERROR + if (H5Tinsert(cmpd_int, "c", (size_t)0, H5T_NATIVE_CHAR) < 0) + TEST_ERROR /* Create inner array datatype */ - if((arr_int = H5Tarray_create2(cmpd_int, 1, dims)) < 0) TEST_ERROR + if ((arr_int = H5Tarray_create2(cmpd_int, 1, dims)) < 0) + TEST_ERROR /* Create outer compound datatype. This type will be truly packed, with no * trailing space. However, the internal compound contained within is not * packed. */ - if((cmpd_ext = H5Tcreate(H5T_COMPOUND, (size_t)8)) < 0) TEST_ERROR - if(H5Tinsert(cmpd_ext, "arr", (size_t)0, arr_int) < 0) TEST_ERROR + if ((cmpd_ext = H5Tcreate(H5T_COMPOUND, (size_t)8)) < 0) + TEST_ERROR + if (H5Tinsert(cmpd_ext, "arr", (size_t)0, arr_int) < 0) + TEST_ERROR /* Create outer array datatype */ - if((arr_ext = H5Tarray_create2(cmpd_ext, 1, dims)) < 0) TEST_ERROR + if ((arr_ext = H5Tarray_create2(cmpd_ext, 1, dims)) < 0) + TEST_ERROR /* Try packing the internal array. Size should be 2 after packing. */ - if((tmp_dt = H5Tcopy(arr_int)) < 0) TEST_ERROR - if(H5Tpack(tmp_dt) < 0) TEST_ERROR - if(2 != H5Tget_size(tmp_dt)) { - H5_FAILED(); AT(); + if ((tmp_dt = H5Tcopy(arr_int)) < 0) + TEST_ERROR + if (H5Tpack(tmp_dt) < 0) + TEST_ERROR + if (2 != H5Tget_size(tmp_dt)) { + H5_FAILED(); + AT(); HDprintf(" Size after packing: %u; expected: 2\n", (unsigned)H5Tget_size(tmp_dt)); goto error; } - if(H5Tclose(tmp_dt) < 0) TEST_ERROR + if (H5Tclose(tmp_dt) < 0) + TEST_ERROR /* Try packing the external array. Size should be 4 after packing. */ - if((tmp_dt = H5Tcopy(arr_ext)) < 0) TEST_ERROR - if(H5Tpack(tmp_dt) < 0) TEST_ERROR - if(4 != H5Tget_size(tmp_dt)) { - H5_FAILED(); AT(); + if ((tmp_dt = H5Tcopy(arr_ext)) < 0) + TEST_ERROR + if (H5Tpack(tmp_dt) < 0) + TEST_ERROR + if (4 != H5Tget_size(tmp_dt)) { + H5_FAILED(); + AT(); HDprintf(" Size after packing: %u; expected: 4\n", (unsigned)H5Tget_size(tmp_dt)); goto error; } - if(H5Tclose(tmp_dt) < 0) TEST_ERROR + if (H5Tclose(tmp_dt) < 0) + TEST_ERROR /* Now we will commit arr_int and arr_ext to a file, and verify that they * are still packed correctly after opening them from the file */ /* Create File */ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Commit the datatypes. Note that they are still unpacked. */ - if(H5Tcommit2(file, "arr_int", arr_int, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tcommit2(file, "arr_ext", arr_ext, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Tcommit2(file, "arr_int", arr_int, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tcommit2(file, "arr_ext", arr_ext, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close IDs */ - if(H5Tclose(cmpd_int) < 0) TEST_ERROR - if(H5Tclose(arr_int) < 0) TEST_ERROR - if(H5Tclose(cmpd_ext) < 0) TEST_ERROR - if(H5Tclose(arr_ext) < 0) TEST_ERROR - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Tclose(cmpd_int) < 0) + TEST_ERROR + if (H5Tclose(arr_int) < 0) + TEST_ERROR + if (H5Tclose(cmpd_ext) < 0) + TEST_ERROR + if (H5Tclose(arr_ext) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR /* Reopen file */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR /* Open committed array datatypes */ - if((arr_int = H5Topen2(file, "arr_int", H5P_DEFAULT)) < 0) TEST_ERROR - if((arr_ext = H5Topen2(file, "arr_ext", H5P_DEFAULT)) < 0) TEST_ERROR + if ((arr_int = H5Topen2(file, "arr_int", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((arr_ext = H5Topen2(file, "arr_ext", H5P_DEFAULT)) < 0) + TEST_ERROR /* Try packing the internal array. Size should be 2 after packing. */ - if((tmp_dt = H5Tcopy(arr_int)) < 0) TEST_ERROR - if(H5Tpack(tmp_dt) < 0) TEST_ERROR - if(2 != H5Tget_size(tmp_dt)) { - H5_FAILED(); AT(); + if ((tmp_dt = H5Tcopy(arr_int)) < 0) + TEST_ERROR + if (H5Tpack(tmp_dt) < 0) + TEST_ERROR + if (2 != H5Tget_size(tmp_dt)) { + H5_FAILED(); + AT(); HDprintf(" Size after packing: %u; expected: 2\n", (unsigned)H5Tget_size(tmp_dt)); goto error; } - if(H5Tclose(tmp_dt) < 0) TEST_ERROR + if (H5Tclose(tmp_dt) < 0) + TEST_ERROR /* Try packing the external array. Size should be 4 after packing. */ - if((tmp_dt = H5Tcopy(arr_ext)) < 0) TEST_ERROR - if(H5Tpack(tmp_dt) < 0) TEST_ERROR - if(4 != H5Tget_size(tmp_dt)) { - H5_FAILED(); AT(); + if ((tmp_dt = H5Tcopy(arr_ext)) < 0) + TEST_ERROR + if (H5Tpack(tmp_dt) < 0) + TEST_ERROR + if (4 != H5Tget_size(tmp_dt)) { + H5_FAILED(); + AT(); HDprintf(" Size after packing: %u; expected: 4\n", (unsigned)H5Tget_size(tmp_dt)); goto error; } - if(H5Tclose(tmp_dt) < 0) TEST_ERROR + if (H5Tclose(tmp_dt) < 0) + TEST_ERROR /* Close IDs */ - if(H5Tclose(arr_int) < 0) TEST_ERROR - if(H5Tclose(arr_ext) < 0) TEST_ERROR - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Tclose(arr_int) < 0) + TEST_ERROR + if (H5Tclose(arr_ext) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR PASSED(); return 0; @@ -3264,7 +3603,6 @@ error: return 1; } /* end test_compound_17() */ - /*------------------------------------------------------------------------- * Function: test_compound_18 * @@ -3282,13 +3620,13 @@ error: static int test_compound_18(void) { - hid_t file = -1; - hid_t gid = -1; - hid_t did = -1; - hid_t aid = -1; - hid_t tid = -1; - hid_t sid = -1; - hsize_t dim = 1; + hid_t file = -1; + hid_t gid = -1; + hid_t did = -1; + hid_t aid = -1; + hid_t tid = -1; + hid_t sid = -1; + hsize_t dim = 1; const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */ char filename[1024]; herr_t ret; @@ -3302,17 +3640,20 @@ test_compound_18(void) /* Attempt to create file with compound datatype that has no fields */ /* Create File */ h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a dataspace to use */ sid = H5Screate_simple(1, &dim, NULL); HDassert(sid > 0); /* Create a dataset with the bad compound datatype */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dcreate2(file, "dataset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(did > 0) { + } + H5E_END_TRY; + if (did > 0) { H5Dclose(did); FAIL_PUTS_ERROR("created dataset with bad compound datatype") } /* end if */ @@ -3322,66 +3663,83 @@ test_compound_18(void) HDassert(gid > 0); /* Create an attribute with the bad compound datatype */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { aid = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(aid > 0) { + } + H5E_END_TRY; + if (aid > 0) { H5Aclose(aid); FAIL_PUTS_ERROR("created attribute with bad compound datatype") } /* end if */ /* Commit the datatype */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tcommit2(file, "cmpnd", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) { + } + H5E_END_TRY; + if (ret >= 0) { FAIL_PUTS_ERROR("committed named datatype with bad compound datatype") } /* end if */ /* Close IDs */ - if(H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR - + if (H5Tclose(tid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Open Generated File */ /* (generated with gen_bad_compound.c) */ - if((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Try to open the datatype */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tid = H5Topen2(file, "cmpnd", H5P_DEFAULT); - } H5E_END_TRY; - if(tid > 0) { + } + H5E_END_TRY; + if (tid > 0) { H5Tclose(tid); FAIL_PUTS_ERROR("opened named datatype with bad compound datatype") } /* end if */ /* Try to open the dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dopen2(file, "dataset", H5P_DEFAULT); - } H5E_END_TRY; - if(did > 0) { + } + H5E_END_TRY; + if (did > 0) { H5Dclose(did); FAIL_PUTS_ERROR("opened dataset with bad compound datatype") } /* end if */ /* Open the group with the attribute */ - if((gid = H5Gopen2(file, "group", H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gopen2(file, "group", H5P_DEFAULT)) < 0) + TEST_ERROR /* Try to open the dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { aid = H5Aopen(gid, "attr", H5P_DEFAULT); - } H5E_END_TRY; - if(aid > 0) { + } + H5E_END_TRY; + if (aid > 0) { H5Aclose(aid); FAIL_PUTS_ERROR("opened attribute with bad compound datatype") } /* end if */ /* Close IDs */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; @@ -3390,7 +3748,6 @@ error: return 1; } /* end test_compound_18() */ - /*------------------------------------------------------------------------- * Function: test_query * @@ -3419,175 +3776,175 @@ test_query(void) long c; double d; }; - hid_t file=-1, tid1=-1, tid2=-1; - char filename[1024]; - char compnd_type[]="Compound_type", enum_type[]="Enum_type"; - short enum_val; - char enum_name[16]; + hid_t file = -1, tid1 = -1, tid2 = -1; + char filename[1024]; + char compnd_type[] = "Compound_type", enum_type[] = "Enum_type"; + short enum_val; + char enum_name[16]; TESTING("query functions of compound and enumeration types"); /* Create File */ h5_fixname(FILENAME[2], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create a compound datatype */ - if((tid1=H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) { + if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) { H5_FAILED(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0) { + if (H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0) { H5_FAILED(); HDprintf("Can't insert field 'a'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0) { + if (H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0) { H5_FAILED(); HDprintf("Can't insert field 'b'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0) { + if (H5Tinsert(tid1, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0) { H5_FAILED(); HDprintf("Can't insert field 'c'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0) { + if (H5Tinsert(tid1, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0) { H5_FAILED(); HDprintf("Can't insert field 'd'\n"); goto error; } /* end if */ /* Create a enumerate datatype */ - if((tid2=H5Tcreate(H5T_ENUM, sizeof(short))) < 0) { + if ((tid2 = H5Tcreate(H5T_ENUM, sizeof(short))) < 0) { H5_FAILED(); HDprintf("Can't create enumerate type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "RED", (enum_val=10,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "RED", (enum_val = 10, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "GREEN", (enum_val=11,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "GREEN", (enum_val = 11, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "BLUE", (enum_val=12,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "BLUE", (enum_val = 12, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "ORANGE", (enum_val=13,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "ORANGE", (enum_val = 13, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "YELLOW", (enum_val=14,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "YELLOW", (enum_val = 14, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ /* Query member number and member index by name, for compound type. */ - if(H5Tget_nmembers(tid1)!=4) { + if (H5Tget_nmembers(tid1) != 4) { H5_FAILED(); HDprintf("Can't get member number\n"); goto error; } /* end if */ - if(H5Tget_member_index(tid1, "c")!=2) { + if (H5Tget_member_index(tid1, "c") != 2) { H5_FAILED(); HDprintf("Can't get correct index number\n"); goto error; } /* end if */ /* Query member number and member index by member name, for enumeration type. */ - if(H5Tget_nmembers(tid2) != 5) { + if (H5Tget_nmembers(tid2) != 5) { H5_FAILED(); HDprintf("Can't get member number\n"); goto error; } /* end if */ - if(H5Tget_member_index(tid2, "ORANGE") != 3) { + if (H5Tget_member_index(tid2, "ORANGE") != 3) { H5_FAILED(); HDprintf("Can't get correct index number\n"); goto error; } /* end if */ /* Commit compound datatype and close it */ - if(H5Tcommit2(file, compnd_type, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(file, compnd_type, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Can't commit compound datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid1) < 0) { + if (H5Tclose(tid1) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ /* Commit enumeration datatype and close it */ - if(H5Tcommit2(file, enum_type, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(file, enum_type, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Can't commit compound datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid2) < 0) { + if (H5Tclose(tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ /* Open the dataytpe for query */ - if((tid1 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0) + if ((tid1 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid2 = H5Topen2(file, enum_type, H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(file, enum_type, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Query member number and member index by name, for compound type */ - if(H5Tget_nmembers(tid1) != 4) { + if (H5Tget_nmembers(tid1) != 4) { H5_FAILED(); HDprintf("Can't get member number\n"); goto error; } /* end if */ - if(H5Tget_member_index(tid1, "c") != 2) { + if (H5Tget_member_index(tid1, "c") != 2) { H5_FAILED(); HDprintf("Can't get correct index number\n"); goto error; } /* end if */ /* Query member number and member index by member name, for enumeration type */ - if(H5Tget_nmembers(tid2)!=5) { + if (H5Tget_nmembers(tid2) != 5) { H5_FAILED(); HDprintf("Can't get member number\n"); goto error; } /* end if */ - if(H5Tget_member_index(tid2, "ORANGE")!=3) { + if (H5Tget_member_index(tid2, "ORANGE") != 3) { H5_FAILED(); HDprintf("Can't get correct index number\n"); goto error; } /* end if */ /* Query member value by member name, for enumeration type */ - if(H5Tenum_valueof (tid2, "ORANGE", &enum_val) < 0) { + if (H5Tenum_valueof(tid2, "ORANGE", &enum_val) < 0) { H5_FAILED(); HDprintf("Can't get value for enumerate member\n"); goto error; } /* end if */ - if(enum_val!=13) { + if (enum_val != 13) { H5_FAILED(); HDprintf("Incorrect value for enum member\n"); goto error; } /* end if */ /* Query member value by member index, for enumeration type */ - if(H5Tget_member_value (tid2, 2, &enum_val) < 0) { + if (H5Tget_member_value(tid2, 2, &enum_val) < 0) { H5_FAILED(); HDprintf("Can't get value for enum member\n"); goto error; } /* end if */ - if(enum_val!=12) { + if (enum_val != 12) { H5_FAILED(); HDprintf("Incorrect value for enum member\n"); goto error; @@ -3595,30 +3952,30 @@ test_query(void) /* Query member name by member value, for enumeration type */ enum_val = 14; - if(H5Tenum_nameof(tid2, &enum_val, enum_name, (size_t)16) < 0) { + if (H5Tenum_nameof(tid2, &enum_val, enum_name, (size_t)16) < 0) { H5_FAILED(); HDprintf("Can't get name for enum member\n"); goto error; } /* end if */ - if(strcmp("YELLOW", enum_name)) { + if (strcmp("YELLOW", enum_name)) { H5_FAILED(); HDprintf("Incorrect name for enum member\n"); goto error; } /* end if */ /* Close datatype and file */ - if(H5Tclose(tid1) < 0) { + if (H5Tclose(tid1) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid2) < 0) { + if (H5Tclose(tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if(H5Fclose(file) < 0) { + if (H5Fclose(file) < 0) { H5_FAILED(); HDprintf("Can't close file\n"); goto error; @@ -3627,16 +3984,17 @@ test_query(void) PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Tclose (tid1); - H5Tclose (tid2); - H5Fclose (file); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Tclose(tid1); + H5Tclose(tid2); + H5Fclose(file); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_transient * @@ -3654,118 +4012,146 @@ test_query(void) *------------------------------------------------------------------------- */ static int -test_transient (hid_t fapl) +test_transient(hid_t fapl) { - static hsize_t ds_size[2] = {10, 20}; - hid_t file=-1, type=-1, space=-1, dset=-1, t2=-1; - char filename[1024]; - hid_t ret_id; /* Generic hid_t return value */ - herr_t status; + static hsize_t ds_size[2] = {10, 20}; + hid_t file = -1, type = -1, space = -1, dset = -1, t2 = -1; + char filename[1024]; + hid_t ret_id; /* Generic hid_t return value */ + herr_t status; TESTING("transient datatypes"); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { + goto error; } - if ((space = H5Screate_simple (2, ds_size, ds_size)) < 0) goto error; + if ((space = H5Screate_simple(2, ds_size, ds_size)) < 0) + goto error; /* Predefined types cannot be modified or closed */ - H5E_BEGIN_TRY { - status = H5Tset_precision(H5T_NATIVE_INT, (size_t)256); - } H5E_END_TRY; - if (status>=0) { - H5_FAILED(); - HDputs (" Predefined types should not be modifiable!"); - goto error; + H5E_BEGIN_TRY + { + status = H5Tset_precision(H5T_NATIVE_INT, (size_t)256); } - H5E_BEGIN_TRY { - status = H5Tclose (H5T_NATIVE_INT); - } H5E_END_TRY; - if (status>=0) { - H5_FAILED(); - HDputs (" Predefined types should not be closable!"); - goto error; + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Predefined types should not be modifiable!"); + goto error; + } + H5E_BEGIN_TRY + { + status = H5Tclose(H5T_NATIVE_INT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Predefined types should not be closable!"); + goto error; } /* Copying a predefined type results in a modifiable copy */ - if((type=H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - if(H5Tset_precision(type, (size_t)256) < 0) goto error; + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + goto error; + if (H5Tset_precision(type, (size_t)256) < 0) + goto error; /* It should not be possible to create an attribute for a transient type */ - H5E_BEGIN_TRY { - ret_id = H5Acreate2(type, "attr1", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if (ret_id>=0) { - H5_FAILED(); - HDputs (" Attributes should not be allowed for transient types!"); - goto error; + H5E_BEGIN_TRY + { + ret_id = H5Acreate2(type, "attr1", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY; + if (ret_id >= 0) { + H5_FAILED(); + HDputs(" Attributes should not be allowed for transient types!"); + goto error; } /* Create a dataset from a transient datatype */ - if(H5Tclose(type) < 0) goto error; - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - if((dset = H5Dcreate2(file, "dset1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + if (H5Tclose(type) < 0) + goto error; + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + goto error; + if ((dset = H5Dcreate2(file, "dset1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* The type returned from a dataset should not be modifiable */ - if((t2 = H5Dget_type(dset)) < 0) goto error; - H5E_BEGIN_TRY { - status = H5Tset_precision(t2, (size_t)256); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs (" Dataset datatypes should not be modifiable!"); - goto error; + if ((t2 = H5Dget_type(dset)) < 0) + goto error; + H5E_BEGIN_TRY + { + status = H5Tset_precision(t2, (size_t)256); } - if(H5Tclose(t2) < 0) goto error; + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Dataset datatypes should not be modifiable!"); + goto error; + } + if (H5Tclose(t2) < 0) + goto error; /* * Close the dataset and reopen it, testing that it's type is still * read-only. */ - if(H5Dclose(dset) < 0) goto error; - if((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) goto error; - if((t2 = H5Dget_type(dset)) < 0) goto error; - H5E_BEGIN_TRY { - status = H5Tset_precision(t2, (size_t)256); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs (" Dataset datatypes should not be modifiable!"); - goto error; + if (H5Dclose(dset) < 0) + goto error; + if ((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) + goto error; + if ((t2 = H5Dget_type(dset)) < 0) + goto error; + H5E_BEGIN_TRY + { + status = H5Tset_precision(t2, (size_t)256); } - if(H5Tclose(t2) < 0) goto error; + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Dataset datatypes should not be modifiable!"); + goto error; + } + if (H5Tclose(t2) < 0) + goto error; /* * Get the dataset datatype by applying H5Tcopy() to the dataset. The * result should be modifiable. */ - if((t2=H5Tcopy(dset)) < 0) goto error; - if(H5Tset_precision(t2, (size_t)256) < 0) goto error; - if(H5Tclose(t2) < 0) goto error; - + if ((t2 = H5Tcopy(dset)) < 0) + goto error; + if (H5Tset_precision(t2, (size_t)256) < 0) + goto error; + if (H5Tclose(t2) < 0) + goto error; - if(H5Dclose(dset) < 0) goto error; - if(H5Fclose(file) < 0) goto error; - if(H5Tclose(type) < 0) goto error; - if(H5Sclose(space) < 0) goto error; + if (H5Dclose(dset) < 0) + goto error; + if (H5Fclose(file) < 0) + goto error; + if (H5Tclose(type) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Tclose (t2); - H5Tclose (type); - H5Sclose (space); - H5Dclose (dset); - H5Fclose (file); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Tclose(t2); + H5Tclose(type); + H5Sclose(space); + H5Dclose(dset); + H5Fclose(file); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_named * @@ -3783,227 +4169,286 @@ test_transient (hid_t fapl) *------------------------------------------------------------------------- */ static int -test_named (hid_t fapl) +test_named(hid_t fapl) { - hid_t file=-1, type=-1, space=-1, dset=-1, t2=-1, t3=-1, attr1=-1; - herr_t status; - static hsize_t ds_size[2] = {10, 20}; - size_t i,j; - unsigned attr_data[10][20]; - char filename[1024]; + hid_t file = -1, type = -1, space = -1, dset = -1, t2 = -1, t3 = -1, attr1 = -1; + herr_t status; + static hsize_t ds_size[2] = {10, 20}; + size_t i, j; + unsigned attr_data[10][20]; + char filename[1024]; TESTING("named datatypes"); h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file=H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { - goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { + goto error; } - if ((space = H5Screate_simple (2, ds_size, ds_size)) < 0) goto error; + if ((space = H5Screate_simple(2, ds_size, ds_size)) < 0) + goto error; /* Predefined types cannot be committed */ - H5E_BEGIN_TRY { - status = H5Tcommit2(file, "test_named_1 (should not exist)", H5T_NATIVE_INT, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs (" Predefined types should not be committable!"); - goto error; + H5E_BEGIN_TRY + { + status = H5Tcommit2(file, "test_named_1 (should not exist)", H5T_NATIVE_INT, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Predefined types should not be committable!"); + goto error; } /* Copy a predefined datatype and commit the copy */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - if(H5Tcommit2(file, "native-int", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; - if((status = H5Tcommitted(type)) < 0) goto error; - if(0 == status) { - H5_FAILED(); - HDputs (" H5Tcommitted() returned false!"); - goto error; + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + goto error; + if (H5Tcommit2(file, "native-int", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto error; + if ((status = H5Tcommitted(type)) < 0) + goto error; + if (0 == status) { + H5_FAILED(); + HDputs(" H5Tcommitted() returned false!"); + goto error; } /* We should not be able to modify a type after it has been committed. */ - H5E_BEGIN_TRY { - status = H5Tset_precision (type, (size_t)256); - } H5E_END_TRY; - if (status>=0) { - H5_FAILED(); - HDputs (" Committed type is not constant!"); - goto error; + H5E_BEGIN_TRY + { + status = H5Tset_precision(type, (size_t)256); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Committed type is not constant!"); + goto error; } /* We should not be able to re-commit a committed type */ - H5E_BEGIN_TRY { - status = H5Tcommit2(file, "test_named_2 (should not exist)", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs (" Committed types should not be recommitted!"); - goto error; + H5E_BEGIN_TRY + { + status = + H5Tcommit2(file, "test_named_2 (should not exist)", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Committed types should not be recommitted!"); + goto error; } /* It should be possible to define an attribute for the named type */ - if((attr1 = H5Acreate2(type, "attr1", H5T_NATIVE_UCHAR, space, - H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < (size_t)ds_size[0]; i++) - for(j = 0; j < (size_t)ds_size[1]; j++) + if ((attr1 = H5Acreate2(type, "attr1", H5T_NATIVE_UCHAR, space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + for (i = 0; i < (size_t)ds_size[0]; i++) + for (j = 0; j < (size_t)ds_size[1]; j++) attr_data[i][j] = (unsigned)(i * ds_size[1] + j); - if(H5Awrite(attr1, H5T_NATIVE_UINT, attr_data) < 0) goto error; - if(H5Aclose(attr1) < 0) goto error; + if (H5Awrite(attr1, H5T_NATIVE_UINT, attr_data) < 0) + goto error; + if (H5Aclose(attr1) < 0) + goto error; /* * Copying a committed type should result in a transient type which is * not locked. */ - if((t2 = H5Tcopy(type)) < 0) goto error; - if((status = H5Tcommitted(t2)) < 0) goto error; - if(status) { - H5_FAILED(); - HDputs (" Copying a named type should result in a transient type!"); - goto error; + if ((t2 = H5Tcopy(type)) < 0) + goto error; + if ((status = H5Tcommitted(t2)) < 0) + goto error; + if (status) { + H5_FAILED(); + HDputs(" Copying a named type should result in a transient type!"); + goto error; } - if(H5Tset_precision(t2, (size_t)256) < 0) goto error; - if(H5Tclose(t2) < 0) goto error; + if (H5Tset_precision(t2, (size_t)256) < 0) + goto error; + if (H5Tclose(t2) < 0) + goto error; /* * Close the committed type and reopen it. It should return a named type. */ - if(H5Tclose(type) < 0) goto error; - if((type = H5Topen2(file, "native-int", H5P_DEFAULT)) < 0) + if (H5Tclose(type) < 0) + goto error; + if ((type = H5Topen2(file, "native-int", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((status = H5Tcommitted(type)) < 0) goto error; - if(!status) { - H5_FAILED(); - HDputs (" Opened named types should be named types!"); - goto error; + if ((status = H5Tcommitted(type)) < 0) + goto error; + if (!status) { + H5_FAILED(); + HDputs(" Opened named types should be named types!"); + goto error; } /* Create a dataset that uses the named type */ - if((dset = H5Dcreate2(file, "dset1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + if ((dset = H5Dcreate2(file, "dset1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* Get the dataset's datatype and make sure it's a named type */ - if((t2 = H5Dget_type(dset)) < 0) goto error; - if((status = H5Tcommitted(t2)) < 0) goto error; - if(!status) { - H5_FAILED(); - HDputs (" Dataset type should be a named type!"); - goto error; + if ((t2 = H5Dget_type(dset)) < 0) + goto error; + if ((status = H5Tcommitted(t2)) < 0) + goto error; + if (!status) { + H5_FAILED(); + HDputs(" Dataset type should be a named type!"); + goto error; } /* Close the dataset, then close its type, then reopen the dataset */ - if(H5Dclose(dset) < 0) goto error; - if(H5Tclose(t2) < 0) goto error; - if((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) goto error; + if (H5Dclose(dset) < 0) + goto error; + if (H5Tclose(t2) < 0) + goto error; + if ((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) + goto error; /* Get the dataset's type and make sure it's named */ - if((t2 = H5Dget_type(dset)) < 0) goto error; - if((status = H5Tcommitted(t2)) < 0) goto error; - if(!status) { - H5_FAILED(); - HDputs (" Dataset type should be a named type!"); - goto error; + if ((t2 = H5Dget_type(dset)) < 0) + goto error; + if ((status = H5Tcommitted(t2)) < 0) + goto error; + if (!status) { + H5_FAILED(); + HDputs(" Dataset type should be a named type!"); + goto error; } /* * Close the dataset and create another with the type returned from the * first dataset. */ - if(H5Dclose(dset) < 0) goto error; - if((dset = H5Dcreate2(file, "dset2", t2, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if (H5Dclose(dset) < 0) + goto error; + if ((dset = H5Dcreate2(file, "dset2", t2, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* Reopen the second dataset and make sure the type is shared */ - if(H5Tclose(t2) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; - if((dset = H5Dopen2(file, "dset2", H5P_DEFAULT)) < 0) goto error; - if((t2 = H5Dget_type(dset)) < 0) goto error; - if((status = H5Tcommitted(t2)) < 0) goto error; - if(!status) { - H5_FAILED(); - HDputs (" Dataset type should be a named type!"); - goto error; + if (H5Tclose(t2) < 0) + goto error; + if (H5Dclose(dset) < 0) + goto error; + if ((dset = H5Dopen2(file, "dset2", H5P_DEFAULT)) < 0) + goto error; + if ((t2 = H5Dget_type(dset)) < 0) + goto error; + if ((status = H5Tcommitted(t2)) < 0) + goto error; + if (!status) { + H5_FAILED(); + HDputs(" Dataset type should be a named type!"); + goto error; } - if(H5Tclose(t2) < 0) goto error; + if (H5Tclose(t2) < 0) + goto error; /* * Get the dataset datatype by applying H5Tcopy() to the dataset. The * result should be modifiable. */ - if((t2 = H5Tcopy(dset)) < 0) goto error; - if(H5Tset_precision(t2, (size_t)256) < 0) goto error; - if(H5Tclose(t2) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; + if ((t2 = H5Tcopy(dset)) < 0) + goto error; + if (H5Tset_precision(t2, (size_t)256) < 0) + goto error; + if (H5Tclose(t2) < 0) + goto error; + if (H5Dclose(dset) < 0) + goto error; /* * Copy of committed type used as dataset type should not be name type */ - if((t2 = H5Tcopy(type)) < 0) goto error; - if((status = H5Tcommitted(t2)) < 0) goto error; - if(status) { - H5_FAILED(); - HDputs (" Copied type should not be a named type!"); - goto error; + if ((t2 = H5Tcopy(type)) < 0) + goto error; + if ((status = H5Tcommitted(t2)) < 0) + goto error; + if (status) { + H5_FAILED(); + HDputs(" Copied type should not be a named type!"); + goto error; } - if((dset = H5Dcreate2(file, "dset3", t2, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((t3 = H5Dget_type(dset)) < 0) goto error; - if((status = H5Tcommitted(t3)) < 0) goto error; - if(status) { - H5_FAILED(); - HDputs (" Datatype from dataset using copied type should not be a named type!"); - goto error; + if ((dset = H5Dcreate2(file, "dset3", t2, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if ((t3 = H5Dget_type(dset)) < 0) + goto error; + if ((status = H5Tcommitted(t3)) < 0) + goto error; + if (status) { + H5_FAILED(); + HDputs(" Datatype from dataset using copied type should not be a named type!"); + goto error; } - if(H5Tclose(t3) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; + if (H5Tclose(t3) < 0) + goto error; + if (H5Dclose(dset) < 0) + goto error; /* Close */ - if(H5Tclose(type) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Fclose(file) < 0) goto error; + if (H5Tclose(type) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Fclose(file) < 0) + goto error; /* Reopen file with read only access */ if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) goto error; /* Verify that H5Tcommit2 returns an error */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - H5E_BEGIN_TRY { - status = H5Tcommit2(file, "test_named_3 (should not exist)", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + goto error; + H5E_BEGIN_TRY + { + status = + H5Tcommit2(file, "test_named_3 (should not exist)", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); - HDputs (" Types should not be committable to a read-only file!"); + HDputs(" Types should not be committable to a read-only file!"); goto error; } /* Verify that H5Tcommit_anon returns an error */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - H5E_BEGIN_TRY { + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + goto error; + H5E_BEGIN_TRY + { status = H5Tcommit_anon(file, type, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); - HDputs (" Types should not be committable to a read-only file!"); + HDputs(" Types should not be committable to a read-only file!"); goto error; } /* Close */ - if(H5Tclose(type) < 0) goto error; - if(H5Fclose(file) < 0) goto error; + if (H5Tclose(type) < 0) + goto error; + if (H5Fclose(file) < 0) + goto error; PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Tclose(t3); - H5Tclose(t2); - H5Tclose(type); - H5Sclose(space); - H5Dclose(dset); - H5Fclose(file); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Tclose(t3); + H5Tclose(t2); + H5Tclose(type); + H5Sclose(space); + H5Dclose(dset); + H5Fclose(file); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: mkstr * @@ -4020,19 +4465,18 @@ error: static hid_t mkstr(size_t len, H5T_str_t strpad) { - hid_t t; + hid_t t; - if((t = H5Tcopy(H5T_C_S1)) < 0) + if ((t = H5Tcopy(H5T_C_S1)) < 0) return -1; - if(H5Tset_size(t, len) < 0) + if (H5Tset_size(t, len) < 0) return -1; - if(H5Tset_strpad(t, strpad) < 0) + if (H5Tset_strpad(t, strpad) < 0) return -1; return t; } - /*------------------------------------------------------------------------- * Function: test_str_create * @@ -4050,45 +4494,65 @@ static int test_str_create(void) { hid_t fixed_str1, fixed_str2; - hid_t vlen_str1, vlen_str2; + hid_t vlen_str1, vlen_str2; htri_t is_vl_str = FALSE; size_t query_size, str_size = 10; TESTING("string type creation using H5Tcreate"); /* Create fixed-length string in two ways and make sure they are the same */ - if((fixed_str1 = mkstr(str_size, H5T_STR_NULLTERM)) < 0) goto error; + if ((fixed_str1 = mkstr(str_size, H5T_STR_NULLTERM)) < 0) + goto error; - if((fixed_str2 = H5Tcreate(H5T_STRING, str_size)) < 0) goto error; - if(H5Tset_strpad(fixed_str2, H5T_STR_NULLTERM) < 0) goto error; + if ((fixed_str2 = H5Tcreate(H5T_STRING, str_size)) < 0) + goto error; + if (H5Tset_strpad(fixed_str2, H5T_STR_NULLTERM) < 0) + goto error; - if(!H5Tequal(fixed_str1, fixed_str2)) goto error; + if (!H5Tequal(fixed_str1, fixed_str2)) + goto error; - if((query_size = H5Tget_size(fixed_str1)) == 0) goto error; - if(query_size != str_size) goto error; + if ((query_size = H5Tget_size(fixed_str1)) == 0) + goto error; + if (query_size != str_size) + goto error; - if((query_size = H5Tget_size(fixed_str2)) == 0) goto error; - if(query_size != str_size) goto error; + if ((query_size = H5Tget_size(fixed_str2)) == 0) + goto error; + if (query_size != str_size) + goto error; - if(H5Tclose(fixed_str1) < 0) goto error; - if(H5Tclose(fixed_str2) < 0) goto error; + if (H5Tclose(fixed_str1) < 0) + goto error; + if (H5Tclose(fixed_str2) < 0) + goto error; /* Create variable-length string in two ways and make sure they are the same */ - if((vlen_str1 = mkstr((size_t)H5T_VARIABLE, H5T_STR_NULLTERM)) < 0) goto error; + if ((vlen_str1 = mkstr((size_t)H5T_VARIABLE, H5T_STR_NULLTERM)) < 0) + goto error; - if((vlen_str2 = H5Tcreate(H5T_STRING, (size_t)H5T_VARIABLE)) < 0) goto error; - if(H5Tset_strpad(vlen_str2, H5T_STR_NULLTERM) < 0) goto error; + if ((vlen_str2 = H5Tcreate(H5T_STRING, (size_t)H5T_VARIABLE)) < 0) + goto error; + if (H5Tset_strpad(vlen_str2, H5T_STR_NULLTERM) < 0) + goto error; - if(!H5Tequal(vlen_str1, vlen_str2)) goto error; + if (!H5Tequal(vlen_str1, vlen_str2)) + goto error; - if((is_vl_str = H5Tis_variable_str(vlen_str1)) < 0) goto error; - if(!is_vl_str) goto error; + if ((is_vl_str = H5Tis_variable_str(vlen_str1)) < 0) + goto error; + if (!is_vl_str) + goto error; - if((is_vl_str = H5Tis_variable_str(vlen_str2)) < 0) goto error; - if(!is_vl_str) goto error; + if ((is_vl_str = H5Tis_variable_str(vlen_str2)) < 0) + goto error; + if (!is_vl_str) + goto error; - if(H5Tclose(vlen_str1) < 0) goto error; - if(H5Tclose(vlen_str2) < 0) goto error; + if (H5Tclose(vlen_str1) < 0) + goto error; + if (H5Tclose(vlen_str2) < 0) + goto error; PASSED(); return 0; @@ -4098,7 +4562,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_conv_str_1 * @@ -4115,9 +4578,9 @@ error: static int test_conv_str_1(void) { - char *buf = NULL; - hid_t src_type = -1; - hid_t dst_type = -1; + char *buf = NULL; + hid_t src_type = -1; + hid_t dst_type = -1; TESTING("string conversions"); @@ -4125,74 +4588,95 @@ test_conv_str_1(void) * Convert a null-terminated string to a shorter and longer null * terminated string. */ - if((src_type = mkstr((size_t)10, H5T_STR_NULLTERM)) < 0) goto error; - if((dst_type = mkstr((size_t)5, H5T_STR_NULLTERM)) < 0) goto error; - if(NULL == (buf = (char*)HDcalloc((size_t)2, (size_t)10))) goto error; + if ((src_type = mkstr((size_t)10, H5T_STR_NULLTERM)) < 0) + goto error; + if ((dst_type = mkstr((size_t)5, H5T_STR_NULLTERM)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc((size_t)2, (size_t)10))) + goto error; HDmemcpy(buf, "abcdefghi\0abcdefghi\0", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcd\0abcd\0abcdefghi\0", (size_t)20)) { - H5_FAILED(); - HDputs(" Truncated C-string test failed"); - goto error; + H5_FAILED(); + HDputs(" Truncated C-string test failed"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcd\0\0\0\0\0\0abcd\0\0\0\0\0\0", (size_t)20)) { - H5_FAILED(); - HDputs(" Extended C-string test failed"); - goto error; + H5_FAILED(); + HDputs(" Extended C-string test failed"); + goto error; } HDfree(buf); buf = NULL; - if (H5Tclose(src_type) < 0) goto error; - if (H5Tclose(dst_type) < 0) goto error; + if (H5Tclose(src_type) < 0) + goto error; + if (H5Tclose(dst_type) < 0) + goto error; /* * Convert a null padded string to a shorter and then longer string. */ - if((src_type = mkstr((size_t)10, H5T_STR_NULLPAD)) < 0) goto error; - if((dst_type = mkstr((size_t)5, H5T_STR_NULLPAD)) < 0) goto error; - if(NULL == (buf = (char*)HDcalloc((size_t)2, (size_t)10))) goto error; + if ((src_type = mkstr((size_t)10, H5T_STR_NULLPAD)) < 0) + goto error; + if ((dst_type = mkstr((size_t)5, H5T_STR_NULLPAD)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc((size_t)2, (size_t)10))) + goto error; HDmemcpy(buf, "abcdefghijabcdefghij", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdeabcdeabcdefghij", (size_t)20)) { - H5_FAILED(); - HDputs(" Truncated C buffer test failed"); - goto error; + H5_FAILED(); + HDputs(" Truncated C buffer test failed"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", (size_t)20)) { - H5_FAILED(); - HDputs(" Extended C buffer test failed"); - goto error; + H5_FAILED(); + HDputs(" Extended C buffer test failed"); + goto error; } HDfree(buf); buf = NULL; - if (H5Tclose(src_type) < 0) goto error; - if (H5Tclose(dst_type) < 0) goto error; + if (H5Tclose(src_type) < 0) + goto error; + if (H5Tclose(dst_type) < 0) + goto error; /* * Convert a space-padded string to a shorter and then longer string. */ - if((src_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) goto error; - if((dst_type = mkstr((size_t)5, H5T_STR_SPACEPAD)) < 0) goto error; - if(NULL == (buf = (char*)HDcalloc((size_t)2, (size_t)10))) goto error; + if ((src_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) + goto error; + if ((dst_type = mkstr((size_t)5, H5T_STR_SPACEPAD)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc((size_t)2, (size_t)10))) + goto error; HDmemcpy(buf, "abcdefghijabcdefghij", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdeabcdeabcdefghij", (size_t)20)) { - H5_FAILED(); - HDputs(" Truncated Fortran-string test failed"); - goto error; + H5_FAILED(); + HDputs(" Truncated Fortran-string test failed"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcde abcde ", (size_t)20)) { - H5_FAILED(); - HDputs(" Extended Fortran-string test failed"); - goto error; + H5_FAILED(); + HDputs(" Extended Fortran-string test failed"); + goto error; } HDfree(buf); buf = NULL; - if (H5Tclose(src_type) < 0) goto error; - if (H5Tclose(dst_type) < 0) goto error; + if (H5Tclose(src_type) < 0) + goto error; + if (H5Tclose(dst_type) < 0) + goto error; /* * What happens if a null-terminated string is not null terminated? If @@ -4200,146 +4684,189 @@ test_conv_str_1(void) * the destination is a different size or type of string then the right * thing should happen. */ - if((src_type = mkstr((size_t)10, H5T_STR_NULLTERM)) < 0) goto error; - if((dst_type = mkstr((size_t)10, H5T_STR_NULLTERM)) < 0) goto error; - if(NULL == (buf = (char*)HDcalloc((size_t)2, (size_t)10))) goto error; + if ((src_type = mkstr((size_t)10, H5T_STR_NULLTERM)) < 0) + goto error; + if ((dst_type = mkstr((size_t)10, H5T_STR_NULLTERM)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc((size_t)2, (size_t)10))) + goto error; HDmemcpy(buf, "abcdefghijabcdefghij", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdefghijabcdefghij", (size_t)20)) { - H5_FAILED(); - HDputs(" Non-terminated string test 1"); - goto error; + H5_FAILED(); + HDputs(" Non-terminated string test 1"); + goto error; } H5Tclose(dst_type); - if((dst_type = mkstr((size_t)5, H5T_STR_NULLTERM)) < 0) goto error; + if ((dst_type = mkstr((size_t)5, H5T_STR_NULLTERM)) < 0) + goto error; HDmemcpy(buf, "abcdefghijabcdefghij", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcd\0abcd\0abcdefghij", (size_t)20)) { - H5_FAILED(); - HDputs(" Non-terminated string test 2"); - goto error; + H5_FAILED(); + HDputs(" Non-terminated string test 2"); + goto error; } HDmemcpy(buf, "abcdeabcdexxxxxxxxxx", (size_t)20); - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", (size_t)20)) { - H5_FAILED(); - HDputs(" Non-terminated string test 2"); - goto error; + H5_FAILED(); + HDputs(" Non-terminated string test 2"); + goto error; } HDfree(buf); buf = NULL; - if (H5Tclose(src_type) < 0) goto error; - if (H5Tclose(dst_type) < 0) goto error; + if (H5Tclose(src_type) < 0) + goto error; + if (H5Tclose(dst_type) < 0) + goto error; /* * Test C string to Fortran and vice versa. */ - if((src_type = mkstr((size_t)10, H5T_STR_NULLTERM)) < 0) goto error; - if((dst_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) goto error; - if(NULL == (buf = (char*)HDcalloc((size_t)2, (size_t)10))) goto error; + if ((src_type = mkstr((size_t)10, H5T_STR_NULLTERM)) < 0) + goto error; + if ((dst_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc((size_t)2, (size_t)10))) + goto error; HDmemcpy(buf, "abcdefghi\0abcdefghi\0", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdefghi abcdefghi ", (size_t)20)) { - H5_FAILED(); - HDputs(" C string to Fortran test 1"); - goto error; + H5_FAILED(); + HDputs(" C string to Fortran test 1"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdefghi\0abcdefghi\0", (size_t)20)) { - H5_FAILED(); - HDputs(" Fortran to C string test 1"); - goto error; + H5_FAILED(); + HDputs(" Fortran to C string test 1"); + goto error; } - if (H5Tclose(dst_type) < 0) goto error; - if((dst_type = mkstr((size_t)5, H5T_STR_SPACEPAD)) < 0) goto error; + if (H5Tclose(dst_type) < 0) + goto error; + if ((dst_type = mkstr((size_t)5, H5T_STR_SPACEPAD)) < 0) + goto error; HDmemcpy(buf, "abcdefgh\0\0abcdefgh\0\0", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdeabcdeabcdefgh\0\0", (size_t)20)) { - H5_FAILED(); - HDputs(" C string to Fortran test 2"); - goto error; + H5_FAILED(); + HDputs(" C string to Fortran test 2"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", (size_t)20)) { - H5_FAILED(); - HDputs(" Fortran to C string test 2"); - goto error; + H5_FAILED(); + HDputs(" Fortran to C string test 2"); + goto error; } - if (H5Tclose(src_type) < 0) goto error; - if (H5Tclose(dst_type) < 0) goto error; - if((src_type = mkstr((size_t)5, H5T_STR_NULLTERM)) < 0) goto error; - if((dst_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) goto error; + if (H5Tclose(src_type) < 0) + goto error; + if (H5Tclose(dst_type) < 0) + goto error; + if ((src_type = mkstr((size_t)5, H5T_STR_NULLTERM)) < 0) + goto error; + if ((dst_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) + goto error; HDmemcpy(buf, "abcd\0abcd\0xxxxxxxxxx", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcd abcd ", (size_t)20)) { - H5_FAILED(); - HDputs(" C string to Fortran test 3"); - goto error; + H5_FAILED(); + HDputs(" C string to Fortran test 3"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcd\0abcd\0abcd ", (size_t)20)) { - H5_FAILED(); - HDputs(" Fortran to C string test 3"); - goto error; + H5_FAILED(); + HDputs(" Fortran to C string test 3"); + goto error; } HDfree(buf); buf = NULL; - if (H5Tclose(src_type) < 0) goto error; - if (H5Tclose(dst_type) < 0) goto error; + if (H5Tclose(src_type) < 0) + goto error; + if (H5Tclose(dst_type) < 0) + goto error; /* * Test C buffer to Fortran and vice versa. */ - if((src_type = mkstr((size_t)10, H5T_STR_NULLPAD)) < 0) goto error; - if((dst_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) goto error; - if(NULL == (buf = (char*)HDcalloc((size_t)2, (size_t)10))) goto error; + if ((src_type = mkstr((size_t)10, H5T_STR_NULLPAD)) < 0) + goto error; + if ((dst_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc((size_t)2, (size_t)10))) + goto error; HDmemcpy(buf, "abcdefghijabcdefghij", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdefghijabcdefghij", (size_t)20)) { - H5_FAILED(); - HDputs(" C buffer to Fortran test 1"); - goto error; + H5_FAILED(); + HDputs(" C buffer to Fortran test 1"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdefghijabcdefghij", (size_t)20)) { - H5_FAILED(); - HDputs(" Fortran to C buffer test 1"); - goto error; + H5_FAILED(); + HDputs(" Fortran to C buffer test 1"); + goto error; } - if (H5Tclose(dst_type) < 0) goto error; - if((dst_type = mkstr((size_t)5, H5T_STR_SPACEPAD)) < 0) goto error; + if (H5Tclose(dst_type) < 0) + goto error; + if ((dst_type = mkstr((size_t)5, H5T_STR_SPACEPAD)) < 0) + goto error; HDmemcpy(buf, "abcdefgh\0\0abcdefgh\0\0", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcdeabcdeabcdefgh\0\0", (size_t)20)) { - H5_FAILED(); - HDputs(" C buffer to Fortran test 2"); - goto error; + H5_FAILED(); + HDputs(" C buffer to Fortran test 2"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", (size_t)20)) { - H5_FAILED(); - HDputs(" Fortran to C buffer test 2"); - goto error; + H5_FAILED(); + HDputs(" Fortran to C buffer test 2"); + goto error; } - if (H5Tclose(src_type) < 0) goto error; - if (H5Tclose(dst_type) < 0) goto error; - if((src_type = mkstr((size_t)5, H5T_STR_NULLPAD)) < 0) goto error; - if((dst_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) goto error; + if (H5Tclose(src_type) < 0) + goto error; + if (H5Tclose(dst_type) < 0) + goto error; + if ((src_type = mkstr((size_t)5, H5T_STR_NULLPAD)) < 0) + goto error; + if ((dst_type = mkstr((size_t)10, H5T_STR_SPACEPAD)) < 0) + goto error; HDmemcpy(buf, "abcd\0abcd\0xxxxxxxxxx", (size_t)20); - if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcd abcd ", (size_t)20)) { - H5_FAILED(); - HDputs(" C buffer to Fortran test 3"); - goto error; + H5_FAILED(); + HDputs(" C buffer to Fortran test 3"); + goto error; } - if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(dst_type, src_type, (size_t)2, buf, NULL, H5P_DEFAULT) < 0) + goto error; if (HDmemcmp(buf, "abcd\0abcd\0abcd ", (size_t)20)) { - H5_FAILED(); - HDputs(" Fortran to C buffer test 3"); - goto error; + H5_FAILED(); + HDputs(" Fortran to C buffer test 3"); + goto error; } - if(H5Tclose(src_type) < 0) goto error; - if(H5Tclose(dst_type) < 0) goto error; + if (H5Tclose(src_type) < 0) + goto error; + if (H5Tclose(dst_type) < 0) + goto error; HDfree(buf); PASSED(); @@ -4351,12 +4878,14 @@ test_conv_str_1(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(src_type); H5Tclose(dst_type); - } H5E_END_TRY; + } + H5E_END_TRY; - if(buf) + if (buf) HDfree(buf); /* Restore the default error handler (set in h5_reset()) */ @@ -4367,7 +4896,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_conv_str_2 * @@ -4384,24 +4912,27 @@ error: static int test_conv_str_2(void) { - char *buf = NULL, s[80]; + char * buf = NULL, s[80]; hid_t c_type = -1; - hid_t f_type = -1; - const size_t nelmts = NTESTELEM; - size_t i, j, nchars; - int ret_value = 1; + hid_t f_type = -1; + const size_t nelmts = NTESTELEM; + size_t i, j, nchars; + int ret_value = 1; /* * Initialize types and buffer. */ - if((c_type = mkstr((size_t)8, H5T_STR_NULLPAD)) < 0) goto error; - if((f_type = mkstr((size_t)8, H5T_STR_SPACEPAD)) < 0) goto error; - if(NULL == (buf = (char*)HDcalloc(nelmts, (size_t)8))) goto error; - for(i = 0; i < nelmts; i++) { - nchars = (size_t)(HDrand() % 8); - for(j = 0; j < nchars; j++) - buf[i * 8 + j] = (char)('a' + HDrand() % 26); - while(j < nchars) + if ((c_type = mkstr((size_t)8, H5T_STR_NULLPAD)) < 0) + goto error; + if ((f_type = mkstr((size_t)8, H5T_STR_SPACEPAD)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc(nelmts, (size_t)8))) + goto error; + for (i = 0; i < nelmts; i++) { + nchars = (size_t)(HDrand() % 8); + for (j = 0; j < nchars; j++) + buf[i * 8 + j] = (char)('a' + HDrand() % 26); + while (j < nchars) buf[i * 8 + j++] = '\0'; } /* end for */ @@ -4409,21 +4940,23 @@ test_conv_str_2(void) HDsprintf(s, "Testing random string conversion speed"); HDprintf("%-70s", s); HDfflush(stdout); - if(H5Tconvert(c_type, f_type, nelmts, buf, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(c_type, f_type, nelmts, buf, NULL, H5P_DEFAULT) < 0) goto error; - if(H5Tconvert(f_type, c_type, nelmts, buf, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(f_type, c_type, nelmts, buf, NULL, H5P_DEFAULT) < 0) goto error; PASSED(); ret_value = 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(c_type); H5Tclose(f_type); - } H5E_END_TRY; + } + H5E_END_TRY; - if(buf) + if (buf) HDfree(buf); /* Restore the default error handler (set in h5_reset()) */ @@ -4434,7 +4967,6 @@ error: return ret_value; } - /*------------------------------------------------------------------------- * Function: test_conv_str_3 * @@ -4452,81 +4984,101 @@ error: static int test_conv_str_3(void) { - char *buf=NULL; - hid_t type = -1; - hid_t super = -1; - const size_t nelmts = NTESTELEM; - size_t i, j, nchars; - int ret_value = 1; - size_t size; - H5T_pad_t inpad; - H5T_sign_t sign; - char *tag = NULL; - herr_t ret; + char * buf = NULL; + hid_t type = -1; + hid_t super = -1; + const size_t nelmts = NTESTELEM; + size_t i, j, nchars; + int ret_value = 1; + size_t size; + H5T_pad_t inpad; + H5T_sign_t sign; + char * tag = NULL; + herr_t ret; TESTING("some type functions for string"); /* * Initialize types and buffer. */ - if((type = mkstr((size_t)8, H5T_STR_NULLPAD)) < 0) goto error; - if(NULL == (buf = (char*)HDcalloc(nelmts, (size_t)8))) + if ((type = mkstr((size_t)8, H5T_STR_NULLPAD)) < 0) + goto error; + if (NULL == (buf = (char *)HDcalloc(nelmts, (size_t)8))) FAIL_PUTS_ERROR("Allocation failed."); - for(i = 0; i < nelmts; i++) { - nchars = (size_t)(HDrand() % 8); - for(j = 0; j < nchars; j++) - buf[i * 8 + j] = (char)('a' + HDrand() % 26); - while(j < nchars) + for (i = 0; i < nelmts; i++) { + nchars = (size_t)(HDrand() % 8); + for (j = 0; j < nchars; j++) + buf[i * 8 + j] = (char)('a' + HDrand() % 26); + while (j < nchars) buf[i * 8 + j++] = '\0'; } /* end for */ - if(H5Tget_precision(type) == 0) FAIL_STACK_ERROR - if(H5Tget_size(type) == 0) FAIL_STACK_ERROR - if(H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE) < 0) FAIL_STACK_ERROR - if(H5Tget_cset(type) < 0) FAIL_STACK_ERROR - if(H5Tget_strpad(type) < 0) FAIL_STACK_ERROR - if(H5Tset_offset(type, (size_t)0) < 0) FAIL_STACK_ERROR - if(H5Tget_order(type) < 0) FAIL_STACK_ERROR + if (H5Tget_precision(type) == 0) + FAIL_STACK_ERROR + if (H5Tget_size(type) == 0) + FAIL_STACK_ERROR + if (H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE) < 0) + FAIL_STACK_ERROR + if (H5Tget_cset(type) < 0) + FAIL_STACK_ERROR + if (H5Tget_strpad(type) < 0) + FAIL_STACK_ERROR + if (H5Tset_offset(type, (size_t)0) < 0) + FAIL_STACK_ERROR + if (H5Tget_order(type) < 0) + FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tset_precision(type, nelmts); - } H5E_END_TRY; - if(ret >= 0) { + } + H5E_END_TRY; + if (ret >= 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { size = H5Tget_ebias(type); - } H5E_END_TRY; - if(size > 0) { + } + H5E_END_TRY; + if (size > 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { inpad = H5Tget_inpad(type); - } H5E_END_TRY; - if(inpad > -1) { + } + H5E_END_TRY; + if (inpad > -1) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { sign = H5Tget_sign(type); - } H5E_END_TRY; - if(sign > -1) { + } + H5E_END_TRY; + if (sign > -1) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tag = H5Tget_tag(type); - } H5E_END_TRY; - if(tag) { + } + H5E_END_TRY; + if (tag) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { super = H5Tget_super(type); - } H5E_END_TRY; - if(super >= 0) { + } + H5E_END_TRY; + if (super >= 0) { FAIL_PUTS_ERROR("Operation not allowed for this type."); } /* end if */ @@ -4534,14 +5086,16 @@ test_conv_str_3(void) ret_value = 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(type); H5Tclose(super); - } H5E_END_TRY; + } + H5E_END_TRY; - if(buf) + if (buf) HDfree(buf); - if(tag) + if (tag) H5free_memory(tag); /* Technically allocated by API call */ /* Restore the default error handler (set in h5_reset()) */ @@ -4549,10 +5103,9 @@ error: reset_hdf5(); - return ret_value; /* Number of errors */ + return ret_value; /* Number of errors */ } - /*------------------------------------------------------------------------- * Function: test_conv_enum_1 * @@ -4572,52 +5125,58 @@ error: static int test_conv_enum_1(void) { - const size_t nelmts=NTESTELEM; - int i, val, *buf=NULL; - hid_t t1 = -1; - hid_t t2 = -1; - char s[80]; - int ret_value = 1; - size_t u; + const size_t nelmts = NTESTELEM; + int i, val, *buf = NULL; + hid_t t1 = -1; + hid_t t2 = -1; + char s[80]; + int ret_value = 1; + size_t u; /* Build the datatypes */ - if((t1 = H5Tcreate(H5T_ENUM, sizeof(int))) < 0) goto error; - if((t2 = H5Tenum_create(H5T_NATIVE_INT)) < 0) goto error; + if ((t1 = H5Tcreate(H5T_ENUM, sizeof(int))) < 0) + goto error; + if ((t2 = H5Tenum_create(H5T_NATIVE_INT)) < 0) + goto error; s[1] = '\0'; - for(i = 0; i < 26; i++) { - s[0] = (char)('A' + i); - H5Tenum_insert(t1, s, &i); - H5Tenum_insert(t2, s, (val = i * 1000 + i, &val)); + for (i = 0; i < 26; i++) { + s[0] = (char)('A' + i); + H5Tenum_insert(t1, s, &i); + H5Tenum_insert(t2, s, (val = i * 1000 + i, &val)); } /* end for */ /* Initialize the buffer */ - if(NULL == (buf = (int*)HDmalloc(nelmts * MAX(H5Tget_size(t1), H5Tget_size(t2))))) + if (NULL == (buf = (int *)HDmalloc(nelmts * MAX(H5Tget_size(t1), H5Tget_size(t2))))) goto error; - for(u = 0; u < nelmts; u++) + for (u = 0; u < nelmts; u++) buf[u] = HDrand() % 26; /* Conversions */ HDsprintf(s, "Testing random enum conversion O(N)"); HDprintf("%-70s", s); HDfflush(stdout); - if(H5Tconvert(t1, t2, nelmts, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(t1, t2, nelmts, buf, NULL, H5P_DEFAULT) < 0) + goto error; PASSED(); HDsprintf(s, "Testing random enum conversion O(N log N)"); HDprintf("%-70s", s); HDfflush(stdout); - if(H5Tconvert(t2, t1, nelmts, buf, NULL, H5P_DEFAULT) < 0) goto error; + if (H5Tconvert(t2, t1, nelmts, buf, NULL, H5P_DEFAULT) < 0) + goto error; PASSED(); ret_value = 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(t1); H5Tclose(t2); - } H5E_END_TRY; + } + H5E_END_TRY; - if(buf) + if (buf) HDfree(buf); /* Restore the default error handler (set in h5_reset()) */ @@ -4628,7 +5187,6 @@ error: return ret_value; } - /*------------------------------------------------------------------------- * Function: test_conv_enum_2 * @@ -4644,16 +5202,9 @@ error: static int test_conv_enum_2(void) { - hid_t srctype=-1, dsttype=-1, oddsize=-1; - int *data=NULL, i, nerrors=0; - const char *mname[] = { "RED", - "GREEN", - "BLUE", - "YELLOW", - "PINK", - "PURPLE", - "ORANGE", - "WHITE" }; + hid_t srctype = -1, dsttype = -1, oddsize = -1; + int * data = NULL, i, nerrors = 0; + const char *mname[] = {"RED", "GREEN", "BLUE", "YELLOW", "PINK", "PURPLE", "ORANGE", "WHITE"}; TESTING("non-native enumeration type conversion"); @@ -4661,7 +5212,7 @@ test_conv_enum_2(void) oddsize = H5Tcopy(H5T_STD_I32BE); H5Tset_size(oddsize, (size_t)3); /*reduce to 24 bits, not corresponding to any native size*/ srctype = H5Tenum_create(oddsize); - for (i=7; i>=0; --i) { + for (i = 7; i >= 0; --i) { char pattern[3]; pattern[2] = (char)i; pattern[0] = pattern[1] = 0; @@ -4671,27 +5222,26 @@ test_conv_enum_2(void) /* Destination enum type */ dsttype = H5Tenum_create(H5T_NATIVE_INT); HDassert(H5Tget_size(dsttype) > H5Tget_size(srctype)); - for (i=0; i<8; i++) + for (i = 0; i < 8; i++) H5Tenum_insert(dsttype, mname[i], &i); /* Source data */ - data = (int*)HDmalloc(NTESTELEM*sizeof(int)); - for (i=0; i0) { + if (H5Tset_precision(type, (size_t)12) < 0) + goto error; + if (H5Tset_offset(type, (size_t)10) < 0) + goto error; + if (H5Tset_pad(type, H5T_PAD_ONE, H5T_PAD_ONE)) + goto error; + if ((size = H5Tget_size(type)) == 0) + goto error; + if (H5Tset_order(type, H5T_ORDER_BE) < 0) + goto error; + if ((ntype = H5Tget_native_type(type, H5T_DIR_ASCEND)) < 0) + goto error; + + H5E_BEGIN_TRY + { + size = H5Tget_ebias(type); + } + H5E_END_TRY; + if (size > 0) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { - inpad=H5Tget_inpad(type); - } H5E_END_TRY; - if (inpad>-1) { + H5E_BEGIN_TRY + { + inpad = H5Tget_inpad(type); + } + H5E_END_TRY; + if (inpad > -1) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { - cset=H5Tget_cset(type); - } H5E_END_TRY; - if (cset>-1) { + H5E_BEGIN_TRY + { + cset = H5Tget_cset(type); + } + H5E_END_TRY; + if (cset > -1) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { - strpad=H5Tget_strpad(type); - } H5E_END_TRY; - if (strpad>-1) { + H5E_BEGIN_TRY + { + strpad = H5Tget_strpad(type); + } + H5E_END_TRY; + if (strpad > -1) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { - ret=H5Tset_sign(type, H5T_SGN_2); - } H5E_END_TRY; - if(ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tset_sign(type, H5T_SGN_2); + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tag = H5Tget_tag(type); - } H5E_END_TRY; + } + H5E_END_TRY; if (tag) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { super = H5Tget_super(type); - } H5E_END_TRY; - if (super>=0) { + } + H5E_END_TRY; + if (super >= 0) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; @@ -4914,11 +5489,13 @@ test_bitfield_funcs(void) retval = 0; error: - if (retval == -1) retval = 1; + if (retval == -1) + retval = 1; H5free_memory(tag); H5Tclose(ntype); H5Tclose(type); - if (retval == 0) PASSED(); + if (retval == 0) + PASSED(); /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); @@ -4928,7 +5505,6 @@ error: return retval; } - /*------------------------------------------------------------------------- * Function: convert_opaque * @@ -4943,16 +5519,15 @@ error: */ static herr_t convert_opaque(hid_t H5_ATTR_UNUSED st, hid_t H5_ATTR_UNUSED dt, H5T_cdata_t *cdata, - size_t H5_ATTR_UNUSED nelmts, size_t H5_ATTR_UNUSED buf_stride, - size_t H5_ATTR_UNUSED bkg_stride, void H5_ATTR_UNUSED *_buf, - void H5_ATTR_UNUSED *bkg, hid_t H5_ATTR_UNUSED dset_xfer_plid) + size_t H5_ATTR_UNUSED nelmts, size_t H5_ATTR_UNUSED buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void H5_ATTR_UNUSED *_buf, void H5_ATTR_UNUSED *bkg, + hid_t H5_ATTR_UNUSED dset_xfer_plid) { - if (H5T_CONV_CONV==cdata->command) + if (H5T_CONV_CONV == cdata->command) num_opaque_conversions_g++; return 0; } - /*------------------------------------------------------------------------- * Function: test_opaque * @@ -4981,17 +5556,16 @@ test_opaque(void) /* Test some type functions with opaque type */ num_errors += opaque_funcs(); - if(num_errors) + if (num_errors) goto error; PASSED(); return 0; - error: +error: return num_errors; } - /*------------------------------------------------------------------------- * Function: opaque_check * @@ -5008,28 +5582,33 @@ static int opaque_check(int tag_it) { #define OPAQUE_NELMTS 1000 - hid_t st=-1, dt=-1; - herr_t status; - char buf[1]; /*not really used*/ - int saved; + hid_t st = -1, dt = -1; + herr_t status; + char buf[1]; /*not really used*/ + int saved; saved = num_opaque_conversions_g = 0; /* Build source and destination types */ - if ((st=H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) goto error; - if (H5Tset_tag(st, "opaque source type") < 0) goto error; + if ((st = H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) + goto error; + if (H5Tset_tag(st, "opaque source type") < 0) + goto error; - if ((dt=H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) goto error; + if ((dt = H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) + goto error; if (tag_it) { if (H5Tset_tag(dt, "opaque destination type") < 0) goto error; } /* Make sure that we can't convert between the types yet */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tconvert(st, dt, (size_t)OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT); - } H5E_END_TRY; - if (status>=0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); HDprintf(" opaque conversion should have failed but succeeded\n"); goto error; @@ -5040,8 +5619,9 @@ opaque_check(int tag_it) goto error; /* Try the conversion again, this time it should work */ - if (H5Tconvert(st, dt, (size_t)OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT) < 0) goto error; - if (saved+1 != num_opaque_conversions_g) { + if (H5Tconvert(st, dt, (size_t)OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT) < 0) + goto error; + if (saved + 1 != num_opaque_conversions_g) { H5_FAILED(); HDprintf(" unexpected number of opaque conversions\n"); goto error; @@ -5055,14 +5635,15 @@ opaque_check(int tag_it) H5Tclose(dt); return 0; - error: - if (st>0) H5Tclose(st); - if (dt>0) H5Tclose(dt); +error: + if (st > 0) + H5Tclose(st); + if (dt > 0) + H5Tclose(dt); H5_FAILED(); return 1; } - /*------------------------------------------------------------------------- * Function: opaque_long * @@ -5079,26 +5660,32 @@ opaque_check(int tag_it) static int opaque_long(void) { - char *long_tag = NULL; - hid_t dt = -1; - herr_t ret; + char * long_tag = NULL; + hid_t dt = -1; + herr_t ret; /* Build opaque type */ - if((dt=H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) TEST_ERROR + if ((dt = H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) + TEST_ERROR /* Create long tag */ - if(NULL == (long_tag = (char *)HDmalloc((size_t)(16384 + 1)))) TEST_ERROR + if (NULL == (long_tag = (char *)HDmalloc((size_t)(16384 + 1)))) + TEST_ERROR HDmemset(long_tag, 'a', (size_t)16384); long_tag[16384] = '\0'; /* Set opaque type's tag */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tset_tag(dt, long_tag); - } H5E_END_TRY; - if(ret != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (ret != FAIL) + TEST_ERROR /* Close datatype */ - if(H5Tclose(dt) < 0) TEST_ERROR + if (H5Tclose(dt) < 0) + TEST_ERROR /* Release memory for tag */ HDfree(long_tag); @@ -5106,15 +5693,14 @@ opaque_long(void) return 0; error: - if(dt>0) + if (dt > 0) H5Tclose(dt); - if(long_tag) + if (long_tag) HDfree(long_tag); H5_FAILED(); return 1; } - /*------------------------------------------------------------------------- * Function: opaque_funcs * @@ -5131,102 +5717,124 @@ error: static int opaque_funcs(void) { - hid_t type = -1, super=-1; - size_t size; - H5T_pad_t inpad; - H5T_cset_t cset; - H5T_str_t strpad; - H5T_sign_t sign; - herr_t ret; + hid_t type = -1, super = -1; + size_t size; + H5T_pad_t inpad; + H5T_cset_t cset; + H5T_str_t strpad; + H5T_sign_t sign; + herr_t ret; /* Build opaque type */ - if ((type=H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) TEST_ERROR - if (H5Tset_tag(type, "opaque source type") < 0) TEST_ERROR + if ((type = H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) + TEST_ERROR + if (H5Tset_tag(type, "opaque source type") < 0) + TEST_ERROR - if ((size=H5Tget_size(type))==0) goto error; + if ((size = H5Tget_size(type)) == 0) + goto error; - H5E_BEGIN_TRY { - ret=H5Tset_precision(type, (size_t)32); - } H5E_END_TRY; - if (ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tset_precision(type, (size_t)32); + } + H5E_END_TRY; + if (ret >= 0) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { - ret=H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE); - } H5E_END_TRY; - if (ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE); + } + H5E_END_TRY; + if (ret >= 0) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { - size=H5Tget_ebias(type); - } H5E_END_TRY; - if (size>0) { + H5E_BEGIN_TRY + { + size = H5Tget_ebias(type); + } + H5E_END_TRY; + if (size > 0) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { - inpad=H5Tget_inpad(type); - } H5E_END_TRY; - if (inpad>-1) { + H5E_BEGIN_TRY + { + inpad = H5Tget_inpad(type); + } + H5E_END_TRY; + if (inpad > -1) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { - cset=H5Tget_cset(type); - } H5E_END_TRY; - if (cset>-1) { + H5E_BEGIN_TRY + { + cset = H5Tget_cset(type); + } + H5E_END_TRY; + if (cset > -1) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { - strpad=H5Tget_strpad(type); - } H5E_END_TRY; - if (strpad>-1) { + H5E_BEGIN_TRY + { + strpad = H5Tget_strpad(type); + } + H5E_END_TRY; + if (strpad > -1) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { - ret=H5Tset_offset(type, (size_t)16); - } H5E_END_TRY; - if (ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tset_offset(type, (size_t)16); + } + H5E_END_TRY; + if (ret >= 0) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { sign = H5Tget_sign(type); - } H5E_END_TRY; - if (sign>-1) { + } + H5E_END_TRY; + if (sign > -1) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { super = H5Tget_super(type); - } H5E_END_TRY; - if (super>=0) { + } + H5E_END_TRY; + if (super >= 0) { HDprintf("Operation not allowed for this type.\n"); TEST_ERROR } /* end if */ /* Close datatype */ - if(H5Tclose(type) < 0) TEST_ERROR + if (H5Tclose(type) < 0) + TEST_ERROR return 0; - error: - if (type>0) H5Tclose(type); +error: + if (type > 0) + H5Tclose(type); return 1; } - /*------------------------------------------------------------------------- * Function: test_encode * @@ -5257,24 +5865,24 @@ test_encode(void) long c; double d; }; - hid_t file=-1, tid1=-1, tid2=-1, tid3=-1; - hid_t decoded_tid1=-1, decoded_tid2=-1, decoded_tid3=-1; - char filename[1024]; - char compnd_type[]="Compound_type", enum_type[]="Enum_type"; - char vlstr_type[]="VLstring_type"; - short enum_val; - size_t cmpd_buf_size = 0; - size_t enum_buf_size = 0; - size_t vlstr_buf_size = 0; - unsigned char *cmpd_buf=NULL, *enum_buf=NULL, *vlstr_buf=NULL; - hid_t ret_id; - herr_t ret; + hid_t file = -1, tid1 = -1, tid2 = -1, tid3 = -1; + hid_t decoded_tid1 = -1, decoded_tid2 = -1, decoded_tid3 = -1; + char filename[1024]; + char compnd_type[] = "Compound_type", enum_type[] = "Enum_type"; + char vlstr_type[] = "VLstring_type"; + short enum_val; + size_t cmpd_buf_size = 0; + size_t enum_buf_size = 0; + size_t vlstr_buf_size = 0; + unsigned char *cmpd_buf = NULL, *enum_buf = NULL, *vlstr_buf = NULL; + hid_t ret_id; + herr_t ret; TESTING("functions of encoding and decoding datatypes"); /* Create File */ h5_fixname(FILENAME[5], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /*----------------------------------------------------------------------- @@ -5282,71 +5890,71 @@ test_encode(void) *----------------------------------------------------------------------- */ /* Create a compound datatype */ - if((tid1=H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) { + if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) { H5_FAILED(); HDprintf("Can't create datatype!\n"); goto error; } /* end if */ - if(H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0) { + if (H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0) { H5_FAILED(); HDprintf("Can't insert field 'a'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0) { + if (H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0) { H5_FAILED(); HDprintf("Can't insert field 'b'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0) { + if (H5Tinsert(tid1, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0) { H5_FAILED(); HDprintf("Can't insert field 'c'\n"); goto error; } /* end if */ - if(H5Tinsert(tid1, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0) { + if (H5Tinsert(tid1, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0) { H5_FAILED(); HDprintf("Can't insert field 'd'\n"); goto error; } /* end if */ /* Create a enumerate datatype */ - if((tid2=H5Tcreate(H5T_ENUM, sizeof(short))) < 0) { + if ((tid2 = H5Tcreate(H5T_ENUM, sizeof(short))) < 0) { H5_FAILED(); HDprintf("Can't create enumerate type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "RED", (enum_val=0,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "RED", (enum_val = 0, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "GREEN", (enum_val=1,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "GREEN", (enum_val = 1, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "BLUE", (enum_val=2,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "BLUE", (enum_val = 2, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "ORANGE", (enum_val=3,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "ORANGE", (enum_val = 3, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ - if(H5Tenum_insert(tid2, "YELLOW", (enum_val=4,&enum_val)) < 0) { + if (H5Tenum_insert(tid2, "YELLOW", (enum_val = 4, &enum_val)) < 0) { H5_FAILED(); HDprintf("Can't insert field into enumeration type\n"); goto error; } /* end if */ /* Create a variable-length string type */ - if((tid3 = H5Tcopy(H5T_C_S1)) < 0) { + if ((tid3 = H5Tcopy(H5T_C_S1)) < 0) { H5_FAILED(); HDprintf("Can't copy a string type\n"); goto error; } /* end if */ - if(H5Tset_size(tid3, H5T_VARIABLE) < 0) { + if (H5Tset_size(tid3, H5T_VARIABLE) < 0) { H5_FAILED(); HDprintf("Can't the string type to be variable-length\n"); goto error; @@ -5357,128 +5965,128 @@ test_encode(void) *----------------------------------------------------------------------- */ /* Encode compound type in a buffer */ - if(H5Tencode(tid1, NULL, &cmpd_buf_size) < 0) { + if (H5Tencode(tid1, NULL, &cmpd_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode compound type\n"); goto error; } /* end if */ - if(cmpd_buf_size>0) - cmpd_buf = (unsigned char*)HDcalloc((size_t)1, cmpd_buf_size); + if (cmpd_buf_size > 0) + cmpd_buf = (unsigned char *)HDcalloc((size_t)1, cmpd_buf_size); /* Try decoding bogus buffer */ - H5E_BEGIN_TRY { - ret_id = H5Tdecode(cmpd_buf); - } H5E_END_TRY; - if(ret_id!=FAIL) { + H5E_BEGIN_TRY + { + ret_id = H5Tdecode(cmpd_buf); + } + H5E_END_TRY; + if (ret_id != FAIL) { H5_FAILED(); HDprintf("Decoded bogus buffer!\n"); goto error; } - if(H5Tencode(tid1, cmpd_buf, &cmpd_buf_size) < 0) { + if (H5Tencode(tid1, cmpd_buf, &cmpd_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode compound type\n"); goto error; } /* end if */ /* Decode from the compound buffer and return an object handle */ - if((decoded_tid1 = H5Tdecode(cmpd_buf)) < 0) + if ((decoded_tid1 = H5Tdecode(cmpd_buf)) < 0) FAIL_PUTS_ERROR("Can't decode compound type\n") /* Verify that the datatype was copied exactly */ - if(H5Tequal(decoded_tid1, tid1)<=0) { + if (H5Tequal(decoded_tid1, tid1) <= 0) { H5_FAILED(); HDprintf("Datatype wasn't encoded & decoded identically\n"); goto error; } /* end if */ /* Query member number and member index by name, for compound type. */ - if(H5Tget_nmembers(decoded_tid1)!=4) { + if (H5Tget_nmembers(decoded_tid1) != 4) { H5_FAILED(); HDprintf("Can't get member number\n"); goto error; } /* end if */ - if(H5Tget_member_index(decoded_tid1, "c")!=2) { + if (H5Tget_member_index(decoded_tid1, "c") != 2) { H5_FAILED(); HDprintf("Can't get correct index number\n"); goto error; } /* end if */ - /* Encode enumerate type in a buffer */ - if(H5Tencode(tid2, NULL, &enum_buf_size) < 0) { + if (H5Tencode(tid2, NULL, &enum_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode enumerate type\n"); goto error; } /* end if */ - if(enum_buf_size>0) - enum_buf = (unsigned char*)HDcalloc((size_t)1, enum_buf_size); + if (enum_buf_size > 0) + enum_buf = (unsigned char *)HDcalloc((size_t)1, enum_buf_size); - if(H5Tencode(tid2, enum_buf, &enum_buf_size) < 0) { + if (H5Tencode(tid2, enum_buf, &enum_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode enumerate type\n"); goto error; } /* end if */ /* Decode from the enumerate buffer and return an object handle */ - if((decoded_tid2=H5Tdecode(enum_buf)) < 0) { + if ((decoded_tid2 = H5Tdecode(enum_buf)) < 0) { H5_FAILED(); HDprintf("Can't decode enumerate type\n"); goto error; } /* end if */ /* Verify that the datatype was copied exactly */ - if(H5Tequal(decoded_tid2, tid2)<=0) { + if (H5Tequal(decoded_tid2, tid2) <= 0) { H5_FAILED(); HDprintf("Datatype wasn't encoded & decoded identically\n"); goto error; } /* end if */ /* Query member number and member index by name, for enumeration type. */ - if(H5Tget_nmembers(decoded_tid2)!=5) { + if (H5Tget_nmembers(decoded_tid2) != 5) { H5_FAILED(); HDprintf("Can't get member number\n"); goto error; } /* end if */ - if(H5Tget_member_index(decoded_tid2, "ORANGE") != 3) { + if (H5Tget_member_index(decoded_tid2, "ORANGE") != 3) { H5_FAILED(); HDprintf("Can't get correct index number\n"); goto error; } /* end if */ - /* Encode VL string type in a buffer */ - if(H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) { + if (H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode VL string type\n"); goto error; } /* end if */ - if(vlstr_buf_size>0) - vlstr_buf = (unsigned char*)HDcalloc((size_t)1, vlstr_buf_size); + if (vlstr_buf_size > 0) + vlstr_buf = (unsigned char *)HDcalloc((size_t)1, vlstr_buf_size); - if(H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) { + if (H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode VL string type\n"); goto error; } /* end if */ /* Decode from the VL string buffer and return an object handle */ - if((decoded_tid3=H5Tdecode(vlstr_buf)) < 0) { + if ((decoded_tid3 = H5Tdecode(vlstr_buf)) < 0) { H5_FAILED(); HDprintf("Can't decode VL string type\n"); goto error; } /* end if */ /* Verify that the datatype was copied exactly */ - if(H5Tequal(decoded_tid3, tid3)<=0) { + if (H5Tequal(decoded_tid3, tid3) <= 0) { H5_FAILED(); HDprintf("Datatype wasn't encoded & decoded identically\n"); goto error; } /* end if */ - if(!H5Tis_variable_str(decoded_tid3)) { + if (!H5Tis_variable_str(decoded_tid3)) { H5_FAILED(); HDprintf("Datatype wasn't encoded & decoded identically\n"); goto error; @@ -5489,17 +6097,17 @@ test_encode(void) *----------------------------------------------------------------------- */ /* Commit compound datatype and close it */ - if(H5Tcommit2(file, compnd_type, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(file, compnd_type, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Can't commit compound datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid1) < 0) { + if (H5Tclose(tid1) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if(H5Tclose(decoded_tid1) < 0) { + if (H5Tclose(decoded_tid1) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; @@ -5508,17 +6116,17 @@ test_encode(void) cmpd_buf_size = 0; /* Commit enumeration datatype and close it */ - if(H5Tcommit2(file, enum_type, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(file, enum_type, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Can't commit compound datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid2) < 0) { + if (H5Tclose(tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if(H5Tclose(decoded_tid2) < 0) { + if (H5Tclose(decoded_tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; @@ -5527,17 +6135,17 @@ test_encode(void) enum_buf_size = 0; /* Commit enumeration datatype and close it */ - if(H5Tcommit2(file, vlstr_type, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { + if (H5Tcommit2(file, vlstr_type, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Can't commit vl string datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid3) < 0) { + if (H5Tclose(tid3) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if(H5Tclose(decoded_tid3) < 0) { + if (H5Tclose(decoded_tid3) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; @@ -5546,11 +6154,11 @@ test_encode(void) vlstr_buf_size = 0; /* Open the dataytpe for query */ - if((tid1 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0) + if ((tid1 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid2 = H5Topen2(file, enum_type, H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(file, enum_type, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid3 = H5Topen2(file, vlstr_type, H5P_DEFAULT)) < 0) + if ((tid3 = H5Topen2(file, vlstr_type, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /*----------------------------------------------------------------------- @@ -5558,104 +6166,104 @@ test_encode(void) *----------------------------------------------------------------------- */ /* Encode compound type in a buffer */ - if(H5Tencode(tid1, NULL, &cmpd_buf_size) < 0) { + if (H5Tencode(tid1, NULL, &cmpd_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode compound type\n"); goto error; } /* end if */ - if(cmpd_buf_size>0) - cmpd_buf = (unsigned char*)HDcalloc((size_t)1, cmpd_buf_size); + if (cmpd_buf_size > 0) + cmpd_buf = (unsigned char *)HDcalloc((size_t)1, cmpd_buf_size); - if(H5Tencode(tid1, cmpd_buf, &cmpd_buf_size) < 0) { + if (H5Tencode(tid1, cmpd_buf, &cmpd_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode compound type\n"); goto error; } /* end if */ /* Decode from the compound buffer and return an object handle */ - if((decoded_tid1 = H5Tdecode(cmpd_buf)) < 0) + if ((decoded_tid1 = H5Tdecode(cmpd_buf)) < 0) FAIL_PUTS_ERROR("Can't decode compound type\n") /* Verify that the datatype was copied exactly */ - if(H5Tequal(decoded_tid1, tid1)<=0) { + if (H5Tequal(decoded_tid1, tid1) <= 0) { H5_FAILED(); HDprintf("Datatype wasn't encoded & decoded identically\n"); goto error; } /* end if */ /* Query member number and member index by name, for compound type. */ - if(H5Tget_nmembers(decoded_tid1)!=4) { + if (H5Tget_nmembers(decoded_tid1) != 4) { H5_FAILED(); HDprintf("Can't get member number\n"); goto error; } /* end if */ - if(H5Tget_member_index(decoded_tid1, "c")!=2) { + if (H5Tget_member_index(decoded_tid1, "c") != 2) { H5_FAILED(); HDprintf("Can't get correct index number\n"); goto error; } /* end if */ /* Encode enumerate type in a buffer */ - if(H5Tencode(tid2, NULL, &enum_buf_size) < 0) { + if (H5Tencode(tid2, NULL, &enum_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode enumerate type\n"); goto error; } /* end if */ - if(enum_buf_size>0) - enum_buf = (unsigned char*)HDcalloc((size_t)1, enum_buf_size); + if (enum_buf_size > 0) + enum_buf = (unsigned char *)HDcalloc((size_t)1, enum_buf_size); - if(H5Tencode(tid2, enum_buf, &enum_buf_size) < 0) { + if (H5Tencode(tid2, enum_buf, &enum_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode enumerate type\n"); goto error; } /* end if */ /* Decode from the enumerate buffer and return an object handle */ - if((decoded_tid2=H5Tdecode(enum_buf)) < 0) { + if ((decoded_tid2 = H5Tdecode(enum_buf)) < 0) { H5_FAILED(); HDprintf("Can't decode enumerate type\n"); goto error; } /* end if */ /* Verify that the datatype was copied exactly */ - if(H5Tequal(decoded_tid2, tid2)<=0) { + if (H5Tequal(decoded_tid2, tid2) <= 0) { H5_FAILED(); HDprintf("Datatype wasn't encoded & decoded identically\n"); goto error; } /* end if */ /* Query member number and member index by name, for enumeration type. */ - if(H5Tget_nmembers(decoded_tid2)!=5) { + if (H5Tget_nmembers(decoded_tid2) != 5) { H5_FAILED(); HDprintf("Can't get member number\n"); goto error; } /* end if */ - if(H5Tget_member_index(decoded_tid2, "ORANGE")!=3) { + if (H5Tget_member_index(decoded_tid2, "ORANGE") != 3) { H5_FAILED(); HDprintf("Can't get correct index number\n"); goto error; } /* end if */ /* Encode VL string type in a buffer */ - if(H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) { + if (H5Tencode(tid3, NULL, &vlstr_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode VL string type\n"); goto error; } /* end if */ - if(vlstr_buf_size > 0) - vlstr_buf = (unsigned char*)HDcalloc((size_t)1, vlstr_buf_size); + if (vlstr_buf_size > 0) + vlstr_buf = (unsigned char *)HDcalloc((size_t)1, vlstr_buf_size); - if(H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) { + if (H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) { H5_FAILED(); HDprintf("Can't encode VL string type\n"); goto error; } /* end if */ /* Decode from the VL string buffer and return an object handle */ - if((decoded_tid3=H5Tdecode(vlstr_buf)) < 0) { + if ((decoded_tid3 = H5Tdecode(vlstr_buf)) < 0) { H5_FAILED(); HDprintf("Can't decode VL string type\n"); goto error; @@ -5663,12 +6271,12 @@ test_encode(void) HDfree(vlstr_buf); /* Verify that the datatype was copied exactly */ - if(H5Tequal(decoded_tid3, tid3)<=0) { + if (H5Tequal(decoded_tid3, tid3) <= 0) { H5_FAILED(); HDprintf("Datatype wasn't encoded & decoded identically\n"); goto error; } /* end if */ - if(!H5Tis_variable_str(decoded_tid3)) { + if (!H5Tis_variable_str(decoded_tid3)) { H5_FAILED(); HDprintf("Datatype wasn't encoded & decoded identically\n"); goto error; @@ -5680,19 +6288,19 @@ test_encode(void) */ /* Make sure the reference counts for the decoded datatypes are one. */ - if(H5Iget_ref(decoded_tid1) != 1) { + if (H5Iget_ref(decoded_tid1) != 1) { H5_FAILED(); HDprintf("Decoded datatype has incorrect reference count\n"); goto error; } /* end if */ - if(H5Iget_ref(decoded_tid2) != 1) { + if (H5Iget_ref(decoded_tid2) != 1) { H5_FAILED(); HDprintf("Decoded datatype has incorrect reference count\n"); goto error; } /* end if */ - if(H5Iget_ref(decoded_tid3) != 1) { + if (H5Iget_ref(decoded_tid3) != 1) { H5_FAILED(); HDprintf("Decoded datatype has incorrect reference count\n"); goto error; @@ -5700,47 +6308,53 @@ test_encode(void) /* Make sure the reference counts for the decoded datatypes can be * decremented and the datatypes are closed. */ - if(H5Idec_ref(decoded_tid1) != 0) { + if (H5Idec_ref(decoded_tid1) != 0) { H5_FAILED(); HDprintf("Decoded datatype can't close\n"); goto error; } /* end if */ - if(H5Idec_ref(decoded_tid2) != 0) { + if (H5Idec_ref(decoded_tid2) != 0) { H5_FAILED(); HDprintf("Decoded datatype can't close\n"); goto error; } /* end if */ - if(H5Idec_ref(decoded_tid3) != 0) { + if (H5Idec_ref(decoded_tid3) != 0) { H5_FAILED(); HDprintf("Decoded datatype can't close\n"); goto error; } /* end if */ /* Make sure the decoded datatypes are already closed. */ - H5E_BEGIN_TRY { - ret = H5Tclose(decoded_tid1); - } H5E_END_TRY; - if(ret!=FAIL) { + H5E_BEGIN_TRY + { + ret = H5Tclose(decoded_tid1); + } + H5E_END_TRY; + if (ret != FAIL) { H5_FAILED(); HDprintf("Decoded datatype should have been closed\n"); goto error; } - H5E_BEGIN_TRY { - ret = H5Tclose(decoded_tid2); - } H5E_END_TRY; - if(ret!=FAIL) { + H5E_BEGIN_TRY + { + ret = H5Tclose(decoded_tid2); + } + H5E_END_TRY; + if (ret != FAIL) { H5_FAILED(); HDprintf("Decoded datatype should have been closed\n"); goto error; } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tclose(decoded_tid3); - } H5E_END_TRY; - if(ret!=FAIL) { + } + H5E_END_TRY; + if (ret != FAIL) { H5_FAILED(); HDprintf("Decoded datatype should have been closed\n"); goto error; @@ -5751,23 +6365,23 @@ test_encode(void) *----------------------------------------------------------------------- */ /* Close datatype and file */ - if(H5Tclose(tid1) < 0) { + if (H5Tclose(tid1) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid2) < 0) { + if (H5Tclose(tid2) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if(H5Tclose(tid3) < 0) { + if (H5Tclose(tid3) < 0) { H5_FAILED(); HDprintf("Can't close datatype\n"); goto error; } /* end if */ - if(H5Fclose(file) < 0) { + if (H5Fclose(file) < 0) { H5_FAILED(); HDprintf("Can't close file\n"); goto error; @@ -5779,20 +6393,21 @@ test_encode(void) PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Tclose (tid1); - H5Tclose (tid2); - H5Tclose (tid3); - H5Tclose (decoded_tid1); - H5Tclose (decoded_tid2); - H5Tclose (decoded_tid3); - H5Fclose (file); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Tclose(tid1); + H5Tclose(tid2); + H5Tclose(tid3); + H5Tclose(decoded_tid1); + H5Tclose(decoded_tid2); + H5Tclose(decoded_tid3); + H5Fclose(file); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_latest * @@ -5816,155 +6431,153 @@ test_latest(void) long c; double d; }; - hid_t file = (-1); /* File ID */ - hid_t tid1 = (-1), tid2 = (-1); /* Datatype ID */ - hid_t fapl = (-1); /* File access property list */ - H5O_native_info_t oi; /* Stat buffer for committed datatype */ - hsize_t old_dtype_oh_size; /* Size of object header with "old" format */ - hsize_t new_dtype_oh_size; /* Size of object header with "new" format */ - char filename[1024]; /* Buffer for filename */ - const char compnd_type[] = "Compound_type"; /* Name of committed datatype */ + hid_t file = (-1); /* File ID */ + hid_t tid1 = (-1), tid2 = (-1); /* Datatype ID */ + hid_t fapl = (-1); /* File access property list */ + H5O_native_info_t oi; /* Stat buffer for committed datatype */ + hsize_t old_dtype_oh_size; /* Size of object header with "old" format */ + hsize_t new_dtype_oh_size; /* Size of object header with "new" format */ + char filename[1024]; /* Buffer for filename */ + const char compnd_type[] = "Compound_type"; /* Name of committed datatype */ TESTING("encoding datatypes with the 'use the latest format' flag"); /* Create a compound datatype */ - if((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) + if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(tid1, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0) FAIL_STACK_ERROR - if(H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0) + if (H5Tinsert(tid1, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0) FAIL_STACK_ERROR - if(H5Tinsert(tid1, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0) + if (H5Tinsert(tid1, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0) FAIL_STACK_ERROR - if(H5Tinsert(tid1, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0) + if (H5Tinsert(tid1, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0) FAIL_STACK_ERROR /* Create file using default FAPL */ h5_fixname(FILENAME[5], H5P_DEFAULT, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Make a copy of the datatype, to commit */ - if((tid2 = H5Tcopy(tid1)) < 0) + if ((tid2 = H5Tcopy(tid1)) < 0) FAIL_STACK_ERROR /* Commit compound datatype */ - if(H5Tcommit2(file, compnd_type, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(file, compnd_type, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Get information about datatype on disk */ - if(H5Oget_native_info_by_name(file, compnd_type, &oi, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) + if (H5Oget_native_info_by_name(file, compnd_type, &oi, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) FAIL_STACK_ERROR old_dtype_oh_size = oi.hdr.space.total; /* Close datatype */ - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Check that datatype has been encoded/decoded correctly */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Open the dataytpe for query */ - if((tid2 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Verify that the datatype was encoded/decoded correctly */ - if(H5Tequal(tid1, tid2) <= 0) + if (H5Tequal(tid1, tid2) <= 0) FAIL_STACK_ERROR /* Get information about datatype on disk */ - if(H5Oget_native_info_by_name(file, compnd_type, &oi, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) + if (H5Oget_native_info_by_name(file, compnd_type, &oi, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Check that the object header info is still the same */ - if(old_dtype_oh_size != oi.hdr.space.total) + if (old_dtype_oh_size != oi.hdr.space.total) TEST_ERROR /* Close datatype */ - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - /* Set the 'use the latest format' bounds in the FAPL */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create file using default FAPL */ h5_fixname(FILENAME[5], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Make a copy of the datatype, to commit */ - if((tid2 = H5Tcopy(tid1)) < 0) + if ((tid2 = H5Tcopy(tid1)) < 0) FAIL_STACK_ERROR /* Commit compound datatype */ - if(H5Tcommit2(file, compnd_type, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(file, compnd_type, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Get information about datatype on disk */ - if(H5Oget_native_info_by_name(file, compnd_type, &oi, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) + if (H5Oget_native_info_by_name(file, compnd_type, &oi, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) FAIL_STACK_ERROR new_dtype_oh_size = oi.hdr.space.total; /* Check that the new format is smaller than the old format */ - if(old_dtype_oh_size <= new_dtype_oh_size) + if (old_dtype_oh_size <= new_dtype_oh_size) TEST_ERROR /* Close datatype */ - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Check that datatype has been encoded/decoded correctly */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Open the dataytpe for query */ - if((tid2 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0) + if ((tid2 = H5Topen2(file, compnd_type, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Verify that the datatype was encoded/decoded correctly */ - if(H5Tequal(tid1, tid2) <= 0) + if (H5Tequal(tid1, tid2) <= 0) FAIL_STACK_ERROR /* Get information about datatype on disk */ - if(H5Oget_native_info_by_name(file, compnd_type, &oi, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) + if (H5Oget_native_info_by_name(file, compnd_type, &oi, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Check that the object header info is still the same */ - if(new_dtype_oh_size != oi.hdr.space.total) + if (new_dtype_oh_size != oi.hdr.space.total) TEST_ERROR /* Close datatype */ - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - /* Close FAPL */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Close datatype */ - if(H5Tclose(tid1) < 0) + if (H5Tclose(tid1) < 0) FAIL_STACK_ERROR PASSED(); @@ -5972,45 +6585,46 @@ test_latest(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid2); H5Tclose(tid1); H5Fclose(file); H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_latest() */ typedef struct { - unsigned num_range_hi; /* Number of H5T_CONV_EXCEPT_RANGE_HI exceptions seen */ - unsigned num_range_low; /* Number of H5T_CONV_EXCEPT_RANGE_LOW exceptions seen */ - unsigned num_precision; /* Number of H5T_CONV_EXCEPT_PRECISION exceptions seen */ - unsigned num_truncate; /* Number of H5T_CONV_EXCEPT_TRUNCATE exceptions seen */ - unsigned num_other; /* Number of other exceptions seen */ + unsigned num_range_hi; /* Number of H5T_CONV_EXCEPT_RANGE_HI exceptions seen */ + unsigned num_range_low; /* Number of H5T_CONV_EXCEPT_RANGE_LOW exceptions seen */ + unsigned num_precision; /* Number of H5T_CONV_EXCEPT_PRECISION exceptions seen */ + unsigned num_truncate; /* Number of H5T_CONV_EXCEPT_TRUNCATE exceptions seen */ + unsigned num_other; /* Number of other exceptions seen */ } except_info_t; static H5T_conv_ret_t conv_except(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5_ATTR_UNUSED dst_id, - void H5_ATTR_UNUSED *src_buf, void H5_ATTR_UNUSED *dst_buf, void *_user_data) + void H5_ATTR_UNUSED *src_buf, void H5_ATTR_UNUSED *dst_buf, void *_user_data) { except_info_t *user_data = (except_info_t *)_user_data; - if(except_type == H5T_CONV_EXCEPT_RANGE_HI) + if (except_type == H5T_CONV_EXCEPT_RANGE_HI) user_data->num_range_hi++; - else if(except_type == H5T_CONV_EXCEPT_RANGE_LOW) + else if (except_type == H5T_CONV_EXCEPT_RANGE_LOW) user_data->num_range_low++; - else if(except_type == H5T_CONV_EXCEPT_PRECISION) + else if (except_type == H5T_CONV_EXCEPT_PRECISION) user_data->num_precision++; - else if(except_type == H5T_CONV_EXCEPT_TRUNCATE) + else if (except_type == H5T_CONV_EXCEPT_TRUNCATE) user_data->num_truncate++; else user_data->num_other++; - return(H5T_CONV_UNHANDLED); + return (H5T_CONV_UNHANDLED); } - /*------------------------------------------------------------------------- * Function: test_int_float_except * @@ -6036,123 +6650,152 @@ conv_except(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5 static int test_int_float_except(void) { -#if H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 - float buf[CONVERT_SIZE] = {(float)INT_MIN - 172.0f, (float)INT_MAX - 32.0f, (float)INT_MAX - 68.0f, (float)4.5f}; - int buf_int[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX-127, 4}; - float buf_float[CONVERT_SIZE] = {(float)INT_MIN, (float)INT_MAX + 1.0f, (float)INT_MAX - 127.0f, 4}; - int *intp; /* Pointer to buffer, as integers */ - int buf2[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 72, 0}; - float buf2_float[CONVERT_SIZE] = {(float)INT_MIN, (float)INT_MAX, (float)INT_MAX - 127.0f, (float)0.0f}; - int buf2_int[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 127, 0}; - float *floatp; /* Pointer to buffer #2, as floats */ - hid_t dxpl; /* Dataset transfer property list */ - except_info_t e; /* Exception information */ - unsigned u; /* Local index variables */ -#endif /* H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 */ +#if H5_SIZEOF_INT == 4 && H5_SIZEOF_FLOAT == 4 + float buf[CONVERT_SIZE] = {(float)INT_MIN - 172.0f, (float)INT_MAX - 32.0f, (float)INT_MAX - 68.0f, + (float)4.5f}; + int buf_int[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 127, 4}; + float buf_float[CONVERT_SIZE] = {(float)INT_MIN, (float)INT_MAX + 1.0f, (float)INT_MAX - 127.0f, 4}; + int * intp; /* Pointer to buffer, as integers */ + int buf2[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 72, 0}; + float buf2_float[CONVERT_SIZE] = {(float)INT_MIN, (float)INT_MAX, (float)INT_MAX - 127.0f, (float)0.0f}; + int buf2_int[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 127, 0}; + float *floatp; /* Pointer to buffer #2, as floats */ + hid_t dxpl; /* Dataset transfer property list */ + except_info_t e; /* Exception information */ + unsigned u; /* Local index variables */ +#endif /* H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 */ TESTING("exceptions for int <-> float conversions"); -#if H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 +#if H5_SIZEOF_INT == 4 && H5_SIZEOF_FLOAT == 4 /* Create dataset transfer property list */ - if((dxpl = H5Pcreate(H5P_DATASET_XFER) ) < 0) TEST_ERROR + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR /* Set the conversion exception handler in the DXPL */ - if(H5Pset_type_conv_cb(dxpl, conv_except, &e) < 0) TEST_ERROR + if (H5Pset_type_conv_cb(dxpl, conv_except, &e) < 0) + TEST_ERROR /* Convert buffer */ HDmemset(&e, 0, sizeof(except_info_t)); - if(H5Tconvert(H5T_NATIVE_FLOAT, H5T_NATIVE_INT, (size_t)CONVERT_SIZE, buf, NULL, dxpl) < 0) TEST_ERROR + if (H5Tconvert(H5T_NATIVE_FLOAT, H5T_NATIVE_INT, (size_t)CONVERT_SIZE, buf, NULL, dxpl) < 0) + TEST_ERROR /* Check the buffer after conversion, as integers */ - for(u = 0; u < CONVERT_SIZE; u++) { + for (u = 0; u < CONVERT_SIZE; u++) { intp = (int *)&buf[u]; - if(*intp != buf_int[u]) TEST_ERROR + if (*intp != buf_int[u]) + TEST_ERROR } /* end for */ /* Check for proper exceptions */ - if(e.num_range_hi != 1) TEST_ERROR - if(e.num_range_low != 1) TEST_ERROR - if(e.num_precision != 0) TEST_ERROR - if(e.num_truncate != 1) TEST_ERROR - if(e.num_other != 0) TEST_ERROR + if (e.num_range_hi != 1) + TEST_ERROR + if (e.num_range_low != 1) + TEST_ERROR + if (e.num_precision != 0) + TEST_ERROR + if (e.num_truncate != 1) + TEST_ERROR + if (e.num_other != 0) + TEST_ERROR /* Convert buffer */ HDmemset(&e, 0, sizeof(except_info_t)); - if(H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_FLOAT, (size_t)CONVERT_SIZE, - buf, NULL, dxpl) < 0) TEST_ERROR + if (H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_FLOAT, (size_t)CONVERT_SIZE, buf, NULL, dxpl) < 0) + TEST_ERROR /* Check the buffer after conversion, as floats */ - for(u = 0; u < CONVERT_SIZE; u++) { + for (u = 0; u < CONVERT_SIZE; u++) { floatp = (float *)&buf[u]; - if(!H5_FLT_ABS_EQUAL(*floatp, buf_float[u])) TEST_ERROR + if (!H5_FLT_ABS_EQUAL(*floatp, buf_float[u])) + TEST_ERROR } /* end for */ /* Check for proper exceptions */ - if(e.num_range_hi != 0) TEST_ERROR - if(e.num_range_low != 0) TEST_ERROR - if(e.num_precision != 1) TEST_ERROR - if(e.num_truncate != 0) TEST_ERROR - if(e.num_other != 0) TEST_ERROR - + if (e.num_range_hi != 0) + TEST_ERROR + if (e.num_range_low != 0) + TEST_ERROR + if (e.num_precision != 1) + TEST_ERROR + if (e.num_truncate != 0) + TEST_ERROR + if (e.num_other != 0) + TEST_ERROR /* Work on second buffer */ /* Convert second buffer */ HDmemset(&e, 0, sizeof(except_info_t)); - if(H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_FLOAT, (size_t)CONVERT_SIZE, buf2, NULL, dxpl) < 0) + if (H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_FLOAT, (size_t)CONVERT_SIZE, buf2, NULL, dxpl) < 0) TEST_ERROR /* Check the buffer after conversion, as floats */ - for(u = 0; u < CONVERT_SIZE; u++) { + for (u = 0; u < CONVERT_SIZE; u++) { floatp = (float *)&buf2[u]; - if(!H5_FLT_ABS_EQUAL(*floatp, buf2_float[u])) TEST_ERROR + if (!H5_FLT_ABS_EQUAL(*floatp, buf2_float[u])) + TEST_ERROR } /* end for */ /* Check for proper exceptions */ - if(e.num_range_hi != 0) TEST_ERROR - if(e.num_range_low != 0) TEST_ERROR - if(e.num_precision != 2) TEST_ERROR - if(e.num_truncate != 0) TEST_ERROR - if(e.num_other != 0) TEST_ERROR + if (e.num_range_hi != 0) + TEST_ERROR + if (e.num_range_low != 0) + TEST_ERROR + if (e.num_precision != 2) + TEST_ERROR + if (e.num_truncate != 0) + TEST_ERROR + if (e.num_other != 0) + TEST_ERROR /* Convert buffer */ HDmemset(&e, 0, sizeof(except_info_t)); - if(H5Tconvert(H5T_NATIVE_FLOAT, H5T_NATIVE_INT, (size_t)CONVERT_SIZE, buf2, NULL, dxpl) < 0) + if (H5Tconvert(H5T_NATIVE_FLOAT, H5T_NATIVE_INT, (size_t)CONVERT_SIZE, buf2, NULL, dxpl) < 0) TEST_ERROR /* Check the buffer after conversion, as integers */ - for(u = 0; u < CONVERT_SIZE; u++) { + for (u = 0; u < CONVERT_SIZE; u++) { intp = (int *)&buf2[u]; - if(*intp != buf2_int[u]) TEST_ERROR + if (*intp != buf2_int[u]) + TEST_ERROR } /* end for */ /* Check for proper exceptions */ - if(e.num_range_hi != 1) TEST_ERROR - if(e.num_range_low != 0) TEST_ERROR - if(e.num_precision != 0) TEST_ERROR - if(e.num_truncate != 0) TEST_ERROR - if(e.num_other != 0) TEST_ERROR + if (e.num_range_hi != 1) + TEST_ERROR + if (e.num_range_low != 0) + TEST_ERROR + if (e.num_precision != 0) + TEST_ERROR + if (e.num_truncate != 0) + TEST_ERROR + if (e.num_other != 0) + TEST_ERROR /* Close DXPL */ - if(H5Pclose(dxpl) < 0) TEST_ERROR + if (H5Pclose(dxpl) < 0) + TEST_ERROR PASSED(); -#else /* H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 */ +#else /* H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 */ SKIPPED(); HDputs(" Test skipped due to int or float not 4 bytes."); #endif /* H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 */ return 0; -#if H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 +#if H5_SIZEOF_INT == 4 && H5_SIZEOF_FLOAT == 4 error: - H5E_BEGIN_TRY { - H5Pclose (dxpl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(dxpl); + } + H5E_END_TRY; return 1; #endif /* H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4 */ } /* end test_int_float_except() */ - /*------------------------------------------------------------------------- * Function: test_set_order * @@ -6170,150 +6813,222 @@ error: static int test_set_order(void) { - hid_t dtype; /* Datatype ID */ - H5T_order_t order; /* Byte order */ - hsize_t dims[2] = {3, 4}; /* Array dimenstions */ - herr_t ret; /* Generic return value */ + hid_t dtype; /* Datatype ID */ + H5T_order_t order; /* Byte order */ + hsize_t dims[2] = {3, 4}; /* Array dimenstions */ + herr_t ret; /* Generic return value */ TESTING("H5Tset/get_order"); /* Integer */ - if ((dtype = H5Tcopy(H5T_STD_I32BE)) < 0) TEST_ERROR - if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + if ((dtype = H5Tcopy(H5T_STD_I32BE)) < 0) + TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) + TEST_ERROR; H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_NONE); + ret = H5Tset_order(dtype, H5T_ORDER_NONE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR - if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) + TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Float */ - if ((dtype = H5Tcopy(H5T_IEEE_F64LE)) < 0) TEST_ERROR - if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + if ((dtype = H5Tcopy(H5T_IEEE_F64LE)) < 0) + TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) + TEST_ERROR; H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_NONE); + ret = H5Tset_order(dtype, H5T_ORDER_NONE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR - if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) + TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Time */ - if ((dtype = H5Tcopy(H5T_UNIX_D64BE)) < 0) TEST_ERROR - if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + if ((dtype = H5Tcopy(H5T_UNIX_D64BE)) < 0) + TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) + TEST_ERROR; H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_NONE); + ret = H5Tset_order(dtype, H5T_ORDER_NONE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR - if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) + TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Fixed length string */ - if ((dtype = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR - if (H5Tset_size(dtype, (size_t)5) < 0) TEST_ERROR - if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR; - if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; + if ((dtype = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR + if (H5Tset_size(dtype, (size_t)5) < 0) + TEST_ERROR + if (H5T_ORDER_NONE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) + TEST_ERROR; + if (H5T_ORDER_NONE != H5Tget_order(dtype)) + TEST_ERROR; /* Variable length string */ - if (H5Tset_size(dtype, H5T_VARIABLE) < 0) TEST_ERROR + if (H5Tset_size(dtype, H5T_VARIABLE) < 0) + TEST_ERROR H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_NONE); + ret = H5Tset_order(dtype, H5T_ORDER_NONE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR - if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) + TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Bitfield */ - if ((dtype = H5Tcopy(H5T_STD_B16LE)) < 0) TEST_ERROR - if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + if ((dtype = H5Tcopy(H5T_STD_B16LE)) < 0) + TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) + TEST_ERROR; H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_NONE); + ret = H5Tset_order(dtype, H5T_ORDER_NONE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR - if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) + TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Opaque - No effect on the order */ - if ((dtype = H5Tcreate(H5T_OPAQUE, (size_t)96)) < 0) TEST_ERROR - if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR - if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if ((dtype = H5Tcreate(H5T_OPAQUE, (size_t)96)) < 0) + TEST_ERROR + if (H5T_ORDER_NONE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) + TEST_ERROR + if (H5T_ORDER_NONE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Compound */ - if ((dtype = H5Tcreate(H5T_COMPOUND, (size_t)48)) < 0) TEST_ERROR + if ((dtype = H5Tcreate(H5T_COMPOUND, (size_t)48)) < 0) + TEST_ERROR H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_BE); + ret = H5Tset_order(dtype, H5T_ORDER_BE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if ((order = H5Tget_order(dtype)) == H5T_ORDER_ERROR) TEST_ERROR - if (order != H5T_ORDER_NONE) TEST_ERROR - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if ((order = H5Tget_order(dtype)) == H5T_ORDER_ERROR) + TEST_ERROR + if (order != H5T_ORDER_NONE) + TEST_ERROR + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Object reference */ - if ((dtype = H5Tcopy(H5T_STD_REF_OBJ)) < 0) TEST_ERROR - if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR; - if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if ((dtype = H5Tcopy(H5T_STD_REF_OBJ)) < 0) + TEST_ERROR + if (H5T_ORDER_NONE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) + TEST_ERROR; + if (H5T_ORDER_NONE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Region reference */ - if ((dtype = H5Tcopy(H5T_STD_REF_DSETREG)) < 0) TEST_ERROR - if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR; - if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if ((dtype = H5Tcopy(H5T_STD_REF_DSETREG)) < 0) + TEST_ERROR + if (H5T_ORDER_NONE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) + TEST_ERROR; + if (H5T_ORDER_NONE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Enum */ - if ((dtype = H5Tenum_create(H5T_STD_I16BE)) < 0) TEST_ERROR - if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + if ((dtype = H5Tenum_create(H5T_STD_I16BE)) < 0) + TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) + TEST_ERROR; H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_NONE); + ret = H5Tset_order(dtype, H5T_ORDER_NONE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR - if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) + TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Vlen */ - if ((dtype = H5Tvlen_create(H5T_STD_U64LE)) < 0) TEST_ERROR - if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + if ((dtype = H5Tvlen_create(H5T_STD_U64LE)) < 0) + TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) + TEST_ERROR; H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_NONE); + ret = H5Tset_order(dtype, H5T_ORDER_NONE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR - if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) + TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR /* Array */ - if ((dtype = H5Tarray_create2(H5T_IEEE_F64BE, 2, dims)) < 0) TEST_ERROR - if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + if ((dtype = H5Tarray_create2(H5T_IEEE_F64BE, 2, dims)) < 0) + TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) + TEST_ERROR; H5E_BEGIN_TRY - ret = H5Tset_order(dtype, H5T_ORDER_NONE); + ret = H5Tset_order(dtype, H5T_ORDER_NONE); H5E_END_TRY - if (ret >= 0) TEST_ERROR - if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR - if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; - if (H5Tclose(dtype) < 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) + TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR PASSED(); return 0; error: H5E_BEGIN_TRY - H5Tclose (dtype); + H5Tclose(dtype); H5E_END_TRY; return 1; } /* end test_set_order() */ - /*------------------------------------------------------------------------- * Function: test_set_order_compound * @@ -6331,127 +7046,157 @@ error: static int test_set_order_compound(hid_t fapl) { - typedef struct { /* Struct with atomic fields */ + typedef struct { /* Struct with atomic fields */ int i; char c; short s; float f; } atomic_cmpd; - typedef struct { /* Struct with complex fields */ + typedef struct { /* Struct with complex fields */ atomic_cmpd a; hvl_t vl; double b[3][4]; atomic_cmpd d[3][4]; } complex_cmpd; - hid_t file = -1; - hid_t cmpd = -1, memb_cmpd = -1, memb_array1 = -1, memb_array2 = -1, cmpd_array = -1; - hid_t vl_id = -1; - hsize_t dims[2] = {3, 4}; /* Array dimenstions */ - char filename[1024]; - herr_t ret; /* Generic return value */ + hid_t file = -1; + hid_t cmpd = -1, memb_cmpd = -1, memb_array1 = -1, memb_array2 = -1, cmpd_array = -1; + hid_t vl_id = -1; + hsize_t dims[2] = {3, 4}; /* Array dimenstions */ + char filename[1024]; + herr_t ret; /* Generic return value */ TESTING("H5Tset/get_order for compound type"); - if((memb_cmpd = H5Tcreate(H5T_COMPOUND, sizeof(atomic_cmpd))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(memb_cmpd, "i", HOFFSET(atomic_cmpd, i), H5T_NATIVE_INT) < 0) FAIL_STACK_ERROR - if(H5Tinsert(memb_cmpd, "c", HOFFSET(atomic_cmpd, c), H5T_NATIVE_CHAR) < 0) FAIL_STACK_ERROR - if(H5Tinsert(memb_cmpd, "s", HOFFSET(atomic_cmpd, s), H5T_NATIVE_SHORT) < 0) FAIL_STACK_ERROR - if(H5Tinsert(memb_cmpd, "f", HOFFSET(atomic_cmpd, f), H5T_NATIVE_FLOAT) < 0) FAIL_STACK_ERROR + if ((memb_cmpd = H5Tcreate(H5T_COMPOUND, sizeof(atomic_cmpd))) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(memb_cmpd, "i", HOFFSET(atomic_cmpd, i), H5T_NATIVE_INT) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(memb_cmpd, "c", HOFFSET(atomic_cmpd, c), H5T_NATIVE_CHAR) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(memb_cmpd, "s", HOFFSET(atomic_cmpd, s), H5T_NATIVE_SHORT) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(memb_cmpd, "f", HOFFSET(atomic_cmpd, f), H5T_NATIVE_FLOAT) < 0) + FAIL_STACK_ERROR /* Set the order to little-endian. */ - if(H5Tset_order(memb_cmpd, H5T_ORDER_BE) < 0) FAIL_STACK_ERROR + if (H5Tset_order(memb_cmpd, H5T_ORDER_BE) < 0) + FAIL_STACK_ERROR /* Create the array datatypes */ memb_array1 = H5Tarray_create2(H5T_NATIVE_DOUBLE, 2, dims); memb_array2 = H5Tarray_create2(memb_cmpd, 2, dims); /* Set the order to big-endian. */ - if(H5Tset_order(memb_array1, H5T_ORDER_LE) < 0) FAIL_STACK_ERROR + if (H5Tset_order(memb_array1, H5T_ORDER_LE) < 0) + FAIL_STACK_ERROR /* Create a variable-length datatype */ - if((vl_id = H5Tvlen_create(H5T_NATIVE_UINT)) < 0) FAIL_STACK_ERROR + if ((vl_id = H5Tvlen_create(H5T_NATIVE_UINT)) < 0) + FAIL_STACK_ERROR /* Create a compound type using the types above. */ - if((cmpd = H5Tcreate(H5T_COMPOUND, sizeof(complex_cmpd))) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd, "a", HOFFSET(complex_cmpd, a), memb_cmpd) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd, "vl_type", HOFFSET(complex_cmpd, vl), vl_id) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd, "b", HOFFSET(complex_cmpd, b), memb_array1) < 0) FAIL_STACK_ERROR - if(H5Tinsert(cmpd, "d", HOFFSET(complex_cmpd, d), memb_array2) < 0) FAIL_STACK_ERROR + if ((cmpd = H5Tcreate(H5T_COMPOUND, sizeof(complex_cmpd))) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(cmpd, "a", HOFFSET(complex_cmpd, a), memb_cmpd) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(cmpd, "vl_type", HOFFSET(complex_cmpd, vl), vl_id) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(cmpd, "b", HOFFSET(complex_cmpd, b), memb_array1) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(cmpd, "d", HOFFSET(complex_cmpd, d), memb_array2) < 0) + FAIL_STACK_ERROR /* The order should be mixed now. */ - if(H5Tget_order(cmpd) != H5T_ORDER_MIXED) FAIL_STACK_ERROR + if (H5Tget_order(cmpd) != H5T_ORDER_MIXED) + FAIL_STACK_ERROR /* Create an array of the compound type above */ cmpd_array = H5Tarray_create2(cmpd, 2, dims); /* The order of the array type should be the same as the compound type */ - if(H5Tget_order(cmpd_array) != H5T_ORDER_MIXED) FAIL_STACK_ERROR + if (H5Tget_order(cmpd_array) != H5T_ORDER_MIXED) + FAIL_STACK_ERROR /* Verify that the order can't be 'none'. */ H5E_BEGIN_TRY - ret = H5Tset_order(cmpd, H5T_ORDER_NONE); + ret = H5Tset_order(cmpd, H5T_ORDER_NONE); H5E_END_TRY - if(ret >= 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR /* Verify that the order can't be 'mixed'. */ H5E_BEGIN_TRY - ret = H5Tset_order(cmpd, H5T_ORDER_MIXED); + ret = H5Tset_order(cmpd, H5T_ORDER_MIXED); H5E_END_TRY - if(ret >= 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR /* Change the order of the compound type to big-endian*/ - if(H5Tset_order(cmpd, H5T_ORDER_BE) < 0) FAIL_STACK_ERROR + if (H5Tset_order(cmpd, H5T_ORDER_BE) < 0) + FAIL_STACK_ERROR /* Verify that the order of the compound type is big-endian */ - if(H5Tget_order(cmpd) != H5T_ORDER_BE) FAIL_STACK_ERROR + if (H5Tget_order(cmpd) != H5T_ORDER_BE) + FAIL_STACK_ERROR /* Change the order of the array type to little-endian*/ - if(H5Tset_order(cmpd_array, H5T_ORDER_LE) < 0) FAIL_STACK_ERROR + if (H5Tset_order(cmpd_array, H5T_ORDER_LE) < 0) + FAIL_STACK_ERROR /* Verify that the order of the array type is little-endian */ - if(H5Tget_order(cmpd_array) != H5T_ORDER_LE) FAIL_STACK_ERROR + if (H5Tget_order(cmpd_array) != H5T_ORDER_LE) + FAIL_STACK_ERROR /* Create file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Commit the data type */ - if(H5Tcommit2(file, "compound", cmpd, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Tcommit2(file, "compound", cmpd, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that committed type can't change order */ H5E_BEGIN_TRY - ret = H5Tset_order(cmpd, H5T_ORDER_LE); + ret = H5Tset_order(cmpd, H5T_ORDER_LE); H5E_END_TRY - if(ret >= 0) TEST_ERROR + if (ret >= 0) + TEST_ERROR - if(H5Tclose(memb_cmpd) < 0) FAIL_STACK_ERROR - if(H5Tclose(memb_array1) < 0) FAIL_STACK_ERROR - if(H5Tclose(memb_array2) < 0) FAIL_STACK_ERROR - if(H5Tclose(vl_id) < 0) FAIL_STACK_ERROR - if(H5Tclose(cmpd) < 0) FAIL_STACK_ERROR - if(H5Tclose(cmpd_array) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Tclose(memb_cmpd) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_array1) < 0) + FAIL_STACK_ERROR + if (H5Tclose(memb_array2) < 0) + FAIL_STACK_ERROR + if (H5Tclose(vl_id) < 0) + FAIL_STACK_ERROR + if (H5Tclose(cmpd) < 0) + FAIL_STACK_ERROR + if (H5Tclose(cmpd_array) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: H5E_BEGIN_TRY - H5Tclose(memb_cmpd); - H5Tclose(memb_array1); - H5Tclose(memb_array2); - H5Tclose(vl_id); - H5Tclose(cmpd); - H5Tclose(cmpd_array); + H5Tclose(memb_cmpd); + H5Tclose(memb_array1); + H5Tclose(memb_array2); + H5Tclose(vl_id); + H5Tclose(cmpd); + H5Tclose(cmpd_array); H5Fclose(file); H5E_END_TRY; return 1; } /* end test_set_order_compound() */ - /*------------------------------------------------------------------------- * Function: test_named_indirect_reopen * @@ -6468,201 +7213,268 @@ error: static int test_named_indirect_reopen(hid_t fapl) { - hid_t file=-1, type=-1, reopened_type=-1, strtype=-1, dset=-1, space=-1; - static hsize_t dims[1] = {3}; - size_t dt_size; - int enum_value; - const char *tag = "opaque_tag"; - char *tag_ret = NULL; - char filename[1024]; + hid_t file = -1, type = -1, reopened_type = -1, strtype = -1, dset = -1, space = -1; + static hsize_t dims[1] = {3}; + size_t dt_size; + int enum_value; + const char * tag = "opaque_tag"; + char * tag_ret = NULL; + char filename[1024]; TESTING("indirectly reopening committed datatypes"); /* Create file, dataspace */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file=H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if ((space = H5Screate_simple (1, dims, dims)) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((space = H5Screate_simple(1, dims, dims)) < 0) + TEST_ERROR /* * Compound */ /* Create compound type */ - if((strtype = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR - if(H5Tset_size(strtype, H5T_VARIABLE) < 0) TEST_ERROR - if((type = H5Tcreate(H5T_COMPOUND, sizeof(char *))) < 0) TEST_ERROR - if(H5Tinsert(type, "vlstr", (size_t)0, strtype) < 0) TEST_ERROR - if(H5Tclose(strtype) < 0) TEST_ERROR + if ((strtype = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR + if (H5Tset_size(strtype, H5T_VARIABLE) < 0) + TEST_ERROR + if ((type = H5Tcreate(H5T_COMPOUND, sizeof(char *))) < 0) + TEST_ERROR + if (H5Tinsert(type, "vlstr", (size_t)0, strtype) < 0) + TEST_ERROR + if (H5Tclose(strtype) < 0) + TEST_ERROR /* Get size of compound type */ - if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR + if ((dt_size = H5Tget_size(type)) == 0) + TEST_ERROR /* Commit compound type and verify the size doesn't change */ - if(H5Tcommit2(file, "cmpd_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(dt_size != H5Tget_size(type)) TEST_ERROR + if (H5Tcommit2(file, "cmpd_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(type)) + TEST_ERROR /* Create dataset with compound type */ - if((dset = H5Dcreate2(file, "cmpd_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dset = H5Dcreate2(file, "cmpd_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Indirectly reopen type and verify that the size doesn't change */ - if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR - if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR + if ((reopened_type = H5Dget_type(dset)) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(reopened_type)) + TEST_ERROR /* Close types and dataset */ - if(H5Tclose(type) < 0) TEST_ERROR - if(H5Tclose(reopened_type) < 0) TEST_ERROR - if(H5Dclose(dset) < 0) TEST_ERROR + if (H5Tclose(type) < 0) + TEST_ERROR + if (H5Tclose(reopened_type) < 0) + TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR /* * Enum */ /* Create enum type */ - if((type = H5Tenum_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((type = H5Tenum_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR enum_value = 0; - if(H5Tenum_insert(type, "val1", &enum_value) < 0) TEST_ERROR + if (H5Tenum_insert(type, "val1", &enum_value) < 0) + TEST_ERROR enum_value = 1; - if(H5Tenum_insert(type, "val2", &enum_value) < 0) TEST_ERROR + if (H5Tenum_insert(type, "val2", &enum_value) < 0) + TEST_ERROR /* Get size of enum type */ - if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR + if ((dt_size = H5Tget_size(type)) == 0) + TEST_ERROR /* Commit enum type and verify the size doesn't change */ - if(H5Tcommit2(file, "enum_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(dt_size != H5Tget_size(type)) TEST_ERROR + if (H5Tcommit2(file, "enum_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(type)) + TEST_ERROR /* Create dataset with enum type */ - if((dset = H5Dcreate2(file, "enum_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dset = H5Dcreate2(file, "enum_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Indirectly reopen type and verify that the size doesn't change */ - if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR - if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR + if ((reopened_type = H5Dget_type(dset)) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(reopened_type)) + TEST_ERROR /* Close types and dataset */ - if(H5Tclose(type) < 0) TEST_ERROR - if(H5Tclose(reopened_type) < 0) TEST_ERROR - if(H5Dclose(dset) < 0) TEST_ERROR + if (H5Tclose(type) < 0) + TEST_ERROR + if (H5Tclose(reopened_type) < 0) + TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR /* * Vlen */ /* Create vlen type */ - if((type = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((type = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* Get size of vlen type */ - if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR + if ((dt_size = H5Tget_size(type)) == 0) + TEST_ERROR /* Commit vlen type and verify the size doesn't change */ - if(H5Tcommit2(file, "vlen_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(dt_size != H5Tget_size(type)) TEST_ERROR + if (H5Tcommit2(file, "vlen_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(type)) + TEST_ERROR /* Create dataset with vlen type */ - if((dset = H5Dcreate2(file, "vlen_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dset = H5Dcreate2(file, "vlen_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Indirectly reopen type and verify that the size doesn't change */ - if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR - if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR + if ((reopened_type = H5Dget_type(dset)) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(reopened_type)) + TEST_ERROR /* Close types and dataset */ - if(H5Tclose(type) < 0) TEST_ERROR - if(H5Tclose(reopened_type) < 0) TEST_ERROR - if(H5Dclose(dset) < 0) TEST_ERROR + if (H5Tclose(type) < 0) + TEST_ERROR + if (H5Tclose(reopened_type) < 0) + TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR /* * Opaque */ /* Create opaque type */ - if((type = H5Tcreate(H5T_OPAQUE, (size_t)13)) < 0) TEST_ERROR - if(H5Tset_tag(type, tag) < 0) TEST_ERROR + if ((type = H5Tcreate(H5T_OPAQUE, (size_t)13)) < 0) + TEST_ERROR + if (H5Tset_tag(type, tag) < 0) + TEST_ERROR /* Get size of opaque type */ - if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR + if ((dt_size = H5Tget_size(type)) == 0) + TEST_ERROR /* Commit opaque type and verify the size and tag don't change */ - if(H5Tcommit2(file, "opaque_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(dt_size != H5Tget_size(type)) TEST_ERROR - if(NULL == (tag_ret = H5Tget_tag(type))) TEST_ERROR - if(HDstrcmp(tag, tag_ret)) TEST_ERROR + if (H5Tcommit2(file, "opaque_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(type)) + TEST_ERROR + if (NULL == (tag_ret = H5Tget_tag(type))) + TEST_ERROR + if (HDstrcmp(tag, tag_ret)) + TEST_ERROR H5free_memory(tag_ret); tag_ret = NULL; /* Create dataset with opaque type */ - if((dset = H5Dcreate2(file, "opaque_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dset = H5Dcreate2(file, "opaque_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Indirectly reopen type and verify that the size and tag don't change */ - if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR - if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR - if(NULL == (tag_ret = H5Tget_tag(type))) TEST_ERROR - if(HDstrcmp(tag, tag_ret)) TEST_ERROR + if ((reopened_type = H5Dget_type(dset)) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(reopened_type)) + TEST_ERROR + if (NULL == (tag_ret = H5Tget_tag(type))) + TEST_ERROR + if (HDstrcmp(tag, tag_ret)) + TEST_ERROR H5free_memory(tag_ret); tag_ret = NULL; /* Close types and dataset */ - if(H5Tclose(type) < 0) TEST_ERROR - if(H5Tclose(reopened_type) < 0) TEST_ERROR - if(H5Dclose(dset) < 0) TEST_ERROR + if (H5Tclose(type) < 0) + TEST_ERROR + if (H5Tclose(reopened_type) < 0) + TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR /* * Array */ /* Create array type */ - if((type = H5Tarray_create2(H5T_NATIVE_INT, 1, dims)) < 0) TEST_ERROR + if ((type = H5Tarray_create2(H5T_NATIVE_INT, 1, dims)) < 0) + TEST_ERROR /* Get size of array type */ - if((dt_size = H5Tget_size(type)) == 0) TEST_ERROR + if ((dt_size = H5Tget_size(type)) == 0) + TEST_ERROR /* Commit array type and verify the size doesn't change */ - if(H5Tcommit2(file, "array_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(dt_size != H5Tget_size(type)) TEST_ERROR + if (H5Tcommit2(file, "array_type", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(type)) + TEST_ERROR /* Create dataset with array type */ - if((dset = H5Dcreate2(file, "array_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dset = H5Dcreate2(file, "array_dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Indirectly reopen type and verify that the size doesn't change */ - if((reopened_type = H5Dget_type(dset)) < 0) TEST_ERROR - if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR + if ((reopened_type = H5Dget_type(dset)) < 0) + TEST_ERROR + if (dt_size != H5Tget_size(reopened_type)) + TEST_ERROR /* Close types and dataset */ - if(H5Tclose(type) < 0) TEST_ERROR - if(H5Tclose(reopened_type) < 0) TEST_ERROR - if(H5Dclose(dset) < 0) TEST_ERROR + if (H5Tclose(type) < 0) + TEST_ERROR + if (H5Tclose(reopened_type) < 0) + TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR /* Close file and dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Sclose(space) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(type); H5Tclose(strtype); H5Tclose(reopened_type); H5Sclose(space); H5Dclose(dset); - H5Fclose(file); - } H5E_END_TRY; - if(tag_ret) + H5Fclose(file); + } + H5E_END_TRY; + if (tag_ret) H5free_memory(tag_ret); return 1; } /* end test_named_indirect_reopen() */ -static void create_del_obj_named_test_file(const char *filename, hid_t fapl, - H5F_libver_t low, H5F_libver_t high) +static void +create_del_obj_named_test_file(const char *filename, hid_t fapl, H5F_libver_t low, H5F_libver_t high) { - hid_t file; /* File ID */ - hid_t type; /* Datatype ID */ - hid_t space; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dset; /* Dataset ID */ - hid_t fcpl; /* File creation property list ID */ - hid_t my_fapl; /* Copy of file access property list ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned use_at_least_v18;/* Whether to use old or new format */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Generic return value */ + hid_t file; /* File ID */ + hid_t type; /* Datatype ID */ + hid_t space; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dset; /* Dataset ID */ + hid_t fcpl; /* File creation property list ID */ + hid_t my_fapl; /* Copy of file access property list ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned use_at_least_v18; /* Whether to use old or new format */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Generic return value */ /* Make copy of FAPL */ my_fapl = H5Pcopy(fapl); @@ -6681,7 +7493,7 @@ static void create_del_obj_named_test_file(const char *filename, hid_t fapl, fcpl = H5Pcreate(H5P_FILE_CREATE); HDassert(fcpl > 0); - if(use_at_least_v18) { + if (use_at_least_v18) { /* Use dense link storage for all links in root group */ status = H5Pset_link_phase_change(fcpl, 0, 0); HDassert(status >= 0); @@ -6715,7 +7527,7 @@ static void create_del_obj_named_test_file(const char *filename, hid_t fapl, dcpl = H5Pcreate(H5P_DATASET_CREATE); HDassert(dcpl > 0); - if(use_at_least_v18) { + if (use_at_least_v18) { /* Use dense attribute storage for all attributes on dataset */ status = H5Pset_attr_phase_change(dcpl, 0, 0); HDassert(status >= 0); @@ -6734,7 +7546,8 @@ static void create_del_obj_named_test_file(const char *filename, hid_t fapl, HDassert(status >= 0); /* Create attribute */ - attr = H5Acreate_by_name(file, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + attr = H5Acreate_by_name(file, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, type, space, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); HDassert(attr > 0); /* Close dataspace */ @@ -6754,7 +7567,6 @@ static void create_del_obj_named_test_file(const char *filename, hid_t fapl, HDassert(status >= 0); } /* end create_del_obj_named_test_file() */ - /*------------------------------------------------------------------------- * Function: test_delete_obj_named * @@ -6772,24 +7584,25 @@ static void create_del_obj_named_test_file(const char *filename, hid_t fapl, static int test_delete_obj_named(hid_t fapl) { - hid_t filea1 = -1, filea2 = -1, fileb = -1; /* File IDs */ - hid_t attr = -1; /* Attribute ID */ - hid_t dset = -1; /* Dataset ID */ - hid_t fapl2 = -1; /* File access property list ID */ - H5F_libver_t low, high; /* File format bounds */ - char filename[1024], filename2[1024]; + hid_t filea1 = -1, filea2 = -1, fileb = -1; /* File IDs */ + hid_t attr = -1; /* Attribute ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fapl2 = -1; /* File access property list ID */ + H5F_libver_t low, high; /* File format bounds */ + char filename[1024], filename2[1024]; TESTING("deleting objects that use named datatypes"); /* Set up filenames & FAPLs */ - if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR h5_fixname(FILENAME[8], fapl, filename, sizeof filename); h5_fixname(FILENAME[9], fapl2, filename2, sizeof filename2); /* Loop through all valid the combinations of low/high library format bounds, to test delete objects that use named datatypes through different file IDs */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Skip invalid low/high combination */ if ((high == H5F_LIBVER_EARLIEST) || (low > high)) @@ -6799,60 +7612,81 @@ test_delete_obj_named(hid_t fapl) create_del_obj_named_test_file(filename, fapl, low, high); /* Test deleting dataset opened through different file ID */ - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if ((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR - if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if ((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + if (H5Fclose(filea1) < 0) + FAIL_STACK_ERROR - if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + if ((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) + FAIL_STACK_ERROR - if(H5Ldelete(filea2, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(filea2, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR - if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + if (H5Fclose(filea2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fileb) < 0) + FAIL_STACK_ERROR /* Create test file, with attribute that uses committed datatype */ create_del_obj_named_test_file(filename, fapl, low, high); /* Test deleting attribute opened through different file ID */ - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - - if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR - - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - - if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR - - if(H5Adelete_by_name(filea2, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - - if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + if ((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if ((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + if ((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Aclose(attr) < 0) + FAIL_STACK_ERROR + + if (H5Fclose(filea1) < 0) + FAIL_STACK_ERROR + + if ((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) + FAIL_STACK_ERROR + + if (H5Adelete_by_name(filea2, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + + if (H5Fclose(filea2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fileb) < 0) + FAIL_STACK_ERROR } /* end high */ - } /* end low */ + } /* end low */ - if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(attr); H5Dclose(dset); H5Pclose(fapl2); H5Fclose(filea1); H5Fclose(filea2); H5Fclose(fileb); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_delete_obj_named() */ - /*------------------------------------------------------------------------- * Function: test_delete_obj_named_fileid * @@ -6870,27 +7704,28 @@ error: static int test_delete_obj_named_fileid(hid_t fapl) { - hid_t filea1 = -1, filea2 = -1, fileb = -1; /* File IDs */ - hid_t dset_fid = -1; /* File ID from dataset */ - hid_t type_fid = -1; /* File ID from datatype */ - hid_t attr_fid = -1; /* File ID from attribute */ - hid_t type = -1; /* Datatype ID */ - hid_t attr = -1; /* Attribute ID */ - hid_t dset = -1; /* Dataset ID */ - hid_t fapl2 = -1; /* File access property list ID */ - H5F_libver_t low, high; /* File format bounds */ - char filename[1024], filename2[1024]; + hid_t filea1 = -1, filea2 = -1, fileb = -1; /* File IDs */ + hid_t dset_fid = -1; /* File ID from dataset */ + hid_t type_fid = -1; /* File ID from datatype */ + hid_t attr_fid = -1; /* File ID from attribute */ + hid_t type = -1; /* Datatype ID */ + hid_t attr = -1; /* Attribute ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fapl2 = -1; /* File access property list ID */ + H5F_libver_t low, high; /* File format bounds */ + char filename[1024], filename2[1024]; TESTING("deleting objects that use named datatypes"); /* Set up filenames & FAPLs */ - if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR h5_fixname(FILENAME[8], fapl, filename, sizeof filename); h5_fixname(FILENAME[9], fapl2, filename2, sizeof filename2); /* Loop through all the combinations of low/high library format bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Skip invalid low/high combination */ if ((high == H5F_LIBVER_EARLIEST) || (low > high)) @@ -6900,111 +7735,146 @@ test_delete_obj_named_fileid(hid_t fapl) create_del_obj_named_test_file(filename, fapl, low, high); /* Test getting file ID for dataset opened through different file ID */ - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR - if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR - if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify file ID from dataset matches correct file */ dset_fid = H5Iget_file_id(dset); - if(!H5F__same_file_test(dset_fid, filea1)) TEST_ERROR + if (!H5F__same_file_test(dset_fid, filea1)) + TEST_ERROR H5Fclose(dset_fid); /* Verify file ID from datatype (from dataset) matches correct file */ - type = H5Dget_type(dset); + type = H5Dget_type(dset); type_fid = H5Iget_file_id(type); - if(!H5F__same_file_test(type_fid, filea1)) TEST_ERROR + if (!H5F__same_file_test(type_fid, filea1)) + TEST_ERROR H5Fclose(type_fid); H5Tclose(type); - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + if (H5Fclose(filea1) < 0) + FAIL_STACK_ERROR - if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + if ((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) + FAIL_STACK_ERROR - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR - if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify file ID from dataset matches correct file */ dset_fid = H5Iget_file_id(dset); - if(!H5F__same_file_test(dset_fid, filea1)) TEST_ERROR + if (!H5F__same_file_test(dset_fid, filea1)) + TEST_ERROR H5Fclose(dset_fid); /* Verify file ID from datatype (from dataset) matches correct file */ - type = H5Dget_type(dset); + type = H5Dget_type(dset); type_fid = H5Iget_file_id(type); - if(!H5F__same_file_test(type_fid, filea1)) TEST_ERROR + if (!H5F__same_file_test(type_fid, filea1)) + TEST_ERROR H5Fclose(type_fid); H5Tclose(type); - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Fclose(filea1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(filea2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fileb) < 0) + FAIL_STACK_ERROR /* Create test file, with attribute that uses committed datatype */ create_del_obj_named_test_file(filename, fapl, low, high); /* Test getting file ID for attribute opened through different file ID */ - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if ((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR - if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify file ID from dataset matches correct file */ attr_fid = H5Iget_file_id(attr); - if(!H5F__same_file_test(attr_fid, filea1)) TEST_ERROR + if (!H5F__same_file_test(attr_fid, filea1)) + TEST_ERROR H5Fclose(attr_fid); /* Verify file ID from datatype (from dataset) matches correct file */ - type = H5Aget_type(attr); + type = H5Aget_type(attr); type_fid = H5Iget_file_id(type); - if(!H5F__same_file_test(type_fid, filea1)) TEST_ERROR + if (!H5F__same_file_test(type_fid, filea1)) + TEST_ERROR H5Fclose(type_fid); H5Tclose(type); - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + if (H5Aclose(attr) < 0) + FAIL_STACK_ERROR - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + if (H5Fclose(filea1) < 0) + FAIL_STACK_ERROR - if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + if ((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) + FAIL_STACK_ERROR - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR - if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify file ID from dataset matches correct file */ attr_fid = H5Iget_file_id(attr); - if(!H5F__same_file_test(attr_fid, filea1)) TEST_ERROR + if (!H5F__same_file_test(attr_fid, filea1)) + TEST_ERROR H5Fclose(attr_fid); /* Verify file ID from datatype (from dataset) matches correct file */ - type = H5Aget_type(attr); + type = H5Aget_type(attr); type_fid = H5Iget_file_id(type); - if(!H5F__same_file_test(type_fid, filea1)) TEST_ERROR + if (!H5F__same_file_test(type_fid, filea1)) + TEST_ERROR H5Fclose(type_fid); H5Tclose(type); - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + if (H5Aclose(attr) < 0) + FAIL_STACK_ERROR - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + if (H5Fclose(filea1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(filea2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fileb) < 0) + FAIL_STACK_ERROR } /* end high */ - } /* end low */ + } /* end low */ - if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(attr); H5Tclose(type); H5Dclose(dset); @@ -7014,11 +7884,11 @@ error: H5Fclose(fileb); H5Fclose(attr_fid); H5Fclose(type_fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_delete_obj_named_fileid() */ - /*------------------------------------------------------------------------- * Function: test_deprec * @@ -7036,138 +7906,160 @@ error: static int test_deprec(hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t type = -1; /* Datatype ID */ - unsigned rank = 2; /* Rank for array datatype */ - hsize_t dims[2] = {3, 3}; /* Dimensions for array datatype */ - int perm[2] = {0, 1}; /* Dimensions permutations for array datatype */ - hsize_t rdims[2]= {0, 0}; /* Dimensions for querying array datatype */ - int rperm[2] = {-2, -2}; /* Dimensions permutations for array datatype */ - hbool_t dim_mismatch; /* Whether any dimensions didn't match */ - char filename[1024]; - unsigned u; /* Local index variable */ - herr_t status; /* Generic routine value */ + hid_t file = -1; /* File ID */ + hid_t type = -1; /* Datatype ID */ + unsigned rank = 2; /* Rank for array datatype */ + hsize_t dims[2] = {3, 3}; /* Dimensions for array datatype */ + int perm[2] = {0, 1}; /* Dimensions permutations for array datatype */ + hsize_t rdims[2] = {0, 0}; /* Dimensions for querying array datatype */ + int rperm[2] = {-2, -2}; /* Dimensions permutations for array datatype */ + hbool_t dim_mismatch; /* Whether any dimensions didn't match */ + char filename[1024]; + unsigned u; /* Local index variable */ + herr_t status; /* Generic routine value */ TESTING("deprected API routines for datatypes"); /* Create an array datatype with an atomic base type */ /* (dimension permutations allowed, but not stored) */ - if((type = H5Tarray_create1(H5T_NATIVE_INT, (int)rank, dims, perm)) < 0) + if ((type = H5Tarray_create1(H5T_NATIVE_INT, (int)rank, dims, perm)) < 0) FAIL_STACK_ERROR /* Make certain that the correct classes can be detected */ - if(H5Tdetect_class(type, H5T_ARRAY) != TRUE) + if (H5Tdetect_class(type, H5T_ARRAY) != TRUE) FAIL_STACK_ERROR - if(H5Tdetect_class(type, H5T_INTEGER) != TRUE) + if (H5Tdetect_class(type, H5T_INTEGER) != TRUE) FAIL_STACK_ERROR /* Get the array dimensions */ /* (Query the dimension permutations, which is allowed, but ignored) */ - if(H5Tget_array_dims1(type, rdims, rperm) < 0) + if (H5Tget_array_dims1(type, rdims, rperm) < 0) FAIL_STACK_ERROR /* Check the array dimensions */ dim_mismatch = FALSE; - for(u = 0; u < rank; u++) - if(rdims[u] != dims[u]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%u]=%d, tdims1[%u]=%d\n", u, (int)rdims[u], u, (int)dims[u]); + for (u = 0; u < rank; u++) + if (rdims[u] != dims[u]) { + TestErrPrintf("Array dimension information doesn't match!, rdims1[%u]=%d, tdims1[%u]=%d\n", u, + (int)rdims[u], u, (int)dims[u]); dim_mismatch = TRUE; } /* end if */ - if(dim_mismatch) - FAIL_PUTS_ERROR(" Dimensions didn't match!") + if (dim_mismatch) + FAIL_PUTS_ERROR(" Dimensions didn't match!") /* Check the array dimension permutations */ dim_mismatch = FALSE; - for(u = 0; u < rank; u++) - if(rperm[u] != -2) { - TestErrPrintf("Array dimension permutation information was modified!, rdims1[%u]=%d, tdims1[%u]=%d\n", u, rperm[u], u, perm[u]); + for (u = 0; u < rank; u++) + if (rperm[u] != -2) { + TestErrPrintf( + "Array dimension permutation information was modified!, rdims1[%u]=%d, tdims1[%u]=%d\n", u, + rperm[u], u, perm[u]); dim_mismatch = TRUE; } /* end if */ - if(dim_mismatch) - FAIL_PUTS_ERROR(" Dimension permutations modified!") + if (dim_mismatch) + FAIL_PUTS_ERROR(" Dimension permutations modified!") /* Close the datatype */ - if(H5Tclose(type) < 0) + if (H5Tclose(type) < 0) FAIL_STACK_ERROR - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Predefined types cannot be committed */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tcommit1(file, "test_named_1 (should not exist)", H5T_NATIVE_INT); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) FAIL_PUTS_ERROR(" Predefined types should not be committable!") /* Copy a predefined datatype and commit the copy */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR - if(H5Tcommit1(file, "native-int", type) < 0) FAIL_STACK_ERROR - if((status = H5Tcommitted(type)) < 0) FAIL_STACK_ERROR - if(0 == status) + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR + if (H5Tcommit1(file, "native-int", type) < 0) + FAIL_STACK_ERROR + if ((status = H5Tcommitted(type)) < 0) + FAIL_STACK_ERROR + if (0 == status) FAIL_PUTS_ERROR(" H5Tcommitted() returned false!") /* We should not be able to modify a type after it has been committed. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tset_precision(type, (size_t)256); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) FAIL_PUTS_ERROR(" Committed type is not constant!") /* We should not be able to re-commit a committed type */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tcommit1(file, "test_named_2 (should not exist)", type); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) FAIL_PUTS_ERROR(" Committed types should not be recommitted!") /* * Close the committed type and reopen it. It should return a named type. */ - if(H5Tclose(type) < 0) FAIL_STACK_ERROR - if((type = H5Topen1(file, "native-int")) < 0) FAIL_STACK_ERROR - if((status = H5Tcommitted(type)) < 0) FAIL_STACK_ERROR - if(!status) + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR + if ((type = H5Topen1(file, "native-int")) < 0) + FAIL_STACK_ERROR + if ((status = H5Tcommitted(type)) < 0) + FAIL_STACK_ERROR + if (!status) FAIL_PUTS_ERROR(" Opened named types should be named types!") /* Close */ - if(H5Tclose(type) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Reopen file with read only access */ if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) goto error; /* Verify that H5Tcommit2 returns an error */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - H5E_BEGIN_TRY { + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + goto error; + H5E_BEGIN_TRY + { status = H5Tcommit1(file, "test_named_3 (should not exist)", type); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); - HDputs (" Types should not be committable to a read-only file!"); + HDputs(" Types should not be committable to a read-only file!"); goto error; } /* Close */ - if(H5Tclose(type) < 0) goto error; - if(H5Fclose(file) < 0) goto error; + if (H5Tclose(type) < 0) + goto error; + if (H5Fclose(file) < 0) + goto error; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(type); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_deprec() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: test_utf_ascii_conv * @@ -7184,20 +8076,20 @@ error: static int test_utf_ascii_conv(void) { - hid_t fid = -1; - hid_t did = -1; - hid_t utf8_vtid = -1; - hid_t ascii_vtid = -1; - hid_t utf8_tid = -1; - hid_t ascii_tid = -1; - hid_t sid = -1; - const char *utf8_w = "foo!"; - char *ascii_r = NULL; - const char *ascii_w = "bar!"; - char *utf8_r = NULL; + hid_t fid = -1; + hid_t did = -1; + hid_t utf8_vtid = -1; + hid_t ascii_vtid = -1; + hid_t utf8_tid = -1; + hid_t ascii_tid = -1; + hid_t sid = -1; + const char *utf8_w = "foo!"; + char * ascii_r = NULL; + const char *ascii_w = "bar!"; + char * utf8_r = NULL; char filename[1024]; - char ascii2[4], utf8_2[4]; - herr_t status; + char ascii2[4], utf8_2[4]; + herr_t status; TESTING("string conversion between ASCII and UTF"); @@ -7205,168 +8097,217 @@ test_utf_ascii_conv(void) * Test VL string conversion from UTF8 to ASCII ************************************************/ /* Create a variable-length string */ - if((utf8_vtid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR + if ((utf8_vtid = H5Tcopy(H5T_C_S1)) < 0) + FAIL_STACK_ERROR - if((status = H5Tset_size(utf8_vtid, H5T_VARIABLE)) < 0) FAIL_STACK_ERROR + if ((status = H5Tset_size(utf8_vtid, H5T_VARIABLE)) < 0) + FAIL_STACK_ERROR /* Set the character set for the string to UTF-8 */ - if((status = H5Tset_cset(utf8_vtid, H5T_CSET_UTF8)) < 0) FAIL_STACK_ERROR + if ((status = H5Tset_cset(utf8_vtid, H5T_CSET_UTF8)) < 0) + FAIL_STACK_ERROR /* Create a variable-length string */ - if((ascii_vtid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR + if ((ascii_vtid = H5Tcopy(H5T_C_S1)) < 0) + FAIL_STACK_ERROR - if((status = H5Tset_size(ascii_vtid, H5T_VARIABLE)) < 0) FAIL_STACK_ERROR + if ((status = H5Tset_size(ascii_vtid, H5T_VARIABLE)) < 0) + FAIL_STACK_ERROR /* Set the character set for the string to ASCII (should already be so) */ - if((status = H5Tset_cset(ascii_vtid, H5T_CSET_ASCII) < 0)) FAIL_STACK_ERROR + if ((status = H5Tset_cset(ascii_vtid, H5T_CSET_ASCII) < 0)) + FAIL_STACK_ERROR /* Test conversion in memory */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tconvert(utf8_vtid, ascii_vtid, 1, &utf8_w, NULL, H5P_DEFAULT); - } H5E_END_TRY - if(status >= 0) + } + H5E_END_TRY + if (status >= 0) FAIL_STACK_ERROR /* Create a file */ h5_fixname(FILENAME[10], H5P_DEFAULT, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a scalar dataspace for the dataset */ - if((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR /* Create a dataset of UTF8 string type */ - if((did = H5Dcreate2(fid, UTF8_DATASET, utf8_vtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did = H5Dcreate2(fid, UTF8_DATASET, utf8_vtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Write the UTF8 string, as UTF8 */ - if((status = H5Dwrite(did, utf8_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_w)) < 0) FAIL_STACK_ERROR + if ((status = H5Dwrite(did, utf8_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_w)) < 0) + FAIL_STACK_ERROR /* Read the UTF8 string, as ASCII, supposed to fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Dread(did, ascii_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii_r); - } H5E_END_TRY - if(status >= 0) + } + H5E_END_TRY + if (status >= 0) FAIL_STACK_ERROR /* Close the dataset */ - if((status = H5Dclose(did)) < 0) FAIL_STACK_ERROR + if ((status = H5Dclose(did)) < 0) + FAIL_STACK_ERROR /************************************************ * Test VL string conversion from ASCII to UTF8 ************************************************/ /* Test conversion in memory */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tconvert(ascii_vtid, utf8_vtid, 1, &ascii_w, NULL, H5P_DEFAULT); - } H5E_END_TRY - if(status >= 0) + } + H5E_END_TRY + if (status >= 0) FAIL_STACK_ERROR /* Create a dataset of ASCII string type */ - if((did = H5Dcreate2(fid, ASCII_DATASET, ascii_vtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did = H5Dcreate2(fid, ASCII_DATASET, ascii_vtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Write the ASCII string, as ASCII */ - if((status = H5Dwrite(did, ascii_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii_w)) < 0) FAIL_STACK_ERROR + if ((status = H5Dwrite(did, ascii_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii_w)) < 0) + FAIL_STACK_ERROR /* Read the ASCII string, as UTF8, supposed to fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Dread(did, utf8_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_r); - } H5E_END_TRY - if(status >= 0) + } + H5E_END_TRY + if (status >= 0) FAIL_STACK_ERROR /* Close the dataset */ - if((status = H5Dclose(did)) < 0) FAIL_STACK_ERROR + if ((status = H5Dclose(did)) < 0) + FAIL_STACK_ERROR /* Close the UTF8 VL-string datatype */ - if((status = H5Tclose(utf8_vtid)) < 0) FAIL_STACK_ERROR + if ((status = H5Tclose(utf8_vtid)) < 0) + FAIL_STACK_ERROR /* Close the ASCII VL-string datatype */ - if((status = H5Tclose(ascii_vtid)) < 0) FAIL_STACK_ERROR + if ((status = H5Tclose(ascii_vtid)) < 0) + FAIL_STACK_ERROR /********************************************************** * Test fixed-length string conversion from UTF8 to ASCII **********************************************************/ /* Create a fixed-length UTF8 string */ - if((utf8_tid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR + if ((utf8_tid = H5Tcopy(H5T_C_S1)) < 0) + FAIL_STACK_ERROR - if((status = H5Tset_size(utf8_tid, 4)) < 0) FAIL_STACK_ERROR + if ((status = H5Tset_size(utf8_tid, 4)) < 0) + FAIL_STACK_ERROR /* Set the character set for the string to UTF-8 */ - if((status = H5Tset_cset(utf8_tid, H5T_CSET_UTF8)) < 0) FAIL_STACK_ERROR + if ((status = H5Tset_cset(utf8_tid, H5T_CSET_UTF8)) < 0) + FAIL_STACK_ERROR /* Create a fixed-length ASCII string */ - if((ascii_tid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR + if ((ascii_tid = H5Tcopy(H5T_C_S1)) < 0) + FAIL_STACK_ERROR - if((status = H5Tset_size(ascii_tid, 4)) < 0) FAIL_STACK_ERROR + if ((status = H5Tset_size(ascii_tid, 4)) < 0) + FAIL_STACK_ERROR /* Set the character set for the string to ASCII (should already be so) */ - if((status = H5Tset_cset(ascii_tid, H5T_CSET_ASCII) < 0)) FAIL_STACK_ERROR + if ((status = H5Tset_cset(ascii_tid, H5T_CSET_ASCII) < 0)) + FAIL_STACK_ERROR /* Test conversion in memory */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tconvert(utf8_tid, ascii_tid, 1, utf8_2, NULL, H5P_DEFAULT); - } H5E_END_TRY - if(status >= 0) + } + H5E_END_TRY + if (status >= 0) FAIL_STACK_ERROR /* Create a dataset */ - if((did = H5Dcreate2(fid, UTF8_DATASET2, utf8_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did = H5Dcreate2(fid, UTF8_DATASET2, utf8_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Write the UTF8 string, as UTF8 */ - if((status = H5Dwrite(did, utf8_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_w)) < 0) FAIL_STACK_ERROR + if ((status = H5Dwrite(did, utf8_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_w)) < 0) + FAIL_STACK_ERROR /* Read the UTF8 string as ASCII, supposed to fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Dread(did, ascii_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii2); - } H5E_END_TRY - if(status >= 0) + } + H5E_END_TRY + if (status >= 0) FAIL_STACK_ERROR /* Close the dataset */ - if((status = H5Dclose(did)) < 0) FAIL_STACK_ERROR + if ((status = H5Dclose(did)) < 0) + FAIL_STACK_ERROR /********************************************************** * Test fixed-length string conversion from ASCII to UTF8 **********************************************************/ /* Test conversion in memory */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tconvert(ascii_tid, utf8_tid, 1, ascii2, NULL, H5P_DEFAULT); - } H5E_END_TRY - if(status >= 0) + } + H5E_END_TRY + if (status >= 0) FAIL_STACK_ERROR /* Create a dataset */ - if((did = H5Dcreate2(fid, ASCII_DATASET2, ascii_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did = H5Dcreate2(fid, ASCII_DATASET2, ascii_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Write the ASCII string, as ASCII */ - if((status = H5Dwrite(did, ascii_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii_w)) < 0) FAIL_STACK_ERROR + if ((status = H5Dwrite(did, ascii_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii_w)) < 0) + FAIL_STACK_ERROR /* Read the UTF8 string as ASCII, supposed to fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Dread(did, utf8_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_2); - } H5E_END_TRY - if(status >= 0) + } + H5E_END_TRY + if (status >= 0) FAIL_STACK_ERROR /* Close the dataset */ - if((status = H5Dclose(did)) < 0) FAIL_STACK_ERROR + if ((status = H5Dclose(did)) < 0) + FAIL_STACK_ERROR /* Close the UTF8 string datatype */ - if((status = H5Tclose(utf8_tid)) < 0) FAIL_STACK_ERROR + if ((status = H5Tclose(utf8_tid)) < 0) + FAIL_STACK_ERROR /* Close the ASCII string datatype */ - if((status = H5Tclose(ascii_tid)) < 0) FAIL_STACK_ERROR + if ((status = H5Tclose(ascii_tid)) < 0) + FAIL_STACK_ERROR /* Close the dataspace */ - if((status = H5Sclose(sid)) < 0) FAIL_STACK_ERROR + if ((status = H5Sclose(sid)) < 0) + FAIL_STACK_ERROR /* Close the file */ - if((status = H5Fclose(fid)) < 0) FAIL_STACK_ERROR + if ((status = H5Fclose(fid)) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(utf8_vtid); H5Tclose(ascii_vtid); H5Tclose(utf8_tid); @@ -7374,7 +8315,8 @@ error: H5Dclose(did); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -7395,125 +8337,132 @@ error: * the library will only use basic version * *************************************************************************/ -static herr_t verify_version(hid_t dtype, H5F_libver_t low, unsigned *highest_version) +static herr_t +verify_version(hid_t dtype, H5F_libver_t low, unsigned *highest_version) { - hid_t base_dtype = -1; - hid_t mem_dtype = -1; - H5T_t *dtypep = NULL; /* Internal structure of a datatype */ - H5T_class_t type_cls = H5T_NO_CLASS; /* Temporary var for datatype class */ - int nmembers = 0; - unsigned i; - herr_t ret = SUCCEED; /* Generic return value */ + hid_t base_dtype = -1; + hid_t mem_dtype = -1; + H5T_t * dtypep = NULL; /* Internal structure of a datatype */ + H5T_class_t type_cls = H5T_NO_CLASS; /* Temporary var for datatype class */ + int nmembers = 0; + unsigned i; + herr_t ret = SUCCEED; /* Generic return value */ dtypep = (H5T_t *)H5I_object(dtype); - if (dtypep == NULL) TEST_ERROR + if (dtypep == NULL) + TEST_ERROR /* Carry out the verification according to the class of the datatype. For compound datatype, its members will be verified, recursively. For array datatype, its element datatype will be verified, recursively.*/ type_cls = dtypep->shared->type; - switch (type_cls) - { - case H5T_ARRAY: - { - H5T_t *base_dtypep = NULL; /* Internal structure of a datatype */ - - if (low == H5F_LIBVER_EARLIEST) - VERIFY(dtypep->shared->version, H5O_DTYPE_VERSION_2, "H5O_dtype_ver_bounds"); - else - VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[low], "H5O_dtype_ver_bounds"); - - /* Get the base datatype of this array type */ - base_dtype = H5Tget_super(dtype); - CHECK(base_dtype, FAIL, "H5Tget_super"); - - /* Get the base type's internal structure for version */ - base_dtypep = (H5T_t *)H5I_object(base_dtype); - if (base_dtypep == NULL) TEST_ERROR - - /* Reset highest version if this datatype has higher version than - its outer type */ - if (*highest_version < base_dtypep->shared->version) - *highest_version = base_dtypep->shared->version; - - /* Verify the base datatype recursively */ - ret = verify_version(base_dtype, low, highest_version); - - /* Close the member datatype before checking for failure */ - if ((H5Tclose(base_dtype)) < 0) TEST_ERROR + switch (type_cls) { + case H5T_ARRAY: { + H5T_t *base_dtypep = NULL; /* Internal structure of a datatype */ - /* Check if verify_version fails */ - if (ret < 0) TEST_ERROR + if (low == H5F_LIBVER_EARLIEST) + VERIFY(dtypep->shared->version, H5O_DTYPE_VERSION_2, "H5O_dtype_ver_bounds"); + else + VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[low], "H5O_dtype_ver_bounds"); - break; - } - case H5T_COMPOUND: - { - H5T_t *mem_dtypep = NULL; /* Internal structure of a datatype */ - /* Get the number of members of this compound type */ - if ((nmembers = H5Tget_nmembers(dtype)) < 0) TEST_ERROR + /* Get the base datatype of this array type */ + base_dtype = H5Tget_super(dtype); + CHECK(base_dtype, FAIL, "H5Tget_super"); - /* Go through all its member datatypes */ - for (i = 0; i < (unsigned)nmembers; i++) - { - /* Get the member datatype to verify it recursively */ - mem_dtype = H5Tget_member_type(dtype, i); - if (mem_dtype < 0) TEST_ERROR - - /* Get the member type's internal structure for version */ - mem_dtypep = (H5T_t *)H5I_object(mem_dtype); - if (mem_dtypep == NULL) TEST_ERROR + /* Get the base type's internal structure for version */ + base_dtypep = (H5T_t *)H5I_object(base_dtype); + if (base_dtypep == NULL) + TEST_ERROR /* Reset highest version if this datatype has higher version than its outer type */ - if (*highest_version < mem_dtypep->shared->version) - *highest_version = mem_dtypep->shared->version; + if (*highest_version < base_dtypep->shared->version) + *highest_version = base_dtypep->shared->version; - /* Verify the datatype recursively */ - ret = verify_version(mem_dtype, low, highest_version); + /* Verify the base datatype recursively */ + ret = verify_version(base_dtype, low, highest_version); /* Close the member datatype before checking for failure */ - if ((H5Tclose(mem_dtype)) < 0) TEST_ERROR + if ((H5Tclose(base_dtype)) < 0) + TEST_ERROR /* Check if verify_version fails */ - if (ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR + + break; + } + case H5T_COMPOUND: { + H5T_t *mem_dtypep = NULL; /* Internal structure of a datatype */ + /* Get the number of members of this compound type */ + if ((nmembers = H5Tget_nmembers(dtype)) < 0) + TEST_ERROR + + /* Go through all its member datatypes */ + for (i = 0; i < (unsigned)nmembers; i++) { + /* Get the member datatype to verify it recursively */ + mem_dtype = H5Tget_member_type(dtype, i); + if (mem_dtype < 0) + TEST_ERROR + + /* Get the member type's internal structure for version */ + mem_dtypep = (H5T_t *)H5I_object(mem_dtype); + if (mem_dtypep == NULL) + TEST_ERROR + + /* Reset highest version if this datatype has higher version than + its outer type */ + if (*highest_version < mem_dtypep->shared->version) + *highest_version = mem_dtypep->shared->version; + + /* Verify the datatype recursively */ + ret = verify_version(mem_dtype, low, highest_version); + + /* Close the member datatype before checking for failure */ + if ((H5Tclose(mem_dtype)) < 0) + TEST_ERROR + + /* Check if verify_version fails */ + if (ret < 0) + TEST_ERROR + } + /* If this compound datatype contains a datatype of higher version, it + will be promoted to that version, thus, verify with highest version */ + if (*highest_version > H5O_dtype_ver_bounds[low]) + VERIFY(dtypep->shared->version, *highest_version, "verify_version"); + else + VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[low], "verify_version"); + break; } - /* If this compound datatype contains a datatype of higher version, it - will be promoted to that version, thus, verify with highest version */ - if (*highest_version > H5O_dtype_ver_bounds[low]) - VERIFY(dtypep->shared->version, *highest_version, "verify_version"); - else + case H5T_ENUM: VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[low], "verify_version"); - break; - } - case H5T_ENUM: - VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[low], "verify_version"); - break; - case H5T_VLEN: - case H5T_FLOAT: - case H5T_INTEGER: - VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "verify_version"); - break; - case H5T_NCLASSES: - case H5T_NO_CLASS: - case H5T_TIME: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_REFERENCE: - default: - TEST_ERROR + break; + case H5T_VLEN: + case H5T_FLOAT: + case H5T_INTEGER: + VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "verify_version"); + break; + case H5T_NCLASSES: + case H5T_NO_CLASS: + case H5T_TIME: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_REFERENCE: + default: + TEST_ERROR } /* end switch */ error: - H5E_BEGIN_TRY { - H5Tclose(base_dtype); - H5Tclose(mem_dtype); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Tclose(base_dtype); + H5Tclose(mem_dtype); + } + H5E_END_TRY; return ret; } /* end of verify_version */ - /*------------------------------------------------------------------------- * Function: test_versionbounds * @@ -7538,139 +8487,162 @@ error: * *------------------------------------------------------------------------- */ -#define VERFNAME "tverbounds_dtype.h5" -#define VERDSNAME "dataset 1" -#define ARRAY_RANK 1 -#define ARRAY_LEN 10 +#define VERFNAME "tverbounds_dtype.h5" +#define VERDSNAME "dataset 1" +#define ARRAY_RANK 1 +#define ARRAY_LEN 10 static int test_versionbounds(void) { - typedef struct { /* Struct for the simple compound type */ - int single_int; + typedef struct { /* Struct for the simple compound type */ + int single_int; char char_arr[ARRAY_LEN]; } simple_cmp_t; - typedef struct { /* Struct for the inner compound type */ + typedef struct { /* Struct for the inner compound type */ simple_cmp_t inner_arr[ARRAY_LEN]; - hvl_t vlen_float; + hvl_t vlen_float; } inner_cmp_t; - typedef struct { /* Struct for the outer compound type */ + typedef struct { /* Struct for the outer compound type */ inner_cmp_t inner_cmp; - color_t enum_color; + color_t enum_color; } outer_cmp_t; - hid_t file = -1; /* File ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t fapl = -1; /* Copy of file access property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t dset_dtype = -1; /* Dataset's datatype */ - hid_t arr_chartype = -1; /* Array of characters datatype */ - hid_t vlen_floattype = -1; /* Vlen of float datatype */ - hid_t enum_type = -1; /* Enumeration datatype */ - hid_t outer_cmp_type = -1; /* Outer compound datatype */ - hid_t inner_cmp_type = -1; /* Inner compound datatype */ - hid_t simple_cmp_type = -1;/* Simple cmpd dtype, contains no other cmpd */ - hid_t outer_arr_type = -1; /* Outermost array datatype */ - hid_t inner_arr_type = -1; /* Inner array datatype */ - H5F_t *filep = NULL; /* Pointer to internal structure of a file */ - H5T_t *dtypep = NULL; /* Pointer to internal structure of a datatype */ - hsize_t arr_dim[] = {ARRAY_LEN}; /* Length of the array */ - int low, high; /* Indices for iterating over versions */ - H5F_libver_t versions[] = {H5F_LIBVER_EARLIEST, H5F_LIBVER_V18, H5F_LIBVER_V110, H5F_LIBVER_V112, H5F_LIBVER_V114}; - int versions_count = 5; /* Number of version bounds in the array */ - unsigned highest_version; /* Highest version in nested datatypes */ - color_t enum_val; /* Enum type index */ - herr_t ret = 0; /* Generic return value */ + hid_t file = -1; /* File ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl = -1; /* Copy of file access property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t dset_dtype = -1; /* Dataset's datatype */ + hid_t arr_chartype = -1; /* Array of characters datatype */ + hid_t vlen_floattype = -1; /* Vlen of float datatype */ + hid_t enum_type = -1; /* Enumeration datatype */ + hid_t outer_cmp_type = -1; /* Outer compound datatype */ + hid_t inner_cmp_type = -1; /* Inner compound datatype */ + hid_t simple_cmp_type = -1; /* Simple cmpd dtype, contains no other cmpd */ + hid_t outer_arr_type = -1; /* Outermost array datatype */ + hid_t inner_arr_type = -1; /* Inner array datatype */ + H5F_t * filep = NULL; /* Pointer to internal structure of a file */ + H5T_t * dtypep = NULL; /* Pointer to internal structure of a datatype */ + hsize_t arr_dim[] = {ARRAY_LEN}; /* Length of the array */ + int low, high; /* Indices for iterating over versions */ + H5F_libver_t versions[] = {H5F_LIBVER_EARLIEST, H5F_LIBVER_V18, H5F_LIBVER_V110, H5F_LIBVER_V112, + H5F_LIBVER_V114}; + int versions_count = 5; /* Number of version bounds in the array */ + unsigned highest_version; /* Highest version in nested datatypes */ + color_t enum_val; /* Enum type index */ + herr_t ret = 0; /* Generic return value */ TESTING("version bounds with nested datatypes"); /* Create a file access property list */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR /* Create a file creation property list */ - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR /* Create a scalar dataspace */ - if ((space = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR + if ((space = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR /* Create a dataset creation property list */ - if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR /* Create an array datatype of chars */ arr_chartype = H5Tarray_create2(H5T_NATIVE_CHAR, ARRAY_RANK, arr_dim); - if (arr_chartype < 0) TEST_ERROR + if (arr_chartype < 0) + TEST_ERROR /* Create the simple compound datatype that has an integer and an array of chars */ simple_cmp_type = H5Tcreate(H5T_COMPOUND, sizeof(simple_cmp_t)); - if (simple_cmp_type < 0) TEST_ERROR + if (simple_cmp_type < 0) + TEST_ERROR /* Insert integer field */ ret = H5Tinsert(simple_cmp_type, "single_int", HOFFSET(simple_cmp_t, single_int), H5T_NATIVE_INT); - if (ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR /* Insert array field */ ret = H5Tinsert(simple_cmp_type, "char_arr", HOFFSET(simple_cmp_t, char_arr), arr_chartype); - if (ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR /* Create an array datatype containing simple compound datatype */ inner_arr_type = H5Tarray_create2(simple_cmp_type, ARRAY_RANK, arr_dim); - if (inner_arr_type < 0) TEST_ERROR + if (inner_arr_type < 0) + TEST_ERROR /* Create a VL datatype of floats */ vlen_floattype = H5Tvlen_create(H5T_NATIVE_FLOAT); - if (vlen_floattype < 0) TEST_ERROR + if (vlen_floattype < 0) + TEST_ERROR /* Create the innermost compound datatype that houses inner_arr_type and vlen_floattype */ inner_cmp_type = H5Tcreate(H5T_COMPOUND, sizeof(inner_cmp_t)); - if (inner_cmp_type < 0) TEST_ERROR + if (inner_cmp_type < 0) + TEST_ERROR /* Insert integer field */ ret = H5Tinsert(inner_cmp_type, "inner_arr", HOFFSET(inner_cmp_t, inner_arr), inner_arr_type); - if (ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR /* Insert integer field */ ret = H5Tinsert(inner_cmp_type, "vlen_float", HOFFSET(inner_cmp_t, vlen_float), vlen_floattype); - if (ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR /* Create a enumerate datatype */ enum_type = H5Tcreate(H5T_ENUM, sizeof(color_t)); - if (enum_type < 0) TEST_ERROR + if (enum_type < 0) + TEST_ERROR enum_val = E1_RED; - ret = H5Tenum_insert(enum_type, "RED", &enum_val); - if (ret < 0) TEST_ERROR + ret = H5Tenum_insert(enum_type, "RED", &enum_val); + if (ret < 0) + TEST_ERROR enum_val = E1_GREEN; - ret = H5Tenum_insert(enum_type, "GREEN", &enum_val); - if (ret < 0) TEST_ERROR + ret = H5Tenum_insert(enum_type, "GREEN", &enum_val); + if (ret < 0) + TEST_ERROR enum_val = E1_BLUE; - ret = H5Tenum_insert(enum_type, "BLUE", &enum_val); - if (ret < 0) TEST_ERROR + ret = H5Tenum_insert(enum_type, "BLUE", &enum_val); + if (ret < 0) + TEST_ERROR enum_val = E1_ORANGE; - ret = H5Tenum_insert(enum_type, "ORANGE", &enum_val); - if (ret < 0) TEST_ERROR + ret = H5Tenum_insert(enum_type, "ORANGE", &enum_val); + if (ret < 0) + TEST_ERROR enum_val = E1_YELLOW; - ret = H5Tenum_insert(enum_type, "YELLOW", &enum_val); - if (ret < 0) TEST_ERROR + ret = H5Tenum_insert(enum_type, "YELLOW", &enum_val); + if (ret < 0) + TEST_ERROR /* Create the outer compound datatype that contains the inner compound datatype and the enum datatype */ outer_cmp_type = H5Tcreate(H5T_COMPOUND, sizeof(outer_cmp_t)); - if (ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR /* Insert integer field */ ret = H5Tinsert(outer_cmp_type, "inner_cmp", HOFFSET(outer_cmp_t, inner_cmp), inner_cmp_type); - if (ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR /* Insert enum field */ ret = H5Tinsert(outer_cmp_type, "enum_color", HOFFSET(outer_cmp_t, enum_color), enum_type); - if (ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR /* Create an array datatype containing the outer compound datatype */ if ((outer_arr_type = H5Tarray_create2(outer_cmp_type, ARRAY_RANK, arr_dim)) < 0) @@ -7680,60 +8652,74 @@ test_versionbounds(void) skipping invalid combinations */ /* Create the file, create and write to a dataset with compound datatype */ /* Verify the dataset's datatype and its members */ - for(low = 0; low < versions_count; low++) { + for (low = 0; low < versions_count; low++) { - for(high = 0; high < versions_count; high++) { + for (high = 0; high < versions_count; high++) { /* Set version bounds */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(fapl, versions[low], versions[high]); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ continue; /* Create a file */ file = H5Fcreate(VERFNAME, H5F_ACC_TRUNC, fcpl, fapl); - if (file < 0) TEST_ERROR + if (file < 0) + TEST_ERROR /* Get the internal file pointer if the create succeeds */ - if ((filep = (H5F_t *)H5I_object(file)) == NULL) TEST_ERROR + if ((filep = (H5F_t *)H5I_object(file)) == NULL) + TEST_ERROR /* Create dataset using the array type */ dset = H5Dcreate2(file, VERDSNAME, outer_arr_type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (dset < 0) TEST_ERROR + if (dset < 0) + TEST_ERROR /* Get the dataset's datatype */ - if ((dset_dtype = H5Dget_type(dset)) < 0) TEST_ERROR + if ((dset_dtype = H5Dget_type(dset)) < 0) + TEST_ERROR /* Get the version of this datatype */ dtypep = (H5T_t *)H5I_object(dset_dtype); - if (dtypep == NULL) TEST_ERROR + if (dtypep == NULL) + TEST_ERROR highest_version = dtypep->shared->version; /* Verify version of the datatype recursevily */ ret = verify_version(dset_dtype, versions[low], &highest_version); /* Close the dataset's datatype */ - if (H5Tclose(dset_dtype) < 0) TEST_ERROR + if (H5Tclose(dset_dtype) < 0) + TEST_ERROR /* Close dataset and file */ - if (H5Dclose(dset) < 0) TEST_ERROR - if (H5Fclose(file) < 0) TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR } /* for high */ - } /* for low */ + } /* for low */ /* Close dataspace and property lists */ - if (H5Sclose(space) < 0) TEST_ERROR - if (H5Pclose(fcpl) < 0) TEST_ERROR - if (H5Pclose(fapl) < 0) TEST_ERROR + if (H5Sclose(space) < 0) + TEST_ERROR + if (H5Pclose(fcpl) < 0) + TEST_ERROR + if (H5Pclose(fapl) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Tclose(dset_dtype); @@ -7741,11 +8727,11 @@ error: H5Pclose(fcpl); H5Pclose(fapl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_versionbounds() */ - /*------------------------------------------------------------------------- * Function: main * @@ -7762,8 +8748,8 @@ error: int main(void) { - long nerrors = 0; - hid_t fapl = H5I_INVALID_HID; + long nerrors = 0; + hid_t fapl = H5I_INVALID_HID; /* Set the random # seed */ HDsrandom((unsigned)HDtime(NULL)); @@ -7771,7 +8757,7 @@ main(void) reset_hdf5(); fapl = h5_fileaccess(); - if(ALIGNMENT) + if (ALIGNMENT) HDprintf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT); /* Do the tests */ @@ -7826,8 +8812,8 @@ main(void) nerrors += test_utf_ascii_conv(); nerrors += test_versionbounds(); - if(nerrors) { - HDprintf("***** %lu FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S"); + if (nerrors) { + HDprintf("***** %lu FAILURE%s! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } @@ -7835,4 +8821,3 @@ main(void) return 0; } - diff --git a/test/earray.c b/test/earray.c index 82c482d..540f375 100644 --- a/test/earray.c +++ b/test/earray.c @@ -20,94 +20,97 @@ * This file needs to access private datatypes from the H5EA package. * This file also needs to access the extensible array testing code. */ -#define H5EA_FRIEND /*suppress error about including H5EApkg */ +#define H5EA_FRIEND /*suppress error about including H5EApkg */ #define H5EA_TESTING -#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5EApkg.h" /* Extensible Arrays */ /* Other private headers that this test requires */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Iprivate.h" /* IDs */ -#include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VMprivate.h" /* Vectors and arrays */ /* Local macros */ /* Max. testfile name length */ -#define EARRAY_FILENAME_LEN 1024 +#define EARRAY_FILENAME_LEN 1024 /* Extensible array creation values */ -#define ELMT_SIZE sizeof(uint64_t) -#define MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */ -#define IDX_BLK_ELMTS 4 -#define SUP_BLK_MIN_DATA_PTRS 4 -#define DATA_BLK_MIN_ELMTS 16 -#define MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ +#define ELMT_SIZE sizeof(uint64_t) +#define MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */ +#define IDX_BLK_ELMTS 4 +#define SUP_BLK_MIN_DATA_PTRS 4 +#define DATA_BLK_MIN_ELMTS 16 +#define MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ /* Convenience macros for computing earray state */ -#define EA_HDR_SIZE 72 /* (hard-coded, current size) */ -#define EA_IBLOCK_SIZE 298 /* (hard-coded, current size) */ -#define EA_NELMTS(cparam, tparam, idx, sblk_idx) \ - (hsize_t)(cparam->idx_blk_elmts + \ - tparam->sblk_info[sblk_idx].start_idx + \ - ((1 + ((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / tparam->sblk_info[sblk_idx].dblk_nelmts)) \ - * tparam->sblk_info[sblk_idx].dblk_nelmts)) -#define EA_NDATA_BLKS(cparam, tparam, idx, sblk_idx) \ - (1 + tparam->sblk_info[sblk_idx].start_dblk + \ - ((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / tparam->sblk_info[sblk_idx].dblk_nelmts)) +#define EA_HDR_SIZE 72 /* (hard-coded, current size) */ +#define EA_IBLOCK_SIZE 298 /* (hard-coded, current size) */ +#define EA_NELMTS(cparam, tparam, idx, sblk_idx) \ + (hsize_t)(cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx + \ + ((1 + ((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / \ + tparam->sblk_info[sblk_idx].dblk_nelmts)) * \ + tparam->sblk_info[sblk_idx].dblk_nelmts)) +#define EA_NDATA_BLKS(cparam, tparam, idx, sblk_idx) \ + (1 + tparam->sblk_info[sblk_idx].start_dblk + \ + ((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / \ + tparam->sblk_info[sblk_idx].dblk_nelmts)) /* Iterator parameter values */ -#define EA_RND2_SCALE 100 -#define EA_CYC_COUNT 4 +#define EA_RND2_SCALE 100 +#define EA_CYC_COUNT 4 /* Local typedefs */ /* Types of tests to perform */ typedef enum { - EARRAY_TEST_NORMAL, /* "Normal" test, with no testing parameters set */ - EARRAY_TEST_REOPEN, /* Set the reopen_array flag */ - EARRAY_TEST_NTESTS /* The number of test types, must be last */ + EARRAY_TEST_NORMAL, /* "Normal" test, with no testing parameters set */ + EARRAY_TEST_REOPEN, /* Set the reopen_array flag */ + EARRAY_TEST_NTESTS /* The number of test types, must be last */ } earray_test_type_t; /* Types of iteration to perform */ typedef enum { - EARRAY_ITER_FW, /* "Forward" iteration */ - EARRAY_ITER_RV, /* "Reverse" iteration */ - EARRAY_ITER_RND, /* "Random" iteration */ - EARRAY_ITER_CYC, /* "Cyclic" iteration */ - EARRAY_ITER_RND2, /* "Random #2" iteration */ - EARRAY_ITER_NITERS /* The number of iteration types, must be last */ + EARRAY_ITER_FW, /* "Forward" iteration */ + EARRAY_ITER_RV, /* "Reverse" iteration */ + EARRAY_ITER_RND, /* "Random" iteration */ + EARRAY_ITER_CYC, /* "Cyclic" iteration */ + EARRAY_ITER_RND2, /* "Random #2" iteration */ + EARRAY_ITER_NITERS /* The number of iteration types, must be last */ } earray_iter_type_t; /* Orders to operate on entries */ typedef enum { - EARRAY_DIR_FORWARD, /* Insert objects from 0 -> nobjs */ - EARRAY_DIR_RANDOM, /* Insert objects randomly from 0 - nobjs */ - EARRAY_DIR_CYCLIC, /* Insert every n'th object cyclicly: 0, n, 2n, 3n, ..., nobjs/n, 1+nobjs/n, 1+n+nobjs/n, 1+2n+nobjs/n, ..., nobjs */ - EARRAY_DIR_REVERSE, /* Insert objects from nobjs -> 0 */ - EARRAY_DIR_INWARD, /* Insert objects from outside to in: 0, nobjs, 1, nobjs-1, 2, nobjs-2, ..., nobjs/2 */ - EARRAY_DIR_OUTWARD, /* Insert objects from inside to out: nobjs/2, (nobjs/2)-1, (nobjs/2)+1, ..., 0, nobjs */ - EARRAY_DIR_NDIRS /* The number of different insertion orders, must be last */ + EARRAY_DIR_FORWARD, /* Insert objects from 0 -> nobjs */ + EARRAY_DIR_RANDOM, /* Insert objects randomly from 0 - nobjs */ + EARRAY_DIR_CYCLIC, /* Insert every n'th object cyclicly: 0, n, 2n, 3n, ..., nobjs/n, 1+nobjs/n, + 1+n+nobjs/n, 1+2n+nobjs/n, ..., nobjs */ + EARRAY_DIR_REVERSE, /* Insert objects from nobjs -> 0 */ + EARRAY_DIR_INWARD, /* Insert objects from outside to in: 0, nobjs, 1, nobjs-1, 2, nobjs-2, ..., nobjs/2 */ + EARRAY_DIR_OUTWARD, /* Insert objects from inside to out: nobjs/2, (nobjs/2)-1, (nobjs/2)+1, ..., 0, nobjs + */ + EARRAY_DIR_NDIRS /* The number of different insertion orders, must be last */ } earray_test_dir_t; /* Whether to compress data blocks */ typedef enum { - EARRAY_TEST_NO_COMPRESS, /* Don't compress data blocks */ - EARRAY_TEST_COMPRESS, /* Compress data blocks */ - EARRAY_TEST_COMP_N /* The number of different ways to test compressing array blocks, must be last */ + EARRAY_TEST_NO_COMPRESS, /* Don't compress data blocks */ + EARRAY_TEST_COMPRESS, /* Compress data blocks */ + EARRAY_TEST_COMP_N /* The number of different ways to test compressing array blocks, must be last */ } earray_test_comp_t; /* Extensible array state information */ typedef struct earray_state_t { - hsize_t hdr_size; /* Size of header */ - hsize_t nindex_blks; /* # of index blocks */ - hsize_t index_blk_size; /* Size of index blocks */ - hsize_t nsuper_blks; /* # of super blocks */ - hsize_t super_blk_size; /* Size of super blocks */ - hsize_t ndata_blks; /* # of data blocks */ - hsize_t data_blk_size; /* Size of data blocks */ - hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */ - hsize_t nelmts; /* # of elements "realized" */ + hsize_t hdr_size; /* Size of header */ + hsize_t nindex_blks; /* # of index blocks */ + hsize_t index_blk_size; /* Size of index blocks */ + hsize_t nsuper_blks; /* # of super blocks */ + hsize_t super_blk_size; /* Size of super blocks */ + hsize_t ndata_blks; /* # of data blocks */ + hsize_t data_blk_size; /* Size of data blocks */ + hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with + be '1', if no elements have been stored, this value will be '0') */ + hsize_t nelmts; /* # of elements "realized" */ } earray_state_t; /* Forward decl. */ @@ -116,34 +119,34 @@ typedef struct earray_test_param_t earray_test_param_t; /* Extensible array iterator class */ typedef struct earray_iter_t { void *(*init)(const H5EA_create_t *cparam, const earray_test_param_t *tparam, - hsize_t cnt); /* Initialize/allocate iterator private info */ - hssize_t (*next)(void *info); /* Get the next element to test */ - hssize_t (*max_elem)(const void *info); /* Get the max. element set */ - int (*state)(void *_eiter, const H5EA_create_t *cparam, - const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx); /* Get the state of the extensible array */ - herr_t (*term)(void *info); /* Shutdown/free iterator private info */ + hsize_t cnt); /* Initialize/allocate iterator private info */ + hssize_t (*next)(void *info); /* Get the next element to test */ + hssize_t (*max_elem)(const void *info); /* Get the max. element set */ + int (*state)(void *_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam, + earray_state_t *state, hsize_t idx); /* Get the state of the extensible array */ + herr_t (*term)(void *info); /* Shutdown/free iterator private info */ } earray_iter_t; /* Testing parameters */ struct earray_test_param_t { - earray_test_type_t reopen_array; /* Whether to re-open the array during the test */ - earray_test_comp_t comp; /* Whether to compress the blocks or not */ - const earray_iter_t *eiter; /* Iterator to use for this test */ + earray_test_type_t reopen_array; /* Whether to re-open the array during the test */ + earray_test_comp_t comp; /* Whether to compress the blocks or not */ + const earray_iter_t *eiter; /* Iterator to use for this test */ /* Super block information */ - size_t nsblks; /* Number of superblocks needed for array */ - H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */ + size_t nsblks; /* Number of superblocks needed for array */ + H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */ }; /* Flush depend test context */ typedef struct earray_flush_depend_ctx_t { - hbool_t base_obj; /* Flag to indicate that base object has been flushed */ - hbool_t idx0_obj; /* Flag to indicate that index 0's object has been flushed */ - hbool_t idx0_elem; /* Flag to indicate that index 0's element has been flushed */ - hbool_t idx1_obj; /* Flag to indicate that index 1's object has been flushed */ - hbool_t idx1_elem; /* Flag to indicate that index 1's element has been flushed */ - hbool_t idx10000_obj; /* Flag to indicate that index 10000's object has been flushed */ - hbool_t idx10000_elem; /* Flag to indicate that index 10000's element has been flushed */ + hbool_t base_obj; /* Flag to indicate that base object has been flushed */ + hbool_t idx0_obj; /* Flag to indicate that index 0's object has been flushed */ + hbool_t idx0_elem; /* Flag to indicate that index 0's element has been flushed */ + hbool_t idx1_obj; /* Flag to indicate that index 1's object has been flushed */ + hbool_t idx1_elem; /* Flag to indicate that index 1's element has been flushed */ + hbool_t idx10000_obj; /* Flag to indicate that index 10000's object has been flushed */ + hbool_t idx10000_elem; /* Flag to indicate that index 10000's element has been flushed */ } earray_flush_depend_ctx_t; /* Extensible array test cache object */ @@ -152,20 +155,14 @@ typedef struct earray_test_t { H5AC_info_t cache_info; /* Entry information */ - uint64_t idx; /* Index that entry corresponds to */ + uint64_t idx; /* Index that entry corresponds to */ earray_flush_depend_ctx_t *fd_info; /* Context information for flush depend test */ } earray_test_t; - /* Local prototypes */ - /* Local variables */ -const char *FILENAME[] = { - "earray", - "earray_tmp", - NULL -}; +const char *FILENAME[] = {"earray", "earray_tmp", NULL}; /* Filename to use for all tests */ char filename_g[EARRAY_FILENAME_LEN]; @@ -173,7 +170,6 @@ char filename_g[EARRAY_FILENAME_LEN]; /* Empty file size */ h5_stat_size_t empty_size_g; - /*------------------------------------------------------------------------- * Function: init_cparam * @@ -194,18 +190,17 @@ init_cparam(H5EA_create_t *cparam) HDmemset(cparam, 0, sizeof(*cparam)); /* General parameters */ - cparam->cls = H5EA_CLS_TEST; - cparam->raw_elmt_size = ELMT_SIZE; - cparam->max_nelmts_bits = MAX_NELMTS_BITS; - cparam->idx_blk_elmts = IDX_BLK_ELMTS; - cparam->sup_blk_min_data_ptrs = SUP_BLK_MIN_DATA_PTRS; - cparam->data_blk_min_elmts = DATA_BLK_MIN_ELMTS; + cparam->cls = H5EA_CLS_TEST; + cparam->raw_elmt_size = ELMT_SIZE; + cparam->max_nelmts_bits = MAX_NELMTS_BITS; + cparam->idx_blk_elmts = IDX_BLK_ELMTS; + cparam->sup_blk_min_data_ptrs = SUP_BLK_MIN_DATA_PTRS; + cparam->data_blk_min_elmts = DATA_BLK_MIN_ELMTS; cparam->max_dblk_page_nelmts_bits = MAX_DBLOCK_PAGE_NELMTS_BITS; - return(0); + return (0); } /* init_cparam() */ - /*------------------------------------------------------------------------- * Function: init_tparam * @@ -224,9 +219,9 @@ init_cparam(H5EA_create_t *cparam) static int init_tparam(earray_test_param_t *tparam, const H5EA_create_t *cparam) { - hsize_t start_idx; /* First element index for each super block */ - hsize_t start_dblk; /* First data block index for each super block */ - size_t u; /* Local index variable */ + hsize_t start_idx; /* First element index for each super block */ + hsize_t start_dblk; /* First data block index for each super block */ + size_t u; /* Local index variable */ /* Wipe out background */ HDmemset(tparam, 0, sizeof(*tparam)); @@ -239,23 +234,22 @@ init_tparam(earray_test_param_t *tparam, const H5EA_create_t *cparam) HDassert(tparam->sblk_info); /* Compute information about each super block */ - start_idx = 0; + start_idx = 0; start_dblk = 0; - for(u = 0; u < tparam->nsblks; u++) { - tparam->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2); + for (u = 0; u < tparam->nsblks; u++) { + tparam->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2); tparam->sblk_info[u].dblk_nelmts = (size_t)H5_EXP2((u + 1) / 2) * cparam->data_blk_min_elmts; - tparam->sblk_info[u].start_idx = start_idx; - tparam->sblk_info[u].start_dblk = start_dblk; + tparam->sblk_info[u].start_idx = start_idx; + tparam->sblk_info[u].start_dblk = start_dblk; /* Advance starting indices for next super block */ start_idx += (hsize_t)tparam->sblk_info[u].ndblks * (hsize_t)tparam->sblk_info[u].dblk_nelmts; start_dblk += (hsize_t)tparam->sblk_info[u].ndblks; } /* end for */ - return(0); + return (0); } /* init_tparam() */ - /*------------------------------------------------------------------------- * Function: finish_tparam * @@ -276,10 +270,9 @@ finish_tparam(earray_test_param_t *tparam) HDfree(tparam->sblk_info); tparam->sblk_info = NULL; - return(0); + return (0); } /* finish_tparam() */ - /*------------------------------------------------------------------------- * Function: create_file * @@ -297,25 +290,24 @@ static int create_file(unsigned flags, hid_t fapl, hid_t *file, H5F_t **f) { /* Create the file to work on */ - if((*file = H5Fcreate(filename_g, flags, H5P_DEFAULT, fapl)) < 0) + if ((*file = H5Fcreate(filename_g, flags, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5VL_object(*file))) + if (NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) + if (H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* create_file() */ - /*------------------------------------------------------------------------- * Function: check_stats * @@ -332,68 +324,77 @@ error: static int check_stats(const H5EA_t *ea, const earray_state_t *state) { - H5EA_stat_t earray_stats; /* Statistics about the array */ + H5EA_stat_t earray_stats; /* Statistics about the array */ /* Get statistics for extensible array and verify they are correct */ - if(H5EA_get_stats(ea, &earray_stats) < 0) + if (H5EA_get_stats(ea, &earray_stats) < 0) FAIL_STACK_ERROR /* Compare information */ - if(earray_stats.stored.max_idx_set != state->max_idx_set) { - HDfprintf(stdout, "earray_stats.stored.max_idx_set = %Hu, state->max_idx_set = %Hu\n", earray_stats.stored.max_idx_set, state->max_idx_set); + if (earray_stats.stored.max_idx_set != state->max_idx_set) { + HDfprintf(stdout, "earray_stats.stored.max_idx_set = %Hu, state->max_idx_set = %Hu\n", + earray_stats.stored.max_idx_set, state->max_idx_set); TEST_ERROR } /* end if */ - if(earray_stats.stored.nelmts != state->nelmts) { - HDfprintf(stdout, "earray_stats.stored.nelmts = %Hu, state->nelmts = %Hu\n", earray_stats.stored.nelmts, state->nelmts); + if (earray_stats.stored.nelmts != state->nelmts) { + HDfprintf(stdout, "earray_stats.stored.nelmts = %Hu, state->nelmts = %Hu\n", + earray_stats.stored.nelmts, state->nelmts); TEST_ERROR } /* end if */ - if(earray_stats.computed.hdr_size != state->hdr_size) { - HDfprintf(stdout, "earray_stats.computed.hdr_size = %Hu, state->hdr_size = %Hu\n", earray_stats.computed.hdr_size, state->hdr_size); + if (earray_stats.computed.hdr_size != state->hdr_size) { + HDfprintf(stdout, "earray_stats.computed.hdr_size = %Hu, state->hdr_size = %Hu\n", + earray_stats.computed.hdr_size, state->hdr_size); TEST_ERROR } /* end if */ - if(earray_stats.computed.nindex_blks != state->nindex_blks) { - HDfprintf(stdout, "earray_stats.computed.nindex_blks = %Hu, state->nindex_blks = %Hu\n", earray_stats.computed.nindex_blks, state->nindex_blks); + if (earray_stats.computed.nindex_blks != state->nindex_blks) { + HDfprintf(stdout, "earray_stats.computed.nindex_blks = %Hu, state->nindex_blks = %Hu\n", + earray_stats.computed.nindex_blks, state->nindex_blks); TEST_ERROR } /* end if */ - if(earray_stats.computed.index_blk_size != state->index_blk_size) { - HDfprintf(stdout, "earray_stats.computed.index_blk_size = %Hu, state->index_blk_size = %Hu\n", earray_stats.computed.index_blk_size, state->index_blk_size); + if (earray_stats.computed.index_blk_size != state->index_blk_size) { + HDfprintf(stdout, "earray_stats.computed.index_blk_size = %Hu, state->index_blk_size = %Hu\n", + earray_stats.computed.index_blk_size, state->index_blk_size); TEST_ERROR } /* end if */ - if(earray_stats.stored.ndata_blks != state->ndata_blks) { - HDfprintf(stdout, "earray_stats.stored.ndata_blks = %Hu, state->ndata_blks = %Hu\n", earray_stats.stored.ndata_blks, state->ndata_blks); + if (earray_stats.stored.ndata_blks != state->ndata_blks) { + HDfprintf(stdout, "earray_stats.stored.ndata_blks = %Hu, state->ndata_blks = %Hu\n", + earray_stats.stored.ndata_blks, state->ndata_blks); TEST_ERROR } /* end if */ /* Don't compare this currently, it's very hard to compute */ #ifdef NOT_YET - if(earray_stats.stored.data_blk_size != state->data_blk_size) { - HDfprintf(stdout, "earray_stats.stored.data_blk_size = %Hu, state->data_blk_size = %Hu\n", earray_stats.stored.data_blk_size, state->data_blk_size); + if (earray_stats.stored.data_blk_size != state->data_blk_size) { + HDfprintf(stdout, "earray_stats.stored.data_blk_size = %Hu, state->data_blk_size = %Hu\n", + earray_stats.stored.data_blk_size, state->data_blk_size); TEST_ERROR - } /* end if */ + } /* end if */ #endif /* NOT_YET */ - if(earray_stats.stored.nsuper_blks != state->nsuper_blks) { - HDfprintf(stdout, "earray_stats.stored.nsuper_blks = %Hu, state->nsuper_blks = %Hu\n", earray_stats.stored.nsuper_blks, state->nsuper_blks); + if (earray_stats.stored.nsuper_blks != state->nsuper_blks) { + HDfprintf(stdout, "earray_stats.stored.nsuper_blks = %Hu, state->nsuper_blks = %Hu\n", + earray_stats.stored.nsuper_blks, state->nsuper_blks); TEST_ERROR } /* end if */ /* Don't compare this currently, it's very hard to compute */ #ifdef NOT_YET - if(earray_stats.stored.super_blk_size != state->super_blk_size) { - HDfprintf(stdout, "earray_stats.stored.super_blk_size = %Hu, state->super_blk_size = %Hu\n", earray_stats.stored.super_blk_size, state->super_blk_size); + if (earray_stats.stored.super_blk_size != state->super_blk_size) { + HDfprintf(stdout, "earray_stats.stored.super_blk_size = %Hu, state->super_blk_size = %Hu\n", + earray_stats.stored.super_blk_size, state->super_blk_size); TEST_ERROR - } /* end if */ + } /* end if */ #endif /* NOT_YET */ #ifdef QAK -HDfprintf(stderr, "nelmts = %Hu, total EA size = %Hu\n", earray_stats.stored.nelmts, - (earray_stats.computed.hdr_size + earray_stats.computed.index_blk_size + earray_stats.stored.super_blk_size + earray_stats.stored.data_blk_size)); + HDfprintf(stderr, "nelmts = %Hu, total EA size = %Hu\n", earray_stats.stored.nelmts, + (earray_stats.computed.hdr_size + earray_stats.computed.index_blk_size + + earray_stats.stored.super_blk_size + earray_stats.stored.data_blk_size)); #endif /* QAK */ /* All tests passed */ - return(0); + return (0); error: - return(-1); + return (-1); } /* check_stats() */ - /*------------------------------------------------------------------------- * Function: reopen_file * @@ -408,53 +409,52 @@ error: *------------------------------------------------------------------------- */ static int -reopen_file(hid_t *file, H5F_t **f, hid_t fapl, - H5EA_t **ea, haddr_t ea_addr, const earray_test_param_t *tparam) +reopen_file(hid_t *file, H5F_t **f, hid_t fapl, H5EA_t **ea, haddr_t ea_addr, + const earray_test_param_t *tparam) { /* Check for closing & re-opening the array */ /* (actually will close & re-open the file as well) */ - if(tparam->reopen_array) { + if (tparam->reopen_array) { /* Close array, if given */ - if(ea && *ea) { - if(H5EA_close(*ea) < 0) + if (ea && *ea) { + if (H5EA_close(*ea) < 0) FAIL_STACK_ERROR *ea = NULL; } /* end if */ /* Close file */ - if(*file) { - if(H5Fclose(*file) < 0) + if (*file) { + if (H5Fclose(*file) < 0) FAIL_STACK_ERROR *file = (-1); - *f = NULL; + *f = NULL; } /* end if */ /* Re-open the file */ - if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + if ((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5VL_object(*file))) + if (NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) + if (H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR /* Re-open array, if given */ - if(ea) - if(NULL == (*ea = H5EA_open(*f, ea_addr, NULL))) + if (ea) + if (NULL == (*ea = H5EA_open(*f, ea_addr, NULL))) FAIL_STACK_ERROR } /* end if */ /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* reopen_file() */ - /*------------------------------------------------------------------------- * Function: create_array * @@ -469,39 +469,37 @@ error: *------------------------------------------------------------------------- */ static int -create_array(H5F_t *f, const H5EA_create_t *cparam, - H5EA_t **ea, haddr_t *ea_addr, H5EA__ctx_cb_t *cb) +create_array(H5F_t *f, const H5EA_create_t *cparam, H5EA_t **ea, haddr_t *ea_addr, H5EA__ctx_cb_t *cb) { - hsize_t nelmts; /* Number of elements in array */ - earray_state_t state; /* State of extensible array */ + hsize_t nelmts; /* Number of elements in array */ + earray_state_t state; /* State of extensible array */ /* Create array */ - if(NULL == (*ea = H5EA_create(f, cparam, cb))) + if (NULL == (*ea = H5EA_create(f, cparam, cb))) FAIL_STACK_ERROR /* Check status of array */ nelmts = (hsize_t)ULLONG_MAX; - if(H5EA_get_nelmts(*ea, &nelmts) < 0) + if (H5EA_get_nelmts(*ea, &nelmts) < 0) FAIL_STACK_ERROR - if(nelmts > 0) + if (nelmts > 0) TEST_ERROR - if(H5EA_get_addr(*ea, ea_addr) < 0) + if (H5EA_get_addr(*ea, ea_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(*ea_addr)) + if (!H5F_addr_defined(*ea_addr)) TEST_ERROR HDmemset(&state, 0, sizeof(state)); state.hdr_size = EA_HDR_SIZE; - if(check_stats(*ea, &state)) + if (check_stats(*ea, &state)) TEST_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* create_array() */ - /*------------------------------------------------------------------------- * Function: verify_cparam * @@ -518,15 +516,15 @@ error: static int verify_cparam(const H5EA_t *ea, const H5EA_create_t *cparam) { - H5EA_create_t test_cparam; /* Creation parameters for array */ + H5EA_create_t test_cparam; /* Creation parameters for array */ /* Retrieve creation parameters */ HDmemset(&test_cparam, 0, sizeof(H5EA_create_t)); - if(H5EA__get_cparam_test(ea, &test_cparam) < 0) + if (H5EA__get_cparam_test(ea, &test_cparam) < 0) FAIL_STACK_ERROR /* Verify creation parameters */ - if(H5EA__cmp_cparam_test(cparam, &test_cparam)) + if (H5EA__cmp_cparam_test(cparam, &test_cparam)) TEST_ERROR /* Success */ @@ -536,7 +534,6 @@ error: return FAIL; } /* verify_cparam() */ - /*------------------------------------------------------------------------- * Function: finish * @@ -554,43 +551,41 @@ error: static int finish(hid_t file, hid_t fapl, H5F_t *f, H5EA_t *ea, haddr_t ea_addr) { - h5_stat_size_t file_size; /* File size, after deleting array */ + h5_stat_size_t file_size; /* File size, after deleting array */ /* Close the extensible array */ - if(H5EA_close(ea) < 0) + if (H5EA_close(ea) < 0) FAIL_STACK_ERROR #ifdef QAK -HDfprintf(stderr, "ea_addr = %a\n", ea_addr); -H5Fflush(file, H5F_SCOPE_GLOBAL); -HDsystem("cp earray.h5 earray.h5.save"); + HDfprintf(stderr, "ea_addr = %a\n", ea_addr); + H5Fflush(file, H5F_SCOPE_GLOBAL); + HDsystem("cp earray.h5 earray.h5.save"); #endif /* QAK */ /* Delete array */ - if(H5EA_delete(f, ea_addr, NULL) < 0) + if (H5EA_delete(f, ea_addr, NULL) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - /* Get the size of the file */ - if((file_size = h5_get_file_size(filename_g, fapl)) < 0) + if ((file_size = h5_get_file_size(filename_g, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size_g) + if (file_size != empty_size_g) TEST_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* finish() */ - /*------------------------------------------------------------------------- * Function: test_create * @@ -607,13 +602,13 @@ error: static unsigned test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSED *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5EA_t *ea = NULL; /* Extensible array wrapper */ - haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5EA_t *ea = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -622,117 +617,115 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TESTING("invalid extensible array creation parameters"); #ifndef NDEBUG -{ - H5EA_create_t test_cparam; /* Creation parameters for array */ - - /* Set invalid element size */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.raw_elmt_size = 0; - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; - - /* Indicate error */ - TEST_ERROR - } /* end if */ + { + H5EA_create_t test_cparam; /* Creation parameters for array */ - /* Set invalid max. # of elements bits */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_nelmts_bits = 0; - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; + /* Set invalid element size */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.raw_elmt_size = 0; + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ + /* Indicate error */ + TEST_ERROR + } /* end if */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_nelmts_bits = 65; - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; + /* Set invalid max. # of elements bits */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.max_nelmts_bits = 0; + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ + /* Indicate error */ + TEST_ERROR + } /* end if */ - /* Set invalid min. # of data block pointers in super blocks */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.sup_blk_min_data_ptrs = 0; - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.max_nelmts_bits = 65; + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.sup_blk_min_data_ptrs = 1; - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; + /* Indicate error */ + TEST_ERROR + } /* end if */ - /* Indicate error */ - TEST_ERROR - } /* end if */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.sup_blk_min_data_ptrs = 6; - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; + /* Set invalid min. # of data block pointers in super blocks */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.sup_blk_min_data_ptrs = 0; + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ + /* Indicate error */ + TEST_ERROR + } /* end if */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.sup_blk_min_data_ptrs = 1; + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; - /* Set invalid min. # of elements per data block */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.data_blk_min_elmts = 0; - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; + /* Indicate error */ + TEST_ERROR + } /* end if */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.sup_blk_min_data_ptrs = 6; + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ + /* Indicate error */ + TEST_ERROR + } /* end if */ - /* Set invalid max. # of elements per data block page bits */ - if(test_cparam.idx_blk_elmts > 0) { + /* Set invalid min. # of elements per data block */ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1); - H5E_BEGIN_TRY { + test_cparam.data_blk_min_elmts = 0; + H5E_BEGIN_TRY + { ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { + } + H5E_END_TRY; + if (ea) { /* Close opened extensible array */ H5EA_close(ea); ea = NULL; @@ -740,37 +733,61 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE /* Indicate error */ TEST_ERROR } /* end if */ - } /* end if */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = 4; /* corresponds to 16 elements in data block page, which is less than the 64 elements for the default settings */ - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(test_cparam.max_nelmts_bits + 1); - H5E_BEGIN_TRY { - ea = H5EA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(ea) { - /* Close opened extensible array */ - H5EA_close(ea); - ea = NULL; + /* Set invalid max. # of elements per data block page bits */ + if (test_cparam.idx_blk_elmts > 0) { + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.max_dblk_page_nelmts_bits = + (uint8_t)(H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1); + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; + + /* Indicate error */ + TEST_ERROR + } /* end if */ + } /* end if */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.max_dblk_page_nelmts_bits = 4; /* corresponds to 16 elements in data block page, which is + less than the 64 elements for the default settings */ + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ + /* Indicate error */ + TEST_ERROR + } /* end if */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(test_cparam.max_nelmts_bits + 1); + H5E_BEGIN_TRY + { + ea = H5EA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (ea) { + /* Close opened extensible array */ + H5EA_close(ea); + ea = NULL; - PASSED(); -} -#else /* NDEBUG */ + /* Indicate error */ + TEST_ERROR + } /* end if */ + + PASSED(); + } +#else /* NDEBUG */ SKIPPED(); puts(" Not tested when assertions are disabled"); #endif /* NDEBUG */ @@ -781,7 +798,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TESTING("extensible array creation"); /* Create array */ - if(create_array(f, cparam, &ea, &ea_addr, NULL) < 0) + if (create_array(f, cparam, &ea, &ea_addr, NULL) < 0) TEST_ERROR PASSED(); @@ -790,11 +807,11 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TESTING("verify array creation parameters"); /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR /* Close array, delete array, close file & verify file is empty */ - if(finish(file, fapl, f, ea, ea_addr) < 0) + if (finish(file, fapl, f, ea, ea_addr) < 0) TEST_ERROR /* All tests passed */ @@ -803,16 +820,17 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE return 0; error: - H5E_BEGIN_TRY { - if(ea) + H5E_BEGIN_TRY + { + if (ea) H5EA_close(ea); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* end test_create() */ - /*------------------------------------------------------------------------- * Function: test_reopen * @@ -829,13 +847,13 @@ error: static unsigned test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5EA_t *ea = NULL; /* Extensible array wrapper */ - haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5EA_t *ea = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -844,27 +862,27 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TESTING("create, close & reopen extensible array"); /* Create array */ - if(create_array(f, cparam, &ea, &ea_addr, NULL) < 0) + if (create_array(f, cparam, &ea, &ea_addr, NULL) < 0) TEST_ERROR /* Close the extensible array */ - if(H5EA_close(ea) < 0) + if (H5EA_close(ea) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, NULL, HADDR_UNDEF, tparam) < 0) + if (reopen_file(&file, &f, fapl, NULL, HADDR_UNDEF, tparam) < 0) TEST_ERROR /* Re-open the array */ - if(NULL == (ea = H5EA_open(f, ea_addr, NULL))) + if (NULL == (ea = H5EA_open(f, ea_addr, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR /* Close array, delete array, close file & verify file is empty */ - if(finish(file, fapl, f, ea, ea_addr) < 0) + if (finish(file, fapl, f, ea, ea_addr) < 0) TEST_ERROR /* All tests passed */ @@ -873,16 +891,17 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) return 0; error: - H5E_BEGIN_TRY { - if(ea) + H5E_BEGIN_TRY + { + if (ea) H5EA_close(ea); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_reopen() */ - /*------------------------------------------------------------------------- * Function: test_open_twice * @@ -899,16 +918,16 @@ error: static unsigned test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - hid_t file2 = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5F_t *f2 = NULL; /* Internal file object pointer */ - H5EA_t *ea = NULL; /* Extensible array wrapper */ - H5EA_t *ea2 = NULL; /* Extensible array wrapper */ - haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5F_t * f2 = NULL; /* Internal file object pointer */ + H5EA_t *ea = NULL; /* Extensible array wrapper */ + H5EA_t *ea2 = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -917,46 +936,46 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TESTING("open extensible array twice"); /* Create array */ - if(create_array(f, cparam, &ea, &ea_addr, NULL) < 0) + if (create_array(f, cparam, &ea, &ea_addr, NULL) < 0) TEST_ERROR /* Open the array again, through the first file handle */ - if(NULL == (ea2 = H5EA_open(f, ea_addr, NULL))) + if (NULL == (ea2 = H5EA_open(f, ea_addr, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR - if(verify_cparam(ea2, cparam) < 0) + if (verify_cparam(ea2, cparam) < 0) TEST_ERROR /* Close the second extensible array wrapper */ - if(H5EA_close(ea2) < 0) + if (H5EA_close(ea2) < 0) FAIL_STACK_ERROR ea2 = NULL; /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, &ea, ea_addr, tparam) < 0) + if (reopen_file(&file, &f, fapl, &ea, ea_addr, tparam) < 0) TEST_ERROR /* Re-open the file */ - if((file2 = H5Freopen(file)) < 0) + if ((file2 = H5Freopen(file)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f2 = (H5F_t *)H5VL_object(file2))) + if (NULL == (f2 = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Open the extensible array through the second file handle */ - if(NULL == (ea2 = H5EA_open(f2, ea_addr, NULL))) + if (NULL == (ea2 = H5EA_open(f2, ea_addr, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR /* Close the first extensible array wrapper */ - if(H5EA_close(ea) < 0) + if (H5EA_close(ea) < 0) FAIL_STACK_ERROR ea = NULL; @@ -964,11 +983,11 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) /* (close before second file, to detect error on internal array header's * shared file information) */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Close array, delete array, close file & verify file is empty */ - if(finish(file2, fapl, f2, ea2, ea_addr) < 0) + if (finish(file2, fapl, f2, ea2, ea_addr) < 0) TEST_ERROR /* All tests passed */ @@ -977,19 +996,20 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) return 0; error: - H5E_BEGIN_TRY { - if(ea) + H5E_BEGIN_TRY + { + if (ea) H5EA_close(ea); - if(ea2) + if (ea2) H5EA_close(ea2); - H5Fclose(file); - H5Fclose(file2); - } H5E_END_TRY; + H5Fclose(file); + H5Fclose(file2); + } + H5E_END_TRY; return 1; } /* test_open_twice() */ - /*------------------------------------------------------------------------- * Function: test_open_twice_diff * @@ -1008,19 +1028,19 @@ error: static unsigned test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) { - char filename_tmp[EARRAY_FILENAME_LEN]; /* Temporary file name */ - hid_t file = -1; /* File ID */ - hid_t file2 = -1; /* File ID */ - hid_t file0 = -1; /* File ID */ - hid_t file00 = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5F_t *f2 = NULL; /* Internal file object pointer */ - H5EA_t *ea = NULL; /* Extensible array wrapper */ - H5EA_t *ea2 = NULL; /* Extensible array wrapper */ - haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + char filename_tmp[EARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5F_t * f2 = NULL; /* Internal file object pointer */ + H5EA_t *ea = NULL; /* Extensible array wrapper */ + H5EA_t *ea2 = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1029,21 +1049,21 @@ test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tpa TESTING("open extensible array twice, through different file handles"); /* Create array */ - if(create_array(f, cparam, &ea, &ea_addr, NULL) < 0) + if (create_array(f, cparam, &ea, &ea_addr, NULL) < 0) TEST_ERROR /* Open the array again, through the first file handle */ - if(NULL == (ea2 = H5EA_open(f, ea_addr, NULL))) + if (NULL == (ea2 = H5EA_open(f, ea_addr, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR - if(verify_cparam(ea2, cparam) < 0) + if (verify_cparam(ea2, cparam) < 0) TEST_ERROR /* Close the second extensible array wrapper */ - if(H5EA_close(ea2) < 0) + if (H5EA_close(ea2) < 0) FAIL_STACK_ERROR ea2 = NULL; @@ -1051,19 +1071,19 @@ test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tpa /* (So that there is something holding the file open when the extensible * array is closed) */ - if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + if ((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, &ea, ea_addr, tparam) < 0) + if (reopen_file(&file, &f, fapl, &ea, ea_addr, tparam) < 0) TEST_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR /* Close the first extensible array wrapper */ - if(H5EA_close(ea) < 0) + if (H5EA_close(ea) < 0) FAIL_STACK_ERROR ea = NULL; @@ -1071,7 +1091,7 @@ test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tpa /* (close before second file, to detect error on internal array header's * shared file information) */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR file = -1; @@ -1081,34 +1101,33 @@ test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tpa * header stale) */ h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); - if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - /* Re-open the file with the extensible array */ - if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + if ((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f2 = (H5F_t *)H5VL_object(file2))) + if (NULL == (f2 = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Open the extensible array through the second file handle */ - if(NULL == (ea2 = H5EA_open(f2, ea_addr, NULL))) + if (NULL == (ea2 = H5EA_open(f2, ea_addr, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea2, cparam) < 0) + if (verify_cparam(ea2, cparam) < 0) TEST_ERROR /* Close the extra file handles */ - if(H5Fclose(file0) < 0) + if (H5Fclose(file0) < 0) FAIL_STACK_ERROR - if(H5Fclose(file00) < 0) + if (H5Fclose(file00) < 0) FAIL_STACK_ERROR /* Close array, delete array, close file & verify file is empty */ - if(finish(file2, fapl, f2, ea2, ea_addr) < 0) + if (finish(file2, fapl, f2, ea2, ea_addr) < 0) TEST_ERROR /* All tests passed */ @@ -1117,21 +1136,22 @@ test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tpa return 0; error: - H5E_BEGIN_TRY { - if(ea) + H5E_BEGIN_TRY + { + if (ea) H5EA_close(ea); - if(ea2) + if (ea2) H5EA_close(ea2); - H5Fclose(file); - H5Fclose(file2); - H5Fclose(file0); - H5Fclose(file00); - } H5E_END_TRY; + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } + H5E_END_TRY; return 1; } /* test_open_twice_diff() */ - /*------------------------------------------------------------------------- * Function: test_delete_open * @@ -1148,15 +1168,15 @@ error: static unsigned test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5EA_t *ea = NULL; /* Extensible array wrapper */ - H5EA_t *ea2 = NULL; /* Extensible array wrapper */ - haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ - h5_stat_size_t file_size; /* File size, after deleting array */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5EA_t * ea = NULL; /* Extensible array wrapper */ + H5EA_t * ea2 = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + h5_stat_size_t file_size; /* File size, after deleting array */ /* Create file & retrieve pointer to internal file object */ - if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1165,33 +1185,35 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TESTING("deleting open extensible array"); /* Create array */ - if(create_array(f, cparam, &ea, &ea_addr, NULL) < 0) + if (create_array(f, cparam, &ea, &ea_addr, NULL) < 0) TEST_ERROR /* Open the array again */ - if(NULL == (ea2 = H5EA_open(f, ea_addr, NULL))) + if (NULL == (ea2 = H5EA_open(f, ea_addr, NULL))) FAIL_STACK_ERROR /* Request that the array be deleted */ - if(H5EA_delete(f, ea_addr, NULL) < 0) + if (H5EA_delete(f, ea_addr, NULL) < 0) FAIL_STACK_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR - if(verify_cparam(ea2, cparam) < 0) + if (verify_cparam(ea2, cparam) < 0) TEST_ERROR /* Close the second extensible array wrapper */ - if(H5EA_close(ea2) < 0) + if (H5EA_close(ea2) < 0) FAIL_STACK_ERROR ea2 = NULL; /* Try re-opening the array again (should fail, as array will be deleted) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ea2 = H5EA_open(f, ea_addr, NULL); - } H5E_END_TRY; - if(ea2) { + } + H5E_END_TRY; + if (ea2) { /* Close opened array */ H5EA_close(ea2); @@ -1200,19 +1222,21 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) } /* end if */ /* Close the first extensible array wrapper */ - if(H5EA_close(ea) < 0) + if (H5EA_close(ea) < 0) FAIL_STACK_ERROR ea = NULL; /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, NULL, HADDR_UNDEF, tparam) < 0) + if (reopen_file(&file, &f, fapl, NULL, HADDR_UNDEF, tparam) < 0) TEST_ERROR /* Try re-opening the array again (should fail, as array is now deleted) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ea = H5EA_open(f, ea_addr, NULL); - } H5E_END_TRY; - if(ea) { + } + H5E_END_TRY; + if (ea) { /* Close opened array */ H5EA_close(ea); @@ -1221,15 +1245,15 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename_g, fapl)) < 0) + if ((file_size = h5_get_file_size(filename_g, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size_g) + if (file_size != empty_size_g) TEST_ERROR /* All tests passed */ @@ -1238,24 +1262,25 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) return 0; error: - H5E_BEGIN_TRY { - if(ea) + H5E_BEGIN_TRY + { + if (ea) H5EA_close(ea); - if(ea2) + if (ea2) H5EA_close(ea2); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_delete_open() */ /* Extensible array iterator info for forward iteration */ typedef struct eiter_fw_t { - hsize_t idx; /* Index of next array location */ - unsigned base_sblk_idx; /* Starting index for actual superblocks */ + hsize_t idx; /* Index of next array location */ + unsigned base_sblk_idx; /* Starting index for actual superblocks */ } eiter_fw_t; - /*------------------------------------------------------------------------- * Function: eiter_fw_init * @@ -1271,23 +1296,22 @@ typedef struct eiter_fw_t { */ static void * eiter_fw_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_param_t H5_ATTR_UNUSED *tparam, - hsize_t H5_ATTR_UNUSED cnt) + hsize_t H5_ATTR_UNUSED cnt) { - eiter_fw_t *eiter; /* Forward element iteration object */ + eiter_fw_t *eiter; /* Forward element iteration object */ /* Allocate space for the element iteration object */ eiter = (eiter_fw_t *)HDmalloc(sizeof(eiter_fw_t)); HDassert(eiter); /* Initialize the element iteration object */ - eiter->idx = 0; + eiter->idx = 0; eiter->base_sblk_idx = UINT_MAX; /* Return iteration object */ - return(eiter); + return (eiter); } /* end eiter_fw_init() */ - /*------------------------------------------------------------------------- * Function: eiter_fw_next * @@ -1305,7 +1329,7 @@ static hssize_t eiter_fw_next(void *_eiter) { eiter_fw_t *eiter = (eiter_fw_t *)_eiter; - hssize_t ret_val; + hssize_t ret_val; /* Sanity check */ HDassert(eiter); @@ -1313,10 +1337,9 @@ eiter_fw_next(void *_eiter) /* Get the next array index to test */ ret_val = (hssize_t)eiter->idx++; - return(ret_val); + return (ret_val); } /* end eiter_fw_next() */ - /*------------------------------------------------------------------------- * Function: eiter_fw_max * @@ -1339,10 +1362,9 @@ eiter_fw_max(const void *_eiter) HDassert(eiter); /* Return the max. array index used */ - return((hssize_t)(eiter->idx - 1)); + return ((hssize_t)(eiter->idx - 1)); } /* end eiter_fw_max() */ - /*------------------------------------------------------------------------- * Function: eiter_fw_state * @@ -1357,8 +1379,8 @@ eiter_fw_max(const void *_eiter) *------------------------------------------------------------------------- */ static int -eiter_fw_state(void *_eiter, const H5EA_create_t *cparam, - const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx) +eiter_fw_state(void *_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam, + earray_state_t *state, hsize_t idx) { eiter_fw_t *eiter = (eiter_fw_t *)_eiter; @@ -1369,54 +1391,56 @@ eiter_fw_state(void *_eiter, const H5EA_create_t *cparam, HDassert(state); /* Compute the state of the extensible array */ - state->hdr_size = EA_HDR_SIZE; - state->nindex_blks = 1; + state->hdr_size = EA_HDR_SIZE; + state->nindex_blks = 1; state->index_blk_size = EA_IBLOCK_SIZE; - state->max_idx_set = idx + 1; - if(idx < cparam->idx_blk_elmts) { - state->nelmts = (hsize_t)cparam->idx_blk_elmts; + state->max_idx_set = idx + 1; + if (idx < cparam->idx_blk_elmts) { + state->nelmts = (hsize_t)cparam->idx_blk_elmts; state->nsuper_blks = state->ndata_blks = (hsize_t)0; state->super_blk_size = state->data_blk_size = (hsize_t)0; } /* end if */ else { - unsigned sblk_idx; /* Which superblock does this index fall in? */ + unsigned sblk_idx; /* Which superblock does this index fall in? */ /* Compute super block index for element index */ /* (same eqn. as in H5EA__dblock_sblk_idx()) */ - sblk_idx = H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); + sblk_idx = + H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); #ifdef QAK -HDfprintf(stderr, "idx = %Hu, tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", idx, sblk_idx, tparam->sblk_info[sblk_idx].ndblks, tparam->sblk_info[sblk_idx].dblk_nelmts, tparam->sblk_info[sblk_idx].start_idx, tparam->sblk_info[sblk_idx].start_dblk); + HDfprintf(stderr, "idx = %Hu, tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", idx, sblk_idx, + tparam->sblk_info[sblk_idx].ndblks, tparam->sblk_info[sblk_idx].dblk_nelmts, + tparam->sblk_info[sblk_idx].start_idx, tparam->sblk_info[sblk_idx].start_dblk); #endif /* QAK */ state->nelmts = EA_NELMTS(cparam, tparam, idx, sblk_idx); #ifdef QAK -HDfprintf(stderr, "state->nelmts = %Hu\n", state->nelmts); + HDfprintf(stderr, "state->nelmts = %Hu\n", state->nelmts); #endif /* QAK */ state->ndata_blks = EA_NDATA_BLKS(cparam, tparam, idx, sblk_idx); #ifdef QAK -HDfprintf(stderr, "state->ndata_blks = %Hu\n", state->ndata_blks); + HDfprintf(stderr, "state->ndata_blks = %Hu\n", state->ndata_blks); #endif /* QAK */ /* Check if we have any super blocks yet */ - if(tparam->sblk_info[sblk_idx].ndblks >= cparam->sup_blk_min_data_ptrs) { + if (tparam->sblk_info[sblk_idx].ndblks >= cparam->sup_blk_min_data_ptrs) { /* Check if this is the first superblock */ - if(sblk_idx < eiter->base_sblk_idx) + if (sblk_idx < eiter->base_sblk_idx) eiter->base_sblk_idx = sblk_idx; state->nsuper_blks = (sblk_idx - eiter->base_sblk_idx) + 1; #ifdef QAK -HDfprintf(stderr, "state->nsuper_blks = %Hu\n", state->nsuper_blks); -#endif /* QAK */ + HDfprintf(stderr, "state->nsuper_blks = %Hu\n", state->nsuper_blks); +#endif /* QAK */ } /* end if */ else state->nsuper_blks = 0; } /* end else */ - return(0); + return (0); } /* end eiter_fw_state() */ - /*------------------------------------------------------------------------- * Function: eiter_fw_term * @@ -1439,29 +1463,28 @@ eiter_fw_term(void *eiter) /* Free iteration object */ HDfree(eiter); - return(0); + return (0); } /* end eiter_fw_term() */ /* Extensible array iterator class for forward iteration */ static const earray_iter_t ea_iter_fw = { - eiter_fw_init, /* Iterator init */ - eiter_fw_next, /* Next array index */ - eiter_fw_max, /* Max. array index */ - eiter_fw_state, /* State of the extensible array */ - eiter_fw_term /* Iterator term */ + eiter_fw_init, /* Iterator init */ + eiter_fw_next, /* Next array index */ + eiter_fw_max, /* Max. array index */ + eiter_fw_state, /* State of the extensible array */ + eiter_fw_term /* Iterator term */ }; /* Extensible array iterator info for reverse iteration */ typedef struct eiter_rv_t { - hsize_t idx; /* Index of next array location */ - hsize_t max; /* Index of max. array location */ - hsize_t max_sblk_idx; /* Which superblock does the max. array location fall in? */ - hsize_t max_nelmts; /* Max. # of elements for array */ - hsize_t max_ndata_blks; /* Max. # of data blocks for array */ - hsize_t idx_blk_nsblks; /* Number of superblocks directly pointed to in the index block */ + hsize_t idx; /* Index of next array location */ + hsize_t max; /* Index of max. array location */ + hsize_t max_sblk_idx; /* Which superblock does the max. array location fall in? */ + hsize_t max_nelmts; /* Max. # of elements for array */ + hsize_t max_ndata_blks; /* Max. # of data blocks for array */ + hsize_t idx_blk_nsblks; /* Number of superblocks directly pointed to in the index block */ } eiter_rv_t; - /*------------------------------------------------------------------------- * Function: eiter_rv_init * @@ -1476,10 +1499,9 @@ typedef struct eiter_rv_t { *------------------------------------------------------------------------- */ static void * -eiter_rv_init(const H5EA_create_t *cparam, const earray_test_param_t *tparam, - hsize_t cnt) +eiter_rv_init(const H5EA_create_t *cparam, const earray_test_param_t *tparam, hsize_t cnt) { - eiter_rv_t *eiter; /* Reverse element iteration object */ + eiter_rv_t *eiter; /* Reverse element iteration object */ /* Allocate space for the element iteration object */ eiter = (eiter_rv_t *)HDmalloc(sizeof(eiter_rv_t)); @@ -1488,24 +1510,24 @@ eiter_rv_init(const H5EA_create_t *cparam, const earray_test_param_t *tparam, /* Initialize reverse iteration info */ eiter->idx = cnt - 1; eiter->max = cnt - 1; - if(cnt > cparam->idx_blk_elmts) { - eiter->max_sblk_idx = H5VM_log2_gen((uint64_t)(((eiter->max - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); - eiter->max_nelmts = EA_NELMTS(cparam, tparam, eiter->max, eiter->max_sblk_idx); + if (cnt > cparam->idx_blk_elmts) { + eiter->max_sblk_idx = H5VM_log2_gen( + (uint64_t)(((eiter->max - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); + eiter->max_nelmts = EA_NELMTS(cparam, tparam, eiter->max, eiter->max_sblk_idx); eiter->max_ndata_blks = EA_NDATA_BLKS(cparam, tparam, eiter->max, eiter->max_sblk_idx); eiter->idx_blk_nsblks = 2 * H5VM_log2_of2((uint32_t)cparam->sup_blk_min_data_ptrs); } /* end if */ else { - eiter->max_sblk_idx = (hsize_t)0; - eiter->max_nelmts = (hsize_t)0; + eiter->max_sblk_idx = (hsize_t)0; + eiter->max_nelmts = (hsize_t)0; eiter->max_ndata_blks = (hsize_t)0; eiter->idx_blk_nsblks = (hsize_t)0; } /* end else */ /* Return iteration object */ - return(eiter); + return (eiter); } /* end eiter_rv_init() */ - /*------------------------------------------------------------------------- * Function: eiter_rv_next * @@ -1523,7 +1545,7 @@ static hssize_t eiter_rv_next(void *_eiter) { eiter_rv_t *eiter = (eiter_rv_t *)_eiter; - hssize_t ret_val; + hssize_t ret_val; /* Sanity check */ HDassert(eiter); @@ -1531,10 +1553,9 @@ eiter_rv_next(void *_eiter) /* Get the next array index to test */ ret_val = (hssize_t)eiter->idx--; - return(ret_val); + return (ret_val); } /* end eiter_rv_next() */ - /*------------------------------------------------------------------------- * Function: eiter_rv_max * @@ -1557,10 +1578,9 @@ eiter_rv_max(const void *_eiter) HDassert(eiter); /* Return the max. array index used */ - return((hssize_t)eiter->max); + return ((hssize_t)eiter->max); } /* end eiter_rv_max() */ - /*------------------------------------------------------------------------- * Function: eiter_rv_state * @@ -1575,8 +1595,8 @@ eiter_rv_max(const void *_eiter) *------------------------------------------------------------------------- */ static int -eiter_rv_state(void *_eiter, const H5EA_create_t *cparam, - const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx) +eiter_rv_state(void *_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam, + earray_state_t *state, hsize_t idx) { eiter_rv_t *eiter = (eiter_rv_t *)_eiter; @@ -1587,78 +1607,91 @@ eiter_rv_state(void *_eiter, const H5EA_create_t *cparam, HDassert(state); /* Compute the state of the extensible array */ - state->hdr_size = EA_HDR_SIZE; - state->nindex_blks = 1; + state->hdr_size = EA_HDR_SIZE; + state->nindex_blks = 1; state->index_blk_size = EA_IBLOCK_SIZE; - state->max_idx_set = eiter->max + 1; - if(eiter->max < cparam->idx_blk_elmts) { - state->nelmts = (hsize_t)cparam->idx_blk_elmts; + state->max_idx_set = eiter->max + 1; + if (eiter->max < cparam->idx_blk_elmts) { + state->nelmts = (hsize_t)cparam->idx_blk_elmts; state->nsuper_blks = state->ndata_blks = (hsize_t)0; } /* end if */ else { - hsize_t idx_nelmts; /* # of elements for array index */ - hsize_t idx_ndata_blks; /* # of data blocks for array index */ - hsize_t loc_idx = 0; /* Local index, for computing an offset in next lower data block */ - unsigned idx_sblk_idx; /* Which superblock does this index fall in? */ - unsigned loc_sblk_idx = 0; /* Which superblock does the local index fall in? */ + hsize_t idx_nelmts; /* # of elements for array index */ + hsize_t idx_ndata_blks; /* # of data blocks for array index */ + hsize_t loc_idx = 0; /* Local index, for computing an offset in next lower data block */ + unsigned idx_sblk_idx; /* Which superblock does this index fall in? */ + unsigned loc_sblk_idx = 0; /* Which superblock does the local index fall in? */ /* Compute super block index for element index */ /* (same eqn. as in H5EA__dblock_sblk_idx()) */ - if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts) + if (idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts) idx_sblk_idx = 0; else { - hsize_t tmp_idx; /* Temporary index in superblock */ - hsize_t dblk_idx; /* Index of data block within superblock */ + hsize_t tmp_idx; /* Temporary index in superblock */ + hsize_t dblk_idx; /* Index of data block within superblock */ - idx_sblk_idx = H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); - tmp_idx = idx - (cparam->idx_blk_elmts + tparam->sblk_info[idx_sblk_idx].start_idx); + idx_sblk_idx = + H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); + tmp_idx = idx - (cparam->idx_blk_elmts + tparam->sblk_info[idx_sblk_idx].start_idx); dblk_idx = tmp_idx / tparam->sblk_info[idx_sblk_idx].dblk_nelmts; - if(dblk_idx > 0) + if (dblk_idx > 0) loc_idx = idx - tparam->sblk_info[idx_sblk_idx].dblk_nelmts; else loc_idx = cparam->idx_blk_elmts + tparam->sblk_info[idx_sblk_idx].start_idx - 1; - loc_sblk_idx = H5VM_log2_gen((uint64_t)(((loc_idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); + loc_sblk_idx = H5VM_log2_gen( + (uint64_t)(((loc_idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); } /* end else */ #ifdef QAK -HDfprintf(stderr, "idx = %Hu, loc_idx = %Hu, eiter->max_sblk_idx = %u, idx_sblk_idx = %u, loc_sblk_idx = %u\n", idx, loc_idx, eiter->max_sblk_idx, idx_sblk_idx, loc_sblk_idx); -HDfprintf(stderr, "tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", idx_sblk_idx, tparam->sblk_info[idx_sblk_idx].ndblks, tparam->sblk_info[idx_sblk_idx].dblk_nelmts, tparam->sblk_info[idx_sblk_idx].start_idx, tparam->sblk_info[idx_sblk_idx].start_dblk); -HDfprintf(stderr, "tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", eiter->max_sblk_idx, tparam->sblk_info[eiter->max_sblk_idx].ndblks, tparam->sblk_info[eiter->max_sblk_idx].dblk_nelmts, tparam->sblk_info[eiter->max_sblk_idx].start_idx, tparam->sblk_info[eiter->max_sblk_idx].start_dblk); + HDfprintf( + stderr, + "idx = %Hu, loc_idx = %Hu, eiter->max_sblk_idx = %u, idx_sblk_idx = %u, loc_sblk_idx = %u\n", idx, + loc_idx, eiter->max_sblk_idx, idx_sblk_idx, loc_sblk_idx); + HDfprintf(stderr, "tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", idx_sblk_idx, + tparam->sblk_info[idx_sblk_idx].ndblks, tparam->sblk_info[idx_sblk_idx].dblk_nelmts, + tparam->sblk_info[idx_sblk_idx].start_idx, tparam->sblk_info[idx_sblk_idx].start_dblk); + HDfprintf(stderr, "tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", eiter->max_sblk_idx, + tparam->sblk_info[eiter->max_sblk_idx].ndblks, + tparam->sblk_info[eiter->max_sblk_idx].dblk_nelmts, + tparam->sblk_info[eiter->max_sblk_idx].start_idx, + tparam->sblk_info[eiter->max_sblk_idx].start_dblk); #endif /* QAK */ - if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts) + if (idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts) idx_nelmts = (hsize_t)cparam->idx_blk_elmts; else idx_nelmts = EA_NELMTS(cparam, tparam, loc_idx, loc_sblk_idx); state->nelmts = (eiter->max_nelmts - idx_nelmts) + cparam->idx_blk_elmts; #ifdef QAK -HDfprintf(stderr, "eiter->max_nelmts = %Hu, idx_nelmts = %Hu, state->nelmts = %Hu\n", eiter->max_nelmts, idx_nelmts, state->nelmts); + HDfprintf(stderr, "eiter->max_nelmts = %Hu, idx_nelmts = %Hu, state->nelmts = %Hu\n", + eiter->max_nelmts, idx_nelmts, state->nelmts); #endif /* QAK */ - if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts) + if (idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts) idx_ndata_blks = 0; else idx_ndata_blks = EA_NDATA_BLKS(cparam, tparam, loc_idx, loc_sblk_idx); state->ndata_blks = eiter->max_ndata_blks - idx_ndata_blks; #ifdef QAK -HDfprintf(stderr, "eiter->max_ndata_blks = %Hu, idx_ndata_blks = %Hu, state->ndata_blks = %Hu\n", eiter->max_ndata_blks, idx_ndata_blks, state->ndata_blks); + HDfprintf(stderr, "eiter->max_ndata_blks = %Hu, idx_ndata_blks = %Hu, state->ndata_blks = %Hu\n", + eiter->max_ndata_blks, idx_ndata_blks, state->ndata_blks); #endif /* QAK */ /* Check if we have any super blocks yet */ - if(tparam->sblk_info[eiter->max_sblk_idx].ndblks >= cparam->sup_blk_min_data_ptrs) { - if(idx_sblk_idx > eiter->idx_blk_nsblks) + if (tparam->sblk_info[eiter->max_sblk_idx].ndblks >= cparam->sup_blk_min_data_ptrs) { + if (idx_sblk_idx > eiter->idx_blk_nsblks) state->nsuper_blks = (eiter->max_sblk_idx - idx_sblk_idx) + 1; else state->nsuper_blks = (eiter->max_sblk_idx - eiter->idx_blk_nsblks) + 1; #ifdef QAK -HDfprintf(stderr, "eiter->idx_blk_nsblks = %Hu, state->nsuper_blks = %Hu\n", eiter->idx_blk_nsblks, state->nsuper_blks); -#endif /* QAK */ + HDfprintf(stderr, "eiter->idx_blk_nsblks = %Hu, state->nsuper_blks = %Hu\n", + eiter->idx_blk_nsblks, state->nsuper_blks); +#endif /* QAK */ } /* end if */ - } /* end else */ + } /* end else */ - return(0); + return (0); } /* end eiter_rv_state() */ - /*------------------------------------------------------------------------- * Function: eiter_rv_term * @@ -1681,26 +1714,25 @@ eiter_rv_term(void *eiter) /* Free iteration object */ HDfree(eiter); - return(0); + return (0); } /* end eiter_rv_term() */ /* Extensible array iterator class for reverse iteration */ static const earray_iter_t ea_iter_rv = { - eiter_rv_init, /* Iterator init */ - eiter_rv_next, /* Next array index */ - eiter_rv_max, /* Max. array index written */ - eiter_rv_state, /* State of the extensible array */ - eiter_rv_term /* Iterator term */ + eiter_rv_init, /* Iterator init */ + eiter_rv_next, /* Next array index */ + eiter_rv_max, /* Max. array index written */ + eiter_rv_state, /* State of the extensible array */ + eiter_rv_term /* Iterator term */ }; /* Extensible array iterator info for random iteration */ typedef struct eiter_rnd_t { - hsize_t max; /* Max. array index used */ - hsize_t pos; /* Position in shuffled array */ - hsize_t *idx; /* Array of shuffled indices */ + hsize_t max; /* Max. array index used */ + hsize_t pos; /* Position in shuffled array */ + hsize_t *idx; /* Array of shuffled indices */ } eiter_rnd_t; - /*------------------------------------------------------------------------- * Function: eiter_rnd_init * @@ -1716,10 +1748,10 @@ typedef struct eiter_rnd_t { */ static void * eiter_rnd_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_param_t H5_ATTR_UNUSED *tparam, - hsize_t cnt) + hsize_t cnt) { - eiter_rnd_t *eiter; /* Random element iteration object */ - size_t u; /* Local index variable */ + eiter_rnd_t *eiter; /* Random element iteration object */ + size_t u; /* Local index variable */ /* Allocate space for the element iteration object */ eiter = (eiter_rnd_t *)HDmalloc(sizeof(eiter_rnd_t)); @@ -1732,27 +1764,26 @@ eiter_rnd_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_par /* Initialize reverse iteration info */ eiter->max = 0; eiter->pos = 0; - for(u = 0; u < (size_t)cnt; u++) + for (u = 0; u < (size_t)cnt; u++) eiter->idx[u] = (hsize_t)u; /* Randomly shuffle array indices */ - if(cnt > 1) { - for(u = 0; u < (size_t)cnt; u++) { - size_t swap_idx; /* Location to swap with when shuffling */ - hsize_t temp_idx; /* Temporary index */ - - swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u; - temp_idx = eiter->idx[u]; - eiter->idx[u] = eiter->idx[swap_idx]; + if (cnt > 1) { + for (u = 0; u < (size_t)cnt; u++) { + size_t swap_idx; /* Location to swap with when shuffling */ + hsize_t temp_idx; /* Temporary index */ + + swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u; + temp_idx = eiter->idx[u]; + eiter->idx[u] = eiter->idx[swap_idx]; eiter->idx[swap_idx] = temp_idx; } /* end for */ - } /* end if */ + } /* end if */ /* Return iteration object */ - return(eiter); + return (eiter); } /* end eiter_rnd_init() */ - /*------------------------------------------------------------------------- * Function: eiter_rnd_next * @@ -1770,7 +1801,7 @@ static hssize_t eiter_rnd_next(void *_eiter) { eiter_rnd_t *eiter = (eiter_rnd_t *)_eiter; - hssize_t ret_val; + hssize_t ret_val; /* Sanity check */ HDassert(eiter); @@ -1780,13 +1811,12 @@ eiter_rnd_next(void *_eiter) eiter->pos++; /* Check for new max. value */ - if((hsize_t)ret_val > eiter->max) + if ((hsize_t)ret_val > eiter->max) eiter->max = (hsize_t)ret_val; - return(ret_val); + return (ret_val); } /* end eiter_rnd_next() */ - /*------------------------------------------------------------------------- * Function: eiter_rnd_max * @@ -1809,10 +1839,9 @@ eiter_rnd_max(const void *_eiter) HDassert(eiter); /* Return the max. array index used */ - return((hssize_t)eiter->max); + return ((hssize_t)eiter->max); } /* end eiter_rnd_max() */ - /*------------------------------------------------------------------------- * Function: eiter_rnd_term * @@ -1841,19 +1870,18 @@ eiter_rnd_term(void *_eiter) /* Free iteration object */ HDfree(eiter); - return(0); + return (0); } /* end eiter_rnd_term() */ /* Extensible array iterator class for random iteration */ static const earray_iter_t ea_iter_rnd = { - eiter_rnd_init, /* Iterator init */ - eiter_rnd_next, /* Next array index */ - eiter_rnd_max, /* Max. array index written */ - NULL, /* State of the extensible array */ - eiter_rnd_term /* Iterator term */ + eiter_rnd_init, /* Iterator init */ + eiter_rnd_next, /* Next array index */ + eiter_rnd_max, /* Max. array index written */ + NULL, /* State of the extensible array */ + eiter_rnd_term /* Iterator term */ }; - /*------------------------------------------------------------------------- * Function: eiter_rnd2_init * @@ -1869,10 +1897,10 @@ static const earray_iter_t ea_iter_rnd = { */ static void * eiter_rnd2_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_param_t H5_ATTR_UNUSED *tparam, - hsize_t cnt) + hsize_t cnt) { - eiter_rnd_t *eiter; /* Random element iteration object */ - size_t u; /* Local index variable */ + eiter_rnd_t *eiter; /* Random element iteration object */ + size_t u; /* Local index variable */ /* Allocate space for the element iteration object */ eiter = (eiter_rnd_t *)HDmalloc(sizeof(eiter_rnd_t)); @@ -1887,24 +1915,24 @@ eiter_rnd2_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_pa eiter->pos = 0; /* Randomly shuffle array indices */ - if(cnt > 1) { - hsize_t *tmp_idx; /* Temporary index array */ - hsize_t sparse_cnt = (hsize_t)(cnt * EA_RND2_SCALE); /* Sparse range to choose from */ + if (cnt > 1) { + hsize_t *tmp_idx; /* Temporary index array */ + hsize_t sparse_cnt = (hsize_t)(cnt * EA_RND2_SCALE); /* Sparse range to choose from */ /* Allocate temporary index array */ tmp_idx = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)sparse_cnt); HDassert(tmp_idx); /* Initialize temporary index array, for shuffling */ - for(u = 0; u < (size_t)sparse_cnt; u++) + for (u = 0; u < (size_t)sparse_cnt; u++) tmp_idx[u] = (hsize_t)u; /* Shuffle index elements & store in final array */ - for(u = 0; u < (size_t)cnt; u++) { - size_t swap_idx; /* Location to swap with when shuffling */ + for (u = 0; u < (size_t)cnt; u++) { + size_t swap_idx; /* Location to swap with when shuffling */ - swap_idx = ((size_t)HDrandom() % ((size_t)sparse_cnt - u)) + u; - eiter->idx[u] = tmp_idx[swap_idx]; + swap_idx = ((size_t)HDrandom() % ((size_t)sparse_cnt - u)) + u; + eiter->idx[u] = tmp_idx[swap_idx]; tmp_idx[swap_idx] = tmp_idx[u]; } /* end for */ @@ -1912,32 +1940,31 @@ eiter_rnd2_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_pa HDfree(tmp_idx); } /* end if */ else { - for(u = 0; u < (size_t)cnt; u++) + for (u = 0; u < (size_t)cnt; u++) eiter->idx[u] = (hsize_t)u; } /* end else */ /* Return iteration object */ - return(eiter); + return (eiter); } /* end eiter_rnd2_init() */ /* Extensible array iterator class for random iteration */ static const earray_iter_t ea_iter_rnd2 = { - eiter_rnd2_init, /* Iterator init */ - eiter_rnd_next, /* Next array index */ - eiter_rnd_max, /* Max. array index written */ - NULL, /* State of the extensible array */ - eiter_rnd_term /* Iterator term */ + eiter_rnd2_init, /* Iterator init */ + eiter_rnd_next, /* Next array index */ + eiter_rnd_max, /* Max. array index written */ + NULL, /* State of the extensible array */ + eiter_rnd_term /* Iterator term */ }; /* Extensible array iterator info for cyclic iteration */ typedef struct eiter_cyc_t { - hsize_t max; /* Max. array index used */ - hsize_t pos; /* Position in shuffled array */ - hsize_t cnt; /* # of elements to store */ - hsize_t cyc; /* Cycle of elements to choose from */ + hsize_t max; /* Max. array index used */ + hsize_t pos; /* Position in shuffled array */ + hsize_t cnt; /* # of elements to store */ + hsize_t cyc; /* Cycle of elements to choose from */ } eiter_cyc_t; - /*------------------------------------------------------------------------- * Function: eiter_cyc_init * @@ -1953,9 +1980,9 @@ typedef struct eiter_cyc_t { */ static void * eiter_cyc_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_param_t H5_ATTR_UNUSED *tparam, - hsize_t cnt) + hsize_t cnt) { - eiter_cyc_t *eiter; /* Cyclic element iteration object */ + eiter_cyc_t *eiter; /* Cyclic element iteration object */ /* Allocate space for the element iteration object */ eiter = (eiter_cyc_t *)HDmalloc(sizeof(eiter_cyc_t)); @@ -1968,10 +1995,9 @@ eiter_cyc_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_par eiter->cyc = 0; /* Return iteration object */ - return(eiter); + return (eiter); } /* end eiter_cyc_init() */ - /*------------------------------------------------------------------------- * Function: eiter_cyc_next * @@ -1989,7 +2015,7 @@ static hssize_t eiter_cyc_next(void *_eiter) { eiter_cyc_t *eiter = (eiter_cyc_t *)_eiter; - hssize_t ret_val; + hssize_t ret_val; /* Sanity check */ HDassert(eiter); @@ -1997,17 +2023,16 @@ eiter_cyc_next(void *_eiter) /* Get the next array index to test */ ret_val = (hssize_t)eiter->pos; eiter->pos += EA_CYC_COUNT; - if(eiter->pos >= eiter->cnt) + if (eiter->pos >= eiter->cnt) eiter->pos = ++eiter->cyc; /* Check for new max. value */ - if((hsize_t)ret_val > eiter->max) + if ((hsize_t)ret_val > eiter->max) eiter->max = (hsize_t)ret_val; - return(ret_val); + return (ret_val); } /* end eiter_cyc_next() */ - /*------------------------------------------------------------------------- * Function: eiter_cyc_max * @@ -2030,10 +2055,9 @@ eiter_cyc_max(const void *_eiter) HDassert(eiter); /* Return the max. array index used */ - return((hssize_t)eiter->max); + return ((hssize_t)eiter->max); } /* end eiter_cyc_max() */ - /*------------------------------------------------------------------------- * Function: eiter_cyc_term * @@ -2058,19 +2082,18 @@ eiter_cyc_term(void *_eiter) /* Free iteration object */ HDfree(eiter); - return(0); + return (0); } /* end eiter_cyc_term() */ /* Extensible array iterator class for cyclic iteration */ static const earray_iter_t ea_iter_cyc = { - eiter_cyc_init, /* Iterator init */ - eiter_cyc_next, /* Next array index */ - eiter_cyc_max, /* Max. array index written */ - NULL, /* State of the extensible array */ - eiter_cyc_term /* Iterator term */ + eiter_cyc_init, /* Iterator init */ + eiter_cyc_next, /* Next array index */ + eiter_cyc_max, /* Max. array index written */ + NULL, /* State of the extensible array */ + eiter_cyc_term /* Iterator term */ }; - /*------------------------------------------------------------------------- * Function: test_set_elmts * @@ -2085,23 +2108,23 @@ static const earray_iter_t ea_iter_cyc = { *------------------------------------------------------------------------- */ static unsigned -test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, - hsize_t nelmts, const char *test_str) +test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, hsize_t nelmts, + const char *test_str) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5EA_t *ea = NULL; /* Extensible array wrapper */ - void *eiter_info; /* Extensible array iterator info */ - earray_state_t state; /* State of extensible array */ - uint64_t welmt; /* Element to write */ - uint64_t relmt; /* Element to read */ - hsize_t nelmts_written; /* Highest element written in array */ - hsize_t cnt; /* Count of array indices */ - hssize_t smax; /* Index value of max. element set */ - hsize_t max; /* Index value of max. element set */ - hssize_t sidx; /* Index value of first element of first data block */ - hsize_t idx; /* Index value of first element of first data block */ - haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5EA_t * ea = NULL; /* Extensible array wrapper */ + void * eiter_info; /* Extensible array iterator info */ + earray_state_t state; /* State of extensible array */ + uint64_t welmt; /* Element to write */ + uint64_t relmt; /* Element to read */ + hsize_t nelmts_written; /* Highest element written in array */ + hsize_t cnt; /* Count of array indices */ + hssize_t smax; /* Index value of max. element set */ + hsize_t max; /* Index value of max. element set */ + hssize_t sidx; /* Index value of first element of first data block */ + hsize_t idx; /* Index value of first element of first data block */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* * Display testing message @@ -2109,128 +2132,127 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TESTING("%s", test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* Create array */ - if(create_array(f, cparam, &ea, &ea_addr, NULL) < 0) + if (create_array(f, cparam, &ea, &ea_addr, NULL) < 0) TEST_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, &ea, ea_addr, tparam) < 0) + if (reopen_file(&file, &f, fapl, &ea, ea_addr, tparam) < 0) TEST_ERROR /* Verify high-water # of elements written */ nelmts_written = (hsize_t)ULLONG_MAX; - if(H5EA_get_nelmts(ea, &nelmts_written) < 0) + if (H5EA_get_nelmts(ea, &nelmts_written) < 0) FAIL_STACK_ERROR - if(nelmts_written != 0) + if (nelmts_written != 0) TEST_ERROR /* Verify array state */ HDmemset(&state, 0, sizeof(state)); state.hdr_size = EA_HDR_SIZE; - if(check_stats(ea, &state)) + if (check_stats(ea, &state)) TEST_ERROR /* Get all elements from empty array */ /* Initialize iterator */ - if(NULL == (eiter_info = tparam->eiter->init(cparam, tparam, nelmts))) + if (NULL == (eiter_info = tparam->eiter->init(cparam, tparam, nelmts))) TEST_ERROR /* Get elements of array */ - for(cnt = 0; cnt < nelmts; cnt++) { + for (cnt = 0; cnt < nelmts; cnt++) { /* Get the array index */ - if((sidx = tparam->eiter->next(eiter_info)) < 0) + if ((sidx = tparam->eiter->next(eiter_info)) < 0) TEST_ERROR idx = (hsize_t)sidx; /* Retrieve element of array (not set yet) */ relmt = (uint64_t)0; - if(H5EA_get(ea, idx, &relmt) < 0) + if (H5EA_get(ea, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify element is fill value for array */ - if(relmt != H5EA_TEST_FILL) + if (relmt != H5EA_TEST_FILL) TEST_ERROR } /* end for */ /* Shutdown iterator */ - if(tparam->eiter->term(eiter_info) < 0) + if (tparam->eiter->term(eiter_info) < 0) TEST_ERROR - /* Set (& get) all elements from empty array */ /* Initialize iterator */ - if(NULL == (eiter_info = tparam->eiter->init(cparam, tparam, nelmts))) + if (NULL == (eiter_info = tparam->eiter->init(cparam, tparam, nelmts))) TEST_ERROR /* Set elements of array */ - for(cnt = 0; cnt < nelmts; cnt++) { + for (cnt = 0; cnt < nelmts; cnt++) { /* Get the array index */ - if((sidx = tparam->eiter->next(eiter_info)) < 0) + if ((sidx = tparam->eiter->next(eiter_info)) < 0) TEST_ERROR idx = (hsize_t)sidx; /* Retrieve element of array (not set yet) */ relmt = (uint64_t)0; - if(H5EA_get(ea, idx, &relmt) < 0) + if (H5EA_get(ea, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify element is fill value for array */ - if(relmt != H5EA_TEST_FILL) + if (relmt != H5EA_TEST_FILL) TEST_ERROR /* Set element of array */ welmt = (uint64_t)7 + idx; - if(H5EA_set(ea, idx, &welmt) < 0) + if (H5EA_set(ea, idx, &welmt) < 0) FAIL_STACK_ERROR /* Get the max. array index */ - if((smax = tparam->eiter->max_elem(eiter_info)) < 0) + if ((smax = tparam->eiter->max_elem(eiter_info)) < 0) TEST_ERROR max = (hsize_t)smax; /* Verify high-water # of elements written */ nelmts_written = (hsize_t)ULLONG_MAX; - if(H5EA_get_nelmts(ea, &nelmts_written) < 0) + if (H5EA_get_nelmts(ea, &nelmts_written) < 0) FAIL_STACK_ERROR - if(nelmts_written != (max + 1)) + if (nelmts_written != (max + 1)) TEST_ERROR /* Check if array state is available */ - if(tparam->eiter->state) { + if (tparam->eiter->state) { /* Get the extensible array state */ - if(tparam->eiter->state(eiter_info, cparam, tparam, &state, idx) < 0) + if (tparam->eiter->state(eiter_info, cparam, tparam, &state, idx) < 0) TEST_ERROR /* Verify array state */ - if(check_stats(ea, &state)) + if (check_stats(ea, &state)) TEST_ERROR } /* end if */ /* Retrieve element of array (set now) */ relmt = (uint64_t)0; - if(H5EA_get(ea, idx, &relmt) < 0) + if (H5EA_get(ea, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify element is value written */ - if(relmt != welmt) + if (relmt != welmt) TEST_ERROR } /* end for */ /* Shutdown iterator */ - if(tparam->eiter->term(eiter_info) < 0) + if (tparam->eiter->term(eiter_info) < 0) TEST_ERROR /* Close array, delete array, close file & verify file is empty */ - if(finish(file, fapl, f, ea, ea_addr) < 0) + if (finish(file, fapl, f, ea, ea_addr) < 0) TEST_ERROR /* All tests passed */ @@ -2239,16 +2261,17 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, return 0; error: - H5E_BEGIN_TRY { - if(ea) + H5E_BEGIN_TRY + { + if (ea) H5EA_close(ea); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_set_elmts() */ - /*------------------------------------------------------------------------- * Function: test_skip_elmts * @@ -2263,19 +2286,19 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, - hsize_t skip_elmts, const char *test_str) +test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, hsize_t skip_elmts, + const char *test_str) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5EA_t *ea = NULL; /* Extensible array wrapper */ - earray_state_t state; /* State of extensible array */ - uint64_t welmt; /* Element to write */ - uint64_t relmt; /* Element to read */ - hsize_t nelmts_written; /* Highest element written in array */ - hsize_t idx; /* Index value of element to get */ - hsize_t cnt; /* Count of array indices */ - haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5EA_t * ea = NULL; /* Extensible array wrapper */ + earray_state_t state; /* State of extensible array */ + uint64_t welmt; /* Element to write */ + uint64_t relmt; /* Element to read */ + hsize_t nelmts_written; /* Highest element written in array */ + hsize_t idx; /* Index value of element to get */ + hsize_t cnt; /* Count of array indices */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* * Display testing message @@ -2283,32 +2306,32 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TESTING("%s", test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + if (create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* Create array */ - if(create_array(f, cparam, &ea, &ea_addr, NULL) < 0) + if (create_array(f, cparam, &ea, &ea_addr, NULL) < 0) TEST_ERROR /* Verify the creation parameters */ - if(verify_cparam(ea, cparam) < 0) + if (verify_cparam(ea, cparam) < 0) TEST_ERROR /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, &ea, ea_addr, tparam) < 0) + if (reopen_file(&file, &f, fapl, &ea, ea_addr, tparam) < 0) TEST_ERROR /* Verify high-water # of elements written */ nelmts_written = (hsize_t)ULLONG_MAX; - if(H5EA_get_nelmts(ea, &nelmts_written) < 0) + if (H5EA_get_nelmts(ea, &nelmts_written) < 0) FAIL_STACK_ERROR - if(nelmts_written != 0) + if (nelmts_written != 0) TEST_ERROR /* Verify array state */ HDmemset(&state, 0, sizeof(state)); state.hdr_size = EA_HDR_SIZE; - if(check_stats(ea, &state)) + if (check_stats(ea, &state)) TEST_ERROR /* Set (& get) element after skipping elements */ @@ -2316,78 +2339,79 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, /* Retrieve element of array (not set yet) */ relmt = (uint64_t)0; - if(H5EA_get(ea, idx, &relmt) < 0) + if (H5EA_get(ea, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify element is fill value for array */ - if(relmt != H5EA_TEST_FILL) + if (relmt != H5EA_TEST_FILL) TEST_ERROR /* Set element of array */ welmt = (uint64_t)7 + idx; - if(H5EA_set(ea, idx, &welmt) < 0) + if (H5EA_set(ea, idx, &welmt) < 0) FAIL_STACK_ERROR /* Verify high-water # of elements written */ nelmts_written = (hsize_t)ULLONG_MAX; - if(H5EA_get_nelmts(ea, &nelmts_written) < 0) + if (H5EA_get_nelmts(ea, &nelmts_written) < 0) FAIL_STACK_ERROR - if(nelmts_written != (idx + 1)) + if (nelmts_written != (idx + 1)) TEST_ERROR /* Set array state */ HDmemset(&state, 0, sizeof(state)); - state.hdr_size = EA_HDR_SIZE; - state.nindex_blks = 1; + state.hdr_size = EA_HDR_SIZE; + state.nindex_blks = 1; state.index_blk_size = EA_IBLOCK_SIZE; - state.max_idx_set = idx + 1; - if(1 == skip_elmts) { - state.nelmts = (hsize_t)cparam->idx_blk_elmts; + state.max_idx_set = idx + 1; + if (1 == skip_elmts) { + state.nelmts = (hsize_t)cparam->idx_blk_elmts; state.nsuper_blks = state.ndata_blks = (hsize_t)0; } /* end if */ - else if(cparam->idx_blk_elmts == skip_elmts) { - state.nelmts = (hsize_t)cparam->idx_blk_elmts + cparam->data_blk_min_elmts; - state.ndata_blks = (hsize_t)1; + else if (cparam->idx_blk_elmts == skip_elmts) { + state.nelmts = (hsize_t)cparam->idx_blk_elmts + cparam->data_blk_min_elmts; + state.ndata_blks = (hsize_t)1; state.nsuper_blks = (hsize_t)0; } /* end if */ else { - unsigned sblk_idx; /* Which superblock does this index fall in? */ + unsigned sblk_idx; /* Which superblock does this index fall in? */ /* Compute super block index for element index */ /* (same eqn. as in H5EA__dblock_sblk_idx()) */ - sblk_idx = H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); - state.nelmts = (hsize_t)cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].dblk_nelmts; - state.ndata_blks = (hsize_t)1; + sblk_idx = + H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1)); + state.nelmts = (hsize_t)cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].dblk_nelmts; + state.ndata_blks = (hsize_t)1; state.nsuper_blks = (hsize_t)1; } /* end if */ /* Verify array state */ - if(check_stats(ea, &state)) + if (check_stats(ea, &state)) TEST_ERROR /* Retrieve element of array (set now) */ relmt = (uint64_t)0; - if(H5EA_get(ea, idx, &relmt) < 0) + if (H5EA_get(ea, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify element is value written */ - if(relmt != welmt) + if (relmt != welmt) TEST_ERROR /* Get unset elements of array */ - for(cnt = 0; cnt < skip_elmts; cnt++) { + for (cnt = 0; cnt < skip_elmts; cnt++) { /* Retrieve element of array (not set yet) */ relmt = (uint64_t)0; - if(H5EA_get(ea, cnt, &relmt) < 0) + if (H5EA_get(ea, cnt, &relmt) < 0) FAIL_STACK_ERROR /* Verify element is fill value for array */ - if(relmt != H5EA_TEST_FILL) + if (relmt != H5EA_TEST_FILL) TEST_ERROR } /* end for */ /* Close array, delete array, close file & verify file is empty */ - if(finish(file, fapl, f, ea, ea_addr) < 0) + if (finish(file, fapl, f, ea, ea_addr) < 0) TEST_ERROR /* All tests passed */ @@ -2396,16 +2420,17 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, return 0; error: - H5E_BEGIN_TRY { - if(ea) + H5E_BEGIN_TRY + { + if (ea) H5EA_close(ea); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_skip_elmts() */ - /*------------------------------------------------------------------------- * Function: main * @@ -2422,28 +2447,29 @@ error: int main(void) { - H5EA_create_t cparam; /* Creation parameters for extensible array */ - earray_test_param_t tparam; /* Testing parameters */ - earray_test_type_t curr_test; /* Current test being worked on */ - earray_iter_type_t curr_iter; /* Current iteration type being worked on */ - hid_t fapl = -1; /* File access property list for data files */ - unsigned nerrors = 0; /* Cumulative error count */ - time_t curr_time; /* Current time, for seeding random number generator */ - int ExpressMode; /* Test express value */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + H5EA_create_t cparam; /* Creation parameters for extensible array */ + earray_test_param_t tparam; /* Testing parameters */ + earray_test_type_t curr_test; /* Current test being worked on */ + earray_iter_type_t curr_iter; /* Current iteration type being worked on */ + hid_t fapl = -1; /* File access property list for data files */ + unsigned nerrors = 0; /* Cumulative error count */ + time_t curr_time; /* Current time, for seeding random number generator */ + int ExpressMode; /* Test express value */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Reset library */ h5_reset(); - fapl = h5_fileaccess(); + fapl = h5_fileaccess(); ExpressMode = GetTestExpress(); - if(ExpressMode > 1) + if (ExpressMode > 1) HDprintf("***Express test mode on. Some tests may be skipped\n"); /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g)); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Seed random #'s */ @@ -2452,32 +2478,31 @@ main(void) /* Create an empty file to retrieve size */ { - hid_t file; /* File ID */ + hid_t file; /* File ID */ - if((file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/no array */ - if((empty_size_g = h5_get_file_size(filename_g, fapl)) < 0) + if ((empty_size_g = h5_get_file_size(filename_g, fapl)) < 0) TEST_ERROR } - /* Initialize extensible array creation parameters */ init_cparam(&cparam); /* Iterate over the testing parameters */ - for(curr_test = EARRAY_TEST_NORMAL; curr_test < EARRAY_TEST_NTESTS; curr_test++) { + for (curr_test = EARRAY_TEST_NORMAL; curr_test < EARRAY_TEST_NTESTS; curr_test++) { /* Initialize the testing parameters */ init_tparam(&tparam, &cparam); /* Set appropriate testing parameters for each test */ - switch(curr_test) { + switch (curr_test) { /* "Normal" testing parameters */ case EARRAY_TEST_NORMAL: puts("Testing with normal parameters"); @@ -2503,15 +2528,15 @@ main(void) nerrors += test_delete_open(fapl, &cparam, &tparam); /* Iterate over the type of capacity tests */ - for(curr_iter = EARRAY_ITER_FW; curr_iter < EARRAY_ITER_NITERS; curr_iter++) { - hsize_t sblk; /* Super block index */ - hsize_t dblk; /* Data block index */ - hsize_t nelmts; /* # of elements to test */ - char test_str[128]; /* String for describing test */ - hsize_t ndblks; /* # of data blocks tested */ + for (curr_iter = EARRAY_ITER_FW; curr_iter < EARRAY_ITER_NITERS; curr_iter++) { + hsize_t sblk; /* Super block index */ + hsize_t dblk; /* Data block index */ + hsize_t nelmts; /* # of elements to test */ + char test_str[128]; /* String for describing test */ + hsize_t ndblks; /* # of data blocks tested */ /* Set appropriate parameters for each type of iteration */ - switch(curr_iter) { + switch (curr_iter) { /* "Forward" testing parameters */ case EARRAY_ITER_FW: puts("Testing with forward iteration"); @@ -2550,40 +2575,52 @@ main(void) /* Basic capacity tests */ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)1, "setting first element of array"); - nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, "setting index block elements of array"); + nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, + "setting index block elements of array"); /* Super Block capacity tests */ ndblks = 0; - for(sblk = 0; sblk < 9; sblk++) { - for(dblk = 0; dblk < tparam.sblk_info[sblk].ndblks; dblk ++) { + for (sblk = 0; sblk < 9; sblk++) { + for (dblk = 0; dblk < tparam.sblk_info[sblk].ndblks; dblk++) { /* Test first element in data block */ - nelmts = (hsize_t)((hsize_t)1 + cparam.idx_blk_elmts + - tparam.sblk_info[sblk].start_idx + - (tparam.sblk_info[sblk].dblk_nelmts * dblk)); - HDsprintf(test_str, "setting first element of array's data block #%llu", (unsigned long long)ndblks); + nelmts = (hsize_t)((hsize_t)1 + cparam.idx_blk_elmts + tparam.sblk_info[sblk].start_idx + + (tparam.sblk_info[sblk].dblk_nelmts * dblk)); + HDsprintf(test_str, "setting first element of array's data block #%llu", + (unsigned long long)ndblks); nerrors += test_set_elmts(fapl, &cparam, &tparam, nelmts, test_str); /* Test all elements in data block */ - nelmts = (hsize_t)(cparam.idx_blk_elmts + - tparam.sblk_info[sblk].start_idx + - (tparam.sblk_info[sblk].dblk_nelmts * (dblk + 1))); - HDsprintf(test_str, "setting all elements of array's data block #%llu", (unsigned long long)ndblks); + nelmts = (hsize_t)(cparam.idx_blk_elmts + tparam.sblk_info[sblk].start_idx + + (tparam.sblk_info[sblk].dblk_nelmts * (dblk + 1))); + HDsprintf(test_str, "setting all elements of array's data block #%llu", + (unsigned long long)ndblks); nerrors += test_set_elmts(fapl, &cparam, &tparam, nelmts, test_str); /* Increment data block being tested */ ndblks++; } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Check skipping elements */ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)1, "skipping 1st element"); - nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, "skipping index block elements"); - nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (15 * cparam.data_blk_min_elmts) + 1), "skipping index block & data block elements"); - nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (31 * cparam.data_blk_min_elmts) + 1), "skipping 1st super block elements"); - nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (63 * cparam.data_blk_min_elmts) + 1), "skipping 2nd super block elements"); - nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (127 * cparam.data_blk_min_elmts) + 1), "skipping 3rd super block elements"); - nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (255 * cparam.data_blk_min_elmts) + 1), "skipping 4th super block elements"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, + "skipping index block elements"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, + (hsize_t)(cparam.idx_blk_elmts + (15 * cparam.data_blk_min_elmts) + 1), + "skipping index block & data block elements"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, + (hsize_t)(cparam.idx_blk_elmts + (31 * cparam.data_blk_min_elmts) + 1), + "skipping 1st super block elements"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, + (hsize_t)(cparam.idx_blk_elmts + (63 * cparam.data_blk_min_elmts) + 1), + "skipping 2nd super block elements"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, + (hsize_t)(cparam.idx_blk_elmts + (127 * cparam.data_blk_min_elmts) + 1), + "skipping 3rd super block elements"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, + (hsize_t)(cparam.idx_blk_elmts + (255 * cparam.data_blk_min_elmts) + 1), + "skipping 4th super block elements"); /* Close down testing parameters */ finish_tparam(&tparam); @@ -2593,10 +2630,11 @@ main(void) nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; - if(nerrors) + if (nerrors) goto error; HDputs("All extensible array tests passed."); @@ -2608,12 +2646,14 @@ main(void) error: HDputs("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); return 1; } /* end main() */ - diff --git a/test/efc.c b/test/efc.c index 9ae7d53..b902dcb 100644 --- a/test/efc.c +++ b/test/efc.c @@ -16,29 +16,21 @@ #include "h5test.h" -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "H5Fpkg.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Iprivate.h" -#include "H5Pprivate.h" /* Property lists */ - -const char *FILENAME[] = { - "efc0", - "efc1", - "efc2", - "efc3", - "efc4", - "efc5", - NULL -}; +#include "H5Pprivate.h" /* Property lists */ + +const char *FILENAME[] = {"efc0", "efc1", "efc2", "efc3", "efc4", "efc5", NULL}; /* Windows doesn't have PATH_MAX */ #ifndef PATH_MAX -#define PATH_MAX 4096 -#endif /* !PATH_MAX */ +#define PATH_MAX 4096 +#endif /* !PATH_MAX */ /* Global patched filename buffer */ -#define N_FILENAMES 6 +#define N_FILENAMES 6 static char *filename[N_FILENAMES]; /* Global property lists - just copies of the defaults (necessary to use @@ -46,7 +38,6 @@ static char *filename[N_FILENAMES]; hid_t fcpl_id = H5I_INVALID_HID; hid_t fapl_id = H5I_INVALID_HID; - /*------------------------------------------------------------------------- * Function: test_single * @@ -63,414 +54,403 @@ hid_t fapl_id = H5I_INVALID_HID; static unsigned test_single(void) { - H5F_t *f0 = NULL; /* Parent file containing EFC */ - H5F_t *f1 = NULL; /* Child file */ - H5F_t *f2 = NULL; /* Child file */ - H5F_t *f3 = NULL; /* Child file */ - H5F_t *f4 = NULL; /* Child file */ - H5F_t *ftmp1 = NULL; /* Temp file */ - H5F_t *ftmp2 = NULL; /* Temp file */ - H5F_t *ftmp3 = NULL; /* Temp file */ - H5F_t *ftmp4 = NULL; /* Temp file */ + H5F_t *f0 = NULL; /* Parent file containing EFC */ + H5F_t *f1 = NULL; /* Child file */ + H5F_t *f2 = NULL; /* Child file */ + H5F_t *f3 = NULL; /* Child file */ + H5F_t *f4 = NULL; /* Child file */ + H5F_t *ftmp1 = NULL; /* Temp file */ + H5F_t *ftmp2 = NULL; /* Temp file */ + H5F_t *ftmp3 = NULL; /* Temp file */ + H5F_t *ftmp4 = NULL; /* Temp file */ TESTING("single EFC"); /* Set EFC size to 3. Do this instead of H5F__efc_create() so we can pass * a file pointer to H5F__efc_open containing the EFC. */ - if(H5Pset_elink_file_cache_size(fapl_id, 3) < 0) + if (H5Pset_elink_file_cache_size(fapl_id, 3) < 0) TEST_ERROR /* Open parent file */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR /* Disable EFC for child files */ - if(H5Pset_elink_file_cache_size(fapl_id, 0) < 0) + if (H5Pset_elink_file_cache_size(fapl_id, 0) < 0) TEST_ERROR - /* Test 1: Open file 1 through EFC, close, then open normally, verify ref * count = 2, release EFC, verify ref count = 1. Verifies a file can be * held open by the EFC. */ - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 1) + if (ftmp1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp1, NULL) < 0) + if (H5F_try_close(ftmp1, NULL) < 0) FAIL_STACK_ERROR - /* Test 2: Verify that subsequent efc_open requests return the cached top * level file pointer. Open file 1 through EFC, close, open again, verify * file pointers are the same. */ - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR ftmp1 = f1; - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1 != ftmp1) + if (f1 != ftmp1) TEST_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - /* Test 3: Verify LRU functionality. Add four files to the EFC and verify * that the one added first is evicted. Then reopen files in a different * order. Open each file normally after closing through EFC the first time * to track ref counts. */ - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 2) + if (f2->shared->nrefs != 2) TEST_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 2) + if (f2->shared->nrefs != 2) TEST_ERROR - if(f3->shared->nrefs != 2) + if (f3->shared->nrefs != 2) TEST_ERROR - if(NULL == (f4 = H5F__efc_open(f0, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f0, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f4) < 0) + if (H5F_efc_close(f0, f4) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(f2->shared->nrefs != 2) + if (f2->shared->nrefs != 2) TEST_ERROR - if(f3->shared->nrefs != 2) + if (f3->shared->nrefs != 2) TEST_ERROR - if(f4->shared->nrefs != 2) + if (f4->shared->nrefs != 2) TEST_ERROR - if(NULL == (ftmp3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, ftmp3) < 0) + if (H5F_efc_close(f0, ftmp3) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(f2->shared->nrefs != 2) + if (f2->shared->nrefs != 2) TEST_ERROR - if(f3->shared->nrefs != 2) + if (f3->shared->nrefs != 2) TEST_ERROR - if(f4->shared->nrefs != 2) + if (f4->shared->nrefs != 2) TEST_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, ftmp2) < 0) + if (H5F_efc_close(f0, ftmp2) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(f2->shared->nrefs != 2) + if (f2->shared->nrefs != 2) TEST_ERROR - if(f3->shared->nrefs != 2) + if (f3->shared->nrefs != 2) TEST_ERROR - if(f4->shared->nrefs != 2) + if (f4->shared->nrefs != 2) TEST_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, ftmp1) < 0) + if (H5F_efc_close(f0, ftmp1) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 2) + if (f2->shared->nrefs != 2) TEST_ERROR - if(f3->shared->nrefs != 2) + if (f3->shared->nrefs != 2) TEST_ERROR - if(f4->shared->nrefs != 1) + if (f4->shared->nrefs != 1) TEST_ERROR - if(NULL == (ftmp4 = H5F__efc_open(f0, filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp4 = H5F__efc_open(f0, filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, ftmp4) < 0) + if (H5F_efc_close(f0, ftmp4) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 2) + if (f2->shared->nrefs != 2) TEST_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(f4->shared->nrefs != 2) + if (f4->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(f4->shared->nrefs != 1) + if (f4->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f4, NULL) < 0) + if (H5F_try_close(f4, NULL) < 0) FAIL_STACK_ERROR - /* Test 4: Verify that files kept open through the EFC are not evicted by * H5F__efc_release(). */ - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 1) + if (ftmp1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp1, NULL) < 0) + if (H5F_try_close(ftmp1, NULL) < 0) FAIL_STACK_ERROR - /* Test 5: Verify that files kept open through the EFC are not evicted by * filling up the cache. Open 4 files while holding the first open. Verify * that the second file is evicted. Close the first file, reopen the * second, and verify that the first file is evicted. */ - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp1->shared != f1->shared) + if (ftmp1->shared != f1->shared) TEST_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(NULL == (f4 = H5F__efc_open(f0, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f0, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f4) < 0) + if (H5F_efc_close(f0, f4) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 1) + if (ftmp1->shared->nrefs != 1) TEST_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 1) + if (ftmp1->shared->nrefs != 1) TEST_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp1, NULL) < 0) + if (H5F_try_close(ftmp1, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp2, NULL) < 0) + if (H5F_try_close(ftmp2, NULL) < 0) FAIL_STACK_ERROR - /* Test 6: Verify that having a full EFC filled only with open files * prevents further files from being cached. Open and hold open 3 files * through the EFC, then open the fourth and verify that it was not added to * the EFC. */ - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp1->shared != f1->shared) + if (ftmp1->shared != f1->shared) TEST_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp2->shared != f2->shared) + if (ftmp2->shared != f2->shared) TEST_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp3->shared != f3->shared) + if (ftmp3->shared != f3->shared) TEST_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(NULL == (f4 = H5F__efc_open(f0, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f0, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f4) < 0) + if (H5F_efc_close(f0, f4) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp4->shared->nrefs != 1) + if (ftmp4->shared->nrefs != 1) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 1) + if (ftmp1->shared->nrefs != 1) TEST_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(ftmp3->shared->nrefs != 1) + if (ftmp3->shared->nrefs != 1) TEST_ERROR - if(ftmp4->shared->nrefs != 1) + if (ftmp4->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp1, NULL) < 0) + if (H5F_try_close(ftmp1, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp2, NULL) < 0) + if (H5F_try_close(ftmp2, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp3, NULL) < 0) + if (H5F_try_close(ftmp3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp4, NULL) < 0) + if (H5F_try_close(ftmp4, NULL) < 0) FAIL_STACK_ERROR - /* Test 7: Test multiple file opens. Open a file twice, close it once, then * verify that it is not evicted by H5F__efc_release(). */ - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 1) + if (ftmp1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp1, NULL) < 0) + if (H5F_try_close(ftmp1, NULL) < 0) FAIL_STACK_ERROR - /* Close parent file */ - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR PASSED(); @@ -481,7 +461,6 @@ error: return 1; } /* test_single */ - /*------------------------------------------------------------------------- * Function: test_graph_nocycle * @@ -499,15 +478,15 @@ error: static unsigned test_graph_nocycle(void) { - H5F_t *f0 = NULL; /* Parent file containing EFC */ - H5F_t *f1 = NULL; /* Child file */ - H5F_t *f2 = NULL; /* Child file */ - H5F_t *f3 = NULL; /* Child file */ - H5F_t *f4 = NULL; /* Child file */ - H5F_t *ftmp1 = NULL; /* Temp file */ - H5F_t *ftmp2 = NULL; /* Temp file */ - H5F_t *ftmp3 = NULL; /* Temp file */ - H5F_t *ftmp4 = NULL; /* Temp file */ + H5F_t *f0 = NULL; /* Parent file containing EFC */ + H5F_t *f1 = NULL; /* Child file */ + H5F_t *f2 = NULL; /* Child file */ + H5F_t *f3 = NULL; /* Child file */ + H5F_t *f4 = NULL; /* Child file */ + H5F_t *ftmp1 = NULL; /* Temp file */ + H5F_t *ftmp2 = NULL; /* Temp file */ + H5F_t *ftmp3 = NULL; /* Temp file */ + H5F_t *ftmp4 = NULL; /* Temp file */ TESTING("graph of EFCs without cycles"); @@ -515,310 +494,288 @@ test_graph_nocycle(void) * a file pointer to H5F__efc_open containing the EFC. Set to a high number * because we don't test the EFC becoming too large in this test. */ - if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0) + if (H5Pset_elink_file_cache_size(fapl_id, 8) < 0) TEST_ERROR - /* Test 1: Simple 3 file chain. Open file 1 through file 0, then open file * 2 through file 1. Release file 0's EFC and verify that file 2 gets its * ref count reduced (implying file 1 was closed). Do the same with the * opening order reversed. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp2, NULL) < 0) + if (H5F_try_close(ftmp2, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(ftmp1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F__efc_open(ftmp1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, + fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_try_close(ftmp1, NULL) < 0) + if (H5F_try_close(ftmp1, NULL) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp2, NULL) < 0) + if (H5F_try_close(ftmp2, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 2: 5 file chain. The parent file has 2 child files, each of which * has their own child file. Verifies that releasing the parent's EFC * closes all 4 children. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f3, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f3, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, f4) < 0) + if (H5F_efc_close(f3, f4) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp4->shared->nrefs != 2) + if (ftmp4->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(ftmp4->shared->nrefs != 1) + if (ftmp4->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp2, NULL) < 0) + if (H5F_try_close(ftmp2, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp4, NULL) < 0) + if (H5F_try_close(ftmp4, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 3: Simple "inverted" tree. Two parent files share a child file, * which has its own child file. Verify that the child's child is not * closed until both parents' EFCs are released. First release through one * parent, then reopen through that parent and release the other, then * re-release the first parent. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp2) < 0) + if (H5F_efc_close(f1, ftmp2) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(f1->shared->efc) < 0) + if (H5F__efc_release(f1->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 1) + if (ftmp3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp3, NULL) < 0) + if (H5F_try_close(ftmp3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 4: Simple "diamond" tree. The parent file has two children, which * shared the same child. Verify that releasing the parent file closes all * files. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 3) + if (ftmp3->shared->nrefs != 3) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 1) + if (ftmp3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp3, NULL) < 0) + if (H5F_try_close(ftmp3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 5: Dense 5 file graph. f0 caches f1, f2, f3 and f4. f1 and f2 * each cache f3 and f4. f3 caches f4. Verify that releasing f0 closes all * files. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f0, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f0, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f4) < 0) + if (H5F_efc_close(f0, f4) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f1, filename[4], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f4 = H5F__efc_open(f1, filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f4) < 0) + if (H5F_efc_close(f1, f4) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f2, filename[4], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f4 = H5F__efc_open(f2, filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f4) < 0) + if (H5F_efc_close(f2, f4) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f3, filename[4], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f4 = H5F__efc_open(f3, filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, f4) < 0) + if (H5F_efc_close(f3, f4) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp4->shared->nrefs != 5) + if (ftmp4->shared->nrefs != 5) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp4->shared->nrefs != 1) + if (ftmp4->shared->nrefs != 1) TEST_ERROR - if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 1) + if (ftmp1->shared->nrefs != 1) TEST_ERROR - if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 1) + if (ftmp3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(ftmp1, NULL) < 0) + if (H5F_try_close(ftmp1, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp2, NULL) < 0) + if (H5F_try_close(ftmp2, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp3, NULL) < 0) + if (H5F_try_close(ftmp3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp4, NULL) < 0) + if (H5F_try_close(ftmp4, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - PASSED(); return 0; @@ -827,7 +784,6 @@ error: return 1; } /* test_graph_nocycle */ - /*------------------------------------------------------------------------- * Function: test_graph_cycle * @@ -845,16 +801,16 @@ error: static unsigned test_graph_cycle(void) { - H5F_t *f0 = NULL; /* File */ - H5F_t *f1 = NULL; /* File */ - H5F_t *f2 = NULL; /* File */ - H5F_t *f3 = NULL; /* File */ - H5F_t *f4 = NULL; /* File */ - H5F_t *f5 = NULL; /* File */ - H5F_t *ftmp0 = NULL; /* Temp file */ - H5F_t *ftmp1 = NULL; /* Temp file */ - H5F_t *ftmp2 = NULL; /* Temp file */ - H5F_t *ftmp3 = NULL; /* Temp file */ + H5F_t *f0 = NULL; /* File */ + H5F_t *f1 = NULL; /* File */ + H5F_t *f2 = NULL; /* File */ + H5F_t *f3 = NULL; /* File */ + H5F_t *f4 = NULL; /* File */ + H5F_t *f5 = NULL; /* File */ + H5F_t *ftmp0 = NULL; /* Temp file */ + H5F_t *ftmp1 = NULL; /* Temp file */ + H5F_t *ftmp2 = NULL; /* Temp file */ + H5F_t *ftmp3 = NULL; /* Temp file */ TESTING("graph of EFCs with cycles"); @@ -862,2022 +818,1816 @@ test_graph_cycle(void) * a file pointer to H5F__efc_open containing the EFC. Set to a high number * because we don't test the EFC becoming too large in this test. */ - if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0) + if (H5Pset_elink_file_cache_size(fapl_id, 8) < 0) TEST_ERROR - /* Test 1: File caches itself. Verify that closing the file causes it to be * actually closed, and there is no other unexpected behavior. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, ftmp0) < 0) + if (H5F_efc_close(f0, ftmp0) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, ftmp0) < 0) + if (H5F_efc_close(f0, ftmp0) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 2: Indirectly referenced file caches itself. Same as above except * the file is part of another file's EFC. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp1) < 0) + if (H5F_efc_close(f1, ftmp1) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp1) < 0) + if (H5F_efc_close(f1, ftmp1) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - /* Test 3: Simple 2 file cycle */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 4: Simple 2 file cycle (indirectly referenced) */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp1) < 0) + if (H5F_efc_close(f2, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - /* Test 5: Parallel double cycle */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp0) < 0) + if (H5F_efc_close(f2, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 3) + if (f0->shared->nrefs != 3) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 6: Parallel double cycle with release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp0) < 0) + if (H5F_efc_close(f2, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 3) + if (f0->shared->nrefs != 3) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 7: Chained parallel double cycle */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp1) < 0) + if (H5F_efc_close(f2, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp1) < 0) + if (H5F_efc_close(f3, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 8: Chained parallel double cycle with release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp1) < 0) + if (H5F_efc_close(f2, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp1) < 0) + if (H5F_efc_close(f3, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 9: Simple 2 file cycle, extra ID on root */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp1) < 0) + if (H5F_efc_close(f1, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared != ftmp0->shared) + if (f0->shared != ftmp0->shared) TEST_ERROR - if(f0->shared->nrefs != 3) + if (f0->shared->nrefs != 3) TEST_ERROR - if(H5F_try_close(ftmp0, NULL) < 0) + if (H5F_try_close(ftmp0, NULL) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 10: Simple 2 file cycle, extra ID on second file */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(ftmp1->shared->nrefs != 2) + if (ftmp1->shared->nrefs != 2) TEST_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp1, NULL) < 0) + if (H5F_try_close(ftmp1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - /* Test 11: Parallel double cycle, extra ID on a child file */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp0) < 0) + if (H5F_efc_close(f2, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 3) + if (f0->shared->nrefs != 3) TEST_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 3) + if (f0->shared->nrefs != 3) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp2, NULL) < 0) + if (H5F_try_close(ftmp2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - /* Test 12: Parallel double cycle, extra ID on a child file, with release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp0) < 0) + if (H5F_efc_close(f2, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 3) + if (f0->shared->nrefs != 3) TEST_ERROR - if(ftmp2->shared->nrefs != 2) + if (ftmp2->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(H5F__efc_release(ftmp2->shared->efc) < 0) + if (H5F__efc_release(ftmp2->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(ftmp2->shared->nrefs != 1) + if (ftmp2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp2, NULL) < 0) + if (H5F_try_close(ftmp2, NULL) < 0) FAIL_STACK_ERROR - /* Test 13: Chained parallel double cycle, extra ID on a child file */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp1) < 0) + if (H5F_efc_close(f2, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp1) < 0) + if (H5F_efc_close(f3, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp3, NULL) < 0) + if (H5F_try_close(ftmp3, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - /* Test 14: Chained parallel double cycle, extra ID on a child file, with * release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp1) < 0) + if (H5F_efc_close(f2, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp1) < 0) + if (H5F_efc_close(f3, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(ftmp3->shared->efc) < 0) + if (H5F__efc_release(ftmp3->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(ftmp3->shared->nrefs != 1) + if (ftmp3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp3, NULL) < 0) + if (H5F_try_close(ftmp3, NULL) < 0) FAIL_STACK_ERROR - /* Test 15: One local and one remote cycle */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp2) < 0) + if (H5F_efc_close(f3, ftmp2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - /* Test 16: One local and one remote cycle, with release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp2) < 0) + if (H5F_efc_close(f3, ftmp2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - /* Test 17: One local and one remote cycle, remote cycle held open */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp2) < 0) + if (H5F_efc_close(f3, ftmp2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(ftmp3, NULL) < 0) + if (H5F_try_close(ftmp3, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - /* Test 18: One local and one remote cycle, remote cycle held open, with * release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp2) < 0) + if (H5F_efc_close(f3, ftmp2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(ftmp3->shared->nrefs != 2) + if (ftmp3->shared->nrefs != 2) TEST_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 2) + if (f2->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(ftmp3->shared->efc) < 0) + if (H5F__efc_release(ftmp3->shared->efc) < 0) FAIL_STACK_ERROR - if(ftmp3->shared->nrefs != 1) + if (ftmp3->shared->nrefs != 1) TEST_ERROR - if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(ftmp3, NULL) < 0) + if (H5F_try_close(ftmp3, NULL) < 0) FAIL_STACK_ERROR - /* Test 19: "Diamond" shape with links moving from bottom (root) to top. * Also cycle between bottom (root) and top and cycles on the sides. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp0) < 0) + if (H5F_efc_close(f3, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f1, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f1, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f4, ftmp1) < 0) + if (H5F_efc_close(f4, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f4) < 0) + if (H5F_efc_close(f1, f4) < 0) FAIL_STACK_ERROR - if(NULL == (f5 = H5F__efc_open(f2, filename[5], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f5 = H5F__efc_open(f2, filename[5], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f5, ftmp2) < 0) + if (H5F_efc_close(f5, ftmp2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f5) < 0) + if (H5F_efc_close(f2, f5) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F_open(filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f4->shared->nrefs != 1) + if (f4->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f4, NULL) < 0) + if (H5F_try_close(f4, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f5 = H5F_open(filename[5], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f5->shared->nrefs != 1) + if (f5->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f5, NULL) < 0) + if (H5F_try_close(f5, NULL) < 0) FAIL_STACK_ERROR - /* Test 20: "Diamond" shape with links moving from bottom (root) to top. * Also cycle between bottom (root) and top, cycles on the sides, and * release the files instead of closing. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp0) < 0) + if (H5F_efc_close(f3, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f1, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f1, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f4, ftmp1) < 0) + if (H5F_efc_close(f4, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f4) < 0) + if (H5F_efc_close(f1, f4) < 0) FAIL_STACK_ERROR - if(NULL == (f5 = H5F__efc_open(f2, filename[5], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f5 = H5F__efc_open(f2, filename[5], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f5, ftmp2) < 0) + if (H5F_efc_close(f5, ftmp2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f5) < 0) + if (H5F_efc_close(f2, f5) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F_open(filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f4->shared->nrefs != 1) + if (f4->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f4, NULL) < 0) + if (H5F_try_close(f4, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f5 = H5F_open(filename[5], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f5->shared->nrefs != 1) + if (f5->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f5, NULL) < 0) + if (H5F_try_close(f5, NULL) < 0) FAIL_STACK_ERROR - /* Test 21: "Diamond" shape with links moving from bottom (root) to top. * Also cycle between bottom (root) and top, cycles on sides held open. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp0) < 0) + if (H5F_efc_close(f3, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f1, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f1, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f4, ftmp1) < 0) + if (H5F_efc_close(f4, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f4) < 0) + if (H5F_efc_close(f1, f4) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f5 = H5F__efc_open(f2, filename[5], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f5 = H5F__efc_open(f2, filename[5], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f5, ftmp2) < 0) + if (H5F_efc_close(f5, ftmp2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f5) < 0) + if (H5F_efc_close(f2, f5) < 0) FAIL_STACK_ERROR - if(NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f4->shared->nrefs != 2) + if (f4->shared->nrefs != 2) TEST_ERROR - if(f5->shared->nrefs != 2) + if (f5->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(f4->shared->nrefs != 2) + if (f4->shared->nrefs != 2) TEST_ERROR - if(f5->shared->nrefs != 2) + if (f5->shared->nrefs != 2) TEST_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f4, NULL) < 0) + if (H5F_try_close(f4, NULL) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f5->shared->nrefs != 2) + if (f5->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(f5->shared->nrefs != 2) + if (f5->shared->nrefs != 2) TEST_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f5, NULL) < 0) + if (H5F_try_close(f5, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F_open(filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f4->shared->nrefs != 1) + if (f4->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f4, NULL) < 0) + if (H5F_try_close(f4, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f5 = H5F_open(filename[5], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f5->shared->nrefs != 1) + if (f5->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f5, NULL) < 0) + if (H5F_try_close(f5, NULL) < 0) FAIL_STACK_ERROR - /* Test 22: "Diamond" shape with links moving from bottom (root) to top. * Also cycle between bottom (root) and top, cycles on sides held open. * Also release the files instead of closing. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f3) < 0) + if (H5F_efc_close(f2, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp0) < 0) + if (H5F_efc_close(f3, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F__efc_open(f1, filename[4], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f4 = H5F__efc_open(f1, filename[4], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f4, ftmp1) < 0) + if (H5F_efc_close(f4, ftmp1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f4) < 0) + if (H5F_efc_close(f1, f4) < 0) FAIL_STACK_ERROR - if(NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f5 = H5F__efc_open(f2, filename[5], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f5 = H5F__efc_open(f2, filename[5], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f5, ftmp2) < 0) + if (H5F_efc_close(f5, ftmp2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f5) < 0) + if (H5F_efc_close(f2, f5) < 0) FAIL_STACK_ERROR - if(NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f4->shared->nrefs != 2) + if (f4->shared->nrefs != 2) TEST_ERROR - if(f5->shared->nrefs != 2) + if (f5->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f4->shared->nrefs != 2) + if (f4->shared->nrefs != 2) TEST_ERROR - if(f5->shared->nrefs != 2) + if (f5->shared->nrefs != 2) TEST_ERROR - if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 3) + if (f3->shared->nrefs != 3) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(f4->shared->efc) < 0) + if (H5F__efc_release(f4->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f4->shared->nrefs != 1) + if (f4->shared->nrefs != 1) TEST_ERROR - if(f5->shared->nrefs != 2) + if (f5->shared->nrefs != 2) TEST_ERROR - if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 2) + if (f3->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(f5->shared->efc) < 0) + if (H5F__efc_release(f5->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(f4->shared->nrefs != 1) + if (f4->shared->nrefs != 1) TEST_ERROR - if(f5->shared->nrefs != 1) + if (f5->shared->nrefs != 1) TEST_ERROR - if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f4, NULL) < 0) + if (H5F_try_close(f4, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f5, NULL) < 0) + if (H5F_try_close(f5, NULL) < 0) FAIL_STACK_ERROR - /* Test 23: Dense "ball" of files. 4 files each cache all files (including * itself). */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, ftmp0) < 0) + if (H5F_efc_close(f0, ftmp0) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp1) < 0) + if (H5F_efc_close(f1, ftmp1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp2) < 0) + if (H5F_efc_close(f1, ftmp2) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp3) < 0) + if (H5F_efc_close(f1, ftmp3) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp0) < 0) + if (H5F_efc_close(f2, ftmp0) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp1) < 0) + if (H5F_efc_close(f2, ftmp1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f2, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f2, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp2) < 0) + if (H5F_efc_close(f2, ftmp2) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp3) < 0) + if (H5F_efc_close(f2, ftmp3) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp0) < 0) + if (H5F_efc_close(f3, ftmp0) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp1) < 0) + if (H5F_efc_close(f3, ftmp1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp2) < 0) + if (H5F_efc_close(f3, ftmp2) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F__efc_open(f3, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp3 = H5F__efc_open(f3, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp3) < 0) + if (H5F_efc_close(f3, ftmp3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - /* Test 24: Dense "ball" of files. 4 files each cache all files (including * itself). Release the files instead of closing. */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f0, ftmp0) < 0) + if (H5F_efc_close(f0, ftmp0) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f0, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f0, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp1) < 0) + if (H5F_efc_close(f1, ftmp1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp2) < 0) + if (H5F_efc_close(f1, ftmp2) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp3) < 0) + if (H5F_efc_close(f1, ftmp3) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp0) < 0) + if (H5F_efc_close(f2, ftmp0) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp1) < 0) + if (H5F_efc_close(f2, ftmp1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f2, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f2, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp2) < 0) + if (H5F_efc_close(f2, ftmp2) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp3 = H5F__efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f2, ftmp3) < 0) + if (H5F_efc_close(f2, ftmp3) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp0) < 0) + if (H5F_efc_close(f3, ftmp0) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp1 = H5F__efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp1) < 0) + if (H5F_efc_close(f3, ftmp1) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp2 = H5F__efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp2) < 0) + if (H5F_efc_close(f3, ftmp2) < 0) FAIL_STACK_ERROR - if(NULL == (ftmp3 = H5F__efc_open(f3, filename[3], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp3 = H5F__efc_open(f3, filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f3, ftmp3) < 0) + if (H5F_efc_close(f3, ftmp3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f3) < 0) + if (H5F_efc_close(f0, f3) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - /* Test 25: File held open by EFC client interrupts cycle, with release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 26: File held open by EFC does not interrupt cycle, with release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F__efc_open(f0, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f0, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_efc_close(f0, f2) < 0) + if (H5F_efc_close(f0, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - /* Test 27: File held open by EFC client through non-parent file does not * interrupt cycle, but parent file does (no valid way around it) */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 2) + if (f3->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f1) < 0) + if (H5F_efc_close(f2, f1) < 0) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 3) + if (f1->shared->nrefs != 3) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 2) + if (f3->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - /* Test 28: File held open by EFC client through non-parent file does not * interrupt cycle, but parent file does (no valid way around it), with * release */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (f1 = H5F__efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f3 = H5F__efc_open(f1, filename[3], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f3 = H5F__efc_open(f1, filename[3], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f1->shared->nrefs != 2) + if (f1->shared->nrefs != 2) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F__efc_release(f0->shared->efc) < 0) + if (H5F__efc_release(f0->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F__efc_release(f2->shared->efc) < 0) + if (H5F__efc_release(f2->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_efc_close(f1, f3) < 0) + if (H5F_efc_close(f1, f3) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f2, f1) < 0) + if (H5F_efc_close(f2, f1) < 0) FAIL_STACK_ERROR - if(H5F__efc_release(f2->shared->efc) < 0) + if (H5F__efc_release(f2->shared->efc) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f3->shared->nrefs != 1) + if (f3->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f3, NULL) < 0) + if (H5F_try_close(f3, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - /* Test 29: File without EFC interrupts cycle */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5Pset_elink_file_cache_size(fapl_id, 0) < 0) + if (H5Pset_elink_file_cache_size(fapl_id, 0) < 0) TEST_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0) + if (H5Pset_elink_file_cache_size(fapl_id, 8) < 0) TEST_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - /* Test 30: File without EFC does not interrupt cycle */ - if(NULL == (f0 = H5F_open(filename[0], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (f1 = H5F__efc_open(f0, filename[1], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, - fapl_id))) + if (NULL == (ftmp0 = H5F__efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5F_efc_close(f1, ftmp0) < 0) + if (H5F_efc_close(f1, ftmp0) < 0) FAIL_STACK_ERROR - if(H5F_efc_close(f0, f1) < 0) + if (H5F_efc_close(f0, f1) < 0) FAIL_STACK_ERROR - if(H5Pset_elink_file_cache_size(fapl_id, 0) < 0) + if (H5Pset_elink_file_cache_size(fapl_id, 0) < 0) TEST_ERROR - if(NULL == (f2 = H5F__efc_open(f1, filename[2], - H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) + if (NULL == + (f2 = H5F__efc_open(f1, filename[2], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0) + if (H5Pset_elink_file_cache_size(fapl_id, 8) < 0) TEST_ERROR - if(H5F_efc_close(f1, f2) < 0) + if (H5F_efc_close(f1, f2) < 0) FAIL_STACK_ERROR - if(f0->shared->nrefs != 2) + if (f0->shared->nrefs != 2) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f0->shared->nrefs != 1) + if (f0->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f0, NULL) < 0) + if (H5F_try_close(f0, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f1->shared->nrefs != 1) + if (f1->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f1, NULL) < 0) + if (H5F_try_close(f1, NULL) < 0) FAIL_STACK_ERROR - if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) + if (NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id))) FAIL_STACK_ERROR - if(f2->shared->nrefs != 1) + if (f2->shared->nrefs != 1) TEST_ERROR - if(H5F_try_close(f2, NULL) < 0) + if (H5F_try_close(f2, NULL) < 0) FAIL_STACK_ERROR - PASSED(); return 0; @@ -2886,7 +2636,6 @@ error: return 1; } /* test_graph_cycle */ - /*------------------------------------------------------------------------- * Function: main * @@ -2902,11 +2651,11 @@ error: int main(void) { - unsigned nerrors = 0; /* track errors */ - H5P_genplist_t *plist; /* Property list pointer for FAPL */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - int i; /* iterator */ + unsigned nerrors = 0; /* track errors */ + H5P_genplist_t * plist; /* Property list pointer for FAPL */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + int i; /* iterator */ /* Test Setup */ HDputs("Testing the external file cache"); @@ -2916,7 +2665,7 @@ main(void) fapl_id = h5_fileaccess(); /* Allocate memory for filenames */ - for(i = 0; i < N_FILENAMES; i++) { + for (i = 0; i < N_FILENAMES; i++) { filename[i] = (char *)HDcalloc(PATH_MAX, sizeof(char)); } @@ -2929,7 +2678,8 @@ main(void) h5_fixname(FILENAME[5], fapl_id, filename[5], PATH_MAX); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Get the VOL info from the fapl */ @@ -2947,25 +2697,25 @@ main(void) nerrors += test_graph_cycle(); /* Close property lists */ - if(H5Pclose(fcpl_id) < 0) + if (H5Pclose(fcpl_id) < 0) TEST_ERROR /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl_id) < 0 ? 1 : 0); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR api_ctx_pushed = FALSE; - if(nerrors) + if (nerrors) goto error; HDputs("All external file cache tests passed."); h5_clean_files(FILENAME, fapl_id); - for(i = 0; i < N_FILENAMES; i++) { + for (i = 0; i < N_FILENAMES; i++) { HDfree(filename[i]); } @@ -2974,17 +2724,18 @@ main(void) error: HDputs("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_id); - } H5E_END_TRY + } + H5E_END_TRY - if(api_ctx_pushed) + if (api_ctx_pushed) H5CX_pop(); - for(i = 0; i < N_FILENAMES; i++) { + for (i = 0; i < N_FILENAMES; i++) { HDfree(filename[i]); } return EXIT_FAILURE; } /* end main() */ - diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 54f3fb0..57f0a36 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -19,676 +19,665 @@ #include "H5ACprivate.h" #include "H5Pprivate.h" -#define SRC_FNAME "source_file.h5" -#define SRC_DSET "src_dset" +#define SRC_FNAME "source_file.h5" +#define SRC_DSET "src_dset" static int test_encode_decode(hid_t orig_pl, H5F_libver_t low, H5F_libver_t high, hbool_t support_virtual) { - hid_t pl = (-1); /* Decoded property list */ - hid_t fapl = -1; /* File access property list */ - void *temp_buf = NULL; /* Pointer to encoding buffer */ - size_t temp_size = 0; /* Size of encoding buffer */ - herr_t ret; /* Return value */ + hid_t pl = (-1); /* Decoded property list */ + hid_t fapl = -1; /* File access property list */ + void * temp_buf = NULL; /* Pointer to encoding buffer */ + size_t temp_size = 0; /* Size of encoding buffer */ + herr_t ret; /* Return value */ /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set library version bounds */ - if(H5Pset_libver_bounds(fapl, low, high) < 0) + if (H5Pset_libver_bounds(fapl, low, high) < 0) TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pencode2(orig_pl, NULL, &temp_size, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(support_virtual && high < H5F_LIBVER_V110) + if (support_virtual && high < H5F_LIBVER_V110) VERIFY(ret, FAIL, "H5Pencode2"); else { VERIFY(ret, SUCCEED, "H5Pencode2"); /* Allocate the buffer for encoding */ - if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + if (NULL == (temp_buf = (void *)HDmalloc(temp_size))) TEST_ERROR /* Encode the property list to the buffer */ - if(H5Pencode2(orig_pl, temp_buf, &temp_size, fapl) < 0) + if (H5Pencode2(orig_pl, temp_buf, &temp_size, fapl) < 0) TEST_ERROR /* Decode the buffer */ - if((pl = H5Pdecode(temp_buf)) < 0) + if ((pl = H5Pdecode(temp_buf)) < 0) STACK_ERROR /* Check if the original and the decoded property lists are equal */ - if(!H5Pequal(orig_pl, pl)) + if (!H5Pequal(orig_pl, pl)) PUTS_ERROR("encoding-decoding cycle failed\n") /* Close the decoded property list */ - if((H5Pclose(pl)) < 0) + if ((H5Pclose(pl)) < 0) TEST_ERROR /* Free the buffer */ - if(temp_buf) + if (temp_buf) HDfree(temp_buf); #ifndef H5_NO_DEPRECATED_SYMBOLS /* Test H5Pencode1() */ /* first call to encode returns only the size of the buffer needed */ - if(H5Pencode1(orig_pl, NULL, &temp_size) < 0) + if (H5Pencode1(orig_pl, NULL, &temp_size) < 0) STACK_ERROR - if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + if (NULL == (temp_buf = (void *)HDmalloc(temp_size))) TEST_ERROR - if(H5Pencode1(orig_pl, temp_buf, &temp_size) < 0) + if (H5Pencode1(orig_pl, temp_buf, &temp_size) < 0) STACK_ERROR - if((pl = H5Pdecode(temp_buf)) < 0) + if ((pl = H5Pdecode(temp_buf)) < 0) STACK_ERROR - if(!H5Pequal(orig_pl, pl)) + if (!H5Pequal(orig_pl, pl)) PUTS_ERROR("encoding-decoding cycle failed\n") - if((H5Pclose(pl)) < 0) + if ((H5Pclose(pl)) < 0) STACK_ERROR - if(temp_buf) + if (temp_buf) HDfree(temp_buf); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - } - if((H5Pclose(fapl)) < 0) + if ((H5Pclose(fapl)) < 0) TEST_ERROR /* Success */ - return(0); + return (0); error: - if(temp_buf) + if (temp_buf) HDfree(temp_buf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pl); H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - return(-1); + return (-1); } /* end test_encode_decode() */ int main(void) { - hid_t dcpl; /* dataset create prop. list */ - hid_t dapl; /* dataset access prop. list */ - hid_t dxpl; /* dataset xfer prop. list */ - hid_t gcpl; /* group create prop. list */ - hid_t ocpypl; /* object copy prop. list */ - hid_t ocpl; /* object create prop. list */ - hid_t lcpl; /* link create prop. list */ - hid_t lapl; /* link access prop. list */ - hid_t fapl; /* file access prop. list */ - hid_t fcpl; /* file create prop. list */ - hid_t strcpl; /* string create prop. list */ - hid_t acpl; /* attribute create prop. list */ - hid_t srcspace = -1; /* Source dataspaces */ - hid_t vspace = -1; /* Virtual dset dataspaces */ - hsize_t dims[1] = {3}; /* Data space current size */ - hsize_t chunk_size[2] = {16384, 4}; /* chunk size */ - double fill = 2.7f; /* Fill value */ - hsize_t max_size[1]; /* data space maximum size */ - size_t nslots = 521 * 2; - size_t nbytes = 1048576 * 10; - double w0 = 0.5f; - unsigned max_compact; - unsigned min_dense; - const char* c_to_f = "x+32"; + hid_t dcpl; /* dataset create prop. list */ + hid_t dapl; /* dataset access prop. list */ + hid_t dxpl; /* dataset xfer prop. list */ + hid_t gcpl; /* group create prop. list */ + hid_t ocpypl; /* object copy prop. list */ + hid_t ocpl; /* object create prop. list */ + hid_t lcpl; /* link create prop. list */ + hid_t lapl; /* link access prop. list */ + hid_t fapl; /* file access prop. list */ + hid_t fcpl; /* file create prop. list */ + hid_t strcpl; /* string create prop. list */ + hid_t acpl; /* attribute create prop. list */ + hid_t srcspace = -1; /* Source dataspaces */ + hid_t vspace = -1; /* Virtual dset dataspaces */ + hsize_t dims[1] = {3}; /* Data space current size */ + hsize_t chunk_size[2] = {16384, 4}; /* chunk size */ + double fill = 2.7f; /* Fill value */ + hsize_t max_size[1]; /* data space maximum size */ + size_t nslots = 521 * 2; + size_t nbytes = 1048576 * 10; + double w0 = 0.5f; + unsigned max_compact; + unsigned min_dense; + const char * c_to_f = "x+32"; H5F_libver_t low, high; /* Low and high bounds */ - H5AC_cache_config_t my_cache_config = { - H5AC__CURR_CACHE_CONFIG_VERSION, - TRUE, - FALSE, - FALSE, - "temp", - TRUE, - FALSE, - ( 2 * 2048 * 1024), - 0.3f, - (64 * 1024 * 1024), - (4 * 1024 * 1024), - 60000, - H5C_incr__threshold, - 0.8f, - 3.0f, - TRUE, - (8 * 1024 * 1024), - H5C_flash_incr__add_space, - 2.0f, - 0.25f, - H5C_decr__age_out_with_threshold, - 0.997f, - 0.8f, - TRUE, - (3 * 1024 * 1024), - 3, - FALSE, - 0.2f, - (256 * 2048), - H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; - - H5AC_cache_image_config_t my_cache_image_config = { - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, - FALSE, - -1 }; + H5AC_cache_config_t my_cache_config = {H5AC__CURR_CACHE_CONFIG_VERSION, + TRUE, + FALSE, + FALSE, + "temp", + TRUE, + FALSE, + (2 * 2048 * 1024), + 0.3f, + (64 * 1024 * 1024), + (4 * 1024 * 1024), + 60000, + H5C_incr__threshold, + 0.8f, + 3.0f, + TRUE, + (8 * 1024 * 1024), + H5C_flash_incr__add_space, + 2.0f, + 0.25f, + H5C_decr__age_out_with_threshold, + 0.997f, + 0.8f, + TRUE, + (3 * 1024 * 1024), + 3, + FALSE, + 0.2f, + (256 * 2048), + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + + H5AC_cache_image_config_t my_cache_image_config = {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, + -1}; /* Loop through all the combinations of low/high version bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - char msg[80]; /* Message for file version bounds */ - const char *low_string; /* The low bound string */ + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + const char *low_string; /* The low bound string */ const char *high_string; /* The high bound string */ /* Invalid combinations, just continue */ - if(high == H5F_LIBVER_EARLIEST || high < low) + if (high == H5F_LIBVER_EARLIEST || high < low) continue; /* Display testing info */ - low_string = h5_get_version_string(low); + low_string = h5_get_version_string(low); high_string = h5_get_version_string(high); - HDsprintf(msg, "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, high_string); + HDsprintf(msg, "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, + high_string); HDputs(msg); - - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("Encode/Decode DCPLs\n"); /******* ENCODE/DECODE DCPLS *****/ TESTING("Default DCPL Encoding/Decoding"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(dcpl, low, high, FALSE) < 0) + if (test_encode_decode(dcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n") PASSED(); TESTING("DCPL Encoding/Decoding"); - if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) + if ((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) FAIL_STACK_ERROR - if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0) + if ((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0) FAIL_STACK_ERROR - if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0) + if ((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0) FAIL_STACK_ERROR - if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0) + if ((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0) FAIL_STACK_ERROR max_size[0] = 100; - if((H5Pset_external(dcpl, "ext1.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + if ((H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext2.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + if ((H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext3.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + if ((H5Pset_external(dcpl, "ext3.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext4.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + if ((H5Pset_external(dcpl, "ext4.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(dcpl, low, high, FALSE) < 0) + if (test_encode_decode(dcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(dcpl)) < 0) + if ((H5Pclose(dcpl)) < 0) FAIL_STACK_ERROR - PASSED(); + PASSED(); /******* ENCODE/DECODE DCPLS *****/ TESTING("DCPL Encoding/Decoding for virtual layout"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* Set virtual layout */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create source dataspace */ - if((srcspace = H5Screate_simple(1, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace = H5Screate_simple(1, dims, NULL)) < 0) + if ((vspace = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace, SRC_FNAME, SRC_DSET, srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace, SRC_FNAME, SRC_DSET, srcspace) < 0) TEST_ERROR - if(test_encode_decode(dcpl, low, high, TRUE) < 0) + if (test_encode_decode(dcpl, low, high, TRUE) < 0) FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(dcpl)) < 0) + if ((H5Pclose(dcpl)) < 0) FAIL_STACK_ERROR /******* ENCODE/DECODE DAPLS *****/ TESTING("Default DAPL Encoding/Decoding"); - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(dapl, low, high, FALSE) < 0) + if (test_encode_decode(dapl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n") PASSED(); TESTING("DAPL Encoding/Decoding"); - if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) + if ((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(dapl, low, high, FALSE) < 0) + if (test_encode_decode(dapl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(dapl)) < 0) + if ((H5Pclose(dapl)) < 0) FAIL_STACK_ERROR - PASSED(); + PASSED(); /******* ENCODE/DECODE OCPLS *****/ TESTING("Default OCPL Encoding/Decoding"); - if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) + if ((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(ocpl, low, high, FALSE) < 0) + if (test_encode_decode(ocpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n") PASSED(); TESTING("OCPL Encoding/Decoding"); - if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + if ((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) FAIL_STACK_ERROR - if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0) + if ((H5Pset_attr_phase_change(ocpl, 110, 105)) < 0) FAIL_STACK_ERROR - if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) + if ((H5Pset_filter(ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(ocpl, low, high, FALSE) < 0) + if (test_encode_decode(ocpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(ocpl)) < 0) + if ((H5Pclose(ocpl)) < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE DXPLS *****/ TESTING("Default DXPL Encoding/Decoding"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(dxpl, low, high, FALSE) < 0) + if (test_encode_decode(dxpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n") PASSED(); TESTING("DXPL Encoding/Decoding"); - if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) + if ((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) FAIL_STACK_ERROR - if((H5Pset_hyper_vector_size(dxpl, 5)) < 0) + if ((H5Pset_hyper_vector_size(dxpl, 5)) < 0) FAIL_STACK_ERROR #ifdef H5_HAVE_PARALLEL - if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0) + if ((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0) FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0) + if ((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0) FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) + if ((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0) + if ((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0) FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0) + if ((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0) FAIL_STACK_ERROR -#endif/* H5_HAVE_PARALLEL */ - if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0) +#endif /* H5_HAVE_PARALLEL */ + if ((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0) FAIL_STACK_ERROR - if((H5Pset_data_transform(dxpl, c_to_f)) < 0) + if ((H5Pset_data_transform(dxpl, c_to_f)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(dxpl, low, high, FALSE) < 0) + if (test_encode_decode(dxpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(dxpl)) < 0) + if ((H5Pclose(dxpl)) < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE GCPLS *****/ TESTING("Default GCPL Encoding/Decoding"); - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + if ((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(gcpl, low, high, FALSE) < 0) + if (test_encode_decode(gcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n") PASSED(); TESTING("GCPL Encoding/Decoding"); - if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) + if ((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) FAIL_STACK_ERROR - if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0) + if ((H5Pset_link_phase_change(gcpl, 2, 2)) < 0) FAIL_STACK_ERROR /* Query the group creation properties */ - if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0) + if ((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0) FAIL_STACK_ERROR - if((H5Pset_est_link_info(gcpl, 3, 9)) < 0) + if ((H5Pset_est_link_info(gcpl, 3, 9)) < 0) FAIL_STACK_ERROR - if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + if ((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(gcpl, low, high, FALSE) < 0) + if (test_encode_decode(gcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(gcpl)) < 0) + if ((H5Pclose(gcpl)) < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE LCPLS *****/ TESTING("Default LCPL Encoding/Decoding"); - if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) + if ((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(lcpl, low, high, FALSE) < 0) + if (test_encode_decode(lcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n") PASSED(); TESTING("LCPL Encoding/Decoding"); - if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) + if ((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(lcpl, low, high, FALSE) < 0) + if (test_encode_decode(lcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(lcpl)) < 0) + if ((H5Pclose(lcpl)) < 0) FAIL_STACK_ERROR PASSED(); - /******* ENCODE/DECODE LAPLS *****/ TESTING("Default LAPL Encoding/Decoding"); - if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) + if ((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(lapl, low, high, FALSE) < 0) + if (test_encode_decode(lapl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n") PASSED(); TESTING("LAPL Encoding/Decoding"); - if((H5Pset_nlinks(lapl, (size_t)134)) < 0) + if ((H5Pset_nlinks(lapl, (size_t)134)) < 0) FAIL_STACK_ERROR - if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0) + if ((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0) FAIL_STACK_ERROR - if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0) + if ((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0) FAIL_STACK_ERROR /* Create FAPL for the elink FAPL */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR - if((H5Pset_alignment(fapl, 2, 1024)) < 0) + if ((H5Pset_alignment(fapl, 2, 1024)) < 0) FAIL_STACK_ERROR - if((H5Pset_elink_fapl(lapl, fapl)) < 0) + if ((H5Pset_elink_fapl(lapl, fapl)) < 0) FAIL_STACK_ERROR /* Close the elink's FAPL */ - if((H5Pclose(fapl)) < 0) + if ((H5Pclose(fapl)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(lapl, low, high, FALSE) < 0) + if (test_encode_decode(lapl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(lapl)) < 0) + if ((H5Pclose(lapl)) < 0) FAIL_STACK_ERROR PASSED(); - /******* ENCODE/DECODE OCPYPLS *****/ TESTING("Default OCPYPL Encoding/Decoding"); - if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) + if ((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(ocpypl, low, high, FALSE) < 0) + if (test_encode_decode(ocpypl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n") PASSED(); TESTING("OCPYPL Encoding/Decoding"); - if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) + if ((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) FAIL_STACK_ERROR - if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0) + if ((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0) FAIL_STACK_ERROR - if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0) + if ((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(ocpypl, low, high, FALSE) < 0) + if (test_encode_decode(ocpypl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(ocpypl)) < 0) + if ((H5Pclose(ocpypl)) < 0) FAIL_STACK_ERROR PASSED(); - /******* ENCODE/DECODE FAPLS *****/ + /******* ENCODE/DECODE FAPLS *****/ TESTING("Default FAPL Encoding/Decoding"); - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(fapl, low, high, FALSE) < 0) + if (test_encode_decode(fapl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n") PASSED(); TESTING("FAPL Encoding/Decoding"); - if((H5Pset_family_offset(fapl, 1024)) < 0) + if ((H5Pset_family_offset(fapl, 1024)) < 0) FAIL_STACK_ERROR - if((H5Pset_meta_block_size(fapl, 2098452)) < 0) + if ((H5Pset_meta_block_size(fapl, 2098452)) < 0) FAIL_STACK_ERROR - if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0) + if ((H5Pset_sieve_buf_size(fapl, 1048576)) < 0) FAIL_STACK_ERROR - if((H5Pset_alignment(fapl, 2, 1024)) < 0) + if ((H5Pset_alignment(fapl, 2, 1024)) < 0) FAIL_STACK_ERROR - if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0) + if ((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0) FAIL_STACK_ERROR - if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0) + if ((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0) FAIL_STACK_ERROR - if((H5Pset_gc_references(fapl, 1)) < 0) + if ((H5Pset_gc_references(fapl, 1)) < 0) FAIL_STACK_ERROR - if((H5Pset_small_data_block_size(fapl, 2048)) < 0) + if ((H5Pset_small_data_block_size(fapl, 2048)) < 0) FAIL_STACK_ERROR - if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) + if ((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) FAIL_STACK_ERROR - if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0) + if ((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0) FAIL_STACK_ERROR - if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0) + if ((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0) FAIL_STACK_ERROR - if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0) + if ((H5Pset_mdc_config(fapl, &my_cache_config)) < 0) FAIL_STACK_ERROR - if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) + if ((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(fapl, low, high, FALSE) < 0) + if (test_encode_decode(fapl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(fapl)) < 0) + if ((H5Pclose(fapl)) < 0) FAIL_STACK_ERROR PASSED(); - /******* ENCODE/DECODE FCPLS *****/ TESTING("Default FCPL Encoding/Decoding"); - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(fcpl, low, high, FALSE) < 0) + if (test_encode_decode(fcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n") PASSED(); TESTING("FCPL Encoding/Decoding"); - if((H5Pset_userblock(fcpl, 1024) < 0)) + if ((H5Pset_userblock(fcpl, 1024) < 0)) FAIL_STACK_ERROR - if((H5Pset_istore_k(fcpl, 3) < 0)) + if ((H5Pset_istore_k(fcpl, 3) < 0)) FAIL_STACK_ERROR - if((H5Pset_sym_k(fcpl, 4, 5) < 0)) + if ((H5Pset_sym_k(fcpl, 4, 5) < 0)) FAIL_STACK_ERROR - if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0)) + if ((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0)) FAIL_STACK_ERROR - if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) + if ((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) FAIL_STACK_ERROR - if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0)) + if ((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0)) FAIL_STACK_ERROR - if((H5Pset_sizes(fcpl, 8, 4) < 0)) + if ((H5Pset_sizes(fcpl, 8, 4) < 0)) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(fcpl, low, high, FALSE) < 0) + if (test_encode_decode(fcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(fcpl)) < 0) + if ((H5Pclose(fcpl)) < 0) FAIL_STACK_ERROR PASSED(); - /******* ENCODE/DECODE STRCPLS *****/ TESTING("Default STRCPL Encoding/Decoding"); - if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) + if ((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(strcpl, low, high, FALSE) < 0) + if (test_encode_decode(strcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n") PASSED(); TESTING("STRCPL Encoding/Decoding"); - if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) + if ((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(strcpl, low, high, FALSE) < 0) + if (test_encode_decode(strcpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(strcpl)) < 0) + if ((H5Pclose(strcpl)) < 0) FAIL_STACK_ERROR PASSED(); - /******* ENCODE/DECODE ACPLS *****/ TESTING("Default ACPL Encoding/Decoding"); - if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) + if ((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) FAIL_STACK_ERROR /* Test encoding & decoding default property list */ - if(test_encode_decode(acpl, low, high, FALSE) < 0) + if (test_encode_decode(acpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n") PASSED(); TESTING("ACPL Encoding/Decoding"); - if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) + if ((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) FAIL_STACK_ERROR /* Test encoding & decoding property list */ - if(test_encode_decode(acpl, low, high, FALSE) < 0) + if (test_encode_decode(acpl, low, high, FALSE) < 0) FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n") /* release resource */ - if((H5Pclose(acpl)) < 0) + if ((H5Pclose(acpl)) < 0) FAIL_STACK_ERROR PASSED(); } /* end high */ - } /* end low */ + } /* end low */ return 0; error: -HDprintf("***** Plist Encode/Decode tests FAILED! *****\n"); + HDprintf("***** Plist Encode/Decode tests FAILED! *****\n"); return 1; } - diff --git a/test/enc_dec_plist_cross_platform.c b/test/enc_dec_plist_cross_platform.c index c4dec9f..db11729 100644 --- a/test/enc_dec_plist_cross_platform.c +++ b/test/enc_dec_plist_cross_platform.c @@ -18,135 +18,135 @@ #include "h5test.h" #include "H5srcdir.h" -#define CONFIG_LE 0x01 -#define CONFIG_64 0x02 -#define NCONFIG 0x04 +#define CONFIG_LE 0x01 +#define CONFIG_64 0x02 +#define NCONFIG 0x04 static int test_plists(const char *filename_prefix); int main(void) { - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("Encode/Decode property list endianess\n"); /******* ENCODE/DECODE DCPLS *****/ TESTING("Default DCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_dcpl_") < 0) + if (test_plists("testfiles/plist_files/def_dcpl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("DCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/dcpl_") < 0) + if (test_plists("testfiles/plist_files/dcpl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE DAPLS *****/ TESTING("Default DAPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_dapl_") < 0) + if (test_plists("testfiles/plist_files/def_dapl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("DAPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/dapl_") < 0) + if (test_plists("testfiles/plist_files/dapl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE DXPLS *****/ TESTING("Default DXPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_dxpl_") < 0) + if (test_plists("testfiles/plist_files/def_dxpl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("DXPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/dxpl_") < 0) + if (test_plists("testfiles/plist_files/dxpl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE GCPLS *****/ TESTING("Default GCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_gcpl_") < 0) + if (test_plists("testfiles/plist_files/def_gcpl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("GCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/gcpl_") < 0) + if (test_plists("testfiles/plist_files/gcpl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE LCPLS *****/ TESTING("Default LCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_lcpl_") < 0) + if (test_plists("testfiles/plist_files/def_lcpl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("LCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/lcpl_") < 0) + if (test_plists("testfiles/plist_files/lcpl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE LAPLS *****/ TESTING("Default LAPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_lapl_") < 0) + if (test_plists("testfiles/plist_files/def_lapl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("LAPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/lapl_") < 0) + if (test_plists("testfiles/plist_files/lapl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE OCPLS *****/ TESTING("Default OCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_ocpl_") < 0) + if (test_plists("testfiles/plist_files/def_ocpl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("OCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/ocpl_") < 0) + if (test_plists("testfiles/plist_files/ocpl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE OCPYPLS *****/ TESTING("Default OCPYPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_ocpypl_") < 0) + if (test_plists("testfiles/plist_files/def_ocpypl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("OCPYPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/ocpypl_") < 0) + if (test_plists("testfiles/plist_files/ocpypl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE FCPLS *****/ TESTING("Default FCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_fcpl_") < 0) + if (test_plists("testfiles/plist_files/def_fcpl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("FCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/fcpl_") < 0) + if (test_plists("testfiles/plist_files/fcpl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE FAPLS *****/ TESTING("Default FAPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_fapl_") < 0) + if (test_plists("testfiles/plist_files/def_fapl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("FAPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/fapl_") < 0) + if (test_plists("testfiles/plist_files/fapl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE STRCPLS *****/ TESTING("Default STRCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_strcpl_") < 0) + if (test_plists("testfiles/plist_files/def_strcpl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("STRCPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/strcpl_") < 0) + if (test_plists("testfiles/plist_files/strcpl_") < 0) FAIL_STACK_ERROR PASSED(); /******* ENCODE/DECODE ACPLS *****/ TESTING("Default ACPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/def_acpl_") < 0) + if (test_plists("testfiles/plist_files/def_acpl_") < 0) FAIL_STACK_ERROR PASSED(); TESTING("ACPL Encoding/Decoding"); - if(test_plists("testfiles/plist_files/acpl_") < 0) + if (test_plists("testfiles/plist_files/acpl_") < 0) FAIL_STACK_ERROR PASSED(); @@ -159,31 +159,30 @@ error: static hid_t read_and_decode_plist_file(const char *filename_prefix, unsigned config, char *filename, size_t filename_len) { - int fd; - size_t size; + int fd; + size_t size; const char *testfile; - void *buf = NULL; - hid_t plist = H5I_INVALID_HID; + void * buf = NULL; + hid_t plist = H5I_INVALID_HID; /* Generate filename from prefix and configuration word */ - if(HDsnprintf(filename, filename_len, "%s%s%s", filename_prefix, - config & CONFIG_64 ? "64" : "32", - config & CONFIG_LE ? "le" : "be") < 0) + if (HDsnprintf(filename, filename_len, "%s%s%s", filename_prefix, config & CONFIG_64 ? "64" : "32", + config & CONFIG_LE ? "le" : "be") < 0) TEST_ERROR /* Read file 1 */ testfile = H5_get_srcdir_filename(filename); - if((fd = HDopen(testfile, O_RDONLY)) < 0) + if ((fd = HDopen(testfile, O_RDONLY)) < 0) TEST_ERROR size = (size_t)HDlseek(fd, 0, SEEK_END); HDlseek(fd, 0, SEEK_SET); buf = HDmalloc(size); - if(HDread(fd, buf, size) < 0) + if (HDread(fd, buf, size) < 0) TEST_ERROR HDclose(fd); /* Decode property lists */ - if((plist = H5Pdecode(buf)) < 0) + if ((plist = H5Pdecode(buf)) < 0) FAIL_STACK_ERROR error: if (buf != NULL) @@ -194,28 +193,29 @@ error: static int test_plists(const char *filename_prefix) { - int i; + int i; unsigned config[2]; - hid_t plist[2]; - char filename[2][1024]; + hid_t plist[2]; + char filename[2][1024]; /* Iterate over all combinations of configurations */ - for(config[0] = 0; config[0] < (NCONFIG - 1); config[0]++) { - for(config[1] = config[0] + 1; config[1] < NCONFIG; config[1]++) { + for (config[0] = 0; config[0] < (NCONFIG - 1); config[0]++) { + for (config[1] = config[0] + 1; config[1] < NCONFIG; config[1]++) { for (i = 0; i < 2; i++) { - plist[i] = read_and_decode_plist_file(filename_prefix, - config[i], filename[i], sizeof(filename[i])); + plist[i] = + read_and_decode_plist_file(filename_prefix, config[i], filename[i], sizeof(filename[i])); if (plist[i] == H5I_INVALID_HID) goto error; } /* Compare decoded property lists */ - if(!H5Pequal(plist[0], plist[1])) + if (!H5Pequal(plist[0], plist[1])) FAIL_PRINTF_ERROR("PLIST encoding/decoding comparison failed, " - "%s != %s\n", filename[0], filename[1]) + "%s != %s\n", + filename[0], filename[1]) for (i = 0; i < 2; i++) { - if((H5Pclose(plist[i])) < 0) + if ((H5Pclose(plist[i])) < 0) FAIL_STACK_ERROR } } @@ -227,4 +227,3 @@ error: HDprintf("***** Plist Encode/Decode tests FAILED! *****\n"); return -1; } - diff --git a/test/enum.c b/test/enum.c index 109f7c3..ee3290f 100644 --- a/test/enum.c +++ b/test/enum.c @@ -16,22 +16,12 @@ * Tuesday, December 22, 1998 */ #include "h5test.h" -#define CPTR(VAR,CONST) ((VAR)=(CONST),&(VAR)) - -const char *FILENAME[] = { - "enum1", - NULL -}; - -typedef enum { - E1_RED, - E1_GREEN, - E1_BLUE, - E1_WHITE, - E1_BLACK -} c_e1; - - +#define CPTR(VAR, CONST) ((VAR) = (CONST), &(VAR)) + +const char *FILENAME[] = {"enum1", NULL}; + +typedef enum { E1_RED, E1_GREEN, E1_BLUE, E1_WHITE, E1_BLACK } c_e1; + /*------------------------------------------------------------------------- * Function: test_named * @@ -51,61 +41,90 @@ typedef enum { static int test_named(hid_t file) { - hid_t type = -1, cwg = -1; - c_e1 val; - signed char val8; + hid_t type = -1, cwg = -1; + c_e1 val; + signed char val8; TESTING("named enumeration types"); - if((cwg = H5Gcreate2(file, "test_named", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((cwg = H5Gcreate2(file, "test_named", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* A native integer */ - if((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "RED", CPTR(val, E1_RED )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) FAIL_STACK_ERROR - if(H5Tcommit2(cwg, "e1_a", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Tclose(type) < 0) FAIL_STACK_ERROR + if ((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "RED", CPTR(val, E1_RED)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) + FAIL_STACK_ERROR + if (H5Tcommit2(cwg, "e1_a", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR /* A smaller type */ - if((type = H5Tcreate(H5T_ENUM, (size_t)1)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "RED", CPTR(val8, E1_RED )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLUE", CPTR(val8, E1_BLUE )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "WHITE", CPTR(val8, E1_WHITE)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLACK", CPTR(val8, E1_BLACK)) < 0) FAIL_STACK_ERROR - if(H5Tcommit2(cwg, "e1_b", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Tclose(type) < 0) FAIL_STACK_ERROR + if ((type = H5Tcreate(H5T_ENUM, (size_t)1)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "RED", CPTR(val8, E1_RED)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLUE", CPTR(val8, E1_BLUE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "WHITE", CPTR(val8, E1_WHITE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLACK", CPTR(val8, E1_BLACK)) < 0) + FAIL_STACK_ERROR + if (H5Tcommit2(cwg, "e1_b", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR /* A non-native type */ - if(H5T_ORDER_BE == H5Tget_order(H5T_NATIVE_INT)) { - if ((type = H5Tenum_create(H5T_STD_U8LE)) < 0) FAIL_STACK_ERROR - } else { - if ((type = H5Tenum_create(H5T_STD_U8BE)) < 0) FAIL_STACK_ERROR + if (H5T_ORDER_BE == H5Tget_order(H5T_NATIVE_INT)) { + if ((type = H5Tenum_create(H5T_STD_U8LE)) < 0) + FAIL_STACK_ERROR } - if(H5Tenum_insert(type, "RED", CPTR(val8, E1_RED )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLUE", CPTR(val8, E1_BLUE )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "WHITE", CPTR(val8, E1_WHITE)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLACK", CPTR(val8, E1_BLACK)) < 0) FAIL_STACK_ERROR - if(H5Tcommit2(cwg, "e1_c", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Tclose(type) < 0) FAIL_STACK_ERROR - - if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR + else { + if ((type = H5Tenum_create(H5T_STD_U8BE)) < 0) + FAIL_STACK_ERROR + } + if (H5Tenum_insert(type, "RED", CPTR(val8, E1_RED)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLUE", CPTR(val8, E1_BLUE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "WHITE", CPTR(val8, E1_WHITE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLACK", CPTR(val8, E1_BLACK)) < 0) + FAIL_STACK_ERROR + if (H5Tcommit2(cwg, "e1_c", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR + + if (H5Gclose(cwg) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Tclose(type); - H5Gclose(cwg); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Tclose(type); + H5Gclose(cwg); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_conv * @@ -126,140 +145,162 @@ test_named(hid_t file) static int test_conv(hid_t file) { - hid_t cwg=-1, type=-1, space=-1, dset=-1; - c_e1 val; + hid_t cwg = -1, type = -1, space = -1, dset = -1; + c_e1 val; /* Some values are out of range for testing. The library should accept them */ - static c_e1 data1[]={E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, - E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED, - E1_RED, E1_BLUE, E1_GREEN, E1_BLACK, E1_WHITE, - E1_RED, E1_WHITE, (c_e1)0, (c_e1)-1, (c_e1)-2}; - c_e1 data2[NELMTS(data1)]; - short data_short[NELMTS(data1)]; - int data_int[NELMTS(data1)]; - double data_double[NELMTS(data1)]; - hsize_t ds_size[1]={NELMTS(data1)}; - size_t i; + static c_e1 data1[] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, E1_WHITE, E1_BLACK, + E1_GREEN, E1_BLUE, E1_RED, E1_RED, E1_BLUE, E1_GREEN, E1_BLACK, + E1_WHITE, E1_RED, E1_WHITE, (c_e1)0, (c_e1)-1, (c_e1)-2}; + c_e1 data2[NELMTS(data1)]; + short data_short[NELMTS(data1)]; + int data_int[NELMTS(data1)]; + double data_double[NELMTS(data1)]; + hsize_t ds_size[1] = {NELMTS(data1)}; + size_t i; TESTING("enumeration conversions"); - if((cwg = H5Gcreate2(file, "test_conv", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - - if((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "RED", CPTR(val, E1_RED )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) FAIL_STACK_ERROR - - if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR + if ((cwg = H5Gcreate2(file, "test_conv", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + if ((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "RED", CPTR(val, E1_RED)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) + FAIL_STACK_ERROR + + if ((space = H5Screate_simple(1, ds_size, NULL)) < 0) + FAIL_STACK_ERROR /*************************************** * Dataset of enumeration type ***************************************/ /* Create a dataset of enum type and write enum data to it */ - if((dset = H5Dcreate2(cwg, "color_table1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR + if ((dset = H5Dcreate2(cwg, "color_table1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) + FAIL_STACK_ERROR /* Test reading back the data with no conversion */ - if(H5Dread(dset, type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR + if (H5Dread(dset, type, space, space, H5P_DEFAULT, data2) < 0) + FAIL_STACK_ERROR - for(i = 0; i < (size_t)ds_size[0]; i++) - if(data1[i] != data2[i]) { - H5_FAILED(); - HDprintf(" 1. data1[%lu]=%d, data2[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data2[i])); - goto error; - } /* end if */ + for (i = 0; i < (size_t)ds_size[0]; i++) + if (data1[i] != data2[i]) { + H5_FAILED(); + HDprintf(" 1. data1[%lu]=%d, data2[%lu]=%d (should be same)\n", (unsigned long)i, + (int)(data1[i]), (unsigned long)i, (int)(data2[i])); + goto error; + } /* end if */ /* Test converting the data to integer. Read enum data back as integer */ - if(H5Dread(dset, H5T_NATIVE_SHORT, space, space, H5P_DEFAULT, data_short) < 0) FAIL_STACK_ERROR + if (H5Dread(dset, H5T_NATIVE_SHORT, space, space, H5P_DEFAULT, data_short) < 0) + FAIL_STACK_ERROR - for(i = 0; i < (size_t)ds_size[0]; i++) - if((short)data1[i] != data_short[i]) { - H5_FAILED(); - HDprintf(" 2. data1[%lu]=%d, data_short[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data_short[i])); - goto error; - } /* end if */ + for (i = 0; i < (size_t)ds_size[0]; i++) + if ((short)data1[i] != data_short[i]) { + H5_FAILED(); + HDprintf(" 2. data1[%lu]=%d, data_short[%lu]=%d (should be same)\n", (unsigned long)i, + (int)(data1[i]), (unsigned long)i, (int)(data_short[i])); + goto error; + } /* end if */ /* Test converting the data to floating number. Read enum data back as floating number */ - if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, data_double) < 0) FAIL_STACK_ERROR + if (H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, data_double) < 0) + FAIL_STACK_ERROR - for(i = 0; i < (size_t)ds_size[0]; i++) - if((int)data1[i] != (int)data_double[i]) { - H5_FAILED(); - HDprintf(" 3. data1[%lu]=%d, data_double[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data_double[i])); - goto error; - } /* end if */ + for (i = 0; i < (size_t)ds_size[0]; i++) + if ((int)data1[i] != (int)data_double[i]) { + H5_FAILED(); + HDprintf(" 3. data1[%lu]=%d, data_double[%lu]=%d (should be same)\n", (unsigned long)i, + (int)(data1[i]), (unsigned long)i, (int)(data_double[i])); + goto error; + } /* end if */ - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR /*************************************** * Dataset of integer type ***************************************/ /* Create a dataset of native integer and write enum data to it */ - if((dset = H5Dcreate2(cwg, "color_table2", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dset = H5Dcreate2(cwg, "color_table2", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if(H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) + FAIL_STACK_ERROR /* Test reading back the data with no conversion */ - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, data_int) < 0) FAIL_STACK_ERROR + if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, data_int) < 0) + FAIL_STACK_ERROR - for(i = 0; i < (size_t)ds_size[0]; i++) - if((int)data1[i] != data_int[i]) { - H5_FAILED(); - HDprintf(" 4. data1[%lu]=%d, data_int[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data_int[i])); - goto error; - } /* end if */ + for (i = 0; i < (size_t)ds_size[0]; i++) + if ((int)data1[i] != data_int[i]) { + H5_FAILED(); + HDprintf(" 4. data1[%lu]=%d, data_int[%lu]=%d (should be same)\n", (unsigned long)i, + (int)(data1[i]), (unsigned long)i, (int)(data_int[i])); + goto error; + } /* end if */ - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR /*************************************** * Dataset of double type ***************************************/ /* Create a dataset of native double and write enum data to it */ - if((dset = H5Dcreate2(cwg, "color_table3", H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dset = H5Dcreate2(cwg, "color_table3", H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if(H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) + FAIL_STACK_ERROR /* Test reading back the data with no conversion */ - if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, data_double) < 0) FAIL_STACK_ERROR + if (H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, data_double) < 0) + FAIL_STACK_ERROR - for(i = 0; i < (size_t)ds_size[0]; i++) - if((int)data1[i] != (int)data_double[i]) { - H5_FAILED(); - HDprintf(" 5. data1[%lu]=%d, data_double[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data_double[i])); - goto error; - } /* end if */ + for (i = 0; i < (size_t)ds_size[0]; i++) + if ((int)data1[i] != (int)data_double[i]) { + H5_FAILED(); + HDprintf(" 5. data1[%lu]=%d, data_double[%lu]=%d (should be same)\n", (unsigned long)i, + (int)(data1[i]), (unsigned long)i, (int)(data_double[i])); + goto error; + } /* end if */ - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Tclose(type) < 0) FAIL_STACK_ERROR - if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR + if (H5Gclose(cwg) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Dclose(dset); - H5Sclose(space); - H5Tclose(type); - H5Gclose(cwg); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Dclose(dset); + H5Sclose(space); + H5Tclose(type); + H5Gclose(cwg); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_tr1 * @@ -282,70 +323,91 @@ test_conv(hid_t file) static int test_tr1(hid_t file) { - hid_t cwg = -1, m_type = -1, f_type = -1, space = -1, dset = -1; - hsize_t ds_size[1] = {10}; - size_t i; - c_e1 eval; - int ival; - static c_e1 data1[10] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, - E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED}; - c_e1 data2[10]; + hid_t cwg = -1, m_type = -1, f_type = -1, space = -1, dset = -1; + hsize_t ds_size[1] = {10}; + size_t i; + c_e1 eval; + int ival; + static c_e1 data1[10] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, + E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED}; + c_e1 data2[10]; TESTING("O(1) conversions"); - if((cwg = H5Gcreate2(file, "test_tr1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - - if((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "RED", CPTR(eval, E1_RED )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "GREEN", CPTR(eval, E1_GREEN)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "BLUE", CPTR(eval, E1_BLUE )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "WHITE", CPTR(eval, E1_WHITE)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "BLACK", CPTR(eval, E1_BLACK)) < 0) FAIL_STACK_ERROR - - - if((f_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "RED", CPTR(ival, 105)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "GREEN", CPTR(ival, 104)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "BLUE", CPTR(ival, 103)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "WHITE", CPTR(ival, 102)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "BLACK", CPTR(ival, 101)) < 0) FAIL_STACK_ERROR - - if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR - if(H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR - - for(i = 0; i < (size_t)ds_size[0]; i++) - if(data1[i] != data2[i]) { + if ((cwg = H5Gcreate2(file, "test_tr1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + if ((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "RED", CPTR(eval, E1_RED)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "GREEN", CPTR(eval, E1_GREEN)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "BLUE", CPTR(eval, E1_BLUE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "WHITE", CPTR(eval, E1_WHITE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "BLACK", CPTR(eval, E1_BLACK)) < 0) + FAIL_STACK_ERROR + + if ((f_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "RED", CPTR(ival, 105)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "GREEN", CPTR(ival, 104)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "BLUE", CPTR(ival, 103)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "WHITE", CPTR(ival, 102)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "BLACK", CPTR(ival, 101)) < 0) + FAIL_STACK_ERROR + + if ((space = H5Screate_simple(1, ds_size, NULL)) < 0) + FAIL_STACK_ERROR + if ((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) + FAIL_STACK_ERROR + if (H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) + FAIL_STACK_ERROR + + for (i = 0; i < (size_t)ds_size[0]; i++) + if (data1[i] != data2[i]) { H5_FAILED(); - HDprintf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data2[i])); + HDprintf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n", (unsigned long)i, (int)(data1[i]), + (unsigned long)i, (int)(data2[i])); goto error; } - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Tclose(m_type) < 0) FAIL_STACK_ERROR - if(H5Tclose(f_type) < 0) FAIL_STACK_ERROR - if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Tclose(m_type) < 0) + FAIL_STACK_ERROR + if (H5Tclose(f_type) < 0) + FAIL_STACK_ERROR + if (H5Gclose(cwg) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Tclose(m_type); H5Tclose(f_type); H5Gclose(cwg); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_tr2 * @@ -365,69 +427,91 @@ error: static int test_tr2(hid_t file) { - hid_t cwg = -1, m_type = -1, f_type = -1, space = -1, dset = -1; - hsize_t ds_size[1] = {10}; - size_t i; - c_e1 val1; - int val2; - static c_e1 data1[10] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, - E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED}; - c_e1 data2[10]; + hid_t cwg = -1, m_type = -1, f_type = -1, space = -1, dset = -1; + hsize_t ds_size[1] = {10}; + size_t i; + c_e1 val1; + int val2; + static c_e1 data1[10] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, + E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED}; + c_e1 data2[10]; TESTING("O(log N) conversions"); - if((cwg = H5Gcreate2(file, "test_tr2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - - if((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "RED", CPTR(val1, E1_RED )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "GREEN", CPTR(val1, E1_GREEN)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "BLUE", CPTR(val1, E1_BLUE )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "WHITE", CPTR(val1, E1_WHITE)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(m_type, "BLACK", CPTR(val1, E1_BLACK)) < 0) FAIL_STACK_ERROR - - if((f_type = H5Tcreate(H5T_ENUM, sizeof(int))) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "RED", CPTR(val2, 1050)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "GREEN", CPTR(val2, 1040)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "BLUE", CPTR(val2, 1030)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "WHITE", CPTR(val2, 1020)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(f_type, "BLACK", CPTR(val2, 1010)) < 0) FAIL_STACK_ERROR - - if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR - if(H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR - - for(i = 0; i < (size_t)ds_size[0]; i++) - if(data1[i] != data2[i]) { + if ((cwg = H5Gcreate2(file, "test_tr2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + if ((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "RED", CPTR(val1, E1_RED)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "GREEN", CPTR(val1, E1_GREEN)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "BLUE", CPTR(val1, E1_BLUE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "WHITE", CPTR(val1, E1_WHITE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(m_type, "BLACK", CPTR(val1, E1_BLACK)) < 0) + FAIL_STACK_ERROR + + if ((f_type = H5Tcreate(H5T_ENUM, sizeof(int))) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "RED", CPTR(val2, 1050)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "GREEN", CPTR(val2, 1040)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "BLUE", CPTR(val2, 1030)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "WHITE", CPTR(val2, 1020)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(f_type, "BLACK", CPTR(val2, 1010)) < 0) + FAIL_STACK_ERROR + + if ((space = H5Screate_simple(1, ds_size, NULL)) < 0) + FAIL_STACK_ERROR + if ((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) + FAIL_STACK_ERROR + if (H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) + FAIL_STACK_ERROR + + for (i = 0; i < (size_t)ds_size[0]; i++) + if (data1[i] != data2[i]) { H5_FAILED(); - HDprintf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n", - (unsigned long)i, (int)(data1[i]), - (unsigned long)i, (int)(data2[i])); + HDprintf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n", (unsigned long)i, (int)(data1[i]), + (unsigned long)i, (int)(data2[i])); goto error; } - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Tclose(m_type) < 0) FAIL_STACK_ERROR - if(H5Tclose(f_type) < 0) FAIL_STACK_ERROR - if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Tclose(m_type) < 0) + FAIL_STACK_ERROR + if (H5Tclose(f_type) < 0) + FAIL_STACK_ERROR + if (H5Gclose(cwg) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Tclose(m_type); H5Tclose(f_type); H5Gclose(cwg); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_value_dsnt_exist * @@ -455,62 +539,77 @@ static int test_value_dsnt_exist(void) { - hid_t datatype_id=(-1); /* identifiers */ - int val; - char nam[100]; + hid_t datatype_id = (-1); /* identifiers */ + int val; + char nam[100]; size_t size = 100; TESTING("for non-existing name and value"); /* Turn off error reporting since we expect failure in this test */ - if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) goto error; + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) + goto error; - if ((datatype_id = H5Tenum_create(H5T_NATIVE_INT))< 0) goto error; + if ((datatype_id = H5Tenum_create(H5T_NATIVE_INT)) < 0) + goto error; /* These calls should fail, since no memebrs exist yet */ - if (H5Tenum_valueof(datatype_id, "SAX", &val) >= 0) goto error; + if (H5Tenum_valueof(datatype_id, "SAX", &val) >= 0) + goto error; val = 3; - if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) goto error; + if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) + goto error; val = 2; - if (H5Tenum_insert(datatype_id, "TWO", (int *)&val) < 0) goto error; + if (H5Tenum_insert(datatype_id, "TWO", (int *)&val) < 0) + goto error; val = 6; - if (H5Tenum_insert(datatype_id, "SIX", (int *)&val) < 0) goto error; + if (H5Tenum_insert(datatype_id, "SIX", (int *)&val) < 0) + goto error; val = 10; - if (H5Tenum_insert(datatype_id, "TEN", (int *)&val) < 0) goto error; + if (H5Tenum_insert(datatype_id, "TEN", (int *)&val) < 0) + goto error; /* This call should fail since we did not create a member with value = 3*/ val = 3; - if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) goto error; + if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) + goto error; /* This call should fail since we did not create a member with value = 11*/ val = 11; - if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) goto error; + if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) + goto error; /* This call should fail since we did not create a member with value = 0*/ val = 0; - if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) goto error; + if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) + goto error; /* This call should fail since we do not have SAX name in the type */ - if (H5Tenum_valueof(datatype_id, "SAX", &val) >= 0) goto error; + if (H5Tenum_valueof(datatype_id, "SAX", &val) >= 0) + goto error; /* This call should fail since we do not have TEEN name in the type */ - if (H5Tenum_valueof(datatype_id, "TEEN", &val) >= 0) goto error; + if (H5Tenum_valueof(datatype_id, "TEEN", &val) >= 0) + goto error; /* This call should fail since we do not have A name in the type */ - if (H5Tenum_valueof(datatype_id, "A", &val) >= 0) goto error; + if (H5Tenum_valueof(datatype_id, "A", &val) >= 0) + goto error; - if (H5Tclose(datatype_id) < 0) goto error; + if (H5Tclose(datatype_id) < 0) + goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Tclose(datatype_id); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Tclose(datatype_id); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_funcs * @@ -531,97 +630,122 @@ test_value_dsnt_exist(void) static int test_funcs(void) { - hid_t type=-1; - c_e1 val; - size_t size; - H5T_pad_t inpad; - H5T_cset_t cset; - herr_t ret; + hid_t type = -1; + c_e1 val; + size_t size; + H5T_pad_t inpad; + H5T_cset_t cset; + herr_t ret; TESTING("some functions with enumeration types"); /* A native integer */ - if((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "RED", CPTR(val, E1_RED )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE )) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) FAIL_STACK_ERROR - if(H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) FAIL_STACK_ERROR - - if(H5Tget_precision(type) == 0) FAIL_STACK_ERROR - if(H5Tget_size(type) == 0) FAIL_STACK_ERROR - if(H5Tget_offset(type) < 0) FAIL_STACK_ERROR - if(H5Tget_sign(type) < 0) FAIL_STACK_ERROR - if(H5Tget_super(type) < 0) FAIL_STACK_ERROR - - H5E_BEGIN_TRY { - ret=H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE); - } H5E_END_TRY; - if (ret>=0) { + if ((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "RED", CPTR(val, E1_RED)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) + FAIL_STACK_ERROR + if (H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) + FAIL_STACK_ERROR + + if (H5Tget_precision(type) == 0) + FAIL_STACK_ERROR + if (H5Tget_size(type) == 0) + FAIL_STACK_ERROR + if (H5Tget_offset(type) < 0) + FAIL_STACK_ERROR + if (H5Tget_sign(type) < 0) + FAIL_STACK_ERROR + if (H5Tget_super(type) < 0) + FAIL_STACK_ERROR + + H5E_BEGIN_TRY + { + ret = H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE); + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { - size=H5Tget_ebias(type); - } H5E_END_TRY; - if (size>0) { + H5E_BEGIN_TRY + { + size = H5Tget_ebias(type); + } + H5E_END_TRY; + if (size > 0) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { - inpad=H5Tget_inpad(type); - } H5E_END_TRY; - if (inpad>-1) { + H5E_BEGIN_TRY + { + inpad = H5Tget_inpad(type); + } + H5E_END_TRY; + if (inpad > -1) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { - cset=H5Tget_cset(type); - } H5E_END_TRY; - if (cset>-1) { + H5E_BEGIN_TRY + { + cset = H5Tget_cset(type); + } + H5E_END_TRY; + if (cset > -1) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ size = 16; - H5E_BEGIN_TRY { - ret=H5Tset_offset(type, (size_t)size); - } H5E_END_TRY; - if (ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tset_offset(type, (size_t)size); + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - H5E_BEGIN_TRY { - ret=H5Tset_order(type, H5T_ORDER_BE); - } H5E_END_TRY; - if (ret>=0) { + H5E_BEGIN_TRY + { + ret = H5Tset_order(type, H5T_ORDER_BE); + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf("Operation not allowed for this type.\n"); goto error; } /* end if */ - if (H5Tclose(type)<0) goto error; + if (H5Tclose(type) < 0) + goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Tclose(type); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Tclose(type); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: main * @@ -641,16 +765,17 @@ test_funcs(void) int main(void) { - hid_t fapl=-1, file=-1; - char name[1024]; - int nerrors=0; + hid_t fapl = -1, file = -1; + char name[1024]; + int nerrors = 0; h5_reset(); fapl = h5_fileaccess(); /* Create the file */ h5_fixname(FILENAME[0], fapl, name, sizeof name); - if ((file=H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; + if ((file = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; /* Tests */ nerrors += test_named(file); @@ -665,12 +790,13 @@ main(void) /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if (nerrors) goto error; + if (nerrors) + goto error; puts("All enum tests passed."); h5_cleanup(FILENAME, fapl); return 0; - error: +error: puts("*** ENUM TESTS FAILED ***"); return 1; } diff --git a/test/err_compat.c b/test/err_compat.c index bd317bf..91d7d7f 100644 --- a/test/err_compat.c +++ b/test/err_compat.c @@ -20,32 +20,29 @@ #include "h5test.h" #ifdef H5_NO_DEPRECATED_SYMBOLS -int main(void) +int +main(void) { HDprintf("Test skipped because backward compatibility with v1.6 is NOT configured in\n"); return 0; } #else /* H5_NO_DEPRECATED_SYMBOLS */ -const char *FILENAME[] = { - "errors_compat", - NULL -}; - -#define DIM0 100 -#define DIM1 200 +const char *FILENAME[] = {"errors_compat", NULL}; -int **ipoints2 = NULL; -int **icheck2 = NULL; -int *ipoints2_data = NULL; -int *icheck2_data = NULL; +#define DIM0 100 +#define DIM1 200 -#define DSET_NAME "a_dataset" -#define FAKE_ID (hid_t)-1 +int **ipoints2 = NULL; +int **icheck2 = NULL; +int * ipoints2_data = NULL; +int * icheck2_data = NULL; -herr_t custom_print_cb1(int n, H5E_error1_t *err_desc, void* client_data); -herr_t custom_print_cb2(int n, H5E_error2_t *err_desc, void* client_data); +#define DSET_NAME "a_dataset" +#define FAKE_ID (hid_t) - 1 +herr_t custom_print_cb1(int n, H5E_error1_t *err_desc, void *client_data); +herr_t custom_print_cb2(int n, H5E_error2_t *err_desc, void *client_data); /*------------------------------------------------------------------------- * Function: user_print1 @@ -66,17 +63,15 @@ user_print1(FILE *stream) { /* Customized way to print errors */ HDfprintf(stderr, "\n********* Print error stack in customized way *********\n"); - if(H5Ewalk1(H5E_WALK_UPWARD, (H5E_walk1_t)custom_print_cb1, stream) < 0) + if (H5Ewalk1(H5E_WALK_UPWARD, (H5E_walk1_t)custom_print_cb1, stream) < 0) TEST_ERROR; return 0; - error: +error: return -1; - } - /*------------------------------------------------------------------------- * Function: user_print2 * @@ -96,17 +91,15 @@ user_print2(hid_t err_stack, FILE *stream) { /* Customized way to print errors */ HDfprintf(stderr, "\n********* Print error stack in customized way *********\n"); - if(H5Ewalk2(err_stack, H5E_WALK_UPWARD, (H5E_walk2_t)custom_print_cb2, stream) < 0) + if (H5Ewalk2(err_stack, H5E_WALK_UPWARD, (H5E_walk2_t)custom_print_cb2, stream) < 0) TEST_ERROR; return 0; - error: +error: return -1; - } - /*------------------------------------------------------------------------- * Function: custom_print_cb1 * @@ -125,22 +118,21 @@ user_print2(hid_t err_stack, FILE *stream) *------------------------------------------------------------------------- */ herr_t -custom_print_cb1(int n, H5E_error1_t *err_desc, void* client_data) +custom_print_cb1(int n, H5E_error1_t *err_desc, void *client_data) { - FILE *stream = (FILE *)client_data; - char *maj = NULL; - char *min = NULL; - const int indent = 4; + FILE * stream = (FILE *)client_data; + char * maj = NULL; + char * min = NULL; + const int indent = 4; - if(NULL == (min = H5Eget_minor(err_desc->min_num))) + if (NULL == (min = H5Eget_minor(err_desc->min_num))) TEST_ERROR; - if(NULL == (maj = H5Eget_major(err_desc->maj_num))) + if (NULL == (maj = H5Eget_major(err_desc->maj_num))) TEST_ERROR; - HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", - indent, "", n, err_desc->file_name, - err_desc->func_name, err_desc->line); + HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", indent, "", n, err_desc->file_name, + err_desc->func_name, err_desc->line); HDfprintf(stream, "%*smajor: %s\n", indent * 2, "", maj); HDfprintf(stream, "%*sminor: %s\n", indent * 2, "", min); @@ -151,15 +143,14 @@ custom_print_cb1(int n, H5E_error1_t *err_desc, void* client_data) return 0; error: - if(maj) + if (maj) H5free_memory(maj); - if(min) + if (min) H5free_memory(min); return -1; } - /*------------------------------------------------------------------------- * Function: custom_print_cb2 * @@ -178,22 +169,21 @@ error: *------------------------------------------------------------------------- */ herr_t -custom_print_cb2(int n, H5E_error2_t *err_desc, void* client_data) +custom_print_cb2(int n, H5E_error2_t *err_desc, void *client_data) { - FILE *stream = (FILE *)client_data; - char *maj = NULL; - char *min = NULL; - const int indent = 4; + FILE * stream = (FILE *)client_data; + char * maj = NULL; + char * min = NULL; + const int indent = 4; - if(NULL == (min = H5Eget_minor(err_desc->min_num))) + if (NULL == (min = H5Eget_minor(err_desc->min_num))) TEST_ERROR; - if(NULL == (maj = H5Eget_major(err_desc->maj_num))) + if (NULL == (maj = H5Eget_major(err_desc->maj_num))) TEST_ERROR; - HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", - indent, "", n, err_desc->file_name, - err_desc->func_name, err_desc->line); + HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", indent, "", n, err_desc->file_name, + err_desc->func_name, err_desc->line); HDfprintf(stream, "%*smajor: %s\n", indent * 2, "", maj); HDfprintf(stream, "%*sminor: %s\n", indent * 2, "", min); @@ -204,15 +194,14 @@ custom_print_cb2(int n, H5E_error2_t *err_desc, void* client_data) return 0; error: - if(maj) + if (maj) H5free_memory(maj); - if(min) + if (min) H5free_memory(min); return -1; } - /*------------------------------------------------------------------------- * Function: test_error1 * @@ -233,12 +222,12 @@ error: static herr_t test_error1(void) { - hid_t dataset, space; - hsize_t dims[2]; - H5E_auto1_t old_func1; - H5E_auto2_t old_func2; - void *old_data; - herr_t ret; + hid_t dataset, space; + hsize_t dims[2]; + H5E_auto1_t old_func1; + H5E_auto2_t old_func2; + void * old_data; + herr_t ret; TESTING("error API H5Eset/get_auto"); printf("\n"); @@ -246,106 +235,102 @@ test_error1(void) /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if ((space = H5Screate_simple(2, dims, NULL))<0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /* Use H5Eget_auto2 to query the default printing function. The library *should indicate H5Eprint2 as the default. */ - if (H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data)<0) - TEST_ERROR; + if (H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data) < 0) + TEST_ERROR; if (old_data != NULL) - TEST_ERROR; + TEST_ERROR; if (!old_func2 || (H5E_auto2_t)H5Eprint2 != old_func2) - TEST_ERROR; + TEST_ERROR; /* This function sets the default printing function to be H5Eprint2. */ - if(H5Eset_auto2(H5E_DEFAULT, old_func2, old_data)<0) + if (H5Eset_auto2(H5E_DEFAULT, old_func2, old_data) < 0) TEST_ERROR; /* Try the printing function. Dataset creation should fail because the file * doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - if(dataset >= 0) + dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dataset >= 0) TEST_ERROR; /* This call should work. It simply returns H5Eprint1. */ - if((ret = H5Eget_auto1(&old_func1, &old_data))<0) + if ((ret = H5Eget_auto1(&old_func1, &old_data)) < 0) TEST_ERROR; if (old_data != NULL) - TEST_ERROR; + TEST_ERROR; if (!old_func1 || (H5E_auto1_t)H5Eprint1 != old_func1) - TEST_ERROR; + TEST_ERROR; /* This function changes the old-style printing function to be user_print1. */ - if(H5Eset_auto1((H5E_auto1_t)user_print1, stderr)<0) + if (H5Eset_auto1((H5E_auto1_t)user_print1, stderr) < 0) TEST_ERROR; /* Try the printing function. Dataset creation should fail because the file * doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - if(dataset >= 0) + dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dataset >= 0) TEST_ERROR; /* This call should fail because the test mixes H5Eget_auto2 with H5Eset_auto1. * Once the H5Eset_auto1 is called with a user-defined printing function, * a call to H5Eget_auto2 will fail. But keep in mind the printing function is * user_print1. */ - if((ret = H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data))>=0) + if ((ret = H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data)) >= 0) TEST_ERROR; /* This function changes the new-style printing function to be user_print2. */ - if(H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)user_print2, stderr)<0) + if (H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)user_print2, stderr) < 0) TEST_ERROR; /* Try the printing function. Dataset creation should fail because the file * doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - if(dataset >= 0) + dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dataset >= 0) TEST_ERROR; /* This function changes the new-style printing function back to the default H5Eprint2. */ - if(H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)H5Eprint2, NULL)<0) + if (H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)H5Eprint2, NULL) < 0) TEST_ERROR; /* This call should work because the H5Eset_auto2 above restored the default printing * function H5Eprint2. It simply returns user_print1. */ - if((ret = H5Eget_auto1(&old_func1, &old_data))<0) + if ((ret = H5Eget_auto1(&old_func1, &old_data)) < 0) TEST_ERROR; if (old_data != NULL) - TEST_ERROR; + TEST_ERROR; if (!old_func1 || (H5E_auto1_t)user_print1 != old_func1) - TEST_ERROR; + TEST_ERROR; /* This function changes the new-style printing function back to the default H5Eprint1. */ - if(H5Eset_auto1((H5E_auto1_t)H5Eprint1, NULL)<0) + if (H5Eset_auto1((H5E_auto1_t)H5Eprint1, NULL) < 0) TEST_ERROR; /* This call should work because the H5Eset_auto1 above restored the default printing * function H5Eprint1. It simply returns H5Eprint2. */ - if((ret = H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data))<0) + if ((ret = H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data)) < 0) TEST_ERROR; if (old_data != NULL) - TEST_ERROR; + TEST_ERROR; if (!old_func2 || (H5E_auto2_t)H5Eprint2 != old_func2) - TEST_ERROR; + TEST_ERROR; /* Try the printing function. Dataset creation should fail because the file * doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - if(dataset >= 0) + dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dataset >= 0) TEST_ERROR; fprintf(stderr, "\n"); return 0; - error: +error: return -1; } - /*------------------------------------------------------------------------- * Function: test_error2 * @@ -366,9 +351,9 @@ test_error1(void) static herr_t test_error2(hid_t file) { - hid_t dataset, space; - hsize_t dims[2]; - const char *FUNC_test_error="test_error2"; + hid_t dataset, space; + hsize_t dims[2]; + const char *FUNC_test_error = "test_error2"; TESTING("error API based on data I/O"); printf("\n"); @@ -376,46 +361,48 @@ test_error2(hid_t file) /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if ((space = H5Screate_simple(2, dims, NULL))<0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /* Test H5E_BEGIN_TRY */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* Create the dataset */ - if ((dataset = H5Dcreate2(file, DSET_NAME, H5T_STD_I32BE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5Epush1(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_CANTCREATE, - "H5Dcreate2 failed"); + if ((dataset = H5Dcreate2(file, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) { + H5Epush1(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_CANTCREATE, "H5Dcreate2 failed"); goto error; } /* Disable the library's default printing function */ #ifdef H5_USE_16_API_DEFAULT - if(H5Eset_auto(NULL, NULL)<0) + if (H5Eset_auto(NULL, NULL) < 0) #else - if(H5Eset_auto(H5E_DEFAULT, NULL, NULL)<0) + if (H5Eset_auto(H5E_DEFAULT, NULL, NULL) < 0) #endif TEST_ERROR; /* Make H5Dwrite fail, verify default print is disabled */ - if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)<0) { + if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0) { H5Epush1(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_WRITEERROR, - "H5Dwrite shouldn't succeed"); + "H5Dwrite shouldn't succeed"); goto error; } /* In case program comes to this point, close dataset */ - if(H5Dclose(dataset)<0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; TEST_ERROR; - error: +error: return -1; } - /*------------------------------------------------------------------------- * Function: dump_error * @@ -438,22 +425,20 @@ dump_error(void) { /* Print errors in library default way */ HDfprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); - if(H5Eprint1(stderr) < 0) + if (H5Eprint1(stderr) < 0) TEST_ERROR; /* Customized way to print errors */ HDfprintf(stderr, "\n********* Print error stack in customized way *********\n"); - if(H5Ewalk1(H5E_WALK_UPWARD, custom_print_cb1, stderr) < 0) + if (H5Ewalk1(H5E_WALK_UPWARD, custom_print_cb1, stderr) < 0) TEST_ERROR; return 0; - error: +error: return -1; } - - /*------------------------------------------------------------------------- * Function: main * @@ -471,36 +456,36 @@ main(void) { hid_t file, fapl; char filename[1024]; - const char *FUNC_main="main"; + const char *FUNC_main = "main"; int i; - HDfprintf(stderr, " This program tests the Error API compatible with HDF5 v1.6. There are supposed to be some error messages\n"); + HDfprintf(stderr, " This program tests the Error API compatible with HDF5 v1.6. There are supposed to " + "be some error messages\n"); fapl = h5_fileaccess(); /* Set up data arrays */ - if(NULL == (ipoints2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) + if (NULL == (ipoints2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) TEST_ERROR; - if(NULL == (ipoints2 = (int **)HDcalloc(DIM0, sizeof(ipoints2_data)))) + if (NULL == (ipoints2 = (int **)HDcalloc(DIM0, sizeof(ipoints2_data)))) TEST_ERROR; for (i = 0; i < DIM0; i++) ipoints2[i] = ipoints2_data + (i * DIM1); - if(NULL == (icheck2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) + if (NULL == (icheck2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) TEST_ERROR; - if(NULL == (icheck2 = (int **)HDcalloc(DIM0, sizeof(icheck2_data)))) + if (NULL == (icheck2 = (int **)HDcalloc(DIM0, sizeof(icheck2_data)))) TEST_ERROR; for (i = 0; i < DIM0; i++) icheck2[i] = icheck2_data + (i * DIM1); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR ; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* Test error stack */ /* Push an error onto error stack */ - H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADVALUE, - "Error test failed"); + H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADVALUE, "Error test failed"); /* Print out the errors on stack */ dump_error(); @@ -510,15 +495,16 @@ main(void) H5Eclear1(); /* Test error API */ - if(test_error1() < 0) TEST_ERROR ; + if (test_error1() < 0) + TEST_ERROR; - if(test_error2(file) < 0) { - H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADMESG, - "Error test failed"); + if (test_error2(file) < 0) { + H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADMESG, "Error test failed"); H5Eprint1(stderr); } - if(H5Fclose(file) < 0) TEST_ERROR ; + if (H5Fclose(file) < 0) + TEST_ERROR; h5_clean_files(FILENAME, fapl); HDfree(ipoints2); @@ -539,4 +525,3 @@ error: return 1; } #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/test/error_test.c b/test/error_test.c index 7c6cf9f..a476e9a 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -21,68 +21,64 @@ #include "H5srcdir.h" #ifdef H5_USE_16_API -int main(void) +int +main(void) { HDfprintf(stderr, "Test skipped because backward compatibility with v1.6 is configured in\n"); return 0; } #else /* H5_USE_16_API */ -const char *FILENAME[] = { - "errors", - NULL -}; +const char *FILENAME[] = {"errors", NULL}; #define DATAFILE "filter_error" -#define DIM0 100 -#define DIM1 200 - -int **ipoints2 = NULL; -int **icheck2 = NULL; -int *ipoints2_data = NULL; -int *icheck2_data = NULL; +#define DIM0 100 +#define DIM1 200 -hid_t ERR_CLS; -hid_t ERR_CLS2; -hid_t ERR_STACK; +int **ipoints2 = NULL; +int **icheck2 = NULL; +int * ipoints2_data = NULL; +int * icheck2_data = NULL; -hid_t ERR_MAJ_TEST; -hid_t ERR_MAJ_IO; -hid_t ERR_MAJ_API; +hid_t ERR_CLS; +hid_t ERR_CLS2; +hid_t ERR_STACK; -hid_t ERR_MIN_SUBROUTINE; -hid_t ERR_MIN_ERRSTACK; -hid_t ERR_MIN_CREATE; -hid_t ERR_MIN_WRITE; -hid_t ERR_MIN_GETNUM; +hid_t ERR_MAJ_TEST; +hid_t ERR_MAJ_IO; +hid_t ERR_MAJ_API; -#define DSET_NAME "a_dataset" -#define FAKE_ID (hid_t)0 +hid_t ERR_MIN_SUBROUTINE; +hid_t ERR_MIN_ERRSTACK; +hid_t ERR_MIN_CREATE; +hid_t ERR_MIN_WRITE; +hid_t ERR_MIN_GETNUM; -#define ERR_CLS_NAME "Error Test" -#define ERR_CLS2_NAME "Second Test" -#define PROG_NAME "Error Program" -#define PROG2_NAME "Second Program" -#define PROG_VERS "1.0" +#define DSET_NAME "a_dataset" +#define FAKE_ID (hid_t)0 -#define ERR_MAJ_TEST_MSG "Error in test" -#define ERR_MAJ_IO_MSG "Error in IO" -#define ERR_MAJ_API_MSG "Error in API" -#define ERR_MIN_SUBROUTINE_MSG "Error in subroutine" -#define ERR_MIN_ERRSTACK_MSG "Error in error stack" -#define ERR_MIN_CREATE_MSG "Error in H5Dcreate2" -#define ERR_MIN_WRITE_MSG "Error in H5Dwrite" -#define ERR_MIN_GETNUM_MSG "Error in H5Eget_num" +#define ERR_CLS_NAME "Error Test" +#define ERR_CLS2_NAME "Second Test" +#define PROG_NAME "Error Program" +#define PROG2_NAME "Second Program" +#define PROG_VERS "1.0" -#define MSG_SIZE 64 -#define LONG_DESC_SIZE 8192 +#define ERR_MAJ_TEST_MSG "Error in test" +#define ERR_MAJ_IO_MSG "Error in IO" +#define ERR_MAJ_API_MSG "Error in API" +#define ERR_MIN_SUBROUTINE_MSG "Error in subroutine" +#define ERR_MIN_ERRSTACK_MSG "Error in error stack" +#define ERR_MIN_CREATE_MSG "Error in H5Dcreate2" +#define ERR_MIN_WRITE_MSG "Error in H5Dwrite" +#define ERR_MIN_GETNUM_MSG "Error in H5Eget_num" -#define DSET_FILTER_NAME "dataset_with_filter" +#define MSG_SIZE 64 +#define LONG_DESC_SIZE 8192 -static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, - void *client_data); +#define DSET_FILTER_NAME "dataset_with_filter" +static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data); /*------------------------------------------------------------------------- * Function: test_error @@ -97,13 +93,13 @@ static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, static herr_t test_error(hid_t file) { - hid_t dataset = -1; - hid_t space = -1; + hid_t dataset = -1; + hid_t space = -1; hid_t estack_id = -1; - hsize_t dims[2]; - const char *FUNC_test_error = "test_error"; - H5E_auto2_t old_func; - void *old_data = NULL; + hsize_t dims[2]; + const char *FUNC_test_error = "test_error"; + H5E_auto2_t old_func; + void * old_data = NULL; HDfprintf(stderr, "\nTesting error API based on data I/O\n"); @@ -114,12 +110,15 @@ test_error(hid_t file) TEST_ERROR; /* Test H5E_BEGIN_TRY */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* Create the dataset */ - if ((dataset = H5Dcreate2(file, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((dataset = H5Dcreate2(file, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) { H5Epush(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_CREATE, "H5Dcreate2 failed"); goto error; @@ -133,7 +132,7 @@ test_error(hid_t file) #ifdef H5_USE_16_API if (old_func != (H5E_auto_t)H5Eprint) TEST_ERROR; -#else /* H5_USE_16_API */ +#else /* H5_USE_16_API */ if (old_func != (H5E_auto2_t)H5Eprint2) TEST_ERROR; #endif /* H5_USE_16_API */ @@ -163,16 +162,15 @@ test_error(hid_t file) } /* In case program comes to this point, close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; TEST_ERROR; - error: +error: return -1; } /* end test_error() */ - /*------------------------------------------------------------------------- * Function: init_error * @@ -186,10 +184,10 @@ test_error(hid_t file) static herr_t init_error(void) { - ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME) + 1; - ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1; - char *cls_name = NULL; - char *msg = NULL; + ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME) + 1; + ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1; + char * cls_name = NULL; + char * msg = NULL; H5E_type_t msg_type; if (NULL == (cls_name = (char *)HDmalloc(HDstrlen(ERR_CLS_NAME) + 1))) @@ -248,7 +246,6 @@ error: return -1; } /* end init_error() */ - /*------------------------------------------------------------------------- * Function: error_stack * @@ -262,8 +259,8 @@ error: static herr_t error_stack(void) { - ssize_t err_num; - const char *FUNC_error_stack = "error_stack"; + ssize_t err_num; + const char *FUNC_error_stack = "error_stack"; if ((err_num = H5Eget_num(H5E_DEFAULT)) < 0) TEST_ERROR; @@ -290,7 +287,6 @@ error: return -1; } /* end error_stack() */ - /*------------------------------------------------------------------------- * Function: long_desc_cb * @@ -304,7 +300,7 @@ error: static herr_t long_desc_cb(unsigned H5_ATTR_UNUSED n, const H5E_error2_t *err_desc, void *client_data) { - char *real_desc = (char *)client_data; + char *real_desc = (char *)client_data; if (err_desc->desc != NULL && HDstrcmp(err_desc->desc, real_desc) == 0) return 0; @@ -312,7 +308,6 @@ long_desc_cb(unsigned H5_ATTR_UNUSED n, const H5E_error2_t *err_desc, void *clie return -1; } /* end long_desc_cb() */ - /*------------------------------------------------------------------------- * Function: test_long_desc * @@ -329,15 +324,15 @@ long_desc_cb(unsigned H5_ATTR_UNUSED n, const H5E_error2_t *err_desc, void *clie * 'full_desc' in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static herr_t test_long_desc(void) { - const char *format = "Testing very long description string, %s"; - char *long_desc = NULL; - char *full_desc = NULL; - size_t u; - const char *test_FUNC = "test_long_desc"; + const char *format = "Testing very long description string, %s"; + char * long_desc = NULL; + char * full_desc = NULL; + size_t u; + const char *test_FUNC = "test_long_desc"; /* Allocate space for the error description info */ if (NULL == (long_desc = (char *)HDmalloc(LONG_DESC_SIZE))) @@ -355,7 +350,8 @@ test_long_desc(void) TEST_ERROR; /* Push an error with a long description */ - if (H5Epush(H5E_DEFAULT, __FILE__, test_FUNC, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, format, long_desc) < 0) + if (H5Epush(H5E_DEFAULT, __FILE__, test_FUNC, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, format, + long_desc) < 0) TEST_ERROR; /* Create the string that should be in the description. Must use HDsnprintf here @@ -384,8 +380,7 @@ error: return -1; } /* end test_long_desc() */ -H5_GCC_DIAG_ON(format-nonliteral) - +H5_GCC_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- * Function: dump_error @@ -416,7 +411,6 @@ error: return -1; } /* end dump_error() */ - /*------------------------------------------------------------------------- * Function: custom_print_cb * @@ -428,13 +422,13 @@ error: *------------------------------------------------------------------------- */ static herr_t -custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void* client_data) +custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) { - FILE *stream = (FILE *)client_data; - char maj[MSG_SIZE]; - char min[MSG_SIZE]; - char cls[MSG_SIZE]; - const int indent = 4; + FILE * stream = (FILE *)client_data; + char maj[MSG_SIZE]; + char min[MSG_SIZE]; + char cls[MSG_SIZE]; + const int indent = 4; /* Get descriptions for the major and minor error numbers */ if (H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE) < 0) @@ -446,9 +440,8 @@ custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void* client_data) if (H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE) < 0) TEST_ERROR; - HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", - indent, "", n, err_desc->file_name, - err_desc->func_name, err_desc->line); + HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", indent, "", n, err_desc->file_name, + err_desc->func_name, err_desc->line); HDfprintf(stream, "%*sclass: %s\n", indent * 2, "", cls); HDfprintf(stream, "%*smajor: %s\n", indent * 2, "", maj); HDfprintf(stream, "%*sminor: %s\n", indent * 2, "", min); @@ -459,7 +452,6 @@ error: return -1; } /* end custom_print_cb() */ - /*------------------------------------------------------------------------- * Function: test_create * @@ -473,10 +465,10 @@ error: static herr_t test_create(void) { - const char *err_func = "test_create"; /* Function name for pushing error */ - const char *err_msg = "Error message"; /* Error message for pushing error */ - ssize_t err_num; /* Number of errors on stack */ - hid_t estack_id = -1; /* Error stack ID */ + const char *err_func = "test_create"; /* Function name for pushing error */ + const char *err_msg = "Error message"; /* Error message for pushing error */ + ssize_t err_num; /* Number of errors on stack */ + hid_t estack_id = -1; /* Error stack ID */ /* Create an empty error stack */ if ((estack_id = H5Ecreate_stack()) < 0) @@ -488,7 +480,8 @@ test_create(void) TEST_ERROR /* Push an error with a long description */ - if (H5Epush(estack_id, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", err_msg) < 0) + if (H5Epush(estack_id, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", + err_msg) < 0) TEST_ERROR; /* Check the number of errors on stack */ @@ -506,7 +499,7 @@ test_create(void) TEST_ERROR /* Close error stack */ - if(H5Eclose_stack(estack_id) < 0) + if (H5Eclose_stack(estack_id) < 0) TEST_ERROR return 0; @@ -518,7 +511,7 @@ error: /*------------------------------------------------------------------------- * Function: test_copy * - * Purpose: Test copyinging an error stack + * Purpose: Test copying an error stack * * Return: Success: 0 * Failure: -1 @@ -528,14 +521,15 @@ error: static herr_t test_copy(void) { - const char *err_func = "test_copy"; /* Function name for pushing error */ - const char *err_msg = "Error message"; /* Error message for pushing error */ - ssize_t err_num; /* Number of errors on stack */ - hid_t estack_id = -1; /* Error stack ID */ - herr_t ret; /* Generic return value */ + const char *err_func = "test_copy"; /* Function name for pushing error */ + const char *err_msg = "Error message"; /* Error message for pushing error */ + ssize_t err_num; /* Number of errors on stack */ + hid_t estack_id = -1; /* Error stack ID */ + herr_t ret; /* Generic return value */ /* Push an error with a long description */ - if (H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", err_msg) < 0) + if (H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", + err_msg) < 0) TEST_ERROR; /* Check the number of errors on stack */ @@ -569,9 +563,11 @@ test_copy(void) /* Try to close error stack copy. Should fail because * the current H5Eset_current_stack closes the stack to be set. */ - H5E_BEGIN_TRY { - ret = H5Eclose_stack(estack_id); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Eclose_stack(estack_id); + } + H5E_END_TRY if (ret >= 0) TEST_ERROR @@ -581,7 +577,6 @@ error: return -1; } /* end test_copy() */ - /*------------------------------------------------------------------------- * Function: close_error * @@ -617,7 +612,6 @@ error: return -1; } /* end close_error() */ - /*------------------------------------------------------------------------- * Function: test_filter_error * @@ -635,8 +629,8 @@ static herr_t test_filter_error(const char *fname) { const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */ - hid_t file = -1; - hid_t dataset = -1; + hid_t file = -1; + hid_t dataset = -1; int buf[20]; HDfprintf(stderr, "\nTesting error message during data reading when filter isn't registered\n"); @@ -665,7 +659,6 @@ error: return -1; } /* end test_filter_error() */ - /*------------------------------------------------------------------------- * Function: main * @@ -676,11 +669,11 @@ error: int main(void) { - hid_t file = -1; - hid_t fapl = -1; + hid_t file = -1; + hid_t fapl = -1; hid_t estack_id = -1; char filename[1024]; - const char *FUNC_main = "main"; + const char *FUNC_main = "main"; int i; HDfprintf(stderr, " This program tests the Error API. There're supposed to be some error messages\n"); @@ -693,16 +686,16 @@ main(void) TEST_ERROR; /* Set up data arrays */ - if(NULL == (ipoints2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) + if (NULL == (ipoints2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) TEST_ERROR; - if(NULL == (ipoints2 = (int **)HDcalloc(DIM0, sizeof(ipoints2_data)))) + if (NULL == (ipoints2 = (int **)HDcalloc(DIM0, sizeof(ipoints2_data)))) TEST_ERROR; for (i = 0; i < DIM0; i++) ipoints2[i] = ipoints2_data + (i * DIM1); - if(NULL == (icheck2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) + if (NULL == (icheck2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) TEST_ERROR; - if(NULL == (icheck2 = (int **)HDcalloc(DIM0, sizeof(icheck2_data)))) + if (NULL == (icheck2 = (int **)HDcalloc(DIM0, sizeof(icheck2_data)))) TEST_ERROR; for (i = 0; i < DIM0; i++) icheck2[i] = icheck2_data + (i * DIM1); @@ -715,7 +708,7 @@ main(void) if (error_stack() < 0) { /* Push an error onto error stack */ if (H5Epush(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_ERRSTACK, - "Error stack test failed") < 0) + "Error stack test failed") < 0) TEST_ERROR; /* Delete an error from the top of error stack */ @@ -791,4 +784,3 @@ error: return 1; } #endif /* H5_USE_16_API */ - diff --git a/test/evict_on_close.c b/test/evict_on_close.c index 9f6607a..57847bb 100644 --- a/test/evict_on_close.c +++ b/test/evict_on_close.c @@ -16,23 +16,22 @@ * are located in cache.c. */ -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ #define H5D_TESTING -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#define H5I_FRIEND /*suppress error about including H5Ipkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5I_FRIEND /*suppress error about including H5Ipkg */ #define H5I_TESTING - #include "h5test.h" #include "H5Cpkg.h" #include "H5Dpkg.h" #include "H5Fpkg.h" #include "H5Gpkg.h" #include "H5Ipkg.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Evict on close is not supported under parallel at this time. * In the meantime, we just run a simple check that EoC can't be @@ -44,42 +43,39 @@ /* (Requires debug build of the library) */ /* #define EOC_MANUAL_INSPECTION */ -const char *FILENAMES[] = { - "evict-on-close", /* 0 */ - NULL -}; -#define FILENAME_BUF_SIZE 1024 +const char *FILENAMES[] = {"evict-on-close", /* 0 */ + NULL}; +#define FILENAME_BUF_SIZE 1024 /* Group names */ -#define GROUP_OLD_STYLE_NAME "old_style_groups" -#define GROUP_NEW_STYLE_NAME "new_style_groups" +#define GROUP_OLD_STYLE_NAME "old_style_groups" +#define GROUP_NEW_STYLE_NAME "new_style_groups" /* Dataset names */ -#define DSET_COMPACT_NAME "compact" -#define DSET_CONTIGUOUS_NAME "contiguous" -#define DSET_BTREE_NAME "v1_btree" -#define DSET_EARRAY_NAME "earray" -#define DSET_BT2_NAME "v2_btree" -#define DSET_FARRAY_NAME "farray" -#define DSET_SINGLE_NAME "single" +#define DSET_COMPACT_NAME "compact" +#define DSET_CONTIGUOUS_NAME "contiguous" +#define DSET_BTREE_NAME "v1_btree" +#define DSET_EARRAY_NAME "earray" +#define DSET_BT2_NAME "v2_btree" +#define DSET_FARRAY_NAME "farray" +#define DSET_SINGLE_NAME "single" /* Number of data elements in a dataset */ -#define NELEMENTS 1024 +#define NELEMENTS 1024 /* Number of subgroups in each style of group */ -#define NSUBGROUPS 128 +#define NSUBGROUPS 128 /* Max size of subgroup name, not including NULL */ -#define SUBGROUP_NAME_SIZE 16 +#define SUBGROUP_NAME_SIZE 16 /* Prototypes */ static hbool_t verify_tag_not_in_cache(const H5F_t *f, haddr_t tag); -static herr_t check_evict_on_close_api(void); -static hid_t generate_eoc_test_file(hid_t fapl_id); -static herr_t check_dset_scheme(hid_t fid, const char *dset_name); -static herr_t check_group_layout(hid_t fid, const char *group_name); +static herr_t check_evict_on_close_api(void); +static hid_t generate_eoc_test_file(hid_t fapl_id); +static herr_t check_dset_scheme(hid_t fid, const char *dset_name); +static herr_t check_group_layout(hid_t fid, const char *group_name); - /*------------------------------------------------------------------------- * Function: verify_tag_not_in_cache() * @@ -93,18 +89,18 @@ static herr_t check_group_layout(hid_t fid, const char *group_name); static H5_ATTR_PURE hbool_t verify_tag_not_in_cache(const H5F_t *f, haddr_t tag) { - H5C_t *cache_ptr = NULL; /* cache pointer */ - int i = 0; /* iterator */ + H5C_t *cache_ptr = NULL; /* cache pointer */ + int i = 0; /* iterator */ /* Get Internal Cache Pointers */ cache_ptr = f->shared->cache; - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) { - H5C_cache_entry_t *entry_ptr; /* entry pointer */ + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { + H5C_cache_entry_t *entry_ptr; /* entry pointer */ entry_ptr = cache_ptr->index[i]; - while(entry_ptr != NULL) { - if(tag == entry_ptr->tag_info->tag) + while (entry_ptr != NULL) { + if (tag == entry_ptr->tag_info->tag) return TRUE; else entry_ptr = entry_ptr->ht_next; @@ -114,7 +110,6 @@ verify_tag_not_in_cache(const H5F_t *f, haddr_t tag) return FALSE; } /* end verify_tag_not_in_cache() */ - /*------------------------------------------------------------------------- * Function: generate_eoc_test_file() * @@ -128,22 +123,22 @@ verify_tag_not_in_cache(const H5F_t *f, haddr_t tag) static hid_t generate_eoc_test_file(hid_t fapl_id) { - char filename[FILENAME_BUF_SIZE]; /* decorated file name */ - hid_t fid = -1; /* file ID (returned) */ - hid_t fapl_copy_id = -1; /* ID of copied fapl */ - hid_t gid1 = -1, gid2 = -1; /* group IDs */ - hid_t sid = -1; /* dataspace ID */ - hid_t dcpl_id = -1; /* dataset creation plist */ - hid_t did = -1; /* dataset ID */ - int rank; /* # of array dimensions */ - hsize_t current_dims[2]; /* current dataset size */ - hsize_t maximum_dims[2]; /* maximum dataset size */ - hsize_t chunk_dims[2]; /* chunk dimensions */ - H5D_chunk_index_t idx_type; /* dataset chunk index type */ - H5D_layout_t layout_type; /* dataset layout type */ - int *data = NULL; /* buffer for fake data */ - int n; /* # of data elements */ - int i; /* iterator (# subgroups) */ + char filename[FILENAME_BUF_SIZE]; /* decorated file name */ + hid_t fid = -1; /* file ID (returned) */ + hid_t fapl_copy_id = -1; /* ID of copied fapl */ + hid_t gid1 = -1, gid2 = -1; /* group IDs */ + hid_t sid = -1; /* dataspace ID */ + hid_t dcpl_id = -1; /* dataset creation plist */ + hid_t did = -1; /* dataset ID */ + int rank; /* # of array dimensions */ + hsize_t current_dims[2]; /* current dataset size */ + hsize_t maximum_dims[2]; /* maximum dataset size */ + hsize_t chunk_dims[2]; /* chunk dimensions */ + H5D_chunk_index_t idx_type; /* dataset chunk index type */ + H5D_layout_t layout_type; /* dataset layout type */ + int * data = NULL; /* buffer for fake data */ + int n; /* # of data elements */ + int i; /* iterator (# subgroups) */ TESTING("generating evict-on-close test file"); @@ -151,20 +146,19 @@ generate_eoc_test_file(hid_t fapl_id) h5_fixname(FILENAMES[0], fapl_id, filename, sizeof(filename)); /* Copy the fapl and set the latest file format */ - if((fapl_copy_id = H5Pcopy(fapl_id)) < 0) + if ((fapl_copy_id = H5Pcopy(fapl_id)) < 0) TEST_ERROR; - if(H5Pset_libver_bounds(fapl_copy_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl_copy_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; /* Create a data buffer for dataset writes */ - if(NULL == (data = (int *)HDcalloc(NELEMENTS, sizeof(int)))) + if (NULL == (data = (int *)HDcalloc(NELEMENTS, sizeof(int)))) TEST_ERROR; /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; - /*******************************************/ /* CREATE OBJECTS WITH THE OLD FILE FORMAT */ /*******************************************/ @@ -182,25 +176,25 @@ generate_eoc_test_file(hid_t fapl_id) * ensure that the file data structures for groups include * multiple cache entries. */ - if((gid1 = H5Gcreate2(fid, GROUP_OLD_STYLE_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid1 = H5Gcreate2(fid, GROUP_OLD_STYLE_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create sub-groups */ - for(i = 0; i < NSUBGROUPS; i++) { + for (i = 0; i < NSUBGROUPS; i++) { char subgroup_name[SUBGROUP_NAME_SIZE]; /* Create the group name */ HDmemset(subgroup_name, '\0', SUBGROUP_NAME_SIZE); - if(HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0) + if (HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(gid1, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(gid1, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR; } - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) TEST_ERROR; /********************************************************************/ @@ -216,53 +210,52 @@ generate_eoc_test_file(hid_t fapl_id) /********************/ /* Create dataspace */ - n = NELEMENTS; - rank = 1; + n = NELEMENTS; + rank = 1; current_dims[0] = (hsize_t)n; maximum_dims[0] = H5S_UNLIMITED; - if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) + if ((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) TEST_ERROR; /* Create dcpl and set up chunking */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; chunk_dims[0] = 1; - if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) TEST_ERROR; /* Create dataset */ - if((did = H5Dcreate2(fid, DSET_BTREE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_BTREE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR; /* Ensure we're using the correct chunk indexing scheme */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) + if (H5D__layout_idx_type_test(did, &idx_type) < 0) TEST_ERROR; - if(idx_type != H5D_CHUNK_IDX_BTREE) + if (idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using version 1 B-tree as the chunk index"); /* Write a bunch of fake data */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; /* Close IDs for this dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) TEST_ERROR; - /**********************************************/ /* CREATE OBJECTS WITH THE LATEST FILE FORMAT */ /**********************************************/ /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; /* Reopen the file with the "latest file format" fapl */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_copy_id)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_copy_id)) < 0) TEST_ERROR; /*******************/ @@ -278,25 +271,25 @@ generate_eoc_test_file(hid_t fapl_id) * ensure that the file data structures for groups include * multiple cache entries. */ - if((gid1 = H5Gcreate2(fid, GROUP_NEW_STYLE_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid1 = H5Gcreate2(fid, GROUP_NEW_STYLE_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create sub-groups */ - for(i = 0; i < NSUBGROUPS; i++) { + for (i = 0; i < NSUBGROUPS; i++) { char subgroup_name[SUBGROUP_NAME_SIZE]; /* Create the group name */ HDmemset(subgroup_name, '\0', SUBGROUP_NAME_SIZE); - if(HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0) + if (HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(gid1, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(gid1, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR; } - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) TEST_ERROR; /********************************************************************/ @@ -308,40 +301,40 @@ generate_eoc_test_file(hid_t fapl_id) /********************/ /* Create dataspace */ - n = NELEMENTS; - rank = 1; + n = NELEMENTS; + rank = 1; current_dims[0] = (hsize_t)n; maximum_dims[0] = H5S_UNLIMITED; - if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) + if ((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) TEST_ERROR; /* Create dcpl and set up chunking */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; chunk_dims[0] = 1; - if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) TEST_ERROR; /* Create dataset */ - if((did = H5Dcreate2(fid, DSET_EARRAY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_EARRAY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR; /* Ensure we're using the correct chunk indexing scheme */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) + if (H5D__layout_idx_type_test(did, &idx_type) < 0) TEST_ERROR; - if(idx_type != H5D_CHUNK_IDX_EARRAY) + if (idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as the chunk index"); /* Write a bunch of fake data */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; /* Close IDs for this dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) TEST_ERROR; /********************/ @@ -349,43 +342,43 @@ generate_eoc_test_file(hid_t fapl_id) /********************/ /* Create dataspace */ - n = NELEMENTS; - rank = 2; + n = NELEMENTS; + rank = 2; current_dims[0] = (hsize_t)2; - current_dims[1] = (hsize_t)(n/2); + current_dims[1] = (hsize_t)(n / 2); maximum_dims[0] = H5S_UNLIMITED; maximum_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) + if ((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) TEST_ERROR; /* Create dcpl and set up chunking */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; chunk_dims[0] = 1; chunk_dims[1] = 1; - if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) TEST_ERROR; /* Create dataset */ - if((did = H5Dcreate2(fid, DSET_BT2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_BT2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR; /* Ensure we're using the correct chunk indexing scheme */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) + if (H5D__layout_idx_type_test(did, &idx_type) < 0) TEST_ERROR; - if(idx_type != H5D_CHUNK_IDX_BT2) + if (idx_type != H5D_CHUNK_IDX_BT2) FAIL_PUTS_ERROR("should be using version 2 B-tree as the chunk index"); /* Write a bunch of fake data */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; /* Close IDs for this dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) TEST_ERROR; /***************/ @@ -393,41 +386,41 @@ generate_eoc_test_file(hid_t fapl_id) /***************/ /* Create dataspace */ - n = NELEMENTS; - rank = 1; + n = NELEMENTS; + rank = 1; current_dims[0] = (hsize_t)n; maximum_dims[0] = (hsize_t)n; - if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) + if ((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) TEST_ERROR; /* Create dcpl and set up chunking */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; chunk_dims[0] = 1; chunk_dims[1] = 1; - if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) TEST_ERROR; /* Create dataset */ - if((did = H5Dcreate2(fid, DSET_FARRAY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_FARRAY_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR; /* Ensure we're using the correct chunk indexing scheme */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) + if (H5D__layout_idx_type_test(did, &idx_type) < 0) TEST_ERROR; - if(idx_type != H5D_CHUNK_IDX_FARRAY) + if (idx_type != H5D_CHUNK_IDX_FARRAY) FAIL_PUTS_ERROR("should be using fixed array as the chunk index"); /* Write a bunch of fake data */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; /* Close IDs for this dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) TEST_ERROR; /****************/ @@ -435,41 +428,41 @@ generate_eoc_test_file(hid_t fapl_id) /****************/ /* Create dataspace */ - n = NELEMENTS; - rank = 1; + n = NELEMENTS; + rank = 1; current_dims[0] = (hsize_t)n; maximum_dims[0] = (hsize_t)n; - if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) + if ((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) TEST_ERROR; /* Create dcpl and set up chunking */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; chunk_dims[0] = (hsize_t)n; chunk_dims[1] = (hsize_t)n; - if(H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, rank, chunk_dims) < 0) TEST_ERROR; /* Create dataset */ - if((did = H5Dcreate2(fid, DSET_SINGLE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_SINGLE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR; /* Ensure we're using the correct chunk indexing scheme */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) + if (H5D__layout_idx_type_test(did, &idx_type) < 0) TEST_ERROR; - if(idx_type != H5D_CHUNK_IDX_SINGLE) + if (idx_type != H5D_CHUNK_IDX_SINGLE) FAIL_PUTS_ERROR("should be using single chunk as the chunk index"); /* Write a bunch of fake data */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; /* Close IDs for this dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) TEST_ERROR; /**************/ @@ -477,31 +470,32 @@ generate_eoc_test_file(hid_t fapl_id) /**************/ /* Create dataspace */ - n = NELEMENTS; - rank = 1; + n = NELEMENTS; + rank = 1; current_dims[0] = (hsize_t)n; maximum_dims[0] = (hsize_t)n; - if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) + if ((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) TEST_ERROR; /* Create dataset */ - if((did = H5Dcreate2(fid, DSET_CONTIGUOUS_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_CONTIGUOUS_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; /* Ensure we're using the correct layout scheme */ - if(H5D__layout_type_test(did, &layout_type) < 0) + if (H5D__layout_type_test(did, &layout_type) < 0) TEST_ERROR; - if(layout_type != H5D_CONTIGUOUS) + if (layout_type != H5D_CONTIGUOUS) FAIL_PUTS_ERROR("should be using contiguous layout"); /* Write a bunch of fake data */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; /* Close IDs for this dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; /***********/ @@ -509,39 +503,40 @@ generate_eoc_test_file(hid_t fapl_id) /***********/ /* Create dataspace */ - n = 1; - rank = 1; + n = 1; + rank = 1; current_dims[0] = (hsize_t)n; maximum_dims[0] = (hsize_t)n; - if((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) + if ((sid = H5Screate_simple(rank, current_dims, maximum_dims)) < 0) TEST_ERROR; /* Create dcpl and set up compact layout */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if(H5Pset_layout(dcpl_id, H5D_COMPACT) < 0) + if (H5Pset_layout(dcpl_id, H5D_COMPACT) < 0) TEST_ERROR; /* Create dataset */ - if((did = H5Dcreate2(fid, DSET_COMPACT_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_COMPACT_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < + 0) TEST_ERROR; /* Ensure we're using the correct layout scheme */ - if(H5D__layout_type_test(did, &layout_type) < 0) + if (H5D__layout_type_test(did, &layout_type) < 0) TEST_ERROR; - if(layout_type != H5D_COMPACT) + if (layout_type != H5D_COMPACT) FAIL_PUTS_ERROR("should be using compact layout"); /* Write a bunch of fake data */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; /* Close IDs for this dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) TEST_ERROR; /********/ @@ -549,7 +544,7 @@ generate_eoc_test_file(hid_t fapl_id) /********/ /* Close/free everything else */ - if(H5Pclose(fapl_copy_id) < 0) + if (H5Pclose(fapl_copy_id) < 0) TEST_ERROR; HDfree(data); @@ -558,7 +553,8 @@ generate_eoc_test_file(hid_t fapl_id) return fid; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid1); H5Gclose(gid2); H5Fclose(fid); @@ -566,7 +562,8 @@ error: H5Sclose(sid); H5Pclose(dcpl_id); H5Pclose(fapl_copy_id); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(data); @@ -575,7 +572,6 @@ error: } /* end generate_eoc_test_file() */ - /*------------------------------------------------------------------------- * Function: check_group_layout() * @@ -589,17 +585,17 @@ error: static herr_t check_group_layout(hid_t fid, const char *group_name) { - H5F_t *file_ptr = NULL; /* ptr to internal file struct */ - hid_t gid1 = -1, gid2 = -1; /* group IDs */ - H5G_t *grp_ptr = NULL; /* ptr to internal group struct */ - haddr_t tag1, tag2; /* MD cache tags for groups */ - uint32_t before, during, after; /* cache sizes */ - int i; /* iterator */ + H5F_t * file_ptr = NULL; /* ptr to internal file struct */ + hid_t gid1 = -1, gid2 = -1; /* group IDs */ + H5G_t * grp_ptr = NULL; /* ptr to internal group struct */ + haddr_t tag1, tag2; /* MD cache tags for groups */ + uint32_t before, during, after; /* cache sizes */ + int i; /* iterator */ /* NOTE: The TESTING() macro is called in main() */ /* Get a pointer to the file struct */ - if(NULL == (file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) + if (NULL == (file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) TEST_ERROR; /* Record the number of cache entries */ @@ -607,39 +603,38 @@ check_group_layout(hid_t fid, const char *group_name) #ifdef EOC_MANUAL_INSPECTION HDprintf("\nCACHE BEFORE GROUP OPEN:\n"); - if(H5AC_dump_cache(file_ptr) < 0) + if (H5AC_dump_cache(file_ptr) < 0) TEST_ERROR; HDprintf("NUMBER OF CACHE ENTRIES: %u\n", before); #endif /* Open the main group and get its tag */ - if((gid1 = H5Gopen2(fid, group_name, H5P_DEFAULT)) < 0) + if ((gid1 = H5Gopen2(fid, group_name, H5P_DEFAULT)) < 0) TEST_ERROR; - if(NULL == (grp_ptr = (H5G_t *)H5VL_object_verify(gid1, H5I_GROUP))) + if (NULL == (grp_ptr = (H5G_t *)H5VL_object_verify(gid1, H5I_GROUP))) TEST_ERROR; tag1 = grp_ptr->oloc.addr; - /* Open and close all sub-groups */ - for(i = 0; i < NSUBGROUPS; i++) { + for (i = 0; i < NSUBGROUPS; i++) { char subgroup_name[SUBGROUP_NAME_SIZE]; /* Create the group name */ HDmemset(subgroup_name, '\0', SUBGROUP_NAME_SIZE); - if(HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0) + if (HDsnprintf(subgroup_name, (size_t)(SUBGROUP_NAME_SIZE - 1), "%d", i) < 0) TEST_ERROR - if((gid2 = H5Gopen2(gid1, subgroup_name, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gopen2(gid1, subgroup_name, H5P_DEFAULT)) < 0) TEST_ERROR; - if(NULL == (grp_ptr = (H5G_t *)H5VL_object_verify(gid2, H5I_GROUP))) + if (NULL == (grp_ptr = (H5G_t *)H5VL_object_verify(gid2, H5I_GROUP))) TEST_ERROR; tag2 = grp_ptr->oloc.addr; - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR; - if(TRUE == verify_tag_not_in_cache(file_ptr, tag2)) + if (TRUE == verify_tag_not_in_cache(file_ptr, tag2)) TEST_ERROR; } /* end for */ @@ -648,14 +643,14 @@ check_group_layout(hid_t fid, const char *group_name) #ifdef EOC_MANUAL_INSPECTION HDprintf("\nCACHE AFTER OPENING GROUPS (WHILE OPEN):\n"); - if(H5AC_dump_cache(file_ptr) < 0) + if (H5AC_dump_cache(file_ptr) < 0) TEST_ERROR; HDprintf("MAIN GROUP TAG: %#X\n", tag1); HDprintf("NUMBER OF CACHE ENTRIES: %u\n", during); #endif /* Close the main group */ - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) TEST_ERROR; /* Record the number of cache entries */ @@ -663,33 +658,34 @@ check_group_layout(hid_t fid, const char *group_name) #ifdef EOC_MANUAL_INSPECTION HDprintf("\nCACHE AFTER CLOSING GROUPS:\n"); - if(H5AC_dump_cache(file_ptr) < 0) + if (H5AC_dump_cache(file_ptr) < 0) TEST_ERROR; HDprintf("NUMBER OF CACHE ENTRIES: %u\n", after); #endif /* Ensure that the cache does not contain entries with the tag */ - if(TRUE == verify_tag_not_in_cache(file_ptr, tag1)) + if (TRUE == verify_tag_not_in_cache(file_ptr, tag1)) TEST_ERROR; /* Compare the number of cache entries */ - if(before != after || before == during) + if (before != after || before == during) TEST_ERROR; PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid1); H5Gclose(gid2); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } /* end check_group_layout() */ - /*------------------------------------------------------------------------- * Function: check_dset_scheme() * @@ -703,21 +699,21 @@ error: static herr_t check_dset_scheme(hid_t fid, const char *dset_name) { - H5F_t *file_ptr = NULL; /* ptr to internal file struct */ - hid_t did = -1; /* dataset ID */ - H5D_t *dset_ptr = NULL; /* ptr to internal dset struct */ - haddr_t tag; /* MD cache tag for dataset */ - int *data = NULL; /* buffer for fake data */ - uint32_t before, during, after; /* cache sizes */ + H5F_t * file_ptr = NULL; /* ptr to internal file struct */ + hid_t did = -1; /* dataset ID */ + H5D_t * dset_ptr = NULL; /* ptr to internal dset struct */ + haddr_t tag; /* MD cache tag for dataset */ + int * data = NULL; /* buffer for fake data */ + uint32_t before, during, after; /* cache sizes */ /* NOTE: The TESTING() macro is called in main() */ /* Get a pointer to the file struct */ - if(NULL == (file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) + if (NULL == (file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) TEST_ERROR; /* Create the data buffer */ - if(NULL == (data = (int *)HDcalloc(NELEMENTS, sizeof(int)))) + if (NULL == (data = (int *)HDcalloc(NELEMENTS, sizeof(int)))) TEST_ERROR; /* Record the number of cache entries */ @@ -725,22 +721,22 @@ check_dset_scheme(hid_t fid, const char *dset_name) #ifdef EOC_MANUAL_INSPECTION HDprintf("\nCACHE BEFORE DATASET OPEN:\n"); - if(H5AC_dump_cache(file_ptr) < 0) + if (H5AC_dump_cache(file_ptr) < 0) TEST_ERROR; HDprintf("NUMBER OF CACHE ENTRIES: %u\n", before); #endif /* Open dataset and get the metadata tag */ - if((did = H5Dopen2(fid, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dset_name, H5P_DEFAULT)) < 0) TEST_ERROR; - if(NULL == (dset_ptr = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) + if (NULL == (dset_ptr = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) TEST_ERROR; tag = dset_ptr->oloc.addr; /* Read data from the dataset so the cache gets populated with chunk entries * and the like. */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; /* Record the number of cache entries */ @@ -748,14 +744,14 @@ check_dset_scheme(hid_t fid, const char *dset_name) #ifdef EOC_MANUAL_INSPECTION HDprintf("\nCACHE AFTER DATA READ (WHILE OPEN):\n"); - if(H5AC_dump_cache(file_ptr) < 0) + if (H5AC_dump_cache(file_ptr) < 0) TEST_ERROR; HDprintf("TAG: %#X\n", tag); HDprintf("NUMBER OF CACHE ENTRIES: %u\n", during); #endif /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; /* Record the number of cache entries */ @@ -763,17 +759,17 @@ check_dset_scheme(hid_t fid, const char *dset_name) #ifdef EOC_MANUAL_INSPECTION HDprintf("\nCACHE AFTER DATASET CLOSE:\n"); - if(H5AC_dump_cache(file_ptr) < 0) + if (H5AC_dump_cache(file_ptr) < 0) TEST_ERROR; HDprintf("NUMBER OF CACHE ENTRIES: %u\n", after); #endif /* Ensure that the cache does not contain entries with the tag */ - if(TRUE == verify_tag_not_in_cache(file_ptr, tag)) + if (TRUE == verify_tag_not_in_cache(file_ptr, tag)) TEST_ERROR; /* Compare the number of cache entries */ - if(before != after || before == during) + if (before != after || before == during) TEST_ERROR; HDfree(data); @@ -782,16 +778,17 @@ check_dset_scheme(hid_t fid, const char *dset_name) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return FAIL; } /* check_dset_scheme() */ - /*------------------------------------------------------------------------- * Function: check_evict_on_close_api() * @@ -805,63 +802,67 @@ error: static herr_t check_evict_on_close_api(void) { - hid_t fapl_id = -1; - hid_t dapl_id = -1; - hbool_t evict_on_close; - herr_t status; + hid_t fapl_id = -1; + hid_t dapl_id = -1; + hbool_t evict_on_close; + herr_t status; TESTING("evict on close API"); /* Create a fapl */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Check the default */ evict_on_close = TRUE; - if(H5Pget_evict_on_close(fapl_id, &evict_on_close) < 0) + if (H5Pget_evict_on_close(fapl_id, &evict_on_close) < 0) TEST_ERROR; - if(evict_on_close != FALSE) + if (evict_on_close != FALSE) FAIL_PUTS_ERROR("Incorrect default evict on close value."); /* Set the evict on close property */ evict_on_close = TRUE; - if(H5Pset_evict_on_close(fapl_id, evict_on_close) < 0) + if (H5Pset_evict_on_close(fapl_id, evict_on_close) < 0) TEST_ERROR; /* Make sure we can get it back out */ evict_on_close = FALSE; - if(H5Pget_evict_on_close(fapl_id, &evict_on_close) < 0) + if (H5Pget_evict_on_close(fapl_id, &evict_on_close) < 0) TEST_ERROR; - if(evict_on_close != TRUE) + if (evict_on_close != TRUE) FAIL_PUTS_ERROR("Incorrect evict on close value."); /* close fapl */ - if(H5Pclose(fapl_id) < 0) + if (H5Pclose(fapl_id) < 0) TEST_ERROR; /**********************************************/ /* Trying passing in a non-fapl property list */ /**********************************************/ - if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR; /* ensure using an incorrect access plist fails */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Pset_evict_on_close(dapl_id, evict_on_close); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) FAIL_PUTS_ERROR("H5Pset_evict_on_close() accepted invalid access plist."); /* ensure an invalid plist fails */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Pget_evict_on_close(H5I_INVALID_HID, &evict_on_close); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) FAIL_PUTS_ERROR("H5Pget_evict_on_close() accepted invalid hid_t."); /* close dapl */ - if(H5Pclose(dapl_id) < 0) + if (H5Pclose(dapl_id) < 0) TEST_ERROR; PASSED(); @@ -873,7 +874,6 @@ error: } /* check_evict_on_close_api() */ - /*------------------------------------------------------------------------- * Function: main * @@ -884,9 +884,9 @@ error: int main(void) { - hid_t fapl_id = -1; /* VFD-specific fapl */ - hid_t fid = -1; /* file ID */ - unsigned nerrors = 0; /* number of test errors */ + hid_t fapl_id = -1; /* VFD-specific fapl */ + hid_t fid = -1; /* file ID */ + unsigned nerrors = 0; /* number of test errors */ HDprintf("Testing evict-on-close cache behavior\n"); @@ -897,19 +897,19 @@ main(void) nerrors += check_evict_on_close_api() < 0 ? 1 : 0; /* Set up VFD-specific fapl */ - if((fapl_id = h5_fileaccess()) < 0) { + if ((fapl_id = h5_fileaccess()) < 0) { nerrors++; PUTS_ERROR("Unable to get VFD-specific fapl\n"); } /* end if */ /* Set evict-on-close property */ - if(H5Pset_evict_on_close(fapl_id, TRUE) < 0) { + if (H5Pset_evict_on_close(fapl_id, TRUE) < 0) { nerrors++; PUTS_ERROR("Unable to set evict-on-close property\n"); } /* end if */ /* Generate the test file */ - if((fid = generate_eoc_test_file(fapl_id)) < 0) { + if ((fid = generate_eoc_test_file(fapl_id)) < 0) { nerrors++; PUTS_ERROR("Unable to generate test file\n"); } /* end if */ @@ -918,42 +918,42 @@ main(void) * PASSED() and H5_FAILED() are handled in check_configuration() */ TESTING("evict on close with version 1 B-tree chunk index"); - nerrors += check_dset_scheme(fid, DSET_BTREE_NAME) < 0 ? 1 : 0; + nerrors += check_dset_scheme(fid, DSET_BTREE_NAME) < 0 ? 1 : 0; TESTING("evict on close with extensible array chunk index"); - nerrors += check_dset_scheme(fid, DSET_EARRAY_NAME) < 0 ? 1 : 0; + nerrors += check_dset_scheme(fid, DSET_EARRAY_NAME) < 0 ? 1 : 0; TESTING("evict on close with version 2 B-tree chunk index"); - nerrors += check_dset_scheme(fid, DSET_BT2_NAME) < 0 ? 1 : 0; + nerrors += check_dset_scheme(fid, DSET_BT2_NAME) < 0 ? 1 : 0; TESTING("evict on close with fixed array chunk index"); - nerrors += check_dset_scheme(fid, DSET_FARRAY_NAME) < 0 ? 1 : 0; + nerrors += check_dset_scheme(fid, DSET_FARRAY_NAME) < 0 ? 1 : 0; TESTING("evict on close with \'single chunk\' chunk index"); - nerrors += check_dset_scheme(fid, DSET_SINGLE_NAME) < 0 ? 1 : 0; + nerrors += check_dset_scheme(fid, DSET_SINGLE_NAME) < 0 ? 1 : 0; TESTING("evict on close with contiguous layout"); - nerrors += check_dset_scheme(fid, DSET_CONTIGUOUS_NAME) < 0 ? 1 : 0; + nerrors += check_dset_scheme(fid, DSET_CONTIGUOUS_NAME) < 0 ? 1 : 0; TESTING("evict on close with compact layout"); - nerrors += check_dset_scheme(fid, DSET_COMPACT_NAME) < 0 ? 1 : 0; + nerrors += check_dset_scheme(fid, DSET_COMPACT_NAME) < 0 ? 1 : 0; /* Run tests with old- and new-style groups * PASSED() and H5_FAILED() are handled in check_configuration() */ TESTING("evict on close with old-style groups"); - nerrors += check_group_layout(fid, GROUP_OLD_STYLE_NAME) < 0 ? 1 : 0; + nerrors += check_group_layout(fid, GROUP_OLD_STYLE_NAME) < 0 ? 1 : 0; TESTING("evict on close with new-style groups"); - nerrors += check_group_layout(fid, GROUP_NEW_STYLE_NAME) < 0 ? 1 : 0; + nerrors += check_group_layout(fid, GROUP_NEW_STYLE_NAME) < 0 ? 1 : 0; /* Close the test file */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { nerrors++; PUTS_ERROR("Unable to close the test file.\n"); } /* end if */ /* Clean up files and close the VFD-specific fapl */ h5_delete_all_test_files(FILENAMES, fapl_id); - if(H5Pclose(fapl_id) < 0) { + if (H5Pclose(fapl_id) < 0) { nerrors++; PUTS_ERROR("Unable to close VFD-specific fapl.\n"); } /* end if */ - if(nerrors) + if (nerrors) goto error; HDprintf("All evict-on-close tests passed.\n"); @@ -962,14 +962,15 @@ main(void) error: - HDprintf("***** %u evict-on-close test%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + HDprintf("***** %u evict-on-close test%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); h5_delete_all_test_files(FILENAMES, fapl_id); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; HDexit(EXIT_FAILURE); @@ -977,7 +978,6 @@ error: #else - /*------------------------------------------------------------------------- * Function: check_evict_on_close_parallel_fail() * @@ -991,26 +991,28 @@ error: static herr_t check_evict_on_close_parallel_fail(void) { - hid_t fapl_id = -1; - hbool_t evict_on_close; - herr_t status; + hid_t fapl_id = -1; + hbool_t evict_on_close; + herr_t status; TESTING("evict on close fails in parallel"); /* Create a fapl */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set the evict on close property (should fail)*/ evict_on_close = TRUE; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Pset_evict_on_close(fapl_id, evict_on_close); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) FAIL_PUTS_ERROR("H5Pset_evict_on_close() did not fail in parallel HDF5."); /* close fapl */ - if(H5Pclose(fapl_id) < 0) + if (H5Pclose(fapl_id) < 0) TEST_ERROR; PASSED(); @@ -1022,7 +1024,6 @@ error: } /* check_evict_on_close_parallel_fail() */ - /*------------------------------------------------------------------------- * Function: main (parallel version) * @@ -1033,7 +1034,7 @@ error: int main(void) { - unsigned nerrors = 0; /* number of test errors */ + unsigned nerrors = 0; /* number of test errors */ HDprintf("Testing evict-on-close cache behavior\n"); @@ -1043,7 +1044,7 @@ main(void) /* Test that EoC fails in parallel HDF5 */ nerrors += check_evict_on_close_parallel_fail() < 0 ? 1 : 0; - if(nerrors) + if (nerrors) goto error; HDprintf("All evict-on-close tests passed.\n"); @@ -1053,12 +1054,10 @@ main(void) error: - HDprintf("***** %u evict-on-close test%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + HDprintf("***** %u evict-on-close test%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); HDexit(EXIT_FAILURE); } /* main() - parallel */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/test/extend.c b/test/extend.c index 1e2b5b5..f21fce9 100644 --- a/test/extend.c +++ b/test/extend.c @@ -20,23 +20,19 @@ #include "h5test.h" -const char *FILENAME[] = { - "extend", - NULL -}; +const char *FILENAME[] = {"extend", NULL}; -#define N1X 100 /* USE AN EVEN NUMBER! */ -#define N1Y 100 /* USE AN EVEN NUMBER! */ -#define N2X (N1X / 2) -#define N2Y (N1Y / 2) +#define N1X 100 /* USE AN EVEN NUMBER! */ +#define N1Y 100 /* USE AN EVEN NUMBER! */ +#define N2X (N1X / 2) +#define N2Y (N1Y / 2) /* Data buffers */ -static int **buf1 = NULL; -static int *buf1_data = NULL; -static int **buf2 = NULL; -static int *buf2_data = NULL; +static int **buf1 = NULL; +static int * buf1_data = NULL; +static int **buf2 = NULL; +static int * buf2_data = NULL; - /*------------------------------------------------------------------------- * Function: write_data * @@ -53,75 +49,89 @@ static int *buf2_data = NULL; static int write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t mem_space) { - hid_t dataset, file_space, half_space; - static const hsize_t dims[2] = {N1X, N1Y}; - static const hsize_t half_dims[2] = {N2X, N2Y}; - hsize_t size[2]; - hsize_t max_size[2] = {0, 0}; - hsize_t offset[2]; - int i, j, k, m; + hid_t dataset, file_space, half_space; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t half_dims[2] = {N2X, N2Y}; + hsize_t size[2]; + hsize_t max_size[2] = {0, 0}; + hsize_t offset[2]; + int i, j, k, m; TESTING(msg); /* Create the dataset */ - if((dataset = H5Dcreate2(file, name, H5T_NATIVE_INT, mem_space, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dcreate2(file, name, H5T_NATIVE_INT, mem_space, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Write the data */ - for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) { + for (i = 0; i < 5; i++) + for (j = 0; j < 5; j++) { /* Extend the dataset */ offset[0] = (hsize_t)(i * N1X); offset[1] = (hsize_t)(j * N1Y); - size[0] = offset[0] + N1X; - size[1] = offset[1] + N1Y; - if(size[0] > max_size[0] || size[1] > max_size[1]) { - if(size[0] > max_size[0]) + size[0] = offset[0] + N1X; + size[1] = offset[1] + N1Y; + if (size[0] > max_size[0] || size[1] > max_size[1]) { + if (size[0] > max_size[0]) max_size[0] = size[0]; - if(size[1] > max_size[1]) + if (size[1] > max_size[1]) max_size[1] = size[1]; - if(H5Dset_extent(dataset, max_size) < 0) TEST_ERROR; + if (H5Dset_extent(dataset, max_size) < 0) + TEST_ERROR; } /* end if */ /* Select a hyperslab */ - if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; + if ((file_space = H5Dget_space(dataset)) < 0) + TEST_ERROR; + if (H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) + TEST_ERROR; /* Write to the hyperslab */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) TEST_ERROR; - if(H5Sclose(file_space) < 0) TEST_ERROR; + if (H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) + TEST_ERROR; + if (H5Sclose(file_space) < 0) + TEST_ERROR; } /* end for */ /* Read the data */ - if((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) TEST_ERROR; - if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; - for(i = 0; i < 10; i++) { - for(j = 0; j < 10; j++) { + if ((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) + TEST_ERROR; + if ((file_space = H5Dget_space(dataset)) < 0) + TEST_ERROR; + for (i = 0; i < 10; i++) { + for (j = 0; j < 10; j++) { /* Select a hyperslab */ offset[0] = (hsize_t)(i * N2X); offset[1] = (hsize_t)(j * N2Y); - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; + if (H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) + TEST_ERROR; /* Read */ - if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) TEST_ERROR; + if (H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) + TEST_ERROR; /* Compare */ - for(k = 0; k < N2X; k++) - for(m = 0; m < N2Y; m++) - if(buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { + for (k = 0; k < N2X; k++) + for (m = 0; m < N2Y; m++) + if (buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); - HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); + HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, + buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); TEST_ERROR; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Cleanup */ - if(H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Sclose(file_space) < 0) TEST_ERROR; - if(H5Sclose(half_space) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; + if (H5Sclose(file_space) < 0) + TEST_ERROR; + if (H5Sclose(half_space) < 0) + TEST_ERROR; PASSED(); return 0; @@ -131,7 +141,7 @@ error: } /* end write_data() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: write_data_deprec * @@ -149,69 +159,82 @@ error: static int write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t mem_space) { - hid_t dataset, file_space, half_space; - static const hsize_t dims[2] = {N1X, N1Y}; - static const hsize_t half_dims[2] = {N2X, N2Y}; - static hsize_t size[2]; - hsize_t offset[2]; - int i, j, k, m; + hid_t dataset, file_space, half_space; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t half_dims[2] = {N2X, N2Y}; + static hsize_t size[2]; + hsize_t offset[2]; + int i, j, k, m; TESTING(msg); /* Create the dataset */ - if((dataset = H5Dcreate2(file, name, H5T_NATIVE_INT, mem_space, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dcreate2(file, name, H5T_NATIVE_INT, mem_space, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Write the data */ - for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) { + for (i = 0; i < 5; i++) + for (j = 0; j < 5; j++) { /* Extend the dataset */ offset[0] = (hsize_t)(i * N1X); offset[1] = (hsize_t)(j * N1Y); - size[0] = offset[0] + N1X; - size[1] = offset[1] + N1Y; - if(H5Dextend(dataset, size) < 0) TEST_ERROR; + size[0] = offset[0] + N1X; + size[1] = offset[1] + N1Y; + if (H5Dextend(dataset, size) < 0) + TEST_ERROR; /* Select a hyperslab */ - if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; + if ((file_space = H5Dget_space(dataset)) < 0) + TEST_ERROR; + if (H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) + TEST_ERROR; /* Write to the hyperslab */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) TEST_ERROR; - if(H5Sclose(file_space) < 0) TEST_ERROR; + if (H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) + TEST_ERROR; + if (H5Sclose(file_space) < 0) + TEST_ERROR; } /* end for */ /* Read the data */ - if((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) TEST_ERROR; - if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; - for(i = 0; i < 10; i++) { - for(j = 0; j < 10; j++) { + if ((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) + TEST_ERROR; + if ((file_space = H5Dget_space(dataset)) < 0) + TEST_ERROR; + for (i = 0; i < 10; i++) { + for (j = 0; j < 10; j++) { /* Select a hyperslab */ offset[0] = (hsize_t)(i * N2X); offset[1] = (hsize_t)(j * N2Y); - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; + if (H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) + TEST_ERROR; /* Read */ - if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) TEST_ERROR; + if (H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) + TEST_ERROR; /* Compare */ - for(k = 0; k < N2X; k++) - for(m = 0; m < N2Y; m++) - if(buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { + for (k = 0; k < N2X; k++) + for (m = 0; m < N2Y; m++) + if (buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); - HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); + HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, + buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); TEST_ERROR; } /* end if */ - } /* end for */ - } /* end for */ - + } /* end for */ + } /* end for */ /* Cleanup */ - if(H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Sclose(file_space) < 0) TEST_ERROR; - if(H5Sclose(half_space) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; + if (H5Sclose(file_space) < 0) + TEST_ERROR; + if (H5Sclose(half_space) < 0) + TEST_ERROR; PASSED(); return 0; @@ -221,7 +244,6 @@ error: } /* end write_data_deprec() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: main * @@ -235,70 +257,88 @@ error: *------------------------------------------------------------------------- */ int -main (void) +main(void) { - hid_t file, mem_space, cparms; - hid_t fapl; - int nerrors = 0; - static const hsize_t dims[2] = {N1X, N1Y}; - static const hsize_t chunk_dims[2] = {N2X, N2Y}; - static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - char filename[1024]; - int i, j; + hid_t file, mem_space, cparms; + hid_t fapl; + int nerrors = 0; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t chunk_dims[2] = {N2X, N2Y}; + static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + char filename[1024]; + int i, j; h5_reset(); fapl = h5_fileaccess(); /* Initialize buffer and space */ - if(NULL == (buf1_data = (int *)HDcalloc(N1X * N1Y, sizeof(int)))) + if (NULL == (buf1_data = (int *)HDcalloc(N1X * N1Y, sizeof(int)))) TEST_ERROR; - if(NULL == (buf1 = (int **)HDcalloc(N1X, sizeof(buf1_data)))) + if (NULL == (buf1 = (int **)HDcalloc(N1X, sizeof(buf1_data)))) TEST_ERROR; for (i = 0; i < N1X; i++) buf1[i] = buf1_data + (i * N1Y); - if(NULL == (buf2_data = (int *)HDcalloc(N2X * N2Y, sizeof(int)))) + if (NULL == (buf2_data = (int *)HDcalloc(N2X * N2Y, sizeof(int)))) TEST_ERROR; - if(NULL == (buf2 = (int **)HDcalloc(N2X, sizeof(buf2_data)))) + if (NULL == (buf2 = (int **)HDcalloc(N2X, sizeof(buf2_data)))) TEST_ERROR; for (i = 0; i < N2X; i++) buf2[i] = buf2_data + (i * N2Y); - for(i = 0; i < N1X; i++) - for(j = 0; j < N1Y; j++) + for (i = 0; i < N1X; i++) + for (j = 0; j < N1Y; j++) buf1[i][j] = i * N1Y + j; - if((mem_space = H5Screate_simple(2, dims, maxdims)) < 0) TEST_ERROR; + if ((mem_space = H5Screate_simple(2, dims, maxdims)) < 0) + TEST_ERROR; /* Create the file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* Create the dataset creation property list */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if(H5Pset_chunk(cparms, 2, chunk_dims) < 0) TEST_ERROR; + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(cparms, 2, chunk_dims) < 0) + TEST_ERROR; /* Test with incremental allocation */ - nerrors += write_data("extendible dataset with incr. allocation", file, "dataset1a", cparms, mem_space) < 0 ? 1 : 0; + nerrors += + write_data("extendible dataset with incr. allocation", file, "dataset1a", cparms, mem_space) < 0 ? 1 + : 0; #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += write_data_deprec("extendible dataset with incr. allocation w/deprec. symbols", file, "dataset1b", cparms, mem_space) < 0 ? 1 : 0; + nerrors += write_data_deprec("extendible dataset with incr. allocation w/deprec. symbols", file, + "dataset1b", cparms, mem_space) < 0 + ? 1 + : 0; #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Test with early allocation */ - if(H5Pset_alloc_time(cparms, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR; - nerrors += write_data("extendible dataset with early allocation", file, "dataset2a", cparms, mem_space) < 0 ? 1 : 0; + if (H5Pset_alloc_time(cparms, H5D_ALLOC_TIME_EARLY) < 0) + TEST_ERROR; + nerrors += + write_data("extendible dataset with early allocation", file, "dataset2a", cparms, mem_space) < 0 ? 1 + : 0; #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += write_data_deprec("extendible dataset with early allocation w/deprec. symbols", file, "dataset2b", cparms, mem_space) < 0 ? 1 : 0; + nerrors += write_data_deprec("extendible dataset with early allocation w/deprec. symbols", file, + "dataset2b", cparms, mem_space) < 0 + ? 1 + : 0; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - if(H5Pclose(cparms) < 0) TEST_ERROR; - if(H5Sclose(mem_space) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) TEST_ERROR; + if (H5Pclose(cparms) < 0) + TEST_ERROR; + if (H5Sclose(mem_space) < 0) + TEST_ERROR; + if (H5Fclose(file) < 0) + TEST_ERROR; /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if(nerrors) { + if (nerrors) { HDprintf("***** %d FAILURE%s! *****\n", nerrors, (1 == nerrors) ? "" : "S"); HDexit(EXIT_FAILURE); } /* end if */ @@ -323,4 +363,3 @@ error: HDprintf("*** One or more extend tests failed ***\n"); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/external.c b/test/external.c index d29fb6b..dd88f84 100644 --- a/test/external.c +++ b/test/external.c @@ -23,7 +23,6 @@ #define AEF_EXNAME_MAX_LEN 12 /* string buffer size for external file name */ /* used in __add_external_files() */ - /*------------------------------------------------------------------------- * Function: files_have_same_contents * @@ -42,11 +41,11 @@ files_have_same_contents(const char *name1, const char *name2) { int fd1 = 0; int fd2 = 0; - ssize_t n1 = 0; - ssize_t n2 = 0; + ssize_t n1 = 0; + ssize_t n2 = 0; char buf1[1024]; char buf2[1024]; - hbool_t ret = FALSE; /* not equal until proven otherwise */ + hbool_t ret = FALSE; /* not equal until proven otherwise */ if ((fd1 = HDopen(name1, O_RDONLY)) < 0) goto out; @@ -54,39 +53,38 @@ files_have_same_contents(const char *name1, const char *name2) goto out; /* Loop until files are empty or we encounter a problem */ - while(1) { + while (1) { HDmemset(buf1, 0, sizeof(buf1)); HDmemset(buf2, 0, sizeof(buf2)); n1 = HDread(fd1, buf1, sizeof(buf1)); - if(n1 < 0 || (size_t)n1 > sizeof(buf1)) + if (n1 < 0 || (size_t)n1 > sizeof(buf1)) break; n2 = HDread(fd2, buf2, sizeof(buf2)); - if(n2 < 0 || (size_t)n2 > sizeof(buf2)) + if (n2 < 0 || (size_t)n2 > sizeof(buf2)) break; - if(n1 != n2) + if (n1 != n2) break; - if(n1 == 0 && n2 == 0) { + if (n1 == 0 && n2 == 0) { ret = TRUE; break; } - if(HDmemcmp(buf1, buf2, (size_t)n1)) + if (HDmemcmp(buf1, buf2, (size_t)n1)) break; } /* end while */ out: - if(fd1) + if (fd1) HDclose(fd1); - if(fd2) + if (fd2) HDclose(fd2); return ret; } /* end files_have_same_contents() */ - /*------------------------------------------------------------------------- * Function: test_non_extendible * @@ -103,51 +101,53 @@ out: static int test_non_extendible(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1] = {100}; /* data space current size */ - hsize_t max_size[1] = {100}; /* data space maximum size */ - int n = 0; /* number of external files */ - off_t file_offset = 0; /* external file offset */ - hsize_t file_size = 0; /* sizeof external file segment */ - haddr_t dset_addr = HADDR_UNDEF; /* address of dataset */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* data space current size */ + hsize_t max_size[1] = {100}; /* data space maximum size */ + int n = 0; /* number of external files */ + off_t file_offset = 0; /* external file offset */ + hsize_t file_size = 0; /* sizeof external file segment */ + haddr_t dset_addr = HADDR_UNDEF; /* address of dataset */ TESTING("fixed-size data space, exact storage"); /* Create the dataset and close */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR /* Read dataset creation information */ - if((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Test dataset address. Should be undefined. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset_addr = H5Dget_offset(dset); - } H5E_END_TRY; - if(dset_addr != HADDR_UNDEF) + } + H5E_END_TRY; + if (dset_addr != HADDR_UNDEF) FAIL_STACK_ERROR /* Check external count */ - if((dcpl = H5Dget_create_plist(dset)) < 0) + if ((dcpl = H5Dget_create_plist(dset)) < 0) FAIL_STACK_ERROR - if((n = H5Pget_external_count(dcpl)) < 0) + if ((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR - if(1 != n) { + if (1 != n) { H5_FAILED(); HDputs(" Returned external count is wrong."); HDprintf(" got: %d\n ans: 1\n", n); @@ -155,37 +155,41 @@ test_non_extendible(hid_t file) } /* Verify external file settings */ - if(H5Pget_external(dcpl, 0, 0, NULL, &file_offset, &file_size) < 0) + if (H5Pget_external(dcpl, 0, 0, NULL, &file_offset, &file_size) < 0) FAIL_STACK_ERROR - if(file_offset != 0) { + if (file_offset != 0) { H5_FAILED(); HDputs(" Wrong file offset."); HDprintf(" got: %lu\n ans: 0\n", (unsigned long)file_offset); goto error; } - if(file_size != (max_size[0] * sizeof(int))) { + if (file_size != (max_size[0] * sizeof(int))) { H5_FAILED(); HDputs(" Wrong file size."); - HDprintf(" got: %lu\n ans: %lu\n", (unsigned long)file_size, (unsigned long)max_size[0]*sizeof(int)); + HDprintf(" got: %lu\n ans: %lu\n", (unsigned long)file_size, + (unsigned long)max_size[0] * sizeof(int)); goto error; } /* Done (dataspace was previously closed) */ - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(space); H5Dclose(dset); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_non_extendible() */ - /*------------------------------------------------------------------------- * Function: test_too_small * @@ -203,44 +207,48 @@ test_non_extendible(hid_t file) static int test_too_small(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1] = {100}; /* current data space size */ - hsize_t max_size[1] = {100}; /* maximum data space size */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* current data space size */ + hsize_t max_size[1] = {100}; /* maximum data space size */ TESTING("external storage is too small"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < + 0) /* note -1 */ FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset = H5Dcreate2(file, "dset2", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dset >= 0) + } + H5E_END_TRY; + if (dset >= 0) FAIL_PUTS_ERROR(" Small external file succeeded instead of failing."); - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Sclose(space); H5Pclose(dcpl); H5Dclose(dset); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_too_small() */ - /*------------------------------------------------------------------------- * Function: test_large_enough_current_eventual * @@ -259,40 +267,44 @@ test_too_small(hid_t file) static int test_large_enough_current_eventual(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1] = {100}; /* current data space size */ - hsize_t max_size[1] = {200}; /* maximum data space size */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* current data space size */ + hsize_t max_size[1] = {200}; /* maximum data space size */ TESTING("extendible dataspace, exact external size"); - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Pclose(dcpl); H5Sclose(space); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_large_enough_current_eventual() */ - /*------------------------------------------------------------------------- * Function: test_large_enough_current_not_eventual * @@ -310,43 +322,49 @@ error: static int test_large_enough_current_not_eventual(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1] = {100}; /* current data space size */ - hsize_t max_size[1] = {200}; /* maximum data space size */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* current data space size */ + hsize_t max_size[1] = {200}; /* maximum data space size */ TESTING("extendible dataspace, external storage is too small"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < + 0) /* note -1 */ FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset = H5Dcreate2(file, "dset4", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dset >= 0) + } + H5E_END_TRY; + if (dset >= 0) FAIL_PUTS_ERROR(" Small external file succeeded instead of failing."); - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Dclose(dset); H5Pclose(dcpl); H5Sclose(space); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_large_enough_current_not_eventual() */ - /*------------------------------------------------------------------------- * Function: test_unlimited * @@ -364,76 +382,82 @@ test_large_enough_current_not_eventual(hid_t file) static int test_unlimited(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1] = {100}; /* data space current size */ - hsize_t max_size[1] = {H5S_UNLIMITED}; /* data space maximum size */ - int n; /* number of external files */ - off_t file_offset; /* external file offset */ - hsize_t file_size; /* sizeof external file segment */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* data space current size */ + hsize_t max_size[1] = {H5S_UNLIMITED}; /* data space maximum size */ + int n; /* number of external files */ + off_t file_offset; /* external file offset */ + hsize_t file_size; /* sizeof external file segment */ TESTING("unlimited dataspace, unlimited external storage"); /* Create dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR /* Read dataset creation information */ - if((dset = H5Dopen2(file, "dset5", H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(file, "dset5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((dcpl = H5Dget_create_plist(dset)) < 0) + if ((dcpl = H5Dget_create_plist(dset)) < 0) FAIL_STACK_ERROR - if((n = H5Pget_external_count(dcpl)) < 0) + if ((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR - if(1 != n) { + if (1 != n) { H5_FAILED(); HDputs(" Returned external count is wrong."); HDprintf(" got: %d\n ans: 1\n", n); goto error; } /* end if */ - if(H5Pget_external(dcpl, 0, 0, NULL, &file_offset, &file_size) < 0) + if (H5Pget_external(dcpl, 0, 0, NULL, &file_offset, &file_size) < 0) FAIL_STACK_ERROR - if(file_offset != 0) { + if (file_offset != 0) { H5_FAILED(); HDputs(" Wrong file offset."); HDprintf(" got: %lu\n ans: 0\n", (unsigned long)file_offset); goto error; } - if(H5F_UNLIMITED != file_size) { + if (H5F_UNLIMITED != file_size) { H5_FAILED(); HDputs(" Wrong file size."); HDprintf(" got: %lu\n ans: INF\n", (unsigned long)file_size); goto error; } - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Dclose(dset); H5Pclose(dcpl); H5Sclose(space); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_unlimited() */ - /*------------------------------------------------------------------------- * Function: __add_external_files * @@ -450,27 +474,17 @@ test_unlimited(hid_t file) *------------------------------------------------------------------------- */ static int -__add_external_files( - hid_t dcpl_id, - unsigned int n_external_files, - off_t offset, - hsize_t max_ext_size) +__add_external_files(hid_t dcpl_id, unsigned int n_external_files, off_t offset, hsize_t max_ext_size) { - char exname[AEF_EXNAME_MAX_LEN+1]; + char exname[AEF_EXNAME_MAX_LEN + 1]; unsigned int i = 0; if (dcpl_id < 0) { return -1; } for (i = 0; i < n_external_files; i++) { - if (HDsnprintf( - exname, - AEF_EXNAME_MAX_LEN, - "ext%d.data", - i+1) - > AEF_EXNAME_MAX_LEN) - { - HDfprintf(stderr, "External file %d overflows name buffer\n", i+1); + if (HDsnprintf(exname, AEF_EXNAME_MAX_LEN, "ext%d.data", i + 1) > AEF_EXNAME_MAX_LEN) { + HDfprintf(stderr, "External file %d overflows name buffer\n", i + 1); fflush(stderr); return -1; } @@ -483,7 +497,6 @@ __add_external_files( return 0; } /* end __add_external_files() */ - /*------------------------------------------------------------------------- * Function: test_multiple_files * @@ -500,9 +513,9 @@ __add_external_files( static int test_multiple_files(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* dataspace */ - hid_t dset = -1; /* dataset */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* dataspace */ + hid_t dset = -1; /* dataset */ hsize_t cur_size[1] = {100}; /* data space current size */ hsize_t max_size[1] = {100}; /* data space maximum size */ hsize_t max_ext_size; /* maximum size of external files */ @@ -510,7 +523,7 @@ test_multiple_files(hid_t file) TESTING("multiple external files"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR max_ext_size = (hsize_t)(sizeof(int) * max_size[0] / n_external_files); @@ -519,20 +532,22 @@ test_multiple_files(hid_t file) FAIL_STACK_ERROR; } - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR /* Re-use space below */ /* ---------------------------------------------- * Verify that too-small external files will fail */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR max_ext_size -= 1; @@ -541,28 +556,33 @@ test_multiple_files(hid_t file) FAIL_STACK_ERROR; } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset = H5Dcreate2(file, "dset7", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; - if(dset >= 0) + } + H5E_END_TRY; + if (dset >= 0) FAIL_PUTS_ERROR(" Small external files succeeded instead of failing."); - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Pclose(dcpl); H5Sclose(space); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_multiple_files() */ - /*------------------------------------------------------------------------- * Function: test_add_to_unlimited * @@ -580,40 +600,44 @@ error: static int test_add_to_unlimited(void) { - hid_t dcpl = -1; /* dataset creation properties */ - herr_t status = FAIL; /* function return status */ - int n = 0; /* number of external files */ + hid_t dcpl = -1; /* dataset creation properties */ + herr_t status = FAIL; /* function return status */ + int n = 0; /* number of external files */ TESTING("external file following unlimited file"); - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) FAIL_PUTS_ERROR(" H5Pset_external() succeeded when it should have failed."); - if((n = H5Pget_external_count(dcpl)) < 0) + if ((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR - if(1 != n) + if (1 != n) FAIL_PUTS_ERROR(" Wrong external file count returned."); - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_add_to_unlimited() */ - /*------------------------------------------------------------------------- * Function: test_overflow * @@ -631,35 +655,39 @@ test_add_to_unlimited(void) static int test_overflow(void) { - hid_t dcpl = -1; /* dataset creation properties */ - herr_t status = FAIL; /* return status */ + hid_t dcpl = -1; /* dataset creation properties */ + herr_t status = FAIL; /* return status */ TESTING("address overflow in external files"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0) + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED - 1) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) FAIL_PUTS_ERROR(" H5Pset_external() succeeded when it should have failed."); - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_overflow() */ - /*------------------------------------------------------------------------- * Function: test_read_file_set * @@ -676,27 +704,27 @@ test_overflow(void) static int test_read_file_set(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hid_t grp = -1; /* group to emit diagnostics */ - size_t i = 0; /* miscellaneous counter */ - char filename[1024]; /* file names */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ - hid_t hs_space = -1; /* hyperslab data space */ - hsize_t hs_start = 30; /* hyperslab starting offset */ - hsize_t hs_count = 25; /* hyperslab size */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hid_t grp = -1; /* group to emit diagnostics */ + size_t i = 0; /* miscellaneous counter */ + char filename[1024]; /* file names */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size; /* current data space size */ + hid_t hs_space = -1; /* hyperslab data space */ + hsize_t hs_start = 30; /* hyperslab starting offset */ + hsize_t hs_count = 25; /* hyperslab size */ TESTING("read external dataset"); - if(HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) + if (HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) TEST_ERROR /* Reset the raw data files */ - if(reset_raw_data_files(FALSE) < 0) + if (reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the file and an initial group. This causes messages about @@ -704,80 +732,87 @@ test_read_file_set(hid_t fapl) * output looks like. */ h5_fixname(EXT_FNAME[1], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if ((grp = H5Gcreate2(file, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((grp = H5Gcreate2(file, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if (H5Gclose(grp) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR /* Create the dcpl */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - for(i = 0; i < N_EXT_FILES; i++) { - HDsnprintf(filename, sizeof(filename), "extern_%dr.raw", (int) i + 1); - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + for (i = 0; i < N_EXT_FILES; i++) { + HDsnprintf(filename, sizeof(filename), "extern_%dr.raw", (int)i + 1); + if (H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR } /* Create the dataspace */ cur_size = TOTAL_SIZE; - if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) + if ((space = H5Screate_simple(1, &cur_size, NULL)) < 0) FAIL_STACK_ERROR /* Create the dataset */ - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Read the entire dataset */ HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR /* Compare data */ - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) + for (i = 0; i < TOTAL_SIZE; i++) + if (whole[i] != (signed)i) FAIL_PUTS_ERROR("Incorrect value(s) read."); /* Read via a hypserslab in the middle of the dataset */ /* Set up dataspace */ - if((hs_space = H5Scopy(space)) < 0) + if ((hs_space = H5Scopy(space)) < 0) FAIL_STACK_ERROR - if(H5Sselect_hyperslab(hs_space, H5S_SELECT_SET, &hs_start, NULL, &hs_count, NULL) < 0) + if (H5Sselect_hyperslab(hs_space, H5S_SELECT_SET, &hs_start, NULL, &hs_count, NULL) < 0) FAIL_STACK_ERROR /* Read */ HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, hs_space, hs_space, H5P_DEFAULT, whole) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, hs_space, hs_space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR /* Verify data */ - for(i = (size_t)hs_start; i < (size_t)(hs_start + hs_count); i++) { - if(whole[i] != (signed)i) + for (i = (size_t)hs_start; i < (size_t)(hs_start + hs_count); i++) { + if (whole[i] != (signed)i) FAIL_PUTS_ERROR("Incorrect value(s) read (hyperslab)."); } /* end for */ - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Sclose(hs_space) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Sclose(hs_space) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Gclose(grp); H5Dclose(dset); H5Pclose(dcpl); H5Sclose(space); H5Sclose(hs_space); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_read_file_set() */ - /*------------------------------------------------------------------------- * Function: test_write_file_set * @@ -794,112 +829,117 @@ test_read_file_set(hid_t fapl) static int test_write_file_set(hid_t fapl) { - hid_t file = -1; /* file to which to write */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t mem_space = -1; /* memory data space */ - hid_t file_space = -1; /* file data space */ - hid_t dset = -1; /* dataset */ - unsigned i = 0; /* miscellaneous counter */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size = 100; /* current data space size */ - hsize_t max_size = 200; /* maximum data space size */ - hsize_t hs_start = 100; /* hyperslab starting offset */ - hsize_t hs_count = 100; /* hyperslab size */ - char filename[1024]; /* file name */ + hid_t file = -1; /* file to which to write */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t mem_space = -1; /* memory data space */ + hid_t file_space = -1; /* file data space */ + hid_t dset = -1; /* dataset */ + unsigned i = 0; /* miscellaneous counter */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size = 100; /* current data space size */ + hsize_t max_size = 200; /* maximum data space size */ + hsize_t hs_start = 100; /* hyperslab starting offset */ + hsize_t hs_count = 100; /* hyperslab size */ + char filename[1024]; /* file name */ TESTING("write external dataset"); - if(HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) + if (HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) TEST_ERROR /* Create another file */ h5_fixname(EXT_FNAME[2], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create the dcpl and external file list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - for(i = 0; i < N_EXT_FILES; i++) { + for (i = 0; i < N_EXT_FILES; i++) { hsize_t size; - HDsnprintf(filename, sizeof(filename), "extern_%dw.raw", (int) i + 1); + HDsnprintf(filename, sizeof(filename), "extern_%dw.raw", (int)i + 1); - if(i != N_EXT_FILES -1) + if (i != N_EXT_FILES - 1) size = (hsize_t)sizeof(part); else size = H5F_UNLIMITED; - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), size) < 0) + if (H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), size) < 0) FAIL_STACK_ERROR } /* end for */ /* Reset the raw data files */ - if(reset_raw_data_files(FALSE) < 0) + if (reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the dataset */ - if((mem_space = H5Screate_simple(1, &cur_size, &max_size)) < 0) + if ((mem_space = H5Screate_simple(1, &cur_size, &max_size)) < 0) FAIL_STACK_ERROR - if((file_space = H5Scopy(mem_space)) < 0) + if ((file_space = H5Scopy(mem_space)) < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, file_space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, file_space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write the entire dataset and compare with the original */ - for(i = 0; i < cur_size; i++) + for (i = 0; i < cur_size; i++) whole[i] = (int)i; - if(H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, whole) < 0) + if (H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR - for(i = 0; i < N_EXT_FILES; i++) { + for (i = 0; i < N_EXT_FILES; i++) { char name1[64], name2[64]; HDsprintf(name1, "extern_%dr.raw", i + 1); HDsprintf(name2, "extern_%dw.raw", i + 1); - if(!files_have_same_contents(name1, name2)) + if (!files_have_same_contents(name1, name2)) FAIL_PUTS_ERROR(" Output differs from expected value.") } /* end for */ /* Extend the dataset by another 100 elements */ - if(H5Dset_extent(dset, &max_size) < 0) + if (H5Dset_extent(dset, &max_size) < 0) FAIL_STACK_ERROR - if(H5Sclose(file_space) < 0) + if (H5Sclose(file_space) < 0) FAIL_STACK_ERROR - if((file_space = H5Dget_space(dset)) < 0) + if ((file_space = H5Dget_space(dset)) < 0) FAIL_STACK_ERROR /* Write second half of dataset */ - for(i = 0; i < hs_count; i++) + for (i = 0; i < hs_count; i++) whole[i] = 100 + (int)i; - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, &hs_start, NULL, &hs_count, NULL) < 0) + if (H5Sselect_hyperslab(file_space, H5S_SELECT_SET, &hs_start, NULL, &hs_count, NULL) < 0) FAIL_STACK_ERROR - if(H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, whole) < 0) + if (H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR - - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(mem_space) < 0) FAIL_STACK_ERROR - if(H5Sclose(file_space) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Sclose(mem_space) < 0) + FAIL_STACK_ERROR + if (H5Sclose(file_space) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Dclose(dset); H5Pclose(dcpl); H5Sclose(mem_space); H5Sclose(file_space); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_write_file_set() */ - - /*------------------------------------------------------------------------- +/*------------------------------------------------------------------------- * Function: test_path_absolute * * Purpose: Test absolute filenames for external files. @@ -919,78 +959,83 @@ test_write_file_set(hid_t fapl) static int test_path_absolute(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - size_t i = 0; /* miscellaneous counter */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + size_t i = 0; /* miscellaneous counter */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size; /* current data space size */ TESTING("absolute filenames for external file"); h5_fixname(EXT_FNAME[3], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Reset the raw data files */ - if(reset_raw_data_files(FALSE) < 0) + if (reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the dcpl */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) + if (NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) TEST_ERROR - for(i = 0; i < N_EXT_FILES; i++) { - HDsnprintf(filename, sizeof(filename), "%s%sextern_%dr.raw", cwdpath, H5_DIR_SEPS, (int) i + 1); + for (i = 0; i < N_EXT_FILES; i++) { + HDsnprintf(filename, sizeof(filename), "%s%sextern_%dr.raw", cwdpath, H5_DIR_SEPS, (int)i + 1); #if defined(H5_HAVE_WINDOW_PATH) /* For windows, test path-absolute case (\dir\file.raw) for the second file */ - if(i == 1) + if (i == 1) HDsnprintf(filename, sizeof(filename), "%s%sextern_%dr.raw", cwdpath + 2, H5_DIR_SEPS, i + 1); #endif - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + if (H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR } /* end for */ /* create the dataspace */ cur_size = TOTAL_SIZE; - if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) + if ((space = H5Screate_simple(1, &cur_size, NULL)) < 0) FAIL_STACK_ERROR /* create the dataset */ - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Read the entire dataset and compare with the original */ HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) + for (i = 0; i < TOTAL_SIZE; i++) + if (whole[i] != (signed)i) FAIL_PUTS_ERROR("Incorrect value(s) read."); - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Pclose(dcpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_path_absolute() */ - /*------------------------------------------------------------------------- * Function: test_path_relative * @@ -1009,76 +1054,81 @@ error: static int test_path_relative(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - size_t i = 0; /* miscellaneous counters */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + size_t i = 0; /* miscellaneous counters */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size; /* current data space size */ TESTING("filenames relative to current directory for external file"); - if(HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) + if (HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) TEST_ERROR if (HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; /* Reset the raw data files */ - if(reset_raw_data_files(FALSE) < 0) + if (reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) + if (NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) TEST_ERROR for (i = 0; i < N_EXT_FILES; i++) { HDsnprintf(filename, sizeof(filename), "extern_%dr.raw", (int)i + 1); - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + if (H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR } /* end for */ cur_size = TOTAL_SIZE; - if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) + if ((space = H5Screate_simple(1, &cur_size, NULL)) < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Read the entire dataset and compare with the original */ HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) + for (i = 0; i < TOTAL_SIZE; i++) + if (whole[i] != (signed)i) FAIL_PUTS_ERROR("Incorrect value(s) read."); - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Pclose(dcpl); H5Sclose(space); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_path_relative() */ - /*------------------------------------------------------------------------- * Function: test_path_relative_cwd * @@ -1099,133 +1149,147 @@ error: static int test_path_relative_cwd(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dapl = -1; /* dataset access property list */ - hid_t dapl2 = -1; /* copy of dapl */ - hid_t dset = -1; /* dataset */ - hid_t dset2 = -1; /* dataset, opened a second time */ - hid_t dset3 = -1; /* dataset, opened with different prefix */ - size_t i = 0; /* miscellaneous counters */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ - char buffer[1024]; /* buffer to read efile_prefix */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dapl = -1; /* dataset access property list */ + hid_t dapl2 = -1; /* copy of dapl */ + hid_t dset = -1; /* dataset */ + hid_t dset2 = -1; /* dataset, opened a second time */ + hid_t dset3 = -1; /* dataset, opened with different prefix */ + size_t i = 0; /* miscellaneous counters */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size; /* current data space size */ + char buffer[1024]; /* buffer to read efile_prefix */ TESTING("filenames relative to HDF5 file for external file"); - if(HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) + if (HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) TEST_ERROR - if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) + if (HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; /* Reset the raw data files */ - if(reset_raw_data_files(FALSE) < 0) + if (reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) + if (NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) TEST_ERROR - for(i = 0; i < N_EXT_FILES; i++) { + for (i = 0; i < N_EXT_FILES; i++) { HDsnprintf(filename, sizeof(filename), "..%sextern_%dr.raw", H5_DIR_SEPS, (int)i + 1); - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + if (H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR } /* end for */ cur_size = TOTAL_SIZE; - if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) + if ((space = H5Screate_simple(1, &cur_size, NULL)) < 0) FAIL_STACK_ERROR - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR - if(H5Pset_efile_prefix(dapl, "${ORIGIN}") < 0) + if (H5Pset_efile_prefix(dapl, "${ORIGIN}") < 0) FAIL_STACK_ERROR - if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) + if (H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) FAIL_STACK_ERROR - if(HDstrcmp(buffer, "${ORIGIN}") != 0) + if (HDstrcmp(buffer, "${ORIGIN}") != 0) FAIL_PUTS_ERROR("efile prefix not set correctly"); - if((dapl2 = H5Pcopy(dapl)) < 0) + if ((dapl2 = H5Pcopy(dapl)) < 0) FAIL_STACK_ERROR /* Create dataset */ - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl2)) < 0) + if ((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl2)) < 0) FAIL_STACK_ERROR /* Reopen dataset with same efile_prefix property */ - if((dset2 = H5Dopen2(file, "dset1", dapl2)) < 0) + if ((dset2 = H5Dopen2(file, "dset1", dapl2)) < 0) FAIL_STACK_ERROR /* Reopen dataset with different efile_prefix property */ - if(H5Pset_efile_prefix(dapl, "//") < 0) + if (H5Pset_efile_prefix(dapl, "//") < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset3 = H5Dopen2(file, "dset1", dapl); - } H5E_END_TRY; - if(dset3 >= 0) + } + H5E_END_TRY; + if (dset3 >= 0) FAIL_PUTS_ERROR("reopening the dataset with a different efile_prefix succeded"); /* Read the entire dataset and compare with the original */ HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) + for (i = 0; i < TOTAL_SIZE; i++) + if (whole[i] != (signed)i) FAIL_PUTS_ERROR("Incorrect value(s) read."); /* Close dataset */ - if(H5Dclose(dset2) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset2) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR /* Open dataset (use a differend prefix than for create. * This works because the dataset was closed. */ - if(H5Pset_efile_prefix(dapl2, "${ORIGIN}/.") < 0) + if (H5Pset_efile_prefix(dapl2, "${ORIGIN}/.") < 0) FAIL_STACK_ERROR - if((dset = H5Dopen2(file, "dset1", dapl2)) < 0) + if ((dset = H5Dopen2(file, "dset1", dapl2)) < 0) FAIL_STACK_ERROR /* Reopen dataset with same efile_prefix property */ - if((dset2 = H5Dopen2(file, "dset1", dapl2)) < 0) + if ((dset2 = H5Dopen2(file, "dset1", dapl2)) < 0) FAIL_STACK_ERROR /* Reopen dataset with different efile_prefix property */ - if(H5Pset_efile_prefix(dapl, NULL) < 0) + if (H5Pset_efile_prefix(dapl, NULL) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset3 = H5Dopen2(file, "dset1", dapl); - } H5E_END_TRY; - if(dset3 >= 0) + } + H5E_END_TRY; + if (dset3 >= 0) FAIL_PUTS_ERROR("reopening the dataset with a different efile_prefix succeded"); /* Read the entire dataset and compare with the original */ HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) + for (i = 0; i < TOTAL_SIZE; i++) + if (whole[i] != (signed)i) FAIL_PUTS_ERROR("Incorrect value(s) read."); - if(H5Dclose(dset2) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl2) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset2) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl2); H5Pclose(dapl); H5Dclose(dset3); @@ -1234,11 +1298,11 @@ error: H5Pclose(dcpl); H5Sclose(space); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_path_relative_cwd() */ - /*------------------------------------------------------------------------- * Function: test_h5d_get_access_plist * @@ -1255,89 +1319,95 @@ error: static int test_h5d_get_access_plist(hid_t fapl_id) { - hid_t fid = -1; /* file to write to */ - hid_t dcpl_id = -1; /* dataset creation properties */ - hid_t dapl_id = -1; /* dataset access properties */ - hid_t sid = -1; /* data space */ - hid_t did = -1; /* dataset */ - hsize_t dims = 0; /* dataset size */ - char *buffer = NULL; /* saved prefix name from dapl */ - char filename[1024]; /* file names */ + hid_t fid = -1; /* file to write to */ + hid_t dcpl_id = -1; /* dataset creation properties */ + hid_t dapl_id = -1; /* dataset access properties */ + hid_t sid = -1; /* data space */ + hid_t did = -1; /* dataset */ + hsize_t dims = 0; /* dataset size */ + char * buffer = NULL; /* saved prefix name from dapl */ + char filename[1024]; /* file names */ TESTING("H5Dget_access_plist() returns correct prefix"); - if(HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) + if (HDsetenv("HDF5_EXTFILE_PREFIX", "", 1) < 0) TEST_ERROR /* Reset the raw data files */ - if(reset_raw_data_files(FALSE) < 0) + if (reset_raw_data_files(FALSE) < 0) TEST_ERROR /* Create the file */ h5_fixname(EXT_FNAME[5], fapl_id, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) FAIL_STACK_ERROR /* Create the dcpl and set external storage */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_external(dcpl_id, "extern_1r.raw", (off_t)0, (hsize_t)0) < 0) + if (H5Pset_external(dcpl_id, "extern_1r.raw", (off_t)0, (hsize_t)0) < 0) FAIL_STACK_ERROR /* Create the dapl and set the prefix */ - if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR - if(H5Pset_efile_prefix(dapl_id, "someprefix") < 0) + if (H5Pset_efile_prefix(dapl_id, "someprefix") < 0) FAIL_STACK_ERROR /* Create the dataset */ - if((sid = H5Screate_simple(1, &dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, &dims, NULL)) < 0) FAIL_STACK_ERROR - if((did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, dapl_id)) < 0) + if ((did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, dapl_id)) < 0) FAIL_STACK_ERROR /* Close the dapl */ - if(H5Pclose(dapl_id) < 0) + if (H5Pclose(dapl_id) < 0) FAIL_STACK_ERROR dapl_id = -1; /* Get a data access property list from the dataset */ - if((dapl_id = H5Dget_access_plist(did)) < 0) + if ((dapl_id = H5Dget_access_plist(did)) < 0) FAIL_STACK_ERROR /* Check the value for the external prefix */ - if((buffer = (char *)HDcalloc((size_t)64, sizeof(char))) == NULL) + if ((buffer = (char *)HDcalloc((size_t)64, sizeof(char))) == NULL) TEST_ERROR - if(H5Pget_efile_prefix(dapl_id, buffer, (size_t)64) < 0) + if (H5Pget_efile_prefix(dapl_id, buffer, (size_t)64) < 0) FAIL_STACK_ERROR - if(HDstrcmp(buffer, "someprefix") != 0) + if (HDstrcmp(buffer, "someprefix") != 0) FAIL_PUTS_ERROR("external file prefix from dapl incorrect"); /* Close everything */ HDfree(buffer); - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl_id) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl_id) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dapl_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - if(buffer) +error: + if (buffer) HDfree(buffer); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Pclose(dcpl_id); H5Pclose(dapl_id); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_h5d_get_access_plist() */ - /*------------------------------------------------------------------------- * Function: main * @@ -1353,13 +1423,13 @@ test_h5d_get_access_plist(hid_t fapl_id) int main(void) { - hid_t fapl_id_old = -1; /* file access properties (old format) */ - hid_t fapl_id_new = -1; /* file access properties (new format) */ - hid_t fid = -1; /* file for test_1* functions */ - hid_t gid = -1; /* group to emit diagnostics */ - char filename[1024]; /* file name for test_1* funcs */ - unsigned latest_format; /* default or latest file format */ - int nerrors = 0; /* number of errors */ + hid_t fapl_id_old = -1; /* file access properties (old format) */ + hid_t fapl_id_new = -1; /* file access properties (new format) */ + hid_t fid = -1; /* file for test_1* functions */ + hid_t gid = -1; /* group to emit diagnostics */ + char filename[1024]; /* file name for test_1* funcs */ + unsigned latest_format; /* default or latest file format */ + int nerrors = 0; /* number of errors */ h5_reset(); @@ -1368,9 +1438,9 @@ main(void) h5_fixname(EXT_FNAME[0], fapl_id_old, filename, sizeof(filename)); /* Copy and set up a fapl for the latest file format */ - if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) + if ((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) FAIL_STACK_ERROR - if(H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* The file format doesn't matter for this test */ @@ -1378,11 +1448,11 @@ main(void) HDputs(""); /* Test with old & new format groups */ - for(latest_format = FALSE; latest_format <= TRUE; latest_format++) { + for (latest_format = FALSE; latest_format <= TRUE; latest_format++) { hid_t current_fapl_id = -1; /* Set the fapl for different file formats */ - if(latest_format) { + if (latest_format) { HDputs("\nTesting with the latest file format:"); current_fapl_id = fapl_id_new; } @@ -1392,13 +1462,14 @@ main(void) } /* Create the common file used by some of the tests */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, current_fapl_id)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, current_fapl_id)) < 0) FAIL_STACK_ERROR /* Create a group that will be used in the file set read test */ - if((gid = H5Gcreate2(fid, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR /* These tests use a common file */ nerrors += test_non_extendible(fid); @@ -1423,19 +1494,22 @@ main(void) nerrors += (h5_verify_cached_stabs(EXT_FNAME, current_fapl_id) < 0 ? 1 : 0); /* Close the common file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR } /* end for old and new format */ - if(nerrors > 0) goto error; + if (nerrors > 0) + goto error; /* Close the new ff fapl. h5_cleanup will take care of the old ff fapl */ - if(H5Pclose(fapl_id_new) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_id_new) < 0) + FAIL_STACK_ERROR HDputs("All external storage tests passed."); /* Clean up files used by file set tests */ - if(h5_cleanup(EXT_FNAME, fapl_id_old)) { + if (h5_cleanup(EXT_FNAME, fapl_id_old)) { HDremove("extern_1r.raw"); HDremove("extern_2r.raw"); HDremove("extern_3r.raw"); @@ -1452,14 +1526,15 @@ main(void) return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fapl_id_old); H5Pclose(fapl_id_new); H5Gclose(gid); - } H5E_END_TRY; + } + H5E_END_TRY; nerrors = MAX(1, nerrors); HDprintf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); return EXIT_FAILURE; } /* end main() */ - diff --git a/test/external_common.c b/test/external_common.c index a9e600b..f4dbb4e 100644 --- a/test/external_common.c +++ b/test/external_common.c @@ -20,7 +20,6 @@ #include "external_common.h" - /*------------------------------------------------------------------------- * Function: reset_raw_data_files * @@ -37,51 +36,51 @@ herr_t reset_raw_data_files(hbool_t is_env) { - int fd = 0; /* external file descriptor */ - size_t i, j; /* iterators */ - hssize_t n; /* bytes of I/O */ - char filename[1024]; /* file name */ - int data[PART_SIZE]; /* raw data buffer */ - uint8_t *garbage = NULL; /* buffer of garbage data */ - size_t garbage_count; /* size of garbage buffer */ - size_t garbage_bytes; /* # of garbage bytes written to file */ + int fd = 0; /* external file descriptor */ + size_t i, j; /* iterators */ + hssize_t n; /* bytes of I/O */ + char filename[1024]; /* file name */ + int data[PART_SIZE]; /* raw data buffer */ + uint8_t *garbage = NULL; /* buffer of garbage data */ + size_t garbage_count; /* size of garbage buffer */ + size_t garbage_bytes; /* # of garbage bytes written to file */ /* Set up garbage buffer */ garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; - if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) + if (NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) goto error; - for(i = 0; i < garbage_count; i++) + for (i = 0; i < garbage_count; i++) garbage[i] = 0xFF; /* The *r files are pre-filled with data and are used to * verify that read operations work correctly. */ - for(i = 0; i < N_EXT_FILES; i++) { + for (i = 0; i < N_EXT_FILES; i++) { /* Open file */ - if(is_env) + if (is_env) HDsprintf(filename, "extern_env_%lur.raw", (unsigned long)i + 1); else HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write garbage data to the file. This allows us to test the * the ability to set an offset in the raw data file. */ garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) + n = HDwrite(fd, garbage, garbage_bytes); + if (n < 0 || (size_t)n != garbage_bytes) goto error; /* Fill array with data */ - for(j = 0; j < PART_SIZE; j++) { + for (j = 0; j < PART_SIZE; j++) { data[j] = (int)(i * 25 + j); } /* end for */ /* Write raw data to the file. */ n = HDwrite(fd, data, sizeof(data)); - if(n != sizeof(data)) + if (n != sizeof(data)) goto error; /* Close this file */ @@ -93,22 +92,22 @@ reset_raw_data_files(hbool_t is_env) * used to verify that write operations work correctly. The individual * tests fill in the actual data. */ - for(i = 0; i < N_EXT_FILES; i++) { + for (i = 0; i < N_EXT_FILES; i++) { /* Open file */ - if(is_env) + if (is_env) HDsprintf(filename, "extern_env_%luw.raw", (unsigned long)i + 1); else HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Write garbage data to the file. This allows us to test the * the ability to set an offset in the raw data file. */ garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) + n = HDwrite(fd, garbage, garbage_bytes); + if (n < 0 || (size_t)n != garbage_bytes) goto error; /* Close this file */ @@ -119,9 +118,9 @@ reset_raw_data_files(hbool_t is_env) return SUCCEED; error: - if(fd) + if (fd) HDclose(fd); - if(garbage) + if (garbage) HDfree(garbage); return FAIL; } diff --git a/test/external_common.h b/test/external_common.h index f02652b..be5094f 100644 --- a/test/external_common.h +++ b/test/external_common.h @@ -26,11 +26,10 @@ /* A similar collection of files is used for the tests that * perform file I/O. */ -#define N_EXT_FILES 4 -#define PART_SIZE 25 -#define TOTAL_SIZE 100 -#define GARBAGE_PER_FILE 10 - +#define N_EXT_FILES 4 +#define PART_SIZE 25 +#define TOTAL_SIZE 100 +#define GARBAGE_PER_FILE 10 #ifdef __cplusplus extern "C" { diff --git a/test/external_env.c b/test/external_env.c index e9c7635..a5c2bc0 100644 --- a/test/external_env.c +++ b/test/external_env.c @@ -16,11 +16,7 @@ */ #include "external_common.h" -static const char *EXT_ENV_FNAME[] = { - "extern_env_dir/env_file_1", - NULL -}; - +static const char *EXT_ENV_FNAME[] = {"extern_env_dir/env_file_1", NULL}; /*------------------------------------------------------------------------- * Function: test_path_env @@ -46,90 +42,96 @@ static const char *EXT_ENV_FNAME[] = { static int test_path_env(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dapl = -1; /* dataset access property list */ - hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counters */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ - char buffer[1024]; /* buffer to read efile_prefix */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dapl = -1; /* dataset access property list */ + hid_t dset = -1; /* dataset */ + size_t i; /* miscellaneous counters */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size; /* current data space size */ + char buffer[1024]; /* buffer to read efile_prefix */ TESTING("prefix in HDF5_EXTFILE_PREFIX"); - if(HDmkdir("extern_env_dir", (mode_t)0755) < 0 && errno != EEXIST) + if (HDmkdir("extern_env_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; h5_fixname(EXT_ENV_FNAME[0], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Reset the raw data files */ - if(reset_raw_data_files(TRUE) < 0) + if (reset_raw_data_files(TRUE) < 0) TEST_ERROR /* Create the dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) + if (NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) TEST_ERROR - for(i = 0; i < N_EXT_FILES; i++) { - HDsnprintf(filename, sizeof(filename), "..%sextern_env_%dr.raw", H5_DIR_SEPS, (int) i + 1); - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + for (i = 0; i < N_EXT_FILES; i++) { + HDsnprintf(filename, sizeof(filename), "..%sextern_env_%dr.raw", H5_DIR_SEPS, (int)i + 1); + if (H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR } /* end for */ cur_size = TOTAL_SIZE; - if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) + if ((space = H5Screate_simple(1, &cur_size, NULL)) < 0) FAIL_STACK_ERROR - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ - if(H5Pset_efile_prefix(dapl, "someprefix") < 0) + if (H5Pset_efile_prefix(dapl, "someprefix") < 0) FAIL_STACK_ERROR - if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) + if (H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) FAIL_STACK_ERROR - if(HDstrcmp(buffer, "someprefix") != 0) + if (HDstrcmp(buffer, "someprefix") != 0) FAIL_PUTS_ERROR("efile prefix not set correctly"); /* Create dataset */ - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0) + if ((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0) FAIL_STACK_ERROR /* Read the entire dataset and compare with the original */ HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + if (H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) FAIL_STACK_ERROR - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) + for (i = 0; i < TOTAL_SIZE; i++) + if (whole[i] != (signed)i) FAIL_PUTS_ERROR("Incorrect value(s) read."); - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dapl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl); H5Dclose(dset); H5Pclose(dcpl); H5Sclose(space); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_path_env() */ - /*------------------------------------------------------------------------- * Function: main * @@ -145,12 +147,12 @@ error: int main(void) { - hid_t fapl_id_old = -1; /* file access properties (old format) */ - hid_t fapl_id_new = -1; /* file access properties (new format) */ - hid_t fid = -1; /* file for test_1* functions */ - hid_t gid = -1; /* group to emit diagnostics */ - unsigned latest_format; /* default or latest file format */ - int nerrors = 0; /* number of errors */ + hid_t fapl_id_old = -1; /* file access properties (old format) */ + hid_t fapl_id_new = -1; /* file access properties (new format) */ + hid_t fid = -1; /* file for test_1* functions */ + hid_t gid = -1; /* group to emit diagnostics */ + unsigned latest_format; /* default or latest file format */ + int nerrors = 0; /* number of errors */ h5_reset(); @@ -158,17 +160,17 @@ main(void) fapl_id_old = h5_fileaccess(); /* Copy and set up a fapl for the latest file format */ - if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) + if ((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) FAIL_STACK_ERROR - if(H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Test with old & new format groups */ - for(latest_format = FALSE; latest_format <= TRUE; latest_format++) { + for (latest_format = FALSE; latest_format <= TRUE; latest_format++) { hid_t current_fapl_id = -1; /* Set the fapl for different file formats */ - if(latest_format) { + if (latest_format) { HDputs("\nTesting with the latest file format:"); current_fapl_id = fapl_id_new; } /* end if */ @@ -180,15 +182,17 @@ main(void) nerrors += test_path_env(current_fapl_id); } /* end for */ - if(nerrors > 0) goto error; + if (nerrors > 0) + goto error; /* Close the new ff fapl. h5_cleanup will take care of the old ff fapl */ - if(H5Pclose(fapl_id_new) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_id_new) < 0) + FAIL_STACK_ERROR HDputs("All external storage tests passed."); /* Clean up files used by file set tests */ - if(h5_cleanup(EXT_ENV_FNAME, fapl_id_old)) { + if (h5_cleanup(EXT_ENV_FNAME, fapl_id_old)) { HDremove("extern_env_1r.raw"); HDremove("extern_env_2r.raw"); HDremove("extern_env_3r.raw"); @@ -205,14 +209,15 @@ main(void) return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fapl_id_old); H5Pclose(fapl_id_new); H5Gclose(gid); - } H5E_END_TRY; + } + H5E_END_TRY; nerrors = MAX(1, nerrors); HDprintf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); return EXIT_FAILURE; } /* end main() */ - diff --git a/test/external_fname.h b/test/external_fname.h index c5111b6..05433e6 100644 --- a/test/external_fname.h +++ b/test/external_fname.h @@ -23,15 +23,7 @@ /* Include test header files */ #include "h5test.h" -static const char *EXT_FNAME[] = { - "extern_1", - "extern_2", - "extern_3", - "extern_4", - "extern_dir/file_1", - "extern_5", - NULL -}; +static const char *EXT_FNAME[] = {"extern_1", "extern_2", "extern_3", "extern_4", + "extern_dir/file_1", "extern_5", NULL}; #endif /* _EXTERNAL_FNAME_H */ - diff --git a/test/farray.c b/test/farray.c index 2cc79a1..139bdb0 100644 --- a/test/farray.c +++ b/test/farray.c @@ -20,64 +20,61 @@ * This file needs to access private datatypes from the H5FA package. * This file also needs to access the fixed array testing code. */ -#define H5FA_FRIEND /*suppress error about including H5FApkg */ +#define H5FA_FRIEND /*suppress error about including H5FApkg */ #define H5FA_TESTING -#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FApkg.h" /* Fixed Arrays */ /* Other private headers that this test requires */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Iprivate.h" /* IDs */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Local macros */ /* Max. testfile name length */ -#define FARRAY_FILENAME_LEN 1024 +#define FARRAY_FILENAME_LEN 1024 /* Fixed array creation values */ -#define ELMT_SIZE sizeof(uint64_t) -#define MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* 2^10 = 1024 elements per data block page */ +#define ELMT_SIZE sizeof(uint64_t) +#define MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* 2^10 = 1024 elements per data block page */ /* Testing # of elements in the Fixed Array */ -#define TEST_NELMTS 20000 +#define TEST_NELMTS 20000 /* Convenience macros for computing earray state */ -#define FA_HDR_SIZE 28 /* hard-coded */ -#define DBLOCK_PREFIX 18 /* hard-coded */ +#define FA_HDR_SIZE 28 /* hard-coded */ +#define DBLOCK_PREFIX 18 /* hard-coded */ /* 4 giga-elements: max chunk size */ -#define MAX_NELMTS ((unsigned long long)4*1024*1024*1024) /* 4 giga-elements */ +#define MAX_NELMTS ((unsigned long long)4 * 1024 * 1024 * 1024) /* 4 giga-elements */ /* Iterator parameter values */ -#define FA_CYC_COUNT 4 - +#define FA_CYC_COUNT 4 /* Local typedefs */ /* Types of tests to perform */ typedef enum { - FARRAY_TEST_NORMAL, /* "Normal" test, with no testing parameters set */ - FARRAY_TEST_REOPEN, /* Set the reopen_array flag */ - FARRAY_TEST_NTESTS /* The number of test types, must be last */ + FARRAY_TEST_NORMAL, /* "Normal" test, with no testing parameters set */ + FARRAY_TEST_REOPEN, /* Set the reopen_array flag */ + FARRAY_TEST_NTESTS /* The number of test types, must be last */ } farray_test_type_t; /* Types of iteration to perform */ typedef enum { - FARRAY_ITER_FW, /* "Forward" iteration */ - FARRAY_ITER_RV, /* "Reverse" iteration */ - FARRAY_ITER_RND, /* "Random" iteration */ - FARRAY_ITER_CYC, /* "Cyclic" iteration */ - FARRAY_ITER_NITERS /* The number of iteration types, must be last */ + FARRAY_ITER_FW, /* "Forward" iteration */ + FARRAY_ITER_RV, /* "Reverse" iteration */ + FARRAY_ITER_RND, /* "Random" iteration */ + FARRAY_ITER_CYC, /* "Cyclic" iteration */ + FARRAY_ITER_NITERS /* The number of iteration types, must be last */ } farray_iter_type_t; - /* Fixed array state information */ typedef struct farray_state_t { - hsize_t hdr_size; /* Size of header */ - hsize_t dblk_size; /* Size of data block */ - hsize_t nelmts; /* # of elements */ + hsize_t hdr_size; /* Size of header */ + hsize_t dblk_size; /* Size of data block */ + hsize_t nelmts; /* # of elements */ } farray_state_t; /* Forward decl. */ @@ -86,25 +83,20 @@ typedef struct farray_test_param_t farray_test_param_t; /* Fixed array iterator class */ typedef struct farray_iter_t { void *(*init)(const H5FA_create_t *cparam, const farray_test_param_t *tparam, - hsize_t cnt); /* Initialize/allocate iterator private info */ - hssize_t (*next)(void *info); /* Get the next element to test */ - herr_t (*term)(void *info); /* Shutdown/free iterator private info */ + hsize_t cnt); /* Initialize/allocate iterator private info */ + hssize_t (*next)(void *info); /* Get the next element to test */ + herr_t (*term)(void *info); /* Shutdown/free iterator private info */ } farray_iter_t; - /* Testing parameters */ struct farray_test_param_t { - farray_test_type_t reopen_array; /* Whether to re-open the array during the test */ - hsize_t nelmts; /* # of elements to set for the fixed array */ - const farray_iter_t *fiter; /* Iterator to use for this test */ + farray_test_type_t reopen_array; /* Whether to re-open the array during the test */ + hsize_t nelmts; /* # of elements to set for the fixed array */ + const farray_iter_t *fiter; /* Iterator to use for this test */ }; /* Local variables */ -const char *FILENAME[] = { - "farray", - "farray_tmp", - NULL -}; +const char *FILENAME[] = {"farray", "farray_tmp", NULL}; /* Filename to use for all tests */ char filename_g[FARRAY_FILENAME_LEN]; @@ -112,7 +104,6 @@ char filename_g[FARRAY_FILENAME_LEN]; /* Empty file size */ h5_stat_size_t empty_size_g; - /*------------------------------------------------------------------------- * Function: init_cparam * @@ -128,15 +119,14 @@ init_cparam(H5FA_create_t *cparam, farray_test_param_t *tparam) /* Wipe out background */ HDmemset(cparam, 0, sizeof(*cparam)); - cparam->cls = H5FA_CLS_TEST; - cparam->raw_elmt_size = ELMT_SIZE; - cparam->max_dblk_page_nelmts_bits = MAX_DBLOCK_PAGE_NELMTS_BITS; - cparam->nelmts = tparam->nelmts; + cparam->cls = H5FA_CLS_TEST; + cparam->raw_elmt_size = ELMT_SIZE; + cparam->max_dblk_page_nelmts_bits = MAX_DBLOCK_PAGE_NELMTS_BITS; + cparam->nelmts = tparam->nelmts; return SUCCEED; } /* init_cparam() */ - /*------------------------------------------------------------------------- * Function: create_file * @@ -168,7 +158,6 @@ error: return FAIL; } /* create_file() */ - /*------------------------------------------------------------------------- * Function: check_stats * @@ -181,7 +170,7 @@ error: static herr_t check_stats(const H5FA_t *fa, const farray_state_t *state) { - H5FA_stat_t farray_stats; /* Statistics about the array */ + H5FA_stat_t farray_stats; /* Statistics about the array */ /* Get statistics for fixed array and verify they are correct */ if (H5FA_get_stats(fa, &farray_stats) < 0) @@ -189,20 +178,20 @@ check_stats(const H5FA_t *fa, const farray_state_t *state) /* Compare information */ if (farray_stats.hdr_size != state->hdr_size) { - HDfprintf(stdout, "farray_stats.hdr_size = %Hu, state->hdr_size = %Hu\n", - farray_stats.hdr_size, state->hdr_size); + HDfprintf(stdout, "farray_stats.hdr_size = %Hu, state->hdr_size = %Hu\n", farray_stats.hdr_size, + state->hdr_size); TEST_ERROR } if (farray_stats.dblk_size != state->dblk_size) { - HDfprintf(stdout, "farray_stats.dblk_size = %Hu, state->dblk_size = %Hu\n", - farray_stats.dblk_size, state->dblk_size); + HDfprintf(stdout, "farray_stats.dblk_size = %Hu, state->dblk_size = %Hu\n", farray_stats.dblk_size, + state->dblk_size); TEST_ERROR } if (farray_stats.nelmts != state->nelmts) { - HDfprintf(stdout, "farray_stats.nelmts = %Hu, state->nelmts = %Hu\n", - farray_stats.nelmts, state->nelmts); + HDfprintf(stdout, "farray_stats.nelmts = %Hu, state->nelmts = %Hu\n", farray_stats.nelmts, + state->nelmts); TEST_ERROR } @@ -213,7 +202,6 @@ error: return FAIL; } /* check_stats() */ - /*------------------------------------------------------------------------- * Function: set_fa_state * @@ -226,7 +214,7 @@ error: static herr_t set_fa_state(const H5FA_create_t *cparam, farray_state_t *state) { - size_t dblk_page_nelmts; /* # of elements per page */ + size_t dblk_page_nelmts; /* # of elements per page */ /* Sanity check */ HDassert(cparam); @@ -234,16 +222,16 @@ set_fa_state(const H5FA_create_t *cparam, farray_state_t *state) /* Compute the state of the fixed array */ state->hdr_size = FA_HDR_SIZE; - state->nelmts = cparam->nelmts; + state->nelmts = cparam->nelmts; dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; if (state->nelmts > dblk_page_nelmts) { - size_t npages = (size_t)(((state->nelmts + dblk_page_nelmts) - 1) / dblk_page_nelmts); - size_t dblk_page_init_size = (npages + 7) / 8; - hsize_t checksum_size = npages * 4; + size_t npages = (size_t)(((state->nelmts + dblk_page_nelmts) - 1) / dblk_page_nelmts); + size_t dblk_page_init_size = (npages + 7) / 8; + hsize_t checksum_size = npages * 4; - state->dblk_size = DBLOCK_PREFIX + dblk_page_init_size + checksum_size + - state->nelmts * cparam->raw_elmt_size; + state->dblk_size = + DBLOCK_PREFIX + dblk_page_init_size + checksum_size + state->nelmts * cparam->raw_elmt_size; } else state->dblk_size = DBLOCK_PREFIX + state->nelmts * cparam->raw_elmt_size; @@ -251,7 +239,6 @@ set_fa_state(const H5FA_create_t *cparam, farray_state_t *state) return SUCCEED; } /* end set_fa_state() */ - /*------------------------------------------------------------------------- * Function: reopen_file * @@ -262,8 +249,8 @@ set_fa_state(const H5FA_create_t *cparam, farray_state_t *state) *------------------------------------------------------------------------- */ static int -reopen_file(hid_t *fid, H5F_t **f, hid_t fapl_id, - H5FA_t **fa, haddr_t fa_addr, const farray_test_param_t *tparam) +reopen_file(hid_t *fid, H5F_t **f, hid_t fapl_id, H5FA_t **fa, haddr_t fa_addr, + const farray_test_param_t *tparam) { /* Check for closing & re-opening the array */ /* (actually will close & re-open the file as well) */ @@ -281,7 +268,7 @@ reopen_file(hid_t *fid, H5F_t **f, hid_t fapl_id, if (H5Fclose(*fid) < 0) FAIL_STACK_ERROR *fid = H5I_INVALID_HID; - *f = NULL; + *f = NULL; } /* Re-open the file */ @@ -309,7 +296,6 @@ error: return FAIL; } /* reopen_file() */ - /*------------------------------------------------------------------------- * Function: create_array * @@ -320,10 +306,9 @@ error: *------------------------------------------------------------------------- */ static herr_t -create_array(H5F_t *f, const H5FA_create_t *cparam, - H5FA_t **fa, haddr_t *fa_addr) +create_array(H5F_t *f, const H5FA_create_t *cparam, H5FA_t **fa, haddr_t *fa_addr) { - farray_state_t state; /* State of extensible array */ + farray_state_t state; /* State of extensible array */ /* Create array */ if (NULL == (*fa = H5FA_create(f, cparam, NULL))) @@ -337,8 +322,8 @@ create_array(H5F_t *f, const H5FA_create_t *cparam, /* Check array stats */ HDmemset(&state, 0, sizeof(state)); - state.hdr_size = FA_HDR_SIZE; - state.nelmts = cparam->nelmts; + state.hdr_size = FA_HDR_SIZE; + state.nelmts = cparam->nelmts; if (check_stats(*fa, &state)) TEST_ERROR @@ -349,7 +334,6 @@ error: return FAIL; } /* create_array() */ - /*------------------------------------------------------------------------- * Function: verify_cparam * @@ -362,7 +346,7 @@ error: static herr_t verify_cparam(const H5FA_t *fa, const H5FA_create_t *cparam) { - H5FA_create_t test_cparam; /* Creation parameters for array */ + H5FA_create_t test_cparam; /* Creation parameters for array */ /* Retrieve creation parameters */ HDmemset(&test_cparam, 0, sizeof(H5FA_create_t)); @@ -380,7 +364,6 @@ error: return FAIL; } /* verify_cparam() */ - /*------------------------------------------------------------------------- * Function: finish * @@ -394,7 +377,7 @@ error: static herr_t finish(hid_t fid, hid_t fapl_id, H5F_t *f, H5FA_t *fa, haddr_t fa_addr) { - h5_stat_size_t file_size; /* File size, after deleting array */ + h5_stat_size_t file_size; /* File size, after deleting array */ /* Close the fixed array */ if (H5FA_close(fa) < 0) @@ -423,7 +406,6 @@ error: return FAIL; } /* finish() */ - /*------------------------------------------------------------------------- * Function: test_create * @@ -437,13 +419,13 @@ error: static unsigned test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSED *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FA_t *fa = NULL; /* Fixed array wrapper */ - haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FA_t *fa = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if (create_file(fapl, &file, &f) < 0) TEST_ERROR /* @@ -452,57 +434,63 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE TESTING("invalid fixed array creation parameters"); #ifndef NDEBUG -{ - H5FA_create_t test_cparam; /* Creation parameters for array */ - - /* Set invalid element size */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.raw_elmt_size = 0; - H5E_BEGIN_TRY { - fa = H5FA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(fa) { - /* Close opened fixed array */ - H5FA_close(fa); - fa = NULL; - - /* Indicate error */ - TEST_ERROR - } /* end if */ - - /* Set invalid max. # of elements bits */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = 0; - H5E_BEGIN_TRY { - fa = H5FA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(fa) { - /* Close opened fixed array */ - H5FA_close(fa); - fa = NULL; + { + H5FA_create_t test_cparam; /* Creation parameters for array */ + + /* Set invalid element size */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.raw_elmt_size = 0; + H5E_BEGIN_TRY + { + fa = H5FA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (fa) { + /* Close opened fixed array */ + H5FA_close(fa); + fa = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ + /* Indicate error */ + TEST_ERROR + } /* end if */ + + /* Set invalid max. # of elements bits */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.max_dblk_page_nelmts_bits = 0; + H5E_BEGIN_TRY + { + fa = H5FA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (fa) { + /* Close opened fixed array */ + H5FA_close(fa); + fa = NULL; - /* Set invalid max. # of elements */ - HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.nelmts = 0; - H5E_BEGIN_TRY { - fa = H5FA_create(f, &test_cparam, NULL); - } H5E_END_TRY; - if(fa) { - /* Close opened fixed array */ - H5FA_close(fa); - fa = NULL; + /* Indicate error */ + TEST_ERROR + } /* end if */ + + /* Set invalid max. # of elements */ + HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); + test_cparam.nelmts = 0; + H5E_BEGIN_TRY + { + fa = H5FA_create(f, &test_cparam, NULL); + } + H5E_END_TRY; + if (fa) { + /* Close opened fixed array */ + H5FA_close(fa); + fa = NULL; - /* Indicate error */ - TEST_ERROR - } /* end if */ + /* Indicate error */ + TEST_ERROR + } /* end if */ - PASSED(); -} -#else /* NDEBUG */ + PASSED(); + } +#else /* NDEBUG */ SKIPPED(); puts(" Not tested when assertions are disabled"); #endif /* NDEBUG */ @@ -513,7 +501,7 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE TESTING("fixed array creation"); /* Create array */ - if(create_array(f, cparam, &fa, &fa_addr) < 0) + if (create_array(f, cparam, &fa, &fa_addr) < 0) TEST_ERROR PASSED(); @@ -522,11 +510,11 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE TESTING("verify array creation parameters"); /* Verify the creation parameters */ - if(verify_cparam(fa, cparam) < 0) + if (verify_cparam(fa, cparam) < 0) TEST_ERROR /* Close array, delete array, close file & verify file is empty */ - if(finish(file, fapl, f, fa, fa_addr) < 0) + if (finish(file, fapl, f, fa, fa_addr) < 0) TEST_ERROR /* All tests passed */ @@ -535,16 +523,17 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE return 0; error: - H5E_BEGIN_TRY { - if(fa) + H5E_BEGIN_TRY + { + if (fa) H5FA_close(fa); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* end test_create() */ - /*------------------------------------------------------------------------- * Function: test_reopen * @@ -558,13 +547,13 @@ error: static unsigned test_reopen(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FA_t *fa = NULL; /* Fixed array wrapper */ - haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FA_t *fa = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if (create_file(fapl, &file, &f) < 0) TEST_ERROR /* @@ -573,27 +562,27 @@ test_reopen(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) TESTING("create, close & reopen fixed array"); /* Create array */ - if(create_array(f, cparam, &fa, &fa_addr) < 0) + if (create_array(f, cparam, &fa, &fa_addr) < 0) TEST_ERROR /* Close the fixed array */ - if(H5FA_close(fa) < 0) + if (H5FA_close(fa) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, NULL, HADDR_UNDEF, tparam) < 0) + if (reopen_file(&file, &f, fapl, NULL, HADDR_UNDEF, tparam) < 0) TEST_ERROR /* Re-open the array */ - if(NULL == (fa = H5FA_open(f, fa_addr, NULL))) + if (NULL == (fa = H5FA_open(f, fa_addr, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ - if(verify_cparam(fa, cparam) < 0) + if (verify_cparam(fa, cparam) < 0) TEST_ERROR /* Close array, delete array, close file & verify file is empty */ - if(finish(file, fapl, f, fa, fa_addr) < 0) + if (finish(file, fapl, f, fa, fa_addr) < 0) TEST_ERROR /* All tests passed */ @@ -602,16 +591,17 @@ test_reopen(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) return 0; error: - H5E_BEGIN_TRY { - if(fa) + H5E_BEGIN_TRY + { + if (fa) H5FA_close(fa); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_reopen() */ - /*------------------------------------------------------------------------- * Function: test_open_twice * @@ -625,13 +615,13 @@ error: static unsigned test_open_twice(hid_t fapl_id, H5FA_create_t *cparam, farray_test_param_t *tparam) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fid2 = H5I_INVALID_HID; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5F_t *f2 = NULL; /* Internal file object pointer */ - H5FA_t *fa = NULL; /* Fixed array wrapper */ - H5FA_t *fa2 = NULL; /* Fixed array wrapper */ - haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fid2 = H5I_INVALID_HID; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5F_t * f2 = NULL; /* Internal file object pointer */ + H5FA_t *fa = NULL; /* Fixed array wrapper */ + H5FA_t *fa2 = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ if (create_file(fapl_id, &fid, &f) < 0) @@ -701,19 +691,20 @@ test_open_twice(hid_t fapl_id, H5FA_create_t *cparam, farray_test_param_t *tpara return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fa) H5FA_close(fa); if (fa2) H5FA_close(fa2); H5Fclose(fid); H5Fclose(fid2); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_open_twice() */ - /*------------------------------------------------------------------------- * Function: test_open_twice_diff * @@ -732,16 +723,16 @@ error: static unsigned test_open_twice_diff(hid_t fapl_id, H5FA_create_t *cparam, farray_test_param_t *tparam) { - char filename_tmp[FARRAY_FILENAME_LEN]; /* Temporary file name */ - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fid2 = H5I_INVALID_HID; /* File ID */ - hid_t fid0 = H5I_INVALID_HID; /* File ID */ - hid_t fid00 = H5I_INVALID_HID; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5F_t *f2 = NULL; /* Internal file object pointer */ - H5FA_t *fa = NULL; /* Fixed array wrapper */ - H5FA_t *fa2 = NULL; /* Fixed array wrapper */ - haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + char filename_tmp[FARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fid2 = H5I_INVALID_HID; /* File ID */ + hid_t fid0 = H5I_INVALID_HID; /* File ID */ + hid_t fid00 = H5I_INVALID_HID; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5F_t * f2 = NULL; /* Internal file object pointer */ + H5FA_t *fa = NULL; /* Fixed array wrapper */ + H5FA_t *fa2 = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ /* Display testing message */ TESTING("open fixed array twice, through different file handles"); @@ -834,7 +825,8 @@ test_open_twice_diff(hid_t fapl_id, H5FA_create_t *cparam, farray_test_param_t * return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fa) H5FA_close(fa); if (fa2) @@ -843,12 +835,12 @@ error: H5Fclose(fid2); H5Fclose(fid0); H5Fclose(fid00); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_open_twice_diff() */ - /*------------------------------------------------------------------------- * Function: test_delete_open * @@ -862,15 +854,15 @@ error: static unsigned test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FA_t *fa = NULL; /* Fixed array wrapper */ - H5FA_t *fa2 = NULL; /* Fixed array wrapper */ - haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ - h5_stat_size_t file_size; /* File size, after deleting array */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FA_t * fa = NULL; /* Fixed array wrapper */ + H5FA_t * fa2 = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + h5_stat_size_t file_size; /* File size, after deleting array */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if (create_file(fapl, &file, &f) < 0) TEST_ERROR /* @@ -879,33 +871,35 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) TESTING("deleting open fixed array"); /* Create array */ - if(create_array(f, cparam, &fa, &fa_addr) < 0) + if (create_array(f, cparam, &fa, &fa_addr) < 0) TEST_ERROR /* Open the array again */ - if(NULL == (fa2 = H5FA_open(f, fa_addr, NULL))) + if (NULL == (fa2 = H5FA_open(f, fa_addr, NULL))) FAIL_STACK_ERROR /* Request that the array be deleted */ - if(H5FA_delete(f, fa_addr, NULL) < 0) + if (H5FA_delete(f, fa_addr, NULL) < 0) FAIL_STACK_ERROR /* Verify the creation parameters */ - if(verify_cparam(fa, cparam) < 0) + if (verify_cparam(fa, cparam) < 0) TEST_ERROR - if(verify_cparam(fa2, cparam) < 0) + if (verify_cparam(fa2, cparam) < 0) TEST_ERROR /* Close the second fixed array wrapper */ - if(H5FA_close(fa2) < 0) + if (H5FA_close(fa2) < 0) FAIL_STACK_ERROR fa2 = NULL; /* Try re-opening the array again (should fail, as array will be deleted) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fa2 = H5FA_open(f, fa_addr, NULL); - } H5E_END_TRY; - if(fa2) { + } + H5E_END_TRY; + if (fa2) { /* Close opened array */ H5FA_close(fa2); @@ -914,19 +908,21 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) } /* end if */ /* Close the first fixed array wrapper */ - if(H5FA_close(fa) < 0) + if (H5FA_close(fa) < 0) FAIL_STACK_ERROR fa = NULL; /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, NULL, HADDR_UNDEF, tparam) < 0) + if (reopen_file(&file, &f, fapl, NULL, HADDR_UNDEF, tparam) < 0) TEST_ERROR /* Try re-opening the array again (should fail, as array is now deleted) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fa = H5FA_open(f, fa_addr, NULL); - } H5E_END_TRY; - if(fa) { + } + H5E_END_TRY; + if (fa) { /* Close opened array */ H5FA_close(fa); @@ -935,15 +931,15 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename_g, fapl)) < 0) + if ((file_size = h5_get_file_size(filename_g, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size_g) + if (file_size != empty_size_g) TEST_ERROR /* All tests passed */ @@ -952,23 +948,24 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) return 0; error: - H5E_BEGIN_TRY { - if(fa) + H5E_BEGIN_TRY + { + if (fa) H5FA_close(fa); - if(fa2) + if (fa2) H5FA_close(fa2); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_delete_open() */ /* Fixed array iterator info for forward iteration */ typedef struct fiter_fw_t { - hsize_t idx; /* Index of next array location */ + hsize_t idx; /* Index of next array location */ } fiter_fw_t; - /*------------------------------------------------------------------------- * Function: fiter_fw_init * @@ -981,9 +978,9 @@ typedef struct fiter_fw_t { */ static void * fiter_fw_init(const H5FA_create_t H5_ATTR_UNUSED *cparam, const farray_test_param_t H5_ATTR_UNUSED *tparam, - hsize_t H5_ATTR_UNUSED cnt) + hsize_t H5_ATTR_UNUSED cnt) { - fiter_fw_t *fiter; /* Forward element iteration object */ + fiter_fw_t *fiter; /* Forward element iteration object */ /* Allocate space for the element iteration object */ fiter = (fiter_fw_t *)HDmalloc(sizeof(fiter_fw_t)); @@ -993,10 +990,9 @@ fiter_fw_init(const H5FA_create_t H5_ATTR_UNUSED *cparam, const farray_test_para fiter->idx = 0; /* Return iteration object */ - return(fiter); + return (fiter); } /* end fiter_fw_init() */ - /*------------------------------------------------------------------------- * Function: fiter_fw_next * @@ -1011,7 +1007,7 @@ static hssize_t fiter_fw_next(void *_fiter) { fiter_fw_t *fiter = (fiter_fw_t *)_fiter; - hssize_t ret_val; + hssize_t ret_val; /* Sanity check */ HDassert(fiter); @@ -1019,10 +1015,9 @@ fiter_fw_next(void *_fiter) /* Get the next array index to test */ ret_val = (hssize_t)fiter->idx++; - return(ret_val); + return (ret_val); } /* end fiter_fw_next() */ - /*------------------------------------------------------------------------- * Function: fiter_term * @@ -1042,22 +1037,21 @@ fiter_term(void *fiter) /* Free iteration object */ HDfree(fiter); - return(0); + return (0); } /* end fiter_term() */ /* Fixed array iterator class for forward iteration */ static const farray_iter_t fa_iter_fw = { - fiter_fw_init, /* Iterator init */ - fiter_fw_next, /* Next array index */ - fiter_term /* Iterator term */ + fiter_fw_init, /* Iterator init */ + fiter_fw_next, /* Next array index */ + fiter_term /* Iterator term */ }; /* Fixed array iterator info for reverse iteration */ typedef struct fiter_rv_t { - hsize_t idx; /* Index of next array location */ + hsize_t idx; /* Index of next array location */ } fiter_rv_t; - /*------------------------------------------------------------------------- * Function: fiter_rv_init * @@ -1070,9 +1064,9 @@ typedef struct fiter_rv_t { */ static void * fiter_rv_init(const H5FA_create_t *cparam, const farray_test_param_t H5_ATTR_UNUSED *tparam, - hsize_t H5_ATTR_UNUSED cnt) + hsize_t H5_ATTR_UNUSED cnt) { - fiter_rv_t *fiter; /* Reverse element iteration object */ + fiter_rv_t *fiter; /* Reverse element iteration object */ /* Allocate space for the element iteration object */ fiter = (fiter_rv_t *)HDmalloc(sizeof(fiter_rv_t)); @@ -1082,10 +1076,9 @@ fiter_rv_init(const H5FA_create_t *cparam, const farray_test_param_t H5_ATTR_UNU fiter->idx = cparam->nelmts - 1; /* Return iteration object */ - return(fiter); + return (fiter); } /* end fiter_rv_init() */ - /*------------------------------------------------------------------------- * Function: fiter_rv_next * @@ -1100,7 +1093,7 @@ static hssize_t fiter_rv_next(void *_fiter) { fiter_rv_t *fiter = (fiter_rv_t *)_fiter; - hssize_t ret_val; + hssize_t ret_val; /* Sanity check */ HDassert(fiter); @@ -1108,23 +1101,22 @@ fiter_rv_next(void *_fiter) /* Get the next array index to test */ ret_val = (hssize_t)fiter->idx--; - return(ret_val); + return (ret_val); } /* end fiter_rv_next() */ /* Fixed array iterator class for reverse iteration */ static const farray_iter_t fa_iter_rv = { - fiter_rv_init, /* Iterator init */ - fiter_rv_next, /* Next array index */ - fiter_term /* Iterator term */ + fiter_rv_init, /* Iterator init */ + fiter_rv_next, /* Next array index */ + fiter_term /* Iterator term */ }; /* Fixed array iterator info for random iteration */ typedef struct fiter_rnd_t { - hsize_t pos; /* Position in shuffled array */ - hsize_t *idx; /* Array of shuffled indices */ + hsize_t pos; /* Position in shuffled array */ + hsize_t *idx; /* Array of shuffled indices */ } fiter_rnd_t; - /*------------------------------------------------------------------------- * Function: fiter_rnd_init * @@ -1137,10 +1129,10 @@ typedef struct fiter_rnd_t { */ static void * fiter_rnd_init(const H5FA_create_t H5_ATTR_UNUSED *cparam, const farray_test_param_t H5_ATTR_UNUSED *tparam, - hsize_t cnt) + hsize_t cnt) { - fiter_rnd_t *fiter; /* Random element iteration object */ - size_t u; /* Local index variable */ + fiter_rnd_t *fiter; /* Random element iteration object */ + size_t u; /* Local index variable */ /* Allocate space for the element iteration object */ fiter = (fiter_rnd_t *)HDmalloc(sizeof(fiter_rnd_t)); @@ -1152,27 +1144,26 @@ fiter_rnd_init(const H5FA_create_t H5_ATTR_UNUSED *cparam, const farray_test_par /* Initialize reverse iteration info */ fiter->pos = 0; - for(u = 0; u < (size_t)cnt; u++) + for (u = 0; u < (size_t)cnt; u++) fiter->idx[u] = (hsize_t)u; /* Randomly shuffle array indices */ - if(cnt > 1) { - for(u = 0; u < (size_t)cnt; u++) { - size_t swap_idx; /* Location to swap with when shuffling */ - hsize_t temp_idx; /* Temporary index */ - - swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u; - temp_idx = fiter->idx[u]; - fiter->idx[u] = fiter->idx[swap_idx]; + if (cnt > 1) { + for (u = 0; u < (size_t)cnt; u++) { + size_t swap_idx; /* Location to swap with when shuffling */ + hsize_t temp_idx; /* Temporary index */ + + swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u; + temp_idx = fiter->idx[u]; + fiter->idx[u] = fiter->idx[swap_idx]; fiter->idx[swap_idx] = temp_idx; } /* end for */ - } /* end if */ + } /* end if */ /* Return iteration object */ - return(fiter); + return (fiter); } /* end fiter_rnd_init() */ - /*------------------------------------------------------------------------- * Function: fiter_rnd_next * @@ -1187,7 +1178,7 @@ static hssize_t fiter_rnd_next(void *_fiter) { fiter_rnd_t *fiter = (fiter_rnd_t *)_fiter; - hssize_t ret_val; + hssize_t ret_val; /* Sanity check */ HDassert(fiter); @@ -1196,10 +1187,9 @@ fiter_rnd_next(void *_fiter) ret_val = (hssize_t)fiter->idx[fiter->pos]; fiter->pos++; - return(ret_val); + return (ret_val); } /* end fiter_rnd_next() */ - /*------------------------------------------------------------------------- * Function: fiter_rnd_term * @@ -1225,24 +1215,23 @@ fiter_rnd_term(void *_fiter) /* Free iteration object */ HDfree(fiter); - return(0); + return (0); } /* end fiter_rnd_term() */ /* Fixed array iterator class for random iteration */ static const farray_iter_t fa_iter_rnd = { - fiter_rnd_init, /* Iterator init */ - fiter_rnd_next, /* Next array index */ - fiter_rnd_term /* Iterator term */ + fiter_rnd_init, /* Iterator init */ + fiter_rnd_next, /* Next array index */ + fiter_rnd_term /* Iterator term */ }; /* Fixed array iterator info for cyclic iteration */ typedef struct fiter_cyc_t { - hsize_t pos; /* Position in shuffled array */ - hsize_t cnt; /* # of elements to store */ - hsize_t cyc; /* Cycle of elements to choose from */ + hsize_t pos; /* Position in shuffled array */ + hsize_t cnt; /* # of elements to store */ + hsize_t cyc; /* Cycle of elements to choose from */ } fiter_cyc_t; - /*------------------------------------------------------------------------- * Function: fiter_cyc_init * @@ -1255,9 +1244,9 @@ typedef struct fiter_cyc_t { */ static void * fiter_cyc_init(const H5FA_create_t H5_ATTR_UNUSED *cparam, const farray_test_param_t H5_ATTR_UNUSED *tparam, - hsize_t cnt) + hsize_t cnt) { - fiter_cyc_t *fiter; /* Cyclic element iteration object */ + fiter_cyc_t *fiter; /* Cyclic element iteration object */ /* Allocate space for the element iteration object */ fiter = (fiter_cyc_t *)HDmalloc(sizeof(fiter_cyc_t)); @@ -1269,10 +1258,9 @@ fiter_cyc_init(const H5FA_create_t H5_ATTR_UNUSED *cparam, const farray_test_par fiter->cyc = 0; /* Return iteration object */ - return(fiter); + return (fiter); } /* end fiter_cyc_init() */ - /*------------------------------------------------------------------------- * Function: fiter_cyc_next * @@ -1287,7 +1275,7 @@ static hssize_t fiter_cyc_next(void *_fiter) { fiter_cyc_t *fiter = (fiter_cyc_t *)_fiter; - hssize_t ret_val; + hssize_t ret_val; /* Sanity check */ HDassert(fiter); @@ -1295,21 +1283,19 @@ fiter_cyc_next(void *_fiter) /* Get the next array index to test */ ret_val = (hssize_t)fiter->pos; fiter->pos += FA_CYC_COUNT; - if(fiter->pos >= fiter->cnt) + if (fiter->pos >= fiter->cnt) fiter->pos = ++fiter->cyc; - return(ret_val); + return (ret_val); } /* end fiter_cyc_next() */ - /* Fixed array iterator class for cyclic iteration */ static const farray_iter_t fa_iter_cyc = { - fiter_cyc_init, /* Iterator init */ - fiter_cyc_next, /* Next array index */ - fiter_term /* Iterator term */ + fiter_cyc_init, /* Iterator init */ + fiter_cyc_next, /* Next array index */ + fiter_term /* Iterator term */ }; - /*------------------------------------------------------------------------- * Function: check_elmt * @@ -1328,22 +1314,21 @@ check_elmt(void *_relmt, void *_welmt) uint64_t *relmt = (uint64_t *)_relmt; uint64_t *welmt = (uint64_t *)_welmt; - if(welmt == NULL) { /* check for fill value */ - if(*relmt != H5FA_TEST_FILL) + if (welmt == NULL) { /* check for fill value */ + if (*relmt != H5FA_TEST_FILL) TEST_ERROR } /* end if */ else { - if(*relmt != *welmt) + if (*relmt != *welmt) TEST_ERROR } /* end else */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end check_elmt() */ - /*------------------------------------------------------------------------- * Function: test_set_elmts * @@ -1356,21 +1341,21 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, - hsize_t nelmts, const char *test_str) +test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, hsize_t nelmts, + const char *test_str) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FA_t *fa = NULL; /* Fixed array wrapper */ - void *fiter_info; /* Fixed array iterator info */ - farray_state_t state; /* State of fixed array */ - uint64_t welmt; /* Element to write */ - uint64_t relmt; /* Element to read */ - hsize_t cnt; /* Count of array indices */ - hssize_t sidx; /* Index value of next element in the fixed array */ - hsize_t idx; /* Index value of next element in the fixed array */ - hsize_t fa_nelmts; /* # of elements in fixed array */ - haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FA_t * fa = NULL; /* Fixed array wrapper */ + void * fiter_info; /* Fixed array iterator info */ + farray_state_t state; /* State of fixed array */ + uint64_t welmt; /* Element to write */ + uint64_t relmt; /* Element to read */ + hsize_t cnt; /* Count of array indices */ + hssize_t sidx; /* Index value of next element in the fixed array */ + hsize_t idx; /* Index value of next element in the fixed array */ + hsize_t fa_nelmts; /* # of elements in fixed array */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ HDassert(nelmts); /* @@ -1379,111 +1364,110 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, TESTING("%s", test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if (create_file(fapl, &file, &f) < 0) TEST_ERROR /* Create array */ - if(create_array(f, cparam, &fa, &fa_addr) < 0) + if (create_array(f, cparam, &fa, &fa_addr) < 0) TEST_ERROR /* Verify the creation parameters */ - if(verify_cparam(fa, cparam) < 0) + if (verify_cparam(fa, cparam) < 0) TEST_ERROR /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, &fa, fa_addr, tparam) < 0) + if (reopen_file(&file, &f, fapl, &fa, fa_addr, tparam) < 0) TEST_ERROR - if(H5FA_get_nelmts(fa, &fa_nelmts) < 0) + if (H5FA_get_nelmts(fa, &fa_nelmts) < 0) FAIL_STACK_ERROR - if(nelmts > fa_nelmts) + if (nelmts > fa_nelmts) TEST_ERROR /* Verify array state */ HDmemset(&state, 0, sizeof(state)); - state.hdr_size = FA_HDR_SIZE; - state.nelmts = cparam->nelmts; + state.hdr_size = FA_HDR_SIZE; + state.nelmts = cparam->nelmts; state.dblk_size = 0; - if(check_stats(fa, &state)) + if (check_stats(fa, &state)) TEST_ERROR /* Get all elements from empty array */ /* Initialize iterator */ - if(NULL == (fiter_info = tparam->fiter->init(cparam, tparam, nelmts))) + if (NULL == (fiter_info = tparam->fiter->init(cparam, tparam, nelmts))) TEST_ERROR /* Get elements of array */ - for(cnt = 0; cnt < nelmts; cnt++) { + for (cnt = 0; cnt < nelmts; cnt++) { /* Get the array index */ - if((sidx = tparam->fiter->next(fiter_info)) < 0) + if ((sidx = tparam->fiter->next(fiter_info)) < 0) TEST_ERROR - idx = (hsize_t)sidx; + idx = (hsize_t)sidx; /* Retrieve element of array (not set yet) */ relmt = (uint64_t)0; - if(H5FA_get(fa, idx, &relmt) < 0) + if (H5FA_get(fa, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify that the retrieved is correct */ - if(check_elmt(&relmt, NULL)) + if (check_elmt(&relmt, NULL)) TEST_ERROR } /* end for */ /* Shutdown iterator */ - if(tparam->fiter->term(fiter_info) < 0) + if (tparam->fiter->term(fiter_info) < 0) TEST_ERROR - /* Set (& get) all elements from empty array */ /* Initialize iterator */ - if(NULL == (fiter_info = tparam->fiter->init(cparam, tparam, nelmts))) + if (NULL == (fiter_info = tparam->fiter->init(cparam, tparam, nelmts))) TEST_ERROR /* Set elements of array */ - for(cnt = 0; cnt < nelmts; cnt++) { + for (cnt = 0; cnt < nelmts; cnt++) { /* Get the array index */ - if((sidx = tparam->fiter->next(fiter_info)) < 0) + if ((sidx = tparam->fiter->next(fiter_info)) < 0) TEST_ERROR - idx = (hsize_t)sidx; + idx = (hsize_t)sidx; relmt = (uint64_t)0; - if(H5FA_get(fa, idx, &relmt) < 0) + if (H5FA_get(fa, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify that the retrieved element is correct */ - if(check_elmt(&relmt, NULL)) + if (check_elmt(&relmt, NULL)) TEST_ERROR /* Set element of array */ welmt = (uint64_t)7 + idx; - if(H5FA_set(fa, idx, &welmt) < 0) + if (H5FA_set(fa, idx, &welmt) < 0) FAIL_STACK_ERROR /* Retrieve element of array (set now) */ relmt = (uint64_t)0; - if(H5FA_get(fa, idx, &relmt) < 0) + if (H5FA_get(fa, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify that the retrieved element is correct */ - if(check_elmt(&relmt, &welmt)) + if (check_elmt(&relmt, &welmt)) TEST_ERROR } /* end for */ /* Verify array state */ HDmemset(&state, 0, sizeof(state)); set_fa_state(cparam, &state); - if(check_stats(fa, &state)) + if (check_stats(fa, &state)) TEST_ERROR /* Shutdown iterator */ - if(tparam->fiter->term(fiter_info) < 0) + if (tparam->fiter->term(fiter_info) < 0) TEST_ERROR /* Close array, delete array, close file & verify file is empty */ - if(finish(file, fapl, f, fa, fa_addr) < 0) + if (finish(file, fapl, f, fa, fa_addr) < 0) TEST_ERROR /* All tests passed */ @@ -1492,16 +1476,17 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, return 0; error: - H5E_BEGIN_TRY { - if(fa) + H5E_BEGIN_TRY + { + if (fa) H5FA_close(fa); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_set_elmts() */ - /*------------------------------------------------------------------------- * Function: test_skip_elmts * @@ -1514,19 +1499,19 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, - hsize_t skip_elmts, hbool_t check_rest, const char *test_str) +test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, hsize_t skip_elmts, + hbool_t check_rest, const char *test_str) { - hid_t file = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FA_t *fa = NULL; /* Extensible array wrapper */ - farray_state_t state; /* State of extensible array */ - uint64_t welmt; /* Element to write */ - uint64_t relmt; /* Element to read */ - hsize_t idx; /* Index value of element to get */ - hsize_t cnt; /* Count of array indices */ - hsize_t fa_nelmts; /* # of elements in fixed array */ - haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + hid_t file = -1; /* File ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FA_t * fa = NULL; /* Extensible array wrapper */ + farray_state_t state; /* State of extensible array */ + uint64_t welmt; /* Element to write */ + uint64_t relmt; /* Element to read */ + hsize_t idx; /* Index value of element to get */ + hsize_t cnt; /* Count of array indices */ + hsize_t fa_nelmts; /* # of elements in fixed array */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ /* * Display testing message @@ -1534,33 +1519,33 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, TESTING("%s", test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if (create_file(fapl, &file, &f) < 0) TEST_ERROR /* Create array */ - if(create_array(f, cparam, &fa, &fa_addr) < 0) + if (create_array(f, cparam, &fa, &fa_addr) < 0) TEST_ERROR /* Verify the creation parameters */ - if(verify_cparam(fa, cparam) < 0) + if (verify_cparam(fa, cparam) < 0) TEST_ERROR /* Check for closing & re-opening the file */ - if(reopen_file(&file, &f, fapl, &fa, fa_addr, tparam) < 0) + if (reopen_file(&file, &f, fapl, &fa, fa_addr, tparam) < 0) TEST_ERROR - if(H5FA_get_nelmts(fa, &fa_nelmts) < 0) + if (H5FA_get_nelmts(fa, &fa_nelmts) < 0) FAIL_STACK_ERROR - if(skip_elmts >= fa_nelmts) + if (skip_elmts >= fa_nelmts) TEST_ERROR /* Verify array state */ HDmemset(&state, 0, sizeof(state)); - state.hdr_size = FA_HDR_SIZE; - state.nelmts = cparam->nelmts; + state.hdr_size = FA_HDR_SIZE; + state.nelmts = cparam->nelmts; state.dblk_size = 0; - if(check_stats(fa, &state)) + if (check_stats(fa, &state)) TEST_ERROR /* Set (& get) element after skipping elements */ @@ -1568,49 +1553,49 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, /* Retrieve element of array (not set yet) */ relmt = (uint64_t)0; - if(H5FA_get(fa, idx, &relmt) < 0) + if (H5FA_get(fa, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify that the retrieved is correct */ - if(check_elmt(&relmt, NULL)) + if (check_elmt(&relmt, NULL)) TEST_ERROR /* Set element of array */ welmt = (uint64_t)7 + idx; - if(H5FA_set(fa, idx, &welmt) < 0) + if (H5FA_set(fa, idx, &welmt) < 0) FAIL_STACK_ERROR /* Verify array state */ HDmemset(&state, 0, sizeof(state)); set_fa_state(cparam, &state); - if(check_stats(fa, &state)) + if (check_stats(fa, &state)) TEST_ERROR /* Retrieve element of array (set now) */ relmt = (uint64_t)0; - if(H5FA_get(fa, idx, &relmt) < 0) + if (H5FA_get(fa, idx, &relmt) < 0) FAIL_STACK_ERROR /* Verify that the retrieved is correct */ - if(check_elmt(&relmt, &welmt)) + if (check_elmt(&relmt, &welmt)) TEST_ERROR - if(check_rest) { + if (check_rest) { /* Get unset elements of array */ - for(cnt = 0; cnt < skip_elmts; cnt++) { + for (cnt = 0; cnt < skip_elmts; cnt++) { /* Retrieve element of array (not set yet) */ relmt = (uint64_t)0; - if(H5FA_get(fa, cnt, &relmt) < 0) + if (H5FA_get(fa, cnt, &relmt) < 0) FAIL_STACK_ERROR /* Verify that the retrieved is correct */ - if(check_elmt(&relmt, NULL)) + if (check_elmt(&relmt, NULL)) TEST_ERROR } /* end for */ - } /* end if */ + } /* end if */ /* Close array, delete array, close file & verify file is empty */ - if(finish(file, fapl, f, fa, fa_addr) < 0) + if (finish(file, fapl, f, fa, fa_addr) < 0) TEST_ERROR /* All tests passed */ @@ -1619,16 +1604,17 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, return 0; error: - H5E_BEGIN_TRY { - if(fa) + H5E_BEGIN_TRY + { + if (fa) H5FA_close(fa); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* test_skip_elmts() */ - /*------------------------------------------------------------------------- * Function: main * @@ -1642,28 +1628,29 @@ error: int main(void) { - H5FA_create_t cparam; /* Creation parameters for fixed array */ - farray_test_param_t tparam; /* Testing parameters */ - farray_test_type_t curr_test; /* Current test being worked on */ - farray_iter_type_t curr_iter; /* Current iteration type being worked on */ - hid_t fapl = -1; /* File access property list for data files */ - unsigned nerrors = 0; /* Cumulative error count */ - time_t curr_time; /* Current time, for seeding random number generator */ - int ExpressMode; /* Test express value */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + H5FA_create_t cparam; /* Creation parameters for fixed array */ + farray_test_param_t tparam; /* Testing parameters */ + farray_test_type_t curr_test; /* Current test being worked on */ + farray_iter_type_t curr_iter; /* Current iteration type being worked on */ + hid_t fapl = -1; /* File access property list for data files */ + unsigned nerrors = 0; /* Cumulative error count */ + time_t curr_time; /* Current time, for seeding random number generator */ + int ExpressMode; /* Test express value */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Reset library */ h5_reset(); - fapl = h5_fileaccess(); + fapl = h5_fileaccess(); ExpressMode = GetTestExpress(); - if(ExpressMode > 1) + if (ExpressMode > 1) HDprintf("***Express test mode on. Some tests may be skipped\n"); /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g)); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Seed random #'s */ @@ -1672,29 +1659,29 @@ main(void) /* Create an empty file to retrieve size */ { - hid_t file; /* File ID */ + hid_t file; /* File ID */ - if((file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/no array */ - if((empty_size_g = h5_get_file_size(filename_g, fapl)) < 0) + if ((empty_size_g = h5_get_file_size(filename_g, fapl)) < 0) TEST_ERROR } /* Iterate over the testing parameters */ - for(curr_test = FARRAY_TEST_NORMAL; curr_test < FARRAY_TEST_NTESTS; curr_test++) { + for (curr_test = FARRAY_TEST_NORMAL; curr_test < FARRAY_TEST_NTESTS; curr_test++) { /* Initialize the testing parameters */ HDmemset(&tparam, 0, sizeof(tparam)); tparam.nelmts = TEST_NELMTS; /* Set appropriate testing parameters for each test */ - switch(curr_test) { + switch (curr_test) { /* "Normal" testing parameters */ case FARRAY_TEST_NORMAL: HDputs("Testing with NORMAL PARAMETERS"); @@ -1712,8 +1699,8 @@ main(void) goto error; } /* end switch */ - /* Initialize fixed array creation parameters */ - init_cparam(&cparam, &tparam); + /* Initialize fixed array creation parameters */ + init_cparam(&cparam, &tparam); /* Basic capability tests */ nerrors += test_create(fapl, &cparam, &tparam); @@ -1722,11 +1709,11 @@ main(void) nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); - /* Iterate over the type of capacity tests */ - for(curr_iter = FARRAY_ITER_FW; curr_iter < FARRAY_ITER_NITERS; curr_iter++) { + /* Iterate over the type of capacity tests */ + for (curr_iter = FARRAY_ITER_FW; curr_iter < FARRAY_ITER_NITERS; curr_iter++) { /* Set appropriate parameters for each type of iteration */ - switch(curr_iter) { + switch (curr_iter) { /* "Forward" testing parameters */ case FARRAY_ITER_FW: HDputs("Testing with forward iteration"); @@ -1759,16 +1746,20 @@ main(void) /* Basic capacity tests */ nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)1, "setting 1 element of the array"); - nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts/2), "setting half of the array's elements "); - nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)tparam.nelmts, "setting all the array elements"); + nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts / 2), + "setting half of the array's elements "); + nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)tparam.nelmts, + "setting all the array elements"); } /* end for */ /* Check skipping elements */ nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)1, TRUE, "skipping to first element"); - nerrors += test_skip_elmts(fapl, &cparam, &tparam, ((hsize_t)1 << cparam.max_dblk_page_nelmts_bits), TRUE, "skipping to first element in data block page"); - nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts - 1), TRUE, "skipping to last element"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, ((hsize_t)1 << cparam.max_dblk_page_nelmts_bits), + TRUE, "skipping to first element in data block page"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts - 1), TRUE, + "skipping to last element"); - /* Create Fixed Array */ + /* Create Fixed Array */ /* MAX_NELMTS succeeds on some platforms buy may fail on others: * * "H5FD_sec2_truncate(): unable to extend file properly" @@ -1779,21 +1770,23 @@ main(void) * * have both been seen. */ - tparam.nelmts = MAX_NELMTS/17; + tparam.nelmts = MAX_NELMTS / 17; init_cparam(&cparam, &tparam); /* Set the last element in the Fixed Array */ - nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts - 1), FALSE, "skipping to last element"); + nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(tparam.nelmts - 1), FALSE, + "skipping to last element"); } /* end for */ /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; - if(nerrors) + if (nerrors) goto error; HDputs("All fixed array tests passed."); @@ -1805,12 +1798,14 @@ main(void) error: HDputs("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/fheap.c b/test/fheap.c index b6d24f7..bfbb84c 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -20,160 +20,160 @@ * This file needs to access private datatypes from the H5HF package. * This file also needs to access the fractal heap testing code. */ -#define H5HF_FRIEND /*suppress error about including H5HFpkg */ +#define H5HF_FRIEND /*suppress error about including H5HFpkg */ #define H5HF_TESTING -#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5HFpkg.h" /* Fractal heaps */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING #include "H5Fpkg.h" /* Other private headers that this test requires */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VMprivate.h" /* Vectors and arrays */ /* Max. testfile name length */ -#define FHEAP_FILENAME_LEN 1024 +#define FHEAP_FILENAME_LEN 1024 /* Object size macros */ -#define SMALL_OBJ_SIZE1 10 -#define SMALL_OBJ_SIZE2 20 -#define NUM_FILL_OBJS 11 +#define SMALL_OBJ_SIZE1 10 +#define SMALL_OBJ_SIZE2 20 +#define NUM_FILL_OBJS 11 /* "Small" heap creation parameters */ -#define SMALL_DBLOCK_OVERHEAD 21 /* Overhead for direct blocks */ -#define SMALL_CHECKSUM_DBLOCKS TRUE /* Whether to checksum direct blocks */ -#define SMALL_MAN_WIDTH 4 /* Managed obj. table width */ -#define SMALL_MAN_START_BLOCK_SIZE 512 /* Managed obj. starting block size */ -#define SMALL_MAN_MAX_DIRECT_SIZE (64 * 1024) /* Managed obj. max. direct block size */ -#define SMALL_MAN_MAX_INDEX 32 /* Managed obj. # of bits for total heap size */ -#define SMALL_MAN_START_ROOT_ROWS 1 /* Managed obj. starting # of root indirect block rows */ -#define SMALL_ID_LEN 0 /* "Default" heap ID length */ -#define SMALL_STAND_SIZE (SMALL_MAN_MAX_DIRECT_SIZE - SMALL_DBLOCK_OVERHEAD) /* Standalone obj. min. size */ +#define SMALL_DBLOCK_OVERHEAD 21 /* Overhead for direct blocks */ +#define SMALL_CHECKSUM_DBLOCKS TRUE /* Whether to checksum direct blocks */ +#define SMALL_MAN_WIDTH 4 /* Managed obj. table width */ +#define SMALL_MAN_START_BLOCK_SIZE 512 /* Managed obj. starting block size */ +#define SMALL_MAN_MAX_DIRECT_SIZE (64 * 1024) /* Managed obj. max. direct block size */ +#define SMALL_MAN_MAX_INDEX 32 /* Managed obj. # of bits for total heap size */ +#define SMALL_MAN_START_ROOT_ROWS 1 /* Managed obj. starting # of root indirect block rows */ +#define SMALL_ID_LEN 0 /* "Default" heap ID length */ +#define SMALL_STAND_SIZE (SMALL_MAN_MAX_DIRECT_SIZE - SMALL_DBLOCK_OVERHEAD) /* Standalone obj. min. size */ /* "Large" heap creation parameters */ -#define LARGE_DBLOCK_OVERHEAD 21 /* Overhead for direct blocks */ - /* (coincidentally the same size as for small direct blocks) */ -#define LARGE_CHECKSUM_DBLOCKS FALSE /* Whether to checksum direct blocks */ -#define LARGE_MAN_WIDTH 32 /* Managed obj. table width */ -#define LARGE_MAN_START_BLOCK_SIZE 4096 /* Managed obj. starting block size */ -#define LARGE_MAN_MAX_DIRECT_SIZE (1024 * 1024) /* Managed obj. max. direct block size */ -#define LARGE_MAN_MAX_INDEX 64 /* Managed obj. # of bits for total heap size */ -#define LARGE_MAN_START_ROOT_ROWS 1 /* Managed obj. starting # of root indirect block rows */ -#define LARGE_ID_LEN 0 /* "Default" heap ID length */ -#define LARGE_STAND_SIZE (LARGE_MAN_MAX_DIRECT_SIZE - LARGE_DBLOCK_OVERHEAD) /* Standalone obj. min. size */ +#define LARGE_DBLOCK_OVERHEAD 21 /* Overhead for direct blocks */ + /* (coincidentally the same size as for small direct blocks) */ +#define LARGE_CHECKSUM_DBLOCKS FALSE /* Whether to checksum direct blocks */ +#define LARGE_MAN_WIDTH 32 /* Managed obj. table width */ +#define LARGE_MAN_START_BLOCK_SIZE 4096 /* Managed obj. starting block size */ +#define LARGE_MAN_MAX_DIRECT_SIZE (1024 * 1024) /* Managed obj. max. direct block size */ +#define LARGE_MAN_MAX_INDEX 64 /* Managed obj. # of bits for total heap size */ +#define LARGE_MAN_START_ROOT_ROWS 1 /* Managed obj. starting # of root indirect block rows */ +#define LARGE_ID_LEN 0 /* "Default" heap ID length */ +#define LARGE_STAND_SIZE (LARGE_MAN_MAX_DIRECT_SIZE - LARGE_DBLOCK_OVERHEAD) /* Standalone obj. min. size */ /* Define this macro to enable all insertion tests */ /* #define ALL_INSERT_TESTS */ /* Heap metadata macros */ -#define MAX_HEAP_ID_LEN 64 /* Max. # of bytes to use for heap ID */ -#define HEAP_ID_LEN 7 /* # of bytes to use for heap ID */ -#define SMALL_HEAP_ID_LEN 7 /* # of bytes to use for "small" heap's IDs */ -#define LARGE_HEAP_ID_LEN 12 /* # of bytes to use for "large" heap's IDs */ -#define HEAP_MAX_ROOT_ROWS(fh) H5HF_get_max_root_rows(fh) /* Max. # of rows in root indirect block */ -#define DTABLE_WIDTH(fh) H5HF_get_dtable_width_test(fh) /* Width of doubling table for heap */ -#define DTABLE_MAX_DROWS(fh) H5HF_get_dtable_max_drows_test(fh) /* Max. # of direct block rows in any indirect block */ -#define IBLOCK_MAX_DROWS(fh, pos) H5HF_get_iblock_max_drows_test(fh, pos) /* Max. # of direct block rows in a indirect block */ -#define DBLOCK_SIZE(fh, r) H5HF_get_dblock_size_test(fh, r) /* Size of a direct block in a given row */ -#define DBLOCK_FREE(fh, r) H5HF_get_dblock_free_test(fh, r) /* Free space in a direct block of a given row */ +#define MAX_HEAP_ID_LEN 64 /* Max. # of bytes to use for heap ID */ +#define HEAP_ID_LEN 7 /* # of bytes to use for heap ID */ +#define SMALL_HEAP_ID_LEN 7 /* # of bytes to use for "small" heap's IDs */ +#define LARGE_HEAP_ID_LEN 12 /* # of bytes to use for "large" heap's IDs */ +#define HEAP_MAX_ROOT_ROWS(fh) H5HF_get_max_root_rows(fh) /* Max. # of rows in root indirect block */ +#define DTABLE_WIDTH(fh) H5HF_get_dtable_width_test(fh) /* Width of doubling table for heap */ +#define DTABLE_MAX_DROWS(fh) \ + H5HF_get_dtable_max_drows_test(fh) /* Max. # of direct block rows in any indirect block */ +#define IBLOCK_MAX_DROWS(fh, pos) \ + H5HF_get_iblock_max_drows_test(fh, pos) /* Max. # of direct block rows in a indirect block */ +#define DBLOCK_SIZE(fh, r) H5HF_get_dblock_size_test(fh, r) /* Size of a direct block in a given row */ +#define DBLOCK_FREE(fh, r) H5HF_get_dblock_free_test(fh, r) /* Free space in a direct block of a given row \ + */ /* The number of settings for testing: page buffering, file space strategy and persisting free-space */ -#define NUM_PB_FS 6 -#define PAGE_BUFFER_PAGE_SIZE 4096 +#define NUM_PB_FS 6 +#define PAGE_BUFFER_PAGE_SIZE 4096 -const char *FILENAME[] = { - "fheap", - NULL -}; +const char *FILENAME[] = {"fheap", NULL}; /* Types of tests to perform */ typedef enum { - FHEAP_TEST_NORMAL, /* "Normal" test, with no testing parameters set */ - FHEAP_TEST_REOPEN, /* Set the reopen_heap flag */ - FHEAP_TEST_NTESTS /* The number of test types, must be last */ + FHEAP_TEST_NORMAL, /* "Normal" test, with no testing parameters set */ + FHEAP_TEST_REOPEN, /* Set the reopen_heap flag */ + FHEAP_TEST_NTESTS /* The number of test types, must be last */ } fheap_test_type_t; /* Order to delete objects */ typedef enum { - FHEAP_DEL_FORWARD, /* Delete objects from 0 -> nobjs */ - FHEAP_DEL_REVERSE, /* Delete objects from nobjs -> 0 */ - FHEAP_DEL_HEAP, /* Delete entire heap at once */ - FHEAP_DEL_NDIRS /* The number of different deletion orders, must be last */ + FHEAP_DEL_FORWARD, /* Delete objects from 0 -> nobjs */ + FHEAP_DEL_REVERSE, /* Delete objects from nobjs -> 0 */ + FHEAP_DEL_HEAP, /* Delete entire heap at once */ + FHEAP_DEL_NDIRS /* The number of different deletion orders, must be last */ } fheap_test_del_dir_t; /* Order to delete objects */ typedef enum { - FHEAP_DEL_DRAIN_ALL, /* Don't drain half of objects first */ - FHEAP_DEL_DRAIN_HALF, /* Don't drain half of objects first */ - FHEAP_DEL_DRAIN_N /* The number of different ways to drain, must be last */ + FHEAP_DEL_DRAIN_ALL, /* Don't drain half of objects first */ + FHEAP_DEL_DRAIN_HALF, /* Don't drain half of objects first */ + FHEAP_DEL_DRAIN_N /* The number of different ways to drain, must be last */ } fheap_test_del_drain_t; /* Size of objects for "bulk" filling heap blocks */ typedef enum { - FHEAP_TEST_FILL_LARGE, /* Fill heap blocks with "large" objects */ - FHEAP_TEST_FILL_SINGLE, /* Fill heap blocks with single object */ - FHEAP_TEST_FILL_N /* The number of different ways to test filling heap blocks, must be last */ + FHEAP_TEST_FILL_LARGE, /* Fill heap blocks with "large" objects */ + FHEAP_TEST_FILL_SINGLE, /* Fill heap blocks with single object */ + FHEAP_TEST_FILL_N /* The number of different ways to test filling heap blocks, must be last */ } fheap_test_fill_t; /* Whether to compress blocks (during random tests) */ typedef enum { - FHEAP_TEST_NO_COMPRESS, /* Don't compress direct blocks */ - FHEAP_TEST_COMPRESS, /* Compress direct blocks */ - FHEAP_TEST_COMP_N /* The number of different ways to test compressing heap blocks, must be last */ + FHEAP_TEST_NO_COMPRESS, /* Don't compress direct blocks */ + FHEAP_TEST_COMPRESS, /* Compress direct blocks */ + FHEAP_TEST_COMP_N /* The number of different ways to test compressing heap blocks, must be last */ } fheap_test_comp_t; /* Testing parameters */ typedef struct fheap_test_param_t { - fheap_test_type_t reopen_heap; /* Whether to re-open the heap during the test */ - fheap_test_del_dir_t del_dir; /* Whether to delete objects forward or reverse */ - fheap_test_del_drain_t drain_half; /* Whether to drain half of the objects & refill, when deleting objects */ - fheap_test_fill_t fill; /* How to "bulk" fill heap blocks */ - size_t actual_id_len; /* The actual length of heap IDs for a test */ - fheap_test_comp_t comp; /* Whether to compress the blocks or not */ - hid_t my_fcpl; /* File creation property list with file space strategy setting */ + fheap_test_type_t reopen_heap; /* Whether to re-open the heap during the test */ + fheap_test_del_dir_t del_dir; /* Whether to delete objects forward or reverse */ + fheap_test_del_drain_t + drain_half; /* Whether to drain half of the objects & refill, when deleting objects */ + fheap_test_fill_t fill; /* How to "bulk" fill heap blocks */ + size_t actual_id_len; /* The actual length of heap IDs for a test */ + fheap_test_comp_t comp; /* Whether to compress the blocks or not */ + hid_t my_fcpl; /* File creation property list with file space strategy setting */ } fheap_test_param_t; /* Heap state information */ typedef struct fheap_heap_state_t { - size_t man_nobjs; /* # of managed objects within heap */ - hsize_t man_size; /* Size of managed object heap */ - hsize_t man_alloc_size; /* Size of managed object heap allocated */ - hsize_t man_free_space; /* Managed object free space within heap */ - size_t huge_nobjs; /* # of 'huge' objects within heap */ - hsize_t huge_size; /* Size of 'huge' object heap */ - size_t tiny_nobjs; /* # of 'tiny' objects within heap */ - hsize_t tiny_size; /* Size of 'tiny' object heap */ + size_t man_nobjs; /* # of managed objects within heap */ + hsize_t man_size; /* Size of managed object heap */ + hsize_t man_alloc_size; /* Size of managed object heap allocated */ + hsize_t man_free_space; /* Managed object free space within heap */ + size_t huge_nobjs; /* # of 'huge' objects within heap */ + hsize_t huge_size; /* Size of 'huge' object heap */ + size_t tiny_nobjs; /* # of 'tiny' objects within heap */ + hsize_t tiny_size; /* Size of 'tiny' object heap */ } fheap_heap_state_t; /* Heap IDs to retain */ typedef struct fheap_heap_ids_t { - size_t num_ids; /* # of heap IDs in array */ - size_t alloc_ids; /* # of heap IDs allocated in array */ - unsigned char *ids; /* Array of object heap IDs */ - size_t *lens; /* Array of object lengths */ - size_t *offs; /* Array of object offsets (in global shared write buffer) */ + size_t num_ids; /* # of heap IDs in array */ + size_t alloc_ids; /* # of heap IDs allocated in array */ + unsigned char *ids; /* Array of object heap IDs */ + size_t * lens; /* Array of object lengths */ + size_t * offs; /* Array of object offsets (in global shared write buffer) */ } fheap_heap_ids_t; /* Local variables */ -unsigned char *shared_wobj_g; /* Pointer to shared write buffer for objects */ -unsigned char *shared_robj_g; /* Pointer to shared read buffer for objects */ -size_t shared_obj_size_g; /* Size of shared objects */ -unsigned char *shared_ids_g = NULL; /* Array of shared object heap IDs */ -size_t *shared_lens_g = NULL; /* Array of shared object lengths */ -size_t *shared_offs_g = NULL; /* Array of shared object offsets */ -size_t shared_alloc_ids_g = 0; /* # of shared heap IDs allocated in array */ +unsigned char *shared_wobj_g; /* Pointer to shared write buffer for objects */ +unsigned char *shared_robj_g; /* Pointer to shared read buffer for objects */ +size_t shared_obj_size_g; /* Size of shared objects */ +unsigned char *shared_ids_g = NULL; /* Array of shared object heap IDs */ +size_t * shared_lens_g = NULL; /* Array of shared object lengths */ +size_t * shared_offs_g = NULL; /* Array of shared object offsets */ +size_t shared_alloc_ids_g = 0; /* # of shared heap IDs allocated in array */ /* Local routines */ static int init_small_cparam(H5HF_create_t *cparam); static int init_large_cparam(H5HF_create_t *cparam); static int check_stats(const H5HF_t *fh, const fheap_heap_state_t *state); -static int del_objs(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids); +static int del_objs(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids); - /*------------------------------------------------------------------------- * Function: init_small_cparam * @@ -196,21 +196,20 @@ init_small_cparam(H5HF_create_t *cparam) HDmemset(cparam, 0, sizeof(H5HF_create_t)); /* General parameters */ - cparam->id_len = SMALL_ID_LEN; - cparam->max_man_size = SMALL_STAND_SIZE; + cparam->id_len = SMALL_ID_LEN; + cparam->max_man_size = SMALL_STAND_SIZE; cparam->checksum_dblocks = SMALL_CHECKSUM_DBLOCKS; /* Managed object doubling-table parameters */ - cparam->managed.width = SMALL_MAN_WIDTH; + cparam->managed.width = SMALL_MAN_WIDTH; cparam->managed.start_block_size = SMALL_MAN_START_BLOCK_SIZE; - cparam->managed.max_direct_size = SMALL_MAN_MAX_DIRECT_SIZE; - cparam->managed.max_index = SMALL_MAN_MAX_INDEX; - cparam->managed.start_root_rows = SMALL_MAN_START_ROOT_ROWS; + cparam->managed.max_direct_size = SMALL_MAN_MAX_DIRECT_SIZE; + cparam->managed.max_index = SMALL_MAN_MAX_INDEX; + cparam->managed.start_root_rows = SMALL_MAN_START_ROOT_ROWS; - return(0); + return (0); } /* init_small_cparam() */ - /*------------------------------------------------------------------------- * Function: init_large_cparam * @@ -233,21 +232,20 @@ init_large_cparam(H5HF_create_t *cparam) HDmemset(cparam, 0, sizeof(H5HF_create_t)); /* General parameters */ - cparam->id_len = LARGE_ID_LEN; - cparam->max_man_size = LARGE_STAND_SIZE; + cparam->id_len = LARGE_ID_LEN; + cparam->max_man_size = LARGE_STAND_SIZE; cparam->checksum_dblocks = LARGE_CHECKSUM_DBLOCKS; /* Managed object doubling-table parameters */ - cparam->managed.width = LARGE_MAN_WIDTH; + cparam->managed.width = LARGE_MAN_WIDTH; cparam->managed.start_block_size = LARGE_MAN_START_BLOCK_SIZE; - cparam->managed.max_direct_size = LARGE_MAN_MAX_DIRECT_SIZE; - cparam->managed.max_index = LARGE_MAN_MAX_INDEX; - cparam->managed.start_root_rows = LARGE_MAN_START_ROOT_ROWS; + cparam->managed.max_direct_size = LARGE_MAN_MAX_DIRECT_SIZE; + cparam->managed.max_index = LARGE_MAN_MAX_INDEX; + cparam->managed.start_root_rows = LARGE_MAN_START_ROOT_ROWS; - return(0); + return (0); } /* init_large_cparam() */ - /*------------------------------------------------------------------------- * Function: check_stats * @@ -265,52 +263,59 @@ init_large_cparam(H5HF_create_t *cparam) static int check_stats(const H5HF_t *fh, const fheap_heap_state_t *state) { - H5HF_stat_t heap_stats; /* Statistics about the heap */ + H5HF_stat_t heap_stats; /* Statistics about the heap */ /* Get statistics for heap and verify they are correct */ - if(H5HF_stat_info(fh, &heap_stats) < 0) + if (H5HF_stat_info(fh, &heap_stats) < 0) FAIL_STACK_ERROR - if(heap_stats.man_nobjs != state->man_nobjs) { - HDfprintf(stdout, "heap_stats.man_nobjs = %Hu, state->man_nobjs = %Zu\n", heap_stats.man_nobjs, state->man_nobjs); + if (heap_stats.man_nobjs != state->man_nobjs) { + HDfprintf(stdout, "heap_stats.man_nobjs = %Hu, state->man_nobjs = %Zu\n", heap_stats.man_nobjs, + state->man_nobjs); TEST_ERROR } /* end if */ - if(heap_stats.man_size != state->man_size) { - HDfprintf(stdout, "heap_stats.man_size = %Hu, state->man_size = %Hu\n", heap_stats.man_size, state->man_size); + if (heap_stats.man_size != state->man_size) { + HDfprintf(stdout, "heap_stats.man_size = %Hu, state->man_size = %Hu\n", heap_stats.man_size, + state->man_size); TEST_ERROR } /* end if */ - if(heap_stats.man_alloc_size != state->man_alloc_size) { - HDfprintf(stdout, "heap_stats.man_alloc_size = %Hu, state->man_alloc_size = %Hu\n", heap_stats.man_alloc_size, state->man_alloc_size); + if (heap_stats.man_alloc_size != state->man_alloc_size) { + HDfprintf(stdout, "heap_stats.man_alloc_size = %Hu, state->man_alloc_size = %Hu\n", + heap_stats.man_alloc_size, state->man_alloc_size); TEST_ERROR } /* end if */ - if(heap_stats.man_free_space != state->man_free_space) { - HDfprintf(stdout, "heap_stats.man_free_space = %Hu, state->man_free_space = %Hu\n", heap_stats.man_free_space, state->man_free_space); + if (heap_stats.man_free_space != state->man_free_space) { + HDfprintf(stdout, "heap_stats.man_free_space = %Hu, state->man_free_space = %Hu\n", + heap_stats.man_free_space, state->man_free_space); TEST_ERROR } /* end if */ - if(heap_stats.huge_nobjs != state->huge_nobjs) { - HDfprintf(stdout, "heap_stats.huge_nobjs = %Hu, state->huge_nobjs = %Zu\n", heap_stats.huge_nobjs, state->huge_nobjs); + if (heap_stats.huge_nobjs != state->huge_nobjs) { + HDfprintf(stdout, "heap_stats.huge_nobjs = %Hu, state->huge_nobjs = %Zu\n", heap_stats.huge_nobjs, + state->huge_nobjs); TEST_ERROR } /* end if */ - if(heap_stats.huge_size != state->huge_size) { - HDfprintf(stdout, "heap_stats.huge_size = %Hu, state->huge_size = %Hu\n", heap_stats.huge_size, state->huge_size); + if (heap_stats.huge_size != state->huge_size) { + HDfprintf(stdout, "heap_stats.huge_size = %Hu, state->huge_size = %Hu\n", heap_stats.huge_size, + state->huge_size); TEST_ERROR } /* end if */ - if(heap_stats.tiny_nobjs != state->tiny_nobjs) { - HDfprintf(stdout, "heap_stats.tiny_nobjs = %Hu, state->tiny_nobjs = %Zu\n", heap_stats.tiny_nobjs, state->tiny_nobjs); + if (heap_stats.tiny_nobjs != state->tiny_nobjs) { + HDfprintf(stdout, "heap_stats.tiny_nobjs = %Hu, state->tiny_nobjs = %Zu\n", heap_stats.tiny_nobjs, + state->tiny_nobjs); TEST_ERROR } /* end if */ - if(heap_stats.tiny_size != state->tiny_size) { - HDfprintf(stdout, "heap_stats.tiny_size = %Hu, state->tiny_size = %Hu\n", heap_stats.tiny_size, state->tiny_size); + if (heap_stats.tiny_size != state->tiny_size) { + HDfprintf(stdout, "heap_stats.tiny_size = %Hu, state->tiny_size = %Hu\n", heap_stats.tiny_size, + state->tiny_size); TEST_ERROR } /* end if */ /* All tests passed */ - return(0); + return (0); error: - return(1); + return (1); } /* check_stats() */ - /*------------------------------------------------------------------------- * Function: op_memcpy * @@ -331,10 +336,9 @@ op_memcpy(const void *obj, size_t obj_len, void *op_data) /* Make copy of the object */ HDmemcpy(op_data, obj, obj_len); - return(SUCCEED); + return (SUCCEED); } /* op_memcpy() */ - /*------------------------------------------------------------------------- * Function: add_obj * @@ -360,13 +364,12 @@ op_memcpy(const void *obj, size_t obj_len, void *op_data) *------------------------------------------------------------------------- */ static int -add_obj(H5HF_t *fh, size_t obj_off, - size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +add_obj(H5HF_t *fh, size_t obj_off, size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) { - unsigned char heap_id[MAX_HEAP_ID_LEN]; /* Heap ID for object inserted */ - unsigned char *obj; /* Buffer for object to insert */ - size_t id_len; /* Size of fractal heap IDs */ - size_t robj_size; /* Object size read in */ + unsigned char heap_id[MAX_HEAP_ID_LEN]; /* Heap ID for object inserted */ + unsigned char *obj; /* Buffer for object to insert */ + size_t id_len; /* Size of fractal heap IDs */ + size_t robj_size; /* Object size read in */ /* Sanity check */ HDassert(fh); @@ -375,27 +378,27 @@ add_obj(H5HF_t *fh, size_t obj_off, obj = &shared_wobj_g[obj_off]; /* Get information about heap ID lengths */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > MAX_HEAP_ID_LEN) + if (id_len > MAX_HEAP_ID_LEN) TEST_ERROR /* Insert object */ HDmemset(heap_id, 0, id_len); - if(H5HF_insert(fh, obj_size, obj, heap_id) < 0) + if (H5HF_insert(fh, obj_size, obj, heap_id) < 0) FAIL_STACK_ERROR /* Check for tracking the heap's state */ - if(state) { - size_t tiny_max_len; /* Max. length of tiny objects */ - hbool_t tiny_len_extended; /* Do tiny objects use two bytes for the length? */ + if (state) { + size_t tiny_max_len; /* Max. length of tiny objects */ + hbool_t tiny_len_extended; /* Do tiny objects use two bytes for the length? */ /* Check information about tiny objects */ - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR /* Adjust state of heap */ - if(obj_size <= tiny_max_len) { + if (obj_size <= tiny_max_len) { state->tiny_nobjs++; state->tiny_size += obj_size; } /* end if */ @@ -405,36 +408,39 @@ add_obj(H5HF_t *fh, size_t obj_off, } /* end else */ /* Check free space left in heap */ - if(check_stats(fh, state)) + if (check_stats(fh, state)) TEST_ERROR } /* end if */ /* Read in object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(obj, shared_robj_g, obj_size)) + if (HDmemcmp(obj, shared_robj_g, obj_size)) TEST_ERROR /* If the heap IDs are to be retained, append them to the list */ - if(keep_ids) { + if (keep_ids) { /* Check for needing to increase size of heap ID array */ - if(keep_ids->num_ids + 1 > keep_ids->alloc_ids) { + if (keep_ids->num_ids + 1 > keep_ids->alloc_ids) { unsigned char *tmp_ids; - size_t *tmp_lens; - size_t *tmp_offs; + size_t * tmp_lens; + size_t * tmp_offs; keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2)); - if(NULL == (tmp_ids = (unsigned char *)H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids))) + if (NULL == + (tmp_ids = (unsigned char *)H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids))) TEST_ERROR keep_ids->ids = tmp_ids; - if(NULL == (tmp_lens = (size_t *)H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids))) + if (NULL == + (tmp_lens = (size_t *)H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids))) TEST_ERROR keep_ids->lens = tmp_lens; - if(NULL == (tmp_offs = (size_t *)H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids))) + if (NULL == + (tmp_offs = (size_t *)H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids))) TEST_ERROR keep_ids->offs = tmp_offs; } /* end if */ @@ -449,13 +455,12 @@ add_obj(H5HF_t *fh, size_t obj_off, } /* end if */ /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* add_obj() */ - /*------------------------------------------------------------------------- * Function: get_del_string * @@ -476,23 +481,22 @@ get_del_string(const fheap_test_param_t *tparam) char *str; /* Remove half of total objects from heap */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) - if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) + if (tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->drain_half == FHEAP_DEL_DRAIN_ALL) str = H5MM_strdup("(all - forward)"); else str = H5MM_strdup("(half, refill, all - forward)"); - else if(tparam->del_dir == FHEAP_DEL_REVERSE) - if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) + else if (tparam->del_dir == FHEAP_DEL_REVERSE) + if (tparam->drain_half == FHEAP_DEL_DRAIN_ALL) str = H5MM_strdup("(all - reverse)"); else str = H5MM_strdup("(half, refill, all - reverse)"); else str = H5MM_strdup("(all - deleting heap)"); - return(str); + return (str); } /* get_del_string() */ - /*------------------------------------------------------------------------- * Function: get_fill_size * @@ -509,22 +513,21 @@ get_del_string(const fheap_test_param_t *tparam) H5_ATTR_PURE static size_t get_fill_size(const fheap_test_param_t *tparam) { - switch(tparam->fill) { + switch (tparam->fill) { case FHEAP_TEST_FILL_LARGE: - return((size_t)(-1)); + return ((size_t)(-1)); case FHEAP_TEST_FILL_SINGLE: - return((size_t)0); + return ((size_t)0); case FHEAP_TEST_FILL_N: default: HDassert(0 && "Unknown bulk fill type?!?"); } /* end switch */ - return(0); + return (0); } /* get_fill_size() */ - /*------------------------------------------------------------------------- * Function: begin_test * @@ -545,13 +548,12 @@ get_fill_size(const fheap_test_param_t *tparam) * test_desc in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static int -begin_test(fheap_test_param_t *tparam, const char *base_desc, - fheap_heap_ids_t *keep_ids, size_t *fill_size) +begin_test(fheap_test_param_t *tparam, const char *base_desc, fheap_heap_ids_t *keep_ids, size_t *fill_size) { - char *del_str = NULL; /* Deletion order description */ - char *test_desc = NULL; /* Test description */ + char *del_str = NULL; /* Deletion order description */ + char *test_desc = NULL; /* Test description */ /* * Test filling & removing all (small) objects from root direct block of absolute heap @@ -565,15 +567,14 @@ begin_test(fheap_test_param_t *tparam, const char *base_desc, HDmemset(keep_ids, 0, sizeof(fheap_heap_ids_t)); /* Retrieve "bulk" filling object size */ - if(fill_size) + if (fill_size) *fill_size = get_fill_size(tparam); /* Success */ - return(0); + return (0); } /* end begin_test() */ -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - /*------------------------------------------------------------------------- * Function: reopen_file * @@ -588,29 +589,29 @@ H5_GCC_DIAG_ON(format-nonliteral) *------------------------------------------------------------------------- */ static int -reopen_file(hid_t *file, H5F_t **f, const char *filename, hid_t fapl, - H5HF_t **fh, haddr_t fh_addr, const fheap_test_param_t *tparam) +reopen_file(hid_t *file, H5F_t **f, const char *filename, hid_t fapl, H5HF_t **fh, haddr_t fh_addr, + const fheap_test_param_t *tparam) { /* Check for closing & re-opening the heap */ /* (actually will close & re-open the file as well) */ - if(tparam->reopen_heap) { + if (tparam->reopen_heap) { /* Close heap */ - if(H5HF_close(*fh) < 0) + if (H5HF_close(*fh) < 0) FAIL_STACK_ERROR *fh = NULL; /* Close file */ - if(H5Fclose(*file) < 0) + if (H5Fclose(*file) < 0) FAIL_STACK_ERROR *file = (-1); - *f = NULL; + *f = NULL; /* Re-open the file */ - if((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5VL_object(*file))) + if (NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -618,18 +619,17 @@ reopen_file(hid_t *file, H5F_t **f, const char *filename, hid_t fapl, FAIL_STACK_ERROR /* Re-open heap */ - if(NULL == (*fh = H5HF_open(*f, fh_addr))) + if (NULL == (*fh = H5HF_open(*f, fh_addr))) FAIL_STACK_ERROR } /* end if */ /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end reopen_file() */ - /*------------------------------------------------------------------------- * Function: open_heap * @@ -645,23 +645,23 @@ error: *------------------------------------------------------------------------- */ static int -open_heap(char *filename, hid_t fapl, const H5HF_create_t *cparam, - const fheap_test_param_t *tparam, hid_t *file, H5F_t **f, H5HF_t **fh, - haddr_t *fh_addr, fheap_heap_state_t *state, h5_stat_size_t *empty_size) +open_heap(char *filename, hid_t fapl, const H5HF_create_t *cparam, const fheap_test_param_t *tparam, + hid_t *file, H5F_t **f, H5HF_t **fh, haddr_t *fh_addr, fheap_heap_state_t *state, + h5_stat_size_t *empty_size) { - size_t id_len; /* Size of fractal heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, (size_t)FHEAP_FILENAME_LEN); /* Create the file to work on */ - if((*file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((*file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Check for deleting the entire heap */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5VL_object(*file))) + if (NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -669,42 +669,42 @@ open_heap(char *filename, hid_t fapl, const H5HF_create_t *cparam, FAIL_STACK_ERROR /* Create absolute heap */ - if(NULL == (*fh = H5HF_create(*f, cparam))) + if (NULL == (*fh = H5HF_create(*f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(*fh, &id_len) < 0) + if (H5HF_get_id_len(*fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > tparam->actual_id_len) + if (id_len > tparam->actual_id_len) TEST_ERROR - if(H5HF_get_heap_addr(*fh, fh_addr) < 0) + if (H5HF_get_heap_addr(*fh, fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(*fh_addr)) + if (!H5F_addr_defined(*fh_addr)) TEST_ERROR HDmemset(state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(*fh, state)) + if (check_stats(*fh, state)) TEST_ERROR /* Prepare for querying the size of a file with an empty heap */ /* Close (empty) heap */ - if(H5HF_close(*fh) < 0) + if (H5HF_close(*fh) < 0) FAIL_STACK_ERROR *fh = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) + if (H5Fclose(*file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((*empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((*empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5VL_object(*file))) + if (NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -712,36 +712,35 @@ open_heap(char *filename, hid_t fapl, const H5HF_create_t *cparam, FAIL_STACK_ERROR /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Create absolute heap */ - if(NULL == (*fh = H5HF_create(*f, cparam))) + if (NULL == (*fh = H5HF_create(*f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(*fh, &id_len) < 0) + if (H5HF_get_id_len(*fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > tparam->actual_id_len) + if (id_len > tparam->actual_id_len) TEST_ERROR - if(H5HF_get_heap_addr(*fh, fh_addr) < 0) + if (H5HF_get_heap_addr(*fh, fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(*fh_addr)) + if (!H5F_addr_defined(*fh_addr)) TEST_ERROR HDmemset(state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(*fh, state)) + if (check_stats(*fh, state)) TEST_ERROR } /* end if */ else { /* Re-open heap */ - if(NULL == (*fh = H5HF_open(*f, *fh_addr))) + if (NULL == (*fh = H5HF_open(*f, *fh_addr))) FAIL_STACK_ERROR } /* end else */ /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end open_heap() */ - /*------------------------------------------------------------------------- * Function: reopen_heap * @@ -757,18 +756,17 @@ error: *------------------------------------------------------------------------- */ static int -reopen_heap(H5F_t *f, H5HF_t **fh, haddr_t fh_addr, - const fheap_test_param_t *tparam) +reopen_heap(H5F_t *f, H5HF_t **fh, haddr_t fh_addr, const fheap_test_param_t *tparam) { /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { + if (tparam->reopen_heap) { /* Close (empty) heap */ - if(H5HF_close(*fh) < 0) + if (H5HF_close(*fh) < 0) FAIL_STACK_ERROR *fh = NULL; /* Re-open heap */ - if(NULL == (*fh = H5HF_open(f, fh_addr))) + if (NULL == (*fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR } /* end if */ @@ -779,7 +777,6 @@ error: return -1; } /* end reopen_heap() */ - /*------------------------------------------------------------------------- * Function: close_heap * @@ -794,60 +791,57 @@ error: *------------------------------------------------------------------------- */ static int -close_heap(char *filename, hid_t fapl, fheap_test_param_t *tparam, - hid_t file, H5F_t *f, H5HF_t **fh, haddr_t fh_addr, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids, - h5_stat_size_t empty_size) +close_heap(char *filename, hid_t fapl, fheap_test_param_t *tparam, hid_t file, H5F_t *f, H5HF_t **fh, + haddr_t fh_addr, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids, h5_stat_size_t empty_size) { - h5_stat_size_t file_size; /* Size of file currently */ + h5_stat_size_t file_size; /* Size of file currently */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, fh, fh_addr, tparam) < 0) + if (reopen_heap(f, fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - if(check_stats(*fh, state)) + if (check_stats(*fh, state)) TEST_ERROR /* Check for deleting the objects in the heap */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { /* Delete objects inserted (either forward or reverse order) */ - if(del_objs(f, fh, tparam, state, keep_ids)) + if (del_objs(f, fh, tparam, state, keep_ids)) FAIL_STACK_ERROR } /* end if */ /* Close the fractal heap */ - if(H5HF_close(*fh) < 0) + if (H5HF_close(*fh) < 0) FAIL_STACK_ERROR *fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Success */ - return(0); + return (0); error: - return(-1); + return (-1); } /* end close_heap() */ - /*------------------------------------------------------------------------- * Function: del_objs_half_refill * @@ -863,15 +857,14 @@ error: *------------------------------------------------------------------------- */ static int -del_objs_half_refill(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, - fheap_heap_ids_t *keep_ids) +del_objs_half_refill(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, fheap_heap_ids_t *keep_ids) { - unsigned char *wobj; /* Buffer for object to insert */ - haddr_t fh_addr = HADDR_UNDEF; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t half_nobjs; /* Half of total # of objects */ - size_t obj_idx; /* Index of the object to remove */ - size_t u; /* Local index variable */ + unsigned char *wobj; /* Buffer for object to insert */ + haddr_t fh_addr = HADDR_UNDEF; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t half_nobjs; /* Half of total # of objects */ + size_t obj_idx; /* Index of the object to remove */ + size_t u; /* Local index variable */ /* Sanity check */ HDassert(fh); @@ -879,69 +872,68 @@ del_objs_half_refill(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, HDassert(keep_ids); /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - if(H5HF_get_heap_addr(*fh, &fh_addr) < 0) + if (tparam->reopen_heap) { + if (H5HF_get_heap_addr(*fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR } /* end if */ /* Get information about heap ID lengths */ - if(H5HF_get_id_len(*fh, &id_len) < 0) + if (H5HF_get_id_len(*fh, &id_len) < 0) FAIL_STACK_ERROR /* Remove half of total objects from heap */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->del_dir == FHEAP_DEL_FORWARD) obj_idx = 0; else obj_idx = keep_ids->num_ids - 1; half_nobjs = keep_ids->num_ids / 2; - for(u = 0; u < half_nobjs; u++) { + for (u = 0; u < half_nobjs; u++) { /* Remove object from heap */ - if(H5HF_remove(*fh, &keep_ids->ids[id_len * obj_idx]) < 0) + if (H5HF_remove(*fh, &keep_ids->ids[id_len * obj_idx]) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, fh, fh_addr, tparam) < 0) + if (reopen_heap(f, fh, fh_addr, tparam) < 0) TEST_ERROR /* Adjust index of object to delete next */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->del_dir == FHEAP_DEL_FORWARD) obj_idx++; else obj_idx--; } /* end for */ /* Re-insert half of total objects back into heap */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->del_dir == FHEAP_DEL_FORWARD) obj_idx = 0; else obj_idx = keep_ids->num_ids - 1; - for(u = 0; u < half_nobjs; u++) { + for (u = 0; u < half_nobjs; u++) { /* Re-insert object */ wobj = &shared_wobj_g[keep_ids->offs[obj_idx]]; - if(H5HF_insert(*fh, keep_ids->lens[obj_idx], wobj, &keep_ids->ids[id_len * obj_idx]) < 0) + if (H5HF_insert(*fh, keep_ids->lens[obj_idx], wobj, &keep_ids->ids[id_len * obj_idx]) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, fh, fh_addr, tparam) < 0) + if (reopen_heap(f, fh, fh_addr, tparam) < 0) TEST_ERROR /* Adjust index of object to delete next */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->del_dir == FHEAP_DEL_FORWARD) obj_idx++; else obj_idx--; } /* end for */ /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* del_objs_half_refill() */ - /*------------------------------------------------------------------------- * Function: del_objs * @@ -957,13 +949,13 @@ error: *------------------------------------------------------------------------- */ static int -del_objs(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +del_objs(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - haddr_t fh_addr = HADDR_UNDEF; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t obj_idx; /* Index of the object to remove */ - size_t u; /* Local index variable */ + haddr_t fh_addr = HADDR_UNDEF; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t obj_idx; /* Index of the object to remove */ + size_t u; /* Local index variable */ /* Sanity check */ HDassert(fh); @@ -972,38 +964,38 @@ del_objs(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, HDassert(keep_ids); /* Check for first deleting half of objects & then re-inserting them */ - if(tparam->drain_half == FHEAP_DEL_DRAIN_HALF) - if(del_objs_half_refill(f, fh, tparam, keep_ids)) + if (tparam->drain_half == FHEAP_DEL_DRAIN_HALF) + if (del_objs_half_refill(f, fh, tparam, keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(tparam->reopen_heap) { - if(H5HF_get_heap_addr(*fh, &fh_addr) < 0) + if (tparam->reopen_heap) { + if (H5HF_get_heap_addr(*fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR } /* end if */ /* Get information about heap ID lengths */ - if(H5HF_get_id_len(*fh, &id_len) < 0) + if (H5HF_get_id_len(*fh, &id_len) < 0) FAIL_STACK_ERROR /* Remove all objects from heap */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->del_dir == FHEAP_DEL_FORWARD) obj_idx = 0; else obj_idx = keep_ids->num_ids - 1; - for(u = 0; u < keep_ids->num_ids; u++) { + for (u = 0; u < keep_ids->num_ids; u++) { /* Remove object from heap */ - if(H5HF_remove(*fh, &keep_ids->ids[id_len * obj_idx]) < 0) + if (H5HF_remove(*fh, &keep_ids->ids[id_len * obj_idx]) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, fh, fh_addr, tparam) < 0) + if (reopen_heap(f, fh, fh_addr, tparam) < 0) TEST_ERROR /* Adjust index of object to delete next */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->del_dir == FHEAP_DEL_FORWARD) obj_idx++; else obj_idx--; @@ -1013,17 +1005,16 @@ del_objs(H5F_t *f, H5HF_t **fh, fheap_test_param_t *tparam, HDmemset(state, 0, sizeof(fheap_heap_state_t)); /* Check up on heap... */ - if(check_stats(*fh, state)) + if (check_stats(*fh, state)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* del_objs() */ - /*------------------------------------------------------------------------- * Function: fill_heap * @@ -1049,19 +1040,19 @@ error: *------------------------------------------------------------------------- */ static int -fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - unsigned char *wobj; /* Buffer for object to insert */ - unsigned char *curr_id_ptr; /* Pointer into shared ID array */ - size_t *curr_len_ptr; /* Pointer into shared length array */ - size_t *curr_off_ptr; /* Pointer into shared offset array */ - size_t num_ids = 0; /* # of heap IDs in array */ - size_t data_size; /* Size of data portion of heap block */ - size_t last_obj_len; /* Size of last object inserted into heap */ - size_t obj_off; /* Offset of object in shared write buffer */ - size_t id_len; /* Size of fractal heap IDs */ - unsigned u; /* Local index variable */ + unsigned char *wobj; /* Buffer for object to insert */ + unsigned char *curr_id_ptr; /* Pointer into shared ID array */ + size_t * curr_len_ptr; /* Pointer into shared length array */ + size_t * curr_off_ptr; /* Pointer into shared offset array */ + size_t num_ids = 0; /* # of heap IDs in array */ + size_t data_size; /* Size of data portion of heap block */ + size_t last_obj_len; /* Size of last object inserted into heap */ + size_t obj_off; /* Offset of object in shared write buffer */ + size_t id_len; /* Size of fractal heap IDs */ + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(fh); @@ -1069,44 +1060,47 @@ fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, HDassert(obj_size + 256 < shared_obj_size_g); /* Initialize starting information */ - data_size = (size_t)DBLOCK_FREE(fh, block_row); - wobj = shared_wobj_g; - curr_id_ptr = shared_ids_g; + data_size = (size_t)DBLOCK_FREE(fh, block_row); + wobj = shared_wobj_g; + curr_id_ptr = shared_ids_g; curr_len_ptr = shared_lens_g; curr_off_ptr = shared_offs_g; - obj_off = 0; + obj_off = 0; /* Get information about heap ID lengths */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR /* Check for some "magic" object sizes */ - if(obj_size == 0) + if (obj_size == 0) obj_size = data_size; - else if(obj_size == (size_t)(-1)) + else if (obj_size == (size_t)(-1)) obj_size = (data_size / NUM_FILL_OBJS) + 1; /* Loop over inserting objects into the root direct block, until there's no more space */ - while(data_size >= obj_size) { + while (data_size >= obj_size) { /* Increment object count */ num_ids++; /* Check for needing to increase size of heap ID array */ - if(num_ids > shared_alloc_ids_g) { + if (num_ids > shared_alloc_ids_g) { shared_alloc_ids_g = MAX(1024, (shared_alloc_ids_g * 2)); - if(NULL == (shared_ids_g = (unsigned char *)H5MM_realloc(shared_ids_g, id_len * shared_alloc_ids_g))) + if (NULL == + (shared_ids_g = (unsigned char *)H5MM_realloc(shared_ids_g, id_len * shared_alloc_ids_g))) TEST_ERROR - if(NULL == (shared_lens_g = (size_t *)H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g))) + if (NULL == + (shared_lens_g = (size_t *)H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g))) TEST_ERROR - if(NULL == (shared_offs_g = (size_t *)H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g))) + if (NULL == + (shared_offs_g = (size_t *)H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g))) TEST_ERROR - curr_id_ptr = &shared_ids_g[(num_ids - 1) * id_len]; + curr_id_ptr = &shared_ids_g[(num_ids - 1) * id_len]; curr_len_ptr = &shared_lens_g[(num_ids - 1)]; curr_off_ptr = &shared_offs_g[(num_ids - 1)]; } /* end if */ /* Insert object */ - if(H5HF_insert(fh, obj_size, wobj, curr_id_ptr) < 0) + if (H5HF_insert(fh, obj_size, wobj, curr_id_ptr) < 0) FAIL_STACK_ERROR *curr_len_ptr = obj_size; *curr_off_ptr = obj_off; @@ -1116,14 +1110,14 @@ fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, state->man_free_space -= obj_size; /* Check stats for heap */ - if(check_stats(fh, state)) + if (check_stats(fh, state)) TEST_ERROR /* Adjust object & ID pointers */ wobj++; obj_off++; - if(obj_off > 255) { - wobj = shared_wobj_g; + if (obj_off > 255) { + wobj = shared_wobj_g; obj_off = 0; } /* end if */ curr_id_ptr += id_len; @@ -1135,7 +1129,7 @@ fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, } /* end while */ /* Check for adding smaller last object to heap block */ - if(data_size > 0) { + if (data_size > 0) { /* Set size of last object in block */ last_obj_len = data_size; @@ -1143,21 +1137,24 @@ fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, num_ids++; /* Check for needing to increase size of heap ID array */ - if(num_ids > shared_alloc_ids_g) { + if (num_ids > shared_alloc_ids_g) { shared_alloc_ids_g = MAX(1024, (shared_alloc_ids_g * 2)); - if(NULL == (shared_ids_g = (unsigned char *)H5MM_realloc(shared_ids_g, id_len * shared_alloc_ids_g))) + if (NULL == + (shared_ids_g = (unsigned char *)H5MM_realloc(shared_ids_g, id_len * shared_alloc_ids_g))) TEST_ERROR - if(NULL == (shared_lens_g = (size_t *)H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g))) + if (NULL == + (shared_lens_g = (size_t *)H5MM_realloc(shared_lens_g, sizeof(size_t) * shared_alloc_ids_g))) TEST_ERROR - if(NULL == (shared_offs_g = (size_t *)H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g))) + if (NULL == + (shared_offs_g = (size_t *)H5MM_realloc(shared_offs_g, sizeof(size_t) * shared_alloc_ids_g))) TEST_ERROR - curr_id_ptr = &shared_ids_g[(num_ids - 1) * id_len]; + curr_id_ptr = &shared_ids_g[(num_ids - 1) * id_len]; curr_len_ptr = &shared_lens_g[(num_ids - 1)]; curr_off_ptr = &shared_offs_g[(num_ids - 1)]; } /* end if */ /* Insert last object into the heap, using the remaining free space */ - if(H5HF_insert(fh, last_obj_len, wobj, curr_id_ptr) < 0) + if (H5HF_insert(fh, last_obj_len, wobj, curr_id_ptr) < 0) FAIL_STACK_ERROR *curr_len_ptr = last_obj_len; *curr_off_ptr = obj_off; @@ -1167,27 +1164,27 @@ fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, state->man_free_space -= last_obj_len; /* Verify that the heap is full */ - if(check_stats(fh, state)) + if (check_stats(fh, state)) TEST_ERROR } /* end if */ else - last_obj_len = obj_size; /* Normal sized last object */ + last_obj_len = obj_size; /* Normal sized last object */ /* Verify reading the objects written out */ /* Verify all the objects */ - wobj = shared_wobj_g; - curr_id_ptr = shared_ids_g; + wobj = shared_wobj_g; + curr_id_ptr = shared_ids_g; curr_len_ptr = shared_lens_g; curr_off_ptr = shared_offs_g; - for(u = 0; u < num_ids; u++) { + for (u = 0; u < num_ids; u++) { /* Read in object */ - if(H5HF_read(fh, curr_id_ptr, shared_robj_g) < 0) + if (H5HF_read(fh, curr_id_ptr, shared_robj_g) < 0) FAIL_STACK_ERROR /* Check that object is correct */ wobj = &shared_wobj_g[*curr_off_ptr]; - if(HDmemcmp(wobj, shared_robj_g, *curr_len_ptr)) + if (HDmemcmp(wobj, shared_robj_g, *curr_len_ptr)) TEST_ERROR /* Adjust object & ID pointers */ @@ -1197,15 +1194,18 @@ fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, } /* end for */ /* If the heap IDs are to be retained, append them to the list */ - if(keep_ids) { + if (keep_ids) { /* Check for needing to increase size of heap ID array */ - if(keep_ids->num_ids + num_ids > keep_ids->alloc_ids) { + if (keep_ids->num_ids + num_ids > keep_ids->alloc_ids) { keep_ids->alloc_ids = MAX(1024, (keep_ids->alloc_ids * 2)); - if(NULL == (keep_ids->ids = (unsigned char *)H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids))) + if (NULL == + (keep_ids->ids = (unsigned char *)H5MM_realloc(keep_ids->ids, id_len * keep_ids->alloc_ids))) TEST_ERROR - if(NULL == (keep_ids->lens = (size_t *)H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids))) + if (NULL == (keep_ids->lens = + (size_t *)H5MM_realloc(keep_ids->lens, sizeof(size_t) * keep_ids->alloc_ids))) TEST_ERROR - if(NULL == (keep_ids->offs = (size_t *)H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids))) + if (NULL == (keep_ids->offs = + (size_t *)H5MM_realloc(keep_ids->offs, sizeof(size_t) * keep_ids->alloc_ids))) TEST_ERROR } /* end if */ @@ -1219,13 +1219,12 @@ fill_heap(H5HF_t *fh, unsigned block_row, size_t obj_size, } /* end if */ /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_heap() */ - /*------------------------------------------------------------------------- * Function: fill_root_row * @@ -1241,18 +1240,18 @@ error: *------------------------------------------------------------------------- */ static int -fill_root_row(H5HF_t *fh, unsigned row, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_root_row(H5HF_t *fh, unsigned row, size_t obj_size, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - hsize_t first_free_space; /* Size of free space in heap after the first block */ - hsize_t all_free_space; /* Size of free space in heap after all blocks */ - hsize_t first_heap_size; /* Total size of the heap after the first block */ - hsize_t all_heap_size; /* Total size of the heap after all blocks */ - size_t block_size; /* Block size for row */ - size_t block_free; /* Free space in empty block of this row */ - unsigned width; /* Width of heap's doubling table */ - unsigned expand_rows; /* # of rows to expand heap by */ - unsigned u; /* Local index variable */ + hsize_t first_free_space; /* Size of free space in heap after the first block */ + hsize_t all_free_space; /* Size of free space in heap after all blocks */ + hsize_t first_heap_size; /* Total size of the heap after the first block */ + hsize_t all_heap_size; /* Total size of the heap after all blocks */ + size_t block_size; /* Block size for row */ + size_t block_free; /* Free space in empty block of this row */ + unsigned width; /* Width of heap's doubling table */ + unsigned expand_rows; /* # of rows to expand heap by */ + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(fh); @@ -1261,49 +1260,49 @@ fill_root_row(H5HF_t *fh, unsigned row, size_t obj_size, /* Get some information for the heap */ block_size = (size_t)DBLOCK_SIZE(fh, row); block_free = (size_t)DBLOCK_FREE(fh, row); - width = DTABLE_WIDTH(fh); + width = DTABLE_WIDTH(fh); /* Compute the number of rows to expand heap by */ - if(row < 2) + if (row < 2) expand_rows = 1; - else if(POWER_OF_TWO(row)) + else if (POWER_OF_TWO(row)) expand_rows = row; else expand_rows = 0; /* Compute first block & all blocks heap size & free space */ - if(state->man_size == 0) { - first_heap_size = block_size; + if (state->man_size == 0) { + first_heap_size = block_size; first_free_space = block_free; - all_heap_size = width * block_size; - all_free_space = (width - 1) * block_free; + all_heap_size = width * block_size; + all_free_space = (width - 1) * block_free; } /* end if */ - else if(expand_rows == 0) { - all_heap_size = state->man_size; - all_free_space = state->man_free_space; - first_heap_size = all_heap_size; + else if (expand_rows == 0) { + all_heap_size = state->man_size; + all_free_space = state->man_free_space; + first_heap_size = all_heap_size; first_free_space = all_free_space; - all_free_space -= block_free; /* Account for shift from first free space */ - } /* end if */ + all_free_space -= block_free; /* Account for shift from first free space */ + } /* end if */ else { - all_heap_size = state->man_size; + all_heap_size = state->man_size; all_free_space = 0; - for(u = 0; u < expand_rows; u++) { + for (u = 0; u < expand_rows; u++) { all_heap_size += width * DBLOCK_SIZE(fh, row + u); all_free_space += width * DBLOCK_FREE(fh, row + u); } /* end for */ - first_heap_size = all_heap_size; + first_heap_size = all_heap_size; first_free_space = all_free_space; - all_free_space -= block_free; /* Account for shift from first free space */ - } /* end else */ + all_free_space -= block_free; /* Account for shift from first free space */ + } /* end else */ /* Loop over filling direct blocks, until root indirect row is full */ - state->man_size = first_heap_size; + state->man_size = first_heap_size; state->man_free_space = first_free_space; - for(u = 0; u < width; u++) { + for (u = 0; u < width; u++) { /* Set heap's size & free space correctly */ - if(u == 1) { - state->man_size = all_heap_size; + if (u == 1) { + state->man_size = all_heap_size; state->man_free_space = all_free_space; } /* end if */ @@ -1311,18 +1310,17 @@ fill_root_row(H5HF_t *fh, unsigned row, size_t obj_size, state->man_alloc_size += block_size; /* Fill a direct heap block up */ - if(fill_heap(fh, row, obj_size, state, keep_ids)) + if (fill_heap(fh, row, obj_size, state, keep_ids)) TEST_ERROR } /* end for */ /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_root_row() */ - /*------------------------------------------------------------------------- * Function: fill_partial row * @@ -1338,11 +1336,11 @@ error: *------------------------------------------------------------------------- */ static int -fill_partial_row(H5HF_t *fh, unsigned row, unsigned width, - size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_partial_row(H5HF_t *fh, unsigned row, unsigned width, size_t obj_size, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - size_t block_size; /* Size of direct block in this row */ - unsigned u; /* Local index variable */ + size_t block_size; /* Size of direct block in this row */ + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(fh); @@ -1352,23 +1350,22 @@ fill_partial_row(H5HF_t *fh, unsigned row, unsigned width, block_size = (size_t)DBLOCK_SIZE(fh, row); /* Loop over filling direct blocks, until indirect row is full */ - for(u = 0; u < width; u++) { + for (u = 0; u < width; u++) { /* Adjust stats for new block */ state->man_alloc_size += block_size; /* Fill a direct heap block up */ - if(fill_heap(fh, row, obj_size, state, keep_ids)) + if (fill_heap(fh, row, obj_size, state, keep_ids)) TEST_ERROR } /* end for */ /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_partial_row() */ - /*------------------------------------------------------------------------- * Function: fill_row * @@ -1384,25 +1381,23 @@ error: *------------------------------------------------------------------------- */ static int -fill_row(H5HF_t *fh, unsigned row, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_row(H5HF_t *fh, unsigned row, size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) { /* Sanity check */ HDassert(fh); HDassert(state); /* Fill the entire row (with the partial row fill routine) */ - if(fill_partial_row(fh, row, DTABLE_WIDTH(fh), obj_size, state, keep_ids)) + if (fill_partial_row(fh, row, DTABLE_WIDTH(fh), obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_row() */ - /*------------------------------------------------------------------------- * Function: fill_root_direct * @@ -1421,29 +1416,27 @@ error: *------------------------------------------------------------------------- */ static int -fill_root_direct(H5HF_t *fh, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_root_direct(H5HF_t *fh, size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) { - unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */ - unsigned row; /* Row being created */ + unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */ + unsigned row; /* Row being created */ /* Get heap info */ max_dblock_rows = DTABLE_MAX_DROWS(fh); HDassert(max_dblock_rows); /* Loop over rows */ - for(row = 0; row < max_dblock_rows; row++) - if(fill_root_row(fh, row, obj_size, state, keep_ids)) + for (row = 0; row < max_dblock_rows; row++) + if (fill_root_row(fh, row, obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_root_direct() */ - /*------------------------------------------------------------------------- * Function: fill_2nd_indirect * @@ -1461,29 +1454,28 @@ error: *------------------------------------------------------------------------- */ static int -fill_2nd_indirect(H5HF_t *fh, unsigned pos, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_2nd_indirect(H5HF_t *fh, unsigned pos, size_t obj_size, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */ - unsigned row; /* Current row to create */ + unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */ + unsigned row; /* Current row to create */ /* Get some information for the heap */ max_dblock_rows = IBLOCK_MAX_DROWS(fh, pos); HDassert(max_dblock_rows); /* Loop over rows */ - for(row = 0; row < max_dblock_rows; row++) - if(fill_row(fh, row, obj_size, state, keep_ids)) + for (row = 0; row < max_dblock_rows; row++) + if (fill_row(fh, row, obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_2nd_direct() */ - /*------------------------------------------------------------------------- * Function: fill_all_direct * @@ -1500,29 +1492,27 @@ error: *------------------------------------------------------------------------- */ static int -fill_all_direct(H5HF_t *fh, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_all_direct(H5HF_t *fh, size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) { - unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */ - unsigned row; /* Row being created */ + unsigned max_dblock_rows; /* Max. # of direct block rows in indirect block */ + unsigned row; /* Row being created */ /* Get heap info */ max_dblock_rows = DTABLE_MAX_DROWS(fh); HDassert(max_dblock_rows); /* Loop over rows */ - for(row = 0; row < max_dblock_rows; row++) - if(fill_row(fh, row, obj_size, state, keep_ids)) + for (row = 0; row < max_dblock_rows; row++) + if (fill_row(fh, row, obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_all_direct() */ - /*------------------------------------------------------------------------- * Function: fill_2nd_indirect_row * @@ -1540,28 +1530,27 @@ error: *------------------------------------------------------------------------- */ static int -fill_2nd_indirect_row(H5HF_t *fh, unsigned pos, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_2nd_indirect_row(H5HF_t *fh, unsigned pos, size_t obj_size, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - unsigned width; /* Width of heap's doubling table */ - unsigned u; /* Local index variable */ + unsigned width; /* Width of heap's doubling table */ + unsigned u; /* Local index variable */ /* Get some information for the heap */ width = DTABLE_WIDTH(fh); /* Loop over row of indirect blocks */ - for(u = 0; u < width; u++) - if(fill_2nd_indirect(fh, pos, obj_size, state, keep_ids)) + for (u = 0; u < width; u++) + if (fill_2nd_indirect(fh, pos, obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_2nd_direct_row() */ - /*------------------------------------------------------------------------- * Function: fill_all_2nd_indirect_rows * @@ -1579,28 +1568,26 @@ error: *------------------------------------------------------------------------- */ static int -fill_all_2nd_indirect_rows(H5HF_t *fh, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_all_2nd_indirect_rows(H5HF_t *fh, size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) { - unsigned width; /* Width of heap's doubling table */ - unsigned u; /* Local index variable */ + unsigned width; /* Width of heap's doubling table */ + unsigned u; /* Local index variable */ /* Get some information for the heap */ width = DTABLE_WIDTH(fh); /* Loop over rows of 2nd level deep indirect blocks */ - for(u = 0; u < (H5VM_log2_of2(width) + 1); u++) - if(fill_2nd_indirect_row(fh, (u + 1), obj_size, state, keep_ids)) + for (u = 0; u < (H5VM_log2_of2(width) + 1); u++) + if (fill_2nd_indirect_row(fh, (u + 1), obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_2nd_direct_row() */ - /*------------------------------------------------------------------------- * Function: fill_3rd_indirect * @@ -1618,28 +1605,27 @@ error: *------------------------------------------------------------------------- */ static int -fill_3rd_indirect(H5HF_t *fh, unsigned pos, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_3rd_indirect(H5HF_t *fh, unsigned pos, size_t obj_size, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Fill all direct block rows in third level indirect block */ - if(fill_all_direct(fh, obj_size, state, keep_ids)) + if (fill_all_direct(fh, obj_size, state, keep_ids)) TEST_ERROR /* Fill rows of recursive indirect blocks in third level indirect block */ - for(u = 0; u < pos; u++) - if(fill_2nd_indirect_row(fh, (u + 1), obj_size, state, keep_ids)) + for (u = 0; u < pos; u++) + if (fill_2nd_indirect_row(fh, (u + 1), obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_3rd_indirect() */ - /*------------------------------------------------------------------------- * Function: fill_3rd_indirect_row * @@ -1657,29 +1643,28 @@ error: *------------------------------------------------------------------------- */ static int -fill_3rd_indirect_row(H5HF_t *fh, unsigned pos, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_3rd_indirect_row(H5HF_t *fh, unsigned pos, size_t obj_size, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - unsigned width; /* Width of heap's doubling table */ - unsigned u; /* Local index variable */ + unsigned width; /* Width of heap's doubling table */ + unsigned u; /* Local index variable */ /* Get some information for the heap */ width = DTABLE_WIDTH(fh); /* Loop over row of 3rd level indirect blocks */ - for(u = 0; u < width; u++) + for (u = 0; u < width; u++) /* Fill third level indirect block */ - if(fill_3rd_indirect(fh, pos, obj_size, state, keep_ids)) + if (fill_3rd_indirect(fh, pos, obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_3rd_direct_row() */ - /*------------------------------------------------------------------------- * Function: fill_all_3rd_indirect_rows * @@ -1697,29 +1682,27 @@ error: *------------------------------------------------------------------------- */ static int -fill_all_3rd_indirect_rows(H5HF_t *fh, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_all_3rd_indirect_rows(H5HF_t *fh, size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) { - unsigned width; /* Width of heap's doubling table */ - unsigned u; /* Local index variable */ + unsigned width; /* Width of heap's doubling table */ + unsigned u; /* Local index variable */ /* Get some information for the heap */ width = DTABLE_WIDTH(fh); /* Loop over rows of 3rd level deep indirect blocks */ - for(u = 0; u < (H5VM_log2_of2(width) + 1); u++) + for (u = 0; u < (H5VM_log2_of2(width) + 1); u++) /* Fill row of 3rd level indirect blocks */ - if(fill_3rd_indirect_row(fh, (u + 1), obj_size, state, keep_ids)) + if (fill_3rd_indirect_row(fh, (u + 1), obj_size, state, keep_ids)) TEST_ERROR /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_all_3rd_direct_rows() */ - /*------------------------------------------------------------------------- * Function: fill_4th_indirect_row * @@ -1737,39 +1720,38 @@ error: *------------------------------------------------------------------------- */ static int -fill_4th_indirect_row(H5HF_t *fh, unsigned pos, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_4th_indirect_row(H5HF_t *fh, unsigned pos, size_t obj_size, fheap_heap_state_t *state, + fheap_heap_ids_t *keep_ids) { - unsigned width; /* Width of heap's doubling table */ - unsigned u, v; /* Local index variables */ + unsigned width; /* Width of heap's doubling table */ + unsigned u, v; /* Local index variables */ /* Get some information for the heap */ width = DTABLE_WIDTH(fh); /* Loop over row of 4th level indirect blocks */ - for(u = 0; u < width; u++) { + for (u = 0; u < width; u++) { /* Fill all direct block rows in fourth level indirect block */ - if(fill_all_direct(fh, obj_size, state, keep_ids)) + if (fill_all_direct(fh, obj_size, state, keep_ids)) TEST_ERROR /* Fill all rows of 2nd level deep indirect blocks in fourth level indirect block */ - if(fill_all_2nd_indirect_rows(fh, obj_size, state, keep_ids)) + if (fill_all_2nd_indirect_rows(fh, obj_size, state, keep_ids)) TEST_ERROR /* Fill rows of third level indirect blocks in fourth level indirect block */ - for(v = 0; v < pos; v++) - if(fill_3rd_indirect_row(fh, (v + 1), obj_size, state, keep_ids)) + for (v = 0; v < pos; v++) + if (fill_3rd_indirect_row(fh, (v + 1), obj_size, state, keep_ids)) TEST_ERROR } /* end for */ /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_4th_direct_row() */ - /*------------------------------------------------------------------------- * Function: fill_all_4th_indirect_rows * @@ -1787,47 +1769,45 @@ error: *------------------------------------------------------------------------- */ static int -fill_all_4th_indirect_rows(H5HF_t *fh, size_t obj_size, - fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) +fill_all_4th_indirect_rows(H5HF_t *fh, size_t obj_size, fheap_heap_state_t *state, fheap_heap_ids_t *keep_ids) { - unsigned width; /* Width of heap's doubling table */ - unsigned u; /* Local index variable */ + unsigned width; /* Width of heap's doubling table */ + unsigned u; /* Local index variable */ /* Get some information for the heap */ width = DTABLE_WIDTH(fh); /* Loop over rows of 4th level deep indirect blocks */ - for(u = 0; u < (H5VM_log2_of2(width) + 1); u++) { + for (u = 0; u < (H5VM_log2_of2(width) + 1); u++) { /* Fill row of 4th level indirect blocks */ - if(fill_4th_indirect_row(fh, (u + 1), obj_size, state, keep_ids)) + if (fill_4th_indirect_row(fh, (u + 1), obj_size, state, keep_ids)) TEST_ERROR /* Account for root indirect block doubling # of rows again */ /* (From 16 rows to the max. # of rows: 22) */ /* (Note: this is tied to the particular doubling table/heap creation parameters) */ - if(u == 0) { - unsigned max_root_rows; /* Maximum # of rows in root indirect block */ - unsigned row; /* Row in heap */ + if (u == 0) { + unsigned max_root_rows; /* Maximum # of rows in root indirect block */ + unsigned row; /* Row in heap */ /* Get some information for the heap */ max_root_rows = HEAP_MAX_ROOT_ROWS(fh); /* Increase heap size & free space */ - for(row = 16; row < max_root_rows; row++) { + for (row = 16; row < max_root_rows; row++) { state->man_size += width * DBLOCK_SIZE(fh, row); state->man_free_space += width * DBLOCK_FREE(fh, row); } /* end for */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Operations succeeded */ - return(0); + return (0); error: - return(1); + return (1); } /* fill_all_4th_direct_rows() */ - /*------------------------------------------------------------------------- * Function: test_create * @@ -1844,38 +1824,38 @@ error: static unsigned test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_create_t test_cparam; /* Creation parameters for heap */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Heap address in file */ - h5_stat_size_t empty_size; /* File size, w/o heap */ - h5_stat_size_t file_size; /* File size, after deleting heap */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_create_t test_cparam; /* Creation parameters for heap */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Heap address in file */ + h5_stat_size_t empty_size; /* File size, w/o heap */ + h5_stat_size_t file_size; /* File size, after deleting heap */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -1887,48 +1867,48 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) */ TESTING("fractal heap creation"); - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) TEST_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR PASSED(); /* Query the type of address mapping */ TESTING("query heap creation parameters"); HDmemset(&test_cparam, 0, sizeof(H5HF_create_t)); - if(H5HF_get_cparam_test(fh, &test_cparam) < 0) + if (H5HF_get_cparam_test(fh, &test_cparam) < 0) FAIL_STACK_ERROR - if(H5HF_cmp_cparam_test(cparam, &test_cparam)) + if (H5HF_cmp_cparam_test(cparam, &test_cparam)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ @@ -1937,15 +1917,16 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) return 0; error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_create() */ - /*------------------------------------------------------------------------- * Function: test_reopen * @@ -1962,42 +1943,42 @@ error: static unsigned test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_create_t test_cparam; /* Creation parameters for heap */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - h5_stat_size_t empty_size; /* File size, w/o heap */ - h5_stat_size_t file_size; /* File size, after deleting heap */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_state_t state; /* State of fractal heap */ - hbool_t page = FALSE; /* Paged aggregation strategy or not */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_create_t test_cparam; /* Creation parameters for heap */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + h5_stat_size_t empty_size; /* File size, w/o heap */ + h5_stat_size_t file_size; /* File size, after deleting heap */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_state_t state; /* State of fractal heap */ + hbool_t page = FALSE; /* Paged aggregation strategy or not */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR - if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) + if (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) page = TRUE; /* Ignore metadata tags in the file's cache */ @@ -2011,37 +1992,37 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TESTING("create, close & reopen fractal heap"); /* Create heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) TEST_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for closing & re-opening the file */ - if(tparam->reopen_heap) { + if (tparam->reopen_heap) { /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2051,53 +2032,54 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) } /* end if */ /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Query the creation parameters */ HDmemset(&test_cparam, 0, sizeof(H5HF_create_t)); - if(H5HF_get_cparam_test(fh, &test_cparam) < 0) + if (H5HF_get_cparam_test(fh, &test_cparam) < 0) FAIL_STACK_ERROR - if(H5HF_cmp_cparam_test(cparam, &test_cparam)) + if (H5HF_cmp_cparam_test(cparam, &test_cparam)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(!page || (page && !tparam->reopen_heap)) - if(file_size != empty_size) + if (!page || (page && !tparam->reopen_heap)) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_reopen() */ - /*------------------------------------------------------------------------- * Function: test_open_twice * @@ -2114,45 +2096,45 @@ error: static unsigned test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - hid_t file2 = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5F_t *f2 = NULL; /* Internal file object pointer */ - H5HF_create_t test_cparam; /* Creation parameters for heap */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - H5HF_t *fh2 = NULL; /* 2nd fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - h5_stat_size_t empty_size; /* File size, w/o heap */ - h5_stat_size_t file_size; /* File size, after deleting heap */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_state_t state; /* State of fractal heap */ - hbool_t page = FALSE; /* Paged aggregation strategy or not */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5F_t * f2 = NULL; /* Internal file object pointer */ + H5HF_create_t test_cparam; /* Creation parameters for heap */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + H5HF_t * fh2 = NULL; /* 2nd fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + h5_stat_size_t empty_size; /* File size, w/o heap */ + h5_stat_size_t file_size; /* File size, after deleting heap */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_state_t state; /* State of fractal heap */ + hbool_t page = FALSE; /* Paged aggregation strategy or not */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR - if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) + if (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) page = TRUE; /* Ignore metadata tags in the file's cache */ @@ -2165,46 +2147,46 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TESTING("open fractal heap twice"); /* Create heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) TEST_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Open the heap again, through the first file handle */ - if(NULL == (fh2 = H5HF_open(f, fh_addr))) + if (NULL == (fh2 = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Verify the creation parameters */ HDmemset(&test_cparam, 0, sizeof(H5HF_create_t)); - if(H5HF_get_cparam_test(fh2, &test_cparam) < 0) + if (H5HF_get_cparam_test(fh2, &test_cparam) < 0) FAIL_STACK_ERROR - if(H5HF_cmp_cparam_test(cparam, &test_cparam)) + if (H5HF_cmp_cparam_test(cparam, &test_cparam)) TEST_ERROR /* Close the second fractal heap wrapper */ - if(H5HF_close(fh2) < 0) + if (H5HF_close(fh2) < 0) FAIL_STACK_ERROR fh2 = NULL; /* Check for closing & re-opening the heap & file */ - if(reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) + if (reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Re-open the file */ - if((file2 = H5Freopen(file)) < 0) + if ((file2 = H5Freopen(file)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f2 = (H5F_t *)H5VL_object(file2))) + if (NULL == (f2 = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2212,18 +2194,18 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Open the fractal heap through the second file handle */ - if(NULL == (fh2 = H5HF_open(f2, fh_addr))) + if (NULL == (fh2 = H5HF_open(f2, fh_addr))) FAIL_STACK_ERROR /* Verify the creation parameters */ HDmemset(&test_cparam, 0, sizeof(H5HF_create_t)); - if(H5HF_get_cparam_test(fh2, &test_cparam) < 0) + if (H5HF_get_cparam_test(fh2, &test_cparam) < 0) FAIL_STACK_ERROR - if(H5HF_cmp_cparam_test(cparam, &test_cparam)) + if (H5HF_cmp_cparam_test(cparam, &test_cparam)) TEST_ERROR /* Close the first fractal heap wrapper */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; @@ -2231,29 +2213,29 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) /* (close before second file, to detect error on internal heap header's * shared file information) */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Close the second fractal heap wrapper */ - if(H5HF_close(fh2) < 0) + if (H5HF_close(fh2) < 0) FAIL_STACK_ERROR fh2 = NULL; /* Delete heap */ - if(H5HF_delete(f2, fh_addr) < 0) + if (H5HF_delete(f2, fh_addr) < 0) FAIL_STACK_ERROR /* Close the second file */ - if(H5Fclose(file2) < 0) + if (H5Fclose(file2) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(!page || (page && !tparam->reopen_heap)) - if(file_size != empty_size) + if (!page || (page && !tparam->reopen_heap)) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ @@ -2262,19 +2244,20 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) return 0; error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - if(fh2) + if (fh2) H5HF_close(fh2); H5Fclose(file); H5Fclose(file2); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_open_twice() */ - /*------------------------------------------------------------------------- * Function: test_delete_open * @@ -2291,39 +2274,39 @@ error: static unsigned test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_create_t test_cparam; /* Creation parameters for heap */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - H5HF_t *fh2 = NULL; /* 2nd fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_create_t test_cparam; /* Creation parameters for heap */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + H5HF_t * fh2 = NULL; /* 2nd fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/no heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2334,45 +2317,47 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TESTING("deleting open fractal heap"); /* Create heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) TEST_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Open the heap again */ - if(NULL == (fh2 = H5HF_open(f, fh_addr))) + if (NULL == (fh2 = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Request that the heap be deleted */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR /* Verify the creation parameters */ HDmemset(&test_cparam, 0, sizeof(H5HF_create_t)); - if(H5HF_get_cparam_test(fh2, &test_cparam) < 0) + if (H5HF_get_cparam_test(fh2, &test_cparam) < 0) FAIL_STACK_ERROR - if(H5HF_cmp_cparam_test(cparam, &test_cparam)) + if (H5HF_cmp_cparam_test(cparam, &test_cparam)) TEST_ERROR /* Close the second fractal heap wrapper */ - if(H5HF_close(fh2) < 0) + if (H5HF_close(fh2) < 0) FAIL_STACK_ERROR fh2 = NULL; /* Try re-opening the heap again (should fail, as heap will be deleted) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fh2 = H5HF_open(f, fh_addr); - } H5E_END_TRY; - if(fh2) { + } + H5E_END_TRY; + if (fh2) { /* Close opened heap */ H5HF_close(fh2); fh2 = NULL; @@ -2382,22 +2367,22 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) } /* end if */ /* Close the first fractal heap wrapper */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for closing & re-opening the file */ - if(tparam->reopen_heap) { + if (tparam->reopen_heap) { /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2407,10 +2392,12 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) } /* end if */ /* Try re-opening the heap again (should fail, as heap is now deleted) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fh = H5HF_open(f, fh_addr); - } H5E_END_TRY; - if(fh) { + } + H5E_END_TRY; + if (fh) { /* Close opened heap */ H5HF_close(fh); fh = NULL; @@ -2420,15 +2407,15 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ @@ -2437,17 +2424,18 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) return 0; error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - if(fh2) + if (fh2) H5HF_close(fh2); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_delete_open() */ - /*------------------------------------------------------------------------- * Function: test_id_limits * @@ -2464,26 +2452,26 @@ error: static unsigned test_id_limits(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - H5HF_create_t tmp_cparam; /* Local heap creation parameters */ - unsigned deflate_level; /* Deflation level */ - size_t id_len; /* Size of fractal heap IDs */ - size_t tiny_max_len; /* Max. length of tiny objects */ - hbool_t tiny_len_extended; /* Do tiny objects use two bytes for the length? */ - hbool_t huge_ids_direct; /* Are 'huge' objects directly acccessed? */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + H5HF_create_t tmp_cparam; /* Local heap creation parameters */ + unsigned deflate_level; /* Deflation level */ + size_t id_len; /* Size of fractal heap IDs */ + size_t tiny_max_len; /* Max. length of tiny objects */ + hbool_t tiny_len_extended; /* Do tiny objects use two bytes for the length? */ + hbool_t huge_ids_direct; /* Are 'huge' objects directly acccessed? */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2496,285 +2484,278 @@ test_id_limits(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) /* Copy heap creation properties */ HDmemcpy(&tmp_cparam, cparam, sizeof(H5HF_create_t)); - /* Set the 'default' heap ID length */ tmp_cparam.id_len = 0; /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Test ID length information for heap */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != HEAP_ID_LEN) + if (id_len != HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR - if(tiny_max_len != (HEAP_ID_LEN - 1)) + if (tiny_max_len != (HEAP_ID_LEN - 1)) TEST_ERROR - if(tiny_len_extended != FALSE) + if (tiny_len_extended != FALSE) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(huge_ids_direct != FALSE) + if (huge_ids_direct != FALSE) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; - /* Set the heap ID length to the size needed for directly accessing 'huge' objects */ /* (with no I/O pipeline filters) */ tmp_cparam.id_len = 1; /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Test ID length information for heap */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != 17) + if (id_len != 17) FAIL_STACK_ERROR - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR - if(tiny_max_len != 16) + if (tiny_max_len != 16) TEST_ERROR - if(tiny_len_extended != FALSE) + if (tiny_len_extended != FALSE) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(huge_ids_direct != TRUE) + if (huge_ids_direct != TRUE) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; - /* Set the heap ID length to the size needed for directly accessing 'huge' objects */ /* (with I/O pipeline filters) */ tmp_cparam.id_len = 1; /* Set an I/O filter for heap data */ deflate_level = 6; - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) FAIL_STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Test ID length information for heap */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != 29) + if (id_len != 29) FAIL_STACK_ERROR - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR - if(tiny_max_len != 27) + if (tiny_max_len != 27) TEST_ERROR - if(tiny_len_extended != TRUE) + if (tiny_len_extended != TRUE) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(huge_ids_direct != TRUE) + if (huge_ids_direct != TRUE) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Release the I/O pipeline filter information */ H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); - /* Set the heap ID length to a size that's too small for 'managed' heap IDs */ tmp_cparam.id_len = 3; /* Create absolute heap */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fh = H5HF_create(f, &tmp_cparam); - } H5E_END_TRY; - if(NULL != fh) + } + H5E_END_TRY; + if (NULL != fh) FAIL_STACK_ERROR - /* Set the heap ID length a size that's large enough for 'tiny' & 'managed' * objects, but too small for directly accessing 'huge' objects */ tmp_cparam.id_len = 8; /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Test ID length information for heap */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != 8) + if (id_len != 8) FAIL_STACK_ERROR - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR - if(tiny_max_len != 7) + if (tiny_max_len != 7) TEST_ERROR - if(tiny_len_extended != FALSE) + if (tiny_len_extended != FALSE) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(huge_ids_direct != FALSE) + if (huge_ids_direct != FALSE) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; - /* Set the heap ID length a size that's large enough for directly * directly accessing 'huge' objects */ tmp_cparam.id_len = 17; /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Test ID length information for heap */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != 17) + if (id_len != 17) FAIL_STACK_ERROR - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR - if(tiny_max_len != 16) + if (tiny_max_len != 16) TEST_ERROR - if(tiny_len_extended != FALSE) + if (tiny_len_extended != FALSE) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(huge_ids_direct != TRUE) + if (huge_ids_direct != TRUE) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; - /* Set the heap ID length to the low side of the boundary condition for * encoding 'tiny' objects in one byte */ tmp_cparam.id_len = 18; /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Test ID length information for heap */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != 18) + if (id_len != 18) FAIL_STACK_ERROR - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR - if(tiny_max_len != 16) + if (tiny_max_len != 16) TEST_ERROR - if(tiny_len_extended != FALSE) + if (tiny_len_extended != FALSE) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(huge_ids_direct != TRUE) + if (huge_ids_direct != TRUE) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; - /* Set the heap ID length to the high side of the boundary condition for * encoding 'tiny' objects in one byte */ tmp_cparam.id_len = 19; /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Test ID length information for heap */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != 19) + if (id_len != 19) FAIL_STACK_ERROR - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR - if(tiny_max_len != 17) + if (tiny_max_len != 17) TEST_ERROR - if(tiny_len_extended != TRUE) + if (tiny_len_extended != TRUE) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(huge_ids_direct != TRUE) + if (huge_ids_direct != TRUE) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; - /* Set the heap ID length a size that's larger than what is needed for * directly accessing 'huge' objects */ tmp_cparam.id_len = 45; /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Test ID length information for heap */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != 45) + if (id_len != 45) FAIL_STACK_ERROR - if(H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) + if (H5HF_get_tiny_info_test(fh, &tiny_max_len, &tiny_len_extended) < 0) FAIL_STACK_ERROR - if(tiny_max_len != 43) + if (tiny_max_len != 43) TEST_ERROR - if(tiny_len_extended != TRUE) + if (tiny_len_extended != TRUE) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(huge_ids_direct != TRUE) + if (huge_ids_direct != TRUE) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; - /* Set the heap ID length to a size that's too large to encode the length * of 'tiny' objects */ tmp_cparam.id_len = H5HF_MAX_ID_LEN + 1; /* Create absolute heap */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fh = H5HF_create(f, &tmp_cparam); - } H5E_END_TRY; - if(NULL != fh) + } + H5E_END_TRY; + if (NULL != fh) FAIL_STACK_ERROR - /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* All tests passed */ @@ -2783,15 +2764,16 @@ test_id_limits(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) return 0; error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_id_limits() */ - /*------------------------------------------------------------------------- * Function: test_filtered_create * @@ -2808,24 +2790,24 @@ error: static unsigned test_filtered_create(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - H5HF_create_t tmp_cparam; /* Local heap creation parameters */ - H5HF_create_t test_cparam; /* Temporary local heap creation parameters */ - unsigned deflate_level; /* Deflation level */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + H5HF_create_t tmp_cparam; /* Local heap creation parameters */ + H5HF_create_t test_cparam; /* Temporary local heap creation parameters */ + unsigned deflate_level; /* Deflation level */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2838,37 +2820,36 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) /* Copy heap creation properties */ HDmemcpy(&tmp_cparam, cparam, sizeof(H5HF_create_t)); - /* Set an I/O filter for heap data */ deflate_level = 6; - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) FAIL_STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, &tmp_cparam))) + if (NULL == (fh = H5HF_create(f, &tmp_cparam))) FAIL_STACK_ERROR /* Get heap's address */ - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2876,24 +2857,23 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Query the heap creation parameters */ HDmemset(&test_cparam, 0, sizeof(H5HF_create_t)); - if(H5HF_get_cparam_test(fh, &test_cparam) < 0) + if (H5HF_get_cparam_test(fh, &test_cparam) < 0) FAIL_STACK_ERROR - if(H5HF_cmp_cparam_test(&tmp_cparam, &test_cparam)) + if (H5HF_cmp_cparam_test(&tmp_cparam, &test_cparam)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; - /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Release the I/O pipeline filter information */ @@ -2906,15 +2886,16 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) return 0; error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_filtered_create() */ - /*------------------------------------------------------------------------- * Function: test_size * @@ -2931,24 +2912,24 @@ error: static unsigned test_size(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - hsize_t empty_heap_size; /* Total size of empty heap on disk */ - hsize_t one_heap_size; /* Total size of heap on disk after inserting one object */ - hsize_t heap_size; /* Total size of heap on disk */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t *fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + hsize_t empty_heap_size; /* Total size of empty heap on disk */ + hsize_t one_heap_size; /* Total size of heap on disk after inserting one object */ + hsize_t heap_size; /* Total size of heap on disk */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2958,51 +2939,49 @@ test_size(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) /* Display testing message */ TESTING("querying heap statistics") - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR /* Get heap's address */ - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR /* Get an empty heap's size */ empty_heap_size = 0; - if(H5HF_size(fh, &empty_heap_size) < 0) + if (H5HF_size(fh, &empty_heap_size) < 0) FAIL_STACK_ERROR - if(empty_heap_size == 0) + if (empty_heap_size == 0) TEST_ERROR /* Insert an object */ - if(add_obj(fh, (size_t)0, (size_t)10, NULL, NULL) < 0) + if (add_obj(fh, (size_t)0, (size_t)10, NULL, NULL) < 0) TEST_ERROR /* Get the heap's size after inserting one object */ one_heap_size = 0; - if(H5HF_size(fh, &one_heap_size) < 0) + if (H5HF_size(fh, &one_heap_size) < 0) FAIL_STACK_ERROR - if(one_heap_size <= empty_heap_size) + if (one_heap_size <= empty_heap_size) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3010,34 +2989,34 @@ test_size(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Check the heap's size */ heap_size = 0; - if(H5HF_size(fh, &heap_size) < 0) + if (H5HF_size(fh, &heap_size) < 0) FAIL_STACK_ERROR - if(heap_size != one_heap_size) + if (heap_size != one_heap_size) TEST_ERROR /* Insert another object */ - if(add_obj(fh, (size_t)1, (size_t)10, NULL, NULL) < 0) + if (add_obj(fh, (size_t)1, (size_t)10, NULL, NULL) < 0) TEST_ERROR /* Check the heap's size */ heap_size = 0; - if(H5HF_size(fh, &heap_size) < 0) + if (H5HF_size(fh, &heap_size) < 0) FAIL_STACK_ERROR - if(heap_size != one_heap_size) + if (heap_size != one_heap_size) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* All tests passed */ @@ -3046,15 +3025,16 @@ test_size(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) return 0; error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_size() */ - /*------------------------------------------------------------------------- * Function: test_reopen_hdr * @@ -3074,23 +3054,23 @@ error: static unsigned test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) { - hid_t file1 = -1; /* File ID */ - hid_t file2 = -2; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - hsize_t heap_size; /* Total size of heap on disk */ + hid_t file1 = -1; /* File ID */ + hid_t file2 = -2; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t *fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + hsize_t heap_size; /* Total size of heap on disk */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file1))) + if (NULL == (f = (H5F_t *)H5VL_object(file1))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3100,41 +3080,39 @@ test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) /* Display testing message */ TESTING("reopening header through different file") - /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR /* Get heap's address */ - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR /* Insert an object */ - if(add_obj(fh, (size_t)0, (size_t)10, NULL, NULL) < 0) + if (add_obj(fh, (size_t)0, (size_t)10, NULL, NULL) < 0) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file1) < 0) + if (H5Fclose(file1) < 0) FAIL_STACK_ERROR - /* Re-open the file */ - if((file1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Re-open the file again */ - if((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object (file1) */ - if(NULL == (f = (H5F_t *)H5VL_object(file1))) + if (NULL == (f = (H5F_t *)H5VL_object(file1))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3142,58 +3120,58 @@ test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* Open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Close the heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file (file1) */ - if(H5Fclose(file1) < 0) + if (H5Fclose(file1) < 0) FAIL_STACK_ERROR - /* Get a pointer to the internal file object (file2) */ - if(NULL == (f = (H5F_t *)H5VL_object(file2))) + if (NULL == (f = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Reopen the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Check the heap's size */ heap_size = 0; - if(H5HF_size(fh, &heap_size) < 0) + if (H5HF_size(fh, &heap_size) < 0) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR - /* Close the file (file2) */ - if(H5Fclose(file2) < 0) + if (H5Fclose(file2) < 0) FAIL_STACK_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); H5Fclose(file1); H5Fclose(file2); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_reopen_hdr() */ #ifndef QAK2 - + /*------------------------------------------------------------------------- * Function: test_man_insert_weird * @@ -3210,25 +3188,25 @@ error: static unsigned test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_state_t state; /* State of fractal heap */ - herr_t ret; /* Generic return value */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_state_t state; /* State of fractal heap */ + herr_t ret; /* Generic return value */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3236,22 +3214,22 @@ test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa FAIL_STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) TEST_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* @@ -3260,50 +3238,54 @@ test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa TESTING("inserting 'weird' sized objects into absolute heap"); /* Attempt to insert 0-sized object into heap */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5HF_insert(fh, (size_t)0, shared_wobj_g, heap_id); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR H5Eclear2(H5E_DEFAULT); /* Insert a 1-sized object into heap (should be a 'tiny' object) */ - if(add_obj(fh, (size_t)10, (size_t)1, &state, NULL)) + if (add_obj(fh, (size_t)10, (size_t)1, &state, NULL)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check for correctly sized heap */ - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_insert_weird() */ #ifdef ALL_INSERT_TESTS - + /*------------------------------------------------------------------------- * Function: test_man_insert_first * @@ -3321,23 +3303,23 @@ error: static unsigned test_man_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3345,65 +3327,66 @@ test_man_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa FAIL_STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) TEST_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) TEST_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* * Test inserting first (small) object into absolute heap */ TESTING("inserting first (small) object into absolute heap"); - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check for correctly sized heap */ - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_insert_first() */ - /*------------------------------------------------------------------------- * Function: test_man_insert_second * @@ -3421,23 +3404,23 @@ error: static unsigned test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3445,15 +3428,15 @@ test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -3461,43 +3444,44 @@ test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp * Test inserting first (small) object into absolute heap */ TESTING("inserting two (small) objects into absolute heap"); - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert second object */ - if(add_obj(fh, (size_t)20, SMALL_OBJ_SIZE2, &state, NULL)) + if (add_obj(fh, (size_t)20, SMALL_OBJ_SIZE2, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_insert_second() */ - /*------------------------------------------------------------------------- * Function: test_man_insert_root_mult * @@ -3516,24 +3500,24 @@ error: static unsigned test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3541,15 +3525,15 @@ test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -3562,39 +3546,40 @@ test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t fill_size = get_fill_size(tparam); /* Fill the heap up */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, NULL)) + if (fill_heap(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_insert_root_mult() */ - /*------------------------------------------------------------------------- * Function: test_man_insert_force_indirect * @@ -3614,24 +3599,24 @@ error: static unsigned test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3639,15 +3624,15 @@ test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -3660,46 +3645,47 @@ test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par fill_size = get_fill_size(tparam); /* Fill the heap up */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, NULL)) + if (fill_heap(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force root indirect block creation */ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_alloc_size += DBLOCK_SIZE(fh, 0); state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_insert_force_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_insert_fill_second * @@ -3719,24 +3705,24 @@ error: static unsigned test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3744,15 +3730,15 @@ test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -3765,46 +3751,47 @@ test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ fill_size = get_fill_size(tparam); /* Fill the first direct block heap up */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, NULL)) + if (fill_heap(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill the second direct block heap up (also creates initial root indirect block) */ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_alloc_size += DBLOCK_SIZE(fh, 0); state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, NULL)) + if (fill_heap(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_insert_fill_second() */ - /*------------------------------------------------------------------------- * Function: test_man_insert_third_direct * @@ -3825,24 +3812,24 @@ error: static unsigned test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3850,15 +3837,15 @@ test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -3871,51 +3858,52 @@ test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param fill_size = get_fill_size(tparam); /* Fill the first direct block up */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, NULL)) + if (fill_heap(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill the second direct block heap up (also creates initial root indirect block) */ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_alloc_size += DBLOCK_SIZE(fh, 0); state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, NULL)) + if (fill_heap(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force creation of third direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_insert_third_direct() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_first_row * @@ -3935,24 +3923,24 @@ error: static unsigned test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3960,15 +3948,15 @@ test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -3981,36 +3969,37 @@ test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t fill_size = get_fill_size(tparam); /* Fill first row of [root] indirect block */ - if(fill_root_row(fh, 0, fill_size, &state, NULL)) + if (fill_root_row(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_first_row() */ - /*------------------------------------------------------------------------- * Function: test_man_start_second_row * @@ -4030,24 +4019,24 @@ error: static unsigned test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4055,15 +4044,15 @@ test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4076,43 +4065,44 @@ test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t fill_size = get_fill_size(tparam); /* Fill first root indirect row */ - if(fill_root_row(fh, 0, fill_size, &state, NULL)) + if (fill_root_row(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force expanding root indirect block to two rows */ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1); state.man_alloc_size += DBLOCK_SIZE(fh, 1); state.man_free_space = cparam->managed.width * DBLOCK_FREE(fh, 1); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_start_second_row() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_second_row * @@ -4132,24 +4122,24 @@ error: static unsigned test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4157,15 +4147,15 @@ test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4178,40 +4168,41 @@ test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * fill_size = get_fill_size(tparam); /* Fill first root indirect row */ - if(fill_root_row(fh, 0, fill_size, &state, NULL)) + if (fill_root_row(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill second root indirect row */ - if(fill_root_row(fh, 1, fill_size, &state, NULL)) + if (fill_root_row(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_second_row() */ - /*------------------------------------------------------------------------- * Function: test_man_start_third_row * @@ -4232,24 +4223,24 @@ error: static unsigned test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4257,15 +4248,15 @@ test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4278,15 +4269,15 @@ test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * fill_size = get_fill_size(tparam); /* Fill first root indirect row */ - if(fill_root_row(fh, 0, fill_size, &state, NULL)) + if (fill_root_row(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill second root indirect row */ - if(fill_root_row(fh, 1, fill_size, &state, NULL)) + if (fill_root_row(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force expanding root indirect block to four rows */ @@ -4296,32 +4287,33 @@ test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * state.man_alloc_size += DBLOCK_SIZE(fh, 2); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 3); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_start_third_row() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_fourth_row * @@ -4341,25 +4333,25 @@ error: static unsigned test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned u; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned u; /* Local index variables */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4367,15 +4359,15 @@ test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4388,37 +4380,38 @@ test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * fill_size = get_fill_size(tparam); /* Loop over rows */ - for(u = 0; u < 4; u++) - if(fill_root_row(fh, u, fill_size, &state, NULL)) + for (u = 0; u < 4; u++) + if (fill_root_row(fh, u, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_fourth_row() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_all_root_direct * @@ -4438,24 +4431,24 @@ error: static unsigned test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4463,15 +4456,15 @@ test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4484,36 +4477,37 @@ test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para fill_size = get_fill_size(tparam); /* Fill all direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_all_root_direct() */ - /*------------------------------------------------------------------------- * Function: test_man_first_recursive_indirect * @@ -4533,24 +4527,24 @@ error: static unsigned test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4558,15 +4552,15 @@ test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_ STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4579,41 +4573,42 @@ test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_ fill_size = get_fill_size(tparam); /* Fill direct blocks up */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force creation of first recursive indirect block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_first_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_second_direct_recursive_indirect * @@ -4634,24 +4629,24 @@ error: static unsigned test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4659,15 +4654,15 @@ test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4681,48 +4676,49 @@ test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe fill_size = get_fill_size(tparam); /* Fill direct blocks up */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill the first direct block in the recursive indirect block up */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, NULL)) + if (fill_heap(fh, 0, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force creation of second direct block in * first recursive indirect block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_second_direct_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_first_recursive_indirect * @@ -4743,24 +4739,24 @@ error: static unsigned test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4768,15 +4764,15 @@ test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_ STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4790,40 +4786,41 @@ test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_ fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first recursive indirect block */ - if(fill_2nd_indirect(fh, 1, fill_size, &state, NULL)) + if (fill_2nd_indirect(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_first_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_second_recursive_indirect * @@ -4845,24 +4842,24 @@ error: static unsigned test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4870,15 +4867,15 @@ test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -4892,47 +4889,48 @@ test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill first recursive indirect block */ - if(fill_2nd_indirect(fh, 1, fill_size, &state, NULL)) + if (fill_2nd_indirect(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force creation of second * recursive indirect block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_second_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_second_recursive_indirect * @@ -4955,24 +4953,24 @@ error: static unsigned test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4980,15 +4978,15 @@ test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5002,44 +5000,45 @@ test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill first recursive indirect block */ - if(fill_2nd_indirect(fh, 1, fill_size, &state, NULL)) + if (fill_2nd_indirect(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill 2nd recursive indirect block */ - if(fill_2nd_indirect(fh, 1, fill_size, &state, NULL)) + if (fill_2nd_indirect(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_second_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_recursive_indirect_row * @@ -5062,36 +5061,36 @@ error: static unsigned test_man_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5105,40 +5104,41 @@ test_man_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te fill_size = get_fill_size(tparam); /* Fill direct blocks in root indirect block up */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill row of recursive indirect blocks */ - if(fill_2nd_indirect_row(fh, 1, fill_size, &state, NULL)) + if (fill_2nd_indirect_row(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_recursive_indirect_row() */ - /*------------------------------------------------------------------------- * Function: test_man_start_2nd_recursive_indirect * @@ -5159,24 +5159,24 @@ error: static unsigned test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5184,15 +5184,15 @@ test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5206,47 +5206,48 @@ test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t fill_size = get_fill_size(tparam); /* Fill direct blocks in root indirect block up */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill row of recursive indirect blocks */ - if(fill_2nd_indirect_row(fh, 1, fill_size, &state, NULL)) + if (fill_2nd_indirect_row(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force creation of second * recursive indirect block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_start_2nd_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_recursive_indirect_two_deep * @@ -5267,24 +5268,24 @@ error: static unsigned test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5292,15 +5293,15 @@ test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5314,40 +5315,41 @@ test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_recursive_indirect_two_deep() */ - /*------------------------------------------------------------------------- * Function: test_man_start_3rd_recursive_indirect * @@ -5369,24 +5371,24 @@ error: static unsigned test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5394,15 +5396,15 @@ test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5416,47 +5418,48 @@ test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force creation of third level deep * recursive indirect block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_start_3rd_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_first_3rd_recursive_indirect * @@ -5478,24 +5481,24 @@ error: static unsigned test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5503,15 +5506,15 @@ test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5525,48 +5528,49 @@ test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all direct block rows in third level indirect block */ - if(fill_all_direct(fh, fill_size, &state, NULL)) + if (fill_all_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill row of recursive indirect blocks in third level indirect block */ - if(fill_2nd_indirect_row(fh, 1, fill_size, &state, NULL)) + if (fill_2nd_indirect_row(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_first_3rd_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_3rd_recursive_indirect_row * @@ -5588,24 +5592,24 @@ error: static unsigned test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5613,15 +5617,15 @@ test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5629,50 +5633,52 @@ test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea * Test inserting mult. (small) objects to fill all direct * blocks in first recursive indirect block */ - TESTING("inserting objects to fill row of indirect blocks in recursive indirect blocks three levels deep"); + TESTING( + "inserting objects to fill row of indirect blocks in recursive indirect blocks three levels deep"); /* Retrieve "bulk" filling object size */ fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill 1st row of 3rd level indirect blocks */ - if(fill_3rd_indirect_row(fh, 1, fill_size, &state, NULL)) + if (fill_3rd_indirect_row(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_3rd_recursive_indirect_row() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_all_3rd_recursive_indirect * @@ -5694,24 +5700,24 @@ error: static unsigned test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5719,15 +5725,15 @@ test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5735,50 +5741,52 @@ test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea * Test inserting mult. (small) objects to fill all direct * blocks in first recursive indirect block */ - TESTING("inserting objects to fill row of indirect blocks in recursive indirect blocks three levels deep"); + TESTING( + "inserting objects to fill row of indirect blocks in recursive indirect blocks three levels deep"); /* Retrieve "bulk" filling object size */ fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_all_3rd_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_start_4th_recursive_indirect * @@ -5801,24 +5809,24 @@ error: static unsigned test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5826,15 +5834,15 @@ test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5848,51 +5856,52 @@ test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force creation of four level deep * recursive indirect block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_start_4th_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_first_4th_recursive_indirect * @@ -5915,24 +5924,24 @@ error: static unsigned test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5940,15 +5949,15 @@ test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -5956,62 +5965,64 @@ test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh * Test inserting mult. (small) objects to fill all direct * blocks in first recursive indirect block */ - TESTING("inserting objects to fill first (3rd level) indirect block in recursive indirect block four levels deep"); + TESTING("inserting objects to fill first (3rd level) indirect block in recursive indirect block four " + "levels deep"); /* Retrieve "bulk" filling object size */ fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill direct block rows in fourth level indirect block */ - if(fill_all_direct(fh, fill_size, &state, NULL)) + if (fill_all_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level deep indirect blocks in fourth level indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row of 3rd level deep indirect blocks in fourth level indirect block */ - if(fill_3rd_indirect_row(fh, 1, fill_size, &state, NULL)) + if (fill_3rd_indirect_row(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_first_4th_recursive_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_4th_recursive_indirect_row * @@ -6034,24 +6045,24 @@ error: static unsigned test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6059,15 +6070,15 @@ test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -6081,48 +6092,49 @@ test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill 1st row of 4th level indirect blocks */ - if(fill_4th_indirect_row(fh, 1, fill_size, &state, NULL)) + if (fill_4th_indirect_row(fh, 1, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_4th_recursive_indirect_row() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_all_4th_recursive_indirect * @@ -6145,24 +6157,24 @@ error: static unsigned test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6170,15 +6182,15 @@ test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -6192,50 +6204,52 @@ test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 4th level indirect blocks */ - if(fill_all_4th_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_4th_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_all_4th_recursive_indirect() */ #endif /* ALL_INSERT_TESTS */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_man_start_5th_recursive_indirect * @@ -6259,24 +6273,24 @@ error: static unsigned test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6284,15 +6298,15 @@ test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); @@ -6307,69 +6321,71 @@ test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t fill_size = get_fill_size(tparam); /* Fill direct blocks up in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap & file */ - if(reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) + if (reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap & file */ - if(reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) + if (reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap & file */ - if(reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) + if (reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 4th level indirect blocks */ - if(fill_all_4th_indirect_rows(fh, fill_size, &state, NULL)) + if (fill_all_4th_indirect_rows(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap & file */ - if(reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) + if (reopen_file(&file, &f, filename, fapl, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to force creation of five level deep * recursive indirect block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, NULL)) + if (add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, NULL)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_start_5th_recursive_indirect() */ #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_man_remove_bogus * @@ -6387,29 +6403,29 @@ error: static unsigned test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ - unsigned long seed = 0; /* Random # seed */ - size_t id_len; /* Size of fractal heap IDs */ - hsize_t obj_off; /* Offset of object in heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ + unsigned long seed = 0; /* Random # seed */ + size_t id_len; /* Size of fractal heap IDs */ + hsize_t obj_off; /* Offset of object in heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6417,22 +6433,22 @@ test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* @@ -6446,83 +6462,90 @@ test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa /* Choose random # seed */ seed = (unsigned long)HDtime(NULL); #ifdef QAK -/* seed = (unsigned long)1155438845; */ -HDfprintf(stderr, "Random # seed was: %lu\n", seed); + /* seed = (unsigned long)1155438845; */ + HDfprintf(stderr, "Random # seed was: %lu\n", seed); #endif /* QAK */ HDsrandom((unsigned)seed); /* Set heap ID to random (non-null) value */ heap_id[0] = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; - for(u = 1; u < HEAP_ID_LEN; u++) + for (u = 1; u < HEAP_ID_LEN; u++) heap_id[u] = (unsigned char)(HDrandom() + 1); /* Try removing bogus heap ID from empty heap */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5HF_remove(fh, heap_id); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) FAIL_STACK_ERROR /* Fill root direct blocks */ - if(fill_root_direct(fh, fill_size, &state, NULL)) + if (fill_root_direct(fh, fill_size, &state, NULL)) FAIL_STACK_ERROR /* Get offset of random heap ID */ - if(H5HF_get_id_off_test(fh, heap_id, &obj_off) < 0) + if (H5HF_get_id_off_test(fh, heap_id, &obj_off) < 0) FAIL_STACK_ERROR /* Make certain we can't accidentally use a valid heap ID */ - while(obj_off < state.man_size) { + while (obj_off < state.man_size) { /* Set heap ID to random (non-null) value */ heap_id[0] = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; - for(u = 1; u < HEAP_ID_LEN; u++) + for (u = 1; u < HEAP_ID_LEN; u++) heap_id[u] = (unsigned char)(HDrandom() + 1); /* Get offset of random heap ID */ - if(H5HF_get_id_off_test(fh, heap_id, &obj_off) < 0) + if (H5HF_get_id_off_test(fh, heap_id, &obj_off) < 0) FAIL_STACK_ERROR } /* end while */ /* Try removing bogus heap ID from heap w/objects */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5HF_remove(fh, heap_id); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR H5Eclear2(H5E_DEFAULT); /* Try reading bogus heap ID from heap w/objects */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5HF_read(fh, heap_id, shared_robj_g); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR H5Eclear2(H5E_DEFAULT); /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: HDfprintf(stderr, "Random # seed was: %lu\n", seed); - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_bogus() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_one * @@ -6540,28 +6563,28 @@ error: static unsigned test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ - unsigned char obj[SMALL_OBJ_SIZE1]; /* Buffer for object to insert */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ + unsigned char obj[SMALL_OBJ_SIZE1]; /* Buffer for object to insert */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned u; /* Local index variable */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6569,40 +6592,40 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Prepare for querying the size of a file with an empty heap */ /* Close (empty) heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6610,7 +6633,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara STACK_ERROR /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* @@ -6619,73 +6642,74 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara TESTING("removing single object from absolute heap"); /* Initialize the buffer for objects to insert */ - for(u = 0; u < sizeof(obj); u++) + for (u = 0; u < sizeof(obj); u++) obj[u] = (unsigned char)u; /* Insert object into heap */ - if(H5HF_insert(fh, sizeof(obj), obj, &heap_id) < 0) + if (H5HF_insert(fh, sizeof(obj), obj, &heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0) - sizeof(obj); - state.man_nobjs = 1; - if(check_stats(fh, &state)) + state.man_nobjs = 1; + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.man_size = 0; + state.man_size = 0; state.man_alloc_size = 0; state.man_free_space = 0; - state.man_nobjs = 0; - if(check_stats(fh, &state)) + state.man_nobjs = 0; + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_one() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_two * @@ -6703,29 +6727,29 @@ error: static unsigned test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */ - unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */ - unsigned char obj[SMALL_OBJ_SIZE1]; /* Buffer for object to insert */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */ + unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */ + unsigned char obj[SMALL_OBJ_SIZE1]; /* Buffer for object to insert */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned u; /* Local index variable */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6733,40 +6757,40 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Prepare for querying the size of a file with an empty heap */ /* Close (empty) heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6774,7 +6798,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara STACK_ERROR /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* @@ -6783,101 +6807,102 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara TESTING("removing two objects from absolute heap"); /* Initialize the buffer for objects to insert */ - for(u = 0; u < sizeof(obj); u++) + for (u = 0; u < sizeof(obj); u++) obj[u] = (unsigned char)u; /* Insert first object into heap */ - if(H5HF_insert(fh, sizeof(obj), obj, &heap_id1) < 0) + if (H5HF_insert(fh, sizeof(obj), obj, &heap_id1) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0) - sizeof(obj); - state.man_nobjs = 1; - if(check_stats(fh, &state)) + state.man_nobjs = 1; + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Insert second object into heap */ - if(H5HF_insert(fh, sizeof(obj), obj, &heap_id2) < 0) + if (H5HF_insert(fh, sizeof(obj), obj, &heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.man_free_space -= sizeof(obj); state.man_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id1) < 0) + if (H5HF_remove(fh, heap_id1) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.man_free_space += sizeof(obj); state.man_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.man_size = 0; + state.man_size = 0; state.man_alloc_size = 0; state.man_free_space = 0; - state.man_nobjs = 0; - if(check_stats(fh, &state)) + state.man_nobjs = 0; + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_two() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_one_larger * @@ -6896,29 +6921,29 @@ error: static unsigned test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ - unsigned char *obj; /* Buffer for object to insert */ - size_t obj_len; /* Length of object to insert */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ + unsigned char * obj; /* Buffer for object to insert */ + size_t obj_len; /* Length of object to insert */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned u; /* Local index variable */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6926,40 +6951,40 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Prepare for querying the size of a file with an empty heap */ /* Close (empty) heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6967,7 +6992,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t STACK_ERROR /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* @@ -6977,75 +7002,76 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t /* Set up object to insert */ obj_len = (size_t)DBLOCK_SIZE(fh, 2) + 1; - obj = shared_wobj_g; + obj = shared_wobj_g; /* Insert object into heap */ - if(H5HF_insert(fh, obj_len, obj, &heap_id) < 0) + if (H5HF_insert(fh, obj_len, obj, &heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size = DBLOCK_SIZE(fh, 3); state.man_free_space -= obj_len; state.man_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.man_size = 0; + state.man_size = 0; state.man_alloc_size = 0; state.man_free_space = 0; - state.man_nobjs = 0; - if(check_stats(fh, &state)) + state.man_nobjs = 0; + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_one_larger() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_two_larger * @@ -7064,30 +7090,30 @@ error: static unsigned test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */ - unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */ - unsigned char *obj; /* Buffer for object to insert */ - size_t obj_len; /* Length of object to insert */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */ + unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */ + unsigned char * obj; /* Buffer for object to insert */ + size_t obj_len; /* Length of object to insert */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned u; /* Local index variable */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7095,40 +7121,40 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Prepare for querying the size of a file with an empty heap */ /* Close (empty) heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7136,159 +7162,160 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t STACK_ERROR /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* * Test removing two larger objects from absolute heap */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->del_dir == FHEAP_DEL_FORWARD) TESTING("removing two larger objects from absolute heap (forward)") else TESTING("removing two larger objects from absolute heap (reverse)") /* Set up first object to insert */ obj_len = (size_t)DBLOCK_SIZE(fh, 2) + 1; - obj = shared_wobj_g; + obj = shared_wobj_g; /* Insert object into heap */ - if(H5HF_insert(fh, obj_len, obj, &heap_id1) < 0) + if (H5HF_insert(fh, obj_len, obj, &heap_id1) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size = DBLOCK_SIZE(fh, 3); state.man_free_space -= obj_len; state.man_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Set up second object to insert */ obj_len = (size_t)DBLOCK_SIZE(fh, 4) + 1; - obj = shared_wobj_g; + obj = shared_wobj_g; /* Insert object into heap */ - if(H5HF_insert(fh, obj_len, obj, &heap_id2) < 0) + if (H5HF_insert(fh, obj_len, obj, &heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ /* (Goes to 8 rows because of doubling) */ - for(u = 4; u < 8; u++) { + for (u = 4; u < 8; u++) { state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size += DBLOCK_SIZE(fh, 5); state.man_free_space -= obj_len; state.man_nobjs = 2; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove objects in different orders */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) { + if (tparam->del_dir == FHEAP_DEL_FORWARD) { /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id1) < 0) + if (H5HF_remove(fh, heap_id1) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.man_alloc_size -= DBLOCK_SIZE(fh, 3); state.man_free_space += DBLOCK_SIZE(fh, 2) + 1; state.man_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR } /* end if */ else { /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ /* (Goes to 4 rows because of halving) */ - for(u = 4; u < 8; u++) { + for (u = 4; u < 8; u++) { state.man_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space -= DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size -= DBLOCK_SIZE(fh, 5); state.man_free_space += DBLOCK_SIZE(fh, 4) + 1; state.man_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id1) < 0) + if (H5HF_remove(fh, heap_id1) < 0) FAIL_STACK_ERROR } /* end else */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.man_size = 0; + state.man_size = 0; state.man_alloc_size = 0; state.man_free_space = 0; - state.man_nobjs = 0; - if(check_stats(fh, &state)) + state.man_nobjs = 0; + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - /* Verify the file is correct size */ + /* Verify the file is correct size */ #ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_two_larger() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_three_larger * @@ -7307,31 +7334,31 @@ error: static unsigned test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */ - unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */ - unsigned char heap_id3[HEAP_ID_LEN]; /* Heap ID for third object */ - unsigned char *obj; /* Buffer for object to insert */ - size_t obj_len; /* Length of object to insert */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for first object */ + unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for second object */ + unsigned char heap_id3[HEAP_ID_LEN]; /* Heap ID for third object */ + unsigned char * obj; /* Buffer for object to insert */ + size_t obj_len; /* Length of object to insert */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned u; /* Local index variable */ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7339,40 +7366,40 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Prepare for querying the size of a file with an empty heap */ /* Close (empty) heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7380,218 +7407,219 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param STACK_ERROR /* Re-open heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* * Test removing three larger objects from absolute heap */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) + if (tparam->del_dir == FHEAP_DEL_FORWARD) TESTING("removing three larger objects from absolute heap (forward)") else TESTING("removing three larger objects from absolute heap (reverse)") /* Set up first object to insert */ obj_len = (size_t)DBLOCK_SIZE(fh, 2) + 1; - obj = shared_wobj_g; + obj = shared_wobj_g; /* Insert object into heap */ - if(H5HF_insert(fh, obj_len, obj, &heap_id1) < 0) + if (H5HF_insert(fh, obj_len, obj, &heap_id1) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size = DBLOCK_SIZE(fh, 3); state.man_free_space -= obj_len; state.man_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Set up second object to insert */ obj_len = (size_t)DBLOCK_SIZE(fh, 4) + 1; - obj = shared_wobj_g; + obj = shared_wobj_g; /* Insert object into heap */ - if(H5HF_insert(fh, obj_len, obj, &heap_id2) < 0) + if (H5HF_insert(fh, obj_len, obj, &heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ /* (Goes to 8 rows because of doubling) */ - for(u = 4; u < 8; u++) { + for (u = 4; u < 8; u++) { state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size += DBLOCK_SIZE(fh, 5); state.man_free_space -= obj_len; state.man_nobjs = 2; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Set up third object to insert */ obj_len = (size_t)DBLOCK_SIZE(fh, 7) + 1; - obj = shared_wobj_g; + obj = shared_wobj_g; /* Insert object into heap */ - if(H5HF_insert(fh, obj_len, obj, &heap_id3) < 0) + if (H5HF_insert(fh, obj_len, obj, &heap_id3) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ /* (Goes to 16 rows because of doubling) */ - for(u = 8; u < 16; u++) { + for (u = 8; u < 16; u++) { state.man_size += DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size += DBLOCK_SIZE(fh, 8); state.man_free_space -= obj_len; state.man_nobjs = 3; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove objects in different orders */ - if(tparam->del_dir == FHEAP_DEL_FORWARD) { + if (tparam->del_dir == FHEAP_DEL_FORWARD) { /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id1) < 0) + if (H5HF_remove(fh, heap_id1) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.man_alloc_size -= DBLOCK_SIZE(fh, 3); state.man_free_space += DBLOCK_SIZE(fh, 2) + 1; state.man_nobjs = 2; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.man_alloc_size -= DBLOCK_SIZE(fh, 5); state.man_free_space += DBLOCK_SIZE(fh, 4) + 1; state.man_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove third object from heap */ - if(H5HF_remove(fh, heap_id3) < 0) + if (H5HF_remove(fh, heap_id3) < 0) FAIL_STACK_ERROR } /* end if */ else { /* Remove third object from heap */ - if(H5HF_remove(fh, heap_id3) < 0) + if (H5HF_remove(fh, heap_id3) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ /* (Goes to 8 rows because of halving) */ - for(u = 8; u < 16; u++) { + for (u = 8; u < 16; u++) { state.man_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space -= DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size -= DBLOCK_SIZE(fh, 8); state.man_free_space += DBLOCK_SIZE(fh, 7) + 1; state.man_nobjs = 2; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ /* (Goes to 4 rows because of halving) */ - for(u = 4; u < 8; u++) { + for (u = 4; u < 8; u++) { state.man_size -= DBLOCK_SIZE(fh, u) * cparam->managed.width; state.man_free_space -= DBLOCK_FREE(fh, u) * cparam->managed.width; } /* end for */ state.man_alloc_size -= DBLOCK_SIZE(fh, 5); state.man_free_space += DBLOCK_SIZE(fh, 4) + 1; state.man_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id1) < 0) + if (H5HF_remove(fh, heap_id1) < 0) FAIL_STACK_ERROR } /* end else */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.man_size = 0; + state.man_size = 0; state.man_alloc_size = 0; state.man_free_space = 0; - state.man_nobjs = 0; - if(check_stats(fh, &state)) + state.man_nobjs = 0; + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - /* Verify the file is correct size */ + /* Verify the file is correct size */ #ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_three_larger() */ - /*------------------------------------------------------------------------- * Function: test_man_incr_insert_remove * @@ -7608,57 +7636,57 @@ error: static unsigned test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - unsigned char **heap_id = NULL; - unsigned char *heap_id_data = NULL; + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + unsigned char **heap_id = NULL; + unsigned char * heap_id_data = NULL; struct a_type_t1 { char a[10]; char b[40]; - } obj1, obj2; /* Objects to insert/remove */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_state_t state; /* State of fractal heap */ - int i, j; + } obj1, obj2; /* Objects to insert/remove */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_state_t state; /* State of fractal heap */ + int i, j; /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Set up data array */ - if(NULL == (heap_id_data = (unsigned char *)HDcalloc(100 * MAX_HEAP_ID_LEN, sizeof(unsigned char)))) + if (NULL == (heap_id_data = (unsigned char *)HDcalloc(100 * MAX_HEAP_ID_LEN, sizeof(unsigned char)))) TEST_ERROR; - if(NULL == (heap_id = (unsigned char **)HDcalloc(100, sizeof(heap_id_data)))) + if (NULL == (heap_id = (unsigned char **)HDcalloc(100, sizeof(heap_id_data)))) TEST_ERROR; for (i = 0; i < 100; i++) heap_id[i] = heap_id_data + (i * MAX_HEAP_ID_LEN); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) STACK_ERROR /* Create absolute heap */ - if(NULL == (fh = H5HF_create(f, cparam))) + if (NULL == (fh = H5HF_create(f, cparam))) FAIL_STACK_ERROR - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > HEAP_ID_LEN) + if (id_len > HEAP_ID_LEN) FAIL_STACK_ERROR - if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + if (H5HF_get_heap_addr(fh, &fh_addr) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fh_addr)) + if (!H5F_addr_defined(fh_addr)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) FAIL_STACK_ERROR /* @@ -7668,33 +7696,33 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ HDmemset(&obj1, 0, sizeof(obj1)); HDmemset(&obj2, 0, sizeof(obj2)); - for(i = 0; i < 100; i++) { - for(j = 0; j < i; j++) { - if(H5HF_remove(fh, heap_id[j]) < 0) + for (i = 0; i < 100; i++) { + for (j = 0; j < i; j++) { + if (H5HF_remove(fh, heap_id[j]) < 0) FAIL_STACK_ERROR HDsprintf(obj2.b, "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", j); - if(H5HF_insert(fh, (sizeof(obj2)), &obj2, heap_id[j]) < 0) + if (H5HF_insert(fh, (sizeof(obj2)), &obj2, heap_id[j]) < 0) FAIL_STACK_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object */ HDmemset(heap_id[i], 0, id_len); HDsprintf(obj1.b, "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", i); - if(H5HF_insert(fh, (sizeof(obj1)), &obj1, heap_id[i]) < 0) + if (H5HF_insert(fh, (sizeof(obj1)), &obj1, heap_id[i]) < 0) FAIL_STACK_ERROR } /* end for */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* All tests passed */ @@ -7706,11 +7734,13 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ return 0; error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; + H5Fclose(file); + } + H5E_END_TRY; HDfree(heap_id); HDfree(heap_id_data); @@ -7720,7 +7750,7 @@ error: #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_man_remove_root_direct * @@ -7739,36 +7769,35 @@ error: static unsigned test_man_remove_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from root direct block of absolute heap %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "removing all objects from root direct block of absolute heap %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill the heap up */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, &keep_ids)) + if (fill_heap(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -7779,21 +7808,22 @@ test_man_remove_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_root_direct() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_two_direct * @@ -7812,51 +7842,50 @@ error: static unsigned test_man_remove_two_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from two direct blocks of absolute heap %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "removing all objects from two direct blocks of absolute heap %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill the first block in heap */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, &keep_ids)) + if (fill_heap(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Fill the second block in heap */ state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_alloc_size += DBLOCK_SIZE(fh, 0); state.man_free_space = (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, &keep_ids)) + if (fill_heap(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -7867,21 +7896,22 @@ test_man_remove_two_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_two_direct() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_first_row * @@ -7900,33 +7930,32 @@ error: static unsigned test_man_remove_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from first row of direct blocks of absolute heap %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "removing all objects from first row of direct blocks of absolute heap %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill first row of direct blocks */ - if(fill_root_row(fh, 0, fill_size, &state, &keep_ids)) + if (fill_root_row(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -7937,21 +7966,22 @@ test_man_remove_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_first_row() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_first_two_rows * @@ -7970,35 +8000,35 @@ error: static unsigned test_man_remove_first_two_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from first two rows of direct blocks of absolute heap %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "removing all objects from first two rows of direct blocks of absolute heap %s"; /* Test description + */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill first two rows of direct blocks */ - if(fill_root_row(fh, 0, fill_size, &state, &keep_ids)) + if (fill_root_row(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_root_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_root_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8009,21 +8039,22 @@ test_man_remove_first_two_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_par /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_first_two_rows() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_first_four_rows * @@ -8042,39 +8073,39 @@ error: static unsigned test_man_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from first four rows of direct blocks of absolute heap %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "removing all objects from first four rows of direct blocks of absolute heap %s"; /* Test description + */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill first two rows of direct blocks */ - if(fill_root_row(fh, 0, fill_size, &state, &keep_ids)) + if (fill_root_row(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_root_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_root_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_root_row(fh, 2, fill_size, &state, &keep_ids)) + if (fill_root_row(fh, 2, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_root_row(fh, 3, fill_size, &state, &keep_ids)) + if (fill_root_row(fh, 3, fill_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8085,21 +8116,22 @@ test_man_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_first_four_rows() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_all_root_direct * @@ -8118,33 +8150,33 @@ error: static unsigned test_man_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from all direct blocks of root group in absolute heap %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "removing all objects from all direct blocks of root group in absolute heap %s"; /* Test description + */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8155,21 +8187,22 @@ test_man_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_all_root_direct() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_2nd_indirect * @@ -8188,37 +8221,36 @@ error: static unsigned test_man_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from 2nd level indirect blocks of absolute heap %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "removing all objects from 2nd level indirect blocks of absolute heap %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8229,21 +8261,22 @@ test_man_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_2nd_indirect() */ - /*------------------------------------------------------------------------- * Function: test_man_remove_3rd_indirect * @@ -8262,41 +8295,40 @@ error: static unsigned test_man_remove_3rd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "removing all objects from 3rd level indirect blocks of absolute heap %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "removing all objects from 3rd level indirect blocks of absolute heap %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8307,23 +8339,25 @@ test_man_remove_3rd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_remove_3rd_indirect() */ #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_man_skip_start_block * @@ -8345,26 +8379,28 @@ error: static unsigned test_man_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "inserting object that is too large for starting block, then remove all objects %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "inserting object that is too large for starting block, then remove all objects %s"; /* Test + description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - obj_size = (size_t)DBLOCK_SIZE(fh, 0) + 1; + obj_size = (size_t)DBLOCK_SIZE(fh, 0) + 1; state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1); state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2); @@ -8372,12 +8408,11 @@ test_man_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t state.man_free_space = cparam->managed.width * DBLOCK_FREE(fh, 0); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8388,21 +8423,22 @@ test_man_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_skip_start_block() */ - /*------------------------------------------------------------------------- * Function: test_man_skip_start_block_add_back * @@ -8422,28 +8458,30 @@ error: static unsigned test_man_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "skipping starting block, then adding object back to first block, then remove all objects %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "skipping starting block, then adding object back to first block, then remove all objects %s"; /* Test + description + */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Insert object too large for starting block size */ - obj_size = (size_t)DBLOCK_SIZE(fh, 0) + 1; + obj_size = (size_t)DBLOCK_SIZE(fh, 0) + 1; state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1); state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2); @@ -8451,30 +8489,29 @@ test_man_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test state.man_free_space = cparam->managed.width * DBLOCK_FREE(fh, 0); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert an object to fill up the heap block just created */ obj_size = (size_t)DBLOCK_FREE(fh, 2) - obj_size; - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert second "real" object, which should go in earlier direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)20, (size_t)SMALL_OBJ_SIZE2, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, (size_t)SMALL_OBJ_SIZE2, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8485,21 +8522,22 @@ test_man_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_skip_start_block_add_back() */ - /*------------------------------------------------------------------------- * Function: test_man_skip_start_block_add_skipped * @@ -8520,29 +8558,29 @@ error: static unsigned test_man_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "skipping starting block, then adding objects to backfill and extend, then remove all objects %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "skipping starting block, then adding objects to backfill and extend, then " + "remove all objects %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Insert object too large for starting block size */ - obj_size = (size_t)DBLOCK_SIZE(fh, 0) + 1; + obj_size = (size_t)DBLOCK_SIZE(fh, 0) + 1; state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1); state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2); @@ -8550,40 +8588,39 @@ test_man_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t state.man_free_space = cparam->managed.width * DBLOCK_FREE(fh, 0); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert an object to fill up the heap block just created */ obj_size = (size_t)DBLOCK_FREE(fh, 2) - obj_size; - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add rows of blocks to "backfill" direct blocks that were skipped */ - if(fill_row(fh, 0, fill_size, &state, &keep_ids)) + if (fill_row(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert another object, which should extend direct blocks, instead of backfill */ state.man_alloc_size += DBLOCK_SIZE(fh, 2); - if(add_obj(fh, (size_t)20, (size_t)SMALL_OBJ_SIZE2, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, (size_t)SMALL_OBJ_SIZE2, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8594,21 +8631,22 @@ test_man_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_skip_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_skip_2nd_block * @@ -8629,35 +8667,35 @@ error: static unsigned test_man_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert object to initial block, then add object too large for starting direct blocks, then remove all objects %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "insert object to initial block, then add object too large for starting direct " + "blocks, then remove all objects %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Insert small object, to create root direct block */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -8668,15 +8706,14 @@ test_man_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1); state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2); state.man_alloc_size += DBLOCK_SIZE(fh, 2); - state.man_free_space += (cparam->managed.width - 1 )* DBLOCK_FREE(fh, 0); + state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8687,21 +8724,22 @@ test_man_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_skip_2nd_block() */ - /*------------------------------------------------------------------------- * Function: test_man_skip_2nd_block_add_skipped * @@ -8725,37 +8763,38 @@ error: static unsigned test_man_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert object to initial block, then add object too large for starting direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "insert object to initial block, then add object too large for starting direct blocks, then backfill " + "and extend, then remove all objects %s"; /* Test description */ + unsigned v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Insert small object, to create root direct block */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -8766,59 +8805,58 @@ test_man_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 1); state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, 2); state.man_alloc_size += DBLOCK_SIZE(fh, 2); - state.man_free_space += (cparam->managed.width - 1 )* DBLOCK_FREE(fh, 0); + state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert an object to fill up the (smaller) heap block just created */ obj_size = (size_t)DBLOCK_FREE(fh, 0) - SMALL_OBJ_SIZE1; - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill remainder of 2 * start size block */ obj_size = (size_t)DBLOCK_FREE(fh, 2) - ((size_t)DBLOCK_SIZE(fh, 0) + 1); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert objects to fill remaining rows of the starting block size */ /* Fill remainder of first row of direct heap blocks up */ - for(v = 0; v < (cparam->managed.width - 1); v++) { + for (v = 0; v < (cparam->managed.width - 1); v++) { state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, &keep_ids)) + if (fill_heap(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Fill second row of direct blocks */ - if(fill_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to create new 2 * start size direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 2); - if(add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8829,21 +8867,22 @@ test_man_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_skip_2nd_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_one_partial_skip_2nd_block_add_skipped * @@ -8867,50 +8906,53 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "skipping blocks with indirect root, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "skipping blocks with indirect root, then backfill and extend, then remove all objects %s"; /* Test + description + */ + unsigned u; /* Local index variable */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill initial direct block */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, &keep_ids)) + if (fill_heap(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert small object, to create root indirect block */ state.man_size += (cparam->managed.width - 1) * DBLOCK_SIZE(fh, 0); state.man_alloc_size += DBLOCK_SIZE(fh, 0); state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); - if(add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -8924,67 +8966,66 @@ test_man_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t * state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 3); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert an object to fill up the (smaller) heap block just created */ obj_size = (size_t)DBLOCK_FREE(fh, 0) - SMALL_OBJ_SIZE1; - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill remainder of 4 * start size block */ obj_size = (size_t)DBLOCK_FREE(fh, 3) - ((size_t)DBLOCK_SIZE(fh, 2) + 1); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert objects to fill remaining heaps in first row */ - for(u = 0; u < (cparam->managed.width - 2); u++) { + for (u = 0; u < (cparam->managed.width - 2); u++) { /* Fill a direct heap block up */ state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(fill_heap(fh, 0, fill_size, &state, &keep_ids)) + if (fill_heap(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert objects to fill remaining heaps in second row */ - if(fill_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert objects to fill remaining heaps in third row */ - if(fill_row(fh, 2, fill_size, &state, &keep_ids)) + if (fill_row(fh, 2, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to create new 4 * start size direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, (size_t)SMALL_OBJ_SIZE1, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -8995,21 +9036,22 @@ test_man_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t * /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_one_partial_skip_2nd_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_row_skip_add_skipped * @@ -9034,33 +9076,35 @@ error: static unsigned test_man_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling first row, then skipping rows, then backfill and extend, then remove all objects %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling first row, then skipping rows, then backfill and extend, then remove all objects %s"; /* Test + description + */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill first row of direct blocks */ - if(fill_root_row(fh, 0, fill_size, &state, &keep_ids)) + if (fill_root_row(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -9074,46 +9118,45 @@ test_man_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 1); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 2); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 3); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill remainder of 4 * start size block */ obj_size = (size_t)DBLOCK_FREE(fh, 3) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert objects to fill remaining heaps in second row */ - if(fill_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert objects to fill remaining heaps in third row */ - if(fill_row(fh, 2, fill_size, &state, &keep_ids)) + if (fill_row(fh, 2, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to create new 4 * start size direct block */ state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9124,21 +9167,22 @@ test_man_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_row_skip_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_skip_direct_skip_indirect_two_rows_add_skipped * @@ -9158,31 +9202,33 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_direct_rows; /* Number of rows (of direct blocks) in root indirect block */ - unsigned row; /* Current row */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned num_direct_rows; /* Number of rows (of direct blocks) in root indirect block */ + unsigned row; /* Current row */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "skipping direct blocks to last row and skipping two rows of root indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned v; /* Local index variables */ + const char * base_desc = + "skipping direct blocks to last row and skipping two rows of root indirect block, then backfill and " + "extend, then remove all objects %s"; /* Test description */ + unsigned v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Compute # direct block rows in root indirect block */ num_direct_rows = DTABLE_MAX_DROWS(fh); @@ -9192,13 +9238,13 @@ test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row); row++; - } while(row < (num_direct_rows / 2)); + } while (row < (num_direct_rows / 2)); /* Insert object to extend root block to middle of root direct blocks */ obj_size = (size_t)DBLOCK_SIZE(fh, row - 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, row - 1); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Compute heap size & free space when all direct blocks allocated */ @@ -9206,21 +9252,21 @@ test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row); row++; - } while(row < num_direct_rows); + } while (row < num_direct_rows); /* Insert large objects into last row of direct blocks in root indirect * block, to force extension of root indirect block that covers the first * row of indirect blocks in root indirect block */ obj_size = (size_t)DBLOCK_SIZE(fh, num_direct_rows - 2) + 1; - for(v = 0; v < cparam->managed.width; v++) { + for (v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, num_direct_rows - 1); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Compute heap size & free space when root indirect block doubles again */ @@ -9228,19 +9274,18 @@ test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row); row++; - } while(row < (2 * num_direct_rows)); + } while (row < (2 * num_direct_rows)); /* Insert large object, to force creation of indirect blocks with * range of skipped blocks that are too small to hold the large object */ obj_size = (size_t)DBLOCK_SIZE(fh, num_direct_rows - 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, num_direct_rows - 1); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9251,21 +9296,22 @@ test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_skip_direct_skip_indirect_two_rows_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_direct_skip_indirect_start_block_add_skipped * @@ -9284,35 +9330,36 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks and skipping blocks in non-root indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "filling direct blocks and skipping blocks in non-root indirect block, then " + "backfill and extend, then remove all objects %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -9320,49 +9367,48 @@ test_man_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea */ obj_size = (size_t)DBLOCK_SIZE(fh, 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add rows of blocks to "backfill" direct blocks that were skipped */ - if(fill_row(fh, 0, fill_size, &state, &keep_ids)) + if (fill_row(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert an object to fill up the (biggest) heap block created */ obj_size = (size_t)DBLOCK_FREE(fh, 3) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill direct block heaps with 2 * initial block size in nested indirect block */ - if(fill_row(fh, 2, fill_size, &state, &keep_ids)) + if (fill_row(fh, 2, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert one more object, to create new 4 * start size direct block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9373,21 +9419,22 @@ test_man_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_direct_skip_indirect_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped * @@ -9407,41 +9454,43 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - unsigned row; /* Current row in indirect block */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks and skipping row of non-root indirect blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + unsigned row; /* Current row in indirect block */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = "filling direct blocks and skipping row of non-root indirect blocks, then " + "backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u; /* Local index variable */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -9450,46 +9499,46 @@ test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_ */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of direct blocks that are smaller than large object's block size */ - for(row = 0; row < num_first_indirect_rows; row++) { + for (row = 0; row < num_first_indirect_rows; row++) { /* Fill rows of direct blocks in skipped indirect blocks */ - for(u = 0; u < cparam->managed.width; u++) - if(fill_row(fh, row, fill_size, &state, &keep_ids)) + for (u = 0; u < cparam->managed.width; u++) + if (fill_row(fh, row, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill row of direct blocks in largest (i.e. non-skipped) indirect block */ - if(fill_row(fh, row, fill_size, &state, &keep_ids)) + if (fill_row(fh, row, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9500,21 +9549,22 @@ test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_ /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_2nd_direct_less_one_wrap_start_block_add_skipped * @@ -9535,50 +9585,55 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, except last one, and insert object too large for 2nd level indirect blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, except last one, and insert object too " + "large for 2nd level indirect blocks, then backfill and extend, then remove all objects %s"; /* Test + description + */ + unsigned u; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row (except one) of 2nd level indirect blocks */ - for(u = 0; u < cparam->managed.width - 1; u++) + for (u = 0; u < cparam->managed.width - 1; u++) /* Fill all rows of 2nd level indirect blocks in root block */ - if(fill_2nd_indirect(fh, 1, fill_size, &state, &keep_ids)) + if (fill_2nd_indirect(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -9587,51 +9642,50 @@ test_man_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_ */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in 2nd level indirect block's direct blocks * (and rows of next 2nd level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in skipped 2nd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in current 2nd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9642,21 +9696,22 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_2nd_direct_less_one_wrap_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped * @@ -9680,41 +9735,44 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - unsigned row; /* Current row in indirect block */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks and skipping row of non-root indirect blocks, then skip row of direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + unsigned row; /* Current row in indirect block */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks and skipping row of non-root indirect blocks, then skip row of direct blocks, " + "then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u; /* Local index variable */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -9723,89 +9781,88 @@ test_man_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(hid_t fapl, H5 */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object too large for initial block size in skipped indirect blocks */ obj_size = (size_t)DBLOCK_SIZE(fh, 3) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, 4); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (medium) block just created */ obj_size = (size_t)DBLOCK_FREE(fh, 4) - obj_size; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Finish off blocks in row of medium block size (just to make row filling easier below) */ obj_size = (size_t)DBLOCK_FREE(fh, 4); - for(u = 1; u < cparam->managed.width; u++) { + for (u = 1; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 4); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of direct blocks that are smaller than large object's block size */ - for(row = 0; row < num_first_indirect_rows; row++) { + for (row = 0; row < num_first_indirect_rows; row++) { /* Fill rows of direct blocks in skipped indirect blocks */ - for(u = 0; u < cparam->managed.width; u++) - if(fill_row(fh, row, fill_size, &state, &keep_ids)) + for (u = 0; u < cparam->managed.width; u++) + if (fill_row(fh, row, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill row of direct blocks in largest (i.e. non-skipped) indirect block */ /* (Skip the row of blocks filled above) */ - if(row != 4) - if(fill_row(fh, row, fill_size, &state, &keep_ids)) + if (row != 4) + if (fill_row(fh, row, fill_size, &state, &keep_ids)) TEST_ERROR } /* end while */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9816,21 +9873,22 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_direct_skip_indirect_two_rows_add_skipped * @@ -9849,42 +9907,44 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - unsigned max_dblock_rows; /* Max. # of rows (of direct blocks) in the root indirect block */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + unsigned max_dblock_rows; /* Max. # of rows (of direct blocks) in the root indirect block */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks and skipping two rows of root indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + const char * base_desc = "filling direct blocks and skipping two rows of root indirect block, then " + "backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); - max_dblock_rows = DTABLE_MAX_DROWS(fh); + max_dblock_rows = DTABLE_MAX_DROWS(fh); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -9892,71 +9952,70 @@ test_man_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ */ obj_size = (size_t)DBLOCK_SIZE(fh, max_dblock_rows - 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert an object to fill up the (biggest) heap block created */ obj_size = (size_t)DBLOCK_FREE(fh, max_dblock_rows - 1) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in indirect block's direct blocks */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in first row of skipped 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block rows in second row of skipped 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in used 2nd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows in second row of skipped 2nd level indirect blocks (and used 2nd level block) */ /* Direct block rows in skipped 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Direct block row in used 2nd level indirect block */ - if(fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) + if (fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -9967,21 +10026,22 @@ test_man_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_direct_skip_indirect_two_rows_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped * @@ -10002,42 +10062,45 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - unsigned max_dblock_rows; /* Max. # of rows (of direct blocks) in the root indirect block */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + unsigned max_dblock_rows; /* Max. # of rows (of direct blocks) in the root indirect block */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks and skipping two rows of root indirect block, skip one row of root indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + const char * base_desc = + "filling direct blocks and skipping two rows of root indirect block, skip one row of root indirect " + "block, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); - max_dblock_rows = DTABLE_MAX_DROWS(fh); + max_dblock_rows = DTABLE_MAX_DROWS(fh); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of two rows of indirect blocks and @@ -10045,20 +10108,20 @@ test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t */ obj_size = (size_t)DBLOCK_SIZE(fh, max_dblock_rows - 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert an object to fill up the (biggest) heap block created */ obj_size = (size_t)DBLOCK_FREE(fh, max_dblock_rows - 1) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object that can't fit in first row of indirect blocks @@ -10067,76 +10130,76 @@ test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t */ obj_size = (size_t)DBLOCK_SIZE(fh, max_dblock_rows - 3) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 2); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert an object to fill up the (2nd biggest) heap block created */ obj_size = (size_t)DBLOCK_FREE(fh, max_dblock_rows - 2) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in indirect block's direct blocks */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in first row of skipped 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block rows in second row of skipped 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in used 2nd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows in second row of skipped 2nd level indirect blocks (and used 2nd level block) */ /* Finish blocks in partially used 2nd level indirect block */ - if(fill_partial_row(fh, num_first_indirect_rows, cparam->managed.width - 1, fill_size, &state, &keep_ids)) + if (fill_partial_row(fh, num_first_indirect_rows, cparam->managed.width - 1, fill_size, &state, + &keep_ids)) TEST_ERROR /* Direct block rows in skipped 2nd level indirect blocks */ /* (less the one indirect block already used) */ - for(v = 0; v < cparam->managed.width - 1; v++) - if(fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width - 1; v++) + if (fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Direct block row in used 3rd row 2nd level indirect block */ - if(fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) + if (fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, max_dblock_rows - 1); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10147,21 +10210,22 @@ test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_2nd_direct_skip_start_block_add_skipped * @@ -10181,43 +10245,46 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, and skip first rows of direct blocks of 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, and skip first rows of direct blocks of " + "3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description + */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -10226,43 +10293,42 @@ test_man_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t */ obj_size = (size_t)DBLOCK_SIZE(fh, 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, 3) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in 3rd level indirect block's direct blocks */ - if(fill_row(fh, 0, fill_size, &state, &keep_ids)) + if (fill_row(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_row(fh, 2, fill_size, &state, &keep_ids)) + if (fill_row(fh, 2, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10273,21 +10339,22 @@ test_man_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_2nd_direct_skip_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped * @@ -10309,51 +10376,54 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first rows of direct blocks of 3rd level indirect block's 2nd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct " + "blocks, and skip first rows of direct blocks of 3rd level indirect block's 2nd level indirect " + "block, then backfill and extend, then remove all objects %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in third level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -10362,45 +10432,44 @@ test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H */ obj_size = (size_t)DBLOCK_SIZE(fh, 2) + 1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, 3) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in (3rd level indirect block's) 2nd level * indirect block's direct blocks */ - if(fill_row(fh, 0, fill_size, &state, &keep_ids)) + if (fill_row(fh, 0, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR - if(fill_row(fh, 2, fill_size, &state, &keep_ids)) + if (fill_row(fh, 2, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, 3); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10411,21 +10480,22 @@ test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped * @@ -10446,56 +10516,61 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(hid_t fapl, + H5HF_create_t * cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first row of indirect blocks of 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct " + "blocks, and skip first row of indirect blocks of 3rd level indirect block, then backfill and " + "extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in third level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -10504,53 +10579,52 @@ test_man_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(h */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in (first 3rd level indirect block's) 2nd level * indirect block's direct blocks * (and second 3rd level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in 3rd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10561,21 +10635,22 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped * @@ -10597,59 +10672,64 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(hid_t fapl, + H5HF_create_t * cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct blocks, and skip first two rows of indirect blocks of 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect block's direct " + "blocks, and skip first two rows of indirect blocks of 3rd level indirect block, then backfill and " + "extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); #ifdef QAK -HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); + HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); #endif /* QAK */ /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in third level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -10658,60 +10738,59 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows + 1); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows + 1) - obj_size; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in (first 3rd level indirect block's) 2nd level * indirect block's direct blocks * (and second 3rd level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in 3rd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Fill row of direct blocks in second 3rd level indirect block */ - if(fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) + if (fill_row(fh, num_first_indirect_rows, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows + 1); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10722,21 +10801,22 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped * @@ -10759,66 +10839,71 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling first row of 3rd level indirect blocks, except last one, fill all direct blocks in last 3rd level indirect block, and insert object too large for it's 2nd level indirect blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char + *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling first row of 3rd " + "level indirect blocks, except last one, fill all direct blocks in last 3rd level " + "indirect block, and insert object too large for it's 2nd level indirect blocks, then " + "backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks in root indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row (except one) of 3rd level indirect blocks */ - for(u = 0; u < cparam->managed.width - 1; u++) + for (u = 0; u < cparam->managed.width - 1; u++) /* Fill 3rd level indirect block */ - if(fill_3rd_indirect(fh, 1, fill_size, &state, &keep_ids)) + if (fill_3rd_indirect(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in last third level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -10827,52 +10912,51 @@ test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(hid_t */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in 2nd level indirect block's direct blocks * (and rows of next 3rd level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in current 3rd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -10883,21 +10967,22 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped * @@ -10921,73 +11006,78 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped( + hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling first row of 3rd level indirect blocks, fill all direct blocks in next 3rd level indirect block, fill all 1st row of 2nd level indirect blocks, except last one, and insert object too large for 2nd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling first row of 3rd level indirect " + "blocks, fill all direct blocks in next 3rd level indirect block, fill all 1st row of 2nd level " + "indirect blocks, except last one, and insert object too large for 2nd level indirect block, then " + "backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row of 3rd level indirect blocks */ - if(fill_3rd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_3rd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in 2nd row third level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row (except one) of 2nd level indirect blocks */ - for(u = 0; u < cparam->managed.width - 1; u++) - if(fill_2nd_indirect(fh, 1, fill_size, &state, &keep_ids)) + for (u = 0; u < cparam->managed.width - 1; u++) + if (fill_2nd_indirect(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -10996,51 +11086,50 @@ test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_s */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in 2nd level indirect block's direct blocks * (and rows of next 2nd level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in skipped 2nd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in current 2nd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -11051,21 +11140,22 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped * @@ -11087,64 +11177,68 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, + fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill 4th level indirect block's direct blocks, and skip first row of 2nd indirect blocks of 4th level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill " + "4th level indirect block's direct blocks, and skip first row of 2nd indirect blocks of 4th level " + "indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in fourth level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -11153,53 +11247,52 @@ test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(hid_t fapl, H5 */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in (first 4th level indirect block's) 2nd level * indirect block's direct blocks * (and second row of 2nd level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in 2nd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -11210,21 +11303,22 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped() */ - /*------------------------------------------------------------------------- * Function: test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped * @@ -11248,80 +11342,85 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped( + hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill 4th level indirect block's direct, 2nd level indirect blocks and 3rd level direct block, and skip first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill " + "4th level indirect block's direct, 2nd level indirect blocks and 3rd level direct block, and skip " + "first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then " + "backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in fourth level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks in fourth level indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in fourth level indirect block's 3rd level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -11330,53 +11429,52 @@ test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_blo */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in (first 4th level indirect block's first 3rd * level block's) 2nd level indirect block's direct blocks * (and rows of 2nd 3rd level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in 3rd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -11387,23 +11485,25 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped() */ - /*------------------------------------------------------------------------- - * Function: test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped + * Function: + *test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped * * Purpose: Test filling all direct blocks in root indirect block and all * direct blocks in 2nd level indirect blocks, fill all direct @@ -11427,113 +11527,119 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped( + hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 4th level indirect blocks, fill 2nd row 4th level indirect block's direct, 2nd level indirect blocks, first row of 3rd level indirect blocks, 3rd level direct block in 2nd row, and skip first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill " + "first row of 4th level indirect blocks, fill 2nd row 4th level indirect block's direct, 2nd level " + "indirect blocks, first row of 3rd level indirect blocks, 3rd level direct block in 2nd row, and " + "skip first row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then " + "backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row of 4th level indirect blocks */ - if(fill_4th_indirect_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_4th_indirect_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR - /* Account for root indirect block doubling # of rows again */ - /* (From 16 rows to the max. # of rows: 22) */ - /* (Note: this is tied to the particular doubling table/heap creation parameters) */ - { - unsigned max_root_rows; /* Maximum # of rows in root indirect block */ - unsigned row; /* Row in heap */ + /* Account for root indirect block doubling # of rows again */ + /* (From 16 rows to the max. # of rows: 22) */ + /* (Note: this is tied to the particular doubling table/heap creation parameters) */ + { + unsigned max_root_rows; /* Maximum # of rows in root indirect block */ + unsigned row; /* Row in heap */ - /* Get some information for the heap */ - max_root_rows = HEAP_MAX_ROOT_ROWS(fh); + /* Get some information for the heap */ + max_root_rows = HEAP_MAX_ROOT_ROWS(fh); - /* Increase heap size & free space */ - for(row = 16; row < max_root_rows; row++) { - state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row); - state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row); - } /* end for */ - } /* end if */ + /* Increase heap size & free space */ + for (row = 16; row < max_root_rows; row++) { + state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row); + state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row); + } /* end for */ + } /* end if */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in 2nd row 4th level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 2nd row 4th level indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row of 3rd level indirect blocks in 2nd row 4th level indirect block */ - if(fill_3rd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_3rd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in 4th level indirect block's 2nd row of 3rd level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -11542,53 +11648,52 @@ test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_ */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in (first block in 2nd row 4th level indirect * block's first 3rd level block's) 2nd level indirect block's direct * blocks (and rows of 2nd 3rd level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in 3rd level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -11599,23 +11704,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); -} /* test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped() */ + H5Fclose(file); + } + H5E_END_TRY; + return (1); +} /* test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped() + */ - /*------------------------------------------------------------------------- - * Function: test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped + * Function: + *test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped * * Purpose: Test filling all direct blocks in root indirect block and all * direct blocks in 2nd level indirect blocks, fill all direct @@ -11641,95 +11749,102 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped( + hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 3rd level indirect blocks in 4th level indirect block except last 3rd level block, fill direct blocks in 3rd level block, and skip row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill " + "first row of 3rd level indirect blocks in 4th level indirect block except last 3rd level block, " + "fill direct blocks in 3rd level block, and skip row of 2nd indirect blocks of 4th level indirect " + "block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test + description + */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in 4th level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row (except one) of 3rd level indirect blocks in 4th level indirect block */ - for(u = 0; u < cparam->managed.width - 1; u++) { + for (u = 0; u < cparam->managed.width - 1; u++) { /* Fill all direct block rows in 3rd level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill row of 2nd level indirect blocks in 3rd level indirect block */ - if(fill_2nd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_2nd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in 4th level indirect block's last 3rd level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -11738,53 +11853,52 @@ test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_star */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in (4th level indirect block's first 3rd level * block's) 2nd level indirect block's direct blocks (and rows of next 4th * level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in 4th level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -11795,23 +11909,25 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped() */ - /*------------------------------------------------------------------------- - * Function: test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped + * Function: + *test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped * * Purpose: Test filling all direct blocks in root indirect block and all * direct blocks in 2nd level indirect blocks, fill all direct @@ -11837,131 +11953,137 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) +test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped( + hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill first row of 4th level indirect blocks, except last one, fill first row of 3rd level indirect blocks in last 4th level indirect block except last 3rd level block, fill direct blocks in 3rd level block, and skip row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect block, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "filling direct blocks, filling 2nd level indirect blocks, filling 3rd level indirect blocks, fill " + "first row of 4th level indirect blocks, except last one, fill first row of 3rd level indirect " + "blocks in last 4th level indirect block except last 3rd level block, fill direct blocks in 3rd " + "level block, and skip row of 2nd indirect blocks of 4th level indirect block's 3rd level indirect " + "block, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve info about heap */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 3rd level indirect blocks */ - if(fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_3rd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill first row (except one) of 4th level indirect blocks */ - for(u = 0; u < cparam->managed.width - 1; u++) { + for (u = 0; u < cparam->managed.width - 1; u++) { /* Fill all direct block rows in 4th level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill row of 3rd level indirect blocks in 4th level indirect block */ - if(fill_3rd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_3rd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in 4th level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks in 4th level indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill row (except one) of 3rd level indirect blocks in 4th level indirect block */ - for(u = 0; u < cparam->managed.width - 1; u++) { + for (u = 0; u < cparam->managed.width - 1; u++) { /* Fill all direct block rows in 3rd level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Fill row of 2nd level indirect blocks in 3rd level indirect block */ - if(fill_2nd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) + if (fill_2nd_indirect_row(fh, 1, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all direct block rows in 4th level indirect block's last 3rd level indirect block */ - if(fill_all_direct(fh, fill_size, &state, &keep_ids)) + if (fill_all_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR - /* Account for root indirect block doubling # of rows again */ - /* (From 16 rows to the max. # of rows: 22) */ - /* (Note: this is tied to the particular doubling table/heap creation parameters) */ - { - unsigned max_root_rows; /* Maximum # of rows in root indirect block */ - unsigned row; /* Row in heap */ + /* Account for root indirect block doubling # of rows again */ + /* (From 16 rows to the max. # of rows: 22) */ + /* (Note: this is tied to the particular doubling table/heap creation parameters) */ + { + unsigned max_root_rows; /* Maximum # of rows in root indirect block */ + unsigned row; /* Row in heap */ - /* Get some information for the heap */ - max_root_rows = HEAP_MAX_ROOT_ROWS(fh); + /* Get some information for the heap */ + max_root_rows = HEAP_MAX_ROOT_ROWS(fh); - /* Increase heap size & free space */ - for(row = 16; row < max_root_rows; row++) { - state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row); - state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row); - } /* end for */ - } /* end if */ + /* Increase heap size & free space */ + for (row = 16; row < max_root_rows; row++) { + state.man_size += cparam->managed.width * DBLOCK_SIZE(fh, row); + state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, row); + } /* end for */ + } /* end if */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert large object, to force creation of indirect block and @@ -11970,53 +12092,52 @@ test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_ */ obj_size = (size_t)DBLOCK_SIZE(fh, num_first_indirect_rows - 1) + 1; #ifdef QAK -HDfprintf(stderr, "obj_size = %Zu\n", obj_size); + HDfprintf(stderr, "obj_size = %Zu\n", obj_size); #endif /* QAK */ state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object to fill space in (large) block created */ obj_size = (size_t)DBLOCK_FREE(fh, num_first_indirect_rows) - obj_size; - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill rows skipped over in (4th level indirect block's first 3rd level * block's) 2nd level indirect block's direct blocks (and rows of next 4th * level indirect block's direct blocks) */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { /* Direct block rows in 2nd level indirect blocks */ - for(v = 0; v < cparam->managed.width; v++) - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR /* Direct block row in 4th level indirect block */ - if(fill_row(fh, u, fill_size, &state, &keep_ids)) + if (fill_row(fh, u, fill_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Add one more object, to create another "large" block */ obj_size = SMALL_OBJ_SIZE1; state.man_alloc_size += DBLOCK_SIZE(fh, num_first_indirect_rows); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -12027,23 +12148,26 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); -} /* test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped() */ + H5Fclose(file); + } + H5E_END_TRY; + return (1); +} /* test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped() + */ #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_man_frag_simple * @@ -12066,91 +12190,91 @@ error: static unsigned test_man_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "fragmenting small blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "fragmenting small blocks, then backfill and extend, then remove all objects %s"; /* Test description + */ + unsigned u; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Insert objects small enough to fit into initial blocks, but not to * share them with other objects of the same size, until the next larger * block size is reached. */ - obj_size = (size_t)DBLOCK_SIZE(fh, 0) / 2; - state.man_size = DBLOCK_SIZE(fh, 0); + obj_size = (size_t)DBLOCK_SIZE(fh, 0) / 2; + state.man_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); - for(u = 0; u < cparam->managed.width; u++) { + for (u = 0; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - if(u == 0) { + if (u == 0) { state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); } /* end if */ - } /* end for */ + } /* end for */ state.man_size += DBLOCK_SIZE(fh, 1) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, 1) * cparam->managed.width; - for(u = 0; u < cparam->managed.width; u++) { + for (u = 0; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 1); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* (Account for doubling root indirect block for rows 3-4 */ - for(u = 0; u < 2; u++) { + for (u = 0; u < 2; u++) { state.man_size += DBLOCK_SIZE(fh, u + 2) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u + 2) * cparam->managed.width; } /* end for */ /* Add one more object, to create a 2 * start_block_size block */ state.man_alloc_size += DBLOCK_SIZE(fh, 2); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Go back and fill in direct blocks of initial block size (which have large free space in them) */ obj_size = (size_t)DBLOCK_FREE(fh, 0) - obj_size; - for(u = 0; u < cparam->managed.width; u++) - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + for (u = 0; u < cparam->managed.width; u++) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR - for(u = 0; u < cparam->managed.width; u++) - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + for (u = 0; u < cparam->managed.width; u++) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill in 2 * start_block_size block */ obj_size = (size_t)DBLOCK_FREE(fh, 2) - ((size_t)DBLOCK_SIZE(fh, 0) / 2); - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -12161,21 +12285,22 @@ test_man_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_frag_simple() */ - /*------------------------------------------------------------------------- * Function: test_man_frag_direct * @@ -12197,129 +12322,129 @@ error: static unsigned test_man_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned root_direct_rows; /* Number of rows in root indirect block */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "fragmenting direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned root_direct_rows; /* Number of rows in root indirect block */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "fragmenting direct blocks, then backfill and extend, then remove all objects %s"; /* Test description + */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Retrieve # of direct rows in root indirect block */ root_direct_rows = H5HF_get_dtable_max_drows_test(fh); /* Insert objects small enough to fit into each direct block, but not to * share them with other objects of the same size. */ - obj_size = (size_t)DBLOCK_SIZE(fh, 0) / 2; - state.man_size = DBLOCK_SIZE(fh, 0); + obj_size = (size_t)DBLOCK_SIZE(fh, 0) / 2; + state.man_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0); /* First row */ - for(u = 0; u < cparam->managed.width; u++) { + for (u = 0; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 0); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR - if(u == 0) { + if (u == 0) { state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 0); } /* end if */ - } /* end for */ + } /* end for */ state.man_size += DBLOCK_SIZE(fh, 1) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, 1) * cparam->managed.width; /* Second row */ - for(u = 0; u < cparam->managed.width; u++) { + for (u = 0; u < cparam->managed.width; u++) { state.man_alloc_size += DBLOCK_SIZE(fh, 1); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* (Account for doubling root indirect block for rows 3-4 */ - for(u = 0; u < 2; u++) { + for (u = 0; u < 2; u++) { state.man_size += DBLOCK_SIZE(fh, u + 2) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u + 2) * cparam->managed.width; } /* end for */ /* Rows 3-4 */ - for(u = 0; u < 2; u++) { + for (u = 0; u < 2; u++) { obj_size = (size_t)DBLOCK_SIZE(fh, u + 2) / 2; - for(v = 0; v < cparam->managed.width; v++) { + for (v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, u + 2); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ - } /* end for */ + } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* (Account for doubling root indirect block for rows 5-8 */ - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { state.man_size += DBLOCK_SIZE(fh, u + 4) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u + 4) * cparam->managed.width; } /* end for */ /* Rows 5-8 */ - for(u = 0; u < 4; u++) { + for (u = 0; u < 4; u++) { obj_size = (size_t)DBLOCK_SIZE(fh, u + 4) / 2; - for(v = 0; v < cparam->managed.width; v++) { + for (v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, u + 4); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ - } /* end for */ + } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* (Account for doubling root indirect block for rows 9-16 */ - for(u = 0; u < 8; u++) { + for (u = 0; u < 8; u++) { state.man_size += DBLOCK_SIZE(fh, u + 8) * cparam->managed.width; state.man_free_space += DBLOCK_FREE(fh, u + 8) * cparam->managed.width; } /* end for */ /* Row 9 (last direct block row) */ obj_size = (size_t)DBLOCK_SIZE(fh, 8) / 2; - for(v = 0; v < cparam->managed.width; v++) { + for (v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, 8); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Go back and backfill all root block's direct blocks */ - for(u = 0; u < root_direct_rows; u++) { + for (u = 0; u < root_direct_rows; u++) { obj_size = (size_t)DBLOCK_FREE(fh, u) - ((size_t)DBLOCK_SIZE(fh, u) / 2); - for(v = 0; v < cparam->managed.width; v++) - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -12330,21 +12455,22 @@ test_man_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_frag_direct() */ - /*------------------------------------------------------------------------- * Function: test_man_frag_2nd_direct * @@ -12368,70 +12494,71 @@ error: static unsigned test_man_frag_2nd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "fill root direct blocks, then fragment 2nd level indirect block's direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned + num_first_indirect_rows; /* Number of rows (of direct blocks) in each of the first indirect blocks */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "fill root direct blocks, then fragment 2nd level indirect block's direct blocks, then backfill and " + "extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Compute # of bits used in first row */ num_first_indirect_rows = IBLOCK_MAX_DROWS(fh, 1); #ifdef QAK -HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); + HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); #endif /* QAK */ /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert objects small enough to fit into each direct block, but not to * share them with other objects of the same size. */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { obj_size = (size_t)DBLOCK_SIZE(fh, u) / 2; - for(v = 0; v < cparam->managed.width; v++) { + for (v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, u); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ - } /* end for */ + } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Go back and backfill all 2nd level indirect block's direct blocks */ - for(u = 0; u < num_first_indirect_rows; u++) { + for (u = 0; u < num_first_indirect_rows; u++) { obj_size = (size_t)DBLOCK_FREE(fh, u) - ((size_t)DBLOCK_SIZE(fh, u) / 2); - for(v = 0; v < cparam->managed.width; v++) - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -12442,21 +12569,22 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_frag_2nd_direct() */ - /*------------------------------------------------------------------------- * Function: test_man_frag_3rd_direct * @@ -12481,75 +12609,75 @@ error: static unsigned test_man_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned root_direct_rows; /* Number of rows in root indirect block */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t fill_size; /* Size of objects for "bulk" filled blocks */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "fill root direct blocks and 2nd level indirect blocks, then fragment 3rd level indirect block's direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ - unsigned u, v; /* Local index variables */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned root_direct_rows; /* Number of rows in root indirect block */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t fill_size; /* Size of objects for "bulk" filled blocks */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "fill root direct blocks and 2nd level indirect blocks, then fragment 3rd level indirect block's " + "direct blocks, then backfill and extend, then remove all objects %s"; /* Test description */ + unsigned u, v; /* Local index variables */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) + if (begin_test(tparam, base_desc, &keep_ids, &fill_size) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR - /* Compute # of direct rows in root indirect block */ root_direct_rows = DTABLE_MAX_DROWS(fh); /* Fill direct blocks in root indirect block */ - if(fill_root_direct(fh, fill_size, &state, &keep_ids)) + if (fill_root_direct(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Fill all rows of 2nd level indirect blocks in root indirect block */ - if(fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) + if (fill_all_2nd_indirect_rows(fh, fill_size, &state, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert objects small enough to fit into each direct block, but not to * share them with other objects of the same size. */ - for(u = 0; u < root_direct_rows; u++) { + for (u = 0; u < root_direct_rows; u++) { obj_size = (size_t)DBLOCK_SIZE(fh, u) / 2; - for(v = 0; v < cparam->managed.width; v++) { + for (v = 0; v < cparam->managed.width; v++) { state.man_alloc_size += DBLOCK_SIZE(fh, u); - if(add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) + if (add_obj(fh, (size_t)10, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ - } /* end for */ + } /* end for */ /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Go back and backfill all 3rd level indirect block's direct blocks */ - for(u = 0; u < root_direct_rows; u++) { + for (u = 0; u < root_direct_rows; u++) { obj_size = (size_t)DBLOCK_FREE(fh, u) - ((size_t)DBLOCK_SIZE(fh, u) / 2); - for(v = 0; v < cparam->managed.width; v++) - if(add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) + for (v = 0; v < cparam->managed.width; v++) + if (add_obj(fh, (size_t)20, obj_size, &state, &keep_ids)) TEST_ERROR } /* end for */ - /* Perform common file & heap close operations */ - if(close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) + if (close_heap(filename, fapl, tparam, file, f, &fh, fh_addr, &state, &keep_ids, empty_size) < 0) TEST_ERROR /* Free resources */ @@ -12560,23 +12688,25 @@ test_man_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_man_frag_3rd_direct() */ #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_huge_insert_one * @@ -12595,113 +12725,112 @@ error: static unsigned test_huge_insert_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - unsigned char *heap_id = NULL; /* Heap ID for object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert one huge object, then remove %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + unsigned char * heap_id = NULL; /* Heap ID for object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = "insert one huge object, then remove %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Allocate heap ID(s) */ - if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR /* Make certain that 'huge' object's heap IDs are correct size */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != tparam->actual_id_len) + if (id_len != tparam->actual_id_len) TEST_ERROR /* Insert object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = obj_size; + state.huge_size = obj_size; state.huge_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in huge object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { /* Remove object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = 0; + state.huge_size = 0; state.huge_nobjs = 0; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ - /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ @@ -12713,22 +12842,23 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(heap_id); H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_huge_insert_one() */ - /*------------------------------------------------------------------------- * Function: test_huge_insert_two * @@ -12747,191 +12877,190 @@ error: static unsigned test_huge_insert_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - unsigned char *heap_id = NULL; /* Heap ID for first object */ - unsigned char *heap_id2 = NULL; /* Heap ID for second object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert two huge objects, then remove %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + unsigned char * heap_id = NULL; /* Heap ID for first object */ + unsigned char * heap_id2 = NULL; /* Heap ID for second object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = "insert two huge objects, then remove %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Allocate heap ID(s) */ - if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR /* Make certain that 'huge' object's heap IDs are correct size */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != tparam->actual_id_len) + if (id_len != tparam->actual_id_len) TEST_ERROR /* Insert object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = obj_size; + state.huge_size = obj_size; state.huge_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in huge object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert second object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id2, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id2, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size += obj_size ; + state.huge_size += obj_size; state.huge_nobjs = 2; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in second huge object */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id2, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id2, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { - if(tparam->del_dir == FHEAP_DEL_FORWARD) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_FORWARD) { /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = obj_size; + state.huge_size = obj_size; state.huge_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = 0; + state.huge_size = 0; state.huge_nobjs = 0; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ else { /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = obj_size; + state.huge_size = obj_size; state.huge_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = 0; + state.huge_size = 0; state.huge_nobjs = 0; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end else */ - } /* end if */ - + } /* end if */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ @@ -12944,23 +13073,24 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(heap_id); H5MM_xfree(heap_id2); H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_huge_insert_two() */ - /*------------------------------------------------------------------------- * Function: test_huge_insert_three * @@ -12979,264 +13109,263 @@ error: static unsigned test_huge_insert_three(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - unsigned char *heap_id = NULL; /* Heap ID for first object */ - unsigned char *heap_id2 = NULL; /* Heap ID for second object */ - unsigned char *heap_id3 = NULL; /* Heap ID for third object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert three huge objects, then remove %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + unsigned char * heap_id = NULL; /* Heap ID for first object */ + unsigned char * heap_id2 = NULL; /* Heap ID for second object */ + unsigned char * heap_id3 = NULL; /* Heap ID for third object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = "insert three huge objects, then remove %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Allocate heap ID(s) */ - if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR /* Make certain that 'huge' object's heap IDs are correct size */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != tparam->actual_id_len) + if (id_len != tparam->actual_id_len) TEST_ERROR /* Insert first object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = obj_size; + state.huge_size = obj_size; state.huge_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in first huge object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert second object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id2, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id2, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size += obj_size; state.huge_nobjs = 2; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in second huge object */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id2, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id2, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert third object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 3; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id3) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id3) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id3, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id3, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size += obj_size; state.huge_nobjs = 3; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in third huge object */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id3, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id3, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { - if(tparam->del_dir == FHEAP_DEL_FORWARD) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_FORWARD) { /* Remove first object from heap */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove second object from heap */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove third object from heap */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id3) < 0) + if (H5HF_remove(fh, heap_id3) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ else { /* Remove third object from heap */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id3) < 0) + if (H5HF_remove(fh, heap_id3) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove second object from heap */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove first object from heap */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end else */ - } /* end if */ - + } /* end if */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ @@ -13250,24 +13379,25 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(heap_id); H5MM_xfree(heap_id2); H5MM_xfree(heap_id3); H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_huge_insert_three() */ - /*------------------------------------------------------------------------- * Function: test_huge_insert_mix * @@ -13286,153 +13416,153 @@ error: static unsigned test_huge_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - unsigned char *heap_id = NULL; /* Heap ID for first object */ - unsigned char *heap_id2 = NULL; /* Heap ID for second object */ - unsigned char *heap_id3 = NULL; /* Heap ID for third object */ - unsigned char *heap_id4 = NULL; /* Heap ID for fourth object */ - unsigned char *heap_id5 = NULL; /* Heap ID for fifth object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert mix of normal & huge objects, then remove %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + unsigned char * heap_id = NULL; /* Heap ID for first object */ + unsigned char * heap_id2 = NULL; /* Heap ID for second object */ + unsigned char * heap_id3 = NULL; /* Heap ID for third object */ + unsigned char * heap_id4 = NULL; /* Heap ID for fourth object */ + unsigned char * heap_id5 = NULL; /* Heap ID for fifth object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char *base_desc = "insert mix of normal & huge objects, then remove %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Allocate heap ID(s) */ - if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id4 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id4 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id5 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id5 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR /* Make certain that 'huge' object's heap IDs are correct size */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != tparam->actual_id_len) + if (id_len != tparam->actual_id_len) TEST_ERROR /* Insert first object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size += obj_size; state.huge_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in first huge object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert second object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id2, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id2, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size += obj_size; state.huge_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in second huge object */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id2, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id2, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert third object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 3; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id3) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id3) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id3, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id3, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size += obj_size; state.huge_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in third huge object */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id3, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id3, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert fourth object small enough to fit into 'normal' heap blocks */ obj_size = (size_t)DBLOCK_SIZE(fh, 0) + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id4) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id4) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id4, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id4, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_MAN) + if (obj_type != H5HF_ID_TYPE_MAN) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ @@ -13445,31 +13575,31 @@ test_huge_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar state.man_free_space += DBLOCK_FREE(fh, 2) - obj_size; state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 2); state.man_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in fourth ('normal') object */ - if(H5HF_get_obj_len(fh, heap_id4, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id4, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id4, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id4, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert fifth object small enough to fit into 'normal' heap blocks */ obj_size = (size_t)DBLOCK_SIZE(fh, 3) + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id5) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id5) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id5, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id5, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_MAN) + if (obj_type != H5HF_ID_TYPE_MAN) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ @@ -13483,183 +13613,182 @@ test_huge_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 4); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 5); state.man_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in fifth ('normal') object */ - if(H5HF_get_obj_len(fh, heap_id5, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id5, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id5, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id5, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { - if(tparam->del_dir == FHEAP_DEL_FORWARD) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_FORWARD) { /* Remove first object from heap */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove second object from heap */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove third object from heap */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id3) < 0) + if (H5HF_remove(fh, heap_id3) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove fourth ('normal') object from heap */ - if(H5HF_remove(fh, heap_id4) < 0) + if (H5HF_remove(fh, heap_id4) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Remove fifth ('normal') object from heap */ - if(H5HF_remove(fh, heap_id5) < 0) + if (H5HF_remove(fh, heap_id5) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR } /* end if */ else { /* Remove fifth ('normal') object from heap */ - if(H5HF_remove(fh, heap_id5) < 0) + if (H5HF_remove(fh, heap_id5) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Remove fourth ('normal') object from heap */ - if(H5HF_remove(fh, heap_id4) < 0) + if (H5HF_remove(fh, heap_id4) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Reset 'managed' object statistics after they are all removed */ - state.man_nobjs = 0; - state.man_size = 0; + state.man_nobjs = 0; + state.man_size = 0; state.man_alloc_size = 0; state.man_free_space = 0; /* Remove third object from heap */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id3) < 0) + if (H5HF_remove(fh, heap_id3) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove second object from heap */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR } /* end else */ /* Check up on heap... */ HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ - /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ @@ -13675,10 +13804,11 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(heap_id); H5MM_xfree(heap_id2); H5MM_xfree(heap_id3); @@ -13687,14 +13817,14 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_huge_insert_mix() */ - /*------------------------------------------------------------------------- * Function: test_filtered_huge * @@ -13711,106 +13841,106 @@ error: static unsigned test_filtered_huge(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - H5HF_create_t tmp_cparam; /* Local heap creation parameters */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - unsigned char *heap_id = NULL; /* Heap ID for object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned deflate_level; /* Deflation level */ - size_t old_actual_id_len = 0; /* Old actual ID length */ - hbool_t huge_ids_direct; /* Are 'huge' objects directly acccessed? */ - hbool_t pline_init = FALSE; /* Whether the I/O pipeline has been initialized */ - const char *base_desc = "insert 'huge' object into heap with I/O filters, then remove %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + H5HF_create_t tmp_cparam; /* Local heap creation parameters */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + unsigned char * heap_id = NULL; /* Heap ID for object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned deflate_level; /* Deflation level */ + size_t old_actual_id_len = 0; /* Old actual ID length */ + hbool_t huge_ids_direct; /* Are 'huge' objects directly acccessed? */ + hbool_t pline_init = FALSE; /* Whether the I/O pipeline has been initialized */ + const char * base_desc = + "insert 'huge' object into heap with I/O filters, then remove %s"; /* Test description */ /* Copy heap creation properties */ HDmemcpy(&tmp_cparam, cparam, sizeof(H5HF_create_t)); /* Set an I/O filter for heap data */ deflate_level = 6; - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) FAIL_STACK_ERROR pline_init = TRUE; /* Adjust actual ID length, if asking for IDs that can directly access 'huge' objects */ - if(cparam->id_len == 1) { - old_actual_id_len = tparam->actual_id_len; - tparam->actual_id_len = 29; /* 1 + 8 (file address size) + 8 (file length size) + 4 (filter mask length) + 8 (object length size) */ - } /* end if */ + if (cparam->id_len == 1) { + old_actual_id_len = tparam->actual_id_len; + tparam->actual_id_len = 29; /* 1 + 8 (file address size) + 8 (file length size) + 4 (filter mask + length) + 8 (object length size) */ + } /* end if */ /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR - /* Allocate heap ID(s) */ - if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR /* Make certain that 'huge' object's heap IDs are correct form */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != tparam->actual_id_len) + if (id_len != tparam->actual_id_len) TEST_ERROR - if(H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) + if (H5HF_get_huge_info_test(fh, NULL, &huge_ids_direct) < 0) FAIL_STACK_ERROR - if(cparam->id_len == 1) { - if(huge_ids_direct != TRUE) + if (cparam->id_len == 1) { + if (huge_ids_direct != TRUE) TEST_ERROR } /* end if */ - else - if(tparam->actual_id_len >= 29) { - if(huge_ids_direct != TRUE) - TEST_ERROR - } /* end if */ - else { - if(huge_ids_direct != FALSE) - TEST_ERROR - } /* end else */ + else if (tparam->actual_id_len >= 29) { + if (huge_ids_direct != TRUE) + TEST_ERROR + } /* end if */ + else { + if (huge_ids_direct != FALSE) + TEST_ERROR + } /* end else */ /* Insert object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* QAK */ #ifdef QAK /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -13818,74 +13948,75 @@ test_filtered_huge(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR #endif /* QAK */ -/* QAK */ + /* QAK */ /* Check up on heap... */ - state.huge_size = obj_size; + state.huge_size = obj_size; state.huge_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in huge object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { /* Remove object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.huge_size = 0; + state.huge_size = 0; state.huge_nobjs = 0; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, (unsigned long)file_size); + HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, + (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Reset actual ID length, if asking for IDs that can directly access 'huge' objects */ - if(cparam->id_len == 1) + if (cparam->id_len == 1) tparam->actual_id_len = old_actual_id_len; /* Free resources */ @@ -13895,23 +14026,25 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(heap_id); - if(fh) + if (fh) H5HF_close(fh); - if(pline_init) + if (pline_init) H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_filtered_huge() */ #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_tiny_insert_one * @@ -13930,113 +14063,112 @@ error: static unsigned test_tiny_insert_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - unsigned char *heap_id = NULL; /* Heap ID for object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert one tiny object, then remove %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + unsigned char * heap_id = NULL; /* Heap ID for object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = "insert one tiny object, then remove %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Allocate heap ID(s) */ - if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR /* Make certain that 'tiny' object's heap IDs are correct size */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != tparam->actual_id_len) + if (id_len != tparam->actual_id_len) TEST_ERROR /* Insert object small enough to encode in heap ID */ obj_size = tparam->actual_id_len - 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_TINY) + if (obj_type != H5HF_ID_TYPE_TINY) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size = obj_size; + state.tiny_size = obj_size; state.tiny_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in tiny object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { /* Remove object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size = 0; + state.tiny_size = 0; state.tiny_nobjs = 0; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ - /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ @@ -14048,22 +14180,23 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(heap_id); H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_tiny_insert_one() */ - /*------------------------------------------------------------------------- * Function: test_tiny_insert_two * @@ -14082,191 +14215,190 @@ error: static unsigned test_tiny_insert_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - unsigned char *heap_id = NULL; /* Heap ID for first object */ - unsigned char *heap_id2 = NULL; /* Heap ID for second object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert two tiny objects, then remove %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + unsigned char * heap_id = NULL; /* Heap ID for first object */ + unsigned char * heap_id2 = NULL; /* Heap ID for second object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = "insert two tiny objects, then remove %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Allocate heap ID(s) */ - if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR /* Make certain that 'tiny' object's heap IDs are correct size */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != tparam->actual_id_len) + if (id_len != tparam->actual_id_len) TEST_ERROR /* Insert object small enough to encode in heap ID */ obj_size = tparam->actual_id_len - 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_TINY) + if (obj_type != H5HF_ID_TYPE_TINY) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size = obj_size; + state.tiny_size = obj_size; state.tiny_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in tiny object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert second object small enough to encode in heap ID */ obj_size = tparam->actual_id_len - 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id2, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id2, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_TINY) + if (obj_type != H5HF_ID_TYPE_TINY) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size += obj_size ; + state.tiny_size += obj_size; state.tiny_nobjs = 2; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in second tiny object */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id2, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id2, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { - if(tparam->del_dir == FHEAP_DEL_FORWARD) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_FORWARD) { /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size = obj_size; + state.tiny_size = obj_size; state.tiny_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size = 0; + state.tiny_size = 0; state.tiny_nobjs = 0; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ else { /* Remove second object from heap */ - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size = obj_size; + state.tiny_size = obj_size; state.tiny_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size = 0; + state.tiny_size = 0; state.tiny_nobjs = 0; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end else */ - } /* end if */ - + } /* end if */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ @@ -14279,23 +14411,24 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(heap_id); H5MM_xfree(heap_id2); H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_tiny_insert_two() */ - /*------------------------------------------------------------------------- * Function: test_tiny_insert_mix * @@ -14315,180 +14448,181 @@ error: static unsigned test_tiny_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - size_t id_len; /* Size of fractal heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - unsigned char *heap_id = NULL; /* Heap ID for first object */ - unsigned char *heap_id2 = NULL; /* Heap ID for second object */ - unsigned char *heap_id3 = NULL; /* Heap ID for third object */ - unsigned char *heap_id4 = NULL; /* Heap ID for fourth object */ - unsigned char *heap_id5 = NULL; /* Heap ID for fifth object */ - unsigned char *heap_id6 = NULL; /* Heap ID for sixth object */ - unsigned char *heap_id7 = NULL; /* Heap ID for seventh object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - const char *base_desc = "insert mix of normal, huge & tiny objects, then remove %s"; /* Test description */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + size_t id_len; /* Size of fractal heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + unsigned char * heap_id = NULL; /* Heap ID for first object */ + unsigned char * heap_id2 = NULL; /* Heap ID for second object */ + unsigned char * heap_id3 = NULL; /* Heap ID for third object */ + unsigned char * heap_id4 = NULL; /* Heap ID for fourth object */ + unsigned char * heap_id5 = NULL; /* Heap ID for fifth object */ + unsigned char * heap_id6 = NULL; /* Heap ID for sixth object */ + unsigned char * heap_id7 = NULL; /* Heap ID for seventh object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + const char * base_desc = + "insert mix of normal, huge & tiny objects, then remove %s"; /* Test description */ /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Allocate heap ID(s) */ - if(NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id2 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id3 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id4 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id4 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id5 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id5 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id6 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id6 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR - if(NULL == (heap_id7 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) + if (NULL == (heap_id7 = (unsigned char *)H5MM_malloc(tparam->actual_id_len))) TEST_ERROR /* Make certain that 'tiny' object's heap IDs are correct size */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len != tparam->actual_id_len) + if (id_len != tparam->actual_id_len) TEST_ERROR /* Insert first object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size += obj_size; state.huge_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in first huge object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Check 'op' functionality on first huge object */ HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_op(fh, heap_id, op_memcpy, shared_robj_g) < 0) + if (H5HF_op(fh, heap_id, op_memcpy, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert second object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id2, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id2, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size += obj_size; state.huge_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in second huge object */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id2, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id2, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Check 'op' functionality on second huge object */ HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_op(fh, heap_id2, op_memcpy, shared_robj_g) < 0) + if (H5HF_op(fh, heap_id2, op_memcpy, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert third object too large for managed heap blocks */ obj_size = SMALL_STAND_SIZE + 3; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id3) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id3) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id3, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id3, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_HUGE) + if (obj_type != H5HF_ID_TYPE_HUGE) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size += obj_size; state.huge_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in third huge object */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id3, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id3, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Check 'op' functionality on third huge object */ HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_op(fh, heap_id3, op_memcpy, shared_robj_g) < 0) + if (H5HF_op(fh, heap_id3, op_memcpy, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert fourth object small enough to fit into 'normal' heap blocks */ obj_size = (size_t)DBLOCK_SIZE(fh, 0) + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id4) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id4) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id4, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id4, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_MAN) + if (obj_type != H5HF_ID_TYPE_MAN) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ @@ -14501,38 +14635,38 @@ test_tiny_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar state.man_free_space += DBLOCK_FREE(fh, 2) - obj_size; state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 2); state.man_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in fourth ('normal') object */ - if(H5HF_get_obj_len(fh, heap_id4, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id4, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id4, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id4, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Check 'op' functionality on fourth ('normal') object */ HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_op(fh, heap_id4, op_memcpy, shared_robj_g) < 0) + if (H5HF_op(fh, heap_id4, op_memcpy, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert fifth object small enough to fit into 'normal' heap blocks */ obj_size = (size_t)DBLOCK_SIZE(fh, 3) + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id5) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id5) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id5, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id5, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_MAN) + if (obj_type != H5HF_ID_TYPE_MAN) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ @@ -14546,327 +14680,325 @@ test_tiny_insert_mix(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar state.man_free_space += (cparam->managed.width - 1) * DBLOCK_FREE(fh, 4); state.man_free_space += cparam->managed.width * DBLOCK_FREE(fh, 5); state.man_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in fifth ('normal') object */ - if(H5HF_get_obj_len(fh, heap_id5, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id5, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id5, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id5, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Check 'op' functionality on fifth ('normal') object */ HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_op(fh, heap_id5, op_memcpy, shared_robj_g) < 0) + if (H5HF_op(fh, heap_id5, op_memcpy, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR - /* Insert sixth object small enough to encode in heap ID */ obj_size = tparam->actual_id_len - 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id6) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id6) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id6, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id6, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_TINY) + if (obj_type != H5HF_ID_TYPE_TINY) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ - state.tiny_size = obj_size; + state.tiny_size = obj_size; state.tiny_nobjs = 1; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in tiny object */ - if(H5HF_get_obj_len(fh, heap_id6, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id6, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id6, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id6, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Check 'op' functionality on sixth ('tiny') object */ HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_op(fh, heap_id6, op_memcpy, shared_robj_g) < 0) + if (H5HF_op(fh, heap_id6, op_memcpy, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Insert seventh object small enough to encode in heap ID */ obj_size = tparam->actual_id_len - 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id7) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id7) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id7, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id7, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_TINY) + if (obj_type != H5HF_ID_TYPE_TINY) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.tiny_size += obj_size; state.tiny_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in tiny object */ - if(H5HF_get_obj_len(fh, heap_id7, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id7, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id7, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id7, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Check 'op' functionality on seventh ('tiny') object */ HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_op(fh, heap_id7, op_memcpy, shared_robj_g) < 0) + if (H5HF_op(fh, heap_id7, op_memcpy, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { - if(tparam->del_dir == FHEAP_DEL_FORWARD) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_FORWARD) { /* Remove first object from heap */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove second object from heap */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove third object from heap */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id3) < 0) + if (H5HF_remove(fh, heap_id3) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove fourth ('normal') object from heap */ - if(H5HF_remove(fh, heap_id4) < 0) + if (H5HF_remove(fh, heap_id4) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Remove fifth ('normal') object from heap */ - if(H5HF_remove(fh, heap_id5) < 0) + if (H5HF_remove(fh, heap_id5) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Reset 'managed' object statistics after they are all removed */ - state.man_nobjs = 0; - state.man_size = 0; + state.man_nobjs = 0; + state.man_size = 0; state.man_alloc_size = 0; state.man_free_space = 0; /* Remove sixth object from heap */ - if(H5HF_get_obj_len(fh, heap_id6, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id6, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id6) < 0) + if (H5HF_remove(fh, heap_id6) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.tiny_size -= robj_size; state.tiny_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove seventh object from heap */ - if(H5HF_remove(fh, heap_id7) < 0) + if (H5HF_remove(fh, heap_id7) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR } /* end if */ else { /* Remove seventh object from heap */ - if(H5HF_get_obj_len(fh, heap_id7, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id7, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id7) < 0) + if (H5HF_remove(fh, heap_id7) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.tiny_size -= robj_size; state.tiny_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove sixth object from heap */ - if(H5HF_get_obj_len(fh, heap_id6, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id6, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id6) < 0) + if (H5HF_remove(fh, heap_id6) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.tiny_size -= robj_size; state.tiny_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove fifth ('normal') object from heap */ - if(H5HF_remove(fh, heap_id5) < 0) + if (H5HF_remove(fh, heap_id5) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Remove fourth ('normal') object from heap */ - if(H5HF_remove(fh, heap_id4) < 0) + if (H5HF_remove(fh, heap_id4) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Reset 'managed' object statistics after they are all removed */ - state.man_nobjs = 0; - state.man_size = 0; + state.man_nobjs = 0; + state.man_size = 0; state.man_alloc_size = 0; state.man_free_space = 0; /* Remove third object from heap */ - if(H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id3, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id3) < 0) + if (H5HF_remove(fh, heap_id3) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove second object from heap */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ state.huge_size -= robj_size; state.huge_nobjs--; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Remove first object from heap */ - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR } /* end else */ /* Check up on heap... */ HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ - /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ @@ -14884,10 +15016,11 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(heap_id); H5MM_xfree(heap_id2); H5MM_xfree(heap_id3); @@ -14898,17 +15031,18 @@ error: H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_tiny_insert_mix() */ #endif /* QAK */ #endif /* QAK2 */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_filtered_man_root_direct * @@ -14925,70 +15059,70 @@ error: static unsigned test_filtered_man_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - H5HF_create_t tmp_cparam; /* Local heap creation parameters */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + H5HF_create_t tmp_cparam; /* Local heap creation parameters */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ #ifdef NOT_YET - h5_stat_size_t file_size; /* Size of file currently */ -#endif /* NOT_YET */ - unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned deflate_level; /* Deflation level */ - const char *base_desc = "insert one 'managed' object into heap with I/O filters, then remove %s"; /* Test description */ + h5_stat_size_t file_size; /* Size of file currently */ +#endif /* NOT_YET */ + unsigned char heap_id[HEAP_ID_LEN]; /* Heap ID for object */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned deflate_level; /* Deflation level */ + const char * base_desc = + "insert one 'managed' object into heap with I/O filters, then remove %s"; /* Test description */ /* Copy heap creation properties */ HDmemcpy(&tmp_cparam, cparam, sizeof(H5HF_create_t)); /* Set an I/O filter for heap data */ deflate_level = 6; - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) FAIL_STACK_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR - /* Insert object small enough to fit into direct heap block */ obj_size = (size_t)DBLOCK_SIZE(fh, 0) / 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_MAN) + if (obj_type != H5HF_ID_TYPE_MAN) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -14996,73 +15130,74 @@ test_filtered_man_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Check up on heap... */ - state.man_size = DBLOCK_SIZE(fh, 0); + state.man_size = DBLOCK_SIZE(fh, 0); state.man_alloc_size = DBLOCK_SIZE(fh, 0); state.man_free_space = DBLOCK_FREE(fh, 0) - obj_size; state.man_nobjs++; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in ('normal') object */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { /* Remove object from heap */ - if(H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id) < 0) + if (H5HF_remove(fh, heap_id) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Check up on heap... */ HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Needs file free space to be persistent */ #ifdef NOT_YET /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, (unsigned long)file_size); + HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, + (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR #endif /* NOT_YET */ @@ -15072,18 +15207,19 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_filtered_man_root_direct() */ - /*------------------------------------------------------------------------- * Function: test_filtered_man_root_indirect * @@ -15100,80 +15236,80 @@ error: static unsigned test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - H5HF_create_t tmp_cparam; /* Local heap creation parameters */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + H5HF_create_t tmp_cparam; /* Local heap creation parameters */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ #ifdef NOT_YET - h5_stat_size_t file_size; /* Size of file currently */ -#endif /* NOT_YET */ - unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for object #1 */ - unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for object #2 */ - size_t obj_size; /* Size of object */ - size_t robj_size; /* Size of object read */ - unsigned char obj_type; /* Type of storage for object */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned deflate_level; /* Deflation level */ - const char *base_desc = "insert two 'managed' objects into heap with I/O filters, then remove %s"; /* Test description */ + h5_stat_size_t file_size; /* Size of file currently */ +#endif /* NOT_YET */ + unsigned char heap_id1[HEAP_ID_LEN]; /* Heap ID for object #1 */ + unsigned char heap_id2[HEAP_ID_LEN]; /* Heap ID for object #2 */ + size_t obj_size; /* Size of object */ + size_t robj_size; /* Size of object read */ + unsigned char obj_type; /* Type of storage for object */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned deflate_level; /* Deflation level */ + const char * base_desc = + "insert two 'managed' objects into heap with I/O filters, then remove %s"; /* Test description */ /* Copy heap creation properties */ HDmemcpy(&tmp_cparam, cparam, sizeof(H5HF_create_t)); /* Set an I/O filter for heap data */ deflate_level = 6; - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) FAIL_STACK_ERROR /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Perform common test initialization operations */ - if(begin_test(tparam, base_desc, &keep_ids, NULL) < 0) + if (begin_test(tparam, base_desc, &keep_ids, NULL) < 0) TEST_ERROR - /* Insert object #1, small enough to fit into direct heap block */ obj_size = (size_t)DBLOCK_SIZE(fh, 0) / 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id1) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id1) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id1, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id1, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_MAN) + if (obj_type != H5HF_ID_TYPE_MAN) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Insert object #2, small enough to fit into direct heap block */ obj_size = (size_t)DBLOCK_SIZE(fh, 0) / 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, heap_id2) < 0) FAIL_STACK_ERROR - if(H5HF_get_id_type_test(heap_id2, &obj_type) < 0) + if (H5HF_get_id_type_test(heap_id2, &obj_type) < 0) FAIL_STACK_ERROR - if(obj_type != H5HF_ID_TYPE_MAN) + if (obj_type != H5HF_ID_TYPE_MAN) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15181,63 +15317,63 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Check up on heap... */ - state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); + state.man_size = cparam->managed.width * DBLOCK_SIZE(fh, 0); state.man_alloc_size = 2 * DBLOCK_SIZE(fh, 0); state.man_free_space = (cparam->managed.width * DBLOCK_FREE(fh, 0)) - (obj_size * 2); state.man_nobjs += 2; - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Read in ('normal') object #1 */ - if(H5HF_get_obj_len(fh, heap_id1, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id1, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id1, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id1, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Read in ('normal') object #2 */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(obj_size != robj_size) + if (obj_size != robj_size) TEST_ERROR HDmemset(shared_robj_g, 0, obj_size); - if(H5HF_read(fh, heap_id2, shared_robj_g) < 0) + if (H5HF_read(fh, heap_id2, shared_robj_g) < 0) FAIL_STACK_ERROR - if(HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) + if (HDmemcmp(shared_wobj_g, shared_robj_g, obj_size)) TEST_ERROR /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { - if(tparam->del_dir == FHEAP_DEL_FORWARD) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_FORWARD) { /* Remove object #1 from heap */ - if(H5HF_get_obj_len(fh, heap_id1, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id1, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id1) < 0) + if (H5HF_remove(fh, heap_id1) < 0) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15245,35 +15381,35 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Remove object #2 from heap */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Check up on heap... */ HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15281,36 +15417,36 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Check up on heap... */ HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ else { /* Remove object #2 from heap */ - if(H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id2, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id2) < 0) + if (H5HF_remove(fh, heap_id2) < 0) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15318,35 +15454,35 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Remove object #1 from heap */ - if(H5HF_get_obj_len(fh, heap_id1, &robj_size) < 0) + if (H5HF_get_obj_len(fh, heap_id1, &robj_size) < 0) FAIL_STACK_ERROR - if(H5HF_remove(fh, heap_id1) < 0) + if (H5HF_remove(fh, heap_id1) < 0) FAIL_STACK_ERROR /* Check up on heap... */ HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15354,43 +15490,44 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Check up on heap... */ HDmemset(&state, 0, sizeof(fheap_heap_state_t)); - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end else */ - } /* end if */ + } /* end if */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Needs file free space to be persistent */ #ifdef NOT_YET /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, (unsigned long)file_size); + HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_size, + (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR #endif /* NOT_YET */ @@ -15400,20 +15537,22 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { - if(fh) + H5E_BEGIN_TRY + { + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_filtered_man_root_indirect() */ #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_random * @@ -15434,22 +15573,22 @@ error: static unsigned test_random(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - H5HF_create_t tmp_cparam; /* Local heap creation parameters */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned long seed = 0; /* Random # seed */ - hsize_t total_obj_added; /* Size of objects added */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - size_t obj_size; /* Size of object */ - size_t obj_loc; /* Location of object in buffer */ - fheap_heap_state_t state; /* State of fractal heap */ - size_t u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + H5HF_create_t tmp_cparam; /* Local heap creation parameters */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned long seed = 0; /* Random # seed */ + hsize_t total_obj_added; /* Size of objects added */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + size_t obj_size; /* Size of object */ + size_t obj_loc; /* Location of object in buffer */ + fheap_heap_state_t state; /* State of fractal heap */ + size_t u; /* Local index variable */ /* Initialize the heap ID structure */ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); @@ -15458,37 +15597,40 @@ test_random(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_test_pa HDmemcpy(&tmp_cparam, cparam, sizeof(H5HF_create_t)); /* Check if we are compressing the blocks */ - if(tparam->comp == FHEAP_TEST_COMPRESS) { - unsigned deflate_level; /* Deflation level */ + if (tparam->comp == FHEAP_TEST_COMPRESS) { + unsigned deflate_level; /* Deflation level */ /* Set an I/O filter for heap data */ deflate_level = 6; - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < + 0) FAIL_STACK_ERROR } /* end if */ /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Get information about heap ID lengths */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > MAX_HEAP_ID_LEN) + if (id_len > MAX_HEAP_ID_LEN) TEST_ERROR /* * Display testing message */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { - if(tparam->comp == FHEAP_TEST_COMPRESS) - TESTING("inserting random-sized objects in heap with compressed blocks, then remove all objects (all - deleting heap)") + if (tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->comp == FHEAP_TEST_COMPRESS) + TESTING("inserting random-sized objects in heap with compressed blocks, then remove all objects " + "(all - deleting heap)") else TESTING("inserting random-sized objects, then remove all objects (all - deleting heap)") } /* end if */ else { - if(tparam->comp == FHEAP_TEST_COMPRESS) - TESTING("inserting random-sized objects in heap with compressed blocks, then remove all objects (all - random)") + if (tparam->comp == FHEAP_TEST_COMPRESS) + TESTING("inserting random-sized objects in heap with compressed blocks, then remove all objects " + "(all - random)") else TESTING("inserting random-sized objects, then remove all objects (all - random)") } /* end else */ @@ -15496,44 +15638,45 @@ test_random(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_test_pa /* Choose random # seed */ seed = (unsigned long)HDtime(NULL); #ifdef QAK -/* seed = (unsigned long)1156158635; */ -HDfprintf(stderr, "Random # seed was: %lu\n", seed); + /* seed = (unsigned long)1156158635; */ + HDfprintf(stderr, "Random # seed was: %lu\n", seed); #endif /* QAK */ HDsrandom((unsigned)seed); /* Loop over adding objects to the heap, until the size limit is reached */ total_obj_added = 0; - while(total_obj_added < size_limit) { + while (total_obj_added < size_limit) { /* Choose a random size of object (from 1 up to above standalone block size limit) */ obj_size = (((uint32_t)HDrandom() % (tmp_cparam.max_man_size + 255)) + 1); - obj_loc = (tmp_cparam.max_man_size + 255) - obj_size; + obj_loc = (tmp_cparam.max_man_size + 255) - obj_size; /* Insert object */ - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Increment the amount of objects added */ total_obj_added += obj_size; } /* end while */ #ifdef QAK -HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = %Hu\n", keep_ids.num_ids, total_obj_added, size_limit); + HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = %Hu\n", keep_ids.num_ids, + total_obj_added, size_limit); #endif /* QAK */ /* Randomize the order of the IDs kept */ - for(u = 0; u < keep_ids.num_ids; u++) { - size_t pos; /* Position to swap with */ + for (u = 0; u < keep_ids.num_ids; u++) { + size_t pos; /* Position to swap with */ /* Choose a position to swap with */ /* (0 is current position) */ pos = ((size_t)HDrandom() % (keep_ids.num_ids - u)); /* If we chose a different position, swap with it */ - if(pos > 0) { - unsigned char temp_id[MAX_HEAP_ID_LEN]; /* Temp. heap ID holder */ + if (pos > 0) { + unsigned char temp_id[MAX_HEAP_ID_LEN]; /* Temp. heap ID holder */ /* Swap current position with future position */ /* (just swap the heap ID, the len & offset isn't used */ @@ -15541,55 +15684,55 @@ HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = % HDmemcpy(&keep_ids.ids[u * id_len], &keep_ids.ids[(u + pos) * id_len], id_len); HDmemcpy(&keep_ids.ids[(u + pos) * id_len], temp_id, id_len); } /* end if */ - } /* end for */ + } /* end for */ /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { /* Delete objects inserted */ - for(u = 0; u < keep_ids.num_ids; u++) { + for (u = 0; u < keep_ids.num_ids; u++) { /* Remove object from heap */ - if(H5HF_remove(fh, &keep_ids.ids[id_len * u]) < 0) + if (H5HF_remove(fh, &keep_ids.ids[id_len * u]) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR } /* end for */ /* Check up on heap... */ - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ - if(tparam->comp == FHEAP_TEST_COMPRESS) + if (tparam->comp == FHEAP_TEST_COMPRESS) H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ /* Free resources */ @@ -15600,25 +15743,26 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: HDfprintf(stderr, "Random # seed was: %lu\n", seed); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(tparam->comp == FHEAP_TEST_COMPRESS) + if (tparam->comp == FHEAP_TEST_COMPRESS) H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ - if(fh) + if (fh) H5HF_close(fh); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_random() */ - /*------------------------------------------------------------------------- * Function: test_random_pow2 * @@ -15640,22 +15784,22 @@ error: static unsigned test_random_pow2(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - H5HF_create_t tmp_cparam; /* Local heap creation parameters */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - unsigned long seed = 0; /* Random # seed */ - hsize_t total_obj_added; /* Size of objects added */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - h5_stat_size_t file_size; /* Size of file currently */ - size_t obj_size; /* Size of object */ - size_t obj_loc; /* Location of object in buffer */ - fheap_heap_state_t state; /* State of fractal heap */ - size_t u; /* Local index variable */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + H5HF_create_t tmp_cparam; /* Local heap creation parameters */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + unsigned long seed = 0; /* Random # seed */ + hsize_t total_obj_added; /* Size of objects added */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + h5_stat_size_t file_size; /* Size of file currently */ + size_t obj_size; /* Size of object */ + size_t obj_loc; /* Location of object in buffer */ + fheap_heap_state_t state; /* State of fractal heap */ + size_t u; /* Local index variable */ /* Initialize the heap ID structure */ HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); @@ -15664,94 +15808,100 @@ test_random_pow2(hsize_t size_limit, hid_t fapl, H5HF_create_t *cparam, fheap_te HDmemcpy(&tmp_cparam, cparam, sizeof(H5HF_create_t)); /* Check if we are compressing the blocks */ - if(tparam->comp == FHEAP_TEST_COMPRESS) { - unsigned deflate_level; /* Deflation level */ + if (tparam->comp == FHEAP_TEST_COMPRESS) { + unsigned deflate_level; /* Deflation level */ /* Set an I/O filter for heap data */ deflate_level = 6; - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < + 0) FAIL_STACK_ERROR } /* end if */ /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Get information about heap ID lengths */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > MAX_HEAP_ID_LEN) + if (id_len > MAX_HEAP_ID_LEN) TEST_ERROR /* * Display testing message */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { - if(tparam->comp == FHEAP_TEST_COMPRESS) - TESTING("inserting random-sized objects with power of 2 distribution in heap with compressed blocks, then remove all objects (all - deleting heap)") + if (tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->comp == FHEAP_TEST_COMPRESS) + TESTING("inserting random-sized objects with power of 2 distribution in heap with compressed " + "blocks, then remove all objects (all - deleting heap)") else - TESTING("inserting random-sized objects with power of 2 distribution, then remove all objects (all - deleting heap)") + TESTING("inserting random-sized objects with power of 2 distribution, then remove all objects " + "(all - deleting heap)") } /* end if */ else { - if(tparam->comp == FHEAP_TEST_COMPRESS) - TESTING("inserting random-sized objects with power of 2 distribution in heap with compressed blocks, then remove all objects (all - random)") + if (tparam->comp == FHEAP_TEST_COMPRESS) + TESTING("inserting random-sized objects with power of 2 distribution in heap with compressed " + "blocks, then remove all objects (all - random)") else - TESTING("inserting random-sized objects with power of 2 distribution, then remove all objects (all - random)") + TESTING("inserting random-sized objects with power of 2 distribution, then remove all objects " + "(all - random)") } /* end else */ /* Choose random # seed */ seed = (unsigned long)HDtime(NULL); #ifdef QAK -/* seed = (unsigned long)1155181717; */ -HDfprintf(stderr, "Random # seed was: %lu\n", seed); + /* seed = (unsigned long)1155181717; */ + HDfprintf(stderr, "Random # seed was: %lu\n", seed); #endif /* QAK */ HDsrandom((unsigned)seed); /* Loop over adding objects to the heap, until the size limit is reached */ total_obj_added = 0; - while(total_obj_added < size_limit) { - size_t size_range = (tmp_cparam.managed.start_block_size / 8); /* Object size range */ + while (total_obj_added < size_limit) { + size_t size_range = (tmp_cparam.managed.start_block_size / 8); /* Object size range */ /* Determine the size of the range for this object */ /* (50% of the objects inserted will use the initial size range, * 25% of the objects will be twice as large, 12.5% will be * four times larger, etc.) */ - while(HDrandom() < (RAND_MAX / 2) && size_range < tmp_cparam.max_man_size) + while (HDrandom() < (RAND_MAX / 2) && size_range < tmp_cparam.max_man_size) size_range *= 2; - if(size_range > (tmp_cparam.max_man_size + 255)) + if (size_range > (tmp_cparam.max_man_size + 255)) size_range = tmp_cparam.max_man_size + 255; /* Choose a random size of object (from 1 up to stand alone block size) */ obj_size = (((unsigned)HDrandom() % (size_range - 1)) + 1); - obj_loc = (tmp_cparam.max_man_size + 255) - obj_size; + obj_loc = (tmp_cparam.max_man_size + 255) - obj_size; /* Insert object */ - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Increment the amount of objects added */ total_obj_added += obj_size; } /* end while */ #ifdef QAK -HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = %Hu\n", keep_ids.num_ids, total_obj_added, size_limit); + HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = %Hu\n", keep_ids.num_ids, + total_obj_added, size_limit); #endif /* QAK */ /* Randomize the order of the IDs kept */ - for(u = 0; u < keep_ids.num_ids; u++) { - size_t pos; /* Position to swap with */ + for (u = 0; u < keep_ids.num_ids; u++) { + size_t pos; /* Position to swap with */ /* Choose a position to swap with */ /* (0 is current position) */ pos = ((size_t)HDrandom() % (keep_ids.num_ids - u)); /* If we chose a different position, swap with it */ - if(pos > 0) { - unsigned char temp_id[MAX_HEAP_ID_LEN]; /* Temp. heap ID holder */ + if (pos > 0) { + unsigned char temp_id[MAX_HEAP_ID_LEN]; /* Temp. heap ID holder */ /* Swap current position with future position */ /* (just swap the heap ID, the len & offset isn't used */ @@ -15759,56 +15909,56 @@ HDfprintf(stderr, "keep_ids.num_ids = %Zu, total_obj_added = %Hu, size_limit = % HDmemcpy(&keep_ids.ids[u * id_len], &keep_ids.ids[(u + pos) * id_len], id_len); HDmemcpy(&keep_ids.ids[(u + pos) * id_len], temp_id, id_len); } /* end if */ - } /* end for */ + } /* end for */ /* Delete individual objects, if we won't be deleting the entire heap later */ - if(tparam->del_dir != FHEAP_DEL_HEAP) { + if (tparam->del_dir != FHEAP_DEL_HEAP) { /* Delete objects inserted */ - for(u = 0; u < keep_ids.num_ids; u++) { + for (u = 0; u < keep_ids.num_ids; u++) { /* Remove object from heap */ - if(H5HF_remove(fh, &keep_ids.ids[id_len * u]) < 0) + if (H5HF_remove(fh, &keep_ids.ids[id_len * u]) < 0) FAIL_STACK_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR } /* end for */ /* Check up on heap... */ - if(check_stats(fh, &state)) + if (check_stats(fh, &state)) TEST_ERROR } /* end if */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Check for deleting the entire heap */ - if(tparam->del_dir == FHEAP_DEL_HEAP) { + if (tparam->del_dir == FHEAP_DEL_HEAP) { /* Delete heap */ - if(H5HF_delete(f, fh_addr) < 0) + if (H5HF_delete(f, fh_addr) < 0) FAIL_STACK_ERROR } /* end if */ /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR #ifdef QAK -HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); -HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); + HDfprintf(stderr, "empty_size = %lu\n", (unsigned long)empty_size); + HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); #endif /* QAK */ /* Verify the file is correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR /* Free resources */ - if(tparam->comp == FHEAP_TEST_COMPRESS) + if (tparam->comp == FHEAP_TEST_COMPRESS) H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ /* Free resources */ @@ -15819,26 +15969,28 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); /* All tests passed */ PASSED(); - return(0); + return (0); error: HDfprintf(stderr, "Random # seed was: %lu\n", seed); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - if(tparam->comp == FHEAP_TEST_COMPRESS) + if (tparam->comp == FHEAP_TEST_COMPRESS) H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_random_pow2() */ #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_write * @@ -15855,9 +16007,10 @@ error: /* Custom filter used to verify that the filters are actually called and do not * just silently fail */ static hbool_t test_write_filter_called; -static size_t test_write_filter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED cd_values[], size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, - void H5_ATTR_UNUSED **buf) +static size_t +test_write_filter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned int H5_ATTR_UNUSED cd_values[], size_t nbytes, + size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) { test_write_filter_called = TRUE; @@ -15867,29 +16020,29 @@ static size_t test_write_filter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATT static unsigned test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - H5HF_create_t tmp_cparam; /* Local heap creation parameters */ - size_t id_len; /* Size of fractal heap IDs */ - unsigned char tiny_heap_id[HEAP_ID_LEN]; /* Heap ID for 'tiny' object */ - unsigned char huge_heap_id[HEAP_ID_LEN]; /* Heap ID for 'huge' object */ - hbool_t id_changed = FALSE; /* Whether the heap ID changed */ - unsigned char *rewrite_obj = NULL; /* Pointer to re-write buffer for objects */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t obj_loc; /* Location of object in buffer */ - fheap_heap_state_t state; /* State of fractal heap */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + H5HF_create_t tmp_cparam; /* Local heap creation parameters */ + size_t id_len; /* Size of fractal heap IDs */ + unsigned char tiny_heap_id[HEAP_ID_LEN]; /* Heap ID for 'tiny' object */ + unsigned char huge_heap_id[HEAP_ID_LEN]; /* Heap ID for 'huge' object */ + hbool_t id_changed = FALSE; /* Whether the heap ID changed */ + unsigned char * rewrite_obj = NULL; /* Pointer to re-write buffer for objects */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t obj_loc; /* Location of object in buffer */ + fheap_heap_state_t state; /* State of fractal heap */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* * Display testing message */ - if(tparam->comp == FHEAP_TEST_COMPRESS) + if (tparam->comp == FHEAP_TEST_COMPRESS) TESTING("writing objects in heap with compressed blocks") else TESTING("writing objects in heap") @@ -15901,95 +16054,100 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) HDmemcpy(&tmp_cparam, cparam, sizeof(H5HF_create_t)); /* Check if we are compressing the blocks */ - if(tparam->comp == FHEAP_TEST_COMPRESS) { - H5Z_class2_t filter_class; /* Custom filter */ - unsigned deflate_level; /* Deflation level */ + if (tparam->comp == FHEAP_TEST_COMPRESS) { + H5Z_class2_t filter_class; /* Custom filter */ + unsigned deflate_level; /* Deflation level */ /* Set an I/O filter for heap data */ deflate_level = 6; - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < 0) + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &deflate_level) < + 0) FAIL_STACK_ERROR /* Register and append custom filter */ - filter_class.version = H5Z_CLASS_T_VERS; - filter_class.id = H5Z_FILTER_RESERVED + 43; + filter_class.version = H5Z_CLASS_T_VERS; + filter_class.id = H5Z_FILTER_RESERVED + 43; filter_class.encoder_present = TRUE; filter_class.decoder_present = TRUE; - filter_class.name = "custom_fheap_filter"; - filter_class.can_apply = NULL; - filter_class.set_local = NULL; - filter_class.filter = test_write_filter; - if(H5Zregister(&filter_class) < 0) TEST_ERROR - if(H5Z_append(&tmp_cparam.pline, H5Z_FILTER_RESERVED + 43, 0, (size_t)0, NULL) < 0) + filter_class.name = "custom_fheap_filter"; + filter_class.can_apply = NULL; + filter_class.set_local = NULL; + filter_class.filter = test_write_filter; + if (H5Zregister(&filter_class) < 0) + TEST_ERROR + if (H5Z_append(&tmp_cparam.pline, H5Z_FILTER_RESERVED + 43, 0, (size_t)0, NULL) < 0) FAIL_STACK_ERROR test_write_filter_called = FALSE; } /* end if */ /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, &tmp_cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Get information about heap ID lengths */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > MAX_HEAP_ID_LEN) + if (id_len > MAX_HEAP_ID_LEN) TEST_ERROR - /* Create 'tiny' and 'huge' objects */ obj_size = id_len / 2; - if(H5HF_insert(fh, obj_size, shared_wobj_g, tiny_heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, tiny_heap_id) < 0) FAIL_STACK_ERROR obj_size = tmp_cparam.max_man_size + 1; - if(H5HF_insert(fh, obj_size, shared_wobj_g, huge_heap_id) < 0) + if (H5HF_insert(fh, obj_size, shared_wobj_g, huge_heap_id) < 0) FAIL_STACK_ERROR /* Verify that writing to 'huge' objects works for un-filtered heaps */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5HF_write(fh, huge_heap_id, &id_changed, shared_wobj_g); - } H5E_END_TRY; + } + H5E_END_TRY; HDassert(!id_changed); - if(tparam->comp == FHEAP_TEST_COMPRESS) { - if(ret >= 0) + if (tparam->comp == FHEAP_TEST_COMPRESS) { + if (ret >= 0) TEST_ERROR } /* end if */ else { - if(ret < 0) + if (ret < 0) FAIL_STACK_ERROR } /* end else */ /* Verify that writing to 'tiny' objects return failure (for now) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5HF_write(fh, tiny_heap_id, &id_changed, shared_wobj_g); - } H5E_END_TRY; + } + H5E_END_TRY; HDassert(!id_changed); - if(ret >= 0) + if (ret >= 0) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Verify that the custom filter has been applied for the huge object (if * applicable) */ - if(tparam->comp == FHEAP_TEST_COMPRESS) { - if(!test_write_filter_called) TEST_ERROR + if (tparam->comp == FHEAP_TEST_COMPRESS) { + if (!test_write_filter_called) + TEST_ERROR test_write_filter_called = FALSE; } /* end if */ - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15997,66 +16155,66 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Initialize data to overwrite with */ rewrite_obj = (unsigned char *)H5MM_malloc(shared_obj_size_g); - for(u = 0; u < shared_obj_size_g; u++) + for (u = 0; u < shared_obj_size_g; u++) rewrite_obj[u] = (unsigned char)(shared_wobj_g[u] * 2); /* Insert different sized objects, but stay out of "tiny" and "huge" zones */ obj_size = 20; - for(u = 0; u < 40; u++) { + for (u = 0; u < 40; u++) { obj_loc = u; - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR /* Check for closing & re-opening the heap */ - if(reopen_heap(f, &fh, fh_addr, tparam) < 0) + if (reopen_heap(f, &fh, fh_addr, tparam) < 0) TEST_ERROR /* Overwrite data just written */ - if(H5HF_write(fh, &keep_ids.ids[id_len * u], &id_changed, rewrite_obj) < 0) + if (H5HF_write(fh, &keep_ids.ids[id_len * u], &id_changed, rewrite_obj) < 0) FAIL_STACK_ERROR HDassert(!id_changed); /* Read data back in */ - if(H5HF_read(fh, &keep_ids.ids[id_len * u], shared_robj_g) < 0) + if (H5HF_read(fh, &keep_ids.ids[id_len * u], shared_robj_g) < 0) FAIL_STACK_ERROR /* Compare data read in */ - if(HDmemcmp(rewrite_obj, shared_robj_g, obj_size)) + if (HDmemcmp(rewrite_obj, shared_robj_g, obj_size)) TEST_ERROR /* Change size of data to write */ - if(u < 20) + if (u < 20) obj_size = (size_t)((float)obj_size * 1.3F); else obj_size = (size_t)((float)obj_size / 1.3F); } /* end for */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Verify that the custom filter has been applied to the managed objects (if * applicable) */ - if(tparam->comp == FHEAP_TEST_COMPRESS) - if(!test_write_filter_called) TEST_ERROR - + if (tparam->comp == FHEAP_TEST_COMPRESS) + if (!test_write_filter_called) + TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -16064,38 +16222,38 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Verify changed objects */ obj_size = 20; - for(u = 0; u < 40; u++) { + for (u = 0; u < 40; u++) { /* Read data back in */ - if(H5HF_read(fh, &keep_ids.ids[id_len * u], shared_robj_g) < 0) + if (H5HF_read(fh, &keep_ids.ids[id_len * u], shared_robj_g) < 0) FAIL_STACK_ERROR /* Compare data read in */ - if(HDmemcmp(rewrite_obj, shared_robj_g, obj_size)) + if (HDmemcmp(rewrite_obj, shared_robj_g, obj_size)) TEST_ERROR /* Change size of data to write */ - if(u < 20) + if (u < 20) obj_size = (size_t)((float)obj_size * 1.3F); else obj_size = (size_t)((float)obj_size / 1.3F); } /* end for */ /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Free resources */ - if(tparam->comp == FHEAP_TEST_COMPRESS) + if (tparam->comp == FHEAP_TEST_COMPRESS) H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ /* Free resources */ @@ -16107,24 +16265,26 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); H5MM_xfree(rewrite_obj); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_write() */ #endif /* QAK */ #ifndef QAK - + /*------------------------------------------------------------------------- * Function: test_bug1 * @@ -16143,17 +16303,17 @@ error: static unsigned test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) { - hid_t file = -1; /* File ID */ - char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5HF_t *fh = NULL; /* Fractal heap wrapper */ - haddr_t fh_addr; /* Address of fractal heap */ - size_t id_len; /* Size of fractal heap IDs */ - fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ - h5_stat_size_t empty_size; /* Size of a file with an empty heap */ - size_t obj_size; /* Size of object */ - size_t obj_loc; /* Location of object in buffer */ - fheap_heap_state_t state; /* State of fractal heap */ + hid_t file = -1; /* File ID */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5HF_t * fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + size_t id_len; /* Size of fractal heap IDs */ + fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ + h5_stat_size_t empty_size; /* Size of a file with an empty heap */ + size_t obj_size; /* Size of object */ + size_t obj_loc; /* Location of object in buffer */ + fheap_heap_state_t state; /* State of fractal heap */ /* * Display testing message @@ -16164,63 +16324,61 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) HDmemset(&keep_ids, 0, sizeof(fheap_heap_ids_t)); /* Perform common file & heap open operations */ - if(open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) + if (open_heap(filename, fapl, cparam, tparam, &file, &f, &fh, &fh_addr, &state, &empty_size) < 0) TEST_ERROR /* Get information about heap ID lengths */ - if(H5HF_get_id_len(fh, &id_len) < 0) + if (H5HF_get_id_len(fh, &id_len) < 0) FAIL_STACK_ERROR - if(id_len > MAX_HEAP_ID_LEN) + if (id_len > MAX_HEAP_ID_LEN) TEST_ERROR /* Insert objects */ obj_size = 44; - obj_loc = 1; - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + obj_loc = 1; + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR obj_size = 484; - obj_loc = 2; - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + obj_loc = 2; + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR obj_size = 168; - obj_loc = 3; - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + obj_loc = 3; + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR obj_size = 96; - obj_loc = 4; - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + obj_loc = 4; + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR obj_size = 568; - obj_loc = 5; - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + obj_loc = 5; + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR obj_size = 568; - obj_loc = 6; - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + obj_loc = 6; + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -16228,29 +16386,28 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Remove one of the objects */ - if(H5HF_remove(fh, &keep_ids.ids[id_len * 4]) < 0) + if (H5HF_remove(fh, &keep_ids.ids[id_len * 4]) < 0) FAIL_STACK_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -16258,25 +16415,24 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, fh_addr))) + if (NULL == (fh = H5HF_open(f, fh_addr))) FAIL_STACK_ERROR /* Insert another object */ obj_size = 208; - obj_loc = 6; - if(add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) + obj_loc = 6; + if (add_obj(fh, obj_loc, obj_size, NULL, &keep_ids)) TEST_ERROR /* Close the fractal heap */ - if(H5HF_close(fh) < 0) + if (H5HF_close(fh) < 0) FAIL_STACK_ERROR fh = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - /* Free resources */ H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); @@ -16285,22 +16441,23 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) /* All tests passed */ PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(keep_ids.ids); H5MM_xfree(keep_ids.lens); H5MM_xfree(keep_ids.offs); - if(fh) + if (fh) H5HF_close(fh); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_bug1() */ #endif /* QAK */ - /*------------------------------------------------------------------------- * Function: main * @@ -16318,24 +16475,24 @@ error: int main(void) { - fheap_test_param_t tparam; /* Testing parameters */ - H5HF_create_t small_cparam; /* Creation parameters for "small" heap */ - H5HF_create_t large_cparam; /* Creation parameters for "large" heap */ - hid_t fapl = -1, def_fapl = -1; /* File access property list for data files */ - hid_t pb_fapl = -1; /* File access property list for data files */ - hid_t fcpl = -1, def_fcpl = -1; /* File creation property list for data files */ - fheap_test_type_t curr_test; /* Current test being worked on */ - unsigned u, v; /* Local index variable */ - unsigned nerrors = 0; /* Cumulative error count */ - unsigned num_pb_fs = 1; /* The number of settings to test for page buffering and file space handling */ - int ExpressMode; /* Express testing level */ - const char *envval; /* Environment variable */ - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + fheap_test_param_t tparam; /* Testing parameters */ + H5HF_create_t small_cparam; /* Creation parameters for "small" heap */ + H5HF_create_t large_cparam; /* Creation parameters for "large" heap */ + hid_t fapl = -1, def_fapl = -1; /* File access property list for data files */ + hid_t pb_fapl = -1; /* File access property list for data files */ + hid_t fcpl = -1, def_fcpl = -1; /* File creation property list for data files */ + fheap_test_type_t curr_test; /* Current test being worked on */ + unsigned u, v; /* Local index variable */ + unsigned nerrors = 0; /* Cumulative error count */ + unsigned num_pb_fs = 1; /* The number of settings to test for page buffering and file space handling */ + int ExpressMode; /* Express testing level */ + const char *envval; /* Environment variable */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Don't run this test using certain file drivers */ envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL) + if (envval == NULL) envval = "nomatch"; /* Current VFD that does not support contigous address space */ @@ -16344,7 +16501,7 @@ main(void) /* Reset library */ h5_reset(); - def_fapl = h5_fileaccess(); + def_fapl = h5_fileaccess(); ExpressMode = GetTestExpress(); /* @@ -16357,9 +16514,9 @@ main(void) * Activate full testing when this feature is re-enabled * in the future for parallel build. */ - if(ExpressMode > 1) + if (ExpressMode > 1) HDprintf("***Express test mode on. Some tests may be skipped\n"); - else if(ExpressMode == 0) { + else if (ExpressMode == 0) { #ifdef H5_HAVE_PARALLEL num_pb_fs = NUM_PB_FS - 2; #else @@ -16372,47 +16529,48 @@ main(void) init_large_cparam(&large_cparam); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Allocate space for the shared objects */ shared_obj_size_g = large_cparam.max_man_size + 256; - shared_wobj_g = (unsigned char *)H5MM_malloc(shared_obj_size_g); - shared_robj_g = (unsigned char *)H5MM_malloc(shared_obj_size_g); + shared_wobj_g = (unsigned char *)H5MM_malloc(shared_obj_size_g); + shared_robj_g = (unsigned char *)H5MM_malloc(shared_obj_size_g); /* Create a copy def_fapl and enable page buffering */ - if((pb_fapl = H5Pcopy(def_fapl)) < 0) + if ((pb_fapl = H5Pcopy(def_fapl)) < 0) TEST_ERROR - if(H5Pset_page_buffer_size(pb_fapl, PAGE_BUFFER_PAGE_SIZE, 0, 0) < 0) + if (H5Pset_page_buffer_size(pb_fapl, PAGE_BUFFER_PAGE_SIZE, 0, 0) < 0) TEST_ERROR /* Create a file creation property list */ - if((def_fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((def_fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR /* Initialize the shared write buffer for objects */ - for(u = 0; u < shared_obj_size_g; u++) + for (u = 0; u < shared_obj_size_g; u++) shared_wobj_g[u] = (unsigned char)u; - for(v = 0; v < num_pb_fs; v++) { + for (v = 0; v < num_pb_fs; v++) { /* Skip test when: a) multi/split drivers and b) persisting free-space or using paged aggregation strategy because the library will fail file creation (temporary) for the above conditions */ - if(!contig_addr_vfd && v) + if (!contig_addr_vfd && v) break; - if((fcpl = H5Pcopy(def_fcpl)) < 0) + if ((fcpl = H5Pcopy(def_fcpl)) < 0) TEST_ERROR - switch(v) { + switch (v) { case 0: - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)1) < 0) TEST_ERROR fapl = def_fapl; break; case 1: - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) TEST_ERROR fapl = def_fapl; /* This is a fix for the daily test failure from the checkin for libver bounds. */ @@ -16440,26 +16598,26 @@ main(void) * library to use version 2 object header for the superblock extension * message. */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) TEST_ERROR break; case 2: - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) TEST_ERROR fapl = def_fapl; break; case 3: - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) TEST_ERROR fapl = def_fapl; break; case 4: - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) TEST_ERROR fapl = pb_fapl; break; case 5: - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) TEST_ERROR fapl = pb_fapl; break; @@ -16470,7 +16628,7 @@ main(void) } /* Iterate over the testing parameters */ - for(curr_test = FHEAP_TEST_NORMAL; curr_test < FHEAP_TEST_NTESTS; curr_test++) { + for (curr_test = FHEAP_TEST_NORMAL; curr_test < FHEAP_TEST_NTESTS; curr_test++) { /* Clear the testing parameters */ HDmemset(&tparam, 0, sizeof(fheap_test_param_t)); tparam.actual_id_len = HEAP_ID_LEN; @@ -16479,7 +16637,7 @@ main(void) tparam.my_fcpl = fcpl; /* Set appropriate testing parameters for each test */ - switch(curr_test) { + switch (curr_test) { /* "Normal" testing parameters */ case FHEAP_TEST_NORMAL: HDputs("Testing with normal parameters"); @@ -16509,288 +16667,346 @@ main(void) nerrors += test_reopen_hdr(fapl, &small_cparam, tparam.my_fcpl); { - fheap_test_fill_t fill; /* Size of objects to fill heap blocks with */ - - /* Filling with different sized objects */ - for(fill = FHEAP_TEST_FILL_LARGE; fill < FHEAP_TEST_FILL_N; fill++) { - tparam.fill = fill; - - /* Set appropriate testing parameters for each test */ - switch(fill) { - /* "Bulk fill" heap blocks with 'large' objects */ - case FHEAP_TEST_FILL_LARGE: - HDputs("Bulk-filling blocks w/large objects"); - break; - - /* "Bulk fill" heap blocks with 'single' objects */ - case FHEAP_TEST_FILL_SINGLE: - HDputs("Bulk-filling blocks w/single object"); - break; - - /* An unknown test? */ - case FHEAP_TEST_FILL_N: - default: - goto error; - } /* end switch */ + fheap_test_fill_t fill; /* Size of objects to fill heap blocks with */ - /* - * Test fractal heap managed object insertion - */ - - /* "Weird" sized objects */ - nerrors += test_man_insert_weird(fapl, &small_cparam, &tparam); - -#ifdef ALL_INSERT_TESTS - /* "Standard" sized objects, building from simple to complex heaps */ - nerrors += test_man_insert_first(fapl, &small_cparam, &tparam); - nerrors += test_man_insert_second(fapl, &small_cparam, &tparam); - nerrors += test_man_insert_root_mult(fapl, &small_cparam, &tparam); - nerrors += test_man_insert_force_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_insert_fill_second(fapl, &small_cparam, &tparam); - nerrors += test_man_insert_third_direct(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_first_row(fapl, &small_cparam, &tparam); - nerrors += test_man_start_second_row(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_second_row(fapl, &small_cparam, &tparam); - nerrors += test_man_start_third_row(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_fourth_row(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_all_root_direct(fapl, &small_cparam, &tparam); - nerrors += test_man_first_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_second_direct_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_first_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_second_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_second_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_recursive_indirect_row(fapl, &small_cparam, &tparam); - nerrors += test_man_start_2nd_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_recursive_indirect_two_deep(fapl, &small_cparam, &tparam); - nerrors += test_man_start_3rd_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_first_3rd_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_3rd_recursive_indirect_row(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_all_3rd_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_start_4th_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_first_4th_recursive_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_4th_recursive_indirect_row(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_all_4th_recursive_indirect(fapl, &small_cparam, &tparam); -#endif /* ALL_INSERT_TESTS */ - /* If this test fails, uncomment the tests above, which build up to this - * level of complexity gradually. -QAK - */ - if(ExpressMode > 1) - HDprintf("***Express test mode on. test_man_start_5th_recursive_indirect is skipped\n"); - else - nerrors += test_man_start_5th_recursive_indirect(fapl, &small_cparam, &tparam); - - /* - * Test fractal heap object deletion - */ - /* Simple removal */ - nerrors += test_man_remove_bogus(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_one(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_two(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_one_larger(fapl, &small_cparam, &tparam); - tparam.del_dir = FHEAP_DEL_FORWARD; - nerrors += test_man_remove_two_larger(fapl, &small_cparam, &tparam); - tparam.del_dir = FHEAP_DEL_REVERSE; - nerrors += test_man_remove_two_larger(fapl, &small_cparam, &tparam); - tparam.del_dir = FHEAP_DEL_FORWARD; - nerrors += test_man_remove_three_larger(fapl, &small_cparam, &tparam); - tparam.del_dir = FHEAP_DEL_REVERSE; - nerrors += test_man_remove_three_larger(fapl, &small_cparam, &tparam); + /* Filling with different sized objects */ + for (fill = FHEAP_TEST_FILL_LARGE; fill < FHEAP_TEST_FILL_N; fill++) { + tparam.fill = fill; - /* Incremental insert & removal */ - tparam.del_dir = FHEAP_DEL_FORWARD; - nerrors += test_man_incr_insert_remove(fapl, &small_cparam, &tparam); - - { - fheap_test_del_dir_t del_dir; /* Deletion direction */ - fheap_test_del_drain_t drain_half; /* Deletion draining */ + /* Set appropriate testing parameters for each test */ + switch (fill) { + /* "Bulk fill" heap blocks with 'large' objects */ + case FHEAP_TEST_FILL_LARGE: + HDputs("Bulk-filling blocks w/large objects"); + break; - /* More complex removal patterns */ - for(del_dir = FHEAP_DEL_FORWARD; del_dir < FHEAP_DEL_NDIRS; del_dir++) { - tparam.del_dir = del_dir; - for(drain_half = FHEAP_DEL_DRAIN_ALL; drain_half < FHEAP_DEL_DRAIN_N; drain_half++) { - tparam.drain_half = drain_half; - /* Don't need to test deletion directions when deleting entire heap */ - if(tparam.del_dir == FHEAP_DEL_HEAP && tparam.drain_half > FHEAP_DEL_DRAIN_ALL) + /* "Bulk fill" heap blocks with 'single' objects */ + case FHEAP_TEST_FILL_SINGLE: + HDputs("Bulk-filling blocks w/single object"); break; - /* Simple insertion patterns */ - nerrors += test_man_remove_root_direct(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_two_direct(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_first_row(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_first_two_rows(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_first_four_rows(fapl, &small_cparam, &tparam); - if(ExpressMode > 1) - HDprintf("***Express test mode on. Some tests skipped\n"); - else { - nerrors += test_man_remove_all_root_direct(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_2nd_indirect(fapl, &small_cparam, &tparam); - nerrors += test_man_remove_3rd_indirect(fapl, &small_cparam, &tparam); - } /* end else */ - - /* Skip blocks insertion */ - /* (covers insertion & deletion of skipped blocks) */ - nerrors += test_man_skip_start_block(fapl, &small_cparam, &tparam); - nerrors += test_man_skip_start_block_add_back(fapl, &small_cparam, &tparam); - nerrors += test_man_skip_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_skip_2nd_block(fapl, &small_cparam, &tparam); - nerrors += test_man_skip_2nd_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_one_partial_skip_2nd_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_row_skip_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_skip_direct_skip_indirect_two_rows_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_direct_skip_indirect_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_2nd_direct_less_one_wrap_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_direct_skip_indirect_two_rows_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_2nd_direct_skip_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped(fapl, &small_cparam, &tparam); - if(ExpressMode > 1) - HDprintf("***Express test mode on. Some tests skipped\n"); - else { - nerrors += test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(fapl, &small_cparam, &tparam); - nerrors += test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped(fapl, &small_cparam, &tparam); - } /* end else */ - - /* Fragmented insertion patterns */ - /* (covers insertion & deletion of fragmented blocks) */ - nerrors += test_man_frag_simple(fapl, &small_cparam, &tparam); - nerrors += test_man_frag_direct(fapl, &small_cparam, &tparam); - nerrors += test_man_frag_2nd_direct(fapl, &small_cparam, &tparam); - nerrors += test_man_frag_3rd_direct(fapl, &small_cparam, &tparam); - } /* end for */ - } /* end for */ + /* An unknown test? */ + case FHEAP_TEST_FILL_N: + default: + goto error; + } /* end switch */ - /* Reset deletion drain parameter */ - tparam.drain_half = FHEAP_DEL_DRAIN_ALL; + /* + * Test fractal heap managed object insertion + */ - } /* end block */ - } /* end for */ - } /* end block */ + /* "Weird" sized objects */ + nerrors += test_man_insert_weird(fapl, &small_cparam, &tparam); + +#ifdef ALL_INSERT_TESTS + /* "Standard" sized objects, building from simple to complex heaps */ + nerrors += test_man_insert_first(fapl, &small_cparam, &tparam); + nerrors += test_man_insert_second(fapl, &small_cparam, &tparam); + nerrors += test_man_insert_root_mult(fapl, &small_cparam, &tparam); + nerrors += test_man_insert_force_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_insert_fill_second(fapl, &small_cparam, &tparam); + nerrors += test_man_insert_third_direct(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_first_row(fapl, &small_cparam, &tparam); + nerrors += test_man_start_second_row(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_second_row(fapl, &small_cparam, &tparam); + nerrors += test_man_start_third_row(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_fourth_row(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_all_root_direct(fapl, &small_cparam, &tparam); + nerrors += test_man_first_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_second_direct_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_first_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_second_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_second_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_recursive_indirect_row(fapl, &small_cparam, &tparam); + nerrors += test_man_start_2nd_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_recursive_indirect_two_deep(fapl, &small_cparam, &tparam); + nerrors += test_man_start_3rd_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_first_3rd_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_3rd_recursive_indirect_row(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_all_3rd_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_start_4th_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_first_4th_recursive_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_4th_recursive_indirect_row(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_all_4th_recursive_indirect(fapl, &small_cparam, &tparam); +#endif /* ALL_INSERT_TESTS */ + /* If this test fails, uncomment the tests above, which build up to this + * level of complexity gradually. -QAK + */ + if (ExpressMode > 1) + HDprintf( + "***Express test mode on. test_man_start_5th_recursive_indirect is skipped\n"); + else + nerrors += test_man_start_5th_recursive_indirect(fapl, &small_cparam, &tparam); + + /* + * Test fractal heap object deletion + */ + /* Simple removal */ + nerrors += test_man_remove_bogus(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_one(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_two(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_one_larger(fapl, &small_cparam, &tparam); + tparam.del_dir = FHEAP_DEL_FORWARD; + nerrors += test_man_remove_two_larger(fapl, &small_cparam, &tparam); + tparam.del_dir = FHEAP_DEL_REVERSE; + nerrors += test_man_remove_two_larger(fapl, &small_cparam, &tparam); + tparam.del_dir = FHEAP_DEL_FORWARD; + nerrors += test_man_remove_three_larger(fapl, &small_cparam, &tparam); + tparam.del_dir = FHEAP_DEL_REVERSE; + nerrors += test_man_remove_three_larger(fapl, &small_cparam, &tparam); + + /* Incremental insert & removal */ + tparam.del_dir = FHEAP_DEL_FORWARD; + nerrors += test_man_incr_insert_remove(fapl, &small_cparam, &tparam); + + { + fheap_test_del_dir_t del_dir; /* Deletion direction */ + fheap_test_del_drain_t drain_half; /* Deletion draining */ + + /* More complex removal patterns */ + for (del_dir = FHEAP_DEL_FORWARD; del_dir < FHEAP_DEL_NDIRS; del_dir++) { + tparam.del_dir = del_dir; + for (drain_half = FHEAP_DEL_DRAIN_ALL; drain_half < FHEAP_DEL_DRAIN_N; + drain_half++) { + tparam.drain_half = drain_half; + /* Don't need to test deletion directions when deleting entire heap */ + if (tparam.del_dir == FHEAP_DEL_HEAP && + tparam.drain_half > FHEAP_DEL_DRAIN_ALL) + break; + + /* Simple insertion patterns */ + nerrors += test_man_remove_root_direct(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_two_direct(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_first_row(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_first_two_rows(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_first_four_rows(fapl, &small_cparam, &tparam); + if (ExpressMode > 1) + HDprintf("***Express test mode on. Some tests skipped\n"); + else { + nerrors += test_man_remove_all_root_direct(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_2nd_indirect(fapl, &small_cparam, &tparam); + nerrors += test_man_remove_3rd_indirect(fapl, &small_cparam, &tparam); + } /* end else */ + + /* Skip blocks insertion */ + /* (covers insertion & deletion of skipped blocks) */ + nerrors += test_man_skip_start_block(fapl, &small_cparam, &tparam); + nerrors += test_man_skip_start_block_add_back(fapl, &small_cparam, &tparam); + nerrors += + test_man_skip_start_block_add_skipped(fapl, &small_cparam, &tparam); + nerrors += test_man_skip_2nd_block(fapl, &small_cparam, &tparam); + nerrors += test_man_skip_2nd_block_add_skipped(fapl, &small_cparam, &tparam); + nerrors += test_man_fill_one_partial_skip_2nd_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += test_man_fill_row_skip_add_skipped(fapl, &small_cparam, &tparam); + nerrors += test_man_skip_direct_skip_indirect_two_rows_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += test_man_fill_direct_skip_indirect_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += test_man_fill_2nd_direct_less_one_wrap_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += test_man_fill_direct_skip_2nd_indirect_skip_2nd_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += test_man_fill_direct_skip_indirect_two_rows_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += test_man_fill_2nd_direct_skip_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_2nd_direct_fill_direct_skip2_3rd_indirect_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_3rd_direct_less_one_fill_direct_wrap_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_1st_row_3rd_direct_fill_2nd_direct_less_one_wrap_start_block_add_skipped( + fapl, &small_cparam, &tparam); + if (ExpressMode > 1) + HDprintf("***Express test mode on. Some tests skipped\n"); + else { + nerrors += + test_man_fill_3rd_direct_fill_direct_skip_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_two_rows_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_3rd_direct_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped( + fapl, &small_cparam, &tparam); + nerrors += + test_man_fill_4th_direct_less_one_fill_2nd_direct_fill_direct_skip_3rd_indirect_wrap_start_block_add_skipped( + fapl, &small_cparam, &tparam); + } /* end else */ + + /* Fragmented insertion patterns */ + /* (covers insertion & deletion of fragmented blocks) */ + nerrors += test_man_frag_simple(fapl, &small_cparam, &tparam); + nerrors += test_man_frag_direct(fapl, &small_cparam, &tparam); + nerrors += test_man_frag_2nd_direct(fapl, &small_cparam, &tparam); + nerrors += test_man_frag_3rd_direct(fapl, &small_cparam, &tparam); + } /* end for */ + } /* end for */ + + /* Reset deletion drain parameter */ + tparam.drain_half = FHEAP_DEL_DRAIN_ALL; + + } /* end block */ + } /* end for */ + } /* end block */ /* * Test fractal heap 'huge' & 'tiny' object insertion & deletion */ { - fheap_test_del_dir_t del_dir; /* Deletion direction */ - unsigned id_len; /* Length of heap IDs */ - - /* Test "normal" & "direct" storage of 'huge' & 'tiny' heap IDs */ - for(id_len = 0; id_len < 3; id_len++) { - /* Set the ID length for this test */ - small_cparam.id_len = (uint16_t)id_len; - - /* Print information about each test */ - switch(id_len) { - /* Use "normal" form for 'huge' object's heap IDs */ - case 0: - HDputs("Using 'normal' heap ID format for 'huge' objects"); - break; - - /* Use "direct" form for 'huge' object's heap IDs */ - case 1: - HDputs("Using 'direct' heap ID format for 'huge' objects"); - - /* Adjust actual length of heap IDs for directly storing 'huge' object's file offset & length in heap ID */ - tparam.actual_id_len = 17; /* 1 + 8 (file address size) + 8 (file length size) */ - break; - - /* Use "direct" storage for 'huge' objects and larger IDs for 'tiny' objects */ - case 2: - small_cparam.id_len = 37; - HDputs("Using 'direct' heap ID format for 'huge' objects and larger IDs for 'tiny' objects"); - tparam.actual_id_len = 37; - break; - - /* An unknown test? */ - default: - goto error; - } /* end switch */ - - /* Try several different methods of deleting objects */ - for(del_dir = FHEAP_DEL_FORWARD; del_dir < FHEAP_DEL_NDIRS; del_dir++) { - tparam.del_dir = del_dir; + fheap_test_del_dir_t del_dir; /* Deletion direction */ + unsigned id_len; /* Length of heap IDs */ + + /* Test "normal" & "direct" storage of 'huge' & 'tiny' heap IDs */ + for (id_len = 0; id_len < 3; id_len++) { + /* Set the ID length for this test */ + small_cparam.id_len = (uint16_t)id_len; + + /* Print information about each test */ + switch (id_len) { + /* Use "normal" form for 'huge' object's heap IDs */ + case 0: + HDputs("Using 'normal' heap ID format for 'huge' objects"); + break; - /* Test 'huge' object insert & delete */ - nerrors += test_huge_insert_one(fapl, &small_cparam, &tparam); - nerrors += test_huge_insert_two(fapl, &small_cparam, &tparam); - nerrors += test_huge_insert_three(fapl, &small_cparam, &tparam); - nerrors += test_huge_insert_mix(fapl, &small_cparam, &tparam); - nerrors += test_filtered_huge(fapl, &small_cparam, &tparam); - - /* Test 'tiny' object insert & delete */ - nerrors += test_tiny_insert_one(fapl, &small_cparam, &tparam); - nerrors += test_tiny_insert_two(fapl, &small_cparam, &tparam); - nerrors += test_tiny_insert_mix(fapl, &small_cparam, &tparam); - } /* end for */ - } /* end for */ + /* Use "direct" form for 'huge' object's heap IDs */ + case 1: + HDputs("Using 'direct' heap ID format for 'huge' objects"); - /* Reset the "normal" heap ID lengths */ - small_cparam.id_len = 0; - tparam.actual_id_len = HEAP_ID_LEN; + /* Adjust actual length of heap IDs for directly storing 'huge' object's file + * offset & length in heap ID */ + tparam.actual_id_len = 17; /* 1 + 8 (file address size) + 8 (file length size) */ + break; + + /* Use "direct" storage for 'huge' objects and larger IDs for 'tiny' objects */ + case 2: + small_cparam.id_len = 37; + HDputs("Using 'direct' heap ID format for 'huge' objects and larger IDs for " + "'tiny' objects"); + tparam.actual_id_len = 37; + break; + + /* An unknown test? */ + default: + goto error; + } /* end switch */ + + /* Try several different methods of deleting objects */ + for (del_dir = FHEAP_DEL_FORWARD; del_dir < FHEAP_DEL_NDIRS; del_dir++) { + tparam.del_dir = del_dir; + + /* Test 'huge' object insert & delete */ + nerrors += test_huge_insert_one(fapl, &small_cparam, &tparam); + nerrors += test_huge_insert_two(fapl, &small_cparam, &tparam); + nerrors += test_huge_insert_three(fapl, &small_cparam, &tparam); + nerrors += test_huge_insert_mix(fapl, &small_cparam, &tparam); + nerrors += test_filtered_huge(fapl, &small_cparam, &tparam); + + /* Test 'tiny' object insert & delete */ + nerrors += test_tiny_insert_one(fapl, &small_cparam, &tparam); + nerrors += test_tiny_insert_two(fapl, &small_cparam, &tparam); + nerrors += test_tiny_insert_mix(fapl, &small_cparam, &tparam); + } /* end for */ + } /* end for */ + + /* Reset the "normal" heap ID lengths */ + small_cparam.id_len = 0; + tparam.actual_id_len = HEAP_ID_LEN; } /* end block */ /* Test I/O filter support */ /* Try several different methods of deleting objects */ { - fheap_test_del_dir_t del_dir; /* Deletion direction */ - - for(del_dir = FHEAP_DEL_FORWARD; del_dir < FHEAP_DEL_NDIRS; del_dir++) { - tparam.del_dir = del_dir; + fheap_test_del_dir_t del_dir; /* Deletion direction */ - /* Controlled tests */ - /* XXX: Re-enable file size checks in these tests, after the file has persistent free space tracking working */ - nerrors += test_filtered_man_root_direct(fapl, &small_cparam, &tparam); - nerrors += test_filtered_man_root_indirect(fapl, &small_cparam, &tparam); - - /* Random tests, with compressed blocks */ - tparam.comp = FHEAP_TEST_COMPRESS; - nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(50*1000*1000) : (hsize_t)(25*1000*1000)), fapl, &small_cparam, &tparam); - nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(50*1000*1000) : (hsize_t)(2*1000*1000)), fapl, &small_cparam, &tparam); + for (del_dir = FHEAP_DEL_FORWARD; del_dir < FHEAP_DEL_NDIRS; del_dir++) { + tparam.del_dir = del_dir; - /* Reset block compression */ - tparam.comp = FHEAP_TEST_NO_COMPRESS; - } /* end for */ - } /* end block */ + /* Controlled tests */ + /* XXX: Re-enable file size checks in these tests, after the file has persistent free + * space tracking working */ + nerrors += test_filtered_man_root_direct(fapl, &small_cparam, &tparam); + nerrors += test_filtered_man_root_indirect(fapl, &small_cparam, &tparam); + + /* Random tests, with compressed blocks */ + tparam.comp = FHEAP_TEST_COMPRESS; + nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(50 * 1000 * 1000) + : (hsize_t)(25 * 1000 * 1000)), + fapl, &small_cparam, &tparam); + nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(50 * 1000 * 1000) + : (hsize_t)(2 * 1000 * 1000)), + fapl, &small_cparam, &tparam); + + /* Reset block compression */ + tparam.comp = FHEAP_TEST_NO_COMPRESS; + } /* end for */ + } /* end block */ /* Random object insertion & deletion */ - if(ExpressMode > 1) + if (ExpressMode > 1) HDprintf("***Express test mode on. Some tests skipped\n"); else { /* Random tests using "small" heap creation parameters */ HDputs("Using 'small' heap creation parameters"); /* (reduce size of tests when re-opening each time) */ - /* XXX: Try to speed things up enough that these tests don't have to be reduced when re-opening */ + /* XXX: Try to speed things up enough that these tests don't have to be reduced when + * re-opening */ tparam.del_dir = FHEAP_DEL_FORWARD; - nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(50*1000*1000)), fapl, &small_cparam, &tparam); - nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(4*1000*1000)), fapl, &small_cparam, &tparam); + nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100 * 1000 * 1000) + : (hsize_t)(50 * 1000 * 1000)), + fapl, &small_cparam, &tparam); + nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100 * 1000 * 1000) + : (hsize_t)(4 * 1000 * 1000)), + fapl, &small_cparam, &tparam); tparam.del_dir = FHEAP_DEL_HEAP; - nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(50*1000*1000)), fapl, &small_cparam, &tparam); - nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(4*1000*1000)), fapl, &small_cparam, &tparam); + nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100 * 1000 * 1000) + : (hsize_t)(50 * 1000 * 1000)), + fapl, &small_cparam, &tparam); + nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100 * 1000 * 1000) + : (hsize_t)(4 * 1000 * 1000)), + fapl, &small_cparam, &tparam); /* Random tests using "large" heap creation parameters */ HDputs("Using 'large' heap creation parameters"); tparam.actual_id_len = LARGE_HEAP_ID_LEN; /* (reduce size of tests when re-opening each time) */ - /* XXX: Try to speed things up enough that these tests don't have to be reduced when re-opening */ + /* XXX: Try to speed things up enough that these tests don't have to be reduced when + * re-opening */ tparam.del_dir = FHEAP_DEL_FORWARD; - nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(50*1000*1000)), fapl, &large_cparam, &tparam); - nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(4*1000*1000)), fapl, &large_cparam, &tparam); + nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100 * 1000 * 1000) + : (hsize_t)(50 * 1000 * 1000)), + fapl, &large_cparam, &tparam); + nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100 * 1000 * 1000) + : (hsize_t)(4 * 1000 * 1000)), + fapl, &large_cparam, &tparam); tparam.del_dir = FHEAP_DEL_HEAP; - nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(50*1000*1000)), fapl, &large_cparam, &tparam); - nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100*1000*1000) : (hsize_t)(4*1000*1000)), fapl, &large_cparam, &tparam); + nerrors += test_random((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100 * 1000 * 1000) + : (hsize_t)(50 * 1000 * 1000)), + fapl, &large_cparam, &tparam); + nerrors += test_random_pow2((curr_test == FHEAP_TEST_NORMAL ? (hsize_t)(100 * 1000 * 1000) + : (hsize_t)(4 * 1000 * 1000)), + fapl, &large_cparam, &tparam); /* Reset the "normal" heap ID length */ tparam.actual_id_len = SMALL_HEAP_ID_LEN; @@ -16809,13 +17025,13 @@ main(void) tparam.comp = FHEAP_TEST_NO_COMPRESS; } /* end for */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) TEST_ERROR } /* end num_pb_fs */ /* Tests that address specific bugs */ tparam.my_fcpl = def_fcpl; - fapl = def_fapl; + fapl = def_fapl; /* Tests that address specific bugs */ nerrors += test_bug1(fapl, &small_cparam, &tparam); @@ -16823,7 +17039,7 @@ main(void) /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if(nerrors) + if (nerrors) goto error; HDputs("All fractal heap tests passed."); @@ -16834,11 +17050,14 @@ main(void) H5MM_xfree(shared_lens_g); H5MM_xfree(shared_offs_g); - if(H5Pclose(def_fcpl) < 0) TEST_ERROR - if(H5Pclose(pb_fapl) < 0) TEST_ERROR + if (H5Pclose(def_fcpl) < 0) + TEST_ERROR + if (H5Pclose(pb_fapl) < 0) + TEST_ERROR /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; /* Clean up file used */ @@ -16848,7 +17067,8 @@ main(void) error: HDputs("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5MM_xfree(shared_wobj_g); H5MM_xfree(shared_robj_g); H5MM_xfree(shared_ids_g); @@ -16858,10 +17078,11 @@ error: H5Pclose(pb_fapl); H5Pclose(def_fcpl); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); return 1; } /* end main() */ - diff --git a/test/file_image.c b/test/file_image.c index bb16e6d..5ce0ff2 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -12,62 +12,60 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: file_image -* -* Test setting file images -* -*************************************************************/ + * + * Test program: file_image + * + * Test setting file images + * + *************************************************************/ #include "h5test.h" #include "H5Fprivate.h" /* required to test property removals */ -#define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0) +#define VERIFY(condition, string) \ + do { \ + if (!(condition)) \ + FAIL_PUTS_ERROR(string) \ + } while (0) /* Values for callback bit field */ -#define MALLOC 0x01 -#define MEMCPY 0x02 -#define REALLOC 0x04 -#define FREE 0x08 -#define UDATA_COPY 0x10 -#define UDATA_FREE 0x20 - -#define RANK 2 -#define DIM0 1024 -#define DIM1 32 +#define MALLOC 0x01 +#define MEMCPY 0x02 +#define REALLOC 0x04 +#define FREE 0x08 +#define UDATA_COPY 0x10 +#define UDATA_FREE 0x20 + +#define RANK 2 +#define DIM0 1024 +#define DIM1 32 #define DSET_NAME "test_dset" #define FAMILY_SIZE (2 * 1024) #define USERBLOCK_SIZE 512 -const char *FILENAME[] = { - "file_image_core_test", - NULL -}; +const char *FILENAME[] = {"file_image_core_test", NULL}; /* need a second file name array, as the first file name array contains * files we don't want to delete on cleanup. */ -const char *FILENAME2[] = { - "sec2_get_file_image_test", - "stdio_get_file_image_test", - "core_get_file_image_test", - "family_get_file_image_test", - "multi_get_file_image_test", - "split_get_file_image_test", - "get_file_image_error_rejection_test", - NULL -}; +const char *FILENAME2[] = {"sec2_get_file_image_test", + "stdio_get_file_image_test", + "core_get_file_image_test", + "family_get_file_image_test", + "multi_get_file_image_test", + "split_get_file_image_test", + "get_file_image_error_rejection_test", + NULL}; typedef struct { - unsigned char used_callbacks; /* Bitfield for tracking callbacks */ - H5FD_file_image_op_t malloc_src; /* Source of file image callbacks */ + unsigned char used_callbacks; /* Bitfield for tracking callbacks */ + H5FD_file_image_op_t malloc_src; /* Source of file image callbacks */ H5FD_file_image_op_t memcpy_src; H5FD_file_image_op_t realloc_src; H5FD_file_image_op_t free_src; } udata_t; - /****************************************************************************** * Function: test_properties * @@ -85,16 +83,16 @@ typedef struct { static int test_properties(void) { - hid_t fapl_1 = -1; - hid_t fapl_2 = -1; - char *buffer = 0; - int count = 10; - void *temp = 0; - char *temp2 = 0; - int i; - size_t size; - size_t temp_size; - int retval = 1; + hid_t fapl_1 = -1; + hid_t fapl_2 = -1; + char * buffer = 0; + int count = 10; + void * temp = 0; + char * temp2 = 0; + int i; + size_t size; + size_t temp_size; + int retval = 1; TESTING("File image property list functions"); @@ -104,27 +102,31 @@ test_properties(void) * property list functions. In the file driver tests further down, this will * not be the case. */ - size = (size_t)count * sizeof(char); + size = (size_t)count * sizeof(char); buffer = (char *)HDmalloc(size); - for(i = 0; i < count - 1; i++) + for (i = 0; i < count - 1; i++) buffer[i] = (char)(65 + i); buffer[count - 1] = '\0'; /* Create fapl */ - if((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR + if ((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR /* Get file image stuff */ - if(H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) + FAIL_STACK_ERROR /* Check default values */ VERIFY(temp == NULL, "Default pointer is wrong"); VERIFY(temp_size == 0, "Default size is wrong"); /* Set file image stuff */ - if(H5Pset_file_image(fapl_1, (void *)buffer, size) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image(fapl_1, (void *)buffer, size) < 0) + FAIL_STACK_ERROR /* Get the same */ - if(H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_1, (void **)&temp, &temp_size) < 0) + FAIL_STACK_ERROR /* Check that sizes are the same, and that the buffers are identical but separate */ VERIFY(temp != NULL, "temp is null!"); @@ -133,36 +135,39 @@ test_properties(void) VERIFY(0 == HDmemcmp(temp, buffer, size), "Buffers contain different data"); /* Copy the fapl */ - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Get values from the new fapl */ - if(H5Pget_file_image(fapl_2, (void **)&temp2, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_2, (void **)&temp2, &temp_size) < 0) + FAIL_STACK_ERROR /* Check that sizes are the same, and that the buffers are identical but separate */ - VERIFY(temp_size == size,"Sizes of buffers don't match"); - VERIFY(temp2 != NULL,"Recieved buffer not set"); + VERIFY(temp_size == size, "Sizes of buffers don't match"); + VERIFY(temp2 != NULL, "Recieved buffer not set"); VERIFY(temp2 != buffer, "Retrieved buffer is the same as original"); VERIFY(temp2 != temp, "Retrieved buffer is the same as previously retrieved buffer"); - VERIFY(0 == HDmemcmp(temp2, buffer, size),"Buffers contain different data"); + VERIFY(0 == HDmemcmp(temp2, buffer, size), "Buffers contain different data"); retval = 0; error: /* Close everything */ - if(H5Pclose(fapl_1) < 0) retval = 1; - if(H5Pclose(fapl_2) < 0) retval = 1; + if (H5Pclose(fapl_1) < 0) + retval = 1; + if (H5Pclose(fapl_2) < 0) + retval = 1; HDfree(buffer); H5free_memory(temp); H5free_memory(temp2); - if(retval == 0) + if (retval == 0) PASSED(); return retval; } /* end test_properties() */ - /****************************************************************************** * Function: malloc_cb * @@ -185,7 +190,6 @@ malloc_cb(size_t size, H5FD_file_image_op_t op, void *udata) return HDmalloc(size); } - /****************************************************************************** * Function: memcpy_cb * @@ -208,7 +212,6 @@ memcpy_cb(void *dest, const void *src, size_t size, H5FD_file_image_op_t op, voi return HDmemcpy(dest, src, size); } - /****************************************************************************** * Function: realloc_cb * @@ -228,10 +231,9 @@ realloc_cb(void *ptr, size_t size, H5FD_file_image_op_t op, void *udata) u->used_callbacks |= REALLOC; u->realloc_src = op; - return HDrealloc(ptr,size); + return HDrealloc(ptr, size); } - /****************************************************************************** * Function: free_cb * @@ -250,10 +252,9 @@ free_cb(void *ptr, H5FD_file_image_op_t op, void *udata) u->used_callbacks |= FREE; u->free_src = op; HDfree(ptr); - return(SUCCEED); + return (SUCCEED); } - /****************************************************************************** * Function: udata_copy_cb * @@ -277,7 +278,6 @@ udata_copy_cb(void *udata) return udata; } - /****************************************************************************** * Function: udata_free_cb * @@ -298,10 +298,9 @@ udata_free_cb(void *udata) udata_t *u = (udata_t *)udata; u->used_callbacks |= UDATA_FREE; - return(SUCCEED); + return (SUCCEED); } - /****************************************************************************** * Function: reset_udata * @@ -320,7 +319,6 @@ reset_udata(udata_t *u) u->malloc_src = u->memcpy_src = u->realloc_src = u->free_src = H5FD_FILE_IMAGE_OP_NO_OP; } - /****************************************************************************** * Function: test_callbacks * @@ -334,19 +332,19 @@ reset_udata(udata_t *u) static int test_callbacks(void) { - H5FD_file_image_callbacks_t real_callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb, - &free_cb, &udata_copy_cb, &udata_free_cb, NULL}; + H5FD_file_image_callbacks_t real_callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb, &free_cb, + &udata_copy_cb, &udata_free_cb, NULL}; H5FD_file_image_callbacks_t null_callbacks = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; H5FD_file_image_callbacks_t callbacks; - hid_t fapl_1; - hid_t fapl_2; - udata_t *udata; - char *file_image; - char *temp_file_image; - int count = 10; - int i; - size_t size; - size_t temp_size; + hid_t fapl_1; + hid_t fapl_2; + udata_t * udata; + char * file_image; + char * temp_file_image; + int count = 10; + int i; + size_t size; + size_t temp_size; TESTING("Callback use in property list operations"); @@ -358,18 +356,20 @@ test_callbacks(void) real_callbacks.udata = (void *)udata; /* Allocate and initialize file image buffer */ - size = (size_t)count * sizeof(char); + size = (size_t)count * sizeof(char); file_image = (char *)HDmalloc(size); - for(i = 0; i < count - 1; i++) + for (i = 0; i < count - 1; i++) file_image[i] = (char)(65 + i); file_image[count - 1] = '\0'; /* Create fapl */ - if((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR + if ((fapl_1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR /* Get file image stuff */ callbacks = real_callbacks; - if(H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) + FAIL_STACK_ERROR /* Check default values */ VERIFY(callbacks.image_malloc == NULL, "Default malloc callback is wrong"); @@ -380,14 +380,15 @@ test_callbacks(void) VERIFY(callbacks.udata_free == NULL, "Default udata free callback is wrong"); VERIFY(callbacks.udata == NULL, "Default udata is wrong"); - /* Set file image callbacks */ callbacks = real_callbacks; - if(H5Pset_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image_callbacks(fapl_1, &callbacks) < 0) + FAIL_STACK_ERROR /* Get file image callbacks */ callbacks = null_callbacks; - if(H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image_callbacks(fapl_1, &callbacks) < 0) + FAIL_STACK_ERROR /* Verify values */ VERIFY(callbacks.image_malloc == &malloc_cb, "malloc callback was not set or retrieved properly"); @@ -398,50 +399,59 @@ test_callbacks(void) VERIFY(callbacks.udata_free == &udata_free_cb, "udata free callback was not set or retrieved properly"); VERIFY(callbacks.udata == udata, "udata was not set or retrieved properly"); - /* * Check callbacks in internal function without a previously set file image */ /* Copy fapl */ reset_udata(udata); - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Verify that the property's copy callback used the correct image callbacks */ VERIFY(udata->used_callbacks == (UDATA_COPY), "Copying a fapl with no image used incorrect callbacks"); /* Close fapl */ reset_udata(udata); - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_2) < 0) + FAIL_STACK_ERROR /* Verify that the udata free callback was used */ VERIFY(udata->used_callbacks == (UDATA_FREE), "Closing a fapl with no image used incorrect callbacks"); /* Copy again */ - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Remove property from fapl */ reset_udata(udata); - if(H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) FAIL_STACK_ERROR + if (H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) + FAIL_STACK_ERROR /* Verify that the property's delete callback was called using the correct image callbacks */ - VERIFY(udata->used_callbacks == (UDATA_FREE), "Removing a property from a fapl with no image used incorrect callbacks"); + VERIFY(udata->used_callbacks == (UDATA_FREE), + "Removing a property from a fapl with no image used incorrect callbacks"); /* Close it again */ - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_2) < 0) + FAIL_STACK_ERROR /* Get file image */ reset_udata(udata); - if(H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) + FAIL_STACK_ERROR /* Verify that the correct callbacks were used */ - VERIFY(udata->used_callbacks == 0, "attempting to retrieve the image from a fapl without an image has an unexpected callback"); + VERIFY(udata->used_callbacks == 0, + "attempting to retrieve the image from a fapl without an image has an unexpected callback"); /* Set file image */ reset_udata(udata); - if(H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) + FAIL_STACK_ERROR - VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), "Setting a file image (first time) used incorrect callbacks"); + VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), + "Setting a file image (first time) used incorrect callbacks"); /* * Check callbacks in internal functions with a previously set file image @@ -449,55 +459,68 @@ test_callbacks(void) /* Copy fapl */ reset_udata(udata); - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Verify that the property's copy callback used the correct image callbacks */ - VERIFY(udata->used_callbacks == (MALLOC | MEMCPY | UDATA_COPY), "Copying a fapl with an image used incorrect callbacks"); + VERIFY(udata->used_callbacks == (MALLOC | MEMCPY | UDATA_COPY), + "Copying a fapl with an image used incorrect callbacks"); VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, "malloc callback has wrong source"); VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, "memcpy callback has wrong source"); /* Close fapl */ reset_udata(udata); - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_2) < 0) + FAIL_STACK_ERROR /* Verify that the udata free callback was used */ - VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), "Closing a fapl with an image used incorrect callbacks"); + VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), + "Closing a fapl with an image used incorrect callbacks"); VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, "free callback has wrong source"); /* Copy again */ - if((fapl_2 = H5Pcopy(fapl_1)) < 0) FAIL_STACK_ERROR + if ((fapl_2 = H5Pcopy(fapl_1)) < 0) + FAIL_STACK_ERROR /* Remove property from fapl */ reset_udata(udata); - if(H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) FAIL_STACK_ERROR + if (H5Premove(fapl_2, H5F_ACS_FILE_IMAGE_INFO_NAME) < 0) + FAIL_STACK_ERROR /* Verify that the property's delete callback was called using the correct image callbacks */ - VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), "Removing a property from a fapl with an image used incorrect callbacks"); + VERIFY(udata->used_callbacks == (FREE | UDATA_FREE), + "Removing a property from a fapl with an image used incorrect callbacks"); VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, "free callback has wrong source"); /* Close it again */ - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_2) < 0) + FAIL_STACK_ERROR /* Get file image */ reset_udata(udata); - if(H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) FAIL_STACK_ERROR + if (H5Pget_file_image(fapl_1, (void **)&temp_file_image, &temp_size) < 0) + FAIL_STACK_ERROR /* Verify that the correct callbacks were used */ - VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), "attempting to retrieve the image from a fapl with an image has an unexpected callback"); + VERIFY(udata->used_callbacks == (MALLOC | MEMCPY), + "attempting to retrieve the image from a fapl with an image has an unexpected callback"); VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, "malloc callback has wrong source"); VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, "memcpy callback has wrong source"); /* Set file image */ reset_udata(udata); - if(H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image(fapl_1, (void *)file_image, size) < 0) + FAIL_STACK_ERROR - VERIFY(udata->used_callbacks == (FREE | MALLOC | MEMCPY), "Setting a file image (second time) used incorrect callbacks"); + VERIFY(udata->used_callbacks == (FREE | MALLOC | MEMCPY), + "Setting a file image (second time) used incorrect callbacks"); VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "malloc callback has wrong source"); VERIFY(udata->memcpy_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "memcpy callback has wrong source"); VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, "freec callback has wrong source"); /* Close stuff */ - if(H5Pclose(fapl_1) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_1) < 0) + FAIL_STACK_ERROR HDfree(file_image); HDfree(temp_file_image); HDfree(udata); @@ -509,7 +532,6 @@ error: return 1; } /* test_callbacks() */ - /****************************************************************************** * Function: test_core * @@ -524,22 +546,22 @@ error: static int test_core(void) { - hid_t fapl; - hid_t file; - hid_t dset; - hid_t space; - udata_t *udata; - unsigned char *file_image; - char filename[1024]; - char copied_filename[1024]; - const char *tmp = NULL; - size_t size; - hsize_t dims[2]; - int fd; - h5_stat_t sb; - herr_t ret; - H5FD_file_image_callbacks_t callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb, - &free_cb, &udata_copy_cb, &udata_free_cb, NULL}; + hid_t fapl; + hid_t file; + hid_t dset; + hid_t space; + udata_t * udata; + unsigned char * file_image; + char filename[1024]; + char copied_filename[1024]; + const char * tmp = NULL; + size_t size; + hsize_t dims[2]; + int fd; + h5_stat_t sb; + herr_t ret; + H5FD_file_image_callbacks_t callbacks = {&malloc_cb, &memcpy_cb, &realloc_cb, &free_cb, + &udata_copy_cb, &udata_free_cb, NULL}; TESTING("Initial file image and callbacks in Core VFD"); @@ -579,16 +601,18 @@ test_core(void) reset_udata(udata); file = H5Fopen(copied_filename, H5F_ACC_RDONLY, fapl); VERIFY(file >= 0, "H5Fopen failed"); - VERIFY((udata->used_callbacks == MALLOC) || - (udata->used_callbacks == (MALLOC | UDATA_COPY | UDATA_FREE)), "opening a core file used the wrong callbacks"); - VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_FILE_OPEN, "Malloc callback came from wrong sourc in core open"); + VERIFY((udata->used_callbacks == MALLOC) || (udata->used_callbacks == (MALLOC | UDATA_COPY | UDATA_FREE)), + "opening a core file used the wrong callbacks"); + VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_FILE_OPEN, + "Malloc callback came from wrong sourc in core open"); /* Close file */ reset_udata(udata); ret = H5Fclose(file); VERIFY(ret >= 0, "H5Fclose failed"); VERIFY(udata->used_callbacks == FREE, "Closing a core file used the wrong callbacks"); - VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close"); + VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, + "Free callback came from wrong sourc in core close"); /* Reopen file */ file = H5Fopen(copied_filename, H5F_ACC_RDWR, fapl); @@ -597,19 +621,20 @@ test_core(void) /* Set up a new dset */ dims[0] = DIM0; dims[1] = DIM1; - space = H5Screate_simple(RANK, dims, dims); + space = H5Screate_simple(RANK, dims, dims); VERIFY(space >= 0, "H5Screate failed"); /* Create new dset, invoking H5FD_core_write */ reset_udata(udata); dset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset >=0, "H5Dcreate failed"); + VERIFY(dset >= 0, "H5Dcreate failed"); /* Flush the write and check the realloc callback */ ret = H5Fflush(file, H5F_SCOPE_LOCAL); VERIFY(ret >= 0, "H5Fflush failed"); VERIFY(udata->used_callbacks == (REALLOC), "core write used the wrong callbacks"); - VERIFY(udata->realloc_src == H5FD_FILE_IMAGE_OP_FILE_RESIZE, "Realloc callback came from wrong source in core write"); + VERIFY(udata->realloc_src == H5FD_FILE_IMAGE_OP_FILE_RESIZE, + "Realloc callback came from wrong source in core write"); /* Close dset and space */ ret = H5Dclose(dset); @@ -622,26 +647,30 @@ test_core(void) ret = H5Fclose(file); VERIFY(ret >= 0, "H5Fclose failed"); VERIFY(udata->used_callbacks == (FREE), "Closing a core file used the wrong callbacks"); - VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, "Free callback came from wrong sourc in core close"); + VERIFY(udata->free_src == H5FD_FILE_IMAGE_OP_FILE_CLOSE, + "Free callback came from wrong sourc in core close"); /* Create file image buffer */ fd = HDopen(copied_filename, O_RDONLY); VERIFY(fd > 0, "open failed"); ret = HDfstat(fd, &sb); VERIFY(ret == 0, "fstat failed"); - size = (size_t)sb.st_size; + size = (size_t)sb.st_size; file_image = (unsigned char *)HDmalloc(size); - if(HDread(fd, file_image, size) < 0) + if (HDread(fd, file_image, size) < 0) FAIL_PUTS_ERROR("unable to read from file descriptor"); ret = HDclose(fd); VERIFY(ret == 0, "close failed"); /* Set file image in plist */ - if(H5Pset_file_image(fapl, file_image, size) < 0) FAIL_STACK_ERROR + if (H5Pset_file_image(fapl, file_image, size) < 0) + FAIL_STACK_ERROR /* Test open with file image */ - if((file = H5Fopen("dne.h5", H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if ((file = H5Fopen("dne.h5", H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Release resources */ h5_clean_files(FILENAME, fapl); @@ -657,7 +686,6 @@ error: return 1; } /* end test_core() */ - /****************************************************************************** * Function: test_get_file_image * @@ -678,37 +706,34 @@ error: * 'member_file_name' in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static int -test_get_file_image(const char * test_banner, - const int file_name_num, - hid_t fapl, - hbool_t user) +test_get_file_image(const char *test_banner, const int file_name_num, hid_t fapl, hbool_t user) { - char file_name[1024] = "\0"; - void * insertion_ptr = NULL; - void * image_ptr = NULL; - void * file_image_ptr = NULL; - hbool_t is_family_file = FALSE; - hbool_t identical; - int data[100]; - int i; - int fd = -1; - int result; - hid_t driver = -1; - hid_t file_id = -1; - hid_t dset_id = -1; - hid_t space_id = -1; - hid_t core_fapl_id = -1; - hid_t core_file_id = -1; - herr_t err; - hsize_t dims[2]; - ssize_t bytes_read; - ssize_t image_size; - ssize_t file_size; + char file_name[1024] = "\0"; + void * insertion_ptr = NULL; + void * image_ptr = NULL; + void * file_image_ptr = NULL; + hbool_t is_family_file = FALSE; + hbool_t identical; + int data[100]; + int i; + int fd = -1; + int result; + hid_t driver = -1; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t space_id = -1; + hid_t core_fapl_id = -1; + hid_t core_file_id = -1; + herr_t err; + hsize_t dims[2]; + ssize_t bytes_read; + ssize_t image_size; + ssize_t file_size; h5_stat_t stat_buf; - hid_t fcpl = -1; - herr_t ret; + hid_t fcpl = -1; + herr_t ret; TESTING("%s", test_banner); @@ -716,18 +741,18 @@ test_get_file_image(const char * test_banner, driver = H5Pget_driver(fapl); VERIFY(driver >= 0, "H5Pget_driver(fapl) failed"); - if(driver == H5FD_FAMILY) + if (driver == H5FD_FAMILY) is_family_file = TRUE; /* setup the file name */ h5_fixname(FILENAME2[file_name_num], fapl, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); fcpl = H5Pcreate(H5P_FILE_CREATE); VERIFY(fcpl >= 0, "H5Pcreate"); - if(user) { + if (user) { ret = H5Pset_userblock(fcpl, (hsize_t)USERBLOCK_SIZE); - VERIFY(ret >=0, "H5Pset_userblock"); + VERIFY(ret >= 0, "H5Pset_userblock"); } /* create the file */ @@ -735,15 +760,14 @@ test_get_file_image(const char * test_banner, VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) @@ -777,17 +801,17 @@ test_get_file_image(const char * test_banner, err = H5Fclose(file_id); VERIFY(err == SUCCEED, "H5Fclose(file_id) failed."); - if(is_family_file) { - char member_file_name[1024]; + if (is_family_file) { + char member_file_name[1024]; ssize_t bytes_to_read; ssize_t member_size; ssize_t size_remaining; - /* + /* * Modifications need to be made to accommodate userblock when * H5Fget_file_image() works for family driver */ - i = 0; + i = 0; file_size = 0; do { @@ -801,7 +825,7 @@ test_get_file_image(const char * test_banner, i++; file_size += member_size; - } while(member_size > 0); + } while (member_size > 0); /* Since we use the eoa to calculate the image size, the file size * may be larger. This is OK, as long as (in this specialized instance) @@ -814,10 +838,10 @@ test_get_file_image(const char * test_banner, VERIFY(file_image_ptr != NULL, "HDmalloc(2f) failed."); size_remaining = image_size; - insertion_ptr = file_image_ptr; - i = 0; + insertion_ptr = file_image_ptr; + i = 0; - while(size_remaining > 0) { + while (size_remaining > 0) { /* construct the member file name */ HDsnprintf(member_file_name, 1024, file_name, i); @@ -825,11 +849,12 @@ test_get_file_image(const char * test_banner, fd = HDopen(member_file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); - if(size_remaining >= FAMILY_SIZE ){ - bytes_to_read = FAMILY_SIZE; + if (size_remaining >= FAMILY_SIZE) { + bytes_to_read = FAMILY_SIZE; size_remaining -= FAMILY_SIZE; - } else { - bytes_to_read = size_remaining; + } + else { + bytes_to_read = size_remaining; size_remaining = 0; } @@ -845,7 +870,8 @@ test_get_file_image(const char * test_banner, result = HDclose(fd); VERIFY(result == 0, "HDclose() failed."); } - } else { + } + else { /* get the size of the test file */ result = HDstat(file_name, &stat_buf); VERIFY(result == 0, "HDstat() failed."); @@ -855,12 +881,12 @@ test_get_file_image(const char * test_banner, * the remainder of the file is all '\0's. */ file_size = (ssize_t)stat_buf.st_size; - if(user) { + if (user) { VERIFY(file_size > USERBLOCK_SIZE, "file size !> userblock size."); file_size -= USERBLOCK_SIZE; } - /* with latest mods to truncate call in core file drive, + /* with latest mods to truncate call in core file drive, * file size should match image size */ VERIFY(file_size == image_size, "file size != image size."); @@ -873,7 +899,7 @@ test_get_file_image(const char * test_banner, fd = HDopen(file_name, O_RDONLY); VERIFY(fd >= 0, "HDopen() failed."); - if(user) { + if (user) { HDoff_t off; /* Position at userblock */ @@ -892,20 +918,19 @@ test_get_file_image(const char * test_banner, /* verify that the file and the image contain the same data */ identical = TRUE; - i = 0; - while((i < (int)image_size) && identical) { - if(((char *)image_ptr)[i] != ((char *)file_image_ptr)[i]) + i = 0; + while ((i < (int)image_size) && identical) { + if (((char *)image_ptr)[i] != ((char *)file_image_ptr)[i]) identical = FALSE; i++; } VERIFY(identical, "file and image differ."); - /* finally, verify that we can use the core file driver to open the image */ /* create fapl for core file driver */ core_fapl_id = H5Pcreate(H5P_FILE_ACCESS); - VERIFY(core_fapl_id >=0, "H5Pcreate() failed"); + VERIFY(core_fapl_id >= 0, "H5Pcreate() failed"); /* setup core_fapl_id to use the core file driver */ err = H5Pset_fapl_core(core_fapl_id, (size_t)(64 * 1024), FALSE); @@ -931,11 +956,11 @@ test_get_file_image(const char * test_banner, h5_clean_files(FILENAME2, fapl); /* discard the image buffer if it exists */ - if(image_ptr != NULL) + if (image_ptr != NULL) HDfree(image_ptr); /* discard the image buffer if it exists */ - if(file_image_ptr != NULL) + if (file_image_ptr != NULL) HDfree(file_image_ptr); PASSED(); @@ -945,9 +970,8 @@ test_get_file_image(const char * test_banner, error: return 1; } /* end test_get_file_image() */ -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - /****************************************************************************** * Function: test_get_file_image_error_rejection * @@ -964,24 +988,23 @@ H5_GCC_DIAG_ON(format-nonliteral) static int test_get_file_image_error_rejection(void) { - const char *memb_name[H5FD_MEM_NTYPES]; - char file_name[1024] = "\0"; - void * image_ptr = NULL; - int data[100]; - int i; - hid_t fapl_id = -1; - hid_t file_id = -1; - hid_t dset_id = -1; - hid_t space_id = -1; - herr_t err; - hsize_t dims[2]; - ssize_t bytes_read; - ssize_t image_size; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - + const char *memb_name[H5FD_MEM_NTYPES]; + char file_name[1024] = "\0"; + void * image_ptr = NULL; + int data[100]; + int i; + hid_t fapl_id = -1; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t space_id = -1; + herr_t err; + hsize_t dims[2]; + ssize_t bytes_read; + ssize_t image_size; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; TESTING("H5Fget_file_image() error rejection"); @@ -997,7 +1020,6 @@ test_get_file_image_error_rejection(void) * good id, but not a file id */ - /* setup fapl -- driver type doesn't matter much, so make it stdio */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); VERIFY(fapl_id >= 0, "H5Pcreate(1) failed"); @@ -1007,28 +1029,26 @@ test_get_file_image_error_rejection(void) /* setup the file name */ h5_fixname(FILENAME2[6], fapl_id, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); /* create the file */ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) data[i] = i; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)data); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data); VERIFY(err >= 0, "H5Dwrite() failed."); /* Flush the file */ @@ -1044,25 +1064,31 @@ test_get_file_image_error_rejection(void) VERIFY(image_ptr != NULL, "HDmalloc(1) failed."); /* load the image of the file into the buffer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { bytes_read = H5Fget_file_image(file_id, image_ptr, (size_t)(image_size - 1)); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(bytes_read < 0, "H5Fget_file_image(2 -- test 1) succeeded."); /* Call H5Fget_file_image() with good buffer and buffer size, * but non-existant file_id. Should fail. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { bytes_read = H5Fget_file_image((hid_t)0, image_ptr, (size_t)(image_size)); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(bytes_read < 0, "H5Fget_file_image(3 -- test 1) succeeded."); /* Call H5Fget_file_image() with good buffer and buffer size, * but a file_id of the wrong type. Should fail. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { bytes_read = H5Fget_file_image(dset_id, image_ptr, (size_t)(image_size)); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(bytes_read < 0, "H5Fget_file_image(4 -- test 1) succeeded."); /* Close dset and space */ @@ -1079,7 +1105,7 @@ test_get_file_image_error_rejection(void) h5_clean_files(FILENAME2, fapl_id); /* discard the image buffer if it exists */ - if(image_ptr != NULL) + if (image_ptr != NULL) HDfree(image_ptr); /************************** Test #2 **********************************/ @@ -1088,7 +1114,7 @@ test_get_file_image_error_rejection(void) */ /* setup parameters for multi file driver */ - for(mt = (H5FD_mem_t)0; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + for (mt = (H5FD_mem_t)0; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { memb_addr[mt] = HADDR_UNDEF; memb_fapl[mt] = H5P_DEFAULT; memb_map[mt] = H5FD_MEM_DRAW; @@ -1105,10 +1131,10 @@ test_get_file_image_error_rejection(void) memb_name[H5FD_MEM_BTREE] = "%s-b.h5"; memb_addr[H5FD_MEM_BTREE] = memb_addr[H5FD_MEM_SUPER] + TYPE_SLICE; - memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; - memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; - memb_name[H5FD_MEM_DRAW] = "%s-r.h5"; - memb_addr[H5FD_MEM_DRAW] = memb_addr[H5FD_MEM_BTREE] + TYPE_SLICE; + memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; + memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; + memb_name[H5FD_MEM_DRAW] = "%s-r.h5"; + memb_addr[H5FD_MEM_DRAW] = memb_addr[H5FD_MEM_BTREE] + TYPE_SLICE; memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; memb_fapl[H5FD_MEM_GHEAP] = H5P_DEFAULT; @@ -1120,44 +1146,41 @@ test_get_file_image_error_rejection(void) memb_name[H5FD_MEM_LHEAP] = "%s-l.h5"; memb_addr[H5FD_MEM_LHEAP] = memb_addr[H5FD_MEM_GHEAP] + TYPE_SLICE; - memb_map[H5FD_MEM_OHDR] = H5FD_MEM_OHDR; - memb_fapl[H5FD_MEM_OHDR] = H5P_DEFAULT; - memb_name[H5FD_MEM_OHDR] = "%s-o.h5"; - memb_addr[H5FD_MEM_OHDR] = memb_addr[H5FD_MEM_LHEAP] + TYPE_SLICE; + memb_map[H5FD_MEM_OHDR] = H5FD_MEM_OHDR; + memb_fapl[H5FD_MEM_OHDR] = H5P_DEFAULT; + memb_name[H5FD_MEM_OHDR] = "%s-o.h5"; + memb_addr[H5FD_MEM_OHDR] = memb_addr[H5FD_MEM_LHEAP] + TYPE_SLICE; /* setup fapl */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); VERIFY(fapl_id >= 0, "H5Pcreate(2) failed"); /* setup the fapl for the multi file driver */ - err = H5Pset_fapl_multi(fapl_id, memb_map, memb_fapl, memb_name, - memb_addr, FALSE); + err = H5Pset_fapl_multi(fapl_id, memb_map, memb_fapl, memb_name, memb_addr, FALSE); VERIFY(err >= 0, "H5Pset_fapl_multi failed"); /* setup the file name */ h5_fixname(FILENAME2[4], fapl_id, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); /* create the file */ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) data[i] = i; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)data); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data); VERIFY(err >= 0, "H5Dwrite() failed."); /* Flush the file */ @@ -1165,9 +1188,11 @@ test_get_file_image_error_rejection(void) VERIFY(err >= 0, "H5Fflush failed"); /* attempt to get the size of the file -- should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { image_size = H5Fget_file_image(file_id, NULL, (size_t)0); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(image_size == -1, "H5Fget_file_image(5) succeeded."); /* Close dset and space */ @@ -1198,28 +1223,26 @@ test_get_file_image_error_rejection(void) /* setup the file name */ h5_fixname(FILENAME2[5], fapl_id, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); /* create the file */ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) data[i] = i; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)data); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data); VERIFY(err >= 0, "H5Dwrite() failed."); /* Flush the file */ @@ -1227,9 +1250,11 @@ test_get_file_image_error_rejection(void) VERIFY(err >= 0, "H5Fflush failed"); /* attempt to get the size of the file -- should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { image_size = H5Fget_file_image(file_id, NULL, (size_t)0); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(image_size == -1, "H5Fget_file_image(6) succeeded."); /* Close dset and space */ @@ -1258,28 +1283,26 @@ test_get_file_image_error_rejection(void) VERIFY(err >= 0, "H5Pset_fapl_family failed"); h5_fixname(FILENAME2[3], fapl_id, file_name, sizeof(file_name)); - VERIFY(HDstrlen(file_name)>0, "h5_fixname failed"); + VERIFY(HDstrlen(file_name) > 0, "h5_fixname failed"); /* create the file */ file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VERIFY(file_id >= 0, "H5Fcreate() failed."); /* Set up data space for new new data set */ - dims[0] = 10; - dims[1] = 10; + dims[0] = 10; + dims[1] = 10; space_id = H5Screate_simple(2, dims, dims); VERIFY(space_id >= 0, "H5Screate() failed"); /* Create a dataset */ - dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VERIFY(dset_id >=0, "H5Dcreate() failed"); + dset_id = H5Dcreate2(file_id, "dset 0", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VERIFY(dset_id >= 0, "H5Dcreate() failed"); /* write some data to the data set */ for (i = 0; i < 100; i++) data[i] = i; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)data); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)data); VERIFY(err >= 0, "H5Dwrite() failed."); /* Flush the file */ @@ -1287,9 +1310,11 @@ test_get_file_image_error_rejection(void) VERIFY(err >= 0, "H5Fflush failed"); /* attempt to get the size of the file -- should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { image_size = H5Fget_file_image(file_id, NULL, (size_t)0); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(image_size == -1, "H5Fget_file_image(7) succeeded."); /* Close dset and space */ @@ -1320,8 +1345,8 @@ error: int main(void) { - int errors = 0; - hid_t fapl; + int errors = 0; + hid_t fapl; unsigned user; h5_reset(); @@ -1333,33 +1358,30 @@ main(void) errors += test_core(); /* Perform tests with/without user block */ - for(user = FALSE; user <= TRUE; user++) { - - /* test H5Fget_file_image() with sec2 driver */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - if(H5Pset_fapl_sec2(fapl) < 0) - errors++; - else - errors += test_get_file_image("H5Fget_file_image() with sec2 driver", - 0, fapl, user); - - /* test H5Fget_file_image() with stdio driver */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - if(H5Pset_fapl_stdio(fapl) < 0) - errors++; - else - errors += test_get_file_image("H5Fget_file_image() with stdio driver", - 1, fapl, user); - - /* test H5Fget_file_image() with core driver */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - if(H5Pset_fapl_core(fapl, (size_t)(64 *1024), TRUE) < 0) - errors++; - else - errors += test_get_file_image("H5Fget_file_image() with core driver", - 2, fapl, user); - - } /* end for */ + for (user = FALSE; user <= TRUE; user++) { + + /* test H5Fget_file_image() with sec2 driver */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_sec2(fapl) < 0) + errors++; + else + errors += test_get_file_image("H5Fget_file_image() with sec2 driver", 0, fapl, user); + + /* test H5Fget_file_image() with stdio driver */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_stdio(fapl) < 0) + errors++; + else + errors += test_get_file_image("H5Fget_file_image() with stdio driver", 1, fapl, user); + + /* test H5Fget_file_image() with core driver */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_core(fapl, (size_t)(64 * 1024), TRUE) < 0) + errors++; + else + errors += test_get_file_image("H5Fget_file_image() with core driver", 2, fapl, user); + + } /* end for */ #if 0 /* at present, H5Fget_file_image() rejects files opened with the @@ -1386,13 +1408,11 @@ main(void) /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); - if(errors) { - HDprintf("***** %d File Image TEST%s FAILED! *****\n", - errors, errors > 1 ? "S" : ""); + if (errors) { + HDprintf("***** %d File Image TEST%s FAILED! *****\n", errors, errors > 1 ? "S" : ""); return 1; } HDprintf("All File Image tests passed.\n"); return 0; } - diff --git a/test/filenotclosed.c b/test/filenotclosed.c index 2d050eb..13ce9fd 100644 --- a/test/filenotclosed.c +++ b/test/filenotclosed.c @@ -16,11 +16,10 @@ * application does not close the file. (See HDFFV-10160) */ - #include "h5test.h" -#define FILENAME "filenotclosed" -#define DATASET_NAME "dset" +#define FILENAME "filenotclosed" +#define DATASET_NAME "dset" /*------------------------------------------------------------------------- * Function: catch_signal @@ -33,12 +32,12 @@ * *------------------------------------------------------------------------- */ -static void catch_signal(int H5_ATTR_UNUSED signo) +static void +catch_signal(int H5_ATTR_UNUSED signo) { HDexit(EXIT_FAILURE); } /* catch_signal() */ - /*------------------------------------------------------------------------- * Function: main * @@ -55,22 +54,22 @@ static void catch_signal(int H5_ATTR_UNUSED signo) int main(void) { - hid_t fapl = -1; /* File access property lists */ - hid_t fid = -1; /* File ID */ - hid_t did = -1; /* Dataset ID */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t cur_dim[1] = {5}; /* Current dimension sizes */ - hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dim[1] = {10}; /* Chunk dimension sizes */ - int buf[5] = {1, 2, 3, 4, 5}; /* The data to be written to the dataset */ - char filename[100]; /* File name */ - const char *env_h5_drvr; /* File Driver value from environment */ - hbool_t contig_addr_vfd; /* Contiguous address vfd */ - - /* Get the VFD to use */ + hid_t fapl = -1; /* File access property lists */ + hid_t fid = -1; /* File ID */ + hid_t did = -1; /* Dataset ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t cur_dim[1] = {5}; /* Current dimension sizes */ + hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dim[1] = {10}; /* Chunk dimension sizes */ + int buf[5] = {1, 2, 3, 4, 5}; /* The data to be written to the dataset */ + char filename[100]; /* File name */ + const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t contig_addr_vfd; /* Contiguous address vfd */ + + /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; /* Skip test when using VFDs that has different address spaces for each @@ -79,7 +78,7 @@ main(void) * split/multi driver. Please see HDFFV-10160. */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(!contig_addr_vfd) { + if (!contig_addr_vfd) { SKIPPED(); puts(" Temporary skipped for a spilt/multi driver"); HDexit(EXIT_SUCCESS); @@ -88,51 +87,51 @@ main(void) h5_reset(); /* To exit from the file for SIGABRT signal */ - if(HDsignal(SIGABRT, catch_signal) == SIG_ERR) + if (HDsignal(SIGABRT, catch_signal) == SIG_ERR) TEST_ERROR fapl = h5_fileaccess(); h5_fixname(FILENAME, fapl, filename, sizeof(filename)); /* Set to latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR /* Create the file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create the dcpl and set the chunk size */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, 1, chunk_dim) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dim) < 0) TEST_ERROR /* Create the dataspace */ - if((sid = H5Screate_simple(1, cur_dim, max_dim)) < 0) + if ((sid = H5Screate_simple(1, cur_dim, max_dim)) < 0) TEST_ERROR /* Create the dataset */ - if((did = H5Dcreate2(fid, DATASET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR /* Close the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /* Close the property lists */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR /* The file is not closed. */ diff --git a/test/fillval.c b/test/fillval.c index 72b8dcb..4be9cd7 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -26,18 +26,8 @@ */ /* #define NO_FILLING */ -const char *FILENAME[] = { - "fillval_1", - "fillval_2", - "fillval_3", - "fillval_4", - "fillval_5", - "fillval_6", - "fillval_7", - "fillval_8", - "fillval_9", - NULL -}; +const char *FILENAME[] = {"fillval_1", "fillval_2", "fillval_3", "fillval_4", "fillval_5", + "fillval_6", "fillval_7", "fillval_8", "fillval_9", NULL}; /* Common type for compound datatype operations */ typedef struct { @@ -49,18 +39,17 @@ typedef struct { /* Common type for compound+vl datatype operations */ typedef struct { - int x; - char *a; - char *b; - int y; + int x; + char *a; + char *b; + int y; } comp_vl_datatype; /* The fill_old.h5 is generated from gen_old_fill.c in HDF5 'test' directory * for version 1.4(after 1.4.3). To get this data file, simply compile * gen_old_fill.c with HDF5 library (before v1.5) and run it. */ #define FILE_COMPATIBLE "fill_old.h5" -#define FILE_NAME_RAW "fillval.raw" - +#define FILE_NAME_RAW "fillval.raw" /*------------------------------------------------------------------------- * Function: create_compound_type @@ -78,31 +67,33 @@ typedef struct { * *------------------------------------------------------------------------- */ -static hid_t create_compound_type(void) +static hid_t +create_compound_type(void) { - hid_t ret_value=-1; + hid_t ret_value = -1; - if((ret_value = H5Tcreate(H5T_COMPOUND, sizeof(comp_datatype))) < 0) + if ((ret_value = H5Tcreate(H5T_COMPOUND, sizeof(comp_datatype))) < 0) goto error; - if(H5Tinsert(ret_value, "a", HOFFSET(comp_datatype, a), H5T_NATIVE_FLOAT) < 0) + if (H5Tinsert(ret_value, "a", HOFFSET(comp_datatype, a), H5T_NATIVE_FLOAT) < 0) goto error; - if(H5Tinsert(ret_value, "x", HOFFSET(comp_datatype, x), H5T_NATIVE_INT) < 0) + if (H5Tinsert(ret_value, "x", HOFFSET(comp_datatype, x), H5T_NATIVE_INT) < 0) goto error; - if(H5Tinsert(ret_value, "y", HOFFSET(comp_datatype, y), H5T_NATIVE_DOUBLE) < 0) + if (H5Tinsert(ret_value, "y", HOFFSET(comp_datatype, y), H5T_NATIVE_DOUBLE) < 0) + goto error; + if (H5Tinsert(ret_value, "z", HOFFSET(comp_datatype, z), H5T_NATIVE_CHAR) < 0) goto error; - if(H5Tinsert(ret_value, "z", HOFFSET(comp_datatype, z), H5T_NATIVE_CHAR) < 0) - goto error; return ret_value; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(ret_value); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_compound_vl_type * @@ -120,33 +111,42 @@ error: static hid_t create_compound_vl_type(void) { - hid_t str_id = -1; /* Datatype for VL-string fields */ + hid_t str_id = -1; /* Datatype for VL-string fields */ hid_t ret_value = -1; /* Create a string datatype */ - if((str_id = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR - if(H5Tset_size(str_id, H5T_VARIABLE) < 0) TEST_ERROR - - if((ret_value = H5Tcreate(H5T_COMPOUND, sizeof(comp_vl_datatype))) < 0) TEST_ERROR - if(H5Tinsert(ret_value, "x", HOFFSET(comp_vl_datatype, x), H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(ret_value, "a", HOFFSET(comp_vl_datatype, a), str_id) < 0) TEST_ERROR - if(H5Tinsert(ret_value, "b", HOFFSET(comp_vl_datatype, b), str_id) < 0) TEST_ERROR - if(H5Tinsert(ret_value, "y", HOFFSET(comp_vl_datatype, y), H5T_NATIVE_INT) < 0) TEST_ERROR + if ((str_id = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR + if (H5Tset_size(str_id, H5T_VARIABLE) < 0) + TEST_ERROR + + if ((ret_value = H5Tcreate(H5T_COMPOUND, sizeof(comp_vl_datatype))) < 0) + TEST_ERROR + if (H5Tinsert(ret_value, "x", HOFFSET(comp_vl_datatype, x), H5T_NATIVE_INT) < 0) + TEST_ERROR + if (H5Tinsert(ret_value, "a", HOFFSET(comp_vl_datatype, a), str_id) < 0) + TEST_ERROR + if (H5Tinsert(ret_value, "b", HOFFSET(comp_vl_datatype, b), str_id) < 0) + TEST_ERROR + if (H5Tinsert(ret_value, "y", HOFFSET(comp_vl_datatype, y), H5T_NATIVE_INT) < 0) + TEST_ERROR /* Close string datatype */ - if(H5Tclose(str_id) < 0) TEST_ERROR + if (H5Tclose(str_id) < 0) + TEST_ERROR return ret_value; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(str_id); H5Tclose(ret_value); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end create_compound_vl_type() */ - /*------------------------------------------------------------------------- * Function: test_getset * @@ -167,15 +167,15 @@ error: static int test_getset(void) { - hid_t dcpl=-1; - int fill_i; - hid_t type_ss=-1, type_si=-1; + hid_t dcpl = -1; + int fill_i; + hid_t type_ss = -1, type_si = -1; struct fill_si { - int v1, v2; - } fill_si; + int v1, v2; + } fill_si; struct fill_ss { - short v1, v2; - } fill_ss, fill_ss_rd; + short v1, v2; + } fill_ss, fill_ss_rd; TESTING("property lists"); @@ -183,33 +183,32 @@ test_getset(void) * Create the dataset creation property list and the data types that will * be used during this test. */ - if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if((type_ss=H5Tcreate(H5T_COMPOUND, sizeof fill_ss)) < 0 || - H5Tinsert(type_ss, "v1", HOFFSET(struct fill_ss, v1), - H5T_NATIVE_SHORT) < 0 || - H5Tinsert(type_ss, "v2", HOFFSET(struct fill_ss, v2), - H5T_NATIVE_SHORT) < 0) { - goto error; - } - if((type_si=H5Tcreate(H5T_COMPOUND, sizeof fill_si)) < 0 || - H5Tinsert(type_si, "v1", HOFFSET(struct fill_si, v1), - H5T_NATIVE_INT) < 0 || - H5Tinsert(type_si, "v2", HOFFSET(struct fill_si, v2), - H5T_NATIVE_INT) < 0) { - goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if ((type_ss = H5Tcreate(H5T_COMPOUND, sizeof fill_ss)) < 0 || + H5Tinsert(type_ss, "v1", HOFFSET(struct fill_ss, v1), H5T_NATIVE_SHORT) < 0 || + H5Tinsert(type_ss, "v2", HOFFSET(struct fill_ss, v2), H5T_NATIVE_SHORT) < 0) { + goto error; + } + if ((type_si = H5Tcreate(H5T_COMPOUND, sizeof fill_si)) < 0 || + H5Tinsert(type_si, "v1", HOFFSET(struct fill_si, v1), H5T_NATIVE_INT) < 0 || + H5Tinsert(type_si, "v2", HOFFSET(struct fill_si, v2), H5T_NATIVE_INT) < 0) { + goto error; } /* * Reading the fill value from a dataset creation property list that has * no fill value should result in a failure. */ - H5E_BEGIN_TRY { - H5Pget_fill_value(dcpl, H5T_NATIVE_INT, &fill_i); - } H5E_END_TRY; - if(fill_i != 0) { - H5_FAILED(); - puts(" H5Pget_fill_value() should return default 0"); - goto error; + H5E_BEGIN_TRY + { + H5Pget_fill_value(dcpl, H5T_NATIVE_INT, &fill_i); + } + H5E_END_TRY; + if (fill_i != 0) { + H5_FAILED(); + puts(" H5Pget_fill_value() should return default 0"); + goto error; } /* @@ -217,58 +216,67 @@ test_getset(void) */ fill_ss.v1 = 1111; fill_ss.v2 = 2222; - if(H5Pset_fill_value(dcpl, type_ss, &fill_ss) < 0) goto error; + if (H5Pset_fill_value(dcpl, type_ss, &fill_ss) < 0) + goto error; /* * Get the fill value using the same data type that was used to set it. */ - if(H5Pget_fill_value(dcpl, type_ss, &fill_ss_rd) < 0) goto error; - if(fill_ss.v1!=fill_ss_rd.v1 || fill_ss.v2!=fill_ss_rd.v2) { - H5_FAILED(); - puts(" Failed to get fill value using same data type that was "); - puts(" used to set the fill value."); - goto error; + if (H5Pget_fill_value(dcpl, type_ss, &fill_ss_rd) < 0) + goto error; + if (fill_ss.v1 != fill_ss_rd.v1 || fill_ss.v2 != fill_ss_rd.v2) { + H5_FAILED(); + puts(" Failed to get fill value using same data type that was "); + puts(" used to set the fill value."); + goto error; } /* * Get the fill value using some other data type. */ - if(H5Pget_fill_value(dcpl, type_si, &fill_si) < 0) goto error; - if(fill_ss.v1!=fill_si.v1 || fill_ss.v2!=fill_si.v2) { - H5_FAILED(); - puts(" Failed to get fill value using a data type other than what"); - puts(" was used to set the fill value."); - goto error; + if (H5Pget_fill_value(dcpl, type_si, &fill_si) < 0) + goto error; + if (fill_ss.v1 != fill_si.v1 || fill_ss.v2 != fill_si.v2) { + H5_FAILED(); + puts(" Failed to get fill value using a data type other than what"); + puts(" was used to set the fill value."); + goto error; } /* * Reset the fill value */ - if(H5Pset_fill_value(dcpl, type_si, &fill_si) < 0) goto error; - if(H5Pget_fill_value(dcpl, type_ss, &fill_ss) < 0) goto error; - if(fill_si.v1!=fill_ss.v1 || fill_si.v2!=fill_ss.v2) { - H5_FAILED(); - puts(" Resetting the fill value was unsuccessful."); - goto error; + if (H5Pset_fill_value(dcpl, type_si, &fill_si) < 0) + goto error; + if (H5Pget_fill_value(dcpl, type_ss, &fill_ss) < 0) + goto error; + if (fill_si.v1 != fill_ss.v1 || fill_si.v2 != fill_ss.v2) { + H5_FAILED(); + puts(" Resetting the fill value was unsuccessful."); + goto error; } /* Success */ - if(H5Pclose(dcpl) < 0) goto error; - if(H5Tclose(type_si) < 0) goto error; - if(H5Tclose(type_ss) < 0) goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Tclose(type_si) < 0) + goto error; + if (H5Tclose(type_ss) < 0) + goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Tclose(type_si); - H5Tclose(type_ss); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Pclose(dcpl); + H5Tclose(type_si); + H5Tclose(type_ss); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_getset_vl * @@ -287,82 +295,104 @@ static int test_getset_vl(hid_t fapl) { hsize_t dims[1] = {2}; - hid_t fileid = (-1), spaceid = (-1), dtypeid = (-1), datasetid = (-1), plistid = (-1); - char fill_value[] = "aaaa"; - char orig_fill_value[] = "aaaa"; - char *f1 = fill_value; - char *f2; - char filename[1024]; + hid_t fileid = (-1), spaceid = (-1), dtypeid = (-1), datasetid = (-1), plistid = (-1); + char fill_value[] = "aaaa"; + char orig_fill_value[] = "aaaa"; + char * f1 = fill_value; + char * f2; + char filename[1024]; TESTING("property lists, with variable-length datatype"); /* Create string type. */ - if((dtypeid = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR - if(H5Tset_size(dtypeid, H5T_VARIABLE) < 0) TEST_ERROR + if ((dtypeid = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR + if (H5Tset_size(dtypeid, H5T_VARIABLE) < 0) + TEST_ERROR /* Set up dataset creation property list, with fill value */ - if((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_fill_value(plistid, dtypeid, &f1) < 0) TEST_ERROR + if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_fill_value(plistid, dtypeid, &f1) < 0) + TEST_ERROR /* Modify original fill value string */ fill_value[0] = 'b'; /* Retrieve fill value from property */ - if(H5Pget_fill_value(plistid, dtypeid, &f2) < 0) TEST_ERROR + if (H5Pget_fill_value(plistid, dtypeid, &f2) < 0) + TEST_ERROR /* Verify that the fill value is the original value */ - if(HDstrcmp(f2, orig_fill_value)) TEST_ERROR + if (HDstrcmp(f2, orig_fill_value)) + TEST_ERROR /* Release the fill value retrieved */ HDfree(f2); /* Open file. */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fileid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fileid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Write an dataset of this type. */ - if((spaceid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR - if((datasetid = H5Dcreate2(fileid, "Dataset", dtypeid, spaceid, H5P_DEFAULT, plistid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((spaceid = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + if ((datasetid = H5Dcreate2(fileid, "Dataset", dtypeid, spaceid, H5P_DEFAULT, plistid, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close IDs (except datatype) */ - if(H5Dclose(datasetid) < 0) TEST_ERROR - if(H5Pclose(plistid) < 0) TEST_ERROR - if(H5Sclose(spaceid) < 0) TEST_ERROR - if(H5Fclose(fileid) < 0) TEST_ERROR - + if (H5Dclose(datasetid) < 0) + TEST_ERROR + if (H5Pclose(plistid) < 0) + TEST_ERROR + if (H5Sclose(spaceid) < 0) + TEST_ERROR + if (H5Fclose(fileid) < 0) + TEST_ERROR /* Re-open file, group & dataset */ - if((fileid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((datasetid = H5Dopen2(fileid, "Dataset", H5P_DEFAULT)) < 0) TEST_ERROR + if ((fileid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((datasetid = H5Dopen2(fileid, "Dataset", H5P_DEFAULT)) < 0) + TEST_ERROR /* Get dataset's creation property list */ - if((plistid = H5Dget_create_plist(datasetid)) < 0) TEST_ERROR + if ((plistid = H5Dget_create_plist(datasetid)) < 0) + TEST_ERROR /* Query fill value */ - if(H5Pget_fill_value(plistid, dtypeid, &f2) < 0) TEST_ERROR + if (H5Pget_fill_value(plistid, dtypeid, &f2) < 0) + TEST_ERROR /* Verify that the fill value is the original value */ - if(HDstrcmp(f2, orig_fill_value)) TEST_ERROR + if (HDstrcmp(f2, orig_fill_value)) + TEST_ERROR /* Release the fill value retrieved */ HDfree(f2); /* Close IDs */ - if(H5Dclose(datasetid) < 0) TEST_ERROR - if(H5Fclose(fileid) < 0) TEST_ERROR - if(H5Pclose(plistid) < 0) TEST_ERROR - if(H5Tclose(dtypeid) < 0) TEST_ERROR + if (H5Dclose(datasetid) < 0) + TEST_ERROR + if (H5Fclose(fileid) < 0) + TEST_ERROR + if (H5Pclose(plistid) < 0) + TEST_ERROR + if (H5Tclose(dtypeid) < 0) + TEST_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + } + H5E_END_TRY; return 1; } /* end test_getset_vl() */ - /*------------------------------------------------------------------------- * Function: test_create * @@ -384,346 +414,444 @@ test_getset_vl(hid_t fapl) static int test_create(hid_t fapl, const char *base_name, H5D_layout_t layout) { - hid_t file=-1, space=-1, dcpl=-1, comp_type_id=-1; - hid_t dset1=-1, dset2=-1, dset3=-1, dset4=-1, dset5=-1, - dset6=-1, /* dset7=-1, */ dset8=-1, dset9=-1; - hsize_t cur_size[5] = {2, 8, 8, 4, 2}; - hsize_t ch_size[5] = {1, 1, 1, 4, 1}; - short rd_s, fill_s = 0x1234; - long rd_l, fill_l = 0x4321; - char filename[1024]; - H5D_space_status_t allocation; - H5D_alloc_time_t alloc_time; + hid_t file = -1, space = -1, dcpl = -1, comp_type_id = -1; + hid_t dset1 = -1, dset2 = -1, dset3 = -1, dset4 = -1, dset5 = -1, dset6 = -1, /* dset7=-1, */ dset8 = -1, + dset9 = -1; + hsize_t cur_size[5] = {2, 8, 8, 4, 2}; + hsize_t ch_size[5] = {1, 1, 1, 4, 1}; + short rd_s, fill_s = 0x1234; + long rd_l, fill_l = 0x4321; + char filename[1024]; + H5D_space_status_t allocation; + H5D_alloc_time_t alloc_time; H5D_fill_time_t fill_time; - comp_datatype rd_c, fill_ctype; + comp_datatype rd_c, fill_ctype; - if(H5D_CHUNKED==layout) { - TESTING("chunked dataset creation"); - } else if(H5D_COMPACT==layout) { + if (H5D_CHUNKED == layout) { + TESTING("chunked dataset creation"); + } + else if (H5D_COMPACT == layout) { TESTING("compact dataset creation"); - } else { - TESTING("contiguous dataset creation"); + } + else { + TESTING("contiguous dataset creation"); } /* * Create a file. */ h5_fixname(base_name, fapl, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; - if((space=H5Screate_simple(5, cur_size, cur_size)) < 0) goto error; - if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5D_CHUNKED==layout) { - if(H5Pset_chunk(dcpl, 5, ch_size) < 0) goto error; - } else if(H5D_COMPACT==layout) { - if(H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto error; + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + if ((space = H5Screate_simple(5, cur_size, cur_size)) < 0) + goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5D_CHUNKED == layout) { + if (H5Pset_chunk(dcpl, 5, ch_size) < 0) + goto error; + } + else if (H5D_COMPACT == layout) { + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) + goto error; } /* Create a compound datatype */ - if((comp_type_id = create_compound_type()) < 0) goto error; + if ((comp_type_id = create_compound_type()) < 0) + goto error; /* I. Test cases for late space allocation except compact dataset */ - if(H5D_COMPACT!=layout) { - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) goto error; - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5D_COMPACT != layout) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; /* 1. Compound datatype test */ - if(H5Pget_fill_value(dcpl, comp_type_id, &fill_ctype) < 0) goto error; + if (H5Pget_fill_value(dcpl, comp_type_id, &fill_ctype) < 0) + goto error; fill_ctype.y = 4444; - if(H5Pset_fill_value(dcpl, comp_type_id, &fill_ctype) < 0) goto error; - if((dset9 = H5Dcreate2(file, "dset9", comp_type_id, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if (H5Pset_fill_value(dcpl, comp_type_id, &fill_ctype) < 0) + goto error; + if ((dset9 = H5Dcreate2(file, "dset9", comp_type_id, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - /* The three datasets test three fill - * conversion paths: small to large, large to small, and no conversion. - * They depend on `short' being smaller than `long'. - */ - /* 2. Small to large fill conversion */ + /* The three datasets test three fill + * conversion paths: small to large, large to small, and no conversion. + * They depend on `short' being smaller than `long'. + */ + /* 2. Small to large fill conversion */ #ifndef NO_FILLING - if(H5Pset_fill_value(dcpl, H5T_NATIVE_SHORT, &fill_s) < 0) goto error; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_SHORT, &fill_s) < 0) + goto error; #endif - if((dset1=H5Dcreate2(file, "dset1", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; + if ((dset1 = H5Dcreate2(file, "dset1", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; - /* 3. Large to small fill conversion */ + /* 3. Large to small fill conversion */ #ifndef NO_FILLING - if(H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l) < 0) goto error; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l) < 0) + goto error; #endif - if((dset2=H5Dcreate2(file, "dset2", H5T_NATIVE_SHORT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; + if ((dset2 = H5Dcreate2(file, "dset2", H5T_NATIVE_SHORT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; - /* 4. No conversion */ + /* 4. No conversion */ #ifndef NO_FILLING - if(H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l) < 0) goto error; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l) < 0) + goto error; #endif - if((dset3=H5Dcreate2(file, "dset3", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; + if ((dset3 = H5Dcreate2(file, "dset3", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; /* 5. late space allocation and never write fill value */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; - if((dset4=H5Dcreate2(file, "dset4", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; + if ((dset4 = H5Dcreate2(file, "dset4", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* 6. fill value is undefined while fill write time is H5D_FILL_TIME_ALLOC. * Supposed to fail. */ - if(H5Pset_fill_value(dcpl, (hid_t)-1, NULL) < 0) goto error; - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; - H5E_BEGIN_TRY { - if(H5Dcreate2(file, "dset7", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)!=FAIL) + if (H5Pset_fill_value(dcpl, (hid_t)-1, NULL) < 0) + goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; + H5E_BEGIN_TRY + { + if (H5Dcreate2(file, "dset7", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; } /* II. Test early space allocation cases */ - if(H5Pclose(dcpl) < 0) goto error; - if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5D_CHUNKED==layout) { - if(H5Pset_chunk(dcpl, 5, ch_size) < 0) goto error; - } else if(H5D_COMPACT==layout) { - if(H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5D_CHUNKED == layout) { + if (H5Pset_chunk(dcpl, 5, ch_size) < 0) + goto error; + } + else if (H5D_COMPACT == layout) { + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) + goto error; } - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto error; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto error; /* 1. Compound datatype test */ - if(H5Pget_fill_value(dcpl, comp_type_id, &fill_ctype) < 0) goto error; + if (H5Pget_fill_value(dcpl, comp_type_id, &fill_ctype) < 0) + goto error; fill_ctype.y = 4444; - if(H5Pset_fill_value(dcpl, comp_type_id, &fill_ctype) < 0) goto error; - if((dset8 = H5Dcreate2(file, "dset8", comp_type_id, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if (H5Pset_fill_value(dcpl, comp_type_id, &fill_ctype) < 0) + goto error; + if ((dset8 = H5Dcreate2(file, "dset8", comp_type_id, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - - if(H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l) < 0) goto error; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l) < 0) + goto error; /* 2. Never write fill value */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; - if((dset5 = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; + if ((dset5 = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* 3. Write fill value at space allocation time */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; - if((dset6 = H5Dcreate2(file, "dset6", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; + if ((dset6 = H5Dcreate2(file, "dset6", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; /* 4. fill value is undefined while fill write time is H5D_FILL_TIME_ALLOC. * Supposed to fail. */ - if(H5Pset_fill_value(dcpl, (hid_t)-1, NULL) < 0) goto error; - H5E_BEGIN_TRY { - if(H5Dcreate2(file, "dset7", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)!=FAIL) + if (H5Pset_fill_value(dcpl, (hid_t)-1, NULL) < 0) + goto error; + H5E_BEGIN_TRY + { + if (H5Dcreate2(file, "dset7", H5T_NATIVE_LONG, space, H5P_DEFAULT, dcpl, H5P_DEFAULT) != FAIL) goto error; - } H5E_END_TRY; + } + H5E_END_TRY; /* Close everything */ - if(H5D_COMPACT != layout) { - if(H5Dclose(dset1) < 0) goto error; - if(H5Dclose(dset2) < 0) goto error; - if(H5Dclose(dset3) < 0) goto error; - if(H5Dclose(dset4) < 0) goto error; - if(H5Dclose(dset9) < 0) goto error; - } - if(H5Dclose(dset5) < 0) goto error; - if(H5Dclose(dset6) < 0) goto error; - if(H5Dclose(dset8) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; - if(H5Fclose(file) < 0) goto error; + if (H5D_COMPACT != layout) { + if (H5Dclose(dset1) < 0) + goto error; + if (H5Dclose(dset2) < 0) + goto error; + if (H5Dclose(dset3) < 0) + goto error; + if (H5Dclose(dset4) < 0) + goto error; + if (H5Dclose(dset9) < 0) + goto error; + } + if (H5Dclose(dset5) < 0) + goto error; + if (H5Dclose(dset6) < 0) + goto error; + if (H5Dclose(dset8) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Fclose(file) < 0) + goto error; /* Open the file and get the dataset fill value from each dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - goto error; + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + goto error; /* I. Check cases for late space allocation except compact dataset */ - if(H5D_COMPACT != layout) { + if (H5D_COMPACT != layout) { /* 1. Large to small conversion */ - if((dset1 = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) goto error; - if((dcpl = H5Dget_create_plist(dset1)) < 0) goto error; + if ((dset1 = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl = H5Dget_create_plist(dset1)) < 0) + goto error; #ifndef NO_FILLING - if(H5Pget_fill_value(dcpl, H5T_NATIVE_SHORT, &rd_s) < 0) goto error; - if(rd_s != fill_s) { - H5_FAILED(); - HDprintf(" %d: Got a different fill value than what was set.",__LINE__); - HDprintf(" Got %d, set %d\n", rd_s, fill_s); - goto error; + if (H5Pget_fill_value(dcpl, H5T_NATIVE_SHORT, &rd_s) < 0) + goto error; + if (rd_s != fill_s) { + H5_FAILED(); + HDprintf(" %d: Got a different fill value than what was set.", __LINE__); + HDprintf(" Got %d, set %d\n", rd_s, fill_s); + goto error; } #endif - if(H5Dclose(dset1) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset1) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; /* 2. Small to large conversion */ - if((dset2 = H5Dopen2(file, "dset2", H5P_DEFAULT)) < 0) goto error; - if((dcpl = H5Dget_create_plist(dset2)) < 0) goto error; + if ((dset2 = H5Dopen2(file, "dset2", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl = H5Dget_create_plist(dset2)) < 0) + goto error; #ifndef NO_FILLING - if(H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l) < 0) goto error; - if(rd_l!=fill_l) { - H5_FAILED(); - HDprintf(" %d: Got a different fill value than what was set.",__LINE__); - HDprintf(" Got %ld, set %ld\n", rd_l, fill_l); - goto error; + if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l) < 0) + goto error; + if (rd_l != fill_l) { + H5_FAILED(); + HDprintf(" %d: Got a different fill value than what was set.", __LINE__); + HDprintf(" Got %ld, set %ld\n", rd_l, fill_l); + goto error; } #endif - if(H5Dclose(dset2) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset2) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; /* 3. No conversion */ - if((dset3 = H5Dopen2(file, "dset3", H5P_DEFAULT)) < 0) goto error; - if((dcpl = H5Dget_create_plist(dset3)) < 0) goto error; + if ((dset3 = H5Dopen2(file, "dset3", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl = H5Dget_create_plist(dset3)) < 0) + goto error; #ifndef NO_FILLING - if(H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l) < 0) goto error; - if(rd_l != fill_l) { - H5_FAILED(); - HDprintf(" %d: Got a different fill value than what was set.",__LINE__); - HDprintf(" Got %ld, set %ld\n", rd_l, fill_l); - goto error; + if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l) < 0) + goto error; + if (rd_l != fill_l) { + H5_FAILED(); + HDprintf(" %d: Got a different fill value than what was set.", __LINE__); + HDprintf(" Got %ld, set %ld\n", rd_l, fill_l); + goto error; } #endif - if(H5Pget_alloc_time(dcpl, &alloc_time) < 0) goto error; - if(H5Pget_fill_time(dcpl, &fill_time) < 0) goto error; - if(alloc_time != H5D_ALLOC_TIME_LATE) { + if (H5Pget_alloc_time(dcpl, &alloc_time) < 0) + goto error; + if (H5Pget_fill_time(dcpl, &fill_time) < 0) + goto error; + if (alloc_time != H5D_ALLOC_TIME_LATE) { H5_FAILED(); puts(" Got non-H5D_ALLOC_TIME_LATE space allocation time."); HDprintf(" Got %d\n", alloc_time); } - if(fill_time != H5D_FILL_TIME_ALLOC) { + if (fill_time != H5D_FILL_TIME_ALLOC) { H5_FAILED(); puts(" Got non-H5D_FILL_TIME_ALLOC fill value write time."); HDprintf(" Got %d\n", fill_time); } - if(H5Dclose(dset3) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset3) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; /* 4. late space allocation and never write fill value */ - if((dset4 = H5Dopen2(file, "dset4", H5P_DEFAULT)) < 0) goto error; - if(H5Dget_space_status(dset4, &allocation) < 0) goto error; - if(layout == H5D_CONTIGUOUS && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED) { + if ((dset4 = H5Dopen2(file, "dset4", H5P_DEFAULT)) < 0) + goto error; + if (H5Dget_space_status(dset4, &allocation) < 0) + goto error; + if (layout == H5D_CONTIGUOUS && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED) { H5_FAILED(); puts(" Got allocated space instead of unallocated."); HDprintf(" Got %d\n", allocation); goto error; } - if((dcpl = H5Dget_create_plist(dset4)) < 0) goto error; - if(H5Pget_alloc_time(dcpl, &alloc_time) < 0) goto error; - if(H5Pget_fill_time(dcpl, &fill_time) < 0) goto error; - if(alloc_time != H5D_ALLOC_TIME_LATE) { - H5_FAILED(); - puts(" Got non-H5D_ALLOC_TIME_LATE space allocation time."); - HDprintf(" Got %d\n", alloc_time); + if ((dcpl = H5Dget_create_plist(dset4)) < 0) + goto error; + if (H5Pget_alloc_time(dcpl, &alloc_time) < 0) + goto error; + if (H5Pget_fill_time(dcpl, &fill_time) < 0) + goto error; + if (alloc_time != H5D_ALLOC_TIME_LATE) { + H5_FAILED(); + puts(" Got non-H5D_ALLOC_TIME_LATE space allocation time."); + HDprintf(" Got %d\n", alloc_time); } - if(fill_time != H5D_FILL_TIME_NEVER) { - H5_FAILED(); - puts(" Got non-H5D_FILL_TIME_NEVER fill value write time."); - HDprintf(" Got %d\n", fill_time); + if (fill_time != H5D_FILL_TIME_NEVER) { + H5_FAILED(); + puts(" Got non-H5D_FILL_TIME_NEVER fill value write time."); + HDprintf(" Got %d\n", fill_time); } - if(H5Dclose(dset4) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset4) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; /* 5. Compound datatype test */ - if((dset9 = H5Dopen2(file, "dset9", H5P_DEFAULT)) < 0) goto error; - if((dcpl = H5Dget_create_plist(dset9)) < 0) goto error; - if(H5Pget_fill_value(dcpl, comp_type_id, &rd_c) < 0) goto error; - if(!H5_FLT_ABS_EQUAL(rd_c.a, 0) || !H5_DBL_ABS_EQUAL(rd_c.y, fill_ctype.y) || rd_c.x != 0 || rd_c.z != '\0') { - H5_FAILED(); - puts(" Got wrong fill value"); - HDprintf(" Got rd_c.a=%f, rd_c.y=%f and rd_c.x=%d, rd_c.z=%c\n", - (double)rd_c.a, rd_c.y, rd_c.x, rd_c.z); + if ((dset9 = H5Dopen2(file, "dset9", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl = H5Dget_create_plist(dset9)) < 0) + goto error; + if (H5Pget_fill_value(dcpl, comp_type_id, &rd_c) < 0) + goto error; + if (!H5_FLT_ABS_EQUAL(rd_c.a, 0) || !H5_DBL_ABS_EQUAL(rd_c.y, fill_ctype.y) || rd_c.x != 0 || + rd_c.z != '\0') { + H5_FAILED(); + puts(" Got wrong fill value"); + HDprintf(" Got rd_c.a=%f, rd_c.y=%f and rd_c.x=%d, rd_c.z=%c\n", (double)rd_c.a, rd_c.y, + rd_c.x, rd_c.z); } - if(H5Dclose(dset9) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset9) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; } /* II. Check early space allocation cases */ /* 1. Never write fill value */ - if((dset5 = H5Dopen2(file, "dset5", H5P_DEFAULT)) < 0) goto error; - if((dcpl = H5Dget_create_plist(dset5)) < 0) goto error; - if(H5Dget_space_status(dset5, &allocation) < 0) goto error; - if(layout == H5D_CONTIGUOUS && allocation != H5D_SPACE_STATUS_ALLOCATED) { + if ((dset5 = H5Dopen2(file, "dset5", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl = H5Dget_create_plist(dset5)) < 0) + goto error; + if (H5Dget_space_status(dset5, &allocation) < 0) + goto error; + if (layout == H5D_CONTIGUOUS && allocation != H5D_SPACE_STATUS_ALLOCATED) { H5_FAILED(); - HDprintf(" %d: Got unallocated space instead of allocated.\n",__LINE__); + HDprintf(" %d: Got unallocated space instead of allocated.\n", __LINE__); HDprintf(" Got %d\n", allocation); goto error; } - if(H5Pget_alloc_time(dcpl, &alloc_time) < 0) goto error; - if(alloc_time != H5D_ALLOC_TIME_EARLY) { + if (H5Pget_alloc_time(dcpl, &alloc_time) < 0) + goto error; + if (alloc_time != H5D_ALLOC_TIME_EARLY) { H5_FAILED(); puts(" Got non-H5D_ALLOC_TIME_EARLY space allocation time."); HDprintf(" Got %d\n", alloc_time); } - if(H5Pget_fill_time(dcpl, &fill_time) < 0) goto error; - if(fill_time != H5D_FILL_TIME_NEVER) { + if (H5Pget_fill_time(dcpl, &fill_time) < 0) + goto error; + if (fill_time != H5D_FILL_TIME_NEVER) { H5_FAILED(); puts(" Got non-H5D_FILL_TIME_NEVER fill value write time."); HDprintf(" Got %d\n", fill_time); } - if(H5Dclose(dset5) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset5) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; /* 2. test writing fill value at space allocation time */ - if((dset6 = H5Dopen2(file, "dset6", H5P_DEFAULT)) < 0) goto error; - if((dcpl = H5Dget_create_plist(dset6)) < 0) goto error; - if(H5Dget_space_status(dset6, &allocation) < 0) goto error; - if(layout == H5D_CONTIGUOUS && allocation != H5D_SPACE_STATUS_ALLOCATED) { + if ((dset6 = H5Dopen2(file, "dset6", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl = H5Dget_create_plist(dset6)) < 0) + goto error; + if (H5Dget_space_status(dset6, &allocation) < 0) + goto error; + if (layout == H5D_CONTIGUOUS && allocation != H5D_SPACE_STATUS_ALLOCATED) { H5_FAILED(); - HDprintf(" %d: Got unallocated space instead of allocated.\n",__LINE__); + HDprintf(" %d: Got unallocated space instead of allocated.\n", __LINE__); HDprintf(" Got %d\n", allocation); goto error; } - if(H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l) < 0) goto error; - if(rd_l != fill_l) { + if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l) < 0) + goto error; + if (rd_l != fill_l) { H5_FAILED(); - HDprintf(" %d: Got a different fill value than what was set.",__LINE__); + HDprintf(" %d: Got a different fill value than what was set.", __LINE__); HDprintf(" Got %ld, set %ld\n", rd_l, fill_l); goto error; } - if(H5Pget_alloc_time(dcpl, &alloc_time) < 0) goto error; - if(alloc_time != H5D_ALLOC_TIME_EARLY) { + if (H5Pget_alloc_time(dcpl, &alloc_time) < 0) + goto error; + if (alloc_time != H5D_ALLOC_TIME_EARLY) { H5_FAILED(); puts(" Got non-H5D_ALLOC_TIME_EARLY space allocation time."); HDprintf(" Got %d\n", alloc_time); } - if(H5Pget_fill_time(dcpl, &fill_time) < 0) goto error; - if(fill_time != H5D_FILL_TIME_ALLOC) { + if (H5Pget_fill_time(dcpl, &fill_time) < 0) + goto error; + if (fill_time != H5D_FILL_TIME_ALLOC) { H5_FAILED(); puts(" Got non-H5D_FILL_TIME_ALLOC fill value write time."); HDprintf(" Got %d\n", fill_time); } - if(H5Dclose(dset6) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset6) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; /* 3. Compound datatype test */ - if((dset8 = H5Dopen2(file, "dset8", H5P_DEFAULT)) < 0) goto error; - if((dcpl = H5Dget_create_plist(dset8)) < 0) goto error; - if(H5Pget_fill_value(dcpl, comp_type_id, &rd_c) < 0) goto error; - if(!H5_FLT_ABS_EQUAL(rd_c.a, 0) || !H5_DBL_ABS_EQUAL(rd_c.y, fill_ctype.y) || rd_c.x != 0 || rd_c.z != '\0') { + if ((dset8 = H5Dopen2(file, "dset8", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl = H5Dget_create_plist(dset8)) < 0) + goto error; + if (H5Pget_fill_value(dcpl, comp_type_id, &rd_c) < 0) + goto error; + if (!H5_FLT_ABS_EQUAL(rd_c.a, 0) || !H5_DBL_ABS_EQUAL(rd_c.y, fill_ctype.y) || rd_c.x != 0 || + rd_c.z != '\0') { H5_FAILED(); puts(" Got wrong fill value"); - HDprintf(" Got rd_c.a=%f, rd_c.y=%f and rd_c.x=%d, rd_c.z=%c\n", - (double)rd_c.a, rd_c.y, rd_c.x, rd_c.z); + HDprintf(" Got rd_c.a=%f, rd_c.y=%f and rd_c.x=%d, rd_c.z=%c\n", (double)rd_c.a, rd_c.y, rd_c.x, + rd_c.z); } - if(H5Dclose(dset8) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; + if (H5Dclose(dset8) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; - if(H5Fclose(file) < 0) goto error; + if (H5Fclose(file) < 0) + goto error; PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Sclose(space); - if(H5D_COMPACT != layout) { - H5Dclose(dset1); - H5Dclose(dset2); - H5Dclose(dset3); - H5Dclose(dset4); - H5Dclose(dset9); + H5E_BEGIN_TRY + { + H5Pclose(dcpl); + H5Sclose(space); + if (H5D_COMPACT != layout) { + H5Dclose(dset1); + H5Dclose(dset2); + H5Dclose(dset3); + H5Dclose(dset4); + H5Dclose(dset9); } H5Dclose(dset5); H5Dclose(dset6); - H5Dclose(dset8); - H5Fclose(file); - } H5E_END_TRY; + H5Dclose(dset8); + H5Fclose(file); + } + H5E_END_TRY; return 1; } @@ -746,35 +874,34 @@ error: *------------------------------------------------------------------------- */ static int -test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, - H5D_fill_time_t fill_time, H5D_layout_t layout, - H5T_class_t datatype, hid_t ctype_id) +test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, H5D_fill_time_t fill_time, + H5D_layout_t layout, H5T_class_t datatype, hid_t ctype_id) { - hid_t fspace=-1, mspace=-1, dset1=-1, dset2=-1; - hsize_t cur_size[5] = {2, 8, 8, 4, 2}; - hsize_t one[5] = {1, 1, 1, 1, 1}; - hsize_t hs_size[5], hs_stride[5]; - hsize_t hs_offset[5], nelmts; - int fillval=(-1), val_rd, should_be; - int i, j, *buf=NULL, odd; - unsigned u; - comp_datatype rd_c, fill_c, should_be_c; - comp_datatype *buf_c=NULL; - H5D_space_status_t allocation; + hid_t fspace = -1, mspace = -1, dset1 = -1, dset2 = -1; + hsize_t cur_size[5] = {2, 8, 8, 4, 2}; + hsize_t one[5] = {1, 1, 1, 1, 1}; + hsize_t hs_size[5], hs_stride[5]; + hsize_t hs_offset[5], nelmts; + int fillval = (-1), val_rd, should_be; + int i, j, *buf = NULL, odd; + unsigned u; + comp_datatype rd_c, fill_c, should_be_c; + comp_datatype * buf_c = NULL; + H5D_space_status_t allocation; fill_c.a = 0; fill_c.x = 0; fill_c.y = 0; fill_c.z = 0; - if(datatype == H5T_INTEGER) { - fillval = *(int*)_fillval; + if (datatype == H5T_INTEGER) { + fillval = *(int *)_fillval; } - else if(datatype == H5T_COMPOUND) { - fill_c.a=((comp_datatype*)_fillval)->a; - fill_c.x=((comp_datatype*)_fillval)->x; - fill_c.y=((comp_datatype*)_fillval)->y; - fill_c.z=((comp_datatype*)_fillval)->z; + else if (datatype == H5T_COMPOUND) { + fill_c.a = ((comp_datatype *)_fillval)->a; + fill_c.x = ((comp_datatype *)_fillval)->x; + fill_c.y = ((comp_datatype *)_fillval)->y; + fill_c.z = ((comp_datatype *)_fillval)->z; } else { HDputs("Invalid type for test"); @@ -782,156 +909,158 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, } /* Create dataset */ - if((fspace = H5Screate_simple(5, cur_size, cur_size)) < 0) + if ((fspace = H5Screate_simple(5, cur_size, cur_size)) < 0) goto error; - if(datatype == H5T_INTEGER && (dset1 = H5Dcreate2(file, dname, H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if (datatype == H5T_INTEGER && + (dset1 = H5Dcreate2(file, dname, H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(datatype == H5T_COMPOUND && (dset2 = H5Dcreate2(file, dname, ctype_id, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if (datatype == H5T_COMPOUND && + (dset2 = H5Dcreate2(file, dname, ctype_id, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Read some data and make sure it's the fill value */ - if((mspace = H5Screate_simple(5, one, NULL)) < 0) + if ((mspace = H5Screate_simple(5, one, NULL)) < 0) goto error; - for (i=0; i<1000; i++) { - for (j=0; j<5; j++) - hs_offset[j] = (hsize_t)HDrand() % cur_size[j]; - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, - one, NULL) < 0) goto error; + for (i = 0; i < 1000; i++) { + for (j = 0; j < 5; j++) + hs_offset[j] = (hsize_t)HDrand() % cur_size[j]; + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + goto error; - /* case for atomic datatype */ - if(datatype==H5T_INTEGER) { - if(H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, - &val_rd) < 0) goto error; - if(fill_time!=H5D_FILL_TIME_NEVER && val_rd!=fillval) { - H5_FAILED(); + /* case for atomic datatype */ + if (datatype == H5T_INTEGER) { + if (H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd) < 0) + goto error; + if (fill_time != H5D_FILL_TIME_NEVER && val_rd != fillval) { + H5_FAILED(); HDfprintf(stdout, "%u: Value read was not a fill value.\n", (unsigned)__LINE__); - HDfprintf(stdout," Elmt={%Hu,%Hu,%Hu,%Hu,%Hu}, read: %u, " - "Fill value: %u\n", - hs_offset[0], hs_offset[1], - hs_offset[2], hs_offset[3], - hs_offset[4], val_rd, fillval); - goto error; + HDfprintf(stdout, + " Elmt={%Hu,%Hu,%Hu,%Hu,%Hu}, read: %u, " + "Fill value: %u\n", + hs_offset[0], hs_offset[1], hs_offset[2], hs_offset[3], hs_offset[4], val_rd, + fillval); + goto error; + } + /* case for compound datatype */ } - /* case for compound datatype */ - } - else if(datatype==H5T_COMPOUND) { - if(H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, - &rd_c) < 0) goto error; - if(fill_time != H5D_FILL_TIME_NEVER && (!H5_FLT_ABS_EQUAL(rd_c.a, fill_c.a) || - rd_c.x != fill_c.x || !H5_DBL_ABS_EQUAL(rd_c.y, fill_c.y) || - rd_c.z != fill_c.z)) { + else if (datatype == H5T_COMPOUND) { + if (H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, &rd_c) < 0) + goto error; + if (fill_time != H5D_FILL_TIME_NEVER && + (!H5_FLT_ABS_EQUAL(rd_c.a, fill_c.a) || rd_c.x != fill_c.x || + !H5_DBL_ABS_EQUAL(rd_c.y, fill_c.y) || rd_c.z != fill_c.z)) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not a fill value.\n", (unsigned)__LINE__); - HDfprintf(stdout," Elmt={%Hu,%Hu,%Hu,%Hu,%Hu}, read: %f, %d, %f, %c" - "Fill value: %f, %d, %f, %c\n", - hs_offset[0], hs_offset[1], - hs_offset[2], hs_offset[3], - hs_offset[4], (double)rd_c.a, rd_c.x, rd_c.y, rd_c.z, - (double)fill_c.a, fill_c.x, fill_c.y, fill_c.z); + HDfprintf(stdout, + " Elmt={%Hu,%Hu,%Hu,%Hu,%Hu}, read: %f, %d, %f, %c" + "Fill value: %f, %d, %f, %c\n", + hs_offset[0], hs_offset[1], hs_offset[2], hs_offset[3], hs_offset[4], + (double)rd_c.a, rd_c.x, rd_c.y, rd_c.z, (double)fill_c.a, fill_c.x, fill_c.y, + fill_c.z); goto error; } } } - if(H5Sclose(mspace) < 0) goto error; + if (H5Sclose(mspace) < 0) + goto error; /* Select all odd data locations in the file dataset */ - for (i=0, nelmts=1; i<5; i++) { - hs_size[i] = cur_size[i]/2; + for (i = 0, nelmts = 1; i < 5; i++) { + hs_size[i] = cur_size[i] / 2; hs_offset[i] = 0; hs_stride[i] = 2; nelmts *= hs_size[i]; } - if((mspace=H5Screate_simple(5, hs_size, hs_size)) < 0) goto error; - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride, - hs_size, NULL) < 0) goto error; + if ((mspace = H5Screate_simple(5, hs_size, hs_size)) < 0) + goto error; + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride, hs_size, NULL) < 0) + goto error; /* Read non-contiguous selection from empty dataset */ /* case for atomic datatype */ - if(datatype==H5T_INTEGER) { + if (datatype == H5T_INTEGER) { /*check for overflow*/ HDassert((nelmts * sizeof(int)) == (hsize_t)((size_t)(nelmts * sizeof(int)))); buf = (int *)HDmalloc((size_t)(nelmts * sizeof(int))); - if(H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0) + if (H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0) goto error; /* Verify values, except if no fill value written */ - if(fill_time != H5D_FILL_TIME_NEVER) { - for(u = 0; u < nelmts; u++) { - if(buf[u] != fillval) { + if (fill_time != H5D_FILL_TIME_NEVER) { + for (u = 0; u < nelmts; u++) { + if (buf[u] != fillval) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not a fill value.\n", (unsigned)__LINE__); - HDfprintf(stdout," Elmt={%Hu, %Hu, %Hu, %Hu, %Hu}, read: %u, " - "Fill value: %u\n", - hs_offset[0], hs_offset[1], - hs_offset[2], hs_offset[3], - hs_offset[4], buf[u], fillval); + HDfprintf(stdout, + " Elmt={%Hu, %Hu, %Hu, %Hu, %Hu}, read: %u, " + "Fill value: %u\n", + hs_offset[0], hs_offset[1], hs_offset[2], hs_offset[3], hs_offset[4], buf[u], + fillval); goto error; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ } /* case for compound datatype */ - else if(datatype == H5T_COMPOUND) { + else if (datatype == H5T_COMPOUND) { /*check for overflow*/ - HDassert((nelmts * sizeof(comp_datatype)) == - (hsize_t)((size_t)(nelmts * sizeof(comp_datatype)))); - buf_c = (comp_datatype *)HDmalloc((size_t)nelmts * sizeof(comp_datatype)); + HDassert((nelmts * sizeof(comp_datatype)) == (hsize_t)((size_t)(nelmts * sizeof(comp_datatype)))); + buf_c = (comp_datatype *)HDmalloc((size_t)nelmts * sizeof(comp_datatype)); - if(H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, buf_c) < 0) + if (H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, buf_c) < 0) goto error; /* Verify values, except if no fill value written */ - if(fill_time != H5D_FILL_TIME_NEVER) { - for(u = 0; u < nelmts; u++) { - if(!H5_FLT_ABS_EQUAL(buf_c[u].a, fill_c.a) || buf_c[u].x != fill_c.x || - !H5_DBL_ABS_EQUAL(buf_c[u].y, fill_c.y) || buf_c[u].z != fill_c.z) { + if (fill_time != H5D_FILL_TIME_NEVER) { + for (u = 0; u < nelmts; u++) { + if (!H5_FLT_ABS_EQUAL(buf_c[u].a, fill_c.a) || buf_c[u].x != fill_c.x || + !H5_DBL_ABS_EQUAL(buf_c[u].y, fill_c.y) || buf_c[u].z != fill_c.z) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not a fill value.\n", (unsigned)__LINE__); - HDfprintf(stdout," Elmt={%Hu, %Hu, %Hu, %Hu, %Hu}, read: %f, %d, %f, %c" - "Fill value: %f, %d, %f, %c\n", - hs_offset[0], hs_offset[1], - hs_offset[2], hs_offset[3], - hs_offset[4], - (double)buf_c[u].a, buf_c[u].x, buf_c[u].y, buf_c[u].z, - (double)fill_c.a, fill_c.x, fill_c.y, fill_c.z); + HDfprintf(stdout, + " Elmt={%Hu, %Hu, %Hu, %Hu, %Hu}, read: %f, %d, %f, %c" + "Fill value: %f, %d, %f, %c\n", + hs_offset[0], hs_offset[1], hs_offset[2], hs_offset[3], hs_offset[4], + (double)buf_c[u].a, buf_c[u].x, buf_c[u].y, buf_c[u].z, (double)fill_c.a, + fill_c.x, fill_c.y, fill_c.z); goto error; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ } /* Write to all odd data locations */ /* case for atomic datatype */ - if(datatype == H5T_INTEGER) { - for(u = 0; u < nelmts; u++) + if (datatype == H5T_INTEGER) { + for (u = 0; u < nelmts; u++) buf[u] = 9999; - if(H5Dwrite(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0) goto error; } /* case for compound datatype */ - else if(datatype == H5T_COMPOUND) { + else if (datatype == H5T_COMPOUND) { HDmemset(buf_c, 0, ((size_t)nelmts * sizeof(comp_datatype))); - for(u = 0; u < nelmts; u++) { - buf_c[u].a = 1111.11F; - buf_c[u].x = 2222; - buf_c[u].y = 3333.3333F; - buf_c[u].z = 'd'; - } - if(H5Dwrite(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, buf_c) < 0) + for (u = 0; u < nelmts; u++) { + buf_c[u].a = 1111.11F; + buf_c[u].x = 2222; + buf_c[u].y = 3333.3333F; + buf_c[u].z = 'd'; + } + if (H5Dwrite(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, buf_c) < 0) goto error; } /* Check if space is allocated */ - if(datatype==H5T_INTEGER && H5Dget_space_status(dset1, &allocation) < 0) - goto error; - if(datatype==H5T_COMPOUND && H5Dget_space_status(dset2, &allocation) < 0) + if (datatype == H5T_INTEGER && H5Dget_space_status(dset1, &allocation) < 0) + goto error; + if (datatype == H5T_COMPOUND && H5Dget_space_status(dset2, &allocation) < 0) goto error; - if(layout == H5D_CONTIGUOUS && allocation != H5D_SPACE_STATUS_ALLOCATED) { + if (layout == H5D_CONTIGUOUS && allocation != H5D_SPACE_STATUS_ALLOCATED) { H5_FAILED(); - HDprintf(" %d: Got unallocated space instead of allocated.\n",__LINE__); + HDprintf(" %d: Got unallocated space instead of allocated.\n", __LINE__); HDprintf(" Got %d\n", allocation); goto error; } @@ -940,126 +1069,129 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, H5Sclose(mspace); /* Read some data and make sure it's the right value */ - if((mspace = H5Screate_simple(5, one, NULL)) < 0) + if ((mspace = H5Screate_simple(5, one, NULL)) < 0) goto error; - for(i = 0; i < 1000; i++) { - for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % cur_size[j]; - odd += (int)(hs_offset[j]%2); - } /* end for */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + for (i = 0; i < 1000; i++) { + for (j = 0, odd = 0; j < 5; j++) { + hs_offset[j] = (hsize_t)HDrand() % cur_size[j]; + odd += (int)(hs_offset[j] % 2); + } /* end for */ + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) goto error; - /* case for atomic datatype */ - if(datatype==H5T_INTEGER) { - if(H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd) < 0) + /* case for atomic datatype */ + if (datatype == H5T_INTEGER) { + if (H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd) < 0) goto error; - if(fill_time == H5D_FILL_TIME_ALLOC) { + if (fill_time == H5D_FILL_TIME_ALLOC) { should_be = odd ? fillval : 9999; - if(val_rd!=should_be) { + if (val_rd != should_be) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not correct.\n", (unsigned)__LINE__); HDprintf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, " - "should be: %u\n", - (long)hs_offset[0], (long)hs_offset[1], - (long)hs_offset[2], (long)hs_offset[3], - (long)hs_offset[4], val_rd, should_be); + "should be: %u\n", + (long)hs_offset[0], (long)hs_offset[1], (long)hs_offset[2], (long)hs_offset[3], + (long)hs_offset[4], val_rd, should_be); goto error; } - } - else if(fill_time == H5D_FILL_TIME_NEVER && !odd) { - should_be = 9999; - if(val_rd!=should_be) { - H5_FAILED(); + } + else if (fill_time == H5D_FILL_TIME_NEVER && !odd) { + should_be = 9999; + if (val_rd != should_be) { + H5_FAILED(); HDfprintf(stdout, "%u: Value read was not correct.\n", (unsigned)__LINE__); - HDprintf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, " - "should be: %u\n", - (long)hs_offset[0], (long)hs_offset[1], - (long)hs_offset[2], (long)hs_offset[3], - (long)hs_offset[4], val_rd, should_be); - goto error; + HDprintf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %u, " + "should be: %u\n", + (long)hs_offset[0], (long)hs_offset[1], (long)hs_offset[2], (long)hs_offset[3], + (long)hs_offset[4], val_rd, should_be); + goto error; + } } - } else if(fill_time == H5D_FILL_TIME_NEVER && odd) { - /*Trash data. Don't compare*/ - } - } /* end for datatype==H5T_INTEGER */ - /* case for compound datatype */ - else if(datatype==H5T_COMPOUND) { - if(H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, &rd_c) < 0) + else if (fill_time == H5D_FILL_TIME_NEVER && odd) { + /*Trash data. Don't compare*/ + } + } /* end for datatype==H5T_INTEGER */ + /* case for compound datatype */ + else if (datatype == H5T_COMPOUND) { + if (H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, &rd_c) < 0) goto error; - if(fill_time == H5D_FILL_TIME_ALLOC) { - if(odd) { - should_be_c.a=fill_c.a; - should_be_c.x=fill_c.x; - should_be_c.y=fill_c.y; - should_be_c.z=fill_c.z; - } else { - should_be_c.a=buf_c[0].a; - should_be_c.x=buf_c[0].x; - should_be_c.y=buf_c[0].y; - should_be_c.z=buf_c[0].z; - } - if(!H5_FLT_ABS_EQUAL(rd_c.a, should_be_c.a) || rd_c.x != should_be_c.x || - !H5_DBL_ABS_EQUAL(rd_c.y, should_be_c.y) || rd_c.z != should_be_c.z) { + if (fill_time == H5D_FILL_TIME_ALLOC) { + if (odd) { + should_be_c.a = fill_c.a; + should_be_c.x = fill_c.x; + should_be_c.y = fill_c.y; + should_be_c.z = fill_c.z; + } + else { + should_be_c.a = buf_c[0].a; + should_be_c.x = buf_c[0].x; + should_be_c.y = buf_c[0].y; + should_be_c.z = buf_c[0].z; + } + if (!H5_FLT_ABS_EQUAL(rd_c.a, should_be_c.a) || rd_c.x != should_be_c.x || + !H5_DBL_ABS_EQUAL(rd_c.y, should_be_c.y) || rd_c.z != should_be_c.z) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not correct.\n", (unsigned)__LINE__); HDprintf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %f,%d,%f,%c " - "should be: %f,%d,%f,%c\n", - (long)hs_offset[0], (long)hs_offset[1], - (long)hs_offset[2], (long)hs_offset[3], - (long)hs_offset[4], - (double)rd_c.a, rd_c.x, rd_c.y, rd_c.z, (double)should_be_c.a, - should_be_c.x,should_be_c.y,should_be_c.z); + "should be: %f,%d,%f,%c\n", + (long)hs_offset[0], (long)hs_offset[1], (long)hs_offset[2], (long)hs_offset[3], + (long)hs_offset[4], (double)rd_c.a, rd_c.x, rd_c.y, rd_c.z, + (double)should_be_c.a, should_be_c.x, should_be_c.y, should_be_c.z); goto error; - } - } /* end for fill_time == H5D_FILL_TIME_ALLOC */ - else if(fill_time == H5D_FILL_TIME_NEVER && !odd) { - should_be_c.a=buf_c[0].a; - should_be_c.x=buf_c[0].x; - should_be_c.y=buf_c[0].y; - should_be_c.z=buf_c[0].z; - if(!H5_FLT_ABS_EQUAL(rd_c.a, should_be_c.a) || rd_c.x != should_be_c.x || - !H5_DBL_ABS_EQUAL(rd_c.y, should_be_c.y) || rd_c.z != should_be_c.z) { + } + } /* end for fill_time == H5D_FILL_TIME_ALLOC */ + else if (fill_time == H5D_FILL_TIME_NEVER && !odd) { + should_be_c.a = buf_c[0].a; + should_be_c.x = buf_c[0].x; + should_be_c.y = buf_c[0].y; + should_be_c.z = buf_c[0].z; + if (!H5_FLT_ABS_EQUAL(rd_c.a, should_be_c.a) || rd_c.x != should_be_c.x || + !H5_DBL_ABS_EQUAL(rd_c.y, should_be_c.y) || rd_c.z != should_be_c.z) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not correct.\n", (unsigned)__LINE__); HDprintf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %f,%d,%f,%c " - "should be: %f,%d,%f,%c\n", - (long)hs_offset[0], (long)hs_offset[1], - (long)hs_offset[2], (long)hs_offset[3], - (long)hs_offset[4], - (double)rd_c.a, rd_c.x, rd_c.y, rd_c.z, (double)should_be_c.a, - should_be_c.x,should_be_c.y,should_be_c.z); + "should be: %f,%d,%f,%c\n", + (long)hs_offset[0], (long)hs_offset[1], (long)hs_offset[2], (long)hs_offset[3], + (long)hs_offset[4], (double)rd_c.a, rd_c.x, rd_c.y, rd_c.z, + (double)should_be_c.a, should_be_c.x, should_be_c.y, should_be_c.z); goto error; } - } /* end for fill_time == H5D_FILL_TIME_NEVER */ - else if(fill_time == H5D_FILL_TIME_NEVER && odd) { + } /* end for fill_time == H5D_FILL_TIME_NEVER */ + else if (fill_time == H5D_FILL_TIME_NEVER && odd) { /*Trash data. Don't compare*/ } - } /* end for datatype==H5T_COMPOUND */ + } /* end for datatype==H5T_COMPOUND */ } - if(datatype == H5T_COMPOUND) { + if (datatype == H5T_COMPOUND) { HDfree(buf_c); buf_c = NULL; } /* end if */ - if(H5Sclose(mspace) < 0) goto error; - if(datatype==H5T_INTEGER && H5Dclose(dset1) < 0) goto error; - if(datatype==H5T_COMPOUND && H5Dclose(dset2) < 0) goto error; - if(H5Sclose(fspace) < 0) goto error; + if (H5Sclose(mspace) < 0) + goto error; + if (datatype == H5T_INTEGER && H5Dclose(dset1) < 0) + goto error; + if (datatype == H5T_COMPOUND && H5Dclose(dset2) < 0) + goto error; + if (H5Sclose(fspace) < 0) + goto error; return 0; - error: - H5E_BEGIN_TRY { - if(datatype==H5T_INTEGER) H5Dclose(dset1); - if(datatype==H5T_COMPOUND) H5Dclose(dset2); - H5Sclose(fspace); - H5Sclose(mspace); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + if (datatype == H5T_INTEGER) + H5Dclose(dset1); + if (datatype == H5T_COMPOUND) + H5Dclose(dset2); + H5Sclose(fspace); + H5Sclose(mspace); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_rdwr * @@ -1081,158 +1213,187 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, static int test_rdwr(hid_t fapl, const char *base_name, H5D_layout_t layout) { - char filename[1024]; - hid_t file=-1, dcpl=-1, ctype_id=-1; - hsize_t ch_size[5] = {2, 8, 8, 4, 2}; - int nerrors=0; - int fillval = 0x4c70f1cd; - comp_datatype fill_ctype={0,0,0,0}; - - if(H5D_CHUNKED==layout) { + char filename[1024]; + hid_t file = -1, dcpl = -1, ctype_id = -1; + hsize_t ch_size[5] = {2, 8, 8, 4, 2}; + int nerrors = 0; + int fillval = 0x4c70f1cd; + comp_datatype fill_ctype = {0, 0, 0, 0}; + + if (H5D_CHUNKED == layout) { TESTING("chunked dataset I/O"); - } else if(H5D_COMPACT==layout) { + } + else if (H5D_COMPACT == layout) { TESTING("compact dataset I/O"); - } else { + } + else { TESTING("contiguous dataset I/O"); } h5_fixname(base_name, fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5D_CHUNKED == layout) { - if(H5Pset_chunk(dcpl, 5, ch_size) < 0) + if (H5D_CHUNKED == layout) { + if (H5Pset_chunk(dcpl, 5, ch_size) < 0) goto error; } - else if(H5D_COMPACT == layout) { - if(H5Pset_layout(dcpl, H5D_COMPACT) < 0) + else if (H5D_COMPACT == layout) { + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto error; } - if((ctype_id = create_compound_type()) < 0) + if ((ctype_id = create_compound_type()) < 0) goto error; /* I. Test H5D_ALLOC_TIME_LATE space allocation cases */ - if(H5D_COMPACT != layout) { - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) goto error; + if (H5D_COMPACT != layout) { + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto error; /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; fillval = 0; - nerrors += test_rdwr_cases(file, dcpl, "dset1", &fillval, H5D_FILL_TIME_ALLOC, - layout, H5T_INTEGER, (hid_t)-1); + nerrors += test_rdwr_cases(file, dcpl, "dset1", &fillval, H5D_FILL_TIME_ALLOC, layout, H5T_INTEGER, + (hid_t)-1); /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset2", &fillval, H5D_FILL_TIME_NEVER, - layout, H5T_INTEGER, (hid_t)-1); + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; + nerrors += test_rdwr_cases(file, dcpl, "dset2", &fillval, H5D_FILL_TIME_NEVER, layout, H5T_INTEGER, + (hid_t)-1); /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value is user-defined */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; fillval = 0x4c70f1cd; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset3", &fillval, H5D_FILL_TIME_ALLOC, - layout, H5T_INTEGER, (hid_t)-1); + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + goto error; + nerrors += test_rdwr_cases(file, dcpl, "dset3", &fillval, H5D_FILL_TIME_ALLOC, layout, H5T_INTEGER, + (hid_t)-1); /* case for H5D_FILL_TIME_NEVER as fill write time and fill value is user-defined */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset4", &fillval, H5D_FILL_TIME_NEVER, - layout, H5T_INTEGER, (hid_t)-1); + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + goto error; + nerrors += test_rdwr_cases(file, dcpl, "dset4", &fillval, H5D_FILL_TIME_NEVER, layout, H5T_INTEGER, + (hid_t)-1); /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value is undefined */ /* This case has been tested in test_create() function */ /* case for H5D_FILL_TIME_NEVER as fill write time and fill value is undefined */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; - if(H5Pset_fill_value(dcpl, (hid_t)-1, NULL) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset5", &fillval, H5D_FILL_TIME_NEVER, - layout, H5T_INTEGER, (hid_t)-1); + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; + if (H5Pset_fill_value(dcpl, (hid_t)-1, NULL) < 0) + goto error; + nerrors += test_rdwr_cases(file, dcpl, "dset5", &fillval, H5D_FILL_TIME_NEVER, layout, H5T_INTEGER, + (hid_t)-1); /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value is user-defined * as compound type */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; HDmemset(&fill_ctype, 0, sizeof(fill_ctype)); fill_ctype.y = 4444.4444F; - if(H5Pset_fill_value(dcpl, ctype_id, &fill_ctype) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset11", &fill_ctype, H5D_FILL_TIME_ALLOC, - layout, H5T_COMPOUND, ctype_id); - - if(H5Pclose(dcpl) < 0) goto error; - if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5D_CHUNKED==layout) { - if(H5Pset_chunk(dcpl, 5, ch_size) < 0) goto error; + if (H5Pset_fill_value(dcpl, ctype_id, &fill_ctype) < 0) + goto error; + nerrors += test_rdwr_cases(file, dcpl, "dset11", &fill_ctype, H5D_FILL_TIME_ALLOC, layout, + H5T_COMPOUND, ctype_id); + + if (H5Pclose(dcpl) < 0) + goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5D_CHUNKED == layout) { + if (H5Pset_chunk(dcpl, 5, ch_size) < 0) + goto error; } } - /* II. Test H5D_ALLOC_TIME_EARLY space allocation cases */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto error; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto error; /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; fillval = 0; - nerrors += test_rdwr_cases(file, dcpl, "dset6", &fillval, H5D_FILL_TIME_ALLOC, - layout, H5T_INTEGER, (hid_t)-1); + nerrors += + test_rdwr_cases(file, dcpl, "dset6", &fillval, H5D_FILL_TIME_ALLOC, layout, H5T_INTEGER, (hid_t)-1); /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset7", &fillval, H5D_FILL_TIME_NEVER, layout, - H5T_INTEGER, (hid_t)-1); + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; + nerrors += + test_rdwr_cases(file, dcpl, "dset7", &fillval, H5D_FILL_TIME_NEVER, layout, H5T_INTEGER, (hid_t)-1); /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value is user-defined */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; fillval = 0x4c70f1cd; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset8", &fillval, H5D_FILL_TIME_ALLOC, - layout, H5T_INTEGER, (hid_t)-1); + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + goto error; + nerrors += + test_rdwr_cases(file, dcpl, "dset8", &fillval, H5D_FILL_TIME_ALLOC, layout, H5T_INTEGER, (hid_t)-1); /* case for H5D_FILL_TIME_NEVER as fill write time and fill value is user-defined */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset9", &fillval, H5D_FILL_TIME_NEVER, - layout, H5T_INTEGER, (hid_t)-1); + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + goto error; + nerrors += + test_rdwr_cases(file, dcpl, "dset9", &fillval, H5D_FILL_TIME_NEVER, layout, H5T_INTEGER, (hid_t)-1); /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value is undefined */ /* This case has been tested in test_create() function */ /* case for H5D_FILL_TIME_NEVER as fill write time and fill value is undefined */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; - if(H5Pset_fill_value(dcpl, (hid_t)-1, NULL) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset10", &fillval, H5D_FILL_TIME_NEVER, - layout, H5T_INTEGER, (hid_t)-1); + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; + if (H5Pset_fill_value(dcpl, (hid_t)-1, NULL) < 0) + goto error; + nerrors += + test_rdwr_cases(file, dcpl, "dset10", &fillval, H5D_FILL_TIME_NEVER, layout, H5T_INTEGER, (hid_t)-1); /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value is user-defined * as compound type */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; HDmemset(&fill_ctype, 0, sizeof(fill_ctype)); fill_ctype.y = 4444.4444F; - if(H5Pset_fill_value(dcpl, ctype_id, &fill_ctype) < 0) goto error; - nerrors += test_rdwr_cases(file, dcpl, "dset12", &fill_ctype, H5D_FILL_TIME_ALLOC, - layout, H5T_COMPOUND, ctype_id); - + if (H5Pset_fill_value(dcpl, ctype_id, &fill_ctype) < 0) + goto error; + nerrors += test_rdwr_cases(file, dcpl, "dset12", &fill_ctype, H5D_FILL_TIME_ALLOC, layout, H5T_COMPOUND, + ctype_id); - if(nerrors) - goto error; - if(H5Pclose(dcpl) < 0) goto error; - if(H5Tclose(ctype_id) < 0) goto error; - if(H5Fclose(file) < 0) goto error; + if (nerrors) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Tclose(ctype_id) < 0) + goto error; + if (H5Fclose(file) < 0) + goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); - H5Tclose(ctype_id); + H5Tclose(ctype_id); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return nerrors; } - /*------------------------------------------------------------------------- * Function: test_extend_init_integer * @@ -1249,10 +1410,10 @@ test_rdwr(hid_t fapl, const char *base_name, H5D_layout_t layout) static int test_extend_init_integer(void *_buf, size_t nelmts, const void *_val) { - int *buf = (int *)_buf; /* Buffer to initialize */ - const int *val = (const int *)_val; /* Value to use */ + int * buf = (int *)_buf; /* Buffer to initialize */ + const int *val = (const int *)_val; /* Value to use */ - while(nelmts) { + while (nelmts) { *buf++ = *val; nelmts--; } /* end while */ @@ -1260,7 +1421,6 @@ test_extend_init_integer(void *_buf, size_t nelmts, const void *_val) return 0; } /* end test_extend_init_integer() */ - /*------------------------------------------------------------------------- * Function: test_extend_verify_integer * @@ -1275,20 +1435,19 @@ test_extend_init_integer(void *_buf, size_t nelmts, const void *_val) *------------------------------------------------------------------------- */ static int -test_extend_verify_integer(unsigned lineno, const hsize_t *offset, - const void *_test_val, const void *_compare_val) +test_extend_verify_integer(unsigned lineno, const hsize_t *offset, const void *_test_val, + const void *_compare_val) { - const int *test_val = (const int *)_test_val; /* Value to test */ - const int *compare_val = (const int *)_compare_val; /* Value to compare against */ + const int *test_val = (const int *)_test_val; /* Value to test */ + const int *compare_val = (const int *)_compare_val; /* Value to compare against */ /* Verify value */ - if(*test_val != *compare_val) { + if (*test_val != *compare_val) { HDfprintf(stdout, "%u: Value read was not expected.\n", lineno); - HDfprintf(stdout," Elmt = {%Hu, %Hu, %Hu, %Hu, %Hu}, read: %d, " - "expected: %d\n", - offset[0], offset[1], - offset[2], offset[3], - offset[4], *test_val, *compare_val); + HDfprintf(stdout, + " Elmt = {%Hu, %Hu, %Hu, %Hu, %Hu}, read: %d, " + "expected: %d\n", + offset[0], offset[1], offset[2], offset[3], offset[4], *test_val, *compare_val); goto error; } /* end if */ @@ -1298,7 +1457,6 @@ error: return -1; } /* end test_extend_verify_integer() */ - /*------------------------------------------------------------------------- * Function: test_extend_release_integer * @@ -1318,7 +1476,6 @@ test_extend_release_integer(void H5_ATTR_UNUSED *_elmt) return 0; } /* end test_extend_release_integer() */ - /*------------------------------------------------------------------------- * Function: test_extend_init_cmpd_vl * @@ -1335,10 +1492,10 @@ test_extend_release_integer(void H5_ATTR_UNUSED *_elmt) static int test_extend_init_cmpd_vl(void *_buf, size_t nelmts, const void *_val) { - comp_vl_datatype *buf = (comp_vl_datatype *)_buf; /* Buffer to initialize */ - const comp_vl_datatype *val = (const comp_vl_datatype *)_val; /* Value to use */ + comp_vl_datatype * buf = (comp_vl_datatype *)_buf; /* Buffer to initialize */ + const comp_vl_datatype *val = (const comp_vl_datatype *)_val; /* Value to use */ - while(nelmts) { + while (nelmts) { /* Shallow copy all fields */ *buf = *val; @@ -1353,7 +1510,6 @@ test_extend_init_cmpd_vl(void *_buf, size_t nelmts, const void *_val) return 0; } /* end test_extend_init_cmpd_vl() */ - /*------------------------------------------------------------------------- * Function: test_extend_verify_cmpd_vl * @@ -1368,23 +1524,22 @@ test_extend_init_cmpd_vl(void *_buf, size_t nelmts, const void *_val) *------------------------------------------------------------------------- */ static int -test_extend_verify_cmpd_vl(unsigned lineno, const hsize_t *offset, - const void *_test_val, const void *_compare_val) +test_extend_verify_cmpd_vl(unsigned lineno, const hsize_t *offset, const void *_test_val, + const void *_compare_val) { - const comp_vl_datatype *test_val = (const comp_vl_datatype *)_test_val; /* Value to test */ - const comp_vl_datatype *compare_val = (const comp_vl_datatype *)_compare_val; /* Value to compare against */ + const comp_vl_datatype *test_val = (const comp_vl_datatype *)_test_val; /* Value to test */ + const comp_vl_datatype *compare_val = + (const comp_vl_datatype *)_compare_val; /* Value to compare against */ /* Verify value */ - if((test_val->x != compare_val->x) || - HDstrcmp(test_val->a, compare_val->a) || - HDstrcmp(test_val->b, compare_val->b) || - (test_val->y != compare_val->y)) { + if ((test_val->x != compare_val->x) || HDstrcmp(test_val->a, compare_val->a) || + HDstrcmp(test_val->b, compare_val->b) || (test_val->y != compare_val->y)) { HDfprintf(stdout, "%u: Value read was not expected.\n", lineno); - HDfprintf(stdout," Elmt = {%Hu, %Hu, %Hu, %Hu, %Hu}, read: {%d, '%s', '%s', %d} " - "expected: {%d, '%s', '%s', %d}\n", - offset[0], offset[1], offset[2], offset[3], offset[4], - test_val->x, test_val->a, test_val->b, test_val->y, - compare_val->x, compare_val->a, compare_val->b, compare_val->y); + HDfprintf(stdout, + " Elmt = {%Hu, %Hu, %Hu, %Hu, %Hu}, read: {%d, '%s', '%s', %d} " + "expected: {%d, '%s', '%s', %d}\n", + offset[0], offset[1], offset[2], offset[3], offset[4], test_val->x, test_val->a, + test_val->b, test_val->y, compare_val->x, compare_val->a, compare_val->b, compare_val->y); goto error; } /* end if */ @@ -1394,7 +1549,6 @@ error: return -1; } /* end test_extend_verify_cmpd_vl() */ - /*------------------------------------------------------------------------- * Function: test_extend_release_cmpd_vl * @@ -1411,7 +1565,7 @@ error: static int test_extend_release_cmpd_vl(void *_elmt) { - comp_vl_datatype *elmt = (comp_vl_datatype *)_elmt; /* Element to free */ + comp_vl_datatype *elmt = (comp_vl_datatype *)_elmt; /* Element to free */ /* Free memory for string fields */ HDfree(elmt->a); @@ -1420,7 +1574,6 @@ test_extend_release_cmpd_vl(void *_elmt) return 0; } /* end test_extend_release_integer() */ - /*------------------------------------------------------------------------- * Function: test_extend_cases * @@ -1435,110 +1588,118 @@ test_extend_release_cmpd_vl(void *_elmt) *------------------------------------------------------------------------- */ static int -test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, - hsize_t *ch_size, hsize_t *start_size, hsize_t *max_size, hid_t dtype, void *fillval) +test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, hsize_t *ch_size, hsize_t *start_size, + hsize_t *max_size, hid_t dtype, void *fillval) { - hid_t fspace = -1, mspace = -1; /* File & memory dataspaces */ - hid_t dset = -1; /* Dataset ID */ - hid_t dcpl = -1; /* Dataset creation property list */ - hsize_t extend_size[5]; /* Dimensions to extend to */ - hsize_t one[5] = {1, 1, 1, 1, 1}; /* Dimensions of single element dataspace */ - hsize_t hs_size[5], hs_stride[5], hs_offset[5]; - size_t nelmts; - H5T_class_t dtype_class; /* Class of datatype */ - int (*init_rtn)(void *, size_t, const void *); - int (*verify_rtn)(unsigned, const hsize_t *, const void *, const void *); - int (*release_rtn)(void *); - size_t val_size; /* Size of element */ - void *val_rd, *odd_val; - const void *init_val, *should_be, *even_val; - int val_rd_i, init_val_i = 9999; + hid_t fspace = -1, mspace = -1; /* File & memory dataspaces */ + hid_t dset = -1; /* Dataset ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + hsize_t extend_size[5]; /* Dimensions to extend to */ + hsize_t one[5] = {1, 1, 1, 1, 1}; /* Dimensions of single element dataspace */ + hsize_t hs_size[5], hs_stride[5], hs_offset[5]; + size_t nelmts; + H5T_class_t dtype_class; /* Class of datatype */ + int (*init_rtn)(void *, size_t, const void *); + int (*verify_rtn)(unsigned, const hsize_t *, const void *, const void *); + int (*release_rtn)(void *); + size_t val_size; /* Size of element */ + void * val_rd, *odd_val; + const void * init_val, *should_be, *even_val; + int val_rd_i, init_val_i = 9999; comp_vl_datatype init_val_c = {87, NULL, NULL, 129}; comp_vl_datatype val_rd_c; - void *buf = NULL; - unsigned odd; /* Whether an odd or even coord. was read */ - unsigned i, j; /* Local index variables */ + void * buf = NULL; + unsigned odd; /* Whether an odd or even coord. was read */ + unsigned i, j; /* Local index variables */ /* Set vl datatype init value strings */ init_val_c.a = HDstrdup("baz"); init_val_c.b = HDstrdup("mumble"); /* Make copy of dataset creation property list */ - if((dcpl = H5Pcopy(_dcpl)) < 0) TEST_ERROR + if ((dcpl = H5Pcopy(_dcpl)) < 0) + TEST_ERROR #ifndef NO_FILLING - if(H5Pset_fill_value(dcpl, dtype, fillval) < 0) TEST_ERROR + if (H5Pset_fill_value(dcpl, dtype, fillval) < 0) + TEST_ERROR #endif /* Get class of datatype */ - if((dtype_class = H5Tget_class(dtype)) < 0) TEST_ERROR + if ((dtype_class = H5Tget_class(dtype)) < 0) + TEST_ERROR /* Create a dataspace */ - if((fspace = H5Screate_simple(5, start_size, max_size)) < 0) TEST_ERROR + if ((fspace = H5Screate_simple(5, start_size, max_size)) < 0) + TEST_ERROR /* Create dataset */ - if((dset = H5Dcreate2(file, dset_name, dtype, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - + if ((dset = H5Dcreate2(file, dset_name, dtype, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR /* Set up pointers to elements */ - if(dtype_class == H5T_INTEGER) { + if (dtype_class == H5T_INTEGER) { /* Initialize specific values for this datatype */ - val_size = sizeof(int); - init_val = &init_val_i; - init_rtn = test_extend_init_integer; - verify_rtn = test_extend_verify_integer; + val_size = sizeof(int); + init_val = &init_val_i; + init_rtn = test_extend_init_integer; + verify_rtn = test_extend_verify_integer; release_rtn = test_extend_release_integer; - val_rd = &val_rd_i; - odd_val = fillval; - even_val = &init_val_i; + val_rd = &val_rd_i; + odd_val = fillval; + even_val = &init_val_i; } /* end if */ else { /* Sanity check */ assert(dtype_class == H5T_COMPOUND); /* Initialize specific values for this datatype */ - val_size = sizeof(comp_vl_datatype); - init_val = &init_val_c; - init_rtn = test_extend_init_cmpd_vl; - verify_rtn = test_extend_verify_cmpd_vl; + val_size = sizeof(comp_vl_datatype); + init_val = &init_val_c; + init_rtn = test_extend_init_cmpd_vl; + verify_rtn = test_extend_verify_cmpd_vl; release_rtn = test_extend_release_cmpd_vl; - val_rd = &val_rd_c; - odd_val = fillval; - even_val = &init_val_c; + val_rd = &val_rd_c; + odd_val = fillval; + even_val = &init_val_c; } /* end else */ - /* Read some data and make sure it's the fill value */ - if((mspace = H5Screate_simple(5, one, NULL)) < 0) TEST_ERROR - for(i = 0; i < 1000; i++) { + if ((mspace = H5Screate_simple(5, one, NULL)) < 0) + TEST_ERROR + for (i = 0; i < 1000; i++) { /* Set offset for random element */ - for(j = 0; j < 5; j++) - hs_offset[j] = (hsize_t)HDrand() % start_size[j]; + for (j = 0; j < 5; j++) + hs_offset[j] = (hsize_t)HDrand() % start_size[j]; /* Select the random element */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + TEST_ERROR /* Read the random element */ - if(H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Verify the element read in */ - if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, fillval) < 0) TEST_ERROR + if (verify_rtn((unsigned)__LINE__, hs_offset, val_rd, fillval) < 0) + TEST_ERROR /* Release any VL components */ - if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Clear the read buffer */ HDmemset(val_rd, 0, val_size); } /* end for */ - if(H5Sclose(mspace) < 0) TEST_ERROR - + if (H5Sclose(mspace) < 0) + TEST_ERROR /* Initialize dataspace & hyperslab info */ - for(i = 0, nelmts = 1; i < 5; i++) { - hs_size[i] = (start_size[i] + 1) / 2; - hs_offset[i] = 0; - hs_stride[i] = 2; - nelmts *= hs_size[i]; + for (i = 0, nelmts = 1; i < 5; i++) { + hs_size[i] = (start_size[i] + 1) / 2; + hs_offset[i] = 0; + hs_stride[i] = 2; + nelmts *= hs_size[i]; } /* end for */ /* Check for overflow */ @@ -1549,186 +1710,219 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, init_rtn(buf, nelmts, init_val); /* Create dataspace describing memory buffer */ - if((mspace = H5Screate_simple(5, hs_size, hs_size)) < 0) TEST_ERROR + if ((mspace = H5Screate_simple(5, hs_size, hs_size)) < 0) + TEST_ERROR /* Select elements within file dataspace */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride, hs_size, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride, hs_size, NULL) < 0) + TEST_ERROR /* Write to all even data locations */ - if(H5Dwrite(dset, dtype, mspace, fspace, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(dset, dtype, mspace, fspace, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* Close memory dataspace */ - if(H5Sclose(mspace) < 0) TEST_ERROR - + if (H5Sclose(mspace) < 0) + TEST_ERROR /* Read some data and make sure it's the right value */ - if((mspace = H5Screate_simple(5, one, NULL)) < 0) TEST_ERROR - for(i = 0; i < 1000; i++) { + if ((mspace = H5Screate_simple(5, one, NULL)) < 0) + TEST_ERROR + for (i = 0; i < 1000; i++) { /* Set offset for random element */ - for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % start_size[j]; - odd += (unsigned)(hs_offset[j] % 2); - } /* end for */ + for (j = 0, odd = 0; j < 5; j++) { + hs_offset[j] = (hsize_t)HDrand() % start_size[j]; + odd += (unsigned)(hs_offset[j] % 2); + } /* end for */ /* Select the random element */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + TEST_ERROR /* Read the random element */ - if(H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Verify the element read in */ - should_be = odd ? odd_val : even_val; - if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR + should_be = odd ? odd_val : even_val; + if (verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) + TEST_ERROR /* Release any VL components */ - if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Clear the read buffer */ HDmemset(val_rd, 0, val_size); } /* end for */ - if(H5Sclose(mspace) < 0) TEST_ERROR - + if (H5Sclose(mspace) < 0) + TEST_ERROR /* Extend the dataset one element in each dimension */ - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) extend_size[i] = start_size[i] + 1; - if(H5Dset_extent(dset, extend_size) < 0) TEST_ERROR + if (H5Dset_extent(dset, extend_size) < 0) + TEST_ERROR /* Re-open file dataspace */ - if(H5Sclose(fspace) < 0) TEST_ERROR - if((fspace = H5Dget_space(dset)) < 0) TEST_ERROR - + if (H5Sclose(fspace) < 0) + TEST_ERROR + if ((fspace = H5Dget_space(dset)) < 0) + TEST_ERROR /* Read some data and make sure it's the right value */ - if((mspace = H5Screate_simple(5, one, NULL)) < 0) TEST_ERROR - for(i = 0; i < 1000; i++) { + if ((mspace = H5Screate_simple(5, one, NULL)) < 0) + TEST_ERROR + for (i = 0; i < 1000; i++) { /* Set offset for random element */ - for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; - if(hs_offset[j] >= start_size[j]) - odd = 1; - else - odd += (unsigned)(hs_offset[j] % 2); - } /* end for */ + for (j = 0, odd = 0; j < 5; j++) { + hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; + if (hs_offset[j] >= start_size[j]) + odd = 1; + else + odd += (unsigned)(hs_offset[j] % 2); + } /* end for */ /* Select the random element */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + TEST_ERROR /* Read the random element */ - if(H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Verify the element read in */ - should_be = odd ? odd_val : even_val; - if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR + should_be = odd ? odd_val : even_val; + if (verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) + TEST_ERROR /* Release any VL components */ - if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Clear the read buffer */ HDmemset(val_rd, 0, val_size); } /* end for */ - if(H5Sclose(mspace) < 0) TEST_ERROR - + if (H5Sclose(mspace) < 0) + TEST_ERROR /* Extend the dataset to the maximum dimension sizes */ - if(H5Dset_extent(dset, max_size) < 0) TEST_ERROR + if (H5Dset_extent(dset, max_size) < 0) + TEST_ERROR /* Re-open file dataspace */ - if(H5Sclose(fspace) < 0) TEST_ERROR - if((fspace = H5Dget_space(dset)) < 0) TEST_ERROR - + if (H5Sclose(fspace) < 0) + TEST_ERROR + if ((fspace = H5Dget_space(dset)) < 0) + TEST_ERROR /* Read some data and make sure it's the right value */ - if((mspace = H5Screate_simple(5, one, NULL)) < 0) TEST_ERROR - for(i = 0; i < 1000; i++) { + if ((mspace = H5Screate_simple(5, one, NULL)) < 0) + TEST_ERROR + for (i = 0; i < 1000; i++) { /* Set offset for random element */ - for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % max_size[j]; - if(hs_offset[j] >= start_size[j]) - odd = 1; - else - odd += (unsigned)(hs_offset[j] % 2); - } /* end for */ + for (j = 0, odd = 0; j < 5; j++) { + hs_offset[j] = (hsize_t)HDrand() % max_size[j]; + if (hs_offset[j] >= start_size[j]) + odd = 1; + else + odd += (unsigned)(hs_offset[j] % 2); + } /* end for */ /* Select the random element */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + TEST_ERROR /* Read the random element */ - if(H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Verify the element read in */ - should_be = odd ? odd_val : even_val; - if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR + should_be = odd ? odd_val : even_val; + if (verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) + TEST_ERROR /* Release any VL components */ - if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Clear the read buffer */ HDmemset(val_rd, 0, val_size); } /* end for */ - if(H5Sclose(mspace) < 0) TEST_ERROR - + if (H5Sclose(mspace) < 0) + TEST_ERROR /* Shrink the dataset to half of it's maximum size, plus 1/2 of a chunk */ - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) extend_size[i] = (max_size[i] / 2) + (ch_size[i] / 2); - if(H5Dset_extent(dset, extend_size) < 0) TEST_ERROR + if (H5Dset_extent(dset, extend_size) < 0) + TEST_ERROR /* Re-open file dataspace */ - if(H5Sclose(fspace) < 0) TEST_ERROR - if((fspace = H5Dget_space(dset)) < 0) TEST_ERROR - + if (H5Sclose(fspace) < 0) + TEST_ERROR + if ((fspace = H5Dget_space(dset)) < 0) + TEST_ERROR /* Read some data and make sure it's the right value */ - if((mspace = H5Screate_simple(5, one, NULL)) < 0) TEST_ERROR - for(i = 0; i < 1000; i++) { + if ((mspace = H5Screate_simple(5, one, NULL)) < 0) + TEST_ERROR + for (i = 0; i < 1000; i++) { /* Set offset for random element */ - for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; - if(hs_offset[j] >= start_size[j]) - odd = 1; - else - odd += (unsigned)(hs_offset[j] % 2); - } /* end for */ + for (j = 0, odd = 0; j < 5; j++) { + hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; + if (hs_offset[j] >= start_size[j]) + odd = 1; + else + odd += (unsigned)(hs_offset[j] % 2); + } /* end for */ /* Select the random element */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + TEST_ERROR /* Read the random element */ - if(H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Verify the element read in */ - should_be = odd ? odd_val : even_val; - if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR + should_be = odd ? odd_val : even_val; + if (verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) + TEST_ERROR /* Release any VL components */ - if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Clear the read buffer */ HDmemset(val_rd, 0, val_size); } /* end for */ - if(H5Sclose(mspace) < 0) TEST_ERROR - + if (H5Sclose(mspace) < 0) + TEST_ERROR /* Extend the dataset's size by one element, in a dimension that won't * cause additional chunks to be needed */ extend_size[2] += 1; - if(H5Dset_extent(dset, extend_size) < 0) TEST_ERROR + if (H5Dset_extent(dset, extend_size) < 0) + TEST_ERROR /* Re-open file dataspace */ - if(H5Sclose(fspace) < 0) TEST_ERROR - if((fspace = H5Dget_space(dset)) < 0) TEST_ERROR - + if (H5Sclose(fspace) < 0) + TEST_ERROR + if ((fspace = H5Dget_space(dset)) < 0) + TEST_ERROR /* Create dataspace for single element sized bufer */ - if((mspace = H5Screate_simple(5, one, NULL)) < 0) TEST_ERROR + if ((mspace = H5Screate_simple(5, one, NULL)) < 0) + TEST_ERROR /* Set location for "top-most" element in dataset to write */ - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) hs_offset[i] = extend_size[i] - 1; /* Select the element */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + TEST_ERROR /* Write one element in a chunk that's 'partial' and overwrite a fill * value that was initialized in the H5Dset_extent() routine. This will @@ -1736,75 +1930,86 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, * next read of another fill-value initialized element in this chunk will * fail. */ - if(H5Dwrite(dset, dtype, mspace, fspace, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(dset, dtype, mspace, fspace, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* Read value back in */ - if(H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Verify the element read in is the value written out */ - if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, buf) < 0) TEST_ERROR + if (verify_rtn((unsigned)__LINE__, hs_offset, val_rd, buf) < 0) + TEST_ERROR /* Set the element back to fillval */ - if(H5Dwrite(dset, dtype, mspace, fspace, H5P_DEFAULT, fillval) < 0) TEST_ERROR + if (H5Dwrite(dset, dtype, mspace, fspace, H5P_DEFAULT, fillval) < 0) + TEST_ERROR /* Release any VL components */ - if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Clear the read buffer */ HDmemset(val_rd, 0, val_size); - /* Set location for another element initialized by H5Dset_extent() */ hs_offset[3] -= 1; /* Select the element */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + TEST_ERROR /* Read value back in */ - if(H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Verify the element read in is the fill-value */ - if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, fillval) < 0) TEST_ERROR + if (verify_rtn((unsigned)__LINE__, hs_offset, val_rd, fillval) < 0) + TEST_ERROR /* Release any VL components */ - if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Clear the read buffer */ HDmemset(val_rd, 0, val_size); - /* Read some data and make sure it's the right value */ - for(i = 0; i < 1000; i++) { + for (i = 0; i < 1000; i++) { /* Set offset for random element */ - for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; - if(hs_offset[j] >= start_size[j]) - odd = 1; - else - odd += (unsigned)(hs_offset[j] % 2); - } /* end for */ + for (j = 0, odd = 0; j < 5; j++) { + hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; + if (hs_offset[j] >= start_size[j]) + odd = 1; + else + odd += (unsigned)(hs_offset[j] % 2); + } /* end for */ /* Select the random element */ - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + TEST_ERROR /* Read the random element */ - if(H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Dread(dset, dtype, mspace, fspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Verify the element read in */ - should_be = odd ? odd_val : even_val; - if(verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) TEST_ERROR + should_be = odd ? odd_val : even_val; + if (verify_rtn((unsigned)__LINE__, hs_offset, val_rd, should_be) < 0) + TEST_ERROR /* Release any VL components */ - if(H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) TEST_ERROR + if (H5Treclaim(dtype, mspace, H5P_DEFAULT, val_rd) < 0) + TEST_ERROR /* Clear the read buffer */ HDmemset(val_rd, 0, val_size); } /* end for */ - if(H5Sclose(mspace) < 0) TEST_ERROR - + if (H5Sclose(mspace) < 0) + TEST_ERROR /* Release elements & memory buffer */ - for(i = 0; i < nelmts; i++) + for (i = 0; i < nelmts; i++) release_rtn((void *)((char *)buf + (val_size * i))); HDfree(init_val_c.a); @@ -1812,9 +2017,12 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, HDfree(buf); /* Cleanup IDs */ - if(H5Pclose(dcpl) < 0) TEST_ERROR - if(H5Dclose(dset) < 0) TEST_ERROR - if(H5Sclose(fspace) < 0) TEST_ERROR + if (H5Pclose(dcpl) < 0) + TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Sclose(fspace) < 0) + TEST_ERROR return 0; @@ -1823,17 +2031,18 @@ error: HDfree(init_val_c.b); HDfree(buf); - H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Dclose(dset); - H5Sclose(fspace); - H5Sclose(mspace); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(dcpl); + H5Dclose(dset); + H5Sclose(fspace); + H5Sclose(mspace); + } + H5E_END_TRY; return -1; } /* end test_extend_cases() */ - /*------------------------------------------------------------------------- * Function: test_extend * @@ -1853,34 +2062,36 @@ error: static int test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) { - hid_t file = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t cmpd_vl_tid = -1; /* Compound+vl datatype ID */ - hsize_t start_size[5] = {8, 8, 8, 4, 2}; - hsize_t max_size[5] = {32, 32, 32, 16, 8}; - hsize_t ch_size[5] = {1, 8, 8, 4, 2}; + hid_t file = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t cmpd_vl_tid = -1; /* Compound+vl datatype ID */ + hsize_t start_size[5] = {8, 8, 8, 4, 2}; + hsize_t max_size[5] = {32, 32, 32, 16, 8}; + hsize_t ch_size[5] = {1, 8, 8, 4, 2}; #ifdef NO_FILLING - int fillval_i = 0; + int fillval_i = 0; #else - int fillval_i = 0x4c70f1cd; + int fillval_i = 0x4c70f1cd; #endif - comp_vl_datatype fillval_c = {32, NULL, NULL, 64}; /* Fill value for compound+vl datatype tests */ - char filename[1024]; + comp_vl_datatype fillval_c = {32, NULL, NULL, 64}; /* Fill value for compound+vl datatype tests */ + char filename[1024]; /* Print testing message */ - if(H5D_CHUNKED == layout) - TESTING("chunked dataset extend") + if (H5D_CHUNKED == layout) + TESTING("chunked dataset extend") else - TESTING("contiguous dataset extend") + TESTING("contiguous dataset extend") /* Set vl datatype fill value strings */ fillval_c.a = HDstrdup("foo"); fillval_c.b = HDstrdup("bar"); /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5D_CHUNKED == layout) - if(H5Pset_chunk(dcpl, 5, ch_size) < 0) TEST_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5D_CHUNKED == layout) + if (H5Pset_chunk(dcpl, 5, ch_size) < 0) + TEST_ERROR #if 1 /* @@ -1893,14 +2104,13 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) * first dimension can be extendible' as long as the test isn't skipped * below. */ - if(H5D_CONTIGUOUS==layout) { - max_size[0] = (max_size[0] * max_size[1] * max_size[2] * - max_size[3] * max_size[4]) / - (start_size[1] * start_size[2] * start_size[3] * start_size[4]); - max_size[1] = start_size[1]; - max_size[2] = start_size[2]; - max_size[3] = start_size[3]; - max_size[4] = start_size[4]; + if (H5D_CONTIGUOUS == layout) { + max_size[0] = (max_size[0] * max_size[1] * max_size[2] * max_size[3] * max_size[4]) / + (start_size[1] * start_size[2] * start_size[3] * start_size[4]); + max_size[1] = start_size[1]; + max_size[2] = start_size[2]; + max_size[3] = start_size[3]; + max_size[4] = start_size[4]; } #endif @@ -1911,15 +2121,16 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) * `extendible contiguous non-external dataset' as long as the test isn't * skipped below. */ - if(H5D_CONTIGUOUS==layout) { - int fd; - hsize_t nelmts; + if (H5D_CONTIGUOUS == layout) { + int fd; + hsize_t nelmts; - nelmts = max_size[0]*max_size[1]*max_size[2]*max_size[3]*max_size[4]; - if((fd = HDopen(FILE_NAME_RAW, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0 || - HDclose(fd) < 0) goto error; - if(H5Pset_external(dcpl, FILE_NAME_RAW, (off_t)0, (hsize_t)nelmts*sizeof(int)) < 0) - goto error; + nelmts = max_size[0] * max_size[1] * max_size[2] * max_size[3] * max_size[4]; + if ((fd = HDopen(FILE_NAME_RAW, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0 || + HDclose(fd) < 0) + goto error; + if (H5Pset_external(dcpl, FILE_NAME_RAW, (off_t)0, (hsize_t)nelmts * sizeof(int)) < 0) + goto error; } #endif @@ -1930,32 +2141,37 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) * dimension. If it's removed prematurely then you'll get one of the * errors described above or `unable to select fill value region'. */ - if(H5D_CONTIGUOUS==layout) { - SKIPPED(); - puts(" Not implemented yet -- needs H5S_SELECT_DIFF operator"); - goto skip; + if (H5D_CONTIGUOUS == layout) { + SKIPPED(); + puts(" Not implemented yet -- needs H5S_SELECT_DIFF operator"); + goto skip; } #endif /* Create a file and dataset */ h5_fixname(base_name, fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Get the compound+vl datatype */ - if((cmpd_vl_tid = create_compound_vl_type()) < 0) TEST_ERROR + if ((cmpd_vl_tid = create_compound_vl_type()) < 0) + TEST_ERROR /* Test integer datatype case */ - if(test_extend_cases(file, dcpl, "dset1", ch_size, start_size, max_size, - H5T_NATIVE_INT, &fillval_i) < 0) TEST_ERROR + if (test_extend_cases(file, dcpl, "dset1", ch_size, start_size, max_size, H5T_NATIVE_INT, &fillval_i) < 0) + TEST_ERROR /* Test compound+vl datatype datatype case */ - if(test_extend_cases(file, dcpl, "dset2", ch_size, start_size, max_size, - cmpd_vl_tid, &fillval_c) < 0) TEST_ERROR + if (test_extend_cases(file, dcpl, "dset2", ch_size, start_size, max_size, cmpd_vl_tid, &fillval_c) < 0) + TEST_ERROR /* Cleanup */ - if(H5Tclose(cmpd_vl_tid) < 0) TEST_ERROR - if(H5Pclose(dcpl) < 0) TEST_ERROR - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Tclose(cmpd_vl_tid) < 0) + TEST_ERROR + if (H5Pclose(dcpl) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR HDfree(fillval_c.a); HDfree(fillval_c.b); @@ -1968,25 +2184,28 @@ error: HDfree(fillval_c.a); HDfree(fillval_c.b); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(cmpd_vl_tid); - H5Pclose(dcpl); - H5Fclose(file); - } H5E_END_TRY; + H5Pclose(dcpl); + H5Fclose(file); + } + H5E_END_TRY; return 1; skip: HDfree(fillval_c.a); HDfree(fillval_c.b); - H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Fclose(file); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(dcpl); + H5Fclose(file); + } + H5E_END_TRY; return 0; } /* end test_extend() */ - /*------------------------------------------------------------------------- * Function: test_compatible * @@ -2007,108 +2226,129 @@ skip: static int test_compatible(void) { - hid_t file=-1, dset1=-1, dset2=-1; - hid_t dcpl1=-1, dcpl2=-1, fspace=-1, mspace=-1; - int rd_fill=0, fill_val=4444, val_rd=0; - hsize_t dims[2], one[2]={1,1}; - hsize_t hs_offset[2]={3,4}; + hid_t file = -1, dset1 = -1, dset2 = -1; + hid_t dcpl1 = -1, dcpl2 = -1, fspace = -1, mspace = -1; + int rd_fill = 0, fill_val = 4444, val_rd = 0; + hsize_t dims[2], one[2] = {1, 1}; + hsize_t hs_offset[2] = {3, 4}; H5D_fill_value_t status; - const char *testfile = H5_get_srcdir_filename(FILE_COMPATIBLE); /* Corrected test file name */ + const char * testfile = H5_get_srcdir_filename(FILE_COMPATIBLE); /* Corrected test file name */ TESTING("contiguous dataset compatibility with v. 1.4"); - if((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { - HDprintf(" Could not open file %s. Try set $srcdir to point at the " - "source directory of test\n", testfile); - goto error; - } - - if((dset1 = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) goto error; - if((dcpl1 = H5Dget_create_plist(dset1)) < 0) goto error; - if(H5Pfill_value_defined(dcpl1, &status) < 0) goto error; - if(status != H5D_FILL_VALUE_UNDEFINED) { - H5_FAILED(); - HDprintf(" %d: Got a different fill value than what was set.",__LINE__); - HDprintf(" Got status=%ld, suppose to be H5D_FILL_VALUE_UNDEFINED\n", - (long)status); - goto error; - } - if((fspace = H5Dget_space(dset1)) < 0) goto error; - if(H5Sget_simple_extent_dims(fspace, dims, NULL) < 0) goto error; - if(dims[0] != 8 || dims[1] != 8) { - H5_FAILED(); - puts(" Got a different dimension size than what was set."); - HDprintf(" Got dims[0]=%ld, dims[1]=%ld, set 8x8\n", (long)dims[0], (long)dims[1]); - goto error; - } - if((mspace = H5Screate_simple(2, one, NULL)) < 0) goto error; - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) - goto error; - if(H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd) < 0) - goto error; - if(val_rd != 0) { - H5_FAILED(); - puts(" Got a different value than what was set."); - HDprintf(" Got %ld, set 0\n", (long)val_rd); - goto error; - } - if(H5Pclose(dcpl1) < 0) goto error; - if(H5Sclose(fspace) < 0) goto error; - if(H5Sclose(mspace) < 0) goto error; - if(H5Dclose(dset1) < 0) goto error; - - - if((dset2 = H5Dopen2(file, "dset2", H5P_DEFAULT)) < 0) goto error; - if((dcpl2 = H5Dget_create_plist(dset2)) < 0) goto error; - if(H5Pfill_value_defined(dcpl2, &status) < 0) goto error; - if(status != H5D_FILL_VALUE_USER_DEFINED) { - H5_FAILED(); - HDprintf(" %d: Got a different fill value than what was set.",__LINE__); - HDprintf(" Got status=%ld, suppose to be H5D_FILL_VALUE_USER_DEFINED\n", - (long)status); - goto error; - } - if(H5Pget_fill_value(dcpl2, H5T_NATIVE_INT, &rd_fill) < 0) goto error; - if(rd_fill != fill_val) { - H5_FAILED(); - HDprintf(" %d: Got a different fill value than what was set.",__LINE__); - HDprintf(" Got %ld, set %ld\n", (long)rd_fill, (long)fill_val); - goto error; - } - fspace = -1; - if((fspace = H5Dget_space(dset2)) < 0) goto error; - dims[0] = dims[1] = (hsize_t)-1; - if(H5Sget_simple_extent_dims(fspace, dims, NULL) < 0) goto error; - if(dims[0] != 8 || dims[1] != 8) { - H5_FAILED(); - puts(" Got a different dimension size than what was set."); - HDprintf(" Got dims[0]=%ld, dims[1]=%ld, set 8x8\n", (long)dims[0], (long)dims[1]); - goto error; - } - if((mspace=H5Screate_simple(2, one, NULL)) < 0) goto error; - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) - goto error; - if(H5Dread(dset2, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd) < 0) - goto error; - if(val_rd != fill_val) { - H5_FAILED(); - puts(" Got a different value than what was set."); - HDprintf(" Got %ld, set %ld\n", (long)val_rd, (long)fill_val); - goto error; - } - if(H5Pclose(dcpl2) < 0) goto error; - if(H5Sclose(fspace) < 0) goto error; - if(H5Sclose(mspace) < 0) goto error; - if(H5Dclose(dset2) < 0) goto error; - - if(H5Fclose(file) < 0) goto error; - - PASSED(); + if ((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + HDprintf(" Could not open file %s. Try set $srcdir to point at the " + "source directory of test\n", + testfile); + goto error; + } + + if ((dset1 = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl1 = H5Dget_create_plist(dset1)) < 0) + goto error; + if (H5Pfill_value_defined(dcpl1, &status) < 0) + goto error; + if (status != H5D_FILL_VALUE_UNDEFINED) { + H5_FAILED(); + HDprintf(" %d: Got a different fill value than what was set.", __LINE__); + HDprintf(" Got status=%ld, suppose to be H5D_FILL_VALUE_UNDEFINED\n", (long)status); + goto error; + } + if ((fspace = H5Dget_space(dset1)) < 0) + goto error; + if (H5Sget_simple_extent_dims(fspace, dims, NULL) < 0) + goto error; + if (dims[0] != 8 || dims[1] != 8) { + H5_FAILED(); + puts(" Got a different dimension size than what was set."); + HDprintf(" Got dims[0]=%ld, dims[1]=%ld, set 8x8\n", (long)dims[0], (long)dims[1]); + goto error; + } + if ((mspace = H5Screate_simple(2, one, NULL)) < 0) + goto error; + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + goto error; + if (H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd) < 0) + goto error; + if (val_rd != 0) { + H5_FAILED(); + puts(" Got a different value than what was set."); + HDprintf(" Got %ld, set 0\n", (long)val_rd); + goto error; + } + if (H5Pclose(dcpl1) < 0) + goto error; + if (H5Sclose(fspace) < 0) + goto error; + if (H5Sclose(mspace) < 0) + goto error; + if (H5Dclose(dset1) < 0) + goto error; + + if ((dset2 = H5Dopen2(file, "dset2", H5P_DEFAULT)) < 0) + goto error; + if ((dcpl2 = H5Dget_create_plist(dset2)) < 0) + goto error; + if (H5Pfill_value_defined(dcpl2, &status) < 0) + goto error; + if (status != H5D_FILL_VALUE_USER_DEFINED) { + H5_FAILED(); + HDprintf(" %d: Got a different fill value than what was set.", __LINE__); + HDprintf(" Got status=%ld, suppose to be H5D_FILL_VALUE_USER_DEFINED\n", (long)status); + goto error; + } + if (H5Pget_fill_value(dcpl2, H5T_NATIVE_INT, &rd_fill) < 0) + goto error; + if (rd_fill != fill_val) { + H5_FAILED(); + HDprintf(" %d: Got a different fill value than what was set.", __LINE__); + HDprintf(" Got %ld, set %ld\n", (long)rd_fill, (long)fill_val); + goto error; + } + fspace = -1; + if ((fspace = H5Dget_space(dset2)) < 0) + goto error; + dims[0] = dims[1] = (hsize_t)-1; + if (H5Sget_simple_extent_dims(fspace, dims, NULL) < 0) + goto error; + if (dims[0] != 8 || dims[1] != 8) { + H5_FAILED(); + puts(" Got a different dimension size than what was set."); + HDprintf(" Got dims[0]=%ld, dims[1]=%ld, set 8x8\n", (long)dims[0], (long)dims[1]); + goto error; + } + if ((mspace = H5Screate_simple(2, one, NULL)) < 0) + goto error; + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) + goto error; + if (H5Dread(dset2, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd) < 0) + goto error; + if (val_rd != fill_val) { + H5_FAILED(); + puts(" Got a different value than what was set."); + HDprintf(" Got %ld, set %ld\n", (long)val_rd, (long)fill_val); + goto error; + } + if (H5Pclose(dcpl2) < 0) + goto error; + if (H5Sclose(fspace) < 0) + goto error; + if (H5Sclose(mspace) < 0) + goto error; + if (H5Dclose(dset2) < 0) + goto error; + + if (H5Fclose(file) < 0) + goto error; + + PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl1); H5Sclose(fspace); H5Sclose(mspace); @@ -2117,7 +2357,8 @@ error: H5Sclose(fspace); H5Dclose(dset2); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -2144,37 +2385,38 @@ error: static int test_partalloc_cases(hid_t file, hid_t dcpl, const char *dname, H5D_fill_time_t fill_time) { - hid_t fspace=-1, dset1=-1, rspace = -1; - herr_t ret; - hsize_t ds_size[2] = {4, 4}; - hsize_t max_size[2] = {H5S_UNLIMITED,4}; - hsize_t chunk_size[2] = {1, 4}; - int fillval=(-1); - int w_values[] = {42}; /* New value to be written */ - int f_values[4] = {88,88,88,88}; /* pre-seed read buffer with known values */ - int r_values[4] = {88,88,88,88}; /* pre-seed read buffer with known values */ - hsize_t coord[1][2]; /* coordinate(s) of point to write */ + hid_t fspace = -1, dset1 = -1, rspace = -1; + herr_t ret; + hsize_t ds_size[2] = {4, 4}; + hsize_t max_size[2] = {H5S_UNLIMITED, 4}; + hsize_t chunk_size[2] = {1, 4}; + int fillval = (-1); + int w_values[] = {42}; /* New value to be written */ + int f_values[4] = {88, 88, 88, 88}; /* pre-seed read buffer with known values */ + int r_values[4] = {88, 88, 88, 88}; /* pre-seed read buffer with known values */ + hsize_t coord[1][2]; /* coordinate(s) of point to write */ hsize_t start[2], count[2]; - fillval = 0; /* default fill value is zero */ + fillval = 0; /* default fill value is zero */ /* Create dataset with 4x4 integer dataset */ - if((fspace = H5Screate_simple(2, ds_size, max_size)) < 0) + if ((fspace = H5Screate_simple(2, ds_size, max_size)) < 0) goto error; - if((dset1 = H5Dcreate2(file, dname, H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset1 = H5Dcreate2(file, dname, H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* * Select a point in the file dataspace. */ - coord[0][0]=0; coord[0][1]=0; - if (H5Sselect_elements( fspace, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord)) + coord[0][0] = 0; + coord[0][1] = 0; + if (H5Sselect_elements(fspace, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord)) goto error; /* * Write single data point to the dataset. */ - if ((ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, fspace, H5P_DEFAULT, w_values))< 0) { + if ((ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, fspace, H5P_DEFAULT, w_values)) < 0) { goto error; } @@ -2189,8 +2431,8 @@ test_partalloc_cases(hid_t file, hid_t dcpl, const char *dname, H5D_fill_time_t if ((ret = H5Sselect_hyperslab(fspace, H5S_SELECT_SET, start, NULL, count, NULL)) < 0) goto error; if ((ret = H5Sselect_all(rspace)) < 0) - goto error; - if(H5Dread(dset1, H5T_NATIVE_INT, rspace, fspace, H5P_DEFAULT, &r_values) < 0) + goto error; + if (H5Dread(dset1, H5T_NATIVE_INT, rspace, fspace, H5P_DEFAULT, &r_values) < 0) goto error; /* Read the third row of elements: all fill */ @@ -2200,59 +2442,55 @@ test_partalloc_cases(hid_t file, hid_t dcpl, const char *dname, H5D_fill_time_t count[1] = 4; if ((ret = H5Sselect_hyperslab(fspace, H5S_SELECT_SET, start, NULL, count, NULL)) < 0) goto error; - if(H5Dread(dset1, H5T_NATIVE_INT, rspace, fspace, H5P_DEFAULT, &f_values) < 0) + if (H5Dread(dset1, H5T_NATIVE_INT, rspace, fspace, H5P_DEFAULT, &f_values) < 0) goto error; - if(fill_time != H5D_FILL_TIME_NEVER) { + if (fill_time != H5D_FILL_TIME_NEVER) { /* check allocated chunk */ - if ((r_values[0] != w_values[0]) || - (r_values[1] != fillval) || - (r_values[2] != fillval) || - (r_values[3] != fillval)) { + if ((r_values[0] != w_values[0]) || (r_values[1] != fillval) || (r_values[2] != fillval) || + (r_values[3] != fillval)) { H5_FAILED(); HDfprintf(stdout, "%u: Allocated chunk value read was not correct.\n", (unsigned)__LINE__); - HDprintf(" {%ld,%ld,%ld,%ld} should be {%ld,%ld,%ld,%ld}\n", - (long)r_values[0], (long)r_values[1], - (long)r_values[2], (long)r_values[3], - (long)w_values[0], (long)fillval, - (long)fillval, (long)fillval ); + HDprintf(" {%ld,%ld,%ld,%ld} should be {%ld,%ld,%ld,%ld}\n", (long)r_values[0], + (long)r_values[1], (long)r_values[2], (long)r_values[3], (long)w_values[0], + (long)fillval, (long)fillval, (long)fillval); goto error; } /* check unallocated chunk */ - if ((f_values[0] != fillval) || - (f_values[1] != fillval) || - (f_values[2] != fillval) || - (f_values[3] != fillval)) { + if ((f_values[0] != fillval) || (f_values[1] != fillval) || (f_values[2] != fillval) || + (f_values[3] != fillval)) { H5_FAILED(); HDfprintf(stdout, "%u: Unallocated chunk value read was not correct.\n", (unsigned)__LINE__); - HDprintf(" {%ld,%ld,%ld,%ld} should be {%ld,%ld,%ld,%ld}\n", - (long)f_values[0], (long)f_values[1], - (long)f_values[2], (long)f_values[3], - (long)fillval, (long)fillval, - (long)fillval, (long)fillval ); + HDprintf(" {%ld,%ld,%ld,%ld} should be {%ld,%ld,%ld,%ld}\n", (long)f_values[0], + (long)f_values[1], (long)f_values[2], (long)f_values[3], (long)fillval, (long)fillval, + (long)fillval, (long)fillval); goto error; } /* for the "never fill" case expect to get trash values, so skip */ } - else if(fill_time == H5D_FILL_TIME_NEVER) { + else if (fill_time == H5D_FILL_TIME_NEVER) { } - if(H5Sclose(rspace) < 0) goto error; - if(H5Dclose(dset1) < 0) goto error; - if(H5Sclose(fspace) < 0) goto error; + if (H5Sclose(rspace) < 0) + goto error; + if (H5Dclose(dset1) < 0) + goto error; + if (H5Sclose(fspace) < 0) + goto error; return 0; - error: - H5E_BEGIN_TRY { - H5Dclose(dset1); - H5Sclose(fspace); - H5Sclose(rspace); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Dclose(dset1); + H5Sclose(fspace); + H5Sclose(rspace); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_partalloc * @@ -2271,117 +2509,134 @@ test_partalloc_cases(hid_t file, hid_t dcpl, const char *dname, H5D_fill_time_t static int test_partalloc(hid_t fapl, const char *base_name) { - char filename[1024]; - hid_t file=-1, dcpl=-1; - hsize_t ch_size[2] = {1, 4}; - int nerrors=0; + char filename[1024]; + hid_t file = -1, dcpl = -1; + hsize_t ch_size[2] = {1, 4}; + int nerrors = 0; TESTING("chunked dataset partially allocated I/O"); h5_fixname(base_name, fapl, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, ch_size) < 0) goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dcpl, 2, ch_size) < 0) + goto error; /* I. Test H5D_ALLOC_TIME_LATE space allocation cases */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) goto error; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, "\nALLOC_TIME_LATE\n" ); + HDfprintf(stdout, "\nALLOC_TIME_LATE\n"); #endif /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_ALLOC\n" ); + HDfprintf(stdout, " FILL_TIME_ALLOC\n"); #endif nerrors += test_partalloc_cases(file, dcpl, "dset1", H5D_FILL_TIME_ALLOC); /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_NEVER\n" ); + HDfprintf(stdout, " FILL_TIME_NEVER\n"); #endif - nerrors += test_partalloc_cases(file, dcpl, "dset2", H5D_FILL_TIME_NEVER ); + nerrors += test_partalloc_cases(file, dcpl, "dset2", H5D_FILL_TIME_NEVER); /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_IFSET\n" ); + HDfprintf(stdout, " FILL_TIME_IFSET\n"); #endif - nerrors += test_partalloc_cases(file, dcpl, "dset3", H5D_FILL_TIME_IFSET ); + nerrors += test_partalloc_cases(file, dcpl, "dset3", H5D_FILL_TIME_IFSET); /* II. Test H5D_ALLOC_TIME_INCR space allocation cases */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR) < 0) goto error; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, "\nALLOC_TIME_INCR\n" ); + HDfprintf(stdout, "\nALLOC_TIME_INCR\n"); #endif /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_ALLOC\n" ); + HDfprintf(stdout, " FILL_TIME_ALLOC\n"); #endif - nerrors += test_partalloc_cases(file, dcpl, "dset4", H5D_FILL_TIME_ALLOC ); + nerrors += test_partalloc_cases(file, dcpl, "dset4", H5D_FILL_TIME_ALLOC); /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_NEVER\n" ); + HDfprintf(stdout, " FILL_TIME_NEVER\n"); #endif - nerrors += test_partalloc_cases(file, dcpl, "dset5", H5D_FILL_TIME_NEVER ); + nerrors += test_partalloc_cases(file, dcpl, "dset5", H5D_FILL_TIME_NEVER); /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_IFSET\n" ); + HDfprintf(stdout, " FILL_TIME_IFSET\n"); #endif - nerrors += test_partalloc_cases(file, dcpl, "dset6", H5D_FILL_TIME_IFSET ); + nerrors += test_partalloc_cases(file, dcpl, "dset6", H5D_FILL_TIME_IFSET); /* III. Test H5D_ALLOC_TIME_EARLY space allocation cases */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto error; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, "\nALLOC_TIME_EARLY\n" ); + HDfprintf(stdout, "\nALLOC_TIME_EARLY\n"); #endif /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_ALLOC\n" ); + HDfprintf(stdout, " FILL_TIME_ALLOC\n"); #endif - nerrors += test_partalloc_cases(file, dcpl, "dset7", H5D_FILL_TIME_ALLOC ); + nerrors += test_partalloc_cases(file, dcpl, "dset7", H5D_FILL_TIME_ALLOC); /* case for H5D_FILL_TIME_NEVER as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_NEVER\n" ); + HDfprintf(stdout, " FILL_TIME_NEVER\n"); #endif - nerrors += test_partalloc_cases(file, dcpl, "dset8", H5D_FILL_TIME_NEVER ); + nerrors += test_partalloc_cases(file, dcpl, "dset8", H5D_FILL_TIME_NEVER); /* case for H5D_FILL_TIME_IFSET as fill write time and fill value to be default */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) + goto error; #ifdef DEBUG - HDfprintf( stdout, " FILL_TIME_IFSET\n" ); + HDfprintf(stdout, " FILL_TIME_IFSET\n"); #endif - nerrors += test_partalloc_cases(file, dcpl, "dset9", H5D_FILL_TIME_IFSET ); + nerrors += test_partalloc_cases(file, dcpl, "dset9", H5D_FILL_TIME_IFSET); - if(nerrors) - goto error; - if(H5Pclose(dcpl) < 0) goto error; - if(H5Fclose(file) < 0) goto error; + if (nerrors) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Fclose(file) < 0) + goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return nerrors; } - /*------------------------------------------------------------------------- * Function: main * @@ -2399,25 +2654,25 @@ test_partalloc(hid_t fapl, const char *base_name) int main(int argc, char *argv[]) { - int nerrors=0, argno, test_contig=1, test_chunk=1, test_compact=1; - hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */ - unsigned new_format; /* Whether to use the new format or not */ + int nerrors = 0, argno, test_contig = 1, test_chunk = 1, test_compact = 1; + hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */ + unsigned new_format; /* Whether to use the new format or not */ - if(argc >= 2) { + if (argc >= 2) { test_contig = test_chunk = test_compact = 0; - for(argno = 1; argno < argc; argno++) { - if(!strcmp(argv[argno], "contiguous")) + for (argno = 1; argno < argc; argno++) { + if (!strcmp(argv[argno], "contiguous")) test_contig = 1; - else if(!strcmp(argv[argno], "chunked")) + else if (!strcmp(argv[argno], "chunked")) test_chunk = 1; - else if(!strcmp(argv[argno], "compact")) - test_compact =1; + else if (!strcmp(argv[argno], "compact")) + test_compact = 1; else { HDfprintf(stderr, "usage: %s [contiguous] [chunked] [compact]\n", argv[0]); HDexit(EXIT_FAILURE); } } /* end for */ - } /* end if */ + } /* end if */ h5_reset(); fapl = h5_fileaccess(); @@ -2427,17 +2682,19 @@ main(int argc, char *argv[]) nerrors += test_getset_vl(fapl); /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl; /* Set the FAPL for the type of format */ - if(new_format) { + if (new_format) { puts("\nTesting with new file format:"); my_fapl = fapl2; } /* end if */ @@ -2447,27 +2704,27 @@ main(int argc, char *argv[]) } /* end else */ /* Chunked storage layout tests */ - if(test_chunk) { + if (test_chunk) { nerrors += test_create(my_fapl, FILENAME[0], H5D_CHUNKED); - nerrors += test_rdwr (my_fapl, FILENAME[2], H5D_CHUNKED); + nerrors += test_rdwr(my_fapl, FILENAME[2], H5D_CHUNKED); nerrors += test_extend(my_fapl, FILENAME[4], H5D_CHUNKED); nerrors += test_partalloc(my_fapl, FILENAME[8]); } /* end if */ /* Contiguous storage layout tests */ - if(test_contig) { + if (test_contig) { nerrors += test_create(my_fapl, FILENAME[1], H5D_CONTIGUOUS); - nerrors += test_rdwr (my_fapl, FILENAME[3], H5D_CONTIGUOUS); + nerrors += test_rdwr(my_fapl, FILENAME[3], H5D_CONTIGUOUS); nerrors += test_extend(my_fapl, FILENAME[5], H5D_CONTIGUOUS); nerrors += test_compatible(); } /* end if */ /* Compact dataset storage tests */ - if(test_compact) { + if (test_compact) { nerrors += test_create(my_fapl, FILENAME[6], H5D_COMPACT); - nerrors += test_rdwr (my_fapl, FILENAME[7], H5D_COMPACT); + nerrors += test_rdwr(my_fapl, FILENAME[7], H5D_COMPACT); } /* end if */ - } /* end for */ + } /* end for */ /* Close 2nd FAPL */ H5Pclose(fapl2); @@ -2475,11 +2732,11 @@ main(int argc, char *argv[]) /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if(nerrors) + if (nerrors) goto error; HDputs("All fill value tests passed."); - if(h5_cleanup(FILENAME, fapl)) + if (h5_cleanup(FILENAME, fapl)) HDremove(FILE_NAME_RAW); HDexit(EXIT_SUCCESS); @@ -2488,4 +2745,3 @@ error: HDputs("***** FILL VALUE TESTS FAILED *****"); HDexit(EXIT_FAILURE); } - diff --git a/test/filter_fail.c b/test/filter_fail.c index e5187be..e933a48 100644 --- a/test/filter_fail.c +++ b/test/filter_fail.c @@ -21,32 +21,27 @@ #include "h5test.h" -#define DSET_NAME "dset_fail" -#define H5Z_FILTER_FAIL_TEST 312 -#define DIM 10 -#define FILTER_CHUNK_DIM 2 +#define DSET_NAME "dset_fail" +#define H5Z_FILTER_FAIL_TEST 312 +#define DIM 10 +#define FILTER_CHUNK_DIM 2 -const char *FILENAME[] = { - "filter_fail_with_cache", - "filter_fail_without_cache", - NULL -}; +const char *FILENAME[] = {"filter_fail_with_cache", "filter_fail_without_cache", NULL}; -static size_t filter_fail(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_fail(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_FAIL_TEST[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_FAIL_TEST, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "filter_fail_test", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_fail, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_FAIL_TEST, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "filter_fail_test", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_fail, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: filter_fail * @@ -62,22 +57,22 @@ const H5Z_class2_t H5Z_FAIL_TEST[1] = {{ *------------------------------------------------------------------------- */ static size_t -filter_fail(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +filter_fail(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, const unsigned int H5_ATTR_UNUSED *cd_values, + size_t nbytes, size_t *buf_size, void **buf) { - int *dst = (int*)(*buf); - size_t ret_value = 0; + int * dst = (int *)(*buf); + size_t ret_value = 0; - if(flags & H5Z_FLAG_REVERSE) { /* do nothing during read */ + if (flags & H5Z_FLAG_REVERSE) { /* do nothing during read */ *buf_size = nbytes; ret_value = nbytes; - } /* end if */ + } /* end if */ else { /* Write data */ /* If it's the last chunk, pretend to fail. Otherwise, do nothing. */ - if(*dst == 8 || *dst == 9) { + if (*dst == 8 || *dst == 9) { ret_value = 0; - } else { + } + else { *buf_size = nbytes; ret_value = *buf_size; } @@ -86,7 +81,6 @@ filter_fail(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, return ret_value; } /* end filter_fail() */ - /*------------------------------------------------------------------------- * Function: test_filter_write_failure * @@ -114,104 +108,122 @@ filter_fail(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, static herr_t test_filter_write(char *file_name, hid_t my_fapl, hbool_t cache_enabled) { - hid_t file = -1; - hid_t dataset=-1; /* dataset ID */ - hid_t sid=-1; /* dataspace ID */ - hid_t dcpl=-1; /* dataset creation property list ID */ - hsize_t dims[1]={DIM}; /* dataspace dimension - 10*/ - hsize_t chunk_dims[1]={FILTER_CHUNK_DIM}; /* chunk dimension - 2*/ - int points[DIM]; /* Data */ - herr_t ret; /* generic return value */ - int i; - - if(cache_enabled) { + hid_t file = -1; + hid_t dataset = -1; /* dataset ID */ + hid_t sid = -1; /* dataspace ID */ + hid_t dcpl = -1; /* dataset creation property list ID */ + hsize_t dims[1] = {DIM}; /* dataspace dimension - 10*/ + hsize_t chunk_dims[1] = {FILTER_CHUNK_DIM}; /* chunk dimension - 2*/ + int points[DIM]; /* Data */ + herr_t ret; /* generic return value */ + int i; + + if (cache_enabled) { TESTING("data writing when a mandatory filter fails and chunk cache is enabled"); - } else { + } + else { TESTING("data writing when a mandatory filter fails and chunk cache is disabled"); } /* Create file */ - if((file = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((file = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* create the data space */ - if((sid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR /* Create dcpl and register the filter */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) TEST_ERROR + if (H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + TEST_ERROR - if(H5Zregister (H5Z_FAIL_TEST) < 0) TEST_ERROR + if (H5Zregister(H5Z_FAIL_TEST) < 0) + TEST_ERROR /* Check that the filter was registered */ - if(TRUE != H5Zfilter_avail(H5Z_FILTER_FAIL_TEST)) FAIL_STACK_ERROR + if (TRUE != H5Zfilter_avail(H5Z_FILTER_FAIL_TEST)) + FAIL_STACK_ERROR /* Enable the filter as mandatory */ - if(H5Pset_filter(dcpl, H5Z_FILTER_FAIL_TEST, 0, (size_t)0, NULL) < 0) + if (H5Pset_filter(dcpl, H5Z_FILTER_FAIL_TEST, 0, (size_t)0, NULL) < 0) TEST_ERROR /* create a dataset */ - if((dataset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dataset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR /* Initialize the write buffer */ - for(i = 0; i < DIM; i++) + for (i = 0; i < DIM; i++) points[i] = i; /* Write data. If the chunk cache is enabled, H5Dwrite should succeed. If it is * diabled, H5Dwrite should fail. */ - if(cache_enabled) { - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, points) < 0) + if (cache_enabled) { + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, points) < 0) TEST_ERROR - } else { + } + else { /* Data writing should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, points); - } H5E_END_TRY; - if(ret >= 0) { - H5_FAILED(); - puts(" Data writing is supposed to fail because the chunk can't be written to file."); - TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) { + H5_FAILED(); + puts(" Data writing is supposed to fail because the chunk can't be written to file."); + TEST_ERROR } } /* clean up objects used for this test */ - if(H5Pclose (dcpl) < 0) TEST_ERROR - if(H5Sclose (sid) < 0) TEST_ERROR + if (H5Pclose(dcpl) < 0) + TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR /* Close dataset. If the chunk cache is enabled, the flushing of chunks should fail * during H5Dclose. If it is diabled, H5Dwrite should fail but H5Dclose should succeed. */ - if(cache_enabled) { - H5E_BEGIN_TRY { - ret = H5Dclose (dataset); - } H5E_END_TRY; - if(ret >= 0) { - H5_FAILED(); - puts(" Dataset is supposed to fail because the chunk can't be flushed to file."); - TEST_ERROR + if (cache_enabled) { + H5E_BEGIN_TRY + { + ret = H5Dclose(dataset); } - } else { - if(H5Dclose (dataset) < 0) + H5E_END_TRY; + if (ret >= 0) { + H5_FAILED(); + puts(" Dataset is supposed to fail because the chunk can't be flushed to file."); + TEST_ERROR + } + } + else { + if (H5Dclose(dataset) < 0) TEST_ERROR } /* Even though H5Dclose or H5Dwrite fails, it should release all resources. * So the file should close successfully. */ - if(H5Fclose (file) < 0) TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(dataset); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_filter_write() */ - /*------------------------------------------------------------------------- * Function: test_filter_read * @@ -233,48 +245,53 @@ error: static herr_t test_filter_read(char *file_name, hid_t my_fapl) { - hid_t file = -1; - hid_t dataset=-1; /* dataset ID */ - hid_t sid = -1; - hid_t mspace = -1; - hsize_t dims[1]={DIM}; /* dataspace dimension - 10*/ - int rbuf[DIM]; /* Data */ - hsize_t dset_size = 0; /* Dataset storage size */ - hsize_t hs_offset[H5S_MAX_RANK]; - hsize_t hs_size[H5S_MAX_RANK]; - hsize_t stride[1] = {2}; - hsize_t zero[8]; - hsize_t nelmts = DIM/2; - int i; + hid_t file = -1; + hid_t dataset = -1; /* dataset ID */ + hid_t sid = -1; + hid_t mspace = -1; + hsize_t dims[1] = {DIM}; /* dataspace dimension - 10*/ + int rbuf[DIM]; /* Data */ + hsize_t dset_size = 0; /* Dataset storage size */ + hsize_t hs_offset[H5S_MAX_RANK]; + hsize_t hs_size[H5S_MAX_RANK]; + hsize_t stride[1] = {2}; + hsize_t zero[8]; + hsize_t nelmts = DIM / 2; + int i; TESTING("data reading when a mandatory filter fails"); /* Open file */ - if((file = H5Fopen(file_name, H5F_ACC_RDONLY, my_fapl)) < 0) TEST_ERROR + if ((file = H5Fopen(file_name, H5F_ACC_RDONLY, my_fapl)) < 0) + TEST_ERROR /* Open dataset */ - if((dataset = H5Dopen2(file, DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dataset = H5Dopen2(file, DSET_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR /* Verify the storage size is equal to 4 chunks */ - if((dset_size = H5Dget_storage_size(dataset)) == 0) TEST_ERROR + if ((dset_size = H5Dget_storage_size(dataset)) == 0) + TEST_ERROR - if(dset_size != 4 * FILTER_CHUNK_DIM * sizeof(int)) TEST_ERROR + if (dset_size != 4 * FILTER_CHUNK_DIM * sizeof(int)) + TEST_ERROR /* Read the chunks */ HDmemset(rbuf, 0, DIM * sizeof(int)); - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR /* Check that the values read are the same as the values written. * The last chunk should not be in the file. */ - for(i = 0; i < DIM; i++) { - if(i < DIM-2 && rbuf[i] != i) { + for (i = 0; i < DIM; i++) { + if (i < DIM - 2 && rbuf[i] != i) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d\n", i); HDprintf(" rbuf[%d]=%d\n", i, rbuf[i]); TEST_ERROR - } else if(i >= DIM-2 && rbuf[i] != 0) { + } + else if (i >= DIM - 2 && rbuf[i] != 0) { H5_FAILED(); HDprintf(" No value should be read.\n"); HDprintf(" At index %d\n", i); @@ -284,37 +301,40 @@ test_filter_read(char *file_name, hid_t my_fapl) } /* Try to read in hyperslab simulating the h5dump's way of printing data */ - if((sid = H5Dget_space(dataset)) < 0) TEST_ERROR + if ((sid = H5Dget_space(dataset)) < 0) + TEST_ERROR HDmemset(hs_offset, 0, sizeof(hs_offset)); - HDmemset(hs_size, 0, sizeof(hs_size)); - hs_size[0] = DIM/2; + HDmemset(hs_size, 0, sizeof(hs_size)); + hs_size[0] = DIM / 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, stride, hs_size, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, stride, hs_size, NULL) < 0) TEST_ERROR /* create the data space */ - if((mspace = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR + if ((mspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR HDmemset(zero, 0, sizeof zero); - if(H5Sselect_hyperslab(mspace, H5S_SELECT_SET, zero, stride, &nelmts, NULL) < 0) + if (H5Sselect_hyperslab(mspace, H5S_SELECT_SET, zero, stride, &nelmts, NULL) < 0) TEST_ERROR HDmemset(rbuf, 0, DIM * sizeof(int)); - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR /* Check that the values read are the same as the values written. * The last chunk should not be in the file. */ - for(i = 0; i < DIM; i+=2) { - if(i < DIM-2 && rbuf[i] != i) { + for (i = 0; i < DIM; i += 2) { + if (i < DIM - 2 && rbuf[i] != i) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d\n", i); HDprintf(" rbuf[%d]=%d\n", i, rbuf[i]); TEST_ERROR - } else if(i >= DIM-2 && rbuf[i] != 0) { + } + else if (i >= DIM - 2 && rbuf[i] != 0) { H5_FAILED(); HDprintf(" No value should be read.\n"); HDprintf(" At index %d\n", i); @@ -323,21 +343,27 @@ test_filter_read(char *file_name, hid_t my_fapl) } } - if(H5Sclose (sid) < 0) TEST_ERROR - if(H5Sclose (mspace) < 0) TEST_ERROR - if(H5Dclose (dataset) < 0) TEST_ERROR - if(H5Fclose (file) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR + if (H5Sclose(mspace) < 0) + TEST_ERROR + if (H5Dclose(dataset) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Sclose(mspace); H5Dclose(dataset); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_filter_read() */ @@ -357,13 +383,13 @@ error: int main(void) { - hid_t fapl; - int mdc_nelmts = 0; - size_t rdcc_nelmts = 0; - size_t rdcc_nbytes = 0; - double rdcc_w0 = 0; - char filename[1024]; - unsigned nerrors = 0; + hid_t fapl; + int mdc_nelmts = 0; + size_t rdcc_nelmts = 0; + size_t rdcc_nbytes = 0; + double rdcc_w0 = 0; + char filename[1024]; + unsigned nerrors = 0; h5_reset(); fapl = h5_fileaccess(); @@ -372,19 +398,19 @@ main(void) /* The chunk cache is used so that the flushing of data chunks happens * during H5Dclose. All values are default. */ - nerrors += (test_filter_write(filename, fapl, TRUE) < 0 ? 1 : 0); - nerrors += (test_filter_read(filename, fapl) < 0 ? 1 : 0); + nerrors += (test_filter_write(filename, fapl, TRUE) < 0 ? 1 : 0); + nerrors += (test_filter_read(filename, fapl) < 0 ? 1 : 0); h5_fixname(FILENAME[1], fapl, filename, sizeof filename); /* Disable the chunk cache so that the writing of data chunks happens * during H5Dwrite. */ - if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + if (H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) TEST_ERROR /* Run the test again. */ - nerrors += (test_filter_write(filename, fapl, FALSE) < 0 ? 1 : 0); - nerrors += (test_filter_read(filename, fapl) < 0 ? 1 : 0); + nerrors += (test_filter_write(filename, fapl, FALSE) < 0 ? 1 : 0); + nerrors += (test_filter_read(filename, fapl) < 0 ? 1 : 0); /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); @@ -392,16 +418,17 @@ main(void) h5_cleanup(FILENAME, fapl); /* Make sure we can close the library */ - if(H5close() < 0) TEST_ERROR + if (H5close() < 0) + TEST_ERROR - if (nerrors) TEST_ERROR + if (nerrors) + TEST_ERROR HDexit(EXIT_SUCCESS); error: if (nerrors) { - HDprintf("***** %u FAILURE%s! *****\n", - nerrors, 1==nerrors?"":"S"); + HDprintf("***** %u FAILURE%s! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } } /* end main() */ diff --git a/test/filter_plugin.c b/test/filter_plugin.c index 9897c84..61518f7 100644 --- a/test/filter_plugin.c +++ b/test/filter_plugin.c @@ -25,55 +25,50 @@ #include "H5Zpkg.h" /* Filters IDs for test filter plugins */ -#define FILTER1_ID 257 -#define FILTER2_ID 258 -#define FILTER3_ID 259 -#define FILTER4_ID 260 +#define FILTER1_ID 257 +#define FILTER2_ID 258 +#define FILTER3_ID 259 +#define FILTER4_ID 260 -const char *FILENAME[] = { - "filter_plugin", - NULL -}; -#define FILENAME_BUF_SIZE 1024 +const char *FILENAME[] = {"filter_plugin", NULL}; +#define FILENAME_BUF_SIZE 1024 /* Dataset names */ -#define DSET_DEFLATE_NAME "deflate dset" -#define DSET_FILTER1_NAME "filter 1 dset" -#define DSET_FILTER2_NAME "filter 2 dset" -#define DSET_FILTER3_NAME "filter 3 dset" +#define DSET_DEFLATE_NAME "deflate dset" +#define DSET_FILTER1_NAME "filter 1 dset" +#define DSET_FILTER2_NAME "filter 2 dset" +#define DSET_FILTER3_NAME "filter 3 dset" /* Array sizes used throughout the test */ -#define DSET_DIM1 100 -#define DSET_DIM2 200 -#define CHUNK_DIM1 2 -#define CHUNK_DIM2 25 -#define HYPERSLAB_OFFSET1 7 -#define HYPERSLAB_OFFSET2 30 -#define HYPERSLAB_SIZE1 4 -#define HYPERSLAB_SIZE2 50 +#define DSET_DIM1 100 +#define DSET_DIM2 200 +#define CHUNK_DIM1 2 +#define CHUNK_DIM2 25 +#define HYPERSLAB_OFFSET1 7 +#define HYPERSLAB_OFFSET2 30 +#define HYPERSLAB_SIZE1 4 +#define HYPERSLAB_SIZE2 50 /* Global size arrays */ -const hsize_t sizes_g[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ -const hsize_t hs_sizes_g[2] = {HYPERSLAB_SIZE1, HYPERSLAB_SIZE2}; /* Hyperslab sizes */ -const hsize_t hs_offsets_g[2] = {HYPERSLAB_OFFSET1, HYPERSLAB_OFFSET2}; /* Hyperslab offsets */ -const hsize_t chunk_sizes_g[2] = {CHUNK_DIM1, CHUNK_DIM2}; /* Chunk dimensions */ +const hsize_t sizes_g[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ +const hsize_t hs_sizes_g[2] = {HYPERSLAB_SIZE1, HYPERSLAB_SIZE2}; /* Hyperslab sizes */ +const hsize_t hs_offsets_g[2] = {HYPERSLAB_OFFSET1, HYPERSLAB_OFFSET2}; /* Hyperslab offsets */ +const hsize_t chunk_sizes_g[2] = {CHUNK_DIM1, CHUNK_DIM2}; /* Chunk dimensions */ /* Limit random number within 20000 */ -#define RANDOM_LIMIT 20000 +#define RANDOM_LIMIT 20000 /* Things used in the groups + filter plugins test */ -#define N_SUBGROUPS 1000 -#define SUBGROUP_PREFIX "subgroup_" -#define TOP_LEVEL_GROUP_NAME "top-level group" +#define N_SUBGROUPS 1000 +#define SUBGROUP_PREFIX "subgroup_" +#define TOP_LEVEL_GROUP_NAME "top-level group" /* Global arrays in which to save data */ -int **orig_deflate_g = NULL; -int **orig_dynlib1_g = NULL; -int **orig_dynlib2_g = NULL; -int **orig_dynlib4_g = NULL; +int **orig_deflate_g = NULL; +int **orig_dynlib1_g = NULL; +int **orig_dynlib2_g = NULL; +int **orig_dynlib4_g = NULL; - - /*------------------------------------------------------------------------- * Function: free_2D_array * @@ -85,7 +80,8 @@ int **orig_dynlib4_g = NULL; *------------------------------------------------------------------------- */ static herr_t -free_2D_array(int ***arr) { +free_2D_array(int ***arr) +{ if (arr && *arr && (*arr)[0]) HDfree((*arr)[0]); @@ -96,7 +92,6 @@ free_2D_array(int ***arr) { return SUCCEED; } /* end free_2D_array() */ - /*------------------------------------------------------------------------- * Function: allocate_and_init_2D_array * @@ -108,11 +103,12 @@ free_2D_array(int ***arr) { *------------------------------------------------------------------------- */ static herr_t -allocate_and_init_2D_array(int ***arr, const hsize_t *sizes, int **initial_values) { +allocate_and_init_2D_array(int ***arr, const hsize_t *sizes, int **initial_values) +{ - size_t r, c; /* Data rows and columns */ - size_t i; /* Iterator */ - size_t n_bytes; /* # of bytes to copy */ + size_t r, c; /* Data rows and columns */ + size_t i; /* Iterator */ + size_t n_bytes; /* # of bytes to copy */ r = (size_t)sizes[0]; c = (size_t)sizes[1]; @@ -138,7 +134,6 @@ error: return FAIL; } /* end allocate_and_init_2D_array() */ - /*------------------------------------------------------------------------- * Function: compare_2D_arrays * @@ -149,8 +144,9 @@ error: *------------------------------------------------------------------------- */ static herr_t -compare_2D_arrays(int **dset1, int **dset2, const hsize_t *sizes, /*OUT*/ hbool_t *are_same) { - hsize_t i, j; /* index variables */ +compare_2D_arrays(int **dset1, int **dset2, const hsize_t *sizes, /*OUT*/ hbool_t *are_same) +{ + hsize_t i, j; /* index variables */ *are_same = TRUE; @@ -168,7 +164,6 @@ compare_2D_arrays(int **dset1, int **dset2, const hsize_t *sizes, /*OUT*/ hbool_ } /* end compare_2D_arrays() */ - /*------------------------------------------------------------------------- * Function: ensure_filter_works * @@ -181,19 +176,19 @@ compare_2D_arrays(int **dset1, int **dset2, const hsize_t *sizes, /*OUT*/ hbool_ static herr_t ensure_filter_works(hid_t fid, const char *name, hid_t dcpl_id) { - hid_t did = -1; /* Dataset ID */ - hid_t dxpl_id = -1; /* Dataset xfer property list ID */ - hid_t write_dxpl_id = -1; /* Dataset xfer property list ID for writing */ - hid_t sid = -1; /* Dataspace ID */ - void *tconv_buf = NULL; /* Temporary conversion buffer */ - int **orig = NULL; /* Data written to the dataset */ - int **read = NULL; /* Data read from the dataset */ - size_t r, c; /* Data rows and columns */ - size_t hs_r, hs_c, hs_offr, hs_offc; /* Hypserslab sizes and offsets */ - size_t i, j; /* Local index variables */ - int n = 0; /* Value written to point array */ - hbool_t are_same; /* Output from dataset compare function */ - int ***save_array = NULL; /* (Global) array where the final data go */ + hid_t did = -1; /* Dataset ID */ + hid_t dxpl_id = -1; /* Dataset xfer property list ID */ + hid_t write_dxpl_id = -1; /* Dataset xfer property list ID for writing */ + hid_t sid = -1; /* Dataspace ID */ + void * tconv_buf = NULL; /* Temporary conversion buffer */ + int ** orig = NULL; /* Data written to the dataset */ + int ** read = NULL; /* Data read from the dataset */ + size_t r, c; /* Data rows and columns */ + size_t hs_r, hs_c, hs_offr, hs_offc; /* Hypserslab sizes and offsets */ + size_t i, j; /* Local index variables */ + int n = 0; /* Value written to point array */ + hbool_t are_same; /* Output from dataset compare function */ + int *** save_array = NULL; /* (Global) array where the final data go */ /* initialize */ r = (size_t)sizes_g[0]; @@ -348,8 +343,8 @@ ensure_filter_works(hid_t fid, const char *name, hid_t dcpl_id) */ TESTING(" filters (partial I/O)"); - hs_r = (size_t)hs_sizes_g[0]; - hs_c = (size_t)hs_sizes_g[1]; + hs_r = (size_t)hs_sizes_g[0]; + hs_c = (size_t)hs_sizes_g[1]; hs_offr = (size_t)hs_offsets_g[0]; hs_offc = (size_t)hs_offsets_g[1]; for (i = 0; i < hs_r; i++) @@ -411,12 +406,14 @@ ensure_filter_works(hid_t fid, const char *name, hid_t dcpl_id) error: /* Clean up objects used for this test */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); H5Pclose(dxpl_id); H5Pclose(write_dxpl_id); - } H5E_END_TRY + } + H5E_END_TRY /* NULLs are okay here */ free_2D_array(&orig); @@ -428,7 +425,6 @@ error: return FAIL; } /* end ensure_filter_works() */ - /*------------------------------------------------------------------------- * Function: test_dataset_write_with_filters * @@ -441,10 +437,10 @@ error: static herr_t test_dataset_write_with_filters(hid_t fid) { - hid_t dcpl_id = -1; /* Dataset creation property list ID */ - unsigned int compress_level; /* Deflate compression level */ - unsigned int filter1_data; /* Data used by filter 1 */ - unsigned int libver_values[4]; /* Used w/ the filter that makes HDF5 calls */ + hid_t dcpl_id = -1; /* Dataset creation property list ID */ + unsigned int compress_level; /* Deflate compression level */ + unsigned int filter1_data; /* Data used by filter 1 */ + unsigned int libver_values[4]; /* Used w/ the filter that makes HDF5 calls */ /*---------------------------------------------------------- * STEP 1: Test deflation by itself. @@ -467,7 +463,7 @@ test_dataset_write_with_filters(hid_t fid) /* Clean up objects used for this test */ if (H5Pclose(dcpl_id) < 0) TEST_ERROR; -#else /* H5_HAVE_FILTER_DEFLATE */ +#else /* H5_HAVE_FILTER_DEFLATE */ SKIPPED(); HDputs(" Deflate filter not enabled"); #endif /* H5_HAVE_FILTER_DEFLATE */ @@ -570,14 +566,15 @@ test_dataset_write_with_filters(hid_t fid) error: /* Clean up objects used for this test */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl_id); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end test_dataset_write_with_filters() */ - /*------------------------------------------------------------------------- * Function: test_read_data * @@ -590,9 +587,9 @@ error: static herr_t test_read_data(hid_t did, int *origin_data) { - int **check = NULL; - int *data_p = origin_data; - size_t i, j; /* Local index variables */ + int ** check = NULL; + int * data_p = origin_data; + size_t i, j; /* Local index variables */ if (allocate_and_init_2D_array(&check, sizes_g, NULL) < 0) TEST_ERROR; @@ -602,9 +599,9 @@ test_read_data(hid_t did, int *origin_data) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i = 0; i < sizes_g[0]; i++) - for(j = 0; j < sizes_g[1]; j++) { - if(*data_p != check[i][j]) + for (i = 0; i < sizes_g[0]; i++) + for (j = 0; j < sizes_g[1]; j++) { + if (*data_p != check[i][j]) TEST_ERROR data_p++; } @@ -621,8 +618,6 @@ error: return FAIL; } /* end test_read_data() */ - - /*------------------------------------------------------------------------- * Function: test_dataset_read_with_filters * @@ -636,7 +631,7 @@ error: static herr_t test_dataset_read_with_filters(hid_t fid) { - hid_t did = -1; /* Dataset ID */ + hid_t did = -1; /* Dataset ID */ /*---------------------------------------------------------- * STEP 1: Test deflation by itself. @@ -657,7 +652,7 @@ test_dataset_read_with_filters(hid_t fid) if (H5Dclose(did) < 0) TEST_ERROR; -#else /* H5_HAVE_FILTER_DEFLATE */ +#else /* H5_HAVE_FILTER_DEFLATE */ SKIPPED(); HDputs(" Deflate filter not enabled"); #endif /* H5_HAVE_FILTER_DEFLATE */ @@ -711,14 +706,15 @@ test_dataset_read_with_filters(hid_t fid) error: /* Clean up objects used for this test */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end test_dataset_read_with_filters() */ - /*------------------------------------------------------------------------- * Function: ensure_data_read_fails * @@ -731,17 +727,19 @@ error: static herr_t ensure_data_read_fails(hid_t did) { - int **check = NULL; - herr_t ret = FAIL; + int ** check = NULL; + herr_t ret = FAIL; if (allocate_and_init_2D_array(&check, sizes_g, NULL) < 0) TEST_ERROR; /* Read the dataset back (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, *check); - } H5E_END_TRY - if(ret >= 0) + } + H5E_END_TRY + if (ret >= 0) TEST_ERROR; free_2D_array(&check); @@ -755,7 +753,6 @@ error: return FAIL; } /* end ensure_data_read_fails() */ - /*------------------------------------------------------------------------- * Function: test_no_read_when_plugins_disabled * @@ -769,8 +766,8 @@ error: static herr_t test_no_read_when_plugins_disabled(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - unsigned plugin_flags; /* Plugin access flags */ + hid_t did = -1; /* Dataset ID */ + unsigned plugin_flags; /* Plugin access flags */ TESTING("filter plugin 1 with filter plugins disabled"); @@ -804,16 +801,17 @@ test_no_read_when_plugins_disabled(hid_t fid) error: /* Clean up objects used for this test */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN; H5PLset_loading_state(plugin_flags); H5Dclose(did); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end test_no_read_when_plugins_disabled() */ - /*------------------------------------------------------------------------- * Function: test_creating_groups_using_plugins * @@ -826,11 +824,11 @@ error: static herr_t test_creating_groups_using_plugins(hid_t fid) { - hid_t gcpl_id = -1; - hid_t gid = -1; - hid_t sub_gid = -1; - int i; - char subgroup_name[256]; + hid_t gcpl_id = -1; + hid_t gid = -1; + hid_t sub_gid = -1; + int i; + char subgroup_name[256]; TESTING("creating groups with filter plugin 4"); @@ -870,16 +868,17 @@ test_creating_groups_using_plugins(hid_t fid) error: /* Clean up objects used for this test */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(sub_gid); H5Gclose(gid); H5Pclose(gcpl_id); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end test_creating_groups_using_plugins() */ - /*------------------------------------------------------------------------- * Function: test_opening_groups_using_plugins * @@ -892,10 +891,10 @@ error: static herr_t test_opening_groups_using_plugins(hid_t fid) { - hid_t gid = -1; - hid_t sub_gid = -1; - int i; - char subgroup_name[256]; + hid_t gid = -1; + hid_t sub_gid = -1; + int i; + char subgroup_name[256]; TESTING("opening groups with filter plugin 4"); @@ -926,16 +925,16 @@ test_opening_groups_using_plugins(hid_t fid) error: /* Clean up objects used for this test */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Gclose(sub_gid); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end test_opening_groups_using_plugins() */ - - /*------------------------------------------------------------------------- * Function: test_path_api_calls * @@ -992,8 +991,8 @@ test_path_api_calls(void) /* Remove all existing paths */ for (u = n_paths; u > 0; u--) - if (H5PLremove(u-1) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); + if (H5PLremove(u - 1) < 0) { + HDfprintf(stderr, " at %u: %s\n", u, path); TEST_ERROR; } @@ -1005,19 +1004,19 @@ test_path_api_calls(void) PASSED(); - TESTING(" remove (index 0 in empty table)"); /* Try to remove index zero in an empty list (SHOULD FAIL) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5PLremove(0); - } H5E_END_TRY + } + H5E_END_TRY if (ret >= 0) TEST_ERROR; PASSED(); - /****************/ /* H5PLappend() */ /****************/ @@ -1028,14 +1027,13 @@ test_path_api_calls(void) for (u = 0; u < n_starting_paths; u++) { HDsprintf(path, "a_path_%u", u); if (H5PLappend(path) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); + HDfprintf(stderr, " at %u: %s\n", u, path); TEST_ERROR; } } PASSED(); - /**********************/ /* H5PLremove() again */ /**********************/ @@ -1043,16 +1041,17 @@ test_path_api_calls(void) TESTING(" remove (index too high)"); /* Try to remove a path where the index is beyond the table capacity (SHOULD FAIL) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5PLremove(n_starting_paths); - } H5E_END_TRY + } + H5E_END_TRY if (ret >= 0) TEST_ERROR PASSED(); - /*************/ /* H5PLget() */ /*************/ @@ -1061,7 +1060,7 @@ test_path_api_calls(void) /* Get the path length by passing in NULL */ if ((path_len = H5PLget(0, NULL, 0)) <= 0) { - HDfprintf(stderr," get path 0 length failed\n"); + HDfprintf(stderr, " get path 0 length failed\n"); TEST_ERROR; } if (path_len != 8) @@ -1069,24 +1068,23 @@ test_path_api_calls(void) /* Get the path */ if ((path_len = H5PLget(0, path, 256)) <= 0) { - HDfprintf(stderr," get 0 len: %u : %s\n", path_len, path); + HDfprintf(stderr, " get 0 len: %u : %s\n", path_len, path); TEST_ERROR; } if (HDstrcmp(path, "a_path_0") != 0) { - HDfprintf(stderr," get 0: %s\n", path); + HDfprintf(stderr, " get 0: %s\n", path); TEST_ERROR; } PASSED(); - TESTING(" get (high and low indices)"); /* Get path at index 1 */ if ((path_len = H5PLget(1, path, 256)) <= 0) TEST_ERROR; if (HDstrcmp(path, "a_path_1") != 0) { - HDfprintf(stderr," get 1: %s\n", path); + HDfprintf(stderr, " get 1: %s\n", path); TEST_ERROR; } @@ -1095,25 +1093,25 @@ test_path_api_calls(void) TEST_ERROR; HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1); if (HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get %u: %s\n", n_starting_paths - 1, path); + HDfprintf(stderr, " get %u: %s\n", n_starting_paths - 1, path); TEST_ERROR; } PASSED(); - TESTING(" get (index too high)"); /* Get path at the last + 1 index (SHOULD FAIL) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { path_len = H5PLget(n_starting_paths, NULL, 0); - } H5E_END_TRY + } + H5E_END_TRY if (path_len > 0) TEST_ERROR; PASSED(); - /*****************/ /* H5PLprepend() */ /*****************/ @@ -1132,7 +1130,7 @@ test_path_api_calls(void) if ((path_len = H5PLget(8, path, 256)) <= 0) TEST_ERROR; if (HDstrcmp(path, "a_path_9") != 0) { - HDfprintf(stderr," get 8: %s\n", path); + HDfprintf(stderr, " get 8: %s\n", path); TEST_ERROR; } @@ -1144,13 +1142,12 @@ test_path_api_calls(void) PASSED(); - TESTING(" prepend"); /* Prepend one path */ HDsprintf(path, "a_path_%d", n_starting_paths + 1); if (H5PLprepend(path) < 0) { - HDfprintf(stderr," prepend %u: %s\n", n_starting_paths + 1, path); + HDfprintf(stderr, " prepend %u: %s\n", n_starting_paths + 1, path); TEST_ERROR; } @@ -1164,7 +1161,7 @@ test_path_api_calls(void) if (H5PLget(8, path, 256) <= 0) TEST_ERROR; if (HDstrcmp(path, "a_path_7") != 0) { - HDfprintf(stderr," get 8: %s\n", path); + HDfprintf(stderr, " get 8: %s\n", path); TEST_ERROR; } @@ -1173,13 +1170,12 @@ test_path_api_calls(void) TEST_ERROR; HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1); if (HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get 0: %s\n", path); + HDfprintf(stderr, " get 0: %s\n", path); TEST_ERROR; } PASSED(); - /*****************/ /* H5PLreplace() */ /*****************/ @@ -1189,7 +1185,7 @@ test_path_api_calls(void) /* Replace one path at index 1 */ HDsprintf(path, "a_path_%u", n_starting_paths + 4); if (H5PLreplace(path, 1) < 0) { - HDfprintf(stderr," replace 1: %s\n", path); + HDfprintf(stderr, " replace 1: %s\n", path); TEST_ERROR; } @@ -1208,7 +1204,7 @@ test_path_api_calls(void) TEST_ERROR; HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1); if (HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get 0: %s\n", path); + HDfprintf(stderr, " get 0: %s\n", path); TEST_ERROR; } @@ -1216,13 +1212,12 @@ test_path_api_calls(void) if (H5PLget(2, path, 256) <= 0) TEST_ERROR; if (HDstrcmp(path, "a_path_1") != 0) { - HDfprintf(stderr," get 2: %s\n", path); + HDfprintf(stderr, " get 2: %s\n", path); TEST_ERROR; } PASSED(); - /****************/ /* H5PLinsert() */ /****************/ @@ -1241,7 +1236,7 @@ test_path_api_calls(void) if (H5PLget(4, path, 256) <= 0) TEST_ERROR; if (HDstrcmp(path, "a_path_4") != 0) { - HDfprintf(stderr," get 4: %s\n", path); + HDfprintf(stderr, " get 4: %s\n", path); TEST_ERROR; } @@ -1252,13 +1247,12 @@ test_path_api_calls(void) TEST_ERROR; PASSED(); - TESTING(" insert"); /* Insert one path at index 3*/ HDsprintf(path, "a_path_%d", n_starting_paths + 5); if (H5PLinsert(path, 3) < 0) { - HDfprintf(stderr," insert 3: %s\n", path); + HDfprintf(stderr, " insert 3: %s\n", path); TEST_ERROR; } @@ -1266,7 +1260,7 @@ test_path_api_calls(void) if (H5PLget(4, path, 256) <= 0) TEST_ERROR; if (HDstrcmp(path, "a_path_2") != 0) { - HDfprintf(stderr," get 4: %s\n", path); + HDfprintf(stderr, " get 4: %s\n", path); TEST_ERROR; } @@ -1278,7 +1272,6 @@ test_path_api_calls(void) PASSED(); - /****************/ /* H5PLremove() */ /****************/ @@ -1292,8 +1285,8 @@ test_path_api_calls(void) /* Remove all existing paths */ for (u = n_paths; u > 0; u--) - if (H5PLremove(u-1) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); + if (H5PLremove(u - 1) < 0) { + HDfprintf(stderr, " at %u: %s\n", u, path); TEST_ERROR; } @@ -1305,14 +1298,12 @@ test_path_api_calls(void) PASSED(); - return SUCCEED; error: return FAIL; } /* end test_path_api_calls() */ - /*------------------------------------------------------------------------- * Function: disable_chunk_cache * @@ -1323,11 +1314,12 @@ error: *------------------------------------------------------------------------- */ static herr_t -disable_chunk_cache(hid_t fapl_id) { - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; +disable_chunk_cache(hid_t fapl_id) +{ + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; if (H5Pget_cache(fapl_id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) TEST_ERROR; @@ -1340,7 +1332,6 @@ error: return FAIL; } /* end disable_chunk_cache() */ - /*------------------------------------------------------------------------- * Function: main * @@ -1353,12 +1344,12 @@ error: int main(void) { - char filename[FILENAME_BUF_SIZE]; - hid_t fid = -1; - hid_t old_ff_fapl_id = -1; - hid_t new_ff_fapl_id = -1; - unsigned new_format; - int nerrors = 0; + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; + hid_t old_ff_fapl_id = -1; + hid_t new_ff_fapl_id = -1; + unsigned new_format; + int nerrors = 0; /*******************************************************************/ /* ENSURE THAT WRITING TO DATASETS AND CREATING GROUPS WORKS */ @@ -1453,7 +1444,7 @@ main(void) nerrors += (test_dataset_read_with_filters(fid) < 0 ? 1 : 0); /* Test creating groups using dynamically-loaded plugin filters */ - nerrors += (test_opening_groups_using_plugins(fid) < 0 ? 1 : 0); + nerrors += (test_opening_groups_using_plugins(fid) < 0 ? 1 : 0); /* Close FAPLs */ if (H5Pclose(old_ff_fapl_id) < 0) @@ -1493,9 +1484,9 @@ main(void) TEST_ERROR; /* When filters are disabled, make sure we can't read data from a - * dataset that requires a filter plugin. - */ - nerrors += (test_no_read_when_plugins_disabled(fid) < 0 ? 1 : 0); + * dataset that requires a filter plugin. + */ + nerrors += (test_no_read_when_plugins_disabled(fid) < 0 ? 1 : 0); if (H5Fclose(fid) < 0) TEST_ERROR; @@ -1530,7 +1521,7 @@ main(void) /************************************/ /* Test the APIs for access to the filter plugin path table */ - nerrors += (test_path_api_calls() < 0 ? 1 : 0); + nerrors += (test_path_api_calls() < 0 ? 1 : 0); if (nerrors) TEST_ERROR; @@ -1540,11 +1531,13 @@ main(void) HDexit(EXIT_SUCCESS); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(old_ff_fapl_id); H5Pclose(new_ff_fapl_id); - } H5E_END_TRY + } + H5E_END_TRY /* Free up saved arrays (NULLs okay) */ free_2D_array(&orig_deflate_g); @@ -1556,4 +1549,3 @@ error: HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/filter_plugin1_dsets.c b/test/filter_plugin1_dsets.c index a9a53ae..9810678 100644 --- a/test/filter_plugin1_dsets.c +++ b/test/filter_plugin1_dsets.c @@ -14,33 +14,39 @@ * Purpose: Test dataset filter plugin for the filter_pluging.c test. */ - #include #include #include "H5PLextern.h" -#define FILTER1_ID 257 +#define FILTER1_ID 257 -static size_t add_sub_value(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t add_sub_value(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* Filter class struct */ const H5Z_class2_t FILTER_INFO[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER1_ID, /* Filter ID number */ - 1, /* Encoding enabled */ - 1, /* Decoding enabled */ - "test filter plugin 1", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)add_sub_value, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER1_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 1", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)add_sub_value, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return FILTER_INFO;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return FILTER_INFO; +} - /*------------------------------------------------------------------------- * Function: add_sub_value * @@ -55,12 +61,12 @@ const void *H5PLget_plugin_info(void) {return FILTER_INFO;} *------------------------------------------------------------------------- */ static size_t -add_sub_value(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, - size_t nbytes, size_t *buf_size, void **buf) +add_sub_value(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 value = 0; /* Data value to add/subtract */ + int * int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int value = 0; /* Data value to add/subtract */ /* Check for the correct number of parameters */ if (0 == cd_nelmts) @@ -90,4 +96,3 @@ add_sub_value(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_value return nbytes; } /* end add_sub_value() */ - diff --git a/test/filter_plugin2_dsets.c b/test/filter_plugin2_dsets.c index 6a79148..425bf81 100644 --- a/test/filter_plugin2_dsets.c +++ b/test/filter_plugin2_dsets.c @@ -19,28 +19,35 @@ #include "H5PLextern.h" -#define FILTER2_ID 258 -#define MULTIPLIER 3 +#define FILTER2_ID 258 +#define MULTIPLIER 3 -static size_t mult_div_value(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t mult_div_value(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* Filter class struct */ const H5Z_class2_t FILTER_INFO[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER2_ID, /* Filter ID number */ - 1, /* Encoding enabled */ - 1, /* Decoding enabled */ - "test filter plugin 2", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)mult_div_value, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER2_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 2", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)mult_div_value, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return FILTER_INFO;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return FILTER_INFO; +} - /*------------------------------------------------------------------------- * Function: mult_div_value * @@ -55,11 +62,11 @@ const void *H5PLget_plugin_info(void) {return FILTER_INFO;} *------------------------------------------------------------------------- */ static size_t -mult_div_value(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) +mult_div_value(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) @@ -85,4 +92,3 @@ mult_div_value(unsigned int flags, size_t cd_nelmts, return nbytes; } /* end mult_div_value() */ - diff --git a/test/filter_plugin3_dsets.c b/test/filter_plugin3_dsets.c index b43020f..55f13ef 100644 --- a/test/filter_plugin3_dsets.c +++ b/test/filter_plugin3_dsets.c @@ -20,29 +20,37 @@ #include "H5PLextern.h" -#define FILTER3_ID 259 +#define FILTER3_ID 259 -#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) +#define PUSH_ERR(func, minor, str) \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) -static size_t add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* Filter class struct */ const H5Z_class2_t FILTER_INFO[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER3_ID, /* Filter ID number */ - 1, /* Encoding enabled */ - 1, /* Decoding enabled */ - "test filter plugin 3", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)add_sub_value_hdf5, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER3_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 3", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)add_sub_value_hdf5, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return FILTER_INFO;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return FILTER_INFO; +} - /*------------------------------------------------------------------------- * Function: add_sub_value_hdf5 * @@ -61,15 +69,15 @@ const void *H5PLget_plugin_info(void) {return FILTER_INFO;} *------------------------------------------------------------------------- */ static size_t -add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, - size_t nbytes, size_t *buf_size, void **buf) +add_sub_value_hdf5(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 value = 0; /* Data value to add/subtract */ - unsigned majnum = 0; /* Output data from the HDF5 library call */ - unsigned minnum = 0; - unsigned relnum = 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 value = 0; /* Data value to add/subtract */ + unsigned majnum = 0; /* Output data from the HDF5 library call */ + unsigned minnum = 0; + unsigned relnum = 0; /* Check for the library version. * We don't do anything with this information - it's just to ensure that @@ -116,4 +124,3 @@ add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_ return nbytes; } /* end add_sub_value_hdf5() */ - diff --git a/test/filter_plugin4_groups.c b/test/filter_plugin4_groups.c index 88ea20d..a342d54 100644 --- a/test/filter_plugin4_groups.c +++ b/test/filter_plugin4_groups.c @@ -20,29 +20,36 @@ #include "H5PLextern.h" -#define FILTER4_ID 260 -#define SUFFIX_LEN 8 -#define GROUP_SUFFIX ".h5group" +#define FILTER4_ID 260 +#define SUFFIX_LEN 8 +#define GROUP_SUFFIX ".h5group" -static size_t append_to_group_name(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t append_to_group_name(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* Filter class struct */ const H5Z_class2_t FILTER_INFO[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER4_ID, /* Filter ID number */ - 1, /* Encoding enabled */ - 1, /* Decoding enabled */ - "test filter plugin 4", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)append_to_group_name, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER4_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 4", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)append_to_group_name, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return FILTER_INFO;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return FILTER_INFO; +} - /*------------------------------------------------------------------------- * Function: append_to_group_name * @@ -57,10 +64,10 @@ const void *H5PLget_plugin_info(void) {return FILTER_INFO;} *------------------------------------------------------------------------- */ static size_t -append_to_group_name(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) +append_to_group_name(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - size_t new_name_size = 0; /* Return value */ + size_t new_name_size = 0; /* Return value */ /* Check for the correct number of parameters */ if (cd_nelmts > 0) @@ -75,8 +82,8 @@ append_to_group_name(unsigned int flags, size_t cd_nelmts, } else { /* WRITE - Append the suffix to the group name */ - void *outbuf = NULL; /* Pointer to new buffer */ - unsigned char *dst = NULL; /* Temporary pointer to destination buffer */ + void * outbuf = NULL; /* Pointer to new buffer */ + unsigned char *dst = NULL; /* Temporary pointer to destination buffer */ /* Get memory for the new, larger string buffer using the * library's memory allocator. @@ -95,12 +102,11 @@ append_to_group_name(unsigned int flags, size_t cd_nelmts, H5free_memory(*buf); /* Set return values */ - *buf_size = nbytes + SUFFIX_LEN; - *buf = outbuf; - outbuf = NULL; + *buf_size = nbytes + SUFFIX_LEN; + *buf = outbuf; + outbuf = NULL; new_name_size = *buf_size; } return new_name_size; } /* append_to_group_name() */ - diff --git a/test/flush1.c b/test/flush1.c index 04f24f7..f9c64a5 100644 --- a/test/flush1.c +++ b/test/flush1.c @@ -24,36 +24,27 @@ #include "h5test.h" /* This file needs to access the file driver testing code */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING -#include "H5FDpkg.h" /* File drivers */ - -const char *FILENAME[] = { - "flush", - "flush-swmr", - "noflush", - "noflush-swmr", - "flush_extend", - "flush_extend-swmr", - "noflush_extend", - "noflush_extend-swmr", - NULL -}; +#include "H5FDpkg.h" /* File drivers */ + +const char *FILENAME[] = {"flush", "flush-swmr", "noflush", + "noflush-swmr", "flush_extend", "flush_extend-swmr", + "noflush_extend", "noflush_extend-swmr", NULL}; /* Number and size of dataset dims, chunk size, etc. */ -#define NDIMS 1 -#define NELEMENTS 10000 -#define CHUNK_SIZE 25 -#define FIRST_DSET_NAME "dset1" -#define SECOND_DSET_NAME "dset2" +#define NDIMS 1 +#define NELEMENTS 10000 +#define CHUNK_SIZE 25 +#define FIRST_DSET_NAME "dset1" +#define SECOND_DSET_NAME "dset2" /* Number of sub-groups created in the containing group */ -#define NGROUPS 100 +#define NGROUPS 100 -static hid_t create_file(const char *filename, hid_t fapl_id, hbool_t swmr); +static hid_t create_file(const char *filename, hid_t fapl_id, hbool_t swmr); static herr_t add_dset_to_file(hid_t fid, const char *dset_name); - /*------------------------------------------------------------------------- * Function: create_file * @@ -70,49 +61,50 @@ static herr_t add_dset_to_file(hid_t fid, const char *dset_name); static hid_t create_file(const char *filename, hid_t fapl_id, hbool_t swmr) { - hid_t fid = -1; /* file ID */ - hid_t top_gid = -1; /* containing group ID */ - hid_t gid = -1; /* subgroup ID */ - char group_name[32]; /* group name */ - unsigned flags; /* file open flags */ - int i; /* iterator */ + hid_t fid = -1; /* file ID */ + hid_t top_gid = -1; /* containing group ID */ + hid_t gid = -1; /* subgroup ID */ + char group_name[32]; /* group name */ + unsigned flags; /* file open flags */ + int i; /* iterator */ flags = H5F_ACC_TRUNC | (swmr ? H5F_ACC_SWMR_WRITE : 0); - if((fid = H5Fcreate(filename, flags, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(filename, flags, H5P_DEFAULT, fapl_id)) < 0) STACK_ERROR /* Create a chunked dataset */ - if(add_dset_to_file(fid, FIRST_DSET_NAME) < 0) + if (add_dset_to_file(fid, FIRST_DSET_NAME) < 0) TEST_ERROR /* Create some groups */ - if((top_gid = H5Gcreate2(fid, "top_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((top_gid = H5Gcreate2(fid, "top_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) STACK_ERROR - for(i = 0; i < NGROUPS; i++) { + for (i = 0; i < NGROUPS; i++) { HDsprintf(group_name, "group%02d", i); - if((gid = H5Gcreate2(top_gid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(top_gid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) STACK_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) STACK_ERROR } /* end for */ - if(H5Gclose(top_gid) < 0) + if (H5Gclose(top_gid) < 0) STACK_ERROR return fid; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Gclose(gid); H5Gclose(top_gid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end create_file() */ - /*------------------------------------------------------------------------- * Function: add_dset_to_file * @@ -128,37 +120,37 @@ error: static herr_t add_dset_to_file(hid_t fid, const char *dset_name) { - hid_t dcpl_id = -1; /* dataset creation plist ID */ - hid_t sid = -1; /* dataspace ID */ - hid_t did = -1; /* dataset ID */ - int *data = NULL; /* data buffer */ - hsize_t dims[1] = {NELEMENTS}; /* size of dataset */ - hsize_t chunk_dims[1] = {CHUNK_SIZE}; /* chunk size */ - int i; /* iterator */ + hid_t dcpl_id = -1; /* dataset creation plist ID */ + hid_t sid = -1; /* dataspace ID */ + hid_t did = -1; /* dataset ID */ + int * data = NULL; /* data buffer */ + hsize_t dims[1] = {NELEMENTS}; /* size of dataset */ + hsize_t chunk_dims[1] = {CHUNK_SIZE}; /* chunk size */ + int i; /* iterator */ /* Create a chunked dataset */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) STACK_ERROR - if(H5Pset_chunk(dcpl_id, NDIMS, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, NDIMS, chunk_dims) < 0) STACK_ERROR - if((sid = H5Screate_simple(NDIMS, dims, NULL)) < 0) + if ((sid = H5Screate_simple(NDIMS, dims, NULL)) < 0) STACK_ERROR - if((did = H5Dcreate2(fid, dset_name, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, dset_name, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) STACK_ERROR /* Write some data */ - if(NULL == (data = (int *)HDcalloc((size_t)NELEMENTS, sizeof(int)))) + if (NULL == (data = (int *)HDcalloc((size_t)NELEMENTS, sizeof(int)))) STACK_ERROR - for(i = 0; i < NELEMENTS; i++) + for (i = 0; i < NELEMENTS; i++) data[i] = i; - if(H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) STACK_ERROR - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) STACK_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) STACK_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) STACK_ERROR HDfree(data); @@ -166,18 +158,19 @@ add_dset_to_file(hid_t fid, const char *dset_name) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl_id); H5Sclose(sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(data); return FAIL; } /* end add_dset_to_file() */ - /*------------------------------------------------------------------------- * Function: main * @@ -196,19 +189,19 @@ error: int main(void) { - char *driver = NULL; /* name of current VFD (from env var) */ - hbool_t vfd_supports_swmr; /* whether the current VFD supports SWMR */ - hid_t fid = -1; /* file ID */ - hid_t fapl_id = -1; /* file access proplist ID */ - char filename[1024]; /* filename */ - hbool_t use_swmr; /* whether or not to use SWMR I/O */ + char * driver = NULL; /* name of current VFD (from env var) */ + hbool_t vfd_supports_swmr; /* whether the current VFD supports SWMR */ + hid_t fid = -1; /* file ID */ + hid_t fapl_id = -1; /* file access proplist ID */ + char filename[1024]; /* filename */ + hbool_t use_swmr; /* whether or not to use SWMR I/O */ h5_reset(); - if((fapl_id = h5_fileaccess()) < 0) + if ((fapl_id = h5_fileaccess()) < 0) TEST_ERROR /* Check if the current VFD supports SWMR */ - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv("HDF5_DRIVER"); vfd_supports_swmr = H5FD__supports_swmr_test(driver); /*************************************************/ @@ -219,20 +212,20 @@ main(void) TESTING("H5Fflush (part1 with flush)"); h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); use_swmr = FALSE; - if((fid = create_file(filename, fapl_id, use_swmr)) < 0) + if ((fid = create_file(filename, fapl_id, use_swmr)) < 0) TEST_ERROR - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR PASSED(); /* Create a file and flush w/ SWMR I/O */ TESTING("H5Fflush (part1 with flush + SWMR)"); - if(vfd_supports_swmr) { + if (vfd_supports_swmr) { h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)); use_swmr = TRUE; - if((fid = create_file(filename, fapl_id, use_swmr)) < 0) + if ((fid = create_file(filename, fapl_id, use_swmr)) < 0) TEST_ERROR - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR PASSED(); } /* end if */ @@ -243,16 +236,16 @@ main(void) TESTING("H5Fflush (part1 without flush)"); h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename)); use_swmr = FALSE; - if((fid = create_file(filename, fapl_id, use_swmr)) < 0) + if ((fid = create_file(filename, fapl_id, use_swmr)) < 0) TEST_ERROR PASSED(); /* Create a file which will not be flushed w/ SWMR I/O */ TESTING("H5Fflush (part1 without flush + SWMR)"); - if(vfd_supports_swmr) { + if (vfd_supports_swmr) { h5_fixname(FILENAME[3], fapl_id, filename, sizeof(filename)); use_swmr = TRUE; - if((fid = create_file(filename, fapl_id, use_swmr)) < 0) + if ((fid = create_file(filename, fapl_id, use_swmr)) < 0) TEST_ERROR PASSED(); } /* end if */ @@ -263,28 +256,28 @@ main(void) TESTING("H5Fflush (part1 with flush and later addition and another flush)"); h5_fixname(FILENAME[4], fapl_id, filename, sizeof(filename)); use_swmr = FALSE; - if((fid = create_file(filename, fapl_id, use_swmr)) < 0) + if ((fid = create_file(filename, fapl_id, use_swmr)) < 0) TEST_ERROR - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR - if(add_dset_to_file(fid, SECOND_DSET_NAME) < 0) + if (add_dset_to_file(fid, SECOND_DSET_NAME) < 0) TEST_ERROR - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR PASSED(); /* Create a file, flush, add a dataset, flush w/ SWMR I/O */ TESTING("H5Fflush (part1 with flush and later addition and another flush + SWMR)"); - if(vfd_supports_swmr) { + if (vfd_supports_swmr) { h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename)); use_swmr = TRUE; - if((fid = create_file(filename, fapl_id, use_swmr)) < 0) + if ((fid = create_file(filename, fapl_id, use_swmr)) < 0) TEST_ERROR - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR - if(add_dset_to_file(fid, SECOND_DSET_NAME) < 0) + if (add_dset_to_file(fid, SECOND_DSET_NAME) < 0) TEST_ERROR - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR PASSED(); } /* end if */ @@ -295,31 +288,31 @@ main(void) TESTING("H5Fflush (part1 with flush and later addition)"); h5_fixname(FILENAME[6], fapl_id, filename, sizeof(filename)); use_swmr = FALSE; - if((fid = create_file(filename, fapl_id, use_swmr)) < 0) + if ((fid = create_file(filename, fapl_id, use_swmr)) < 0) TEST_ERROR - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR - if(add_dset_to_file(fid, SECOND_DSET_NAME) < 0) + if (add_dset_to_file(fid, SECOND_DSET_NAME) < 0) TEST_ERROR PASSED(); /* Create a file, flush, add a dataset, (no flush) w/ SWMR I/O */ TESTING("H5Fflush (part1 with flush and later addition + SWMR)"); - if(vfd_supports_swmr) { + if (vfd_supports_swmr) { h5_fixname(FILENAME[7], fapl_id, filename, sizeof(filename)); use_swmr = TRUE; - if((fid = create_file(filename, fapl_id, use_swmr)) < 0) + if ((fid = create_file(filename, fapl_id, use_swmr)) < 0) TEST_ERROR - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR - if(add_dset_to_file(fid, SECOND_DSET_NAME) < 0) + if (add_dset_to_file(fid, SECOND_DSET_NAME) < 0) TEST_ERROR PASSED(); } /* end if */ else SKIPPED(); - if(!vfd_supports_swmr) + if (!vfd_supports_swmr) HDprintf("NOTE: Some tests were skipped since the current VFD lacks SWMR support\n"); /* Flush console output streams */ @@ -327,17 +320,18 @@ main(void) HDfflush(stderr); /* DO NOT CLOSE FILE ID! */ - if(H5Pclose(fapl_id) < 0) + if (H5Pclose(fapl_id) < 0) STACK_ERROR /* _exit() is necessary since we want a hard close of the library */ HD_exit(EXIT_SUCCESS); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/flush2.c b/test/flush2.c index 5fc716b..b1f5ebe 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -23,39 +23,29 @@ #include "h5test.h" /* This file needs to access the file driver testing code */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING -#include "H5FDpkg.h" /* File drivers */ +#include "H5FDpkg.h" /* File drivers */ /* Make this private property (defined in H5Fprivate.h) available */ /* This is used in the helper routine clear_status_flags() */ -#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" +#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" - -const char *FILENAME[] = { - "flush", - "flush-swmr", - "noflush", - "noflush-swmr", - "flush_extend", - "flush_extend-swmr", - "noflush_extend", - "noflush_extend-swmr", - NULL -}; +const char *FILENAME[] = {"flush", "flush-swmr", "noflush", + "noflush-swmr", "flush_extend", "flush_extend-swmr", + "noflush_extend", "noflush_extend-swmr", NULL}; /* Number and size of dataset dims, chunk size, etc. */ -#define NELEMENTS 10000 -#define FIRST_DSET_NAME "dset1" -#define SECOND_DSET_NAME "dset2" +#define NELEMENTS 10000 +#define FIRST_DSET_NAME "dset1" +#define SECOND_DSET_NAME "dset2" /* Number of sub-groups created in the containing group */ -#define NGROUPS 100 +#define NGROUPS 100 static hbool_t dset_ok(hid_t fid, const char *dset_name); static hbool_t file_ok(const char *filename, hid_t fapl_id, hbool_t check_second_dset); - /*------------------------------------------------------------------------- * Function: dset_ok * @@ -71,34 +61,34 @@ static hbool_t file_ok(const char *filename, hid_t fapl_id, hbool_t check_second static hbool_t dset_ok(hid_t fid, const char *dset_name) { - hid_t sid = -1; /* dataspace ID */ - hid_t did = -1; /* dataset ID */ - int *data = NULL; /* data buffer */ - hsize_t dims[1] = {0}; /* size of dataset */ - int i; /* iterator */ + hid_t sid = -1; /* dataspace ID */ + hid_t did = -1; /* dataset ID */ + int * data = NULL; /* data buffer */ + hsize_t dims[1] = {0}; /* size of dataset */ + int i; /* iterator */ /* Open the dataset and check size */ - if((did = H5Dopen2(fid, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dset_name, H5P_DEFAULT)) < 0) goto error; - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto error; - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto error; - if(dims[0] != NELEMENTS) + if (dims[0] != NELEMENTS) goto error; /* Read the data */ - if(NULL == (data = (int *)HDcalloc((size_t)NELEMENTS, sizeof(int)))) + if (NULL == (data = (int *)HDcalloc((size_t)NELEMENTS, sizeof(int)))) goto error; - if(H5Dread(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) + if (H5Dread(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) goto error; - for(i = 0; i < NELEMENTS; i++) - if(i != data[i]) + for (i = 0; i < NELEMENTS; i++) + if (i != data[i]) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; HDfree(data); @@ -106,17 +96,18 @@ dset_ok(hid_t fid, const char *dset_name) return TRUE; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(data); return FALSE; } /* end dset_ok() */ - /*------------------------------------------------------------------------- * Function: file_ok * @@ -132,47 +123,49 @@ error: static hbool_t file_ok(const char *filename, hid_t fapl_id, hbool_t check_second_dset) { - hid_t fid = -1; /* file ID */ - hid_t top_gid = -1; /* containing group ID */ - hid_t gid = -1; /* subgroup ID */ - char group_name[32]; /* group name */ - int i; /* iterator */ + hid_t fid = -1; /* file ID */ + hid_t top_gid = -1; /* containing group ID */ + hid_t gid = -1; /* subgroup ID */ + char group_name[32]; /* group name */ + int i; /* iterator */ /* open file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id)) < 0) goto error; /* check datasets */ - if(!dset_ok(fid, FIRST_DSET_NAME)) + if (!dset_ok(fid, FIRST_DSET_NAME)) goto error; - if(check_second_dset) - if(!dset_ok(fid, SECOND_DSET_NAME)) + if (check_second_dset) + if (!dset_ok(fid, SECOND_DSET_NAME)) goto error; /* check groups */ - if((top_gid = H5Gopen2(fid, "top_group", H5P_DEFAULT)) < 0) + if ((top_gid = H5Gopen2(fid, "top_group", H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < NGROUPS; i++) { + for (i = 0; i < NGROUPS; i++) { HDsprintf(group_name, "group%02d", i); - if((gid = H5Gopen2(top_gid, group_name, H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(top_gid, group_name, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; } /* end for */ - if(H5Gclose(top_gid) < 0) + if (H5Gclose(top_gid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; return TRUE; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(top_gid); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FALSE; } /* end file_ok() */ @@ -193,42 +186,43 @@ error: static herr_t clear_status_flags(const char *filename, hid_t fapl_id) { - hid_t new_fapl_id = -1; /* copy of the file access plist ID */ - hid_t fid = -1; /* file ID */ - hbool_t clear = TRUE; + hid_t new_fapl_id = -1; /* copy of the file access plist ID */ + hid_t fid = -1; /* file ID */ + hbool_t clear = TRUE; /* Get a copy of fapl */ - if((new_fapl_id = H5Pcopy(fapl_id)) < 0) + if ((new_fapl_id = H5Pcopy(fapl_id)) < 0) goto error; /* Set this private property */ - if(H5Pset(new_fapl_id, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) + if (H5Pset(new_fapl_id, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) goto error; /* Has to open rw */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, new_fapl_id)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, new_fapl_id)) < 0) goto error; /* CLose the property list */ - if(H5Pclose(new_fapl_id) < 0) + if (H5Pclose(new_fapl_id) < 0) goto error; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(new_fapl_id); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end clear_status_flags() */ - /*------------------------------------------------------------------------- * Function: main * @@ -245,19 +239,19 @@ error: int main(void) { - char *driver = NULL; /* name of current VFD (from env var) */ - hbool_t vfd_supports_swmr; /* whether the current VFD supports SWMR */ - hid_t fapl_id = -1; /* file access proplist ID */ - char filename[1024]; /* filename */ - hbool_t check_second_dset; /* whether or not to check the second dset */ - H5E_auto2_t func; /* for shutting off error reporting */ + char * driver = NULL; /* name of current VFD (from env var) */ + hbool_t vfd_supports_swmr; /* whether the current VFD supports SWMR */ + hid_t fapl_id = -1; /* file access proplist ID */ + char filename[1024]; /* filename */ + hbool_t check_second_dset; /* whether or not to check the second dset */ + H5E_auto2_t func; /* for shutting off error reporting */ h5_reset(); - if((fapl_id = h5_fileaccess()) < 0) + if ((fapl_id = h5_fileaccess()) < 0) PUTS_ERROR("bad vfd-dependent fapl") /* Check if the current VFD supports SWMR */ - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv("HDF5_DRIVER"); vfd_supports_swmr = H5FD__supports_swmr_test(driver); /* TEST 1 */ @@ -265,7 +259,7 @@ main(void) TESTING("H5Fflush (part2 with flush)"); h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); check_second_dset = FALSE; - if(file_ok(filename, fapl_id, check_second_dset)) + if (file_ok(filename, fapl_id, check_second_dset)) PASSED(); else TEST_ERROR @@ -273,12 +267,12 @@ main(void) /* TEST 2 */ /* Check the case where the file was flushed (w/SWMR) */ TESTING("H5Fflush (part2 with flush + SWMR)"); - if(vfd_supports_swmr) { + if (vfd_supports_swmr) { h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)); check_second_dset = FALSE; - if(clear_status_flags(filename, fapl_id) < 0) + if (clear_status_flags(filename, fapl_id) < 0) TEST_ERROR - if(file_ok(filename, fapl_id, check_second_dset)) + if (file_ok(filename, fapl_id, check_second_dset)) PASSED(); else TEST_ERROR @@ -290,14 +284,14 @@ main(void) /* Check the case where the file was not flushed */ TESTING("H5Fflush (part2 without flush)"); /* Turn the error stack off (failures expected) */ - if(H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0) + if (H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0) FAIL_STACK_ERROR - if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) FAIL_STACK_ERROR h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename)); check_second_dset = FALSE; - if(file_ok(filename, fapl_id, check_second_dset)) { -#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS) + if (file_ok(filename, fapl_id, check_second_dset)) { +#if defined H5_HAVE_WIN32_API && !defined(hdf5_EXPORTS) SKIPPED(); HDputs(" the DLL will flush the file even when calling _exit, skip this test temporarily"); #else @@ -307,24 +301,24 @@ main(void) else PASSED(); /* Turn the error stack back on */ - if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR /* TEST 4 */ /* Check the case where the file was not flushed (w/SWMR) */ TESTING("H5Fflush (part2 without flush + SWMR)"); - if(vfd_supports_swmr) { + if (vfd_supports_swmr) { /* Turn the error stack off (failures expected) */ - if(H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0) + if (H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0) FAIL_STACK_ERROR - if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) FAIL_STACK_ERROR h5_fixname(FILENAME[3], fapl_id, filename, sizeof(filename)); check_second_dset = FALSE; - if(clear_status_flags(filename, fapl_id) < 0) + if (clear_status_flags(filename, fapl_id) < 0) TEST_ERROR - if(file_ok(filename, fapl_id, check_second_dset)) { -#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS) + if (file_ok(filename, fapl_id, check_second_dset)) { +#if defined H5_HAVE_WIN32_API && !defined(hdf5_EXPORTS) SKIPPED(); HDputs(" the DLL will flush the file even when calling _exit, skip this test temporarily"); #else @@ -334,7 +328,7 @@ main(void) else PASSED(); /* Turn the error stack back on */ - if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR } /* end if */ else @@ -347,7 +341,7 @@ main(void) TESTING("H5Fflush (part2 with flush and later addition and another flush)"); check_second_dset = TRUE; h5_fixname(FILENAME[4], fapl_id, filename, sizeof(filename)); - if(file_ok(filename, fapl_id, check_second_dset)) + if (file_ok(filename, fapl_id, check_second_dset)) PASSED(); else TEST_ERROR @@ -357,12 +351,12 @@ main(void) * added afterward and then flushed (w/SWMR) */ TESTING("H5Fflush (part2 with flush and later addition and another flush + SWMR)"); - if(vfd_supports_swmr) { + if (vfd_supports_swmr) { check_second_dset = TRUE; h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename)); - if(clear_status_flags(filename, fapl_id) < 0) + if (clear_status_flags(filename, fapl_id) < 0) TEST_ERROR - if(file_ok(filename, fapl_id, check_second_dset)) + if (file_ok(filename, fapl_id, check_second_dset)) PASSED(); else TEST_ERROR @@ -376,14 +370,14 @@ main(void) */ TESTING("H5Fflush (part2 with flush and later addition)"); /* Turn the error stack off (failures expected) */ - if(H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0) + if (H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0) FAIL_STACK_ERROR - if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) FAIL_STACK_ERROR h5_fixname(FILENAME[6], fapl_id, filename, sizeof(filename)); check_second_dset = TRUE; - if(file_ok(filename, fapl_id, check_second_dset)) { -#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS) + if (file_ok(filename, fapl_id, check_second_dset)) { +#if defined H5_HAVE_WIN32_API && !defined(hdf5_EXPORTS) SKIPPED() HDputs(" the DLL will flush the file even when calling _exit, skip this test temporarily"); #else @@ -393,7 +387,7 @@ main(void) else PASSED(); /* Turn the error stack back on */ - if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR /* TEST 8 */ @@ -401,18 +395,18 @@ main(void) * afterward and not flushed (w/ SWMR). */ TESTING("H5Fflush (part2 with flush and later addition + SWMR)"); - if(vfd_supports_swmr) { + if (vfd_supports_swmr) { /* Turn the error stack off (failures expected) */ - if(H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0) + if (H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0) FAIL_STACK_ERROR - if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) FAIL_STACK_ERROR h5_fixname(FILENAME[7], fapl_id, filename, sizeof(filename)); check_second_dset = TRUE; - if(clear_status_flags(filename, fapl_id) < 0) + if (clear_status_flags(filename, fapl_id) < 0) TEST_ERROR - if(file_ok(filename, fapl_id, check_second_dset)) { -#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS) + if (file_ok(filename, fapl_id, check_second_dset)) { +#if defined H5_HAVE_WIN32_API && !defined(hdf5_EXPORTS) SKIPPED(); HDputs(" the DLL will flush the file even when calling _exit, skip this test temporarily"); #else @@ -422,13 +416,13 @@ main(void) else PASSED(); /* Turn the error stack back on */ - if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) + if (H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR } /* end if */ else SKIPPED() - if(!vfd_supports_swmr) + if (!vfd_supports_swmr) HDprintf("NOTE: Some tests were skipped since the current VFD lacks SWMR support\n"); h5_cleanup(FILENAME, fapl_id); @@ -438,4 +432,3 @@ main(void) error: HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/flushrefresh.c b/test/flushrefresh.c index 2db1d6b..798d45a 100644 --- a/test/flushrefresh.c +++ b/test/flushrefresh.c @@ -23,7 +23,7 @@ * */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING /* ======== */ @@ -31,7 +31,7 @@ /* ======== */ #include "testhdf5.h" -#include "H5FDpkg.h" /* File Drivers */ +#include "H5FDpkg.h" /* File Drivers */ /* ======= */ /* Defines */ @@ -41,10 +41,10 @@ #define FILENAME "flushrefresh.h5" /* Names of Signal Files */ -#define SIGNAL_TO_SCRIPT "flushrefresh_VERIFICATION_START" +#define SIGNAL_TO_SCRIPT "flushrefresh_VERIFICATION_START" #define SIGNAL_BETWEEN_PROCESSES_1 "flushrefresh_VERIFICATION_CHECKPOINT1" #define SIGNAL_BETWEEN_PROCESSES_2 "flushrefresh_VERIFICATION_CHECKPOINT2" -#define SIGNAL_FROM_SCRIPT "flushrefresh_VERIFICATION_DONE" +#define SIGNAL_FROM_SCRIPT "flushrefresh_VERIFICATION_DONE" /* Paths to Various Objects in the Testfile */ #define RG "/" @@ -59,7 +59,7 @@ #define T3 "/Group3/CommittedDatatype3" /* Flushed States */ -#define FLUSHED "FLUSHED" +#define FLUSHED "FLUSHED" #define NOT_FLUSHED "NOT_FLUSHED" /* Error Handling */ @@ -67,26 +67,26 @@ For errors occurring in the spawned process (from the test script), use the PROCESS_ERROR macro, which will send a signal to the main process so the main process can propogate errors correctly. */ -FILE * errorfile; +FILE *errorfile; #define ERRFILE "flushrefresh_ERROR" -#define PROCESS_ERROR \ - { \ - errorfile = HDfopen(ERRFILE, "w+"); \ - HDfprintf(errorfile, "Error occurred in flushrefresh.\n"); \ - HDfflush(errorfile); \ - HDfclose(errorfile); \ - TEST_ERROR; \ +#define PROCESS_ERROR \ + { \ + errorfile = HDfopen(ERRFILE, "w+"); \ + HDfprintf(errorfile, "Error occurred in flushrefresh.\n"); \ + HDfflush(errorfile); \ + HDfclose(errorfile); \ + TEST_ERROR; \ } -#define CLEANUP_FILES \ - { \ - HDremove(ERRFILE); \ - HDremove(FILENAME); \ - HDremove(SIGNAL_TO_SCRIPT); \ - HDremove(SIGNAL_BETWEEN_PROCESSES_1); \ - HDremove(SIGNAL_BETWEEN_PROCESSES_2); \ - HDremove(SIGNAL_FROM_SCRIPT); \ - } \ +#define CLEANUP_FILES \ + { \ + HDremove(ERRFILE); \ + HDremove(FILENAME); \ + HDremove(SIGNAL_TO_SCRIPT); \ + HDremove(SIGNAL_BETWEEN_PROCESSES_1); \ + HDremove(SIGNAL_BETWEEN_PROCESSES_2); \ + HDremove(SIGNAL_FROM_SCRIPT); \ + } /* ===================== */ /* Function Declarations */ @@ -97,13 +97,13 @@ int main(int argc, const char *argv[]); /* Flush Test Framework */ herr_t test_flush(void); -herr_t flush_verification(const char * obj_pathname, const char * expected); -herr_t run_flush_verification_process(const char * obj_pathname, const char * expected); +herr_t flush_verification(const char *obj_pathname, const char *expected); +herr_t run_flush_verification_process(const char *obj_pathname, const char *expected); /* Refresh Test Framework */ herr_t test_refresh(void); -herr_t refresh_verification(const char * obj_pathname); -herr_t start_refresh_verification_process(const char * obj_pathname); +herr_t refresh_verification(const char *obj_pathname); +herr_t start_refresh_verification_process(const char *obj_pathname); herr_t end_refresh_verification_process(void); /* Other Helper Functions */ @@ -114,7 +114,6 @@ herr_t end_verification(void); /* Functions */ /* ========= */ - /*------------------------------------------------------------------------- * Function: main * @@ -137,17 +136,18 @@ herr_t end_verification(void); * *------------------------------------------------------------------------- */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { /* Variables */ const char *envval = NULL; /* Initialize library */ - if(H5open() < 0) + if (H5open() < 0) TEST_ERROR; /* Parse command line options */ - if(argc == 1) { + if (argc == 1) { /* No arguments supplied. Run main test routines if * using sec2 or stdio driver, otherwise don't run * anything. */ @@ -155,25 +155,32 @@ int main(int argc, const char *argv[]) /* Determine driver being used */ envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL || H5FD__supports_swmr_test(envval)) { - if(test_flush() != SUCCEED) TEST_ERROR; - if(test_refresh() != SUCCEED) TEST_ERROR; + if (envval == NULL || H5FD__supports_swmr_test(envval)) { + if (test_flush() != SUCCEED) + TEST_ERROR; + if (test_refresh() != SUCCEED) + TEST_ERROR; } /* end if */ else { - HDfprintf(stdout, "Skipping all flush/refresh tests (only run with SWMR-enabled file drivers).\n"); + HDfprintf(stdout, + "Skipping all flush/refresh tests (only run with SWMR-enabled file drivers).\n"); /* Test script is expecting some signals, so send them out to end it. */ - if(end_verification() < 0) TEST_ERROR; - if(end_verification() < 0) TEST_ERROR; + if (end_verification() < 0) + TEST_ERROR; + if (end_verification() < 0) + TEST_ERROR; } /* end else */ } - else if(argc == 3) { + else if (argc == 3) { /* Two arguments supplied. Pass them to flush verification routine. */ - if(flush_verification(argv[1], argv[2]) != 0) PROCESS_ERROR; + if (flush_verification(argv[1], argv[2]) != 0) + PROCESS_ERROR; } - else if(argc == 2) { + else if (argc == 2) { /* One argument supplied. Pass it to refresh verification routine. */ - if(refresh_verification(argv[1]) != 0) PROCESS_ERROR; + if (refresh_verification(argv[1]) != 0) + PROCESS_ERROR; } else { /* Illegal number of arguments supplied. Error. */ @@ -188,7 +195,6 @@ error: return EXIT_FAILURE; } /* main */ - /*------------------------------------------------------------------------- * Function: test_flush * @@ -202,7 +208,8 @@ error: * *------------------------------------------------------------------------- */ -herr_t test_flush(void) +herr_t +test_flush(void) { /************************************************************************** * @@ -239,26 +246,26 @@ herr_t test_flush(void) **************************************************************************/ /************************************************************************** - * Generated Test File will look like this: - * - * GROUP "/" - * DATASET "Dataset1" - * GROUP "Group1" { - * DATASET "Dataset2" - * GROUP "Group2" { - * DATATYPE "CommittedDatatype3" - * } - * } - * GROUP "Group3" { - * DATASET "Dataset3" - * DATATYPE "CommittedDatatype2" - * } - * DATATYPE "CommittedDatatype1" + * Generated Test File will look like this: + * + * GROUP "/" + * DATASET "Dataset1" + * GROUP "Group1" { + * DATASET "Dataset2" + * GROUP "Group2" { + * DATATYPE "CommittedDatatype3" + * } + * } + * GROUP "Group3" { + * DATASET "Dataset3" + * DATATYPE "CommittedDatatype2" + * } + * DATATYPE "CommittedDatatype1" **************************************************************************/ /* Variables */ - hid_t fid,gid,gid2,gid3,sid,tid1,tid2,tid3,did,did2,did3,rid,fapl,status = 0; - hsize_t dims[2] = {3,5}; + hid_t fid, gid, gid2, gid3, sid, tid1, tid2, tid3, did, did2, did3, rid, fapl, status = 0; + hsize_t dims[2] = {3, 5}; /* Testing Message */ HDfprintf(stdout, "Testing individual object flush behavior:\n"); @@ -271,43 +278,60 @@ herr_t test_flush(void) /* ================ */ /* Create file, open root group - have to use latest file format for SWMR */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if((rid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; + if ((rid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create data space and types */ - if((sid = H5Screate_simple(2, dims, dims)) < 0) TEST_ERROR; - if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR; - if((tid2 = H5Tcopy(H5T_NATIVE_CHAR)) < 0) TEST_ERROR; - if((tid3 = H5Tcopy(H5T_NATIVE_LONG)) < 0) TEST_ERROR; + if ((sid = H5Screate_simple(2, dims, dims)) < 0) + TEST_ERROR; + if ((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR; + if ((tid2 = H5Tcopy(H5T_NATIVE_CHAR)) < 0) + TEST_ERROR; + if ((tid3 = H5Tcopy(H5T_NATIVE_LONG)) < 0) + TEST_ERROR; /* Create Group1 */ - if((gid = H5Gcreate2(fid, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((gid = H5Gcreate2(fid, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Group2 */ - if((gid2 = H5Gcreate2(gid, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((gid2 = H5Gcreate2(gid, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Group3 */ - if((gid3 = H5Gcreate2(fid, "Group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((gid3 = H5Gcreate2(fid, "Group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Dataset1 */ - if((did = H5Dcreate2(fid, "Dataset1", tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((did = H5Dcreate2(fid, "Dataset1", tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Dataset2 */ - if((did2 = H5Dcreate2(gid, "Dataset2", tid3, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((did2 = H5Dcreate2(gid, "Dataset2", tid3, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Dataset3 */ - if((did3 = H5Dcreate2(gid3, "Dataset3", tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((did3 = H5Dcreate2(gid3, "Dataset3", tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create CommittedDatatype1 */ - if((status = H5Tcommit2(fid, "CommittedDatatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((status = H5Tcommit2(fid, "CommittedDatatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create CommittedDatatype2 */ - if((status = H5Tcommit2(gid2, "CommittedDatatype2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((status = H5Tcommit2(gid2, "CommittedDatatype2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create CommittedDatatype3 */ - if((status = H5Tcommit2(gid3, "CommittedDatatype3", tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((status = H5Tcommit2(gid3, "CommittedDatatype3", tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* ============ */ /* FLUSH GROUPS */ @@ -317,57 +341,100 @@ herr_t test_flush(void) TESTING("to ensure H5Gflush correctly flushes single groups"); /* First, let's verify that nothing is currently flushed. */ - if(run_flush_verification_process(RG, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if (run_flush_verification_process(RG, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; /* Then, flush the root group and verify it's the only thing on disk */ - if((status = H5Gflush(rid)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Gflush(rid)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; /* Flush Group1 and Verify it is recently flushed, and nothing * else has changed. */ - if((status = H5Gflush(gid)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Gflush(gid)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; /* Flush Group2 and Verify it is recently flushed, and nothing * else has changed. */ - if((status = H5Gflush(gid2)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Gflush(gid2)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; PASSED(); @@ -379,30 +446,52 @@ herr_t test_flush(void) TESTING("to ensure H5Dflush correctly flushes single datasets"); /* Flush Dataset1 and verify it's the only thing that hits disk. */ - if((status = H5Dflush(did)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Dflush(did)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; /* Flush Dataset2 and verify it's the only thing that hits disk. */ - if((status = H5Dflush(did2)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Dflush(did2)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; PASSED(); @@ -414,30 +503,52 @@ herr_t test_flush(void) TESTING("to ensure H5Tflush correctly flushes single datatypes"); /* Flush Datatype 1 and verify it's the only thing that hits disk. */ - if((status = H5Tflush(tid1)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Tflush(tid1)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; /* Flush Datatype 2 and verify it's the only thing that hits disk. */ - if((status = H5Tflush(tid2)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Tflush(tid2)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; PASSED(); @@ -449,61 +560,102 @@ herr_t test_flush(void) TESTING("to ensure H5Oflush correctly flushes single objects"); /* Flush Group3 and verify it's the only thing that hits disk. */ - if((status = H5Oflush(gid3)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, NOT_FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Oflush(gid3)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, NOT_FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; /* Flush Dataset3 and verify it's the only thing that hits disk. */ - if((status = H5Oflush(did3)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, NOT_FLUSHED) != 0) TEST_ERROR; + if ((status = H5Oflush(did3)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, NOT_FLUSHED) != 0) + TEST_ERROR; /* Flush CommittedDatatype3 and verify it's the only thing that hits disk. */ - if((status = H5Oflush(tid3)) < 0) TEST_ERROR; - if(run_flush_verification_process(RG, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(G3, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(D3, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T1, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T2, FLUSHED) != 0) TEST_ERROR; - if(run_flush_verification_process(T3, FLUSHED) != 0) TEST_ERROR; + if ((status = H5Oflush(tid3)) < 0) + TEST_ERROR; + if (run_flush_verification_process(RG, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(G3, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(D3, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T1, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T2, FLUSHED) != 0) + TEST_ERROR; + if (run_flush_verification_process(T3, FLUSHED) != 0) + TEST_ERROR; PASSED(); /* ================== */ /* Cleanup and Return */ /* ================== */ - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Gclose(gid) < 0) TEST_ERROR; - if(H5Gclose(gid2) < 0) TEST_ERROR; - if(H5Dclose(did) < 0) TEST_ERROR; - if(H5Dclose(did2) < 0) TEST_ERROR; - if(H5Gclose(rid) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Gclose(gid2) < 0) + TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Dclose(did2) < 0) + TEST_ERROR; + if (H5Gclose(rid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* Delete test file */ HDremove(FILENAME); - if(end_verification() < 0) TEST_ERROR; + if (end_verification() < 0) + TEST_ERROR; return SUCCEED; @@ -511,7 +663,6 @@ error: return FAIL; } /* end test_flush */ - /*------------------------------------------------------------------------- * Function: test_refresh * @@ -525,7 +676,8 @@ error: * *------------------------------------------------------------------------- */ -herr_t test_refresh(void) +herr_t +test_refresh(void) { /************************************************************************** * @@ -562,30 +714,30 @@ herr_t test_refresh(void) **************************************************************************/ /************************************************************************** - * Generated Test File will look like this: - * - * GROUP "/" - * DATASET "Dataset1" - * GROUP "Group1" { - * DATASET "Dataset2" - * GROUP "Group2" { - * DATATYPE "CommittedDatatype3" - * } - * } - * GROUP "Group3" { - * DATASET "Dataset3" - * DATATYPE "CommittedDatatype2" - * } - * DATATYPE "CommittedDatatype1" + * Generated Test File will look like this: + * + * GROUP "/" + * DATASET "Dataset1" + * GROUP "Group1" { + * DATASET "Dataset2" + * GROUP "Group2" { + * DATATYPE "CommittedDatatype3" + * } + * } + * GROUP "Group3" { + * DATASET "Dataset3" + * DATATYPE "CommittedDatatype2" + * } + * DATATYPE "CommittedDatatype1" **************************************************************************/ /* Variables */ - hid_t aid,fid,sid,tid1,did,dcpl,fapl = 0; - hid_t gid,gid2,gid3,tid2,tid3,did2,did3; - herr_t status = 0; - hsize_t dims[2] = {50,50}; - hsize_t cdims[2] = {1,1}; - int fillval = 2; + hid_t aid, fid, sid, tid1, did, dcpl, fapl = 0; + hid_t gid, gid2, gid3, tid2, tid3, did2, did3; + herr_t status = 0; + hsize_t dims[2] = {50, 50}; + hsize_t cdims[2] = {1, 1}; + int fillval = 2; /* Testing Message */ HDfprintf(stdout, "Testing individual object refresh behavior:\n"); @@ -598,48 +750,68 @@ herr_t test_refresh(void) /* ================ */ /* Create File */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* Create data space and types */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if(H5Pset_chunk(dcpl, 2, cdims) < 0) TEST_ERROR; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) TEST_ERROR; - if((sid = H5Screate_simple(2, dims, dims)) < 0) TEST_ERROR; - if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR; - if((tid2 = H5Tcopy(H5T_NATIVE_CHAR)) < 0) TEST_ERROR; - if((tid3 = H5Tcopy(H5T_NATIVE_LONG)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, cdims) < 0) + TEST_ERROR; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0) + TEST_ERROR; + if ((sid = H5Screate_simple(2, dims, dims)) < 0) + TEST_ERROR; + if ((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR; + if ((tid2 = H5Tcopy(H5T_NATIVE_CHAR)) < 0) + TEST_ERROR; + if ((tid3 = H5Tcopy(H5T_NATIVE_LONG)) < 0) + TEST_ERROR; /* Create Group1 */ - if((gid = H5Gcreate2(fid, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((gid = H5Gcreate2(fid, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Group2 */ - if((gid2 = H5Gcreate2(gid, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((gid2 = H5Gcreate2(gid, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Group3 */ - if((gid3 = H5Gcreate2(fid, "Group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((gid3 = H5Gcreate2(fid, "Group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Dataset1 */ - if((did = H5Dcreate2(fid, "Dataset1", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((did = H5Dcreate2(fid, "Dataset1", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Dataset2 */ - if((did2 = H5Dcreate2(gid, "Dataset2", tid3, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((did2 = H5Dcreate2(gid, "Dataset2", tid3, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create Dataset3 */ - if((did3 = H5Dcreate2(gid3, "Dataset3", tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((did3 = H5Dcreate2(gid3, "Dataset3", tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create CommittedDatatype1 */ - if((status = H5Tcommit2(fid, "CommittedDatatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((status = H5Tcommit2(fid, "CommittedDatatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create CommittedDatatype2 */ - if((status = H5Tcommit2(gid2, "CommittedDatatype2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((status = H5Tcommit2(gid2, "CommittedDatatype2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Create CommittedDatatype3 */ - if((status = H5Tcommit2(gid3, "CommittedDatatype3", tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((status = H5Tcommit2(gid3, "CommittedDatatype3", tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Flush File to Disk */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) TEST_ERROR; + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + TEST_ERROR; /* ================ */ /* Refresh Datasets */ @@ -650,22 +822,32 @@ herr_t test_refresh(void) /* Create an attribute on each object before flush. */ /* Verify First Dataset can be refreshed with H5Drefresh */ - if(start_refresh_verification_process(D1) != 0) TEST_ERROR; + if (start_refresh_verification_process(D1) != 0) + TEST_ERROR; - if((aid = H5Acreate2(did, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(did) < 0) TEST_ERROR; + if ((aid = H5Acreate2(did, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(did) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; /* Verify Second Dataset can be refreshed with H5Drefresh */ - if(start_refresh_verification_process(D2) != 0) TEST_ERROR; + if (start_refresh_verification_process(D2) != 0) + TEST_ERROR; - if((aid = H5Acreate2(did2, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(did2) < 0) TEST_ERROR; + if ((aid = H5Acreate2(did2, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(did2) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; PASSED(); @@ -676,22 +858,32 @@ herr_t test_refresh(void) TESTING("to ensure that H5Grefresh correctly refreshes single groups"); /* Verify First Group can be refreshed with H5Grefresh */ - if(start_refresh_verification_process(G1) != 0) TEST_ERROR; + if (start_refresh_verification_process(G1) != 0) + TEST_ERROR; - if((aid = H5Acreate2(gid, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(gid) < 0) TEST_ERROR; + if ((aid = H5Acreate2(gid, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(gid) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; /* Verify Second Group can be refreshed with H5Grefresh */ - if(start_refresh_verification_process(G2) != 0) TEST_ERROR; + if (start_refresh_verification_process(G2) != 0) + TEST_ERROR; - if((aid = H5Acreate2(gid2, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(gid2) < 0) TEST_ERROR; + if ((aid = H5Acreate2(gid2, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(gid2) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; PASSED(); @@ -701,22 +893,32 @@ herr_t test_refresh(void) TESTING("to ensure that H5Trefresh correctly refreshes single datatypes"); /* Verify First Committed Datatype can be refreshed with H5Trefresh */ - if(start_refresh_verification_process(T1) != 0) TEST_ERROR; + if (start_refresh_verification_process(T1) != 0) + TEST_ERROR; - if((aid = H5Acreate2(tid1, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(tid1) < 0) TEST_ERROR; + if ((aid = H5Acreate2(tid1, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(tid1) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; /* Verify Second Committed Datatype can be refreshed with H5Trefresh */ - if(start_refresh_verification_process(T2) != 0) TEST_ERROR; + if (start_refresh_verification_process(T2) != 0) + TEST_ERROR; - if((aid = H5Acreate2(tid2, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(tid2) < 0) TEST_ERROR; + if ((aid = H5Acreate2(tid2, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(tid2) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; PASSED(); /* =============== */ @@ -726,31 +928,46 @@ herr_t test_refresh(void) TESTING("to ensure that H5Orefresh correctly refreshes single objects"); /* Verify Third Dataset can be refreshed with H5Orefresh */ - if(start_refresh_verification_process(D3) != 0) TEST_ERROR; + if (start_refresh_verification_process(D3) != 0) + TEST_ERROR; - if((aid = H5Acreate2(did3, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(did3) < 0) TEST_ERROR; + if ((aid = H5Acreate2(did3, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(did3) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; /* Verify Third Group can be refreshed with H5Orefresh */ - if(start_refresh_verification_process(G3) != 0) TEST_ERROR; + if (start_refresh_verification_process(G3) != 0) + TEST_ERROR; - if((aid = H5Acreate2(gid3, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(gid3) < 0) TEST_ERROR; + if ((aid = H5Acreate2(gid3, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(gid3) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; /* Verify Third Committed Datatype can be refreshed with H5Orefresh */ - if(start_refresh_verification_process(T3) != 0) TEST_ERROR; + if (start_refresh_verification_process(T3) != 0) + TEST_ERROR; - if((aid = H5Acreate2(tid3, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) TEST_ERROR; - if(H5Oflush(tid3) < 0) TEST_ERROR; + if ((aid = H5Acreate2(tid3, "Attribute", tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Aclose(aid) < 0) + TEST_ERROR; + if (H5Oflush(tid3) < 0) + TEST_ERROR; - if(end_refresh_verification_process() != 0) TEST_ERROR; + if (end_refresh_verification_process() != 0) + TEST_ERROR; PASSED(); @@ -759,24 +976,38 @@ herr_t test_refresh(void) /* ================== */ /* Close Stuff */ - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Tclose(tid1) < 0) TEST_ERROR; - if(H5Tclose(tid2) < 0) TEST_ERROR; - if(H5Tclose(tid3) < 0) TEST_ERROR; - if(H5Dclose(did) < 0) TEST_ERROR; - if(H5Dclose(did2) < 0) TEST_ERROR; - if(H5Dclose(did3) < 0) TEST_ERROR; - if(H5Gclose(gid) < 0) TEST_ERROR; - if(H5Gclose(gid2) < 0) TEST_ERROR; - if(H5Gclose(gid3) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Tclose(tid1) < 0) + TEST_ERROR; + if (H5Tclose(tid2) < 0) + TEST_ERROR; + if (H5Tclose(tid3) < 0) + TEST_ERROR; + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Dclose(did2) < 0) + TEST_ERROR; + if (H5Dclose(did3) < 0) + TEST_ERROR; + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Gclose(gid2) < 0) + TEST_ERROR; + if (H5Gclose(gid3) < 0) + TEST_ERROR; + if (H5Sclose(sid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* Delete Test File */ HDremove(FILENAME); - if(end_verification() < 0) TEST_ERROR; + if (end_verification() < 0) + TEST_ERROR; return SUCCEED; @@ -785,7 +1016,6 @@ error: return FAIL; } /* test_refresh() */ - /*------------------------------------------------------------------------- * Function: run_flush_verification_process * @@ -800,7 +1030,8 @@ error: * *------------------------------------------------------------------------- */ -herr_t run_flush_verification_process(const char * obj_pathname, const char * expected) +herr_t +run_flush_verification_process(const char *obj_pathname, const char *expected) { HDremove(SIGNAL_FROM_SCRIPT); @@ -808,10 +1039,12 @@ herr_t run_flush_verification_process(const char * obj_pathname, const char * ex h5_send_message(SIGNAL_TO_SCRIPT, obj_pathname, expected); /* Wait for Signal from SCRIPT indicating that verification process has completed. */ - if(h5_wait_message(SIGNAL_FROM_SCRIPT) < 0) TEST_ERROR; + if (h5_wait_message(SIGNAL_FROM_SCRIPT) < 0) + TEST_ERROR; /* Check to see if any errors occurred */ - if(check_for_errors() < 0) TEST_ERROR; + if (check_for_errors() < 0) + TEST_ERROR; /* Return */ return SUCCEED; @@ -820,7 +1053,6 @@ error: return FAIL; } /* run_flush_verification_process */ - /*------------------------------------------------------------------------- * Function: flush_verification * @@ -838,41 +1070,50 @@ error: * *------------------------------------------------------------------------- */ -herr_t flush_verification(const char * obj_pathname, const char * expected) +herr_t +flush_verification(const char *obj_pathname, const char *expected) { /* Variables */ - hid_t oid = -1, fid = -1; - herr_t status = 0; + hid_t oid = -1, fid = -1; + herr_t status = 0; H5O_info2_t oinfo; /* Try to open the testfile and then obj_pathname within the file */ - H5E_BEGIN_TRY { - fid = H5Fopen(FILENAME, H5F_ACC_SWMR_READ, H5P_DEFAULT); - oid = H5Oopen(fid, obj_pathname, H5P_DEFAULT); + H5E_BEGIN_TRY + { + fid = H5Fopen(FILENAME, H5F_ACC_SWMR_READ, H5P_DEFAULT); + oid = H5Oopen(fid, obj_pathname, H5P_DEFAULT); status = H5Oget_info3(oid, &oinfo, H5O_INFO_BASIC); - } H5E_END_TRY; + } + H5E_END_TRY; /* Compare to expected result */ - if(HDstrcmp(expected, FLUSHED) == 0) { - if((oid < 0) || (status < 0)) { + if (HDstrcmp(expected, FLUSHED) == 0) { + if ((oid < 0) || (status < 0)) { HDfprintf(stderr, "Error! %s should be on disk, but was NOT!\n", obj_pathname); PROCESS_ERROR; } /* end if */ - } else if(HDstrcmp(expected, NOT_FLUSHED) == 0) { - if((oid > 0) || (status > 0)) { - HDfprintf(stderr, "Error! %s not expected to be flushed, but it was found on disk!\n", obj_pathname); + } + else if (HDstrcmp(expected, NOT_FLUSHED) == 0) { + if ((oid > 0) || (status > 0)) { + HDfprintf(stderr, "Error! %s not expected to be flushed, but it was found on disk!\n", + obj_pathname); PROCESS_ERROR; } /* end if */ - } else { - HDfprintf(stderr, "Error! Bad verification parameters. %s is an invalid expected outcome.\n", expected); + } + else { + HDfprintf(stderr, "Error! Bad verification parameters. %s is an invalid expected outcome.\n", + expected); PROCESS_ERROR; } /* end if */ /* Cleanup */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Oclose(oid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return SUCCEED; @@ -880,7 +1121,6 @@ error: return FAIL; } /* flush_verification */ - /*------------------------------------------------------------------------- * Function: start_refresh_verification_process * @@ -895,7 +1135,8 @@ error: * *------------------------------------------------------------------------- */ -herr_t start_refresh_verification_process(const char * obj_pathname) +herr_t +start_refresh_verification_process(const char *obj_pathname) { HDremove(SIGNAL_BETWEEN_PROCESSES_1); @@ -905,10 +1146,12 @@ herr_t start_refresh_verification_process(const char * obj_pathname) /* Wait for Signal from VERIFICATION PROCESS indicating that it's opened the target object and ready for MAIN PROCESS to modify it */ - if(h5_wait_message(SIGNAL_BETWEEN_PROCESSES_1) < 0) TEST_ERROR; + if (h5_wait_message(SIGNAL_BETWEEN_PROCESSES_1) < 0) + TEST_ERROR; /* Check to see if any errors occurred */ - if(check_for_errors() < 0) TEST_ERROR; + if (check_for_errors() < 0) + TEST_ERROR; /* Return */ return SUCCEED; @@ -917,7 +1160,6 @@ error: return FAIL; } /* start_refresh_verification_process */ - /*------------------------------------------------------------------------- * Function: end_refresh_verification_process * @@ -933,7 +1175,8 @@ error: * *------------------------------------------------------------------------- */ -herr_t end_refresh_verification_process(void) +herr_t +end_refresh_verification_process(void) { HDremove(SIGNAL_FROM_SCRIPT); @@ -944,10 +1187,12 @@ herr_t end_refresh_verification_process(void) /* Wait for Signal from SCRIPT indicating that the refresh verification process has completed. */ - if(h5_wait_message(SIGNAL_FROM_SCRIPT) < 0) TEST_ERROR; + if (h5_wait_message(SIGNAL_FROM_SCRIPT) < 0) + TEST_ERROR; /* Check to see if any errors occurred */ - if(check_for_errors() < 0) TEST_ERROR; + if (check_for_errors() < 0) + TEST_ERROR; /* Return */ return SUCCEED; @@ -956,7 +1201,6 @@ error: return FAIL; } /* end_refresh_verification_process */ - /*------------------------------------------------------------------------- * Function: refresh_verification * @@ -974,32 +1218,37 @@ error: * *------------------------------------------------------------------------- */ -herr_t refresh_verification(const char * obj_pathname) +herr_t +refresh_verification(const char *obj_pathname) { /* Variables */ - hid_t oid,fid,status = 0; - H5O_info2_t flushed_oinfo; - H5O_info2_t refreshed_oinfo; + hid_t oid, fid, status = 0; + H5O_info2_t flushed_oinfo; + H5O_info2_t refreshed_oinfo; H5O_native_info_t flushed_ninfo; H5O_native_info_t refreshed_ninfo; - int tries = 800, sleep_tries = 400; - int token_cmp; - hbool_t ok = FALSE; + int tries = 800, sleep_tries = 400; + int token_cmp; + hbool_t ok = FALSE; HDremove(SIGNAL_BETWEEN_PROCESSES_2); /* Open Object */ - if((fid = H5Fopen(FILENAME, H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0) PROCESS_ERROR; - if((oid = H5Oopen(fid, obj_pathname, H5P_DEFAULT)) < 0) PROCESS_ERROR; + if ((fid = H5Fopen(FILENAME, H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0) + PROCESS_ERROR; + if ((oid = H5Oopen(fid, obj_pathname, H5P_DEFAULT)) < 0) + PROCESS_ERROR; /* Get Object info */ - if((status = H5Oget_info3(oid, &flushed_oinfo, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS)) < 0) PROCESS_ERROR; - if((status = H5Oget_native_info(oid, &flushed_ninfo, H5O_NATIVE_INFO_HDR)) < 0) PROCESS_ERROR; + if ((status = H5Oget_info3(oid, &flushed_oinfo, H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS)) < 0) + PROCESS_ERROR; + if ((status = H5Oget_native_info(oid, &flushed_ninfo, H5O_NATIVE_INFO_HDR)) < 0) + PROCESS_ERROR; /* Make sure there are no attributes on the object. This is just a sanity check to ensure we didn't erroneously flush the attribute before starting the verification. */ - if(flushed_oinfo.num_attrs != 0) + if (flushed_oinfo.num_attrs != 0) PROCESS_ERROR; /* Send Signal to MAIN PROCESS indicating that it can go ahead and modify the @@ -1008,25 +1257,37 @@ herr_t refresh_verification(const char * obj_pathname) /* Wait for Signal from MAIN PROCESS indicating that it's modified the object and we can run verification now. */ - if(h5_wait_message(SIGNAL_BETWEEN_PROCESSES_2) < 0) PROCESS_ERROR; + if (h5_wait_message(SIGNAL_BETWEEN_PROCESSES_2) < 0) + PROCESS_ERROR; /* Get object info again. This will NOT reflect what's on disk, only what's in the cache. Thus, all values will be unchanged from above, despite newer information being on disk. */ - if((status = H5Oget_info3(oid, &refreshed_oinfo, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS)) < 0) PROCESS_ERROR; - if((status = H5Oget_native_info(oid, &refreshed_ninfo, H5O_NATIVE_INFO_HDR)) < 0) PROCESS_ERROR; + if ((status = H5Oget_info3(oid, &refreshed_oinfo, H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS)) < 0) + PROCESS_ERROR; + if ((status = H5Oget_native_info(oid, &refreshed_ninfo, H5O_NATIVE_INFO_HDR)) < 0) + PROCESS_ERROR; /* Verify that before doing a refresh, getting the object info returns stale information. (i.e., unchanged from above, despite new info on disk). */ - if(H5Otoken_cmp(oid, &flushed_oinfo.token, &refreshed_oinfo.token, &token_cmp) < 0) PROCESS_ERROR; - if(token_cmp) PROCESS_ERROR; - if(flushed_oinfo.type != refreshed_oinfo.type) PROCESS_ERROR; - if(flushed_oinfo.num_attrs != refreshed_oinfo.num_attrs) PROCESS_ERROR; - if(flushed_ninfo.hdr.version != refreshed_ninfo.hdr.version) PROCESS_ERROR; - if(flushed_ninfo.hdr.flags != refreshed_ninfo.hdr.flags) PROCESS_ERROR; - if(flushed_ninfo.hdr.nmesgs != refreshed_ninfo.hdr.nmesgs) PROCESS_ERROR; - if(flushed_ninfo.hdr.nchunks != refreshed_ninfo.hdr.nchunks) PROCESS_ERROR; - if(flushed_ninfo.hdr.space.total != refreshed_ninfo.hdr.space.total) PROCESS_ERROR; + if (H5Otoken_cmp(oid, &flushed_oinfo.token, &refreshed_oinfo.token, &token_cmp) < 0) + PROCESS_ERROR; + if (token_cmp) + PROCESS_ERROR; + if (flushed_oinfo.type != refreshed_oinfo.type) + PROCESS_ERROR; + if (flushed_oinfo.num_attrs != refreshed_oinfo.num_attrs) + PROCESS_ERROR; + if (flushed_ninfo.hdr.version != refreshed_ninfo.hdr.version) + PROCESS_ERROR; + if (flushed_ninfo.hdr.flags != refreshed_ninfo.hdr.flags) + PROCESS_ERROR; + if (flushed_ninfo.hdr.nmesgs != refreshed_ninfo.hdr.nmesgs) + PROCESS_ERROR; + if (flushed_ninfo.hdr.nchunks != refreshed_ninfo.hdr.nchunks) + PROCESS_ERROR; + if (flushed_ninfo.hdr.space.total != refreshed_ninfo.hdr.space.total) + PROCESS_ERROR; /* Refresh object */ /* The H5*refresh function called depends on which object we are trying @@ -1034,18 +1295,22 @@ herr_t refresh_verification(const char * obj_pathname) * test cases is easy). */ do { - if((HDstrcmp(obj_pathname, D1) == 0) || (HDstrcmp(obj_pathname, D2) == 0)) { - if(H5Drefresh(oid) < 0) PROCESS_ERROR; + if ((HDstrcmp(obj_pathname, D1) == 0) || (HDstrcmp(obj_pathname, D2) == 0)) { + if (H5Drefresh(oid) < 0) + PROCESS_ERROR; } /* end if */ - else if((HDstrcmp(obj_pathname, G1) == 0) || (HDstrcmp(obj_pathname, G2) == 0)) { - if(H5Grefresh(oid) < 0) PROCESS_ERROR; + else if ((HDstrcmp(obj_pathname, G1) == 0) || (HDstrcmp(obj_pathname, G2) == 0)) { + if (H5Grefresh(oid) < 0) + PROCESS_ERROR; } /* end if */ - else if((HDstrcmp(obj_pathname, T1) == 0) || (HDstrcmp(obj_pathname, T2) == 0)) { - if(H5Trefresh(oid) < 0) PROCESS_ERROR; + else if ((HDstrcmp(obj_pathname, T1) == 0) || (HDstrcmp(obj_pathname, T2) == 0)) { + if (H5Trefresh(oid) < 0) + PROCESS_ERROR; } /* end if */ - else if((HDstrcmp(obj_pathname, D3) == 0) || (HDstrcmp(obj_pathname, G3) == 0) || - (HDstrcmp(obj_pathname, T3) == 0)) { - if(H5Orefresh(oid) < 0) PROCESS_ERROR; + else if ((HDstrcmp(obj_pathname, D3) == 0) || (HDstrcmp(obj_pathname, G3) == 0) || + (HDstrcmp(obj_pathname, T3) == 0)) { + if (H5Orefresh(oid) < 0) + PROCESS_ERROR; } /* end if */ else { HDfprintf(stdout, "Error. %s is an unrecognized object.\n", obj_pathname); @@ -1053,42 +1318,46 @@ herr_t refresh_verification(const char * obj_pathname) } /* end else */ /* Get object info. This should now accurately reflect the refreshed object on disk. */ - if((status = H5Oget_info3(oid, &refreshed_oinfo, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS)) < 0) PROCESS_ERROR; - if((status = H5Oget_native_info(oid, &refreshed_ninfo, H5O_NATIVE_INFO_HDR)) < 0) PROCESS_ERROR; - if(H5Otoken_cmp(oid, &flushed_oinfo.token, &refreshed_oinfo.token, &token_cmp) < 0) PROCESS_ERROR; + if ((status = H5Oget_info3(oid, &refreshed_oinfo, H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS)) < 0) + PROCESS_ERROR; + if ((status = H5Oget_native_info(oid, &refreshed_ninfo, H5O_NATIVE_INFO_HDR)) < 0) + PROCESS_ERROR; + if (H5Otoken_cmp(oid, &flushed_oinfo.token, &refreshed_oinfo.token, &token_cmp) < 0) + PROCESS_ERROR; /* Confirm following (first 4) attributes are the same: */ /* Confirm following (last 4) attributes are different */ - if( (!token_cmp) && - (flushed_oinfo.type == refreshed_oinfo.type) && - (flushed_oinfo.num_attrs != refreshed_oinfo.num_attrs) && - (flushed_ninfo.hdr.version == refreshed_ninfo.hdr.version) && - (flushed_ninfo.hdr.flags == refreshed_ninfo.hdr.flags) && - (flushed_ninfo.hdr.nmesgs != refreshed_ninfo.hdr.nmesgs) && - (flushed_ninfo.hdr.nchunks != refreshed_ninfo.hdr.nchunks) && - (flushed_ninfo.hdr.space.total != refreshed_ninfo.hdr.space.total) ) { + if ((!token_cmp) && (flushed_oinfo.type == refreshed_oinfo.type) && + (flushed_oinfo.num_attrs != refreshed_oinfo.num_attrs) && + (flushed_ninfo.hdr.version == refreshed_ninfo.hdr.version) && + (flushed_ninfo.hdr.flags == refreshed_ninfo.hdr.flags) && + (flushed_ninfo.hdr.nmesgs != refreshed_ninfo.hdr.nmesgs) && + (flushed_ninfo.hdr.nchunks != refreshed_ninfo.hdr.nchunks) && + (flushed_ninfo.hdr.space.total != refreshed_ninfo.hdr.space.total)) { ok = TRUE; break; } - if(tries == sleep_tries) + if (tries == sleep_tries) HDsleep(1); - } while(--tries); + } while (--tries); - if(!ok) { - HDprintf("FLUSHED: num_attrs=%d, nmesgs=%d, nchunks=%d, total=%d\n", - (int)flushed_oinfo.num_attrs, (int)flushed_ninfo.hdr.nmesgs, - (int)flushed_ninfo.hdr.nchunks, (int)flushed_ninfo.hdr.space.total); - HDprintf("REFRESHED: num_attrs=%d, nmesgs=%d, nchunks=%d, total=%d\n", - (int)refreshed_oinfo.num_attrs, (int)refreshed_ninfo.hdr.nmesgs, - (int)refreshed_ninfo.hdr.nchunks, (int)refreshed_ninfo.hdr.space.total); + if (!ok) { + HDprintf("FLUSHED: num_attrs=%d, nmesgs=%d, nchunks=%d, total=%d\n", (int)flushed_oinfo.num_attrs, + (int)flushed_ninfo.hdr.nmesgs, (int)flushed_ninfo.hdr.nchunks, + (int)flushed_ninfo.hdr.space.total); + HDprintf("REFRESHED: num_attrs=%d, nmesgs=%d, nchunks=%d, total=%d\n", (int)refreshed_oinfo.num_attrs, + (int)refreshed_ninfo.hdr.nmesgs, (int)refreshed_ninfo.hdr.nchunks, + (int)refreshed_ninfo.hdr.space.total); PROCESS_ERROR; } /* Close objects */ - if(H5Oclose(oid) < 0) PROCESS_ERROR; - if(H5Fclose(fid) < 0) PROCESS_ERROR; + if (H5Oclose(oid) < 0) + PROCESS_ERROR; + if (H5Fclose(fid) < 0) + PROCESS_ERROR; /* Return */ return SUCCEED; @@ -1097,7 +1366,6 @@ error: return FAIL; } /* refresh_verification */ - /*------------------------------------------------------------------------- * Function: check_for_errors() * @@ -1115,11 +1383,12 @@ error: * *------------------------------------------------------------------------- */ -herr_t check_for_errors(void) +herr_t +check_for_errors(void) { - FILE * file; + FILE *file; - if((file = HDfopen(ERRFILE, "r"))) { + if ((file = HDfopen(ERRFILE, "r"))) { HDfclose(file); HDremove(ERRFILE); return FAIL; @@ -1128,7 +1397,6 @@ herr_t check_for_errors(void) return SUCCEED; } /* check_for_errors */ - /*------------------------------------------------------------------------- * Function: end_verification * @@ -1142,7 +1410,8 @@ herr_t check_for_errors(void) * *------------------------------------------------------------------------- */ -herr_t end_verification(void) +herr_t +end_verification(void) { HDremove(SIGNAL_FROM_SCRIPT); @@ -1150,11 +1419,11 @@ herr_t end_verification(void) h5_send_message(SIGNAL_TO_SCRIPT, "VERIFICATION_DONE", "VERIFICATION_DONE"); /* Wait for Signal from SCRIPT indicating that we can continue. */ - if(h5_wait_message(SIGNAL_FROM_SCRIPT) < 0) TEST_ERROR; + if (h5_wait_message(SIGNAL_FROM_SCRIPT) < 0) + TEST_ERROR; return SUCCEED; error: return FAIL; } /* end_verification */ - diff --git a/test/freespace.c b/test/freespace.c index 124ae3e..628adfb 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -15,78 +15,74 @@ */ #include "h5test.h" -#define H5FS_FRIEND /*suppress error about including H5FSpkg */ +#define H5FS_FRIEND /*suppress error about including H5FSpkg */ #define H5FS_TESTING -#include "H5FSpkg.h" /* Free space manager */ - +#include "H5FSpkg.h" /* Free space manager */ /* Other private headers that this test requires */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "H5Fpkg.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Iprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VMprivate.h" -#define FILENAME_LEN 1024 - -#define TEST_FSPACE_SECT_TYPE 0 -#define TEST_FSPACE_SECT_TYPE_NEW 1 -#define TEST_FSPACE_SECT_TYPE_NONE 2 - -#define TEST_FSPACE_SHRINK 80 -#define TEST_FSPACE_EXPAND 120 -#define TEST_MAX_SECT_SIZE (64 * 1024) -#define TEST_MAX_INDEX 32 - -#define TEST_SECT_ADDR60 60 -#define TEST_SECT_ADDR70 70 -#define TEST_SECT_ADDR80 80 -#define TEST_SECT_ADDR100 100 -#define TEST_SECT_ADDR150 150 -#define TEST_SECT_ADDR200 200 -#define TEST_SECT_ADDR300 300 - -#define TEST_SECT_SIZE5 5 -#define TEST_SECT_SIZE10 10 -#define TEST_SECT_SIZE15 15 -#define TEST_SECT_SIZE20 20 -#define TEST_SECT_SIZE30 30 -#define TEST_SECT_SIZE40 40 -#define TEST_SECT_SIZE50 50 -#define TEST_SECT_SIZE80 80 - -#define FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */ -#define FSPACE_ALIGN_DEF 1 /* Default: no alignment */ - -const char *FILENAME[] = { - "frspace", - NULL -}; +#define FILENAME_LEN 1024 + +#define TEST_FSPACE_SECT_TYPE 0 +#define TEST_FSPACE_SECT_TYPE_NEW 1 +#define TEST_FSPACE_SECT_TYPE_NONE 2 + +#define TEST_FSPACE_SHRINK 80 +#define TEST_FSPACE_EXPAND 120 +#define TEST_MAX_SECT_SIZE (64 * 1024) +#define TEST_MAX_INDEX 32 + +#define TEST_SECT_ADDR60 60 +#define TEST_SECT_ADDR70 70 +#define TEST_SECT_ADDR80 80 +#define TEST_SECT_ADDR100 100 +#define TEST_SECT_ADDR150 150 +#define TEST_SECT_ADDR200 200 +#define TEST_SECT_ADDR300 300 + +#define TEST_SECT_SIZE5 5 +#define TEST_SECT_SIZE10 10 +#define TEST_SECT_SIZE15 15 +#define TEST_SECT_SIZE20 20 +#define TEST_SECT_SIZE30 30 +#define TEST_SECT_SIZE40 40 +#define TEST_SECT_SIZE50 50 +#define TEST_SECT_SIZE80 80 + +#define FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */ +#define FSPACE_ALIGN_DEF 1 /* Default: no alignment */ + +const char *FILENAME[] = {"frspace", NULL}; typedef struct frspace_state_t { - hsize_t tot_space; /* Total amount of space tracked */ - hsize_t tot_sect_count; /* Total # of sections tracked */ - hsize_t serial_sect_count; /* # of serializable sections tracked */ - hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ + hsize_t tot_space; /* Total amount of space tracked */ + hsize_t tot_sect_count; /* Total # of sections tracked */ + hsize_t serial_sect_count; /* # of serializable sections tracked */ + hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ } frspace_state_t; -haddr_t g_eoa=0; -static haddr_t TEST_get_eoa(void); -static void TEST_set_eoa(haddr_t); +haddr_t g_eoa = 0; +static haddr_t TEST_get_eoa(void); +static void TEST_set_eoa(haddr_t); /* * TEST client */ typedef struct TEST_free_section_t { - H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ + H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ } TEST_free_section_t; - static herr_t TEST_sect_init_cls(H5FS_section_class_t *, void *); static herr_t TEST_sect_free(H5FS_section_info_t *_sect); -static herr_t TEST_sect_can_merge(const H5FS_section_info_t *, const H5FS_section_info_t *, void H5_ATTR_UNUSED *); +static herr_t TEST_sect_can_merge(const H5FS_section_info_t *, const H5FS_section_info_t *, + void H5_ATTR_UNUSED *); static herr_t TEST_sect_merging(H5FS_section_info_t **, H5FS_section_info_t *, void H5_ATTR_UNUSED *); static herr_t TEST_sect_can_shrink(const H5FS_section_info_t *, void *); static herr_t TEST_sect_shrinking(H5FS_section_info_t **, void *); @@ -100,101 +96,95 @@ static unsigned test_fs_sect_change_class(hid_t fapl); static unsigned test_fs_sect_extend(hid_t fapl); static unsigned test_fs_sect_iterate(hid_t fapl); - H5FS_section_class_t TEST_FSPACE_SECT_CLS[1] = {{ - TEST_FSPACE_SECT_TYPE, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + TEST_FSPACE_SECT_TYPE, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - TEST_sect_init_cls, /* Initialize section class */ - NULL, /* Terminate section class */ + TEST_sect_init_cls, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - NULL, /* Deserialize section */ - TEST_sect_can_merge, /* Can sections merge? */ - TEST_sect_merging, /* Merge sections */ - TEST_sect_can_shrink, /* Can section shrink container?*/ - TEST_sect_shrinking, /* Shrink container w/section */ - TEST_sect_free, /* Free section */ - NULL, /* Check validity of section */ - NULL, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + NULL, /* Deserialize section */ + TEST_sect_can_merge, /* Can sections merge? */ + TEST_sect_merging, /* Merge sections */ + TEST_sect_can_shrink, /* Can section shrink container?*/ + TEST_sect_shrinking, /* Shrink container w/section */ + TEST_sect_free, /* Free section */ + NULL, /* Check validity of section */ + NULL, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; H5FS_section_class_t TEST_FSPACE_SECT_CLS_NEW[1] = {{ - TEST_FSPACE_SECT_TYPE_NEW, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + TEST_FSPACE_SECT_TYPE_NEW, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - TEST_sect_init_cls, /* Initialize section class */ - NULL, /* Terminate section class */ + TEST_sect_init_cls, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - NULL, /* Deserialize section */ - TEST_sect_can_merge, /* Can sections merge? */ - TEST_sect_merging, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - TEST_sect_free, /* Free section */ - NULL, /* Check validity of section */ - NULL, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + NULL, /* Deserialize section */ + TEST_sect_can_merge, /* Can sections merge? */ + TEST_sect_merging, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + TEST_sect_free, /* Free section */ + NULL, /* Check validity of section */ + NULL, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; H5FS_section_class_t TEST_FSPACE_SECT_CLS_NOINIT[1] = {{ - TEST_FSPACE_SECT_TYPE_NONE, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + TEST_FSPACE_SECT_TYPE_NONE, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - NULL, /* Deserialize section */ - TEST_sect_can_merge, /* Can sections merge? */ - TEST_sect_merging, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - TEST_sect_free, /* Free section */ - NULL, /* Check validity of section */ - NULL, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + NULL, /* Deserialize section */ + TEST_sect_can_merge, /* Can sections merge? */ + TEST_sect_merging, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + TEST_sect_free, /* Free section */ + NULL, /* Check validity of section */ + NULL, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; -const H5FS_section_class_t *test_classes[] = { - TEST_FSPACE_SECT_CLS, - TEST_FSPACE_SECT_CLS_NEW, - TEST_FSPACE_SECT_CLS_NOINIT -}; - +const H5FS_section_class_t *test_classes[] = {TEST_FSPACE_SECT_CLS, TEST_FSPACE_SECT_CLS_NEW, + TEST_FSPACE_SECT_CLS_NOINIT}; static void init_cparam(H5FS_create_t *); static void init_sect_node(TEST_free_section_t *, haddr_t, hsize_t, unsigned, H5FS_section_state_t); -static int check_stats(const H5F_t *, const H5FS_t *, frspace_state_t *); +static int check_stats(const H5F_t *, const H5FS_t *, frspace_state_t *); -#define NUM_SECTIONS 1000 +#define NUM_SECTIONS 1000 /* User data for free space section iterator callback */ typedef struct { - hsize_t tot_size; - hsize_t tot_sect_count; + hsize_t tot_size; + hsize_t tot_sect_count; } TEST_iter_ud_t; static herr_t TEST_sects_cb(H5FS_section_info_t *_sect, void *_udata); - /* * Tests */ @@ -205,8 +195,8 @@ static herr_t TEST_sects_cb(H5FS_section_info_t *_sect, void *_udata); static herr_t TEST_sect_init_cls(H5FS_section_class_t *cls, void *_udata) { - herr_t ret_value = SUCCEED; /* Return value */ - unsigned *init_flags; + herr_t ret_value = SUCCEED; /* Return value */ + unsigned *init_flags; /* Check arguments. */ HDassert(cls); @@ -223,17 +213,17 @@ TEST_sect_init_cls(H5FS_section_class_t *cls, void *_udata) * true if second section adjoins the first section */ H5_ATTR_PURE static herr_t -TEST_sect_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +TEST_sect_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { const TEST_free_section_t *sect1 = (const TEST_free_section_t *)_sect1; const TEST_free_section_t *sect2 = (const TEST_free_section_t *)_sect2; - htri_t ret_value; /* Return value */ + htri_t ret_value; /* Return value */ /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Check if second section adjoins first section */ @@ -246,29 +236,28 @@ TEST_sect_can_merge(const H5FS_section_info_t *_sect1, * Merge the two sections (second section is merged into the first section) */ static herr_t -TEST_sect_merging(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void H5_ATTR_UNUSED *_udata) +TEST_sect_merging(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { - TEST_free_section_t **sect1 = (TEST_free_section_t **)_sect1; - TEST_free_section_t *sect2 = (TEST_free_section_t *)_sect2; - herr_t ret_value = SUCCEED; /* Return value */ + TEST_free_section_t **sect1 = (TEST_free_section_t **)_sect1; + TEST_free_section_t * sect2 = (TEST_free_section_t *)_sect2; + herr_t ret_value = SUCCEED; /* Return value */ /* Check arguments. */ HDassert(sect1); HDassert(((*sect1)->sect_info.type == TEST_FSPACE_SECT_TYPE) || - ((*sect1)->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) || - ((*sect1)->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE)); + ((*sect1)->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) || + ((*sect1)->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE)); HDassert(sect2); HDassert((sect2->sect_info.type == TEST_FSPACE_SECT_TYPE) || - (sect2->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) || - (sect2->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE)); + (sect2->sect_info.type == TEST_FSPACE_SECT_TYPE_NEW) || + (sect2->sect_info.type == TEST_FSPACE_SECT_TYPE_NONE)); HDassert(H5F_addr_eq((*sect1)->sect_info.addr + (*sect1)->sect_info.size, sect2->sect_info.addr)); /* Add second section's size to first section */ (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(TEST_sect_free((H5FS_section_info_t *)sect2) < 0) + if (TEST_sect_free((H5FS_section_info_t *)sect2) < 0) TEST_ERROR error: return ret_value; @@ -296,11 +285,11 @@ TEST_sect_free(H5FS_section_info_t *sect) static herr_t TEST_sect_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { - unsigned *can_shrink = (unsigned *)_udata; - const TEST_free_section_t *sect = (const TEST_free_section_t *)_sect; - haddr_t end, eoa; + unsigned * can_shrink = (unsigned *)_udata; + const TEST_free_section_t *sect = (const TEST_free_section_t *)_sect; + haddr_t end, eoa; - if(can_shrink == NULL) + if (can_shrink == NULL) return FALSE; end = sect->sect_info.addr + sect->sect_info.size; @@ -320,8 +309,8 @@ TEST_sect_can_shrink(const H5FS_section_info_t *_sect, void *_udata) static herr_t TEST_sect_shrinking(H5FS_section_info_t **_sect, void *_udata) { - TEST_free_section_t **sect = (TEST_free_section_t **)_sect; - unsigned *can_shrink = (unsigned *)_udata; + TEST_free_section_t **sect = (TEST_free_section_t **)_sect; + unsigned * can_shrink = (unsigned *)_udata; /* address of the section is faked, so, doesn't need to do anything */ /* just free the section node */ @@ -336,16 +325,15 @@ error: return FALSE; } - /* * iteration callback */ static herr_t TEST_sects_cb(H5FS_section_info_t *_sect, void *_udata) { - TEST_free_section_t *sect = (TEST_free_section_t *)_sect; - TEST_iter_ud_t *udata = (TEST_iter_ud_t *)_udata; - herr_t ret_value = SUCCEED; /* Return value */ + TEST_free_section_t *sect = (TEST_free_section_t *)_sect; + TEST_iter_ud_t * udata = (TEST_iter_ud_t *)_udata; + herr_t ret_value = SUCCEED; /* Return value */ HDassert(sect); HDassert(udata); @@ -353,7 +341,7 @@ TEST_sects_cb(H5FS_section_info_t *_sect, void *_udata) udata->tot_size += sect->sect_info.size; udata->tot_sect_count += 1; - return(ret_value); + return (ret_value); } /* supporting routine for shrinking */ @@ -367,7 +355,7 @@ TEST_get_eoa(void) static void TEST_set_eoa(haddr_t val) { - g_eoa = val; + g_eoa = val; } /* @@ -381,8 +369,8 @@ init_cparam(H5FS_create_t *cparam) /* Set the free space creation parameters */ cparam->shrink_percent = TEST_FSPACE_SHRINK; cparam->expand_percent = TEST_FSPACE_EXPAND; - cparam->max_sect_size = TEST_MAX_SECT_SIZE; - cparam->max_sect_addr = TEST_MAX_INDEX; + cparam->max_sect_size = TEST_MAX_SECT_SIZE; + cparam->max_sect_addr = TEST_MAX_INDEX; } /* init_cparam() */ @@ -390,11 +378,12 @@ init_cparam(H5FS_create_t *cparam) * Initialize free space section node */ static void -init_sect_node(TEST_free_section_t *sect_node, haddr_t addr, hsize_t size, unsigned type, H5FS_section_state_t state) +init_sect_node(TEST_free_section_t *sect_node, haddr_t addr, hsize_t size, unsigned type, + H5FS_section_state_t state) { - sect_node->sect_info.addr = addr; - sect_node->sect_info.size = size; - sect_node->sect_info.type = type; + sect_node->sect_info.addr = addr; + sect_node->sect_info.size = size; + sect_node->sect_info.type = type; sect_node->sect_info.state = state; } /* init_sect_node() */ @@ -404,30 +393,30 @@ init_sect_node(TEST_free_section_t *sect_node, haddr_t addr, hsize_t size, unsig static int check_stats(const H5F_t *f, const H5FS_t *frsp, frspace_state_t *state) { - H5FS_stat_t frspace_stats; /* Statistics about the heap */ + H5FS_stat_t frspace_stats; /* Statistics about the heap */ /* Get statistics for heap and verify they are correct */ - if(H5FS_stat_info(f, frsp, &frspace_stats) < 0) + if (H5FS_stat_info(f, frsp, &frspace_stats) < 0) FAIL_STACK_ERROR - if(frspace_stats.tot_space != state->tot_space) { - HDfprintf(stdout, "frspace_stats.tot_space = %Hu, state->tot_space = %Zu\n", - frspace_stats.tot_space, state->tot_space); + if (frspace_stats.tot_space != state->tot_space) { + HDfprintf(stdout, "frspace_stats.tot_space = %Hu, state->tot_space = %Zu\n", frspace_stats.tot_space, + state->tot_space); TEST_ERROR } /* end if */ - if(frspace_stats.tot_sect_count != state->tot_sect_count) { + if (frspace_stats.tot_sect_count != state->tot_sect_count) { HDfprintf(stdout, "frspace_stats.tot_sect_count = %Hu, state->tot_sect_count = %Hu\n", - frspace_stats.tot_sect_count, state->tot_sect_count); + frspace_stats.tot_sect_count, state->tot_sect_count); TEST_ERROR } /* end if */ - if(frspace_stats.serial_sect_count != state->serial_sect_count) { + if (frspace_stats.serial_sect_count != state->serial_sect_count) { HDfprintf(stdout, "frspace_stats.serial_sect_count = %Hu, state->serial_sect_count = %Hu\n", - frspace_stats.serial_sect_count, state->serial_sect_count); + frspace_stats.serial_sect_count, state->serial_sect_count); TEST_ERROR } /* end if */ - if(frspace_stats.ghost_sect_count != state->ghost_sect_count) { + if (frspace_stats.ghost_sect_count != state->ghost_sect_count) { HDfprintf(stdout, "frspace_stats.ghost_sect_count = %Hu, state->ghost_sect_count = %Hu\n", - frspace_stats.ghost_sect_count, state->ghost_sect_count); + frspace_stats.ghost_sect_count, state->ghost_sect_count); TEST_ERROR } /* end if */ @@ -448,16 +437,16 @@ error: static unsigned test_fs_create(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FS_t *frsp = NULL; /* pointer to free space structure */ - haddr_t fs_addr; /* address of free space */ - h5_stat_size_t file_size, empty_size; /* File size */ - frspace_state_t state; /* State of free space*/ - H5FS_create_t cparam, test_cparam; /* creation parameters */ - uint16_t nclasses; - unsigned init_flags=0; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FS_t * frsp = NULL; /* pointer to free space structure */ + haddr_t fs_addr; /* address of free space */ + h5_stat_size_t file_size, empty_size; /* File size */ + frspace_state_t state; /* State of free space*/ + H5FS_create_t cparam, test_cparam; /* creation parameters */ + uint16_t nclasses; + unsigned init_flags = 0; TESTING("the creation/close/reopen/deletion of the free-space manager"); @@ -465,23 +454,23 @@ test_fs_create(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* initialize creation parameters for free-space manager */ @@ -491,60 +480,60 @@ test_fs_create(hid_t fapl) /* Tag with the global free space tag */ H5AC_tag(H5AC__FREESPACE_TAG, NULL); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR - if(frsp->nclasses != nclasses) + if (frsp->nclasses != nclasses) TEST_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR HDmemset(&test_cparam, 0, sizeof(H5FS_create_t)); - if(H5FS__get_cparam_test(frsp, &test_cparam) < 0) + if (H5FS__get_cparam_test(frsp, &test_cparam) < 0) FAIL_STACK_ERROR - if(H5FS__cmp_cparam_test(&cparam, &test_cparam)) + if (H5FS__cmp_cparam_test(&cparam, &test_cparam)) FAIL_STACK_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; /* reopen the free-space manager */ - if(NULL == (frsp = H5FS_open(f, fs_addr, - nclasses, test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_open(f, fs_addr, nclasses, test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, + (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR if (frsp->nclasses != nclasses) TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) + if (H5FS_delete(f, fs_addr) < 0) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -552,15 +541,16 @@ test_fs_create(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - if(frsp) + H5E_BEGIN_TRY + { + if (frsp) H5FS_close(f, frsp); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_fs_create() */ - /* * Test 1: * Create free-space manager @@ -588,42 +578,42 @@ error: static unsigned test_fs_sect_add(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FS_t *frsp = NULL; /* pointer to free space structure */ - haddr_t fs_addr=HADDR_UNDEF; /* address of free space */ - uint16_t nclasses; - H5FS_create_t cparam; /* creation parameters */ - frspace_state_t state; /* State of free space*/ - - TEST_free_section_t *sect_node = NULL; - unsigned init_flags=0; - h5_stat_size_t file_size=0, tmp_file_size=0, fr_meta_size=0; - unsigned can_shrink=FALSE; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FS_t * frsp = NULL; /* pointer to free space structure */ + haddr_t fs_addr = HADDR_UNDEF; /* address of free space */ + uint16_t nclasses; + H5FS_create_t cparam; /* creation parameters */ + frspace_state_t state; /* State of free space*/ + + TEST_free_section_t *sect_node = NULL; + unsigned init_flags = 0; + h5_stat_size_t file_size = 0, tmp_file_size = 0, fr_meta_size = 0; + unsigned can_shrink = FALSE; TESTING("adding a section via H5FS_sect_add() to free-space: test 1"); h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -632,20 +622,20 @@ test_fs_sect_add(hid_t fapl) /* Tag with the global free space tag */ H5AC_tag(H5AC__FREESPACE_TAG, NULL); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR - if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, NULL) < 0) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); @@ -653,25 +643,25 @@ test_fs_sect_add(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR fr_meta_size = H5FS_HEADER_SIZE(f) + H5FS_SINFO_PREFIX_SIZE(f); /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((tmp_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((tmp_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - if (tmp_file_size <= (file_size+fr_meta_size)) + if (tmp_file_size <= (file_size + fr_meta_size)) TEST_ERROR PASSED(); @@ -679,36 +669,36 @@ test_fs_sect_add(hid_t fapl) TESTING("adding a section via H5FS_sect_add() to free-space with H5FS_CLS_GHOST_OBJ: test 2"); /* Get the size of a file w/empty heap*/ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); nclasses = NELMTS(test_classes); init_flags = H5FS_CLS_GHOST_OBJ; - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* Create free list section node */ - if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, - 0, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, 0, NULL) < 0) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); @@ -716,24 +706,24 @@ test_fs_sect_add(hid_t fapl) state.tot_sect_count += 1; state.ghost_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR fr_meta_size = H5FS_HEADER_SIZE(f); /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((tmp_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((tmp_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - if (tmp_file_size != (file_size+fr_meta_size)) + if (tmp_file_size != (file_size + fr_meta_size)) TEST_ERROR PASSED(); @@ -741,68 +731,68 @@ test_fs_sect_add(hid_t fapl) TESTING("adding a section via H5FS_sect_add() to free-space: test 3"); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR - TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ + TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ init_cparam(&cparam); nclasses = NELMTS(test_classes); init_flags = 0; - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR - if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR /* * Add section A */ - init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, - H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) + FAIL_STACK_ERROR /* nothing in free-space */ HDmemset(&state, 0, sizeof(frspace_state_t)); - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) + if (H5FS_delete(f, fs_addr) < 0) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -810,78 +800,78 @@ test_fs_sect_add(hid_t fapl) TESTING("adding a section via H5FS_sect_add() to free-space: test 4"); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file w/empty heap*/ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR - TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ + TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ init_cparam(&cparam); nclasses = NELMTS(test_classes); init_flags = 0; - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR - if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR /* * Add section A */ - init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, - H5FS_ADD_DESERIALIZING, &can_shrink) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, H5FS_ADD_DESERIALIZING, &can_shrink) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += sect_node->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node) < 0) + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node) < 0) FAIL_STACK_ERROR /* Free the section node(s) */ - if(TEST_sect_free((H5FS_section_info_t *)sect_node) < 0) + if (TEST_sect_free((H5FS_section_info_t *)sect_node) < 0) TEST_ERROR sect_node = NULL; /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) + if (H5FS_delete(f, fs_addr) < 0) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -889,17 +879,18 @@ test_fs_sect_add(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - if(sect_node) + H5E_BEGIN_TRY + { + if (sect_node) TEST_sect_free((H5FS_section_info_t *)sect_node); - if(frsp) + if (frsp) H5FS_close(f, frsp); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_fs_sect_add() */ - /* * To verify the finding of a section with the requested-size from free-space * @@ -923,19 +914,19 @@ error: static unsigned test_fs_sect_find(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FS_t *frsp = NULL; /* pointer to free space structure */ - haddr_t fs_addr=HADDR_UNDEF; /* address of free space */ - uint16_t nclasses; - H5FS_create_t cparam; /* creation parameters */ - frspace_state_t state; /* State of free space*/ - - TEST_free_section_t *sect_node1 = NULL, *sect_node2, *sect_node3 = NULL, *sect_node4 = NULL; - TEST_free_section_t *node; - htri_t node_found = FALSE; - unsigned init_flags=0; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FS_t * frsp = NULL; /* pointer to free space structure */ + haddr_t fs_addr = HADDR_UNDEF; /* address of free space */ + uint16_t nclasses; + H5FS_create_t cparam; /* creation parameters */ + frspace_state_t state; /* State of free space*/ + + TEST_free_section_t *sect_node1 = NULL, *sect_node2, *sect_node3 = NULL, *sect_node4 = NULL; + TEST_free_section_t *node; + htri_t node_found = FALSE; + unsigned init_flags = 0; TESTING("H5FS_sect_find(): free-space is empty"); @@ -943,11 +934,11 @@ test_fs_sect_find(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -956,29 +947,29 @@ test_fs_sect_find(hid_t fapl) /* Tag with the global free space tag */ H5AC_tag(H5AC__FREESPACE_TAG, NULL); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)TEST_SECT_SIZE30, (H5FS_section_info_t **)&node)) < 0) + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)TEST_SECT_SIZE30, (H5FS_section_info_t **)&node)) < 0) FAIL_STACK_ERROR - if (node_found) TEST_ERROR + if (node_found) + TEST_ERROR - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; @@ -987,11 +978,11 @@ test_fs_sect_find(hid_t fapl) TESTING("H5FS_sect_find() a section equal to requested-size from free-space"); /* reopen the free-space manager */ - if(NULL == (frsp = H5FS_open(f, fs_addr, nclasses, - test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + if (NULL == (frsp = H5FS_open(f, fs_addr, nclasses, test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, + (hsize_t)FSPACE_ALIGN_DEF))) FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR if (frsp->nclasses != nclasses) TEST_ERROR @@ -999,13 +990,13 @@ test_fs_sect_find(hid_t fapl) /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); @@ -1013,100 +1004,99 @@ test_fs_sect_find(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - /* * Add section C */ - if(NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node3, (haddr_t)(TEST_SECT_ADDR200), (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node3, (haddr_t)(TEST_SECT_ADDR200), (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node3, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node3, H5FS_ADD_RETURNED_SPACE, NULL) < 0) FAIL_STACK_ERROR state.tot_space += sect_node3->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) FAIL_STACK_ERROR state.tot_space += sect_node2->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section D */ - if(NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR300, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR300, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node4, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node4, H5FS_ADD_RETURNED_SPACE, NULL) < 0) FAIL_STACK_ERROR state.tot_space += sect_node4->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0) + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0) FAIL_STACK_ERROR - if (!node_found) TEST_ERROR + if (!node_found) + TEST_ERROR if ((node->sect_info.addr != TEST_SECT_ADDR100) || (node->sect_info.size != TEST_SECT_SIZE50)) TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) TEST_ERROR /* remove sections A, C and D */ - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) FAIL_STACK_ERROR - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node3) < 0) + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node3) < 0) FAIL_STACK_ERROR - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node4) < 0) + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node4) < 0) FAIL_STACK_ERROR /* Free the section node(s) */ - if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + if (TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) TEST_ERROR sect_node1 = NULL; - if(TEST_sect_free((H5FS_section_info_t *)sect_node3) < 0) + if (TEST_sect_free((H5FS_section_info_t *)sect_node3) < 0) TEST_ERROR sect_node3 = NULL; - if(TEST_sect_free((H5FS_section_info_t *)sect_node4) < 0) + if (TEST_sect_free((H5FS_section_info_t *)sect_node4) < 0) TEST_ERROR sect_node4 = NULL; /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; @@ -1115,11 +1105,11 @@ test_fs_sect_find(hid_t fapl) TESTING("H5FS_sect_find() a section greater than requested-size from free-space"); /* reopen the free-space manager */ - if(NULL == (frsp = H5FS_open(f, fs_addr, nclasses, - test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + if (NULL == (frsp = H5FS_open(f, fs_addr, nclasses, test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, + (hsize_t)FSPACE_ALIGN_DEF))) FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR if (frsp->nclasses != nclasses) TEST_ERROR @@ -1127,13 +1117,13 @@ test_fs_sect_find(hid_t fapl) /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); @@ -1141,30 +1131,29 @@ test_fs_sect_find(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR200, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR200, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) FAIL_STACK_ERROR state.tot_space += sect_node2->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0) + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0) FAIL_STACK_ERROR if (!node_found) @@ -1172,21 +1161,21 @@ test_fs_sect_find(hid_t fapl) if ((node->sect_info.addr != TEST_SECT_ADDR200) || (node->sect_info.size < TEST_SECT_SIZE50)) TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) TEST_ERROR node = NULL; /* remove sections A */ - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) FAIL_STACK_ERROR /* Free the section node(s) */ - if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + if (TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) TEST_ERROR sect_node1 = NULL; /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; @@ -1195,11 +1184,11 @@ test_fs_sect_find(hid_t fapl) TESTING("H5FS_sect_find(): cannot find a section with requested-size from free-space"); /* reopen the free-space manager */ - if(NULL == (frsp = H5FS_open(f, fs_addr, nclasses, - test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_open(f, fs_addr, nclasses, test_classes, NULL, (hsize_t)FSPACE_THRHD_DEF, + (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR if (frsp->nclasses != nclasses) TEST_ERROR @@ -1207,13 +1196,13 @@ test_fs_sect_find(hid_t fapl) /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); @@ -1221,36 +1210,36 @@ test_fs_sect_find(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0) + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node)) < 0) FAIL_STACK_ERROR - if (node_found) TEST_ERROR + if (node_found) + TEST_ERROR /* remove sections A */ - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) FAIL_STACK_ERROR /* Free the section node(s) */ - if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + if (TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) TEST_ERROR sect_node1 = NULL; /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) + if (H5FS_delete(f, fs_addr) < 0) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -1258,21 +1247,22 @@ test_fs_sect_find(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - if(sect_node1) + H5E_BEGIN_TRY + { + if (sect_node1) TEST_sect_free((H5FS_section_info_t *)sect_node1); - if(sect_node3) + if (sect_node3) TEST_sect_free((H5FS_section_info_t *)sect_node3); - if(sect_node4) + if (sect_node4) TEST_sect_free((H5FS_section_info_t *)sect_node4); - if(frsp) - H5FS_close(f, frsp); + if (frsp) + H5FS_close(f, frsp); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_fs_sect_find() */ - /* * To verify that sections are merged when adding sections to free-space * @@ -1308,19 +1298,19 @@ error: static unsigned test_fs_sect_merge(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FS_t *frsp = NULL; /* pointer to free space structure */ - haddr_t fs_addr=HADDR_UNDEF; /* address of free space */ - uint16_t nclasses; - H5FS_create_t cparam; /* creation parameters */ - frspace_state_t state; /* State of free space*/ - - TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL, *sect_node3=NULL, *sect_node4=NULL; - unsigned init_flags=0; - htri_t node_found = FALSE; - TEST_free_section_t *node; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FS_t * frsp = NULL; /* pointer to free space structure */ + haddr_t fs_addr = HADDR_UNDEF; /* address of free space */ + uint16_t nclasses; + H5FS_create_t cparam; /* creation parameters */ + frspace_state_t state; /* State of free space*/ + + TEST_free_section_t *sect_node1 = NULL, *sect_node2 = NULL, *sect_node3 = NULL, *sect_node4 = NULL; + unsigned init_flags = 0; + htri_t node_found = FALSE; + TEST_free_section_t *node; TESTING("the merge of sections when H5FS_sect_add() to free-space: test 1"); @@ -1331,11 +1321,11 @@ test_fs_sect_merge(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -1344,113 +1334,114 @@ test_fs_sect_merge(hid_t fapl) /* Tag with the global free space tag */ H5AC_tag(H5AC__FREESPACE_TAG, NULL); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section C */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += TEST_SECT_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* section B & C are merged */ state.tot_space += TEST_SECT_SIZE30; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE10, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE10, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node3, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node3, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* section A is merged with the merged section of B & C */ state.tot_space += TEST_SECT_SIZE10; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section D */ - if(NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR150, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR150, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node4, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node4, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* section D is merged with the merged section of A & B & C */ state.tot_space += TEST_SECT_SIZE80; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - /* should be able to find the merged section of A, B, C & D */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE10+TEST_SECT_SIZE30+TEST_SECT_SIZE50+TEST_SECT_SIZE80), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find( + f, frsp, (hsize_t)(TEST_SECT_SIZE10 + TEST_SECT_SIZE30 + TEST_SECT_SIZE50 + TEST_SECT_SIZE80), + (H5FS_section_info_t **)&node)) < 0) + FAIL_STACK_ERROR - if (!node_found) TEST_ERROR + if (!node_found) + TEST_ERROR if ((node->sect_info.addr != TEST_SECT_ADDR60) || - (node->sect_info.size != (TEST_SECT_SIZE10+TEST_SECT_SIZE30+TEST_SECT_SIZE50+TEST_SECT_SIZE80))) - TEST_ERROR + (node->sect_info.size != (TEST_SECT_SIZE10 + TEST_SECT_SIZE30 + TEST_SECT_SIZE50 + TEST_SECT_SIZE80))) + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -1461,98 +1452,99 @@ test_fs_sect_merge(hid_t fapl) TESTING("the merge of sections when H5FS_sect_add() to free-space: test 2"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); nclasses = NELMTS(test_classes); init_flags = H5FS_CLS_SEPAR_OBJ; - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += TEST_SECT_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* section A & B are not merged because H5FS_CLS_SEPAR_OBJ is set */ state.tot_space += TEST_SECT_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* should not be able to find the merged section of A & B */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE30+TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE30 + TEST_SECT_SIZE50), + (H5FS_section_info_t **)&node)) < 0) + FAIL_STACK_ERROR - if (node_found) TEST_ERROR + if (node_found) + TEST_ERROR /* remove section A from free-space */ - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) + FAIL_STACK_ERROR /* remove section B from free-space */ - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node2) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node2) < 0) + FAIL_STACK_ERROR /* Free the section node(s) */ - if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + TEST_ERROR sect_node1 = NULL; - if(TEST_sect_free((H5FS_section_info_t *)sect_node2) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)sect_node2) < 0) + TEST_ERROR sect_node2 = NULL; /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -1563,93 +1555,93 @@ test_fs_sect_merge(hid_t fapl) TESTING("the merge of sections when H5FS_sect_add() to free-space: test 3"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); nclasses = NELMTS(test_classes); init_flags = 0; /* reset */ - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE10, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE10, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += TEST_SECT_SIZE10; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, + TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* sections A & B are not merged because H5FS_CLS_MERGE_SYM is set & section class type is different */ state.tot_space += TEST_SECT_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section C */ - if(NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE); + init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, + TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node3, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node3, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* sections B & C are merged because H5FS_CLS_MERGE_SYM is set & section class type is the same */ state.tot_space += TEST_SECT_SIZE50; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section D */ - if(NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node4 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR150, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node4, (haddr_t)TEST_SECT_ADDR150, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node4, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node4, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* * section D is not merged with the merged section of B & C because @@ -1659,68 +1651,73 @@ test_fs_sect_merge(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* should not be able to find a merged section of A, B, C & D */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE10+TEST_SECT_SIZE30+TEST_SECT_SIZE50+TEST_SECT_SIZE80), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find( + f, frsp, (hsize_t)(TEST_SECT_SIZE10 + TEST_SECT_SIZE30 + TEST_SECT_SIZE50 + TEST_SECT_SIZE80), + (H5FS_section_info_t **)&node)) < 0) + FAIL_STACK_ERROR - if (node_found) TEST_ERROR + if (node_found) + TEST_ERROR /* should be able to find the merged section of B & C */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE30+TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE30 + TEST_SECT_SIZE50), + (H5FS_section_info_t **)&node)) < 0) + FAIL_STACK_ERROR - if (!node_found) TEST_ERROR + if (!node_found) + TEST_ERROR if ((node->sect_info.addr != TEST_SECT_ADDR70) || - (node->sect_info.size != (TEST_SECT_SIZE30+TEST_SECT_SIZE50))) - TEST_ERROR + (node->sect_info.size != (TEST_SECT_SIZE30 + TEST_SECT_SIZE50))) + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR /* should be able to find section A */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE10), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE10), (H5FS_section_info_t **)&node)) < + 0) + FAIL_STACK_ERROR - if (!node_found) TEST_ERROR + if (!node_found) + TEST_ERROR if ((node->sect_info.addr != TEST_SECT_ADDR60) || (node->sect_info.size != TEST_SECT_SIZE10)) - TEST_ERROR + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR /* should be able to find section D */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE80), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE80), (H5FS_section_info_t **)&node)) < + 0) + FAIL_STACK_ERROR - if (!node_found) TEST_ERROR + if (!node_found) + TEST_ERROR if ((node->sect_info.addr != TEST_SECT_ADDR150) || (node->sect_info.size != TEST_SECT_SIZE80)) - TEST_ERROR + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -1728,15 +1725,17 @@ test_fs_sect_merge(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - if(sect_node1) + H5E_BEGIN_TRY + { + if (sect_node1) TEST_sect_free((H5FS_section_info_t *)sect_node1); - if(sect_node2) + if (sect_node2) TEST_sect_free((H5FS_section_info_t *)sect_node2); - if(frsp) + if (frsp) H5FS_close(f, frsp); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_fs_sect_merge() */ @@ -1777,20 +1776,20 @@ error: static unsigned test_fs_sect_shrink(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FS_t *frsp = NULL; /* pointer to free space structure */ - haddr_t fs_addr=HADDR_UNDEF; /* address of free space */ - uint16_t nclasses; - H5FS_create_t cparam; /* creation parameters */ - frspace_state_t state; /* State of free space*/ - - TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL; - unsigned init_flags=0; - unsigned can_shrink=FALSE; - htri_t node_found = FALSE; - TEST_free_section_t *node; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FS_t * frsp = NULL; /* pointer to free space structure */ + haddr_t fs_addr = HADDR_UNDEF; /* address of free space */ + uint16_t nclasses; + H5FS_create_t cparam; /* creation parameters */ + frspace_state_t state; /* State of free space*/ + + TEST_free_section_t *sect_node1 = NULL, *sect_node2 = NULL; + unsigned init_flags = 0; + unsigned can_shrink = FALSE; + htri_t node_found = FALSE; + TEST_free_section_t *node; TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 1"); @@ -1798,202 +1797,203 @@ test_fs_sect_shrink(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); nclasses = NELMTS(test_classes); - TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ + TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ /* Tag with the global free space tag */ H5AC_tag(H5AC__FREESPACE_TAG, NULL); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A that allow shrinking but its section class type does not define "can_shrink" */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, + TEST_FSPACE_SECT_TYPE_NEW, H5FS_SECT_LIVE); can_shrink = FALSE; - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += sect_node1->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* section A should still be there in free-space */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < + 0) + FAIL_STACK_ERROR - if (!node_found) TEST_ERROR + if (!node_found) + TEST_ERROR if ((node->sect_info.addr != TEST_SECT_ADDR100) || (node->sect_info.size != TEST_SECT_SIZE50)) - TEST_ERROR + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR /* * Re-add section A that allow shrinking and its section class type defines "can_shrink" */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); can_shrink = FALSE; - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) FAIL_STACK_ERROR /* should have nothing in free-space */ HDmemset(&state, 0, sizeof(frspace_state_t)); - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* section A should not be there in free-space */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0) + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < + 0) FAIL_STACK_ERROR - if (node_found) TEST_ERROR + if (node_found) + TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) + if (H5FS_close(f, frsp) < 0) FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) + if (H5FS_delete(f, fs_addr) < 0) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); - TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 2"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); nclasses = NELMTS(test_classes); - TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ + TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ /* does not allow merging */ init_flags = H5FS_CLS_SEPAR_OBJ; - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += sect_node1->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) + FAIL_STACK_ERROR /* free-space should be the same since section B is shrunk */ - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* section B should not be there in free-space */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < + 0) + FAIL_STACK_ERROR if (node_found) TEST_ERROR - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - /* section A should still be there in free-space */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE20), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE20), (H5FS_section_info_t **)&node)) < + 0) + FAIL_STACK_ERROR - if (!node_found) TEST_ERROR + if (!node_found) + TEST_ERROR if ((node->sect_info.addr != TEST_SECT_ADDR80) || (node->sect_info.size != TEST_SECT_SIZE20)) - TEST_ERROR + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2001,90 +2001,91 @@ test_fs_sect_shrink(hid_t fapl) TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 3"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); nclasses = NELMTS(test_classes); - TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ + TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ init_flags = 0; /* reset */ - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += sect_node1->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, &can_shrink) < 0) + FAIL_STACK_ERROR /* section A & B are merged and then strunk, so there is nothing in free-space */ HDmemset(&state, 0, sizeof(frspace_state_t)); - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* section B should not be there in free-space */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE50), (H5FS_section_info_t **)&node)) < + 0) + FAIL_STACK_ERROR if (node_found) TEST_ERROR /* section A should not be there in free-space */ - if((node_found = H5FS_sect_find(f, frsp, - (hsize_t)(TEST_SECT_SIZE30), (H5FS_section_info_t **)&node)) < 0) - FAIL_STACK_ERROR + if ((node_found = H5FS_sect_find(f, frsp, (hsize_t)(TEST_SECT_SIZE30), (H5FS_section_info_t **)&node)) < + 0) + FAIL_STACK_ERROR - if (node_found) TEST_ERROR + if (node_found) + TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2092,11 +2093,13 @@ test_fs_sect_shrink(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - if(frsp) - H5FS_close(f, frsp); + H5E_BEGIN_TRY + { + if (frsp) + H5FS_close(f, frsp); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_sect_shrink() */ @@ -2120,18 +2123,18 @@ error: static unsigned test_fs_sect_change_class(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FS_t *frsp = NULL; /* pointer to free space structure */ - haddr_t fs_addr=HADDR_UNDEF; /* address of free space */ - uint16_t nclasses; - H5FS_create_t cparam; /* creation parameters */ - frspace_state_t state; /* State of free space*/ - - TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL, *sect_node3=NULL; - unsigned init_flags=0; - TEST_free_section_t *node; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FS_t * frsp = NULL; /* pointer to free space structure */ + haddr_t fs_addr = HADDR_UNDEF; /* address of free space */ + uint16_t nclasses; + H5FS_create_t cparam; /* creation parameters */ + frspace_state_t state; /* State of free space*/ + + TEST_free_section_t *sect_node1 = NULL, *sect_node2 = NULL, *sect_node3 = NULL; + unsigned init_flags = 0; + TEST_free_section_t *node; TESTING("the change of section class via H5FS_sect_change_class() in free-space: Test 1"); @@ -2139,11 +2142,11 @@ test_fs_sect_change_class(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -2153,91 +2156,89 @@ test_fs_sect_change_class(hid_t fapl) H5AC_tag(H5AC__FREESPACE_TAG, NULL); init_flags = H5FS_CLS_GHOST_OBJ; - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR60, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += TEST_SECT_SIZE30; state.tot_sect_count += 1; state.ghost_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, + TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR state.tot_space += TEST_SECT_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR - if (H5FS_sect_change_class(f, frsp, (H5FS_section_info_t *)sect_node1, - TEST_FSPACE_SECT_TYPE_NONE) < 0) + if (H5FS_sect_change_class(f, frsp, (H5FS_section_info_t *)sect_node1, TEST_FSPACE_SECT_TYPE_NONE) < 0) TEST_ERROR state.serial_sect_count += 1; - state.ghost_sect_count -=1; - if(check_stats(f, frsp, &state)) + state.ghost_sect_count -= 1; + if (check_stats(f, frsp, &state)) TEST_ERROR - if(H5FS_sect_find(f, frsp, - (hsize_t)TEST_SECT_SIZE30, (H5FS_section_info_t **)&node) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_find(f, frsp, (hsize_t)TEST_SECT_SIZE30, (H5FS_section_info_t **)&node) < 0) + FAIL_STACK_ERROR if (node->sect_info.type != TEST_FSPACE_SECT_TYPE_NONE) - TEST_ERROR + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node2) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node2) < 0) + FAIL_STACK_ERROR /* Free the section node(s) */ - if(TEST_sect_free((H5FS_section_info_t *)sect_node2) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)sect_node2) < 0) + TEST_ERROR sect_node2 = NULL; /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2248,118 +2249,114 @@ test_fs_sect_change_class(hid_t fapl) TESTING("the merge of sections when H5FS_sect_add() to free-space: test 2"); /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); nclasses = NELMTS(test_classes); init_flags = H5FS_CLS_SEPAR_OBJ; - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE30, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE50, + TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* * Add section C */ - if(NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node3 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR200, (hsize_t)TEST_SECT_SIZE80, TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE); + init_sect_node(sect_node3, (haddr_t)TEST_SECT_ADDR200, (hsize_t)TEST_SECT_SIZE80, + TEST_FSPACE_SECT_TYPE_NONE, H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node3, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node3, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR /* change the class of B to A's class */ - if (H5FS_sect_change_class(f, frsp, (H5FS_section_info_t *)sect_node2, - TEST_FSPACE_SECT_TYPE) < 0) - TEST_ERROR + if (H5FS_sect_change_class(f, frsp, (H5FS_section_info_t *)sect_node2, TEST_FSPACE_SECT_TYPE) < 0) + TEST_ERROR /* change the class of C to A's class */ - if (H5FS_sect_change_class(f, frsp, (H5FS_section_info_t *)sect_node3, - TEST_FSPACE_SECT_TYPE) < 0) - TEST_ERROR + if (H5FS_sect_change_class(f, frsp, (H5FS_section_info_t *)sect_node3, TEST_FSPACE_SECT_TYPE) < 0) + TEST_ERROR /* the merge_list should be empty */ if (frsp->sinfo->merge_list) - if (H5SL_count(frsp->sinfo->merge_list)) - TEST_ERROR + if (H5SL_count(frsp->sinfo->merge_list)) + TEST_ERROR /* verify that section B has changed class */ - if(H5FS_sect_find(f, frsp, - (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_find(f, frsp, (hsize_t)TEST_SECT_SIZE50, (H5FS_section_info_t **)&node) < 0) + FAIL_STACK_ERROR if (node->sect_info.type != TEST_FSPACE_SECT_TYPE) - TEST_ERROR + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR /* verify that section C has changed class */ - if(H5FS_sect_find(f, frsp, - (hsize_t)TEST_SECT_SIZE80, (H5FS_section_info_t **)&node) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_find(f, frsp, (hsize_t)TEST_SECT_SIZE80, (H5FS_section_info_t **)&node) < 0) + FAIL_STACK_ERROR if (node->sect_info.type != TEST_FSPACE_SECT_TYPE) - TEST_ERROR + TEST_ERROR - if(TEST_sect_free((H5FS_section_info_t *)node) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)node) < 0) + TEST_ERROR /* remove section A from free-space */ - if(H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_remove(f, frsp, (H5FS_section_info_t *)sect_node1) < 0) + FAIL_STACK_ERROR /* Free the section node(s) */ - if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) - TEST_ERROR + if (TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) + TEST_ERROR sect_node1 = NULL; /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2367,19 +2364,20 @@ test_fs_sect_change_class(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - if(sect_node1) + H5E_BEGIN_TRY + { + if (sect_node1) TEST_sect_free((H5FS_section_info_t *)sect_node1); - if(sect_node2) + if (sect_node2) TEST_sect_free((H5FS_section_info_t *)sect_node2); - if(frsp) + if (frsp) H5FS_close(f, frsp); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_sect_change_class() */ - /* * To verify the extension of a block using space from a section in free-space * @@ -2413,28 +2411,28 @@ error: static unsigned test_fs_sect_extend(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FS_t *frsp = NULL; /* pointer to free space structure */ - haddr_t fs_addr=HADDR_UNDEF; /* address of free space */ - uint16_t nclasses; - H5FS_create_t cparam; /* creation parameters */ - frspace_state_t state; /* State of free space*/ - TEST_free_section_t *sect_node1=NULL, *sect_node2=NULL; - unsigned init_flags=0; - htri_t status; /* Status of 'try' calls */ + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FS_t * frsp = NULL; /* pointer to free space structure */ + haddr_t fs_addr = HADDR_UNDEF; /* address of free space */ + uint16_t nclasses; + H5FS_create_t cparam; /* creation parameters */ + frspace_state_t state; /* State of free space*/ + TEST_free_section_t *sect_node1 = NULL, *sect_node2 = NULL; + unsigned init_flags = 0; + htri_t status; /* Status of 'try' calls */ TESTING("a block's extension by requested-size which is = adjoining free section's size: Test 1"); h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Tag with the global free space tag */ @@ -2446,73 +2444,74 @@ test_fs_sect_extend(hid_t fapl) init_cparam(&cparam); nclasses = NELMTS(test_classes); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += sect_node1->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR state.tot_space += sect_node2->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Extend a block by requested-size */ - if((status = H5FS_sect_try_extend(f, frsp, (haddr_t)TEST_SECT_SIZE80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE40, 0, NULL)) < 0) - FAIL_STACK_ERROR - if(FALSE == status) + if ((status = H5FS_sect_try_extend(f, frsp, (haddr_t)TEST_SECT_SIZE80, (hsize_t)TEST_SECT_SIZE20, + (hsize_t)TEST_SECT_SIZE40, 0, NULL)) < 0) + FAIL_STACK_ERROR + if (FALSE == status) TEST_ERROR /* Succeed in extending the block: free space info is decremented accordingly */ state.tot_space -= (hsize_t)TEST_SECT_SIZE40; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; PASSED(); @@ -2522,70 +2521,71 @@ test_fs_sect_extend(hid_t fapl) */ TESTING("a block's extension by requested-size which is > adjoining free section's size: Test 2"); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += sect_node1->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR state.tot_space += sect_node2->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Extend the block by requested-size */ - if((status = H5FS_sect_try_extend(f, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE50, 0, NULL)) < 0) - FAIL_STACK_ERROR - if(TRUE == status) + if ((status = H5FS_sect_try_extend(f, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, + (hsize_t)TEST_SECT_SIZE50, 0, NULL)) < 0) + FAIL_STACK_ERROR + if (TRUE == status) TEST_ERROR /* Not able to extend the block: free space info remains the same */ - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; PASSED(); @@ -2595,71 +2595,72 @@ test_fs_sect_extend(hid_t fapl) */ TESTING("a block's extension by requested-size which is < adjoining free section's size: Test 3"); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += sect_node1->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR state.tot_space += sect_node2->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Extend the block by requested-size */ - if((status = H5FS_sect_try_extend(f, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, (hsize_t)TEST_SECT_SIZE30, 0, NULL)) < 0) - TEST_ERROR - if(FALSE == status) + if ((status = H5FS_sect_try_extend(f, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE20, + (hsize_t)TEST_SECT_SIZE30, 0, NULL)) < 0) + TEST_ERROR + if (FALSE == status) TEST_ERROR /* Succeed in extending the block: total free space is decreased but other info remains the same */ state.tot_space -= 30; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; PASSED(); @@ -2669,90 +2670,92 @@ test_fs_sect_extend(hid_t fapl) */ TESTING("a block's extension by requested-size which does not adjoin any free section: Test 4"); - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR /* * Add section A */ - if(NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node1 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node1, (haddr_t)TEST_SECT_ADDR70, (hsize_t)TEST_SECT_SIZE5, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node1, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(frspace_state_t)); state.tot_space += sect_node1->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* * Add section B */ - if(NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node2 = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + init_sect_node(sect_node2, (haddr_t)TEST_SECT_ADDR100, (hsize_t)TEST_SECT_SIZE40, TEST_FSPACE_SECT_TYPE, + H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node2, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR state.tot_space += sect_node2->sect_info.size; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Extend the block by requested-size */ - if((status = H5FS_sect_try_extend(f, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE15, (hsize_t)TEST_SECT_SIZE40, 0, NULL)) < 0) - TEST_ERROR - if(TRUE == status) + if ((status = H5FS_sect_try_extend(f, frsp, (haddr_t)TEST_SECT_ADDR80, (hsize_t)TEST_SECT_SIZE15, + (hsize_t)TEST_SECT_SIZE40, 0, NULL)) < 0) + TEST_ERROR + if (TRUE == status) TEST_ERROR /* Not able to extend the block: free space manager info remains the same */ - if(check_stats(f, frsp, &state)) + if (check_stats(f, frsp, &state)) TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; PASSED(); /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR return 0; error: - H5E_BEGIN_TRY { - if(frsp) + H5E_BEGIN_TRY + { + if (frsp) H5FS_close(f, frsp); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_sect_extend() */ - /* * To verify the iteration of free-space sections * @@ -2764,19 +2767,19 @@ error: static unsigned test_fs_sect_iterate(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FS_t *frsp = NULL; /* pointer to free space structure */ - haddr_t fs_addr=HADDR_UNDEF; /* address of free space */ - uint16_t nclasses; - H5FS_create_t cparam; /* creation parameters */ - - TEST_free_section_t *sect_node=NULL; - unsigned init_flags=0, sect_size; - TEST_iter_ud_t udata; - int i; - hsize_t tot_space, nsects; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FS_t * frsp = NULL; /* pointer to free space structure */ + haddr_t fs_addr = HADDR_UNDEF; /* address of free space */ + uint16_t nclasses; + H5FS_create_t cparam; /* creation parameters */ + + TEST_free_section_t *sect_node = NULL; + unsigned init_flags = 0, sect_size; + TEST_iter_ud_t udata; + int i; + hsize_t tot_space, nsects; TESTING("iteration of sections in the free-space manager"); @@ -2784,63 +2787,62 @@ test_fs_sect_iterate(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); - nclasses = NELMTS(test_classes); - udata.tot_size = 0; + nclasses = NELMTS(test_classes); + udata.tot_size = 0; udata.tot_sect_count = 0; /* Tag with the global free space tag */ H5AC_tag(H5AC__FREESPACE_TAG, NULL); init_flags = H5FS_CLS_SEPAR_OBJ; - if(NULL == (frsp = H5FS_create(f, &fs_addr, - &cparam, nclasses, test_classes, &init_flags, (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) - FAIL_STACK_ERROR + if (NULL == (frsp = H5FS_create(f, &fs_addr, &cparam, nclasses, test_classes, &init_flags, + (hsize_t)FSPACE_THRHD_DEF, (hsize_t)FSPACE_ALIGN_DEF))) + FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_addr)) + if (!H5F_addr_defined(fs_addr)) TEST_ERROR for (i = 1; i <= NUM_SECTIONS; i++) { - if(NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) - FAIL_STACK_ERROR + if (NULL == (sect_node = (TEST_free_section_t *)HDmalloc(sizeof(TEST_free_section_t)))) + FAIL_STACK_ERROR - sect_size = (unsigned)((i-1) % 9) + 1; - init_sect_node(sect_node, (haddr_t)i*10, (hsize_t)sect_size, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); + sect_size = (unsigned)((i - 1) % 9) + 1; + init_sect_node(sect_node, (haddr_t)i * 10, (hsize_t)sect_size, TEST_FSPACE_SECT_TYPE, H5FS_SECT_LIVE); - if(H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, - H5FS_ADD_RETURNED_SPACE, NULL) < 0) - FAIL_STACK_ERROR + if (H5FS_sect_add(f, frsp, (H5FS_section_info_t *)sect_node, H5FS_ADD_RETURNED_SPACE, NULL) < 0) + FAIL_STACK_ERROR } /* end for */ - if(H5FS_sect_iterate(f, frsp, TEST_sects_cb, &udata) < 0) - TEST_ERROR + if (H5FS_sect_iterate(f, frsp, TEST_sects_cb, &udata) < 0) + TEST_ERROR H5FS_sect_stats(frsp, &tot_space, &nsects); if (udata.tot_size != tot_space) - TEST_ERROR + TEST_ERROR if (udata.tot_sect_count != nsects) - TEST_ERROR + TEST_ERROR /* Close the free space manager */ - if(H5FS_close(f, frsp) < 0) - FAIL_STACK_ERROR + if (H5FS_close(f, frsp) < 0) + FAIL_STACK_ERROR frsp = NULL; /* Delete free space manager */ - if(H5FS_delete(f, fs_addr) < 0) - FAIL_STACK_ERROR + if (H5FS_delete(f, fs_addr) < 0) + FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2848,35 +2850,37 @@ test_fs_sect_iterate(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - if(frsp) + H5E_BEGIN_TRY + { + if (frsp) H5FS_close(f, frsp); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_fs_sect_iterate() */ - int main(void) { - hid_t fapl = -1; /* File access property list for data files */ - unsigned nerrors = 0; /* Cumulative error count */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t fapl = -1; /* File access property list for data files */ + unsigned nerrors = 0; /* Cumulative error count */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ h5_reset(); - if((fapl = h5_fileaccess()) < 0) { + if ((fapl = h5_fileaccess()) < 0) { nerrors++; PUTS_ERROR("Can't get VFD-dependent fapl") } /* end if */ /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* make sure alignment is not set for tests to succeed */ - if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0) { + if (H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0) { nerrors++; PUTS_ERROR("Can't set alignment") } /* end if */ @@ -2893,12 +2897,13 @@ main(void) /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if(nerrors) + if (nerrors) goto error; HDputs("All free-space tests passed."); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; h5_cleanup(FILENAME, fapl); @@ -2906,12 +2911,14 @@ main(void) error: HDputs("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); HDexit(EXIT_FAILURE); } /* main() */ - diff --git a/test/gen_bad_compound.c b/test/gen_bad_compound.c index 292659c..8002368 100644 --- a/test/gen_bad_compound.c +++ b/test/gen_bad_compound.c @@ -26,16 +26,17 @@ #define FILENAME "bad_compound.h5" -int main() +int +main() { - hid_t file; - hid_t cmpd_dt; - hid_t sid; - hid_t did; - hid_t aid; - hid_t gid; - hsize_t dim = 1; - herr_t ret; + hid_t file; + hid_t cmpd_dt; + hid_t sid; + hid_t did; + hid_t aid; + hid_t gid; + hsize_t dim = 1; + herr_t ret; /* Create compound datatype, but don't insert fields */ cmpd_dt = H5Tcreate(H5T_COMPOUND, (size_t)8); @@ -79,6 +80,5 @@ int main() ret = H5Fclose(file); assert(ret >= 0); - return(0); + return (0); } - diff --git a/test/gen_bad_offset.c b/test/gen_bad_offset.c index b485e36..e9b37b8 100644 --- a/test/gen_bad_offset.c +++ b/test/gen_bad_offset.c @@ -16,15 +16,13 @@ */ #include "h5test.h" -#define TESTFILE "bad_offset.h5" -#define GRP1 "group1" -#define GRP2 "group2" -#define DSET "dsetA" -#define SOFT1 "soft_one" -#define SOFT2 "soft_two" +#define TESTFILE "bad_offset.h5" +#define GRP1 "group1" +#define GRP2 "group2" +#define DSET "dsetA" +#define SOFT1 "soft_one" +#define SOFT2 "soft_two" - - /*------------------------------------------------------------------------- * Function: main * @@ -53,49 +51,49 @@ int main(void) { - hid_t fid = -1, gid1 = -1, gid2 = -1; /* File and group IDs */ - hid_t did = -1, sid = -1; /* Dataset and dataspace IDs */ - int fd = -1; /* File descriptor */ - int64_t val = 999; /* Bad offset value */ + hid_t fid = -1, gid1 = -1, gid2 = -1; /* File and group IDs */ + hid_t did = -1, sid = -1; /* Dataset and dataspace IDs */ + int fd = -1; /* File descriptor */ + int64_t val = 999; /* Bad offset value */ /* Create the test file */ - if((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create two groups */ - if((gid1 = H5Gcreate2(fid, GRP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid1 = H5Gcreate2(fid, GRP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gid2 = H5Gcreate2(gid1, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(gid1, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close the groups */ - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) FAIL_STACK_ERROR /* Create soft links to the groups */ - if(H5Lcreate_soft("/group1", fid, SOFT1, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/group1", fid, SOFT1, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("/group1/group2", fid, SOFT2, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/group1/group2", fid, SOFT2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Create a dataset */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR - if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -103,45 +101,46 @@ main(void) */ /* Open the file */ - if((fd = HDopen(TESTFILE, O_RDWR, 0663)) < 0) + if ((fd = HDopen(TESTFILE, O_RDWR, 0663)) < 0) FAIL_STACK_ERROR /* Position the file for /group1/group2: replace heap offset "8" by bad offset */ - if(HDlseek(fd, (HDoff_t)880, SEEK_SET) < 0) + if (HDlseek(fd, (HDoff_t)880, SEEK_SET) < 0) FAIL_STACK_ERROR /* Write the bad offset value to the file */ - if(HDwrite(fd, &val, sizeof(val)) < 0) + if (HDwrite(fd, &val, sizeof(val)) < 0) FAIL_STACK_ERROR /* Position the file for /dsetA: replace name offset into private heap "72" by bad offset */ - if(HDlseek(fd, (HDoff_t)1512, SEEK_SET) < 0) + if (HDlseek(fd, (HDoff_t)1512, SEEK_SET) < 0) FAIL_STACK_ERROR /* Write the bad offset value to the file */ - if(HDwrite(fd, &val, sizeof(val)) < 0) + if (HDwrite(fd, &val, sizeof(val)) < 0) FAIL_STACK_ERROR /* Position the file for /soft_one: replace link value offset in the scratch pad "32" by bad offset */ - if(HDlseek(fd, (HDoff_t)1616, SEEK_SET) < 0) + if (HDlseek(fd, (HDoff_t)1616, SEEK_SET) < 0) FAIL_STACK_ERROR /* Write the bad offset value to the file */ - if(HDwrite(fd, &val, sizeof(val)) < 0) + if (HDwrite(fd, &val, sizeof(val)) < 0) FAIL_STACK_ERROR /* Close the file */ - if(HDclose(fd) < 0) + if (HDclose(fd) < 0) FAIL_STACK_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid1); H5Gclose(gid2); H5Dclose(did); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return EXIT_FAILURE; } /* end main() */ - diff --git a/test/gen_bad_ohdr.c b/test/gen_bad_ohdr.c index 36ba64a..0199ad9 100644 --- a/test/gen_bad_ohdr.c +++ b/test/gen_bad_ohdr.c @@ -27,7 +27,7 @@ #include "H5Oprivate.h" #ifdef H5O_ENABLE_BAD_MESG_COUNT -#define FILENAME "tbad_msg_count.h5" +#define FILENAME "tbad_msg_count.h5" #define GROUPNAME "Group" #define ATTRNAME1 "Attribute #1" #define ATTRNAME2 "Attribute #2" @@ -40,64 +40,80 @@ #define FALSE 0 #endif /* FALSE */ -int main(void) +int +main(void) { #ifdef H5O_ENABLE_BAD_MESG_COUNT - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t gcpl = -1; /* Group creation property list ID */ - hbool_t store_bad_mesg_count; /* Flag for storing a bad message count */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t gcpl = -1; /* Group creation property list ID */ + hbool_t store_bad_mesg_count; /* Flag for storing a bad message count */ /* Create test file */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* Create group creation property list */ - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error; + if ((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + goto error; /* Add property for storing bad message count */ store_bad_mesg_count = TRUE; - if(H5Pinsert2(gcpl, H5O_BAD_MESG_COUNT_NAME, H5O_BAD_MESG_COUNT_SIZE, &store_bad_mesg_count, NULL, NULL, NULL, NULL, NULL, NULL) < 0) goto error; + if (H5Pinsert2(gcpl, H5O_BAD_MESG_COUNT_NAME, H5O_BAD_MESG_COUNT_SIZE, &store_bad_mesg_count, NULL, NULL, + NULL, NULL, NULL, NULL) < 0) + goto error; /* Create group with bad object header message count */ - if((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) goto error; + if ((gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) + goto error; /* Close group creation property list */ - if(H5Pclose(gcpl) < 0) goto error; + if (H5Pclose(gcpl) < 0) + goto error; /* Create dataspace for attributes */ - if((sid = H5Screate(H5S_SCALAR)) < 0) goto error; + if ((sid = H5Screate(H5S_SCALAR)) < 0) + goto error; /* Create attribute on root group */ - if((aid = H5Acreate2(gid, ATTRNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(aid) < 0) goto error; + if ((aid = H5Acreate2(gid, ATTRNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Aclose(aid) < 0) + goto error; /* Create another attribute on root group */ - if((aid = H5Acreate2(gid, ATTRNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(aid) < 0) goto error; + if ((aid = H5Acreate2(gid, ATTRNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Aclose(aid) < 0) + goto error; /* Close dataspace */ - if(H5Sclose(sid) < 0) goto error; + if (H5Sclose(sid) < 0) + goto error; /* Close group */ - if(H5Gclose(gid) < 0) goto error; + if (H5Gclose(gid) < 0) + goto error; /* Close file */ - if(H5Fclose(fid) < 0) goto error; + if (H5Fclose(fid) < 0) + goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(aid); H5Sclose(sid); H5Pclose(gcpl); H5Fclose(fid); - } H5E_END_TRY; -#else /* H5O_ENABLE_BAD_MESG_COUNT */ + } + H5E_END_TRY; +#else /* H5O_ENABLE_BAD_MESG_COUNT */ HDputs("H5O_BAD_MESG_COUNT compiler macro not defined!"); #endif /* H5O_ENABLE_BAD_MESG_COUNT */ return 1; } - diff --git a/test/gen_bogus.c b/test/gen_bogus.c index ab2620f..b21adeb 100644 --- a/test/gen_bogus.c +++ b/test/gen_bogus.c @@ -44,114 +44,143 @@ static int generate_datasets(hid_t loc_id, unsigned bogus_id) { - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t did = -1; /* Dataset ID */ - uint8_t bogus_flags = 0; /* Flags for bogus message */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t did = -1; /* Dataset ID */ + uint8_t bogus_flags = 0; /* Flags for bogus message */ /* Create dataspace for datasets */ - if((sid = H5Screate(H5S_SCALAR)) < 0) goto error; + if ((sid = H5Screate(H5S_SCALAR)) < 0) + goto error; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* Add property for bogus message flags */ - if(H5Pinsert2(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, H5O_BOGUS_MSG_FLAGS_SIZE, &bogus_flags, NULL, NULL, NULL, NULL, NULL, NULL) < 0) goto error; + if (H5Pinsert2(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, H5O_BOGUS_MSG_FLAGS_SIZE, &bogus_flags, NULL, NULL, NULL, + NULL, NULL, NULL) < 0) + goto error; /* Add property for bogus message ID */ - if(H5Pinsert2(dcpl, H5O_BOGUS_MSG_ID_NAME, H5O_BOGUS_MSG_ID_SIZE, &bogus_id, NULL, NULL, NULL, NULL, NULL, NULL) < 0) goto error; + if (H5Pinsert2(dcpl, H5O_BOGUS_MSG_ID_NAME, H5O_BOGUS_MSG_ID_SIZE, &bogus_id, NULL, NULL, NULL, NULL, + NULL, NULL) < 0) + goto error; /* Create dataset with "bogus" message, but no message flags */ - if((did = H5Dcreate2(loc_id, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did) < 0) goto error; + if ((did = H5Dcreate2(loc_id, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; /* Set "fail if unknown and open for write" message flag for bogus message */ bogus_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE; - if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error; + if (H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) + goto error; /* Create second dataset, with "fail if unknown" message flag */ - if((did = H5Dcreate2(loc_id, "Dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did) < 0) goto error; + if ((did = H5Dcreate2(loc_id, "Dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; /* Set "fail if unknown always" message flag for bogus message */ bogus_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS; - if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error; + if (H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) + goto error; /* Create third dataset, with "fail if unknown always" message flag */ - if((did = H5Dcreate2(loc_id, "Dataset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did) < 0) goto error; + if ((did = H5Dcreate2(loc_id, "Dataset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; /* Set "mark if unknown" message flag for bogus message */ bogus_flags = H5O_MSG_FLAG_MARK_IF_UNKNOWN; - if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error; + if (H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) + goto error; /* Create fourth dataset, with "mark if unknown" message flag */ - if((did = H5Dcreate2(loc_id, "Dataset4", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did) < 0) goto error; + if ((did = H5Dcreate2(loc_id, "Dataset4", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; /* Set "shareable" message flag for bogus message */ bogus_flags = H5O_MSG_FLAG_SHAREABLE; - if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error; + if (H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) + goto error; /* Create fourth dataset, with "shareable" message flag */ - if((did = H5Dcreate2(loc_id, "Dataset5", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did) < 0) goto error; + if ((did = H5Dcreate2(loc_id, "Dataset5", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; /* Close dataset creation property list */ - if(H5Pclose(dcpl) < 0) goto error; + if (H5Pclose(dcpl) < 0) + goto error; /* Close dataspace */ - if(H5Sclose(sid) < 0) goto error; + if (H5Sclose(sid) < 0) + goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* generate_datasets() */ #endif -int main(void) +int +main(void) { #ifdef H5O_ENABLE_BOGUS - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ /* Create file for test datasets */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* Create datasets in "/" group with bogus message H5O_BOGUS_VALID_ID */ - if(generate_datasets(fid, H5O_BOGUS_VALID_ID) < 0) + if (generate_datasets(fid, H5O_BOGUS_VALID_ID) < 0) goto error; - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create datasets in "/group" with bogus message H5O_BOGUS_INVALID_ID */ - if(generate_datasets(gid, H5O_BOGUS_INVALID_ID) < 0) + if (generate_datasets(gid, H5O_BOGUS_INVALID_ID) < 0) goto error; /* Close the group */ - if(H5Gclose(gid) < 0) goto error; + if (H5Gclose(gid) < 0) + goto error; /* Close file */ - if(H5Fclose(fid) < 0) goto error; + if (H5Fclose(fid) < 0) + goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; -#else /* H5O_ENABLE_BOGUS */ + } + H5E_END_TRY; +#else /* H5O_ENABLE_BOGUS */ HDputs("H5O_ENABLE_BOGUS compiler macro not defined!"); #endif /* H5O_ENABLE_BOGUS */ return 1; } - diff --git a/test/gen_bounds.c b/test/gen_bounds.c index 2f696e6..d7e9b8c 100644 --- a/test/gen_bounds.c +++ b/test/gen_bounds.c @@ -51,36 +51,35 @@ * Defines for gen_ref_files() */ /* File names used for references */ -#define FILENAME_REF_E_L "bounds_ref_earliest_latest.h5" -#define FILENAME_REF_L_L "bounds_ref_latest_latest.h5" -#define FILENAME_REF_V112_V112 "bounds_ref_v112_v112.h5" -#define FILENAME_REF_V110_V110 "bounds_ref_v110_v110.h5" -#define FILENAME_REF_V18_V18 "bounds_ref_v18_v18.h5" +#define FILENAME_REF_E_L "bounds_ref_earliest_latest.h5" +#define FILENAME_REF_L_L "bounds_ref_latest_latest.h5" +#define FILENAME_REF_V112_V112 "bounds_ref_v112_v112.h5" +#define FILENAME_REF_V110_V110 "bounds_ref_v110_v110.h5" +#define FILENAME_REF_V18_V18 "bounds_ref_v18_v18.h5" /* Dataset names for references */ -#define REVISED_REFS_DSET "Revised_refs_dset" -#define OLD_REF_OBJ_DSET "Old_ref_object_dset" -#define OLD_REF_REG_DSET "Old_ref_region_dset" +#define REVISED_REFS_DSET "Revised_refs_dset" +#define OLD_REF_OBJ_DSET "Old_ref_object_dset" +#define OLD_REF_REG_DSET "Old_ref_region_dset" -#define GROUP "Group" -#define ATTR "Attr" -#define DATASET "Dataset" -#define POWER32 4294967296 /* 2^32 */ +#define GROUP "Group" +#define ATTR "Attr" +#define DATASET "Dataset" +#define POWER32 4294967296 /* 2^32 */ /* * Defines for gen_sel_files() */ /* File names for hyperslab/point selections */ -#define FILENAME_SEL_E_L "bounds_sel_earliest_latest.h5" -#define FILENAME_SEL_L_L "bounds_sel_latest_latest.h5" -#define FILENAME_SEL_V112_V112 "bounds_sel_v112_v112.h5" -#define FILENAME_SEL_V110_V110 "bounds_sel_v110_v110.h5" +#define FILENAME_SEL_E_L "bounds_sel_earliest_latest.h5" +#define FILENAME_SEL_L_L "bounds_sel_latest_latest.h5" +#define FILENAME_SEL_V112_V112 "bounds_sel_v112_v112.h5" +#define FILENAME_SEL_V110_V110 "bounds_sel_v110_v110.h5" /* Dataset names for hyperslab/point selections */ -#define SEL_EX_REG_DSET "Sel_ex32_reg_dset" -#define SEL_EX_IRR_DSET "Sel_ex32_irr_dset" -#define SEL_EX_PT_DSET "Sel_ex32_pt_dset" - +#define SEL_EX_REG_DSET "Sel_ex32_reg_dset" +#define SEL_EX_IRR_DSET "Sel_ex32_irr_dset" +#define SEL_EX_PT_DSET "Sel_ex32_pt_dset" /*********************************************************************** * gen_earliest_latest() creates file "bounds_earliest_latest.h5" @@ -108,45 +107,51 @@ #define CHK_DIM1 50 #define CHK_DIM2 50 -static herr_t gen_earliest_latest(void) +static herr_t +gen_earliest_latest(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - float *buf = NULL; /* Buffer for writing data */ - float *bufp = NULL; /* Pointer to data buffer */ - hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float * buf = NULL; /* Buffer for writing data */ + float * bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ int i, j; herr_t ret = SUCCEED; /* Generic return value */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; /* Set the "use the earliest/latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; /* Create file */ - if((fid = H5Fcreate(FILENAME_E_L, H5F_ACC_TRUNC, fcpl, fapl)) <0) + if ((fid = H5Fcreate(FILENAME_E_L, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR; /* Close file property lists */ - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Pclose(fcpl) < 0) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Pclose(fcpl) < 0) + TEST_ERROR; /* * Add a chunked dataset with layout version 3 (default) */ buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); - if (buf == NULL) TEST_ERROR; + if (buf == NULL) + TEST_ERROR; /* Fill sample data */ bufp = buf; @@ -155,59 +160,75 @@ static herr_t gen_earliest_latest(void) *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(RANK, dims, NULL)) < 0) + TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + TEST_ERROR; /* Create and write the dataset */ dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (dset < 0) TEST_ERROR; + if (dset < 0) + TEST_ERROR; ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (ret < 0) TEST_ERROR; + if (ret < 0) + TEST_ERROR; /* Close property list and dataset, will reuse dataspace */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; /* * Add a chunked dataset with layout version 4 (H5Pset_chunk_opts) */ /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + TEST_ERROR; /* Disable partial chunk filters, triggers layout version 4 */ - if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + if (H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR; /* Create and write the dataset */ dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (dset < 0) TEST_ERROR; + if (dset < 0) + TEST_ERROR; ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (ret < 0) TEST_ERROR; + if (ret < 0) + TEST_ERROR; /* Release allocated buffer */ HDfree(buf); bufp = buf = NULL; /* Close everything */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; - if(H5Sclose(space) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Pclose(dcpl); @@ -215,7 +236,8 @@ error: H5Pclose(fapl); H5Fclose(fid); HDfree(buf); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* gen_earliest_latest */ @@ -229,46 +251,52 @@ error: * Return: SUCCEED/FAIL * ***********************************************************************/ -static herr_t gen_earliest_v18(void) +static herr_t +gen_earliest_v18(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - float *buf = NULL; /* Buffer for writing data */ - float *bufp = NULL; /* Pointer to data buffer */ - hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float * buf = NULL; /* Buffer for writing data */ + float * bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ int i, j; herr_t ret = SUCCEED; /* Generic return value */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; /* Set the "use the earliest/v18 version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18) < 0) TEST_ERROR; /* Create file */ - if((fid = H5Fcreate(FILENAME_E_18, H5F_ACC_TRUNC, fcpl, fapl)) <0) + if ((fid = H5Fcreate(FILENAME_E_18, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR; /* Close file property lists */ - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Pclose(fcpl) < 0) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Pclose(fcpl) < 0) + TEST_ERROR; /* * Add a chunked dataset with layout version 3 (default) */ buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); - if (buf == NULL) TEST_ERROR; + if (buf == NULL) + TEST_ERROR; /* Fill sample data */ bufp = buf; @@ -277,35 +305,45 @@ static herr_t gen_earliest_v18(void) *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(RANK, dims, NULL)) < 0) + TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + TEST_ERROR; /* Create and write the dataset */ dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (dset < 0) TEST_ERROR; + if (dset < 0) + TEST_ERROR; ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (ret < 0) TEST_ERROR; + if (ret < 0) + TEST_ERROR; /* Release allocated buffer */ HDfree(buf); bufp = buf = NULL; /* Close everything */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; - if(H5Sclose(space) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Pclose(dcpl); @@ -313,7 +351,8 @@ error: H5Pclose(fapl); H5Fclose(fid); HDfree(buf); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* gen_earliest_v18 */ @@ -331,38 +370,42 @@ error: * Return: SUCCEED/FAIL * ***********************************************************************/ -static herr_t gen_latest_latest(void) +static herr_t +gen_latest_latest(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - float *buf = NULL; /* Buffer for writing data */ - float *bufp = NULL; /* Pointer to data buffer */ - hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float * buf = NULL; /* Buffer for writing data */ + float * bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ int i, j; herr_t ret = SUCCEED; /* Generic return value */ /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; /* Set the "use the latest/latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; /* Create the file with version 3 superblock */ fid = H5Fcreate(FILENAME_L_L, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if (fid < 0) TEST_ERROR; + if (fid < 0) + TEST_ERROR; /* * Add a chunked dataset with layout version 4 (H5Pset_chunk_opts) */ buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); - if (buf == NULL) TEST_ERROR; + if (buf == NULL) + TEST_ERROR; /* Fill sample data */ bufp = buf; @@ -371,44 +414,55 @@ static herr_t gen_latest_latest(void) *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(RANK, dims, NULL)) < 0) + TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + TEST_ERROR; /* Disable partial chunk filters, triggers layout version 4 */ - if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + if (H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR; /* Create and write the dataset */ dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (dset < 0) TEST_ERROR; + if (dset < 0) + TEST_ERROR; ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (ret < 0) TEST_ERROR; + if (ret < 0) + TEST_ERROR; /* Release allocated buffer */ HDfree(buf); bufp = buf = NULL; /* Close everything */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; - if(H5Sclose(space) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Pclose(dcpl); H5Fclose(fid); HDfree(buf); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* gen_latest_latest */ @@ -424,46 +478,52 @@ error: * Return: SUCCEED/FAIL * ***********************************************************************/ -static herr_t gen_v18_latest(void) +static herr_t +gen_v18_latest(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - float *buf = NULL; /* Buffer for writing data */ - float *bufp = NULL; /* Pointer to data buffer */ - hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float * buf = NULL; /* Buffer for writing data */ + float * bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ int i, j; herr_t ret = SUCCEED; /* Generic return value */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; /* Set the "use the v18/latest version of the format" bounds for creating objects in the file, also trigger version 2 superblock */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) TEST_ERROR; /* Create file */ - if((fid = H5Fcreate(FILENAME_18_L, H5F_ACC_TRUNC, fcpl, fapl)) <0) + if ((fid = H5Fcreate(FILENAME_18_L, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR; /* Close file property lists */ - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Pclose(fcpl) < 0) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Pclose(fcpl) < 0) + TEST_ERROR; /* * Add a chunked dataset with layout version 3 (default) */ buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); - if (buf == NULL) TEST_ERROR; + if (buf == NULL) + TEST_ERROR; /* Fill sample data */ bufp = buf; @@ -472,34 +532,44 @@ static herr_t gen_v18_latest(void) *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(RANK, dims, NULL)) < 0) + TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + TEST_ERROR; /* Create and write the dataset */ dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (dset < 0) TEST_ERROR; + if (dset < 0) + TEST_ERROR; ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (ret < 0) TEST_ERROR; + if (ret < 0) + TEST_ERROR; /* Release allocated buffer */ HDfree(buf); bufp = buf = NULL; /* Close property list and dataset, will reuse dataspace */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; - if(H5Sclose(space) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Pclose(dcpl); @@ -507,7 +577,8 @@ error: H5Pclose(fapl); H5Fclose(fid); HDfree(buf); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* gen_v18_latest */ @@ -522,46 +593,52 @@ error: * Return: SUCCEED/FAIL * ***********************************************************************/ -static herr_t gen_v18_v18(void) +static herr_t +gen_v18_v18(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - float *buf = NULL; /* Buffer for writing data */ - float *bufp = NULL; /* Pointer to data buffer */ - hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float * buf = NULL; /* Buffer for writing data */ + float * bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ int i, j; herr_t ret = SUCCEED; /* Generic return value */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; /* Set the "use the v18 version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_V18) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_V18) < 0) TEST_ERROR; /* Create file */ - if((fid = H5Fcreate(FILENAME_18_18, H5F_ACC_TRUNC, fcpl, fapl)) <0) + if ((fid = H5Fcreate(FILENAME_18_18, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR; /* Close file property lists */ - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Pclose(fcpl) < 0) TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Pclose(fcpl) < 0) + TEST_ERROR; /* * Add a chunked dataset with layout version 3 (default) */ buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); - if (buf == NULL) TEST_ERROR; + if (buf == NULL) + TEST_ERROR; /* Fill sample data */ bufp = buf; @@ -570,36 +647,45 @@ static herr_t gen_v18_v18(void) *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(RANK, dims, NULL)) < 0) + TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + TEST_ERROR; /* Create and write the dataset */ dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (dset < 0) TEST_ERROR; + if (dset < 0) + TEST_ERROR; ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (ret < 0) TEST_ERROR; + if (ret < 0) + TEST_ERROR; /* Close property list and dataset, will reuse dataspace */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; /* Close the file, then reopen it with the latest version */ - if(H5Fclose(fid) < 0) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; /* Set the "use the v18/latest version of the format" bounds for creating a layout version 4 object in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) TEST_ERROR; - if((fid = H5Fopen(FILENAME_18_18, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(FILENAME_18_18, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* @@ -607,35 +693,45 @@ static herr_t gen_v18_v18(void) */ /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + TEST_ERROR; /* Disable partial chunk filters */ - if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + if (H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR; /* Create and write the dataset */ dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if (dset < 0) TEST_ERROR; + if (dset < 0) + TEST_ERROR; ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (ret < 0) TEST_ERROR; + if (ret < 0) + TEST_ERROR; /* Release allocated buffer */ HDfree(buf); bufp = buf = NULL; /* Close everything */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; - if(H5Sclose(space) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset); H5Sclose(space); H5Pclose(dcpl); @@ -643,7 +739,8 @@ error: H5Pclose(fapl); H5Fclose(fid); HDfree(buf); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* gen_v18_v18 */ @@ -676,126 +773,129 @@ error: * Return: SUCCEED/FAIL * ***********************************************************************/ -static herr_t gen_sel_files(const char *filename, H5F_libver_t low_bound, H5F_libver_t high_bound) +static herr_t +gen_sel_files(const char *filename, H5F_libver_t low_bound, H5F_libver_t high_bound) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hsize_t numparticles = 8388608; - hsize_t total_particles = numparticles * 513; - hsize_t vdsdims[1] = {total_particles}; /* Dataset dimension size */ - hsize_t coord[4]; /* Point selection */ - hsize_t ref_start; /* Starting location of hyperslab */ - hsize_t ref_stride; /* Stride of hyperslab */ - hsize_t ref_count; /* Element count of hyperslab */ - hsize_t ref_block; /* Block size of hyperslab */ - hid_t ref_sid = H5I_INVALID_HID; /* Dataspace ID for the reference dataset */ - hid_t ref_did = H5I_INVALID_HID; /* Dataset ID for the reference dataset */ - hsize_t ref_dims[1] = {1}; /* Dimension for reference dataset */ - hdset_reg_ref_t ref_wbuf[1]; /* Buffer for dataset region reference */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hsize_t numparticles = 8388608; + hsize_t total_particles = numparticles * 513; + hsize_t vdsdims[1] = {total_particles}; /* Dataset dimension size */ + hsize_t coord[4]; /* Point selection */ + hsize_t ref_start; /* Starting location of hyperslab */ + hsize_t ref_stride; /* Stride of hyperslab */ + hsize_t ref_count; /* Element count of hyperslab */ + hsize_t ref_block; /* Block size of hyperslab */ + hid_t ref_sid = H5I_INVALID_HID; /* Dataspace ID for the reference dataset */ + hid_t ref_did = H5I_INVALID_HID; /* Dataset ID for the reference dataset */ + hsize_t ref_dims[1] = {1}; /* Dimension for reference dataset */ + hdset_reg_ref_t ref_wbuf[1]; /* Buffer for dataset region reference */ /* * Create test file, attribute, group and dataset */ - /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + /* Create the test file */ + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create a dataset */ - if((sid = H5Screate_simple(1, vdsdims, NULL)) < 0) + if ((sid = H5Screate_simple(1, vdsdims, NULL)) < 0) TEST_ERROR; - if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set to use the low/high bounds in fapl */ - if(H5Pset_libver_bounds(fapl, low_bound, high_bound) < 0) + if (H5Pset_libver_bounds(fapl, low_bound, high_bound) < 0) TEST_ERROR; /* Open the file with fapl */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Open the dataset */ - if((did = H5Dopen2(fid, DATASET, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DATASET, H5P_DEFAULT)) < 0) TEST_ERROR; /* Get the dataset's dataspace */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) TEST_ERROR; /* Create dataspace for the reference dataset */ ref_dims[0] = 1; - if((ref_sid = H5Screate_simple(1, ref_dims, NULL)) < 0) + if ((ref_sid = H5Screate_simple(1, ref_dims, NULL)) < 0) TEST_ERROR; /* Generate regular hyperslab exceeding 32 */ - ref_start = 0; - ref_count = 2; - ref_block = 4; + ref_start = 0; + ref_count = 2; + ref_block = 4; ref_stride = POWER32; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &ref_start, &ref_stride, &ref_count, &ref_block) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, &ref_start, &ref_stride, &ref_count, &ref_block) < 0) TEST_ERROR; /* Should succeed for v110 and above */ - if(high_bound >= H5F_LIBVER_V110) { + if (high_bound >= H5F_LIBVER_V110) { /* Create the first reference */ - if(H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0) + if (H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0) TEST_ERROR; /* Create the reference datset */ - if((ref_did = H5Dcreate2(fid, SEL_EX_REG_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((ref_did = H5Dcreate2(fid, SEL_EX_REG_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Write to the reference datset */ - if(H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0) + if (H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0) TEST_ERROR; - if(H5Dclose(ref_did) < 0) + if (H5Dclose(ref_did) < 0) TEST_ERROR; } /* Generate irregular hyperslab exceeding 32 */ - ref_start = 8; - ref_count = 5; - ref_block = 2; + ref_start = 8; + ref_count = 5; + ref_block = 2; ref_stride = POWER32; - if(H5Sselect_hyperslab(sid, H5S_SELECT_OR, &ref_start, &ref_stride, &ref_count, &ref_block) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_OR, &ref_start, &ref_stride, &ref_count, &ref_block) < 0) TEST_ERROR; /* Should succeed for v112 and above */ - if(high_bound >= H5F_LIBVER_V112) { + if (high_bound >= H5F_LIBVER_V112) { /* Create the second reference */ - if(H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0) + if (H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0) TEST_ERROR; /* Create the reference datset */ - if((ref_did = H5Dcreate2(fid, SEL_EX_IRR_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((ref_did = H5Dcreate2(fid, SEL_EX_IRR_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Write to the reference datset */ - if(H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0) + if (H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0) TEST_ERROR; - if(H5Dclose(ref_did) < 0) + if (H5Dclose(ref_did) < 0) TEST_ERROR; } @@ -805,52 +905,55 @@ static herr_t gen_sel_files(const char *filename, H5F_libver_t low_bound, H5F_l coord[2] = POWER32 + 1; coord[3] = 19; - if(H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord) < 0) + if (H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord) < 0) TEST_ERROR; /* Should succeed for v112 and above */ - if(high_bound >= H5F_LIBVER_V112) { + if (high_bound >= H5F_LIBVER_V112) { /* Create the third reference */ - if(H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0) + if (H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0) TEST_ERROR; /* Create the reference datset */ - if((ref_did = H5Dcreate2(fid, SEL_EX_PT_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((ref_did = H5Dcreate2(fid, SEL_EX_PT_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; /* Write to the reference datset */ - if(H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0) + if (H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0) TEST_ERROR; - if(H5Dclose(ref_did) < 0) + if (H5Dclose(ref_did) < 0) TEST_ERROR; } /* Closing */ - if(H5Sclose(ref_sid) < 0) + if (H5Sclose(ref_sid) < 0) TEST_ERROR; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(ref_did); H5Sclose(ref_sid); H5Dclose(did); H5Sclose(sid); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; @@ -887,97 +990,99 @@ error: * Return: SUCCEED/FAIL * ***********************************************************************/ -static herr_t gen_ref_files(const char *filename, H5F_libver_t low_bound, H5F_libver_t high_bound) +static herr_t +gen_ref_files(const char *filename, H5F_libver_t low_bound, H5F_libver_t high_bound) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - hid_t aid = H5I_INVALID_HID; /* Attribute ID */ - hid_t asid = H5I_INVALID_HID; /* Dataspace ID for attribute */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hsize_t dims[1] = {100}; /* Dimension size */ - unsigned *dwbuf = NULL; /* Buffer for writing data */ - hid_t ref_sid = H5I_INVALID_HID; /* Dataspace ID for the reference dataset */ - hid_t ref_did = H5I_INVALID_HID; /* Dataset ID for the reference dataset */ - hsize_t rev_ref_dims[1] = {3}; /* Dimension size for the reference dataset */ - H5R_ref_t rev_ref_wbuf[3]; /* Buffer for storing the revised references */ - hobj_ref_t old_ref_obj_wbuf[1]; /* Buffer for storing the old reference object */ - hdset_reg_ref_t old_ref_reg_wbuf[1]; /* Buffer for storing the old dataset region reference */ - hsize_t old_ref_dims[] = {1}; /* Dimension size for the reference dataset */ - hsize_t start[1]; /* Starting location of hyperslab */ - hsize_t stride[1]; /* Stride of hyperslab */ - hsize_t count[1]; /* Element count of hyperslab */ - hsize_t block[1]; /* Block size of hyperslab */ - unsigned i; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t asid = H5I_INVALID_HID; /* Dataspace ID for attribute */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hsize_t dims[1] = {100}; /* Dimension size */ + unsigned * dwbuf = NULL; /* Buffer for writing data */ + hid_t ref_sid = H5I_INVALID_HID; /* Dataspace ID for the reference dataset */ + hid_t ref_did = H5I_INVALID_HID; /* Dataset ID for the reference dataset */ + hsize_t rev_ref_dims[1] = {3}; /* Dimension size for the reference dataset */ + H5R_ref_t rev_ref_wbuf[3]; /* Buffer for storing the revised references */ + hobj_ref_t old_ref_obj_wbuf[1]; /* Buffer for storing the old reference object */ + hdset_reg_ref_t old_ref_reg_wbuf[1]; /* Buffer for storing the old dataset region reference */ + hsize_t old_ref_dims[] = {1}; /* Dimension size for the reference dataset */ + hsize_t start[1]; /* Starting location of hyperslab */ + hsize_t stride[1]; /* Stride of hyperslab */ + hsize_t count[1]; /* Element count of hyperslab */ + hsize_t block[1]; /* Block size of hyperslab */ + unsigned i; /* Local index variable */ /* * Create test file, attribute, group and dataset */ - if((dwbuf = HDcalloc(sizeof(unsigned), 100)) == NULL) + if ((dwbuf = HDcalloc(sizeof(unsigned), 100)) == NULL) TEST_ERROR; /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create dataspace for the attribute */ - if((asid = H5Screate(H5S_SCALAR)) < 0) + if ((asid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR; /* Create an attribute to the root group */ - if((aid = H5Acreate2(fid, ATTR, H5T_NATIVE_UINT, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(fid, ATTR, H5T_NATIVE_UINT, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create a group */ - if((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create dataspace for the dataset */ - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR; /* Create a dataset in the group */ - if((did = H5Dcreate2(gid, DATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(gid, DATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Initialize data to write */ - for(i = 0; i < 100; i++) + for (i = 0; i < 100; i++) dwbuf[i] = i * 3; /* Write data to disk */ - if(H5Dwrite(did, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf) < 0) + if (H5Dwrite(did, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf) < 0) TEST_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Sclose(asid) < 0) + if (H5Sclose(asid) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; - if(dwbuf) { + if (dwbuf) { HDfree(dwbuf); dwbuf = NULL; } /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; /* Set to use the low/high bounds in fapl */ - if(H5Pset_libver_bounds(fapl, low_bound, high_bound) < 0) + if (H5Pset_libver_bounds(fapl, low_bound, high_bound) < 0) TEST_ERROR; /* Open the file with fapl */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) <0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* @@ -985,9 +1090,9 @@ static herr_t gen_ref_files(const char *filename, H5F_libver_t low_bound, H5F_l */ /* Retrieve dataspace for the existing dataset */ - if((did = H5Dopen2(fid, "/Group/Dataset", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "/Group/Dataset", H5P_DEFAULT)) < 0) TEST_ERROR; - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) TEST_ERROR; /* Select 15 2x1 hyperslabs for the dataset region reference */ @@ -995,100 +1100,102 @@ static herr_t gen_ref_files(const char *filename, H5F_libver_t low_bound, H5F_l stride[0] = 5; count[0] = 15; block[0] = 2; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR; - - if(high_bound >= H5F_LIBVER_V112) { + if (high_bound >= H5F_LIBVER_V112) { /* Create dataspace for the reference dataset */ - if((ref_sid = H5Screate_simple(1, rev_ref_dims, NULL)) < 0) + if ((ref_sid = H5Screate_simple(1, rev_ref_dims, NULL)) < 0) TEST_ERROR; /* Create a dataset with the revised reference type */ - ref_did = H5Dcreate2(fid, REVISED_REFS_DSET, H5T_STD_REF, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ref_did = + H5Dcreate2(fid, REVISED_REFS_DSET, H5T_STD_REF, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Store the reference to "Attr" */ - if(H5Rcreate_attr(fid, "/", "Attr", H5P_DEFAULT, &rev_ref_wbuf[0]) < 0) + if (H5Rcreate_attr(fid, "/", "Attr", H5P_DEFAULT, &rev_ref_wbuf[0]) < 0) TEST_ERROR; /* Store the reference to /Group */ - if(H5Rcreate_object(fid, "/Group", H5P_DEFAULT, &rev_ref_wbuf[1]) < 0) + if (H5Rcreate_object(fid, "/Group", H5P_DEFAULT, &rev_ref_wbuf[1]) < 0) TEST_ERROR; /* Store the dataset region referenced to /Group/Dataset */ - if(H5Rcreate_region(fid, "/Group/Dataset", sid, H5P_DEFAULT, &rev_ref_wbuf[2]) < 0) + if (H5Rcreate_region(fid, "/Group/Dataset", sid, H5P_DEFAULT, &rev_ref_wbuf[2]) < 0) TEST_ERROR; /* Write to the reference dataset */ - if(H5Dwrite(ref_did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rev_ref_wbuf) < 0) + if (H5Dwrite(ref_did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rev_ref_wbuf) < 0) TEST_ERROR; /* Destroy references */ - for(i = 0; i < 3; i++) - if(H5Rdestroy(&rev_ref_wbuf[i]) < 0) + for (i = 0; i < 3; i++) + if (H5Rdestroy(&rev_ref_wbuf[i]) < 0) TEST_ERROR; /* Closing */ - if(H5Dclose(ref_did) < 0) + if (H5Dclose(ref_did) < 0) TEST_ERROR; - if(H5Sclose(ref_sid) < 0) + if (H5Sclose(ref_sid) < 0) TEST_ERROR; } /* Create dataspace for the reference dataset */ - if((ref_sid = H5Screate_simple(1, old_ref_dims, NULL)) < 0) + if ((ref_sid = H5Screate_simple(1, old_ref_dims, NULL)) < 0) TEST_ERROR; /* Create a dataset with the old object reference type */ - if((ref_did = H5Dcreate2(fid, OLD_REF_OBJ_DSET, H5T_STD_REF_OBJ, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((ref_did = H5Dcreate2(fid, OLD_REF_OBJ_DSET, H5T_STD_REF_OBJ, ref_sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; /* Create reference to /Group */ - if(H5Rcreate(&old_ref_obj_wbuf[0], fid, "/Group", H5R_OBJECT, -1) < 0) + if (H5Rcreate(&old_ref_obj_wbuf[0], fid, "/Group", H5R_OBJECT, -1) < 0) TEST_ERROR; /* Write to the reference dataset */ - if(H5Dwrite(ref_did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, old_ref_obj_wbuf) < 0) + if (H5Dwrite(ref_did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, old_ref_obj_wbuf) < 0) TEST_ERROR; /* Close the dataset */ - if(H5Dclose(ref_did) < 0) + if (H5Dclose(ref_did) < 0) TEST_ERROR; - /* Create a dataset with the old dataset region reference type */ - if((ref_did = H5Dcreate2(fid, OLD_REF_REG_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((ref_did = H5Dcreate2(fid, OLD_REF_REG_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; /* Create dataset region reference */ - if(H5Rcreate(&old_ref_reg_wbuf[0], fid, "/Group/Dataset", H5R_DATASET_REGION, sid) < 0) + if (H5Rcreate(&old_ref_reg_wbuf[0], fid, "/Group/Dataset", H5R_DATASET_REGION, sid) < 0) TEST_ERROR; /* Write selection to the reference dataset */ - if(H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, old_ref_reg_wbuf) < 0) + if (H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, old_ref_reg_wbuf) < 0) TEST_ERROR; /* Closing */ - if(H5Dclose(ref_did) < 0) + if (H5Dclose(ref_did) < 0) TEST_ERROR; - if(H5Sclose(ref_sid) < 0) + if (H5Sclose(ref_sid) < 0) TEST_ERROR; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(ref_did); H5Sclose(ref_sid); H5Dclose(did); @@ -1096,52 +1203,58 @@ error: H5Pclose(fapl); H5Fclose(fid); HDfree(dwbuf); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* gen_ref_files() */ -int main(void) +int +main(void) { /* Generate file bounds_earliest_latest.h5 */ - if (gen_earliest_latest() < 0) TEST_ERROR; + if (gen_earliest_latest() < 0) + TEST_ERROR; /* Generate file bounds_earliest_v18.h5 */ - if (gen_earliest_v18() < 0) TEST_ERROR; + if (gen_earliest_v18() < 0) + TEST_ERROR; /* Generate file bounds_latest_latest.h5 */ - if (gen_latest_latest() < 0) TEST_ERROR; + if (gen_latest_latest() < 0) + TEST_ERROR; /* Generate file bounds_v18_latest.h5 */ - if (gen_v18_latest() < 0) TEST_ERROR; + if (gen_v18_latest() < 0) + TEST_ERROR; /* Generate file bounds_v18_v18.h5 */ - if (gen_v18_v18() < 0) TEST_ERROR; - + if (gen_v18_v18() < 0) + TEST_ERROR; /* * Files generated via gen_ref_files() */ /* Generate bounds_ref_earliest_latest.h5 */ - if(gen_ref_files(FILENAME_REF_E_L, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) + if (gen_ref_files(FILENAME_REF_E_L, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; /* Generate bounds_ref_latest_latest.h5 */ - if(gen_ref_files(FILENAME_REF_L_L, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (gen_ref_files(FILENAME_REF_L_L, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; /* Generate bounds_ref_v112_v112.h5 */ - if(gen_ref_files(FILENAME_REF_V112_V112, H5F_LIBVER_V112, H5F_LIBVER_V112) < 0) + if (gen_ref_files(FILENAME_REF_V112_V112, H5F_LIBVER_V112, H5F_LIBVER_V112) < 0) TEST_ERROR; /* Generate bounds_ref_v110_v110.h5 */ - if(gen_ref_files(FILENAME_REF_V110_V110, H5F_LIBVER_V110, H5F_LIBVER_V110) < 0) + if (gen_ref_files(FILENAME_REF_V110_V110, H5F_LIBVER_V110, H5F_LIBVER_V110) < 0) TEST_ERROR; /* Generate bounds_ref_v18_v18.h5 */ - if(gen_ref_files(FILENAME_REF_V18_V18, H5F_LIBVER_V18, H5F_LIBVER_V18) < 0) + if (gen_ref_files(FILENAME_REF_V18_V18, H5F_LIBVER_V18, H5F_LIBVER_V18) < 0) TEST_ERROR; /* @@ -1149,19 +1262,19 @@ int main(void) */ /* Generate bounds_sel_earliest_latest.h5 */ - if(gen_sel_files(FILENAME_SEL_E_L, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) + if (gen_sel_files(FILENAME_SEL_E_L, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; /* Generate bounds_sel_latest_latest.h5 */ - if(gen_sel_files(FILENAME_SEL_L_L, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (gen_sel_files(FILENAME_SEL_L_L, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR; /* Generate bounds_sel_v112_v112.h5 */ - if(gen_sel_files(FILENAME_SEL_V112_V112, H5F_LIBVER_V112, H5F_LIBVER_V112) < 0) + if (gen_sel_files(FILENAME_SEL_V112_V112, H5F_LIBVER_V112, H5F_LIBVER_V112) < 0) TEST_ERROR; /* Generate bounds_sel_v110_v110.h5 */ - if(gen_sel_files(FILENAME_SEL_V110_V110, H5F_LIBVER_V110, H5F_LIBVER_V110) < 0) + if (gen_sel_files(FILENAME_SEL_V110_V110, H5F_LIBVER_V110, H5F_LIBVER_V110) < 0) TEST_ERROR; return EXIT_SUCCESS; @@ -1169,4 +1282,3 @@ int main(void) error: return EXIT_FAILURE; } - diff --git a/test/gen_cross.c b/test/gen_cross.c index 105895d..c5d9cd6 100644 --- a/test/gen_cross.c +++ b/test/gen_cross.c @@ -28,40 +28,40 @@ #include "h5test.h" -#define H5FILE_NAME "data.h5" -#define DATASETNAME "Array_le" -#define DATASETNAME1 "Array_be" -#define DATASETNAME2 "Scale_offset_float_data_le" -#define DATASETNAME3 "Scale_offset_float_data_be" -#define DATASETNAME4 "Scale_offset_double_data_le" -#define DATASETNAME5 "Scale_offset_double_data_be" -#define DATASETNAME6 "Scale_offset_char_data_le" -#define DATASETNAME7 "Scale_offset_char_data_be" -#define DATASETNAME8 "Scale_offset_short_data_le" -#define DATASETNAME9 "Scale_offset_short_data_be" -#define DATASETNAME10 "Scale_offset_int_data_le" -#define DATASETNAME11 "Scale_offset_int_data_be" -#define DATASETNAME12 "Scale_offset_long_long_data_le" -#define DATASETNAME13 "Scale_offset_long_long_data_be" - -#define DATASETNAME14 "Fletcher_float_data_le" -#define DATASETNAME15 "Fletcher_float_data_be" -#define DATASETNAME16 "Deflate_float_data_le" -#define DATASETNAME17 "Deflate_float_data_be" +#define H5FILE_NAME "data.h5" +#define DATASETNAME "Array_le" +#define DATASETNAME1 "Array_be" +#define DATASETNAME2 "Scale_offset_float_data_le" +#define DATASETNAME3 "Scale_offset_float_data_be" +#define DATASETNAME4 "Scale_offset_double_data_le" +#define DATASETNAME5 "Scale_offset_double_data_be" +#define DATASETNAME6 "Scale_offset_char_data_le" +#define DATASETNAME7 "Scale_offset_char_data_be" +#define DATASETNAME8 "Scale_offset_short_data_le" +#define DATASETNAME9 "Scale_offset_short_data_be" +#define DATASETNAME10 "Scale_offset_int_data_le" +#define DATASETNAME11 "Scale_offset_int_data_be" +#define DATASETNAME12 "Scale_offset_long_long_data_le" +#define DATASETNAME13 "Scale_offset_long_long_data_be" + +#define DATASETNAME14 "Fletcher_float_data_le" +#define DATASETNAME15 "Fletcher_float_data_be" +#define DATASETNAME16 "Deflate_float_data_le" +#define DATASETNAME17 "Deflate_float_data_be" #ifdef H5_HAVE_FILTER_SZIP -#define DATASETNAME18 "Szip_float_data_le" -#define DATASETNAME19 "Szip_float_data_be" +#define DATASETNAME18 "Szip_float_data_le" +#define DATASETNAME19 "Szip_float_data_be" #endif /* H5_HAVE_FILTER_SZIP */ -#define DATASETNAME20 "Shuffle_float_data_le" -#define DATASETNAME21 "Shuffle_float_data_be" -#define DATASETNAME22 "Nbit_float_data_le" -#define DATASETNAME23 "Nbit_float_data_be" +#define DATASETNAME20 "Shuffle_float_data_le" +#define DATASETNAME21 "Shuffle_float_data_be" +#define DATASETNAME22 "Nbit_float_data_le" +#define DATASETNAME23 "Nbit_float_data_be" -#define NX 6 -#define NY 6 -#define RANK 2 -#define CHUNK0 4 -#define CHUNK1 3 +#define NX 6 +#define NY 6 +#define RANK 2 +#define CHUNK0 4 +#define CHUNK1 3 int create_normal_dset(hid_t fid, hid_t fsid, hid_t msid); int create_scale_offset_dsets_float(hid_t fid, hid_t fsid, hid_t msid); @@ -78,7 +78,6 @@ int create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid); int create_shuffle_dsets_float(hid_t fid, hid_t fsid, hid_t msid); int create_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid); - /*------------------------------------------------------------------------- * Function: create_normal_dset * @@ -97,18 +96,18 @@ int create_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid); int create_normal_dset(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* file and dataset handles */ - hid_t dcpl = -1; - float data[NX][NY]; /* data to write */ - float fillvalue = -2.2f; - int i, j; + hid_t dataset = -1; /* file and dataset handles */ + hid_t dcpl = -1; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2f; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) - data[j][i] = ((float)(i + j + 1)) / 3; + for (i = 0; i < NY; i++) + data[j][i] = ((float)(i + j + 1)) / 3; } /* * 1/3 2/3 3/3 4/3 5/3 6/3 @@ -123,69 +122,68 @@ create_normal_dset(hid_t fid, hid_t fsid, hid_t msid) /* * Create the dataset creation property list, set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace and * little-endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME, H5T_IEEE_F64LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME, H5T_IEEE_F64LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* * Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace and * big-endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME1, H5T_IEEE_F64BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME1, H5T_IEEE_F64BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* * Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_scale_offset_dsets_float * @@ -204,79 +202,78 @@ error: int create_scale_offset_dsets_float(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - float data[NX][NY]; /* data to write */ - float fillvalue = -2.2f; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2f; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) - data[j][i] = ((float)(i + j + 1))/3; + data[j][i] = ((float)(i + j + 1)) / 3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_scaleoffset(dcpl, H5Z_SO_FLOAT_DSCALE, 3) < 0) + if (H5Pset_scaleoffset(dcpl, H5Z_SO_FLOAT_DSCALE, 3) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME2, H5T_IEEE_F32LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME2, H5T_IEEE_F32LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME3, H5T_IEEE_F32BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME3, H5T_IEEE_F32BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_scale_offset_dsets_double * @@ -295,79 +292,78 @@ error: int create_scale_offset_dsets_double(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - double data[NX][NY]; /* data to write */ - double fillvalue = -2.2f; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + double data[NX][NY]; /* data to write */ + double fillvalue = -2.2f; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) - data[j][i] = ((double)(i + j + 1))/3; + for (i = 0; i < NY; i++) + data[j][i] = ((double)(i + j + 1)) / 3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_scaleoffset(dcpl, H5Z_SO_FLOAT_DSCALE, 3) < 0) + if (H5Pset_scaleoffset(dcpl, H5Z_SO_FLOAT_DSCALE, 3) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME4, H5T_IEEE_F64LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME4, H5T_IEEE_F64LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_DOUBLE, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_DOUBLE, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME5, H5T_IEEE_F64BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME5, H5T_IEEE_F64BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_DOUBLE, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_DOUBLE, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_scale_offset_dset_char * @@ -386,12 +382,12 @@ error: int create_scale_offset_dsets_char(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - char data[NX][NY]; /* data to write */ - char fillvalue = -2; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + char data[NX][NY]; /* data to write */ + char fillvalue = -2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. @@ -413,60 +409,59 @@ create_scale_offset_dsets_char(hid_t fid, hid_t fsid, hid_t msid) * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) + if (H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_CHAR, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_CHAR, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME6, H5T_STD_I8LE, fsid, H5P_DEFAULT, - dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME6, H5T_STD_I8LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_CHAR, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_CHAR, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME7, H5T_STD_I8BE, fsid, H5P_DEFAULT, - dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME7, H5T_STD_I8BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_CHAR, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_CHAR, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_scale_offset_dset_short * @@ -485,12 +480,12 @@ error: int create_scale_offset_dsets_short(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - short data[NX][NY]; /* data to write */ - short fillvalue = -2; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + short data[NX][NY]; /* data to write */ + short fillvalue = -2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. @@ -512,60 +507,59 @@ create_scale_offset_dsets_short(hid_t fid, hid_t fsid, hid_t msid) * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) + if (H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_SHORT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_SHORT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME8, H5T_STD_I16LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME8, H5T_STD_I16LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_SHORT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_SHORT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME9, H5T_STD_I16BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME9, H5T_STD_I16BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_SHORT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_SHORT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_scale_offset_dset_int * @@ -584,19 +578,19 @@ error: int create_scale_offset_dsets_int(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - int data[NX][NY]; /* data to write */ - int fillvalue = -2; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + int data[NX][NY]; /* data to write */ + int fillvalue = -2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) - data[j][i] = i + j; + for (i = 0; i < NY; i++) + data[j][i] = i + j; } /* * 0 1 2 3 4 5 @@ -611,60 +605,59 @@ create_scale_offset_dsets_int(hid_t fid, hid_t fsid, hid_t msid) * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) + if (H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME10, H5T_STD_I32LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME10, H5T_STD_I32LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME11, H5T_STD_I32BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME11, H5T_STD_I32BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_scale_offset_dset_long_long * @@ -684,12 +677,12 @@ error: int create_scale_offset_dsets_long_long(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - long long data[NX][NY]; /* data to write */ - long long fillvalue = -2; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + long long data[NX][NY]; /* data to write */ + long long fillvalue = -2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. @@ -711,60 +704,59 @@ create_scale_offset_dsets_long_long(hid_t fid, hid_t fsid, hid_t msid) * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) + if (H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_LLONG, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_LLONG, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME12, H5T_STD_I64LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME12, H5T_STD_I64LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_LLONG, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_LLONG, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME13, H5T_STD_I64BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME13, H5T_STD_I64BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_LLONG, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_LLONG, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_fletcher_dsets_float * @@ -783,79 +775,78 @@ error: int create_fletcher_dsets_float(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - float data[NX][NY]; /* data to write */ - float fillvalue = -2.2f; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2f; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) - data[j][i] = ((float)(i + j + 1))/3; + data[j][i] = ((float)(i + j + 1)) / 3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_filter(dcpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL) < 0) + if (H5Pset_filter(dcpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME14, H5T_IEEE_F32LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME14, H5T_IEEE_F32LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME15, H5T_IEEE_F32BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME15, H5T_IEEE_F32BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_deflate_dsets_float * @@ -875,69 +866,67 @@ int create_deflate_dsets_float(hid_t fid, hid_t fsid, hid_t msid) { #ifdef H5_HAVE_FILTER_DEFLATE - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - float data[NX][NY]; /* data to write */ - float fillvalue = -2.2f; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2f; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) - data[j][i] = ((float)(i + j + 1))/3; + data[j][i] = ((float)(i + j + 1)) / 3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_deflate (dcpl, 6) < 0) + if (H5Pset_deflate(dcpl, 6) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME16, H5T_IEEE_F32LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME16, H5T_IEEE_F32LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME17, H5T_IEEE_F32BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME17, H5T_IEEE_F32BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR -#else /* H5_HAVE_FILTER_DEFLATE */ - const char *not_supported= "Deflate filter is not enabled. Can't create the dataset."; +#else /* H5_HAVE_FILTER_DEFLATE */ + const char *not_supported = "Deflate filter is not enabled. Can't create the dataset."; puts(not_supported); #endif /* H5_HAVE_FILTER_DEFLATE */ @@ -946,10 +935,12 @@ create_deflate_dsets_float(hid_t fid, hid_t fsid, hid_t msid) #ifdef H5_HAVE_FILTER_DEFLATE error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; #endif /* H5_HAVE_FILTER_DEFLATE */ @@ -975,80 +966,79 @@ error: int create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset; /* dataset handles */ - hid_t dcpl; - float data[NX][NY]; /* data to write */ - float fillvalue = -2.2f; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset; /* dataset handles */ + hid_t dcpl; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2f; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) - data[j][i] = ((float)(i + j + 1))/3; + data[j][i] = ((float)(i + j + 1)) / 3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_szip(dcpl, H5_SZIP_NN_OPTION_MASK, 4) < 0) + if (H5Pset_szip(dcpl, H5_SZIP_NN_OPTION_MASK, 4) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME18, H5T_IEEE_F32LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME18, H5T_IEEE_F32LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME19, H5T_IEEE_F32BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME19, H5T_IEEE_F32BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } #endif /* H5_HAVE_FILTER_SZIP */ - /*------------------------------------------------------------------------- * Function: create_shuffle_dsets_float * @@ -1067,79 +1057,78 @@ error: int create_shuffle_dsets_float(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t dcpl = -1; - float data[NX][NY]; /* data to write */ - float fillvalue = -2.2f; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t dcpl = -1; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2f; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) - data[j][i] = ((float)(i + j + 1))/3; + data[j][i] = ((float)(i + j + 1)) / 3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_shuffle (dcpl) < 0) + if (H5Pset_shuffle(dcpl) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME20, H5T_IEEE_F32LE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME20, H5T_IEEE_F32LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if((dataset = H5Dcreate2(fid, DATASETNAME21, H5T_IEEE_F32BE, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME21, H5T_IEEE_F32BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: create_nbit_dsets_float * @@ -1158,100 +1147,99 @@ error: int create_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid) { - hid_t dataset = -1; /* dataset handles */ - hid_t datatype = -1; - hid_t dcpl = -1; - size_t precision, offset; - float data[NX][NY]; /* data to write */ - float fillvalue = -2.2f; - hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; - int i, j; + hid_t dataset = -1; /* dataset handles */ + hid_t datatype = -1; + hid_t dcpl = -1; + size_t precision, offset; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2f; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) - data[j][i] = ((float)(i + j + 1))/3; + data[j][i] = ((float)(i + j + 1)) / 3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_nbit(dcpl) < 0) + if (H5Pset_nbit(dcpl) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR - if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* Define user-defined single-precision floating-point type for dataset. * A 20-bit little-endian data type. */ - if((datatype = H5Tcopy(H5T_IEEE_F32LE)) < 0) + if ((datatype = H5Tcopy(H5T_IEEE_F32LE)) < 0) TEST_ERROR - if(H5Tset_fields(datatype, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) + if (H5Tset_fields(datatype, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) TEST_ERROR offset = 7; - if(H5Tset_offset(datatype,offset) < 0) + if (H5Tset_offset(datatype, offset) < 0) TEST_ERROR precision = 20; - if(H5Tset_precision(datatype,precision) < 0) + if (H5Tset_precision(datatype, precision) < 0) TEST_ERROR - if(H5Tset_size(datatype, (size_t)4) < 0) + if (H5Tset_size(datatype, (size_t)4) < 0) TEST_ERROR - if(H5Tset_ebias(datatype, (size_t)31) < 0) + if (H5Tset_ebias(datatype, (size_t)31) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, * user-defined datatype, and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME22, datatype, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME22, datatype, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ - if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) + if (H5Tset_order(datatype, H5T_ORDER_BE) < 0) TEST_ERROR - if((dataset = H5Dcreate2(fid, DATASETNAME23, datatype, fsid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid, DATASETNAME23, datatype, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: main * @@ -1264,20 +1252,20 @@ error: *------------------------------------------------------------------------- */ int -main (void) +main(void) { - hid_t file = -1; - hid_t filespace = -1; - hid_t memspace = -1; - hsize_t dimsf[RANK]; - hsize_t start[RANK] = {0, 0}; + hid_t file = -1; + hid_t filespace = -1; + hid_t memspace = -1; + hsize_t dimsf[RANK]; + hsize_t start[RANK] = {0, 0}; /* * Create a new file using H5F_ACC_TRUNC access, * default file creation properties, and default file * access properties. */ - if((file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* @@ -1287,80 +1275,79 @@ main (void) */ dimsf[0] = NX + 1; dimsf[1] = NY; - if((filespace = H5Screate_simple(RANK, dimsf, NULL)) < 0) + if ((filespace = H5Screate_simple(RANK, dimsf, NULL)) < 0) TEST_ERROR; dimsf[0] = NX; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, dimsf, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, dimsf, NULL) < 0) TEST_ERROR; /* Create memory space. This does not include the extra row for fill * values. */ HDassert(dimsf[0] == NX); HDassert(dimsf[1] == NY); - if((memspace = H5Screate_simple(RANK, dimsf, NULL)) < 0) + if ((memspace = H5Screate_simple(RANK, dimsf, NULL)) < 0) TEST_ERROR; /* Create a regular dataset */ - if(create_normal_dset(file, filespace, memspace) < 0) + if (create_normal_dset(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of FLOAT with scale-offset filter */ - if(create_scale_offset_dsets_float(file, filespace, memspace) < 0) + if (create_scale_offset_dsets_float(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of DOUBLE with scale-offset filter */ - if(create_scale_offset_dsets_double(file, filespace, memspace) < 0) + if (create_scale_offset_dsets_double(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of CHAR with scale-offset filter */ - if(create_scale_offset_dsets_char(file, filespace, memspace) < 0) + if (create_scale_offset_dsets_char(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of SHORT with scale-offset filter */ - if(create_scale_offset_dsets_short(file, filespace, memspace) < 0) + if (create_scale_offset_dsets_short(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of INT with scale-offset filter */ - if(create_scale_offset_dsets_int(file, filespace, memspace) < 0) + if (create_scale_offset_dsets_int(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of LONG LONG with scale-offset filter */ - if(create_scale_offset_dsets_long_long(file, filespace, memspace) < 0) + if (create_scale_offset_dsets_long_long(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of FLOAT with fletcher filter */ - if(create_fletcher_dsets_float(file, filespace, memspace) < 0) + if (create_fletcher_dsets_float(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of FLOAT with deflate filter */ - if(create_deflate_dsets_float(file, filespace, memspace) < 0) + if (create_deflate_dsets_float(file, filespace, memspace) < 0) TEST_ERROR; #ifdef H5_HAVE_FILTER_SZIP /* Create a dataset of FLOAT with szip filter */ - if(create_szip_dsets_float(file, filespace, memspace) < 0) + if (create_szip_dsets_float(file, filespace, memspace) < 0) TEST_ERROR; -#else /* H5_HAVE_FILTER_SZIP */ +#else /* H5_HAVE_FILTER_SZIP */ HDputs("Szip filter is not enabled. Can't create the dataset."); #endif /* H5_HAVE_FILTER_SZIP */ /* Create a dataset of FLOAT with shuffle filter */ - if(create_shuffle_dsets_float(file, filespace, memspace) < 0) + if (create_shuffle_dsets_float(file, filespace, memspace) < 0) TEST_ERROR; /* Create a dataset of FLOAT with nbit filter */ - if(create_nbit_dsets_float(file, filespace, memspace) < 0) + if (create_nbit_dsets_float(file, filespace, memspace) < 0) TEST_ERROR; - /* * Close/release resources. */ - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR; - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; HDexit(EXIT_SUCCESS); @@ -1368,4 +1355,3 @@ main (void) error: HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/gen_deflate.c b/test/gen_deflate.c index 3409a81..22c901c 100644 --- a/test/gen_deflate.c +++ b/test/gen_deflate.c @@ -25,17 +25,15 @@ #include "h5test.h" -#define TESTFILE "deflate.h5" +#define TESTFILE "deflate.h5" /* 2-D dataset with fixed dimensions */ -#define SPACE_RANK 2 -#define SPACE_DIM1 100 -#define SPACE_DIM2 200 -#define CHUNK_DIM1 50 -#define CHUNK_DIM2 50 +#define SPACE_RANK 2 +#define SPACE_DIM1 100 +#define SPACE_DIM2 200 +#define CHUNK_DIM1 50 +#define CHUNK_DIM2 50 - - /*------------------------------------------------------------------------- * Function: main * @@ -49,55 +47,55 @@ int main(void) { - hid_t fid = -1, sid = -1, did = -1, dcpl_id = -1; - hsize_t dims[SPACE_RANK] = {SPACE_DIM1, SPACE_DIM2}; - hsize_t chunk_dims[SPACE_RANK] = {CHUNK_DIM1, CHUNK_DIM2}; - size_t i,j; /* Local index variables */ - int *data = NULL; /* Dataset data */ + hid_t fid = -1, sid = -1, did = -1, dcpl_id = -1; + hsize_t dims[SPACE_RANK] = {SPACE_DIM1, SPACE_DIM2}; + hsize_t chunk_dims[SPACE_RANK] = {CHUNK_DIM1, CHUNK_DIM2}; + size_t i, j; /* Local index variables */ + int * data = NULL; /* Dataset data */ /* Initialize the data */ /* (Try for something easily compressible) */ - if(NULL == (data = (int *)HDmalloc(SPACE_DIM1 * SPACE_DIM2 * sizeof(int)))) + if (NULL == (data = (int *)HDmalloc(SPACE_DIM1 * SPACE_DIM2 * sizeof(int)))) TEST_ERROR - for(i = 0; i < SPACE_DIM1; i++) - for(j = 0; j < SPACE_DIM2; j++) + for (i = 0; i < SPACE_DIM1; i++) + for (j = 0; j < SPACE_DIM2; j++) data[(i * SPACE_DIM2) + j] = (int)(j % 5); /* Create the file */ - if((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create the dataspace */ - if((sid = H5Screate_simple(SPACE_RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(SPACE_RANK, dims, NULL)) < 0) FAIL_STACK_ERROR /* Create the dataset creation property list */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* Set up for deflated data */ - if(H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) FAIL_STACK_ERROR - if(H5Pset_deflate(dcpl_id, 9) < 0) + if (H5Pset_deflate(dcpl_id, 9) < 0) FAIL_STACK_ERROR /* Create the compressed dataset */ - if((did = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR /* Close everything */ - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR HDfree(data); @@ -105,15 +103,16 @@ main(void) return EXIT_SUCCESS; error: - if(data) + if (data) HDfree(data); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl_id); H5Dclose(did); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return EXIT_FAILURE; } /* end main() */ - diff --git a/test/gen_file_image.c b/test/gen_file_image.c index 9607cc2..44bf0d2 100644 --- a/test/gen_file_image.c +++ b/test/gen_file_image.c @@ -20,14 +20,13 @@ */ #include "h5test.h" -#define TESTFILE "file_image_core_test.h5" +#define TESTFILE "file_image_core_test.h5" /* 2-D dataset with fixed dimensions */ -#define SPACE_RANK 2 -#define SPACE_DIM1 128 -#define SPACE_DIM2 32 +#define SPACE_RANK 2 +#define SPACE_DIM1 128 +#define SPACE_DIM2 32 - /*------------------------------------------------------------------------- * Function: main * @@ -42,53 +41,54 @@ int main(void) { hid_t fid = -1, sid = -1, did = -1; - hsize_t dims[SPACE_RANK] = {SPACE_DIM1, SPACE_DIM2}; - size_t i,j; /* Local index variables */ - int *data = NULL; /* Dataset data */ + hsize_t dims[SPACE_RANK] = {SPACE_DIM1, SPACE_DIM2}; + size_t i, j; /* Local index variables */ + int * data = NULL; /* Dataset data */ /* Initialize the data */ - if(NULL == (data = (int *)HDmalloc(SPACE_DIM1 * SPACE_DIM2 * sizeof(int)))) + if (NULL == (data = (int *)HDmalloc(SPACE_DIM1 * SPACE_DIM2 * sizeof(int)))) TEST_ERROR - for(i = 0; i < SPACE_DIM1; i++) - for(j = 0; j < SPACE_DIM2; j++) + for (i = 0; i < SPACE_DIM1; i++) + for (j = 0; j < SPACE_DIM2; j++) data[(i * SPACE_DIM2) + j] = (int)(j % 5); /* Create the file */ - if((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create the dataspace */ - if((sid = H5Screate_simple(SPACE_RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(SPACE_RANK, dims, NULL)) < 0) FAIL_STACK_ERROR /* Create the compressed dataset */ - if((did = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR /* Close everything */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR return EXIT_SUCCESS; error: - if(data) + if (data) HDfree(data); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return EXIT_FAILURE; } /* end main() */ - diff --git a/test/gen_filespace.c b/test/gen_filespace.c index bf49b7b..3803628 100644 --- a/test/gen_filespace.c +++ b/test/gen_filespace.c @@ -14,21 +14,21 @@ #include "hdf5.h" #include -#define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */ +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) /* # of elements */ const char *FILENAMES[] = { - "fsm_aggr_nopersist.h5", /* H5F_FSPACE_STRATEGY_FSM_AGGR + not persisting free-space */ - "fsm_aggr_persist.h5", /* H5F_FSPACE_STRATEGY_FSM_AGGR + persisting free-space */ - "paged_nopersist.h5", /* H5F_FSPACE_STRATEGY_PAGE + not persisting free-space */ - "paged_persist.h5", /* H5F_FSPACE_STRATEGY_PAGE + persisting free-space */ - "aggr.h5", /* H5F_FSPACE_STRATEGY_AGGR */ - "none.h5" /* H5F_FSPACE_STRATEGY_NONE */ + "fsm_aggr_nopersist.h5", /* H5F_FSPACE_STRATEGY_FSM_AGGR + not persisting free-space */ + "fsm_aggr_persist.h5", /* H5F_FSPACE_STRATEGY_FSM_AGGR + persisting free-space */ + "paged_nopersist.h5", /* H5F_FSPACE_STRATEGY_PAGE + not persisting free-space */ + "paged_persist.h5", /* H5F_FSPACE_STRATEGY_PAGE + persisting free-space */ + "aggr.h5", /* H5F_FSPACE_STRATEGY_AGGR */ + "none.h5" /* H5F_FSPACE_STRATEGY_NONE */ }; -#define DATASET "dset" -#define NUM_ELMTS 100 -#define FALSE 0 -#define TRUE 1 +#define DATASET "dset" +#define NUM_ELMTS 100 +#define FALSE 0 +#define TRUE 1 /* * Compile and run this program in the trunk to generate @@ -44,58 +44,61 @@ const char *FILENAMES[] = { * compatibility testing via test_filespace_round_compatible() in test/tfile.c. * */ -int main(void) +int +main(void) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t dim[1]; /* Dimension sizes */ - int data[NUM_ELMTS]; /* Buffer for data */ - int i, j; /* Local index variables */ - H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ - unsigned fs_persist; /* Persisting free-space or not */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim[1]; /* Dimension sizes */ + int data[NUM_ELMTS]; /* Buffer for data */ + int i, j; /* Local index variables */ + H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ + unsigned fs_persist; /* Persisting free-space or not */ j = 0; - for(fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_strategy < H5F_FSPACE_STRATEGY_NTYPES; fs_strategy++) { - for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + for (fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_strategy < H5F_FSPACE_STRATEGY_NTYPES; + fs_strategy++) { + for (fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { - if(fs_persist && fs_strategy >= H5F_FSPACE_STRATEGY_AGGR) + if (fs_persist && fs_strategy >= H5F_FSPACE_STRATEGY_AGGR) continue; /* Get a copy of the default file creation property */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; - if(H5Pset_file_space_strategy(fcpl, fs_strategy, fs_persist, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, fs_strategy, fs_persist, (hsize_t)1) < 0) goto error; /* Create the file with the file space info */ - if((fid = H5Fcreate(FILENAMES[j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAMES[j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create the dataset */ dim[0] = NUM_ELMTS; - if((sid = H5Screate_simple(1, dim, NULL)) < 0) + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; - for(i = 0; i < NUM_ELMTS; i++) + for (i = 0; i < NUM_ELMTS; i++) data[i] = i; /* Write the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; ++j; } @@ -105,11 +108,13 @@ int main(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Sclose(did); H5Pclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } diff --git a/test/gen_filters.c b/test/gen_filters.c index 9764830..a97c2f6 100644 --- a/test/gen_filters.c +++ b/test/gen_filters.c @@ -13,18 +13,17 @@ #include "h5test.h" -#define TESTFILE1 "test_filters.h5" -#define TESTFILE2 "filter_error.h5" -#define DSETNAME "dataset_with_filter" +#define TESTFILE1 "test_filters.h5" +#define TESTFILE2 "filter_error.h5" +#define DSETNAME "dataset_with_filter" /* Temporary filter IDs used for testing */ -#define H5Z_FILTER_BOGUS 305 +#define H5Z_FILTER_BOGUS 305 /* Local prototypes for filter functions */ -static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); - /*------------------------------------------------------------------------- * Function: create_file_with_bogus_filter * @@ -46,66 +45,78 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, static herr_t test_filters_endianess(void) { - hid_t fid = -1; /* file ID */ - hid_t dsid = -1; /* dataset ID */ - hid_t sid = -1; /* dataspace ID */ - hid_t dcpl = -1; /* dataset creation property list ID */ - hsize_t dims[1] = {20}; /* dataspace dimensions */ - hsize_t chunk_dims[1] = {10}; /* chunk dimensions */ - int buf[20]; - int rank = 1; - int i; - - for(i = 0; i < 20; i++) + hid_t fid = -1; /* file ID */ + hid_t dsid = -1; /* dataset ID */ + hid_t sid = -1; /* dataspace ID */ + hid_t dcpl = -1; /* dataset creation property list ID */ + hsize_t dims[1] = {20}; /* dataspace dimensions */ + hsize_t chunk_dims[1] = {10}; /* chunk dimensions */ + int buf[20]; + int rank = 1; + int i; + + for (i = 0; i < 20; i++) buf[i] = 1; /* create a file using default properties */ - if((fid = H5Fcreate(TESTFILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((fid = H5Fcreate(TESTFILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* create a data space */ - if((sid = H5Screate_simple(rank, dims, NULL)) < 0) goto error; + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) + goto error; /* create dcpl */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, rank, chunk_dims) < 0) goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dcpl, rank, chunk_dims) < 0) + goto error; - if(H5Pset_fletcher32(dcpl) < 0) goto error; + if (H5Pset_fletcher32(dcpl) < 0) + goto error; /* create a dataset */ - if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; + if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; + if (H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; /* close */ - if(H5Pclose(dcpl) < 0) goto error; - if(H5Dclose(dsid) < 0) goto error; - if(H5Sclose(sid) < 0) goto error; - if(H5Fclose(fid) < 0) goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Dclose(dsid) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dsid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_filters_endianess() */ /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - filter_bogus, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_bogus, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: filter_bogus * @@ -122,13 +133,12 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ */ static size_t filter_bogus(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { return nbytes; } - /*------------------------------------------------------------------------- * Function: create_file_with_bogus_filter * @@ -146,59 +156,72 @@ filter_bogus(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, static herr_t create_file_with_bogus_filter(void) { - hid_t fid = -1; /* file ID */ - hid_t dsid = -1; /* dataset ID */ - hid_t sid = -1; /* dataspace ID */ - hid_t dcpl = -1; /* dataset creation property list ID */ - hsize_t dims[1] = {20}; /* dataspace dimensions */ - hsize_t chunk_dims[1] = {10}; /* chunk dimensions */ - int buf[20]; - int rank = 1; - int i; - - for(i = 0; i < 20; i++) + hid_t fid = -1; /* file ID */ + hid_t dsid = -1; /* dataset ID */ + hid_t sid = -1; /* dataspace ID */ + hid_t dcpl = -1; /* dataset creation property list ID */ + hsize_t dims[1] = {20}; /* dataspace dimensions */ + hsize_t chunk_dims[1] = {10}; /* chunk dimensions */ + int buf[20]; + int rank = 1; + int i; + + for (i = 0; i < 20; i++) buf[i] = 1; /* create a file using default properties */ - if((fid = H5Fcreate(TESTFILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((fid = H5Fcreate(TESTFILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* create a data space */ - if((sid = H5Screate_simple(rank, dims, NULL)) < 0) goto error; + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) + goto error; /* create dcpl */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* create chunking */ - if(H5Pset_chunk(dcpl, rank, chunk_dims) < 0) goto error; + if (H5Pset_chunk(dcpl, rank, chunk_dims) < 0) + goto error; /* register bogus filter */ - if(H5Zregister (H5Z_BOGUS) < 0) goto error; - if(H5Pset_filter(dcpl, H5Z_FILTER_BOGUS, 0, (size_t)0, NULL) < 0) goto error; + if (H5Zregister(H5Z_BOGUS) < 0) + goto error; + if (H5Pset_filter(dcpl, H5Z_FILTER_BOGUS, 0, (size_t)0, NULL) < 0) + goto error; /* create a dataset */ - if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; + if ((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; + if (H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; /* close */ - if(H5Pclose(dcpl) < 0) goto error; - if(H5Dclose(dsid) < 0) goto error; - if(H5Sclose(sid) < 0) goto error; - if(H5Fclose(fid) < 0) goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Dclose(dsid) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(dsid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: main * @@ -213,20 +236,19 @@ error: int main(void) { - int nerrors = 0; + int nerrors = 0; - nerrors += test_filters_endianess() < 0 ? 1 : 0; - nerrors += create_file_with_bogus_filter() < 0 ? 1 : 0; + nerrors += test_filters_endianess() < 0 ? 1 : 0; + nerrors += create_file_with_bogus_filter() < 0 ? 1 : 0; - if(nerrors) - goto error; - printf("All tests passed.\n"); + if (nerrors) + goto error; + printf("All tests passed.\n"); - return 0; + return 0; error: - nerrors = MAX(1, nerrors); - printf("***** %d GEN_FILTERS FAILURES *****\n", nerrors); - return 1; + nerrors = MAX(1, nerrors); + printf("***** %d GEN_FILTERS FAILURES *****\n", nerrors); + return 1; } - diff --git a/test/gen_mergemsg.c b/test/gen_mergemsg.c index f158d57..84f4376 100644 --- a/test/gen_mergemsg.c +++ b/test/gen_mergemsg.c @@ -25,25 +25,26 @@ #include #include "hdf5.h" -#define FILENAME "mergemsg.h5" -#define GROUP1 "grp1" -#define GROUP2 "grp2" -#define GROUP3 "grp3" -#define ATTR1 "__111111111111__" -#define ATTR1_LEN 11 -#define ATTR2 "__222222222__" -#define ATTR2_LEN 11 -#define ATTR3 "__333333333__" -#define ATTR3_LEN 1 - -int main() +#define FILENAME "mergemsg.h5" +#define GROUP1 "grp1" +#define GROUP2 "grp2" +#define GROUP3 "grp3" +#define ATTR1 "__111111111111__" +#define ATTR1_LEN 11 +#define ATTR2 "__222222222__" +#define ATTR2_LEN 11 +#define ATTR3 "__333333333__" +#define ATTR3_LEN 1 + +int +main() { - hid_t fid; /* File ID */ - hid_t gid, gid2, gid3; /* Group IDs */ - hid_t aid; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t gid, gid2, gid3; /* Group IDs */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + herr_t ret; /* Generic return value */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -69,7 +70,6 @@ int main() ret = H5Fclose(fid); assert(ret >= 0); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); assert(fid > 0); @@ -138,7 +138,6 @@ int main() ret = H5Fclose(fid); assert(ret >= 0); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); assert(fid > 0); @@ -167,9 +166,6 @@ int main() ret = H5Fclose(fid); assert(ret >= 0); - - - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); assert(fid > 0); @@ -212,8 +208,6 @@ int main() ret = H5Fclose(fid); assert(ret >= 0); - - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); assert(fid > 0); @@ -260,7 +254,6 @@ int main() ret = H5Fclose(fid); assert(ret >= 0); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); assert(fid > 0); @@ -281,7 +274,6 @@ int main() ret = H5Fclose(fid); assert(ret >= 0); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); assert(fid > 0); @@ -324,7 +316,5 @@ int main() ret = H5Fclose(fid); assert(ret >= 0); - return(0); + return (0); } - - diff --git a/test/gen_new_array.c b/test/gen_new_array.c index 27f162c..6cd2d7d 100644 --- a/test/gen_new_array.c +++ b/test/gen_new_array.c @@ -28,18 +28,17 @@ */ #include "hdf5.h" -#define TESTFILE "tarrnew.h5" +#define TESTFILE "tarrnew.h5" /* 1-D array datatype */ -#define ARRAY1_RANK 1 +#define ARRAY1_RANK 1 #define ARRAY1_DIM1 4 /* 2-D dataset with fixed dimensions */ -#define SPACE1_RANK 2 -#define SPACE1_DIM1 8 -#define SPACE1_DIM2 9 +#define SPACE1_RANK 2 +#define SPACE1_DIM1 8 +#define SPACE1_DIM2 9 - /*------------------------------------------------------------------------- * Function: main * @@ -59,75 +58,75 @@ int main(void) { - typedef struct { /* Typedef for compound datatype */ - short i; - float f[ARRAY1_DIM1]; - long l[ARRAY1_DIM1]; + typedef struct { /* Typedef for compound datatype */ + short i; + float f[ARRAY1_DIM1]; + long l[ARRAY1_DIM1]; double d; } s3_t; - hid_t file, space, type, arr_type, dset; - hsize_t tdims1[] = {ARRAY1_DIM1}; - hsize_t cur_dim[SPACE1_RANK]={SPACE1_DIM1,SPACE1_DIM2}; - herr_t ret; /* Generic return value */ + hid_t file, space, type, arr_type, dset; + hsize_t tdims1[] = {ARRAY1_DIM1}; + hsize_t cur_dim[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; + herr_t ret; /* Generic return value */ /* Create the file */ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(file<0) + if (file < 0) printf("file<0!\n"); /* Create the dataspace (for both datasets) */ space = H5Screate_simple(SPACE1_RANK, cur_dim, NULL); - if(space<0) + if (space < 0) printf("space<0!\n"); /* Create the compound datatype with array fields */ type = H5Tcreate(H5T_COMPOUND, sizeof(s3_t)); - if(type<0) + if (type < 0) printf("type<0!\n"); /* Insert integer field */ - ret = H5Tinsert (type, "i", HOFFSET(s3_t,i), H5T_NATIVE_SHORT); - if(ret<0) + ret = H5Tinsert(type, "i", HOFFSET(s3_t, i), H5T_NATIVE_SHORT); + if (ret < 0) printf("field 1 insert<0!\n"); /* Creat the array datatype */ arr_type = H5Tarray_create2(H5T_NATIVE_FLOAT, ARRAY1_RANK, tdims1); - if(arr_type < 0) + if (arr_type < 0) printf("arr_type<0!\n"); /* Insert float array field */ - ret = H5Tinsert (type, "f", HOFFSET(s3_t,f), arr_type); - if(ret<0) + ret = H5Tinsert(type, "f", HOFFSET(s3_t, f), arr_type); + if (ret < 0) printf("field 3 insert<0!\n"); /* Close array datatype */ - ret = H5Tclose (arr_type); - if(ret<0) + ret = H5Tclose(arr_type); + if (ret < 0) printf("field 3 array close<0!\n"); /* Creat the array datatype */ arr_type = H5Tarray_create2(H5T_NATIVE_LONG, ARRAY1_RANK, tdims1); - if(arr_type < 0) + if (arr_type < 0) printf("arr_type<0!\n"); /* Insert long array field */ - ret = H5Tinsert (type, "l", HOFFSET(s3_t,l), arr_type); - if(ret<0) + ret = H5Tinsert(type, "l", HOFFSET(s3_t, l), arr_type); + if (ret < 0) printf("field 3 insert<0!\n"); /* Close array datatype */ - ret = H5Tclose (arr_type); - if(ret<0) + ret = H5Tclose(arr_type); + if (ret < 0) printf("field 3 array close<0!\n"); /* Insert double field */ - ret = H5Tinsert (type, "d", HOFFSET(s3_t,d), H5T_NATIVE_DOUBLE); - if(ret<0) + ret = H5Tinsert(type, "d", HOFFSET(s3_t, d), H5T_NATIVE_DOUBLE); + if (ret < 0) printf("field 4 insert<0!\n"); /* Create the dataset with compound array fields */ dset = H5Dcreate2(file, "Dataset1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset<0) + if (dset < 0) printf("dset<0!\n"); H5Dclose(dset); @@ -136,12 +135,12 @@ main(void) /* Create the compound datatype with array fields */ type = H5Tarray_create2(H5T_NATIVE_INT, ARRAY1_RANK, tdims1); - if(type < 0) + if (type < 0) printf("type<0!\n"); /* Create the dataset with array datatype */ dset = H5Dcreate2(file, "Dataset2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset<0) + if (dset < 0) printf("dset<0!\n"); H5Dclose(dset); @@ -153,4 +152,3 @@ main(void) return 0; } - diff --git a/test/gen_new_fill.c b/test/gen_new_fill.c index 5bdbf73..d0f043b 100644 --- a/test/gen_new_fill.c +++ b/test/gen_new_fill.c @@ -31,57 +31,74 @@ int main(void) { - hid_t file=-1, dcpl=-1, space=-1, dset1=-1, dset2=-1; - hsize_t cur_size[2]={8, 8}; - H5D_space_status_t allocation; - int fill_val1 = 4444, fill_val2=5555; + hid_t file = -1, dcpl = -1, space = -1, dset1 = -1, dset2 = -1; + hsize_t cur_size[2] = {8, 8}; + H5D_space_status_t allocation; + int fill_val1 = 4444, fill_val2 = 5555; - if((file=H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) <0) goto error; - if((space=H5Screate_simple(2, cur_size, cur_size)) < 0) goto error; - if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if ((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if ((space = H5Screate_simple(2, cur_size, cur_size)) < 0) + goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; /* Create a dataset with space being allocated and fill value written */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto error; - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill_val1) < 0) goto error; - if((dset1 = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dget_space_status(dset1, &allocation) < 0) goto error; - if(allocation == H5D_SPACE_STATUS_NOT_ALLOCATED) { - puts(" Got unallocated space instead of allocated."); - printf(" Got %d\n", allocation); - goto error; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill_val1) < 0) + goto error; + if ((dset1 = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dget_space_status(dset1, &allocation) < 0) + goto error; + if (allocation == H5D_SPACE_STATUS_NOT_ALLOCATED) { + puts(" Got unallocated space instead of allocated."); + printf(" Got %d\n", allocation); + goto error; } - if(H5Dclose(dset1) < 0) goto error; + if (H5Dclose(dset1) < 0) + goto error; /* Create a dataset with space allocation being delayed */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) goto error; - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill_val2) < 0) goto error; - if((dset2 = H5Dcreate2(file, "dset2", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dget_space_status(dset2, &allocation) < 0) goto error; - if(allocation != H5D_SPACE_STATUS_NOT_ALLOCATED) { - puts(" Got allocated space instead of unallocated."); - printf(" Got %d\n", allocation); - goto error; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto error; + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + goto error; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill_val2) < 0) + goto error; + if ((dset2 = H5Dcreate2(file, "dset2", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if (H5Dget_space_status(dset2, &allocation) < 0) + goto error; + if (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED) { + puts(" Got allocated space instead of unallocated."); + printf(" Got %d\n", allocation); + goto error; } - if(H5Dclose(dset2) < 0) goto error; + if (H5Dclose(dset2) < 0) + goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Pclose(dcpl) < 0) goto error; - if(H5Fclose(file) < 0) goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Fclose(file) < 0) + goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(space); H5Dclose(dset1); H5Dclose(dset2); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - diff --git a/test/gen_new_group.c b/test/gen_new_group.c index 6924291..a73828b 100644 --- a/test/gen_new_group.c +++ b/test/gen_new_group.c @@ -29,75 +29,95 @@ #define FILENAME "group_new.h5" -int main(void) +int +main(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t gid = -1; /* Group creation property list ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t gid = -1; /* Group creation property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; /* Adjust group creation parameters for root group */ /* (So that it is created in "dense storage" form) */ - if(H5Pset_link_phase_change(fcpl, 0, 0) < 0) goto error; + if (H5Pset_link_phase_change(fcpl, 0, 0) < 0) + goto error; /* Copy the file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; /* Create file for test groups */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) <0) goto error; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + goto error; /* Close file access property list */ - if(H5Pclose(fapl) < 0) goto error; + if (H5Pclose(fapl) < 0) + goto error; /* Close file creation property list */ - if(H5Pclose(fcpl) < 0) goto error; + if (H5Pclose(fcpl) < 0) + goto error; /* Create dataspace for datasets */ - if((sid = H5Screate(H5S_SCALAR)) < 0) goto error; + if ((sid = H5Screate(H5S_SCALAR)) < 0) + goto error; /* Create empty group (w/default group creation properties) */ - if((gid = H5Gcreate2(fid, "empty", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) goto error; + if ((gid = H5Gcreate2(fid, "empty", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Gclose(gid) < 0) + goto error; /* Create group which will contain link messages (w/default group creation properties) */ - if((gid = H5Gcreate2(fid, "links", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((gid = H5Gcreate2(fid, "links", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* Create dataset in group */ - if((did = H5Dcreate2(gid, "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did)<0) goto error; + if ((did = H5Dcreate2(gid, "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; /* Create second dataset in group */ - if((did = H5Dcreate2(gid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did)<0) goto error; + if ((did = H5Dcreate2(gid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; /* Close dataspace */ - if(H5Sclose(sid) < 0) goto error; + if (H5Sclose(sid) < 0) + goto error; /* Close group */ - if(H5Gclose(gid) < 0) goto error; + if (H5Gclose(gid) < 0) + goto error; /* Close file */ - if(H5Fclose(fid) < 0) goto error; + if (H5Fclose(fid) < 0) + goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); H5Gclose(gid); H5Pclose(fcpl); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - diff --git a/test/gen_new_mtime.c b/test/gen_new_mtime.c index b44d567..87de948 100644 --- a/test/gen_new_mtime.c +++ b/test/gen_new_mtime.c @@ -26,9 +26,8 @@ #include "hdf5.h" -#define TESTFILE "tmtimen.h5" +#define TESTFILE "tmtimen.h5" - /*------------------------------------------------------------------------- * Function: main * @@ -48,21 +47,21 @@ int main(void) { - hid_t file, space, dset; + hid_t file, space, dset; /* Create the file */ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(file<0) + if (file < 0) printf("file<0!\n"); /* Create the dataspace (for dataset) */ space = H5Screate(H5S_SCALAR); - if(space<0) + if (space < 0) printf("space<0!\n"); /* Create the dataset with compound array fields */ dset = H5Dcreate2(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset<0) + if (dset < 0) printf("dset<0!\n"); H5Dclose(dset); @@ -71,5 +70,3 @@ main(void) return 0; } - - diff --git a/test/gen_new_super.c b/test/gen_new_super.c index d371f5f..2a268f5 100644 --- a/test/gen_new_super.c +++ b/test/gen_new_super.c @@ -25,10 +25,9 @@ #include "h5test.h" -#define TESTFILE "tsupern.h5" -#define ISTORE_IK 64 +#define TESTFILE "tsupern.h5" +#define ISTORE_IK 64 - /*------------------------------------------------------------------------- * Function: main * @@ -44,15 +43,15 @@ int main(void) { - hid_t file; /* File IDs for old & new files */ - hid_t fcpl; /* File creation property list */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; + hid_t file; /* File IDs for old & new files */ + hid_t fcpl; /* File creation property list */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Create a file creation property list */ fcpl = H5Pcreate(H5P_FILE_CREATE); HDassert(fcpl >= 0); - ret = H5Pset_istore_k(fcpl,ISTORE_IK); + ret = H5Pset_istore_k(fcpl, ISTORE_IK); HDassert(ret >= 0); /* Creating a file with the non-default file creation property list should @@ -60,7 +59,7 @@ main(void) */ /* Create file with custom file creation property list */ - file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); + file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); HDassert(file >= 0); /* Close FCPL */ @@ -73,4 +72,3 @@ main(void) return EXIT_SUCCESS; } - diff --git a/test/gen_noencoder.c b/test/gen_noencoder.c index e6ac9cf..9b68bcd 100644 --- a/test/gen_noencoder.c +++ b/test/gen_noencoder.c @@ -32,18 +32,18 @@ int main(void) { - hid_t file_id; - hid_t dset_id; - hid_t dcpl_id; - hid_t space_id; + hid_t file_id; + hid_t dset_id; + hid_t dcpl_id; + hid_t space_id; hsize_t dims, maxdims; - int fill = 0; - int write_buf[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + int fill = 0; + int write_buf[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; file_id = H5Fcreate("noencoder.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - dims = 10; - maxdims = H5S_UNLIMITED; + dims = 10; + maxdims = H5S_UNLIMITED; space_id = H5Screate_simple(1, &dims, &maxdims); dcpl_id = H5Pcreate(H5P_DATASET_CREATE); @@ -52,8 +52,9 @@ main(void) H5Pset_fill_value(dcpl_id, H5T_NATIVE_INT, &fill); H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_ALLOC); -/* Create dataset noencoder_szip_dset.h5 */ - dset_id = H5Dcreate2(file_id, "noencoder_szip_dset.h5", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + /* Create dataset noencoder_szip_dset.h5 */ + dset_id = H5Dcreate2(file_id, "noencoder_szip_dset.h5", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, + H5P_DEFAULT); H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf); @@ -68,8 +69,9 @@ main(void) H5Pset_fill_value(dcpl_id, H5T_NATIVE_INT, &fill); H5Pset_fill_time(dcpl_id, H5D_FILL_TIME_ALLOC); -/* Create dataset noencoder_szip_shuffle_fletcher_dset.h5 */ - dset_id = H5Dcreate2(file_id, "noencoder_szip_shuffle_fletcher_dset.h5", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + /* Create dataset noencoder_szip_shuffle_fletcher_dset.h5 */ + dset_id = H5Dcreate2(file_id, "noencoder_szip_shuffle_fletcher_dset.h5", H5T_NATIVE_INT, space_id, + H5P_DEFAULT, dcpl_id, H5P_DEFAULT); H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf); @@ -78,6 +80,5 @@ main(void) H5Sclose(space_id); H5Fclose(file_id); - return(0); + return (0); } - diff --git a/test/gen_nullspace.c b/test/gen_nullspace.c index 26df3f1..9002309 100644 --- a/test/gen_nullspace.c +++ b/test/gen_nullspace.c @@ -26,19 +26,19 @@ #include "h5test.h" -#define NULLFILE "tnullspace.h5" -#define NULLDATASET "null_dataset" -#define NULLATTR "null_attribute" +#define NULLFILE "tnullspace.h5" +#define NULLDATASET "null_dataset" +#define NULLATTR "null_attribute" int main(void) { - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ - hid_t sid; /* Dataspace ID */ - hid_t did; /* Dataset ID */ - hid_t attr; /* Attribute ID */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ + hid_t attr; /* Attribute ID */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Create the file */ fid = H5Fcreate(NULLFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -81,5 +81,3 @@ main(void) return EXIT_SUCCESS; } - - diff --git a/test/gen_old_array.c b/test/gen_old_array.c index 3fab657..a9763fa 100644 --- a/test/gen_old_array.c +++ b/test/gen_old_array.c @@ -27,18 +27,17 @@ */ #include "hdf5.h" -#define TESTFILE "tarrold.h5" +#define TESTFILE "tarrold.h5" /* 1-D array datatype */ -#define ARRAY1_RANK 1 +#define ARRAY1_RANK 1 #define ARRAY1_DIM1 4 /* 2-D dataset with fixed dimensions */ -#define SPACE1_RANK 2 -#define SPACE1_DIM1 8 -#define SPACE1_DIM2 9 +#define SPACE1_RANK 2 +#define SPACE1_DIM1 8 +#define SPACE1_DIM2 9 - /*------------------------------------------------------------------------- * Function: main * @@ -58,55 +57,55 @@ int main(void) { - typedef struct { /* Typedef for compound datatype */ + typedef struct { /* Typedef for compound datatype */ short i; float f; - long l; + long l; } s2_t; - typedef struct { /* Typedef for compound datatype */ - short i; - float f[ARRAY1_DIM1]; - long l[ARRAY1_DIM1]; + typedef struct { /* Typedef for compound datatype */ + short i; + float f[ARRAY1_DIM1]; + long l[ARRAY1_DIM1]; double d; } s3_t; - hid_t file, space, type, dset; - size_t tdims1[] = {ARRAY1_DIM1}; - hsize_t cur_dim[SPACE1_RANK]={SPACE1_DIM1,SPACE1_DIM2}; - herr_t ret; /* Generic return value */ + hid_t file, space, type, dset; + size_t tdims1[] = {ARRAY1_DIM1}; + hsize_t cur_dim[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; + herr_t ret; /* Generic return value */ /* Create the file */ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(file<0) + if (file < 0) printf("file<0!\n"); /* Create the dataspace (for both datasets) */ space = H5Screate_simple(SPACE1_RANK, cur_dim, NULL); - if(space<0) + if (space < 0) printf("space<0!\n"); /* Create the compound datatype with non-array fields */ type = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); - if(type<0) + if (type < 0) printf("type<0!\n"); /* Insert integer field */ - ret = H5Tinsert (type, "i", HOFFSET(s2_t,i), H5T_NATIVE_SHORT); - if(ret<0) + ret = H5Tinsert(type, "i", HOFFSET(s2_t, i), H5T_NATIVE_SHORT); + if (ret < 0) printf("field 1 insert<0!\n"); /* Insert float field */ - ret = H5Tinsert (type, "f", HOFFSET(s2_t,f), H5T_NATIVE_FLOAT); - if(ret<0) + ret = H5Tinsert(type, "f", HOFFSET(s2_t, f), H5T_NATIVE_FLOAT); + if (ret < 0) printf("field 3 insert<0!\n"); /* Insert long field */ - ret = H5Tinsert (type, "l", HOFFSET(s2_t,l), H5T_NATIVE_LONG); - if(ret<0) + ret = H5Tinsert(type, "l", HOFFSET(s2_t, l), H5T_NATIVE_LONG); + if (ret < 0) printf("field 3 insert<0!\n"); /* Create the dataset with compound non-array fields */ dset = H5Dcreate2(file, "Dataset1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset<0) + if (dset < 0) printf("dset<0!\n"); H5Dclose(dset); @@ -115,32 +114,32 @@ main(void) /* Create the compound datatype with array fields */ type = H5Tcreate(H5T_COMPOUND, sizeof(s3_t)); - if(type<0) + if (type < 0) printf("type<0!\n"); /* Insert integer field */ - ret = H5Tinsert (type, "i", HOFFSET(s3_t,i), H5T_NATIVE_SHORT); - if(ret<0) + ret = H5Tinsert(type, "i", HOFFSET(s3_t, i), H5T_NATIVE_SHORT); + if (ret < 0) printf("field 1 insert<0!\n"); /* Insert float array field */ - ret = H5Tinsert_array (type, "f", HOFFSET(s3_t,f), ARRAY1_RANK, tdims1, NULL, H5T_NATIVE_FLOAT); - if(ret<0) + ret = H5Tinsert_array(type, "f", HOFFSET(s3_t, f), ARRAY1_RANK, tdims1, NULL, H5T_NATIVE_FLOAT); + if (ret < 0) printf("field 3 insert<0!\n"); /* Insert long array field */ - ret = H5Tinsert_array (type, "l", HOFFSET(s3_t,l), ARRAY1_RANK, tdims1, NULL, H5T_NATIVE_LONG); - if(ret<0) + ret = H5Tinsert_array(type, "l", HOFFSET(s3_t, l), ARRAY1_RANK, tdims1, NULL, H5T_NATIVE_LONG); + if (ret < 0) printf("field 3 insert<0!\n"); /* Insert double field */ - ret = H5Tinsert (type, "d", HOFFSET(s3_t,d), H5T_NATIVE_DOUBLE); - if(ret<0) + ret = H5Tinsert(type, "d", HOFFSET(s3_t, d), H5T_NATIVE_DOUBLE); + if (ret < 0) printf("field 4 insert<0!\n"); /* Create the dataset with compound array fields */ dset = H5Dcreate2(file, "Dataset2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset<0) + if (dset < 0) printf("dset<0!\n"); H5Dclose(dset); diff --git a/test/gen_old_group.c b/test/gen_old_group.c index d109329..1b69894 100644 --- a/test/gen_old_group.c +++ b/test/gen_old_group.c @@ -31,28 +31,34 @@ #define FILENAME "group_old.h5" -int main(void) +int +main(void) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group creation property list ID */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group creation property list ID */ /* Create file for test groups */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) <0) goto error; + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* Create empty group that uses "symbol table" form to store links */ - if((gid = H5Gcreate2(fid, "old", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) goto error; + if ((gid = H5Gcreate2(fid, "old", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Gclose(gid) < 0) + goto error; /* Close file */ - if(H5Fclose(fid) < 0) goto error; + if (H5Fclose(fid) < 0) + goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - diff --git a/test/gen_old_layout.c b/test/gen_old_layout.c index 56c3e4e..5a17145 100644 --- a/test/gen_old_layout.c +++ b/test/gen_old_layout.c @@ -30,11 +30,10 @@ #include "hdf5.h" #define TESTFILE "tlayouto.h5" -#define SPACE_RANK 2 -#define SPACE_DIM0 (8*1024*1024*1024ULL) -#define SPACE_DIM1 ((256*1024*1024ULL)+1ULL) +#define SPACE_RANK 2 +#define SPACE_DIM0 (8 * 1024 * 1024 * 1024ULL) +#define SPACE_DIM1 ((256 * 1024 * 1024ULL) + 1ULL) - /*------------------------------------------------------------------------- * Function: main * @@ -54,34 +53,34 @@ int main(void) { - hid_t file, space, dset, dcpl; - herr_t ret; - unsigned rank=SPACE_RANK; /* Rank of dataspace */ - hsize_t big_dims[SPACE_RANK]={SPACE_DIM0,SPACE_DIM1}; /* Large dimensions */ + hid_t file, space, dset, dcpl; + herr_t ret; + unsigned rank = SPACE_RANK; /* Rank of dataspace */ + hsize_t big_dims[SPACE_RANK] = {SPACE_DIM0, SPACE_DIM1}; /* Large dimensions */ /* Create the file */ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(file<0) + if (file < 0) printf("file<0!\n"); /* Create the dataspace (for dataset) */ - space = H5Screate_simple(rank,big_dims,NULL); - if(space<0) + space = H5Screate_simple(rank, big_dims, NULL); + if (space < 0) printf("space<0!\n"); /* Create a dataset creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl<0) + if (dcpl < 0) printf("dcpl<0!\n"); /* Make certain that the dataset's storage doesn't get allocated :-) */ - ret = H5Pset_alloc_time(dcpl,H5D_ALLOC_TIME_LATE); - if(ret<0) + ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); + if (ret < 0) printf("H5Pset_alloc_time() failed!\n"); /* Create the dataset with deferred storage allocation */ dset = H5Dcreate2(file, "Dataset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset<0) + if (dset < 0) printf("dset<0!\n"); H5Dclose(dset); @@ -91,4 +90,3 @@ main(void) return 0; } - diff --git a/test/gen_old_mtime.c b/test/gen_old_mtime.c index cbe3bdc..f14ecdf 100644 --- a/test/gen_old_mtime.c +++ b/test/gen_old_mtime.c @@ -26,9 +26,8 @@ #include "hdf5.h" -#define TESTFILE "tmtimeo.h5" +#define TESTFILE "tmtimeo.h5" - /*------------------------------------------------------------------------- * Function: main * @@ -48,21 +47,21 @@ int main(void) { - hid_t file, space, dset; + hid_t file, space, dset; /* Create the file */ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(file<0) + if (file < 0) printf("file<0!\n"); /* Create the dataspace (for dataset) */ space = H5Screate(H5S_SCALAR); - if(space<0) + if (space < 0) printf("space<0!\n"); /* Create the dataset with compound array fields */ dset = H5Dcreate2(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset<0) + if (dset < 0) printf("dset<0!\n"); H5Dclose(dset); @@ -71,6 +70,3 @@ main(void) return 0; } - - - diff --git a/test/gen_plist.c b/test/gen_plist.c index 7f64aa4..a03e886 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -23,75 +23,70 @@ static int encode_plist(hid_t plist_id, int little_endian, int word_length, cons int main(void) { - hid_t dcpl1; /* dataset create prop. list */ - hid_t dapl1; /* dataset access prop. list */ - hid_t dxpl1; /* dataset xfer prop. list */ - hid_t gcpl1; /* group create prop. list */ - hid_t ocpypl1; /* object copy prop. list */ - hid_t ocpl1; /* object create prop. list */ - hid_t lcpl1; /* link create prop. list */ - hid_t lapl1; /* link access prop. list */ - hid_t fapl1; /* file access prop. list */ - hid_t fcpl1; /* file create prop. list */ - hid_t strcpl1; /* string create prop. list */ - hid_t acpl1; /* attribute create prop. list */ - - herr_t ret = 0; - hsize_t chunk_size = 16384; /* chunk size */ - int fill = 2; /* Fill value */ - hsize_t max_size[1]; /* data space maximum size */ - size_t nslots = 521 * 2; - size_t nbytes = 1048576 * 10; - double w0 = 0.5f; - unsigned max_compact; - unsigned min_dense; - const char* c_to_f = "x+32"; - int little_endian; - int word_length; - H5AC_cache_config_t my_cache_config = { - H5AC__CURR_CACHE_CONFIG_VERSION, - 1 /*TRUE*/, - 0 /*FALSE*/, - 0 /*FALSE*/, - "temp", - 1 /*TRUE*/, - 0 /*FALSE*/, - ( 2 * 2048 * 1024), - 0.3f, - (64 * 1024 * 1024), - (4 * 1024 * 1024), - 60000, - H5C_incr__threshold, - 0.8f, - 3.0f, - 1 /*TRUE*/, - (8 * 1024 * 1024), - H5C_flash_incr__add_space, - 2.0f, - 0.25f, - H5C_decr__age_out_with_threshold, - 0.997f, - 0.8f, - 1 /*TRUE*/, - (3 * 1024 * 1024), - 3, - 0 /*FALSE*/, - 0.2f, - (256 * 2048), - H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY}; - H5AC_cache_image_config_t my_cache_image_config = { - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, - FALSE, - -1}; - + hid_t dcpl1; /* dataset create prop. list */ + hid_t dapl1; /* dataset access prop. list */ + hid_t dxpl1; /* dataset xfer prop. list */ + hid_t gcpl1; /* group create prop. list */ + hid_t ocpypl1; /* object copy prop. list */ + hid_t ocpl1; /* object create prop. list */ + hid_t lcpl1; /* link create prop. list */ + hid_t lapl1; /* link access prop. list */ + hid_t fapl1; /* file access prop. list */ + hid_t fcpl1; /* file create prop. list */ + hid_t strcpl1; /* string create prop. list */ + hid_t acpl1; /* attribute create prop. list */ + + herr_t ret = 0; + hsize_t chunk_size = 16384; /* chunk size */ + int fill = 2; /* Fill value */ + hsize_t max_size[1]; /* data space maximum size */ + size_t nslots = 521 * 2; + size_t nbytes = 1048576 * 10; + double w0 = 0.5f; + unsigned max_compact; + unsigned min_dense; + const char * c_to_f = "x+32"; + int little_endian; + int word_length; + H5AC_cache_config_t my_cache_config = {H5AC__CURR_CACHE_CONFIG_VERSION, + 1 /*TRUE*/, + 0 /*FALSE*/, + 0 /*FALSE*/, + "temp", + 1 /*TRUE*/, + 0 /*FALSE*/, + (2 * 2048 * 1024), + 0.3f, + (64 * 1024 * 1024), + (4 * 1024 * 1024), + 60000, + H5C_incr__threshold, + 0.8f, + 3.0f, + 1 /*TRUE*/, + (8 * 1024 * 1024), + H5C_flash_incr__add_space, + 2.0f, + 0.25f, + H5C_decr__age_out_with_threshold, + 0.997f, + 0.8f, + 1 /*TRUE*/, + (3 * 1024 * 1024), + 3, + 0 /*FALSE*/, + 0.2f, + (256 * 2048), + H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY}; + H5AC_cache_image_config_t my_cache_image_config = {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, + -1}; /* check endianess */ { short int word = 0x0001; - char *byte = (char *) &word; + char * byte = (char *)&word; - if(byte[0] == 1) + if (byte[0] == 1) /* little endian */ little_endian = 1; else @@ -108,153 +103,147 @@ main(void) H5open(); /******* ENCODE/DECODE DCPLS *****/ - if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) assert(dcpl1 > 0); - if((ret = encode_plist(dcpl1, little_endian, word_length, "testfiles/plist_files/def_dcpl_")) < 0) + if ((ret = encode_plist(dcpl1, little_endian, word_length, "testfiles/plist_files/def_dcpl_")) < 0) assert(ret > 0); - if((ret = H5Pset_chunk(dcpl1, 1, &chunk_size)) < 0) + if ((ret = H5Pset_chunk(dcpl1, 1, &chunk_size)) < 0) assert(ret > 0); - if((ret = H5Pset_alloc_time(dcpl1, H5D_ALLOC_TIME_LATE)) < 0) + if ((ret = H5Pset_alloc_time(dcpl1, H5D_ALLOC_TIME_LATE)) < 0) assert(ret > 0); ret = H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32BE, (size_t)1, &fill, NULL, H5P_DEFAULT); assert(ret >= 0); - if((ret = H5Pset_fill_value(dcpl1, H5T_STD_I32BE, &fill)) < 0) + if ((ret = H5Pset_fill_value(dcpl1, H5T_STD_I32BE, &fill)) < 0) assert(ret > 0); - if((ret = H5Pset_dset_no_attrs_hint(dcpl1, FALSE)) < 0) + if ((ret = H5Pset_dset_no_attrs_hint(dcpl1, FALSE)) < 0) assert(ret > 0); max_size[0] = 100; - if((ret = H5Pset_external(dcpl1, "ext1.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + if ((ret = H5Pset_external(dcpl1, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) assert(ret > 0); - if((ret = H5Pset_external(dcpl1, "ext2.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + if ((ret = H5Pset_external(dcpl1, "ext2.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) assert(ret > 0); - if((ret = H5Pset_external(dcpl1, "ext3.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + if ((ret = H5Pset_external(dcpl1, "ext3.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) assert(ret > 0); - if((ret = H5Pset_external(dcpl1, "ext4.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + if ((ret = H5Pset_external(dcpl1, "ext4.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) assert(ret > 0); - if((ret = encode_plist(dcpl1, little_endian, word_length, "testfiles/plist_files/dcpl_")) < 0) + if ((ret = encode_plist(dcpl1, little_endian, word_length, "testfiles/plist_files/dcpl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(dcpl1)) < 0) - assert(ret > 0); - + if ((ret = H5Pclose(dcpl1)) < 0) + assert(ret > 0); /******* ENCODE/DECODE DAPLS *****/ - if((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) assert(dapl1 > 0); - if((ret = encode_plist(dapl1, little_endian, word_length, "testfiles/plist_files/def_dapl_")) < 0) + if ((ret = encode_plist(dapl1, little_endian, word_length, "testfiles/plist_files/def_dapl_")) < 0) assert(ret > 0); - if((ret = H5Pset_chunk_cache(dapl1, nslots, nbytes, w0)) < 0) + if ((ret = H5Pset_chunk_cache(dapl1, nslots, nbytes, w0)) < 0) assert(ret > 0); - if((ret = encode_plist(dapl1, little_endian, word_length, "testfiles/plist_files/dapl_")) < 0) + if ((ret = encode_plist(dapl1, little_endian, word_length, "testfiles/plist_files/dapl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(dapl1)) < 0) - assert(ret > 0); + if ((ret = H5Pclose(dapl1)) < 0) + assert(ret > 0); /******* ENCODE/DECODE DXPLS *****/ - if((dxpl1 = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl1 = H5Pcreate(H5P_DATASET_XFER)) < 0) assert(dxpl1 > 0); - if((ret = encode_plist(dxpl1, little_endian, word_length, "testfiles/plist_files/def_dxpl_")) < 0) + if ((ret = encode_plist(dxpl1, little_endian, word_length, "testfiles/plist_files/def_dxpl_")) < 0) assert(ret > 0); - if((ret = H5Pset_btree_ratios(dxpl1, 0.2f, 0.6f, 0.2f)) < 0) + if ((ret = H5Pset_btree_ratios(dxpl1, 0.2f, 0.6f, 0.2f)) < 0) assert(ret > 0); - if((ret = H5Pset_hyper_vector_size(dxpl1, 5)) < 0) + if ((ret = H5Pset_hyper_vector_size(dxpl1, 5)) < 0) assert(ret > 0); #ifdef H5_HAVE_PARALLEL - if((ret = H5Pset_dxpl_mpio(dxpl1, H5FD_MPIO_COLLECTIVE)) < 0) + if ((ret = H5Pset_dxpl_mpio(dxpl1, H5FD_MPIO_COLLECTIVE)) < 0) assert(ret > 0); - if((ret = H5Pset_dxpl_mpio_collective_opt(dxpl1, H5FD_MPIO_INDIVIDUAL_IO)) < 0) + if ((ret = H5Pset_dxpl_mpio_collective_opt(dxpl1, H5FD_MPIO_INDIVIDUAL_IO)) < 0) assert(ret > 0); - if((ret = H5Pset_dxpl_mpio_chunk_opt(dxpl1, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) + if ((ret = H5Pset_dxpl_mpio_chunk_opt(dxpl1, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) assert(ret > 0); - if((ret = H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl1, 30)) < 0) + if ((ret = H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl1, 30)) < 0) assert(ret > 0); - if((ret = H5Pset_dxpl_mpio_chunk_opt_num(dxpl1, 40)) < 0) + if ((ret = H5Pset_dxpl_mpio_chunk_opt_num(dxpl1, 40)) < 0) assert(ret > 0); -#endif/* H5_HAVE_PARALLEL */ - if((ret = H5Pset_edc_check(dxpl1, H5Z_DISABLE_EDC)) < 0) +#endif /* H5_HAVE_PARALLEL */ + if ((ret = H5Pset_edc_check(dxpl1, H5Z_DISABLE_EDC)) < 0) assert(ret > 0); - if((ret = H5Pset_data_transform(dxpl1, c_to_f)) < 0) + if ((ret = H5Pset_data_transform(dxpl1, c_to_f)) < 0) assert(ret > 0); - if((ret = encode_plist(dxpl1, little_endian, word_length, "testfiles/plist_files/dxpl_")) < 0) + if ((ret = encode_plist(dxpl1, little_endian, word_length, "testfiles/plist_files/dxpl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(dxpl1)) < 0) - assert(ret > 0); - + if ((ret = H5Pclose(dxpl1)) < 0) + assert(ret > 0); /******* ENCODE/DECODE GCPLS *****/ - if((gcpl1 = H5Pcreate(H5P_GROUP_CREATE)) < 0) + if ((gcpl1 = H5Pcreate(H5P_GROUP_CREATE)) < 0) assert(gcpl1 > 0); - if((ret = encode_plist(gcpl1, little_endian, word_length, "testfiles/plist_files/def_gcpl_")) < 0) + if ((ret = encode_plist(gcpl1, little_endian, word_length, "testfiles/plist_files/def_gcpl_")) < 0) assert(ret > 0); - if((ret = H5Pset_local_heap_size_hint(gcpl1, 256)) < 0) - assert(ret > 0); + if ((ret = H5Pset_local_heap_size_hint(gcpl1, 256)) < 0) + assert(ret > 0); - if((ret = H5Pset_link_phase_change(gcpl1, 2, 2)) < 0) - assert(ret > 0); + if ((ret = H5Pset_link_phase_change(gcpl1, 2, 2)) < 0) + assert(ret > 0); /* Query the group creation properties */ - if((ret = H5Pget_link_phase_change(gcpl1, &max_compact, &min_dense)) < 0) - assert(ret > 0); + if ((ret = H5Pget_link_phase_change(gcpl1, &max_compact, &min_dense)) < 0) + assert(ret > 0); - if((ret = H5Pset_est_link_info(gcpl1, 3, 9)) < 0) - assert(ret > 0); + if ((ret = H5Pset_est_link_info(gcpl1, 3, 9)) < 0) + assert(ret > 0); - if((ret = H5Pset_link_creation_order(gcpl1, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) - assert(ret > 0); + if ((ret = H5Pset_link_creation_order(gcpl1, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + assert(ret > 0); - if((ret = encode_plist(gcpl1, little_endian, word_length, "testfiles/plist_files/gcpl_")) < 0) + if ((ret = encode_plist(gcpl1, little_endian, word_length, "testfiles/plist_files/gcpl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(gcpl1)) < 0) - assert(ret > 0); + if ((ret = H5Pclose(gcpl1)) < 0) + assert(ret > 0); /******* ENCODE/DECODE LCPLS *****/ - if((lcpl1 = H5Pcreate(H5P_LINK_CREATE)) < 0) + if ((lcpl1 = H5Pcreate(H5P_LINK_CREATE)) < 0) assert(lcpl1 > 0); - if((ret = encode_plist(lcpl1, little_endian, word_length, "testfiles/plist_files/def_lcpl_")) < 0) + if ((ret = encode_plist(lcpl1, little_endian, word_length, "testfiles/plist_files/def_lcpl_")) < 0) assert(ret > 0); - if((ret = H5Pset_create_intermediate_group(lcpl1, 1 /*TRUE*/)) < 0) + if ((ret = H5Pset_create_intermediate_group(lcpl1, 1 /*TRUE*/)) < 0) assert(ret > 0); - if((ret = encode_plist(lcpl1, little_endian, word_length, "testfiles/plist_files/lcpl_")) < 0) + if ((ret = encode_plist(lcpl1, little_endian, word_length, "testfiles/plist_files/lcpl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(lcpl1)) < 0) + if ((ret = H5Pclose(lcpl1)) < 0) assert(ret > 0); /******* ENCODE/DECODE OCPYLS *****/ - if((ocpypl1 = H5Pcreate(H5P_OBJECT_COPY)) < 0) + if ((ocpypl1 = H5Pcreate(H5P_OBJECT_COPY)) < 0) assert(ocpypl1 > 0); - if((ret = encode_plist(ocpypl1, little_endian, word_length, "testfiles/plist_files/def_ocpypl_")) < 0) + if ((ret = encode_plist(ocpypl1, little_endian, word_length, "testfiles/plist_files/def_ocpypl_")) < 0) assert(ret > 0); ret = H5Pset_copy_object(ocpypl1, H5O_COPY_EXPAND_EXT_LINK_FLAG); @@ -266,152 +255,152 @@ main(void) ret = H5Padd_merge_committed_dtype_path(ocpypl1, "bar"); assert(ret >= 0); - if((ret = encode_plist(ocpypl1, little_endian, word_length, "testfiles/plist_files/ocpypl_")) < 0) + if ((ret = encode_plist(ocpypl1, little_endian, word_length, "testfiles/plist_files/ocpypl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(ocpypl1)) < 0) - assert(ret > 0); + if ((ret = H5Pclose(ocpypl1)) < 0) + assert(ret > 0); /******* ENCODE/DECODE OCPLS *****/ - if((ocpl1 = H5Pcreate(H5P_OBJECT_CREATE)) < 0) + if ((ocpl1 = H5Pcreate(H5P_OBJECT_CREATE)) < 0) assert(ocpl1 > 0); - if((ret = encode_plist(ocpl1, little_endian, word_length, "testfiles/plist_files/def_ocpl_")) < 0) + if ((ret = encode_plist(ocpl1, little_endian, word_length, "testfiles/plist_files/def_ocpl_")) < 0) assert(ret > 0); - if((ret = H5Pset_attr_creation_order(ocpl1, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) - assert(ret > 0); + if ((ret = H5Pset_attr_creation_order(ocpl1, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + assert(ret > 0); - if((ret = H5Pset_attr_phase_change (ocpl1, 110, 105)) < 0) - assert(ret > 0); + if ((ret = H5Pset_attr_phase_change(ocpl1, 110, 105)) < 0) + assert(ret > 0); - if((ret = H5Pset_filter (ocpl1, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) + if ((ret = H5Pset_filter(ocpl1, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) assert(ret > 0); - if((ret = encode_plist(ocpl1, little_endian, word_length, "testfiles/plist_files/ocpl_")) < 0) + if ((ret = encode_plist(ocpl1, little_endian, word_length, "testfiles/plist_files/ocpl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(ocpl1)) < 0) + if ((ret = H5Pclose(ocpl1)) < 0) assert(ret > 0); /******* ENCODE/DECODE LAPLS *****/ - if((lapl1 = H5Pcreate(H5P_LINK_ACCESS)) < 0) + if ((lapl1 = H5Pcreate(H5P_LINK_ACCESS)) < 0) assert(lapl1 > 0); - if((ret = encode_plist(lapl1, little_endian, word_length, "testfiles/plist_files/def_lapl_")) < 0) + if ((ret = encode_plist(lapl1, little_endian, word_length, "testfiles/plist_files/def_lapl_")) < 0) assert(ret > 0); - if((ret = H5Pset_nlinks(lapl1, (size_t)134)) < 0) + if ((ret = H5Pset_nlinks(lapl1, (size_t)134)) < 0) assert(ret > 0); - if((ret = H5Pset_elink_acc_flags(lapl1, H5F_ACC_RDONLY)) < 0) + if ((ret = H5Pset_elink_acc_flags(lapl1, H5F_ACC_RDONLY)) < 0) assert(ret > 0); - if((ret = H5Pset_elink_prefix(lapl1, "/tmpasodiasod")) < 0) + if ((ret = H5Pset_elink_prefix(lapl1, "/tmpasodiasod")) < 0) assert(ret > 0); /* Create FAPL for the elink FAPL */ - if((fapl1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) assert(fapl1 > 0); - if((ret = H5Pset_alignment(fapl1, 2, 1024)) < 0) + if ((ret = H5Pset_alignment(fapl1, 2, 1024)) < 0) assert(ret > 0); - if((ret = H5Pset_elink_fapl(lapl1, fapl1)) < 0) + if ((ret = H5Pset_elink_fapl(lapl1, fapl1)) < 0) assert(ret > 0); /* Close the elink's FAPL */ - if((ret = H5Pclose(fapl1)) < 0) + if ((ret = H5Pclose(fapl1)) < 0) assert(ret > 0); - if((ret = encode_plist(lapl1, little_endian, word_length, "testfiles/plist_files/lapl_")) < 0) + if ((ret = encode_plist(lapl1, little_endian, word_length, "testfiles/plist_files/lapl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(lapl1)) < 0) + if ((ret = H5Pclose(lapl1)) < 0) assert(ret > 0); /******* ENCODE/DECODE FAPLS *****/ - if((fapl1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) assert(fapl1 > 0); - if((ret = encode_plist(fapl1, little_endian, word_length, "testfiles/plist_files/def_fapl_")) < 0) + if ((ret = encode_plist(fapl1, little_endian, word_length, "testfiles/plist_files/def_fapl_")) < 0) assert(ret > 0); - if((ret = H5Pset_family_offset(fapl1, 1024)) < 0) + if ((ret = H5Pset_family_offset(fapl1, 1024)) < 0) assert(ret > 0); - if((ret = H5Pset_meta_block_size(fapl1, 2098452)) < 0) + if ((ret = H5Pset_meta_block_size(fapl1, 2098452)) < 0) assert(ret > 0); - if((ret = H5Pset_sieve_buf_size(fapl1, 1048576)) < 0) + if ((ret = H5Pset_sieve_buf_size(fapl1, 1048576)) < 0) assert(ret > 0); - if((ret = H5Pset_alignment(fapl1, 2, 1024)) < 0) + if ((ret = H5Pset_alignment(fapl1, 2, 1024)) < 0) assert(ret > 0); - if((ret = H5Pset_cache(fapl1, 1024, 128, 10485760, 0.3f)) < 0) + if ((ret = H5Pset_cache(fapl1, 1024, 128, 10485760, 0.3f)) < 0) assert(ret > 0); - if((ret = H5Pset_elink_file_cache_size(fapl1, 10485760)) < 0) + if ((ret = H5Pset_elink_file_cache_size(fapl1, 10485760)) < 0) assert(ret > 0); - if((ret = H5Pset_gc_references(fapl1, 1)) < 0) + if ((ret = H5Pset_gc_references(fapl1, 1)) < 0) assert(ret > 0); - if((ret = H5Pset_small_data_block_size(fapl1, 2048)) < 0) + if ((ret = H5Pset_small_data_block_size(fapl1, 2048)) < 0) assert(ret > 0); - if((ret = H5Pset_libver_bounds(fapl1, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) + if ((ret = H5Pset_libver_bounds(fapl1, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) assert(ret > 0); - if((ret = H5Pset_fclose_degree(fapl1, H5F_CLOSE_WEAK)) < 0) + if ((ret = H5Pset_fclose_degree(fapl1, H5F_CLOSE_WEAK)) < 0) assert(ret > 0); - if((ret = H5Pset_multi_type(fapl1, H5FD_MEM_GHEAP)) < 0) + if ((ret = H5Pset_multi_type(fapl1, H5FD_MEM_GHEAP)) < 0) assert(ret > 0); - if((ret = H5Pset_mdc_config(fapl1, &my_cache_config)) < 0) + if ((ret = H5Pset_mdc_config(fapl1, &my_cache_config)) < 0) assert(ret > 0); - if((ret = H5Pset_mdc_image_config(fapl1, &my_cache_image_config)) < 0) + if ((ret = H5Pset_mdc_image_config(fapl1, &my_cache_image_config)) < 0) assert(ret > 0); - if((ret = encode_plist(fapl1, little_endian, word_length, "testfiles/plist_files/fapl_")) < 0) + if ((ret = encode_plist(fapl1, little_endian, word_length, "testfiles/plist_files/fapl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(fapl1)) < 0) + if ((ret = H5Pclose(fapl1)) < 0) assert(ret > 0); /******* ENCODE/DECODE FCPLS *****/ - if((fcpl1 = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl1 = H5Pcreate(H5P_FILE_CREATE)) < 0) assert(fcpl1 > 0); - if((ret = encode_plist(fcpl1, little_endian, word_length, "testfiles/plist_files/def_fcpl_")) < 0) + if ((ret = encode_plist(fcpl1, little_endian, word_length, "testfiles/plist_files/def_fcpl_")) < 0) assert(ret > 0); - if((ret = H5Pset_userblock(fcpl1, 1024) < 0)) - assert(ret > 0); + if ((ret = H5Pset_userblock(fcpl1, 1024) < 0)) + assert(ret > 0); - if((ret = H5Pset_istore_k(fcpl1, 3) < 0)) - assert(ret > 0); + if ((ret = H5Pset_istore_k(fcpl1, 3) < 0)) + assert(ret > 0); - if((ret = H5Pset_sym_k(fcpl1, 4, 5) < 0)) - assert(ret > 0); + if ((ret = H5Pset_sym_k(fcpl1, 4, 5) < 0)) + assert(ret > 0); - if((ret = H5Pset_shared_mesg_nindexes(fcpl1, 8) < 0)) - assert(ret > 0); + if ((ret = H5Pset_shared_mesg_nindexes(fcpl1, 8) < 0)) + assert(ret > 0); - if((ret = H5Pset_shared_mesg_index(fcpl1, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) - assert(ret > 0); + if ((ret = H5Pset_shared_mesg_index(fcpl1, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) + assert(ret > 0); - if((ret = H5Pset_shared_mesg_phase_change(fcpl1, 60, 20) < 0)) - assert(ret > 0); + if ((ret = H5Pset_shared_mesg_phase_change(fcpl1, 60, 20) < 0)) + assert(ret > 0); - if((ret = H5Pset_sizes(fcpl1, 8, 4) < 0)) - assert(ret > 0); + if ((ret = H5Pset_sizes(fcpl1, 8, 4) < 0)) + assert(ret > 0); - if((ret = H5Pset_file_space_strategy(fcpl1, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1)) < 0) - assert(ret > 0); + if ((ret = H5Pset_file_space_strategy(fcpl1, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1)) < 0) + assert(ret > 0); - if((ret = H5Pset_file_space_page_size(fcpl1, (hsize_t)4096)) < 0) - assert(ret > 0); + if ((ret = H5Pset_file_space_page_size(fcpl1, (hsize_t)4096)) < 0) + assert(ret > 0); - if((ret = encode_plist(fcpl1, little_endian, word_length, "testfiles/plist_files/fcpl_")) < 0) + if ((ret = encode_plist(fcpl1, little_endian, word_length, "testfiles/plist_files/fcpl_")) < 0) assert(ret > 0); /* release resource */ - if((ret = H5Pclose(fcpl1)) < 0) + if ((ret = H5Pclose(fcpl1)) < 0) assert(ret > 0); /******* ENCODE/DECODE STRCPLS *****/ @@ -454,25 +443,26 @@ main(void) static int encode_plist(hid_t plist_id, int little_endian, int word_length, const char *filename_prefix) { - int fd = 0; /* file descriptor */ - herr_t ret = 0; - void *temp_buf = NULL; - size_t temp_size = 0; + int fd = 0; /* file descriptor */ + herr_t ret = 0; + void * temp_buf = NULL; + size_t temp_size = 0; ssize_t H5_ATTR_NDEBUG_UNUSED write_size; - char filename[1024]; + char filename[1024]; /* Generate filename */ - if((ret = HDsnprintf(filename, sizeof(filename), "%s%d%s", filename_prefix, word_length, little_endian ? "le" : "be")) < 0) + if ((ret = HDsnprintf(filename, sizeof(filename), "%s%d%s", filename_prefix, word_length, + little_endian ? "le" : "be")) < 0) HDassert(ret > 0); /* first call to encode returns only the size of the buffer needed */ - if((ret = H5Pencode2(plist_id, NULL, &temp_size, H5P_DEFAULT)) < 0) + if ((ret = H5Pencode2(plist_id, NULL, &temp_size, H5P_DEFAULT)) < 0) HDassert(ret > 0); temp_buf = HDcalloc(1, temp_size); HDassert(temp_buf); - if((ret = H5Pencode2(plist_id, temp_buf, &temp_size, H5P_DEFAULT)) < 0) + if ((ret = H5Pencode2(plist_id, temp_buf, &temp_size, H5P_DEFAULT)) < 0) HDassert(ret > 0); fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); @@ -487,4 +477,3 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil return 1; } - diff --git a/test/gen_sizes_lheap.c b/test/gen_sizes_lheap.c index 81742df..24ad91b 100644 --- a/test/gen_sizes_lheap.c +++ b/test/gen_sizes_lheap.c @@ -23,8 +23,7 @@ #include "hdf5.h" -#define TESTFILE "tsizeslheap.h5" - +#define TESTFILE "tsizeslheap.h5" /*------------------------------------------------------------------------- * Function: main @@ -45,30 +44,30 @@ int main(void) { - hid_t file, space, dset, fcpl; + hid_t file, space, dset, fcpl; /* Create the FCPL */ fcpl = H5Pcreate(H5P_FILE_CREATE); - if(fcpl < 0) + if (fcpl < 0) printf("fcpl < 0!\n"); /* Set sizeof_addr and sizeof_size to be 4 */ - if(H5Pset_sizes(fcpl, 4, 4) < 0) + if (H5Pset_sizes(fcpl, 4, 4) < 0) printf("H5Pset_sizes < 0!\n"); /* Create the file */ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); - if(file < 0) + if (file < 0) printf("file < 0!\n"); /* Create the dataspace (for dataset) */ space = H5Screate(H5S_SCALAR); - if(space < 0) + if (space < 0) printf("space < 0!\n"); /* Create the dataset with compound array fields */ dset = H5Dcreate2(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset < 0) + if (dset < 0) printf("dset < 0!\n"); H5Dclose(dset); diff --git a/test/gen_specmetaread.c b/test/gen_specmetaread.c index f2625a7..edbedbd 100644 --- a/test/gen_specmetaread.c +++ b/test/gen_specmetaread.c @@ -23,27 +23,26 @@ * the library on the trunk as of when this file is checked in. */ - #include "h5test.h" -#define FILENAME "specmetaread.h5" -#define DIM 10 +#define FILENAME "specmetaread.h5" +#define DIM 10 int main(void) { - hid_t fid; - hid_t fapl; - hid_t did; - hid_t space; - hsize_t dim[1] = {DIM}; - unsigned data[DIM]; - unsigned u; - herr_t H5_ATTR_NDEBUG_UNUSED ret; + hid_t fid; + hid_t fapl; + hid_t did; + hid_t space; + hsize_t dim[1] = {DIM}; + unsigned data[DIM]; + unsigned u; + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Initialize the data */ - for(u = 0; u < DIM; u++) - data[u] = u; + for (u = 0; u < DIM; u++) + data[u] = u; /* Create a FAPL with the metadata and small data aggregators turned off */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -91,4 +90,3 @@ main(void) return 0; } - diff --git a/test/gen_udlinks.c b/test/gen_udlinks.c index e48d0e8..7bac453 100644 --- a/test/gen_udlinks.c +++ b/test/gen_udlinks.c @@ -25,64 +25,74 @@ #include "hdf5.h" #include -#define NAME_LE_1 "le_extlink1.h5" -#define NAME_LE_2 "le_extlink2.h5" -#define NAME_BE_1 "be_extlink1.h5" -#define NAME_BE_2 "be_extlink2.h5" +#define NAME_LE_1 "le_extlink1.h5" +#define NAME_LE_2 "le_extlink2.h5" +#define NAME_BE_1 "be_extlink1.h5" +#define NAME_BE_2 "be_extlink2.h5" #define NAME_BUF_SIZE 25 int -main (void) +main(void) { - hid_t fid1=-1; - hid_t fid2=-1; - hid_t gid=-1; - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; + hid_t fid1 = -1; + hid_t fid2 = -1; + hid_t gid = -1; + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; - /* Name the files differently depending on the endianness of this platform */ + /* Name the files differently depending on the endianness of this platform */ - switch(H5Tget_order(H5T_NATIVE_INT)) - { - case H5T_ORDER_LE: - strcpy(filename1, NAME_LE_1); - strcpy(filename2, NAME_LE_2); - break; - case H5T_ORDER_BE: - strcpy(filename1, NAME_BE_1); - strcpy(filename2, NAME_BE_2); - break; - case H5T_ORDER_ERROR: - case H5T_ORDER_VAX: - case H5T_ORDER_MIXED: - case H5T_ORDER_NONE: - default: - goto error; - } + switch (H5Tget_order(H5T_NATIVE_INT)) { + case H5T_ORDER_LE: + strcpy(filename1, NAME_LE_1); + strcpy(filename2, NAME_LE_2); + break; + case H5T_ORDER_BE: + strcpy(filename1, NAME_BE_1); + strcpy(filename2, NAME_BE_2); + break; + case H5T_ORDER_ERROR: + case H5T_ORDER_VAX: + case H5T_ORDER_MIXED: + case H5T_ORDER_NONE: + default: + goto error; + } - /* Create the two files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + /* Create the two files */ + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; - /* Create two groups in the second file */ - if((gid = H5Gcreate2(fid2, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((H5Gclose(gid)) < 0) goto error; - if((gid = H5Gcreate2(fid2, "group/subgroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((H5Gclose(gid)) < 0) goto error; + /* Create two groups in the second file */ + if ((gid = H5Gcreate2(fid2, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if ((H5Gclose(gid)) < 0) + goto error; + if ((gid = H5Gcreate2(fid2, "group/subgroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if ((H5Gclose(gid)) < 0) + goto error; - /* Create an external link in the first file pointing to the group in the second file */ - if(H5Lcreate_external(filename2, "group", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; + /* Create an external link in the first file pointing to the group in the second file */ + if (H5Lcreate_external(filename2, "group", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto error; - if((H5Fclose(fid1)) < 0) goto error; - if((H5Fclose(fid2)) < 0) goto error; + if ((H5Fclose(fid1)) < 0) + goto error; + if ((H5Fclose(fid2)) < 0) + goto error; - return 0; + return 0; error: - H5E_BEGIN_TRY { - H5Fclose(fid1); - H5Fclose(fid2); - H5Gclose(gid); - } H5E_END_TRY - return 1; + H5E_BEGIN_TRY + { + H5Fclose(fid1); + H5Fclose(fid2); + H5Gclose(gid); + } + H5E_END_TRY + return 1; } diff --git a/test/genall5.c b/test/genall5.c index cac4542..84d4f38 100644 --- a/test/genall5.c +++ b/test/genall5.c @@ -20,16 +20,15 @@ */ #include "cache_common.h" -#include "vfd_swmr_common.h" /* for below_speed_limit() */ +#include "vfd_swmr_common.h" /* for below_speed_limit() */ #include "genall5.h" -#define DSET_DIMS (1024 * 1024) -#define DSET_SMALL_DIMS (64 * 1024) -#define DSET_CHUNK_DIMS 1024 +#define DSET_DIMS (1024 * 1024) +#define DSET_SMALL_DIMS (64 * 1024) +#define DSET_CHUNK_DIMS 1024 #define DSET_COMPACT_DIMS 4096 -typedef enum phase {PHASE_CREATE, PHASE_VALIDATE, PHASE_DELETE, - PHASE_VALIDATE_DELETION} phase_t; +typedef enum phase { PHASE_CREATE, PHASE_VALIDATE, PHASE_DELETE, PHASE_VALIDATE_DELETION } phase_t; static hbool_t rm_ns_grp_0(hid_t, const char *); static hbool_t rm_ns_grp_c(hid_t, const char *, unsigned); @@ -51,10 +50,9 @@ static hbool_t missing_ds_chk_i(hid_t, const char *, hbool_t); static hbool_t missing_ds_cpt_i(hid_t, const char *, hbool_t); static hbool_t missing_ds_ctg_v(hid_t, const char *, hbool_t); -#define FN_ITEM_DEFN(__name, ...) \ - typedef bool (*__name##fn_t)(__VA_ARGS__); \ - static const __name##fn_t __name##_fntbl[] = \ - {__name, vrfy_##__name, rm_##__name, missing_##__name} +#define FN_ITEM_DEFN(__name, ...) \ + typedef bool (*__name##fn_t)(__VA_ARGS__); \ + static const __name##fn_t __name##_fntbl[] = {__name, vrfy_##__name, rm_##__name, missing_##__name} FN_ITEM_DEFN(ns_grp_0, hid_t, const char *); FN_ITEM_DEFN(ns_grp_c, hid_t, const char *, unsigned); @@ -72,14 +70,14 @@ static hbool_t file_has_no_path(hid_t fid, const char *path) { switch (H5Lexists(fid, path, H5P_DEFAULT)) { - case FALSE: - return true; - case TRUE: - failure_mssg = "H5Lexists unexpectedly true."; - return false; - default: - failure_mssg = "H5Lexists unexpectedly failed."; - return false; + case FALSE: + return true; + case TRUE: + failure_mssg = "H5Lexists unexpectedly true."; + return false; + default: + failure_mssg = "H5Lexists unexpectedly failed."; + return false; } } @@ -125,8 +123,8 @@ rm_ns_grp_0(hid_t fid, const char *group_name) hbool_t ns_grp_0(hid_t fid, const char *group_name) { - hid_t gid = -1; - hid_t gcpl = -1; + hid_t gid = -1; + hid_t gcpl = -1; herr_t ret; gcpl = H5Pcreate(H5P_GROUP_CREATE); @@ -167,7 +165,6 @@ ns_grp_0(hid_t fid, const char *group_name) return true; } - /*------------------------------------------------------------------------- * Function: vrfy_ns_grp_0 * @@ -188,11 +185,11 @@ ns_grp_0(hid_t fid, const char *group_name) hbool_t vrfy_ns_grp_0(hid_t fid, const char *group_name) { - hid_t gid = -1; - hid_t gcpl = -1; + hid_t gid = -1; + hid_t gcpl = -1; H5G_info_t grp_info; - unsigned crt_order_flags = 0; - herr_t ret; + unsigned crt_order_flags = 0; + herr_t ret; gid = H5Gopen2(fid, group_name, H5P_DEFAULT); @@ -213,9 +210,9 @@ vrfy_ns_grp_0(hid_t fid, const char *group_name) if (ret < 0) { failure_mssg = "vrfy_ns_grp_0: H5Pget_link_creation_order() failed"; return false; - } else if ( H5P_CRT_ORDER_TRACKED != crt_order_flags) { - failure_mssg = - "vrfy_ns_grp_0: H5P_CRT_ORDER_TRACKED != crt_order_flags"; + } + else if (H5P_CRT_ORDER_TRACKED != crt_order_flags) { + failure_mssg = "vrfy_ns_grp_0: H5P_CRT_ORDER_TRACKED != crt_order_flags"; return false; } @@ -232,17 +229,20 @@ vrfy_ns_grp_0(hid_t fid, const char *group_name) if (ret < 0) { failure_mssg = "vrfy_ns_grp_0: H5Gget_info() failed"; return false; - } else if (H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type) { - failure_mssg = - "vrfy_ns_grp_0: H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type"; + } + else if (H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type) { + failure_mssg = "vrfy_ns_grp_0: H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type"; return false; - } else if (0 != grp_info.nlinks) { + } + else if (0 != grp_info.nlinks) { failure_mssg = "vrfy_ns_grp_0: 0 != grp_info.nlinks"; return false; - } else if (0 != grp_info.max_corder) { + } + else if (0 != grp_info.max_corder) { failure_mssg = "vrfy_ns_grp_0: 0 != grp_info.max_corder"; return false; - } else if ( FALSE != grp_info.mounted) { + } + else if (FALSE != grp_info.mounted) { failure_mssg = "vrfy_ns_grp_0: FALSE != grp_info.mounted"; return false; } @@ -257,7 +257,6 @@ vrfy_ns_grp_0(hid_t fid, const char *group_name) return true; } /* vrfy_ns_grp_0() */ - /*------------------------------------------------------------------------- * Function: ns_grp_c * @@ -276,8 +275,7 @@ vrfy_ns_grp_0(hid_t fid, const char *group_name) */ static hbool_t -missing_ns_grp_c(hid_t fid, const char *group_name, - unsigned H5_ATTR_UNUSED nlinks) +missing_ns_grp_c(hid_t fid, const char *group_name, unsigned H5_ATTR_UNUSED nlinks) { return file_has_no_path(fid, group_name); } @@ -291,11 +289,11 @@ rm_ns_grp_c(hid_t fid, const char *group_name, unsigned H5_ATTR_UNUSED nlinks) hbool_t ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { - hid_t gid = -1; - hid_t gcpl = -1; + hid_t gid = -1; + hid_t gcpl = -1; unsigned max_compact; unsigned u; - herr_t ret; + herr_t ret; gcpl = H5Pcreate(H5P_GROUP_CREATE); @@ -319,15 +317,17 @@ ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) } max_compact = 0; - ret = H5Pget_link_phase_change(gcpl, &max_compact, NULL); + ret = H5Pget_link_phase_change(gcpl, &max_compact, NULL); if (ret < 0) { failure_mssg = "ns_grp_c: H5Pget_link_phase_change() failed"; return false; - } else if (nlinks <= 0) { + } + else if (nlinks <= 0) { failure_mssg = "ns_grp_c: nlinks <= 0"; return false; - } else if (nlinks >= max_compact) { + } + else if (nlinks >= max_compact) { failure_mssg = "ns_grp_c: nlinks >= max_compact"; return false; } @@ -338,25 +338,24 @@ ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) HDsprintf(linkname, "%u", u); if (0 == (u % 3)) { - ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, - H5P_DEFAULT); + ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { failure_mssg = "ns_grp_c: H5Lcreate_soft() failed"; return false; } - } else if (1 == (u % 3)) { - ret = H5Lcreate_hard(fid, "/", gid, linkname, H5P_DEFAULT, - H5P_DEFAULT); + } + else if (1 == (u % 3)) { + ret = H5Lcreate_hard(fid, "/", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { failure_mssg = "ns_grp_c: H5Lcreate_hard() failed"; return false; } - } else { + } + else { HDassert(2 == (u % 3)); - ret = H5Lcreate_external("external.h5", "/ext", gid, linkname, - H5P_DEFAULT, H5P_DEFAULT); + ret = H5Lcreate_external("external.h5", "/ext", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { failure_mssg = "ns_grp_c: H5Lcreate_external() failed"; @@ -383,7 +382,6 @@ ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) } /* ns_grp_c() */ - /*------------------------------------------------------------------------- * Function: vrfy_ns_grp_c * @@ -404,12 +402,12 @@ ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) hbool_t vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { - hid_t gid = -1; - hid_t gcpl = -1; + hid_t gid = -1; + hid_t gcpl = -1; H5G_info_t grp_info; - unsigned crt_order_flags = 0; - unsigned u; - herr_t ret; + unsigned crt_order_flags = 0; + unsigned u; + herr_t ret; gid = H5Gopen2(fid, group_name, H5P_DEFAULT); @@ -430,9 +428,9 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_ns_grp_c: H5Pget_link_creation_order() failed"; return false; - } else if ( H5P_CRT_ORDER_TRACKED != crt_order_flags) { - failure_mssg = - "vrfy_ns_grp_c: H5P_CRT_ORDER_TRACKED != crt_order_flags"; + } + else if (H5P_CRT_ORDER_TRACKED != crt_order_flags) { + failure_mssg = "vrfy_ns_grp_c: H5P_CRT_ORDER_TRACKED != crt_order_flags"; return false; } @@ -449,25 +447,28 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_ns_grp_c: H5Gget_info() failed"; return false; - } else if (H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type) { - failure_mssg = - "vrfy_ns_grp_c: H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type"; + } + else if (H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type) { + failure_mssg = "vrfy_ns_grp_c: H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type"; return false; - } else if (nlinks != grp_info.nlinks) { + } + else if (nlinks != grp_info.nlinks) { failure_mssg = "vrfy_ns_grp_c: nlinks != grp_info.nlinks"; return false; - } else if (nlinks != grp_info.max_corder) { + } + else if (nlinks != grp_info.max_corder) { failure_mssg = "vrfy_ns_grp_c: nlinks != grp_info.max_corder"; return false; - } else if ( FALSE != grp_info.mounted) { + } + else if (FALSE != grp_info.mounted) { failure_mssg = "vrfy_ns_grp_c: FALSE != grp_info.mounted"; return false; } for (u = 0; u < nlinks; u++) { H5L_info2_t lnk_info; - char linkname[16]; - htri_t link_exists; + char linkname[16]; + htri_t link_exists; HDsprintf(linkname, "%u", u); link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); @@ -483,13 +484,16 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_ns_grp_c: H5Lget_info() failed"; return false; - } else if ( TRUE != lnk_info.corder_valid) { + } + else if (TRUE != lnk_info.corder_valid) { failure_mssg = "vrfy_ns_grp_c: TRUE != lnk_info.corder_valid"; return false; - } else if (u != lnk_info.corder) { + } + else if (u != lnk_info.corder) { failure_mssg = "vrfy_ns_grp_c: u != lnk_info.corder"; return false; - } else if (H5T_CSET_ASCII != lnk_info.cset) { + } + else if (H5T_CSET_ASCII != lnk_info.cset) { failure_mssg = "vrfy_ns_grp_c: H5T_CSET_ASCII != lnk_info.cset"; return false; } @@ -513,22 +517,23 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) return false; } - ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, - H5P_DEFAULT); + ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, H5P_DEFAULT); if (ret < 0) { failure_mssg = "vrfy_ns_grp_c: H5Lget_val() failed"; HDfree(slinkval); return false; - } else if (0 != HDstrcmp(slinkval, group_name)) { + } + else if (0 != HDstrcmp(slinkval, group_name)) { failure_mssg = "vrfy_ns_grp_c: 0 != HDstrcmp(slinkval, group_name)"; HDfree(slinkval); return false; } HDfree(slinkval); - } else if (1 == (u % 3)) { + } + else if (1 == (u % 3)) { H5O_info2_t root_oinfo; - int token_cmp = 0; + int token_cmp = 0; if (H5L_TYPE_HARD != lnk_info.type) { failure_mssg = "vrfy_ns_grp_c: H5L_TYPE_HARD != lnk_info.type"; @@ -541,23 +546,25 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_ns_grp_c: H5Oget_info() failed."; return false; - } else if(H5Otoken_cmp(fid, &root_oinfo.token, &lnk_info.u.token, &token_cmp) < 0) { + } + else if (H5Otoken_cmp(fid, &root_oinfo.token, &lnk_info.u.token, &token_cmp) < 0) { failure_mssg = "vrfy_ns_grp_c: H5Otoken_cmp() failed."; return false; - } else if (token_cmp) { + } + else if (token_cmp) { failure_mssg = "vrfy_ns_grp_c: root_oinfo.token != lnk_info.u.token"; return false; } - } else { - void *elinkval; + } + else { + void * elinkval; const char *file = NULL; const char *path = NULL; HDassert(2 == (u % 3)); if (H5L_TYPE_EXTERNAL != lnk_info.type) { - failure_mssg = - "vrfy_ns_grp_c: H5L_TYPE_EXTERNAL != lnk_info.type"; + failure_mssg = "vrfy_ns_grp_c: H5L_TYPE_EXTERNAL != lnk_info.type"; return false; } @@ -568,25 +575,24 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) return false; } - ret = H5Lget_val(gid, linkname, elinkval, lnk_info.u.val_size, - H5P_DEFAULT); + ret = H5Lget_val(gid, linkname, elinkval, lnk_info.u.val_size, H5P_DEFAULT); if (ret < 0) { failure_mssg = "vrfy_ns_grp_c: H5Lget_val() failed."; return false; } - ret = H5Lunpack_elink_val(elinkval, lnk_info.u.val_size, NULL, - &file, &path); + ret = H5Lunpack_elink_val(elinkval, lnk_info.u.val_size, NULL, &file, &path); if (ret < 0) { failure_mssg = "vrfy_ns_grp_c: H5Lunpack_elink_val() failed."; HDfree(elinkval); return false; - } else if (0 != HDstrcmp(file, "external.h5")) { - failure_mssg = - "vrfy_ns_grp_c: 0 != HDstrcmp(file, \"external.h5\")"; + } + else if (0 != HDstrcmp(file, "external.h5")) { + failure_mssg = "vrfy_ns_grp_c: 0 != HDstrcmp(file, \"external.h5\")"; HDfree(elinkval); return false; - } else if (0 != HDstrcmp(path, "/ext")) { + } + else if (0 != HDstrcmp(path, "/ext")) { failure_mssg = "vrfy_ns_grp_c: 0 != HDstrcmp(path, \"/ext\")"; HDfree(elinkval); return false; @@ -605,7 +611,6 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) return true; } /* vrfy_ns_grp_c() */ - /*------------------------------------------------------------------------- * Function: ns_grp_d * @@ -624,8 +629,7 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) */ static hbool_t -missing_ns_grp_d(hid_t fid, const char *group_name, - unsigned H5_ATTR_UNUSED nlinks) +missing_ns_grp_d(hid_t fid, const char *group_name, unsigned H5_ATTR_UNUSED nlinks) { return file_has_no_path(fid, group_name); } @@ -639,11 +643,11 @@ rm_ns_grp_d(hid_t fid, const char *group_name, unsigned H5_ATTR_UNUSED nlinks) hbool_t ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { - hid_t gid = -1; - hid_t gcpl = -1; + hid_t gid = -1; + hid_t gcpl = -1; unsigned max_compact; unsigned u; - herr_t ret; + herr_t ret; gcpl = H5Pcreate(H5P_GROUP_CREATE); @@ -667,7 +671,7 @@ ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) } max_compact = 0; - ret = H5Pget_link_phase_change(gcpl, &max_compact, NULL); + ret = H5Pget_link_phase_change(gcpl, &max_compact, NULL); if (ret < 0) { failure_mssg = "ns_grp_d: H5Pget_link_phase_change() failed."; @@ -684,26 +688,25 @@ ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) HDsprintf(linkname, "%u", u); if (0 == (u % 3)) { - ret = H5Lcreate_soft(group_name, gid, linkname, - H5P_DEFAULT, H5P_DEFAULT); + ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { failure_mssg = "ns_grp_d: H5Lcreate_soft() failed."; return false; } - } else if (1 == (u % 3)) { - ret = H5Lcreate_hard(fid, "/", gid, linkname, - H5P_DEFAULT, H5P_DEFAULT); + } + else if (1 == (u % 3)) { + ret = H5Lcreate_hard(fid, "/", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { failure_mssg = "ns_grp_d: H5Lcreate_hard() failed."; return false; } - } else { + } + else { HDassert(2 == (u % 3)); - ret = H5Lcreate_external("external.h5", "/ext", gid, linkname, - H5P_DEFAULT, H5P_DEFAULT); + ret = H5Lcreate_external("external.h5", "/ext", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { failure_mssg = "ns_grp_d: H5Lcreate_external() failed."; @@ -729,7 +732,6 @@ ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) return true; } /* ns_grp_d() */ - /*------------------------------------------------------------------------- * Function: vrfy_ns_grp_d * @@ -747,16 +749,15 @@ ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) *------------------------------------------------------------------------- */ - hbool_t vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { - hid_t gid = -1; - hid_t gcpl = -1; + hid_t gid = -1; + hid_t gcpl = -1; H5G_info_t grp_info; - unsigned crt_order_flags = 0; - unsigned u; - herr_t ret; + unsigned crt_order_flags = 0; + unsigned u; + herr_t ret; gid = H5Gopen2(fid, group_name, H5P_DEFAULT); @@ -777,9 +778,9 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_ns_grp_d: H5Pget_link_creation_order() failed."; return false; - } else if (H5P_CRT_ORDER_TRACKED != crt_order_flags) { - failure_mssg = - "vrfy_ns_grp_d: H5P_CRT_ORDER_TRACKED != crt_order_flags"; + } + else if (H5P_CRT_ORDER_TRACKED != crt_order_flags) { + failure_mssg = "vrfy_ns_grp_d: H5P_CRT_ORDER_TRACKED != crt_order_flags"; return false; } @@ -796,24 +797,28 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_ns_grp_d: H5Gget_info() failed."; return false; - } else if (H5G_STORAGE_TYPE_DENSE != grp_info.storage_type) { + } + else if (H5G_STORAGE_TYPE_DENSE != grp_info.storage_type) { failure_mssg = "vrfy_ns_grp_d: H5G_STORAGE_TYPE_DENSE != grp_info.storage_type"; return false; - } else if (nlinks != grp_info.nlinks) { + } + else if (nlinks != grp_info.nlinks) { failure_mssg = "vrfy_ns_grp_d: nlinks != grp_info.nlinks"; return false; - } else if (nlinks != grp_info.max_corder) { + } + else if (nlinks != grp_info.max_corder) { failure_mssg = "vrfy_ns_grp_d: nlinks != grp_info.max_corder"; return false; - } else if ( FALSE != grp_info.mounted) { + } + else if (FALSE != grp_info.mounted) { failure_mssg = "vrfy_ns_grp_d: FALSE != grp_info.mounted"; return false; } for (u = 0; u < nlinks; u++) { H5L_info2_t lnk_info; - char linkname[16]; - htri_t link_exists; + char linkname[16]; + htri_t link_exists; HDsprintf(linkname, "%u", u); link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); @@ -829,13 +834,16 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_ns_grp_d: H5Lget_info() failed."; return false; - } else if (TRUE != lnk_info.corder_valid) { + } + else if (TRUE != lnk_info.corder_valid) { failure_mssg = "vrfy_ns_grp_d: TRUE != lnk_info.corder_valid"; return false; - } else if (u != lnk_info.corder) { + } + else if (u != lnk_info.corder) { failure_mssg = "vrfy_ns_grp_d: u != lnk_info.corder"; return false; - } else if (H5T_CSET_ASCII != lnk_info.cset) { + } + else if (H5T_CSET_ASCII != lnk_info.cset) { failure_mssg = "vrfy_ns_grp_d: H5T_CSET_ASCII != lnk_info.cset"; return false; } @@ -859,21 +867,22 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) return false; } - ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, - H5P_DEFAULT); + ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, H5P_DEFAULT); if (ret < 0) { failure_mssg = "vrfy_ns_grp_d: H5Lget_val() failed"; HDfree(slinkval); return false; - } else if (0 != HDstrcmp(slinkval, group_name)) { + } + else if (0 != HDstrcmp(slinkval, group_name)) { failure_mssg = "vrfy_ns_grp_d: 0 != HDstrcmp(slinkval, group_name)"; HDfree(slinkval); return false; } HDfree(slinkval); - } else if (1 == (u % 3)) { + } + else if (1 == (u % 3)) { H5O_info2_t root_oinfo; - int token_cmp = 0; + int token_cmp = 0; if (H5L_TYPE_HARD != lnk_info.type) { failure_mssg = "vrfy_ns_grp_d: H5L_TYPE_HARD != lnk_info.type"; @@ -885,23 +894,25 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_ns_grp_d: H5Oget_info() failed."; return false; - } else if(H5Otoken_cmp(fid, &root_oinfo.token, &lnk_info.u.token, &token_cmp) < 0) { + } + else if (H5Otoken_cmp(fid, &root_oinfo.token, &lnk_info.u.token, &token_cmp) < 0) { failure_mssg = "vrfy_ns_grp_d: H5Otoken_cmp() failed."; return false; - } else if (token_cmp) { + } + else if (token_cmp) { failure_mssg = "vrfy_ns_grp_d: root_oinfo.token != lnk_info.u.token"; return false; } - } else { - void *elinkval; + } + else { + void * elinkval; const char *file = NULL; const char *path = NULL; HDassert(2 == (u % 3)); if (H5L_TYPE_EXTERNAL != lnk_info.type) { - failure_mssg = - "vrfy_ns_grp_d: H5L_TYPE_EXTERNAL != lnk_info.type"; + failure_mssg = "vrfy_ns_grp_d: H5L_TYPE_EXTERNAL != lnk_info.type"; return false; } @@ -912,25 +923,24 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) return false; } - ret = H5Lget_val(gid, linkname, elinkval, lnk_info.u.val_size, - H5P_DEFAULT); + ret = H5Lget_val(gid, linkname, elinkval, lnk_info.u.val_size, H5P_DEFAULT); if (ret < 0) { failure_mssg = "vrfy_ns_grp_d: H5Lget_val failed."; return false; } - ret = H5Lunpack_elink_val(elinkval, lnk_info.u.val_size, NULL, - &file, &path); + ret = H5Lunpack_elink_val(elinkval, lnk_info.u.val_size, NULL, &file, &path); if (ret < 0) { failure_mssg = "vrfy_ns_grp_d: H5Lunpack_elink_val failed."; HDfree(elinkval); return false; - } else if (0 != HDstrcmp(file, "external.h5")) { - failure_mssg = - "vrfy_ns_grp_d: 0 != HDstrcmp(file, \"external.h5\")."; + } + else if (0 != HDstrcmp(file, "external.h5")) { + failure_mssg = "vrfy_ns_grp_d: 0 != HDstrcmp(file, \"external.h5\")."; HDfree(elinkval); return false; - } else if (0 != HDstrcmp(path, "/ext")) { + } + else if (0 != HDstrcmp(path, "/ext")) { failure_mssg = "vrfy_ns_grp_d: 0 != HDstrcmp(path, \"/ext\")"; HDfree(elinkval); return false; @@ -950,7 +960,6 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) } /* vrfy_ns_grp_d() */ - /*------------------------------------------------------------------------- * Function: os_grp_0 * @@ -982,52 +991,52 @@ rm_os_grp_0(hid_t fid, const char *group_name) hbool_t os_grp_0(hid_t fid, const char *group_name) { - hid_t gid = -1; - hid_t fapl = -1; + hid_t gid = -1; + hid_t fapl = -1; H5F_libver_t low, high; herr_t ret; /* get the file's file access property list */ fapl = H5Fget_access_plist(fid); - if ( fapl <= 0 ) { + if (fapl <= 0) { failure_mssg = "os_grp_0: H5Fget_access_plist() failed."; return false; } /* get low and high bounds from fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_0: H5Pget_libver_bounds() failed(1)."; return false; } /* turn file format latest off */ - if(low >= H5F_LIBVER_V18) { + if (low >= H5F_LIBVER_V18) { ret = H5Fset_libver_bounds(fid, H5F_LIBVER_EARLIEST, high); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; return false; } } gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( gid <= 0 ) { + if (gid <= 0) { failure_mssg = "os_grp_0: H5Gcreate2() failed."; return false; } ret = H5Gclose(gid); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_0: H5Gclose() failed."; return false; } /* restore low and high bounds */ - if(low >= H5F_LIBVER_V18) { + if (low >= H5F_LIBVER_V18) { ret = H5Fset_libver_bounds(fid, low, high); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; return false; } @@ -1036,7 +1045,6 @@ os_grp_0(hid_t fid, const char *group_name) return true; } /* os_grp_0() */ - /*------------------------------------------------------------------------- * Function: vrfy_os_grp_0 * @@ -1056,11 +1064,11 @@ os_grp_0(hid_t fid, const char *group_name) hbool_t vrfy_os_grp_0(hid_t fid, const char *group_name) { - hid_t gid = -1; - hid_t gcpl = -1; + hid_t gid = -1; + hid_t gcpl = -1; H5G_info_t grp_info; - unsigned crt_order_flags = 0; - herr_t ret; + unsigned crt_order_flags = 0; + herr_t ret; gid = H5Gopen2(fid, group_name, H5P_DEFAULT); @@ -1081,7 +1089,8 @@ vrfy_os_grp_0(hid_t fid, const char *group_name) if (ret < 0) { failure_mssg = "vrfy_os_grp_0: H5Pget_link_creation_order() failed"; return false; - } else if (0 != crt_order_flags) { + } + else if (0 != crt_order_flags) { failure_mssg = "vrfy_os_grp_0: 0 != crt_order_flags"; return false; } @@ -1099,16 +1108,20 @@ vrfy_os_grp_0(hid_t fid, const char *group_name) if (ret < 0) { failure_mssg = "vrfy_os_grp_0: H5Gget_info() failed."; return false; - } else if (H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type) { + } + else if (H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type) { failure_mssg = "vrfy_os_grp_0: H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type"; return false; - } else if (0 != grp_info.nlinks) { + } + else if (0 != grp_info.nlinks) { failure_mssg = "vrfy_os_grp_0: 0 != grp_info.nlinks"; return false; - } else if (0 != grp_info.max_corder) { + } + else if (0 != grp_info.max_corder) { failure_mssg = "vrfy_os_grp_0: 0 != grp_info.max_corder"; return false; - } else if ( FALSE != grp_info.mounted) { + } + else if (FALSE != grp_info.mounted) { failure_mssg = "vrfy_os_grp_0: FALSE != grp_info.mounted"; return false; } @@ -1123,7 +1136,6 @@ vrfy_os_grp_0(hid_t fid, const char *group_name) return true; } /* vrfy_os_grp_0() */ - /*------------------------------------------------------------------------- * Function: os_grp_n * @@ -1143,14 +1155,13 @@ vrfy_os_grp_0(hid_t fid, const char *group_name) static hbool_t missing_os_grp_n(hid_t fid, const char *group_name, int H5_ATTR_UNUSED proc_num, - unsigned H5_ATTR_UNUSED nlinks) + unsigned H5_ATTR_UNUSED nlinks) { return file_has_no_path(fid, group_name); } static hbool_t -rm_os_grp_n(hid_t fid, const char *group_name, int H5_ATTR_UNUSED proc_num, - unsigned H5_ATTR_UNUSED nlinks) +rm_os_grp_n(hid_t fid, const char *group_name, int H5_ATTR_UNUSED proc_num, unsigned H5_ATTR_UNUSED nlinks) { return remove_from_file_path(fid, group_name); } @@ -1158,37 +1169,37 @@ rm_os_grp_n(hid_t fid, const char *group_name, int H5_ATTR_UNUSED proc_num, hbool_t os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) { - hid_t gid = -1; - unsigned u; - hid_t fapl = -1; + hid_t gid = -1; + unsigned u; + hid_t fapl = -1; H5F_libver_t low, high; - herr_t ret; + herr_t ret; /* get the file's file access property list */ fapl = H5Fget_access_plist(fid); - if ( fapl <= 0 ) { + if (fapl <= 0) { failure_mssg = "os_grp_n: H5Fget_access_plist() failed."; return false; } /* get low and high bounds from fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_0: H5Pget_libver_bounds() failed(1)."; return false; } /* turn file format latest off */ - if(low >= H5F_LIBVER_V18) { + if (low >= H5F_LIBVER_V18) { ret = H5Fset_libver_bounds(fid, H5F_LIBVER_EARLIEST, high); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; return false; } } gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( gid <= 0 ) { + if (gid <= 0) { failure_mssg = "os_grp_n: H5Gcreate2() failed."; return false; } @@ -1200,17 +1211,18 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) HDsprintf(linkname, "ln%d_%u", proc_num, u); - if(0 == (u % 2)) { + if (0 == (u % 2)) { ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, H5P_DEFAULT); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_n: H5Lcreate_soft() failed."; return false; } - } else { + } + else { HDassert(1 == (u % 2)); ret = H5Lcreate_hard(fid, "/", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_n: H5Lcreate_hard() failed."; return false; } @@ -1219,15 +1231,15 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) ret = H5Gclose(gid); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_n: H5Gclose() failed."; return false; } /* restore low and high bounds */ - if(low >= H5F_LIBVER_V18) { + if (low >= H5F_LIBVER_V18) { ret = H5Fset_libver_bounds(fid, low, high); - if ( ret < 0 ) { + if (ret < 0) { failure_mssg = "os_grp_n: H5Fset_libver_bounds() failed(2)."; return false; } @@ -1236,7 +1248,6 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) return true; } /* os_grp_n() */ - /*------------------------------------------------------------------------- * Function: vrfy_os_grp_n * @@ -1256,12 +1267,12 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) hbool_t vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) { - hid_t gid = -1; - hid_t gcpl = -1; + hid_t gid = -1; + hid_t gcpl = -1; H5G_info_t grp_info; - unsigned crt_order_flags = 0; - unsigned u; - herr_t ret; + unsigned crt_order_flags = 0; + unsigned u; + herr_t ret; gid = H5Gopen2(fid, group_name, H5P_DEFAULT); @@ -1282,7 +1293,8 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_os_grp_n: H5Pget_link_creation_order"; return false; - } else if (0 != crt_order_flags) { + } + else if (0 != crt_order_flags) { failure_mssg = "vrfy_os_grp_n: 0 != crt_order_flags"; return false; } @@ -1301,24 +1313,28 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_os_grp_n: H5Gget_info() failed"; return false; - } else if (H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type) { + } + else if (H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type) { failure_mssg = "vrfy_os_grp_n: H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type"; return false; - } else if (nlinks != grp_info.nlinks) { + } + else if (nlinks != grp_info.nlinks) { failure_mssg = "vrfy_os_grp_n: nlinks != grp_info.nlinks"; return false; - } else if (0 != grp_info.max_corder) { + } + else if (0 != grp_info.max_corder) { failure_mssg = "vrfy_os_grp_n: 0 != grp_info.max_corder"; return false; - } else if ( FALSE != grp_info.mounted) { + } + else if (FALSE != grp_info.mounted) { failure_mssg = "vrfy_os_grp_n: FALSE != grp_info.mounted"; return false; } for (u = 0; u < nlinks; u++) { H5L_info2_t lnk_info; - char linkname[32]; - htri_t link_exists; + char linkname[32]; + htri_t link_exists; HDsprintf(linkname, "ln%d_%u", proc_num, u); link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); @@ -1336,7 +1352,7 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) failure_mssg = "vrfy_os_grp_n: H5Lget_info() failed"; return false; } - else if ( FALSE != lnk_info.corder_valid) { + else if (FALSE != lnk_info.corder_valid) { failure_mssg = "vrfy_os_grp_n: FALSE != lnk_info.corder_valid"; return false; } @@ -1351,7 +1367,8 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) if (H5L_TYPE_SOFT != lnk_info.type) { failure_mssg = "vrfy_os_grp_n: H5L_TYPE_SOFT != lnk_info.type"; return false; - } else if ((HDstrlen(group_name) + 1) != lnk_info.u.val_size) { + } + else if ((HDstrlen(group_name) + 1) != lnk_info.u.val_size) { failure_mssg = "vrfy_os_grp_n: (HDstrlen(group_name) + 1) != lnk_info.u.val_size"; return false; } @@ -1363,22 +1380,23 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) return false; } - ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, - H5P_DEFAULT); + ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, H5P_DEFAULT); if (ret < 0) { failure_mssg = "vrfy_os_grp_n: H5Lget_val() failed"; HDfree(slinkval); return false; - } else if (0 != HDstrcmp(slinkval, group_name)) { + } + else if (0 != HDstrcmp(slinkval, group_name)) { failure_mssg = "vrfy_os_grp_n: 0 != HDstrcmp(slinkval, group_name)"; HDfree(slinkval); return false; } HDfree(slinkval); - } else { + } + else { H5O_info2_t root_oinfo; - int token_cmp = 0; + int token_cmp = 0; HDassert(1 == (u % 2)); @@ -1393,10 +1411,12 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) if (ret < 0) { failure_mssg = "vrfy_os_grp_n: H5Oget_info() failed."; return false; - } else if(H5Otoken_cmp(fid, &root_oinfo.token, &lnk_info.u.token, &token_cmp) < 0) { + } + else if (H5Otoken_cmp(fid, &root_oinfo.token, &lnk_info.u.token, &token_cmp) < 0) { failure_mssg = "vrfy_os_grp_n: H5Otoken_cmp() failed."; return false; - } else if (token_cmp) { + } + else if (token_cmp) { failure_mssg = "vrfy_os_grp_n: root_oinfo.token != lnk_info.u.token"; return false; } @@ -1413,7 +1433,6 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) return true; } /* vrfy_os_grp_n() */ - /*------------------------------------------------------------------------- * Function: ds_ctg_i * @@ -1432,8 +1451,7 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) *------------------------------------------------------------------------- */ static hbool_t -missing_ds_ctg_i(hid_t fid, const char *dset_name, - hbool_t H5_ATTR_UNUSED write_data) +missing_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t H5_ATTR_UNUSED write_data) { return file_has_no_path(fid, dset_name); } @@ -1447,12 +1465,12 @@ rm_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t H5_ATTR_UNUSED write_data) hbool_t ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) { - int *wdata = NULL; + int * wdata = NULL; unsigned u; - hid_t dsid = -1; - hid_t sid = -1; - hsize_t dims[1] = { DSET_DIMS }; - herr_t ret; + hid_t dsid = -1; + hid_t sid = -1; + hsize_t dims[1] = {DSET_DIMS}; + herr_t ret; sid = H5Screate_simple(1, dims, NULL); @@ -1461,8 +1479,7 @@ ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) return false; } - dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (dsid <= 0) { failure_mssg = "ds_ctg_i: H5Dcreate2() failed"; @@ -1485,10 +1502,9 @@ ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) } for (u = 0; u < DSET_DIMS; u++) - wdata[u] = (int) u; + wdata[u] = (int)u; - ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - wdata); + ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDfree(wdata); @@ -1508,7 +1524,6 @@ ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) return true; } /* ds_ctg_i */ - /*------------------------------------------------------------------------- * Function: vrfy_ds_ctg_i * @@ -1528,18 +1543,18 @@ ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) hbool_t vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) { - int *rdata = NULL; - unsigned u; - hid_t dsid = -1; - hid_t sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; + int * rdata = NULL; + unsigned u; + hid_t dsid = -1; + hid_t sid = -1; + hid_t tid = -1; + hid_t dcpl = -1; H5D_space_status_t allocation; - H5D_layout_t layout; - int ndims; - hsize_t dims[1], max_dims[1]; - htri_t type_equal; - herr_t ret; + H5D_layout_t layout; + int ndims; + hsize_t dims[1], max_dims[1]; + htri_t type_equal; + herr_t ret; dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); @@ -1567,10 +1582,12 @@ vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_ctg_i: H5Sget_simple_extent_dims() failed"; return false; - } else if ( DSET_DIMS != dims[0]) { + } + else if (DSET_DIMS != dims[0]) { failure_mssg = "vrfy_ds_ctg_i: DSET_DIMS != dims[0]"; return false; - } else if ( DSET_DIMS != max_dims[0]) { + } + else if (DSET_DIMS != max_dims[0]) { failure_mssg = "vrfy_ds_ctg_i: DSET_DIMS != max_dims[0]"; return false; } @@ -1608,13 +1625,15 @@ vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_ctg_i: H5Dget_space_status() failed."; return false; - } else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { + } + else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { failure_mssg = "vrfy_ds_ctg_i: " - "write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; + "write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; return false; - } else if (!write_data && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { + } + else if (!write_data && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { failure_mssg = "vrfy_ds_ctg_i: " - "!write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; + "!write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; return false; } @@ -1647,15 +1666,14 @@ vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) return false; } - ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - rdata); + ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); if (ret < 0) { failure_mssg = "vrfy_ds_ctg_i: H5Dread() failed."; return false; } for (u = 0; u < DSET_DIMS; u++) { - if ((int) u != rdata[u]) { + if ((int)u != rdata[u]) { failure_mssg = "vrfy_ds_ctg_i: u != rdata[u]."; HDfree(rdata); return false; @@ -1675,7 +1693,6 @@ vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) } /* vrfy_ds_ctg_i() */ - /*------------------------------------------------------------------------- * Function: ds_chk_i * @@ -1694,8 +1711,7 @@ vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) *------------------------------------------------------------------------- */ static hbool_t -missing_ds_chk_i(hid_t fid, const char *dset_name, - hbool_t H5_ATTR_UNUSED write_data) +missing_ds_chk_i(hid_t fid, const char *dset_name, hbool_t H5_ATTR_UNUSED write_data) { return file_has_no_path(fid, dset_name); } @@ -1709,14 +1725,14 @@ rm_ds_chk_i(hid_t fid, const char *dset_name, hbool_t H5_ATTR_UNUSED write_data) hbool_t ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) { - int *wdata = NULL; + int * wdata = NULL; unsigned u; - hid_t dsid = -1; - hid_t dcpl = -1; - hid_t sid = -1; - hsize_t dims[1] = { DSET_DIMS }; - hsize_t chunk_dims[1] = { DSET_CHUNK_DIMS }; - herr_t ret; + hid_t dsid = -1; + hid_t dcpl = -1; + hid_t sid = -1; + hsize_t dims[1] = {DSET_DIMS}; + hsize_t chunk_dims[1] = {DSET_CHUNK_DIMS}; + herr_t ret; sid = H5Screate_simple(1, dims, NULL); @@ -1739,8 +1755,7 @@ ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) return false; } - dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, - H5P_DEFAULT); + dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); if (dsid <= 0) { failure_mssg = "ds_chk_i: H5Dcreate2() failed"; @@ -1770,10 +1785,9 @@ ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) } for (u = 0; u < DSET_DIMS; u++) - wdata[u] = (int) u; + wdata[u] = (int)u; - ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - wdata); + ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDfree(wdata); if (ret < 0) { failure_mssg = "ds_chk_i: H5Dwrite() failed."; @@ -1791,7 +1805,6 @@ ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) return true; } /* ds_chk_i */ - /*------------------------------------------------------------------------- * Function: vrfy_ds_chk_i * @@ -1811,18 +1824,18 @@ ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) hbool_t vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) { - int *rdata = NULL; - unsigned u; - hid_t dsid = -1; - hid_t sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; + int * rdata = NULL; + unsigned u; + hid_t dsid = -1; + hid_t sid = -1; + hid_t tid = -1; + hid_t dcpl = -1; H5D_space_status_t allocation; - H5D_layout_t layout; - int ndims; - hsize_t dims[1], max_dims[1], chunk_dims[1]; - htri_t type_equal; - herr_t ret; + H5D_layout_t layout; + int ndims; + hsize_t dims[1], max_dims[1], chunk_dims[1]; + htri_t type_equal; + herr_t ret; dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); @@ -1850,10 +1863,12 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_chk_i: H5Sget_simple_extent_dims() failed"; return false; - } else if ( DSET_DIMS != dims[0]) { + } + else if (DSET_DIMS != dims[0]) { failure_mssg = "vrfy_ds_chk_i: DSET_DIMS != dims[0]"; return false; - } else if ( DSET_DIMS != max_dims[0]) { + } + else if (DSET_DIMS != max_dims[0]) { failure_mssg = "vrfy_ds_chk_i: DSET_DIMS != max_dims[0]"; return false; } @@ -1891,10 +1906,12 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_chk_i: H5Dget_space_status() failed."; return false; - } else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { + } + else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { failure_mssg = "vrfy_ds_chk_i: write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; return false; - } else if (!write_data && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { + } + else if (!write_data && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { failure_mssg = "vrfy_ds_chk_i: !write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; return false; } @@ -1918,7 +1935,8 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_chk_i: H5Pget_chunk"; return false; - } else if ( DSET_CHUNK_DIMS != chunk_dims[0]) { + } + else if (DSET_CHUNK_DIMS != chunk_dims[0]) { failure_mssg = "vrfy_ds_chk_i: "; return false; } @@ -1938,15 +1956,14 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) return false; } - ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - rdata); + ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); if (ret < 0) { failure_mssg = "vrfy_ds_chk_i: H5Dread() failed."; return false; } for (u = 0; u < DSET_DIMS; u++) { - if ((int) u != rdata[u]) { + if ((int)u != rdata[u]) { failure_mssg = "vrfy_ds_chk_i: u != rdata[u]"; HDfree(rdata); return false; @@ -1965,7 +1982,6 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) return true; } /* vrfy_ds_chk_i() */ - /*------------------------------------------------------------------------- * Function: ds_cpt_i * @@ -1984,8 +2000,7 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) *------------------------------------------------------------------------- */ static hbool_t -missing_ds_cpt_i(hid_t fid, const char *dset_name, - hbool_t H5_ATTR_UNUSED write_data) +missing_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t H5_ATTR_UNUSED write_data) { return file_has_no_path(fid, dset_name); } @@ -1999,13 +2014,13 @@ rm_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t H5_ATTR_UNUSED write_data) hbool_t ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) { - int *wdata = NULL; + int * wdata = NULL; unsigned u; - hid_t dsid = -1; - hid_t dcpl = -1; - hid_t sid = -1; - hsize_t dims[1] = { DSET_COMPACT_DIMS }; - herr_t ret; + hid_t dsid = -1; + hid_t dcpl = -1; + hid_t sid = -1; + hsize_t dims[1] = {DSET_COMPACT_DIMS}; + herr_t ret; sid = H5Screate_simple(1, dims, NULL); @@ -2028,8 +2043,7 @@ ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) return false; } - dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, - H5P_DEFAULT); + dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); if (dsid <= 0) { failure_mssg = "ds_cpt_i: H5Dcreate2() failed."; @@ -2059,10 +2073,9 @@ ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) } for (u = 0; u < DSET_COMPACT_DIMS; u++) - wdata[u] = (int) u; + wdata[u] = (int)u; - ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - wdata); + ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDfree(wdata); if (ret < 0) { @@ -2082,7 +2095,6 @@ ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) } /* ds_cpt_i() */ - /*------------------------------------------------------------------------- * Function: vrfy_ds_cpt_i * @@ -2102,18 +2114,18 @@ ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) hbool_t vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) { - int *rdata = NULL; - unsigned u; - hid_t dsid = -1; - hid_t sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; + int * rdata = NULL; + unsigned u; + hid_t dsid = -1; + hid_t sid = -1; + hid_t tid = -1; + hid_t dcpl = -1; H5D_space_status_t allocation; - H5D_layout_t layout; - int ndims; - hsize_t dims[1], max_dims[1]; - htri_t type_equal; - herr_t ret; + H5D_layout_t layout; + int ndims; + hsize_t dims[1], max_dims[1]; + htri_t type_equal; + herr_t ret; dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); @@ -2141,10 +2153,12 @@ vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_cpt_i: H5Sget_simple_extent_dims() failed"; return false; - } else if ( DSET_COMPACT_DIMS != dims[0]) { + } + else if (DSET_COMPACT_DIMS != dims[0]) { failure_mssg = "vrfy_ds_cpt_i: DSET_COMPACT_DIMS != dims[0]"; return false; - } else if ( DSET_COMPACT_DIMS != max_dims[0]) { + } + else if (DSET_COMPACT_DIMS != max_dims[0]) { failure_mssg = "vrfy_ds_cpt_i: DSET_COMPACT_DIMS != max_dims[0]"; return false; } @@ -2182,9 +2196,9 @@ vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_cpt_i: H5Dget_space_status() failed."; return false; - } else if (H5D_SPACE_STATUS_ALLOCATED != allocation) { - failure_mssg = - "vrfy_ds_cpt_i: H5D_SPACE_STATUS_ALLOCATED != allocation"; + } + else if (H5D_SPACE_STATUS_ALLOCATED != allocation) { + failure_mssg = "vrfy_ds_cpt_i: H5D_SPACE_STATUS_ALLOCATED != allocation"; return false; } @@ -2217,15 +2231,14 @@ vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) return false; } - ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - rdata); + ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); if (ret < 0) { failure_mssg = "vrfy_ds_cpt_i: H5Dread() failed."; return false; } for (u = 0; u < DSET_COMPACT_DIMS; u++) { - if ((int) u != rdata[u]) { + if ((int)u != rdata[u]) { failure_mssg = "vrfy_ds_cpt_i: (int)u != rdata[u]"; HDfree(rdata); return false; @@ -2244,7 +2257,6 @@ vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) return true; } /* vrfy_ds_cpt_i() */ - /*------------------------------------------------------------------------- * Function: ds_ctg_v * @@ -2263,8 +2275,7 @@ vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) *------------------------------------------------------------------------- */ static hbool_t -missing_ds_ctg_v(hid_t fid, const char *dset_name, - hbool_t H5_ATTR_UNUSED write_data) +missing_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t H5_ATTR_UNUSED write_data) { return file_has_no_path(fid, dset_name); } @@ -2278,12 +2289,12 @@ rm_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t H5_ATTR_UNUSED write_data) hbool_t ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { - hid_t dsid = -1; - hid_t sid = -1; - hid_t tid = -1; - hsize_t dims[1] = { DSET_SMALL_DIMS }; - herr_t ret; - hvl_t *wdata = NULL; + hid_t dsid = -1; + hid_t sid = -1; + hid_t tid = -1; + hsize_t dims[1] = {DSET_SMALL_DIMS}; + herr_t ret; + hvl_t * wdata = NULL; unsigned u; sid = H5Screate_simple(1, dims, NULL); @@ -2300,8 +2311,7 @@ ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) return false; } - dsid = H5Dcreate2(fid, dset_name, tid, sid, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dsid = H5Dcreate2(fid, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (dsid <= 0) { failure_mssg = "ds_ctg_v: H5Dcreate2() failed."; @@ -2317,11 +2327,11 @@ ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) } for (u = 0; u < DSET_SMALL_DIMS; u++) { - int *tdata; + int * tdata; unsigned len; unsigned v; - len = (u % 10) + 1; + len = (u % 10) + 1; tdata = HDmalloc(sizeof(int) * len); if (!tdata) { @@ -2333,10 +2343,10 @@ ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) } for (v = 0; v < len; v++) - tdata[v] = (int) (u + v); + tdata[v] = (int)(u + v); wdata[u].len = len; - wdata[u].p = tdata; + wdata[u].p = tdata; } ret = H5Dwrite(dsid, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); @@ -2383,7 +2393,6 @@ ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) return true; } /* ds_ctg_v() */ - /*------------------------------------------------------------------------- * Function: vrfy_ds_ctg_v * @@ -2403,19 +2412,19 @@ ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) hbool_t vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { - hid_t dsid = -1; - hid_t sid = -1; - hid_t tid = -1; - hid_t tmp_tid = -1; - hid_t dcpl = -1; + hid_t dsid = -1; + hid_t sid = -1; + hid_t tid = -1; + hid_t tmp_tid = -1; + hid_t dcpl = -1; H5D_space_status_t allocation; - H5D_layout_t layout; - int ndims; - hsize_t dims[1], max_dims[1]; - htri_t type_equal; - hvl_t *rdata = NULL; - unsigned u; - herr_t ret; + H5D_layout_t layout; + int ndims; + hsize_t dims[1], max_dims[1]; + htri_t type_equal; + hvl_t * rdata = NULL; + unsigned u; + herr_t ret; dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); @@ -2443,10 +2452,12 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_ctg_v: H5Sget_simple_extent_dims() failed."; return false; - } else if ( DSET_SMALL_DIMS != dims[0]) { + } + else if (DSET_SMALL_DIMS != dims[0]) { failure_mssg = "vrfy_ds_ctg_v: DSET_SMALL_DIMS != dims[0]"; return false; - } else if ( DSET_SMALL_DIMS != max_dims[0]) { + } + else if (DSET_SMALL_DIMS != max_dims[0]) { failure_mssg = "vrfy_ds_ctg_v: DSET_SMALL_DIMS != max_dims[0]"; return false; } @@ -2484,14 +2495,13 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) if (ret < 0) { failure_mssg = "vrfy_ds_ctg_v: H5Dget_space_status() failed"; return false; - } else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { - failure_mssg = - "vrfy_ds_ctg_v: write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; + } + else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { + failure_mssg = "vrfy_ds_ctg_v: write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; return false; - } else if (!write_data - && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { - failure_mssg = - "vrfy_ds_ctg_v: !write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; + } + else if (!write_data && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { + failure_mssg = "vrfy_ds_ctg_v: !write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; return false; } @@ -2535,14 +2545,15 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) unsigned len; unsigned v; - len = (unsigned) rdata[u].len; + len = (unsigned)rdata[u].len; for (v = 0; v < len; v++) { - int *tdata = (int *) rdata[u].p; + int *tdata = (int *)rdata[u].p; if (!tdata) { failure_mssg = "vrfy_ds_ctg_v: !tdata"; return false; - } else if ((int) (u + v) != tdata[v]) { + } + else if ((int)(u + v) != tdata[v]) { failure_mssg = "vrfy_ds_ctg_v: (int)(u + v) != tdata[v]"; return false; } @@ -2597,89 +2608,88 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) * * The program may also fail an assert()ion if the selected objects cannot * be created/validated. - * + * * Return `true` if the selector was valid, `false` if it was not. */ static hbool_t -create_or_validate_selection(hid_t fid, const char *full_path, - int selector, zoo_config_t config, phase_t phase, bool *okp) +create_or_validate_selection(hid_t fid, const char *full_path, int selector, zoo_config_t config, + phase_t phase, bool *okp) { bool ok; switch (selector) { - case 0: /* Add & verify an empty "new style" group */ - ok = ns_grp_0_fntbl[phase](fid, full_path); - break; - case 1: /* Add & verify a compact "new style" group (3 link messages) */ - ok = ns_grp_c_fntbl[phase](fid, full_path, 3); - break; - case 2: - /* Add & verify a dense "new style" group (w/300 links, - * in v2 B-tree & fractal heap) - */ - ok = ns_grp_d_fntbl[phase](fid, full_path, 300); - break; - case 3: /* Add & verify an empty "old style" group to file */ - ok = os_grp_0_fntbl[phase](fid, full_path); - break; - case 4: - /* Add & verify an "old style" group (w/300 links, in - * v1 B-tree & local heap) to file - */ - ok = os_grp_n_fntbl[phase](fid, full_path, config.proc_num, 300); - break; - case 5: - /* Add & verify a contiguous dataset w/integer datatype (but no data) - * to file - */ - ok = ds_ctg_i_fntbl[phase](fid, full_path, false); - break; - case 6: - /* Add & verify a contiguous dataset w/integer datatype (with data) - * to file - */ - ok = ds_ctg_i_fntbl[phase](fid, full_path, true); - break; - case 7: - /* Add & verify a chunked dataset w/integer datatype (but no data) - * to file - */ - ok = ds_chk_i_fntbl[phase](fid, full_path, false); - break; - case 8: - /* Add & verify a chunked dataset w/integer datatype (and data) - * to file - */ - ok = ds_chk_i_fntbl[phase](fid, full_path, true); - break; - case 9: - /* Add & verify a compact dataset w/integer datatype (but no data) - * to file - */ - ok = config.skip_compact || - ds_cpt_i_fntbl[phase](fid, full_path, false); - break; - case 10: - /* Add & verify a compact dataset w/integer datatype (and data) - * to file - */ - ok = config.skip_compact || ds_cpt_i_fntbl[phase](fid, full_path, true); - break; - case 11: - /* Add & verify a contiguous dataset w/variable-length datatype - * (but no data) to file - */ - ok = config.skip_varlen || ds_ctg_v_fntbl[phase](fid, full_path, false); - break; - case 12: - /* Add & verify a contiguous dataset w/variable-length datatype - * (and data) to file - */ - ok = config.skip_varlen || ds_ctg_v_fntbl[phase](fid, full_path, true); - break; - default: - return false; + case 0: /* Add & verify an empty "new style" group */ + ok = ns_grp_0_fntbl[phase](fid, full_path); + break; + case 1: /* Add & verify a compact "new style" group (3 link messages) */ + ok = ns_grp_c_fntbl[phase](fid, full_path, 3); + break; + case 2: + /* Add & verify a dense "new style" group (w/300 links, + * in v2 B-tree & fractal heap) + */ + ok = ns_grp_d_fntbl[phase](fid, full_path, 300); + break; + case 3: /* Add & verify an empty "old style" group to file */ + ok = os_grp_0_fntbl[phase](fid, full_path); + break; + case 4: + /* Add & verify an "old style" group (w/300 links, in + * v1 B-tree & local heap) to file + */ + ok = os_grp_n_fntbl[phase](fid, full_path, config.proc_num, 300); + break; + case 5: + /* Add & verify a contiguous dataset w/integer datatype (but no data) + * to file + */ + ok = ds_ctg_i_fntbl[phase](fid, full_path, false); + break; + case 6: + /* Add & verify a contiguous dataset w/integer datatype (with data) + * to file + */ + ok = ds_ctg_i_fntbl[phase](fid, full_path, true); + break; + case 7: + /* Add & verify a chunked dataset w/integer datatype (but no data) + * to file + */ + ok = ds_chk_i_fntbl[phase](fid, full_path, false); + break; + case 8: + /* Add & verify a chunked dataset w/integer datatype (and data) + * to file + */ + ok = ds_chk_i_fntbl[phase](fid, full_path, true); + break; + case 9: + /* Add & verify a compact dataset w/integer datatype (but no data) + * to file + */ + ok = config.skip_compact || ds_cpt_i_fntbl[phase](fid, full_path, false); + break; + case 10: + /* Add & verify a compact dataset w/integer datatype (and data) + * to file + */ + ok = config.skip_compact || ds_cpt_i_fntbl[phase](fid, full_path, true); + break; + case 11: + /* Add & verify a contiguous dataset w/variable-length datatype + * (but no data) to file + */ + ok = config.skip_varlen || ds_ctg_v_fntbl[phase](fid, full_path, false); + break; + case 12: + /* Add & verify a contiguous dataset w/variable-length datatype + * (and data) to file + */ + ok = config.skip_varlen || ds_ctg_v_fntbl[phase](fid, full_path, true); + break; + default: + return false; } *okp = ok; return true; @@ -2696,7 +2706,7 @@ random_pause(unsigned int max_pause_msecs) return; nsecs_per_msec = 1 + (uint64_t)HDrandom() % (1000 * 1000); - nsecs = max_pause_msecs * nsecs_per_msec; + nsecs = max_pause_msecs * nsecs_per_msec; H5_nanosleep(nsecs); } @@ -2710,13 +2720,13 @@ random_pause(unsigned int max_pause_msecs) */ static hbool_t -tend_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, - zoo_config_t config, const phase_t *phase, size_t nphases) +tend_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, zoo_config_t config, + const phase_t *phase, size_t nphases) { - char full_path[1024]; - int i, nwritten; - size_t j; - char *leafp; + char full_path[1024]; + int i, nwritten; + size_t j; + char * leafp; hbool_t ok = TRUE; nwritten = HDsnprintf(full_path, sizeof(full_path), "%s/*", base_path); @@ -2734,8 +2744,7 @@ tend_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, HDassert('A' + i <= 'Z'); *leafp = (char)('A' + i); for (j = 0; j < nphases; j++) { - if (!create_or_validate_selection(fid, full_path, i, config, - phase[j], &ok)) + if (!create_or_validate_selection(fid, full_path, i, config, phase[j], &ok)) goto out; if (phase[j] == PHASE_CREATE || phase[j] == PHASE_DELETE) zoo_create_hook(fid); @@ -2777,8 +2786,7 @@ out: */ hbool_t -create_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, - zoo_config_t config) +create_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, zoo_config_t config) { const phase_t phase[] = {PHASE_CREATE, PHASE_VALIDATE}; @@ -2805,8 +2813,7 @@ create_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, */ hbool_t -validate_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, - zoo_config_t config) +validate_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, zoo_config_t config) { const phase_t phase[] = {PHASE_VALIDATE}; @@ -2814,8 +2821,7 @@ validate_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, } hbool_t -delete_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, - zoo_config_t config) +delete_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, zoo_config_t config) { const phase_t phase[] = {PHASE_DELETE}; @@ -2823,11 +2829,9 @@ delete_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, } hbool_t -validate_deleted_zoo(hid_t fid, const char *base_path, - struct timespec *lastmsgtime, zoo_config_t config) +validate_deleted_zoo(hid_t fid, const char *base_path, struct timespec *lastmsgtime, zoo_config_t config) { const phase_t phase[] = {PHASE_VALIDATE_DELETION}; return tend_zoo(fid, base_path, lastmsgtime, config, phase, NELMTS(phase)); } - diff --git a/test/genall5.h b/test/genall5.h index 2c37b50..3b62be8 100644 --- a/test/genall5.h +++ b/test/genall5.h @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* +/* * This file contains declarations of all functions defined in genall5.c */ @@ -19,14 +19,14 @@ #define GENALL5_H typedef struct _zoo_config { - int proc_num; - bool continue_on_failure; - bool skip_compact; - bool skip_varlen; - unsigned max_pause_msecs; - struct timespec msgival; /* minimum interval between warning-message - * repetitions - */ + int proc_num; + bool continue_on_failure; + bool skip_compact; + bool skip_varlen; + unsigned max_pause_msecs; + struct timespec msgival; /* minimum interval between warning-message + * repetitions + */ } zoo_config_t; /**************/ @@ -39,8 +39,7 @@ extern "C" { H5TEST_DLL hbool_t create_zoo(hid_t, const char *, struct timespec *, zoo_config_t); H5TEST_DLL hbool_t validate_zoo(hid_t, const char *, struct timespec *, zoo_config_t); H5TEST_DLL hbool_t delete_zoo(hid_t, const char *, struct timespec *, zoo_config_t); -H5TEST_DLL hbool_t validate_deleted_zoo(hid_t, const char *, struct timespec *, - zoo_config_t); +H5TEST_DLL hbool_t validate_deleted_zoo(hid_t, const char *, struct timespec *, zoo_config_t); H5TEST_DLL hbool_t ns_grp_0(hid_t fid, const char *group_name); H5TEST_DLL hbool_t vrfy_ns_grp_0(hid_t fid, const char *group_name); @@ -55,8 +54,7 @@ H5TEST_DLL hbool_t os_grp_0(hid_t fid, const char *group_name); H5TEST_DLL hbool_t vrfy_os_grp_0(hid_t fid, const char *group_name); H5TEST_DLL hbool_t os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks); -H5TEST_DLL hbool_t vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, - unsigned nlinks); +H5TEST_DLL hbool_t vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks); H5TEST_DLL hbool_t ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data); H5TEST_DLL hbool_t vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data); diff --git a/test/getname.c b/test/getname.c index a6f2f5a..756d108 100644 --- a/test/getname.c +++ b/test/getname.c @@ -18,39 +18,32 @@ * Purpose: Tests the "ID to name" functionality */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#define H5I_FRIEND /*suppress error about including H5Ipkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5I_FRIEND /*suppress error about including H5Ipkg */ /* Define these macros to indicate that the testing APIs should be available */ #define H5G_TESTING #define H5I_TESTING #include "h5test.h" -#include "H5Gpkg.h" /* Groups */ -#include "H5Ipkg.h" /* IDs */ - +#include "H5Gpkg.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ /* Compound datatype */ typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; -const char *FILENAME[] = { - "getname", - "getname1", - "getname2", - "getname3", - NULL -}; +const char *FILENAME[] = {"getname", "getname1", "getname2", "getname3", NULL}; -#define NAME_BUF_SIZE 64 -#define SMALL_NAME_BUF_SIZE 2 +#define NAME_BUF_SIZE 64 +#define SMALL_NAME_BUF_SIZE 2 /* Object reference macros */ -#define SPACE1_RANK 1 -#define SPACE1_DIM1 8 +#define SPACE1_RANK 1 +#define SPACE1_DIM1 8 /* Dataset region reference macros */ #define REFREG_DSETNAMEV "MATRIX" @@ -59,27 +52,32 @@ const char *FILENAME[] = { static int check_name(hid_t id, const char *chk_name, const char *chk_user_path) { - char name[NAME_BUF_SIZE]; /* Buffer to hold name and its size */ - char user_path[NAME_BUF_SIZE]; /* Buffer to hold user path */ - size_t user_path_len; /* Length of user path */ - unsigned user_path_hidden; /* Whether the user path is hidden */ + char name[NAME_BUF_SIZE]; /* Buffer to hold name and its size */ + char user_path[NAME_BUF_SIZE]; /* Buffer to hold user path */ + size_t user_path_len; /* Length of user path */ + unsigned user_path_hidden; /* Whether the user path is hidden */ /* Get name */ *name = '\0'; - if(H5Iget_name(id, name, NAME_BUF_SIZE) < 0) TEST_ERROR + if (H5Iget_name(id, name, NAME_BUF_SIZE) < 0) + TEST_ERROR /* Get user path */ *user_path = '\0'; - if(H5G__user_path_test(id, user_path, &user_path_len, &user_path_hidden) < 0) TEST_ERROR + if (H5G__user_path_test(id, user_path, &user_path_len, &user_path_hidden) < 0) + TEST_ERROR /* Check on name from H5Iget_name() */ - if(HDstrcmp(name, chk_name)) goto error; + if (HDstrcmp(name, chk_name)) + goto error; /* Check on user path */ - if(HDstrcmp(user_path, chk_user_path)) goto error; + if (HDstrcmp(user_path, chk_user_path)) + goto error; /* Check that if user path is hidden, the name from H5Iget_name() and the user path should be different */ - if(user_path_hidden && !HDstrcmp(chk_name, chk_user_path)) TEST_ERROR + if (user_path_hidden && !HDstrcmp(chk_name, chk_user_path)) + TEST_ERROR /* Everything matches */ return 0; @@ -92,20 +90,20 @@ error: static int test_main(hid_t file_id, hid_t fapl) { - char filename1[1024]; - char filename2[1024]; - char filename3[1024]; - hid_t file1_id, file2_id, file3_id; - hid_t group_id, group2_id, group3_id, group4_id, group5_id, group6_id, group7_id; - hid_t dataset_id, dataset2_id; - hid_t space_id; - hid_t type_id, type2_id; - hsize_t dims[1] = { 5 }; - size_t name_len; /* Name length */ - H5O_info2_t oinfo; /* Object info structs */ - hid_t dtype; /* Object identifier for testing */ - hid_t dtype_anon; /* Object identifier for testing anonymous */ - ssize_t size; /* Size returned by H5Iget_name */ + char filename1[1024]; + char filename2[1024]; + char filename3[1024]; + hid_t file1_id, file2_id, file3_id; + hid_t group_id, group2_id, group3_id, group4_id, group5_id, group6_id, group7_id; + hid_t dataset_id, dataset2_id; + hid_t space_id; + hid_t type_id, type2_id; + hsize_t dims[1] = {5}; + size_t name_len; /* Name length */ + H5O_info2_t oinfo; /* Object info structs */ + hid_t dtype; /* Object identifier for testing */ + hid_t dtype_anon; /* Object identifier for testing anonymous */ + ssize_t size; /* Size returned by H5Iget_name */ /* Initialize the file names */ h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1); @@ -113,42 +111,46 @@ test_main(hid_t file_id, hid_t fapl) h5_fixname(FILENAME[3], fapl, filename3, sizeof filename3); /*------------------------------------------------------------------------- - * Test H5Iget_name with one group - *------------------------------------------------------------------------- - */ + * Test H5Iget_name with one group + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with one group"); /* Create group "g0" in the root group using absolute name */ - if((group_id = H5Gcreate2(file_id, "/g0", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g0", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g0", "/g0") < 0) TEST_ERROR + if (check_name(group_id, "/g0", "/g0") < 0) + TEST_ERROR /* Close */ H5Gclose(group_id); PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with more than one group - *------------------------------------------------------------------------- - */ + * Test H5Iget_name with more than one group + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with more than one group"); /* Create group "g1" in the root group using absolute name */ - if((group_id = H5Gcreate2(file_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create group "g2" in group "g1" using absolute name */ - if((group2_id = H5Gcreate2(file_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR + if (check_name(group_id, "/g1", "/g1") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g1/g2", "/g1/g2") < 0) + TEST_ERROR /* Close */ H5Gclose(group_id); @@ -156,106 +158,123 @@ test_main(hid_t file_id, hid_t fapl) PASSED(); - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Gopen2 - *------------------------------------------------------------------------- - */ + * Test H5Iget_name with H5Gopen2 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Gopen2"); /* Reopen the group */ - if((group_id = H5Gopen2(file_id, "/g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Reopen the group */ - if((group2_id = H5Gopen2(file_id, "/g1/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "/g1/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR + if (check_name(group_id, "/g1", "/g1") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g1/g2", "/g1/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR PASSED(); - - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Dcreate2 - *------------------------------------------------------------------------- - */ + * Test H5Iget_name with H5Dcreate2 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Dcreate2"); /* Create the dataspace */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR /* Create a new dataset */ - if((dataset_id = H5Dcreate2(file_id , "d1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dataset_id = + H5Dcreate2(file_id, "d1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Verify */ - if(check_name(dataset_id, "/d1", "/d1") < 0) TEST_ERROR + if (check_name(dataset_id, "/d1", "/d1") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR /* Reopen the group */ - if((group_id = H5Gopen2(file_id, "g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a new dataset inside "g1" */ - if((dataset_id = H5Dcreate2(group_id , "d1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset_id = + H5Dcreate2(group_id, "d1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(dataset_id, "/g1/d1", "/g1/d1") < 0) TEST_ERROR + if (check_name(dataset_id, "/g1/d1", "/g1/d1") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Dopen2 - *------------------------------------------------------------------------- - */ + * Test H5Iget_name with H5Dopen2 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Dopen2"); /* Reopen the dataset */ - if((dataset_id = H5Dopen2(file_id, "d1", H5P_DEFAULT)) < 0) TEST_ERROR + if ((dataset_id = H5Dopen2(file_id, "d1", H5P_DEFAULT)) < 0) + TEST_ERROR /* Verify */ - if(check_name(dataset_id, "/d1", "/d1") < 0) TEST_ERROR + if (check_name(dataset_id, "/d1", "/d1") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR /* Reopen the group */ - if((group_id = H5Gopen2(file_id, "g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Reopen the dataset */ - if((dataset_id = H5Dopen2(group_id, "d1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset_id = H5Dopen2(group_id, "d1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(dataset_id, "/g1/d1", "/g1/d1") < 0) TEST_ERROR + if (check_name(dataset_id, "/g1/d1", "/g1/d1") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- * Test H5Iget_name with a long path *------------------------------------------------------------------------- @@ -264,33 +283,46 @@ test_main(hid_t file_id, hid_t fapl) TESTING("H5Iget_name with a long path"); /* Create group "g2/bar/baz" */ - if((group_id = H5Gcreate2(file_id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "g2/bar", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "g2/bar/baz", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "g2/bar", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "g2/bar/baz", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a dataset */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR - if((dataset_id = H5Dcreate2(group3_id , "d1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + if ((dataset_id = H5Dcreate2(group3_id, "d1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Reopen the dataset */ - if((dataset_id = H5Dopen2(file_id, "/g2/bar/baz/d1", H5P_DEFAULT)) < 0) TEST_ERROR + if ((dataset_id = H5Dopen2(file_id, "/g2/bar/baz/d1", H5P_DEFAULT)) < 0) + TEST_ERROR /* Verify */ - if(check_name(dataset_id, "/g2/bar/baz/d1", "/g2/bar/baz/d1") < 0) TEST_ERROR + if (check_name(dataset_id, "/g2/bar/baz/d1", "/g2/bar/baz/d1") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR PASSED(); - /*------------------------------------------------------------------------- * Test H5Iget_name with H5Tcommit2 *------------------------------------------------------------------------- @@ -299,18 +331,24 @@ test_main(hid_t file_id, hid_t fapl) TESTING("H5Iget_name with H5Tcommit2"); /* Create a datatype */ - if((type_id = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0) TEST_ERROR + if ((type_id = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0) + TEST_ERROR /* Insert fields */ - if(H5Tinsert(type_id, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(type_id, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(type_id, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) TEST_ERROR + if (H5Tinsert(type_id, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT) < 0) + TEST_ERROR + if (H5Tinsert(type_id, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0) + TEST_ERROR + if (H5Tinsert(type_id, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) + TEST_ERROR /* Save datatype for later */ - if(H5Tcommit2(file_id, "t1", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Tcommit2(file_id, "t1", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify */ - if(check_name(type_id, "/t1", "/t1") < 0) TEST_ERROR + if (check_name(type_id, "/t1", "/t1") < 0) + TEST_ERROR /* Close datatype */ H5Tclose(type_id); @@ -325,399 +363,503 @@ test_main(hid_t file_id, hid_t fapl) TESTING("H5Iget_name with H5Topen2"); /* Open the named datatype */ - if((type_id = H5Topen2(file_id, "t1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((type_id = H5Topen2(file_id, "t1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(type_id, "/t1", "/t1") < 0) TEST_ERROR + if (check_name(type_id, "/t1", "/t1") < 0) + TEST_ERROR /* Close datatype */ - if(H5Tclose(type_id) < 0) FAIL_STACK_ERROR + if (H5Tclose(type_id) < 0) + FAIL_STACK_ERROR PASSED(); - - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lmove and H5Gopen2 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lmove and H5Gopen2 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lmove and H5Gopen2"); /* Reopen the group */ - if((group_id = H5Gopen2(file_id, "/g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Rename group */ - if(H5Lmove(file_id, "/g1", H5L_SAME_LOC, "/g1a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g1", H5L_SAME_LOC, "/g1a", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g1a", "/g1a") < 0) TEST_ERROR + if (check_name(group_id, "/g1a", "/g1a") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR PASSED(); - - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lmove and H5Dopen2 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lmove and H5Dopen2 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lmove and H5Dopen2"); /* Reopen the dataset */ - if((dataset_id = H5Dopen2(file_id, "/d1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset_id = H5Dopen2(file_id, "/d1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Rename dataset */ - if(H5Lmove(file_id, "/d1", H5L_SAME_LOC, "/d1a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/d1", H5L_SAME_LOC, "/d1a", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(dataset_id, "/d1a", "/d1a") < 0) FAIL_STACK_ERROR + if (check_name(dataset_id, "/d1a", "/d1a") < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR PASSED(); - - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lmove and H5Topen2 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lmove and H5Topen2 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lmove and H5Topen2"); /* Open the named datatype */ - if((type_id = H5Topen2(file_id, "/t1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((type_id = H5Topen2(file_id, "/t1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Rename datatype */ - if(H5Lmove(file_id, "/t1", H5L_SAME_LOC, "/t1a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/t1", H5L_SAME_LOC, "/t1a", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(type_id, "/t1a", "/t1a") < 0) FAIL_STACK_ERROR + if (check_name(type_id, "/t1a", "/t1a") < 0) + FAIL_STACK_ERROR /* Close datatype */ - if(H5Tclose(type_id) < 0) FAIL_STACK_ERROR + if (H5Tclose(type_id) < 0) + FAIL_STACK_ERROR PASSED(); - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lmove and relative names - *------------------------------------------------------------------------- - */ + * Test H5Iget_name with H5Lmove and relative names + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lmove and relative names"); /* Create group "/g3" */ - if((group_id = H5Gcreate2(file_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create group "/g3/foo" using absolute name */ - if((group2_id = H5Gcreate2(file_id, "/g3/foo1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g3/foo1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Open group "/g3/foo" again */ - if((group3_id = H5Gopen2(file_id, "/g3/foo1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g3/foo1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Rename group */ - if(H5Lmove(group_id, "foo1", H5L_SAME_LOC, "foo2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(group_id, "foo1", H5L_SAME_LOC, "foo2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g3", "/g3") < 0) TEST_ERROR + if (check_name(group_id, "/g3", "/g3") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "/g3/foo2", "/g3/foo2") < 0) TEST_ERROR + if (check_name(group2_id, "/g3/foo2", "/g3/foo2") < 0) + TEST_ERROR /* Verify */ - if(check_name(group3_id, "/g3/foo2", "/g3/foo2") < 0) TEST_ERROR + if (check_name(group3_id, "/g3/foo2", "/g3/foo2") < 0) + TEST_ERROR /* Rename group again */ - if(H5Lmove(file_id, "g3/foo2", H5L_SAME_LOC, "g3/foo1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "g3/foo2", H5L_SAME_LOC, "g3/foo1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g3", "/g3") < 0) TEST_ERROR + if (check_name(group_id, "/g3", "/g3") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "/g3/foo1", "/g3/foo1") < 0) TEST_ERROR + if (check_name(group2_id, "/g3/foo1", "/g3/foo1") < 0) + TEST_ERROR /* Verify */ - if(check_name(group3_id, "/g3/foo1", "/g3/foo1") < 0) TEST_ERROR + if (check_name(group3_id, "/g3/foo1", "/g3/foo1") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lmove and a long path - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lmove and a long path + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lmove and a long path"); /* Create group "g4/A/B" */ - if((group_id = H5Gcreate2(file_id, "g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "g4/A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "g4/A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "g4/A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "g4/A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create group "g5/C" */ - if((group4_id = H5Gcreate2(file_id, "g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group5_id = H5Gcreate2(file_id, "g5/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group4_id = H5Gcreate2(file_id, "g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group5_id = H5Gcreate2(file_id, "g5/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) TEST_ERROR + if (check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) + TEST_ERROR /* Move group "B" to "D"*/ - if(H5Lmove(file_id, "/g4/A/B", H5L_SAME_LOC, "/g5/C/D", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g4/A/B", H5L_SAME_LOC, "/g5/C/D", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g5/C/D", "/g5/C/D") < 0) TEST_ERROR + if (check_name(group3_id, "/g5/C/D", "/g5/C/D") < 0) + TEST_ERROR /* Move group "/g5/C/D" back to "/g4/A/B" using relative name */ - if(H5Lmove(group5_id, "D", group2_id, "B", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(group5_id, "D", group2_id, "B", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) TEST_ERROR + if (check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) + TEST_ERROR /* Move group "/g4/A/B" to "/g4/F/B" using relative name */ - if(H5Lmove(group_id, "A", group_id, "F", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(group_id, "A", group_id, "F", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g4/F/B", "/g4/F/B") < 0) TEST_ERROR + if (check_name(group3_id, "/g4/F/B", "/g4/F/B") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "/g4/F", "/g4/F") < 0) TEST_ERROR + if (check_name(group2_id, "/g4/F", "/g4/F") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group5_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lmove and a long path #2 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lmove and a long path #2 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lmove and a long path #2"); /* Create group "g6/A/B" and "g7" */ - if((group_id = H5Gcreate2(file_id, "g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "g6/A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "g6/A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group4_id = H5Gcreate2(file_id, "g7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "g6/A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "g6/A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group4_id = H5Gcreate2(file_id, "g7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g6/A/B", "/g6/A/B") < 0) TEST_ERROR + if (check_name(group3_id, "/g6/A/B", "/g6/A/B") < 0) + TEST_ERROR /* Move group "A" to "C"*/ - if(H5Lmove(file_id, "/g6/A", H5L_SAME_LOC, "/g7/C", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g6/A", H5L_SAME_LOC, "/g7/C", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g7/C", "/g7/C") < 0) TEST_ERROR + if (check_name(group2_id, "/g7/C", "/g7/C") < 0) + TEST_ERROR /* Verify */ - if(check_name(group3_id, "/g7/C/B", "/g7/C/B") < 0) TEST_ERROR + if (check_name(group3_id, "/g7/C/B", "/g7/C/B") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Ldelete - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Ldelete + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Ldelete"); /* Create a new group. */ - if((group_id = H5Gcreate2(file_id, "/g8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete */ - if(H5Ldelete(file_id, "/g8", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/g8", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "", "") < 0) TEST_ERROR + if (check_name(group_id, "", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Ldelete and a long path - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Ldelete and a long path + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Ldelete and a long path"); /* Create group "g9/a/b" */ - if((group_id = H5Gcreate2(file_id, "g9", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "g9/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "g9/a/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "g9", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "g9/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "g9/a/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete */ - if(H5Ldelete(file_id, "/g9/a", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/g9/a", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "", "") < 0) TEST_ERROR + if (check_name(group2_id, "", "") < 0) + TEST_ERROR /* Verify */ - if(check_name(group3_id, "", "") < 0) TEST_ERROR + if (check_name(group3_id, "", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Recreate groups */ - if((group2_id = H5Gcreate2(group_id, "a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(group_id, "a/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(group_id, "a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(group_id, "a/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete, using relative path */ - if(H5Ldelete(group_id, "a", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(group_id, "a", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "", "") < 0) TEST_ERROR + if (check_name(group2_id, "", "") < 0) + TEST_ERROR /* Verify */ - if(check_name(group3_id, "", "") < 0) TEST_ERROR + if (check_name(group3_id, "", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR /* Create group "g10/a/b" */ - if((group_id = H5Gcreate2(file_id, "g10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "g10/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "g10/a/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "g10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "g10/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "g10/a/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete */ - if(H5Ldelete(file_id, "/g10/a/b", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/g10/a/b", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "", "") < 0) TEST_ERROR + if (check_name(group3_id, "", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Recreate group */ - if((group3_id = H5Gcreate2(group_id, "a/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(group_id, "a/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete, using relative path */ - if(H5Ldelete(group_id, "a/b", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(group_id, "a/b", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "", "") < 0) TEST_ERROR + if (check_name(group3_id, "", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Ldelete, same names - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Ldelete, same names + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Ldelete, same names"); /* Create group "g11/g" */ - if((group_id = H5Gcreate2(file_id, "g11", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "g11/g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "g11", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "g11/g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create two datasets "g11/d" and "g11/g/d"*/ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) FAIL_STACK_ERROR - if((dataset_id = H5Dcreate2(group_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((dataset2_id = H5Dcreate2(group2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + FAIL_STACK_ERROR + if ((dataset_id = + H5Dcreate2(group_id, "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((dataset2_id = + H5Dcreate2(group2_id, "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete */ - if(H5Ldelete(file_id, "/g11/d", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/g11/d", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(dataset_id, "", "") < 0) TEST_ERROR + if (check_name(dataset_id, "", "") < 0) + TEST_ERROR /* Verify */ - if(check_name(dataset2_id, "/g11/g/d", "/g11/g/d") < 0) TEST_ERROR + if (check_name(dataset2_id, "/g11/g/d", "/g11/g/d") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset2_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset2_id) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Fmount; with IDs on the list - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Fmount; with IDs on the list + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Fmount; with IDs on the list"); /* Create a group "g12" in the first file */ - if((group_id = H5Gcreate2(file_id, "/g12", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g12", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR /* Create second file and dataset "d" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a dataspace */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR /* Create the dataset */ - if((dataset_id = H5Dcreate2(file1_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dataset_id = + H5Dcreate2(file1_id, "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR /* Mount second file under "g12" in the first file */ - if(H5Fmount(file_id, "/g12", file1_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(file_id, "/g12", file1_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Access dataset D in the first file under "/G/D" name */ - if((dataset_id = H5Dopen2(file_id, "/g12/d", H5P_DEFAULT)) < 0) TEST_ERROR + if ((dataset_id = H5Dopen2(file_id, "/g12/d", H5P_DEFAULT)) < 0) + TEST_ERROR /* Verify */ - if(check_name(dataset_id, "/g12/d", "/g12/d") < 0) TEST_ERROR + if (check_name(dataset_id, "/g12/d", "/g12/d") < 0) + TEST_ERROR - if(H5Funmount(file_id, "/g12") < 0) TEST_ERROR + if (H5Funmount(file_id, "/g12") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR - + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR PASSED(); - /*------------------------------------------------------------------------- * Test H5Iget_name with H5Fmount; long name *------------------------------------------------------------------------- @@ -726,199 +868,271 @@ test_main(hid_t file_id, hid_t fapl) TESTING("H5Iget_name with H5Fmount; long name"); /* Create a group "g13/g1/g2" in the first file */ - if((group_id = H5Gcreate2(file_id, "/g13", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g13/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "/g13/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g13", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g13/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "/g13/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Create second file and group "g" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if((group_id = H5Gcreate2(file1_id, "/g14", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g14/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g14/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g14", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g14/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g14/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Mount second file under "/g13/g1" in the first file */ - if(H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Access group in the first file */ - if((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR - - if(H5Funmount(file_id, "/g13/g1") < 0) FAIL_STACK_ERROR + if (check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) + TEST_ERROR + if (H5Funmount(file_id, "/g13/g1") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g14/g3/g4", "") < 0) TEST_ERROR + if (check_name(group_id, "/g14/g3/g4", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR /* Access group in the file to mount */ - if((group3_id = H5Gopen2(file1_id, "/g14/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file1_id, "/g14/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Mount second file under "/g13/g1" in the first file(again) */ - if(H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Get a group ID for the parent of the newly mounted group */ - if((group2_id = H5Gopen2(file_id, "/g13", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "/g13", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Access group in the first file */ - if((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR - if(check_name(group3_id, "/g14/g3/g4", "/g14/g3/g4") < 0) TEST_ERROR + if (check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) + TEST_ERROR + if (check_name(group3_id, "/g14/g3/g4", "/g14/g3/g4") < 0) + TEST_ERROR - if(H5Funmount(group2_id, "g1") < 0) FAIL_STACK_ERROR + if (H5Funmount(group2_id, "g1") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g14/g3/g4", "") < 0) TEST_ERROR - if(check_name(group3_id, "/g14/g3/g4", "/g14/g3/g4") < 0) TEST_ERROR + if (check_name(group_id, "/g14/g3/g4", "") < 0) + TEST_ERROR + if (check_name(group3_id, "/g14/g3/g4", "/g14/g3/g4") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Mount second file under "/g13/g1" in the first file(again) */ - if(H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Get a group ID for the newly mounted group */ - if((group2_id = H5Gopen2(file_id, "/g13/g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "/g13/g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Access group in the first file */ - if((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR - if(check_name(group2_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR + if (check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) + TEST_ERROR + if (check_name(group2_id, "/g13/g1", "/g13/g1") < 0) + TEST_ERROR - if(H5Funmount(group2_id, ".") < 0) FAIL_STACK_ERROR + if (H5Funmount(group2_id, ".") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g14/g3/g4", "") < 0) TEST_ERROR - if(check_name(group2_id, "/", "") < 0) TEST_ERROR + if (check_name(group_id, "/g14/g3/g4", "") < 0) + TEST_ERROR + if (check_name(group2_id, "/", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR /* Mount second file under "/g13/g1" in the first file, using relative path */ - if((group3_id = H5Gopen2(file_id, "/g13", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g13", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g13", "/g13") < 0) TEST_ERROR + if (check_name(group3_id, "/g13", "/g13") < 0) + TEST_ERROR - if(H5Fmount(group3_id, "g1", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(group3_id, "g1", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Get a group ID for the newly mounted group */ - if((group2_id = H5Gopen2(file_id, "/g13/g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "/g13/g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/g13/g1", "/g13/g1") < 0) + TEST_ERROR /* Access group in the first file */ - if((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR + if (check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR /* Access group in the first file, with relative path */ - if((group_id = H5Gopen2(group2_id, "g14/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(group2_id, "g14/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR + if (check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR - if(H5Funmount(group2_id, ".") < 0) FAIL_STACK_ERROR + if (H5Funmount(group2_id, ".") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/", "") < 0) TEST_ERROR + if (check_name(group2_id, "/", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Mount second file under "/g13/g1" in the first file, using relative path */ - if((group3_id = H5Gopen2(file_id, "/g13/g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g13/g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR + if (check_name(group3_id, "/g13/g1", "/g13/g1") < 0) + TEST_ERROR - if(H5Fmount(group3_id, ".", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(group3_id, ".", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Get a group ID for the newly mounted group */ - if((group2_id = H5Gopen2(file_id, "/g13/g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "/g13/g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/g13/g1", "/g13/g1") < 0) + TEST_ERROR /* Access group in the first file */ - if((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g13/g1/g14/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR + if (check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR /* Access group in the first file, with relative path */ - if((group_id = H5Gopen2(group2_id, "g14/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(group2_id, "g14/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR + if (check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR - if(H5Funmount(group2_id, ".") < 0) FAIL_STACK_ERROR + if (H5Funmount(group2_id, ".") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/", "") < 0) TEST_ERROR - if(check_name(group3_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/", "") < 0) + TEST_ERROR + if (check_name(group3_id, "/g13/g1", "/g13/g1") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR PASSED(); - -/*------------------------------------------------------------------------- - * Test H5Iget_name with H5Funmount - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Funmount + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Funmount"); /* Create a group "g15/g1/g2" in the first file */ - if((group_id = H5Gcreate2(file_id, "/g15", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g15/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "/g15/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group4_id = H5Gcreate2(file_id, "/g15/g1/g2/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g15", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g15/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "/g15/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group4_id = H5Gcreate2(file_id, "/g15/g1/g2/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -929,47 +1143,62 @@ test_main(hid_t file_id, hid_t fapl) /* Create second file and group "g" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if((group_id = H5Gcreate2(file1_id, "/g16", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g16/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g16/g4/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g16", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g16/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g16/g4/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Access group in the first file */ - if((group_id = H5Gopen2(file_id, "/g15/g1/g2/g3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g15/g1/g2/g3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Mount second file under "/g13/g1" in the first file */ - if(H5Fmount(file_id, "/g15/g1", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g15/g1", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Access group in the second file */ - if((group2_id = H5Gopen2(file_id, "/g15/g1/g16/g4/g5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "/g15/g1/g16/g4/g5", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "", "/g15/g1/g2/g3") < 0) TEST_ERROR + if (check_name(group_id, "", "/g15/g1/g2/g3") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "/g15/g1/g16/g4/g5", "/g15/g1/g16/g4/g5") < 0) TEST_ERROR + if (check_name(group2_id, "/g15/g1/g16/g4/g5", "/g15/g1/g16/g4/g5") < 0) + TEST_ERROR - if(H5Funmount(file_id, "/g15/g1") < 0) FAIL_STACK_ERROR + if (H5Funmount(file_id, "/g15/g1") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g15/g1/g2/g3", "/g15/g1/g2/g3") < 0) TEST_ERROR + if (check_name(group_id, "/g15/g1/g2/g3", "/g15/g1/g2/g3") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "/g16/g4/g5", "") < 0) TEST_ERROR + if (check_name(group2_id, "/g16/g4/g5", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR - + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR PASSED(); - /*------------------------------------------------------------------------- * Test H5Iget_name with a defined type dataset *------------------------------------------------------------------------- @@ -978,278 +1207,352 @@ test_main(hid_t file_id, hid_t fapl) TESTING("H5Iget_name with a defined type dataset"); /* Create a datatype */ - if((type_id = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0) FAIL_STACK_ERROR + if ((type_id = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0) + FAIL_STACK_ERROR /* Insert fields */ - if(H5Tinsert(type_id, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT) < 0) FAIL_STACK_ERROR - if(H5Tinsert(type_id, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0) FAIL_STACK_ERROR - if(H5Tinsert(type_id, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) FAIL_STACK_ERROR + if (H5Tinsert(type_id, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(type_id, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0) + FAIL_STACK_ERROR + if (H5Tinsert(type_id, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) + FAIL_STACK_ERROR /* Create group "g17" */ - if((group_id = H5Gcreate2(file_id, "g17", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "g17", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Save datatype for later */ - if(H5Tcommit2(group_id, "t", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Tcommit2(group_id, "t", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create a dataspace */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) FAIL_STACK_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + FAIL_STACK_ERROR /* Create a new dataset */ - if((dataset_id = H5Dcreate2(group_id , "d", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset_id = H5Dcreate2(group_id, "d", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + FAIL_STACK_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Tclose(type_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type_id) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR /* Open the named datatype */ - if((type_id = H5Topen2(file_id, "/g17/t", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((type_id = H5Topen2(file_id, "/g17/t", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(type_id, "/g17/t", "/g17/t") < 0) TEST_ERROR + if (check_name(type_id, "/g17/t", "/g17/t") < 0) + TEST_ERROR /* Close datatype */ - if(H5Tclose(type_id) < 0) FAIL_STACK_ERROR + if (H5Tclose(type_id) < 0) + FAIL_STACK_ERROR /* Reopen the dataset */ - if((dataset_id = H5Dopen2(file_id, "/g17/d", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset_id = H5Dopen2(file_id, "/g17/d", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get datatype*/ - if((type_id = H5Dget_type(dataset_id)) < 0) FAIL_STACK_ERROR + if ((type_id = H5Dget_type(dataset_id)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(type_id, "/g17/t", "/g17/t") < 0) TEST_ERROR + if (check_name(type_id, "/g17/t", "/g17/t") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Tclose(type_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with objects that have two names - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with objects that have two names + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with datasets that have two names"); /* Open dataset named "d"*/ - if((dataset_id = H5Dopen2(file_id, "/g17/d", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset_id = H5Dopen2(file_id, "/g17/d", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create link to dataset named "link" */ - if(H5Lcreate_hard(dataset_id, ".", file_id, "/g17/link", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if((dataset2_id = H5Dopen2(file_id, "/g17/link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(dataset_id, ".", file_id, "/g17/link", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if ((dataset2_id = H5Dopen2(file_id, "/g17/link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Make sure that the two IDs use two different names */ - if(check_name(dataset_id, "/g17/d", "/g17/d") < 0) TEST_ERROR - if(check_name(dataset2_id, "/g17/link", "/g17/link") < 0) TEST_ERROR + if (check_name(dataset_id, "/g17/d", "/g17/d") < 0) + TEST_ERROR + if (check_name(dataset2_id, "/g17/link", "/g17/link") < 0) + TEST_ERROR - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset2_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset2_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with different files, test1 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with different files, test1 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with different files"); /* Create a new file using default properties. */ - if((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a new file using default properties. */ - if((file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create the dataspace */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) FAIL_STACK_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + FAIL_STACK_ERROR /* Create a new dataset */ - if((dataset_id = H5Dcreate2(file2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset_id = + H5Dcreate2(file2_id, "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a new dataset */ - if((dataset2_id = H5Dcreate2(file3_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset2_id = + H5Dcreate2(file3_id, "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete */ - if(H5Ldelete(file2_id, "/d", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file2_id, "/d", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(dataset_id, "", "") < 0) TEST_ERROR + if (check_name(dataset_id, "", "") < 0) + TEST_ERROR /* Verify */ - if(check_name(dataset2_id, "/d", "/d") < 0) TEST_ERROR + if (check_name(dataset2_id, "/d", "/d") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset2_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file3_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset2_id) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with different files, test2 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with different files, test2 + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with different files #2"); /* Create a new file using default properties. */ - if((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a new file using default properties. */ - if((file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create the dataspace */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) FAIL_STACK_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + FAIL_STACK_ERROR /* Create a new dataset */ - if((dataset_id = H5Dcreate2(file2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset_id = + H5Dcreate2(file2_id, "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a new dataset */ - if((dataset2_id = H5Dcreate2(file3_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset2_id = + H5Dcreate2(file3_id, "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete */ - if(H5Ldelete(file3_id, "/d", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file3_id, "/d", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(dataset_id, "/d", "/d") < 0) TEST_ERROR + if (check_name(dataset_id, "/d", "/d") < 0) + TEST_ERROR /* Verify */ - if(check_name(dataset2_id, "", "") < 0) TEST_ERROR + if (check_name(dataset2_id, "", "") < 0) + TEST_ERROR /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset2_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file3_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset2_id) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with a small buffer for name - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with a small buffer for name + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with a small buffer for name"); /* Reopen the group */ - if((group_id = H5Gopen2(file_id, "/g17", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g17", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR -{ - /*small buffer to hold name and its size */ - char name2[SMALL_NAME_BUF_SIZE]; + { + /*small buffer to hold name and its size */ + char name2[SMALL_NAME_BUF_SIZE]; - /* Get name */ - *name2 = '\0'; - name_len=(size_t)H5Iget_name(group_id, name2, SMALL_NAME_BUF_SIZE); + /* Get name */ + *name2 = '\0'; + name_len = (size_t)H5Iget_name(group_id, name2, SMALL_NAME_BUF_SIZE); - /* Check that name is longer */ - if(name_len <= SMALL_NAME_BUF_SIZE) TEST_ERROR - if(HDstrcmp(name2, "/")) TEST_ERROR -} + /* Check that name is longer */ + if (name_len <= SMALL_NAME_BUF_SIZE) + TEST_ERROR + if (HDstrcmp(name2, "/")) + TEST_ERROR + } /* Verify */ - if(check_name(group_id, "/g17", "/g17") < 0) TEST_ERROR + if (check_name(group_id, "/g17", "/g17") < 0) + TEST_ERROR /* Close */ H5Gclose(group_id); PASSED(); - /*------------------------------------------------------------------------- - * Test H5Iget_name with a dynamic buffer for name - *------------------------------------------------------------------------- - */ + * Test H5Iget_name with a dynamic buffer for name + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with a dynamic buffer for name"); /* Reopen the group */ - if((group_id = H5Gopen2(file_id, "/g17", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g17", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get name */ name_len = (size_t)H5Iget_name(group_id, NULL, NAME_BUF_SIZE); -{ - /* dynamic buffer to hold name */ - char *name3; + { + /* dynamic buffer to hold name */ + char *name3; - /* Include the extra null character */ - name3 = (char *)HDmalloc(name_len + 1); - if(!name3) TEST_ERROR + /* Include the extra null character */ + name3 = (char *)HDmalloc(name_len + 1); + if (!name3) + TEST_ERROR - /* Get name with dynamic buffer */ - *name3 = '\0'; - if(H5Iget_name(group_id, name3, name_len + 1) < 0) TEST_ERROR + /* Get name with dynamic buffer */ + *name3 = '\0'; + if (H5Iget_name(group_id, name3, name_len + 1) < 0) + TEST_ERROR - /* Verify */ - if(HDstrcmp(name3, "/g17")) TEST_ERROR - *name3 = '\0'; + /* Verify */ + if (HDstrcmp(name3, "/g17")) + TEST_ERROR + *name3 = '\0'; - /* Get name with smaller buffer */ - *name3 = '\0'; - if(H5Iget_name(group_id, name3, 3) < 0) TEST_ERROR + /* Get name with smaller buffer */ + *name3 = '\0'; + if (H5Iget_name(group_id, name3, 3) < 0) + TEST_ERROR - /* Verify */ - if(HDstrcmp(name3, "/g")) TEST_ERROR + /* Verify */ + if (HDstrcmp(name3, "/g")) + TEST_ERROR - HDfree(name3); -} + HDfree(name3); + } /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR PASSED(); - -/*------------------------------------------------------------------------- - * Test H5Iget_name with invalid IDs - *------------------------------------------------------------------------- - */ - + /*------------------------------------------------------------------------- + * Test H5Iget_name with invalid IDs + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with invalid IDs"); /* Create a dataspace */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR /* Define a datatype */ - if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* Create a new dataset */ - if((dataset_id = H5Dcreate2(file_id , "d2", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dataset_id = H5Dcreate2(file_id, "d2", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR -{ - char name[NAME_BUF_SIZE]; /* Buffer to hold name and its size */ + { + char name[NAME_BUF_SIZE]; /* Buffer to hold name and its size */ - /* Get name for non commited datatype, it should fail */ - H5E_BEGIN_TRY { - if(H5Iget_name(type_id, name, NAME_BUF_SIZE) > 0) TEST_ERROR - } H5E_END_TRY; + /* Get name for non commited datatype, it should fail */ + H5E_BEGIN_TRY + { + if (H5Iget_name(type_id, name, NAME_BUF_SIZE) > 0) + TEST_ERROR + } + H5E_END_TRY; - /* Get name for dataspace, it should fail */ - H5E_BEGIN_TRY { - if(H5Iget_name(space_id, name, NAME_BUF_SIZE) > 0) TEST_ERROR - } H5E_END_TRY; -} + /* Get name for dataspace, it should fail */ + H5E_BEGIN_TRY + { + if (H5Iget_name(space_id, name, NAME_BUF_SIZE) > 0) + TEST_ERROR + } + H5E_END_TRY; + } /* Close */ - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR - if(H5Tclose(type_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type_id) < 0) + FAIL_STACK_ERROR PASSED(); - /*------------------------------------------------------------------------- * Test H5Iget_name with added names with mounting *------------------------------------------------------------------------- @@ -1258,701 +1561,969 @@ test_main(hid_t file_id, hid_t fapl) TESTING("H5Iget_name with added names with mounting"); /* Create a group "g18/g2" in the first file */ - if((group_id = H5Gcreate2(file_id, "/g18", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g18/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g18", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g18/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Also create a dataset and a datatype */ - if((space_id = H5Screate_simple(1, dims, NULL)) < 0) FAIL_STACK_ERROR - if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR - if((dataset_id = H5Dcreate2(file_id, "g18/d2", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) + FAIL_STACK_ERROR + if ((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR + if ((dataset_id = + H5Dcreate2(file_id, "g18/d2", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if(H5Tcommit2(file_id, "g18/t2", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Tcommit2(file_id, "g18/t2", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create second file and group "/g3/g4/g5" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group4_id = H5Gcreate2(file1_id, "/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group5_id = H5Gcreate2(file1_id, "/g3/g4/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group4_id = H5Gcreate2(file1_id, "/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group5_id = H5Gcreate2(file1_id, "/g3/g4/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Mount first file at "g3/g4" in the second file */ - if(H5Fmount(file1_id, "/g3/g4", file_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(file1_id, "/g3/g4", file_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Get name for the group ID in the first file, should be "/g18/g2" still */ - if(check_name(group2_id, "/g18/g2", "/g18/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g18/g2", "/g18/g2") < 0) + TEST_ERROR /* Get name for the dataset ID in the first file, should be "/g18/g2/d2" still */ - if(check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) TEST_ERROR + if (check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) + TEST_ERROR /* Get name for the datatype ID in the first file, should be "/g18/g2/t2" still */ - if(check_name(type_id, "/g18/t2", "/g18/t2") < 0) TEST_ERROR + if (check_name(type_id, "/g18/t2", "/g18/t2") < 0) + TEST_ERROR /* Open the mounted group, dataset, and datatype through their new names */ - if((group6_id = H5Gopen2(file1_id, "/g3/g4/g18/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((dataset2_id = H5Dopen2(file1_id, "/g3/g4/g18/d2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((type2_id = H5Topen2(file1_id, "/g3/g4/g18/t2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group6_id = H5Gopen2(file1_id, "/g3/g4/g18/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((dataset2_id = H5Dopen2(file1_id, "/g3/g4/g18/d2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((type2_id = H5Topen2(file1_id, "/g3/g4/g18/t2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify names */ - if(check_name(group6_id, "/g3/g4/g18/g2", "/g3/g4/g18/g2") < 0) TEST_ERROR - if(check_name(dataset2_id, "/g3/g4/g18/d2", "/g3/g4/g18/d2") < 0) TEST_ERROR - if(check_name(type2_id, "/g3/g4/g18/t2", "/g3/g4/g18/t2") < 0) TEST_ERROR + if (check_name(group6_id, "/g3/g4/g18/g2", "/g3/g4/g18/g2") < 0) + TEST_ERROR + if (check_name(dataset2_id, "/g3/g4/g18/d2", "/g3/g4/g18/d2") < 0) + TEST_ERROR + if (check_name(type2_id, "/g3/g4/g18/t2", "/g3/g4/g18/t2") < 0) + TEST_ERROR /* Verify that old IDs still refer to objects by their old names */ - if(check_name(group2_id, "/g18/g2", "/g18/g2") < 0) TEST_ERROR - if(check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) TEST_ERROR - if(check_name(type_id, "/g18/t2", "/g18/t2") < 0) TEST_ERROR + if (check_name(group2_id, "/g18/g2", "/g18/g2") < 0) + TEST_ERROR + if (check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) + TEST_ERROR + if (check_name(type_id, "/g18/t2", "/g18/t2") < 0) + TEST_ERROR /* Unmount */ - if(H5Funmount(file1_id, "/g3/g4") < 0) FAIL_STACK_ERROR + if (H5Funmount(file1_id, "/g3/g4") < 0) + FAIL_STACK_ERROR /* Get name for the IDs of the first file, should be unchanged */ - if(check_name(group2_id, "/g18/g2", "/g18/g2") < 0) TEST_ERROR - if(check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) TEST_ERROR - if(check_name(type_id, "/g18/t2", "/g18/t2") < 0) TEST_ERROR + if (check_name(group2_id, "/g18/g2", "/g18/g2") < 0) + TEST_ERROR + if (check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) + TEST_ERROR + if (check_name(type_id, "/g18/t2", "/g18/t2") < 0) + TEST_ERROR /* Get name for the IDs of the second file, should be local names now */ - if(check_name(group6_id, "/g18/g2", "") < 0) TEST_ERROR - if(check_name(dataset2_id, "/g18/d2", "") < 0) TEST_ERROR - if(check_name(type2_id, "/g18/t2", "") < 0) TEST_ERROR - - if(H5Tclose(type_id) < 0) FAIL_STACK_ERROR - if(H5Tclose(type2_id) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group6_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR + if (check_name(group6_id, "/g18/g2", "") < 0) + TEST_ERROR + if (check_name(dataset2_id, "/g18/d2", "") < 0) + TEST_ERROR + if (check_name(type2_id, "/g18/t2", "") < 0) + TEST_ERROR - PASSED(); + if (H5Tclose(type_id) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type2_id) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset_id) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group5_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group6_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR + PASSED(); - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Fclose - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Fclose + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Fclose"); /* Create a file and group "/g1/g2" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file1_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g1/g2", "/g1/g2") < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g1/g2", "/g1/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Fmount and H5Ldelete - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Fmount and H5Ldelete + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Fmount and H5Ldelete"); /* Create a file and group "/g1/g2" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file1_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a new file and group "/g3/g4" in it */ - if((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file2_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group4_id = H5Gcreate2(file2_id, "/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file2_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group4_id = H5Gcreate2(file2_id, "/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Mount first file at "/g3/g4" in the second file */ - if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the mounted group */ - if((group5_id = H5Gopen2(file2_id, "/g3/g4/g1/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group5_id = H5Gopen2(file2_id, "/g3/g4/g1/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR + if (check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) + TEST_ERROR /* Delete */ - if(H5Ldelete(file1_id, "/g3/g4/g1/g2", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file1_id, "/g3/g4/g1/g2", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "", "") < 0) TEST_ERROR + if (check_name(group5_id, "", "") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "", "") < 0) TEST_ERROR + if (check_name(group2_id, "", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2_id) < 0) FAIL_STACK_ERROR - - PASSED(); + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group5_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2_id) < 0) + FAIL_STACK_ERROR + PASSED(); - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Fmount and H5Lmove - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Fmount and H5Lmove + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Fmount and H5Lmove"); /* Create a file and group "/g1/g2" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file1_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a new file and group "/g3/g4" in it */ - if((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file2_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group4_id = H5Gcreate2(file2_id, "/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file2_id, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group4_id = H5Gcreate2(file2_id, "/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Mount first file at "g3/g4" in the second file */ - if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g3/g4", "/g3/g4") < 0) TEST_ERROR + if (check_name(group4_id, "/g3/g4", "/g3/g4") < 0) + TEST_ERROR /* Open the mounted group */ - if((group5_id = H5Gopen2(file2_id, "/g3/g4/g1/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group5_id = H5Gopen2(file2_id, "/g3/g4/g1/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR + if (check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) + TEST_ERROR /* Open another mounted group, in the middle of the path */ - if((group6_id = H5Gopen2(file2_id, "/g3/g4/g1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group6_id = H5Gopen2(file2_id, "/g3/g4/g1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR + if (check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) + TEST_ERROR /* Rename group */ - if(H5Lmove(file2_id, "/g3/g4/g1/g2", H5L_SAME_LOC, "/g3/g4/g1/g5", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file2_id, "/g3/g4/g1/g2", H5L_SAME_LOC, "/g3/g4/g1/g5", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "/g3/g4/g1/g5", "/g3/g4/g1/g5") < 0) TEST_ERROR - if(check_name(group2_id, "/g1/g5", "/g1/g5") < 0) TEST_ERROR + if (check_name(group5_id, "/g3/g4/g1/g5", "/g3/g4/g1/g5") < 0) + TEST_ERROR + if (check_name(group2_id, "/g1/g5", "/g1/g5") < 0) + TEST_ERROR /* Rename group */ - if(H5Lmove(file2_id, "/g3/g4/g1", H5L_SAME_LOC, "/g3/g4/g1a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file2_id, "/g3/g4/g1", H5L_SAME_LOC, "/g3/g4/g1a", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "/g3/g4/g1a/g5", "/g3/g4/g1a/g5") < 0) TEST_ERROR - if(check_name(group2_id, "/g1a/g5", "/g1a/g5") < 0) TEST_ERROR + if (check_name(group5_id, "/g3/g4/g1a/g5", "/g3/g4/g1a/g5") < 0) + TEST_ERROR + if (check_name(group2_id, "/g1a/g5", "/g1a/g5") < 0) + TEST_ERROR /* Verify */ - if(check_name(group6_id, "/g3/g4/g1a", "/g3/g4/g1a") < 0) TEST_ERROR - if(check_name(group_id, "/g1a", "/g1a") < 0) TEST_ERROR + if (check_name(group6_id, "/g3/g4/g1a", "/g3/g4/g1a") < 0) + TEST_ERROR + if (check_name(group_id, "/g1a", "/g1a") < 0) + TEST_ERROR /* Rename middle group back, using relative path */ - if(H5Lmove(group3_id, "g4/g1a", H5L_SAME_LOC, "g4/g1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(group3_id, "g4/g1a", H5L_SAME_LOC, "g4/g1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "/g3/g4/g1/g5", "/g3/g4/g1/g5") < 0) TEST_ERROR - if(check_name(group2_id, "/g1/g5", "/g1/g5") < 0) TEST_ERROR - if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR - if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR + if (check_name(group5_id, "/g3/g4/g1/g5", "/g3/g4/g1/g5") < 0) + TEST_ERROR + if (check_name(group2_id, "/g1/g5", "/g1/g5") < 0) + TEST_ERROR + if (check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) + TEST_ERROR + if (check_name(group_id, "/g1", "/g1") < 0) + TEST_ERROR /* Rename end group back, using relative path */ - if(H5Lmove(group3_id, "g4/g1/g5", H5L_SAME_LOC, "g4/g1/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(group3_id, "g4/g1/g5", H5L_SAME_LOC, "g4/g1/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR - if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR - if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR - if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR + if (check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) + TEST_ERROR + if (check_name(group2_id, "/g1/g2", "/g1/g2") < 0) + TEST_ERROR + if (check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) + TEST_ERROR + if (check_name(group_id, "/g1", "/g1") < 0) + TEST_ERROR /* Rename mount point */ - if(H5Lmove(file2_id, "/g3/g4", H5L_SAME_LOC, "/g3/g4a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file2_id, "/g3/g4", H5L_SAME_LOC, "/g3/g4a", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g3/g4a", "/g3/g4a") < 0) TEST_ERROR - if(check_name(group5_id, "/g3/g4a/g1/g2", "/g3/g4a/g1/g2") < 0) TEST_ERROR - if(check_name(group6_id, "/g3/g4a/g1", "/g3/g4a/g1") < 0) TEST_ERROR + if (check_name(group4_id, "/g3/g4a", "/g3/g4a") < 0) + TEST_ERROR + if (check_name(group5_id, "/g3/g4a/g1/g2", "/g3/g4a/g1/g2") < 0) + TEST_ERROR + if (check_name(group6_id, "/g3/g4a/g1", "/g3/g4a/g1") < 0) + TEST_ERROR /* Rename mount point back, using relative path*/ - if(H5Lmove(group3_id, "g4a", H5L_SAME_LOC, "g4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(group3_id, "g4a", H5L_SAME_LOC, "g4", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g3/g4", "/g3/g4") < 0) TEST_ERROR - if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR - if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR + if (check_name(group4_id, "/g3/g4", "/g3/g4") < 0) + TEST_ERROR + if (check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) + TEST_ERROR + if (check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group6_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group5_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group6_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lcreate_hard - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lcreate_hard + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lcreate_hard"); /* Create group "g19/g1" */ - if((group_id = H5Gcreate2(file_id, "/g19", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g19/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g19", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g19/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create hard link to "g19/g1/ group */ - if(H5Lcreate_hard(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/g19/g1", "/g19/g1") < 0) + TEST_ERROR /* Open the group */ - if((group3_id = H5Gopen2(file_id, "/g19/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g19/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR + if (check_name(group3_id, "/g19/g2", "/g19/g2") < 0) + TEST_ERROR /* Rename original group */ - if(H5Lmove(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR - if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g19/g3", "/g19/g3") < 0) + TEST_ERROR + if (check_name(group3_id, "/g19/g2", "/g19/g2") < 0) + TEST_ERROR /* Rename original group back, using relative path */ - if(H5Lmove(group_id, "g3", H5L_SAME_LOC, "g1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(group_id, "g3", H5L_SAME_LOC, "g1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR - if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g19/g1", "/g19/g1") < 0) + TEST_ERROR + if (check_name(group3_id, "/g19/g2", "/g19/g2") < 0) + TEST_ERROR /* Create another hard link to "/g19/g1" group */ - if(H5Lcreate_hard(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the group */ - if((group4_id = H5Gopen2(file_id, "/g19/g3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group4_id = H5Gopen2(file_id, "/g19/g3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR + if (check_name(group4_id, "/g19/g3", "/g19/g3") < 0) + TEST_ERROR /* Delete group */ - if(H5Ldelete(file_id, "/g19/g3", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/g19/g3", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g19/g1", "") < 0) TEST_ERROR - if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR - if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR + if (check_name(group4_id, "/g19/g1", "") < 0) + TEST_ERROR + if (check_name(group2_id, "/g19/g1", "/g19/g1") < 0) + TEST_ERROR + if (check_name(group3_id, "/g19/g2", "/g19/g2") < 0) + TEST_ERROR /* Close the unlinked group */ - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR /* Create another hard link to "/g19/g1" group */ - if(H5Lcreate_hard(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(file_id, "/g19/g1", H5L_SAME_LOC, "/g19/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the group */ - if((group4_id = H5Gopen2(file_id, "/g19/g3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group4_id = H5Gopen2(file_id, "/g19/g3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR + if (check_name(group4_id, "/g19/g3", "/g19/g3") < 0) + TEST_ERROR /* Delete group, using relative path */ - if(H5Ldelete(group_id, "g3", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(group_id, "g3", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g19/g1", "") < 0) TEST_ERROR - if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR - if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR + if (check_name(group4_id, "/g19/g1", "") < 0) + TEST_ERROR + if (check_name(group2_id, "/g19/g1", "/g19/g1") < 0) + TEST_ERROR + if (check_name(group3_id, "/g19/g2", "/g19/g2") < 0) + TEST_ERROR /* Close the unlinked group */ - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lcreate_soft - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lcreate_soft + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lcreate_soft"); /* Create group "g20/g1" */ - if((group_id = H5Gcreate2(file_id, "/g20", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g20/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g20", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g20/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create symbolic link to "g20/g1/ group */ - if(H5Lcreate_soft("/g20/g1", file_id, "/g20/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/g20/g1", file_id, "/g20/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g20/g1", "/g20/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/g20/g1", "/g20/g1") < 0) + TEST_ERROR /* Open the group */ - if((group3_id = H5Gopen2(file_id, "/g20/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g20/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g20/g2", "/g20/g2") < 0) TEST_ERROR + if (check_name(group3_id, "/g20/g2", "/g20/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lcreate_soft and move target - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lcreate_soft and move target + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lcreate_soft and move target"); /* Create group "g21/g1" */ - if((group_id = H5Gcreate2(file_id, "/g21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g21/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g21/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create symbolic link to "g21/g1/ group */ - if(H5Lcreate_soft("/g21/g1", file_id, "/g21/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/g21/g1", file_id, "/g21/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g21/g1", "/g21/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/g21/g1", "/g21/g1") < 0) + TEST_ERROR /* Open the group */ - if((group3_id = H5Gopen2(file_id, "/g21/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g21/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Rename group */ - if(H5Lmove(file_id, "/g21/g1", H5L_SAME_LOC, "/g21/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g21/g1", H5L_SAME_LOC, "/g21/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g21/g3", "/g21/g3") < 0) TEST_ERROR - if(check_name(group3_id, "/g21/g2", "/g21/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g21/g3", "/g21/g3") < 0) + TEST_ERROR + if (check_name(group3_id, "/g21/g2", "/g21/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lcreate_soft and move source - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lcreate_soft and move source + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lcreate_soft and move source"); /* Create group "g22/g1" */ - if((group_id = H5Gcreate2(file_id, "/g22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g22/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g22/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create symbolic link to "g22/g1/ group */ - if(H5Lcreate_soft("/g22/g1", file_id, "/g22/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/g22/g1", file_id, "/g22/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g22/g1", "/g22/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/g22/g1", "/g22/g1") < 0) + TEST_ERROR /* Open the group */ - if((group3_id = H5Gopen2(file_id, "/g22/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g22/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Rename soft link */ - if(H5Lmove(file_id, "/g22/g2", H5L_SAME_LOC, "/g22/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g22/g2", H5L_SAME_LOC, "/g22/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g22/g1", "/g22/g1") < 0) TEST_ERROR - if(check_name(group3_id, "/g22/g3", "/g22/g3") < 0) TEST_ERROR + if (check_name(group2_id, "/g22/g1", "/g22/g1") < 0) + TEST_ERROR + if (check_name(group3_id, "/g22/g3", "/g22/g3") < 0) + TEST_ERROR /* Rename soft link, using relative paths */ - if(H5Lmove(group_id, "g3", H5L_SAME_LOC, "g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(group_id, "g3", H5L_SAME_LOC, "g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g22/g1", "/g22/g1") < 0) TEST_ERROR - if(check_name(group3_id, "/g22/g2", "/g22/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g22/g1", "/g22/g1") < 0) + TEST_ERROR + if (check_name(group3_id, "/g22/g2", "/g22/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lcreate_soft and unlink target - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lcreate_soft and unlink target + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lcreate_soft and unlink target"); /* Create group "g23/g1" */ - if((group_id = H5Gcreate2(file_id, "/g23", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g23/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g23", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g23/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create symbolic link to "g23/g1/ group */ - if(H5Lcreate_soft("/g23/g1", file_id, "/g23/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/g23/g1", file_id, "/g23/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g23/g1", "/g23/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/g23/g1", "/g23/g1") < 0) + TEST_ERROR /* Open the group */ - if((group3_id = H5Gopen2(file_id, "/g23/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g23/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete group */ - if(H5Ldelete(file_id, "/g23/g1", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/g23/g1", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g23/g2", "/g23/g2") < 0) TEST_ERROR + if (check_name(group3_id, "/g23/g2", "/g23/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with H5Lcreate_soft and unlink source - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with H5Lcreate_soft and unlink source + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with H5Lcreate_soft and unlink source"); /* Create group "g24/g1" */ - if((group_id = H5Gcreate2(file_id, "/g24", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g24/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g24", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g24/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create symbolic link to "g24/g1/ group */ - if(H5Lcreate_soft("/g24/g1", file_id, "/g24/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/g24/g1", file_id, "/g24/g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g24/g1", "/g24/g1") < 0) TEST_ERROR + if (check_name(group2_id, "/g24/g1", "/g24/g1") < 0) + TEST_ERROR /* Open the group */ - if((group3_id = H5Gopen2(file_id, "/g24/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g24/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete symbolic link */ - if(H5Ldelete(file_id, "/g24/g2", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/g24/g2", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g24/g1", "") < 0) TEST_ERROR + if (check_name(group3_id, "/g24/g1", "") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with several nested mounted files - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with several nested mounted files + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with several nested mounted files"); /* Create a group "g25/g1/g2" in the first file */ - if((group_id = H5Gcreate2(file_id, "/g25", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g25/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "/g25/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g25", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g25/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "/g25/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Create second file and group "/g26/g3/g4" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file1_id, "/g26", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g26/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g26/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g26", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g26/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g26/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Create third file and group "/g27/g5/g6" in it */ - if((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file2_id, "/g27", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file2_id, "/g27/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file2_id, "/g27/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file2_id, "/g27", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file2_id, "/g27/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file2_id, "/g27/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Create fourth file and group "/g28/g5/g6" in it */ - if((file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file3_id, "/g28", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file3_id, "/g28/g7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file3_id, "/g28/g7/g8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file3_id, "/g28", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file3_id, "/g28/g7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file3_id, "/g28/g7/g8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Access group which will be hidden in the first file */ - if((group_id = H5Gopen2(file_id, "/g25/g1/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g25/g1/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g25/g1/g2", "/g25/g1/g2") < 0) TEST_ERROR + if (check_name(group_id, "/g25/g1/g2", "/g25/g1/g2") < 0) + TEST_ERROR /* Mount second file under "/g25/g1" in the first file */ - if(H5Fmount(file_id, "/g25/g1", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g25/g1", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "", "/g25/g1/g2") < 0) TEST_ERROR + if (check_name(group_id, "", "/g25/g1/g2") < 0) + TEST_ERROR /* Access group which will be hidden in the second file */ - if((group2_id = H5Gopen2(file_id, "/g25/g1/g26/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "/g25/g1/g26/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g25/g1/g26/g3/g4", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR + if (check_name(group2_id, "/g25/g1/g26/g3/g4", "/g25/g1/g26/g3/g4") < 0) + TEST_ERROR /* Mount third file under "/g25/g1/g26/g3" in the first file */ - if(H5Fmount(file_id, "/g25/g1/g26/g3", file2_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g25/g1/g26/g3", file2_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR + if (check_name(group2_id, "", "/g25/g1/g26/g3/g4") < 0) + TEST_ERROR /* Access group in the third file */ - if((group3_id = H5Gopen2(file_id, "/g25/g1/g26/g3/g27/g5/g6", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g25/g1/g26/g3/g27/g5/g6", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g25/g1/g26/g3/g27/g5/g6", "/g25/g1/g26/g3/g27/g5/g6") < 0) TEST_ERROR + if (check_name(group3_id, "/g25/g1/g26/g3/g27/g5/g6", "/g25/g1/g26/g3/g27/g5/g6") < 0) + TEST_ERROR /* Mount fourth file under "/g25/g1/g26/g3/g27/g5" in the first file */ - if(H5Fmount(file_id, "/g25/g1/g26/g3/g27/g5", file3_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g25/g1/g26/g3/g27/g5", file3_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "", "/g25/g1/g26/g3/g27/g5/g6") < 0) TEST_ERROR + if (check_name(group3_id, "", "/g25/g1/g26/g3/g27/g5/g6") < 0) + TEST_ERROR /* Access group in the fourth file */ - if((group4_id = H5Gopen2(file_id, "/g25/g1/g26/g3/g27/g5/g28/g7/g8", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group4_id = H5Gopen2(file_id, "/g25/g1/g26/g3/g27/g5/g28/g7/g8", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g25/g1/g26/g3/g27/g5/g28/g7/g8", "/g25/g1/g26/g3/g27/g5/g28/g7/g8") < 0) TEST_ERROR + if (check_name(group4_id, "/g25/g1/g26/g3/g27/g5/g28/g7/g8", "/g25/g1/g26/g3/g27/g5/g28/g7/g8") < 0) + TEST_ERROR - if(H5Funmount(file_id, "/g25/g1/g26/g3/g27/g5") < 0) FAIL_STACK_ERROR + if (H5Funmount(file_id, "/g25/g1/g26/g3/g27/g5") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g28/g7/g8", "") < 0) TEST_ERROR - if(check_name(group3_id, "/g25/g1/g26/g3/g27/g5/g6", "/g25/g1/g26/g3/g27/g5/g6") < 0) TEST_ERROR - if(check_name(group2_id, "", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR - if(check_name(group_id, "", "/g25/g1/g2") < 0) TEST_ERROR + if (check_name(group4_id, "/g28/g7/g8", "") < 0) + TEST_ERROR + if (check_name(group3_id, "/g25/g1/g26/g3/g27/g5/g6", "/g25/g1/g26/g3/g27/g5/g6") < 0) + TEST_ERROR + if (check_name(group2_id, "", "/g25/g1/g26/g3/g4") < 0) + TEST_ERROR + if (check_name(group_id, "", "/g25/g1/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file3_id) < 0) + FAIL_STACK_ERROR - if(H5Funmount(file_id, "/g25/g1/g26/g3") < 0) FAIL_STACK_ERROR + if (H5Funmount(file_id, "/g25/g1/g26/g3") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g27/g5/g6", "") < 0) TEST_ERROR - if(check_name(group2_id, "/g25/g1/g26/g3/g4", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR - if(check_name(group_id, "", "/g25/g1/g2") < 0) TEST_ERROR + if (check_name(group3_id, "/g27/g5/g6", "") < 0) + TEST_ERROR + if (check_name(group2_id, "/g25/g1/g26/g3/g4", "/g25/g1/g26/g3/g4") < 0) + TEST_ERROR + if (check_name(group_id, "", "/g25/g1/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2_id) < 0) + FAIL_STACK_ERROR - if(H5Funmount(file_id, "/g25/g1") < 0) FAIL_STACK_ERROR + if (H5Funmount(file_id, "/g25/g1") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g26/g3/g4", "") < 0) TEST_ERROR - if(check_name(group_id, "/g25/g1/g2", "/g25/g1/g2") < 0) TEST_ERROR + if (check_name(group2_id, "/g26/g3/g4", "") < 0) + TEST_ERROR + if (check_name(group_id, "/g25/g1/g2", "/g25/g1/g2") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name and H5Lmove with repeated path components - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name and H5Lmove with repeated path components + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name and H5Lmove with repeated path components"); /* Create a group "g29/g1/g2/g1/g2" in a file */ - if((group_id = H5Gcreate2(file_id, "/g29", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g29/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "/g29/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group4_id = H5Gcreate2(file_id, "/g29/g1/g2/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group5_id = H5Gcreate2(file_id, "/g29/g1/g2/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g29", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g29/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "/g29/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group4_id = H5Gcreate2(file_id, "/g29/g1/g2/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group5_id = H5Gcreate2(file_id, "/g29/g1/g2/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Rename group */ - if(H5Lmove(file_id, "/g29/g1/g2/g1/g2", H5L_SAME_LOC, "/g29/g1/g2/g1/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g29/g1/g2/g1/g2", H5L_SAME_LOC, "/g29/g1/g2/g1/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "/g29/g1/g2/g1/g3", "/g29/g1/g2/g1/g3") < 0) TEST_ERROR + if (check_name(group5_id, "/g29/g1/g2/g1/g3", "/g29/g1/g2/g1/g3") < 0) + TEST_ERROR /* Rename group in middle of path, keeping within the same group */ - if(H5Lmove(file_id, "/g29/g1/g2/g1", H5L_SAME_LOC, "/g29/g1/g2/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g29/g1/g2/g1", H5L_SAME_LOC, "/g29/g1/g2/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g29/g1/g2/g3", "/g29/g1/g2/g3") < 0) TEST_ERROR - if(check_name(group5_id, "/g29/g1/g2/g3/g3", "/g29/g1/g2/g3/g3") < 0) TEST_ERROR + if (check_name(group4_id, "/g29/g1/g2/g3", "/g29/g1/g2/g3") < 0) + TEST_ERROR + if (check_name(group5_id, "/g29/g1/g2/g3/g3", "/g29/g1/g2/g3/g3") < 0) + TEST_ERROR /* Rename group in middle of path, moving to another group in file */ - if(H5Lmove(file_id, "/g29/g1/g2/g3", H5L_SAME_LOC, "/g29/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file_id, "/g29/g1/g2/g3", H5L_SAME_LOC, "/g29/g3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g29/g3", "/g29/g3") < 0) TEST_ERROR - if(check_name(group5_id, "/g29/g3/g3", "/g29/g3/g3") < 0) TEST_ERROR + if (check_name(group4_id, "/g29/g3", "/g29/g3") < 0) + TEST_ERROR + if (check_name(group5_id, "/g29/g3/g3", "/g29/g3/g3") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group5_id) < 0) + FAIL_STACK_ERROR PASSED(); - -/*------------------------------------------------------------------------- - * Test H5Iget_name with higher mounted file - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with higher mounted file + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with higher mounted file"); /* Create a group "/g30/g1/g2" in the first file */ - if((group_id = H5Gcreate2(file_id, "/g30", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g30/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "/g30/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g30", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g30/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "/g30/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -1962,9 +2533,12 @@ test_main(hid_t file_id, hid_t fapl) /* Create second file and group "/g31/g3/g4" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if((group_id = H5Gcreate2(file1_id, "/g31", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g31/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g31/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g31", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g31/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g31/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -1974,9 +2548,12 @@ test_main(hid_t file_id, hid_t fapl) /* Create third file and group "/g32/g5/g6" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if((group_id = H5Gcreate2(file2_id, "/g32", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file2_id, "/g32/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file2_id, "/g32/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file2_id, "/g32", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file2_id, "/g32/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file2_id, "/g32/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -1986,9 +2563,12 @@ test_main(hid_t file_id, hid_t fapl) /* Create fourth file and group "/g33/g5/g6" in it */ file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if((group_id = H5Gcreate2(file3_id, "/g33", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file3_id, "/g33/g7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file3_id, "/g33/g7/g8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file3_id, "/g33", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file3_id, "/g33/g7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file3_id, "/g33/g7/g8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -1996,73 +2576,102 @@ test_main(hid_t file_id, hid_t fapl) H5Gclose(group3_id); /* Access group which will be hidden in the first file */ - if((group_id = H5Gopen2(file_id, "/g30/g1/g2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, "/g30/g1/g2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g30/g1/g2", "/g30/g1/g2") < 0) TEST_ERROR + if (check_name(group_id, "/g30/g1/g2", "/g30/g1/g2") < 0) + TEST_ERROR /* Mount second file under "/g30/g1" in the first file */ - if(H5Fmount(file_id, "/g30/g1", file1_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(file_id, "/g30/g1", file1_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify */ - if(check_name(group_id, "", "/g30/g1/g2") < 0) TEST_ERROR + if (check_name(group_id, "", "/g30/g1/g2") < 0) + TEST_ERROR /* Access group which will be hidden in the second file */ - if((group2_id = H5Gopen2(file_id, "/g30/g1/g31/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "/g30/g1/g31/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g30/g1/g31/g3/g4", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR + if (check_name(group2_id, "/g30/g1/g31/g3/g4", "/g30/g1/g31/g3/g4") < 0) + TEST_ERROR /* Mount third file under "/g30/g1/g31/g3" in the first file */ - if(H5Fmount(file_id, "/g30/g1/g31/g3", file2_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(file_id, "/g30/g1/g31/g3", file2_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR + if (check_name(group2_id, "", "/g30/g1/g31/g3/g4") < 0) + TEST_ERROR /* Access group which will be hidden in the third file */ - if((group3_id = H5Gopen2(file_id, "/g30/g1/g31/g3/g32/g5/g6", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group3_id = H5Gopen2(file_id, "/g30/g1/g31/g3/g32/g5/g6", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g30/g1/g31/g3/g32/g5/g6", "/g30/g1/g31/g3/g32/g5/g6") < 0) TEST_ERROR + if (check_name(group3_id, "/g30/g1/g31/g3/g32/g5/g6", "/g30/g1/g31/g3/g32/g5/g6") < 0) + TEST_ERROR /* Mount fourth file under "/g30" in the first file, hiding the files below it */ - if(H5Fmount(file_id, "/g30", file3_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(file_id, "/g30", file3_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify */ - if(check_name(group3_id, "", "/g30/g1/g31/g3/g32/g5/g6") < 0) TEST_ERROR + if (check_name(group3_id, "", "/g30/g1/g31/g3/g32/g5/g6") < 0) + TEST_ERROR /* Access group which will be in the fourth file */ - if((group4_id = H5Gopen2(file_id, "/g30/g33/g7/g8", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group4_id = H5Gopen2(file_id, "/g30/g33/g7/g8", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g30/g33/g7/g8", "/g30/g33/g7/g8") < 0) TEST_ERROR + if (check_name(group4_id, "/g30/g33/g7/g8", "/g30/g33/g7/g8") < 0) + TEST_ERROR /* Unmount fourth file */ - if(H5Funmount(file_id, "/g30") < 0) TEST_ERROR + if (H5Funmount(file_id, "/g30") < 0) + TEST_ERROR /* Verify */ - if(check_name(group4_id, "/g33/g7/g8", "") < 0) TEST_ERROR - if(check_name(group3_id, "/g30/g1/g31/g3/g32/g5/g6", "/g30/g1/g31/g3/g32/g5/g6") < 0) TEST_ERROR - if(check_name(group2_id, "", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR - if(check_name(group_id, "", "/g30/g1/g2") < 0) TEST_ERROR + if (check_name(group4_id, "/g33/g7/g8", "") < 0) + TEST_ERROR + if (check_name(group3_id, "/g30/g1/g31/g3/g32/g5/g6", "/g30/g1/g31/g3/g32/g5/g6") < 0) + TEST_ERROR + if (check_name(group2_id, "", "/g30/g1/g31/g3/g4") < 0) + TEST_ERROR + if (check_name(group_id, "", "/g30/g1/g2") < 0) + TEST_ERROR /* Unmount third file */ - if(H5Funmount(file_id, "/g30/g1/g31/g3") < 0) TEST_ERROR + if (H5Funmount(file_id, "/g30/g1/g31/g3") < 0) + TEST_ERROR /* Verify */ - if(check_name(group4_id, "/g33/g7/g8", "") < 0) TEST_ERROR - if(check_name(group3_id, "/g32/g5/g6", "") < 0) TEST_ERROR - if(check_name(group2_id, "/g30/g1/g31/g3/g4", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR - if(check_name(group_id, "", "/g30/g1/g2") < 0) TEST_ERROR + if (check_name(group4_id, "/g33/g7/g8", "") < 0) + TEST_ERROR + if (check_name(group3_id, "/g32/g5/g6", "") < 0) + TEST_ERROR + if (check_name(group2_id, "/g30/g1/g31/g3/g4", "/g30/g1/g31/g3/g4") < 0) + TEST_ERROR + if (check_name(group_id, "", "/g30/g1/g2") < 0) + TEST_ERROR /* Unmount second file */ - if(H5Funmount(file_id, "/g30/g1") < 0) TEST_ERROR + if (H5Funmount(file_id, "/g30/g1") < 0) + TEST_ERROR /* Verify */ - if(check_name(group4_id, "/g33/g7/g8", "") < 0) TEST_ERROR - if(check_name(group3_id, "/g32/g5/g6", "") < 0) TEST_ERROR - if(check_name(group2_id, "/g31/g3/g4", "") < 0) TEST_ERROR - if(check_name(group_id, "/g30/g1/g2", "/g30/g1/g2") < 0) TEST_ERROR + if (check_name(group4_id, "/g33/g7/g8", "") < 0) + TEST_ERROR + if (check_name(group3_id, "/g32/g5/g6", "") < 0) + TEST_ERROR + if (check_name(group2_id, "/g31/g3/g4", "") < 0) + TEST_ERROR + if (check_name(group_id, "/g30/g1/g2", "/g30/g1/g2") < 0) + TEST_ERROR /* Close groups */ H5Gclose(group_id); @@ -2077,166 +2686,230 @@ test_main(hid_t file_id, hid_t fapl) PASSED(); - -/*------------------------------------------------------------------------- - * Test H5Iget_name with multiple hard links and mounted files - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with multiple hard links and mounted files + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with multiple hard links and mounted files"); /* Create second file and group "/g35/g3/g4" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file1_id, "/g35", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g35/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g35/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g35", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g35/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g35/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Create group "/g34/g1/g2" in first file */ - if((group_id = H5Gcreate2(file_id, "/g34", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g34/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "/g34/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g34", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g34/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "/g34/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create hard link to "/g34/g1/g2 group */ - if(H5Lcreate_hard(file_id, "/g34/g1/g2", H5L_SAME_LOC, "/g34/g2a", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(file_id, "/g34/g1/g2", H5L_SAME_LOC, "/g34/g2a", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g34/g1/g2", "/g34/g1/g2") < 0) TEST_ERROR + if (check_name(group3_id, "/g34/g1/g2", "/g34/g1/g2") < 0) + TEST_ERROR /* Open the link to the group */ - if((group4_id = H5Gopen2(file_id, "/g34/g2a", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group4_id = H5Gopen2(file_id, "/g34/g2a", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) TEST_ERROR + if (check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) + TEST_ERROR /* Mount second file under "/g34/g1" in the first file */ - if(H5Fmount(file_id, "/g34/g1", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g34/g1", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "", "/g34/g1/g2") < 0) TEST_ERROR - if(check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) TEST_ERROR + if (check_name(group3_id, "", "/g34/g1/g2") < 0) + TEST_ERROR + if (check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) + TEST_ERROR /* Unmount second file */ - if(H5Funmount(file_id, "/g34/g1") < 0) FAIL_STACK_ERROR + if (H5Funmount(file_id, "/g34/g1") < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group3_id, "/g34/g1/g2", "/g34/g1/g2") < 0) TEST_ERROR - if(check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) TEST_ERROR + if (check_name(group3_id, "/g34/g1/g2", "/g34/g1/g2") < 0) + TEST_ERROR + if (check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) + TEST_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR PASSED(); - - /*------------------------------------------------------------------------- - * Test H5Iget_name with mounted files and unlinking - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with mounted files and unlinking + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with mounted files and unlinking"); /* Create group "/g36/g1/g2" in first file */ - if((group_id = H5Gcreate2(file_id, "/g36", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "/g36/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file_id, "/g36/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, "/g36", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "/g36/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file_id, "/g36/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR /* Create second file and group "/g37/g4" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file1_id, "/g37", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g37/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g37/g4/g5a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group4_id = H5Gcreate2(file1_id, "/g37/g4/g5b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g37", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g37/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g37/g4/g5a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group4_id = H5Gcreate2(file1_id, "/g37/g4/g5b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Mount second file under "/g36/g1" in the first file */ - if(H5Fmount(file_id, "/g36/g1", file1_id, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file_id, "/g36/g1", file1_id, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open group in mounted file */ - if((group5_id = H5Gopen2(file_id, "/g36/g1/g37/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group5_id = H5Gopen2(file_id, "/g36/g1/g37/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group5_id, "/g36/g1/g37", "/g36/g1/g37") < 0) TEST_ERROR + if (check_name(group5_id, "/g36/g1/g37", "/g36/g1/g37") < 0) + TEST_ERROR /* Open group to delete in mounted file */ - if((group6_id = H5Gopen2(file_id, "/g36/g1/g37/g4/g5a", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group6_id = H5Gopen2(file_id, "/g36/g1/g37/g4/g5a", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group6_id, "/g36/g1/g37/g4/g5a", "/g36/g1/g37/g4/g5a") < 0) TEST_ERROR + if (check_name(group6_id, "/g36/g1/g37/g4/g5a", "/g36/g1/g37/g4/g5a") < 0) + TEST_ERROR /* Delete end group in mounted file, using relative paths */ - if(H5Ldelete(group5_id, "g4/g5a", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(group5_id, "g4/g5a", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group6_id, "", "") < 0) TEST_ERROR - if(check_name(group3_id, "", "") < 0) TEST_ERROR + if (check_name(group6_id, "", "") < 0) + TEST_ERROR + if (check_name(group3_id, "", "") < 0) + TEST_ERROR /* Close deleted group */ - if(H5Gclose(group6_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group6_id) < 0) + FAIL_STACK_ERROR /* Open groups to delete in mounted file */ - if((group6_id = H5Gopen2(file_id, "/g36/g1/g37/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group7_id = H5Gopen2(file_id, "/g36/g1/g37/g4/g5b", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group6_id = H5Gopen2(file_id, "/g36/g1/g37/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group7_id = H5Gopen2(file_id, "/g36/g1/g37/g4/g5b", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group6_id, "/g36/g1/g37/g4", "/g36/g1/g37/g4") < 0) TEST_ERROR - if(check_name(group7_id, "/g36/g1/g37/g4/g5b", "/g36/g1/g37/g4/g5b") < 0) TEST_ERROR + if (check_name(group6_id, "/g36/g1/g37/g4", "/g36/g1/g37/g4") < 0) + TEST_ERROR + if (check_name(group7_id, "/g36/g1/g37/g4/g5b", "/g36/g1/g37/g4/g5b") < 0) + TEST_ERROR /* Delete middle group in mounted file, using relative paths */ - if(H5Ldelete(group5_id, "g4", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(group5_id, "g4", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group6_id, "", "") < 0) TEST_ERROR - if(check_name(group2_id, "", "") < 0) TEST_ERROR - if(check_name(group7_id, "", "") < 0) TEST_ERROR - if(check_name(group4_id, "", "") < 0) TEST_ERROR + if (check_name(group6_id, "", "") < 0) + TEST_ERROR + if (check_name(group2_id, "", "") < 0) + TEST_ERROR + if (check_name(group7_id, "", "") < 0) + TEST_ERROR + if (check_name(group4_id, "", "") < 0) + TEST_ERROR /* Close deleted groups */ - if(H5Gclose(group6_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group7_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group6_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group7_id) < 0) + FAIL_STACK_ERROR /* Close group in mounted file */ - if(H5Gclose(group5_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group5_id) < 0) + FAIL_STACK_ERROR - if(H5Funmount(file_id, "/g36/g1") < 0) FAIL_STACK_ERROR + if (H5Funmount(file_id, "/g36/g1") < 0) + FAIL_STACK_ERROR /* Close */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1_id) < 0) + FAIL_STACK_ERROR PASSED(); - -/*------------------------------------------------------------------------- - * Test H5Iget_name with mounting already mounted files - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with mounting already mounted files + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with mounting already mounted files"); /* Create file and group "/g38/g1/g2" in it */ - if((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file1_id, "/g38", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g38/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g38/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g38", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g38/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g38/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -2244,11 +2917,15 @@ test_main(hid_t file_id, hid_t fapl) H5Gclose(group3_id); /* Create second file and group "/g39/g1/g2" in it */ - if((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file2_id, "/g39", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file2_id, "/g39/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file2_id, "/g39/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file2_id, "/g39", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file2_id, "/g39/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file2_id, "/g39/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -2256,11 +2933,15 @@ test_main(hid_t file_id, hid_t fapl) H5Gclose(group3_id); /* Create third file and group "/g40/g5/g6" in it */ - if((file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR - if((group_id = H5Gcreate2(file3_id, "/g40", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file3_id, "/g40/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file3_id, "/g40/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file3_id, "/g40", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file3_id, "/g40/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file3_id, "/g40/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -2268,34 +2949,46 @@ test_main(hid_t file_id, hid_t fapl) H5Gclose(group3_id); /* Mount second file under "/g38/g1" in the first file */ - if(H5Fmount(file1_id, "/g38/g1", file2_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(file1_id, "/g38/g1", file2_id, H5P_DEFAULT) < 0) + TEST_ERROR - if((group_id = H5Gopen2(file1_id, "/g38/g1/g39/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file1_id, "/g38/g1/g39/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) TEST_ERROR + if (check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) + TEST_ERROR /* Mount first file under "/g40/g5" in the third file */ - if(H5Fmount(file3_id, "/g40/g5", file1_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(file3_id, "/g40/g5", file1_id, H5P_DEFAULT) < 0) + TEST_ERROR - if((group2_id = H5Gopen2(file3_id, "/g40/g5/g38/g1/g39/g3/g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file3_id, "/g40/g5/g38/g1/g39/g3/g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g40/g5/g38/g1/g39/g3/g4", "/g40/g5/g38/g1/g39/g3/g4") < 0) TEST_ERROR - if(check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) TEST_ERROR + if (check_name(group2_id, "/g40/g5/g38/g1/g39/g3/g4", "/g40/g5/g38/g1/g39/g3/g4") < 0) + TEST_ERROR + if (check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) + TEST_ERROR /* Unmount first file */ - if(H5Funmount(file3_id, "/g40/g5") < 0) TEST_ERROR + if (H5Funmount(file3_id, "/g40/g5") < 0) + TEST_ERROR /* Verify */ - if(check_name(group2_id, "/g38/g1/g39/g3/g4", "") < 0) TEST_ERROR - if(check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) TEST_ERROR + if (check_name(group2_id, "/g38/g1/g39/g3/g4", "") < 0) + TEST_ERROR + if (check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) + TEST_ERROR /* Unmount second file */ - if(H5Funmount(file1_id, "/g38/g1") < 0) TEST_ERROR + if (H5Funmount(file1_id, "/g38/g1") < 0) + TEST_ERROR /* Verify */ - if(check_name(group_id, "/g39/g3/g4", "") < 0) TEST_ERROR + if (check_name(group_id, "/g39/g3/g4", "") < 0) + TEST_ERROR /* Close */ H5Gclose(group_id); @@ -2306,19 +2999,22 @@ test_main(hid_t file_id, hid_t fapl) PASSED(); -/*------------------------------------------------------------------------- - * Test H5Iget_name with opening object in unmounted file - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Iget_name with opening object in unmounted file + *------------------------------------------------------------------------- + */ TESTING("H5Iget_name with opening object in unmounted file"); /* Create file and group "/g39/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if((group_id = H5Gcreate2(file1_id, "/g41", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file1_id, "/g41/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file1_id, "/g41/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file1_id, "/g41", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file1_id, "/g41/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file1_id, "/g41/g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -2328,9 +3024,12 @@ test_main(hid_t file_id, hid_t fapl) /* Create second file and group "/g42/g1/g2" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if((group_id = H5Gcreate2(file2_id, "/g42", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file2_id, "/g42/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group3_id = H5Gcreate2(file2_id, "/g42/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file2_id, "/g42", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file2_id, "/g42/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group3_id = H5Gcreate2(file2_id, "/g42/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close */ H5Gclose(group_id); @@ -2338,20 +3037,26 @@ test_main(hid_t file_id, hid_t fapl) H5Gclose(group3_id); /* Mount second file under "/g41/g1" in the first file */ - if(H5Fmount(file1_id, "/g41/g1", file2_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(file1_id, "/g41/g1", file2_id, H5P_DEFAULT) < 0) + TEST_ERROR - if((group_id = H5Gopen2(file1_id, "/g41/g1/g42/g3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file1_id, "/g41/g1/g42/g3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group_id, "/g41/g1/g42/g3", "/g41/g1/g42/g3") < 0) TEST_ERROR + if (check_name(group_id, "/g41/g1/g42/g3", "/g41/g1/g42/g3") < 0) + TEST_ERROR /* Unmount file */ - if(H5Funmount(file1_id, "/g41/g1") < 0) TEST_ERROR + if (H5Funmount(file1_id, "/g41/g1") < 0) + TEST_ERROR - if((group2_id = H5Gopen2(group_id, "g4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(group_id, "g4", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify */ - if(check_name(group2_id, "/g42/g3/g4", "") < 0) TEST_ERROR + if (check_name(group2_id, "/g42/g3/g4", "") < 0) + TEST_ERROR /* Close */ H5Gclose(group_id); @@ -2368,47 +3073,67 @@ test_main(hid_t file_id, hid_t fapl) TESTING("H5Iget_name with anonymous datatypes"); /* Commit the type anonymously and link it in */ - if((dtype = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((dtype = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* Test H5Iget_name with created datatype, should fail because not committed */ - H5E_BEGIN_TRY { - if((size = H5Iget_name(dtype, NULL, 0)) >= 0) TEST_ERROR - } H5E_END_TRY; - - if(H5Tcommit_anon(file2_id, dtype, H5P_DEFAULT, H5P_DEFAULT)) TEST_ERROR + H5E_BEGIN_TRY + { + if ((size = H5Iget_name(dtype, NULL, 0)) >= 0) + TEST_ERROR + } + H5E_END_TRY; + + if (H5Tcommit_anon(file2_id, dtype, H5P_DEFAULT, H5P_DEFAULT)) + TEST_ERROR /* Test H5Iget_name with anonymously created datatype, should pass because committed */ - if((size = H5Iget_name(dtype, NULL, 0)) != 0) TEST_ERROR + if ((size = H5Iget_name(dtype, NULL, 0)) != 0) + TEST_ERROR /* Create a link to the object */ - if(H5Olink(dtype, file2_id, "datatype", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Olink(dtype, file2_id, "datatype", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Commit a second datatype with no links to it and commit it */ - if((dtype_anon = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit_anon(file2_id, dtype_anon, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if ((dtype_anon = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit_anon(file2_id, dtype_anon, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Test H5Iget_name with anonymously created datatype, should pass because committed */ - if((size = H5Iget_name(dtype_anon, NULL,0)) != 0) TEST_ERROR + if ((size = H5Iget_name(dtype_anon, NULL, 0)) != 0) + TEST_ERROR /* Store the address of the datatype for later use */ - if(H5Oget_info3(dtype_anon, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(dtype_anon, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR /* Update the reference count to dtype_anon to preserve the datatype */ - if(H5Oincr_refcount(dtype_anon) < 0) TEST_ERROR + if (H5Oincr_refcount(dtype_anon) < 0) + TEST_ERROR - if(H5Tclose(dtype) < 0) TEST_ERROR - if(H5Tclose(dtype_anon) < 0) TEST_ERROR - if(H5Fclose(file2_id) < 0) TEST_ERROR + if (H5Tclose(dtype) < 0) + TEST_ERROR + if (H5Tclose(dtype_anon) < 0) + TEST_ERROR + if (H5Fclose(file2_id) < 0) + TEST_ERROR /* Re-open the file and check that the anonymous datatypes persist */ - if((file2_id = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file2_id = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Check the H5Iget_name does not return an error for anon committed datatypes */ - if((dtype_anon = H5Oopen_by_token(file2_id, oinfo.token)) < 0) TEST_ERROR + if ((dtype_anon = H5Oopen_by_token(file2_id, oinfo.token)) < 0) + TEST_ERROR - if((size = H5Iget_name(dtype_anon, NULL, 0)) != 0) TEST_ERROR + if ((size = H5Iget_name(dtype_anon, NULL, 0)) != 0) + TEST_ERROR - if(H5Tclose(dtype_anon) < 0) TEST_ERROR - if(H5Fclose(file2_id) < 0) TEST_ERROR + if (H5Tclose(dtype_anon) < 0) + TEST_ERROR + if (H5Fclose(file2_id) < 0) + TEST_ERROR PASSED(); @@ -2421,302 +3146,350 @@ error: static int test_obj_ref(hid_t fapl) { - char filename1[1024]; - char filename2[1024]; - hid_t fid1, fid2; /* HDF5 File IDs */ - hid_t dataset, dataset2; /* Dataset ID */ - hid_t group, group2; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hobj_ref_t wbuf[SPACE1_DIM1]; /* Buffer to write to disk */ - int tu32[SPACE1_DIM1]; /* Int data */ - ssize_t namelen; /* Length of the name */ - int i; /* counting variables */ - char buf[100]; + char filename1[1024]; + char filename2[1024]; + hid_t fid1, fid2; /* HDF5 File IDs */ + hid_t dataset, dataset2; /* Dataset ID */ + hid_t group, group2; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hobj_ref_t wbuf[SPACE1_DIM1]; /* Buffer to write to disk */ + int tu32[SPACE1_DIM1]; /* Int data */ + ssize_t namelen; /* Length of the name */ + int i; /* counting variables */ + char buf[100]; /* Initialize the file names */ h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[2], fapl, filename2, sizeof filename2); /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create dataspace for datasets */ - if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) + if ((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) FAIL_STACK_ERROR /* Create a group */ - if((group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a single dataset inside the second file, which will be mounted * and used to mask objects in the first file */ - if((dataset = H5Dcreate2(fid2, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(fid2, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR /* Create a dataset(inside Group1) */ - if((dataset = H5Dcreate2(group, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(group, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize data buffer */ - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) tu32[i] = i * 3; /* Write selection to disk */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tu32) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tu32) < 0) FAIL_STACK_ERROR /* Close Dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR /* Create another dataset(inside Group1) */ - if((dataset = H5Dcreate2(group, "Dataset2", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(group, "Dataset2", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close Dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR /* Create a datatype to refer to */ - if((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0) + if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0) FAIL_STACK_ERROR /* Insert fields */ - if(H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT) < 0) FAIL_STACK_ERROR - if(H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0) + if (H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0) FAIL_STACK_ERROR - if(H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) + if (H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) FAIL_STACK_ERROR /* Save datatype for later */ - if(H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Close datatype */ - if(H5Tclose(tid1) < 0) + if (H5Tclose(tid1) < 0) FAIL_STACK_ERROR /* Create a new group in group1 */ - if((group2 = H5Gcreate2(group, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2 = H5Gcreate2(group, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a hard link to group1 in group2 */ - if(H5Lcreate_hard(fid1, "/Group1", H5L_SAME_LOC, "/Group1/Group2/Link", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(fid1, "/Group1", H5L_SAME_LOC, "/Group1/Group2/Link", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Create dataset in that group */ - if((dataset = H5Dcreate2(group2, "Dataset4", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(group2, "Dataset4", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close Dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(group) < 0) + if (H5Gclose(group) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2) < 0) + if (H5Gclose(group2) < 0) FAIL_STACK_ERROR /* Open up that hard link and make a new dataset there */ - if((group = H5Gopen2(fid1, "/Group1/Group2/Link", H5P_DEFAULT)) < 0) + if ((group = H5Gopen2(fid1, "/Group1/Group2/Link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((dataset = H5Dcreate2(group, "Dataset5", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(group, "Dataset5", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR - if(H5Gclose(group) < 0) + if (H5Gclose(group) < 0) FAIL_STACK_ERROR - /* Create a dataset to store references */ - if((dataset = H5Dcreate2(fid1, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(fid1, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create reference to dataset */ - if(H5Rcreate(&wbuf[0], fid1, "/Dataset3", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&wbuf[0], fid1, "/Dataset3", H5R_OBJECT, (hid_t)-1) < 0) FAIL_STACK_ERROR /* Create reference to dataset */ - if(H5Rcreate(&wbuf[1], fid1, "/Group1/Dataset2", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&wbuf[1], fid1, "/Group1/Dataset2", H5R_OBJECT, (hid_t)-1) < 0) FAIL_STACK_ERROR /* Create reference to group */ - if(H5Rcreate(&wbuf[2], fid1, "/Group1", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&wbuf[2], fid1, "/Group1", H5R_OBJECT, (hid_t)-1) < 0) FAIL_STACK_ERROR /* Create reference to named datatype */ - if(H5Rcreate(&wbuf[3], fid1, "/Group1/Datatype1", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&wbuf[3], fid1, "/Group1/Datatype1", H5R_OBJECT, (hid_t)-1) < 0) FAIL_STACK_ERROR - if(H5Rcreate(&wbuf[4], fid1, "/Group1/Group2/Dataset4", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&wbuf[4], fid1, "/Group1/Group2/Dataset4", H5R_OBJECT, (hid_t)-1) < 0) FAIL_STACK_ERROR - if(H5Rcreate(&wbuf[5], fid1, "/Group1/Group2", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&wbuf[5], fid1, "/Group1/Group2", H5R_OBJECT, (hid_t)-1) < 0) FAIL_STACK_ERROR - if(H5Rcreate(&wbuf[6], fid1, "/Group1/Group2/Link/Dataset5", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&wbuf[6], fid1, "/Group1/Group2/Link/Dataset5", H5R_OBJECT, (hid_t)-1) < 0) FAIL_STACK_ERROR /* Create reference to root group */ - if(H5Rcreate(&wbuf[7], fid1, "/", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&wbuf[7], fid1, "/", H5R_OBJECT, (hid_t)-1) < 0) FAIL_STACK_ERROR /* Write selection to disk */ - if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) FAIL_STACK_ERROR TESTING("getting path to normal dataset in root group"); - if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[0])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); - if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR - if(!((HDstrcmp(buf, "/Dataset3") == 0) &&(namelen == 9))) TEST_ERROR + if ((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[0])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(dataset2, (char *)buf, sizeof(buf)); + if (H5Dclose(dataset2) < 0) + FAIL_STACK_ERROR + if (!((HDstrcmp(buf, "/Dataset3") == 0) && (namelen == 9))) + TEST_ERROR *buf = '\0'; /* Check H5Rget_name returns the correct length of the name when name is NULL */ namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], NULL, 0); - if(namelen != 9) TEST_ERROR + if (namelen != 9) + TEST_ERROR /* Make sure size parameter is ignored */ namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], NULL, 200); - if(namelen != 9) TEST_ERROR + if (namelen != 9) + TEST_ERROR - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], (char*)buf, sizeof(buf)); - if(!((HDstrcmp(buf, "/Dataset3") == 0) &&(namelen == 9))) TEST_ERROR + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], (char *)buf, sizeof(buf)); + if (!((HDstrcmp(buf, "/Dataset3") == 0) && (namelen == 9))) + TEST_ERROR PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in /Group1"); - if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[1])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); - if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR - if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) &&(namelen == 16))) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf)); - if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) &&(namelen == 16))) TEST_ERROR + if ((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[1])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(dataset2, (char *)buf, sizeof(buf)); + if (H5Dclose(dataset2) < 0) + FAIL_STACK_ERROR + if (!((HDstrcmp(buf, "/Group1/Dataset2") == 0) && (namelen == 16))) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char *)buf, sizeof(buf)); + if (!((HDstrcmp(buf, "/Group1/Dataset2") == 0) && (namelen == 16))) + TEST_ERROR PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to /Group1"); - if((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[2])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(group, (char*)buf, sizeof(buf)); - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(!((HDstrcmp(buf, "/Group1") == 0) &&(namelen == 7))) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[2], (char*)buf, sizeof(buf)); - if(!((HDstrcmp(buf, "/Group1") == 0) &&(namelen == 7))) TEST_ERROR + if ((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[2])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(group, (char *)buf, sizeof(buf)); + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (!((HDstrcmp(buf, "/Group1") == 0) && (namelen == 7))) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[2], (char *)buf, sizeof(buf)); + if (!((HDstrcmp(buf, "/Group1") == 0) && (namelen == 7))) + TEST_ERROR PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to datatype in /Group1"); - if((tid1 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[3])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(tid1, (char*)buf, sizeof(buf)); - if(H5Tclose(tid1) < 0) FAIL_STACK_ERROR - if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) &&(namelen == 17))) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[3], (char*)buf, sizeof(buf)); - if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) &&(namelen == 17))) TEST_ERROR + if ((tid1 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[3])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(tid1, (char *)buf, sizeof(buf)); + if (H5Tclose(tid1) < 0) + FAIL_STACK_ERROR + if (!((HDstrcmp(buf, "/Group1/Datatype1") == 0) && (namelen == 17))) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[3], (char *)buf, sizeof(buf)); + if (!((HDstrcmp(buf, "/Group1/Datatype1") == 0) && (namelen == 17))) + TEST_ERROR PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in nested group"); - if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); - if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR - if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) &&(namelen == 23))) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf)); - if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) &&(namelen == 23))) TEST_ERROR + if ((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[4])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(dataset2, (char *)buf, sizeof(buf)); + if (H5Dclose(dataset2) < 0) + FAIL_STACK_ERROR + if (!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) && (namelen == 23))) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char *)buf, sizeof(buf)); + if (!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) && (namelen == 23))) + TEST_ERROR PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to nested group"); - if((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[5])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(group, (char*)buf, sizeof(buf)); - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(!((HDstrcmp(buf, "/Group1/Group2") == 0) &&(namelen == 14))) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[5], (char*)buf, sizeof(buf)); - if(!((HDstrcmp(buf, "/Group1/Group2") == 0) &&(namelen == 14))) TEST_ERROR + if ((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[5])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(group, (char *)buf, sizeof(buf)); + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (!((HDstrcmp(buf, "/Group1/Group2") == 0) && (namelen == 14))) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[5], (char *)buf, sizeof(buf)); + if (!((HDstrcmp(buf, "/Group1/Group2") == 0) && (namelen == 14))) + TEST_ERROR PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset created via hard link"); - if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[6])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); - if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR - if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) &&(namelen == 16))) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[6], (char*)buf, sizeof(buf)); - if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) &&(namelen == 16))) TEST_ERROR + if ((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[6])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(dataset2, (char *)buf, sizeof(buf)); + if (H5Dclose(dataset2) < 0) + FAIL_STACK_ERROR + if (!((HDstrcmp(buf, "/Group1/Dataset5") == 0) && (namelen == 16))) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[6], (char *)buf, sizeof(buf)); + if (!((HDstrcmp(buf, "/Group1/Dataset5") == 0) && (namelen == 16))) + TEST_ERROR PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to root group"); - if((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[7])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(group, (char*)buf, sizeof(buf)); - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(!((HDstrcmp(buf, "/") == 0) &&(namelen == 1))) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[7], (char*)buf, sizeof(buf)); - if(!((HDstrcmp(buf, "/") == 0) &&(namelen == 1))) TEST_ERROR + if ((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[7])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(group, (char *)buf, sizeof(buf)); + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (!((HDstrcmp(buf, "/") == 0) && (namelen == 1))) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[7], (char *)buf, sizeof(buf)); + if (!((HDstrcmp(buf, "/") == 0) && (namelen == 1))) + TEST_ERROR PASSED(); /* Now we mount fid2 at /Group2 and look for dataset4. It shouldn't be found */ - if(H5Fmount(fid1, "/Group1/Group2", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/Group1/Group2", fid2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR TESTING("getting path to dataset hidden by a mounted file"); - if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR - *buf = '\0'; - namelen = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); - if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR - if(namelen != 0) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf)); - if(namelen != 0) TEST_ERROR + if ((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[4])) < 0) + FAIL_STACK_ERROR + *buf = '\0'; + namelen = H5Iget_name(dataset2, (char *)buf, sizeof(buf)); + if (H5Dclose(dataset2) < 0) + FAIL_STACK_ERROR + if (namelen != 0) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char *)buf, sizeof(buf)); + if (namelen != 0) + TEST_ERROR PASSED(); /* Now we try unlinking dataset2 from the file and searching for it. It shouldn't be found */ - if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[1])) < 0) + if ((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[1])) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid1, "/Group1/Dataset2", H5P_DEFAULT) < 0) + if (H5Ldelete(fid1, "/Group1/Dataset2", H5P_DEFAULT) < 0) FAIL_STACK_ERROR TESTING("getting path to dataset that has been unlinked"); - *buf = '\0'; - namelen = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); - if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR - if(namelen != 0) TEST_ERROR - *buf = '\0'; - namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf)); - if(namelen != 0) TEST_ERROR + *buf = '\0'; + namelen = H5Iget_name(dataset2, (char *)buf, sizeof(buf)); + if (H5Dclose(dataset2) < 0) + FAIL_STACK_ERROR + if (namelen != 0) + TEST_ERROR + *buf = '\0'; + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char *)buf, sizeof(buf)); + if (namelen != 0) + TEST_ERROR PASSED(); /* Close disk dataspace */ - if(H5Sclose(sid1) < 0) + if (H5Sclose(sid1) < 0) FAIL_STACK_ERROR /* Close Dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR return 0; @@ -2728,51 +3501,53 @@ error: static int test_reg_ref(hid_t fapl) { - char filename1[1024]; - hid_t file_id; /* file identifier */ - hid_t dsetv_id; /*dataset identifiers*/ - hid_t dsetr_id; - hid_t space_id, spacer_id; - hsize_t dims[2] = {2,9}; - hsize_t dimsr[1] = {2}; - int rank = 2; - int rankr = 1; + char filename1[1024]; + hid_t file_id; /* file identifier */ + hid_t dsetv_id; /*dataset identifiers*/ + hid_t dsetr_id; + hid_t space_id, spacer_id; + hsize_t dims[2] = {2, 9}; + hsize_t dimsr[1] = {2}; + int rank = 2; + int rankr = 1; hdset_reg_ref_t ref[2]; hdset_reg_ref_t ref_out[2]; - int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}}; - hsize_t start[2]; - hsize_t count[2]; - hsize_t coord[2][3] = {{0, 0, 1}, {6, 0, 8}}; - unsigned num_points = 3; - ssize_t name_size1, name_size2; - char buf1[NAME_BUF_SIZE], buf2[NAME_BUF_SIZE]; + int data[2][9] = {{1, 1, 2, 3, 3, 4, 5, 5, 6}, {1, 2, 2, 3, 4, 4, 5, 6, 6}}; + hsize_t start[2]; + hsize_t count[2]; + hsize_t coord[2][3] = {{0, 0, 1}, {6, 0, 8}}; + unsigned num_points = 3; + ssize_t name_size1, name_size2; + char buf1[NAME_BUF_SIZE], buf2[NAME_BUF_SIZE]; /* Initialize the file name */ h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1); /* Create file with default file create property but vfd access property. */ - if((file_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR + if ((file_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create dataspace for datasets */ - if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) - TEST_ERROR - if((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) - TEST_ERROR + if ((space_id = H5Screate_simple(rank, dims, NULL)) < 0) + TEST_ERROR + if ((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) + TEST_ERROR /* Create integer dataset */ - if((dsetv_id = H5Dcreate2(file_id, REFREG_DSETNAMEV, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR + if ((dsetv_id = H5Dcreate2(file_id, REFREG_DSETNAMEV, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR - /* Write data to the dataset */ - if(H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT, data) < 0) - TEST_ERROR - if(H5Dclose(dsetv_id) < 0) - TEST_ERROR + /* Write data to the dataset */ + if (H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + TEST_ERROR + if (H5Dclose(dsetv_id) < 0) + TEST_ERROR /* Dataset with references */ - if((dsetr_id = H5Dcreate2(file_id, REFREG_DSETNAMER, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR + if ((dsetr_id = H5Dcreate2(file_id, REFREG_DSETNAMER, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* * Create a reference to the hyperslab. @@ -2781,44 +3556,43 @@ test_reg_ref(hid_t fapl) start[1] = 3; count[0] = 2; count[1] = 3; - if(H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) - TEST_ERROR - if(H5Rcreate(&ref[0], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id) < 0) - TEST_ERROR + if (H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + TEST_ERROR + if (H5Rcreate(&ref[0], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id) < 0) + TEST_ERROR /* Create a reference to elements selection */ - if(H5Sselect_none(space_id) < 0) - TEST_ERROR - if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) - TEST_ERROR - if(H5Rcreate(&ref[1], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id) < 0) - TEST_ERROR + if (H5Sselect_none(space_id) < 0) + TEST_ERROR + if (H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) + TEST_ERROR + if (H5Rcreate(&ref[1], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id) < 0) + TEST_ERROR /* Write dataset with the references */ - if(H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) - TEST_ERROR + if (H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) + TEST_ERROR /* Close all objects */ - if(H5Sclose(space_id) < 0) - TEST_ERROR - if(H5Sclose(spacer_id) < 0) - TEST_ERROR - if(H5Dclose(dsetr_id) < 0) - TEST_ERROR - if(H5Fclose(file_id) < 0) - TEST_ERROR - + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (H5Sclose(spacer_id) < 0) + TEST_ERROR + if (H5Dclose(dsetr_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Reopen the file to read selections back */ - if((file_id = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR + if ((file_id = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Reopen the dataset with object references and read references to the buffer */ - if((dsetr_id = H5Dopen2(file_id, REFREG_DSETNAMER, H5P_DEFAULT)) < 0) - TEST_ERROR + if ((dsetr_id = H5Dopen2(file_id, REFREG_DSETNAMER, H5P_DEFAULT)) < 0) + TEST_ERROR - if(H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out) < 0) - TEST_ERROR + if (H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out) < 0) + TEST_ERROR /* Get name of the dataset the first region reference points to using H5Rget_name */ TESTING("H5Rget_name to get name from region reference(hyperslab)"); @@ -2826,10 +3600,12 @@ test_reg_ref(hid_t fapl) /* Check H5Rget_name returns the correct length of the name when name is NULL */ name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], NULL, 0); - if(name_size1 != 7) TEST_ERROR + if (name_size1 != 7) + TEST_ERROR - name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, NAME_BUF_SIZE ); - if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR + name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char *)buf1, NAME_BUF_SIZE); + if (!((HDstrcmp(buf1, "/MATRIX") == 0) && (name_size1 == 7))) + TEST_ERROR PASSED(); TESTING("H5Iget_name to get name from region reference(hyperslab)"); @@ -2838,39 +3614,45 @@ test_reg_ref(hid_t fapl) dsetv_id = H5Rdereference2(dsetr_id, H5P_DEFAULT, H5R_DATASET_REGION, &ref_out[0]); /* Get name of the dataset the first region reference points using H5Iget_name */ - *buf2 = '\0'; - name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE); - if(!((HDstrcmp(buf2, "/MATRIX") == 0) &&(name_size2 == 7))) TEST_ERROR + *buf2 = '\0'; + name_size2 = H5Iget_name(dsetv_id, (char *)buf2, NAME_BUF_SIZE); + if (!((HDstrcmp(buf2, "/MATRIX") == 0) && (name_size2 == 7))) + TEST_ERROR - if(H5Dclose(dsetv_id) < 0) TEST_ERROR + if (H5Dclose(dsetv_id) < 0) + TEST_ERROR PASSED(); /* Get name of the dataset the second region reference points to using H5Rget_name */ TESTING("H5Rget_name to get name from region reference(pnt selec)"); - *buf1 = '\0'; - name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1], (char*)buf1, NAME_BUF_SIZE); - if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR + *buf1 = '\0'; + name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1], (char *)buf1, NAME_BUF_SIZE); + if (!((HDstrcmp(buf1, "/MATRIX") == 0) && (name_size1 == 7))) + TEST_ERROR PASSED(); TESTING("H5Iget_name to get name from region reference(pnt selec)"); /* Dereference the second reference */ - if((dsetv_id = H5Rdereference2(dsetr_id, H5P_DEFAULT, H5R_DATASET_REGION, &ref_out[1])) < 0) TEST_ERROR + if ((dsetv_id = H5Rdereference2(dsetr_id, H5P_DEFAULT, H5R_DATASET_REGION, &ref_out[1])) < 0) + TEST_ERROR /* Get name of the dataset the first region reference points using H5Iget_name */ - *buf2 = '\0'; - name_size2 = H5Iget_name(dsetv_id, (char*)buf2, NAME_BUF_SIZE); - if(!((HDstrcmp(buf2, "/MATRIX") == 0) &&(name_size2 == 7))) TEST_ERROR + *buf2 = '\0'; + name_size2 = H5Iget_name(dsetv_id, (char *)buf2, NAME_BUF_SIZE); + if (!((HDstrcmp(buf2, "/MATRIX") == 0) && (name_size2 == 7))) + TEST_ERROR - if(H5Dclose(dsetv_id) < 0) TEST_ERROR + if (H5Dclose(dsetv_id) < 0) + TEST_ERROR PASSED(); - if(H5Dclose(dsetr_id) < 0) - TEST_ERROR - if(H5Fclose(file_id) < 0) - TEST_ERROR + if (H5Dclose(dsetr_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR return 0; @@ -2878,7 +3660,6 @@ error: return 1; } - /*------------------------------------------------------------------------- * Function: test_elinks * @@ -2897,73 +3678,74 @@ error: static int test_elinks(hid_t fapl) { - char filename1[1024], filename2[1024]; /* Filenames */ - hid_t fid1, fid2; /* HDF5 File IDs */ - hid_t group, group2; /* Group IDs */ - char name[NAME_BUF_SIZE]; /* Buffer for storing object's name */ - ssize_t namelen; /* Length of object's name */ - hbool_t name_cached; /* Indicate if name is cached */ + char filename1[1024], filename2[1024]; /* Filenames */ + hid_t fid1, fid2; /* HDF5 File IDs */ + hid_t group, group2; /* Group IDs */ + char name[NAME_BUF_SIZE]; /* Buffer for storing object's name */ + ssize_t namelen; /* Length of object's name */ + hbool_t name_cached; /* Indicate if name is cached */ /* Initialize the file names */ h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[2], fapl, filename2, sizeof filename2); /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create a group in the second file */ - if((group2 = H5Gcreate2(fid2, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((group2 = H5Gcreate2(fid2, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close Group */ - if(H5Gclose(group2) < 0) + if (H5Gclose(group2) < 0) FAIL_STACK_ERROR /* Create an external link in first file to the group in the second file */ - if(H5Lcreate_external(filename2, "Group2", fid1, "Link_to_Group2", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_external(filename2, "Group2", fid1, "Link_to_Group2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Create an external link in second file to the external link in the first file */ - if(H5Lcreate_external(filename1, "Link_to_Group2", fid2, "Link_to_Link_to_Group2", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_external(filename1, "Link_to_Group2", fid2, "Link_to_Link_to_Group2", H5P_DEFAULT, + H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Open the group in thesecond file through the external link */ - if((group = H5Gopen2(fid1, "Link_to_Group2", H5P_DEFAULT)) < 0) + if ((group = H5Gopen2(fid1, "Link_to_Group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Query the external link object's name */ - *name = '\0'; + *name = '\0'; name_cached = FALSE; - namelen = H5I__get_name_test(group, (char*)name, sizeof(name), &name_cached); - if(!((HDstrcmp(name, "/Group2") == 0) && (namelen == 7) && name_cached)) + namelen = H5I__get_name_test(group, (char *)name, sizeof(name), &name_cached); + if (!((HDstrcmp(name, "/Group2") == 0) && (namelen == 7) && name_cached)) TEST_ERROR /* Close Group */ - if(H5Gclose(group) < 0) + if (H5Gclose(group) < 0) FAIL_STACK_ERROR /* Open the group in the second file through the external link to the external link */ - if((group = H5Gopen2(fid2, "Link_to_Link_to_Group2", H5P_DEFAULT)) < 0) + if ((group = H5Gopen2(fid2, "Link_to_Link_to_Group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Query the external link to external link object's name */ - *name = '\0'; + *name = '\0'; name_cached = FALSE; - namelen = H5I__get_name_test(group, (char*)name, sizeof(name), &name_cached); - if(!((HDstrcmp(name, "/Group2") == 0) && (namelen == 7) && name_cached)) + namelen = H5I__get_name_test(group, (char *)name, sizeof(name), &name_cached); + if (!((HDstrcmp(name, "/Group2") == 0) && (namelen == 7) && name_cached)) TEST_ERROR /* Close Group */ - if(H5Gclose(group) < 0) + if (H5Gclose(group) < 0) FAIL_STACK_ERROR /* Close files */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR return 0; @@ -2975,10 +3757,10 @@ error: int main(void) { - hid_t file_id =(-1); - int nerrors = 0; + hid_t file_id = (-1); + int nerrors = 0; hid_t fapl; - char filename0[1024]; + char filename0[1024]; /* Reset the library and get the file access property list */ h5_reset(); @@ -2988,7 +3770,8 @@ main(void) /* Create a new file_id using default create property but vfd access * property. */ - if((file_id = H5Fcreate(filename0,H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename0, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Call "main" test routine */ nerrors += test_main(file_id, fapl); @@ -3002,7 +3785,7 @@ main(void) /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if(nerrors) + if (nerrors) goto error; puts("All getname tests passed."); @@ -3011,12 +3794,13 @@ main(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; puts("***** GET NAME TESTS FAILED *****"); return 1; } - diff --git a/test/gheap.c b/test/gheap.c index 09ba1cf..00c3190 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -21,7 +21,7 @@ */ #include "h5test.h" #include "H5ACprivate.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" #include "H5Fprivate.h" #include "H5Gprivate.h" @@ -35,28 +35,20 @@ #define GHEAP_REPEATED_ERR_LIM 20 /* Number of heap objects to test */ -#define GHEAP_TEST_NOBJS 1024 - -#define GHEAP_REPEATED_ERR(MSG) \ -{ \ - nerrors++; \ - if(nerrors <= GHEAP_REPEATED_ERR_LIM) { \ - H5_FAILED(); \ - puts(MSG); \ - if(nerrors == GHEAP_REPEATED_ERR_LIM) \ - puts(" Suppressing further errors..."); \ - } /* end if */ \ -} /* end GHEAP_REPEATED_ERR */ - -const char *FILENAME[] = { - "gheap1", - "gheap2", - "gheap3", - "gheap4", - "gheapooo", - NULL -}; +#define GHEAP_TEST_NOBJS 1024 +#define GHEAP_REPEATED_ERR(MSG) \ + { \ + nerrors++; \ + if (nerrors <= GHEAP_REPEATED_ERR_LIM) { \ + H5_FAILED(); \ + puts(MSG); \ + if (nerrors == GHEAP_REPEATED_ERR_LIM) \ + puts(" Suppressing further errors..."); \ + } /* end if */ \ + } /* end GHEAP_REPEATED_ERR */ + +const char *FILENAME[] = {"gheap1", "gheap2", "gheap3", "gheap4", "gheapooo", NULL}; /*------------------------------------------------------------------------- * Function: test_1 @@ -74,30 +66,30 @@ const char *FILENAME[] = { *------------------------------------------------------------------------- */ static int -test_1 (hid_t fapl) +test_1(hid_t fapl) { - hid_t file = H5I_INVALID_HID; - H5F_t *f = NULL; - H5HG_t *obj = NULL; - uint8_t out[GHEAP_TEST_NOBJS]; - uint8_t in[GHEAP_TEST_NOBJS]; - size_t u; - size_t size; - herr_t status; - int nerrors = 0; - char filename[1024]; + hid_t file = H5I_INVALID_HID; + H5F_t * f = NULL; + H5HG_t *obj = NULL; + uint8_t out[GHEAP_TEST_NOBJS]; + uint8_t in[GHEAP_TEST_NOBJS]; + size_t u; + size_t size; + herr_t status; + int nerrors = 0; + char filename[1024]; TESTING("monotonically increasing lengths"); /* Allocate buffer for H5HG_t */ - if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) + if (NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) goto error; /* Open a clean file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5VL_object(file))) { + if (NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); HDputs(" Unable to create file"); goto error; @@ -108,17 +100,17 @@ test_1 (hid_t fapl) * a clean file, the addresses allocated for the collections should also * be monotonically increasing. */ - for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + for (u = 0; u < GHEAP_TEST_NOBJS; u++) { size = u + 1; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); status = H5HG_insert(f, size, out, obj + u); - if(status < 0) { + if (status < 0) { H5_FAILED(); HDputs(" Unable to insert object into global heap"); nerrors++; } - else if(u && H5F_addr_gt(obj[u - 1].addr, obj[u].addr)) { + else if (u && H5F_addr_gt(obj[u - 1].addr, obj[u].addr)) { H5_FAILED(); HDputs(" Collection addresses are not monotonically increasing"); nerrors++; @@ -128,16 +120,16 @@ test_1 (hid_t fapl) /* * Now try to read each object back. */ - for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + for (u = 0; u < GHEAP_TEST_NOBJS; u++) { size = u + 1; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - if(NULL == H5HG_read(f, obj + u, in, NULL)) { + if (NULL == H5HG_read(f, obj + u, in, NULL)) { H5_FAILED(); HDputs(" Unable to read object"); nerrors++; } - else if(HDmemcmp(in, out, size)) { + else if (HDmemcmp(in, out, size)) { H5_FAILED(); HDputs(" Value read doesn't match value written"); nerrors++; @@ -148,24 +140,25 @@ test_1 (hid_t fapl) HDfree(obj); obj = NULL; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; - if(nerrors) + if (nerrors) goto error; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - if(obj) + } + H5E_END_TRY; + if (obj) HDfree(obj); return MAX(1, nerrors); } - /*------------------------------------------------------------------------- * Function: test_2 * @@ -182,29 +175,29 @@ error: *------------------------------------------------------------------------- */ static int -test_2 (hid_t fapl) +test_2(hid_t fapl) { - hid_t file = H5I_INVALID_HID; - H5F_t *f = NULL; - H5HG_t *obj = NULL; - uint8_t out[GHEAP_TEST_NOBJS]; - uint8_t in[GHEAP_TEST_NOBJS]; - size_t u; - size_t size; - int nerrors = 0; - char filename[1024]; + hid_t file = H5I_INVALID_HID; + H5F_t * f = NULL; + H5HG_t *obj = NULL; + uint8_t out[GHEAP_TEST_NOBJS]; + uint8_t in[GHEAP_TEST_NOBJS]; + size_t u; + size_t size; + int nerrors = 0; + char filename[1024]; TESTING("monotonically decreasing lengths"); /* Allocate buffer for H5HG_t */ - if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) + if (NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) goto error; /* Open a clean file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5VL_object(file))) { + if (NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); HDputs(" Unable to create file"); goto error; @@ -213,11 +206,11 @@ test_2 (hid_t fapl) /* * Write the objects, monotonically decreasing in length. */ - for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + for (u = 0; u < GHEAP_TEST_NOBJS; u++) { size = GHEAP_TEST_NOBJS - u; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - if(H5HG_insert(f, size, out, obj + u) < 0) { + if (H5HG_insert(f, size, out, obj + u) < 0) { H5_FAILED(); HDputs(" Unable to insert object into global heap"); nerrors++; @@ -227,16 +220,16 @@ test_2 (hid_t fapl) /* * Now try to read each object back. */ - for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + for (u = 0; u < GHEAP_TEST_NOBJS; u++) { size = GHEAP_TEST_NOBJS - u; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - if(NULL == H5HG_read(f, obj + u, in, NULL)) { + if (NULL == H5HG_read(f, obj + u, in, NULL)) { H5_FAILED(); HDputs(" Unable to read object"); nerrors++; } - else if (memcmp (in, out, size)) { + else if (memcmp(in, out, size)) { H5_FAILED(); HDputs(" Value read doesn't match value written"); nerrors++; @@ -247,24 +240,25 @@ test_2 (hid_t fapl) HDfree(obj); obj = NULL; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; - if(nerrors) + if (nerrors) goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - if(obj) + } + H5E_END_TRY; + if (obj) HDfree(obj); return MAX(1, nerrors); } - /*------------------------------------------------------------------------- * Function: test_3 * @@ -281,41 +275,41 @@ test_2 (hid_t fapl) *------------------------------------------------------------------------- */ static int -test_3 (hid_t fapl) +test_3(hid_t fapl) { - hid_t file = H5I_INVALID_HID; - H5F_t *f = NULL; - H5HG_t *obj = NULL; - uint8_t out[GHEAP_TEST_NOBJS]; - size_t u; - size_t size; - herr_t status; - int nerrors = 0; - char filename[1024]; + hid_t file = H5I_INVALID_HID; + H5F_t * f = NULL; + H5HG_t *obj = NULL; + uint8_t out[GHEAP_TEST_NOBJS]; + size_t u; + size_t size; + herr_t status; + int nerrors = 0; + char filename[1024]; TESTING("complete object removal"); /* Allocate buffer for H5HG_t */ - if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) + if (NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) goto error; /* Open a clean file */ h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5VL_object(file))) { + if (NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); HDputs(" Unable to create file"); goto error; } /* Create some stuff */ - for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + for (u = 0; u < GHEAP_TEST_NOBJS; u++) { size = u % 30 + 100; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); status = H5HG_insert(f, size, out, obj + u); - if (status<0) { + if (status < 0) { H5_FAILED(); HDputs(" Unable to insert object into global heap"); nerrors++; @@ -323,9 +317,9 @@ test_3 (hid_t fapl) } /* Remove everything */ - for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + for (u = 0; u < GHEAP_TEST_NOBJS; u++) { status = H5HG_remove(f, obj + u); - if (status<0) { + if (status < 0) { H5_FAILED(); HDputs(" Unable to remove object"); nerrors++; @@ -336,24 +330,25 @@ test_3 (hid_t fapl) HDfree(obj); obj = NULL; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; - if(nerrors) + if (nerrors) goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - if(obj) + } + H5E_END_TRY; + if (obj) HDfree(obj); return MAX(1, nerrors); } - /*------------------------------------------------------------------------- * Function: test_4 * @@ -371,41 +366,41 @@ test_3 (hid_t fapl) *------------------------------------------------------------------------- */ static int -test_4 (hid_t fapl) +test_4(hid_t fapl) { - hid_t file = H5I_INVALID_HID; - H5F_t *f = NULL; - H5HG_t *obj = NULL; - uint8_t out[GHEAP_TEST_NOBJS]; - size_t u; - size_t size; - herr_t status; - int nerrors = 0; - char filename[1024]; + hid_t file = H5I_INVALID_HID; + H5F_t * f = NULL; + H5HG_t *obj = NULL; + uint8_t out[GHEAP_TEST_NOBJS]; + size_t u; + size_t size; + herr_t status; + int nerrors = 0; + char filename[1024]; TESTING("partial object removal"); /* Allocate buffer for H5HG_t */ - if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) + if (NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) goto error; /* Open a clean file */ h5_fixname(FILENAME[3], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5VL_object(file))) { + if (NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); HDputs(" Unable to create file"); goto error; } - for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + for (u = 0; u < GHEAP_TEST_NOBJS; u++) { /* Insert */ size = u % 30 + 100; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); status = H5HG_insert(f, size, out, obj + u); - if (status<0) { + if (status < 0) { H5_FAILED(); HDputs(" Unable to insert object into global heap"); nerrors++; @@ -415,10 +410,10 @@ test_4 (hid_t fapl) * next one has already been inserted. That is, insert A, B, C; * remove B, insert D, E, F; remove E; etc. */ - if(1 == (u % 3)) { + if (1 == (u % 3)) { H5Eclear2(H5E_DEFAULT); status = H5HG_remove(f, obj + u - 1); - if (status<0) { + if (status < 0) { H5_FAILED(); HDputs(" Unable to remove object"); nerrors++; @@ -431,24 +426,25 @@ test_4 (hid_t fapl) HDfree(obj); obj = NULL; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; - if(nerrors) + if (nerrors) goto error; PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - if(obj) + } + H5E_END_TRY; + if (obj) HDfree(obj); return MAX(1, nerrors); } - /*------------------------------------------------------------------------- * Function: test_ooo_indices * @@ -469,24 +465,24 @@ test_4 (hid_t fapl) static int test_ooo_indices(hid_t fapl) { - hid_t file = H5I_INVALID_HID; - H5F_t *f = NULL; - unsigned i, j; - H5HG_t *obj = NULL; - herr_t status; - int nerrors = 0; - char filename[1024]; + hid_t file = H5I_INVALID_HID; + H5F_t * f = NULL; + unsigned i, j; + H5HG_t * obj = NULL; + herr_t status; + int nerrors = 0; + char filename[1024]; TESTING("out of order indices"); - if(NULL == (obj = (H5HG_t *)HDmalloc(2000 * sizeof(*obj)))) + if (NULL == (obj = (H5HG_t *)HDmalloc(2000 * sizeof(*obj)))) goto error; /* Open a clean file */ h5_fixname(FILENAME[4], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5VL_object(file))) { + if (NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); HDputs(" Unable to create file"); goto error; @@ -495,28 +491,28 @@ test_ooo_indices(hid_t fapl) /* Alternately insert 1000 entries and remove the previous group of 1000 * entries, until the indices wrap around. */ - for(i = 0; i < 66; i++) { + for (i = 0; i < 66; i++) { /* Insert 1000 entries. The index into the obj array will alternate up * and down by 1000 so the previous set of insertions is preserved and * can be deleted. */ - for(j=1000*((~i&1)); j<1000*((~i&1)+1); j++) { + for (j = 1000 * ((~i & 1)); j < 1000 * ((~i & 1) + 1); j++) { H5Eclear2(H5E_DEFAULT); status = H5HG_insert(f, sizeof(j), &j, &obj[j]); - if (status<0) + if (status < 0) GHEAP_REPEATED_ERR(" Unable to insert object into global heap") /* Check that the index is as expected */ - if(obj[j].idx != ((1000 * i) + j - (1000 * ((~i & 1)))) % ((1u << 16) - 1) + 1) + if (obj[j].idx != ((1000 * i) + j - (1000 * ((~i & 1)))) % ((1u << 16) - 1) + 1) GHEAP_REPEATED_ERR(" Unexpected global heap index"); } /* Remove the previous 1000 entries */ - if(i>0) - for(j=1000*(i&1); j<1000*((i&1)+1); j++) { + if (i > 0) + for (j = 1000 * (i & 1); j < 1000 * ((i & 1) + 1); j++) { H5Eclear2(H5E_DEFAULT); status = H5HG_remove(f, &obj[j]); - if (status<0) + if (status < 0) GHEAP_REPEATED_ERR(" Unable to remove object from global heap"); } } @@ -528,28 +524,28 @@ test_ooo_indices(hid_t fapl) /* Reopen the file */ if (H5Fclose(file) < 0) goto error; - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5VL_object(file))) { + if (NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); HDputs(" Unable to open file"); goto error; } /* end if */ /* Read the objects to make sure the heap is still readable */ - for(i=0; i<1000; i++) { - if(NULL == H5HG_read(f, &obj[i], &j, NULL)) + for (i = 0; i < 1000; i++) { + if (NULL == H5HG_read(f, &obj[i], &j, NULL)) goto error; - if(i != j) { + if (i != j) { H5_FAILED(); HDputs(" Incorrect read value"); goto error; } } - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; - if(nerrors) + if (nerrors) goto error; HDfree(obj); obj = NULL; @@ -557,16 +553,17 @@ test_ooo_indices(hid_t fapl) PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - if(obj) + } + H5E_END_TRY; + if (obj) HDfree(obj); return MAX(1, nerrors); } /* end test_ooo_indices */ - /*------------------------------------------------------------------------- * Function: main * @@ -577,18 +574,19 @@ test_ooo_indices(hid_t fapl) *------------------------------------------------------------------------- */ int -main (void) +main(void) { - int nerrors = 0; - hid_t fapl_id = H5I_INVALID_HID; - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + int nerrors = 0; + hid_t fapl_id = H5I_INVALID_HID; + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ h5_reset(); if ((fapl_id = h5_fileaccess()) < 0) goto error; /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; nerrors += test_1(fapl_id); @@ -606,20 +604,23 @@ main (void) HDputs("All global heap tests passed."); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; h5_cleanup(FILENAME, fapl_id); HDexit(EXIT_SUCCESS); - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); HDputs("*** TESTS FAILED ***"); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/h5test.c b/test/h5test.c index a0d2843..d425642 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -19,20 +19,20 @@ * */ -#undef NDEBUG /*override -DNDEBUG */ +#undef NDEBUG /*override -DNDEBUG */ #include "h5test.h" #include "H5srcdir.h" #include "H5srcdir_str.h" /* Necessary for h5_verify_cached_stabs() */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ #define H5G_TESTING #include "H5Gpkg.h" #ifdef H5_HAVE_WIN32_API #include -#endif /* H5_HAVE_WIN32_API */ +#endif /* H5_HAVE_WIN32_API */ /* * Define these environment variables or constants to influence functions in @@ -71,12 +71,12 @@ #ifndef HDF5_PARAPREFIX #define HDF5_PARAPREFIX "" #endif -char *paraprefix = NULL; /* for command line option para-prefix */ +char *paraprefix = NULL; /* for command line option para-prefix */ #ifdef H5_HAVE_PARALLEL -MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ +MPI_Info h5_io_info_g = MPI_INFO_NULL; /* MPI INFO object for IO */ #endif -#define READ_BUF_SIZE 65536 +#define READ_BUF_SIZE 65536 /* * These are the letters that are appended to the file name when generating @@ -93,13 +93,13 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ static const char *multi_letters = "msbrglo"; /* Length of multi-file VFD filename buffers */ -#define H5TEST_MULTI_FILENAME_LEN 1024 +#define H5TEST_MULTI_FILENAME_LEN 1024 /* Temporary file for sending signal messages */ #define TMP_SIGNAL_FILE "tmp_signal_file" /* The # of seconds to wait for the message file--used by h5_wait_message() */ -#define MESSAGE_TIMEOUT 300 /* Timeout in seconds */ +#define MESSAGE_TIMEOUT 300 /* Timeout in seconds */ /* Buffer to construct path in and return pointer to */ static char srcdir_path[1024] = ""; @@ -109,22 +109,19 @@ static char srcdir_testpath[1024] = ""; /* The strings that correspond to library version bounds H5F_libver_t in H5Fpublic.h */ /* This is used by h5_get_version_string() */ -const char *LIBVER_NAMES[] = { - "earliest", /* H5F_LIBVER_EARLIEST = 0 */ - "v18", /* H5F_LIBVER_V18 = 1 */ - "v110", /* H5F_LIBVER_V110 = 2 */ - "v112", /* H5F_LIBVER_V112 = 3 */ - "latest", /* H5F_LIBVER_V114 = 4 */ - NULL -}; +const char *LIBVER_NAMES[] = {"earliest", /* H5F_LIBVER_EARLIEST = 0 */ + "v18", /* H5F_LIBVER_V18 = 1 */ + "v110", /* H5F_LIBVER_V110 = 2 */ + "v112", /* H5F_LIBVER_V112 = 3 */ + "latest", /* H5F_LIBVER_V114 = 4 */ + NULL}; /* Previous error reporting function */ static H5E_auto2_t err_func = NULL; static herr_t h5_errors(hid_t estack, void *client_data); -static char *h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, - char *fullname, size_t size, hbool_t nest_printf, hbool_t subst_for_superblock); - +static char * h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fullname, + size_t size, hbool_t nest_printf, hbool_t subst_for_superblock); /*------------------------------------------------------------------------- * Function: h5_errors @@ -154,14 +151,14 @@ void h5_testing(const char *fmt, ...) { va_list ap; - char buf[62 + 1]; /* room for 62-char field + NUL */ + char buf[62 + 1]; /* room for 62-char field + NUL */ va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); printf("Testing %s", buf); fflush(stdout); } - + /*------------------------------------------------------------------------- * Function: h5_clean_files * @@ -180,7 +177,7 @@ h5_clean_files(const char *base_name[], hid_t fapl) { int i; - for(i = 0; base_name[i]; i++) { + for (i = 0; base_name[i]; i++) { h5_delete_test_file(base_name[i], fapl); } @@ -190,7 +187,6 @@ h5_clean_files(const char *base_name[], hid_t fapl) return; } /* end h5_clean_files() */ - /*------------------------------------------------------------------------- * Function: h5_delete_test_file * @@ -214,58 +210,60 @@ h5_clean_files(const char *base_name[], hid_t fapl) * sub_filename in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") void h5_delete_test_file(const char *base_name, hid_t fapl) { - char filename[1024]; /* VFD-dependent filename to delete */ - char sub_filename[2048]; /* sub-files in multi & family VFDs */ - hid_t driver = -1; /* VFD ID */ + char filename[1024]; /* VFD-dependent filename to delete */ + char sub_filename[2048]; /* sub-files in multi & family VFDs */ + hid_t driver = -1; /* VFD ID */ /* Get the VFD-dependent filename */ - if(NULL == h5_fixname(base_name, fapl, filename, sizeof(filename))) + if (NULL == h5_fixname(base_name, fapl, filename, sizeof(filename))) return; driver = H5Pget_driver(fapl); - if(driver == H5FD_FAMILY) { + if (driver == H5FD_FAMILY) { int j; - for(j = 0; /*void*/; j++) { + for (j = 0; /*void*/; j++) { HDsnprintf(sub_filename, sizeof(sub_filename), filename, j); /* If we can't access the file, it probably doesn't exist * and we are done deleting the sub-files. */ - if(HDaccess(sub_filename, F_OK) < 0) + if (HDaccess(sub_filename, F_OK) < 0) break; HDremove(sub_filename); } /* end for */ - } else if(driver == H5FD_CORE) { - hbool_t backing; /* Whether the core file has backing store */ + } + else if (driver == H5FD_CORE) { + hbool_t backing; /* Whether the core file has backing store */ H5Pget_fapl_core(fapl, NULL, &backing); /* If the file was stored to disk with bacing store, remove it */ - if(backing) + if (backing) HDremove(filename); - } else if (driver == H5FD_MULTI) { + } + else if (driver == H5FD_MULTI) { H5FD_mem_t mt; HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { HDsnprintf(sub_filename, sizeof(sub_filename), "%s-%c.h5", filename, multi_letters[mt]); HDremove(sub_filename); } - } else { + } + else { HDremove(filename); } /* end driver selection tree */ return; } /* end h5_delete_test_file() */ -H5_GCC_DIAG_ON(format-nonliteral) - +H5_GCC_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- * Function: h5_delete_all_test_files @@ -290,16 +288,15 @@ H5_GCC_DIAG_ON(format-nonliteral) void h5_delete_all_test_files(const char *base_name[], hid_t fapl) { - int i; /* iterator */ + int i; /* iterator */ - for(i = 0; base_name[i]; i++) { + for (i = 0; base_name[i]; i++) { h5_delete_test_file(base_name[i], fapl); } /* end for */ return; } /* end h5_delete_all_test_files() */ - /*------------------------------------------------------------------------- * Function: h5_cleanup * @@ -317,9 +314,9 @@ h5_delete_all_test_files(const char *base_name[], hid_t fapl) int h5_cleanup(const char *base_name[], hid_t fapl) { - int retval = 0; + int retval = 0; - if(GetTestCleanup()) { + if (GetTestCleanup()) { /* Clean up files in base_name, and the FAPL */ h5_clean_files(base_name, fapl); @@ -332,7 +329,6 @@ h5_cleanup(const char *base_name[], hid_t fapl) return retval; } /* end h5_cleanup() */ - /*------------------------------------------------------------------------- * Function: h5_test_shutdown * @@ -361,7 +357,6 @@ h5_test_shutdown(void) return; } /* end h5_test_shutdown() */ - /*------------------------------------------------------------------------- * Function: h5_restore_err * @@ -383,7 +378,6 @@ h5_restore_err(void) err_func = NULL; } - /*------------------------------------------------------------------------- * Function: h5_reset * @@ -418,27 +412,27 @@ h5_reset(void) * appropriate configure flags/macros. QAK - 2007/12/20 */ #ifdef OLD_WAY -{ - char filename[1024]; + { + char filename[1024]; - /* - * Cause the library to emit some diagnostics early so they don't - * interfere with other formatted output. - */ - HDsprintf(filename, "/tmp/h5emit-%05d.h5", HDgetpid()); - H5E_BEGIN_TRY { - hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT); - hid_t grp = H5Gcreate2(file, "emit", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(grp); - H5Fclose(file); - HDunlink(filename); - } H5E_END_TRY; -} + /* + * Cause the library to emit some diagnostics early so they don't + * interfere with other formatted output. + */ + HDsprintf(filename, "/tmp/h5emit-%05d.h5", HDgetpid()); + H5E_BEGIN_TRY + { + hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + hid_t grp = H5Gcreate2(file, "emit", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(grp); + H5Fclose(file); + HDunlink(filename); + } + H5E_END_TRY; + } #endif /* OLD_WAY */ } - /*------------------------------------------------------------------------- * Function: h5_test_init * @@ -471,7 +465,6 @@ h5_test_init(void) return; } /* end h5_test_init() */ - /*------------------------------------------------------------------------- * Function: h5_fixname * @@ -500,7 +493,6 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, FALSE, FALSE)); } - /*------------------------------------------------------------------------- * Function: h5_fixname_superblock * @@ -526,7 +518,6 @@ h5_fixname_superblock(const char *base_name, hid_t fapl_id, char *fullname, size return (h5_fixname_real(base_name, fapl_id, ".h5", fullname, size, FALSE, TRUE)); } - /*------------------------------------------------------------------------- * Function: h5_fixname_no_suffix * @@ -546,7 +537,6 @@ h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t s return (h5_fixname_real(base_name, fapl, NULL, fullname, size, FALSE, FALSE)); } - /*------------------------------------------------------------------------- * Function: h5_fixname_printf * @@ -572,7 +562,6 @@ h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, TRUE, FALSE)); } - /*------------------------------------------------------------------------- * Function: h5_fixname_real * @@ -596,16 +585,16 @@ h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size *------------------------------------------------------------------------- */ static char * -h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, - char *fullname, size_t size, hbool_t nest_printf, hbool_t subst_for_superblock) +h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fullname, size_t size, + hbool_t nest_printf, hbool_t subst_for_superblock) { - const char *prefix = NULL; - const char *env = NULL; /* HDF5_DRIVER environment variable */ - char *ptr, last = '\0'; - const char *suffix = _suffix; - size_t i, j; - hid_t driver = -1; - int isppdriver = 0; /* if the driver is MPI parallel */ + const char *prefix = NULL; + const char *env = NULL; /* HDF5_DRIVER environment variable */ + char * ptr, last = '\0'; + const char *suffix = _suffix; + size_t i, j; + hid_t driver = -1; + int isppdriver = 0; /* if the driver is MPI parallel */ if (!base_name || !fullname || size < 1) return NULL; @@ -613,13 +602,13 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, HDmemset(fullname, 0, size); /* figure out the suffix */ - if(H5P_DEFAULT != fapl) { - if((driver = H5Pget_driver(fapl)) < 0) + if (H5P_DEFAULT != fapl) { + if ((driver = H5Pget_driver(fapl)) < 0) return NULL; - if(suffix) { - if(H5FD_FAMILY == driver) { - if(subst_for_superblock) + if (suffix) { + if (H5FD_FAMILY == driver) { + if (subst_for_superblock) suffix = "00000.h5"; else suffix = nest_printf ? "%%05d.h5" : "%05d.h5"; @@ -633,19 +622,19 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, env = HDgetenv("HDF5_DRIVER"); #ifdef HDF5_DRIVER /* Use the environment variable, then the compile-time constant */ - if(!env) + if (!env) env = HDF5_DRIVER; #endif - if(env && !HDstrcmp(env, "split")) { + if (env && !HDstrcmp(env, "split")) { /* split VFD */ - if(subst_for_superblock) + if (subst_for_superblock) suffix = "-m.h5"; else suffix = NULL; } else { /* multi VFD */ - if(subst_for_superblock) + if (subst_for_superblock) suffix = "-s.h5"; else suffix = NULL; @@ -663,13 +652,14 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, * (The #ifdef is needed to prevent compile failure in case MPI is not * configured.) */ - if(isppdriver) { + if (isppdriver) { #ifdef H5_HAVE_PARALLEL - if(getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP")) + if (getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP")) SetTestNoCleanup(); -#endif /* H5_HAVE_PARALLEL */ - } else { - if(HDgetenv("HDF5_NOCLEANUP")) +#endif /* H5_HAVE_PARALLEL */ + } + else { + if (HDgetenv("HDF5_NOCLEANUP")) SetTestNoCleanup(); } @@ -679,7 +669,7 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, * (The #ifdef is needed to prevent compile failure in case MPI is not * configured.) */ - if(isppdriver) { + if (isppdriver) { #ifdef H5_HAVE_PARALLEL /* * For parallel: @@ -698,20 +688,21 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, if (mpi_rank == 0) HDprintf("*** Hint ***\n" - "You can use environment variable HDF5_PARAPREFIX to " - "run parallel test files in a\n" - "different directory or to add file type prefix. e.g.,\n" - " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" - " export HDF5_PARAPREFIX\n" - "*** End of Hint ***\n"); + "You can use environment variable HDF5_PARAPREFIX to " + "run parallel test files in a\n" + "different directory or to add file type prefix. e.g.,\n" + " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" + " export HDF5_PARAPREFIX\n" + "*** End of Hint ***\n"); explained = TRUE; #ifdef HDF5_PARAPREFIX prefix = HDF5_PARAPREFIX; -#endif /* HDF5_PARAPREFIX */ +#endif /* HDF5_PARAPREFIX */ } -#endif /* H5_HAVE_PARALLEL */ - } else { +#endif /* H5_HAVE_PARALLEL */ + } + else { /* * For serial: * First use the environment variable, then try the constant @@ -721,7 +712,7 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, #ifdef HDF5_PREFIX if (!prefix) prefix = HDF5_PREFIX; -#endif /* HDF5_PREFIX */ +#endif /* HDF5_PREFIX */ } /* Prepend the prefix value to the base name */ @@ -738,8 +729,8 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, */ char *user, *login; - user = HDgetenv("USER"); - login = HDgetenv("LOGIN"); + user = HDgetenv("USER"); + login = HDgetenv("LOGIN"); subdir = (user ? user : login); if (subdir) { @@ -756,7 +747,7 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, if (!fullname[0]) { /* We didn't append the prefix yet */ HDstrncpy(fullname, prefix, size); - fullname[size -1] = '\0'; + fullname[size - 1] = '\0'; } if (HDstrlen(fullname) + HDstrlen(base_name) + 1 < size) { @@ -778,19 +769,23 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, HDstrcat(fullname, "/"); HDstrcat(fullname, base_name); - } else { + } + else { /* Buffer is too small */ return NULL; } - } else { + } + else { if (HDsnprintf(fullname, size, "%s/%s", prefix, base_name) == (int)size) /* Buffer is too small */ return NULL; } - } else if (HDstrlen(base_name) >= size) { + } + else if (HDstrlen(base_name) >= size) { /* Buffer is too small */ return NULL; - } else { + } + else { HDstrcpy(fullname, base_name); } @@ -813,7 +808,6 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, return fullname; } - /*------------------------------------------------------------------------- * Function: h5_rmprefix * @@ -841,10 +835,9 @@ h5_rmprefix(const char *filename) else ret_ptr++; - return(ret_ptr); + return (ret_ptr); } - /*------------------------------------------------------------------------- * Function: h5_fileaccess * @@ -863,28 +856,27 @@ h5_rmprefix(const char *filename) hid_t h5_fileaccess(void) { - hid_t fapl_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Attempt to set up a file driver first */ - if(h5_get_vfd_fapl(fapl_id) < 0) + if (h5_get_vfd_fapl(fapl_id) < 0) goto error; /* Finally, check for libver bounds */ - if(h5_get_libver_fapl(fapl_id) < 0) + if (h5_get_libver_fapl(fapl_id) < 0) goto error; return fapl_id; error: - if(fapl_id != H5I_INVALID_HID) + if (fapl_id != H5I_INVALID_HID) H5Pclose(fapl_id); return H5I_INVALID_HID; } /* end h5_fileaccess() */ - /*------------------------------------------------------------------------- * Function: h5_fileaccess_flags * @@ -903,28 +895,27 @@ error: hid_t h5_fileaccess_flags(unsigned flags) { - hid_t fapl_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Attempt to set up a file driver first */ - if((flags & H5_FILEACCESS_VFD) && h5_get_vfd_fapl(fapl_id) < 0) + if ((flags & H5_FILEACCESS_VFD) && h5_get_vfd_fapl(fapl_id) < 0) goto error; /* Finally, check for libver bounds */ - if((flags & H5_FILEACCESS_LIBVER) && h5_get_libver_fapl(fapl_id) < 0) + if ((flags & H5_FILEACCESS_LIBVER) && h5_get_libver_fapl(fapl_id) < 0) goto error; return fapl_id; error: - if(fapl_id != H5I_INVALID_HID) + if (fapl_id != H5I_INVALID_HID) H5Pclose(fapl_id); return H5I_INVALID_HID; } /* end h5_fileaccess_flags() */ - /*------------------------------------------------------------------------- * Function: h5_get_vfd_fapl * @@ -942,23 +933,23 @@ error: herr_t h5_get_vfd_fapl(hid_t fapl) { - const char *env = NULL; /* HDF5_DRIVER environment variable */ - const char *tok = NULL; /* strtok pointer */ - char *lasts = NULL; /* Context pointer for strtok_r() call */ - char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */ + const char *env = NULL; /* HDF5_DRIVER environment variable */ + const char *tok = NULL; /* strtok pointer */ + char * lasts = NULL; /* Context pointer for strtok_r() call */ + char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */ /* Get the environment variable, if it exists */ env = HDgetenv("HDF5_DRIVER"); #ifdef HDF5_DRIVER /* Use the environment variable, then the compile-time constant */ - if(!env) + if (!env) env = HDF5_DRIVER; #endif /* If the environment variable was not set, just return * without modifying the FAPL. */ - if(!env || !*env) + if (!env || !*env) goto done; /* Get the first 'word' of the environment variable. @@ -967,37 +958,42 @@ h5_get_vfd_fapl(hid_t fapl) */ HDstrncpy(buf, env, sizeof(buf)); buf[sizeof(buf) - 1] = '\0'; - if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) + if (NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) goto done; - if(!HDstrcmp(tok, "sec2")) { + if (!HDstrcmp(tok, "sec2")) { /* POSIX (section 2) read() and write() system calls */ - if(H5Pset_fapl_sec2(fapl) < 0) + if (H5Pset_fapl_sec2(fapl) < 0) goto error; - } else if(!HDstrcmp(tok, "stdio")) { + } + else if (!HDstrcmp(tok, "stdio")) { /* Standard C fread() and fwrite() system calls */ - if(H5Pset_fapl_stdio(fapl) < 0) + if (H5Pset_fapl_stdio(fapl) < 0) goto error; - } else if(!HDstrcmp(tok, "core")) { + } + else if (!HDstrcmp(tok, "core")) { /* In-memory driver settings (backing store on, 1 MB increment) */ - if(H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) + if (H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) goto error; - } else if(!HDstrcmp(tok, "core_paged")) { + } + else if (!HDstrcmp(tok, "core_paged")) { /* In-memory driver with write tracking and paging on */ - if(H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) + if (H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) goto error; - if(H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0) + if (H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0) goto error; - } else if(!HDstrcmp(tok, "split")) { + } + else if (!HDstrcmp(tok, "split")) { /* Split meta data and raw data each using default driver */ - if(H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) + if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) goto error; - } else if(!HDstrcmp(tok, "multi")) { + } + else if (!HDstrcmp(tok, "multi")) { /* Multi-file driver, general case of the split driver */ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char *sv[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + char * sv[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; H5FD_mem_t mt; @@ -1007,48 +1003,52 @@ h5_get_vfd_fapl(hid_t fapl) HDmemset(memb_addr, 0, sizeof(memb_addr)); HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { memb_fapl[mt] = H5P_DEFAULT; - sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN); + sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN); HDassert(sv[mt]); HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); } /* end for */ - if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) goto error; - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) HDfree(sv[mt]); - } else if(!HDstrcmp(tok, "family")) { + } + else if (!HDstrcmp(tok, "family")) { /* Family of files, each 1MB and using the default driver */ - hsize_t fam_size = 100 * 1024 * 1024; /* 100 MB */ + hsize_t fam_size = 100 * 1024 * 1024; /* 100 MB */ /* Was a family size specified in the environment variable? */ - if((tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) + if ((tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) fam_size = (hsize_t)(HDstrtod(tok, NULL) * 1024 * 1024); - if(H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT) < 0) goto error; - } else if(!HDstrcmp(tok, "log")) { + } + else if (!HDstrcmp(tok, "log")) { /* Log file access */ unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; /* Were special log file flags specified in the environment variable? */ - if((tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) + if ((tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) log_flags = (unsigned)HDstrtol(tok, NULL, 0); - if(H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0) + if (H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0) goto error; #ifdef H5_HAVE_DIRECT - } else if(!HDstrcmp(tok, "direct")) { + } + else if (!HDstrcmp(tok, "direct")) { /* Linux direct read() and write() system calls. Set memory boundary, * file block size, and copy buffer size to the default values. */ - if(H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0) + if (H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0) goto error; #endif - } else { + } + else { /* Unknown driver */ goto error; } /* end if */ @@ -1060,7 +1060,6 @@ error: return -1; } /* end h5_get_vfd_fapl() */ - /*------------------------------------------------------------------------- * Function: h5_get_libver_fapl * @@ -1078,23 +1077,23 @@ error: herr_t h5_get_libver_fapl(hid_t fapl) { - const char *env = NULL; /* HDF5_DRIVER environment variable */ - const char *tok = NULL; /* strtok pointer */ - char *lasts = NULL; /* Context pointer for strtok_r() call */ - char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */ + const char *env = NULL; /* HDF5_DRIVER environment variable */ + const char *tok = NULL; /* strtok pointer */ + char * lasts = NULL; /* Context pointer for strtok_r() call */ + char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */ /* Get the environment variable, if it exists */ env = HDgetenv("HDF5_LIBVER_BOUNDS"); #ifdef HDF5_LIBVER_BOUNDS /* Use the environment variable, then the compile-time constant */ - if(!env) + if (!env) env = HDF5_LIBVER_BOUNDS; #endif /* If the environment variable was not set, just return * without modifying the FAPL. */ - if(!env || !*env) + if (!env || !*env) goto done; /* Get the first 'word' of the environment variable. @@ -1103,12 +1102,12 @@ h5_get_libver_fapl(hid_t fapl) */ HDstrncpy(buf, env, sizeof(buf)); buf[sizeof(buf) - 1] = '\0'; - if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) + if (NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) goto done; - if(!HDstrcmp(tok, "latest")) { + if (!HDstrcmp(tok, "latest")) { /* use the latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; } /* end if */ else { @@ -1123,7 +1122,6 @@ error: return -1; } /* end h5_get_libver_fapl() */ - /*------------------------------------------------------------------------- * Function: h5_no_hwconv * @@ -1144,7 +1142,6 @@ h5_no_hwconv(void) H5Tunregister(H5T_PERS_HARD, NULL, (hid_t)-1, (hid_t)-1, NULL); } - /*------------------------------------------------------------------------- * Function: h5_show_hostname * @@ -1162,10 +1159,10 @@ h5_no_hwconv(void) void h5_show_hostname(void) { - char hostname[80]; + char hostname[80]; #ifdef H5_HAVE_WIN32_API WSADATA wsaData; - int err; + int err; #endif /* try show the process or thread id in multiple processes cases*/ @@ -1176,8 +1173,8 @@ h5_show_hostname(void) MPI_Initialized(&mpi_initialized); MPI_Finalized(&mpi_finalized); - if(mpi_initialized && !mpi_finalized) { - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + if (mpi_initialized && !mpi_finalized) { + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); HDprintf("MPI-process %d.", mpi_rank); } else @@ -1188,8 +1185,8 @@ h5_show_hostname(void) #endif #ifdef H5_HAVE_WIN32_API - err = WSAStartup( MAKEWORD(2,2), &wsaData ); - if ( err != 0 ) { + err = WSAStartup(MAKEWORD(2, 2), &wsaData); + if (err != 0) { /* could not find a usable WinSock DLL */ return; } @@ -1200,10 +1197,9 @@ h5_show_hostname(void) /* 2.2 in wVersion since that is the version we */ /* requested. */ - if ( LOBYTE( wsaData.wVersion ) != 2 || - HIBYTE( wsaData.wVersion ) != 2 ) { + if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { /* could not find a usable WinSock DLL */ - WSACleanup( ); + WSACleanup(); return; } @@ -1221,7 +1217,6 @@ h5_show_hostname(void) #endif } - #ifdef H5_HAVE_PARALLEL /* * Function: h5_set_info_object @@ -1239,16 +1234,17 @@ h5_show_hostname(void) int h5_set_info_object(void) { - char *envp; /* environment pointer */ - int ret_value=0; + char *envp; /* environment pointer */ + int ret_value = 0; /* handle any MPI INFO hints via $HDF5_MPI_INFO */ - if ((envp = HDgetenv("HDF5_MPI_INFO")) != NULL){ + if ((envp = HDgetenv("HDF5_MPI_INFO")) != NULL) { char *next, *valp; valp = envp = next = HDstrdup(envp); - if (!valp) return 0; + if (!valp) + return 0; /* create an INFO object if not created yet */ if (h5_io_info_g == MPI_INFO_NULL) @@ -1256,14 +1252,14 @@ h5_set_info_object(void) do { size_t len; - char *key_val, *endp, *namep; + char * key_val, *endp, *namep; if (*valp == ';') valp++; /* copy key/value pair into temporary buffer */ - len = strcspn(valp, ";"); - next = &valp[len]; + len = strcspn(valp, ";"); + next = &valp[len]; key_val = (char *)HDcalloc(1, len + 1); /* increment the next pointer past the terminating semicolon */ @@ -1276,7 +1272,8 @@ h5_set_info_object(void) while (*namep && (*namep == ' ' || *namep == '\t')) namep++; - if (!*namep) continue; /* was all white space, so move to next k/v pair */ + if (!*namep) + continue; /* was all white space, so move to next k/v pair */ /* eat up any ending white spaces */ endp = &namep[HDstrlen(namep) - 1]; @@ -1287,7 +1284,7 @@ h5_set_info_object(void) /* find the '=' */ valp = HDstrchr(namep, '='); - if (valp != NULL) { /* it's a valid key/value pairing */ + if (valp != NULL) { /* it's a valid key/value pairing */ char *tmp_val = valp + 1; /* change '=' to \0, move valp down one */ @@ -1320,7 +1317,6 @@ h5_set_info_object(void) return ret_value; } - /* * Function: h5_dump_info_object * Purpose: Display content of an MPI Info object @@ -1331,28 +1327,26 @@ h5_set_info_object(void) void h5_dump_info_object(MPI_Info info) { - char key[MPI_MAX_INFO_KEY+1]; - char value[MPI_MAX_INFO_VAL+1]; - int flag; - int i, nkeys; + char key[MPI_MAX_INFO_KEY + 1]; + char value[MPI_MAX_INFO_VAL + 1]; + int flag; + int i, nkeys; HDprintf("Dumping MPI Info Object (up to %d bytes per item):\n", MPI_MAX_INFO_VAL); - if (info==MPI_INFO_NULL){ - HDprintf("object is MPI_INFO_NULL\n"); + if (info == MPI_INFO_NULL) { + HDprintf("object is MPI_INFO_NULL\n"); } else { - MPI_Info_get_nkeys(info, &nkeys); - HDprintf("object has %d items\n", nkeys); - for (i=0; i= 0) { - if(env == NULL) - env = (char*) HDmalloc((size_t)len+1); - else if(HDstrlen(env) < (size_t)len) - env = (char*) HDrealloc(env, (size_t)len+1); + if (len >= 0) { + if (env == NULL) + env = (char *)HDmalloc((size_t)len + 1); + else if (HDstrlen(env) < (size_t)len) + env = (char *)HDrealloc(env, (size_t)len + 1); MPI_Bcast(env, len, MPI_CHAR, root, comm); env[len] = '\0'; } else { - if(env) + if (env) HDfree(env); env = NULL; } @@ -1624,7 +1620,7 @@ getenv_all(MPI_Comm comm, int root, const char* name) } else { /* use original getenv */ - if(env) + if (env) HDfree(env); env = HDgetenv(name); } /* end if */ @@ -1655,30 +1651,30 @@ getenv_all(MPI_Comm comm, int root, const char* name) int h5_make_local_copy(const char *origfilename, const char *local_copy_name) { - int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */ - ssize_t nread; /* Number of bytes read in */ - void *buf = NULL; /* Buffer for copying data */ - const char *filename = H5_get_srcdir_filename(origfilename); /* Get the test file name to copy */ + int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */ + ssize_t nread; /* Number of bytes read in */ + void * buf = NULL; /* Buffer for copying data */ + const char *filename = H5_get_srcdir_filename(origfilename); /* Get the test file name to copy */ /* Allocate copy buffer */ - if(NULL == (buf = HDcalloc((size_t)1, (size_t)READ_BUF_SIZE))) + if (NULL == (buf = HDcalloc((size_t)1, (size_t)READ_BUF_SIZE))) goto error; /* Copy old file into temporary file */ - if((fd_old = HDopen(filename, O_RDONLY)) < 0) + if ((fd_old = HDopen(filename, O_RDONLY)) < 0) goto error; - if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd_new = HDopen(local_copy_name, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; /* Copy data */ - while((nread = HDread(fd_old, buf, (size_t)READ_BUF_SIZE)) > 0) - if(HDwrite(fd_new, buf, (size_t)nread) < 0) + while ((nread = HDread(fd_old, buf, (size_t)READ_BUF_SIZE)) > 0) + if (HDwrite(fd_new, buf, (size_t)nread) < 0) goto error; /* Close files */ - if(HDclose(fd_old) < 0) + if (HDclose(fd_old) < 0) goto error; - if(HDclose(fd_new) < 0) + if (HDclose(fd_new) < 0) goto error; /* Release memory */ @@ -1688,15 +1684,14 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) error: /* ignore return values since we're already noted the problem */ - if(fd_old > 0) + if (fd_old > 0) HDclose(fd_old); - if(fd_new > 0) + if (fd_new > 0) HDclose(fd_new); HDfree(buf); return -1; } /* end h5_make_local_copy() */ - /*------------------------------------------------------------------------- * Function: h5_verify_cached_stabs_cb * @@ -1710,16 +1705,15 @@ error: *------------------------------------------------------------------------- */ static herr_t -h5_verify_cached_stabs_cb(hid_t oid, const char H5_ATTR_UNUSED *name, - const H5O_info2_t *oinfo, void H5_ATTR_UNUSED *udata) +h5_verify_cached_stabs_cb(hid_t oid, const char H5_ATTR_UNUSED *name, const H5O_info2_t *oinfo, + void H5_ATTR_UNUSED *udata) { - if(oinfo->type == H5O_TYPE_GROUP) + if (oinfo->type == H5O_TYPE_GROUP) return H5G__verify_cached_stabs_test(oid); else return SUCCEED; } /* end h5_verify_cached_stabs_cb() */ - /*------------------------------------------------------------------------- * Function: h5_verify_cached_stabs * @@ -1743,27 +1737,29 @@ h5_verify_cached_stabs_cb(hid_t oid, const char H5_ATTR_UNUSED *name, herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl) { - hid_t file = -1; - char filename[1024]; - int i = 0; + hid_t file = -1; + char filename[1024]; + int i = 0; - while(base_name[i]) { + while (base_name[i]) { if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL) continue; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY - if(file < 0) { + } + H5E_END_TRY + if (file < 0) { i++; continue; } /* end if */ - if(H5Ovisit3(file, H5_INDEX_NAME, H5_ITER_NATIVE, - h5_verify_cached_stabs_cb, NULL, H5O_INFO_BASIC) < 0) + if (H5Ovisit3(file, H5_INDEX_NAME, H5_ITER_NATIVE, h5_verify_cached_stabs_cb, NULL, H5O_INFO_BASIC) < + 0) goto error; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) goto error; file = -1; @@ -1773,9 +1769,11 @@ h5_verify_cached_stabs(const char *base_name[], hid_t fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } @@ -1813,18 +1811,18 @@ h5_send_message(const char *send, const char *arg1, const char *arg2) signalfile = HDfopen(TMP_SIGNAL_FILE, "w+"); /* Write messages to signal file, if provided */ - if(arg2 != NULL) { + if (arg2 != NULL) { HDassert(arg1); HDfprintf(signalfile, "%s\n%s\n", arg1, arg2); } /* end if */ - else if(arg1 != NULL) { + else if (arg1 != NULL) { HDassert(arg2 == NULL); HDfprintf(signalfile, "%s\n", arg1); } /* end if */ else { HDassert(arg1 == NULL); HDassert(arg2 == NULL); - }/* end else */ + } /* end else */ HDfclose(signalfile); @@ -1861,8 +1859,8 @@ h5_send_message(const char *send, const char *arg1, const char *arg2) herr_t h5_wait_message(const char *waitfor) { - FILE *returnfile; - time_t t0,t1; + FILE * returnfile; + time_t t0, t1; /* Start timer. If this function runs for too long (i.e., expected signal is never received), it will @@ -1878,11 +1876,11 @@ h5_wait_message(const char *waitfor) /* If we've been waiting for a signal for too long, then it was likely never sent and we should fail rather than loop infinitely */ - if(HDdifftime(t1, t0) > MESSAGE_TIMEOUT) { + if (HDdifftime(t1, t0) > MESSAGE_TIMEOUT) { HDfprintf(stdout, "Error communicating between processes. Make sure test script is running.\n"); TEST_ERROR; } /* end if */ - } /* end while */ + } /* end while */ HDfclose(returnfile); HDunlink(waitfor); @@ -1899,64 +1897,96 @@ error: * real VFDs. */ static H5FD_t *dummy_vfd_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static H5FD_t *dummy_vfd_open(const char H5_ATTR_UNUSED *name, unsigned H5_ATTR_UNUSED flags, hid_t H5_ATTR_UNUSED fapl_id, haddr_t H5_ATTR_UNUSED maxaddr) { return NULL; } +static H5FD_t * +dummy_vfd_open(const char H5_ATTR_UNUSED *name, unsigned H5_ATTR_UNUSED flags, hid_t H5_ATTR_UNUSED fapl_id, + haddr_t H5_ATTR_UNUSED maxaddr) +{ + return NULL; +} static herr_t dummy_vfd_close(H5FD_t *_file); -static herr_t dummy_vfd_close(H5FD_t H5_ATTR_UNUSED *_file) { return FAIL; } +static herr_t +dummy_vfd_close(H5FD_t H5_ATTR_UNUSED *_file) +{ + return FAIL; +} static haddr_t dummy_vfd_get_eoa(const H5FD_t *file, H5FD_mem_t type); -static haddr_t dummy_vfd_get_eoa(const H5FD_t H5_ATTR_UNUSED *file, H5FD_mem_t H5_ATTR_UNUSED type) { return HADDR_UNDEF; } +static haddr_t +dummy_vfd_get_eoa(const H5FD_t H5_ATTR_UNUSED *file, H5FD_mem_t H5_ATTR_UNUSED type) +{ + return HADDR_UNDEF; +} static herr_t dummy_vfd_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static herr_t dummy_vfd_set_eoa(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t H5_ATTR_UNUSED addr) { return FAIL; } +static herr_t +dummy_vfd_set_eoa(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t H5_ATTR_UNUSED addr) +{ + return FAIL; +} static haddr_t dummy_vfd_get_eof(const H5FD_t *file, H5FD_mem_t type); -static haddr_t dummy_vfd_get_eof(const H5FD_t H5_ATTR_UNUSED *file, H5FD_mem_t H5_ATTR_UNUSED type) { return HADDR_UNDEF; } +static haddr_t +dummy_vfd_get_eof(const H5FD_t H5_ATTR_UNUSED *file, H5FD_mem_t H5_ATTR_UNUSED type) +{ + return HADDR_UNDEF; +} -static herr_t dummy_vfd_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, void *buf); -static herr_t dummy_vfd_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf) { return FAIL; } +static herr_t dummy_vfd_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t +dummy_vfd_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf) +{ + return FAIL; +} -static herr_t dummy_vfd_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf); -static herr_t dummy_vfd_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) { return FAIL; } +static herr_t dummy_vfd_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t +dummy_vfd_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) +{ + return FAIL; +} /* Dummy VFD with the minimum parameters to make a VFD that can be registered */ static const H5FD_class_t H5FD_dummy_g = { - "dummy", /* name */ - 1, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - NULL, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - NULL, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - dummy_vfd_open, /* open */ - dummy_vfd_close, /* close */ - NULL, /* cmp */ - NULL, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - dummy_vfd_get_eoa, /* get_eoa */ - dummy_vfd_set_eoa, /* set_eoa */ - dummy_vfd_get_eof, /* get_eof */ - NULL, /* get_handle */ - dummy_vfd_read, /* read */ - dummy_vfd_write, /* write */ - NULL, /* flush */ - NULL, /* truncate */ - NULL, /* lock */ - NULL, /* unlock */ - NULL, /* dedup */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "dummy", /* name */ + 1, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + NULL, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + dummy_vfd_open, /* open */ + dummy_vfd_close, /* close */ + NULL, /* cmp */ + NULL, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + dummy_vfd_get_eoa, /* get_eoa */ + dummy_vfd_set_eoa, /* set_eoa */ + dummy_vfd_get_eof, /* get_eof */ + NULL, /* get_handle */ + dummy_vfd_read, /* read */ + dummy_vfd_write, /* write */ + NULL, /* flush */ + NULL, /* truncate */ + NULL, /* lock */ + NULL, /* unlock */ + NULL, /* dedup */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; - /*------------------------------------------------------------------------- * Function: h5_get_dummy_vfd_class() * @@ -1980,10 +2010,10 @@ static const H5FD_class_t H5FD_dummy_g = { H5FD_class_t * h5_get_dummy_vfd_class(void) { - H5FD_class_t *vfd_class = NULL; /* Dummy VFD that will be returned */ + H5FD_class_t *vfd_class = NULL; /* Dummy VFD that will be returned */ /* Create the class and initialize everything to zero/NULL */ - if(NULL == (vfd_class = (H5FD_class_t *)HDmalloc(sizeof(H5FD_class_t)))) + if (NULL == (vfd_class = (H5FD_class_t *)HDmalloc(sizeof(H5FD_class_t)))) TEST_ERROR; /* Copy the dummy VFD */ @@ -1992,7 +2022,7 @@ h5_get_dummy_vfd_class(void) return vfd_class; error: - if(vfd_class) + if (vfd_class) HDfree(vfd_class); return NULL; } /* h5_get_dummy_vfd_class */ @@ -2020,10 +2050,10 @@ error: H5VL_class_t * h5_get_dummy_vol_class(void) { - H5VL_class_t *vol_class = NULL; /* Dummy VOL class that will be returned */ + H5VL_class_t *vol_class = NULL; /* Dummy VOL class that will be returned */ /* Create the class and initialize everything to zero/NULL */ - if(NULL == (vol_class = (H5VL_class_t *)HDcalloc((size_t)1, sizeof(H5VL_class_t)))) + if (NULL == (vol_class = (H5VL_class_t *)HDcalloc((size_t)1, sizeof(H5VL_class_t)))) TEST_ERROR; /* Fill in the minimum parameters to make a VOL connector class that @@ -2034,7 +2064,7 @@ h5_get_dummy_vol_class(void) return vol_class; error: - if(vol_class) + if (vol_class) HDfree(vol_class); return NULL; } /* h5_get_dummy_vol_class */ @@ -2051,7 +2081,7 @@ error: H5_ATTR_PURE const char * h5_get_version_string(H5F_libver_t libver) { - return(LIBVER_NAMES[libver]); + return (LIBVER_NAMES[libver]); } /* end of h5_get_version_string */ /*------------------------------------------------------------------------- @@ -2142,21 +2172,22 @@ done: * *------------------------------------------------------------------------- */ -const char *H5_get_srcdir_filename(const char *filename) +const char * +H5_get_srcdir_filename(const char *filename) { const char *srcdir = H5_get_srcdir(); /* Check for error */ - if(NULL == srcdir) - return(NULL); + if (NULL == srcdir) + return (NULL); else { /* Build path to test file */ - if((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) { + if ((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) { HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename); - return(srcdir_testpath); + return (srcdir_testpath); } /* end if */ else - return(NULL); + return (NULL); } /* end else */ } /* end H5_get_srcdir_filename() */ @@ -2169,21 +2200,22 @@ const char *H5_get_srcdir_filename(const char *filename) * *------------------------------------------------------------------------- */ -const char *H5_get_srcdir(void) +const char * +H5_get_srcdir(void) { const char *srcdir = HDgetenv("srcdir"); /* Check for using the srcdir from configure time */ - if(NULL == srcdir) + if (NULL == srcdir) srcdir = config_srcdir; /* Build path to all test files */ - if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) { + if ((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) { HDsnprintf(srcdir_path, sizeof(srcdir_path), "%s/", srcdir); - return(srcdir_path); + return (srcdir_path); } /* end if */ else - return(NULL); + return (NULL); } /* end H5_get_srcdir() */ /*------------------------------------------------------------------------- @@ -2255,4 +2287,3 @@ done: HDfree(dup_buf); return ret_value; } /* end h5_duplicate_file_by_bytes() */ - diff --git a/test/h5test.h b/test/h5test.h index 6a7ae85..249c2a6 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -49,11 +49,11 @@ * 8 * 9 High: Highest level. All information. */ -#define VERBO_NONE 0 /* None */ -#define VERBO_DEF 3 /* Default */ -#define VERBO_LO 5 /* Low */ -#define VERBO_MED 7 /* Medium */ -#define VERBO_HI 9 /* High */ +#define VERBO_NONE 0 /* None */ +#define VERBO_DEF 3 /* Default */ +#define VERBO_LO 5 /* Low */ +#define VERBO_MED 7 /* Medium */ +#define VERBO_HI 9 /* High */ /* * Verbose queries @@ -64,18 +64,18 @@ /* Should be used internally by the libtest.a only. */ #define HDGetTestVerbosity() (TestVerbosity) -#define VERBOSE_NONE (HDGetTestVerbosity()==VERBO_NONE) -#define VERBOSE_DEF (HDGetTestVerbosity()>=VERBO_DEF) -#define VERBOSE_LO (HDGetTestVerbosity()>=VERBO_LO) -#define VERBOSE_MED (HDGetTestVerbosity()>=VERBO_MED) -#define VERBOSE_HI (HDGetTestVerbosity()>=VERBO_HI) +#define VERBOSE_NONE (HDGetTestVerbosity() == VERBO_NONE) +#define VERBOSE_DEF (HDGetTestVerbosity() >= VERBO_DEF) +#define VERBOSE_LO (HDGetTestVerbosity() >= VERBO_LO) +#define VERBOSE_MED (HDGetTestVerbosity() >= VERBO_MED) +#define VERBOSE_HI (HDGetTestVerbosity() >= VERBO_HI) /* * Test controls definitions. */ -#define SKIPTEST 1 /* Skip this test */ -#define ONLYTEST 2 /* Do only this test */ -#define BEGINTEST 3 /* Skip all tests before this test */ +#define SKIPTEST 1 /* Skip this test */ +#define ONLYTEST 2 /* Do only this test */ +#define BEGINTEST 3 /* Skip all tests before this test */ /* * This contains the filename prefix specified as command line option for @@ -83,14 +83,13 @@ */ H5TEST_DLLVAR char *paraprefix; #ifdef H5_HAVE_PARALLEL -H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ +H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #endif /* * Print the current location on the standard output stream. */ -#define AT() HDprintf (" at %s:%d in %s()...\n", \ - __FILE__, __LINE__, FUNC); +#define AT() HDprintf(" at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); /* * The name of the test is printed by saying TESTING("something") which will @@ -102,29 +101,80 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ * the H5_FAILED() macro is invoked automatically when an API function fails. */ #define TESTING(...) h5_testing(__VA_ARGS__); -#define TESTING_2(WHAT) {HDprintf(" Testing %-60s",WHAT); HDfflush(stdout);} -#define PASSED() do {HDputs(" PASSED");HDfflush(stdout);} while (0) -#define H5_FAILED() {HDputs("*FAILED*");HDfflush(stdout);} -#define H5_WARNING() {HDputs("*WARNING*");HDfflush(stdout);} -#define SKIPPED() {HDputs(" -SKIP-");HDfflush(stdout);} -#define PUTS_ERROR(s) {HDputs(s); AT(); goto error;} -#define TEST_ERROR {H5_FAILED(); AT(); goto error;} -#define STACK_ERROR {H5Eprint2(H5E_DEFAULT, stdout); goto error;} -#define FAIL_STACK_ERROR {H5_FAILED(); AT(); H5Eprint2(H5E_DEFAULT, stdout); \ - goto error;} -#define FAIL_PUTS_ERROR(s) {H5_FAILED(); AT(); HDputs(s); goto error;} -#define FAIL_PRINTF_ERROR(fmt, ...) {H5_FAILED(); AT(); HDprintf(fmt, __VA_ARGS__); goto error;} +#define TESTING_2(WHAT) \ + { \ + HDprintf(" Testing %-60s", WHAT); \ + HDfflush(stdout); \ + } +#define PASSED() \ + do { \ + HDputs(" PASSED"); \ + HDfflush(stdout); \ + } while (0) +#define H5_FAILED() \ + { \ + HDputs("*FAILED*"); \ + HDfflush(stdout); \ + } +#define H5_WARNING() \ + { \ + HDputs("*WARNING*"); \ + HDfflush(stdout); \ + } +#define SKIPPED() \ + { \ + HDputs(" -SKIP-"); \ + HDfflush(stdout); \ + } +#define PUTS_ERROR(s) \ + { \ + HDputs(s); \ + AT(); \ + goto error; \ + } +#define TEST_ERROR \ + { \ + H5_FAILED(); \ + AT(); \ + goto error; \ + } +#define STACK_ERROR \ + { \ + H5Eprint2(H5E_DEFAULT, stdout); \ + goto error; \ + } +#define FAIL_STACK_ERROR \ + { \ + H5_FAILED(); \ + AT(); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + goto error; \ + } +#define FAIL_PUTS_ERROR(s) \ + { \ + H5_FAILED(); \ + AT(); \ + HDputs(s); \ + goto error; \ + } +#define FAIL_PRINTF_ERROR(fmt, ...) \ + { \ + H5_FAILED(); \ + AT(); \ + HDprintf(fmt, __VA_ARGS__); \ + goto error; \ + } /* * Alarm definitions to wait up (terminate) a test that runs too long. */ -#define H5_ALARM_SEC 1200 /* default is 20 minutes */ -#define ALARM_ON TestAlarmOn() -#define ALARM_OFF HDalarm(0) +#define H5_ALARM_SEC 1200 /* default is 20 minutes */ +#define ALARM_ON TestAlarmOn() +#define ALARM_OFF HDalarm(0) /* Flags for h5_fileaccess_flags() */ -#define H5_FILEACCESS_VFD 0x01 -#define H5_FILEACCESS_LIBVER 0x02 +#define H5_FILEACCESS_VFD 0x01 +#define H5_FILEACCESS_LIBVER 0x02 /* Macros to create and fill 2D arrays with a single heap allocation. * These can be used to replace large stack and global arrays which raise @@ -152,67 +202,66 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ * * HDfree(array); */ -#define H5TEST_ALLOCATE_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ -do { \ - /* Prefix with h5taa to avoid shadow warnings */ \ - size_t h5taa_pointers_size = 0; \ - size_t h5taa_data_size = 0; \ - int h5taa_i; \ - \ - h5taa_pointers_size = (DIMS_I) * sizeof(TYPE *); \ - h5taa_data_size = (DIMS_I) * (DIMS_J) * sizeof(TYPE); \ - \ - ARR = (TYPE **)HDmalloc(h5taa_pointers_size + h5taa_data_size); \ - \ - ARR[0] = (TYPE *)(ARR + (DIMS_I)); \ - \ - for (h5taa_i = 1; h5taa_i < (DIMS_I); h5taa_i++) \ - ARR[h5taa_i] = ARR[h5taa_i-1] + (DIMS_J); \ -} while(0) - -#define H5TEST_FILL_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ -do { \ - /* Prefix with h5tfa to avoid shadow warnings */ \ - int h5tfa_i = 0; \ - int h5tfa_j = 0; \ - TYPE h5tfa_count = 0; \ - \ - for (h5tfa_i = 0; h5tfa_i < (DIMS_I); h5tfa_i++) \ - for (h5tfa_j = 0; h5tfa_j < (DIMS_J); h5tfa_j++) { \ - ARR[h5tfa_i][h5tfa_j] = h5tfa_count; \ - h5tfa_count++; \ - } \ -} while(0) +#define H5TEST_ALLOCATE_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ + do { \ + /* Prefix with h5taa to avoid shadow warnings */ \ + size_t h5taa_pointers_size = 0; \ + size_t h5taa_data_size = 0; \ + int h5taa_i; \ + \ + h5taa_pointers_size = (DIMS_I) * sizeof(TYPE *); \ + h5taa_data_size = (DIMS_I) * (DIMS_J) * sizeof(TYPE); \ + \ + ARR = (TYPE **)HDmalloc(h5taa_pointers_size + h5taa_data_size); \ + \ + ARR[0] = (TYPE *)(ARR + (DIMS_I)); \ + \ + for (h5taa_i = 1; h5taa_i < (DIMS_I); h5taa_i++) \ + ARR[h5taa_i] = ARR[h5taa_i - 1] + (DIMS_J); \ + } while (0) +#define H5TEST_FILL_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ + do { \ + /* Prefix with h5tfa to avoid shadow warnings */ \ + int h5tfa_i = 0; \ + int h5tfa_j = 0; \ + TYPE h5tfa_count = 0; \ + \ + for (h5tfa_i = 0; h5tfa_i < (DIMS_I); h5tfa_i++) \ + for (h5tfa_j = 0; h5tfa_j < (DIMS_J); h5tfa_j++) { \ + ARR[h5tfa_i][h5tfa_j] = h5tfa_count; \ + h5tfa_count++; \ + } \ + } while (0) #ifdef __cplusplus extern "C" { #endif /* Generally useful testing routines */ -H5TEST_DLL void h5_testing(const char *, ...) H5_ATTR_FORMAT(printf, 1, 2); -H5TEST_DLL void h5_clean_files(const char *base_name[], hid_t fapl); -H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); -H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size); -H5TEST_DLL char *h5_fixname_superblock(const char *base_name, hid_t fapl, char *fullname, size_t size); -H5TEST_DLL char *h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size); -H5TEST_DLL char *h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size); -H5TEST_DLL hid_t h5_fileaccess(void); -H5TEST_DLL hid_t h5_fileaccess_flags(unsigned flags); -H5TEST_DLL void h5_no_hwconv(void); +H5TEST_DLL void h5_testing(const char *, ...) H5_ATTR_FORMAT(printf, 1, 2); +H5TEST_DLL void h5_clean_files(const char *base_name[], hid_t fapl); +H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); +H5TEST_DLL char * h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size); +H5TEST_DLL char * h5_fixname_superblock(const char *base_name, hid_t fapl, char *fullname, size_t size); +H5TEST_DLL char * h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size); +H5TEST_DLL char * h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size); +H5TEST_DLL hid_t h5_fileaccess(void); +H5TEST_DLL hid_t h5_fileaccess_flags(unsigned flags); +H5TEST_DLL void h5_no_hwconv(void); H5TEST_DLL const char *h5_rmprefix(const char *filename); -H5TEST_DLL void h5_reset(void); -H5TEST_DLL void h5_restore_err(void); -H5TEST_DLL void h5_show_hostname(void); +H5TEST_DLL void h5_reset(void); +H5TEST_DLL void h5_restore_err(void); +H5TEST_DLL void h5_show_hostname(void); H5TEST_DLL h5_stat_size_t h5_get_file_size(const char *filename, hid_t fapl); -H5TEST_DLL int print_func(const char *format, ...); -H5TEST_DLL int h5_make_local_copy(const char *origfilename, const char *local_copy_name); -H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl); +H5TEST_DLL int print_func(const char *format, ...); +H5TEST_DLL int h5_make_local_copy(const char *origfilename, const char *local_copy_name); +H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl); H5TEST_DLL H5FD_class_t *h5_get_dummy_vfd_class(void); H5TEST_DLL H5VL_class_t *h5_get_dummy_vol_class(void); -H5TEST_DLL const char *h5_get_version_string(H5F_libver_t libver); -H5TEST_DLL int h5_compare_file_bytes(char *fname1, char *fname2); -H5TEST_DLL int h5_duplicate_file_by_bytes(const char *orig, const char *dest); +H5TEST_DLL const char * h5_get_version_string(H5F_libver_t libver); +H5TEST_DLL int h5_compare_file_bytes(char *fname1, char *fname2); +H5TEST_DLL int h5_duplicate_file_by_bytes(const char *orig, const char *dest); /* Functions that will replace components of a FAPL */ H5TEST_DLL herr_t h5_get_vfd_fapl(hid_t fapl_id); @@ -229,47 +278,47 @@ H5TEST_DLL void h5_test_init(void); H5TEST_DLL void h5_test_shutdown(void); /* Routines for operating on the list of tests (for the "all in one" tests) */ -H5TEST_DLL void TestUsage(void); -H5TEST_DLL void AddTest(const char *TheName, void (*TheCall) (void), - void (*Cleanup) (void), const char *TheDescr, - const void *Parameters); -H5TEST_DLL void TestInfo(const char *ProgName); -H5TEST_DLL void TestParseCmdLine(int argc, char *argv[]); -H5TEST_DLL void PerformTests(void); -H5TEST_DLL void TestSummary(void); -H5TEST_DLL void TestCleanup(void); -H5TEST_DLL void TestShutdown(void); -H5TEST_DLL void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[])); -H5TEST_DLL int GetTestVerbosity(void); -H5TEST_DLL int SetTestVerbosity(int newval); -H5TEST_DLL int GetTestSummary(void); -H5TEST_DLL int GetTestCleanup(void); -H5TEST_DLL int SetTestNoCleanup(void); -H5TEST_DLL int GetTestExpress(void); -H5TEST_DLL int SetTestExpress(int newval); -H5TEST_DLL void ParseTestVerbosity(char *argv); -H5TEST_DLL int GetTestNumErrs(void); -H5TEST_DLL void IncTestNumErrs(void); +H5TEST_DLL void TestUsage(void); +H5TEST_DLL void AddTest(const char *TheName, void (*TheCall)(void), void (*Cleanup)(void), + const char *TheDescr, const void *Parameters); +H5TEST_DLL void TestInfo(const char *ProgName); +H5TEST_DLL void TestParseCmdLine(int argc, char *argv[]); +H5TEST_DLL void PerformTests(void); +H5TEST_DLL void TestSummary(void); +H5TEST_DLL void TestCleanup(void); +H5TEST_DLL void TestShutdown(void); +H5TEST_DLL void TestInit(const char *ProgName, void (*private_usage)(void), + int (*private_parser)(int ac, char *av[])); +H5TEST_DLL int GetTestVerbosity(void); +H5TEST_DLL int SetTestVerbosity(int newval); +H5TEST_DLL int GetTestSummary(void); +H5TEST_DLL int GetTestCleanup(void); +H5TEST_DLL int SetTestNoCleanup(void); +H5TEST_DLL int GetTestExpress(void); +H5TEST_DLL int SetTestExpress(int newval); +H5TEST_DLL void ParseTestVerbosity(char *argv); +H5TEST_DLL int GetTestNumErrs(void); +H5TEST_DLL void IncTestNumErrs(void); H5TEST_DLL const void *GetTestParameters(void); -H5TEST_DLL int TestErrPrintf(const char *format, ...) H5_ATTR_FORMAT(printf, 1, 2); -H5TEST_DLL void SetTest(const char *testname, int action); -H5TEST_DLL void TestAlarmOn(void); -H5TEST_DLL void TestAlarmOff(void); +H5TEST_DLL int TestErrPrintf(const char *format, ...) H5_ATTR_FORMAT(printf, 1, 2); +H5TEST_DLL void SetTest(const char *testname, int action); +H5TEST_DLL void TestAlarmOn(void); +H5TEST_DLL void TestAlarmOff(void); #ifdef H5_HAVE_FILTER_SZIP H5TEST_DLL int h5_szip_can_encode(void); #endif /* H5_HAVE_FILTER_SZIP */ #ifdef H5_HAVE_PARALLEL -H5TEST_DLL int h5_set_info_object(void); -H5TEST_DLL void h5_dump_info_object(MPI_Info info); -H5TEST_DLL char* getenv_all(MPI_Comm comm, int root, const char* name); +H5TEST_DLL int h5_set_info_object(void); +H5TEST_DLL void h5_dump_info_object(MPI_Info info); +H5TEST_DLL char *getenv_all(MPI_Comm comm, int root, const char *name); #endif /* Extern global variables */ H5TEST_DLLVAR int TestVerbosity; -H5TEST_DLL void h5_send_message(const char *file, const char *arg1, const char *arg2); +H5TEST_DLL void h5_send_message(const char *file, const char *arg1, const char *arg2); H5TEST_DLL herr_t h5_wait_message(const char *file); #ifdef __cplusplus diff --git a/test/hdfs.c b/test/hdfs.c index ab39da6..4c7d045 100644 --- a/test/hdfs.c +++ b/test/hdfs.c @@ -23,12 +23,11 @@ * 2018-04-23 */ -#include "h5test.h" /* testing utilities */ -#include "H5FDhdfs.h" /* this file driver's utilities */ - +#include "h5test.h" /* testing utilities */ +#include "H5FDhdfs.h" /* this file driver's utilities */ #ifdef H5_HAVE_LIBHDFS -#define HDFS_TEST_DEBUG 0 +#define HDFS_TEST_DEBUG 0 #define HDFS_TEST_MAX_BUF_SIZE 256 #endif /* H5_HAVE_LIBHDFS */ @@ -75,7 +74,6 @@ * *****************************************************************************/ - /*---------------------------------------------------------------------------- * * ifdef flag: JSVERIFY_EXP_ACT @@ -87,7 +85,6 @@ */ #define JSVERIFY_EXP_ACT 1L - /*---------------------------------------------------------------------------- * * Macro: JSFAILED_AT() @@ -104,11 +101,11 @@ * *---------------------------------------------------------------------------- */ -#define JSFAILED_AT() { \ - HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ -} +#define JSFAILED_AT() \ + { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ + } - /*---------------------------------------------------------------------------- * * Macro: FAIL_IF() @@ -132,13 +129,12 @@ * *---------------------------------------------------------------------------- */ -#define FAIL_IF(condition) \ -if (condition) { \ - JSFAILED_AT() \ - goto error; \ -} +#define FAIL_IF(condition) \ + if (condition) { \ + JSFAILED_AT() \ + goto error; \ + } - /*---------------------------------------------------------------------------- * * Macro: FAIL_UNLESS() @@ -162,14 +158,13 @@ if (condition) { \ *---------------------------------------------------------------------------- */ #if 0 /* UNUSED */ -#define FAIL_UNLESS(condition) \ -if (!(condition)) { \ - JSFAILED_AT() \ - goto error; \ -} +#define FAIL_UNLESS(condition) \ + if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ + } #endif /* UNUSED */ - /*---------------------------------------------------------------------------- * * Macro: JSERR_LONG() @@ -195,17 +190,17 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSERR_LONG(expected, actual, reason) { \ - JSFAILED_AT() \ - if (reason!= NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ - (long)(expected), (long)(actual)); \ - } \ -} - - +#define JSERR_LONG(expected, actual, reason) \ + { \ + JSFAILED_AT() \ + if (reason != NULL) { \ + HDprintf("%s\n", (reason)); \ + } \ + else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", (long)(expected), (long)(actual)); \ + } \ + } + /*---------------------------------------------------------------------------- * * Macro: JSERR_STR() @@ -234,21 +229,19 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSERR_STR(expected, actual, reason) { \ - JSFAILED_AT() \ - if ((reason) != NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ - (expected), (actual)); \ - } \ -} - - +#define JSERR_STR(expected, actual, reason) \ + { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } \ + else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", (expected), (actual)); \ + } \ + } #ifdef JSVERIFY_EXP_ACT - /*---------------------------------------------------------------------------- * * Macro: JSVERIFY() @@ -265,13 +258,12 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY(expected, actual, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY */ +#define JSVERIFY(expected, actual, reason) \ + if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY */ - /*---------------------------------------------------------------------------- * * Macro: JSVERIFY_NOT() @@ -288,13 +280,12 @@ if ((long)(actual) != (long)(expected)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY_NOT(expected, actual, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ +#define JSVERIFY_NOT(expected, actual, reason) \ + if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY_NOT */ - /*---------------------------------------------------------------------------- * * Macro: JSVERIFY_STR() @@ -311,12 +302,11 @@ if ((long)(actual) == (long)(expected)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY_STR(expected, actual, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ - +#define JSVERIFY_STR(expected, actual, reason) \ + if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY_STR */ #else /* JSVERIFY_EXP_ACT not defined @@ -324,7 +314,6 @@ if (strcmp((actual), (expected)) != 0) { \ * Repeats macros above, but with actual/expected parameters reversed. */ - /*---------------------------------------------------------------------------- * Macro: JSVERIFY() * See: JSVERIFY documentation above. @@ -332,13 +321,12 @@ if (strcmp((actual), (expected)) != 0) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY(actual, expected, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY */ +#define JSVERIFY(actual, expected, reason) \ + if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY */ - /*---------------------------------------------------------------------------- * Macro: JSVERIFY_NOT() * See: JSVERIFY_NOT documentation above. @@ -346,13 +334,12 @@ if ((long)(actual) != (long)(expected)) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY_NOT(actual, expected, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ +#define JSVERIFY_NOT(actual, expected, reason) \ + if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY_NOT */ - /*---------------------------------------------------------------------------- * Macro: JSVERIFY_STR() * See: JSVERIFY_STR documentation above. @@ -360,11 +347,11 @@ if ((long)(actual) == (long)(expected)) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY_STR(actual, expected, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ +#define JSVERIFY_STR(actual, expected, reason) \ + if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY_STR */ #endif /* ifdef/else JSVERIFY_EXP_ACT */ @@ -375,7 +362,7 @@ if (strcmp((actual), (expected)) != 0) { \ /* copied from src/hdfs.c */ #ifdef H5_HAVE_LIBHDFS -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) #endif /* H5_HAVE_LIBHDFS */ #define HDFS_NAMENODE_NAME_MAX_SIZE 128 @@ -391,20 +378,19 @@ static const char filename_raven[] = "/tmp/Poe_Raven.txt"; static const char filename_example_h5[] = "/tmp/t.h5"; #endif /* H5_HAVE_LIBHDFS */ -static H5FD_hdfs_fapl_t default_fa = { - 1, /* fa version */ - "localhost", /* namenode name */ - 0, /* namenode port */ - "", /* user name */ - "", /* kerberos path */ - 1024, /* buffer size */ +static H5FD_hdfs_fapl_t default_fa = { + 1, /* fa version */ + "localhost", /* namenode name */ + 0, /* namenode port */ + "", /* user name */ + "", /* kerberos path */ + 1024, /* buffer size */ }; /****************** * TEST FUNCTIONS * ******************/ - /*--------------------------------------------------------------------------- * * Function: test_fapl_config_validation() @@ -438,28 +424,30 @@ test_fapl_config_validation(void) *************************/ struct testcase { - const char *msg; - herr_t expected; - H5FD_hdfs_fapl_t config; + const char * msg; + herr_t expected; + H5FD_hdfs_fapl_t config; }; /************************ * test-local variables * ************************/ - hid_t fapl_id = -1; /* file access property list ID */ + hid_t fapl_id = -1; /* file access property list ID */ H5FD_hdfs_fapl_t config; H5FD_hdfs_fapl_t fa_fetch; - herr_t success = SUCCEED; - unsigned int i = 0; - unsigned int ncases = 6; /* should equal number of cases */ - struct testcase *case_ptr = NULL; /* dumb work-around for possible */ - /* dynamic cases creation because */ - /* of compiler warnings Wlarger-than */ - struct testcase cases_arr[] = { - { "default config fapl", + herr_t success = SUCCEED; + unsigned int i = 0; + unsigned int ncases = 6; /* should equal number of cases */ + struct testcase *case_ptr = NULL; /* dumb work-around for possible */ + /* dynamic cases creation because */ + /* of compiler warnings Wlarger-than */ + struct testcase cases_arr[] = { + { + "default config fapl", SUCCEED, - { 1, /* version */ + { + 1, /* version */ "localhost", /* namenode_name */ 0, /* namenode_port number */ "some_user", /* user_name */ @@ -467,9 +455,11 @@ test_fapl_config_validation(void) -1, /* stream_buffer_size */ }, }, - { "invalid version number (2)", + { + "invalid version number (2)", FAIL, - { 2, /* version */ + { + 2, /* version */ "localhost", /* namenode_name */ 0, /* namenode_port number */ "some_user", /* user_name */ @@ -477,9 +467,11 @@ test_fapl_config_validation(void) -1, /* stream_buffer_size */ }, }, - { "invalid version number (0)", + { + "invalid version number (0)", FAIL, - { 0, /* version */ + { + 0, /* version */ "localhost", /* namenode_name */ 0, /* namenode_port number */ "some_user", /* user_name */ @@ -487,19 +479,23 @@ test_fapl_config_validation(void) -1, /* stream_buffer_size */ }, }, - { "nonsense kerberos path still ok?", + { + "nonsense kerberos path still ok?", SUCCEED, - { 1, /* version */ - "localhost", /* namenode_name */ - 0, /* namenode_port number */ - "some_user", /* user_name */ + { + 1, /* version */ + "localhost", /* namenode_name */ + 0, /* namenode_port number */ + "some_user", /* user_name */ "pathToSomewhere", /* kerberos_ticket_cache path */ - -1, /* stream_buffer_size */ + -1, /* stream_buffer_size */ }, }, - { "namenode port number too high", + { + "namenode port number too high", FAIL, - { 1, /* version */ + { + 1, /* version */ "localhost", /* namenode_name */ 88000, /* namenode_port number */ "some_user", /* user_name */ @@ -507,9 +503,11 @@ test_fapl_config_validation(void) -1, /* stream_buffer_size */ }, }, - { "negative namenode port number", + { + "negative namenode port number", FAIL, - { 1, /* version */ + { + 1, /* version */ "localhost", /* namenode_name */ -1, /* namenode_port number */ "some_user", /* user_name */ @@ -532,60 +530,46 @@ test_fapl_config_validation(void) *--------------- */ case_ptr = &cases_arr[i]; - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) /* sanity-check */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF(fapl_id < 0) /* sanity-check */ /*----------------------------------- * Actually test -- set fapl. * Mute stack trace in failure cases. *----------------------------------- */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { /* `H5FD_hdfs_validate_config(...)` is static/private * to src/hdfs.c and cannot (and should not?) be tested directly? * Instead, validate config through public api. */ success = H5Pset_fapl_hdfs(fapl_id, &case_ptr->config); - } H5E_END_TRY; + } + H5E_END_TRY; - JSVERIFY( case_ptr->expected, success, case_ptr->msg ) + JSVERIFY(case_ptr->expected, success, case_ptr->msg) /* Make sure we can get back what we put in. * Only valid if the fapl configuration does not result in error. */ if (success == SUCCEED) { config = case_ptr->config; - JSVERIFY( SUCCEED, - H5Pget_fapl_hdfs(fapl_id, &fa_fetch), - "unable to get fapl" ) - JSVERIFY( H5FD__CURR_HDFS_FAPL_T_VERSION, - fa_fetch.version, - "invalid version number" ) - JSVERIFY( config.version, - fa_fetch.version, - "version number mismatch" ) - JSVERIFY( config.namenode_port, - fa_fetch.namenode_port, - "namenode port mismatch" ) - JSVERIFY( config.stream_buffer_size, - fa_fetch.stream_buffer_size, - "streambuffer size mismatch" ) - JSVERIFY_STR( config.namenode_name, - fa_fetch.namenode_name, - NULL ) - JSVERIFY_STR( config.user_name, - fa_fetch.user_name, - NULL ) - JSVERIFY_STR( config.kerberos_ticket_cache, - fa_fetch.kerberos_ticket_cache, - NULL ) + JSVERIFY(SUCCEED, H5Pget_fapl_hdfs(fapl_id, &fa_fetch), "unable to get fapl") + JSVERIFY(H5FD__CURR_HDFS_FAPL_T_VERSION, fa_fetch.version, "invalid version number") + JSVERIFY(config.version, fa_fetch.version, "version number mismatch") + JSVERIFY(config.namenode_port, fa_fetch.namenode_port, "namenode port mismatch") + JSVERIFY(config.stream_buffer_size, fa_fetch.stream_buffer_size, "streambuffer size mismatch") + JSVERIFY_STR(config.namenode_name, fa_fetch.namenode_name, NULL) + JSVERIFY_STR(config.user_name, fa_fetch.user_name, NULL) + JSVERIFY_STR(config.kerberos_ticket_cache, fa_fetch.kerberos_ticket_cache, NULL) } /*----------------------------- * per-test sanitation/teardown *----------------------------- */ - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; } /* for each test case */ @@ -599,15 +583,16 @@ error: ***********/ if (fapl_id < 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; } return 1; } /* end test_fapl_config_validation() */ - /*------------------------------------------------------------------------- * * Function: test_hdfs_fapl() @@ -634,10 +619,10 @@ test_hdfs_fapl(void) * test-local variables * ************************/ - hid_t fapl_id = -1; /* file access property list ID */ - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - H5FD_hdfs_fapl_t hdfs_fa_0 = { + hid_t fapl_id = -1; /* file access property list ID */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + H5FD_hdfs_fapl_t hdfs_fa_0 = { 1, /* version*/ "", /* node name */ 9000, /* node port */ @@ -651,40 +636,40 @@ test_hdfs_fapl(void) /* Set property list and file name for HDFS driver. */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) + FAIL_IF(fapl_id < 0) - FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &hdfs_fa_0) ) + FAIL_IF(FAIL == H5Pset_fapl_hdfs(fapl_id, &hdfs_fa_0)) driver_id = H5Pget_driver(fapl_id); - FAIL_IF( driver_id < 0 ) + FAIL_IF(driver_id < 0) /**************** * Check that the VFD feature flags are correct * SPEC MAY CHANGE ******************/ - FAIL_IF( H5FDdriver_query(driver_id, &driver_flags) < 0 ) + FAIL_IF(H5FDdriver_query(driver_id, &driver_flags) < 0) - JSVERIFY_NOT( 0, (driver_flags & H5FD_FEAT_DATA_SIEVE), - "bit(s) in `driver_flags` must align with " - "H5FD_FEAT_DATA_SIEVE" ) + JSVERIFY_NOT(0, (driver_flags & H5FD_FEAT_DATA_SIEVE), + "bit(s) in `driver_flags` must align with " + "H5FD_FEAT_DATA_SIEVE") - JSVERIFY( H5FD_FEAT_DATA_SIEVE, driver_flags, - "H5FD_FEAT_DATA_SIEVE should be the only supported flag") + JSVERIFY(H5FD_FEAT_DATA_SIEVE, driver_flags, "H5FD_FEAT_DATA_SIEVE should be the only supported flag") PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_hdfs_fapl() */ - /*--------------------------------------------------------------------------- * * Function: test_vfd_open() @@ -743,70 +728,80 @@ test_vfd_open(void) ************************/ struct test_condition failing_conditions[] = { - { "default property list (H5P_DEFAULT) is invalid", + { + "default property list (H5P_DEFAULT) is invalid", filename_bard, H5F_ACC_RDONLY, FAPL_H5P_DEFAULT, MAXADDR, TRUE, }, - { "generic file access property list is invalid", + { + "generic file access property list is invalid", filename_bard, H5F_ACC_RDONLY, FAPL_UNCONFIGURED, MAXADDR, TRUE, }, - { "filename cannot be null", + { + "filename cannot be null", NULL, H5F_ACC_RDONLY, FAPL_HDFS, MAXADDR, FALSE, }, - { "filename cannot be empty", + { + "filename cannot be empty", "", H5F_ACC_RDONLY, FAPL_HDFS, MAXADDR, FALSE, }, - { "file at filename must exist", + { + "file at filename must exist", filename_missing, H5F_ACC_RDONLY, FAPL_HDFS, MAXADDR, FALSE, }, - { "read-write flag not supported", + { + "read-write flag not supported", filename_bard, H5F_ACC_RDWR, FAPL_HDFS, MAXADDR, FALSE, }, - { "truncate flag not supported", + { + "truncate flag not supported", filename_bard, H5F_ACC_TRUNC, FAPL_HDFS, MAXADDR, FALSE, }, - { "create flag not supported", + { + "create flag not supported", filename_bard, H5F_ACC_CREAT, FAPL_HDFS, MAXADDR, FALSE, }, - { "EXCL flag not supported", + { + "EXCL flag not supported", filename_bard, H5F_ACC_EXCL, FAPL_HDFS, MAXADDR, FALSE, }, - { "maxaddr cannot be 0 (caught in `H5FD_open()`)", + { + "maxaddr cannot be 0 (caught in `H5FD_open()`)", filename_bard, H5F_ACC_RDONLY, FAPL_HDFS, @@ -814,20 +809,20 @@ test_vfd_open(void) FALSE, }, }; - unsigned i = 0; - unsigned failing_conditions_count = 10; - H5FD_t *fd = NULL; - hid_t fapl_hdfs = -1; - hid_t fapl_unconfigured = -1; + unsigned i = 0; + unsigned failing_conditions_count = 10; + H5FD_t * fd = NULL; + hid_t fapl_hdfs = -1; + hid_t fapl_unconfigured = -1; TESTING("HDFS VFD-level open"); fapl_unconfigured = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_unconfigured < 0 ) + FAIL_IF(fapl_unconfigured < 0) fapl_hdfs = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_hdfs < 0 ) - FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_hdfs, &default_fa) ) + FAIL_IF(fapl_hdfs < 0) + FAIL_IF(FAIL == H5Pset_fapl_hdfs(fapl_hdfs, &default_fa)) /********* * TESTS * @@ -844,8 +839,7 @@ test_vfd_open(void) if (T.which_fapl == FAPL_UNCONFIGURED) { fapl_id = fapl_unconfigured; } - else - if (T.which_fapl == FAPL_HDFS) { + else if (T.which_fapl == FAPL_HDFS) { fapl_id = fapl_hdfs; } @@ -853,18 +847,17 @@ test_vfd_open(void) HDfprintf(stderr, "testing: %s\n", T.message); #endif /* HDFS_TEST_DEBUG */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fd = H5FDopen(T.url, T.flags, fapl_id, T.maxaddr); - } H5E_END_TRY; + } + H5E_END_TRY; if (NULL != fd) { - if (TRUE == T.might_use_other_driver && - H5FD_HDFS != fd->driver_id) - { - HDfprintf(stderr, "\n!!!!! WARNING !!!!!\n" \ - " Successful open of file on local system " \ - "with non-HDFS VFD.\n"); - JSVERIFY(SUCCEED, H5FDclose(fd), - "unable to close errant open"); + if (TRUE == T.might_use_other_driver && H5FD_HDFS != fd->driver_id) { + HDfprintf(stderr, "\n!!!!! WARNING !!!!!\n" + " Successful open of file on local system " + "with non-HDFS VFD.\n"); + JSVERIFY(SUCCEED, H5FDclose(fd), "unable to close errant open"); fd = NULL; } else { @@ -873,36 +866,32 @@ test_vfd_open(void) } } - FAIL_IF( NULL != fd ) /* sanity check */ + FAIL_IF(NULL != fd) /* sanity check */ #if HDFS_TEST_DEBUG - HDfprintf(stderr, "nominal open\n"); + HDfprintf(stderr, "nominal open\n"); #endif /* HDFS_TEST_DEBUG */ /* finally, show that a file can be opened */ - fd = H5FDopen( - filename_bard, - H5F_ACC_RDONLY, - fapl_hdfs, - MAXADDR); - FAIL_IF( NULL == fd ) + fd = H5FDopen(filename_bard, H5F_ACC_RDONLY, fapl_hdfs, MAXADDR); + FAIL_IF(NULL == fd) /************ * TEARDOWN * ************/ #if HDFS_TEST_DEBUG - HDfprintf(stderr, "teardown...\n"); + HDfprintf(stderr, "teardown...\n"); #endif /* HDFS_TEST_DEBUG */ - FAIL_IF( FAIL == H5FDclose(fd) ) + FAIL_IF(FAIL == H5FDclose(fd)) fd = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_hdfs) ) + FAIL_IF(FAIL == H5Pclose(fapl_hdfs)) fapl_hdfs = -1; - FAIL_IF( FAIL == H5Pclose(fapl_unconfigured) ) + FAIL_IF(FAIL == H5Pclose(fapl_unconfigured)) fapl_unconfigured = -1; PASSED(); @@ -917,14 +906,16 @@ error: if (fd) { (void)H5FDclose(fd); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl_hdfs >= 0) { (void)H5Pclose(fapl_hdfs); } if (fapl_unconfigured >= 0) { (void)H5Pclose(fapl_unconfigured); } - } H5E_END_TRY; + } + H5E_END_TRY; return 1; @@ -936,7 +927,6 @@ error: } /* end test_vfd_open() */ - /*--------------------------------------------------------------------------- * * Function: test_eof_eoa() @@ -979,8 +969,8 @@ test_eof_eoa(void) * test-local variables * ************************/ - H5FD_t *fd_shakespeare = NULL; - hid_t fapl_id = -1; + H5FD_t *fd_shakespeare = NULL; + hid_t fapl_id = -1; TESTING("HDFS eof/eoa gets and sets"); @@ -989,15 +979,11 @@ test_eof_eoa(void) *********/ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( 0 > fapl_id ) - FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + FAIL_IF(0 > fapl_id) + FAIL_IF(FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa)) - fd_shakespeare = H5FDopen( - filename_bard, - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); - FAIL_IF( NULL == fd_shakespeare ) + fd_shakespeare = H5FDopen(filename_bard, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); + FAIL_IF(NULL == fd_shakespeare) /********* * TESTS * @@ -1005,46 +991,31 @@ test_eof_eoa(void) /* verify as found */ - JSVERIFY( 5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), NULL ) - JSVERIFY( H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), - H5FDget_eof(fd_shakespeare, H5FD_MEM_DRAW), - "mismatch between DEFAULT and RAW memory types" ) - JSVERIFY( 0, - H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoA should be unset by H5FDopen" ) + JSVERIFY(5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), NULL) + JSVERIFY(H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), H5FDget_eof(fd_shakespeare, H5FD_MEM_DRAW), + "mismatch between DEFAULT and RAW memory types") + JSVERIFY(0, H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), "EoA should be unset by H5FDopen") /* set EoA below EoF */ - JSVERIFY( SUCCEED, - H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 44442202), - "unable to set EoA (lower)" ) - JSVERIFY( 5458199, - H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoF changed" ) - JSVERIFY( 44442202, - H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoA unchanged" ) + JSVERIFY(SUCCEED, H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 44442202), "unable to set EoA (lower)") + JSVERIFY(5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), "EoF changed") + JSVERIFY(44442202, H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), "EoA unchanged") /* set EoA above EoF */ - JSVERIFY( SUCCEED, - H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 6789012), - "unable to set EoA (higher)" ) - JSVERIFY( 5458199, - H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoF changed" ) - JSVERIFY( 6789012, - H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoA unchanged" ) + JSVERIFY(SUCCEED, H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 6789012), "unable to set EoA (higher)") + JSVERIFY(5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), "EoF changed") + JSVERIFY(6789012, H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), "EoA unchanged") /************ * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(fd_shakespeare) ) + FAIL_IF(FAIL == H5FDclose(fd_shakespeare)) fd_shakespeare = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; PASSED(); @@ -1060,9 +1031,11 @@ error: (void)H5FDclose(fd_shakespeare); } if (fapl_id >= 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; } return 1; @@ -1071,7 +1044,6 @@ error: } /* end test_eof_eoa() */ - /*----------------------------------------------------------------------------- * * Function: test_H5FDread_without_eoa_set_fails() @@ -1098,10 +1070,10 @@ test_H5FDread_without_eoa_set_fails(void) #else - char buffer[HDFS_TEST_MAX_BUF_SIZE]; - unsigned int i = 0; - H5FD_t *file_shakespeare = NULL; - hid_t fapl_id = -1; + char buffer[HDFS_TEST_MAX_BUF_SIZE]; + unsigned int i = 0; + H5FD_t * file_shakespeare = NULL; + hid_t fapl_id = -1; TESTING("HDFS VFD read-eoa temporal coupling library limitation"); @@ -1112,18 +1084,13 @@ test_H5FDread_without_eoa_set_fails(void) /* create HDFS fapl */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) - FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + FAIL_IF(fapl_id < 0) + FAIL_IF(FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa)) - file_shakespeare = H5FDopen( - filename_bard, - H5F_ACC_RDONLY, - fapl_id, - MAXADDR); - FAIL_IF( NULL == file_shakespeare ) + file_shakespeare = H5FDopen(filename_bard, H5F_ACC_RDONLY, fapl_id, MAXADDR); + FAIL_IF(NULL == file_shakespeare) - JSVERIFY( 0, H5FDget_eoa(file_shakespeare, H5FD_MEM_DEFAULT), - "EoA should remain unset by H5FDopen" ) + JSVERIFY(0, H5FDget_eoa(file_shakespeare, H5FD_MEM_DEFAULT), "EoA should remain unset by H5FDopen") /* zero buffer contents */ for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { @@ -1134,28 +1101,21 @@ test_H5FDread_without_eoa_set_fails(void) * TEST * ********/ - H5E_BEGIN_TRY { /* mute stack trace on expected failure */ - JSVERIFY( FAIL, - H5FDread(file_shakespeare, - H5FD_MEM_DRAW, - H5P_DEFAULT, - 1200699, - 102, - buffer), - "cannot read before eoa is set" ) - } H5E_END_TRY; + H5E_BEGIN_TRY{/* mute stack trace on expected failure */ + JSVERIFY(FAIL, H5FDread(file_shakespeare, H5FD_MEM_DRAW, H5P_DEFAULT, 1200699, 102, buffer), + "cannot read before eoa is set")} H5E_END_TRY; for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { - JSVERIFY( 0, (unsigned)buffer[i], "buffer was modified by write!" ) + JSVERIFY(0, (unsigned)buffer[i], "buffer was modified by write!") } /************ * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(file_shakespeare) ) + FAIL_IF(FAIL == H5FDclose(file_shakespeare)) file_shakespeare = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; PASSED(); @@ -1171,9 +1131,11 @@ error: (void)H5FDclose(file_shakespeare); } if (fapl_id >= 0) { - H5E_BEGIN_TRY { - (void)H5Pclose(fapl_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + (void)H5Pclose(fapl_id); + } + H5E_END_TRY; } return 1; @@ -1182,8 +1144,6 @@ error: } /* end test_H5FDread_without_eoa_set_fails() */ - - /*--------------------------------------------------------------------------- * * Function: test_read() @@ -1232,42 +1192,48 @@ test_read(void) * test-local variables * ************************/ struct testcase cases[] = { - { "successful range-get", + { + "successful range-get", 6464, 5691, 32, /* fancy quotes are three bytes each(?) */ SUCCEED, "Quoth the Raven “Nevermore.”", }, - { "read past EOA fails (EOA < EOF < addr)", + { + "read past EOA fails (EOA < EOF < addr)", 3000, 4000, 100, FAIL, NULL, }, - { "read overlapping EOA fails (EOA < addr < EOF < (addr+len))", + { + "read overlapping EOA fails (EOA < addr < EOF < (addr+len))", 3000, 8000, 100, FAIL, NULL, }, - { "read past EOA/EOF fails ((EOA==EOF) < addr)", + { + "read past EOA/EOF fails ((EOA==EOF) < addr)", 6464, 7000, 100, FAIL, NULL, }, - { "read overlapping EOA/EOF fails (addr < (EOA==EOF) < (addr+len))", + { + "read overlapping EOA/EOF fails (addr < (EOA==EOF) < (addr+len))", 6464, 6400, 100, FAIL, NULL, }, - { "read between EOF and EOA fails (EOF < addr < (addr+len) < EOA)", + { + "read between EOF and EOA fails (EOF < addr < (addr+len) < EOA)", 8000, 7000, 100, @@ -1275,14 +1241,14 @@ test_read(void) NULL, }, }; - unsigned testcase_count = 6; - unsigned test_i = 0; - struct testcase test; - herr_t open_return = FAIL; - char buffer[HDFS_TEST_MAX_BUF_SIZE]; - unsigned int i = 0; - H5FD_t *file_raven = NULL; - hid_t fapl_id = -1; + unsigned testcase_count = 6; + unsigned test_i = 0; + struct testcase test; + herr_t open_return = FAIL; + char buffer[HDFS_TEST_MAX_BUF_SIZE]; + unsigned int i = 0; + H5FD_t * file_raven = NULL; + hid_t fapl_id = -1; TESTING("HDFS VFD read/range-gets"); @@ -1293,8 +1259,8 @@ test_read(void) /* create HDFS fapl */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) - FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + FAIL_IF(fapl_id < 0) + FAIL_IF(FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa)) /* zero buffer contents */ for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { @@ -1303,14 +1269,11 @@ test_read(void) /* open file */ - file_raven = H5FDopen( - filename_raven, - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); /* Demonstrate success with "automatic" value */ - FAIL_IF( NULL == file_raven ) + file_raven = H5FDopen(filename_raven, H5F_ACC_RDONLY, fapl_id, + HADDR_UNDEF); /* Demonstrate success with "automatic" value */ + FAIL_IF(NULL == file_raven) - JSVERIFY( 6464, H5FDget_eof(file_raven, H5FD_MEM_DEFAULT), NULL ) + JSVERIFY(6464, H5FDget_eof(file_raven, H5FD_MEM_DEFAULT), NULL) /********* * TESTS * @@ -1325,10 +1288,9 @@ test_read(void) test = cases[test_i]; open_return = FAIL; - FAIL_IF( HDFS_TEST_MAX_BUF_SIZE < test.len ) /* buffer too small! */ + FAIL_IF(HDFS_TEST_MAX_BUF_SIZE < test.len) /* buffer too small! */ - FAIL_IF( FAIL == - H5FDset_eoa( file_raven, H5FD_MEM_DEFAULT, test.eoa_set) ) + FAIL_IF(FAIL == H5FDset_eoa(file_raven, H5FD_MEM_DEFAULT, test.eoa_set)) /* zero buffer contents */ for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { @@ -1339,22 +1301,16 @@ test_read(void) * conduct test * * ------------ */ - H5E_BEGIN_TRY { - open_return = H5FDread( - file_raven, - H5FD_MEM_DRAW, - H5P_DEFAULT, - test.addr, - test.len, - buffer); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + open_return = H5FDread(file_raven, H5FD_MEM_DRAW, H5P_DEFAULT, test.addr, test.len, buffer); + } + H5E_END_TRY; - JSVERIFY( test.success, - open_return, - test.message ) + JSVERIFY(test.success, open_return, test.message) if (open_return == SUCCEED) { - JSVERIFY_STR( test.expected, buffer, NULL ) + JSVERIFY_STR(test.expected, buffer, NULL) } } /* for each testcase */ @@ -1363,10 +1319,10 @@ test_read(void) * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(file_raven) ) + FAIL_IF(FAIL == H5FDclose(file_raven)) file_raven = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; PASSED(); @@ -1378,13 +1334,15 @@ error: * CLEANUP * ***********/ - if (file_raven != 0) { + if (file_raven != 0) { (void)H5FDclose(file_raven); } if (fapl_id >= 0) { - H5E_BEGIN_TRY { - (void)H5Pclose(fapl_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + (void)H5Pclose(fapl_id); + } + H5E_END_TRY; } return 1; @@ -1393,7 +1351,6 @@ error: } /* end test_read() */ - /*--------------------------------------------------------------------------- * * Function: test_noops_and_autofails() @@ -1441,9 +1398,9 @@ test_noops_and_autofails(void) * test-local variables * ************************/ - hid_t fapl_id = -1; - H5FD_t *file = NULL; - const char data[36] = "The Force shall be with you, always"; + hid_t fapl_id = -1; + H5FD_t * file = NULL; + const char data[36] = "The Force shall be with you, always"; TESTING("HDFS VFD always-fail and no-op routines"); @@ -1454,17 +1411,13 @@ test_noops_and_autofails(void) /* create HDFS fapl */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) - FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + FAIL_IF(fapl_id < 0) + FAIL_IF(FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa)) /* open file */ - file = H5FDopen( - filename_bard, - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); - FAIL_IF( NULL == file ) + file = H5FDopen(filename_bard, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); + FAIL_IF(NULL == file) /********* * TESTS * @@ -1472,35 +1425,19 @@ test_noops_and_autofails(void) /* auto-fail calls to write and truncate */ - H5E_BEGIN_TRY { - JSVERIFY( FAIL, - H5FDwrite(file, H5FD_MEM_DRAW, H5P_DEFAULT, 1000, 35, data), - "write must fail" ) - } H5E_END_TRY; - - H5E_BEGIN_TRY { - JSVERIFY( FAIL, - H5FDtruncate(file, H5P_DEFAULT, FALSE), - "truncate must fail" ) - } H5E_END_TRY; - - H5E_BEGIN_TRY { - JSVERIFY( FAIL, - H5FDtruncate(file, H5P_DEFAULT, TRUE), - "truncate must fail (closing)" ) - } H5E_END_TRY; + H5E_BEGIN_TRY{JSVERIFY(FAIL, H5FDwrite(file, H5FD_MEM_DRAW, H5P_DEFAULT, 1000, 35, data), + "write must fail")} H5E_END_TRY; + + H5E_BEGIN_TRY{JSVERIFY(FAIL, H5FDtruncate(file, H5P_DEFAULT, FALSE), "truncate must fail")} H5E_END_TRY; + + H5E_BEGIN_TRY{ + JSVERIFY(FAIL, H5FDtruncate(file, H5P_DEFAULT, TRUE), "truncate must fail (closing)")} H5E_END_TRY; /* no-op calls to `lock()` and `unlock()` */ - JSVERIFY( SUCCEED, - H5FDlock(file, TRUE), - "lock always succeeds; has no effect" ) - JSVERIFY( SUCCEED, - H5FDlock(file, FALSE), - NULL ) - JSVERIFY( SUCCEED, - H5FDunlock(file), - NULL ) + JSVERIFY(SUCCEED, H5FDlock(file, TRUE), "lock always succeeds; has no effect") + JSVERIFY(SUCCEED, H5FDlock(file, FALSE), NULL) + JSVERIFY(SUCCEED, H5FDunlock(file), NULL) /* Lock/unlock with null file or similar error crashes tests. * HDassert in calling heirarchy, `H5FD[un]lock()` and `H5FD_[un]lock()` */ @@ -1509,10 +1446,10 @@ test_noops_and_autofails(void) * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(file) ) + FAIL_IF(FAIL == H5FDclose(file)) file = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; PASSED(); @@ -1525,9 +1462,11 @@ error: ***********/ if (fapl_id >= 0) { - H5E_BEGIN_TRY { - (void)H5Pclose(fapl_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + (void)H5Pclose(fapl_id); + } + H5E_END_TRY; } if (file != NULL) { (void)H5FDclose(file); @@ -1539,7 +1478,6 @@ error: } /* end test_noops_and_autofails() */ - /*--------------------------------------------------------------------------- * * Function: test_cmp() @@ -1563,15 +1501,12 @@ test_cmp(void) { TESTING("HDFS cmp (comparison)"); SKIPPED(); - HDfprintf( - stderr, - " TODO: Distinct valid fapls to open the same file.\n"); + HDfprintf(stderr, " TODO: Distinct valid fapls to open the same file.\n"); return 0; } /* end test_cmp() */ - /*--------------------------------------------------------------------------- * * Function: test_H5F_integration() @@ -1628,8 +1563,8 @@ test_H5F_integration(void) *********/ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( 0 > fapl_id ) - FAIL_IF( FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa) ) + FAIL_IF(0 > fapl_id) + FAIL_IF(FAIL == H5Pset_fapl_hdfs(fapl_id, &default_fa)) /********* * TESTS * @@ -1637,39 +1572,26 @@ test_H5F_integration(void) /* Read-Write Open access is not allowed with this file driver. */ - H5E_BEGIN_TRY { - FAIL_IF( 0 <= H5Fopen( - filename_example_h5, - H5F_ACC_RDWR, - fapl_id) ) - } H5E_END_TRY; + H5E_BEGIN_TRY{FAIL_IF(0 <= H5Fopen(filename_example_h5, H5F_ACC_RDWR, fapl_id))} H5E_END_TRY; /* H5Fcreate() is not allowed with this file driver. */ - H5E_BEGIN_TRY { - FAIL_IF( 0 <= H5Fcreate( - filename_missing, - H5F_ACC_RDONLY, - H5P_DEFAULT, - fapl_id) ) - } H5E_END_TRY; + H5E_BEGIN_TRY{ + FAIL_IF(0 <= H5Fcreate(filename_missing, H5F_ACC_RDONLY, H5P_DEFAULT, fapl_id))} H5E_END_TRY; /* Successful open. */ - file = H5Fopen( - filename_example_h5, - H5F_ACC_RDONLY, - fapl_id); - FAIL_IF( file < 0 ) + file = H5Fopen(filename_example_h5, H5F_ACC_RDONLY, fapl_id); + FAIL_IF(file < 0) /************ * TEARDOWN * ************/ - FAIL_IF( FAIL == H5Fclose(file) ) + FAIL_IF(FAIL == H5Fclose(file)) file = -1; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; PASSED(); @@ -1681,13 +1603,16 @@ error: ***********/ #if HDFS_TEST_DEBUG - HDprintf("\nerror!"); fflush(stdout); + HDprintf("\nerror!"); + fflush(stdout); #endif /* HDFS_TEST_DEBUG */ if (fapl_id >= 0) { - H5E_BEGIN_TRY { - (void)H5Pclose(fapl_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + (void)H5Pclose(fapl_id); + } + H5E_END_TRY; } if (file > 0) { (void)H5Fclose(file); @@ -1699,7 +1624,6 @@ error: } /* test_H5F_integration */ - /*------------------------------------------------------------------------- * * Function: main @@ -1724,17 +1648,15 @@ main(void) ******************/ static char hdfs_namenode_name[HDFS_NAMENODE_NAME_MAX_SIZE] = ""; - const char *hdfs_namenode_name_env = NULL; + const char *hdfs_namenode_name_env = NULL; hdfs_namenode_name_env = HDgetenv("HDFS_TEST_NAMENODE_NAME"); if (hdfs_namenode_name_env == NULL || hdfs_namenode_name_env[0] == '\0') { HDstrncpy(hdfs_namenode_name, "localhost", HDFS_NAMENODE_NAME_MAX_SIZE); } else { - HDstrncpy( /* TODO: error-check? */ - default_fa.namenode_name, - hdfs_namenode_name_env, - HDFS_NAMENODE_NAME_MAX_SIZE); + HDstrncpy(/* TODO: error-check? */ + default_fa.namenode_name, hdfs_namenode_name_env, HDFS_NAMENODE_NAME_MAX_SIZE); } h5_reset(); @@ -1752,9 +1674,7 @@ main(void) nerrors += test_H5F_integration(); if (nerrors > 0) { - HDprintf("***** %d hdfs TEST%s FAILED! *****\n", - nerrors, - nerrors > 1 ? "S" : ""); + HDprintf("***** %d hdfs TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); nerrors = 1; } else { @@ -1763,5 +1683,3 @@ main(void) return nerrors; /* 0 if no errors, 1 if any errors */ } /* end main() */ - - diff --git a/test/hyperslab.c b/test/hyperslab.c index 4c84868..b9df916 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -23,17 +23,16 @@ #include "h5test.h" #include "H5VMprivate.h" -#define TEST_SMALL 0x0001 -#define TEST_MEDIUM 0x0002 +#define TEST_SMALL 0x0001 +#define TEST_MEDIUM 0x0002 -#define VARIABLE_SRC 0 -#define VARIABLE_DST 1 -#define VARIABLE_BOTH 2 +#define VARIABLE_SRC 0 +#define VARIABLE_DST 1 +#define VARIABLE_BOTH 2 -#define ARRAY_FILL_SIZE 4 +#define ARRAY_FILL_SIZE 4 #define ARRAY_OFFSET_NDIMS 3 - /*------------------------------------------------------------------------- * Function: init_full * @@ -49,23 +48,22 @@ static unsigned init_full(uint8_t *array, size_t nx, size_t ny, size_t nz) { - uint8_t acc = 128; - unsigned total = 0; - size_t i, j, k; - - for(i = 0; i < nx; i++) - for(j = 0; j < ny; j++) - for(k = 0; k < nz; k++) { - total += acc; - *array = acc; - acc++; - array++; - } /* end for */ + uint8_t acc = 128; + unsigned total = 0; + size_t i, j, k; + + for (i = 0; i < nx; i++) + for (j = 0; j < ny; j++) + for (k = 0; k < nz; k++) { + total += acc; + *array = acc; + acc++; + array++; + } /* end for */ return total; } /* end init_full() */ - /*------------------------------------------------------------------------- * Function: print_array * @@ -81,27 +79,26 @@ init_full(uint8_t *array, size_t nx, size_t ny, size_t nz) static void print_array(uint8_t *array, size_t nx, size_t ny, size_t nz) { - size_t i, j, k; - - for(i = 0; i < nx; i++) { - if(nz > 1) - HDprintf("i=%lu:\n", (unsigned long)i); - else - HDprintf("%03lu:", (unsigned long)i); - - for(j = 0; j < ny; j++) { - if(nz > 1) - HDprintf("%03lu:", (unsigned long)j); - for(k = 0; k < nz; k++) - HDprintf(" %3d", *array++); - if(nz > 1) + size_t i, j, k; + + for (i = 0; i < nx; i++) { + if (nz > 1) + HDprintf("i=%lu:\n", (unsigned long)i); + else + HDprintf("%03lu:", (unsigned long)i); + + for (j = 0; j < ny; j++) { + if (nz > 1) + HDprintf("%03lu:", (unsigned long)j); + for (k = 0; k < nz; k++) + HDprintf(" %3d", *array++); + if (nz > 1) + HDprintf("\n"); + } /* end for */ HDprintf("\n"); } /* end for */ - HDprintf("\n"); - } /* end for */ } /* end print_array() */ - /*------------------------------------------------------------------------- * Function: print_ref * @@ -121,7 +118,7 @@ print_ref(size_t nx, size_t ny, size_t nz) { uint8_t *array; - if(NULL != (array = (uint8_t *)HDmalloc(nx * ny * nz))) { + if (NULL != (array = (uint8_t *)HDmalloc(nx * ny * nz))) { HDprintf("Reference array:\n"); init_full(array, nx, ny, nz); print_array(array, nx, ny, nz); @@ -129,7 +126,6 @@ print_ref(size_t nx, size_t ny, size_t nz) } /* end if */ } /* end print_ref() */ - /*------------------------------------------------------------------------- * Function: test_fill * @@ -145,79 +141,77 @@ print_ref(size_t nx, size_t ny, size_t nz) *------------------------------------------------------------------------- */ static herr_t -test_fill(size_t nx, size_t ny, size_t nz, - size_t di, size_t dj, size_t dk, - size_t ddx, size_t ddy, size_t ddz) +test_fill(size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_t dk, size_t ddx, size_t ddy, + size_t ddz) { - uint8_t *dst = NULL; /*destination array */ - hsize_t hs_size[3]; /*hyperslab size */ - hsize_t dst_size[3]; /*destination total size */ - hsize_t dst_offset[3]; /*offset of hyperslab in dest */ - unsigned ref_value; /*reference value */ - unsigned acc; /*accumulator */ - size_t i, j, k, dx, dy, dz; /*counters */ - size_t u, v, w; - unsigned ndims; /*hyperslab dimensionality */ - char dim[64], s[256]; /*temp string */ - unsigned fill_value; /*fill value */ + uint8_t *dst = NULL; /*destination array */ + hsize_t hs_size[3]; /*hyperslab size */ + hsize_t dst_size[3]; /*destination total size */ + hsize_t dst_offset[3]; /*offset of hyperslab in dest */ + unsigned ref_value; /*reference value */ + unsigned acc; /*accumulator */ + size_t i, j, k, dx, dy, dz; /*counters */ + size_t u, v, w; + unsigned ndims; /*hyperslab dimensionality */ + char dim[64], s[256]; /*temp string */ + unsigned fill_value; /*fill value */ /* * Dimensionality. */ - if(0 == nz) { - if(0 == ny) { + if (0 == nz) { + if (0 == ny) { ndims = 1; ny = nz = 1; - HDsprintf(dim, "%lu", (unsigned long) nx); + HDsprintf(dim, "%lu", (unsigned long)nx); } /* end if */ else { ndims = 2; - nz = 1; - HDsprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny); + nz = 1; + HDsprintf(dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny); } /* end else */ - } /* end if */ + } /* end if */ else { ndims = 3; - HDsprintf(dim, "%lux%lux%lu", (unsigned long) nx, (unsigned long) ny, - (unsigned long) nz); + HDsprintf(dim, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); } /* end else */ HDsprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim); HDprintf("%-70s", s); fflush(stdout); /* Allocate array */ - if(NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) + if (NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) TEST_ERROR init_full(dst, nx, ny, nz); - for(i = 0; i < nx; i += di) { - for(j = 0; j < ny; j += dj) { - for(k = 0; k < nz; k += dk) { - for(dx = 1; dx <= nx - i; dx += ddx) { - for(dy = 1; dy <= ny - j; dy += ddy) { - for(dz = 1; dz <= nz - k; dz += ddz) { + for (i = 0; i < nx; i += di) { + for (j = 0; j < ny; j += dj) { + for (k = 0; k < nz; k += dk) { + for (dx = 1; dx <= nx - i; dx += ddx) { + for (dy = 1; dy <= ny - j; dy += ddy) { + for (dz = 1; dz <= nz - k; dz += ddz) { /* Describe the hyperslab */ - dst_size[0] = nx; - dst_size[1] = ny; - dst_size[2] = nz; + dst_size[0] = nx; + dst_size[1] = ny; + dst_size[2] = nz; dst_offset[0] = i; dst_offset[1] = j; dst_offset[2] = k; - hs_size[0] = dx; - hs_size[1] = dy; - hs_size[2] = dz; + hs_size[0] = dx; + hs_size[1] = dy; + hs_size[2] = dz; - for(fill_value = 0; fill_value < 256; fill_value += 64) { + for (fill_value = 0; fill_value < 256; fill_value += 64) { /* * Initialize the full array, then subtract the * original * fill values and add the new ones. */ ref_value = init_full(dst, nx, ny, nz); - for(u = (size_t)dst_offset[0]; u < dst_offset[0] + dx; u++) - for(v = (size_t)dst_offset[1]; v < dst_offset[1] + dy; v++) - for(w = (size_t)dst_offset[2]; w < dst_offset[2] + dz; w++) + for (u = (size_t)dst_offset[0]; u < dst_offset[0] + dx; u++) + for (v = (size_t)dst_offset[1]; v < dst_offset[1] + dy; v++) + for (w = (size_t)dst_offset[2]; w < dst_offset[2] + dz; w++) ref_value -= dst[u * ny * nz + v * nz + w]; ref_value += fill_value * (unsigned)dx * (unsigned)dy * (unsigned)dz; @@ -229,14 +223,14 @@ test_fill(size_t nx, size_t ny, size_t nz, * reference value. */ acc = 0; - for(u = 0; u < nx; u++) - for(v = 0; v < ny; v++) - for(w = 0; w < nz; w++) + for (u = 0; u < nx; u++) + for (v = 0; v < ny; v++) + for (w = 0; w < nz; w++) acc += dst[u * ny * nz + v * nz + w]; - if(acc != ref_value) { + if (acc != ref_value) { H5_FAILED() - if(!HDisatty(1)) { + if (!HDisatty(1)) { /* * Print debugging info unless output * is going directly to a terminal. @@ -244,26 +238,24 @@ test_fill(size_t nx, size_t ny, size_t nz, AT(); HDprintf(" acc != ref_value\n"); HDprintf(" i=%lu, j=%lu, k=%lu, " - "dx=%lu, dy=%lu, dz=%lu, " - "fill=%d\n", (unsigned long)i, - (unsigned long)j, - (unsigned long)k, - (unsigned long)dx, - (unsigned long)dy, - (unsigned long)dz, fill_value); + "dx=%lu, dy=%lu, dz=%lu, " + "fill=%d\n", + (unsigned long)i, (unsigned long)j, (unsigned long)k, + (unsigned long)dx, (unsigned long)dy, (unsigned long)dz, + fill_value); print_ref(nx, ny, nz); HDprintf("\n Result is:\n"); print_array(dst, nx, ny, nz); } /* end if */ goto error; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ - } /* end for */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ PASSED(); @@ -272,12 +264,11 @@ test_fill(size_t nx, size_t ny, size_t nz, return SUCCEED; error: - if(dst) + if (dst) HDfree(dst); return FAIL; } /* end test_fill() */ - /*------------------------------------------------------------------------- * Function: test_copy * @@ -305,48 +296,45 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_copy(int mode, - size_t nx, size_t ny, size_t nz, - size_t di, size_t dj, size_t dk, - size_t ddx, size_t ddy, size_t ddz) +test_copy(int mode, size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_t dk, size_t ddx, size_t ddy, + size_t ddz) { - uint8_t *src = NULL; /*source array */ - uint8_t *dst = NULL; /*destination array */ - hsize_t hs_size[3]; /*hyperslab size */ - hsize_t dst_size[3]; /*destination total size */ - hsize_t src_size[3]; /*source total size */ - hsize_t dst_offset[3]; /*offset of hyperslab in dest */ - hsize_t src_offset[3]; /*offset of hyperslab in source */ - unsigned ref_value; /*reference value */ - unsigned acc; /*accumulator */ + uint8_t * src = NULL; /*source array */ + uint8_t * dst = NULL; /*destination array */ + hsize_t hs_size[3]; /*hyperslab size */ + hsize_t dst_size[3]; /*destination total size */ + hsize_t src_size[3]; /*source total size */ + hsize_t dst_offset[3]; /*offset of hyperslab in dest */ + hsize_t src_offset[3]; /*offset of hyperslab in source */ + unsigned ref_value; /*reference value */ + unsigned acc; /*accumulator */ hsize_t i, j, k, dx, dy, dz; /*counters */ hsize_t u, v, w; - unsigned ndims; /*hyperslab dimensionality */ + unsigned ndims; /*hyperslab dimensionality */ char dim[64], s[256]; /*temp string */ const char *sub; /* * Dimensionality. */ - if(0 == nz) { - if(0 == ny) { + if (0 == nz) { + if (0 == ny) { ndims = 1; ny = nz = 1; - HDsprintf(dim, "%lu", (unsigned long) nx); + HDsprintf(dim, "%lu", (unsigned long)nx); } /* end if */ else { ndims = 2; - nz = 1; - HDsprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny); + nz = 1; + HDsprintf(dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny); } /* end else */ - } /* end if */ + } /* end if */ else { ndims = 3; - HDsprintf(dim, "%lux%lux%lu", (unsigned long) nx, (unsigned long) ny, - (unsigned long) nz); + HDsprintf(dim, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); } /* end else */ - switch(mode) { + switch (mode) { case VARIABLE_SRC: /* * The hyperslab "travels" through the source array but the @@ -383,31 +371,31 @@ test_copy(int mode, /* * Allocate arrays */ - if(NULL == (src = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) + if (NULL == (src = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) TEST_ERROR - if(NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) + if (NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) TEST_ERROR init_full(src, nx, ny, nz); - for(i = 0; i < nx; i += di) { - for(j = 0; j < ny; j += dj) { - for(k = 0; k < nz; k += dk) { - for(dx = 1; dx <= nx - i; dx += ddx) { - for(dy = 1; dy <= ny - j; dy += ddy) { - for(dz = 1; dz <= nz - k; dz += ddz) { + for (i = 0; i < nx; i += di) { + for (j = 0; j < ny; j += dj) { + for (k = 0; k < nz; k += dk) { + for (dx = 1; dx <= nx - i; dx += ddx) { + for (dy = 1; dy <= ny - j; dy += ddy) { + for (dz = 1; dz <= nz - k; dz += ddz) { /* * Describe the source and destination hyperslabs * and the arrays to which they belong. */ - hs_size[0] = dx; - hs_size[1] = dy; - hs_size[2] = dz; + hs_size[0] = dx; + hs_size[1] = dy; + hs_size[2] = dz; dst_size[0] = src_size[0] = nx; dst_size[1] = src_size[1] = ny; dst_size[2] = src_size[2] = nz; - switch(mode) { + switch (mode) { case VARIABLE_SRC: dst_offset[0] = 0; dst_offset[1] = 0; @@ -444,38 +432,39 @@ test_copy(int mode, * value to compare against later. */ ref_value = 0; - for(u = src_offset[0]; u < src_offset[0] + dx; u++) - for(v = src_offset[1]; v < src_offset[1] + dy; v++) - for(w = src_offset[2]; w < src_offset[2] + dz; w++) + for (u = src_offset[0]; u < src_offset[0] + dx; u++) + for (v = src_offset[1]; v < src_offset[1] + dy; v++) + for (w = src_offset[2]; w < src_offset[2] + dz; w++) ref_value += src[u * ny * nz + v * nz + w]; /* * Set all loc values to 1 so we can detect writing * outside the hyperslab. */ - for(u = 0; u < nx; u++) - for(v = 0; v < ny; v++) - for(w = 0; w < nz; w++) + for (u = 0; u < nx; u++) + for (v = 0; v < ny; v++) + for (w = 0; w < nz; w++) dst[u * ny * nz + v * nz + w] = 1; /* * Copy a hyperslab from the global array to the * local array. */ - H5VM_hyper_copy(ndims, hs_size, dst_size, dst_offset, dst, src_size, src_offset, src); + H5VM_hyper_copy(ndims, hs_size, dst_size, dst_offset, dst, src_size, src_offset, + src); /* * Sum the destination hyperslab. It should be * the same as the reference value. */ acc = 0; - for(u = dst_offset[0]; u < dst_offset[0] + dx; u++) - for(v = dst_offset[1]; v < dst_offset[1] + dy; v++) - for(w = dst_offset[2]; w < dst_offset[2] + dz; w++) + for (u = dst_offset[0]; u < dst_offset[0] + dx; u++) + for (v = dst_offset[1]; v < dst_offset[1] + dy; v++) + for (w = dst_offset[2]; w < dst_offset[2] + dz; w++) acc += dst[u * ny * nz + v * nz + w]; - if(acc != ref_value) { + if (acc != ref_value) { H5_FAILED() - if(!HDisatty(1)) { + if (!HDisatty(1)) { /* * Print debugging info unless output is * going directly to a terminal. @@ -483,13 +472,9 @@ test_copy(int mode, AT(); HDprintf(" acc != ref_value\n"); HDprintf(" i=%lu, j=%lu, k=%lu, " - "dx=%lu, dy=%lu, dz=%lu\n", - (unsigned long)i, - (unsigned long)j, - (unsigned long)k, - (unsigned long)dx, - (unsigned long)dy, - (unsigned long)dz); + "dx=%lu, dy=%lu, dz=%lu\n", + (unsigned long)i, (unsigned long)j, (unsigned long)k, + (unsigned long)dx, (unsigned long)dy, (unsigned long)dz); print_ref(nx, ny, nz); HDprintf("\n Destination array is:\n"); print_array(dst, nx, ny, nz); @@ -503,9 +488,9 @@ test_copy(int mode, * we added the border of 1's to the hyperslab. */ acc = 0; - for(u = 0; u < nx; u++) - for(v = 0; v < ny; v++) - for(w = 0; w < nz; w++) + for (u = 0; u < nx; u++) + for (v = 0; v < ny; v++) + for (w = 0; w < nz; w++) acc += dst[u * ny * nz + v * nz + w]; /* @@ -513,37 +498,33 @@ test_copy(int mode, * optimization bug in the Mongoose 7.20 Irix64 * compiler. */ - if(acc + (unsigned) dx * (unsigned) dy - * (unsigned) dz != ref_value + nx * ny * nz) { + if (acc + (unsigned)dx * (unsigned)dy * (unsigned)dz != + ref_value + nx * ny * nz) { H5_FAILED() - if(!HDisatty(1)) { + if (!HDisatty(1)) { /* * Print debugging info unless output is * going directly to a terminal. */ AT(); HDprintf(" acc != ref_value + nx*ny*nz - " - "dx*dy*dz\n"); + "dx*dy*dz\n"); HDprintf(" i=%lu, j=%lu, k=%lu, " - "dx=%lu, dy=%lu, dz=%lu\n", - (unsigned long)i, - (unsigned long)j, - (unsigned long)k, - (unsigned long)dx, - (unsigned long)dy, - (unsigned long)dz); + "dx=%lu, dy=%lu, dz=%lu\n", + (unsigned long)i, (unsigned long)j, (unsigned long)k, + (unsigned long)dx, (unsigned long)dy, (unsigned long)dz); print_ref(nx, ny, nz); HDprintf("\n Destination array is:\n"); print_array(dst, nx, ny, nz); } /* end if */ goto error; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ PASSED(); @@ -553,15 +534,14 @@ test_copy(int mode, return SUCCEED; error: - if(src) + if (src) HDfree(src); - if(dst) + if (dst) HDfree(dst); return FAIL; } /* end test_copy() */ - /*------------------------------------------------------------------------- * Function: test_multifill * @@ -583,32 +563,32 @@ error: static herr_t test_multifill(size_t nx) { - hsize_t size; - hsize_t src_stride; - hsize_t dst_stride; - char s[64]; + hsize_t size; + hsize_t src_stride; + hsize_t dst_stride; + char s[64]; struct a_struct { - int left; + int left; double mid; - int right; + int right; } fill, *src = NULL, *dst = NULL; - hsize_t i, j; + hsize_t i, j; HDprintf("%-70s", "Testing multi-byte fill value"); fflush(stdout); /* Initialize the source and destination */ - if(NULL == (src = (struct a_struct *)HDmalloc(nx * sizeof(*src)))) + if (NULL == (src = (struct a_struct *)HDmalloc(nx * sizeof(*src)))) TEST_ERROR - if(NULL == (dst = (struct a_struct *)HDmalloc(nx * sizeof(*dst)))) + if (NULL == (dst = (struct a_struct *)HDmalloc(nx * sizeof(*dst)))) TEST_ERROR - for(i = 0; i < nx; i++) { - src[i].left = 1111111; - src[i].mid = 12345.6789F; + for (i = 0; i < nx; i++) { + src[i].left = 1111111; + src[i].mid = 12345.6789F; src[i].right = 2222222; - dst[i].left = 3333333; - dst[i].mid = 98765.4321F; + dst[i].left = 3333333; + dst[i].mid = 98765.4321F; dst[i].right = 4444444; } /* end for */ @@ -616,8 +596,8 @@ test_multifill(size_t nx) * Describe the fill value. The zero stride says to read the same thing * over and over again. */ - fill.left = 55555555; - fill.mid = 3.1415927F; + fill.left = 55555555; + fill.mid = 3.1415927F; fill.right = 66666666; src_stride = 0; @@ -630,41 +610,39 @@ test_multifill(size_t nx) * Copy the fill value into each element */ size = nx; - H5VM_stride_copy(1, (hsize_t)sizeof(double), &size, &dst_stride, - &(dst[0].mid), &src_stride, &(fill.mid)); + H5VM_stride_copy(1, (hsize_t)sizeof(double), &size, &dst_stride, &(dst[0].mid), &src_stride, &(fill.mid)); /* * Check */ s[0] = '\0'; - for(i = 0; i < nx; i++) { - if(dst[i].left != 3333333) + for (i = 0; i < nx; i++) { + if (dst[i].left != 3333333) HDsprintf(s, "bad dst[%lu].left", (unsigned long)i); - else if(!H5_DBL_ABS_EQUAL(dst[i].mid, fill.mid)) + else if (!H5_DBL_ABS_EQUAL(dst[i].mid, fill.mid)) /* Check if two DOUBLE values are equal. If their difference * is smaller than the EPSILON value for double, they are * considered equal. See the definition in h5test.h. */ HDsprintf(s, "bad dst[%lu].mid", (unsigned long)i); - else if(dst[i].right != 4444444) + else if (dst[i].right != 4444444) HDsprintf(s, "bad dst[%lu].right", (unsigned long)i); - if(s[0]) { + if (s[0]) { H5_FAILED() - if(!HDisatty(1)) { + if (!HDisatty(1)) { AT(); - HDprintf(" fill={%d,%g,%d}\n ", fill.left, fill.mid, - fill.right); - for(j = 0; j < sizeof(fill); j++) + HDprintf(" fill={%d,%g,%d}\n ", fill.left, fill.mid, fill.right); + for (j = 0; j < sizeof(fill); j++) HDprintf(" %02x", ((uint8_t *)&fill)[j]); - HDprintf("\n dst[%lu]={%d,%g,%d}\n ", (unsigned long)i, - dst[i].left, dst[i].mid, dst[i].right); - for(j = 0; j < sizeof(dst[i]); j++) + HDprintf("\n dst[%lu]={%d,%g,%d}\n ", (unsigned long)i, dst[i].left, dst[i].mid, + dst[i].right); + for (j = 0; j < sizeof(dst[i]); j++) HDprintf(" %02x", ((uint8_t *)(dst + i))[j]); HDprintf("\n"); } /* end if */ goto error; } /* end if */ - } /* end for */ + } /* end for */ PASSED(); @@ -674,15 +652,14 @@ test_multifill(size_t nx) return SUCCEED; error: - if(src) + if (src) HDfree(src); - if(dst) + if (dst) HDfree(dst); return FAIL; } /* end test_multifill() */ - /*------------------------------------------------------------------------- * Function: test_endian * @@ -702,41 +679,41 @@ error: static herr_t test_endian(size_t nx) { - uint8_t *src = NULL; /*source array */ - uint8_t *dst = NULL; /*destination array */ - hssize_t src_stride[2]; /*source strides */ - hssize_t dst_stride[2]; /*destination strides */ - hsize_t size[2]; /*size vector */ - hsize_t i, j; + uint8_t *src = NULL; /*source array */ + uint8_t *dst = NULL; /*destination array */ + hssize_t src_stride[2]; /*source strides */ + hssize_t dst_stride[2]; /*destination strides */ + hsize_t size[2]; /*size vector */ + hsize_t i, j; HDprintf("%-70s", "Testing endian conversion by stride"); fflush(stdout); /* Initialize arrays */ - if(NULL == (src = (uint8_t *)HDmalloc(nx * 4))) + if (NULL == (src = (uint8_t *)HDmalloc(nx * 4))) TEST_ERROR - if(NULL == (dst = (uint8_t *)HDcalloc(nx , (size_t)4))) + if (NULL == (dst = (uint8_t *)HDcalloc(nx, (size_t)4))) TEST_ERROR - init_full(src, nx, (size_t)4,(size_t)1); + init_full(src, nx, (size_t)4, (size_t)1); /* Initialize strides */ src_stride[0] = 0; src_stride[1] = 1; dst_stride[0] = 8; dst_stride[1] = -1; - size[0] = nx; - size[1] = 4; + size[0] = nx; + size[1] = 4; /* Copy the array */ H5VM_stride_copy_s(2, (hsize_t)1, size, dst_stride, dst + 3, src_stride, src); /* Compare */ - for(i = 0; i < nx; i++) { - for(j = 0; j < 4; j++) { - if(src[i * 4 + j] != dst[i * 4 + 3 - j]) { + for (i = 0; i < nx; i++) { + for (j = 0; j < 4; j++) { + if (src[i * 4 + j] != dst[i * 4 + 3 - j]) { H5_FAILED() - if(!HDisatty(1)) { + if (!HDisatty(1)) { /* * Print debugging info unless output is going directly * to a terminal. @@ -750,8 +727,8 @@ test_endian(size_t nx) } /* end if */ goto error; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ PASSED(); @@ -761,15 +738,14 @@ test_endian(size_t nx) return SUCCEED; error: - if(src) + if (src) HDfree(src); - if(dst) + if (dst) HDfree(dst); return FAIL; } /* end test_endian() */ - /*------------------------------------------------------------------------- * Function: test_transpose * @@ -788,67 +764,65 @@ error: static herr_t test_transpose(size_t nx, size_t ny) { - int *src = NULL; - int *dst = NULL; - hsize_t src_stride[2], dst_stride[2]; - hsize_t size[2]; + int * src = NULL; + int * dst = NULL; + hsize_t src_stride[2], dst_stride[2]; + hsize_t size[2]; char s[256]; - hsize_t i, j; + hsize_t i, j; - HDsprintf(s, "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx, - (unsigned long)ny); + HDsprintf(s, "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx, (unsigned long)ny); HDprintf("%-70s", s); fflush(stdout); /* Initialize */ - if(NULL == (src = (int *)HDmalloc(nx * ny * sizeof(*src)))) + if (NULL == (src = (int *)HDmalloc(nx * ny * sizeof(*src)))) TEST_ERROR - if(NULL == (dst = (int *)HDcalloc(nx * ny, sizeof(*dst)))) + if (NULL == (dst = (int *)HDcalloc(nx * ny, sizeof(*dst)))) TEST_ERROR - for(i = 0; i < nx; i++) - for(j = 0; j < ny; j++) + for (i = 0; i < nx; i++) + for (j = 0; j < ny; j++) src[i * ny + j] = (int)(i * ny + j); /* Build stride info */ - size[0] = nx; - size[1] = ny; + size[0] = nx; + size[1] = ny; src_stride[0] = 0; src_stride[1] = sizeof(*src); dst_stride[0] = (hsize_t)((1 - nx * ny) * sizeof(*src)); dst_stride[1] = (hsize_t)(nx * sizeof(*src)); /* Copy and transpose */ - H5VM_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst, - src_stride, src); + H5VM_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst, src_stride, src); /* Check */ - for(i = 0; i < nx; i++) { - for(j = 0; j < ny; j++) { - if(src[i * ny + j] != dst[j * nx + i]) { + for (i = 0; i < nx; i++) { + for (j = 0; j < ny; j++) { + if (src[i * ny + j] != dst[j * nx + i]) { H5_FAILED() - if(!HDisatty(1)) { + if (!HDisatty(1)) { AT(); HDprintf(" diff at i=%lu, j=%lu\n", (unsigned long)i, (unsigned long)j); HDprintf(" Source is:\n"); - for(i = 0; i < nx; i++) { + for (i = 0; i < nx; i++) { HDprintf("%3lu:", (unsigned long)i); - for(j = 0; j < ny; j++) + for (j = 0; j < ny; j++) HDprintf(" %6d", src[i * ny + j]); HDprintf("\n"); } /* end for */ HDprintf("\n Destination is:\n"); for (i = 0; i < ny; i++) { HDprintf("%3lu:", (unsigned long)i); - for(j = 0; j < nx; j++) + for (j = 0; j < nx; j++) HDprintf(" %6d", dst[i * nx + j]); HDprintf("\n"); } /* end for */ - } /* end if */ + } /* end if */ goto error; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ PASSED(); @@ -858,15 +832,14 @@ test_transpose(size_t nx, size_t ny) return SUCCEED; error: - if(src) + if (src) HDfree(src); - if(dst) + if (dst) HDfree(dst); return FAIL; } /* end test_transpose() */ - /*------------------------------------------------------------------------- * Function: test_sub_super * @@ -887,53 +860,50 @@ error: static herr_t test_sub_super(size_t nx, size_t ny) { - uint8_t *full = NULL; /*original image */ - uint8_t *half = NULL; /*image at 1/2 resolution */ - uint8_t *twice = NULL; /*2x2 pixels */ - hsize_t src_stride[4]; /*source stride info */ - hsize_t dst_stride[4]; /*destination stride info */ - hsize_t size[4]; /*number of sample points */ - hsize_t i, j; - char s[256]; - - HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", - (unsigned long)(2 * nx), (unsigned long)(2 * ny), - (unsigned long)nx, (unsigned long)ny); + uint8_t *full = NULL; /*original image */ + uint8_t *half = NULL; /*image at 1/2 resolution */ + uint8_t *twice = NULL; /*2x2 pixels */ + hsize_t src_stride[4]; /*source stride info */ + hsize_t dst_stride[4]; /*destination stride info */ + hsize_t size[4]; /*number of sample points */ + hsize_t i, j; + char s[256]; + + HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)(2 * nx), + (unsigned long)(2 * ny), (unsigned long)nx, (unsigned long)ny); HDprintf("%-70s", s); fflush(stdout); /* Initialize */ - if(NULL == (full = (uint8_t *)HDmalloc(4 * nx * ny))) + if (NULL == (full = (uint8_t *)HDmalloc(4 * nx * ny))) TEST_ERROR - if(NULL == (half = (uint8_t *)HDcalloc((size_t)1, nx * ny))) + if (NULL == (half = (uint8_t *)HDcalloc((size_t)1, nx * ny))) TEST_ERROR - if(NULL == (twice = (uint8_t *)HDcalloc((size_t)4, nx * ny))) + if (NULL == (twice = (uint8_t *)HDcalloc((size_t)4, nx * ny))) TEST_ERROR init_full(full, 2 * nx, 2 * ny, (size_t)1); /* Setup */ - size[0] = nx; - size[1] = ny; + size[0] = nx; + size[1] = ny; src_stride[0] = (hsize_t)(2 * ny); src_stride[1] = 2; dst_stride[0] = 0; dst_stride[1] = 1; /* Copy */ - H5VM_stride_copy(2, (hsize_t)sizeof(uint8_t), size, dst_stride, half, - src_stride, full); + H5VM_stride_copy(2, (hsize_t)sizeof(uint8_t), size, dst_stride, half, src_stride, full); /* Check */ - for(i = 0; i < nx; i++) { - for(j = 0; j < ny; j++) { - if(full[4 * i * ny + 2 * j] != half[i * ny + j]) { + for (i = 0; i < nx; i++) { + for (j = 0; j < ny; j++) { + if (full[4 * i * ny + 2 * j] != half[i * ny + j]) { H5_FAILED() - if(!HDisatty(1)) { + if (!HDisatty(1)) { AT(); - HDprintf(" full[%lu][%lu] != half[%lu][%lu]\n", - (unsigned long)i * 2, (unsigned long)j * 2, - (unsigned long)i, (unsigned long)j); + HDprintf(" full[%lu][%lu] != half[%lu][%lu]\n", (unsigned long)i * 2, + (unsigned long)j * 2, (unsigned long)i, (unsigned long)j); HDprintf(" full is:\n"); print_array(full, 2 * nx, 2 * ny, (size_t)1); HDprintf("\n half is:\n"); @@ -941,25 +911,24 @@ test_sub_super(size_t nx, size_t ny) } /* end if */ goto error; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ PASSED(); /* * Test replicating pixels to produce an image twice as large in each * dimension. */ - HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", - (unsigned long)nx, (unsigned long)ny, (unsigned long)(2 * nx), - (unsigned long)(2 * ny)); + HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)nx, (unsigned long)ny, + (unsigned long)(2 * nx), (unsigned long)(2 * ny)); HDprintf("%-70s", s); fflush(stdout); /* Setup stride */ - size[0] = nx; - size[1] = ny; - size[2] = 2; - size[3] = 2; + size[0] = nx; + size[1] = ny; + size[2] = 2; + size[3] = 2; src_stride[0] = 0; src_stride[1] = 1; src_stride[2] = 0; @@ -970,32 +939,27 @@ test_sub_super(size_t nx, size_t ny) dst_stride[3] = sizeof(uint8_t); /* Copy */ - H5VM_stride_copy(4, (hsize_t)sizeof(uint8_t), size, dst_stride, twice, - src_stride, half); + H5VM_stride_copy(4, (hsize_t)sizeof(uint8_t), size, dst_stride, twice, src_stride, half); /* Check */ s[0] = '\0'; - for(i = 0; i < nx; i++) { - for(j = 0; j < ny; j++) { - if(half[i * ny + j] != twice[4 * i * ny + 2 * j]) - HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", - (unsigned long)i, (unsigned long)j, - (unsigned long)i * 2, (unsigned long)j * 2); - else if(half[i * ny + j] != twice[4 * i * ny + 2 * j + 1]) - HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", - (unsigned long)i, (unsigned long)j, - (unsigned long)i * 2, (unsigned long)j * 2 + 1); - else if(half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j]) - HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", - (unsigned long)i, (unsigned long)j, - (unsigned long)i * 2 + 1, (unsigned long)j * 2); - else if(half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1]) - HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", - (unsigned long)i, (unsigned long)j, - (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1); - if(s[0]) { + for (i = 0; i < nx; i++) { + for (j = 0; j < ny; j++) { + if (half[i * ny + j] != twice[4 * i * ny + 2 * j]) + HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j, + (unsigned long)i * 2, (unsigned long)j * 2); + else if (half[i * ny + j] != twice[4 * i * ny + 2 * j + 1]) + HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j, + (unsigned long)i * 2, (unsigned long)j * 2 + 1); + else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j]) + HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j, + (unsigned long)i * 2 + 1, (unsigned long)j * 2); + else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1]) + HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j, + (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1); + if (s[0]) { H5_FAILED() - if(!HDisatty(1)) { + if (!HDisatty(1)) { AT(); HDprintf(" %s\n Half is:\n", s); print_array(half, nx, ny, (size_t)1); @@ -1004,8 +968,8 @@ test_sub_super(size_t nx, size_t ny) } /* end if */ goto error; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ PASSED(); @@ -1016,17 +980,16 @@ test_sub_super(size_t nx, size_t ny) return SUCCEED; error: - if(full) + if (full) HDfree(full); - if(half) + if (half) HDfree(half); - if(twice) + if (twice) HDfree(twice); return FAIL; } /* test_sub_super() */ - /*------------------------------------------------------------------------- * Function: test_array_fill * @@ -1046,29 +1009,29 @@ error: static herr_t test_array_fill(size_t lo, size_t hi) { - int *dst = NULL; /* Destination */ - int src[ARRAY_FILL_SIZE]; /* Source to duplicate */ - size_t u, v, w; /* Local index variables */ - char s[256]; + int * dst = NULL; /* Destination */ + int src[ARRAY_FILL_SIZE]; /* Source to duplicate */ + size_t u, v, w; /* Local index variables */ + char s[256]; TESTING("array filling %4zu-%-4zu elements", lo, hi); /* Initialize */ - if(NULL == (dst = (int *)HDcalloc(sizeof(int),ARRAY_FILL_SIZE * hi))) + if (NULL == (dst = (int *)HDcalloc(sizeof(int), ARRAY_FILL_SIZE * hi))) TEST_ERROR /* Setup */ - for(u = 0; u < ARRAY_FILL_SIZE; u++) + for (u = 0; u < ARRAY_FILL_SIZE; u++) src[u] = (char)u; /* Fill */ - for(w = lo; w <= hi; w++) { + for (w = lo; w <= hi; w++) { H5VM_array_fill(dst, src, sizeof(src), w); /* Check */ - for(u = 0; u < w; u++) - for(v = 0; v < ARRAY_FILL_SIZE; v++) - if(dst[(u * ARRAY_FILL_SIZE) + v] != src[v]) + for (u = 0; u < w; u++) + for (v = 0; v < ARRAY_FILL_SIZE; v++) + if (dst[(u * ARRAY_FILL_SIZE) + v] != src[v]) TEST_ERROR HDmemset(dst, 0, sizeof(int) * ARRAY_FILL_SIZE * w); @@ -1081,12 +1044,11 @@ test_array_fill(size_t lo, size_t hi) return SUCCEED; error: - if(dst) + if (dst) HDfree(dst); return FAIL; } /* end test_array_fill() */ - /*------------------------------------------------------------------------- * Function: test_array_offset_n_calc * @@ -1106,19 +1068,19 @@ error: static herr_t test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) { - hsize_t *a = NULL; - hsize_t *temp_a; /* Array for stored calculated offsets */ - hsize_t off; /* Offset in array */ - size_t u, v, w; /* Local index variables */ - hsize_t dims[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of array to check */ - hsize_t coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates to check offset of */ - hsize_t new_coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of offset */ - char s[256]; + hsize_t *a = NULL; + hsize_t *temp_a; /* Array for stored calculated offsets */ + hsize_t off; /* Offset in array */ + size_t u, v, w; /* Local index variables */ + hsize_t dims[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of array to check */ + hsize_t coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates to check offset of */ + hsize_t new_coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of offset */ + char s[256]; TESTING("array offset %4zux%4zux%4zu elements", z, y, x); /* Initialize */ - if(NULL == (a = (hsize_t *)HDmalloc(sizeof(hsize_t) * x * y *z))) + if (NULL == (a = (hsize_t *)HDmalloc(sizeof(hsize_t) * x * y * z))) TEST_ERROR dims[0] = z; @@ -1126,13 +1088,13 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) dims[2] = x; /* Setup */ - for(u = 0, temp_a = a, off = 0; u < z; u++) - for(v = 0; v < y; v++) - for(w = 0; w < x; w++) + for (u = 0, temp_a = a, off = 0; u < z; u++) + for (v = 0; v < y; v++) + for (w = 0; w < x; w++) *temp_a++ = off++; /* Check offsets */ - for(u = 0; u < n; u++) { + for (u = 0; u < n; u++) { /* Get random coordinate */ coords[0] = (hsize_t)((size_t)HDrandom() % z); coords[1] = (hsize_t)((size_t)HDrandom() % y); @@ -1142,20 +1104,21 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) off = H5VM_array_offset(ARRAY_OFFSET_NDIMS, dims, coords); /* Check offset of coordinate */ - if(a[off] != off) + if (a[off] != off) TEST_ERROR /* Get coordinates of offset */ - if(H5VM_array_calc(off, ARRAY_OFFSET_NDIMS, dims, new_coords) < 0) + if (H5VM_array_calc(off, ARRAY_OFFSET_NDIMS, dims, new_coords) < 0) TEST_ERROR /* Check computed coordinates */ - for(v = 0; v < ARRAY_OFFSET_NDIMS; v++) - if(coords[v] != new_coords[v]) { - HDfprintf(stderr,"coords[%u]=%Hu, new_coords[%u]=%Hu\n", (unsigned)v, coords[v], (unsigned)v, new_coords[v]); + for (v = 0; v < ARRAY_OFFSET_NDIMS; v++) + if (coords[v] != new_coords[v]) { + HDfprintf(stderr, "coords[%u]=%Hu, new_coords[%u]=%Hu\n", (unsigned)v, coords[v], (unsigned)v, + new_coords[v]); TEST_ERROR; } /* end if */ - } /* end for */ + } /* end for */ PASSED(); @@ -1164,13 +1127,12 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) return SUCCEED; error: - if(a) + if (a) HDfree(a); return FAIL; } /* end test_array_offset_n_calc() */ - /*------------------------------------------------------------------------- * Function: main * @@ -1188,32 +1150,32 @@ error: int main(int argc, char *argv[]) { - herr_t status; - int nerrors = 0; - unsigned size_of_test; + herr_t status; + int nerrors = 0; + unsigned size_of_test; /* Parse arguments or assume `small' & `medium' */ - if(1 == argc) + if (1 == argc) size_of_test = TEST_SMALL | TEST_MEDIUM; else { int i; - for(i = 1, size_of_test = 0; i < argc; i++) { - if(!HDstrcmp(argv[i], "small")) + for (i = 1, size_of_test = 0; i < argc; i++) { + if (!HDstrcmp(argv[i], "small")) size_of_test |= TEST_SMALL; - else if(!HDstrcmp(argv[i], "medium")) + else if (!HDstrcmp(argv[i], "medium")) size_of_test |= TEST_MEDIUM; else { HDprintf("unrecognized argument: %s\n", argv[i]); HDexit(EXIT_FAILURE); } /* end else */ - } /* end for */ - } /* end else */ + } /* end for */ + } /* end else */ HDprintf("Test sizes: "); - if(size_of_test & TEST_SMALL) + if (size_of_test & TEST_SMALL) HDprintf(" SMALL"); - if(size_of_test & TEST_MEDIUM) + if (size_of_test & TEST_MEDIUM) HDprintf(" MEDIUM"); HDprintf("\n"); @@ -1226,33 +1188,33 @@ main(int argc, char *argv[]) */ #ifdef H5_HAVE_THREADSAFE H5open(); -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ /* *------------------------------ * TEST HYPERSLAB FILL OPERATION *------------------------------ */ - if(size_of_test & TEST_SMALL) { - status = test_fill((size_t)11, (size_t)0, (size_t)0, (size_t)1, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + if (size_of_test & TEST_SMALL) { + status = test_fill((size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_fill((size_t)11, (size_t)10, (size_t)0, (size_t)1, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_fill((size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_fill((size_t)3, (size_t)5, (size_t)5, (size_t)1, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_fill((size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { - status = test_fill((size_t)113, (size_t)0, (size_t)0, (size_t)1, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + if (size_of_test & TEST_MEDIUM) { + status = test_fill((size_t)113, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_fill((size_t)15, (size_t)11, (size_t)0, (size_t)1, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_fill((size_t)15, (size_t)11, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_fill((size_t)5, (size_t)7, (size_t)7, (size_t)1, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_fill((size_t)5, (size_t)7, (size_t)7, (size_t)1, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ @@ -1262,84 +1224,84 @@ main(int argc, char *argv[]) */ /* exhaustive, one-dimensional test */ - if(size_of_test & TEST_SMALL) { - status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)0, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + if (size_of_test & TEST_SMALL) { + status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)11, (size_t)0, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_DST, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)0, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { - status = test_copy(VARIABLE_SRC, (size_t)179, (size_t)0, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + if (size_of_test & TEST_MEDIUM) { + status = test_copy(VARIABLE_SRC, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)179, (size_t)0, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_DST, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)179, (size_t)0, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_BOTH, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ /* exhaustive, two-dimensional test */ - if(size_of_test & TEST_SMALL) { - status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)10, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + if (size_of_test & TEST_SMALL) { + status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)11, (size_t)10, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_DST, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)10, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { - status = test_copy(VARIABLE_SRC, (size_t)13, (size_t)19, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + if (size_of_test & TEST_MEDIUM) { + status = test_copy(VARIABLE_SRC, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)13, (size_t)19, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_DST, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)13, (size_t)19, (size_t)0, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_BOTH, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ /* sparse, two-dimensional test */ - if(size_of_test & TEST_MEDIUM) { - status = test_copy(VARIABLE_SRC, (size_t)73, (size_t)67, (size_t)0, - (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); + if (size_of_test & TEST_MEDIUM) { + status = test_copy(VARIABLE_SRC, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1, + (size_t)13, (size_t)11, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)73, (size_t)67, (size_t)0, - (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); + status = test_copy(VARIABLE_DST, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1, + (size_t)13, (size_t)11, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)73, (size_t)67, (size_t)0, - (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); + status = test_copy(VARIABLE_BOTH, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1, + (size_t)13, (size_t)11, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ /* exhaustive, three-dimensional test */ - if(size_of_test & TEST_SMALL) { - status = test_copy(VARIABLE_SRC, (size_t)3, (size_t)5, (size_t)5, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + if (size_of_test & TEST_SMALL) { + status = test_copy(VARIABLE_SRC, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)3, (size_t)5, (size_t)5, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_DST, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)3, (size_t)5, (size_t)5, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_BOTH, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { - status = test_copy(VARIABLE_SRC, (size_t)7, (size_t)9, (size_t)5, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + if (size_of_test & TEST_MEDIUM) { + status = test_copy(VARIABLE_SRC, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)7, (size_t)9, (size_t)5, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_DST, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)7, (size_t)9, (size_t)5, - (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + status = test_copy(VARIABLE_BOTH, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1, + (size_t)1, (size_t)1, (size_t)1); nerrors += status < 0 ? 1 : 0; } /* end if */ @@ -1347,11 +1309,11 @@ main(int argc, char *argv[]) * TEST MULTI-BYTE FILL *--------------------- */ - if(size_of_test & TEST_SMALL) { + if (size_of_test & TEST_SMALL) { status = test_multifill((size_t)10); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { + if (size_of_test & TEST_MEDIUM) { status = test_multifill((size_t)500000); nerrors += status < 0 ? 1 : 0; } /* end if */ @@ -1360,7 +1322,7 @@ main(int argc, char *argv[]) * TEST TRANSLATION OPERATORS *--------------------------- */ - if(size_of_test & TEST_SMALL) { + if (size_of_test & TEST_SMALL) { status = test_endian((size_t)10); nerrors += status < 0 ? 1 : 0; status = test_transpose((size_t)9, (size_t)9); @@ -1368,7 +1330,7 @@ main(int argc, char *argv[]) status = test_transpose((size_t)3, (size_t)11); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { + if (size_of_test & TEST_MEDIUM) { status = test_endian((size_t)800000); nerrors += status < 0 ? 1 : 0; status = test_transpose((size_t)1200, (size_t)1200); @@ -1381,11 +1343,11 @@ main(int argc, char *argv[]) * TEST SAMPLING OPERATIONS *------------------------- */ - if(size_of_test & TEST_SMALL) { + if (size_of_test & TEST_SMALL) { status = test_sub_super((size_t)5, (size_t)10); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { + if (size_of_test & TEST_MEDIUM) { status = test_sub_super((size_t)480, (size_t)640); nerrors += status < 0 ? 1 : 0; } /* end if */ @@ -1394,11 +1356,11 @@ main(int argc, char *argv[]) * TEST ARRAY FILL OPERATIONS *------------------------- */ - if(size_of_test & TEST_SMALL) { + if (size_of_test & TEST_SMALL) { status = test_array_fill((size_t)1, (size_t)9); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { + if (size_of_test & TEST_MEDIUM) { status = test_array_fill((size_t)9, (size_t)257); nerrors += status < 0 ? 1 : 0; } /* end if */ @@ -1407,23 +1369,20 @@ main(int argc, char *argv[]) * TEST ARRAY OFFSET OPERATIONS *------------------------- */ - if(size_of_test & TEST_SMALL) { - status = test_array_offset_n_calc((size_t)20, (size_t)7, (size_t)11, - (size_t)13); + if (size_of_test & TEST_SMALL) { + status = test_array_offset_n_calc((size_t)20, (size_t)7, (size_t)11, (size_t)13); nerrors += status < 0 ? 1 : 0; } /* end if */ - if(size_of_test & TEST_MEDIUM) { - status = test_array_offset_n_calc((size_t)500, (size_t)71, - (size_t)193, (size_t)347); + if (size_of_test & TEST_MEDIUM) { + status = test_array_offset_n_calc((size_t)500, (size_t)71, (size_t)193, (size_t)347); nerrors += status < 0 ? 1 : 0; } /* end if */ /*--- END OF TESTS ---*/ - if(nerrors) { - HDprintf("***** %d HYPERSLAB TEST%s FAILED! *****\n", nerrors, 1 - == nerrors ? "" : "S"); - if(HDisatty(1)) + if (nerrors) { + HDprintf("***** %d HYPERSLAB TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); + if (HDisatty(1)) HDprintf("(Redirect output to a pager or a file to see debug output)\n"); HDexit(EXIT_FAILURE); } /* end if */ @@ -1432,8 +1391,7 @@ main(int argc, char *argv[]) #ifdef H5_HAVE_THREADSAFE H5close(); -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ HDexit(EXIT_SUCCESS); } - diff --git a/test/istore.c b/test/istore.c index be6949e..bbb584c 100644 --- a/test/istore.c +++ b/test/istore.c @@ -17,7 +17,7 @@ * Purpose: Tests various aspects of indexed raw data storage. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "h5test.h" @@ -29,26 +29,21 @@ #include "H5Oprivate.h" #include "H5VMprivate.h" -const char *FILENAME[] = { - "istore", - NULL -}; +const char *FILENAME[] = {"istore", NULL}; - -#define TEST_SMALL 0x0001 -#define TEST_MEDIUM 0x0002 -#define TEST_LARGE 0x0004 +#define TEST_SMALL 0x0001 +#define TEST_MEDIUM 0x0002 +#define TEST_LARGE 0x0004 /* The datatype of the dataset operated on by this test */ -#define TEST_DATATYPE H5T_NATIVE_UCHAR +#define TEST_DATATYPE H5T_NATIVE_UCHAR -#define TEST_CHUNK_SIZE 50 +#define TEST_CHUNK_SIZE 50 #define TEST_SPARSE_SIZE 1000000 hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; hsize_t zero[H5O_LAYOUT_NDIMS]; - /*------------------------------------------------------------------------- * Function: is_sparse * @@ -68,23 +63,28 @@ hsize_t zero[H5O_LAYOUT_NDIMS]; static int is_sparse(void) { - int fd; - h5_stat_t sb; - - if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; - if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0; - if (5!=HDwrite(fd, "hello", (size_t)5)) return 0; - if (HDclose(fd) < 0) return 0; - if (HDstat("x.h5", &sb) < 0) return 0; - if (HDremove("x.h5") < 0) return 0; + int fd; + h5_stat_t sb; + + if ((fd = HDopen("x.h5", O_RDWR | O_TRUNC | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) + return 0; + if (HDlseek(fd, (off_t)(1024 * 1024), SEEK_SET) != 1024 * 1024) + return 0; + if (5 != HDwrite(fd, "hello", (size_t)5)) + return 0; + if (HDclose(fd) < 0) + return 0; + if (HDstat("x.h5", &sb) < 0) + return 0; + if (HDremove("x.h5") < 0) + return 0; #ifdef H5_HAVE_STAT_ST_BLOCKS - return ((unsigned long)sb.st_blocks*512 < (unsigned long)sb.st_size); + return ((unsigned long)sb.st_blocks * 512 < (unsigned long)sb.st_size); #else return (0); #endif } - /*------------------------------------------------------------------------- * Function: print_array * @@ -102,29 +102,29 @@ is_sparse(void) static void print_array(uint8_t *array, size_t nx, size_t ny, size_t nz) { - size_t i, j, k; + size_t i, j, k; for (i = 0; i < nx; i++) { - if (nz > 1) { - HDfprintf(stderr,"i=%lu:\n", (unsigned long)i); - } else { - HDfprintf(stderr,"%03lu:", (unsigned long)i); - } + if (nz > 1) { + HDfprintf(stderr, "i=%lu:\n", (unsigned long)i); + } + else { + HDfprintf(stderr, "%03lu:", (unsigned long)i); + } - for (j = 0; j < ny; j++) { - if (nz > 1) - HDfprintf(stderr,"%03lu:", (unsigned long)j); - for (k = 0; k < nz; k++) { - HDfprintf(stderr," %3d", *array++); + for (j = 0; j < ny; j++) { + if (nz > 1) + HDfprintf(stderr, "%03lu:", (unsigned long)j); + for (k = 0; k < nz; k++) { + HDfprintf(stderr, " %3d", *array++); + } + if (nz > 1) + HDfprintf(stderr, "\n"); } - if (nz > 1) - HDfprintf(stderr,"\n"); - } - HDfprintf(stderr,"\n"); + HDfprintf(stderr, "\n"); } } - /*------------------------------------------------------------------------- * Function: new_object * @@ -150,29 +150,35 @@ print_array(uint8_t *array, size_t nx, size_t ny, size_t nz) static hid_t new_object(hid_t f, const char *name, int ndims, hsize_t dims[], hsize_t cdims[]) { - hid_t dataset; /* Dataset ID */ - hid_t space; /* Dataspace ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t dataset; /* Dataset ID */ + hid_t space; /* Dataspace ID */ + hid_t dcpl; /* Dataset creation property list ID */ /* Create the dataset creation property list */ - if ((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; /* Set the chunk dimensions */ - if(H5Pset_chunk(dcpl, ndims, cdims) < 0) TEST_ERROR; + if (H5Pset_chunk(dcpl, ndims, cdims) < 0) + TEST_ERROR; /* Create the dataspace */ - if((space = H5Screate_simple(ndims, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(ndims, dims, NULL)) < 0) + TEST_ERROR; /* Create the dataset */ - if((dataset = H5Dcreate2(f, name, TEST_DATATYPE, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dcreate2(f, name, TEST_DATATYPE, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Clean up */ /* Close property lists */ - if(H5Pclose(dcpl) < 0) TEST_ERROR; + if (H5Pclose(dcpl) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; return dataset; @@ -180,7 +186,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: test_create * @@ -201,11 +206,11 @@ error: static herr_t test_create(hid_t f, const char *prefix) { - hid_t dataset; /* Dataset ID */ - hsize_t dims[H5O_LAYOUT_NDIMS+1]; /* Dimensions of dataset */ - hsize_t my_chunk_dims[H5O_LAYOUT_NDIMS+1]; /* Dimensions of chunks */ - char name[256]; /* Dataset name */ - unsigned u; /* Local index variable */ + hid_t dataset; /* Dataset ID */ + hsize_t dims[H5O_LAYOUT_NDIMS + 1]; /* Dimensions of dataset */ + hsize_t my_chunk_dims[H5O_LAYOUT_NDIMS + 1]; /* Dimensions of chunks */ + char name[256]; /* Dataset name */ + unsigned u; /* Local index variable */ TESTING("istore create"); @@ -216,11 +221,11 @@ test_create(hid_t f, const char *prefix) /* Create chunked dataset of this dimensionality */ HDsnprintf(name, sizeof name, "%s_%02u", prefix, u); - if((dataset = new_object(f, name, (int)u, dims, my_chunk_dims)) < 0) + if ((dataset = new_object(f, name, (int)u, dims, my_chunk_dims)) < 0) return FAIL; /* Close dataset created */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) return FAIL; } @@ -228,7 +233,6 @@ test_create(hid_t f, const char *prefix) return SUCCEED; } - /*------------------------------------------------------------------------- * Function: test_extend * @@ -248,40 +252,40 @@ test_create(hid_t f, const char *prefix) *------------------------------------------------------------------------- */ static herr_t -test_extend(hid_t f, const char *prefix, - size_t nx, size_t ny, size_t nz) +test_extend(hid_t f, const char *prefix, size_t nx, size_t ny, size_t nz) { - hid_t dataset; /* Dataset ID */ - hid_t fspace; /* Dataset's file dataspace */ - hid_t mspace; /* Dataset's memory dataspace */ - size_t i, j, k, ctr; - int ndims; - uint8_t *buf = NULL, *check = NULL, *whole = NULL; - char dims[64], s[256], name[256]; - hsize_t offset[3]; - hsize_t max_corner[3]; - hsize_t size[3]; - hsize_t whole_size[3]; - hsize_t nelmts; + hid_t dataset; /* Dataset ID */ + hid_t fspace; /* Dataset's file dataspace */ + hid_t mspace; /* Dataset's memory dataspace */ + size_t i, j, k, ctr; + int ndims; + uint8_t *buf = NULL, *check = NULL, *whole = NULL; + char dims[64], s[256], name[256]; + hsize_t offset[3]; + hsize_t max_corner[3]; + hsize_t size[3]; + hsize_t whole_size[3]; + hsize_t nelmts; if (!nz) { - if (!ny) { - ndims = 1; - ny = nz = 1; - HDsprintf(dims, "%lu", (unsigned long) nx); - } else { - ndims = 2; - nz = 1; - HDsprintf(dims, "%lux%lu", (unsigned long) nx, (unsigned long) ny); + if (!ny) { + ndims = 1; + ny = nz = 1; + HDsprintf(dims, "%lu", (unsigned long)nx); + } + else { + ndims = 2; + nz = 1; + HDsprintf(dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny); + } } - } else { - ndims = 3; - HDsprintf(dims, "%lux%lux%lu", - (unsigned long) nx, (unsigned long) ny, (unsigned long) nz); + else { + ndims = 3; + HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); } TESTING("istore extend: %s", dims); - buf = (uint8_t *)HDmalloc(nx * ny * nz); + buf = (uint8_t *)HDmalloc(nx * ny * nz); check = (uint8_t *)HDmalloc(nx * ny * nz); whole = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz); @@ -294,35 +298,36 @@ test_extend(hid_t f, const char *prefix, /* Build the new empty object */ HDsprintf(name, "%s_%s", prefix, dims); - if ((dataset=new_object(f, name, ndims, whole_size, whole_size)) < 0) { - HDfprintf(stderr," Cannot create %u-d object `%s'\n", ndims, name); + if ((dataset = new_object(f, name, ndims, whole_size, whole_size)) < 0) { + HDfprintf(stderr, " Cannot create %u-d object `%s'\n", ndims, name); goto error; } /* Get dataset's dataspace */ - if((fspace=H5Dget_space(dataset)) < 0) TEST_ERROR; - - for (ctr = 0; - H5VM_vector_lt_u((unsigned)ndims, max_corner, whole_size); - ctr++) { - - /* Size and location */ - if (0 == ctr) { - offset[0] = offset[1] = offset[2] = 0; - size[0] = size[1] = size[2] = 1; - nelmts = 1; - } else { - for (i=0, nelmts=1; i<(size_t)ndims; i++) { - if (ctr % (size_t)ndims == i) { - offset[i] = max_corner[i]; - size[i] = MIN(1, whole_size[i] - offset[i]); - } else { - offset[i] = 0; - size[i] = max_corner[i]; + if ((fspace = H5Dget_space(dataset)) < 0) + TEST_ERROR; + + for (ctr = 0; H5VM_vector_lt_u((unsigned)ndims, max_corner, whole_size); ctr++) { + + /* Size and location */ + if (0 == ctr) { + offset[0] = offset[1] = offset[2] = 0; + size[0] = size[1] = size[2] = 1; + nelmts = 1; } - nelmts *= size[i]; + else { + for (i = 0, nelmts = 1; i < (size_t)ndims; i++) { + if (ctr % (size_t)ndims == i) { + offset[i] = max_corner[i]; + size[i] = MIN(1, whole_size[i] - offset[i]); + } + else { + offset[i] = 0; + size[i] = max_corner[i]; + } + nelmts *= size[i]; + } } - } #if 0 if (0 == ctr) @@ -343,89 +348,92 @@ test_extend(hid_t f, const char *prefix, HDfprintf(stderr,"\n"); #endif - /* Fill the source array */ - if (0 == nelmts) continue; - HDmemset(buf, (signed)(128+ctr), (size_t)nelmts); + /* Fill the source array */ + if (0 == nelmts) + continue; + HDmemset(buf, (signed)(128 + ctr), (size_t)nelmts); /* Create dataspace for selection in memory */ - if((mspace=H5Screate_simple(1,&nelmts,NULL)) < 0) TEST_ERROR; + if ((mspace = H5Screate_simple(1, &nelmts, NULL)) < 0) + TEST_ERROR; /* Select region in file dataspace */ - if(H5Sselect_hyperslab(fspace,H5S_SELECT_SET,offset,NULL,size,NULL) < 0) TEST_ERROR; + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, offset, NULL, size, NULL) < 0) + TEST_ERROR; - /* Write to disk */ - if (H5Dwrite(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, buf) < 0) { - H5_FAILED(); - HDfprintf(stderr," Write failed: ctr=%lu\n", (unsigned long)ctr); - goto error; - } + /* Write to disk */ + if (H5Dwrite(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); + HDfprintf(stderr, " Write failed: ctr=%lu\n", (unsigned long)ctr); + goto error; + } - /* Read from disk */ - HDmemset(check, 0xff, (size_t)nelmts); - if (H5Dread(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, check) < 0) { - H5_FAILED(); - HDfprintf(stderr," Read failed: ctr=%lu\n", (unsigned long)ctr); - goto error; - } - if (HDmemcmp(buf, check, (size_t)nelmts)) { - H5_FAILED(); - HDfprintf(stderr," Read check failed: ctr=%lu\n", (unsigned long)ctr); - HDfprintf(stderr," Wrote:\n"); - print_array(buf, (size_t)size[0], (size_t)size[1], - (size_t)size[2]); - HDfprintf(stderr," Read:\n"); - print_array(check, (size_t)size[0], (size_t)size[1], - (size_t)size[2]); - goto error; - } + /* Read from disk */ + HDmemset(check, 0xff, (size_t)nelmts); + if (H5Dread(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, check) < 0) { + H5_FAILED(); + HDfprintf(stderr, " Read failed: ctr=%lu\n", (unsigned long)ctr); + goto error; + } + if (HDmemcmp(buf, check, (size_t)nelmts)) { + H5_FAILED(); + HDfprintf(stderr, " Read check failed: ctr=%lu\n", (unsigned long)ctr); + HDfprintf(stderr, " Wrote:\n"); + print_array(buf, (size_t)size[0], (size_t)size[1], (size_t)size[2]); + HDfprintf(stderr, " Read:\n"); + print_array(check, (size_t)size[0], (size_t)size[1], (size_t)size[2]); + goto error; + } /* Close memory dataspace */ - if(H5Sclose(mspace) < 0) TEST_ERROR; + if (H5Sclose(mspace) < 0) + TEST_ERROR; - /* Write to `whole' buffer for later checking */ - H5VM_hyper_copy((unsigned)ndims, size, - whole_size, offset, whole, /*dst*/ - size, H5VM_ZERO, buf); /*src*/ + /* Write to `whole' buffer for later checking */ + H5VM_hyper_copy((unsigned)ndims, size, whole_size, offset, whole, /*dst*/ + size, H5VM_ZERO, buf); /*src*/ - /* Update max corner */ - for (i=0; i<(size_t)ndims; i++) - max_corner[i] = MAX(max_corner[i], offset[i]+size[i]); + /* Update max corner */ + for (i = 0; i < (size_t)ndims; i++) + max_corner[i] = MAX(max_corner[i], offset[i] + size[i]); } /* Now read the entire array back out and check it */ HDmemset(buf, 0xff, nx * ny * nz); if (H5Dread(dataset, TEST_DATATYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) { - H5_FAILED(); - HDfprintf(stderr," Read failed for whole array.\n"); - goto error; + H5_FAILED(); + HDfprintf(stderr, " Read failed for whole array.\n"); + goto error; } - for (i=0; i 1) { - HDfprintf(stderr,", j=%lu", (unsigned long)j); - } - if (ndims > 2) { - HDfprintf(stderr,", k=%lu", (unsigned long)k); + for (i = 0; i < nx; i++) { + for (j = 0; j < ny; j++) { + for (k = 0; k < nz; k++) { + if (whole[i * ny * nz + j * nz + k] != buf[i * ny * nz + j * nz + k]) { + H5_FAILED(); + HDfprintf(stderr, " Check failed at i=%lu", (unsigned long)i); + if (ndims > 1) { + HDfprintf(stderr, ", j=%lu", (unsigned long)j); + } + if (ndims > 2) { + HDfprintf(stderr, ", k=%lu", (unsigned long)k); + } + HDfprintf(stderr, "\n Check array is:\n"); + print_array(whole, nx, ny, nz); + HDfprintf(stderr, " Value read is:\n"); + print_array(buf, nx, ny, nz); + goto error; + } } - HDfprintf(stderr,"\n Check array is:\n"); - print_array(whole, nx, ny, nz); - HDfprintf(stderr," Value read is:\n"); - print_array(buf, nx, ny, nz); - goto error; } - } - } } /* Close dataset's dataspace */ - if(H5Sclose(fspace) < 0) TEST_ERROR; + if (H5Sclose(fspace) < 0) + TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Free memory used */ HDfree(buf); @@ -442,7 +450,6 @@ error: return FAIL; } - /*------------------------------------------------------------------------- * Function: test_sparse * @@ -461,39 +468,39 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_sparse(hid_t f, const char *prefix, size_t nblocks, - size_t nx, size_t ny, size_t nz, int skip_test) +test_sparse(hid_t f, const char *prefix, size_t nblocks, size_t nx, size_t ny, size_t nz, int skip_test) { - hid_t dataset; /* Dataset ID */ - hid_t fspace; /* Dataset's file dataspace */ - hid_t mspace; /* Dataset's memory dataspace */ - int ndims; - hsize_t ctr; - char dims[64], s[256], name[256]; - hsize_t offset[3]; - hsize_t size[3], total = 0; - uint8_t *buf = NULL; - hsize_t whole_size[3]; /* Size of dataset's dataspace */ - size_t u; /* Local index variable */ + hid_t dataset; /* Dataset ID */ + hid_t fspace; /* Dataset's file dataspace */ + hid_t mspace; /* Dataset's memory dataspace */ + int ndims; + hsize_t ctr; + char dims[64], s[256], name[256]; + hsize_t offset[3]; + hsize_t size[3], total = 0; + uint8_t *buf = NULL; + hsize_t whole_size[3]; /* Size of dataset's dataspace */ + size_t u; /* Local index variable */ if (!nz) { - if (!ny) { - ndims = 1; - ny = nz = 1; - HDsprintf(dims, "%lu", (unsigned long) nx); - } else { - ndims = 2; - nz = 1; - HDsprintf(dims, "%lux%lu", (unsigned long) nx, (unsigned long) ny); + if (!ny) { + ndims = 1; + ny = nz = 1; + HDsprintf(dims, "%lu", (unsigned long)nx); + } + else { + ndims = 2; + nz = 1; + HDsprintf(dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny); + } } - } else { - ndims = 3; - HDsprintf(dims, "%lux%lux%lu", - (unsigned long) nx, (unsigned long) ny, (unsigned long) nz); + else { + ndims = 3; + HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); } TESTING("istore sparse: %s", dims); - if(skip_test){ + if (skip_test) { SKIPPED() return SUCCEED; } @@ -501,8 +508,8 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks, HDmemset(buf, 128, nx * ny * nz); /* Set dimensions of dataset */ - for (u=0; u<(size_t)ndims; u++) - whole_size[u]=TEST_SPARSE_SIZE; + for (u = 0; u < (size_t)ndims; u++) + whole_size[u] = TEST_SPARSE_SIZE; /* Set dimensions of selection */ size[0] = nx; @@ -511,58 +518,64 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks, /* Build the new empty object */ HDsprintf(name, "%s_%s", prefix, dims); - if ((dataset=new_object(f, name, ndims, whole_size, chunk_dims)) < 0) { + if ((dataset = new_object(f, name, ndims, whole_size, chunk_dims)) < 0) { HDprintf(" Cannot create %u-d object `%s'\n", ndims, name); goto error; } /* Get dataset's dataspace */ - if((fspace=H5Dget_space(dataset)) < 0) TEST_ERROR; + if ((fspace = H5Dget_space(dataset)) < 0) + TEST_ERROR; /* Create dataspace for memory buffer */ - if((mspace=H5Screate_simple(ndims,size,NULL)) < 0) TEST_ERROR; + if ((mspace = H5Screate_simple(ndims, size, NULL)) < 0) + TEST_ERROR; - for (ctr=0; ctr 1) - HDprintf(",%lu", (unsigned long) (offset[1])); - if (ndims > 2) - HDprintf(",%lu", (unsigned long) (offset[2])); - HDprintf("), size=(%lu", (unsigned long) (size[0])); - if (ndims > 1) - HDprintf(",%lu", (unsigned long) (size[1])); - if (ndims > 2) - HDprintf(",%lu", (unsigned long) (size[2])); - HDprintf(")\n"); - goto error; - } - total += nx * ny * nz; + /* write to disk */ + if (H5Dwrite(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); + HDprintf(" Write failed: ctr=%lu\n", (unsigned long)ctr); + HDprintf(" offset=(%lu", (unsigned long)(offset[0])); + if (ndims > 1) + HDprintf(",%lu", (unsigned long)(offset[1])); + if (ndims > 2) + HDprintf(",%lu", (unsigned long)(offset[2])); + HDprintf("), size=(%lu", (unsigned long)(size[0])); + if (ndims > 1) + HDprintf(",%lu", (unsigned long)(size[1])); + if (ndims > 2) + HDprintf(",%lu", (unsigned long)(size[2])); + HDprintf(")\n"); + goto error; + } + total += nx * ny * nz; #if 0 HDfprintf(stderr,"ctr: ctr=%Zu, total=%Zu\n", ctr, total); #endif - /* We don't test reading yet.... */ + /* We don't test reading yet.... */ } /* Close memory dataspace */ - if(H5Sclose(mspace) < 0) TEST_ERROR; + if (H5Sclose(mspace) < 0) + TEST_ERROR; /* Close dataset's dataspace */ - if(H5Sclose(fspace) < 0) TEST_ERROR; + if (H5Sclose(fspace) < 0) + TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; HDfree(buf); PASSED(); @@ -573,7 +586,6 @@ error: return FAIL; } - /*------------------------------------------------------------------------- * Function: main * @@ -589,28 +601,32 @@ error: int main(int argc, char *argv[]) { - hid_t fapl=-1, file=-1, fcpl=-1; - herr_t status; - int nerrors = 0; - unsigned size_of_test; - unsigned u; /* Local index variable */ - char filename[1024]; - int skip_test = 0; - int has_sparse_support = 0; + hid_t fapl = -1, file = -1, fcpl = -1; + herr_t status; + int nerrors = 0; + unsigned size_of_test; + unsigned u; /* Local index variable */ + char filename[1024]; + int skip_test = 0; + int has_sparse_support = 0; /* Parse arguments or assume these tests (`small', `medium' ) */ if (1 == argc) { size_of_test = TEST_SMALL | TEST_MEDIUM | TEST_LARGE; - } else { - int i; + } + else { + int i; for (i = 1, size_of_test = 0; i < argc; i++) { if (!strcmp(argv[i], "small")) { size_of_test |= TEST_SMALL; - } else if (!strcmp(argv[i], "medium")) { + } + else if (!strcmp(argv[i], "medium")) { size_of_test |= TEST_MEDIUM; - } else if (!strcmp(argv[i], "large")) { + } + else if (!strcmp(argv[i], "large")) { size_of_test |= TEST_LARGE; - } else { + } + else { HDprintf("unrecognized argument: %s\n", argv[i]); } } @@ -643,19 +659,19 @@ main(int argc, char *argv[]) /* Create the test file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { HDprintf("Cannot create file %s; test aborted\n", filename); HDexit(EXIT_FAILURE); } /* Initialize chunk dimensions */ - for(u = 0; u < H5O_LAYOUT_NDIMS; u++) + for (u = 0; u < H5O_LAYOUT_NDIMS; u++) chunk_dims[u] = TEST_CHUNK_SIZE; /* - * Creation test: Creates empty objects with various raw data sizes - * and alignments. - */ + * Creation test: Creates empty objects with various raw data sizes + * and alignments. + */ status = test_create(file, "create"); nerrors += status < 0 ? 1 : 0; @@ -698,7 +714,7 @@ main(int argc, char *argv[]) * e.g.: Windows NTFS filesystems */ status = test_sparse(file, "sparse", (size_t)800, (size_t)50, (size_t)50, (size_t)50, skip_test); - if(skip_test) + if (skip_test) HDprintf(" The current VFD does not support sparse files on this platform.\n"); nerrors += status < 0 ? 1 : 0; } @@ -711,8 +727,7 @@ main(int argc, char *argv[]) nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); if (nerrors) { - HDprintf("***** %d I-STORE TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d I-STORE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } @@ -722,4 +737,3 @@ main(int argc, char *argv[]) HDexit(EXIT_SUCCESS); } - diff --git a/test/lheap.c b/test/lheap.c index 5f60dca..0bcc8ea 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -20,20 +20,16 @@ #include "h5test.h" #include "H5srcdir.h" #include "H5ACprivate.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5HLprivate.h" #include "H5Iprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ -const char *FILENAME[] = { - "lheap", - NULL -}; +const char *FILENAME[] = {"lheap", NULL}; #define TESTFILE "tsizeslheap.h5" -#define NOBJS 40 - +#define NOBJS 40 /*------------------------------------------------------------------------- * Function: main @@ -52,24 +48,25 @@ const char *FILENAME[] = { int main(void) { - hid_t fapl = H5P_DEFAULT; /* file access properties */ - hid_t file = -1; /* hdf5 file */ - H5F_t *f = NULL; /* hdf5 file pointer */ - char filename[1024]; /* file name */ - haddr_t heap_addr; /* local heap address */ - H5HL_t *heap = NULL; /* local heap */ - size_t obj[NOBJS]; /* offsets within the heap */ - int i, j; /* miscellaneous counters */ - char buf[1024]; /* the value to store */ - const char *s; /* value to read */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t fapl = H5P_DEFAULT; /* file access properties */ + hid_t file = -1; /* hdf5 file */ + H5F_t * f = NULL; /* hdf5 file pointer */ + char filename[1024]; /* file name */ + haddr_t heap_addr; /* local heap address */ + H5HL_t * heap = NULL; /* local heap */ + size_t obj[NOBJS]; /* offsets within the heap */ + int i, j; /* miscellaneous counters */ + char buf[1024]; /* the value to store */ + const char *s; /* value to read */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Reset library */ h5_reset(); fapl = h5_fileaccess(); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* @@ -77,42 +74,42 @@ main(void) */ TESTING("local heap write"); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if(FAIL == (file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))) + if (FAIL == (file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))) goto error; - if(NULL == (f = (H5F_t *)H5VL_object(file))) { + if (NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } - if(FAIL == H5AC_ignore_tags(f)) { + if (FAIL == H5AC_ignore_tags(f)) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } - if(FAIL == H5HL_create(f, (size_t)0, &heap_addr/*out*/)) { + if (FAIL == H5HL_create(f, (size_t)0, &heap_addr /*out*/)) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } - if(NULL == (heap = H5HL_protect(f, heap_addr, H5AC__NO_FLAGS_SET))) { + if (NULL == (heap = H5HL_protect(f, heap_addr, H5AC__NO_FLAGS_SET))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } - for(i = 0; i < NOBJS; i++) { + for (i = 0; i < NOBJS; i++) { HDsprintf(buf, "%03d-", i); - for(j = 4; j < i; j++) + for (j = 4; j < i; j++) buf[j] = (char)('0' + j % 10); - if(j > 4) + if (j > 4) buf[j] = '\0'; - if(UFAIL == (obj[i] = H5HL_insert(f, heap, strlen(buf) + 1, buf))) { + if (UFAIL == (obj[i] = H5HL_insert(f, heap, strlen(buf) + 1, buf))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; } } - if(FAIL == H5HL_unprotect(heap)) { + if (FAIL == H5HL_unprotect(heap)) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -127,9 +124,9 @@ main(void) TESTING("local heap read"); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if(FAIL == (file = H5Fopen(filename, H5F_ACC_RDONLY, fapl))) + if (FAIL == (file = H5Fopen(filename, H5F_ACC_RDONLY, fapl))) goto error; - if(NULL == (f = (H5F_t *)H5VL_object(file))) { + if (NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -139,14 +136,14 @@ main(void) H5Eprint2(H5E_DEFAULT, stdout); goto error; } - for(i = 0; i < NOBJS; i++) { + for (i = 0; i < NOBJS; i++) { HDsprintf(buf, "%03d-", i); - for(j = 4; j < i; j++) + for (j = 4; j < i; j++) buf[j] = (char)('0' + j % 10); - if(j > 4) + if (j > 4) buf[j] = '\0'; - if(NULL == (heap = H5HL_protect(f, heap_addr, H5AC__READ_ONLY_FLAG))) { + if (NULL == (heap = H5HL_protect(f, heap_addr, H5AC__READ_ONLY_FLAG))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -166,7 +163,7 @@ main(void) goto error; } - if(FAIL == H5HL_unprotect(heap)) { + if (FAIL == H5HL_unprotect(heap)) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -181,30 +178,31 @@ main(void) TESTING("opening pre-created file with non-default sizes"); { const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */ - hid_t dset = -1; - file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - if(file >= 0){ - if((dset = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0) + hid_t dset = -1; + file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + if (file >= 0) { + if ((dset = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR } else { H5_FAILED(); - HDprintf("***cannot open the pre-created non-default sizes test file (%s)\n", - testfile); + HDprintf("***cannot open the pre-created non-default sizes test file (%s)\n", testfile); goto error; } /* end else */ } PASSED(); /* Verify symbol table messages are cached */ - if(h5_verify_cached_stabs(FILENAME, fapl) < 0) TEST_ERROR + if (h5_verify_cached_stabs(FILENAME, fapl) < 0) + TEST_ERROR /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; HDputs("All local heap tests passed."); @@ -212,14 +210,16 @@ main(void) return EXIT_SUCCESS; - error: +error: HDputs("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); return EXIT_FAILURE; } - diff --git a/test/links.c b/test/links.c index cd9f05c..903e95a 100644 --- a/test/links.c +++ b/test/links.c @@ -19,14 +19,14 @@ * This file needs to access private information from the H5FD package. * This file also needs to access the file driver testing code. */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING /* * This file needs to access private information from the H5G package. * This file also needs to access the group testing code. */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ #define H5G_TESTING #include "h5test.h" @@ -38,104 +38,104 @@ #include "H5VLnative_private.h" /* Native VOL connector */ /* File for external link test. Created with gen_udlinks.c */ -#define LINKED_FILE "be_extlink2.h5" +#define LINKED_FILE "be_extlink2.h5" -#define TMPDIR "tmp_links/" -#define TMPDIR2 "tmp2_links/" +#define TMPDIR "tmp_links/" +#define TMPDIR2 "tmp2_links/" /* Symlinks for external link symlink test */ -#define SYMLINK1 TMPDIR "sym1.h5" -#define SYMLINK2 TMPDIR2 "sym2.h5" - -const char *FILENAME[] = { - "links0", - "links1", - "links2", - "links3", - "links4a", /* 4 */ - "links4b", /* 5 */ - "links4c", /* 6 */ - "links4d", /* 7 */ - "links5", /* 8 */ - "links6", /* 9 */ - "links7", /* 10 */ - "links8", /* 11 */ - "extlinks0", /* 12: main files */ - TMPDIR "extlinks0", /* 13: */ - "extlinks1", /* 14: target files */ - TMPDIR "extlinks1", /* 15: */ - "extlinks2", /* 16: */ - TMPDIR "extlinks2", /* 17: */ - "extlinks3", /* 18: */ - TMPDIR "extlinks3", /* 19: */ - "extlinks4", /* 20: */ - TMPDIR "extlinks4", /* 21: */ - "extlinks5", /* 22: */ - TMPDIR "extlinks6", /* 23: */ - "extlinks7", /* 24: */ - TMPDIR "extlinks7", /* 25: */ - TMPDIR "extlinks8", /* 26: */ - "extlinks9", /* 27: */ - TMPDIR "extlinks9", /* 28: */ - "extlinks10", /* 29: */ /* TESTS for windows */ - TMPDIR "extlinks10", /* 30: */ - TMPDIR "extlinks11", /* 31: */ - TMPDIR "extlinks12", /* 32: */ - "extlinks13", /* 33: */ - TMPDIR "extlinks13", /* 34: */ - TMPDIR "extlinks14", /* 35: */ - TMPDIR "extlinks15", /* 36: */ - "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ - "extlinks16B", /* 38: */ - "extlinks17", /* 39: */ - "extlinks18A", /* 40: */ - "extlinks18B", /* 41: */ - "extlinks19A", /* 42: */ - "extlinks19B", /* 43: */ - "extlinks20", /* 44: */ - "extlinks21A", /* 45: Files for symlink() tests*/ - TMPDIR2 "extlinks21B", /* 46: */ - TMPDIR2 "extlinks21C", /* 47: */ - "extlinks21C", /* 48: (same as #47, only without the TMPDIR2 prefix) */ - TMPDIR "extlinks21D", /* 49: */ - TMPDIR "extlinks21E", /* 50: */ - "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */ - NULL -}; - -#define FAMILY_SIZE 1024 -#define CORE_INCREMENT 1024 -#define NUM40 40 +#define SYMLINK1 TMPDIR "sym1.h5" +#define SYMLINK2 TMPDIR2 "sym2.h5" + +const char *FILENAME[] = {"links0", + "links1", + "links2", + "links3", + "links4a", /* 4 */ + "links4b", /* 5 */ + "links4c", /* 6 */ + "links4d", /* 7 */ + "links5", /* 8 */ + "links6", /* 9 */ + "links7", /* 10 */ + "links8", /* 11 */ + "extlinks0", /* 12: main files */ + TMPDIR "extlinks0", /* 13: */ + "extlinks1", /* 14: target files */ + TMPDIR "extlinks1", /* 15: */ + "extlinks2", /* 16: */ + TMPDIR "extlinks2", /* 17: */ + "extlinks3", /* 18: */ + TMPDIR "extlinks3", /* 19: */ + "extlinks4", /* 20: */ + TMPDIR "extlinks4", /* 21: */ + "extlinks5", /* 22: */ + TMPDIR "extlinks6", /* 23: */ + "extlinks7", /* 24: */ + TMPDIR "extlinks7", /* 25: */ + TMPDIR "extlinks8", /* 26: */ + "extlinks9", /* 27: */ + TMPDIR "extlinks9", /* 28: */ + "extlinks10", + /* 29: */ /* TESTS for windows */ + TMPDIR "extlinks10", /* 30: */ + TMPDIR "extlinks11", /* 31: */ + TMPDIR "extlinks12", /* 32: */ + "extlinks13", /* 33: */ + TMPDIR "extlinks13", /* 34: */ + TMPDIR "extlinks14", /* 35: */ + TMPDIR "extlinks15", /* 36: */ + "extlinks16A", + /* 37: */ /* TESTS for H5P_set_elink_fapl */ + "extlinks16B", /* 38: */ + "extlinks17", /* 39: */ + "extlinks18A", /* 40: */ + "extlinks18B", /* 41: */ + "extlinks19A", /* 42: */ + "extlinks19B", /* 43: */ + "extlinks20", /* 44: */ + "extlinks21A", /* 45: Files for symlink() tests*/ + TMPDIR2 "extlinks21B", /* 46: */ + TMPDIR2 "extlinks21C", /* 47: */ + "extlinks21C", /* 48: (same as #47, only without the TMPDIR2 prefix) */ + TMPDIR "extlinks21D", /* 49: */ + TMPDIR "extlinks21E", /* 50: */ + "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */ + NULL}; + +#define FAMILY_SIZE 1024 +#define CORE_INCREMENT 1024 +#define NUM40 40 /* do not do check_all_closed() for "ext*" files and "tmp_links/ext*" */ -#define EXTSTOP 12 +#define EXTSTOP 12 -#define LINK_BUF_SIZE 1024 -#define NAME_BUF_SIZE 1024 -#define MAX_NAME_LEN ((64*1024)+1024) +#define LINK_BUF_SIZE 1024 +#define NAME_BUF_SIZE 1024 +#define MAX_NAME_LEN ((64 * 1024) + 1024) /* Link type IDs */ -#define UD_HARD_TYPE 201 -#define UD_CB_TYPE H5L_TYPE_MAX -#define UD_PLIST_TYPE 128 +#define UD_HARD_TYPE 201 +#define UD_CB_TYPE H5L_TYPE_MAX +#define UD_PLIST_TYPE 128 #define UD_CBFAIL_TYPE UD_PLIST_TYPE -#define UD_ERROR_TYPE 189 -#define UD_BAD_TYPE1 H5L_TYPE_HARD -#define UD_BAD_TYPE2 (H5L_TYPE_UD_MIN - 5) -#define UD_BAD_VERS (H5L_LINK_CLASS_T_VERS + 1) +#define UD_ERROR_TYPE 189 +#define UD_BAD_TYPE1 H5L_TYPE_HARD +#define UD_BAD_TYPE2 (H5L_TYPE_UD_MIN - 5) +#define UD_BAD_VERS (H5L_LINK_CLASS_T_VERS + 1) -#define DEST_PROP_NAME "destination_group" +#define DEST_PROP_NAME "destination_group" #define REREG_TARGET_NAME "rereg_target" -#define UD_CB_LINK_NAME "ud_callback_link" +#define UD_CB_LINK_NAME "ud_callback_link" #define NEW_UD_CB_LINK_NAME "ud_callback_link2" -#define UD_CB_TARGET "ud_target" -#define UD_CB_TARGET_LEN 10 +#define UD_CB_TARGET "ud_target" +#define UD_CB_TARGET_LEN 10 #define LE_FILENAME "le_extlink1.h5" #define BE_FILENAME "be_extlink1.h5" -#define ELINK_CB_FAM_SIZE (hsize_t) 100 +#define ELINK_CB_FAM_SIZE (hsize_t)100 #define H5L_DIM1 100 #define H5L_DIM2 100 @@ -143,290 +143,250 @@ const char *FILENAME[] = { #define FILTER_FILESIZE_MAX_FRACTION (double)0.9F /* Creation order macros */ -#define CORDER_GROUP_NAME "corder_group" -#define CORDER_SOFT_GROUP_NAME "corder_soft_group" -#define CORDER_NLINKS 18 -#define CORDER_ITER_STOP 3 -#define CORDER_EST_ENTRY_LEN 9 +#define CORDER_GROUP_NAME "corder_group" +#define CORDER_SOFT_GROUP_NAME "corder_soft_group" +#define CORDER_NLINKS 18 +#define CORDER_ITER_STOP 3 +#define CORDER_EST_ENTRY_LEN 9 /* Timestamp macros */ -#define TIMESTAMP_GROUP_1 "timestamp1" -#define TIMESTAMP_GROUP_2 "timestamp2" +#define TIMESTAMP_GROUP_1 "timestamp1" +#define TIMESTAMP_GROUP_2 "timestamp2" /* Link iteration struct */ typedef struct { - H5_iter_order_t order; /* Direction of iteration */ - unsigned ncalled; /* # of times callback is entered */ - unsigned nskipped; /* # of links skipped */ - int stop; /* # of iterations to stop after */ - int64_t curr; /* Current creation order value */ - size_t max_visit; /* Size of "visited link" flag array */ - hbool_t *visited; /* Pointer to array of "visited link" flags */ + H5_iter_order_t order; /* Direction of iteration */ + unsigned ncalled; /* # of times callback is entered */ + unsigned nskipped; /* # of links skipped */ + int stop; /* # of iterations to stop after */ + int64_t curr; /* Current creation order value */ + size_t max_visit; /* Size of "visited link" flag array */ + hbool_t * visited; /* Pointer to array of "visited link" flags */ } link_iter_info_t; /* Link visit structs */ typedef struct { - const char *path; /* Path to link */ - H5L_type_t type; /* Type of link */ + const char *path; /* Path to link */ + H5L_type_t type; /* Type of link */ } link_visit_t; -static const link_visit_t lvisit0[] = { - {"Dataset_zero", H5L_TYPE_HARD}, - {"Group1", H5L_TYPE_HARD}, - {"Group1/Dataset_one", H5L_TYPE_HARD}, - {"Group1/Group2", H5L_TYPE_HARD}, - {"Group1/Group2/Dataset_two", H5L_TYPE_HARD}, - {"Group1/Group2/Type_two", H5L_TYPE_HARD}, - {"Group1/Group2/hard_zero", H5L_TYPE_HARD}, - {"Group1/Type_one", H5L_TYPE_HARD}, - {"Group1/hard_one", H5L_TYPE_HARD}, - {"Type_zero", H5L_TYPE_HARD}, - {"ext_dangle", H5L_TYPE_EXTERNAL}, - {"ext_one", H5L_TYPE_EXTERNAL}, - {"hard_one", H5L_TYPE_HARD}, - {"hard_two", H5L_TYPE_HARD}, - {"hard_zero", H5L_TYPE_HARD}, - {"soft_dangle", H5L_TYPE_SOFT}, - {"soft_one", H5L_TYPE_SOFT}, - {"soft_two", H5L_TYPE_SOFT} -}; -static const link_visit_t lvisit1[] = { - {"Dataset_one", H5L_TYPE_HARD}, - {"Group2", H5L_TYPE_HARD}, - {"Group2/Dataset_two", H5L_TYPE_HARD}, - {"Group2/Type_two", H5L_TYPE_HARD}, - {"Group2/hard_zero", H5L_TYPE_HARD}, - {"Group2/hard_zero/Dataset_zero", H5L_TYPE_HARD}, - {"Group2/hard_zero/Group1", H5L_TYPE_HARD}, - {"Group2/hard_zero/Type_zero", H5L_TYPE_HARD}, - {"Group2/hard_zero/ext_dangle", H5L_TYPE_EXTERNAL}, - {"Group2/hard_zero/ext_one", H5L_TYPE_EXTERNAL}, - {"Group2/hard_zero/hard_one", H5L_TYPE_HARD}, - {"Group2/hard_zero/hard_two", H5L_TYPE_HARD}, - {"Group2/hard_zero/hard_zero", H5L_TYPE_HARD}, - {"Group2/hard_zero/soft_dangle", H5L_TYPE_SOFT}, - {"Group2/hard_zero/soft_one", H5L_TYPE_SOFT}, - {"Group2/hard_zero/soft_two", H5L_TYPE_SOFT}, - {"Type_one", H5L_TYPE_HARD}, - {"hard_one", H5L_TYPE_HARD} -}; -static const link_visit_t lvisit2[] = { - {"Dataset_two", H5L_TYPE_HARD}, - {"Type_two", H5L_TYPE_HARD}, - {"hard_zero", H5L_TYPE_HARD}, - {"hard_zero/Dataset_zero", H5L_TYPE_HARD}, - {"hard_zero/Group1", H5L_TYPE_HARD}, - {"hard_zero/Group1/Dataset_one", H5L_TYPE_HARD}, - {"hard_zero/Group1/Group2", H5L_TYPE_HARD}, - {"hard_zero/Group1/Type_one", H5L_TYPE_HARD}, - {"hard_zero/Group1/hard_one", H5L_TYPE_HARD}, - {"hard_zero/Type_zero", H5L_TYPE_HARD}, - {"hard_zero/ext_dangle", H5L_TYPE_EXTERNAL}, - {"hard_zero/ext_one", H5L_TYPE_EXTERNAL}, - {"hard_zero/hard_one", H5L_TYPE_HARD}, - {"hard_zero/hard_two", H5L_TYPE_HARD}, - {"hard_zero/hard_zero", H5L_TYPE_HARD}, - {"hard_zero/soft_dangle", H5L_TYPE_SOFT}, - {"hard_zero/soft_one", H5L_TYPE_SOFT}, - {"hard_zero/soft_two", H5L_TYPE_SOFT} -}; +static const link_visit_t lvisit0[] = {{"Dataset_zero", H5L_TYPE_HARD}, + {"Group1", H5L_TYPE_HARD}, + {"Group1/Dataset_one", H5L_TYPE_HARD}, + {"Group1/Group2", H5L_TYPE_HARD}, + {"Group1/Group2/Dataset_two", H5L_TYPE_HARD}, + {"Group1/Group2/Type_two", H5L_TYPE_HARD}, + {"Group1/Group2/hard_zero", H5L_TYPE_HARD}, + {"Group1/Type_one", H5L_TYPE_HARD}, + {"Group1/hard_one", H5L_TYPE_HARD}, + {"Type_zero", H5L_TYPE_HARD}, + {"ext_dangle", H5L_TYPE_EXTERNAL}, + {"ext_one", H5L_TYPE_EXTERNAL}, + {"hard_one", H5L_TYPE_HARD}, + {"hard_two", H5L_TYPE_HARD}, + {"hard_zero", H5L_TYPE_HARD}, + {"soft_dangle", H5L_TYPE_SOFT}, + {"soft_one", H5L_TYPE_SOFT}, + {"soft_two", H5L_TYPE_SOFT}}; +static const link_visit_t lvisit1[] = {{"Dataset_one", H5L_TYPE_HARD}, + {"Group2", H5L_TYPE_HARD}, + {"Group2/Dataset_two", H5L_TYPE_HARD}, + {"Group2/Type_two", H5L_TYPE_HARD}, + {"Group2/hard_zero", H5L_TYPE_HARD}, + {"Group2/hard_zero/Dataset_zero", H5L_TYPE_HARD}, + {"Group2/hard_zero/Group1", H5L_TYPE_HARD}, + {"Group2/hard_zero/Type_zero", H5L_TYPE_HARD}, + {"Group2/hard_zero/ext_dangle", H5L_TYPE_EXTERNAL}, + {"Group2/hard_zero/ext_one", H5L_TYPE_EXTERNAL}, + {"Group2/hard_zero/hard_one", H5L_TYPE_HARD}, + {"Group2/hard_zero/hard_two", H5L_TYPE_HARD}, + {"Group2/hard_zero/hard_zero", H5L_TYPE_HARD}, + {"Group2/hard_zero/soft_dangle", H5L_TYPE_SOFT}, + {"Group2/hard_zero/soft_one", H5L_TYPE_SOFT}, + {"Group2/hard_zero/soft_two", H5L_TYPE_SOFT}, + {"Type_one", H5L_TYPE_HARD}, + {"hard_one", H5L_TYPE_HARD}}; +static const link_visit_t lvisit2[] = {{"Dataset_two", H5L_TYPE_HARD}, + {"Type_two", H5L_TYPE_HARD}, + {"hard_zero", H5L_TYPE_HARD}, + {"hard_zero/Dataset_zero", H5L_TYPE_HARD}, + {"hard_zero/Group1", H5L_TYPE_HARD}, + {"hard_zero/Group1/Dataset_one", H5L_TYPE_HARD}, + {"hard_zero/Group1/Group2", H5L_TYPE_HARD}, + {"hard_zero/Group1/Type_one", H5L_TYPE_HARD}, + {"hard_zero/Group1/hard_one", H5L_TYPE_HARD}, + {"hard_zero/Type_zero", H5L_TYPE_HARD}, + {"hard_zero/ext_dangle", H5L_TYPE_EXTERNAL}, + {"hard_zero/ext_one", H5L_TYPE_EXTERNAL}, + {"hard_zero/hard_one", H5L_TYPE_HARD}, + {"hard_zero/hard_two", H5L_TYPE_HARD}, + {"hard_zero/hard_zero", H5L_TYPE_HARD}, + {"hard_zero/soft_dangle", H5L_TYPE_SOFT}, + {"hard_zero/soft_one", H5L_TYPE_SOFT}, + {"hard_zero/soft_two", H5L_TYPE_SOFT}}; typedef struct { - unsigned idx; /* Index in link visit structure */ - const link_visit_t *info; /* Pointer to the link visit structure to use */ + unsigned idx; /* Index in link visit structure */ + const link_visit_t *info; /* Pointer to the link visit structure to use */ } lvisit_ud_t; - /* Object visit structs */ typedef struct { - const char *path; /* Path to object */ - H5O_type_t type; /* Type of object */ + const char *path; /* Path to object */ + H5O_type_t type; /* Type of object */ } obj_visit_t; -static const obj_visit_t ovisit0_old[] = { - {".", H5O_TYPE_GROUP}, - {"Dataset_zero", H5O_TYPE_DATASET}, - {"Group1", H5O_TYPE_GROUP}, - {"Group1/Dataset_one", H5O_TYPE_DATASET}, - {"Group1/Group2", H5O_TYPE_GROUP}, - {"Group1/Group2/Dataset_two", H5O_TYPE_DATASET}, - {"Group1/Group2/Type_two", H5O_TYPE_NAMED_DATATYPE}, - {"Group1/Type_one", H5O_TYPE_NAMED_DATATYPE}, - {"Type_zero", H5O_TYPE_NAMED_DATATYPE} -}; -static const obj_visit_t ovisit0_new[] = { - {".", H5O_TYPE_GROUP}, - {"Dataset_zero", H5O_TYPE_DATASET}, - {"Group1", H5O_TYPE_GROUP}, - {"Group1/Dataset_one", H5O_TYPE_DATASET}, - {"Group1/Group2", H5O_TYPE_GROUP}, - {"Group1/Group2/Dataset_two", H5O_TYPE_DATASET}, - {"Group1/Group2/Type_two", H5O_TYPE_NAMED_DATATYPE}, - {"Group1/Type_one", H5O_TYPE_NAMED_DATATYPE}, - {"Type_zero", H5O_TYPE_NAMED_DATATYPE} -}; -static const obj_visit_t ovisit1_old[] = { - {".", H5O_TYPE_GROUP}, - {"Dataset_one", H5O_TYPE_DATASET}, - {"Group2", H5O_TYPE_GROUP}, - {"Group2/Dataset_two", H5O_TYPE_DATASET}, - {"Group2/Type_two", H5O_TYPE_NAMED_DATATYPE}, - {"Group2/hard_zero", H5O_TYPE_GROUP}, - {"Group2/hard_zero/Dataset_zero", H5O_TYPE_DATASET}, - {"Group2/hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE}, - {"Type_one", H5O_TYPE_NAMED_DATATYPE} -}; -static const obj_visit_t ovisit1_new[] = { - {".", H5O_TYPE_GROUP}, - {"Dataset_one", H5O_TYPE_DATASET}, - {"Group2", H5O_TYPE_GROUP}, - {"Group2/Dataset_two", H5O_TYPE_DATASET}, - {"Group2/Type_two", H5O_TYPE_NAMED_DATATYPE}, - {"Group2/hard_zero", H5O_TYPE_GROUP}, - {"Group2/hard_zero/Dataset_zero", H5O_TYPE_DATASET}, - {"Group2/hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE}, - {"Type_one", H5O_TYPE_NAMED_DATATYPE} -}; -static const obj_visit_t ovisit2_old[] = { - {".", H5O_TYPE_GROUP}, - {"Dataset_two", H5O_TYPE_DATASET}, - {"Type_two", H5O_TYPE_NAMED_DATATYPE}, - {"hard_zero", H5O_TYPE_GROUP}, - {"hard_zero/Dataset_zero", H5O_TYPE_DATASET}, - {"hard_zero/Group1", H5O_TYPE_GROUP}, - {"hard_zero/Group1/Dataset_one", H5O_TYPE_DATASET}, - {"hard_zero/Group1/Type_one", H5O_TYPE_NAMED_DATATYPE}, - {"hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE} -}; -static const obj_visit_t ovisit2_new[] = { - {".", H5O_TYPE_GROUP}, - {"Dataset_two", H5O_TYPE_DATASET}, - {"Type_two", H5O_TYPE_NAMED_DATATYPE}, - {"hard_zero", H5O_TYPE_GROUP}, - {"hard_zero/Dataset_zero", H5O_TYPE_DATASET}, - {"hard_zero/Group1", H5O_TYPE_GROUP}, - {"hard_zero/Group1/Dataset_one", H5O_TYPE_DATASET}, - {"hard_zero/Group1/Type_one", H5O_TYPE_NAMED_DATATYPE}, - {"hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE} -}; +static const obj_visit_t ovisit0_old[] = {{".", H5O_TYPE_GROUP}, + {"Dataset_zero", H5O_TYPE_DATASET}, + {"Group1", H5O_TYPE_GROUP}, + {"Group1/Dataset_one", H5O_TYPE_DATASET}, + {"Group1/Group2", H5O_TYPE_GROUP}, + {"Group1/Group2/Dataset_two", H5O_TYPE_DATASET}, + {"Group1/Group2/Type_two", H5O_TYPE_NAMED_DATATYPE}, + {"Group1/Type_one", H5O_TYPE_NAMED_DATATYPE}, + {"Type_zero", H5O_TYPE_NAMED_DATATYPE}}; +static const obj_visit_t ovisit0_new[] = {{".", H5O_TYPE_GROUP}, + {"Dataset_zero", H5O_TYPE_DATASET}, + {"Group1", H5O_TYPE_GROUP}, + {"Group1/Dataset_one", H5O_TYPE_DATASET}, + {"Group1/Group2", H5O_TYPE_GROUP}, + {"Group1/Group2/Dataset_two", H5O_TYPE_DATASET}, + {"Group1/Group2/Type_two", H5O_TYPE_NAMED_DATATYPE}, + {"Group1/Type_one", H5O_TYPE_NAMED_DATATYPE}, + {"Type_zero", H5O_TYPE_NAMED_DATATYPE}}; +static const obj_visit_t ovisit1_old[] = {{".", H5O_TYPE_GROUP}, + {"Dataset_one", H5O_TYPE_DATASET}, + {"Group2", H5O_TYPE_GROUP}, + {"Group2/Dataset_two", H5O_TYPE_DATASET}, + {"Group2/Type_two", H5O_TYPE_NAMED_DATATYPE}, + {"Group2/hard_zero", H5O_TYPE_GROUP}, + {"Group2/hard_zero/Dataset_zero", H5O_TYPE_DATASET}, + {"Group2/hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE}, + {"Type_one", H5O_TYPE_NAMED_DATATYPE}}; +static const obj_visit_t ovisit1_new[] = {{".", H5O_TYPE_GROUP}, + {"Dataset_one", H5O_TYPE_DATASET}, + {"Group2", H5O_TYPE_GROUP}, + {"Group2/Dataset_two", H5O_TYPE_DATASET}, + {"Group2/Type_two", H5O_TYPE_NAMED_DATATYPE}, + {"Group2/hard_zero", H5O_TYPE_GROUP}, + {"Group2/hard_zero/Dataset_zero", H5O_TYPE_DATASET}, + {"Group2/hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE}, + {"Type_one", H5O_TYPE_NAMED_DATATYPE}}; +static const obj_visit_t ovisit2_old[] = {{".", H5O_TYPE_GROUP}, + {"Dataset_two", H5O_TYPE_DATASET}, + {"Type_two", H5O_TYPE_NAMED_DATATYPE}, + {"hard_zero", H5O_TYPE_GROUP}, + {"hard_zero/Dataset_zero", H5O_TYPE_DATASET}, + {"hard_zero/Group1", H5O_TYPE_GROUP}, + {"hard_zero/Group1/Dataset_one", H5O_TYPE_DATASET}, + {"hard_zero/Group1/Type_one", H5O_TYPE_NAMED_DATATYPE}, + {"hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE}}; +static const obj_visit_t ovisit2_new[] = {{".", H5O_TYPE_GROUP}, + {"Dataset_two", H5O_TYPE_DATASET}, + {"Type_two", H5O_TYPE_NAMED_DATATYPE}, + {"hard_zero", H5O_TYPE_GROUP}, + {"hard_zero/Dataset_zero", H5O_TYPE_DATASET}, + {"hard_zero/Group1", H5O_TYPE_GROUP}, + {"hard_zero/Group1/Dataset_one", H5O_TYPE_DATASET}, + {"hard_zero/Group1/Type_one", H5O_TYPE_NAMED_DATATYPE}, + {"hard_zero/Type_zero", H5O_TYPE_NAMED_DATATYPE}}; typedef struct { - unsigned idx; /* Index in object visit structure */ - const obj_visit_t *info; /* Pointer to the object visit structure to use */ + unsigned idx; /* Index in object visit structure */ + const obj_visit_t *info; /* Pointer to the object visit structure to use */ } ovisit_ud_t; static hid_t dcpl_g; /* for [un]minimized dataset object headers */ -static herr_t -UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, - size_t udata_size, hid_t lcpl_id); -static hid_t -UD_hard_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, - hid_t dxpl_id); -static herr_t -UD_hard_delete(const char *link_name, hid_t file, const void *udata, - size_t udata_size); +static herr_t UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size, + hid_t lcpl_id); +static hid_t UD_hard_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t lapl_id, hid_t dxpl_id); +static herr_t UD_hard_delete(const char *link_name, hid_t file, const void *udata, size_t udata_size); /* User-defined link class */ const H5L_class_t UD_hard_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ - "UD_hard_link", /* Link class name for debugging */ - UD_hard_create, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_hard_traverse, /* The actual traversal function */ - UD_hard_delete, /* Deletion callback */ - NULL /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ + "UD_hard_link", /* Link class name for debugging */ + UD_hard_create, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_hard_traverse, /* The actual traversal function */ + UD_hard_delete, /* Deletion callback */ + NULL /* Query callback */ }}; #ifndef H5_NO_DEPRECATED_SYMBOLS -static herr_t -UD_hard_create_deprec(const char *link_name, hid_t loc_group, const void *udata, - size_t udata_size, hid_t lcpl_id); -static hid_t -UD_hard_traverse_deprec(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, - hid_t dxpl_id); -static herr_t -UD_hard_delete_deprec(const char *link_name, hid_t file, const void *udata, - size_t udata_size); +static herr_t UD_hard_create_deprec(const char *link_name, hid_t loc_group, const void *udata, + size_t udata_size, hid_t lcpl_id); +static hid_t UD_hard_traverse_deprec(const char *link_name, hid_t cur_group, const void *udata, + size_t udata_size, hid_t lapl_id, hid_t dxpl_id); +static herr_t UD_hard_delete_deprec(const char *link_name, hid_t file, const void *udata, size_t udata_size); /* User-defined link class */ const H5L_class_t UD_hard_class_deprec[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ - "UD_hard_link_deprec", /* Link class name for debugging */ - UD_hard_create_deprec, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_hard_traverse_deprec, /* The actual traversal function */ - UD_hard_delete_deprec, /* Deletion callback */ - NULL /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ + "UD_hard_link_deprec", /* Link class name for debugging */ + UD_hard_create_deprec, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_hard_traverse_deprec, /* The actual traversal function */ + UD_hard_delete_deprec, /* Deletion callback */ + NULL /* Query callback */ }}; #endif -static hid_t -UD_rereg_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, - hid_t dxpl_id); +static hid_t UD_rereg_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t lapl_id, hid_t dxpl_id); /* This link class has the same ID number as the UD hard links but * has a very different traversal function */ const H5L_class_t UD_rereg_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ - "UD_reregistered_type", /* Link class name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_rereg_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ + "UD_reregistered_type", /* Link class name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_rereg_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; -static herr_t -UD_cb_create(const char * link_name, hid_t loc_group, const void *udata, - size_t udata_size, hid_t lcpl_id); -static herr_t -UD_cb_move(const char *new_name, hid_t new_loc, const void *udata, - size_t udata_size); -static hid_t -UD_cb_traverse(const char * link_name, hid_t cur_group, const void *udata, - size_t udata_size, hid_t lapl_id, hid_t dxpl_id); -static herr_t -UD_cb_delete(const char *link_name, hid_t file, const void *udata, - size_t udata_size); -static ssize_t -UD_cb_query(const char * link_name, const void *udata, size_t udata_size, - void *buf, size_t buf_size); +static herr_t UD_cb_create(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size, + hid_t lcpl_id); +static herr_t UD_cb_move(const char *new_name, hid_t new_loc, const void *udata, size_t udata_size); +static hid_t UD_cb_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t lapl_id, hid_t dxpl_id); +static herr_t UD_cb_delete(const char *link_name, hid_t file, const void *udata, size_t udata_size); +static ssize_t UD_cb_query(const char *link_name, const void *udata, size_t udata_size, void *buf, + size_t buf_size); const H5L_class_t UD_cb_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_CB_TYPE, /* Link type id number */ - NULL, /* NULL name (to make sure this doesn't break anything */ - UD_cb_create, /* Creation callback */ - UD_cb_move, /* Move/rename callback */ - UD_cb_move, /* Copy callback */ - UD_cb_traverse, /* The actual traversal function */ - UD_cb_delete, /* Deletion callback */ - UD_cb_query /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_CB_TYPE, /* Link type id number */ + NULL, /* NULL name (to make sure this doesn't break anything */ + UD_cb_create, /* Creation callback */ + UD_cb_move, /* Move/rename callback */ + UD_cb_move, /* Copy callback */ + UD_cb_traverse, /* The actual traversal function */ + UD_cb_delete, /* Deletion callback */ + UD_cb_query /* Query callback */ }}; -static hid_t -UD_plist_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, - hid_t dxpl_id); +static hid_t UD_plist_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t lapl_id, hid_t dxpl_id); const H5L_class_t UD_plist_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ (H5L_type_t)UD_PLIST_TYPE, /* Link type id number */ - "UD_plist_link", /* Link class name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_plist_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + "UD_plist_link", /* Link class name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_plist_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; /*------------------------------------------------------------------------- @@ -446,7 +406,6 @@ fix_ext_filename(char *path_name, char *cwd, const char *file_name) HDstrcat(path_name, file_name); } - /*------------------------------------------------------------------------- * Function: mklinks * @@ -459,52 +418,63 @@ fix_ext_filename(char *path_name, char *cwd, const char *file_name) static int mklinks(hid_t fapl, hbool_t new_format) { - hid_t file, scalar, grp, d1; - hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + hid_t file, scalar, grp, d1; + hsize_t size[1] = {1}; + char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("link creation (w/new group format)") else TESTING("link creation") /* Create a file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((scalar = H5Screate_simple(1, size, size)) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((scalar = H5Screate_simple(1, size, size)) < 0) + TEST_ERROR /* Create a group */ - if((grp = H5Gcreate2(file, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(grp) < 0) TEST_ERROR + if ((grp = H5Gcreate2(file, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(grp) < 0) + TEST_ERROR /* Create a dataset */ - if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(d1) < 0) TEST_ERROR + if ((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(d1) < 0) + TEST_ERROR /* Create a hard link */ - if(H5Lcreate_hard(file, "d1", H5L_SAME_LOC, "grp1/hard", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(file, "d1", H5L_SAME_LOC, "grp1/hard", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create a symbolic link */ - if(H5Lcreate_soft("/d1", file, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft("/d1", file, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create a symbolic link to something that doesn't exist */ - if(H5Lcreate_soft("foobar", file, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft("foobar", file, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create a recursive symbolic link */ - if(H5Lcreate_soft("/grp1/recursive", file, "/grp1/recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft("/grp1/recursive", file, "/grp1/recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close */ - if(H5Sclose(scalar) < 0) TEST_ERROR - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Sclose(scalar) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR PASSED(); return SUCCEED; - error: +error: return FAIL; } - /*------------------------------------------------------------------------- * Function: new_links * @@ -517,73 +487,105 @@ mklinks(hid_t fapl, hbool_t new_format) static int new_links(hid_t fapl, hbool_t new_format) { - hid_t file_a, file_b=(-1); - hid_t grp1_a=(-1), grp1_b=(-1), grp2_a=(-1), grp2_b=(-1); - hid_t scalar=(-1); - hid_t dset1=(-1), dset2=(-1); - char filename[NAME_BUF_SIZE]; - hsize_t size[1] = {1}; - - if(new_format) + hid_t file_a, file_b = (-1); + hid_t grp1_a = (-1), grp1_b = (-1), grp2_a = (-1), grp2_b = (-1); + hid_t scalar = (-1); + hid_t dset1 = (-1), dset2 = (-1); + char filename[NAME_BUF_SIZE]; + hsize_t size[1] = {1}; + + if (new_format) TESTING("H5Lcreate functions (w/new group format)") else TESTING("H5Lcreate functions") /* Create two files */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR - if((scalar = H5Screate_simple (1, size, size)) < 0) TEST_ERROR + if ((scalar = H5Screate_simple(1, size, size)) < 0) + TEST_ERROR /* Create two groups in each file */ - if((grp1_a = H5Gcreate2(file_a, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((grp2_a = H5Gcreate2(file_a, "grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((grp1_b = H5Gcreate2(file_b, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((grp2_b = H5Gcreate2(file_b, "grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((grp1_a = H5Gcreate2(file_a, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((grp2_a = H5Gcreate2(file_a, "grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((grp1_b = H5Gcreate2(file_b, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((grp2_b = H5Gcreate2(file_b, "grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create datasets */ - if((dset1 = H5Dcreate2(file_a, "dataset1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if((dset2 = H5Dcreate2(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dset1 = H5Dcreate2(file_a, "dataset1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < + 0) + TEST_ERROR + if ((dset2 = H5Dcreate2(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Create links within a file. Both of source and destination use * H5L_SAME_LOC. Both hard and soft links should fail. */ - H5E_BEGIN_TRY { - if(H5Lcreate_hard(H5L_SAME_LOC, "dataset1", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT)!=FAIL) TEST_ERROR - } H5E_END_TRY; - H5E_BEGIN_TRY { - if(H5Lcreate_soft("dataset1", H5L_SAME_LOC, "soft", H5P_DEFAULT, H5P_DEFAULT)!=FAIL) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lcreate_hard(H5L_SAME_LOC, "dataset1", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) != FAIL) + TEST_ERROR + } + H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lcreate_soft("dataset1", H5L_SAME_LOC, "soft", H5P_DEFAULT, H5P_DEFAULT) != FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Create links across files with hard link. Should fail. */ - H5E_BEGIN_TRY { - if(H5Lcreate_hard(file_a, "dataset1", file_b, "hard", H5P_DEFAULT, H5P_DEFAULT)!=FAIL) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lcreate_hard(file_a, "dataset1", file_b, "hard", H5P_DEFAULT, H5P_DEFAULT) != FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Create hard link to test H5L_SAME_LOC */ - if(H5Lcreate_hard(grp1_a, "dataset2", H5L_SAME_LOC, "hard1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(grp1_a, "dataset2", H5L_SAME_LOC, "hard1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create links to test hard links across different locations */ - if(H5Lcreate_hard(grp1_a, "dataset2", grp2_a, "hard2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(grp1_a, "dataset2", grp2_a, "hard2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close dataspace and files */ - if(H5Sclose(scalar) < 0) TEST_ERROR - if(H5Dclose(dset1) < 0) TEST_ERROR - if(H5Dclose(dset2) < 0) TEST_ERROR - if(H5Gclose(grp1_a) < 0) TEST_ERROR - if(H5Gclose(grp2_a) < 0) TEST_ERROR - if(H5Gclose(grp1_b) < 0) TEST_ERROR - if(H5Gclose(grp2_b) < 0) TEST_ERROR - if(H5Fclose(file_a) < 0) TEST_ERROR - if(H5Fclose(file_b) < 0) TEST_ERROR + if (H5Sclose(scalar) < 0) + TEST_ERROR + if (H5Dclose(dset1) < 0) + TEST_ERROR + if (H5Dclose(dset2) < 0) + TEST_ERROR + if (H5Gclose(grp1_a) < 0) + TEST_ERROR + if (H5Gclose(grp2_a) < 0) + TEST_ERROR + if (H5Gclose(grp1_b) < 0) + TEST_ERROR + if (H5Gclose(grp2_b) < 0) + TEST_ERROR + if (H5Fclose(file_a) < 0) + TEST_ERROR + if (H5Fclose(file_b) < 0) + TEST_ERROR PASSED(); return SUCCEED; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Sclose(scalar); H5Dclose(dset1); H5Dclose(dset2); @@ -593,11 +595,11 @@ new_links(hid_t fapl, hbool_t new_format) H5Gclose(grp2_b); H5Fclose(file_a); H5Fclose(file_b); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } - /*------------------------------------------------------------------------- * Function: cklinks * @@ -611,140 +613,166 @@ new_links(hid_t fapl, hbool_t new_format) static int cklinks(hid_t fapl, hbool_t new_format) { - hid_t file; - H5O_info2_t oinfo1, oinfo2; - H5L_info2_t linfo; - char linkval[LINK_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; - int token_cmp; - herr_t status; + hid_t file; + H5O_info2_t oinfo1, oinfo2; + H5L_info2_t linfo; + char linkval[LINK_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; + int token_cmp; + herr_t status; - if(new_format) + if (new_format) TESTING("link queries (w/new group format)") else TESTING("link queries") /* Open the file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Hard link */ - if(H5Oget_info_by_name3(file, "d1", &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file, "grp1/hard", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5O_TYPE_DATASET != oinfo2.type) { + if (H5Oget_info_by_name3(file, "d1", &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file, "grp1/hard", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5O_TYPE_DATASET != oinfo2.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } /* end if */ - if(H5Otoken_cmp(file, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) FAIL_STACK_ERROR - if(token_cmp) { + if (H5Otoken_cmp(file, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) + FAIL_STACK_ERROR + if (token_cmp) { H5_FAILED(); HDputs(" Hard link test failed. Link seems not to point to the "); HDputs(" expected file location."); TEST_ERROR } /* end if */ - if(H5Lexists(file, "/", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - if(H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - if(H5Lexists(file, "grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - if(H5Lexists(file, "/grp1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - if(H5Lexists(file, "/grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - H5E_BEGIN_TRY { + if (H5Lexists(file, "/", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + if (H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + if (H5Lexists(file, "grp1/hard", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + if (H5Lexists(file, "/grp1", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + if (H5Lexists(file, "/grp1/hard", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { status = H5Lexists(file, "no_grp1/hard", H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); HDputs(" H5Lexists() should have failed for a path with missing components."); TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); HDputs(" H5Lexists() should have failed for a path with missing components."); TEST_ERROR } /* end if */ /* Symbolic link */ - if(H5Oget_info_by_name3(file, "grp1/soft", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5O_TYPE_DATASET != oinfo2.type) { + if (H5Oget_info_by_name3(file, "grp1/soft", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5O_TYPE_DATASET != oinfo2.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } /* end if */ - if(H5Otoken_cmp(file, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) FAIL_STACK_ERROR - if(token_cmp) { + if (H5Otoken_cmp(file, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) + FAIL_STACK_ERROR + if (token_cmp) { H5_FAILED(); HDputs(" Soft link test failed. Link seems not to point to the "); HDputs(" expected file location."); TEST_ERROR } /* end if */ - if(H5Lget_val(file, "grp1/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(HDstrcmp(linkval, "/d1")) { + if (H5Lget_val(file, "grp1/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(linkval, "/d1")) { H5_FAILED(); HDputs(" Soft link test failed. Wrong link value"); TEST_ERROR } /* end if */ - if(H5Lexists(file, "grp1/soft", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if (H5Lexists(file, "grp1/soft", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR /* Dangling link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Oget_info_by_name3(file, "grp1/dangle", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); HDputs(" H5Oget_info_by_name() should have failed for a dangling link."); TEST_ERROR } /* end if */ - if(H5Lget_info2(file, "grp1/dangle", &linfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5L_TYPE_SOFT != linfo.type) { + if (H5Lget_info2(file, "grp1/dangle", &linfo, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5L_TYPE_SOFT != linfo.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); TEST_ERROR } /* end if */ - if(H5Lget_val(file, "grp1/dangle", linkval, sizeof linkval, H5P_DEFAULT) < 0) { + if (H5Lget_val(file, "grp1/dangle", linkval, sizeof linkval, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf(" %d: Can't retrieve link value\n", __LINE__); TEST_ERROR } /* end if */ - if(HDstrcmp(linkval, "foobar")) { + if (HDstrcmp(linkval, "foobar")) { H5_FAILED(); HDputs(" Dangling link test failed. Wrong link value"); TEST_ERROR } /* end if */ - if(H5Lexists(file, "grp1/dangle", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if (H5Lexists(file, "grp1/dangle", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR /* Recursive link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Oget_info_by_name3(file, "grp1/recursive", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); HDputs(" H5Oget_info_by_name() should have failed for a recursive link."); TEST_ERROR } /* end if */ - if(H5Lget_info2(file, "grp1/recursive", &linfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5L_TYPE_SOFT != linfo.type) { + if (H5Lget_info2(file, "grp1/recursive", &linfo, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5L_TYPE_SOFT != linfo.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); TEST_ERROR } /* end if */ - if(H5Lget_val(file, "grp1/recursive", linkval, sizeof linkval, H5P_DEFAULT) < 0) { + if (H5Lget_val(file, "grp1/recursive", linkval, sizeof linkval, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf(" %d: Can't retrieve link value\n", __LINE__); TEST_ERROR } /* end if */ - if(HDstrcmp(linkval, "/grp1/recursive")) { + if (HDstrcmp(linkval, "/grp1/recursive")) { H5_FAILED(); HDputs(" Recursive link test failed. Wrong link value"); TEST_ERROR } /* end if */ /* Non-existent link */ - if(H5Lexists(file, "foobar", H5P_DEFAULT) == TRUE) FAIL_STACK_ERROR + if (H5Lexists(file, "foobar", H5P_DEFAULT) == TRUE) + FAIL_STACK_ERROR /* Cleanup */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; @@ -753,7 +781,6 @@ error: return FAIL; } /* end cklinks() */ - /*------------------------------------------------------------------------- * Function: ck_new_links * @@ -767,35 +794,41 @@ error: static int ck_new_links(hid_t fapl, hbool_t new_format) { - hid_t file; - H5O_info2_t oi_dset, oi_hard1, oi_hard2; - char filename[NAME_BUF_SIZE]; - int token_cmp1, token_cmp2; + hid_t file; + H5O_info2_t oi_dset, oi_hard1, oi_hard2; + char filename[NAME_BUF_SIZE]; + int token_cmp1, token_cmp2; - if(new_format) + if (new_format) TESTING("new link queries (w/new group format)") else TESTING("new link queries") /* Open the file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Get hard link info */ - if(H5Oget_info_by_name3(file, "/grp1/dataset2", &oi_dset, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file, "/grp1/hard1", &oi_hard1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file, "/grp2/hard2", &oi_hard2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_info_by_name3(file, "/grp1/dataset2", &oi_dset, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file, "/grp1/hard1", &oi_hard1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file, "/grp2/hard2", &oi_hard2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR /* Check hard links */ - if(H5O_TYPE_DATASET != oi_hard1.type || H5O_TYPE_DATASET != oi_hard2.type) { + if (H5O_TYPE_DATASET != oi_hard1.type || H5O_TYPE_DATASET != oi_hard2.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } - if(H5Otoken_cmp(file, &oi_dset.token, &oi_hard1.token, &token_cmp1) < 0) TEST_ERROR - if(H5Otoken_cmp(file, &oi_dset.token, &oi_hard2.token, &token_cmp2) < 0) TEST_ERROR - if(token_cmp1 || token_cmp2) { + if (H5Otoken_cmp(file, &oi_dset.token, &oi_hard1.token, &token_cmp1) < 0) + TEST_ERROR + if (H5Otoken_cmp(file, &oi_dset.token, &oi_hard2.token, &token_cmp2) < 0) + TEST_ERROR + if (token_cmp1 || token_cmp2) { H5_FAILED(); HDputs(" Hard link test failed. Link seems not to point to the "); HDputs(" expected file location."); @@ -803,7 +836,8 @@ ck_new_links(hid_t fapl, hbool_t new_format) } /* Cleanup */ - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR PASSED(); return 0; @@ -812,7 +846,6 @@ error: return -1; } /* end ck_new_links() */ - /*------------------------------------------------------------------------- * Function: long_links * @@ -825,45 +858,54 @@ error: static int long_links(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t gid2 = -1; /* Datatype ID */ - char *objname = NULL; /* Name of object [Long] */ - size_t u; /* Local index variable */ - char filename[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t gid2 = -1; /* Datatype ID */ + char * objname = NULL; /* Name of object [Long] */ + size_t u; /* Local index variable */ + char filename[NAME_BUF_SIZE]; + + if (new_format) TESTING("long names for objects & links (w/new group format)") else TESTING("long names for objects & links") /* Create files */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group with short name in file (used as target for hard links) */ - if((gid = H5Gcreate2(fid, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Construct very long file name */ - if((objname = (char *)HDmalloc((size_t)(MAX_NAME_LEN + 1))) == NULL) TEST_ERROR - for(u = 0; u < MAX_NAME_LEN; u++) + if ((objname = (char *)HDmalloc((size_t)(MAX_NAME_LEN + 1))) == NULL) + TEST_ERROR + for (u = 0; u < MAX_NAME_LEN; u++) objname[u] = 'a'; objname[MAX_NAME_LEN] = '\0'; /* Create hard link to existing object */ - if(H5Lcreate_hard(fid, "grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(fid, "grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create soft link to existing object */ objname[0] = 'b'; - if(H5Lcreate_soft("grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft("grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create group with long name in existing group */ - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close objects */ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Release memory */ HDfree(objname); @@ -871,17 +913,18 @@ long_links(hid_t fapl, hbool_t new_format) PASSED(); return SUCCEED; - error: - H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; HDfree(objname); return FAIL; } - /*------------------------------------------------------------------------- * Function: toomany * @@ -894,12 +937,12 @@ long_links(hid_t fapl, hbool_t new_format) static int toomany(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("too many links (w/new group format)") else TESTING("too many links") @@ -912,116 +955,175 @@ toomany(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group with short name in file (used as target for hard links) */ - if((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create chain of hard links to existing object (no limit on #) */ - if(H5Lcreate_hard(fid, "final", fid, "hard1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard1", fid, "hard2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard2", fid, "hard3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard3", fid, "hard4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard4", fid, "hard5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard5", fid, "hard6", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard6", fid, "hard7", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard7", fid, "hard8", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard8", fid, "hard9", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard9", fid, "hard10", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard10", fid, "hard11", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard11", fid, "hard12", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard12", fid, "hard13", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard13", fid, "hard14", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard14", fid, "hard15", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard15", fid, "hard16", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard16", fid, "hard17", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard17", fid, "hard18", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard18", fid, "hard19", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard19", fid, "hard20", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "hard20", fid, "hard21", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(fid, "final", fid, "hard1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard1", fid, "hard2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard2", fid, "hard3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard3", fid, "hard4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard4", fid, "hard5", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard5", fid, "hard6", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard6", fid, "hard7", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard7", fid, "hard8", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard8", fid, "hard9", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard9", fid, "hard10", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard10", fid, "hard11", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard11", fid, "hard12", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard12", fid, "hard13", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard13", fid, "hard14", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard14", fid, "hard15", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard15", fid, "hard16", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard16", fid, "hard17", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard17", fid, "hard18", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard18", fid, "hard19", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard19", fid, "hard20", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "hard20", fid, "hard21", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create chain of soft links to existing object (limited) */ - if(H5Lcreate_soft("final", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft1", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft2", fid, "soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft3", fid, "soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft4", fid, "soft5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft5", fid, "soft6", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft6", fid, "soft7", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft7", fid, "soft8", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft8", fid, "soft9", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft9", fid, "soft10", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft10", fid, "soft11", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft11", fid, "soft12", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft12", fid, "soft13", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft13", fid, "soft14", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft14", fid, "soft15", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft15", fid, "soft16", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("soft16", fid, "soft17", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft("final", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft1", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft2", fid, "soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft3", fid, "soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft4", fid, "soft5", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft5", fid, "soft6", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft6", fid, "soft7", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft7", fid, "soft8", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft8", fid, "soft9", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft9", fid, "soft10", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft10", fid, "soft11", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft11", fid, "soft12", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft12", fid, "soft13", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft13", fid, "soft14", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft14", fid, "soft15", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft15", fid, "soft16", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("soft16", fid, "soft17", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open file */ - if((fid=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open object through last hard link */ - if((gid = H5Gopen2(fid, "hard21", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "hard21", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/hard21")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/hard21")) + TEST_ERROR /* Create object in hard-linked group */ - if((gid2 = H5Gcreate2(gid, "new_hard", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_hard", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group in hard-linked group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close hard-linked object */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Open object through too deep soft link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "soft17", H5P_DEFAULT); - } H5E_END_TRY; - if(gid >= 0) { + } + H5E_END_TRY; + if (gid >= 0) { H5_FAILED(); HDputs(" Should have failed for sequence of too many nested links."); TEST_ERROR } /* end if */ /* Open object through lesser soft link */ - if((gid = H5Gopen2(fid, "soft16", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "soft16", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/soft16")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/soft16")) + TEST_ERROR /* Create object using soft links */ - if((gid2 = H5Gcreate2(gid, "new_soft", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_soft", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close groups */ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end toomany() */ - /*------------------------------------------------------------------------- * Function: test_lcpl * @@ -1034,17 +1136,17 @@ toomany(hid_t fapl, hbool_t new_format) static int test_lcpl(hid_t fapl, hbool_t new_format) { - hid_t file_id = -1; - hid_t group_id = -1; - hid_t space_id = -1; - hid_t dset_id = -1; - hid_t type_id = -1; - hid_t lcpl_id = -1; - H5L_info2_t linfo; - char filename[1024]; - hsize_t dims[2]; - - if(new_format) + hid_t file_id = -1; + hid_t group_id = -1; + hid_t space_id = -1; + hid_t dset_id = -1; + hid_t type_id = -1; + hid_t lcpl_id = -1; + H5L_info2_t linfo; + char filename[1024]; + hsize_t dims[2]; + + if (new_format) TESTING("link creation property lists (w/new group format)") else TESTING("link creation property lists") @@ -1055,127 +1157,186 @@ test_lcpl(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create and link a group with the default LCPL */ - if((group_id = H5Gcreate2(file_id, "/group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, "/group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Check that its character encoding is the default */ - if(H5Lget_info2(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5F_DEFAULT_CSET) TEST_ERROR + if (H5Lget_info2(file_id, "group", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5F_DEFAULT_CSET) + TEST_ERROR /* Create and commit a datatype with the default LCPL */ - if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(file_id, "/type", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(type_id) < 0) TEST_ERROR + if ((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(file_id, "/type", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(type_id) < 0) + TEST_ERROR /* Check that its character encoding is the default */ - if(H5Lget_info2(file_id, "type", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5F_DEFAULT_CSET) TEST_ERROR + if (H5Lget_info2(file_id, "type", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5F_DEFAULT_CSET) + TEST_ERROR /* Create a dataspace */ dims[0] = H5L_DIM1; dims[1] = H5L_DIM2; - if((space_id=H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR /* Create a dataset using the default LCPL */ - if((dset_id = H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(dset_id) < 0) TEST_ERROR + if ((dset_id = + H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(dset_id) < 0) + TEST_ERROR /* Check that its character encoding is the default */ - if(H5Lget_info2(file_id, "dataset", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5F_DEFAULT_CSET) TEST_ERROR + if (H5Lget_info2(file_id, "dataset", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5F_DEFAULT_CSET) + TEST_ERROR /* Create a link creation property list with the UTF-8 character encoding */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) + TEST_ERROR /* Create and link a group with the new LCPL */ - if((group_id = H5Gcreate2(file_id, "/group2", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, "/group2", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(H5Lget_info2(file_id, "group2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info2(file_id, "group2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Create and commit a datatype with the new LCPL */ - if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(file_id, "/type2", type_id, lcpl_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(type_id) < 0) TEST_ERROR + if ((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(file_id, "/type2", type_id, lcpl_id, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(type_id) < 0) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(H5Lget_info2(file_id, "type2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info2(file_id, "type2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Create a dataset using the new LCPL */ - if((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(dset_id) < 0) TEST_ERROR + if ((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, dcpl_g, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Dclose(dset_id) < 0) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(H5Lget_info2(file_id, "dataset2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info2(file_id, "dataset2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Create a new link to the dataset with a different character encoding. */ - if(H5Pclose(lcpl_id) < 0) TEST_ERROR - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) + TEST_ERROR - if(H5Lcreate_hard(file_id, "/dataset2", file_id, "/dataset2_link", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(file_id, "/dataset2", file_id, "/dataset2_link", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Check that its character encoding is ASCII */ - if(H5Lget_info2(file_id, "/dataset2_link", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_ASCII) TEST_ERROR + if (H5Lget_info2(file_id, "/dataset2_link", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_ASCII) + TEST_ERROR /* Check that the first link's encoding hasn't changed */ - if(H5Lget_info2(file_id, "/dataset2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info2(file_id, "/dataset2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Make sure that LCPLs work properly for other API calls: */ /* H5Lcreate_soft */ - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR - if(H5Lcreate_soft("dataset2", file_id, "slink_to_dset2", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info2(file_id, "slink_to_dset2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) + TEST_ERROR + if (H5Lcreate_soft("dataset2", file_id, "slink_to_dset2", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info2(file_id, "slink_to_dset2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* H5Lmove */ - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) TEST_ERROR - if(H5Lmove(file_id, "slink_to_dset2", file_id, "moved_slink", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info2(file_id, "moved_slink", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_ASCII) TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) + TEST_ERROR + if (H5Lmove(file_id, "slink_to_dset2", file_id, "moved_slink", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info2(file_id, "moved_slink", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_ASCII) + TEST_ERROR /* H5Lcopy */ - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR - if(H5Lcopy(file_id, "moved_slink", file_id, "copied_slink", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info2(file_id, "copied_slink", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) + TEST_ERROR + if (H5Lcopy(file_id, "moved_slink", file_id, "copied_slink", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info2(file_id, "copied_slink", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* H5Lcreate_external */ - if(H5Lcreate_external("filename", "path", file_id, "extlink", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info2(file_id, "extlink", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lcreate_external("filename", "path", file_id, "extlink", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info2(file_id, "extlink", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Close open IDs */ - if(H5Pclose(lcpl_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Dclose(dset_id); H5Tclose(type_id); H5Pclose(lcpl_id); H5Sclose(space_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_lcpl() */ - /*------------------------------------------------------------------------- * Function: test_move * @@ -1188,97 +1349,136 @@ error: static int test_move(hid_t fapl, hbool_t new_format) { - hid_t file_a = -1, file_b = -1; - hid_t grp_1 = -1, grp_2 = -1, grp_move = -1, moved_grp = -1; - char filename[1024]; + hid_t file_a = -1, file_b = -1; + hid_t grp_1 = -1, grp_2 = -1, grp_move = -1, moved_grp = -1; + char filename[1024]; - if(new_format) + if (new_format) TESTING("H5Lmove (w/new group format)") else TESTING("H5Lmove") /* Create two new files */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create groups in first file */ - if((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((grp_2 = H5Gcreate2(file_a, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((grp_move = H5Gcreate2(grp_1, "group_move", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((grp_2 = H5Gcreate2(file_a, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((grp_move = H5Gcreate2(grp_1, "group_move", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create hard, soft and external links. */ - if(H5Lcreate_hard(grp_1, "group_move", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/group1/group_move", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(grp_1, "group_move", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("/group1/group_move", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Move a group within the file. Both of source and destination use * H5L_SAME_LOC. Should fail. */ - H5E_BEGIN_TRY { - if(H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT)!=FAIL) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != + FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Move a group across files. Should fail. */ - H5E_BEGIN_TRY { - if(H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) !=FAIL) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Move a soft link across files. Should succeed. */ - if(H5Lmove(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lexists(file_b, "soft_new_name", H5P_DEFAULT) != TRUE) TEST_ERROR + if (H5Lmove(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lexists(file_b, "soft_new_name", H5P_DEFAULT) != TRUE) + TEST_ERROR /* Move an external link across files. Should succeed. */ - if(H5Lmove(grp_2, "ext", file_b, "ext_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lexists(file_b, "ext_new_name", H5P_DEFAULT) != TRUE) TEST_ERROR + if (H5Lmove(grp_2, "ext", file_b, "ext_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lexists(file_b, "ext_new_name", H5P_DEFAULT) != TRUE) + TEST_ERROR /* Move a group across groups in the same file while renaming it. */ - if(H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group just moved to the new location. */ - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if( H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Verify that the group is no longer in the original location */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { moved_grp = H5Gopen2(grp_1, "group_move", H5P_DEFAULT); - } H5E_END_TRY; - if(moved_grp >= 0) { + } + H5E_END_TRY; + if (moved_grp >= 0) { H5_FAILED(); HDputs(" Group still in original location?"); TEST_ERROR } /* end if */ /* Use H5Lmove to rename a group without moving it. */ - if(H5Lmove(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lmove(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group. */ - if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Use H5Lmove to move a group without renaming it. */ - if(H5Lmove(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lmove(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group . */ - if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Move the group while giving long paths. */ - if(H5Lmove(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lmove(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group just moved to the new location. */ - if((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Verify that the group is in no previous locations */ - H5E_BEGIN_TRY { - if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR - if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR - if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if ((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) >= 0) + FAIL_STACK_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) >= 0) + FAIL_STACK_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) >= 0) + FAIL_STACK_ERROR + if ((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) >= 0) + FAIL_STACK_ERROR + } + H5E_END_TRY; H5Gclose(grp_1); H5Gclose(grp_2); @@ -1291,18 +1491,19 @@ test_move(hid_t fapl, hbool_t new_format) error: H5_FAILED(); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(grp_1); H5Gclose(grp_2); H5Gclose(grp_move); H5Gclose(moved_grp); H5Fclose(file_a); H5Fclose(file_b); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_copy * @@ -1315,97 +1516,143 @@ error: static int test_copy(hid_t fapl, hbool_t new_format) { - hid_t file_a = -1, file_b = -1; - hid_t grp_1 = -1, grp_2 = -1, grp_move = -1, moved_grp = -1; - char filename[1024]; + hid_t file_a = -1, file_b = -1; + hid_t grp_1 = -1, grp_2 = -1, grp_move = -1, moved_grp = -1; + char filename[1024]; - if(new_format) + if (new_format) TESTING("H5Lcopy (w/new group format)") else TESTING("H5Lcopy") /* Create two new files */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create groups in first file */ - if((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((grp_2 = H5Gcreate2(file_a, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((grp_move = H5Gcreate2(grp_1, "group_copy", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((grp_2 = H5Gcreate2(file_a, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((grp_move = H5Gcreate2(grp_1, "group_copy", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create hard, soft and external links. */ - if(H5Lcreate_hard(grp_1, "group_copy", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/group1/group_copy", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(grp_1, "group_copy", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("/group1/group_copy", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external("filename", "pathname", grp_2, "ext", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Copy a group within the file. Both of source and destination use * H5L_SAME_LOC. Should fail. */ - H5E_BEGIN_TRY { - if(H5Lcopy(H5L_SAME_LOC, "group_copy", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) !=FAIL) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lcopy(H5L_SAME_LOC, "group_copy", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != + FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Copy a group across files. Should fail. */ - H5E_BEGIN_TRY { - if(H5Lcopy(grp_1, "group_copy", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) !=FAIL) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lcopy(grp_1, "group_copy", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Copy a soft link across files. Should succeed. */ - if(H5Lcopy(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lexists(file_b, "soft_new_name", H5P_DEFAULT) != TRUE) TEST_ERROR + if (H5Lcopy(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lexists(file_b, "soft_new_name", H5P_DEFAULT) != TRUE) + TEST_ERROR /* Copy an external link across files. Should succeed. */ - if(H5Lcopy(grp_2, "ext", file_b, "ext_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lexists(file_b, "ext_new_name", H5P_DEFAULT) != TRUE) TEST_ERROR + if (H5Lcopy(grp_2, "ext", file_b, "ext_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lexists(file_b, "ext_new_name", H5P_DEFAULT) != TRUE) + TEST_ERROR /* Move a group across groups in the same file while renaming it. */ - if(H5Lcopy(grp_1, "group_copy", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcopy(grp_1, "group_copy", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group just moved to the new location. */ - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Verify that the group is also in the original location */ - if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Use H5Lcopy to create a group in the same location with a different name. */ - if(H5Lcopy(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcopy(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group. */ - if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Verify that the group is also in the original location */ - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Use H5Lcopy to copy to a different location with the same name. */ - if(H5Lcopy(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcopy(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group . */ - if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Verify that the group is still in the previous location */ - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Copy the group while giving long paths. */ - if(H5Lcopy(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcopy(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group just moved to the new location. */ - if((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_newest_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR /* Verify that the group is still in all previous original locations */ - if((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR - if((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR - if((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR + if ((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR + if ((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + TEST_ERROR H5Gclose(grp_1); H5Gclose(grp_2); @@ -1418,18 +1665,19 @@ test_copy(hid_t fapl, hbool_t new_format) error: H5_FAILED(); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(grp_1); H5Gclose(grp_2); H5Gclose(grp_move); H5Gclose(moved_grp); H5Fclose(file_a); H5Fclose(file_b); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_move_preserves * @@ -1443,21 +1691,21 @@ error: static int test_move_preserves(hid_t fapl_id, hbool_t new_format) { - hid_t file_id=-1; - hid_t group_id=-1; - hid_t fcpl_id=-1; /* Group creation property list ID */ - hid_t lcpl_id=-1; - hid_t lcpl2_id=-1; + hid_t file_id = -1; + hid_t group_id = -1; + hid_t fcpl_id = -1; /* Group creation property list ID */ + hid_t lcpl_id = -1; + hid_t lcpl2_id = -1; H5O_info2_t oinfo; H5L_info2_t linfo; - H5T_cset_t old_cset; - int64_t old_corder; /* Creation order value of link */ - time_t old_modification_time; - time_t curr_time; - unsigned crt_order_flags; /* Status of creation order info for GCPL */ - char filename[1024]; - - if(new_format) + H5T_cset_t old_cset; + int64_t old_corder; /* Creation order value of link */ + time_t old_modification_time; + time_t curr_time; + unsigned crt_order_flags; /* Status of creation order info for GCPL */ + char filename[1024]; + + if (new_format) TESTING("moving and copying links preserves their properties (w/new group format)") else TESTING("moving and copying links preserves their properties") @@ -1465,140 +1713,211 @@ test_move_preserves(hid_t fapl_id, hbool_t new_format) /* Create a file creation property list with creation order stored for links * in the root group */ - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR - if(H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) TEST_ERROR - if(crt_order_flags != 0) TEST_ERROR - if(H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED) < 0) TEST_ERROR - if(H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) TEST_ERROR - if(crt_order_flags != H5P_CRT_ORDER_TRACKED) TEST_ERROR + if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + if (H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) + TEST_ERROR + if (crt_order_flags != 0) + TEST_ERROR + if (H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + TEST_ERROR + if (H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) + TEST_ERROR + if (crt_order_flags != H5P_CRT_ORDER_TRACKED) + TEST_ERROR /* Create file */ /* (with creation order tracking for the root group) */ h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) + TEST_ERROR /* Create a link creation property list with the UTF-8 character encoding */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) + TEST_ERROR /* Create a group with that lcpl */ - if((group_id = H5Gcreate2(file_id, "group", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, "group", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Get the group's link's information */ - if(H5Lget_info2(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info2(file_id, "group", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR old_cset = linfo.cset; - if(old_cset != H5T_CSET_UTF8) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR + if (old_cset != H5T_CSET_UTF8) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR old_corder = linfo.corder; - if(old_corder != 0) TEST_ERROR + if (old_corder != 0) + TEST_ERROR old_modification_time = oinfo.mtime; /* If this test happens too quickly, the times will all be the same. Make sure the time changes. */ curr_time = HDtime(NULL); - while(HDtime(NULL) <= curr_time) + while (HDtime(NULL) <= curr_time) ; /* Close the file and reopen it */ - if(H5Fclose(file_id) < 0) TEST_ERROR - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + TEST_ERROR /* Get the link's character set & modification time . They should be unchanged */ - if(H5Lget_info2(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(old_cset != linfo.cset) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(old_corder != linfo.corder) TEST_ERROR - - /* Create a new link to the group. It should have a different creation order value but the same modification time */ - if(H5Lcreate_hard(file_id, "group", file_id, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file_id, "group2", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info2(file_id, "group2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(old_corder == linfo.corder) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 1) TEST_ERROR - if(linfo.cset != H5T_CSET_ASCII) TEST_ERROR + if (H5Lget_info2(file_id, "group", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (old_cset != linfo.cset) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (old_corder != linfo.corder) + TEST_ERROR + + /* Create a new link to the group. It should have a different creation order value but the same + * modification time */ + if (H5Lcreate_hard(file_id, "group", file_id, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file_id, "group2", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info2(file_id, "group2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_corder == linfo.corder) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 1) + TEST_ERROR + if (linfo.cset != H5T_CSET_ASCII) + TEST_ERROR /* Copy the first link to a UTF-8 name. * Its creation order value should be different, but modification time * should not change. */ - if(H5Lcopy(file_id, "group", file_id, "group_copied", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file_id, "group_copied", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info2(file_id, "group_copied", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 2) TEST_ERROR + if (H5Lcopy(file_id, "group", file_id, "group_copied", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file_id, "group_copied", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info2(file_id, "group_copied", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 2) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Move the link with the default property list. */ - if(H5Lmove(file_id, "group_copied", file_id, "group_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file_id, "group_copied2", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info2(file_id, "group_copied2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 3) TEST_ERROR + if (H5Lmove(file_id, "group_copied", file_id, "group_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file_id, "group_copied2", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info2(file_id, "group_copied2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 3) + TEST_ERROR /* Check that its character encoding is not UTF-8 */ - if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR + if (linfo.cset == H5T_CSET_UTF8) + TEST_ERROR /* Check that the original link is unchanged */ - if(H5Oget_info_by_name3(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info2(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(old_corder != linfo.corder) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Oget_info_by_name3(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info2(file_id, "group", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (old_corder != linfo.corder) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Move the first link to a UTF-8 name. * Its creation order value will change, but modification time should not * change. */ - if(H5Lmove(file_id, "group", file_id, "group_moved", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file_id, "group_moved", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info2(file_id, "group_moved", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 4) TEST_ERROR + if (H5Lmove(file_id, "group", file_id, "group_moved", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file_id, "group_moved", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info2(file_id, "group_moved", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 4) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Move the link again using the default property list. */ - if(H5Lmove(file_id, "group_moved", file_id, "group_moved_again", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(file_id, "group_moved_again", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info2(file_id, "group_moved_again", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 5) TEST_ERROR + if (H5Lmove(file_id, "group_moved", file_id, "group_moved_again", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(file_id, "group_moved_again", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info2(file_id, "group_moved_again", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 5) + TEST_ERROR /* Check that its character encoding is not UTF-8 */ - if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR + if (linfo.cset == H5T_CSET_UTF8) + TEST_ERROR /* Close open IDs */ - if(H5Pclose(fcpl_id) < 0) TEST_ERROR - if(H5Pclose(lcpl_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Pclose(fcpl_id) < 0) + TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl_id); H5Pclose(lcpl_id); H5Pclose(lcpl2_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_move_preserves() */ - /*------------------------------------------------------------------------- * Function: test_deprec * @@ -1612,16 +1931,16 @@ error: static int test_deprec(hid_t fapl, hbool_t new_format) { - hid_t file_id = -1; - hid_t group1_id = -1; - hid_t group2_id = -1; - H5G_stat_t sb_hard1, sb_hard2, sb_soft1, sb_soft2; - H5G_obj_t obj_type; /* Object type */ - hsize_t num_objs; /* Number of objects in a group */ - char filename[1024]; - char tmpstr[1024]; - - if(new_format) + hid_t file_id = -1; + hid_t group1_id = -1; + hid_t group2_id = -1; + H5G_stat_t sb_hard1, sb_hard2, sb_soft1, sb_soft2; + H5G_obj_t obj_type; /* Object type */ + hsize_t num_objs; /* Number of objects in a group */ + char filename[1024]; + char tmpstr[1024]; + + if (new_format) TESTING("backwards compatibility (w/new group format)") else TESTING("backwards compatibility") @@ -1629,48 +1948,74 @@ test_deprec(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create two groups in the file */ - if((group1_id = H5Gcreate2(file_id, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gcreate2(file_id, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group1_id = H5Gcreate2(file_id, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gcreate2(file_id, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Test H5Gset and get comment */ - if(H5Gset_comment(file_id, "group1", "comment") < 0) FAIL_STACK_ERROR - if(H5Gget_comment(file_id, "group1", sizeof(tmpstr), tmpstr) < 0) FAIL_STACK_ERROR - if(HDstrcmp(tmpstr, "comment")) TEST_ERROR + if (H5Gset_comment(file_id, "group1", "comment") < 0) + FAIL_STACK_ERROR + if (H5Gget_comment(file_id, "group1", sizeof(tmpstr), tmpstr) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(tmpstr, "comment")) + TEST_ERROR /* Create links using H5Glink and H5Glink2 */ - if(H5Glink(file_id, H5G_LINK_HARD, "group2", "group1/link_to_group2") < 0) FAIL_STACK_ERROR - if(H5Glink2(file_id, "group1", H5G_LINK_HARD, group2_id, "link_to_group1") < 0) FAIL_STACK_ERROR - if(H5Glink2(file_id, "link_to_group1", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/soft_link_to_group1") < 0) FAIL_STACK_ERROR - if(H5Glink2(file_id, "dangle", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/dangle_soft_link") < 0) FAIL_STACK_ERROR + if (H5Glink(file_id, H5G_LINK_HARD, "group2", "group1/link_to_group2") < 0) + FAIL_STACK_ERROR + if (H5Glink2(file_id, "group1", H5G_LINK_HARD, group2_id, "link_to_group1") < 0) + FAIL_STACK_ERROR + if (H5Glink2(file_id, "link_to_group1", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/soft_link_to_group1") < 0) + FAIL_STACK_ERROR + if (H5Glink2(file_id, "dangle", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/dangle_soft_link") < 0) + FAIL_STACK_ERROR /* Test getting the names for objects */ - if(H5Gget_objname_by_idx(group1_id, (hsize_t)0, tmpstr, sizeof(tmpstr)) < 0) FAIL_STACK_ERROR - if(HDstrcmp(tmpstr, "link_to_group2")) TEST_ERROR - H5E_BEGIN_TRY { - if(H5Gget_objname_by_idx(group1_id, (hsize_t)1, tmpstr, sizeof(tmpstr)) >= 0) TEST_ERROR - } H5E_END_TRY; + if (H5Gget_objname_by_idx(group1_id, (hsize_t)0, tmpstr, sizeof(tmpstr)) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(tmpstr, "link_to_group2")) + TEST_ERROR + H5E_BEGIN_TRY + { + if (H5Gget_objname_by_idx(group1_id, (hsize_t)1, tmpstr, sizeof(tmpstr)) >= 0) + TEST_ERROR + } + H5E_END_TRY; /* Test getting the type for objects */ - if((obj_type = H5Gget_objtype_by_idx(group1_id, (hsize_t)0)) < 0) FAIL_STACK_ERROR - if(obj_type != H5G_GROUP) TEST_ERROR - H5E_BEGIN_TRY { - if(H5Gget_objtype_by_idx(group1_id, (hsize_t)1) >= 0) TEST_ERROR - } H5E_END_TRY; + if ((obj_type = H5Gget_objtype_by_idx(group1_id, (hsize_t)0)) < 0) + FAIL_STACK_ERROR + if (obj_type != H5G_GROUP) + TEST_ERROR + H5E_BEGIN_TRY + { + if (H5Gget_objtype_by_idx(group1_id, (hsize_t)1) >= 0) + TEST_ERROR + } + H5E_END_TRY; /* Test getting the number of objects in a group */ - if(H5Gget_num_objs(file_id, &num_objs) < 0) FAIL_STACK_ERROR - if(num_objs != 2) TEST_ERROR - if(H5Gget_num_objs(group1_id, &num_objs) < 0) FAIL_STACK_ERROR - if(num_objs != 1) TEST_ERROR + if (H5Gget_num_objs(file_id, &num_objs) < 0) + FAIL_STACK_ERROR + if (num_objs != 2) + TEST_ERROR + if (H5Gget_num_objs(group1_id, &num_objs) < 0) + FAIL_STACK_ERROR + if (num_objs != 1) + TEST_ERROR /* Test that H5Glink created hard links properly */ - if(H5Gget_objinfo(file_id, "/group2", TRUE, &sb_hard1) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file_id, "/group1/link_to_group2", TRUE, &sb_hard2) < 0) FAIL_STACK_ERROR + if (H5Gget_objinfo(file_id, "/group2", TRUE, &sb_hard1) < 0) + FAIL_STACK_ERROR + if (H5Gget_objinfo(file_id, "/group1/link_to_group2", TRUE, &sb_hard2) < 0) + FAIL_STACK_ERROR - if(HDmemcmp(&sb_hard1.objno, sb_hard2.objno, sizeof(sb_hard1.objno))) { + if (HDmemcmp(&sb_hard1.objno, sb_hard2.objno, sizeof(sb_hard1.objno))) { H5_FAILED(); HDputs(" Hard link test failed. Link seems not to point to the "); HDputs(" expected file location."); @@ -1678,10 +2023,12 @@ test_deprec(hid_t fapl, hbool_t new_format) } /* end if */ /* Test for the other hard link created */ - if(H5Gget_objinfo(file_id, "/group1", TRUE, &sb_hard1) < 0) FAIL_STACK_ERROR - if(H5Gget_objinfo(file_id, "/group2/link_to_group1", TRUE, &sb_hard2) < 0) FAIL_STACK_ERROR + if (H5Gget_objinfo(file_id, "/group1", TRUE, &sb_hard1) < 0) + FAIL_STACK_ERROR + if (H5Gget_objinfo(file_id, "/group2/link_to_group1", TRUE, &sb_hard2) < 0) + FAIL_STACK_ERROR - if(HDmemcmp(&sb_hard1.objno, sb_hard2.objno, sizeof(sb_hard1.objno))) { + if (HDmemcmp(&sb_hard1.objno, sb_hard2.objno, sizeof(sb_hard1.objno))) { H5_FAILED(); HDputs(" Hard link test failed. Link seems not to point to the "); HDputs(" expected file location."); @@ -1689,60 +2036,87 @@ test_deprec(hid_t fapl, hbool_t new_format) } /* end if */ /* Test the soft link */ - if(H5Gget_objinfo(file_id, "/group2/soft_link_to_group1", FALSE, &sb_soft1) < 0) FAIL_STACK_ERROR - if(sb_soft1.type != H5G_LINK) TEST_ERROR - if(sb_soft1.linklen != HDstrlen("link_to_group1") + 1) TEST_ERROR + if (H5Gget_objinfo(file_id, "/group2/soft_link_to_group1", FALSE, &sb_soft1) < 0) + FAIL_STACK_ERROR + if (sb_soft1.type != H5G_LINK) + TEST_ERROR + if (sb_soft1.linklen != HDstrlen("link_to_group1") + 1) + TEST_ERROR - if(H5Gget_linkval(group2_id, "soft_link_to_group1", sb_soft1.linklen, tmpstr) < 0) FAIL_STACK_ERROR - if(HDstrcmp("link_to_group1", tmpstr)) TEST_ERROR + if (H5Gget_linkval(group2_id, "soft_link_to_group1", sb_soft1.linklen, tmpstr) < 0) + FAIL_STACK_ERROR + if (HDstrcmp("link_to_group1", tmpstr)) + TEST_ERROR /* Test non-existing links with H5Gget_objinfo */ - H5E_BEGIN_TRY { - if(H5Gget_objinfo(file_id, "/group2/soft_link_no_exist", TRUE, NULL) >= 0) FAIL_STACK_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Gget_objinfo(file_id, "/group2/soft_link_no_exist", TRUE, NULL) >= 0) + FAIL_STACK_ERROR + } + H5E_END_TRY; /* Test the dangling soft link */ - if(H5Gget_objinfo(file_id, "/group2/dangle_soft_link", FALSE, &sb_soft2) < 0) FAIL_STACK_ERROR - if(sb_soft2.type != H5G_LINK) TEST_ERROR - if(sb_soft2.linklen != HDstrlen("dangle") + 1) TEST_ERROR - - if(H5Gget_linkval(group2_id, "dangle_soft_link", sb_soft2.linklen, tmpstr) < 0) FAIL_STACK_ERROR - if(HDstrcmp("dangle", tmpstr)) TEST_ERROR + if (H5Gget_objinfo(file_id, "/group2/dangle_soft_link", FALSE, &sb_soft2) < 0) + FAIL_STACK_ERROR + if (sb_soft2.type != H5G_LINK) + TEST_ERROR + if (sb_soft2.linklen != HDstrlen("dangle") + 1) + TEST_ERROR + if (H5Gget_linkval(group2_id, "dangle_soft_link", sb_soft2.linklen, tmpstr) < 0) + FAIL_STACK_ERROR + if (HDstrcmp("dangle", tmpstr)) + TEST_ERROR /* Test H5Gmove and H5Gmove2 */ - if(H5Gmove(file_id, "group1", "moved_group1") < 0) FAIL_STACK_ERROR - if(H5Gmove2(file_id, "group2", group1_id, "moved_group2") < 0) FAIL_STACK_ERROR + if (H5Gmove(file_id, "group1", "moved_group1") < 0) + FAIL_STACK_ERROR + if (H5Gmove2(file_id, "group2", group1_id, "moved_group2") < 0) + FAIL_STACK_ERROR /* Ensure that both groups can be opened */ - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group1_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group1_id) < 0) + FAIL_STACK_ERROR - if((group1_id = H5Gopen2(file_id, "moved_group1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2_id = H5Gopen2(file_id, "moved_group1/moved_group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group1_id = H5Gopen2(file_id, "moved_group1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2_id = H5Gopen2(file_id, "moved_group1/moved_group2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close open IDs */ - if(H5Gclose(group2_id) < 0) FAIL_STACK_ERROR - if(H5Gclose(group1_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group2_id) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group1_id) < 0) + FAIL_STACK_ERROR /* Test H5Gunlink */ - if(H5Gunlink(file_id, "moved_group1/moved_group2") < 0) FAIL_STACK_ERROR + if (H5Gunlink(file_id, "moved_group1/moved_group2") < 0) + FAIL_STACK_ERROR - H5E_BEGIN_TRY { - if(H5Gopen2(file_id, "moved_group1/moved_group2", H5P_DEFAULT) >=0) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Gopen2(file_id, "moved_group1/moved_group2", H5P_DEFAULT) >= 0) + TEST_ERROR + } + H5E_END_TRY; - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group2_id); H5Gclose(group1_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_deprec() */ @@ -1759,137 +2133,161 @@ error: static int cklinks_deprec(hid_t fapl, hbool_t new_format) { - hid_t file; - H5O_info1_t oinfo1, oinfo2; - H5L_info1_t linfo; - char linkval[LINK_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; - herr_t status; + hid_t file; + H5O_info1_t oinfo1, oinfo2; + H5L_info1_t linfo; + char linkval[LINK_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; + herr_t status; - if(new_format) + if (new_format) TESTING("link queries using deprecated routines (w/new group format)") else TESTING("link queries using deprecated routines") /* Open the file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Hard link */ - if(H5Oget_info_by_name2(file, "d1", &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name2(file, "grp1/hard", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5O_TYPE_DATASET != oinfo2.type) { + if (H5Oget_info_by_name2(file, "d1", &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name2(file, "grp1/hard", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5O_TYPE_DATASET != oinfo2.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } /* end if */ - if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { + if (H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { H5_FAILED(); HDputs(" Hard link test failed. Link seems not to point to the "); HDputs(" expected file location."); TEST_ERROR } /* end if */ - if(H5Lexists(file, "/", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - if(H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - if(H5Lexists(file, "grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - if(H5Lexists(file, "/grp1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - if(H5Lexists(file, "/grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR - H5E_BEGIN_TRY { + if (H5Lexists(file, "/", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + if (H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + if (H5Lexists(file, "grp1/hard", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + if (H5Lexists(file, "/grp1", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + if (H5Lexists(file, "/grp1/hard", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { status = H5Lexists(file, "no_grp1/hard", H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" H5Lexists() should have failed for a path with missing components."); - TEST_ERROR + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); HDputs(" H5Lexists() should have failed for a path with missing components."); TEST_ERROR } /* end if */ /* Symbolic link */ - if(H5Oget_info_by_name2(file, "grp1/soft", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5O_TYPE_DATASET != oinfo2.type) { + if (H5Oget_info_by_name2(file, "grp1/soft", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5O_TYPE_DATASET != oinfo2.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } /* end if */ - if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { + if (H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { H5_FAILED(); HDputs(" Soft link test failed. Link seems not to point to the "); HDputs(" expected file location."); TEST_ERROR } /* end if */ - if(H5Lget_val(file, "grp1/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(HDstrcmp(linkval, "/d1")) { + if (H5Lget_val(file, "grp1/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(linkval, "/d1")) { H5_FAILED(); HDputs(" Soft link test failed. Wrong link value"); TEST_ERROR } /* end if */ - if(H5Lexists(file, "grp1/soft", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if (H5Lexists(file, "grp1/soft", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR /* Dangling link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Oget_info_by_name2(file, "grp1/dangle", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); HDputs(" H5Oget_info_by_name() should have failed for a dangling link."); TEST_ERROR } /* end if */ - if(H5Lget_info1(file, "grp1/dangle", &linfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5L_TYPE_SOFT != linfo.type) { + if (H5Lget_info1(file, "grp1/dangle", &linfo, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5L_TYPE_SOFT != linfo.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); TEST_ERROR } /* end if */ - if(H5Lget_val(file, "grp1/dangle", linkval, sizeof linkval, H5P_DEFAULT) < 0) { + if (H5Lget_val(file, "grp1/dangle", linkval, sizeof linkval, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf(" %d: Can't retrieve link value\n", __LINE__); TEST_ERROR } /* end if */ - if(HDstrcmp(linkval, "foobar")) { + if (HDstrcmp(linkval, "foobar")) { H5_FAILED(); HDputs(" Dangling link test failed. Wrong link value"); TEST_ERROR } /* end if */ - if(H5Lexists(file, "grp1/dangle", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if (H5Lexists(file, "grp1/dangle", H5P_DEFAULT) != TRUE) + FAIL_STACK_ERROR /* Recursive link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Oget_info_by_name2(file, "grp1/recursive", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { + } + H5E_END_TRY; + if (status >= 0) { H5_FAILED(); HDputs(" H5Oget_info_by_name() should have failed for a recursive link."); TEST_ERROR } /* end if */ - if(H5Lget_info1(file, "grp1/recursive", &linfo, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5L_TYPE_SOFT != linfo.type) { + if (H5Lget_info1(file, "grp1/recursive", &linfo, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5L_TYPE_SOFT != linfo.type) { H5_FAILED(); HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); TEST_ERROR } /* end if */ - if(H5Lget_val(file, "grp1/recursive", linkval, sizeof linkval, H5P_DEFAULT) < 0) { + if (H5Lget_val(file, "grp1/recursive", linkval, sizeof linkval, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf(" %d: Can't retrieve link value\n", __LINE__); TEST_ERROR } /* end if */ - if(HDstrcmp(linkval, "/grp1/recursive")) { + if (HDstrcmp(linkval, "/grp1/recursive")) { H5_FAILED(); HDputs(" Recursive link test failed. Wrong link value"); TEST_ERROR } /* end if */ /* Non-existent link */ - if(H5Lexists(file, "foobar", H5P_DEFAULT) == TRUE) FAIL_STACK_ERROR + if (H5Lexists(file, "foobar", H5P_DEFAULT) == TRUE) + FAIL_STACK_ERROR /* Cleanup */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; @@ -1910,17 +2308,17 @@ error: static int test_lcpl_deprec(hid_t fapl, hbool_t new_format) { - hid_t file_id = -1; - hid_t group_id = -1; - hid_t space_id = -1; - hid_t dset_id = -1; - hid_t type_id = -1; - hid_t lcpl_id = -1; - H5L_info1_t linfo; - char filename[1024]; - hsize_t dims[2]; - - if(new_format) + hid_t file_id = -1; + hid_t group_id = -1; + hid_t space_id = -1; + hid_t dset_id = -1; + hid_t type_id = -1; + hid_t lcpl_id = -1; + H5L_info1_t linfo; + char filename[1024]; + hsize_t dims[2]; + + if (new_format) TESTING("link creation property lists using deprecated routines (w/new group format)") else TESTING("link creation property lists using deprecated routines") @@ -1931,123 +2329,183 @@ test_lcpl_deprec(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create and link a group with the default LCPL */ - if((group_id = H5Gcreate2(file_id, "/group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, "/group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Check that its character encoding is the default */ - if(H5Lget_info1(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5F_DEFAULT_CSET) TEST_ERROR + if (H5Lget_info1(file_id, "group", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5F_DEFAULT_CSET) + TEST_ERROR /* Create and commit a datatype with the default LCPL */ - if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(file_id, "/type", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(type_id) < 0) TEST_ERROR + if ((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(file_id, "/type", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(type_id) < 0) + TEST_ERROR /* Check that its character encoding is the default */ - if(H5Lget_info1(file_id, "type", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5F_DEFAULT_CSET) TEST_ERROR + if (H5Lget_info1(file_id, "type", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5F_DEFAULT_CSET) + TEST_ERROR /* Create a dataspace */ dims[0] = H5L_DIM1; dims[1] = H5L_DIM2; - if((space_id=H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR /* Create a dataset using the default LCPL */ - if((dset_id = H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(dset_id) < 0) TEST_ERROR - + if ((dset_id = + H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(dset_id) < 0) + TEST_ERROR + /* Check that its character encoding is the default */ - if(H5Lget_info1(file_id, "dataset", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5F_DEFAULT_CSET) TEST_ERROR + if (H5Lget_info1(file_id, "dataset", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5F_DEFAULT_CSET) + TEST_ERROR /* Create a link creation property list with the UTF-8 character encoding */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) + TEST_ERROR /* Create and link a group with the new LCPL */ - if((group_id = H5Gcreate2(file_id, "/group2", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, "/group2", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(H5Lget_info1(file_id, "group2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info1(file_id, "group2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Create and commit a datatype with the new LCPL */ - if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(file_id, "/type2", type_id, lcpl_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(type_id) < 0) TEST_ERROR + if ((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(file_id, "/type2", type_id, lcpl_id, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(type_id) < 0) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(H5Lget_info1(file_id, "type2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info1(file_id, "type2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Create a dataset using the new LCPL */ - if((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(dset_id) < 0) TEST_ERROR + if ((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, dcpl_g, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Dclose(dset_id) < 0) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(H5Lget_info1(file_id, "dataset2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info1(file_id, "dataset2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Create a new link to the dataset with a different character encoding. */ - if(H5Pclose(lcpl_id) < 0) TEST_ERROR - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) + TEST_ERROR - if(H5Lcreate_hard(file_id, "/dataset2", file_id, "/dataset2_link", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(file_id, "/dataset2", file_id, "/dataset2_link", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Check that its character encoding is ASCII */ - if(H5Lget_info1(file_id, "/dataset2_link", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_ASCII) TEST_ERROR + if (H5Lget_info1(file_id, "/dataset2_link", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_ASCII) + TEST_ERROR /* Check that the first link's encoding hasn't changed */ - if(H5Lget_info1(file_id, "/dataset2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info1(file_id, "/dataset2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Make sure that LCPLs work properly for other API calls: */ /* H5Lcreate_soft */ - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR - if(H5Lcreate_soft("dataset2", file_id, "slink_to_dset2", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info1(file_id, "slink_to_dset2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) + TEST_ERROR + if (H5Lcreate_soft("dataset2", file_id, "slink_to_dset2", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info1(file_id, "slink_to_dset2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* H5Lmove */ - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) TEST_ERROR - if(H5Lmove(file_id, "slink_to_dset2", file_id, "moved_slink", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info1(file_id, "moved_slink", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_ASCII) TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) + TEST_ERROR + if (H5Lmove(file_id, "slink_to_dset2", file_id, "moved_slink", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info1(file_id, "moved_slink", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_ASCII) + TEST_ERROR /* H5Lcopy */ - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR - if(H5Lcopy(file_id, "moved_slink", file_id, "copied_slink", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info1(file_id, "copied_slink", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) + TEST_ERROR + if (H5Lcopy(file_id, "moved_slink", file_id, "copied_slink", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info1(file_id, "copied_slink", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* H5Lcreate_external */ - if(H5Lcreate_external("filename", "path", file_id, "extlink", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info1(file_id, "extlink", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lcreate_external("filename", "path", file_id, "extlink", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info1(file_id, "extlink", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Close open IDs */ - if(H5Pclose(lcpl_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Dclose(dset_id); H5Tclose(type_id); H5Pclose(lcpl_id); H5Sclose(space_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_lcpl_deprec() */ @@ -2064,158 +2522,231 @@ error: static int test_move_preserves_deprec(hid_t fapl_id, hbool_t new_format) { - hid_t file_id=-1; - hid_t group_id=-1; - hid_t fcpl_id=-1; /* Group creation property list ID */ - hid_t lcpl_id=-1; - hid_t lcpl2_id=-1; + hid_t file_id = -1; + hid_t group_id = -1; + hid_t fcpl_id = -1; /* Group creation property list ID */ + hid_t lcpl_id = -1; + hid_t lcpl2_id = -1; H5O_info1_t oinfo; H5L_info1_t linfo; - H5T_cset_t old_cset; - int64_t old_corder; /* Creation order value of link */ - time_t old_modification_time; - time_t curr_time; - unsigned crt_order_flags; /* Status of creation order info for GCPL */ - char filename[1024]; - - if(new_format) - TESTING("moving and copying links using deprecated routines preserves their properties (w/new group format)") + H5T_cset_t old_cset; + int64_t old_corder; /* Creation order value of link */ + time_t old_modification_time; + time_t curr_time; + unsigned crt_order_flags; /* Status of creation order info for GCPL */ + char filename[1024]; + + if (new_format) + TESTING("moving and copying links using deprecated routines preserves their properties (w/new group " + "format)") else TESTING("moving and copying links using deprecated routines preserves their properties") /* Create a file creation property list with creation order stored for links * in the root group */ - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR - if(H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) TEST_ERROR - if(crt_order_flags != 0) TEST_ERROR - if(H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED) < 0) TEST_ERROR - if(H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) TEST_ERROR - if(crt_order_flags != H5P_CRT_ORDER_TRACKED) TEST_ERROR + if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + if (H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) + TEST_ERROR + if (crt_order_flags != 0) + TEST_ERROR + if (H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + TEST_ERROR + if (H5Pget_link_creation_order(fcpl_id, &crt_order_flags) < 0) + TEST_ERROR + if (crt_order_flags != H5P_CRT_ORDER_TRACKED) + TEST_ERROR /* Create file */ /* (with creation order tracking for the root group) */ h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) + TEST_ERROR /* Create a link creation property list with the UTF-8 character encoding */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) + TEST_ERROR /* Create a group with that lcpl */ - if((group_id = H5Gcreate2(file_id, "group", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, "group", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Get the group's link's information */ - if(H5Lget_info1(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info1(file_id, "group", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR old_cset = linfo.cset; - if(old_cset != H5T_CSET_UTF8) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR + if (old_cset != H5T_CSET_UTF8) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR old_corder = linfo.corder; - if(old_corder != 0) TEST_ERROR + if (old_corder != 0) + TEST_ERROR old_modification_time = oinfo.mtime; /* If this test happens too quickly, the times will all be the same. Make sure the time changes. */ curr_time = HDtime(NULL); - while(HDtime(NULL) <= curr_time) + while (HDtime(NULL) <= curr_time) ; /* Close the file and reopen it */ - if(H5Fclose(file_id) < 0) TEST_ERROR - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + TEST_ERROR /* Get the link's character set & modification time . They should be unchanged */ - if(H5Lget_info1(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(old_cset != linfo.cset) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(old_corder != linfo.corder) TEST_ERROR - - /* Create a new link to the group. It should have a different creation order value but the same modification time */ - if(H5Lcreate_hard(file_id, "group", file_id, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(file_id, "group2", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info1(file_id, "group2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(old_corder == linfo.corder) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 1) TEST_ERROR - if(linfo.cset != H5T_CSET_ASCII) TEST_ERROR + if (H5Lget_info1(file_id, "group", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (old_cset != linfo.cset) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (old_corder != linfo.corder) + TEST_ERROR + + /* Create a new link to the group. It should have a different creation order value but the same + * modification time */ + if (H5Lcreate_hard(file_id, "group", file_id, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(file_id, "group2", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info1(file_id, "group2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_corder == linfo.corder) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 1) + TEST_ERROR + if (linfo.cset != H5T_CSET_ASCII) + TEST_ERROR /* Copy the first link to a UTF-8 name. * Its creation order value should be different, but modification time * should not change. */ - if(H5Lcopy(file_id, "group", file_id, "group_copied", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(file_id, "group_copied", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info1(file_id, "group_copied", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 2) TEST_ERROR + if (H5Lcopy(file_id, "group", file_id, "group_copied", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(file_id, "group_copied", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info1(file_id, "group_copied", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 2) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Move the link with the default property list. */ - if(H5Lmove(file_id, "group_copied", file_id, "group_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(file_id, "group_copied2", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info1(file_id, "group_copied2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 3) TEST_ERROR + if (H5Lmove(file_id, "group_copied", file_id, "group_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(file_id, "group_copied2", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info1(file_id, "group_copied2", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 3) + TEST_ERROR /* Check that its character encoding is not UTF-8 */ - if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR + if (linfo.cset == H5T_CSET_UTF8) + TEST_ERROR /* Check that the original link is unchanged */ - if(H5Oget_info_by_name2(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info1(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(old_corder != linfo.corder) TEST_ERROR - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Oget_info_by_name2(file_id, "group", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info1(file_id, "group", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (old_corder != linfo.corder) + TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Move the first link to a UTF-8 name. * Its creation order value will change, but modification time should not * change. */ - if(H5Lmove(file_id, "group", file_id, "group_moved", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(file_id, "group_moved", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info1(file_id, "group_moved", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 4) TEST_ERROR + if (H5Lmove(file_id, "group", file_id, "group_moved", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(file_id, "group_moved", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info1(file_id, "group_moved", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 4) + TEST_ERROR /* Check that its character encoding is UTF-8 */ - if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR + if (linfo.cset != H5T_CSET_UTF8) + TEST_ERROR /* Move the link again using the default property list. */ - if(H5Lmove(file_id, "group_moved", file_id, "group_moved_again", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(file_id, "group_moved_again", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR - if(old_modification_time != oinfo.mtime) TEST_ERROR - if(H5Lget_info1(file_id, "group_moved_again", &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != 5) TEST_ERROR + if (H5Lmove(file_id, "group_moved", file_id, "group_moved_again", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(file_id, "group_moved_again", &oinfo, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR + if (old_modification_time != oinfo.mtime) + TEST_ERROR + if (H5Lget_info1(file_id, "group_moved_again", &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != 5) + TEST_ERROR /* Check that its character encoding is not UTF-8 */ - if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR + if (linfo.cset == H5T_CSET_UTF8) + TEST_ERROR /* Close open IDs */ - if(H5Pclose(fcpl_id) < 0) TEST_ERROR - if(H5Pclose(lcpl_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Pclose(fcpl_id) < 0) + TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl_id); H5Pclose(lcpl_id); H5Pclose(lcpl2_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_move_preserves_deprec() */ @@ -2231,16 +2762,16 @@ error: static int external_link_root_deprec(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5L_info1_t linfo; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; - const char *file; /* File from external link */ - const char *path; /* Path from external link */ - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info1_t linfo; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + const char *file; /* File from external link */ + const char *path; /* Path from external link */ + + if (new_format) TESTING("external link to root using deprecated routines (w/new group format)") else TESTING("external link to root using deprecated routines") @@ -2250,35 +2781,43 @@ external_link_root_deprec(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create file to point to */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Check that external links are registered with the library */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR /* Create file with link to first file */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to object in first file */ - if(H5Lcreate_external(filename1, "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Check information for external link */ - if(H5Lget_info1(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; - if(H5L_TYPE_EXTERNAL != linfo.type) { + if (H5Lget_info1(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) + goto error; + if (H5L_TYPE_EXTERNAL != linfo.type) { H5_FAILED(); HDputs(" Unexpected object type - should have been an external link"); goto error; } - if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR - if(HDstrcmp(file, filename1)) { + if (H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) + TEST_ERROR + if (HDstrcmp(file, filename1)) { H5_FAILED(); HDputs(" External link file name incorrect"); goto error; } - if(HDstrcmp(path, "/")) { + if (HDstrcmp(path, "/")) { H5_FAILED(); HDputs(" External link path incorrect"); goto error; @@ -2286,111 +2825,146 @@ external_link_root_deprec(hid_t fapl, hbool_t new_format) /* Create external link to object in first file */ /* (add a few extra '/'s to make certain library normalizes external link object names) */ - if(H5Lcreate_external(filename1, "///", fid, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "///", fid, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Check information for external link */ - if(H5Lget_info1(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; - if(H5L_TYPE_EXTERNAL != linfo.type) { + if (H5Lget_info1(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) + goto error; + if (H5L_TYPE_EXTERNAL != linfo.type) { H5_FAILED(); HDputs(" Unexpected object type - should have been an external link"); goto error; } - if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR - if(HDstrcmp(file, filename1)) { + if (H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) + TEST_ERROR + if (HDstrcmp(file, filename1)) { H5_FAILED(); HDputs(" External link file name incorrect"); goto error; } - if(HDstrcmp(path, "/")) { + if (HDstrcmp(path, "/")) { H5_FAILED(); HDputs(" External link path incorrect"); goto error; } /* Close and re-open file to ensure that data is written to disk */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((fid = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close external object (lets first file close) */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create a new object using H5Gcreate2 through the external link * directly */ - if((gid = H5Gcreate2(fid, "ext_link/newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "ext_link/newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close file and group */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); /* Open first file again with read-only access and check on objects created */ - if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open objects created through external link */ - if((gid = H5Gopen2(fid, "new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gid2 = H5Gopen2(fid, "newer_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((gid2 = H5Gopen2(fid, "newer_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check names */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/new_group")) TEST_ERROR - if(H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/newer_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/new_group")) + TEST_ERROR + if (H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/newer_group")) + TEST_ERROR /* Close opened objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); /* Verify that new objects can't be created through a read-only external * link. */ - if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gcreate2(fid, "ext_link/readonly_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY - if(gid >= 0) TEST_ERROR + } + H5E_END_TRY + if (gid >= 0) + TEST_ERROR /* Close second file again */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_root_deprec() */ @@ -2407,17 +2981,16 @@ error: static int external_link_query_deprec(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - const char *file_name; /* Name of the file the external link points to */ - const char *object_name; /* Name of the object the external link points to */ - H5O_info1_t oi; /* Object information */ - H5L_info1_t li; /* Link information */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ - query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + const char *file_name; /* Name of the file the external link points to */ + const char *object_name; /* Name of the object the external link points to */ + H5O_info1_t oi; /* Object information */ + H5L_info1_t li; /* Link information */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ + query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ + + if (new_format) TESTING("query aspects of external link using deprecated routines (w/new group format)") else TESTING("query aspects of external link using deprecated routines") @@ -2427,15 +3000,19 @@ external_link_query_deprec(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file, with external link to object in second file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link */ /* (add a few extra '/'s to make certain library normalizes external link object names) */ - if(H5Lcreate_external(filename2, "///dst//", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "///dst//", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Get size of buffer for external link */ - if(H5Lget_info1(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR + if (H5Lget_info1(fid, "src", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) + TEST_ERROR if (H5L_TYPE_EXTERNAL != li.type) { H5_FAILED(); HDputs(" Unexpected link class - should have been an external link"); @@ -2443,76 +3020,105 @@ external_link_query_deprec(hid_t fapl, hbool_t new_format) } /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file to point to */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create object to link to */ - if((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Get size of buffer for external link */ - if(H5Lget_info1(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR - if(H5L_TYPE_EXTERNAL != li.type) { + if (H5Lget_info1(fid, "src", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) + TEST_ERROR + if (H5L_TYPE_EXTERNAL != li.type) { H5_FAILED(); HDputs(" Unexpected link class - should have been an external link"); goto error; } /* Get information for external link. It should be two strings right after each other */ - if(H5Lget_val(fid, "src", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_val(fid, "src", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR /* Extract the file and object names from the buffer */ - if(H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, &file_name, &object_name) < 0) TEST_ERROR + if (H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, &file_name, &object_name) < 0) + TEST_ERROR /* Compare the file and object names */ - if(HDstrcmp(file_name, filename2)) TEST_ERROR - if(HDstrcmp(object_name, "/dst")) TEST_ERROR + if (HDstrcmp(file_name, filename2)) + TEST_ERROR + if (HDstrcmp(object_name, "/dst")) + TEST_ERROR /* Query information about object that external link points to */ - if(H5Oget_info_by_name2(fid, "src", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5O_TYPE_GROUP != oi.type) { + if (H5Oget_info_by_name2(fid, "src", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5O_TYPE_GROUP != oi.type) { H5_FAILED(); HDputs(" Unexpected object type - should have been a group"); goto error; } /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Make sure that passing in NULLs to H5Lunpack_elink_val works */ - if(H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, NULL, NULL) < 0) TEST_ERROR + if (H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, NULL, NULL) < 0) + TEST_ERROR /* Make sure that bogus cases trigger errors in H5Lunpack_elink_val */ - H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) TEST_ERROR - } H5E_END_TRY - H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR - } H5E_END_TRY - H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR - } H5E_END_TRY - H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) TEST_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) + TEST_ERROR + } + H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) + TEST_ERROR + } + H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) + TEST_ERROR + } + H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) + TEST_ERROR + } + H5E_END_TRY PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_query_deprec() */ @@ -2529,20 +3135,18 @@ error: static int external_link_closing_deprec(hid_t fapl, hbool_t new_format) { - hid_t fid1 = (-1), fid2 = (-1), fid3 = (-1), fid4=(-1); - hid_t gid=(-1), tid=(-1), tid2=(-1), sid=(-1), did=(-1); - hid_t lcpl_id=(-1); - hsize_t dims[2]; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ - buf[NAME_BUF_SIZE]; /* misc. buffer */ + hid_t fid1 = (-1), fid2 = (-1), fid3 = (-1), fid4 = (-1); + hid_t gid = (-1), tid = (-1), tid2 = (-1), sid = (-1), did = (-1); + hid_t lcpl_id = (-1); + hsize_t dims[2]; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ + buf[NAME_BUF_SIZE]; /* misc. buffer */ H5L_info1_t li; H5O_info1_t oi; hobj_ref_t obj_ref; - if(new_format) + if (new_format) TESTING("that external files are closed during traversal (w/new group format)") else TESTING("that external files are closed during traversal") @@ -2562,175 +3166,263 @@ external_link_closing_deprec(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[6], fapl, filename4, sizeof filename4); /* Create four files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create a dataspace and a datatype so we can create/commit a dataset/datatype in the files */ dims[0] = 2; dims[1] = 2; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if ((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* Create external links from each file to the next */ - if(H5Lcreate_external(filename2, "/", fid1, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename4, "/", fid3, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename3, "/", fid2, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename4, "/", fid3, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close all files but the first */ - if(H5Fclose(fid4) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid4) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Test creating each kind of object */ - if((gid = H5Gcreate2(fid1, "elink/elink/elink/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Tcommit2(fid1, "elink/elink/elink/type1", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid1, "elink/elink/elink/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Tcommit2(fid1, "elink/elink/elink/type1", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if ((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Test that getting info works */ - if(H5Lget_info1(fid1, "elink/elink/elink/type1", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info1(fid1, "elink/elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(fid1, "elink/elink/elink/type1", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name2(fid1, "elink/elink/elink", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info1(fid1, "elink/elink/elink/type1", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info1(fid1, "elink/elink/elink", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(fid1, "elink/elink/elink/type1", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(fid1, "elink/elink/elink", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR /* Test move */ - if(H5Lmove(fid1, "elink/elink/elink/group1", fid1, - "elink/elink/elink/group1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lmove(fid1, "elink/elink/elink/group1", fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR /* Open file 4 so we can do some fancy things */ - if((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if(H5Lmove(fid1, "elink/elink/elink/type1", fid4, - "type1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lmove(fid4, "dataset1", fid1, - "elink/elink/elink/dataset1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Lmove(fid1, "elink/elink/elink/type1", fid4, "type1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lmove(fid4, "dataset1", fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file 4 again */ - if(H5Fclose(fid4) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid4) < 0) + FAIL_STACK_ERROR /* Test copy (as of this test, it uses the same code as move) */ - if(H5Lcopy(fid1, "elink/elink/elink", fid1, - "elink/elink/elink_copied", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcopy(fid1, "elink/elink/elink", fid1, - "elink/elink/elink/elink_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcopy(fid1, "elink/elink/elink", fid1, "elink/elink/elink_copied", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcopy(fid1, "elink/elink/elink", fid1, "elink/elink/elink/elink_copied2", H5P_DEFAULT, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Test H5Gset and get comment */ - if(H5Oset_comment_by_name(fid1, "elink/elink/elink/group1_moved", "comment", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_comment_by_name(fid1, "elink/elink/elink/group1_moved", buf, sizeof(buf), H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(HDstrcmp(buf, "comment")) TEST_ERROR + if (H5Oset_comment_by_name(fid1, "elink/elink/elink/group1_moved", "comment", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_comment_by_name(fid1, "elink/elink/elink/group1_moved", buf, sizeof(buf), H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(buf, "comment")) + TEST_ERROR /* Test H5*open */ - if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(tid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Test H5*open2 */ - if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(tid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Test H5Oopen */ - if((did = H5Oopen(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Oopen(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Test H5Fmount */ - if((gid = H5Gcreate2(fid1, "elink/elink/elink/mnt", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - H5E_BEGIN_TRY { - if(H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT) >= 0) TEST_ERROR - if(H5Funmount(fid1, "elink/elink/elink/mnt") >= 0) TEST_ERROR - } H5E_END_TRY + if ((gid = H5Gcreate2(fid1, "elink/elink/elink/mnt", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + H5E_BEGIN_TRY + { + if (H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT) >= 0) + TEST_ERROR + if (H5Funmount(fid1, "elink/elink/elink/mnt") >= 0) + TEST_ERROR + } + H5E_END_TRY /* Test H5Rcreate */ - if(H5Rcreate(&obj_ref, fid1, "elink/elink/elink/type1_moved", H5R_OBJECT, (hid_t)(-1)) < 0) TEST_ERROR + if (H5Rcreate(&obj_ref, fid1, "elink/elink/elink/type1_moved", H5R_OBJECT, (hid_t)(-1)) < 0) + TEST_ERROR /* Test unlink */ - if(H5Ldelete(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(fid1, "elink/elink/elink_copied", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(fid1, "elink/elink/elink/elink_copied2", H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink_copied", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink/elink_copied2", H5P_DEFAULT) < 0) + TEST_ERROR /* We've tested that the various functions above don't leave files open. - * Now test that we can't confuse HDF5 by giving unusual paths with external links - */ + * Now test that we can't confuse HDF5 by giving unusual paths with external links + */ /* Create an external link that points to another external link */ - if((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if(H5Lcreate_external(filename3, "/elink", fid2, "elink2", - H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + if (H5Lcreate_external(filename3, "/elink", fid2, "elink2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Do an external link traversal that recursively calls another external link. */ - if((gid = H5Gcreate2(fid1, "elink/elink2/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid1, "elink/elink2/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create two more groups so that the last three elements in the path are - * all within the same external file - */ - if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3/group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Oget_info_by_name2(fid1, "elink/elink2/group2/group3/group4", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + * all within the same external file + */ + if ((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3/group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Oget_info_by_name2(fid1, "elink/elink2/group2/group3/group4", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR /* Add a few regular groups and a soft link in file2 using intermediate group creation */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR - if(H5Lcreate_soft("/elink2", fid1, "elink/file2group1/file2group2/slink", - lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) + TEST_ERROR + if (H5Lcreate_soft("/elink2", fid1, "elink/file2group1/file2group2/slink", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Try to traverse this path. There are three soft traversals in a row; * slink points to (file2)/elink2, which points to (file3)/elink, which * points to file 4. */ - if((gid = H5Gcreate2(fid1, "elink/file2group1/file2group2/slink/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Lget_info1(fid1, "elink/file2group1/file2group2/slink/group3", &li, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid1, "elink/file2group1/file2group2/slink/group3", H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Lget_info1(fid1, "elink/file2group1/file2group2/slink/group3", &li, H5P_DEFAULT) < 0) + TEST_ERROR /* Some simpler tests */ - if((gid = H5Gcreate2(fid1, "elink/file2group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Lget_info1(fid1, "elink/file2group3", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info1(fid1, "elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR - + if ((gid = H5Gcreate2(fid1, "elink/file2group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Lget_info1(fid1, "elink/file2group3", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info1(fid1, "elink/elink", &li, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file1, the only file that should still be open */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Re-create each file. If they are hanging open, these creates will fail */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Cleanup */ - if(H5Sclose(sid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) TEST_ERROR - if(H5Fclose(fid4) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR + if (H5Fclose(fid4) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Tclose(tid); H5Dclose(did); @@ -2740,21 +3432,22 @@ error: H5Fclose(fid3); H5Fclose(fid2); H5Fclose(fid1); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* external_link_closing_deprec() */ /* Callback functions for UD hard links. */ /* UD_hard_create increments the object's reference count */ static herr_t -UD_hard_create_deprec(const char H5_ATTR_UNUSED * link_name, hid_t loc_group, const void *udata, - size_t udata_size, hid_t H5_ATTR_UNUSED lcpl_id) +UD_hard_create_deprec(const char H5_ATTR_UNUSED *link_name, hid_t loc_group, const void *udata, + size_t udata_size, hid_t H5_ATTR_UNUSED lcpl_id) { haddr_t addr; - hid_t target_obj = -1; - herr_t ret_value = 0; + hid_t target_obj = -1; + herr_t ret_value = 0; - if(udata_size != sizeof(haddr_t)) { + if (udata_size != sizeof(haddr_t)) { ret_value = -1; goto done; } /* end if */ @@ -2762,34 +3455,34 @@ UD_hard_create_deprec(const char H5_ATTR_UNUSED * link_name, hid_t loc_group, co addr = *((const haddr_t *)udata); /* Open the object this link points to */ - target_obj= H5Oopen_by_addr(loc_group, addr); - if(target_obj < 0) { + target_obj = H5Oopen_by_addr(loc_group, addr); + if (target_obj < 0) { ret_value = -1; goto done; } /* end if */ /* Increment the reference count of the target object */ - if(H5Oincr_refcount(target_obj) < 0) { + if (H5Oincr_refcount(target_obj) < 0) { ret_value = -1; goto done; } /* end if */ done: /* Close the target object if we opened it */ - if(target_obj >= 0) { - switch(H5Iget_type(target_obj)) { + if (target_obj >= 0) { + switch (H5Iget_type(target_obj)) { case H5I_GROUP: - if(H5Gclose(target_obj) < 0) + if (H5Gclose(target_obj) < 0) ret_value = -1; break; case H5I_DATASET: - if(H5Dclose(target_obj) < 0) + if (H5Dclose(target_obj) < 0) ret_value = -1; break; case H5I_DATATYPE: - if(H5Tclose(target_obj) < 0) + if (H5Tclose(target_obj) < 0) ret_value = -1; break; @@ -2811,26 +3504,25 @@ done: case H5I_SPACE_SEL_ITER: case H5I_NTYPES: default: - return FAIL; + return FAIL; } /* end switch */ - } /* end if */ + } /* end if */ return ret_value; } /* end UD_hard_create() */ /* Traverse a hard link by opening the object */ static hid_t -UD_hard_traverse_deprec(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t H5_ATTR_UNUSED lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id) +UD_hard_traverse_deprec(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const void *udata, + size_t udata_size, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id) { haddr_t addr; - hid_t ret_value = -1; + hid_t ret_value = -1; - if(udata_size != sizeof(haddr_t)) + if (udata_size != sizeof(haddr_t)) return FAIL; - addr = *((const haddr_t *) udata); + addr = *((const haddr_t *)udata); ret_value = H5Oopen_by_addr(cur_group, addr); /* If this fails, our return value will be negative. */ @@ -2839,49 +3531,48 @@ UD_hard_traverse_deprec(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, /* UD_hard_delete decrements the object's reference count */ static herr_t -UD_hard_delete_deprec(const char H5_ATTR_UNUSED * link_name, hid_t file, const void *udata, - size_t udata_size) +UD_hard_delete_deprec(const char H5_ATTR_UNUSED *link_name, hid_t file, const void *udata, size_t udata_size) { haddr_t addr; - hid_t target_obj = -1; - herr_t ret_value = 0; + hid_t target_obj = -1; + herr_t ret_value = 0; - if(udata_size != sizeof(haddr_t)) { + if (udata_size != sizeof(haddr_t)) { ret_value = -1; goto done; } /* end if */ - addr = *((const haddr_t *) udata); + addr = *((const haddr_t *)udata); /* Open the object this link points to */ - target_obj= H5Oopen_by_addr(file, addr); - if(target_obj < 0) { + target_obj = H5Oopen_by_addr(file, addr); + if (target_obj < 0) { ret_value = -1; goto done; } /* end if */ /* Decrement the reference count of the target object */ - if(H5Odecr_refcount(target_obj) < 0) { + if (H5Odecr_refcount(target_obj) < 0) { ret_value = -1; goto done; } /* end if */ done: /* Close the target object if we opened it */ - if(target_obj >= 0) { - switch(H5Iget_type(target_obj)) { + if (target_obj >= 0) { + switch (H5Iget_type(target_obj)) { case H5I_GROUP: - if(H5Gclose(target_obj) < 0) + if (H5Gclose(target_obj) < 0) ret_value = -1; break; case H5I_DATASET: - if(H5Dclose(target_obj) < 0) + if (H5Dclose(target_obj) < 0) ret_value = -1; break; case H5I_DATATYPE: - if(H5Tclose(target_obj) < 0) + if (H5Tclose(target_obj) < 0) ret_value = -1; break; @@ -2905,7 +3596,7 @@ done: default: return FAIL; } /* end switch */ - } /* end if */ + } /* end if */ return ret_value; } /* end UD_hard_delete() */ @@ -2913,11 +3604,11 @@ done: static int ud_hard_links_deprec(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5L_info1_t li; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ - h5_stat_size_t empty_size; /* Size of an empty file */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info1_t li; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ + h5_stat_size_t empty_size; /* Size of an empty file */ char filename[NAME_BUF_SIZE]; TESTING("user-defined hard link using deprecated routines (w/new group format)") @@ -2925,70 +3616,98 @@ ud_hard_links_deprec(hid_t fapl) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Get the size of the empty file for reference */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((empty_size = h5_get_file_size(filename, fapl))<0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Check that external links are registered and UD hard links are not */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + TEST_ERROR /* Register "user-defined hard links" with the library */ - if(H5Lregister(UD_hard_class_deprec) < 0) TEST_ERROR + if (H5Lregister(UD_hard_class_deprec) < 0) + TEST_ERROR /* Check that UD hard links are now registered */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + TEST_ERROR /* Create a group for the UD hard link to point to */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Get address for the group to give to the hard link */ - if(H5Lget_info1(fid, "group", &li, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info1(fid, "group", &li, H5P_DEFAULT) < 0) + TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create a user-defined "hard link" to the group using the address we got * from H5Lget_info1 */ - if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), (size_t)sizeof(haddr_t), H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), (size_t)sizeof(haddr_t), + H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close and re-open file to ensure that data is written to disk */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open group through UD link */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/group")) + TEST_ERROR /* Create object in group */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close groups*/ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Re-open group without using ud link to check that it was created properly */ - if((gid = H5Gopen2(fid, "group/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "group/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/group/new_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/group/new_group")) + TEST_ERROR /* Close opened object */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Check that H5Lget_objinfo works on the hard link */ - if(H5Lget_info1(fid, "ud_link", &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lget_info1(fid, "ud_link", &li, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* UD hard links have no query function, thus return a "link length" of 0 */ - if(li.u.val_size != 0) TEST_ERROR - if(UD_HARD_TYPE != li.type) { + if (li.u.val_size != 0) + TEST_ERROR + if (UD_HARD_TYPE != li.type) { H5_FAILED(); HDputs(" Unexpected link class - should have been a UD hard link"); goto error; @@ -2996,190 +3715,245 @@ ud_hard_links_deprec(hid_t fapl) /* Unlink the group pointed to by the UD link. It shouldn't be * deleted because of the UD link. */ - if(H5Ldelete(fid, "/group", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "/group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Ensure we can open the group through the UD link */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Unlink the group contained within it. */ - if(H5Ldelete(gid, "new_group", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, "new_group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Now delete the UD link. This should cause the group to be * deleted, too. */ - if(H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* The file should be empty again. */ - if(empty_size != h5_get_file_size(filename, fapl)) TEST_ERROR + if (empty_size != h5_get_file_size(filename, fapl)) + TEST_ERROR - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end ud_hard_links_deprec() */ static int ud_link_reregister_deprec(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5L_info1_t li; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; - h5_stat_size_t empty_size; /* Size of an empty file */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info1_t li; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; + h5_stat_size_t empty_size; /* Size of an empty file */ TESTING("registering a new class for existing UD links using deprecated routines (w/new group format)") /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Get the size of the empty file for reference */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((empty_size = h5_get_file_size(filename, fapl))<0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Check that UD hard links are not registered */ - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + TEST_ERROR /* Register "user-defined hard links" with the library */ - if(H5Lregister(UD_hard_class_deprec) < 0) TEST_ERROR + if (H5Lregister(UD_hard_class_deprec) < 0) + TEST_ERROR /* Check that UD hard links are registered */ - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + TEST_ERROR /* Point a UD defined hard link to a group in the same way as the previous test */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lget_info1(fid, "group", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lget_info1(fid, "group", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), - sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), sizeof(li.u.address), + H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create a group named REREG_TARGET_NAME in the same group as the ud link */ - if((gid = H5Gcreate2(fid, REREG_TARGET_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, REREG_TARGET_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Now unregister UD hard links */ - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) TEST_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + TEST_ERROR /* Check that UD hard links are no longer registered */ - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + TEST_ERROR /* Verify that we can't traverse the ud link anymore */ - H5E_BEGIN_TRY { - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) >= 0) TEST_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) >= 0) + TEST_ERROR + } + H5E_END_TRY /* Verify that we can't create any new links of this type */ - H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), - sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT) >= 0) + H5E_BEGIN_TRY + { + if (H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), sizeof(li.u.address), + H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR - } H5E_END_TRY + } + H5E_END_TRY /* Register a new kind of link with the same ID number */ - if(H5Lregister(UD_rereg_class) < 0) TEST_ERROR + if (H5Lregister(UD_rereg_class) < 0) + TEST_ERROR /* Check that UD hard links are registered again */ - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + TEST_ERROR /* Open a group through the ud link (now a different class of link). * It should be a different group * than the UD hard link pointed to */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/" REREG_TARGET_NAME)) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/" REREG_TARGET_NAME)) + TEST_ERROR /* Create object in group */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close groups*/ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Re-open group without using ud link to check that it was created properly */ - if((gid = H5Gopen2(fid, "rereg_target/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "rereg_target/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/rereg_target/new_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/rereg_target/new_group")) + TEST_ERROR /* Close opened object */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Unlink the group pointed to by the UD hard link. It shouldn't be * deleted because the UD link incremented its reference count. */ - if(H5Ldelete(fid, "/group", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "/group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* What a mess! Re-register user-defined links to clean up the * reference counts. We shouldn't actually need to unregister the * other link type */ - if(H5Lregister(UD_hard_class_deprec) < 0) FAIL_STACK_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) FAIL_STACK_ERROR + if (H5Lregister(UD_hard_class_deprec) < 0) + FAIL_STACK_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + FAIL_STACK_ERROR /* Ensure we can open the group through the UD link (now that UD hard * links have been registered) */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Delete the UD hard link. This should cause the group to be * deleted, too. */ - if(H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Unlink the other two groups so that we can make sure the file is empty */ - if(H5Ldelete(fid, "/rereg_target/new_group", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, REREG_TARGET_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "/rereg_target/new_group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, REREG_TARGET_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* The file should be empty again. */ - if(empty_size != h5_get_file_size(filename, fapl)) TEST_ERROR + if (empty_size != h5_get_file_size(filename, fapl)) + TEST_ERROR - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) FAIL_STACK_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + FAIL_STACK_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end ud_link_reregister_deprec() */ static int ud_callbacks_deprec(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ hid_t lcpl = -1; /* Link Creation PL */ H5L_info1_t li; /* Link information */ char ud_target_name[] = UD_CB_TARGET; /* Link target name */ char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("user-defined link callbacks using deprecated routines (w/new group format)") else TESTING("user-defined link callbacks using deprecated routines") @@ -3187,40 +3961,57 @@ ud_callbacks_deprec(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Check that registered link classes are, and unregistered ones aren't */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_CB_TYPE) != FALSE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_CB_TYPE) != FALSE) + TEST_ERROR /* Hit two birds with one stone: register UD hard links from previous * test to check that having two UD links registered at once presents * no problems. */ - if(H5Lregister(UD_hard_class_deprec) < 0) TEST_ERROR + if (H5Lregister(UD_hard_class_deprec) < 0) + TEST_ERROR /* Register user-defined link class. This is the one we'll actually be using. */ - if(H5Lregister(UD_cb_class) < 0) TEST_ERROR + if (H5Lregister(UD_cb_class) < 0) + TEST_ERROR /* Check that registered link classes are, and unregistered ones aren't */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_CB_TYPE) != TRUE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_CB_TYPE) != TRUE) + TEST_ERROR /* Create a group for the UD link to point to */ - if((gid = H5Gcreate2(fid, UD_CB_TARGET, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, UD_CB_TARGET, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create a user-defined link to the group. These UD links behave like soft links. */ - if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, + H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Try opening group through UD link */ - if((gid = H5Gopen2(fid, UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gopen2(fid, UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Query the link to test its query callback */ - if(H5Lget_info1(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.u.val_size != 16) TEST_ERROR + if (H5Lget_info1(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.u.val_size != 16) + TEST_ERROR if (UD_CB_TYPE != li.type) { H5_FAILED(); HDputs(" Unexpected link class - should have been a UD hard link"); @@ -3228,64 +4019,93 @@ ud_callbacks_deprec(hid_t fapl, hbool_t new_format) } /* Fill the query buffer */ - if(H5Lget_val(fid, UD_CB_LINK_NAME, query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(HDstrcmp(query_buf, "query succeeded") != 0) TEST_ERROR + if (H5Lget_val(fid, UD_CB_LINK_NAME, query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(query_buf, "query succeeded") != 0) + TEST_ERROR /* Move the link */ - if(H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Re-open group to ensure that move worked */ - if((gid = H5Gopen2(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Remove UD link */ - if(H5Ldelete(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Test that the callbacks don't work if the link class is not registered */ /* Create a new link. Just for fun, give it a non-default character * encoding (to test that LAPLs work) */ - if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_char_encoding(lcpl, H5T_CSET_UTF8) < 0) FAIL_STACK_ERROR - if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, lcpl, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Pclose(lcpl) < 0) FAIL_STACK_ERROR + if ((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_char_encoding(lcpl, H5T_CSET_UTF8) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, + lcpl, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Pclose(lcpl) < 0) + FAIL_STACK_ERROR /* Check its character encoding */ - if(H5Lget_info1(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(li.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info1(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (li.cset != H5T_CSET_UTF8) + TEST_ERROR /* Unregister the link class so the library forgets what its callbacks do */ - if(H5Lunregister((H5L_type_t)UD_CB_TYPE) < 0) FAIL_STACK_ERROR + if (H5Lunregister((H5L_type_t)UD_CB_TYPE) < 0) + FAIL_STACK_ERROR /* Now test that each of the callbacks fails */ - H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR - if(H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR - if((gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, + (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) + FAIL_STACK_ERROR + if (H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) >= 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) + FAIL_STACK_ERROR + if ((gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT)) >= 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) + FAIL_STACK_ERROR + } + H5E_END_TRY /* The query callback should NOT fail, but should be unable to give a linklen */ - if(H5Lget_info1(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(li.u.val_size != 0) TEST_ERROR - if(li.type != UD_CB_TYPE) TEST_ERROR + if (H5Lget_info1(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (li.u.val_size != 0) + TEST_ERROR + if (li.type != UD_CB_TYPE) + TEST_ERROR /* Unregister the UD hard links */ - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Pclose (lcpl); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(lcpl); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end ud_callbacks_deprec() */ @@ -3302,17 +4122,17 @@ error: static int lapl_nlinks_deprec(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t plist = -1; /* lapl ID */ - hid_t tid = -1, sid = -1, did = -1; /* Other IDs */ - hid_t gapl = -1, dapl = -1, tapl = -1; /* Other property lists */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; - size_t nlinks; /* nlinks for H5Pset_nlinks */ - hsize_t dims[2]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t plist = -1; /* lapl ID */ + hid_t tid = -1, sid = -1, did = -1; /* Other IDs */ + hid_t gapl = -1, dapl = -1, tapl = -1; /* Other property lists */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; + size_t nlinks; /* nlinks for H5Pset_nlinks */ + hsize_t dims[2]; + + if (new_format) TESTING("adjusting nlinks with LAPL using deprecated routines (w/new group format)") else TESTING("adjusting nlinks with LAPL using deprecated routines") @@ -3325,76 +4145,113 @@ lapl_nlinks_deprec(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group with short name in file (used as target for links) */ - if((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create chain of soft links to existing object (limited) */ - if(H5Lcreate_soft("final", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft1", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft2", fid, "soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft3", fid, "soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft4", fid, "soft5", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft5", fid, "soft6", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft6", fid, "soft7", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft7", fid, "soft8", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft8", fid, "soft9", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft9", fid, "soft10", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft10", fid, "soft11", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft11", fid, "soft12", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft12", fid, "soft13", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft13", fid, "soft14", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft14", fid, "soft15", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft15", fid, "soft16", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft16", fid, "soft17", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("final", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft1", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft2", fid, "soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft3", fid, "soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft4", fid, "soft5", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft5", fid, "soft6", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft6", fid, "soft7", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft7", fid, "soft8", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft8", fid, "soft9", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft9", fid, "soft10", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft10", fid, "soft11", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft11", fid, "soft12", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft12", fid, "soft13", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft13", fid, "soft14", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft14", fid, "soft15", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft15", fid, "soft16", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft16", fid, "soft17", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Create LAPL with higher-than-usual nlinks value */ /* Create a non-default lapl with udata set to point to the first group */ - if((plist = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR + if ((plist = H5Pcreate(H5P_LINK_ACCESS)) < 0) + TEST_ERROR nlinks = 20; - if(H5Pset_nlinks(plist, nlinks) < 0) TEST_ERROR + if (H5Pset_nlinks(plist, nlinks) < 0) + TEST_ERROR /* Ensure that nlinks was set successfully */ nlinks = 0; - if(H5Pget_nlinks(plist, &nlinks) < 0) TEST_ERROR - if(nlinks != 20) TEST_ERROR + if (H5Pget_nlinks(plist, &nlinks) < 0) + TEST_ERROR + if (nlinks != 20) + TEST_ERROR /* Open object through what is normally too many soft links using * new property list */ - if((gid = H5Oopen(fid, "soft17", plist)) < 0) TEST_ERROR + if ((gid = H5Oopen(fid, "soft17", plist)) < 0) + TEST_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/soft17")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/soft17")) + TEST_ERROR /* Create group using soft link */ - if((gid2 = H5Gcreate2(gid, "new_soft", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_soft", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close groups */ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Set nlinks to a smaller number */ nlinks = 4; - if(H5Pset_nlinks(plist, nlinks) < 0) TEST_ERROR + if (H5Pset_nlinks(plist, nlinks) < 0) + TEST_ERROR /* Ensure that nlinks was set successfully */ nlinks = 0; - if(H5Pget_nlinks(plist, &nlinks) < 0) TEST_ERROR - if(nlinks != 4) TEST_ERROR + if (H5Pget_nlinks(plist, &nlinks) < 0) + TEST_ERROR + if (nlinks != 4) + TEST_ERROR /* Try opening through what is now too many soft links */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Oopen(fid, "soft5", plist); - } H5E_END_TRY; + } + H5E_END_TRY; if (gid >= 0) { H5_FAILED(); HDputs(" Should have failed for sequence of too many nested links."); @@ -3402,106 +4259,149 @@ lapl_nlinks_deprec(hid_t fapl, hbool_t new_format) } /* Open object through lesser soft link */ - if((gid = H5Oopen(fid, "soft4", plist)) < 0) TEST_ERROR + if ((gid = H5Oopen(fid, "soft4", plist)) < 0) + TEST_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/soft4")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/soft4")) + TEST_ERROR /* Test other functions that should use a LAPL */ nlinks = 20; - if(H5Pset_nlinks(plist, nlinks) < 0) TEST_ERROR + if (H5Pset_nlinks(plist, nlinks) < 0) + TEST_ERROR /* Try copying and moving when both src and dst contain many soft links * using a non-default LAPL */ - if(H5Lcopy(fid, "soft17", fid, "soft17/newer_soft", H5P_DEFAULT, plist) < 0) TEST_ERROR - if(H5Lmove(fid, "soft17/newer_soft", fid, "soft17/newest_soft", H5P_DEFAULT, plist) < 0) TEST_ERROR + if (H5Lcopy(fid, "soft17", fid, "soft17/newer_soft", H5P_DEFAULT, plist) < 0) + TEST_ERROR + if (H5Lmove(fid, "soft17/newer_soft", fid, "soft17/newest_soft", H5P_DEFAULT, plist) < 0) + TEST_ERROR /* H5Olink */ - if(H5Olink(gid, fid, "soft17/link_to_group", H5P_DEFAULT, plist) < 0) TEST_ERROR + if (H5Olink(gid, fid, "soft17/link_to_group", H5P_DEFAULT, plist) < 0) + TEST_ERROR /* H5Lcreate_hard and H5Lcreate_soft */ - if(H5Lcreate_hard(fid, "soft17", fid, "soft17/link2_to_group", H5P_DEFAULT, plist) < 0) TEST_ERROR - if(H5Lcreate_soft("/soft4", fid, "soft17/soft_link", H5P_DEFAULT, plist) < 0) TEST_ERROR + if (H5Lcreate_hard(fid, "soft17", fid, "soft17/link2_to_group", H5P_DEFAULT, plist) < 0) + TEST_ERROR + if (H5Lcreate_soft("/soft4", fid, "soft17/soft_link", H5P_DEFAULT, plist) < 0) + TEST_ERROR /* H5Ldelete */ - if(H5Ldelete(fid, "soft17/soft_link", plist) < 0) TEST_ERROR + if (H5Ldelete(fid, "soft17/soft_link", plist) < 0) + TEST_ERROR /* H5Lget_val and H5Lget_info1 */ - if(H5Lget_val(fid, "soft17", NULL, (size_t)0, plist) < 0) TEST_ERROR - if(H5Lget_info1(fid, "soft17", NULL, plist) < 0) TEST_ERROR + if (H5Lget_val(fid, "soft17", NULL, (size_t)0, plist) < 0) + TEST_ERROR + if (H5Lget_info1(fid, "soft17", NULL, plist) < 0) + TEST_ERROR /* H5Lcreate_external and H5Lcreate_ud */ - if(H5Lcreate_external("filename", "path", fid, "soft17/extlink", H5P_DEFAULT, plist) < 0) TEST_ERROR - if(H5Lregister(UD_rereg_class) < 0) TEST_ERROR - if(H5Lcreate_ud(fid, "soft17/udlink", (H5L_type_t)UD_HARD_TYPE, NULL, (size_t)0, H5P_DEFAULT, plist) < 0) TEST_ERROR + if (H5Lcreate_external("filename", "path", fid, "soft17/extlink", H5P_DEFAULT, plist) < 0) + TEST_ERROR + if (H5Lregister(UD_rereg_class) < 0) + TEST_ERROR + if (H5Lcreate_ud(fid, "soft17/udlink", (H5L_type_t)UD_HARD_TYPE, NULL, (size_t)0, H5P_DEFAULT, plist) < 0) + TEST_ERROR /* Close plist */ - if(H5Pclose(plist) < 0) TEST_ERROR + if (H5Pclose(plist) < 0) + TEST_ERROR /* Create a datatype and dataset as targets inside the group */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(gid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(gid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR dims[0] = 2; dims[1] = 2; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + if ((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Try to open the objects using too many symlinks with default *APLs */ - H5E_BEGIN_TRY { - if((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >= 0) + H5E_BEGIN_TRY + { + if ((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >= 0) FAIL_PUTS_ERROR(" Should have failed for too many nested links.") - if((tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT)) >= 0) + if ((tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT)) >= 0) FAIL_PUTS_ERROR(" Should have failed for too many nested links.") - if((did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT)) >= 0) + if ((did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT)) >= 0) FAIL_PUTS_ERROR(" Should have failed for too many nested links.") - } H5E_END_TRY + } + H5E_END_TRY /* Create property lists with nlinks set */ - if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR - if((tapl = H5Pcreate(H5P_DATATYPE_ACCESS)) < 0) TEST_ERROR - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR + if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) + TEST_ERROR + if ((tapl = H5Pcreate(H5P_DATATYPE_ACCESS)) < 0) + TEST_ERROR + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + TEST_ERROR nlinks = 20; - if(H5Pset_nlinks(gapl, nlinks) < 0) TEST_ERROR - if(H5Pset_nlinks(tapl, nlinks) < 0) TEST_ERROR - if(H5Pset_nlinks(dapl, nlinks) < 0) TEST_ERROR + if (H5Pset_nlinks(gapl, nlinks) < 0) + TEST_ERROR + if (H5Pset_nlinks(tapl, nlinks) < 0) + TEST_ERROR + if (H5Pset_nlinks(dapl, nlinks) < 0) + TEST_ERROR /* We should now be able to use these property lists to open each kind * of object. */ - if((gid = H5Gopen2(fid, "soft17", gapl)) < 0) FAIL_STACK_ERROR - if((tid = H5Topen2(fid, "soft17/datatype", tapl)) < 0) TEST_ERROR - if((did = H5Dopen2(fid, "soft17/dataset", dapl)) < 0) TEST_ERROR + if ((gid = H5Gopen2(fid, "soft17", gapl)) < 0) + FAIL_STACK_ERROR + if ((tid = H5Topen2(fid, "soft17/datatype", tapl)) < 0) + TEST_ERROR + if ((did = H5Dopen2(fid, "soft17/dataset", dapl)) < 0) + TEST_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close plists */ - if(H5Pclose(gapl) < 0) TEST_ERROR - if(H5Pclose(tapl) < 0) TEST_ERROR - if(H5Pclose(dapl) < 0) TEST_ERROR + if (H5Pclose(gapl) < 0) + TEST_ERROR + if (H5Pclose(tapl) < 0) + TEST_ERROR + if (H5Pclose(dapl) < 0) + TEST_ERROR /* Unregister UD hard link class */ - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) TEST_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gapl); H5Pclose(dapl); H5Pclose(tapl); @@ -3512,7 +4412,8 @@ error: H5Gclose(gid); H5Pclose(plist); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end lapl_nlinks_deprec() */ @@ -3528,14 +4429,14 @@ error: static int linkinfo_deprec(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t tid = -1; /* Type ID */ - hid_t sid = -1, did = -1; /* Dataspace and dataset IDs */ - H5L_info1_t li; /* Link information */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t tid = -1; /* Type ID */ + hid_t sid = -1, did = -1; /* Dataspace and dataset IDs */ + H5L_info1_t li; /* Link information */ char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("link type field in H5Lget_info using deprecated routines (w/new group format)") else TESTING("link type field in H5Lget_info using deprecated routines") @@ -3543,58 +4444,88 @@ linkinfo_deprec(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Register a couple of user-defined link classes with the library */ - if(H5Lregister(UD_plist_class) < 0) TEST_ERROR + if (H5Lregister(UD_plist_class) < 0) + TEST_ERROR /* Create an object of each type */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(fid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("group", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(fid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("group", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR - if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR + if ((sid = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR + if ((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR - if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external("file_name", "obj_path", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < + 0) + TEST_ERROR + if (H5Lcreate_external("file_name", "obj_path", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close all objects */ - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Make sure that link type is correct when objects are queried */ - if(H5Lget_info1(fid, "datatype", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_HARD) TEST_ERROR - if(H5Lget_info1(fid, "group", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_HARD) TEST_ERROR - if(H5Lget_info1(fid, "dataset", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_HARD) TEST_ERROR - - if(H5Lget_info1(fid, "ext_link", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_EXTERNAL) TEST_ERROR - if(H5Lget_info1(fid, "softlink", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_SOFT) TEST_ERROR - if(H5Lget_info1(fid, "ud_link", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != UD_PLIST_TYPE) TEST_ERROR + if (H5Lget_info1(fid, "datatype", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_HARD) + TEST_ERROR + if (H5Lget_info1(fid, "group", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_HARD) + TEST_ERROR + if (H5Lget_info1(fid, "dataset", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_HARD) + TEST_ERROR + + if (H5Lget_info1(fid, "ext_link", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_EXTERNAL) + TEST_ERROR + if (H5Lget_info1(fid, "softlink", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_SOFT) + TEST_ERROR + if (H5Lget_info1(fid, "ud_link", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != UD_PLIST_TYPE) + TEST_ERROR /* Ensure that passing a NULL pointer doesn't cause an error */ - if(H5Lget_info1(fid, "group", NULL, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info1(fid, "group", NULL, H5P_DEFAULT) < 0) + TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Tclose (tid); - H5Dclose (did); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Tclose(tid); + H5Dclose(did); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end linkinfo_deprec() */ @@ -3611,102 +4542,132 @@ error: static int corder_create_compact_deprec(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - unsigned u; /* Local index variable */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned nlinks; /* Number of link messages in group's header */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + unsigned u; /* Local index variable */ TESTING("creating compact group with creation order indexing using deprecated routines") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on group's initial status */ - if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__is_empty_test(group_id) != TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Create several links, but keep group in compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR - if(nlinks != (u + 1)) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, &nlinks) != TRUE) + TEST_ERROR + if (nlinks != (u + 1)) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR } /* end for */ /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open group created */ - if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR - if(nlinks != max_compact) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, &nlinks) != TRUE) + TEST_ERROR + if (nlinks != max_compact) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Loop through links, checking their creation order values */ /* (the name index is used, but the creation order value is in the same order) */ - for(u = 0; u < max_compact; u++) { - H5L_info1_t linfo; /* Link information */ + for (u = 0; u < max_compact; u++) { + H5L_info1_t linfo; /* Link information */ /* Retrieve information for link */ HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Lget_info1(group_id, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info1(group_id, objname, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify creation order of link */ - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != u) TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != u) + TEST_ERROR } /* end for */ /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end corder_create_compact_deprec() */ @@ -3723,117 +4684,153 @@ error: static int corder_create_dense_deprec(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - unsigned u; /* Local index variable */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned nlinks; /* Number of link messages in group's header */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + unsigned u; /* Local index variable */ TESTING("creating dense group with creation order indexing using deprecated routines") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on group's initial status */ - if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__is_empty_test(group_id) != TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR - if(nlinks != (u + 1)) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, &nlinks) != TRUE) + TEST_ERROR + if (nlinks != (u + 1)) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR } /* end for */ /* Create another link, to push group into dense form */ HDsnprintf(objname, sizeof(objname), "filler %u", max_compact); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open group created */ - if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Loop through links, checking their creation order values */ /* (the name index is used, but the creation order value is in the same order) */ - for(u = 0; u < (max_compact + 1); u++) { - H5L_info1_t linfo; /* Link information */ + for (u = 0; u < (max_compact + 1); u++) { + H5L_info1_t linfo; /* Link information */ /* Retrieve information for link */ HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Lget_info1(group_id, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info1(group_id, objname, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify creation order of link */ - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != u) TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != u) + TEST_ERROR } /* end for */ /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end corder_create_dense_deprec() */ @@ -3851,111 +4848,154 @@ error: *------------------------------------------------------------------------- */ static int -link_info_by_idx_check_deprec(hid_t group_id, const char *linkname, hsize_t n, - hbool_t hard_link, hbool_t use_index) +link_info_by_idx_check_deprec(hid_t group_id, const char *linkname, hsize_t n, hbool_t hard_link, + hbool_t use_index) { - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - char valname[NAME_BUF_SIZE]; /* Link value name */ - char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ - H5L_info1_t linfo; /* Link info struct */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + char valname[NAME_BUF_SIZE]; /* Link value name */ + char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ + H5L_info1_t linfo; /* Link info struct */ /* Make link value for increasing/native order queries */ HDsnprintf(valname, sizeof(valname), "value %02u", (unsigned)n); /* Verify the link information for first link, in increasing creation order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in increasing creation order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in increasing creation order */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in increasing creation order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, + H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR /* Don't test "native" order if there is no creation order index, since * there's not a good way to easily predict the link's order in the name * index. */ - if(use_index) { + if (use_index) { /* Verify the link information for first link, in native creation order (which is increasing) */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, (hsize_t)0, &linfo, + H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in native creation order (which is increasing) */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in native creation order (which is increasing) */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in native creation order (which is increasing) */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR } /* end if */ /* Verify the link information for first link, in decreasing creation order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, n, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in decreasing creation order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in decreasing creation order */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in decreasing creation order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR - + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR /* Verify the link information for first link, in increasing link name order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in increasing link name order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in increasing link name order */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpval, (size_t)NAME_BUF_SIZE, + H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in increasing link name order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, + H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR /* Don't test "native" order queries on link name order, since there's not * a good way to easily predict the order of the links in the name index. @@ -3963,32 +5003,42 @@ link_info_by_idx_check_deprec(hid_t group_id, const char *linkname, hsize_t n, /* Verify the link information for first link, in decreasing link name order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, n, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in decreasing link name order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in decreasing link name order */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in decreasing link name order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR /* Success */ - return(0); + return (0); error: /* Failure */ - return(-1); + return (-1); } /* end link_info_by_idx_check_deprec() */ /*------------------------------------------------------------------------- @@ -4004,170 +5054,229 @@ error: static int link_info_by_idx_deprec(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned hard_link; /* Create hard or soft link? */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - H5L_info1_t linfo; /* Link info struct */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char valname[NAME_BUF_SIZE]; /* Link value name */ - char filename[NAME_BUF_SIZE];/* File name */ - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - unsigned u; /* Local index variable */ - ssize_t name_len; /* Length of name */ - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned hard_link; /* Create hard or soft link? */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5L_info1_t linfo; /* Link info struct */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char valname[NAME_BUF_SIZE]; /* Link value name */ + char filename[NAME_BUF_SIZE]; /* File name */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ + herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ - for(hard_link = FALSE; hard_link <= TRUE; hard_link++) { + for (hard_link = FALSE; hard_link <= TRUE; hard_link++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { - if(hard_link) { - if(use_index) - TESTING("querying info by index w/creation order index, using hard links and deprecated routines") + for (use_index = FALSE; use_index <= TRUE; use_index++) { + if (hard_link) { + if (use_index) + TESTING("querying info by index w/creation order index, using hard links and deprecated " + "routines") else - TESTING("querying info by index w/o creation order index, using hard links and deprecated routines") + TESTING("querying info by index w/o creation order index, using hard links and " + "deprecated routines") } /* end if */ else { - if(use_index) - TESTING("querying info by index w/creation order index, using soft links and deprecated routines") + if (use_index) + TESTING("querying info by index w/creation order index, using soft links and deprecated " + "routines") else - TESTING("querying info by index w/o creation order index, using soft links and deprecated routines") + TESTING("querying info by index w/o creation order index, using soft links and " + "deprecated routines") } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order( + gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Check for query on empty group */ - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - } H5E_END_TRY; - if(name_len >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + } + H5E_END_TRY; + if (name_len >= 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Check for creating hard or soft link */ - if(hard_link) { - hid_t group_id2; /* Group ID */ + if (hard_link) { + hid_t group_id2; /* Group ID */ /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end if */ else { /* Make value for link */ HDsnprintf(valname, sizeof(valname), "value %02u", u); /* Create soft link */ - if(H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ /* Verify link information for new link */ - if(link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) + TEST_ERROR } /* end for */ /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound offset queries */ - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - } H5E_END_TRY; - if(name_len >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + } + H5E_END_TRY; + if (name_len >= 0) + TEST_ERROR /* Create more links, to push group into dense form */ - for(; u < (max_compact * 2); u++) { + for (; u < (max_compact * 2); u++) { /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Check for creating hard or soft link */ - if(hard_link) { - hid_t group_id2; /* Group ID */ + if (hard_link) { + hid_t group_id2; /* Group ID */ /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end if */ else { /* Make value for link */ HDsnprintf(valname, sizeof(valname), "value %02u", u); /* Create soft link */ - if(H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ /* Verify state of group */ - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Verify link information for new link */ - if(link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) + TEST_ERROR } /* end for */ /* Check for out of bound offset queries */ - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - } H5E_END_TRY; - if(name_len >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + } + H5E_END_TRY; + if (name_len >= 0) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ + } /* end for */ return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end link_info_by_idx_deprec() */ @@ -4184,65 +5293,71 @@ error: static int link_info_by_idx_old_deprec(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - unsigned hard_link; /* Create hard or soft link? */ - H5L_info1_t linfo; /* Link info struct */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char valname[NAME_BUF_SIZE]; /* Link value name */ - char filename[NAME_BUF_SIZE];/* File name */ - haddr_t objno[CORDER_NLINKS]; /* Addresses of the objects created */ - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ - unsigned u; /* Local index variable */ - ssize_t name_len; /* Length of name */ - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + unsigned hard_link; /* Create hard or soft link? */ + H5L_info1_t linfo; /* Link info struct */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char valname[NAME_BUF_SIZE]; /* Link value name */ + char filename[NAME_BUF_SIZE]; /* File name */ + haddr_t objno[CORDER_NLINKS]; /* Addresses of the objects created */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ + unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ + herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ - for(hard_link = FALSE; hard_link <= TRUE; hard_link++) { - if(hard_link) + for (hard_link = FALSE; hard_link <= TRUE; hard_link++) { + if (hard_link) TESTING("querying info by index in old-style group, using hard links and deprecated routines") else TESTING("querying info by index in old-style group, using soft links and deprecated routines") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group to operate on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { + for (u = 0; u < CORDER_NLINKS; u++) { /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Check for creating hard or soft link */ - if(hard_link) { - H5O_info1_t oi; /* Buffer for querying object's info */ + if (hard_link) { + H5O_info1_t oi; /* Buffer for querying object's info */ /* Create group */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info2(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info2(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oi.addr; /* Close group */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end if */ else { /* Make value for link */ HDsnprintf(valname, sizeof(valname), "value %02u", u); /* Create soft link */ - if(H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ - } /* end for */ + } /* end for */ /* Verify link information for created links */ - for(u = 0; u < CORDER_NLINKS; u++) { - unsigned dec_u = CORDER_NLINKS - (u + 1); /* Decreasing mapped index */ + for (u = 0; u < CORDER_NLINKS; u++) { + unsigned dec_u = CORDER_NLINKS - (u + 1); /* Decreasing mapped index */ /* Make link name for increasing/native order queries */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -4251,34 +5366,50 @@ link_info_by_idx_old_deprec(hid_t fapl) HDsnprintf(valname, sizeof(valname), "value %02u", u); /* Verify link information (in increasing order) */ - if(hard_link) { - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5F_addr_ne(linfo.u.address, objno[u])) TEST_ERROR + if (hard_link) { + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, &linfo, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5F_addr_ne(linfo.u.address, objno[u])) + TEST_ERROR } /* end if */ else { - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end else */ /* Verify link name (in increasing order) */ - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(objname, tmpname)) TEST_ERROR - + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR /* Verify link information (in native order - native is increasing) */ - if(hard_link) { - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5F_addr_ne(linfo.u.address, objno[u])) TEST_ERROR + if (hard_link) { + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, &linfo, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5F_addr_ne(linfo.u.address, objno[u])) + TEST_ERROR } /* end if */ else { - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end else */ /* Verify link name (in native order - native is increasing) */ - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(objname, tmpname)) TEST_ERROR - + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR /* Make link name for decreasing order queries */ HDsnprintf(objname, sizeof(objname), "filler %02u", dec_u); @@ -4287,38 +5418,58 @@ link_info_by_idx_old_deprec(hid_t fapl) HDsnprintf(valname, sizeof(valname), "value %02u", dec_u); /* Verify link information (in decreasing order) */ - if(hard_link) { - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5F_addr_ne(linfo.u.address, objno[dec_u])) TEST_ERROR + if (hard_link) { + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, &linfo, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5F_addr_ne(linfo.u.address, objno[dec_u])) + TEST_ERROR } /* end if */ else { - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end else */ /* Verify link name (in decreasing order) */ - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Check for creation order index queries */ - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - } H5E_END_TRY; - if(name_len >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + } + H5E_END_TRY; + if (name_len >= 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ @@ -4326,10 +5477,12 @@ link_info_by_idx_old_deprec(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end link_info_by_idx_old_deprec() */ @@ -4346,305 +5499,398 @@ error: static int delete_by_idx_deprec(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - H5L_info1_t linfo; /* Link info struct */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5L_info1_t linfo; /* Link info struct */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("deleting links by creation order index in increasing order w/creation order index using deprecated routines") + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + TESTING("deleting links by creation order index in increasing order w/creation " + "order index using deprecated routines") else - TESTING("deleting links by creation order index in increasing order w/o creation order index using deprecated routines") + TESTING("deleting links by creation order index in increasing order w/o creation " + "order index using deprecated routines") } /* end if */ else { - if(use_index) - TESTING("deleting links by creation order index in decreasing order w/creation order index using deprecated routines") + if (use_index) + TESTING("deleting links by creation order index in decreasing order w/creation " + "order index using deprecated routines") else - TESTING("deleting links by creation order index in decreasing order w/o creation order index using deprecated routines") + TESTING("deleting links by creation order index in decreasing order w/o creation " + "order index using deprecated routines") } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("deleting links by name index in increasing order w/creation order index using deprecated routines") + if (order == H5_ITER_INC) { + if (use_index) + TESTING("deleting links by name index in increasing order w/creation order index " + "using deprecated routines") else - TESTING("deleting links by name index in increasing order w/o creation order index using deprecated routines") + TESTING("deleting links by name index in increasing order w/o creation order " + "index using deprecated routines") } /* end if */ else { - if(use_index) - TESTING("deleting links by name index in decreasing order w/creation order index using deprecated routines") + if (use_index) + TESTING("deleting links by name index in decreasing order w/creation order index " + "using deprecated routines") else - TESTING("deleting links by name index in decreasing order w/o creation order index using deprecated routines") + TESTING("deleting links by name index in decreasing order w/o creation order " + "index using deprecated routines") } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | + (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < + 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Delete links from one end */ /* Check for deletion on empty group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for deletion on non-existing group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, "None", idx_type, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < max_compact; u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify link information for new link */ - if(link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (compact) */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound deletion */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Delete links from compact group */ - for(u = 0; u < (max_compact - 1); u++) { + for (u = 0; u < (max_compact - 1); u++) { /* Delete first link in appropriate order */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(linfo.corder != (u + 1)) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (linfo.corder != (u + 1)) + TEST_ERROR } /* end if */ else { - if(linfo.corder != (max_compact - (u + 2))) TEST_ERROR + if (linfo.corder != (max_compact - (u + 2))) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", (u + 1)); else HDsnprintf(objname, sizeof(objname), "filler %02u", (max_compact - (u + 2))); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group (empty) */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR /* Create more links, to push group into dense form */ - for(u = 0; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < (max_compact * 2); u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group (dense) */ - if(u >= max_compact) - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (u >= max_compact) + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Verify link information for new link */ - if(link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) + TEST_ERROR } /* end for */ /* Check for out of bound deletion again */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Delete links from dense group, in appropriate order */ - for(u = 0; u < ((max_compact * 2) - 1); u++) { + for (u = 0; u < ((max_compact * 2) - 1); u++) { /* Delete first link in appropriate order */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(linfo.corder != (u + 1)) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (linfo.corder != (u + 1)) + TEST_ERROR } /* end if */ else { - if(linfo.corder != ((max_compact * 2) - (u + 2))) TEST_ERROR + if (linfo.corder != ((max_compact * 2) - (u + 2))) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", (u + 1)); else HDsnprintf(objname, sizeof(objname), "filler %02u", ((max_compact * 2) - (u + 2))); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group (empty) */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Check for deletion on empty group again */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Delete links in middle */ /* Create more links, to push group into dense form */ - for(u = 0; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < (max_compact * 2); u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group (dense) */ - if(u >= max_compact) - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (u >= max_compact) + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Verify link information for new link */ - if(link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check_deprec(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) + TEST_ERROR } /* end for */ /* Delete every other link from dense group, in appropriate order */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Delete link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for current link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", idx_type, order, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(linfo.corder != ((u * 2) + 1)) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", idx_type, order, (hsize_t)u, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (linfo.corder != ((u * 2) + 1)) + TEST_ERROR } /* end if */ else { - if(linfo.corder != ((max_compact * 2) - ((u * 2) + 2))) TEST_ERROR + if (linfo.corder != ((max_compact * 2) - ((u * 2) + 2))) + TEST_ERROR } /* end else */ /* Verify the name for current link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", ((u * 2) + 1)); else - HDsnprintf(objname, sizeof(objname), "filler %02u", ((max_compact * 2) - ((u * 2) + 2))); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + HDsnprintf(objname, sizeof(objname), "filler %02u", + ((max_compact * 2) - ((u * 2) + 2))); + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete remaining links from dense group, in appropriate order */ - for(u = 0; u < (max_compact - 1); u++) { + for (u = 0; u < (max_compact - 1); u++) { /* Delete link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(linfo.corder != ((u * 2) + 3)) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (linfo.corder != ((u * 2) + 3)) + TEST_ERROR } /* end if */ else { - if(linfo.corder != ((max_compact * 2) - ((u * 2) + 4))) TEST_ERROR + if (linfo.corder != ((max_compact * 2) - ((u * 2) + 4))) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", ((u * 2) + 3)); else - HDsnprintf(objname, sizeof(objname), "filler %02u", ((max_compact * 2) - ((u * 2) + 4))); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + HDsnprintf(objname, sizeof(objname), "filler %02u", + ((max_compact * 2) - ((u * 2) + 4))); + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group (empty) */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end delete_by_idx_deprec() */ @@ -4661,194 +5907,243 @@ error: static int delete_by_idx_old_deprec(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - H5L_info1_t linfo; /* Link info struct */ - H5_iter_order_t order; /* Order within in the index */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - haddr_t objno[CORDER_NLINKS]; /* Addresses of the objects created */ - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + H5L_info1_t linfo; /* Link info struct */ + H5_iter_order_t order; /* Order within in the index */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + haddr_t objno[CORDER_NLINKS]; /* Addresses of the objects created */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { /* Print test banner */ - if(order == H5_ITER_INC) - TESTING("deleting links by index in increasing order in old-style group using deprecated routines") + if (order == H5_ITER_INC) + TESTING( + "deleting links by index in increasing order in old-style group using deprecated routines") else - TESTING("deleting links by index in decreasing order in old-style group using deprecated routines") + TESTING( + "deleting links by index in decreasing order in old-style group using deprecated routines") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group to operate on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Delete links from one end */ /* Check for deletion in empty group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - H5O_info1_t oi; /* Buffer for querying object's info */ + for (u = 0; u < CORDER_NLINKS; u++) { + H5O_info1_t oi; /* Buffer for querying object's info */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create group */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info2(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info2(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oi.addr; /* Close group */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Check for bad index type deletion */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for out of bounds deletion */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Delete links, in appropriate order */ - for(u = 0; u < (CORDER_NLINKS - 1); u++) { - unsigned dec_u = CORDER_NLINKS - (u + 2); /* Decreasing mapped index */ + for (u = 0; u < (CORDER_NLINKS - 1); u++) { + unsigned dec_u = CORDER_NLINKS - (u + 2); /* Decreasing mapped index */ /* Delete first link in appropriate order */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(H5F_addr_ne(linfo.u.address, objno[u + 1])) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (H5F_addr_ne(linfo.u.address, objno[u + 1])) + TEST_ERROR } /* end if */ else { - if(H5F_addr_ne(linfo.u.address, objno[dec_u])) TEST_ERROR + if (H5F_addr_ne(linfo.u.address, objno[dec_u])) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", (u + 1)); else HDsnprintf(objname, sizeof(objname), "filler %02u", dec_u); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Check for deletion in empty group (again) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Delete links in middle */ /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - H5O_info1_t oi; /* Buffer for querying object's info */ + for (u = 0; u < CORDER_NLINKS; u++) { + H5O_info1_t oi; /* Buffer for querying object's info */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create group */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info2(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info2(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oi.addr; /* Close group */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Delete every other link from group, in appropriate order */ - for(u = 0; u < (CORDER_NLINKS / 2); u++) { - unsigned dec_u = CORDER_NLINKS - ((u * 2) + 2); /* Decreasing mapped index */ + for (u = 0; u < (CORDER_NLINKS / 2); u++) { + unsigned dec_u = CORDER_NLINKS - ((u * 2) + 2); /* Decreasing mapped index */ /* Delete link */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for current link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(H5F_addr_ne(linfo.u.address, objno[(u * 2) + 1])) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (H5F_addr_ne(linfo.u.address, objno[(u * 2) + 1])) + TEST_ERROR } /* end if */ else { - if(H5F_addr_ne(linfo.u.address, objno[dec_u])) TEST_ERROR + if (H5F_addr_ne(linfo.u.address, objno[dec_u])) + TEST_ERROR } /* end else */ /* Verify the name for current link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", ((u * 2) + 1)); else HDsnprintf(objname, sizeof(objname), "filler %02u", dec_u); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete remaining links from group, in appropriate order */ - for(u = 0; u < ((CORDER_NLINKS / 2) - 1); u++) { - unsigned dec_u = CORDER_NLINKS - ((u * 2) + 4); /* Decreasing mapped index */ + for (u = 0; u < ((CORDER_NLINKS / 2) - 1); u++) { + unsigned dec_u = CORDER_NLINKS - ((u * 2) + 4); /* Decreasing mapped index */ /* Delete link */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(H5F_addr_ne(linfo.u.address, objno[(u * 2) + 3])) TEST_ERROR + if (H5Lget_info_by_idx1(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (H5F_addr_ne(linfo.u.address, objno[(u * 2) + 3])) + TEST_ERROR } /* end if */ else { - if(H5F_addr_ne(linfo.u.address, objno[dec_u])) TEST_ERROR + if (H5F_addr_ne(linfo.u.address, objno[dec_u])) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", ((u * 2) + 3)); else HDsnprintf(objname, sizeof(objname), "filler %02u", dec_u); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ @@ -4856,10 +6151,12 @@ delete_by_idx_old_deprec(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end delete_by_idx_old_deprec() */ @@ -4874,62 +6171,61 @@ error: *------------------------------------------------------------------------- */ static int -link_iterate_deprec_cb(hid_t group_id, const char *link_name, const H5L_info1_t *info, - void *_op_data) +link_iterate_deprec_cb(hid_t group_id, const char *link_name, const H5L_info1_t *info, void *_op_data) { - link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ - char objname[NAME_BUF_SIZE]; /* Object name */ - H5L_info1_t my_info; /* Local link info */ + link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ + char objname[NAME_BUF_SIZE]; /* Object name */ + H5L_info1_t my_info; /* Local link info */ /* Increment # of times the callback was called */ op_data->ncalled++; /* Get the link information directly to compare */ - if(H5Lget_info1(group_id, link_name, &my_info, H5P_DEFAULT) < 0) + if (H5Lget_info1(group_id, link_name, &my_info, H5P_DEFAULT) < 0) return H5_ITER_ERROR; /* Check more things for link iteration (vs. group iteration) */ - if(info) { + if (info) { /* Check for correct order of iteration */ /* (if we are operating in increasing or decreasing order) */ - if(op_data->order != H5_ITER_NATIVE) - if(info->corder != op_data->curr) + if (op_data->order != H5_ITER_NATIVE) + if (info->corder != op_data->curr) return H5_ITER_ERROR; /* Compare link info structs */ - if(info->type != my_info.type) + if (info->type != my_info.type) return H5_ITER_ERROR; - if(info->corder_valid != my_info.corder_valid) + if (info->corder_valid != my_info.corder_valid) return H5_ITER_ERROR; - if(info->corder != my_info.corder) + if (info->corder != my_info.corder) return H5_ITER_ERROR; - if(info->cset != my_info.cset) + if (info->cset != my_info.cset) return H5_ITER_ERROR; - if(H5F_addr_ne(info->u.address, my_info.u.address)) + if (H5F_addr_ne(info->u.address, my_info.u.address)) return H5_ITER_ERROR; } /* end if */ /* Verify name of link */ HDsnprintf(objname, sizeof(objname), "filler %02u", (unsigned)my_info.corder); - if(HDstrcmp(link_name, objname)) + if (HDstrcmp(link_name, objname)) return H5_ITER_ERROR; /* Check if we've visited this link before */ - if((size_t)op_data->curr >= op_data->max_visit) + if ((size_t)op_data->curr >= op_data->max_visit) return H5_ITER_ERROR; - if(op_data->visited[op_data->curr]) + if (op_data->visited[op_data->curr]) return H5_ITER_ERROR; op_data->visited[op_data->curr] = TRUE; /* Advance to next value, in correct direction */ - if(op_data->order != H5_ITER_DEC) + if (op_data->order != H5_ITER_DEC) op_data->curr++; else op_data->curr--; /* Check for stopping in the middle of iterating */ - if(op_data->stop > 0) - if(--op_data->stop == 0) + if (op_data->stop > 0) + if (--op_data->stop == 0) return CORDER_ITER_STOP; return H5_ITER_CONT; @@ -4963,7 +6259,7 @@ group_iterate_deprec_cb(hid_t group_id, const char *link_name, void *_op_data) */ static int link_iterate_fail_deprec_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *link_name, - const H5L_info1_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) + const H5L_info1_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) { return H5_ITER_ERROR; } /* end link_iterate_fail_deprec_cb() */ @@ -4978,130 +6274,155 @@ link_iterate_fail_deprec_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UN *------------------------------------------------------------------------- */ static int -link_iterate_check_deprec(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, - unsigned max_links, link_iter_info_t *iter_info) +link_iterate_check_deprec(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, unsigned max_links, + link_iter_info_t *iter_info) { - unsigned v; /* Local index variable */ - hsize_t skip; /* # of links to skip in group */ - int gskip; /* # of links to skip in group, with H5Giterate */ - herr_t ret; /* Generic return value */ + unsigned v; /* Local index variable */ + hsize_t skip; /* # of links to skip in group */ + int gskip; /* # of links to skip in group, with H5Giterate */ + herr_t ret; /* Generic return value */ /* Iterate over links in group */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Literate1(group_id, idx_type, order, &skip, link_iterate_deprec_cb, iter_info) < 0) TEST_ERROR + if (H5Literate1(group_id, idx_type, order, &skip, link_iterate_deprec_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(skip != max_links) TEST_ERROR - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + if (skip != max_links) + TEST_ERROR + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR /* Iterate over links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Giterate(group_id, ".", &gskip, group_iterate_deprec_cb, iter_info) < 0) TEST_ERROR + if (H5Giterate(group_id, ".", &gskip, group_iterate_deprec_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(gskip != (int)max_links) TEST_ERROR - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + if (gskip != (int)max_links) + TEST_ERROR + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR /* Skip over some links in group */ iter_info->nskipped = (unsigned)(skip = max_links / 2); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Literate1(group_id, idx_type, order, &skip, link_iterate_deprec_cb, iter_info) < 0) TEST_ERROR + if (H5Literate1(group_id, idx_type, order, &skip, link_iterate_deprec_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(skip != max_links) TEST_ERROR - if(order == H5_ITER_INC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v + (max_links / 2)] == FALSE) TEST_ERROR + if (skip != max_links) + TEST_ERROR + if (order == H5_ITER_INC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v + (max_links / 2)] == FALSE) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == TRUE) nvisit++; - if(nvisit != (max_links / 2)) TEST_ERROR + if (nvisit != (max_links / 2)) + TEST_ERROR } /* end else */ /* Skip over some links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Giterate(group_id, ".", &gskip, group_iterate_deprec_cb, iter_info) < 0) TEST_ERROR + if (H5Giterate(group_id, ".", &gskip, group_iterate_deprec_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(gskip != (int)max_links) TEST_ERROR - if(order == H5_ITER_INC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v + (max_links / 2)] == FALSE) TEST_ERROR + if (gskip != (int)max_links) + TEST_ERROR + if (order == H5_ITER_INC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v + (max_links / 2)] == FALSE) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == TRUE) nvisit++; - if(nvisit != (max_links / 2)) TEST_ERROR + if (nvisit != (max_links / 2)) + TEST_ERROR } /* end else */ /* Iterate over links in group, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if((ret = H5Literate1(group_id, idx_type, order, &skip, link_iterate_deprec_cb, iter_info)) < 0) TEST_ERROR - if(ret != CORDER_ITER_STOP) TEST_ERROR - if(iter_info->ncalled != 3) TEST_ERROR + if ((ret = H5Literate1(group_id, idx_type, order, &skip, link_iterate_deprec_cb, iter_info)) < 0) + TEST_ERROR + if (ret != CORDER_ITER_STOP) + TEST_ERROR + if (iter_info->ncalled != 3) + TEST_ERROR /* Iterate over links in group, stopping in the middle, with H5Giterate() */ iter_info->nskipped = (unsigned)(gskip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if((ret = H5Giterate(group_id, ".", &gskip, group_iterate_deprec_cb, iter_info)) < 0) TEST_ERROR - if(ret != CORDER_ITER_STOP) TEST_ERROR - if(iter_info->ncalled != 3) TEST_ERROR + if ((ret = H5Giterate(group_id, ".", &gskip, group_iterate_deprec_cb, iter_info)) < 0) + TEST_ERROR + if (ret != CORDER_ITER_STOP) + TEST_ERROR + if (iter_info->ncalled != 3) + TEST_ERROR /* Check for iteration routine indicating failure */ skip = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate1(group_id, idx_type, order, &skip, link_iterate_fail_deprec_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Success */ return SUCCEED; @@ -5127,177 +6448,219 @@ error: static int link_iterate_deprec(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - link_iter_info_t iter_info; /* Iterator info */ - hbool_t *visited = NULL; /* Array of flags for visiting links */ - hsize_t skip; /* # of links to skip in group */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + link_iter_info_t iter_info; /* Iterator info */ + hbool_t * visited = NULL; /* Array of flags for visiting links */ + hsize_t skip; /* # of links to skip in group */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Allocate the "visited link" array */ iter_info.max_visit = max_compact * 2; - if(NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) TEST_ERROR + if (NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) + TEST_ERROR iter_info.visited = visited; /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("iterating over links by creation order index in increasing order w/creation order index using deprecated routines") + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + TESTING("iterating over links by creation order index in increasing order " + "w/creation order index using deprecated routines") else - TESTING("iterating over links by creation order index in increasing order w/o creation order index using deprecated routines") + TESTING("iterating over links by creation order index in increasing order w/o " + "creation order index using deprecated routines") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("iterating over links by creation order index in decreasing order w/creation order index using deprecated routines") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING("iterating over links by creation order index in decreasing order " + "w/creation order index using deprecated routines") else - TESTING("iterating over links by creation order index in decreasing order w/o creation order index using deprecated routines") + TESTING("iterating over links by creation order index in decreasing order w/o " + "creation order index using deprecated routines") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) - TESTING("iterating over links by creation order index in native order w/creation order index using deprecated routines") + if (use_index) + TESTING("iterating over links by creation order index in native order w/creation " + "order index using deprecated routines") else - TESTING("iterating over links by creation order index in native order w/o creation order index using deprecated routines") + TESTING("iterating over links by creation order index in native order w/o " + "creation order index using deprecated routines") } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("iterating over links by name index in increasing order w/creation order index using deprecated routines") + if (order == H5_ITER_INC) { + if (use_index) + TESTING("iterating over links by name index in increasing order w/creation order " + "index using deprecated routines") else - TESTING("iterating over links by name index in increasing order w/o creation order index using deprecated routines") + TESTING("iterating over links by name index in increasing order w/o creation " + "order index using deprecated routines") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("iterating over links by name index in decreasing order w/creation order index using deprecated routines") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING("iterating over links by name index in decreasing order w/creation order " + "index using deprecated routines") else - TESTING("iterating over links by name index in decreasing order w/o creation order index using deprecated routines") + TESTING("iterating over links by name index in decreasing order w/o creation " + "order index using deprecated routines") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) - TESTING("iterating over links by name index in native order w/creation order index using deprecated routines") + if (use_index) + TESTING("iterating over links by name index in native order w/creation order " + "index using deprecated routines") else - TESTING("iterating over links by name index in native order w/o creation order index using deprecated routines") + TESTING("iterating over links by name index in native order w/o creation order " + "index using deprecated routines") } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | + (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < + 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Check for iteration on empty group */ /* (should be OK) */ - if(H5Literate1(group_id, idx_type, order, NULL, link_iterate_deprec_cb, NULL) < 0) TEST_ERROR + if (H5Literate1(group_id, idx_type, order, NULL, link_iterate_deprec_cb, NULL) < 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < max_compact; u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (compact) */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound iteration on compact group */ skip = (hsize_t)u; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate1(group_id, idx_type, order, &skip, link_iterate_deprec_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Test iteration over links in compact group */ - if(link_iterate_check_deprec(group_id, idx_type, order, u, &iter_info) < 0) TEST_ERROR + if (link_iterate_check_deprec(group_id, idx_type, order, u, &iter_info) < 0) + TEST_ERROR /* Create more links, to push group into dense form */ - for(; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + for (; u < (max_compact * 2); u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (dense) */ - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound iteration on dense group */ skip = (hsize_t)u; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate1(group_id, idx_type, order, &skip, link_iterate_deprec_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Test iteration over links in dense group */ - if(link_iterate_check_deprec(group_id, idx_type, order, u, &iter_info) < 0) TEST_ERROR - + if (link_iterate_check_deprec(group_id, idx_type, order, u, &iter_info) < 0) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Free resources */ - if(visited) + if (visited) HDfree(visited); return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; - if(visited) + if (visited) HDfree(visited); return FAIL; @@ -5315,53 +6678,54 @@ error: static int link_iterate_old_deprec_cb(hid_t group_id, const char *link_name, const H5L_info1_t *info, void *_op_data) { - link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ - char objname[NAME_BUF_SIZE]; /* Object name */ - H5L_info1_t my_info; /* Local link info */ + link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ + char objname[NAME_BUF_SIZE]; /* Object name */ + H5L_info1_t my_info; /* Local link info */ /* Increment # of times the callback was called */ op_data->ncalled++; /* Get the link information directly to compare */ - if(H5Lget_info1(group_id, link_name, &my_info, H5P_DEFAULT) < 0) + if (H5Lget_info1(group_id, link_name, &my_info, H5P_DEFAULT) < 0) return H5_ITER_ERROR; /* Check more things for link iteration (vs. group iteration) */ - if(info) { + if (info) { /* Compare link info structs */ - if(info->type != my_info.type) + if (info->type != my_info.type) return H5_ITER_ERROR; - if(info->corder_valid != my_info.corder_valid) + if (info->corder_valid != my_info.corder_valid) return H5_ITER_ERROR; - if(info->corder != my_info.corder) + if (info->corder != my_info.corder) return H5_ITER_ERROR; - if(info->cset != my_info.cset) + if (info->cset != my_info.cset) return H5_ITER_ERROR; - if(H5F_addr_ne(info->u.address, my_info.u.address)) + if (H5F_addr_ne(info->u.address, my_info.u.address)) return H5_ITER_ERROR; } /* end if */ /* Verify name of link */ - HDsnprintf(objname, sizeof(objname), "filler %02u", (info ? (unsigned)op_data->curr : (unsigned)((op_data->ncalled - 1) + op_data->nskipped))); - if(HDstrcmp(link_name, objname)) + HDsnprintf(objname, sizeof(objname), "filler %02u", + (info ? (unsigned)op_data->curr : (unsigned)((op_data->ncalled - 1) + op_data->nskipped))); + if (HDstrcmp(link_name, objname)) return H5_ITER_ERROR; /* Check if we've visited this link before */ - if((size_t)op_data->curr >= op_data->max_visit) + if ((size_t)op_data->curr >= op_data->max_visit) return H5_ITER_ERROR; - if(op_data->visited[op_data->curr]) + if (op_data->visited[op_data->curr]) return H5_ITER_ERROR; op_data->visited[op_data->curr] = TRUE; /* Advance to next value, in correct direction */ - if(op_data->order != H5_ITER_DEC) + if (op_data->order != H5_ITER_DEC) op_data->curr++; else op_data->curr--; /* Check for stopping in the middle of iterating */ - if(op_data->stop > 0) - if(--op_data->stop == 0) + if (op_data->stop > 0) + if (--op_data->stop == 0) return CORDER_ITER_STOP; return H5_ITER_CONT; @@ -5393,141 +6757,173 @@ group_iterate_old_deprec_cb(hid_t group_id, const char *link_name, void *_op_dat *------------------------------------------------------------------------- */ static int -link_iterate_old_check_deprec(hid_t group_id, H5_iter_order_t order, unsigned max_links, link_iter_info_t *iter_info) +link_iterate_old_check_deprec(hid_t group_id, H5_iter_order_t order, unsigned max_links, + link_iter_info_t *iter_info) { - unsigned v; /* Local index variable */ - hsize_t skip; /* # of links to skip in group */ - int gskip; /* # of links to skip in group, with H5Giterate */ - herr_t ret; /* Generic return value */ + unsigned v; /* Local index variable */ + hsize_t skip; /* # of links to skip in group */ + int gskip; /* # of links to skip in group, with H5Giterate */ + herr_t ret; /* Generic return value */ /* Iterate over links in group */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Literate1(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_deprec_cb, iter_info) < 0) TEST_ERROR + if (H5Literate1(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_deprec_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(skip != max_links) TEST_ERROR - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + if (skip != max_links) + TEST_ERROR + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR /* Iterate over links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Giterate(group_id, ".", &gskip, group_iterate_old_deprec_cb, iter_info) < 0) TEST_ERROR + if (H5Giterate(group_id, ".", &gskip, group_iterate_old_deprec_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(gskip != (int)max_links) TEST_ERROR - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + if (gskip != (int)max_links) + TEST_ERROR + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR /* Skip over some links in group */ iter_info->nskipped = (unsigned)(skip = max_links / 2); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Literate1(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_deprec_cb, iter_info) < 0) TEST_ERROR + if (H5Literate1(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_deprec_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(skip != max_links) TEST_ERROR - if(order == H5_ITER_INC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v + (max_links / 2)] == FALSE) TEST_ERROR + if (skip != max_links) + TEST_ERROR + if (order == H5_ITER_INC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v + (max_links / 2)] == FALSE) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == TRUE) nvisit++; - if(nvisit != (max_links / 2)) TEST_ERROR + if (nvisit != (max_links / 2)) + TEST_ERROR } /* end else */ /* Skip over some links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Giterate(group_id, ".", &gskip, group_iterate_old_deprec_cb, iter_info) < 0) TEST_ERROR + if (H5Giterate(group_id, ".", &gskip, group_iterate_old_deprec_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(gskip != (int)max_links) TEST_ERROR - if(order == H5_ITER_INC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v + (max_links / 2)] == FALSE) TEST_ERROR + if (gskip != (int)max_links) + TEST_ERROR + if (order == H5_ITER_INC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v + (max_links / 2)] == FALSE) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == TRUE) nvisit++; - if(nvisit != (max_links / 2)) TEST_ERROR + if (nvisit != (max_links / 2)) + TEST_ERROR } /* end else */ /* Iterate over links in group, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if((ret = H5Literate1(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_deprec_cb, iter_info)) < 0) TEST_ERROR - if(ret != CORDER_ITER_STOP) TEST_ERROR - if(iter_info->ncalled != 3) TEST_ERROR + if ((ret = H5Literate1(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_deprec_cb, iter_info)) < 0) + TEST_ERROR + if (ret != CORDER_ITER_STOP) + TEST_ERROR + if (iter_info->ncalled != 3) + TEST_ERROR /* Iterate over links in group, stopping in the middle, with H5Giterate() */ iter_info->nskipped = (unsigned)(gskip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if((ret = H5Giterate(group_id, ".", &gskip, group_iterate_old_deprec_cb, iter_info)) < 0) TEST_ERROR - if(ret != CORDER_ITER_STOP) TEST_ERROR - if(iter_info->ncalled != 3) TEST_ERROR + if ((ret = H5Giterate(group_id, ".", &gskip, group_iterate_old_deprec_cb, iter_info)) < 0) + TEST_ERROR + if (ret != CORDER_ITER_STOP) + TEST_ERROR + if (iter_info->ncalled != 3) + TEST_ERROR /* Check for iteration routine indicating failure */ skip = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate1(group_id, H5_INDEX_NAME, order, &skip, link_iterate_fail_deprec_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for iteration w/bad location ID */ skip = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate1((hid_t)(-1), H5_INDEX_NAME, order, &skip, link_iterate_fail_deprec_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Giterate((hid_t)(-1), ".", &gskip, group_iterate_old_deprec_cb, iter_info); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Success */ return SUCCEED; @@ -5548,110 +6944,130 @@ error: static int link_iterate_old_deprec(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - H5_iter_order_t order; /* Order within in the index */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - link_iter_info_t iter_info; /* Iterator info */ - hbool_t *visited = NULL; /* Array of flags for visiting links */ - hsize_t skip; /* # of links to skip in group */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + H5_iter_order_t order; /* Order within in the index */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + link_iter_info_t iter_info; /* Iterator info */ + hbool_t * visited = NULL; /* Array of flags for visiting links */ + hsize_t skip; /* # of links to skip in group */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Allocate the "visited link" array */ iter_info.max_visit = CORDER_NLINKS; - if(NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) TEST_ERROR + if (NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) + TEST_ERROR iter_info.visited = visited; /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Print appropriate test message */ - if(order == H5_ITER_INC) { - TESTING("iterating over links by name index in increasing order in old-style group using deprecated routines") + if (order == H5_ITER_INC) { + TESTING("iterating over links by name index in increasing order in old-style group using " + "deprecated routines") } /* end if */ - else if(order == H5_ITER_DEC) { - TESTING("iterating over links by name index in decreasing order in old-style group using deprecated routines") + else if (order == H5_ITER_DEC) { + TESTING("iterating over links by name index in decreasing order in old-style group using " + "deprecated routines") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - TESTING("iterating over links by name index in native order in old-style group using deprecated routines") + TESTING("iterating over links by name index in native order in old-style group using deprecated " + "routines") } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check for iteration on empty group */ /* (should be OK) */ - if(H5Literate1(group_id, H5_INDEX_NAME, order, NULL, link_iterate_old_deprec_cb, NULL) < 0) TEST_ERROR + if (H5Literate1(group_id, H5_INDEX_NAME, order, NULL, link_iterate_old_deprec_cb, NULL) < 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < CORDER_NLINKS; u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (symbol table) */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound iteration on old-style group */ skip = (hsize_t)u; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate1(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_deprec_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for iteration on creation order */ /* (should fail) */ skip = (hsize_t)0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate1(group_id, H5_INDEX_CRT_ORDER, order, &skip, link_iterate_old_deprec_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Test iteration over links in group */ - if(link_iterate_old_check_deprec(group_id, order, u, &iter_info) < 0) TEST_ERROR + if (link_iterate_old_check_deprec(group_id, order, u, &iter_info) < 0) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ /* Free resources */ - if(visited) + if (visited) HDfree(visited); return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; - if(visited) + if (visited) HDfree(visited); return FAIL; } /* end link_iterate_old_deprec() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: external_link_root * @@ -5664,16 +7080,16 @@ error: static int external_link_root(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5L_info2_t linfo; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; - const char *file; /* File from external link */ - const char *path; /* Path from external link */ - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info2_t linfo; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + const char *file; /* File from external link */ + const char *path; /* Path from external link */ + + if (new_format) TESTING("external link to root (w/new group format)") else TESTING("external link to root") @@ -5683,35 +7099,43 @@ external_link_root(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create file to point to */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Check that external links are registered with the library */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR /* Create file with link to first file */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to object in first file */ - if(H5Lcreate_external(filename1, "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Check information for external link */ - if(H5Lget_info2(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; - if(H5L_TYPE_EXTERNAL != linfo.type) { + if (H5Lget_info2(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) + goto error; + if (H5L_TYPE_EXTERNAL != linfo.type) { H5_FAILED(); HDputs(" Unexpected object type - should have been an external link"); goto error; } - if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR - if(HDstrcmp(file, filename1)) { + if (H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) + TEST_ERROR + if (HDstrcmp(file, filename1)) { H5_FAILED(); HDputs(" External link file name incorrect"); goto error; } - if(HDstrcmp(path, "/")) { + if (HDstrcmp(path, "/")) { H5_FAILED(); HDputs(" External link path incorrect"); goto error; @@ -5719,115 +7143,149 @@ external_link_root(hid_t fapl, hbool_t new_format) /* Create external link to object in first file */ /* (add a few extra '/'s to make certain library normalizes external link object names) */ - if(H5Lcreate_external(filename1, "///", fid, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "///", fid, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Check information for external link */ - if(H5Lget_info2(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) goto error; - if(H5L_TYPE_EXTERNAL != linfo.type) { + if (H5Lget_info2(fid, "ext_link", &linfo, H5P_DEFAULT) < 0) + goto error; + if (H5L_TYPE_EXTERNAL != linfo.type) { H5_FAILED(); HDputs(" Unexpected object type - should have been an external link"); goto error; } - if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) TEST_ERROR - if(HDstrcmp(file, filename1)) { + if (H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lunpack_elink_val(objname, linfo.u.val_size, NULL, &file, &path) < 0) + TEST_ERROR + if (HDstrcmp(file, filename1)) { H5_FAILED(); HDputs(" External link file name incorrect"); goto error; } - if(HDstrcmp(path, "/")) { + if (HDstrcmp(path, "/")) { H5_FAILED(); HDputs(" External link path incorrect"); goto error; } /* Close and re-open file to ensure that data is written to disk */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((fid = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close external object (lets first file close) */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create a new object using H5Gcreate2 through the external link * directly */ - if((gid = H5Gcreate2(fid, "ext_link/newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "ext_link/newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close file and group */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); /* Open first file again with read-only access and check on objects created */ - if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open objects created through external link */ - if((gid = H5Gopen2(fid, "new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gid2 = H5Gopen2(fid, "newer_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((gid2 = H5Gopen2(fid, "newer_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check names */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/new_group")) TEST_ERROR - if(H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/newer_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/new_group")) + TEST_ERROR + if (H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/newer_group")) + TEST_ERROR /* Close opened objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); /* Verify that new objects can't be created through a read-only external * link. */ - if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gcreate2(fid, "ext_link/readonly_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY - if(gid >= 0) TEST_ERROR + } + H5E_END_TRY + if (gid >= 0) + TEST_ERROR /* Close second file again */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_root() */ - /*------------------------------------------------------------------------- * Function: external_link_path * @@ -5841,13 +7299,13 @@ error: static int external_link_path(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("external link to object on path (w/new group format)") else TESTING("external link to object on path") @@ -5857,78 +7315,99 @@ external_link_path(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create file to point to */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create object down a path */ - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if((gid = H5Gcreate2(fid, "A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if((gid = H5Gcreate2(fid, "A/B/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "A/B/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create file with link to first file */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to object in first file */ - if(H5Lcreate_external(filename1, "/A/B/C", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/A/B/C", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/A/B/C")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/A/B/C")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close external object (lets first file close) */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close second file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file again and check on object created */ - if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open object created through external link */ - if((gid = H5Gopen2(fid, "/A/B/C/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/A/B/C/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/A/B/C/new_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/A/B/C/new_group")) + TEST_ERROR /* Close opened object */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_path() */ - /*------------------------------------------------------------------------- * Function: external_link_mult * @@ -5942,15 +7421,13 @@ error: static int external_link_mult(hid_t fapl, hbool_t new_format) { - hid_t fid = -1, fid2 = -1; /* File IDs */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE]; /* Names of files to externally link across */ - - if(new_format) + hid_t fid = -1, fid2 = -1; /* File IDs */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE]; /* Names of files to externally link across */ + + if (new_format) TESTING("external links across multiple files (w/new group format)") else TESTING("external links across multiple files") @@ -5962,130 +7439,174 @@ external_link_mult(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[6], fapl, filename4, sizeof filename4); /* Create first file to point to */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create object down a path */ - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if((gid = H5Gcreate2(fid, "A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if((gid = H5Gcreate2(fid, "A/B/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "A/B/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file to point to */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link down a path */ - if((gid = H5Gcreate2(fid, "D", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "D", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if((gid = H5Gcreate2(fid, "D/E", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "D/E", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create external link to object in first file */ - if(H5Lcreate_external(filename1, "/A/B/C", gid, "F", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/A/B/C", gid, "F", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create third file to point to */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link down a path */ - if((gid = H5Gcreate2(fid, "G", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "G", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if((gid = H5Gcreate2(fid, "G/H", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "G/H", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create external link to object in second file */ - if(H5Lcreate_external(filename2, "/D/E/F", gid, "I", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/D/E/F", gid, "I", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create file with link to third file */ - if((fid=H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to object in first file */ - if(H5Lcreate_external(filename3, "/G/H/I", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename3, "/G/H/I", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/A/B/C")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/A/B/C")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close external object (lets first file close) */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close second file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file again and check on object created */ - if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open object created through external link */ - if((gid = H5Gopen2(fid, "/A/B/C/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/A/B/C/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/A/B/C/new_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/A/B/C/new_group")) + TEST_ERROR /* Close opened object */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open an object through external links */ - if((fid = H5Fopen(filename4, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename4, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* The intermediate files should not stay open. Replace one of them with a new file. */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Open the other with write access and delete the external link in it */ - if((fid2 = H5Fopen(filename3, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if(H5Ldelete(fid2, "G/H/I", H5P_DEFAULT) < 0) TEST_ERROR + if ((fid2 = H5Fopen(filename3, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + if (H5Ldelete(fid2, "G/H/I", H5P_DEFAULT) < 0) + TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Cleanup */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_mult() */ - /*------------------------------------------------------------------------- * Function: external_link_self * @@ -6098,15 +7619,15 @@ error: static int external_link_self(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t lcpl_id = -1; /* Link Creation Property List ID */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; - char filename3[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t lcpl_id = -1; /* Link Creation Property List ID */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + char filename3[NAME_BUF_SIZE]; + + if (new_format) TESTING("external link to self (w/new group format)") else TESTING("external link to self") @@ -6117,116 +7638,156 @@ external_link_self(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[3], fapl, filename3, sizeof filename1); /* Create file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create an lcpl with intermediate group creation set */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) + TEST_ERROR /* Create a series of groups within the file: /A/B and /X/Y/Z */ - if((gid = H5Gcreate2(fid, "A/B", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "X/Y", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "A/B", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "X/Y", lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if(H5Pclose (lcpl_id) < 0) TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR /* Create external link to own root group*/ - if(H5Lcreate_external(filename1, "/X", fid, "A/B/C", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/X", fid, "A/B/C", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "A/B/C/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "A/B/C/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/X")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/X")) + TEST_ERROR /* Create object through external link */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close created group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close object opened through external link */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Check on object created */ - if((gid = H5Gopen2(fid, "X/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "X/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/X/new_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/X/new_group")) + TEST_ERROR /* Close opened object */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Complicate things. Use this file as an intermediate file in a chain * of external links that will go: file2 -> file1 -> file1 -> file3 */ /* Create file2 with an external link to file1 */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR - if(H5Lcreate_external(filename1, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file2 */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create file3 as a target */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "end", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "end", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open file1 and create an extlink pointing to file3 */ - if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid, "/X/Y/Z", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename3, "/", fid, "/X/Y/Z", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file1 */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Re-open file2 and traverse through file1 (with its recursive extlink) to file3 */ - if((fid=H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR - if((gid = H5Gopen2(fid, "ext_link/B/C/Y/Z/end", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ext_link/B/C/Y/Z/end", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create object through external link */ - if((gid2 = H5Gcreate2(gid, "newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "newer_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Cleanup */ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open up file3 and make sure the object was created successfully */ - if((fid = H5Fopen(filename3, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename3, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, "end/newer_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "end/newer_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Cleanup */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Pclose(lcpl_id); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_self() */ - /*------------------------------------------------------------------------- * Function: external_link_pingpong * @@ -6254,13 +7815,12 @@ error: static int external_link_pingpong(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1), gid2 = (-1); /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - if(new_format) + if (new_format) TESTING("external links back and forth (w/new group format)") else TESTING("external links back and forth") @@ -6270,84 +7830,110 @@ external_link_pingpong(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external links for chain */ - if(H5Lcreate_external(filename2, "/link2", fid, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link4", fid, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link6", fid, "link5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/link2", fid, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link4", fid, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link6", fid, "link5", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create final object */ - if((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external links for chain */ - if(H5Lcreate_external(filename1, "/link3", fid, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/link5", fid, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/final", fid, "link6", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/link3", fid, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/link5", fid, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/final", fid, "link6", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "link1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "link1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/final")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/final")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close external object (lets first file close) */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file again and check on object created */ - if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open object created through external link */ - if((gid = H5Gopen2(fid, "/final/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/final/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/final/new_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/final/new_group")) + TEST_ERROR /* Close opened object */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_pingpong() */ - /*------------------------------------------------------------------------- * Function: external_link_toomany * @@ -6381,13 +7967,12 @@ error: static int external_link_toomany(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - if(new_format) + if (new_format) TESTING("too many external links (w/new group format)") else TESTING("too many external links") @@ -6403,50 +7988,75 @@ external_link_toomany(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external links for chain */ - if(H5Lcreate_external(filename2, "/link2", fid, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link4", fid, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link6", fid, "link5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link8", fid, "link7", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link10", fid, "link9", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link12", fid, "link11", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link14", fid, "link13", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/link16", fid, "link15", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/final", fid, "link17", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/link2", fid, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link4", fid, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link6", fid, "link5", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link8", fid, "link7", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link10", fid, "link9", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link12", fid, "link11", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link14", fid, "link13", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/link16", fid, "link15", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/final", fid, "link17", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external links for chain */ - if(H5Lcreate_external(filename1, "/link3", fid, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/link5", fid, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/link7", fid, "link6", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/link9", fid, "link8", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/link11", fid, "link10", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/link13", fid, "link12", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/link15", fid, "link14", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/link17", fid, "link16", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/link3", fid, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/link5", fid, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/link7", fid, "link6", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/link9", fid, "link8", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/link11", fid, "link10", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/link13", fid, "link12", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/link15", fid, "link14", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/link17", fid, "link16", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create final object */ - if((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "link1", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; if (gid >= 0) { H5_FAILED(); HDprintf("%d: Should have failed for sequence of too many nested links.", __LINE__); @@ -6454,37 +8064,45 @@ external_link_toomany(hid_t fapl, hbool_t new_format) } /* Open object through external link */ - if((gid = H5Gopen2(fid, "link3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "link3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/final")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/final")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close external object */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid2); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_toomany() */ - /*------------------------------------------------------------------------- * Function: external_link_dangling * @@ -6498,14 +8116,13 @@ error: static int external_link_dangling(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - hid_t rid = -1; /* Root Group ID */ - hid_t status = -1; /* Status */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + hid_t rid = -1; /* Root Group ID */ + hid_t status = -1; /* Status */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + + if (new_format) TESTING("dangling external links (w/new group format)") else TESTING("dangling external links") @@ -6515,32 +8132,41 @@ external_link_dangling(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create dangling external links */ - if(H5Lcreate_external("missing", "/missing", fid, "no_file", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/missing", fid, "no_object", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external("missing", "/missing", fid, "no_file", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/missing", fid, "no_object", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file (for dangling object test) */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Get root group ID */ - if((rid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) TEST_ERROR; + if ((rid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + TEST_ERROR; /* Open object through dangling file external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "no_file", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; if (gid >= 0) { H5_FAILED(); HDputs(" Should have failed for sequence of too many nested links."); @@ -6548,9 +8174,11 @@ external_link_dangling(hid_t fapl, hbool_t new_format) } /* Open object through dangling object external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "no_object", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; if (gid >= 0) { H5_FAILED(); HDputs(" Should have failed for sequence of too many nested links."); @@ -6558,33 +8186,38 @@ external_link_dangling(hid_t fapl, hbool_t new_format) } /* Try to get name of object by index through dangling file external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Lget_name_by_idx(rid, "no_file", H5_INDEX_NAME, H5_ITER_INC, 0, NULL, 0, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; if (status >= 0) { H5_FAILED(); - HDputs(" Retreiving name of object by index through dangling file external link should have failed."); + HDputs( + " Retreiving name of object by index through dangling file external link should have failed."); } /* end if */ /* Close root group */ - if(H5Gclose(rid) < 0) TEST_ERROR + if (H5Gclose(rid) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_dangling() */ - /*------------------------------------------------------------------------- * Function: external_link_prefix * @@ -6603,14 +8236,12 @@ error: static int external_link_prefix(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - hid_t gapl_id = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + hid_t gapl_id = -1; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via H5Pset_elink_prefix()(w/new group format)") else TESTING("external links via H5Pset_elink_prefix()") @@ -6622,34 +8253,43 @@ external_link_prefix(hid_t fapl, hbool_t new_format) /* create tmp_links directory and get current working directory path */ if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR + TEST_ERROR /* set up name for target file: "tmp_links/extlinks2" */ h5_fixname(FILENAME[17], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file (without the absolute path) */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* set up prefix for external link */ - if((gapl_id = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR - if(H5Pset_elink_prefix(gapl_id, TMPDIR) < 0) TEST_ERROR + if ((gapl_id = H5Pcreate(H5P_GROUP_ACCESS)) < 0) + TEST_ERROR + if (H5Pset_elink_prefix(gapl_id, TMPDIR) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", gapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file from pathnames set via H5Pset_elink_prefix() */ if (gid < 0) { @@ -6659,26 +8299,30 @@ external_link_prefix(hid_t fapl, hbool_t new_format) } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_prefix() */ - /*------------------------------------------------------------------------- * Function: external_link_abs_mainpath: test 3 * * Purpose: 1. target link: "extlinks3" - * 2. main file: Linux:"/CWD/tmp_links/extlinks0"; Windows: ":/CWD/tmp_links/extlinks0" + * 2. main file: Linux:"/CWD/tmp_links/extlinks0"; Windows: ":/CWD/tmp_links/extlinks0" * 3. target file: "tmp_links/extlinks3" * Should be able to access the target file via the main file's absolute path * @@ -6689,15 +8333,12 @@ error: static int external_link_abs_mainpath(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via main file's absolute path (w/new group format)") else TESTING("external links via main file's absolute path") @@ -6708,7 +8349,8 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[19], fapl, filename3, sizeof filename3); /* create tmp_links directory and get current working directory path */ - if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || + (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR /* @@ -6720,48 +8362,58 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file from absolute path set for main file */ - if(gid < 0) { - H5_FAILED(); - HDputs(" Should have found the file in tmp_links directory."); - goto error; + if (gid < 0) { + H5_FAILED(); + HDputs(" Should have found the file in tmp_links directory."); + goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_abs_mainpath() */ - /*------------------------------------------------------------------------- * Function: external_link_rel_mainpath: test 4 * @@ -6777,13 +8429,11 @@ error: static int external_link_rel_mainpath(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("external links via main file's CWD + relative path(w/new group format)") else TESTING("external links via main file's CWD + relative path") @@ -6794,30 +8444,37 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR - /* set up name for main file: "tmp_links/extlinks0" */ + /* set up name for main file: "tmp_links/extlinks0" */ h5_fixname(FILENAME[13], fapl, filename1, sizeof filename1); /* set up name for target file: "tmp_links/extlinks4" */ h5_fixname(FILENAME[21], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file from the main file's relative pathname */ if (gid < 0) { @@ -6827,17 +8484,21 @@ external_link_rel_mainpath(hid_t fapl, hbool_t new_format) } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_rel_mainpath() */ @@ -6856,14 +8517,11 @@ error: static int external_link_cwd(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via current working directory(w/new group format)") else TESTING("external links via current working directory") @@ -6872,7 +8530,8 @@ external_link_cwd(hid_t fapl, hbool_t new_format) /* set up name for target file: "extlinks5" */ h5_fixname(FILENAME[22], fapl, filename2, sizeof filename2); - if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || + (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR /* @@ -6884,52 +8543,63 @@ external_link_cwd(hid_t fapl, hbool_t new_format) h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* Create the target file */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file from the current working directory */ - if(gid < 0) { + if (gid < 0) { H5_FAILED(); HDputs(" Should have found the file in current working directory"); goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_cwd() */ - /*------------------------------------------------------------------------- * Function: external_link_abstar: test 6 * - * Purpose: 1. target link: Linux:"/CWD/tmp_links/extlinks6"; Windows:":/CWD/tmp_links/extlinks6" + * Purpose: 1. target link: Linux:"/CWD/tmp_links/extlinks6"; Windows:":/CWD/tmp_links/extlinks6" * 2. main file: "extlinks0" * 3. target file: "tmp_links/extlinks6" * Should be able to access the target file's absolute path @@ -6941,15 +8611,12 @@ error: static int external_link_abstar(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via target's absolute path (w/new group format)") else TESTING("external links via target's absolute path") @@ -6957,8 +8624,9 @@ external_link_abstar(hid_t fapl, hbool_t new_format) /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); - /* create tmp_links directory and get current working directory path */ - if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) + /* create tmp_links directory and get current working directory path */ + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || + (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR /* @@ -6973,50 +8641,63 @@ external_link_abstar(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[23], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file with abolute path */ - if(gid < 0) { + if (gid < 0) { H5_FAILED(); HDputs(" Should have found the file in tmp_links directory."); goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_abstar() */ /*------------------------------------------------------------------------- * Function: external_link_abstar_cur: test 7 * - * Purpose: 1. target link: Linux: "/CWD/tmp_links/extlinks7"; Windows: ":/CWD/tmp_links/extlinks7" + * Purpose: 1. target link: Linux: "/CWD/tmp_links/extlinks7"; Windows: ":/CWD/tmp_links/extlinks7" * 2. main file: "extlinks0" * 3. target file: "extlinks7" * Should be able to access the target file via the main file's CWD. @@ -7028,15 +8709,12 @@ error: static int external_link_abstar_cur(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via main file's CWD (w/new group format)") else TESTING("external links via main file's CWD") @@ -7048,35 +8726,44 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[24], fapl, filename3, sizeof filename3); /* create tmp_links directory and get current working directory path */ - if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || + (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR - /* - * set up name for external linked target file: - * Linux: "/CWD/tmp_links/extlinks7" - * Windows: ":/CWD/tmp_links/extlinks7" - */ + /* + * set up name for external linked target file: + * Linux: "/CWD/tmp_links/extlinks7" + * Windows: ":/CWD/tmp_links/extlinks7" + */ fix_ext_filename(tmpname, cwdpath, FILENAME[25]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file from main file's current working directory */ if (gid < 0) { @@ -7086,21 +8773,24 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_abstar_cur() */ - /*------------------------------------------------------------------------- * Function: external_link_reltar: test 8 * @@ -7116,12 +8806,11 @@ error: static int external_link_reltar(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("external links via main file's CWD + target's relative path(w/new group format)") else TESTING("external links via main file's CWD + target's relative path") @@ -7130,50 +8819,59 @@ external_link_reltar(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); /* create tmp_links directory */ - if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR /* set up name for target file name: "tmp_links/extlinks8" */ /* set up name for external linked target file: "tmp_links/extlinks8" */ h5_fixname(FILENAME[26], fapl, filename2, sizeof filename2); /* Create the target file */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "///A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "///A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); HDputs(" Should have found the file in tmp_links directory."); goto error; } /* end if */ /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_reltar() */ - /*------------------------------------------------------------------------- * Function: external_link_chdir: test 9 * @@ -7191,13 +8889,11 @@ error: static int external_link_chdir(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("external links via chdir and found in current working directory (w/new group format)") else TESTING("external links via chdir and found in current working directory") @@ -7208,34 +8904,44 @@ external_link_chdir(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[27], fapl, filename2, sizeof filename2); /* create tmp_links directory */ - if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR /* set up name for target file name ("tmp_links/extlinks9") */ h5_fixname(FILENAME[28], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - if (HDchdir(TMPDIR) < 0) TEST_ERROR + if (HDchdir(TMPDIR) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; - if (HDchdir("..") < 0) TEST_ERROR + if (HDchdir("..") < 0) + TEST_ERROR /* * Should be able to find the target file from: @@ -7248,21 +8954,24 @@ external_link_chdir(hid_t fapl, hbool_t new_format) } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_chdir() */ - /*------------------------------------------------------------------------- * Function: external_set_elink_fapl1: test 10 * @@ -7286,29 +8995,27 @@ error: static int external_set_elink_fapl1(hid_t fapl, hbool_t new_format) { - hid_t fid=(-1); - hid_t fidA=(-1), fidB=(-1); - hid_t gidA=(-1), gidB=(-1); - hid_t oidA=(-1), oidB=(-1); - char filename1[NAME_BUF_SIZE], - filename2A[NAME_BUF_SIZE], - filename2B[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - hid_t fam_fapl=-1, multi_fapl=-1; - hid_t lapl_idA=-1, lapl_idB=-1; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][64]; + hid_t fid = (-1); + hid_t fidA = (-1), fidB = (-1); + hid_t gidA = (-1), gidB = (-1); + hid_t oidA = (-1), oidB = (-1); + char filename1[NAME_BUF_SIZE], filename2A[NAME_BUF_SIZE], filename2B[NAME_BUF_SIZE], + tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; + hid_t fam_fapl = -1, multi_fapl = -1; + hid_t lapl_idA = -1, lapl_idB = -1; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][64]; H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; - if(new_format) + if (new_format) TESTING("H5Pset/get_elink_fapl() with different physical layouts (w/new group format)") else TESTING("H5Pset/get_elink_fapl() with different physical layouts") - if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || + (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR /* @@ -7321,25 +9028,26 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) /* create "family" fapl */ fam_fapl = h5_fileaccess(); - if(H5Pset_fapl_family(fam_fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) TEST_ERROR; + if (H5Pset_fapl_family(fam_fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR; /* set up name for external linked target file A: "extlinks16A" */ /* set up name for target file A: "extlinks16A" */ h5_fixname(FILENAME[37], fam_fapl, filename2A, sizeof filename2A); /* settings for multi file */ - HDmemset(memb_map, 0, sizeof memb_map); + HDmemset(memb_map, 0, sizeof memb_map); HDmemset(memb_fapl, 0, sizeof memb_fapl); HDmemset(memb_name, 0, sizeof memb_name); HDmemset(memb_addr, 0, sizeof memb_addr); HDmemset(sv, 0, sizeof sv); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { - memb_map[mt] = H5FD_MEM_SUPER; + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + memb_map[mt] = H5FD_MEM_SUPER; memb_fapl[mt] = H5P_DEFAULT; } /* end for */ - memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; + memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE; memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP; @@ -7350,57 +9058,71 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) HDsnprintf(sv[H5FD_MEM_BTREE], sizeof(sv[H5FD_MEM_BTREE]), "%%s-%c.h5", 'b'); memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; - memb_addr[H5FD_MEM_BTREE] = HADDR_MAX/6; + memb_addr[H5FD_MEM_BTREE] = HADDR_MAX / 6; HDsnprintf(sv[H5FD_MEM_DRAW], sizeof(sv[H5FD_MEM_DRAW]), "%%s-%c.h5", 'r'); memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; - memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/3; + memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 3; HDsnprintf(sv[H5FD_MEM_GHEAP], sizeof(sv[H5FD_MEM_GHEAP]), "%%s-%c.h5", 'g'); memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; - memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX/2; + memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX / 2; HDsnprintf(sv[H5FD_MEM_LHEAP], sizeof(sv[H5FD_MEM_LHEAP]), "%%s-%c.h5", 'l'); memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP]; - memb_addr[H5FD_MEM_LHEAP] = (HADDR_MAX/3)*2; + memb_addr[H5FD_MEM_LHEAP] = (HADDR_MAX / 3) * 2; HDsnprintf(sv[H5FD_MEM_OHDR], sizeof(sv[H5FD_MEM_OHDR]), "%%s-%c.h5", 'o'); memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR]; - memb_addr[H5FD_MEM_OHDR] = (HADDR_MAX/6)*5; + memb_addr[H5FD_MEM_OHDR] = (HADDR_MAX / 6) * 5; /* create "multi" fapl */ multi_fapl = h5_fileaccess(); - if(H5Pset_fapl_multi(multi_fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) TEST_ERROR; + if (H5Pset_fapl_multi(multi_fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) + TEST_ERROR; /* set up name for external linked target file B: "extlinks16B" */ /* set up name for target file B: "extlinks16B" */ h5_fixname(FILENAME[38], multi_fapl, filename2B, sizeof filename2B); /* Create target file A to be a "family" file */ - if((fidA=H5Fcreate(filename2A, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR - if((gidA=H5Gcreate2(fidA, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fidA = H5Fcreate(filename2A, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) + TEST_ERROR + if ((gidA = H5Gcreate2(fidA, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create target file B to be a "multi" file */ - if((fidB=H5Fcreate(filename2B, H5F_ACC_TRUNC, H5P_DEFAULT, multi_fapl)) < 0) TEST_ERROR - if((gidB=H5Gcreate2(fidB, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fidB = H5Fcreate(filename2B, H5F_ACC_TRUNC, H5P_DEFAULT, multi_fapl)) < 0) + TEST_ERROR + if ((gidB = H5Gcreate2(fidB, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target files */ - if(H5Gclose(gidA) < 0) TEST_ERROR - if(H5Gclose(gidB) < 0) TEST_ERROR - if(H5Fclose(fidA) < 0) TEST_ERROR - if(H5Fclose(fidB) < 0) TEST_ERROR + if (H5Gclose(gidA) < 0) + TEST_ERROR + if (H5Gclose(gidB) < 0) + TEST_ERROR + if (H5Fclose(fidA) < 0) + TEST_ERROR + if (H5Fclose(fidB) < 0) + TEST_ERROR /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file A:/A */ - if(H5Lcreate_external(filename2A, "/A", fid, "ext_linkA", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2A, "/A", fid, "ext_linkA", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create external link to target file B:/B */ - if(H5Lcreate_external(filename2B, "/B", fid, "ext_linkB", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2B, "/B", fid, "ext_linkB", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Set file access property list for link access to use the family driver */ - if((lapl_idA = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR - if(H5Pset_elink_fapl(lapl_idA, fam_fapl) < 0) TEST_ERROR + if ((lapl_idA = H5Pcreate(H5P_LINK_ACCESS)) < 0) + TEST_ERROR + if (H5Pset_elink_fapl(lapl_idA, fam_fapl) < 0) + TEST_ERROR /* open target object A */ oidA = H5Oopen(fid, "ext_linkA", lapl_idA); @@ -7413,8 +9135,10 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) } /* Set file access property list for link access to use the multi driver */ - if((lapl_idB = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR - if(H5Pset_elink_fapl(lapl_idB, multi_fapl) < 0) TEST_ERROR + if ((lapl_idB = H5Pcreate(H5P_LINK_ACCESS)) < 0) + TEST_ERROR + if (H5Pset_elink_fapl(lapl_idB, multi_fapl) < 0) + TEST_ERROR /* open target object B */ oidB = H5Oopen(fid, "ext_linkB", lapl_idB); @@ -7427,33 +9151,41 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) } /* closing */ - if(H5Pclose(lapl_idA) < 0) TEST_ERROR - if(H5Pclose(lapl_idB) < 0) TEST_ERROR - if(H5Pclose(fam_fapl) < 0) TEST_ERROR - if(H5Pclose(multi_fapl) < 0) TEST_ERROR - if(H5Oclose(oidA) < 0) TEST_ERROR - if(H5Oclose(oidB) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Pclose(lapl_idA) < 0) + TEST_ERROR + if (H5Pclose(lapl_idB) < 0) + TEST_ERROR + if (H5Pclose(fam_fapl) < 0) + TEST_ERROR + if (H5Pclose(multi_fapl) < 0) + TEST_ERROR + if (H5Oclose(oidA) < 0) + TEST_ERROR + if (H5Oclose(oidB) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Pclose (lapl_idA); - H5Pclose (lapl_idB); - H5Pclose (fam_fapl); - H5Pclose (multi_fapl); - H5Gclose (gidA); - H5Gclose (gidB); - H5Oclose (oidA); - H5Oclose (oidB); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(lapl_idA); + H5Pclose(lapl_idB); + H5Pclose(fam_fapl); + H5Pclose(multi_fapl); + H5Gclose(gidA); + H5Gclose(gidB); + H5Oclose(oidA); + H5Oclose(oidB); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_set_elink_fapl1() */ - /*------------------------------------------------------------------------- * Function: external_set_elink_fapl2: test 11 * @@ -7480,47 +9212,48 @@ error: static int external_set_elink_fapl2(hid_t fapl, hbool_t new_format) { - hid_t fid = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t core_fapl = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t dset = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t dapl_id = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - char *filename1 = NULL; - char *filename2 = NULL; - char *tmpname = NULL; - char *cwdpath = NULL; - hsize_t dims[2]; - int **points = NULL; - int *points_data = NULL; - int i, j, n; - h5_stat_size_t filesize; - h5_stat_size_t new_filesize; - - if(new_format) + hid_t fid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t core_fapl = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t dapl_id = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + char * filename1 = NULL; + char * filename2 = NULL; + char * tmpname = NULL; + char * cwdpath = NULL; + hsize_t dims[2]; + int ** points = NULL; + int * points_data = NULL; + int i, j, n; + h5_stat_size_t filesize; + h5_stat_size_t new_filesize; + + if (new_format) TESTING("H5Pset/get_elink_fapl() with same physical layout (w/new group format)") else TESTING("H5Pset/get_elink_fapl() with same physical layout") /* Set up file names and paths */ - if(NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename2 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename2 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || + (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR /* Set up data array */ - if(NULL == (points_data = (int *)HDcalloc(NUM40 * NUM40, sizeof(int)))) + if (NULL == (points_data = (int *)HDcalloc(NUM40 * NUM40, sizeof(int)))) TEST_ERROR; - if(NULL == (points = (int **)HDcalloc(NUM40, sizeof(points_data)))) + if (NULL == (points = (int **)HDcalloc(NUM40, sizeof(points_data)))) TEST_ERROR; for (i = 0; i < NUM40; i++) points[i] = points_data + (i * NUM40); @@ -7535,19 +9268,23 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* create fapl for the target file to be a "core" file */ core_fapl = h5_fileaccess(); - if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) TEST_ERROR + if (H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) + TEST_ERROR /* set up name for external linked target file: "extlinks17" */ /* set up name for target file: "extlinks17" */ h5_fixname(FILENAME[39], core_fapl, filename2, NAME_BUF_SIZE); /* Create the target file to be a "core" file */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR dims[0] = NUM40; dims[1] = NUM40; - if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR /* Create dataset creation property list */ if (dcpl_g == H5P_DEFAULT) @@ -7556,60 +9293,78 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) dcpl = H5Pcopy(dcpl_g); if (0 > dcpl) TEST_ERROR; - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) TEST_ERROR; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + TEST_ERROR; /* create "Dataset" in group "A" of target file */ - if((dset = H5Dcreate2(gid, "Dataset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if ((dset = H5Dcreate2(gid, "Dataset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Pclose(dcpl) < 0) TEST_ERROR - if(H5Sclose(space) < 0) TEST_ERROR - if(H5Dclose(dset) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Pclose(dcpl) < 0) + TEST_ERROR + if (H5Sclose(space) < 0) + TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* get size of target file */ filesize = h5_get_file_size(filename2, core_fapl); /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file: ext_link->extlinks17:/A/Dataset */ - if(H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* create fapl to be a "core" file without backing store */ - if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0) TEST_ERROR + if (H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0) + TEST_ERROR /* Set file access property list for link access to use the "core" driver */ - if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR - if(H5Pset_elink_fapl(dapl_id, core_fapl) < 0) TEST_ERROR + if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + TEST_ERROR + if (H5Pset_elink_fapl(dapl_id, core_fapl) < 0) + TEST_ERROR /* try to open the external linked target dataset */ did = H5Dopen2(fid, "ext_link", dapl_id); - if(did < 0) { + if (did < 0) { H5_FAILED(); HDputs(" Should succeed in opening the target dataset"); goto error; } /* Initialize the dataset */ - for(i = n = 0; i < NUM40; i++) - for(j = 0; j < NUM40; j++) + for (i = n = 0; i < NUM40; i++) + for (j = 0; j < NUM40; j++) points[i][j] = n++; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) TEST_ERROR + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) + TEST_ERROR - if(H5Pclose(dapl_id) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Pclose(dapl_id) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR new_filesize = h5_get_file_size(filename2, core_fapl); /* the file size should remain the same since there is no backing store */ - if(new_filesize != filesize) TEST_ERROR + if (new_filesize != filesize) + TEST_ERROR - if(H5Pclose(core_fapl) < 0) TEST_ERROR + if (H5Pclose(core_fapl) < 0) + TEST_ERROR HDfree(points); HDfree(points_data); @@ -7623,7 +9378,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(space); H5Dclose(dset); @@ -7632,7 +9388,8 @@ error: H5Dclose(did); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(points); HDfree(points_data); @@ -7645,7 +9402,6 @@ error: return FAIL; } /* end external_set_elink_fapl2() */ - /*------------------------------------------------------------------------- * Function: external_set_elink_fapl3: test 12 * @@ -7674,74 +9430,96 @@ error: static int external_set_elink_fapl3(hbool_t new_format) { - hid_t core_fapl = -1, stdio_fapl = -1; - hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl; + hid_t core_fapl = -1, stdio_fapl = -1; + hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl; - if(new_format) + if (new_format) TESTING("H5Pset/get_fapl() (w/new group format)") else TESTING("H5Pset/get_fapl()") /* create fapl for the target file to be a "core" file */ core_fapl = h5_fileaccess(); - if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) TEST_ERROR + if (H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0) + TEST_ERROR stdio_fapl = h5_fileaccess(); - if(H5Pset_fapl_stdio(stdio_fapl) < 0) TEST_ERROR + if (H5Pset_fapl_stdio(stdio_fapl) < 0) + TEST_ERROR /* Set file access property list for link access to use the "stdio" driver */ - if((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR - if(H5Pset_elink_fapl(lapl_id, stdio_fapl) < 0) TEST_ERROR + if ((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) + TEST_ERROR + if (H5Pset_elink_fapl(lapl_id, stdio_fapl) < 0) + TEST_ERROR /* Verify that the driver for the link's fapl is the "stdio" driver */ - if((l_fapl = H5Pget_elink_fapl(lapl_id)) < 0) TEST_ERROR - if(H5Pget_driver(l_fapl) != H5FD_STDIO) TEST_ERROR - if(H5Pclose(l_fapl) < 0) TEST_ERROR + if ((l_fapl = H5Pget_elink_fapl(lapl_id)) < 0) + TEST_ERROR + if (H5Pget_driver(l_fapl) != H5FD_STDIO) + TEST_ERROR + if (H5Pclose(l_fapl) < 0) + TEST_ERROR /* Set file access property list for link access to use the "core" driver */ - if(H5Pset_elink_fapl(lapl_id, core_fapl) < 0) TEST_ERROR + if (H5Pset_elink_fapl(lapl_id, core_fapl) < 0) + TEST_ERROR /* Make a copy of the link access property */ - if((new_lapl_id = H5Pcopy(lapl_id)) < 0) TEST_ERROR + if ((new_lapl_id = H5Pcopy(lapl_id)) < 0) + TEST_ERROR /* get the fapl set in lapl_id */ - if(H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR - if(H5Pclose(lapl_id) < 0) TEST_ERROR + if (H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) + TEST_ERROR + if (H5Pclose(lapl_id) < 0) + TEST_ERROR /* Try closing out_fapl, should succeed since H5Pget() should clone its fapl */ - if(H5Pclose(out_fapl) < 0) TEST_ERROR + if (H5Pclose(out_fapl) < 0) + TEST_ERROR /* Verify that the driver for the copied link's fapl is the "core" driver */ - if((l_fapl = H5Pget_elink_fapl(new_lapl_id)) < 0) TEST_ERROR - if(H5Pget_driver(l_fapl) != H5FD_CORE) TEST_ERROR + if ((l_fapl = H5Pget_elink_fapl(new_lapl_id)) < 0) + TEST_ERROR + if (H5Pget_driver(l_fapl) != H5FD_CORE) + TEST_ERROR /* get the fapl set in new_lapl_id */ - if(H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR - if(H5Premove(new_lapl_id, "external link fapl") < 0) TEST_ERROR + if (H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) + TEST_ERROR + if (H5Premove(new_lapl_id, "external link fapl") < 0) + TEST_ERROR /* Try closing out_fapl, should succeed since H5Pget() should clone its fapl */ - if(H5Pclose(out_fapl) < 0) TEST_ERROR + if (H5Pclose(out_fapl) < 0) + TEST_ERROR - if(H5Pclose(l_fapl) < 0) TEST_ERROR - if(H5Pclose(new_lapl_id) < 0) TEST_ERROR - if(H5Pclose(core_fapl) < 0) TEST_ERROR - if(H5Pclose(stdio_fapl) < 0) TEST_ERROR + if (H5Pclose(l_fapl) < 0) + TEST_ERROR + if (H5Pclose(new_lapl_id) < 0) + TEST_ERROR + if (H5Pclose(core_fapl) < 0) + TEST_ERROR + if (H5Pclose(stdio_fapl) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(l_fapl); H5Pclose(lapl_id); H5Pclose(new_lapl_id); H5Pclose(core_fapl); H5Pclose(stdio_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_set_elink_fapl3() */ - /*------------------------------------------------------------------------- * Function: external_set_elink_acc_flags * @@ -7754,13 +9532,12 @@ error: static int external_set_elink_acc_flags(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; - herr_t ret; - unsigned flags; + hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; + herr_t ret; + unsigned flags; - if(new_format) + if (new_format) TESTING("H5Pset/get_elink_acc_flags() (w/new group format)") else TESTING("H5Pset/get_elink_acc_flags()") @@ -7768,195 +9545,276 @@ external_set_elink_acc_flags(const char *env_h5_drvr, hid_t fapl, hbool_t new_fo /* Create parent and target files, and external link */ h5_fixname(FILENAME[40], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[41], fapl, filename2, sizeof filename2); - if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/", file1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if ((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/", file1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file2, leave file1 open (should be read-write) */ - if(H5Fclose(file2) < 0) TEST_ERROR + if (H5Fclose(file2) < 0) + TEST_ERROR /* Create new gapl, and set elink access flags to be H5F_ACC_RDONLY */ - if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR - if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) TEST_ERROR + if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) + TEST_ERROR + if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) + TEST_ERROR /* Verify "get" routine functionality */ - if(H5Pget_elink_acc_flags(gapl, &flags) < 0) TEST_ERROR - if(flags != H5F_ACC_RDONLY) TEST_ERROR + if (H5Pget_elink_acc_flags(gapl, &flags) < 0) + TEST_ERROR + if (flags != H5F_ACC_RDONLY) + TEST_ERROR /* Attempt to create a group through the external link using gapl (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl); - } H5E_END_TRY; - if(group != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (group != FAIL) + TEST_ERROR /* Close file1 and reopen with read only access */ - if(H5Fclose(file1) < 0) TEST_ERROR - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Set elink access flags on gapl to be H5F_ACC_RDWR */ - if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) TEST_ERROR + if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) + TEST_ERROR /* Create a group through the external link using gapl (should succeed) */ - if((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR + if ((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) + TEST_ERROR /* Close group */ - if(H5Gclose(group) < 0) TEST_ERROR + if (H5Gclose(group) < 0) + TEST_ERROR /* Unset elink access flags on gapl */ - if(H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) TEST_ERROR + if (H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) + TEST_ERROR /* Attempt to create a group through the external link using gapl (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { subgroup = H5Gcreate2(file1, "/ext_link/group/subgroup", H5P_DEFAULT, H5P_DEFAULT, gapl); - } H5E_END_TRY; - if(subgroup != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (subgroup != FAIL) + TEST_ERROR /* Attempt to set SWMR flags on gapl. * This is just a smoke check of the flags. The actual external link * functionality is tested in the SWMR tests. */ /* Set SWMR reader flags on gapl */ - if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ) < 0) TEST_ERROR + if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ) < 0) + TEST_ERROR /* Set SWMR writer flags on gapl */ - if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE) < 0) TEST_ERROR + if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE) < 0) + TEST_ERROR /* Attempt to set invalid flags on gapl */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_TRUNC); - } H5E_END_TRY; - if(ret != FAIL) TEST_ERROR - H5E_BEGIN_TRY { + } + H5E_END_TRY; + if (ret != FAIL) + TEST_ERROR + H5E_BEGIN_TRY + { ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_EXCL); - } H5E_END_TRY; - if(ret != FAIL) TEST_ERROR - H5E_BEGIN_TRY { + } + H5E_END_TRY; + if (ret != FAIL) + TEST_ERROR + H5E_BEGIN_TRY + { ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_CREAT); - } H5E_END_TRY; - if(ret != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (ret != FAIL) + TEST_ERROR /* SWMR reader with write access */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR | H5F_ACC_SWMR_READ); - } H5E_END_TRY; - if(ret != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (ret != FAIL) + TEST_ERROR /* SWMR writer with read-only access */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY | H5F_ACC_SWMR_WRITE); - } H5E_END_TRY; - if(ret != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (ret != FAIL) + TEST_ERROR /* Close file1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR /* Only run this part with VFDs that support SWMR */ - if(H5FD__supports_swmr_test(env_h5_drvr)) { + if (H5FD__supports_swmr_test(env_h5_drvr)) { /* Reopen file1, with read-write and SWMR-write access */ /* Only supported under the latest file format */ - if(new_format) { - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR + if (new_format) { + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) + FAIL_STACK_ERROR /* Open a group through the external link using default gapl */ - if((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify that the correct parameters have been set on file2 */ - if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR - if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR - if(flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) TEST_ERROR + if ((file2 = H5Iget_file_id(group)) < 0) + FAIL_STACK_ERROR + if (H5Fget_intent(file2, &flags) < 0) + FAIL_STACK_ERROR + if (flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) + TEST_ERROR /* Close file2 and group */ - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR /* Set elink access flags on gapl to be H5F_ACC_RDWR (dropping SWMR_WRITE) */ - if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) FAIL_STACK_ERROR + if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) + FAIL_STACK_ERROR /* Open a group through the external link using gapl */ - if((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) FAIL_STACK_ERROR + if ((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) + FAIL_STACK_ERROR /* Verify that the correct parameters have been set on file2 */ - if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR - if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR - if(flags != H5F_ACC_RDWR) TEST_ERROR + if ((file2 = H5Iget_file_id(group)) < 0) + FAIL_STACK_ERROR + if (H5Fget_intent(file2, &flags) < 0) + FAIL_STACK_ERROR + if (flags != H5F_ACC_RDWR) + TEST_ERROR /* Close file2 and group */ - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR /* Close file1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR } /* Reopen file1, with read-only and SWMR-read access */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) + FAIL_STACK_ERROR /* Open a group through the external link using default gapl */ - if((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify that the correct parameters have been set on file2 */ - if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR - if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR - if(flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) TEST_ERROR + if ((file2 = H5Iget_file_id(group)) < 0) + FAIL_STACK_ERROR + if (H5Fget_intent(file2, &flags) < 0) + FAIL_STACK_ERROR + if (flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) + TEST_ERROR /* Close file2 and group */ - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR /* Set elink access flags on gapl to be H5F_ACC_RDWR (dropping SWMR_WRITE) */ - if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) FAIL_STACK_ERROR + if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) + FAIL_STACK_ERROR /* Open a group through the external link using gapl */ - if((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) FAIL_STACK_ERROR + if ((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) + FAIL_STACK_ERROR /* Verify that the correct parameters have been set on file2 */ - if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR - if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR - if(flags != H5F_ACC_RDONLY) TEST_ERROR + if ((file2 = H5Iget_file_id(group)) < 0) + FAIL_STACK_ERROR + if (H5Fget_intent(file2, &flags) < 0) + FAIL_STACK_ERROR + if (flags != H5F_ACC_RDONLY) + TEST_ERROR /* Close file2 and group */ - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR /* Close file1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR } /* end if */ - /* Verify that H5Fcreate and H5Fopen reject H5F_ACC_DEFAULT */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file1 = H5Fcreate(filename1, H5F_ACC_DEFAULT, H5P_DEFAULT, fapl); - } H5E_END_TRY; - if(file1 != FAIL) TEST_ERROR - H5E_BEGIN_TRY { + } + H5E_END_TRY; + if (file1 != FAIL) + TEST_ERROR + H5E_BEGIN_TRY + { file1 = H5Fcreate(filename1, H5F_ACC_TRUNC | H5F_ACC_DEFAULT, H5P_DEFAULT, fapl); - } H5E_END_TRY; - if(file1 != FAIL) TEST_ERROR - H5E_BEGIN_TRY { + } + H5E_END_TRY; + if (file1 != FAIL) + TEST_ERROR + H5E_BEGIN_TRY + { file1 = H5Fopen(filename1, H5F_ACC_DEFAULT, fapl); - } H5E_END_TRY; - if(file1 != FAIL) TEST_ERROR - H5E_BEGIN_TRY { + } + H5E_END_TRY; + if (file1 != FAIL) + TEST_ERROR + H5E_BEGIN_TRY + { file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_DEFAULT, fapl); - } H5E_END_TRY; - if(file1 != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (file1 != FAIL) + TEST_ERROR /* Close gapl */ - if(H5Pclose(gapl) < 0) TEST_ERROR + if (H5Pclose(gapl) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group); H5Gclose(subgroup); H5Fclose(file1); H5Fclose(file2); H5Pclose(gapl); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_set_elink_acc_flags() */ - /*------------------------------------------------------------------------- * Function: external_set_elink_cb * @@ -7966,34 +9824,38 @@ error: * Failure: -1 *------------------------------------------------------------------------- */ - /* User data structure for callback function */ +/* User data structure for callback function */ typedef struct { - const char *parent_file; /* Expected parent file name */ - const char *target_file; /* Expected target file name */ - hid_t base_fapl; /* Base fapl for family driver */ - hsize_t fam_size; /* Size of family files */ - int code; /* Code to control the actions taken by the callback */ + const char *parent_file; /* Expected parent file name */ + const char *target_file; /* Expected target file name */ + hid_t base_fapl; /* Base fapl for family driver */ + hsize_t fam_size; /* Size of family files */ + int code; /* Code to control the actions taken by the callback */ } set_elink_cb_t; /* Callback function */ static herr_t -external_set_elink_cb_cb(const char *parent_file, const char *parent_group, - const char *target_file, const char *target_obj, unsigned *flags, - hid_t fapl, void *_op_data) +external_set_elink_cb_cb(const char *parent_file, const char *parent_group, const char *target_file, + const char *target_obj, unsigned *flags, hid_t fapl, void *_op_data) { - set_elink_cb_t *op_data = (set_elink_cb_t *)_op_data; + set_elink_cb_t *op_data = (set_elink_cb_t *)_op_data; /* Verify file and object names are correct */ - if (HDstrcmp(parent_file, op_data->parent_file)) return FAIL; - if (HDstrcmp(parent_group, "/group1")) return FAIL; - if (HDstrcmp(target_file, op_data->target_file)) return FAIL; - if (HDstrcmp(target_obj, "/")) return FAIL; + if (HDstrcmp(parent_file, op_data->parent_file)) + return FAIL; + if (HDstrcmp(parent_group, "/group1")) + return FAIL; + if (HDstrcmp(target_file, op_data->target_file)) + return FAIL; + if (HDstrcmp(target_obj, "/")) + return FAIL; /* Set flags to be read-write */ *flags = (*flags & ~H5F_ACC_RDONLY) | H5F_ACC_RDWR; /* Set family file driver on fapl */ - if (H5Pset_fapl_family(fapl, op_data->fam_size, op_data->base_fapl) < 0) return FAIL; + if (H5Pset_fapl_family(fapl, op_data->fam_size, op_data->base_fapl) < 0) + return FAIL; /* Codes to cause an invalid condition (and verify that an error is issued */ if (op_data->code == 1) @@ -8008,15 +9870,13 @@ external_set_elink_cb_cb(const char *parent_file, const char *parent_group, static int external_set_elink_cb(hid_t fapl, hbool_t new_format) { - hid_t file1 = -1, file2 = -1, group = -1, gapl = -1, fam_fapl = -1, ret_fapl = -1, base_driver; - set_elink_cb_t op_data, - *op_data_p; + hid_t file1 = -1, file2 = -1, group = -1, gapl = -1, fam_fapl = -1, ret_fapl = -1, base_driver; + set_elink_cb_t op_data, *op_data_p; H5L_elink_traverse_t cb; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; - unsigned flags; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; + unsigned flags; - if(new_format) + if (new_format) TESTING("H5Pset/get_elink_cb() (w/new group format)") else TESTING("H5Pset/get_elink_cb()") @@ -8028,96 +9888,132 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) /* Family file driver cannot be used with family or multi drivers for member files */ /* Also disable parallel member drivers, because H5F_HAS_FEATURE(H5FD_FEAT_HAS_MPI) would report FALSE, causing problems */ - base_driver = H5Pget_driver(fapl); - op_data.base_fapl = (base_driver == H5FD_FAMILY || base_driver == H5FD_MULTI - || base_driver == H5FD_MPIO || base_driver == H5FD_CORE) ? H5P_DEFAULT : fapl; + base_driver = H5Pget_driver(fapl); + op_data.base_fapl = (base_driver == H5FD_FAMILY || base_driver == H5FD_MULTI || + base_driver == H5FD_MPIO || base_driver == H5FD_CORE) + ? H5P_DEFAULT + : fapl; op_data.fam_size = ELINK_CB_FAM_SIZE; - op_data.code = 0; + op_data.code = 0; /* Create family fapl */ - if ((fam_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR - if (H5Pset_fapl_family(fam_fapl, op_data.fam_size, op_data.base_fapl) < 0) TEST_ERROR + if ((fam_fapl = H5Pcopy(fapl)) < 0) + TEST_ERROR + if (H5Pset_fapl_family(fam_fapl, op_data.fam_size, op_data.base_fapl) < 0) + TEST_ERROR /* Create parent and target files, group, and external link */ h5_fixname(FILENAME[42], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[43], fam_fapl, filename2, sizeof filename2); - if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR - if((group = H5Gcreate2(file1, "group1",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lcreate_external(filename2, "/", group, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if ((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) + TEST_ERROR + if ((group = H5Gcreate2(file1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lcreate_external(filename2, "/", group, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close files and group */ - if(H5Fclose(file1) < 0) TEST_ERROR - if(H5Fclose(file2) < 0) TEST_ERROR - if(H5Gclose(group) < 0) TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR + if (H5Fclose(file2) < 0) + TEST_ERROR + if (H5Gclose(group) < 0) + TEST_ERROR /* Create new gapl, and set elink callback */ - if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR - if(H5Pset_elink_cb(gapl, external_set_elink_cb_cb, &op_data) < 0) TEST_ERROR + if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) + TEST_ERROR + if (H5Pset_elink_cb(gapl, external_set_elink_cb_cb, &op_data) < 0) + TEST_ERROR /* Verify "get" routine functionality */ - if(H5Pget_elink_cb(gapl, &cb, (void **) &op_data_p) < 0) TEST_ERROR - if(cb != external_set_elink_cb_cb) TEST_ERROR - if(op_data_p != &op_data) TEST_ERROR + if (H5Pget_elink_cb(gapl, &cb, (void **)&op_data_p) < 0) + TEST_ERROR + if (cb != external_set_elink_cb_cb) + TEST_ERROR + if (op_data_p != &op_data) + TEST_ERROR /* Open file1 with read only access */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Create a group through the external link using gapl */ - if((group = H5Gcreate2(file1, "/group1/ext_link/group2", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR + if ((group = H5Gcreate2(file1, "/group1/ext_link/group2", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) + TEST_ERROR /* Verify that the correct parameters have been set on file2 (somewhat * redundant as the library would be unable to create the group otherwise) */ - if((file2 = H5Iget_file_id(group)) < 0) TEST_ERROR - if(H5Fget_intent(file2, &flags) < 0) TEST_ERROR - if(!(flags & H5F_ACC_RDWR)) TEST_ERROR - if((ret_fapl = H5Fget_access_plist(file2)) < 0) TEST_ERROR - if(H5FD_FAMILY != H5Pget_driver(ret_fapl)) TEST_ERROR + if ((file2 = H5Iget_file_id(group)) < 0) + TEST_ERROR + if (H5Fget_intent(file2, &flags) < 0) + TEST_ERROR + if (!(flags & H5F_ACC_RDWR)) + TEST_ERROR + if ((ret_fapl = H5Fget_access_plist(file2)) < 0) + TEST_ERROR + if (H5FD_FAMILY != H5Pget_driver(ret_fapl)) + TEST_ERROR - if(H5Gclose(group) < 0) TEST_ERROR - if(H5Fclose(file2) < 0) TEST_ERROR - if(H5Pclose(ret_fapl) < 0) TEST_ERROR - if(H5Pclose(fam_fapl) < 0) TEST_ERROR + if (H5Gclose(group) < 0) + TEST_ERROR + if (H5Fclose(file2) < 0) + TEST_ERROR + if (H5Pclose(ret_fapl) < 0) + TEST_ERROR + if (H5Pclose(fam_fapl) < 0) + TEST_ERROR /* Modify the user data structure to cause the callback to fail next time */ op_data.code = 1; /* Attempt to reopen group2 (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { group = H5Gopen2(file1, "/group1/ext_link/group2", gapl); - } H5E_END_TRY; - if(group != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (group != FAIL) + TEST_ERROR /* Modify the user data structure to cause the callback to return invalid flags */ op_data.code = 2; /* Attempt to reopen group2 (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { group = H5Gopen2(file1, "/group1/ext_link/group2", gapl); - } H5E_END_TRY; - if(group != FAIL) TEST_ERROR + } + H5E_END_TRY; + if (group != FAIL) + TEST_ERROR /* Close */ - if(H5Fclose(file1) < 0) TEST_ERROR - if(H5Pclose(gapl) < 0) TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR + if (H5Pclose(gapl) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group); H5Fclose(file1); H5Fclose(file2); H5Pclose(gapl); H5Pclose(ret_fapl); H5Pclose(fam_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_set_elink_cb() */ - /*------------------------------------------------------------------------- * Function: external_reset_register * @@ -8131,48 +10027,58 @@ error: static int external_reset_register(void) { - hid_t file; - char filename[NAME_BUF_SIZE]; + hid_t file; + char filename[NAME_BUF_SIZE]; TESTING("external links are registered after reset") /* Create and close file */ h5_fixname(FILENAME[44], H5P_DEFAULT, filename, sizeof filename); - if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Fclose(file) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR /* Reset the library */ H5close(); /* Re open file */ - if ((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create an external link */ - if (H5Lcreate_external("some_file", "some_obj", file, "ext_link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external("some_file", "some_obj", file, "ext_link1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file */ - if (H5Fclose(file) < 0) TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR /* Try again to make sure the previous H5Lcreate_external call does not * affect the ability to reset */ H5close(); - if ((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Lcreate_external("another_file", "another_obj", file, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if (H5Fclose(file) < 0) TEST_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lcreate_external("another_file", "another_obj", file, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR - if(HDremove(filename) != 0) TEST_ERROR + if (HDremove(filename) != 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_reset_register() */ - #ifdef H5_HAVE_WINDOW_PATH /*------------------------------------------------------------------------- @@ -8191,15 +10097,12 @@ error: static int external_link_win1(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via main file's current drive/rel path(windows)(w/new group format)") else TESTING("external links via main file's current drive/rel path(windows)") @@ -8207,7 +10110,7 @@ external_link_win1(hid_t fapl, hbool_t new_format) /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + if (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR /* set up name for target link: "/CWD/tmp_links/extlinks10" */ @@ -8220,47 +10123,58 @@ external_link_win1(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[29], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file via main file's CWD*/ - if(gid < 0) { + if (gid < 0) { H5_FAILED(); HDputs(" Should have found the file in CWD."); goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win1() */ - /*------------------------------------------------------------------------- * Function: external_link_win2 * @@ -8277,15 +10191,12 @@ error: static int external_link_win2(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via target's rel drive/abs path directly(windows)(w/new group format)") else TESTING("external links via target's rel drive/abs path directly(windows)") @@ -8293,12 +10204,14 @@ external_link_win2(hid_t fapl, hbool_t new_format) /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); - /* create tmp_links directory and get current working directory path */ - if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) + /* create tmp_links directory and get current working directory path */ + if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || + (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR /* set up name for target link: "/CWD/tmp_links/extlinks11" */ - HDstrcpy(tmpname, &cwdpath[2]); /* stripped the drive letter to make it relative drive but absolute path */ + HDstrcpy(tmpname, + &cwdpath[2]); /* stripped the drive letter to make it relative drive but absolute path */ HDstrcat(tmpname, "/"); HDstrcat(tmpname, FILENAME[31]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); @@ -8307,48 +10220,58 @@ external_link_win2(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[31], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file directly */ - if(gid < 0) { + if (gid < 0) { H5_FAILED(); HDputs(" Should have found the file in tmp_links."); goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win2() */ - /*------------------------------------------------------------------------- * Function: external_link_win3 * @@ -8365,15 +10288,12 @@ error: static int external_link_win3(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - int drive = 0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive = 0; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via target's abs drive/rel path directly (windows)(w/new group format)") else TESTING("external links via target's abs drive/rel path directly (windows)") @@ -8387,31 +10307,38 @@ external_link_win3(hid_t fapl, hbool_t new_format) /* set up name for target link: ":tmp_links/extlinks12" */ drive = HDgetdrive(); - HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive+'A'-1), FILENAME[32]); + HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive + 'A' - 1), FILENAME[32]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* set up name for target file: "tmp_links/extlinks12" */ h5_fixname(FILENAME[32], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file directly */ if (gid < 0) { @@ -8421,17 +10348,21 @@ external_link_win3(hid_t fapl, hbool_t new_format) } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; - error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win3() */ @@ -8451,49 +10382,54 @@ external_link_win3(hid_t fapl, hbool_t new_format) static int external_link_win4(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive = 0; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via main file's abs drive/rel path (windows)(w/new group format)") else TESTING("external links via main file's abs drive/rel path (windows)") /* set up name for main file: ":tmp_links/extlinks0" */ drive = HDgetdrive(); - HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive+'A'-1), FILENAME[13]); + HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive + 'A' - 1), FILENAME[13]); h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* set up name for target link: ":extlinks13" */ - HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive+'A'-1), FILENAME[33]); + HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive + 'A' - 1), FILENAME[33]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* set up name for target file: "tmp_links/extlinks13" */ h5_fixname(FILENAME[34], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file via main file's absolute drive/relative path */ if (gid < 0) { @@ -8503,21 +10439,24 @@ external_link_win4(hid_t fapl, hbool_t new_format) } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win4() */ - /*------------------------------------------------------------------------- * Function: external_link_win5 * @@ -8534,21 +10473,18 @@ error: static int external_link_win5(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive = 0; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via main file's rel drive/abs path (windows)(w/new group format)") else TESTING("external links via main file's rel drive/abs path (windows)") - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + if (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR drive = HDgetdrive(); if (drive >= 26) @@ -8563,54 +10499,65 @@ external_link_win5(hid_t fapl, hbool_t new_format) h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* set up name for target link: ":tmp_links/extlinks14" */ - HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive+'A'-1), FILENAME[35]); + HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive + 'A' - 1), FILENAME[35]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* set up name for target file: "tmp_links/extlinks14" */ h5_fixname(FILENAME[35], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file via main file's rel drive/abs path */ - if(gid < 0) { + if (gid < 0) { H5_FAILED(); HDputs(" Should have found the file in CWD."); goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win5() */ - /*------------------------------------------------------------------------- * Function: external_link_win6 * @@ -8627,15 +10574,12 @@ error: static int external_link_win6(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - int drive=0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive = 0; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE]; + + if (new_format) TESTING("external links via target's current drive/rel path (windows)(w/new group format)") else TESTING("external links via target's current drive/rel path (windows)") @@ -8653,30 +10597,38 @@ external_link_win6(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); /* set up name for target link: ":tmp_links/extlinks15" */ - HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive+'A'-1), FILENAME[36]); + HDsnprintf(tmpname, sizeof(tmpname), "%c:%s", (drive + 'A' - 1), FILENAME[36]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* set up name for target file: "tmp/extlinks15" */ h5_fixname(FILENAME[36], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file via target file's rel path in current drive */ if (gid < 0) { @@ -8686,21 +10638,24 @@ external_link_win6(hid_t fapl, hbool_t new_format) } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win6() */ - /*------------------------------------------------------------------------- * Function: external_link_win7 * @@ -8717,23 +10672,21 @@ error: static int external_link_win7(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) - TESTING("external links via main file's UNC local host/main drive/rel path(windows)(w/new group format)") + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) + TESTING( + "external links via main file's UNC local host/main drive/rel path(windows)(w/new group format)") else TESTING("external links via main file's UNC local host/main drive/rel path(windows)") /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + if (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR /* set up name for target link: "\\127.0.0.1\c$/tmp_links/extlinks10" */ @@ -8746,47 +10699,58 @@ external_link_win7(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[29], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file via main file's local host/main drive*/ - if(gid < 0) { + if (gid < 0) { H5_FAILED(); HDputs(" Should have found the file in local host/main drive."); goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win7() */ - /*------------------------------------------------------------------------- * Function: external_link_win8 * @@ -8804,78 +10768,89 @@ error: static int external_link_win8(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - int drive = 0; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) - TESTING("external links via target's Long UNC abs drive/abs path directly (windows)(w/new group format)") + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + int drive = 0; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) + TESTING( + "external links via target's Long UNC abs drive/abs path directly (windows)(w/new group format)") else TESTING("external links via target's Long UNC abs drive/abs path directly (windows)") /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR + if (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + TEST_ERROR /* create tmp_links directory */ - if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR /* set up name for target link: ":\CWD\extlinks10" */ drive = HDgetdrive(); - HDsnprintf(tmpname, sizeof(tmpname), "\\\\?\\%c:%s\\%s", (drive+'A'-1), &cwdpath[2], FILENAME[30]); + HDsnprintf(tmpname, sizeof(tmpname), "\\\\?\\%c:%s\\%s", (drive + 'A' - 1), &cwdpath[2], FILENAME[30]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* set up name for target file: "extlinks10" */ h5_fixname(FILENAME[30], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file directly */ - if(gid < 0) { + if (gid < 0) { H5_FAILED(); HDputs(" Should have found the file in tmp_links."); goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win8() */ - /*------------------------------------------------------------------------- * Function: external_link_win9 * @@ -8892,23 +10867,22 @@ error: static int external_link_win9(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - - if(new_format) - TESTING("external links via main file's Long UNC local host/main drive/rel path(windows)(w/new group format)") + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], + cwdpath[NAME_BUF_SIZE]; + + if (new_format) + TESTING("external links via main file's Long UNC local host/main drive/rel path(windows)(w/new group " + "format)") else TESTING("external links via main file's Long UNC local host/main drive/rel path(windows)") /* set up name for main file: "extlinks0" */ h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1); - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR + if (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + TEST_ERROR /* set up name for target link: "\\?\UNC\127.0.0.1\c$/tmp_links/extlinks10" */ HDstrcpy(tmpname, "\\\\?\\UNC\127.0.0.1\\c$"); /* absolute path */ @@ -8920,49 +10894,60 @@ external_link_win9(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[29], fapl, filename3, sizeof filename3); /* Create the target file */ - if((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* should be able to find the target file via main file's local host/main drive*/ - if(gid < 0) { + if (gid < 0) { H5_FAILED(); HDputs(" Should have found the file in local host/main drive."); goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_win9() */ #endif /* H5_HAVE_WINDOW_PATH */ - /*------------------------------------------------------------------------- * Function: external_link_recursive * @@ -8975,11 +10960,11 @@ error: static int external_link_recursive(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE]; /* Names of files to externally link across */ - if(new_format) + if (new_format) TESTING("recursive external links (w/new group format)") else TESTING("recursive external links") @@ -8988,21 +10973,27 @@ external_link_recursive(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[3], fapl, filename1, sizeof filename1); /* Create first file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create recursive external links */ - if(H5Lcreate_external(filename1, "/recursive", fid, "recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename1, "/recursive", fid, "recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open object through dangling file external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "recursive", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; if (gid >= 0) { H5_FAILED(); HDputs(" Should have failed for recursive external links."); @@ -9010,20 +11001,22 @@ external_link_recursive(hid_t fapl, hbool_t new_format) } /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end external_link_recursive() */ - /*------------------------------------------------------------------------- * Function: external_link_query * @@ -9037,17 +11030,16 @@ error: static int external_link_query(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - const char *file_name; /* Name of the file the external link points to */ - const char *object_name; /* Name of the object the external link points to */ - H5O_info2_t oi; /* Object information */ - H5L_info2_t li; /* Link information */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ - query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + const char *file_name; /* Name of the file the external link points to */ + const char *object_name; /* Name of the object the external link points to */ + H5O_info2_t oi; /* Object information */ + H5L_info2_t li; /* Link information */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ + query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ + + if (new_format) TESTING("query aspects of external link (w/new group format)") else TESTING("query aspects of external link") @@ -9057,15 +11049,19 @@ external_link_query(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file, with external link to object in second file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link */ /* (add a few extra '/'s to make certain library normalizes external link object names) */ - if(H5Lcreate_external(filename2, "///dst//", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "///dst//", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Get size of buffer for external link */ - if(H5Lget_info2(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR + if (H5Lget_info2(fid, "src", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) + TEST_ERROR if (H5L_TYPE_EXTERNAL != li.type) { H5_FAILED(); HDputs(" Unexpected link class - should have been an external link"); @@ -9073,80 +11069,108 @@ external_link_query(hid_t fapl, hbool_t new_format) } /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file to point to */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create object to link to */ - if((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Get size of buffer for external link */ - if(H5Lget_info2(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR - if(H5L_TYPE_EXTERNAL != li.type) { + if (H5Lget_info2(fid, "src", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) + TEST_ERROR + if (H5L_TYPE_EXTERNAL != li.type) { H5_FAILED(); HDputs(" Unexpected link class - should have been an external link"); goto error; } /* Get information for external link. It should be two strings right after each other */ - if(H5Lget_val(fid, "src", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_val(fid, "src", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR /* Extract the file and object names from the buffer */ - if(H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, &file_name, &object_name) < 0) TEST_ERROR + if (H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, &file_name, &object_name) < 0) + TEST_ERROR /* Compare the file and object names */ - if(HDstrcmp(file_name, filename2)) TEST_ERROR - if(HDstrcmp(object_name, "/dst")) TEST_ERROR + if (HDstrcmp(file_name, filename2)) + TEST_ERROR + if (HDstrcmp(object_name, "/dst")) + TEST_ERROR /* Query information about object that external link points to */ - if(H5Oget_info_by_name3(fid, "src", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5O_TYPE_GROUP != oi.type) { + if (H5Oget_info_by_name3(fid, "src", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5O_TYPE_GROUP != oi.type) { H5_FAILED(); HDputs(" Unexpected object type - should have been a group"); goto error; } /* Close first file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Make sure that passing in NULLs to H5Lunpack_elink_val works */ - if(H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, NULL, NULL) < 0) TEST_ERROR + if (H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, NULL, NULL) < 0) + TEST_ERROR /* Make sure that bogus cases trigger errors in H5Lunpack_elink_val */ - H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) TEST_ERROR - } H5E_END_TRY - H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR - } H5E_END_TRY - H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR - } H5E_END_TRY - H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) TEST_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) + TEST_ERROR + } + H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) + TEST_ERROR + } + H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) + TEST_ERROR + } + H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) + TEST_ERROR + } + H5E_END_TRY PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_query() */ - /*------------------------------------------------------------------------- * Function: external_link_unlink_compact * @@ -9159,12 +11183,11 @@ error: static int external_link_unlink_compact(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - if(new_format) + if (new_format) TESTING("unlinking external link in compact group (w/new group format)") else TESTING("unlinking external link in compact group") @@ -9174,58 +11197,73 @@ external_link_unlink_compact(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file, with external link to object in second file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link */ - if(H5Lcreate_external(filename2, "/dst", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/dst", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file to point to */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create object to link to */ - if((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Unlink external link */ - if(H5Ldelete(fid, "src", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "src", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Open second file */ - if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Open group for external link */ - if((gid = H5Gopen2(fid, "dst", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "dst", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_unlink_compact() */ - /*------------------------------------------------------------------------- * Function: external_link_unlink_dense * @@ -9238,18 +11276,17 @@ error: static int external_link_unlink_dense(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gcpl = -1; /* Group creation property list ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - unsigned nmsgs; /* Number of messages in group's header */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned u; /* Local index variable */ - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gcpl = -1; /* Group creation property list ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + unsigned nmsgs; /* Number of messages in group's header */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned u; /* Local index variable */ + + if (new_format) TESTING("unlinking external link in dense group (w/new group format)") else TESTING("unlinking external link in dense group") @@ -9259,112 +11296,151 @@ external_link_unlink_dense(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file, with external link to object in second file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Open root group */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check on root group's status */ - if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) != TRUE) + TEST_ERROR /* Query the group creation properties */ - if((gcpl = H5Gget_create_plist(gid)) < 0) TEST_ERROR - if(H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) TEST_ERROR + if ((gcpl = H5Gget_create_plist(gid)) < 0) + TEST_ERROR + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) + TEST_ERROR /* Create external link */ - /* (This also covers the case of having an external link in a compact group that's converted to a dense group) */ - if(H5Lcreate_external(filename2, "/dst", gid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* (This also covers the case of having an external link in a compact group that's converted to a dense + * group) */ + if (H5Lcreate_external(filename2, "/dst", gid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Check on root group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR - if(nmsgs != 1) TEST_ERROR - if(H5G__has_stab_test(gid) == TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, &nmsgs) != TRUE) + TEST_ERROR + if (nmsgs != 1) + TEST_ERROR + if (H5G__has_stab_test(gid) == TRUE) + TEST_ERROR /* Create enough objects in the root group to change it into a "dense" group */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR } /* end for */ /* Check on root group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Close group creation property list */ - if(H5Pclose(gcpl) < 0) TEST_ERROR + if (H5Pclose(gcpl) < 0) + TEST_ERROR /* Close root group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file to point to */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create object to link to */ - if((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Open root group */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Unlink external link */ - if(H5Ldelete(fid, "src", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "src", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Remove enough objects in the root group to change it into a "compact" group */ - for(u = 0; u < ((max_compact - min_dense) + 1); u++) { + for (u = 0; u < ((max_compact - min_dense) + 1); u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Check on root group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR - if(nmsgs != (min_dense - 1)) TEST_ERROR - if(H5G__is_new_dense_test(gid) == TRUE) TEST_ERROR - if(H5G__has_stab_test(gid) == TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, &nmsgs) != TRUE) + TEST_ERROR + if (nmsgs != (min_dense - 1)) + TEST_ERROR + if (H5G__is_new_dense_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(gid) == TRUE) + TEST_ERROR /* Close root group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Open second file */ - if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Open group for external link (should be unaffected) */ - if((gid = H5Gopen2(fid, "dst", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "dst", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_unlink_dense() */ - /*------------------------------------------------------------------------- * Function: external_link_move * @@ -9377,13 +11453,12 @@ error: static int external_link_move(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - if(new_format) + if (new_format) TESTING("move external link (w/new group format)") else TESTING("move external link") @@ -9393,162 +11468,213 @@ external_link_move(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file, with external link to object in second file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link */ - if(H5Lcreate_external(filename2, "/dst", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/dst", fid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file to point to */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create object to link to */ - if((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR -/* Move external link to different name within same group */ + /* Move external link to different name within same group */ /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Move external link within same group */ - if(H5Lmove(fid, "src", H5L_SAME_LOC, "src2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(fid, "src", H5L_SAME_LOC, "src2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "src2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "src2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR - if(HDstrcmp(objname, "/dst")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(objname, "/dst")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR /* Close external object */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Open second file */ - if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Open group created through external link */ - if((gid = H5Gopen2(fid, "dst/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "dst/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR -/* Move external link to different group */ + /* Move external link to different group */ /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Create another group, to move the external link into */ - if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Move external link to different group */ - if(H5Lmove(fid, "src2", gid, "src3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(fid, "src2", gid, "src3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close new group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "/group2/src3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/group2/src3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR - if(HDstrcmp(objname, "/dst")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(objname, "/dst")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR /* Close external object */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Open second file */ - if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Open group created through external link */ - if((gid = H5Gopen2(fid, "dst/new_group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "dst/new_group2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR -/* Move external link back to original group */ + /* Move external link back to original group */ /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "/group2/src3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/group2/src3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR - if(HDstrcmp(objname, "/dst")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(objname, "/dst")) + TEST_ERROR /* Move external link back to original location */ - if(H5Lmove(fid, "/group2/src3", H5L_SAME_LOC, "/src", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(fid, "/group2/src3", H5L_SAME_LOC, "/src", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR - if(HDstrcmp(objname, "/dst")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(objname, "/dst")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR /* Close external object */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Open second file */ - if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Open group created through external link */ - if((gid = H5Gopen2(fid, "dst/new_group3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "dst/new_group3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_move() */ - /*------------------------------------------------------------------------- * Function: external_link_ride * @@ -9562,18 +11688,17 @@ error: static int external_link_ride(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gcpl = -1; /* Group creation property list ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ - unsigned nmsgs; /* Number of messages in group's header */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned u; /* Local index variable */ - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gcpl = -1; /* Group creation property list ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */ + unsigned nmsgs; /* Number of messages in group's header */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned u; /* Local index variable */ + + if (new_format) TESTING("external link along for the ride (w/new group format)") else TESTING("external link along for the ride") @@ -9583,154 +11708,205 @@ external_link_ride(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); /* Create first file, with external link to object in second file */ - if((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Open root group */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check on root group's status */ - if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) != TRUE) + TEST_ERROR /* Query the group creation properties */ - if((gcpl = H5Gget_create_plist(gid)) < 0) TEST_ERROR - if(H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) TEST_ERROR + if ((gcpl = H5Gget_create_plist(gid)) < 0) + TEST_ERROR + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) + TEST_ERROR /* Create enough objects in the root group to change it into a "dense" group */ - for(u = 0; u < (max_compact + 1); u++) { + for (u = 0; u < (max_compact + 1); u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR } /* end for */ /* Check on root group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(new_format) { - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (new_format) { + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR } /* end if */ else { - if(H5G__has_stab_test(gid) != TRUE) TEST_ERROR + if (H5G__has_stab_test(gid) != TRUE) + TEST_ERROR } /* end else */ /* Create external link */ /* (This also covers the case of adding an external link to a dense group) */ - if(H5Lcreate_external(filename2, "/dst", gid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/dst", gid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Check on root group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Close group creation property list */ - if(H5Pclose(gcpl) < 0) TEST_ERROR + if (H5Pclose(gcpl) < 0) + TEST_ERROR /* Close root group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create second file to point to */ - if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create object to link to */ - if((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "dst", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR -/* Remove enough objects to convert group containing external link back into compact form */ + /* Remove enough objects to convert group containing external link back into compact form */ /* Open first file */ - if((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "src", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "src", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/dst")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/dst")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close external object */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Open root group */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Remove enough objects in the root group to change it into a "compact" group */ - for(u = 0; u < ((max_compact - min_dense) + 3); u++) { + for (u = 0; u < ((max_compact - min_dense) + 3); u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Check on root group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR - if(nmsgs != (min_dense - 1)) TEST_ERROR - if(H5G__has_stab_test(gid) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) == TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, &nmsgs) != TRUE) + TEST_ERROR + if (nmsgs != (min_dense - 1)) + TEST_ERROR + if (H5G__has_stab_test(gid) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) == TRUE) + TEST_ERROR /* Close root group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Open object through external link */ - if((gid = H5Gopen2(fid, "src", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "src", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/dst")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/dst")) + TEST_ERROR /* Create object in external file */ - if((gid2 = H5Gcreate2(gid, "new_group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group in external file */ - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR /* Close external object */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Open second file */ - if((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Open group created through external link */ - if((gid = H5Gopen2(fid, "dst/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "dst/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Open group created through external link */ - if((gid = H5Gopen2(fid, "dst/new_group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "dst/new_group2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl); H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_ride() */ - /*------------------------------------------------------------------------- * Function: external_link_closing * @@ -9744,20 +11920,18 @@ error: static int external_link_closing(hid_t fapl, hbool_t new_format) { - hid_t fid1 = (-1), fid2 = (-1), fid3 = (-1), fid4=(-1); - hid_t gid=(-1), tid=(-1), tid2=(-1), sid=(-1), did=(-1); - hid_t lcpl_id=(-1); - hsize_t dims[2]; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ - buf[NAME_BUF_SIZE]; /* misc. buffer */ + hid_t fid1 = (-1), fid2 = (-1), fid3 = (-1), fid4 = (-1); + hid_t gid = (-1), tid = (-1), tid2 = (-1), sid = (-1), did = (-1); + hid_t lcpl_id = (-1); + hsize_t dims[2]; + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE], /* Names of files to externally link across */ + buf[NAME_BUF_SIZE]; /* misc. buffer */ H5L_info2_t li; H5O_info2_t oi; hobj_ref_t obj_ref; - if(new_format) + if (new_format) TESTING("that external files are closed during traversal (w/new group format)") else TESTING("that external files are closed during traversal") @@ -9777,175 +11951,263 @@ external_link_closing(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[6], fapl, filename4, sizeof filename4); /* Create four files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create a dataspace and a datatype so we can create/commit a dataset/datatype in the files */ dims[0] = 2; dims[1] = 2; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if ((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* Create external links from each file to the next */ - if(H5Lcreate_external(filename2, "/", fid1, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename4, "/", fid3, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename3, "/", fid2, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename4, "/", fid3, "elink", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close all files but the first */ - if(H5Fclose(fid4) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid4) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Test creating each kind of object */ - if((gid = H5Gcreate2(fid1, "elink/elink/elink/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Tcommit2(fid1, "elink/elink/elink/type1", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid1, "elink/elink/elink/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Tcommit2(fid1, "elink/elink/elink/type1", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if ((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Test that getting info works */ - if(H5Lget_info2(fid1, "elink/elink/elink/type1", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info2(fid1, "elink/elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(fid1, "elink/elink/elink/type1", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(fid1, "elink/elink/elink", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info2(fid1, "elink/elink/elink/type1", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info2(fid1, "elink/elink/elink", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(fid1, "elink/elink/elink/type1", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(fid1, "elink/elink/elink", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR /* Test move */ - if(H5Lmove(fid1, "elink/elink/elink/group1", fid1, - "elink/elink/elink/group1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lmove(fid1, "elink/elink/elink/group1", fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR /* Open file 4 so we can do some fancy things */ - if((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if(H5Lmove(fid1, "elink/elink/elink/type1", fid4, - "type1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lmove(fid4, "dataset1", fid1, - "elink/elink/elink/dataset1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Lmove(fid1, "elink/elink/elink/type1", fid4, "type1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lmove(fid4, "dataset1", fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file 4 again */ - if(H5Fclose(fid4) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid4) < 0) + FAIL_STACK_ERROR /* Test copy (as of this test, it uses the same code as move) */ - if(H5Lcopy(fid1, "elink/elink/elink", fid1, - "elink/elink/elink_copied", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcopy(fid1, "elink/elink/elink", fid1, - "elink/elink/elink/elink_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcopy(fid1, "elink/elink/elink", fid1, "elink/elink/elink_copied", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcopy(fid1, "elink/elink/elink", fid1, "elink/elink/elink/elink_copied2", H5P_DEFAULT, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Test H5Gset and get comment */ - if(H5Oset_comment_by_name(fid1, "elink/elink/elink/group1_moved", "comment", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_comment_by_name(fid1, "elink/elink/elink/group1_moved", buf, sizeof(buf), H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(HDstrcmp(buf, "comment")) TEST_ERROR + if (H5Oset_comment_by_name(fid1, "elink/elink/elink/group1_moved", "comment", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_comment_by_name(fid1, "elink/elink/elink/group1_moved", buf, sizeof(buf), H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(buf, "comment")) + TEST_ERROR /* Test H5*open */ - if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(tid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Test H5*open2 */ - if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(tid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Test H5Oopen */ - if((did = H5Oopen(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Oopen(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Test H5Fmount */ - if((gid = H5Gcreate2(fid1, "elink/elink/elink/mnt", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - H5E_BEGIN_TRY { - if(H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT) >= 0) TEST_ERROR - if(H5Funmount(fid1, "elink/elink/elink/mnt") >= 0) TEST_ERROR - } H5E_END_TRY + if ((gid = H5Gcreate2(fid1, "elink/elink/elink/mnt", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + H5E_BEGIN_TRY + { + if (H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT) >= 0) + TEST_ERROR + if (H5Funmount(fid1, "elink/elink/elink/mnt") >= 0) + TEST_ERROR + } + H5E_END_TRY /* Test H5Rcreate */ - if(H5Rcreate(&obj_ref, fid1, "elink/elink/elink/type1_moved", H5R_OBJECT, (hid_t)(-1)) < 0) TEST_ERROR + if (H5Rcreate(&obj_ref, fid1, "elink/elink/elink/type1_moved", H5R_OBJECT, (hid_t)(-1)) < 0) + TEST_ERROR /* Test unlink */ - if(H5Ldelete(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(fid1, "elink/elink/elink_copied", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(fid1, "elink/elink/elink/elink_copied2", H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink_copied", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(fid1, "elink/elink/elink/elink_copied2", H5P_DEFAULT) < 0) + TEST_ERROR /* We've tested that the various functions above don't leave files open. - * Now test that we can't confuse HDF5 by giving unusual paths with external links - */ + * Now test that we can't confuse HDF5 by giving unusual paths with external links + */ /* Create an external link that points to another external link */ - if((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if(H5Lcreate_external(filename3, "/elink", fid2, "elink2", - H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + if (H5Lcreate_external(filename3, "/elink", fid2, "elink2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Do an external link traversal that recursively calls another external link. */ - if((gid = H5Gcreate2(fid1, "elink/elink2/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid1, "elink/elink2/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create two more groups so that the last three elements in the path are - * all within the same external file - */ - if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3/group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Oget_info_by_name3(fid1, "elink/elink2/group2/group3/group4", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + * all within the same external file + */ + if ((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid1, "elink/elink2/group2/group3/group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(fid1, "elink/elink2/group2/group3/group4", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR /* Add a few regular groups and a soft link in file2 using intermediate group creation */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR - if(H5Lcreate_soft("/elink2", fid1, "elink/file2group1/file2group2/slink", - lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) + TEST_ERROR + if (H5Lcreate_soft("/elink2", fid1, "elink/file2group1/file2group2/slink", lcpl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Try to traverse this path. There are three soft traversals in a row; * slink points to (file2)/elink2, which points to (file3)/elink, which * points to file 4. */ - if((gid = H5Gcreate2(fid1, "elink/file2group1/file2group2/slink/group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Lget_info2(fid1, "elink/file2group1/file2group2/slink/group3", &li, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid1, "elink/file2group1/file2group2/slink/group3", H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Lget_info2(fid1, "elink/file2group1/file2group2/slink/group3", &li, H5P_DEFAULT) < 0) + TEST_ERROR /* Some simpler tests */ - if((gid = H5Gcreate2(fid1, "elink/file2group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Lget_info2(fid1, "elink/file2group3", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info2(fid1, "elink/elink", &li, H5P_DEFAULT) < 0) TEST_ERROR - + if ((gid = H5Gcreate2(fid1, "elink/file2group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Lget_info2(fid1, "elink/file2group3", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info2(fid1, "elink/elink", &li, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file1, the only file that should still be open */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Re-create each file. If they are hanging open, these creates will fail */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Cleanup */ - if(H5Sclose(sid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) TEST_ERROR - if(H5Fclose(fid4) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR + if (H5Fclose(fid4) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Tclose(tid); H5Dclose(did); @@ -9955,11 +12217,11 @@ error: H5Fclose(fid3); H5Fclose(fid2); H5Fclose(fid1); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* external_link_closing() */ - /*------------------------------------------------------------------------- * Function: ext_link_endian * @@ -9974,63 +12236,78 @@ error: static int external_link_endian(hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t lapl_id = -1; /* Prop List ID */ - const char *pathbuf = H5_get_srcdir(); /* Path to the files */ - const char *namebuf; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t lapl_id = -1; /* Prop List ID */ + const char *pathbuf = H5_get_srcdir(); /* Path to the files */ + const char *namebuf; - if(new_format) + if (new_format) TESTING("endianness of external links (w/new group format)") else TESTING("endianness of external links") /* Create a link access property list with the path to the srcdir */ - if((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR - if(H5Pset_elink_prefix(lapl_id, pathbuf) < 0) TEST_ERROR + if ((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) + TEST_ERROR + if (H5Pset_elink_prefix(lapl_id, pathbuf) < 0) + TEST_ERROR namebuf = H5_get_srcdir_filename(LE_FILENAME); /* Corrected test file name */ /* Test LE file; try to open a group through the external link */ - if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid = H5Oopen(fid, "ext_link", lapl_id)) < 0) TEST_ERROR + if ((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((gid = H5Oopen(fid, "ext_link", lapl_id)) < 0) + TEST_ERROR /* Open a group in the external file using that group ID */ - if((gid2 = H5Gopen2(gid, "subgroup", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gopen2(gid, "subgroup", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close the IDs */ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR namebuf = H5_get_srcdir_filename(BE_FILENAME); /* Corrected test file name */ /* Test BE file; try to open a group through the external link */ - if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid = H5Oopen(fid, "ext_link", lapl_id)) < 0) TEST_ERROR + if ((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((gid = H5Oopen(fid, "ext_link", lapl_id)) < 0) + TEST_ERROR /* Open a group in the external file using that group ID */ - if((gid2 = H5Gopen2(gid, "subgroup", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gopen2(gid, "subgroup", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close the IDs */ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } - /*------------------------------------------------------------------------- * Function: external_link_strong * @@ -10044,14 +12321,13 @@ error: static int external_link_strong(hid_t fapl, hbool_t new_format) { - hid_t my_fapl = (-1); /* File access property list */ - hid_t fid1 = (-1), fid2 = (-1); /* File ID */ - hid_t gid1 = (-1), gid2 = (-1); /* Group IDs */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE]; - - if(new_format) + hid_t my_fapl = (-1); /* File access property list */ + hid_t fid1 = (-1), fid2 = (-1); /* File ID */ + hid_t gid1 = (-1), gid2 = (-1); /* Group IDs */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; + + if (new_format) TESTING("that external files work with strong file close degree (w/new group format)") else TESTING("that external files work with strong file close degree") @@ -10061,57 +12337,82 @@ external_link_strong(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Copy file access property list */ - if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((my_fapl = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Set strong file close degree */ - if(H5Pset_fclose_degree(my_fapl, H5F_CLOSE_STRONG) < 0) TEST_ERROR + if (H5Pset_fclose_degree(my_fapl, H5F_CLOSE_STRONG) < 0) + TEST_ERROR /* Create a group at /A/B/C in first file */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((gid1 = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) TEST_ERROR - if((gid1 = H5Gcreate2(fid1, "A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) TEST_ERROR - if((gid1 = H5Gcreate2(fid1, "A/B/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((gid1 = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if ((gid1 = H5Gcreate2(fid1, "A/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if ((gid1 = H5Gcreate2(fid1, "A/B/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Create an external link /W/X/DLINK in second file to :/A/B/C */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(fid2, "/W", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(fid2, "/W/X", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/A/B/C", gid2, "DLINK", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid2 = H5Gcreate2(fid2, "/W", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if ((gid2 = H5Gcreate2(fid2, "/W/X", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/A/B/C", gid2, "DLINK", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Access external link from file #1 */ - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((gid2 = H5Gopen2(fid2, "/W/X/DLINK", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/A/B/C")) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + if ((gid2 = H5Gopen2(fid2, "/W/X/DLINK", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Iget_name(gid2, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/A/B/C")) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Close fapl */ - if(H5Pclose(my_fapl) < 0) TEST_ERROR + if (H5Pclose(my_fapl) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(my_fapl); H5Gclose(fapl); H5Gclose(gid2); H5Gclose(gid1); H5Fclose(fid2); H5Fclose(fid1); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end external_link_strong() */ - /*------------------------------------------------------------------------- * Function: external_symlink * @@ -10126,30 +12427,30 @@ static int external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { #ifdef H5_HAVE_SYMLINK - hid_t file1 = H5I_INVALID_HID; - hid_t file2 = H5I_INVALID_HID; - hid_t file3 = H5I_INVALID_HID; - hid_t file4 = H5I_INVALID_HID; - hid_t file5 = H5I_INVALID_HID; - hid_t group2 = H5I_INVALID_HID; - hid_t group3 = H5I_INVALID_HID; - hid_t group4 = H5I_INVALID_HID; - hid_t group5 = H5I_INVALID_HID; - char *filename1 = NULL; - char *filename2a = NULL; - char *filename2b = NULL; - char *filename3a = NULL; - char *filename3b = NULL; - char *filename4a = NULL; - char *filename4b = NULL; - char *filename5a = NULL; - char *filename5b = NULL; - char *tmpname = NULL; - char *cwdpath = NULL; - hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */ -#endif /* H5_HAVE_SYMLINK */ - - if(new_format) + hid_t file1 = H5I_INVALID_HID; + hid_t file2 = H5I_INVALID_HID; + hid_t file3 = H5I_INVALID_HID; + hid_t file4 = H5I_INVALID_HID; + hid_t file5 = H5I_INVALID_HID; + hid_t group2 = H5I_INVALID_HID; + hid_t group3 = H5I_INVALID_HID; + hid_t group4 = H5I_INVALID_HID; + hid_t group5 = H5I_INVALID_HID; + char * filename1 = NULL; + char * filename2a = NULL; + char * filename2b = NULL; + char * filename3a = NULL; + char * filename3b = NULL; + char * filename4a = NULL; + char * filename4b = NULL; + char * filename5a = NULL; + char * filename5b = NULL; + char * tmpname = NULL; + char * cwdpath = NULL; + hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */ +#endif /* H5_HAVE_SYMLINK */ + + if (new_format) TESTING("external links w/symlink files (w/new group format)") else TESTING("external links w/symlink files") @@ -10158,47 +12459,46 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Skip test when using VFDs that can't provide a POSIX compatible file * descriptor. */ - have_posix_compat_vfd = (hbool_t)(!HDstrcmp(env_h5_drvr, "sec2") - || !HDstrcmp(env_h5_drvr, "core") - || !HDstrcmp(env_h5_drvr, "nomatch")); - if(!have_posix_compat_vfd) { + have_posix_compat_vfd = (hbool_t)(!HDstrcmp(env_h5_drvr, "sec2") || !HDstrcmp(env_h5_drvr, "core") || + !HDstrcmp(env_h5_drvr, "nomatch")); + if (!have_posix_compat_vfd) { SKIPPED(); HDputs(" Current VFD doesn't support POSIX I/O calls"); return SUCCEED; } - if(NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename2a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename2a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename2b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename2b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename3a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename3a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename3b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename3b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename4a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename4a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename4b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename4b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename5a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename5a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (filename5b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (filename5b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; - if(NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + if (NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) TEST_ERROR; /* set up name for main file: "extlinks21A" */ h5_fixname(FILENAME[45], fapl, filename1, NAME_BUF_SIZE); /* create tmp_links directory and get current working directory path */ - if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR - if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) + if (HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + if (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) TEST_ERROR /* Set up names for files in the subdirectories */ @@ -10210,7 +12510,8 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */ /* (i.e. tmp_links/sym1.h5 -> /tmp2_links/extlinks21B.h5) */ - if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR + if (HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) + TEST_ERROR /* set up name for file #3 in temporary directory #2: "tmp2_links/extlinks21C" */ h5_fixname(FILENAME[47], fapl, filename3a, NAME_BUF_SIZE); @@ -10223,103 +12524,138 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */ /* (i.e. tmp2_links/sym2.h5 -> /tmp_links/extlinks21D.h5) */ - if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR + if (HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) + TEST_ERROR /* set up name for file #5 in temporary directory #1: "tmp_links/extlinks21E" */ h5_fixname(FILENAME[50], fapl, filename5a, NAME_BUF_SIZE); h5_fixname(FILENAME[51], fapl, filename5b, NAME_BUF_SIZE); /* Create file #1 in current directory */ - if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to file & object in temporary directory #2, using symlink #1 name */ - if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file #1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR /* Create file #2 in tmp_links directory #2 */ - if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(H5Fclose(file2) < 0) TEST_ERROR + if ((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if (H5Fclose(file2) < 0) + TEST_ERROR /* Re-open file #2 in tmp_links directory through symlink */ - if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Create group in file #2 in temporary directory */ - if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create external link to file #3 & object in temporary directory #2 */ - if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close group in file #2 */ - if(H5Gclose(group2) < 0) TEST_ERROR + if (H5Gclose(group2) < 0) + TEST_ERROR /* Close file #2 */ - if(H5Fclose(file2) < 0) TEST_ERROR + if (H5Fclose(file2) < 0) + TEST_ERROR /* Create file #3 in temp. directory #2 */ - if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group in file #3 */ - if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create external link to file & object in temporary directory #1, using symlink #2 name */ - if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close group in file #3 */ - if(H5Gclose(group3) < 0) TEST_ERROR + if (H5Gclose(group3) < 0) + TEST_ERROR /* Close file #3 */ - if(H5Fclose(file3) < 0) TEST_ERROR + if (H5Fclose(file3) < 0) + TEST_ERROR /* Create file #4 in temporary directory #1 */ - if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group in file #4 in 'temporary' directory */ - if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create external link to file #5 & object in temporary directory #1 */ - if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close group in file #4 */ - if(H5Gclose(group4) < 0) TEST_ERROR + if (H5Gclose(group4) < 0) + TEST_ERROR /* Close file #4 */ - if(H5Fclose(file4) < 0) TEST_ERROR + if (H5Fclose(file4) < 0) + TEST_ERROR /* Create file #5 in temporary directory #1 */ - if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group in file #5 in 'temporary' directory #1 */ - if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group5) < 0) TEST_ERROR + if ((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group5) < 0) + TEST_ERROR /* Close file #5 */ - if(H5Fclose(file5) < 0) TEST_ERROR + if (H5Fclose(file5) < 0) + TEST_ERROR /* Actual tests... */ /* Reopen file #1 */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open group in file #2, through external link w/symlink */ - if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2) < 0) TEST_ERROR + if ((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2) < 0) + TEST_ERROR /* Open group in file #3, through external link w/symlink to external link */ - if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3) < 0) TEST_ERROR + if ((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group3) < 0) + TEST_ERROR /* Open group in file #4, through external link w/symlink to external link w/symlink */ - if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4) < 0) TEST_ERROR + if ((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group4) < 0) + TEST_ERROR /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */ - if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5) < 0) TEST_ERROR + if ((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group5) < 0) + TEST_ERROR /* Close file #1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR HDfree(filename1); HDfree(filename2a); @@ -10338,7 +12674,8 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group5); H5Gclose(group4); H5Gclose(group3); @@ -10348,7 +12685,8 @@ error: H5Fclose(file3); H5Fclose(file2); H5Fclose(file1); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(filename1); HDfree(filename2a); @@ -10364,7 +12702,7 @@ error: return FAIL; -#else /* H5_HAVE_SYMLINK */ +#else /* H5_HAVE_SYMLINK */ SKIPPED(); HDputs(" Current file system or operating system doesn't support symbolic links"); @@ -10372,7 +12710,6 @@ error: #endif /* H5_HAVE_SYMLINK */ } /* end external_symlink() */ - /*------------------------------------------------------------------------- * Function: external_copy_invalid_object * @@ -10388,12 +12725,12 @@ error: static int external_copy_invalid_object(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t ocpyplid = -1; /* Object copy plist ID */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t ocpyplid = -1; /* Object copy plist ID */ + char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("copying invalid external links to the source file (w/new group format)") else TESTING("copying invalid external links to the source file") @@ -10402,46 +12739,58 @@ external_copy_invalid_object(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Create object copy plist, set expand external flag */ - if((ocpyplid = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR - if(H5Pset_copy_object(ocpyplid, H5O_COPY_EXPAND_EXT_LINK_FLAG) < 0) TEST_ERROR + if ((ocpyplid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR + if (H5Pset_copy_object(ocpyplid, H5O_COPY_EXPAND_EXT_LINK_FLAG) < 0) + TEST_ERROR /* Create file and group */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create an external link in the group to the source file with an invalid * object name */ - if(H5Lcreate_external(filename, "no_object", fid, "/group1/link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "no_object", fid, "/group1/link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Copy the group containing the external link */ - if(H5Ocopy(fid, "group1", fid, "group2", ocpyplid, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid, "group1", fid, "group2", ocpyplid, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Attempt to truncate the file again. If there is a lingering id for this * file this will fail */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Close */ - if(H5Fclose(fid) < 0) TEST_ERROR - if(H5Pclose(ocpyplid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if (H5Pclose(ocpyplid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); H5Pclose(ocpyplid); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end external_copy_invalid_object */ - /*------------------------------------------------------------------------- * Function: external_dont_fail_to_source * @@ -10456,12 +12805,12 @@ error: static int external_dont_fail_to_source(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t oid = -1; /* Object ID */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t oid = -1; /* Object ID */ + char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("that invalid external links don't open the source file (w/new group format)") else TESTING("that invalid external links don't open the source file") @@ -10470,38 +12819,47 @@ external_dont_fail_to_source(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Create file and group */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create an external link with an invalid file name, but the same object * name as the group. This way, if the external link is interpreted to * refer to the source file, it will link to the group */ - if(H5Lcreate_external("no_file", "/group", fid, "link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external("no_file", "/group", fid, "link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Attempt to open the object the link points to. This should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { oid = H5Oopen(fid, "link", H5P_DEFAULT); - } H5E_END_TRY - if(oid >= 0) FAIL_PUTS_ERROR("Succeeded in opening target of invalid external link") + } + H5E_END_TRY + if (oid >= 0) + FAIL_PUTS_ERROR("Succeeded in opening target of invalid external link") /* Close */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Oclose(oid); H5Fclose(fid); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end external_dont_fail_to_source */ - /*------------------------------------------------------------------------- * Function: external_file_cache * @@ -10516,19 +12874,19 @@ error: static int external_file_cache(hid_t fapl, hbool_t new_format) { - hid_t my_fapl = -1; /* Temporary FAPL */ - hid_t fid1 = -1; /* File ID */ - hid_t fid2 = -1; /* File ID */ - hid_t fid3 = -1; /* File ID */ - hid_t fid4 = -1; /* File ID */ - hid_t oid = -1; /* Object ID */ - unsigned efc_size; - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; - char filename3[NAME_BUF_SIZE]; - char filename4[NAME_BUF_SIZE]; + hid_t my_fapl = -1; /* Temporary FAPL */ + hid_t fid1 = -1; /* File ID */ + hid_t fid2 = -1; /* File ID */ + hid_t fid3 = -1; /* File ID */ + hid_t fid4 = -1; /* File ID */ + hid_t oid = -1; /* Object ID */ + unsigned efc_size; + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + char filename3[NAME_BUF_SIZE]; + char filename4[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("external file cache with external links (w/new group format)") else TESTING("external file cache with external links") @@ -10540,229 +12898,302 @@ external_file_cache(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[3], fapl, filename4, sizeof filename4); /* Verify that the default EFC size is 0 */ - if(H5Pget_elink_file_cache_size(fapl, &efc_size) < 0) TEST_ERROR - if(efc_size != 0) + if (H5Pget_elink_file_cache_size(fapl, &efc_size) < 0) + TEST_ERROR + if (efc_size != 0) FAIL_PUTS_ERROR("default external file cache size is not 0") /* Copy FAPL and enable external file caching */ - if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR - if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0) TEST_ERROR + if ((my_fapl = H5Pcopy(fapl)) < 0) + TEST_ERROR + if (H5Pset_elink_file_cache_size(my_fapl, 8) < 0) + TEST_ERROR /* Verify that the external file cache size has been set */ - if(H5Pget_elink_file_cache_size(my_fapl, &efc_size) < 0) TEST_ERROR - if(efc_size != 8) + if (H5Pget_elink_file_cache_size(my_fapl, &efc_size) < 0) + TEST_ERROR + if (efc_size != 8) FAIL_PUTS_ERROR("external file cache size different from expected") /* Test 1: One file caches another */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close the target of the external link */ - if((oid = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oclose(oid) < 0) TEST_ERROR + if ((oid = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR /* Verify that both files are now open */ H5F_sfile_assert_num(2); /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); /* Test 2: One file caches another, release parent's EFC */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close the target of the external link */ - if((oid = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oclose(oid) < 0) TEST_ERROR + if ((oid = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR /* Verify that both files are now open */ H5F_sfile_assert_num(2); /* Release file 1's EFC */ - if(H5Fclear_elink_file_cache(fid1) < 0) TEST_ERROR + if (H5Fclear_elink_file_cache(fid1) < 0) + TEST_ERROR /* Verify that only the parent file is now open */ H5F_sfile_assert_num(1); /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); /* Test 3: "Y" shaped tree */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* Create links */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename4, "/", fid2, "link_to_4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename4, "/", fid2, "link_to_4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close files 2-4 */ - if(H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR - if(H5Fclose(fid4) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR + if (H5Fclose(fid4) < 0) + TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close one branch of the tree */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_3", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oclose(oid) < 0) TEST_ERROR + if ((oid = H5Oopen(fid1, "link_to_2/link_to_3", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR /* Verify that files 2 and 3 are now open */ H5F_sfile_assert_num(3); /* Open and close the other branch of the tree */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_4", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oclose(oid) < 0) TEST_ERROR + if ((oid = H5Oopen(fid1, "link_to_2/link_to_4", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR /* Verify that all files are now open */ H5F_sfile_assert_num(4); /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that all files are now closed */ H5F_sfile_assert_num(0); /* Test 4: "Y" shaped tree, release parent's EFC */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* Create links */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename4, "/", fid2, "link_to_4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename4, "/", fid2, "link_to_4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close files 2-4 */ - if(H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR - if(H5Fclose(fid4) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR + if (H5Fclose(fid4) < 0) + TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close one branch of the tree */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_3", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oclose(oid) < 0) TEST_ERROR + if ((oid = H5Oopen(fid1, "link_to_2/link_to_3", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR /* Verify that files 2 and 3 are now open */ H5F_sfile_assert_num(3); /* Open and close the other branch of the tree */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_4", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oclose(oid) < 0) TEST_ERROR + if ((oid = H5Oopen(fid1, "link_to_2/link_to_4", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR /* Verify that all files are now open */ H5F_sfile_assert_num(4); /* Release file 1's EFC */ - if(H5Fclear_elink_file_cache(fid1) < 0) TEST_ERROR + if (H5Fclear_elink_file_cache(fid1) < 0) + TEST_ERROR /* Verify that only file 1 is now open */ H5F_sfile_assert_num(1); /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that all files are now closed */ H5F_sfile_assert_num(0); /* Test 5: 3 file cycle */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* Create links */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/", fid3, "link_to_1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/", fid3, "link_to_1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close files 2-3 */ - if(H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close one complete cycle */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_3/link_to_1", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oclose(oid) < 0) TEST_ERROR + if ((oid = H5Oopen(fid1, "link_to_2/link_to_3/link_to_1", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR /* Verify that all files are now open */ H5F_sfile_assert_num(3); /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that all files are now closed */ H5F_sfile_assert_num(0); /* Test 6: 3 file cycle, release parent's EFC */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* Create links */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external(filename1, "/", fid3, "link_to_1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename3, "/", fid2, "link_to_3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external(filename1, "/", fid3, "link_to_1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close files 2-3 */ - if(H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR /* Verify that only 1 file is open */ H5F_sfile_assert_num(1); /* Open and close one complete cycle */ - if((oid = H5Oopen(fid1, "link_to_2/link_to_3/link_to_1", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oclose(oid) < 0) TEST_ERROR + if ((oid = H5Oopen(fid1, "link_to_2/link_to_3/link_to_1", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR /* Verify that all files are now open */ H5F_sfile_assert_num(3); /* Release file 1's EFC */ - if(H5Fclear_elink_file_cache(fid1) < 0) TEST_ERROR + if (H5Fclear_elink_file_cache(fid1) < 0) + TEST_ERROR /* Verify that only file 1 is now open */ H5F_sfile_assert_num(1); /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that all files are now closed */ H5F_sfile_assert_num(0); @@ -10774,19 +13205,20 @@ external_file_cache(hid_t fapl, hbool_t new_format) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Oclose(oid); H5Fclose(fid1); H5Fclose(fid2); H5Fclose(fid3); H5Fclose(fid4); H5Pclose(my_fapl); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end external_file_cache */ - /*------------------------------------------------------------------------- * Function: external_open_twice * @@ -10800,16 +13232,16 @@ error: static int external_open_twice(hid_t fapl, hbool_t new_format) { - hid_t fid1 = -1; /* File ID */ - hid_t fid2 = -1; /* File ID */ - hid_t oid1 = -1; /* Object ID */ - hid_t oid2 = -1; /* Object ID */ - hid_t type = -1; /* Datatype ID */ - hid_t space = -1; /* Dataspace ID */ - char filename1[NAME_BUF_SIZE]; - char filename2[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid1 = -1; /* File ID */ + hid_t fid2 = -1; /* File ID */ + hid_t oid1 = -1; /* Object ID */ + hid_t oid2 = -1; /* Object ID */ + hid_t type = -1; /* Datatype ID */ + hid_t space = -1; /* Dataspace ID */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + + if (new_format) TESTING("opening object twice through elink (w/new group format)") else TESTING("opening object twice through elink") @@ -10820,115 +13252,160 @@ external_open_twice(hid_t fapl, hbool_t new_format) /* Test 1: Open root group twice */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Open the target of the external link twice */ - if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if ((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR /* Close both objects, in the reverse opening order (necessary to duplicate bug */ - if(H5Oclose(oid2) < 0) TEST_ERROR - if(H5Oclose(oid1) < 0) TEST_ERROR + if (H5Oclose(oid2) < 0) + TEST_ERROR + if (H5Oclose(oid1) < 0) + TEST_ERROR /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); /* Test 2: Open group twice */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create target group */ - if((oid1 = H5Gcreate2(fid2, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(oid1) < 0) TEST_ERROR + if ((oid1 = H5Gcreate2(fid2, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(oid1) < 0) + TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/group", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/group", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Open the target of the external link twice */ - if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if ((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR /* Close both objects, in the reverse opening order (necessary to duplicate bug */ - if(H5Oclose(oid2) < 0) TEST_ERROR - if(H5Oclose(oid1) < 0) TEST_ERROR + if (H5Oclose(oid2) < 0) + TEST_ERROR + if (H5Oclose(oid1) < 0) + TEST_ERROR /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); /* Test 3: Open dataset twice */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create target dataset */ - if((space = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR - if((oid1 = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(oid1) < 0) TEST_ERROR - if(H5Sclose(space) < 0) TEST_ERROR + if ((space = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR + if ((oid1 = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(oid1) < 0) + TEST_ERROR + if (H5Sclose(space) < 0) + TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/dset", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/dset", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Open the target of the external link twice */ - if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if ((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR /* Close both objects, in the reverse opening order (necessary to duplicate bug */ - if(H5Oclose(oid2) < 0) TEST_ERROR - if(H5Oclose(oid1) < 0) TEST_ERROR + if (H5Oclose(oid2) < 0) + TEST_ERROR + if (H5Oclose(oid1) < 0) + TEST_ERROR /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); /* Test 4: Open datatype twice */ /* Create files */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create target datatype */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(fid2, "dtype", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(type) < 0) TEST_ERROR + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(fid2, "dtype", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(type) < 0) + TEST_ERROR /* Create link */ - if(H5Lcreate_external(filename2, "/dtype", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/dtype", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file 2 */ - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Open the target of the external link twice */ - if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR - if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) TEST_ERROR + if ((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR /* Close both objects, in the reverse opening order (necessary to duplicate bug */ - if(H5Oclose(oid2) < 0) TEST_ERROR - if(H5Oclose(oid1) < 0) TEST_ERROR + if (H5Oclose(oid2) < 0) + TEST_ERROR + if (H5Oclose(oid1) < 0) + TEST_ERROR /* Close file 1 */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Verify that both files are now closed */ H5F_sfile_assert_num(0); @@ -10937,19 +13414,20 @@ external_open_twice(hid_t fapl, hbool_t new_format) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Oclose(oid1); H5Oclose(oid2); H5Tclose(type); H5Fclose(fid1); H5Fclose(fid2); H5Sclose(space); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end external_open_twice() */ - /*------------------------------------------------------------------------- * Function: external_link_with_committed_datatype * @@ -10972,26 +13450,26 @@ error: static int external_link_with_committed_datatype(hid_t fapl, hbool_t new_format) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gid1 = -1, gid2 = -1; /* Group IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t sid2 = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t atid = -1; /* Attribute's datatype ID */ - hid_t did = -1; /* Dataset ID */ - hid_t dtid = -1; /* Dataset's datatype ID */ - hid_t dcpl = -1; /* Dataset creation property list */ - int wdata = 99; /* Attribute data written */ - int wbuf[60]; /* Data buffer for writing */ - int rbuf[60]; /* Data buffer for reading */ - int i; /* Local index variable */ - char filename1[NAME_BUF_SIZE]; /* File name for main file */ - char filename2[NAME_BUF_SIZE]; /* File name for target file */ - hsize_t dims[2] = {5, 12}; /* Dimension sizes */ - hsize_t chunks[2] = {3, 7}; /* Chunk sizes */ - - if(new_format) + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gid1 = -1, gid2 = -1; /* Group IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t sid2 = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t atid = -1; /* Attribute's datatype ID */ + hid_t did = -1; /* Dataset ID */ + hid_t dtid = -1; /* Dataset's datatype ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + int wdata = 99; /* Attribute data written */ + int wbuf[60]; /* Data buffer for writing */ + int rbuf[60]; /* Data buffer for reading */ + int i; /* Local index variable */ + char filename1[NAME_BUF_SIZE]; /* File name for main file */ + char filename2[NAME_BUF_SIZE]; /* File name for target file */ + hsize_t dims[2] = {5, 12}; /* Dimension sizes */ + hsize_t chunks[2] = {3, 7}; /* Chunk sizes */ + + if (new_format) TESTING("attach committed datatype to external group's attribute/dataset(w/new group format)") else TESTING("attach committed datatype to external group's attribute/dataset") @@ -11001,159 +13479,210 @@ external_link_with_committed_datatype(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Main file */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create external link from main file to target file */ - if(H5Lcreate_external(filename2, "target_group", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_external(filename2, "target_group", fid1, "link_to_2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create target file */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create group in target file */ - if((gid2 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid2) < 0) + FAIL_STACK_ERROR /* Open the group which is externally linked to target file */ - if((gid1 = H5Gopen2(fid1, "link_to_2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid1 = H5Gopen2(fid1, "link_to_2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a copy of integer datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR /* Commit the datatype to the main file root group */ - if(H5Tcommit2(fid1, "myDatatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Tcommit2(fid1, "myDatatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR /* Attach an attribute with the committed datatype to the group */ - if((aid = H5Acreate2(gid1, "myAttribute", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((aid = H5Acreate2(gid1, "myAttribute", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Write data to the attribute */ - if(H5Awrite(aid, tid, &wdata) < 0) FAIL_STACK_ERROR + if (H5Awrite(aid, tid, &wdata) < 0) + FAIL_STACK_ERROR /* Get the attribute's datatype */ - if((atid = H5Aget_type(aid)) < 0) FAIL_STACK_ERROR + if ((atid = H5Aget_type(aid)) < 0) + FAIL_STACK_ERROR /* Verify the datatype is not committed */ - if(H5Tcommitted(atid) == TRUE) FAIL_STACK_ERROR + if (H5Tcommitted(atid) == TRUE) + FAIL_STACK_ERROR /* Close the attribute */ - if(H5Aclose(aid) < 0) FAIL_STACK_ERROR + if (H5Aclose(aid) < 0) + FAIL_STACK_ERROR /* Create a chunked dataset */ - if((sid2 = H5Screate_simple(2, dims, NULL)) < 0) FAIL_STACK_ERROR + if ((sid2 = H5Screate_simple(2, dims, NULL)) < 0) + FAIL_STACK_ERROR if (dcpl_g == H5P_DEFAULT) dcpl = H5Pcreate(H5P_DATASET_CREATE); else dcpl = H5Pcopy(dcpl_g); - if (0 > dcpl) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunks) < 0) FAIL_STACK_ERROR + if (0 > dcpl) + FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl, 2, chunks) < 0) + FAIL_STACK_ERROR /* Initialize data buffers */ - for(i = 0; i < 60; i++) { + for (i = 0; i < 60; i++) { wbuf[i] = i; rbuf[i] = 0; } /* Create a dataset with the committed datatype in the group */ - if((did = H5Dcreate2(gid1, "myDataset", tid, sid2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did = H5Dcreate2(gid1, "myDataset", tid, sid2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Write to the dataset */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) FAIL_STACK_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + FAIL_STACK_ERROR /* Get the dataset's datatype */ - if((dtid = H5Dget_type(did)) < 0) FAIL_STACK_ERROR + if ((dtid = H5Dget_type(did)) < 0) + FAIL_STACK_ERROR /* Verify the datatype is not committed */ - if(H5Tcommitted(dtid) == TRUE) FAIL_STACK_ERROR + if (H5Tcommitted(dtid) == TRUE) + FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Close the dataset creation property list */ - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) + FAIL_STACK_ERROR /* Close the dataspaces */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid2) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid2) < 0) + FAIL_STACK_ERROR /* Close the datatypes */ - if(H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(atid) < 0) FAIL_STACK_ERROR - if(H5Tclose(dtid) < 0) FAIL_STACK_ERROR + if (H5Tclose(tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(atid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(dtid) < 0) + FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(gid1) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid1) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid1) < 0) + FAIL_STACK_ERROR /* Open the mainfile */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Open the committed datatype in the mainfile */ - if((tid = H5Topen2(fid1, "myDatatype", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid = H5Topen2(fid1, "myDatatype", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify the datatype is committed */ - if(H5Tcommitted(tid) == FALSE) FAIL_STACK_ERROR + if (H5Tcommitted(tid) == FALSE) + FAIL_STACK_ERROR /* Open the group which is externally linked to target file */ - if((gid1 = H5Gopen2(fid1, "link_to_2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid1 = H5Gopen2(fid1, "link_to_2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Open the attribute attached to the group */ - if((aid = H5Aopen(gid1, "myAttribute", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((aid = H5Aopen(gid1, "myAttribute", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the attribute's datatype */ - if((atid = H5Aget_type(aid)) < 0) FAIL_STACK_ERROR + if ((atid = H5Aget_type(aid)) < 0) + FAIL_STACK_ERROR /* Verify the attribute's datatype is not committed */ - if(H5Tcommitted(atid) == TRUE) FAIL_STACK_ERROR + if (H5Tcommitted(atid) == TRUE) + FAIL_STACK_ERROR /* Close the attribute */ - if(H5Aclose(aid) < 0) FAIL_STACK_ERROR + if (H5Aclose(aid) < 0) + FAIL_STACK_ERROR /* Delete the attribute */ - if(H5Adelete(gid1, "myAttribute") < 0) FAIL_STACK_ERROR + if (H5Adelete(gid1, "myAttribute") < 0) + FAIL_STACK_ERROR /* Open the dataset in the group */ - if((did = H5Dopen2(gid1, "myDataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did = H5Dopen2(gid1, "myDataset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the dataset's datatype */ - if((dtid = H5Dget_type(did)) < 0) FAIL_STACK_ERROR + if ((dtid = H5Dget_type(did)) < 0) + FAIL_STACK_ERROR /* Verify the dataset's datatype is not committed */ - if(H5Tcommitted(dtid) == TRUE) FAIL_STACK_ERROR + if (H5Tcommitted(dtid) == TRUE) + FAIL_STACK_ERROR /* Read the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) FAIL_STACK_ERROR + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + FAIL_STACK_ERROR /* Compare the data read should be the same as wbuf */ - if(HDmemcmp(wbuf, rbuf, sizeof(wbuf)) != 0) FAIL_STACK_ERROR + if (HDmemcmp(wbuf, rbuf, sizeof(wbuf)) != 0) + FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(gid1) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid1) < 0) + FAIL_STACK_ERROR /* Close the datatypes */ - if(H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Tclose(atid) < 0) FAIL_STACK_ERROR - if(H5Tclose(dtid) < 0) FAIL_STACK_ERROR + if (H5Tclose(tid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(atid) < 0) + FAIL_STACK_ERROR + if (H5Tclose(dtid) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid2); H5Fclose(fid1); H5Gclose(gid1); @@ -11170,12 +13699,12 @@ error: H5Aclose(dtid); H5Pclose(dcpl); - } H5E_END_TRY + } + H5E_END_TRY return FAIL; } /* end external_link_with_committed_datatype() */ - /*------------------------------------------------------------------------- * Function: ud_hard_links * @@ -11189,14 +13718,14 @@ error: /* Callback functions for UD hard links. */ /* UD_hard_create increments the object's reference count */ static herr_t -UD_hard_create(const char H5_ATTR_UNUSED * link_name, hid_t loc_group, const void *udata, - size_t udata_size, hid_t H5_ATTR_UNUSED lcpl_id) +UD_hard_create(const char H5_ATTR_UNUSED *link_name, hid_t loc_group, const void *udata, size_t udata_size, + hid_t H5_ATTR_UNUSED lcpl_id) { H5O_token_t token; - hid_t target_obj = -1; - herr_t ret_value = 0; + hid_t target_obj = -1; + herr_t ret_value = 0; - if(udata_size != sizeof(H5O_token_t)) { + if (udata_size != sizeof(H5O_token_t)) { ret_value = -1; goto done; } /* end if */ @@ -11205,33 +13734,33 @@ UD_hard_create(const char H5_ATTR_UNUSED * link_name, hid_t loc_group, const voi /* Open the object this link points to */ target_obj = H5Oopen_by_token(loc_group, token); - if(target_obj < 0) { + if (target_obj < 0) { ret_value = -1; goto done; } /* end if */ /* Increment the reference count of the target object */ - if(H5Oincr_refcount(target_obj) < 0) { + if (H5Oincr_refcount(target_obj) < 0) { ret_value = -1; goto done; } /* end if */ done: /* Close the target object if we opened it */ - if(target_obj >= 0) { - switch(H5Iget_type(target_obj)) { + if (target_obj >= 0) { + switch (H5Iget_type(target_obj)) { case H5I_GROUP: - if(H5Gclose(target_obj) < 0) + if (H5Gclose(target_obj) < 0) ret_value = -1; break; case H5I_DATASET: - if(H5Dclose(target_obj) < 0) + if (H5Dclose(target_obj) < 0) ret_value = -1; break; case H5I_DATATYPE: - if(H5Tclose(target_obj) < 0) + if (H5Tclose(target_obj) < 0) ret_value = -1; break; @@ -11253,23 +13782,22 @@ done: case H5I_SPACE_SEL_ITER: case H5I_NTYPES: default: - return FAIL; + return FAIL; } /* end switch */ - } /* end if */ + } /* end if */ return ret_value; } /* end UD_hard_create() */ /* Traverse a hard link by opening the object */ static hid_t -UD_hard_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t H5_ATTR_UNUSED lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id) +UD_hard_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const void *udata, size_t udata_size, + hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id) { H5O_token_t token; - hid_t ret_value = -1; + hid_t ret_value = -1; - if(udata_size != sizeof(H5O_token_t)) + if (udata_size != sizeof(H5O_token_t)) return FAIL; token = *(const H5O_token_t *)udata; @@ -11282,14 +13810,13 @@ UD_hard_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, /* UD_hard_delete decrements the object's reference count */ static herr_t -UD_hard_delete(const char H5_ATTR_UNUSED * link_name, hid_t file, const void *udata, - size_t udata_size) +UD_hard_delete(const char H5_ATTR_UNUSED *link_name, hid_t file, const void *udata, size_t udata_size) { H5O_token_t token; - hid_t target_obj = -1; - herr_t ret_value = 0; + hid_t target_obj = -1; + herr_t ret_value = 0; - if(udata_size != sizeof(H5O_token_t)) { + if (udata_size != sizeof(H5O_token_t)) { ret_value = -1; goto done; } /* end if */ @@ -11298,33 +13825,33 @@ UD_hard_delete(const char H5_ATTR_UNUSED * link_name, hid_t file, const void *ud /* Open the object this link points to */ target_obj = H5Oopen_by_token(file, token); - if(target_obj < 0) { + if (target_obj < 0) { ret_value = -1; goto done; } /* end if */ /* Decrement the reference count of the target object */ - if(H5Odecr_refcount(target_obj) < 0) { + if (H5Odecr_refcount(target_obj) < 0) { ret_value = -1; goto done; } /* end if */ done: /* Close the target object if we opened it */ - if(target_obj >= 0) { - switch(H5Iget_type(target_obj)) { + if (target_obj >= 0) { + switch (H5Iget_type(target_obj)) { case H5I_GROUP: - if(H5Gclose(target_obj) < 0) + if (H5Gclose(target_obj) < 0) ret_value = -1; break; case H5I_DATASET: - if(H5Dclose(target_obj) < 0) + if (H5Dclose(target_obj) < 0) ret_value = -1; break; case H5I_DATATYPE: - if(H5Tclose(target_obj) < 0) + if (H5Tclose(target_obj) < 0) ret_value = -1; break; @@ -11348,7 +13875,7 @@ done: default: return FAIL; } /* end switch */ - } /* end if */ + } /* end if */ return ret_value; } /* end UD_hard_delete() */ @@ -11356,11 +13883,11 @@ done: static int ud_hard_links(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5L_info2_t li; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ - h5_stat_size_t empty_size; /* Size of an empty file */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info2_t li; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ + h5_stat_size_t empty_size; /* Size of an empty file */ char filename[NAME_BUF_SIZE]; TESTING("user-defined hard link (w/new group format)") @@ -11368,70 +13895,98 @@ ud_hard_links(hid_t fapl) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Get the size of the empty file for reference */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((empty_size = h5_get_file_size(filename, fapl))<0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Check that external links are registered and UD hard links are not */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + TEST_ERROR /* Register "user-defined hard links" with the library */ - if(H5Lregister(UD_hard_class) < 0) TEST_ERROR + if (H5Lregister(UD_hard_class) < 0) + TEST_ERROR /* Check that UD hard links are now registered */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + TEST_ERROR /* Create a group for the UD hard link to point to */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Get address for the group to give to the hard link */ - if(H5Lget_info2(fid, "group", &li, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info2(fid, "group", &li, H5P_DEFAULT) < 0) + TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create a user-defined "hard link" to the group using the address we got * from H5Lget_info2 */ - if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.token), sizeof(H5O_token_t), H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.token), sizeof(H5O_token_t), + H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close and re-open file to ensure that data is written to disk */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open group through UD link */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/group")) + TEST_ERROR /* Create object in group */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close groups*/ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Re-open group without using ud link to check that it was created properly */ - if((gid = H5Gopen2(fid, "group/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "group/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/group/new_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/group/new_group")) + TEST_ERROR /* Close opened object */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Check that H5Lget_objinfo works on the hard link */ - if(H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* UD hard links have no query function, thus return a "link length" of 0 */ - if(li.u.val_size != 0) TEST_ERROR - if(UD_HARD_TYPE != li.type) { + if (li.u.val_size != 0) + TEST_ERROR + if (UD_HARD_TYPE != li.type) { H5_FAILED(); HDputs(" Unexpected link class - should have been a UD hard link"); goto error; @@ -11439,40 +13994,49 @@ ud_hard_links(hid_t fapl) /* Unlink the group pointed to by the UD link. It shouldn't be * deleted because of the UD link. */ - if(H5Ldelete(fid, "/group", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "/group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Ensure we can open the group through the UD link */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Unlink the group contained within it. */ - if(H5Ldelete(gid, "new_group", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, "new_group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Now delete the UD link. This should cause the group to be * deleted, too. */ - if(H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* The file should be empty again. */ - if(empty_size != h5_get_file_size(filename, fapl)) TEST_ERROR + if (empty_size != h5_get_file_size(filename, fapl)) + TEST_ERROR - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end ud_hard_links() */ - /*------------------------------------------------------------------------- * Function: UD_rereg_traverse * @@ -11487,13 +14051,13 @@ error: * in the current group named REREG_TARGET_NAME */ static hid_t -UD_rereg_traverse(const char H5_ATTR_UNUSED * link_name, hid_t cur_group, - const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size, hid_t lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id) +UD_rereg_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const void H5_ATTR_UNUSED *udata, + size_t H5_ATTR_UNUSED udata_size, hid_t lapl_id, hid_t H5_ATTR_UNUSED dxpl_id) { hid_t ret_value; - if((ret_value = H5Oopen(cur_group, REREG_TARGET_NAME, lapl_id)) < 0) TEST_ERROR + if ((ret_value = H5Oopen(cur_group, REREG_TARGET_NAME, lapl_id)) < 0) + TEST_ERROR return ret_value; @@ -11504,143 +14068,187 @@ error: static int ud_link_reregister(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5L_info2_t li; /* Link information */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; - h5_stat_size_t empty_size; /* Size of an empty file */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5L_info2_t li; /* Link information */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; + h5_stat_size_t empty_size; /* Size of an empty file */ TESTING("registering a new class for existing UD links (w/new group format)") /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Get the size of the empty file for reference */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((empty_size = h5_get_file_size(filename, fapl))<0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Check that UD hard links are not registered */ - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + TEST_ERROR /* Register "user-defined hard links" with the library */ - if(H5Lregister(UD_hard_class) < 0) TEST_ERROR + if (H5Lregister(UD_hard_class) < 0) + TEST_ERROR /* Check that UD hard links are registered */ - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + TEST_ERROR /* Point a UD defined hard link to a group in the same way as the previous test */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lget_info2(fid, "group", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lget_info2(fid, "group", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.token), - sizeof(H5O_token_t), H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_HARD_TYPE, &(li.u.token), sizeof(H5O_token_t), + H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Create a group named REREG_TARGET_NAME in the same group as the ud link */ - if((gid = H5Gcreate2(fid, REREG_TARGET_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, REREG_TARGET_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Now unregister UD hard links */ - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) TEST_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + TEST_ERROR /* Check that UD hard links are no longer registered */ - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + TEST_ERROR /* Verify that we can't traverse the ud link anymore */ - H5E_BEGIN_TRY { - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) >= 0) TEST_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) >= 0) + TEST_ERROR + } + H5E_END_TRY /* Verify that we can't create any new links of this type */ - H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.token), - sizeof(H5O_token_t), H5P_DEFAULT, H5P_DEFAULT) >= 0) + H5E_BEGIN_TRY + { + if (H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.token), sizeof(H5O_token_t), + H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR - } H5E_END_TRY + } + H5E_END_TRY /* Register a new kind of link with the same ID number */ - if(H5Lregister(UD_rereg_class) < 0) TEST_ERROR + if (H5Lregister(UD_rereg_class) < 0) + TEST_ERROR /* Check that UD hard links are registered again */ - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + TEST_ERROR /* Open a group through the ud link (now a different class of link). * It should be a different group * than the UD hard link pointed to */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/" REREG_TARGET_NAME)) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/" REREG_TARGET_NAME)) + TEST_ERROR /* Create object in group */ - if((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close groups*/ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Re-open group without using ud link to check that it was created properly */ - if((gid = H5Gopen2(fid, "rereg_target/new_group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "rereg_target/new_group", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/rereg_target/new_group")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/rereg_target/new_group")) + TEST_ERROR /* Close opened object */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Unlink the group pointed to by the UD hard link. It shouldn't be * deleted because the UD link incremented its reference count. */ - if(H5Ldelete(fid, "/group", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "/group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* What a mess! Re-register user-defined links to clean up the * reference counts. We shouldn't actually need to unregister the * other link type */ - if(H5Lregister(UD_hard_class) < 0) FAIL_STACK_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) FAIL_STACK_ERROR + if (H5Lregister(UD_hard_class) < 0) + FAIL_STACK_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + FAIL_STACK_ERROR /* Ensure we can open the group through the UD link (now that UD hard * links have been registered) */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Delete the UD hard link. This should cause the group to be * deleted, too. */ - if(H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Unlink the other two groups so that we can make sure the file is empty */ - if(H5Ldelete(fid, "/rereg_target/new_group", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, REREG_TARGET_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "/rereg_target/new_group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, REREG_TARGET_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* The file should be empty again. */ - if(empty_size != h5_get_file_size(filename, fapl)) TEST_ERROR + if (empty_size != h5_get_file_size(filename, fapl)) + TEST_ERROR - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) FAIL_STACK_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + FAIL_STACK_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end ud_link_reregister() */ - /*------------------------------------------------------------------------- * Function: UD_cb_create * @@ -11654,17 +14262,23 @@ error: /* Callback functions for UD "callback" links. */ /* Creation callback. Called during move as well. */ static herr_t -UD_cb_create(const char * link_name, hid_t loc_group, const void *udata, - size_t udata_size, hid_t lcpl_id) +UD_cb_create(const char *link_name, hid_t loc_group, const void *udata, size_t udata_size, hid_t lcpl_id) { - if(!link_name) TEST_ERROR - if(loc_group < 0) TEST_ERROR - if(udata_size > 0 && !udata) TEST_ERROR - if(lcpl_id < 0) TEST_ERROR + if (!link_name) + TEST_ERROR + if (loc_group < 0) + TEST_ERROR + if (udata_size > 0 && !udata) + TEST_ERROR + if (lcpl_id < 0) + TEST_ERROR - if(HDstrcmp(link_name, UD_CB_LINK_NAME) && strcmp(link_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR - if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR - if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR + if (HDstrcmp(link_name, UD_CB_LINK_NAME) && strcmp(link_name, NEW_UD_CB_LINK_NAME)) + TEST_ERROR + if (HDstrcmp((const char *)udata, UD_CB_TARGET)) + TEST_ERROR + if (udata_size != UD_CB_TARGET_LEN) + TEST_ERROR return SUCCEED; @@ -11673,21 +14287,27 @@ error: } /* end UD_cb_create() */ static hid_t -UD_cb_traverse(const char * link_name, hid_t cur_group, const void *udata, - size_t udata_size, hid_t lapl_id, hid_t H5_ATTR_UNUSED dxpl_id) +UD_cb_traverse(const char *link_name, hid_t cur_group, const void *udata, size_t udata_size, hid_t lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id) { const char *target = (const char *)udata; - hid_t ret_value; + hid_t ret_value; - if(!link_name) TEST_ERROR - if(cur_group < 0) TEST_ERROR - if(udata_size > 0 && !udata) TEST_ERROR + if (!link_name) + TEST_ERROR + if (cur_group < 0) + TEST_ERROR + if (udata_size > 0 && !udata) + TEST_ERROR - if(HDstrcmp(link_name, UD_CB_LINK_NAME) && strcmp(link_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR - if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR - if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR + if (HDstrcmp(link_name, UD_CB_LINK_NAME) && strcmp(link_name, NEW_UD_CB_LINK_NAME)) + TEST_ERROR + if (HDstrcmp((const char *)udata, UD_CB_TARGET)) + TEST_ERROR + if (udata_size != UD_CB_TARGET_LEN) + TEST_ERROR - if((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0) + if ((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0) TEST_ERROR return ret_value; @@ -11698,16 +14318,21 @@ error: /* Callback for when the link is moved or renamed */ static herr_t -UD_cb_move(const char *new_name, hid_t new_loc, const void *udata, - size_t udata_size) +UD_cb_move(const char *new_name, hid_t new_loc, const void *udata, size_t udata_size) { - if(!new_name) TEST_ERROR - if(new_loc < 0) TEST_ERROR - if(udata_size > 0 && !udata) TEST_ERROR + if (!new_name) + TEST_ERROR + if (new_loc < 0) + TEST_ERROR + if (udata_size > 0 && !udata) + TEST_ERROR - if(HDstrcmp(new_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR - if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR - if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR + if (HDstrcmp(new_name, NEW_UD_CB_LINK_NAME)) + TEST_ERROR + if (HDstrcmp((const char *)udata, UD_CB_TARGET)) + TEST_ERROR + if (udata_size != UD_CB_TARGET_LEN) + TEST_ERROR return SUCCEED; @@ -11717,16 +14342,21 @@ error: /* Callback for when the link is deleted. Also called during move */ static herr_t -UD_cb_delete(const char *link_name, hid_t file, const void *udata, - size_t udata_size) +UD_cb_delete(const char *link_name, hid_t file, const void *udata, size_t udata_size) { - if(!link_name) TEST_ERROR - if(file < 0) TEST_ERROR - if(udata_size > 0 && !udata) TEST_ERROR + if (!link_name) + TEST_ERROR + if (file < 0) + TEST_ERROR + if (udata_size > 0 && !udata) + TEST_ERROR - if(HDstrcmp(link_name, UD_CB_LINK_NAME) && HDstrcmp(link_name, NEW_UD_CB_LINK_NAME)) TEST_ERROR - if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR - if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR + if (HDstrcmp(link_name, UD_CB_LINK_NAME) && HDstrcmp(link_name, NEW_UD_CB_LINK_NAME)) + TEST_ERROR + if (HDstrcmp((const char *)udata, UD_CB_TARGET)) + TEST_ERROR + if (udata_size != UD_CB_TARGET_LEN) + TEST_ERROR return SUCCEED; @@ -11736,19 +14366,24 @@ error: /* Callback for when the link is queried */ static ssize_t -UD_cb_query(const char * link_name, const void *udata, size_t udata_size, - void *buf, size_t buf_size) +UD_cb_query(const char *link_name, const void *udata, size_t udata_size, void *buf, size_t buf_size) { - if(!link_name) TEST_ERROR - if(udata_size > 0 && !udata) TEST_ERROR + if (!link_name) + TEST_ERROR + if (udata_size > 0 && !udata) + TEST_ERROR - if(HDstrcmp(link_name, UD_CB_LINK_NAME)) TEST_ERROR - if(HDstrcmp((const char *)udata, UD_CB_TARGET)) TEST_ERROR - if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR + if (HDstrcmp(link_name, UD_CB_LINK_NAME)) + TEST_ERROR + if (HDstrcmp((const char *)udata, UD_CB_TARGET)) + TEST_ERROR + if (udata_size != UD_CB_TARGET_LEN) + TEST_ERROR - if(buf) { - if(buf_size < 16) TEST_ERROR - HDstrcpy((char *)buf, "query succeeded"); + if (buf) { + if (buf_size < 16) + TEST_ERROR + HDstrcpy((char *)buf, "query succeeded"); } /* end if */ /* There are 15 characters and a NULL in "query succeeded" */ @@ -11761,15 +14396,15 @@ error: static int ud_callbacks(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ hid_t lcpl = -1; /* Link Creation PL */ H5L_info2_t li; /* Link information */ char ud_target_name[] = UD_CB_TARGET; /* Link target name */ char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("user-defined link callbacks (w/new group format)") else TESTING("user-defined link callbacks") @@ -11777,40 +14412,57 @@ ud_callbacks(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Check that registered link classes are, and unregistered ones aren't */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_CB_TYPE) != FALSE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != FALSE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_CB_TYPE) != FALSE) + TEST_ERROR /* Hit two birds with one stone: register UD hard links from previous * test to check that having two UD links registered at once presents * no problems. */ - if(H5Lregister(UD_hard_class) < 0) TEST_ERROR + if (H5Lregister(UD_hard_class) < 0) + TEST_ERROR /* Register user-defined link class. This is the one we'll actually be using. */ - if(H5Lregister(UD_cb_class) < 0) TEST_ERROR + if (H5Lregister(UD_cb_class) < 0) + TEST_ERROR /* Check that registered link classes are, and unregistered ones aren't */ - if(H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) TEST_ERROR - if(H5Lis_registered((H5L_type_t)UD_CB_TYPE) != TRUE) TEST_ERROR + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_HARD_TYPE) != TRUE) + TEST_ERROR + if (H5Lis_registered((H5L_type_t)UD_CB_TYPE) != TRUE) + TEST_ERROR /* Create a group for the UD link to point to */ - if((gid = H5Gcreate2(fid, UD_CB_TARGET, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, UD_CB_TARGET, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create a user-defined link to the group. These UD links behave like soft links. */ - if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, + H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Try opening group through UD link */ - if((gid = H5Gopen2(fid, UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gopen2(fid, UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Query the link to test its query callback */ - if(H5Lget_info2(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.u.val_size != 16) TEST_ERROR + if (H5Lget_info2(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.u.val_size != 16) + TEST_ERROR if (UD_CB_TYPE != li.type) { H5_FAILED(); HDputs(" Unexpected link class - should have been a UD hard link"); @@ -11818,68 +14470,96 @@ ud_callbacks(hid_t fapl, hbool_t new_format) } /* Fill the query buffer */ - if(H5Lget_val(fid, UD_CB_LINK_NAME, query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(HDstrcmp(query_buf, "query succeeded") != 0) TEST_ERROR + if (H5Lget_val(fid, UD_CB_LINK_NAME, query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(query_buf, "query succeeded") != 0) + TEST_ERROR /* Move the link */ - if(H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Re-open group to ensure that move worked */ - if((gid = H5Gopen2(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Remove UD link */ - if(H5Ldelete(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, NEW_UD_CB_LINK_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Test that the callbacks don't work if the link class is not registered */ /* Create a new link. Just for fun, give it a non-default character * encoding (to test that LAPLs work) */ - if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_char_encoding(lcpl, H5T_CSET_UTF8) < 0) FAIL_STACK_ERROR - if(H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, lcpl, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Pclose(lcpl) < 0) FAIL_STACK_ERROR + if ((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_char_encoding(lcpl, H5T_CSET_UTF8) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_ud(fid, UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, + lcpl, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Pclose(lcpl) < 0) + FAIL_STACK_ERROR /* Check its character encoding */ - if(H5Lget_info2(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(li.cset != H5T_CSET_UTF8) TEST_ERROR + if (H5Lget_info2(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (li.cset != H5T_CSET_UTF8) + TEST_ERROR /* Unregister the link class so the library forgets what its callbacks do */ - if(H5Lunregister((H5L_type_t)UD_CB_TYPE) < 0) FAIL_STACK_ERROR + if (H5Lunregister((H5L_type_t)UD_CB_TYPE) < 0) + FAIL_STACK_ERROR /* Now test that each of the callbacks fails */ - H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR - if(H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR - if((gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT)) >= 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) FAIL_STACK_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, + (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) + FAIL_STACK_ERROR + if (H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) >= 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) + FAIL_STACK_ERROR + if ((gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT)) >= 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) + FAIL_STACK_ERROR + } + H5E_END_TRY /* The query callback should NOT fail, but should be unable to give a linklen */ - if(H5Lget_info2(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(li.u.val_size != 0) TEST_ERROR - if(li.type != UD_CB_TYPE) TEST_ERROR + if (H5Lget_info2(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (li.u.val_size != 0) + TEST_ERROR + if (li.type != UD_CB_TYPE) + TEST_ERROR /* Unregister the UD hard links */ - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) FAIL_STACK_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Pclose (lcpl); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(lcpl); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end ud_callbacks() */ - /*------------------------------------------------------------------------- * Function: lapl_udata * @@ -11891,19 +14571,21 @@ error: *------------------------------------------------------------------------- */ static hid_t -UD_plist_traverse(const char H5_ATTR_UNUSED * link_name, hid_t cur_group, - const void H5_ATTR_UNUSED *udata, size_t udata_size, hid_t lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id) +UD_plist_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const void H5_ATTR_UNUSED *udata, + size_t udata_size, hid_t lapl_id, hid_t H5_ATTR_UNUSED dxpl_id) { - char target[NAME_BUF_SIZE]; + char target[NAME_BUF_SIZE]; hid_t ret_value; - if(udata_size != 0) TEST_ERROR + if (udata_size != 0) + TEST_ERROR /* Get the name of the target from the property list. */ - if(H5Pget(lapl_id, DEST_PROP_NAME, target) < 0) TEST_ERROR + if (H5Pget(lapl_id, DEST_PROP_NAME, target) < 0) + TEST_ERROR - if((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0) TEST_ERROR + if ((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0) + TEST_ERROR return ret_value; @@ -11914,14 +14596,14 @@ error: static int lapl_udata(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t plist_id = -1; /* Property List ID */ - char group_a_name[NAME_BUF_SIZE]; - char group_b_name[NAME_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t plist_id = -1; /* Property List ID */ + char group_a_name[NAME_BUF_SIZE]; + char group_b_name[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; + + if (new_format) TESTING("user data passed through lapl (w/new group format)") else TESTING("user data passed through lapl") @@ -11929,80 +14611,110 @@ lapl_udata(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Register UD link types from previous tests to check that having * multiple types registered at once presents no problems. */ - if(H5Lregister(UD_cb_class) < 0) TEST_ERROR + if (H5Lregister(UD_cb_class) < 0) + TEST_ERROR /* Register the link class. We'll actually be using for this test. */ - if(H5Lregister(UD_plist_class) < 0) TEST_ERROR + if (H5Lregister(UD_plist_class) < 0) + TEST_ERROR /* Another link class from a previous test */ - if(H5Lregister(UD_hard_class) < 0) TEST_ERROR + if (H5Lregister(UD_hard_class) < 0) + TEST_ERROR /* Unregister the first link type registered to make sure this doesn't * break anything. */ - if(H5Lunregister((H5L_type_t)UD_CB_TYPE) < 0) TEST_ERROR + if (H5Lunregister((H5L_type_t)UD_CB_TYPE) < 0) + TEST_ERROR /* Create two groups for the UD link to point to */ - if((gid = H5Gcreate2(fid, "group_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "group_b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "group_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "group_b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create a user-defined link to the group. These UD links have no udata. */ - if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < + 0) + TEST_ERROR /* Create a non-default lapl with a new property pointing to group a*/ - if((plist_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR + if ((plist_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) + TEST_ERROR HDstrcpy(group_a_name, "group_a"); - if(H5Pinsert2(plist_id, DEST_PROP_NAME, (size_t)NAME_BUF_SIZE, group_a_name, NULL, NULL, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if (H5Pinsert2(plist_id, DEST_PROP_NAME, (size_t)NAME_BUF_SIZE, group_a_name, NULL, NULL, NULL, NULL, + NULL, NULL) < 0) + TEST_ERROR /* Try opening group through UD link */ - if((gid = H5Oopen(fid, "ud_link", plist_id)) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(gid, "subgroup_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Oopen(fid, "ud_link", plist_id)) < 0) + TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "subgroup_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Verify that we can open the new group without using the ud link */ - if((gid2 = H5Gopen2(fid, "/group_a/subgroup_a", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid, "/group_a/subgroup_a", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Now use the same ud link to access group_b */ strcpy(group_b_name, "group_b"); - if(H5Pset(plist_id, DEST_PROP_NAME, group_b_name) < 0) TEST_ERROR + if (H5Pset(plist_id, DEST_PROP_NAME, group_b_name) < 0) + TEST_ERROR /* Create a subgroup */ - if((gid = H5Oopen(fid, "ud_link", plist_id)) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(gid, "subgroup_b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Oopen(fid, "ud_link", plist_id)) < 0) + TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "subgroup_b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Verify that we can open the new group without using the ud link */ - if((gid2 = H5Gopen2(fid, "/group_b/subgroup_b", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid, "/group_b/subgroup_b", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close property list */ - if(H5Pclose(plist_id) < 0) TEST_ERROR + if (H5Pclose(plist_id) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Pclose (plist_id); - H5Gclose (gid); - H5Gclose (gid2); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(plist_id); + H5Gclose(gid); + H5Gclose(gid2); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end lapl_udata() */ - /*------------------------------------------------------------------------- * Function: ud_link_errors * @@ -12014,26 +14726,28 @@ error: *------------------------------------------------------------------------- */ static herr_t -UD_cbsucc_create(const char H5_ATTR_UNUSED * link_name, hid_t H5_ATTR_UNUSED loc_group, - const void *udata, size_t udata_size, hid_t H5_ATTR_UNUSED lcpl_id) +UD_cbsucc_create(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED loc_group, const void *udata, + size_t udata_size, hid_t H5_ATTR_UNUSED lcpl_id) { /* Check to make sure that this "soft link" has a target */ - if(udata_size < 1 || !udata) return FAIL; + if (udata_size < 1 || !udata) + return FAIL; return SUCCEED; } /* end UD_cbsucc_create() */ static hid_t -UD_cbsucc_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, - const void *udata, size_t H5_ATTR_UNUSED udata_size, hid_t lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id) +UD_cbsucc_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const void *udata, + size_t H5_ATTR_UNUSED udata_size, hid_t lapl_id, hid_t H5_ATTR_UNUSED dxpl_id) { const char *target = (const char *)udata; - hid_t ret_value; + hid_t ret_value; - if(!target) goto error; + if (!target) + goto error; - if((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0) goto error; + if ((ret_value = H5Oopen(cur_group, target, lapl_id)) < 0) + goto error; return ret_value; @@ -12044,7 +14758,7 @@ error: /* Failure callback for when the link is moved or renamed */ static herr_t UD_cbfail_move(const char H5_ATTR_UNUSED *new_name, hid_t H5_ATTR_UNUSED new_loc, - const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) + const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) { /* This traversal function will always fail. */ return FAIL; @@ -12053,7 +14767,7 @@ UD_cbfail_move(const char H5_ATTR_UNUSED *new_name, hid_t H5_ATTR_UNUSED new_loc /* SuccessCallback for when the link is moved or renamed */ static herr_t UD_cbsucc_move(const char H5_ATTR_UNUSED *new_name, hid_t H5_ATTR_UNUSED new_loc, - const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) + const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) { /* This traversal function will always succeed. */ return SUCCEED; @@ -12062,7 +14776,7 @@ UD_cbsucc_move(const char H5_ATTR_UNUSED *new_name, hid_t H5_ATTR_UNUSED new_loc /* Callback for when the link is deleted. Also called during move */ static herr_t UD_cbsucc_delete(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED file, - const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) + const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) { /* This callback will always succeed */ return SUCCEED; @@ -12071,7 +14785,7 @@ UD_cbsucc_delete(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED file /* Callback for when the link is deleted. Also called during move */ static herr_t UD_cbfail_delete(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED file, - const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) + const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size) { /* This traversal function will always fail. */ /* Note: un-deletable links are in general a very bad idea! */ @@ -12081,7 +14795,7 @@ UD_cbfail_delete(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED file /* Callback for when the link is queried */ static ssize_t UD_cbfail_query(const char H5_ATTR_UNUSED *link_name, const void H5_ATTR_UNUSED *udata, - size_t H5_ATTR_UNUSED udata_size, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNUSED buf_size) + size_t H5_ATTR_UNUSED udata_size, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNUSED buf_size) { /* This traversal function will always fail. */ return FAIL; @@ -12090,14 +14804,15 @@ UD_cbfail_query(const char H5_ATTR_UNUSED *link_name, const void H5_ATTR_UNUSED /* Callback for when the link is queried */ static ssize_t UD_cbfail_on_write_query(const char H5_ATTR_UNUSED *link_name, const void H5_ATTR_UNUSED *udata, - size_t H5_ATTR_UNUSED udata_size, void *buf, size_t H5_ATTR_UNUSED buf_size) + size_t H5_ATTR_UNUSED udata_size, void *buf, size_t H5_ATTR_UNUSED buf_size) { /* This traversal function will return a buffer size, * but will fail when a buffer is passed in ("writing to the buffer" * fails */ - if(buf != NULL) return FAIL; + if (buf != NULL) + return FAIL; return SUCCEED; } /* end UD_cbfail_on_write_query() */ @@ -12105,14 +14820,14 @@ UD_cbfail_on_write_query(const char H5_ATTR_UNUSED *link_name, const void H5_ATT /* Callback for when the link is queried */ static ssize_t UD_cbsucc_query(const char H5_ATTR_UNUSED *link_name, const void H5_ATTR_UNUSED *udata, - size_t H5_ATTR_UNUSED udata_size, void *buf, size_t buf_size) + size_t H5_ATTR_UNUSED udata_size, void *buf, size_t buf_size) { /* This traversal function will return a buffer size, * but will fail when a buffer is passed in ("writing to the buffer" * fails */ - if(buf != NULL && buf_size >= 8) + if (buf != NULL && buf_size >= 8) HDstrcpy((char *)buf, "succeed"); return 8; @@ -12120,65 +14835,65 @@ UD_cbsucc_query(const char H5_ATTR_UNUSED *link_name, const void H5_ATTR_UNUSED /* This class is full of failing callbacks */ const H5L_class_t UD_cbfail_class1[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */ - "UD_cbfail_link1", /* Link class name for debugging */ - UD_cbsucc_create, /* Creation callback */ - UD_cbfail_move, /* Move/rename callback */ - UD_cbfail_move, /* Copy callback */ - UD_cbsucc_traverse, /* The actual traversal function */ - UD_cbfail_delete, /* Deletion callback */ - UD_cbfail_query /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */ + "UD_cbfail_link1", /* Link class name for debugging */ + UD_cbsucc_create, /* Creation callback */ + UD_cbfail_move, /* Move/rename callback */ + UD_cbfail_move, /* Copy callback */ + UD_cbsucc_traverse, /* The actual traversal function */ + UD_cbfail_delete, /* Deletion callback */ + UD_cbfail_query /* Query callback */ }}; /* This class is has two failing callbacks, move and query */ const H5L_class_t UD_cbfail_class2[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */ - "UD_cbfail_link2", /* Link class name for debugging */ - UD_cbsucc_create, /* Creation callback */ - UD_cbfail_move, /* Move/rename callback */ - UD_cbsucc_move, /* Copy callback */ - UD_cbsucc_traverse, /* The actual traversal function */ - UD_cbsucc_delete, /* Deletion callback */ - UD_cbfail_on_write_query /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */ + "UD_cbfail_link2", /* Link class name for debugging */ + UD_cbsucc_create, /* Creation callback */ + UD_cbfail_move, /* Move/rename callback */ + UD_cbsucc_move, /* Copy callback */ + UD_cbsucc_traverse, /* The actual traversal function */ + UD_cbsucc_delete, /* Deletion callback */ + UD_cbfail_on_write_query /* Query callback */ }}; /* All of these callbacks will succeed */ const H5L_class_t UD_cbfail_class3[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */ - "UD_cbfail_link3", /* Link class name for debugging */ - UD_cbsucc_create, /* Creation callback */ - UD_cbsucc_move, /* Move/rename callback */ - UD_cbsucc_move, /* Copy callback */ - UD_cbsucc_traverse, /* The actual traversal function */ - UD_cbsucc_delete, /* Deletion callback */ - UD_cbsucc_query /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_CBFAIL_TYPE, /* Link type id number */ + "UD_cbfail_link3", /* Link class name for debugging */ + UD_cbsucc_create, /* Creation callback */ + UD_cbsucc_move, /* Move/rename callback */ + UD_cbsucc_move, /* Copy callback */ + UD_cbsucc_traverse, /* The actual traversal function */ + UD_cbsucc_delete, /* Deletion callback */ + UD_cbsucc_query /* Query callback */ }}; /* Link classes that are invalid for various reasons */ const H5L_class_t UD_error1_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ (H5L_type_t)UD_ERROR_TYPE, /* Link type id number */ - "UD_error_link", /* Link class name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - NULL, /* This class has no traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + "UD_error_link", /* Link class name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + NULL, /* This class has no traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; const H5L_class_t UD_error2_class[1] = {{ - UD_BAD_VERS, /* Invalid H5L_class_t version */ + UD_BAD_VERS, /* Invalid H5L_class_t version */ (H5L_type_t)UD_ERROR_TYPE, /* Link type id number */ - "UD_error_link", /* Link class name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_cbsucc_traverse, /* Traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + "UD_error_link", /* Link class name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_cbsucc_traverse, /* Traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; const H5L_class_t UD_error3_class[1] = {{ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ @@ -12206,127 +14921,180 @@ const H5L_class_t UD_error4_class[1] = {{ static int ud_link_errors(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ char group_name[NAME_BUF_SIZE]; char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; - H5L_info2_t li; /* Link information */ + H5L_info2_t li; /* Link information */ - if(new_format) + if (new_format) TESTING("user-defined link error conditions (w/new group format)") else TESTING("user-defined link error conditions") /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Try to register some invalid link classes */ - H5E_BEGIN_TRY { - if(H5Lregister(UD_error1_class) >= 0) TEST_ERROR - if(H5Lregister(UD_error2_class) >= 0) TEST_ERROR - if(H5Lregister(UD_error3_class) >= 0) TEST_ERROR - if(H5Lregister(UD_error4_class) >= 0) TEST_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lregister(UD_error1_class) >= 0) + TEST_ERROR + if (H5Lregister(UD_error2_class) >= 0) + TEST_ERROR + if (H5Lregister(UD_error3_class) >= 0) + TEST_ERROR + if (H5Lregister(UD_error4_class) >= 0) + TEST_ERROR + } + H5E_END_TRY /* Register the UD plist class. */ - if(H5Lregister(UD_plist_class) < 0) TEST_ERROR + if (H5Lregister(UD_plist_class) < 0) + TEST_ERROR /* Now register the first class we'll be using. * It has the same ID as the plist class, and should replace it. */ - if(H5Lregister(UD_cbfail_class1) < 0) FAIL_STACK_ERROR + if (H5Lregister(UD_cbfail_class1) < 0) + FAIL_STACK_ERROR /* Create a group for the UD link to point to */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Try to create internally defined links with H5Lcreate_ud */ - H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_HARD, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR - if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_SOFT, "str", (size_t)4, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_HARD, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR + if (H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_SOFT, "str", (size_t)4, H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR + } + H5E_END_TRY - /* Try to create a link with H5Lcreate_ud that has a NULL udata pointer, but a non-zero udata_size value */ - H5E_BEGIN_TRY { - if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, NULL, 1, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR - } H5E_END_TRY; + /* Try to create a link with H5Lcreate_ud that has a NULL udata pointer, but a non-zero udata_size value + */ + H5E_BEGIN_TRY + { + if (H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, NULL, 1, H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR + } + H5E_END_TRY; /* Create a user-defined link to the group. */ strcpy(group_name, "/group"); - if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, + H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the group through the ud link */ - if((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Now test that each of the callbacks will cause a failure if it returns -1 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { /* The create callback will fail if we pass in no udata */ - if(H5Lcreate_ud(fid, "fail", (H5L_type_t)UD_CBFAIL_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR + if (H5Lcreate_ud(fid, "fail", (H5L_type_t)UD_CBFAIL_TYPE, NULL, (size_t)0, H5P_DEFAULT, + H5P_DEFAULT) >= 0) + TEST_ERROR /* The move and copy callbacks will fail */ - if(H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR - if(H5Lcopy(fid, "ud_link", fid, "copy_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR + if (H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR + if (H5Lcopy(fid, "ud_link", fid, "copy_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR /* The traversal callback will fail if we remove its target */ - if(H5Ldelete(fid, "group", H5P_DEFAULT) < 0) TEST_ERROR - if((gid = H5Gopen2(gid, "ud_link", H5P_DEFAULT)) >= 0) TEST_ERROR + if (H5Ldelete(fid, "group", H5P_DEFAULT) < 0) + TEST_ERROR + if ((gid = H5Gopen2(gid, "ud_link", H5P_DEFAULT)) >= 0) + TEST_ERROR /* The deletion callback will always fail */ - if(H5Ldelete(fid, "ud_link", H5P_DEFAULT) >= 0) TEST_ERROR + if (H5Ldelete(fid, "ud_link", H5P_DEFAULT) >= 0) + TEST_ERROR /* The query callback will fail */ - if(H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) >=0) TEST_ERROR - } H5E_END_TRY + if (H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) >= 0) + TEST_ERROR + } + H5E_END_TRY /* Now use a class with different callback functions */ - if(H5Lregister(UD_cbfail_class2) < 0) FAIL_STACK_ERROR + if (H5Lregister(UD_cbfail_class2) < 0) + FAIL_STACK_ERROR /* Moving should still fail, but copying will succeed */ - H5E_BEGIN_TRY { - if(H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR - } H5E_END_TRY - if(H5Lcopy(fid, "ud_link", fid, "copy_succ", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + if (H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR + } + H5E_END_TRY + if (H5Lcopy(fid, "ud_link", fid, "copy_succ", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* The query callback will succeed when we only want to get the size of the buffer... */ - if(H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(li.u.val_size != 0) TEST_ERROR + if (H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (li.u.val_size != 0) + TEST_ERROR /* ...but fail when we try to write data to the buffer itself*/ - H5E_BEGIN_TRY { - if(H5Lget_val(fid, "ud_link", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) >=0) TEST_ERROR - } H5E_END_TRY + H5E_BEGIN_TRY + { + if (H5Lget_val(fid, "ud_link", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) >= 0) + TEST_ERROR + } + H5E_END_TRY /* Register a new class */ - if(H5Lregister(UD_cbfail_class3) < 0) FAIL_STACK_ERROR + if (H5Lregister(UD_cbfail_class3) < 0) + FAIL_STACK_ERROR /* Now querying should succeed */ - if(H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(li.u.val_size != 8) TEST_ERROR - if(H5Lget_val(fid, "ud_link", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(HDstrcmp(query_buf, "succeed") != 0) TEST_ERROR + if (H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (li.u.val_size != 8) + TEST_ERROR + if (H5Lget_val(fid, "ud_link", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(query_buf, "succeed") != 0) + TEST_ERROR /* Moving and copying should both succeed */ - if(H5Lmove(fid, "copy_succ", H5L_SAME_LOC, "move_succ", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcopy(fid, "ud_link", fid, "copy_succ2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(fid, "copy_succ", H5L_SAME_LOC, "move_succ", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcopy(fid, "ud_link", fid, "copy_succ2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Delete link (this callback should work now) */ - if(H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "ud_link", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end ud_link_errors() */ - /*------------------------------------------------------------------------- * Function: lapl_nlinks * @@ -12340,17 +15108,17 @@ error: static int lapl_nlinks(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t plist = -1; /* lapl ID */ - hid_t tid = -1, sid = -1, did = -1; /* Other IDs */ - hid_t gapl = -1, dapl = -1, tapl = -1; /* Other property lists */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; - size_t nlinks; /* nlinks for H5Pset_nlinks */ - hsize_t dims[2]; - - if(new_format) + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t plist = -1; /* lapl ID */ + hid_t tid = -1, sid = -1, did = -1; /* Other IDs */ + hid_t gapl = -1, dapl = -1, tapl = -1; /* Other property lists */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; + size_t nlinks; /* nlinks for H5Pset_nlinks */ + hsize_t dims[2]; + + if (new_format) TESTING("adjusting nlinks with LAPL (w/new group format)") else TESTING("adjusting nlinks with LAPL") @@ -12363,76 +15131,113 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) /* Create file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group with short name in file (used as target for links) */ - if((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "final", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create chain of soft links to existing object (limited) */ - if(H5Lcreate_soft("final", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft1", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft2", fid, "soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft3", fid, "soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft4", fid, "soft5", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft5", fid, "soft6", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft6", fid, "soft7", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft7", fid, "soft8", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft8", fid, "soft9", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft9", fid, "soft10", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft10", fid, "soft11", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft11", fid, "soft12", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft12", fid, "soft13", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft13", fid, "soft14", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft14", fid, "soft15", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft15", fid, "soft16", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("soft16", fid, "soft17", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("final", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft1", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft2", fid, "soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft3", fid, "soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft4", fid, "soft5", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft5", fid, "soft6", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft6", fid, "soft7", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft7", fid, "soft8", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft8", fid, "soft9", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft9", fid, "soft10", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft10", fid, "soft11", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft11", fid, "soft12", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft12", fid, "soft13", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft13", fid, "soft14", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft14", fid, "soft15", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft15", fid, "soft16", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("soft16", fid, "soft17", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Open file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Create LAPL with higher-than-usual nlinks value */ /* Create a non-default lapl with udata set to point to the first group */ - if((plist = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR + if ((plist = H5Pcreate(H5P_LINK_ACCESS)) < 0) + TEST_ERROR nlinks = 20; - if(H5Pset_nlinks(plist, nlinks) < 0) TEST_ERROR + if (H5Pset_nlinks(plist, nlinks) < 0) + TEST_ERROR /* Ensure that nlinks was set successfully */ nlinks = 0; - if(H5Pget_nlinks(plist, &nlinks) < 0) TEST_ERROR - if(nlinks != 20) TEST_ERROR + if (H5Pget_nlinks(plist, &nlinks) < 0) + TEST_ERROR + if (nlinks != 20) + TEST_ERROR /* Open object through what is normally too many soft links using * new property list */ - if((gid = H5Oopen(fid, "soft17", plist)) < 0) TEST_ERROR + if ((gid = H5Oopen(fid, "soft17", plist)) < 0) + TEST_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/soft17")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/soft17")) + TEST_ERROR /* Create group using soft link */ - if((gid2 = H5Gcreate2(gid, "new_soft", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "new_soft", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close groups */ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Set nlinks to a smaller number */ nlinks = 4; - if(H5Pset_nlinks(plist, nlinks) < 0) TEST_ERROR + if (H5Pset_nlinks(plist, nlinks) < 0) + TEST_ERROR /* Ensure that nlinks was set successfully */ nlinks = 0; - if(H5Pget_nlinks(plist, &nlinks) < 0) TEST_ERROR - if(nlinks != 4) TEST_ERROR + if (H5Pget_nlinks(plist, &nlinks) < 0) + TEST_ERROR + if (nlinks != 4) + TEST_ERROR /* Try opening through what is now too many soft links */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Oopen(fid, "soft5", plist); - } H5E_END_TRY; + } + H5E_END_TRY; if (gid >= 0) { H5_FAILED(); HDputs(" Should have failed for sequence of too many nested links."); @@ -12440,106 +15245,149 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) } /* Open object through lesser soft link */ - if((gid = H5Oopen(fid, "soft4", plist)) < 0) TEST_ERROR + if ((gid = H5Oopen(fid, "soft4", plist)) < 0) + TEST_ERROR /* Check name */ - if(H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/soft4")) TEST_ERROR + if (H5Iget_name(gid, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/soft4")) + TEST_ERROR /* Test other functions that should use a LAPL */ nlinks = 20; - if(H5Pset_nlinks(plist, nlinks) < 0) TEST_ERROR + if (H5Pset_nlinks(plist, nlinks) < 0) + TEST_ERROR /* Try copying and moving when both src and dst contain many soft links * using a non-default LAPL */ - if(H5Lcopy(fid, "soft17", fid, "soft17/newer_soft", H5P_DEFAULT, plist) < 0) TEST_ERROR - if(H5Lmove(fid, "soft17/newer_soft", fid, "soft17/newest_soft", H5P_DEFAULT, plist) < 0) TEST_ERROR + if (H5Lcopy(fid, "soft17", fid, "soft17/newer_soft", H5P_DEFAULT, plist) < 0) + TEST_ERROR + if (H5Lmove(fid, "soft17/newer_soft", fid, "soft17/newest_soft", H5P_DEFAULT, plist) < 0) + TEST_ERROR /* H5Olink */ - if(H5Olink(gid, fid, "soft17/link_to_group", H5P_DEFAULT, plist) < 0) TEST_ERROR + if (H5Olink(gid, fid, "soft17/link_to_group", H5P_DEFAULT, plist) < 0) + TEST_ERROR /* H5Lcreate_hard and H5Lcreate_soft */ - if(H5Lcreate_hard(fid, "soft17", fid, "soft17/link2_to_group", H5P_DEFAULT, plist) < 0) TEST_ERROR - if(H5Lcreate_soft("/soft4", fid, "soft17/soft_link", H5P_DEFAULT, plist) < 0) TEST_ERROR + if (H5Lcreate_hard(fid, "soft17", fid, "soft17/link2_to_group", H5P_DEFAULT, plist) < 0) + TEST_ERROR + if (H5Lcreate_soft("/soft4", fid, "soft17/soft_link", H5P_DEFAULT, plist) < 0) + TEST_ERROR /* H5Ldelete */ - if(H5Ldelete(fid, "soft17/soft_link", plist) < 0) TEST_ERROR + if (H5Ldelete(fid, "soft17/soft_link", plist) < 0) + TEST_ERROR /* H5Lget_val and H5Lget_info2 */ - if(H5Lget_val(fid, "soft17", NULL, (size_t)0, plist) < 0) TEST_ERROR - if(H5Lget_info2(fid, "soft17", NULL, plist) < 0) TEST_ERROR + if (H5Lget_val(fid, "soft17", NULL, (size_t)0, plist) < 0) + TEST_ERROR + if (H5Lget_info2(fid, "soft17", NULL, plist) < 0) + TEST_ERROR /* H5Lcreate_external and H5Lcreate_ud */ - if(H5Lcreate_external("filename", "path", fid, "soft17/extlink", H5P_DEFAULT, plist) < 0) TEST_ERROR - if(H5Lregister(UD_rereg_class) < 0) TEST_ERROR - if(H5Lcreate_ud(fid, "soft17/udlink", (H5L_type_t)UD_HARD_TYPE, NULL, (size_t)0, H5P_DEFAULT, plist) < 0) TEST_ERROR + if (H5Lcreate_external("filename", "path", fid, "soft17/extlink", H5P_DEFAULT, plist) < 0) + TEST_ERROR + if (H5Lregister(UD_rereg_class) < 0) + TEST_ERROR + if (H5Lcreate_ud(fid, "soft17/udlink", (H5L_type_t)UD_HARD_TYPE, NULL, (size_t)0, H5P_DEFAULT, plist) < 0) + TEST_ERROR /* Close plist */ - if(H5Pclose(plist) < 0) TEST_ERROR + if (H5Pclose(plist) < 0) + TEST_ERROR /* Create a datatype and dataset as targets inside the group */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(gid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(gid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR dims[0] = 2; dims[1] = 2; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + if ((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Try to open the objects using too many symlinks with default *APLs */ - H5E_BEGIN_TRY { - if((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >= 0) + H5E_BEGIN_TRY + { + if ((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >= 0) FAIL_PUTS_ERROR(" Should have failed for too many nested links.") - if((tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT)) >= 0) + if ((tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT)) >= 0) FAIL_PUTS_ERROR(" Should have failed for too many nested links.") - if((did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT)) >= 0) + if ((did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT)) >= 0) FAIL_PUTS_ERROR(" Should have failed for too many nested links.") - } H5E_END_TRY + } + H5E_END_TRY /* Create property lists with nlinks set */ - if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR - if((tapl = H5Pcreate(H5P_DATATYPE_ACCESS)) < 0) TEST_ERROR - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR + if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) + TEST_ERROR + if ((tapl = H5Pcreate(H5P_DATATYPE_ACCESS)) < 0) + TEST_ERROR + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + TEST_ERROR nlinks = 20; - if(H5Pset_nlinks(gapl, nlinks) < 0) TEST_ERROR - if(H5Pset_nlinks(tapl, nlinks) < 0) TEST_ERROR - if(H5Pset_nlinks(dapl, nlinks) < 0) TEST_ERROR + if (H5Pset_nlinks(gapl, nlinks) < 0) + TEST_ERROR + if (H5Pset_nlinks(tapl, nlinks) < 0) + TEST_ERROR + if (H5Pset_nlinks(dapl, nlinks) < 0) + TEST_ERROR /* We should now be able to use these property lists to open each kind * of object. */ - if((gid = H5Gopen2(fid, "soft17", gapl)) < 0) FAIL_STACK_ERROR - if((tid = H5Topen2(fid, "soft17/datatype", tapl)) < 0) TEST_ERROR - if((did = H5Dopen2(fid, "soft17/dataset", dapl)) < 0) TEST_ERROR + if ((gid = H5Gopen2(fid, "soft17", gapl)) < 0) + FAIL_STACK_ERROR + if ((tid = H5Topen2(fid, "soft17/datatype", tapl)) < 0) + TEST_ERROR + if ((did = H5Dopen2(fid, "soft17/dataset", dapl)) < 0) + TEST_ERROR /* Close objects */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close plists */ - if(H5Pclose(gapl) < 0) TEST_ERROR - if(H5Pclose(tapl) < 0) TEST_ERROR - if(H5Pclose(dapl) < 0) TEST_ERROR + if (H5Pclose(gapl) < 0) + TEST_ERROR + if (H5Pclose(tapl) < 0) + TEST_ERROR + if (H5Pclose(dapl) < 0) + TEST_ERROR /* Unregister UD hard link class */ - if(H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) TEST_ERROR + if (H5Lunregister((H5L_type_t)UD_HARD_TYPE) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gapl); H5Pclose(dapl); H5Pclose(tapl); @@ -12550,11 +15398,11 @@ error: H5Gclose(gid); H5Pclose(plist); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end lapl_nlinks() */ - /*------------------------------------------------------------------------- * Function: linkinfo * @@ -12567,14 +15415,14 @@ error: static int linkinfo(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t tid = -1; /* Type ID */ - hid_t sid = -1, did = -1; /* Dataspace and dataset IDs */ - H5L_info2_t li; /* Link information */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t tid = -1; /* Type ID */ + hid_t sid = -1, did = -1; /* Dataspace and dataset IDs */ + H5L_info2_t li; /* Link information */ char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) TESTING("link type field in H5Lget_info (w/new group format)") else TESTING("link type field in H5Lget_info") @@ -12582,62 +15430,91 @@ linkinfo(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Register a couple of user-defined link classes with the library */ - if(H5Lregister(UD_plist_class) < 0) TEST_ERROR + if (H5Lregister(UD_plist_class) < 0) + TEST_ERROR /* Create an object of each type */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(fid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("group", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(fid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("group", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR - if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR + if ((sid = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR + if ((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR - if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external("file_name", "obj_path", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < + 0) + TEST_ERROR + if (H5Lcreate_external("file_name", "obj_path", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close all objects */ - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Make sure that link type is correct when objects are queried */ - if(H5Lget_info2(fid, "datatype", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_HARD) TEST_ERROR - if(H5Lget_info2(fid, "group", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_HARD) TEST_ERROR - if(H5Lget_info2(fid, "dataset", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_HARD) TEST_ERROR - - if(H5Lget_info2(fid, "ext_link", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_EXTERNAL) TEST_ERROR - if(H5Lget_info2(fid, "softlink", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != H5L_TYPE_SOFT) TEST_ERROR - if(H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.type != UD_PLIST_TYPE) TEST_ERROR + if (H5Lget_info2(fid, "datatype", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_HARD) + TEST_ERROR + if (H5Lget_info2(fid, "group", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_HARD) + TEST_ERROR + if (H5Lget_info2(fid, "dataset", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_HARD) + TEST_ERROR + + if (H5Lget_info2(fid, "ext_link", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_EXTERNAL) + TEST_ERROR + if (H5Lget_info2(fid, "softlink", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != H5L_TYPE_SOFT) + TEST_ERROR + if (H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) < 0) + TEST_ERROR + if (li.type != UD_PLIST_TYPE) + TEST_ERROR /* Ensure that passing a NULL pointer doesn't cause an error */ - if(H5Lget_info2(fid, "group", NULL, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info2(fid, "group", NULL, H5P_DEFAULT) < 0) + TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - H5Tclose (tid); - H5Dclose (did); - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Tclose(tid); + H5Dclose(did); + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return FAIL; } /* end linkinfo() */ - /*------------------------------------------------------------------------- * Function: check_all_closed * @@ -12655,11 +15532,11 @@ error: static int check_all_closed(hid_t fapl, hbool_t new_format, int stopat) { - hid_t fid=-1; - char filename[NAME_BUF_SIZE]; - int x; + hid_t fid = -1; + char filename[NAME_BUF_SIZE]; + int x; - if(new_format) + if (new_format) TESTING("that all files were closed correctly (w/new group format)") else TESTING("that all files were closed correctly") @@ -12669,20 +15546,24 @@ check_all_closed(hid_t fapl, hbool_t new_format, int stopat) * To check this, try to create every file used in this test. If * a file is already open, creating it will fail. */ - for(x=0; FILENAME[x] != NULL && x < stopat; x++) { + for (x = 0; FILENAME[x] != NULL && x < stopat; x++) { h5_fixname(FILENAME[x], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR } PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end check_all_closed() */ @@ -12698,88 +15579,123 @@ error: static hid_t build_visit_file(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t tid = -1; /* Datatype ID */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t tid = -1; /* Datatype ID */ + char filename[NAME_BUF_SIZE]; const char *pathname = H5_get_srcdir_filename(LINKED_FILE); /* Corrected test file name */ h5_fixname(FILENAME[9], fapl, filename, sizeof filename); /* Create file for visiting */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group */ - if((gid = H5Gcreate2(fid, "/Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "/Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create nested group */ - if((gid2 = H5Gcreate2(gid, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, "Group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close groups */ - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create soft links to groups created */ - if(H5Lcreate_soft("/Group1", fid, "/soft_one", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/Group1/Group2", fid, "/soft_two", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft("/Group1", fid, "/soft_one", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("/Group1/Group2", fid, "/soft_two", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create dangling soft link */ - if(H5Lcreate_soft("nowhere", fid, "/soft_dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft("nowhere", fid, "/soft_dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create hard links to all groups */ - if(H5Lcreate_hard(fid, "/", fid, "hard_zero", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "/Group1", fid, "hard_one", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "/Group1/Group2", fid, "hard_two", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(fid, "/", fid, "hard_zero", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "/Group1", fid, "hard_one", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "/Group1/Group2", fid, "hard_two", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create loops w/hard links */ - if(H5Lcreate_hard(fid, "/Group1", fid, "/Group1/hard_one", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_hard(fid, "/", fid, "/Group1/Group2/hard_zero", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_hard(fid, "/Group1", fid, "/Group1/hard_one", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_hard(fid, "/", fid, "/Group1/Group2/hard_zero", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create external link to existing file */ - if(H5Lcreate_external(pathname, "/group", fid, "/ext_one", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(pathname, "/group", fid, "/ext_one", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create dangling external link to non-existent file */ - if(H5Lcreate_external("foo.h5", "/group", fid, "/ext_dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external("foo.h5", "/group", fid, "/ext_dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Create dataset in each group */ - if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR + if ((sid = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR - if((did = H5Dcreate2(fid, "/Dataset_zero", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid, "/Dataset_zero", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR - if((did = H5Dcreate2(fid, "/Group1/Dataset_one", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid, "/Group1/Dataset_one", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR - if((did = H5Dcreate2(fid, "/Group1/Group2/Dataset_two", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid, "/Group1/Group2/Dataset_two", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR /* Create named datatype in each group */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(fid, "/Type_zero", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(fid, "/Type_zero", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(fid, "/Group1/Type_one", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(fid, "/Group1/Type_one", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit2(fid, "/Group1/Group2/Type_two", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if (H5Tcommit2(fid, "/Group1/Group2/Type_two", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR - return(fid); + return (fid); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end build_visit_file() */ - /*------------------------------------------------------------------------- * Function: visit_link_cb * @@ -12795,16 +15711,17 @@ visit_link_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5L_info2_t lvisit_ud_t *op_data = (lvisit_ud_t *)_op_data; /* Check for correct link information */ - if(HDstrcmp(op_data->info[op_data->idx].path, name)) return(H5_ITER_ERROR); - if(op_data->info[op_data->idx].type != linfo->type) return(H5_ITER_ERROR); + if (HDstrcmp(op_data->info[op_data->idx].path, name)) + return (H5_ITER_ERROR); + if (op_data->info[op_data->idx].type != linfo->type) + return (H5_ITER_ERROR); /* Advance to next location in expected output */ op_data->idx++; - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /* end visit_link_cb() */ - /*------------------------------------------------------------------------- * Function: link_visit * @@ -12817,58 +15734,71 @@ visit_link_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5L_info2_t static int link_visit(hid_t fapl, hbool_t new_format) { - lvisit_ud_t udata; /* User-data for visiting */ - hid_t fid = -1; - hid_t gid = -1; /* Group ID */ + lvisit_ud_t udata; /* User-data for visiting */ + hid_t fid = -1; + hid_t gid = -1; /* Group ID */ - if(new_format) + if (new_format) TESTING("link visiting (w/new group format)") else TESTING("link visiting") /* Construct "interesting" file to visit */ - if((fid = build_visit_file(fapl)) < 0) TEST_ERROR + if ((fid = build_visit_file(fapl)) < 0) + TEST_ERROR /* Visit all the links reachable from the root group (with file ID) */ - udata.idx = 0; + udata.idx = 0; udata.info = lvisit0; - if(H5Lvisit2(fid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) FAIL_STACK_ERROR + if (H5Lvisit2(fid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) + FAIL_STACK_ERROR /* Visit all the links reachable from the root group (with group ID) */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = lvisit0; - if(H5Lvisit2(gid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Lvisit2(gid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Visit all the links reachable from each internal group */ - if((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = lvisit1; - if(H5Lvisit2(gid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Lvisit2(gid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, "/Group1/Group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/Group1/Group2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = lvisit2; - if(H5Lvisit2(gid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Lvisit2(gid, H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file created */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end link_visit() */ - /*------------------------------------------------------------------------- * Function: link_visit_by_name * @@ -12881,66 +15811,82 @@ error: static int link_visit_by_name(hid_t fapl, hbool_t new_format) { - lvisit_ud_t udata; /* User-data for visiting */ - hid_t fid = -1; - hid_t gid = -1; /* Group ID */ + lvisit_ud_t udata; /* User-data for visiting */ + hid_t fid = -1; + hid_t gid = -1; /* Group ID */ - if(new_format) + if (new_format) TESTING("link visiting by name (w/new group format)") else TESTING("link visiting by name") /* Construct "interesting" file to visit */ - if((fid = build_visit_file(fapl)) < 0) TEST_ERROR + if ((fid = build_visit_file(fapl)) < 0) + TEST_ERROR /* Visit all the links reachable from the root group (with file ID) */ - udata.idx = 0; + udata.idx = 0; udata.info = lvisit0; - if(H5Lvisit_by_name2(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lvisit_by_name2(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Visit all the links reachable from the root group (with group ID) */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = lvisit0; - if(H5Lvisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Lvisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Visit all the links reachable from each internal group */ - udata.idx = 0; + udata.idx = 0; udata.info = lvisit1; - if(H5Lvisit_by_name2(fid, "/Group1", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lvisit_by_name2(fid, "/Group1", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = lvisit1; - if(H5Lvisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Lvisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR - udata.idx = 0; + udata.idx = 0; udata.info = lvisit2; - if(H5Lvisit_by_name2(fid, "/Group1/Group2", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lvisit_by_name2(fid, "/Group1/Group2", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, "/Group1/Group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/Group1/Group2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = lvisit2; - if(H5Lvisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Lvisit_by_name2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_link_cb, &udata, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file created */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end link_visit_by_name() */ - /*------------------------------------------------------------------------- * Function: visit_obj_cb * @@ -12956,16 +15902,17 @@ visit_obj_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5O_info2_t ovisit_ud_t *op_data = (ovisit_ud_t *)_op_data; /* Check for correct object information */ - if(HDstrcmp(op_data->info[op_data->idx].path, name)) return(H5_ITER_ERROR); - if(op_data->info[op_data->idx].type != oinfo->type) return(H5_ITER_ERROR); + if (HDstrcmp(op_data->info[op_data->idx].path, name)) + return (H5_ITER_ERROR); + if (op_data->info[op_data->idx].type != oinfo->type) + return (H5_ITER_ERROR); /* Advance to next location in expected output */ op_data->idx++; - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /* end visit_obj_cb() */ - /*------------------------------------------------------------------------- * Function: obj_visit * @@ -12978,58 +15925,71 @@ visit_obj_cb(hid_t H5_ATTR_UNUSED group_id, const char *name, const H5O_info2_t static int obj_visit(hid_t fapl, hbool_t new_format) { - ovisit_ud_t udata; /* User-data for visiting */ - hid_t fid = -1; - hid_t gid = -1; /* Group ID */ + ovisit_ud_t udata; /* User-data for visiting */ + hid_t fid = -1; + hid_t gid = -1; /* Group ID */ - if(new_format) + if (new_format) TESTING("object visiting (w/new group format)") else TESTING("object visiting") /* Construct "interesting" file to visit */ - if((fid = build_visit_file(fapl)) < 0) TEST_ERROR + if ((fid = build_visit_file(fapl)) < 0) + TEST_ERROR /* Visit all the objects reachable from the root group (with file ID) */ - udata.idx = 0; + udata.idx = 0; udata.info = new_format ? ovisit0_new : ovisit0_old; - if(H5Ovisit3(fid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR + if (H5Ovisit3(fid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) + FAIL_STACK_ERROR /* Visit all the objects reachable from the root group (with group ID) */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = new_format ? ovisit0_new : ovisit0_old; - if(H5Ovisit3(gid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Ovisit3(gid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Visit all the objects reachable from each internal group */ - if((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = new_format ? ovisit1_new : ovisit1_old; - if(H5Ovisit3(gid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Ovisit3(gid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, "/Group1/Group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/Group1/Group2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = new_format ? ovisit2_new : ovisit2_old; - if(H5Ovisit3(gid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Ovisit3(gid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file created */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end obj_visit() */ - /*------------------------------------------------------------------------- * Function: obj_visit_by_name * @@ -13042,66 +16002,87 @@ error: static int obj_visit_by_name(hid_t fapl, hbool_t new_format) { - ovisit_ud_t udata; /* User-data for visiting */ - hid_t fid = -1; - hid_t gid = -1; /* Group ID */ + ovisit_ud_t udata; /* User-data for visiting */ + hid_t fid = -1; + hid_t gid = -1; /* Group ID */ - if(new_format) + if (new_format) TESTING("object visiting by name (w/new group format)") else TESTING("object visiting by name") /* Construct "interesting" file to visit */ - if((fid = build_visit_file(fapl)) < 0) TEST_ERROR + if ((fid = build_visit_file(fapl)) < 0) + TEST_ERROR /* Visit all the objects reachable from the root group (with file ID) */ - udata.idx = 0; + udata.idx = 0; udata.info = new_format ? ovisit0_new : ovisit0_old; - if(H5Ovisit_by_name3(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ovisit_by_name3(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Visit all the objects reachable from the root group (with group ID) */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = new_format ? ovisit0_new : ovisit0_old; - if(H5Ovisit_by_name3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Ovisit_by_name3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Visit all the objects reachable from each internal group */ - udata.idx = 0; + udata.idx = 0; udata.info = new_format ? ovisit1_new : ovisit1_old; - if(H5Ovisit_by_name3(fid, "/Group1", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ovisit_by_name3(fid, "/Group1", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/Group1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = new_format ? ovisit1_new : ovisit1_old; - if(H5Ovisit_by_name3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Ovisit_by_name3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR - udata.idx = 0; + udata.idx = 0; udata.info = new_format ? ovisit2_new : ovisit2_old; - if(H5Ovisit_by_name3(fid, "/Group1/Group2", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ovisit_by_name3(fid, "/Group1/Group2", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, + H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR - if((gid = H5Gopen2(fid, "/Group1/Group2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - udata.idx = 0; + if ((gid = H5Gopen2(fid, "/Group1/Group2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + udata.idx = 0; udata.info = new_format ? ovisit2_new : ovisit2_old; - if(H5Ovisit_by_name3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Ovisit_by_name3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file created */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end obj_visit_by_name() */ - /*------------------------------------------------------------------------- * Function: visit_obj_stop_cb * @@ -13111,17 +16092,17 @@ error: *------------------------------------------------------------------------- */ static int -visit_obj_stop_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *name, const H5O_info2_t H5_ATTR_UNUSED *oinfo, void *_op_data) +visit_obj_stop_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *name, + const H5O_info2_t H5_ATTR_UNUSED *oinfo, void *_op_data) { unsigned *op_data = (unsigned *)_op_data; /* Increment the number of visited objects */ (*op_data)++; - return(H5_ITER_STOP); + return (H5_ITER_STOP); } /* end visit_obj_stop_cb() */ - /*------------------------------------------------------------------------- * Function: obj_visit_stop * @@ -13135,48 +16116,56 @@ visit_obj_stop_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *name static int obj_visit_stop(hid_t fapl, hbool_t new_format) { - unsigned nvisited; /* User-data for visiting */ - hid_t fid = -1; - herr_t ret; /* Return value */ + unsigned nvisited; /* User-data for visiting */ + hid_t fid = -1; + herr_t ret; /* Return value */ - if(new_format) + if (new_format) TESTING("stopping object iteration (w/new group format)") else TESTING("stopping object iteration") /* Construct "interesting" file to visit */ - if((fid = build_visit_file(fapl)) < 0) TEST_ERROR + if ((fid = build_visit_file(fapl)) < 0) + TEST_ERROR /* Start iteration. The callback should only be called once because it * returns H5_ITER_STOP */ nvisited = 0; - if((ret = H5Ovisit3(fid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb, &nvisited, H5O_INFO_BASIC)) < 0) + if ((ret = H5Ovisit3(fid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb, &nvisited, H5O_INFO_BASIC)) < 0) FAIL_STACK_ERROR - if(ret != H5_ITER_STOP) TEST_ERROR - if(nvisited != 1) TEST_ERROR + if (ret != H5_ITER_STOP) + TEST_ERROR + if (nvisited != 1) + TEST_ERROR /* Same test with H5Ovisit_by_name */ nvisited = 0; - if((ret = H5Ovisit_by_name3(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb, - &nvisited, H5O_INFO_BASIC, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(ret != H5_ITER_STOP) TEST_ERROR - if(nvisited != 1) TEST_ERROR + if ((ret = H5Ovisit_by_name3(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_obj_stop_cb, &nvisited, + H5O_INFO_BASIC, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (ret != H5_ITER_STOP) + TEST_ERROR + if (nvisited != 1) + TEST_ERROR /* Close file created */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end obj_visit_stop() */ - /*------------------------------------------------------------------------- * Function: link_filters * @@ -13195,46 +16184,58 @@ static enum { LFS_DECODED } link_filter_state; -static htri_t link_filter_can_apply(hid_t dcpl_id, hid_t type_id, hid_t space_id) +static htri_t +link_filter_can_apply(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - if(dcpl_id >= 0 || type_id >= 0 || space_id >= 0) return -1; + if (dcpl_id >= 0 || type_id >= 0 || space_id >= 0) + return -1; - if(link_filter_state >= LFS_ENCODED) return 1; + if (link_filter_state >= LFS_ENCODED) + return 1; - if(link_filter_state != LFS_INIT) return -1; + if (link_filter_state != LFS_INIT) + return -1; link_filter_state = LFS_CAN_APPLY_CALLED; return 1; } /* end link_fitler_can_apply */ -static herr_t link_filter_set_local(hid_t dcpl_id, hid_t type_id, hid_t space_id) +static herr_t +link_filter_set_local(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - if(dcpl_id >= 0 || type_id >= 0 || space_id >= 0) return -1; + if (dcpl_id >= 0 || type_id >= 0 || space_id >= 0) + return -1; - if(link_filter_state >= LFS_ENCODED) return 0; + if (link_filter_state >= LFS_ENCODED) + return 0; - if(link_filter_state != LFS_CAN_APPLY_CALLED) return -1; + if (link_filter_state != LFS_CAN_APPLY_CALLED) + return -1; link_filter_state = LFS_SET_LOCAL_CALLED; return 0; } /* end link_filter_set_local */ -static size_t link_filter_filter(unsigned int flags, size_t cd_nelmts, - const unsigned int cd_values[], size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, - void H5_ATTR_UNUSED **buf) +static size_t +link_filter_filter(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], size_t nbytes, + size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) { - if(flags & H5Z_FLAG_OPTIONAL || cd_nelmts != 1 || cd_values[0] != 2112) return 0; + if (flags & H5Z_FLAG_OPTIONAL || cd_nelmts != 1 || cd_values[0] != 2112) + return 0; - if(link_filter_state == LFS_DECODED) return nbytes; + if (link_filter_state == LFS_DECODED) + return nbytes; - if(flags & H5Z_FLAG_REVERSE) { - if(link_filter_state != LFS_ENCODED) return 0; + if (flags & H5Z_FLAG_REVERSE) { + if (link_filter_state != LFS_ENCODED) + return 0; link_filter_state = LFS_DECODED; } else { - if(link_filter_state < LFS_SET_LOCAL_CALLED) return 0; + if (link_filter_state < LFS_SET_LOCAL_CALLED) + return 0; link_filter_state = LFS_ENCODED; } /* end else */ @@ -13244,25 +16245,25 @@ static size_t link_filter_filter(unsigned int flags, size_t cd_nelmts, static int link_filters(hid_t fapl, hbool_t new_format) { - hid_t fid = -1, fcpl = -1; - hid_t gid1 = -1, gid2 = -1, gcpl1 = -1, gcpl2 = -1; - hid_t lcpl = -1; - size_t cd_nelmts = 1; - unsigned cd_value = 2112; - unsigned cd_value_out; - unsigned flags_out; - unsigned filter_config_out; - int nfilters = 0; + hid_t fid = -1, fcpl = -1; + hid_t gid1 = -1, gid2 = -1, gcpl1 = -1, gcpl2 = -1; + hid_t lcpl = -1; + size_t cd_nelmts = 1; + unsigned cd_value = 2112; + unsigned cd_value_out; + unsigned flags_out; + unsigned filter_config_out; + int nfilters = 0; H5Z_class2_t filter_class; - char name_out[24]; - char filename[NAME_BUF_SIZE]; - htri_t tri_ret; - herr_t status; + char name_out[24]; + char filename[NAME_BUF_SIZE]; + htri_t tri_ret; + herr_t status; /* This test actually always uses the new group format for the main group. * The new format flag affects the version of object header messages, * etc., which are important for this test. */ - if(new_format) + if (new_format) TESTING("group link filters (w/new group format)") else TESTING("group link filters") @@ -13273,242 +16274,361 @@ link_filters(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create gcpl, force use of dense storage */ - if((gcpl1 = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR - if(H5Pset_link_phase_change(gcpl1, 2, 2) < 0) TEST_ERROR + if ((gcpl1 = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR + if (H5Pset_link_phase_change(gcpl1, 2, 2) < 0) + TEST_ERROR /* Add deflate and checksum filters, if available */ - if((tri_ret = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) < 0) TEST_ERROR - if(tri_ret) { - if(H5Pset_deflate(gcpl1, 6) < 0) TEST_ERROR + if ((tri_ret = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) < 0) + TEST_ERROR + if (tri_ret) { + if (H5Pset_deflate(gcpl1, 6) < 0) + TEST_ERROR nfilters++; } /* end if */ - if((tri_ret = H5Zfilter_avail(H5Z_FILTER_FLETCHER32)) < 0) TEST_ERROR - if(tri_ret) { - if(H5Pset_fletcher32(gcpl1) < 0) TEST_ERROR + if ((tri_ret = H5Zfilter_avail(H5Z_FILTER_FLETCHER32)) < 0) + TEST_ERROR + if (tri_ret) { + if (H5Pset_fletcher32(gcpl1) < 0) + TEST_ERROR nfilters++; } /* end if */ /* Register and add custom filter */ - filter_class.version = H5Z_CLASS_T_VERS; - filter_class.id = H5Z_FILTER_RESERVED + 42; + filter_class.version = H5Z_CLASS_T_VERS; + filter_class.id = H5Z_FILTER_RESERVED + 42; filter_class.encoder_present = TRUE; filter_class.decoder_present = TRUE; - filter_class.name = "custom_link_filter"; - filter_class.can_apply = link_filter_can_apply; - filter_class.set_local = link_filter_set_local; - filter_class.filter = link_filter_filter; - if(H5Zregister(&filter_class) < 0) TEST_ERROR - if(H5Pset_filter(gcpl1, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0) TEST_ERROR + filter_class.name = "custom_link_filter"; + filter_class.can_apply = link_filter_can_apply; + filter_class.set_local = link_filter_set_local; + filter_class.filter = link_filter_filter; + if (H5Zregister(&filter_class) < 0) + TEST_ERROR + if (H5Pset_filter(gcpl1, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0) + TEST_ERROR nfilters++; /* Test various other filter functions for use on gcpl's */ - if(H5Pget_nfilters(gcpl1) != nfilters) TEST_ERROR - if(H5Pall_filters_avail(gcpl1) != TRUE) TEST_ERROR + if (H5Pget_nfilters(gcpl1) != nfilters) + TEST_ERROR + if (H5Pall_filters_avail(gcpl1) != TRUE) + TEST_ERROR /* Create a group using this filter, add some soft links to it */ - if((gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, gcpl1, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, gcpl1, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lcreate_soft("/", gid1, "link1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file and group */ - if(H5Gclose(gid1) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Verify the filter has been applied */ - if(link_filter_state != LFS_ENCODED) TEST_ERROR + if (link_filter_state != LFS_ENCODED) + TEST_ERROR /* Reopen file and group */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((gid1 = H5Gopen2(fid, "group1", H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + if ((gid1 = H5Gopen2(fid, "group1", H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve gcpl, verify number of filters */ - if((gcpl2 = H5Gget_create_plist(gid1)) < 0) TEST_ERROR - if(H5Pget_nfilters(gcpl2) != nfilters) TEST_ERROR - if(H5Pclose(gcpl2) < 0) TEST_ERROR + if ((gcpl2 = H5Gget_create_plist(gid1)) < 0) + TEST_ERROR + if (H5Pget_nfilters(gcpl2) != nfilters) + TEST_ERROR + if (H5Pclose(gcpl2) < 0) + TEST_ERROR /* Now try copying gcpl1, and verify number of filters */ - if((gcpl2 = H5Pcopy(gcpl1)) < 0) TEST_ERROR - if(H5Pget_nfilters(gcpl2) != nfilters) TEST_ERROR - if(H5Pclose(gcpl2) < 0) TEST_ERROR + if ((gcpl2 = H5Pcopy(gcpl1)) < 0) + TEST_ERROR + if (H5Pget_nfilters(gcpl2) != nfilters) + TEST_ERROR + if (H5Pclose(gcpl2) < 0) + TEST_ERROR /* Add another soft link */ - if(H5Lcreate_soft("/", gid1, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft("/", gid1, "link4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Copy the group */ - if(H5Ocopy(fid, "group1", fid, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if((gid2 = H5Gopen2(fid, "group2", H5P_DEFAULT)) <0) TEST_ERROR + if (H5Ocopy(fid, "group1", fid, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if ((gid2 = H5Gopen2(fid, "group2", H5P_DEFAULT)) < 0) + TEST_ERROR /* Verify that all links have been copied */ - if(H5Lexists(gid2, "link1", H5P_DEFAULT) != TRUE) TEST_ERROR - if(H5Lexists(gid2, "link2", H5P_DEFAULT) != TRUE) TEST_ERROR - if(H5Lexists(gid2, "link3", H5P_DEFAULT) != TRUE) TEST_ERROR - if(H5Lexists(gid2, "link4", H5P_DEFAULT) != TRUE) TEST_ERROR + if (H5Lexists(gid2, "link1", H5P_DEFAULT) != TRUE) + TEST_ERROR + if (H5Lexists(gid2, "link2", H5P_DEFAULT) != TRUE) + TEST_ERROR + if (H5Lexists(gid2, "link3", H5P_DEFAULT) != TRUE) + TEST_ERROR + if (H5Lexists(gid2, "link4", H5P_DEFAULT) != TRUE) + TEST_ERROR /* Retrieve gcpl, verify number of filters */ - if((gcpl2 = H5Gget_create_plist(gid2)) < 0) TEST_ERROR - if(H5Pget_nfilters(gcpl2) != nfilters) TEST_ERROR + if ((gcpl2 = H5Gget_create_plist(gid2)) < 0) + TEST_ERROR + if (H5Pget_nfilters(gcpl2) != nfilters) + TEST_ERROR /* Delete 3 links to force the group back into compact mode */ - if(H5Ldelete(gid1, "link2", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(gid1, "link3", H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ldelete(gid1, "link4", H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(gid1, "link2", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(gid1, "link3", H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ldelete(gid1, "link4", H5P_DEFAULT) < 0) + TEST_ERROR /* Close file and groups */ - if(H5Gclose(gid1) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Reset link filter state */ link_filter_state = LFS_INIT; /* Reopen file and group, add 2 links */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((gid1 = H5Gopen2(fid, "group1", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + if ((gid1 = H5Gopen2(fid, "group1", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lcreate_soft("/", gid1, "link2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_soft("/", gid1, "link3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close file and group */ - if(H5Gclose(gid1) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Verify that the filter was reapplied */ - if(link_filter_state != LFS_ENCODED) TEST_ERROR + if (link_filter_state != LFS_ENCODED) + TEST_ERROR /* Test H5Pget_filter_by_id2 and H5Pget_filter2 */ - if(H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out, - &cd_nelmts, &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) TEST_ERROR - if(flags_out != 0 || cd_value_out != cd_value - || HDstrcmp(filter_class.name, name_out) - || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED - | H5Z_FILTER_CONFIG_DECODE_ENABLED)) TEST_ERROR - if(H5Pget_filter2(gcpl2, (unsigned)(nfilters - 1), &flags_out, &cd_nelmts, - &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) TEST_ERROR - if(flags_out != 0 || cd_value_out != cd_value - || HDstrcmp(filter_class.name, name_out) - || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED - | H5Z_FILTER_CONFIG_DECODE_ENABLED)) TEST_ERROR + if (H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out, &cd_nelmts, &cd_value_out, + (size_t)24, name_out, &filter_config_out) < 0) + TEST_ERROR + if (flags_out != 0 || cd_value_out != cd_value || HDstrcmp(filter_class.name, name_out) || + filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) + TEST_ERROR + if (H5Pget_filter2(gcpl2, (unsigned)(nfilters - 1), &flags_out, &cd_nelmts, &cd_value_out, (size_t)24, + name_out, &filter_config_out) < 0) + TEST_ERROR + if (flags_out != 0 || cd_value_out != cd_value || HDstrcmp(filter_class.name, name_out) || + filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) + TEST_ERROR /* Test H5Pmodify_filter */ cd_value++; - if(H5Pmodify_filter(gcpl2, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0) TEST_ERROR - if(H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out, - &cd_nelmts, &cd_value_out, (size_t)24, name_out, &filter_config_out) < 0) TEST_ERROR - if(flags_out != 0 || cd_value_out != cd_value - || HDstrcmp(filter_class.name, name_out) - || filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED - | H5Z_FILTER_CONFIG_DECODE_ENABLED)) TEST_ERROR + if (H5Pmodify_filter(gcpl2, H5Z_FILTER_RESERVED + 42, 0, (size_t)1, &cd_value) < 0) + TEST_ERROR + if (H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out, &cd_nelmts, &cd_value_out, + (size_t)24, name_out, &filter_config_out) < 0) + TEST_ERROR + if (flags_out != 0 || cd_value_out != cd_value || HDstrcmp(filter_class.name, name_out) || + filter_config_out != (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) + TEST_ERROR /* Test H5Premove_filter */ - if(H5Premove_filter(gcpl2, H5Z_FILTER_RESERVED + 42) < 0) TEST_ERROR - H5E_BEGIN_TRY { - status = H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, - &flags_out, &cd_nelmts, &cd_value_out, (size_t)24, name_out, - &filter_config_out); - } H5E_END_TRY - if(status >= 0) TEST_ERROR + if (H5Premove_filter(gcpl2, H5Z_FILTER_RESERVED + 42) < 0) + TEST_ERROR + H5E_BEGIN_TRY + { + status = H5Pget_filter_by_id2(gcpl2, H5Z_FILTER_RESERVED + 42, &flags_out, &cd_nelmts, &cd_value_out, + (size_t)24, name_out, &filter_config_out); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR /* Close remaining ids */ - if(H5Pclose(gcpl1) < 0) TEST_ERROR - if(H5Pclose(gcpl2) < 0) TEST_ERROR + if (H5Pclose(gcpl1) < 0) + TEST_ERROR + if (H5Pclose(gcpl2) < 0) + TEST_ERROR /* Now create an object in the compressed group, creating intermediate * groups, to verify that the filter pipeline is inherited for the groups * that are created along the way */ /* Reopen file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Create lcpl, setting the "create intermediate groups" flag */ - if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl, (unsigned)TRUE) < 0) TEST_ERROR + if ((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_create_intermediate_group(lcpl, (unsigned)TRUE) < 0) + TEST_ERROR /* Create new group, with missing intermediate groups, in compressed group */ - if((gid1 = H5Gcreate2(fid, "group1/group2/group3/group4", lcpl, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid1 = H5Gcreate2(fid, "group1/group2/group3/group4", lcpl, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close LCPL ID */ - if(H5Pclose(lcpl) < 0) TEST_ERROR + if (H5Pclose(lcpl) < 0) + TEST_ERROR /* Verify that new group doesn't have filters */ - if((gcpl1 = H5Gget_create_plist(gid1)) < 0) TEST_ERROR - if(H5Pget_nfilters(gcpl1) != 0) TEST_ERROR + if ((gcpl1 = H5Gget_create_plist(gid1)) < 0) + TEST_ERROR + if (H5Pget_nfilters(gcpl1) != 0) + TEST_ERROR /* Close group & GCPL IDs */ - if(H5Pclose(gcpl1) < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) TEST_ERROR + if (H5Pclose(gcpl1) < 0) + TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR /* Open intermediate groups that were created and verify that they have filters */ - if((gid1 = H5Gopen2(fid, "group1/group2", H5P_DEFAULT)) < 0) TEST_ERROR - if((gcpl1 = H5Gget_create_plist(gid1)) < 0) TEST_ERROR - if(H5Pget_nfilters(gcpl1) != nfilters) TEST_ERROR - if(H5Pclose(gcpl1) < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) TEST_ERROR - if((gid1 = H5Gopen2(fid, "group1/group2/group3", H5P_DEFAULT)) < 0) TEST_ERROR - if((gcpl1 = H5Gget_create_plist(gid1)) < 0) TEST_ERROR - if(H5Pget_nfilters(gcpl1) != nfilters) TEST_ERROR - if(H5Pclose(gcpl1) < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) TEST_ERROR + if ((gid1 = H5Gopen2(fid, "group1/group2", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((gcpl1 = H5Gget_create_plist(gid1)) < 0) + TEST_ERROR + if (H5Pget_nfilters(gcpl1) != nfilters) + TEST_ERROR + if (H5Pclose(gcpl1) < 0) + TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if ((gid1 = H5Gopen2(fid, "group1/group2/group3", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((gcpl1 = H5Gget_create_plist(gid1)) < 0) + TEST_ERROR + if (H5Pget_nfilters(gcpl1) != nfilters) + TEST_ERROR + if (H5Pclose(gcpl1) < 0) + TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Now create the same file with and without deflate, and verify that the * file size is smaller with deflate */ /* But only if the deflate filter is available */ - if((tri_ret = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) < 0) TEST_ERROR - if(tri_ret) { + if ((tri_ret = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) < 0) + TEST_ERROR + if (tri_ret) { h5_stat_size_t filesize_filtered; h5_stat_size_t filesize_unfiltered; /* Create gcpl, force use of dense storage */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR - if(H5Pset_link_phase_change(fcpl, 2, 2) < 0) TEST_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + if (H5Pset_link_phase_change(fcpl, 2, 2) < 0) + TEST_ERROR /* Create file */ - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR /* Create links in file */ - if(H5Lcreate_soft("/", fid, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/", fid, + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/", fid, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft( + "/", fid, + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/", fid, "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/", fid, + "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file, get file size */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR filesize_unfiltered = h5_get_file_size(filename, fapl); /* Set deflate fitler */ - if(H5Pset_deflate(fcpl, 6) < 0) TEST_ERROR + if (H5Pset_deflate(fcpl, 6) < 0) + TEST_ERROR /* Recreate the same file with the deflate filter */ - if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR - if(H5Lcreate_soft("/", fid, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", H5P_DEFAULT, H5P_DEFAULT) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR + if (H5Lcreate_soft("/", fid, + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/", fid, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft( + "/", fid, + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_soft("/", fid, "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/", fid, + "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file, get file size */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR filesize_filtered = h5_get_file_size(filename, fapl); /* Check that the file size is smaller with the filter */ - if((double)filesize_filtered > ((double)filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION)) TEST_ERROR + if ((double)filesize_filtered > ((double)filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION)) + TEST_ERROR /* Close */ - if(H5Pclose(fcpl) < 0) TEST_ERROR + if (H5Pclose(fcpl) < 0) + TEST_ERROR } /* end if */ PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid1); H5Gclose(gid2); H5Fclose(fid); @@ -13516,11 +16636,11 @@ error: H5Pclose(gcpl1); H5Pclose(gcpl2); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end link_filters() */ - /*------------------------------------------------------------------------- * Function: obj_exists * @@ -13533,12 +16653,12 @@ error: static int obj_exists(hid_t fapl, hbool_t new_format) { - char filename[NAME_BUF_SIZE]; /* Buffer for file name */ - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - herr_t status; /* Generic return value */ + char filename[NAME_BUF_SIZE]; /* Buffer for file name */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + herr_t status; /* Generic return value */ - if(new_format) + if (new_format) TESTING("object exists (w/new group format)") else TESTING("object exists") @@ -13546,227 +16666,310 @@ obj_exists(hid_t fapl, hbool_t new_format) /* Set up filename and create file*/ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR -/* Hard links */ + /* Hard links */ /* Verify that H5Oexists_by_name() fails for non-existent link in root group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Oexists_by_name(fid, "foo", H5P_DEFAULT); - } H5E_END_TRY - if(status >= 0) TEST_ERROR + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR /* Create a group, as a destination for testing */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() succeeds for hard linked object */ - if(TRUE != H5Oexists_by_name(fid, "group", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "group", H5P_DEFAULT)) + TEST_ERROR /* Verify that H5Oexists_by_name() fails for non-existent link in non-root group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Oexists_by_name(fid, "group/foo", H5P_DEFAULT); - } H5E_END_TRY - if(status >= 0) TEST_ERROR + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR -/* Soft links */ + /* Soft links */ /* Create dangling soft-link in root group */ - if(H5Lcreate_soft("dangle", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("dangle", fid, "soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE for dangling soft-link in root group */ - if(FALSE != H5Oexists_by_name(fid, "soft1", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "soft1", H5P_DEFAULT)) + TEST_ERROR /* Create soft-link in root group that points to object */ - if(H5Lcreate_soft("/group", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/group", fid, "soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE for soft-link in root group that points to object */ - if(TRUE != H5Oexists_by_name(fid, "soft2", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "soft2", H5P_DEFAULT)) + TEST_ERROR /* Create dangling soft-link in non-root group */ - if(H5Lcreate_soft("dangle", fid, "group/soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("dangle", fid, "group/soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE for dangling soft-link in non-root group */ - if(FALSE != H5Oexists_by_name(fid, "group/soft1", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "group/soft1", H5P_DEFAULT)) + TEST_ERROR /* Create soft-link in non-root group that points to object */ - if(H5Lcreate_soft("/group", fid, "group/soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/group", fid, "group/soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE for soft-link in non-root group that points to object */ - if(TRUE != H5Oexists_by_name(fid, "group/soft2", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "group/soft2", H5P_DEFAULT)) + TEST_ERROR -/* External links */ + /* External links */ /* Create dangling (file doesn't exist) external link in root group */ - if(H5Lcreate_external("nofile", "dangle", fid, "external1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external("nofile", "dangle", fid, "external1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - /* Verify that H5Oexists_by_name() returns FALSE for dangling (file doesn't exist) external link in root group */ - if(FALSE != H5Oexists_by_name(fid, "external1", H5P_DEFAULT)) TEST_ERROR + /* Verify that H5Oexists_by_name() returns FALSE for dangling (file doesn't exist) external link in root + * group */ + if (FALSE != H5Oexists_by_name(fid, "external1", H5P_DEFAULT)) + TEST_ERROR /* Create dangling (object doesn't exist) external link in root group */ - if(H5Lcreate_external(filename, "dangle", fid, "external2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "dangle", fid, "external2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - /* Verify that H5Oexists_by_name() returns FALSE for dangling (object doesn't exist) external link in root group */ - if(FALSE != H5Oexists_by_name(fid, "external2", H5P_DEFAULT)) TEST_ERROR + /* Verify that H5Oexists_by_name() returns FALSE for dangling (object doesn't exist) external link in root + * group */ + if (FALSE != H5Oexists_by_name(fid, "external2", H5P_DEFAULT)) + TEST_ERROR /* Create external link in root group that points to object */ - if(H5Lcreate_external(filename, "group", fid, "external3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "group", fid, "external3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE for external link in root group that points to object */ - if(TRUE != H5Oexists_by_name(fid, "external3", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "external3", H5P_DEFAULT)) + TEST_ERROR /* Create dangling (file doesn't exist) external link in non-root group */ - if(H5Lcreate_external("nofile", "dangle", fid, "group/external1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external("nofile", "dangle", fid, "group/external1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - /* Verify that H5Oexists_by_name() returns FALSE for dangling (file doesn't exist) external link in non-root group */ - if(FALSE != H5Oexists_by_name(fid, "group/external1", H5P_DEFAULT)) TEST_ERROR + /* Verify that H5Oexists_by_name() returns FALSE for dangling (file doesn't exist) external link in + * non-root group */ + if (FALSE != H5Oexists_by_name(fid, "group/external1", H5P_DEFAULT)) + TEST_ERROR /* Create dangling (object doesn't exist) external link in non-root group */ - if(H5Lcreate_external(filename, "dangle", fid, "group/external2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "dangle", fid, "group/external2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - /* Verify that H5Oexists_by_name() returns FALSE for dangling (object doesn't exist) external link in non-root group */ - if(FALSE != H5Oexists_by_name(fid, "group/external2", H5P_DEFAULT)) TEST_ERROR + /* Verify that H5Oexists_by_name() returns FALSE for dangling (object doesn't exist) external link in + * non-root group */ + if (FALSE != H5Oexists_by_name(fid, "group/external2", H5P_DEFAULT)) + TEST_ERROR /* Create external link in non-root group that points to object */ - if(H5Lcreate_external(filename, "group", fid, "group/external3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "group", fid, "group/external3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - /* Verify that H5Oexists_by_name() returns TRUE for external link in non-root group that points to object */ - if(TRUE != H5Oexists_by_name(fid, "group/external3", H5P_DEFAULT)) TEST_ERROR + /* Verify that H5Oexists_by_name() returns TRUE for external link in non-root group that points to object + */ + if (TRUE != H5Oexists_by_name(fid, "group/external3", H5P_DEFAULT)) + TEST_ERROR -/* Soft->External links */ + /* Soft->External links */ /* Create soft-link in root group that points to dangling (file doesn't exist) external link */ - if(H5Lcreate_soft("external1", fid, "soft-elink1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("external1", fid, "soft-elink1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "soft-elink1", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "soft-elink1", H5P_DEFAULT)) + TEST_ERROR /* Create soft-link in root group that points to dangling (object doesn't exist) external link */ - if(H5Lcreate_soft("external2", fid, "soft-elink2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("external2", fid, "soft-elink2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "soft-elink2", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "soft-elink2", H5P_DEFAULT)) + TEST_ERROR /* Create soft-link in root group that points to external link that points to object */ - if(H5Lcreate_soft("external3", fid, "soft-elink3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("external3", fid, "soft-elink3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "soft-elink3", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "soft-elink3", H5P_DEFAULT)) + TEST_ERROR - /* Create soft-link in root group that points to dangling (file doesn't exist) external link in non-root group */ - if(H5Lcreate_soft("group/external1", fid, "soft-elink4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + /* Create soft-link in root group that points to dangling (file doesn't exist) external link in non-root + * group */ + if (H5Lcreate_soft("group/external1", fid, "soft-elink4", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "soft-elink4", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "soft-elink4", H5P_DEFAULT)) + TEST_ERROR - /* Create soft-link in root group that points to dangling (object doesn't exist) external link in non-root group */ - if(H5Lcreate_soft("group/external2", fid, "soft-elink5", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + /* Create soft-link in root group that points to dangling (object doesn't exist) external link in non-root + * group */ + if (H5Lcreate_soft("group/external2", fid, "soft-elink5", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "soft-elink5", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "soft-elink5", H5P_DEFAULT)) + TEST_ERROR /* Create soft-link in root group that points to external link in non-root group that points to object */ - if(H5Lcreate_soft("group/external3", fid, "soft-elink6", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("group/external3", fid, "soft-elink6", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "soft-elink6", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "soft-elink6", H5P_DEFAULT)) + TEST_ERROR /* Create soft-link in non-root group that points to dangling (file doesn't exist) external link */ - if(H5Lcreate_soft("/external1", fid, "group/soft-elink1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/external1", fid, "group/soft-elink1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/soft-elink1", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "group/soft-elink1", H5P_DEFAULT)) + TEST_ERROR /* Create soft-link in non-root group that points to dangling (object doesn't exist) external link */ - if(H5Lcreate_soft("/external2", fid, "group/soft-elink2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/external2", fid, "group/soft-elink2", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/soft-elink2", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "group/soft-elink2", H5P_DEFAULT)) + TEST_ERROR /* Create soft-link in non-root group that points to external link that points to object */ - if(H5Lcreate_soft("/external3", fid, "group/soft-elink3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/external3", fid, "group/soft-elink3", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "group/soft-elink3", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "group/soft-elink3", H5P_DEFAULT)) + TEST_ERROR - /* Create soft-link in non-root group that points to dangling (file doesn't exist) external link in non-root group */ - if(H5Lcreate_soft("/group/external1", fid, "group/soft-elink4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + /* Create soft-link in non-root group that points to dangling (file doesn't exist) external link in + * non-root group */ + if (H5Lcreate_soft("/group/external1", fid, "group/soft-elink4", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/soft-elink4", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "group/soft-elink4", H5P_DEFAULT)) + TEST_ERROR - /* Create soft-link in non-root group that points to dangling (object doesn't exist) external link in non-root group */ - if(H5Lcreate_soft("/group/external2", fid, "group/soft-elink5", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + /* Create soft-link in non-root group that points to dangling (object doesn't exist) external link in + * non-root group */ + if (H5Lcreate_soft("/group/external2", fid, "group/soft-elink5", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/soft-elink5", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "group/soft-elink5", H5P_DEFAULT)) + TEST_ERROR - /* Create soft-link in non-root group that points to external link in non-root group that points to object */ - if(H5Lcreate_soft("/group/external3", fid, "group/soft-elink6", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + /* Create soft-link in non-root group that points to external link in non-root group that points to object + */ + if (H5Lcreate_soft("/group/external3", fid, "group/soft-elink6", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "group/soft-elink6", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "group/soft-elink6", H5P_DEFAULT)) + TEST_ERROR -/* External->Soft links */ + /* External->Soft links */ /* Create external link in root group that points to dangling soft link in root group */ - if(H5Lcreate_external(filename, "soft1", fid, "elink-soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "soft1", fid, "elink-soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "elink-soft1", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "elink-soft1", H5P_DEFAULT)) + TEST_ERROR /* Create external link in root group that points to soft link in root group that points to object */ - if(H5Lcreate_external(filename, "soft2", fid, "elink-soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "soft2", fid, "elink-soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "elink-soft2", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "elink-soft2", H5P_DEFAULT)) + TEST_ERROR /* Create external link in root group that points to dangling soft link in non-root group */ - if(H5Lcreate_external(filename, "group/soft1", fid, "elink-soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "group/soft1", fid, "elink-soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "elink-soft3", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "elink-soft3", H5P_DEFAULT)) + TEST_ERROR /* Create external link in root group that points to soft link in root group that points to object */ - if(H5Lcreate_external(filename, "group/soft2", fid, "elink-soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "group/soft2", fid, "elink-soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "elink-soft4", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "elink-soft4", H5P_DEFAULT)) + TEST_ERROR /* Create external link in non-root group that points to dangling soft link in root group */ - if(H5Lcreate_external(filename, "soft1", fid, "group/elink-soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "soft1", fid, "group/elink-soft1", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/elink-soft1", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "group/elink-soft1", H5P_DEFAULT)) + TEST_ERROR /* Create external link in non-root group that points to soft link in root group that points to object */ - if(H5Lcreate_external(filename, "soft2", fid, "group/elink-soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "soft2", fid, "group/elink-soft2", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "group/elink-soft2", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "group/elink-soft2", H5P_DEFAULT)) + TEST_ERROR /* Create external link in non-root group that points to dangling soft link in non-root group */ - if(H5Lcreate_external(filename, "group/soft1", fid, "group/elink-soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename, "group/soft1", fid, "group/elink-soft3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns FALSE */ - if(FALSE != H5Oexists_by_name(fid, "group/elink-soft3", H5P_DEFAULT)) TEST_ERROR + if (FALSE != H5Oexists_by_name(fid, "group/elink-soft3", H5P_DEFAULT)) + TEST_ERROR - /* Create external link in non-root group that points to soft link in non-root group that points to object */ - if(H5Lcreate_external(filename, "group/soft2", fid, "group/elink-soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Create external link in non-root group that points to soft link in non-root group that points to object + */ + if (H5Lcreate_external(filename, "group/soft2", fid, "group/elink-soft4", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify that H5Oexists_by_name() returns TRUE */ - if(TRUE != H5Oexists_by_name(fid, "group/elink-soft4", H5P_DEFAULT)) TEST_ERROR + if (TRUE != H5Oexists_by_name(fid, "group/elink-soft4", H5P_DEFAULT)) + TEST_ERROR /* Close file created */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end obj_exists() */ - /*------------------------------------------------------------------------- * Function: corder_create_empty * @@ -13779,96 +16982,123 @@ error: static int corder_create_empty(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned crt_order_flags; /* Status of creation order info for GCPL */ - herr_t ret; /* Generic return value */ - char filename[NAME_BUF_SIZE];/* File name */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned crt_order_flags; /* Status of creation order info for GCPL */ + herr_t ret; /* Generic return value */ + char filename[NAME_BUF_SIZE]; /* File name */ TESTING("creating empty group with creation order indexing") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order indexing on group */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) TEST_ERROR - if(crt_order_flags != 0) TEST_ERROR + if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) + TEST_ERROR + if (crt_order_flags != 0) + TEST_ERROR /* Setting invalid combination of a group order creation order indexing on should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_INDEXED); - } H5E_END_TRY; - if(ret > 0) { + } + H5E_END_TRY; + if (ret > 0) { H5_FAILED(); - HDputs(" H5Pset_link_create_order() should have failed for a creation order index with no tracking."); + HDputs( + " H5Pset_link_create_order() should have failed for a creation order index with no tracking."); TEST_ERROR } /* end if */ /* Set creation order tracking & indexing on group */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) TEST_ERROR - if(crt_order_flags != 0) TEST_ERROR - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) TEST_ERROR - if(crt_order_flags != (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) TEST_ERROR + if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) + TEST_ERROR + if (crt_order_flags != 0) + TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) + TEST_ERROR + if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) + TEST_ERROR + if (crt_order_flags != (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on group's status */ - if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_empty_test(group_id) != TRUE) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open group created */ - if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check on group's status */ - if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_empty_test(group_id) != TRUE) + TEST_ERROR /* Retrieve group creation property list for group */ - if((gcpl_id = H5Gget_create_plist(group_id)) < 0) TEST_ERROR + if ((gcpl_id = H5Gget_create_plist(group_id)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) TEST_ERROR - if(crt_order_flags != (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) TEST_ERROR + if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) + TEST_ERROR + if (crt_order_flags != (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end corder_create_empty() */ - /*------------------------------------------------------------------------- * Function: corder_create_compact * @@ -13882,106 +17112,135 @@ error: static int corder_create_compact(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - unsigned u; /* Local index variable */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned nlinks; /* Number of link messages in group's header */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + unsigned u; /* Local index variable */ TESTING("creating compact group with creation order indexing") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on group's initial status */ - if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__is_empty_test(group_id) != TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Create several links, but keep group in compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR - if(nlinks != (u + 1)) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, &nlinks) != TRUE) + TEST_ERROR + if (nlinks != (u + 1)) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR } /* end for */ /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open group created */ - if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR - if(nlinks != max_compact) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, &nlinks) != TRUE) + TEST_ERROR + if (nlinks != max_compact) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Loop through links, checking their creation order values */ /* (the name index is used, but the creation order value is in the same order) */ - for(u = 0; u < max_compact; u++) { - H5L_info2_t linfo; /* Link information */ + for (u = 0; u < max_compact; u++) { + H5L_info2_t linfo; /* Link information */ /* Retrieve information for link */ HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Lget_info2(group_id, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info2(group_id, objname, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify creation order of link */ - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != u) TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != u) + TEST_ERROR } /* end for */ /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end corder_create_compact() */ - /*------------------------------------------------------------------------- * Function: corder_create_dense * @@ -13995,121 +17254,156 @@ error: static int corder_create_dense(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - unsigned u; /* Local index variable */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned nlinks; /* Number of link messages in group's header */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + unsigned u; /* Local index variable */ TESTING("creating dense group with creation order indexing") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on group's initial status */ - if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__is_empty_test(group_id) != TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR - if(nlinks != (u + 1)) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, &nlinks) != TRUE) + TEST_ERROR + if (nlinks != (u + 1)) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR } /* end for */ /* Create another link, to push group into dense form */ HDsnprintf(objname, sizeof(objname), "filler %u", max_compact); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open group created */ - if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Loop through links, checking their creation order values */ /* (the name index is used, but the creation order value is in the same order) */ - for(u = 0; u < (max_compact + 1); u++) { - H5L_info2_t linfo; /* Link information */ + for (u = 0; u < (max_compact + 1); u++) { + H5L_info2_t linfo; /* Link information */ /* Retrieve information for link */ HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Lget_info2(group_id, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_info2(group_id, objname, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify creation order of link */ - if(linfo.corder_valid != TRUE) TEST_ERROR - if(linfo.corder != u) TEST_ERROR + if (linfo.corder_valid != TRUE) + TEST_ERROR + if (linfo.corder != u) + TEST_ERROR } /* end for */ /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end corder_create_dense() */ - /*------------------------------------------------------------------------- * Function: corder_transition * @@ -14123,216 +17417,289 @@ error: static int corder_transition(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned nlinks; /* Number of link messages in group's header */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - h5_stat_size_t empty_size; /* Size of empty file */ - h5_stat_size_t file_size; /* Size of file after operating on it */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - unsigned u; /* Local index variable */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned nlinks; /* Number of link messages in group's header */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + h5_stat_size_t empty_size; /* Size of empty file */ + h5_stat_size_t file_size; /* Size of file after operating on it */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + unsigned u; /* Local index variable */ TESTING("transitioning group with creation order indexing between dense & compact forms") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) FAIL_STACK_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + FAIL_STACK_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) FAIL_STACK_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + FAIL_STACK_ERROR /* Increase estimated link info, so the group's object header is large * enough to hold all the link messages in one chunk */ - if(H5Pset_est_link_info(gcpl_id, max_compact, CORDER_EST_ENTRY_LEN) < 0) TEST_ERROR + if (H5Pset_est_link_info(gcpl_id, max_compact, CORDER_EST_ENTRY_LEN) < 0) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) FAIL_STACK_ERROR + if (H5Pclose(gcpl_id) < 0) + FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Get the size of the file with an empty group */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Open group created */ - if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Create another link, to push group into dense form */ HDsnprintf(objname, sizeof(objname), "filler %u", max_compact); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR /* Delete several links from group, until it resumes compact form */ - for(u = max_compact; u >= min_dense; u--) { + for (u = max_compact; u >= min_dense; u--) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR } /* end for */ /* Delete another link, to push group into compact form */ HDsnprintf(objname, sizeof(objname), "filler %u", (min_dense - 1)); - if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR - if(nlinks != (min_dense - 1)) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, &nlinks) != TRUE) + TEST_ERROR + if (nlinks != (min_dense - 1)) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Re-add links to get back into dense form */ - for(u = (min_dense - 1); u < (max_compact + 1); u++) { + for (u = (min_dense - 1); u < (max_compact + 1); u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR /* Open group created */ - if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR /* Delete several links from group, until it resumes compact form */ - for(u = max_compact; u >= min_dense; u--) { + for (u = max_compact; u >= min_dense; u--) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR } /* end for */ /* Delete another link, to push group into compact form */ HDsnprintf(objname, sizeof(objname), "filler %u", (min_dense - 1)); - if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR - if(nlinks != (min_dense - 1)) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, &nlinks) != TRUE) + TEST_ERROR + if (nlinks != (min_dense - 1)) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Re-add links to get back into dense form */ - for(u = (min_dense - 1); u < (max_compact + 1); u++) { + for (u = (min_dense - 1); u < (max_compact + 1); u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR /* Delete all the links */ - for(u = max_compact; u > 0; u--) { + for (u = max_compact; u > 0; u--) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) + TEST_ERROR } /* end for */ HDsnprintf(objname, sizeof(objname), "filler %u", (unsigned)0); - if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Get the size of the file now */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - if(file_size != empty_size) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end corder_transition() */ - /*------------------------------------------------------------------------- * Function: corder_delete * @@ -14347,117 +17714,143 @@ error: static int corder_delete(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - unsigned reopen_file; /* Whether to re-open the file before deleting group */ - h5_stat_size_t empty_size; /* Size of empty file */ - h5_stat_size_t file_size; /* Size of file after operating on it */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - unsigned u; /* Local index variable */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + unsigned reopen_file; /* Whether to re-open the file before deleting group */ + h5_stat_size_t empty_size; /* Size of empty file */ + h5_stat_size_t file_size; /* Size of file after operating on it */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + unsigned u; /* Local index variable */ TESTING("deleting group with creation order indexing in dense form") /* Loop to leave file open when deleting group, or to close & re-open file * before deleting group */ - for(reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) { + for (reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) { /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - /* Creating file with latest format will enable paged aggregation with persistent fs */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + /* Creating file with latest format will enable paged aggregation with persistent fs */ + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Get the size of an empty file */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) FAIL_STACK_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + FAIL_STACK_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) FAIL_STACK_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + FAIL_STACK_ERROR /* Increase estimated link info, so the group's object header is large * enough to hold all the link messages in one chunk */ - if(H5Pset_est_link_info(gcpl_id, max_compact, CORDER_EST_ENTRY_LEN) < 0) TEST_ERROR + if (H5Pset_est_link_info(gcpl_id, max_compact, CORDER_EST_ENTRY_LEN) < 0) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) FAIL_STACK_ERROR + if (H5Pclose(gcpl_id) < 0) + FAIL_STACK_ERROR /* Create links until the group is in dense form */ - for(u = 0; u < max_compact * 2; u++) { + for (u = 0; u < max_compact * 2; u++) { HDsnprintf(objname, sizeof(objname), "filler %u", u); - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group_id2) < 0) FAIL_STACK_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group_id2) < 0) + FAIL_STACK_ERROR } /* end for */ /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(group_id) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR - if(name_count != corder_count) TEST_ERROR + if (H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) + TEST_ERROR + if (name_count != corder_count) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) FAIL_STACK_ERROR + if (H5Gclose(group_id) < 0) + FAIL_STACK_ERROR /* Check for deleting group without re-opening file */ - if(!reopen_file) + if (!reopen_file) /* Delete the group with the creation order index */ - if(H5Ldelete(file_id, CORDER_GROUP_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, CORDER_GROUP_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Check for deleting group after re-opening file */ - if(reopen_file) { + if (reopen_file) { /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Delete the group with the creation order index */ - if(H5Ldelete(file_id, CORDER_GROUP_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, CORDER_GROUP_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR } /* end if */ /* Get the size of the file now */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - if(file_size != empty_size) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR + if (file_size != empty_size) + TEST_ERROR } /* end for */ PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end corder_delete() */ - /*------------------------------------------------------------------------- * Function: link_info_by_idx_check * @@ -14472,111 +17865,153 @@ error: *------------------------------------------------------------------------- */ static int -link_info_by_idx_check(hid_t group_id, const char *linkname, hsize_t n, - hbool_t hard_link, hbool_t use_index) +link_info_by_idx_check(hid_t group_id, const char *linkname, hsize_t n, hbool_t hard_link, hbool_t use_index) { - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - char valname[NAME_BUF_SIZE]; /* Link value name */ - char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ - H5L_info2_t linfo; /* Link info struct */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + char valname[NAME_BUF_SIZE]; /* Link value name */ + char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ + H5L_info2_t linfo; /* Link info struct */ /* Make link value for increasing/native order queries */ HDsnprintf(valname, sizeof(valname), "value %02u", (unsigned)n); /* Verify the link information for first link, in increasing creation order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in increasing creation order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in increasing creation order */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in increasing creation order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, + H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR /* Don't test "native" order if there is no creation order index, since * there's not a good way to easily predict the link's order in the name * index. */ - if(use_index) { + if (use_index) { /* Verify the link information for first link, in native creation order (which is increasing) */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, (hsize_t)0, &linfo, + H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in native creation order (which is increasing) */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in native creation order (which is increasing) */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in native creation order (which is increasing) */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR } /* end if */ /* Verify the link information for first link, in decreasing creation order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, n, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in decreasing creation order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in decreasing creation order */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in decreasing creation order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR - + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR /* Verify the link information for first link, in increasing link name order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in increasing link name order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in increasing link name order */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpval, (size_t)NAME_BUF_SIZE, + H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in increasing link name order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, + H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR /* Don't test "native" order queries on link name order, since there's not * a good way to easily predict the order of the links in the name index. @@ -14584,35 +18019,44 @@ link_info_by_idx_check(hid_t group_id, const char *linkname, hsize_t n, /* Verify the link information for first link, in decreasing link name order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, n, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != 0) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, n, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != 0) + TEST_ERROR /* Verify the link information for new link, in decreasing link name order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.corder != (int64_t)n) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.corder != (int64_t)n) + TEST_ERROR /* Verify value for new soft link, in decreasing link name order */ - if(!hard_link) { + if (!hard_link) { HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end if */ /* Verify the name for new link, in decreasing link name order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(linkname, tmpname)) + TEST_ERROR /* Success */ - return(0); + return (0); error: /* Failure */ - return(-1); + return (-1); } /* end link_info_by_idx_check() */ - /*------------------------------------------------------------------------- * Function: link_info_by_idx * @@ -14626,34 +18070,34 @@ error: static int link_info_by_idx(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - unsigned hard_link; /* Create hard or soft link? */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - H5L_info2_t linfo; /* Link info struct */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char valname[NAME_BUF_SIZE]; /* Link value name */ - char filename[NAME_BUF_SIZE];/* File name */ - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - unsigned u; /* Local index variable */ - ssize_t name_len; /* Length of name */ - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + unsigned hard_link; /* Create hard or soft link? */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5L_info2_t linfo; /* Link info struct */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char valname[NAME_BUF_SIZE]; /* Link value name */ + char filename[NAME_BUF_SIZE]; /* File name */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ + herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ - for(hard_link = FALSE; hard_link <= TRUE; hard_link++) { + for (hard_link = FALSE; hard_link <= TRUE; hard_link++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { - if(hard_link) { - if(use_index) + for (use_index = FALSE; use_index <= TRUE; use_index++) { + if (hard_link) { + if (use_index) TESTING("querying info by index w/creation order index, using hard links") else TESTING("querying info by index w/o creation order index, using hard links") } /* end if */ else { - if(use_index) + if (use_index) TESTING("querying info by index w/creation order index, using soft links") else TESTING("querying info by index w/o creation order index, using soft links") @@ -14661,139 +18105,193 @@ link_info_by_idx(hid_t fapl) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order( + gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) + TEST_ERROR /* Create group with creation order indexing & tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Check for query on empty group */ - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - } H5E_END_TRY; - if(name_len >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + } + H5E_END_TRY; + if (name_len >= 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Check for creating hard or soft link */ - if(hard_link) { - hid_t group_id2; /* Group ID */ + if (hard_link) { + hid_t group_id2; /* Group ID */ /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end if */ else { /* Make value for link */ HDsnprintf(valname, sizeof(valname), "value %02u", u); /* Create soft link */ - if(H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ /* Verify link information for new link */ - if(link_info_by_idx_check(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) + TEST_ERROR } /* end for */ /* Verify state of group */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound offset queries */ - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - } H5E_END_TRY; - if(name_len >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + } + H5E_END_TRY; + if (name_len >= 0) + TEST_ERROR /* Create more links, to push group into dense form */ - for(; u < (max_compact * 2); u++) { + for (; u < (max_compact * 2); u++) { /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Check for creating hard or soft link */ - if(hard_link) { - hid_t group_id2; /* Group ID */ + if (hard_link) { + hid_t group_id2; /* Group ID */ /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end if */ else { /* Make value for link */ HDsnprintf(valname, sizeof(valname), "value %02u", u); /* Create soft link */ - if(H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ /* Verify state of group */ - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Verify link information for new link */ - if(link_info_by_idx_check(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) + TEST_ERROR } /* end for */ /* Check for out of bound offset queries */ - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - } H5E_END_TRY; - if(name_len >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + } + H5E_END_TRY; + if (name_len >= 0) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ + } /* end for */ return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end link_info_by_idx() */ - /*------------------------------------------------------------------------- * Function: link_info_by_idx_old * @@ -14807,75 +18305,83 @@ error: static int link_info_by_idx_old(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - H5F_t *f = NULL; - unsigned hard_link; /* Create hard or soft link? */ - H5L_info2_t linfo; /* Link info struct */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char valname[NAME_BUF_SIZE]; /* Link value name */ - char filename[NAME_BUF_SIZE];/* File name */ - H5O_token_t objtoken[CORDER_NLINKS];/* Tokens (Addresses) of the objects created */ - void *vol_obj_file = NULL; /* Object of file_id */ - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ - unsigned u; /* Local index variable */ - ssize_t name_len; /* Length of name */ - int token_cmp; - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + H5F_t * f = NULL; + unsigned hard_link; /* Create hard or soft link? */ + H5L_info2_t linfo; /* Link info struct */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char valname[NAME_BUF_SIZE]; /* Link value name */ + char filename[NAME_BUF_SIZE]; /* File name */ + H5O_token_t objtoken[CORDER_NLINKS]; /* Tokens (Addresses) of the objects created */ + void * vol_obj_file = NULL; /* Object of file_id */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ + unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ + int token_cmp; + herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ - for(hard_link = FALSE; hard_link <= TRUE; hard_link++) { - if(hard_link) + for (hard_link = FALSE; hard_link <= TRUE; hard_link++) { + if (hard_link) TESTING("querying info by index in old-style group, using hard links") else TESTING("querying info by index in old-style group, using soft links") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Need the file struct to address encoding */ /* Retrieve VOL object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) TEST_ERROR + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) + TEST_ERROR /* Retrieve file from VOL object */ - if(NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) TEST_ERROR + if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) + TEST_ERROR /* Create group to operate on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { + for (u = 0; u < CORDER_NLINKS; u++) { /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Check for creating hard or soft link */ - if(hard_link) { - H5O_info2_t oi; /* Buffer for querying object's info */ + if (hard_link) { + H5O_info2_t oi; /* Buffer for querying object's info */ /* Create group */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's object token */ - if(H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&objtoken[u], &oi.token, sizeof(H5O_token_t)); /* Close group */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end if */ else { /* Make value for link */ HDsnprintf(valname, sizeof(valname), "value %02u", u); /* Create soft link */ - if(H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ - } /* end for */ + } /* end for */ /* Verify link information for created links */ - for(u = 0; u < CORDER_NLINKS; u++) { - unsigned dec_u = CORDER_NLINKS - (u + 1); /* Decreasing mapped index */ + for (u = 0; u < CORDER_NLINKS; u++) { + unsigned dec_u = CORDER_NLINKS - (u + 1); /* Decreasing mapped index */ /* Make link name for increasing/native order queries */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); @@ -14884,36 +18390,54 @@ link_info_by_idx_old(hid_t fapl) HDsnprintf(valname, sizeof(valname), "value %02u", u); /* Verify link information (in increasing order) */ - if(hard_link) { - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (hard_link) { + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, &linfo, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end if */ else { - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end else */ /* Verify link name (in increasing order) */ - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(objname, tmpname)) TEST_ERROR - + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR /* Verify link information (in native order - native is increasing) */ - if(hard_link) { - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (hard_link) { + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, &linfo, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end if */ else { - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end else */ /* Verify link name (in native order - native is increasing) */ - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(objname, tmpname)) TEST_ERROR - + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR /* Make link name for decreasing order queries */ HDsnprintf(objname, sizeof(objname), "filler %02u", dec_u); @@ -14922,39 +18446,60 @@ link_info_by_idx_old(hid_t fapl) HDsnprintf(valname, sizeof(valname), "value %02u", dec_u); /* Verify link information (in decreasing order) */ - if(hard_link) { - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[dec_u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (hard_link) { + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, &linfo, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[dec_u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end if */ else { - if(H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, tmpval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(valname, tmpval)) TEST_ERROR + if (H5Lget_val_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, tmpval, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(valname, tmpval)) + TEST_ERROR } /* end else */ /* Verify link name (in decreasing order) */ - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Check for creation order index queries */ - H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - } H5E_END_TRY; - if(name_len >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY + { + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + } + H5E_END_TRY; + if (name_len >= 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ @@ -14962,14 +18507,15 @@ link_info_by_idx_old(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end link_info_by_idx_old() */ - /*------------------------------------------------------------------------- * Function: delete_by_idx * @@ -14983,309 +18529,399 @@ error: static int delete_by_idx(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - H5L_info2_t linfo; /* Link info struct */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5L_info2_t linfo; /* Link info struct */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("deleting links by creation order index in increasing order w/creation order index") + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + TESTING("deleting links by creation order index in increasing order w/creation " + "order index") else - TESTING("deleting links by creation order index in increasing order w/o creation order index") + TESTING("deleting links by creation order index in increasing order w/o creation " + "order index") } /* end if */ else { - if(use_index) - TESTING("deleting links by creation order index in decreasing order w/creation order index") + if (use_index) + TESTING("deleting links by creation order index in decreasing order w/creation " + "order index") else - TESTING("deleting links by creation order index in decreasing order w/o creation order index") + TESTING("deleting links by creation order index in decreasing order w/o creation " + "order index") } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) + if (order == H5_ITER_INC) { + if (use_index) TESTING("deleting links by name index in increasing order w/creation order index") else - TESTING("deleting links by name index in increasing order w/o creation order index") + TESTING( + "deleting links by name index in increasing order w/o creation order index") } /* end if */ else { - if(use_index) + if (use_index) TESTING("deleting links by name index in decreasing order w/creation order index") else - TESTING("deleting links by name index in decreasing order w/o creation order index") + TESTING( + "deleting links by name index in decreasing order w/o creation order index") } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | + (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < + 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Delete links from one end */ /* Check for deletion on empty group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for deletion on non-existing group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, "None", idx_type, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < max_compact; u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify link information for new link */ - if(link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (compact) */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound deletion */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Delete links from compact group */ - for(u = 0; u < (max_compact - 1); u++) { + for (u = 0; u < (max_compact - 1); u++) { /* Delete first link in appropriate order */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(linfo.corder != (u + 1)) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (linfo.corder != (u + 1)) + TEST_ERROR } /* end if */ else { - if(linfo.corder != (max_compact - (u + 2))) TEST_ERROR + if (linfo.corder != (max_compact - (u + 2))) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", (u + 1)); else HDsnprintf(objname, sizeof(objname), "filler %02u", (max_compact - (u + 2))); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group (empty) */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR /* Create more links, to push group into dense form */ - for(u = 0; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < (max_compact * 2); u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group (dense) */ - if(u >= max_compact) - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (u >= max_compact) + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Verify link information for new link */ - if(link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) + TEST_ERROR } /* end for */ /* Check for out of bound deletion again */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Delete links from dense group, in appropriate order */ - for(u = 0; u < ((max_compact * 2) - 1); u++) { + for (u = 0; u < ((max_compact * 2) - 1); u++) { /* Delete first link in appropriate order */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(linfo.corder != (u + 1)) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (linfo.corder != (u + 1)) + TEST_ERROR } /* end if */ else { - if(linfo.corder != ((max_compact * 2) - (u + 2))) TEST_ERROR + if (linfo.corder != ((max_compact * 2) - (u + 2))) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", (u + 1)); else HDsnprintf(objname, sizeof(objname), "filler %02u", ((max_compact * 2) - (u + 2))); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group (empty) */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Check for deletion on empty group again */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Delete links in middle */ /* Create more links, to push group into dense form */ - for(u = 0; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < (max_compact * 2); u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Verify state of group (dense) */ - if(u >= max_compact) - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (u >= max_compact) + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Verify link information for new link */ - if(link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR + if (link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) + TEST_ERROR } /* end for */ /* Delete every other link from dense group, in appropriate order */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Delete link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for current link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", idx_type, order, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(linfo.corder != ((u * 2) + 1)) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", idx_type, order, (hsize_t)u, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (linfo.corder != ((u * 2) + 1)) + TEST_ERROR } /* end if */ else { - if(linfo.corder != ((max_compact * 2) - ((u * 2) + 2))) TEST_ERROR + if (linfo.corder != ((max_compact * 2) - ((u * 2) + 2))) + TEST_ERROR } /* end else */ /* Verify the name for current link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", ((u * 2) + 1)); else - HDsnprintf(objname, sizeof(objname), "filler %02u", ((max_compact * 2) - ((u * 2) + 2))); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + HDsnprintf(objname, sizeof(objname), "filler %02u", + ((max_compact * 2) - ((u * 2) + 2))); + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete remaining links from dense group, in appropriate order */ - for(u = 0; u < (max_compact - 1); u++) { + for (u = 0; u < (max_compact - 1); u++) { /* Delete link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(linfo.corder != ((u * 2) + 3)) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < + 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (linfo.corder != ((u * 2) + 3)) + TEST_ERROR } /* end if */ else { - if(linfo.corder != ((max_compact * 2) - ((u * 2) + 4))) TEST_ERROR + if (linfo.corder != ((max_compact * 2) - ((u * 2) + 4))) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", ((u * 2) + 3)); else - HDsnprintf(objname, sizeof(objname), "filler %02u", ((max_compact * 2) - ((u * 2) + 4))); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + HDsnprintf(objname, sizeof(objname), "filler %02u", + ((max_compact * 2) - ((u * 2) + 4))); + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group (empty) */ - if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(group_id) == TRUE) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end delete_by_idx() */ - /*------------------------------------------------------------------------- * Function: delete_by_idx_old * @@ -15299,211 +18935,266 @@ error: static int delete_by_idx_old(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1, group_id2 = -1; /* Group IDs */ - H5F_t *f = NULL; - H5L_info2_t linfo; /* Link info struct */ - H5_iter_order_t order; /* Order within in the index */ - void *vol_obj_file = NULL; /* Object of file_id */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - H5O_token_t objtoken[CORDER_NLINKS];/* Tokens (Addresses) of the objects created */ - char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ - unsigned u; /* Local index variable */ - int token_cmp; - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1, group_id2 = -1; /* Group IDs */ + H5F_t * f = NULL; + H5L_info2_t linfo; /* Link info struct */ + H5_iter_order_t order; /* Order within in the index */ + void * vol_obj_file = NULL; /* Object of file_id */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + H5O_token_t objtoken[CORDER_NLINKS]; /* Tokens (Addresses) of the objects created */ + char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ + unsigned u; /* Local index variable */ + int token_cmp; + herr_t ret; /* Generic return value */ /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { /* Print test banner */ - if(order == H5_ITER_INC) + if (order == H5_ITER_INC) TESTING("deleting links by index in increasing order in old-style group") else TESTING("deleting links by index in decreasing order in old-style group") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Need the file struct to address encoding */ /* Retrieve VOL object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) TEST_ERROR + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) + TEST_ERROR /* Retrieve file from VOL object */ - if(NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) TEST_ERROR + if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) + TEST_ERROR /* Create group to operate on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Delete links from one end */ /* Check for deletion in empty group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - H5O_info2_t oi; /* Buffer for querying object's info */ + for (u = 0; u < CORDER_NLINKS; u++) { + H5O_info2_t oi; /* Buffer for querying object's info */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create group */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's object token */ - if(H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&objtoken[u], &oi.token, sizeof(H5O_token_t)); /* Close group */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Check for bad index type deletion */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for out of bounds deletion */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Delete links, in appropriate order */ - for(u = 0; u < (CORDER_NLINKS - 1); u++) { - unsigned dec_u = CORDER_NLINKS - (u + 2); /* Decreasing mapped index */ + for (u = 0; u < (CORDER_NLINKS - 1); u++) { + unsigned dec_u = CORDER_NLINKS - (u + 2); /* Decreasing mapped index */ /* Delete first link in appropriate order */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[u + 1], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[u + 1], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end if */ else { - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[dec_u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[dec_u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", (u + 1)); else HDsnprintf(objname, sizeof(objname), "filler %02u", dec_u); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Check for deletion in empty group (again) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Delete links in middle */ /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - H5O_info2_t oi; /* Buffer for querying object's info */ + for (u = 0; u < CORDER_NLINKS; u++) { + H5O_info2_t oi; /* Buffer for querying object's info */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create group */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's object token */ - if(H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&objtoken[u], &oi.token, sizeof(H5O_token_t)); /* Close group */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Delete every other link from group, in appropriate order */ - for(u = 0; u < (CORDER_NLINKS / 2); u++) { - unsigned dec_u = CORDER_NLINKS - ((u * 2) + 2); /* Decreasing mapped index */ + for (u = 0; u < (CORDER_NLINKS / 2); u++) { + unsigned dec_u = CORDER_NLINKS - ((u * 2) + 2); /* Decreasing mapped index */ /* Delete link */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for current link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[(u * 2) + 1], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[(u * 2) + 1], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end if */ else { - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[dec_u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[dec_u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end else */ /* Verify the name for current link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", ((u * 2) + 1)); else HDsnprintf(objname, sizeof(objname), "filler %02u", dec_u); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete remaining links from group, in appropriate order */ - for(u = 0; u < ((CORDER_NLINKS / 2) - 1); u++) { - unsigned dec_u = CORDER_NLINKS - ((u * 2) + 4); /* Decreasing mapped index */ + for (u = 0; u < ((CORDER_NLINKS / 2) - 1); u++) { + unsigned dec_u = CORDER_NLINKS - ((u * 2) + 4); /* Decreasing mapped index */ /* Delete link */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify the link information for first link in appropriate order */ HDmemset(&linfo, 0, sizeof(linfo)); - if(H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) { - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[(u * 2) + 3], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (H5Lget_info_by_idx2(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) { + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[(u * 2) + 3], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end if */ else { - if(H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[dec_u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (H5Otoken_cmp(group_id, &linfo.u.token, &objtoken[dec_u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end else */ /* Verify the name for first link in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - if(H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(order == H5_ITER_INC) + if (H5Lget_name_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (order == H5_ITER_INC) HDsnprintf(objname, sizeof(objname), "filler %02u", ((u * 2) + 3)); else HDsnprintf(objname, sizeof(objname), "filler %02u", dec_u); - if(HDstrcmp(objname, tmpname)) TEST_ERROR + if (HDstrcmp(objname, tmpname)) + TEST_ERROR } /* end for */ /* Delete last link */ - if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify state of group */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ @@ -15511,15 +19202,16 @@ delete_by_idx_old(hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end delete_by_idx_old() */ - /*------------------------------------------------------------------------- * Function: link_iterate_cb * @@ -15530,66 +19222,65 @@ error: *------------------------------------------------------------------------- */ static int -link_iterate_cb(hid_t group_id, const char *link_name, const H5L_info2_t *info, - void *_op_data) +link_iterate_cb(hid_t group_id, const char *link_name, const H5L_info2_t *info, void *_op_data) { - link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ - char objname[NAME_BUF_SIZE]; /* Object name */ - H5L_info2_t my_info; /* Local link info */ + link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ + char objname[NAME_BUF_SIZE]; /* Object name */ + H5L_info2_t my_info; /* Local link info */ /* Increment # of times the callback was called */ op_data->ncalled++; /* Get the link information directly to compare */ - if(H5Lget_info2(group_id, link_name, &my_info, H5P_DEFAULT) < 0) + if (H5Lget_info2(group_id, link_name, &my_info, H5P_DEFAULT) < 0) return H5_ITER_ERROR; /* Check more things for link iteration (vs. group iteration) */ - if(info) { + if (info) { int token_cmp; /* Check for correct order of iteration */ /* (if we are operating in increasing or decreasing order) */ - if(op_data->order != H5_ITER_NATIVE) - if(info->corder != op_data->curr) + if (op_data->order != H5_ITER_NATIVE) + if (info->corder != op_data->curr) return H5_ITER_ERROR; /* Compare link info structs */ - if(info->type != my_info.type) + if (info->type != my_info.type) return H5_ITER_ERROR; - if(info->corder_valid != my_info.corder_valid) + if (info->corder_valid != my_info.corder_valid) return H5_ITER_ERROR; - if(info->corder != my_info.corder) + if (info->corder != my_info.corder) return H5_ITER_ERROR; - if(info->cset != my_info.cset) + if (info->cset != my_info.cset) return H5_ITER_ERROR; - if(H5Otoken_cmp(group_id, &info->u.token, &my_info.u.token, &token_cmp) < 0) + if (H5Otoken_cmp(group_id, &info->u.token, &my_info.u.token, &token_cmp) < 0) return H5_ITER_ERROR; - if(token_cmp) + if (token_cmp) return H5_ITER_ERROR; } /* end if */ /* Verify name of link */ HDsnprintf(objname, sizeof(objname), "filler %02u", (unsigned)my_info.corder); - if(HDstrcmp(link_name, objname)) + if (HDstrcmp(link_name, objname)) return H5_ITER_ERROR; /* Check if we've visited this link before */ - if((size_t)op_data->curr >= op_data->max_visit) + if ((size_t)op_data->curr >= op_data->max_visit) return H5_ITER_ERROR; - if(op_data->visited[op_data->curr]) + if (op_data->visited[op_data->curr]) return H5_ITER_ERROR; op_data->visited[op_data->curr] = TRUE; /* Advance to next value, in correct direction */ - if(op_data->order != H5_ITER_DEC) + if (op_data->order != H5_ITER_DEC) op_data->curr++; else op_data->curr--; /* Check for stopping in the middle of iterating */ - if(op_data->stop > 0) - if(--op_data->stop == 0) + if (op_data->stop > 0) + if (--op_data->stop == 0) return CORDER_ITER_STOP; return H5_ITER_CONT; @@ -15614,7 +19305,6 @@ group_iterate_cb(hid_t group_id, const char *link_name, void *_op_data) } /* end group_iterate_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: link_iterate_fail_cb * @@ -15627,12 +19317,11 @@ group_iterate_cb(hid_t group_id, const char *link_name, void *_op_data) */ static int link_iterate_fail_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *link_name, - const H5L_info2_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) + const H5L_info2_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) { return H5_ITER_ERROR; } /* end link_iterate_fail_cb() */ - /*------------------------------------------------------------------------- * Function: link_iterate_check * @@ -15643,138 +19332,163 @@ link_iterate_fail_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *l *------------------------------------------------------------------------- */ static int -link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, - unsigned max_links, link_iter_info_t *iter_info) +link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, unsigned max_links, + link_iter_info_t *iter_info) { - unsigned v; /* Local index variable */ - hsize_t skip; /* # of links to skip in group */ + unsigned v; /* Local index variable */ + hsize_t skip; /* # of links to skip in group */ #ifndef H5_NO_DEPRECATED_SYMBOLS - int gskip; /* # of links to skip in group, with H5Giterate */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - herr_t ret; /* Generic return value */ + int gskip; /* # of links to skip in group, with H5Giterate */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + herr_t ret; /* Generic return value */ /* Iterate over links in group */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Literate2(group_id, idx_type, order, &skip, link_iterate_cb, iter_info) < 0) TEST_ERROR + if (H5Literate2(group_id, idx_type, order, &skip, link_iterate_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(skip != max_links) TEST_ERROR - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + if (skip != max_links) + TEST_ERROR + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info) < 0) TEST_ERROR + if (H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(gskip != (int)max_links) TEST_ERROR - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + if (gskip != (int)max_links) + TEST_ERROR + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Skip over some links in group */ iter_info->nskipped = (unsigned)(skip = max_links / 2); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Literate2(group_id, idx_type, order, &skip, link_iterate_cb, iter_info) < 0) TEST_ERROR + if (H5Literate2(group_id, idx_type, order, &skip, link_iterate_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(skip != max_links) TEST_ERROR - if(order == H5_ITER_INC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v + (max_links / 2)] == FALSE) TEST_ERROR + if (skip != max_links) + TEST_ERROR + if (order == H5_ITER_INC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v + (max_links / 2)] == FALSE) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == TRUE) nvisit++; - if(nvisit != (max_links / 2)) TEST_ERROR + if (nvisit != (max_links / 2)) + TEST_ERROR } /* end else */ #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info) < 0) TEST_ERROR + if (H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(gskip != (int)max_links) TEST_ERROR - if(order == H5_ITER_INC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v + (max_links / 2)] == FALSE) TEST_ERROR + if (gskip != (int)max_links) + TEST_ERROR + if (order == H5_ITER_INC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v + (max_links / 2)] == FALSE) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == TRUE) nvisit++; - if(nvisit != (max_links / 2)) TEST_ERROR - } /* end else */ + if (nvisit != (max_links / 2)) + TEST_ERROR + } /* end else */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Iterate over links in group, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if((ret = H5Literate2(group_id, idx_type, order, &skip, link_iterate_cb, iter_info)) < 0) TEST_ERROR - if(ret != CORDER_ITER_STOP) TEST_ERROR - if(iter_info->ncalled != 3) TEST_ERROR + if ((ret = H5Literate2(group_id, idx_type, order, &skip, link_iterate_cb, iter_info)) < 0) + TEST_ERROR + if (ret != CORDER_ITER_STOP) + TEST_ERROR + if (iter_info->ncalled != 3) + TEST_ERROR #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ iter_info->nskipped = (unsigned)(gskip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if((ret = H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info)) < 0) TEST_ERROR - if(ret != CORDER_ITER_STOP) TEST_ERROR - if(iter_info->ncalled != 3) TEST_ERROR + if ((ret = H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info)) < 0) + TEST_ERROR + if (ret != CORDER_ITER_STOP) + TEST_ERROR + if (iter_info->ncalled != 3) + TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Check for iteration routine indicating failure */ skip = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2(group_id, idx_type, order, &skip, link_iterate_fail_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Success */ return SUCCEED; @@ -15783,7 +19497,6 @@ error: return FAIL; } /* end link_iterate_check() */ - /*------------------------------------------------------------------------- * Function: link_iterate * @@ -15801,183 +19514,224 @@ error: static int link_iterate(hid_t fapl) { - hid_t file_id = (-1); /* File ID */ - hid_t group_id = (-1); /* Group ID */ - hid_t gcpl_id = (-1); /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - link_iter_info_t iter_info; /* Iterator info */ - hbool_t *visited = NULL; /* Array of flags for visiting links */ - hsize_t skip; /* # of links to skip in group */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + link_iter_info_t iter_info; /* Iterator info */ + hbool_t * visited = NULL; /* Array of flags for visiting links */ + hsize_t skip; /* # of links to skip in group */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Allocate the "visited link" array */ iter_info.max_visit = max_compact * 2; - if(NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) TEST_ERROR + if (NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) + TEST_ERROR iter_info.visited = visited; /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("iterating over links by creation order index in increasing order w/creation order index") + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + TESTING("iterating over links by creation order index in increasing order " + "w/creation order index") else - TESTING("iterating over links by creation order index in increasing order w/o creation order index") + TESTING("iterating over links by creation order index in increasing order w/o " + "creation order index") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("iterating over links by creation order index in decreasing order w/creation order index") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING("iterating over links by creation order index in decreasing order " + "w/creation order index") else - TESTING("iterating over links by creation order index in decreasing order w/o creation order index") + TESTING("iterating over links by creation order index in decreasing order w/o " + "creation order index") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) - TESTING("iterating over links by creation order index in native order w/creation order index") + if (use_index) + TESTING("iterating over links by creation order index in native order w/creation " + "order index") else - TESTING("iterating over links by creation order index in native order w/o creation order index") + TESTING("iterating over links by creation order index in native order w/o " + "creation order index") } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("iterating over links by name index in increasing order w/creation order index") + if (order == H5_ITER_INC) { + if (use_index) + TESTING("iterating over links by name index in increasing order w/creation order " + "index") else - TESTING("iterating over links by name index in increasing order w/o creation order index") + TESTING("iterating over links by name index in increasing order w/o creation " + "order index") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("iterating over links by name index in decreasing order w/creation order index") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING("iterating over links by name index in decreasing order w/creation order " + "index") else - TESTING("iterating over links by name index in decreasing order w/o creation order index") + TESTING("iterating over links by name index in decreasing order w/o creation " + "order index") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) - TESTING("iterating over links by name index in native order w/creation order index") + if (use_index) + TESTING( + "iterating over links by name index in native order w/creation order index") else - TESTING("iterating over links by name index in native order w/o creation order index") + TESTING( + "iterating over links by name index in native order w/o creation order index") } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | + (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < + 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Check for iteration on empty group */ /* (should be OK) */ - if(H5Literate2(group_id, idx_type, order, NULL, link_iterate_cb, NULL) < 0) TEST_ERROR + if (H5Literate2(group_id, idx_type, order, NULL, link_iterate_cb, NULL) < 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < max_compact; u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (compact) */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound iteration on compact group */ skip = (hsize_t)u; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2(group_id, idx_type, order, &skip, link_iterate_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Test iteration over links in compact group */ - if(link_iterate_check(group_id, idx_type, order, u, &iter_info) < 0) TEST_ERROR + if (link_iterate_check(group_id, idx_type, order, u, &iter_info) < 0) + TEST_ERROR /* Create more links, to push group into dense form */ - for(; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + for (; u < (max_compact * 2); u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (dense) */ - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound iteration on dense group */ skip = (hsize_t)u; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2(group_id, idx_type, order, &skip, link_iterate_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Test iteration over links in dense group */ - if(link_iterate_check(group_id, idx_type, order, u, &iter_info) < 0) TEST_ERROR - + if (link_iterate_check(group_id, idx_type, order, u, &iter_info) < 0) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Free resources */ - if(visited) + if (visited) HDfree(visited); return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; - if(visited) + if (visited) HDfree(visited); return FAIL; } /* end link_iterate() */ - /*------------------------------------------------------------------------- * Function: link_iterate_old_cb * @@ -15990,57 +19744,58 @@ error: static int link_iterate_old_cb(hid_t group_id, const char *link_name, const H5L_info2_t *info, void *_op_data) { - link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ - char objname[NAME_BUF_SIZE]; /* Object name */ - H5L_info2_t my_info; /* Local link info */ + link_iter_info_t *op_data = (link_iter_info_t *)_op_data; /* User data */ + char objname[NAME_BUF_SIZE]; /* Object name */ + H5L_info2_t my_info; /* Local link info */ /* Increment # of times the callback was called */ op_data->ncalled++; /* Get the link information directly to compare */ - if(H5Lget_info2(group_id, link_name, &my_info, H5P_DEFAULT) < 0) + if (H5Lget_info2(group_id, link_name, &my_info, H5P_DEFAULT) < 0) return H5_ITER_ERROR; /* Check more things for link iteration (vs. group iteration) */ - if(info) { + if (info) { int token_cmp; /* Compare link info structs */ - if(info->type != my_info.type) + if (info->type != my_info.type) return H5_ITER_ERROR; - if(info->corder_valid != my_info.corder_valid) + if (info->corder_valid != my_info.corder_valid) return H5_ITER_ERROR; - if(info->corder != my_info.corder) + if (info->corder != my_info.corder) return H5_ITER_ERROR; - if(info->cset != my_info.cset) + if (info->cset != my_info.cset) return H5_ITER_ERROR; - if(H5Otoken_cmp(group_id, &info->u.token, &my_info.u.token, &token_cmp) < 0) + if (H5Otoken_cmp(group_id, &info->u.token, &my_info.u.token, &token_cmp) < 0) return H5_ITER_ERROR; - if(token_cmp) + if (token_cmp) return H5_ITER_ERROR; } /* end if */ /* Verify name of link */ - HDsnprintf(objname, sizeof(objname), "filler %02u", (info ? (unsigned)op_data->curr : (unsigned)((op_data->ncalled - 1) + op_data->nskipped))); - if(HDstrcmp(link_name, objname)) + HDsnprintf(objname, sizeof(objname), "filler %02u", + (info ? (unsigned)op_data->curr : (unsigned)((op_data->ncalled - 1) + op_data->nskipped))); + if (HDstrcmp(link_name, objname)) return H5_ITER_ERROR; /* Check if we've visited this link before */ - if((size_t)op_data->curr >= op_data->max_visit) + if ((size_t)op_data->curr >= op_data->max_visit) return H5_ITER_ERROR; - if(op_data->visited[op_data->curr]) + if (op_data->visited[op_data->curr]) return H5_ITER_ERROR; op_data->visited[op_data->curr] = TRUE; /* Advance to next value, in correct direction */ - if(op_data->order != H5_ITER_DEC) + if (op_data->order != H5_ITER_DEC) op_data->curr++; else op_data->curr--; /* Check for stopping in the middle of iterating */ - if(op_data->stop > 0) - if(--op_data->stop == 0) + if (op_data->stop > 0) + if (--op_data->stop == 0) return CORDER_ITER_STOP; return H5_ITER_CONT; @@ -16065,7 +19820,6 @@ group_iterate_old_cb(hid_t group_id, const char *link_name, void *_op_data) } /* end group_iterate_old_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: link_iterate_old_check * @@ -16078,148 +19832,179 @@ group_iterate_old_cb(hid_t group_id, const char *link_name, void *_op_data) static int link_iterate_old_check(hid_t group_id, H5_iter_order_t order, unsigned max_links, link_iter_info_t *iter_info) { - unsigned v; /* Local index variable */ - hsize_t skip; /* # of links to skip in group */ + unsigned v; /* Local index variable */ + hsize_t skip; /* # of links to skip in group */ #ifndef H5_NO_DEPRECATED_SYMBOLS - int gskip; /* # of links to skip in group, with H5Giterate */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - herr_t ret; /* Generic return value */ + int gskip; /* # of links to skip in group, with H5Giterate */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + herr_t ret; /* Generic return value */ /* Iterate over links in group */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Literate2(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info) < 0) TEST_ERROR + if (H5Literate2(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(skip != max_links) TEST_ERROR - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + if (skip != max_links) + TEST_ERROR + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info) < 0) TEST_ERROR + if (H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(gskip != (int)max_links) TEST_ERROR - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + if (gskip != (int)max_links) + TEST_ERROR + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Skip over some links in group */ iter_info->nskipped = (unsigned)(skip = max_links / 2); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Literate2(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info) < 0) TEST_ERROR + if (H5Literate2(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(skip != max_links) TEST_ERROR - if(order == H5_ITER_INC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v + (max_links / 2)] == FALSE) TEST_ERROR + if (skip != max_links) + TEST_ERROR + if (order == H5_ITER_INC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v + (max_links / 2)] == FALSE) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == TRUE) nvisit++; - if(nvisit != (max_links / 2)) TEST_ERROR + if (nvisit != (max_links / 2)) + TEST_ERROR } /* end else */ #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if(H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info) < 0) TEST_ERROR + if (H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info) < 0) + TEST_ERROR /* Verify that we visited all the links */ - if(gskip != (int)max_links) TEST_ERROR - if(order == H5_ITER_INC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v + (max_links / 2)] == FALSE) TEST_ERROR + if (gskip != (int)max_links) + TEST_ERROR + if (order == H5_ITER_INC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v + (max_links / 2)] == FALSE) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_links / 2); v++) - if(iter_info->visited[v] == FALSE) TEST_ERROR + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_links / 2); v++) + if (iter_info->visited[v] == FALSE) + TEST_ERROR } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_links; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_links; v++) + if (iter_info->visited[v] == TRUE) nvisit++; - if(nvisit != (max_links / 2)) TEST_ERROR - } /* end else */ + if (nvisit != (max_links / 2)) + TEST_ERROR + } /* end else */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Iterate over links in group, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if((ret = H5Literate2(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info)) < 0) TEST_ERROR - if(ret != CORDER_ITER_STOP) TEST_ERROR - if(iter_info->ncalled != 3) TEST_ERROR + if ((ret = H5Literate2(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info)) < 0) + TEST_ERROR + if (ret != CORDER_ITER_STOP) + TEST_ERROR + if (iter_info->ncalled != 3) + TEST_ERROR #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ iter_info->nskipped = (unsigned)(gskip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_links - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - if((ret = H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info)) < 0) TEST_ERROR - if(ret != CORDER_ITER_STOP) TEST_ERROR - if(iter_info->ncalled != 3) TEST_ERROR + if ((ret = H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info)) < 0) + TEST_ERROR + if (ret != CORDER_ITER_STOP) + TEST_ERROR + if (iter_info->ncalled != 3) + TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Check for iteration routine indicating failure */ skip = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2(group_id, H5_INDEX_NAME, order, &skip, link_iterate_fail_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for iteration w/bad location ID */ skip = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2((hid_t)(-1), H5_INDEX_NAME, order, &skip, link_iterate_fail_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR #ifndef H5_NO_DEPRECATED_SYMBOLS - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Giterate((hid_t)(-1), ".", &gskip, group_iterate_old_cb, iter_info); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Success */ @@ -16229,7 +20014,6 @@ error: return FAIL; } /* end link_iterate_old_check() */ - /*------------------------------------------------------------------------- * Function: link_iterate_old * @@ -16242,29 +20026,30 @@ error: static int link_iterate_old(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - H5_iter_order_t order; /* Order within in the index */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE];/* File name */ - link_iter_info_t iter_info; /* Iterator info */ - hbool_t *visited = NULL; /* Array of flags for visiting links */ - hsize_t skip; /* # of links to skip in group */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + H5_iter_order_t order; /* Order within in the index */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; /* File name */ + link_iter_info_t iter_info; /* Iterator info */ + hbool_t * visited = NULL; /* Array of flags for visiting links */ + hsize_t skip; /* # of links to skip in group */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Allocate the "visited link" array */ iter_info.max_visit = CORDER_NLINKS; - if(NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) TEST_ERROR + if (NULL == (visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit))) + TEST_ERROR iter_info.visited = visited; /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Print appropriate test message */ - if(order == H5_ITER_INC) { + if (order == H5_ITER_INC) { TESTING("iterating over links by name index in increasing order in old-style group") } /* end if */ - else if(order == H5_ITER_DEC) { + else if (order == H5_ITER_DEC) { TESTING("iterating over links by name index in decreasing order in old-style group") } /* end else */ else { @@ -16274,77 +20059,93 @@ link_iterate_old(hid_t fapl) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check for iteration on empty group */ /* (should be OK) */ - if(H5Literate2(group_id, H5_INDEX_NAME, order, NULL, link_iterate_old_cb, NULL) < 0) TEST_ERROR + if (H5Literate2(group_id, H5_INDEX_NAME, order, NULL, link_iterate_old_cb, NULL) < 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < CORDER_NLINKS; u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (symbol table) */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound iteration on old-style group */ skip = (hsize_t)u; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for iteration on creation order */ /* (should fail) */ skip = (hsize_t)0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2(group_id, H5_INDEX_CRT_ORDER, order, &skip, link_iterate_old_cb, NULL); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Test iteration over links in group */ - if(link_iterate_old_check(group_id, order, u, &iter_info) < 0) TEST_ERROR + if (link_iterate_old_check(group_id, order, u, &iter_info) < 0) + TEST_ERROR /* Close the group */ - if(H5Gclose(group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ /* Free resources */ - if(visited) + if (visited) HDfree(visited); return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; - if(visited) + if (visited) HDfree(visited); return FAIL; } /* end link_iterate_old() */ - /*------------------------------------------------------------------------- * Function: open_by_idx_check * @@ -16355,83 +20156,100 @@ error: *------------------------------------------------------------------------- */ static int -open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, - H5_index_t idx_type, H5_iter_order_t order, unsigned max_links, H5O_token_t *objno) +open_by_idx_check(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, H5_index_t idx_type, + H5_iter_order_t order, unsigned max_links, H5O_token_t *objno) { char mntname[NAME_BUF_SIZE]; /* Link value */ - hid_t group_id = -1; /* ID of group to test */ - H5O_info2_t oi; /* Buffer for querying object's info */ - H5O_token_t mnt_root_token; /* Token (address) of root group in file to mount */ - hid_t obj_id; /* ID of object opened */ - unsigned mnt_idx; /* Index to mount group on */ - unsigned u, v; /* Local index variables */ + hid_t group_id = -1; /* ID of group to test */ + H5O_info2_t oi; /* Buffer for querying object's info */ + H5O_token_t mnt_root_token; /* Token (address) of root group in file to mount */ + hid_t obj_id; /* ID of object opened */ + unsigned mnt_idx; /* Index to mount group on */ + unsigned u, v; /* Local index variables */ int token_cmp; /* Work through main & soft link groups */ - for(v = 0; v < 2; v++) { + for (v = 0; v < 2; v++) { /* Choose appropriate group to open links within */ - if(0 == v) + if (0 == v) group_id = main_group_id; else group_id = soft_group_id; /* Open each object in main group by index and check that it's the correct one */ - for(u = 0; u < max_links; u++) { + for (u = 0; u < max_links; u++) { /* Open the object */ - if((obj_id = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT)) < 0) TEST_ERROR + if ((obj_id = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT)) < 0) + TEST_ERROR /* Get the object's information */ - if(H5Oget_info3(obj_id, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(obj_id, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR /* Check that the object is the correct one */ - if(order == H5_ITER_INC) { - if(H5Otoken_cmp(obj_id, &oi.token, &objno[u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (order == H5_ITER_INC) { + if (H5Otoken_cmp(obj_id, &oi.token, &objno[u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ + else if (order == H5_ITER_DEC) { + unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ - if(H5Otoken_cmp(obj_id, &oi.token, &objno[dec_u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR + if (H5Otoken_cmp(obj_id, &oi.token, &objno[dec_u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR } /* end if */ else { /* XXX: What to do about native order? */ } /* end else */ /* Close object */ - if(H5Oclose(obj_id) < 0) TEST_ERROR + if (H5Oclose(obj_id) < 0) + TEST_ERROR } /* end for */ - } /* end for */ + } /* end for */ /* Verify opening correct object by index when file mounting is present */ /* Get the address of the root group in the file to mount */ - if(H5Oget_info3(mount_file_id, &oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(mount_file_id, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR HDmemcpy(&mnt_root_token, &oi.token, sizeof(mnt_root_token)); /* Mount a file over a group in main group */ mnt_idx = 2; HDsnprintf(mntname, sizeof(mntname), "/%s/filler %02u", CORDER_GROUP_NAME, mnt_idx); - if(H5Fmount(main_group_id, mntname, mount_file_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(main_group_id, mntname, mount_file_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the object that the file is mounted on */ - if((obj_id = H5Oopen_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)mnt_idx, H5P_DEFAULT)) < 0) TEST_ERROR + if ((obj_id = H5Oopen_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)mnt_idx, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Get the object's information */ - if(H5Oget_info3(obj_id, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(obj_id, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR /* Check that the object is the root of the mounted file and not in the previous file */ - if(H5Otoken_cmp(obj_id, &oi.token, &mnt_root_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Otoken_cmp(obj_id, &oi.token, &objno[mnt_idx], &token_cmp) < 0) TEST_ERROR - if(!token_cmp) TEST_ERROR + if (H5Otoken_cmp(obj_id, &oi.token, &mnt_root_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Otoken_cmp(obj_id, &oi.token, &objno[mnt_idx], &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) + TEST_ERROR /* Close object */ - if(H5Oclose(obj_id) < 0) TEST_ERROR + if (H5Oclose(obj_id) < 0) + TEST_ERROR /* Unmount the file */ - if(H5Funmount(main_group_id, mntname) < 0) TEST_ERROR + if (H5Funmount(main_group_id, mntname) < 0) + TEST_ERROR /* Success */ return SUCCEED; @@ -16440,7 +20258,6 @@ error: return FAIL; } /* end open_by_idx_check() */ - /*------------------------------------------------------------------------- * Function: open_by_idx * @@ -16454,215 +20271,262 @@ error: static int open_by_idx(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t mount_file_id = -1; /* File ID for file to mount */ - hid_t group_id = -1; /* Group ID */ - hid_t soft_group_id = -1; /* Group ID for soft links */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - H5O_info2_t oi; /* Buffer for querying object's info */ - char filename[NAME_BUF_SIZE];/* File name */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char valname[2 * NAME_BUF_SIZE]; /* Link value */ - H5O_token_t *objno = NULL; /* Tokens (addresses) of the objects created */ - unsigned u; /* Local index variable */ - hid_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t mount_file_id = -1; /* File ID for file to mount */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5O_info2_t oi; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE]; /* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char valname[2 * NAME_BUF_SIZE]; /* Link value */ + H5O_token_t * objno = NULL; /* Tokens (addresses) of the objects created */ + unsigned u; /* Local index variable */ + hid_t ret; /* Generic return value */ /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Allocate object token array */ - if(NULL == (objno = (H5O_token_t *)HDmalloc(sizeof(H5O_token_t) * (max_compact * 2)))) TEST_ERROR + if (NULL == (objno = (H5O_token_t *)HDmalloc(sizeof(H5O_token_t) * (max_compact * 2)))) + TEST_ERROR /* Create file to mount */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((mount_file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((mount_file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("open object by creation order index in increasing order w/creation order index") + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + TESTING("open object by creation order index in increasing order w/creation " + "order index") else - TESTING("open object by creation order index in increasing order w/o creation order index") + TESTING("open object by creation order index in increasing order w/o creation " + "order index") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("open object by creation order index in decreasing order w/creation order index") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING("open object by creation order index in decreasing order w/creation " + "order index") else - TESTING("open object by creation order index in decreasing order w/o creation order index") + TESTING("open object by creation order index in decreasing order w/o creation " + "order index") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) - TESTING("open object by creation order index in native order w/creation order index") + if (use_index) + TESTING( + "open object by creation order index in native order w/creation order index") else - TESTING("open object by creation order index in native order w/o creation order index") + TESTING("open object by creation order index in native order w/o creation order " + "index") } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) + if (order == H5_ITER_INC) { + if (use_index) TESTING("open object by name index in increasing order w/creation order index") else TESTING("open object by name index in increasing order w/o creation order index") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) + else if (order == H5_ITER_DEC) { + if (use_index) TESTING("open object by name index in decreasing order w/creation order index") else TESTING("open object by name index in decreasing order w/o creation order index") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) + if (use_index) TESTING("open object by name index in native order w/creation order index") else TESTING("open object by name index in native order w/o creation order index") } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | + (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < + 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Create group with creation order tracking on for soft links */ - if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((soft_group_id = + H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Try to open on object in an empty group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < max_compact; u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oi.token; /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* Verify state of group (compact) */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound open by index on compact group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Verify opening objects by index */ - if(open_by_idx_check(group_id, soft_group_id, mount_file_id, idx_type, order, u, objno) < 0) TEST_ERROR + if (open_by_idx_check(group_id, soft_group_id, mount_file_id, idx_type, order, u, objno) < 0) + TEST_ERROR /* Create more links, to push group into dense form */ - for(; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ + for (; u < (max_compact * 2); u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oi.token; /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (dense) */ - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound open by index on compact group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Verify opening objects by index */ - if(open_by_idx_check(group_id, soft_group_id, mount_file_id, idx_type, order, u, objno) < 0) TEST_ERROR + if (open_by_idx_check(group_id, soft_group_id, mount_file_id, idx_type, order, u, objno) < 0) + TEST_ERROR /* Close the groups */ - if(H5Gclose(group_id) < 0) TEST_ERROR - if(H5Gclose(soft_group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR + if (H5Gclose(soft_group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the file for mounting */ - if(H5Fclose(mount_file_id) < 0) TEST_ERROR + if (H5Fclose(mount_file_id) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Free resources */ - if(objno) + if (objno) HDfree(objno); return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Gclose(soft_group_id); H5Fclose(file_id); H5Fclose(mount_file_id); - } H5E_END_TRY; + } + H5E_END_TRY; - if(objno) + if (objno) HDfree(objno); return FAIL; } /* end open_by_idx() */ - /*------------------------------------------------------------------------- * Function: open_by_idx_check_old * @@ -16673,82 +20537,100 @@ error: *------------------------------------------------------------------------- */ static int -open_by_idx_check_old(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, - H5_index_t idx_type, H5_iter_order_t order, unsigned max_links, H5O_token_t *objno) +open_by_idx_check_old(hid_t main_group_id, hid_t soft_group_id, hid_t mount_file_id, H5_index_t idx_type, + H5_iter_order_t order, unsigned max_links, H5O_token_t *objno) { char mntname[NAME_BUF_SIZE]; /* Link value */ - hid_t group_id = -1; /* ID of group to test */ - H5O_info2_t oi; /* Buffer for querying object's info */ - H5O_token_t mnt_root_token; /* Token of root group in file to mount */ - hid_t obj_id; /* ID of object opened */ - unsigned mnt_idx; /* Index to mount group on */ - unsigned u, v; /* Local index variables */ - int cmp_value; /* Token comparison value */ + hid_t group_id = -1; /* ID of group to test */ + H5O_info2_t oi; /* Buffer for querying object's info */ + H5O_token_t mnt_root_token; /* Token of root group in file to mount */ + hid_t obj_id; /* ID of object opened */ + unsigned mnt_idx; /* Index to mount group on */ + unsigned u, v; /* Local index variables */ + int cmp_value; /* Token comparison value */ /* Work through main & soft link groups */ - for(v = 0; v < 2; v++) { + for (v = 0; v < 2; v++) { /* Choose appropriate group to open links within */ - if(0 == v) + if (0 == v) group_id = main_group_id; else group_id = soft_group_id; /* Open each object in main group by index and check that it's the correct one */ - for(u = 0; u < max_links; u++) { + for (u = 0; u < max_links; u++) { /* Open the object */ - if((obj_id = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT)) < 0) TEST_ERROR + if ((obj_id = H5Oopen_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT)) < 0) + TEST_ERROR /* Get the object's information */ - if(H5Oget_info3(obj_id, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(obj_id, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR /* Check that the object is the correct one */ - if(order == H5_ITER_INC) { - if(H5Otoken_cmp(group_id, &oi.token, &objno[u], &cmp_value) < 0) TEST_ERROR - if(0 != cmp_value) TEST_ERROR + if (order == H5_ITER_INC) { + if (H5Otoken_cmp(group_id, &oi.token, &objno[u], &cmp_value) < 0) + TEST_ERROR + if (0 != cmp_value) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ + else if (order == H5_ITER_DEC) { + unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ - if(H5Otoken_cmp(group_id, &oi.token, &objno[dec_u], &cmp_value) < 0) TEST_ERROR - if(0 != cmp_value) TEST_ERROR + if (H5Otoken_cmp(group_id, &oi.token, &objno[dec_u], &cmp_value) < 0) + TEST_ERROR + if (0 != cmp_value) + TEST_ERROR } /* end if */ else { /* XXX: What to do about native order? */ } /* end else */ /* Close object */ - if(H5Oclose(obj_id) < 0) TEST_ERROR + if (H5Oclose(obj_id) < 0) + TEST_ERROR } /* end for */ - } /* end for */ + } /* end for */ /* Verify opening correct object by index when file mounting is present */ /* Get the address of the root group in the file to mount */ - if(H5Oget_info3(mount_file_id, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(mount_file_id, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR mnt_root_token = oi.token; /* Mount a file over a group in main group */ mnt_idx = 2; HDsnprintf(mntname, sizeof(mntname), "/%s/filler %02u", CORDER_GROUP_NAME, mnt_idx); - if(H5Fmount(main_group_id, mntname, mount_file_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fmount(main_group_id, mntname, mount_file_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the object that the file is mounted on */ - if((obj_id = H5Oopen_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)mnt_idx, H5P_DEFAULT)) < 0) TEST_ERROR + if ((obj_id = H5Oopen_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)mnt_idx, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Get the object's information */ - if(H5Oget_info3(obj_id, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(obj_id, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR /* Check that the object is the root of the mounted file and not in the previous file */ - if(H5Otoken_cmp(group_id, &oi.token, &mnt_root_token, &cmp_value) < 0) TEST_ERROR - if(0 != cmp_value) TEST_ERROR - if(H5Otoken_cmp(group_id, &oi.token, &objno[mnt_idx], &cmp_value) < 0) TEST_ERROR - if(0 == cmp_value) TEST_ERROR + if (H5Otoken_cmp(group_id, &oi.token, &mnt_root_token, &cmp_value) < 0) + TEST_ERROR + if (0 != cmp_value) + TEST_ERROR + if (H5Otoken_cmp(group_id, &oi.token, &objno[mnt_idx], &cmp_value) < 0) + TEST_ERROR + if (0 == cmp_value) + TEST_ERROR /* Close object */ - if(H5Oclose(obj_id) < 0) TEST_ERROR + if (H5Oclose(obj_id) < 0) + TEST_ERROR /* Unmount the file */ - if(H5Funmount(main_group_id, mntname) < 0) TEST_ERROR + if (H5Funmount(main_group_id, mntname) < 0) + TEST_ERROR /* Success */ return SUCCEED; @@ -16770,30 +20652,31 @@ error: static int open_by_idx_old(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t mount_file_id = -1; /* File ID for file to mount */ - hid_t group_id = -1; /* Group ID */ - hid_t soft_group_id = -1; /* Group ID for soft links */ - H5_iter_order_t order; /* Order within in the index */ - H5O_info2_t oi; /* Buffer for querying object's info */ - char filename[NAME_BUF_SIZE];/* File name */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char valname[2 * NAME_BUF_SIZE]; /* Link value */ - H5O_token_t objno[CORDER_NLINKS]; /* Tokens for the objects created */ - unsigned u; /* Local index variable */ - hid_t ret; /* Generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t mount_file_id = -1; /* File ID for file to mount */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + H5_iter_order_t order; /* Order within in the index */ + H5O_info2_t oi; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE]; /* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char valname[2 * NAME_BUF_SIZE]; /* Link value */ + H5O_token_t objno[CORDER_NLINKS]; /* Tokens for the objects created */ + unsigned u; /* Local index variable */ + hid_t ret; /* Generic return value */ /* Create file to mount */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((mount_file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((mount_file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Print appropriate test message */ - if(order == H5_ITER_INC) { + if (order == H5_ITER_INC) { TESTING("open object by name index in increasing order in old-style group") } /* end if */ - else if(order == H5_ITER_DEC) { + else if (order == H5_ITER_DEC) { TESTING("open object by name index in decreasing order in old-style group") } /* end else */ else { @@ -16803,89 +20686,112 @@ open_by_idx_old(hid_t fapl) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create old-style group */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create old-style group for soft links */ - if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - + if ((soft_group_id = + H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Try to open on object in an empty group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oopen_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2; /* Group ID */ + for (u = 0; u < CORDER_NLINKS; u++) { + hid_t group_id2; /* Group ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oi, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oi.token; /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (symbol table) */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound open by index */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oopen_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for creation order index open */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oopen_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)(u - 1), H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Verify opening objects by index */ - if(open_by_idx_check_old(group_id, soft_group_id, mount_file_id, H5_INDEX_NAME, order, u, objno) < 0) TEST_ERROR + if (open_by_idx_check_old(group_id, soft_group_id, mount_file_id, H5_INDEX_NAME, order, u, objno) < 0) + TEST_ERROR /* Close the groups */ - if(H5Gclose(group_id) < 0) TEST_ERROR - if(H5Gclose(soft_group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR + if (H5Gclose(soft_group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ /* Close the file for mounting */ - if(H5Fclose(mount_file_id) < 0) TEST_ERROR + if (H5Fclose(mount_file_id) < 0) + TEST_ERROR return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Gclose(soft_group_id); H5Fclose(file_id); H5Fclose(mount_file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end open_by_idx_old() */ - /*------------------------------------------------------------------------- * Function: object_info_check * @@ -16896,58 +20802,71 @@ error: *------------------------------------------------------------------------- */ static int -object_info_check(hid_t main_group_id, hid_t soft_group_id, H5_index_t idx_type, - H5_iter_order_t order, unsigned max_links, H5O_token_t *objno) +object_info_check(hid_t main_group_id, hid_t soft_group_id, H5_index_t idx_type, H5_iter_order_t order, + unsigned max_links, H5O_token_t *objno) { char objname[NAME_BUF_SIZE]; /* Object name */ - hid_t group_id = -1; /* ID of group to test */ - H5O_info2_t oinfo; /* Buffer for querying object's info */ - unsigned u, v; /* Local index variables */ + hid_t group_id = -1; /* ID of group to test */ + H5O_info2_t oinfo; /* Buffer for querying object's info */ + unsigned u, v; /* Local index variables */ int token_cmp; /* Work through main & soft link groups */ - for(v = 0; v < 2; v++) { + for (v = 0; v < 2; v++) { /* Choose appropriate group to open links within */ - if(0 == v) + if (0 == v) group_id = main_group_id; else group_id = soft_group_id; /* Open each object in group by name and check that it's the correct one */ - for(u = 0; u < max_links; u++) { + for (u = 0; u < max_links; u++) { /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Query the object's information, by name */ - if(H5Oget_info_by_name3(group_id, objname, &oinfo, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_info_by_name3(group_id, objname, &oinfo, H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT) < 0) + TEST_ERROR /* Check that the object is the correct one */ - if(H5Otoken_cmp(group_id, &oinfo.token, &objno[u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(oinfo.num_attrs != u) TEST_ERROR + if (H5Otoken_cmp(group_id, &oinfo.token, &objno[u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (oinfo.num_attrs != u) + TEST_ERROR /* Query the object's information, by index */ - if(H5Oget_info_by_idx3(group_id, ".", idx_type, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_info_by_idx3(group_id, ".", idx_type, order, (hsize_t)u, &oinfo, + H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS, H5P_DEFAULT) < 0) + TEST_ERROR /* Check that the object is the correct one */ - if(order == H5_ITER_INC) { - if(H5Otoken_cmp(group_id, &oinfo.token, &objno[u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(oinfo.num_attrs != u) TEST_ERROR + if (order == H5_ITER_INC) { + if (H5Otoken_cmp(group_id, &oinfo.token, &objno[u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (oinfo.num_attrs != u) + TEST_ERROR } /* end if */ - else if(order == H5_ITER_DEC) { - unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ - - if(H5Otoken_cmp(group_id, &oinfo.token, &objno[dec_u], &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(oinfo.num_attrs != dec_u) TEST_ERROR + else if (order == H5_ITER_DEC) { + unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ + + if (H5Otoken_cmp(group_id, &oinfo.token, &objno[dec_u], &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (oinfo.num_attrs != dec_u) + TEST_ERROR } /* end if */ else { /* XXX: What to do about native order? */ } /* end else */ } /* end for */ - } /* end for */ + } /* end for */ /* Success */ return SUCCEED; @@ -16956,7 +20875,6 @@ error: return FAIL; } /* end object_info_check() */ - /*------------------------------------------------------------------------- * Function: object_info * @@ -16970,240 +20888,298 @@ error: static int object_info(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t soft_group_id = -1; /* Group ID for soft links */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - hid_t space_id = -1; /* Dataspace ID (for attributes) */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - H5O_info2_t oinfo; /* Buffer for querying object's info */ - char filename[NAME_BUF_SIZE];/* File name */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char valname[2 * NAME_BUF_SIZE]; /* Link value */ - char attrname[NAME_BUF_SIZE]; /* Attribute name */ - H5O_token_t *objno = NULL; /* Tokens (addresses) of the objects created */ - herr_t ret; /* Generic return value */ - unsigned u, v; /* Local index variables */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + hid_t space_id = -1; /* Dataspace ID (for attributes) */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5O_info2_t oinfo; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE]; /* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char valname[2 * NAME_BUF_SIZE]; /* Link value */ + char attrname[NAME_BUF_SIZE]; /* Attribute name */ + H5O_token_t * objno = NULL; /* Tokens (addresses) of the objects created */ + herr_t ret; /* Generic return value */ + unsigned u, v; /* Local index variables */ /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Allocate object token array */ - if(NULL == (objno = (H5O_token_t *)HDmalloc(sizeof(H5O_token_t) * (max_compact * 2)))) TEST_ERROR + if (NULL == (objno = (H5O_token_t *)HDmalloc(sizeof(H5O_token_t) * (max_compact * 2)))) + TEST_ERROR /* Create dataspace for attributes */ - if((space_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR + if ((space_id = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("query object info by creation order index in increasing order w/creation order index") + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + TESTING("query object info by creation order index in increasing order " + "w/creation order index") else - TESTING("query object info by creation order index in increasing order w/o creation order index") + TESTING("query object info by creation order index in increasing order w/o " + "creation order index") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("query object info by creation order index in decreasing order w/creation order index") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING("query object info by creation order index in decreasing order " + "w/creation order index") else - TESTING("query object info by creation order index in decreasing order w/o creation order index") + TESTING("query object info by creation order index in decreasing order w/o " + "creation order index") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) - TESTING("query object info by creation order index in native order w/creation order index") + if (use_index) + TESTING("query object info by creation order index in native order w/creation " + "order index") else - TESTING("query object info by creation order index in native order w/o creation order index") + TESTING("query object info by creation order index in native order w/o creation " + "order index") } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("query object info by name index in increasing order w/creation order index") + if (order == H5_ITER_INC) { + if (use_index) + TESTING( + "query object info by name index in increasing order w/creation order index") else - TESTING("query object info by name index in increasing order w/o creation order index") + TESTING("query object info by name index in increasing order w/o creation order " + "index") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("query object info by name index in decreasing order w/creation order index") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING( + "query object info by name index in decreasing order w/creation order index") else - TESTING("query object info by name index in decreasing order w/o creation order index") + TESTING("query object info by name index in decreasing order w/o creation order " + "index") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) + if (use_index) TESTING("query object info by name index in native order w/creation order index") else - TESTING("query object info by name index in native order w/o creation order index") + TESTING( + "query object info by name index in native order w/o creation order index") } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | + (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < + 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Create group with creation order tracking on for soft links */ - if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR - + if ((soft_group_id = + H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check for out of bound query by index on empty group */ - H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, + H5O_INFO_BASIC, H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { - hid_t group_id2; /* Group ID */ - hid_t attr_id; /* Attribute ID */ + for (u = 0; u < max_compact; u++) { + hid_t group_id2; /* Group ID */ + hid_t attr_id; /* Attribute ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info3(group_id2, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oinfo.token; /* Create attributes on new object */ - for(v = 0; v < u; v++) { + for (v = 0; v < u; v++) { /* Make name for attribute */ HDsnprintf(attrname, sizeof(attrname), "attr %02u", v); /* Create attribute */ - if((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* Close attribute */ - if(H5Aclose(attr_id) < 0) TEST_ERROR + if (H5Aclose(attr_id) < 0) + TEST_ERROR } /* end for */ /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (compact) */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound query by index */ - H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, + H5O_INFO_BASIC, H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Verify querying objects by name */ - if(object_info_check(group_id, soft_group_id, idx_type, order, u, objno) < 0) TEST_ERROR - + if (object_info_check(group_id, soft_group_id, idx_type, order, u, objno) < 0) + TEST_ERROR /* Create more links, to push group into dense form */ - for(; u < (max_compact * 2); u++) { - hid_t group_id2; /* Group ID */ - hid_t attr_id; /* Attribute ID */ + for (; u < (max_compact * 2); u++) { + hid_t group_id2; /* Group ID */ + hid_t attr_id; /* Attribute ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info3(group_id2, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oinfo.token; /* Create attributes on new object */ - for(v = 0; v < u; v++) { + for (v = 0; v < u; v++) { /* Make name for attribute */ HDsnprintf(attrname, sizeof(attrname), "attr %02u", v); /* Create attribute */ - if((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* Close attribute */ - if(H5Aclose(attr_id) < 0) TEST_ERROR + if (H5Aclose(attr_id) < 0) + TEST_ERROR } /* end for */ /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (dense) */ - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound query by index */ - H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, + H5O_INFO_BASIC, H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Verify querying objects by name */ - if(object_info_check(group_id, soft_group_id, idx_type, order, u, objno) < 0) TEST_ERROR - + if (object_info_check(group_id, soft_group_id, idx_type, order, u, objno) < 0) + TEST_ERROR /* Close the groups */ - if(H5Gclose(group_id) < 0) TEST_ERROR - if(H5Gclose(soft_group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR + if (H5Gclose(soft_group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Free resources */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(objno) + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (objno) HDfree(objno); return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space_id); H5Pclose(gcpl_id); H5Gclose(group_id); H5Gclose(soft_group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; - if(objno) + if (objno) HDfree(objno); return FAIL; } /* end object_info() */ - /*------------------------------------------------------------------------- * Function: object_info_check_old * @@ -17214,59 +21190,72 @@ error: *------------------------------------------------------------------------- */ static int -object_info_check_old(hid_t main_group_id, hid_t soft_group_id, H5_index_t idx_type, - H5_iter_order_t order, unsigned max_links, H5O_token_t *objno) +object_info_check_old(hid_t main_group_id, hid_t soft_group_id, H5_index_t idx_type, H5_iter_order_t order, + unsigned max_links, H5O_token_t *objno) { char objname[NAME_BUF_SIZE]; /* Object name */ - hid_t group_id = -1; /* ID of group to test */ - H5O_info2_t oinfo; /* Buffer for querying object's info */ - unsigned u, v; /* Local index variables */ + hid_t group_id = -1; /* ID of group to test */ + H5O_info2_t oinfo; /* Buffer for querying object's info */ + unsigned u, v; /* Local index variables */ /* Work through main & soft link groups */ - for(v = 0; v < 2; v++) { + for (v = 0; v < 2; v++) { /* Choose appropriate group to open links within */ - if(0 == v) + if (0 == v) group_id = main_group_id; else group_id = soft_group_id; /* Open each object in group by name and check that it's the correct one */ - for(u = 0; u < max_links; u++) { - int cmp_value; /* Token comparison value */ + for (u = 0; u < max_links; u++) { + int cmp_value; /* Token comparison value */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Query the object's information, by name */ - if(H5Oget_info_by_name3(group_id, objname, &oinfo, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_info_by_name3(group_id, objname, &oinfo, H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT) < 0) + TEST_ERROR /* Check that the object is the correct one */ - if(H5Otoken_cmp(group_id, &oinfo.token, &objno[u], &cmp_value) < 0) TEST_ERROR - if(0 != cmp_value) TEST_ERROR - if(oinfo.num_attrs != u) TEST_ERROR + if (H5Otoken_cmp(group_id, &oinfo.token, &objno[u], &cmp_value) < 0) + TEST_ERROR + if (0 != cmp_value) + TEST_ERROR + if (oinfo.num_attrs != u) + TEST_ERROR /* Query the object's information, by index */ - if(H5Oget_info_by_idx3(group_id, ".", idx_type, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_info_by_idx3(group_id, ".", idx_type, order, (hsize_t)u, &oinfo, + H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS, H5P_DEFAULT) < 0) + TEST_ERROR /* Check that the object is the correct one */ - if(order == H5_ITER_INC) { - if(H5Otoken_cmp(group_id, &oinfo.token, &objno[u], &cmp_value) < 0) TEST_ERROR - if(0 != cmp_value) TEST_ERROR - if(oinfo.num_attrs != u) TEST_ERROR + if (order == H5_ITER_INC) { + if (H5Otoken_cmp(group_id, &oinfo.token, &objno[u], &cmp_value) < 0) + TEST_ERROR + if (0 != cmp_value) + TEST_ERROR + if (oinfo.num_attrs != u) + TEST_ERROR } - else if(order == H5_ITER_DEC) { - unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ - - if(H5Otoken_cmp(group_id, &oinfo.token, &objno[dec_u], &cmp_value) < 0) TEST_ERROR - if(0 != cmp_value) TEST_ERROR - if(oinfo.num_attrs != dec_u) TEST_ERROR + else if (order == H5_ITER_DEC) { + unsigned dec_u = max_links - (u + 1); /* Decreasing mapped index */ + + if (H5Otoken_cmp(group_id, &oinfo.token, &objno[dec_u], &cmp_value) < 0) + TEST_ERROR + if (0 != cmp_value) + TEST_ERROR + if (oinfo.num_attrs != dec_u) + TEST_ERROR } else { /* XXX: What to do about native order? */ } } /* end for */ - } /* end for */ + } /* end for */ /* Success */ return SUCCEED; @@ -17287,31 +21276,32 @@ error: static int object_info_old(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t soft_group_id = -1; /* Group ID for soft links */ - hid_t space_id = -1; /* Dataspace ID (for attributes) */ - H5_iter_order_t order; /* Order within in the index */ - H5O_info2_t oinfo; /* Buffer for querying object's info */ - char filename[NAME_BUF_SIZE];/* File name */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char valname[2 * NAME_BUF_SIZE]; /* Link value */ - char attrname[NAME_BUF_SIZE]; /* Attribute name */ - H5O_token_t objno[CORDER_NLINKS]; /* Tokens for the objects created */ - herr_t ret; /* Generic return value */ - unsigned u, v; /* Local index variables */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + hid_t space_id = -1; /* Dataspace ID (for attributes) */ + H5_iter_order_t order; /* Order within in the index */ + H5O_info2_t oinfo; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE]; /* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char valname[2 * NAME_BUF_SIZE]; /* Link value */ + char attrname[NAME_BUF_SIZE]; /* Attribute name */ + H5O_token_t objno[CORDER_NLINKS]; /* Tokens for the objects created */ + herr_t ret; /* Generic return value */ + unsigned u, v; /* Local index variables */ /* Create dataspace for attributes */ - if((space_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR + if ((space_id = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Print appropriate test message */ - if(order == H5_ITER_INC) { + if (order == H5_ITER_INC) { TESTING("query object info by name index in increasing order in old-style group") } /* end if */ - else if(order == H5_ITER_DEC) { + else if (order == H5_ITER_DEC) { TESTING("query object info by name index in decreasing order in old-style group") } /* end else */ else { @@ -17321,101 +21311,131 @@ object_info_old(hid_t fapl) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create old-style group */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create old-style group for soft links */ - if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((soft_group_id = + H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check for out of bound query by index on empty group */ - H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, H5O_INFO_BASIC, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2; /* Group ID */ - hid_t attr_id; /* Attribute ID */ + for (u = 0; u < CORDER_NLINKS; u++) { + hid_t group_id2; /* Group ID */ + hid_t attr_id; /* Attribute ID */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's address on disk */ - if(H5Oget_info3(group_id2, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(group_id2, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR objno[u] = oinfo.token; /* Create attributes on new object */ - for(v = 0; v < u; v++) { + for (v = 0; v < u; v++) { /* Make name for attribute */ HDsnprintf(attrname, sizeof(attrname), "attr %02u", v); /* Create attribute */ - if((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* Close attribute */ - if(H5Aclose(attr_id) < 0) TEST_ERROR + if (H5Aclose(attr_id) < 0) + TEST_ERROR } /* end for */ /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR } /* end for */ /* Verify state of group (symbol table) */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound query by index */ - H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for creation order index query */ - H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)(u - 1), &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)(u - 1), &oinfo, + H5O_INFO_BASIC, H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Verify querying objects by name */ - if(object_info_check_old(group_id, soft_group_id, H5_INDEX_NAME, order, u, objno) < 0) TEST_ERROR + if (object_info_check_old(group_id, soft_group_id, H5_INDEX_NAME, order, u, objno) < 0) + TEST_ERROR /* Close the groups */ - if(H5Gclose(group_id) < 0) TEST_ERROR - if(H5Gclose(soft_group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR + if (H5Gclose(soft_group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ /* Free resources */ - if(H5Sclose(space_id) < 0) TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space_id); H5Gclose(group_id); H5Gclose(soft_group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end object_info_old() */ - /*------------------------------------------------------------------------- * Function: group_info * @@ -17429,396 +21449,541 @@ error: static int group_info(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t soft_group_id = -1; /* Group ID for soft links */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - H5G_info_t grp_info; /* Buffer for querying object's info */ - char filename[NAME_BUF_SIZE];/* File name */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char objname2[NAME_BUF_SIZE]; /* Object name */ - char valname[2 * NAME_BUF_SIZE]; /* Link value */ - herr_t ret; /* Generic return value */ - unsigned u, v; /* Local index variables */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5G_info_t grp_info; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE]; /* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char objname2[NAME_BUF_SIZE]; /* Object name */ + char valname[2 * NAME_BUF_SIZE]; /* Link value */ + herr_t ret; /* Generic return value */ + unsigned u, v; /* Local index variables */ /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Query the group creation properties */ - if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + if (H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) + TEST_ERROR /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("query group info by creation order index in increasing order w/creation order index") + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + TESTING("query group info by creation order index in increasing order w/creation " + "order index") else - TESTING("query group info by creation order index in increasing order w/o creation order index") + TESTING("query group info by creation order index in increasing order w/o " + "creation order index") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("query group info by creation order index in decreasing order w/creation order index") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING("query group info by creation order index in decreasing order w/creation " + "order index") else - TESTING("query group info by creation order index in decreasing order w/o creation order index") + TESTING("query group info by creation order index in decreasing order w/o " + "creation order index") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) - TESTING("query group info by creation order index in native order w/creation order index") + if (use_index) + TESTING("query group info by creation order index in native order w/creation " + "order index") else - TESTING("query group info by creation order index in native order w/o creation order index") + TESTING("query group info by creation order index in native order w/o creation " + "order index") } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) - TESTING("query group info by name index in increasing order w/creation order index") + if (order == H5_ITER_INC) { + if (use_index) + TESTING( + "query group info by name index in increasing order w/creation order index") else - TESTING("query group info by name index in increasing order w/o creation order index") + TESTING( + "query group info by name index in increasing order w/o creation order index") } /* end if */ - else if(order == H5_ITER_DEC) { - if(use_index) - TESTING("query group info by name index in decreasing order w/creation order index") + else if (order == H5_ITER_DEC) { + if (use_index) + TESTING( + "query group info by name index in decreasing order w/creation order index") else - TESTING("query group info by name index in decreasing order w/o creation order index") + TESTING( + "query group info by name index in decreasing order w/o creation order index") } /* end else */ else { HDassert(order == H5_ITER_NATIVE); - if(use_index) + if (use_index) TESTING("query group info by name index in native order w/creation order index") else TESTING("query group info by name index in native order w/o creation order index") } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Set creation order tracking & indexing on group */ - if(H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | + (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < + 0) + TEST_ERROR /* Create group with creation order tracking on */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Create group with creation order tracking on for soft links */ - if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((soft_group_id = + H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check for out of bound query by index on empty group */ - H5E_BEGIN_TRY { - ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { - hid_t group_id2, group_id3; /* Group IDs */ + for (u = 0; u < max_compact; u++) { + hid_t group_id2, group_id3; /* Group IDs */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's information */ - if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id2, &grp_info) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Retrieve group's information */ - if(H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Retrieve group's information */ - if(H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Create objects in new group created */ - for(v = 0; v <= u; v++) { + for (v = 0; v <= u; v++) { /* Make name for link */ HDsnprintf(objname2, sizeof(objname2), "filler %02u", v); /* Create hard link, with group object */ - if((group_id3 = H5Gcreate2(group_id2, objname2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id3 = + H5Gcreate2(group_id2, objname2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group created */ - if(H5Gclose(group_id3) < 0) TEST_ERROR + if (H5Gclose(group_id3) < 0) + TEST_ERROR } /* end for */ /* Retrieve group's information */ - if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id2, &grp_info) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information */ - if(H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information */ - if(H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information */ - if(order != H5_ITER_NATIVE) { - if(order == H5_ITER_INC) { - if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (order != H5_ITER_NATIVE) { + if (order == H5_ITER_INC) { + if (H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &grp_info, + H5P_DEFAULT) < 0) + TEST_ERROR } /* end if */ else { - if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &grp_info, + H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR } /* end if */ /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Retrieve main group's information */ - if(H5Gget_info(group_id, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id, &grp_info) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve main group's information, by name */ - if(H5Gget_info_by_name(file_id, CORDER_GROUP_NAME, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(file_id, CORDER_GROUP_NAME, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve main group's information, by name */ - if(H5Gget_info_by_name(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Retrieve soft link group's information, by name */ - if(H5Gget_info(soft_group_id, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(soft_group_id, &grp_info) < 0) + TEST_ERROR /* Check soft link group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR } /* end for */ /* Verify state of group (compact) */ - if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if (H5G__has_links_test(group_id, NULL) != TRUE) + TEST_ERROR /* Check for out of bound query by index */ - H5E_BEGIN_TRY { - ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create more links, to push group into dense form */ - for(; u < (max_compact * 2); u++) { - hid_t group_id2, group_id3; /* Group IDs */ + for (; u < (max_compact * 2); u++) { + hid_t group_id2, group_id3; /* Group IDs */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's information */ - if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id2, &grp_info) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Retrieve group's information, by name */ - if(H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Retrieve group's information, by name */ - if(H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Create objects in new group created */ - for(v = 0; v <= u; v++) { + for (v = 0; v <= u; v++) { /* Make name for link */ HDsnprintf(objname2, sizeof(objname2), "filler %02u", v); /* Create hard link, with group object */ - if((group_id3 = H5Gcreate2(group_id2, objname2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id3 = + H5Gcreate2(group_id2, objname2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group created */ - if(H5Gclose(group_id3) < 0) TEST_ERROR + if (H5Gclose(group_id3) < 0) + TEST_ERROR } /* end for */ /* Retrieve group's information */ - if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id2, &grp_info) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information, by name */ - if(H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information, by name */ - if(H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information */ - if(order != H5_ITER_NATIVE) { - if(order == H5_ITER_INC) { - if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (order != H5_ITER_NATIVE) { + if (order == H5_ITER_INC) { + if (H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &grp_info, + H5P_DEFAULT) < 0) + TEST_ERROR } /* end if */ else { - if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &grp_info, + H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR } /* end if */ /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Retrieve main group's information */ - if(H5Gget_info(group_id, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id, &grp_info) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve main group's information, by name */ - if(H5Gget_info_by_name(file_id, CORDER_GROUP_NAME, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(file_id, CORDER_GROUP_NAME, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve main group's information, by name */ - if(H5Gget_info_by_name(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Retrieve soft link group's information, by name */ - if(H5Gget_info(soft_group_id, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(soft_group_id, &grp_info) < 0) + TEST_ERROR /* Check soft link group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR - if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) + TEST_ERROR + if (grp_info.max_corder != (int64_t)(u + 1)) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR } /* end for */ /* Verify state of group (dense) */ - if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR + if (H5G__is_new_dense_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound query by index */ - H5E_BEGIN_TRY { - ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Close the groups */ - if(H5Gclose(group_id) < 0) TEST_ERROR - if(H5Gclose(soft_group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR + if (H5Gclose(soft_group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Free resources */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR return SUCCEED; error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Gclose(soft_group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end group_info() */ - /*------------------------------------------------------------------------- * Function: group_info_old * @@ -17832,24 +21997,24 @@ error: static int group_info_old(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t soft_group_id = -1; /* Group ID for soft links */ - H5_iter_order_t order; /* Order within in the index */ - H5G_info_t grp_info; /* Buffer for querying object's info */ - char filename[NAME_BUF_SIZE];/* File name */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char objname2[NAME_BUF_SIZE]; /* Object name */ - char valname[2 * NAME_BUF_SIZE]; /* Link value */ - herr_t ret; /* Generic return value */ - unsigned u, v; /* Local index variables */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t soft_group_id = -1; /* Group ID for soft links */ + H5_iter_order_t order; /* Order within in the index */ + H5G_info_t grp_info; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE]; /* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char objname2[NAME_BUF_SIZE]; /* Object name */ + char valname[2 * NAME_BUF_SIZE]; /* Link value */ + herr_t ret; /* Generic return value */ + unsigned u, v; /* Local index variables */ /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { - if(order == H5_ITER_INC) { + for (order = H5_ITER_INC; order <= H5_ITER_NATIVE; order++) { + if (order == H5_ITER_INC) { TESTING("query group info by name index in increasing order in old-style group") } /* end if */ - else if(order == H5_ITER_DEC) { + else if (order == H5_ITER_DEC) { TESTING("query group info by name index in decreasing order in old-style group") } /* end else */ else { @@ -17859,166 +22024,236 @@ group_info_old(hid_t fapl) /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create old-style group */ - if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create old-style group for soft links */ - if((soft_group_id = H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((soft_group_id = + H5Gcreate2(file_id, CORDER_SOFT_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check for out of bound query by index on empty group */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create several links */ - for(u = 0; u < CORDER_NLINKS; u++) { - hid_t group_id2, group_id3; /* Group IDs */ + for (u = 0; u < CORDER_NLINKS; u++) { + hid_t group_id2, group_id3; /* Group IDs */ /* Make name for link */ HDsnprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve group's information */ - if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id2, &grp_info) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Retrieve group's information, by name */ - if(H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Retrieve group's information, by name */ - if(H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new/empty) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != 0) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != 0) + TEST_ERROR /* Create objects in new group created */ - for(v = 0; v <= u; v++) { + for (v = 0; v <= u; v++) { /* Make name for link */ HDsnprintf(objname2, sizeof(objname2), "filler %02u", v); /* Create hard link, with group object */ - if((group_id3 = H5Gcreate2(group_id2, objname2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id3 = H5Gcreate2(group_id2, objname2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close group created */ - if(H5Gclose(group_id3) < 0) TEST_ERROR + if (H5Gclose(group_id3) < 0) + TEST_ERROR } /* end for */ /* Retrieve group's information */ - if(H5Gget_info(group_id2, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id2, &grp_info) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information, by name */ - if(H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, objname, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information, by name */ - if(H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve group's information */ - if(order != H5_ITER_NATIVE) { - if(order == H5_ITER_INC) { - if(H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (order != H5_ITER_NATIVE) { + if (order == H5_ITER_INC) { + if (H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, + H5P_DEFAULT) < 0) + TEST_ERROR } /* end if */ else { - if(H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, + H5P_DEFAULT) < 0) + TEST_ERROR } /* end else */ /* Check (new) group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR } /* end if */ /* Close group created */ - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Retrieve main group's information */ - if(H5Gget_info(group_id, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(group_id, &grp_info) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve main group's information, by name */ - if(H5Gget_info_by_name(file_id, CORDER_GROUP_NAME, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(file_id, CORDER_GROUP_NAME, &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Retrieve main group's information, by name */ - if(H5Gget_info_by_name(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Gget_info_by_name(group_id, ".", &grp_info, H5P_DEFAULT) < 0) + TEST_ERROR /* Check main group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR /* Create soft link in another group, to objects in main group */ HDsnprintf(valname, sizeof(valname), "/%s/%s", CORDER_GROUP_NAME, objname); - if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Retrieve soft link group's information, by name */ - if(H5Gget_info(soft_group_id, &grp_info) < 0) TEST_ERROR + if (H5Gget_info(soft_group_id, &grp_info) < 0) + TEST_ERROR /* Check soft link group's information */ - if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR - if(grp_info.max_corder != 0) TEST_ERROR - if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + if (grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) + TEST_ERROR + if (grp_info.max_corder != 0) + TEST_ERROR + if (grp_info.nlinks != (hsize_t)(u + 1)) + TEST_ERROR } /* end for */ /* Verify state of group (old-style) */ - if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR + if (H5G__has_stab_test(group_id) != TRUE) + TEST_ERROR /* Check for out of bound query by index */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Check for bad index query by index group */ - H5E_BEGIN_TRY { - ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)0, &grp_info, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + H5E_BEGIN_TRY + { + ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)0, &grp_info, + H5P_DEFAULT); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Close the groups */ - if(H5Gclose(group_id) < 0) TEST_ERROR - if(H5Gclose(soft_group_id) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR + if (H5Gclose(soft_group_id) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); } /* end for */ @@ -18027,16 +22262,17 @@ group_info_old(hid_t fapl) error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(group_id); H5Gclose(soft_group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end group_info_old() */ - /*------------------------------------------------------------------------- * Function: timestamps * @@ -18050,145 +22286,212 @@ error: static int timestamps(hid_t fapl) { - hid_t file_id = -1; /* File ID */ - hid_t group_id = -1; /* Group ID */ - hid_t group_id2 = -1; /* Group ID */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - hid_t gcpl_id2 = -1; /* Group creation property list ID */ - H5O_info2_t oinfo, oinfo2; /* Object info for groups created */ - H5O_native_info_t ninfo, ninfo2; /* Native info for groups created */ - char filename[NAME_BUF_SIZE];/* File name */ - hbool_t track_times; /* The object timestamp setting */ + hid_t file_id = -1; /* File ID */ + hid_t group_id = -1; /* Group ID */ + hid_t group_id2 = -1; /* Group ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + hid_t gcpl_id2 = -1; /* Group creation property list ID */ + H5O_info2_t oinfo, oinfo2; /* Object info for groups created */ + H5O_native_info_t ninfo, ninfo2; /* Native info for groups created */ + char filename[NAME_BUF_SIZE]; /* File name */ + hbool_t track_times; /* The object timestamp setting */ /* Print test message */ TESTING("timestamps on objects") /* Create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Query the object timestamp setting */ - if(H5Pget_obj_track_times(gcpl_id, &track_times) < 0) TEST_ERROR + if (H5Pget_obj_track_times(gcpl_id, &track_times) < 0) + TEST_ERROR /* Check default timestamp information */ - if(track_times != TRUE) TEST_ERROR + if (track_times != TRUE) + TEST_ERROR /* Set a non-default object timestamp setting */ - if(H5Pset_obj_track_times(gcpl_id, FALSE) < 0) TEST_ERROR + if (H5Pset_obj_track_times(gcpl_id, FALSE) < 0) + TEST_ERROR /* Query the object timestamp setting */ - if(H5Pget_obj_track_times(gcpl_id, &track_times) < 0) TEST_ERROR + if (H5Pget_obj_track_times(gcpl_id, &track_times) < 0) + TEST_ERROR /* Check default timestamp information */ - if(track_times != FALSE) TEST_ERROR + if (track_times != FALSE) + TEST_ERROR /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create group with non-default object timestamp setting */ - if((group_id = H5Gcreate2(file_id, TIMESTAMP_GROUP_1, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id = H5Gcreate2(file_id, TIMESTAMP_GROUP_1, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close the group creation property list */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR /* Create group with default object timestamp setting */ - if((group_id2 = H5Gcreate2(file_id, TIMESTAMP_GROUP_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((group_id2 = H5Gcreate2(file_id, TIMESTAMP_GROUP_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Retrieve the new groups' creation properties */ - if((gcpl_id = H5Gget_create_plist(group_id)) < 0) TEST_ERROR - if((gcpl_id2 = H5Gget_create_plist(group_id2)) < 0) TEST_ERROR + if ((gcpl_id = H5Gget_create_plist(group_id)) < 0) + TEST_ERROR + if ((gcpl_id2 = H5Gget_create_plist(group_id2)) < 0) + TEST_ERROR /* Query & verify the object timestamp settings */ - if(H5Pget_obj_track_times(gcpl_id, &track_times) < 0) TEST_ERROR - if(track_times != FALSE) TEST_ERROR - if(H5Pget_obj_track_times(gcpl_id2, &track_times) < 0) TEST_ERROR - if(track_times != TRUE) TEST_ERROR + if (H5Pget_obj_track_times(gcpl_id, &track_times) < 0) + TEST_ERROR + if (track_times != FALSE) + TEST_ERROR + if (H5Pget_obj_track_times(gcpl_id2, &track_times) < 0) + TEST_ERROR + if (track_times != TRUE) + TEST_ERROR /* Query the object information for each group */ /* Generic info */ - if(H5Oget_info3(group_id, &oinfo, H5O_INFO_TIME) < 0) TEST_ERROR - if(H5Oget_info3(group_id2, &oinfo2, H5O_INFO_TIME) < 0) TEST_ERROR + if (H5Oget_info3(group_id, &oinfo, H5O_INFO_TIME) < 0) + TEST_ERROR + if (H5Oget_info3(group_id2, &oinfo2, H5O_INFO_TIME) < 0) + TEST_ERROR /* Native file format info */ - if(H5Oget_native_info(group_id, &ninfo, H5O_NATIVE_INFO_HDR) < 0) TEST_ERROR - if(H5Oget_native_info(group_id2, &ninfo2, H5O_NATIVE_INFO_HDR) < 0) TEST_ERROR + if (H5Oget_native_info(group_id, &ninfo, H5O_NATIVE_INFO_HDR) < 0) + TEST_ERROR + if (H5Oget_native_info(group_id2, &ninfo2, H5O_NATIVE_INFO_HDR) < 0) + TEST_ERROR /* Sanity check object information for each group */ /* Generic info */ - if(oinfo.atime != 0) TEST_ERROR - if(oinfo.mtime != 0) TEST_ERROR - if(oinfo.ctime != 0) TEST_ERROR - if(oinfo.btime != 0) TEST_ERROR - if(oinfo.atime == oinfo2.atime) TEST_ERROR - if(oinfo.mtime == oinfo2.mtime) TEST_ERROR - if(oinfo.ctime == oinfo2.ctime) TEST_ERROR - if(oinfo.btime == oinfo2.btime) TEST_ERROR + if (oinfo.atime != 0) + TEST_ERROR + if (oinfo.mtime != 0) + TEST_ERROR + if (oinfo.ctime != 0) + TEST_ERROR + if (oinfo.btime != 0) + TEST_ERROR + if (oinfo.atime == oinfo2.atime) + TEST_ERROR + if (oinfo.mtime == oinfo2.mtime) + TEST_ERROR + if (oinfo.ctime == oinfo2.ctime) + TEST_ERROR + if (oinfo.btime == oinfo2.btime) + TEST_ERROR /* Native file format info */ - if((ninfo.hdr.flags & H5O_HDR_STORE_TIMES) != 0) TEST_ERROR - if((ninfo2.hdr.flags & H5O_HDR_STORE_TIMES) == 0) TEST_ERROR - if(ninfo.hdr.space.total >= ninfo2.hdr.space.total) TEST_ERROR - if(ninfo.hdr.space.meta >= ninfo2.hdr.space.meta) TEST_ERROR + if ((ninfo.hdr.flags & H5O_HDR_STORE_TIMES) != 0) + TEST_ERROR + if ((ninfo2.hdr.flags & H5O_HDR_STORE_TIMES) == 0) + TEST_ERROR + if (ninfo.hdr.space.total >= ninfo2.hdr.space.total) + TEST_ERROR + if (ninfo.hdr.space.meta >= ninfo2.hdr.space.meta) + TEST_ERROR /* Close the property lists */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR - if(H5Pclose(gcpl_id2) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR + if (H5Pclose(gcpl_id2) < 0) + TEST_ERROR /* Close the groups */ - if(H5Gclose(group_id) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR /* Open groups */ - if((group_id = H5Gopen2(file_id, TIMESTAMP_GROUP_1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group_id2 = H5Gopen2(file_id, TIMESTAMP_GROUP_2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group_id = H5Gopen2(file_id, TIMESTAMP_GROUP_1, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group_id2 = H5Gopen2(file_id, TIMESTAMP_GROUP_2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Retrieve the groups' creation properties */ - if((gcpl_id = H5Gget_create_plist(group_id)) < 0) TEST_ERROR - if((gcpl_id2 = H5Gget_create_plist(group_id2)) < 0) TEST_ERROR + if ((gcpl_id = H5Gget_create_plist(group_id)) < 0) + TEST_ERROR + if ((gcpl_id2 = H5Gget_create_plist(group_id2)) < 0) + TEST_ERROR /* Query & verify the object timestamp settings */ - if(H5Pget_obj_track_times(gcpl_id, &track_times) < 0) TEST_ERROR - if(track_times != FALSE) TEST_ERROR - if(H5Pget_obj_track_times(gcpl_id2, &track_times) < 0) TEST_ERROR - if(track_times != TRUE) TEST_ERROR + if (H5Pget_obj_track_times(gcpl_id, &track_times) < 0) + TEST_ERROR + if (track_times != FALSE) + TEST_ERROR + if (H5Pget_obj_track_times(gcpl_id2, &track_times) < 0) + TEST_ERROR + if (track_times != TRUE) + TEST_ERROR /* Query the object information for each group */ - if(H5Oget_info3(group_id, &oinfo, H5O_INFO_TIME) < 0) TEST_ERROR - if(H5Oget_info3(group_id2, &oinfo2, H5O_INFO_TIME) < 0) TEST_ERROR + if (H5Oget_info3(group_id, &oinfo, H5O_INFO_TIME) < 0) + TEST_ERROR + if (H5Oget_info3(group_id2, &oinfo2, H5O_INFO_TIME) < 0) + TEST_ERROR /* Native file format info */ - if(H5Oget_native_info(group_id, &ninfo, H5O_NATIVE_INFO_HDR) < 0) TEST_ERROR - if(H5Oget_native_info(group_id2, &ninfo2, H5O_NATIVE_INFO_HDR) < 0) TEST_ERROR + if (H5Oget_native_info(group_id, &ninfo, H5O_NATIVE_INFO_HDR) < 0) + TEST_ERROR + if (H5Oget_native_info(group_id2, &ninfo2, H5O_NATIVE_INFO_HDR) < 0) + TEST_ERROR /* Sanity check object information for each group */ /* Generic info */ - if(oinfo.atime != 0) TEST_ERROR - if(oinfo.mtime != 0) TEST_ERROR - if(oinfo.ctime != 0) TEST_ERROR - if(oinfo.btime != 0) TEST_ERROR - if(oinfo.atime == oinfo2.atime) TEST_ERROR - if(oinfo.mtime == oinfo2.mtime) TEST_ERROR - if(oinfo.ctime == oinfo2.ctime) TEST_ERROR - if(oinfo.btime == oinfo2.btime) TEST_ERROR + if (oinfo.atime != 0) + TEST_ERROR + if (oinfo.mtime != 0) + TEST_ERROR + if (oinfo.ctime != 0) + TEST_ERROR + if (oinfo.btime != 0) + TEST_ERROR + if (oinfo.atime == oinfo2.atime) + TEST_ERROR + if (oinfo.mtime == oinfo2.mtime) + TEST_ERROR + if (oinfo.ctime == oinfo2.ctime) + TEST_ERROR + if (oinfo.btime == oinfo2.btime) + TEST_ERROR /* Native file format info */ - if((ninfo.hdr.flags & H5O_HDR_STORE_TIMES) != 0) TEST_ERROR - if((ninfo2.hdr.flags & H5O_HDR_STORE_TIMES) == 0) TEST_ERROR - if(ninfo.hdr.space.total >= ninfo2.hdr.space.total) TEST_ERROR - if(ninfo.hdr.space.meta >= ninfo2.hdr.space.meta) TEST_ERROR + if ((ninfo.hdr.flags & H5O_HDR_STORE_TIMES) != 0) + TEST_ERROR + if ((ninfo2.hdr.flags & H5O_HDR_STORE_TIMES) == 0) + TEST_ERROR + if (ninfo.hdr.space.total >= ninfo2.hdr.space.total) + TEST_ERROR + if (ninfo.hdr.space.meta >= ninfo2.hdr.space.meta) + TEST_ERROR /* Close the property lists */ - if(H5Pclose(gcpl_id) < 0) TEST_ERROR - if(H5Pclose(gcpl_id2) < 0) TEST_ERROR + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR + if (H5Pclose(gcpl_id2) < 0) + TEST_ERROR /* Close the groups */ - if(H5Gclose(group_id) < 0) TEST_ERROR - if(H5Gclose(group_id2) < 0) TEST_ERROR + if (H5Gclose(group_id) < 0) + TEST_ERROR + if (H5Gclose(group_id2) < 0) + TEST_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); @@ -18196,16 +22499,17 @@ timestamps(hid_t fapl) error: /* Free resources */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(gcpl_id); H5Gclose(group_id); H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end timestamps() */ - /*------------------------------------------------------------------------- * Function: main * @@ -18217,40 +22521,43 @@ error: int main(void) { - hid_t fapl = -1, fapl2 = -1; /* File access property lists */ - int nerrors = 0; - unsigned new_format; /* Whether to use the new format or not */ - unsigned minimize_dset_oh; - unsigned efc; /* Whether to use the external file cache */ - const char *env_h5_drvr; /* File Driver value from environment */ + hid_t fapl = -1, fapl2 = -1; /* File access property lists */ + int nerrors = 0; + unsigned new_format; /* Whether to use the new format or not */ + unsigned minimize_dset_oh; + unsigned efc; /* Whether to use the external file cache */ + const char *env_h5_drvr; /* File Driver value from environment */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; h5_reset(); fapl = h5_fileaccess(); /* fapl2 uses "latest version bounds" */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + TEST_ERROR + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR for (minimize_dset_oh = 0; minimize_dset_oh <= 1; minimize_dset_oh++) { if (minimize_dset_oh) { HDprintf("\n-Testing with minimzed dataset object headers-\n"); dcpl_g = H5Pcreate(H5P_DATASET_CREATE); - if (0 > dcpl_g) TEST_ERROR + if (0 > dcpl_g) + TEST_ERROR } else { HDprintf("\n-Testing with unminimzed dataset object headers-\n"); dcpl_g = H5P_DEFAULT; } - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl; /* Check for FAPL to use */ - if(new_format) { + if (new_format) { my_fapl = fapl2; HDprintf("\n--Testing with 'new format'--\n"); } @@ -18260,7 +22567,8 @@ main(void) } /* always enter tests without external cache */ - if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) TEST_ERROR + if (H5Pset_elink_file_cache_size(my_fapl, 0) < 0) + TEST_ERROR /* General tests... (on both old & new format groups */ nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0; @@ -18302,13 +22610,15 @@ main(void) nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; /* Try external link tests both with and without the external file cache */ - for(efc = FALSE; efc <= TRUE; efc++) { - if(efc) { - if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0) TEST_ERROR + for (efc = FALSE; efc <= TRUE; efc++) { + if (efc) { + if (H5Pset_elink_file_cache_size(my_fapl, 8) < 0) + TEST_ERROR HDprintf("\n---Testing with external file cache---\n"); } /* end if */ else { - if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) TEST_ERROR + if (H5Pset_elink_file_cache_size(my_fapl, 0) < 0) + TEST_ERROR HDprintf("\n---Testing without external file cache---\n"); } /* end else */ @@ -18371,16 +22681,16 @@ main(void) * so assume that everything that passed for external links * above has already been tested for UD links. */ - if(new_format == TRUE) { - nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */ + if (new_format == TRUE) { + nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */ #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += ud_hard_links_deprec(fapl2) < 0 ? 1 : 0; /* requires new format groups */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */ + nerrors += ud_hard_links_deprec(fapl2) < 0 ? 1 : 0; /* requires new format groups */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */ #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += ud_link_reregister_deprec(fapl2) < 0 ? 1 : 0; /* requires new format groups */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ + nerrors += ud_link_reregister_deprec(fapl2) < 0 ? 1 : 0; /* requires new format groups */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + } /* end if */ nerrors += ud_callbacks(my_fapl, new_format) < 0 ? 1 : 0; #ifndef H5_NO_DEPRECATED_SYMBOLS nerrors += ud_callbacks_deprec(my_fapl, new_format) < 0 ? 1 : 0; @@ -18413,10 +22723,10 @@ main(void) /* New group revision feature tests */ nerrors += corder_create_empty(fapl2) < 0 ? 1 : 0; -/* XXX: when creation order indexing is fully working, go back and add checks - * to these tests to make certain that the creation order values are - * correct. - */ + /* XXX: when creation order indexing is fully working, go back and add checks + * to these tests to make certain that the creation order values are + * correct. + */ nerrors += corder_create_compact(fapl2) < 0 ? 1 : 0; #ifndef H5_NO_DEPRECATED_SYMBOLS nerrors += corder_create_compact_deprec(fapl2) < 0 ? 1 : 0; @@ -18482,8 +22792,8 @@ main(void) nerrors += external_reset_register() < 0 ? 1 : 0; /* Results */ - if(nerrors) { - HDprintf("***** %d LINK TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); + if (nerrors) { + HDprintf("***** %d LINK TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } HDprintf("All link tests passed.\n"); @@ -18502,4 +22812,3 @@ error: HDputs("*** TESTS FAILED ***"); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/links_env.c b/test/links_env.c index efb8cfd..2d7a0fd 100644 --- a/test/links_env.c +++ b/test/links_env.c @@ -15,27 +15,24 @@ * Purpose: Tests hard, soft (symbolic) & external links. */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ #define H5G_TESTING #include "h5test.h" -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ -#define TMPDIR "tmp_links_env/" -#define NAME_BUF_SIZE 1024 +#define TMPDIR "tmp_links_env/" +#define NAME_BUF_SIZE 1024 -const char *FILENAME[] = { - "extlinks_env0", /* 0: main file */ - "extlinks_env1", /* 1: target file */ - TMPDIR "extlinks_env1", /* 2 */ - NULL -}; +const char *FILENAME[] = {"extlinks_env0", /* 0: main file */ + "extlinks_env1", /* 1: target file */ + TMPDIR "extlinks_env1", /* 2 */ + NULL}; static int external_link_env(hid_t fapl, hbool_t new_format); - /*------------------------------------------------------------------------- * Function: external_link_env (moved from links.c) * @@ -59,21 +56,21 @@ static int external_link_env(hid_t fapl, hbool_t new_format); static int external_link_env(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - const char *envval = NULL; /* Pointer to environment variable */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; /* Holders for filename */ - - if(new_format) + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group IDs */ + const char *envval = NULL; /* Pointer to environment variable */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; /* Holders for filename */ + + if (new_format) TESTING("external links via environment variable (w/new group format)") else TESTING("external links via environment variable") if ((envval = HDgetenv("HDF5_EXT_PREFIX")) == NULL) envval = "nomatch"; - if (HDstrcmp(envval, ".:tmp_links_env")) TEST_ERROR + if (HDstrcmp(envval, ".:tmp_links_env")) + TEST_ERROR /* Set up name for main file:"extlinks_env0" */ h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); @@ -82,55 +79,65 @@ external_link_env(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Create "tmp_links_env" directory */ - if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR /* Set up name (location) for the target file: "tmp_links_env/extlinks1" */ h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); /* Create the target file in "tmp_links_env" directory */ - if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if ((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Closing for target file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Create the main file */ - if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Create external link to target file */ - if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Open object through external link */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should be able to find the target file from pathnames set via HDF5_EXT_PREFIX */ if (gid < 0) { - H5_FAILED(); - puts(" Should have found the file in tmp_links_env directory."); - goto error; + H5_FAILED(); + puts(" Should have found the file in tmp_links_env directory."); + goto error; } /* closing for main file */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Gclose(gid); + H5Fclose(fid); + } + H5E_END_TRY; return -1; } /* end external_link_env() */ - /*------------------------------------------------------------------------- * Function: main * @@ -145,8 +152,8 @@ external_link_env(hid_t fapl, hbool_t new_format) int main(void) { - hid_t fapl; /* File access property lists */ - int nerrors = 0; /* Error from tests */ + hid_t fapl; /* File access property lists */ + int nerrors = 0; /* Error from tests */ h5_reset(); fapl = h5_fileaccess(); @@ -154,7 +161,8 @@ main(void) nerrors += external_link_env(fapl, FALSE) < 0 ? 1 : 0; /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR nerrors += external_link_env(fapl, TRUE) < 0 ? 1 : 0; @@ -164,9 +172,9 @@ main(void) h5_cleanup(FILENAME, fapl); /* Results */ - if(nerrors) { - HDprintf("***** %d External Link (HDF5_EXT_PREFIX) test%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "s"); + if (nerrors) { + HDprintf("***** %d External Link (HDF5_EXT_PREFIX) test%s FAILED! *****\n", nerrors, + 1 == nerrors ? "" : "s"); HDexit(EXIT_FAILURE); } HDprintf("All external Link (HDF5_EXT_PREFIX) tests passed.\n"); @@ -180,4 +188,3 @@ error: HDputs("*** TESTS FAILED ***"); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/mf.c b/test/mf.c index 7cfc954..c9e9821 100644 --- a/test/mf.c +++ b/test/mf.c @@ -23,91 +23,88 @@ #include "h5test.h" -#define H5MF_FRIEND /*suppress error about including H5MFpkg */ +#define H5MF_FRIEND /*suppress error about including H5MFpkg */ #include "H5MFpkg.h" -#define H5FS_FRIEND /*suppress error about including H5FSpkg */ +#define H5FS_FRIEND /*suppress error about including H5FSpkg */ #include "H5FSpkg.h" -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING #include "H5Fpkg.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5FLprivate.h" #include "H5Iprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VMprivate.h" -#define FILENAME_LEN 1024 +#define FILENAME_LEN 1024 -#define TBLOCK_SIZE1 1 -#define TBLOCK_SIZE2 2 -#define TBLOCK_SIZE3 3 -#define TBLOCK_SIZE4 4 -#define TBLOCK_SIZE5 5 -#define TBLOCK_SIZE6 6 +#define TBLOCK_SIZE1 1 +#define TBLOCK_SIZE2 2 +#define TBLOCK_SIZE3 3 +#define TBLOCK_SIZE4 4 +#define TBLOCK_SIZE5 5 +#define TBLOCK_SIZE6 6 #ifdef PB_OUT -#define TBLOCK_SIZE7 7 -#define TBLOCK_SIZE8 8 +#define TBLOCK_SIZE7 7 +#define TBLOCK_SIZE8 8 #endif /* PB_OUT */ -#define TBLOCK_SIZE10 10 -#define TBLOCK_SIZE11 11 -#define TBLOCK_SIZE20 20 -#define TBLOCK_SIZE30 30 -#define TBLOCK_SIZE36 36 -#define TBLOCK_SIZE40 40 -#define TBLOCK_SIZE50 50 -#define TBLOCK_SIZE80 80 -#define TBLOCK_SIZE90 90 -#define TBLOCK_SIZE98 98 -#define TBLOCK_SIZE100 100 -#define TBLOCK_SIZE150 150 -#define TBLOCK_SIZE200 200 -#define TBLOCK_SIZE600 600 -#define TBLOCK_SIZE700 700 -#define TBLOCK_SIZE1034 1034 -#define TBLOCK_SIZE1970 1970 -#define TBLOCK_SIZE2048 2048 -#define TBLOCK_SIZE2058 2058 -#define TBLOCK_SIZE2192 2192 -#define TBLOCK_SIZE3080 3080 -#define TBLOCK_SIZE3088 3088 -#define TBLOCK_SIZE3198 3198 -#define TBLOCK_SIZE3286 3286 -#define TBLOCK_SIZE3248 3248 -#define TBLOCK_SIZE3900 3900 -#define TBLOCK_SIZE4020 4020 -#define TBLOCK_SIZE4086 4086 -#define TBLOCK_SIZE4096 4096 -#define TBLOCK_SIZE4106 4106 -#define TBLOCK_SIZE5000 5000 -#define TBLOCK_SIZE6000 6000 -#define TBLOCK_SIZE8000 8000 -#define TBLOCK_SIZE8100 8100 -#define TBLOCK_SIZE8192 8192 -#define TBLOCK_SIZE8190 8190 -#define TBLOCK_SIZE12000 12000 - -#define TBLOCK_ADDR70 70 -#define TBLOCK_ADDR100 100 - -#define TEST_ALIGN16 16 -#define TEST_ALIGN1024 1024 -#define TEST_ALIGN4096 4096 - -#define TEST_THRESHOLD10 10 -#define TEST_THRESHOLD3 3 - -const char *FILENAME[] = { - "mf", - NULL -}; +#define TBLOCK_SIZE10 10 +#define TBLOCK_SIZE11 11 +#define TBLOCK_SIZE20 20 +#define TBLOCK_SIZE30 30 +#define TBLOCK_SIZE36 36 +#define TBLOCK_SIZE40 40 +#define TBLOCK_SIZE50 50 +#define TBLOCK_SIZE80 80 +#define TBLOCK_SIZE90 90 +#define TBLOCK_SIZE98 98 +#define TBLOCK_SIZE100 100 +#define TBLOCK_SIZE150 150 +#define TBLOCK_SIZE200 200 +#define TBLOCK_SIZE600 600 +#define TBLOCK_SIZE700 700 +#define TBLOCK_SIZE1034 1034 +#define TBLOCK_SIZE1970 1970 +#define TBLOCK_SIZE2048 2048 +#define TBLOCK_SIZE2058 2058 +#define TBLOCK_SIZE2192 2192 +#define TBLOCK_SIZE3080 3080 +#define TBLOCK_SIZE3088 3088 +#define TBLOCK_SIZE3198 3198 +#define TBLOCK_SIZE3286 3286 +#define TBLOCK_SIZE3248 3248 +#define TBLOCK_SIZE3900 3900 +#define TBLOCK_SIZE4020 4020 +#define TBLOCK_SIZE4086 4086 +#define TBLOCK_SIZE4096 4096 +#define TBLOCK_SIZE4106 4106 +#define TBLOCK_SIZE5000 5000 +#define TBLOCK_SIZE6000 6000 +#define TBLOCK_SIZE8000 8000 +#define TBLOCK_SIZE8100 8100 +#define TBLOCK_SIZE8192 8192 +#define TBLOCK_SIZE8190 8190 +#define TBLOCK_SIZE12000 12000 + +#define TBLOCK_ADDR70 70 +#define TBLOCK_ADDR100 100 + +#define TEST_ALIGN16 16 +#define TEST_ALIGN1024 1024 +#define TEST_ALIGN4096 4096 + +#define TEST_THRESHOLD10 10 +#define TEST_THRESHOLD3 3 + +const char *FILENAME[] = {"mf", NULL}; typedef enum { - TEST_NORMAL, /* size of aggregator is >= alignment size */ - TEST_AGGR_SMALL, /* size of aggregator is smaller than alignment size */ - TEST_NTESTS /* The number of test types, must be last */ + TEST_NORMAL, /* size of aggregator is >= alignment size */ + TEST_AGGR_SMALL, /* size of aggregator is smaller than alignment size */ + TEST_NTESTS /* The number of test types, must be last */ } test_type_t; static int check_stats(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *state); @@ -161,41 +158,41 @@ static unsigned test_page_alignment(const char *env_h5_drvr, hid_t fapl); static int check_stats(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *state) { - H5FS_stat_t frspace_stats; /* Statistics about the heap */ + H5FS_stat_t frspace_stats; /* Statistics about the heap */ HDassert(f); HDassert(frsp); /* Get statistics for free-space and verify they are correct */ - if(H5FS_stat_info(f, frsp, &frspace_stats) < 0) + if (H5FS_stat_info(f, frsp, &frspace_stats) < 0) FAIL_STACK_ERROR - if(frspace_stats.tot_space != state->tot_space) { - HDfprintf(stdout, "frspace_stats.tot_space = %Hu, state->tot_space = %Zu\n", - frspace_stats.tot_space, state->tot_space); + if (frspace_stats.tot_space != state->tot_space) { + HDfprintf(stdout, "frspace_stats.tot_space = %Hu, state->tot_space = %Zu\n", frspace_stats.tot_space, + state->tot_space); TEST_ERROR } /* end if */ - if(frspace_stats.tot_sect_count != state->tot_sect_count) { + if (frspace_stats.tot_sect_count != state->tot_sect_count) { HDfprintf(stdout, "frspace_stats.tot_sect_count = %Hu, state->tot_sect_count = %Hu\n", frspace_stats.tot_sect_count, state->tot_sect_count); TEST_ERROR } /* end if */ - if(frspace_stats.serial_sect_count != state->serial_sect_count) { + if (frspace_stats.serial_sect_count != state->serial_sect_count) { HDfprintf(stdout, "frspace_stats.serial_sect_count = %Hu, state->serial_sect_count = %Hu\n", frspace_stats.serial_sect_count, state->serial_sect_count); TEST_ERROR } /* end if */ - if(frspace_stats.ghost_sect_count != state->ghost_sect_count) { + if (frspace_stats.ghost_sect_count != state->ghost_sect_count) { HDfprintf(stdout, "frspace_stats.ghost_sect_count = %Hu, state->ghost_sect_count = %Hu\n", frspace_stats.ghost_sect_count, state->ghost_sect_count); TEST_ERROR } /* end if */ /* All tests passed */ - return(0); + return (0); error: - return(1); + return (1); } /* check_stats() */ /* @@ -212,16 +209,16 @@ error: static unsigned test_mf_eoa(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t fapl_new = -1; /* copy of fapl */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* file size */ - H5FD_mem_t type; + hid_t file = -1; /* File ID */ + hid_t fapl_new = -1; /* copy of fapl */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* file size */ + H5FD_mem_t type; haddr_t addr1, addr2; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF; - hsize_t ma_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MM_alloc() of file allocation"); @@ -229,22 +226,23 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) * type of metadata allocation. */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_new = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Turn off using meta/small data aggregator */ @@ -252,16 +250,16 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) H5Pset_small_data_block_size(fapl_new, (hsize_t)0); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* nothing should be changed in meta_aggr */ @@ -282,40 +280,40 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) if (addr2 < (haddr_t)file_size) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TBLOCK_SIZE30+TBLOCK_SIZE50)) + if (new_file_size != (file_size + TBLOCK_SIZE30 + TBLOCK_SIZE50)) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30); H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE50); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR - if(H5Pclose(fapl_new) < 0) + if (H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR PASSED(); @@ -325,14 +323,16 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support continuous address space"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_new); - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_mf_eoa() */ /* @@ -357,16 +357,16 @@ error: static unsigned test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t fapl_new = -1; /* copy of fapl */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size = 0, new_file_size; /* file size */ - H5FD_mem_t type; - haddr_t addr = 0; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hid_t file = -1; /* File ID */ + hid_t fapl_new = -1; /* copy of fapl */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size = 0, new_file_size; /* file size */ + H5FD_mem_t type; + haddr_t addr = 0; + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_try_shrink() of file allocation: test 1"); @@ -374,22 +374,23 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) * type of metadata allocation. */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_new = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Turn off using meta/small data aggregator */ @@ -397,11 +398,11 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) H5Pset_small_data_block_size(fapl_new, (hsize_t)0); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -414,50 +415,52 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) /* nothing should be changed in meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != ma_addr) TEST_ERROR - if (new_ma_size != ma_size) TEST_ERROR + if (new_ma_addr != ma_addr) + TEST_ERROR + if (new_ma_size != ma_size) + TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TBLOCK_SIZE30)) + if (new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); /* should succeed */ - if(H5MF_try_shrink(f, type, addr, (hsize_t)TBLOCK_SIZE30) <= 0) + if (H5MF_try_shrink(f, type, addr, (hsize_t)TBLOCK_SIZE30) <= 0) TEST_ERROR /* nothing should be changed in meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size); - if(new_ma_addr != ma_addr) + if (new_ma_addr != ma_addr) TEST_ERROR - if(new_ma_size != ma_size) + if (new_ma_size != ma_size) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR PASSED(); @@ -472,13 +475,13 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) /* Skip test when using VFDs that has different address spaces for each * type of metadata allocation. */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -489,23 +492,25 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* should not succeed in shrinking */ - if(H5MF_try_shrink(f, type, addr, (hsize_t)TBLOCK_SIZE30 - 10) > 0) + if (H5MF_try_shrink(f, type, addr, (hsize_t)TBLOCK_SIZE30 - 10) > 0) TEST_ERROR /* nothing should be changed in meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size); - if (new_ma_addr != ma_addr) TEST_ERROR - if (new_ma_size != ma_size) TEST_ERROR + if (new_ma_addr != ma_addr) + TEST_ERROR + if (new_ma_size != ma_size) + TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + TBLOCK_SIZE30)) + if (new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR PASSED(); @@ -515,41 +520,42 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - TESTING("H5MF_try_shrink() of file allocation: test 3"); /* Skip test when using VFDs that has different address spaces for each * type of metadata allocation. */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); /* should not succeed in shrinking */ - if(H5MF_try_shrink(f, type, addr, (hsize_t)TBLOCK_SIZE30 + 10) > 0) + if (H5MF_try_shrink(f, type, addr, (hsize_t)TBLOCK_SIZE30 + 10) > 0) TEST_ERROR /* nothing should be changed in meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size); - if (new_ma_addr != ma_addr) TEST_ERROR - if (new_ma_size != ma_size) TEST_ERROR + if (new_ma_addr != ma_addr) + TEST_ERROR + if (new_ma_size != ma_size) + TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + TBLOCK_SIZE30)) + if (new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR PASSED(); @@ -564,40 +570,40 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) /* Skip test when using VFDs that has different address spaces for each * type of metadata allocation. */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); /* should succeed in shrinking */ - if(H5MF_try_shrink(f, type, addr+10, (hsize_t)(TBLOCK_SIZE30 - 10)) <= 0) + if (H5MF_try_shrink(f, type, addr + 10, (hsize_t)(TBLOCK_SIZE30 - 10)) <= 0) TEST_ERROR /* nothing should be changed in meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size); - if(new_ma_addr != ma_addr) + if (new_ma_addr != ma_addr) TEST_ERROR - if(new_ma_size != ma_size) + if (new_ma_size != ma_size) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + 10)) + if (new_file_size != (file_size + 10)) TEST_ERROR - if(H5Pclose(fapl_new) < 0) + if (H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR PASSED(); @@ -607,14 +613,16 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_new); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_eoa_shrink() */ /* @@ -635,17 +643,17 @@ error: static unsigned test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t fapl_new = -1; /* copy of fapl */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* File size */ - H5FD_mem_t type; + hid_t file = -1; /* File ID */ + hid_t fapl_new = -1; /* copy of fapl */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* File size */ + H5FD_mem_t type; haddr_t addr; - htri_t was_extended; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + htri_t was_extended; + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_try_extend() of file allocation: test 1"); @@ -653,36 +661,37 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) * type of metadata allocation. */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_new = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Turn off using meta/small data aggregator */ - if(H5Pset_meta_block_size(fapl_new, (hsize_t)0) < 0) + if (H5Pset_meta_block_size(fapl_new, (hsize_t)0) < 0) FAIL_STACK_ERROR - if(H5Pset_small_data_block_size(fapl_new, (hsize_t)0) < 0) + if (H5Pset_small_data_block_size(fapl_new, (hsize_t)0) < 0) FAIL_STACK_ERROR /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -697,29 +706,30 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) if (new_ma_addr != ma_addr) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + TBLOCK_SIZE30)) + if (new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* should succeed */ - was_extended = H5MF_try_extend(f, type, (haddr_t)addr, (hsize_t)TBLOCK_SIZE30, (hsize_t)TBLOCK_SIZE50); + was_extended = + H5MF_try_extend(f, type, (haddr_t)addr, (hsize_t)TBLOCK_SIZE30, (hsize_t)TBLOCK_SIZE50); - if(was_extended <= 0) + if (was_extended <= 0) TEST_ERROR /* nothing should be changed in meta_aggr */ @@ -727,15 +737,15 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) if (new_ma_addr != ma_addr) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size + TBLOCK_SIZE30 + TBLOCK_SIZE50)) + if (new_file_size != (file_size + TBLOCK_SIZE30 + TBLOCK_SIZE50)) TEST_ERROR PASSED(); @@ -750,17 +760,17 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) /* Skip test when using VFDs that has different address spaces for each * type of metadata allocation. */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -768,18 +778,19 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) type = H5FD_MEM_SUPER; addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); - if(addr < (haddr_t)file_size) + if (addr < (haddr_t)file_size) TEST_ERROR /* nothing should be changed in meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if(new_ma_addr != ma_addr) + if (new_ma_addr != ma_addr) TEST_ERROR - was_extended = H5MF_try_extend(f, type, (haddr_t)addr, (hsize_t)(TBLOCK_SIZE30-10), (hsize_t)(TBLOCK_SIZE50)); + was_extended = + H5MF_try_extend(f, type, (haddr_t)addr, (hsize_t)(TBLOCK_SIZE30 - 10), (hsize_t)(TBLOCK_SIZE50)); /* should not succeed */ - if(was_extended > 0) + if (was_extended > 0) TEST_ERROR /* nothing should be changed in meta_aggr */ @@ -787,18 +798,18 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) if (new_ma_addr != ma_addr) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size + TBLOCK_SIZE30) + if (new_file_size != file_size + TBLOCK_SIZE30) TEST_ERROR - if(H5Pclose(fapl_new) < 0) + if (H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR PASSED(); @@ -808,14 +819,16 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_new); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_eoa_extend() */ /* @@ -844,159 +857,168 @@ error: static unsigned test_mf_tmp(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - hid_t file = -1; /* File ID */ - hid_t fapl2 = -1; /* File access property list */ - hid_t fcpl = -1; /* File creation property list */ + hid_t file = -1; /* File ID */ + hid_t fapl2 = -1; /* File access property list */ + hid_t fcpl = -1; /* File creation property list */ - if(new_format) + if (new_format) TESTING("'temporary' file space allocation with new library format") else TESTING("'temporary' file space allocation with old library format") /* Can't run this test with multi-file VFDs */ - if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* file size */ - haddr_t maxaddr; /* File's max. address */ - haddr_t tmp_addr; /* Temporary space file address */ - haddr_t norm_addr; /* Normal space file address */ - haddr_t check_addr; /* File address for checking for errors */ - unsigned char buf = 0; /* Buffer to read/write with */ - herr_t status; /* Generic status value */ + if (HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* file size */ + haddr_t maxaddr; /* File's max. address */ + haddr_t tmp_addr; /* Temporary space file address */ + haddr_t norm_addr; /* Normal space file address */ + haddr_t check_addr; /* File address for checking for errors */ + unsigned char buf = 0; /* Buffer to read/write with */ + herr_t status; /* Generic status value */ /* Set the filename to use for this test */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR - if(new_format) { + if (new_format) { /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); } /* end if */ /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, new_format?fapl2:fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, new_format ? fapl2 : fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Retrieve the file's maxaddr */ - if(H5F__get_maxaddr_test(file, &maxaddr) < 0) + if (H5F__get_maxaddr_test(file, &maxaddr) < 0) FAIL_STACK_ERROR /* Allocate some temporary address space */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)TBLOCK_SIZE30))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)TBLOCK_SIZE30))) FAIL_STACK_ERROR /* Check if temporary file address is valid */ - if(!H5F_IS_TMP_ADDR(f, tmp_addr)) + if (!H5F_IS_TMP_ADDR(f, tmp_addr)) TEST_ERROR - if(tmp_addr < (haddr_t)(maxaddr - TBLOCK_SIZE30)) + if (tmp_addr < (haddr_t)(maxaddr - TBLOCK_SIZE30)) TEST_ERROR /* Reading & writing with a temporary address value should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5F_block_read(f, H5FD_MEM_SUPER, tmp_addr, sizeof(buf), &buf); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5F_block_write(f, H5FD_MEM_SUPER, tmp_addr, sizeof(buf), &buf); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) TEST_ERROR /* Freeing a temporary address value should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5MF_xfree(f, H5FD_MEM_SUPER, tmp_addr, (hsize_t)TBLOCK_SIZE30); - } H5E_END_TRY; - if(status >= 0) + } + H5E_END_TRY; + if (status >= 0) TEST_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 1/3 of the file as temporary address space */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3)))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3)))) FAIL_STACK_ERROR - if(!H5F_IS_TMP_ADDR(f, tmp_addr)) + if (!H5F_IS_TMP_ADDR(f, tmp_addr)) TEST_ERROR /* Allocate 1/3 of the file as normal address space */ - if(HADDR_UNDEF == (norm_addr = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)(maxaddr / 3)))) + if (HADDR_UNDEF == (norm_addr = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)(maxaddr / 3)))) FAIL_STACK_ERROR - if(H5F_IS_TMP_ADDR(f, norm_addr)) + if (H5F_IS_TMP_ADDR(f, norm_addr)) TEST_ERROR /* Test that pushing temporary space allocation into normal space fails */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { check_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3)); - } H5E_END_TRY; - if(H5F_addr_defined(check_addr)) + } + H5E_END_TRY; + if (H5F_addr_defined(check_addr)) TEST_ERROR /* Test that pushing normal space allocation into temporary space fails */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { check_addr = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)(maxaddr / 3)); - } H5E_END_TRY; - if(H5F_addr_defined(check_addr)) + } + H5E_END_TRY; + if (H5F_addr_defined(check_addr)) TEST_ERROR /* Free the normal block (so the file doesn't blow up to a huge size) */ - if(H5MF_xfree(f, H5FD_MEM_DRAW, norm_addr, (hsize_t)(maxaddr / 3)) < 0) + if (H5MF_xfree(f, H5FD_MEM_DRAW, norm_addr, (hsize_t)(maxaddr / 3)) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR PASSED(); @@ -1006,13 +1028,15 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) HDputs(" Current VFD doesn't support continuous address space"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_tmp() */ /* @@ -1026,31 +1050,31 @@ error: static unsigned test_mf_fs_start(hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t fapl_new = -1; /* copy of fapl */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* file size */ - H5FS_stat_t state; - + hid_t file = -1; /* File ID */ + hid_t fapl_new = -1; /* copy of fapl */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* file size */ + H5FS_stat_t state; TESTING("H5MF_create_fstype()/H5MF__open_fstype() of free-space manager"); /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_new = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Turn off using meta/small data aggregator */ @@ -1058,54 +1082,55 @@ test_mf_fs_start(hid_t fapl) H5Pset_small_data_block_size(fapl_new, (hsize_t)0); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR - if(H5Pclose(fapl_new) < 0) + if (H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_new); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_fs_start() */ - /* *------------------------------------------------------------------------- * To verify that a block is allocated/freed from/to the free-space manager @@ -1136,33 +1161,34 @@ error: static unsigned test_mf_fs_alloc_free(hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t fapl_new = -1; /* copy of fapl */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* file size */ + hid_t file = -1; /* File ID */ + hid_t fapl_new = -1; /* copy of fapl */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* file size */ H5MF_free_section_t *sect_node = NULL; - haddr_t addr; - haddr_t tmp; - H5FS_stat_t state; + haddr_t addr; + haddr_t tmp; + H5FS_stat_t state; TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 1"); /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_new = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Turn off using meta/small data aggregator */ @@ -1170,27 +1196,27 @@ test_mf_fs_alloc_free(hid_t fapl) H5Pset_small_data_block_size(fapl_new, (hsize_t)0); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ sect_node = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -1198,21 +1224,21 @@ test_mf_fs_alloc_free(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 30 */ addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is section A in free-space */ - if(addr != TBLOCK_ADDR70) + if (addr != TBLOCK_ADDR70) TEST_ERROR state.tot_space -= TBLOCK_SIZE30; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block to free-space */ @@ -1221,21 +1247,22 @@ test_mf_fs_alloc_free(hid_t fapl) state.tot_space += TBLOCK_SIZE30; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove section A from free-space */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != + TRUE) TEST_ERROR - if(tmp != TBLOCK_ADDR70) + if (tmp != TBLOCK_ADDR70) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ @@ -1247,27 +1274,27 @@ test_mf_fs_alloc_free(hid_t fapl) TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 2"); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ sect_node = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); - /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + /* Add section A to free-space manager */ + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -1275,20 +1302,20 @@ test_mf_fs_alloc_free(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 20 */ addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE20)); /* Verify that the allocated block is section A in free-space manager */ - if(addr != TBLOCK_ADDR70) + if (addr != TBLOCK_ADDR70) TEST_ERROR /* should still have 1 section of size 10 left in free-space manager */ state.tot_space -= (TBLOCK_SIZE20); - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block to free-space manager */ @@ -1296,21 +1323,22 @@ test_mf_fs_alloc_free(hid_t fapl) /* Still 1 section in free-space because of merging */ state.tot_space += TBLOCK_SIZE20; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove section A from free-space */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != + TRUE) TEST_ERROR - if(tmp != TBLOCK_ADDR70) + if (tmp != TBLOCK_ADDR70) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ @@ -1322,27 +1350,27 @@ test_mf_fs_alloc_free(hid_t fapl) TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 3"); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ sect_node = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -1350,7 +1378,7 @@ test_mf_fs_alloc_free(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* @@ -1361,23 +1389,24 @@ test_mf_fs_alloc_free(hid_t fapl) addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE40)); /* Verify that the allocated block is not section A in free-space */ - if(addr == TBLOCK_ADDR70) + if (addr == TBLOCK_ADDR70) TEST_ERROR /* free-space info should be the same */ - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove section A from free-space */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != + TRUE) TEST_ERROR /* Verify that the block is section A in free-space */ - if(tmp != TBLOCK_ADDR70) + if (tmp != TBLOCK_ADDR70) TEST_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block of size 40 to free-space */ @@ -1388,36 +1417,37 @@ test_mf_fs_alloc_free(hid_t fapl) * The block is returned to free-space. * It is shrunk and freed because it is at end of file. */ - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR - if(H5Pclose(fapl_new) < 0) + if (H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_new); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_fs_alloc_free() */ - /* *------------------------------------------------------------------------- * To verify that a block allocated from the free-space manager can be extended @@ -1460,34 +1490,35 @@ error: static unsigned test_mf_fs_extend(hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t fapl_new = -1; /* copy of fapl */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* file size */ - H5MF_free_section_t *sect_node1 = NULL, *sect_node2=NULL; - haddr_t addr; - haddr_t tmp; - H5FS_stat_t state; /* State of free space*/ - htri_t was_extended; + hid_t file = -1; /* File ID */ + hid_t fapl_new = -1; /* copy of fapl */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* file size */ + H5MF_free_section_t *sect_node1 = NULL, *sect_node2 = NULL; + haddr_t addr; + haddr_t tmp; + H5FS_stat_t state; /* State of free space*/ + htri_t was_extended; TESTING("H5MF_try_extend() of free-space manager:test 1"); /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_new = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Turn off using meta/small data aggregator */ @@ -1495,27 +1526,27 @@ test_mf_fs_extend(hid_t fapl) H5Pset_small_data_block_size(fapl_new, (hsize_t)0); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ sect_node1 = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -1523,42 +1554,43 @@ test_mf_fs_extend(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 30 */ addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is section A in free-space manager */ - if(addr != TBLOCK_ADDR70) + if (addr != TBLOCK_ADDR70) TEST_ERROR state.tot_space -= TBLOCK_SIZE30; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Create section B */ sect_node2 = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR100, (hsize_t)TBLOCK_SIZE50); /* Add section B to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) FAIL_STACK_ERROR state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Try to extend the allocated block */ - was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, (hsize_t)TBLOCK_SIZE50); + was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, + (hsize_t)TBLOCK_SIZE50); /* should succeed */ - if(was_extended <= 0) + if (was_extended <= 0) TEST_ERROR /* Section B is removed from free-space manager */ @@ -1566,32 +1598,33 @@ test_mf_fs_extend(hid_t fapl) state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the extended block to free-space manager */ - H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50)); + H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)(TBLOCK_SIZE30 + TBLOCK_SIZE50)); /* Verify that the extended block is back into free-space */ - state.tot_space += (TBLOCK_SIZE30+TBLOCK_SIZE50); - state.tot_sect_count = 1; + state.tot_space += (TBLOCK_SIZE30 + TBLOCK_SIZE50); + state.tot_sect_count = 1; state.serial_sect_count = 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove the extended block */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30 + TBLOCK_SIZE50), + f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) TEST_ERROR - if(tmp != TBLOCK_ADDR70) + if (tmp != TBLOCK_ADDR70) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ @@ -1603,27 +1636,27 @@ test_mf_fs_extend(hid_t fapl) TESTING("H5MF_try_extend() of free-space manager:test 2"); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ sect_node1 = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -1631,46 +1664,47 @@ test_mf_fs_extend(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 30 */ addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is section A in free-space manager */ - if(addr != TBLOCK_ADDR70) + if (addr != TBLOCK_ADDR70) TEST_ERROR state.tot_space -= TBLOCK_SIZE30; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Create section B */ sect_node2 = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR100, (hsize_t)TBLOCK_SIZE50); /* Add section B to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) FAIL_STACK_ERROR state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Try to extend the allocated block */ - was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, (hsize_t)(TBLOCK_SIZE50+10)); + was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, + (hsize_t)(TBLOCK_SIZE50 + 10)); /* Should not be able to extend the allocated block */ - if(was_extended) + if (was_extended) TEST_ERROR /* free-space info should remain the same */ - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the allocated block A to free-space */ @@ -1680,20 +1714,22 @@ test_mf_fs_extend(hid_t fapl) /* rest of the info remains the same */ state.tot_space += TBLOCK_SIZE30; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove the merged sections A & B from free-space */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30 + TBLOCK_SIZE50), + f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) TEST_ERROR - if(tmp != addr) TEST_ERROR + if (tmp != addr) + TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ @@ -1705,27 +1741,27 @@ test_mf_fs_extend(hid_t fapl) TESTING("H5MF_try_extend() of free-space manager:test 3"); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ sect_node1 = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30); /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -1733,69 +1769,72 @@ test_mf_fs_extend(hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 30 */ addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is section A in free-space manager */ - if(addr != TBLOCK_ADDR70) + if (addr != TBLOCK_ADDR70) TEST_ERROR state.tot_space -= TBLOCK_SIZE30; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Create section B */ sect_node2 = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR100, (hsize_t)TBLOCK_SIZE50); /* Add section B to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) FAIL_STACK_ERROR state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Try to extend the allocated block */ - was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, (hsize_t)(TBLOCK_SIZE40)); + was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE30, + (hsize_t)(TBLOCK_SIZE40)); /* Should succeed in extending the allocated block */ - if(was_extended <=0) + if (was_extended <= 0) TEST_ERROR /* Should have 1 section of size=10 left in free-space manager */ state.tot_space -= (TBLOCK_SIZE40); - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the extended block */ - H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE40)); + H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)(TBLOCK_SIZE30 + TBLOCK_SIZE40)); /* rest info is same, the extended section returned is merged with the section in free-space */ - state.tot_space += (TBLOCK_SIZE30+TBLOCK_SIZE40); + state.tot_space += (TBLOCK_SIZE30 + TBLOCK_SIZE40); - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove the merged sections A & B from free-space */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30 + TBLOCK_SIZE50), + f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) TEST_ERROR - if(tmp != addr) TEST_ERROR + if (tmp != addr) + TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ @@ -1807,120 +1846,127 @@ test_mf_fs_extend(hid_t fapl) TESTING("H5MF_try_extend() of free-space manager:test 4"); /* Re-open the file with meta/small data setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ - sect_node1 = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)(TBLOCK_SIZE30-10)); + sect_node1 = + H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)(TBLOCK_SIZE30 - 10)); /* Add section A of size=20 to free-space */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node1)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); - state.tot_space += (TBLOCK_SIZE30-10); + state.tot_space += (TBLOCK_SIZE30 - 10); state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of size=20 */ - addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30-10)); + addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30 - 10)); /* Verify that the allocated block is section A in free-space manager */ - if(addr != TBLOCK_ADDR70) + if (addr != TBLOCK_ADDR70) TEST_ERROR - state.tot_space -= (TBLOCK_SIZE30-10); + state.tot_space -= (TBLOCK_SIZE30 - 10); state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Create section B */ sect_node2 = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR100, (hsize_t)TBLOCK_SIZE50); /* Add section B to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node2)) FAIL_STACK_ERROR state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Try to extend the allocated block */ - was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)(TBLOCK_SIZE30-10), (hsize_t)TBLOCK_SIZE50); + was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)TBLOCK_ADDR70, (hsize_t)(TBLOCK_SIZE30 - 10), + (hsize_t)TBLOCK_SIZE50); /* Should not succeed in extending the allocated block */ - if(was_extended) + if (was_extended) TEST_ERROR /* Free-space info should be the same */ - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the allocated block */ - H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)(TBLOCK_SIZE30-10)); + H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)(TBLOCK_SIZE30 - 10)); - state.tot_space += (TBLOCK_SIZE30-10); + state.tot_space += (TBLOCK_SIZE30 - 10); state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Remove section A from free-space manger */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30-10), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE30 - 10), f->shared->fs_man[H5FD_MEM_SUPER], + &tmp) != TRUE) TEST_ERROR - if(tmp != addr) TEST_ERROR + if (tmp != addr) + TEST_ERROR /* Remove section B from free-space manager */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE50, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE50, f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != + TRUE) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl_new)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR - if(H5Pclose(fapl_new) < 0) + if (H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_new); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_fs_extend() */ /* @@ -1952,47 +1998,47 @@ error: static unsigned test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - haddr_t addr, saddr; - haddr_t tmp; - haddr_t ma_addr=HADDR_UNDEF; - hsize_t ma_size=0; - H5MF_free_section_t *sect_node=NULL; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + haddr_t addr, saddr; + haddr_t tmp; + haddr_t ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0; + H5MF_free_section_t *sect_node = NULL; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("A free-space section absorbs an aggregator: test 1"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Allocate a section from meta_aggr */ @@ -2000,18 +2046,21 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - /* Create a section */ - sect_node = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)(ma_addr+ma_size), (hsize_t)TBLOCK_SIZE2048); + /* Create a section */ + sect_node = + H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)(ma_addr + ma_size), (hsize_t)TBLOCK_SIZE2048); /* Add a section to free-space that adjoins end of the aggregator */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) - FAIL_STACK_ERROR + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + FAIL_STACK_ERROR /* Verify that the section did absorb the aggregator */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(ma_addr+ma_size), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(ma_addr + ma_size), + f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) TEST_ERROR - if(tmp != ma_addr) TEST_ERROR + if (tmp != ma_addr) + TEST_ERROR /* Restore info for aggregator */ f->shared->meta_aggr.addr = ma_addr; @@ -2020,7 +2069,7 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) /* Remove section from meta_aggr */ H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)TBLOCK_SIZE30); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2033,22 +2082,22 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) TESTING("A free-space section absorbs an aggregator: test 2"); /* Skip test when using VFDs that don't use the metadata aggregator */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Allocate a section from meta_aggr */ @@ -2062,14 +2111,15 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) sect_node = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)addr, (hsize_t)TBLOCK_SIZE30); /* When adding, meta_aggr is absorbed onto the end of the section */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) FAIL_STACK_ERROR /* Verify that the section did absorb the aggregator */ - if(H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(ma_size+TBLOCK_SIZE30), f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) + if (H5MF__find_sect(f, H5FD_MEM_SUPER, (hsize_t)(ma_size + TBLOCK_SIZE30), + f->shared->fs_man[H5FD_MEM_SUPER], &tmp) != TRUE) TEST_ERROR - if((tmp + TBLOCK_SIZE30) != ma_addr) + if ((tmp + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* restore info to meta_aggr */ @@ -2081,7 +2131,7 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) /* Remove section from sdata_aggr */ H5MF_xfree(f, H5FD_MEM_DRAW, saddr, (hsize_t)TBLOCK_SIZE50); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -2091,13 +2141,15 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_fs_absorb() */ /* @@ -2121,109 +2173,109 @@ error: static unsigned test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - hid_t fcpl; /* File creation property list */ - h5_stat_size_t file_size, new_file_size; /* file size */ - H5FD_mem_t type; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + hid_t fcpl; /* File creation property list */ + h5_stat_size_t file_size, new_file_size; /* file size */ + H5FD_mem_t type; haddr_t addr1, addr2; - haddr_t ma_addr=HADDR_UNDEF; - hsize_t ma_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator:test 1"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* File creation property list template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR /* Set to H5F_FSPACE_STRATEGY_AGGR strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) TEST_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* Get the size of a file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) TEST_ERROR /* Allocate first block from meta_aggr */ type = H5FD_MEM_SUPER; - if((addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30)) == HADDR_UNDEF) + if ((addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30)) == HADDR_UNDEF) TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate second block from meta_aggr */ - if((addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50)) == HADDR_UNDEF) + if ((addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50)) == HADDR_UNDEF) TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr2+TBLOCK_SIZE50) != ma_addr) + if ((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR - if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) + if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != (file_size+TBLOCK_SIZE30+TBLOCK_SIZE50)) + if (new_file_size != (file_size + TBLOCK_SIZE30 + TBLOCK_SIZE50)) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) TEST_ERROR /* Free the two blocks: order matters because of H5F_FSPACE_STRATEGY_AGGR strategy */ - if(H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE50) < 0) + if (H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE50) < 0) TEST_ERROR - if(H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30) < 0) + if (H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30) < 0) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ if (new_file_size != file_size) TEST_ERROR - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) TEST_ERROR PASSED(); @@ -2233,14 +2285,16 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); H5Pclose(fcpl); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_alloc1() */ /* @@ -2271,55 +2325,55 @@ error: static unsigned test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* file size */ - H5FD_mem_t type; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* file size */ + H5FD_mem_t type; haddr_t addr1, addr2, addr3; - haddr_t ma_addr=HADDR_UNDEF; - hsize_t ma_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator:test 2"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of a file */ - if((file_size= h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr2+TBLOCK_SIZE50) != ma_addr) + if ((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) @@ -2329,39 +2383,39 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr3+TBLOCK_SIZE2058) != ma_addr) + if ((addr3 + TBLOCK_SIZE2058) != ma_addr) TEST_ERROR - if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) + if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ /* Unused space is freed from the end of the file */ - if(new_file_size != (file_size+TBLOCK_SIZE30+TBLOCK_SIZE50+TBLOCK_SIZE2058)) + if (new_file_size != (file_size + TBLOCK_SIZE30 + TBLOCK_SIZE50 + TBLOCK_SIZE2058)) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR - H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30+TBLOCK_SIZE50+TBLOCK_SIZE2058); + H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30 + TBLOCK_SIZE50 + TBLOCK_SIZE2058); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ @@ -2375,13 +2429,15 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_alloc2() */ /* @@ -2425,52 +2481,52 @@ error: static unsigned test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* file size */ - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* file size */ + H5FD_mem_t type, stype; haddr_t addr1, addr2, addr3, addr4, saddr1; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0; - haddr_t sdata_addr=HADDR_UNDEF; - hsize_t sdata_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0; + haddr_t sdata_addr = HADDR_UNDEF; + hsize_t sdata_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator: test 3"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate second block from meta_aggr */ @@ -2478,18 +2534,19 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr2+TBLOCK_SIZE50) != ma_addr) + if ((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR - if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) + if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR /* Allocate first block from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if((saddr1+TBLOCK_SIZE30) != sdata_addr) + if ((saddr1 + TBLOCK_SIZE30) != sdata_addr) + TEST_ERROR + if (sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR - if(sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR /* Allocate third block, which is from file allocation not from meta_aggr */ addr3 = H5MF_alloc(f, type, (hsize_t)(TBLOCK_SIZE2058)); @@ -2497,17 +2554,20 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); /* info for meta_aggr shouldn't be changed */ - if(addr3 != (sdata_addr+sdata_size)) TEST_ERROR - if((addr3+TBLOCK_SIZE2058) == new_ma_addr) TEST_ERROR - if((new_ma_addr != ma_addr) || (new_ma_size != ma_size)) TEST_ERROR + if (addr3 != (sdata_addr + sdata_size)) + TEST_ERROR + if ((addr3 + TBLOCK_SIZE2058) == new_ma_addr) + TEST_ERROR + if ((new_ma_addr != ma_addr) || (new_ma_size != ma_size)) + TEST_ERROR /* Allocate fourth block, which should be from meta_aggr */ addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr4+TBLOCK_SIZE50) != ma_addr) + if ((addr4 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR - if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50 + TBLOCK_SIZE50))) + if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50 + TBLOCK_SIZE50))) TEST_ERROR /* Free all the allocated blocks */ @@ -2517,15 +2577,15 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, type, addr4, (hsize_t)TBLOCK_SIZE50); H5MF_xfree(f, stype, saddr1, (hsize_t)TBLOCK_SIZE30); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR PASSED(); @@ -2535,16 +2595,17 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_alloc3() */ - /* *------------------------------------------------------------------------- * To verify that blocks are allocated from the aggregator @@ -2590,91 +2651,91 @@ error: static unsigned test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* File size */ - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* File size */ + H5FD_mem_t type, stype; haddr_t addr1, addr2, saddr1, saddr2, saddr3; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0, sdata_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0, sdata_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator:test 4"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR - if(ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) + if (ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR /* Allocate first block from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if((saddr1+TBLOCK_SIZE30) != sdata_addr) + if ((saddr1 + TBLOCK_SIZE30) != sdata_addr) TEST_ERROR /* Allocate second block from sdata_aggr */ saddr2 = H5MF_alloc(f, stype, (hsize_t)(TBLOCK_SIZE2048 - TBLOCK_SIZE30)); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if(saddr2+(TBLOCK_SIZE2048 - TBLOCK_SIZE30) != sdata_addr) + if (saddr2 + (TBLOCK_SIZE2048 - TBLOCK_SIZE30) != sdata_addr) TEST_ERROR /* Allocate third block from sdata_aggr */ saddr3 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if((saddr3+TBLOCK_SIZE50) != sdata_addr) + if ((saddr3 + TBLOCK_SIZE50) != sdata_addr) TEST_ERROR - if(sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE50)) + if (sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE50)) TEST_ERROR /* Allocate second block of 2058, which is from file allocation, not from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2058); - if(addr2 != sdata_addr) + if (addr2 != sdata_addr) TEST_ERROR /* sdata_aggr is reset 0 */ H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if((sdata_addr != 0) && (sdata_size != 0)) + if ((sdata_addr != 0) && (sdata_size != 0)) TEST_ERROR /* info is unchanged in meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if((new_ma_addr != ma_addr) && (new_ma_size != ma_size)) + if ((new_ma_addr != ma_addr) && (new_ma_size != ma_size)) TEST_ERROR /* Free all the allocated blocks */ @@ -2684,15 +2745,15 @@ test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, stype, saddr2, (hsize_t)TBLOCK_SIZE2048 - TBLOCK_SIZE30); H5MF_xfree(f, stype, saddr3, (hsize_t)TBLOCK_SIZE50); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR PASSED(); @@ -2702,13 +2763,15 @@ test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_alloc4() */ /* @@ -2729,77 +2792,78 @@ error: * * Allocate third block (1970) from meta_aggr: * request-size is > what is left in meta_aggr and is < meta_aggr->alloc_size - * Result: A block of meta_aggr->alloc_size is extended via file allocation and is absorbed into the meta_aggr - * The block of 1970 is allocated from there - * There is space of 2046 left in meta_aggr + * Result: A block of meta_aggr->alloc_size is extended via file allocation and is absorbed into the + *meta_aggr The block of 1970 is allocated from there There is space of 2046 left in meta_aggr * *------------------------------------------------------------------------- */ static unsigned test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* File size */ - H5FD_mem_t type; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* File size */ + H5FD_mem_t type; haddr_t addr1, addr2, addr3; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator:test 5"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate second block from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if(addr2+TBLOCK_SIZE50 != ma_addr) + if (addr2 + TBLOCK_SIZE50 != ma_addr) TEST_ERROR - if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30+TBLOCK_SIZE50))) + if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR /* Allocate third block from meta_aggr */ addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1970); H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if(addr3 != ma_addr) TEST_ERROR - if((addr3+TBLOCK_SIZE1970) != new_ma_addr) TEST_ERROR - if(new_ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE1970 - ma_size))) + if (addr3 != ma_addr) + TEST_ERROR + if ((addr3 + TBLOCK_SIZE1970) != new_ma_addr) + TEST_ERROR + if (new_ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE1970 - ma_size))) TEST_ERROR /* Free all the allocated blocks */ @@ -2807,15 +2871,15 @@ test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE50); H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE1970); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR PASSED(); @@ -2825,13 +2889,15 @@ test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_alloc5() */ /* @@ -2871,43 +2937,43 @@ error: static unsigned test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; /* file size */ - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; /* file size */ + H5FD_mem_t type, stype; haddr_t addr1, addr2, addr3, saddr1; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0, sdata_size=0; - H5FS_stat_t state; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0, sdata_size = 0; + H5FS_stat_t state; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator:test 6"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -2916,45 +2982,50 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate second block from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if(addr2+TBLOCK_SIZE50 != ma_addr) + if (addr2 + TBLOCK_SIZE50 != ma_addr) TEST_ERROR - if(ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) + if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR /* Allocate first block from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if((saddr1+TBLOCK_SIZE30) != sdata_addr) TEST_ERROR - if(sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR + if ((saddr1 + TBLOCK_SIZE30) != sdata_addr) + TEST_ERROR + if (sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) + TEST_ERROR /* Allocate third block from meta_aggr */ addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1970); H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if((addr3+TBLOCK_SIZE1970) != new_ma_addr) TEST_ERROR - if(addr3 != (sdata_addr+sdata_size)) TEST_ERROR + if ((addr3 + TBLOCK_SIZE1970) != new_ma_addr) + TEST_ERROR + if (addr3 != (sdata_addr + sdata_size)) + TEST_ERROR - if((ma_addr+TBLOCK_SIZE1970) == new_ma_addr) TEST_ERROR - if(new_ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE1970)) + if ((ma_addr + TBLOCK_SIZE1970) == new_ma_addr) + TEST_ERROR + if (new_ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE1970)) TEST_ERROR /* Verify that meta_aggr's unused space of 1968 is freed to free-space */ HDmemset(&state, 0, sizeof(H5FS_stat_t)); - state.tot_space += (TBLOCK_SIZE2048 - (TBLOCK_SIZE30+TBLOCK_SIZE50)); + state.tot_space += (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50)); state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if (check_stats(f, f->shared->fs_man[type], &state)) TEST_ERROR /* Free all the allocated blocks */ @@ -2963,15 +3034,15 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE1970); H5MF_xfree(f, stype, saddr1, (hsize_t)TBLOCK_SIZE30); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((new_file_size = h5_get_file_size(filename, fapl)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(new_file_size != file_size) + if (new_file_size != file_size) TEST_ERROR PASSED(); @@ -2981,13 +3052,15 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_alloc6() */ /* @@ -3038,81 +3111,82 @@ error: static unsigned test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t empty_size, file_size; - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t empty_size, file_size; + H5FD_mem_t type, stype; haddr_t addr1, addr2, addr3, saddr1, saddr2, saddr3; - haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, sdata_size=0; - H5FS_stat_t state; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, sdata_size = 0; + H5FS_stat_t state; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_alloc() of meta/sdata aggregator:test 7"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate the first block from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate the second block from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if (addr2+TBLOCK_SIZE50 != ma_addr) + if (addr2 + TBLOCK_SIZE50 != ma_addr) TEST_ERROR if (ma_size != (TBLOCK_SIZE2048 - (TBLOCK_SIZE30 + TBLOCK_SIZE50))) TEST_ERROR /* Allocate the first block from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr1+TBLOCK_SIZE30) != sdata_addr) + if ((saddr1 + TBLOCK_SIZE30) != sdata_addr) TEST_ERROR /* Allocate the second block from sdata_aggr */ saddr2 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE2048 - TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr2+(TBLOCK_SIZE2048 - TBLOCK_SIZE30)) != sdata_addr) + if ((saddr2 + (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) != sdata_addr) + TEST_ERROR + if (sdata_size != 0) TEST_ERROR - if (sdata_size != 0) TEST_ERROR /* Allocate the third block from sdata_aggr */ saddr3 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if ((saddr3+TBLOCK_SIZE50) != sdata_addr) + if ((saddr3 + TBLOCK_SIZE50) != sdata_addr) TEST_ERROR if (sdata_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE50)) TEST_ERROR @@ -3121,14 +3195,19 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1970); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if (addr3 != sdata_addr) TEST_ERROR - if ((addr3 + TBLOCK_SIZE1970) != ma_addr) TEST_ERROR - if (ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE1970)) TEST_ERROR + if (addr3 != sdata_addr) + TEST_ERROR + if ((addr3 + TBLOCK_SIZE1970) != ma_addr) + TEST_ERROR + if (ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE1970)) + TEST_ERROR /* sdata_aggr info is reset to 0 */ H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != HADDR_UNDEF) TEST_ERROR - if (sdata_size != 0) TEST_ERROR + if (sdata_addr != HADDR_UNDEF) + TEST_ERROR + if (sdata_size != 0) + TEST_ERROR /* Verify that meta_aggr's unused space of 1968 is freed to free-space */ HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -3136,7 +3215,7 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if (check_stats(f, f->shared->fs_man[type], &state)) TEST_ERROR /* Free all the allocated blocks */ @@ -3147,11 +3226,11 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, stype, saddr2, (hsize_t)(TBLOCK_SIZE2048 - TBLOCK_SIZE30)); H5MF_xfree(f, stype, saddr3, (hsize_t)TBLOCK_SIZE50); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ @@ -3165,13 +3244,15 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_alloc7() */ /* @@ -3201,50 +3282,50 @@ error: static unsigned test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t empty_size = 0, file_size; - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t empty_size = 0, file_size; + H5FD_mem_t type, stype; haddr_t new_addr, addr, saddr; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0, sdata_size=0; - htri_t was_extended; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0, sdata_size = 0; + htri_t was_extended; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_try_extend() of meta/sdata aggregator: test 1"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate the first block from meta_aggr */ type = H5FD_MEM_SUPER; addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr+TBLOCK_SIZE30) != ma_addr) + if ((addr + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Adjust meta_aggr's info info for testing */ @@ -3257,14 +3338,15 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) was_extended = H5MF_try_extend(f, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE50)); /* should succeed */ - if(!was_extended) + if (!was_extended) TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if(new_ma_addr != (addr+TBLOCK_SIZE50)) + if (new_ma_addr != (addr + TBLOCK_SIZE50)) + TEST_ERROR + if (new_ma_size != (f->shared->meta_aggr.alloc_size - TBLOCK_SIZE50)) TEST_ERROR - if(new_ma_size != (f->shared->meta_aggr.alloc_size - TBLOCK_SIZE50)) TEST_ERROR /* Free the allocated blocks */ H5MF_xfree(f, type, addr, (hsize_t)TBLOCK_SIZE50); @@ -3273,14 +3355,15 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) was_extended = H5MF_try_extend(f, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE700)); /* should succeed */ - if(!was_extended) + if (!was_extended) TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if(new_ma_addr != (addr + TBLOCK_SIZE700)) + if (new_ma_addr != (addr + TBLOCK_SIZE700)) + TEST_ERROR + if (new_ma_size != (f->shared->meta_aggr.alloc_size * 2 - TBLOCK_SIZE700)) TEST_ERROR - if(new_ma_size != (f->shared->meta_aggr.alloc_size * 2 - TBLOCK_SIZE700)) TEST_ERROR /* Free the allocated blocks */ H5MF_xfree(f, type, addr, (hsize_t)TBLOCK_SIZE700); @@ -3289,23 +3372,24 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) was_extended = H5MF_try_extend(f, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE2058)); /* should succeed */ - if(!was_extended) + if (!was_extended) TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); if (new_ma_addr != (addr + TBLOCK_SIZE2058)) TEST_ERROR - if (new_ma_size != f->shared->meta_aggr.size) TEST_ERROR + if (new_ma_size != f->shared->meta_aggr.size) + TEST_ERROR /* Free the allocated blocks */ H5MF_xfree(f, type, addr, (hsize_t)TBLOCK_SIZE2058); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ @@ -3322,27 +3406,27 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) TESTING("H5MF_try_extend() of meta/sdata aggregator: test 2"); /* Skip test when using VFDs that don't use the metadata aggregator */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate the first block from meta_aggr */ type = H5FD_MEM_SUPER; addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr+TBLOCK_SIZE30) != ma_addr) + if ((addr + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate the first block from sdata_aggr */ stype = H5FD_MEM_DRAW; saddr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if((saddr+TBLOCK_SIZE50) != sdata_addr) + if ((saddr + TBLOCK_SIZE50) != sdata_addr) TEST_ERROR /* Adjust meta_aggr's info info for testing */ @@ -3354,14 +3438,14 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) /* should be able to fulfill request from the aggreqator itself */ was_extended = H5MF_try_extend(f, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE50)); - if(!was_extended) + if (!was_extended) TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if(new_ma_addr != (addr+TBLOCK_SIZE50)) + if (new_ma_addr != (addr + TBLOCK_SIZE50)) TEST_ERROR - if(new_ma_size != (f->shared->meta_aggr.alloc_size-TBLOCK_SIZE50)) + if (new_ma_size != (f->shared->meta_aggr.alloc_size - TBLOCK_SIZE50)) TEST_ERROR /* Restore info for meta_aggr */ @@ -3371,15 +3455,15 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, type, addr, (hsize_t)TBLOCK_SIZE30); H5MF_xfree(f, stype, saddr, (hsize_t)TBLOCK_SIZE50); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -3392,27 +3476,27 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) TESTING("H5MF_try_extend() of meta/sdata aggregator: test 3"); /* Skip test when using VFDs that don't use the metadata aggregator */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ type = H5FD_MEM_SUPER; addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr+TBLOCK_SIZE30) != ma_addr) + if ((addr + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate first block from sdata_aggr */ stype = H5FD_MEM_DRAW; saddr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if((saddr+TBLOCK_SIZE50) != sdata_addr) + if ((saddr + TBLOCK_SIZE50) != sdata_addr) TEST_ERROR /* Adjust meta_aggr's info info for testing */ @@ -3424,13 +3508,15 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) /* unable to fulfill request from the aggreqator itself */ was_extended = H5MF_try_extend(f, type, (haddr_t)new_addr, (hsize_t)10, (hsize_t)(TBLOCK_SIZE50)); - if(was_extended) + if (was_extended) TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != addr) TEST_ERROR - if (new_ma_size != 0) TEST_ERROR + if (new_ma_addr != addr) + TEST_ERROR + if (new_ma_size != 0) + TEST_ERROR /* restore info for meta_aggr */ f->shared->meta_aggr.addr = ma_addr; @@ -3439,15 +3525,15 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, type, addr, (hsize_t)TBLOCK_SIZE30); H5MF_xfree(f, stype, saddr, (hsize_t)TBLOCK_SIZE50); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -3457,13 +3543,15 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_extend() */ /* @@ -3491,72 +3579,73 @@ error: static unsigned test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t empty_size = 0, file_size; - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t empty_size = 0, file_size; + H5FD_mem_t type, stype; haddr_t addr1, addr2, addr3, saddr1; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF; - haddr_t new_sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0; - hsize_t sdata_size=0, new_sdata_size=0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; + haddr_t new_sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0; + hsize_t sdata_size = 0, new_sdata_size = 0; + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("H5MF_try_shrink() of meta/sdata aggregator: test 1"); /* Skip test when using VFDs that don't use the metadata aggregator */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate block A from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); ma_addr = new_ma_addr - TBLOCK_SIZE30; - if((addr1 + TBLOCK_SIZE30) != new_ma_addr) + if ((addr1 + TBLOCK_SIZE30) != new_ma_addr) TEST_ERROR /* should succeed */ - if(H5MF_try_shrink(f, type, addr1, (hsize_t)TBLOCK_SIZE30) <= 0) + if (H5MF_try_shrink(f, type, addr1, (hsize_t)TBLOCK_SIZE30) <= 0) TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if(new_ma_addr != ma_addr) TEST_ERROR + if (new_ma_addr != ma_addr) + TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -3569,53 +3658,59 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) TESTING("H5MF_try_shrink() of meta/sdata aggregator: test 2"); /* Skip test when using VFDs that don't use the metadata aggregator */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate block A from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR - if(ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) TEST_ERROR + if ((addr1 + TBLOCK_SIZE30) != ma_addr) + TEST_ERROR + if (ma_size != (TBLOCK_SIZE2048 - TBLOCK_SIZE30)) + TEST_ERROR /* Allocate block B from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->sdata_aggr), NULL, &sdata_size); /* should succeed */ - if(H5MF_try_shrink(f, stype, saddr1, (hsize_t)TBLOCK_SIZE50) <= 0) + if (H5MF_try_shrink(f, stype, saddr1, (hsize_t)TBLOCK_SIZE50) <= 0) TEST_ERROR H5MF__aggr_query(f, &(f->shared->sdata_aggr), &new_sdata_addr, &new_sdata_size); - if(new_sdata_addr != saddr1) TEST_ERROR - if(new_sdata_size != sdata_size + TBLOCK_SIZE50) TEST_ERROR + if (new_sdata_addr != saddr1) + TEST_ERROR + if (new_sdata_size != sdata_size + TBLOCK_SIZE50) + TEST_ERROR /* meta_aggr info should be updated because the block is absorbed into the meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != ma_addr) TEST_ERROR - if (new_ma_size != (ma_size)) TEST_ERROR + if (new_ma_addr != ma_addr) + TEST_ERROR + if (new_ma_size != (ma_size)) + TEST_ERROR H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -3628,56 +3723,57 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) TESTING("H5MF_try_shrink() of meta/sdata aggregator: test 3"); /* Skip test when using VFDs that don't use the metadata aggregator */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate block A from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* Allocate block B from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr2+TBLOCK_SIZE50) != ma_addr) + if ((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* Allocate block C from meta_aggr */ - addr3 = H5MF_alloc(f, type, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50)); + addr3 = H5MF_alloc(f, type, (hsize_t)(TBLOCK_SIZE30 + TBLOCK_SIZE50)); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr3+TBLOCK_SIZE30+TBLOCK_SIZE50) != ma_addr) + if ((addr3 + TBLOCK_SIZE30 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* should not succeed */ - if(H5MF_try_shrink(f, type, addr2, (hsize_t)TBLOCK_SIZE50) > 0) + if (H5MF_try_shrink(f, type, addr2, (hsize_t)TBLOCK_SIZE50) > 0) TEST_ERROR /* aggregator info should be the same as before */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if(new_ma_addr != ma_addr) TEST_ERROR + if (new_ma_addr != ma_addr) + TEST_ERROR H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30); H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE50); - H5MF_xfree(f, type, addr3, (hsize_t)(TBLOCK_SIZE30+TBLOCK_SIZE50)); + H5MF_xfree(f, type, addr3, (hsize_t)(TBLOCK_SIZE30 + TBLOCK_SIZE50)); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify the file is the correct size */ - if(file_size != empty_size) + if (file_size != empty_size) TEST_ERROR PASSED(); @@ -3687,13 +3783,15 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) HDputs(" Current VFD doesn't support metadata aggregator"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { - H5Fclose(file); - } H5E_END_TRY; - return(1); + H5E_BEGIN_TRY + { + H5Fclose(file); + } + H5E_END_TRY; + return (1); } /* test_mf_aggr_absorb() */ /* @@ -3731,117 +3829,122 @@ error: static unsigned test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) { - hid_t file = -1; /* File ID */ - hid_t fapl1 = -1; - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size, new_file_size; - H5FD_mem_t type; + hid_t file = -1; /* File ID */ + hid_t fapl1 = -1; + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size, new_file_size; + H5FD_mem_t type; haddr_t addr1, addr2; - haddr_t ma_addr=HADDR_UNDEF; - hsize_t ma_size=0; + haddr_t ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0; htri_t was_extended; - H5FS_stat_t state; - hsize_t alignment=0, mis_align=0, tmp=0, accum=0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + H5FS_stat_t state; + hsize_t alignment = 0, mis_align = 0, tmp = 0, accum = 0; + hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ TESTING("H5MM_alloc() of file allocation with alignment: test 1"); /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") - && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(have_alloc_vfd) { + have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") && HDstrcmp(env_h5_drvr, "split") && + HDstrcmp(env_h5_drvr, "multi")); + if (have_alloc_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Turn off using meta/small data aggregator */ - if((fapl1 = H5Pcopy(new_fapl)) < 0) TEST_ERROR + if ((fapl1 = H5Pcopy(new_fapl)) < 0) + TEST_ERROR H5Pset_meta_block_size(fapl1, (hsize_t)0); H5Pset_small_data_block_size(fapl1, (hsize_t)0); /* Create the file to work on (without alignment) */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* get alignment setting */ - if(H5Pget_alignment(fapl1, NULL, &alignment) < 0) + if (H5Pget_alignment(fapl1, NULL, &alignment) < 0) TEST_ERROR /* Re-open the file with alignment and meta/sdata setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ - if((tmp = (hsize_t)file_size % alignment)) - mis_align = alignment - tmp; + if ((tmp = (hsize_t)file_size % alignment)) + mis_align = alignment - tmp; accum = mis_align + TBLOCK_SIZE30; /* Allocate a block of 30 from file allocation */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if(addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR /* there should be nothing in the aggregator */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if(ma_addr || ma_size) TEST_ERROR + if (ma_addr || ma_size) + TEST_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if (check_stats(f, f->shared->fs_man[type], &state)) TEST_ERROR } /* calculate fragment for alignment of block 50 */ mis_align = 0; if ((tmp = ((hsize_t)file_size + accum) % alignment)) - mis_align = alignment - tmp; + mis_align = alignment - tmp; accum += (mis_align + TBLOCK_SIZE50); addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if (addr2 % alignment) TEST_ERROR + if (addr2 % alignment) + TEST_ERROR /* there should be nothing in the aggregator */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if(ma_addr || ma_size) TEST_ERROR + if (ma_addr || ma_size) + TEST_ERROR - if(mis_align) { + if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[type], &state)) + if (check_stats(f, f->shared->fs_man[type], &state)) TEST_ERROR } H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30); H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE50); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if((new_file_size = h5_get_file_size(filename, fapl1)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl1)) < 0) TEST_ERROR if (new_file_size != file_size) @@ -3859,48 +3962,50 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - if(have_alloc_vfd) { + if (have_alloc_vfd) { /* Re-open the file with alignment and meta/sdata setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* allocate a block of 50 from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); /* address should be aligned */ - if (addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if((file_size = h5_get_file_size(filename, fapl1)) < 0) + if ((file_size = h5_get_file_size(filename, fapl1)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* shrink the block */ - if(H5MF_try_shrink(f, type, addr1, (hsize_t)TBLOCK_SIZE50) <= 0) + if (H5MF_try_shrink(f, type, addr1, (hsize_t)TBLOCK_SIZE50) <= 0) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if((new_file_size = h5_get_file_size(filename, fapl1)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl1)) < 0) TEST_ERROR - if (new_file_size != (file_size-TBLOCK_SIZE50)) TEST_ERROR + if (new_file_size != (file_size - TBLOCK_SIZE50)) + TEST_ERROR PASSED(); } /* end if */ @@ -3914,49 +4019,53 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - if(have_alloc_vfd) { + if (have_alloc_vfd) { /* Re-open the file with alignment and meta/sdata setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* allocate a block of 50 */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); /* address should be aligned */ - if(addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if((file_size = h5_get_file_size(filename, fapl1)) < 0) + if ((file_size = h5_get_file_size(filename, fapl1)) < 0) TEST_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* try to extend the block */ - was_extended = H5MF_try_extend(f, type, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE50, (hsize_t)TBLOCK_SIZE30); + was_extended = + H5MF_try_extend(f, type, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE50, (hsize_t)TBLOCK_SIZE30); - if(was_extended <=0) TEST_ERROR + if (was_extended <= 0) + TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if((new_file_size = h5_get_file_size(filename, fapl1)) < 0) + if ((new_file_size = h5_get_file_size(filename, fapl1)) < 0) TEST_ERROR - if (new_file_size != (file_size+TBLOCK_SIZE30)) TEST_ERROR + if (new_file_size != (file_size + TBLOCK_SIZE30)) + TEST_ERROR PASSED(); } /* end if */ @@ -3965,13 +4074,15 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) HDputs(" Current VFD doesn't support mis-aligned fragments"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_align_eoa() */ /* @@ -4009,16 +4120,16 @@ error: static unsigned test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - h5_stat_size_t file_size; - H5F_t *f = NULL; /* Internal file object pointer */ + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + h5_stat_size_t file_size; + H5F_t * f = NULL; /* Internal file object pointer */ H5MF_free_section_t *sect_node = NULL; - haddr_t addr; - H5FS_stat_t state; - htri_t was_extended; - hsize_t alignment=0, tmp=0, mis_align=0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + haddr_t addr; + H5FS_stat_t state; + htri_t was_extended; + hsize_t alignment = 0, tmp = 0, mis_align = 0; + hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ TESTING("H5MF_alloc() of free-space manager with alignment: test 1"); @@ -4026,39 +4137,39 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* get alignment setting */ - if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0) + if (H5Pget_alignment(new_fapl, NULL, &alignment) < 0) TEST_ERROR /* Re-open the file with alignment setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) - TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) - TEST_ERROR + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + TEST_ERROR + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + TEST_ERROR /* Create section A */ sect_node = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)alignment, (hsize_t)TBLOCK_SIZE50); /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -4066,21 +4177,23 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 50 */ addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is section A in free-space */ - if(addr != (haddr_t)alignment) TEST_ERROR - if(addr % alignment) TEST_ERROR + if (addr != (haddr_t)alignment) + TEST_ERROR + if (addr % alignment) + TEST_ERROR state.tot_space -= TBLOCK_SIZE50; state.tot_sect_count -= 1; state.serial_sect_count -= 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block to free-space */ @@ -4089,39 +4202,38 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) state.tot_space += TBLOCK_SIZE50; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); TESTING("H5MF_alloc() of free-space manager with alignment: test 2"); - /* Re-open the file with alignment setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ sect_node = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE8000); /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -4129,45 +4241,48 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Allocate a block of 600 */ addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE600); /* Verify that the allocated block is aligned */ - if (addr % alignment) TEST_ERROR + if (addr % alignment) + TEST_ERROR /* should have 1 more section in free-space */ state.tot_space -= TBLOCK_SIZE600; state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* try to extend the block */ - was_extended = H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)addr, (hsize_t)TBLOCK_SIZE600, (hsize_t)TBLOCK_SIZE200); + was_extended = + H5MF_try_extend(f, H5FD_MEM_SUPER, (haddr_t)addr, (hsize_t)TBLOCK_SIZE600, (hsize_t)TBLOCK_SIZE200); - if(was_extended <=0) TEST_ERROR + if (was_extended <= 0) + TEST_ERROR /* space should be decreased by 200, # of sections remain the same */ state.tot_space -= TBLOCK_SIZE200; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* Free the block to free-space manager */ - H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)(TBLOCK_SIZE600+TBLOCK_SIZE200)); + H5MF_xfree(f, H5FD_MEM_SUPER, addr, (hsize_t)(TBLOCK_SIZE600 + TBLOCK_SIZE200)); /* only 1 section in free-space because of merging */ - state.tot_space += (TBLOCK_SIZE600+TBLOCK_SIZE200); - state.tot_sect_count = 1; + state.tot_space += (TBLOCK_SIZE600 + TBLOCK_SIZE200); + state.tot_sect_count = 1; state.serial_sect_count = 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -4177,34 +4292,34 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") - && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(have_alloc_vfd) { - if((file_size = h5_get_file_size(filename, new_fapl)) < 0) + have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") && HDstrcmp(env_h5_drvr, "split") && + HDstrcmp(env_h5_drvr, "multi")); + if (have_alloc_vfd) { + if ((file_size = h5_get_file_size(filename, new_fapl)) < 0) TEST_ERROR /* Re-open the file with alignment setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) + if (H5MF__start_fstype(f, (H5F_mem_page_t)H5FD_MEM_SUPER) < 0) FAIL_STACK_ERROR - if(f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) + if (f->shared->fs_state[H5FD_MEM_SUPER] != H5F_FS_STATE_OPEN) TEST_ERROR - if(f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) + if (f->shared->fs_man[H5FD_MEM_SUPER]->client != H5FS_CLIENT_FILE_ID) TEST_ERROR /* Create section A */ sect_node = H5MF__sect_new(H5MF_FSPACE_SECT_SIMPLE, (haddr_t)TBLOCK_ADDR70, (hsize_t)TBLOCK_SIZE700); /* Add section A to free-space manager */ - if(H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) + if (H5MF__add_sect(f, H5FD_MEM_SUPER, f->shared->fs_man[H5FD_MEM_SUPER], sect_node)) FAIL_STACK_ERROR HDmemset(&state, 0, sizeof(H5FS_stat_t)); @@ -4212,7 +4327,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) state.tot_sect_count += 1; state.serial_sect_count += 1; - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR /* * Allocate a block of 40 @@ -4222,11 +4337,12 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) addr = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)(TBLOCK_SIZE40)); /* Verify that the allocated block is aligned */ - if(addr % alignment) + if (addr % alignment) TEST_ERROR /* verify that the allocated block is from file allocation, not section A in free-space */ - if (!(addr >= (haddr_t)file_size)) TEST_ERROR + if (!(addr >= (haddr_t)file_size)) + TEST_ERROR /* calculate fragment for alignment of block 40 from file allocation */ if ((tmp = (hsize_t)file_size % alignment)) @@ -4239,10 +4355,10 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) } /* free-space info should be the same */ - if(check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) + if (check_stats(f, f->shared->fs_man[H5FD_MEM_SUPER], &state)) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -4252,13 +4368,15 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) HDputs(" Current VFD doesn't support mis-aligned fragments"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_align_fs() */ /* @@ -4362,69 +4480,69 @@ error: static unsigned test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size; /* File size */ + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size; /* File size */ - H5FD_mem_t type; - haddr_t addr1, addr2, addr3, addr4; + H5FD_mem_t type; + haddr_t addr1, addr2, addr3, addr4; H5FS_stat_t state; - haddr_t ma_addr=HADDR_UNDEF; - hsize_t ma_size=0, mis_align=0; - hsize_t alignment=0, tmp=0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ - + haddr_t ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0, mis_align = 0; + hsize_t alignment = 0, tmp = 0; + hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 1"); /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") - && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(have_alloc_vfd) { + have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") && HDstrcmp(env_h5_drvr, "split") && + HDstrcmp(env_h5_drvr, "multi")); + if (have_alloc_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on (without alignment) */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* get alignment setting */ - if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0) + if (H5Pget_alignment(new_fapl, NULL, &alignment) < 0) TEST_ERROR /* Re-open the file with alignment setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ - if((tmp = (hsize_t)file_size % alignment)) + if ((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if(addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ HDmemset(&state, 0, sizeof(H5FS_stat_t)); - if(mis_align) { + if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -4437,17 +4555,18 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* calculate fragment for alignment of block 50 */ mis_align = 0; - if((tmp = ma_addr % alignment)) + if ((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 50 from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if(addr2 % alignment) TEST_ERROR + if (addr2 % alignment) + TEST_ERROR /* fragment for alignment of block 50 is freed to free-space */ - if(mis_align) { + if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -4455,7 +4574,7 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr2 + TBLOCK_SIZE50) != ma_addr) + if ((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 80 */ @@ -4466,10 +4585,11 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE80); /* Verify that the allocated block is aligned */ - if(addr3 % alignment) TEST_ERROR + if (addr3 % alignment) + TEST_ERROR /* fragment for alignment of block 80 is freed to free-space */ - if(mis_align) { + if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -4477,22 +4597,23 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr3 + TBLOCK_SIZE80) != ma_addr) + if ((addr3 + TBLOCK_SIZE80) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 1970 */ mis_align = 0; - if((tmp = ma_addr % alignment)) + if ((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 1970 from meta_aggr */ addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1970); /* Verify that the allocated block is aligned */ - if(addr4 % alignment) TEST_ERROR + if (addr4 % alignment) + TEST_ERROR /* fragment for alignment of block 1970 is freed to free-space */ - if(mis_align) { + if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -4500,11 +4621,11 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr4 + TBLOCK_SIZE1970) != ma_addr) + if ((addr4 + TBLOCK_SIZE1970) != ma_addr) TEST_ERROR /* Verify total size of free space after all the allocations */ - if(check_stats(f, f->shared->fs_man[type], &state)) + if (check_stats(f, f->shared->fs_man[type], &state)) TEST_ERROR H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30); @@ -4512,7 +4633,7 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE80); H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE1970); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -4522,13 +4643,15 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) HDputs(" Current VFD doesn't support mis-aligned fragments"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_align_alloc1() */ /* @@ -4620,67 +4743,68 @@ error: static unsigned test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size; /* File size */ - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size; /* File size */ + H5FD_mem_t type, stype; haddr_t addr1, addr2, addr3, saddr1; - H5FS_stat_t state[H5FD_MEM_NTYPES]; - haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, sdata_size=0, mis_align=0; - hsize_t alignment=0, tmp=0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + H5FS_stat_t state[H5FD_MEM_NTYPES]; + haddr_t ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, sdata_size = 0, mis_align = 0; + hsize_t alignment = 0, tmp = 0; + hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 2"); /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") - && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(have_alloc_vfd) { + have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") && HDstrcmp(env_h5_drvr, "split") && + HDstrcmp(env_h5_drvr, "multi")); + if (have_alloc_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on (without alignment) */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* get alignment setting */ - if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0) + if (H5Pget_alignment(new_fapl, NULL, &alignment) < 0) TEST_ERROR /* Re-open the file with alignment setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ - if((tmp = (hsize_t)file_size % alignment)) + if ((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if(addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ HDmemset(&state, 0, sizeof(H5FS_stat_t) * H5FD_MEM_NTYPES); - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -4688,21 +4812,22 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1 + TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* fragment for alignment of block 50 is freed to free-space */ mis_align = 0; - if((tmp = ma_addr % alignment)) + if ((tmp = ma_addr % alignment)) mis_align = alignment - tmp; addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if(addr2 % alignment) TEST_ERROR + if (addr2 % alignment) + TEST_ERROR /* fragment for alignment of block 50 is freed to free-space */ - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -4710,7 +4835,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr2 + TBLOCK_SIZE50) != ma_addr) + if ((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* @@ -4725,29 +4850,31 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) * block 30 is allocated from ma_addr */ mis_align = 0; - if((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment))) + if ((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment))) mis_align = alignment - tmp; else if ((alignment == TEST_ALIGN4096) && (tmp = (ma_addr % alignment))) mis_align = alignment - tmp; /* Allocate a block of 30 from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); /* fragment for alignment of block 30 for sdata_aggr is freed to free-space */ - if(mis_align) { + if (mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; } /* Verify that the allocated block is aligned */ - if (saddr1 % alignment) TEST_ERROR + if (saddr1 % alignment) + TEST_ERROR H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if(sdata_addr != (saddr1 + TBLOCK_SIZE30)) TEST_ERROR + if (sdata_addr != (saddr1 + TBLOCK_SIZE30)) + TEST_ERROR /* * Calculate fragment for the allocation of block 80 from meta_aggr: @@ -4759,7 +4886,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) * block 30 is allocated from ma_addr */ mis_align = 0; - if((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment))) + if ((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment))) mis_align = alignment - tmp; else if ((alignment == TEST_ALIGN4096) && (tmp = ((sdata_addr + sdata_size) % alignment))) mis_align = alignment - tmp; @@ -4768,10 +4895,11 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE80); /* Verify that the allocated block is aligned */ - if (addr3 % alignment) TEST_ERROR + if (addr3 % alignment) + TEST_ERROR /* fragment for alignment of block 80 is freed to free-space */ - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -4779,26 +4907,26 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr3 + TBLOCK_SIZE80) != ma_addr) + if ((addr3 + TBLOCK_SIZE80) != ma_addr) TEST_ERROR /* Verify total size of free space after all the allocations */ - if(f->shared->fs_man[type]) { - if(check_stats(f, f->shared->fs_man[type], &(state[type]))) - TEST_ERROR - } + if (f->shared->fs_man[type]) { + if (check_stats(f, f->shared->fs_man[type], &(state[type]))) + TEST_ERROR + } - if(f->shared->fs_man[stype]) { - if(check_stats(f, f->shared->fs_man[stype], &(state[stype]))) - TEST_ERROR - } + if (f->shared->fs_man[stype]) { + if (check_stats(f, f->shared->fs_man[stype], &(state[stype]))) + TEST_ERROR + } H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE30); H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE50); H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE80); H5MF_xfree(f, stype, saddr1, (hsize_t)TBLOCK_SIZE30); - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -4808,13 +4936,15 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) HDputs(" Current VFD doesn't support mis-aligned fragments"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_align_alloc2() */ /* @@ -4957,69 +5087,69 @@ error: static unsigned test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size; - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size; + H5FD_mem_t type, stype; haddr_t addr1, addr2, addr3; haddr_t saddr1, saddr2, saddr3; - H5FS_stat_t state[H5FD_MEM_NTYPES]; - haddr_t ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, sdata_size=0, mis_align=0; - hsize_t alignment=0, tmp=0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ - + H5FS_stat_t state[H5FD_MEM_NTYPES]; + haddr_t ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, sdata_size = 0, mis_align = 0; + hsize_t alignment = 0, tmp = 0; + hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 3"); /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") - && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(have_alloc_vfd) { + have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") && HDstrcmp(env_h5_drvr, "split") && + HDstrcmp(env_h5_drvr, "multi")); + if (have_alloc_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on (without alignment) */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* get alignment setting */ - if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0) + if (H5Pget_alignment(new_fapl, NULL, &alignment) < 0) TEST_ERROR /* Re-open the file with alignment setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ - if((tmp = (hsize_t)file_size % alignment)) + if ((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if(addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ HDmemset(&state, 0, sizeof(H5FS_stat_t) * H5FD_MEM_NTYPES); - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -5031,24 +5161,25 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* calculate fragment for alignment of block 50 */ mis_align = 0; - if((tmp = ma_addr % alignment)) + if ((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 50 from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if(addr2 % alignment) TEST_ERROR + if (addr2 % alignment) + TEST_ERROR /* fragment for alignment of block 50 is freed to free-space */ - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; } H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr2 + TBLOCK_SIZE50) != ma_addr) + if ((addr2 + TBLOCK_SIZE50) != ma_addr) TEST_ERROR /* @@ -5063,62 +5194,67 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) * block 30 is allocated from ma_addr */ mis_align = 0; - if((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment))) + if ((alignment == TEST_ALIGN1024) && (tmp = ((ma_addr + ma_size) % alignment))) mis_align = alignment - tmp; else if ((alignment == TEST_ALIGN4096) && (tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if(saddr1 % alignment) TEST_ERROR + if (saddr1 % alignment) + TEST_ERROR /* fragment for alignment of block 30 for sdata_aggr is freed to free-space */ - if(mis_align) { + if (mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; } H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if(sdata_addr != (saddr1+TBLOCK_SIZE30)) TEST_ERROR + if (sdata_addr != (saddr1 + TBLOCK_SIZE30)) + TEST_ERROR /* calculate fragment for alignment of block 50 in sdata_aggr */ mis_align = 0; - if((tmp = sdata_addr % alignment)) + if ((tmp = sdata_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 50 from sdata_aggr */ saddr2 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if(saddr2 % alignment) TEST_ERROR + if (saddr2 % alignment) + TEST_ERROR /* fragment for alignment of block 50 for sdata_aggr is freed to free-space */ - if(mis_align) { + if (mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; } H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if(sdata_addr != (saddr2 + TBLOCK_SIZE50)) TEST_ERROR + if (sdata_addr != (saddr2 + TBLOCK_SIZE50)) + TEST_ERROR /* calculate fragment for alignment of block 80 in sdata_aggr */ mis_align = 0; - if((tmp = sdata_addr % alignment)) + if ((tmp = sdata_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 80 from sdata_aggr */ saddr3 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE80); /* Verify that the allocated block is aligned */ - if(saddr3 % alignment) TEST_ERROR + if (saddr3 % alignment) + TEST_ERROR /* fragment for alignment of block 80 for sdata_aggr is freed to free-space */ - if(mis_align) { + if (mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; @@ -5130,17 +5266,18 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* calculate fragment for alignment of block 1034 */ mis_align = 0; - if((tmp = sdata_addr % alignment)) + if ((tmp = sdata_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 1034 for meta_aggr */ addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1034); /* Verify that the allocated block is aligned */ - if(addr3 % alignment) TEST_ERROR + if (addr3 % alignment) + TEST_ERROR /* fragment for alignment of block 1034 for meta_aggr is freed to free-space */ - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -5148,11 +5285,11 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* calculate unused space in meta_aggr that is freed to free-space after block 1034 */ mis_align = 0; - if((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment))) + if ((alignment == TEST_ALIGN1024) && (tmp = (ma_addr % alignment))) mis_align = alignment - tmp; /* fragment for unused space in meta_aggr after block 1034 is freed to free-space */ - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -5160,21 +5297,21 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr3 + TBLOCK_SIZE1034) != ma_addr) + if ((addr3 + TBLOCK_SIZE1034) != ma_addr) TEST_ERROR /* Verify total size of free space after all allocations */ - if(f->shared->fs_man[type]) { - if(check_stats(f, f->shared->fs_man[type], &(state[type]))) - TEST_ERROR - } + if (f->shared->fs_man[type]) { + if (check_stats(f, f->shared->fs_man[type], &(state[type]))) + TEST_ERROR + } - if(f->shared->fs_man[stype]) { - if(check_stats(f, f->shared->fs_man[stype], &(state[stype]))) - TEST_ERROR - } + if (f->shared->fs_man[stype]) { + if (check_stats(f, f->shared->fs_man[stype], &(state[stype]))) + TEST_ERROR + } - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -5184,16 +5321,17 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) HDputs(" Current VFD doesn't support mis-aligned fragments"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_align_alloc3() */ - /* *------------------------------------------------------------------------- * To verify that blocks allocated from the aggregator are aligned @@ -5263,68 +5401,68 @@ error: static unsigned test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size; - H5FD_mem_t type; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size; + H5FD_mem_t type; haddr_t addr1, addr2, addr3; - H5FS_stat_t state; - haddr_t ma_addr=HADDR_UNDEF; - hsize_t ma_size=0, saved_ma_size=0; - hsize_t alignment=0, mis_align=0, tmp=0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ - + H5FS_stat_t state; + haddr_t ma_addr = HADDR_UNDEF; + hsize_t ma_size = 0, saved_ma_size = 0; + hsize_t alignment = 0, mis_align = 0, tmp = 0; + hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 4"); /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") - && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(have_alloc_vfd) { + have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") && HDstrcmp(env_h5_drvr, "split") && + HDstrcmp(env_h5_drvr, "multi")); + if (have_alloc_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on (without alignment) */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file with alignment setting and meta/sdata setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* get alignment setting */ - if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0) + if (H5Pget_alignment(new_fapl, NULL, &alignment) < 0) TEST_ERROR /* calculate fragment for alignment of block 30 */ - if((tmp = (hsize_t)file_size % alignment)) + if ((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if(addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ HDmemset(&state, 0, sizeof(H5FS_stat_t)); - if(mis_align) { + if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -5332,21 +5470,23 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); saved_ma_size = ma_size; - if((addr1+TBLOCK_SIZE30) != ma_addr) TEST_ERROR + if ((addr1 + TBLOCK_SIZE30) != ma_addr) + TEST_ERROR /* calculate fragment for alignment of block 2058 */ mis_align = 0; - if((tmp = ma_addr % alignment)) + if ((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 2058 from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2058); /* Verify that the allocated block is aligned */ - if(addr2 % alignment) TEST_ERROR + if (addr2 % alignment) + TEST_ERROR /* fragment for alignment of block 2058 is freed to free-space */ - if(mis_align) { + if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; @@ -5354,36 +5494,39 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr2 + TBLOCK_SIZE2058) != ma_addr) TEST_ERROR + if ((addr2 + TBLOCK_SIZE2058) != ma_addr) + TEST_ERROR /* meta_aggr->size remains the same */ - if(ma_size != saved_ma_size) TEST_ERROR + if (ma_size != saved_ma_size) + TEST_ERROR /* calculate fragment for alignment of block 5 from meta_aggr */ mis_align = 0; - if((tmp = ma_addr % alignment)) + if ((tmp = ma_addr % alignment)) mis_align = alignment - tmp; /* Allocate a block of 5 from meta_aggr */ addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5); /* fragment for alignment of block 5 is freed to free-space */ - if(mis_align) { + if (mis_align) { state.tot_space += mis_align; state.tot_sect_count += 1; state.serial_sect_count += 1; } /* Verify that the allocated block is aligned */ - if(addr3 % alignment) TEST_ERROR + if (addr3 % alignment) + TEST_ERROR /* Verify total size of free space after all allocations */ - if(f->shared->fs_man[type]) { - if(check_stats(f, f->shared->fs_man[type], &state)) - TEST_ERROR - } + if (f->shared->fs_man[type]) { + if (check_stats(f, f->shared->fs_man[type], &state)) + TEST_ERROR + } - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -5393,13 +5536,15 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) HDputs(" Current VFD doesn't support mis-aligned fragments"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_align_alloc4() */ /* @@ -5473,73 +5618,74 @@ error: static unsigned test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size; - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size; + H5FD_mem_t type, stype; haddr_t addr1, addr2, saddr1; - H5FS_stat_t state[H5FD_MEM_NTYPES]; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF; - haddr_t sdata_addr=HADDR_UNDEF, new_sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0, sdata_size=0, new_sdata_size=0; - hsize_t alignment=0, mis_align=0, tmp=0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ - + H5FS_stat_t state[H5FD_MEM_NTYPES]; + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; + haddr_t sdata_addr = HADDR_UNDEF, new_sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0, sdata_size = 0, new_sdata_size = 0; + hsize_t alignment = 0, mis_align = 0, tmp = 0; + hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 5"); /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") - && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(have_alloc_vfd) { + have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") && HDstrcmp(env_h5_drvr, "split") && + HDstrcmp(env_h5_drvr, "multi")); + if (have_alloc_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on (without alignment) */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file with alignment setting and meta/sdata setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* get alignment setting */ - if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0) + if (H5Pget_alignment(new_fapl, NULL, &alignment) < 0) TEST_ERROR /* calculate fragment for alignment of block 30 */ - if((tmp = (hsize_t)file_size % alignment)) + if ((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if(addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR + if ((addr1 + TBLOCK_SIZE30) != ma_addr) + TEST_ERROR /* fragment for alignment of block 30 is freed to free-space */ HDmemset(&state, 0, sizeof(H5FS_stat_t) * H5FD_MEM_NTYPES); - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; @@ -5547,54 +5693,57 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* calculate fragment for alignment of block 30 from sdata_aggr */ mis_align = 0; - if((tmp = (ma_addr + ma_size) % alignment)) + if ((tmp = (ma_addr + ma_size) % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if(saddr1 % alignment) TEST_ERROR + if (saddr1 % alignment) + TEST_ERROR /* fragment of alignment for block 30 in sdata_aggr is freed to free-space */ - if(mis_align) { + if (mis_align) { state[stype].tot_space += mis_align; state[stype].tot_sect_count += 1; state[stype].serial_sect_count += 1; } H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if((saddr1+TBLOCK_SIZE30) != sdata_addr) TEST_ERROR + if ((saddr1 + TBLOCK_SIZE30) != sdata_addr) + TEST_ERROR /* calculate fragment for alignment of block 2058 from meta_aggr */ mis_align = 0; - if((tmp = (sdata_addr + sdata_size) % alignment)) + if ((tmp = (sdata_addr + sdata_size) % alignment)) mis_align = alignment - tmp; /* Allocate a block of 2058 from meta_aggr */ addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2058); /* Verify that the allocated block is aligned */ - if (addr2 % alignment) TEST_ERROR + if (addr2 % alignment) + TEST_ERROR /* fragment for alignment of block 2058 is freed to free-space */ - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; } /* Verify total size of free space after all allocations */ - if(f->shared->fs_man[type]) { - if(check_stats(f, f->shared->fs_man[type], &(state[type]))) - TEST_ERROR - } + if (f->shared->fs_man[type]) { + if (check_stats(f, f->shared->fs_man[type], &(state[type]))) + TEST_ERROR + } - if(f->shared->fs_man[stype]) { - if(check_stats(f, f->shared->fs_man[stype], &(state[stype]))) - TEST_ERROR - } + if (f->shared->fs_man[stype]) { + if (check_stats(f, f->shared->fs_man[stype], &(state[stype]))) + TEST_ERROR + } /* nothing is changed in meta_aggr */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); @@ -5606,7 +5755,7 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if (new_sdata_addr != sdata_addr || new_sdata_size != sdata_size) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -5616,16 +5765,17 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) HDputs(" Current VFD doesn't support mis-aligned fragments"); } /* end else */ - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_align_alloc5() */ - /* *------------------------------------------------------------------------- * To verify that blocks allocated from the aggregator are aligned @@ -5738,75 +5888,76 @@ error: static unsigned test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - h5_stat_size_t file_size; - H5FD_mem_t type, stype; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + h5_stat_size_t file_size; + H5FD_mem_t type, stype; haddr_t addr1, addr2; haddr_t saddr1, saddr2, saddr3; - H5FS_stat_t state[H5FD_MEM_NTYPES]; - haddr_t ma_addr=HADDR_UNDEF, new_ma_addr=HADDR_UNDEF, sdata_addr=HADDR_UNDEF; - hsize_t ma_size=0, new_ma_size=0, sdata_size=0; - hsize_t alignment=0, mis_align=0, tmp=0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + H5FS_stat_t state[H5FD_MEM_NTYPES]; + haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; + hsize_t ma_size = 0, new_ma_size = 0, sdata_size = 0; + hsize_t alignment = 0, mis_align = 0, tmp = 0; + hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 6"); /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") - && HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(have_alloc_vfd) { + have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") && HDstrcmp(env_h5_drvr, "split") && + HDstrcmp(env_h5_drvr, "multi")); + if (have_alloc_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on (without alignment) */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Re-open the file with alignment setting and meta/sdata setting */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* get alignment setting */ - if(H5Pget_alignment(new_fapl, NULL, &alignment) < 0) + if (H5Pget_alignment(new_fapl, NULL, &alignment) < 0) TEST_ERROR /* calculate fragment for alignment of block 30 */ - if((tmp = (hsize_t)file_size % alignment)) + if ((tmp = (hsize_t)file_size % alignment)) mis_align = alignment - tmp; /* Allocate a block of 30 from meta_aggr */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (addr1 % alignment) TEST_ERROR + if (addr1 % alignment) + TEST_ERROR /* fragment for alignment of block 30 in meta_aggr is freed to free-space */ HDmemset(&state, 0, sizeof(H5FS_stat_t) * H5FD_MEM_NTYPES); - if(mis_align) { + if (mis_align) { state[type].tot_space += mis_align; state[type].tot_sect_count += 1; state[type].serial_sect_count += 1; } H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); - if ((addr1+TBLOCK_SIZE30) != ma_addr) + if ((addr1 + TBLOCK_SIZE30) != ma_addr) TEST_ERROR /* calculate fragment for alignment of block 30 in sdata_aggr */ @@ -5815,11 +5966,12 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) mis_align = alignment - tmp; /* Allocate a block of 30 from sdata_aggr */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); /* Verify that the allocated block is aligned */ - if (saddr1 % alignment) TEST_ERROR + if (saddr1 % alignment) + TEST_ERROR /* fragment for alignment of block 30 in sdata_aggr is freed to free-space */ if (mis_align) { @@ -5829,7 +5981,8 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) } H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != (saddr1+TBLOCK_SIZE30)) TEST_ERROR + if (sdata_addr != (saddr1 + TBLOCK_SIZE30)) + TEST_ERROR /* calculate fragment for alignment of block 50 in sdata_aggr */ mis_align = 0; @@ -5840,7 +5993,8 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) saddr2 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE50); /* Verify that the allocated block is aligned */ - if (saddr2 % alignment) TEST_ERROR + if (saddr2 % alignment) + TEST_ERROR /* fragment for alignment of block 50 in sdata_aggr is freed to free-space */ if (mis_align) { @@ -5850,7 +6004,8 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) } H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != (saddr2+TBLOCK_SIZE50)) TEST_ERROR + if (sdata_addr != (saddr2 + TBLOCK_SIZE50)) + TEST_ERROR /* calculate fragment for alignment of block 80 in sdata_aggr */ mis_align = 0; @@ -5861,7 +6016,8 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) saddr3 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE80); /* Verify that the allocated block is aligned */ - if (saddr3 % alignment) TEST_ERROR + if (saddr3 % alignment) + TEST_ERROR /* fragment for alignment of block 80 in sdata_aggr is freed to free-space */ if (mis_align) { @@ -5871,7 +6027,8 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) } H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sdata_addr, &sdata_size); - if (sdata_addr != (saddr3+TBLOCK_SIZE80)) TEST_ERROR + if (sdata_addr != (saddr3 + TBLOCK_SIZE80)) + TEST_ERROR /* calculate fragment for alignment of block 2058 */ /* remaining space in sdata_aggr is freed and shrunk */ @@ -5883,7 +6040,8 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2058); /* Verify that the allocated block is aligned */ - if (addr2 % alignment) TEST_ERROR + if (addr2 % alignment) + TEST_ERROR /* fragment for alignment of block 2058 is freed to free-space */ if (mis_align) { @@ -5901,18 +6059,17 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if (sdata_addr != HADDR_UNDEF || sdata_size != 0) TEST_ERROR - if(f->shared->fs_man[type]) { - if(check_stats(f, f->shared->fs_man[type], &(state[type]))) - TEST_ERROR - } - + if (f->shared->fs_man[type]) { + if (check_stats(f, f->shared->fs_man[type], &(state[type]))) + TEST_ERROR + } - if(f->shared->fs_man[stype]) { - if(check_stats(f, f->shared->fs_man[stype], &(state[stype]))) - TEST_ERROR - } + if (f->shared->fs_man[stype]) { + if (check_stats(f, f->shared->fs_man[stype], &(state[stype]))) + TEST_ERROR + } - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -5925,9 +6082,11 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_mf_align_alloc6() */ @@ -5938,15 +6097,15 @@ error: static unsigned test_mf_bug1(const char *env_h5_drvr, hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t copied_fapl = -1; /* FAPL to use for this test */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; - haddr_t addr1, addr2; - hsize_t block_size; - hsize_t align; - hbool_t split = FALSE, multi = FALSE; + hid_t file = -1; /* File ID */ + hid_t copied_fapl = -1; /* FAPL to use for this test */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; + haddr_t addr1, addr2; + hsize_t block_size; + hsize_t align; + hbool_t split = FALSE, multi = FALSE; TESTING("H5MF_alloc() bug 1"); @@ -5954,143 +6113,153 @@ test_mf_bug1(const char *env_h5_drvr, hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Copy fapl */ - if((copied_fapl = H5Pcopy(fapl)) < 0) + if ((copied_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR /* Get metadata block size */ - if(H5Pget_meta_block_size(copied_fapl, &block_size) < 0) + if (H5Pget_meta_block_size(copied_fapl, &block_size) < 0) TEST_ERROR /* Set alignment to equal block size / 2 */ align = block_size / 2; - if(H5Pset_alignment(copied_fapl, 0, align) < 0) + if (H5Pset_alignment(copied_fapl, 0, align) < 0) TEST_ERROR /* Check for split or multi driver */ - if(!HDstrcmp(env_h5_drvr, "split")) + if (!HDstrcmp(env_h5_drvr, "split")) split = TRUE; - else if(!HDstrcmp(env_h5_drvr, "multi")) + else if (!HDstrcmp(env_h5_drvr, "multi")) multi = TRUE; /* Add alignment to member files for split/multi driver */ - if(split || multi) { + if (split || multi) { hid_t memb_fapl; /* Creat fapl */ - if((memb_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((memb_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set alignment. Note that it is the block size of the parent FAPL that * is important here. */ - if(H5Pset_alignment(memb_fapl, 0, align) < 0) + if (H5Pset_alignment(memb_fapl, 0, align) < 0) TEST_ERROR - if(split) { + if (split) { /* Set split driver with new FAPLs */ - if(H5Pset_fapl_split(copied_fapl, "-m.h5", memb_fapl, "-r.h5", memb_fapl) < 0) + if (H5Pset_fapl_split(copied_fapl, "-m.h5", memb_fapl, "-r.h5", memb_fapl) < 0) TEST_ERROR } /* end if */ else { H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; - char *memb_name[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - hbool_t relax; - H5FD_mem_t mt; + hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; + char * memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + H5FD_mem_t mt; /* Get current multi settings */ HDmemset(memb_name, 0, sizeof memb_name); - if(H5Pget_fapl_multi(copied_fapl, memb_map, NULL, memb_name, memb_addr, &relax) < 0) + if (H5Pget_fapl_multi(copied_fapl, memb_map, NULL, memb_name, memb_addr, &relax) < 0) TEST_ERROR /* Populate memb_fapl_arr, patch memb_addr so member file addresses * are aligned */ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { memb_fapl_arr[mt] = memb_fapl; - memb_addr[mt] = ((memb_addr[mt] + align - 1) / align) * align; + memb_addr[mt] = ((memb_addr[mt] + align - 1) / align) * align; } /* end for */ /* Set multi driver with new FAPLs */ - if(H5Pset_fapl_multi(copied_fapl, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + if (H5Pset_fapl_multi(copied_fapl, memb_map, memb_fapl_arr, (const char *const *)memb_name, + memb_addr, relax) < 0) TEST_ERROR /* Free memb_name */ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) free(memb_name[mt]); } /* end else */ /* Close memb_fapl */ - if(H5Pclose(memb_fapl) < 0) + if (H5Pclose(memb_fapl) < 0) TEST_ERROR } /* end if */ /* Reopen the file with alignment */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, copied_fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, copied_fapl)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) TEST_ERROR /* Allocate a block of size align from meta_aggr. This should create an * aggregator that extends to the end of the file, with * block_size / 2 bytes remaining, and the end of the file aligned */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, align); /* Verify that the allocated block is aligned */ - if(addr1 % align) TEST_ERROR + if (addr1 % align) + TEST_ERROR /* Allocate a block of size align from meta_aggr. This should force the * aggregator to extend to the end of the file, with 0 bytes remaining, and * the end of the file aligned */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr2 = H5MF_alloc(f, type, align); /* Verify that the allocated block is aligned */ - if(addr2 % align) TEST_ERROR + if (addr2 % align) + TEST_ERROR /* Verify that the allocated block is placed align after the previous */ - if((addr2 - addr1) != align) TEST_ERROR + if ((addr2 - addr1) != align) + TEST_ERROR /* Allocate a block of size block_size + 1 from meta_aggr. This should * force the aggregator to extend to the end of the file, with 0 bytes * remaining, and the end of the file unaligned */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, block_size + (hsize_t)1); /* Verify that the allocated block is aligned */ - if(addr1 % align) TEST_ERROR + if (addr1 % align) + TEST_ERROR /* Verify that the allocated block is placed block_size / 2 after the * previous */ - if((addr1 - addr2) != align) TEST_ERROR + if ((addr1 - addr2) != align) + TEST_ERROR /* Allocate a block of size 1. This should extend the aggregator from * the previous allocation, and align the new block */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr2 = H5MF_alloc(f, type, (hsize_t)1); /* Verify that the allocated block is aligned */ - if(addr2 % align) TEST_ERROR + if (addr2 % align) + TEST_ERROR /* Verify that the allocated block is placed 3 * (block_size / 2) after * the previous */ - if((addr2 - addr1) != (3 * align)) TEST_ERROR + if ((addr2 - addr1) != (3 * align)) + TEST_ERROR PASSED(); /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_bug1() */ /* @@ -6101,17 +6270,17 @@ error: static unsigned test_mf_fs_persist_split(void) { - hid_t file = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t fapl = -1; /* File access property list ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type, stype, btype; /* File allocation type */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ - haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_DRAW */ - haddr_t baddr5, baddr6, baddr7, baddr8; /* File address for H5FD_MEM_BTREE */ - haddr_t tmp_addr; /* temporary variable for address */ + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl = -1; /* File access property list ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FD_mem_t type, stype, btype; /* File allocation type */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ + haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_DRAW */ + haddr_t baddr5, baddr6, baddr7, baddr8; /* File address for H5FD_MEM_BTREE */ + haddr_t tmp_addr; /* temporary variable for address */ TESTING("File's free-space managers are persistent for split-file"); @@ -6120,291 +6289,293 @@ test_mf_fs_persist_split(void) */ SKIPPED(); HDfprintf(stdout, " Persistent FSMs disabled in multi file driver.\n"); - return 0; /* <========== note return */ + return 0; /* <========== note return */ /* File creation property list template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - /* for now, we don't support persistent free space managers - * with the split file driver. - */ - SKIPPED(); + /* for now, we don't support persistent free space managers + * with the split file driver. + */ + SKIPPED(); HDfprintf(stdout, " Persistent FSMs disabled in multi file driver.\n"); - return 0; /* <========== note return */ + return 0; /* <========== note return */ /* File creation property list template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - FAIL_STACK_ERROR + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR /* Set up split driver */ - if(H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0) + if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* File creation property list template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 4 blocks of type H5FD_MEM_SUPER */ type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR /* Put block #1, #3 into H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR /* Allocate 4 blocks of type H5FD_MEM_DRAW */ stype = H5FD_MEM_DRAW; - if(HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR /* Put block #1, #3 into H5FD_MEM_DRAW free-space manager */ - if(H5MF_xfree(f, stype, saddr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, stype, saddr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, stype, saddr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, stype, saddr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) + if (!H5F_addr_defined(f->shared->fs_addr[type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + if (fs_stat.tot_space < (TBLOCK_SIZE1 + TBLOCK_SIZE3)) TEST_ERROR - if(fs_stat.serial_sect_count < 2) + if (fs_stat.serial_sect_count < 2) TEST_ERROR /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager; block #3 still in free-space */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(tmp_addr != addr1) + if (tmp_addr != addr1) TEST_ERROR /* Verify that the free-space manager for H5FD_MEM_DRAW is there */ - if(!H5F_addr_defined(f->shared->fs_addr[stype])) + if (!H5F_addr_defined(f->shared->fs_addr[stype])) TEST_ERROR - /* Start up H5FD_MEM_DRAW free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)stype) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)stype) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[stype], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[stype], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + if (fs_stat.tot_space < (TBLOCK_SIZE1 + TBLOCK_SIZE3)) TEST_ERROR - if(fs_stat.serial_sect_count < 2) + if (fs_stat.serial_sect_count < 2) TEST_ERROR /* Retrieve blocks #1 from H5FD_MEM_DRAW free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(tmp_addr != saddr1) + if (tmp_addr != saddr1) TEST_ERROR /* Retrieve blocks #3 from H5FD_MEM_DRAW free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(tmp_addr != saddr3) + if (tmp_addr != saddr3) TEST_ERROR /* H5FD_MEM_DRAW free-space manager is going away at closing */ /* works for this one because the freeing of sect_addr is to H5FD_MEM_SUPER fs, not against itself */ /* Allocate 4 blocks of type H5FD_MEM_BTREE */ btype = H5FD_MEM_BTREE; - if(HADDR_UNDEF == (baddr5 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE5))) + if (HADDR_UNDEF == (baddr5 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE5))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr6 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE6))) + if (HADDR_UNDEF == (baddr6 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE6))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr7 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE7))) + if (HADDR_UNDEF == (baddr7 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE7))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr8 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE8))) + if (HADDR_UNDEF == (baddr8 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE8))) FAIL_STACK_ERROR /* Put block #5 & #7 into H5FD_MEM_BTREE free-space manager */ - if(H5MF_xfree(f, btype, baddr5, (hsize_t)TBLOCK_SIZE5) < 0) + if (H5MF_xfree(f, btype, baddr5, (hsize_t)TBLOCK_SIZE5) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, btype, baddr7, (hsize_t)TBLOCK_SIZE7) < 0) + if (H5MF_xfree(f, btype, baddr7, (hsize_t)TBLOCK_SIZE7) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */ - if(H5F_addr_defined(f->shared->fs_addr[stype])) + if (H5F_addr_defined(f->shared->fs_addr[stype])) TEST_ERROR /* Verify that the free-space manager for H5FD_MEM_SUPER is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) + if (!H5F_addr_defined(f->shared->fs_addr[type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TBLOCK_SIZE3+TBLOCK_SIZE5+TBLOCK_SIZE7)) + if (fs_stat.tot_space < (TBLOCK_SIZE3 + TBLOCK_SIZE5 + TBLOCK_SIZE7)) TEST_ERROR /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(tmp_addr != addr3) + if (tmp_addr != addr3) TEST_ERROR /* Retrieve block #7 from H5FD_MEM_BTREE free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE7))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE7))) FAIL_STACK_ERROR - if(tmp_addr != baddr7) + if (tmp_addr != baddr7) TEST_ERROR /* There should still be block #5 of H5FD_MEM_BTREE in H5FD_MEM_BTREE free-space manager */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) + if (!H5F_addr_defined(f->shared->fs_addr[type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < TBLOCK_SIZE5) + if (fs_stat.tot_space < TBLOCK_SIZE5) TEST_ERROR /* Closing */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); H5Pclose(fcpl); H5Pclose(fapl); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_fs_persist_split() */ -#define MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) { \ - H5FD_mem_t mt; \ - HDmemset(memb_map, 0, sizeof memb_map); \ - HDmemset(memb_fapl, 0, sizeof memb_fapl); \ - HDmemset(memb_name, 0, sizeof memb_name); \ - HDmemset(memb_addr, 0, sizeof memb_addr); \ - HDmemset(sv, 0, sizeof sv); \ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { \ - memb_map[mt] = H5FD_MEM_SUPER; \ - memb_fapl[mt] = H5P_DEFAULT; \ - } \ - memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE; \ - memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; \ - memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; \ - memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP; \ - HDsprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); \ - memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; \ - memb_addr[H5FD_MEM_SUPER] = 0; \ - HDsprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b'); \ - memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; \ - memb_addr[H5FD_MEM_BTREE] = HADDR_MAX/6; \ - HDsprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); \ - memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; \ - memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/3; \ - HDsprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g'); \ - memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; \ - memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX/2; \ - HDsprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l'); \ - memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP]; \ - memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX*2/3; \ - HDsprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o'); \ - memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR]; \ - memb_addr[H5FD_MEM_OHDR] = HADDR_MAX*5/6; \ -} +#define MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) \ + { \ + H5FD_mem_t mt; \ + HDmemset(memb_map, 0, sizeof memb_map); \ + HDmemset(memb_fapl, 0, sizeof memb_fapl); \ + HDmemset(memb_name, 0, sizeof memb_name); \ + HDmemset(memb_addr, 0, sizeof memb_addr); \ + HDmemset(sv, 0, sizeof sv); \ + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { \ + memb_map[mt] = H5FD_MEM_SUPER; \ + memb_fapl[mt] = H5P_DEFAULT; \ + } \ + memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE; \ + memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; \ + memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; \ + memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP; \ + HDsprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); \ + memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; \ + memb_addr[H5FD_MEM_SUPER] = 0; \ + HDsprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b'); \ + memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; \ + memb_addr[H5FD_MEM_BTREE] = HADDR_MAX / 6; \ + HDsprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); \ + memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; \ + memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 3; \ + HDsprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g'); \ + memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; \ + memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX / 2; \ + HDsprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l'); \ + memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP]; \ + memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX * 2 / 3; \ + HDsprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o'); \ + memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR]; \ + memb_addr[H5FD_MEM_OHDR] = HADDR_MAX * 5 / 6; \ + } /* *------------------------------------------------------------------------- @@ -6414,26 +6585,25 @@ error: static unsigned test_mf_fs_persist_multi(void) { - hid_t file = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t fapl = -1; /* File access property list ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type, stype, btype, gtype; /* File allocation type */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - haddr_t addr1, addr2, addr3, addr4; /* File allocation type */ - haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_SUPER */ - haddr_t baddr1, baddr2, baddr3, baddr4; /* File address for H5FD_MEM_DRAW */ - haddr_t gaddr1, gaddr2; /* File address for H5FD_MEM_GHEAP */ - haddr_t tmp_addr; /* Temporary variable for address */ - H5FS_section_info_t *node; /* Free space section node */ - htri_t node_found = FALSE; /* Indicate section is in free-space */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */ - hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */ - char sv[H5FD_MEM_NTYPES][64]; /* Name generators */ - const char *memb_name[H5FD_MEM_NTYPES]; /* Name generators */ - haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */ - + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl = -1; /* File access property list ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FD_mem_t type, stype, btype, gtype; /* File allocation type */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + haddr_t addr1, addr2, addr3, addr4; /* File allocation type */ + haddr_t saddr1, saddr2, saddr3, saddr4; /* File address for H5FD_MEM_SUPER */ + haddr_t baddr1, baddr2, baddr3, baddr4; /* File address for H5FD_MEM_DRAW */ + haddr_t gaddr1, gaddr2; /* File address for H5FD_MEM_GHEAP */ + haddr_t tmp_addr; /* Temporary variable for address */ + H5FS_section_info_t *node; /* Free space section node */ + htri_t node_found = FALSE; /* Indicate section is in free-space */ + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */ + hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */ + char sv[H5FD_MEM_NTYPES][64]; /* Name generators */ + const char * memb_name[H5FD_MEM_NTYPES]; /* Name generators */ + haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */ TESTING("File's free-space managers are persistent for multi-file"); @@ -6442,286 +6612,290 @@ test_mf_fs_persist_multi(void) */ SKIPPED(); HDfprintf(stdout, " Persistent FSMs disabled in multi file driver.\n"); - return 0; /* <========== note return */ + return 0; /* <========== note return */ /* for now, we don't support persistent free space managers * with the multi file driver. */ SKIPPED(); HDfprintf(stdout, " Persistent FSMs disabled in multi file driver.\n"); - return 0; /* <========== note return */ + return 0; /* <========== note return */ /* File creation property list template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) FAIL_STACK_ERROR - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR MULTI_SETUP(memb_map, memb_fapl, memb_name, memb_addr, sv) - if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) TEST_ERROR; /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 4 blocks of type H5FD_MEM_SUPER */ type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR /* Put block #1, #3 into H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR /* Allocate 4 blocks of type H5FD_MEM_DRAW */ stype = H5FD_MEM_DRAW; - if(HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (saddr2 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (saddr3 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (saddr4 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR /* Put block #1, #3 into H5FD_MEM_DRAW free-space manager */ - if(H5MF_xfree(f, stype, saddr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, stype, saddr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, stype, saddr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, stype, saddr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) + if (!H5F_addr_defined(f->shared->fs_addr[type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + if (fs_stat.tot_space < (TBLOCK_SIZE1 + TBLOCK_SIZE3)) TEST_ERROR - if(fs_stat.serial_sect_count < 2) + if (fs_stat.serial_sect_count < 2) TEST_ERROR /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager; block #3 still in free-space */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(tmp_addr != addr1) + if (tmp_addr != addr1) TEST_ERROR /* Verify that the free-space manager for H5FD_MEM_DRAW is there */ - if(!H5F_addr_defined(f->shared->fs_addr[stype])) + if (!H5F_addr_defined(f->shared->fs_addr[stype])) TEST_ERROR /* Start up H5FD_MEM_DRAW free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)stype) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)stype) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[stype], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[stype], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + if (fs_stat.tot_space < (TBLOCK_SIZE1 + TBLOCK_SIZE3)) TEST_ERROR - if(fs_stat.serial_sect_count < 2) + if (fs_stat.serial_sect_count < 2) TEST_ERROR /* Retrieve blocks #1 from H5FD_MEM_DRAW free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(tmp_addr != saddr1) + if (tmp_addr != saddr1) TEST_ERROR /* Retrieve blocks #3 from H5FD_MEM_DRAW free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(tmp_addr != saddr3) + if (tmp_addr != saddr3) TEST_ERROR /* Allocate 4 blocks of type H5FD_MEM_BTREE */ btype = H5FD_MEM_BTREE; - if(HADDR_UNDEF == (baddr1 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (baddr1 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr2 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (baddr2 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr3 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (baddr3 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (baddr4 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (baddr4 = H5MF_alloc(f, btype, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR /* Put block #1 & #3 into H5FD_MEM_BTREE free-space manager */ - if(H5MF_xfree(f, btype, baddr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, btype, baddr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, btype, baddr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, btype, baddr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the free-space manager for H5FD_MEM_SUPER is there */ - if(!H5F_addr_defined(f->shared->fs_addr[type])) + if (!H5F_addr_defined(f->shared->fs_addr[type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[type], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < TBLOCK_SIZE3) + if (fs_stat.tot_space < TBLOCK_SIZE3) TEST_ERROR /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(tmp_addr != addr3) + if (tmp_addr != addr3) TEST_ERROR /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */ - if(H5F_addr_defined(f->shared->fs_addr[stype])) + if (H5F_addr_defined(f->shared->fs_addr[stype])) TEST_ERROR /* Verify that the free-space manager for H5FD_MEM_BTREE is there */ - if(!H5F_addr_defined(f->shared->fs_addr[btype])) + if (!H5F_addr_defined(f->shared->fs_addr[btype])) TEST_ERROR /* Start up H5FD_MEM_BTREE free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)btype) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)btype) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[btype], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[btype], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3)) + if (fs_stat.tot_space < (TBLOCK_SIZE1 + TBLOCK_SIZE3)) TEST_ERROR - if(fs_stat.serial_sect_count < 2) + if (fs_stat.serial_sect_count < 2) TEST_ERROR /* Allocate 2 blocks of type H5FD_MEM_GHEAP */ gtype = H5FD_MEM_GHEAP; - if(HADDR_UNDEF == (gaddr2 = H5MF_alloc(f, gtype, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (gaddr2 = H5MF_alloc(f, gtype, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (gaddr1 = H5MF_alloc(f, gtype, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (gaddr1 = H5MF_alloc(f, gtype, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR /* Put block #2 into H5FD_MEM_GHEAP free-space manager */ - if(H5MF_xfree(f, gtype, gaddr2, (hsize_t)TBLOCK_SIZE2) < 0) + if (H5MF_xfree(f, gtype, gaddr2, (hsize_t)TBLOCK_SIZE2) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* If H5FD_MEM_SUPER is there, should not find block #1 & #3 */ - if(H5F_addr_defined(f->shared->fs_addr[type])) { + if (H5F_addr_defined(f->shared->fs_addr[type])) { /* Start up H5FD_MEM_SUPER free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)type) < 0) FAIL_STACK_ERROR - if((node_found = H5FS_sect_find(f, f->shared->fs_man[type], - (hsize_t)TBLOCK_SIZE1, (H5FS_section_info_t **)&node)) < 0) + if ((node_found = H5FS_sect_find(f, f->shared->fs_man[type], (hsize_t)TBLOCK_SIZE1, + (H5FS_section_info_t **)&node)) < 0) FAIL_STACK_ERROR - if(node_found) TEST_ERROR + if (node_found) + TEST_ERROR - if((node_found = H5FS_sect_find(f, f->shared->fs_man[type], - (hsize_t)TBLOCK_SIZE3, (H5FS_section_info_t **)&node)) < 0) + if ((node_found = H5FS_sect_find(f, f->shared->fs_man[type], (hsize_t)TBLOCK_SIZE3, + (H5FS_section_info_t **)&node)) < 0) FAIL_STACK_ERROR - if(node_found) TEST_ERROR + if (node_found) + TEST_ERROR } /* Verify that the H5FD_MEM_GHEAP free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[gtype])) + if (!H5F_addr_defined(f->shared->fs_addr[gtype])) TEST_ERROR /* Start up H5FD_MEM_GHEAP free-space manager */ - if(H5MF__open_fstype(f, (H5F_mem_page_t)gtype) < 0) + if (H5MF__open_fstype(f, (H5F_mem_page_t)gtype) < 0) FAIL_STACK_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[gtype], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[gtype], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < TBLOCK_SIZE2) + if (fs_stat.tot_space < TBLOCK_SIZE2) TEST_ERROR /* Closing */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); H5Pclose(fcpl); H5Pclose(fapl); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_fs_persist_multi() */ #endif /* PB_OUT */ @@ -6733,41 +6907,43 @@ error: static unsigned test_mf_fs_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - hid_t file = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t fapl2 = -1; /* File access property list ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; /* File allocation type */ - H5FD_mem_t tt; /* File allocation type */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ - haddr_t tmp_addr; /* Temporary variable for address */ - - if(new_format) + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl2 = -1; /* File access property list ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; /* File allocation type */ + H5FD_mem_t tt; /* File allocation type */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ + haddr_t tmp_addr; /* Temporary variable for address */ + + if (new_format) TESTING("File's free-space is persistent with new library format") else TESTING("File's free-space is persistent with old library format") - if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")) { + if (HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")) { /* File creation property list template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR - if(new_format) { + if (new_format) { /* Latest format */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Set to paged aggregation and persisting free-space */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) TEST_ERROR - } else { + } + else { /* Setting: aggregation with persisting free-space */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) TEST_ERROR } @@ -6775,125 +6951,127 @@ test_mf_fs_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 6 blocks */ type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5))) + if (HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE6))) + if (HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE6))) FAIL_STACK_ERROR /* Put block #1, #3, #5 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr5, (hsize_t)TBLOCK_SIZE5) < 0) + if (H5MF_xfree(f, type, addr5, (hsize_t)TBLOCK_SIZE5) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__alloc_to_fs_type(f->shared, type, TBLOCK_SIZE6, (H5F_mem_page_t *)&tt); /* Verify that H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[tt])) + if (!H5F_addr_defined(f->shared->fs_addr[tt])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(!(f->shared->fs_man[tt])) - if(H5MF__open_fstype(f, (H5F_mem_page_t)tt) < 0) + if (!(f->shared->fs_man[tt])) + if (H5MF__open_fstype(f, (H5F_mem_page_t)tt) < 0) FAIL_STACK_ERROR /* Get info for free-space manager */ - if(H5FS_stat_info(f, f->shared->fs_man[tt], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[tt], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify free-space info */ - if(fs_stat.tot_space < (TBLOCK_SIZE1+TBLOCK_SIZE3+TBLOCK_SIZE5)) + if (fs_stat.tot_space < (TBLOCK_SIZE1 + TBLOCK_SIZE3 + TBLOCK_SIZE5)) TEST_ERROR - if(fs_stat.serial_sect_count < 3) + if (fs_stat.serial_sect_count < 3) TEST_ERROR /* Retrieve block #3 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(tmp_addr != addr3) + if (tmp_addr != addr3) TEST_ERROR /* Retrieve block #1 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(tmp_addr != addr1) + if (tmp_addr != addr1) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[tt])) + if (!H5F_addr_defined(f->shared->fs_addr[tt])) TEST_ERROR /* Retrieve block #5 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5))) + if (HADDR_UNDEF == (tmp_addr = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5))) FAIL_STACK_ERROR - if(tmp_addr != addr5) + if (tmp_addr != addr5) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support persisting free-space or paged aggregation strategy"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); H5Pclose(fcpl); H5Pclose(fapl2); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_fs_persist() */ /* @@ -6904,19 +7082,19 @@ error: static unsigned test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - hid_t file = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - hid_t fapl2 = -1; /* File access property list */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; /* File allocation type */ + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + hid_t fapl2 = -1; /* File access property list */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; /* File allocation type */ H5FS_stat_t fs_stat; /* Information for free-space manager */ - haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ - haddr_t addrx; + haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ + haddr_t addrx; H5FD_mem_t fs_type; - hbool_t contig_addr_vfd; + hbool_t contig_addr_vfd; - if(new_format) + if (new_format) TESTING("File's free-space is going away with new library format") else TESTING("File's free-space is going away with old library format") @@ -6924,160 +7102,165 @@ test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Current VFD that does not support contigous address space */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* File creation property list template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR - if(new_format) { - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (new_format) { + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR - } else { - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) + } + else { + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR } /* Set to aggregation and persisting free-space */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 4 blocks */ type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR /* Put block #1, #3 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR /* Retrieve block #1, #3 from H5FD_MEM_SUPER free-space manager */ - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__alloc_to_fs_type(f->shared, type, TBLOCK_SIZE4, (H5F_mem_page_t *)&fs_type); /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ - if(H5F_addr_defined(f->shared->fs_addr[fs_type])) + if (H5F_addr_defined(f->shared->fs_addr[fs_type])) TEST_ERROR /* Put block #3 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that H5FD_MEM_SUPER free-space manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) + if (!H5F_addr_defined(f->shared->fs_addr[fs_type])) TEST_ERROR /* Start up H5FD_MEM_SUPER free-space manager */ - if(!(f->shared->fs_man[fs_type])) - if(H5MF__open_fstype(f, (H5F_mem_page_t)fs_type) < 0) + if (!(f->shared->fs_man[fs_type])) + if (H5MF__open_fstype(f, (H5F_mem_page_t)fs_type) < 0) FAIL_STACK_ERROR /* Get info for H5FD_MEM_SUPER free-space manager */ - if(H5FS_stat_info(f, f->shared->fs_man[fs_type], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[fs_type], &fs_stat) < 0) FAIL_STACK_ERROR - if(!H5F_addr_defined(fs_stat.addr)) + if (!H5F_addr_defined(fs_stat.addr)) TEST_ERROR - if(fs_stat.tot_space < TBLOCK_SIZE3) + if (fs_stat.tot_space < TBLOCK_SIZE3) TEST_ERROR /* Allocate/free space accordingly so that the free-space manager will go away */ - if(new_format) { - if(H5MF_xfree(f, type, addr4, (hsize_t)TBLOCK_SIZE4) < 0) + if (new_format) { + if (H5MF_xfree(f, type, addr4, (hsize_t)TBLOCK_SIZE4) < 0) FAIL_STACK_ERROR - } else { - if(HADDR_UNDEF == (addrx = H5MF_alloc(f, type, (hsize_t)3))) + } + else { + if (HADDR_UNDEF == (addrx = H5MF_alloc(f, type, (hsize_t)3))) FAIL_STACK_ERROR } /* The H5FD_MEM_SUPER free-space manager will go away at H5MF_close() */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ - if(H5F_addr_defined(f->shared->fs_addr[fs_type])) + if (H5F_addr_defined(f->shared->fs_addr[fs_type])) TEST_ERROR /* Closing */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support persistent free-space manager"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); H5Pclose(fcpl); H5Pclose(fapl2); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_fs_gone() */ /* @@ -7089,20 +7272,20 @@ error: static unsigned test_mf_strat_thres_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - hid_t file = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list template */ - hid_t fapl2 = -1; /* File access property list template */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; /* File allocation type */ - H5FD_mem_t tt; /* File allocation type */ - haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ - H5F_fspace_strategy_t fs_type; /* File space handling strategy */ - hsize_t fs_threshold; /* Free-space section threshold */ - unsigned fs_persist; /* To persist free-space or not */ - hbool_t contig_addr_vfd; - - if(new_format) + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list template */ + hid_t fapl2 = -1; /* File access property list template */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; /* File allocation type */ + H5FD_mem_t tt; /* File allocation type */ + haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ + H5F_fspace_strategy_t fs_type; /* File space handling strategy */ + hsize_t fs_threshold; /* Free-space section threshold */ + unsigned fs_persist; /* To persist free-space or not */ + hbool_t contig_addr_vfd; + + if (new_format) TESTING("File space strategy/persisting/threshold with new library format") else TESTING("File space strategy/persisting/threshold with old library format") @@ -7110,142 +7293,143 @@ test_mf_strat_thres_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_for /* Current VFD that does not support contigous address space */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) - FAIL_STACK_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + FAIL_STACK_ERROR - if(new_format) - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (new_format) + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Test with TRUE or FALSE for persisting free-space */ - for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + for (fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { - for(fs_threshold = 0; fs_threshold <= TEST_THRESHOLD10; fs_threshold++) { + for (fs_threshold = 0; fs_threshold <= TEST_THRESHOLD10; fs_threshold++) { /* Testing for H5F_FSPACE_STRATEGY_FSM_AGGR and H5F_FSPACE_STRATEGY_PAGE strategies only */ - for(fs_type = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_type < H5F_FSPACE_STRATEGY_AGGR; fs_type++) { + for (fs_type = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_type < H5F_FSPACE_STRATEGY_AGGR; fs_type++) { - if(!contig_addr_vfd && (fs_persist || fs_type == H5F_FSPACE_STRATEGY_PAGE)) + if (!contig_addr_vfd && (fs_persist || fs_type == H5F_FSPACE_STRATEGY_PAGE)) continue; /* Create file-creation template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set default file space information */ - if(H5Pset_file_space_strategy(fcpl, fs_type, (hbool_t)fs_persist, fs_threshold) < 0) + if (H5Pset_file_space_strategy(fcpl, fs_type, (hbool_t)fs_persist, fs_threshold) < 0) FAIL_STACK_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 6 blocks */ type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5))) + if (HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE6))) + if (HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE6))) FAIL_STACK_ERROR /* Put block #1, #3, #5 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr5, (hsize_t)TBLOCK_SIZE5) < 0) + if (H5MF_xfree(f, type, addr5, (hsize_t)TBLOCK_SIZE5) < 0) FAIL_STACK_ERROR - /* Close the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF__alloc_to_fs_type(f->shared, type, TBLOCK_SIZE6, (H5F_mem_page_t *)&tt); /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR - if(f->shared->fs_persist) { - hssize_t nsects; /* # of free-space sections */ - int i; /* local index variable */ + if (f->shared->fs_persist) { + hssize_t nsects; /* # of free-space sections */ + int i; /* local index variable */ H5F_sect_info_t *sect_info; /* array to hold the free-space information */ /* Get the # of free-space sections in the file */ - if((nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, NULL)) < 0) + if ((nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)0, NULL)) < 0) FAIL_STACK_ERROR /* Verify no free-space sections */ /* paged aggregation has 1 section for last_small */ - if(fs_threshold > TBLOCK_SIZE5 && nsects && fs_type != H5F_FSPACE_STRATEGY_PAGE) + if (fs_threshold > TBLOCK_SIZE5 && nsects && fs_type != H5F_FSPACE_STRATEGY_PAGE) TEST_ERROR - if(nsects) { + if (nsects) { /* Allocate storage for the free space section information */ sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t)); H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)nsects, sect_info); /* Verify the size of free-space sections */ - for(i = 0; i < nsects; i++) - if(sect_info[i].size < fs_threshold) + for (i = 0; i < nsects; i++) + if (sect_info[i].size < fs_threshold) TEST_ERROR - if(sect_info) + if (sect_info) HDfree(sect_info); } - } else { - if(H5F_addr_defined(f->shared->fs_addr[tt])) + } + else { + if (H5F_addr_defined(f->shared->fs_addr[tt])) TEST_ERROR } /* Closing */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR } /* end for fs_type */ - } /* end for fs_threshold */ - } /* end for fs_persist */ + } /* end for fs_threshold */ + } /* end for fs_persist */ - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl); H5Pclose(fapl2); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_strat_thres_persist() */ /* @@ -7257,21 +7441,21 @@ error: static unsigned test_mf_strat_thres_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { - hid_t file = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list template */ - hid_t fapl2 = -1; /* File access property list template */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type; /* File allocation type */ - H5FD_mem_t tt; /* File allocation type */ - haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ - H5F_fspace_strategy_t fs_type; /* File space handling strategy */ - unsigned fs_persist; /* To persist free-space or not */ - H5FS_stat_t fs_state; /* Information for free-space manager */ - H5FS_stat_t fs_state_zero; /* Information for free-space manager */ - hbool_t contig_addr_vfd; - - if(new_format) + hid_t file = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list template */ + hid_t fapl2 = -1; /* File access property list template */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FD_mem_t type; /* File allocation type */ + H5FD_mem_t tt; /* File allocation type */ + haddr_t addr1, addr2, addr3, addr4, addr5, addr6; /* File address for H5FD_MEM_SUPER */ + H5F_fspace_strategy_t fs_type; /* File space handling strategy */ + unsigned fs_persist; /* To persist free-space or not */ + H5FS_stat_t fs_state; /* Information for free-space manager */ + H5FS_stat_t fs_state_zero; /* Information for free-space manager */ + hbool_t contig_addr_vfd; + + if (new_format) TESTING("File space merge/shrink for section size < threshold with new library format") else TESTING("File space merge/shrink for section size < threshold with old library format") @@ -7279,158 +7463,162 @@ test_mf_strat_thres_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format /* Current VFD that does not support contigous address space */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); HDmemset(&fs_state_zero, 0, sizeof(H5FS_stat_t)); /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) + if ((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR - if(new_format) - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (new_format) + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Test with TRUE or FALSE for persisting free-space */ - for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + for (fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { /* Testing for H5F_FSPACE_STRATEGY_FSM_AGGR and H5F_FSPACE_STRATEGY_PAGE strategies only */ - for(fs_type = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_type < H5F_FSPACE_STRATEGY_AGGR; fs_type++) { + for (fs_type = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_type < H5F_FSPACE_STRATEGY_AGGR; fs_type++) { /* Skip for multi/split driver: persisting free-space or paged aggregation strategy */ - if(!contig_addr_vfd && (fs_persist || fs_type == H5F_FSPACE_STRATEGY_PAGE)) + if (!contig_addr_vfd && (fs_persist || fs_type == H5F_FSPACE_STRATEGY_PAGE)) continue; /* Clear out free-space statistics */ HDmemset(&fs_state, 0, sizeof(H5FS_stat_t)); /* Create file-creation template */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set default file space information */ - if(H5Pset_file_space_strategy(fcpl, fs_type, fs_persist, (hsize_t)TEST_THRESHOLD3) < 0) + if (H5Pset_file_space_strategy(fcpl, fs_type, fs_persist, (hsize_t)TEST_THRESHOLD3) < 0) FAIL_STACK_ERROR /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 6 blocks */ type = H5FD_MEM_SUPER; - if(HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) + if (HADDR_UNDEF == (addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE1))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) + if (HADDR_UNDEF == (addr2 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE2))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) + if (HADDR_UNDEF == (addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE3))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) + if (HADDR_UNDEF == (addr4 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE4))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5))) + if (HADDR_UNDEF == (addr5 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE5))) FAIL_STACK_ERROR - if(HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE6))) + if (HADDR_UNDEF == (addr6 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE6))) FAIL_STACK_ERROR H5MF__alloc_to_fs_type(f->shared, type, TBLOCK_SIZE6, (H5F_mem_page_t *)&tt); /* For paged aggregation, the section in the page at EOF for small meta fs is not shrunk away */ - if(fs_type == H5F_FSPACE_STRATEGY_PAGE) - if(H5FS_stat_info(f, f->shared->fs_man[tt], &fs_state) < 0) + if (fs_type == H5F_FSPACE_STRATEGY_PAGE) + if (H5FS_stat_info(f, f->shared->fs_man[tt], &fs_state) < 0) FAIL_STACK_ERROR /* Put block #3, #5 to H5FD_MEM_SUPER free-space manager */ - if(H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) + if (H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr5, (hsize_t)TBLOCK_SIZE5) < 0) + if (H5MF_xfree(f, type, addr5, (hsize_t)TBLOCK_SIZE5) < 0) FAIL_STACK_ERROR fs_state.tot_space += TBLOCK_SIZE3 + TBLOCK_SIZE5; fs_state.tot_sect_count += 2; fs_state.serial_sect_count += 2; - if(check_stats(f, f->shared->fs_man[tt], &fs_state)) + if (check_stats(f, f->shared->fs_man[tt], &fs_state)) TEST_ERROR /* section #2 is less than threshold but is merged into section #3 */ - if(H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE2) < 0) + if (H5MF_xfree(f, type, addr2, (hsize_t)TBLOCK_SIZE2) < 0) FAIL_STACK_ERROR fs_state.tot_space += TBLOCK_SIZE2; - if(check_stats(f, f->shared->fs_man[tt], &fs_state)) + if (check_stats(f, f->shared->fs_man[tt], &fs_state)) TEST_ERROR - if(H5MF_xfree(f, type, addr4, (hsize_t)TBLOCK_SIZE4) < 0) + if (H5MF_xfree(f, type, addr4, (hsize_t)TBLOCK_SIZE4) < 0) FAIL_STACK_ERROR - if(H5MF_xfree(f, type, addr6, (hsize_t)TBLOCK_SIZE6) < 0) + if (H5MF_xfree(f, type, addr6, (hsize_t)TBLOCK_SIZE6) < 0) FAIL_STACK_ERROR - /* For paged aggregation, the sections in the page at EOF for small meta fs are merged but are not shrunk away */ - if(fs_type == H5F_FSPACE_STRATEGY_PAGE) { + /* For paged aggregation, the sections in the page at EOF for small meta fs are merged but are not + * shrunk away */ + if (fs_type == H5F_FSPACE_STRATEGY_PAGE) { fs_state.tot_sect_count = fs_state.serial_sect_count = 1; fs_state.tot_space += (TBLOCK_SIZE4 + TBLOCK_SIZE6); } /* For old format: the sections at EOF are shrunk away */ - if(check_stats(f, f->shared->fs_man[tt], (fs_type == H5F_FSPACE_STRATEGY_PAGE) ? &fs_state:&fs_state_zero)) + if (check_stats(f, f->shared->fs_man[tt], + (fs_type == H5F_FSPACE_STRATEGY_PAGE) ? &fs_state : &fs_state_zero)) TEST_ERROR /* section #1 is less than threshold but is shrunk away */ - if(H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) + if (H5MF_xfree(f, type, addr1, (hsize_t)TBLOCK_SIZE1) < 0) FAIL_STACK_ERROR /* For paged aggregation, the section in the page at EOF for small meta fs is not shrunk away */ - if(fs_type == H5F_FSPACE_STRATEGY_PAGE) + if (fs_type == H5F_FSPACE_STRATEGY_PAGE) fs_state.tot_space += TBLOCK_SIZE1; /* For old format: the sections at EOF are shrunk away */ - if(check_stats(f, f->shared->fs_man[tt], (fs_type == H5F_FSPACE_STRATEGY_PAGE) ? &fs_state : &fs_state_zero)) + if (check_stats(f, f->shared->fs_man[tt], + (fs_type == H5F_FSPACE_STRATEGY_PAGE) ? &fs_state : &fs_state_zero)) TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Free-space manager should be empty */ - if(!(fs_type == H5F_FSPACE_STRATEGY_PAGE && fs_persist)) - if(H5F_addr_defined(f->shared->fs_addr[tt])) + if (!(fs_type == H5F_FSPACE_STRATEGY_PAGE && fs_persist)) + if (H5F_addr_defined(f->shared->fs_addr[tt])) TEST_ERROR /* Closing */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR } /* end for fs_type */ - } /* end for fs_persist */ + } /* end for fs_persist */ - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl); H5Pclose(fapl2); H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_mf_strat_thres_gone() */ /* @@ -7458,11 +7646,11 @@ error: static unsigned test_dichotomy(hid_t fapl) { - hid_t file = -1; /* File ID */ - char filename[FILENAME_LEN]; /* Filename to use */ - H5F_t *f = NULL; /* Internal file object pointer */ - H5FD_mem_t type, stype; - haddr_t addr1, addr3, saddr1, saddr2; + hid_t file = -1; /* File ID */ + char filename[FILENAME_LEN]; /* Filename to use */ + H5F_t * f = NULL; /* Internal file object pointer */ + H5FD_mem_t type, stype; + haddr_t addr1, addr3, saddr1, saddr2; TESTING("Allocation from raw or metadata free-space manager"); @@ -7470,22 +7658,22 @@ test_dichotomy(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate the first block of type H5FD_MEM_SUPER */ - type = H5FD_MEM_SUPER; + type = H5FD_MEM_SUPER; addr1 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Allocate the second block of type H5FD_MEM_SUPER */ H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE50); /* Allocate the first block of type H5FD_MEM_DRAW */ - stype = H5FD_MEM_DRAW; + stype = H5FD_MEM_DRAW; saddr1 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); /* Free the first block of type H5FD_MEM_SUPER */ @@ -7495,7 +7683,8 @@ test_dichotomy(hid_t fapl) saddr2 = H5MF_alloc(f, stype, (hsize_t)TBLOCK_SIZE30); /* Verify that saddr1 is not addr1 */ - if(saddr2 == addr1) TEST_ERROR + if (saddr2 == addr1) + TEST_ERROR /* Free the first block of type H5FD_MEM_DRAW */ H5MF_xfree(f, stype, saddr1, (hsize_t)TBLOCK_SIZE30); @@ -7504,20 +7693,23 @@ test_dichotomy(hid_t fapl) addr3 = H5MF_alloc(f, type, (hsize_t)TBLOCK_SIZE30); /* Verify that addr3 is not saddr1 */ - if(addr3 == saddr1) TEST_ERROR + if (addr3 == saddr1) + TEST_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_dichotomy() */ /* @@ -7531,42 +7723,44 @@ static int set_multi_split(hid_t fapl, hsize_t pagesize, hbool_t is_multi_or_split) { H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; - char *memb_name[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - hbool_t relax; - H5FD_mem_t mt; + hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; + char * memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + H5FD_mem_t mt; HDassert(is_multi_or_split); HDmemset(memb_name, 0, sizeof memb_name); /* Get current split settings */ - if(H5Pget_fapl_multi(fapl, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) + if (H5Pget_fapl_multi(fapl, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) TEST_ERROR - if(is_multi_or_split) { + if (is_multi_or_split) { /* Set memb_addr aligned */ memb_addr[H5FD_MEM_SUPER] = ((memb_addr[H5FD_MEM_SUPER] + pagesize - 1) / pagesize) * pagesize; - memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + pagesize - 1) / pagesize) * pagesize; - } else { + memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + pagesize - 1) / pagesize) * pagesize; + } + else { /* Set memb_addr aligned */ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) memb_addr[mt] = ((memb_addr[mt] + pagesize - 1) / pagesize) * pagesize; } /* end else */ /* Set multi driver with new FAPLs */ - if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl_arr, (const char *const *)memb_name, memb_addr, relax) < + 0) TEST_ERROR /* Free memb_name */ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) free(memb_name[mt]); return 0; error: - return(-1); + return (-1); } /* set_multi_split() */ /*------------------------------------------------------------------------- @@ -7586,55 +7780,56 @@ static unsigned test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - hid_t fapl_new = -1; /* File access property list ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - haddr_t addr2, addr3; /* Addresses for small metadata blocks */ - haddr_t saddr1; /* Addresses for small raw data blocks */ - haddr_t gaddr1; /* Addresses for large data blocks */ - hbool_t split = FALSE, multi = FALSE; - char filename[FILENAME_LEN]; /* Filename to use */ - haddr_t found_addr; /* Address of the found section */ - unsigned fs_persist; /* To persist free-space or not */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + hid_t fapl_new = -1; /* File access property list ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + haddr_t addr2, addr3; /* Addresses for small metadata blocks */ + haddr_t saddr1; /* Addresses for small raw data blocks */ + haddr_t gaddr1; /* Addresses for large data blocks */ + hbool_t split = FALSE, multi = FALSE; + char filename[FILENAME_LEN]; /* Filename to use */ + haddr_t found_addr; /* Address of the found section */ + unsigned fs_persist; /* To persist free-space or not */ TESTING("Paged aggregation for file space: H5MF_alloc/H5MF_xfree"); /* Check for split or multi driver */ - if(!HDstrcmp(env_h5_drvr, "split")) + if (!HDstrcmp(env_h5_drvr, "split")) split = TRUE; - else if(!HDstrcmp(env_h5_drvr, "multi")) + else if (!HDstrcmp(env_h5_drvr, "multi")) multi = TRUE; - if(!multi && !split) { + if (!multi && !split) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_new = H5Pcopy(fapl)) < 0) + TEST_ERROR - if(multi || split) - if(set_multi_split(fapl_new, 4096, split) < 0) + if (multi || split) + if (set_multi_split(fapl_new, 4096, split) < 0) TEST_ERROR; /* Test with TRUE or FALSE for persisting free-space */ - for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + for (fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { H5F_mem_page_t fs_type; /* File creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR /* Set the strategy to paged aggregation */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, fs_persist, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, fs_persist, (hsize_t)1) < 0) TEST_ERROR /* Create the file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR /* Allocate 3 small metadata blocks: addr1, addr2, addr3 */ @@ -7645,13 +7840,14 @@ test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) /* Free the block with addr2 */ H5MF_xfree(f, H5FD_MEM_OHDR, addr2, (hsize_t)TBLOCK_SIZE1034); - if(!fs_persist) { + if (!fs_persist) { H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_OHDR, TBLOCK_SIZE1034, (H5F_mem_page_t *)&fs_type); /* Verify that the freed block with addr2 is found from the small metadata manager */ - if(H5MF__find_sect(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE1034, f->shared->fs_man[fs_type], &found_addr) < 0) + if (H5MF__find_sect(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE1034, f->shared->fs_man[fs_type], + &found_addr) < 0) TEST_ERROR - if(found_addr != addr2) + if (found_addr != addr2) TEST_ERROR } /* end if */ @@ -7662,11 +7858,12 @@ test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) /* Free the block with saddr1 */ H5MF_xfree(f, H5FD_MEM_DRAW, saddr1, (hsize_t)TBLOCK_SIZE30); - if(!fs_persist) { + if (!fs_persist) { /* Verify that the freed block with saddr1 is found from the small raw data manager */ - if(H5MF__find_sect(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5F_MEM_PAGE_DRAW], &found_addr) < 0) + if (H5MF__find_sect(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE30, + f->shared->fs_man[H5F_MEM_PAGE_DRAW], &found_addr) < 0) TEST_ERROR - if(found_addr != saddr1) + if (found_addr != saddr1) TEST_ERROR } /* end if */ @@ -7677,108 +7874,116 @@ test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) /* Free the block with gaddr1 */ H5MF_xfree(f, H5FD_MEM_DRAW, gaddr1, (hsize_t)TBLOCK_SIZE5000); - if(!fs_persist) { + if (!fs_persist) { H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_DRAW, TBLOCK_SIZE5000, (H5F_mem_page_t *)&fs_type); /* Verify that the freed block with gaddr1 is found from the large data manager */ - if(H5MF__find_sect(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE8192, f->shared->fs_man[fs_type], &found_addr) < 0) + if (H5MF__find_sect(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE8192, f->shared->fs_man[fs_type], + &found_addr) < 0) TEST_ERROR - if(found_addr != gaddr1) + if (found_addr != gaddr1) TEST_ERROR } /* end if */ /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Close the property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) TEST_ERROR - if(fs_persist) { + if (fs_persist) { /* Re-open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR /* Verify that the large generic manager is there */ H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_DRAW, TBLOCK_SIZE5000, (H5F_mem_page_t *)&fs_type); - if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) + if (!H5F_addr_defined(f->shared->fs_addr[fs_type])) TEST_ERROR /* Verify that the small metadata manager is there */ - H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_OHDR, f->shared->fs_page_size - 1, (H5F_mem_page_t *)&fs_type); - if(!H5F_addr_defined(f->shared->fs_addr[fs_type])) + H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_OHDR, f->shared->fs_page_size - 1, + (H5F_mem_page_t *)&fs_type); + if (!H5F_addr_defined(f->shared->fs_addr[fs_type])) TEST_ERROR /* Set up to use the small metadata manager */ - if(!(f->shared->fs_man[fs_type])) - if(H5MF__open_fstype(f, fs_type) < 0) + if (!(f->shared->fs_man[fs_type])) + if (H5MF__open_fstype(f, fs_type) < 0) TEST_ERROR /* Verify that the freed block with addr2 is found from the small metadata manager */ - if(H5MF__find_sect(f, H5FD_MEM_OHDR, (hsize_t)(f->shared->fs_page_size-(addr3+TBLOCK_SIZE50)), f->shared->fs_man[fs_type], &found_addr) < 0) + if (H5MF__find_sect(f, H5FD_MEM_OHDR, + (hsize_t)(f->shared->fs_page_size - (addr3 + TBLOCK_SIZE50)), + f->shared->fs_man[fs_type], &found_addr) < 0) TEST_ERROR - if(found_addr != (addr3+TBLOCK_SIZE50)) + if (found_addr != (addr3 + TBLOCK_SIZE50)) TEST_ERROR /* Verify that the small raw data manager is there */ - if(!H5F_addr_defined(f->shared->fs_addr[H5F_MEM_PAGE_DRAW])) + if (!H5F_addr_defined(f->shared->fs_addr[H5F_MEM_PAGE_DRAW])) TEST_ERROR /* Set up to use the small raw data manager */ - if(!(f->shared->fs_man[H5F_MEM_PAGE_DRAW])) - if(H5MF__open_fstype(f, H5F_MEM_PAGE_DRAW) < 0) + if (!(f->shared->fs_man[H5F_MEM_PAGE_DRAW])) + if (H5MF__open_fstype(f, H5F_MEM_PAGE_DRAW) < 0) TEST_ERROR /* Verify that the freed block with saddr1 is found from the small raw data manager */ - if(H5MF__find_sect(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE30, f->shared->fs_man[H5F_MEM_PAGE_DRAW], &found_addr) < 0) + if (H5MF__find_sect(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE30, + f->shared->fs_man[H5F_MEM_PAGE_DRAW], &found_addr) < 0) TEST_ERROR - if(found_addr != saddr1) + if (found_addr != saddr1) TEST_ERROR H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_DRAW, TBLOCK_SIZE5000, (H5F_mem_page_t *)&fs_type); - if(!(f->shared->fs_man[fs_type])) + if (!(f->shared->fs_man[fs_type])) /* Set up to use the large data manager */ - if(H5MF__open_fstype(f, fs_type) < 0) + if (H5MF__open_fstype(f, fs_type) < 0) TEST_ERROR /* Verify that the freed block with gaddr1 is found from the large data manager */ - if(H5MF__find_sect(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE8192, f->shared->fs_man[fs_type], &found_addr) < 0) + if (H5MF__find_sect(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE8192, f->shared->fs_man[fs_type], + &found_addr) < 0) TEST_ERROR - if(found_addr != gaddr1) + if (found_addr != gaddr1) TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR } /* end if fs_persist */ - } /* end for */ + } /* end for */ - if(H5Pclose(fapl_new) < 0) + if (H5Pclose(fapl_new) < 0) TEST_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support persisting free-space or paged aggregation strategy"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fcpl); H5Pclose(fapl_new); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_page_alloc_xfree() */ @@ -7799,72 +8004,78 @@ static unsigned test_page_try_shrink(const char *env_h5_drvr, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - H5F_t *f = NULL; /* Internal file object pointer */ - haddr_t addr1; /* Address for small metadata block */ - haddr_t saddr1; /* Address for small raw data block */ - haddr_t gaddr1; /* Address for large data block */ - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - htri_t status; /* status from shrinking */ - h5_stat_size_t file_size; /* File size */ - char filename[FILENAME_LEN]; /* Filename to use */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + H5F_t * f = NULL; /* Internal file object pointer */ + haddr_t addr1; /* Address for small metadata block */ + haddr_t saddr1; /* Address for small raw data block */ + haddr_t gaddr1; /* Address for large data block */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + htri_t status; /* status from shrinking */ + h5_stat_size_t file_size; /* File size */ + char filename[FILENAME_LEN]; /* Filename to use */ TESTING("Paged aggregation for file space: H5MF_try_shrink()"); /* Current VFD that does not support continuous address space */ - contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") ); + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* File creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set the strategy to paged aggregation */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) FAIL_STACK_ERROR /* Create the file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR /* Allocate a small metadata block with addr1 */ addr1 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE50); /* Try to shrink the block with addr1 */ - if((status = H5MF_try_shrink(f, H5FD_MEM_OHDR, addr1, (hsize_t)TBLOCK_SIZE50)) < 0) + if ((status = H5MF_try_shrink(f, H5FD_MEM_OHDR, addr1, (hsize_t)TBLOCK_SIZE50)) < 0) FAIL_STACK_ERROR - /* Couldn't shrink due to the section (remaining space in the page) is in the small metadata free-space manager */ - if(status == TRUE) TEST_ERROR + /* Couldn't shrink due to the section (remaining space in the page) is in the small metadata + * free-space manager */ + if (status == TRUE) + TEST_ERROR /* Allocate a small raw data block with saddr1 */ saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE50); /* Try to shrink the block with saddr1 */ - if((status = H5MF_try_shrink(f, H5FD_MEM_DRAW, saddr1, (hsize_t)TBLOCK_SIZE50)) < 0) + if ((status = H5MF_try_shrink(f, H5FD_MEM_DRAW, saddr1, (hsize_t)TBLOCK_SIZE50)) < 0) FAIL_STACK_ERROR - /* Couldn't shrink due to the section (remaining space in the page) is in the small raw data free-space manager */ - if(status == TRUE) TEST_ERROR + /* Couldn't shrink due to the section (remaining space in the page) is in the small raw data + * free-space manager */ + if (status == TRUE) + TEST_ERROR /* Allocate a large data block with gaddr1 */ gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE5000); /* Try to shrink the block with gaddr1 */ - if((status = H5MF_try_shrink(f, H5FD_MEM_DRAW, gaddr1, (hsize_t)TBLOCK_SIZE5000)) < 0) + if ((status = H5MF_try_shrink(f, H5FD_MEM_DRAW, gaddr1, (hsize_t)TBLOCK_SIZE5000)) < 0) FAIL_STACK_ERROR - /* Couldn't shrink due to the section (remaining space in the page) is in the large-sized free-space manager */ - if(status == TRUE) TEST_ERROR + /* Couldn't shrink due to the section (remaining space in the page) is in the large-sized free-space + * manager */ + if (status == TRUE) + TEST_ERROR /* Free the block with saddr1--merge to become 1 page, then return to the large manager */ H5MF_xfree(f, H5FD_MEM_DRAW, saddr1, (hsize_t)TBLOCK_SIZE50); @@ -7872,36 +8083,38 @@ test_page_try_shrink(const char *env_h5_drvr, hid_t fapl) /* Merge all 3 sections and shrunk */ H5MF_xfree(f, H5FD_MEM_OHDR, gaddr1, (hsize_t)TBLOCK_SIZE5000); - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Should be on page boundary */ - if(file_size % TBLOCK_SIZE4096) + if (file_size % TBLOCK_SIZE4096) TEST_ERROR /* Close the property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support paged aggregation"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fcpl); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_page_try_shrink() */ @@ -7922,48 +8135,51 @@ static unsigned test_page_small_try_extend(const char *env_h5_drvr, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - H5F_t *f = NULL; /* Internal file object pointer */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + H5F_t * f = NULL; /* Internal file object pointer */ haddr_t addr1, addr2, addr3; /* Addresses for small metadata blocks */ haddr_t saddr1; /* Address for small raw data block */ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - htri_t was_extended; /* Whether the block can be extended or not */ - char filename[FILENAME_LEN]; /* Filename to use */ + htri_t was_extended; /* Whether the block can be extended or not */ + char filename[FILENAME_LEN]; /* Filename to use */ TESTING("Paged aggregation for file space: H5MF_try_extend() a small block"); /* Current VFD that does not support continuous address space */ - contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")); + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && + HDstrcmp(env_h5_drvr, "family")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* File creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set the strategy to paged aggregation */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) FAIL_STACK_ERROR /* Create the file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR /* Allocate a small metadata block with addr1 */ addr1 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE98); /* Try extending the block with addr1 at EOF not crossing page boundary */ - was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE98, (hsize_t)3100); + was_extended = + H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE98, (hsize_t)3100); /* Should succeed */ - if(was_extended != TRUE) TEST_ERROR + if (was_extended != TRUE) + TEST_ERROR /* Allocate 2 small metadata blocks with addr2 and addr3--will be on another metadata page */ addr2 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE100); @@ -7971,23 +8187,29 @@ test_page_small_try_extend(const char *env_h5_drvr, hid_t fapl) /* The block with addr2 should be page aligned */ /* The block with addr3 resides right next to the block with addr2 */ - if(addr2 % TBLOCK_SIZE4096) + if (addr2 % TBLOCK_SIZE4096) TEST_ERROR - if(addr3 != (addr2 + TBLOCK_SIZE100)) + if (addr3 != (addr2 + TBLOCK_SIZE100)) TEST_ERROR /* Free the block with addr2 */ H5MF_xfree(f, H5FD_MEM_OHDR, addr2, (hsize_t)TBLOCK_SIZE100); - /* Try extending the block with addr1 that will cross to the next page where the freed block with addr2 resides */ - was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3198, (hsize_t)TBLOCK_SIZE100); + /* Try extending the block with addr1 that will cross to the next page where the freed block with + * addr2 resides */ + was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3198, + (hsize_t)TBLOCK_SIZE100); /* Shouldn't succeed--should not cross page boundary */ - if(was_extended == TRUE) TEST_ERROR + if (was_extended == TRUE) + TEST_ERROR - /* Try extending the block with addr1 into the free-space section that is big enough to fulfill the request */ - was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3198, (hsize_t)TBLOCK_SIZE50); + /* Try extending the block with addr1 into the free-space section that is big enough to fulfill the + * request */ + was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3198, + (hsize_t)TBLOCK_SIZE50); /* Should succeed */ - if(was_extended != TRUE) TEST_ERROR + if (was_extended != TRUE) + TEST_ERROR /* Free the block with addr1 */ H5MF_xfree(f, H5FD_MEM_OHDR, addr1, (hsize_t)TBLOCK_SIZE3248); @@ -7998,65 +8220,81 @@ test_page_small_try_extend(const char *env_h5_drvr, hid_t fapl) addr1 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE3286); /* Try extending the block into the threshold with size > H5F_FILE_SPACE_PGEND_META_THRES */ - was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3286, (hsize_t)TBLOCK_SIZE11); + was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3286, + (hsize_t)TBLOCK_SIZE11); /* Shouldn't succeed */ - if(was_extended == TRUE) TEST_ERROR + if (was_extended == TRUE) + TEST_ERROR /* Try extending the block into the threshold with size < H5F_FILE_SPACE_PGEND_META_THRES */ - was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3286, (hsize_t)TBLOCK_SIZE2); + was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, (haddr_t)addr1, (hsize_t)TBLOCK_SIZE3286, + (hsize_t)TBLOCK_SIZE2); /* Should succeed */ - if(was_extended != TRUE) TEST_ERROR + if (was_extended != TRUE) + TEST_ERROR - /* Free the block with addr3--will merge with the remaining sections to become a page and then free the page */ + /* Free the block with addr3--will merge with the remaining sections to become a page and then free + * the page */ H5MF_xfree(f, H5FD_MEM_OHDR, addr3, (hsize_t)TBLOCK_SIZE150); /* Allocate a small raw data block with saddr1 */ saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE4086); /* Try extending the block crossing the page boundary */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4086, (hsize_t)TBLOCK_SIZE11); + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4086, + (hsize_t)TBLOCK_SIZE11); /* Shouldn't succeed */ - if(was_extended == TRUE) TEST_ERROR + if (was_extended == TRUE) + TEST_ERROR /* Try extending the block not crossing page boundary */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4086, (hsize_t)TBLOCK_SIZE10); + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4086, + (hsize_t)TBLOCK_SIZE10); /* Should succeed */ - if(was_extended != TRUE) TEST_ERROR + if (was_extended != TRUE) + TEST_ERROR /* The extended block is now "large" in size */ /* Try extending the block */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4096, (hsize_t)TBLOCK_SIZE10); + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4096, + (hsize_t)TBLOCK_SIZE10); /* Should succeed */ - if(was_extended != TRUE) TEST_ERROR + if (was_extended != TRUE) + TEST_ERROR /* Try extending the large-sized block */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4106, (hsize_t)TBLOCK_SIZE5000); - /* Should not succeed because the mis-aligned fragment in the page is in the large-sized free-space manager */ - if(was_extended == TRUE) TEST_ERROR + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)saddr1, (hsize_t)TBLOCK_SIZE4106, + (hsize_t)TBLOCK_SIZE5000); + /* Should not succeed because the mis-aligned fragment in the page is in the large-sized free-space + * manager */ + if (was_extended == TRUE) + TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support paged aggregation"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fcpl); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_page_small_try_extend() */ @@ -8077,127 +8315,149 @@ static unsigned test_page_large_try_extend(const char *env_h5_drvr, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - H5F_t *f = NULL; /* Internal file object pointer */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + H5F_t * f = NULL; /* Internal file object pointer */ haddr_t gaddr1, gaddr2, gaddr3, gaddr4; /* Addresses for large data blocks */ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - htri_t was_extended; /* Whether the block can be extended or not */ - char filename[FILENAME_LEN]; /* Filename to use */ + htri_t was_extended; /* Whether the block can be extended or not */ + char filename[FILENAME_LEN]; /* Filename to use */ TESTING("Paged aggregation for file space: H5MF_try_extend() a large block"); /* Current VFD that does not support continuous address space */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* File creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set the strategy to paged aggregation */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) FAIL_STACK_ERROR /* Create the file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR /* Allocate a large data block with gaddr1 */ gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)6000); /* Should be page aligned */ - if(gaddr1 % TBLOCK_SIZE4096) + if (gaddr1 % TBLOCK_SIZE4096) TEST_ERROR /* Extending the block with gaddr1 at EOF to become 2 pages */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr1, (hsize_t)TBLOCK_SIZE6000, (hsize_t)TBLOCK_SIZE2192); + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr1, (hsize_t)TBLOCK_SIZE6000, + (hsize_t)TBLOCK_SIZE2192); /* Should succeed */ - if(was_extended != TRUE) TEST_ERROR + if (was_extended != TRUE) + TEST_ERROR /* Allocate a large data block with gaddr2 */ gaddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE8000); /* Should be page aligned */ - if(gaddr2 % TBLOCK_SIZE4096) + if (gaddr2 % TBLOCK_SIZE4096) TEST_ERROR /* Try extending the block with gaddr1 */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr1, (hsize_t)TBLOCK_SIZE8192, (hsize_t)TBLOCK_SIZE50); + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr1, (hsize_t)TBLOCK_SIZE8192, + (hsize_t)TBLOCK_SIZE50); /* Should not succeed */ - if(was_extended == TRUE) TEST_ERROR + if (was_extended == TRUE) + TEST_ERROR /* Allocate a large data block with gaddr3 */ gaddr3 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE8000); /* Should be page aligned */ - if(gaddr3 % TBLOCK_SIZE4096) + if (gaddr3 % TBLOCK_SIZE4096) TEST_ERROR - /* Try extending the block with gaddr2--there is a free-space section big enough to fulfill the request */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8000, (hsize_t)TBLOCK_SIZE100); + /* Try extending the block with gaddr2--there is a free-space section big enough to fulfill the + * request */ + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8000, + (hsize_t)TBLOCK_SIZE100); /* Should succeed */ - if(was_extended == FALSE) TEST_ERROR + if (was_extended == FALSE) + TEST_ERROR - /* Try extending the block with gaddr2--there is no free-space section big enough to fulfill the request */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8100, (hsize_t)TBLOCK_SIZE100); + /* Try extending the block with gaddr2--there is no free-space section big enough to fulfill the + * request */ + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8100, + (hsize_t)TBLOCK_SIZE100); /* Should not succeed */ - if(was_extended == TRUE) TEST_ERROR + if (was_extended == TRUE) + TEST_ERROR - /* Try extending the block with gaddr2--there is a free-space section big enough to fulfill the request */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8100, (hsize_t)TBLOCK_SIZE90); + /* Try extending the block with gaddr2--there is a free-space section big enough to fulfill the + * request */ + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8100, + (hsize_t)TBLOCK_SIZE90); /* Should succeed */ - if(was_extended == FALSE) TEST_ERROR + if (was_extended == FALSE) + TEST_ERROR /* Try extending the block with gaddr2 */ - /* There is no free-space section big enough to fulfill the request (request is < H5F_FILE_SPACE_PGEND_META_THRES) */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8190, (hsize_t)TBLOCK_SIZE5); + /* There is no free-space section big enough to fulfill the request (request is < + * H5F_FILE_SPACE_PGEND_META_THRES) */ + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8190, + (hsize_t)TBLOCK_SIZE5); /* Should not succeed */ - if(was_extended == TRUE) TEST_ERROR + if (was_extended == TRUE) + TEST_ERROR /* Allocate a large data block with gaddr4 */ gaddr4 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE5000); /* Should be page aligned */ - if(gaddr4 % TBLOCK_SIZE4096) + if (gaddr4 % TBLOCK_SIZE4096) TEST_ERROR - /* Free the block with gaddr3--will merge with remaining free space to become 2 pages + section (size 2) in previous page */ + /* Free the block with gaddr3--will merge with remaining free space to become 2 pages + section (size + * 2) in previous page */ H5MF_xfree(f, H5FD_MEM_DRAW, gaddr3, (hsize_t)TBLOCK_SIZE8000); - /* Try extending the block with gaddr2 crossing page boundary--there is free-space section big enough to fulfill the request */ - was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8190, (hsize_t)TBLOCK_SIZE5); + /* Try extending the block with gaddr2 crossing page boundary--there is free-space section big enough + * to fulfill the request */ + was_extended = H5MF_try_extend(f, H5FD_MEM_DRAW, (haddr_t)gaddr2, (hsize_t)TBLOCK_SIZE8190, + (hsize_t)TBLOCK_SIZE5); /* Should succeed */ - if(was_extended == FALSE) TEST_ERROR + if (was_extended == FALSE) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support paged aggregation strategy"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fcpl); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_page_large_try_extend() */ @@ -8218,39 +8478,39 @@ static unsigned test_page_large(const char *env_h5_drvr, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list ID */ - H5F_t *f = NULL; /* Internal file object pointer */ - haddr_t gaddr1, gaddr2, gaddr3, gaddr4; /* Addresses for blocks */ - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - h5_stat_size_t file_size; /* File size */ - char filename[FILENAME_LEN]; /* Filename to use */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + H5F_t * f = NULL; /* Internal file object pointer */ + haddr_t gaddr1, gaddr2, gaddr3, gaddr4; /* Addresses for blocks */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + h5_stat_size_t file_size; /* File size */ + char filename[FILENAME_LEN]; /* Filename to use */ TESTING("Paged aggregation for file space: large allocations and de-allocations"); /* Current VFD that does not support continuous address space */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); - if(contig_addr_vfd) { + if (contig_addr_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* File creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set the strategy to paged aggregation */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) FAIL_STACK_ERROR /* Create the file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR /* Allocate a large data block with gaddr1 */ @@ -8258,20 +8518,20 @@ test_page_large(const char *env_h5_drvr, hid_t fapl) gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE6000); /* Should be page aligned */ - if(gaddr1 % TBLOCK_SIZE4096) + if (gaddr1 % TBLOCK_SIZE4096) TEST_ERROR /* Allocate a large data block with gaddr2--should be on another page */ /* Allocate 1 page + 3904 bytes; 192 bytes in free-space manager */ gaddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE8000); /* Should be page aligned */ - if(gaddr2 % TBLOCK_SIZE4096) + if (gaddr2 % TBLOCK_SIZE4096) TEST_ERROR /* Allocate a large data block with gaddr3--should be on another page */ /* Allocate 2 pages + 3808 bytes; 288 bytes in free-space manager */ gaddr3 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE12000); - if(!H5F_addr_defined(gaddr3)) + if (!H5F_addr_defined(gaddr3)) TEST_ERROR /* Free the block with gaddr2 */ @@ -8279,32 +8539,33 @@ test_page_large(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, H5FD_MEM_DRAW, gaddr2, (hsize_t)TBLOCK_SIZE8000); /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify that the manager contains 2 free-space sections: 10384 and 288 */ - if(fs_stat.tot_sect_count != 2) + if (fs_stat.tot_sect_count != 2) TEST_ERROR - if(fs_stat.tot_space != (10384+288)) + if (fs_stat.tot_space != (10384 + 288)) TEST_ERROR - /* Allocate a large data block with gaddr4--there is a free-space section able to fulfill the request */ + /* Allocate a large data block with gaddr4--there is a free-space section able to fulfill the request + */ /* Free-space sections: 2192 + 3192 + 288 = 5672 bytes */ gaddr4 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE5000); /* Should be page aligned */ - if(gaddr4 % TBLOCK_SIZE4096) + if (gaddr4 % TBLOCK_SIZE4096) TEST_ERROR - if(gaddr4 != gaddr2) + if (gaddr4 != gaddr2) TEST_ERROR /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify that that there are 3 free-space sections */ - if(fs_stat.tot_sect_count != 3) + if (fs_stat.tot_sect_count != 3) TEST_ERROR - if(fs_stat.tot_space != (2192+3192+288)) + if (fs_stat.tot_space != (2192 + 3192 + 288)) TEST_ERROR /* Free the two blocks with gaddr1 and gaddr4 */ @@ -8312,44 +8573,46 @@ test_page_large(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, H5FD_MEM_DRAW, gaddr4, (hsize_t)TBLOCK_SIZE5000); /* Get free-space info */ - if(H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) FAIL_STACK_ERROR /* Verify that that there are 2 free-space sections: 16384 (4 pages) + 288 */ - if(fs_stat.tot_sect_count != 2) + if (fs_stat.tot_sect_count != 2) TEST_ERROR - if(fs_stat.tot_space != (16384+288)) + if (fs_stat.tot_space != (16384 + 288)) TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) + if ((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR /* Verify that file size end on a page boundary */ - if(file_size % TBLOCK_SIZE4096) + if (file_size % TBLOCK_SIZE4096) TEST_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support paged aggregation strategy"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_page_large() */ @@ -8369,44 +8632,44 @@ error: static unsigned test_page_small(const char *env_h5_drvr, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - H5F_t *f = NULL; /* Internal file object pointer */ - haddr_t addr2, addr3, addr4, addr5; /* Addresses for blocks */ - haddr_t addr9, addr10, addr11; /* Address for small metadata blocks */ - haddr_t saddr1, saddr2; /* Addresses for small raw data blocks */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - char filename[FILENAME_LEN]; /* Filename to use */ - hbool_t multi= FALSE, split = FALSE, family = FALSE; + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + H5F_t * f = NULL; /* Internal file object pointer */ + haddr_t addr2, addr3, addr4, addr5; /* Addresses for blocks */ + haddr_t addr9, addr10, addr11; /* Address for small metadata blocks */ + haddr_t saddr1, saddr2; /* Addresses for small raw data blocks */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + char filename[FILENAME_LEN]; /* Filename to use */ + hbool_t multi = FALSE, split = FALSE, family = FALSE; TESTING("Paged aggregation for file space: small allocations and de-allocations"); - if(!HDstrcmp(env_h5_drvr, "split")) + if (!HDstrcmp(env_h5_drvr, "split")) split = TRUE; - else if(!HDstrcmp(env_h5_drvr, "multi")) + else if (!HDstrcmp(env_h5_drvr, "multi")) multi = TRUE; - else if(!HDstrcmp(env_h5_drvr, "family")) + else if (!HDstrcmp(env_h5_drvr, "family")) family = TRUE; - if(!multi && !split) { + if (!multi && !split) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* File creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set the strategy to paged aggregation */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1) < 0) FAIL_STACK_ERROR /* Create the file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR /* Allocate 2 small metadata blocks: addr1, addr2 */ @@ -8416,45 +8679,48 @@ test_page_small(const char *env_h5_drvr, hid_t fapl) /* Allocate a small raw data block with saddr1 */ saddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE30); /* Should be on the second page and page aligned */ - if(saddr1 % TBLOCK_SIZE4096) + if (saddr1 % TBLOCK_SIZE4096) TEST_ERROR /* Allocate a small raw data block with saddr2 */ saddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE50); /* Should not be page aligned */ - if(!(saddr2 % TBLOCK_SIZE4096)) + if (!(saddr2 % TBLOCK_SIZE4096)) TEST_ERROR /* Should be next to the block with saddr1 */ - if(saddr2 != (saddr1 + TBLOCK_SIZE30)) + if (saddr2 != (saddr1 + TBLOCK_SIZE30)) TEST_ERROR - /* Allocate a small metadata block with addr3--there is no free-space section big enough to fulfill the request */ + /* Allocate a small metadata block with addr3--there is no free-space section big enough to fulfill + * the request */ addr3 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE4020); /* Should be on the third page and page aligned */ - if(addr3 % TBLOCK_SIZE4096) + if (addr3 % TBLOCK_SIZE4096) TEST_ERROR - /* Allocate a small metadata block with addr4--there is a free-space section big enough to fulfill the request */ + /* Allocate a small metadata block with addr4--there is a free-space section big enough to fulfill the + * request */ addr4 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE80); /* Should not be page aligned */ - if(!(addr4 % TBLOCK_SIZE4096)) + if (!(addr4 % TBLOCK_SIZE4096)) TEST_ERROR /* Should be next to the block with addr2 */ - if(addr4 != (addr2 + TBLOCK_SIZE50)) + if (addr4 != (addr2 + TBLOCK_SIZE50)) TEST_ERROR - /* Allocate a small metadata block with addr5--there is a free-space section big enough to fulfill the request */ + /* Allocate a small metadata block with addr5--there is a free-space section big enough to fulfill the + * request */ addr5 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE40); /* Should not be page aligned */ - if(!(addr5 % TBLOCK_SIZE4096)) + if (!(addr5 % TBLOCK_SIZE4096)) TEST_ERROR /* Should be next to the block with addr3 */ - if(addr5 != (addr3 + TBLOCK_SIZE4020)) + if (addr5 != (addr3 + TBLOCK_SIZE4020)) TEST_ERROR /* Allocate a small metadata block with addr6--taking up the remaining space in the first page */ - if(family) + if (family) H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE3080); else H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE3088); @@ -8466,54 +8732,59 @@ test_page_small(const char *env_h5_drvr, hid_t fapl) H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE50); addr9 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE80); - /* Free the block with saddr1 and saddr2--merge with remaining section to become a page which will be returned to the large manager */ + /* Free the block with saddr1 and saddr2--merge with remaining section to become a page which will be + * returned to the large manager */ H5MF_xfree(f, H5FD_MEM_DRAW, saddr1, (hsize_t)TBLOCK_SIZE30); H5MF_xfree(f, H5FD_MEM_DRAW, saddr2, (hsize_t)TBLOCK_SIZE50); /* Verify that the large manager does contain a section with file space page size (default is 4096) */ - if(!f->shared->fs_man[H5F_MEM_PAGE_GENERIC]) + if (!f->shared->fs_man[H5F_MEM_PAGE_GENERIC]) TEST_ERROR - if(H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[H5F_MEM_PAGE_GENERIC], &fs_stat) < 0) FAIL_STACK_ERROR - if(fs_stat.tot_space != TBLOCK_SIZE4096) + if (fs_stat.tot_space != TBLOCK_SIZE4096) TEST_ERROR - /* Allocate a small metadata block with addr10--there is a free-space section big enough to fulfill the request */ + /* Allocate a small metadata block with addr10--there is a free-space section big enough to fulfill + * the request */ addr10 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE3900); /* The block should be next to the block with addr9 */ - if(addr10 != (addr9 + TBLOCK_SIZE80)) + if (addr10 != (addr9 + TBLOCK_SIZE80)) TEST_ERROR /* Allocate a small metadata block with addr11 */ - /* The current free-space section is unable to fulfill the request; obtain a page from the large manager */ + /* The current free-space section is unable to fulfill the request; obtain a page from the large + * manager */ addr11 = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)TBLOCK_SIZE80); /* The address of the block should be the same the freed block with saddr1 */ - if(addr11 != saddr1) + if (addr11 != saddr1) TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support paged aggregation strategy"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fcpl); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_page_small() */ @@ -8534,26 +8805,26 @@ static unsigned test_page_alignment(const char *env_h5_drvr, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t fcpl2 = -1; /* File creation property list ID */ - hid_t fapl_new = -1; /* File access property list ID */ - H5F_t *f = NULL; /* Internal file object pointer */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fcpl2 = -1; /* File creation property list ID */ + hid_t fapl_new = -1; /* File access property list ID */ + H5F_t * f = NULL; /* Internal file object pointer */ haddr_t addr1, addr2; /* Addresses for small metadata blocks */ haddr_t saddr1, saddr2; /* Addresses for small raw data blocks */ haddr_t gaddr1, gaddr2; /* Addresses for blocks */ - char filename[FILENAME_LEN]; /* Filename to use */ + char filename[FILENAME_LEN]; /* Filename to use */ hbool_t split = FALSE, multi = FALSE; TESTING("Paged aggregation and H5Pset_alignment: verify proper alignment is used"); /* Check for split or multi driver */ - if(!HDstrcmp(env_h5_drvr, "split")) + if (!HDstrcmp(env_h5_drvr, "split")) split = TRUE; - else if(!HDstrcmp(env_h5_drvr, "multi")) + else if (!HDstrcmp(env_h5_drvr, "multi")) multi = TRUE; - if(!multi && !split) { + if (!multi && !split) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -8563,94 +8834,100 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) * page size when paged aggregation is enabled. */ - if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_new = H5Pcopy(fapl)) < 0) + TEST_ERROR /* The alignment to use will be the library's default file space page size */ - if(H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Set alignment value to 16 */ - if(H5Pset_alignment(fapl_new, (hsize_t)0, (hsize_t)TEST_ALIGN16) < 0) + if (H5Pset_alignment(fapl_new, (hsize_t)0, (hsize_t)TEST_ALIGN16) < 0) TEST_ERROR - if(split || multi) { - hid_t memb_fapl; + if (split || multi) { + hid_t memb_fapl; H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; - char *memb_name[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - hbool_t relax; - H5FD_mem_t mt; + hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; + char * memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + H5FD_mem_t mt; /* Create fapl */ - if((memb_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((memb_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set alignment */ - if(H5Pset_alignment(memb_fapl, 0, (hsize_t)TEST_ALIGN16) < 0) + if (H5Pset_alignment(memb_fapl, 0, (hsize_t)TEST_ALIGN16) < 0) TEST_ERROR HDmemset(memb_name, 0, sizeof memb_name); - if(split) { + if (split) { /* Set split driver with new FAPLs */ - if(H5Pset_fapl_split(fapl_new, "-m.h5", memb_fapl, "-r.h5", memb_fapl) < 0) + if (H5Pset_fapl_split(fapl_new, "-m.h5", memb_fapl, "-r.h5", memb_fapl) < 0) TEST_ERROR /* Get current multi settings */ - if(H5Pget_fapl_multi(fapl_new, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) + if (H5Pget_fapl_multi(fapl_new, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) TEST_ERROR /* Set memb_addr aligned */ - memb_addr[H5FD_MEM_SUPER] = ((memb_addr[H5FD_MEM_SUPER] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; - memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; + memb_addr[H5FD_MEM_SUPER] = + ((memb_addr[H5FD_MEM_SUPER] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; + memb_addr[H5FD_MEM_DRAW] = + ((memb_addr[H5FD_MEM_DRAW] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; /* Set split driver with new FAPLs */ - if(H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + if (H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl_arr, (const char *const *)memb_name, + memb_addr, relax) < 0) TEST_ERROR - - } else { + } + else { /* Get current multi settings */ - if(H5Pget_fapl_multi(fapl_new, memb_map, NULL, memb_name, memb_addr, &relax) < 0) + if (H5Pget_fapl_multi(fapl_new, memb_map, NULL, memb_name, memb_addr, &relax) < 0) TEST_ERROR /* Populate memb_fapl_arr */ /* Set memb_addr aligned */ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { memb_fapl_arr[mt] = memb_fapl; - memb_addr[mt] = ((memb_addr[mt] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; + memb_addr[mt] = + ((memb_addr[mt] + TBLOCK_SIZE4096 - 1) / TBLOCK_SIZE4096) * TBLOCK_SIZE4096; } /* Set multi driver with new FAPLs */ - if(H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + if (H5Pset_fapl_multi(fapl_new, memb_map, memb_fapl_arr, (const char *const *)memb_name, + memb_addr, relax) < 0) TEST_ERROR } /* end else */ /* Free memb_name */ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) free(memb_name[mt]); /* Close memb_fapl */ - if(H5Pclose(memb_fapl) < 0) + if (H5Pclose(memb_fapl) < 0) TEST_ERROR } /* end if */ /* File creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR /* Set the strategy to paged aggregation and persisting free space */ /* The alignment to use will be the library's default file space page size */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) TEST_ERROR /* Create the file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_new)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR /* Allocate 2 small raw data blocks */ @@ -8658,11 +8935,11 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) saddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE50); /* Should be on the second page and page aligned on 4096 (default file space page size) */ - if(saddr1 % TBLOCK_SIZE4096) + if (saddr1 % TBLOCK_SIZE4096) TEST_ERROR /* Should be next to the block with saddr1 */ - if(saddr2 != (saddr1 + TBLOCK_SIZE30)) + if (saddr2 != (saddr1 + TBLOCK_SIZE30)) TEST_ERROR /* Allocate 2 large raw data blocks */ @@ -8670,19 +8947,19 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) gaddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE8000); /* Should be on the 3rd page and page aligned */ - if(gaddr1 % TBLOCK_SIZE4096) + if (gaddr1 % TBLOCK_SIZE4096) TEST_ERROR /* Should be on the 4th page and page aligned */ - if(gaddr2 % TBLOCK_SIZE4096) + if (gaddr2 % TBLOCK_SIZE4096) TEST_ERROR /* Close the file creation property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* @@ -8691,18 +8968,18 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) */ /* fapl_new has latest format and H5Pset_alignment set */ /* Disable small data block mechanism */ - if(H5Pset_small_data_block_size(fapl_new, (hsize_t)0) < 0) + if (H5Pset_small_data_block_size(fapl_new, (hsize_t)0) < 0) TEST_ERROR /* Disable metadata block mechanism */ - if(H5Pset_meta_block_size(fapl_new, (hsize_t)0) < 0) + if (H5Pset_meta_block_size(fapl_new, (hsize_t)0) < 0) TEST_ERROR /* Create the file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_new)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_new)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR /* Allocate 2 small metadata blocks */ @@ -8710,12 +8987,12 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) addr2 = H5MF_alloc(f, H5FD_MEM_SUPER, (hsize_t)TBLOCK_SIZE50); /* Should be aligned on 16 */ - if(addr1 % TEST_ALIGN16 || addr2 % TEST_ALIGN16) + if (addr1 % TEST_ALIGN16 || addr2 % TEST_ALIGN16) TEST_ERROR /* addr2 should be right next to the block with addr1 */ - if((addr1 + TBLOCK_SIZE30) % TEST_ALIGN16) - if(addr2 != (((addr1 + TBLOCK_SIZE30) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + if ((addr1 + TBLOCK_SIZE30) % TEST_ALIGN16) + if (addr2 != (((addr1 + TBLOCK_SIZE30) / TEST_ALIGN16) + 1) * TEST_ALIGN16) TEST_ERROR /* Allocate 2 small raw data blocks */ @@ -8723,23 +9000,23 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) saddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE100); /* Should be aligned on 16 */ - if(saddr1 % TEST_ALIGN16 || saddr2 % TEST_ALIGN16) + if (saddr1 % TEST_ALIGN16 || saddr2 % TEST_ALIGN16) TEST_ERROR - if(!multi && !split) { + if (!multi && !split) { /* saddr1 should be right next to the block with addr2 */ - if((addr2 + TBLOCK_SIZE50) % TEST_ALIGN16) - if(saddr1 != (((addr2 + TBLOCK_SIZE50) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + if ((addr2 + TBLOCK_SIZE50) % TEST_ALIGN16) + if (saddr1 != (((addr2 + TBLOCK_SIZE50) / TEST_ALIGN16) + 1) * TEST_ALIGN16) TEST_ERROR } /* saddr2 should be right next to the block with saddr1 */ - if((saddr1 + TBLOCK_SIZE80) % TEST_ALIGN16) - if(saddr2 != (((saddr1 + TBLOCK_SIZE80) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + if ((saddr1 + TBLOCK_SIZE80) % TEST_ALIGN16) + if (saddr2 != (((saddr1 + TBLOCK_SIZE80) / TEST_ALIGN16) + 1) * TEST_ALIGN16) TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* @@ -8747,23 +9024,23 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) * via H5Pset_alignment when paged aggregation not enabled. */ /* File creation property list */ - if((fcpl2 = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl2 = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR /* Set file space page size */ - if(H5Pset_file_space_page_size(fcpl2, (hsize_t)TBLOCK_SIZE8192) < 0) + if (H5Pset_file_space_page_size(fcpl2, (hsize_t)TBLOCK_SIZE8192) < 0) TEST_ERROR /* Set strategy to H5F_FSPACE_STRATEGY_AGGR but meta/raw data block is 0 as set in fapl_new */ - if(H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) TEST_ERROR /* fapl_new has latest format, H5Pset_alignment set, and disable meta/raw block */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl2, fapl_new)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl2, fapl_new)) < 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) TEST_ERROR /* Allocate 2 small raw data blocks */ @@ -8771,72 +9048,74 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) saddr2 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE50); /* Should be aligned on 16 */ - if(saddr1 % TEST_ALIGN16) + if (saddr1 % TEST_ALIGN16) TEST_ERROR - if(saddr2 % TEST_ALIGN16) + if (saddr2 % TEST_ALIGN16) TEST_ERROR /* saddr2 should be right next to the block with saddr1 */ - if((saddr1 + TBLOCK_SIZE30) % TEST_ALIGN16) - if(saddr2 != (((saddr1 + TBLOCK_SIZE30) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + if ((saddr1 + TBLOCK_SIZE30) % TEST_ALIGN16) + if (saddr2 != (((saddr1 + TBLOCK_SIZE30) / TEST_ALIGN16) + 1) * TEST_ALIGN16) TEST_ERROR /* Allocate a large raw data block */ gaddr1 = H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)TBLOCK_SIZE5000); /* Should be aligned on 16 */ - if(gaddr1 % TEST_ALIGN16) + if (gaddr1 % TEST_ALIGN16) TEST_ERROR /* gaddr1 is right next to the block with saddr2 */ - if((saddr2 + TBLOCK_SIZE50) % TEST_ALIGN16) - if(gaddr1 != (((saddr2 + TBLOCK_SIZE50) / TEST_ALIGN16) + 1) * TEST_ALIGN16) + if ((saddr2 + TBLOCK_SIZE50) % TEST_ALIGN16) + if (gaddr1 != (((saddr2 + TBLOCK_SIZE50) / TEST_ALIGN16) + 1) * TEST_ALIGN16) TEST_ERROR /* There is no free-space manager involved for H5F_FSPACE_STRATEGY_AGGR strategy */ - if(f->shared->fs_man[H5FD_MEM_DRAW] || f->shared->fs_man[H5FD_MEM_SUPER]) + if (f->shared->fs_man[H5FD_MEM_DRAW] || f->shared->fs_man[H5FD_MEM_SUPER]) TEST_ERROR /* Closing */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR - if(H5Pclose(fcpl2) < 0) + if (H5Pclose(fcpl2) < 0) TEST_ERROR - if(H5Pclose(fapl_new) < 0) + if (H5Pclose(fapl_new) < 0) TEST_ERROR PASSED(); - - } else { + } + else { SKIPPED(); HDputs(" Current VFD doesn't support persisting free-space or paged aggregation strategy"); } - return(0); + return (0); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fcpl); H5Pclose(fapl_new); - } H5E_END_TRY; - return(1); + } + H5E_END_TRY; + return (1); } /* test_page_alignment() */ int main(void) { - hid_t fapl = -1; /* File access property list for data files */ - hid_t new_fapl = -1; /* File access property list for alignment & aggr setting */ - unsigned nerrors = 0; /* Cumulative error count */ - test_type_t curr_test; /* Current test being worked on */ - const char *env_h5_drvr; /* File Driver value from environment */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t fapl = -1; /* File access property list for data files */ + hid_t new_fapl = -1; /* File access property list for alignment & aggr setting */ + unsigned nerrors = 0; /* Cumulative error count */ + test_type_t curr_test; /* Current test being worked on */ + const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; h5_reset(); @@ -8844,11 +9123,13 @@ main(void) fapl = h5_fileaccess(); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Make a copy of the FAPL before adjusting the alignment */ - if((new_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((new_fapl = H5Pcopy(fapl)) < 0) + TEST_ERROR /* For old library format--interaction with file allocation */ nerrors += test_mf_eoa(env_h5_drvr, fapl); nerrors += test_mf_eoa_shrink(env_h5_drvr, fapl); @@ -8875,16 +9156,16 @@ main(void) nerrors += test_mf_aggr_absorb(env_h5_drvr, fapl); /* For old library format--tests for alignment */ - for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; curr_test++) { + for (curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; curr_test++) { - switch(curr_test) { + switch (curr_test) { case TEST_NORMAL: /* set alignment = 1024 */ - if(H5Pset_alignment(new_fapl, (hsize_t)0, (hsize_t)TEST_ALIGN1024) < 0) + if (H5Pset_alignment(new_fapl, (hsize_t)0, (hsize_t)TEST_ALIGN1024) < 0) TEST_ERROR break; case TEST_AGGR_SMALL: /* set alignment = 4096 */ - if(H5Pset_alignment(new_fapl, (hsize_t)0, (hsize_t)TEST_ALIGN4096) < 0) + if (H5Pset_alignment(new_fapl, (hsize_t)0, (hsize_t)TEST_ALIGN4096) < 0) TEST_ERROR break; @@ -8950,35 +9231,38 @@ main(void) nerrors += test_page_large_try_extend(env_h5_drvr, fapl); nerrors += test_page_small_try_extend(env_h5_drvr, fapl); nerrors += test_page_try_shrink(env_h5_drvr, fapl); - nerrors += test_page_alloc_xfree(env_h5_drvr, fapl); /* can handle multi/split */ - nerrors += test_page_alignment(env_h5_drvr, fapl); /* can handle multi/split */ + nerrors += test_page_alloc_xfree(env_h5_drvr, fapl); /* can handle multi/split */ + nerrors += test_page_alignment(env_h5_drvr, fapl); /* can handle multi/split */ /* tests for specific bugs */ nerrors += test_mf_bug1(env_h5_drvr, fapl); - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR h5_cleanup(FILENAME, fapl); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; - if(nerrors) + if (nerrors) goto error; HDputs("All free-space manager tests for file memory passed."); - return(0); + return (0); error: HDputs("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(new_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); - return(1); + return (1); } /* main() */ - diff --git a/test/mirror_vfd.c b/test/mirror_vfd.c index 4da742f..9da432e 100644 --- a/test/mirror_vfd.c +++ b/test/mirror_vfd.c @@ -41,8 +41,8 @@ /* Parameters for the "large chunked dataset" writing */ #define MAX_DSET_COUNT 255 -#define DSET_DIM 32 -#define CHUNK_DIM 8 +#define DSET_DIM 32 +#define CHUNK_DIM 8 #define CONCURRENT_COUNT 3 /* Number of files in concurrent test */ @@ -58,13 +58,13 @@ static unsigned int g_verbosity = DEFAULT_VERBOSITY; /* Macro for selective debug printing / logging */ -#define LOGPRINT(lvl, ...) \ -do { \ - if ((lvl) <= g_verbosity) { \ - fprintf(g_log_stream, __VA_ARGS__); \ - fflush(g_log_stream); \ - } \ -} while (0) +#define LOGPRINT(lvl, ...) \ + do { \ + if ((lvl) <= g_verbosity) { \ + fprintf(g_log_stream, __VA_ARGS__); \ + fflush(g_log_stream); \ + } \ + } while (0) #define MIRROR_RW_DIR "mirror_rw/" #define MIRROR_WO_DIR "mirror_wo/" @@ -76,34 +76,30 @@ static char mesg[MIRR_MESG_SIZE + 1]; /* Convenience structure for passing file names via helper functions. */ struct mirrortest_filenames { - char rw[H5FD_SPLITTER_PATH_MAX+1]; - char wo[H5FD_SPLITTER_PATH_MAX+1]; - char log[H5FD_SPLITTER_PATH_MAX+1]; + char rw[H5FD_SPLITTER_PATH_MAX + 1]; + char wo[H5FD_SPLITTER_PATH_MAX + 1]; + char log[H5FD_SPLITTER_PATH_MAX + 1]; }; static FILE *g_log_stream = NULL; /* initialized at runtime */ -static herr_t _verify_datasets(unsigned min_dset, unsigned max_dset, - hid_t *filespace_id, hid_t *dataset_id, hid_t memspace_id); +static herr_t _verify_datasets(unsigned min_dset, unsigned max_dset, hid_t *filespace_id, hid_t *dataset_id, + hid_t memspace_id); -static herr_t _create_chunking_ids(hid_t file_id, unsigned min_dset, - unsigned max_dset, hsize_t *chunk_dims, hsize_t *dset_dims, - hid_t *dataspace_ids, hid_t *filespace_ids, hid_t *dataset_ids, - hid_t *memspace_id); +static herr_t _create_chunking_ids(hid_t file_id, unsigned min_dset, unsigned max_dset, hsize_t *chunk_dims, + hsize_t *dset_dims, hid_t *dataspace_ids, hid_t *filespace_ids, + hid_t *dataset_ids, hid_t *memspace_id); -static herr_t _close_chunking_ids(unsigned min_dset, unsigned max_dset, - hid_t *dataspace_ids, hid_t *filespace_ids, hid_t *dataset_ids, - hid_t *memspace_id); +static herr_t _close_chunking_ids(unsigned min_dset, unsigned max_dset, hid_t *dataspace_ids, + hid_t *filespace_ids, hid_t *dataset_ids, hid_t *memspace_id); -static herr_t _populate_filepath(const char *dirname, const char *_basename, - hid_t fapl_id, char *path_out, hbool_t h5suffix); +static herr_t _populate_filepath(const char *dirname, const char *_basename, hid_t fapl_id, char *path_out, + hbool_t h5suffix); -static hid_t create_mirroring_split_fapl(const char *_basename, - struct mirrortest_filenames *names); +static hid_t create_mirroring_split_fapl(const char *_basename, struct mirrortest_filenames *names); static void mybzero(void *dest, size_t size); - /* ---------------------------------------------------------------------------- * Function: mybzero * @@ -118,15 +114,14 @@ static void mybzero(void *dest, size_t size) { size_t i = 0; - char *s = NULL; + char * s = NULL; HDassert(dest != NULL); s = (char *)dest; for (i = 0; i < size; i++) { - *(s+i) = 0; + *(s + i) = 0; } } /* end mybzero() */ - /* ---------------------------------------------------------------------------- * Function: _populate_filepath * @@ -142,41 +137,29 @@ mybzero(void *dest, size_t size) * ---------------------------------------------------------------------------- */ static herr_t -_populate_filepath(const char *dirname, const char *_basename, hid_t fapl_id, - char *path_out, hbool_t h5suffix) +_populate_filepath(const char *dirname, const char *_basename, hid_t fapl_id, char *path_out, + hbool_t h5suffix) { char _path[H5FD_SPLITTER_PATH_MAX]; - if ((_basename == NULL) || - (*_basename == 0) || - (dirname == NULL) || - (*dirname == 0) || - (path_out == NULL)) - { + if ((_basename == NULL) || (*_basename == 0) || (dirname == NULL) || (*dirname == 0) || + (path_out == NULL)) { TEST_ERROR; } if (HDsnprintf(_path, H5FD_SPLITTER_PATH_MAX, "%s%s%s", dirname, - (dirname[strlen(dirname)] == '/') ? "" : "/", /* slash iff needed */ - _basename) - > H5FD_SPLITTER_PATH_MAX) - { + (dirname[strlen(dirname)] == '/') ? "" : "/", /* slash iff needed */ + _basename) > H5FD_SPLITTER_PATH_MAX) { TEST_ERROR; } if (h5suffix == TRUE) { - if (h5_fixname(_path, fapl_id, path_out, - H5FD_SPLITTER_PATH_MAX) - == NULL) - { + if (h5_fixname(_path, fapl_id, path_out, H5FD_SPLITTER_PATH_MAX) == NULL) { TEST_ERROR; } } else { - if (h5_fixname_no_suffix(_path, fapl_id, path_out, - H5FD_SPLITTER_PATH_MAX) - == NULL) - { + if (h5_fixname_no_suffix(_path, fapl_id, path_out, H5FD_SPLITTER_PATH_MAX) == NULL) { TEST_ERROR; } } @@ -187,7 +170,6 @@ error: return FAIL; } /* end _populate_filepath() */ - /* --------------------------------------------------------------------------- * Function: build_paths * @@ -201,40 +183,27 @@ error: * --------------------------------------------------------------------------- */ static herr_t -build_paths( - const char *_basename, - H5FD_splitter_vfd_config_t *splitter_config, - struct mirrortest_filenames *names) +build_paths(const char *_basename, H5FD_splitter_vfd_config_t *splitter_config, + struct mirrortest_filenames *names) { char baselogname[H5FD_SPLITTER_PATH_MAX]; - if (_populate_filepath(MIRROR_RW_DIR, _basename, - splitter_config->rw_fapl_id, names->rw, TRUE) - == FAIL) - { + if (_populate_filepath(MIRROR_RW_DIR, _basename, splitter_config->rw_fapl_id, names->rw, TRUE) == FAIL) { TEST_ERROR; } - if (_populate_filepath(MIRROR_WO_DIR, _basename, - splitter_config->wo_fapl_id, names->wo, TRUE) - == FAIL) - { + if (_populate_filepath(MIRROR_WO_DIR, _basename, splitter_config->wo_fapl_id, names->wo, TRUE) == FAIL) { TEST_ERROR; } if (_basename == NULL || *_basename == 0) return FAIL; - if (HDsnprintf(baselogname, H5FD_SPLITTER_PATH_MAX, "%s_err.log", - _basename) - > H5FD_SPLITTER_PATH_MAX) - { + if (HDsnprintf(baselogname, H5FD_SPLITTER_PATH_MAX, "%s_err.log", _basename) > H5FD_SPLITTER_PATH_MAX) { TEST_ERROR; } - if (_populate_filepath(MIRROR_WO_DIR, baselogname, - splitter_config->wo_fapl_id, names->log, FALSE) - == FAIL) - { + if (_populate_filepath(MIRROR_WO_DIR, baselogname, splitter_config->wo_fapl_id, names->log, FALSE) == + FAIL) { TEST_ERROR; } @@ -244,7 +213,6 @@ error: return FAIL; } /* end build_paths() */ - /* --------------------------------------------------------------------------- * Function: test_fapl_configuration * @@ -260,7 +228,7 @@ error: static int test_fapl_configuration(void) { - hid_t fapl_id; + hid_t fapl_id; H5FD_mirror_fapl_t mirror_conf = { H5FD_MIRROR_FAPL_MAGIC, /* magic */ H5FD_MIRROR_CURR_FAPL_T_VERSION, /* version */ @@ -292,9 +260,7 @@ test_fapl_configuration(void) if (SERVER_HANDSHAKE_PORT != fa_out.handshake_port) { TEST_ERROR; } - if (HDstrncmp(SERVER_IP_ADDRESS, (const char *)fa_out.remote_ip, - H5FD_MIRROR_MAX_IP_LEN)) - { + if (HDstrncmp(SERVER_IP_ADDRESS, (const char *)fa_out.remote_ip, H5FD_MIRROR_MAX_IP_LEN)) { TEST_ERROR; } @@ -312,29 +278,27 @@ error: return -1; } /* end test_fapl_configuration() */ +#define PRINT_BUFFER_DIFF(act, exp, len) \ + do { \ + size_t _x = 0; \ + while ((act)[_x] == (exp)[_x]) { \ + _x++; \ + } \ + if (_x != (len)) { \ + size_t _y = 0; \ + HDprintf("First bytes differ at %zu\n", _x); \ + HDprintf("exp "); \ + for (_y = _x; _y < (len); _y++) { \ + HDprintf("%02X", (unsigned char)(exp)[_y]); \ + } \ + HDprintf("\nact "); \ + for (_y = _x; _y < (len); _y++) { \ + HDprintf("%02X", (unsigned char)(act)[_y]); \ + } \ + HDprintf("\n"); \ + } \ + } while (0); /* end PRINT_BUFFER_DIFF */ - -#define PRINT_BUFFER_DIFF(act, exp, len) do { \ - size_t _x = 0; \ - while ((act)[_x] == (exp)[_x]) { \ - _x++; \ - } \ - if (_x != (len)) { \ - size_t _y = 0; \ - HDprintf("First bytes differ at %zu\n", _x); \ - HDprintf("exp "); \ - for (_y = _x; _y < (len); _y++) { \ - HDprintf("%02X", (unsigned char)(exp)[_y]); \ - } \ - HDprintf("\nact "); \ - for (_y = _x; _y < (len); _y++) { \ - HDprintf("%02X", (unsigned char)(act)[_y]); \ - } \ - HDprintf("\n"); \ - } \ -} while (0); /* end PRINT_BUFFER_DIFF */ - - /* --------------------------------------------------------------------------- * Function: test_xmit_encode_decode * @@ -358,18 +322,18 @@ test_xmit_encode_decode(void) * Use sequential values to easily generate the expected buffer with a * for loop. */ - xmit_mock.magic = 0x00010203; - xmit_mock.version = 0x04; + xmit_mock.magic = 0x00010203; + xmit_mock.version = 0x04; xmit_mock.session_token = 0x05060708; - xmit_mock.xmit_count = 0x090A0B0C; - xmit_mock.op = 0x0D; + xmit_mock.xmit_count = 0x090A0B0C; + xmit_mock.op = 0x0D; /* Test uint8_t encode/decode */ do { unsigned char buf[8]; unsigned char expected[8]; - const uint8_t v = 200; + const uint8_t v = 200; unsigned char out = 0; /* Start of buffer uint8_t @@ -377,7 +341,7 @@ test_xmit_encode_decode(void) mybzero(buf, 8); mybzero(expected, 8); expected[0] = 200; - out = 0; + out = 0; if (H5FD__mirror_xmit_encode_uint8(buf, v) != 1) { TEST_ERROR; } @@ -397,15 +361,15 @@ test_xmit_encode_decode(void) mybzero(buf, 8); mybzero(expected, 8); expected[3] = v; - out = 0; - if (H5FD__mirror_xmit_encode_uint8((buf+3), v) != 1) { + out = 0; + if (H5FD__mirror_xmit_encode_uint8((buf + 3), v) != 1) { TEST_ERROR; } if (HDmemcmp(buf, expected, 8) != 0) { PRINT_BUFFER_DIFF(buf, expected, 8); TEST_ERROR; } - if (H5FD__mirror_xmit_decode_uint8(&out, (buf+3)) != 1) { + if (H5FD__mirror_xmit_decode_uint8(&out, (buf + 3)) != 1) { TEST_ERROR; } if (v != out) { @@ -417,15 +381,15 @@ test_xmit_encode_decode(void) mybzero(buf, 8); mybzero(expected, 8); expected[7] = v; - out = 0; - if (H5FD__mirror_xmit_encode_uint8((buf+7), v) != 1) { + out = 0; + if (H5FD__mirror_xmit_encode_uint8((buf + 7), v) != 1) { TEST_ERROR; } if (HDmemcmp(buf, expected, 8) != 0) { PRINT_BUFFER_DIFF(buf, expected, 8); TEST_ERROR; } - if (H5FD__mirror_xmit_decode_uint8(&out, (buf+7)) != 1) { + if (H5FD__mirror_xmit_decode_uint8(&out, (buf + 7)) != 1) { TEST_ERROR; } if (v != out) { @@ -439,8 +403,8 @@ test_xmit_encode_decode(void) do { unsigned char buf[8]; unsigned char expected[8]; - const uint16_t v = 0x8F02; - uint16_t out = 0; + const uint16_t v = 0x8F02; + uint16_t out = 0; /* Start of buffer uint16_t */ @@ -448,7 +412,7 @@ test_xmit_encode_decode(void) mybzero(expected, 8); expected[0] = 0x8F; expected[1] = 0x02; - out = 0; + out = 0; if (H5FD__mirror_xmit_encode_uint16(buf, v) != 2) { TEST_ERROR; } @@ -469,22 +433,22 @@ test_xmit_encode_decode(void) mybzero(expected, 8); expected[3] = 0x8F; expected[4] = 0x02; - out = 0; - if (H5FD__mirror_xmit_encode_uint16((buf+3), v) != 2) { + out = 0; + if (H5FD__mirror_xmit_encode_uint16((buf + 3), v) != 2) { TEST_ERROR; } if (HDmemcmp(buf, expected, 8) != 0) { PRINT_BUFFER_DIFF(buf, expected, 8); TEST_ERROR; } - if (H5FD__mirror_xmit_decode_uint16(&out, (buf+3)) != 2) { + if (H5FD__mirror_xmit_decode_uint16(&out, (buf + 3)) != 2) { TEST_ERROR; } if (out != v) { TEST_ERROR; } /* slice */ - if (H5FD__mirror_xmit_decode_uint16(&out, (buf+4)) != 2) { + if (H5FD__mirror_xmit_decode_uint16(&out, (buf + 4)) != 2) { TEST_ERROR; } if (out != 0x0200) { @@ -497,15 +461,15 @@ test_xmit_encode_decode(void) mybzero(expected, 8); expected[6] = 0x8F; expected[7] = 0x02; - out = 0; - if (H5FD__mirror_xmit_encode_uint16((buf+6), v) != 2) { + out = 0; + if (H5FD__mirror_xmit_encode_uint16((buf + 6), v) != 2) { TEST_ERROR; } if (HDmemcmp(buf, expected, 8) != 0) { PRINT_BUFFER_DIFF(buf, expected, 8); TEST_ERROR; } - if (H5FD__mirror_xmit_decode_uint16(&out, (buf+6)) != 2) { + if (H5FD__mirror_xmit_decode_uint16(&out, (buf + 6)) != 2) { TEST_ERROR; } if (out != v) { @@ -519,8 +483,8 @@ test_xmit_encode_decode(void) do { unsigned char buf[8]; unsigned char expected[8]; - const uint32_t v = 0x8F020048; - uint32_t out = 0; + const uint32_t v = 0x8F020048; + uint32_t out = 0; /* Start of buffer uint32_t */ @@ -530,7 +494,7 @@ test_xmit_encode_decode(void) expected[1] = 0x02; expected[2] = 0x00; expected[3] = 0x48; - out = 0; + out = 0; if (H5FD__mirror_xmit_encode_uint32(buf, v) != 4) { TEST_ERROR; } @@ -553,22 +517,22 @@ test_xmit_encode_decode(void) expected[4] = 0x02; expected[5] = 0x00; expected[6] = 0x48; - out = 0; - if (H5FD__mirror_xmit_encode_uint32((buf+3), v) != 4) { + out = 0; + if (H5FD__mirror_xmit_encode_uint32((buf + 3), v) != 4) { TEST_ERROR; } if (HDmemcmp(buf, expected, 8) != 0) { PRINT_BUFFER_DIFF(buf, expected, 8); TEST_ERROR; } - if (H5FD__mirror_xmit_decode_uint32(&out, (buf+3)) != 4) { + if (H5FD__mirror_xmit_decode_uint32(&out, (buf + 3)) != 4) { TEST_ERROR; } if (out != v) { TEST_ERROR; } /* slice */ - if (H5FD__mirror_xmit_decode_uint32(&out, (buf+4)) != 4) { + if (H5FD__mirror_xmit_decode_uint32(&out, (buf + 4)) != 4) { TEST_ERROR; } if (out != 0x02004800) { @@ -583,15 +547,15 @@ test_xmit_encode_decode(void) expected[5] = 0x02; expected[6] = 0x00; expected[7] = 0x48; - out = 0; - if (H5FD__mirror_xmit_encode_uint32((buf+4), v) != 4) { + out = 0; + if (H5FD__mirror_xmit_encode_uint32((buf + 4), v) != 4) { TEST_ERROR; } if (HDmemcmp(buf, expected, 8) != 0) { PRINT_BUFFER_DIFF(buf, expected, 8); TEST_ERROR; } - if (H5FD__mirror_xmit_decode_uint32(&out, (buf+4)) != 4) { + if (H5FD__mirror_xmit_decode_uint32(&out, (buf + 4)) != 4) { TEST_ERROR; } if (out != v) { @@ -605,8 +569,8 @@ test_xmit_encode_decode(void) do { unsigned char buf[16]; unsigned char expected[16]; - const uint64_t v = 0x90DCBE17939CE4BB; - uint64_t out = 0; + const uint64_t v = 0x90DCBE17939CE4BB; + uint64_t out = 0; /* Start of buffer uint64_t */ @@ -620,7 +584,7 @@ test_xmit_encode_decode(void) expected[5] = 0x9C; expected[6] = 0xE4; expected[7] = 0xBB; - out = 0; + out = 0; if (H5FD__mirror_xmit_encode_uint64(buf, v) != 8) { TEST_ERROR; } @@ -647,22 +611,22 @@ test_xmit_encode_decode(void) expected[8] = 0x9C; expected[9] = 0xE4; expected[10] = 0xBB; - out = 0; - if (H5FD__mirror_xmit_encode_uint64((buf+3), v) != 8) { + out = 0; + if (H5FD__mirror_xmit_encode_uint64((buf + 3), v) != 8) { TEST_ERROR; } if (HDmemcmp(buf, expected, 16) != 0) { PRINT_BUFFER_DIFF(buf, expected, 16); TEST_ERROR; } - if (H5FD__mirror_xmit_decode_uint64(&out, (buf+3)) != 8) { + if (H5FD__mirror_xmit_decode_uint64(&out, (buf + 3)) != 8) { TEST_ERROR; } if (out != v) { TEST_ERROR; } /* slice */ - if (H5FD__mirror_xmit_decode_uint64(&out, (buf+6)) != 8) { + if (H5FD__mirror_xmit_decode_uint64(&out, (buf + 6)) != 8) { TEST_ERROR; } if (out != 0x17939CE4BB000000) { @@ -681,15 +645,15 @@ test_xmit_encode_decode(void) expected[13] = 0x9C; expected[14] = 0xE4; expected[15] = 0xBB; - out = 0; - if (H5FD__mirror_xmit_encode_uint64((buf+8), v) != 8) { + out = 0; + if (H5FD__mirror_xmit_encode_uint64((buf + 8), v) != 8) { TEST_ERROR; } if (HDmemcmp(buf, expected, 16) != 0) { PRINT_BUFFER_DIFF(buf, expected, 16); TEST_ERROR; } - if (H5FD__mirror_xmit_decode_uint64(&out, (buf+8)) != 8) { + if (H5FD__mirror_xmit_decode_uint64(&out, (buf + 8)) != 8) { TEST_ERROR; } if (out != v) { @@ -704,10 +668,10 @@ test_xmit_encode_decode(void) * Then repeat from a different offset in the buffer and compare. */ do { - unsigned char buf[H5FD_MIRROR_XMIT_HEADER_SIZE+8]; - unsigned char expected[H5FD_MIRROR_XMIT_HEADER_SIZE+8]; + unsigned char buf[H5FD_MIRROR_XMIT_HEADER_SIZE + 8]; + unsigned char expected[H5FD_MIRROR_XMIT_HEADER_SIZE + 8]; H5FD_mirror_xmit_t xmit_out; - size_t i = 0; + size_t i = 0; /* sanity check */ if (14 != H5FD_MIRROR_XMIT_HEADER_SIZE) { @@ -716,51 +680,55 @@ test_xmit_encode_decode(void) /* Populate the expected buffer; expect end padding of 0xFF */ - HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_HEADER_SIZE+8); - for (i=0; i < H5FD_MIRROR_XMIT_HEADER_SIZE; i++) { - expected[i+2] = (unsigned char)i; + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_HEADER_SIZE + 8); + for (i = 0; i < H5FD_MIRROR_XMIT_HEADER_SIZE; i++) { + expected[i + 2] = (unsigned char)i; } /* Encode, and compare buffer contents * Initial buffer is filled with 0xFF to match expected padding */ - HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_HEADER_SIZE+8); - if (H5FD_mirror_xmit_encode_header((buf+2), &xmit_mock) - != H5FD_MIRROR_XMIT_HEADER_SIZE) - { + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_HEADER_SIZE + 8); + if (H5FD_mirror_xmit_encode_header((buf + 2), &xmit_mock) != H5FD_MIRROR_XMIT_HEADER_SIZE) { TEST_ERROR; } - if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_HEADER_SIZE+8) != 0) { - PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_HEADER_SIZE+8); + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_HEADER_SIZE + 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_HEADER_SIZE + 8); TEST_ERROR; } /* Decode from buffer */ - if (H5FD_mirror_xmit_decode_header(&xmit_out, (buf+2)) - != H5FD_MIRROR_XMIT_HEADER_SIZE) - { + if (H5FD_mirror_xmit_decode_header(&xmit_out, (buf + 2)) != H5FD_MIRROR_XMIT_HEADER_SIZE) { TEST_ERROR; } - if (xmit_out.magic != xmit_mock.magic) TEST_ERROR; - if (xmit_out.version != xmit_mock.version) TEST_ERROR; - if (xmit_out.session_token != xmit_mock.session_token) TEST_ERROR; - if (xmit_out.xmit_count != xmit_mock.xmit_count) TEST_ERROR; - if (xmit_out.op != xmit_mock.op) TEST_ERROR; + if (xmit_out.magic != xmit_mock.magic) + TEST_ERROR; + if (xmit_out.version != xmit_mock.version) + TEST_ERROR; + if (xmit_out.session_token != xmit_mock.session_token) + TEST_ERROR; + if (xmit_out.xmit_count != xmit_mock.xmit_count) + TEST_ERROR; + if (xmit_out.op != xmit_mock.op) + TEST_ERROR; /* Decode from different offset in buffer * Observe changes when ingesting the padding */ - if (H5FD_mirror_xmit_decode_header(&xmit_out, (buf)) - != H5FD_MIRROR_XMIT_HEADER_SIZE) - { + if (H5FD_mirror_xmit_decode_header(&xmit_out, (buf)) != H5FD_MIRROR_XMIT_HEADER_SIZE) { TEST_ERROR; } - if (xmit_out.magic != 0xFFFF0001) TEST_ERROR; - if (xmit_out.version != 0x02) TEST_ERROR; - if (xmit_out.session_token != 0x03040506) TEST_ERROR; - if (xmit_out.xmit_count != 0x0708090A) TEST_ERROR; - if (xmit_out.op != 0x0B) TEST_ERROR; + if (xmit_out.magic != 0xFFFF0001) + TEST_ERROR; + if (xmit_out.version != 0x02) + TEST_ERROR; + if (xmit_out.session_token != 0x03040506) + TEST_ERROR; + if (xmit_out.xmit_count != 0x0708090A) + TEST_ERROR; + if (xmit_out.op != 0x0B) + TEST_ERROR; } while (0); /* end xmit header en/decode */ @@ -770,14 +738,14 @@ test_xmit_encode_decode(void) * Then repeat from a different offset in the buffer and compare. */ do { - unsigned char buf[H5FD_MIRROR_XMIT_EOA_SIZE+8]; - unsigned char expected[H5FD_MIRROR_XMIT_EOA_SIZE+8]; + unsigned char buf[H5FD_MIRROR_XMIT_EOA_SIZE + 8]; + unsigned char expected[H5FD_MIRROR_XMIT_EOA_SIZE + 8]; H5FD_mirror_xmit_eoa_t xmit_in; H5FD_mirror_xmit_eoa_t xmit_out; - size_t i = 0; + size_t i = 0; /* sanity check */ - if ((14+9) != H5FD_MIRROR_XMIT_EOA_SIZE) { + if ((14 + 9) != H5FD_MIRROR_XMIT_EOA_SIZE) { FAIL_PUTS_ERROR("Header size definition does not match test\n"); } if (xmit_mock.op != 0x0D) { @@ -786,61 +754,69 @@ test_xmit_encode_decode(void) /* Populate the expected buffer; expect end padding of 0xFF */ - HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_EOA_SIZE+8); - for (i=0; i < H5FD_MIRROR_XMIT_EOA_SIZE; i++) { - expected[i+2] = (unsigned char)i; + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_EOA_SIZE + 8); + for (i = 0; i < H5FD_MIRROR_XMIT_EOA_SIZE; i++) { + expected[i + 2] = (unsigned char)i; } /* Set xmit_in */ - xmit_in.pub = xmit_mock; /* shared/common */ - xmit_in.type = 0x0E; + xmit_in.pub = xmit_mock; /* shared/common */ + xmit_in.type = 0x0E; xmit_in.eoa_addr = 0x0F10111213141516; /* Encode, and compare buffer contents * Initial buffer is filled with 0xFF to match expected padding */ - HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_EOA_SIZE+8); - if (H5FD_mirror_xmit_encode_set_eoa((buf+2), &xmit_in) - != H5FD_MIRROR_XMIT_EOA_SIZE) - { + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_EOA_SIZE + 8); + if (H5FD_mirror_xmit_encode_set_eoa((buf + 2), &xmit_in) != H5FD_MIRROR_XMIT_EOA_SIZE) { TEST_ERROR; } - if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_EOA_SIZE+8) != 0) { - PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_EOA_SIZE+8); + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_EOA_SIZE + 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_EOA_SIZE + 8); TEST_ERROR; } /* Decode from buffer */ - if (H5FD_mirror_xmit_decode_set_eoa(&xmit_out, (buf+2)) - != H5FD_MIRROR_XMIT_EOA_SIZE) - { + if (H5FD_mirror_xmit_decode_set_eoa(&xmit_out, (buf + 2)) != H5FD_MIRROR_XMIT_EOA_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; - if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; - if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; - if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; - if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; - if (xmit_out.type != 0x0E) TEST_ERROR; - if (xmit_out.eoa_addr != 0x0F10111213141516) TEST_ERROR; + if (xmit_out.pub.magic != xmit_mock.magic) + TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) + TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) + TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) + TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) + TEST_ERROR; + if (xmit_out.type != 0x0E) + TEST_ERROR; + if (xmit_out.eoa_addr != 0x0F10111213141516) + TEST_ERROR; /* Decode from different offset in buffer * Observe changes when ingesting the padding */ - if (H5FD_mirror_xmit_decode_set_eoa(&xmit_out, (buf)) - != H5FD_MIRROR_XMIT_EOA_SIZE) - { + if (H5FD_mirror_xmit_decode_set_eoa(&xmit_out, (buf)) != H5FD_MIRROR_XMIT_EOA_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; - if (xmit_out.pub.version != 0x02) TEST_ERROR; - if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; - if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; - if (xmit_out.pub.op != 0x0B) TEST_ERROR; - if (xmit_out.type != 0x0C) TEST_ERROR; - if (xmit_out.eoa_addr != 0x0D0E0F1011121314) TEST_ERROR; + if (xmit_out.pub.magic != 0xFFFF0001) + TEST_ERROR; + if (xmit_out.pub.version != 0x02) + TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) + TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) + TEST_ERROR; + if (xmit_out.pub.op != 0x0B) + TEST_ERROR; + if (xmit_out.type != 0x0C) + TEST_ERROR; + if (xmit_out.eoa_addr != 0x0D0E0F1011121314) + TEST_ERROR; } while (0); /* end xmit set-eoa en/decode */ @@ -850,14 +826,14 @@ test_xmit_encode_decode(void) * Then repeat from a different offset in the buffer and compare. */ do { - unsigned char buf[H5FD_MIRROR_XMIT_LOCK_SIZE+8]; - unsigned char expected[H5FD_MIRROR_XMIT_LOCK_SIZE+8]; + unsigned char buf[H5FD_MIRROR_XMIT_LOCK_SIZE + 8]; + unsigned char expected[H5FD_MIRROR_XMIT_LOCK_SIZE + 8]; H5FD_mirror_xmit_lock_t xmit_in; H5FD_mirror_xmit_lock_t xmit_out; - size_t i = 0; + size_t i = 0; /* sanity check */ - if ((14+8) != H5FD_MIRROR_XMIT_LOCK_SIZE) { + if ((14 + 8) != H5FD_MIRROR_XMIT_LOCK_SIZE) { FAIL_PUTS_ERROR("Header size definition does not match test\n"); } if (xmit_mock.op != 0x0D) { @@ -866,58 +842,64 @@ test_xmit_encode_decode(void) /* Populate the expected buffer; expect end padding of 0xFF */ - HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_LOCK_SIZE+8); - for (i=0; i < H5FD_MIRROR_XMIT_LOCK_SIZE; i++) { - expected[i+2] = (unsigned char)i; + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_LOCK_SIZE + 8); + for (i = 0; i < H5FD_MIRROR_XMIT_LOCK_SIZE; i++) { + expected[i + 2] = (unsigned char)i; } /* Set xmit_in */ xmit_in.pub = xmit_mock; /* shared/common */ - xmit_in.rw = 0x0E0F101112131415; + xmit_in.rw = 0x0E0F101112131415; /* Encode, and compare buffer contents * Initial buffer is filled with 0xFF to match expected padding */ - HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_LOCK_SIZE+8); - if (H5FD_mirror_xmit_encode_lock((buf+2), &xmit_in) - != H5FD_MIRROR_XMIT_LOCK_SIZE) - { + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_LOCK_SIZE + 8); + if (H5FD_mirror_xmit_encode_lock((buf + 2), &xmit_in) != H5FD_MIRROR_XMIT_LOCK_SIZE) { TEST_ERROR; } - if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_LOCK_SIZE+8) != 0) { - PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_LOCK_SIZE+8); + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_LOCK_SIZE + 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_LOCK_SIZE + 8); TEST_ERROR; } /* Decode from buffer */ - if (H5FD_mirror_xmit_decode_lock(&xmit_out, (buf+2)) - != H5FD_MIRROR_XMIT_LOCK_SIZE) - { + if (H5FD_mirror_xmit_decode_lock(&xmit_out, (buf + 2)) != H5FD_MIRROR_XMIT_LOCK_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; - if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; - if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; - if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; - if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; - if (xmit_out.rw != 0x0E0F101112131415) TEST_ERROR; + if (xmit_out.pub.magic != xmit_mock.magic) + TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) + TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) + TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) + TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) + TEST_ERROR; + if (xmit_out.rw != 0x0E0F101112131415) + TEST_ERROR; /* Decode from different offset in buffer * Observe changes when ingesting the padding */ - if (H5FD_mirror_xmit_decode_lock(&xmit_out, (buf)) - != H5FD_MIRROR_XMIT_LOCK_SIZE) - { + if (H5FD_mirror_xmit_decode_lock(&xmit_out, (buf)) != H5FD_MIRROR_XMIT_LOCK_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; - if (xmit_out.pub.version != 0x02) TEST_ERROR; - if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; - if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; - if (xmit_out.pub.op != 0x0B) TEST_ERROR; - if (xmit_out.rw != 0x0C0D0E0F10111213) TEST_ERROR; + if (xmit_out.pub.magic != 0xFFFF0001) + TEST_ERROR; + if (xmit_out.pub.version != 0x02) + TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) + TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) + TEST_ERROR; + if (xmit_out.pub.op != 0x0B) + TEST_ERROR; + if (xmit_out.rw != 0x0C0D0E0F10111213) + TEST_ERROR; } while (0); /* end xmit lock en/decode */ @@ -930,14 +912,14 @@ test_xmit_encode_decode(void) * string, with all following bytes in the encoded buffer being zeroed. */ do { - unsigned char buf[H5FD_MIRROR_XMIT_OPEN_SIZE+8]; - unsigned char expected[H5FD_MIRROR_XMIT_OPEN_SIZE+8]; + unsigned char buf[H5FD_MIRROR_XMIT_OPEN_SIZE + 8]; + unsigned char expected[H5FD_MIRROR_XMIT_OPEN_SIZE + 8]; H5FD_mirror_xmit_open_t xmit_in; H5FD_mirror_xmit_open_t xmit_out; - size_t i = 0; + size_t i = 0; /* sanity check */ - if ((14+20+4097) != H5FD_MIRROR_XMIT_OPEN_SIZE) { + if ((14 + 20 + 4097) != H5FD_MIRROR_XMIT_OPEN_SIZE) { FAIL_PUTS_ERROR("Header size definition does not match test\n"); } if (xmit_mock.op != 0x0D) { @@ -946,90 +928,92 @@ test_xmit_encode_decode(void) /* Populate the expected buffer; expect end padding of 0xFF */ - HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_OPEN_SIZE+8); - for (i=0; i < H5FD_MIRROR_XMIT_OPEN_SIZE; i++) { + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_OPEN_SIZE + 8); + for (i = 0; i < H5FD_MIRROR_XMIT_OPEN_SIZE; i++) { /* 0x100 is "zero" in a byte, so encode will treat it as a NULL- * terminator in the filepath string. Expect all zeroes following. */ - expected[i+2] = (i > 0xFF) ? 0 : (unsigned char)i; + expected[i + 2] = (i > 0xFF) ? 0 : (unsigned char)i; } /* Set xmit_in */ - xmit_in.pub = xmit_mock; /* shared/common */ - xmit_in.flags = 0x0E0F1011; - xmit_in.maxaddr = 0x1213141516171819; + xmit_in.pub = xmit_mock; /* shared/common */ + xmit_in.flags = 0x0E0F1011; + xmit_in.maxaddr = 0x1213141516171819; xmit_in.size_t_blob = 0x1A1B1C1D1E1F2021; - for (i=0x22; i < H5FD_MIRROR_XMIT_FILEPATH_MAX+0x22; i++) { + for (i = 0x22; i < H5FD_MIRROR_XMIT_FILEPATH_MAX + 0x22; i++) { /* nonzero values repeat after 0x100, but will not be encoded */ - xmit_in.filename[i-0x22] = (char)(i % 0x100); + xmit_in.filename[i - 0x22] = (char)(i % 0x100); } - xmit_in.filename[H5FD_MIRROR_XMIT_FILEPATH_MAX-1] = 0; + xmit_in.filename[H5FD_MIRROR_XMIT_FILEPATH_MAX - 1] = 0; /* Encode, and compare buffer contents * Initial buffer is filled with 0xFF to match expected padding */ - HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_OPEN_SIZE+8); - if (H5FD_mirror_xmit_encode_open((buf+2), &xmit_in) - != H5FD_MIRROR_XMIT_OPEN_SIZE) - { + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_OPEN_SIZE + 8); + if (H5FD_mirror_xmit_encode_open((buf + 2), &xmit_in) != H5FD_MIRROR_XMIT_OPEN_SIZE) { TEST_ERROR; } - if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_OPEN_SIZE+8) != 0) { - PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_OPEN_SIZE+8); + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_OPEN_SIZE + 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_OPEN_SIZE + 8); TEST_ERROR; } /* Decode from buffer */ - if (H5FD_mirror_xmit_decode_open(&xmit_out, (buf+2)) - != H5FD_MIRROR_XMIT_OPEN_SIZE) - { + if (H5FD_mirror_xmit_decode_open(&xmit_out, (buf + 2)) != H5FD_MIRROR_XMIT_OPEN_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; - if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; - if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; - if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; - if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; - if (xmit_out.flags != xmit_in.flags) TEST_ERROR; - if (xmit_out.maxaddr != xmit_in.maxaddr) TEST_ERROR; - if (xmit_out.size_t_blob != xmit_in.size_t_blob) TEST_ERROR; - if (HDstrncmp(xmit_out.filename, xmit_in.filename, - H5FD_MIRROR_XMIT_FILEPATH_MAX) - != 0) - { - PRINT_BUFFER_DIFF(xmit_out.filename, xmit_in.filename, - H5FD_MIRROR_XMIT_FILEPATH_MAX); + if (xmit_out.pub.magic != xmit_mock.magic) + TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) + TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) + TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) + TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) + TEST_ERROR; + if (xmit_out.flags != xmit_in.flags) + TEST_ERROR; + if (xmit_out.maxaddr != xmit_in.maxaddr) + TEST_ERROR; + if (xmit_out.size_t_blob != xmit_in.size_t_blob) + TEST_ERROR; + if (HDstrncmp(xmit_out.filename, xmit_in.filename, H5FD_MIRROR_XMIT_FILEPATH_MAX) != 0) { + PRINT_BUFFER_DIFF(xmit_out.filename, xmit_in.filename, H5FD_MIRROR_XMIT_FILEPATH_MAX); TEST_ERROR; } /* Decode from different offset in buffer * Observe changes when ingesting the padding */ - if (H5FD_mirror_xmit_decode_open(&xmit_out, (buf)) - != H5FD_MIRROR_XMIT_OPEN_SIZE) - { - TEST_ERROR; - } - if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; - if (xmit_out.pub.version != 0x02) TEST_ERROR; - if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; - if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; - if (xmit_out.pub.op != 0x0B) TEST_ERROR; - if (xmit_out.flags != 0x0C0D0E0F) TEST_ERROR; - if (xmit_out.maxaddr != 0x1011121314151617) TEST_ERROR; - if (xmit_out.size_t_blob != 0x18191A1B1C1D1E1F) TEST_ERROR; + if (H5FD_mirror_xmit_decode_open(&xmit_out, (buf)) != H5FD_MIRROR_XMIT_OPEN_SIZE) { + TEST_ERROR; + } + if (xmit_out.pub.magic != 0xFFFF0001) + TEST_ERROR; + if (xmit_out.pub.version != 0x02) + TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) + TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) + TEST_ERROR; + if (xmit_out.pub.op != 0x0B) + TEST_ERROR; + if (xmit_out.flags != 0x0C0D0E0F) + TEST_ERROR; + if (xmit_out.maxaddr != 0x1011121314151617) + TEST_ERROR; + if (xmit_out.size_t_blob != 0x18191A1B1C1D1E1F) + TEST_ERROR; /* update expected "filepath" in structure */ - for (i=0x20; i < H5FD_MIRROR_XMIT_FILEPATH_MAX+0x20; i++) { - xmit_in.filename[i-0x20] = (i > 0xFF) ? 0 : (char)i; + for (i = 0x20; i < H5FD_MIRROR_XMIT_FILEPATH_MAX + 0x20; i++) { + xmit_in.filename[i - 0x20] = (i > 0xFF) ? 0 : (char)i; } - if (HDstrncmp(xmit_out.filename, xmit_in.filename, - H5FD_MIRROR_XMIT_FILEPATH_MAX) - != 0) - { - PRINT_BUFFER_DIFF(xmit_out.filename, xmit_in.filename, - H5FD_MIRROR_XMIT_FILEPATH_MAX); + if (HDstrncmp(xmit_out.filename, xmit_in.filename, H5FD_MIRROR_XMIT_FILEPATH_MAX) != 0) { + PRINT_BUFFER_DIFF(xmit_out.filename, xmit_in.filename, H5FD_MIRROR_XMIT_FILEPATH_MAX); TEST_ERROR; } @@ -1044,14 +1028,14 @@ test_xmit_encode_decode(void) * string, with all following bytes in the encoded buffer being zeroed. */ do { - unsigned char buf[H5FD_MIRROR_XMIT_REPLY_SIZE+8]; - unsigned char expected[H5FD_MIRROR_XMIT_REPLY_SIZE+8]; + unsigned char buf[H5FD_MIRROR_XMIT_REPLY_SIZE + 8]; + unsigned char expected[H5FD_MIRROR_XMIT_REPLY_SIZE + 8]; H5FD_mirror_xmit_reply_t xmit_in; H5FD_mirror_xmit_reply_t xmit_out; - size_t i = 0; + size_t i = 0; /* sanity check */ - if ((14+4+256) != H5FD_MIRROR_XMIT_REPLY_SIZE) { + if ((14 + 4 + 256) != H5FD_MIRROR_XMIT_REPLY_SIZE) { FAIL_PUTS_ERROR("Header size definition does not match test\n"); } if (xmit_mock.op != 0x0D) { @@ -1060,84 +1044,82 @@ test_xmit_encode_decode(void) /* Populate the expected buffer; expect end padding of 0xFF */ - HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_REPLY_SIZE+8); - for (i=0; i < H5FD_MIRROR_XMIT_REPLY_SIZE; i++) { + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_REPLY_SIZE + 8); + for (i = 0; i < H5FD_MIRROR_XMIT_REPLY_SIZE; i++) { /* 0x100 is "zero" in a byte, so encode will treat it as a NULL- * terminator in the filepath string. Expect all zeroes following. */ - expected[i+2] = (i > 0xFF) ? 0 : (unsigned char)i; + expected[i + 2] = (i > 0xFF) ? 0 : (unsigned char)i; } /* Set xmit_in */ - xmit_in.pub = xmit_mock; /* shared/common */ + xmit_in.pub = xmit_mock; /* shared/common */ xmit_in.status = 0x0E0F1011; - for (i=0x12; i < H5FD_MIRROR_STATUS_MESSAGE_MAX+0x12; i++) { + for (i = 0x12; i < H5FD_MIRROR_STATUS_MESSAGE_MAX + 0x12; i++) { /* nonzero values repeat after 0x100, but will not be encoded */ - xmit_in.message[i-0x12] = (char)(i % 0x100); + xmit_in.message[i - 0x12] = (char)(i % 0x100); } - xmit_in.message[H5FD_MIRROR_STATUS_MESSAGE_MAX-1] = 0; + xmit_in.message[H5FD_MIRROR_STATUS_MESSAGE_MAX - 1] = 0; /* Encode, and compare buffer contents * Initial buffer is filled with 0xFF to match expected padding */ - HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_REPLY_SIZE+8); - if (H5FD_mirror_xmit_encode_reply((buf+2), &xmit_in) - != H5FD_MIRROR_XMIT_REPLY_SIZE) - { + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_REPLY_SIZE + 8); + if (H5FD_mirror_xmit_encode_reply((buf + 2), &xmit_in) != H5FD_MIRROR_XMIT_REPLY_SIZE) { TEST_ERROR; } - if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_REPLY_SIZE+8) != 0) { - PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_REPLY_SIZE+8); + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_REPLY_SIZE + 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_REPLY_SIZE + 8); TEST_ERROR; } /* Decode from buffer */ - if (H5FD_mirror_xmit_decode_reply(&xmit_out, (buf+2)) - != H5FD_MIRROR_XMIT_REPLY_SIZE) - { + if (H5FD_mirror_xmit_decode_reply(&xmit_out, (buf + 2)) != H5FD_MIRROR_XMIT_REPLY_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; - if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; - if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; - if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; - if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; - if (xmit_out.status != xmit_in.status) TEST_ERROR; - if (HDstrncmp(xmit_out.message, xmit_in.message, - H5FD_MIRROR_STATUS_MESSAGE_MAX) - != 0) - { - PRINT_BUFFER_DIFF(xmit_out.message, xmit_in.message, - H5FD_MIRROR_STATUS_MESSAGE_MAX); + if (xmit_out.pub.magic != xmit_mock.magic) + TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) + TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) + TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) + TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) + TEST_ERROR; + if (xmit_out.status != xmit_in.status) + TEST_ERROR; + if (HDstrncmp(xmit_out.message, xmit_in.message, H5FD_MIRROR_STATUS_MESSAGE_MAX) != 0) { + PRINT_BUFFER_DIFF(xmit_out.message, xmit_in.message, H5FD_MIRROR_STATUS_MESSAGE_MAX); TEST_ERROR; } /* Decode from different offset in buffer * Observe changes when ingesting the padding */ - if (H5FD_mirror_xmit_decode_reply(&xmit_out, (buf)) - != H5FD_MIRROR_XMIT_REPLY_SIZE) - { + if (H5FD_mirror_xmit_decode_reply(&xmit_out, (buf)) != H5FD_MIRROR_XMIT_REPLY_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; - if (xmit_out.pub.version != 0x02) TEST_ERROR; - if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; - if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; - if (xmit_out.pub.op != 0x0B) TEST_ERROR; - if (xmit_out.status != 0x0C0D0E0F) TEST_ERROR; + if (xmit_out.pub.magic != 0xFFFF0001) + TEST_ERROR; + if (xmit_out.pub.version != 0x02) + TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) + TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) + TEST_ERROR; + if (xmit_out.pub.op != 0x0B) + TEST_ERROR; + if (xmit_out.status != 0x0C0D0E0F) + TEST_ERROR; /* update expected "message" in structure */ - for (i=0x10; i < H5FD_MIRROR_STATUS_MESSAGE_MAX+0x10; i++) { - xmit_in.message[i-0x10] = (i > 0xFF) ? 0 : (char)i; + for (i = 0x10; i < H5FD_MIRROR_STATUS_MESSAGE_MAX + 0x10; i++) { + xmit_in.message[i - 0x10] = (i > 0xFF) ? 0 : (char)i; } - if (HDstrncmp(xmit_out.message, xmit_in.message, - H5FD_MIRROR_STATUS_MESSAGE_MAX) - != 0) - { - PRINT_BUFFER_DIFF(xmit_out.message, xmit_in.message, - H5FD_MIRROR_STATUS_MESSAGE_MAX); + if (HDstrncmp(xmit_out.message, xmit_in.message, H5FD_MIRROR_STATUS_MESSAGE_MAX) != 0) { + PRINT_BUFFER_DIFF(xmit_out.message, xmit_in.message, H5FD_MIRROR_STATUS_MESSAGE_MAX); TEST_ERROR; } @@ -1149,14 +1131,14 @@ test_xmit_encode_decode(void) * Then repeat from a different offset in the buffer and compare. */ do { - unsigned char buf[H5FD_MIRROR_XMIT_WRITE_SIZE+8]; - unsigned char expected[H5FD_MIRROR_XMIT_WRITE_SIZE+8]; + unsigned char buf[H5FD_MIRROR_XMIT_WRITE_SIZE + 8]; + unsigned char expected[H5FD_MIRROR_XMIT_WRITE_SIZE + 8]; H5FD_mirror_xmit_write_t xmit_in; H5FD_mirror_xmit_write_t xmit_out; - size_t i = 0; + size_t i = 0; /* sanity check */ - if ((14+17) != H5FD_MIRROR_XMIT_WRITE_SIZE) { + if ((14 + 17) != H5FD_MIRROR_XMIT_WRITE_SIZE) { FAIL_PUTS_ERROR("Header size definition does not match test\n"); } if (xmit_mock.op != 0x0D) { @@ -1165,9 +1147,9 @@ test_xmit_encode_decode(void) /* Populate the expected buffer; expect end padding of 0xFF */ - HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_WRITE_SIZE+8); - for (i=0; i < H5FD_MIRROR_XMIT_WRITE_SIZE; i++) { - expected[i+2] = (unsigned char)i; + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_WRITE_SIZE + 8); + for (i = 0; i < H5FD_MIRROR_XMIT_WRITE_SIZE; i++) { + expected[i + 2] = (unsigned char)i; } /* Set xmit_in @@ -1180,49 +1162,59 @@ test_xmit_encode_decode(void) /* Encode, and compare buffer contents * Initial buffer is filled with 0xFF to match expected padding */ - HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_WRITE_SIZE+8); - if (H5FD_mirror_xmit_encode_write((buf+2), &xmit_in) - != H5FD_MIRROR_XMIT_WRITE_SIZE) - { + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_WRITE_SIZE + 8); + if (H5FD_mirror_xmit_encode_write((buf + 2), &xmit_in) != H5FD_MIRROR_XMIT_WRITE_SIZE) { TEST_ERROR; } - if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_WRITE_SIZE+8) != 0) { - PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_WRITE_SIZE+8); + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_WRITE_SIZE + 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_WRITE_SIZE + 8); TEST_ERROR; } /* Decode from buffer */ - if (H5FD_mirror_xmit_decode_write(&xmit_out, (buf+2)) - != H5FD_MIRROR_XMIT_WRITE_SIZE) - { + if (H5FD_mirror_xmit_decode_write(&xmit_out, (buf + 2)) != H5FD_MIRROR_XMIT_WRITE_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; - if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; - if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; - if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; - if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; - if (xmit_out.type != 0x0E) TEST_ERROR; - if (xmit_out.offset != 0x0F10111213141516) TEST_ERROR; - if (xmit_out.size != 0x1718191A1B1C1D1E) TEST_ERROR; + if (xmit_out.pub.magic != xmit_mock.magic) + TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) + TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) + TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) + TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) + TEST_ERROR; + if (xmit_out.type != 0x0E) + TEST_ERROR; + if (xmit_out.offset != 0x0F10111213141516) + TEST_ERROR; + if (xmit_out.size != 0x1718191A1B1C1D1E) + TEST_ERROR; /* Decode from different offset in buffer * Observe changes when ingesting the padding */ - if (H5FD_mirror_xmit_decode_write(&xmit_out, (buf)) - != H5FD_MIRROR_XMIT_WRITE_SIZE) - { + if (H5FD_mirror_xmit_decode_write(&xmit_out, (buf)) != H5FD_MIRROR_XMIT_WRITE_SIZE) { TEST_ERROR; } - if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; - if (xmit_out.pub.version != 0x02) TEST_ERROR; - if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; - if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; - if (xmit_out.pub.op != 0x0B) TEST_ERROR; - if (xmit_out.type != 0x0C) TEST_ERROR; - if (xmit_out.offset != 0x0D0E0F1011121314) TEST_ERROR; - if (xmit_out.size != 0x15161718191A1B1C) TEST_ERROR; + if (xmit_out.pub.magic != 0xFFFF0001) + TEST_ERROR; + if (xmit_out.pub.version != 0x02) + TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) + TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) + TEST_ERROR; + if (xmit_out.pub.op != 0x0B) + TEST_ERROR; + if (xmit_out.type != 0x0C) + TEST_ERROR; + if (xmit_out.offset != 0x0D0E0F1011121314) + TEST_ERROR; + if (xmit_out.size != 0x15161718191A1B1C) + TEST_ERROR; } while (0); /* end xmit write en/decode */ @@ -1233,7 +1225,6 @@ error: return -1; } /* end test_xmit_encode_decode */ - /* --------------------------------------------------------------------------- * Function: create_mirroring_split_fapl * @@ -1253,19 +1244,18 @@ error: * --------------------------------------------------------------------------- */ static hid_t -create_mirroring_split_fapl(const char *_basename, - struct mirrortest_filenames *names) +create_mirroring_split_fapl(const char *_basename, struct mirrortest_filenames *names) { - H5FD_splitter_vfd_config_t splitter_config; - H5FD_mirror_fapl_t mirror_conf; - hid_t ret_value = H5I_INVALID_HID; + H5FD_splitter_vfd_config_t splitter_config; + H5FD_mirror_fapl_t mirror_conf; + hid_t ret_value = H5I_INVALID_HID; if (_basename == NULL || *_basename == '\0') { TEST_ERROR; } - splitter_config.magic = H5FD_SPLITTER_MAGIC; - splitter_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + splitter_config.magic = H5FD_SPLITTER_MAGIC; + splitter_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; splitter_config.ignore_wo_errs = FALSE; /* Create Splitter R/W channel driver (sec2) @@ -1280,13 +1270,10 @@ create_mirroring_split_fapl(const char *_basename, /* Create Splitter W/O channel driver (mirror) */ - mirror_conf.magic = H5FD_MIRROR_FAPL_MAGIC; - mirror_conf.version = H5FD_MIRROR_CURR_FAPL_T_VERSION; + mirror_conf.magic = H5FD_MIRROR_FAPL_MAGIC; + mirror_conf.version = H5FD_MIRROR_CURR_FAPL_T_VERSION; mirror_conf.handshake_port = SERVER_HANDSHAKE_PORT; - if (HDstrncpy(mirror_conf.remote_ip, SERVER_IP_ADDRESS, - H5FD_MIRROR_MAX_IP_LEN) - == NULL) - { + if (HDstrncpy(mirror_conf.remote_ip, SERVER_IP_ADDRESS, H5FD_MIRROR_MAX_IP_LEN) == NULL) { TEST_ERROR; } splitter_config.wo_fapl_id = H5Pcreate(H5P_FILE_ACCESS); @@ -1305,16 +1292,10 @@ create_mirroring_split_fapl(const char *_basename, /* Set file paths for w/o and logfile */ - if (HDstrncpy(splitter_config.wo_path, (const char *)names->wo, - H5FD_SPLITTER_PATH_MAX) - == NULL) - { + if (HDstrncpy(splitter_config.wo_path, (const char *)names->wo, H5FD_SPLITTER_PATH_MAX) == NULL) { TEST_ERROR; } - if (HDstrncpy(splitter_config.log_file_path, (const char *)names->log, - H5FD_SPLITTER_PATH_MAX) - == NULL) - { + if (HDstrncpy(splitter_config.log_file_path, (const char *)names->log, H5FD_SPLITTER_PATH_MAX) == NULL) { TEST_ERROR; } @@ -1354,7 +1335,6 @@ error: return H5I_INVALID_HID; } /* end create_mirroring_split_fapl() */ - /* --------------------------------------------------------------------------- * Function: test_create_and_close * @@ -1375,8 +1355,8 @@ static int test_create_and_close(void) { struct mirrortest_filenames names; - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id = H5P_DEFAULT; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; TESTING("File creation and immediate close"); @@ -1411,14 +1391,15 @@ test_create_and_close(void) return 0; error: - H5E_BEGIN_TRY{ + H5E_BEGIN_TRY + { (void)H5Fclose(file_id); (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_create_and_close() */ - /* ---------------------------------------------------------------------------- * Function: create_datasets * @@ -1435,20 +1416,18 @@ error: * ---------------------------------------------------------------------------- */ static herr_t -create_datasets(hid_t file_id, - unsigned min_dset, - unsigned max_dset) +create_datasets(hid_t file_id, unsigned min_dset, unsigned max_dset) { - hid_t dataspace_ids[MAX_DSET_COUNT + 1]; - hid_t dataset_ids[MAX_DSET_COUNT + 1]; - hid_t filespace_ids[MAX_DSET_COUNT + 1]; - int data_chunk[CHUNK_DIM][CHUNK_DIM]; - unsigned int i, j, k, l, m; - hsize_t offset[2]; - hid_t memspace_id = H5I_INVALID_HID; - hsize_t a_size[2] = {CHUNK_DIM, CHUNK_DIM}; - hsize_t chunk_dims[2] = {CHUNK_DIM, CHUNK_DIM}; - hsize_t dset_dims[2] = {DSET_DIM, DSET_DIM}; + hid_t dataspace_ids[MAX_DSET_COUNT + 1]; + hid_t dataset_ids[MAX_DSET_COUNT + 1]; + hid_t filespace_ids[MAX_DSET_COUNT + 1]; + int data_chunk[CHUNK_DIM][CHUNK_DIM]; + unsigned int i, j, k, l, m; + hsize_t offset[2]; + hid_t memspace_id = H5I_INVALID_HID; + hsize_t a_size[2] = {CHUNK_DIM, CHUNK_DIM}; + hsize_t chunk_dims[2] = {CHUNK_DIM, CHUNK_DIM}; + hsize_t dset_dims[2] = {DSET_DIM, DSET_DIM}; HDassert(file_id >= 0); HDassert(min_dset <= max_dset); @@ -1463,7 +1442,7 @@ create_datasets(hid_t file_id, for (i = 0; i < MAX_DSET_COUNT; i++) { LOGPRINT(3, "clearing IDs [%d]\n", i); dataspace_ids[i] = H5I_INVALID_HID; - dataset_ids[i] = H5I_INVALID_HID; + dataset_ids[i] = H5I_INVALID_HID; filespace_ids[i] = H5I_INVALID_HID; } @@ -1471,10 +1450,8 @@ create_datasets(hid_t file_id, * Generate dataspace, dataset, and 'filespace' IDs */ - if (_create_chunking_ids(file_id, min_dset, max_dset, chunk_dims, - dset_dims, dataspace_ids, filespace_ids, dataset_ids, &memspace_id) - == FAIL) - { + if (_create_chunking_ids(file_id, min_dset, max_dset, chunk_dims, dset_dims, dataspace_ids, filespace_ids, + dataset_ids, &memspace_id) == FAIL) { TEST_ERROR; } @@ -1483,23 +1460,16 @@ create_datasets(hid_t file_id, * for a given chunk 'location', write chunk data to each dataset. */ - for (i = 0; i < DSET_DIM; i += CHUNK_DIM) - { + for (i = 0; i < DSET_DIM; i += CHUNK_DIM) { LOGPRINT(3, "i: %d\n", i); - for (j = 0; j < DSET_DIM; j += CHUNK_DIM) - { + for (j = 0; j < DSET_DIM; j += CHUNK_DIM) { LOGPRINT(3, " j: %d\n", j); - for (m = min_dset; m <= max_dset; m++) - { + for (m = min_dset; m <= max_dset; m++) { LOGPRINT(3, " m: %d\n", m); - for (k = 0; k < CHUNK_DIM; k++) - { - for (l = 0; l < CHUNK_DIM; l++) - { - data_chunk[k][l] = (int)((DSET_DIM * DSET_DIM * m) + - (DSET_DIM * (i + k)) + j + l); - LOGPRINT(3, " data_chunk[%d][%d]: %d\n", - k, l, data_chunk[k][l]); + for (k = 0; k < CHUNK_DIM; k++) { + for (l = 0; l < CHUNK_DIM; l++) { + data_chunk[k][l] = (int)((DSET_DIM * DSET_DIM * m) + (DSET_DIM * (i + k)) + j + l); + LOGPRINT(3, " data_chunk[%d][%d]: %d\n", k, l, data_chunk[k][l]); } } @@ -1507,21 +1477,15 @@ create_datasets(hid_t file_id, offset[0] = (hsize_t)i; offset[1] = (hsize_t)j; LOGPRINT(3, " H5Sselect_hyperslab()\n"); - if (H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL) - < 0) - { + if (H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL) < 0) { TEST_ERROR; } LOGPRINT(3, " H5Dwrite()\n"); - if (H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, - filespace_ids[m], H5P_DEFAULT, data_chunk) - < 0) - { + if (H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, + data_chunk) < 0) { TEST_ERROR; } - } } } @@ -1530,10 +1494,7 @@ create_datasets(hid_t file_id, * Read and verify data from datasets */ - if (_verify_datasets(min_dset, max_dset, filespace_ids, dataset_ids, - memspace_id) - == FAIL) - { + if (_verify_datasets(min_dset, max_dset, filespace_ids, dataset_ids, memspace_id) == FAIL) { TEST_ERROR; } @@ -1541,23 +1502,19 @@ create_datasets(hid_t file_id, * Cleanup */ - if (_close_chunking_ids(min_dset, max_dset, dataspace_ids, filespace_ids, - dataset_ids, &memspace_id) - == FAIL) - { + if (_close_chunking_ids(min_dset, max_dset, dataspace_ids, filespace_ids, dataset_ids, &memspace_id) == + FAIL) { TEST_ERROR; } return SUCCEED; error: - (void)_close_chunking_ids(min_dset, max_dset, dataspace_ids, - filespace_ids, dataset_ids, &memspace_id); + (void)_close_chunking_ids(min_dset, max_dset, dataspace_ids, filespace_ids, dataset_ids, &memspace_id); LOGPRINT(1, "create_datasets() FAILED\n"); return FAIL; } /* end create_datasets() */ - /* ---------------------------------------------------------------------------- * Function: _create_chunking_ids * @@ -1570,19 +1527,13 @@ error: * ---------------------------------------------------------------------------- */ static herr_t -_create_chunking_ids(hid_t file_id, - unsigned min_dset, - unsigned max_dset, - hsize_t *chunk_dims, - hsize_t *dset_dims, - hid_t *dataspace_ids, - hid_t *filespace_ids, - hid_t *dataset_ids, - hid_t *memspace_id) +_create_chunking_ids(hid_t file_id, unsigned min_dset, unsigned max_dset, hsize_t *chunk_dims, + hsize_t *dset_dims, hid_t *dataspace_ids, hid_t *filespace_ids, hid_t *dataset_ids, + hid_t *memspace_id) { char dset_name[DSET_NAME_LEN + 1]; - unsigned m = 0; - hid_t dcpl_id = H5I_INVALID_HID; + unsigned m = 0; + hid_t dcpl_id = H5I_INVALID_HID; LOGPRINT(2, "_create_chunking_ids()\n"); @@ -1605,8 +1556,7 @@ _create_chunking_ids(hid_t file_id, for (m = min_dset; m <= max_dset; m++) { dataspace_ids[m] = H5Screate_simple(2, dset_dims, NULL); if (dataspace_ids[m] < 0) { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to create dataspace ID %d\n", m); + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to create dataspace ID %d\n", m); FAIL_PUTS_ERROR(mesg); } } @@ -1616,19 +1566,15 @@ _create_chunking_ids(hid_t file_id, */ for (m = min_dset; m <= max_dset; m++) { - if (HDsnprintf(dset_name, DSET_NAME_LEN, "/dset%03d", m) - > DSET_NAME_LEN) - { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to compose dset name %d\n", m); + if (HDsnprintf(dset_name, DSET_NAME_LEN, "/dset%03d", m) > DSET_NAME_LEN) { + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to compose dset name %d\n", m); FAIL_PUTS_ERROR(mesg); } - dataset_ids[m] = H5Dcreate(file_id, dset_name, H5T_STD_I32BE, - dataspace_ids[m], H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dataset_ids[m] = + H5Dcreate(file_id, dset_name, H5T_STD_I32BE, dataspace_ids[m], H5P_DEFAULT, dcpl_id, H5P_DEFAULT); if (dataset_ids[m] < 0) { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to create dset ID %d\n", m); + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to create dset ID %d\n", m); FAIL_PUTS_ERROR(mesg); } } @@ -1640,8 +1586,7 @@ _create_chunking_ids(hid_t file_id, for (m = min_dset; m <= max_dset; m++) { filespace_ids[m] = H5Dget_space(dataset_ids[m]); if (filespace_ids[m] < 0) { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to create filespace ID %d\n", m); + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to create filespace ID %d\n", m); FAIL_PUTS_ERROR(mesg); } } @@ -1675,7 +1620,6 @@ error: return FAIL; } /* end _create_chunking_ids() */ - /* ---------------------------------------------------------------------------- * Function: _open_chunking_ids * @@ -1688,16 +1632,10 @@ error: * ---------------------------------------------------------------------------- */ static herr_t -_open_chunking_ids( - hid_t file_id, - unsigned min_dset, - unsigned max_dset, - hsize_t *chunk_dims, - hid_t *filespace_ids, - hid_t *dataset_ids, - hid_t *memspace_id) +_open_chunking_ids(hid_t file_id, unsigned min_dset, unsigned max_dset, hsize_t *chunk_dims, + hid_t *filespace_ids, hid_t *dataset_ids, hid_t *memspace_id) { - char dset_name[DSET_NAME_LEN+1]; + char dset_name[DSET_NAME_LEN + 1]; unsigned m = 0; LOGPRINT(2, "_open_chunking_ids()\n"); @@ -1707,11 +1645,8 @@ _open_chunking_ids( */ for (m = min_dset; m <= max_dset; m++) { - if (HDsnprintf(dset_name, DSET_NAME_LEN, "/dset%03d", m) - > DSET_NAME_LEN) - { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to compose dset name %d\n", m); + if (HDsnprintf(dset_name, DSET_NAME_LEN, "/dset%03d", m) > DSET_NAME_LEN) { + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to compose dset name %d\n", m); FAIL_PUTS_ERROR(mesg); } @@ -1729,8 +1664,7 @@ _open_chunking_ids( for (m = min_dset; m <= max_dset; m++) { filespace_ids[m] = H5Dget_space(dataset_ids[m]); if (filespace_ids[m] < 0) { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to get filespace ID %d\n", m); + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to get filespace ID %d\n", m); FAIL_PUTS_ERROR(mesg); } } @@ -1751,7 +1685,6 @@ error: return FAIL; } /* end _open_chunking_ids() */ - /* --------------------------------------------------------------------------- * Function: _close_chunking_ids * @@ -1766,12 +1699,8 @@ error: * --------------------------------------------------------------------------- */ static herr_t -_close_chunking_ids(unsigned min_dset, - unsigned max_dset, - hid_t *dataspace_ids, - hid_t *filespace_ids, - hid_t *dataset_ids, - hid_t *memspace_id) +_close_chunking_ids(unsigned min_dset, unsigned max_dset, hid_t *dataspace_ids, hid_t *filespace_ids, + hid_t *dataset_ids, hid_t *memspace_id) { unsigned m; @@ -1781,26 +1710,21 @@ _close_chunking_ids(unsigned min_dset, LOGPRINT(3, "closing ids[%d]\n", m); if (dataspace_ids) { if (H5Sclose(dataspace_ids[m]) < 0) { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to close dataspace_id[%d]\n", m); + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to close dataspace_id[%d]\n", m); FAIL_PUTS_ERROR(mesg); } } if (H5Dclose(dataset_ids[m]) < 0) { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to close dataset_id[%d]\n", m); + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to close dataset_id[%d]\n", m); FAIL_PUTS_ERROR(mesg); } if (H5Sclose(filespace_ids[m]) < 0) { - HDsnprintf(mesg, MIRR_MESG_SIZE, - "unable to close filespace_id[%d]\n", m); + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to close filespace_id[%d]\n", m); FAIL_PUTS_ERROR(mesg); } } - if ( (*memspace_id != H5I_INVALID_HID) && - (H5Sclose(*memspace_id) < 0) ) - { + if ((*memspace_id != H5I_INVALID_HID) && (H5Sclose(*memspace_id) < 0)) { TEST_ERROR; } @@ -1811,7 +1735,6 @@ error: return FAIL; } /* end _close_chunking_ids() */ - /* --------------------------------------------------------------------------- * Function: _verify_datasets * @@ -1825,11 +1748,8 @@ error: * --------------------------------------------------------------------------- */ static herr_t -_verify_datasets(unsigned min_dset, - unsigned max_dset, - hid_t *filespace_ids, - hid_t *dataset_ids, - hid_t memspace_id) +_verify_datasets(unsigned min_dset, unsigned max_dset, hid_t *filespace_ids, hid_t *dataset_ids, + hid_t memspace_id) { unsigned i, j, k, l, m; int data_chunk[CHUNK_DIM][CHUNK_DIM]; @@ -1838,51 +1758,36 @@ _verify_datasets(unsigned min_dset, LOGPRINT(2, "_verify_datasets()\n"); - for (i = 0; i < DSET_DIM; i += CHUNK_DIM) - { + for (i = 0; i < DSET_DIM; i += CHUNK_DIM) { LOGPRINT(3, "i: %d\n", i); - for (j = 0; j < DSET_DIM; j += CHUNK_DIM) - { + for (j = 0; j < DSET_DIM; j += CHUNK_DIM) { LOGPRINT(3, " j: %d\n", j); - for (m = min_dset; m <= max_dset; m++) - { + for (m = min_dset; m <= max_dset; m++) { LOGPRINT(3, " m: %d\n", m); /* select on disk hyperslab */ offset[0] = (hsize_t)i; offset[1] = (hsize_t)j; - if (H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL) - < 0) - { + if (H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL) < 0) { TEST_ERROR; } - if (H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, - filespace_ids[m], H5P_DEFAULT, data_chunk) - < 0) - { - HDsnprintf(mesg, MIRR_MESG_SIZE, - " H5Dread() [%d][%d][%d]\n", - i, j, m); + if (H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, + data_chunk) < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, " H5Dread() [%d][%d][%d]\n", i, j, m); FAIL_PUTS_ERROR(mesg); } for (k = 0; k < CHUNK_DIM; k++) { for (l = 0; l < CHUNK_DIM; l++) { - if ((unsigned)data_chunk[k][l] - != - ((DSET_DIM * DSET_DIM * m) + - (DSET_DIM * (i + k)) + j + l)) - { - HDsnprintf(mesg, MIRR_MESG_SIZE, - " MISMATCH [%d][%d][%d][%d][%d]\n", - i, j, m, k, l); + if ((unsigned)data_chunk[k][l] != + ((DSET_DIM * DSET_DIM * m) + (DSET_DIM * (i + k)) + j + l)) { + HDsnprintf(mesg, MIRR_MESG_SIZE, " MISMATCH [%d][%d][%d][%d][%d]\n", i, j, m, + k, l); FAIL_PUTS_ERROR(mesg); } } } - } } } @@ -1894,7 +1799,6 @@ error: return FAIL; } /* end _verify_datasets() */ - /* --------------------------------------------------------------------------- * Function: verify_datasets * @@ -1909,9 +1813,7 @@ error: * --------------------------------------------------------------------------- */ static herr_t -verify_datasets(hid_t file_id, - unsigned min_dset, - unsigned max_dset) +verify_datasets(hid_t file_id, unsigned min_dset, unsigned max_dset) { hid_t dataset_ids[MAX_DSET_COUNT + 1]; hid_t filespace_ids[MAX_DSET_COUNT + 1]; @@ -1931,7 +1833,7 @@ verify_datasets(hid_t file_id, for (i = 0; i < MAX_DSET_COUNT; i++) { LOGPRINT(3, "clearing IDs [%d]\n", i); - dataset_ids[i] = H5I_INVALID_HID; + dataset_ids[i] = H5I_INVALID_HID; filespace_ids[i] = H5I_INVALID_HID; } @@ -1939,10 +1841,8 @@ verify_datasets(hid_t file_id, * Generate dataspace, dataset, and 'filespace' IDs */ - if (_open_chunking_ids(file_id, min_dset, max_dset, chunk_dims, - filespace_ids, dataset_ids, &memspace_id) - == FAIL) - { + if (_open_chunking_ids(file_id, min_dset, max_dset, chunk_dims, filespace_ids, dataset_ids, + &memspace_id) == FAIL) { TEST_ERROR; } @@ -1950,10 +1850,7 @@ verify_datasets(hid_t file_id, * Read and verify data from datasets */ - if (_verify_datasets(min_dset, max_dset, filespace_ids, dataset_ids, - memspace_id) - == FAIL) - { + if (_verify_datasets(min_dset, max_dset, filespace_ids, dataset_ids, memspace_id) == FAIL) { TEST_ERROR; } @@ -1961,10 +1858,7 @@ verify_datasets(hid_t file_id, * Cleanup */ - if (_close_chunking_ids(min_dset, max_dset, NULL, filespace_ids, - dataset_ids, &memspace_id) - == FAIL) - { + if (_close_chunking_ids(min_dset, max_dset, NULL, filespace_ids, dataset_ids, &memspace_id) == FAIL) { TEST_ERROR; } @@ -1972,13 +1866,11 @@ verify_datasets(hid_t file_id, error: LOGPRINT(1, "verify_datasets() FAILED\n"); - (void)_close_chunking_ids(min_dset, max_dset, NULL, filespace_ids, - dataset_ids, &memspace_id); + (void)_close_chunking_ids(min_dset, max_dset, NULL, filespace_ids, dataset_ids, &memspace_id); return FAIL; } /* end verify_datasets() */ - /* --------------------------------------------------------------------------- * Function: test_basic_dataset_write * @@ -1998,15 +1890,15 @@ static int test_basic_dataset_write(void) { struct mirrortest_filenames names; - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id = H5P_DEFAULT; - hid_t dset_id = H5I_INVALID_HID; - hid_t dspace_id = H5I_INVALID_HID; - hid_t dtype_id = H5T_NATIVE_INT; - hsize_t dims[2] = { DATABUFFER_SIZE, DATABUFFER_SIZE }; - int *buf = NULL; - int i = 0; - int j = 0; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; + hid_t dset_id = H5I_INVALID_HID; + hid_t dspace_id = H5I_INVALID_HID; + hid_t dtype_id = H5T_NATIVE_INT; + hsize_t dims[2] = {DATABUFFER_SIZE, DATABUFFER_SIZE}; + int * buf = NULL; + int i = 0; + int j = 0; TESTING("Mirror open and dataset writing"); @@ -2025,7 +1917,7 @@ test_basic_dataset_write(void) } for (i = 0; i < DATABUFFER_SIZE; i++) { for (j = 0; j < DATABUFFER_SIZE; j++) { - int k = i * DATABUFFER_SIZE + j; + int k = i * DATABUFFER_SIZE + j; buf[k] = k; } } @@ -2042,7 +1934,6 @@ test_basic_dataset_write(void) } file_id = H5I_INVALID_HID; - /* -------------------- */ /* TEST: Repoen and Write */ @@ -2055,15 +1946,12 @@ test_basic_dataset_write(void) if (H5I_INVALID_HID == dspace_id) { TEST_ERROR; } - dset_id = H5Dcreate2(file_id, "dataset", dtype_id, dspace_id, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, "dataset", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (H5I_INVALID_HID == dset_id) { TEST_ERROR; } - if (H5Dwrite(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) - == FAIL) - { + if (H5Dwrite(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) == FAIL) { TEST_ERROR; } @@ -2098,7 +1986,8 @@ test_basic_dataset_write(void) return 0; error: - H5E_BEGIN_TRY{ + H5E_BEGIN_TRY + { (void)H5Fclose(file_id); if (buf) { HDfree(buf); @@ -2108,11 +1997,11 @@ error: if (fapl_id != H5P_DEFAULT && fapl_id > 0) { (void)H5Pclose(fapl_id); } - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_basic_dataset_write() */ - /* --------------------------------------------------------------------------- * Function: test_chunked_dataset_write * @@ -2132,8 +2021,8 @@ static int test_chunked_dataset_write(void) { struct mirrortest_filenames names; - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id = H5P_DEFAULT; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; TESTING("Mirror open and dataset writing (chunked)"); @@ -2215,16 +2104,17 @@ test_chunked_dataset_write(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Fclose(file_id); if (fapl_id != H5P_DEFAULT && fapl_id > 0) { (void)H5Pclose(fapl_id); } - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_chunked_dataset_write() */ - /* --------------------------------------------------------------------------- * Function: test_on_disk_zoo * @@ -2244,11 +2134,11 @@ error: static int test_on_disk_zoo(void) { - const char grp_name[] = "/only"; + const char grp_name[] = "/only"; struct mirrortest_filenames names; - hid_t file_id = H5I_INVALID_HID; - hid_t grp_id = H5I_INVALID_HID; - hid_t fapl_id = H5P_DEFAULT; + hid_t file_id = H5I_INVALID_HID; + hid_t grp_id = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; TESTING("'Zoo' of on-disk structures"); @@ -2266,8 +2156,7 @@ test_on_disk_zoo(void) TEST_ERROR; } - grp_id = H5Gcreate2(file_id, grp_name, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + grp_id = H5Gcreate2(file_id, grp_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp_id == H5I_INVALID_HID) { TEST_ERROR; } @@ -2277,10 +2166,10 @@ test_on_disk_zoo(void) * from cache_common and/or genall5. */ - if ( pass ) { + if (pass) { create_zoo(file_id, grp_name, 0); } - if ( pass ) { + if (pass) { if (H5Fclose(file_id) == FAIL) { TEST_ERROR; } @@ -2289,10 +2178,10 @@ test_on_disk_zoo(void) TEST_ERROR; } } - if ( pass ) { + if (pass) { validate_zoo(file_id, grp_name, 0); /* sanity-check */ } - if ( !pass ) { + if (!pass) { HDprintf(failure_mssg); TEST_ERROR; } @@ -2323,17 +2212,18 @@ test_on_disk_zoo(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Fclose(file_id); (void)H5Gclose(grp_id); if (fapl_id != H5P_DEFAULT && fapl_id > 0) { (void)H5Pclose(fapl_id); } - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_on_disk_zoo() */ - /* --------------------------------------------------------------------------- * Function: test_vanishing_datasets * @@ -2358,17 +2248,17 @@ static int test_vanishing_datasets(void) { struct mirrortest_filenames names; - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dspace_id = H5I_INVALID_HID; - hid_t mirror_fapl_id = H5I_INVALID_HID; - hsize_t dims[2] = {DATABUFFER_SIZE, DATABUFFER_SIZE}; - uint32_t buf[DATABUFFER_SIZE][DATABUFFER_SIZE]; /* consider malloc? */ - H5G_info_t group_info; - unsigned int i, j, k; - const unsigned int max_loops = 20; - const unsigned int max_at_one_time = 3; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dspace_id = H5I_INVALID_HID; + hid_t mirror_fapl_id = H5I_INVALID_HID; + hsize_t dims[2] = {DATABUFFER_SIZE, DATABUFFER_SIZE}; + uint32_t buf[DATABUFFER_SIZE][DATABUFFER_SIZE]; /* consider malloc? */ + H5G_info_t group_info; + unsigned int i, j, k; + const unsigned int max_loops = 20; + const unsigned int max_at_one_time = 3; TESTING("Vanishing Datasets"); @@ -2393,15 +2283,12 @@ test_vanishing_datasets(void) TEST_ERROR; } - for (i=0; i < max_loops; i++) { + for (i = 0; i < max_loops; i++) { char namebuf[DSET_NAME_LEN + 1]; /* deleting datasets */ if (i >= max_at_one_time) { - if (HDsnprintf(namebuf, DSET_NAME_LEN, "/dset%02d", - (i - max_at_one_time) ) - > DSET_NAME_LEN) - { + if (HDsnprintf(namebuf, DSET_NAME_LEN, "/dset%02d", (i - max_at_one_time)) > DSET_NAME_LEN) { TEST_ERROR; } if (H5Ldelete(file_id, namebuf, H5P_DEFAULT) < 0) { @@ -2411,27 +2298,22 @@ test_vanishing_datasets(void) /* writing datasets */ if (i < (max_loops - max_at_one_time)) { - if (HDsnprintf(namebuf, DSET_NAME_LEN, "/dset%02d", i) - > DSET_NAME_LEN) - { + if (HDsnprintf(namebuf, DSET_NAME_LEN, "/dset%02d", i) > DSET_NAME_LEN) { TEST_ERROR; } - dset_id = H5Dcreate2(file_id, namebuf, H5T_STD_U32LE, dspace_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = + H5Dcreate2(file_id, namebuf, H5T_STD_U32LE, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (H5I_INVALID_HID == dset_id) { TEST_ERROR; } - for (j=0; j < DATABUFFER_SIZE; j++) { - for (k=0; k < DATABUFFER_SIZE; k++) { + for (j = 0; j < DATABUFFER_SIZE; j++) { + for (k = 0; k < DATABUFFER_SIZE; k++) { buf[j][k] = (uint32_t)i; } } - if (H5Dwrite(dset_id, H5T_STD_U32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - buf) - < 0) - { + if (H5Dwrite(dset_id, H5T_STD_U32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) { TEST_ERROR; } @@ -2498,7 +2380,8 @@ test_vanishing_datasets(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (mirror_fapl_id != H5I_INVALID_HID) { H5Pclose(mirror_fapl_id); } @@ -2514,11 +2397,11 @@ error: if (dspace_id != H5I_INVALID_HID) { H5Sclose(dspace_id); } - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_vanishing_datasets() */ - /* --------------------------------------------------------------------------- * Function: test_concurrent_access * @@ -2538,34 +2421,34 @@ test_concurrent_access(void) { struct file_bundle { struct mirrortest_filenames names; - hid_t dset_id; - hid_t fapl_id; - hid_t file_id; + hid_t dset_id; + hid_t fapl_id; + hid_t file_id; } bundle[CONCURRENT_COUNT]; - hid_t dspace_id = H5I_INVALID_HID; - hid_t dtype_id = H5T_NATIVE_INT; - hsize_t dims[2] = { DATABUFFER_SIZE, DATABUFFER_SIZE }; - int *buf = NULL; - int i = 0; - int j = 0; + hid_t dspace_id = H5I_INVALID_HID; + hid_t dtype_id = H5T_NATIVE_INT; + hsize_t dims[2] = {DATABUFFER_SIZE, DATABUFFER_SIZE}; + int * buf = NULL; + int i = 0; + int j = 0; TESTING("Concurrent opened mirrored files"); /* blank bundle */ for (i = 0; i < CONCURRENT_COUNT; i++) { - bundle[i].dset_id = H5I_INVALID_HID; - bundle[i].fapl_id = H5I_INVALID_HID; - bundle[i].file_id = H5I_INVALID_HID; - *bundle[i].names.rw = '\0'; - *bundle[i].names.wo = '\0'; + bundle[i].dset_id = H5I_INVALID_HID; + bundle[i].fapl_id = H5I_INVALID_HID; + bundle[i].file_id = H5I_INVALID_HID; + *bundle[i].names.rw = '\0'; + *bundle[i].names.wo = '\0'; *bundle[i].names.log = '\0'; } /* Create FAPL for Splitter[sec2|mirror] */ for (i = 0; i < CONCURRENT_COUNT; i++) { - char _name[16] = ""; - hid_t _fapl_id = H5I_INVALID_HID; + char _name[16] = ""; + hid_t _fapl_id = H5I_INVALID_HID; HDsnprintf(_name, 15, "concurrent%d", i); _fapl_id = create_mirroring_split_fapl(_name, &bundle[i].names); if (H5I_INVALID_HID == _fapl_id) { @@ -2582,7 +2465,7 @@ test_concurrent_access(void) } for (i = 0; i < DATABUFFER_SIZE; i++) { for (j = 0; j < DATABUFFER_SIZE; j++) { - int k = i * DATABUFFER_SIZE + j; + int k = i * DATABUFFER_SIZE + j; buf[k] = k; } } @@ -2601,16 +2484,15 @@ test_concurrent_access(void) hid_t _file_id = H5I_INVALID_HID; hid_t _dset_id = H5I_INVALID_HID; - _file_id = H5Fcreate(bundle[i].names.rw, H5F_ACC_TRUNC, H5P_DEFAULT, - bundle[i].fapl_id); + _file_id = H5Fcreate(bundle[i].names.rw, H5F_ACC_TRUNC, H5P_DEFAULT, bundle[i].fapl_id); if (H5I_INVALID_HID == _file_id) { TEST_ERROR; } - bundle[i].file_id = _file_id; + bundle[i].file_id = _file_id; - _dset_id = H5Dcreate2(_file_id, "dataset", dtype_id, dspace_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + _dset_id = + H5Dcreate2(_file_id, "dataset", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (H5I_INVALID_HID == _dset_id) { TEST_ERROR; } @@ -2621,10 +2503,7 @@ test_concurrent_access(void) /* TEST: Write to files */ for (i = 0; i < CONCURRENT_COUNT; i++) { - if (H5Dwrite(bundle[i].dset_id, dtype_id, H5S_ALL, H5S_ALL, - H5P_DEFAULT, buf) - == FAIL) - { + if (H5Dwrite(bundle[i].dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) == FAIL) { TEST_ERROR; } } @@ -2666,7 +2545,8 @@ test_concurrent_access(void) return 0; error: - H5E_BEGIN_TRY{ + H5E_BEGIN_TRY + { if (buf) { HDfree(buf); } @@ -2676,11 +2556,11 @@ error: (void)H5Fclose(bundle[i].file_id); (void)H5Pclose(bundle[i].fapl_id); } - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_concurrent_access() */ - /* --------------------------------------------------------------------------- * Function: main * @@ -2736,8 +2616,7 @@ main(void) } if (nerrors) { - HDprintf("***** %d Mirror VFD TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + HDprintf("***** %d Mirror VFD TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); return EXIT_FAILURE; } @@ -2757,5 +2636,3 @@ main(void) } #endif /* H5_HAVE_MIRROR_VFD */ - - diff --git a/test/mount.c b/test/mount.c index 3abe084..5256be4 100644 --- a/test/mount.c +++ b/test/mount.c @@ -18,28 +18,18 @@ * Purpose: Tests file mounting. */ #include "h5test.h" -#include "H5Fprivate.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ - -const char *FILENAME[] = { - "mount_1", - "mount_2", - "mount_3", - "mount_4", - "mount_5", - "mount_6", - "mount_7", - NULL -}; +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ + +const char *FILENAME[] = {"mount_1", "mount_2", "mount_3", "mount_4", "mount_5", "mount_6", "mount_7", NULL}; /* For "mount_after_close" test */ -#define RANK 2 -#define NX 4 -#define NY 5 -#define NAME_BUF_SIZE 40 +#define RANK 2 +#define NX 4 +#define NY 5 +#define NAME_BUF_SIZE 40 int bm[NX][NY], bm_out[NX][NY]; /* Data buffers */ - /*------------------------------------------------------------------------- * Function: setup * @@ -59,44 +49,61 @@ int bm[NX][NY], bm_out[NX][NY]; /* Data buffers */ static int setup(hid_t fapl) { - hid_t file = -1; - char filename[1024]; + hid_t file = -1; + char filename[1024]; /* file 1 */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if(H5Gclose(H5Gcreate2(file, "/mnt1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(H5Gcreate2(file, "/mnt1/file1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(H5Gcreate2(file, "/mnt_unlink", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(H5Gcreate2(file, "/mnt_move_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lcreate_hard(file, "/mnt1/file1", H5L_SAME_LOC, "/file1", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_hard(file, "/mnt1", H5L_SAME_LOC, "/mnt1_link", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(H5Gcreate2(file, "/mnt1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(H5Gcreate2(file, "/mnt1/file1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(H5Gcreate2(file, "/mnt_unlink", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(H5Gcreate2(file, "/mnt_move_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_hard(file, "/mnt1/file1", H5L_SAME_LOC, "/file1", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_hard(file, "/mnt1", H5L_SAME_LOC, "/mnt1_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* file 2 */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if(H5Gclose(H5Gcreate2(file, "/file2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(H5Gcreate2(file, "/rename_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(H5Gcreate2(file, "/rename_b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(H5Gcreate2(file, "/rename_a/x", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(H5Gcreate2(file, "/file2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(H5Gcreate2(file, "/rename_a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(H5Gcreate2(file, "/rename_b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(H5Gcreate2(file, "/rename_a/x", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* file 3 */ h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR return 0; error: - H5E_BEGIN_TRY { - H5Fclose(file); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Fclose(file); + } + H5E_END_TRY; return -1; } /* end setup() */ - /*------------------------------------------------------------------------- * Function: test_basic * @@ -117,35 +124,42 @@ error: static int test_basic(hid_t fapl) { - hid_t file1 = -1, file2 = -1, grp = -1; - char filename1[1024], filename2[1024]; + hid_t file1 = -1, file2 = -1, grp = -1; + char filename1[1024], filename2[1024]; TESTING("basic functionality"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if ((grp = H5Gopen2(file1, "/mnt1/file2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grp) < 0) + FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if((grp = H5Gopen2(file1, "/mnt1/file2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR - if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Fclose(file1); - H5Fclose(file2); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Fclose(file1); + H5Fclose(file2); + } + H5E_END_TRY; return 1; } /* end test_basic() */ - /*------------------------------------------------------------------------- * Function: test_illegal * @@ -166,34 +180,35 @@ test_basic(hid_t fapl) static int test_illegal(hid_t fapl) { - hid_t file1 = -1, file1b = -1, file2 = -1, file3 = -1, file3b = -1, mnt = -1; - char filename1[1024], filename2[1024], filename3[1024]; - herr_t status; + hid_t file1 = -1, file1b = -1, file2 = -1, file3 = -1, file3b = -1, mnt = -1; + char filename1[1024], filename2[1024], filename3[1024]; + herr_t status; TESTING("illegal mount operations"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); - /* Open the files */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0 || - (file3 = H5Fopen(filename3, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR - if((file1b = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR - if((file3b = H5Fopen(filename3, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0 || + (file3 = H5Fopen(filename3, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if ((file1b = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if ((file3b = H5Fopen(filename3, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Try mounting a file on itself */ - H5E_BEGIN_TRY { - status = H5Fmount(file1, "/mnt1", file1, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Mounting a file on itself should have failed."); - TEST_ERROR + H5E_BEGIN_TRY + { + status = H5Fmount(file1, "/mnt1", file1, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Mounting a file on itself should have failed."); + TEST_ERROR } /* end if */ /* @@ -201,18 +216,24 @@ test_illegal(hid_t fapl) * point before we mount the first file or we'll end up mounting file3 at * the root of file2 and the mount will succeed. */ - if((mnt = H5Gopen2(file1, "/mnt1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Fmount(mnt, ".", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - status = H5Fmount(mnt, ".", file3, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Mounting two files at one mount point should have failed."); - TEST_ERROR + if ((mnt = H5Gopen2(file1, "/mnt1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(mnt, ".", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + status = H5Fmount(mnt, ".", file3, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Mounting two files at one mount point should have failed."); + TEST_ERROR } /* end if */ - if(H5Funmount(mnt, ".") < 0) FAIL_STACK_ERROR - if(H5Gclose(mnt) < 0) FAIL_STACK_ERROR + if (H5Funmount(mnt, ".") < 0) + FAIL_STACK_ERROR + if (H5Gclose(mnt) < 0) + FAIL_STACK_ERROR /* * Try mounting the same file opened twice at the same place. @@ -220,54 +241,70 @@ test_illegal(hid_t fapl) * We have to open the mount point before we mount the first file or we'll * end up mounting file3b at the root of file3 and the mount will succeed. */ - if((mnt = H5Gopen2(file1, "/mnt1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Fmount(mnt, ".", file3, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - status = H5Fmount(mnt, ".", file3b, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Mounting same file opened twice at one mount point should have failed."); - TEST_ERROR + if ((mnt = H5Gopen2(file1, "/mnt1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(mnt, ".", file3, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + status = H5Fmount(mnt, ".", file3b, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Mounting same file opened twice at one mount point should have failed."); + TEST_ERROR } /* end if */ - if(H5Funmount(mnt, ".") < 0) FAIL_STACK_ERROR - if(H5Gclose(mnt) < 0) FAIL_STACK_ERROR + if (H5Funmount(mnt, ".") < 0) + FAIL_STACK_ERROR + if (H5Gclose(mnt) < 0) + FAIL_STACK_ERROR /* Try to create a "weak" cycle */ - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - status = H5Fmount(file2, "/mnt1/file2", file1b, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Creating a cycle with mount points should have failed."); - TEST_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + status = H5Fmount(file2, "/mnt1/file2", file1b, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Creating a cycle with mount points should have failed."); + TEST_ERROR } /* end if */ - if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + FAIL_STACK_ERROR /* Close everything and return */ - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1b) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR - if(H5Fclose(file3) < 0) FAIL_STACK_ERROR - if(H5Fclose(file3b) < 0) FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1b) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file3) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file3b) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(mnt); - H5Fclose(file1); - H5Fclose(file1b); - H5Fclose(file2); - H5Fclose(file3); - H5Fclose(file3b); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(mnt); + H5Fclose(file1); + H5Fclose(file1b); + H5Fclose(file2); + H5Fclose(file3); + H5Fclose(file3b); + } + H5E_END_TRY; return 1; } /* end test_illegal() */ - /*------------------------------------------------------------------------- * Function: test_samefile * @@ -285,27 +322,26 @@ error: static int test_samefile(hid_t fapl) { - hid_t file1a = -1, file1b = -1, file2 = -1, file3 = -1; - hid_t mnt1a = -1, mnt1b = -1; - char filename1[1024], filename2[1024], filename3[1024]; - H5G_info_t grp_info; - herr_t status; + hid_t file1a = -1, file1b = -1, file2 = -1, file3 = -1; + hid_t mnt1a = -1, mnt1b = -1; + char filename1[1024], filename2[1024], filename3[1024]; + H5G_info_t grp_info; + herr_t status; TESTING("same file mount operations"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); - /* Open the files */ - if((file1a = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR - if((file1b = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR - if((file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR - if((file3 = H5Fopen(filename3, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR + if ((file1a = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if ((file1b = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if ((file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if ((file3 = H5Fopen(filename3, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* * Try mounting different files at the same place in each of the "top" @@ -314,22 +350,37 @@ test_samefile(hid_t fapl) * We have to open the mount point before we mount the first file or we'll * end up mounting file4 at the root of file3 and the mount will succeed. */ - if((mnt1a = H5Gopen2(file1a, "/mnt1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gget_info(mnt1a, &grp_info) < 0) FAIL_STACK_ERROR - if(grp_info.mounted) FAIL_PUTS_ERROR(" Group shouldn't have 'mounted' flag set.") - if((mnt1b = H5Gopen2(file1b, "/mnt1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gget_info(mnt1b, &grp_info) < 0) FAIL_STACK_ERROR - if(grp_info.mounted) FAIL_PUTS_ERROR(" Group shouldn't have 'mounted' flag set.") - if(H5Fmount(mnt1a, ".", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gget_info(mnt1a, &grp_info) < 0) FAIL_STACK_ERROR - if(!grp_info.mounted) FAIL_PUTS_ERROR(" Group should have 'mounted' flag set.") - H5E_BEGIN_TRY { - status = H5Fmount(mnt1b, ".", file3, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) FAIL_PUTS_ERROR(" Mounting different files at one mount point should have failed.") - if(H5Funmount(mnt1a, ".") < 0) FAIL_STACK_ERROR - if(H5Gclose(mnt1a) < 0) FAIL_STACK_ERROR - if(H5Gclose(mnt1b) < 0) FAIL_STACK_ERROR + if ((mnt1a = H5Gopen2(file1a, "/mnt1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gget_info(mnt1a, &grp_info) < 0) + FAIL_STACK_ERROR + if (grp_info.mounted) + FAIL_PUTS_ERROR(" Group shouldn't have 'mounted' flag set.") + if ((mnt1b = H5Gopen2(file1b, "/mnt1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gget_info(mnt1b, &grp_info) < 0) + FAIL_STACK_ERROR + if (grp_info.mounted) + FAIL_PUTS_ERROR(" Group shouldn't have 'mounted' flag set.") + if (H5Fmount(mnt1a, ".", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gget_info(mnt1a, &grp_info) < 0) + FAIL_STACK_ERROR + if (!grp_info.mounted) + FAIL_PUTS_ERROR(" Group should have 'mounted' flag set.") + H5E_BEGIN_TRY + { + status = H5Fmount(mnt1b, ".", file3, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR(" Mounting different files at one mount point should have failed.") + if (H5Funmount(mnt1a, ".") < 0) + FAIL_STACK_ERROR + if (H5Gclose(mnt1a) < 0) + FAIL_STACK_ERROR + if (H5Gclose(mnt1b) < 0) + FAIL_STACK_ERROR /* * Try mounting same files at the same place in each of the "top" @@ -338,46 +389,65 @@ test_samefile(hid_t fapl) * We have to open the mount point before we mount the first file or we'll * end up mounting file4 at the root of file3 and the mount will succeed. */ - if((mnt1a = H5Gopen2(file1a, "/mnt1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gget_info(mnt1a, &grp_info) < 0) FAIL_STACK_ERROR - if(grp_info.mounted) FAIL_PUTS_ERROR(" Group shouldn't have 'mounted' flag set.") - if((mnt1b = H5Gopen2(file1b, "/mnt1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gget_info(mnt1b, &grp_info) < 0) FAIL_STACK_ERROR - if(grp_info.mounted) FAIL_PUTS_ERROR(" Group shouldn't have 'mounted' flag set.") - if(H5Fmount(mnt1a, ".", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gget_info(mnt1a, &grp_info) < 0) FAIL_STACK_ERROR - if(!grp_info.mounted) FAIL_PUTS_ERROR(" Group should have 'mounted' flag set.") - H5E_BEGIN_TRY { - status = H5Fmount(mnt1b, ".", file2, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) FAIL_PUTS_ERROR(" Mounting same files at one mount point should have failed.") - if(H5Funmount(mnt1a, ".") < 0) FAIL_STACK_ERROR - if(H5Gclose(mnt1a) < 0) FAIL_STACK_ERROR - if(H5Gclose(mnt1b) < 0) FAIL_STACK_ERROR - + if ((mnt1a = H5Gopen2(file1a, "/mnt1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gget_info(mnt1a, &grp_info) < 0) + FAIL_STACK_ERROR + if (grp_info.mounted) + FAIL_PUTS_ERROR(" Group shouldn't have 'mounted' flag set.") + if ((mnt1b = H5Gopen2(file1b, "/mnt1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gget_info(mnt1b, &grp_info) < 0) + FAIL_STACK_ERROR + if (grp_info.mounted) + FAIL_PUTS_ERROR(" Group shouldn't have 'mounted' flag set.") + if (H5Fmount(mnt1a, ".", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gget_info(mnt1a, &grp_info) < 0) + FAIL_STACK_ERROR + if (!grp_info.mounted) + FAIL_PUTS_ERROR(" Group should have 'mounted' flag set.") + H5E_BEGIN_TRY + { + status = H5Fmount(mnt1b, ".", file2, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR(" Mounting same files at one mount point should have failed.") + if (H5Funmount(mnt1a, ".") < 0) + FAIL_STACK_ERROR + if (H5Gclose(mnt1a) < 0) + FAIL_STACK_ERROR + if (H5Gclose(mnt1b) < 0) + FAIL_STACK_ERROR /* Close everything and return */ - if(H5Fclose(file1a) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1b) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR - if(H5Fclose(file3) < 0) FAIL_STACK_ERROR + if (H5Fclose(file1a) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1b) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file3) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(mnt1a); - H5Gclose(mnt1b); - H5Fclose(file1a); - H5Fclose(file1b); - H5Fclose(file2); - H5Fclose(file3); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(mnt1a); + H5Gclose(mnt1b); + H5Fclose(file1a); + H5Fclose(file1b); + H5Fclose(file2); + H5Fclose(file3); + } + H5E_END_TRY; return 1; } /* end test_samefile() */ - /*------------------------------------------------------------------------- * Function: test_hide * @@ -399,32 +469,34 @@ error: static int test_hide(hid_t fapl) { - hid_t file1 = -1, file2 = -1, grp = -1; - H5O_info2_t oi1, oi2; - char filename1[1024], filename2[1024]; - hbool_t same_obj; + hid_t file1 = -1, file2 = -1, grp = -1; + H5O_info2_t oi1, oi2; + char filename1[1024], filename2[1024]; + hbool_t same_obj; TESTING("name hiding under mount point"); h5_fixname(FILENAME[0], fapl, filename1, sizeof(filename1)); h5_fixname(FILENAME[1], fapl, filename2, sizeof(filename2)); - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Get information about file1:/mnt1/file1 for later */ - if(H5Oget_info_by_name3(file1, "/mnt1/file1", &oi1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + if (H5Oget_info_by_name3(file1, "/mnt1/file1", &oi1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Build the virtual file */ - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Original names under file1:/mnt1 should not be accessible */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { grp = H5Gopen2(file1, "/mnt1/file1", H5P_DEFAULT); - } H5E_END_TRY; - if(grp >= 0) { + } + H5E_END_TRY; + if (grp >= 0) { H5_FAILED(); HDputs(" Name is still accessible under mount point."); TEST_ERROR @@ -434,45 +506,49 @@ test_hide(hid_t fapl) * The original objects under file1:/mnt1 are still accessible by their * other names. This is a rather stupid test but demonstrates a point. */ - if(H5Oget_info_by_name3(file1, "/file1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + if (H5Oget_info_by_name3(file1, "/file1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR same_obj = TRUE; - if(oi1.fileno == oi2.fileno) { + if (oi1.fileno == oi2.fileno) { int token_cmp; - if(H5Otoken_cmp(file1, &oi1.token, &oi2.token, &token_cmp) < 0) + if (H5Otoken_cmp(file1, &oi1.token, &oi2.token, &token_cmp) < 0) FAIL_STACK_ERROR - if(token_cmp) + if (token_cmp) same_obj = FALSE; } else same_obj = FALSE; - if(!same_obj) { + if (!same_obj) { H5_FAILED(); HDputs(" Hard link failed for hidden object."); TEST_ERROR } /* Unmount and close objects */ - if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(grp); H5Fclose(file1); H5Fclose(file2); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_hide() */ - /*------------------------------------------------------------------------- * Function: test_assoc * @@ -493,70 +569,74 @@ error: static int test_assoc(hid_t fapl) { - hid_t file1 = -1, file2 = -1; - H5O_info2_t oi1, oi2; - char filename1[1024], filename2[1024]; - hbool_t same_obj; + hid_t file1 = -1, file2 = -1; + H5O_info2_t oi1, oi2; + char filename1[1024], filename2[1024]; + hbool_t same_obj; TESTING("mount point open"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Open the files */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Get information about the root of file2 */ - if(H5Oget_info3(file2, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(file2, &oi1, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Create the virtual file */ - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* * Get info about the mount point -- should be the same as the root group * of file2. */ - if(H5Oget_info_by_name3(file1, "/mnt1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + if (H5Oget_info_by_name3(file1, "/mnt1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR same_obj = TRUE; - if(oi1.fileno == oi2.fileno) { + if (oi1.fileno == oi2.fileno) { int token_cmp; - if(H5Otoken_cmp(file1, &oi1.token, &oi2.token, &token_cmp) < 0) + if (H5Otoken_cmp(file1, &oi1.token, &oi2.token, &token_cmp) < 0) FAIL_STACK_ERROR - if(token_cmp) + if (token_cmp) same_obj = FALSE; } else same_obj = FALSE; - if(!same_obj) { + if (!same_obj) { H5_FAILED(); HDputs(" Association failed."); TEST_ERROR } /* end if */ /* Shut down */ - if(H5Funmount(file1, "/mnt1_link") < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1_link") < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file2); H5Fclose(file1); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_assoc() */ - /*------------------------------------------------------------------------- * Function: test_mntlnk * @@ -578,47 +658,55 @@ error: static int test_mntlnk(hid_t fapl) { - hid_t file1 = -1, file2 = -1, grp = -1; - char filename1[1024], filename2[1024]; + hid_t file1 = -1, file2 = -1, grp = -1; + char filename1[1024], filename2[1024]; TESTING("multi-linked mount point"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); - /* Build the virtual file */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* * Can we see file2:/file2 as both file1:/mnt1/file2 and * file1:/mnt1_link/file2? */ - if((grp = H5Gopen2(file1, "/mnt1/file2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR - if((grp = H5Gopen2(file1, "/mnt1_link/file2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR + if ((grp = H5Gopen2(file1, "/mnt1/file2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grp) < 0) + FAIL_STACK_ERROR + if ((grp = H5Gopen2(file1, "/mnt1_link/file2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grp) < 0) + FAIL_STACK_ERROR /* Unlink using second name */ - if(H5Funmount(file1, "/mnt1_link") < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1_link") < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(grp); - H5Fclose(file1); - H5Fclose(file2); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(grp); + H5Fclose(file1); + H5Fclose(file2); + } + H5E_END_TRY; return 1; } /* end test_mntlnk() */ - /*------------------------------------------------------------------------- * Function: test_move * @@ -640,48 +728,56 @@ error: static int test_move(hid_t fapl) { - hid_t file1 = -1, file2 = -1; - herr_t status; - char filename1[1024], filename2[1024]; + hid_t file1 = -1, file2 = -1; + herr_t status; + char filename1[1024], filename2[1024]; TESTING("object renaming"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Build the virtual file */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* First rename an object in the mounted file, then try it across files */ - if(H5Lmove(file1, "/mnt1/rename_a/x", H5L_SAME_LOC, "/mnt1/rename_b/y", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - status = H5Lmove(file1, "/mnt1/rename_b/y", H5L_SAME_LOC, "/y", H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Moving an object across files should't have been possible"); - TEST_ERROR + if (H5Lmove(file1, "/mnt1/rename_a/x", H5L_SAME_LOC, "/mnt1/rename_b/y", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + status = H5Lmove(file1, "/mnt1/rename_b/y", H5L_SAME_LOC, "/y", H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Moving an object across files should't have been possible"); + TEST_ERROR } /* end if */ /* Shut down */ - if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Fclose(file1); - H5Fclose(file2); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Fclose(file1); + H5Fclose(file2); + } + H5E_END_TRY; return 1; } /* end test_move() */ - /*------------------------------------------------------------------------- * Function: test_preopen * @@ -702,46 +798,54 @@ error: static int test_preopen(hid_t fapl) { - hid_t file1 = -1, file2 = -1, grp = -1; + hid_t file1 = -1, file2 = -1, grp = -1; H5O_info2_t oinfo; - char filename1[1024], filename2[1024]; + char filename1[1024], filename2[1024]; TESTING("preopening objects under the mount point"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Open something under the mount point */ - if((grp = H5Gopen2(file1, "/mnt1/file1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((grp = H5Gopen2(file1, "/mnt1/file1", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Build the virtual file */ - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Now access the thing we previously opened */ - if(H5Oget_info3(grp, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR + if (H5Oget_info3(grp, &oinfo, H5O_INFO_BASIC) < 0) + FAIL_STACK_ERROR /* Shut down */ - if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + FAIL_STACK_ERROR + if (H5Gclose(grp) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(grp); - H5Fclose(file2); - H5Fclose(file1); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(grp); + H5Fclose(file2); + H5Fclose(file1); + } + H5E_END_TRY; return 1; } /* end test_preopen() */ - /*------------------------------------------------------------------------- * Function: test_postopen * @@ -764,50 +868,59 @@ static int test_postopen(hid_t fapl) { - hid_t file1 = -1, file2 = -1, grp = -1; + hid_t file1 = -1, file2 = -1, grp = -1; H5O_info2_t oinfo; - char filename1[1024], filename2[1024]; + char filename1[1024], filename2[1024]; TESTING("open object access after unmount"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Create the virtual file */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open some object in the mounted file */ - if((grp = H5Gopen2(file1, "/mnt1/file2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((grp = H5Gopen2(file1, "/mnt1/file2", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Unmount the file */ - if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + FAIL_STACK_ERROR /* Now access the thing we previously opened */ - if(H5Oget_info3(grp, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR + if (H5Oget_info3(grp, &oinfo, H5O_INFO_BASIC) < 0) + FAIL_STACK_ERROR /* Try accessing it from the file */ - if(H5Oget_info_by_name3(file2, "/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file2, "/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Shut down */ - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Gclose(grp) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(grp); - H5Fclose(file2); - H5Fclose(file1); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(grp); + H5Fclose(file2); + H5Fclose(file1); + } + H5E_END_TRY; return 1; } /* end test_postopen() */ - /*------------------------------------------------------------------------- * Function: test_unlink * @@ -829,28 +942,31 @@ error: static int test_unlink(hid_t fapl) { - hid_t file1 = -1, file2 = -1, mnt = -1, root = -1; + hid_t file1 = -1, file2 = -1, mnt = -1, root = -1; H5O_info2_t oinfo; - char filename1[1024], filename2[1024]; - herr_t status; + char filename1[1024], filename2[1024]; + herr_t status; TESTING("mount point unlinking"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Open files */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* * Opening the mount point before mounting opens the group in the parent * file, but opening the mount point after mounting is the same as * opening the root group of the child file. */ - if((mnt = H5Gopen2(file1, "/mnt_unlink", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt_unlink", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if((root = H5Gopen2(file1, "/mnt_unlink", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((mnt = H5Gopen2(file1, "/mnt_unlink", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt_unlink", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if ((root = H5Gopen2(file1, "/mnt_unlink", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* * "/file2" of file2 should be visible as an absolute name through either @@ -858,42 +974,54 @@ test_unlink(hid_t fapl) * before the H5Fmount() and thus refers to the mount point itself rather * than the group mounted there. */ - if(H5Oget_info_by_name3(file1, "/mnt_unlink/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(mnt, "/mnt_unlink/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(root, "/mnt_unlink/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(root, "file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - status = H5Oget_info_by_name3(mnt, "file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Incorrect traversal from mount point!"); - TEST_ERROR + if (H5Oget_info_by_name3(file1, "/mnt_unlink/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(mnt, "/mnt_unlink/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(root, "/mnt_unlink/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(root, "file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + status = H5Oget_info_by_name3(mnt, "file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Incorrect traversal from mount point!"); + TEST_ERROR } /* end if */ /* Unlink the mount point */ - if(H5Ldelete(file1, "/mnt_unlink", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file1, "/mnt_unlink", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* * We should still be able to get to "/file2" of file2 by starting at * `root' which is still open, but not by name. */ - if(H5Oget_info_by_name3(root, "file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - status = H5Oget_info_by_name3(mnt, "file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Traversal through mount point should not have worked!"); - TEST_ERROR + if (H5Oget_info_by_name3(root, "file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + status = H5Oget_info_by_name3(mnt, "file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Traversal through mount point should not have worked!"); + TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { - status = H5Oget_info_by_name3(file2, "/mnt_unlink/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Traversal through mount point should not have worked!"); - TEST_ERROR + H5E_BEGIN_TRY + { + status = H5Oget_info_by_name3(file2, "/mnt_unlink/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Traversal through mount point should not have worked!"); + TEST_ERROR } /* end if */ /* @@ -901,44 +1029,54 @@ test_unlink(hid_t fapl) * the mount point because the name doesn't exist anymore. We must * supply the mount point directly. */ - H5E_BEGIN_TRY { - status = H5Funmount(file1, "/mnt_unlink"); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDprintf(" %d: Unmount by name should not have been allowed!\n",__LINE__); - TEST_ERROR + H5E_BEGIN_TRY + { + status = H5Funmount(file1, "/mnt_unlink"); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDprintf(" %d: Unmount by name should not have been allowed!\n", __LINE__); + TEST_ERROR } /* end if */ - H5E_BEGIN_TRY { - status = H5Funmount(file2, "/"); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDprintf(" %d: Unmount by name should not have been allowed!\n",__LINE__); - TEST_ERROR + H5E_BEGIN_TRY + { + status = H5Funmount(file2, "/"); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDprintf(" %d: Unmount by name should not have been allowed!\n", __LINE__); + TEST_ERROR } /* end if */ - if(H5Funmount(mnt, ".") < 0) FAIL_STACK_ERROR + if (H5Funmount(mnt, ".") < 0) + FAIL_STACK_ERROR /* Close files */ - if(H5Gclose(mnt) < 0) FAIL_STACK_ERROR - if(H5Gclose(root) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Gclose(mnt) < 0) + FAIL_STACK_ERROR + if (H5Gclose(root) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(mnt); - H5Gclose(root); - H5Fclose(file2); - H5Fclose(file1); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(mnt); + H5Gclose(root); + H5Fclose(file2); + H5Fclose(file1); + } + H5E_END_TRY; return 1; } /* end test_unlink() */ - /*------------------------------------------------------------------------- * Function: test_mvmpt * @@ -958,43 +1096,50 @@ error: static int test_mvmpt(hid_t fapl) { - hid_t file1 = -1, file2 = -1; - H5O_info2_t oinfo; - char filename1[1024], filename2[1024]; + hid_t file1 = -1, file2 = -1; + H5O_info2_t oinfo; + char filename1[1024], filename2[1024]; TESTING("mount point renaming"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Build the virtual file */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt_move_a", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt_move_a", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Rename the mount point */ - if(H5Lmove(file1, "/mnt_move_a", H5L_SAME_LOC, "/mnt_move_b", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(file1, "/mnt_move_a", H5L_SAME_LOC, "/mnt_move_b", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Access something under the new name */ - if(H5Oget_info_by_name3(file1, "/mnt_move_b/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file1, "/mnt_move_b/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Shut down */ - if(H5Funmount(file1, "/mnt_move_b") < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt_move_b") < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Fclose(file1); - H5Fclose(file2); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Fclose(file1); + H5Fclose(file2); + } + H5E_END_TRY; return 1; } /* end test_mvmpt() */ - /*------------------------------------------------------------------------- * Function: test_interlink * @@ -1014,42 +1159,47 @@ error: static int test_interlink(hid_t fapl) { - hid_t file1 = -1, file2 = -1; + hid_t file1 = -1, file2 = -1; #ifdef NOT_NOW - hid_t type = -1, space = -1, dset = -1; - hsize_t cur_dims[1] = {2}; + hid_t type = -1, space = -1, dset = -1; + hsize_t cur_dims[1] = {2}; #endif /* NOT_NOW */ - char filename1[1024], filename2[1024]; - herr_t status; + char filename1[1024], filename2[1024]; + herr_t status; TESTING("interfile hard links"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Build the virtual file */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Try an interfile hard link directly */ - H5E_BEGIN_TRY { - status = H5Lcreate_hard(file1, "/mnt1/file2", H5L_SAME_LOC, "/file2", H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Interfile hard link should not have been allowed!"); - TEST_ERROR + H5E_BEGIN_TRY + { + status = H5Lcreate_hard(file1, "/mnt1/file2", H5L_SAME_LOC, "/file2", H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Interfile hard link should not have been allowed!"); + TEST_ERROR } /* end if */ /* Try an interfile hard link by renaming something */ - H5E_BEGIN_TRY { - status = H5Lmove(file1, "/mnt1/file2", H5L_SAME_LOC, "/file2", H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) { - H5_FAILED(); - HDputs(" Interfile renaming should not have been allowed!"); - TEST_ERROR + H5E_BEGIN_TRY + { + status = H5Lmove(file1, "/mnt1/file2", H5L_SAME_LOC, "/file2", H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) { + H5_FAILED(); + HDputs(" Interfile renaming should not have been allowed!"); + TEST_ERROR } /* end if */ /* Commented this code out until Jira issue #7638 is resolved. Once that @@ -1058,48 +1208,59 @@ test_interlink(hid_t fapl) */ #ifdef NOT_NOW /* Try an interfile hard link by sharing a data type */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR - if(H5Tcommit2(file1, "/type1", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_dims, NULL)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - dset = H5Dcreate2(file1, "/mnt1/file2/dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(dset >= 0) { - H5_FAILED(); - HDputs(" Dataset and shared type must be in the same file!"); - TEST_ERROR + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR + if (H5Tcommit2(file1, "/type1", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if ((space = H5Screate_simple(1, cur_dims, NULL)) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + dset = H5Dcreate2(file1, "/mnt1/file2/dset", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY; + if (dset >= 0) { + H5_FAILED(); + HDputs(" Dataset and shared type must be in the same file!"); + TEST_ERROR } /* end if */ /* Close IDs */ - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Tclose(type) < 0) FAIL_STACK_ERROR -#else /* NOT_NOW */ + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR +#else /* NOT_NOW */ SKIPPED(); HDputs(" Test skipped due file pointer sharing issue (Jira 7638)."); #endif /* NOT_NOW */ /* Shut down */ - if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { #ifdef NOT_NOW - H5Dclose(dset); - H5Sclose(space); - H5Tclose(type); + H5Dclose(dset); + H5Sclose(space); + H5Tclose(type); #endif /* NOT_NOW */ - H5Fclose(file1); - H5Fclose(file2); - } H5E_END_TRY; + H5Fclose(file1); + H5Fclose(file2); + } + H5E_END_TRY; return 1; } /* end test_interlink() */ - /*------------------------------------------------------------------------- * Function: test_uniformity * @@ -1120,51 +1281,66 @@ error: static int test_uniformity(hid_t fapl) { - hid_t file1 = -1, file2 = -1; + hid_t file1 = -1, file2 = -1; H5O_info2_t oinfo; - char filename1[1024], filename2[1024]; + char filename1[1024], filename2[1024]; TESTING("file handle uniformity"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Build the virtual file */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Access some things from the file1 handle */ - if(H5Oget_info_by_name3(file1, "/", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file1, "/mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file1, "mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file1, "/mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file1, "mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file1, "/", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file1, "/mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file1, "mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file1, "/mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file1, "mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Access the same things from the file2 handle */ - if(H5Oget_info_by_name3(file2, "/", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file2, "/mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file2, "mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file2, "/mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file2, "mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file2, "/", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file2, "/mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file2, "mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file2, "/mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file2, "mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Shut down */ - if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Fclose(file1); - H5Fclose(file2); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Fclose(file1); + H5Fclose(file2); + } + H5E_END_TRY; return 1; } /* end test_uniformity() */ - /*------------------------------------------------------------------------- * Function: test_close * @@ -1184,66 +1360,76 @@ error: static int test_close(hid_t fapl) { - hid_t file1 = -1, file2 = -1; + hid_t file1 = -1, file2 = -1; H5O_info2_t oinfo; - char filename1[1024], filename2[1024]; + char filename1[1024], filename2[1024]; TESTING("file handle close"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Build the virtual file */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* * Close file1 unmounting it from the virtual file. Objects in file1 are * still accessible through the file2 handle. */ - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file2, "/mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { - H5_FAILED(); - HDputs(" File1 contents are not accessible!"); - TEST_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file2, "/mnt1", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { + H5_FAILED(); + HDputs(" File1 contents are not accessible!"); + TEST_ERROR } /* end if */ - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); /* Build the virtual file again */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || - (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* * Close file2. It is not actually closed because it's a child of file1. */ - if(H5Fclose(file2) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file1, "/mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Fclose(file1) < 0) FAIL_STACK_ERROR + if (H5Fclose(file2) < 0) + FAIL_STACK_ERROR + if (H5Oget_info_by_name3(file1, "/mnt1/file2", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file1) < 0) + FAIL_STACK_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); /* Shut down */ PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Fclose(file1); - H5Fclose(file2); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Fclose(file1); + H5Fclose(file2); + } + H5E_END_TRY; return 1; } /* end test_close() */ - /*------------------------------------------------------------------------- * Function: test_mount_after_close * @@ -1264,25 +1450,25 @@ test_close(hid_t fapl) static int test_mount_after_close(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gidA = -1, gidAB = -1, gidABM = -1, gidX = -1, gidXY = -1; /* Group identifiers */ - hid_t gidABMX = -1, gidABC = -1, gidABT = -1; /* Group IDs for testing */ - hid_t didABMXYD = -1; /* Dataset ID for testing */ - hid_t did = -1, sid = -1; /* Dataset and dataspace identifiers */ - char filename1[1024], filename2[1024]; /* Name of files to mount */ - char objname[NAME_BUF_SIZE]; /* Name of object opened */ - hsize_t dims[] = {NX,NY}; /* Dataset dimensions */ - int i, j; /* Local index variable */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1, gidAB = -1, gidABM = -1, gidX = -1, gidXY = -1; /* Group identifiers */ + hid_t gidABMX = -1, gidABC = -1, gidABT = -1; /* Group IDs for testing */ + hid_t didABMXYD = -1; /* Dataset ID for testing */ + hid_t did = -1, sid = -1; /* Dataset and dataspace identifiers */ + char filename1[1024], filename2[1024]; /* Name of files to mount */ + char objname[NAME_BUF_SIZE]; /* Name of object opened */ + hsize_t dims[] = {NX, NY}; /* Dataset dimensions */ + int i, j; /* Local index variable */ TESTING("mounting on group after file is closed"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* - * Initialization of buffer matrix "bm" - */ - for(i =0; i < NX; i++) - for(j = 0; j < NY; j++) + * Initialization of buffer matrix "bm" + */ + for (i = 0; i < NX; i++) + for (j = 0; j < NY; j++) bm[i][j] = i + j; /* Create first file and a groups in it. */ @@ -1293,146 +1479,192 @@ test_mount_after_close(hid_t fapl) /A/B/M Group /A/B/T -> /A */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gidAB = H5Gcreate2(gidA, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((gidAB = H5Gcreate2(gidA, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Mount point */ - if((gidABM = H5Gcreate2(gidAB, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gidABM = H5Gcreate2(gidAB, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Soft link */ - if(H5Lcreate_soft("./M/X/Y", gidAB, "C", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("./M/X/Y", gidAB, "C", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Soft link */ - if(H5Lcreate_soft("/A", gidAB, "T", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/A", gidAB, "T", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close groups and file */ - if(H5Gclose(gidABM) < 0) FAIL_STACK_ERROR - if(H5Gclose(gidAB) < 0) FAIL_STACK_ERROR - if(H5Gclose(gidA) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR - - /* Create second file and dataset "D" in it. */ - /* h5ls shows: */ - /* /X Group - /X/T -> ./Y - /X/Y Group - /X/Y/D Dataset {4, 5} - */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if (H5Gclose(gidABM) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gidAB) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gidA) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid1) < 0) + FAIL_STACK_ERROR + + /* Create second file and dataset "D" in it. */ + /* h5ls shows: */ + /* /X Group + /X/T -> ./Y + /X/Y Group + /X/Y/D Dataset {4, 5} + */ + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR dims[0] = NX; dims[1] = NY; - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) FAIL_STACK_ERROR + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + FAIL_STACK_ERROR - if((gidX = H5Gcreate2(fid2, "/X", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((gidXY = H5Gcreate2(gidX, "Y", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did = H5Dcreate2(gidXY, "D", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gidX = H5Gcreate2(fid2, "/X", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((gidXY = H5Gcreate2(gidX, "Y", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((did = H5Dcreate2(gidXY, "D", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Soft link */ - if(H5Lcreate_soft("./Y", gidX, "T", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("./Y", gidX, "T", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Write data to the dataset. */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm) < 0) FAIL_STACK_ERROR + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm) < 0) + FAIL_STACK_ERROR /* Close all identifiers. */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Gclose(gidXY) < 0) FAIL_STACK_ERROR - if(H5Gclose(gidX) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gidXY) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gidX) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid2) < 0) + FAIL_STACK_ERROR -/* Beginning of the actual test code */ + /* Beginning of the actual test code */ - /* - * Reopen both files - */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR - /* - * Open /A/B to use as a mount point - */ - if((gidAB = H5Gopen2(fid1, "/A/B", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + /* + * Reopen both files + */ + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR + /* + * Open /A/B to use as a mount point + */ + if ((gidAB = H5Gopen2(fid1, "/A/B", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - /* - * Close the parent file. This keeps the file open because of the other handle on the group within - */ + /* + * Close the parent file. This keeps the file open because of the other handle on the group within + */ /* We close the file (it should stay open from the group) */ - if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid1) < 0) + FAIL_STACK_ERROR - /* - * Mount second file under G in the first file. - */ - if(H5Fmount(gidAB, "M", fid2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + /* + * Mount second file under G in the first file. + */ + if (H5Fmount(gidAB, "M", fid2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open "normal" group in mounted file */ /* (This shows we successfully mounted) */ - if((gidABMX = H5Gopen2(gidAB, "M/X", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gidABMX = H5Gopen2(gidAB, "M/X", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ *objname = '\0'; - if(H5Iget_name(gidABMX, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR - if(HDstrcmp(objname, "/A/B/M/X")) TEST_ERROR + if (H5Iget_name(gidABMX, objname, (size_t)NAME_BUF_SIZE) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(objname, "/A/B/M/X")) + TEST_ERROR /* Close object in mounted file */ - if(H5Gclose(gidABMX) < 0) FAIL_STACK_ERROR + if (H5Gclose(gidABMX) < 0) + FAIL_STACK_ERROR /* Open group in mounted file through softlink */ - if((gidABC = H5Gopen2(gidAB, "C", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gidABC = H5Gopen2(gidAB, "C", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ *objname = '\0'; - if(H5Iget_name(gidABC, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR - if(HDstrcmp(objname, "/A/B/C")) TEST_ERROR + if (H5Iget_name(gidABC, objname, (size_t)NAME_BUF_SIZE) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(objname, "/A/B/C")) + TEST_ERROR /* Close object in mounted file */ - if(H5Gclose(gidABC) < 0) FAIL_STACK_ERROR + if (H5Gclose(gidABC) < 0) + FAIL_STACK_ERROR /* Open group in original file through softlink */ - if((gidABT = H5Gopen2(gidAB, "T", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gidABT = H5Gopen2(gidAB, "T", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ *objname = '\0'; - if(H5Iget_name(gidABT, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR - if(HDstrcmp(objname, "/A/B/T")) TEST_ERROR + if (H5Iget_name(gidABT, objname, (size_t)NAME_BUF_SIZE) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(objname, "/A/B/T")) + TEST_ERROR /* Close object in original file */ - if(H5Gclose(gidABT) < 0) FAIL_STACK_ERROR + if (H5Gclose(gidABT) < 0) + FAIL_STACK_ERROR /* Open "normal" dataset in mounted file */ - if((didABMXYD = H5Dopen2(gidAB, "M/X/Y/D", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((didABMXYD = H5Dopen2(gidAB, "M/X/Y/D", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check name */ *objname = '\0'; - if(H5Iget_name(didABMXYD, objname, (size_t)NAME_BUF_SIZE) < 0) FAIL_STACK_ERROR - if(HDstrcmp(objname, "/A/B/M/X/Y/D")) TEST_ERROR + if (H5Iget_name(didABMXYD, objname, (size_t)NAME_BUF_SIZE) < 0) + FAIL_STACK_ERROR + if (HDstrcmp(objname, "/A/B/M/X/Y/D")) + TEST_ERROR /* Close object in mounted file */ - if(H5Dclose(didABMXYD) < 0) FAIL_STACK_ERROR + if (H5Dclose(didABMXYD) < 0) + FAIL_STACK_ERROR - if(H5Gclose(gidAB) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR + if (H5Gclose(gidAB) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid2) < 0) + FAIL_STACK_ERROR /* Shut down */ PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Sclose(sid); - H5Dclose(did); - H5Gclose(didABMXYD); - H5Gclose(gidABT); - H5Gclose(gidABC); - H5Gclose(gidABMX); - H5Gclose(gidXY); - H5Gclose(gidX); - H5Gclose(gidABM); - H5Gclose(gidAB); - H5Gclose(gidA); - H5Fclose(fid1); + H5E_BEGIN_TRY + { + H5Sclose(sid); + H5Dclose(did); + H5Gclose(didABMXYD); + H5Gclose(gidABT); + H5Gclose(gidABC); + H5Gclose(gidABMX); + H5Gclose(gidXY); + H5Gclose(gidX); + H5Gclose(gidABM); + H5Gclose(gidAB); + H5Gclose(gidA); + H5Fclose(fid1); H5Fclose(fid2); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_mount_after_close() */ - /*------------------------------------------------------------------------- * Function: test_mount_after_unmount * @@ -1453,21 +1685,18 @@ error: static int test_mount_after_unmount(hid_t fapl) { - hid_t fid1=-1, fid2=-1, fid3=-1, fid4=-1; /* File IDs */ - hid_t gidA=-1, gidB=-1, gidX=-1, gidY=-1, gidZ=-1; /* Group identifiers */ - hid_t gidBM=-1; /* Group identifiers */ - hid_t gidBMZ=-1; /* Group identifiers */ - hid_t gidAM=-1; /* Group identifiers */ - hid_t gidAMX=-1; /* Group identifiers */ - hid_t gidAMXX=-1; /* Group identifiers */ - hid_t gidAMXMY=-1; /* Group identifiers */ - hid_t gidXM=-1; /* Group identifiers */ - hid_t gidXX=-1; /* Group identifiers */ - char filename1[1024], - filename2[1024], - filename3[1024], - filename4[1024]; /* Name of files to mount */ - char objname[NAME_BUF_SIZE]; /* Name of object opened */ + hid_t fid1 = -1, fid2 = -1, fid3 = -1, fid4 = -1; /* File IDs */ + hid_t gidA = -1, gidB = -1, gidX = -1, gidY = -1, gidZ = -1; /* Group identifiers */ + hid_t gidBM = -1; /* Group identifiers */ + hid_t gidBMZ = -1; /* Group identifiers */ + hid_t gidAM = -1; /* Group identifiers */ + hid_t gidAMX = -1; /* Group identifiers */ + hid_t gidAMXX = -1; /* Group identifiers */ + hid_t gidAMXMY = -1; /* Group identifiers */ + hid_t gidXM = -1; /* Group identifiers */ + hid_t gidXX = -1; /* Group identifiers */ + char filename1[1024], filename2[1024], filename3[1024], filename4[1024]; /* Name of files to mount */ + char objname[NAME_BUF_SIZE]; /* Name of object opened */ TESTING("mounting after file is unmounted"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); @@ -1476,205 +1705,204 @@ test_mount_after_unmount(hid_t fapl) h5_fixname(FILENAME[3], fapl, filename4, sizeof filename4); /* Create first file and some groups in it. */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidAM = H5Gcreate2(gidA, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidAM = H5Gcreate2(gidA, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if((gidB = H5Gcreate2(fid1, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidB = H5Gcreate2(fid1, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidBM = H5Gcreate2(gidB, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidBM = H5Gcreate2(gidB, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidBM) < 0) + if (H5Gclose(gidBM) < 0) TEST_ERROR - if(H5Gclose(gidB) < 0) + if (H5Gclose(gidB) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create second file and a group in it. */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Create second file and a group in it. */ + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gidX = H5Gcreate2(fid2, "/X", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidX = H5Gcreate2(fid2, "/X", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidXM = H5Gcreate2(gidX, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidXM = H5Gcreate2(gidX, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidXM) < 0) + if (H5Gclose(gidXM) < 0) TEST_ERROR - if((gidXX = H5Gcreate2(gidX, "X", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidXX = H5Gcreate2(gidX, "X", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidXX) < 0) + if (H5Gclose(gidXX) < 0) TEST_ERROR - if(H5Gclose(gidX) < 0) + if (H5Gclose(gidX) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Create third file and a group in it. */ - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Create third file and a group in it. */ + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gidY = H5Gcreate2(fid3, "/Y", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidY = H5Gcreate2(fid3, "/Y", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidY) < 0) + if (H5Gclose(gidY) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR - /* Create fourth file and a group in it. */ - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Create fourth file and a group in it. */ + if ((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((gidZ = H5Gcreate2(fid4, "/Z", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidZ = H5Gcreate2(fid4, "/Z", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidZ) < 0) + if (H5Gclose(gidZ) < 0) TEST_ERROR - if(H5Fclose(fid4) < 0) + if (H5Fclose(fid4) < 0) TEST_ERROR + /* Beginning of the actual test code */ -/* Beginning of the actual test code */ - - /* - * Reopen all three files - */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + /* + * Reopen all three files + */ + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((fid3 = H5Fopen(filename3, H5F_ACC_RDWR, fapl)) < 0) + if ((fid3 = H5Fopen(filename3, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) + if ((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - /* - * Open /A & /B to use as a mount points - */ - if((gidA = H5Gopen2(fid1, "/A", H5P_DEFAULT)) < 0) + /* + * Open /A & /B to use as a mount points + */ + if ((gidA = H5Gopen2(fid1, "/A", H5P_DEFAULT)) < 0) TEST_ERROR - if((gidB = H5Gopen2(fid1, "/B", H5P_DEFAULT)) < 0) + if ((gidB = H5Gopen2(fid1, "/B", H5P_DEFAULT)) < 0) TEST_ERROR - /* - * Mount second file on /A/M in the first file. - */ - if(H5Fmount(gidA, "M", fid2, H5P_DEFAULT) < 0) + /* + * Mount second file on /A/M in the first file. + */ + if (H5Fmount(gidA, "M", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file */ /* (This shows we successfully mounted) */ - if((gidAMXX = H5Gopen2(gidA, "M/X/X", H5P_DEFAULT)) < 0) + if ((gidAMXX = H5Gopen2(gidA, "M/X/X", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *objname = '\0'; - if(H5Iget_name( gidAMXX, objname, (size_t)NAME_BUF_SIZE ) < 0) + if (H5Iget_name(gidAMXX, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/A/M/X/X")) + if (HDstrcmp(objname, "/A/M/X/X")) TEST_ERROR /* Open group in mounted file #2 */ - if((gidAMX = H5Gopen2(gidA, "M/X", H5P_DEFAULT)) < 0) + if ((gidAMX = H5Gopen2(gidA, "M/X", H5P_DEFAULT)) < 0) TEST_ERROR /* Mount third file */ - if(H5Fmount(gidAMX, "M", fid3, H5P_DEFAULT) < 0) + if (H5Fmount(gidAMX, "M", fid3, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file #3 */ /* (This shows we successfully mounted) */ - if((gidAMXMY = H5Gopen2(gidAMX, "M/Y", H5P_DEFAULT)) < 0) + if ((gidAMXMY = H5Gopen2(gidAMX, "M/Y", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *objname = '\0'; - if(H5Iget_name( gidAMXMY, objname, (size_t)NAME_BUF_SIZE ) < 0) + if (H5Iget_name(gidAMXMY, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/A/M/X/M/Y")) + if (HDstrcmp(objname, "/A/M/X/M/Y")) TEST_ERROR /* Unmount second file */ - if(H5Funmount(fid1, "/A/M") < 0) - TEST_ERROR + if (H5Funmount(fid1, "/A/M") < 0) + TEST_ERROR /* Check name */ *objname = '\0'; - if(H5Iget_name( gidAMXMY, objname, (size_t)NAME_BUF_SIZE ) < 0) + if (H5Iget_name(gidAMXMY, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/X/M/Y")) + if (HDstrcmp(objname, "/X/M/Y")) TEST_ERROR /* Rename object in file #3 that is "disconnected" from name hiearchy */ /* (It is "disconnected" because it's parent file has been unmounted) */ - if(H5Lmove(gidAMX,"M/Y",gidAMX,"M/Z", H5P_DEFAULT, H5P_DEFAULT) < 0) - TEST_ERROR + if (H5Lmove(gidAMX, "M/Y", gidAMX, "M/Z", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close group in file #3 */ - if(H5Gclose(gidAMXMY) < 0) - TEST_ERROR + if (H5Gclose(gidAMXMY) < 0) + TEST_ERROR /* Re-open group in file #3 */ - if((gidAMXMY = H5Gopen2(gidAMX, "M/Z", H5P_DEFAULT)) < 0) + if ((gidAMXMY = H5Gopen2(gidAMX, "M/Z", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name again */ *objname = '\0'; - if(H5Iget_name( gidAMXMY, objname, (size_t)NAME_BUF_SIZE ) < 0) - TEST_ERROR - if(HDstrcmp(objname, "/X/M/Z")) - TEST_ERROR + if (H5Iget_name(gidAMXMY, objname, (size_t)NAME_BUF_SIZE) < 0) + TEST_ERROR + if (HDstrcmp(objname, "/X/M/Z")) + TEST_ERROR /* Mount fourth file */ - if(H5Fmount(gidB, "M", fid4, H5P_DEFAULT) < 0) + if (H5Fmount(gidB, "M", fid4, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file */ /* (This shows we successfully mounted) */ - if((gidBMZ = H5Gopen2(gidB, "M/Z", H5P_DEFAULT)) < 0) + if ((gidBMZ = H5Gopen2(gidB, "M/Z", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *objname = '\0'; - if(H5Iget_name( gidBMZ, objname, (size_t)NAME_BUF_SIZE ) < 0) + if (H5Iget_name(gidBMZ, objname, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(objname, "/B/M/Z")) + if (HDstrcmp(objname, "/B/M/Z")) TEST_ERROR /* Unmount third file */ if (H5Funmount(fid2, "/X/M") < 0) - TEST_ERROR + TEST_ERROR /* Unmount fourth file */ if (H5Funmount(fid1, "/B/M") < 0) - TEST_ERROR + TEST_ERROR /* Close objects in mounted files */ - if(H5Gclose(gidBMZ) < 0) - TEST_ERROR - if(H5Gclose(gidAMXMY) < 0) - TEST_ERROR - if(H5Gclose(gidAMXX) < 0) - TEST_ERROR - if(H5Gclose(gidAMX) < 0) - TEST_ERROR + if (H5Gclose(gidBMZ) < 0) + TEST_ERROR + if (H5Gclose(gidAMXMY) < 0) + TEST_ERROR + if (H5Gclose(gidAMXX) < 0) + TEST_ERROR + if (H5Gclose(gidAMX) < 0) + TEST_ERROR /* Close objects in original file */ - if(H5Gclose(gidB) < 0) - TEST_ERROR - if(H5Gclose(gidA) < 0) - TEST_ERROR + if (H5Gclose(gidB) < 0) + TEST_ERROR + if (H5Gclose(gidA) < 0) + TEST_ERROR /* Close files */ - if(H5Fclose(fid4) < 0) + if (H5Fclose(fid4) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR /* Shut down */ @@ -1682,29 +1910,30 @@ test_mount_after_unmount(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidZ); - H5Gclose(gidY); - H5Gclose(gidXX); - H5Gclose(gidXM); - H5Gclose(gidX); - H5Gclose(gidBMZ); - H5Gclose(gidBM); - H5Gclose(gidB); - H5Gclose(gidAMXMY); - H5Gclose(gidAMXX); - H5Gclose(gidAMX); - H5Gclose(gidAM); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidZ); + H5Gclose(gidY); + H5Gclose(gidXX); + H5Gclose(gidXM); + H5Gclose(gidX); + H5Gclose(gidBMZ); + H5Gclose(gidBM); + H5Gclose(gidB); + H5Gclose(gidAMXMY); + H5Gclose(gidAMXX); + H5Gclose(gidAMX); + H5Gclose(gidAM); + H5Gclose(gidA); H5Fclose(fid4); H5Fclose(fid3); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_missing_unmount * @@ -1725,12 +1954,10 @@ error: static int test_missing_unmount(hid_t fapl) { - hid_t fid1=-1, fid2=-1, fid3=-1; /* File IDs */ - hid_t gidA=-1, gidE=-1, gidM=-1; /* Group IDs */ - hid_t gidAE=-1, gidAEM=-1; /* Group IDs */ - char filename1[1024], - filename2[1024], - filename3[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ + hid_t gidA = -1, gidE = -1, gidM = -1; /* Group IDs */ + hid_t gidAE = -1, gidAEM = -1; /* Group IDs */ + char filename1[1024], filename2[1024], filename3[1024]; /* Name of files to mount */ TESTING("missing unmount"); @@ -1739,107 +1966,104 @@ test_missing_unmount(hid_t fapl) h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidE = H5Gcreate2(fid2, "E", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidE = H5Gcreate2(fid2, "E", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidE) < 0) + if (H5Gclose(gidE) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Create file #3 */ - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid3, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid3, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR - /* Re-open files and mount file #2 in file #1 and file #3 in file #2 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file */ - if((gidAE = H5Gopen2(fid2, "A/E", H5P_DEFAULT)) < 0) + if ((gidAE = H5Gopen2(fid2, "A/E", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - if((fid3 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(gidAE, ".", fid3, H5P_DEFAULT) < 0) + if (H5Fmount(gidAE, ".", fid3, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file */ - if((gidAEM = H5Gopen2(fid3, "A/E/M", H5P_DEFAULT)) < 0) + if ((gidAEM = H5Gopen2(fid3, "A/E/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #3 */ - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR /* (Still have all file #2 & #3 mounted and groups open in all three files) */ /* Unmount file #2 & #3 */ - if(H5Funmount(gidAE,".") < 0) + if (H5Funmount(gidAE, ".") < 0) TEST_ERROR /* Skip unmounting file #2 from file #1 */ /* Close groups in mounted file */ - if(H5Gclose(gidAEM) < 0) + if (H5Gclose(gidAEM) < 0) TEST_ERROR - if(H5Gclose(gidAE) < 0) + if (H5Gclose(gidAE) < 0) TEST_ERROR /* Close group in top file */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -1847,20 +2071,21 @@ test_missing_unmount(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidM); - H5Gclose(gidE); - H5Gclose(gidAEM); - H5Gclose(gidAE); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidM); + H5Gclose(gidE); + H5Gclose(gidAEM); + H5Gclose(gidAE); + H5Gclose(gidA); H5Fclose(fid3); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_missing_unmount() */ - /*------------------------------------------------------------------------- * Function: test_hold_open_file * @@ -1881,10 +2106,9 @@ error: static int test_hold_open_file(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ - char filename1[1024], - filename2[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ + char filename1[1024], filename2[1024]; /* Name of files to mount */ TESTING("hold open w/file"); @@ -1892,89 +2116,87 @@ test_hold_open_file(hid_t fapl) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Attempt to open group in mounted file */ /* (Should work because file is still mounted) */ - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Attempt to open group in mounted file */ /* (Should work because file is still mounted) */ - if((gidAM = H5Gopen2(gidA, "/A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(gidA, "/A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Unmount file #2 */ - if(H5Funmount(gidA, ".") < 0) + if (H5Funmount(gidA, ".") < 0) TEST_ERROR /* Close group in top file */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -1982,17 +2204,18 @@ test_hold_open_file(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidM); - H5Gclose(gidAM); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidM); + H5Gclose(gidAM); + H5Gclose(gidA); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_hold_open_file() */ - /*------------------------------------------------------------------------- * Function: test_hold_open_group * @@ -2013,10 +2236,9 @@ error: static int test_hold_open_group(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gid = -1, gidA = -1, gidM = -1, gidAM = -1, gidAM2 = -1; /* Group IDs */ - char filename1[1024], - filename2[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gid = -1, gidA = -1, gidM = -1, gidAM = -1, gidAM2 = -1; /* Group IDs */ + char filename1[1024], filename2[1024]; /* Name of files to mount */ TESTING("hold open w/group"); @@ -2024,113 +2246,111 @@ test_hold_open_group(hid_t fapl) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Close group in parent file */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR /* Keep fid1 & gidAM open, everything else closed */ /* Retry to opening group in mounted file */ /* (Should work because file is still mounted) */ - if((gidAM2 = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM2 = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM2) < 0) + if (H5Gclose(gidAM2) < 0) TEST_ERROR /* Close original group in mount file */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Attempt to open group in mounted file */ /* (Should work because file is still mounted) */ - if((gidAM2 = H5Gopen2(fid1, "/A/M", H5P_DEFAULT)) < 0) + if ((gidAM2 = H5Gopen2(fid1, "/A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR /* Get ID of file #2 */ - if((fid2 = H5Iget_file_id(gidAM2)) < 0) + if ((fid2 = H5Iget_file_id(gidAM2)) < 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM2) < 0) + if (H5Gclose(gidAM2) < 0) TEST_ERROR /* Attempt to open group in mounted file */ /* (Should work because file is still mounted) */ - if((gidAM2 = H5Gopen2(fid2, "/A/M", H5P_DEFAULT)) < 0) + if ((gidAM2 = H5Gopen2(fid2, "/A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Attempt to open group in parent file */ /* (Should work because files should be mounted together) */ - if((gid = H5Gopen2(gidAM2, "/", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(gidAM2, "/", H5P_DEFAULT)) < 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM2) < 0) + if (H5Gclose(gidAM2) < 0) TEST_ERROR /* Close group in parent file */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -2138,19 +2358,20 @@ test_hold_open_group(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidM); - H5Gclose(gidAM); - H5Gclose(gidAM2); - H5Gclose(gidA); - H5Gclose(gid); + H5E_BEGIN_TRY + { + H5Gclose(gidM); + H5Gclose(gidAM); + H5Gclose(gidAM2); + H5Gclose(gidA); + H5Gclose(gid); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_hold_open_group() */ - /*------------------------------------------------------------------------- * Function: test_fcdegree_same * @@ -2171,12 +2392,11 @@ error: static int test_fcdegree_same(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ - hid_t fapl_id = -1; /* FAPL IDs */ - herr_t ret; /* Generic return value */ - char filename1[1024], - filename2[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ + hid_t fapl_id = -1; /* FAPL IDs */ + herr_t ret; /* Generic return value */ + char filename1[1024], filename2[1024]; /* Name of files to mount */ TESTING("file close degrees must be same"); @@ -2184,98 +2404,98 @@ test_fcdegree_same(hid_t fapl) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR /* Create FAPL & set file close degree for file #2 to be different */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set file close mode to H5F_CLOSE_STRONG */ - if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG) < 0) + if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) TEST_ERROR /* Try mounting file with different file close degree (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fmount(gidA, ".", fid2, H5P_DEFAULT); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Set file close mode to H5F_CLOSE_WEAK */ - if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_WEAK) < 0) + if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_WEAK) < 0) TEST_ERROR /* Close file #2 & re-open with same file close degree as file #1 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) TEST_ERROR /* Try mounting files again (should work now) */ - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Verify opening group in mounted file */ - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Close group in parent file */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR /* Close file #2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR /* Close FAPL ID */ - if(H5Pclose(fapl_id) < 0) + if (H5Pclose(fapl_id) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -2283,18 +2503,19 @@ test_fcdegree_same(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_id); - H5Gclose(gidM); - H5Gclose(gidAM); - H5Gclose(gidA); + H5Gclose(gidM); + H5Gclose(gidAM); + H5Gclose(gidA); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_fcdegree_same() */ - /*------------------------------------------------------------------------- * Function: test_fcdegree_semi * @@ -2315,12 +2536,11 @@ error: static int test_fcdegree_semi(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ - hid_t fapl_id = -1; /* FAPL IDs */ - herr_t ret; /* Generic return value */ - char filename1[1024], - filename2[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ + hid_t fapl_id = -1; /* FAPL IDs */ + herr_t ret; /* Generic return value */ + char filename1[1024], filename2[1024]; /* Name of files to mount */ TESTING("'semi' file close degree"); @@ -2328,95 +2548,97 @@ test_fcdegree_semi(hid_t fapl) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Create FAPL & set file close degree to be "semi" */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set file close mode to H5F_CLOSE_SEMI */ - if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI) < 0) + if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI) < 0) TEST_ERROR /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl_id)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl_id)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) TEST_ERROR /* Mount files together */ - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Verify opening group in mounted file */ - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #1 (should succeed, since file #2 is open still) */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR /* Try closing file #2 (should fail, since there are still objects open) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fclose(fid2); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close group in parent file */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR /* Try closing file #2 (should still fail, since there are still objects open in child file) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fclose(fid2); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Close file #2 (should succeed now) */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Close FAPL ID */ - if(H5Pclose(fapl_id) < 0) + if (H5Pclose(fapl_id) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -2424,18 +2646,19 @@ test_fcdegree_semi(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_id); - H5Gclose(gidM); - H5Gclose(gidAM); - H5Gclose(gidA); + H5Gclose(gidM); + H5Gclose(gidAM); + H5Gclose(gidA); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_fcdegree_semi() */ - /*------------------------------------------------------------------------- * Function: test_fcdegree_strong * @@ -2456,13 +2679,12 @@ error: static int test_fcdegree_strong(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ - hid_t fapl_id = -1; /* FAPL IDs */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ + hid_t fapl_id = -1; /* FAPL IDs */ H5O_info2_t oinfo; - char filename1[1024], - filename2[1024]; /* Name of files to mount */ - herr_t ret; /* Generic return value */ + char filename1[1024], filename2[1024]; /* Name of files to mount */ + herr_t ret; /* Generic return value */ TESTING("'strong' file close degree"); @@ -2470,91 +2692,93 @@ test_fcdegree_strong(hid_t fapl) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Create FAPL & set file close degree to be "strong" */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR /* Set file close mode to H5F_CLOSE_STRONG */ - if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG) < 0) + if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG) < 0) TEST_ERROR /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl_id)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl_id)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) TEST_ERROR /* Mount files together */ - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file */ - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR /* Check that objects are still open */ - if(H5Oget_info3(gidA, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(gidA, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(gidAM, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(gidAM, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR /* Close file #2 (should close open objects also) */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Check that objects are closed */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oget_info3(gidA, &oinfo, H5O_INFO_BASIC); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oget_info3(gidAM, &oinfo, H5O_INFO_BASIC); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close FAPL ID */ - if(H5Pclose(fapl_id) < 0) + if (H5Pclose(fapl_id) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -2562,18 +2786,19 @@ test_fcdegree_strong(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_id); - H5Gclose(gidM); - H5Gclose(gidAM); - H5Gclose(gidA); + H5Gclose(gidM); + H5Gclose(gidAM); + H5Gclose(gidA); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_fcdegree_strong() */ - /*------------------------------------------------------------------------- * Function: test_acc_perm * @@ -2596,13 +2821,11 @@ error: static int test_acc_perm(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ - hid_t gidA = -1, gidB = -1, gidC = -1, gidM = -1, gidAM = -1, gidAMZ = -1; /* Group IDs */ - hid_t bad_id = -1; /* Bad ID from object create */ - char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ - char filename1[1024], - filename2[1024], - filename3[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ + hid_t gidA = -1, gidB = -1, gidC = -1, gidM = -1, gidAM = -1, gidAMZ = -1; /* Group IDs */ + hid_t bad_id = -1; /* Bad ID from object create */ + char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ + char filename1[1024], filename2[1024], filename3[1024]; /* Name of files to mount */ TESTING("access permissions"); @@ -2611,152 +2834,154 @@ test_acc_perm(hid_t fapl) h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR /* Get and verify file name */ - if(H5Fget_name(gidA, name, NAME_BUF_SIZE) < 0) + if (H5Fget_name(gidA, name, NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, filename1) != 0) + if (HDstrcmp(name, filename1) != 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR /* Get and verify file name */ - if(H5Fget_name(fid2, name, NAME_BUF_SIZE) < 0) + if (H5Fget_name(fid2, name, NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, filename2) != 0) + if (HDstrcmp(name, filename2) != 0) TEST_ERROR /* Mount files together */ - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Get and verify file name */ - if(H5Fget_name(fid2, name, NAME_BUF_SIZE) < 0) + if (H5Fget_name(fid2, name, NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, filename2) != 0) + if (HDstrcmp(name, filename2) != 0) TEST_ERROR /* Open group in mounted file */ - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Get and verify file name */ - if(H5Fget_name(gidAM, name, NAME_BUF_SIZE) < 0) + if (H5Fget_name(gidAM, name, NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, filename2) != 0) + if (HDstrcmp(name, filename2) != 0) TEST_ERROR /* Attempt to create objects in read only file (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { bad_id = H5Gcreate2(gidAM, "Z", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(bad_id >= 0) + } + H5E_END_TRY; + if (bad_id >= 0) TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { bad_id = H5Gcreate2(fid1, "/A/L", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(bad_id >= 0) + } + H5E_END_TRY; + if (bad_id >= 0) TEST_ERROR /* Attempt to create objects in read/write file (should succeed) */ - if((gidB = H5Gcreate2(fid2, "/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidB = H5Gcreate2(fid2, "/B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidB) < 0) + if (H5Gclose(gidB) < 0) TEST_ERROR /* (Note that this object should get created in the "hidden" group for "A" in parent file) */ - if((gidC = H5Gcreate2(gidA, "C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidC = H5Gcreate2(gidA, "C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidC) < 0) + if (H5Gclose(gidC) < 0) TEST_ERROR /* Create file #3 (it will have R/W permissions) */ - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount file #3 on file #2 */ - if(H5Fmount(gidAM, ".", fid3, H5P_DEFAULT) < 0) + if (H5Fmount(gidAM, ".", fid3, H5P_DEFAULT) < 0) TEST_ERROR /* Attempt to create objects in read/write file (should succeed) */ - if((gidAMZ = H5Gcreate2(fid1, "/A/M/Z", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidAMZ = H5Gcreate2(fid1, "/A/M/Z", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Get and verify file name */ - if(H5Fget_name(gidAMZ, name, NAME_BUF_SIZE) < 0) + if (H5Fget_name(gidAMZ, name, NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, filename3) != 0) + if (HDstrcmp(name, filename3) != 0) TEST_ERROR /* Close object in file #3 */ - if(H5Gclose(gidAMZ) < 0) + if (H5Gclose(gidAMZ) < 0) TEST_ERROR - /* Attempt to create objects in read only file again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { bad_id = H5Gcreate2(fid1, "/A/L", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(bad_id >= 0) + } + H5E_END_TRY; + if (bad_id >= 0) TEST_ERROR /* Close group in mounted file */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Close group in parent file */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR /* Close file #3 */ - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR /* Close file #2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -2764,21 +2989,22 @@ test_acc_perm(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidM); - H5Gclose(gidAMZ); - H5Gclose(gidAM); - H5Gclose(gidC); - H5Gclose(gidB); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidM); + H5Gclose(gidAMZ); + H5Gclose(gidAM); + H5Gclose(gidC); + H5Gclose(gidB); + H5Gclose(gidA); H5Fclose(fid3); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_acc_perm() */ - /*------------------------------------------------------------------------- * Function: test_mult_mount * @@ -2799,14 +3025,12 @@ error: static int test_mult_mount(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1, fid3 = -1, fid3_2 = -1; /* File IDs */ - hid_t gidA = -1, gidB = -1; /* Group IDs in file #1 */ - hid_t gidM = -1, gidN = -1, gidAM = -1; /* Group IDs in file #2 */ - hid_t gidS = -1, gidT = -1, gidU = -1, gidBS = -1, gidAMT = -1; /* Group IDs in file #3 */ - char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ - char filename1[1024], - filename2[1024], - filename3[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1, fid3 = -1, fid3_2 = -1; /* File IDs */ + hid_t gidA = -1, gidB = -1; /* Group IDs in file #1 */ + hid_t gidM = -1, gidN = -1, gidAM = -1; /* Group IDs in file #2 */ + hid_t gidS = -1, gidT = -1, gidU = -1, gidBS = -1, gidAMT = -1; /* Group IDs in file #3 */ + char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ + char filename1[1024], filename2[1024], filename3[1024]; /* Name of files to mount */ TESTING("multiple mounts"); @@ -2815,171 +3039,167 @@ test_mult_mount(hid_t fapl) h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if((gidB = H5Gcreate2(fid1, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidB = H5Gcreate2(fid1, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidB) < 0) + if (H5Gclose(gidB) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if((gidN = H5Gcreate2(fid2, "N", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidN = H5Gcreate2(fid2, "N", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidN) < 0) + if (H5Gclose(gidN) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Create file #3 */ - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidS = H5Gcreate2(fid3, "S", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidS = H5Gcreate2(fid3, "S", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidS) < 0) + if (H5Gclose(gidS) < 0) TEST_ERROR - if((gidT = H5Gcreate2(fid3, "T", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidT = H5Gcreate2(fid3, "T", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidT) < 0) + if (H5Gclose(gidT) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR - /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR - if((gidB = H5Gopen2(fid1, "B", H5P_DEFAULT)) < 0) + if ((gidB = H5Gopen2(fid1, "B", H5P_DEFAULT)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount files together */ - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file */ - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Open file #3 again */ - if((fid3 = H5Fopen(filename3, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fopen(filename3, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount file #3 on file #2 */ - if(H5Fmount(gidAM, ".", fid3, H5P_DEFAULT) < 0) + if (H5Fmount(gidAM, ".", fid3, H5P_DEFAULT) < 0) TEST_ERROR /* Re-open file #3 */ - if((fid3_2 = H5Freopen(fid3)) < 0) + if ((fid3_2 = H5Freopen(fid3)) < 0) TEST_ERROR /* Mount file #3 on file #1 also */ - if(H5Fmount(gidB, ".", fid3_2, H5P_DEFAULT) < 0) + if (H5Fmount(gidB, ".", fid3_2, H5P_DEFAULT) < 0) TEST_ERROR /* Open object in file #3 through file #2 mount path */ - if((gidAMT = H5Gopen2(fid1, "A/M/T", H5P_DEFAULT)) < 0) + if ((gidAMT = H5Gopen2(fid1, "A/M/T", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *name = '\0'; - if(H5Iget_name(gidAMT, name, (size_t)NAME_BUF_SIZE ) < 0) + if (H5Iget_name(gidAMT, name, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, "/A/M/T")) + if (HDstrcmp(name, "/A/M/T")) TEST_ERROR /* Create object in file #3 */ - if((gidU = H5Gcreate2(gidAMT, "U", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidU = H5Gcreate2(gidAMT, "U", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidU) < 0) + if (H5Gclose(gidU) < 0) TEST_ERROR /* Open object in file #3 through file #1 mount path */ - if((gidBS = H5Gopen2(fid1, "B/S", H5P_DEFAULT)) < 0) + if ((gidBS = H5Gopen2(fid1, "B/S", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *name = '\0'; - if(H5Iget_name(gidBS, name, (size_t)NAME_BUF_SIZE ) < 0) + if (H5Iget_name(gidBS, name, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, "/B/S")) + if (HDstrcmp(name, "/B/S")) TEST_ERROR /* Re-open object created in file #3 through file #1 mount path */ - if((gidU = H5Gopen2(gidBS, "/B/T/U", H5P_DEFAULT)) < 0) + if ((gidU = H5Gopen2(gidBS, "/B/T/U", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidU) < 0) + if (H5Gclose(gidU) < 0) TEST_ERROR /* Close groups in file #3 */ - if(H5Gclose(gidBS) < 0) + if (H5Gclose(gidBS) < 0) TEST_ERROR - if(H5Gclose(gidAMT) < 0) + if (H5Gclose(gidAMT) < 0) TEST_ERROR /* Close group in file #2 */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Close groups in file #1 */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Gclose(gidB) < 0) + if (H5Gclose(gidB) < 0) TEST_ERROR /* Close file #3 IDs */ - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR - if(H5Fclose(fid3_2) < 0) + if (H5Fclose(fid3_2) < 0) TEST_ERROR /* Close file #2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -2987,26 +3207,27 @@ test_mult_mount(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidU); - H5Gclose(gidAMT); - H5Gclose(gidT); - H5Gclose(gidBS); - H5Gclose(gidS); - H5Gclose(gidAM); - H5Gclose(gidN); - H5Gclose(gidM); - H5Gclose(gidB); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidU); + H5Gclose(gidAMT); + H5Gclose(gidT); + H5Gclose(gidBS); + H5Gclose(gidS); + H5Gclose(gidAM); + H5Gclose(gidN); + H5Gclose(gidM); + H5Gclose(gidB); + H5Gclose(gidA); H5Fclose(fid3_2); H5Fclose(fid3); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_mult_mount() */ - /*------------------------------------------------------------------------- * Function: test_nested_survive * @@ -3027,15 +3248,13 @@ error: static int test_nested_survive(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ - hid_t gidA = -1; /* Group IDs in file #1 */ - hid_t gidM = -1, gidAM = -1; /* Group IDs in file #2 */ - hid_t gidS = -1, gidMS = -1, gidAMS = -1; /* Group IDs in file #3 */ - char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ - ssize_t name_len; /* Filename length */ - char filename1[1024], - filename2[1024], - filename3[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ + hid_t gidA = -1; /* Group IDs in file #1 */ + hid_t gidM = -1, gidAM = -1; /* Group IDs in file #2 */ + hid_t gidS = -1, gidMS = -1, gidAMS = -1; /* Group IDs in file #3 */ + char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ + ssize_t name_len; /* Filename length */ + char filename1[1024], filename2[1024], filename3[1024]; /* Name of files to mount */ TESTING("nested mounts survive"); @@ -3044,163 +3263,161 @@ test_nested_survive(hid_t fapl) h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Create file #3 */ - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidS = H5Gcreate2(fid3, "S", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidS = H5Gcreate2(fid3, "S", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidS) < 0) + if (H5Gclose(gidS) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR - /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount files together */ - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file */ - if((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidAM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Open file #3 again */ - if((fid3 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount file #3 on file #2 */ - if(H5Fmount(gidAM, ".", fid3, H5P_DEFAULT) < 0) + if (H5Fmount(gidAM, ".", fid3, H5P_DEFAULT) < 0) TEST_ERROR /* Open object in file #3 through file #1 mount path */ - if((gidAMS = H5Gopen2(fid1, "A/M/S", H5P_DEFAULT)) < 0) + if ((gidAMS = H5Gopen2(fid1, "A/M/S", H5P_DEFAULT)) < 0) TEST_ERROR /* Close group in file #3 */ - if(H5Gclose(gidAMS) < 0) + if (H5Gclose(gidAMS) < 0) TEST_ERROR /* Check name */ *name = '\0'; - if((name_len = H5Iget_name(gidAM, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidAM, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/A/M")) + if (name_len == 0 || HDstrcmp(name, "/A/M")) TEST_ERROR /* Unmount file #2 from file #1 */ - if(H5Funmount(gidA, ".") < 0) + if (H5Funmount(gidA, ".") < 0) TEST_ERROR /* Check name */ *name = '\0'; - if((name_len = H5Iget_name(gidAM, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidAM, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len != 0 || HDstrcmp(name, "")) + if (name_len != 0 || HDstrcmp(name, "")) TEST_ERROR /* Open object in file #3 through file #1 mount path (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gidAMS = H5Gopen2(fid1, "A/M/S", H5P_DEFAULT); - } H5E_END_TRY; - if(gidAMS >= 0) + } + H5E_END_TRY; + if (gidAMS >= 0) TEST_ERROR /* Open object in file #3 through file #2 mount path */ - if((gidMS = H5Gopen2(fid2, "M/S", H5P_DEFAULT)) < 0) + if ((gidMS = H5Gopen2(fid2, "M/S", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *name = '\0'; - if(H5Iget_name(gidMS, name, (size_t)NAME_BUF_SIZE ) < 0) + if (H5Iget_name(gidMS, name, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, "/M/S")) + if (HDstrcmp(name, "/M/S")) TEST_ERROR /* Close group in file #3 */ - if(H5Gclose(gidMS) < 0) + if (H5Gclose(gidMS) < 0) TEST_ERROR /* Re-mount file #2 on file #1 */ - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Open object in file #3 through file #1 mount path again */ - if((gidAMS = H5Gopen2(fid1, "A/M/S", H5P_DEFAULT)) < 0) + if ((gidAMS = H5Gopen2(fid1, "A/M/S", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *name = '\0'; - if(H5Iget_name(gidAMS, name, (size_t)NAME_BUF_SIZE ) < 0) + if (H5Iget_name(gidAMS, name, (size_t)NAME_BUF_SIZE) < 0) TEST_ERROR - if(HDstrcmp(name, "/A/M/S")) + if (HDstrcmp(name, "/A/M/S")) TEST_ERROR /* Close group in file #3 */ - if(H5Gclose(gidAMS) < 0) + if (H5Gclose(gidAMS) < 0) TEST_ERROR /* Close group in file #2 */ - if(H5Gclose(gidAM) < 0) + if (H5Gclose(gidAM) < 0) TEST_ERROR /* Close groups in file #1 */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR /* Close file #3 IDs */ - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR /* Close file #2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -3208,21 +3425,22 @@ test_nested_survive(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidAMS); - H5Gclose(gidMS); - H5Gclose(gidS); - H5Gclose(gidAM); - H5Gclose(gidM); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidAMS); + H5Gclose(gidMS); + H5Gclose(gidS); + H5Gclose(gidAM); + H5Gclose(gidM); + H5Gclose(gidA); H5Fclose(fid3); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_nested_survive() */ - /*------------------------------------------------------------------------- * Function: test_close_parent * @@ -3243,13 +3461,12 @@ error: static int test_close_parent(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gidA = -1; /* Group IDs in file #1 */ - hid_t gidM = -1; /* Group IDs in file #2 */ - char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ - ssize_t name_len; /* Filename length */ - char filename1[1024], - filename2[1024]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1; /* Group IDs in file #1 */ + hid_t gidM = -1; /* Group IDs in file #2 */ + char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ + ssize_t name_len; /* Filename length */ + char filename1[1024], filename2[1024]; /* Name of files to mount */ TESTING("close parent"); @@ -3257,63 +3474,61 @@ test_close_parent(hid_t fapl) h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); /* Create file #1 */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Re-open files and mount file #2 in file #1 */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) + if ((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount files together */ - if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Open group in mounted file */ - if((gidM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) + if ((gidM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Close group in file #1 */ - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR /* Close files #1 & #2 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR /* Both underlying shared files should be open still */ @@ -3321,27 +3536,27 @@ test_close_parent(hid_t fapl) /* Check the name of "M" is still defined */ *name = '\0'; - if((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/A/M")) + if (name_len == 0 || HDstrcmp(name, "/A/M")) TEST_ERROR /* Unmount file #2 from file #1, closing file #1 */ - if(H5Funmount(gidM, "/A") < 0) + if (H5Funmount(gidM, "/A") < 0) TEST_ERROR /* Check the name of "M" is defined in its file */ *name = '\0'; - if((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/M")) + if (name_len == 0 || HDstrcmp(name, "/M")) TEST_ERROR /* Just file #2's underlying shared file should be open still */ H5F_sfile_assert_num(1); /* Close group in file #2, letting file #2 close */ - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR /* All underlying shared file structs should be closed */ @@ -3351,16 +3566,17 @@ test_close_parent(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidM); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidM); + H5Gclose(gidA); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_close_parent() */ - /*------------------------------------------------------------------------- * Function: test_cut_graph * @@ -3416,25 +3632,20 @@ error: static int test_cut_graph(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1, fid3 = -1, - fid4 = -1, fid5 = -1, fid6 = -1, fid7 = -1; /* File IDs */ - hid_t gidA = -1, gidB = -1; /* Group IDs in file #1 */ - hid_t gidD = -1, gidE = -1; /* Group IDs in file #2 */ - hid_t gidH = -1, gidI = -1; /* Group IDs in file #3 */ - hid_t gidK = -1; /* Group IDs in file #4 */ - hid_t gidM = -1; /* Group IDs in file #5 */ - hid_t gidO = -1; /* Group IDs in file #6 */ - hid_t gidQ = -1; /* Group IDs in file #7 */ - char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ - ssize_t name_len; /* Filename length */ - ssize_t obj_count; /* Number of objects open */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE], - filename5[NAME_BUF_SIZE], - filename6[NAME_BUF_SIZE], - filename7[NAME_BUF_SIZE]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1, fid3 = -1, fid4 = -1, fid5 = -1, fid6 = -1, fid7 = -1; /* File IDs */ + hid_t gidA = -1, gidB = -1; /* Group IDs in file #1 */ + hid_t gidD = -1, gidE = -1; /* Group IDs in file #2 */ + hid_t gidH = -1, gidI = -1; /* Group IDs in file #3 */ + hid_t gidK = -1; /* Group IDs in file #4 */ + hid_t gidM = -1; /* Group IDs in file #5 */ + hid_t gidO = -1; /* Group IDs in file #6 */ + hid_t gidQ = -1; /* Group IDs in file #7 */ + char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ + ssize_t name_len; /* Filename length */ + ssize_t obj_count; /* Number of objects open */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE], filename5[NAME_BUF_SIZE], filename6[NAME_BUF_SIZE], + filename7[NAME_BUF_SIZE]; /* Name of files to mount */ TESTING("cutting mount graph"); @@ -3447,292 +3658,290 @@ test_cut_graph(hid_t fapl) h5_fixname(FILENAME[6], fapl, filename7, sizeof filename3); /* Create file #1 & it's groups */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if((gidB = H5Gcreate2(fid1, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidB = H5Gcreate2(fid1, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidB) < 0) + if (H5Gclose(gidB) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 & it's groups */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidD = H5Gcreate2(fid2, "D", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidD = H5Gcreate2(fid2, "D", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidD) < 0) + if (H5Gclose(gidD) < 0) TEST_ERROR - if((gidE = H5Gcreate2(fid2, "E", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidE = H5Gcreate2(fid2, "E", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidE) < 0) + if (H5Gclose(gidE) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Create file #3 & it's groups */ - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidH = H5Gcreate2(fid3, "H", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidH = H5Gcreate2(fid3, "H", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidH) < 0) + if (H5Gclose(gidH) < 0) TEST_ERROR - if((gidI = H5Gcreate2(fid3, "I", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidI = H5Gcreate2(fid3, "I", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidI) < 0) + if (H5Gclose(gidI) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR /* Create file #4 & it's group */ - if((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid4 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidK = H5Gcreate2(fid4, "K", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidK = H5Gcreate2(fid4, "K", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidK) < 0) + if (H5Gclose(gidK) < 0) TEST_ERROR - if(H5Fclose(fid4) < 0) + if (H5Fclose(fid4) < 0) TEST_ERROR /* Create file #5 & it's group */ - if((fid5 = H5Fcreate(filename5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid5 = H5Fcreate(filename5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidM = H5Gcreate2(fid5, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidM = H5Gcreate2(fid5, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR - if(H5Fclose(fid5) < 0) + if (H5Fclose(fid5) < 0) TEST_ERROR /* Create file #6 & it's group */ - if((fid6 = H5Fcreate(filename6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid6 = H5Fcreate(filename6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidO = H5Gcreate2(fid6, "O", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidO = H5Gcreate2(fid6, "O", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidO) < 0) + if (H5Gclose(gidO) < 0) TEST_ERROR - if(H5Fclose(fid6) < 0) + if (H5Fclose(fid6) < 0) TEST_ERROR /* Create file #7 & it's group */ - if((fid7 = H5Fcreate(filename7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid7 = H5Fcreate(filename7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidQ = H5Gcreate2(fid7, "Q", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidQ = H5Gcreate2(fid7, "Q", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidQ) < 0) + if (H5Gclose(gidQ) < 0) TEST_ERROR - if(H5Fclose(fid7) < 0) + if (H5Fclose(fid7) < 0) TEST_ERROR - /* Re-open files and build mount hierarchy */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount file #2 at /A */ - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(fid1, "/A", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/A", fid2, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Mount file #3 at /B */ - if((fid3 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(fid1, "/B", fid3, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/B", fid3, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR /* Mount file #4 at /A/D */ - if((fid4 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid4 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(fid1, "/A/D", fid4, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/A/D", fid4, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid4) < 0) + if (H5Fclose(fid4) < 0) TEST_ERROR /* Mount file #5 at /A/E */ - if((fid5 = H5Fopen(filename5, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid5 = H5Fopen(filename5, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(fid1, "/A/E", fid5, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/A/E", fid5, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid5) < 0) + if (H5Fclose(fid5) < 0) TEST_ERROR /* Mount file #6 at /B/H */ - if((fid6 = H5Fopen(filename6, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid6 = H5Fopen(filename6, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(fid1, "/B/H", fid6, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/B/H", fid6, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid6) < 0) + if (H5Fclose(fid6) < 0) TEST_ERROR /* Mount file #7 at /B/H */ - if((fid7 = H5Fopen(filename7, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid7 = H5Fopen(filename7, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(fid1, "/B/I", fid7, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/B/I", fid7, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid7) < 0) + if (H5Fclose(fid7) < 0) TEST_ERROR /* Open object in file #5 */ - if((gidM = H5Gopen2(fid1, "A/E/M", H5P_DEFAULT)) < 0) + if ((gidM = H5Gopen2(fid1, "A/E/M", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *name = '\0'; - if((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/A/E/M")) + if (name_len == 0 || HDstrcmp(name, "/A/E/M")) TEST_ERROR /* Open object in file #7 */ - if((gidQ = H5Gopen2(fid1, "B/I/Q", H5P_DEFAULT)) < 0) + if ((gidQ = H5Gopen2(fid1, "B/I/Q", H5P_DEFAULT)) < 0) TEST_ERROR /* Check name */ *name = '\0'; - if((name_len = H5Iget_name(gidQ, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidQ, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/B/I/Q")) + if (name_len == 0 || HDstrcmp(name, "/B/I/Q")) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Get a new file ID for file #5 */ - if((fid5 = H5Iget_file_id(gidM)) < 0) + if ((fid5 = H5Iget_file_id(gidM)) < 0) TEST_ERROR /* Check the number of objects currently open */ - if((obj_count = H5Fget_obj_count(fid5, H5F_OBJ_ALL)) < 0) + if ((obj_count = H5Fget_obj_count(fid5, H5F_OBJ_ALL)) < 0) TEST_ERROR - if(obj_count != 2) /* one object and the file ID */ + if (obj_count != 2) /* one object and the file ID */ TEST_ERROR /* Close ID on file #5 */ - if(H5Fclose(fid5) < 0) + if (H5Fclose(fid5) < 0) TEST_ERROR - /* Get a new file ID for file #7 */ - if((fid7 = H5Iget_file_id(gidQ)) < 0) + if ((fid7 = H5Iget_file_id(gidQ)) < 0) TEST_ERROR /* Check the number of objects currently open */ - if((obj_count = H5Fget_obj_count(fid7, H5F_OBJ_ALL)) < 0) + if ((obj_count = H5Fget_obj_count(fid7, H5F_OBJ_ALL)) < 0) TEST_ERROR - if(obj_count != 2) /* one object and the file ID */ + if (obj_count != 2) /* one object and the file ID */ TEST_ERROR /* Close ID on file #7 */ - if(H5Fclose(fid7) < 0) + if (H5Fclose(fid7) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR - /* Unmount file #2 from file #1, cutting the graph */ - if(H5Funmount(gidM, "/A") < 0) + if (H5Funmount(gidM, "/A") < 0) TEST_ERROR /* Attempt to open an object in file #4, from file #1 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gidK = H5Gopen2(gidQ, "/A/D/K", H5P_DEFAULT); - } H5E_END_TRY; - if(gidK >= 0) + } + H5E_END_TRY; + if (gidK >= 0) TEST_ERROR /* Open object in file #4 from file #5 */ - if((gidK = H5Gopen2(gidM, "/D/K", H5P_DEFAULT)) < 0) + if ((gidK = H5Gopen2(gidM, "/D/K", H5P_DEFAULT)) < 0) TEST_ERROR /* Check the name of "K" is correct */ *name = '\0'; - if((name_len = H5Iget_name(gidK, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidK, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/D/K")) + if (name_len == 0 || HDstrcmp(name, "/D/K")) TEST_ERROR - if(H5Gclose(gidK) < 0) + if (H5Gclose(gidK) < 0) TEST_ERROR /* Attempt to open an object in file #6, from file #5 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gidO = H5Gopen2(gidM, "/B/H/O", H5P_DEFAULT); - } H5E_END_TRY; - if(gidO >= 0) + } + H5E_END_TRY; + if (gidO >= 0) TEST_ERROR /* Open object in file #6 from file #7 */ - if((gidO = H5Gopen2(gidQ, "/B/H/O", H5P_DEFAULT)) < 0) + if ((gidO = H5Gopen2(gidQ, "/B/H/O", H5P_DEFAULT)) < 0) TEST_ERROR /* Check the name of "O" is correct */ *name = '\0'; - if((name_len = H5Iget_name(gidO, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidO, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/B/H/O")) + if (name_len == 0 || HDstrcmp(name, "/B/H/O")) TEST_ERROR - if(H5Gclose(gidO) < 0) + if (H5Gclose(gidO) < 0) TEST_ERROR /* Check the name of "M" is defined in its file */ *name = '\0'; - if((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/E/M")) + if (name_len == 0 || HDstrcmp(name, "/E/M")) TEST_ERROR /* Check the name of "Q" is still defined */ *name = '\0'; - if((name_len = H5Iget_name(gidQ, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidQ, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/B/I/Q")) + if (name_len == 0 || HDstrcmp(name, "/B/I/Q")) TEST_ERROR /* Check that all seven underlying files are still opened */ H5F_sfile_assert_num(7); /* Close "M" in file #5, which should close files 2, 4 & 5 */ - if(H5Gclose(gidM) < 0) + if (H5Gclose(gidM) < 0) TEST_ERROR /* Check that only four underlying files are still opened */ H5F_sfile_assert_num(4); /* Unmount file #3 from file #1, cutting the graph */ - if(H5Funmount(gidQ, "/B") < 0) + if (H5Funmount(gidQ, "/B") < 0) TEST_ERROR /* Check that only three underlying files are still opened */ @@ -3741,27 +3950,27 @@ test_cut_graph(hid_t fapl) /* Check the name of "Q" is defined in its file */ *name = '\0'; - if((name_len = H5Iget_name(gidQ, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidQ, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/I/Q")) + if (name_len == 0 || HDstrcmp(name, "/I/Q")) TEST_ERROR /* Open object in file #6 from file #7 */ - if((gidO = H5Gopen2(gidQ, "/H/O", H5P_DEFAULT)) < 0) + if ((gidO = H5Gopen2(gidQ, "/H/O", H5P_DEFAULT)) < 0) TEST_ERROR /* Check the name of "O" is correct */ *name = '\0'; - if((name_len = H5Iget_name(gidO, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidO, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/H/O")) + if (name_len == 0 || HDstrcmp(name, "/H/O")) TEST_ERROR - if(H5Gclose(gidO) < 0) + if (H5Gclose(gidO) < 0) TEST_ERROR /* Close last object and let files 3, 6 & 7 close */ - if(H5Gclose(gidQ) < 0) + if (H5Gclose(gidQ) < 0) TEST_ERROR /* Verify that all underlying shared files have been closed now */ @@ -3771,29 +3980,30 @@ test_cut_graph(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidQ); - H5Gclose(gidO); - H5Gclose(gidM); - H5Gclose(gidK); - H5Gclose(gidI); - H5Gclose(gidH); - H5Gclose(gidE); - H5Gclose(gidD); - H5Gclose(gidB); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidQ); + H5Gclose(gidO); + H5Gclose(gidM); + H5Gclose(gidK); + H5Gclose(gidI); + H5Gclose(gidH); + H5Gclose(gidE); + H5Gclose(gidD); + H5Gclose(gidB); + H5Gclose(gidA); H5Fclose(fid7); H5Fclose(fid6); H5Fclose(fid5); H5Fclose(fid4); H5Fclose(fid3); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_cut_graph() */ - /*------------------------------------------------------------------------- * Function: test_symlink * @@ -3814,16 +4024,15 @@ error: static int test_symlink(hid_t fapl) { - hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ - hid_t gidA = -1, gidB = -1; /* Group IDs in file #1 */ - hid_t gidD = -1, gidE = -1; /* Group IDs in file #2 */ - hid_t gidH = -1, gidI = -1; /* Group IDs in file #3 */ - hid_t gidL = -1; /* Group IDs through soft link to file #3 */ - char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ - ssize_t name_len; /* Filename length */ - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; /* Name of files to mount */ + hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ + hid_t gidA = -1, gidB = -1; /* Group IDs in file #1 */ + hid_t gidD = -1, gidE = -1; /* Group IDs in file #2 */ + hid_t gidH = -1, gidI = -1; /* Group IDs in file #3 */ + hid_t gidL = -1; /* Group IDs through soft link to file #3 */ + char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ + ssize_t name_len; /* Filename length */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; /* Name of files to mount */ TESTING("symlinks"); @@ -3832,110 +4041,109 @@ test_symlink(hid_t fapl) h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); /* Create file #1 & it's groups */ - if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidA) < 0) + if (H5Gclose(gidA) < 0) TEST_ERROR - if((gidB = H5Gcreate2(fid1, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidB = H5Gcreate2(fid1, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidB) < 0) + if (H5Gclose(gidB) < 0) TEST_ERROR /* Create soft link to mounted object */ - if(H5Lcreate_soft("./A/D/H", fid1, "L", H5P_DEFAULT, H5P_DEFAULT) < 0) /* Soft link */ + if (H5Lcreate_soft("./A/D/H", fid1, "L", H5P_DEFAULT, H5P_DEFAULT) < 0) /* Soft link */ TEST_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR - /* Create file #2 & it's groups */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidD = H5Gcreate2(fid2, "D", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidD = H5Gcreate2(fid2, "D", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidD) < 0) + if (H5Gclose(gidD) < 0) TEST_ERROR - if((gidE = H5Gcreate2(fid2, "E", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidE = H5Gcreate2(fid2, "E", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidE) < 0) + if (H5Gclose(gidE) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - /* Create file #3 & it's groups */ - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gidH = H5Gcreate2(fid3, "H", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidH = H5Gcreate2(fid3, "H", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidH) < 0) + if (H5Gclose(gidH) < 0) TEST_ERROR - if((gidI = H5Gcreate2(fid3, "I", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gidI = H5Gcreate2(fid3, "I", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gidI) < 0) + if (H5Gclose(gidI) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR - /* Re-open files and build mount hierarchy */ - if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount file #2 at /A */ - if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(fid1, "/A", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/A", fid2, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR /* Attempt to open an object in file #3 (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gidL = H5Gopen2(fid1, "L", H5P_DEFAULT); - } H5E_END_TRY; - if(gidL >= 0) + } + H5E_END_TRY; + if (gidL >= 0) TEST_ERROR /* Mount file #3 at /A/D */ - if((fid3 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Fmount(fid1, "/A/D", fid3, H5P_DEFAULT) < 0) + if (H5Fmount(fid1, "/A/D", fid3, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR /* Open soft link to object in file #3 */ - if((gidL = H5Gopen2(fid1, "L", H5P_DEFAULT)) < 0) + if ((gidL = H5Gopen2(fid1, "L", H5P_DEFAULT)) < 0) TEST_ERROR /* Check the name of "L" is correct */ *name = '\0'; - if((name_len = H5Iget_name(gidL, name, (size_t)NAME_BUF_SIZE )) < 0) + if ((name_len = H5Iget_name(gidL, name, (size_t)NAME_BUF_SIZE)) < 0) TEST_ERROR - if(name_len == 0 || HDstrcmp(name, "/L")) + if (name_len == 0 || HDstrcmp(name, "/L")) TEST_ERROR /* Close file #1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) TEST_ERROR /* Verify that all 3 underlying shared files are still open */ H5F_sfile_assert_num(3); /* Close object opened through soft link */ - if(H5Gclose(gidL) < 0) + if (H5Gclose(gidL) < 0) TEST_ERROR /* Verify that all underlying shared files have been closed now */ @@ -3945,22 +4153,23 @@ test_symlink(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gidL); - H5Gclose(gidI); - H5Gclose(gidH); - H5Gclose(gidE); - H5Gclose(gidD); - H5Gclose(gidB); - H5Gclose(gidA); + H5E_BEGIN_TRY + { + H5Gclose(gidL); + H5Gclose(gidI); + H5Gclose(gidH); + H5Gclose(gidE); + H5Gclose(gidD); + H5Gclose(gidB); + H5Gclose(gidA); H5Fclose(fid3); H5Fclose(fid2); - H5Fclose(fid1); - } H5E_END_TRY; + H5Fclose(fid1); + } + H5E_END_TRY; return 1; } /* end test_symlink() */ - /*------------------------------------------------------------------------- * Function: test_sharedacc * @@ -3977,15 +4186,14 @@ error: * *------------------------------------------------------------------------- */ - static int +static int test_sharedacc(hid_t fapl) { hid_t fid1[2] = {-1, -1}, fid2[2] = {-1, -1}; /* File IDs */ hid_t gid = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; /* Name of files to mount */ - int i, j, k; /* Counters */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; /* Name of files to mount */ + int i, j, k; /* Counters */ TESTING("shared mount access"); @@ -3994,60 +4202,60 @@ test_sharedacc(hid_t fapl) h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); /* Create file #1 & its group */ - if((fid1[0] = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1[0] = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid1[0], "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid1[0], "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR /* Create file #2 & its group */ - if((fid2[0] = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2[0] = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid = H5Gcreate2(fid2[0], "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid2[0], "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR /* Test mount before reopen, then using reopened handle for access */ - if(H5Fmount(fid1[0], "/A", fid2[0], H5P_DEFAULT) < 0) + if (H5Fmount(fid1[0], "/A", fid2[0], H5P_DEFAULT) < 0) TEST_ERROR - if((fid1[1] = H5Freopen(fid1[0])) < 0) + if ((fid1[1] = H5Freopen(fid1[0])) < 0) TEST_ERROR - if((fid2[1] = H5Freopen(fid2[0])) < 0) + if ((fid2[1] = H5Freopen(fid2[0])) < 0) TEST_ERROR - if((gid = H5Gopen2(fid1[1], "/A/B", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid1[1], "/A/B", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR - if(H5Funmount(fid1[1], "/A") < 0) + if (H5Funmount(fid1[1], "/A") < 0) TEST_ERROR /* "Brute force" test of all possible ways of mounting, accessing, and * unmounting files with multiple handles (mount after reopen) */ - for(i=0; i<2; i++) - for(j=0; j<2; j++) - for(k=0; k<2; k++) { - if(H5Fmount(fid1[i], "/A", fid2[j], H5P_DEFAULT) < 0) + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + for (k = 0; k < 2; k++) { + if (H5Fmount(fid1[i], "/A", fid2[j], H5P_DEFAULT) < 0) TEST_ERROR - if((gid = H5Gopen2(fid1[k], "/A/B", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid1[k], "/A/B", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR - if(H5Funmount(fid1[k], "/A") < 0) + if (H5Funmount(fid1[k], "/A") < 0) TEST_ERROR } /* Close file IDs */ - for(i=0; i<2; i++) { - if(H5Fclose(fid1[i]) < 0) + for (i = 0; i < 2; i++) { + if (H5Fclose(fid1[i]) < 0) TEST_ERROR - if(H5Fclose(fid2[i]) < 0) + if (H5Fclose(fid2[i]) < 0) TEST_ERROR } /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -4055,17 +4263,18 @@ test_sharedacc(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gid); - for(i=0; i<2; i++) { - H5Fclose(fid1[i]); - H5Fclose(fid2[i]); + H5E_BEGIN_TRY + { + H5Gclose(gid); + for (i = 0; i < 2; i++) { + H5Fclose(fid1[i]); + H5Fclose(fid2[i]); + } } - } H5E_END_TRY; + H5E_END_TRY; return 1; } /* end test_sharedacc() */ - /*------------------------------------------------------------------------- * Function: test_sharedclose * @@ -4083,14 +4292,13 @@ error: * *------------------------------------------------------------------------- */ - static int +static int test_sharedclose(hid_t fapl) { hid_t fid1a = -1, fid1b = -1, fid2 = -1, fid3 = -2; /* File IDs */ hid_t gid1 = -1, gid2 = -1, gid3 = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE]; /* Name of files to mount */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], + filename3[NAME_BUF_SIZE]; /* Name of files to mount */ TESTING("closing shared mounts"); @@ -4099,112 +4307,112 @@ test_sharedclose(hid_t fapl) h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); /* Create file #1a & its group */ - if((fid1a = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1a = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid1 = H5Gcreate2(fid1a, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid1 = H5Gcreate2(fid1a, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create file #1b & its groups */ - if((fid1b = H5Freopen(fid1a)) < 0) + if ((fid1b = H5Freopen(fid1a)) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(fid1b, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(fid1b, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid3 = H5Gcreate2(fid1b, "B/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid3 = H5Gcreate2(fid1b, "B/C", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create file #3 */ - if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount file #2 to file #1a */ - if(H5Fmount(gid1, ".", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(gid1, ".", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Mount file #3 to file #1b */ - if(H5Fmount(gid2, ".", fid3, H5P_DEFAULT) < 0) + if (H5Fmount(gid2, ".", fid3, H5P_DEFAULT) < 0) TEST_ERROR /* Close file #1b. It should be held open by the groups in it. */ - if(H5Fclose(fid1b) < 0) + if (H5Fclose(fid1b) < 0) TEST_ERROR /* Close file #3. It should be held open by the groups in its parent. */ - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR /* Close group B in file #1b. This should not close file #1b and #3. */ - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR /* Check that file #3 is still open */ H5F_sfile_assert_num(3); /* Close group B/C in file #1b. This should close file #1b and #3. */ - if(H5Gclose(gid3) < 0) + if (H5Gclose(gid3) < 0) TEST_ERROR /* Check that file #3 has been closed */ H5F_sfile_assert_num(2); /* Unmount file 2 and close the rest of the handles */ - if(H5Funmount(fid1a, "A") < 0) + if (H5Funmount(fid1a, "A") < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid1a) < 0) + if (H5Fclose(fid1a) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); /* Create file #1 & its group */ - if((fid1a = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1a = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid1 = H5Gcreate2(fid1a, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid1 = H5Gcreate2(fid1a, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create file #1b & its group */ - if((fid1b = H5Freopen(fid1a)) < 0) + if ((fid1b = H5Freopen(fid1a)) < 0) TEST_ERROR - if((gid2 = H5Gcreate2(fid1b, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(fid1b, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create file #2 */ - if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Mount file #2 to file #1 */ - if(H5Fmount(fid1a, "A", fid2, H5P_DEFAULT) < 0) + if (H5Fmount(fid1a, "A", fid2, H5P_DEFAULT) < 0) TEST_ERROR /* Close file #1b. It should be held open by the group in it. */ - if(H5Fclose(fid1b) < 0) + if (H5Fclose(fid1b) < 0) TEST_ERROR /* Close the group in file #1b. This should close file # 1b. */ - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) TEST_ERROR /* Unmount file 2 and close the rest of the handles */ - if(H5Funmount(fid1a, "A") < 0) + if (H5Funmount(fid1a, "A") < 0) TEST_ERROR - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) TEST_ERROR - if(H5Fclose(fid1a) < 0) + if (H5Fclose(fid1a) < 0) TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) + if (H5I_nmembers(H5I_FILE) != 0) TEST_ERROR H5F_sfile_assert_num(0); @@ -4212,19 +4420,20 @@ test_sharedclose(hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gid1); - H5Gclose(gid2); - H5Gclose(gid3); - H5Fclose(fid1a); - H5Fclose(fid1b); - H5Fclose(fid2); - H5Fclose(fid3); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid1); + H5Gclose(gid2); + H5Gclose(gid3); + H5Fclose(fid1a); + H5Fclose(fid1b); + H5Fclose(fid2); + H5Fclose(fid3); + } + H5E_END_TRY; return 1; } /* end test_sharedclose() */ - /*------------------------------------------------------------------------- * Function: test_multisharedclose * @@ -4242,15 +4451,13 @@ error: * *------------------------------------------------------------------------- */ - static int +static int test_multisharedclose(hid_t fapl) { hid_t fid1 = -1, fid2 = -1; /* File IDs */ hid_t gid1 = -1, gid2 = -1, gid3 = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - filename3[NAME_BUF_SIZE], - filename4[NAME_BUF_SIZE]; /* Name of files to mount */ + char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], filename3[NAME_BUF_SIZE], + filename4[NAME_BUF_SIZE]; /* Name of files to mount */ TESTING("closing multiple shared mounts"); @@ -4260,95 +4467,128 @@ test_multisharedclose(hid_t fapl) h5_fixname(FILENAME[3], fapl, filename4, sizeof filename4); /* Create master file with three groups to serve as mount points */ - if ((fid1 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Gclose(H5Gcreate2(fid1, "mnt1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Gclose(H5Gcreate2(fid1, "mnt2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Gclose(H5Gcreate2(fid1, "mnt3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Fclose(fid1) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(H5Gcreate2(fid1, "mnt1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(H5Gcreate2(fid1, "mnt2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(H5Gcreate2(fid1, "mnt3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Create child file with group */ - if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Fclose(fid1) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Create child file with group */ - if ((fid1 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Fclose(fid1) < 0) TEST_ERROR + if ((fid1 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Create child file with group */ - if ((fid1 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Fclose(fid1) < 0) TEST_ERROR - + if ((fid1 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(H5Gcreate2(fid1, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Open master and child 1 and mount child 1 to master */ - if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if ((fid2 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Fmount(fid1, "mnt1", fid2, H5P_DEFAULT) < 0) TEST_ERROR + if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((fid2 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Fmount(fid1, "mnt1", fid2, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group in child 1 */ - if ((gid1 = H5Gopen2(fid1, "mnt1/grp", H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid1 = H5Gopen2(fid1, "mnt1/grp", H5P_DEFAULT)) < 0) + TEST_ERROR /* Close both files. They will be held open by gid1 */ - if (H5Idec_ref(fid2) < 0) TEST_ERROR - if (H5Idec_ref(fid1) < 0) TEST_ERROR - + if (H5Idec_ref(fid2) < 0) + TEST_ERROR + if (H5Idec_ref(fid1) < 0) + TEST_ERROR /* Open master and child 2 and mount child 2 to master */ - if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Fmount(fid1, "mnt2", fid2, H5P_DEFAULT) < 0) TEST_ERROR + if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Fmount(fid1, "mnt2", fid2, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group in child 2 */ - if ((gid2 = H5Gopen2(fid1, "mnt2/grp", H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid1, "mnt2/grp", H5P_DEFAULT)) < 0) + TEST_ERROR /* Close both files. They will be held open by gid2 */ - if (H5Idec_ref(fid2) < 0) TEST_ERROR - if (H5Idec_ref(fid1) < 0) TEST_ERROR - + if (H5Idec_ref(fid2) < 0) + TEST_ERROR + if (H5Idec_ref(fid1) < 0) + TEST_ERROR /* Open master and child 3 and mount child 3 to master */ - if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if ((fid2 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Fmount(fid1, "mnt3", fid2, H5P_DEFAULT) < 0) TEST_ERROR + if ((fid1 = H5Fopen(filename4, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((fid2 = H5Fopen(filename3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Fmount(fid1, "mnt3", fid2, H5P_DEFAULT) < 0) + TEST_ERROR /* Open the group in child 3 */ - if ((gid3 = H5Gopen2(fid1, "mnt3/grp", H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid3 = H5Gopen2(fid1, "mnt3/grp", H5P_DEFAULT)) < 0) + TEST_ERROR /* Close both files. They will be held open by gid3 */ - if (H5Idec_ref(fid2) < 0) TEST_ERROR - if (H5Idec_ref(fid1) < 0) TEST_ERROR - + if (H5Idec_ref(fid2) < 0) + TEST_ERROR + if (H5Idec_ref(fid1) < 0) + TEST_ERROR /* Close gid1. This will close child 1. */ - if (H5Idec_ref(gid1) < 0) TEST_ERROR + if (H5Idec_ref(gid1) < 0) + TEST_ERROR /* Close gid2. This will close child 2. */ - if (H5Idec_ref(gid2) < 0) TEST_ERROR + if (H5Idec_ref(gid2) < 0) + TEST_ERROR /* Close gid3. This will close child 3 and the master file. */ - if (H5Idec_ref(gid3) < 0) TEST_ERROR + if (H5Idec_ref(gid3) < 0) + TEST_ERROR /* Check that all file IDs have been closed */ - if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR + if (H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR H5F_sfile_assert_num(0); PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gid1); - H5Gclose(gid2); - H5Gclose(gid3); - H5Fclose(fid2); - H5Fclose(fid2); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid1); + H5Gclose(gid2); + H5Gclose(gid3); + H5Fclose(fid2); + H5Fclose(fid2); + } + H5E_END_TRY; return 1; } /* end test_multisharedclose() */ - /*------------------------------------------------------------------------- * Function: main * @@ -4368,12 +4608,13 @@ error: int main(void) { - int nerrors = 0; - hid_t fapl = -1; + int nerrors = 0; + hid_t fapl = -1; h5_reset(); fapl = h5_fileaccess(); - if (setup(fapl) < 0) goto error; + if (setup(fapl) < 0) + goto error; nerrors += test_basic(fapl); nerrors += test_illegal(fapl); @@ -4410,7 +4651,8 @@ main(void) /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if (nerrors) goto error; + if (nerrors) + goto error; HDputs("All mount tests passed."); h5_cleanup(FILENAME, fapl); @@ -4421,4 +4663,3 @@ error: HDputs("***** MOUNT ERRORS *****"); return 1; } - diff --git a/test/mtime.c b/test/mtime.c index 81a20db..b925692 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -23,16 +23,12 @@ #include "h5test.h" #include "H5srcdir.h" -const char *FILENAME[] = { - "mtime", - NULL -}; - -#define TESTFILE1 "tmtimeo.h5" -#define MTIME1 1055531866 -#define TESTFILE2 "tmtimen.h5" -#define MTIME2 1041606478 +const char *FILENAME[] = {"mtime", NULL}; +#define TESTFILE1 "tmtimeo.h5" +#define MTIME1 1055531866 +#define TESTFILE2 "tmtimen.h5" +#define MTIME2 1041606478 /*------------------------------------------------------------------------- * Function: main @@ -56,14 +52,14 @@ const char *FILENAME[] = { int main(void) { - hid_t fapl, file, space, dset; - hsize_t size[1] = {2}; - time_t now; - struct tm *tm; - H5O_info2_t oi1, oi2; - signed char buf1[32], buf2[32]; - char filename[1024]; - int token_cmp; + hid_t fapl, file, space, dset; + hsize_t size[1] = {2}; + time_t now; + struct tm * tm; + H5O_info2_t oi1, oi2; + signed char buf1[32], buf2[32]; + char filename[1024]; + int token_cmp; h5_reset(); fapl = h5_fileaccess(); @@ -72,15 +68,19 @@ main(void) /* Create the file, create a dataset, then close the file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - 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 ((space = H5Screate_simple(1, size, NULL)) < 0) TEST_ERROR; - if((space = H5Screate_simple(1, size, NULL)) < 0) TEST_ERROR; - if((dset = H5Dcreate2(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; now = HDtime(NULL); - if(H5Dclose(dset) < 0) TEST_ERROR; - if(H5Sclose(space) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Fclose(file) < 0) + TEST_ERROR; /* * Open the file and get the modification time. We'll test the @@ -88,16 +88,23 @@ main(void) * knowing its name. */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR; - if(H5Oget_info_by_name3(file, "dset", &oi1, H5O_INFO_BASIC|H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR; - if((dset = H5Dopen2(file, "dset", H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Oget_info3(dset, &oi2, H5O_INFO_BASIC|H5O_INFO_TIME) < 0) TEST_ERROR; - if(H5Otoken_cmp(file, &oi1.token, &oi2.token, &token_cmp) < 0)TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) TEST_ERROR; + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR; + if (H5Oget_info_by_name3(file, "dset", &oi1, H5O_INFO_BASIC | H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR; + if ((dset = H5Dopen2(file, "dset", H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Oget_info3(dset, &oi2, H5O_INFO_BASIC | H5O_INFO_TIME) < 0) + TEST_ERROR; + if (H5Otoken_cmp(file, &oi1.token, &oi2.token, &token_cmp) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; + if (H5Fclose(file) < 0) + TEST_ERROR; /* Compare object tokens & times from the two ways of calling H5Oget_info() */ - if(token_cmp || oi1.ctime != oi2.ctime) { + if (token_cmp || oi1.ctime != oi2.ctime) { H5_FAILED(); HDputs(" Calling H5Oget_info() with the dataset ID returned"); HDputs(" different values than calling it with a file and dataset"); @@ -106,24 +113,24 @@ main(void) } /* Compare times -- they must be within 60 seconds of one another */ - if(0 == oi1.ctime) { + if (0 == oi1.ctime) { SKIPPED(); HDputs(" The modification time could not be decoded on this OS."); HDputs(" Modification times will be mantained in the file but"); HDputs(" cannot be queried on this system. See H5O_mtime_decode()."); return 0; - } else if(HDfabs(HDdifftime(now, oi1.ctime)) > (double)60.0F) { + } + else if (HDfabs(HDdifftime(now, oi1.ctime)) > (double)60.0F) { H5_FAILED(); tm = HDlocaltime(&(oi1.ctime)); - HDstrftime((char*)buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm); + HDstrftime((char *)buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm); tm = HDlocaltime(&now); - HDstrftime((char*)buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S", tm); + HDstrftime((char *)buf2, sizeof buf2, "%Y-%m-%d %H:%M:%S", tm); HDprintf(" got: %s\n ans: %s\n", buf1, buf2); goto error; } PASSED(); - /* Check opening existing file with old-style modification time information * and make certain that the time is correct */ @@ -133,22 +140,22 @@ main(void) const char *testfile = H5_get_srcdir_filename(TESTFILE1); /* Corrected test file name */ file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - if(file >= 0){ - if(H5Oget_info_by_name3(file, "/Dataset1", &oi1, H5O_INFO_TIME, H5P_DEFAULT) < 0) + if (file >= 0) { + if (H5Oget_info_by_name3(file, "/Dataset1", &oi1, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR; - if(oi1.ctime != MTIME1) { + if (oi1.ctime != MTIME1) { H5_FAILED(); - /* If this fails, examine H5Omtime.c. Modification time is very - * system dependent (e.g., on Windows DST must be hardcoded). */ + /* If this fails, examine H5Omtime.c. Modification time is very + * system dependent (e.g., on Windows DST must be hardcoded). */ puts(" Old modification time incorrect"); goto error; } - if(H5Fclose(file) < 0) TEST_ERROR; + if (H5Fclose(file) < 0) + TEST_ERROR; } else { H5_FAILED(); - HDprintf("***cannot open the pre-created old modification test file (%s)\n", - testfile); + HDprintf("***cannot open the pre-created old modification test file (%s)\n", testfile); goto error; } /* end else */ } @@ -163,27 +170,28 @@ main(void) const char *testfile = H5_get_srcdir_filename(TESTFILE2); /* Corrected test file name */ file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - if(file >= 0){ - if(H5Oget_info_by_name3(file, "/Dataset1", &oi2, H5O_INFO_TIME, H5P_DEFAULT) < 0) + if (file >= 0) { + if (H5Oget_info_by_name3(file, "/Dataset1", &oi2, H5O_INFO_TIME, H5P_DEFAULT) < 0) TEST_ERROR; - if(oi2.ctime != MTIME2) { - H5_FAILED(); - HDputs(" Modification time incorrect."); - goto error; + if (oi2.ctime != MTIME2) { + H5_FAILED(); + HDputs(" Modification time incorrect."); + goto error; } - if(H5Fclose(file) < 0) TEST_ERROR; + if (H5Fclose(file) < 0) + TEST_ERROR; } else { H5_FAILED(); - HDprintf("***cannot open the pre-created old modification test file (%s)\n", - testfile); + HDprintf("***cannot open the pre-created old modification test file (%s)\n", testfile); goto error; } /* end else */ } PASSED(); /* Verify symbol table messages are cached */ - if(h5_verify_cached_stabs(FILENAME, fapl) < 0) TEST_ERROR + if (h5_verify_cached_stabs(FILENAME, fapl) < 0) + TEST_ERROR /* All looks good */ HDputs("All modification time tests passed."); @@ -194,4 +202,3 @@ main(void) error: return EXIT_FAILURE; } /* end main() */ - diff --git a/test/ntypes.c b/test/ntypes.c index f1d2449..1260b0c 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -20,47 +20,42 @@ #include "h5test.h" -const char *FILENAME[] = { - "ntypes", - NULL -}; - -#define DIM0 100 -#define DIM1 200 -#define DIM3 20 - - -int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; -short spoints2[DIM0][DIM1], scheck2[DIM0][DIM1]; -int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5]; - -#define DSET_ATOMIC_NAME_1 "atomic_type_1" -#define DSET_ATOMIC_NAME_2 "atomic_type_2" -#define DSET_ATOMIC_NAME_3 "atomic_type_3" -#define DSET_ATOMIC_NAME_4 "atomic_type_4" -#define DSET_ATOMIC_NAME_5 "atomic_type_5" -#define DSET_COMPOUND_NAME "compound_type" -#define DSET_COMPOUND_NAME_2 "compound_type_2" -#define DSET_COMPOUND_NAME_3 "compound_type_3" -#define DSET_COMPOUND_NAME_4 "compound_type_4" -#define DSET_ENUM_NAME "enum_type" -#define DSET_ARRAY_NAME "array_type" -#define DSET_ARRAY2_NAME "array_type_2" -#define DSET_VL_NAME "vl_type" -#define DSET_VLSTR_NAME "vlstr_type" -#define DSET_STR_NAME "str_type" -#define DSET_OPAQUE_NAME "opaque_type" -#define DSET1_BITFIELD_NAME "bitfield_type_1" -#define DSET2_BITFIELD_NAME "bitfield_type_2" - -#define SPACE1_DIM1 4 -#define SPACE1_RANK 1 -#define SPACE2_RANK 2 -#define SPACE2_DIM1 10 -#define SPACE2_DIM2 10 -#define BITFIELD_ENUMB 8 - - +const char *FILENAME[] = {"ntypes", NULL}; + +#define DIM0 100 +#define DIM1 200 +#define DIM3 20 + +int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; +short spoints2[DIM0][DIM1], scheck2[DIM0][DIM1]; +int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5]; + +#define DSET_ATOMIC_NAME_1 "atomic_type_1" +#define DSET_ATOMIC_NAME_2 "atomic_type_2" +#define DSET_ATOMIC_NAME_3 "atomic_type_3" +#define DSET_ATOMIC_NAME_4 "atomic_type_4" +#define DSET_ATOMIC_NAME_5 "atomic_type_5" +#define DSET_COMPOUND_NAME "compound_type" +#define DSET_COMPOUND_NAME_2 "compound_type_2" +#define DSET_COMPOUND_NAME_3 "compound_type_3" +#define DSET_COMPOUND_NAME_4 "compound_type_4" +#define DSET_ENUM_NAME "enum_type" +#define DSET_ARRAY_NAME "array_type" +#define DSET_ARRAY2_NAME "array_type_2" +#define DSET_VL_NAME "vl_type" +#define DSET_VLSTR_NAME "vlstr_type" +#define DSET_STR_NAME "str_type" +#define DSET_OPAQUE_NAME "opaque_type" +#define DSET1_BITFIELD_NAME "bitfield_type_1" +#define DSET2_BITFIELD_NAME "bitfield_type_2" + +#define SPACE1_DIM1 4 +#define SPACE1_RANK 1 +#define SPACE2_RANK 2 +#define SPACE2_DIM1 10 +#define SPACE2_DIM2 10 +#define BITFIELD_ENUMB 8 + /*------------------------------------------------------------------------- * Function: test_atomic_dtype * @@ -80,59 +75,63 @@ int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5]; static herr_t test_atomic_dtype(hid_t file) { - hid_t dataset = -1, space = -1; - hid_t dtype = -1, native_type = -1; - int i, j, n; - hsize_t dims[2]; - void *tmp = NULL; + hid_t dataset = -1, space = -1; + hid_t dtype = -1, native_type = -1; + int i, j, n; + hsize_t dims[2]; + void * tmp = NULL; TESTING("atomic datatype"); /* Initialize the dataset */ - for(i = n = 0; i < DIM0; i++) - for(j = 0; j < DIM1; j++) + for (i = n = 0; i < DIM0; i++) + for (j = 0; j < DIM1; j++) ipoints2[i][j] = n++; /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /*------------------- Test data values ------------------------*/ /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_1, H5T_STD_I32BE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_1, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0) TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_ATOMIC_NAME_1, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_ATOMIC_NAME_1, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Verify the datatype retrieved and converted */ - if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_INT)) + if (H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_INT)) TEST_ERROR; - if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I32BE)) + if (H5Tget_size(native_type) < H5Tget_size(H5T_STD_I32BE)) TEST_ERROR; - if(H5T_INTEGER != H5Tget_class(native_type)) + if (H5T_INTEGER != H5Tget_class(native_type)) TEST_ERROR; /* Read the dataset back. The temporary buffer is for special platforms * like Cray. */ - if(NULL == (tmp = HDmalloc((size_t)(DIM0 * DIM1 * H5Tget_size(native_type))))) + if (NULL == (tmp = HDmalloc((size_t)(DIM0 * DIM1 * H5Tget_size(native_type))))) TEST_ERROR - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) TEST_ERROR; /* Copy data from temporary buffer to destination buffer */ @@ -141,139 +140,156 @@ test_atomic_dtype(hid_t file) tmp = NULL; /* Convert to the integer type */ - if(H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0 * DIM1), icheck2, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0 * DIM1), icheck2, NULL, H5P_DEFAULT) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i = 0; i < DIM0; i++) - for(j = 0; j < DIM1; j++) - if(ipoints2[i][j] != icheck2[i][j]) { + for (i = 0; i < DIM0; i++) + for (j = 0; j < DIM1; j++) + if (ipoints2[i][j] != icheck2[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); goto error; } /* end if */ - if(H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; - if(H5Tclose(dtype) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR; /*------------------ Test different data types ----------------*/ /* Create the dataset of H5T_STD_I64LE */ - if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_2, H5T_STD_I64LE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_2, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Verify the datatype retrieved and converted */ - if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_LLONG)) + if (H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_LLONG)) TEST_ERROR; - if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I64LE)) + if (H5Tget_size(native_type) < H5Tget_size(H5T_STD_I64LE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(native_type)) + if (H5T_INTEGER != H5Tget_class(native_type)) TEST_ERROR; - if(H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; - if(H5Tclose(dtype) < 0) TEST_ERROR; - + if (H5Dclose(dataset) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR; /* Create the dataset of H5T_STD_I8LE */ - if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_3, H5T_STD_I8LE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_3, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_ASCEND)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_ASCEND)) < 0) TEST_ERROR; /* Verify the datatype retrieved and converted */ - if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_CHAR)) + if (H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_CHAR)) TEST_ERROR; - if(H5Tget_size(native_type) < H5Tget_size(H5T_STD_I8LE)) + if (H5Tget_size(native_type) < H5Tget_size(H5T_STD_I8LE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(native_type)) + if (H5T_INTEGER != H5Tget_class(native_type)) TEST_ERROR; - if(H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; - if(H5Tclose(dtype) < 0) TEST_ERROR; - + if (H5Dclose(dataset) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR; /* Create the dataset of H5T_IEEE_F32BE */ - if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_4, H5T_IEEE_F32BE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_4, H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DESCEND)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DESCEND)) < 0) TEST_ERROR; /* Verify the datatype retrieved and converted */ - if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_FLOAT)) + if (H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_FLOAT)) TEST_ERROR; - if(H5Tget_size(native_type) < H5Tget_size(H5T_IEEE_F32BE)) + if (H5Tget_size(native_type) < H5Tget_size(H5T_IEEE_F32BE)) TEST_ERROR; - if(H5T_FLOAT!=H5Tget_class(native_type)) + if (H5T_FLOAT != H5Tget_class(native_type)) TEST_ERROR; - if(H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; - if(H5Tclose(dtype) < 0) TEST_ERROR; - + if (H5Dclose(dataset) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR; /* Create the dataset of H5T_IEEE_F64BE */ - if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_5, H5T_IEEE_F64BE, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_5, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DESCEND)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DESCEND)) < 0) TEST_ERROR; /* Verify the datatype retrieved and converted */ - if(H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_DOUBLE)) + if (H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_DOUBLE)) TEST_ERROR; - if(H5Tget_size(native_type) < H5Tget_size(H5T_IEEE_F64BE)) + if (H5Tget_size(native_type) < H5Tget_size(H5T_IEEE_F64BE)) TEST_ERROR; - if(H5T_FLOAT != H5Tget_class(native_type)) + if (H5T_FLOAT != H5Tget_class(native_type)) TEST_ERROR; - if(H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; - if(H5Tclose(dtype) < 0) TEST_ERROR; - + if (H5Dclose(dataset) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; PASSED(); return 0; error: - if(tmp) + if (tmp) HDfree(tmp); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Tclose(native_type); H5Tclose(dtype); H5Sclose(space); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_compound_dtype2 * @@ -294,244 +310,274 @@ static herr_t test_compound_dtype2(hid_t file) { typedef struct s2 { - short c2; - long l2; - long long ll2; + short c2; + long l2; + long long ll2; } s2; typedef struct s1 { - char c; - int i; - s2 st; - unsigned long long l; + char c; + int i; + s2 st; + unsigned long long l; } s1; - hid_t dataset = -1, space = -1; - hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1, - tid_m2 = -1, mem_id = -1, nest_mem_id = -1; - int i, j, n; - hsize_t dims[2]; - s1 *temp_point = NULL, *temp_check = NULL; - s1 *points = NULL, *check = NULL; - void *tmp = NULL, *bkg = NULL; + hid_t dataset = -1, space = -1; + hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1, tid_m2 = -1, mem_id = -1, + nest_mem_id = -1; + int i, j, n; + hsize_t dims[2]; + s1 * temp_point = NULL, *temp_check = NULL; + s1 * points = NULL, *check = NULL; + void * tmp = NULL, *bkg = NULL; TESTING("nested compound datatype"); /* Allocate space for the points & check arrays */ - if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1))) + if (NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1))) TEST_ERROR; - if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1))) TEST_ERROR; /* Initialize the dataset */ - for(i = n = 0, temp_point = points; i < DIM0; i++) { - for(j = 0; j < DIM1; j++, temp_point++) { - temp_point->c = 't'; - temp_point->i = n++; - temp_point->st.c2 = (short)(i + j); - temp_point->st.l2 = (i * 5 + j * 50) * n; + for (i = n = 0, temp_point = points; i < DIM0; i++) { + for (j = 0; j < DIM1; j++, temp_point++) { + temp_point->c = 't'; + temp_point->i = n++; + temp_point->st.c2 = (short)(i + j); + temp_point->st.l2 = (i * 5 + j * 50) * n; temp_point->st.ll2 = (i * 10 + j * 100) * n; - temp_point->l = (unsigned long long)((i * 40 + j * 400) * n); + temp_point->l = (unsigned long long)((i * 40 + j * 400) * n); } /* end for */ - } /* end for */ + } /* end for */ /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /* Create compound datatype for disk storage */ - if((tid2=H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) TEST_ERROR; - if((tid=H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR; + if ((tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) + TEST_ERROR; + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) + TEST_ERROR; /* Insert and pack members */ - if(H5Tinsert(tid2, "c2", HOFFSET(s2, c2), H5T_STD_I16BE) < 0) TEST_ERROR; + if (H5Tinsert(tid2, "c2", HOFFSET(s2, c2), H5T_STD_I16BE) < 0) + TEST_ERROR; #if H5_SIZEOF_LONG == 4 - if(H5Tinsert(tid2, "l2", HOFFSET(s2, l2), H5T_STD_I32LE) < 0) TEST_ERROR; + if (H5Tinsert(tid2, "l2", HOFFSET(s2, l2), H5T_STD_I32LE) < 0) + TEST_ERROR; #elif H5_SIZEOF_LONG == 8 - if(H5Tinsert(tid2, "l2", HOFFSET(s2, l2), H5T_STD_I64LE) < 0) TEST_ERROR; + if (H5Tinsert(tid2, "l2", HOFFSET(s2, l2), H5T_STD_I64LE) < 0) + TEST_ERROR; #else #error "Unknown 'long' size" #endif #if H5_SIZEOF_LONG_LONG == 4 - if(H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I32BE) < 0) TEST_ERROR; + if (H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I32BE) < 0) + TEST_ERROR; #elif H5_SIZEOF_LONG_LONG == 8 - if(H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I64BE) < 0) TEST_ERROR; + if (H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I64BE) < 0) + TEST_ERROR; #else #error "Unknown 'long long' size" #endif - if(H5Tinsert(tid, "c", HOFFSET(s1, c), H5T_STD_U8LE) < 0) TEST_ERROR; - if(H5Tinsert(tid, "i", HOFFSET(s1, i), H5T_STD_I32LE) < 0) TEST_ERROR; - if(H5Tinsert(tid, "st", HOFFSET(s1, st), tid2) < 0) TEST_ERROR; + if (H5Tinsert(tid, "c", HOFFSET(s1, c), H5T_STD_U8LE) < 0) + TEST_ERROR; + if (H5Tinsert(tid, "i", HOFFSET(s1, i), H5T_STD_I32LE) < 0) + TEST_ERROR; + if (H5Tinsert(tid, "st", HOFFSET(s1, st), tid2) < 0) + TEST_ERROR; #if H5_SIZEOF_LONG_LONG == 4 - if(H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U32BE) < 0) TEST_ERROR; + if (H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U32BE) < 0) + TEST_ERROR; #elif H5_SIZEOF_LONG_LONG == 8 - if(H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U64BE) < 0) TEST_ERROR; + if (H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U64BE) < 0) + TEST_ERROR; #else #error "Unknown 'long long' size" #endif /* Take away the paddings */ - if(H5Tpack(tid) < 0) TEST_ERROR; + if (H5Tpack(tid) < 0) + TEST_ERROR; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_2, tid, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, DSET_COMPOUND_NAME_2, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create compound datatype for memory */ - if((tid_m2 = H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) TEST_ERROR; - if((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR; + if ((tid_m2 = H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) + TEST_ERROR; + if ((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) + TEST_ERROR; /* Insert members */ - if(H5Tinsert(tid_m2, "c2", HOFFSET(s2, c2), H5T_NATIVE_SHORT) < 0) TEST_ERROR; - if(H5Tinsert(tid_m2, "l2", HOFFSET(s2, l2), H5T_NATIVE_LONG) < 0) TEST_ERROR; - if(H5Tinsert(tid_m2, "ll2", HOFFSET(s2, ll2), H5T_NATIVE_LLONG) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "i", HOFFSET(s1, i), H5T_NATIVE_INT) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "st", HOFFSET(s1, st), tid_m2) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "l", HOFFSET(s1, l), H5T_NATIVE_ULLONG) < 0) TEST_ERROR; + if (H5Tinsert(tid_m2, "c2", HOFFSET(s2, c2), H5T_NATIVE_SHORT) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m2, "l2", HOFFSET(s2, l2), H5T_NATIVE_LONG) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m2, "ll2", HOFFSET(s2, ll2), H5T_NATIVE_LLONG) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "i", HOFFSET(s1, i), H5T_NATIVE_INT) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "st", HOFFSET(s1, st), tid_m2) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "l", HOFFSET(s1, l), H5T_NATIVE_ULLONG) < 0) + TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + if (H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; - + if (H5Sclose(space) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_COMPOUND_NAME_2, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_COMPOUND_NAME_2, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; - if(H5Tequal(native_type, tid_m) != TRUE) + if (H5Tequal(native_type, tid_m) != TRUE) TEST_ERROR; /* Verify the datatype of each field retrieved and converted */ /* check the char member */ - if((mem_id = H5Tget_member_type(native_type, 0)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 0)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_SCHAR)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_SCHAR)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I8LE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I8LE)) TEST_ERROR; - if(H5T_INTEGER != H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* check the integer member */ - if((mem_id = H5Tget_member_type(native_type, 1)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 1)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_INT)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_INT)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* check the unsigned long long member */ - if((mem_id = H5Tget_member_type(native_type, 3)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 3)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_ULLONG)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_ULLONG)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U64BE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U64BE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* check the nested compound member */ - if((nest_mem_id = H5Tget_member_type(native_type, 2)) < 0) + if ((nest_mem_id = H5Tget_member_type(native_type, 2)) < 0) TEST_ERROR; - if((mem_id = H5Tget_member_type(nest_mem_id, 0)) < 0) + if ((mem_id = H5Tget_member_type(nest_mem_id, 0)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_SHORT)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_SHORT)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I16BE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I16BE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); - if((mem_id = H5Tget_member_type(nest_mem_id, 1)) < 0) + if ((mem_id = H5Tget_member_type(nest_mem_id, 1)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LONG)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LONG)) + TEST_ERROR; +#if H5_SIZEOF_LONG == 4 + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) + TEST_ERROR; +#elif H5_SIZEOF_LONG == 8 + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64LE)) TEST_ERROR; -#if H5_SIZEOF_LONG==4 - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) TEST_ERROR; -#elif H5_SIZEOF_LONG==8 - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64LE)) TEST_ERROR; #else #error "Unknown 'long' size" #endif - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); - if((mem_id = H5Tget_member_type(nest_mem_id, 2)) < 0) + if ((mem_id = H5Tget_member_type(nest_mem_id, 2)) < 0) + TEST_ERROR; + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) +#if H5_SIZEOF_LONG_LONG == 4 + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) + TEST_ERROR; +#elif H5_SIZEOF_LONG_LONG == 8 + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64LE)) TEST_ERROR; -#if H5_SIZEOF_LONG_LONG==4 - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) TEST_ERROR; -#elif H5_SIZEOF_LONG_LONG==8 - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64LE)) TEST_ERROR; #else #error "Unknown 'long long' size" #endif - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* Read the dataset back. Temporary buffer is for special platforms like * Cray */ - if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) + if (NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR - if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1))) TEST_ERROR; - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) TEST_ERROR; - HDmemcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type)); + HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type)); HDfree(tmp); tmp = NULL; - if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0) + if (H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0) TEST_ERROR; HDfree(bkg); bkg = NULL; /* Check that the values read are the same as the values written */ - for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++) { - for(j = 0; j < DIM1; j++, temp_point++, temp_check++) { - if(temp_point->c != temp_check->c || - temp_point->i != temp_check->i || - temp_point->st.c2 != temp_check->st.c2 || - temp_point->st.l2 != temp_check->st.l2 || - temp_point->st.ll2 != temp_check->st.ll2 || - temp_point->l != temp_check->l ) { + for (i = 0, temp_point = points, temp_check = check; i < DIM0; i++) { + for (j = 0; j < DIM1; j++, temp_point++, temp_check++) { + if (temp_point->c != temp_check->c || temp_point->i != temp_check->i || + temp_point->st.c2 != temp_check->st.c2 || temp_point->st.l2 != temp_check->st.l2 || + temp_point->st.ll2 != temp_check->st.ll2 || temp_point->l != temp_check->l) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); goto error; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close temporary datatypes */ - if(H5Tclose(tid2) < 0) TEST_ERROR; - if(H5Tclose(tid) < 0) TEST_ERROR; - if(H5Tclose(tid_m2) < 0) TEST_ERROR; + if (H5Tclose(tid2) < 0) + TEST_ERROR; + if (H5Tclose(tid) < 0) + TEST_ERROR; + if (H5Tclose(tid_m2) < 0) + TEST_ERROR; /* Close HDF5 objects */ H5Dclose(dataset); @@ -547,16 +593,17 @@ test_compound_dtype2(hid_t file) return 0; error: - if(tmp) + if (tmp) HDfree(tmp); - if(bkg) + if (bkg) HDfree(bkg); - if(points) + if (points) HDfree(points); - if(check) + if (check) HDfree(check); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid); H5Tclose(tid2); H5Tclose(tid_m); @@ -567,12 +614,12 @@ error: H5Dclose(dataset); H5Tclose(dtype); H5Tclose(native_type); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_compound_dtype * @@ -593,32 +640,32 @@ static herr_t test_compound_dtype(hid_t file) { typedef struct { - char c; - unsigned int i; - long long l; + char c; + unsigned int i; + long long l; } s1; - hid_t dataset = -1, space = -1; - hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, mem_id = -1; - int i, j, n; - hsize_t dims[2]; - s1 *temp_point = NULL; - s1 *temp_check = NULL; - s1 *points = NULL; - s1 *check = NULL; - void *tmp = NULL; - void *bkg = NULL; + hid_t dataset = -1, space = -1; + hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, mem_id = -1; + int i, j, n; + hsize_t dims[2]; + s1 * temp_point = NULL; + s1 * temp_check = NULL; + s1 * points = NULL; + s1 * check = NULL; + void * tmp = NULL; + void * bkg = NULL; TESTING("compound datatype"); /* Allocate space for the points & check arrays */ - if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1))) + if (NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1))) TEST_ERROR; - if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1))) TEST_ERROR; /* Initialize the dataset */ - for(i = n = 0, temp_point = points; i < DIM0; i++) - for(j = 0; j < DIM1; j++, temp_point++) { + for (i = n = 0, temp_point = points; i < DIM0; i++) + for (j = 0; j < DIM1; j++, temp_point++) { temp_point->c = 't'; temp_point->i = (unsigned int)(n++); temp_point->l = (i * 10 + j * 100) * n; @@ -627,106 +674,117 @@ test_compound_dtype(hid_t file) /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /* Create compound datatype for disk storage */ - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR; + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) + TEST_ERROR; /* Insert members */ - if(H5Tinsert(tid, "c", 0, H5T_STD_U8LE) < 0) TEST_ERROR; - if(H5Tinsert(tid, "i", 1, H5T_STD_U32LE) < 0) TEST_ERROR; - if(H5Tinsert(tid, "l", 5, H5T_STD_I64BE) < 0) TEST_ERROR; + if (H5Tinsert(tid, "c", 0, H5T_STD_U8LE) < 0) + TEST_ERROR; + if (H5Tinsert(tid, "i", 1, H5T_STD_U32LE) < 0) + TEST_ERROR; + if (H5Tinsert(tid, "l", 5, H5T_STD_I64BE) < 0) + TEST_ERROR; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME, tid, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) TEST_ERROR; /* Create compound datatype for datatype in memory */ - if((tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR; - if(H5Tinsert(tid2, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) TEST_ERROR; - if(H5Tinsert(tid2, "i", HOFFSET(s1, i), H5T_NATIVE_UINT) < 0) TEST_ERROR; - if(H5Tinsert(tid2, "l", HOFFSET(s1, l), H5T_NATIVE_LLONG) < 0) TEST_ERROR; + if ((tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) + TEST_ERROR; + if (H5Tinsert(tid2, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) + TEST_ERROR; + if (H5Tinsert(tid2, "i", HOFFSET(s1, i), H5T_NATIVE_UINT) < 0) + TEST_ERROR; + if (H5Tinsert(tid2, "l", HOFFSET(s1, l), H5T_NATIVE_LLONG) < 0) + TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + if (H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; - + if (H5Sclose(space) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_COMPOUND_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_COMPOUND_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; - if(H5Tequal(native_type, tid2) != TRUE) + if (H5Tequal(native_type, tid2) != TRUE) TEST_ERROR; /* Verify the datatype of each field retrieved and converted */ - if((mem_id = H5Tget_member_type(native_type, 0)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 0)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UCHAR)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UCHAR)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U8LE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U8LE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); - if((mem_id = H5Tget_member_type(native_type, 1)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 1)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UINT)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UINT)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U32LE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U32LE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); - if((mem_id = H5Tget_member_type(native_type, 2)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 2)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64BE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64BE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* Read the dataset back. Temporary buffer is for special platforms like * Cray */ - if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) + if (NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR - if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1))) TEST_ERROR - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) TEST_ERROR; HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type)); HDfree(tmp); tmp = NULL; - if(H5Tconvert(native_type, tid2, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0) + if (H5Tconvert(native_type, tid2, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0) TEST_ERROR; HDfree(bkg); bkg = NULL; /* Check that the values read are the same as the values written */ - for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++) - for(j = 0; j < DIM1; j++, temp_point++, temp_check++) - if(temp_point->c != temp_check->c || - temp_point->i != temp_check->i || - temp_point->l != temp_check->l ) { + for (i = 0, temp_point = points, temp_check = check; i < DIM0; i++) + for (j = 0; j < DIM1; j++, temp_point++, temp_check++) + if (temp_point->c != temp_check->c || temp_point->i != temp_check->i || + temp_point->l != temp_check->l) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -734,7 +792,8 @@ test_compound_dtype(hid_t file) } /* end if */ /* Close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR; + if (H5Tclose(tid) < 0) + TEST_ERROR; H5Dclose(dataset); H5Tclose(dtype); @@ -750,16 +809,17 @@ test_compound_dtype(hid_t file) error: /* Free memory for test data */ - if(tmp) + if (tmp) HDfree(tmp); - if(bkg) + if (bkg) HDfree(bkg); - if(points) + if (points) HDfree(points); - if(check) + if (check) HDfree(check); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid); H5Sclose(space); H5Tclose(mem_id); @@ -767,12 +827,12 @@ error: H5Tclose(dtype); H5Tclose(native_type); H5Tclose(tid2); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_compound_dtype3 * @@ -793,169 +853,184 @@ static herr_t test_compound_dtype3(hid_t file) { typedef struct { - char c; - int a[5]; - long long l; + char c; + int a[5]; + long long l; } s1; - hid_t dataset = -1, space = -1; - hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1, - tid_m2 = -1, mem_id = -1, nest_mem_id = -1; - hsize_t array_dims[1] = {5}; - int i, j, k, n; - hsize_t dims[2]; - s1 *temp_point = NULL, *temp_check = NULL; - s1 *points = NULL, *check = NULL; - void *tmp = NULL, *bkg = NULL; + hid_t dataset = -1, space = -1; + hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1, tid_m2 = -1, mem_id = -1, + nest_mem_id = -1; + hsize_t array_dims[1] = {5}; + int i, j, k, n; + hsize_t dims[2]; + s1 * temp_point = NULL, *temp_check = NULL; + s1 * points = NULL, *check = NULL; + void * tmp = NULL, *bkg = NULL; TESTING("compound datatype with array as field"); /* Allocate space for the points & check arrays */ - if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1))) + if (NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1))) TEST_ERROR; - if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1))) TEST_ERROR; /* Initialize the dataset */ - for(i = n = 0, temp_point = points; i < DIM0; i++) - for(j = 0; j < DIM1; j++, temp_point++) { + for (i = n = 0, temp_point = points; i < DIM0; i++) + for (j = 0; j < DIM1; j++, temp_point++) { temp_point->c = 't'; temp_point->l = (i * 10 + j * 100) * n; - for(k = 0; k < 5; k++) + for (k = 0; k < 5; k++) (temp_point->a)[k] = n++; } /* end for */ /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /* Create array datatype */ - if((tid2 = H5Tarray_create2(H5T_STD_I32LE, 1, array_dims)) < 0) TEST_ERROR; + if ((tid2 = H5Tarray_create2(H5T_STD_I32LE, 1, array_dims)) < 0) + TEST_ERROR; /* Create compound datatype for disk storage */ - if((tid = H5Tcreate(H5T_COMPOUND, 29)) < 0) TEST_ERROR; + if ((tid = H5Tcreate(H5T_COMPOUND, 29)) < 0) + TEST_ERROR; /* Insert members */ - if(H5Tinsert(tid, "c", 0, H5T_STD_U8LE) < 0) TEST_ERROR; - if(H5Tinsert(tid, "a", 1, tid2) < 0) TEST_ERROR; - if(H5Tinsert(tid, "l", 21, H5T_STD_I64BE) < 0) TEST_ERROR; + if (H5Tinsert(tid, "c", 0, H5T_STD_U8LE) < 0) + TEST_ERROR; + if (H5Tinsert(tid, "a", 1, tid2) < 0) + TEST_ERROR; + if (H5Tinsert(tid, "l", 21, H5T_STD_I64BE) < 0) + TEST_ERROR; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_3, tid, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, DSET_COMPOUND_NAME_3, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create array datatype */ - if((tid_m2 = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) TEST_ERROR; + if ((tid_m2 = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) + TEST_ERROR; /* Create compound datatype for datatype in memory */ - if((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "a", HOFFSET(s1, a), tid_m2) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "l", HOFFSET(s1, l), H5T_NATIVE_LLONG) < 0) TEST_ERROR; + if ((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "a", HOFFSET(s1, a), tid_m2) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "l", HOFFSET(s1, l), H5T_NATIVE_LLONG) < 0) + TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + if (H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR; - if(H5Tclose(tid2) < 0) TEST_ERROR; + if (H5Tclose(tid) < 0) + TEST_ERROR; + if (H5Tclose(tid2) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; - + if (H5Sclose(space) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_COMPOUND_NAME_3, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_COMPOUND_NAME_3, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Verify the datatype of each field retrieved and converted */ /* check the char member */ - if((mem_id = H5Tget_member_type(native_type, 0)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 0)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UCHAR)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UCHAR)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U8LE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U8LE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* check the array member */ - if((mem_id = H5Tget_member_type(native_type, 1)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 1)) < 0) TEST_ERROR; - if(H5T_ARRAY!=H5Tget_class(mem_id)) + if (H5T_ARRAY != H5Tget_class(mem_id)) TEST_ERROR; - if((nest_mem_id = H5Tget_super(mem_id)) < 0) + if ((nest_mem_id = H5Tget_super(mem_id)) < 0) TEST_ERROR; - if(H5Tget_order(nest_mem_id) != H5Tget_order(H5T_NATIVE_INT)) + if (H5Tget_order(nest_mem_id) != H5Tget_order(H5T_NATIVE_INT)) TEST_ERROR; - if(H5Tget_size(nest_mem_id) < H5Tget_size(H5T_STD_I32LE)) + if (H5Tget_size(nest_mem_id) < H5Tget_size(H5T_STD_I32LE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(nest_mem_id)) + if (H5T_INTEGER != H5Tget_class(nest_mem_id)) TEST_ERROR; H5Tclose(nest_mem_id); H5Tclose(mem_id); /* check the long long member */ - if((mem_id = H5Tget_member_type(native_type, 2)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 2)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64BE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64BE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* Read the dataset back. Temporary buffer is for special platforms like * Cray */ - if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) + if (NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR; - if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1))) TEST_ERROR; - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) TEST_ERROR; HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type)); HDfree(tmp); tmp = NULL; - if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0) + if (H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0) TEST_ERROR; HDfree(bkg); bkg = NULL; /* Check that the values read are the same as the values written */ - for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++) - for(j = 0; j < DIM1; j++, temp_point++, temp_check++) { - if(temp_point->c != temp_check->c || - temp_point->l != temp_check->l ) { + for (i = 0, temp_point = points, temp_check = check; i < DIM0; i++) + for (j = 0; j < DIM1; j++, temp_point++, temp_check++) { + if (temp_point->c != temp_check->c || temp_point->l != temp_check->l) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); goto error; } /* end if */ - for(k = 0; k < 5; k++) { - if(temp_point->a[k] != temp_check->a[k]) { + for (k = 0; k < 5; k++) { + if (temp_point->a[k] != temp_check->a[k]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d,%d\n", i, j, k); goto error; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ H5Dclose(dataset); H5Tclose(dtype); @@ -972,16 +1047,17 @@ test_compound_dtype3(hid_t file) error: /* Free memory for test data */ - if(tmp) + if (tmp) HDfree(tmp); - if(bkg) + if (bkg) HDfree(bkg); - if(points) + if (points) HDfree(points); - if(check) + if (check) HDfree(check); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Tclose(mem_id); H5Tclose(nest_mem_id); @@ -992,12 +1068,12 @@ error: H5Tclose(tid2); H5Tclose(tid_m); H5Tclose(tid_m2); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_compound_opaque * @@ -1018,159 +1094,173 @@ static herr_t test_compound_opaque(hid_t file) { typedef struct { - char c; - unsigned char o[5]; - long long l; + char c; + unsigned char o[5]; + long long l; } s1; - hid_t dataset = -1, space = -1; - hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1, - mem_id = -1; - int i, j, k, n; - hsize_t dims[2]; - s1 *temp_point = NULL, *temp_check = NULL; - s1 *points = NULL, *check = NULL; - void *tmp = NULL, *bkg = NULL; + hid_t dataset = -1, space = -1; + hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1, mem_id = -1; + int i, j, k, n; + hsize_t dims[2]; + s1 * temp_point = NULL, *temp_check = NULL; + s1 * points = NULL, *check = NULL; + void * tmp = NULL, *bkg = NULL; TESTING("compound datatype with opaque field"); /* Allocate space for the points & check arrays */ - if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1))) + if (NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1))) TEST_ERROR; - if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1))) TEST_ERROR; /* Initialize the dataset */ - for(i = n = 0, temp_point = points; i < DIM0; i++) - for(j = 0; j < DIM1; j++, temp_point++) { + for (i = n = 0, temp_point = points; i < DIM0; i++) + for (j = 0; j < DIM1; j++, temp_point++) { temp_point->c = 't'; temp_point->l = (i * 10 + j * 100) * n; - for(k = 0; k < 5; k++) + for (k = 0; k < 5; k++) (temp_point->o)[k] = (unsigned char)(n++); } /* end for */ /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /* Create opaque datatype */ - if((tid2 = H5Tcreate(H5T_OPAQUE, sizeof(temp_point->o))) < 0) TEST_ERROR; - if(H5Tset_tag(tid2, "testing opaque field") < 0) TEST_ERROR; + if ((tid2 = H5Tcreate(H5T_OPAQUE, sizeof(temp_point->o))) < 0) + TEST_ERROR; + if (H5Tset_tag(tid2, "testing opaque field") < 0) + TEST_ERROR; /* Create compound datatype for disk storage */ - if((tid = H5Tcreate(H5T_COMPOUND, 14)) < 0) TEST_ERROR; + if ((tid = H5Tcreate(H5T_COMPOUND, 14)) < 0) + TEST_ERROR; /* Insert members */ - if(H5Tinsert(tid, "c", 0, H5T_STD_U8LE) < 0) TEST_ERROR; - if(H5Tinsert(tid, "o", 1, tid2) < 0) TEST_ERROR; - if(H5Tinsert(tid, "l", 6, H5T_STD_I64BE) < 0) TEST_ERROR; + if (H5Tinsert(tid, "c", 0, H5T_STD_U8LE) < 0) + TEST_ERROR; + if (H5Tinsert(tid, "o", 1, tid2) < 0) + TEST_ERROR; + if (H5Tinsert(tid, "l", 6, H5T_STD_I64BE) < 0) + TEST_ERROR; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_4, tid, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, DSET_COMPOUND_NAME_4, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create compound datatype for datatype in memory */ - if((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "o", HOFFSET(s1, o), tid2) < 0) TEST_ERROR; - if(H5Tinsert(tid_m, "l", HOFFSET(s1, l), H5T_NATIVE_LLONG) < 0) TEST_ERROR; + if ((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "o", HOFFSET(s1, o), tid2) < 0) + TEST_ERROR; + if (H5Tinsert(tid_m, "l", HOFFSET(s1, l), H5T_NATIVE_LLONG) < 0) + TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + if (H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR; - if(H5Tclose(tid2) < 0) TEST_ERROR; + if (H5Tclose(tid) < 0) + TEST_ERROR; + if (H5Tclose(tid2) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; - + if (H5Sclose(space) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_COMPOUND_NAME_4, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_COMPOUND_NAME_4, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Verify the datatype of each field retrieved and converted */ /* check the char member */ - if((mem_id = H5Tget_member_type(native_type, 0)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 0)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UCHAR)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UCHAR)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U8LE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U8LE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* check the array member */ - if((mem_id = H5Tget_member_type(native_type, 1)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 1)) < 0) TEST_ERROR; - if(H5T_OPAQUE!=H5Tget_class(mem_id)) + if (H5T_OPAQUE != H5Tget_class(mem_id)) TEST_ERROR; - if(H5Tget_size(mem_id) != sizeof(temp_point->o)) + if (H5Tget_size(mem_id) != sizeof(temp_point->o)) TEST_ERROR; H5Tclose(mem_id); /* check the long long member */ - if((mem_id = H5Tget_member_type(native_type, 2)) < 0) + if ((mem_id = H5Tget_member_type(native_type, 2)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) + if (H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64BE)) + if (H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64BE)) TEST_ERROR; - if(H5T_INTEGER!=H5Tget_class(mem_id)) + if (H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; H5Tclose(mem_id); /* Read the dataset back. Temporary buffer is for special platforms like * Cray */ - if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) + if (NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR; - if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1))) TEST_ERROR; - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) TEST_ERROR; HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type)); HDfree(tmp); tmp = NULL; - if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0) + if (H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0) TEST_ERROR; HDfree(bkg); bkg = NULL; /* Check that the values read are the same as the values written */ - for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++) - for(j = 0; j < DIM1; j++, temp_point++, temp_check++) { - if(temp_point->c != temp_check->c || - temp_point->l != temp_check->l ) { + for (i = 0, temp_point = points, temp_check = check; i < DIM0; i++) + for (j = 0; j < DIM1; j++, temp_point++, temp_check++) { + if (temp_point->c != temp_check->c || temp_point->l != temp_check->l) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); goto error; } /* end if */ - for(k = 0; k < 5; k++) { - if(temp_point->o[k] != temp_check->o[k]) { + for (k = 0; k < 5; k++) { + if (temp_point->o[k] != temp_check->o[k]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d,%d\n", i, j, k); goto error; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ H5Dclose(dataset); H5Tclose(dtype); @@ -1186,16 +1276,17 @@ test_compound_opaque(hid_t file) error: /* Free memory for test data */ - if(tmp) + if (tmp) HDfree(tmp); - if(bkg) + if (bkg) HDfree(bkg); - if(points) + if (points) HDfree(points); - if(check) + if (check) HDfree(check); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Tclose(mem_id); H5Dclose(dataset); @@ -1204,12 +1295,12 @@ error: H5Tclose(tid); H5Tclose(tid2); H5Tclose(tid_m); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_enum_dtype * @@ -1229,101 +1320,102 @@ error: static herr_t test_enum_dtype(hid_t file) { - hid_t dataset = -1, space = -1; - hid_t tid = -1, tid_m = -1, dtype = -1, native_type = -1; - int i, j, n; - hsize_t dims[2]; - void *tmp = NULL; - short colors[8]; + hid_t dataset = -1, space = -1; + hid_t tid = -1, tid_m = -1, dtype = -1, native_type = -1; + int i, j, n; + hsize_t dims[2]; + void * tmp = NULL; + short colors[8]; unsigned char sub_colors[16]; - const char *mname[] = { "RED", - "GREEN", - "BLUE", - "YELLOW", - "PINK", - "PURPLE", - "ORANGE", - "WHITE" }; + const char * mname[] = {"RED", "GREEN", "BLUE", "YELLOW", "PINK", "PURPLE", "ORANGE", "WHITE"}; TESTING("enum datatype"); /* Initialize the dataset */ - for(i = 0; i < DIM0; i++) - for(j = 0, n = 0; j < DIM1; j++, n++) + for (i = 0; i < DIM0; i++) + for (j = 0, n = 0; j < DIM1; j++, n++) spoints2[i][j] = (short)((i * 10 + j * 100 + n) % 8); /* Create the data space */ dims[0] = DIM0; dims[1] = DIM1; - if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; /* Construct enum type based on native type */ - if((tid = H5Tenum_create(H5T_STD_I16LE)) < 0) TEST_ERROR; + if ((tid = H5Tenum_create(H5T_STD_I16LE)) < 0) + TEST_ERROR; - for(i = 0; i < 8; i++) { - sub_colors[i * 2] = (unsigned char)i; + for (i = 0; i < 8; i++) { + sub_colors[i * 2] = (unsigned char)i; sub_colors[i * 2 + 1] = 0; - if(H5Tenum_insert(tid, mname[i], &(sub_colors[i*2])) < 0) TEST_ERROR; + if (H5Tenum_insert(tid, mname[i], &(sub_colors[i * 2])) < 0) + TEST_ERROR; } /* end for */ /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_ENUM_NAME, tid, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_ENUM_NAME, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Construct enum type based on native type in memory */ - if((tid_m = H5Tenum_create(H5T_NATIVE_SHORT)) < 0) TEST_ERROR; + if ((tid_m = H5Tenum_create(H5T_NATIVE_SHORT)) < 0) + TEST_ERROR; - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { colors[i] = (short)i; - if(H5Tenum_insert(tid_m, mname[i], &(colors[i])) < 0) TEST_ERROR; + if (H5Tenum_insert(tid_m, mname[i], &(colors[i])) < 0) + TEST_ERROR; } /* end for */ /* Write the data to the dataset */ - if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, spoints2) < 0) + if (H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, spoints2) < 0) TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR; + if (H5Tclose(tid) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_ENUM_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_ENUM_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Read the dataset back. Temporary buffer is for special platforms like * Cray */ - if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) + if (NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) TEST_ERROR; HDmemcpy(scheck2, tmp, DIM0 * DIM1 * H5Tget_size(native_type)); HDfree(tmp); tmp = NULL; - if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), scheck2, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(native_type, tid_m, (DIM0 * DIM1), scheck2, NULL, H5P_DEFAULT) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i = 0; i < DIM0; i++) - for(j = 0; j < DIM1; j++) - if(spoints2[i][j] != scheck2[i][j]) { + for (i = 0; i < DIM0; i++) + for (j = 0; j < DIM1; j++) + if (spoints2[i][j] != scheck2[i][j]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); - HDprintf(" spoints2[i][j]=%hd, scheck2[i][j]=%hd\n", spoints2[i][j], - scheck2[i][j]); + HDprintf(" spoints2[i][j]=%hd, scheck2[i][j]=%hd\n", spoints2[i][j], scheck2[i][j]); goto error; } /* end if */ @@ -1336,22 +1428,23 @@ test_enum_dtype(hid_t file) error: /* Free memory for test data */ - if(tmp) + if (tmp) HDfree(tmp); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Dclose(dataset); H5Tclose(dtype); H5Tclose(native_type); H5Tclose(tid); H5Tclose(tid_m); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_array_dtype * @@ -1372,109 +1465,124 @@ static herr_t test_array_dtype(hid_t file) { typedef struct { - char c; - int i; + char c; + int i; long long l; } s1; - hid_t dataset = -1, space = -1; - hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid3 = -1, tid_m = -1; - int i, j, k, n; - hsize_t space_dims[2], array_dims[1]={5}; - s1 *temp_point = NULL, *temp_check = NULL; - s1 *points = NULL, *check = NULL; - void *tmp = NULL; + hid_t dataset = -1, space = -1; + hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid3 = -1, tid_m = -1; + int i, j, k, n; + hsize_t space_dims[2], array_dims[1] = {5}; + s1 * temp_point = NULL, *temp_check = NULL; + s1 * points = NULL, *check = NULL; + void * tmp = NULL; TESTING("array of compound datatype"); /* Allocate space for the points & check arrays */ - if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1 * 5))) + if (NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1 * 5))) TEST_ERROR; - if(NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1 * 5))) + if (NULL == (check = (s1 *)HDcalloc(sizeof(s1), DIM0 * DIM1 * 5))) TEST_ERROR; /* Initialize the dataset */ - for(i = n = 0, temp_point = points; i < DIM0; i++) - for(j = 0; j < DIM1; j++) - for(k = 0; k < 5; k++,temp_point++) { - temp_point->c= 't'; - temp_point->i= n++; - temp_point->l= (i * 10 + j * 100) * n; + for (i = n = 0, temp_point = points; i < DIM0; i++) + for (j = 0; j < DIM1; j++) + for (k = 0; k < 5; k++, temp_point++) { + temp_point->c = 't'; + temp_point->i = n++; + temp_point->l = (i * 10 + j * 100) * n; } /* end for */ /* Create the data space */ space_dims[0] = DIM0; space_dims[1] = DIM1; - if((space = H5Screate_simple(2, space_dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(2, space_dims, NULL)) < 0) + TEST_ERROR; /* Create compound datatype for disk storage */ - if((tid2 = H5Tcreate(H5T_COMPOUND, 13)) < 0) TEST_ERROR; + if ((tid2 = H5Tcreate(H5T_COMPOUND, 13)) < 0) + TEST_ERROR; /* Insert members */ - if(H5Tinsert(tid2, "c", 0, H5T_STD_U8BE) < 0) TEST_ERROR; - if(H5Tinsert(tid2, "i", 1, H5T_STD_U32LE) < 0) TEST_ERROR; - if(H5Tinsert(tid2, "l", 5, H5T_STD_I64BE) < 0) TEST_ERROR; + if (H5Tinsert(tid2, "c", 0, H5T_STD_U8BE) < 0) + TEST_ERROR; + if (H5Tinsert(tid2, "i", 1, H5T_STD_U32LE) < 0) + TEST_ERROR; + if (H5Tinsert(tid2, "l", 5, H5T_STD_I64BE) < 0) + TEST_ERROR; /* Create array datatype for disk storage */ - if((tid = H5Tarray_create2(tid2, 1, array_dims)) < 0) TEST_ERROR; + if ((tid = H5Tarray_create2(tid2, 1, array_dims)) < 0) + TEST_ERROR; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_ARRAY_NAME, tid, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_ARRAY_NAME, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create compound datatype for datatype in memory */ - if((tid3 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR; - if(H5Tinsert(tid3, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) TEST_ERROR; - if(H5Tinsert(tid3, "i", HOFFSET(s1, i), H5T_NATIVE_UINT) < 0) TEST_ERROR; - if(H5Tinsert(tid3, "l", HOFFSET(s1, l), H5T_NATIVE_LLONG) < 0) TEST_ERROR; + if ((tid3 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) + TEST_ERROR; + if (H5Tinsert(tid3, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) + TEST_ERROR; + if (H5Tinsert(tid3, "i", HOFFSET(s1, i), H5T_NATIVE_UINT) < 0) + TEST_ERROR; + if (H5Tinsert(tid3, "l", HOFFSET(s1, l), H5T_NATIVE_LLONG) < 0) + TEST_ERROR; /* Create array datatype for memory */ - if((tid_m = H5Tarray_create2(tid3, 1, array_dims)) < 0) TEST_ERROR; + if ((tid_m = H5Tarray_create2(tid3, 1, array_dims)) < 0) + TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + if (H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR; - if(H5Tclose(tid2) < 0) TEST_ERROR; + if (H5Tclose(tid) < 0) + TEST_ERROR; + if (H5Tclose(tid2) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_ARRAY_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_ARRAY_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Read the dataset back. Temporary buffer is for special platforms like * Cray */ - if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) + if (NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) TEST_ERROR; HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type)); HDfree(tmp); tmp = NULL; - if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, NULL, H5P_DEFAULT) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++) - for(j = 0; j < DIM1; j++) - for(k = 0; k < 5; k++, temp_point++, temp_check++) - if(temp_point->c != temp_check->c || - temp_point->i != temp_check->i || - temp_point->l != temp_check->l ) { + for (i = 0, temp_point = points, temp_check = check; i < DIM0; i++) + for (j = 0; j < DIM1; j++) + for (k = 0; k < 5; k++, temp_point++, temp_check++) + if (temp_point->c != temp_check->c || temp_point->i != temp_check->i || + temp_point->l != temp_check->l) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -1482,11 +1590,16 @@ test_array_dtype(hid_t file) } /* end if */ /* Close HDF5 objects */ - if(H5Dclose(dataset)) TEST_ERROR; - if(H5Tclose(native_type)) TEST_ERROR; - if(H5Tclose(dtype)) TEST_ERROR; - if(H5Tclose(tid_m) < 0) TEST_ERROR; - if(H5Tclose(tid3) < 0) TEST_ERROR; + if (H5Dclose(dataset)) + TEST_ERROR; + if (H5Tclose(native_type)) + TEST_ERROR; + if (H5Tclose(dtype)) + TEST_ERROR; + if (H5Tclose(tid_m) < 0) + TEST_ERROR; + if (H5Tclose(tid3) < 0) + TEST_ERROR; /* Free memory for test data */ HDfree(points); @@ -1497,14 +1610,15 @@ test_array_dtype(hid_t file) error: /* Free memory for test data */ - if(tmp) + if (tmp) HDfree(tmp); - if(points) + if (points) HDfree(points); - if(check) + if (check) HDfree(check); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Dclose(dataset); H5Tclose(dtype); @@ -1513,12 +1627,12 @@ error: H5Tclose(tid2); H5Tclose(tid3); H5Tclose(tid_m); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_array_dtype2 * @@ -1538,77 +1652,84 @@ error: static herr_t test_array_dtype2(hid_t file) { - hid_t dataset = -1, space = -1; - hid_t dtype = -1, native_type = -1, tid = -1, tid_m = -1; - int i, j, k, n; - hsize_t space_dims[2], array_dims[1] = {5}; - void *tmp = NULL; + hid_t dataset = -1, space = -1; + hid_t dtype = -1, native_type = -1, tid = -1, tid_m = -1; + int i, j, k, n; + hsize_t space_dims[2], array_dims[1] = {5}; + void * tmp = NULL; TESTING("array of atomic datatype"); /* Initialize the dataset */ - for(i = n = 0;i < DIM0; i++) - for(j = 0; j < DIM1; j++) - for(k = 0; k < 5; k++) + for (i = n = 0; i < DIM0; i++) + for (j = 0; j < DIM1; j++) + for (k = 0; k < 5; k++) ipoints3[i][j][k] = n++; /* Create the data space */ space_dims[0] = DIM0; space_dims[1] = DIM1; - if((space = H5Screate_simple(2, space_dims, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(2, space_dims, NULL)) < 0) + TEST_ERROR; /* Create array datatype for disk storage */ - if((tid = H5Tarray_create2(H5T_STD_I32LE, 1, array_dims)) < 0) TEST_ERROR; + if ((tid = H5Tarray_create2(H5T_STD_I32LE, 1, array_dims)) < 0) + TEST_ERROR; /* Create the dataset */ - if((dataset = H5Dcreate2(file, DSET_ARRAY2_NAME, tid, space, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_ARRAY2_NAME, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create array datatype for memory */ - if((tid_m = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) TEST_ERROR; + if ((tid_m = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) + TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints3) < 0) + if (H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints3) < 0) TEST_ERROR; /* Close dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR; + if (H5Tclose(tid) < 0) + TEST_ERROR; /* Close dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_ARRAY2_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_ARRAY2_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Read the dataset back. Temporary buffer is for special platforms like * Cray */ - if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) + if (NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) TEST_ERROR; HDmemcpy(icheck3, tmp, DIM0 * DIM1 * H5Tget_size(native_type)); HDfree(tmp); tmp = NULL; - if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), icheck3, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(native_type, tid_m, (DIM0 * DIM1), icheck3, NULL, H5P_DEFAULT) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i = 0; i < DIM0; i++) - for(j = 0; j < DIM1; j++) - for(k = 0; k < 5; k++) - if(icheck3[i][j][k] != ipoints3[i][j][k]) { + for (i = 0; i < DIM0; i++) + for (j = 0; j < DIM1; j++) + for (k = 0; k < 5; k++) + if (icheck3[i][j][k] != ipoints3[i][j][k]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -1616,32 +1737,37 @@ test_array_dtype2(hid_t file) } /* end if */ /* Close HDF5 objects */ - if(H5Dclose(dataset)) TEST_ERROR; - if(H5Tclose(native_type)) TEST_ERROR; - if(H5Tclose(dtype)) TEST_ERROR; - if(H5Tclose(tid_m) < 0) TEST_ERROR; + if (H5Dclose(dataset)) + TEST_ERROR; + if (H5Tclose(native_type)) + TEST_ERROR; + if (H5Tclose(dtype)) + TEST_ERROR; + if (H5Tclose(tid_m) < 0) + TEST_ERROR; PASSED(); return 0; error: /* Free memory for test data */ - if(tmp) + if (tmp) HDfree(tmp); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Dclose(dataset); H5Tclose(dtype); H5Tclose(native_type); H5Tclose(tid); H5Tclose(tid_m); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_vl_dtype * @@ -1661,153 +1787,175 @@ error: static herr_t test_vl_dtype(hid_t file) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hvl_t *t1, *t2; /* Temporary pointer to VL information */ - hsize_t dims1[] = {SPACE1_DIM1}; - hid_t dataset = -1, space = -1; - hid_t dtype = -1, native_type = -1, nat_super_type = -1, tid = -1, tid2 = -1, tid_m = -1, tid_m2 = -1; - size_t i, j, k; - void **tmp = NULL; + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hvl_t * t1, *t2; /* Temporary pointer to VL information */ + hsize_t dims1[] = {SPACE1_DIM1}; + hid_t dataset = -1, space = -1; + hid_t dtype = -1, native_type = -1, nat_super_type = -1, tid = -1, tid2 = -1, tid_m = -1, tid_m2 = -1; + size_t i, j, k; + void ** tmp = NULL; TESTING("variable length datatype"); /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { wdata[i].p = HDmalloc((i + 1) * sizeof(hvl_t)); - if(NULL == wdata[i].p) { + if (NULL == wdata[i].p) { H5_FAILED(); - HDprintf(" Cannot allocate memory for VL data! i=%u\n",(unsigned)i); + HDprintf(" Cannot allocate memory for VL data! i=%u\n", (unsigned)i); goto error; } /* end if */ wdata[i].len = i + 1; - for(t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) { + for (t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) { t1->p = HDmalloc((j + 1) * sizeof(unsigned int)); - if(NULL == t1->p) { + if (NULL == t1->p) { H5_FAILED(); - HDprintf(" Cannot allocate memory for VL data! i=%u, j=%u\n",(unsigned)i,(unsigned)j); + HDprintf(" Cannot allocate memory for VL data! i=%u, j=%u\n", (unsigned)i, (unsigned)j); goto error; } /* end if */ t1->len = j + 1; - for(k = 0; k < (j + 1); k++) + for (k = 0; k < (j + 1); k++) ((unsigned int *)t1->p)[k] = (unsigned int)(i * 100 + j * 10 + k); } /* end for */ - } /* end for */ + } /* end for */ /* Create dataspace for datasets */ - if((space = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) + TEST_ERROR; /* Create the base VL type */ - if((tid2 = H5Tvlen_create (H5T_STD_U32LE)) < 0) TEST_ERROR; + if ((tid2 = H5Tvlen_create(H5T_STD_U32LE)) < 0) + TEST_ERROR; /* Create a VL datatype for disk storage */ - if((tid = H5Tvlen_create(tid2)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(tid2)) < 0) + TEST_ERROR /* Create a dataset */ - if((dataset = H5Dcreate2(file, DSET_VL_NAME, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET_VL_NAME, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create a base VL datatype for memory */ - if((tid_m2 = H5Tvlen_create(H5T_NATIVE_UINT)) < 0) TEST_ERROR; + if ((tid_m2 = H5Tvlen_create(H5T_NATIVE_UINT)) < 0) + TEST_ERROR; /* Create a VL datatype for memory */ - if((tid_m = H5Tvlen_create (tid_m2)) < 0) TEST_ERROR; + if ((tid_m = H5Tvlen_create(tid_m2)) < 0) + TEST_ERROR; /* Write dataset to disk */ - if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR; + if (H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) + TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR; - if(H5Tclose(tid) < 0) TEST_ERROR; + if (H5Tclose(tid2) < 0) + TEST_ERROR; + if (H5Tclose(tid) < 0) + TEST_ERROR; /* Open a dataset */ - if((dataset = H5Dopen2(file, DSET_VL_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_VL_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Get native datatype for dataset */ - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Also get native base type for this nested VL type. Should be an integer type. */ - if((nat_super_type = H5Tget_super(native_type)) < 0) + if ((nat_super_type = H5Tget_super(native_type)) < 0) TEST_ERROR; - if((nat_super_type = H5Tget_super(nat_super_type)) < 0) + if ((nat_super_type = H5Tget_super(nat_super_type)) < 0) TEST_ERROR; /* Read dataset from disk */ - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR; + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) + TEST_ERROR; /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) { - if(wdata[i].len != rdata[i].len) { + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].len != rdata[i].len) { H5_FAILED(); - HDprintf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + HDprintf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", (int)i, + (int)wdata[i].len, (int)i, (int)rdata[i].len); goto error; } /* end if */ - for(t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)rdata[i].p, j = 0; j < rdata[i].len; j++, t1++, t2++) { - if(t1->len != t2->len) { + for (t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)rdata[i].p, j = 0; j < rdata[i].len; j++, t1++, t2++) { + if (t1->len != t2->len) { H5_FAILED(); - HDprintf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len); + HDprintf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n", (int)i, + (int)wdata[i].len, (int)i, (int)rdata[i].len); goto error; } /* end if */ /* use temporary buffer to convert datatype. This is for special * platforms like Cray */ - if(NULL == (tmp = (void **)HDmalloc(t2->len * sizeof(unsigned int)))) + if (NULL == (tmp = (void **)HDmalloc(t2->len * sizeof(unsigned int)))) TEST_ERROR HDmemcpy(tmp, t2->p, t2->len * H5Tget_size(nat_super_type)); - if(H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT) < 0) TEST_ERROR; - for(k = 0; k < t2->len; k++) { - if(((unsigned int *)t1->p)[k] != ((unsigned int *)tmp)[k]) { + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)tmp)[k]) { H5_FAILED(); - HDprintf(" VL data don't match!, wdata[%u].p=%d, rdata[%u].p=%u\n", - (unsigned)i, ((unsigned int*)t1->p)[k], (unsigned)i, ((unsigned int*)tmp)[k]); + HDprintf(" VL data don't match!, wdata[%u].p=%d, rdata[%u].p=%u\n", (unsigned)i, + ((unsigned int *)t1->p)[k], (unsigned)i, ((unsigned int *)tmp)[k]); goto error; } /* end if */ - } /* end for */ + } /* end for */ HDfree(tmp); tmp = NULL; } /* end for */ - } /* end for */ + } /* end for */ /* Reclaim the read VL data */ - if(H5Treclaim(native_type, space, H5P_DEFAULT, rdata) < 0) TEST_ERROR; + if (H5Treclaim(native_type, space, H5P_DEFAULT, rdata) < 0) + TEST_ERROR; /* Reclaim the write VL data */ - if(H5Treclaim(native_type, space, H5P_DEFAULT, wdata) < 0) TEST_ERROR; + if (H5Treclaim(native_type, space, H5P_DEFAULT, wdata) < 0) + TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(native_type) < 0) TEST_ERROR; - native_type = -1; /* reset so that error handling can check for VL reclaim */ - if(H5Tclose(dtype) < 0) TEST_ERROR; - if(H5Tclose(tid_m) < 0) TEST_ERROR; - if(H5Tclose(tid_m2) < 0) TEST_ERROR; - + if (H5Tclose(native_type) < 0) + TEST_ERROR; + native_type = -1; /* reset so that error handling can check for VL reclaim */ + if (H5Tclose(dtype) < 0) + TEST_ERROR; + if (H5Tclose(tid_m) < 0) + TEST_ERROR; + if (H5Tclose(tid_m2) < 0) + TEST_ERROR; /* Close disk dataspace */ - if(H5Sclose(space) < 0) TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; PASSED(); return 0; error: /* Free memory for test data */ - if(tmp) + if (tmp) HDfree(tmp); - H5E_BEGIN_TRY { - if(native_type > 0) { + H5E_BEGIN_TRY + { + if (native_type > 0) { H5Treclaim(native_type, space, H5P_DEFAULT, rdata); H5Treclaim(native_type, space, H5P_DEFAULT, wdata); } /* end if */ @@ -1820,12 +1968,12 @@ error: H5Tclose(tid2); H5Tclose(tid_m); H5Tclose(tid_m2); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_vl_type() */ - /*------------------------------------------------------------------------- * Function: test_vlstr_dtype * @@ -1845,88 +1993,103 @@ error: static herr_t test_vlstr_dtype(hid_t file) { - const char *wdata[SPACE1_DIM1]= { - "Four score and seven years ago our forefathers brought forth on this continent a new nation,", - "conceived in liberty and dedicated to the proposition that all men are created equal.", - "Now we are engaged in a great civil war,", - "testing whether that nation or any nation so conceived and so dedicated can long endure." - }; /* Information to write */ - char *rdata[SPACE1_DIM1]; /* Information read in */ - hbool_t rdata_alloc = FALSE; /* Whether the read data is allocated */ - hid_t dataset = -1; /* Dataset ID */ - hid_t sid1 = -1; /* Dataspace ID */ - hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i; /* counting variable */ + const char *wdata[SPACE1_DIM1] = { + "Four score and seven years ago our forefathers brought forth on this continent a new nation,", + "conceived in liberty and dedicated to the proposition that all men are created equal.", + "Now we are engaged in a great civil war,", + "testing whether that nation or any nation so conceived and so dedicated can long endure."}; /* Information + to + write + */ + char * rdata[SPACE1_DIM1]; /* Information read in */ + hbool_t rdata_alloc = FALSE; /* Whether the read data is allocated */ + hid_t dataset = -1; /* Dataset ID */ + hid_t sid1 = -1; /* Dataspace ID */ + hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + unsigned i; /* counting variable */ /* Output message about test being performed */ TESTING("variable length string datatype"); /* Create dataspace for datasets */ - if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) TEST_ERROR; + if ((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) + TEST_ERROR; /* Create a datatype to refer to */ - if((tid1 = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR; + if ((tid1 = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR; - if(H5Tset_size(tid1,H5T_VARIABLE) < 0) TEST_ERROR; - if(H5T_STRING != H5Tget_class(tid1) || !H5Tis_variable_str(tid1)) + if (H5Tset_size(tid1, H5T_VARIABLE) < 0) + TEST_ERROR; + if (H5T_STRING != H5Tget_class(tid1) || !H5Tis_variable_str(tid1)) TEST_ERROR; /* Create a dataset */ - if((dataset = H5Dcreate2(file, DSET_VLSTR_NAME, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dcreate2(file, DSET_VLSTR_NAME, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Write dataset to disk */ - if(H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR; + if (H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) + TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Open a dataset */ - if((dataset = H5Dopen2(file, DSET_VLSTR_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_VLSTR_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Get datatype for dataset */ - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; /* Construct native type */ - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Check if the data type is equal */ - if(!H5Tequal(native_type, tid1)) + if (!H5Tequal(native_type, tid1)) TEST_ERROR; /* Read dataset from disk */ - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR; + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) + TEST_ERROR; rdata_alloc = TRUE; /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) { - if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) { + for (i = 0; i < SPACE1_DIM1; i++) { + if (HDstrlen(wdata[i]) != HDstrlen(rdata[i])) { H5_FAILED(); - HDprintf(" VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", - (int)i, (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i])); + HDprintf(" VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", (int)i, + (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i])); goto error; } /* end if */ - if(HDstrcmp(wdata[i], rdata[i]) != 0 ) { + if (HDstrcmp(wdata[i], rdata[i]) != 0) { H5_FAILED(); - HDprintf(" VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", - (int)i, wdata[i], (int)i, rdata[i]); + HDprintf(" VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i], + (int)i, rdata[i]); goto error; } /* end if */ - } /* end for */ + } /* end for */ /* Close Dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid1) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; + if (H5Tclose(tid1) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; /* Close disk dataspace */ - if(H5Sclose(sid1) < 0) TEST_ERROR; + if (H5Sclose(sid1) < 0) + TEST_ERROR; /* Free memory for rdata */ - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) HDfree(rdata[i]); rdata_alloc = FALSE; @@ -1934,24 +2097,25 @@ test_vlstr_dtype(hid_t file) return 0; error: - if(rdata_alloc) { + if (rdata_alloc) { /* Free memory for rdata */ - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) HDfree(rdata[i]); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Tclose(dtype); H5Tclose(native_type); H5Tclose(sid1); H5Tclose(tid1); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_vlstr_dtype() */ - /*------------------------------------------------------------------------- * Function: test_str_dtype * @@ -1971,99 +2135,109 @@ error: static herr_t test_str_dtype(hid_t file) { - const char wdata[SPACE1_DIM1][4]= { - "one", - "two", - "3rd", - "4th" - }; /* Information to write */ - char rdata[SPACE1_DIM1][4]; /* Information read in */ - hid_t dataset = -1; /* Dataset ID */ - hid_t sid1 = -1; /* Dataspace ID */ - hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i; /* counting variable */ + const char wdata[SPACE1_DIM1][4] = {"one", "two", "3rd", "4th"}; /* Information to write */ + char rdata[SPACE1_DIM1][4]; /* Information read in */ + hid_t dataset = -1; /* Dataset ID */ + hid_t sid1 = -1; /* Dataspace ID */ + hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + unsigned i; /* counting variable */ /* Output message about test being performed */ TESTING("fixed-length string datatype"); /* Create dataspace for datasets */ - if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) TEST_ERROR; + if ((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) + TEST_ERROR; /* Create a datatype to refer to */ - if((tid1 = H5Tcopy (H5T_C_S1)) < 0) TEST_ERROR; + if ((tid1 = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR; - if(H5Tset_size(tid1, 4) < 0) TEST_ERROR; - if(H5T_STRING != H5Tget_class(tid1)) TEST_ERROR; + if (H5Tset_size(tid1, 4) < 0) + TEST_ERROR; + if (H5T_STRING != H5Tget_class(tid1)) + TEST_ERROR; /* Create a dataset */ - if((dataset = H5Dcreate2(file, DSET_STR_NAME, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dcreate2(file, DSET_STR_NAME, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Write dataset to disk */ - if(H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR; + if (H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) + TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Open a dataset */ - if((dataset = H5Dopen2(file, DSET_STR_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_STR_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; /* Get datatype for dataset */ - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; /* Construct native type */ - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Check if the data type is equal */ - if(!H5Tequal(native_type, tid1) || H5T_STRING!=H5Tget_class(native_type)) + if (!H5Tequal(native_type, tid1) || H5T_STRING != H5Tget_class(native_type)) TEST_ERROR; /* Read dataset from disk */ - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR; + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) + TEST_ERROR; /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) { - if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) { + for (i = 0; i < SPACE1_DIM1; i++) { + if (HDstrlen(wdata[i]) != HDstrlen(rdata[i])) { H5_FAILED(); - HDprintf(" data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", - (int)i, (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i])); + HDprintf(" data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", (int)i, + (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i])); goto error; } /* end if */ - if(HDstrcmp(wdata[i], rdata[i]) != 0 ) { + if (HDstrcmp(wdata[i], rdata[i]) != 0) { H5_FAILED(); - HDprintf(" data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", - (int)i, wdata[i], (int)i, rdata[i]); + HDprintf(" data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i], (int)i, + rdata[i]); goto error; } /* end if */ - } /* end for */ + } /* end for */ /* Close Dataset */ - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid1) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; + if (H5Tclose(tid1) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; /* Close disk dataspace */ - if(H5Sclose(sid1) < 0) TEST_ERROR; + if (H5Sclose(sid1) < 0) + TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Tclose(dtype); H5Tclose(native_type); H5Tclose(tid1); H5Tclose(sid1); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_str_dtype() */ - /*------------------------------------------------------------------------- * Function: test_refer_dtype * @@ -2087,124 +2261,126 @@ test_refer_dtype(hid_t file) typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; - hid_t dataset = -1; /* Dataset ID */ - hid_t group = -1; /* Group ID */ - hid_t sid1 = -1; /* Dataspace ID */ - hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */ - hsize_t dims1[] = {1}; - H5O_type_t obj_type; /* Object type */ - hobj_ref_t *wbuf = NULL, /* buffer to write to disk */ - *rbuf = NULL; /* buffer read from disk */ + hid_t dataset = -1; /* Dataset ID */ + hid_t group = -1; /* Group ID */ + hid_t sid1 = -1; /* Dataspace ID */ + hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */ + hsize_t dims1[] = {1}; + H5O_type_t obj_type; /* Object type */ + hobj_ref_t *wbuf = NULL, /* buffer to write to disk */ + *rbuf = NULL; /* buffer read from disk */ /* Output message about test being performed */ TESTING("reference datatype"); /* Allocate write & read buffers */ - if(NULL == (wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t))))) + if (NULL == (wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t))))) TEST_ERROR - if(NULL == (rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t))))) + if (NULL == (rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t))))) TEST_ERROR /* Create dataspace for datasets */ - if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) + if ((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) TEST_ERROR; /* Create a group */ - if((group = H5Gcreate2(file, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group = H5Gcreate2(file, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a datatype to refer to */ - if((tid1 = H5Tcreate (H5T_COMPOUND, sizeof(s1_t))) < 0) + if ((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0) TEST_ERROR; /* Insert fields */ - if(H5Tinsert (tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT) < 0) + if (H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR; - if(H5Tinsert (tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0) + if (H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT) < 0) TEST_ERROR; - if(H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) + if (H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) TEST_ERROR; /* Save datatype for later */ - if(H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid1) < 0) + if (H5Tclose(tid1) < 0) TEST_ERROR; /* Close group */ - if(H5Gclose(group) < 0) + if (H5Gclose(group) < 0) TEST_ERROR; /* Create a dataset */ - if((dataset = H5Dcreate2(file, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dataset = + H5Dcreate2(file, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create reference to named datatype */ - if(H5Rcreate(wbuf, file, "/Group1/Datatype1", H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(wbuf, file, "/Group1/Datatype1", H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR; - if(H5Rget_obj_type2(dataset, H5R_OBJECT, wbuf, &obj_type) < 0) + if (H5Rget_obj_type2(dataset, H5R_OBJECT, wbuf, &obj_type) < 0) TEST_ERROR; - if(obj_type != H5O_TYPE_NAMED_DATATYPE) + if (obj_type != H5O_TYPE_NAMED_DATATYPE) TEST_ERROR; /* Write selection to disk */ - if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; /* Close disk dataspace */ - if(H5Sclose(sid1) < 0) + if (H5Sclose(sid1) < 0) TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; /* Open the dataset */ - if((dataset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0) TEST_ERROR; /* Get datatype for dataset */ - if((dtype = H5Dget_type(dataset)) < 0) + if ((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; /* Construct native type */ - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Check if the data type is equal */ - if(!H5Tequal(native_type, H5T_STD_REF_OBJ)) + if (!H5Tequal(native_type, H5T_STD_REF_OBJ)) TEST_ERROR; /* Read selection from disk */ - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; /* Open datatype object */ - if((tid1 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, rbuf)) < 0) + if ((tid1 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, rbuf)) < 0) TEST_ERROR; /* Verify correct datatype */ - if(H5Tget_class(tid1) != H5T_COMPOUND) + if (H5Tget_class(tid1) != H5T_COMPOUND) TEST_ERROR; - if(H5Tget_nmembers(tid1)!=3) + if (H5Tget_nmembers(tid1) != 3) TEST_ERROR; /* Close datatype */ - if(H5Tclose(tid1) < 0) + if (H5Tclose(tid1) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) + if (H5Tclose(native_type) < 0) TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; /* Free memory buffers */ @@ -2216,24 +2392,25 @@ test_refer_dtype(hid_t file) return 0; error: - if(wbuf) + if (wbuf) HDfree(wbuf); - if(rbuf) + if (rbuf) HDfree(rbuf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid1); H5Gclose(group); H5Tclose(tid1); H5Tclose(dtype); H5Tclose(native_type); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; -} /* test_refer_dtype() */ +} /* test_refer_dtype() */ - /*------------------------------------------------------------------------- * Function: test_refer_dtype2 * @@ -2253,172 +2430,171 @@ error: static herr_t test_refer_dtype2(hid_t file) { - hid_t dset1 = -1, /* Dataset ID */ - dset2 = -1; /* Dereferenced dataset ID */ - hid_t sid1 = -1, /* Dataspace ID #1 */ - sid2 = -1; /* Dataspace ID #2 */ + hid_t dset1 = -1, /* Dataset ID */ + dset2 = -1; /* Dereferenced dataset ID */ + hid_t sid1 = -1, /* Dataspace ID #1 */ + sid2 = -1; /* Dataspace ID #2 */ hid_t dtype = -1, native_type = -1; - hsize_t dims1[] = { 1 }, dims2[] = { SPACE2_DIM1, SPACE2_DIM2 }; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hdset_reg_ref_t wbuf, /* buffer to write to disk */ - rbuf; /* buffer read from disk */ - uint8_t *dwbuf = NULL, /* Buffer for writing numeric data to disk */ - *drbuf = NULL; /* Buffer for reading numeric data from disk */ - uint8_t *tu8 = NULL; /* Temporary pointer to uint8 data */ - H5O_type_t obj_type; /* Object type */ - int i; /* counting variables */ + hsize_t dims1[] = {1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hdset_reg_ref_t wbuf, /* buffer to write to disk */ + rbuf; /* buffer read from disk */ + uint8_t *dwbuf = NULL, /* Buffer for writing numeric data to disk */ + *drbuf = NULL; /* Buffer for reading numeric data from disk */ + uint8_t * tu8 = NULL; /* Temporary pointer to uint8 data */ + H5O_type_t obj_type; /* Object type */ + int i; /* counting variables */ /* Output message about test being performed */ TESTING("dataset region reference"); /* Allocate write & read buffers */ - if(NULL == (dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2))) + if (NULL == (dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2))) TEST_ERROR - if(NULL == (drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2))) + if (NULL == (drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2))) TEST_ERROR /* Create dataspace for datasets */ - if((sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL)) < 0) + if ((sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL)) < 0) TEST_ERROR; /* Create a dataset */ - if((dset2 = H5Dcreate2(file, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset2 = H5Dcreate2(file, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) + for (tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ - if(H5Dwrite(dset2, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf) < 0) + if (H5Dwrite(dset2, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf) < 0) TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dset2) < 0) + if (H5Dclose(dset2) < 0) TEST_ERROR; /* Create dataspace for the reference dataset */ - if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) + if ((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) TEST_ERROR; /* Create a reference dataset */ - if((dset1 = H5Dcreate2(file, "Dataset1", H5T_STD_REF_DSETREG, sid1, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset1 = H5Dcreate2(file, "Dataset1", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; /* Create references */ /* Select 6x6 hyperslab for first reference */ - start[0] = 2; - start[1] = 2; + start[0] = 2; + start[1] = 2; stride[0] = 1; stride[1] = 1; - count[0] = 1; - count[1] = 1; - block[0] = 6; - block[1] = 6; + count[0] = 1; + count[1] = 1; + block[0] = 6; + block[1] = 6; - if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR; - if((int)H5Sget_select_npoints(sid2) != 36) + if ((int)H5Sget_select_npoints(sid2) != 36) TEST_ERROR; /* Store first dataset region */ - if(H5Rcreate(&wbuf, file, "/Dataset2", H5R_DATASET_REGION, sid2) < 0) + if (H5Rcreate(&wbuf, file, "/Dataset2", H5R_DATASET_REGION, sid2) < 0) TEST_ERROR; - if(H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &wbuf, &obj_type) < 0) + if (H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &wbuf, &obj_type) < 0) TEST_ERROR; - if(obj_type != H5O_TYPE_DATASET) + if (obj_type != H5O_TYPE_DATASET) TEST_ERROR; /* Write selection to disk */ - if(H5Dwrite(dset1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + if (H5Dwrite(dset1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) TEST_ERROR; /* Close disk dataspace */ - if(H5Sclose(sid1) < 0) + if (H5Sclose(sid1) < 0) TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dset1) < 0) + if (H5Dclose(dset1) < 0) TEST_ERROR; /* Close uint8 dataset dataspace */ - if(H5Sclose(sid2) < 0) + if (H5Sclose(sid2) < 0) TEST_ERROR; /* Open the dataset */ - if((dset1 = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0) + if ((dset1 = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0) TEST_ERROR; /* Get datatype for dataset */ - if((dtype = H5Dget_type(dset1)) < 0) + if ((dtype = H5Dget_type(dset1)) < 0) TEST_ERROR; /* Construct native type */ - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; /* Check if the data type is equal */ - if(!H5Tequal(native_type, H5T_STD_REF_DSETREG)) + if (!H5Tequal(native_type, H5T_STD_REF_DSETREG)) TEST_ERROR; /* Read selection from disk */ - if(H5Dread(dset1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + if (H5Dread(dset1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) TEST_ERROR; /* Try to open objects */ - if((dset2 = H5Rdereference2(dset1, H5P_DEFAULT, H5R_DATASET_REGION, &rbuf)) < 0) + if ((dset2 = H5Rdereference2(dset1, H5P_DEFAULT, H5R_DATASET_REGION, &rbuf)) < 0) TEST_ERROR; /* Check what H5Rget_obj_type2 function returns */ - if(H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &rbuf, &obj_type) < 0) + if (H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &rbuf, &obj_type) < 0) TEST_ERROR; - if(obj_type != H5O_TYPE_DATASET) + if (obj_type != H5O_TYPE_DATASET) TEST_ERROR; /* Check information in referenced dataset */ - if((sid1 = H5Dget_space(dset2)) < 0) + if ((sid1 = H5Dget_space(dset2)) < 0) TEST_ERROR; - if((int)H5Sget_simple_extent_npoints(sid1) != 100) + if ((int)H5Sget_simple_extent_npoints(sid1) != 100) TEST_ERROR; /* Read from disk */ - if(H5Dread(dset2, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf) < 0) + if (H5Dread(dset2, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf) < 0) TEST_ERROR; - for(tu8 = (uint8_t *)drbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++, tu8++) - if(*tu8 != (uint8_t)(i * 3)) + for (tu8 = (uint8_t *)drbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++, tu8++) + if (*tu8 != (uint8_t)(i * 3)) TEST_ERROR; /* Get the hyperslab selection */ - if((sid2 = H5Rget_region(dset1, H5R_DATASET_REGION, &rbuf)) < 0) + if ((sid2 = H5Rget_region(dset1, H5R_DATASET_REGION, &rbuf)) < 0) TEST_ERROR; /* Verify correct hyperslab selected */ - if((int)H5Sget_select_npoints(sid2) != 36) + if ((int)H5Sget_select_npoints(sid2) != 36) TEST_ERROR; - if((int)H5Sget_select_hyper_nblocks(sid2) != 1) + if ((int)H5Sget_select_hyper_nblocks(sid2) != 1) TEST_ERROR; /* Close region space */ - if(H5Sclose(sid2) < 0) + if (H5Sclose(sid2) < 0) TEST_ERROR; /* Close first space */ - if(H5Sclose(sid1) < 0) + if (H5Sclose(sid1) < 0) TEST_ERROR; /* Close dereferenced Dataset */ - if(H5Dclose(dset2) < 0) + if (H5Dclose(dset2) < 0) TEST_ERROR; /* Close Dataset */ - if(H5Dclose(dset1) < 0) + if (H5Dclose(dset1) < 0) TEST_ERROR; /* Free memory buffers */ @@ -2430,24 +2606,25 @@ test_refer_dtype2(hid_t file) error: /* Free memory buffers */ - if(dwbuf) + if (dwbuf) HDfree(dwbuf); - if(drbuf) + if (drbuf) HDfree(drbuf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid2); H5Sclose(sid1); H5Tclose(dtype); H5Tclose(native_type); H5Dclose(dset2); H5Dclose(dset1); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; -} /* test_refer_dtype2() */ +} /* test_refer_dtype2() */ - /*------------------------------------------------------------------------- * Function: test_opaque_dtype * @@ -2467,73 +2644,86 @@ error: static herr_t test_opaque_dtype(hid_t file) { - hid_t type = -1, space = -1, dset = -1; - hid_t dataset = -1, dtype = -1, native_type = -1; - size_t i; - unsigned char wbuf[32], rbuf[32]; - hsize_t nelmts; + hid_t type = -1, space = -1, dset = -1; + hid_t dataset = -1, dtype = -1, native_type = -1; + size_t i; + unsigned char wbuf[32], rbuf[32]; + hsize_t nelmts; TESTING("opaque datatype"); /* opaque_1 */ nelmts = sizeof(wbuf); - if((type = H5Tcreate(H5T_OPAQUE, 1)) < 0) TEST_ERROR; - if(H5Tset_tag(type, "testing 1-byte opaque type") < 0) TEST_ERROR; - if((space = H5Screate_simple(1, &nelmts, NULL)) < 0) TEST_ERROR; - if((dset = H5Dcreate2(file, DSET_OPAQUE_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((type = H5Tcreate(H5T_OPAQUE, 1)) < 0) + TEST_ERROR; + if (H5Tset_tag(type, "testing 1-byte opaque type") < 0) + TEST_ERROR; + if ((space = H5Screate_simple(1, &nelmts, NULL)) < 0) + TEST_ERROR; + if ((dset = H5Dcreate2(file, DSET_OPAQUE_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - for(i = 0; i < sizeof(wbuf); i++) + for (i = 0; i < sizeof(wbuf); i++) wbuf[i] = (unsigned char)(0xff ^ i); - if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; - if(H5Sclose(space) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) TEST_ERROR; - + if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Dclose(dset) < 0) + TEST_ERROR; /* Open dataset again to check H5Tget_native_type */ - if((dataset = H5Dopen2(file, DSET_OPAQUE_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset = H5Dopen2(file, DSET_OPAQUE_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; - if(!H5Tequal(native_type, type)) TEST_ERROR; + if (!H5Tequal(native_type, type)) + TEST_ERROR; - if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; - for(i = 0; i < sizeof(rbuf); i++) - if(rbuf[i] != wbuf[i]) { + for (i = 0; i < sizeof(rbuf); i++) + if (rbuf[i] != wbuf[i]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %u\n", (unsigned)i); goto error; } /* end if */ - if(H5Tclose(type) < 0) TEST_ERROR; - if(H5Tclose(dtype) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) TEST_ERROR; + if (H5Tclose(type) < 0) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Tclose(type); H5Tclose(dtype); H5Tclose(native_type); H5Dclose(dset); H5Dclose(dataset); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_opaque_dtype */ - /*------------------------------------------------------------------------- * Function: test_bitfield_dtype * @@ -2556,61 +2746,76 @@ error: static herr_t test_bitfield_dtype(hid_t file) { - hid_t type=-1, space=-1, dset1=-1, dset2=-1; - hid_t dataset1=-1, dataset2=-1, dtype=-1, native_type=-1; - size_t ntype_size, i; - unsigned char wbuf[BITFIELD_ENUMB*sizeof(int)]; - unsigned char *p=NULL; - void *rbuf = NULL; - unsigned int intw[BITFIELD_ENUMB], intr[BITFIELD_ENUMB]; - hsize_t nelmts; + hid_t type = -1, space = -1, dset1 = -1, dset2 = -1; + hid_t dataset1 = -1, dataset2 = -1, dtype = -1, native_type = -1; + size_t ntype_size, i; + unsigned char wbuf[BITFIELD_ENUMB * sizeof(int)]; + unsigned char *p = NULL; + void * rbuf = NULL; + unsigned int intw[BITFIELD_ENUMB], intr[BITFIELD_ENUMB]; + hsize_t nelmts; TESTING("bitfield datatype"); nelmts = BITFIELD_ENUMB; - if((type = H5Tcopy(H5T_STD_B32BE)) < 0) TEST_ERROR; + if ((type = H5Tcopy(H5T_STD_B32BE)) < 0) + TEST_ERROR; - if((space = H5Screate_simple(1, &nelmts, NULL)) < 0) TEST_ERROR; + if ((space = H5Screate_simple(1, &nelmts, NULL)) < 0) + TEST_ERROR; /* Create and write to dataset1 with a unsigned char buffer */ - if((dset1 = H5Dcreate2(file, DSET1_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dset1 = H5Dcreate2(file, DSET1_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR; - for(i = 0; i < BITFIELD_ENUMB*sizeof(int); i++) + for (i = 0; i < BITFIELD_ENUMB * sizeof(int); i++) wbuf[i] = (unsigned char)((unsigned int)0xff ^ (unsigned int)i); - if(H5Dwrite(dset1, H5T_NATIVE_B32, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; - if(H5Dclose(dset1) < 0) TEST_ERROR; + if (H5Dwrite(dset1, H5T_NATIVE_B32, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + TEST_ERROR; + if (H5Dclose(dset1) < 0) + TEST_ERROR; /* Create and write to dataset2 with a unsigned int buffer */ - if((dset2 = H5Dcreate2(file, DSET2_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dset2 = H5Dcreate2(file, DSET2_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR; - for(i = 0; i < BITFIELD_ENUMB; i++) - intw[i] = (unsigned int)0xff << (unsigned int)((i*8)%32); + for (i = 0; i < BITFIELD_ENUMB; i++) + intw[i] = (unsigned int)0xff << (unsigned int)((i * 8) % 32); - if(H5Dwrite(dset2, H5T_NATIVE_B32, H5S_ALL, H5S_ALL, H5P_DEFAULT, intw) < 0) TEST_ERROR; - if(H5Dclose(dset2) < 0) TEST_ERROR; - if(H5Sclose(space) < 0) TEST_ERROR; - if(H5Tclose(type) < 0) TEST_ERROR; + if (H5Dwrite(dset2, H5T_NATIVE_B32, H5S_ALL, H5S_ALL, H5P_DEFAULT, intw) < 0) + TEST_ERROR; + if (H5Dclose(dset2) < 0) + TEST_ERROR; + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Tclose(type) < 0) + TEST_ERROR; /* Open dataset1 again to check H5Tget_native_type */ - if((dataset1 = H5Dopen2(file, DSET1_BITFIELD_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset1 = H5Dopen2(file, DSET1_BITFIELD_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset1)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset1)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + TEST_ERROR; - if((ntype_size = H5Tget_size(native_type)) == 0) TEST_ERROR; + if ((ntype_size = H5Tget_size(native_type)) == 0) + TEST_ERROR; - rbuf = HDmalloc((size_t)nelmts*ntype_size); + rbuf = HDmalloc((size_t)nelmts * ntype_size); /* Read the data and compare them */ - if(H5Dread(dataset1, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; + if (H5Dread(dataset1, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR; p = (unsigned char *)rbuf; - for(i = 0; i < BITFIELD_ENUMB*4; i++) { - if(*p != wbuf[i]) { + for (i = 0; i < BITFIELD_ENUMB * 4; i++) { + if (*p != wbuf[i]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %zu\n", i); @@ -2619,23 +2824,31 @@ test_bitfield_dtype(hid_t file) p++; } - if(H5Tclose(dtype) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; - if(H5Dclose(dataset1) < 0) TEST_ERROR; - if(rbuf) HDfree(rbuf); + if (H5Tclose(dtype) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Dclose(dataset1) < 0) + TEST_ERROR; + if (rbuf) + HDfree(rbuf); /* Open dataset2 again to check H5Tget_native_type */ - if((dataset2 = H5Dopen2(file, DSET2_BITFIELD_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; + if ((dataset2 = H5Dopen2(file, DSET2_BITFIELD_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; - if((dtype = H5Dget_type(dataset2)) < 0) TEST_ERROR; + if ((dtype = H5Dget_type(dataset2)) < 0) + TEST_ERROR; - if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + TEST_ERROR; /* Read the data and compare them */ - if(H5Dread(dataset2, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, intr) < 0) TEST_ERROR; + if (H5Dread(dataset2, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, intr) < 0) + TEST_ERROR; - for(i = 0; i < BITFIELD_ENUMB; i++) { - if(intr[i] != intw[i]) { + for (i = 0; i < BITFIELD_ENUMB; i++) { + if (intr[i] != intw[i]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %zu\n", i); @@ -2643,15 +2856,19 @@ test_bitfield_dtype(hid_t file) } } - if(H5Tclose(dtype) < 0) TEST_ERROR; - if(H5Tclose(native_type) < 0) TEST_ERROR; - if(H5Dclose(dataset2) < 0) TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Dclose(dataset2) < 0) + TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Tclose(type); H5Tclose(dtype); @@ -2660,12 +2877,12 @@ error: H5Dclose(dset2); H5Dclose(dataset1); H5Dclose(dataset2); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_bitfield_dtype */ - /*------------------------------------------------------------------------- * Function: test_ninteger * @@ -2685,27 +2902,27 @@ error: static herr_t test_ninteger(void) { - hid_t fid1 = -1; /* file ID */ - hid_t fid2 = -1; /* file ID */ - hid_t did1 = -1; /* dataset ID */ - hid_t did2 = -1; /* dataset ID */ - hid_t sid1 = -1; /* dataspace ID */ - hid_t dcpl1 = -1; /* dataset creation property list ID */ - hid_t dcpl2 = -1; /* dataset creation property list ID */ - hid_t tid1 = -1; /* file datatype */ - hid_t tid2 = -1; /* file datatype */ - hid_t nid1 = -1; /* native datatype */ - hid_t nid2 = -1; /* native datatype */ - hsize_t dims[1] = {DIM3}; /* dataspace dimensions */ - hsize_t nelmts; /* number of elements in dataset */ - int rank = 1; /* rank of dataset */ - int buf[DIM3]; - int chk[DIM3]; - int i; + hid_t fid1 = -1; /* file ID */ + hid_t fid2 = -1; /* file ID */ + hid_t did1 = -1; /* dataset ID */ + hid_t did2 = -1; /* dataset ID */ + hid_t sid1 = -1; /* dataspace ID */ + hid_t dcpl1 = -1; /* dataset creation property list ID */ + hid_t dcpl2 = -1; /* dataset creation property list ID */ + hid_t tid1 = -1; /* file datatype */ + hid_t tid2 = -1; /* file datatype */ + hid_t nid1 = -1; /* native datatype */ + hid_t nid2 = -1; /* native datatype */ + hsize_t dims[1] = {DIM3}; /* dataspace dimensions */ + hsize_t nelmts; /* number of elements in dataset */ + int rank = 1; /* rank of dataset */ + int buf[DIM3]; + int chk[DIM3]; + int i; TESTING("native integer "); - for(i = 0; i < DIM3; i++) + for (i = 0; i < DIM3; i++) buf[i] = i; /*------------------------------------------------------------------------- @@ -2713,26 +2930,34 @@ test_ninteger(void) *------------------------------------------------------------------------- */ /* create a file using default properties */ - if((fid1 = H5Fcreate("tstint1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate("tstint1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* create a data space */ - if((sid1 = H5Screate_simple(rank, dims, NULL)) < 0) FAIL_STACK_ERROR + if ((sid1 = H5Screate_simple(rank, dims, NULL)) < 0) + FAIL_STACK_ERROR /* create dcpl */ - if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* create a dataset */ - if((did1 = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did1 = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* write */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) FAIL_STACK_ERROR + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + FAIL_STACK_ERROR /* close */ - if(H5Sclose(sid1) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl1) < 0) FAIL_STACK_ERROR - if(H5Dclose(did1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid1) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl1) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid1) < 0) + FAIL_STACK_ERROR /*------------------------------------------------------------------------- * step 2: open and create another file copying the data from file1 @@ -2740,71 +2965,87 @@ test_ninteger(void) */ /* open */ - if((fid1 = H5Fopen("tstint1.h5", H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid1 = H5Fopen("tstint1.h5", H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open dataset */ - if((did1 = H5Dopen2(fid1, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did1 = H5Dopen2(fid1, "dset", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if((sid1 = H5Dget_space(did1)) < 0) FAIL_STACK_ERROR + if ((sid1 = H5Dget_space(did1)) < 0) + FAIL_STACK_ERROR /* get dcpl */ - if((dcpl1 = H5Dget_create_plist(did1)) < 0) FAIL_STACK_ERROR + if ((dcpl1 = H5Dget_create_plist(did1)) < 0) + FAIL_STACK_ERROR /* get file datatype */ - if((tid1 = H5Dget_type(did1)) < 0) FAIL_STACK_ERROR + if ((tid1 = H5Dget_type(did1)) < 0) + FAIL_STACK_ERROR /* get native datatype */ - if((nid1 = H5Tget_native_type(tid1, H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((nid1 = H5Tget_native_type(tid1, H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR /* get size */ - if(H5Tget_size(nid1) == 0) FAIL_STACK_ERROR + if (H5Tget_size(nid1) == 0) + FAIL_STACK_ERROR /* get rank */ - if((rank = H5Sget_simple_extent_ndims(sid1)) < 0) FAIL_STACK_ERROR + if ((rank = H5Sget_simple_extent_ndims(sid1)) < 0) + FAIL_STACK_ERROR HDmemset(dims, 0, sizeof dims); /* get dimension */ - if(H5Sget_simple_extent_dims(sid1, dims, NULL) < 0) FAIL_STACK_ERROR + if (H5Sget_simple_extent_dims(sid1, dims, NULL) < 0) + FAIL_STACK_ERROR nelmts = 1; - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) nelmts *= dims[i]; /* read */ - if(H5Dread(did1, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) FAIL_STACK_ERROR + if (H5Dread(did1, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) + FAIL_STACK_ERROR /* create a file using default properties */ - if((fid2 = H5Fcreate("tstint2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid2 = H5Fcreate("tstint2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* create a dataset using the native type */ - if((did2 = H5Dcreate2(fid2, "dset", nid1, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((did2 = H5Dcreate2(fid2, "dset", nid1, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* write */ - if(H5Dwrite(did2, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) FAIL_STACK_ERROR + if (H5Dwrite(did2, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) + FAIL_STACK_ERROR /* get dcpl */ - if((dcpl2 = H5Dget_create_plist(did2)) < 0) FAIL_STACK_ERROR + if ((dcpl2 = H5Dget_create_plist(did2)) < 0) + FAIL_STACK_ERROR /* get file datatype */ - if((tid2 = H5Dget_type(did2)) < 0) FAIL_STACK_ERROR + if ((tid2 = H5Dget_type(did2)) < 0) + FAIL_STACK_ERROR /* get native datatype */ - if((nid2 = H5Tget_native_type(tid2, H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((nid2 = H5Tget_native_type(tid2, H5T_DIR_DEFAULT)) < 0) + FAIL_STACK_ERROR /* check */ - if(H5Tget_precision(nid1) != H5Tget_precision(nid2)) { + if (H5Tget_precision(nid1) != H5Tget_precision(nid2)) { HDprintf(" Precision differ.\n"); TEST_ERROR } /* end if */ /* compare dataset creation property lists */ - if(H5Pequal(dcpl1, dcpl2) <= 0) { + if (H5Pequal(dcpl1, dcpl2) <= 0) { HDprintf(" Property lists differ.\n"); TEST_ERROR } /* end if */ /* check */ - for(i = 0; i < DIM3; i++) - if(buf[i] != chk[i]) { + for (i = 0; i < DIM3; i++) + if (buf[i] != chk[i]) { H5_FAILED(); HDprintf(" Read different values than written.\n"); HDprintf(" At index %d\n", i); @@ -2812,23 +3053,35 @@ test_ninteger(void) } /* end if */ /* close */ - if(H5Sclose(sid1) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl1) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl2) < 0) FAIL_STACK_ERROR - if(H5Tclose(tid1) < 0) FAIL_STACK_ERROR - if(H5Tclose(tid2) < 0) FAIL_STACK_ERROR - if(H5Tclose(nid1) < 0) FAIL_STACK_ERROR - if(H5Tclose(nid2) < 0) FAIL_STACK_ERROR - if(H5Dclose(did1) < 0) FAIL_STACK_ERROR - if(H5Dclose(did2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid1) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl1) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl2) < 0) + FAIL_STACK_ERROR + if (H5Tclose(tid1) < 0) + FAIL_STACK_ERROR + if (H5Tclose(tid2) < 0) + FAIL_STACK_ERROR + if (H5Tclose(nid1) < 0) + FAIL_STACK_ERROR + if (H5Tclose(nid2) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did1) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did2) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid1) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid2) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl1); H5Pclose(dcpl2); H5Tclose(tid1); @@ -2840,12 +3093,12 @@ error: H5Sclose(sid1); H5Fclose(fid1); H5Fclose(fid2); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_ninteger() */ - /*------------------------------------------------------------------------- * Function: main * @@ -2861,41 +3114,41 @@ error: int main(void) { - hid_t file, fapl; - int nerrors = 0; - char filename[1024]; + hid_t file, fapl; + int nerrors = 0; + char filename[1024]; h5_reset(); fapl = h5_fileaccess(); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - nerrors += test_atomic_dtype(file) < 0 ? 1 : 0; - nerrors += test_compound_dtype(file) < 0 ? 1 : 0; - nerrors += test_compound_dtype2(file) < 0 ? 1 : 0; - nerrors += test_compound_dtype3(file) < 0 ? 1 : 0; - nerrors += test_compound_opaque(file) < 0 ? 1 : 0; - nerrors += test_enum_dtype(file) < 0 ? 1 : 0; - nerrors += test_array_dtype(file) < 0 ? 1 : 0; - nerrors += test_array_dtype2(file) < 0 ? 1 : 0; - nerrors += test_vl_dtype(file) < 0 ? 1 : 0; - nerrors += test_vlstr_dtype(file) < 0 ? 1 : 0; - nerrors += test_str_dtype(file) < 0 ? 1 : 0; - nerrors += test_refer_dtype(file) < 0 ? 1 : 0; - nerrors += test_refer_dtype2(file) < 0 ? 1 : 0; - nerrors += test_opaque_dtype(file) < 0 ? 1 : 0; - nerrors += test_bitfield_dtype(file) < 0 ? 1 : 0; - nerrors += test_ninteger() < 0 ? 1 : 0; - - if(H5Fclose(file) < 0) + nerrors += test_atomic_dtype(file) < 0 ? 1 : 0; + nerrors += test_compound_dtype(file) < 0 ? 1 : 0; + nerrors += test_compound_dtype2(file) < 0 ? 1 : 0; + nerrors += test_compound_dtype3(file) < 0 ? 1 : 0; + nerrors += test_compound_opaque(file) < 0 ? 1 : 0; + nerrors += test_enum_dtype(file) < 0 ? 1 : 0; + nerrors += test_array_dtype(file) < 0 ? 1 : 0; + nerrors += test_array_dtype2(file) < 0 ? 1 : 0; + nerrors += test_vl_dtype(file) < 0 ? 1 : 0; + nerrors += test_vlstr_dtype(file) < 0 ? 1 : 0; + nerrors += test_str_dtype(file) < 0 ? 1 : 0; + nerrors += test_refer_dtype(file) < 0 ? 1 : 0; + nerrors += test_refer_dtype2(file) < 0 ? 1 : 0; + nerrors += test_opaque_dtype(file) < 0 ? 1 : 0; + nerrors += test_bitfield_dtype(file) < 0 ? 1 : 0; + nerrors += test_ninteger() < 0 ? 1 : 0; + + if (H5Fclose(file) < 0) goto error; /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); - if(nerrors) + if (nerrors) goto error; HDprintf("All native datatype tests passed.\n"); @@ -2904,15 +3157,15 @@ main(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); h5_cleanup(FILENAME, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; nerrors = MAX(1, nerrors); - HDprintf("***** %d DATASET TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d DATASET TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } - diff --git a/test/null_vol_connector.c b/test/null_vol_connector.c index ef76fe6..095169c 100644 --- a/test/null_vol_connector.c +++ b/test/null_vol_connector.c @@ -15,129 +15,147 @@ * (registration, etc.). */ - /* Public HDF5 header */ #include "hdf5.h" /* For HDF5 plugin functionality */ #include "H5PLextern.h" - /* This connector's header */ #include "null_vol_connector.h" /* The VOL class struct */ static const H5VL_class_t null_vol_g = { - 0, /* version */ - NULL_VOL_CONNECTOR_VALUE, /* value */ - NULL_VOL_CONNECTOR_NAME, /* name */ - 0, /* capability flags */ - NULL, /* initialize */ - NULL, /* terminate */ - { /* info_cls */ - (size_t)0, /* size */ - NULL, /* copy */ - NULL, /* compare */ - NULL, /* free */ - NULL, /* to_str */ - NULL, /* from_str */ + 0, /* version */ + NULL_VOL_CONNECTOR_VALUE, /* value */ + NULL_VOL_CONNECTOR_NAME, /* name */ + 0, /* capability flags */ + NULL, /* initialize */ + NULL, /* terminate */ + { + /* info_cls */ + (size_t)0, /* size */ + NULL, /* copy */ + NULL, /* compare */ + NULL, /* free */ + NULL, /* to_str */ + NULL, /* from_str */ }, - { /* wrap_cls */ - NULL, /* get_object */ - NULL, /* get_wrap_ctx */ - NULL, /* wrap_object */ - NULL, /* unwrap_object */ - NULL, /* free_wrap_ctx */ + { + /* wrap_cls */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL, /* free_wrap_ctx */ }, - { /* attribute_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* attribute_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* dataset_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* dataset_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* datatype_cls */ - NULL, /* commit */ - NULL, /* open */ - NULL, /* get_size */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* datatype_cls */ + NULL, /* commit */ + NULL, /* open */ + NULL, /* get_size */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* file_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* file_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* group_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* group_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* link_cls */ - NULL, /* create */ - NULL, /* copy */ - NULL, /* move */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + { + /* link_cls */ + NULL, /* create */ + NULL, /* copy */ + NULL, /* move */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, - { /* object_cls */ - NULL, /* open */ - NULL, /* copy */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + { + /* object_cls */ + NULL, /* open */ + NULL, /* copy */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, - { /* introspect_cls */ - NULL, /* get_conn_cls */ - NULL, /* opt_query */ + { + /* introspect_cls */ + NULL, /* get_conn_cls */ + NULL, /* opt_query */ }, - { /* request_cls */ - NULL, /* wait */ - NULL, /* notify */ - NULL, /* cancel */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* free */ + { + /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ }, - { /* blob_cls */ - NULL, /* put */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + { + /* blob_cls */ + NULL, /* put */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, - { /* token_cls */ - NULL, /* cmp */ - NULL, /* to_str */ - NULL /* from_str */ + { + /* token_cls */ + NULL, /* cmp */ + NULL, /* to_str */ + NULL /* from_str */ }, - NULL /* optional */ + NULL /* optional */ }; /* These two functions are necessary to load this plugin using * the HDF5 library. */ -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_VOL;} -const void *H5PLget_plugin_info(void) {return &null_vol_g;} - +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_VOL; +} +const void * +H5PLget_plugin_info(void) +{ + return &null_vol_g; +} diff --git a/test/null_vol_connector.h b/test/null_vol_connector.h index 11c8826..e4c7cd894 100644 --- a/test/null_vol_connector.h +++ b/test/null_vol_connector.h @@ -18,8 +18,7 @@ #ifndef _null_vol_connector_H #define _null_vol_connector_H -#define NULL_VOL_CONNECTOR_VALUE ((H5VL_class_value_t)160) -#define NULL_VOL_CONNECTOR_NAME "null_vol_connector" +#define NULL_VOL_CONNECTOR_VALUE ((H5VL_class_value_t)160) +#define NULL_VOL_CONNECTOR_NAME "null_vol_connector" #endif /* _null_vol_connector_H */ - diff --git a/test/objcopy.c b/test/objcopy.c index 5174700..a9ddff7 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -23,172 +23,155 @@ #include "H5Iprivate.h" #include "H5Pprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ /* * This file needs to access private information from the H5S package. * This file also needs to access the dataspace testing code. */ -#define H5S_FRIEND /*suppress error about including H5Spkg */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ #define H5S_TESTING -#include "H5Spkg.h" /* Dataspaces */ +#include "H5Spkg.h" /* Dataspaces */ /* * This file needs to access private information from the H5P package. * This file also needs to access the property list testing code. */ -#define H5P_FRIEND /*suppress error about including H5Ppkg */ +#define H5P_FRIEND /*suppress error about including H5Ppkg */ #define H5P_TESTING -#include "H5Ppkg.h" /* Property Lists */ +#include "H5Ppkg.h" /* Property Lists */ /* * This file needs to access private information from the H5D package. * This file also needs to access the dataset testing code. */ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ #define H5D_TESTING -#include "H5Dpkg.h" /* Datasets */ +#include "H5Dpkg.h" /* Datasets */ /* * This file needs to access private information from the H5O package. * This file also needs to access the dataspace testing code. */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ #define H5O_TESTING -#include "H5Opkg.h" /* Object header */ +#include "H5Opkg.h" /* Object header */ - -const char *FILENAME[] = { - "objcopy_src", - "objcopy_dst", - "objcopy_ext", - "objcopy_src2", - "verbound_src", - "verbound_dst", - NULL -}; +const char *FILENAME[] = {"objcopy_src", "objcopy_dst", "objcopy_ext", "objcopy_src2", + "verbound_src", "verbound_dst", NULL}; /* Configuration, really a series of bit flags. Maximum value is all three * bit flags enabled. */ -#define CONFIG_SHARE_SRC 1 -#define CONFIG_SHARE_DST 2 +#define CONFIG_SHARE_SRC 1 +#define CONFIG_SHARE_DST 2 #define CONFIG_SRC_NEW_FORMAT 4 #define CONFIG_DST_NEW_FORMAT 8 -#define CONFIG_DENSE 16 -#define MAX_CONFIGURATION 31 +#define CONFIG_DENSE 16 +#define MAX_CONFIGURATION 31 -#define FILE_EXT "objcopy_ext.dat" +#define FILE_EXT "objcopy_ext.dat" /* The fill_old.h5 is generated from gen_old_fill.c in HDF5 'test' directory * for version 1.4(after 1.4.3). To get this data file, simply compile * gen_old_fill.c with HDF5 library (before v1.5) and run it. */ -#define FILE_OLD_LAYOUT "fill_old.h5" - - -#define NAME_DATATYPE_SIMPLE "H5T_NATIVE_INT" -#define NAME_DATATYPE_SIMPLE2 "H5T_NATIVE_INT-2" -#define NAME_DATATYPE_VL "vlen of int" -#define NAME_DATATYPE_VL_VL "vlen of vlen of int" -#define NAME_DATASET_SIMPLE "dataset_simple" -#define NAME_DATASET_SIMPLE2 "dataset_simple_copy" -#define NAME_DATASET_SIMPLE3 "dataset_simple_another_copy" -#define NAME_DATASET_COMPOUND "dataset_compound" -#define NAME_DATASET_CHUNKED "dataset_chunked" -#define NAME_DATASET_CHUNKED_SINGLE "dataset_chunked_single" -#define NAME_DATASET_CHUNKED2 "dataset_chunked2" -#define NAME_DATASET_CHUNKED2_SINGLE "dataset_chunked2_single" -#define NAME_DATASET_CHUNKED3 "dataset_chunked3" -#define NAME_DATASET_CHUNKED3_SINGLE "dataset_chunked3_single" -#define NAME_DATASET_CHUNKED4 "dataset_chunked4" -#define NAME_DATASET_CHUNKED4_SINGLE "dataset_chunked4_single" -#define NAME_DATASET_COMPACT "dataset_compact" -#define NAME_DATASET_EXTERNAL "dataset_ext" +#define FILE_OLD_LAYOUT "fill_old.h5" + +#define NAME_DATATYPE_SIMPLE "H5T_NATIVE_INT" +#define NAME_DATATYPE_SIMPLE2 "H5T_NATIVE_INT-2" +#define NAME_DATATYPE_VL "vlen of int" +#define NAME_DATATYPE_VL_VL "vlen of vlen of int" +#define NAME_DATASET_SIMPLE "dataset_simple" +#define NAME_DATASET_SIMPLE2 "dataset_simple_copy" +#define NAME_DATASET_SIMPLE3 "dataset_simple_another_copy" +#define NAME_DATASET_COMPOUND "dataset_compound" +#define NAME_DATASET_CHUNKED "dataset_chunked" +#define NAME_DATASET_CHUNKED_SINGLE "dataset_chunked_single" +#define NAME_DATASET_CHUNKED2 "dataset_chunked2" +#define NAME_DATASET_CHUNKED2_SINGLE "dataset_chunked2_single" +#define NAME_DATASET_CHUNKED3 "dataset_chunked3" +#define NAME_DATASET_CHUNKED3_SINGLE "dataset_chunked3_single" +#define NAME_DATASET_CHUNKED4 "dataset_chunked4" +#define NAME_DATASET_CHUNKED4_SINGLE "dataset_chunked4_single" +#define NAME_DATASET_COMPACT "dataset_compact" +#define NAME_DATASET_EXTERNAL "dataset_ext" #define NAME_DATASET_NAMED_DTYPE "dataset_named_dtype" -#define NAME_DATASET_NAMED_DTYPE2 "dataset_named_dtype2" -#define NAME_DATASET_MULTI_OHDR "dataset_multi_ohdr" +#define NAME_DATASET_NAMED_DTYPE2 "dataset_named_dtype2" +#define NAME_DATASET_MULTI_OHDR "dataset_multi_ohdr" #define NAME_DATASET_MULTI_OHDR2 "dataset_multi_ohdr2" -#define NAME_DATASET_VL "dataset_vl" -#define NAME_DATASET_VL2 "dataset_vl2" -#define NAME_DATASET_VL_VL "dataset_vl_vl" -#define NAME_DATASET_VL_VL2 "dataset_vl_vl2" -#define NAME_DATASET_CMPD_VL "dataset_cmpd_vl" -#define NAME_DATASET_SUB_SUB "/g0/g00/g000/dataset_simple" -#define NAME_GROUP_UNCOPIED "/uncopied" -#define NAME_GROUP_EMPTY "/empty" -#define NAME_GROUP_TOP "/g0" -#define NAME_GROUP_TOP2 "/g1" -#define NAME_GROUP_TOP3 "/g2" -#define NAME_GROUP_TOP4 "/g3" -#define NAME_GROUP_SUB "/g0/g00" -#define NAME_GROUP_SUB_2 "/g0/g01" -#define NAME_GROUP_SUB_SUB "/g0/g00/g000" -#define NAME_GROUP_SUB_SUB2 "g000" -#define NAME_GROUP_DATASET "/g0/dataset_simple" -#define NAME_GROUP_LINK "/g_links" -#define NAME_GROUP_LINK2 "/g_links2" -#define NAME_GROUP_LOOP "g_loop" -#define NAME_GROUP_LOOP2 "g_loop2" -#define NAME_GROUP_LOOP3 "g_loop3" -#define NAME_GROUP_REF "ref_grp" -#define NAME_LINK_DATASET "/g_links/dataset_simple" -#define NAME_LINK_HARD "/g_links/hard_link_to_dataset_simple" -#define NAME_LINK_SOFT "/g_links/soft_link_to_dataset_simple" -#define NAME_LINK_SOFT2 "/g_links2/soft_link_to_dataset_simple" -#define NAME_LINK_EXTERN "/g_links/external_link_to_dataset_simple" -#define NAME_LINK_EXTERN2 "/g_links2/external_link_to_dataset_simple" -#define NAME_LINK_SOFT_DANGLE "/g_links/soft_link_to_nowhere" -#define NAME_LINK_SOFT_DANGLE2 "/g_links2/soft_link_to_nowhere" -#define NAME_LINK_EXTERN_DANGLE "/g_links/external_link_to_nowhere" -#define NAME_LINK_EXTERN_DANGLE2 "/g_links2/external_link_to_nowhere" -#define NAME_OLD_FORMAT "/dset1" - -#define NAME_BUF_SIZE 1024 -#define ATTR_NAME_LEN 80 -#define DIM_SIZE_1 12 -#define DIM_SIZE_2 6 -#define MAX_DIM_SIZE_1 100 -#define MAX_DIM_SIZE_2 80 -#define CHUNK_SIZE_1 5 /* Not an even fraction of dimension sizes, so we test copying partial chunks */ -#define CHUNK_SIZE_2 5 -#define NUM_SUB_GROUPS 20 -#define NUM_WIDE_LOOP_GROUPS 10 -#define NUM_DATASETS 10 -#define ATTR_CMPD_STRING "ThisIsAString" - -char src_obj_full_name[215]; /* the full path + name of the object to be copied */ - -unsigned num_attributes_g; /* Number of attributes created */ +#define NAME_DATASET_VL "dataset_vl" +#define NAME_DATASET_VL2 "dataset_vl2" +#define NAME_DATASET_VL_VL "dataset_vl_vl" +#define NAME_DATASET_VL_VL2 "dataset_vl_vl2" +#define NAME_DATASET_CMPD_VL "dataset_cmpd_vl" +#define NAME_DATASET_SUB_SUB "/g0/g00/g000/dataset_simple" +#define NAME_GROUP_UNCOPIED "/uncopied" +#define NAME_GROUP_EMPTY "/empty" +#define NAME_GROUP_TOP "/g0" +#define NAME_GROUP_TOP2 "/g1" +#define NAME_GROUP_TOP3 "/g2" +#define NAME_GROUP_TOP4 "/g3" +#define NAME_GROUP_SUB "/g0/g00" +#define NAME_GROUP_SUB_2 "/g0/g01" +#define NAME_GROUP_SUB_SUB "/g0/g00/g000" +#define NAME_GROUP_SUB_SUB2 "g000" +#define NAME_GROUP_DATASET "/g0/dataset_simple" +#define NAME_GROUP_LINK "/g_links" +#define NAME_GROUP_LINK2 "/g_links2" +#define NAME_GROUP_LOOP "g_loop" +#define NAME_GROUP_LOOP2 "g_loop2" +#define NAME_GROUP_LOOP3 "g_loop3" +#define NAME_GROUP_REF "ref_grp" +#define NAME_LINK_DATASET "/g_links/dataset_simple" +#define NAME_LINK_HARD "/g_links/hard_link_to_dataset_simple" +#define NAME_LINK_SOFT "/g_links/soft_link_to_dataset_simple" +#define NAME_LINK_SOFT2 "/g_links2/soft_link_to_dataset_simple" +#define NAME_LINK_EXTERN "/g_links/external_link_to_dataset_simple" +#define NAME_LINK_EXTERN2 "/g_links2/external_link_to_dataset_simple" +#define NAME_LINK_SOFT_DANGLE "/g_links/soft_link_to_nowhere" +#define NAME_LINK_SOFT_DANGLE2 "/g_links2/soft_link_to_nowhere" +#define NAME_LINK_EXTERN_DANGLE "/g_links/external_link_to_nowhere" +#define NAME_LINK_EXTERN_DANGLE2 "/g_links2/external_link_to_nowhere" +#define NAME_OLD_FORMAT "/dset1" + +#define NAME_BUF_SIZE 1024 +#define ATTR_NAME_LEN 80 +#define DIM_SIZE_1 12 +#define DIM_SIZE_2 6 +#define MAX_DIM_SIZE_1 100 +#define MAX_DIM_SIZE_2 80 +#define CHUNK_SIZE_1 5 /* Not an even fraction of dimension sizes, so we test copying partial chunks */ +#define CHUNK_SIZE_2 5 +#define NUM_SUB_GROUPS 20 +#define NUM_WIDE_LOOP_GROUPS 10 +#define NUM_DATASETS 10 +#define ATTR_CMPD_STRING "ThisIsAString" + +char src_obj_full_name[215]; /* the full path + name of the object to be copied */ + +unsigned num_attributes_g; /* Number of attributes created */ /* Table containing object id and object name */ /* (Used for detecting duplicate objects when comparing groups */ static struct { - size_t nalloc; /* number of slots allocated */ - size_t nobjs; /* number of objects */ - H5O_token_t *obj; /* Tokens of objects seen */ + size_t nalloc; /* number of slots allocated */ + size_t nobjs; /* number of objects */ + H5O_token_t *obj; /* Tokens of objects seen */ } idtab_g; /* Local function prototypes */ -static int -compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, - const void *buf1, const void *buf2, hid_t obj_owner); -static int -compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf); -static int -compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags); -static int -compare_idx_type(hid_t fapl, hid_t did, H5D_chunk_index_t new_type, H5D_chunk_index_t old_type); - -static int -test_copy_attribute_compound_vlstr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl); -static int -attach_attribute_compound_vlstr(hid_t loc_id); -static int -compare_attribute_compound_vlstr(hid_t loc, hid_t loc2); +static int compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, const void *buf1, + const void *buf2, hid_t obj_owner); +static int compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf); +static int compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags); +static int compare_idx_type(hid_t fapl, hid_t did, H5D_chunk_index_t new_type, H5D_chunk_index_t old_type); +static int test_copy_attribute_compound_vlstr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl); +static int attach_attribute_compound_vlstr(hid_t loc_id); +static int compare_attribute_compound_vlstr(hid_t loc, hid_t loc2); /*------------------------------------------------------------------------- * Function: token_insert @@ -205,25 +188,24 @@ compare_attribute_compound_vlstr(hid_t loc, hid_t loc2); static void token_insert(H5O_info2_t *oi) { - size_t n; + size_t n; /* Don't add it if the link count is 1 because such an object can only * be encountered once. */ - if(oi->rc < 2) + if (oi->rc < 2) return; /* Extend the table */ - if(idtab_g.nobjs >= idtab_g.nalloc) { - idtab_g.nalloc = MAX(256, 2*idtab_g.nalloc); - idtab_g.obj = (H5O_token_t *)HDrealloc(idtab_g.obj, idtab_g.nalloc * sizeof(idtab_g.obj[0])); + if (idtab_g.nobjs >= idtab_g.nalloc) { + idtab_g.nalloc = MAX(256, 2 * idtab_g.nalloc); + idtab_g.obj = (H5O_token_t *)HDrealloc(idtab_g.obj, idtab_g.nalloc * sizeof(idtab_g.obj[0])); } /* end if */ /* Insert the entry */ - n = idtab_g.nobjs++; + n = idtab_g.nobjs++; idtab_g.obj[n] = oi->token; } /* end token_insert() */ - /*------------------------------------------------------------------------- * Function: token_lookup * @@ -241,21 +223,21 @@ static H5_ATTR_PURE hbool_t token_lookup(hid_t loc_id, H5O_info2_t *oi) { size_t n; - int token_cmp; + int token_cmp; - if(oi->rc < 2) return FALSE; /*only one link possible*/ + if (oi->rc < 2) + return FALSE; /*only one link possible*/ - for(n = 0; n < idtab_g.nobjs; n++) { - if(H5Otoken_cmp(loc_id, &idtab_g.obj[n], &oi->token, &token_cmp) < 0) + for (n = 0; n < idtab_g.nobjs; n++) { + if (H5Otoken_cmp(loc_id, &idtab_g.obj[n], &oi->token, &token_cmp) < 0) return FALSE; - if(!token_cmp) + if (!token_cmp) return TRUE; } return FALSE; } /* end token_lookup() */ - /*------------------------------------------------------------------------- * Function: token_reset * @@ -271,13 +253,12 @@ token_lookup(hid_t loc_id, H5O_info2_t *oi) static void token_reset(void) { - if(idtab_g.obj) + if (idtab_g.obj) HDfree(idtab_g.obj); - idtab_g.obj = NULL; + idtab_g.obj = NULL; idtab_g.nalloc = idtab_g.nobjs = 0; } /* end token_reset() */ - /*------------------------------------------------------------------------- * Function: attach_ref_attr * @@ -293,50 +274,68 @@ token_reset(void) static herr_t attach_ref_attr(hid_t file_id, hid_t loc_id) { - char dsetname1[] = "dataset1_pointed_by_ref_attr"; - char dsetname2[] = "dataset2_pointed_by_ref_attr"; - hid_t did1 = (-1), did2 = (-1), aid = (-1), sid = (-1), sid_ref = (-1); - hsize_t dims[2] = {2,9}; - hsize_t dims_ref[1] = {2}; + char dsetname1[] = "dataset1_pointed_by_ref_attr"; + char dsetname2[] = "dataset2_pointed_by_ref_attr"; + hid_t did1 = (-1), did2 = (-1), aid = (-1), sid = (-1), sid_ref = (-1); + hsize_t dims[2] = {2, 9}; + hsize_t dims_ref[1] = {2}; hobj_ref_t ref[2]; - int data1[2][9] = {{1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,18}}; - int data2[2][9] = {{2,2,2,2,2,2,2,2,2},{2,2,2,2,2,2,2,2,18}}; + int data1[2][9] = {{1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 18}}; + int data2[2][9] = {{2, 2, 2, 2, 2, 2, 2, 2, 2}, {2, 2, 2, 2, 2, 2, 2, 2, 18}}; /* creates two simple datasets */ - if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((sid_ref = H5Screate_simple(1, dims_ref, NULL)) < 0) TEST_ERROR - if((did1 = H5Dcreate2(file_id, dsetname1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data1) < 0) TEST_ERROR - if((did2 = H5Dcreate2(file_id, dsetname2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data2) < 0) TEST_ERROR + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + if ((sid_ref = H5Screate_simple(1, dims_ref, NULL)) < 0) + TEST_ERROR + if ((did1 = H5Dcreate2(file_id, dsetname1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0) + TEST_ERROR + if ((did2 = H5Dcreate2(file_id, dsetname2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2) < 0) + TEST_ERROR /* create an attribute with two object references */ - if(H5Rcreate(&ref[0], file_id, dsetname1, H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR - if(H5Rcreate(&ref[1], file_id, dsetname2, H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR - if((aid = H5Acreate2(loc_id, "obj_ref_attr", H5T_STD_REF_OBJ, sid_ref, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_STD_REF_OBJ, ref) < 0) TEST_ERROR + if (H5Rcreate(&ref[0], file_id, dsetname1, H5R_OBJECT, (hid_t)-1) < 0) + TEST_ERROR + if (H5Rcreate(&ref[1], file_id, dsetname2, H5R_OBJECT, (hid_t)-1) < 0) + TEST_ERROR + if ((aid = H5Acreate2(loc_id, "obj_ref_attr", H5T_STD_REF_OBJ, sid_ref, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Awrite(aid, H5T_STD_REF_OBJ, ref) < 0) + TEST_ERROR - if(H5Sclose(sid) < 0) TEST_ERROR - if(H5Sclose(sid_ref) < 0) TEST_ERROR - if(H5Dclose(did1) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) TEST_ERROR - if(H5Aclose(aid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR + if (H5Sclose(sid_ref) < 0) + TEST_ERROR + if (H5Dclose(did1) < 0) + TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Sclose(sid_ref); H5Dclose(did1); H5Dclose(did2); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; - return(-1); + return (-1); } - /*------------------------------------------------------------------------- * Function: attach_reg_ref_attr * @@ -352,66 +351,87 @@ error: static herr_t attach_reg_ref_attr(hid_t file_id, hid_t loc_id) { - const char dsetnamev[] = "dataset_pointed_by_reg_ref_attr"; - hid_t aid = (-1); - hid_t space_id = (-1); /* dataspace identifiers */ - hid_t spacer_id = (-1); /* dataspace identifiers */ - hid_t dsetv_id = (-1); /*dataset identifiers*/ - hsize_t dims[2] = {2,9}; - hsize_t dimsr[1] = {2}; - int rank = 2; - int rankr =1; + const char dsetnamev[] = "dataset_pointed_by_reg_ref_attr"; + hid_t aid = (-1); + hid_t space_id = (-1); /* dataspace identifiers */ + hid_t spacer_id = (-1); /* dataspace identifiers */ + hid_t dsetv_id = (-1); /*dataset identifiers*/ + hsize_t dims[2] = {2, 9}; + hsize_t dimsr[1] = {2}; + int rank = 2; + int rankr = 1; hdset_reg_ref_t ref[2]; - int data[2][9] = {{1,1,2,3,3,4,5,5,999},{1,2,2,3,4,4,5,6,999}}; - hsize_t start[2] = {0, 3}; - hsize_t count[2] = {2, 3}; - hsize_t coord[3][2] = {{0, 0}, {1, 6}, {0, 8}}; - size_t num_points = 3; + int data[2][9] = {{1, 1, 2, 3, 3, 4, 5, 5, 999}, {1, 2, 2, 3, 4, 4, 5, 6, 999}}; + hsize_t start[2] = {0, 3}; + hsize_t count[2] = {2, 3}; + hsize_t coord[3][2] = {{0, 0}, {1, 6}, {0, 8}}; + size_t num_points = 3; /* create a 2D dataset */ - if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) TEST_ERROR - if((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) TEST_ERROR - if((dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(rank, dims, NULL)) < 0) + TEST_ERROR + if ((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) + TEST_ERROR + if ((dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + TEST_ERROR /* create reg_ref of block selection */ - if(H5Sselect_hyperslab(space_id,H5S_SELECT_SET,start,NULL,count,NULL) < 0) TEST_ERROR - if(H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) TEST_ERROR + if (H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + TEST_ERROR + if (H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) + TEST_ERROR /* create reg_ref of point selection */ - if(H5Sselect_none(space_id) < 0) TEST_ERROR - if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) TEST_ERROR - if(H5Rcreate(&ref[1], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) TEST_ERROR + if (H5Sselect_none(space_id) < 0) + TEST_ERROR + if (H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) + TEST_ERROR + if (H5Rcreate(&ref[1], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) + TEST_ERROR /* create reg_ref attribute */ - if((aid = H5Acreate2(loc_id, "reg_ref_attr", H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_STD_REF_DSETREG, ref) < 0) TEST_ERROR + if ((aid = H5Acreate2(loc_id, "reg_ref_attr", H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Awrite(aid, H5T_STD_REF_DSETREG, ref) < 0) + TEST_ERROR /* attach the reg_ref attribute to the dataset itself */ - if(H5Aclose(aid) < 0) TEST_ERROR - if((aid = H5Acreate2(dsetv_id, "reg_ref_attr", H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_STD_REF_DSETREG, ref) < 0) TEST_ERROR - - if(H5Sclose(spacer_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Dclose(dsetv_id) < 0) TEST_ERROR - if(H5Aclose(aid) < 0) TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR + if ((aid = H5Acreate2(dsetv_id, "reg_ref_attr", H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Awrite(aid, H5T_STD_REF_DSETREG, ref) < 0) + TEST_ERROR + if (H5Sclose(spacer_id) < 0) + TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (H5Dclose(dsetv_id) < 0) + TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(spacer_id); H5Sclose(space_id); H5Dclose(dsetv_id); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; - return(-1); + return (-1); } - /*------------------------------------------------------------------------- * Function: create_reg_ref_dataset * @@ -427,84 +447,116 @@ error: static herr_t create_reg_ref_dataset(hid_t file_id, hid_t loc_id) { - const char dsetnamev[] = "dataset_pointed_by_ref_dset"; - const char dsetnamer[] = "dataset_with_reg_ref"; - const char dsetnamer1[] = "compact_dataset_with_reg_ref"; - const char dsetnamer2[] = "compressed_dataset_with_reg_ref"; - hid_t space_id = (-1); /* dataspace identifiers */ - hid_t spacer_id = (-1); - hid_t dsetv_id = (-1); /*dataset identifiers*/ - hid_t dsetr_id = (-1); - hsize_t dims[2] = {2,9}; - hsize_t dimsr[1] = {2}; - int rank = 2; - int rankr =1; - hsize_t chunk_size=1; + const char dsetnamev[] = "dataset_pointed_by_ref_dset"; + const char dsetnamer[] = "dataset_with_reg_ref"; + const char dsetnamer1[] = "compact_dataset_with_reg_ref"; + const char dsetnamer2[] = "compressed_dataset_with_reg_ref"; + hid_t space_id = (-1); /* dataspace identifiers */ + hid_t spacer_id = (-1); + hid_t dsetv_id = (-1); /*dataset identifiers*/ + hid_t dsetr_id = (-1); + hsize_t dims[2] = {2, 9}; + hsize_t dimsr[1] = {2}; + int rank = 2; + int rankr = 1; + hsize_t chunk_size = 1; hdset_reg_ref_t ref[2]; - int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}}; - hsize_t start[2]; - hsize_t count[2]; - hsize_t coord[3][2] = {{0, 0}, {1, 6}, {0, 8}}; - size_t num_points = 3; - hid_t pid = (-1); - - if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) TEST_ERROR - if((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) TEST_ERROR - if((dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data) < 0) TEST_ERROR - if((dsetr_id = H5Dcreate2(loc_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + int data[2][9] = {{1, 1, 2, 3, 3, 4, 5, 5, 6}, {1, 2, 2, 3, 4, 4, 5, 6, 6}}; + hsize_t start[2]; + hsize_t count[2]; + hsize_t coord[3][2] = {{0, 0}, {1, 6}, {0, 8}}; + size_t num_points = 3; + hid_t pid = (-1); + + if ((space_id = H5Screate_simple(rank, dims, NULL)) < 0) + TEST_ERROR + if ((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) + TEST_ERROR + if ((dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + TEST_ERROR + if ((dsetr_id = H5Dcreate2(loc_id, dsetnamer, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR start[0] = 0; start[1] = 3; count[0] = 2; count[1] = 3; - if(H5Sselect_hyperslab(space_id,H5S_SELECT_SET,start,NULL,count,NULL) < 0) TEST_ERROR - if(H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) TEST_ERROR - if(H5Sselect_none(space_id) < 0) TEST_ERROR - if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) TEST_ERROR - if(H5Rcreate(&ref[1], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) TEST_ERROR - if(H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref) < 0) TEST_ERROR - if(H5Dclose(dsetr_id) < 0) TEST_ERROR + if (H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + TEST_ERROR + if (H5Rcreate(&ref[0], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) + TEST_ERROR + if (H5Sselect_none(space_id) < 0) + TEST_ERROR + if (H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) + TEST_ERROR + if (H5Rcreate(&ref[1], file_id, dsetnamev, H5R_DATASET_REGION, space_id) < 0) + TEST_ERROR + if (H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) + TEST_ERROR + if (H5Dclose(dsetr_id) < 0) + TEST_ERROR /* create and set compact plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_layout(pid, H5D_COMPACT) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_layout(pid, H5D_COMPACT) < 0) + TEST_ERROR - if((dsetr_id = H5Dcreate2(loc_id, dsetnamer1, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Pclose(pid) < 0) TEST_ERROR - if(H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) TEST_ERROR - if(H5Dclose(dsetr_id) < 0) TEST_ERROR + if ((dsetr_id = H5Dcreate2(loc_id, dsetnamer1, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, pid, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR + if (H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) + TEST_ERROR + if (H5Dclose(dsetr_id) < 0) + TEST_ERROR /* create and set comp & chunk plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(pid, 1, &chunk_size) < 0) TEST_ERROR - if(H5Pset_deflate(pid, 9) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(pid, 1, &chunk_size) < 0) + TEST_ERROR + if (H5Pset_deflate(pid, 9) < 0) + TEST_ERROR - if((dsetr_id = H5Dcreate2(loc_id, dsetnamer2, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Pclose(pid) < 0) TEST_ERROR - if(H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref) < 0) TEST_ERROR - if(H5Dclose(dsetr_id) < 0) TEST_ERROR + if ((dsetr_id = H5Dcreate2(loc_id, dsetnamer2, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, pid, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR + if (H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) + TEST_ERROR + if (H5Dclose(dsetr_id) < 0) + TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Sclose(spacer_id) < 0) TEST_ERROR - if(H5Dclose(dsetv_id) < 0) TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (H5Sclose(spacer_id) < 0) + TEST_ERROR + if (H5Dclose(dsetv_id) < 0) + TEST_ERROR return 0; - error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space_id); H5Sclose(spacer_id); H5Dclose(dsetr_id); H5Dclose(dsetv_id); H5Pclose(pid); - } H5E_END_TRY; + } + H5E_END_TRY; - return(-1); + return (-1); } - /*------------------------------------------------------------------------- * Function: attach_attribute_vl * @@ -520,51 +572,49 @@ error: static int test_copy_attach_attribute_vl(hid_t loc_id) { - hid_t aid = -1, sid = -1, tid=-1; - hvl_t buf[4]; - hsize_t dim1=4; + hid_t aid = -1, sid = -1, tid = -1; + hvl_t buf[4]; + hsize_t dim1 = 4; unsigned int i, j; - int ret_value = -1; + int ret_value = -1; - if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 ) + if ((sid = H5Screate_simple(1, &dim1, NULL)) < 0) goto done; - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) goto done; - for(i = 0; i < 4; i++) { - buf[i].len = i*3+1; - buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); - for(j = 0; j < buf[i].len; j++) + for (i = 0; i < 4; i++) { + buf[i].len = i * 3 + 1; + buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); + for (j = 0; j < buf[i].len; j++) ((int *)buf[i].p)[j] = (int)(j + 1); } /* end for */ - if((aid = H5Acreate2(loc_id, "vlen attribute", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(loc_id, "vlen attribute", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto done; - if(H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, buf) < 0) goto done; ret_value = 0; done: - if(tid >0 && sid > 0) { + if (tid > 0 && sid > 0) { hid_t dxpl_id = H5Pcreate(H5P_DATASET_XFER); H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL); H5Treclaim(tid, sid, dxpl_id, buf); H5Pclose(dxpl_id); } - if(sid > 0) + if (sid > 0) H5Sclose(sid); - if(tid > 0) + if (tid > 0) H5Tclose(tid); - if(aid > 0) + if (aid > 0) H5Aclose(aid); return ret_value; } /* end of attach_attribute_vl */ - - /*------------------------------------------------------------------------- * Function: test_copy_attach_attributes * @@ -580,22 +630,22 @@ done: static int test_copy_attach_attributes(hid_t loc_id, hid_t type_id) { - hid_t aid = -1, sid = -1; - char attr_name[ATTR_NAME_LEN]; - int attr_data[2]; - hsize_t dim1 = 2; - hid_t acpl = -1; - unsigned u; - int ret_value = -1; - - if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 ) + hid_t aid = -1, sid = -1; + char attr_name[ATTR_NAME_LEN]; + int attr_data[2]; + hsize_t dim1 = 2; + hid_t acpl = -1; + unsigned u; + int ret_value = -1; + + if ((sid = H5Screate_simple(1, &dim1, NULL)) < 0) goto done; /* Create attribute creation plist */ - if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) + if ((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) goto done; - for(u = 0; u < num_attributes_g; u++) { + for (u = 0; u < num_attributes_g; u++) { HDsprintf(attr_name, "%u attr", u); /* Set attribute data */ @@ -603,40 +653,38 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id) attr_data[1] = (int)(200 * u); /* Set attribute character set (alternate) */ - if(u % 2) { - if(H5Pset_char_encoding(acpl, H5T_CSET_ASCII) < 0) + if (u % 2) { + if (H5Pset_char_encoding(acpl, H5T_CSET_ASCII) < 0) goto done; } /* end if */ - else - if(H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0) - goto done; + else if (H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0) + goto done; - if((aid = H5Acreate2(loc_id, attr_name, type_id, sid, acpl, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(loc_id, attr_name, type_id, sid, acpl, H5P_DEFAULT)) < 0) goto done; - if(H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) + if (H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) goto done; - if(aid > 0) + if (aid > 0) H5Aclose(aid); - aid = -1; + aid = -1; } ret_value = 0; done: - if(sid > 0) + if (sid > 0) H5Sclose(sid); - if(aid > 0) + if (aid > 0) H5Aclose(aid); - if(acpl > 0) + if (acpl > 0) H5Pclose(acpl); return ret_value; } - /*------------------------------------------------------------------------- * Function: test_copy_attach_paired_attributes * @@ -652,19 +700,21 @@ done: static int test_copy_attach_paired_attributes(hid_t loc_id, hid_t loc_id2, hid_t type_id) { - hid_t aid = -1, sid = -1; - char attr_name[ATTR_NAME_LEN]; - int attr_data[2]; - hid_t acpl = -1; - unsigned u; - hsize_t dim1 = 2; - - if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 ) goto done; + hid_t aid = -1, sid = -1; + char attr_name[ATTR_NAME_LEN]; + int attr_data[2]; + hid_t acpl = -1; + unsigned u; + hsize_t dim1 = 2; + + if ((sid = H5Screate_simple(1, &dim1, NULL)) < 0) + goto done; /* Create attribute creation plist */ - if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) goto done; + if ((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) + goto done; - for(u = 0; u < num_attributes_g; u++) { + for (u = 0; u < num_attributes_g; u++) { HDsprintf(attr_name, "%u attr", u); /* Set attribute data */ @@ -672,40 +722,48 @@ test_copy_attach_paired_attributes(hid_t loc_id, hid_t loc_id2, hid_t type_id) attr_data[1] = (int)(200 * u); /* Set attribute character set (alternate) */ - if(u % 2) { - if(H5Pset_char_encoding(acpl, H5T_CSET_ASCII) < 0) goto done; + if (u % 2) { + if (H5Pset_char_encoding(acpl, H5T_CSET_ASCII) < 0) + goto done; } /* end if */ - else - if(H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0) goto done; + else if (H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0) + goto done; /* Add attribute to first object */ - if((aid = H5Acreate2(loc_id, attr_name, type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto done; - if(H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) goto done; - if(H5Aclose(aid) < 0) goto done; + if ((aid = H5Acreate2(loc_id, attr_name, type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto done; + if (H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) + goto done; + if (H5Aclose(aid) < 0) + goto done; /* Add attribute to second object */ - if((aid = H5Acreate2(loc_id2, attr_name, type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto done; - if(H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) goto done; - if(H5Aclose(aid) < 0) goto done; + if ((aid = H5Acreate2(loc_id2, attr_name, type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto done; + if (H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) + goto done; + if (H5Aclose(aid) < 0) + goto done; } - if(H5Sclose(sid) < 0) goto done; - if(H5Pclose(acpl) < 0) goto done; + if (H5Sclose(sid) < 0) + goto done; + if (H5Pclose(acpl) < 0) + goto done; return 0; done: - if(sid > 0) + if (sid > 0) H5Sclose(sid); - if(aid > 0) + if (aid > 0) H5Aclose(aid); - if(acpl > 0) + if (acpl > 0) H5Pclose(acpl); return -1; } /* end test_copy_attach_paired_attributes() */ - /*------------------------------------------------------------------------- * Function: compare_attribute * @@ -721,86 +779,110 @@ done: static int compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_owner) { - hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - size_t elmt_size; /* Size of datatype */ - htri_t is_committed; /* If the datatype is committed */ - htri_t is_committed2; /* If the datatype is committed */ - H5A_info_t ainfo; /* Attribute info */ - H5A_info_t ainfo2; /* Attribute info */ - hssize_t nelmts; /* # of elements in dataspace */ - void *rbuf = NULL; /* Buffer for reading raw data */ - void *rbuf2 = NULL; /* Buffer for reading raw data */ + hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + size_t elmt_size; /* Size of datatype */ + htri_t is_committed; /* If the datatype is committed */ + htri_t is_committed2; /* If the datatype is committed */ + H5A_info_t ainfo; /* Attribute info */ + H5A_info_t ainfo2; /* Attribute info */ + hssize_t nelmts; /* # of elements in dataspace */ + void * rbuf = NULL; /* Buffer for reading raw data */ + void * rbuf2 = NULL; /* Buffer for reading raw data */ /* Check the character sets are equal */ - if(H5Aget_info(aid, &ainfo) < 0) TEST_ERROR - if(H5Aget_info(aid2, &ainfo2) < 0) TEST_ERROR - if(ainfo.cset != ainfo2.cset) TEST_ERROR + if (H5Aget_info(aid, &ainfo) < 0) + TEST_ERROR + if (H5Aget_info(aid2, &ainfo2) < 0) + TEST_ERROR + if (ainfo.cset != ainfo2.cset) + TEST_ERROR /* Check the creation orders are equal (if appropriate) */ - if(ainfo.corder_valid != ainfo2.corder_valid) TEST_ERROR - if(ainfo.corder_valid) - if(ainfo.corder != ainfo2.corder) TEST_ERROR + if (ainfo.corder_valid != ainfo2.corder_valid) + TEST_ERROR + if (ainfo.corder_valid) + if (ainfo.corder != ainfo2.corder) + TEST_ERROR /* Check the datatypes are equal */ /* Open the datatype for the source attribute */ - if((tid = H5Aget_type(aid)) < 0) TEST_ERROR + if ((tid = H5Aget_type(aid)) < 0) + TEST_ERROR /* Open the datatype for the destination attribute */ - if((tid2 = H5Aget_type(aid2)) < 0) TEST_ERROR + if ((tid2 = H5Aget_type(aid2)) < 0) + TEST_ERROR /* Check that both datatypes are committed/not committed */ - if((is_committed = H5Tcommitted(tid)) < 0) TEST_ERROR - if((is_committed2 = H5Tcommitted(tid2)) < 0) TEST_ERROR - if(is_committed != is_committed2) TEST_ERROR + if ((is_committed = H5Tcommitted(tid)) < 0) + TEST_ERROR + if ((is_committed2 = H5Tcommitted(tid2)) < 0) + TEST_ERROR + if (is_committed != is_committed2) + TEST_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* Determine the size of datatype (for later) */ - if((elmt_size = H5Tget_size(tid)) == 0) TEST_ERROR + if ((elmt_size = H5Tget_size(tid)) == 0) + TEST_ERROR /* Check the dataspaces are equal */ /* Open the dataspace for the source attribute */ - if((sid = H5Aget_space(aid)) < 0) TEST_ERROR + if ((sid = H5Aget_space(aid)) < 0) + TEST_ERROR /* Open the dataspace for the destination attribute */ - if((sid2 = H5Aget_space(aid2)) < 0) TEST_ERROR + if ((sid2 = H5Aget_space(aid2)) < 0) + TEST_ERROR /* Compare the dataspaces */ - if(H5Sextent_equal(sid, sid2) != TRUE) TEST_ERROR + if (H5Sextent_equal(sid, sid2) != TRUE) + TEST_ERROR /* Determine the number of elements in dataspace (for later) */ - if((nelmts = H5Sget_simple_extent_npoints(sid2)) < 0) TEST_ERROR + if ((nelmts = H5Sget_simple_extent_npoints(sid2)) < 0) + TEST_ERROR /* Check the raw data is equal */ /* Allocate & initialize space for the raw data buffers */ - if((rbuf = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR - if((rbuf2 = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR + if ((rbuf = HDcalloc(elmt_size, (size_t)nelmts)) == NULL) + TEST_ERROR + if ((rbuf2 = HDcalloc(elmt_size, (size_t)nelmts)) == NULL) + TEST_ERROR /* Read data from the source attribute */ - if(H5Aread(aid, tid, rbuf) < 0) TEST_ERROR + if (H5Aread(aid, tid, rbuf) < 0) + TEST_ERROR /* Read data from the destination attribute */ - if(H5Aread(aid2, tid2, rbuf2) < 0) TEST_ERROR + if (H5Aread(aid2, tid2, rbuf2) < 0) + TEST_ERROR /* Check raw data read in against data written out */ - if(wbuf) { - if(!compare_data(aid, (hid_t)0, pid, tid, (size_t)nelmts, wbuf, rbuf, obj_owner)) TEST_ERROR - if(!compare_data(aid2, (hid_t)0, pid, tid2, (size_t)nelmts, wbuf, rbuf2, obj_owner)) TEST_ERROR + if (wbuf) { + if (!compare_data(aid, (hid_t)0, pid, tid, (size_t)nelmts, wbuf, rbuf, obj_owner)) + TEST_ERROR + if (!compare_data(aid2, (hid_t)0, pid, tid2, (size_t)nelmts, wbuf, rbuf2, obj_owner)) + TEST_ERROR } /* end if */ /* Don't have written data, just compare data between the two attributes */ - else - if(!compare_data(aid, aid2, pid, tid, (size_t)nelmts, rbuf, rbuf2, obj_owner)) TEST_ERROR + else if (!compare_data(aid, aid2, pid, tid, (size_t)nelmts, rbuf, rbuf2, obj_owner)) + TEST_ERROR /* Reclaim vlen data, if necessary */ - if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) - if(H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR - if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) - if(H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE) + if (H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + if (H5Tdetect_class(tid2, H5T_VLEN) == TRUE) + if (H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) + TEST_ERROR /* Release raw data buffers */ HDfree(rbuf); @@ -809,34 +891,39 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_ rbuf2 = NULL; /* close the source dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR /* close the destination dataspace */ - if(H5Sclose(sid2) < 0) TEST_ERROR + if (H5Sclose(sid2) < 0) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the destination datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR return TRUE; error: - if(rbuf) + if (rbuf) HDfree(rbuf); - if(rbuf2) + if (rbuf2) HDfree(rbuf2); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid2); H5Sclose(sid); H5Tclose(tid2); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return FALSE; } /* end compare_attribute() */ - /*------------------------------------------------------------------------- * Function: compare_std_attributes * @@ -855,62 +942,75 @@ error: static int compare_std_attributes(hid_t oid, hid_t oid2, hid_t pid) { - hid_t aid = -1, aid2 = -1; /* Attribute IDs */ - H5O_info2_t oinfo1, oinfo2; /* Object info */ - unsigned cpy_flags; /* Object copy flags */ + hid_t aid = -1, aid2 = -1; /* Attribute IDs */ + H5O_info2_t oinfo1, oinfo2; /* Object info */ + unsigned cpy_flags; /* Object copy flags */ /* Retrieve the object copy flags from the property list, if it's non-DEFAULT */ - if(pid != H5P_DEFAULT) { - if(H5Pget_copy_object(pid, &cpy_flags) < 0) TEST_ERROR + if (pid != H5P_DEFAULT) { + if (H5Pget_copy_object(pid, &cpy_flags) < 0) + TEST_ERROR } /* end if */ else cpy_flags = 0; /* Check the number of attributes on source dataset */ - if(H5Oget_info3(oid, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) TEST_ERROR + if (H5Oget_info3(oid, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) + TEST_ERROR /* Check the number of attributes on destination dataset */ - if(H5Oget_info3(oid2, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) TEST_ERROR + if (H5Oget_info3(oid2, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) + TEST_ERROR - if(cpy_flags & H5O_COPY_WITHOUT_ATTR_FLAG) { + if (cpy_flags & H5O_COPY_WITHOUT_ATTR_FLAG) { /* Check that the destination has no attributes */ - if(oinfo2.num_attrs != 0) TEST_ERROR + if (oinfo2.num_attrs != 0) + TEST_ERROR } /* end if */ else { - char attr_name[ATTR_NAME_LEN]; /* Attribute name */ - unsigned i; /* Local index variable */ + char attr_name[ATTR_NAME_LEN]; /* Attribute name */ + unsigned i; /* Local index variable */ /* Compare the number of attributes */ - if(oinfo1.num_attrs != oinfo2.num_attrs) TEST_ERROR + if (oinfo1.num_attrs != oinfo2.num_attrs) + TEST_ERROR /* Check the attributes are equal */ - for(i = 0; i < (unsigned)oinfo1.num_attrs; i++) { - if((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Aget_name(aid, (size_t)ATTR_NAME_LEN, attr_name) < 0) TEST_ERROR + for (i = 0; i < (unsigned)oinfo1.num_attrs; i++) { + if ((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Aget_name(aid, (size_t)ATTR_NAME_LEN, attr_name) < 0) + TEST_ERROR - if((aid2 = H5Aopen(oid2, attr_name, H5P_DEFAULT)) < 0) TEST_ERROR + if ((aid2 = H5Aopen(oid2, attr_name, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check the attributes are equal */ - if(!compare_attribute(aid, aid2, pid, NULL, oid)) TEST_ERROR + if (!compare_attribute(aid, aid2, pid, NULL, oid)) + TEST_ERROR /* Close the attributes */ - if(H5Aclose(aid) < 0) TEST_ERROR - if(H5Aclose(aid2) < 0) TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR + if (H5Aclose(aid2) < 0) + TEST_ERROR } /* end for */ - } /* end if */ + } /* end if */ /* Objects should be the same. :-) */ return TRUE; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid2); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; return FALSE; } /* end compare_std_attributes() */ - /*------------------------------------------------------------------------- * Function: compare_data * @@ -924,166 +1024,192 @@ error: *------------------------------------------------------------------------- */ static int -compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, - const void *buf1, const void *buf2, hid_t obj_owner) +compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, const void *buf1, + const void *buf2, hid_t obj_owner) { - size_t elmt_size; /* Size of an element */ + size_t elmt_size; /* Size of an element */ /* Check size of each element */ - if((elmt_size = H5Tget_size(tid)) == 0) TEST_ERROR + if ((elmt_size = H5Tget_size(tid)) == 0) + TEST_ERROR /* If the type is a compound containing a vlen, loop over all elements for * each compound member. Compounds containing reference are not supported * yet. */ - if((H5Tget_class(tid) == H5T_COMPOUND) - && (H5Tdetect_class(tid, H5T_VLEN) == TRUE)) { - hid_t memb_id; /* Member id */ - const uint8_t *memb1; /* Pointer to current member */ - const uint8_t *memb2; /* Pointer to current member */ - int nmembs; /* Number of members */ - size_t memb_off; /* Member offset */ - size_t memb_size; /* Member size */ - unsigned memb_idx; /* Member index */ - size_t elmt; /* Current element */ + if ((H5Tget_class(tid) == H5T_COMPOUND) && (H5Tdetect_class(tid, H5T_VLEN) == TRUE)) { + hid_t memb_id; /* Member id */ + const uint8_t *memb1; /* Pointer to current member */ + const uint8_t *memb2; /* Pointer to current member */ + int nmembs; /* Number of members */ + size_t memb_off; /* Member offset */ + size_t memb_size; /* Member size */ + unsigned memb_idx; /* Member index */ + size_t elmt; /* Current element */ /* Get number of members in compound */ - if((nmembs = H5Tget_nmembers(tid)) < 0) TEST_ERROR + if ((nmembs = H5Tget_nmembers(tid)) < 0) + TEST_ERROR /* Loop over members */ - for(memb_idx=0; memb_idx<(unsigned)nmembs; memb_idx++) { + for (memb_idx = 0; memb_idx < (unsigned)nmembs; memb_idx++) { /* Get member offset. Note that we cannot check for an error here. */ memb_off = H5Tget_member_offset(tid, memb_idx); /* Get member id */ - if((memb_id = H5Tget_member_type(tid, memb_idx)) < 0) TEST_ERROR + if ((memb_id = H5Tget_member_type(tid, memb_idx)) < 0) + TEST_ERROR /* Get member size */ - if((memb_size = H5Tget_size(memb_id)) == 0) TEST_ERROR + if ((memb_size = H5Tget_size(memb_id)) == 0) + TEST_ERROR /* Set up pointers to member in the first element */ memb1 = (const uint8_t *)buf1 + memb_off; memb2 = (const uint8_t *)buf2 + memb_off; /* Check if this member contains (or is) a vlen */ - if(H5Tget_class(memb_id) == H5T_VLEN) { - hid_t base_id; /* vlen base type id */ + if (H5Tget_class(memb_id) == H5T_VLEN) { + hid_t base_id; /* vlen base type id */ /* Get base type of vlen datatype */ - if((base_id = H5Tget_super(memb_id)) < 0) TEST_ERROR + if ((base_id = H5Tget_super(memb_id)) < 0) + TEST_ERROR /* Iterate over all elements, recursively calling this function * for each */ - for(elmt=0; elmtlen - != ((const hvl_t *)((const void *)memb2))->len) + if (((const hvl_t *)((const void *)memb1))->len != + ((const hvl_t *)((const void *)memb2))->len) TEST_ERROR /* Check vlen data */ - if(!compare_data(parent1, parent2, pid, base_id, - ((const hvl_t *)((const void *)memb1))->len, - ((const hvl_t *)((const void *)memb1))->p, - ((const hvl_t *)((const void *)memb2))->p, obj_owner)) + if (!compare_data(parent1, parent2, pid, base_id, + ((const hvl_t *)((const void *)memb1))->len, + ((const hvl_t *)((const void *)memb1))->p, + ((const hvl_t *)((const void *)memb2))->p, obj_owner)) TEST_ERROR /* Update member pointers */ memb1 += elmt_size; memb2 += elmt_size; } /* end for */ - } else { + } + else { /* vlens cannot currently be nested below the top layer of a * compound */ HDassert(H5Tdetect_class(memb_id, H5T_VLEN) == FALSE); /* Iterate over all elements, calling memcmp() for each */ - for(elmt=0; elmtlen != vl_buf2->len) TEST_ERROR + if (vl_buf1->len != vl_buf2->len) + TEST_ERROR /* Check vlen data */ - if(!compare_data(parent1, parent2, pid, base_tid, vl_buf1->len, vl_buf1->p, vl_buf2->p, obj_owner)) TEST_ERROR + if (!compare_data(parent1, parent2, pid, base_tid, vl_buf1->len, vl_buf1->p, vl_buf2->p, + obj_owner)) + TEST_ERROR } /* end for */ - if(H5Tclose(base_tid) < 0) TEST_ERROR + if (H5Tclose(base_tid) < 0) + TEST_ERROR } /* end if */ - else if(H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) { - size_t u; /* Local index variable */ + else if (H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) { + size_t u; /* Local index variable */ /* Check for "simple" reference datatype */ - if(H5Tget_class(tid) != H5T_REFERENCE) TEST_ERROR + if (H5Tget_class(tid) != H5T_REFERENCE) + TEST_ERROR /* Check for object or region reference */ - if(H5Tequal(tid, H5T_STD_REF_OBJ) > 0) { - const hobj_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */ + if (H5Tequal(tid, H5T_STD_REF_OBJ) > 0) { + const hobj_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */ /* Loop over elements in buffers */ ref_buf1 = (const hobj_ref_t *)buf1; ref_buf2 = (const hobj_ref_t *)buf2; - for(u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) { - hid_t obj1_id, obj2_id; /* IDs for objects referenced */ + for (u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) { + hid_t obj1_id, obj2_id; /* IDs for objects referenced */ H5O_type_t obj1_type, obj2_type; /* Types of objects referenced */ /* Check for types of objects handled */ - if(H5Rget_obj_type2(parent1, H5R_OBJECT, ref_buf1, &obj1_type) < 0) TEST_ERROR - if(H5Rget_obj_type2(parent2, H5R_OBJECT, ref_buf2, &obj2_type) < 0) TEST_ERROR - if(obj1_type != obj2_type) TEST_ERROR + if (H5Rget_obj_type2(parent1, H5R_OBJECT, ref_buf1, &obj1_type) < 0) + TEST_ERROR + if (H5Rget_obj_type2(parent2, H5R_OBJECT, ref_buf2, &obj2_type) < 0) + TEST_ERROR + if (obj1_type != obj2_type) + TEST_ERROR /* Open referenced objects */ - if((obj1_id = H5Rdereference2(parent1, H5P_DEFAULT, H5R_OBJECT, ref_buf1)) < 0) TEST_ERROR - if((obj2_id = H5Rdereference2(parent2, H5P_DEFAULT, H5R_OBJECT, ref_buf2)) < 0) TEST_ERROR + if ((obj1_id = H5Rdereference2(parent1, H5P_DEFAULT, H5R_OBJECT, ref_buf1)) < 0) + TEST_ERROR + if ((obj2_id = H5Rdereference2(parent2, H5P_DEFAULT, H5R_OBJECT, ref_buf2)) < 0) + TEST_ERROR /* break the infinite loop when the ref_object points to itself */ - if(obj_owner > 0) { + if (obj_owner > 0) { H5O_info2_t oinfo1, oinfo2; - int token_cmp; - - if(H5Oget_info3(obj_owner, &oinfo1, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(obj1_id, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(obj1_id, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) TEST_ERROR - if(!token_cmp) { - if(H5Oclose(obj1_id) < 0) TEST_ERROR - if(H5Oclose(obj2_id) < 0) TEST_ERROR + int token_cmp; + + if (H5Oget_info3(obj_owner, &oinfo1, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Oget_info3(obj1_id, &oinfo2, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(obj1_id, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) { + if (H5Oclose(obj1_id) < 0) + TEST_ERROR + if (H5Oclose(obj2_id) < 0) + TEST_ERROR return TRUE; } } /* Check for types of objects handled */ - switch(obj1_type) { + switch (obj1_type) { case H5O_TYPE_DATASET: - if(compare_datasets(obj1_id, obj2_id, pid, NULL) != TRUE) TEST_ERROR + if (compare_datasets(obj1_id, obj2_id, pid, NULL) != TRUE) + TEST_ERROR break; case H5O_TYPE_GROUP: - if(compare_groups(obj1_id, obj2_id, pid, -1, 0) != TRUE) TEST_ERROR + if (compare_groups(obj1_id, obj2_id, pid, -1, 0) != TRUE) + TEST_ERROR break; case H5O_TYPE_NAMED_DATATYPE: - if(H5Tequal(obj1_id, obj2_id) != TRUE) TEST_ERROR + if (H5Tequal(obj1_id, obj2_id) != TRUE) + TEST_ERROR break; case H5O_TYPE_MAP: @@ -1096,57 +1222,72 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, } /* end switch */ /* Close objects */ - if(H5Oclose(obj1_id) < 0) TEST_ERROR - if(H5Oclose(obj2_id) < 0) TEST_ERROR + if (H5Oclose(obj1_id) < 0) + TEST_ERROR + if (H5Oclose(obj2_id) < 0) + TEST_ERROR } /* end for */ - } /* end if */ - else if(H5Tequal(tid, H5T_STD_REF_DSETREG) > 0) { - const hdset_reg_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */ + } /* end if */ + else if (H5Tequal(tid, H5T_STD_REF_DSETREG) > 0) { + const hdset_reg_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */ /* Loop over elements in buffers */ ref_buf1 = (const hdset_reg_ref_t *)buf1; ref_buf2 = (const hdset_reg_ref_t *)buf2; - for(u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) { - hid_t obj1_id, obj2_id; /* IDs for objects referenced */ - hid_t obj1_sid, obj2_sid; /* Dataspace IDs for objects referenced */ + for (u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) { + hid_t obj1_id, obj2_id; /* IDs for objects referenced */ + hid_t obj1_sid, obj2_sid; /* Dataspace IDs for objects referenced */ H5O_type_t obj1_type, obj2_type; /* Types of objects referenced */ /* Check for types of objects handled */ - if(H5Rget_obj_type2(parent1, H5R_DATASET_REGION, ref_buf1, &obj1_type) < 0) TEST_ERROR - if(H5Rget_obj_type2(parent2, H5R_DATASET_REGION, ref_buf2, &obj2_type) < 0) TEST_ERROR - if(obj1_type != obj2_type) TEST_ERROR + if (H5Rget_obj_type2(parent1, H5R_DATASET_REGION, ref_buf1, &obj1_type) < 0) + TEST_ERROR + if (H5Rget_obj_type2(parent2, H5R_DATASET_REGION, ref_buf2, &obj2_type) < 0) + TEST_ERROR + if (obj1_type != obj2_type) + TEST_ERROR /* Open referenced objects */ - if((obj1_id = H5Rdereference2(parent1, H5P_DEFAULT, H5R_DATASET_REGION, ref_buf1)) < 0) TEST_ERROR - if((obj2_id = H5Rdereference2(parent2, H5P_DEFAULT, H5R_DATASET_REGION, ref_buf2)) < 0) TEST_ERROR + if ((obj1_id = H5Rdereference2(parent1, H5P_DEFAULT, H5R_DATASET_REGION, ref_buf1)) < 0) + TEST_ERROR + if ((obj2_id = H5Rdereference2(parent2, H5P_DEFAULT, H5R_DATASET_REGION, ref_buf2)) < 0) + TEST_ERROR /* break the infinite loop when the ref_object points to itself */ - if(obj_owner > 0) { + if (obj_owner > 0) { H5O_info2_t oinfo1, oinfo2; - int token_cmp; - - if(H5Oget_info3(obj_owner, &oinfo1, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(obj1_id, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(obj1_id, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) TEST_ERROR - if(!token_cmp) { - if(H5Oclose(obj1_id) < 0) TEST_ERROR - if(H5Oclose(obj2_id) < 0) TEST_ERROR + int token_cmp; + + if (H5Oget_info3(obj_owner, &oinfo1, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Oget_info3(obj1_id, &oinfo2, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(obj1_id, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) { + if (H5Oclose(obj1_id) < 0) + TEST_ERROR + if (H5Oclose(obj2_id) < 0) + TEST_ERROR return TRUE; } } /* Check for types of objects handled */ - switch(obj1_type) { + switch (obj1_type) { case H5O_TYPE_DATASET: - if(compare_datasets(obj1_id, obj2_id, pid, NULL) != TRUE) TEST_ERROR + if (compare_datasets(obj1_id, obj2_id, pid, NULL) != TRUE) + TEST_ERROR break; case H5O_TYPE_GROUP: - if(compare_groups(obj1_id, obj2_id, pid, -1, 0) != TRUE) TEST_ERROR + if (compare_groups(obj1_id, obj2_id, pid, -1, 0) != TRUE) + TEST_ERROR break; case H5O_TYPE_NAMED_DATATYPE: - if(H5Tequal(obj1_id, obj2_id) != TRUE) TEST_ERROR + if (H5Tequal(obj1_id, obj2_id) != TRUE) + TEST_ERROR break; case H5O_TYPE_MAP: @@ -1159,26 +1300,33 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, } /* end switch */ /* Close objects */ - if(H5Oclose(obj1_id) < 0) TEST_ERROR - if(H5Oclose(obj2_id) < 0) TEST_ERROR + if (H5Oclose(obj1_id) < 0) + TEST_ERROR + if (H5Oclose(obj2_id) < 0) + TEST_ERROR /* Get regions for referenced datasets */ - if((obj1_sid = H5Rget_region(parent1, H5R_DATASET_REGION, ref_buf1)) < 0) TEST_ERROR - if((obj2_sid = H5Rget_region(parent2, H5R_DATASET_REGION, ref_buf2)) < 0) TEST_ERROR + if ((obj1_sid = H5Rget_region(parent1, H5R_DATASET_REGION, ref_buf1)) < 0) + TEST_ERROR + if ((obj2_sid = H5Rget_region(parent2, H5R_DATASET_REGION, ref_buf2)) < 0) + TEST_ERROR /* Check if dataspaces are the same shape */ - if(H5Sselect_shape_same(obj1_sid, obj2_sid) < 0) TEST_ERROR + if (H5Sselect_shape_same(obj1_sid, obj2_sid) < 0) + TEST_ERROR /* Close dataspaces */ - if(H5Sclose(obj1_sid) < 0) TEST_ERROR - if(H5Sclose(obj2_sid) < 0) TEST_ERROR + if (H5Sclose(obj1_sid) < 0) + TEST_ERROR + if (H5Sclose(obj2_sid) < 0) + TEST_ERROR } /* end for */ - } /* end if */ + } /* end if */ else TEST_ERROR } /* end else */ - else - if(HDmemcmp(buf1, buf2, (elmt_size * nelmts))) TEST_ERROR + else if (HDmemcmp(buf1, buf2, (elmt_size * nelmts))) + TEST_ERROR /* Data should be the same. :-) */ return TRUE; @@ -1187,7 +1335,6 @@ error: return FALSE; } /* end compare_data() */ - /*------------------------------------------------------------------------- * Function: compare_datasets * @@ -1203,81 +1350,98 @@ error: static int compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) { - hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property list IDs */ - size_t elmt_size; /* Size of datatype */ - htri_t is_committed; /* If the datatype is committed */ - htri_t is_committed2; /* If the datatype is committed */ - int nfilters; /* Number of filters applied to dataset */ - hssize_t nelmts; /* # of elements in dataspace */ - void *rbuf = NULL; /* Buffer for reading raw data */ - void *rbuf2 = NULL; /* Buffer for reading raw data */ - H5D_space_status_t space_status; /* Dataset's raw dataspace status */ - H5D_space_status_t space_status2; /* Dataset's raw dataspace status */ + hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property list IDs */ + size_t elmt_size; /* Size of datatype */ + htri_t is_committed; /* If the datatype is committed */ + htri_t is_committed2; /* If the datatype is committed */ + int nfilters; /* Number of filters applied to dataset */ + hssize_t nelmts; /* # of elements in dataspace */ + void * rbuf = NULL; /* Buffer for reading raw data */ + void * rbuf2 = NULL; /* Buffer for reading raw data */ + H5D_space_status_t space_status; /* Dataset's raw dataspace status */ + H5D_space_status_t space_status2; /* Dataset's raw dataspace status */ /* Check the datatypes are equal */ /* Open the datatype for the source dataset */ - if((tid = H5Dget_type(did)) < 0) TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR /* Open the datatype for the destination dataset */ - if((tid2 = H5Dget_type(did2)) < 0) TEST_ERROR + if ((tid2 = H5Dget_type(did2)) < 0) + TEST_ERROR /* Check that both datatypes are committed/not committed */ - if((is_committed = H5Tcommitted(tid)) < 0) TEST_ERROR - if((is_committed2 = H5Tcommitted(tid2)) < 0) TEST_ERROR - if(is_committed != is_committed2) TEST_ERROR + if ((is_committed = H5Tcommitted(tid)) < 0) + TEST_ERROR + if ((is_committed2 = H5Tcommitted(tid2)) < 0) + TEST_ERROR + if (is_committed != is_committed2) + TEST_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* Determine the size of datatype (for later) */ - if((elmt_size = H5Tget_size(tid)) == 0) TEST_ERROR - + if ((elmt_size = H5Tget_size(tid)) == 0) + TEST_ERROR /* Check the dataspaces are equal */ /* Open the dataspace for the source dataset */ - if((sid = H5Dget_space(did)) < 0) TEST_ERROR + if ((sid = H5Dget_space(did)) < 0) + TEST_ERROR /* Open the dataspace for the destination dataset */ - if((sid2 = H5Dget_space(did2)) < 0) TEST_ERROR + if ((sid2 = H5Dget_space(did2)) < 0) + TEST_ERROR /* Compare the dataspaces */ - if(H5Sextent_equal(sid, sid2) != TRUE) TEST_ERROR + if (H5Sextent_equal(sid, sid2) != TRUE) + TEST_ERROR /* Determine the number of elements in dataspace (for later) */ - if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) TEST_ERROR - + if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) + TEST_ERROR /* Check the dataset creation property lists are equal */ /* Open the dataset creation property list for the source dataset */ - if((dcpl = H5Dget_create_plist(did)) < 0) TEST_ERROR + if ((dcpl = H5Dget_create_plist(did)) < 0) + TEST_ERROR /* Open the dataset creation property list for the destination dataset */ - if((dcpl2 = H5Dget_create_plist(did2)) < 0) TEST_ERROR + if ((dcpl2 = H5Dget_create_plist(did2)) < 0) + TEST_ERROR /* Compare the rest of the dataset creation property lists */ - if(H5Pequal(dcpl, dcpl2) != TRUE) TEST_ERROR + if (H5Pequal(dcpl, dcpl2) != TRUE) + TEST_ERROR /* Get the number of filters on dataset (for later) */ - if((nfilters = H5Pget_nfilters(dcpl)) < 0) TEST_ERROR + if ((nfilters = H5Pget_nfilters(dcpl)) < 0) + TEST_ERROR /* close the source dataset creation property list */ - if(H5Pclose(dcpl) < 0) TEST_ERROR + if (H5Pclose(dcpl) < 0) + TEST_ERROR /* close the destination dataset creation property list */ - if(H5Pclose(dcpl2) < 0) TEST_ERROR - + if (H5Pclose(dcpl2) < 0) + TEST_ERROR /* Check the allocated storage is the same */ /* Check that the space allocation status is the same */ - if(H5Dget_space_status(did, &space_status) < 0) TEST_ERROR - if(H5Dget_space_status(did2, &space_status2) < 0) TEST_ERROR - if(space_status != space_status2) TEST_ERROR + if (H5Dget_space_status(did, &space_status) < 0) + TEST_ERROR + if (H5Dget_space_status(did2, &space_status2) < 0) + TEST_ERROR + if (space_status != space_status2) + TEST_ERROR /* Check that the space used is the same */ /* (Don't check if the dataset is filtered (i.e. compressed, etc.) and @@ -1285,38 +1449,47 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) * data in each dataset will (probably) be different and the storage * size will thus vary) */ - if(!(nfilters > 0 && (H5Tdetect_class(tid, H5T_VLEN) || - (H5Tdetect_class(tid, H5T_REFERENCE) && H5Tequal(tid, H5T_STD_REF_DSETREG))))) { - hsize_t storage_size = H5Dget_storage_size(did); /* Dataset's raw data storage size */ - hsize_t storage_size2 = H5Dget_storage_size(did2); /* 2nd Dataset's raw data storage size */ + if (!(nfilters > 0 && (H5Tdetect_class(tid, H5T_VLEN) || + (H5Tdetect_class(tid, H5T_REFERENCE) && H5Tequal(tid, H5T_STD_REF_DSETREG))))) { + hsize_t storage_size = H5Dget_storage_size(did); /* Dataset's raw data storage size */ + hsize_t storage_size2 = H5Dget_storage_size(did2); /* 2nd Dataset's raw data storage size */ - if(storage_size != storage_size2) TEST_ERROR + if (storage_size != storage_size2) + TEST_ERROR } /* end if */ /* Check the raw data is equal */ /* Allocate & initialize space for the raw data buffers */ - if((rbuf = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR - if((rbuf2 = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR + if ((rbuf = HDcalloc(elmt_size, (size_t)nelmts)) == NULL) + TEST_ERROR + if ((rbuf2 = HDcalloc(elmt_size, (size_t)nelmts)) == NULL) + TEST_ERROR /* Read data from datasets */ - if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR - if(H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + if (H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf2) < 0) + TEST_ERROR /* Check raw data read in against data written out */ - if(wbuf) { - if(!compare_data(did, (hid_t)0, pid, tid, (size_t)nelmts, wbuf, rbuf, did)) TEST_ERROR - if(!compare_data(did2, (hid_t)0, pid, tid2, (size_t)nelmts, wbuf, rbuf2, did2)) TEST_ERROR + if (wbuf) { + if (!compare_data(did, (hid_t)0, pid, tid, (size_t)nelmts, wbuf, rbuf, did)) + TEST_ERROR + if (!compare_data(did2, (hid_t)0, pid, tid2, (size_t)nelmts, wbuf, rbuf2, did2)) + TEST_ERROR } /* end if */ /* Don't have written data, just compare data between the two datasets */ - else - if(!compare_data(did, did2, pid, tid, (size_t)nelmts, rbuf, rbuf2, did)) TEST_ERROR + else if (!compare_data(did, did2, pid, tid, (size_t)nelmts, rbuf, rbuf2, did)) + TEST_ERROR /* Reclaim vlen data, if necessary */ - if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) - if(H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR - if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) - if(H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE) + if (H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + if (H5Tdetect_class(tid2, H5T_VLEN) == TRUE) + if (H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) + TEST_ERROR /* Release raw data buffers */ HDfree(rbuf); @@ -1325,30 +1498,34 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) rbuf2 = NULL; /* close the source dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR /* close the destination dataspace */ - if(H5Sclose(sid2) < 0) TEST_ERROR + if (H5Sclose(sid2) < 0) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the destination datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR - + if (H5Tclose(tid2) < 0) + TEST_ERROR /* Check if the attributes are equal */ - if(compare_std_attributes(did, did2, pid) != TRUE) TEST_ERROR - + if (compare_std_attributes(did, did2, pid) != TRUE) + TEST_ERROR /* Datasets should be the same. :-) */ return TRUE; error: - H5E_BEGIN_TRY { - if(rbuf) + H5E_BEGIN_TRY + { + if (rbuf) HDfree(rbuf); - if(rbuf2) + if (rbuf2) HDfree(rbuf2); H5Pclose(dcpl2); H5Pclose(dcpl); @@ -1356,11 +1533,11 @@ error: H5Sclose(sid); H5Tclose(tid2); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return FALSE; } /* end compare_datasets() */ - /*------------------------------------------------------------------------- * Function: compare_groups * @@ -1376,102 +1553,126 @@ error: static int compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) { - H5G_info_t ginfo; /* Group info struct */ - H5G_info_t ginfo2; /* Group info struct */ - hsize_t idx; /* Index over the objects in group */ - unsigned cpy_flags; /* Object copy flags */ + H5G_info_t ginfo; /* Group info struct */ + H5G_info_t ginfo2; /* Group info struct */ + hsize_t idx; /* Index over the objects in group */ + unsigned cpy_flags; /* Object copy flags */ /* Retrieve the object copy flags from the property list, if it's non-DEFAULT */ - if(pid != H5P_DEFAULT) { - if(H5Pget_copy_object(pid, &cpy_flags) < 0) TEST_ERROR + if (pid != H5P_DEFAULT) { + if (H5Pget_copy_object(pid, &cpy_flags) < 0) + TEST_ERROR } /* end if */ else cpy_flags = 0; /* Check if both groups have the same # of objects */ - if(H5Gget_info(gid, &ginfo) < 0) TEST_ERROR - if(H5Gget_info(gid2, &ginfo2) < 0) TEST_ERROR - if((cpy_flags & H5O_COPY_SHALLOW_HIERARCHY_FLAG) && depth == 0) { - if(ginfo2.nlinks != 0) TEST_ERROR + if (H5Gget_info(gid, &ginfo) < 0) + TEST_ERROR + if (H5Gget_info(gid2, &ginfo2) < 0) + TEST_ERROR + if ((cpy_flags & H5O_COPY_SHALLOW_HIERARCHY_FLAG) && depth == 0) { + if (ginfo2.nlinks != 0) + TEST_ERROR } /* end if */ else { - if(ginfo.nlinks != ginfo2.nlinks) TEST_ERROR + if (ginfo.nlinks != ginfo2.nlinks) + TEST_ERROR } /* end if */ /* Check contents of groups */ - if(ginfo2.nlinks > 0) { - char objname[NAME_BUF_SIZE]; /* Name of object in group */ - char objname2[NAME_BUF_SIZE]; /* Name of object in group */ - H5L_info2_t linfo; /* Link information */ - H5L_info2_t linfo2; /* Link information */ + if (ginfo2.nlinks > 0) { + char objname[NAME_BUF_SIZE]; /* Name of object in group */ + char objname2[NAME_BUF_SIZE]; /* Name of object in group */ + H5L_info2_t linfo; /* Link information */ + H5L_info2_t linfo2; /* Link information */ /* Loop over contents of groups */ - for(idx = 0; idx < ginfo.nlinks; idx++) { + for (idx = 0; idx < ginfo.nlinks; idx++) { /* Check name of objects */ - if(H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_name_by_idx(gid2, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(objname, objname2)) TEST_ERROR + if (H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname, (size_t)NAME_BUF_SIZE, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_name_by_idx(gid2, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname2, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(objname, objname2)) + TEST_ERROR /* Get link info */ - if(H5Lget_info2(gid, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info2(gid2, objname2, &linfo2, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.type != linfo2.type) TEST_ERROR + if (H5Lget_info2(gid, objname, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info2(gid2, objname2, &linfo2, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.type != linfo2.type) + TEST_ERROR /* Extra checks for "real" objects */ - if(linfo.type == H5L_TYPE_HARD) { - hid_t oid, oid2; /* IDs of objects within group */ - H5O_info2_t oinfo, oinfo2; /* Data model object info */ - H5O_native_info_t ninfo, ninfo2; /* Native file format object info */ + if (linfo.type == H5L_TYPE_HARD) { + hid_t oid, oid2; /* IDs of objects within group */ + H5O_info2_t oinfo, oinfo2; /* Data model object info */ + H5O_native_info_t ninfo, ninfo2; /* Native file format object info */ /* Compare some pieces of the object info */ /* Get data model object info */ - if(H5Oget_info_by_name3(gid, objname, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(gid2, objname2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_info_by_name3(gid, objname, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(gid2, objname2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR /* Get native object info */ - if(H5Oget_native_info_by_name(gid, objname, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_native_info_by_name(gid2, objname2, &ninfo2, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_native_info_by_name(gid, objname, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_native_info_by_name(gid2, objname2, &ninfo2, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) + TEST_ERROR - if(oinfo.type != oinfo2.type) TEST_ERROR - if(oinfo.rc != oinfo2.rc) TEST_ERROR + if (oinfo.type != oinfo2.type) + TEST_ERROR + if (oinfo.rc != oinfo2.rc) + TEST_ERROR /* If NULL messages are preserved, the number of messages * should be the same in the destination. * Otherwise, it should simply be true that the number * of messages hasn't increased. */ - if(H5O_COPY_PRESERVE_NULL_FLAG & copy_flags) { - if(ninfo.hdr.nmesgs != ninfo2.hdr.nmesgs) + if (H5O_COPY_PRESERVE_NULL_FLAG & copy_flags) { + if (ninfo.hdr.nmesgs != ninfo2.hdr.nmesgs) ; - else - if(ninfo.hdr.nmesgs < ninfo2.hdr.nmesgs) TEST_ERROR - } + else if (ninfo.hdr.nmesgs < ninfo2.hdr.nmesgs) + TEST_ERROR + } /* Check for object already having been compared */ - if(token_lookup(gid, &oinfo)) + if (token_lookup(gid, &oinfo)) continue; else token_insert(&oinfo); /* Open objects */ - if((oid = H5Oopen(gid, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((oid2 = H5Oopen(gid2, objname2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((oid = H5Oopen(gid, objname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((oid2 = H5Oopen(gid2, objname2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Compare objects within group */ - switch(oinfo.type) { + switch (oinfo.type) { case H5O_TYPE_GROUP: /* Compare groups */ - if(compare_groups(oid, oid2, pid, depth - 1, copy_flags) != TRUE) TEST_ERROR + if (compare_groups(oid, oid2, pid, depth - 1, copy_flags) != TRUE) + TEST_ERROR break; case H5O_TYPE_DATASET: /* Compare datasets */ - if(compare_datasets(oid, oid2, pid, NULL) != TRUE) TEST_ERROR + if (compare_datasets(oid, oid2, pid, NULL) != TRUE) + TEST_ERROR break; case H5O_TYPE_NAMED_DATATYPE: /* Compare datatypes */ - if(H5Tequal(oid, oid2) != TRUE) TEST_ERROR + if (H5Tequal(oid, oid2) != TRUE) + TEST_ERROR break; case H5O_TYPE_MAP: @@ -1485,47 +1686,55 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) } /* end switch */ /* Close objects */ - if(H5Oclose(oid) < 0) TEST_ERROR - if(H5Oclose(oid2) < 0) TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR + if (H5Oclose(oid2) < 0) + TEST_ERROR } /* end if */ else { /* Check that both links are the same size */ - if(linfo.u.val_size != linfo2.u.val_size) TEST_ERROR + if (linfo.u.val_size != linfo2.u.val_size) + TEST_ERROR /* Compare link values */ - if(linfo.type == H5L_TYPE_SOFT || - (linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX)) { - char linkval[NAME_BUF_SIZE]; /* Link value */ - char linkval2[NAME_BUF_SIZE]; /* Link value */ + if (linfo.type == H5L_TYPE_SOFT || + (linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX)) { + char linkval[NAME_BUF_SIZE]; /* Link value */ + char linkval2[NAME_BUF_SIZE]; /* Link value */ /* Get link values */ HDassert(linfo.u.val_size <= NAME_BUF_SIZE); - if(H5Lget_val(gid, objname, linkval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_val(gid, objname, linkval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR /* Compare link data */ - if(HDmemcmp(linkval, linkval2, linfo.u.val_size)) TEST_ERROR + if (HDmemcmp(linkval, linkval2, linfo.u.val_size)) + TEST_ERROR } /* end else-if */ else { -HDassert(0 && "Unknown type of link"); + HDassert(0 && "Unknown type of link"); } /* end else */ - } /* end else */ - } /* end for */ - } /* end if */ + } /* end else */ + } /* end for */ + } /* end if */ /* Check if the attributes are equal */ - if(compare_std_attributes(gid, gid2, pid) != TRUE) TEST_ERROR + if (compare_std_attributes(gid, gid2, pid) != TRUE) + TEST_ERROR /* Groups should be the same. :-) */ return TRUE; error: - H5E_BEGIN_TRY { - } H5E_END_TRY; + H5E_BEGIN_TRY + { + } + H5E_END_TRY; return FALSE; } /* end compare_groups() */ - /*------------------------------------------------------------------------- * Function: compare_idx_type * @@ -1544,29 +1753,29 @@ static int compare_idx_type(hid_t fapl, hid_t did, H5D_chunk_index_t new_type, H5D_chunk_index_t old_type) { H5D_chunk_index_t idx_type; /* Dataset chunk index type */ - H5F_libver_t low; /* File format low bound */ + H5F_libver_t low; /* File format low bound */ /* Get the chunk index type */ - if(H5D__layout_idx_type_test(did, &idx_type) < 0) - FAIL_STACK_ERROR + if (H5D__layout_idx_type_test(did, &idx_type) < 0) + FAIL_STACK_ERROR /* Check if we are using the latest version of the format */ - if(H5Pget_libver_bounds(fapl, &low, NULL) < 0) - FAIL_STACK_ERROR + if (H5Pget_libver_bounds(fapl, &low, NULL) < 0) + FAIL_STACK_ERROR /* Verify index type */ - if(low == H5F_LIBVER_LATEST) { - if(idx_type != new_type) + if (low == H5F_LIBVER_LATEST) { + if (idx_type != new_type) + TEST_ERROR + } + else if (idx_type != old_type) TEST_ERROR - } else if(idx_type != old_type) - TEST_ERROR return TRUE; error: return FALSE; } /* compare_idx_type() */ - /*------------------------------------------------------------------------- * Function: test_copy_named_datatype * @@ -1583,10 +1792,10 @@ error: static int test_copy_named_datatype(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): named datatype"); @@ -1598,68 +1807,85 @@ test_copy_named_datatype(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t d token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the datatype from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATATYPE_SIMPLE, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATATYPE_SIMPLE, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the datatype for copy */ - if((tid = H5Topen2(fid_src, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid = H5Topen2(fid_src, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the copied datatype */ - if((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* close the destination datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid2); H5Tclose(tid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_named_datatype */ - /*------------------------------------------------------------------------- * Function: test_copy_named_datatype_vl * @@ -1676,10 +1902,10 @@ error: static int test_copy_named_datatype_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): named vlen datatype"); @@ -1691,68 +1917,85 @@ test_copy_named_datatype_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_ token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the datatype from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATATYPE_VL, fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATATYPE_VL, fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the datatype for copy */ - if((tid = H5Topen2(fid_src, NAME_DATATYPE_VL, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid = H5Topen2(fid_src, NAME_DATATYPE_VL, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the copied datatype */ - if((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* close the destination datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid2); H5Tclose(tid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_named_datatype_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_named_datatype_vl_vl * @@ -1769,10 +2012,10 @@ error: static int test_copy_named_datatype_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): named nested vlen datatype"); @@ -1784,74 +2027,93 @@ test_copy_named_datatype_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* create first vlen datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create second (nested) vlen datatype */ - if((tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR + if ((tid2 = H5Tvlen_create(tid)) < 0) + TEST_ERROR /* create named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_VL_VL, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_VL_VL, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the first datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the second datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the datatype from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATATYPE_VL_VL, fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATATYPE_VL_VL, fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the datatype for copy */ - if((tid = H5Topen2(fid_src, NAME_DATATYPE_VL_VL, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid = H5Topen2(fid_src, NAME_DATATYPE_VL_VL, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the copied datatype */ - if((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* close the destination datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid2); H5Tclose(tid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_named_datatype_vl_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_named_datatype_attr_self * @@ -1870,16 +2132,16 @@ error: static int test_copy_named_datatype_attr_self(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - hid_t aid = -1; /* Attribute ID */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t dims[2] = {3, 4}; /* Dataspace dimensions */ - H5O_info2_t oinfo, oinfo2; /* Object info */ - H5G_info_t ginfo; /* Group info */ - hbool_t same_type; - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + hid_t aid = -1; /* Attribute ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dims[2] = {3, 4}; /* Dataspace dimensions */ + H5O_info2_t oinfo, oinfo2; /* Object info */ + H5G_info_t ginfo; /* Group info */ + hbool_t same_type; + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): named datatype with self-referential attribute"); @@ -1891,119 +2153,150 @@ test_copy_named_datatype_attr_self(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataspace */ - if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR /* create attribute */ - if((aid = H5Acreate2(tid, "attr_self", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((aid = H5Acreate2(tid, "attr_self", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* attach other attributes to the dataset */ - if(test_copy_attach_attributes(tid, tid) < 0) TEST_ERROR + if (test_copy_attach_attributes(tid, tid) < 0) + TEST_ERROR /* close the attribute */ - if(H5Aclose(aid) < 0) TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the datatype from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATATYPE_SIMPLE, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATATYPE_SIMPLE, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the source datatype */ - if((tid = H5Topen2(fid_src, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid = H5Topen2(fid_src, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the copied datatype */ - if((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* open the destination attribute */ - if((aid = H5Aopen(tid2, "attr_self", H5P_DEFAULT)) < 0) TEST_ERROR + if ((aid = H5Aopen(tid2, "attr_self", H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination attribute's datatype */ - if((tid = H5Aget_type(aid)) < 0) TEST_ERROR + if ((tid = H5Aget_type(aid)) < 0) + TEST_ERROR /* verify that the attribute's datatype is committed */ - if(H5Tcommitted(tid) != TRUE) TEST_ERROR + if (H5Tcommitted(tid) != TRUE) + TEST_ERROR /* verify that the tokens of the datatypes are the same */ - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(tid2, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Oget_info3(tid2, &oinfo2, H5O_INFO_BASIC) < 0) + TEST_ERROR same_type = TRUE; - if(oinfo.fileno == oinfo2.fileno) { + if (oinfo.fileno == oinfo2.fileno) { int token_cmp; - if(H5Otoken_cmp(tid2, &oinfo.token, &oinfo2.token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) same_type = FALSE; + if (H5Otoken_cmp(tid2, &oinfo.token, &oinfo2.token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + same_type = FALSE; } else same_type = FALSE; - if(!same_type) + if (!same_type) FAIL_PUTS_ERROR("destination attribute does not use the same committed datatype") /* Verify that there are only 2 links int he destination root group */ - if(H5Gget_info(fid_dst, &ginfo) < 0) - if(ginfo.nlinks != 2) - FAIL_PUTS_ERROR("unexpected number of links in destination root group") + if (H5Gget_info(fid_dst, &ginfo) < 0) + if (ginfo.nlinks != 2) + FAIL_PUTS_ERROR("unexpected number of links in destination root group") /* close the attribute */ - if(H5Aclose(aid) < 0) TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR /* close the datatypes */ - if(H5Tclose(tid2) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); H5Aclose(aid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_named_datatype_attr_self */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_simple * @@ -2020,21 +2313,21 @@ error: static int test_copy_dataset_simple(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ - hsize_t dim2d[2]; /* Dataset dimensions */ - int i, j; /* local index variables */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ + hsize_t dim2d[2]; /* Dataset dimensions */ + int i, j; /* local index variables */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): simple dataset"); /* Initialize write buffer */ - for (i=0; ishared->layout.version; /* Close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR /* Close the dataset */ - if(H5Dclose(did_src) < 0) TEST_ERROR + if (H5Dclose(did_src) < 0) + TEST_ERROR /* Close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* Open the source file with read-only */ fid_src = H5Fopen(src_fname, H5F_ACC_RDONLY, fapl_src); - if (fid_src < 0) TEST_ERROR + if (fid_src < 0) + TEST_ERROR /* Loop through all the combinations of low/high library format bounds, skipping invalid combinations. Create a destination file and copy the source dataset to it, then verify */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Set version bounds */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(fapl_dst, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ continue; /* Create destination file */ fid_dst = H5Fcreate(dst_fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_dst); - if (fid_dst < 0) TEST_ERROR + if (fid_dst < 0) + TEST_ERROR /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Try to copy the dataset */ - H5E_BEGIN_TRY { - ret = H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, + H5P_DEFAULT); + } + H5E_END_TRY; /* If copy failed, check if the failure is expected */ - if (ret < 0) - { + if (ret < 0) { /* Failure is valid if layout version of source dataset is greater than destination */ if (srcdset_layoutversion <= H5O_layout_ver_bounds[high]) TEST_ERROR /* Close the DST file before continue */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR continue; } /* Close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Open destination file */ fid_dst = H5Fopen(dst_fname, H5F_ACC_RDWR, fapl_dst); - if (fid_dst < 0) TEST_ERROR + if (fid_dst < 0) + TEST_ERROR /* Open the datasets to compare */ did_src = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT); - if (did_src < 0) TEST_ERROR + if (did_src < 0) + TEST_ERROR did_dst = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT); - if (did_dst < 0) TEST_ERROR + if (did_dst < 0) + TEST_ERROR /* Check if the datasets are equal */ if (compare_datasets(did_src, did_dst, H5P_DEFAULT, buf) != TRUE) TEST_ERROR /* Close the datasets */ - if(H5Dclose(did_dst) < 0) TEST_ERROR - if(H5Dclose(did_src) < 0) TEST_ERROR + if (H5Dclose(did_dst) < 0) + TEST_ERROR + if (H5Dclose(did_src) < 0) + TEST_ERROR /* Close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR } /* for high */ - } /* for low */ + } /* for low */ /* Close property list and source file */ - if (H5Pclose(fapl_dst) < 0) TEST_ERROR - if (H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Pclose(fapl_dst) < 0) + TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did_dst); H5Dclose(did_src); H5Sclose(sid); H5Pclose(fapl_dst); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_versionbounds */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_simple_samefile * @@ -2313,20 +2655,20 @@ error: static int test_copy_dataset_simple_samefile(hid_t fcpl, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ - hsize_t dim2d[2]; /* Dataset dimensions */ - int i, j; /* local index variables */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ + hsize_t dim2d[2]; /* Dataset dimensions */ + int i, j; /* local index variables */ + char filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): simple dataset within the same file"); /* Initialize write buffer */ - for (i=0; i 0) + if (sid > 0) H5Sclose(sid); - if(tid > 0) + if (tid > 0) H5Tclose(tid); - if(vl_str_tid > 0) + if (vl_str_tid > 0) H5Tclose(vl_str_tid); - if(cmpd_tid > 0) + if (cmpd_tid > 0) H5Tclose(cmpd_tid); - if(aid > 0) + if (aid > 0) H5Aclose(aid); HDfree(buf.v); @@ -5882,71 +6988,79 @@ done: static int compare_attribute_compound_vlstr(hid_t loc, hid_t loc2) { - hid_t aid = -1, aid2 = -1; /* Attribute IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ + hid_t aid = -1, aid2 = -1; /* Attribute IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ hid_t dxpl_id = -1; - typedef struct { /* Compound structure for the attribute */ - int i; - char *v; + typedef struct { /* Compound structure for the attribute */ + int i; + char *v; } s1; - s1 rbuf; /* Buffer for data read */ - s1 rbuf2; /* Buffer for data read */ + s1 rbuf; /* Buffer for data read */ + s1 rbuf2; /* Buffer for data read */ /* Open the attributes attached to the objects */ - if((aid = H5Aopen_by_idx(loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - if((aid2 = H5Aopen_by_idx(loc2, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((aid = H5Aopen_by_idx(loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((aid2 = H5Aopen_by_idx(loc2, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Get the attributes' datatypes */ - if((tid = H5Aget_type(aid)) < 0) - FAIL_STACK_ERROR - if((tid2 = H5Aget_type(aid2)) < 0) - FAIL_STACK_ERROR + if ((tid = H5Aget_type(aid)) < 0) + FAIL_STACK_ERROR + if ((tid2 = H5Aget_type(aid2)) < 0) + FAIL_STACK_ERROR /* Get the attributes' dataspaces */ - if((sid = H5Aget_space(aid)) < 0) - FAIL_STACK_ERROR - if((sid2 = H5Aget_space(aid2)) < 0) - FAIL_STACK_ERROR + if ((sid = H5Aget_space(aid)) < 0) + FAIL_STACK_ERROR + if ((sid2 = H5Aget_space(aid2)) < 0) + FAIL_STACK_ERROR /* Read the attributes */ - if(H5Aread(aid, tid, &rbuf) < 0) - FAIL_STACK_ERROR - if(H5Aread(aid2, tid2, &rbuf2) < 0) - FAIL_STACK_ERROR + if (H5Aread(aid, tid, &rbuf) < 0) + FAIL_STACK_ERROR + if (H5Aread(aid2, tid2, &rbuf2) < 0) + FAIL_STACK_ERROR /* Compare the attributes' data */ - if(rbuf.i != rbuf2.i) - FAIL_STACK_ERROR - if(HDstrlen(rbuf.v) != HDstrlen(rbuf2.v)) - FAIL_STACK_ERROR - if(HDmemcmp(rbuf.v, rbuf2.v, HDstrlen(rbuf.v))) - FAIL_STACK_ERROR + if (rbuf.i != rbuf2.i) + FAIL_STACK_ERROR + if (HDstrlen(rbuf.v) != HDstrlen(rbuf2.v)) + FAIL_STACK_ERROR + if (HDmemcmp(rbuf.v, rbuf2.v, HDstrlen(rbuf.v))) + FAIL_STACK_ERROR /* Reclaim vlen buffer */ - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid, sid, dxpl_id, &rbuf) < 0) TEST_ERROR - if(H5Treclaim(tid, sid, dxpl_id, &rbuf2) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid, sid, dxpl_id, &rbuf) < 0) + TEST_ERROR + if (H5Treclaim(tid, sid, dxpl_id, &rbuf2) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR /* Close the dataspaces */ - if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR - if(H5Sclose(sid2) < 0) - FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(sid2) < 0) + FAIL_STACK_ERROR /* Close the attributes */ - if(H5Aclose(aid) < 0) - FAIL_STACK_ERROR - if(H5Aclose(aid2) < 0) - FAIL_STACK_ERROR + if (H5Aclose(aid) < 0) + FAIL_STACK_ERROR + if (H5Aclose(aid2) < 0) + FAIL_STACK_ERROR return TRUE; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Aclose(aid2); H5Treclaim(tid, sid, H5P_DEFAULT, &rbuf); @@ -5956,7 +7070,8 @@ error: H5Tclose(tid); H5Tclose(tid2); H5Pclose(dxpl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FALSE; } /* compare_attribute_compound_vlstr() */ @@ -5980,14 +7095,14 @@ error: static int test_copy_attribute_compound_vlstr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t aid = -1, aid2 = -1; /* Attribute IDs */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hsize_t dim2d[2]; /* Dataset dimensions */ - char src_filename[NAME_BUF_SIZE]; /* Source file name */ - char dst_filename[NAME_BUF_SIZE]; /* Destination file name */ + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t aid = -1, aid2 = -1; /* Attribute IDs */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hsize_t dim2d[2]; /* Dataset dimensions */ + char src_filename[NAME_BUF_SIZE]; /* Source file name */ + char dst_filename[NAME_BUF_SIZE]; /* Destination file name */ TESTING("H5Ocopy(): attribute with compound datatype consisting of variable length string"); @@ -5999,118 +7114,120 @@ test_copy_attribute_compound_vlstr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) - FAIL_STACK_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + FAIL_STACK_ERROR /* set dataspace dimensions */ dim2d[0] = DIM_SIZE_1; dim2d[1] = DIM_SIZE_2; /* create 2D dataspace */ - if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) - FAIL_STACK_ERROR + if ((sid = H5Screate_simple(2, dim2d, NULL)) < 0) + FAIL_STACK_ERROR /* create 2D int dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) + FAIL_STACK_ERROR /* attach an attribute to the dataset */ - if(attach_attribute_compound_vlstr(did) < 0) - FAIL_STACK_ERROR + if (attach_attribute_compound_vlstr(did) < 0) + FAIL_STACK_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* create a group */ - if((gid = H5Gcreate2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* attach attribute to the group */ - if(attach_attribute_compound_vlstr(gid) < 0) - FAIL_STACK_ERROR + if (attach_attribute_compound_vlstr(gid) < 0) + FAIL_STACK_ERROR /* close the group */ - if(H5Gclose(gid) < 0) - FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) - FAIL_STACK_ERROR - + if (H5Fclose(fid_src) < 0) + FAIL_STACK_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) - FAIL_STACK_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + FAIL_STACK_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) - FAIL_STACK_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + FAIL_STACK_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) - FAIL_STACK_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* open the src dataset */ - if((did = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* compare the data of the attributes attached to the two datasets */ - if(compare_attribute_compound_vlstr(did, did2) < 0) - FAIL_STACK_ERROR + if (compare_attribute_compound_vlstr(did, did2) < 0) + FAIL_STACK_ERROR /* close the datasets */ - if(H5Dclose(did2) < 0) - FAIL_STACK_ERROR - if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + if (H5Dclose(did2) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did) < 0) + FAIL_STACK_ERROR /* Copy the group */ - if(H5Ocopy(fid_src, NAME_GROUP_EMPTY, fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT) < 0) - FAIL_STACK_ERROR + if (H5Ocopy(fid_src, NAME_GROUP_EMPTY, fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the src group */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* compare the data of the attributes attached to the two groups */ - if(compare_attribute_compound_vlstr(gid, gid2) < 0) - FAIL_STACK_ERROR + if (compare_attribute_compound_vlstr(gid, gid2) < 0) + FAIL_STACK_ERROR /* close the groups */ - if(H5Gclose(gid) < 0) - FAIL_STACK_ERROR - if(H5Gclose(gid2) < 0) - FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid_src) < 0) + FAIL_STACK_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid_dst) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid2); H5Aclose(aid); H5Dclose(did2); @@ -6120,11 +7237,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_attribute_compound_vlstr() */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_compressed_vl * @@ -6143,18 +7260,18 @@ static int test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { #ifdef H5_HAVE_FILTER_DEFLATE - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - hsize_t dim2d[2]; /* Dataset dimensions */ - hsize_t chunk_dim2d[2] ={CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */ - hvl_t buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ - int i, j, k; /* Local index variables */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + hsize_t dim2d[2]; /* Dataset dimensions */ + hsize_t chunk_dim2d[2] = {CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */ + hvl_t buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ + int i, j, k; /* Local index variables */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; #endif /* H5_HAVE_FILTER_DEFLATE */ TESTING("H5Ocopy(): compressed dataset with VLEN datatype"); @@ -6162,12 +7279,12 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, #ifndef H5_HAVE_FILTER_DEFLATE SKIPPED(); puts(" Deflation filter not available"); -#else /* H5_HAVE_FILTER_DEFLATE */ +#else /* H5_HAVE_FILTER_DEFLATE */ /* set initial data values */ for (i = 0; i < DIM_SIZE_1; i++) { for (j = 0; j < DIM_SIZE_2; j++) { buf[i][j].len = (size_t)(j + 1); - buf[i][j].p = (int *)HDmalloc(buf[i][j].len * sizeof(int)); + buf[i][j].p = (int *)HDmalloc(buf[i][j].len * sizeof(int)); for (k = 0; k < (int)buf[i][j].len; k++) ((int *)buf[i][j].p)[k] = i * 10000 + j * 100 + k; } @@ -6181,85 +7298,113 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim2d[0]=DIM_SIZE_1; - dim2d[1]=DIM_SIZE_2; + dim2d[0] = DIM_SIZE_1; + dim2d[1] = DIM_SIZE_2; /* create dataspace */ - if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(2, dim2d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create and set comp & chunk plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(pid, 2, chunk_dim2d) < 0) TEST_ERROR - if(H5Pset_deflate(pid, 9) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(pid, 2, chunk_dim2d) < 0) + TEST_ERROR + if (H5Pset_deflate(pid, 9) < 0) + TEST_ERROR /* create dataset */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_CHUNKED, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* close chunk plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); #endif /* H5_HAVE_FILTER_DEFLATE */ @@ -6267,7 +7412,8 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, #ifdef H5_HAVE_FILTER_DEFLATE error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did2); H5Dclose(did); H5Pclose(pid); @@ -6277,12 +7423,12 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; #endif /* H5_HAVE_FILTER_DEFLATE */ } /* end test_copy_dataset_compressed_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_group_empty * @@ -6299,10 +7445,10 @@ error: static int test_copy_group_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): empty group"); @@ -6314,68 +7460,85 @@ test_copy_group_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_ token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* create group at the SRC file */ - if((gid = H5Gcreate2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* attach attributes to the group */ - if(test_copy_attach_attributes(gid, H5T_NATIVE_INT) < 0) TEST_ERROR + if (test_copy_attach_attributes(gid, H5T_NATIVE_INT) < 0) + TEST_ERROR /* close the group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the group from SRC to DST */ - if(H5Ocopy(fid_src, NAME_GROUP_EMPTY, fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_GROUP_EMPTY, fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Check if the groups are equal */ - if(compare_groups(gid, gid2, H5P_DEFAULT, -1, 0) != TRUE) TEST_ERROR + if (compare_groups(gid, gid2, H5P_DEFAULT, -1, 0) != TRUE) + TEST_ERROR /* close the destination group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* close the source group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_group_empty */ - /*------------------------------------------------------------------------- * Function: test_copy_root_group * @@ -6392,23 +7555,23 @@ error: static int test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t gid_sub = -1; /* Sub-group ID */ + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t gid_sub = -1; /* Sub-group ID */ hsize_t dim2d[2]; - int buf[DIM_SIZE_1][DIM_SIZE_2]; - int i, j; - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + int buf[DIM_SIZE_1][DIM_SIZE_2]; + int i, j; + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): root group"); /* set initial data values */ - for (i=0; i= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_exist */ - /*------------------------------------------------------------------------- * Function: test_copy_path * @@ -7670,23 +9106,23 @@ error: static int test_copy_path(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t gid = -1; /* Group ID */ - int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ - hsize_t dim2d[2]; /* Dataset dimensions */ - int i, j; /* local index variables */ - herr_t ret; /* Generic return value */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t gid = -1; /* Group ID */ + int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ + hsize_t dim2d[2]; /* Dataset dimensions */ + int i, j; /* local index variables */ + herr_t ret; /* Generic return value */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): full path"); /* Initialize write buffer */ - for (i=0; i= 0) TEST_ERROR + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR /* Create the intermediate groups in destination file */ - if((gid = H5Gcreate2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if((gid = H5Gcreate2(fid_dst, NAME_GROUP_SUB, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid_dst, NAME_GROUP_SUB, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR - if((gid = H5Gcreate2(fid_dst, NAME_GROUP_SUB_SUB, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid_dst, NAME_GROUP_SUB_SUB, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* copy the dataset from SRC to DST, using full path */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did2); H5Dclose(did); H5Sclose(sid); H5Gclose(gid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_path */ - /*------------------------------------------------------------------------- * Function: test_copy_same_file_named_datatype * @@ -7805,9 +9271,9 @@ error: static int test_copy_same_file_named_datatype(hid_t fcpl_src, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + char filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): named datatype in same file"); @@ -7818,46 +9284,55 @@ test_copy_same_file_named_datatype(hid_t fcpl_src, hid_t fapl) token_reset(); /* create source file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create named datatype */ - if((H5Tcommit2(fid, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - + if ((H5Tcommit2(fid, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the datatype from SRC to DST */ - if(H5Ocopy(fid, NAME_DATATYPE_SIMPLE, fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid, NAME_DATATYPE_SIMPLE, fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the copied datatype */ - if((tid2 = H5Topen2(fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((tid2 = H5Topen2(fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* close the destination datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid2); H5Tclose(tid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_same_file_named_datatype */ - /*------------------------------------------------------------------------- * Function: test_copy_old_layout * @@ -7878,15 +9353,16 @@ error: static int test_copy_old_layout(hid_t fcpl_dst, hid_t fapl, hbool_t test_open) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t src_fapl = -1; /* Source file FAPL ID */ + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t src_fapl = -1; /* Source file FAPL ID */ const char *src_filename = H5_get_srcdir_filename(FILE_OLD_LAYOUT); /* Corrected test file name */ - char dst_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; - if(test_open) { + if (test_open) { TESTING("H5Ocopy(): opened dataset with old layout format"); - } else { + } + else { TESTING("H5Ocopy(): dataset with old layout format"); } @@ -7897,66 +9373,82 @@ test_copy_old_layout(hid_t fcpl_dst, hid_t fapl, hbool_t test_open) token_reset(); /* Setup */ - if((src_fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) TEST_ERROR + if ((src_fapl = h5_fileaccess_flags(H5_FILEACCESS_LIBVER)) < 0) + TEST_ERROR /* open source file (read-only) */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* Close source FAPL */ - if(H5Pclose(src_fapl) < 0) TEST_ERROR + if (H5Pclose(src_fapl) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR - if(test_open) { + if (test_open) { /* open the source dataset */ - if((did = H5Dopen2(fid_src, NAME_OLD_FORMAT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_OLD_FORMAT, H5P_DEFAULT)) < 0) + TEST_ERROR } /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_OLD_FORMAT, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_OLD_FORMAT, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - if(!test_open) { + if (!test_open) { /* open the source dataset */ - if((did = H5Dopen2(fid_src, NAME_OLD_FORMAT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_OLD_FORMAT, H5P_DEFAULT)) < 0) + TEST_ERROR } /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(src_fapl); H5Dclose(did2); H5Dclose(did); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_old_layout */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_compact_named_vl * @@ -7974,25 +9466,25 @@ error: static int test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid_copy=-1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid_copy = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): compact dataset with named VLEN datatype"); /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].len = i+1; - buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); - for(j = 0; j < buf[i].len; j++) + for (i = 0; i < DIM_SIZE_1; i++) { + buf[i].len = i + 1; + buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); + for (j = 0; j < buf[i].len; j++) ((int *)buf[i].p)[j] = (int)(i * 10 + j); } /* end for */ @@ -8004,99 +9496,129 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* make a copy of the datatype for later use */ - if((tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR + if ((tid_copy = H5Tcopy(tid)) < 0) + TEST_ERROR /* named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create and set compact plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_layout(pid, H5D_COMPACT) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_layout(pid, H5D_COMPACT) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close compact plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid_copy) < 0) TEST_ERROR + if (H5Tclose(tid_copy) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Dclose(did2); H5Dclose(did); @@ -8107,11 +9629,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_compact_named_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_contig_named_vl * @@ -8129,24 +9651,24 @@ error: static int test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid_copy=-1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid_copy = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): contigous dataset with named VLEN datatype"); /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].len = i+1; - buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); - for(j = 0; j < buf[i].len; j++) + for (i = 0; i < DIM_SIZE_1; i++) { + buf[i].len = i + 1; + buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); + for (j = 0; j < buf[i].len; j++) ((int *)buf[i].p)[j] = (int)(i * 10 + j); } /* end for */ @@ -8158,92 +9680,119 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* make a copy of the datatype for later use */ - if((tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR + if ((tid_copy = H5Tcopy(tid)) < 0) + TEST_ERROR /* named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid_copy) < 0) TEST_ERROR + if (H5Tclose(tid_copy) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did2); H5Dclose(did); H5Treclaim(tid_copy, sid, H5P_DEFAULT, buf); @@ -8253,11 +9802,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_contig_named_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_chunked_named_vl * @@ -8276,32 +9825,34 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open) +test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, + hbool_t test_open) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid_copy=-1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; - - if(test_open) { + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid_copy = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + + if (test_open) { TESTING("H5Ocopy(): chunked and opened dataset with named VLEN datatype"); - } else { + } + else { TESTING("H5Ocopy(): chunked dataset with named VLEN datatype"); } /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].len = i+1; - buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); - for(j = 0; j < buf[i].len; j++) + for (i = 0; i < DIM_SIZE_1; i++) { + buf[i].len = i + 1; + buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); + for (j = 0; j < buf[i].len; j++) ((int *)buf[i].p)[j] = (int)(i * 10 + j); } /* end for */ @@ -8313,104 +9864,134 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* make a copy of the datatype for later use */ - if((tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR + if ((tid_copy = H5Tcopy(tid)) < 0) + TEST_ERROR /* named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR - /* create and set chunk plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR + /* create and set chunk plist */ + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(pid, 1, chunk_dim1d) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close compact plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR - if(!test_open) { + if (!test_open) { /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR } /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - if(!test_open) { + if (!test_open) { /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) + TEST_ERROR } /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid_copy) < 0) TEST_ERROR + if (H5Tclose(tid_copy) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Dclose(did2); H5Dclose(did); @@ -8421,11 +10002,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_chunked_named_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_compressed_named_vl * @@ -8443,26 +10024,26 @@ error: static int test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid_copy=-1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid_copy = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): compressed dataset with named VLEN datatype"); /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].len = i+1; - buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); - for(j = 0; j < buf[i].len; j++) + for (i = 0; i < DIM_SIZE_1; i++) { + buf[i].len = i + 1; + buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int)); + for (j = 0; j < buf[i].len; j++) ((int *)buf[i].p)[j] = (int)(i * 10 + j); } /* end for */ @@ -8474,100 +10055,131 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_ token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* make a copy of the datatype for later use */ - if((tid_copy = H5Tcopy(tid)) < 0)TEST_ERROR + if ((tid_copy = H5Tcopy(tid)) < 0) + TEST_ERROR /* named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_VL, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR - /* create and set chunk plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR - if(H5Pset_deflate(pid, 9) < 0) TEST_ERROR + /* create and set chunk plist */ + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(pid, 1, chunk_dim1d) < 0) + TEST_ERROR + if (H5Pset_deflate(pid, 9) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close compact plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid_copy, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid_copy) < 0) TEST_ERROR + if (H5Tclose(tid_copy) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Dclose(did2); H5Dclose(did); @@ -8578,11 +10190,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_compressed_named_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_compact_vl_vl * @@ -8600,41 +10212,40 @@ error: static int test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid=-1, tid2=-1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j, k; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - hvl_t *tvl; /* Temporary pointer to VL information */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j, k; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + hvl_t * tvl; /* Temporary pointer to VL information */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): compact dataset with nested VLEN datatype"); /* set initial data values */ - for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); - if(tvl->p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + buf[i].len = i + 1; + for (tvl = (hvl_t *)buf[i].p, j = 0; j < (i + 1); j++, tvl++) { + tvl->p = HDmalloc((j + 1) * sizeof(unsigned int)); + if (tvl->p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return 1; } /* end if */ - tvl->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)tvl->p)[k]=i*100+j*10+k; + tvl->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)tvl->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ - + } /* end for */ /* Initialize the filenames */ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); @@ -8644,93 +10255,123 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create nested VL datatype */ - if((tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR + if ((tid2 = H5Tvlen_create(tid)) < 0) + TEST_ERROR /* create and set compact plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_layout(pid, H5D_COMPACT) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_layout(pid, H5D_COMPACT) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close compact plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid2, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did2); H5Dclose(did); H5Treclaim(tid2, sid, H5P_DEFAULT, buf); @@ -8741,11 +10382,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_compact_vl_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_contig_vl_vl * @@ -8764,47 +10405,48 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open) +test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, + hbool_t test_open) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid=-1, tid2=-1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j, k; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - hvl_t *tvl; /* Temporary pointer to VL information */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; - - if(test_open) { + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j, k; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + hvl_t * tvl; /* Temporary pointer to VL information */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + + if (test_open) { TESTING("H5Ocopy(): contigous and opened dataset with nested VLEN datatype"); - } else { + } + else { TESTING("H5Ocopy(): contigous dataset with nested VLEN datatype"); } /* set initial data values */ - for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); - if(tvl->p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + buf[i].len = i + 1; + for (tvl = (hvl_t *)buf[i].p, j = 0; j < (i + 1); j++, tvl++) { + tvl->p = HDmalloc((j + 1) * sizeof(unsigned int)); + if (tvl->p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); TEST_ERROR } /* end if */ - tvl->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)tvl->p)[k]=i*100+j*10+k; + tvl->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)tvl->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ - + } /* end for */ /* Initialize the filenames */ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); @@ -8814,96 +10456,125 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create nested VL datatype */ - if((tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR + if ((tid2 = H5Tvlen_create(tid)) < 0) + TEST_ERROR /* create and set compact plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close compact plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR - if(!test_open) { + if (!test_open) { /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR } /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - if(!test_open) { + if (!test_open) { /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) + TEST_ERROR } /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid2, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did2); H5Dclose(did); H5Treclaim(tid2, sid, H5P_DEFAULT, buf); @@ -8914,11 +10585,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_contig_vl_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_chunked_vl_vl * @@ -8936,41 +10607,41 @@ error: static int test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2=-1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j, k; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - hvl_t *tvl; /* Temporary pointer to VL information */ - hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j, k; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + hvl_t * tvl; /* Temporary pointer to VL information */ + hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): chunked dataset with nested VLEN datatype"); /* set initial data values */ - for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); - if(tvl->p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + buf[i].len = i + 1; + for (tvl = (hvl_t *)buf[i].p, j = 0; j < (i + 1); j++, tvl++) { + tvl->p = HDmalloc((j + 1) * sizeof(unsigned int)); + if (tvl->p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); TEST_ERROR } /* end if */ - tvl->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)tvl->p)[k]=i*100+j*10+k; + tvl->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)tvl->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ + } /* end for */ /* Initialize the filenames */ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); @@ -8980,131 +10651,165 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create nested VL datatype */ - if((tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR + if ((tid2 = H5Tvlen_create(tid)) < 0) + TEST_ERROR /* create and set chunk plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(pid, 1, chunk_dim1d) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR - + if (H5Dclose(did) < 0) + TEST_ERROR /* Set allocation time to early */ - if(H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + if (H5Pset_alloc_time(pid, H5D_ALLOC_TIME_EARLY) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL2, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL2, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR - + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ocopy(fid_src, NAME_DATASET_VL_VL2, fid_dst, NAME_DATASET_VL_VL2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL_VL2, fid_dst, NAME_DATASET_VL_VL2, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) + TEST_ERROR - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if (compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR - + if (H5Dclose(did) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL2, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL2, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL2, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL2, H5P_DEFAULT)) < 0) + TEST_ERROR - if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + if (compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR - + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid2, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Dclose(did2); H5Dclose(did); @@ -9115,11 +10820,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_chunked_vl_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_compressed_vl_vl * @@ -9138,47 +10843,49 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t test_open) +test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, + hbool_t test_open) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2=-1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j, k; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - hvl_t *tvl; /* Temporary pointer to VL information */ - hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; - - if(test_open) { + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j, k; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + hvl_t * tvl; /* Temporary pointer to VL information */ + hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + + if (test_open) { TESTING("H5Ocopy(): compressed and opened dataset with nested VLEN datatype"); - } else { + } + else { TESTING("H5Ocopy(): compressed dataset with nested VLEN datatype"); } /* set initial data values */ - for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); - if(tvl->p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + buf[i].len = i + 1; + for (tvl = (hvl_t *)buf[i].p, j = 0; j < (i + 1); j++, tvl++) { + tvl->p = HDmalloc((j + 1) * sizeof(unsigned int)); + if (tvl->p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); TEST_ERROR } /* end if */ - tvl->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)tvl->p)[k]=i*100+j*10+k; + tvl->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)tvl->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ + } /* end for */ /* Initialize the filenames */ h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); @@ -9188,99 +10895,128 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create nested VL datatype */ - if((tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR + if ((tid2 = H5Tvlen_create(tid)) < 0) + TEST_ERROR - /* create and set chunk plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR - if(H5Pset_deflate(pid, 9) < 0) TEST_ERROR + /* create and set chunk plist */ + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(pid, 1, chunk_dim1d) < 0) + TEST_ERROR + if (H5Pset_deflate(pid, 9) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_VL_VL, tid2, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close compact plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR - if(!test_open) { + if (!test_open) { /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR } /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR - if(!test_open) { + if (!test_open) { /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) + TEST_ERROR } /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid2, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Dclose(did2); H5Dclose(did); @@ -9291,7 +11027,8 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_compressed_vl_vl */ @@ -9299,12 +11036,11 @@ error: * Common data structure for the copy_dataset_*_cmpd_vl tests. */ typedef struct cmpd_vl_t { - int a; - hvl_t b; + int a; + hvl_t b; double c; } cmpd_vl_t; - /*------------------------------------------------------------------------- * Function: test_copy_dataset_contig_cmpd_vl * @@ -9322,27 +11058,27 @@ typedef struct cmpd_vl_t { static int test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t tid2 = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t did2 = -1; /* Dataset ID */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t tid2 = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t did2 = -1; /* Dataset ID */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): contiguous dataset with compound VLEN datatype"); /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].a = (int)(i * (i - 1)); - buf[i].b.len = i+1; - buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); - for(j = 0; j < buf[i].b.len; j++) + for (i = 0; i < DIM_SIZE_1; i++) { + buf[i].a = (int)(i * (i - 1)); + buf[i].b.len = i + 1; + buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); + for (j = 0; j < buf[i].b.len; j++) ((int *)buf[i].b.p)[j] = (int)(i * 10 + j); buf[i].c = 1.0F / ((float)i + 1.0F); } /* end for */ @@ -9355,88 +11091,118 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) TEST_ERROR - if(H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) TEST_ERROR - if(H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) TEST_ERROR + if ((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) + TEST_ERROR + if (H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) + TEST_ERROR + if (H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) + TEST_ERROR + if (H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did2); H5Dclose(did); H5Treclaim(tid, sid, H5P_DEFAULT, buf); @@ -9446,11 +11212,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_contig_cmpd_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_chunked_cmpd_vl * @@ -9468,27 +11234,27 @@ error: static int test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ - cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ + cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): chunked dataset with compound VLEN datatype"); /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].a = (int)(i * (i - 1)); - buf[i].b.len = i+1; - buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); - for(j = 0; j < buf[i].b.len; j++) + for (i = 0; i < DIM_SIZE_1; i++) { + buf[i].a = (int)(i * (i - 1)); + buf[i].b.len = i + 1; + buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); + for (j = 0; j < buf[i].b.len; j++) ((int *)buf[i].b.p)[j] = (int)(i * 10 + j); buf[i].c = 1.0F / ((float)i + 1.0F); } /* end for */ @@ -9501,95 +11267,127 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) TEST_ERROR - if(H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) TEST_ERROR - if(H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) TEST_ERROR + if ((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) + TEST_ERROR + if (H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) + TEST_ERROR + if (H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) + TEST_ERROR + if (H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) + TEST_ERROR /* create and set chunk plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(pid, 1, chunk_dim1d) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* close chunk plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did2); H5Dclose(did); H5Treclaim(tid, sid, H5P_DEFAULT, buf); @@ -9600,11 +11398,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_chunked_cmpd_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_compact_cmpd_vl * @@ -9622,26 +11420,26 @@ error: static int test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Dataset creation property list ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t dxpl_id = -1; /* Dataset transfer property list ID */ - unsigned int i, j; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Dataset creation property list ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ + unsigned int i, j; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): compact dataset with compound VLEN datatype"); /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) { - buf[i].a = (int)(i * (i - 1)); - buf[i].b.len = i+1; - buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); - for(j = 0; j < buf[i].b.len; j++) + for (i = 0; i < DIM_SIZE_1; i++) { + buf[i].a = (int)(i * (i - 1)); + buf[i].b.len = i + 1; + buf[i].b.p = (int *)HDmalloc(buf[i].b.len * sizeof(int)); + for (j = 0; j < buf[i].b.len; j++) ((int *)buf[i].b.p)[j] = (int)(i * 10 + j); buf[i].c = 1.0F / ((float)i + 1.0F); } /* end for */ @@ -9654,95 +11452,127 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* create datatype */ - if((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) TEST_ERROR - if(H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) TEST_ERROR - if(H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) TEST_ERROR + if ((tid2 = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(cmpd_vl_t))) < 0) + TEST_ERROR + if (H5Tinsert(tid, "a", HOFFSET(cmpd_vl_t, a), H5T_NATIVE_INT) < 0) + TEST_ERROR + if (H5Tinsert(tid, "b", HOFFSET(cmpd_vl_t, b), tid2) < 0) + TEST_ERROR + if (H5Tinsert(tid, "c", HOFFSET(cmpd_vl_t, c), H5T_NATIVE_DOUBLE) < 0) + TEST_ERROR /* create and set compact plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_layout(pid, H5D_COMPACT) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_layout(pid, H5D_COMPACT) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_CMPD_VL, tid, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close compact plist */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR - + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy the dataset from SRC to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_CMPD_VL, fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* open the dataset for copy */ - if((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_src, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* open the destination dataset */ - if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dopen2(fid_dst, NAME_DATASET_CMPD_VL, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if the datasets are equal */ - if(compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) TEST_ERROR + if (compare_datasets(did, did2, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR /* close the destination dataset */ - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* close the source dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* Reclaim vlen buffer */ - if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR - if(H5Treclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR - if(H5Pclose(dxpl_id) < 0) TEST_ERROR + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR + if (H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) + TEST_ERROR + if (H5Treclaim(tid, sid, dxpl_id, buf) < 0) + TEST_ERROR + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR } /* end if */ /* close datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did2); H5Dclose(did); H5Treclaim(tid, sid, H5P_DEFAULT, buf); @@ -9753,11 +11583,11 @@ error: H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_dataset_compact_cmpd_vl */ - /*------------------------------------------------------------------------- * Function: test_copy_null_ref * @@ -9779,17 +11609,17 @@ error: static int test_copy_null_ref(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Object copy property list ID */ - hid_t did1 = -1, did2 = -1; /* Dataset IDs */ - hsize_t dim1d[1] = {2}; /* Dataset dimensions */ - hobj_ref_t obj_buf[2]; /* Buffer for object refs */ - hdset_reg_ref_t reg_buf[2]; /* Buffer for region refs */ - char zeros[MAX(sizeof(obj_buf),sizeof(reg_buf))]; /* Array of zeros, for memcmp */ - char src_filename[NAME_BUF_SIZE]; - char mid_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Object copy property list ID */ + hid_t did1 = -1, did2 = -1; /* Dataset IDs */ + hsize_t dim1d[1] = {2}; /* Dataset dimensions */ + hobj_ref_t obj_buf[2]; /* Buffer for object refs */ + hdset_reg_ref_t reg_buf[2]; /* Buffer for region refs */ + char zeros[MAX(sizeof(obj_buf), sizeof(reg_buf))]; /* Array of zeros, for memcmp */ + char src_filename[NAME_BUF_SIZE]; + char mid_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): NULL references"); @@ -9805,121 +11635,150 @@ test_copy_null_ref(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fap token_reset(); /* Create source file */ - if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + if ((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* Create object reference dataset at SRC file */ - if((did1 = H5Dcreate2(fid1, "obj_ref_dset", H5T_STD_REF_OBJ, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did1 = H5Dcreate2(fid1, "obj_ref_dset", H5T_STD_REF_OBJ, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* Create region reference dataset at SRC file */ - if((did2 = H5Dcreate2(fid1, "reg_ref_dset", H5T_STD_REF_DSETREG, - sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dcreate2(fid1, "reg_ref_dset", H5T_STD_REF_DSETREG, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* Create references */ - if(H5Rcreate(&obj_buf[0], did1, ".", H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR - if(H5Rcreate(&obj_buf[1], did2, ".", H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR - if(H5Rcreate(®_buf[0], did1, ".", H5R_DATASET_REGION, sid) < 0) + if (H5Rcreate(&obj_buf[0], did1, ".", H5R_OBJECT, (hid_t)-1) < 0) + TEST_ERROR + if (H5Rcreate(&obj_buf[1], did2, ".", H5R_OBJECT, (hid_t)-1) < 0) + TEST_ERROR + if (H5Rcreate(®_buf[0], did1, ".", H5R_DATASET_REGION, sid) < 0) TEST_ERROR - if(H5Rcreate(®_buf[1], did2, ".", H5R_DATASET_REGION, sid) < 0) + if (H5Rcreate(®_buf[1], did2, ".", H5R_DATASET_REGION, sid) < 0) TEST_ERROR /* Write data into file */ - if(H5Dwrite(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) - < 0) TEST_ERROR - if(H5Dwrite(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - reg_buf) < 0) TEST_ERROR + if (H5Dwrite(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) < 0) + TEST_ERROR + if (H5Dwrite(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, reg_buf) < 0) + TEST_ERROR /* Close datasets */ - if(H5Dclose(did1) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did1) < 0) + TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* Create middle file */ - if((fid2 = H5Fcreate(mid_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + if ((fid2 = H5Fcreate(mid_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Copy the source file to the middle file. Note the expand references * flag is not set. */ - if(H5Ocopy(fid1, "/", fid2, "/A", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid1, "/", fid2, "/A", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close source file */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Open copied datasets */ - if((did1 = H5Dopen2(fid2, "/A/obj_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR - if((did2 = H5Dopen2(fid2, "/A/reg_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR + if ((did1 = H5Dopen2(fid2, "/A/obj_ref_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((did2 = H5Dopen2(fid2, "/A/reg_ref_dset", H5P_DEFAULT)) < 0) + TEST_ERROR /* Read copied datasets */ - if(H5Dread(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) - < 0) TEST_ERROR - if(H5Dread(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - reg_buf) < 0) TEST_ERROR + if (H5Dread(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) < 0) + TEST_ERROR + if (H5Dread(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, reg_buf) < 0) + TEST_ERROR /* Verify that the references contain only "0" bytes */ - if(HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) TEST_ERROR - if(HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) TEST_ERROR + if (HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) + TEST_ERROR + if (HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) + TEST_ERROR /* Close datasets */ - if(H5Dclose(did1) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did1) < 0) + TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* Create destination file */ - if((fid1 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + if ((fid1 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create object copy property list */ - if((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR /* Set the "expand references" flag */ - if(H5Pset_copy_object(pid, H5O_COPY_EXPAND_REFERENCE_FLAG) < 0) TEST_ERROR + if (H5Pset_copy_object(pid, H5O_COPY_EXPAND_REFERENCE_FLAG) < 0) + TEST_ERROR /* Copy the middle file to the destination file. Note the expand references * flag *is* set, even though the references are now NULL. */ - if(H5Ocopy(fid2, "/", fid1, "/AA", pid, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid2, "/", fid1, "/AA", pid, H5P_DEFAULT) < 0) + TEST_ERROR /* Close source file */ - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Open copied datasets */ - if((did1 = H5Dopen2(fid1, "/AA/A/obj_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR - if((did2 = H5Dopen2(fid1, "/AA/A/reg_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR + if ((did1 = H5Dopen2(fid1, "/AA/A/obj_ref_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((did2 = H5Dopen2(fid1, "/AA/A/reg_ref_dset", H5P_DEFAULT)) < 0) + TEST_ERROR /* Read copied datasets */ - if(H5Dread(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) - < 0) TEST_ERROR - if(H5Dread(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - reg_buf) < 0) TEST_ERROR + if (H5Dread(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) < 0) + TEST_ERROR + if (H5Dread(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, reg_buf) < 0) + TEST_ERROR /* Verify that the references contain only "0" bytes */ - if(HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) TEST_ERROR - if(HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) TEST_ERROR + if (HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) + TEST_ERROR + if (HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) + TEST_ERROR /* Close */ - if(H5Pclose(pid) < 0) TEST_ERROR - if(H5Dclose(did1) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR + if (H5Dclose(did1) < 0) + TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Dclose(did1); H5Dclose(did2); H5Fclose(fid1); H5Fclose(fid2); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_null_ref */ - /*------------------------------------------------------------------------- * Function: test_copy_null_ref_open * @@ -9944,21 +11803,21 @@ error: static int test_copy_null_ref_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t pid = -1; /* Object copy property list ID */ - hid_t did1 = -1, did2 = -1; /* Dataset IDs */ - hid_t did3 = -1, did4 = -1; /* Dataset IDs */ - hid_t did5 = -1, did6 = -1; /* Dataset IDs */ - hid_t dcpl = -1; /* Dataset creation property list */ - hsize_t chunk_dim1d[1] = {2}; /* Chunk dimensions */ - hsize_t dim1d[1] = {3}; /* Dataset dimensions */ - hobj_ref_t obj_buf[3]; /* Buffer for object refs */ - hdset_reg_ref_t reg_buf[3]; /* Buffer for region refs */ - char zeros[MAX(sizeof(obj_buf),sizeof(reg_buf))]; /* Array of zeros, for memcmp */ - char src_filename[NAME_BUF_SIZE]; - char mid_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t pid = -1; /* Object copy property list ID */ + hid_t did1 = -1, did2 = -1; /* Dataset IDs */ + hid_t did3 = -1, did4 = -1; /* Dataset IDs */ + hid_t did5 = -1, did6 = -1; /* Dataset IDs */ + hid_t dcpl = -1; /* Dataset creation property list */ + hsize_t chunk_dim1d[1] = {2}; /* Chunk dimensions */ + hsize_t dim1d[1] = {3}; /* Dataset dimensions */ + hobj_ref_t obj_buf[3]; /* Buffer for object refs */ + hdset_reg_ref_t reg_buf[3]; /* Buffer for region refs */ + char zeros[MAX(sizeof(obj_buf), sizeof(reg_buf))]; /* Array of zeros, for memcmp */ + char src_filename[NAME_BUF_SIZE]; + char mid_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): NULL references for opened datasets"); @@ -9974,118 +11833,150 @@ test_copy_null_ref_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t ds token_reset(); /* Create source file */ - if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + if ((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR - /* create and set chunk plist */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(dcpl, 1, chunk_dim1d) < 0) TEST_ERROR - if(H5Pset_deflate(dcpl, 9) < 0) TEST_ERROR - if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR + /* create and set chunk plist */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(dcpl, 1, chunk_dim1d) < 0) + TEST_ERROR + if (H5Pset_deflate(dcpl, 9) < 0) + TEST_ERROR + if (H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + TEST_ERROR /* Create object reference dataset at SRC file */ - if((did1 = H5Dcreate2(fid1, "obj_ref_dset", H5T_STD_REF_OBJ, sid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did1 = H5Dcreate2(fid1, "obj_ref_dset", H5T_STD_REF_OBJ, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR /* Create region reference dataset at SRC file */ - if((did2 = H5Dcreate2(fid1, "reg_ref_dset", H5T_STD_REF_DSETREG, - sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did2 = H5Dcreate2(fid1, "reg_ref_dset", H5T_STD_REF_DSETREG, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) + TEST_ERROR /* Create references */ - if(H5Rcreate(&obj_buf[0], did1, ".", H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR - if(H5Rcreate(&obj_buf[1], did2, ".", H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR - if(H5Rcreate(®_buf[0], did1, ".", H5R_DATASET_REGION, sid) < 0) + if (H5Rcreate(&obj_buf[0], did1, ".", H5R_OBJECT, (hid_t)-1) < 0) + TEST_ERROR + if (H5Rcreate(&obj_buf[1], did2, ".", H5R_OBJECT, (hid_t)-1) < 0) TEST_ERROR - if(H5Rcreate(®_buf[1], did2, ".", H5R_DATASET_REGION, sid) < 0) + if (H5Rcreate(®_buf[0], did1, ".", H5R_DATASET_REGION, sid) < 0) + TEST_ERROR + if (H5Rcreate(®_buf[1], did2, ".", H5R_DATASET_REGION, sid) < 0) TEST_ERROR /* Write data into file */ - if(H5Dwrite(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) - < 0) TEST_ERROR - if(H5Dwrite(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - reg_buf) < 0) TEST_ERROR - + if (H5Dwrite(did1, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) < 0) + TEST_ERROR + if (H5Dwrite(did2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, reg_buf) < 0) + TEST_ERROR /* Create middle file */ - if((fid2 = H5Fcreate(mid_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + if ((fid2 = H5Fcreate(mid_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Copy the source file to the middle file. Note the expand references * flag is not set. */ - if(H5Ocopy(fid1, "/", fid2, "/A", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid1, "/", fid2, "/A", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR /* Close datasets in source file */ - if(H5Dclose(did1) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) TEST_ERROR + if (H5Dclose(did1) < 0) + TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR /* Close source file */ - if(H5Fclose(fid1) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR /* Open copied datasets */ - if((did3 = H5Dopen2(fid2, "/A/obj_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR - if((did4 = H5Dopen2(fid2, "/A/reg_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR + if ((did3 = H5Dopen2(fid2, "/A/obj_ref_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((did4 = H5Dopen2(fid2, "/A/reg_ref_dset", H5P_DEFAULT)) < 0) + TEST_ERROR /* Read copied datasets */ - if(H5Dread(did3, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) - < 0) TEST_ERROR - if(H5Dread(did4, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - reg_buf) < 0) TEST_ERROR + if (H5Dread(did3, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) < 0) + TEST_ERROR + if (H5Dread(did4, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, reg_buf) < 0) + TEST_ERROR /* Verify that the references contain only "0" bytes */ - if(HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) TEST_ERROR - if(HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) TEST_ERROR + if (HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) + TEST_ERROR + if (HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) + TEST_ERROR /* Create destination file */ - if((fid3 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) - TEST_ERROR + if ((fid3 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR /* Create object copy property list */ - if((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR /* Set the "expand references" flag */ - if(H5Pset_copy_object(pid, H5O_COPY_EXPAND_REFERENCE_FLAG) < 0) TEST_ERROR + if (H5Pset_copy_object(pid, H5O_COPY_EXPAND_REFERENCE_FLAG) < 0) + TEST_ERROR /* Copy the middle file to the destination file. Note the expand references * flag *is* set, even though the references are now NULL. */ - if(H5Ocopy(fid2, "/", fid3, "/AA", pid, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid2, "/", fid3, "/AA", pid, H5P_DEFAULT) < 0) + TEST_ERROR /* Close datasets in middle file */ - if(H5Dclose(did3) < 0) TEST_ERROR - if(H5Dclose(did4) < 0) TEST_ERROR + if (H5Dclose(did3) < 0) + TEST_ERROR + if (H5Dclose(did4) < 0) + TEST_ERROR /* Close the middle file */ - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Open copied datasets */ - if((did5 = H5Dopen2(fid3, "/AA/A/obj_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR - if((did6 = H5Dopen2(fid3, "/AA/A/reg_ref_dset", H5P_DEFAULT)) < 0) TEST_ERROR + if ((did5 = H5Dopen2(fid3, "/AA/A/obj_ref_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((did6 = H5Dopen2(fid3, "/AA/A/reg_ref_dset", H5P_DEFAULT)) < 0) + TEST_ERROR /* Read copied datasets */ - if(H5Dread(did5, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) - < 0) TEST_ERROR - if(H5Dread(did6, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - reg_buf) < 0) TEST_ERROR + if (H5Dread(did5, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_buf) < 0) + TEST_ERROR + if (H5Dread(did6, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, reg_buf) < 0) + TEST_ERROR /* Verify that the references contain only "0" bytes */ - if(HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) TEST_ERROR - if(HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) TEST_ERROR + if (HDmemcmp(obj_buf, zeros, sizeof(obj_buf))) + TEST_ERROR + if (HDmemcmp(reg_buf, zeros, sizeof(reg_buf))) + TEST_ERROR /* Close */ - if(H5Pclose(pid) < 0) TEST_ERROR - if(H5Pclose(dcpl) < 0) TEST_ERROR - if(H5Dclose(did5) < 0) TEST_ERROR - if(H5Dclose(did6) < 0) TEST_ERROR - if(H5Fclose(fid3) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR + if (H5Pclose(dcpl) < 0) + TEST_ERROR + if (H5Dclose(did5) < 0) + TEST_ERROR + if (H5Dclose(did6) < 0) + TEST_ERROR + if (H5Fclose(fid3) < 0) + TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Pclose(dcpl); H5Sclose(sid); @@ -10098,11 +11989,11 @@ error: H5Fclose(fid1); H5Fclose(fid2); H5Fclose(fid3); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_null_ref_open */ - /*------------------------------------------------------------------------- * Function: test_copy_attr_crt_order * @@ -10120,11 +12011,11 @@ error: static int test_copy_attr_crt_order(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gcplid = -1; /* Group creation property list ID */ - hid_t gid1 = -1, gid2 = -1; /* Group IDs */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gcplid = -1; /* Group creation property list ID */ + hid_t gid1 = -1, gid2 = -1; /* Group IDs */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): attributes with creation order"); @@ -10136,95 +12027,109 @@ test_copy_attr_crt_order(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t d token_reset(); /* Create source file */ - if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + if ((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create GCPL */ - if((gcplid = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcplid = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Create group with creation order tracked */ - if(H5Pset_attr_creation_order(gcplid, H5P_CRT_ORDER_TRACKED) < 0) TEST_ERROR - if((gid1 = H5Gcreate2(fid1, NAME_GROUP_TOP, H5P_DEFAULT, gcplid, H5P_DEFAULT)) - < 0) + if (H5Pset_attr_creation_order(gcplid, H5P_CRT_ORDER_TRACKED) < 0) + TEST_ERROR + if ((gid1 = H5Gcreate2(fid1, NAME_GROUP_TOP, H5P_DEFAULT, gcplid, H5P_DEFAULT)) < 0) TEST_ERROR /* Add attributes to group */ - if(test_copy_attach_attributes(gid1, H5T_NATIVE_INT) < 0) TEST_ERROR + if (test_copy_attach_attributes(gid1, H5T_NATIVE_INT) < 0) + TEST_ERROR /* Close group */ - if(H5Gclose(gid1) < 0) TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR /* Create group with creation order tracked and indexed */ - if(H5Pset_attr_creation_order(gcplid, H5P_CRT_ORDER_TRACKED - | H5P_CRT_ORDER_INDEXED) < 0) + if (H5Pset_attr_creation_order(gcplid, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0) TEST_ERROR - if((gid1 = H5Gcreate2(fid1, NAME_GROUP_TOP2, H5P_DEFAULT, gcplid, - H5P_DEFAULT)) < 0) + if ((gid1 = H5Gcreate2(fid1, NAME_GROUP_TOP2, H5P_DEFAULT, gcplid, H5P_DEFAULT)) < 0) TEST_ERROR /* Add attributes to group */ - if(test_copy_attach_attributes(gid1, H5T_NATIVE_INT) < 0) TEST_ERROR + if (test_copy_attach_attributes(gid1, H5T_NATIVE_INT) < 0) + TEST_ERROR /* Close group */ - if(H5Gclose(gid1) < 0) TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR /* Close GCPL */ - if(H5Pclose(gcplid) < 0) TEST_ERROR - + if (H5Pclose(gcplid) < 0) + TEST_ERROR /* Create destination file */ - if((fid2 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + if ((fid2 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Copy the groups to the destination file */ - if(H5Ocopy(fid1, NAME_GROUP_TOP, fid2, NAME_GROUP_TOP, H5P_DEFAULT, - H5P_DEFAULT) < 0) + if (H5Ocopy(fid1, NAME_GROUP_TOP, fid2, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Ocopy(fid1, NAME_GROUP_TOP2, fid2, NAME_GROUP_TOP2, H5P_DEFAULT, - H5P_DEFAULT) < 0) + if (H5Ocopy(fid1, NAME_GROUP_TOP2, fid2, NAME_GROUP_TOP2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Open groups with creation order tracked */ - if((gid1 = H5Gopen2(fid1, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid2 = H5Gopen2(fid2, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid1 = H5Gopen2(fid1, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((gid2 = H5Gopen2(fid2, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + TEST_ERROR /* Compare the attributes */ - if(compare_std_attributes(gid1, gid2, H5P_DEFAULT) != TRUE) TEST_ERROR + if (compare_std_attributes(gid1, gid2, H5P_DEFAULT) != TRUE) + TEST_ERROR /* Close groups */ - if(H5Gclose(gid1) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Open groups with creation order tracked and indexed */ - if((gid1 = H5Gopen2(fid1, NAME_GROUP_TOP2, H5P_DEFAULT)) < 0) TEST_ERROR - if((gid2 = H5Gopen2(fid2, NAME_GROUP_TOP2, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid1 = H5Gopen2(fid1, NAME_GROUP_TOP2, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((gid2 = H5Gopen2(fid2, NAME_GROUP_TOP2, H5P_DEFAULT)) < 0) + TEST_ERROR /* Compare the attributes */ - if(compare_std_attributes(gid1, gid2, H5P_DEFAULT) != TRUE) TEST_ERROR + if (compare_std_attributes(gid1, gid2, H5P_DEFAULT) != TRUE) + TEST_ERROR /* Close groups */ - if(H5Gclose(gid1) < 0) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid1) < 0) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close */ - if(H5Fclose(fid1) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid1); H5Gclose(gid2); H5Pclose(gcplid); H5Fclose(fid1); H5Fclose(fid2); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_attr_crt_order */ - /*------------------------------------------------------------------------- * Function: test_copy_committed_datatype_merge * @@ -10239,32 +12144,32 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_committed_datatype_merge(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, - hid_t dst_fapl, hbool_t reopen) +test_copy_committed_datatype_merge(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, + hbool_t reopen) { - hid_t fid_src1 = -1, fid_src2 = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t ocpypl_id = -1; /* Object copy plist ID */ - unsigned int i; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - int buf[DIM_SIZE_1]; /* Buffer for writing data */ - H5O_info2_t oinfo; /* Object info */ - H5O_token_t exp_token; /* Expected object token */ - char src1_filename[NAME_BUF_SIZE]; - char src2_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; - int token_cmp; - - if(reopen) { + hid_t fid_src1 = -1, fid_src2 = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t ocpypl_id = -1; /* Object copy plist ID */ + unsigned int i; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + int buf[DIM_SIZE_1]; /* Buffer for writing data */ + H5O_info2_t oinfo; /* Object info */ + H5O_token_t exp_token; /* Expected object token */ + char src1_filename[NAME_BUF_SIZE]; + char src2_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + int token_cmp; + + if (reopen) { TESTING("H5Ocopy(): merging committed datatypes with reopen") } /* end if */ else TESTING("H5Ocopy(): merging committed datatypes") /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) + for (i = 0; i < DIM_SIZE_1; i++) buf[i] = (int)i; /* Initialize the filenames */ @@ -10276,185 +12181,262 @@ test_copy_committed_datatype_merge(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap token_reset(); /* create source files */ - if((fid_src1 = H5Fcreate(src1_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR - if((fid_src2 = H5Fcreate(src2_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src1 = H5Fcreate(src1_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR + if ((fid_src2 = H5Fcreate(src2_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* * Populate source file 1 */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype */ - if((H5Tcommit2(fid_src1, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src1, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src1, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src1, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file 1 */ - if(H5Fclose(fid_src1) < 0) TEST_ERROR + if (H5Fclose(fid_src1) < 0) + TEST_ERROR /* * Populate source file 2 */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype */ - if((H5Tcommit2(fid_src2, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src2, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src2, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src2, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file 1 */ - if(H5Fclose(fid_src2) < 0) TEST_ERROR - + if (H5Fclose(fid_src2) < 0) + TEST_ERROR /* open the source files with read-only */ - if((fid_src1 = H5Fopen(src1_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR - if((fid_src2 = H5Fopen(src2_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src1 = H5Fopen(src1_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR + if ((fid_src2 = H5Fopen(src2_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* Create ocpl and set merge named dtype flag */ - if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR - if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR + if ((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR + if (H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) + TEST_ERROR /* * First copy each entire file to the destination file (each with their own * group), and verify the committed datatypes are merged */ /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy SRC1 to DST */ - if(H5Ocopy(fid_src1, "/", fid_dst, NAME_GROUP_TOP, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src1, "/", fid_dst, NAME_GROUP_TOP, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* copy SRC2 to DST */ - if(H5Ocopy(fid_src2, "/", fid_dst, NAME_GROUP_TOP2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src2, "/", fid_dst, NAME_GROUP_TOP2, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open SRC1 committed dtype, get token */ - if((tid = H5Topen2(fid_dst, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open SRC1 dset dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open SRC2 committed dtype, check token */ - if((tid = H5Topen2(fid_dst, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open SRC2 dset dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* * Now copy only the datasets to the destination file, and verify the committed * datatypes are merged */ /* recreate destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR - /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create an uncopied object in destination file so that tokens in source and destination files aren't the + * same */ + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* copy SRC1 to DST */ - if(H5Ocopy(fid_src1, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src1, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* copy SRC2 to DST */ - if(H5Ocopy(fid_src2, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src2, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open SRC1 dset dtype, get token */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open SRC2 dset dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* close the SRC files */ - if(H5Fclose(fid_src1) < 0) TEST_ERROR - if(H5Fclose(fid_src2) < 0) TEST_ERROR + if (H5Fclose(fid_src1) < 0) + TEST_ERROR + if (H5Fclose(fid_src2) < 0) + TEST_ERROR /* close property list */ - if(H5Pclose(ocpypl_id) < 0) TEST_ERROR + if (H5Pclose(ocpypl_id) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid_src1); H5Fclose(fid_src2); H5Fclose(fid_dst); @@ -10462,11 +12444,11 @@ error: H5Sclose(sid); H5Dclose(did); H5Pclose(ocpypl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_committed_datatype_merge */ - /*------------------------------------------------------------------------- * Function: test_copy_committed_datatype_merge_same_file * @@ -10484,27 +12466,27 @@ error: static int test_copy_committed_datatype_merge_same_file(hid_t fcpl, hid_t fapl, hbool_t reopen) { - hid_t fid = -1; /* File ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t gid = -1; /* Group ID */ - hid_t ocpypl_id = -1; /* Object copy plist ID */ - unsigned int i; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - int buf[DIM_SIZE_1]; /* Buffer for writing data */ - H5O_info2_t oinfo; /* Object info */ - H5O_token_t exp_token; /* Expected object token */ - char filename[NAME_BUF_SIZE]; - int token_cmp; - - if(reopen) + hid_t fid = -1; /* File ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t gid = -1; /* Group ID */ + hid_t ocpypl_id = -1; /* Object copy plist ID */ + unsigned int i; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + int buf[DIM_SIZE_1]; /* Buffer for writing data */ + H5O_info2_t oinfo; /* Object info */ + H5O_token_t exp_token; /* Expected object token */ + char filename[NAME_BUF_SIZE]; + int token_cmp; + + if (reopen) TESTING("H5Ocopy(): merging committed datatypes to the source file with reopen") else TESTING("H5Ocopy(): merging committed datatypes to the source file") /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) + for (i = 0; i < DIM_SIZE_1; i++) buf[i] = (int)i; /* Initialize the filename */ @@ -10514,72 +12496,95 @@ test_copy_committed_datatype_merge_same_file(hid_t fcpl, hid_t fapl, hbool_t reo token_reset(); /* create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* * Populate first group */ /* Create group */ - if((gid = H5Gcreate2(fid, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype */ - if((H5Tcommit2(fid, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset */ - if((did = H5Dcreate2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* * Populate second group */ /* Create group */ - if((gid = H5Gcreate2(fid, NAME_GROUP_TOP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, NAME_GROUP_TOP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype */ - if((H5Tcommit2(fid, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset */ - if((did = H5Dcreate2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the group */ - if(H5Gclose(gid) < 0) TEST_ERROR - + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create ocpl and set merge committed dtype flag */ - if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR - if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR + if ((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR + if (H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) + TEST_ERROR /* * First copy each group to the destination group 3 (each with their own @@ -10588,168 +12593,257 @@ test_copy_committed_datatype_merge_same_file(hid_t fcpl, hid_t fapl, hbool_t reo * corresponding source datatype. */ /* Create destination group */ - if((gid = H5Gcreate2(fid, NAME_GROUP_TOP3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, NAME_GROUP_TOP3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* copy group 1 to DST */ - if(H5Ocopy(fid, NAME_GROUP_TOP, fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid, NAME_GROUP_TOP, fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* copy group 2 to DST */ - if(H5Ocopy(fid, NAME_GROUP_TOP2, fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid, NAME_GROUP_TOP2, fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR } /* end if */ /* Open group 1 source committed dtype, get token */ - if((tid = H5Topen2(fid, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid, NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open group 1 source dset dtype, check token */ - if((did = H5Dopen2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open group 1 committed dtype, check token */ - if((tid = H5Topen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR + if ((tid = H5Topen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open group 1 dset dtype, check token */ - if((did = H5Dopen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open group 2 source committed dtype, get token and make sure it is * different from group 1 source committed dtype */ - if((tid = H5Topen2(fid, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(!token_cmp) TEST_ERROR + if ((tid = H5Topen2(fid, NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open group 2 source dset dtype, check token */ - if((did = H5Dopen2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR - - /* Open group 2 committed dtype, check token */ - if((tid = H5Topen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - + if ((did = H5Dopen2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + + /* Open group 2 committed dtype, check token */ + if ((tid = H5Topen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2 "/" NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + /* Open group 2 dset dtype, check token */ - if((did = H5Dopen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid, NAME_GROUP_TOP3 "/" NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* * Now copy only the datasets to the destination group, and verify the committed * datatypes are merged as expected */ /* Create destination group */ - if((gid = H5Gcreate2(fid, NAME_GROUP_TOP4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, NAME_GROUP_TOP4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* copy SRC1 to DST */ - if(H5Ocopy(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE, + ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* copy SRC2 to DST */ - if(H5Ocopy(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE2, + ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid) < 0) TEST_ERROR - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR } /* end if */ /* Open group 1 source dset dtype, get token */ - if((did = H5Dopen2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((did = H5Dopen2(fid, NAME_GROUP_TOP "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open group 1 dset dtype, check token */ - if((did = H5Dopen2(fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open group 2 source dset dtype, get token and make sure it is * different from group 1 source dset dtype */ - if((did = H5Dopen2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(!token_cmp) TEST_ERROR + if ((did = H5Dopen2(fid, NAME_GROUP_TOP2 "/" NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open group 2 dset dtype, check token */ - if((did = H5Dopen2(fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid, NAME_GROUP_TOP4 "/" NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* close property list */ - if(H5Pclose(ocpypl_id) < 0) TEST_ERROR + if (H5Pclose(ocpypl_id) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Tclose(tid); H5Sclose(sid); H5Dclose(did); H5Pclose(ocpypl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_committed_datatype_merge_same_file */ - - /*------------------------------------------------------------------------- * Function: test_copy_committed_dt_merge_sugg * @@ -10766,30 +12860,30 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_committed_dt_merge_sugg(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, - hid_t dst_fapl, hbool_t reopen) +test_copy_committed_dt_merge_sugg(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, + hbool_t reopen) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t ocpypl_id = -1; /* Object copy plist ID */ - unsigned int i; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - int buf[DIM_SIZE_1]; /* Buffer for writing data */ - H5O_info2_t oinfo; /* Object info */ - H5O_token_t exp_token; /* Expected object token */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; - int token_cmp; - - if(reopen) + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t ocpypl_id = -1; /* Object copy plist ID */ + unsigned int i; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + int buf[DIM_SIZE_1]; /* Buffer for writing data */ + H5O_info2_t oinfo; /* Object info */ + H5O_token_t exp_token; /* Expected object token */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + int token_cmp; + + if (reopen) TESTING("H5Ocopy(): merging committed datatypes with suggestions and reopen") else TESTING("H5Ocopy(): merging committed datatypes with suggestions") /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) + for (i = 0; i < DIM_SIZE_1; i++) buf[i] = (int)i; /* Initialize the filenames */ @@ -10800,189 +12894,254 @@ test_copy_committed_dt_merge_sugg(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* * Populate source file */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR /* * Populate destination file */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype "a" */ - if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype "b" */ - if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* Create ocpl and set merge committed dtype flag */ - if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR - if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR + if ((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR + if (H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) + TEST_ERROR /* * First copy dataset using "/b" as a suggestion, and verify that it uses * datatype "b" in the destination file */ /* Add datatype suggestion */ - if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) TEST_ERROR + if (H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) + TEST_ERROR /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open committed dtype "b", get token */ - if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open dset dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* * Now free suggestions, copy dataset without any suggestions, and verify * that it uses datatype "a" in the destination file */ /* Free suggestions */ - if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR + if (H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) + TEST_ERROR /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* Delete destination dataset */ /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open committed dtype "a", get token */ - if((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open dset 2 dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open committed dtype "b", get token */ - if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open dset dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close property list */ - if(H5Pclose(ocpypl_id) < 0) TEST_ERROR + if (H5Pclose(ocpypl_id) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid_src); H5Fclose(fid_dst); H5Tclose(tid); H5Sclose(sid); H5Dclose(did); H5Pclose(ocpypl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_committed_dt_merge_sugg */ - /*------------------------------------------------------------------------- * Function: test_copy_committed_dt_merge_attr * @@ -10999,32 +13158,32 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_committed_dt_merge_attr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, - hid_t dst_fapl, hbool_t reopen) +test_copy_committed_dt_merge_attr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, + hbool_t reopen) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t gid = -1; /* Group ID */ - hid_t ocpypl_id = -1; /* Object copy plist ID */ - unsigned int i; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - int buf[DIM_SIZE_1]; /* Buffer for writing data */ - H5O_info2_t oinfo; /* Object info */ - H5O_token_t exp_token; /* Expected object token */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; - int token_cmp; - - if(reopen) + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t gid = -1; /* Group ID */ + hid_t ocpypl_id = -1; /* Object copy plist ID */ + unsigned int i; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + int buf[DIM_SIZE_1]; /* Buffer for writing data */ + H5O_info2_t oinfo; /* Object info */ + H5O_token_t exp_token; /* Expected object token */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + int token_cmp; + + if (reopen) TESTING("H5Ocopy(): merging committed datatypes with attributes and reopen") else TESTING("H5Ocopy(): merging committed datatypes with attributes") /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) + for (i = 0; i < DIM_SIZE_1; i++) buf[i] = (int)i; /* Initialize the filenames */ @@ -11035,129 +13194,171 @@ test_copy_committed_dt_merge_attr(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* * Populate source file */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR /* * Populate destination file */ /* Create group */ - if((gid = H5Gcreate2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* create anonymous committed datatype */ - if((H5Tcommit_anon(fid_dst, tid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit_anon(fid_dst, tid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create attribute at SRC file */ - if((aid = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((aid = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Awrite(aid, tid, buf) < 0) TEST_ERROR + if (H5Awrite(aid, tid, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the attribute */ - if(H5Aclose(aid) < 0) TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR /* close the group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* Create ocpl and set merge committed dtype flag */ - if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR - if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR + if ((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR + if (H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) + TEST_ERROR /* * Copy dataset and verify that it uses the same committed datatype as the * already existing attribute in the destination file. */ /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open attribute dtype, get token */ - if((aid = H5Aopen_by_name(fid_dst, NAME_GROUP_TOP, "attr", H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Aget_type(aid)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((aid = H5Aopen_by_name(fid_dst, NAME_GROUP_TOP, "attr", H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Aget_type(aid)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Aclose(aid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR /* Open dset dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close property list */ - if(H5Pclose(ocpypl_id) < 0) TEST_ERROR + if (H5Pclose(ocpypl_id) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid_src); H5Fclose(fid_dst); H5Tclose(tid); @@ -11166,46 +13367,47 @@ error: H5Aclose(aid); H5Gclose(gid); H5Pclose(ocpypl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_committed_dt_merge_attr */ /* * Defines used for the committed datatype tests */ -#define SRC_ROOT_GROUP "src_root" -#define ROOT_NDT_INT "root_ndt_int" +#define SRC_ROOT_GROUP "src_root" +#define ROOT_NDT_INT "root_ndt_int" #define GROUP_NDT_SHORT "group_ndt_short" -#define SRC_GRP "src_grp" -#define DST_GRP "dst_grp" -#define DST_GRP2 "dst_grp2" +#define SRC_GRP "src_grp" +#define DST_GRP "dst_grp" +#define DST_GRP2 "dst_grp2" -#define SRC_NDT_SHORT "src_ndt_short" +#define SRC_NDT_SHORT "src_ndt_short" #define SRC_NDT_INT "src_ndt_int" -#define SRC_NDT_INT2 "src_ndt_int2" -#define SRC_NDT_FLOAT "src_ndt_float" -#define SRC_NDT_DOUBLE "src_ndt_double" +#define SRC_NDT_INT2 "src_ndt_int2" +#define SRC_NDT_FLOAT "src_ndt_float" +#define SRC_NDT_DOUBLE "src_ndt_double" -#define DST_NDT_SHORT "dst_ndt_short" +#define DST_NDT_SHORT "dst_ndt_short" #define DST_NDT_INT "dst_ndt_int" -#define DST_NDT_FLOAT "dst_ndt_float" -#define DST_NDT_DOUBLE "dst_ndt_double" +#define DST_NDT_FLOAT "dst_ndt_float" +#define DST_NDT_DOUBLE "dst_ndt_double" -#define SRC_NDT_DSET "src_ndt_dset" -#define SRC_NDT_DSET2 "src_ndt_dset2" -#define SRC_NDT_DSET3 "src_ndt_dset3" +#define SRC_NDT_DSET "src_ndt_dset" +#define SRC_NDT_DSET2 "src_ndt_dset2" +#define SRC_NDT_DSET3 "src_ndt_dset3" -#define SRC_DSET "src_dset" -#define SRC_DSET1 "src_dset1" +#define SRC_DSET "src_dset" +#define SRC_DSET1 "src_dset1" -#define SRC_ATTR "src_attr" +#define SRC_ATTR "src_attr" -#define DST_ATTR_ANON_SHORT "dst_attr_anon_short" -#define DST_ATTR_ANON_INT "dst_attr_anon_int" +#define DST_ATTR_ANON_SHORT "dst_attr_anon_short" +#define DST_ATTR_ANON_INT "dst_attr_anon_int" #define DST_ATTR "dst_attr" -#define DST_ATTR2 "dst_attr2" +#define DST_ATTR2 "dst_attr2" /*------------------------------------------------------------------------- * Function: test_copy_cdt_hier_merge @@ -11232,32 +13434,32 @@ error: static int test_copy_cdt_hier_merge(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t reopen) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t gid = -1; /* Group IDs */ - hid_t f_tid = -1; /* Datatype ID for root group */ - hid_t g_tid = -1; /* Datatype ID for group */ - hid_t anon_tid = -1; /* Anonymous datatype */ - hid_t aid = -1; /* Attribute ID */ - hid_t ocpypl_id = -1; /* Object copy plist ID */ - int i; /* Local index variable */ - hsize_t dim1d[1]; /* dimension sizes */ - int buf[DIM_SIZE_1]; /* Buffer for data */ - H5O_token_t exp_token_int, exp_token_short; /* Expected object tokenes */ - H5O_info2_t oinfo; /* Object info */ - char src_filename[NAME_BUF_SIZE]; /* Source file name */ - char dst_filename[NAME_BUF_SIZE]; /* Destination file name */ - int token_cmp; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t gid = -1; /* Group IDs */ + hid_t f_tid = -1; /* Datatype ID for root group */ + hid_t g_tid = -1; /* Datatype ID for group */ + hid_t anon_tid = -1; /* Anonymous datatype */ + hid_t aid = -1; /* Attribute ID */ + hid_t ocpypl_id = -1; /* Object copy plist ID */ + int i; /* Local index variable */ + hsize_t dim1d[1]; /* dimension sizes */ + int buf[DIM_SIZE_1]; /* Buffer for data */ + H5O_token_t exp_token_int, exp_token_short; /* Expected object tokenes */ + H5O_info2_t oinfo; /* Object info */ + char src_filename[NAME_BUF_SIZE]; /* Source file name */ + char dst_filename[NAME_BUF_SIZE]; /* Destination file name */ + int token_cmp; - if(reopen) + if (reopen) TESTING("H5Ocopy(): hier. of committed datatypes and merging with reopen") else TESTING("H5Ocopy(): hier. of committed datatypes and merging ") /* set initial data values */ - for (i=0; icalled++; - return(udata->search_action); + return (udata->search_action); } /* mcdt_search_cb() */ static int -test_copy_set_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, - hid_t dst_fapl, hbool_t reopen) +test_copy_set_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, hbool_t reopen) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t ocpypl_id = -1; /* Object copy plist ID */ - unsigned int i; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - int buf[DIM_SIZE_1]; /* Buffer for writing data */ - H5O_info2_t oinfo; /* Object info */ - H5O_token_t exp_token; /* Expected object token */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; - mcdt_search_cb_ud cb_udata; /* User data for callback */ - int token_cmp; - - if(reopen) + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t ocpypl_id = -1; /* Object copy plist ID */ + unsigned int i; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + int buf[DIM_SIZE_1]; /* Buffer for writing data */ + H5O_info2_t oinfo; /* Object info */ + H5O_token_t exp_token; /* Expected object token */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + mcdt_search_cb_ud cb_udata; /* User data for callback */ + int token_cmp; + + if (reopen) TESTING("H5Ocopy(): H5Pset_mcdt_search_cb and reopen") else TESTING("H5Ocopy(): H5Pset_mcdt_search_cb") /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) + for (i = 0; i < DIM_SIZE_1; i++) buf[i] = (int)i; /* Initialize the filenames */ @@ -12852,304 +15588,414 @@ test_copy_set_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* * Populate source file */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* named datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR /* Create an uncopied group in destination file */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* * Populate destination file */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype "a" */ - if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype "b" */ - if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* Create ocpl and set merge committed dtype flag */ - if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR - if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR + if ((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR + if (H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) + TEST_ERROR /* * First copy dataset using "/b" as a suggestion, and verify that it uses * datatype "b" in the destination file */ /* Add datatype suggestion */ - if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) TEST_ERROR + if (H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) + TEST_ERROR /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open committed dtype "b", get token */ - if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open dset dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* * Set callback to continue the search */ cb_udata.search_action = H5O_MCDT_SEARCH_CONT; - cb_udata.called = 0; + cb_udata.called = 0; /* Free suggestions */ - if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR + if (H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) + TEST_ERROR /* Add datatype suggestion to group "/uncopied" */ - if(H5Padd_merge_committed_dtype_path(ocpypl_id, NAME_GROUP_UNCOPIED) < 0) TEST_ERROR + if (H5Padd_merge_committed_dtype_path(ocpypl_id, NAME_GROUP_UNCOPIED) < 0) + TEST_ERROR /* Continue the global search */ - if(H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cb, &cb_udata) < 0) - TEST_ERROR + if (H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cb, &cb_udata) < 0) + TEST_ERROR /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify callback has been called exactly once */ - if(cb_udata.called != 1) TEST_ERROR + if (cb_udata.called != 1) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open committed dtype "a", get token */ - if((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open copied dataset and its dtype, check token */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* * Stop the search, default action is to create an anonymous committed datatype */ cb_udata.search_action = H5O_MCDT_SEARCH_STOP; - cb_udata.called = 0; + cb_udata.called = 0; /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify callback has been called exactly once */ - if(cb_udata.called != 1) TEST_ERROR + if (cb_udata.called != 1) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open committed dtype "a", get token */ - if((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open the copied dataset and get its dtype, tokens should not be equal */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(!token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open committed dtype "b", get token */ - if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open the copied dataset and get its dtype, tokens should not be equal */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(!token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* * Stop the search, default action is to create an anonymous committed datatype. * Disable suggestion list. */ cb_udata.search_action = H5O_MCDT_SEARCH_STOP; - cb_udata.called = 0; + cb_udata.called = 0; /* Free suggestions */ - if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR + if (H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) + TEST_ERROR /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* Delete dataset */ - if(H5Ldelete(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR /* Verify callback has been called exactly once */ - if(cb_udata.called != 1) TEST_ERROR + if (cb_udata.called != 1) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Open committed dtype "a", get token */ - if((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/a", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open the copied dataset and get its dtype, tokens should not be equal */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(!token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Open committed dtype "b", get token */ - if((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR + if ((tid = H5Topen2(fid_dst, "/b", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR HDmemcpy(&exp_token, &oinfo.token, sizeof(exp_token)); - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* Open the copied dataset and get its dtype, tokens should not be equal */ - if((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) TEST_ERROR - if((tid = H5Dget_type(did)) < 0) TEST_ERROR - if(H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) TEST_ERROR - if(!token_cmp) TEST_ERROR - if(H5Tclose(tid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR + if ((did = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR + if (H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(tid, &oinfo.token, &exp_token, &token_cmp) < 0) + TEST_ERROR + if (!token_cmp) + TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close property list */ - if(H5Pclose(ocpypl_id) < 0) TEST_ERROR + if (H5Pclose(ocpypl_id) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid_src); H5Fclose(fid_dst); H5Tclose(tid); H5Sclose(sid); H5Dclose(did); H5Pclose(ocpypl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_set_mcdt_search_cb */ - /*------------------------------------------------------------------------- * Function: test_copy_set_get_mcdt_cb * @@ -13169,7 +16015,7 @@ mcdt_search_cbA(void *_udata) { H5O_mcdt_search_ret_t *action = (H5O_mcdt_search_ret_t *)_udata; - return(*action); + return (*action); } /* mcdt_search_cb() */ static H5O_mcdt_search_ret_t @@ -13177,36 +16023,36 @@ mcdt_search_cbB(void *_udata) { H5O_mcdt_search_ret_t *action = (H5O_mcdt_search_ret_t *)_udata; - return(*action); + return (*action); } /* mnt_search_cb() */ /* The main test function */ static int -test_copy_set_get_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, - hid_t dst_fapl, hbool_t reopen) +test_copy_set_get_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, + hbool_t reopen) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t ocpypl_id = -1; /* Object copy plist ID */ - unsigned int i; /* Local index variables */ - hsize_t dim1d[1]; /* Dataset dimensions */ - int buf[DIM_SIZE_1]; /* Buffer for writing data */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; - H5O_mcdt_search_cb_t mcdt_cb = NULL; /* The callback function */ - H5O_mcdt_search_ret_t mcdt_udataA; /* User data for callback */ - H5O_mcdt_search_ret_t mcdt_udataB; /* User data for callback */ - H5O_mcdt_search_ret_t *mcdt_udata_p = NULL; /* Pointer to user data for callback */ - - if(reopen) + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t ocpypl_id = -1; /* Object copy plist ID */ + unsigned int i; /* Local index variables */ + hsize_t dim1d[1]; /* Dataset dimensions */ + int buf[DIM_SIZE_1]; /* Buffer for writing data */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + H5O_mcdt_search_cb_t mcdt_cb = NULL; /* The callback function */ + H5O_mcdt_search_ret_t mcdt_udataA; /* User data for callback */ + H5O_mcdt_search_ret_t mcdt_udataB; /* User data for callback */ + H5O_mcdt_search_ret_t *mcdt_udata_p = NULL; /* Pointer to user data for callback */ + + if (reopen) TESTING("H5Ocopy(): H5Pset/get_mcdt_search_cb and reopen") else TESTING("H5Ocopy(): H5Pset/get_mcdt_search_cb") /* set initial data values */ - for(i = 0; i < DIM_SIZE_1; i++) + for (i = 0; i < DIM_SIZE_1; i++) buf[i] = (int)i; /* Initialize the filenames */ @@ -13217,103 +16063,132 @@ test_copy_set_get_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, token_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR /* Set dataspace dimensions */ - dim1d[0]=DIM_SIZE_1; + dim1d[0] = DIM_SIZE_1; /* create dataspace */ - if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR + if ((sid = H5Screate_simple(1, dim1d, NULL)) < 0) + TEST_ERROR /* * Populate source file */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype */ - if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create dataset at SRC file */ - if((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* write data into file */ - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the dataset */ - if(H5Dclose(did) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR /* Create an uncopied group in destination file */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* * Populate destination file */ /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype "a" */ - if((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_dst, "/a", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* create datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR /* committed datatype "b" */ - if((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((H5Tcommit2(fid_dst, "/b", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* close the datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* Create ocpl and set merge committed dtype flag */ - if((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR - if(H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) TEST_ERROR + if ((ocpypl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR + if (H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) < 0) + TEST_ERROR /* * First copy dataset using "/b" as a suggestion, and verify that it uses * datatype "b" in the destination file */ /* Add datatype suggestion */ - if(H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) TEST_ERROR + if (H5Padd_merge_committed_dtype_path(ocpypl_id, "/b") < 0) + TEST_ERROR /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ /* Verify "get" routine functionality */ - if(H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **) &mcdt_udata_p) < 0) TEST_ERROR + if (H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **)&mcdt_udata_p) < 0) + TEST_ERROR - if(mcdt_cb != NULL) TEST_ERROR - if(mcdt_udata_p != NULL) TEST_ERROR + if (mcdt_cb != NULL) + TEST_ERROR + if (mcdt_udata_p != NULL) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* * Set callback to continue the search @@ -13321,130 +16196,161 @@ test_copy_set_get_mcdt_search_cb(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, mcdt_udataA = H5O_MCDT_SEARCH_CONT; /* Free suggestions */ - if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR + if (H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) + TEST_ERROR /* Add datatype suggestion to group "/uncopied" */ - if(H5Padd_merge_committed_dtype_path(ocpypl_id, NAME_GROUP_UNCOPIED) < 0) TEST_ERROR + if (H5Padd_merge_committed_dtype_path(ocpypl_id, NAME_GROUP_UNCOPIED) < 0) + TEST_ERROR /* Continue the global search */ - if(H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbA, &mcdt_udataA) < 0) - TEST_ERROR + if (H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbA, &mcdt_udataA) < 0) + TEST_ERROR /* open the destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE2, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ - mcdt_cb = NULL; + mcdt_cb = NULL; mcdt_udata_p = NULL; /* Verify "get" routine functionality */ - if(H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **) &mcdt_udata_p) < 0) TEST_ERROR + if (H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **)&mcdt_udata_p) < 0) + TEST_ERROR - if(mcdt_cb != mcdt_search_cbA) TEST_ERROR - if(mcdt_udata_p != &mcdt_udataA) TEST_ERROR + if (mcdt_cb != mcdt_search_cbA) + TEST_ERROR + if (mcdt_udata_p != &mcdt_udataA) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* * Stop the search, default action is to create an anonymous committed datatype */ mcdt_udataB = H5O_MCDT_SEARCH_STOP; - if(H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbA, &mcdt_udataB) < 0) - TEST_ERROR + if (H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbA, &mcdt_udataB) < 0) + TEST_ERROR /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR - /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + /* copy SRC dset to DST */ + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ - mcdt_cb = NULL; + mcdt_cb = NULL; mcdt_udata_p = NULL; /* Verify "get" routine functionality */ - if(H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **) &mcdt_udata_p) < 0) TEST_ERROR + if (H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **)&mcdt_udata_p) < 0) + TEST_ERROR - if(mcdt_cb != mcdt_search_cbA) TEST_ERROR - if(mcdt_udata_p != &mcdt_udataB) TEST_ERROR + if (mcdt_cb != mcdt_search_cbA) + TEST_ERROR + if (mcdt_udata_p != &mcdt_udataB) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR - /* Free suggestions */ - if(H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) TEST_ERROR + /* Free suggestions */ + if (H5Pfree_merge_committed_dtype_paths(ocpypl_id) < 0) + TEST_ERROR - if(H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbB, &mcdt_udataB) < 0) - TEST_ERROR + if (H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cbB, &mcdt_udataB) < 0) + TEST_ERROR /* open destination file */ - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* Delete dataset */ - if(H5Ldelete(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ldelete(fid_dst, NAME_DATASET_SIMPLE3, H5P_DEFAULT) < 0) + TEST_ERROR /* copy SRC dset to DST */ - if(H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE3, ocpypl_id, H5P_DEFAULT) < 0) + TEST_ERROR - if(reopen) { + if (reopen) { /* Reopen file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR - if((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR + if ((fid_dst = H5Fopen(dst_filename, H5F_ACC_RDONLY, dst_fapl)) < 0) + TEST_ERROR } /* end if */ - mcdt_cb = NULL; + mcdt_cb = NULL; mcdt_udata_p = NULL; /* Verify "get" routine functionality */ - if(H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **) &mcdt_udata_p) < 0) TEST_ERROR + if (H5Pget_mcdt_search_cb(ocpypl_id, &mcdt_cb, (void **)&mcdt_udata_p) < 0) + TEST_ERROR - if(mcdt_cb != mcdt_search_cbB) TEST_ERROR - if(mcdt_udata_p != &mcdt_udataB) TEST_ERROR + if (mcdt_cb != mcdt_search_cbB) + TEST_ERROR + if (mcdt_udata_p != &mcdt_udataB) + TEST_ERROR /* Close destination file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close property list */ - if(H5Pclose(ocpypl_id) < 0) TEST_ERROR + if (H5Pclose(ocpypl_id) < 0) + TEST_ERROR /* close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid_src); H5Fclose(fid_dst); H5Tclose(tid); H5Sclose(sid); H5Dclose(did); H5Pclose(ocpypl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_set_get_mcdt_search_cb */ - /*------------------------------------------------------------------------- * Function: test_copy_iterate * @@ -13460,29 +16366,29 @@ error: *------------------------------------------------------------------------- */ static herr_t -test_copy_iterate_cb(hid_t loc_id, const char *name, - const H5L_info2_t H5_ATTR_UNUSED *link_info, void *op_data) +test_copy_iterate_cb(hid_t loc_id, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, + void *op_data) { hid_t dst_loc_id = *((hid_t *)op_data); - if(H5Ocopy(loc_id, name, dst_loc_id, name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Ocopy(loc_id, name, dst_loc_id, name, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - return(H5_ITER_CONT); + return (H5_ITER_CONT); error: - return(H5_ITER_ERROR); + return (H5_ITER_ERROR); } /* end test_copy_iterate_cb */ static int test_copy_iterate(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gid = -1; /* Group ID */ - int i; - char grp_name[16]; - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gid = -1; /* Group ID */ + int i; + char grp_name[16]; + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): inside H5Literate() callback"); @@ -13494,54 +16400,62 @@ test_copy_iterate(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl token_reset(); /* Create source file */ - if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + if ((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create groups */ - for(i=0; i<9; i++) { + for (i = 0; i < 9; i++) { HDsnprintf(grp_name, sizeof(grp_name), "grp%d", i); - if((gid = H5Gcreate2(fid1, grp_name, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid1, grp_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) TEST_ERROR } /* end for */ /* Create destination file */ - if((fid2 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + if ((fid2 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Close files */ - if(H5Fclose(fid1) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR /* Reopen files */ - if((fid1 = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) TEST_ERROR - if((fid2 = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + if ((fid1 = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) + TEST_ERROR + if ((fid2 = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) + TEST_ERROR /* Iterate over links in the root group, copying each object */ - if((gid = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Literate2(gid, H5_INDEX_NAME, H5_ITER_INC, NULL, test_copy_iterate_cb, &fid2) < 0) + if ((gid = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Literate2(gid, H5_INDEX_NAME, H5_ITER_INC, NULL, test_copy_iterate_cb, &fid2) < 0) TEST_ERROR /* Close */ - if(H5Gclose(gid) < 0) TEST_ERROR - if(H5Fclose(fid1) < 0) TEST_ERROR - if(H5Fclose(fid2) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR + if (H5Fclose(fid1) < 0) + TEST_ERROR + if (H5Fclose(fid2) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid1); H5Fclose(fid2); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_iterate */ - /*------------------------------------------------------------------------- * Function: test_copy_option * @@ -13556,29 +16470,29 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, - unsigned flag, hbool_t crt_intermediate_grp, const char* test_desciption) +test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, unsigned flag, + hbool_t crt_intermediate_grp, const char *test_desciption) { - hid_t fid_src = -1, fid_dst = -1, fid_ext = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t gid=-1, gid2=-1, gid_ref=-1; /* Group IDs */ - hid_t gid_sub=-1, gid_sub_sub=-1; /* Sub-group ID */ - hid_t pid=-1, lcpl_id=-1; /* Property IDs */ - unsigned cpy_flags; /* Object copy flags */ - int depth = -1; /* Copy depth */ - hsize_t dim2d[2]; - int buf[DIM_SIZE_1][DIM_SIZE_2]; - int i, j; - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1, fid_ext = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t gid = -1, gid2 = -1, gid_ref = -1; /* Group IDs */ + hid_t gid_sub = -1, gid_sub_sub = -1; /* Sub-group ID */ + hid_t pid = -1, lcpl_id = -1; /* Property IDs */ + unsigned cpy_flags; /* Object copy flags */ + int depth = -1; /* Copy depth */ + hsize_t dim2d[2]; + int buf[DIM_SIZE_1][DIM_SIZE_2]; + int i, j; + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING(test_desciption); /* set initial data values */ - for (i=0; i 0) { + if ((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) { /* Create group to copy */ - if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft(NAME_DATASET_SUB_SUB, fid_src, NAME_LINK_SOFT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("nowhere", fid_src, NAME_LINK_SOFT_DANGLE, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft(NAME_DATASET_SUB_SUB, fid_src, NAME_LINK_SOFT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("nowhere", fid_src, NAME_LINK_SOFT_DANGLE, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Create group to compare with */ - if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lcreate_hard(fid_src, NAME_DATASET_SUB_SUB, H5L_SAME_LOC, NAME_LINK_SOFT2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("nowhere", fid_src, NAME_LINK_SOFT_DANGLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_hard(fid_src, NAME_DATASET_SUB_SUB, H5L_SAME_LOC, NAME_LINK_SOFT2, H5P_DEFAULT, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("nowhere", fid_src, NAME_LINK_SOFT_DANGLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR } /* end if */ - if((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) { - char ext_filename[NAME_BUF_SIZE]; + if ((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) { + char ext_filename[NAME_BUF_SIZE]; h5_fixname(FILENAME[2], src_fapl, ext_filename, sizeof ext_filename); /* Create the external file and dataset */ - if((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR - if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid_ext, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid_ext) < 0) TEST_ERROR + if ((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR + if ((sid = H5Screate_simple(2, dim2d, NULL)) < 0) + TEST_ERROR + if ((did = H5Dcreate2(fid_ext, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + if (H5Fclose(fid_ext) < 0) + TEST_ERROR /* Create group to copy */ - if(!(flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG)) { - if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (!(flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG)) { + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR } /* end if */ - else - if((gid = H5Gopen2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lcreate_external(ext_filename, NAME_DATASET_SIMPLE, fid_src, NAME_LINK_EXTERN, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external("no_file", "no_object", fid_src, NAME_LINK_EXTERN_DANGLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + else if ((gid = H5Gopen2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lcreate_external(ext_filename, NAME_DATASET_SIMPLE, fid_src, NAME_LINK_EXTERN, H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external("no_file", "no_object", fid_src, NAME_LINK_EXTERN_DANGLE, H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create group to compare with */ - if(!(flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG)) { - if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (!(flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG)) { + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR } /* end if */ - else - if((gid = H5Gopen2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid_src, NAME_LINK_EXTERN2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR - if(H5Lcreate_external("no_file", "no_object", fid_src, NAME_LINK_EXTERN_DANGLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + else if ((gid = H5Gopen2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_LINK_EXTERN2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR + if (H5Lcreate_external("no_file", "no_object", fid_src, NAME_LINK_EXTERN_DANGLE2, H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR } /* end if */ - if((flag & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) { - if((gid_ref = H5Gcreate2(fid_src, NAME_GROUP_REF, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((flag & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) { + if ((gid_ref = H5Gcreate2(fid_src, NAME_GROUP_REF, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create an attribute of object references */ - if(attach_ref_attr(fid_src, gid_ref) < 0) TEST_ERROR + if (attach_ref_attr(fid_src, gid_ref) < 0) + TEST_ERROR /* create an attribute of region references */ - if(attach_reg_ref_attr(fid_src, gid_ref) < 0) TEST_ERROR + if (attach_reg_ref_attr(fid_src, gid_ref) < 0) + TEST_ERROR /* create a dataset of region references */ - if(create_reg_ref_dataset(fid_src, gid_ref) < 0) TEST_ERROR + if (create_reg_ref_dataset(fid_src, gid_ref) < 0) + TEST_ERROR /* Close group holding reference objects */ - if(H5Gclose(gid_ref) < 0) TEST_ERROR + if (H5Gclose(gid_ref) < 0) + TEST_ERROR } /* end if */ /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ /* (except when expanding soft links */ - if((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) { - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) TEST_ERROR + if ((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) { + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) + TEST_ERROR } /* end if */ - else - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + else if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create property to pass copy options */ - if((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR /* set options for object copy */ - if(H5Pset_copy_object(pid, flag) < 0) TEST_ERROR + if (H5Pset_copy_object(pid, flag) < 0) + TEST_ERROR /* Verify object copy flags */ - if(H5Pget_copy_object(pid, &cpy_flags) < 0) TEST_ERROR - if(cpy_flags != flag) TEST_ERROR + if (H5Pget_copy_object(pid, &cpy_flags) < 0) + TEST_ERROR + if (cpy_flags != flag) + TEST_ERROR /* copy the group from SRC to DST */ - if(crt_intermediate_grp) { + if (crt_intermediate_grp) { /* Create link creation plist to pass in intermediate group creation */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) + TEST_ERROR - if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, "/new_g0/new_g00", pid, lcpl_id) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, "/new_g0/new_g00", pid, lcpl_id) < 0) + TEST_ERROR - if(H5Pclose(lcpl_id) < 0) TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, "/new_g0/new_g00", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - - } else if(((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) - || ((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0)) { - if(H5Ocopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, pid, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid_dst, "/new_g0/new_g00", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + } + else if (((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) || ((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0)) { + if (H5Ocopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, pid, H5P_DEFAULT) < 0) + TEST_ERROR - if((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) + if ((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) /* Unlink dataset to copy from original location */ /* (So group comparison works properly) */ - if(H5Ldelete(fid_src, NAME_DATASET_SUB_SUB, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid_src, NAME_DATASET_SUB_SUB, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_LINK, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - - } else if(flag & (H5O_COPY_WITHOUT_ATTR_FLAG | H5O_COPY_PRESERVE_NULL_FLAG)) { - if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_LINK, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + } + else if (flag & (H5O_COPY_WITHOUT_ATTR_FLAG | H5O_COPY_PRESERVE_NULL_FLAG)) { + if (H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - } else if(flag & H5O_COPY_SHALLOW_HIERARCHY_FLAG) { - if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + } + else if (flag & H5O_COPY_SHALLOW_HIERARCHY_FLAG) { + if (H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Set the copy depth */ depth = 1; - } else if((flag & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) { - if(H5Ocopy(fid_src, NAME_GROUP_REF, fid_dst, NAME_GROUP_REF, pid, H5P_DEFAULT) < 0) TEST_ERROR + } + else if ((flag & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) { + if (H5Ocopy(fid_src, NAME_GROUP_REF, fid_dst, NAME_GROUP_REF, pid, H5P_DEFAULT) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_REF, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_REF, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_REF, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - } else { + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_REF, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + } + else { /* Unknown flag */ TEST_ERROR } /* end else */ /* Check if the groups are equal */ - if(compare_groups(gid, gid2, pid, depth, flag) != TRUE) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (compare_groups(gid, gid2, pid, depth, flag) != TRUE) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* close properties */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(lcpl_id); H5Pclose(pid); H5Sclose(sid); @@ -13826,11 +16834,11 @@ error: H5Fclose(fid_dst); H5Fclose(fid_src); H5Fclose(fid_ext); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_option */ - /*------------------------------------------------------------------------- * Function: test_copy_dataset_open * @@ -13874,32 +16882,32 @@ error: static int test_copy_dataset_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { - hid_t fid_src = -1, fid_dst = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t did3 = -1, did4 = -1; /* Dataset IDs */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t pid = -1; /* Dataset creation property list */ - hsize_t chunk_dim2d[2] = {CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimension sizes */ - int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ - int newbuf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ - hsize_t dim2d[2]; /* Dataset dimensions */ - int i, j; /* local index variables */ - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t did3 = -1, did4 = -1; /* Dataset IDs */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t pid = -1; /* Dataset creation property list */ + hsize_t chunk_dim2d[2] = {CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimension sizes */ + int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ + int newbuf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ + hsize_t dim2d[2]; /* Dataset dimensions */ + int i, j; /* local index variables */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING("H5Ocopy(): copying objects while opened"); /* Initialize write buffer */ - for (i=0; irc < 2) + if (oinfo->rc < 2) return; /* Extend the table */ - if(idtab_g.nobjs >= idtab_g.nalloc) { + if (idtab_g.nobjs >= idtab_g.nalloc) { idtab_g.nalloc = MAX(256, 2 * idtab_g.nalloc); - idtab_g.obj = (H5O_token_t *)HDrealloc(idtab_g.obj, idtab_g.nalloc * sizeof(idtab_g.obj[0])); + idtab_g.obj = (H5O_token_t *)HDrealloc(idtab_g.obj, idtab_g.nalloc * sizeof(idtab_g.obj[0])); } /* Insert the entry */ - n = idtab_g.nobjs++; + n = idtab_g.nobjs++; idtab_g.obj[n] = oinfo->token; } /* end token_insert() */ - /*------------------------------------------------------------------------- * Function: token_lookup * @@ -137,22 +131,21 @@ static H5_ATTR_PURE hbool_t token_lookup(hid_t loc_id, H5O_info2_t *oinfo) { size_t n; - int token_cmp; + int token_cmp; - if(oinfo->rc < 2) + if (oinfo->rc < 2) return FALSE; /*only one link possible*/ - for(n = 0; n < idtab_g.nobjs; n++) { - if(H5Otoken_cmp(loc_id, &(idtab_g.obj[n]), &oinfo->token, &token_cmp) < 0) + for (n = 0; n < idtab_g.nobjs; n++) { + if (H5Otoken_cmp(loc_id, &(idtab_g.obj[n]), &oinfo->token, &token_cmp) < 0) return FALSE; - if(0 == token_cmp) + if (0 == token_cmp) return TRUE; } return FALSE; } /* end token_lookup() */ - /*------------------------------------------------------------------------- * Function: token_reset * @@ -168,13 +161,12 @@ token_lookup(hid_t loc_id, H5O_info2_t *oinfo) static void token_reset(void) { - if(idtab_g.obj) + if (idtab_g.obj) HDfree(idtab_g.obj); - idtab_g.obj = NULL; + idtab_g.obj = NULL; idtab_g.nalloc = idtab_g.nobjs = 0; } /* end token_reset() */ - /*------------------------------------------------------------------------- * Function: attach_ref_attr * @@ -187,41 +179,61 @@ token_reset(void) static herr_t attach_ref_attr(hid_t file_id, hid_t loc_id) { - char dsetname1[] = "dataset1_pointed_by_ref_attr"; - char dsetname2[] = "dataset2_pointed_by_ref_attr"; - hid_t did1 = (-1), did2 = (-1), aid = (-1), sid = (-1), sid_ref = (-1); - hsize_t dims[2] = {2,9}; - hsize_t dims_ref[1] = {2}; + char dsetname1[] = "dataset1_pointed_by_ref_attr"; + char dsetname2[] = "dataset2_pointed_by_ref_attr"; + hid_t did1 = (-1), did2 = (-1), aid = (-1), sid = (-1), sid_ref = (-1); + hsize_t dims[2] = {2, 9}; + hsize_t dims_ref[1] = {2}; H5R_ref_t ref[2]; - int data1[2][9] = {{1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,18}}; - int data2[2][9] = {{2,2,2,2,2,2,2,2,2},{2,2,2,2,2,2,2,2,18}}; + int data1[2][9] = {{1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 18}}; + int data2[2][9] = {{2, 2, 2, 2, 2, 2, 2, 2, 2}, {2, 2, 2, 2, 2, 2, 2, 2, 18}}; /* creates two simple datasets */ - if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((sid_ref = H5Screate_simple(1, dims_ref, NULL)) < 0) TEST_ERROR - if((did1 = H5Dcreate2(file_id, dsetname1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data1) < 0) TEST_ERROR - if((did2 = H5Dcreate2(file_id, dsetname2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data2) < 0) TEST_ERROR + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + if ((sid_ref = H5Screate_simple(1, dims_ref, NULL)) < 0) + TEST_ERROR + if ((did1 = H5Dcreate2(file_id, dsetname1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0) + TEST_ERROR + if ((did2 = H5Dcreate2(file_id, dsetname2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2) < 0) + TEST_ERROR /* create an attribute with two object references */ - if(H5Rcreate_object(file_id, dsetname1, H5P_DEFAULT, &ref[0]) < 0) TEST_ERROR - if(H5Rcreate_object(file_id, dsetname2, H5P_DEFAULT, &ref[1]) < 0) TEST_ERROR - if((aid = H5Acreate2(loc_id, "obj_ref_attr", H5T_STD_REF, sid_ref, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_STD_REF, ref) < 0) TEST_ERROR - - if(H5Sclose(sid) < 0) TEST_ERROR - if(H5Sclose(sid_ref) < 0) TEST_ERROR - if(H5Dclose(did1) < 0) TEST_ERROR - if(H5Dclose(did2) < 0) TEST_ERROR - if(H5Aclose(aid) < 0) TEST_ERROR - if(H5Rdestroy(&ref[0]) < 0) TEST_ERROR - if(H5Rdestroy(&ref[1]) < 0) TEST_ERROR + if (H5Rcreate_object(file_id, dsetname1, H5P_DEFAULT, &ref[0]) < 0) + TEST_ERROR + if (H5Rcreate_object(file_id, dsetname2, H5P_DEFAULT, &ref[1]) < 0) + TEST_ERROR + if ((aid = H5Acreate2(loc_id, "obj_ref_attr", H5T_STD_REF, sid_ref, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Awrite(aid, H5T_STD_REF, ref) < 0) + TEST_ERROR + + if (H5Sclose(sid) < 0) + TEST_ERROR + if (H5Sclose(sid_ref) < 0) + TEST_ERROR + if (H5Dclose(did1) < 0) + TEST_ERROR + if (H5Dclose(did2) < 0) + TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR + if (H5Rdestroy(&ref[0]) < 0) + TEST_ERROR + if (H5Rdestroy(&ref[1]) < 0) + TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Sclose(sid_ref); H5Dclose(did1); @@ -229,9 +241,10 @@ error: H5Aclose(aid); H5Rdestroy(&ref[0]); H5Rdestroy(&ref[1]); - } H5E_END_TRY; + } + H5E_END_TRY; - return(-1); + return (-1); } /*------------------------------------------------------------------------- @@ -250,69 +263,90 @@ static herr_t attach_reg_ref_attr(hid_t file_id, hid_t loc_id) { const char dsetnamev[] = "dataset_pointed_by_reg_ref_attr"; - hid_t aid = (-1); - hid_t space_id = (-1); /* dataspace identifiers */ - hid_t spacer_id = (-1); /* dataspace identifiers */ - hid_t dsetv_id = (-1); /*dataset identifiers*/ - hsize_t dims[2] = {2,9}; - hsize_t dimsr[1] = {2}; - int rank = 2; - int rankr =1; - H5R_ref_t ref[2]; - int data[2][9] = {{1,1,2,3,3,4,5,5,999},{1,2,2,3,4,4,5,6,999}}; - hsize_t start[2] = {0, 3}; - hsize_t count[2] = {2, 3}; - hsize_t coord[3][2] = {{0, 0}, {1, 6}, {0, 8}}; - size_t num_points = 3; + hid_t aid = (-1); + hid_t space_id = (-1); /* dataspace identifiers */ + hid_t spacer_id = (-1); /* dataspace identifiers */ + hid_t dsetv_id = (-1); /*dataset identifiers*/ + hsize_t dims[2] = {2, 9}; + hsize_t dimsr[1] = {2}; + int rank = 2; + int rankr = 1; + H5R_ref_t ref[2]; + int data[2][9] = {{1, 1, 2, 3, 3, 4, 5, 5, 999}, {1, 2, 2, 3, 4, 4, 5, 6, 999}}; + hsize_t start[2] = {0, 3}; + hsize_t count[2] = {2, 3}; + hsize_t coord[3][2] = {{0, 0}, {1, 6}, {0, 8}}; + size_t num_points = 3; /* create a 2D dataset */ - if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) TEST_ERROR - if((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) TEST_ERROR - if((dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data) < 0) TEST_ERROR + if ((space_id = H5Screate_simple(rank, dims, NULL)) < 0) + TEST_ERROR + if ((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) + TEST_ERROR + if ((dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + TEST_ERROR /* create reg_ref of block selection */ - if(H5Sselect_hyperslab(space_id,H5S_SELECT_SET,start,NULL,count,NULL) < 0) TEST_ERROR - if(H5Rcreate_region(file_id, dsetnamev, space_id, H5P_DEFAULT, &ref[0]) < 0) TEST_ERROR + if (H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + TEST_ERROR + if (H5Rcreate_region(file_id, dsetnamev, space_id, H5P_DEFAULT, &ref[0]) < 0) + TEST_ERROR /* create reg_ref of point selection */ - if(H5Sselect_none(space_id) < 0) TEST_ERROR - if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) TEST_ERROR - if(H5Rcreate_region(file_id, dsetnamev, space_id, H5P_DEFAULT, &ref[1]) < 0) TEST_ERROR + if (H5Sselect_none(space_id) < 0) + TEST_ERROR + if (H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) + TEST_ERROR + if (H5Rcreate_region(file_id, dsetnamev, space_id, H5P_DEFAULT, &ref[1]) < 0) + TEST_ERROR /* create reg_ref attribute */ - if((aid = H5Acreate2(loc_id, "reg_ref_attr", H5T_STD_REF, spacer_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_STD_REF, ref) < 0) TEST_ERROR + if ((aid = H5Acreate2(loc_id, "reg_ref_attr", H5T_STD_REF, spacer_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Awrite(aid, H5T_STD_REF, ref) < 0) + TEST_ERROR /* attach the reg_ref attribute to the dataset itself */ - if(H5Aclose(aid) < 0) TEST_ERROR - if((aid = H5Acreate2(dsetv_id, "reg_ref_attr", H5T_STD_REF, spacer_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Awrite(aid, H5T_STD_REF, ref) < 0) TEST_ERROR - - if(H5Sclose(spacer_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Dclose(dsetv_id) < 0) TEST_ERROR - if(H5Aclose(aid) < 0) TEST_ERROR - if(H5Rdestroy(&ref[0]) < 0) TEST_ERROR - if(H5Rdestroy(&ref[1]) < 0) TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR + if ((aid = H5Acreate2(dsetv_id, "reg_ref_attr", H5T_STD_REF, spacer_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Awrite(aid, H5T_STD_REF, ref) < 0) + TEST_ERROR + if (H5Sclose(spacer_id) < 0) + TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (H5Dclose(dsetv_id) < 0) + TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR + if (H5Rdestroy(&ref[0]) < 0) + TEST_ERROR + if (H5Rdestroy(&ref[1]) < 0) + TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(spacer_id); H5Sclose(space_id); H5Dclose(dsetv_id); H5Aclose(aid); H5Rdestroy(&ref[0]); H5Rdestroy(&ref[1]); - } H5E_END_TRY; + } + H5E_END_TRY; - return(-1); + return (-1); } - /*------------------------------------------------------------------------- * Function: create_reg_ref_dataset * @@ -328,75 +362,109 @@ error: static herr_t create_reg_ref_dataset(hid_t file_id, hid_t loc_id) { - const char dsetnamev[] = "dataset_pointed_by_ref_dset"; - const char dsetnamer[] = "dataset_with_reg_ref"; + const char dsetnamev[] = "dataset_pointed_by_ref_dset"; + const char dsetnamer[] = "dataset_with_reg_ref"; const char dsetnamer1[] = "compact_dataset_with_reg_ref"; const char dsetnamer2[] = "compressed_dataset_with_reg_ref"; - hid_t space_id = (-1); /* dataspace identifiers */ - hid_t spacer_id = (-1); - hid_t dsetv_id = (-1); /*dataset identifiers*/ - hid_t dsetr_id = (-1); - hsize_t dims[2] = {2,9}; - hsize_t dimsr[1] = {2}; - int rank = 2; - int rankr =1; - hsize_t chunk_size=1; - H5R_ref_t ref[2]; - int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}}; - hsize_t start[2]; - hsize_t count[2]; - hsize_t coord[3][2] = {{0, 0}, {1, 6}, {0, 8}}; - size_t num_points = 3; - hid_t pid = (-1); - - if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) TEST_ERROR - if((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) TEST_ERROR - if((dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data) < 0) TEST_ERROR - if((dsetr_id = H5Dcreate2(loc_id, dsetnamer, H5T_STD_REF, spacer_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + hid_t space_id = (-1); /* dataspace identifiers */ + hid_t spacer_id = (-1); + hid_t dsetv_id = (-1); /*dataset identifiers*/ + hid_t dsetr_id = (-1); + hsize_t dims[2] = {2, 9}; + hsize_t dimsr[1] = {2}; + int rank = 2; + int rankr = 1; + hsize_t chunk_size = 1; + H5R_ref_t ref[2]; + int data[2][9] = {{1, 1, 2, 3, 3, 4, 5, 5, 6}, {1, 2, 2, 3, 4, 4, 5, 6, 6}}; + hsize_t start[2]; + hsize_t count[2]; + hsize_t coord[3][2] = {{0, 0}, {1, 6}, {0, 8}}; + size_t num_points = 3; + hid_t pid = (-1); + + if ((space_id = H5Screate_simple(rank, dims, NULL)) < 0) + TEST_ERROR + if ((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) + TEST_ERROR + if ((dsetv_id = H5Dcreate2(file_id, dsetnamev, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + TEST_ERROR + if ((dsetr_id = H5Dcreate2(loc_id, dsetnamer, H5T_STD_REF, spacer_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR start[0] = 0; start[1] = 3; count[0] = 2; count[1] = 3; - if(H5Sselect_hyperslab(space_id,H5S_SELECT_SET,start,NULL,count,NULL) < 0) TEST_ERROR - if(H5Rcreate_region(file_id, dsetnamev, space_id, H5P_DEFAULT, &ref[0]) < 0) TEST_ERROR - if(H5Sselect_none(space_id) < 0) TEST_ERROR - if(H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) TEST_ERROR - if(H5Rcreate_region(file_id, dsetnamev, space_id, H5P_DEFAULT, &ref[1]) < 0) TEST_ERROR - if(H5Dwrite(dsetr_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref) < 0) TEST_ERROR - if(H5Dclose(dsetr_id) < 0) TEST_ERROR + if (H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + TEST_ERROR + if (H5Rcreate_region(file_id, dsetnamev, space_id, H5P_DEFAULT, &ref[0]) < 0) + TEST_ERROR + if (H5Sselect_none(space_id) < 0) + TEST_ERROR + if (H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hsize_t *)coord) < 0) + TEST_ERROR + if (H5Rcreate_region(file_id, dsetnamev, space_id, H5P_DEFAULT, &ref[1]) < 0) + TEST_ERROR + if (H5Dwrite(dsetr_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) + TEST_ERROR + if (H5Dclose(dsetr_id) < 0) + TEST_ERROR /* create and set compact plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_layout(pid, H5D_COMPACT) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_layout(pid, H5D_COMPACT) < 0) + TEST_ERROR - if((dsetr_id = H5Dcreate2(loc_id, dsetnamer1, H5T_STD_REF, spacer_id, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Pclose(pid) < 0) TEST_ERROR - if(H5Dwrite(dsetr_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) TEST_ERROR - if(H5Dclose(dsetr_id) < 0) TEST_ERROR + if ((dsetr_id = H5Dcreate2(loc_id, dsetnamer1, H5T_STD_REF, spacer_id, H5P_DEFAULT, pid, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR + if (H5Dwrite(dsetr_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) + TEST_ERROR + if (H5Dclose(dsetr_id) < 0) + TEST_ERROR /* create and set comp & chunk plist */ - if((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(pid, 1, &chunk_size) < 0) TEST_ERROR - if(H5Pset_deflate(pid, 9) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if (H5Pset_chunk(pid, 1, &chunk_size) < 0) + TEST_ERROR + if (H5Pset_deflate(pid, 9) < 0) + TEST_ERROR - if((dsetr_id = H5Dcreate2(loc_id, dsetnamer2, H5T_STD_REF, spacer_id, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Pclose(pid) < 0) TEST_ERROR - if(H5Dwrite(dsetr_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref) < 0) TEST_ERROR - if(H5Dclose(dsetr_id) < 0) TEST_ERROR + if ((dsetr_id = H5Dcreate2(loc_id, dsetnamer2, H5T_STD_REF, spacer_id, H5P_DEFAULT, pid, H5P_DEFAULT)) < + 0) + TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR + if (H5Dwrite(dsetr_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref) < 0) + TEST_ERROR + if (H5Dclose(dsetr_id) < 0) + TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Sclose(spacer_id) < 0) TEST_ERROR - if(H5Dclose(dsetv_id) < 0) TEST_ERROR - if(H5Rdestroy(&ref[0]) < 0) TEST_ERROR - if(H5Rdestroy(&ref[1]) < 0) TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR + if (H5Sclose(spacer_id) < 0) + TEST_ERROR + if (H5Dclose(dsetv_id) < 0) + TEST_ERROR + if (H5Rdestroy(&ref[0]) < 0) + TEST_ERROR + if (H5Rdestroy(&ref[1]) < 0) + TEST_ERROR return 0; - error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space_id); H5Sclose(spacer_id); H5Dclose(dsetr_id); @@ -404,9 +472,10 @@ error: H5Pclose(pid); H5Rdestroy(&ref[0]); H5Rdestroy(&ref[1]); - } H5E_END_TRY; + } + H5E_END_TRY; - return(-1); + return (-1); } /*------------------------------------------------------------------------- @@ -424,22 +493,22 @@ error: static int test_copy_attach_attributes(hid_t loc_id, hid_t type_id) { - hid_t aid = -1, sid = -1; - char attr_name[ATTR_NAME_LEN]; - int attr_data[2]; - hsize_t dim1 = 2; - hid_t acpl = -1; - unsigned u; - int ret_value = -1; - - if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 ) + hid_t aid = -1, sid = -1; + char attr_name[ATTR_NAME_LEN]; + int attr_data[2]; + hsize_t dim1 = 2; + hid_t acpl = -1; + unsigned u; + int ret_value = -1; + + if ((sid = H5Screate_simple(1, &dim1, NULL)) < 0) goto done; /* Create attribute creation plist */ - if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) + if ((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) goto done; - for(u = 0; u < num_attributes_g; u++) { + for (u = 0; u < num_attributes_g; u++) { HDsprintf(attr_name, "%u attr", u); /* Set attribute data */ @@ -447,34 +516,33 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id) attr_data[1] = (int)(200 * u); /* Set attribute character set (alternate) */ - if(u % 2) { - if(H5Pset_char_encoding(acpl, H5T_CSET_ASCII) < 0) + if (u % 2) { + if (H5Pset_char_encoding(acpl, H5T_CSET_ASCII) < 0) goto done; } /* end if */ - else - if(H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0) - goto done; + else if (H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0) + goto done; - if((aid = H5Acreate2(loc_id, attr_name, type_id, sid, acpl, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(loc_id, attr_name, type_id, sid, acpl, H5P_DEFAULT)) < 0) goto done; - if(H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) + if (H5Awrite(aid, H5T_NATIVE_INT, attr_data) < 0) goto done; - if(aid > 0) + if (aid > 0) H5Aclose(aid); - aid = -1; + aid = -1; } ret_value = 0; done: - if(sid > 0) + if (sid > 0) H5Sclose(sid); - if(aid > 0) + if (aid > 0) H5Aclose(aid); - if(acpl > 0) + if (acpl > 0) H5Pclose(acpl); return ret_value; @@ -495,86 +563,110 @@ done: static int compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_owner) { - hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - size_t elmt_size; /* Size of datatype */ - htri_t is_committed; /* If the datatype is committed */ - htri_t is_committed2; /* If the datatype is committed */ - H5A_info_t ainfo; /* Attribute info */ - H5A_info_t ainfo2; /* Attribute info */ - hssize_t nelmts; /* # of elements in dataspace */ - void *rbuf = NULL; /* Buffer for reading raw data */ - void *rbuf2 = NULL; /* Buffer for reading raw data */ + hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + size_t elmt_size; /* Size of datatype */ + htri_t is_committed; /* If the datatype is committed */ + htri_t is_committed2; /* If the datatype is committed */ + H5A_info_t ainfo; /* Attribute info */ + H5A_info_t ainfo2; /* Attribute info */ + hssize_t nelmts; /* # of elements in dataspace */ + void * rbuf = NULL; /* Buffer for reading raw data */ + void * rbuf2 = NULL; /* Buffer for reading raw data */ /* Check the character sets are equal */ - if(H5Aget_info(aid, &ainfo) < 0) TEST_ERROR - if(H5Aget_info(aid2, &ainfo2) < 0) TEST_ERROR - if(ainfo.cset != ainfo2.cset) TEST_ERROR + if (H5Aget_info(aid, &ainfo) < 0) + TEST_ERROR + if (H5Aget_info(aid2, &ainfo2) < 0) + TEST_ERROR + if (ainfo.cset != ainfo2.cset) + TEST_ERROR /* Check the creation orders are equal (if appropriate) */ - if(ainfo.corder_valid != ainfo2.corder_valid) TEST_ERROR - if(ainfo.corder_valid) - if(ainfo.corder != ainfo2.corder) TEST_ERROR + if (ainfo.corder_valid != ainfo2.corder_valid) + TEST_ERROR + if (ainfo.corder_valid) + if (ainfo.corder != ainfo2.corder) + TEST_ERROR /* Check the datatypes are equal */ /* Open the datatype for the source attribute */ - if((tid = H5Aget_type(aid)) < 0) TEST_ERROR + if ((tid = H5Aget_type(aid)) < 0) + TEST_ERROR /* Open the datatype for the destination attribute */ - if((tid2 = H5Aget_type(aid2)) < 0) TEST_ERROR + if ((tid2 = H5Aget_type(aid2)) < 0) + TEST_ERROR /* Check that both datatypes are committed/not committed */ - if((is_committed = H5Tcommitted(tid)) < 0) TEST_ERROR - if((is_committed2 = H5Tcommitted(tid2)) < 0) TEST_ERROR - if(is_committed != is_committed2) TEST_ERROR + if ((is_committed = H5Tcommitted(tid)) < 0) + TEST_ERROR + if ((is_committed2 = H5Tcommitted(tid2)) < 0) + TEST_ERROR + if (is_committed != is_committed2) + TEST_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* Determine the size of datatype (for later) */ - if((elmt_size = H5Tget_size(tid)) == 0) TEST_ERROR + if ((elmt_size = H5Tget_size(tid)) == 0) + TEST_ERROR /* Check the dataspaces are equal */ /* Open the dataspace for the source attribute */ - if((sid = H5Aget_space(aid)) < 0) TEST_ERROR + if ((sid = H5Aget_space(aid)) < 0) + TEST_ERROR /* Open the dataspace for the destination attribute */ - if((sid2 = H5Aget_space(aid2)) < 0) TEST_ERROR + if ((sid2 = H5Aget_space(aid2)) < 0) + TEST_ERROR /* Compare the dataspaces */ - if(H5Sextent_equal(sid, sid2) != TRUE) TEST_ERROR + if (H5Sextent_equal(sid, sid2) != TRUE) + TEST_ERROR /* Determine the number of elements in dataspace (for later) */ - if((nelmts = H5Sget_simple_extent_npoints(sid2)) < 0) TEST_ERROR + if ((nelmts = H5Sget_simple_extent_npoints(sid2)) < 0) + TEST_ERROR /* Check the raw data is equal */ /* Allocate & initialize space for the raw data buffers */ - if((rbuf = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR - if((rbuf2 = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR + if ((rbuf = HDcalloc(elmt_size, (size_t)nelmts)) == NULL) + TEST_ERROR + if ((rbuf2 = HDcalloc(elmt_size, (size_t)nelmts)) == NULL) + TEST_ERROR /* Read data from the source attribute */ - if(H5Aread(aid, tid, rbuf) < 0) TEST_ERROR + if (H5Aread(aid, tid, rbuf) < 0) + TEST_ERROR /* Read data from the destination attribute */ - if(H5Aread(aid2, tid2, rbuf2) < 0) TEST_ERROR + if (H5Aread(aid2, tid2, rbuf2) < 0) + TEST_ERROR /* Check raw data read in against data written out */ - if(wbuf) { - if(!compare_data(aid, (hid_t)0, pid, tid, (size_t)nelmts, wbuf, rbuf, obj_owner)) TEST_ERROR - if(!compare_data(aid2, (hid_t)0, pid, tid2, (size_t)nelmts, wbuf, rbuf2, obj_owner)) TEST_ERROR + if (wbuf) { + if (!compare_data(aid, (hid_t)0, pid, tid, (size_t)nelmts, wbuf, rbuf, obj_owner)) + TEST_ERROR + if (!compare_data(aid2, (hid_t)0, pid, tid2, (size_t)nelmts, wbuf, rbuf2, obj_owner)) + TEST_ERROR } /* end if */ /* Don't have written data, just compare data between the two attributes */ - else - if(!compare_data(aid, aid2, pid, tid, (size_t)nelmts, rbuf, rbuf2, obj_owner)) TEST_ERROR + else if (!compare_data(aid, aid2, pid, tid, (size_t)nelmts, rbuf, rbuf2, obj_owner)) + TEST_ERROR /* Reclaim vlen data, if necessary */ - if(H5Tdetect_class(tid, H5T_VLEN) == TRUE || H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) - if(H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR - if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE || H5Tdetect_class(tid2, H5T_REFERENCE) == TRUE) - if(H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE || H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) + if (H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + if (H5Tdetect_class(tid2, H5T_VLEN) == TRUE || H5Tdetect_class(tid2, H5T_REFERENCE) == TRUE) + if (H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) + TEST_ERROR /* Release raw data buffers */ HDfree(rbuf); @@ -583,34 +675,39 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_ rbuf2 = NULL; /* close the source dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR /* close the destination dataspace */ - if(H5Sclose(sid2) < 0) TEST_ERROR + if (H5Sclose(sid2) < 0) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the destination datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR + if (H5Tclose(tid2) < 0) + TEST_ERROR return TRUE; error: - if(rbuf) + if (rbuf) HDfree(rbuf); - if(rbuf2) + if (rbuf2) HDfree(rbuf2); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid2); H5Sclose(sid); H5Tclose(tid2); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return FALSE; } /* end compare_attribute() */ - /*------------------------------------------------------------------------- * Function: compare_std_attributes * @@ -629,62 +726,75 @@ error: static int compare_std_attributes(hid_t oid, hid_t oid2, hid_t pid) { - hid_t aid = -1, aid2 = -1; /* Attribute IDs */ - H5O_info2_t oinfo1, oinfo2; /* Object info */ - unsigned cpy_flags; /* Object copy flags */ + hid_t aid = -1, aid2 = -1; /* Attribute IDs */ + H5O_info2_t oinfo1, oinfo2; /* Object info */ + unsigned cpy_flags; /* Object copy flags */ /* Retrieve the object copy flags from the property list, if it's non-DEFAULT */ - if(pid != H5P_DEFAULT) { - if(H5Pget_copy_object(pid, &cpy_flags) < 0) TEST_ERROR + if (pid != H5P_DEFAULT) { + if (H5Pget_copy_object(pid, &cpy_flags) < 0) + TEST_ERROR } /* end if */ else cpy_flags = 0; /* Check the number of attributes on source dataset */ - if(H5Oget_info3(oid, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) TEST_ERROR + if (H5Oget_info3(oid, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) + TEST_ERROR /* Check the number of attributes on destination dataset */ - if(H5Oget_info3(oid2, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) TEST_ERROR + if (H5Oget_info3(oid2, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) + TEST_ERROR - if(cpy_flags & H5O_COPY_WITHOUT_ATTR_FLAG) { + if (cpy_flags & H5O_COPY_WITHOUT_ATTR_FLAG) { /* Check that the destination has no attributes */ - if(oinfo2.num_attrs != 0) TEST_ERROR + if (oinfo2.num_attrs != 0) + TEST_ERROR } /* end if */ else { - char attr_name[ATTR_NAME_LEN]; /* Attribute name */ - unsigned i; /* Local index variable */ + char attr_name[ATTR_NAME_LEN]; /* Attribute name */ + unsigned i; /* Local index variable */ /* Compare the number of attributes */ - if(oinfo1.num_attrs != oinfo2.num_attrs) TEST_ERROR + if (oinfo1.num_attrs != oinfo2.num_attrs) + TEST_ERROR /* Check the attributes are equal */ - for(i = 0; i < (unsigned)oinfo1.num_attrs; i++) { - if((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Aget_name(aid, (size_t)ATTR_NAME_LEN, attr_name) < 0) TEST_ERROR + for (i = 0; i < (unsigned)oinfo1.num_attrs; i++) { + if ((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Aget_name(aid, (size_t)ATTR_NAME_LEN, attr_name) < 0) + TEST_ERROR - if((aid2 = H5Aopen(oid2, attr_name, H5P_DEFAULT)) < 0) TEST_ERROR + if ((aid2 = H5Aopen(oid2, attr_name, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check the attributes are equal */ - if(!compare_attribute(aid, aid2, pid, NULL, oid)) TEST_ERROR + if (!compare_attribute(aid, aid2, pid, NULL, oid)) + TEST_ERROR /* Close the attributes */ - if(H5Aclose(aid) < 0) TEST_ERROR - if(H5Aclose(aid2) < 0) TEST_ERROR + if (H5Aclose(aid) < 0) + TEST_ERROR + if (H5Aclose(aid2) < 0) + TEST_ERROR } /* end for */ - } /* end if */ + } /* end if */ /* Objects should be the same. :-) */ return TRUE; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid2); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; return FALSE; } /* end compare_std_attributes() */ - /*------------------------------------------------------------------------- * Function: compare_data * @@ -698,166 +808,192 @@ error: *------------------------------------------------------------------------- */ static int -compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, - const void *buf1, const void *buf2, hid_t obj_owner) +compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, const void *buf1, + const void *buf2, hid_t obj_owner) { - size_t elmt_size; /* Size of an element */ + size_t elmt_size; /* Size of an element */ /* Check size of each element */ - if((elmt_size = H5Tget_size(tid)) == 0) TEST_ERROR + if ((elmt_size = H5Tget_size(tid)) == 0) + TEST_ERROR /* If the type is a compound containing a vlen, loop over all elements for * each compound member. Compounds containing reference are not supported * yet. */ - if((H5Tget_class(tid) == H5T_COMPOUND) - && (H5Tdetect_class(tid, H5T_VLEN) == TRUE)) { - hid_t memb_id; /* Member id */ - const uint8_t *memb1; /* Pointer to current member */ - const uint8_t *memb2; /* Pointer to current member */ - int nmembs; /* Number of members */ - size_t memb_off; /* Member offset */ - size_t memb_size; /* Member size */ - unsigned memb_idx; /* Member index */ - size_t elmt; /* Current element */ + if ((H5Tget_class(tid) == H5T_COMPOUND) && (H5Tdetect_class(tid, H5T_VLEN) == TRUE)) { + hid_t memb_id; /* Member id */ + const uint8_t *memb1; /* Pointer to current member */ + const uint8_t *memb2; /* Pointer to current member */ + int nmembs; /* Number of members */ + size_t memb_off; /* Member offset */ + size_t memb_size; /* Member size */ + unsigned memb_idx; /* Member index */ + size_t elmt; /* Current element */ /* Get number of members in compound */ - if((nmembs = H5Tget_nmembers(tid)) < 0) TEST_ERROR + if ((nmembs = H5Tget_nmembers(tid)) < 0) + TEST_ERROR /* Loop over members */ - for(memb_idx=0; memb_idx<(unsigned)nmembs; memb_idx++) { + for (memb_idx = 0; memb_idx < (unsigned)nmembs; memb_idx++) { /* Get member offset. Note that we cannot check for an error here. */ memb_off = H5Tget_member_offset(tid, memb_idx); /* Get member id */ - if((memb_id = H5Tget_member_type(tid, memb_idx)) < 0) TEST_ERROR + if ((memb_id = H5Tget_member_type(tid, memb_idx)) < 0) + TEST_ERROR /* Get member size */ - if((memb_size = H5Tget_size(memb_id)) == 0) TEST_ERROR + if ((memb_size = H5Tget_size(memb_id)) == 0) + TEST_ERROR /* Set up pointers to member in the first element */ memb1 = (const uint8_t *)buf1 + memb_off; memb2 = (const uint8_t *)buf2 + memb_off; /* Check if this member contains (or is) a vlen */ - if(H5Tget_class(memb_id) == H5T_VLEN) { - hid_t base_id; /* vlen base type id */ + if (H5Tget_class(memb_id) == H5T_VLEN) { + hid_t base_id; /* vlen base type id */ /* Get base type of vlen datatype */ - if((base_id = H5Tget_super(memb_id)) < 0) TEST_ERROR + if ((base_id = H5Tget_super(memb_id)) < 0) + TEST_ERROR /* Iterate over all elements, recursively calling this function * for each */ - for(elmt=0; elmtlen - != ((const hvl_t *)((const void *)memb2))->len) + if (((const hvl_t *)((const void *)memb1))->len != + ((const hvl_t *)((const void *)memb2))->len) TEST_ERROR /* Check vlen data */ - if(!compare_data(parent1, parent2, pid, base_id, - ((const hvl_t *)((const void *)memb1))->len, - ((const hvl_t *)((const void *)memb1))->p, - ((const hvl_t *)((const void *)memb2))->p, obj_owner)) + if (!compare_data(parent1, parent2, pid, base_id, + ((const hvl_t *)((const void *)memb1))->len, + ((const hvl_t *)((const void *)memb1))->p, + ((const hvl_t *)((const void *)memb2))->p, obj_owner)) TEST_ERROR /* Update member pointers */ memb1 += elmt_size; memb2 += elmt_size; } /* end for */ - } else { + } + else { /* vlens cannot currently be nested below the top layer of a * compound */ HDassert(H5Tdetect_class(memb_id, H5T_VLEN) == FALSE); /* Iterate over all elements, calling memcmp() for each */ - for(elmt=0; elmtlen != vl_buf2->len) TEST_ERROR + if (vl_buf1->len != vl_buf2->len) + TEST_ERROR /* Check vlen data */ - if(!compare_data(parent1, parent2, pid, base_tid, vl_buf1->len, vl_buf1->p, vl_buf2->p, obj_owner)) TEST_ERROR + if (!compare_data(parent1, parent2, pid, base_tid, vl_buf1->len, vl_buf1->p, vl_buf2->p, + obj_owner)) + TEST_ERROR } /* end for */ - if(H5Tclose(base_tid) < 0) TEST_ERROR + if (H5Tclose(base_tid) < 0) + TEST_ERROR } /* end if */ - else if(H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) { - size_t u; /* Local index variable */ + else if (H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) { + size_t u; /* Local index variable */ /* Check for "simple" reference datatype */ - if(H5Tget_class(tid) != H5T_REFERENCE) TEST_ERROR + if (H5Tget_class(tid) != H5T_REFERENCE) + TEST_ERROR /* Check for object or region reference */ - if(H5Tequal(tid, H5T_STD_REF) > 0) { - H5R_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */ + if (H5Tequal(tid, H5T_STD_REF) > 0) { + H5R_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */ /* Loop over elements in buffers */ ref_buf1 = (H5R_ref_t *)buf1; ref_buf2 = (H5R_ref_t *)buf2; - for(u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) { - hid_t obj1_id, obj2_id; /* IDs for objects referenced */ + for (u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) { + hid_t obj1_id, obj2_id; /* IDs for objects referenced */ H5O_type_t obj1_type, obj2_type; /* Types of objects referenced */ /* Check for types of objects handled */ - if(H5Rget_obj_type3(ref_buf1, H5P_DEFAULT, &obj1_type) < 0) TEST_ERROR - if(H5Rget_obj_type3(ref_buf2, H5P_DEFAULT, &obj2_type) < 0) TEST_ERROR - if(obj1_type != obj2_type) TEST_ERROR + if (H5Rget_obj_type3(ref_buf1, H5P_DEFAULT, &obj1_type) < 0) + TEST_ERROR + if (H5Rget_obj_type3(ref_buf2, H5P_DEFAULT, &obj2_type) < 0) + TEST_ERROR + if (obj1_type != obj2_type) + TEST_ERROR /* Open referenced objects */ - if((obj1_id = H5Ropen_object(ref_buf1, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((obj2_id = H5Ropen_object(ref_buf2, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((obj1_id = H5Ropen_object(ref_buf1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((obj2_id = H5Ropen_object(ref_buf2, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* break the infinite loop when the ref_object points to itself */ - if(obj_owner > 0) { + if (obj_owner > 0) { H5O_info2_t oinfo1, oinfo2; - int token_cmp; - - if(H5Oget_info3(obj_owner, &oinfo1, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Oget_info3(obj1_id, &oinfo2, H5O_INFO_BASIC) < 0) TEST_ERROR - if(H5Otoken_cmp(obj1_id, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) TEST_ERROR - if(0 == token_cmp) { - if(H5Oclose(obj1_id) < 0) TEST_ERROR - if(H5Oclose(obj2_id) < 0) TEST_ERROR + int token_cmp; + + if (H5Oget_info3(obj_owner, &oinfo1, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Oget_info3(obj1_id, &oinfo2, H5O_INFO_BASIC) < 0) + TEST_ERROR + if (H5Otoken_cmp(obj1_id, &oinfo1.token, &oinfo2.token, &token_cmp) < 0) + TEST_ERROR + if (0 == token_cmp) { + if (H5Oclose(obj1_id) < 0) + TEST_ERROR + if (H5Oclose(obj2_id) < 0) + TEST_ERROR return TRUE; } } /* Check for types of objects handled */ - switch(obj1_type) { + switch (obj1_type) { case H5O_TYPE_DATASET: - if(compare_datasets(obj1_id, obj2_id, pid, NULL) != TRUE) TEST_ERROR + if (compare_datasets(obj1_id, obj2_id, pid, NULL) != TRUE) + TEST_ERROR break; case H5O_TYPE_GROUP: - if(compare_groups(obj1_id, obj2_id, pid, -1, 0) != TRUE) TEST_ERROR + if (compare_groups(obj1_id, obj2_id, pid, -1, 0) != TRUE) + TEST_ERROR break; case H5O_TYPE_NAMED_DATATYPE: - if(H5Tequal(obj1_id, obj2_id) != TRUE) TEST_ERROR + if (H5Tequal(obj1_id, obj2_id) != TRUE) + TEST_ERROR break; case H5O_TYPE_MAP: @@ -870,30 +1006,37 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, } /* end switch */ /* Close objects */ - if(H5Oclose(obj1_id) < 0) TEST_ERROR - if(H5Oclose(obj2_id) < 0) TEST_ERROR + if (H5Oclose(obj1_id) < 0) + TEST_ERROR + if (H5Oclose(obj2_id) < 0) + TEST_ERROR - if(H5Rget_type(ref_buf1) == H5R_DATASET_REGION2) { - hid_t obj1_sid, obj2_sid; /* Dataspace IDs for objects referenced */ + if (H5Rget_type(ref_buf1) == H5R_DATASET_REGION2) { + hid_t obj1_sid, obj2_sid; /* Dataspace IDs for objects referenced */ /* Get regions for referenced datasets */ - if((obj1_sid = H5Ropen_region(ref_buf1, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((obj2_sid = H5Ropen_region(ref_buf2, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((obj1_sid = H5Ropen_region(ref_buf1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((obj2_sid = H5Ropen_region(ref_buf2, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check if dataspaces are the same shape */ - if(H5Sselect_shape_same(obj1_sid, obj2_sid) < 0) TEST_ERROR + if (H5Sselect_shape_same(obj1_sid, obj2_sid) < 0) + TEST_ERROR /* Close dataspaces */ - if(H5Sclose(obj1_sid) < 0) TEST_ERROR - if(H5Sclose(obj2_sid) < 0) TEST_ERROR + if (H5Sclose(obj1_sid) < 0) + TEST_ERROR + if (H5Sclose(obj2_sid) < 0) + TEST_ERROR } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else TEST_ERROR } /* end else */ - else - if(HDmemcmp(buf1, buf2, (elmt_size * nelmts))) TEST_ERROR + else if (HDmemcmp(buf1, buf2, (elmt_size * nelmts))) + TEST_ERROR /* Data should be the same. :-) */ return TRUE; @@ -902,7 +1045,6 @@ error: return FALSE; } /* end compare_data() */ - /*------------------------------------------------------------------------- * Function: compare_datasets * @@ -918,81 +1060,98 @@ error: static int compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) { - hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ - hid_t tid = -1, tid2 = -1; /* Datatype IDs */ - hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property list IDs */ - size_t elmt_size; /* Size of datatype */ - htri_t is_committed; /* If the datatype is committed */ - htri_t is_committed2; /* If the datatype is committed */ - int nfilters; /* Number of filters applied to dataset */ - hssize_t nelmts; /* # of elements in dataspace */ - void *rbuf = NULL; /* Buffer for reading raw data */ - void *rbuf2 = NULL; /* Buffer for reading raw data */ - H5D_space_status_t space_status; /* Dataset's raw dataspace status */ - H5D_space_status_t space_status2; /* Dataset's raw dataspace status */ + hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property list IDs */ + size_t elmt_size; /* Size of datatype */ + htri_t is_committed; /* If the datatype is committed */ + htri_t is_committed2; /* If the datatype is committed */ + int nfilters; /* Number of filters applied to dataset */ + hssize_t nelmts; /* # of elements in dataspace */ + void * rbuf = NULL; /* Buffer for reading raw data */ + void * rbuf2 = NULL; /* Buffer for reading raw data */ + H5D_space_status_t space_status; /* Dataset's raw dataspace status */ + H5D_space_status_t space_status2; /* Dataset's raw dataspace status */ /* Check the datatypes are equal */ /* Open the datatype for the source dataset */ - if((tid = H5Dget_type(did)) < 0) TEST_ERROR + if ((tid = H5Dget_type(did)) < 0) + TEST_ERROR /* Open the datatype for the destination dataset */ - if((tid2 = H5Dget_type(did2)) < 0) TEST_ERROR + if ((tid2 = H5Dget_type(did2)) < 0) + TEST_ERROR /* Check that both datatypes are committed/not committed */ - if((is_committed = H5Tcommitted(tid)) < 0) TEST_ERROR - if((is_committed2 = H5Tcommitted(tid2)) < 0) TEST_ERROR - if(is_committed != is_committed2) TEST_ERROR + if ((is_committed = H5Tcommitted(tid)) < 0) + TEST_ERROR + if ((is_committed2 = H5Tcommitted(tid2)) < 0) + TEST_ERROR + if (is_committed != is_committed2) + TEST_ERROR /* Compare the datatypes */ - if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + if (H5Tequal(tid, tid2) != TRUE) + TEST_ERROR /* Determine the size of datatype (for later) */ - if((elmt_size = H5Tget_size(tid)) == 0) TEST_ERROR - + if ((elmt_size = H5Tget_size(tid)) == 0) + TEST_ERROR /* Check the dataspaces are equal */ /* Open the dataspace for the source dataset */ - if((sid = H5Dget_space(did)) < 0) TEST_ERROR + if ((sid = H5Dget_space(did)) < 0) + TEST_ERROR /* Open the dataspace for the destination dataset */ - if((sid2 = H5Dget_space(did2)) < 0) TEST_ERROR + if ((sid2 = H5Dget_space(did2)) < 0) + TEST_ERROR /* Compare the dataspaces */ - if(H5Sextent_equal(sid, sid2) != TRUE) TEST_ERROR + if (H5Sextent_equal(sid, sid2) != TRUE) + TEST_ERROR /* Determine the number of elements in dataspace (for later) */ - if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) TEST_ERROR - + if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) + TEST_ERROR /* Check the dataset creation property lists are equal */ /* Open the dataset creation property list for the source dataset */ - if((dcpl = H5Dget_create_plist(did)) < 0) TEST_ERROR + if ((dcpl = H5Dget_create_plist(did)) < 0) + TEST_ERROR /* Open the dataset creation property list for the destination dataset */ - if((dcpl2 = H5Dget_create_plist(did2)) < 0) TEST_ERROR + if ((dcpl2 = H5Dget_create_plist(did2)) < 0) + TEST_ERROR /* Compare the rest of the dataset creation property lists */ - if(H5Pequal(dcpl, dcpl2) != TRUE) TEST_ERROR + if (H5Pequal(dcpl, dcpl2) != TRUE) + TEST_ERROR /* Get the number of filters on dataset (for later) */ - if((nfilters = H5Pget_nfilters(dcpl)) < 0) TEST_ERROR + if ((nfilters = H5Pget_nfilters(dcpl)) < 0) + TEST_ERROR /* close the source dataset creation property list */ - if(H5Pclose(dcpl) < 0) TEST_ERROR + if (H5Pclose(dcpl) < 0) + TEST_ERROR /* close the destination dataset creation property list */ - if(H5Pclose(dcpl2) < 0) TEST_ERROR - + if (H5Pclose(dcpl2) < 0) + TEST_ERROR /* Check the allocated storage is the same */ /* Check that the space allocation status is the same */ - if(H5Dget_space_status(did, &space_status) < 0) TEST_ERROR - if(H5Dget_space_status(did2, &space_status2) < 0) TEST_ERROR - if(space_status != space_status2) TEST_ERROR + if (H5Dget_space_status(did, &space_status) < 0) + TEST_ERROR + if (H5Dget_space_status(did2, &space_status2) < 0) + TEST_ERROR + if (space_status != space_status2) + TEST_ERROR /* Check that the space used is the same */ /* (Don't check if the dataset is filtered (i.e. compressed, etc.) and @@ -1000,38 +1159,47 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) * data in each dataset will (probably) be different and the storage * size will thus vary) */ - if(!(nfilters > 0 && (H5Tdetect_class(tid, H5T_VLEN) || - (H5Tdetect_class(tid, H5T_REFERENCE) && H5Tequal(tid, H5T_STD_REF))))) { - hsize_t storage_size = H5Dget_storage_size(did); /* Dataset's raw data storage size */ - hsize_t storage_size2 = H5Dget_storage_size(did2); /* 2nd Dataset's raw data storage size */ + if (!(nfilters > 0 && (H5Tdetect_class(tid, H5T_VLEN) || + (H5Tdetect_class(tid, H5T_REFERENCE) && H5Tequal(tid, H5T_STD_REF))))) { + hsize_t storage_size = H5Dget_storage_size(did); /* Dataset's raw data storage size */ + hsize_t storage_size2 = H5Dget_storage_size(did2); /* 2nd Dataset's raw data storage size */ - if(storage_size != storage_size2) TEST_ERROR + if (storage_size != storage_size2) + TEST_ERROR } /* end if */ /* Check the raw data is equal */ /* Allocate & initialize space for the raw data buffers */ - if((rbuf = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR - if((rbuf2 = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR + if ((rbuf = HDcalloc(elmt_size, (size_t)nelmts)) == NULL) + TEST_ERROR + if ((rbuf2 = HDcalloc(elmt_size, (size_t)nelmts)) == NULL) + TEST_ERROR /* Read data from datasets */ - if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR - if(H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + if (H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf2) < 0) + TEST_ERROR /* Check raw data read in against data written out */ - if(wbuf) { - if(!compare_data(did, (hid_t)0, pid, tid, (size_t)nelmts, wbuf, rbuf, did)) TEST_ERROR - if(!compare_data(did2, (hid_t)0, pid, tid2, (size_t)nelmts, wbuf, rbuf2, did2)) TEST_ERROR + if (wbuf) { + if (!compare_data(did, (hid_t)0, pid, tid, (size_t)nelmts, wbuf, rbuf, did)) + TEST_ERROR + if (!compare_data(did2, (hid_t)0, pid, tid2, (size_t)nelmts, wbuf, rbuf2, did2)) + TEST_ERROR } /* end if */ /* Don't have written data, just compare data between the two datasets */ - else - if(!compare_data(did, did2, pid, tid, (size_t)nelmts, rbuf, rbuf2, did)) TEST_ERROR + else if (!compare_data(did, did2, pid, tid, (size_t)nelmts, rbuf, rbuf2, did)) + TEST_ERROR /* Reclaim vlen data, if necessary */ - if(H5Tdetect_class(tid, H5T_VLEN) == TRUE || H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) - if(H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR - if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE || H5Tdetect_class(tid2, H5T_REFERENCE) == TRUE) - if(H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE || H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) + if (H5Treclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + if (H5Tdetect_class(tid2, H5T_VLEN) == TRUE || H5Tdetect_class(tid2, H5T_REFERENCE) == TRUE) + if (H5Treclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) + TEST_ERROR /* Release raw data buffers */ HDfree(rbuf); @@ -1040,30 +1208,34 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) rbuf2 = NULL; /* close the source dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR /* close the destination dataspace */ - if(H5Sclose(sid2) < 0) TEST_ERROR + if (H5Sclose(sid2) < 0) + TEST_ERROR /* close the source datatype */ - if(H5Tclose(tid) < 0) TEST_ERROR + if (H5Tclose(tid) < 0) + TEST_ERROR /* close the destination datatype */ - if(H5Tclose(tid2) < 0) TEST_ERROR - + if (H5Tclose(tid2) < 0) + TEST_ERROR /* Check if the attributes are equal */ - if(compare_std_attributes(did, did2, pid) != TRUE) TEST_ERROR - + if (compare_std_attributes(did, did2, pid) != TRUE) + TEST_ERROR /* Datasets should be the same. :-) */ return TRUE; error: - H5E_BEGIN_TRY { - if(rbuf) + H5E_BEGIN_TRY + { + if (rbuf) HDfree(rbuf); - if(rbuf2) + if (rbuf2) HDfree(rbuf2); H5Pclose(dcpl2); H5Pclose(dcpl); @@ -1071,11 +1243,11 @@ error: H5Sclose(sid); H5Tclose(tid2); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return FALSE; } /* end compare_datasets() */ - /*------------------------------------------------------------------------- * Function: compare_groups * @@ -1091,103 +1263,126 @@ error: static int compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) { - H5G_info_t ginfo; /* Group info struct */ - H5G_info_t ginfo2; /* Group info struct */ - hsize_t idx; /* Index over the objects in group */ - unsigned cpy_flags; /* Object copy flags */ + H5G_info_t ginfo; /* Group info struct */ + H5G_info_t ginfo2; /* Group info struct */ + hsize_t idx; /* Index over the objects in group */ + unsigned cpy_flags; /* Object copy flags */ /* Retrieve the object copy flags from the property list, if it's non-DEFAULT */ - if(pid != H5P_DEFAULT) { - if(H5Pget_copy_object(pid, &cpy_flags) < 0) TEST_ERROR + if (pid != H5P_DEFAULT) { + if (H5Pget_copy_object(pid, &cpy_flags) < 0) + TEST_ERROR } /* end if */ else cpy_flags = 0; /* Check if both groups have the same # of objects */ - if(H5Gget_info(gid, &ginfo) < 0) TEST_ERROR - if(H5Gget_info(gid2, &ginfo2) < 0) TEST_ERROR - if((cpy_flags & H5O_COPY_SHALLOW_HIERARCHY_FLAG) && depth == 0) { - if(ginfo2.nlinks != 0) TEST_ERROR + if (H5Gget_info(gid, &ginfo) < 0) + TEST_ERROR + if (H5Gget_info(gid2, &ginfo2) < 0) + TEST_ERROR + if ((cpy_flags & H5O_COPY_SHALLOW_HIERARCHY_FLAG) && depth == 0) { + if (ginfo2.nlinks != 0) + TEST_ERROR } /* end if */ else { - if(ginfo.nlinks != ginfo2.nlinks) TEST_ERROR + if (ginfo.nlinks != ginfo2.nlinks) + TEST_ERROR } /* end if */ /* Check contents of groups */ - if(ginfo2.nlinks > 0) { - char objname[NAME_BUF_SIZE]; /* Name of object in group */ - char objname2[NAME_BUF_SIZE]; /* Name of object in group */ - H5L_info2_t linfo; /* Link information */ - H5L_info2_t linfo2; /* Link information */ + if (ginfo2.nlinks > 0) { + char objname[NAME_BUF_SIZE]; /* Name of object in group */ + char objname2[NAME_BUF_SIZE]; /* Name of object in group */ + H5L_info2_t linfo; /* Link information */ + H5L_info2_t linfo2; /* Link information */ /* Loop over contents of groups */ - for(idx = 0; idx < ginfo.nlinks; idx++) { + for (idx = 0; idx < ginfo.nlinks; idx++) { /* Check name of objects */ - if(H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_name_by_idx(gid2, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(objname, objname2)) TEST_ERROR + if (H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname, (size_t)NAME_BUF_SIZE, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_name_by_idx(gid2, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname2, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(objname, objname2)) + TEST_ERROR /* Get link info */ - if(H5Lget_info2(gid, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_info2(gid2, objname2, &linfo2, H5P_DEFAULT) < 0) TEST_ERROR - if(linfo.type != linfo2.type) TEST_ERROR + if (H5Lget_info2(gid, objname, &linfo, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_info2(gid2, objname2, &linfo2, H5P_DEFAULT) < 0) + TEST_ERROR + if (linfo.type != linfo2.type) + TEST_ERROR /* Extra checks for "real" objects */ - if(linfo.type == H5L_TYPE_HARD) { - hid_t oid, oid2; /* IDs of objects within group */ - H5O_info2_t oinfo, oinfo2; /* Data model object info */ - H5O_native_info_t ninfo, ninfo2; /* Native file format object info */ + if (linfo.type == H5L_TYPE_HARD) { + hid_t oid, oid2; /* IDs of objects within group */ + H5O_info2_t oinfo, oinfo2; /* Data model object info */ + H5O_native_info_t ninfo, ninfo2; /* Native file format object info */ /* Compare some pieces of the object info */ /* Get data model object info */ - if(H5Oget_info_by_name3(gid, objname, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_info_by_name3(gid2, objname2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_info_by_name3(gid, objname, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_info_by_name3(gid2, objname2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + TEST_ERROR /* Get native object info */ - if(H5Oget_native_info_by_name(gid, objname, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Oget_native_info_by_name(gid2, objname2, &ninfo2, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Oget_native_info_by_name(gid, objname, &ninfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Oget_native_info_by_name(gid2, objname2, &ninfo2, H5O_NATIVE_INFO_HDR, H5P_DEFAULT) < 0) + TEST_ERROR - if(oinfo.type != oinfo2.type) TEST_ERROR - if(oinfo.rc != oinfo2.rc) TEST_ERROR + if (oinfo.type != oinfo2.type) + TEST_ERROR + if (oinfo.rc != oinfo2.rc) + TEST_ERROR /* If NULL messages are preserved, the number of messages * should be the same in the destination. * Otherwise, it should simply be true that the number * of messages hasn't increased. */ - if(H5O_COPY_PRESERVE_NULL_FLAG & copy_flags) { - if(ninfo.hdr.nmesgs != ninfo2.hdr.nmesgs) + if (H5O_COPY_PRESERVE_NULL_FLAG & copy_flags) { + if (ninfo.hdr.nmesgs != ninfo2.hdr.nmesgs) ; - else - if(ninfo.hdr.nmesgs < ninfo2.hdr.nmesgs) - TEST_ERROR - } + else if (ninfo.hdr.nmesgs < ninfo2.hdr.nmesgs) + TEST_ERROR + } /* Check for object already having been compared */ - if(token_lookup(gid, &oinfo)) + if (token_lookup(gid, &oinfo)) continue; else token_insert(&oinfo); /* Open objects */ - if((oid = H5Oopen(gid, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((oid2 = H5Oopen(gid2, objname2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((oid = H5Oopen(gid, objname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((oid2 = H5Oopen(gid2, objname2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Compare objects within group */ - switch(oinfo.type) { + switch (oinfo.type) { case H5O_TYPE_GROUP: /* Compare groups */ - if(compare_groups(oid, oid2, pid, depth - 1, copy_flags) != TRUE) TEST_ERROR + if (compare_groups(oid, oid2, pid, depth - 1, copy_flags) != TRUE) + TEST_ERROR break; case H5O_TYPE_DATASET: /* Compare datasets */ - if(compare_datasets(oid, oid2, pid, NULL) != TRUE) TEST_ERROR + if (compare_datasets(oid, oid2, pid, NULL) != TRUE) + TEST_ERROR break; case H5O_TYPE_NAMED_DATATYPE: /* Compare datatypes */ - if(H5Tequal(oid, oid2) != TRUE) TEST_ERROR + if (H5Tequal(oid, oid2) != TRUE) + TEST_ERROR break; case H5O_TYPE_MAP: @@ -1201,43 +1396,52 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) } /* end switch */ /* Close objects */ - if(H5Oclose(oid) < 0) TEST_ERROR - if(H5Oclose(oid2) < 0) TEST_ERROR + if (H5Oclose(oid) < 0) + TEST_ERROR + if (H5Oclose(oid2) < 0) + TEST_ERROR } /* end if */ else { /* Check that both links are the same size */ - if(linfo.u.val_size != linfo2.u.val_size) TEST_ERROR + if (linfo.u.val_size != linfo2.u.val_size) + TEST_ERROR /* Compare link values */ - if(linfo.type == H5L_TYPE_SOFT || - (linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX)) { - char linkval[NAME_BUF_SIZE]; /* Link value */ - char linkval2[NAME_BUF_SIZE]; /* Link value */ + if (linfo.type == H5L_TYPE_SOFT || + (linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX)) { + char linkval[NAME_BUF_SIZE]; /* Link value */ + char linkval2[NAME_BUF_SIZE]; /* Link value */ /* Get link values */ HDassert(linfo.u.val_size <= NAME_BUF_SIZE); - if(H5Lget_val(gid, objname, linkval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Lget_val(gid, objname, linkval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) + TEST_ERROR /* Compare link data */ - if(HDmemcmp(linkval, linkval2, linfo.u.val_size)) TEST_ERROR + if (HDmemcmp(linkval, linkval2, linfo.u.val_size)) + TEST_ERROR } /* end else-if */ else { -HDassert(0 && "Unknown type of link"); + HDassert(0 && "Unknown type of link"); } /* end else */ - } /* end else */ - } /* end for */ - } /* end if */ + } /* end else */ + } /* end for */ + } /* end if */ /* Check if the attributes are equal */ - if(compare_std_attributes(gid, gid2, pid) != TRUE) TEST_ERROR + if (compare_std_attributes(gid, gid2, pid) != TRUE) + TEST_ERROR /* Groups should be the same. :-) */ return TRUE; error: - H5E_BEGIN_TRY { - } H5E_END_TRY; + H5E_BEGIN_TRY + { + } + H5E_END_TRY; return FALSE; } /* end compare_groups() */ @@ -1255,29 +1459,29 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, - unsigned flag, hbool_t crt_intermediate_grp, const char* test_desciption) +test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, unsigned flag, + hbool_t crt_intermediate_grp, const char *test_desciption) { - hid_t fid_src = -1, fid_dst = -1, fid_ext = -1; /* File IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t gid=-1, gid2=-1, gid_ref=-1; /* Group IDs */ - hid_t gid_sub=-1, gid_sub_sub=-1; /* Sub-group ID */ - hid_t pid=-1, lcpl_id=-1; /* Property IDs */ - unsigned cpy_flags; /* Object copy flags */ - int depth = -1; /* Copy depth */ - hsize_t dim2d[2]; - int buf[DIM_SIZE_1][DIM_SIZE_2]; - int i, j; - char src_filename[NAME_BUF_SIZE]; - char dst_filename[NAME_BUF_SIZE]; + hid_t fid_src = -1, fid_dst = -1, fid_ext = -1; /* File IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t gid = -1, gid2 = -1, gid_ref = -1; /* Group IDs */ + hid_t gid_sub = -1, gid_sub_sub = -1; /* Sub-group ID */ + hid_t pid = -1, lcpl_id = -1; /* Property IDs */ + unsigned cpy_flags; /* Object copy flags */ + int depth = -1; /* Copy depth */ + hsize_t dim2d[2]; + int buf[DIM_SIZE_1][DIM_SIZE_2]; + int i, j; + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; TESTING(test_desciption); /* set initial data values */ - for (i=0; i 0) { + if ((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) { /* Create group to copy */ - if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft(NAME_DATASET_SUB_SUB, fid_src, NAME_LINK_SOFT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("nowhere", fid_src, NAME_LINK_SOFT_DANGLE, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft(NAME_DATASET_SUB_SUB, fid_src, NAME_LINK_SOFT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("nowhere", fid_src, NAME_LINK_SOFT_DANGLE, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Create group to compare with */ - if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lcreate_hard(fid_src, NAME_DATASET_SUB_SUB, H5L_SAME_LOC, NAME_LINK_SOFT2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("nowhere", fid_src, NAME_LINK_SOFT_DANGLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_hard(fid_src, NAME_DATASET_SUB_SUB, H5L_SAME_LOC, NAME_LINK_SOFT2, H5P_DEFAULT, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("nowhere", fid_src, NAME_LINK_SOFT_DANGLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR } /* end if */ - if((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) { - char ext_filename[NAME_BUF_SIZE]; + if ((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) { + char ext_filename[NAME_BUF_SIZE]; h5_fixname(FILENAME[2], src_fapl, ext_filename, sizeof ext_filename); /* Create the external file and dataset */ - if((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR - if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid_ext, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid_ext) < 0) TEST_ERROR + if ((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR + if ((sid = H5Screate_simple(2, dim2d, NULL)) < 0) + TEST_ERROR + if ((did = H5Dcreate2(fid_ext, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + if (H5Fclose(fid_ext) < 0) + TEST_ERROR /* Create group to copy */ - if(!(flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG)) { - if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (!(flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG)) { + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR } /* end if */ - else - if((gid = H5Gopen2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Lcreate_external(ext_filename, NAME_DATASET_SIMPLE, fid_src, NAME_LINK_EXTERN, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lcreate_external("no_file", "no_object", fid_src, NAME_LINK_EXTERN_DANGLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + else if ((gid = H5Gopen2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Lcreate_external(ext_filename, NAME_DATASET_SIMPLE, fid_src, NAME_LINK_EXTERN, H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Lcreate_external("no_file", "no_object", fid_src, NAME_LINK_EXTERN_DANGLE, H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Create group to compare with */ - if(!(flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG)) { - if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (!(flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG)) { + if ((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR } /* end if */ - else - if((gid = H5Gopen2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid_src, NAME_LINK_EXTERN2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR - if(H5Lcreate_external("no_file", "no_object", fid_src, NAME_LINK_EXTERN_DANGLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Dclose(did) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + else if ((gid = H5Gopen2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((did = H5Dcreate2(fid_src, NAME_LINK_EXTERN2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR + if (H5Lcreate_external("no_file", "no_object", fid_src, NAME_LINK_EXTERN_DANGLE2, H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close dataspace */ - if(H5Sclose(sid) < 0) TEST_ERROR + if (H5Sclose(sid) < 0) + TEST_ERROR } /* end if */ - if((flag & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) { - if((gid_ref = H5Gcreate2(fid_src, NAME_GROUP_REF, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((flag & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) { + if ((gid_ref = H5Gcreate2(fid_src, NAME_GROUP_REF, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create an attribute of new object references */ - if(attach_ref_attr(fid_src, gid_ref) < 0) TEST_ERROR + if (attach_ref_attr(fid_src, gid_ref) < 0) + TEST_ERROR /* create an attribute of region references */ - if(attach_reg_ref_attr(fid_src, gid_ref) < 0) TEST_ERROR + if (attach_reg_ref_attr(fid_src, gid_ref) < 0) + TEST_ERROR /* create a dataset of region references */ - if(create_reg_ref_dataset(fid_src, gid_ref) < 0) TEST_ERROR + if (create_reg_ref_dataset(fid_src, gid_ref) < 0) + TEST_ERROR /* Close group holding reference objects */ - if(H5Gclose(gid_ref) < 0) TEST_ERROR + if (H5Gclose(gid_ref) < 0) + TEST_ERROR } /* end if */ /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* open the source file with read-only */ /* (except when expanding soft links */ - if((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) { - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) TEST_ERROR + if ((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) { + if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) + TEST_ERROR } /* end if */ - else - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + else if ((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) + TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + if ((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR /* Create an uncopied object in destination file so that tokens in source and destination files aren't the same */ - if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* create property to pass copy options */ - if((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) TEST_ERROR + if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + TEST_ERROR /* set options for object copy */ - if(H5Pset_copy_object(pid, flag) < 0) TEST_ERROR + if (H5Pset_copy_object(pid, flag) < 0) + TEST_ERROR /* Verify object copy flags */ - if(H5Pget_copy_object(pid, &cpy_flags) < 0) TEST_ERROR - if(cpy_flags != flag) TEST_ERROR + if (H5Pget_copy_object(pid, &cpy_flags) < 0) + TEST_ERROR + if (cpy_flags != flag) + TEST_ERROR /* copy the group from SRC to DST */ - if(crt_intermediate_grp) { + if (crt_intermediate_grp) { /* Create link creation plist to pass in intermediate group creation */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) + TEST_ERROR - if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, "/new_g0/new_g00", pid, lcpl_id) < 0) TEST_ERROR + if (H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, "/new_g0/new_g00", pid, lcpl_id) < 0) + TEST_ERROR - if(H5Pclose(lcpl_id) < 0) TEST_ERROR + if (H5Pclose(lcpl_id) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, "/new_g0/new_g00", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - - } else if(((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) - || ((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0)) { - if(H5Ocopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, pid, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid_dst, "/new_g0/new_g00", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + } + else if (((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) || ((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0)) { + if (H5Ocopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, pid, H5P_DEFAULT) < 0) + TEST_ERROR - if((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) + if ((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) /* Unlink dataset to copy from original location */ /* (So group comparison works properly) */ - if(H5Ldelete(fid_src, NAME_DATASET_SUB_SUB, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid_src, NAME_DATASET_SUB_SUB, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_LINK2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_LINK, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - - } else if(flag & (H5O_COPY_WITHOUT_ATTR_FLAG | H5O_COPY_PRESERVE_NULL_FLAG)) { - if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_LINK, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + } + else if (flag & (H5O_COPY_WITHOUT_ATTR_FLAG | H5O_COPY_PRESERVE_NULL_FLAG)) { + if (H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - } else if(flag & H5O_COPY_SHALLOW_HIERARCHY_FLAG) { - if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + } + else if (flag & H5O_COPY_SHALLOW_HIERARCHY_FLAG) { + if (H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Set the copy depth */ depth = 1; - } else if((flag & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) { - if(H5Ocopy(fid_src, NAME_GROUP_REF, fid_dst, NAME_GROUP_REF, pid, H5P_DEFAULT) < 0) TEST_ERROR + } + else if ((flag & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) { + if (H5Ocopy(fid_src, NAME_GROUP_REF, fid_dst, NAME_GROUP_REF, pid, H5P_DEFAULT) < 0) + TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_REF, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid_src, NAME_GROUP_REF, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_REF, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - } else { + if ((gid2 = H5Gopen2(fid_dst, NAME_GROUP_REF, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + } + else { /* Unknown flag */ TEST_ERROR } /* end else */ /* Check if the groups are equal */ - if(compare_groups(gid, gid2, pid, depth, flag) != TRUE) TEST_ERROR - if(H5Gclose(gid2) < 0) TEST_ERROR - if(H5Gclose(gid) < 0) TEST_ERROR + if (compare_groups(gid, gid2, pid, depth, flag) != TRUE) + TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* close the SRC file */ - if(H5Fclose(fid_src) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) + TEST_ERROR /* close the DST file */ - if(H5Fclose(fid_dst) < 0) TEST_ERROR + if (H5Fclose(fid_dst) < 0) + TEST_ERROR /* close properties */ - if(H5Pclose(pid) < 0) TEST_ERROR + if (H5Pclose(pid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(lcpl_id); H5Pclose(pid); H5Sclose(sid); @@ -1525,7 +1823,8 @@ error: H5Fclose(fid_dst); H5Fclose(fid_src); H5Fclose(fid_ext); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_copy_option */ @@ -1548,12 +1847,12 @@ error: int main(void) { - int nerrors = 0; + int nerrors = 0; hid_t fapl, fapl2; - hid_t fcpl_shared, ocpl; - unsigned max_compact, min_dense; - int configuration; /* Configuration of tests. */ - int ExpressMode; + hid_t fcpl_shared, ocpl; + unsigned max_compact, min_dense; + int configuration; /* Configuration of tests. */ + int ExpressMode; /* Setup */ h5_reset(); @@ -1564,39 +1863,47 @@ main(void) HDprintf("***Express test mode on. Some tests may be skipped\n"); /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR /* Create an FCPL with sharing enabled */ - if((fcpl_shared = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR - if(H5Pset_shared_mesg_nindexes(fcpl_shared, 1) < 0) TEST_ERROR - if(H5Pset_shared_mesg_index(fcpl_shared, 0, H5O_SHMESG_ALL_FLAG, 10) < 0) TEST_ERROR + if ((fcpl_shared = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + if (H5Pset_shared_mesg_nindexes(fcpl_shared, 1) < 0) + TEST_ERROR + if (H5Pset_shared_mesg_index(fcpl_shared, 0, H5O_SHMESG_ALL_FLAG, 10) < 0) + TEST_ERROR /* Obtain the default attribute storage phase change values */ - if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) TEST_ERROR - if(H5Pget_attr_phase_change(ocpl, &max_compact, &min_dense) < 0) TEST_ERROR - if(H5Pclose(ocpl) < 0) TEST_ERROR + if ((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) + TEST_ERROR + if (H5Pget_attr_phase_change(ocpl, &max_compact, &min_dense) < 0) + TEST_ERROR + if (H5Pclose(ocpl) < 0) + TEST_ERROR /* Test in all configurations */ - for(configuration = 0; configuration <= MAX_CONFIGURATION; configuration++) { + for (configuration = 0; configuration <= MAX_CONFIGURATION; configuration++) { hid_t src_fapl; hid_t dst_fapl; hid_t fcpl_src; hid_t fcpl_dst; /* No need to test dense attributes with old format */ - if(!(configuration & CONFIG_SRC_NEW_FORMAT) && (configuration & CONFIG_DENSE)) + if (!(configuration & CONFIG_SRC_NEW_FORMAT) && (configuration & CONFIG_DENSE)) continue; /* TODO Region references currently do not support copy from new format to old format * (this may be fixed once H5Sencode/decode and H5CXis fixed) */ - if((configuration & CONFIG_SRC_NEW_FORMAT) && !(configuration & CONFIG_DST_NEW_FORMAT)) + if ((configuration & CONFIG_SRC_NEW_FORMAT) && !(configuration & CONFIG_DST_NEW_FORMAT)) continue; /* Test with and without shared messages */ - if(configuration & CONFIG_SHARE_SRC) { + if (configuration & CONFIG_SHARE_SRC) { HDputs("\nTesting with shared src messages:"); fcpl_src = fcpl_shared; } @@ -1604,7 +1911,7 @@ main(void) HDputs("\nTesting without shared src messages:"); fcpl_src = H5P_DEFAULT; } - if(configuration & CONFIG_SHARE_DST) { + if (configuration & CONFIG_SHARE_DST) { HDputs("Testing with shared dst messages:"); fcpl_dst = fcpl_shared; } @@ -1614,12 +1921,12 @@ main(void) } /* Set the FAPL for the source file's type of format */ - if(configuration & CONFIG_SRC_NEW_FORMAT) { + if (configuration & CONFIG_SRC_NEW_FORMAT) { HDputs("Testing with latest format for source file:"); src_fapl = fapl2; /* Test with and without dense attributes */ - if(configuration & CONFIG_DENSE) { + if (configuration & CONFIG_DENSE) { HDputs("Testing with dense attributes:"); num_attributes_g = max_compact + 1; } @@ -1630,12 +1937,12 @@ main(void) } /* end if */ else { HDputs("Testing with oldest file format for source file:"); - src_fapl = fapl; + src_fapl = fapl; num_attributes_g = 4; } /* end else */ /* Set the FAPL for the destination file's type of format */ - if(configuration & CONFIG_DST_NEW_FORMAT) { + if (configuration & CONFIG_DST_NEW_FORMAT) { HDputs("Testing with latest format for destination file:"); dst_fapl = fapl2; } /* end if */ @@ -1645,9 +1952,8 @@ main(void) } /* end else */ /* The tests... */ - nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, - H5O_COPY_EXPAND_REFERENCE_FLAG, - FALSE, "H5Ocopy(): expand object reference"); + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, H5O_COPY_EXPAND_REFERENCE_FLAG, + FALSE, "H5Ocopy(): expand object reference"); } /* end for */ /* Reset file token checking info */ @@ -1657,13 +1963,12 @@ main(void) nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); /* Results */ - if(nerrors) { - HDprintf("***** %d OBJECT COPY TEST%s FAILED! *****\n", - nerrors, (1 == nerrors ? "" : "S")); + if (nerrors) { + HDprintf("***** %d OBJECT COPY TEST%s FAILED! *****\n", nerrors, (1 == nerrors ? "" : "S")); HDexit(EXIT_FAILURE); } /* end if */ - HDputs ("All object copying tests passed."); + HDputs("All object copying tests passed."); /* close property list. * NOTE: if this property list is not closed and the test is @@ -1695,4 +2000,3 @@ main(void) error: HDexit(EXIT_FAILURE); } /* main */ - diff --git a/test/ohdr.c b/test/ohdr.c index ad76576..0757e26 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -16,30 +16,25 @@ */ #include "h5test.h" -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Iprivate.h" /* Identifiers */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Iprivate.h" /* Identifiers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* * This file needs to access private datatypes from the H5O package. * This file also needs to access the object header testing code. */ -#define H5O_FRIEND /* suppress error about including H5Opkg */ +#define H5O_FRIEND /* suppress error about including H5Opkg */ #define H5O_TESTING #include "H5Opkg.h" /* * This file needs to access private datatypes from the H5G package. */ -#define H5G_FRIEND /* suppress error about including H5Gpkg */ +#define H5G_FRIEND /* suppress error about including H5Gpkg */ #include "H5Gpkg.h" -const char *FILENAME[] = { - "ohdr", - "ohdr_min_a", - "ohdr_min_b", - NULL -}; +const char *FILENAME[] = {"ohdr", "ohdr_min_a", "ohdr_min_b", NULL}; /* used for object header size comparison */ #define EQ 1 @@ -50,12 +45,12 @@ const char *FILENAME[] = { * To get this data file, define H5O_ENABLE_BOGUS in src/H5Oprivate, rebuild * the library and simply compile gen_bogus.c with that HDF5 library and run it. */ -#define FILE_BOGUS "tbogus.h5" -#define TESTFILE_LEN 256 +#define FILE_BOGUS "tbogus.h5" +#define TESTFILE_LEN 256 /* */ -#define FILE_OHDR_SWMR "ohdr_swmr.h5" -#define DSET_NAME "COMPACT_DSET" +#define FILE_OHDR_SWMR "ohdr_swmr.h5" +#define DSET_NAME "COMPACT_DSET" #define OBJ_VERSION_LATEST 2 /* @@ -70,14 +65,14 @@ const char *FILENAME[] = { static herr_t test_cont(char *filename, hid_t fapl) { - hid_t file=-1; - H5F_t *f = NULL; + hid_t file = -1; + H5F_t * f = NULL; H5O_hdr_info_t hdr_info; - H5O_loc_t oh_locA, oh_locB; - time_t time_new; - const char *short_name = "T"; - const char *long_name = "This is the message"; - size_t nchunks; + H5O_loc_t oh_locA, oh_locB; + time_t time_new; + const char * short_name = "T"; + const char * long_name = "This is the message"; + size_t nchunks; TESTING("object header continuation block"); @@ -85,9 +80,9 @@ test_cont(char *filename, hid_t fapl) HDmemset(&oh_locB, 0, sizeof(oh_locB)); /* Create the file to operate on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR if (H5AC_ignore_tags(f) < 0) { H5_FAILED(); @@ -95,61 +90,61 @@ test_cont(char *filename, hid_t fapl) goto error; } /* end if */ - if(H5O_create(f, (size_t)H5O_MIN_SIZE, (size_t)0, H5P_GROUP_CREATE_DEFAULT, &oh_locA/*out*/) < 0) - FAIL_STACK_ERROR + if (H5O_create(f, (size_t)H5O_MIN_SIZE, (size_t)0, H5P_GROUP_CREATE_DEFAULT, &oh_locA /*out*/) < 0) + FAIL_STACK_ERROR - if(H5O_create(f, (size_t)H5O_MIN_SIZE, (size_t)0, H5P_GROUP_CREATE_DEFAULT, &oh_locB/*out*/) < 0) - FAIL_STACK_ERROR + if (H5O_create(f, (size_t)H5O_MIN_SIZE, (size_t)0, H5P_GROUP_CREATE_DEFAULT, &oh_locB /*out*/) < 0) + FAIL_STACK_ERROR time_new = 11111111; - if(H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &long_name) < 0) + if (H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &long_name) < 0) FAIL_STACK_ERROR - if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new) < 0) + if (H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new) < 0) FAIL_STACK_ERROR - if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new) < 0) + if (H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new) < 0) FAIL_STACK_ERROR - if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new) < 0) + if (H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new) < 0) FAIL_STACK_ERROR - if(H5O_msg_create(&oh_locA, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) + if (H5O_msg_create(&oh_locA, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) FAIL_STACK_ERROR - if(H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new) < 0) + if (H5O_msg_create(&oh_locB, H5O_MTIME_ID, 0, 0, &time_new) < 0) FAIL_STACK_ERROR - if(H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &short_name) < 0) + if (H5O_msg_create(&oh_locA, H5O_NAME_ID, 0, 0, &short_name) < 0) FAIL_STACK_ERROR - if(1 != H5O_link(&oh_locA, 1)) + if (1 != H5O_link(&oh_locA, 1)) FAIL_STACK_ERROR - if(1 != H5O_link(&oh_locB, 1)) + if (1 != H5O_link(&oh_locB, 1)) FAIL_STACK_ERROR - if(H5AC_flush(f) < 0) + if (H5AC_flush(f) < 0) FAIL_STACK_ERROR - if(H5O__expunge_chunks_test(&oh_locA) < 0) + if (H5O__expunge_chunks_test(&oh_locA) < 0) FAIL_STACK_ERROR - if(H5O_get_hdr_info(&oh_locA, &hdr_info) < 0) + if (H5O_get_hdr_info(&oh_locA, &hdr_info) < 0) FAIL_STACK_ERROR nchunks = hdr_info.nchunks; /* remove the 1st H5O_NAME_ID message */ - if(H5O_msg_remove(&oh_locA, H5O_NAME_ID, 0, FALSE) < 0) + if (H5O_msg_remove(&oh_locA, H5O_NAME_ID, 0, FALSE) < 0) FAIL_STACK_ERROR - if(H5O_get_hdr_info(&oh_locA, &hdr_info) < 0) + if (H5O_get_hdr_info(&oh_locA, &hdr_info) < 0) FAIL_STACK_ERROR - if(hdr_info.nchunks >= nchunks) + if (hdr_info.nchunks >= nchunks) TEST_ERROR - if(H5O_close(&oh_locA, NULL) < 0) + if (H5O_close(&oh_locA, NULL) < 0) FAIL_STACK_ERROR - if(H5O_close(&oh_locB, NULL) < 0) + if (H5O_close(&oh_locB, NULL) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -157,11 +152,13 @@ test_cont(char *filename, hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5O_close(&oh_locA, NULL); H5O_close(&oh_locB, NULL); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_cont() */ @@ -177,90 +174,90 @@ error: static herr_t test_ohdr_cache(char *filename, hid_t fapl) { - hid_t file = -1; /* File ID */ - hid_t my_fapl; /* FAPL ID */ - H5AC_cache_config_t mdc_config; /* Metadata cache configuration info */ - H5F_t *f = NULL; /* File handle */ - H5HL_t *lheap, *lheap2, *lheap3; /* Pointer to local heaps */ - haddr_t lheap_addr, lheap_addr2, lheap_addr3; /* Local heap addresses */ - H5O_loc_t oh_loc; /* Object header location */ - time_t time_new; /* Time value for modification time message */ - unsigned rc; /* Refcount for object */ + hid_t file = -1; /* File ID */ + hid_t my_fapl; /* FAPL ID */ + H5AC_cache_config_t mdc_config; /* Metadata cache configuration info */ + H5F_t * f = NULL; /* File handle */ + H5HL_t * lheap, *lheap2, *lheap3; /* Pointer to local heaps */ + haddr_t lheap_addr, lheap_addr2, lheap_addr3; /* Local heap addresses */ + H5O_loc_t oh_loc; /* Object header location */ + time_t time_new; /* Time value for modification time message */ + unsigned rc; /* Refcount for object */ TESTING("object header creation in cache"); /* Make a copy of the FAPL */ - if((my_fapl = H5Pcopy(fapl)) < 0) + if ((my_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR /* Tweak down the size of the metadata cache to only 64K */ mdc_config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if(H5Pget_mdc_config(my_fapl, &mdc_config) < 0) + if (H5Pget_mdc_config(my_fapl, &mdc_config) < 0) FAIL_STACK_ERROR mdc_config.set_initial_size = TRUE; - mdc_config.initial_size = 32 * 1024; - mdc_config.max_size = 64 * 1024; - mdc_config.min_size = 8 * 1024; - if(H5Pset_mdc_config(my_fapl, &mdc_config) < 0) + mdc_config.initial_size = 32 * 1024; + mdc_config.max_size = 64 * 1024; + mdc_config.min_size = 8 * 1024; + if (H5Pset_mdc_config(my_fapl, &mdc_config) < 0) FAIL_STACK_ERROR /* Create the file to operate on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) FAIL_STACK_ERROR - if(H5Pclose(my_fapl) < 0) + if (H5Pclose(my_fapl) < 0) FAIL_STACK_ERROR - if(NULL == (f = (H5F_t *)H5VL_object(file))) + if (NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR - if(H5AC_ignore_tags(f) < 0) + if (H5AC_ignore_tags(f) < 0) FAIL_STACK_ERROR /* Create object (local heap) that occupies most of cache */ - if(H5HL_create(f, (31 * 1024), &lheap_addr) < 0) + if (H5HL_create(f, (31 * 1024), &lheap_addr) < 0) FAIL_STACK_ERROR /* Protect local heap (which actually pins it in the cache) */ - if(NULL == (lheap = H5HL_protect(f, lheap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (lheap = H5HL_protect(f, lheap_addr, H5AC__READ_ONLY_FLAG))) FAIL_STACK_ERROR /* Create an object header */ HDmemset(&oh_loc, 0, sizeof(oh_loc)); - if(H5O_create(f, (size_t)2048, (size_t)1, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/) < 0) + if (H5O_create(f, (size_t)2048, (size_t)1, H5P_GROUP_CREATE_DEFAULT, &oh_loc /*out*/) < 0) FAIL_STACK_ERROR /* Query object header information */ rc = 0; - if(H5O__get_rc_test(&oh_loc, &rc) < 0) + if (H5O__get_rc_test(&oh_loc, &rc) < 0) FAIL_STACK_ERROR - if(0 != rc) + if (0 != rc) TEST_ERROR /* Create object (local heap) that occupies most of cache */ - if(H5HL_create(f, (31 * 1024), &lheap_addr2) < 0) + if (H5HL_create(f, (31 * 1024), &lheap_addr2) < 0) FAIL_STACK_ERROR /* Protect local heap (which actually pins it in the cache) */ - if(NULL == (lheap2 = H5HL_protect(f, lheap_addr2, H5AC__READ_ONLY_FLAG))) + if (NULL == (lheap2 = H5HL_protect(f, lheap_addr2, H5AC__READ_ONLY_FLAG))) FAIL_STACK_ERROR /* Unprotect local heap (which actually unpins it from the cache) */ - if(H5HL_unprotect(lheap2) < 0) + if (H5HL_unprotect(lheap2) < 0) FAIL_STACK_ERROR /* Create object header message in new object header */ time_new = 11111111; - if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) + if (H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) FAIL_STACK_ERROR /* Create object (local heap) that occupies most of cache */ - if(H5HL_create(f, (31 * 1024), &lheap_addr3) < 0) + if (H5HL_create(f, (31 * 1024), &lheap_addr3) < 0) FAIL_STACK_ERROR /* Protect local heap (which actually pins it in the cache) */ - if(NULL == (lheap3 = H5HL_protect(f, lheap_addr3, H5AC__READ_ONLY_FLAG))) + if (NULL == (lheap3 = H5HL_protect(f, lheap_addr3, H5AC__READ_ONLY_FLAG))) FAIL_STACK_ERROR /* Unprotect local heap (which actually unpins it from the cache) */ - if(H5HL_unprotect(lheap3) < 0) + if (H5HL_unprotect(lheap3) < 0) FAIL_STACK_ERROR /* Query object header information */ @@ -270,24 +267,24 @@ test_ohdr_cache(char *filename, hid_t fapl) * a non-invasive way -QAK) */ rc = 0; - if(H5O__get_rc_test(&oh_loc, &rc) < 0) + if (H5O__get_rc_test(&oh_loc, &rc) < 0) FAIL_STACK_ERROR - if(0 != rc) + if (0 != rc) TEST_ERROR /* Decrement reference count o object header */ - if(H5O_dec_rc_by_loc(&oh_loc) < 0) + if (H5O_dec_rc_by_loc(&oh_loc) < 0) FAIL_STACK_ERROR /* Close object header created */ - if(H5O_close(&oh_loc, NULL) < 0) + if (H5O_close(&oh_loc, NULL) < 0) FAIL_STACK_ERROR /* Unprotect local heap (which actually unpins it from the cache) */ - if(H5HL_unprotect(lheap) < 0) + if (H5HL_unprotect(lheap) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR PASSED(); @@ -295,9 +292,11 @@ test_ohdr_cache(char *filename, hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* test_ohdr_cache() */ @@ -312,120 +311,122 @@ error: static herr_t test_ohdr_swmr(hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t plist = -1; /* Dataset creation property list */ - size_t compact_size = 1024; /* The size of compact dataset */ - int *wbuf = NULL; /* Buffer for writing */ - hsize_t dims[1]; /* Dimension sizes */ - size_t u; /* Iterator */ - int n; /* Data variable */ - H5O_native_info_t ninfo; /* Information for the object */ - - if(new_format) { + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t plist = -1; /* Dataset creation property list */ + size_t compact_size = 1024; /* The size of compact dataset */ + int * wbuf = NULL; /* Buffer for writing */ + hsize_t dims[1]; /* Dimension sizes */ + size_t u; /* Iterator */ + int n; /* Data variable */ + H5O_native_info_t ninfo; /* Information for the object */ + + if (new_format) { TESTING("exercise the coding for the re-read of the object header for SWMR access: latest-format"); - } else { - TESTING("exercise the coding for the re-read of the object header for SWMR access: non-latest-format"); + } + else { + TESTING( + "exercise the coding for the re-read of the object header for SWMR access: non-latest-format"); } /* end if */ /* File access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR /* Create the file with/without latest format: ensure version 2 object header for SWMR */ - if(new_format) { + if (new_format) { /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR - if((fid = H5Fcreate(FILE_OHDR_SWMR, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILE_OHDR_SWMR, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } /* end if */ else { - if((fid = H5Fcreate(FILE_OHDR_SWMR, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILE_OHDR_SWMR, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } /* end else */ /* Initialize data */ wbuf = (int *)HDcalloc(compact_size, sizeof(int)); - n = 0; - for(u = 0; u < compact_size; u++) + n = 0; + for (u = 0; u < compact_size; u++) wbuf[u] = n++; /* Create a small data space for compact dataset */ dims[0] = (hsize_t)compact_size; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) FAIL_STACK_ERROR /* Create property list for compact dataset creation */ - if((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* Set the layout for the compact dataset */ - if(H5Pset_layout(plist, H5D_COMPACT) < 0) + if (H5Pset_layout(plist, H5D_COMPACT) < 0) FAIL_STACK_ERROR /* Create a compact dataset */ - if((did = H5Dcreate2(fid, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write to the compact dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Open the file for SWMR write with/without latest format */ - if((fid = H5Fopen(FILE_OHDR_SWMR, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(FILE_OHDR_SWMR, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR /* Open the compact dataset */ - if((did = H5Dopen2(fid, DSET_NAME, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DSET_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get the object information */ - if(H5Oget_native_info(did, &ninfo, H5O_NATIVE_INFO_HDR) < 0) + if (H5Oget_native_info(did, &ninfo, H5O_NATIVE_INFO_HDR) < 0) FAIL_STACK_ERROR - if(new_format) - if(ninfo.hdr.version != OBJ_VERSION_LATEST) + if (new_format) + if (ninfo.hdr.version != OBJ_VERSION_LATEST) FAIL_STACK_ERROR /* The size of object header should be greater than the speculative read size of H5O_SPEC_READ_SIZE */ /* This will exercise the coding for the re-read of the object header for SWMR access */ - if(ninfo.hdr.space.total < H5O_SPEC_READ_SIZE) + if (ninfo.hdr.space.total < H5O_SPEC_READ_SIZE) TEST_ERROR; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR /* Close the dataset creation property list */ - if(H5Pclose(plist) < 0) + if (H5Pclose(plist) < 0) FAIL_STACK_ERROR /* Close the file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Remove the test file */ - if(HDremove(FILE_OHDR_SWMR) < 0) + if (HDremove(FILE_OHDR_SWMR) < 0) FAIL_STACK_ERROR /* Free the buffer */ @@ -436,7 +437,8 @@ test_ohdr_swmr(hbool_t new_format) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Dclose(did); H5Sclose(sid); @@ -444,7 +446,8 @@ error: H5Pclose(fapl); HDremove(FILE_OHDR_SWMR); HDfree(wbuf); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* test_ohdr_swmr() */ @@ -465,59 +468,59 @@ error: static herr_t test_unknown(unsigned bogus_id, char *filename, hid_t fapl) { - hid_t fid = -1; /* file ID */ - hid_t gid = -1; /* group ID */ - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t loc = -1; /* location: file or group ID */ - hid_t fid_bogus = -1; /* bogus file ID */ - hid_t gid_bogus = -1; /* bogus group ID */ - hid_t loc_bogus = -1; /* location: bogus file or group ID */ - char testfile[TESTFILE_LEN]; + hid_t fid = -1; /* file ID */ + hid_t gid = -1; /* group ID */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t loc = -1; /* location: file or group ID */ + hid_t fid_bogus = -1; /* bogus file ID */ + hid_t gid_bogus = -1; /* bogus group ID */ + hid_t loc_bogus = -1; /* location: bogus file or group ID */ + char testfile[TESTFILE_LEN]; /* create a different name for a local copy of the data file to be opened with rd/wr file permissions in case build and test are done in the source directory. */ HDstrncpy(testfile, FILE_BOGUS, TESTFILE_LEN); - testfile[TESTFILE_LEN - 1]='\0'; + testfile[TESTFILE_LEN - 1] = '\0'; HDstrncat(testfile, ".copy", 5); /* Make a copy of the data file from svn. */ - if(h5_make_local_copy(FILE_BOGUS, testfile) < 0) - FAIL_STACK_ERROR + if (h5_make_local_copy(FILE_BOGUS, testfile) < 0) + FAIL_STACK_ERROR TESTING("object with unknown header message and no flags set"); /* Open filename */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Open FILE_BOGUS */ - if((fid_bogus = H5Fopen(testfile, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid_bogus = H5Fopen(testfile, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { + if (bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in FILE_BOGUS */ - if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) + if ((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc_bogus = gid_bogus; /* Create "group" in filename */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc = gid; - - } else { /* H5O_BOGUS_VALID_ID */ + } + else { /* H5O_BOGUS_VALID_ID */ loc_bogus = fid_bogus; - loc = fid; + loc = fid; } /* end else */ - /* Open the dataset with the unknown header message, but no extra flags */ - if((did = H5Dopen2(loc_bogus, "Dataset1", H5P_DEFAULT)) < 0) + /* Open the dataset with the unknown header message, but no extra flags */ + if ((did = H5Dopen2(loc_bogus, "Dataset1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR PASSED(); @@ -525,9 +528,9 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) TESTING("object with unknown header message & 'shareable' flag set"); /* Open the dataset with the unknown header message, adn "shareable" flag */ - if((did = H5Dopen2(loc_bogus, "Dataset5", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_bogus, "Dataset5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR PASSED(); @@ -535,9 +538,9 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) TESTING("object in r/o file with unknown header message & 'fail if unknown and open for write' flag set"); /* Open the dataset with the unknown header message, and "fail if unknown and open for write" flag */ - if((did = H5Dopen2(loc_bogus, "Dataset2", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_bogus, "Dataset2", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR PASSED(); @@ -545,10 +548,12 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) TESTING("object in r/o file with unknown header message & 'fail if unknown always' flag set"); /* Attempt to open the dataset with the unknown header message, and "fail if unknown always" flag */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dopen2(loc_bogus, "Dataset3", H5P_DEFAULT); - } H5E_END_TRY; - if(did >= 0) { + } + H5E_END_TRY; + if (did >= 0) { H5Dclose(did); TEST_ERROR } /* end if */ @@ -558,157 +563,164 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) TESTING("object with unknown header message & 'mark if unknown' flag set"); /* Copy object with "mark if unknown" flag on message into file (FILENAME[0]) that can be modified */ - if(H5Ocopy(loc_bogus, "Dataset4", loc, "Dataset4", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Ocopy(loc_bogus, "Dataset4", loc, "Dataset4", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Closing: filename */ - if(bogus_id == H5O_BOGUS_INVALID_ID) - if(H5Gclose(gid) < 0) + if (bogus_id == H5O_BOGUS_INVALID_ID) + if (H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Re-open filename, with read-only permissions */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { + if (bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc = gid; - } else + } + else loc = fid; /* Open the dataset with the "mark if unknown" message */ - if((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Check that the "unknown" message was _NOT_ marked */ - if(H5O__check_msg_marked_test(did, FALSE) < 0) + if (H5O__check_msg_marked_test(did, FALSE) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close "group" in filename depending on bogus_id */ - if(bogus_id == H5O_BOGUS_INVALID_ID) - if(H5Gclose(gid) < 0) + if (bogus_id == H5O_BOGUS_INVALID_ID) + if (H5Gclose(gid) < 0) FAIL_STACK_ERROR /* Close filename (to flush change to object header) */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Re-open filename */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { + if (bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc = gid; - } else + } + else loc = fid; /* Open the dataset with the "mark if unknown" message */ - if((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create data space */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR /* Create an attribute, to get the object header into write access */ - if((aid = H5Acreate2(did, "Attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "Attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR /* Close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close "group" in filename depending on bogus_id */ - if(bogus_id == H5O_BOGUS_INVALID_ID) - if(H5Gclose(gid) < 0) + if (bogus_id == H5O_BOGUS_INVALID_ID) + if (H5Gclose(gid) < 0) FAIL_STACK_ERROR /* Close filename (to flush change to object header) */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Re-open filename */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { + if (bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in filename */ - if((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc = gid; - } else + } + else loc = fid; /* Re-open the dataset with the "mark if unknown" message */ - if((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc, "Dataset4", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Check that the "unknown" message was marked */ - if(H5O__check_msg_marked_test(did, TRUE) < 0) + if (H5O__check_msg_marked_test(did, TRUE) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Closing: filename */ - if(bogus_id == H5O_BOGUS_INVALID_ID) - if(H5Gclose(gid) < 0) + if (bogus_id == H5O_BOGUS_INVALID_ID) + if (H5Gclose(gid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); /* Closing: FILE_BOGUS */ - if(bogus_id == H5O_BOGUS_INVALID_ID) - if(H5Gclose(gid_bogus) < 0) + if (bogus_id == H5O_BOGUS_INVALID_ID) + if (H5Gclose(gid_bogus) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid_bogus) < 0) + if (H5Fclose(fid_bogus) < 0) FAIL_STACK_ERROR TESTING("object in r/w file with unknown header message & 'fail if unknown and open for write' flag set"); /* Open FILE_BOGUS with RW intent this time */ - if((fid_bogus = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid_bogus = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Set up location ID */ - if(bogus_id == H5O_BOGUS_INVALID_ID) { + if (bogus_id == H5O_BOGUS_INVALID_ID) { /* Open "group" in FILE_BOGUS */ - if((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) + if ((gid_bogus = H5Gopen2(fid_bogus, "group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR loc_bogus = gid_bogus; - } else + } + else loc_bogus = fid_bogus; - /* Attempt to open the dataset with the unknown header message, and "fail if unknown and open for write" flag */ - H5E_BEGIN_TRY { + /* Attempt to open the dataset with the unknown header message, and "fail if unknown and open for write" + * flag */ + H5E_BEGIN_TRY + { did = H5Dopen2(loc_bogus, "Dataset2", H5P_DEFAULT); - } H5E_END_TRY; - if(did >= 0) { + } + H5E_END_TRY; + if (did >= 0) { H5Dclose(did); TEST_ERROR } /* end if */ @@ -718,19 +730,21 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) TESTING("object in r/w file with unknown header message & 'fail if unknown always' flag set"); /* Attempt to open the dataset with the unknown header message, and "fail if unknown always" flag */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dopen2(loc_bogus, "Dataset3", H5P_DEFAULT); - } H5E_END_TRY; - if(did >= 0) { + } + H5E_END_TRY; + if (did >= 0) { H5Dclose(did); TEST_ERROR } /* end if */ /* Closing: FILE_BOGUS */ - if(bogus_id == H5O_BOGUS_INVALID_ID) - if(H5Gclose(gid_bogus) < 0) + if (bogus_id == H5O_BOGUS_INVALID_ID) + if (H5Gclose(gid_bogus) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid_bogus) < 0) + if (H5Fclose(fid_bogus) < 0) FAIL_STACK_ERROR PASSED(); @@ -738,7 +752,8 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Gclose(gid); H5Fclose(fid_bogus); @@ -746,7 +761,8 @@ error: H5Dclose(did); H5Sclose(sid); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* test_unknown() */ @@ -760,7 +776,7 @@ count_attributes(hid_t dset_id) { H5O_info2_t info; - if(H5Oget_info3(dset_id, &info, H5O_INFO_NUM_ATTRS) < 0) + if (H5Oget_info3(dset_id, &info, H5O_INFO_NUM_ATTRS) < 0) return -1; else return (int)info.num_attrs; /* should never exceed int bounds */ @@ -776,7 +792,7 @@ _oh_getsize(hid_t did, hsize_t *size_out) { H5O_native_info_t ninfo; - if(FAIL == H5Oget_native_info(did, &ninfo, H5O_NATIVE_INFO_HDR)) + if (FAIL == H5Oget_native_info(did, &ninfo, H5O_NATIVE_INFO_HDR)) return FAIL; *size_out = ninfo.hdr.space.total; @@ -795,14 +811,14 @@ oh_compare(hid_t did1, hid_t did2) hsize_t space1 = 0; hsize_t space2 = 0; - if(FAIL == _oh_getsize(did1, &space1)) + if (FAIL == _oh_getsize(did1, &space1)) return -1; - if(FAIL == _oh_getsize(did2, &space2)) + if (FAIL == _oh_getsize(did2, &space2)) return -2; - if(space1 < space2) + if (space1 < space2) return LT; - else if(space1 > space2) + else if (space1 > space2) return GT; else return EQ; @@ -813,55 +829,56 @@ oh_compare(hid_t did1, hid_t did2) * Conduct additions side-by-side with a standard datataset and one with * minimized dataset object headers. */ -#define ATTR_NAME_MAX 64 -#define ATTR_SHORT "first" -#define ATTR_LONG "second" -#define N_ATTRS 64 +#define ATTR_NAME_MAX 64 +#define ATTR_SHORT "first" +#define ATTR_LONG "second" +#define N_ATTRS 64 static herr_t test_minimized_dset_ohdr_attribute_addition(hid_t fapl_id) { - hsize_t dims[1] = {0}; /* dataspace extent */ - char filename[512] = ""; + hsize_t dims[1] = {0}; /* dataspace extent */ + char filename[512] = ""; char attr_name[ATTR_NAME_MAX] = ""; - hid_t fid = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t aid = H5I_INVALID_HID; - char *in_buf = NULL; - char *out_buf = NULL; - size_t buf_size = 0; - int out_val = 0; - int in_val = 0; + hid_t fid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + char * in_buf = NULL; + char * out_buf = NULL; + size_t buf_size = 0; + int out_val = 0; + int in_val = 0; int i; TESTING("adding attributes to datasets created with H5Pset_dset_no_attrs_hint()") /* Create the test file */ - if(NULL == h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename))) + if (NULL == h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename))) TEST_ERROR; - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) == H5I_INVALID_HID) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) == H5I_INVALID_HID) TEST_ERROR; /* Set the 'no attrs' hint on the dcpl */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) == H5I_INVALID_HID) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) == H5I_INVALID_HID) TEST_ERROR; - if(H5Pset_dset_no_attrs_hint(dcpl_id, TRUE) < 0) + if (H5Pset_dset_no_attrs_hint(dcpl_id, TRUE) < 0) TEST_ERROR; /* The dataset doesn't need to contain data */ dims[0] = 0; - if((sid = H5Screate_simple(1, dims, NULL)) == H5I_INVALID_HID) + if ((sid = H5Screate_simple(1, dims, NULL)) == H5I_INVALID_HID) TEST_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, "H5Pset_dset_no_attrs_hint", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) == H5I_INVALID_HID) + if ((did = H5Dcreate2(fid, "H5Pset_dset_no_attrs_hint", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, + H5P_DEFAULT)) == H5I_INVALID_HID) TEST_ERROR; /* Close */ - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) TEST_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; /********************************************** @@ -869,9 +886,9 @@ test_minimized_dset_ohdr_attribute_addition(hid_t fapl_id) **********************************************/ buf_size = HDstrlen(ATTR_LONG) + 1; - if(NULL == (in_buf = (char *)HDcalloc(buf_size, sizeof(char)))) + if (NULL == (in_buf = (char *)HDcalloc(buf_size, sizeof(char)))) TEST_ERROR; - if(NULL == (out_buf = (char *)HDcalloc(buf_size, sizeof(char)))) + if (NULL == (out_buf = (char *)HDcalloc(buf_size, sizeof(char)))) TEST_ERROR; /* Create a string attribute on the dataset @@ -880,93 +897,95 @@ test_minimized_dset_ohdr_attribute_addition(hid_t fapl_id) * to it. */ dims[0] = buf_size; - if((sid = H5Screate_simple(1, dims, NULL)) == H5I_INVALID_HID) + if ((sid = H5Screate_simple(1, dims, NULL)) == H5I_INVALID_HID) TEST_ERROR; - if((aid = H5Acreate2(did, "string_attr", H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) == H5I_INVALID_HID) + if ((aid = H5Acreate2(did, "string_attr", H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) == + H5I_INVALID_HID) TEST_ERROR; /* Write attribute data */ HDstrcpy(in_buf, ATTR_SHORT); - if(H5Awrite(aid, H5T_NATIVE_CHAR, in_buf) < 0) + if (H5Awrite(aid, H5T_NATIVE_CHAR, in_buf) < 0) TEST_ERROR; /* Make sure the count is correct */ - if(count_attributes(did) != 1) + if (count_attributes(did) != 1) TEST_ERROR; /* Read the data back and verify */ - if(H5Aread(aid, H5T_NATIVE_CHAR, out_buf) < 0) + if (H5Aread(aid, H5T_NATIVE_CHAR, out_buf) < 0) TEST_ERROR; - if(HDstrcmp(in_buf, out_buf)) + if (HDstrcmp(in_buf, out_buf)) TEST_ERROR; /* modify the string attribute */ HDmemset(in_buf, 0, buf_size); HDstrcpy(in_buf, ATTR_LONG); - if(H5Awrite(aid, H5T_NATIVE_CHAR, in_buf) < 0) + if (H5Awrite(aid, H5T_NATIVE_CHAR, in_buf) < 0) TEST_ERROR; - if(count_attributes(did) != 1) + if (count_attributes(did) != 1) TEST_ERROR; /* Read the data back and verify */ - if(H5Aread(aid, H5T_NATIVE_CHAR, out_buf) < 0) + if (H5Aread(aid, H5T_NATIVE_CHAR, out_buf) < 0) TEST_ERROR; - if(HDstrcmp(in_buf, out_buf)) + if (HDstrcmp(in_buf, out_buf)) TEST_ERROR; /* Close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR; /*************************************** * ADD A BUNCH OF (INTEGER) ATTRIBUTES * ***************************************/ - if((sid = H5Screate(H5S_SCALAR)) == H5I_INVALID_HID) + if ((sid = H5Screate(H5S_SCALAR)) == H5I_INVALID_HID) TEST_ERROR; /* Loop over a reasonable number of attributes */ - for(i = 0; i < N_ATTRS; i++) { + for (i = 0; i < N_ATTRS; i++) { /* Set the attribute's name */ - if(HDsnprintf(attr_name, ATTR_NAME_MAX, "int_attr_%d", i) < 0) + if (HDsnprintf(attr_name, ATTR_NAME_MAX, "int_attr_%d", i) < 0) TEST_ERROR; /* Create an integer attribute on the dataset */ - if((aid = H5Acreate2(did, attr_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) == H5I_INVALID_HID) + if ((aid = H5Acreate2(did, attr_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) == + H5I_INVALID_HID) TEST_ERROR; /* Write attribute data */ in_val = i; - if(H5Awrite(aid, H5T_NATIVE_INT, &in_val) < 0) + if (H5Awrite(aid, H5T_NATIVE_INT, &in_val) < 0) TEST_ERROR; /* Make sure the count is correct (already has one attribute) */ - if(count_attributes(did) != i + 2) + if (count_attributes(did) != i + 2) TEST_ERROR; /* Read the data back and verify */ - if(H5Aread(aid, H5T_NATIVE_INT, &out_val) < 0) + if (H5Aread(aid, H5T_NATIVE_INT, &out_val) < 0) TEST_ERROR; - if(in_val != out_val) + if (in_val != out_val) TEST_ERROR; /* Close */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) TEST_ERROR; } /* Close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; /* Close the remaining IDs */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; /* Free memory */ @@ -976,14 +995,16 @@ test_minimized_dset_ohdr_attribute_addition(hid_t fapl_id) PASSED(); return SUCCEED; -error : - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { (void)H5Pclose(dcpl_id); (void)H5Sclose(sid); (void)H5Dclose(did); (void)H5Aclose(aid); (void)H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(in_buf); HDfree(out_buf); @@ -1033,123 +1054,145 @@ test_minimized_dset_ohdr_size_comparisons(hid_t fapl_id) * file-minimized | F_x | F_Y | F_N */ - /********* * SETUP * *********/ /* Set filenames (not in a test, can't use TEST_ERROR) */ - if(h5_fixname(FILENAME[1], fapl_id, filename_a, sizeof(filename_a)) == NULL) + if (h5_fixname(FILENAME[1], fapl_id, filename_a, sizeof(filename_a)) == NULL) return FAIL; - if(h5_fixname(FILENAME[2], fapl_id, filename_b, sizeof(filename_b)) == NULL) + if (h5_fixname(FILENAME[2], fapl_id, filename_b, sizeof(filename_b)) == NULL) return FAIL; for (compact = 0; compact < 2; compact++) { /* 0 or 1 */ - if(compact) + if (compact) TESTING("minimized dset object headers size comparisons (compact)") else TESTING("minimized dset object headers size comparisons") dcpl_default = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_default < 0) TEST_ERROR + if (dcpl_default < 0) + TEST_ERROR dcpl_minimize = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_minimize < 0) TEST_ERROR + if (dcpl_minimize < 0) + TEST_ERROR ret = H5Pset_dset_no_attrs_hint(dcpl_minimize, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR dcpl_dontmin = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_dontmin < 0) TEST_ERROR + if (dcpl_dontmin < 0) + TEST_ERROR ret = H5Pset_dset_no_attrs_hint(dcpl_dontmin, FALSE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR - if(compact) { + if (compact) { ret = H5Pset_layout(dcpl_default, H5D_COMPACT); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR ret = H5Pset_layout(dcpl_minimize, H5D_COMPACT); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR ret = H5Pset_layout(dcpl_dontmin, H5D_COMPACT); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR } dspace_id = H5Screate_simple(1, array_10, NULL); - if(dspace_id < 0) TEST_ERROR + if (dspace_id < 0) + TEST_ERROR int_type_id = H5Tcopy(H5T_NATIVE_INT); - if(int_type_id < 0) TEST_ERROR + if (int_type_id < 0) + TEST_ERROR file_f_id = H5Fcreate(filename_a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_f_id < 0) TEST_ERROR + if (file_f_id < 0) + TEST_ERROR - dset_f_x_id = H5Dcreate2(file_f_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); - if(dset_f_x_id < 0) TEST_ERROR + dset_f_x_id = + H5Dcreate2(file_f_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); + if (dset_f_x_id < 0) + TEST_ERROR - dset_f_N_id = H5Dcreate2(file_f_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); - if(dset_f_N_id < 0) TEST_ERROR + dset_f_N_id = + H5Dcreate2(file_f_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); + if (dset_f_N_id < 0) + TEST_ERROR - dset_f_Y_id = H5Dcreate2(file_f_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); - if(dset_f_x_id < 0) TEST_ERROR + dset_f_Y_id = + H5Dcreate2(file_f_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); + if (dset_f_x_id < 0) + TEST_ERROR file_F_id = H5Fcreate(filename_b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_F_id < 0) TEST_ERROR + if (file_F_id < 0) + TEST_ERROR ret = H5Fset_dset_no_attrs_hint(file_F_id, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR - dset_F_x_id = H5Dcreate2(file_F_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); - if(dset_F_x_id < 0) TEST_ERROR + dset_F_x_id = + H5Dcreate2(file_F_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); + if (dset_F_x_id < 0) + TEST_ERROR - dset_F_N_id = H5Dcreate2(file_F_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); - if(dset_F_N_id < 0) TEST_ERROR + dset_F_N_id = + H5Dcreate2(file_F_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); + if (dset_F_N_id < 0) + TEST_ERROR - dset_F_Y_id = H5Dcreate2(file_F_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); - if(dset_F_Y_id < 0) TEST_ERROR + dset_F_Y_id = + H5Dcreate2(file_F_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); + if (dset_F_Y_id < 0) + TEST_ERROR /********* * TESTS * *********/ - if(oh_compare(dset_f_x_id, dset_f_x_id) != EQ) TEST_ERROR /* identity */ + if (oh_compare(dset_f_x_id, dset_f_x_id) != EQ) + TEST_ERROR /* identity */ - if(oh_compare(dset_f_x_id, dset_f_N_id) != EQ) TEST_ERROR - if(oh_compare(dset_f_x_id, dset_f_Y_id) != GT) TEST_ERROR - if(oh_compare(dset_f_N_id, dset_f_Y_id) != GT) TEST_ERROR + if (oh_compare(dset_f_x_id, dset_f_N_id) != EQ) + TEST_ERROR if (oh_compare(dset_f_x_id, dset_f_Y_id) != GT) + TEST_ERROR if (oh_compare(dset_f_N_id, dset_f_Y_id) != GT) TEST_ERROR - if(oh_compare(dset_F_x_id, dset_F_N_id) != EQ) TEST_ERROR - if(oh_compare(dset_F_x_id, dset_F_Y_id) != EQ) TEST_ERROR - if(oh_compare(dset_F_N_id, dset_F_Y_id) != EQ) TEST_ERROR + if (oh_compare(dset_F_x_id, dset_F_N_id) != EQ) + TEST_ERROR if (oh_compare(dset_F_x_id, dset_F_Y_id) != EQ) + TEST_ERROR if (oh_compare(dset_F_N_id, dset_F_Y_id) != EQ) TEST_ERROR - if(oh_compare(dset_F_x_id, dset_f_Y_id) != EQ) TEST_ERROR - if(oh_compare(dset_F_x_id, dset_f_x_id) != LT) TEST_ERROR + if (oh_compare(dset_F_x_id, dset_f_Y_id) != EQ) + TEST_ERROR if (oh_compare(dset_F_x_id, dset_f_x_id) != LT) TEST_ERROR - /************ - * TEARDOWN * - ************/ + /************ + * TEARDOWN * + ************/ - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Tclose(int_type_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_default) < 0) TEST_ERROR - if(H5Pclose(dcpl_minimize) < 0) TEST_ERROR - if(H5Pclose(dcpl_dontmin) < 0) TEST_ERROR + if (H5Sclose(dspace_id) < 0) TEST_ERROR if (H5Tclose(int_type_id) < 0) + TEST_ERROR if (H5Pclose(dcpl_default) < 0) TEST_ERROR if (H5Pclose(dcpl_minimize) < 0) + TEST_ERROR if (H5Pclose(dcpl_dontmin) < 0) TEST_ERROR - if(H5Fclose(file_f_id) < 0) TEST_ERROR - if(H5Dclose(dset_f_x_id) < 0) TEST_ERROR - if(H5Dclose(dset_f_N_id) < 0) TEST_ERROR - if(H5Dclose(dset_f_Y_id) < 0) TEST_ERROR + if (H5Fclose(file_f_id) < 0) TEST_ERROR if (H5Dclose(dset_f_x_id) < 0) + TEST_ERROR if (H5Dclose(dset_f_N_id) < 0) TEST_ERROR if (H5Dclose(dset_f_Y_id) < 0) + TEST_ERROR - if(H5Fclose(file_F_id) < 0) TEST_ERROR - if(H5Dclose(dset_F_x_id) < 0) TEST_ERROR - if(H5Dclose(dset_F_N_id) < 0) TEST_ERROR - if(H5Dclose(dset_F_Y_id) < 0) TEST_ERROR + if (H5Fclose(file_F_id) < 0) TEST_ERROR if (H5Dclose(dset_F_x_id) < 0) + TEST_ERROR if (H5Dclose(dset_F_N_id) < 0) TEST_ERROR if (H5Dclose(dset_F_Y_id) < 0) + TEST_ERROR - PASSED(); + PASSED(); } /* compact and non-compact */ return SUCCEED; -error : - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { (void)H5Pclose(dcpl_default); (void)H5Pclose(dcpl_minimize); (void)H5Pclose(dcpl_dontmin); @@ -1165,7 +1208,8 @@ error : (void)H5Dclose(dset_F_x_id); (void)H5Dclose(dset_F_N_id); (void)H5Dclose(dset_F_Y_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* test_minimized_dset_ohdr_size_comparisons */ @@ -1177,8 +1221,8 @@ test_minimized_dset_ohdr_with_filter(hid_t fapl_id) { char filename[512] = ""; const hsize_t extents[1] = {1024}; /* extents of dataspace */ - const unsigned filter_values[] = {0}; /* TBD */ - const hsize_t chunk_dim[] = {32}; /* needed for filter */ + const unsigned filter_values[] = {0}; /* TBD */ + const hsize_t chunk_dim[] = {32}; /* needed for filter */ const int ndims = 1; hid_t dspace_id = -1; hid_t dtype_id = -1; @@ -1206,79 +1250,110 @@ test_minimized_dset_ohdr_with_filter(hid_t fapl_id) * SETUP * *********/ - if(h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)) == NULL) + if (h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)) == NULL) TEST_ERROR dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mx_id < 0) TEST_ERROR + if (dcpl_mx_id < 0) + TEST_ERROR ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR dcpl_xZ_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_xZ_id < 0) TEST_ERROR + if (dcpl_xZ_id < 0) + TEST_ERROR ret = H5Pset_chunk(dcpl_xZ_id, ndims, chunk_dim); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR ret = H5Pset_filter(dcpl_xZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR dcpl_mZ_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mZ_id < 0) TEST_ERROR + if (dcpl_mZ_id < 0) + TEST_ERROR ret = H5Pset_dset_no_attrs_hint(dcpl_mZ_id, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR ret = H5Pset_chunk(dcpl_mZ_id, ndims, chunk_dim); - if(ret < 0) TEST_ERROR - ret = H5Pset_filter( dcpl_mZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR + ret = H5Pset_filter(dcpl_mZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); + if (ret < 0) + TEST_ERROR dspace_id = H5Screate_simple(1, extents, extents); - if(dspace_id < 0) TEST_ERROR + if (dspace_id < 0) + TEST_ERROR dtype_id = H5Tcopy(H5T_NATIVE_INT); - if(dtype_id < 0) TEST_ERROR + if (dtype_id < 0) + TEST_ERROR file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_id < 0) TEST_ERROR + if (file_id < 0) + TEST_ERROR dset_xx_id = H5Dcreate2(file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset_xx_id < 0) TEST_ERROR + if (dset_xx_id < 0) + TEST_ERROR dset_mx_id = H5Dcreate2(file_id, "Mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); - if(dset_mx_id < 0) TEST_ERROR + if (dset_mx_id < 0) + TEST_ERROR dset_xZ_id = H5Dcreate2(file_id, "xZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xZ_id, H5P_DEFAULT); - if(dset_xZ_id < 0) TEST_ERROR + if (dset_xZ_id < 0) + TEST_ERROR dset_mZ_id = H5Dcreate2(file_id, "MZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mZ_id, H5P_DEFAULT); - if(dset_mZ_id < 0) TEST_ERROR + if (dset_mZ_id < 0) + TEST_ERROR /********* * TESTS * *********/ - if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR - if(oh_compare(dset_mx_id, dset_xZ_id) != LT) TEST_ERROR - if(oh_compare(dset_mZ_id, dset_mx_id) != GT) TEST_ERROR - if(oh_compare(dset_mZ_id, dset_xZ_id) != LT) TEST_ERROR + if (oh_compare(dset_mx_id, dset_xx_id) != LT) + TEST_ERROR + if (oh_compare(dset_mx_id, dset_xZ_id) != LT) + TEST_ERROR + if (oh_compare(dset_mZ_id, dset_mx_id) != GT) + TEST_ERROR + if (oh_compare(dset_mZ_id, dset_xZ_id) != LT) + TEST_ERROR /************ * TEARDOWN * ************/ - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Tclose(dtype_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_xZ_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mZ_id) < 0) TEST_ERROR - if(H5Dclose(dset_xx_id) < 0) TEST_ERROR - if(H5Dclose(dset_xZ_id) < 0) TEST_ERROR - if(H5Dclose(dset_mx_id) < 0) TEST_ERROR - if(H5Dclose(dset_mZ_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR + if (H5Sclose(dspace_id) < 0) + TEST_ERROR + if (H5Tclose(dtype_id) < 0) + TEST_ERROR + if (H5Pclose(dcpl_xZ_id) < 0) + TEST_ERROR + if (H5Pclose(dcpl_mx_id) < 0) + TEST_ERROR + if (H5Pclose(dcpl_mZ_id) < 0) + TEST_ERROR + if (H5Dclose(dset_xx_id) < 0) + TEST_ERROR + if (H5Dclose(dset_xZ_id) < 0) + TEST_ERROR + if (H5Dclose(dset_mx_id) < 0) + TEST_ERROR + if (H5Dclose(dset_mZ_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Sclose(dspace_id); (void)H5Tclose(dtype_id); (void)H5Pclose(dcpl_xZ_id); @@ -1289,7 +1364,8 @@ error: (void)H5Dclose(dset_mx_id); (void)H5Dclose(dset_mZ_id); (void)H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* test_minimized_dset_ohdr_with_filter */ @@ -1322,11 +1398,15 @@ test_minimized_dset_ohdr_modification_times(hid_t _fapl_id) hid_t fapl_id = -1; herr_t ret; - unsigned i = 0; /* for testcase loop */ - unsigned n_cases = 2; /* must match `cases` array size below */ + unsigned i = 0; /* for testcase loop */ + unsigned n_cases = 2; /* must match `cases` array size below */ struct testcase cases[2] = { - { 1, }, /* version 1 object header */ - { 2, }, /* version 2 object header */ + { + 1, + }, /* version 1 object header */ + { + 2, + }, /* version 2 object header */ }; /* dcpl suffixes: @@ -1345,38 +1425,50 @@ test_minimized_dset_ohdr_modification_times(hid_t _fapl_id) * SETUP * *********/ - if(h5_fixname(FILENAME[1], _fapl_id, filename, sizeof(filename)) == NULL) + if (h5_fixname(FILENAME[1], _fapl_id, filename, sizeof(filename)) == NULL) TEST_ERROR dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mx_id < 0) TEST_ERROR + if (dcpl_mx_id < 0) + TEST_ERROR ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR dcpl_xT_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_xT_id < 0) TEST_ERROR + if (dcpl_xT_id < 0) + TEST_ERROR ret = H5Pset_obj_track_times(dcpl_xT_id, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR dcpl_mT_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mT_id < 0) TEST_ERROR + if (dcpl_mT_id < 0) + TEST_ERROR ret = H5Pset_dset_no_attrs_hint(dcpl_mT_id, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR ret = H5Pset_obj_track_times(dcpl_mT_id, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR dcpl_mN_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mN_id < 0) TEST_ERROR + if (dcpl_mN_id < 0) + TEST_ERROR ret = H5Pset_dset_no_attrs_hint(dcpl_mN_id, TRUE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR ret = H5Pset_obj_track_times(dcpl_mN_id, FALSE); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR dspace_id = H5Screate_simple(1, extents, extents); - if(dspace_id < 0) TEST_ERROR + if (dspace_id < 0) + TEST_ERROR dtype_id = H5Tcopy(H5T_NATIVE_INT); - if(dtype_id < 0) TEST_ERROR + if (dtype_id < 0) + TEST_ERROR for (i = 0; i < n_cases; i++) { @@ -1385,55 +1477,76 @@ test_minimized_dset_ohdr_modification_times(hid_t _fapl_id) * -------------- */ fapl_id = H5Pcopy(_fapl_id); - if(fapl_id < 0) TEST_ERROR + if (fapl_id < 0) + TEST_ERROR - if(cases[i].oh_version > 1) { + if (cases[i].oh_version > 1) { ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_V110); - if(ret < 0) TEST_ERROR + if (ret < 0) + TEST_ERROR } file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_id < 0) TEST_ERROR + if (file_id < 0) + TEST_ERROR - dset_xx_id = H5Dcreate2( file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset_xx_id < 0) TEST_ERROR + dset_xx_id = H5Dcreate2(file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset_xx_id < 0) + TEST_ERROR dset_mx_id = H5Dcreate2(file_id, "mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); - if(dset_mx_id < 0) TEST_ERROR + if (dset_mx_id < 0) + TEST_ERROR dset_xT_id = H5Dcreate2(file_id, "xT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xT_id, H5P_DEFAULT); - if(dset_xT_id < 0) TEST_ERROR + if (dset_xT_id < 0) + TEST_ERROR dset_mT_id = H5Dcreate2(file_id, "mT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mT_id, H5P_DEFAULT); - if(dset_mT_id < 0) TEST_ERROR + if (dset_mT_id < 0) + TEST_ERROR dset_mN_id = H5Dcreate2(file_id, "mN", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mN_id, H5P_DEFAULT); - if(dset_mN_id < 0) TEST_ERROR + if (dset_mN_id < 0) + TEST_ERROR /* ----- * * TESTS * * ----- */ /* sanity check */ - if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR - if(oh_compare(dset_mx_id, dset_xT_id) != LT) TEST_ERROR + if (oh_compare(dset_mx_id, dset_xx_id) != LT) + TEST_ERROR + if (oh_compare(dset_mx_id, dset_xT_id) != LT) + TEST_ERROR - if(oh_compare(dset_xx_id, dset_xT_id) != EQ) TEST_ERROR - if(oh_compare(dset_mx_id, dset_mT_id) != EQ) TEST_ERROR - if(oh_compare(dset_mN_id, dset_mT_id) != LT) TEST_ERROR + if (oh_compare(dset_xx_id, dset_xT_id) != EQ) + TEST_ERROR + if (oh_compare(dset_mx_id, dset_mT_id) != EQ) + TEST_ERROR + if (oh_compare(dset_mN_id, dset_mT_id) != LT) + TEST_ERROR - if(oh_compare(dset_mT_id, dset_xT_id) != LT) TEST_ERROR + if (oh_compare(dset_mT_id, dset_xT_id) != LT) + TEST_ERROR /* ----------------- * * per-case teardown * * ----------------- */ - if(H5Dclose(dset_xx_id) < 0) TEST_ERROR - if(H5Dclose(dset_xT_id) < 0) TEST_ERROR - if(H5Dclose(dset_mx_id) < 0) TEST_ERROR - if(H5Dclose(dset_mT_id) < 0) TEST_ERROR - if(H5Dclose(dset_mN_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR - if(H5Pclose(fapl_id) < 0) TEST_ERROR + if (H5Dclose(dset_xx_id) < 0) + TEST_ERROR + if (H5Dclose(dset_xT_id) < 0) + TEST_ERROR + if (H5Dclose(dset_mx_id) < 0) + TEST_ERROR + if (H5Dclose(dset_mT_id) < 0) + TEST_ERROR + if (H5Dclose(dset_mN_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR + if (H5Pclose(fapl_id) < 0) + TEST_ERROR } /* for each version tested */ @@ -1441,18 +1554,25 @@ test_minimized_dset_ohdr_modification_times(hid_t _fapl_id) * TEARDOWN * ************/ - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Tclose(dtype_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_xT_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mT_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mN_id) < 0) TEST_ERROR + if (H5Sclose(dspace_id) < 0) + TEST_ERROR + if (H5Tclose(dtype_id) < 0) + TEST_ERROR + if (H5Pclose(dcpl_xT_id) < 0) + TEST_ERROR + if (H5Pclose(dcpl_mx_id) < 0) + TEST_ERROR + if (H5Pclose(dcpl_mT_id) < 0) + TEST_ERROR + if (H5Pclose(dcpl_mN_id) < 0) + TEST_ERROR PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Sclose(dspace_id); (void)H5Tclose(dtype_id); (void)H5Pclose(dcpl_xT_id); @@ -1466,7 +1586,8 @@ error: (void)H5Dclose(dset_mN_id); (void)H5Fclose(file_id); (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* test_minimized_dset_ohdr_modification_times */ @@ -1477,7 +1598,7 @@ static herr_t test_minimized_dset_ohdr_fillvalue_backwards_compatability(hid_t _fapl_id) { char filename[512] = ""; - const hsize_t extents[1] = {64}; /* extents of dataspace */ + const hsize_t extents[1] = {64}; /* extents of dataspace */ const int fill[1] = {343}; /* fill value of dataset */ hid_t file_id = -1; hid_t dtype_id = -1; @@ -1495,79 +1616,103 @@ test_minimized_dset_ohdr_fillvalue_backwards_compatability(hid_t _fapl_id) TESTING("minimized dset object headers with fill values and different libver support"); fapl_id = H5Pcopy(_fapl_id); - if(fapl_id < 0) TEST_ERROR + if (fapl_id < 0) + TEST_ERROR - if(h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)) == NULL) + if (h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)) == NULL) TEST_ERROR dspace_id = H5Screate_simple(1, extents, extents); - if(dspace_id < 0) TEST_ERROR + if (dspace_id < 0) + TEST_ERROR dtype_id = H5Tcopy(H5T_NATIVE_INT); - if(dtype_id < 0) TEST_ERROR + if (dtype_id < 0) + TEST_ERROR dcpl_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_id < 0) TEST_ERROR + if (dcpl_id < 0) + TEST_ERROR ret = H5Pset_dset_no_attrs_hint(dcpl_id, TRUE); - if(ret == FAIL) TEST_ERROR; + if (ret == FAIL) + TEST_ERROR; ret = H5Pset_fill_value(dcpl_id, dtype_id, fill); - if(ret == FAIL) TEST_ERROR; + if (ret == FAIL) + TEST_ERROR; ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST); - if(ret == FAIL) TEST_ERROR; + if (ret == FAIL) + TEST_ERROR; file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_id < 0) TEST_ERROR + if (file_id < 0) + TEST_ERROR dset_0_id = H5Dcreate2(file_id, "fullrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); - if(dset_0_id < 0) TEST_ERROR + if (dset_0_id < 0) + TEST_ERROR /* Close file and re-open with different libver bounds. * Dataset "fullrange" must also be closed for expected reopen behavior. */ - if(H5Fclose(file_id) < 0) TEST_ERROR; - if(H5Dclose(dset_0_id) < 0) TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5Dclose(dset_0_id) < 0) + TEST_ERROR ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_LATEST); - if(ret == FAIL) TEST_ERROR; + if (ret == FAIL) + TEST_ERROR; file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); - if(file_id < 0) TEST_ERROR + if (file_id < 0) + TEST_ERROR dset_1_id = H5Dcreate2(file_id, "upperrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); - if(dset_1_id < 0) TEST_ERROR + if (dset_1_id < 0) + TEST_ERROR /* re-open "fullrange" dataset */ - dset_0_id = H5Dopen2(file_id, "fullrange", H5P_DEFAULT); - if(dset_0_id < 0) TEST_ERROR + dset_0_id = H5Dopen2(file_id, "fullrange", H5P_DEFAULT); + if (dset_0_id < 0) + TEST_ERROR /********* * TESTS * *********/ /* dset not supporting pre-1.08 should be smaller? */ - if(oh_compare(dset_1_id, dset_0_id) != LT) TEST_ERROR + if (oh_compare(dset_1_id, dset_0_id) != LT) + TEST_ERROR /************ * TEARDOWN * ************/ - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Tclose(dtype_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_id) < 0) TEST_ERROR - if(H5Pclose(fapl_id) < 0) TEST_ERROR - if(H5Dclose(dset_0_id) < 0) TEST_ERROR - if(H5Dclose(dset_1_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Sclose(dspace_id) < 0) + TEST_ERROR + if (H5Tclose(dtype_id) < 0) + TEST_ERROR + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR + if (H5Pclose(fapl_id) < 0) + TEST_ERROR + if (H5Dclose(dset_0_id) < 0) + TEST_ERROR + if (H5Dclose(dset_1_id) < 0) + TEST_ERROR + if (H5Fclose(file_id) < 0) + TEST_ERROR; PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Sclose(dspace_id); (void)H5Tclose(dtype_id); (void)H5Pclose(dcpl_id); @@ -1575,11 +1720,11 @@ error: (void)H5Dclose(dset_0_id); (void)H5Dclose(dset_1_id); (void)H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* test_minimized_dset_ohdr_fillvalue_backwards_compatability */ - /*------------------------------------------------------------------------- * Function: main * @@ -1596,27 +1741,28 @@ error: int main(void) { - hid_t fapl = -1; - hid_t file = -1; - H5F_t *f = NULL; - const char *env_h5_drvr; /* File driver value from environment */ - hbool_t single_file_vfd; /* Whether VFD used stores data in a single file */ - char filename[1024]; + hid_t fapl = -1; + hid_t file = -1; + H5F_t * f = NULL; + const char * env_h5_drvr; /* File driver value from environment */ + hbool_t single_file_vfd; /* Whether VFD used stores data in a single file */ + char filename[1024]; H5O_hdr_info_t hdr_info; /* Object info */ H5O_loc_t oh_loc; /* Object header locations */ - H5F_libver_t low, high; /* File format bounds */ - time_t time_new, ro; - int i; /* Local index variable */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret; /* Generic return value */ + H5F_libver_t low, high; /* File format bounds */ + time_t time_new, ro; + int i; /* Local index variable */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret; /* Generic return value */ /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; /* Check for VFD which stores data in multiple files */ - single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")); + single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && + HDstrcmp(env_h5_drvr, "family")); /* Reset library */ h5_reset(); @@ -1624,266 +1770,272 @@ main(void) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Loop through all the combinations of low/high library format bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - const char *low_string; /* Message for library version low bound */ - const char *high_string; /* Message for library version high bound */ - char msg[80]; /* Message for file format version */ - - /* Set version bounds before opening the file */ - H5E_BEGIN_TRY { - ret = H5Pset_libver_bounds(fapl, low, high); - } H5E_END_TRY; - - if (ret < 0) /* Invalid low/high combinations */ - continue; - - /* Display info about testing */ - low_string = h5_get_version_string(low); - high_string = h5_get_version_string(high); - HDsprintf(msg, "Using file format version: (%s, %s)", low_string, - high_string); - HDputs(msg); - - /* test on object continuation block */ - if(test_cont(filename, fapl) < 0) - TEST_ERROR + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + const char *low_string; /* Message for library version low bound */ + const char *high_string; /* Message for library version high bound */ + char msg[80]; /* Message for file format version */ + + /* Set version bounds before opening the file */ + H5E_BEGIN_TRY + { + ret = H5Pset_libver_bounds(fapl, low, high); + } + H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Display info about testing */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Using file format version: (%s, %s)", low_string, high_string); + HDputs(msg); + + /* test on object continuation block */ + if (test_cont(filename, fapl) < 0) + TEST_ERROR - /* Create the file to operate on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR - if(NULL == (f = (H5F_t *)H5VL_object(file))) - FAIL_STACK_ERROR - if(H5AC_ignore_tags(f) < 0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } /* end if */ - - /* - * Test object header creation - * (using default group creation property list only because it's convenient) - */ - TESTING("object header creation"); - HDmemset(&oh_loc, 0, sizeof(oh_loc)); - if(H5O_create(f, (size_t)64, (size_t)0, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/) < 0) - FAIL_STACK_ERROR - PASSED(); + /* Create the file to operate on */ + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + if (NULL == (f = (H5F_t *)H5VL_object(file))) + FAIL_STACK_ERROR + if (H5AC_ignore_tags(f) < 0) { + H5_FAILED(); + H5Eprint2(H5E_DEFAULT, stdout); + goto error; + } /* end if */ + + /* + * Test object header creation + * (using default group creation property list only because it's convenient) + */ + TESTING("object header creation"); + HDmemset(&oh_loc, 0, sizeof(oh_loc)); + if (H5O_create(f, (size_t)64, (size_t)0, H5P_GROUP_CREATE_DEFAULT, &oh_loc /*out*/) < 0) + FAIL_STACK_ERROR + PASSED(); - /* create a new message */ - TESTING("message creation"); - time_new = 11111111; - if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) - FAIL_STACK_ERROR - if(1 != H5O_link(&oh_loc, 1)) - FAIL_STACK_ERROR - if(H5AC_flush(f) < 0) - FAIL_STACK_ERROR - if(H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) - FAIL_STACK_ERROR - if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro)) - FAIL_STACK_ERROR - if(ro != time_new) - TEST_ERROR - PASSED(); - - /* - * Test modification of an existing message. - */ - TESTING("message modification"); - time_new = 33333333; - if(H5O_msg_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) - FAIL_STACK_ERROR - if(H5AC_flush(f) < 0) - FAIL_STACK_ERROR - if(H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) - FAIL_STACK_ERROR - if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro)) - FAIL_STACK_ERROR - if(ro != time_new) - TEST_ERROR + /* create a new message */ + TESTING("message creation"); + time_new = 11111111; + if (H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) + FAIL_STACK_ERROR + if (1 != H5O_link(&oh_loc, 1)) + FAIL_STACK_ERROR + if (H5AC_flush(f) < 0) + FAIL_STACK_ERROR + if (H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) + FAIL_STACK_ERROR + if (NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro)) + FAIL_STACK_ERROR + if (ro != time_new) + TEST_ERROR + PASSED(); + + /* + * Test modification of an existing message. + */ + TESTING("message modification"); + time_new = 33333333; + if (H5O_msg_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) + FAIL_STACK_ERROR + if (H5AC_flush(f) < 0) + FAIL_STACK_ERROR + if (H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) + FAIL_STACK_ERROR + if (NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro)) + FAIL_STACK_ERROR + if (ro != time_new) + TEST_ERROR - /* Make certain that chunk #0 in the object header can be encoded with a 1-byte size */ - if(H5O_get_hdr_info(&oh_loc, &hdr_info) < 0) - FAIL_STACK_ERROR - if(hdr_info.space.total >=256) - TEST_ERROR + /* Make certain that chunk #0 in the object header can be encoded with a 1-byte size */ + if (H5O_get_hdr_info(&oh_loc, &hdr_info) < 0) + FAIL_STACK_ERROR + if (hdr_info.space.total >= 256) + TEST_ERROR - PASSED(); - - /* - * Test creation of a bunch of messages one after another to see - * what happens when the object header overflows in core. - * (Use 'old' MTIME message here, because it is large enough to be - * replaced with a continuation message (the new one is too small) - * and the library doesn't understand how to migrate more than one - * message from an object header currently - QAK - 10/8/03) - */ - TESTING("object header overflow in memory"); - for(i = 0; i < 40; i++) { - time_new = (i + 1) * 1000 + 1000000; - if(H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new) < 0) + PASSED(); + + /* + * Test creation of a bunch of messages one after another to see + * what happens when the object header overflows in core. + * (Use 'old' MTIME message here, because it is large enough to be + * replaced with a continuation message (the new one is too small) + * and the library doesn't understand how to migrate more than one + * message from an object header currently - QAK - 10/8/03) + */ + TESTING("object header overflow in memory"); + for (i = 0; i < 40; i++) { + time_new = (i + 1) * 1000 + 1000000; + if (H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new) < 0) + FAIL_STACK_ERROR + } /* end for */ + if (H5AC_flush(f) < 0) + FAIL_STACK_ERROR + if (H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) FAIL_STACK_ERROR - } /* end for */ - if(H5AC_flush(f) < 0) - FAIL_STACK_ERROR - if(H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) - FAIL_STACK_ERROR - /* Make certain that chunk #0 in the object header will be encoded with a 2-byte size */ - if(H5O_get_hdr_info(&oh_loc, &hdr_info) < 0) - FAIL_STACK_ERROR - if(hdr_info.space.total < 256) - TEST_ERROR + /* Make certain that chunk #0 in the object header will be encoded with a 2-byte size */ + if (H5O_get_hdr_info(&oh_loc, &hdr_info) < 0) + FAIL_STACK_ERROR + if (hdr_info.space.total < 256) + TEST_ERROR - PASSED(); + PASSED(); - /* Close & re-open file & object header */ - /* (makes certain that an object header in the new format that transitions - * between 1-byte chunk #0 size encoding and 2-byte chunk #0 size encoding - * works correctly - QAK) - */ - TESTING("close & re-open object header"); - if(H5O_close(&oh_loc, NULL) < 0) - FAIL_STACK_ERROR - if(H5Fclose(file) < 0) - FAIL_STACK_ERROR - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - if(NULL == (f = (H5F_t *)H5VL_object(file))) - FAIL_STACK_ERROR - if (H5AC_ignore_tags(f) < 0) - FAIL_STACK_ERROR - oh_loc.file = f; - if(H5O_open(&oh_loc) < 0) - FAIL_STACK_ERROR - PASSED(); - - /* - * Test creation of a bunch of messages one after another to see - * what happens when the object header overflows on disk. - */ - TESTING("object header overflow on disk"); - for(i = 0; i < 10; i++) { - time_new = (i + 1) * 1000 + 10; - if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) + /* Close & re-open file & object header */ + /* (makes certain that an object header in the new format that transitions + * between 1-byte chunk #0 size encoding and 2-byte chunk #0 size encoding + * works correctly - QAK) + */ + TESTING("close & re-open object header"); + if (H5O_close(&oh_loc, NULL) < 0) FAIL_STACK_ERROR - if(H5AC_flush(f) < 0) + if (H5Fclose(file) < 0) FAIL_STACK_ERROR - if(H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - } /* end for */ - PASSED(); - - /* - * Delete all time messages. - */ - TESTING("message deletion"); - if(H5O_msg_remove(&oh_loc, H5O_MTIME_NEW_ID, H5O_ALL, TRUE) < 0) - FAIL_STACK_ERROR - if(H5O_msg_remove(&oh_loc, H5O_MTIME_ID, H5O_ALL, TRUE) < 0) - FAIL_STACK_ERROR - if(H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro)) - FAIL_STACK_ERROR - if(H5O_msg_read(&oh_loc, H5O_MTIME_ID, &ro)) - FAIL_STACK_ERROR - PASSED(); - - - /* - * Constant message handling. - * (can't write to them, but should be able to remove them) - */ - TESTING("constant message handling"); - time_new = 22222222; - if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, H5O_MSG_FLAG_CONSTANT, 0, &time_new) < 0) - FAIL_STACK_ERROR - if(H5AC_flush(f) < 0) - FAIL_STACK_ERROR - if(H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) - FAIL_STACK_ERROR - if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro)) - FAIL_STACK_ERROR - if(ro != time_new) - TEST_ERROR - time_new = 33333333; - H5E_BEGIN_TRY { - ret = H5O_msg_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new); - } H5E_END_TRY; - if(ret >= 0) - TEST_ERROR - if(H5O_msg_remove(&oh_loc, H5O_MTIME_NEW_ID, H5O_ALL, TRUE) < 0) - FAIL_STACK_ERROR - PASSED(); - - - /* release resources */ - TESTING("object header closing"); - if(H5O_close(&oh_loc, NULL) < 0) - FAIL_STACK_ERROR - PASSED(); + if (NULL == (f = (H5F_t *)H5VL_object(file))) + FAIL_STACK_ERROR + if (H5AC_ignore_tags(f) < 0) + FAIL_STACK_ERROR + oh_loc.file = f; + if (H5O_open(&oh_loc) < 0) + FAIL_STACK_ERROR + PASSED(); + + /* + * Test creation of a bunch of messages one after another to see + * what happens when the object header overflows on disk. + */ + TESTING("object header overflow on disk"); + for (i = 0; i < 10; i++) { + time_new = (i + 1) * 1000 + 10; + if (H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new) < 0) + FAIL_STACK_ERROR + if (H5AC_flush(f) < 0) + FAIL_STACK_ERROR + if (H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) + FAIL_STACK_ERROR + } /* end for */ + PASSED(); + + /* + * Delete all time messages. + */ + TESTING("message deletion"); + if (H5O_msg_remove(&oh_loc, H5O_MTIME_NEW_ID, H5O_ALL, TRUE) < 0) + FAIL_STACK_ERROR + if (H5O_msg_remove(&oh_loc, H5O_MTIME_ID, H5O_ALL, TRUE) < 0) + FAIL_STACK_ERROR + if (H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro)) + FAIL_STACK_ERROR + if (H5O_msg_read(&oh_loc, H5O_MTIME_ID, &ro)) + FAIL_STACK_ERROR + PASSED(); + + /* + * Constant message handling. + * (can't write to them, but should be able to remove them) + */ + TESTING("constant message handling"); + time_new = 22222222; + if (H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, H5O_MSG_FLAG_CONSTANT, 0, &time_new) < 0) + FAIL_STACK_ERROR + if (H5AC_flush(f) < 0) + FAIL_STACK_ERROR + if (H5AC_expunge_entry(f, H5AC_OHDR, oh_loc.addr, H5AC__NO_FLAGS_SET) < 0) + FAIL_STACK_ERROR + if (NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro)) + FAIL_STACK_ERROR + if (ro != time_new) + TEST_ERROR + time_new = 33333333; + H5E_BEGIN_TRY + { + ret = H5O_msg_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new); + } + H5E_END_TRY; + if (ret >= 0) + TEST_ERROR + if (H5O_msg_remove(&oh_loc, H5O_MTIME_NEW_ID, H5O_ALL, TRUE) < 0) + FAIL_STACK_ERROR + PASSED(); - /* Close the file we created */ - if(H5Fclose(file) < 0) - TEST_ERROR + /* release resources */ + TESTING("object header closing"); + if (H5O_close(&oh_loc, NULL) < 0) + FAIL_STACK_ERROR + PASSED(); - /* Test reading datasets with undefined object header messages - * and the various "fail/mark if unknown" object header message flags - */ - HDputs("Accessing objects with unknown header messages: H5O_BOGUS_VALID_ID"); - if(single_file_vfd) { - if(test_unknown(H5O_BOGUS_VALID_ID, filename, fapl) < 0) + /* Close the file we created */ + if (H5Fclose(file) < 0) TEST_ERROR - } /* end if */ - else { - SKIPPED(); - HDputs(" Unknown header message test not supported with the current VFD."); - } /* end else */ - HDputs("Accessing objects with unknown header messages: H5O_BOGUS_INVALID_ID"); - if(single_file_vfd) { - if(test_unknown(H5O_BOGUS_INVALID_ID, filename, fapl) < 0) + + /* Test reading datasets with undefined object header messages + * and the various "fail/mark if unknown" object header message flags + */ + HDputs("Accessing objects with unknown header messages: H5O_BOGUS_VALID_ID"); + if (single_file_vfd) { + if (test_unknown(H5O_BOGUS_VALID_ID, filename, fapl) < 0) + TEST_ERROR + } /* end if */ + else { + SKIPPED(); + HDputs(" Unknown header message test not supported with the current VFD."); + } /* end else */ + HDputs("Accessing objects with unknown header messages: H5O_BOGUS_INVALID_ID"); + if (single_file_vfd) { + if (test_unknown(H5O_BOGUS_INVALID_ID, filename, fapl) < 0) + TEST_ERROR + } /* end if */ + else { + SKIPPED(); + HDputs(" Unknown header message test not supported with the current VFD."); + } /* end else */ + + /* Test object header creation metadata cache issues */ + if (test_ohdr_cache(filename, fapl) < 0) TEST_ERROR - } /* end if */ - else { - SKIPPED(); - HDputs(" Unknown header message test not supported with the current VFD."); - } /* end else */ - - /* Test object header creation metadata cache issues */ - if(test_ohdr_cache(filename, fapl) < 0) - TEST_ERROR - if(test_minimized_dset_ohdr_attribute_addition(fapl) < 0) - TEST_ERROR + if (test_minimized_dset_ohdr_attribute_addition(fapl) < 0) + TEST_ERROR - if(test_minimized_dset_ohdr_size_comparisons(fapl) < 0) - TEST_ERROR + if (test_minimized_dset_ohdr_size_comparisons(fapl) < 0) + TEST_ERROR - if(test_minimized_dset_ohdr_with_filter(fapl) < 0) - TEST_ERROR + if (test_minimized_dset_ohdr_with_filter(fapl) < 0) + TEST_ERROR - if(test_minimized_dset_ohdr_modification_times(fapl) < 0) - TEST_ERROR + if (test_minimized_dset_ohdr_modification_times(fapl) < 0) + TEST_ERROR - if(test_minimized_dset_ohdr_fillvalue_backwards_compatability(fapl) < 0) - TEST_ERROR + if (test_minimized_dset_ohdr_fillvalue_backwards_compatability(fapl) < 0) + TEST_ERROR - } /* high */ - } /* low */ + } /* high */ + } /* low */ /* Verify symbol table messages are cached */ - if(h5_verify_cached_stabs(FILENAME, fapl) < 0) TEST_ERROR + if (h5_verify_cached_stabs(FILENAME, fapl) < 0) + TEST_ERROR /* A test to exercise the re-read of the object header for SWMR access */ - if(test_ohdr_swmr(TRUE) < 0) TEST_ERROR - if(test_ohdr_swmr(FALSE) < 0) TEST_ERROR + if (test_ohdr_swmr(TRUE) < 0) + TEST_ERROR + if (test_ohdr_swmr(FALSE) < 0) + TEST_ERROR /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; HDputs("All object header tests passed."); @@ -1892,12 +2044,14 @@ main(void) error: HDputs("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); return 1; } /* end main() */ - diff --git a/test/page_buffer.c b/test/page_buffer.c index 4526410..84e6c33 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -12,12 +12,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: cache_page_buffer -* -* Tests the Page Buffer Feature. -* -*************************************************************/ + * + * Test program: cache_page_buffer + * + * Tests the Page Buffer Feature. + * + *************************************************************/ #include "h5test.h" @@ -25,33 +25,31 @@ * This file needs to access private information from the H5C package. * This file also needs to access the metadata cache testing code. */ -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5C_TESTING /*suppress warning about H5C testing funcs*/ -#include "H5Cpkg.h" /* Cache */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5C_TESTING /*suppress warning about H5C testing funcs*/ +#include "H5Cpkg.h" /* Cache */ - -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Iprivate.h" #include "H5PBprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* * This file needs to access private information from the H5F package. */ -#define H5MF_FRIEND /*suppress error about including H5MFpkg */ +#define H5MF_FRIEND /*suppress error about including H5MFpkg */ #include "H5MFpkg.h" -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING #include "H5Fpkg.h" - -#define FILENAME_LEN 1024 +#define FILENAME_LEN 1024 #ifndef H5_HAVE_PARALLEL -#define NUM_DSETS 5 -#define NX 100 -#define NY 50 +#define NUM_DSETS 5 +#define NX 100 +#define NY 50 #endif /* helper routines */ @@ -62,28 +60,24 @@ static unsigned open_file(char *filename, hid_t fapl, hsize_t page_size, size_t /* test routines */ #ifdef H5_HAVE_PARALLEL -static unsigned verify_page_buffering_disabled(hid_t orig_fapl, - const char *env_h5_drvr); +static unsigned verify_page_buffering_disabled(hid_t orig_fapl, const char *env_h5_drvr); #else static unsigned test_args(hid_t fapl, const char *env_h5_drvr); -static unsigned test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, - bool); +static unsigned test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, bool); static unsigned test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr); static unsigned test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr); static unsigned test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr); -static unsigned md_entry_splitting_smoke_check(hid_t orig_fapl, - const char *env_h5_drvr, bool); -static unsigned md_entry_splitting_boundary_test(hid_t orig_fapl, - const char *env_h5_drvr, bool); +static unsigned md_entry_splitting_smoke_check(hid_t orig_fapl, const char *env_h5_drvr, bool); +static unsigned md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, bool); #endif /* H5_HAVE_PARALLEL */ #define FILENAME "filepaged" static const char *namebases[] = {FILENAME, NULL}; -static const char *namebase = FILENAME; +static const char *namebase = FILENAME; static hid_t paging_fcpl_create(const hsize_t pgsz) -{ +{ hid_t fcpl = H5I_INVALID_HID; if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) @@ -103,15 +97,13 @@ error: static int swmr_fapl_augment(hid_t fapl, const char *filename, uint32_t max_lag) { - H5F_vfd_swmr_config_t config = { - .version = H5F__CURR_VFD_SWMR_CONFIG_VERSION - , .tick_len = 4 - , .max_lag = max_lag - , .writer = true - , .md_pages_reserved = 128 - }; - char *bname = NULL; - char *dname = NULL; + H5F_vfd_swmr_config_t config = {.version = H5F__CURR_VFD_SWMR_CONFIG_VERSION, + .tick_len = 4, + .max_lag = max_lag, + .writer = true, + .md_pages_reserved = 128}; + char * bname = NULL; + char * dname = NULL; if (H5_dirname(filename, &dname) < 0) { HDfprintf(stderr, "H5_dirname() failed\n"); @@ -121,13 +113,12 @@ swmr_fapl_augment(hid_t fapl, const char *filename, uint32_t max_lag) HDfprintf(stderr, "H5_basename() failed\n"); return -1; } - HDsnprintf(config.md_file_path, sizeof(config.md_file_path), - "%s/%s.shadow", dname, bname); + HDsnprintf(config.md_file_path, sizeof(config.md_file_path), "%s/%s.shadow", dname, bname); HDfree(dname); HDfree(bname); /* Enable VFD SWMR configuration */ - if(H5Pset_vfd_swmr_config(fapl, &config) < 0) { + if (H5Pset_vfd_swmr_config(fapl, &config) < 0) { HDfprintf(stderr, "H5Pset_vrd_swmr_config failed\n"); return -1; } @@ -135,8 +126,7 @@ swmr_fapl_augment(hid_t fapl, const char *filename, uint32_t max_lag) } static bool -pgbuf_read_each_equals(H5F_t *f, H5FD_mem_t ty, haddr_t addr, size_t nelts, - int *data, int val) +pgbuf_read_each_equals(H5F_t *f, H5FD_mem_t ty, haddr_t addr, size_t nelts, int *data, int val) { size_t i; @@ -146,8 +136,7 @@ pgbuf_read_each_equals(H5F_t *f, H5FD_mem_t ty, haddr_t addr, size_t nelts, for (i = 0; i < nelts; i++) { if (data[i] != val) { - printf("%s: read %d at data[%zu], expected %d\n", __func__, - data[i], i, val); + printf("%s: read %d at data[%zu], expected %d\n", __func__, data[i], i, val); return false; } } @@ -157,8 +146,7 @@ error: } static bool -vfd_read_each_equals(H5F_t *f, H5FD_mem_t ty, haddr_t addr, size_t nelts, - int *data, int val) +vfd_read_each_equals(H5F_t *f, H5FD_mem_t ty, haddr_t addr, size_t nelts, int *data, int val) { size_t i; @@ -181,7 +169,7 @@ error: } #ifndef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: create_file() * @@ -207,123 +195,124 @@ error: static unsigned create_file(char *filename, hid_t fcpl, hid_t fapl) { - hid_t file_id = -1; - hid_t dset_id = -1; - hid_t grp_id = -1; - hid_t filespace = -1; - hsize_t dimsf[2] = {NX, NY}; /* dataset dimensions */ - int *data = NULL; /* pointer to data buffer to write */ - hid_t dcpl = -1; - int i; - int num_elements; - int j; - char dset_name[32]; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t grp_id = -1; + hid_t filespace = -1; + hsize_t dimsf[2] = {NX, NY}; /* dataset dimensions */ + int * data = NULL; /* pointer to data buffer to write */ + hid_t dcpl = -1; + int i; + int num_elements; + int j; + char dset_name[32]; - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; - if((grp_id = H5Gcreate2(file_id, "GROUP", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((grp_id = H5Gcreate2(file_id, "GROUP", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - num_elements = NX * NY; - if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + num_elements = NX * NY; + if ((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) TEST_ERROR - for (i=0; i < (int)num_elements; i++) + for (i = 0; i < (int)num_elements; i++) data[i] = i; - if((filespace = H5Screate_simple(2, dimsf, NULL)) < 0) + if ((filespace = H5Screate_simple(2, dimsf, NULL)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) FAIL_STACK_ERROR; - for(i=0 ; ishared->pb_ptr == NULL) + if (f->shared->pb_ptr == NULL) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->page_size != page_size) + if (f->shared->pb_ptr->page_size != page_size) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->max_size != page_buffer_size) + if (f->shared->pb_ptr->max_size != page_buffer_size) FAIL_STACK_ERROR; - if((grp_id = H5Gopen2(file_id, "GROUP", H5P_DEFAULT)) < 0) + if ((grp_id = H5Gopen2(file_id, "GROUP", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - num_elements = NX * NY; - if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + num_elements = NX * NY; + if ((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) TEST_ERROR - for(i=0 ; i= 0) + if (file_id >= 0) TEST_ERROR; - /* Test setting a page buffer with a size smaller than a single * page size - should fail */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) TEST_ERROR; - if(H5Pset_file_space_page_size(fcpl, 512) < 0) + if (H5Pset_file_space_page_size(fcpl, 512) < 0) TEST_ERROR; - if(H5Pset_page_buffer_size(fapl, 511, 0, 0) < 0) + if (H5Pset_page_buffer_size(fapl, 511, 0, 0) < 0) TEST_ERROR; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(file_id >= 0) + if (file_id >= 0) TEST_ERROR; - /* Test setting a page buffer with sum of min meta and raw * data percentage > 100 - should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_page_buffer_size(fapl, 512, 50, 51); - } H5E_END_TRY; + } + H5E_END_TRY; - if(ret >= 0) + if (ret >= 0) TEST_ERROR; - if(set_multi_split(env_h5_drvr, fapl, 512) != 0) + if (set_multi_split(env_h5_drvr, fapl, 512) != 0) TEST_ERROR; /* Test setting a page buffer with a size equal to a single page size */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) TEST_ERROR; - if(H5Pset_file_space_page_size(fcpl, 512) < 0) + if (H5Pset_file_space_page_size(fcpl, 512) < 0) TEST_ERROR; - if(H5Pset_page_buffer_size(fapl, 512, 0, 0) < 0) + if (H5Pset_page_buffer_size(fapl, 512, 0, 0) < 0) TEST_ERROR; - if(create_file(filename, fcpl, fapl) != 0) + if (create_file(filename, fcpl, fapl) != 0) TEST_ERROR; - if(open_file(filename, fapl, 512, 512) != 0) + if (open_file(filename, fapl, 512, 512) != 0) TEST_ERROR; - /* Test setting a page buffer with a size slightly larger than a * single page size */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) TEST_ERROR; - if(H5Pset_file_space_page_size(fcpl, 512) < 0) + if (H5Pset_file_space_page_size(fcpl, 512) < 0) TEST_ERROR; - if(H5Pset_page_buffer_size(fapl, 513, 0, 0) < 0) + if (H5Pset_page_buffer_size(fapl, 513, 0, 0) < 0) TEST_ERROR; - if(create_file(filename, fcpl, fapl) != 0) + if (create_file(filename, fcpl, fapl) != 0) TEST_ERROR; - if(open_file(filename, fapl, 512, 512) != 0) + if (open_file(filename, fapl, 512, 512) != 0) TEST_ERROR; - if(set_multi_split(env_h5_drvr, fapl, 4194304) != 0) + if (set_multi_split(env_h5_drvr, fapl, 4194304) != 0) TEST_ERROR; - /* Test setting a large page buffer size and page size */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) TEST_ERROR; - if(H5Pset_file_space_page_size(fcpl, 4194304) < 0) + if (H5Pset_file_space_page_size(fcpl, 4194304) < 0) TEST_ERROR; - if(H5Pset_page_buffer_size(fapl, 16777216, 0, 0) < 0) + if (H5Pset_page_buffer_size(fapl, 16777216, 0, 0) < 0) TEST_ERROR; - if(create_file(filename, fcpl, fapl) != 0) + if (create_file(filename, fcpl, fapl) != 0) TEST_ERROR; - if(open_file(filename, fapl, 4194304, 16777216) != 0) + if (open_file(filename, fapl, 4194304, 16777216) != 0) TEST_ERROR; - if(set_multi_split(env_h5_drvr, fapl, 1) != 0) + if (set_multi_split(env_h5_drvr, fapl, 1) != 0) TEST_ERROR; - /* Test setting a 512 byte page buffer size and page size */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) TEST_ERROR; - if(H5Pset_file_space_page_size(fcpl, 512) < 0) + if (H5Pset_file_space_page_size(fcpl, 512) < 0) TEST_ERROR; - if(H5Pset_page_buffer_size(fapl, 512, 0, 0) < 0) + if (H5Pset_page_buffer_size(fapl, 512, 0, 0) < 0) TEST_ERROR; - if(create_file(filename, fcpl, fapl) != 0) + if (create_file(filename, fcpl, fapl) != 0) TEST_ERROR; - if(open_file(filename, fapl, 512, 512) != 0) + if (open_file(filename, fapl, 512, 512) != 0) TEST_ERROR; - - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_args */ - /* * Function: test_mpmde_delay_basic() * @@ -681,16 +673,16 @@ error: static unsigned test_mpmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - size_t i, num_elements = 2000; - int *data = NULL, *odata = NULL; - H5F_t *f; + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + size_t i, num_elements = 2000; + int * data = NULL, *odata = NULL; + H5F_t * f; const uint32_t max_lag = 5; - hsize_t pgsz = sizeof(int) * 200; - haddr_t addr; + hsize_t pgsz = sizeof(int) * 200; + haddr_t addr; TESTING("Multipage Metadata Delay Handling"); @@ -733,11 +725,10 @@ test_mpmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; /* initialize all the elements to have a value of -1 */ - for(i = 0; i < num_elements; i++) + for (i = 0; i < num_elements; i++) odata[i] = -1; - if (H5F_block_write(f, H5FD_MEM_BTREE, addr, sizeof(int) * num_elements, - odata) < 0) + if (H5F_block_write(f, H5FD_MEM_BTREE, addr, sizeof(int) * num_elements, odata) < 0) FAIL_STACK_ERROR; /* H5Fvfd_swmr_end_tick() processes delayed writes before it increases @@ -746,8 +737,7 @@ test_mpmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) */ for (i = 0; i < max_lag + 1; i++) { /* All elements read using the VFD should be 0. */ - if (!vfd_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, - data, 0)) + if (!vfd_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, data, 0)) TEST_ERROR; H5Fvfd_swmr_end_tick(file_id); } @@ -782,7 +772,8 @@ test_mpmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) @@ -793,12 +784,12 @@ error: HDfree(data); if (odata != NULL) HDfree(odata); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_mpmde_delay_basic() */ - /* * Function: test_spmde_lru_evict_basic() * @@ -827,20 +818,20 @@ error: static unsigned test_spmde_lru_evict_basic(hid_t orig_fapl, const char *env_h5_drvr) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - size_t i, num_elements = 20; - int *data = NULL, *odata = NULL; - H5F_t *f; + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + size_t i, num_elements = 20; + int * data = NULL, *odata = NULL; + H5F_t * f; const uint32_t max_lag = 5; - const hsize_t pgsz = sizeof(int) * 200; - const hsize_t pgbufsz = 10 * pgsz; - hsize_t ofs; - bool flushed; - haddr_t addr; - haddr_t pressure; + const hsize_t pgsz = sizeof(int) * 200; + const hsize_t pgbufsz = 10 * pgsz; + hsize_t ofs; + bool flushed; + haddr_t addr; + haddr_t pressure; TESTING("Single Page Metadata Flush & Eviction Handling"); @@ -889,11 +880,10 @@ test_spmde_lru_evict_basic(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; /* initialize all the elements to have a value of -1 */ - for(i = 0; i < num_elements; i++) + for (i = 0; i < num_elements; i++) odata[i] = -1; - if (H5F_block_write(f, H5FD_MEM_BTREE, addr, sizeof(int) * num_elements, - odata) < 0) + if (H5F_block_write(f, H5FD_MEM_BTREE, addr, sizeof(int) * num_elements, odata) < 0) FAIL_STACK_ERROR; /* H5Fvfd_swmr_end_tick() processes delayed writes before it increases @@ -902,8 +892,7 @@ test_spmde_lru_evict_basic(hid_t orig_fapl, const char *env_h5_drvr) */ for (i = 0; i < max_lag + 1; i++) { /* All elements read using the VFD should be 0. */ - if (!vfd_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, - data, 0)) + if (!vfd_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, data, 0)) TEST_ERROR; H5Fvfd_swmr_end_tick(file_id); } @@ -918,12 +907,9 @@ test_spmde_lru_evict_basic(hid_t orig_fapl, const char *env_h5_drvr) */ for (ofs = 0; ofs < pgbufsz - pgsz * 2; ofs += pgsz) { int tmp = -1; - if (H5F_block_write(f, H5FD_MEM_BTREE, pressure + ofs, - sizeof(tmp), &tmp) < 0) + if (H5F_block_write(f, H5FD_MEM_BTREE, pressure + ofs, sizeof(tmp), &tmp) < 0) FAIL_STACK_ERROR; - if (!flushed && - vfd_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, - data, -1)) { + if (!flushed && vfd_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, data, -1)) { flushed = true; #if 0 printf("Writing page %" PRIuHSIZE " flushed target page.\n", @@ -936,18 +922,16 @@ test_spmde_lru_evict_basic(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; /* initialize all the elements to have a value of -2 */ - for(i = 0; i < num_elements; i++) + for (i = 0; i < num_elements; i++) odata[i] = -2; /* Write -2 to our target page using the VFD. */ - if (H5FD_write(f->shared->lf, H5FD_MEM_BTREE, addr, - sizeof(int) * num_elements, odata) < 0) + if (H5FD_write(f->shared->lf, H5FD_MEM_BTREE, addr, sizeof(int) * num_elements, odata) < 0) FAIL_STACK_ERROR; /* All elements read through the page buffer should be -2. That is, * no page-buffer entry should shadow the page. */ - if (!pgbuf_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, data, - -2)) + if (!pgbuf_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, data, -2)) TEST_ERROR; /* Force ticks to occur so that H5Fclose() doesn't pause waiting @@ -969,7 +953,8 @@ test_spmde_lru_evict_basic(hid_t orig_fapl, const char *env_h5_drvr) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) @@ -980,12 +965,12 @@ error: HDfree(data); if (odata != NULL) HDfree(odata); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_spmde_lru_evict_basic() */ - /* * Function: test_spmde_delay_basic() * @@ -1011,16 +996,16 @@ error: static unsigned test_spmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - size_t i, num_elements = 20; - int *data = NULL, *odata = NULL; - H5F_t *f; + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + size_t i, num_elements = 20; + int * data = NULL, *odata = NULL; + H5F_t * f; const uint32_t max_lag = 5; - hsize_t pgsz = sizeof(int) * 200; - haddr_t addr; + hsize_t pgsz = sizeof(int) * 200; + haddr_t addr; TESTING("Single Page Metadata Delay Handling"); @@ -1051,8 +1036,7 @@ test_spmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; - addr = H5MF_alloc(f, H5FD_MEM_BTREE, - sizeof(int) * num_elements); + addr = H5MF_alloc(f, H5FD_MEM_BTREE, sizeof(int) * num_elements); /* allocate space for 2000 elements */ if (HADDR_UNDEF == addr) FAIL_STACK_ERROR; @@ -1064,11 +1048,10 @@ test_spmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; /* initialize all the elements to have a value of -1 */ - for(i = 0; i < num_elements; i++) + for (i = 0; i < num_elements; i++) odata[i] = -1; - if (H5F_block_write(f, H5FD_MEM_BTREE, addr, sizeof(int) * num_elements, - odata) < 0) + if (H5F_block_write(f, H5FD_MEM_BTREE, addr, sizeof(int) * num_elements, odata) < 0) FAIL_STACK_ERROR; /* H5Fvfd_swmr_end_tick() processes delayed writes before it increases @@ -1077,8 +1060,7 @@ test_spmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) */ for (i = 0; i < max_lag + 1; i++) { /* All elements read using the VFD should be 0. */ - if (!vfd_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, - data, 0)) + if (!vfd_read_each_equals(f, H5FD_MEM_BTREE, addr, num_elements, data, 0)) TEST_ERROR; H5Fvfd_swmr_end_tick(file_id); } @@ -1107,7 +1089,8 @@ test_spmde_delay_basic(hid_t orig_fapl, const char *env_h5_drvr) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) @@ -1118,12 +1101,12 @@ error: HDfree(data); if (odata != NULL) HDfree(odata); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_spmde_delay_basic() */ - /* * Function: test_raw_data_handling() * @@ -1150,40 +1133,39 @@ error: * * JRM -- 2/23/17 * - * Minor changes to adapt to re-implementation of the + * Minor changes to adapt to re-implementation of the * page buffer. * * JRM -- 10/26/18 * * We have decided not to buffer raw data in the page buffer - * when operating in VFD SWMR mode. This is necessary as + * when operating in VFD SWMR mode. This is necessary as * otherwise raw data can get stuck in the page buffer, thus - * delaying it's visibility to the reader. + * delaying it's visibility to the reader. * - * Obviously, there is a potential performance trade off - * here, but it shouldn't be significant in the expected + * Obviously, there is a potential performance trade off + * here, but it shouldn't be significant in the expected * VFD SWMR use cases. Needless to say, we will revisit this * if necessary. * * JRM -- 4/8/20 - * + * */ /* Changes due to file space page size has a minimum size of 512 */ static unsigned -test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, - bool vfd_swmr_mode) +test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, bool vfd_swmr_mode) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - int64_t base_page_cnt; - int64_t page_count = 0; - int i, num_elements = 2000; - haddr_t addr = HADDR_UNDEF; - int *data = NULL; - H5F_t *f = NULL; + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + int64_t base_page_cnt; + int64_t page_count = 0; + int i, num_elements = 2000; + haddr_t addr = HADDR_UNDEF; + int * data = NULL; + H5F_t * f = NULL; const uint32_t max_lag = 5; TESTING("%sRaw Data Handling", vfd_swmr_mode ? "VFD SWMR " : ""); @@ -1211,7 +1193,7 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; /* opening the file inserts one or more pages into the page buffer. @@ -1223,101 +1205,89 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, TEST_ERROR; /* allocate space for 2000 elements */ - if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_DRAW, - sizeof(int) * (size_t)num_elements))) + if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; if ((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) TEST_ERROR; /* initialize all the elements to have a value of -1 */ - for(i=0 ; ishared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) FAIL_STACK_ERROR; /* update elements 300 - 450, with values 300 - - this will bring two more pages into the page buffer. */ - for(i=0 ; i<150 ; i++) - data[i] = i+300; + for (i = 0; i < 150; i++) + data[i] = i + 300; - if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 300), - sizeof(int) * 150, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 300), sizeof(int) * 150, data) < 0) FAIL_STACK_ERROR; page_count += 2; - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) FAIL_STACK_ERROR; /* update elements 100 - 300, this will go to disk but also update existing pages in the page buffer. */ - for(i=0 ; i<200 ; i++) - data[i] = i+100; + for (i = 0; i < 200; i++) + data[i] = i + 100; - if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 100), - sizeof(int) * 200, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 100), sizeof(int) * 200, data) < 0) FAIL_STACK_ERROR; - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) FAIL_STACK_ERROR; /* Update elements 225-300 - this will update an existing page in the PB */ /* Changes: 450 - 600; 150 */ - for(i=0 ; i<150 ; i++) - data[i] = i+450; + for (i = 0; i < 150; i++) + data[i] = i + 450; - if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 450), - sizeof(int) * 150, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 450), sizeof(int) * 150, data) < 0) FAIL_STACK_ERROR; - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) FAIL_STACK_ERROR; /* Do a full page write to block 600-800 - should bypass the PB */ - for(i=0 ; i<200 ; i++) - data[i] = i+600; + for (i = 0; i < 200; i++) + data[i] = i + 600; - if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 600), - sizeof(int) * 200, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 600), sizeof(int) * 200, data) < 0) FAIL_STACK_ERROR; - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) FAIL_STACK_ERROR; - /* read elements 800 - 1200, this should not affect the PB, and should - * read -1s + /* read elements 800 - 1200, this should not affect the PB, and should + * read -1s */ - if (H5F_block_read(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 800), - sizeof(int) * 400, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 800), sizeof(int) * 400, data) < 0) FAIL_STACK_ERROR; - for (i=0; i < 400; i++) { + for (i = 0; i < 400; i++) { if (data[i] != -1) { HDfprintf(stderr, "Read different values than written\n"); HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], -1); @@ -1325,80 +1295,71 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, } } - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) FAIL_STACK_ERROR; /* read elements 1200 - 1201, this should read -1 and bring in an * entire page of addr 1200 */ - if (H5F_block_read(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 1200), - sizeof(int) * 1, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 1200), sizeof(int) * 1, data) < 0) FAIL_STACK_ERROR; - for (i=0; i < 1; i++) { + for (i = 0; i < 1; i++) { if (data[i] != -1) { HDfprintf(stderr, "Read different values than written\n"); HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], -1); TEST_ERROR; } } - page_count ++; + page_count++; - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) TEST_ERROR; /* read elements 175 - 225, this should use the PB existing pages */ /* Changes: 350 - 450 */ /* read elements 175 - 225, this should use the PB existing pages */ - if (H5F_block_read(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 350), - sizeof(int) * 100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 350), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - for (i=0; i < 100; i++) { + for (i = 0; i < 100; i++) { if (data[i] != i + 350) { HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], - i + 350); + HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], i + 350); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) TEST_ERROR; - /* read elements 0 - 800 using the VFD. + /* read elements 0 - 800 using the VFD. * * In the non-VFD SWMR case, this should result in -1s - * except for the writes that went through the PB (100-300 & 600-800) + * except for the writes that went through the PB (100-300 & 600-800) * * In the VFD SWMR case, the page buffer is bypassed for raw data, * thus all writes should be visible. */ - if (H5FD_read(f->shared->lf, H5FD_MEM_DRAW, addr, - sizeof(int) * 800, data) < 0) + if (H5FD_read(f->shared->lf, H5FD_MEM_DRAW, addr, sizeof(int) * 800, data) < 0) FAIL_STACK_ERROR; i = 0; while (i < 800) { - if((vfd_swmr_mode) || (i>=100 && i<300) || i >= 600) { + if ((vfd_swmr_mode) || (i >= 100 && i < 300) || i >= 600) { if (data[i] != i) { HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], i); + HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], i); TEST_ERROR; } } else { if (data[i] != -1) { HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], -1); + HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], -1); TEST_ERROR; } } @@ -1411,16 +1372,14 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_DRAW, addr, sizeof(int) * 800, data) < 0) FAIL_STACK_ERROR; - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) TEST_ERROR; - for (i=0; i < 800; i++) { + for (i = 0; i < 800; i++) { if (data[i] != i) { HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], i); + HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], i); TEST_ERROR; } } @@ -1429,18 +1388,16 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, * also evict existing pages from the PB (page 400 & 1200 that are * existing). */ - for(i=0 ; i<1000 ; i++) + for (i = 0; i < 1000; i++) data[i] = 0; - if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 400), - sizeof(int) * 1000, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 400), sizeof(int) * 1000, data) < 0) FAIL_STACK_ERROR; page_count -= 2; - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) TEST_ERROR; /* read elements 0 - 1000.. this should go to disk then update the @@ -1449,30 +1406,27 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_DRAW, addr, sizeof(int) * 1000, data) < 0) FAIL_STACK_ERROR; - i=0; + i = 0; while (i < 1000) { - if(i<400) { + if (i < 400) { if (data[i] != i) { HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], i); + HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], i); TEST_ERROR; } } else { if (data[i] != 0) { HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], 0); + HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], 0); TEST_ERROR; } } i++; } - if ( ( f->shared->pb_ptr->curr_pages != page_count + base_page_cnt ) && - ( ( vfd_swmr_mode ) && - ( f->shared->pb_ptr->curr_pages != base_page_cnt ) ) ) + if ((f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) && + ((vfd_swmr_mode) && (f->shared->pb_ptr->curr_pages != base_page_cnt))) TEST_ERROR; if (H5Fclose(file_id) < 0) @@ -1487,7 +1441,8 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) @@ -1496,11 +1451,11 @@ error: H5Fclose(file_id); if (data != NULL) HDfree(data); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_raw_data_handling */ - /*------------------------------------------------------------------------- * Function: test_lru_processing() * @@ -1515,9 +1470,9 @@ error: * * Programmer: unknown * ?? / ?? / ?? - * - * Changes: Reworked for new implementation of page buffer. Major - * change was adaption to the new implementation's greater + * + * Changes: Reworked for new implementation of page buffer. Major + * change was adaption to the new implementation's greater * respect for max_pages. * * JRM -- 10/26/18 @@ -1529,62 +1484,60 @@ error: static unsigned test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) { - char filename[FILENAME_LEN]; /* Filename to use */ + char filename[FILENAME_LEN]; /* Filename to use */ hbool_t page_exists; - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - int i; - int num_elements = 2000; - haddr_t addr = HADDR_UNDEF; - haddr_t search_addr = HADDR_UNDEF; - int *data = NULL; - H5F_t *f = NULL; + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + int i; + int num_elements = 2000; + haddr_t addr = HADDR_UNDEF; + haddr_t search_addr = HADDR_UNDEF; + int * data = NULL; + H5F_t * f = NULL; TESTING("LRU Processing"); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); - if((fapl = H5Pcopy(orig_fapl)) < 0) + if ((fapl = H5Pcopy(orig_fapl)) < 0) FAIL_STACK_ERROR - if(set_multi_split(env_h5_drvr, fapl, sizeof(int)*200) != 0) + if (set_multi_split(env_h5_drvr, fapl, sizeof(int) * 200) != 0) TEST_ERROR; - if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + if ((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) TEST_ERROR; - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, sizeof(int)*200) < 0) + if (H5Pset_file_space_page_size(fcpl, sizeof(int) * 200) < 0) FAIL_STACK_ERROR; /* keep 2 pages at max in the page buffer */ - if(H5Pset_page_buffer_size(fapl, sizeof(int)*400, 20, 0) < 0) + if (H5Pset_page_buffer_size(fapl, sizeof(int) * 400, 20, 0) < 0) FAIL_STACK_ERROR; - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; /* allocate space for 2000 elements */ - if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_DRAW, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; /* initialize all the elements to have a value of -1 */ - for(i=0 ; ishared, search_addr, &page_exists) < 0) || (!page_exists)) + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; if (f->shared->pb_ptr->curr_rd_pages != 1) FAIL_STACK_ERROR; - /* update elements 300 - 450, with values 300 - 449 - this will - * bring two pages (addr + 200 & addr + 400) into the page buffer and - * evict addr + 0. + * bring two pages (addr + 200 & addr + 400) into the page buffer and + * evict addr + 0. */ - for(i=0 ; i<150 ; i++) - data[i] = i+300; + for (i = 0; i < 150; i++) + data[i] = i + 300; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*300), - sizeof(int)*150, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 300), sizeof(int) * 150, data) < 0) FAIL_STACK_ERROR; /* verify that addr + 200 and addr + 400 are the only raw data pages in * the page buffer. */ - search_addr = addr + sizeof(int)*200; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 200; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; - search_addr = addr + sizeof(int)*400; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 400; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; if (f->shared->pb_ptr->curr_rd_pages != 2) FAIL_STACK_ERROR; @@ -1634,41 +1585,38 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) /* at this point, the page buffer entries created at file open should * have been evicted. */ - if(f->shared->pb_ptr->curr_md_pages != 0) + if (f->shared->pb_ptr->curr_md_pages != 0) FAIL_STACK_ERROR; - - /* update elements 300-301, this will update page addr + 200 in - * page buffer and move it to the top of the LRU. + /* update elements 300-301, this will update page addr + 200 in + * page buffer and move it to the top of the LRU. */ - for(i=0 ; i<1 ; i++) - data[i] = i+300; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*300), - sizeof(int)*2, data) < 0) + for (i = 0; i < 1; i++) + data[i] = i + 300; + if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 300), sizeof(int) * 2, data) < 0) FAIL_STACK_ERROR; /* verify that addr + 200 and addr + 400 are the only raw data pages in * the page buffer. */ - search_addr = addr + sizeof(int)*200; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 200; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; - search_addr = addr + sizeof(int)*400; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 400; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; if (f->shared->pb_ptr->curr_rd_pages != 2) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 2) + if (f->shared->pb_ptr->curr_pages != 2) FAIL_STACK_ERROR; - /* read elements 1200 - 1201, this should read -1, bring in page + /* read elements 1200 - 1201, this should read -1, bring in page * addr + 1200, and evict page addr + 400 */ - if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*1200), - sizeof(int)*1, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 1200), sizeof(int) * 1, data) < 0) FAIL_STACK_ERROR; - for (i=0; i < 1; i++) { - if(data[i] != -1) { + for (i = 0; i < 1; i++) { + if (data[i] != -1) { HDfprintf(stderr, "Read different values than written\n"); HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], -1); TEST_ERROR; @@ -1678,28 +1626,26 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) /* verify that addr + 200 and addr + 1200 are the only raw data pages in * the page buffer. */ - search_addr = addr + sizeof(int)*200; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 200; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; - search_addr = addr + sizeof(int)*1200; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 1200; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; if (f->shared->pb_ptr->curr_rd_pages != 2) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 2) + if (f->shared->pb_ptr->curr_pages != 2) FAIL_STACK_ERROR; /* read elements 350 - 450, this should load page addr + 400 and move * it to the top of the LRU, and evict page addr + 1200. - */ - if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*350), - sizeof(int)*100, data) < 0) + */ + if (H5F_block_read(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 350), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - for (i=0; i < 100; i++) { - if(data[i] != i+350) { + for (i = 0; i < 100; i++) { + if (data[i] != i + 350) { HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], - i + 350); + HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], i + 350); TEST_ERROR; } } @@ -1707,42 +1653,40 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) /* verify that addr + 200 and addr + 400 are the only raw data pages in * the page buffer. */ - search_addr = addr + sizeof(int)*200; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 200; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; - search_addr = addr + sizeof(int)*400; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 400; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; if (f->shared->pb_ptr->curr_rd_pages != 2) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 2) + if (f->shared->pb_ptr->curr_pages != 2) FAIL_STACK_ERROR; - - /* update elements 400 - 1400 to value 0, this will overwrite and + /* update elements 400 - 1400 to value 0, this will overwrite and * evict page addr + 400. */ - for(i=0 ; i<1000 ; i++) + for (i = 0; i < 1000; i++) data[i] = 0; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*400), - sizeof(int)*1000, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, addr + (sizeof(int) * 400), sizeof(int) * 1000, data) < 0) FAIL_STACK_ERROR; /* verify that addr + 200 is the only raw data page in the page buffer. */ - search_addr = addr + sizeof(int)*200; - if((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) + search_addr = addr + sizeof(int) * 200; + if ((H5PB_page_exists(f->shared, search_addr, &page_exists) < 0) || (!page_exists)) FAIL_STACK_ERROR; if (f->shared->pb_ptr->curr_rd_pages != 1) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 1) + if (f->shared->pb_ptr->curr_pages != 1) FAIL_STACK_ERROR; - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; HDfree(data); @@ -1750,7 +1694,8 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) @@ -1759,11 +1704,11 @@ error: H5Fclose(file_id); if (data != NULL) HDfree(data); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_lru_processing */ - /*------------------------------------------------------------------------- * Function: test_min_threshold() * @@ -1793,9 +1738,9 @@ error: * JRM -- 2/23/17 * * Reworked test for new implementatin of the page buffer. - * The major change was adapting the test for the new + * The major change was adapting the test for the new * page buffers refusal to buffer any raw data when - * min_md_pages == max_pages, or any metadata pages wwhen + * min_md_pages == max_pages, or any metadata pages wwhen * min_rd_pages == max_pages. * * JRM -- 10/27/18 @@ -1806,54 +1751,54 @@ error: static unsigned test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - int64_t base_raw_cnt = 0; + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + int64_t base_raw_cnt = 0; int64_t base_meta_cnt = 0; - int i; - int num_elements = 1000; + int i; + int num_elements = 1000; H5PB_t *pb_ptr; haddr_t meta_addr = HADDR_UNDEF; - haddr_t raw_addr = HADDR_UNDEF; - int *data = NULL; - H5F_t *f = NULL; + haddr_t raw_addr = HADDR_UNDEF; + int * data = NULL; + H5F_t * f = NULL; TESTING("Minimum Metadata threshold Processing"); HDprintf("\n"); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); - if((fapl = H5Pcopy(orig_fapl)) < 0) + if ((fapl = H5Pcopy(orig_fapl)) < 0) TEST_ERROR - if(set_multi_split(env_h5_drvr, fapl, sizeof(int)*200) != 0) + if (set_multi_split(env_h5_drvr, fapl, sizeof(int) * 200) != 0) TEST_ERROR; - if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + if ((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) TEST_ERROR; - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, sizeof(int)*200) < 0) + if (H5Pset_file_space_page_size(fcpl, sizeof(int) * 200) < 0) FAIL_STACK_ERROR; HDprintf("\tMinimum metadata threshold = 100%%\n"); /* keep 5 pages at max in the page buffer and 5 meta page minimum */ - if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 100, 0) < 0) + if (H5Pset_page_buffer_size(fapl, sizeof(int) * 1000, 100, 0) < 0) FAIL_STACK_ERROR; /* create the file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; /* opening the file inserts one or more pages into the page buffer. @@ -1863,140 +1808,123 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) HDassert(f->shared); HDassert(f->shared->pb_ptr); - base_raw_cnt = f->shared->pb_ptr->curr_rd_pages; + base_raw_cnt = f->shared->pb_ptr->curr_rd_pages; base_meta_cnt = f->shared->pb_ptr->curr_md_pages; - if(base_raw_cnt != 0) + if (base_raw_cnt != 0) TEST_ERROR; - if(base_meta_cnt != 2) + if (base_meta_cnt != 2) TEST_ERROR; pb_ptr = f->shared->pb_ptr; - if(pb_ptr->min_md_pages != 5) + if (pb_ptr->min_md_pages != 5) TEST_ERROR; - if(pb_ptr->min_rd_pages != 0) + if (pb_ptr->min_rd_pages != 0) TEST_ERROR; - if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; - if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; /* write all raw data. Since min_md_pages == max_pages, none of it * should end up in the page buffer. */ - for(i=0 ; i<100 ; i++) + for (i = 0; i < 100; i++) data[i] = i; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*200), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 200), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*400), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 400), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*600), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 600), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*800), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 800), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != base_meta_cnt) + if (f->shared->pb_ptr->curr_pages != base_meta_cnt) FAIL_STACK_ERROR; - if(pb_ptr->curr_rd_pages != 0) + if (pb_ptr->curr_rd_pages != 0) TEST_ERROR; /* write all meta data, this would end up in page buffer */ - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*200), - sizeof(int)*50, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 200), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*400), - sizeof(int)*50, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 400), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*600), - sizeof(int)*50, data) < 0) + if (H5F_block_read(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 600), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*800), - sizeof(int)*50, data) < 0) + if (H5F_block_read(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 800), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(pb_ptr->curr_md_pages != 5) + if (pb_ptr->curr_md_pages != 5) TEST_ERROR; - if(pb_ptr->curr_rd_pages != 0) + if (pb_ptr->curr_rd_pages != 0) TEST_ERROR; /* write and read more raw data and make sure that they don't end up in * page buffer */ - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*200), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 200), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*350), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 350), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*500), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 500), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*750), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 750), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*900), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 900), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(pb_ptr->curr_md_pages != 5) + if (pb_ptr->curr_md_pages != 5) TEST_ERROR; - if(pb_ptr->curr_rd_pages != 0) + if (pb_ptr->curr_rd_pages != 0) TEST_ERROR; - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR; - HDprintf("\tMinimum raw data threshold = 100%%\n"); /* keep 5 pages at max in the page buffer and 5 raw page minimum */ - if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 0, 100) < 0) + if (H5Pset_page_buffer_size(fapl, sizeof(int) * 1000, 0, 100) < 0) TEST_ERROR; /* create the file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; /* opening the file inserts one or more pages into the page buffer. @@ -2006,141 +1934,125 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) HDassert(f->shared); HDassert(f->shared->pb_ptr); - base_raw_cnt = f->shared->pb_ptr->curr_rd_pages; + base_raw_cnt = f->shared->pb_ptr->curr_rd_pages; base_meta_cnt = f->shared->pb_ptr->curr_md_pages; - if(base_raw_cnt != 0) + if (base_raw_cnt != 0) TEST_ERROR; - if(base_meta_cnt != 0) + if (base_meta_cnt != 0) TEST_ERROR; pb_ptr = f->shared->pb_ptr; - if(pb_ptr->min_md_pages != 0) + if (pb_ptr->min_md_pages != 0) TEST_ERROR; - if(pb_ptr->min_rd_pages != 5) + if (pb_ptr->min_rd_pages != 5) FAIL_STACK_ERROR; - if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; - if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements))) TEST_ERROR; /* write all meta data, none of this should end up in the page buffer since * min_rd_pages == max_pages * is no raw data yet */ - for(i=0 ; i<100 ; i++) + for (i = 0; i < 100; i++) data[i] = i; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*200), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 200), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*400), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 400), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*600), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 600), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*800), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 800), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 0) + if (f->shared->pb_ptr->curr_pages != 0) FAIL_STACK_ERROR; - if(pb_ptr->curr_md_pages != 0) + if (pb_ptr->curr_md_pages != 0) TEST_ERROR; /* write/read all raw data, this would end up in page buffer */ - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*200), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 200), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*400), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 400), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*600), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 600), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*800), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 800), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(pb_ptr->curr_rd_pages != 5) + if (pb_ptr->curr_rd_pages != 5) TEST_ERROR; - if(pb_ptr->curr_md_pages != 0) + if (pb_ptr->curr_md_pages != 0) TEST_ERROR; /* write and read more meta data and make sure that they don't end up in * page buffer */ - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*100), - sizeof(int)*50, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 100), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*350), - sizeof(int)*50, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 350), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*500), - sizeof(int)*50, data) < 0) + if (H5F_block_read(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 500), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*750), - sizeof(int)*50, data) < 0) + if (H5F_block_read(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 750), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*900), - sizeof(int)*50, data) < 0) + if (H5F_block_read(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 900), sizeof(int) * 50, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(pb_ptr->curr_rd_pages != 5) + if (pb_ptr->curr_rd_pages != 5) TEST_ERROR; - if(pb_ptr->curr_md_pages != 0) + if (pb_ptr->curr_md_pages != 0) TEST_ERROR; - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR; - HDprintf("\tMinimum metadata threshold = 40%%, "); HDprintf("Minimum rawdata threshold = 40%%\n"); - /* keep 5 pages at max in the page buffer 2 meta pages, 2 raw pages - * minimum + /* keep 5 pages at max in the page buffer 2 meta pages, 2 raw pages + * minimum */ - if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 40, 40) < 0) + if (H5Pset_page_buffer_size(fapl, sizeof(int) * 1000, 40, 40) < 0) TEST_ERROR; /* create the file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; /* opening the file inserts one or more pages into the page buffer. @@ -2150,330 +2062,296 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) * metadata entry counts. */ - base_raw_cnt = f->shared->pb_ptr->curr_rd_pages; + base_raw_cnt = f->shared->pb_ptr->curr_rd_pages; base_meta_cnt = f->shared->pb_ptr->curr_md_pages; - if(base_raw_cnt != 0) + if (base_raw_cnt != 0) TEST_ERROR; - if(base_meta_cnt != 2) + if (base_meta_cnt != 2) TEST_ERROR; pb_ptr = f->shared->pb_ptr; - if(pb_ptr->min_md_pages != 2) + if (pb_ptr->min_md_pages != 2) TEST_ERROR; - if(pb_ptr->min_rd_pages != 2) + if (pb_ptr->min_rd_pages != 2) TEST_ERROR; - if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; - if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; /* initialize all the elements to have a value of -1 */ - for(i=0 ; ishared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 5 - base_meta_cnt) + if (f->shared->pb_ptr->curr_rd_pages != 5 - base_meta_cnt) TEST_ERROR; /* add 3 meta entries evicting 1 raw entry */ - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*200), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 200), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*400), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 400), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 3) + if (f->shared->pb_ptr->curr_md_pages != 3) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 2) + if (f->shared->pb_ptr->curr_rd_pages != 2) TEST_ERROR; /* adding more meta entires should replace meta entries since raw data * is at its minimum */ - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*600), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 600), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*800), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 800), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 3) + if (f->shared->pb_ptr->curr_md_pages != 3) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 2) + if (f->shared->pb_ptr->curr_rd_pages != 2) TEST_ERROR; /* bring existing raw entires up the LRU */ - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*750), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 750), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; /* adding 2 raw entries (even with 1 call) should only evict 1 meta * entry and another raw entry */ - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*350), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 350), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 2) + if (f->shared->pb_ptr->curr_md_pages != 2) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 3) + if (f->shared->pb_ptr->curr_rd_pages != 3) TEST_ERROR; - /* read a metadata entry to force the flush of the metadata entries - * in the page buffer, and then read some raw data so that the metadata + /* read a metadata entry to force the flush of the metadata entries + * in the page buffer, and then read some raw data so that the metadata * pages are at the bottom of the LRU. * - * When we are done, should still have 2 metadata pages and 3 raw data + * When we are done, should still have 2 metadata pages and 3 raw data * pages in the page buffer */ - if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*442), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 442), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*150), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 150), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*550), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 550), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 2) + if (f->shared->pb_ptr->curr_md_pages != 2) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 3) + if (f->shared->pb_ptr->curr_rd_pages != 3) TEST_ERROR; - /* adding 2 meta entries should replace 2 entires at the bottom - * of the LRU + /* adding 2 meta entries should replace 2 entires at the bottom + * of the LRU */ - if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*98), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 98), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_read(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*242), - sizeof(int)*100, data) < 0) + if (H5F_block_read(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 242), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 2) + if (f->shared->pb_ptr->curr_md_pages != 2) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 3) + if (f->shared->pb_ptr->curr_rd_pages != 3) TEST_ERROR; - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR; HDprintf("\tMinimum metadata threshold = 20%%\n"); /* keep 5 pages at max in the page buffer and 1 meta page minimum */ - if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 39, 0) < 0) + if (H5Pset_page_buffer_size(fapl, sizeof(int) * 1000, 39, 0) < 0) TEST_ERROR; /* create the file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; pb_ptr = f->shared->pb_ptr; - if(pb_ptr->min_md_pages != 1) + if (pb_ptr->min_md_pages != 1) TEST_ERROR; - if(pb_ptr->min_rd_pages != 0) + if (pb_ptr->min_rd_pages != 0) TEST_ERROR; - if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; - if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; /* initialize all the elements to have a value of -1 */ - for(i=0 ; ishared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 1) + if (f->shared->pb_ptr->curr_md_pages != 1) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 4) + if (f->shared->pb_ptr->curr_rd_pages != 4) TEST_ERROR; /* add 2 meta entries evicting 2 raw entries */ - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*200), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 200), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 3) + if (f->shared->pb_ptr->curr_md_pages != 3) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 2) + if (f->shared->pb_ptr->curr_rd_pages != 2) TEST_ERROR; /* bring the rest of the raw entries up the LRU */ - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*500), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 500), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*700), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 700), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*900), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 900), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; /* write one more raw entry which replace one meta entry */ - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*100), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 100), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 1) + if (f->shared->pb_ptr->curr_md_pages != 1) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 4) + if (f->shared->pb_ptr->curr_rd_pages != 4) TEST_ERROR; /* write one more raw entry which should replace another raw entry * keeping min threshold of meta entries */ - if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*300), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 300), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 1) + if (f->shared->pb_ptr->curr_md_pages != 1) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 4) + if (f->shared->pb_ptr->curr_rd_pages != 4) TEST_ERROR; /* write a metadata entry that should replace the metadata entry * at the bottom of the LRU */ - if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*500), - sizeof(int)*100, data) < 0) + if (H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 500), sizeof(int) * 100, data) < 0) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != 5) + if (f->shared->pb_ptr->curr_pages != 5) FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_md_pages != 1) + if (f->shared->pb_ptr->curr_md_pages != 1) TEST_ERROR; - if(f->shared->pb_ptr->curr_rd_pages != 4) + if (f->shared->pb_ptr->curr_rd_pages != 4) TEST_ERROR; - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; HDfree(data); @@ -2483,7 +2361,8 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) @@ -2492,11 +2371,11 @@ error: H5Fclose(file_id); if (data != NULL) HDfree(data); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_min_threshold */ - /*------------------------------------------------------------------------- * Function: test_stats_collection() * @@ -2534,50 +2413,50 @@ error: static unsigned test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - int i; - int num_elements = 1000; - int64_t base_raw_cnt = 0; + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + int i; + int num_elements = 1000; + int64_t base_raw_cnt = 0; int64_t base_meta_cnt = 0; - haddr_t meta_addr = HADDR_UNDEF; - haddr_t raw_addr = HADDR_UNDEF; - int *data = NULL; - H5F_t *f = NULL; + haddr_t meta_addr = HADDR_UNDEF; + haddr_t raw_addr = HADDR_UNDEF; + int * data = NULL; + H5F_t * f = NULL; TESTING("Statistics Collection"); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); - if((fapl = H5Pcopy(orig_fapl)) < 0) + if ((fapl = H5Pcopy(orig_fapl)) < 0) TEST_ERROR - if(set_multi_split(env_h5_drvr, fapl, sizeof(int)*200) != 0) + if (set_multi_split(env_h5_drvr, fapl, sizeof(int) * 200) != 0) TEST_ERROR; - if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + if ((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) TEST_ERROR - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) TEST_ERROR; - if(H5Pset_file_space_page_size(fcpl, sizeof(int)*200) < 0) + if (H5Pset_file_space_page_size(fcpl, sizeof(int) * 200) < 0) TEST_ERROR; /* keep 5 pages at max in the page buffer */ - if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 20, 0) < 0) + if (H5Pset_page_buffer_size(fapl, sizeof(int) * 1000, 20, 0) < 0) TEST_ERROR; - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; /* opening the file inserts one or more pages into the page buffer. @@ -2588,195 +2467,155 @@ test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr) HDassert(f->shared); HDassert(f->shared->pb_ptr); - base_raw_cnt = f->shared->pb_ptr->curr_rd_pages; + base_raw_cnt = f->shared->pb_ptr->curr_rd_pages; base_meta_cnt = f->shared->pb_ptr->curr_md_pages; - if(base_raw_cnt != 0) + if (base_raw_cnt != 0) TEST_ERROR; - if(base_meta_cnt != 2) + if (base_meta_cnt != 2) TEST_ERROR; /* reset statistics before we begin the tests */ - if(H5Freset_page_buffering_stats(file_id) < 0) + if (H5Freset_page_buffering_stats(file_id) < 0) FAIL_STACK_ERROR; - if(HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; - if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, - sizeof(int)*(size_t)num_elements))) + if (HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; - /* initialize all the elements to have a value of -1 */ - for(i=0 ; ishared->pb_ptr->accesses[0] != 10 ) || - ( f->shared->pb_ptr->accesses[1] != 16 ) || - ( f->shared->pb_ptr->accesses[2] != 0 ) ) { + if ((f->shared->pb_ptr->accesses[0] != 10) || (f->shared->pb_ptr->accesses[1] != 16) || + (f->shared->pb_ptr->accesses[2] != 0)) { - HDfprintf(stderr, "accesses[] = {%d, %d, %d}. {10, 16, 0} expected\n", - f->shared->pb_ptr->accesses[0], - f->shared->pb_ptr->accesses[1], - f->shared->pb_ptr->accesses[2]); + HDfprintf(stderr, "accesses[] = {%d, %d, %d}. {10, 16, 0} expected\n", f->shared->pb_ptr->accesses[0], + f->shared->pb_ptr->accesses[1], f->shared->pb_ptr->accesses[2]); TEST_ERROR; } /* was 2, 1, 1 -- review this */ - if ( ( f->shared->pb_ptr->bypasses[0] != 0 ) || - ( f->shared->pb_ptr->bypasses[1] != 1 ) || - ( f->shared->pb_ptr->bypasses[2] != 1 ) ) { + if ((f->shared->pb_ptr->bypasses[0] != 0) || (f->shared->pb_ptr->bypasses[1] != 1) || + (f->shared->pb_ptr->bypasses[2] != 1)) { - HDfprintf(stderr, "bypasses[] = {%d, %d, %d}. {0, 1, 1} expected\n", - f->shared->pb_ptr->bypasses[0], - f->shared->pb_ptr->bypasses[1], - f->shared->pb_ptr->bypasses[2]); + HDfprintf(stderr, "bypasses[] = {%d, %d, %d}. {0, 1, 1} expected\n", f->shared->pb_ptr->bypasses[0], + f->shared->pb_ptr->bypasses[1], f->shared->pb_ptr->bypasses[2]); TEST_ERROR; } - if ( ( f->shared->pb_ptr->hits[0] != 0 ) || - ( f->shared->pb_ptr->hits[1] != 4 ) || - ( f->shared->pb_ptr->hits[2] != 0 ) ) { + if ((f->shared->pb_ptr->hits[0] != 0) || (f->shared->pb_ptr->hits[1] != 4) || + (f->shared->pb_ptr->hits[2] != 0)) { - HDfprintf(stderr, "hits[] = {%d, %d, %d}. {0, 4, 0} expected\n", - f->shared->pb_ptr->hits[0], - f->shared->pb_ptr->hits[1], - f->shared->pb_ptr->hits[2]); + HDfprintf(stderr, "hits[] = {%d, %d, %d}. {0, 4, 0} expected\n", f->shared->pb_ptr->hits[0], + f->shared->pb_ptr->hits[1], f->shared->pb_ptr->hits[2]); TEST_ERROR; } /* was 9, 16. 0 -- review this */ - if ( ( f->shared->pb_ptr->misses[0] != 10 ) || - ( f->shared->pb_ptr->misses[1] != 16 ) || - ( f->shared->pb_ptr->misses[2] != 0 ) ) { + if ((f->shared->pb_ptr->misses[0] != 10) || (f->shared->pb_ptr->misses[1] != 16) || + (f->shared->pb_ptr->misses[2] != 0)) { - HDfprintf(stderr, "misses[] = {%d, %d, %d}. {10, 16, 0} expected\n", - f->shared->pb_ptr->misses[0], - f->shared->pb_ptr->misses[1], - f->shared->pb_ptr->misses[2]); + HDfprintf(stderr, "misses[] = {%d, %d, %d}. {10, 16, 0} expected\n", f->shared->pb_ptr->misses[0], + f->shared->pb_ptr->misses[1], f->shared->pb_ptr->misses[2]); TEST_ERROR; } /* was 7, 9, 0 -- review this */ - if ( ( f->shared->pb_ptr->evictions[0] != 9) || - ( f->shared->pb_ptr->evictions[1] != 9) || - ( f->shared->pb_ptr->evictions[2] != 0 ) ) { + if ((f->shared->pb_ptr->evictions[0] != 9) || (f->shared->pb_ptr->evictions[1] != 9) || + (f->shared->pb_ptr->evictions[2] != 0)) { HDfprintf(stderr, "evictions[] = {%d, %d, %d}. {%d, %d, 0} expected\n", - f->shared->pb_ptr->evictions[0], - f->shared->pb_ptr->evictions[1], - f->shared->pb_ptr->evictions[2], 7, 9); + f->shared->pb_ptr->evictions[0], f->shared->pb_ptr->evictions[1], + f->shared->pb_ptr->evictions[2], 7, 9); TEST_ERROR; } @@ -2787,104 +2626,89 @@ test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr) unsigned evictions[3]; unsigned bypasses[3]; - if(H5Fget_page_buffering_stats(file_id, accesses, hits, misses, - evictions, bypasses) < 0) + if (H5Fget_page_buffering_stats(file_id, accesses, hits, misses, evictions, bypasses) < 0) FAIL_STACK_ERROR; /* was 9, 16, 0 -- review this */ - if ( ( accesses[0] != 10 ) || - ( accesses[1] != 16 ) || - ( accesses[2] != 0 ) ) { + if ((accesses[0] != 10) || (accesses[1] != 16) || (accesses[2] != 0)) { - HDfprintf(stderr, - "accesses[] = {%d, %d, %d}. {10, 16, 0} expected\n", - accesses[0], accesses[1], accesses[2]); + HDfprintf(stderr, "accesses[] = {%d, %d, %d}. {10, 16, 0} expected\n", accesses[0], accesses[1], + accesses[2]); TEST_ERROR; } /* was 2, 1, 1 -- review this */ - if ( ( bypasses[0] != 0 ) || - ( bypasses[1] != 1 ) || - ( bypasses[2] != 1 ) ) { + if ((bypasses[0] != 0) || (bypasses[1] != 1) || (bypasses[2] != 1)) { - HDfprintf(stderr, "bypasses[] = {%d, %d, %d}. {2, 1, 1} expected\n", - bypasses[0], bypasses[1], bypasses[2]); + HDfprintf(stderr, "bypasses[] = {%d, %d, %d}. {2, 1, 1} expected\n", bypasses[0], bypasses[1], + bypasses[2]); TEST_ERROR; } - if ( ( hits[0] != 0 ) || - ( hits[1] != 4 ) || - ( hits[2] != 0 ) ) { + if ((hits[0] != 0) || (hits[1] != 4) || (hits[2] != 0)) { - HDfprintf(stderr, "hits[] = {%d, %d, %d}. {0, 4, 0} expected\n", - hits[0], hits[1], hits[2]); + HDfprintf(stderr, "hits[] = {%d, %d, %d}. {0, 4, 0} expected\n", hits[0], hits[1], hits[2]); TEST_ERROR; } /* was 9, 16. 0 -- review this */ - if ( ( misses[0] != 10 ) || - ( misses[1] != 16 ) || - ( misses[2] != 0 ) ) { + if ((misses[0] != 10) || (misses[1] != 16) || (misses[2] != 0)) { - HDfprintf(stderr, "misses[] = {%d, %d, %d}. {10, 16, 0} expected\n", - misses[0], misses[1], misses[2]); + HDfprintf(stderr, "misses[] = {%d, %d, %d}. {10, 16, 0} expected\n", misses[0], misses[1], + misses[2]); TEST_ERROR; } /* was 9, 9, 0 -- review this */ - if ( ( evictions[0] != 9 ) || - ( evictions[1] != 9 ) || - ( evictions[2] != 0 ) ) { + if ((evictions[0] != 9) || (evictions[1] != 9) || (evictions[2] != 0)) { - HDfprintf(stderr, - "evictions[] = {%d, %d, %d}. {9, 9, 0} expected\n", - evictions[0], evictions[1], evictions[2]); + HDfprintf(stderr, "evictions[] = {%d, %d, %d}. {9, 9, 0} expected\n", evictions[0], evictions[1], + evictions[2]); TEST_ERROR; } - if(H5Freset_page_buffering_stats(file_id) < 0) + if (H5Freset_page_buffering_stats(file_id) < 0) FAIL_STACK_ERROR; - if(H5Fget_page_buffering_stats(file_id, accesses, hits, misses, - evictions, bypasses) < 0) + if (H5Fget_page_buffering_stats(file_id, accesses, hits, misses, evictions, bypasses) < 0) FAIL_STACK_ERROR; - if(accesses[0] != 0) + if (accesses[0] != 0) TEST_ERROR; - if(accesses[1] != 0) + if (accesses[1] != 0) TEST_ERROR; - if(bypasses[0] != 0) + if (bypasses[0] != 0) TEST_ERROR; - if(bypasses[1] != 0) + if (bypasses[1] != 0) TEST_ERROR; - if(hits[0] != 0) + if (hits[0] != 0) TEST_ERROR; - if(hits[1] != 0) + if (hits[1] != 0) TEST_ERROR; - if(misses[0] != 0) + if (misses[0] != 0) TEST_ERROR; - if(misses[1] != 0) + if (misses[1] != 0) TEST_ERROR; - if(evictions[0] != 0) + if (evictions[0] != 0) TEST_ERROR; - if(evictions[1] != 0) + if (evictions[1] != 0) TEST_ERROR; } - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; HDfree(data); - PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) @@ -2893,13 +2717,13 @@ error: H5Fclose(file_id); if (data != NULL) HDfree(data); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_stats_collection */ #endif /* #ifndef H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: verify_page_buffering_disabled() * @@ -2924,77 +2748,80 @@ error: static unsigned verify_page_buffering_disabled(hid_t orig_fapl, const char *env_h5_drvr) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; TESTING("Page Buffering Disabled"); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); - /* first, try to create a file with page buffering enabled */ - if((fapl = H5Pcopy(orig_fapl)) < 0) + if ((fapl = H5Pcopy(orig_fapl)) < 0) TEST_ERROR - if(set_multi_split(env_h5_drvr, fapl, 4096) != 0) + if (set_multi_split(env_h5_drvr, fapl, 4096) != 0) TEST_ERROR; - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, 4096) < 0) + if (H5Pset_file_space_page_size(fcpl, 4096) < 0) FAIL_STACK_ERROR; - if(H5Pset_page_buffer_size(fapl, 4096*8, 0, 0) < 0) + if (H5Pset_page_buffer_size(fapl, 4096 * 8, 0, 0) < 0) FAIL_STACK_ERROR; /* try to create the file -- should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(file_id >= 0) + if (file_id >= 0) TEST_ERROR; /* now, create a file, close it, and then try to open it with page * buffering enabled. */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, 4096) < 0) + if (H5Pset_file_space_page_size(fcpl, 4096) < 0) FAIL_STACK_ERROR; /* create the file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* close the file */ - if(H5Fclose(file_id) < 0) + if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR; /* try to open the file using the fapl prepared above which enables * page buffering. Should fail. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(file_id >= 0) + if (file_id >= 0) TEST_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -3003,76 +2830,77 @@ verify_page_buffering_disabled(hid_t orig_fapl, const char *env_h5_drvr) error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) H5Pclose(fcpl); if (file_id != H5I_INVALID_HID) H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* verify_page_buffering_disabled() */ - + #endif /* H5_HAVE_PARALLEL */ - /************************************************************************* * * Function: md_entry_splitting_smoke_check() * * Purpose: Normally, file space for metadata entries is allocated - * indvidually. In the context of paged allocation, this + * indvidually. In the context of paged allocation, this * ensures that all entries that cross page boundaries start * on a page boundary, and that any space between the end of - * a multi-page metadata entry and the next page boundary - * is un-used. + * a multi-page metadata entry and the next page boundary + * is un-used. * * In the context of VFD SWMR, this fact along with atomic - * metadata entry I/O is used to minimize the size of the - * index in the metadata file, and to optimize metadata + * metadata entry I/O is used to minimize the size of the + * index in the metadata file, and to optimize metadata * metadata reads on the VFD SWMR reader side. It is also - * used as a simplifying assumption in normal page buffer + * used as a simplifying assumption in normal page buffer * operation. * - * Unfortunately, it turns out that some metadata cache - * clients (H5FA & H5EA) allocate the needed file space in - * a single block, and sub-allocate space for individual - * entries out of this block. + * Unfortunately, it turns out that some metadata cache + * clients (H5FA & H5EA) allocate the needed file space in + * a single block, and sub-allocate space for individual + * entries out of this block. * * While this is a design flaw from the perspective - * VFD SWMR, repairing the issue no feasible at this time, - * and in any case, there will always be the issue of + * VFD SWMR, repairing the issue no feasible at this time, + * and in any case, there will always be the issue of * existing files. * * Thus, for now at least, the page buffer has to code around * the issue when operating in VFD SWMR mode. * - * It does this by examining metadata I/O requests that - * cross page boundaries, and querying the metadata cache + * It does this by examining metadata I/O requests that + * cross page boundaries, and querying the metadata cache * for the ID of the associated cache client. * - * If the request is associated with a cache client that - * that uses sub-allocation, the I/O request must be broken - * into the minimal number of sub-requests such that each - * request either doesn't cross page boundaries, or is - * page aligned, and of length equal to some multiple of + * If the request is associated with a cache client that + * that uses sub-allocation, the I/O request must be broken + * into the minimal number of sub-requests such that each + * request either doesn't cross page boundaries, or is + * page aligned, and of length equal to some multiple of * the page size. * * This test exists to verify that such entries are read * and written correctly. * - * Note that it does not concern itself with verifying - * the correct handling of the split I/O requests, as - * the split is done immediately upon receipt, and each - * of the sub-requests is treated as a normal metadata + * Note that it does not concern itself with verifying + * the correct handling of the split I/O requests, as + * the split is done immediately upon receipt, and each + * of the sub-requests is treated as a normal metadata * I/O request. * * Note that this test requires us to modify the page buffer - * hint fields in the metadata cache to trick it into - * re-laying the desired hints to the page buffer, even + * hint fields in the metadata cache to trick it into + * re-laying the desired hints to the page buffer, even * though it is not generating the I/O requests in this * test. * @@ -3083,33 +2911,31 @@ error: * 4/9/20 * * Changes: None. - * + * *************************************************************************/ -#define HDR_SIZE 40 -#define MD_PAGE_SIZE 250 +#define HDR_SIZE 40 +#define MD_PAGE_SIZE 250 #define TOT_SYNTH_ENTRY_SIZES (HDR_SIZE + (3 * MD_PAGE_SIZE)) static unsigned -md_entry_splitting_smoke_check(hid_t orig_fapl, const char *env_h5_drvr, - bool vfd_swmr_mode) +md_entry_splitting_smoke_check(hid_t orig_fapl, const char *env_h5_drvr, bool vfd_swmr_mode) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - int i; - int * synth_md_vals = NULL; - int * synth_md_test_buf = NULL; - haddr_t base_addr; - haddr_t p0_addr; - haddr_t p1_addr; - haddr_t p2_addr; - H5F_t *f = NULL; + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + int i; + int * synth_md_vals = NULL; + int * synth_md_test_buf = NULL; + haddr_t base_addr; + haddr_t p0_addr; + haddr_t p1_addr; + haddr_t p2_addr; + H5F_t * f = NULL; const uint32_t max_lag = 5; - TESTING("%sMetadata Entry Splitting Smoke Check", \ - vfd_swmr_mode ? "VFD SWMR " : ""); + TESTING("%sMetadata Entry Splitting Smoke Check", vfd_swmr_mode ? "VFD SWMR " : ""); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); @@ -3138,18 +2964,18 @@ md_entry_splitting_smoke_check(hid_t orig_fapl, const char *env_h5_drvr, FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; /* The objective is to perform a quick smoke check on I/O of metadata - * entries that have been sub-allocated out of a larger space allocation. - * We do this by simulating a structure similar to elements of the - * fixed array on disk structure. Specifically, we create a synthetic - * set of metadata entries that are allocated out of a single allocation - * from the free space manager, and perform several reads and writes to + * entries that have been sub-allocated out of a larger space allocation. + * We do this by simulating a structure similar to elements of the + * fixed array on disk structure. Specifically, we create a synthetic + * set of metadata entries that are allocated out of a single allocation + * from the free space manager, and perform several reads and writes to * verify expected behaviour. * - * The synthetic set of metadata entries are constucted of integers + * The synthetic set of metadata entries are constucted of integers * so as to allow easy assignement of unique values. It is constructed * as follows: * @@ -3161,44 +2987,40 @@ md_entry_splitting_smoke_check(hid_t orig_fapl, const char *env_h5_drvr, * page 1: 250 2290, 2291, ... 2539 base_addr + 290 * sizeof(int) * page 2: 250 3540, 3541, ... 3789 base_addr + 540 * sizeof(int) * - * The overall size of the compound metadata entry is 395 * sizeof(int). - * Since we use a page size of 100 * sizeof(int), this system of synthetic + * The overall size of the compound metadata entry is 395 * sizeof(int). + * Since we use a page size of 100 * sizeof(int), this system of synthetic * metadata entries spans four pages. */ /* allocate the buffers needed for the synthetic md entry test */ - if ( (synth_md_vals = (int *)HDcalloc((size_t)TOT_SYNTH_ENTRY_SIZES, - sizeof(int))) == NULL ) + if ((synth_md_vals = (int *)HDcalloc((size_t)TOT_SYNTH_ENTRY_SIZES, sizeof(int))) == NULL) TEST_ERROR - if ( (synth_md_test_buf = (int *)HDcalloc((size_t)TOT_SYNTH_ENTRY_SIZES, - sizeof(int))) == NULL ) + if ((synth_md_test_buf = (int *)HDcalloc((size_t)TOT_SYNTH_ENTRY_SIZES, sizeof(int))) == NULL) TEST_ERROR - /* allocate file space for the synthetic metadata entries and + /* allocate file space for the synthetic metadata entries and * compute their addresses. */ - if (HADDR_UNDEF == - (base_addr = H5MF_alloc(f, H5FD_MEM_BTREE, - sizeof(int) * (size_t)(TOT_SYNTH_ENTRY_SIZES)))) + if (HADDR_UNDEF == + (base_addr = H5MF_alloc(f, H5FD_MEM_BTREE, sizeof(int) * (size_t)(TOT_SYNTH_ENTRY_SIZES)))) FAIL_STACK_ERROR; p0_addr = base_addr + (haddr_t)(sizeof(int) * HDR_SIZE); p1_addr = p0_addr + (haddr_t)(sizeof(int) * MD_PAGE_SIZE); p2_addr = p1_addr + (haddr_t)(sizeof(int) * MD_PAGE_SIZE); - - /* Set all cells in synth_md_vals[] to -1 and write directly to + /* Set all cells in synth_md_vals[] to -1 and write directly to * the underlying file via an H5FD call. This gives us a known * set of values in the underlying file. */ - for ( i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++) { + for (i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++) { synth_md_vals[i] = -1; } - if ( H5FD_write(f->shared->lf, H5FD_MEM_BTREE, base_addr, - sizeof(int) * TOT_SYNTH_ENTRY_SIZES, synth_md_vals) < 0) + if (H5FD_write(f->shared->lf, H5FD_MEM_BTREE, base_addr, sizeof(int) * TOT_SYNTH_ENTRY_SIZES, + synth_md_vals) < 0) FAIL_STACK_ERROR; /* touch up the metadata cache so that it will report that a metadata @@ -3207,121 +3029,108 @@ md_entry_splitting_smoke_check(hid_t orig_fapl, const char *env_h5_drvr, */ H5C_set_curr_io_type_splitable(f->shared->cache, TRUE); - /* initialize the buffer with the values of the synthetic metadata + /* initialize the buffer with the values of the synthetic metadata * entries. */ - for ( i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++ ) { + for (i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++) { synth_md_vals[i] = i; - if ( i > HDR_SIZE ) { + if (i > HDR_SIZE) { synth_md_vals[i] += 1000; } - - if ( i > HDR_SIZE + MD_PAGE_SIZE ) { + + if (i > HDR_SIZE + MD_PAGE_SIZE) { synth_md_vals[i] += 1000; } - if ( i > HDR_SIZE + MD_PAGE_SIZE + MD_PAGE_SIZE ) { + if (i > HDR_SIZE + MD_PAGE_SIZE + MD_PAGE_SIZE) { synth_md_vals[i] += 1000; } - } /* write the header */ - if (H5F_block_write(f, H5FD_MEM_BTREE, base_addr, - sizeof(int) * (size_t)HDR_SIZE, synth_md_vals) < 0) + if (H5F_block_write(f, H5FD_MEM_BTREE, base_addr, sizeof(int) * (size_t)HDR_SIZE, synth_md_vals) < 0) FAIL_STACK_ERROR; /* read the header */ - if (H5F_block_read(f, H5FD_MEM_BTREE, base_addr, - sizeof(int) * (size_t)HDR_SIZE, synth_md_test_buf) < 0) + if (H5F_block_read(f, H5FD_MEM_BTREE, base_addr, sizeof(int) * (size_t)HDR_SIZE, synth_md_test_buf) < 0) FAIL_STACK_ERROR; /* write page 0 */ - if (H5F_block_write(f, H5FD_MEM_BTREE, p0_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_write(f, H5FD_MEM_BTREE, p0_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_vals[HDR_SIZE])) < 0) FAIL_STACK_ERROR; /* read page 0 */ - if (H5F_block_read(f, H5FD_MEM_BTREE, p0_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_read(f, H5FD_MEM_BTREE, p0_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_test_buf[HDR_SIZE])) < 0) FAIL_STACK_ERROR; /* write page 1 */ - if (H5F_block_write(f, H5FD_MEM_BTREE, p1_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_write(f, H5FD_MEM_BTREE, p1_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_vals[HDR_SIZE + MD_PAGE_SIZE])) < 0) FAIL_STACK_ERROR; /* read page 1 */ - if (H5F_block_read(f, H5FD_MEM_BTREE, p1_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_read(f, H5FD_MEM_BTREE, p1_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_test_buf[HDR_SIZE + MD_PAGE_SIZE])) < 0) FAIL_STACK_ERROR; /* write page 2 */ - if (H5F_block_write(f, H5FD_MEM_BTREE, p2_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_write(f, H5FD_MEM_BTREE, p2_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_vals[HDR_SIZE + 2 * MD_PAGE_SIZE])) < 0) FAIL_STACK_ERROR; /* read page 2 */ - if (H5F_block_read(f, H5FD_MEM_BTREE, p2_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_read(f, H5FD_MEM_BTREE, p2_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_test_buf[HDR_SIZE + 2 * MD_PAGE_SIZE])) < 0) FAIL_STACK_ERROR; /* verify reads */ - for ( i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++ ) { + for (i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++) { - if ( synth_md_vals[i] != synth_md_test_buf[i] ) { + if (synth_md_vals[i] != synth_md_test_buf[i]) { - HDfprintf(stderr, "(1) unexpected read %d: val %d -- %d expected\n", - i, synth_md_test_buf[i], synth_md_vals[i]); + HDfprintf(stderr, "(1) unexpected read %d: val %d -- %d expected\n", i, synth_md_test_buf[i], + synth_md_vals[i]); TEST_ERROR; } } /* zero the test buffer, do the reads again in reverse order, and verify */ - for ( i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++) { + for (i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++) { synth_md_test_buf[i] = 0; } /* read page 2 */ - if (H5F_block_read(f, H5FD_MEM_BTREE, p2_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_read(f, H5FD_MEM_BTREE, p2_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_test_buf[HDR_SIZE + 2 * MD_PAGE_SIZE])) < 0) FAIL_STACK_ERROR; /* read page 1 */ - if (H5F_block_read(f, H5FD_MEM_BTREE, p1_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_read(f, H5FD_MEM_BTREE, p1_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_test_buf[HDR_SIZE + MD_PAGE_SIZE])) < 0) FAIL_STACK_ERROR; /* read page 0 */ - if (H5F_block_read(f, H5FD_MEM_BTREE, p0_addr, - sizeof(int) * (size_t)MD_PAGE_SIZE, + if (H5F_block_read(f, H5FD_MEM_BTREE, p0_addr, sizeof(int) * (size_t)MD_PAGE_SIZE, &(synth_md_test_buf[HDR_SIZE])) < 0) FAIL_STACK_ERROR; /* read the header */ - if (H5F_block_read(f, H5FD_MEM_BTREE, base_addr, - sizeof(int) * (size_t)HDR_SIZE, synth_md_test_buf) < 0) + if (H5F_block_read(f, H5FD_MEM_BTREE, base_addr, sizeof(int) * (size_t)HDR_SIZE, synth_md_test_buf) < 0) FAIL_STACK_ERROR; /* verify reads again */ - for ( i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++ ) { + for (i = 0; i < TOT_SYNTH_ENTRY_SIZES; i++) { - if ( synth_md_vals[i] != synth_md_test_buf[i] ) { + if (synth_md_vals[i] != synth_md_test_buf[i]) { - HDfprintf(stderr, "(2) unexpected read %d: val %d -- %d expected\n", - i, synth_md_test_buf[i], synth_md_vals[i]); + HDfprintf(stderr, "(2) unexpected read %d: val %d -- %d expected\n", i, synth_md_test_buf[i], + synth_md_vals[i]); TEST_ERROR; } } @@ -3346,45 +3155,46 @@ md_entry_splitting_smoke_check(hid_t orig_fapl, const char *env_h5_drvr, error: /* Undo the touchup of the metadata cache */ - if ( ( f ) && ( f->shared ) && ( f->shared->cache) ) + if ((f) && (f->shared) && (f->shared->cache)) H5C_set_curr_io_type_splitable(f->shared->cache, FALSE); - if ( synth_md_vals ) + if (synth_md_vals) HDfree(synth_md_vals); - if ( synth_md_test_buf ) + if (synth_md_test_buf) HDfree(synth_md_test_buf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) H5Pclose(fcpl); if (file_id != H5I_INVALID_HID) H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* md_entry_splitting_smoke_check() */ #undef HDR_SIZE -#undef MD_PAGE_SIZE -#undef TOT_SYNTH_ENTRY_SIZES +#undef MD_PAGE_SIZE +#undef TOT_SYNTH_ENTRY_SIZES - /************************************************************************* * * Function: md_entry_splitting_boundary_test() * - * Purpose: Test to verify that I/O request splitting performs as + * Purpose: Test to verify that I/O request splitting performs as * as expected in various boundary conditions. * * The above md_entry_splitting_smoke_check() was directed - * at verifying that the page buffer behaved as expected + * at verifying that the page buffer behaved as expected * in something approaching a typical use case. * - * This test is directed at verifying that entries are - * split correctly under a variety of conditions that + * This test is directed at verifying that entries are + * split correctly under a variety of conditions that * are unlikely unless the user chooses at odd page size. * * Return: 0 if test is sucessful @@ -3394,34 +3204,31 @@ error: * 4/12/20 * * Changes: None. - * + * *************************************************************************/ - static unsigned -md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, - bool vfd_swmr_mode) +md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, bool vfd_swmr_mode) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - int64_t base_page_cnt; - int i; - H5F_t *f = NULL; - const uint32_t max_lag = 5; - size_t page_size = (size_t)512; - int pages_allocated = 32; - size_t alloc_size; - uint8_t * write_buf = NULL; - uint8_t * read_buf = NULL; - haddr_t base_addr = HADDR_UNDEF; - haddr_t first_page_addr = HADDR_UNDEF; - haddr_t start_addr = HADDR_UNDEF; - size_t test_len; - - TESTING("%sMetadata Entry Splitting Boundary Test", \ - vfd_swmr_mode ? "VFD SWMR " : ""); + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl = -1; + hid_t fapl = -1; + int64_t base_page_cnt; + int i; + H5F_t * f = NULL; + const uint32_t max_lag = 5; + size_t page_size = (size_t)512; + int pages_allocated = 32; + size_t alloc_size; + uint8_t * write_buf = NULL; + uint8_t * read_buf = NULL; + haddr_t base_addr = HADDR_UNDEF; + haddr_t first_page_addr = HADDR_UNDEF; + haddr_t start_addr = HADDR_UNDEF; + size_t test_len; + + TESTING("%sMetadata Entry Splitting Boundary Test", vfd_swmr_mode ? "VFD SWMR " : ""); h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); @@ -3450,11 +3257,11 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(file_id))) + if (NULL == (f = (H5F_t *)H5VL_object(file_id))) FAIL_STACK_ERROR; /* opening the file inserts one or more pages into the page buffer. - * Get the number of pages inserted, and verify that it is the + * Get the number of pages inserted, and verify that it is the * expected value. */ base_page_cnt = f->shared->pb_ptr->curr_pages; @@ -3463,31 +3270,31 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, /* Test the folowing cases: * - * 1) splittable md entry that is page aligned and exactly one + * 1) splittable md entry that is page aligned and exactly one * page long. * - * 2) splittable md entry that is page aligned and exactly two + * 2) splittable md entry that is page aligned and exactly two * pages long * * 3) splittable md entry that is page aligned and is exactly one * page and one byte long. - * - * 4) splittable md entry that is exactly one page and one byte + * + * 4) splittable md entry that is exactly one page and one byte * long, and starts one byte before a page bundary. * - * 5) splittable md entry that is exactly one page and two bytes + * 5) splittable md entry that is exactly one page and two bytes * long, and starts one byte before a page boundary. * - * 6) splittable md entry that is two bytes long, and starts one + * 6) splittable md entry that is two bytes long, and starts one * byte before a page boundary. * * 7) splittable md entry that is page aligned and is exactly two * pages and one byte long. - * - * 8) splittable md entry that is exactly two pages and one byte + * + * 8) splittable md entry that is exactly two pages and one byte * long, and starts one byte before a page bundary. * - * 9) splittable md entry that is exactly two pages and two bytes + * 9) splittable md entry that is exactly two pages and two bytes * long, and starts one byte before a page boundary. * */ @@ -3504,17 +3311,16 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (HADDR_UNDEF == (base_addr = H5MF_alloc(f, H5FD_MEM_SUPER, alloc_size))) FAIL_STACK_ERROR; - /* Set all cells write_buf[] to 0 and write directly to + /* Set all cells write_buf[] to 0 and write directly to * the underlying file via an H5FD call. This gives us a known * set of values in the underlying file. */ - for ( i = 0; i < (int)alloc_size; i++) { + for (i = 0; i < (int)alloc_size; i++) { write_buf[i] = 0; } - if ( H5FD_write(f->shared->lf, H5FD_MEM_SUPER, base_addr, - alloc_size, write_buf) < 0) + if (H5FD_write(f->shared->lf, H5FD_MEM_SUPER, base_addr, alloc_size, write_buf) < 0) FAIL_STACK_ERROR; /* touch up the metadata cache so that it will report that a metadata @@ -3523,11 +3329,10 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, */ H5C_set_curr_io_type_splitable(f->shared->cache, TRUE); - - /* 1) splittable md entry that is page aligned and exactly one + /* 1) splittable md entry that is page aligned and exactly one * page long. * - * Should not register as a split I/O. + * Should not register as a split I/O. * * Should log 4 metadata accesses. * should log 3 metadata hits @@ -3535,22 +3340,22 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * should log 1 metadata loads * should log 1 metadata insertions * - * Note that exposes an inefficiency in the page buffer, as page + * Note that exposes an inefficiency in the page buffer, as page * aligned I/O requests of exactly oen page in length really should - * bypass the page buffer. + * bypass the page buffer. * * This should be fixed, but I am bypassing it for now. * * JRM -- 4/18/20 */ first_page_addr = base_addr; - start_addr = base_addr; - test_len = page_size; + start_addr = base_addr; + test_len = page_size; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 1; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3559,15 +3364,15 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "1.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "1.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 2; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3576,27 +3381,24 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "1.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "1.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 0 ) || - ( f->shared->pb_ptr->md_write_splits != 0 ) ) + if ((f->shared->pb_ptr->md_read_splits != 0) || (f->shared->pb_ptr->md_write_splits != 0)) TEST_ERROR; - if ( ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1 ) ) + if ((f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3) || (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1)) TEST_ERROR; - - /* 2) splittable md entry that is page aligned and exactly two + /* 2) splittable md entry that is page aligned and exactly two * pages long * * Should not register as a split I/O. @@ -3622,13 +3424,13 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * The misses in the normal operating mode could be avoided. */ first_page_addr = base_addr + (haddr_t)(page_size); - start_addr = first_page_addr; - test_len = 3 * page_size; + start_addr = first_page_addr; + test_len = 3 * page_size; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 3; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3637,15 +3439,15 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "2.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "2.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 4; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3654,38 +3456,36 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "2.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "2.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 0 ) || - ( f->shared->pb_ptr->md_write_splits != 0 ) ) + if ((f->shared->pb_ptr->md_read_splits != 0) || (f->shared->pb_ptr->md_write_splits != 0)) TEST_ERROR; - if ( vfd_swmr_mode ) { - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 4 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 3 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 1 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 1 ) ) + if (vfd_swmr_mode) { + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 4) || + (f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 3) || + (f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 1) || + (f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 1)) TEST_ERROR; - - } else { - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 4 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 2 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 0 ) ) + } + else { + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 4) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 2) || + (f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 0)) TEST_ERROR; } - /* 3) splittable md entry that is page aligned and is exactly one * page and one byte long. * @@ -3700,13 +3500,13 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * should log 2 metadata insertions */ first_page_addr = base_addr + (haddr_t)(3 * page_size); - start_addr = first_page_addr; - test_len = page_size + 1; + start_addr = first_page_addr; + test_len = page_size + 1; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 5; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3715,15 +3515,15 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "3.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "3.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 6; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3732,28 +3532,25 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "3.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "3.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 2 ) || - ( f->shared->pb_ptr->md_write_splits != 2 ) ) + if ((f->shared->pb_ptr->md_read_splits != 2) || (f->shared->pb_ptr->md_write_splits != 2)) TEST_ERROR; - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MD] != 0 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2 ) ) + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MD] != 0) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6) || (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2)) TEST_ERROR; - - /* 4) splittable md entry that is exactly one page and one byte + /* 4) splittable md entry that is exactly one page and one byte * long, and starts one byte before a page bundary. * * Should register 2 metadata read splits @@ -3768,36 +3565,37 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * */ first_page_addr = base_addr + (haddr_t)(5 * page_size); - start_addr = first_page_addr + (haddr_t)(page_size - 1);; + start_addr = first_page_addr + (haddr_t)(page_size - 1); + ; test_len = page_size + 1; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 7; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) FAIL_STACK_ERROR; - if ( f->shared->pb_ptr->md_write_splits != 1 ) + if (f->shared->pb_ptr->md_write_splits != 1) TEST_ERROR; if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - if ( f->shared->pb_ptr->md_read_splits != 1 ) + if (f->shared->pb_ptr->md_read_splits != 1) TEST_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "4.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "4.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 8; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3806,28 +3604,25 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "4.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "4.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 2 ) || - ( f->shared->pb_ptr->md_write_splits != 2 ) ) + if ((f->shared->pb_ptr->md_read_splits != 2) || (f->shared->pb_ptr->md_write_splits != 2)) TEST_ERROR; - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MD] != 0 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2 ) ) + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MD] != 0) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6) || (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2)) TEST_ERROR; - - /* 5) splittable md entry that is exactly one page and two bytes + /* 5) splittable md entry that is exactly one page and two bytes * long, and starts one byte before a page boundary. * * Should register 2 metadata read splits @@ -3841,13 +3636,14 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * should log 3 metadata insertions */ first_page_addr = base_addr + (haddr_t)(8 * page_size); - start_addr = first_page_addr + (haddr_t)(page_size - 1);; + start_addr = first_page_addr + (haddr_t)(page_size - 1); + ; test_len = page_size + 2; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 9; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3856,15 +3652,15 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "5.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "5.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 10; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3873,28 +3669,25 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "5.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "5.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 2 ) || - ( f->shared->pb_ptr->md_write_splits != 2 ) ) + if ((f->shared->pb_ptr->md_read_splits != 2) || (f->shared->pb_ptr->md_write_splits != 2)) TEST_ERROR; - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MD] != 0 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 12 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 9 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 3 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 3 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 3 ) ) + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MD] != 0) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 12) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 9) || (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 3) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 3) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 3)) TEST_ERROR; - - /* 6) splittable md entry that is two bytes long, and starts one + /* 6) splittable md entry that is two bytes long, and starts one * byte before a page boundary. * * Should register 2 metadata read splits @@ -3908,13 +3701,14 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * should log 2 metadata insertions */ first_page_addr = base_addr + (haddr_t)(11 * page_size); - start_addr = first_page_addr + (haddr_t)(page_size - 1);; + start_addr = first_page_addr + (haddr_t)(page_size - 1); + ; test_len = 2; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 11; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3923,15 +3717,15 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "6.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "6.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 12; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -3940,26 +3734,24 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "6.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "6.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 2 ) || - ( f->shared->pb_ptr->md_write_splits != 2 ) ) + if ((f->shared->pb_ptr->md_read_splits != 2) || (f->shared->pb_ptr->md_write_splits != 2)) TEST_ERROR; - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MD] != 0 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2 ) ) + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MD] != 0) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6) || (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2)) TEST_ERROR; - + /* 7) splittable md entry that is page aligned and is exactly two * pages and one byte long. * @@ -3993,13 +3785,13 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * The misses in the normal operating mode could be avoided. */ first_page_addr = base_addr + (haddr_t)(13 * page_size); - start_addr = first_page_addr; - test_len = 2 * page_size + 1; + start_addr = first_page_addr; + test_len = 2 * page_size + 1; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 13; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -4008,15 +3800,15 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "3.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "3.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 14; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -4025,45 +3817,43 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "3.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "3.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 2 ) || - ( f->shared->pb_ptr->md_write_splits != 2 ) ) - TEST_ERROR; - - if ( vfd_swmr_mode ) { - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 4 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 3 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 1 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 1 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1 ) ) + if ((f->shared->pb_ptr->md_read_splits != 2) || (f->shared->pb_ptr->md_write_splits != 2)) + TEST_ERROR; + + if (vfd_swmr_mode) { + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 4) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4) || + (f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 3) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3) || + (f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 1) || + (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 1) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1)) TEST_ERROR; - - } else { - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 4 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 2 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1 ) ) + } + else { + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 4) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3) || + (f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 2) || + (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1)) TEST_ERROR; } - - /* 8) splittable md entry that is exactly two pages and one byte + /* 8) splittable md entry that is exactly two pages and one byte * long, and starts one byte before a page bundary. * * Should register 2 metadata read splits @@ -4096,36 +3886,37 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * The misses in the normal operating mode could be avoided. */ first_page_addr = base_addr + (haddr_t)(16 * page_size); - start_addr = first_page_addr + (haddr_t)(page_size - 1);; - test_len =2 * page_size + 1; + start_addr = first_page_addr + (haddr_t)(page_size - 1); + ; + test_len = 2 * page_size + 1; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 15; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) FAIL_STACK_ERROR; - if ( f->shared->pb_ptr->md_write_splits != 1 ) + if (f->shared->pb_ptr->md_write_splits != 1) TEST_ERROR; if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - if ( f->shared->pb_ptr->md_read_splits != 1 ) + if (f->shared->pb_ptr->md_read_splits != 1) TEST_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "4.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "4.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 16; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -4134,45 +3925,43 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "4.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "4.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 2 ) || - ( f->shared->pb_ptr->md_write_splits != 2 ) ) - TEST_ERROR; - - if ( vfd_swmr_mode ) { - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 4 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 3 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 1 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 1 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1 ) ) + if ((f->shared->pb_ptr->md_read_splits != 2) || (f->shared->pb_ptr->md_write_splits != 2)) + TEST_ERROR; + + if (vfd_swmr_mode) { + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 4) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4) || + (f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 3) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3) || + (f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 1) || + (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 1) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1)) TEST_ERROR; - - } else { - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 4 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 2 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1 ) ) + } + else { + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 4) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 4) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 3) || + (f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 2) || + (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 1) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 1)) TEST_ERROR; } - - /* 9) splittable md entry that is exactly two pages and two bytes + /* 9) splittable md entry that is exactly two pages and two bytes * long, and starts one byte before a page boundary. * * if vfd_swmr_mode @@ -4202,13 +3991,14 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, * The misses in the normal operating mode could be avoided. */ first_page_addr = base_addr + (haddr_t)(19 * page_size); - start_addr = first_page_addr + (haddr_t)(page_size - 1);; + start_addr = first_page_addr + (haddr_t)(page_size - 1); + ; test_len = 2 * page_size + 2; - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 17; - if ( H5PB_reset_stats(f->shared->pb_ptr) < 0 ) + if (H5PB_reset_stats(f->shared->pb_ptr) < 0) FAIL_STACK_ERROR; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -4217,15 +4007,15 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "5.1) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "5.1) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - for ( i = 0; i < (int)test_len; i++ ) + for (i = 0; i < (int)test_len; i++) write_buf[i] = 18; if (H5F_block_write(f, H5FD_MEM_SUPER, start_addr, test_len, write_buf) < 0) @@ -4234,44 +4024,42 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, if (H5F_block_read(f, H5FD_MEM_SUPER, start_addr, test_len, read_buf) < 0) FAIL_STACK_ERROR; - for ( i = 0; i < (int)test_len; i++ ) { - if ( write_buf[i] != read_buf[i] ) { - HDfprintf(stdout, "5.2) write_buf[%d] = %d != %d = read_buf[%d]\n", - i, (int)(write_buf[i]), (int)(read_buf[i]), i); + for (i = 0; i < (int)test_len; i++) { + if (write_buf[i] != read_buf[i]) { + HDfprintf(stdout, "5.2) write_buf[%d] = %d != %d = read_buf[%d]\n", i, (int)(write_buf[i]), + (int)(read_buf[i]), i); TEST_ERROR; } } - if ( ( f->shared->pb_ptr->md_read_splits != 2 ) || - ( f->shared->pb_ptr->md_write_splits != 2 ) ) - TEST_ERROR; - - if ( vfd_swmr_mode ) { - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 4 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 3 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 1 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 1 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2 ) ) + if ((f->shared->pb_ptr->md_read_splits != 2) || (f->shared->pb_ptr->md_write_splits != 2)) + TEST_ERROR; + + if (vfd_swmr_mode) { + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MPMDE] != 4) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8) || + (f->shared->pb_ptr->hits[H5PB__STATS_MPMDE] != 3) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6) || + (f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 1) || + (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->loads[H5PB__STATS_MPMDE] != 0) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MPMDE] != 1) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2)) TEST_ERROR; - - } else { - if ( ( f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 4 ) || - ( f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8 ) || - ( f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 2 ) || - ( f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2 ) || - ( f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2 ) ) + } + else { + if ((f->shared->pb_ptr->bypasses[H5PB__STATS_MPMDE] != 4) || + (f->shared->pb_ptr->accesses[H5PB__STATS_MD] != 8) || + (f->shared->pb_ptr->hits[H5PB__STATS_MD] != 6) || + (f->shared->pb_ptr->misses[H5PB__STATS_MPMDE] != 2) || + (f->shared->pb_ptr->misses[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->loads[H5PB__STATS_MD] != 2) || + (f->shared->pb_ptr->insertions[H5PB__STATS_MD] != 2)) TEST_ERROR; } - /* Undo the touchup of the metadata cache */ H5C_set_curr_io_type_splitable(f->shared->cache, FALSE); @@ -4292,29 +4080,29 @@ md_entry_splitting_boundary_test(hid_t orig_fapl, const char *env_h5_drvr, error: /* Undo the touchup of the metadata cache */ - if ( ( f ) && ( f->shared ) && ( f->shared->cache) ) + if ((f) && (f->shared) && (f->shared->cache)) H5C_set_curr_io_type_splitable(f->shared->cache, FALSE); - if ( write_buf ) + if (write_buf) HDfree(write_buf); - if ( read_buf ) + if (read_buf) HDfree(read_buf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (fapl != H5I_INVALID_HID) H5Pclose(fapl); if (fcpl != H5I_INVALID_HID) H5Pclose(fcpl); if (file_id != H5I_INVALID_HID) H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* md_entry_splitting_boundary_test() */ - - /*------------------------------------------------------------------------- * Function: main() * @@ -4331,24 +4119,23 @@ error: int main(void) { - hid_t fapl = -1; /* File access property list for data files */ - unsigned nerrors = 0; /* Cumulative error count */ - const char *env_h5_drvr = NULL; /* File Driver value from environment */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t fapl = -1; /* File access property list for data files */ + unsigned nerrors = 0; /* Cumulative error count */ + const char *env_h5_drvr = NULL; /* File Driver value from environment */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ h5_reset(); /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; /* Temporary skip testing with multi/split drivers: * Page buffering depends on paged aggregation which is * currently disabled for multi/split drivers. */ - if((0 == HDstrcmp(env_h5_drvr, "multi")) || - (0 == HDstrcmp(env_h5_drvr, "split"))) { + if ((0 == HDstrcmp(env_h5_drvr, "multi")) || (0 == HDstrcmp(env_h5_drvr, "split"))) { SKIPPED() HDputs("Skip page buffering test because paged aggregation is disabled for multi/split drivers"); @@ -4356,16 +4143,17 @@ main(void) HDexit(EXIT_SUCCESS); } - if((fapl = h5_fileaccess()) < 0) { + if ((fapl = h5_fileaccess()) < 0) { nerrors++; PUTS_ERROR("Can't get VFD-dependent fapl") } /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; -#ifdef H5_HAVE_PARALLEL +#ifdef H5_HAVE_PARALLEL HDputs("Page Buffering is disabled for parallel."); nerrors += verify_page_buffering_disabled(fapl, env_h5_drvr); @@ -4390,11 +4178,12 @@ main(void) h5_clean_files(namebases, fapl); - if(nerrors) + if (nerrors) goto error; /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; HDputs("All Page Buffering tests passed."); @@ -4402,14 +4191,16 @@ main(void) HDexit(EXIT_SUCCESS); error: - HDprintf("***** %d Page Buffering TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + HDprintf("***** %d Page Buffering TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); HDexit(EXIT_FAILURE); diff --git a/test/pool.c b/test/pool.c index 1851d6e..f34a3cc 100644 --- a/test/pool.c +++ b/test/pool.c @@ -20,9 +20,9 @@ * This file needs to access private datatypes from the H5MP package. * This file also needs to access the memory pool testing code. */ -#define H5MP_FRIEND /*suppress error about including H5MPpkg */ +#define H5MP_FRIEND /*suppress error about including H5MPpkg */ #define H5MP_TESTING -#include "H5MPpkg.h" /* Memory Pools */ +#include "H5MPpkg.h" /* Memory Pools */ /* Other private headers that this test requires */ @@ -34,10 +34,9 @@ #define MPOOL_LARGE_BLOCK (MPOOL_PAGE_SIZE * 3) #define MPOOL_NUM_SMALL_BLOCKS 64 #define MPOOL_SMALL_BLOCK 1 -#define MPOOL_NUM_RANDOM 10*1024 +#define MPOOL_NUM_RANDOM 10 * 1024 #define MPOOL_RANDOM_MAX_SIZE (MPOOL_PAGE_SIZE * 2) - /*------------------------------------------------------------------------- * Function: test_create * @@ -54,9 +53,9 @@ static int test_create(void) { - H5MP_pool_t *mp; /* Memory pool */ - H5MP_page_t *page; /* Memory pool page */ - size_t free_size; /* Free size in pool */ + H5MP_pool_t *mp; /* Memory pool */ + H5MP_page_t *page; /* Memory pool page */ + size_t free_size; /* Free size in pool */ /* * Test memory pool creation @@ -64,23 +63,23 @@ test_create(void) TESTING("memory pool creation"); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Check free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != 0) + if (free_size != 0) TEST_ERROR /* Check first page */ - if(H5MP_get_pool_first_page(mp, &page) < 0) + if (H5MP_get_pool_first_page(mp, &page) < 0) TEST_ERROR - if(page != NULL) + if (page != NULL) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR PASSED(); @@ -88,15 +87,16 @@ test_create(void) return 0; error: - H5E_BEGIN_TRY { - if(mp) + H5E_BEGIN_TRY + { + if (mp) H5MP_close(mp); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_create() */ - /*------------------------------------------------------------------------- * Function: test_close_one * @@ -113,7 +113,7 @@ error: static int test_close_one(void) { - H5MP_pool_t *mp; /* Memory pool */ + H5MP_pool_t *mp; /* Memory pool */ /* * Test memory pool closing @@ -121,15 +121,15 @@ test_close_one(void) TESTING("closing pool with blocks still allocated in one page"); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Allocate space in pool */ - if(NULL == H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)) + if (NULL == H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR PASSED(); @@ -137,15 +137,16 @@ test_close_one(void) return 0; error: - H5E_BEGIN_TRY { - if(mp) + H5E_BEGIN_TRY + { + if (mp) H5MP_close(mp); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_close_one() */ - /*------------------------------------------------------------------------- * Function: test_allocate_first * @@ -162,10 +163,10 @@ error: static int test_allocate_first(void) { - H5MP_pool_t *mp; /* Memory pool */ - H5MP_page_t *page; /* Memory pool page */ - size_t free_size; /* Free size in pool */ - void *spc; /* Pointer to space allocated */ + H5MP_pool_t *mp; /* Memory pool */ + H5MP_page_t *page; /* Memory pool page */ + size_t free_size; /* Free size in pool */ + void * spc; /* Pointer to space allocated */ /* * Test memory pool allocation @@ -173,56 +174,60 @@ test_allocate_first(void) TESTING("allocating first block in pool"); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Allocate space in pool */ - if(NULL == (spc = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) + if (NULL == (spc = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) TEST_ERROR /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) + if (free_size != + MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) TEST_ERROR /* Get first page */ - if(H5MP_get_pool_first_page(mp, &page) < 0) + if (H5MP_get_pool_first_page(mp, &page) < 0) TEST_ERROR - if(page == NULL) + if (page == NULL) TEST_ERROR /* Check page's free space */ - if(H5MP_get_page_free_size(page, &free_size) < 0) + if (H5MP_get_page_free_size(page, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) + if (free_size != + MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Check next page */ - if(H5MP_get_page_next_page(page, &page) < 0) + if (H5MP_get_page_next_page(page, &page) < 0) TEST_ERROR - if(page != NULL) + if (page != NULL) TEST_ERROR /* Free space in pool */ H5MP_free(mp, spc); /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) + if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR PASSED(); @@ -230,56 +235,56 @@ test_allocate_first(void) TESTING("allocating large first block in pool"); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Allocate space in pool */ - if(NULL == (spc = H5MP_malloc(mp, (size_t)MPOOL_LARGE_BLOCK))) + if (NULL == (spc = H5MP_malloc(mp, (size_t)MPOOL_LARGE_BLOCK))) TEST_ERROR /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != 0) + if (free_size != 0) TEST_ERROR /* Get first page */ - if(H5MP_get_pool_first_page(mp, &page) < 0) + if (H5MP_get_pool_first_page(mp, &page) < 0) TEST_ERROR - if(page == NULL) + if (page == NULL) TEST_ERROR /* Check page's free space */ - if(H5MP_get_page_free_size(page, &free_size) < 0) + if (H5MP_get_page_free_size(page, &free_size) < 0) TEST_ERROR - if(free_size != 0) + if (free_size != 0) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Check next page */ - if(H5MP_get_page_next_page(page, &page) < 0) + if (H5MP_get_page_next_page(page, &page) < 0) TEST_ERROR - if(page != NULL) + if (page != NULL) TEST_ERROR /* Free space in pool */ H5MP_free(mp, spc); /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_LARGE_BLOCK + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) + if (free_size != MPOOL_LARGE_BLOCK + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR PASSED(); @@ -287,15 +292,16 @@ test_allocate_first(void) return 0; error: - H5E_BEGIN_TRY { - if(mp) + H5E_BEGIN_TRY + { + if (mp) H5MP_close(mp); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_allocate_first() */ - /*------------------------------------------------------------------------- * Function: test_allocate_split * @@ -313,10 +319,10 @@ error: static int test_allocate_split(void) { - H5MP_pool_t *mp; /* Memory pool */ - size_t free_size; /* Free size in pool */ - void *spc1; /* Pointer to space allocated */ - void *spc2; /* Pointer to space allocated */ + H5MP_pool_t *mp; /* Memory pool */ + size_t free_size; /* Free size in pool */ + void * spc1; /* Pointer to space allocated */ + void * spc2; /* Pointer to space allocated */ /* * Test memory pool allocation @@ -324,65 +330,72 @@ test_allocate_split(void) TESTING("splitting block in pool"); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Allocate space in pool */ - if(NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) + if (NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) TEST_ERROR /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) + if (free_size != + MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Allocate more space in pool */ - if(NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) + if (NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) TEST_ERROR /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * 2) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) + if (free_size != + MPOOL_PAGE_SIZE - + (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * 2) + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Free first block in pool */ H5MP_free(mp, spc1); /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) + if (free_size != + MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Free second block in pool (should merge with first block) */ H5MP_free(mp, spc2); /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) + if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR PASSED(); @@ -390,15 +403,16 @@ test_allocate_split(void) return 0; error: - H5E_BEGIN_TRY { - if(mp) + H5E_BEGIN_TRY + { + if (mp) H5MP_close(mp); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_allocate_split() */ - /*------------------------------------------------------------------------- * Function: test_allocate_many_small * @@ -415,10 +429,10 @@ error: static int test_allocate_many_small(void) { - H5MP_pool_t *mp; /* Memory pool */ - size_t free_size; /* Free size in pool */ - void *spc[MPOOL_NUM_SMALL_BLOCKS]; /* Pointers to space allocated */ - int i; /* Local index variable */ + H5MP_pool_t *mp; /* Memory pool */ + size_t free_size; /* Free size in pool */ + void * spc[MPOOL_NUM_SMALL_BLOCKS]; /* Pointers to space allocated */ + int i; /* Local index variable */ /* * Test memory pool allocation @@ -426,41 +440,44 @@ test_allocate_many_small(void) TESTING("allocating many small blocks"); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Allocate space in pool */ - for(i = 0; i < MPOOL_NUM_SMALL_BLOCKS; i++) - if(NULL == (spc[i] = H5MP_malloc(mp, (size_t)MPOOL_SMALL_BLOCK))) + for (i = 0; i < MPOOL_NUM_SMALL_BLOCKS; i++) + if (NULL == (spc[i] = H5MP_malloc(mp, (size_t)MPOOL_SMALL_BLOCK))) TEST_ERROR /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - (((H5MP_BLOCK_ALIGN(MPOOL_SMALL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * MPOOL_NUM_SMALL_BLOCKS) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) + if (free_size != MPOOL_PAGE_SIZE - + (((H5MP_BLOCK_ALIGN(MPOOL_SMALL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * + MPOOL_NUM_SMALL_BLOCKS) + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Free blocks in pool */ /* (Tests free block merging with block after it */ - for(i = (MPOOL_NUM_SMALL_BLOCKS - 1); i >= 0; i--) + for (i = (MPOOL_NUM_SMALL_BLOCKS - 1); i >= 0; i--) H5MP_free(mp, spc[i]); /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) + if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR PASSED(); @@ -468,15 +485,16 @@ test_allocate_many_small(void) return 0; error: - H5E_BEGIN_TRY { - if(mp) + H5E_BEGIN_TRY + { + if (mp) H5MP_close(mp); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_allocate_many_small() */ - /*------------------------------------------------------------------------- * Function: test_allocate_new_page * @@ -494,12 +512,12 @@ error: static int test_allocate_new_page(void) { - H5MP_pool_t *mp; /* Memory pool */ - size_t free_size; /* Free size in pool */ - size_t u; /* Local index variable */ - void *spc[MPOOL_NUM_NORMAL_BLOCKS]; /* Pointer to space allocated */ - void *spc1; /* Pointer to space allocated */ - void *spc2; /* Pointer to space allocated */ + H5MP_pool_t *mp; /* Memory pool */ + size_t free_size; /* Free size in pool */ + size_t u; /* Local index variable */ + void * spc[MPOOL_NUM_NORMAL_BLOCKS]; /* Pointer to space allocated */ + void * spc1; /* Pointer to space allocated */ + void * spc2; /* Pointer to space allocated */ /* * Test memory pool allocation @@ -507,43 +525,46 @@ test_allocate_new_page(void) TESTING("allocate normal-sized block in new page"); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Allocate space in pool */ - for(u = 0; u < MPOOL_NUM_NORMAL_BLOCKS; u++) - if(NULL == (spc[u] = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) + for (u = 0; u < MPOOL_NUM_NORMAL_BLOCKS; u++) + if (NULL == (spc[u] = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) TEST_ERROR /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != (MPOOL_PAGE_SIZE * 3) - (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * MPOOL_NUM_NORMAL_BLOCKS) + (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)) * 3))) + if (free_size != (MPOOL_PAGE_SIZE * 3) - (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * + MPOOL_NUM_NORMAL_BLOCKS) + + (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)) * 3))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Free blocks in pool */ /* (Free alternating blocks, in two passes, which tests block merging w/both neighbors) */ - for(u = 0; u < MPOOL_NUM_NORMAL_BLOCKS; u+=2) + for (u = 0; u < MPOOL_NUM_NORMAL_BLOCKS; u += 2) H5MP_free(mp, spc[u]); - for(u = 1; u < MPOOL_NUM_NORMAL_BLOCKS; u+=2) + for (u = 1; u < MPOOL_NUM_NORMAL_BLOCKS; u += 2) H5MP_free(mp, spc[u]); /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) * 3)) + if (free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) * 3)) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR PASSED(); @@ -551,25 +572,27 @@ test_allocate_new_page(void) TESTING("allocate large-sized block in new page"); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Allocate space in pool */ /* (Normal sized block) */ - if(NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) + if (NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) TEST_ERROR /* (Larger sized block) */ - if(NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_LARGE_BLOCK))) + if (NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_LARGE_BLOCK))) TEST_ERROR /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) + if (free_size != + MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Free blocks in pool */ @@ -577,18 +600,18 @@ test_allocate_new_page(void) H5MP_free(mp, spc2); /* Check pool's free space */ - if(H5MP_get_pool_free_size(mp, &free_size) < 0) + if (H5MP_get_pool_free_size(mp, &free_size) < 0) TEST_ERROR - if(free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) + - MPOOL_LARGE_BLOCK + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))) + if (free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) + MPOOL_LARGE_BLOCK + + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR PASSED(); @@ -596,15 +619,16 @@ test_allocate_new_page(void) return 0; error: - H5E_BEGIN_TRY { - if(mp) + H5E_BEGIN_TRY + { + if (mp) H5MP_close(mp); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_allocate_new_page() */ - /*------------------------------------------------------------------------- * Function: test_allocate_random * @@ -621,13 +645,13 @@ error: static int test_allocate_random(void) { - H5MP_pool_t *mp; /* Memory pool */ - size_t u; /* Local index variable */ - time_t curr_time; /* Current time, for seeding random number generator */ - size_t *blk_size = NULL; /* Pointer to block sizes */ - void **spc = NULL; /* Pointer to space allocated */ - size_t swap_idx; /* Location to swap with when shuffling */ - void *swap_ptr; /* Pointer to swap when shuffling */ + H5MP_pool_t *mp; /* Memory pool */ + size_t u; /* Local index variable */ + time_t curr_time; /* Current time, for seeding random number generator */ + size_t * blk_size = NULL; /* Pointer to block sizes */ + void ** spc = NULL; /* Pointer to space allocated */ + size_t swap_idx; /* Location to swap with when shuffling */ + void * swap_ptr; /* Pointer to swap when shuffling */ /* * Test memory pool allocation @@ -637,68 +661,68 @@ test_allocate_random(void) /* Initialize random number seed */ curr_time = HDtime(NULL); #ifdef QAK -curr_time=1115412944; -HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); + curr_time = 1115412944; + HDfprintf(stderr, "curr_time=%lu\n", (unsigned long)curr_time); #endif /* QAK */ HDsrandom((unsigned)curr_time); /* Create a memory pool */ - if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) + if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) TEST_ERROR /* Allocate space for the block sizes */ - if(NULL == (blk_size = (size_t *)HDmalloc(sizeof(size_t) * MPOOL_NUM_RANDOM))) + if (NULL == (blk_size = (size_t *)HDmalloc(sizeof(size_t) * MPOOL_NUM_RANDOM))) TEST_ERROR /* Allocate space for the block pointers */ - if(NULL == (spc = (void **)HDmalloc(sizeof(void *) * MPOOL_NUM_RANDOM))) + if (NULL == (spc = (void **)HDmalloc(sizeof(void *) * MPOOL_NUM_RANDOM))) TEST_ERROR /* Initialize the block sizes with random values */ - for(u = 0; u < MPOOL_NUM_RANDOM; u++) + for (u = 0; u < MPOOL_NUM_RANDOM; u++) blk_size[u] = (size_t)(HDrandom() % MPOOL_RANDOM_MAX_SIZE) + 1; /* Allocate space in pool */ - for(u = 0; u < MPOOL_NUM_RANDOM; u++) - if(NULL == (spc[u] = H5MP_malloc(mp, blk_size[u]))) + for (u = 0; u < MPOOL_NUM_RANDOM; u++) + if (NULL == (spc[u] = H5MP_malloc(mp, blk_size[u]))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Shuffle pointers to free */ - for(u = 0; u < MPOOL_NUM_RANDOM; u++) { - swap_idx = (size_t)(HDrandom() % (int)(MPOOL_NUM_RANDOM - u)) + u; - swap_ptr = spc[u]; - spc[u] = spc[swap_idx]; + for (u = 0; u < MPOOL_NUM_RANDOM; u++) { + swap_idx = (size_t)(HDrandom() % (int)(MPOOL_NUM_RANDOM - u)) + u; + swap_ptr = spc[u]; + spc[u] = spc[swap_idx]; spc[swap_idx] = swap_ptr; } /* end for */ /* Free blocks in pool */ - for(u = 0; u < MPOOL_NUM_RANDOM; u++) + for (u = 0; u < MPOOL_NUM_RANDOM; u++) H5MP_free(mp, spc[u]); /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Initialize the block sizes with random values */ - for(u = 0; u < MPOOL_NUM_RANDOM; u++) + for (u = 0; u < MPOOL_NUM_RANDOM; u++) blk_size[u] = (size_t)(HDrandom() % MPOOL_RANDOM_MAX_SIZE) + 1; /* Allocate space in pool (again) */ /* (Leave allocated to test closing pool with many blocks still allocated) */ - for(u = 0; u < MPOOL_NUM_RANDOM; u++) - if(NULL == (spc[u] = H5MP_malloc(mp, blk_size[u]))) + for (u = 0; u < MPOOL_NUM_RANDOM; u++) + if (NULL == (spc[u] = H5MP_malloc(mp, blk_size[u]))) TEST_ERROR /* Check that free space totals match */ - if(H5MP_pool_is_free_size_correct(mp) <= 0) + if (H5MP_pool_is_free_size_correct(mp) <= 0) TEST_ERROR /* Close the memory pool */ - if(H5MP_close(mp) < 0) + if (H5MP_close(mp) < 0) TEST_ERROR /* Free memory for block sizes & pointers */ @@ -710,19 +734,20 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); return 0; error: - if(blk_size) + if (blk_size) HDfree(blk_size); - if(spc) + if (spc) HDfree(spc); - H5E_BEGIN_TRY { - if(mp) + H5E_BEGIN_TRY + { + if (mp) H5MP_close(mp); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_allocate_random() */ - /*------------------------------------------------------------------------- * Function: main * @@ -757,7 +782,7 @@ main(void) nerrors += test_allocate_new_page(); nerrors += test_allocate_random(); - if(nerrors) + if (nerrors) goto error; puts("All memory pool tests passed."); @@ -767,4 +792,3 @@ error: puts("*** TESTS FAILED ***"); return 1; } - diff --git a/test/reserved.c b/test/reserved.c index 7e53d9c..e4d91d3 100644 --- a/test/reserved.c +++ b/test/reserved.c @@ -14,12 +14,7 @@ #include "h5test.h" #ifdef BROKEN -const char *FILENAME[] = { - "rsrv_heap", - "rsrv_ohdr", - "rsrv_vlen", - NULL -}; +const char *FILENAME[] = {"rsrv_heap", "rsrv_ohdr", "rsrv_vlen", NULL}; /*------------------------------------------------------------------------- * Function: rsrv_heap @@ -43,11 +38,11 @@ const char *FILENAME[] = { static herr_t rsrv_heap(void) { - hid_t file_id=(-1), dataset_id=(-1), dataspace_id=(-1); - hid_t fapl=(-1), fcpl=(-1); - hsize_t dims[1] = {1}; - char filename[1024], dset_name[10]; - int i; + hid_t file_id = (-1), dataset_id = (-1), dataspace_id = (-1); + hid_t fapl = (-1), fcpl = (-1); + hsize_t dims[1] = {1}; + char filename[1024], dset_name[10]; + int i; TESTING("Reserving file space for heap"); @@ -57,80 +52,102 @@ rsrv_heap(void) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Set file address sizes to be very small. */ fcpl = H5Pcreate(H5P_FILE_CREATE); - if(fcpl < 0) TEST_ERROR; - if(H5Pset_sizes(fcpl, (size_t)2,(size_t)2) < 0) TEST_ERROR; + if (fcpl < 0) + TEST_ERROR; + if (H5Pset_sizes(fcpl, (size_t)2, (size_t)2) < 0) + TEST_ERROR; file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); - if(file_id < 0) TEST_ERROR; + if (file_id < 0) + TEST_ERROR; /* Write datasets until the file is full, at which point HDF5 * should throw an error. */ - for(i = 0; i < 200; i++) { - H5E_BEGIN_TRY { + for (i = 0; i < 200; i++) { + H5E_BEGIN_TRY + { dataspace_id = H5Screate_simple(1, dims, dims); - } H5E_END_TRY + } + H5E_END_TRY HDsprintf(dset_name, "Dset %d", i); - H5E_BEGIN_TRY { - dataset_id = H5Dcreate2(file_id, dset_name, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY + H5E_BEGIN_TRY + { + dataset_id = H5Dcreate2(file_id, dset_name, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY - if(dataset_id < 0) + if (dataset_id < 0) break; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dwrite(dataset_id, H5T_NATIVE_INT, dataspace_id, dataspace_id, H5P_DEFAULT, &i); - } H5E_END_TRY + } + H5E_END_TRY - if(H5Dclose(dataset_id) < 0) TEST_ERROR; - if(H5Sclose(dataspace_id) < 0) TEST_ERROR; + if (H5Dclose(dataset_id) < 0) + TEST_ERROR; + if (H5Sclose(dataspace_id) < 0) + TEST_ERROR; } /* end for */ /* The loop should have broken before completing--the file should not have had * enough address space to hold 200 datasets (or this test needs to be updated!). */ - if(i == 200) + if (i == 200) TEST_ERROR; /* Close the file, property lists, and library */ - if(H5Fclose(file_id) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Pclose(fcpl) < 0) TEST_ERROR; - if(H5close() < 0) TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Pclose(fcpl) < 0) + TEST_ERROR; + if (H5close() < 0) + TEST_ERROR; /* Re-open the library and try to read a dataset from the file we created */ - if(H5open() < 0) TEST_ERROR; + if (H5open() < 0) + TEST_ERROR; HDsprintf(dset_name, "Dset %d", i - 2); file_id = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); - if(file_id < 0) TEST_ERROR; + if (file_id < 0) + TEST_ERROR; dataset_id = H5Dopen2(file_id, dset_name, H5P_DEFAULT); /* If we can read a dataset from the file, the file has been flushed to disk * (if the heap or object headers weren't flushed, the file would be empty). */ - if(dataset_id == H5I_BADID) - TEST_ERROR; + if (dataset_id == H5I_BADID) + TEST_ERROR; - if(H5Dclose(dataset_id) < 0) TEST_ERROR; - if(H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Dclose(dataset_id) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; PASSED(); return 0; error: /* Close everything we can and exit */ - H5E_BEGIN_TRY { - H5Dclose(dataset_id); - H5Sclose(dataspace_id); - H5Pclose(fcpl); - H5Pclose(fapl); - H5Fclose(file_id); - } H5E_END_TRY + H5E_BEGIN_TRY + { + H5Dclose(dataset_id); + H5Sclose(dataspace_id); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(file_id); + } + H5E_END_TRY return 1; } @@ -156,13 +173,13 @@ error: static herr_t rsrv_ohdr(void) { - hid_t file_id=(-1), dataset_id=(-1), dataspace_id=(-1); - hid_t fapl=(-1), fcpl=(-1), aid, attr_id; - hsize_t dims[2]; - herr_t status; - int attrval[4][6]; - char filename[1024], attrname[20]; - int i; + hid_t file_id = (-1), dataset_id = (-1), dataspace_id = (-1); + hid_t fapl = (-1), fcpl = (-1), aid, attr_id; + hsize_t dims[2]; + herr_t status; + int attrval[4][6]; + char filename[1024], attrname[20]; + int i; TESTING("Reserving file space for object headers"); @@ -171,39 +188,47 @@ rsrv_ohdr(void) h5_fixname(FILENAME[1], fapl, filename, sizeof filename); fcpl = H5Pcreate(H5P_FILE_CREATE); - if(fcpl < 0) TEST_ERROR; - if(H5Pset_sizes(fcpl, (size_t)2,(size_t)2) < 0) TEST_ERROR; + if (fcpl < 0) + TEST_ERROR; + if (H5Pset_sizes(fcpl, (size_t)2, (size_t)2) < 0) + TEST_ERROR; file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); - if(file_id < 0) TEST_ERROR; + if (file_id < 0) + TEST_ERROR; /* Create the data space for the dataset. */ - dims[0] = 4; - dims[1] = 6; + dims[0] = 4; + dims[1] = 6; dataspace_id = H5Screate_simple(2, dims, NULL); - if(dataspace_id < 0) TEST_ERROR; + if (dataspace_id < 0) + TEST_ERROR; /* Create the dataset. */ - dataset_id = H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dataset_id < 0) TEST_ERROR; + dataset_id = + H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dataset_id < 0) + TEST_ERROR; - for(i = 0; i < 6; i++) { + for (i = 0; i < 6; i++) { attrval[0][i] = 0; attrval[1][i] = 1; attrval[2][i] = 2; attrval[3][i] = 3; } /* end for */ - for(i = 0; i < 2000; i++) { + for (i = 0; i < 2000; i++) { HDsprintf(attrname, "attr %d", i); - H5E_BEGIN_TRY{ - aid = H5Screate_simple(2, dims, NULL); + H5E_BEGIN_TRY + { + aid = H5Screate_simple(2, dims, NULL); attr_id = H5Acreate2(dataset_id, attrname, H5T_STD_I32BE, aid, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr_id, H5T_NATIVE_INT, attrval); status = H5Aclose(attr_id); - } H5E_END_TRY + } + H5E_END_TRY - if(status < 0) + if (status < 0) break; } /* end for */ @@ -211,48 +236,60 @@ rsrv_ohdr(void) * enough address space to hold 2000 attributes (or this test needs to be updated !). */ - if(i == 2000) + if (i == 2000) TEST_ERROR; /* End access to the dataset and dataspace and release resources. */ - if(H5Dclose(dataset_id) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Pclose(fcpl) < 0) TEST_ERROR; - if(H5Sclose(dataspace_id) < 0) TEST_ERROR; + if (H5Dclose(dataset_id) < 0) + TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Pclose(fcpl) < 0) + TEST_ERROR; + if (H5Sclose(dataspace_id) < 0) + TEST_ERROR; /* Close the file and the library. */ - if(H5Fclose(file_id) < 0) TEST_ERROR; - if(H5close() < 0) TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5close() < 0) + TEST_ERROR; /* Re-open the library and try to read a dataset from the file we created */ - if(H5open() < 0) TEST_ERROR; + if (H5open() < 0) + TEST_ERROR; file_id = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); - if(file_id < 0) TEST_ERROR; + if (file_id < 0) + TEST_ERROR; dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT); /* If we can read the dataset from the file, the file has been flushed to disk * (if the heap or object headers weren't flushed, the file would be empty). */ - if(dataset_id == H5I_BADID) + if (dataset_id == H5I_BADID) TEST_ERROR; - if(H5Dclose(dataset_id) < 0) TEST_ERROR; - if(H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Dclose(dataset_id) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; PASSED(); return 0; error: /* Close everything we can and exit */ - H5E_BEGIN_TRY { - H5Dclose(dataset_id); - H5Sclose(dataspace_id); - H5Pclose(fcpl); - H5Pclose(fapl); - H5Fclose(file_id); - } H5E_END_TRY + H5E_BEGIN_TRY + { + H5Dclose(dataset_id); + H5Sclose(dataspace_id); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(file_id); + } + H5E_END_TRY return 1; } @@ -280,16 +317,16 @@ error: static herr_t rsrv_vlen(void) { - hid_t file_id=(-1), dataset_id=(-1), dataspace_id=(-1), type_id=(-1); - hid_t fapl=(-1), fcpl=(-1), mem_space_id=(-1); - hssize_t offset[1]; - hsize_t start[1]; - hsize_t dims[1], count[1]; - herr_t status; - int i; - int write_buf[20]; - char filename[1024]; - hvl_t vlen_data; + hid_t file_id = (-1), dataset_id = (-1), dataspace_id = (-1), type_id = (-1); + hid_t fapl = (-1), fcpl = (-1), mem_space_id = (-1); + hssize_t offset[1]; + hsize_t start[1]; + hsize_t dims[1], count[1]; + herr_t status; + int i; + int write_buf[20]; + char filename[1024]; + hvl_t vlen_data; TESTING("Reserved space with variable length data"); @@ -299,103 +336,126 @@ rsrv_vlen(void) /* Make file address space very small */ fcpl = H5Pcreate(H5P_FILE_CREATE); - if(fcpl < 0) TEST_ERROR; - if(H5Pset_sizes(fcpl, (size_t)2,(size_t)2) < 0) TEST_ERROR; + if (fcpl < 0) + TEST_ERROR; + if (H5Pset_sizes(fcpl, (size_t)2, (size_t)2) < 0) + TEST_ERROR; file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); - if(file_id < 0) TEST_ERROR; + if (file_id < 0) + TEST_ERROR; /* Create the data space for the dataset. */ - dims[0] = 2000; + dims[0] = 2000; dataspace_id = H5Screate_simple(1, dims, NULL); - if(dataspace_id < 0) TEST_ERROR; + if (dataspace_id < 0) + TEST_ERROR; /* Create a variable length type */ type_id = H5Tvlen_create(H5T_NATIVE_INT); - if(type_id < 0) TEST_ERROR; + if (type_id < 0) + TEST_ERROR; /* Create the dataset. */ dataset_id = H5Dcreate2(file_id, "/dset", type_id, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dataset_id < 0) TEST_ERROR; + if (dataset_id < 0) + TEST_ERROR; /* Create some data to write */ - for(i = 0; i < 20; i++) + for (i = 0; i < 20; i++) write_buf[i] = i + 1; vlen_data.p = write_buf; /* Create a memory dataspace for writing */ - dims[0] = 1; + dims[0] = 1; mem_space_id = H5Screate_simple(1, dims, NULL); - if(mem_space_id < 0) TEST_ERROR; + if (mem_space_id < 0) + TEST_ERROR; /* Create a selection to write to */ start[0] = 0; count[0] = 1; - if(H5Sselect_hyperslab(dataspace_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR; + if (H5Sselect_hyperslab(dataspace_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + TEST_ERROR; - for(i = 0; i< 2000; i++) { - vlen_data.len = (i%20) + 1; + for (i = 0; i < 2000; i++) { + vlen_data.len = (i % 20) + 1; offset[0] = i; - if( H5Soffset_simple(dataspace_id, offset) <0) TEST_ERROR; + if (H5Soffset_simple(dataspace_id, offset) < 0) + TEST_ERROR; H5E_BEGIN_TRY - status = H5Dwrite(dataset_id, type_id, mem_space_id, dataspace_id, H5P_DEFAULT, &vlen_data); + status = H5Dwrite(dataset_id, type_id, mem_space_id, dataspace_id, H5P_DEFAULT, &vlen_data); H5E_END_TRY - if(status < 0) + if (status < 0) break; } /* end for */ /* The loop should have broken before completing--the file should not have had * enough address space to hold 2000 attributes (or this test needs to be updated!). */ - if(i == 2000) + if (i == 2000) TEST_ERROR; /* End access to the dataset and dataspace and release resources. */ - if(H5Dclose(dataset_id) < 0) TEST_ERROR; - if(H5Pclose(fcpl) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) TEST_ERROR; - if(H5Sclose(dataspace_id) < 0) TEST_ERROR; - if(H5Tclose(type_id) < 0) TEST_ERROR; - if(H5Sclose(mem_space_id) < 0) TEST_ERROR; + if (H5Dclose(dataset_id) < 0) + TEST_ERROR; + if (H5Pclose(fcpl) < 0) + TEST_ERROR; + if (H5Pclose(fapl) < 0) + TEST_ERROR; + if (H5Sclose(dataspace_id) < 0) + TEST_ERROR; + if (H5Tclose(type_id) < 0) + TEST_ERROR; + if (H5Sclose(mem_space_id) < 0) + TEST_ERROR; /* Close the file and the library. */ - if(H5Fclose(file_id) < 0) TEST_ERROR; - if(H5close() < 0) TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; + if (H5close() < 0) + TEST_ERROR; /* Re-open the library and try to read a dataset from the file we created */ - if(H5open() < 0) TEST_ERROR; + if (H5open() < 0) + TEST_ERROR; file_id = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); - if(file_id < 0) TEST_ERROR; + if (file_id < 0) + TEST_ERROR; dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT); /* If we can read the dataset from the file, the file has been flushed to disk * (if the heap or object headers weren't flushed, the file would be empty). */ - if(dataset_id == H5I_BADID) + if (dataset_id == H5I_BADID) TEST_ERROR; - if(H5Dclose(dataset_id) < 0) TEST_ERROR; - if(H5Fclose(file_id) < 0) TEST_ERROR; + if (H5Dclose(dataset_id) < 0) + TEST_ERROR; + if (H5Fclose(file_id) < 0) + TEST_ERROR; PASSED(); return 0; error: /* Close everything we can and exit */ - H5E_BEGIN_TRY { - H5Dclose(dataset_id); - H5Sclose(dataspace_id); - H5Sclose(mem_space_id); - H5Tclose(type_id); - H5Pclose(fcpl); - H5Pclose(fapl); - H5Fclose(file_id); - } H5E_END_TRY + H5E_BEGIN_TRY + { + H5Dclose(dataset_id); + H5Sclose(dataspace_id); + H5Sclose(mem_space_id); + H5Tclose(type_id); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(file_id); + } + H5E_END_TRY return 1; } #endif /* BROKEN */ @@ -425,36 +485,35 @@ main(void) * (Also, we should try to make this test work with all the VFDs) */ #ifdef BROKEN - int num_errs=0; - hid_t fapl; + int num_errs = 0; + hid_t fapl; const char *envval = NULL; envval = HDgetenv("HDF5_DRIVER"); if (envval == NULL) envval = "nomatch"; -/* QAK: should be able to use the core driver? */ - if (HDstrcmp(envval, "core") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "family")) { - num_errs+=rsrv_ohdr(); - num_errs+=rsrv_heap(); - num_errs+=rsrv_vlen(); - - if(num_errs > 0) - HDprintf("**** %d FAILURE%s! ****\n", num_errs, num_errs==1?"":"S"); - else - HDputs("All address space reservation tests passed."); - - fapl = h5_fileaccess(); - h5_cleanup(FILENAME, fapl); - return num_errs; + /* QAK: should be able to use the core driver? */ + if (HDstrcmp(envval, "core") && HDstrcmp(envval, "split") && HDstrcmp(envval, "multi") && + HDstrcmp(envval, "family")) { + num_errs += rsrv_ohdr(); + num_errs += rsrv_heap(); + num_errs += rsrv_vlen(); + + if (num_errs > 0) + HDprintf("**** %d FAILURE%s! ****\n", num_errs, num_errs == 1 ? "" : "S"); + else + HDputs("All address space reservation tests passed."); + + fapl = h5_fileaccess(); + h5_cleanup(FILENAME, fapl); + return num_errs; } - else - { - HDputs("All address space reservation tests skippped - Incompatible with current Virtual File Driver"); + else { + HDputs( + "All address space reservation tests skippped - Incompatible with current Virtual File Driver"); } #endif /* BROKEN */ SKIPPED(); return 0; - } - diff --git a/test/ros3.c b/test/ros3.c index 73b6ac2..fd5ce78 100644 --- a/test/ros3.c +++ b/test/ros3.c @@ -77,7 +77,6 @@ * *****************************************************************************/ - /*---------------------------------------------------------------------------- * * ifdef flag: JSVERIFY_EXP_ACT @@ -89,7 +88,6 @@ */ #define JSVERIFY_EXP_ACT 1L - /*---------------------------------------------------------------------------- * * Macro: JSFAILED_AT() @@ -106,10 +104,10 @@ * *---------------------------------------------------------------------------- */ -#define JSFAILED_AT() { \ - HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ -} - +#define JSFAILED_AT() \ + { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ + } /*---------------------------------------------------------------------------- * @@ -134,12 +132,11 @@ * *---------------------------------------------------------------------------- */ -#define FAIL_IF(condition) \ -if (condition) { \ - JSFAILED_AT() \ - goto error; \ -} - +#define FAIL_IF(condition) \ + if (condition) { \ + JSFAILED_AT() \ + goto error; \ + } /*---------------------------------------------------------------------------- * @@ -164,14 +161,13 @@ if (condition) { \ *---------------------------------------------------------------------------- */ #if 0 /* UNUSED */ -#define FAIL_UNLESS(condition) \ -if (!(condition)) { \ - JSFAILED_AT() \ - goto error; \ -} +#define FAIL_UNLESS(condition) \ + if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ + } #endif - /*---------------------------------------------------------------------------- * * Macro: JSERR_LONG() @@ -197,16 +193,16 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSERR_LONG(expected, actual, reason) { \ - JSFAILED_AT() \ - if (reason!= NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ - (long)(expected), (long)(actual)); \ - } \ -} - +#define JSERR_LONG(expected, actual, reason) \ + { \ + JSFAILED_AT() \ + if (reason != NULL) { \ + HDprintf("%s\n", (reason)); \ + } \ + else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", (long)(expected), (long)(actual)); \ + } \ + } /*---------------------------------------------------------------------------- * @@ -236,21 +232,19 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSERR_STR(expected, actual, reason) { \ - JSFAILED_AT() \ - if ((reason) != NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ - (expected), (actual)); \ - } \ -} - - +#define JSERR_STR(expected, actual, reason) \ + { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } \ + else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", (expected), (actual)); \ + } \ + } #ifdef JSVERIFY_EXP_ACT - /*---------------------------------------------------------------------------- * * Macro: JSVERIFY() @@ -267,12 +261,11 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY(expected, actual, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY */ - +#define JSVERIFY(expected, actual, reason) \ + if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY */ /*---------------------------------------------------------------------------- * @@ -290,12 +283,11 @@ if ((long)(actual) != (long)(expected)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY_NOT(expected, actual, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ - +#define JSVERIFY_NOT(expected, actual, reason) \ + if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY_NOT */ /*---------------------------------------------------------------------------- * @@ -313,12 +305,11 @@ if ((long)(actual) == (long)(expected)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY_STR(expected, actual, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ - +#define JSVERIFY_STR(expected, actual, reason) \ + if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY_STR */ #else /* JSVERIFY_EXP_ACT not defined @@ -326,7 +317,6 @@ if (strcmp((actual), (expected)) != 0) { \ * Repeats macros above, but with actual/expected parameters reversed. */ - /*---------------------------------------------------------------------------- * Macro: JSVERIFY() * See: JSVERIFY documentation above. @@ -334,12 +324,11 @@ if (strcmp((actual), (expected)) != 0) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY(actual, expected, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY */ - +#define JSVERIFY(actual, expected, reason) \ + if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY */ /*---------------------------------------------------------------------------- * Macro: JSVERIFY_NOT() @@ -348,12 +337,11 @@ if ((long)(actual) != (long)(expected)) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY_NOT(actual, expected, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ - +#define JSVERIFY_NOT(actual, expected, reason) \ + if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY_NOT */ /*---------------------------------------------------------------------------- * Macro: JSVERIFY_STR() @@ -362,11 +350,11 @@ if ((long)(actual) == (long)(expected)) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY_STR(actual, expected, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ +#define JSVERIFY_STR(actual, expected, reason) \ + if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY_STR */ #endif /* ifdef/else JSVERIFY_EXP_ACT */ @@ -374,16 +362,16 @@ if (strcmp((actual), (expected)) != 0) { \ * OTHER MACROS AND DEFINITIONS * ********************************/ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) #define S3_TEST_PROFILE_NAME "ros3_vfd_test" #define S3_TEST_MAX_URL_SIZE 256 #define S3_TEST_RESOURCE_TEXT_RESTRICTED "t8.shakespeare.txt" -#define S3_TEST_RESOURCE_TEXT_PUBLIC "Poe_Raven.txt" -#define S3_TEST_RESOURCE_H5_PUBLIC "GMODO-SVM01.h5" -#define S3_TEST_RESOURCE_MISSING "missing.csv" +#define S3_TEST_RESOURCE_TEXT_PUBLIC "Poe_Raven.txt" +#define S3_TEST_RESOURCE_H5_PUBLIC "GMODO-SVM01.h5" +#define S3_TEST_RESOURCE_MISSING "missing.csv" static char url_text_restricted[S3_TEST_MAX_URL_SIZE] = ""; static char url_text_public[S3_TEST_MAX_URL_SIZE] = ""; @@ -402,17 +390,13 @@ static char s3_test_aws_region[16]; static char s3_test_aws_access_key_id[64]; static char s3_test_aws_secret_access_key[128]; -H5FD_ros3_fapl_t restricted_access_fa = { - H5FD_CURR_ROS3_FAPL_T_VERSION, /* fapl version */ - TRUE, /* authenticate */ - "", /* aws region */ - "", /* access key id */ - ""}; /* secret access key */ - -H5FD_ros3_fapl_t anonymous_fa = { - H5FD_CURR_ROS3_FAPL_T_VERSION, - FALSE, "", "", "" }; +H5FD_ros3_fapl_t restricted_access_fa = {H5FD_CURR_ROS3_FAPL_T_VERSION, /* fapl version */ + TRUE, /* authenticate */ + "", /* aws region */ + "", /* access key id */ + ""}; /* secret access key */ +H5FD_ros3_fapl_t anonymous_fa = {H5FD_CURR_ROS3_FAPL_T_VERSION, FALSE, "", "", ""}; /*--------------------------------------------------------------------------- * @@ -446,92 +430,108 @@ test_fapl_config_validation(void) *************************/ struct testcase { - const char *msg; - herr_t expected; - H5FD_ros3_fapl_t config; + const char * msg; + herr_t expected; + H5FD_ros3_fapl_t config; }; /************************ * test-local variables * ************************/ - hid_t fapl_id = -1; /* file access property list ID */ + hid_t fapl_id = -1; /* file access property list ID */ H5FD_ros3_fapl_t config; H5FD_ros3_fapl_t fa_fetch; - herr_t success = SUCCEED; - unsigned int i = 0; - unsigned int ncases = 8; /* should equal number of cases */ - struct testcase *case_ptr = NULL; /* dumb work-around for possible */ - /* dynamic cases creation because */ - /* of compiler warnings Wlarger-than */ - struct testcase cases_arr[] = { - { "non-authenticating config allows empties.\n", + herr_t success = SUCCEED; + unsigned int i = 0; + unsigned int ncases = 8; /* should equal number of cases */ + struct testcase *case_ptr = NULL; /* dumb work-around for possible */ + /* dynamic cases creation because */ + /* of compiler warnings Wlarger-than */ + struct testcase cases_arr[] = { + { + "non-authenticating config allows empties.\n", SUCCEED, - { H5FD_CURR_ROS3_FAPL_T_VERSION, /* version */ - FALSE, /* authenticate */ - "", /* aws_region */ - "", /* secret_id */ - "", /* secret_key */ + { + H5FD_CURR_ROS3_FAPL_T_VERSION, /* version */ + FALSE, /* authenticate */ + "", /* aws_region */ + "", /* secret_id */ + "", /* secret_key */ }, }, - { "authenticating config asks for populated strings.\n", + { + "authenticating config asks for populated strings.\n", FAIL, - { H5FD_CURR_ROS3_FAPL_T_VERSION, + { + H5FD_CURR_ROS3_FAPL_T_VERSION, TRUE, "", "", "", }, }, - { "populated strings; key is the empty string?\n", + { + "populated strings; key is the empty string?\n", SUCCEED, - { H5FD_CURR_ROS3_FAPL_T_VERSION, + { + H5FD_CURR_ROS3_FAPL_T_VERSION, TRUE, "region", "me", "", }, }, - { "id cannot be empty.\n", + { + "id cannot be empty.\n", FAIL, - { H5FD_CURR_ROS3_FAPL_T_VERSION, + { + H5FD_CURR_ROS3_FAPL_T_VERSION, TRUE, "", "me", "", }, }, - { "region cannot be empty.\n", + { + "region cannot be empty.\n", FAIL, - { H5FD_CURR_ROS3_FAPL_T_VERSION, + { + H5FD_CURR_ROS3_FAPL_T_VERSION, TRUE, "where", "", "", }, }, - { "all strings populated.\n", + { + "all strings populated.\n", SUCCEED, - { H5FD_CURR_ROS3_FAPL_T_VERSION, + { + H5FD_CURR_ROS3_FAPL_T_VERSION, TRUE, "where", "who", "thisIsA GREAT seeeecrit", }, }, - { "incorrect version should fail\n", + { + "incorrect version should fail\n", FAIL, - { 12345, + { + 12345, FALSE, "", "", "", }, }, - { "non-authenticating config cares not for (de)population" + { + "non-authenticating config cares not for (de)population" "of strings.\n", SUCCEED, - { H5FD_CURR_ROS3_FAPL_T_VERSION, + { + H5FD_CURR_ROS3_FAPL_T_VERSION, FALSE, "someregion", "someid", @@ -560,58 +560,46 @@ test_fapl_config_validation(void) *--------------- */ case_ptr = &cases_arr[i]; - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) /* sanity-check */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + FAIL_IF(fapl_id < 0) /* sanity-check */ /*----------------------------------- * Actually test. * Mute stack trace in failure cases. *----------------------------------- */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { /* `H5FD_ros3_validate_config(...)` is static/private * to src/ros3.c and cannot (and should not?) be tested directly? * Instead, validate config through public api. */ success = H5Pset_fapl_ros3(fapl_id, &case_ptr->config); - } H5E_END_TRY; + } + H5E_END_TRY; - JSVERIFY( case_ptr->expected, success, case_ptr->msg ) + JSVERIFY(case_ptr->expected, success, case_ptr->msg) /* Make sure we can get back what we put in. * Only valid if the fapl configuration does not result in error. */ if (success == SUCCEED) { config = case_ptr->config; - JSVERIFY( SUCCEED, - H5Pget_fapl_ros3(fapl_id, &fa_fetch), - "unable to get fapl" ) - - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, - fa_fetch.version, - "invalid version number" ) - JSVERIFY( config.version, - fa_fetch.version, - "version number mismatch" ) - JSVERIFY( config.authenticate, - fa_fetch.authenticate, - "authentication flag mismatch" ) - JSVERIFY_STR( config.aws_region, - fa_fetch.aws_region, - NULL ) - JSVERIFY_STR( config.secret_id, - fa_fetch.secret_id, - NULL ) - JSVERIFY_STR( config.secret_key, - fa_fetch.secret_key, - NULL ) + JSVERIFY(SUCCEED, H5Pget_fapl_ros3(fapl_id, &fa_fetch), "unable to get fapl") + + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa_fetch.version, "invalid version number") + JSVERIFY(config.version, fa_fetch.version, "version number mismatch") + JSVERIFY(config.authenticate, fa_fetch.authenticate, "authentication flag mismatch") + JSVERIFY_STR(config.aws_region, fa_fetch.aws_region, NULL) + JSVERIFY_STR(config.secret_id, fa_fetch.secret_id, NULL) + JSVERIFY_STR(config.secret_key, fa_fetch.secret_key, NULL) } /*----------------------------- * per-test sanitation/teardown *----------------------------- */ - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; } /* for each test case */ @@ -625,14 +613,15 @@ error: ***********/ if (fapl_id < 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; } return 1; } /* test_fapl_config_validation */ - /*------------------------------------------------------------------------- * * Function: test_ros3_fapl() @@ -661,15 +650,15 @@ test_ros3_fapl(void) * test-local variables * ************************/ - hid_t fapl_id = -1; /* file access property list ID */ - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - H5FD_ros3_fapl_t ros3_fa_0 = { + hid_t fapl_id = -1; /* file access property list ID */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + H5FD_ros3_fapl_t ros3_fa_0 = { H5FD_CURR_ROS3_FAPL_T_VERSION, /* version */ - FALSE, /* authenticate */ - "", /* aws_region */ - "", /* secret_id */ - "plugh", /* secret_key */ + FALSE, /* authenticate */ + "", /* aws_region */ + "", /* secret_id */ + "plugh", /* secret_key */ }; TESTING("ROS3 fapl "); @@ -677,40 +666,40 @@ test_ros3_fapl(void) /* Set property list and file name for ROS3 driver. */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) + FAIL_IF(fapl_id < 0) - FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &ros3_fa_0) ) + FAIL_IF(FAIL == H5Pset_fapl_ros3(fapl_id, &ros3_fa_0)) driver_id = H5Pget_driver(fapl_id); - FAIL_IF( driver_id < 0 ) + FAIL_IF(driver_id < 0) /**************** * Check that the VFD feature flags are correct * SPEC MAY CHANGE ******************/ - FAIL_IF( H5FDdriver_query(driver_id, &driver_flags) < 0 ) + FAIL_IF(H5FDdriver_query(driver_id, &driver_flags) < 0) - JSVERIFY_NOT( 0, (driver_flags & H5FD_FEAT_DATA_SIEVE), - "bit(s) in `driver_flags` must align with " - "H5FD_FEAT_DATA_SIEVE" ) + JSVERIFY_NOT(0, (driver_flags & H5FD_FEAT_DATA_SIEVE), + "bit(s) in `driver_flags` must align with " + "H5FD_FEAT_DATA_SIEVE") - JSVERIFY( H5FD_FEAT_DATA_SIEVE, driver_flags, - "H5FD_FEAT_DATA_SIEVE should be the only supported flag") + JSVERIFY(H5FD_FEAT_DATA_SIEVE, driver_flags, "H5FD_FEAT_DATA_SIEVE should be the only supported flag") PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_ros3_fapl() */ - /*--------------------------------------------------------------------------- * * Function: test_vfd_open() @@ -737,7 +726,6 @@ test_vfd_open(void) * test-local macros * *********************/ - #define FAPL_H5P_DEFAULT -2 #define FAPL_FILE_ACCESS -3 #define FAPL_ROS3_ANON -4 @@ -759,73 +747,83 @@ test_vfd_open(void) ************************/ struct test_condition tests[] = { - { "default property list (H5P_DEFAULT) is invalid", + { + "default property list (H5P_DEFAULT) is invalid", url_text_public, H5F_ACC_RDONLY, FAPL_H5P_DEFAULT, MAXADDR, }, - { "generic file access property list is invalid", + { + "generic file access property list is invalid", url_text_public, H5F_ACC_RDONLY, FAPL_FILE_ACCESS, MAXADDR, }, - { "filename cannot be null", + { + "filename cannot be null", NULL, H5F_ACC_RDONLY, FAPL_ROS3_ANON, MAXADDR, }, - { "filename cannot be empty", + { + "filename cannot be empty", "", H5F_ACC_RDONLY, FAPL_ROS3_ANON, MAXADDR, }, - { "filename must exist", + { + "filename must exist", url_missing, H5F_ACC_RDONLY, FAPL_ROS3_ANON, MAXADDR, }, - { "read-write flag not supported", + { + "read-write flag not supported", url_text_public, H5F_ACC_RDWR, FAPL_ROS3_ANON, MAXADDR, }, - { "truncate flag not supported", + { + "truncate flag not supported", url_text_public, H5F_ACC_TRUNC, FAPL_ROS3_ANON, MAXADDR, }, - { "create flag not supported", + { + "create flag not supported", url_text_public, H5F_ACC_CREAT, FAPL_ROS3_ANON, MAXADDR, }, - { "EXCL flag not supported", + { + "EXCL flag not supported", url_text_public, H5F_ACC_EXCL, FAPL_ROS3_ANON, MAXADDR, }, - { "maxaddr cannot be 0 (caught in `H5FD_open()`)", + { + "maxaddr cannot be 0 (caught in `H5FD_open()`)", url_text_public, H5F_ACC_RDONLY, FAPL_ROS3_ANON, 0, }, }; - H5FD_t *fd = NULL; - hbool_t curl_ready = FALSE; - hid_t fapl_id = -1; - hid_t fapl_file_access = -1; - unsigned i = 0; - unsigned tests_count = 10; + H5FD_t * fd = NULL; + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; + hid_t fapl_file_access = -1; + unsigned i = 0; + unsigned tests_count = 10; TESTING("ROS3 VFD-level open"); @@ -836,15 +834,15 @@ test_vfd_open(void) return 0; } - FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + FAIL_IF(CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) curl_ready = TRUE; fapl_file_access = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_file_access < 0 ) + FAIL_IF(fapl_file_access < 0) fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) - FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &anonymous_fa) ) + FAIL_IF(fapl_id < 0) + FAIL_IF(FAIL == H5Pset_fapl_ros3(fapl_id, &anonymous_fa)) /********* * TESTS * @@ -853,8 +851,8 @@ test_vfd_open(void) /* all the test cases that will _not_ open */ for (i = 0; i < tests_count; i++) { - struct test_condition T = tests[i]; - hid_t _fapl_id = H5P_DEFAULT; + struct test_condition T = tests[i]; + hid_t _fapl_id = H5P_DEFAULT; fd = NULL; @@ -863,35 +861,33 @@ test_vfd_open(void) else if (T.which_fapl == FAPL_ROS3_ANON) _fapl_id = fapl_id; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fd = H5FDopen(T.url, T.flags, _fapl_id, T.maxaddr); - } H5E_END_TRY; + } + H5E_END_TRY; if (NULL != fd) JSVERIFY(1, 0, T.message); /* wrapper to print message and fail */ } - FAIL_IF( NULL != fd ) + FAIL_IF(NULL != fd) /* finally, show that a file can be opened */ - fd = H5FDopen( - url_text_public, - H5F_ACC_RDONLY, - fapl_id, - MAXADDR); - FAIL_IF( NULL == fd ) + fd = H5FDopen(url_text_public, H5F_ACC_RDONLY, fapl_id, MAXADDR); + FAIL_IF(NULL == fd) /************ * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(fd) ) + FAIL_IF(FAIL == H5FDclose(fd)) fd = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; - FAIL_IF( FAIL == H5Pclose(fapl_file_access) ) + FAIL_IF(FAIL == H5Pclose(fapl_file_access)) fapl_file_access = -1; curl_global_cleanup(); @@ -909,14 +905,18 @@ error: (void)H5FDclose(fd); } if (fapl_id >= 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; } if (fapl_file_access >= 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_file_access); - } H5E_END_TRY; + } + H5E_END_TRY; } if (curl_ready == TRUE) { curl_global_cleanup(); @@ -930,7 +930,6 @@ error: } /* test_vfd_open */ - /*--------------------------------------------------------------------------- * * Function: test_eof_eoa() @@ -965,9 +964,9 @@ test_eof_eoa(void) * test-local variables * ************************/ - H5FD_t *fd_shakespeare = NULL; - hbool_t curl_ready = FALSE; - hid_t fapl_id = -1; + H5FD_t *fd_shakespeare = NULL; + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; TESTING("ROS3 eof/eoa gets and sets"); @@ -989,19 +988,15 @@ test_eof_eoa(void) * SETUP * *********/ - FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + FAIL_IF(CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) curl_ready = TRUE; fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( 0 > fapl_id ) - FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa) ) + FAIL_IF(0 > fapl_id) + FAIL_IF(FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa)) - fd_shakespeare = H5FDopen( - url_text_restricted, - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); - FAIL_IF( NULL == fd_shakespeare ) + fd_shakespeare = H5FDopen(url_text_restricted, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); + FAIL_IF(NULL == fd_shakespeare) /********* * TESTS * @@ -1009,45 +1004,30 @@ test_eof_eoa(void) /* verify as found */ - JSVERIFY( 5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), NULL ) - JSVERIFY( H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), - H5FDget_eof(fd_shakespeare, H5FD_MEM_DRAW), - "mismatch between DEFAULT and RAW memory types" ) - JSVERIFY( 0, - H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoA should be unset by H5FDopen" ) + JSVERIFY(5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), NULL) + JSVERIFY(H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), H5FDget_eof(fd_shakespeare, H5FD_MEM_DRAW), + "mismatch between DEFAULT and RAW memory types") + JSVERIFY(0, H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), "EoA should be unset by H5FDopen") /* set EoA below EoF */ - JSVERIFY( SUCCEED, - H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 44442202), - "unable to set EoA (lower)" ) - JSVERIFY( 5458199, - H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoF changed" ) - JSVERIFY( 44442202, - H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoA unchanged" ) + JSVERIFY(SUCCEED, H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 44442202), "unable to set EoA (lower)") + JSVERIFY(5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), "EoF changed") + JSVERIFY(44442202, H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), "EoA unchanged") /* set EoA above EoF */ - JSVERIFY( SUCCEED, - H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 6789012), - "unable to set EoA (higher)" ) - JSVERIFY( 5458199, - H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoF changed" ) - JSVERIFY( 6789012, - H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), - "EoA unchanged" ) + JSVERIFY(SUCCEED, H5FDset_eoa(fd_shakespeare, H5FD_MEM_DEFAULT, 6789012), "unable to set EoA (higher)") + JSVERIFY(5458199, H5FDget_eof(fd_shakespeare, H5FD_MEM_DEFAULT), "EoF changed") + JSVERIFY(6789012, H5FDget_eoa(fd_shakespeare, H5FD_MEM_DEFAULT), "EoA unchanged") /************ * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(fd_shakespeare) ) + FAIL_IF(FAIL == H5FDclose(fd_shakespeare)) - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; curl_global_cleanup(); @@ -1061,19 +1041,22 @@ error: * CLEANUP * ***********/ - if (fd_shakespeare) (void)H5FDclose(fd_shakespeare); - if (TRUE == curl_ready) curl_global_cleanup(); + if (fd_shakespeare) + (void)H5FDclose(fd_shakespeare); + if (TRUE == curl_ready) + curl_global_cleanup(); if (fapl_id >= 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; } return 1; } /* test_eof_eoa */ - /*----------------------------------------------------------------------------- * * Function: test_H5FDread_without_eoa_set_fails() @@ -1091,10 +1074,10 @@ error: static int test_H5FDread_without_eoa_set_fails(void) { - char buffer[256]; - unsigned int i = 0; - H5FD_t *file_shakespeare = NULL; - hid_t fapl_id = -1; + char buffer[256]; + unsigned int i = 0; + H5FD_t * file_shakespeare = NULL; + hid_t fapl_id = -1; TESTING("ROS3 VFD read-eoa temporal coupling library limitation "); @@ -1119,18 +1102,13 @@ test_H5FDread_without_eoa_set_fails(void) /* create ROS3 fapl */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) - FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa) ) + FAIL_IF(fapl_id < 0) + FAIL_IF(FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa)) - file_shakespeare = H5FDopen( - url_text_restricted, - H5F_ACC_RDONLY, - fapl_id, - MAXADDR); - FAIL_IF( NULL == file_shakespeare ) + file_shakespeare = H5FDopen(url_text_restricted, H5F_ACC_RDONLY, fapl_id, MAXADDR); + FAIL_IF(NULL == file_shakespeare) - JSVERIFY( 0, H5FDget_eoa(file_shakespeare, H5FD_MEM_DEFAULT), - "EoA should remain unset by H5FDopen" ) + JSVERIFY(0, H5FDget_eoa(file_shakespeare, H5FD_MEM_DEFAULT), "EoA should remain unset by H5FDopen") for (i = 0; i < 256; i++) buffer[i] = 0; /* zero buffer contents */ @@ -1139,26 +1117,19 @@ test_H5FDread_without_eoa_set_fails(void) * TEST * ********/ - H5E_BEGIN_TRY { /* mute stack trace on expected failure */ - JSVERIFY( FAIL, - H5FDread(file_shakespeare, - H5FD_MEM_DRAW, - H5P_DEFAULT, - 1200699, - 102, - buffer), - "cannot read before eoa is set" ) - } H5E_END_TRY; - JSVERIFY_STR( "", buffer, "buffer should remain untouched" ) + H5E_BEGIN_TRY{/* mute stack trace on expected failure */ + JSVERIFY(FAIL, H5FDread(file_shakespeare, H5FD_MEM_DRAW, H5P_DEFAULT, 1200699, 102, buffer), + "cannot read before eoa is set")} H5E_END_TRY; + JSVERIFY_STR("", buffer, "buffer should remain untouched") /************ * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(file_shakespeare) ) + FAIL_IF(FAIL == H5FDclose(file_shakespeare)) file_shakespeare = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; PASSED(); @@ -1169,19 +1140,21 @@ error: * CLEANUP * ***********/ - if (file_shakespeare) { (void)H5FDclose(file_shakespeare); } + if (file_shakespeare) { + (void)H5FDclose(file_shakespeare); + } if (fapl_id >= 0) { - H5E_BEGIN_TRY { - (void)H5Pclose(fapl_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + (void)H5Pclose(fapl_id); + } + H5E_END_TRY; } return 1; } /* test_H5FDread_without_eoa_set_fails */ - - /*--------------------------------------------------------------------------- * * Function: test_read() @@ -1222,42 +1195,48 @@ test_read(void) * test-local variables * ************************/ struct testcase cases[] = { - { "successful range-get", + { + "successful range-get", 6464, 5691, 32, /* fancy quotes are three bytes each(?) */ SUCCEED, "Quoth the Raven “Nevermore.”", }, - { "read past EOA fails (EOA < EOF < addr)", + { + "read past EOA fails (EOA < EOF < addr)", 3000, 4000, 100, FAIL, NULL, }, - { "read overlapping EOA fails (EOA < addr < EOF < (addr+len))", + { + "read overlapping EOA fails (EOA < addr < EOF < (addr+len))", 3000, 8000, 100, FAIL, NULL, }, - { "read past EOA/EOF fails ((EOA==EOF) < addr)", + { + "read past EOA/EOF fails ((EOA==EOF) < addr)", 6464, 7000, 100, FAIL, NULL, }, - { "read overlapping EOA/EOF fails (addr < (EOA==EOF) < (addr+len))", + { + "read overlapping EOA/EOF fails (addr < (EOA==EOF) < (addr+len))", 6464, 6400, 100, FAIL, NULL, }, - { "read between EOF and EOA fails (EOF < addr < (addr+len) < EOA)", + { + "read between EOF and EOA fails (EOF < addr < (addr+len) < EOA)", 8000, 7000, 100, @@ -1265,14 +1244,14 @@ test_read(void) NULL, }, }; - unsigned testcase_count = 6; - unsigned test_i = 0; - struct testcase test; - herr_t open_return = FAIL; - char buffer[S3_TEST_MAX_URL_SIZE]; - unsigned int i = 0; - H5FD_t *file_raven = NULL; - hid_t fapl_id = -1; + unsigned testcase_count = 6; + unsigned test_i = 0; + struct testcase test; + herr_t open_return = FAIL; + char buffer[S3_TEST_MAX_URL_SIZE]; + unsigned int i = 0; + H5FD_t * file_raven = NULL; + hid_t fapl_id = -1; TESTING("ROS3 VFD read/range-gets"); @@ -1297,19 +1276,19 @@ test_read(void) /* create ROS3 fapl */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) - FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa) ) + FAIL_IF(fapl_id < 0) + FAIL_IF(FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa)) /* open file */ - file_raven = H5FDopen( /* will open with "authenticating" fapl */ - url_text_public, /* TODO: check return state: anon access of restricted says OK? (not NULL) */ - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); /* Demonstrate success with "automatic" value */ - FAIL_IF( NULL == file_raven ) + file_raven = + H5FDopen( /* will open with "authenticating" fapl */ + url_text_public, /* TODO: check return state: anon access of restricted says OK? (not NULL) + */ + H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); /* Demonstrate success with "automatic" value */ + FAIL_IF(NULL == file_raven) - JSVERIFY( 6464, H5FDget_eof(file_raven, H5FD_MEM_DEFAULT), NULL ) + JSVERIFY(6464, H5FDget_eof(file_raven, H5FD_MEM_DEFAULT), NULL) /********* * TESTS * @@ -1324,10 +1303,9 @@ test_read(void) test = cases[test_i]; open_return = FAIL; - FAIL_IF( S3_TEST_MAX_URL_SIZE < test.len ) /* buffer too small! */ + FAIL_IF(S3_TEST_MAX_URL_SIZE < test.len) /* buffer too small! */ - FAIL_IF( FAIL == - H5FD_set_eoa( file_raven, H5FD_MEM_DEFAULT, test.eoa_set) ) + FAIL_IF(FAIL == H5FD_set_eoa(file_raven, H5FD_MEM_DEFAULT, test.eoa_set)) for (i = 0; i < S3_TEST_MAX_URL_SIZE; i++) /* zero buffer contents */ buffer[i] = 0; @@ -1336,21 +1314,15 @@ test_read(void) * conduct test * * ------------ */ - H5E_BEGIN_TRY { - open_return = H5FDread( - file_raven, - H5FD_MEM_DRAW, - H5P_DEFAULT, - test.addr, - test.len, - buffer); - } H5E_END_TRY; - - JSVERIFY( test.success, - open_return, - test.message ) + H5E_BEGIN_TRY + { + open_return = H5FDread(file_raven, H5FD_MEM_DRAW, H5P_DEFAULT, test.addr, test.len, buffer); + } + H5E_END_TRY; + + JSVERIFY(test.success, open_return, test.message) if (open_return == SUCCEED) - JSVERIFY_STR( test.expected, buffer, NULL ) + JSVERIFY_STR(test.expected, buffer, NULL) } /* for each testcase */ @@ -1358,10 +1330,10 @@ test_read(void) * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(file_raven) ) + FAIL_IF(FAIL == H5FDclose(file_raven)) file_raven = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; PASSED(); @@ -1375,16 +1347,17 @@ error: if (file_raven) (void)H5FDclose(file_raven); if (fapl_id >= 0) { - H5E_BEGIN_TRY { - (void)H5Pclose(fapl_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + (void)H5Pclose(fapl_id); + } + H5E_END_TRY; } return 1; } /* test_read */ - /*--------------------------------------------------------------------------- * * Function: test_noops_and_autofails() @@ -1419,14 +1392,13 @@ test_noops_and_autofails(void) * test-local variables * ************************/ - hbool_t curl_ready = FALSE; - hid_t fapl_id = -1; - H5FD_t *file = NULL; - const char data[36] = "The Force shall be with you, always"; + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; + H5FD_t * file = NULL; + const char data[36] = "The Force shall be with you, always"; TESTING("ROS3 VFD always-fail and no-op routines"); - if (FALSE == s3_test_bucket_defined) { SKIPPED(); puts(" environment variable HDF5_ROS3_TEST_BUCKET_URL not defined"); @@ -1438,23 +1410,19 @@ test_noops_and_autofails(void) * SETUP * *********/ - FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + FAIL_IF(CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) curl_ready = TRUE; /* create ROS3 fapl */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) - JSVERIFY( SUCCEED, H5Pset_fapl_ros3(fapl_id, &anonymous_fa), NULL ) + FAIL_IF(fapl_id < 0) + JSVERIFY(SUCCEED, H5Pset_fapl_ros3(fapl_id, &anonymous_fa), NULL) /* open file */ - file = H5FDopen( - url_text_public, - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); - FAIL_IF( NULL == file ) + file = H5FDopen(url_text_public, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); + FAIL_IF(NULL == file) /********* * TESTS * @@ -1462,35 +1430,19 @@ test_noops_and_autofails(void) /* auto-fail calls to write and truncate */ - H5E_BEGIN_TRY { - JSVERIFY( FAIL, - H5FDwrite(file, H5FD_MEM_DRAW, H5P_DEFAULT, 1000, 35, data), - "write must fail" ) - } H5E_END_TRY; - - H5E_BEGIN_TRY { - JSVERIFY( FAIL, - H5FDtruncate(file, H5P_DEFAULT, FALSE), - "truncate must fail" ) - } H5E_END_TRY; - - H5E_BEGIN_TRY { - JSVERIFY( FAIL, - H5FDtruncate(file, H5P_DEFAULT, TRUE), - "truncate must fail (closing)" ) - } H5E_END_TRY; + H5E_BEGIN_TRY{JSVERIFY(FAIL, H5FDwrite(file, H5FD_MEM_DRAW, H5P_DEFAULT, 1000, 35, data), + "write must fail")} H5E_END_TRY; + + H5E_BEGIN_TRY{JSVERIFY(FAIL, H5FDtruncate(file, H5P_DEFAULT, FALSE), "truncate must fail")} H5E_END_TRY; + + H5E_BEGIN_TRY{ + JSVERIFY(FAIL, H5FDtruncate(file, H5P_DEFAULT, TRUE), "truncate must fail (closing)")} H5E_END_TRY; /* no-op calls to `lock()` and `unlock()` */ - JSVERIFY( SUCCEED, - H5FDlock(file, TRUE), - "lock always succeeds; has no effect" ) - JSVERIFY( SUCCEED, - H5FDlock(file, FALSE), - NULL ) - JSVERIFY( SUCCEED, - H5FDunlock(file), - NULL ) + JSVERIFY(SUCCEED, H5FDlock(file, TRUE), "lock always succeeds; has no effect") + JSVERIFY(SUCCEED, H5FDlock(file, FALSE), NULL) + JSVERIFY(SUCCEED, H5FDunlock(file), NULL) /* Lock/unlock with null file or similar error crashes tests. * HDassert in calling heirarchy, `H5FD[un]lock()` and `H5FD_[un]lock()` */ @@ -1499,10 +1451,10 @@ test_noops_and_autofails(void) * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(file) ) + FAIL_IF(FAIL == H5FDclose(file)) file = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; curl_global_cleanup(); @@ -1517,18 +1469,23 @@ error: ***********/ if (fapl_id >= 0) { - H5E_BEGIN_TRY { - (void)H5Pclose(fapl_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + (void)H5Pclose(fapl_id); + } + H5E_END_TRY; + } + if (file) { + (void)H5FDclose(file); + } + if (curl_ready == TRUE) { + curl_global_cleanup(); } - if (file) { (void)H5FDclose(file); } - if (curl_ready == TRUE) { curl_global_cleanup(); } return 1; } /* test_noops_and_autofails*/ - /*--------------------------------------------------------------------------- * * Function: test_cmp() @@ -1563,11 +1520,11 @@ test_cmp(void) * test-local variables * ************************/ - H5FD_t *fd_raven = NULL; - H5FD_t *fd_shakes = NULL; - H5FD_t *fd_raven_2 = NULL; - hbool_t curl_ready = FALSE; - hid_t fapl_id = -1; + H5FD_t *fd_raven = NULL; + H5FD_t *fd_shakes = NULL; + H5FD_t *fd_raven_2 = NULL; + hbool_t curl_ready = FALSE; + hid_t fapl_id = -1; TESTING("ROS3 cmp (comparison)"); @@ -1589,53 +1546,41 @@ test_cmp(void) * SETUP * *********/ - FAIL_IF( CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT) ) + FAIL_IF(CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) curl_ready = TRUE; fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( 0 > fapl_id ) - JSVERIFY( SUCCEED, H5Pset_fapl_ros3(fapl_id, &restricted_access_fa), NULL ) + FAIL_IF(0 > fapl_id) + JSVERIFY(SUCCEED, H5Pset_fapl_ros3(fapl_id, &restricted_access_fa), NULL) - fd_raven = H5FDopen( - url_text_public, - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); - FAIL_IF( NULL == fd_raven ) + fd_raven = H5FDopen(url_text_public, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); + FAIL_IF(NULL == fd_raven) - fd_shakes = H5FDopen( - url_text_restricted, - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); - FAIL_IF( NULL == fd_shakes ) + fd_shakes = H5FDopen(url_text_restricted, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); + FAIL_IF(NULL == fd_shakes) - fd_raven_2 = H5FDopen( - url_text_public, - H5F_ACC_RDONLY, - fapl_id, - HADDR_UNDEF); - FAIL_IF( NULL == fd_raven_2 ) + fd_raven_2 = H5FDopen(url_text_public, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF); + FAIL_IF(NULL == fd_raven_2) /********* * TESTS * *********/ - JSVERIFY( 0, H5FDcmp(fd_raven, fd_raven_2), NULL ) - JSVERIFY( -1, H5FDcmp(fd_raven, fd_shakes), NULL ) - JSVERIFY( -1, H5FDcmp(fd_shakes, fd_raven_2), NULL ) + JSVERIFY(0, H5FDcmp(fd_raven, fd_raven_2), NULL) + JSVERIFY(-1, H5FDcmp(fd_raven, fd_shakes), NULL) + JSVERIFY(-1, H5FDcmp(fd_shakes, fd_raven_2), NULL) /************ * TEARDOWN * ************/ - FAIL_IF( FAIL == H5FDclose(fd_raven) ) + FAIL_IF(FAIL == H5FDclose(fd_raven)) fd_raven = NULL; - FAIL_IF( FAIL == H5FDclose(fd_shakes) ) + FAIL_IF(FAIL == H5FDclose(fd_shakes)) fd_shakes = NULL; - FAIL_IF( FAIL == H5FDclose(fd_raven_2) ) + FAIL_IF(FAIL == H5FDclose(fd_raven_2)) fd_raven_2 = NULL; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; curl_global_cleanup(); @@ -1649,21 +1594,26 @@ error: * CLEANUP * ***********/ - if (fd_raven != NULL) (void)H5FDclose(fd_raven); - if (fd_raven_2 != NULL) (void)H5FDclose(fd_raven_2); - if (fd_shakes != NULL) (void)H5FDclose(fd_shakes); - if (TRUE == curl_ready) curl_global_cleanup(); + if (fd_raven != NULL) + (void)H5FDclose(fd_raven); + if (fd_raven_2 != NULL) + (void)H5FDclose(fd_raven_2); + if (fd_shakes != NULL) + (void)H5FDclose(fd_shakes); + if (TRUE == curl_ready) + curl_global_cleanup(); if (fapl_id >= 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; } return 1; } /* test_cmp */ - /*--------------------------------------------------------------------------- * * Function: test_H5F_integration() @@ -1721,8 +1671,8 @@ test_H5F_integration(void) *********/ fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( 0 > fapl_id ) - FAIL_IF( FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa) ) + FAIL_IF(0 > fapl_id) + FAIL_IF(FAIL == H5Pset_fapl_ros3(fapl_id, &restricted_access_fa)) /********* * TESTS * @@ -1730,39 +1680,25 @@ test_H5F_integration(void) /* Read-Write Open access is not allowed with this file driver. */ - H5E_BEGIN_TRY { - FAIL_IF( 0 <= H5Fopen( - url_h5_public, - H5F_ACC_RDWR, - fapl_id) ) - } H5E_END_TRY; + H5E_BEGIN_TRY{FAIL_IF(0 <= H5Fopen(url_h5_public, H5F_ACC_RDWR, fapl_id))} H5E_END_TRY; /* H5Fcreate() is not allowed with this file driver. */ - H5E_BEGIN_TRY { - FAIL_IF( 0 <= H5Fcreate( - url_missing, - H5F_ACC_RDONLY, - H5P_DEFAULT, - fapl_id) ) - } H5E_END_TRY; + H5E_BEGIN_TRY{FAIL_IF(0 <= H5Fcreate(url_missing, H5F_ACC_RDONLY, H5P_DEFAULT, fapl_id))} H5E_END_TRY; /* Successful open. */ - file = H5Fopen( - url_h5_public, - H5F_ACC_RDONLY, - fapl_id); - FAIL_IF( file < 0 ) + file = H5Fopen(url_h5_public, H5F_ACC_RDONLY, fapl_id); + FAIL_IF(file < 0) /************ * TEARDOWN * ************/ - FAIL_IF( FAIL == H5Fclose(file) ) + FAIL_IF(FAIL == H5Fclose(file)) file = -1; - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; PASSED(); @@ -1772,12 +1708,15 @@ error: /*********** * CLEANUP * ***********/ -HDprintf("\nerror!"); fflush(stdout); + HDprintf("\nerror!"); + fflush(stdout); if (fapl_id >= 0) { - H5E_BEGIN_TRY { - (void)H5Pclose(fapl_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + (void)H5Pclose(fapl_id); + } + H5E_END_TRY; } if (file > 0) (void)H5Fclose(file); @@ -1788,7 +1727,6 @@ HDprintf("\nerror!"); fflush(stdout); #endif /* H5_HAVE_ROS3_VFD */ - /*------------------------------------------------------------------------- * * Function: main @@ -1807,7 +1745,7 @@ int main(void) { #ifdef H5_HAVE_ROS3_VFD - int nerrors = 0; + int nerrors = 0; const char *bucket_url_env = NULL; #endif /* H5_HAVE_ROS3_VFD */ @@ -1822,50 +1760,35 @@ main(void) bucket_url_env = HDgetenv("HDF5_ROS3_TEST_BUCKET_URL"); if (bucket_url_env == NULL || bucket_url_env[0] == '\0') { - HDprintf("WARNING: S3 bucket url is not defined in enviornment " \ + HDprintf("WARNING: S3 bucket url is not defined in enviornment " "variable 'HDF5_ROS3_TEST_BUCKET_URL'!\n"); - } else { + } + else { HDstrncpy(s3_test_bucket_url, bucket_url_env, S3_TEST_MAX_URL_SIZE); s3_test_bucket_defined = TRUE; } - if (S3_TEST_MAX_URL_SIZE < HDsnprintf( - url_text_restricted, - (size_t)S3_TEST_MAX_URL_SIZE, - "%s/%s", - (const char *)s3_test_bucket_url, - (const char *)S3_TEST_RESOURCE_TEXT_RESTRICTED)) - { + if (S3_TEST_MAX_URL_SIZE < HDsnprintf(url_text_restricted, (size_t)S3_TEST_MAX_URL_SIZE, "%s/%s", + (const char *)s3_test_bucket_url, + (const char *)S3_TEST_RESOURCE_TEXT_RESTRICTED)) { HDprintf("* ros3 setup failed (text_restricted) ! *\n"); return 1; } - if (S3_TEST_MAX_URL_SIZE < HDsnprintf( - url_text_public, - (size_t)S3_TEST_MAX_URL_SIZE, - "%s/%s", - (const char *)s3_test_bucket_url, - (const char *)S3_TEST_RESOURCE_TEXT_PUBLIC)) - { + if (S3_TEST_MAX_URL_SIZE < HDsnprintf(url_text_public, (size_t)S3_TEST_MAX_URL_SIZE, "%s/%s", + (const char *)s3_test_bucket_url, + (const char *)S3_TEST_RESOURCE_TEXT_PUBLIC)) { HDprintf("* ros3 setup failed (text_public) ! *\n"); return 1; } - if (S3_TEST_MAX_URL_SIZE < HDsnprintf( - url_h5_public, - (size_t)S3_TEST_MAX_URL_SIZE, - "%s/%s", - (const char *)s3_test_bucket_url, - (const char *)S3_TEST_RESOURCE_H5_PUBLIC)) - { + if (S3_TEST_MAX_URL_SIZE < HDsnprintf(url_h5_public, (size_t)S3_TEST_MAX_URL_SIZE, "%s/%s", + (const char *)s3_test_bucket_url, + (const char *)S3_TEST_RESOURCE_H5_PUBLIC)) { HDprintf("* ros3 setup failed (h5_public) ! *\n"); return 1; } - if (S3_TEST_MAX_URL_SIZE < HDsnprintf( - url_missing, - S3_TEST_MAX_URL_SIZE, - "%s/%s", - (const char *)s3_test_bucket_url, - (const char *)S3_TEST_RESOURCE_MISSING)) - { + if (S3_TEST_MAX_URL_SIZE < HDsnprintf(url_missing, S3_TEST_MAX_URL_SIZE, "%s/%s", + (const char *)s3_test_bucket_url, + (const char *)S3_TEST_RESOURCE_MISSING)) { HDprintf("* ros3 setup failed (missing) ! *\n"); return 1; } @@ -1882,22 +1805,15 @@ main(void) /* attempt to load test credentials * if unable, certain tests will be skipped */ - if (SUCCEED == H5FD_s3comms_load_aws_profile( - S3_TEST_PROFILE_NAME, - s3_test_aws_access_key_id, - s3_test_aws_secret_access_key, - s3_test_aws_region)) - { + if (SUCCEED == H5FD_s3comms_load_aws_profile(S3_TEST_PROFILE_NAME, s3_test_aws_access_key_id, + s3_test_aws_secret_access_key, s3_test_aws_region)) { s3_test_credentials_loaded = 1; - HDstrncpy(restricted_access_fa.aws_region, - (const char *)s3_test_aws_region, - H5FD_ROS3_MAX_REGION_LEN); - HDstrncpy(restricted_access_fa.secret_id, - (const char *)s3_test_aws_access_key_id, - H5FD_ROS3_MAX_SECRET_ID_LEN); - HDstrncpy(restricted_access_fa.secret_key, - (const char *)s3_test_aws_secret_access_key, - H5FD_ROS3_MAX_SECRET_KEY_LEN); + HDstrncpy(restricted_access_fa.aws_region, (const char *)s3_test_aws_region, + H5FD_ROS3_MAX_REGION_LEN); + HDstrncpy(restricted_access_fa.secret_id, (const char *)s3_test_aws_access_key_id, + H5FD_ROS3_MAX_SECRET_ID_LEN); + HDstrncpy(restricted_access_fa.secret_key, (const char *)s3_test_aws_secret_access_key, + H5FD_ROS3_MAX_SECRET_KEY_LEN); } /****************** @@ -1917,11 +1833,10 @@ main(void) nerrors += test_H5F_integration(); if (nerrors > 0) { - HDprintf("***** %d ros3 TEST%s FAILED! *****\n", - nerrors, - nerrors > 1 ? "S" : ""); + HDprintf("***** %d ros3 TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); nerrors = 1; - } else { + } + else { HDprintf("All ros3 tests passed.\n"); } return nerrors; /* 0 if no errors, 1 if any errors */ @@ -1934,4 +1849,3 @@ main(void) #endif /* H5_HAVE_ROS3_VFD */ } /* main() */ - diff --git a/test/s3comms.c b/test/s3comms.c index 9453b75..728501d 100644 --- a/test/s3comms.c +++ b/test/s3comms.c @@ -67,7 +67,6 @@ * *****************************************************************************/ - /*---------------------------------------------------------------------------- * * ifdef flag: JSVERIFY_EXP_ACT @@ -79,7 +78,6 @@ */ #define JSVERIFY_EXP_ACT 1L - /*---------------------------------------------------------------------------- * * Macro: JSFAILED_AT() @@ -96,10 +94,10 @@ * *---------------------------------------------------------------------------- */ -#define JSFAILED_AT() { \ - HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ -} - +#define JSFAILED_AT() \ + { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ + } /*---------------------------------------------------------------------------- * @@ -124,12 +122,11 @@ * *---------------------------------------------------------------------------- */ -#define FAIL_IF(condition) \ -if (condition) { \ - JSFAILED_AT() \ - goto error; \ -} - +#define FAIL_IF(condition) \ + if (condition) { \ + JSFAILED_AT() \ + goto error; \ + } /*---------------------------------------------------------------------------- * @@ -153,12 +150,11 @@ if (condition) { \ * *---------------------------------------------------------------------------- */ -#define FAIL_UNLESS(condition) \ -if (!(condition)) { \ - JSFAILED_AT() \ - goto error; \ -} - +#define FAIL_UNLESS(condition) \ + if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ + } /*---------------------------------------------------------------------------- * @@ -185,16 +181,16 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSERR_LONG(expected, actual, reason) { \ - JSFAILED_AT() \ - if (reason!= NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ - (long)(expected), (long)(actual)); \ - } \ -} - +#define JSERR_LONG(expected, actual, reason) \ + { \ + JSFAILED_AT() \ + if (reason != NULL) { \ + HDprintf("%s\n", (reason)); \ + } \ + else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", (long)(expected), (long)(actual)); \ + } \ + } /*---------------------------------------------------------------------------- * @@ -224,21 +220,21 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSERR_STR(expected, actual, reason) { \ - JSFAILED_AT() \ - if ((reason) != NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ - (expected), (actual)); \ - } \ -} +#define JSERR_STR(expected, actual, reason) \ + { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } \ + else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", (expected), (actual)); \ + } \ + } #ifdef JSVERIFY_EXP_ACT /* VERIFY rountines with paramter order (, [, ]) */ - /*---------------------------------------------------------------------------- * * Macro: JSVERIFY() @@ -255,11 +251,11 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY(expected, actual, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY */ +#define JSVERIFY(expected, actual, reason) \ + if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY */ #if 0 /* UNUSED */ @@ -279,14 +275,13 @@ if ((long)(actual) != (long)(expected)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY_NOT(expected, actual, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ +#define JSVERIFY_NOT(expected, actual, reason) \ + if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY_NOT */ #endif /* JSVERIFY_NOT unused */ - /*---------------------------------------------------------------------------- * * Macro: JSVERIFY_STR() @@ -303,12 +298,11 @@ if ((long)(actual) == (long)(expected)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY_STR(expected, actual, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ - +#define JSVERIFY_STR(expected, actual, reason) \ + if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY_STR */ #else /* JSVERIFY_EXP_ACT not defined @@ -316,7 +310,6 @@ if (strcmp((actual), (expected)) != 0) { \ * Repeats macros above, but with actual/expected parameters reversed. */ - /*---------------------------------------------------------------------------- * Macro: JSVERIFY() * See: JSVERIFY documentation above. @@ -324,11 +317,11 @@ if (strcmp((actual), (expected)) != 0) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY(actual, expected, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY */ +#define JSVERIFY(actual, expected, reason) \ + if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY */ #if 0 /* UNUSED */ @@ -339,14 +332,13 @@ if ((long)(actual) != (long)(expected)) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY_NOT(actual, expected, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ +#define JSVERIFY_NOT(actual, expected, reason) \ + if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY_NOT */ #endif /* JSVERIFY_NOT unused */ - /*---------------------------------------------------------------------------- * Macro: JSVERIFY_STR() * See: JSVERIFY_STR documentation above. @@ -354,22 +346,21 @@ if ((long)(actual) == (long)(expected)) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY_STR(actual, expected, reason) \ -if (strcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ +#define JSVERIFY_STR(actual, expected, reason) \ + if (strcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY_STR */ #endif /* ifdef/else JSVERIFY_EXP_ACT */ - #define S3_TEST_PROFILE_NAME "ros3_vfd_test" #define S3_TEST_RESOURCE_TEXT_RESTRICTED "t8.shakespeare.txt" -#define S3_TEST_RESOURCE_TEXT_PUBLIC "Poe_Raven.txt" -#define S3_TEST_RESOURCE_MISSING "missing.csv" +#define S3_TEST_RESOURCE_TEXT_PUBLIC "Poe_Raven.txt" +#define S3_TEST_RESOURCE_MISSING "missing.csv" -#define S3_TEST_RUN_TIMEOUT 0 /* run tests that might hang */ +#define S3_TEST_RUN_TIMEOUT 0 /* run tests that might hang */ #define S3_TEST_MAX_URL_SIZE 256 /* char array size */ /* Global variables for aws test profile. @@ -384,7 +375,6 @@ static char s3_test_aws_secret_access_key[128] = ""; static char s3_test_bucket_url[S3_TEST_MAX_URL_SIZE] = ""; static hbool_t s3_test_bucket_defined = FALSE; - /*--------------------------------------------------------------------------- * * Function: test_macro_format_credential() @@ -411,15 +401,13 @@ test_macro_format_credential(void) const char date[] = "20130524"; const char region[] = "us-east-1"; const char service[] = "s3"; - const char expected[] = - "AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request"; + const char expected[] = "AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request"; TESTING("test_macro_format_credential"); - FAIL_IF( S3COMMS_MAX_CREDENTIAL_SIZE < - S3COMMS_FORMAT_CREDENTIAL(dest, access, date, region, service) ) + FAIL_IF(S3COMMS_MAX_CREDENTIAL_SIZE < S3COMMS_FORMAT_CREDENTIAL(dest, access, date, region, service)) - JSVERIFY_STR( expected, dest, NULL ) + JSVERIFY_STR(expected, dest, NULL) PASSED(); return 0; @@ -429,7 +417,6 @@ error: } /* end test_macro_format_credential() */ - /*--------------------------------------------------------------------------- * * Function: test_aws_canonical_request() @@ -460,54 +447,65 @@ test_aws_canonical_request(void) }; struct testcase { - const char *exp_request; - const char *exp_headers; - const char *verb; - const char *resource; - unsigned int listsize; - struct header list[5]; + const char * exp_request; + const char * exp_headers; + const char * verb; + const char * resource; + unsigned int listsize; + struct header list[5]; }; /************************ * test-local variables * ************************/ - struct testcase cases[] = { - { "GET\n/some/path.file\n\nhost:somebucket.someserver.somedomain\nrange:bytes=150-244\n\nhost;range\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + struct testcase cases[] = { + { + "GET\n/some/" + "path.file\n\nhost:somebucket.someserver.somedomain\nrange:bytes=150-244\n\nhost;" + "range\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "host;range", "GET", "/some/path.file", 2, - { {"Range", "bytes=150-244"}, + { + {"Range", "bytes=150-244"}, {"Host", "somebucket.someserver.somedomain"}, }, }, - { "HEAD\n/bucketpath/myfile.dat\n\nhost:place.domain\nx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nx-amz-date:19411207T150803Z\n\nhost;x-amz-content-sha256;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "host;x-amz-content-sha256;x-amz-date", - "HEAD", - "/bucketpath/myfile.dat", - 3, - { {"x-amz-content-sha256", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, - {"host", "place.domain"}, - {"x-amz-date", "19411207T150803Z"}, - } - }, - { "PUT\n/\n\n\n\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + {"HEAD\n/bucketpath/" + "myfile.dat\n\nhost:place.domain\nx-amz-content-sha256:" + "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nx-amz-date:" + "19411207T150803Z\n\nhost;x-amz-content-sha256;x-amz-" + "date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "host;x-amz-content-sha256;x-amz-date", + "HEAD", + "/bucketpath/myfile.dat", + 3, + { + {"x-amz-content-sha256", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + {"host", "place.domain"}, + {"x-amz-date", "19411207T150803Z"}, + }}, + { + "PUT\n/\n\n\n\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "", "PUT", "/", 0, - {{"",""},}, /* unused; satisfies compiler */ + { + {"", ""}, + }, /* unused; satisfies compiler */ }, }; /* struct testcase cases[] */ - struct testcase *C = NULL; - char cr_dest[512]; /* canonical request */ - hrb_t *hrb = NULL; /* http request buffer object */ - unsigned int i = 0; /* looping/indexing */ - unsigned int j = 0; /* looping/indexing */ - hrb_node_t *node = NULL; /* http headers list pointer */ - unsigned int n_cases = 3; - char sh_dest[64]; /* signed headers */ + struct testcase *C = NULL; + char cr_dest[512]; /* canonical request */ + hrb_t * hrb = NULL; /* http request buffer object */ + unsigned int i = 0; /* looping/indexing */ + unsigned int j = 0; /* looping/indexing */ + hrb_node_t * node = NULL; /* http headers list pointer */ + unsigned int n_cases = 3; + char sh_dest[64]; /* signed headers */ TESTING("test_aws_canonical_request"); @@ -515,49 +513,40 @@ test_aws_canonical_request(void) /* pre-test bookkeeping */ C = &cases[i]; - for (j = 0; j < 256; j++) { cr_dest[j] = 0; } /* zero request buffer */ - for (j = 0; j < 64; j++) { sh_dest[j] = 0; } /* zero headers buffer */ + for (j = 0; j < 256; j++) { + cr_dest[j] = 0; + } /* zero request buffer */ + for (j = 0; j < 64; j++) { + sh_dest[j] = 0; + } /* zero headers buffer */ /* create HTTP request object with given verb, resource/path */ - hrb = H5FD_s3comms_hrb_init_request(C->verb, - C->resource, - "HTTP/1.1"); + hrb = H5FD_s3comms_hrb_init_request(C->verb, C->resource, "HTTP/1.1"); HDassert(hrb->body == NULL); /* Create headers list from test case input */ for (j = 0; j < C->listsize; j++) { - FAIL_IF( FAIL == - H5FD_s3comms_hrb_node_set( - &node, - C->list[j].name, - C->list[j].value)); + FAIL_IF(FAIL == H5FD_s3comms_hrb_node_set(&node, C->list[j].name, C->list[j].value)); } hrb->first_header = node; /* test */ - JSVERIFY( SUCCEED, - H5FD_s3comms_aws_canonical_request( - cr_dest, - 512, - sh_dest, - 64, - hrb), - " unable to compose canonical request" ) - JSVERIFY_STR( C->exp_headers, sh_dest, NULL ) - JSVERIFY_STR( C->exp_request, cr_dest, NULL ) + JSVERIFY(SUCCEED, H5FD_s3comms_aws_canonical_request(cr_dest, 512, sh_dest, 64, hrb), + " unable to compose canonical request") + JSVERIFY_STR(C->exp_headers, sh_dest, NULL) + JSVERIFY_STR(C->exp_request, cr_dest, NULL) /* tear-down */ while (node != NULL) { - FAIL_IF( FAIL == - H5FD_s3comms_hrb_node_set(&node, node->name, NULL)); + FAIL_IF(FAIL == H5FD_s3comms_hrb_node_set(&node, node->name, NULL)); } HDassert(NULL == node); - FAIL_IF( FAIL == H5FD_s3comms_hrb_destroy(&hrb)); + FAIL_IF(FAIL == H5FD_s3comms_hrb_destroy(&hrb)); HDassert(NULL == hrb); } /* for each test case */ @@ -566,35 +555,20 @@ test_aws_canonical_request(void) * ERROR CASES * ***************/ - /* malformed hrb and/or node-list - */ - JSVERIFY( FAIL, H5FD_s3comms_aws_canonical_request( - cr_dest, - 20, - sh_dest, - 20, - NULL), - "http request object cannot be null" ) + /* malformed hrb and/or node-list + */ + JSVERIFY(FAIL, H5FD_s3comms_aws_canonical_request(cr_dest, 20, sh_dest, 20, NULL), + "http request object cannot be null") hrb = H5FD_s3comms_hrb_init_request("GET", "/", "HTTP/1.1"); - JSVERIFY( FAIL, H5FD_s3comms_aws_canonical_request( - NULL, - 20, - sh_dest, - 20, - hrb), - "canonical request destination cannot be NULL" ) - - JSVERIFY( FAIL, H5FD_s3comms_aws_canonical_request( - cr_dest, - 20, - NULL, - 20, - hrb), - "signed headers destination cannot be null" ) - - FAIL_IF( FAIL == H5FD_s3comms_hrb_destroy(&hrb) ) - HDassert( NULL == hrb ); + JSVERIFY(FAIL, H5FD_s3comms_aws_canonical_request(NULL, 20, sh_dest, 20, hrb), + "canonical request destination cannot be NULL") + + JSVERIFY(FAIL, H5FD_s3comms_aws_canonical_request(cr_dest, 20, NULL, 20, hrb), + "signed headers destination cannot be null") + + FAIL_IF(FAIL == H5FD_s3comms_hrb_destroy(&hrb)) + HDassert(NULL == hrb); PASSED(); return 0; @@ -603,8 +577,8 @@ error: if (node != NULL) { while (node != NULL) - (void)H5FD_s3comms_hrb_node_set(&node, node->name, NULL); - HDassert( node == NULL ); + (void)H5FD_s3comms_hrb_node_set(&node, node->name, NULL); + HDassert(node == NULL); } if (hrb != NULL) { (void)H5FD_s3comms_hrb_destroy(&hrb); @@ -614,7 +588,6 @@ error: } /* end test_aws_canonical_request() */ - /*--------------------------------------------------------------------------- * * Function: test_bytes_to_hex @@ -652,20 +625,20 @@ test_bytes_to_hex(void) ************************/ struct testcase cases[] = { - { "52F3000C9A", - {82,243,0,12,154}, + { + "52F3000C9A", + {82, 243, 0, 12, 154}, 5, FALSE, }, - { "009a0cf3005200", /* lowercase alphas */ - {0,154,12,243,0,82,0}, + { + "009a0cf3005200", /* lowercase alphas */ + {0, 154, 12, 243, 0, 82, 0}, 7, TRUE, }, - { "", - {17,63,26,56}, - 0, - FALSE, /* irrelevant */ + { + "", {17, 63, 26, 56}, 0, FALSE, /* irrelevant */ }, }; int i = 0; @@ -673,8 +646,6 @@ test_bytes_to_hex(void) char out[17]; int out_off = 0; - - TESTING("bytes-to-hex"); for (i = 0; i < n_cases; i++) { @@ -682,25 +653,15 @@ test_bytes_to_hex(void) out[out_off] = 0; } - JSVERIFY( SUCCEED, - H5FD_s3comms_bytes_to_hex(out, - cases[i].in, - cases[i].size, - cases[i].lower), - NULL ) + JSVERIFY(SUCCEED, H5FD_s3comms_bytes_to_hex(out, cases[i].in, cases[i].size, cases[i].lower), NULL) JSVERIFY_STR(cases[i].exp, out, NULL) } /* dest cannot be null */ - JSVERIFY( FAIL, - H5FD_s3comms_bytes_to_hex( - NULL, - (const unsigned char *)"nada", - 5, - FALSE), - "destination cannot be null" ) + JSVERIFY(FAIL, H5FD_s3comms_bytes_to_hex(NULL, (const unsigned char *)"nada", 5, FALSE), + "destination cannot be null") PASSED(); return 0; @@ -710,7 +671,6 @@ error: } /* end test_bytes_to_hex() */ - /*--------------------------------------------------------------------------- * * Function: test_hrb_init_request() @@ -749,35 +709,40 @@ test_hrb_init_request(void) ************************/ struct testcase cases[] = { - { "get HTTP request just as we provided", + { + "get HTTP request just as we provided", "GET", "/path/to/some/file", "/path/to/some/file", "HTTP/1.1", FALSE, }, - { "null verb substitues to GET", + { + "null verb substitues to GET", NULL, "/MYPATH/MYFILE.tiff", "/MYPATH/MYFILE.tiff", "HTTP/1.1", FALSE, }, - { "demonstrate non-GET verb", + { + "demonstrate non-GET verb", "HEAD", "/MYPATH/MYFILE.tiff", "/MYPATH/MYFILE.tiff", "HTTP/1.1", FALSE, }, - { "slash prepended to resource path, if necessary", + { + "slash prepended to resource path, if necessary", NULL, "MYPATH/MYFILE.tiff", "/MYPATH/MYFILE.tiff", NULL, FALSE, }, - { "null resource path causes problem", + { + "null resource path causes problem", "GET", NULL, NULL, @@ -788,36 +753,32 @@ test_hrb_init_request(void) struct testcase *C = NULL; unsigned int i = 0; unsigned int ncases = 5; - hrb_t *req = NULL; + hrb_t * req = NULL; TESTING("hrb_init_request"); for (i = 0; i < ncases; i++) { - C = &cases[i]; - req = H5FD_s3comms_hrb_init_request( - C->verb, - C->resource, - C->version); + C = &cases[i]; + req = H5FD_s3comms_hrb_init_request(C->verb, C->resource, C->version); if (cases[i].ret_null == TRUE) { - FAIL_IF( req != NULL ); + FAIL_IF(req != NULL); } else { - FAIL_IF( req == NULL ); - JSVERIFY( S3COMMS_HRB_MAGIC, req->magic, NULL ) + FAIL_IF(req == NULL); + JSVERIFY(S3COMMS_HRB_MAGIC, req->magic, NULL) if (C->verb == NULL) { - JSVERIFY_STR( "GET", req->verb, NULL ) + JSVERIFY_STR("GET", req->verb, NULL) } else { - JSVERIFY_STR( req->verb, C->verb, NULL ) + JSVERIFY_STR(req->verb, C->verb, NULL) } - JSVERIFY_STR( "HTTP/1.1", req->version, NULL ) - JSVERIFY_STR( C->exp_res, req->resource, NULL ) - FAIL_IF( req->first_header != NULL ); - FAIL_IF( req->body != NULL ); - JSVERIFY( 0, req->body_len, NULL ) - JSVERIFY( SUCCEED, H5FD_s3comms_hrb_destroy(&req), - "unable to destroy hrb_t" ) - FAIL_IF( NULL != req ); /* should annull pointer as well as free */ + JSVERIFY_STR("HTTP/1.1", req->version, NULL) + JSVERIFY_STR(C->exp_res, req->resource, NULL) + FAIL_IF(req->first_header != NULL); + FAIL_IF(req->body != NULL); + JSVERIFY(0, req->body_len, NULL) + JSVERIFY(SUCCEED, H5FD_s3comms_hrb_destroy(&req), "unable to destroy hrb_t") + FAIL_IF(NULL != req); /* should annull pointer as well as free */ } } /* end for each testcase */ @@ -832,7 +793,6 @@ error: } /* end test_hrb_init_request() */ - /*--------------------------------------------------------------------------- * * Function: test_hrb_node_set() @@ -880,11 +840,11 @@ test_hrb_node_set(void) * representing the empty list. */ typedef struct testcase { - const char *message; - node_mock_t delta; - herr_t returned; - const char *given[11]; /* name/value pairs in array; NULL sentinel */ - const char *expected[11]; + const char *message; + node_mock_t delta; + herr_t returned; + const char *given[11]; /* name/value pairs in array; NULL sentinel */ + const char *expected[11]; } testcase; /************************ @@ -892,188 +852,279 @@ test_hrb_node_set(void) ************************/ testcase cases[] = { - { "cannot remove node from null list", - { "Host", NULL }, + { + "cannot remove node from null list", + {"Host", NULL}, FAIL, {NULL}, {NULL}, }, - { "cannot create list with NULL field name", - { NULL, "somevalue" }, + { + "cannot create list with NULL field name", + {NULL, "somevalue"}, FAIL, {NULL}, {NULL}, }, - { "create a new list", - { "Host", "somevalue" }, + { + "create a new list", + {"Host", "somevalue"}, SUCCEED, {NULL}, - { "Host", "somevalue", + { + "Host", + "somevalue", NULL, }, }, - { "insert new node at head list", - { "Host", "somevalue" }, + { + "insert new node at head list", + {"Host", "somevalue"}, SUCCEED, - { "Range", "bytes=20-40", + { + "Range", + "bytes=20-40", NULL, }, - { "Host", "somevalue", - "Range", "bytes=20-40", + { + "Host", + "somevalue", + "Range", + "bytes=20-40", NULL, }, }, - { "append new node at list end", - { "x-amz-date", "somevalue" }, + { + "append new node at list end", + {"x-amz-date", "somevalue"}, SUCCEED, - { "Range", "bytes=20-40", + { + "Range", + "bytes=20-40", NULL, }, - { "Range", "bytes=20-40", - "x-amz-date", "somevalue", + { + "Range", + "bytes=20-40", + "x-amz-date", + "somevalue", NULL, }, }, - { "insert new node inside list", - { "Intermediary", "somevalue" }, + { + "insert new node inside list", + {"Intermediary", "somevalue"}, SUCCEED, - { "Host", "somehost" , - "Range", "bytes=20-40", + { + "Host", + "somehost", + "Range", + "bytes=20-40", NULL, }, - { "Host", "somehost", - "Intermediary", "somevalue", - "Range", "bytes=20-40", + { + "Host", + "somehost", + "Intermediary", + "somevalue", + "Range", + "bytes=20-40", NULL, }, }, - { "modify node", - { "Range", "bytes=40-80" }, + { + "modify node", + {"Range", "bytes=40-80"}, SUCCEED, - { "Host", "somehost", - "Range", "bytes=20-40", + { + "Host", + "somehost", + "Range", + "bytes=20-40", NULL, }, - { "Host", "somehost", - "Range", "bytes=40-80", + { + "Host", + "somehost", + "Range", + "bytes=40-80", NULL, }, }, - { "modify node with new case", - { "RANGE", "bytes=40-80" }, + { + "modify node with new case", + {"RANGE", "bytes=40-80"}, SUCCEED, - { "Host", "somehost", - "Range", "bytes=20-40", + { + "Host", + "somehost", + "Range", + "bytes=20-40", NULL, }, - { "Host", "somehost", - "RANGE", "bytes=40-80", + { + "Host", + "somehost", + "RANGE", + "bytes=40-80", NULL, }, }, - { "cannot add node with no name", - { NULL, "bytes=40-80" }, + { + "cannot add node with no name", + {NULL, "bytes=40-80"}, FAIL, - { "Host", "somehost", + { + "Host", + "somehost", NULL, }, - { "Host", "somehost", + { + "Host", + "somehost", NULL, }, }, - { "add node with 'empty' name", - { "", "bytes=40-80" }, + { + "add node with 'empty' name", + {"", "bytes=40-80"}, SUCCEED, - { "Host", "somehost", + { + "Host", + "somehost", NULL, }, - { "", "bytes=40-80", - "Host", "somehost", + { + "", + "bytes=40-80", + "Host", + "somehost", NULL, }, }, - { "remove node from end of list", - { "Host", NULL }, + { + "remove node from end of list", + {"Host", NULL}, SUCCEED, - { "Date", "Thr, 25 Jan 2018", - "Host", "somehost", + { + "Date", + "Thr, 25 Jan 2018", + "Host", + "somehost", NULL, }, - { "Date", "Thr, 25 Jan 2018", + { + "Date", + "Thr, 25 Jan 2018", NULL, }, }, - { "remove node from middle of list", - { "Host", NULL }, + { + "remove node from middle of list", + {"Host", NULL}, SUCCEED, - { "Date", "Thr, 25 Jan 2018", - "Host", "somehost", - "Range", "bytes=20-40", + { + "Date", + "Thr, 25 Jan 2018", + "Host", + "somehost", + "Range", + "bytes=20-40", NULL, }, - { "Date", "Thr, 25 Jan 2018", - "Range", "bytes=20-40", + { + "Date", + "Thr, 25 Jan 2018", + "Range", + "bytes=20-40", NULL, }, }, - { "remove node from start of list", - { "Date", NULL }, + { + "remove node from start of list", + {"Date", NULL}, SUCCEED, - { "Date", "Thr, 25 Jan 2018", - "Host", "somehost", - "Range", "bytes=20-40", + { + "Date", + "Thr, 25 Jan 2018", + "Host", + "somehost", + "Range", + "bytes=20-40", NULL, }, - { "Host", "somehost", - "Range", "bytes=20-40", + { + "Host", + "somehost", + "Range", + "bytes=20-40", NULL, }, }, - { "remove only node in list", - { "Date", NULL }, + { + "remove only node in list", + {"Date", NULL}, SUCCEED, - { "Date", "Thr, 25 Jan 2018", + { + "Date", + "Thr, 25 Jan 2018", NULL, }, - { NULL, + { + NULL, }, }, - { "attempt to remove absent node fails", - { "Host", NULL }, + { + "attempt to remove absent node fails", + {"Host", NULL}, FAIL, - { "Date", "Thr, 25 Jan 2018", - "Range", "bytes=20-40", + { + "Date", + "Thr, 25 Jan 2018", + "Range", + "bytes=20-40", NULL, }, - { "Date", "Thr, 25 Jan 2018", - "Range", "bytes=20-40", + { + "Date", + "Thr, 25 Jan 2018", + "Range", + "bytes=20-40", NULL, }, }, - { "removal is case-insensitive", - { "hOsT", NULL }, + { + "removal is case-insensitive", + {"hOsT", NULL}, SUCCEED, - { "Date", "Thr, 25 Jan 2018", - "Host", "somehost", - "Range", "bytes=20-40", + { + "Date", + "Thr, 25 Jan 2018", + "Host", + "somehost", + "Range", + "bytes=20-40", NULL, }, - { "Date", "Thr, 25 Jan 2018", - "Range", "bytes=20-40", + { + "Date", + "Thr, 25 Jan 2018", + "Range", + "bytes=20-40", NULL, }, }, }; - unsigned testcases_count = 16; - unsigned test_i = 0; - hrb_node_t *list = NULL; + unsigned testcases_count = 16; + unsigned test_i = 0; + hrb_node_t *list = NULL; TESTING("hrb_node_t (test_hrb_node_set)"); for (test_i = 0; test_i < testcases_count; test_i++) { - const hrb_node_t *node = NULL; - const testcase *test = &(cases[test_i]); - unsigned mock_i = 0; + const hrb_node_t *node = NULL; + const testcase * test = &(cases[test_i]); + unsigned mock_i = 0; /********* * SETUP * @@ -1081,10 +1132,9 @@ test_hrb_node_set(void) for (mock_i = 0; test->given[mock_i] != NULL; mock_i += 2) { const char *name = test->given[mock_i]; - const char *valu = test->given[mock_i+1]; + const char *valu = test->given[mock_i + 1]; - FAIL_IF( SUCCEED != - H5FD_s3comms_hrb_node_set(&list, name, valu) ) + FAIL_IF(SUCCEED != H5FD_s3comms_hrb_node_set(&list, name, valu)) } /******** * TEST * @@ -1092,37 +1142,32 @@ test_hrb_node_set(void) /* perform modification on list */ - JSVERIFY( test->returned, - H5FD_s3comms_hrb_node_set(&list, - test->delta.name, - test->delta.value), - test->message ) - + JSVERIFY(test->returned, H5FD_s3comms_hrb_node_set(&list, test->delta.name, test->delta.value), + test->message) /* verify resulting list */ - node = list; + node = list; mock_i = 0; while (test->expected[mock_i] != NULL && node != NULL) { const char *name = test->expected[mock_i]; - const char *valu = test->expected[mock_i+1]; + const char *valu = test->expected[mock_i + 1]; - JSVERIFY_STR( name, node->name, NULL ) - JSVERIFY_STR( valu, node->value, NULL ) + JSVERIFY_STR(name, node->name, NULL) + JSVERIFY_STR(valu, node->value, NULL) mock_i += 2; node = node->next; } - FAIL_IF( test->expected[mock_i] != NULL ) - FAIL_IF( node != NULL ) + FAIL_IF(test->expected[mock_i] != NULL) + FAIL_IF(node != NULL) /************ * TEARDOWN * ************/ while (list != NULL) { - FAIL_IF( SUCCEED != - H5FD_s3comms_hrb_node_set(&list, list->name, NULL) ) + FAIL_IF(SUCCEED != H5FD_s3comms_hrb_node_set(&list, list->name, NULL)) } } /* end for each testcase */ @@ -1138,8 +1183,6 @@ error: } /* end test_hrb_node_t() */ - - /*--------------------------------------------------------------------------- * * Function: test_HMAC_SHA256() @@ -1162,13 +1205,13 @@ test_HMAC_SHA256(void) *************************/ struct testcase { - herr_t ret; /* SUCCEED/FAIL expected from call */ - const unsigned char key[SHA256_DIGEST_LENGTH]; - size_t key_len; - const char *msg; - size_t msg_len; - const char *exp; /* not used if ret == FAIL */ - size_t dest_size; /* if 0, `dest` is not malloc'd */ + herr_t ret; /* SUCCEED/FAIL expected from call */ + const unsigned char key[SHA256_DIGEST_LENGTH]; + size_t key_len; + const char * msg; + size_t msg_len; + const char * exp; /* not used if ret == FAIL */ + size_t dest_size; /* if 0, `dest` is not malloc'd */ }; /************************ @@ -1176,33 +1219,33 @@ test_HMAC_SHA256(void) ************************/ struct testcase cases[] = { - { SUCCEED, - { 0xdb, 0xb8, 0x93, 0xac, 0xc0, 0x10, 0x96, 0x49, - 0x18, 0xf1, 0xfd, 0x43, 0x3a, 0xdd, 0x87, 0xc7, - 0x0e, 0x8b, 0x0d, 0xb6, 0xbe, 0x30, 0xc1, 0xfb, - 0xea, 0xfe, 0xfa, 0x5e, 0xc6, 0xba, 0x83, 0x78, + { + SUCCEED, + { + 0xdb, 0xb8, 0x93, 0xac, 0xc0, 0x10, 0x96, 0x49, 0x18, 0xf1, 0xfd, + 0x43, 0x3a, 0xdd, 0x87, 0xc7, 0x0e, 0x8b, 0x0d, 0xb6, 0xbe, 0x30, + 0xc1, 0xfb, 0xea, 0xfe, 0xfa, 0x5e, 0xc6, 0xba, 0x83, 0x78, }, SHA256_DIGEST_LENGTH, - "AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972", - HDstrlen("AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972"), + "AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/" + "aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972", + HDstrlen("AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/" + "aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972"), "f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41", SHA256_DIGEST_LENGTH * 2 + 1, /* +1 for null terminator */ }, - { SUCCEED, - {'J','e','f','e'}, + { + SUCCEED, + {'J', 'e', 'f', 'e'}, 4, "what do ya want for nothing?", 28, "5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843", SHA256_DIGEST_LENGTH * 2 + 1, }, - { FAIL, - "DOESN'T MATTER", - 14, - "ALSO IRRELEVANT", - 15, - NULL, - 0, /* dest -> null, resulting in immediate error */ + { + FAIL, "DOESN'T MATTER", 14, "ALSO IRRELEVANT", 15, NULL, + 0, /* dest -> null, resulting in immediate error */ }, }; char *dest = NULL; @@ -1213,44 +1256,32 @@ test_HMAC_SHA256(void) for (i = 0; i < n_cases; i++) { if (cases[i].dest_size == 0) { - dest = NULL; - } else { - dest = (char *)HDmalloc(sizeof(char) * cases[i].dest_size); - HDassert(dest != NULL); + dest = NULL; + } + else { + dest = (char *)HDmalloc(sizeof(char) * cases[i].dest_size); + HDassert(dest != NULL); } - JSVERIFY( cases[i].ret, - H5FD_s3comms_HMAC_SHA256( - cases[i].key, - cases[i].key_len, - cases[i].msg, - cases[i].msg_len, - dest), - cases[i].msg ); + JSVERIFY( + cases[i].ret, + H5FD_s3comms_HMAC_SHA256(cases[i].key, cases[i].key_len, cases[i].msg, cases[i].msg_len, dest), + cases[i].msg); if (cases[i].ret == SUCCEED) { #ifdef VERBOSE - if (0 != - strncmp(cases[i].exp, - dest, - HDstrlen(cases[i].exp))) - { + if (0 != strncmp(cases[i].exp, dest, HDstrlen(cases[i].exp))) { /* print out how wrong things are, and then fail */ dest = (char *)realloc(dest, cases[i].dest_size + 1); HDassert(dest != NULL); dest[cases[i].dest_size] = 0; - HDfprintf(stdout, - "ERROR:\n!!! \"%s\"\n != \"%s\"\n", - cases[i].exp, - dest); + HDfprintf(stdout, "ERROR:\n!!! \"%s\"\n != \"%s\"\n", cases[i].exp, dest); TEST_ERROR; } -#else /* VERBOSE not defined */ +#else /* VERBOSE not defined */ /* simple pass/fail test */ - JSVERIFY( 0, - strncmp(cases[i].exp, dest, HDstrlen(cases[i].exp)), - NULL); + JSVERIFY(0, strncmp(cases[i].exp, dest, HDstrlen(cases[i].exp)), NULL); #endif /* VERBOSE */ } free(dest); @@ -1265,7 +1296,6 @@ error: } /* end test_HMAC_SHA256() */ - /*---------------------------------------------------------------------------- * * Function: test_nlowercase() @@ -1300,15 +1330,18 @@ test_nlowercase(void) * in this test, kept as the null character for simplicity. */ struct testcase cases[] = { - { "HALlEluJAh", + { + "HALlEluJAh", 6, "hallel", }, - { "all\0 lower", + { + "all\0 lower", 10, "all\0 lower", }, - { "to meeeeeee", + { + "to meeeeeee", 0, "", }, @@ -1322,22 +1355,14 @@ test_nlowercase(void) for (i = 0; i < n_cases; i++) { dest = (char *)HDmalloc(sizeof(char) * 16); - JSVERIFY( SUCCEED, - H5FD_s3comms_nlowercase(dest, - cases[i].in, - cases[i].len), - cases[i].in ) + JSVERIFY(SUCCEED, H5FD_s3comms_nlowercase(dest, cases[i].in, cases[i].len), cases[i].in) if (cases[i].len > 0) { - JSVERIFY( 0, strncmp(dest, cases[i].exp, cases[i].len), NULL ) + JSVERIFY(0, strncmp(dest, cases[i].exp, cases[i].len), NULL) } free(dest); } /* end for each testcase */ - JSVERIFY( FAIL, - H5FD_s3comms_nlowercase(NULL, - cases[0].in, - cases[0].len), - "null distination should fail" ) + JSVERIFY(FAIL, H5FD_s3comms_nlowercase(NULL, cases[0].in, cases[0].len), "null distination should fail") PASSED(); return 0; @@ -1348,7 +1373,6 @@ error: } /* end test_nlowercase() */ - /*--------------------------------------------------------------------------- * * Function: test_parse_url() @@ -1378,34 +1402,38 @@ test_parse_url(void) } const_purl_t; struct testcase { - const char *url; - herr_t exp_ret; /* expected return; */ - /* if FAIL, `expected` is unused */ - const_purl_t expected; - const char *msg; + const char *url; + herr_t exp_ret; /* expected return; */ + /* if FAIL, `expected` is unused */ + const_purl_t expected; + const char * msg; }; /************************ * test-local variables * ************************/ - parsed_url_t *purl = NULL; + parsed_url_t * purl = NULL; unsigned int i = 0; unsigned int ncases = 15; struct testcase cases[] = { - { NULL, + { + NULL, FAIL, - { NULL, NULL, NULL, NULL, NULL }, + {NULL, NULL, NULL, NULL, NULL}, "null url", }, - { "", + { + "", FAIL, - { NULL, NULL, NULL, NULL, NULL }, + {NULL, NULL, NULL, NULL, NULL}, "empty url", }, - { "ftp://[1000:4000:0002:2010]", + { + "ftp://[1000:4000:0002:2010]", SUCCEED, - { "ftp", + { + "ftp", "[1000:4000:0002:2010]", NULL, NULL, @@ -1413,9 +1441,11 @@ test_parse_url(void) }, "IPv6 ftp and empty path (root)", }, - { "ftp://[1000:4000:0002:2010]:2040", + { + "ftp://[1000:4000:0002:2010]:2040", SUCCEED, - { "ftp", + { + "ftp", "[1000:4000:0002:2010]", "2040", NULL, @@ -1423,9 +1453,11 @@ test_parse_url(void) }, "root IPv6 ftp with port", }, - { "http://some.domain.org:9000/path/to/resource.txt", + { + "http://some.domain.org:9000/path/to/resource.txt", SUCCEED, - { "http", + { + "http", "some.domain.org", "9000", "path/to/resource.txt", @@ -1433,9 +1465,11 @@ test_parse_url(void) }, "without query", }, - { "https://domain.me:00/file.txt?some_params unchecked", + { + "https://domain.me:00/file.txt?some_params unchecked", SUCCEED, - { "https", + { + "https", "domain.me", "00", "file.txt", @@ -1443,9 +1477,11 @@ test_parse_url(void) }, "with query", }, - { "ftp://domain.com/", + { + "ftp://domain.com/", SUCCEED, - { "ftp", + { + "ftp", "domain.com", NULL, NULL, @@ -1453,9 +1489,11 @@ test_parse_url(void) }, "explicit root w/out port", }, - { "ftp://domain.com:1234/", + { + "ftp://domain.com:1234/", SUCCEED, - { "ftp", + { + "ftp", "domain.com", "1234", NULL, @@ -1463,24 +1501,47 @@ test_parse_url(void) }, "explicit root with port", }, - { "ftp://domain.com:1234/file?", + { + "ftp://domain.com:1234/file?", FAIL, - { NULL, NULL, NULL, NULL, NULL, }, + { + NULL, + NULL, + NULL, + NULL, + NULL, + }, "empty query is invalid", }, - { "ftp://:1234/file", + { + "ftp://:1234/file", FAIL, - { NULL, NULL, NULL, NULL, NULL, }, + { + NULL, + NULL, + NULL, + NULL, + NULL, + }, "no host", }, - { "h&r block", + { + "h&r block", FAIL, - { NULL, NULL, NULL, NULL, NULL, }, + { + NULL, + NULL, + NULL, + NULL, + NULL, + }, "no scheme (bad URL)", }, - { "http://domain.com?a=b&d=b", + { + "http://domain.com?a=b&d=b", SUCCEED, - { "http", + { + "http", "domain.com", NULL, NULL, @@ -1488,9 +1549,11 @@ test_parse_url(void) }, "QUERY with implict PATH", }, - { "http://[5]/path?a=b&d=b", + { + "http://[5]/path?a=b&d=b", SUCCEED, - { "http", + { + "http", "[5]", NULL, "path", @@ -1498,14 +1561,28 @@ test_parse_url(void) }, "IPv6 extraction is really dumb", }, - { "http://[1234:5678:0910:1112]:port/path", + { + "http://[1234:5678:0910:1112]:port/path", FAIL, - { NULL, NULL, NULL, NULL, NULL, }, + { + NULL, + NULL, + NULL, + NULL, + NULL, + }, "non-decimal PORT (port)", }, - { "http://mydomain.com:01a3/path", + { + "http://mydomain.com:01a3/path", FAIL, - { NULL, NULL, NULL, NULL, NULL, }, + { + NULL, + NULL, + NULL, + NULL, + NULL, + }, "non-decimal PORT (01a3)", }, }; @@ -1517,70 +1594,63 @@ test_parse_url(void) *********/ for (i = 0; i < ncases; i++) { - HDassert( purl == NULL ); + HDassert(purl == NULL); - JSVERIFY( cases[i].exp_ret, - H5FD_s3comms_parse_url(cases[i].url, &purl), - cases[i].msg ) + JSVERIFY(cases[i].exp_ret, H5FD_s3comms_parse_url(cases[i].url, &purl), cases[i].msg) if (cases[i].exp_ret == FAIL) { /* on FAIL, `purl` should be untouched--remains NULL */ - FAIL_UNLESS( purl == NULL ) + FAIL_UNLESS(purl == NULL) } else { /* on SUCCEED, `purl` should be set */ - FAIL_IF( purl == NULL ) + FAIL_IF(purl == NULL) if (cases[i].expected.scheme != NULL) { - FAIL_IF( NULL == purl->scheme ) - JSVERIFY_STR( cases[i].expected.scheme, - purl->scheme, - cases[i].msg ) - } else { - FAIL_UNLESS( NULL == purl->scheme ) + FAIL_IF(NULL == purl->scheme) + JSVERIFY_STR(cases[i].expected.scheme, purl->scheme, cases[i].msg) + } + else { + FAIL_UNLESS(NULL == purl->scheme) } if (cases[i].expected.host != NULL) { - FAIL_IF( NULL == purl->host ) - JSVERIFY_STR( cases[i].expected.host, - purl->host, - cases[i].msg ) - } else { - FAIL_UNLESS( NULL == purl->host ) + FAIL_IF(NULL == purl->host) + JSVERIFY_STR(cases[i].expected.host, purl->host, cases[i].msg) + } + else { + FAIL_UNLESS(NULL == purl->host) } if (cases[i].expected.port != NULL) { - FAIL_IF( NULL == purl->port ) - JSVERIFY_STR( cases[i].expected.port, - purl->port, - cases[i].msg ) - } else { - FAIL_UNLESS( NULL == purl->port ) + FAIL_IF(NULL == purl->port) + JSVERIFY_STR(cases[i].expected.port, purl->port, cases[i].msg) + } + else { + FAIL_UNLESS(NULL == purl->port) } if (cases[i].expected.path != NULL) { - FAIL_IF( NULL == purl->path ) - JSVERIFY_STR( cases[i].expected.path, - purl->path, - cases[i].msg ) - } else { - FAIL_UNLESS( NULL == purl->path ) + FAIL_IF(NULL == purl->path) + JSVERIFY_STR(cases[i].expected.path, purl->path, cases[i].msg) + } + else { + FAIL_UNLESS(NULL == purl->path) } if (cases[i].expected.query != NULL) { - FAIL_IF( NULL == purl->query ) - JSVERIFY_STR( cases[i].expected.query, - purl->query, - cases[i].msg ) - } else { - FAIL_UNLESS( NULL == purl->query ) + FAIL_IF(NULL == purl->query) + JSVERIFY_STR(cases[i].expected.query, purl->query, cases[i].msg) + } + else { + FAIL_UNLESS(NULL == purl->query) } } /* end if parse-url return SUCCEED/FAIL */ /* per-test cleanup * well-behaved, even if `purl` is NULL */ - FAIL_IF( FAIL == H5FD_s3comms_free_purl(purl) ) + FAIL_IF(FAIL == H5FD_s3comms_free_purl(purl)) purl = NULL; } /* end for each testcase */ @@ -1598,7 +1668,6 @@ error: } /* end test_parse_url() */ - /*--------------------------------------------------------------------------- * * Function: test_percent_encode_char() @@ -1635,10 +1704,10 @@ test_percent_encode_char(void) ************************/ struct testcase cases[] = { - {'$', "%24", 3}, /* u+0024 dollar sign */ - {' ', "%20", 3}, /* u+0020 space */ - {'^', "%5E", 3}, /* u+0094 carat */ - {'/', "%2F", 3}, /* u+002f solidus (forward slash) */ + {'$', "%24", 3}, /* u+0024 dollar sign */ + {' ', "%20", 3}, /* u+0020 space */ + {'^', "%5E", 3}, /* u+0094 carat */ + {'/', "%2F", 3}, /* u+002f solidus (forward slash) */ /* {??, "%C5%8C", 6},*/ /* u+014c Latin Capital Letter O with Macron */ /* Not included because it is multibyte "wide" character that poses */ /* issues both in the underlying function and in being written in */ @@ -1657,23 +1726,14 @@ test_percent_encode_char(void) TESTING("percent encode characters"); for (i = 0; i < n_cases; i++) { - JSVERIFY( SUCCEED, - H5FD_s3comms_percent_encode_char( - dest, - (const unsigned char)cases[i].c, - &dest_len), - NULL ) - JSVERIFY(cases[i].exp_len, dest_len, NULL ) - JSVERIFY(0, strncmp(dest, cases[i].exp, dest_len), NULL ) - JSVERIFY_STR( cases[i].exp, dest, NULL ) + JSVERIFY(SUCCEED, H5FD_s3comms_percent_encode_char(dest, (const unsigned char)cases[i].c, &dest_len), + NULL) + JSVERIFY(cases[i].exp_len, dest_len, NULL) + JSVERIFY(0, strncmp(dest, cases[i].exp, dest_len), NULL) + JSVERIFY_STR(cases[i].exp, dest, NULL) } - JSVERIFY( FAIL, - H5FD_s3comms_percent_encode_char( - NULL, - (const unsigned char)'^', - &dest_len), - NULL ) + JSVERIFY(FAIL, H5FD_s3comms_percent_encode_char(NULL, (const unsigned char)'^', &dest_len), NULL) PASSED(); return 0; @@ -1682,7 +1742,6 @@ error: return -1; } /* end test_percent_encode_char() */ - /*--------------------------------------------------------------------------- * Function: test_s3r_open() * @@ -1700,7 +1759,7 @@ test_s3r_get_filesize(void) * test-local variables * ************************/ - char url_raven[S3_TEST_MAX_URL_SIZE]; + char url_raven[S3_TEST_MAX_URL_SIZE]; s3r_t *handle = NULL; TESTING("s3r_get_filesize"); @@ -1714,23 +1773,17 @@ test_s3r_get_filesize(void) return 0; } - FAIL_IF( S3_TEST_MAX_URL_SIZE < - HDsnprintf(url_raven, - S3_TEST_MAX_URL_SIZE, - "%s/%s", - s3_test_bucket_url, - S3_TEST_RESOURCE_TEXT_PUBLIC) ); + FAIL_IF(S3_TEST_MAX_URL_SIZE < HDsnprintf(url_raven, S3_TEST_MAX_URL_SIZE, "%s/%s", s3_test_bucket_url, + S3_TEST_RESOURCE_TEXT_PUBLIC)); - JSVERIFY( 0, H5FD_s3comms_s3r_get_filesize(NULL), - "filesize of the null handle should be 0" ) + JSVERIFY(0, H5FD_s3comms_s3r_get_filesize(NULL), "filesize of the null handle should be 0") handle = H5FD_s3comms_s3r_open(url_raven, NULL, NULL, NULL); - FAIL_IF( handle == NULL ) - - JSVERIFY( 6464, H5FD_s3comms_s3r_get_filesize(handle), NULL ) + FAIL_IF(handle == NULL) + JSVERIFY(6464, H5FD_s3comms_s3r_get_filesize(handle), NULL) - FAIL_IF( SUCCEED != H5FD_s3comms_s3r_close(handle) ) + FAIL_IF(SUCCEED != H5FD_s3comms_s3r_close(handle)) PASSED(); return 0; @@ -1743,7 +1796,6 @@ error: } /* end test_s3r_get_filesize() */ - /*--------------------------------------------------------------------------- * Function: test_s3r_open() * @@ -1761,16 +1813,16 @@ test_s3r_open(void) * test-local variables * ************************/ - char url_missing[S3_TEST_MAX_URL_SIZE]; - char url_raven[S3_TEST_MAX_URL_SIZE]; - char url_raven_badport[S3_TEST_MAX_URL_SIZE]; - char url_shakespeare[S3_TEST_MAX_URL_SIZE]; - unsigned char signing_key[SHA256_DIGEST_LENGTH]; - struct tm *now = NULL; - char iso8601now[ISO8601_SIZE]; - s3r_t *handle = NULL; - hbool_t curl_ready = FALSE; - parsed_url_t *purl = NULL; + char url_missing[S3_TEST_MAX_URL_SIZE]; + char url_raven[S3_TEST_MAX_URL_SIZE]; + char url_raven_badport[S3_TEST_MAX_URL_SIZE]; + char url_shakespeare[S3_TEST_MAX_URL_SIZE]; + unsigned char signing_key[SHA256_DIGEST_LENGTH]; + struct tm * now = NULL; + char iso8601now[ISO8601_SIZE]; + s3r_t * handle = NULL; + hbool_t curl_ready = FALSE; + parsed_url_t *purl = NULL; TESTING("s3r_open"); @@ -1791,65 +1843,46 @@ test_s3r_open(void) * PRE-TEST SETUP * ******************/ - FAIL_IF( S3_TEST_MAX_URL_SIZE < - HDsnprintf(url_shakespeare, - S3_TEST_MAX_URL_SIZE, - "%s/%s", - s3_test_bucket_url, - S3_TEST_RESOURCE_TEXT_RESTRICTED) ); - - FAIL_IF( S3_TEST_MAX_URL_SIZE < - HDsnprintf(url_missing, - S3_TEST_MAX_URL_SIZE, - "%s/%s", - s3_test_bucket_url, - S3_TEST_RESOURCE_MISSING) ); - - FAIL_IF( S3_TEST_MAX_URL_SIZE < - HDsnprintf(url_raven, - S3_TEST_MAX_URL_SIZE, - "%s/%s", - s3_test_bucket_url, - S3_TEST_RESOURCE_TEXT_PUBLIC) ); + FAIL_IF(S3_TEST_MAX_URL_SIZE < HDsnprintf(url_shakespeare, S3_TEST_MAX_URL_SIZE, "%s/%s", + s3_test_bucket_url, S3_TEST_RESOURCE_TEXT_RESTRICTED)); + + FAIL_IF(S3_TEST_MAX_URL_SIZE < HDsnprintf(url_missing, S3_TEST_MAX_URL_SIZE, "%s/%s", s3_test_bucket_url, + S3_TEST_RESOURCE_MISSING)); + + FAIL_IF(S3_TEST_MAX_URL_SIZE < HDsnprintf(url_raven, S3_TEST_MAX_URL_SIZE, "%s/%s", s3_test_bucket_url, + S3_TEST_RESOURCE_TEXT_PUBLIC)); /* Set given bucket url with invalid/inactive port number for badport. * Note, this sort of micro-management of parsed_url_t is not advised */ - FAIL_IF( FAIL == H5FD_s3comms_parse_url(s3_test_bucket_url, &purl) ) + FAIL_IF(FAIL == H5FD_s3comms_parse_url(s3_test_bucket_url, &purl)) if (purl->port == NULL) { purl->port = (char *)H5MM_malloc(sizeof(char) * 5); - FAIL_IF( purl->port == NULL ); - FAIL_IF( 5 < HDsnprintf(purl->port, 5, "9000") ) - } else if (strcmp(purl->port, "9000") != 0) { - FAIL_IF( 5 < HDsnprintf(purl->port, 5, "9000") ) - } else { - FAIL_IF( 5 < HDsnprintf(purl->port, 5, "1234") ) + FAIL_IF(purl->port == NULL); + FAIL_IF(5 < HDsnprintf(purl->port, 5, "9000")) } - FAIL_IF( S3_TEST_MAX_URL_SIZE < - HDsnprintf(url_raven_badport, - S3_TEST_MAX_URL_SIZE, - "%s://%s:%s/%s", - purl->scheme, - purl->host, - purl->port, - S3_TEST_RESOURCE_TEXT_PUBLIC) ); + else if (strcmp(purl->port, "9000") != 0) { + FAIL_IF(5 < HDsnprintf(purl->port, 5, "9000")) + } + else { + FAIL_IF(5 < HDsnprintf(purl->port, 5, "1234")) + } + FAIL_IF(S3_TEST_MAX_URL_SIZE < HDsnprintf(url_raven_badport, S3_TEST_MAX_URL_SIZE, "%s://%s:%s/%s", + purl->scheme, purl->host, purl->port, + S3_TEST_RESOURCE_TEXT_PUBLIC)); curl_global_init(CURL_GLOBAL_DEFAULT); curl_ready = TRUE; now = gmnow(); - FAIL_IF( now == NULL ) - FAIL_IF( ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1) ); + FAIL_IF(now == NULL) + FAIL_IF(ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)); /* It is desired to have means available to verify that signing_key * was set successfully and to an expected value. */ - FAIL_IF( FAIL == - H5FD_s3comms_signing_key( - signing_key, - (const char *)s3_test_aws_secret_access_key, - (const char *)s3_test_aws_region, - (const char *)iso8601now) ); + FAIL_IF(FAIL == H5FD_s3comms_signing_key(signing_key, (const char *)s3_test_aws_secret_access_key, + (const char *)s3_test_aws_region, (const char *)iso8601now)); /************************* * OPEN NONEXISTENT FILE * @@ -1858,16 +1891,14 @@ test_s3r_open(void) /* attempt anonymously */ handle = H5FD_s3comms_s3r_open(url_missing, NULL, NULL, NULL); - FAIL_IF( handle != NULL ); + FAIL_IF(handle != NULL); /* attempt with authentication */ - handle = H5FD_s3comms_s3r_open( - url_missing, - (const char *)s3_test_aws_region, - (const char *)s3_test_aws_access_key_id, - (const unsigned char *)signing_key); - FAIL_IF( handle != NULL ); + handle = + H5FD_s3comms_s3r_open(url_missing, (const char *)s3_test_aws_region, + (const char *)s3_test_aws_access_key_id, (const unsigned char *)signing_key); + FAIL_IF(handle != NULL); /************************* * INACTIVE PORT ON HOST * @@ -1876,7 +1907,7 @@ test_s3r_open(void) #if S3_TEST_RUN_TIMEOUT HDprintf("Opening on inactive port may hang for a minute; waiting for timeout\n"); handle = H5FD_s3comms_s3r_open(url_raven_badport, NULL, NULL, NULL); - FAIL_IF( handle != NULL ); + FAIL_IF(handle != NULL); #endif /******************************* @@ -1886,25 +1917,20 @@ test_s3r_open(void) /* anonymous access on restricted file */ handle = H5FD_s3comms_s3r_open(url_shakespeare, NULL, NULL, NULL); - FAIL_IF( handle != NULL ); + FAIL_IF(handle != NULL); /* passed in a bad ID */ - handle = H5FD_s3comms_s3r_open( - url_shakespeare, - (const char *)s3_test_aws_region, - "I_MADE_UP_MY_ID", - (const unsigned char *)signing_key); - FAIL_IF( handle != NULL ); + handle = H5FD_s3comms_s3r_open(url_shakespeare, (const char *)s3_test_aws_region, "I_MADE_UP_MY_ID", + (const unsigned char *)signing_key); + FAIL_IF(handle != NULL); /* using an invalid signing key */ - handle = H5FD_s3comms_s3r_open( - url_shakespeare, - (const char *)s3_test_aws_region, - (const char *)s3_test_aws_access_key_id, - (const unsigned char *)EMPTY_SHA256); - FAIL_IF( handle != NULL ); + handle = + H5FD_s3comms_s3r_open(url_shakespeare, (const char *)s3_test_aws_region, + (const char *)s3_test_aws_access_key_id, (const unsigned char *)EMPTY_SHA256); + FAIL_IF(handle != NULL); /******************************* * SUCCESSFUL OPEN (AND CLOSE) * @@ -1913,48 +1939,35 @@ test_s3r_open(void) /* anonymous */ handle = H5FD_s3comms_s3r_open(url_raven, NULL, NULL, NULL); - FAIL_IF( handle == NULL ); - JSVERIFY( 6464, H5FD_s3comms_s3r_get_filesize(handle), - "did not get expected filesize" ) - JSVERIFY( SUCCEED, - H5FD_s3comms_s3r_close(handle), - "unable to close file" ) + FAIL_IF(handle == NULL); + JSVERIFY(6464, H5FD_s3comms_s3r_get_filesize(handle), "did not get expected filesize") + JSVERIFY(SUCCEED, H5FD_s3comms_s3r_close(handle), "unable to close file") handle = NULL; /* using authentication on anonymously-accessible file? */ - handle = H5FD_s3comms_s3r_open( - url_raven, - (const char *)s3_test_aws_region, - (const char *)s3_test_aws_access_key_id, - (const unsigned char *)signing_key); - FAIL_IF( handle == NULL ); - JSVERIFY( 6464, H5FD_s3comms_s3r_get_filesize(handle), NULL ) - JSVERIFY( SUCCEED, - H5FD_s3comms_s3r_close(handle), - "unable to close file" ) + handle = + H5FD_s3comms_s3r_open(url_raven, (const char *)s3_test_aws_region, + (const char *)s3_test_aws_access_key_id, (const unsigned char *)signing_key); + FAIL_IF(handle == NULL); + JSVERIFY(6464, H5FD_s3comms_s3r_get_filesize(handle), NULL) + JSVERIFY(SUCCEED, H5FD_s3comms_s3r_close(handle), "unable to close file") handle = NULL; /* authenticating */ - handle = H5FD_s3comms_s3r_open( - url_shakespeare, - (const char *)s3_test_aws_region, - (const char *)s3_test_aws_access_key_id, - (const unsigned char *)signing_key); - FAIL_IF( handle == NULL ); - JSVERIFY( 5458199, H5FD_s3comms_s3r_get_filesize(handle), NULL ) - JSVERIFY( SUCCEED, - H5FD_s3comms_s3r_close(handle), - "unable to close file" ) + handle = + H5FD_s3comms_s3r_open(url_shakespeare, (const char *)s3_test_aws_region, + (const char *)s3_test_aws_access_key_id, (const unsigned char *)signing_key); + FAIL_IF(handle == NULL); + JSVERIFY(5458199, H5FD_s3comms_s3r_get_filesize(handle), NULL) + JSVERIFY(SUCCEED, H5FD_s3comms_s3r_close(handle), "unable to close file") handle = NULL; - - curl_global_cleanup(); curl_ready = FALSE; - FAIL_IF( FAIL == H5FD_s3comms_free_purl(purl) ) + FAIL_IF(FAIL == H5FD_s3comms_free_purl(purl)) purl = NULL; PASSED(); @@ -1975,7 +1988,6 @@ error: } /* end test_s3r_open() */ - /*--------------------------------------------------------------------------- * * Function: test_s3r_read() @@ -2007,11 +2019,11 @@ test_s3r_read(void) * test-local variables * ************************/ - char url_raven[S3_TEST_MAX_URL_SIZE]; - char buffer[S3COMMS_TEST_BUFFER_SIZE]; - s3r_t *handle = NULL; - hbool_t curl_ready = FALSE; - unsigned int i = 0; + char url_raven[S3_TEST_MAX_URL_SIZE]; + char buffer[S3COMMS_TEST_BUFFER_SIZE]; + s3r_t * handle = NULL; + hbool_t curl_ready = FALSE; + unsigned int i = 0; TESTING("test_s3r_read"); @@ -2027,12 +2039,8 @@ test_s3r_read(void) curl_global_init(CURL_GLOBAL_DEFAULT); curl_ready = TRUE; - FAIL_IF( S3_TEST_MAX_URL_SIZE < - HDsnprintf(url_raven, - S3_TEST_MAX_URL_SIZE, - "%s/%s", - s3_test_bucket_url, - S3_TEST_RESOURCE_TEXT_PUBLIC) ); + FAIL_IF(S3_TEST_MAX_URL_SIZE < HDsnprintf(url_raven, S3_TEST_MAX_URL_SIZE, "%s/%s", s3_test_bucket_url, + S3_TEST_RESOURCE_TEXT_PUBLIC)); for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) buffer[i] = '\0'; @@ -2040,8 +2048,8 @@ test_s3r_read(void) /* open file */ handle = H5FD_s3comms_s3r_open(url_raven, NULL, NULL, NULL); - FAIL_IF( handle == NULL ) - JSVERIFY( 6464, H5FD_s3comms_s3r_get_filesize(handle), NULL ) + FAIL_IF(handle == NULL) + JSVERIFY(6464, H5FD_s3comms_s3r_get_filesize(handle), NULL) for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) buffer[i] = '\0'; @@ -2050,18 +2058,10 @@ test_s3r_read(void) * read start of file * **********************/ - JSVERIFY( SUCCEED, - H5FD_s3comms_s3r_read( - handle, - (haddr_t)0, - (size_t)118, - buffer), - NULL ) - JSVERIFY_STR ( - "Once upon a midnight dreary, while I pondered, weak and weary,\n" \ - "Over many a quaint and curious volume of forgotten lore", - buffer, - NULL ) + JSVERIFY(SUCCEED, H5FD_s3comms_s3r_read(handle, (haddr_t)0, (size_t)118, buffer), NULL) + JSVERIFY_STR("Once upon a midnight dreary, while I pondered, weak and weary,\n" + "Over many a quaint and curious volume of forgotten lore", + buffer, NULL) for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) buffer[i] = '\0'; @@ -2070,16 +2070,8 @@ test_s3r_read(void) * read arbitrary range * ************************/ - JSVERIFY( SUCCEED, - H5FD_s3comms_s3r_read( - handle, - (haddr_t)2540, - (size_t)54, - buffer), - NULL ) - JSVERIFY_STR( "the grave and stern decorum of the countenance it wore", - buffer, - NULL ) + JSVERIFY(SUCCEED, H5FD_s3comms_s3r_read(handle, (haddr_t)2540, (size_t)54, buffer), NULL) + JSVERIFY_STR("the grave and stern decorum of the countenance it wore", buffer, NULL) for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) buffer[i] = '\0'; @@ -2088,15 +2080,8 @@ test_s3r_read(void) * read one character * **********************/ - JSVERIFY(SUCCEED, - H5FD_s3comms_s3r_read( - handle, - (haddr_t)2540, - (size_t)1, - buffer), - NULL ) - JSVERIFY_STR( "t", buffer, NULL ) - + JSVERIFY(SUCCEED, H5FD_s3comms_s3r_read(handle, (haddr_t)2540, (size_t)1, buffer), NULL) + JSVERIFY_STR("t", buffer, NULL) for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) buffer[i] = '\0'; @@ -2105,18 +2090,14 @@ test_s3r_read(void) * read to EoF * ***************/ - JSVERIFY( SUCCEED, - H5FD_s3comms_s3r_read( - handle, - (haddr_t)6370, - (size_t)0, - buffer), - NULL ) - JSVERIFY( 0, - strncmp(buffer, - "And my soul from out that shadow that lies floating on the floor\nShall be lifted—nevermore!\n", - 94), - buffer ) + JSVERIFY(SUCCEED, H5FD_s3comms_s3r_read(handle, (haddr_t)6370, (size_t)0, buffer), NULL) + JSVERIFY( + 0, + strncmp( + buffer, + "And my soul from out that shadow that lies floating on the floor\nShall be lifted—nevermore!\n", + 94), + buffer) for (i = 0; i < S3COMMS_TEST_BUFFER_SIZE; i++) buffer[i] = '\0'; @@ -2125,48 +2106,34 @@ test_s3r_read(void) * read past eof * *****************/ - JSVERIFY( FAIL, - H5FD_s3comms_s3r_read( - handle, - (haddr_t)6400, - (size_t)100, /* 6400+100 > 6464 */ - buffer), - NULL ) - JSVERIFY( 0, strcmp("", buffer), NULL ) + JSVERIFY(FAIL, + H5FD_s3comms_s3r_read(handle, (haddr_t)6400, (size_t)100, /* 6400+100 > 6464 */ + buffer), + NULL) + JSVERIFY(0, strcmp("", buffer), NULL) /************************ * read starts past eof * ************************/ - JSVERIFY( FAIL, - H5FD_s3comms_s3r_read( - handle, - (haddr_t)1200699, /* 1200699 > 6464 */ - (size_t)100, - buffer), - NULL ) - JSVERIFY( 0, strcmp("", buffer), NULL ) + JSVERIFY(FAIL, + H5FD_s3comms_s3r_read(handle, (haddr_t)1200699, /* 1200699 > 6464 */ + (size_t)100, buffer), + NULL) + JSVERIFY(0, strcmp("", buffer), NULL) /********************** * read starts on eof * **********************/ - JSVERIFY( FAIL, - H5FD_s3comms_s3r_read( - handle, - (haddr_t)6464, - (size_t)0, - buffer), - NULL ) - JSVERIFY( 0, strcmp("", buffer), NULL ) + JSVERIFY(FAIL, H5FD_s3comms_s3r_read(handle, (haddr_t)6464, (size_t)0, buffer), NULL) + JSVERIFY(0, strcmp("", buffer), NULL) /************* * TEAR DOWN * *************/ - JSVERIFY( SUCCEED, - H5FD_s3comms_s3r_close(handle), - "unable to close file" ) + JSVERIFY(SUCCEED, H5FD_s3comms_s3r_close(handle), "unable to close file") handle = NULL; curl_global_cleanup(); @@ -2192,7 +2159,6 @@ error: } /* end test_s3r_read() */ - /*--------------------------------------------------------------------------- * * Function: test_signing_key() @@ -2216,10 +2182,10 @@ test_signing_key(void) *************************/ struct testcase { - const char *region; - const char *secret_key; - const char *when; - unsigned char exp[SHA256_DIGEST_LENGTH]; + const char * region; + const char * secret_key; + const char * when; + unsigned char exp[SHA256_DIGEST_LENGTH]; }; /************************ @@ -2227,13 +2193,14 @@ test_signing_key(void) ************************/ struct testcase cases[] = { - { "us-east-1", + { + "us-east-1", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "20130524T000000Z", - { 0xdb, 0xb8, 0x93, 0xac, 0xc0, 0x10, 0x96, 0x49, - 0x18, 0xf1, 0xfd, 0x43, 0x3a, 0xdd, 0x87, 0xc7, - 0x0e, 0x8b, 0x0d, 0xb6, 0xbe, 0x30, 0xc1, 0xfb, - 0xea, 0xfe, 0xfa, 0x5e, 0xc6, 0xba, 0x83, 0x78, + { + 0xdb, 0xb8, 0x93, 0xac, 0xc0, 0x10, 0x96, 0x49, 0x18, 0xf1, 0xfd, + 0x43, 0x3a, 0xdd, 0x87, 0xc7, 0x0e, 0x8b, 0x0d, 0xb6, 0xbe, 0x30, + 0xc1, 0xfb, 0xea, 0xfe, 0xfa, 0x5e, 0xc6, 0xba, 0x83, 0x78, }, }, }; @@ -2244,68 +2211,37 @@ test_signing_key(void) TESTING("signing_key"); for (i = 0; i < ncases; i++) { - key = (unsigned char *)HDmalloc(sizeof(unsigned char) * \ - SHA256_DIGEST_LENGTH); - HDassert(key != NULL); + key = (unsigned char *)HDmalloc(sizeof(unsigned char) * SHA256_DIGEST_LENGTH); + HDassert(key != NULL); - JSVERIFY( SUCCEED, - H5FD_s3comms_signing_key( - key, - cases[i].secret_key, - cases[i].region, - cases[i].when), - NULL ) + JSVERIFY(SUCCEED, H5FD_s3comms_signing_key(key, cases[i].secret_key, cases[i].region, cases[i].when), + NULL) - JSVERIFY( 0, - strncmp((const char *)cases[i].exp, - (const char *)key, - SHA256_DIGEST_LENGTH), - cases[i].exp ) + JSVERIFY(0, strncmp((const char *)cases[i].exp, (const char *)key, SHA256_DIGEST_LENGTH), + cases[i].exp) free(key); key = NULL; } - /*************** * ERROR CASES * ***************/ - key = (unsigned char *)HDmalloc(sizeof(unsigned char) * \ - SHA256_DIGEST_LENGTH); + key = (unsigned char *)HDmalloc(sizeof(unsigned char) * SHA256_DIGEST_LENGTH); HDassert(key != NULL); - JSVERIFY( FAIL, - H5FD_s3comms_signing_key( - NULL, - cases[0].secret_key, - cases[0].region, - cases[0].when), - "destination cannot be NULL" ) - - JSVERIFY( FAIL, - H5FD_s3comms_signing_key( - key, - NULL, - cases[0].region, - cases[0].when), - "secret key cannot be NULL" ) - - JSVERIFY( FAIL, - H5FD_s3comms_signing_key( - key, - cases[0].secret_key, - NULL, - cases[0].when), - "aws region cannot be NULL" ) - - JSVERIFY( FAIL, - H5FD_s3comms_signing_key( - key, - cases[0].secret_key, - cases[0].region, - NULL), - "time string cannot be NULL" ) + JSVERIFY(FAIL, H5FD_s3comms_signing_key(NULL, cases[0].secret_key, cases[0].region, cases[0].when), + "destination cannot be NULL") + + JSVERIFY(FAIL, H5FD_s3comms_signing_key(key, NULL, cases[0].region, cases[0].when), + "secret key cannot be NULL") + + JSVERIFY(FAIL, H5FD_s3comms_signing_key(key, cases[0].secret_key, NULL, cases[0].when), + "aws region cannot be NULL") + + JSVERIFY(FAIL, H5FD_s3comms_signing_key(key, cases[0].secret_key, cases[0].region, NULL), + "time string cannot be NULL") free(key); key = NULL; @@ -2322,7 +2258,6 @@ error: } /* end test_signing_key() */ - /*--------------------------------------------------------------------------- * * Function: test_tostringtosign() @@ -2351,41 +2286,39 @@ test_tostringtosign(void) * test-local variables * ************************/ - const char canonreq[] = "GET\n/test.txt\n\nhost:examplebucket.s3.amazonaws.com\nrange:bytes=0-9\nx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nx-amz-date:20130524T000000Z\n\nhost;range;x-amz-content-sha256;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; + const char canonreq[] = "GET\n/" + "test.txt\n\nhost:examplebucket.s3.amazonaws.com\nrange:bytes=0-9\nx-amz-content-" + "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nx-amz-" + "date:20130524T000000Z\n\nhost;range;x-amz-content-sha256;x-amz-" + "date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; const char iso8601now[] = "20130524T000000Z"; const char region[] = "us-east-1"; - char s2s[512]; + char s2s[512]; TESTING("s3comms tostringtosign"); - JSVERIFY( SUCCEED, - H5FD_s3comms_tostringtosign(s2s, canonreq, iso8601now, region), - "unable to create string to sign" ) + JSVERIFY(SUCCEED, H5FD_s3comms_tostringtosign(s2s, canonreq, iso8601now, region), + "unable to create string to sign") - JSVERIFY_STR( "AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972", - s2s, NULL ) + JSVERIFY_STR("AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/" + "aws4_request\n7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972", + s2s, NULL) - JSVERIFY( FAIL, - H5FD_s3comms_tostringtosign(s2s, NULL, iso8601now, region), - "canonical request string cannot be NULL" ) + JSVERIFY(FAIL, H5FD_s3comms_tostringtosign(s2s, NULL, iso8601now, region), + "canonical request string cannot be NULL") - JSVERIFY( FAIL, - H5FD_s3comms_tostringtosign(s2s, canonreq, NULL, region), - "time string cannot be NULL" ) + JSVERIFY(FAIL, H5FD_s3comms_tostringtosign(s2s, canonreq, NULL, region), "time string cannot be NULL") - JSVERIFY( FAIL, - H5FD_s3comms_tostringtosign(s2s, canonreq, iso8601now, NULL), - "aws region cannot be NULL" ) + JSVERIFY(FAIL, H5FD_s3comms_tostringtosign(s2s, canonreq, iso8601now, NULL), "aws region cannot be NULL") PASSED(); return 0; -error : +error: return -1; } /* end test_tostringtosign() */ - /*---------------------------------------------------------------------------- * * Function: test_trim() @@ -2418,39 +2351,42 @@ test_trim(void) ************************/ struct testcase cases[] = { - { "block string", + { + "block string", 12, "block string", 12, }, - { " \n\r \t", + { + " \n\r \t", 6, "", 0, }, - { " \twhite b4", + { + " \twhite b4", 10, "white b4", 8, }, - { "white after\r\n ", + { + "white after\r\n ", 15, "white after", 11, }, - { " on\nends\t", + { + " on\nends\t", 9, "on\nends", 7, }, }; - char dest[32]; - size_t dest_len = 0; - int i = 0; - int n_cases = 5; - char *str = NULL; - - + char dest[32]; + size_t dest_len = 0; + int i = 0; + int n_cases = 5; + char * str = NULL; TESTING("s3comms trim"); @@ -2460,28 +2396,24 @@ test_trim(void) HDassert(str != NULL); HDstrncpy(str, cases[i].in, cases[i].in_len); - JSVERIFY( SUCCEED, - H5FD_s3comms_trim(dest, str, cases[i].in_len, &dest_len), - NULL ) - JSVERIFY( cases[i].exp_len, dest_len, cases[i].in ) + JSVERIFY(SUCCEED, H5FD_s3comms_trim(dest, str, cases[i].in_len, &dest_len), NULL) + JSVERIFY(cases[i].exp_len, dest_len, cases[i].in) if (dest_len > 0) { - JSVERIFY( 0, strncmp(cases[i].exp, dest, dest_len), - cases[i].exp ) + JSVERIFY(0, strncmp(cases[i].exp, dest, dest_len), cases[i].exp) } free(str); str = NULL; } /* end for each testcase */ - JSVERIFY( SUCCEED, H5FD_s3comms_trim(dest, NULL, 3, &dest_len), - "should not fail when trimming a null string" ); - JSVERIFY( 0, dest_len, "trimming NULL string writes 0 characters" ) + JSVERIFY(SUCCEED, H5FD_s3comms_trim(dest, NULL, 3, &dest_len), + "should not fail when trimming a null string"); + JSVERIFY(0, dest_len, "trimming NULL string writes 0 characters") HDassert(str == NULL); str = (char *)HDmalloc(sizeof(char *) * 11); HDassert(str != NULL); memcpy(str, "some text ", 11); /* string with null terminator */ - JSVERIFY( FAIL, H5FD_s3comms_trim(NULL, str, 10, &dest_len), - "destination for trim cannot be NULL" ); + JSVERIFY(FAIL, H5FD_s3comms_trim(NULL, str, 10, &dest_len), "destination for trim cannot be NULL"); free(str); str = NULL; @@ -2496,7 +2428,6 @@ error: } /* end test_trim() */ - /*---------------------------------------------------------------------------- * * Function: test_uriencode() @@ -2528,68 +2459,61 @@ test_uriencode(void) * test-local variables * ************************/ - struct testcase cases[] = { - { "/path/to/resource.jpg", - 21, - FALSE, - "/path/to/resource.jpg", - }, - { "/path/to/resource.jpg", - 21, - TRUE, - "%2Fpath%2Fto%2Fresource.jpg", - }, - { "string got_spaa ces", - 20, - TRUE, - "string%20got_spaa%20%20ces", - }, - { "sp ac~es/and-sl ash.encoded", - 27, - TRUE, - "sp%20ac~es%2Fand-sl%20ash.encoded", - }, - { "sp ac~es/and-sl ash.unencoded", - 29, - FALSE, - "sp%20ac~es/and-sl%20ash.unencoded", - }, - { "/path/to/resource.txt", - 0, - FALSE, - "", - - } - }; - char *dest = NULL; - size_t dest_written = 0; - int i = 0; - int ncases = 6; - size_t str_len = 0; - - + struct testcase cases[] = {{ + "/path/to/resource.jpg", + 21, + FALSE, + "/path/to/resource.jpg", + }, + { + "/path/to/resource.jpg", + 21, + TRUE, + "%2Fpath%2Fto%2Fresource.jpg", + }, + { + "string got_spaa ces", + 20, + TRUE, + "string%20got_spaa%20%20ces", + }, + { + "sp ac~es/and-sl ash.encoded", + 27, + TRUE, + "sp%20ac~es%2Fand-sl%20ash.encoded", + }, + { + "sp ac~es/and-sl ash.unencoded", + 29, + FALSE, + "sp%20ac~es/and-sl%20ash.unencoded", + }, + { + "/path/to/resource.txt", + 0, + FALSE, + "", + + }}; + char * dest = NULL; + size_t dest_written = 0; + int i = 0; + int ncases = 6; + size_t str_len = 0; TESTING("s3comms uriencode") for (i = 0; i < ncases; i++) { str_len = cases[i].s_len; - dest = (char *)HDmalloc(sizeof(char) * str_len * 3 + 1); - FAIL_IF( dest == NULL ) - - JSVERIFY( SUCCEED, - H5FD_s3comms_uriencode( - dest, - cases[i].str, - str_len, - cases[i].encode_slash, - &dest_written), - NULL ); - JSVERIFY( HDstrlen(cases[i].expected), - dest_written, - NULL ) - JSVERIFY( 0, - strncmp(dest, cases[i].expected, dest_written), - cases[i].expected ); + dest = (char *)HDmalloc(sizeof(char) * str_len * 3 + 1); + FAIL_IF(dest == NULL) + + JSVERIFY(SUCCEED, + H5FD_s3comms_uriencode(dest, cases[i].str, str_len, cases[i].encode_slash, &dest_written), + NULL); + JSVERIFY(HDstrlen(cases[i].expected), dest_written, NULL) + JSVERIFY(0, strncmp(dest, cases[i].expected, dest_written), cases[i].expected); free(dest); dest = NULL; @@ -2602,12 +2526,10 @@ test_uriencode(void) dest = (char *)HDmalloc(sizeof(char) * 15); HDassert(dest != NULL); - JSVERIFY( FAIL, - H5FD_s3comms_uriencode(NULL, "word$", 5, false, &dest_written), - "destination cannot be NULL" ); - JSVERIFY( FAIL, - H5FD_s3comms_uriencode(dest, NULL, 5, false, &dest_written), - "source string cannot be NULL" ); + JSVERIFY(FAIL, H5FD_s3comms_uriencode(NULL, "word$", 5, false, &dest_written), + "destination cannot be NULL"); + JSVERIFY(FAIL, H5FD_s3comms_uriencode(dest, NULL, 5, false, &dest_written), + "source string cannot be NULL"); free(dest); dest = NULL; @@ -2625,8 +2547,6 @@ error: #endif /* H5_HAVE_ROS3_VFD */ - - /*------------------------------------------------------------------------- * Function: main() * @@ -2648,7 +2568,7 @@ int main(void) { #ifdef H5_HAVE_ROS3_VFD - int nerrors = 0; + int nerrors = 0; const char *bucket_url_env = NULL; h5_reset(); @@ -2665,24 +2585,20 @@ main(void) s3_test_aws_region[0] = '\0'; s3_test_bucket_url[0] = '\0'; -/* TODO: unit/regression test for H5FD_s3comms_load_aws_profile() - * requires a few test files and/or manipulation of default path - */ + /* TODO: unit/regression test for H5FD_s3comms_load_aws_profile() + * requires a few test files and/or manipulation of default path + */ /* attempt to load test credentials * if unable, certain tests will be skipped */ - if (SUCCEED == H5FD_s3comms_load_aws_profile( - S3_TEST_PROFILE_NAME, - s3_test_aws_access_key_id, - s3_test_aws_secret_access_key, - s3_test_aws_region)) - { + if (SUCCEED == H5FD_s3comms_load_aws_profile(S3_TEST_PROFILE_NAME, s3_test_aws_access_key_id, + s3_test_aws_secret_access_key, s3_test_aws_region)) { s3_test_credentials_loaded = 1; } bucket_url_env = HDgetenv("HDF5_ROS3_TEST_BUCKET_URL"); if (bucket_url_env == NULL || bucket_url_env[0] == '\0') { - HDprintf("WARNING: S3 bucket url is not defined in enviornment " \ + HDprintf("WARNING: S3 bucket url is not defined in enviornment " "variable 'HDF5_ROS3_TEST_BUCKET_URL'!\n"); } else { @@ -2692,26 +2608,24 @@ main(void) /* tests ordered rougly by dependence */ nerrors += test_macro_format_credential() < 0 ? 1 : 0; - nerrors += test_trim() < 0 ? 1 : 0; - nerrors += test_nlowercase() < 0 ? 1 : 0; - nerrors += test_uriencode() < 0 ? 1 : 0; - nerrors += test_percent_encode_char() < 0 ? 1 : 0; - nerrors += test_bytes_to_hex() < 0 ? 1 : 0; - nerrors += test_HMAC_SHA256() < 0 ? 1 : 0; - nerrors += test_signing_key() < 0 ? 1 : 0; - nerrors += test_hrb_node_set() < 0 ? 1 : 0; - nerrors += test_hrb_init_request() < 0 ? 1 : 0; - nerrors += test_parse_url() < 0 ? 1 : 0; - nerrors += test_aws_canonical_request() < 0 ? 1 : 0; - nerrors += test_tostringtosign() < 0 ? 1 : 0; - nerrors += test_s3r_open() < 0 ? 1 : 0; - nerrors += test_s3r_get_filesize() < 0 ? 1 : 0; - nerrors += test_s3r_read() < 0 ? 1 : 0; + nerrors += test_trim() < 0 ? 1 : 0; + nerrors += test_nlowercase() < 0 ? 1 : 0; + nerrors += test_uriencode() < 0 ? 1 : 0; + nerrors += test_percent_encode_char() < 0 ? 1 : 0; + nerrors += test_bytes_to_hex() < 0 ? 1 : 0; + nerrors += test_HMAC_SHA256() < 0 ? 1 : 0; + nerrors += test_signing_key() < 0 ? 1 : 0; + nerrors += test_hrb_node_set() < 0 ? 1 : 0; + nerrors += test_hrb_init_request() < 0 ? 1 : 0; + nerrors += test_parse_url() < 0 ? 1 : 0; + nerrors += test_aws_canonical_request() < 0 ? 1 : 0; + nerrors += test_tostringtosign() < 0 ? 1 : 0; + nerrors += test_s3r_open() < 0 ? 1 : 0; + nerrors += test_s3r_get_filesize() < 0 ? 1 : 0; + nerrors += test_s3r_read() < 0 ? 1 : 0; if (nerrors) { - HDprintf("***** %d S3comms TEST%s FAILED! *****\n", - nerrors, - nerrors > 1 ? "S" : ""); + HDprintf("***** %d S3comms TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); return 1; } @@ -2727,4 +2641,3 @@ main(void) #endif /* H5_HAVE_ROS3_VFD */ } /* end main() */ - diff --git a/test/set_extent.c b/test/set_extent.c index 171fd05..90257ac 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -27,122 +27,98 @@ *------------------------------------------------------------------------- */ -const char *FILENAME[] = { - "set_extent1", - "set_extent2", - "set_extent3", - "set_extent4", - "set_extent5", - "set_extent6", - NULL -}; - -#define NAME_BUF_SIZE 1024 +const char *FILENAME[] = {"set_extent1", "set_extent2", "set_extent3", "set_extent4", + "set_extent5", "set_extent6", NULL}; + +#define NAME_BUF_SIZE 1024 #define EXT_FILE_NAME1 "ext1.bin" #define EXT_FILE_NAME2 "ext2.bin" -#define CONFIG_COMPRESS 0x01u -#define CONFIG_FILL 0x02u -#define CONFIG_EARLY_ALLOC 0x04u -#define CONFIG_UNFILT_EDGE 0x08u -#define CONFIG_ALL (CONFIG_COMPRESS + CONFIG_FILL \ - + CONFIG_EARLY_ALLOC + CONFIG_UNFILT_EDGE) -#define FILL_VALUE -1 -#define DO_RANKS_PRINT_CONFIG(TEST) { \ - HDprintf(" Config:\n"); \ - HDprintf(" Test: %s\n", TEST); \ - HDprintf(" Compression: %s\n", (config & CONFIG_COMPRESS ? "yes" : "no")); \ - HDprintf(" Fill value: %s\n", (do_fillvalue ? "yes" : "no")); \ - HDprintf(" Early allocation: %s\n", (config & CONFIG_EARLY_ALLOC ? "yes" \ - : "no")); \ - HDprintf(" Edge chunk filters: %s\n", (config & CONFIG_UNFILT_EDGE \ - ? "disabled" : "enabled")); \ -} /* end DO_RANKS_PRINT_CONFIG */ - -#define RANK1 1 -#define RANK2 2 -#define RANK3 3 -#define DIM0 5 -#define DIM1 5 -#define DIM2 5 -#define DIMS0 3 -#define DIMS1 3 -#define DIMS2 3 -#define DIME0 7 -#define DIME1 7 -#define DIME2 7 -#define ISTORE_IK 64 -#define RAND4_NITER 100 +#define CONFIG_COMPRESS 0x01u +#define CONFIG_FILL 0x02u +#define CONFIG_EARLY_ALLOC 0x04u +#define CONFIG_UNFILT_EDGE 0x08u +#define CONFIG_ALL (CONFIG_COMPRESS + CONFIG_FILL + CONFIG_EARLY_ALLOC + CONFIG_UNFILT_EDGE) +#define FILL_VALUE -1 +#define DO_RANKS_PRINT_CONFIG(TEST) \ + { \ + HDprintf(" Config:\n"); \ + HDprintf(" Test: %s\n", TEST); \ + HDprintf(" Compression: %s\n", (config & CONFIG_COMPRESS ? "yes" : "no")); \ + HDprintf(" Fill value: %s\n", (do_fillvalue ? "yes" : "no")); \ + HDprintf(" Early allocation: %s\n", (config & CONFIG_EARLY_ALLOC ? "yes" : "no")); \ + HDprintf(" Edge chunk filters: %s\n", (config & CONFIG_UNFILT_EDGE ? "disabled" : "enabled")); \ + } /* end DO_RANKS_PRINT_CONFIG */ + +#define RANK1 1 +#define RANK2 2 +#define RANK3 3 +#define DIM0 5 +#define DIM1 5 +#define DIM2 5 +#define DIMS0 3 +#define DIMS1 3 +#define DIMS2 3 +#define DIME0 7 +#define DIME1 7 +#define DIME2 7 +#define ISTORE_IK 64 +#define RAND4_NITER 100 #define RAND4_SPARSE_SWITCH 10 -#define RAND4_FAIL_DUMP(NDIM_SETS, J, K, L, M) { \ - H5_FAILED(); AT(); \ - test_random_rank4_dump(NDIM_SETS, dim_log, cdims, J, K, L, M); \ - goto error; \ -} /* end RAND4_FAIL_DUMP */ -#define RAND4_VL_NITER 40 +#define RAND4_FAIL_DUMP(NDIM_SETS, J, K, L, M) \ + { \ + H5_FAILED(); \ + AT(); \ + test_random_rank4_dump(NDIM_SETS, dim_log, cdims, J, K, L, M); \ + goto error; \ + } /* end RAND4_FAIL_DUMP */ +#define RAND4_VL_NITER 40 #define RAND4_VL_SPARSE_SWITCH 5 typedef enum rank4_index_t { - RANK4_INDEX_BTREE = 0, /* Use b-tree (1/2) as chunk index */ - RANK4_INDEX_FARRAY, /* Use fixed array as chunk index */ - RANK4_INDEX_EARRAY, /* Use extensible array as chunk index */ - RANK4_NINDICES, /* Must be last */ + RANK4_INDEX_BTREE = 0, /* Use b-tree (1/2) as chunk index */ + RANK4_INDEX_FARRAY, /* Use fixed array as chunk index */ + RANK4_INDEX_EARRAY, /* Use extensible array as chunk index */ + RANK4_NINDICES, /* Must be last */ } rank4_index_t; -static int do_ranks( hid_t fapl, hbool_t new_format ); -static int do_layouts( hid_t fapl ); - -static int test_rank1( hid_t fapl, - hid_t dcpl, - hbool_t do_fill_value, - hbool_t disable_edge_filters, - hbool_t set_istore_k); -static int test_rank2( hid_t fapl, - hid_t dcpl, - hbool_t do_fill_value, - hbool_t disable_edge_filters, - hbool_t set_istore_k); -static int test_rank3( hid_t fapl, - hid_t dcpl, - hbool_t do_fill_value, - hbool_t disable_edge_filters, - hbool_t set_istore_k); -static int test_random_rank4( hid_t fapl, - hid_t dcpl, - hbool_t do_fillvalue, - hbool_t disable_edge_filters, - hbool_t do_sparse, - rank4_index_t index_type); -static int test_random_rank4_vl( hid_t fapl, - hid_t dcpl, - hbool_t do_fillvalue, - hbool_t disable_edge_filters, - hbool_t do_sparse, - rank4_index_t index_type); - -static int test_external( hid_t fapl ); -static int test_layouts( H5D_layout_t layout, hid_t fapl ); -static void test_random_rank4_dump( unsigned ndim_sets, hsize_t dim_log[][4], - hsize_t cdims[4], int j, int k, int l, int m ); +static int do_ranks(hid_t fapl, hbool_t new_format); +static int do_layouts(hid_t fapl); + +static int test_rank1(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t disable_edge_filters, + hbool_t set_istore_k); +static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t disable_edge_filters, + hbool_t set_istore_k); +static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t disable_edge_filters, + hbool_t set_istore_k); +static int test_random_rank4(hid_t fapl, hid_t dcpl, hbool_t do_fillvalue, hbool_t disable_edge_filters, + hbool_t do_sparse, rank4_index_t index_type); +static int test_random_rank4_vl(hid_t fapl, hid_t dcpl, hbool_t do_fillvalue, hbool_t disable_edge_filters, + hbool_t do_sparse, rank4_index_t index_type); + +static int test_external(hid_t fapl); +static int test_layouts(H5D_layout_t layout, hid_t fapl); +static void test_random_rank4_dump(unsigned ndim_sets, hsize_t dim_log[][4], hsize_t cdims[4], int j, int k, + int l, int m); /*------------------------------------------------------------------------- * main *------------------------------------------------------------------------- */ -int main( void ) +int +main(void) { - hid_t fapl; /* file access property list */ - hid_t fapl2; /* file access property list w/latest format set */ - unsigned new_format; /* Whether to use the latest file format */ - unsigned chunk_cache; /* Whether to enable chunk caching */ - int nerrors = 0; - const char *env_h5_drvr; /* File Driver value from environment */ - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - + hid_t fapl; /* file access property list */ + hid_t fapl2; /* file access property list w/latest format set */ + unsigned new_format; /* Whether to use the latest file format */ + unsigned chunk_cache; /* Whether to enable chunk caching */ + int nerrors = 0; + const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; /* Current VFD that does not support contigous address space */ contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); @@ -154,31 +130,35 @@ int main( void ) fapl = h5_fileaccess(); /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Set chunk cache so only part of the chunks can be cached on fapl */ - if(H5Pset_cache(fapl, 0, (size_t)8, 256 * sizeof(int), 0.75F) < 0) TEST_ERROR + if (H5Pset_cache(fapl, 0, (size_t)8, 256 * sizeof(int), 0.75F) < 0) + TEST_ERROR /* Disable chunk caching on fapl2 */ - if(H5Pset_cache(fapl2, 0, (size_t)0, (size_t)0, 0.0F) < 0) TEST_ERROR + if (H5Pset_cache(fapl2, 0, (size_t)0, (size_t)0, 0.0F) < 0) + TEST_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR /* Test with old & new format groups */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl; /* Test chunked datasets with and without chunk cache */ - for(chunk_cache = FALSE; chunk_cache <= TRUE; chunk_cache++) { + for (chunk_cache = FALSE; chunk_cache <= TRUE; chunk_cache++) { /* Output message about the type of format */ - if(new_format) + if (new_format) HDprintf("Testing with new file format"); else HDprintf("Testing with old file format"); /* Set the FAPL for the chunk cache settings */ - if(chunk_cache) { + if (chunk_cache) { HDputs(" and chunk cache enabled:"); my_fapl = fapl; } /* end if */ @@ -188,32 +168,33 @@ int main( void ) } /* end else */ /* Set the FAPL for the type of format */ - if(new_format) { + if (new_format) { /* Set the "use the latest version of the format" bounds for * creating objects in the file */ - if(H5Pset_libver_bounds(my_fapl, H5F_LIBVER_LATEST, - H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(my_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR } /* end if */ else /* Set the "use the earliest version of the format" bounds for * creating objects in the file */ - if(H5Pset_libver_bounds(my_fapl, H5F_LIBVER_EARLIEST, - H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(my_fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR /* Tests which use chunked datasets */ - if(!new_format || (new_format && contig_addr_vfd)) - nerrors += do_ranks( my_fapl, new_format ) < 0 ? 1 : 0; + if (!new_format || (new_format && contig_addr_vfd)) + nerrors += do_ranks(my_fapl, new_format) < 0 ? 1 : 0; } /* end for */ /* Tests which do not use chunked datasets */ - if(!new_format || (new_format && contig_addr_vfd)) { - nerrors += test_external( fapl ) < 0 ? 1 : 0; - nerrors += do_layouts( fapl ) < 0 ? 1 : 0; + if (!new_format || (new_format && contig_addr_vfd)) { + nerrors += test_external(fapl) < 0 ? 1 : 0; + nerrors += do_layouts(fapl) < 0 ? 1 : 0; } } /* end for */ /* Close 2nd FAPL */ - if(H5Pclose(fapl2) < 0) TEST_ERROR + if (H5Pclose(fapl2) < 0) + TEST_ERROR /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); @@ -223,7 +204,7 @@ int main( void ) HDremove(EXT_FILE_NAME1); HDremove(EXT_FILE_NAME2); - if(nerrors) + if (nerrors) goto error; HDputs("All H5Dset_extent tests passed."); @@ -231,180 +212,174 @@ int main( void ) error: nerrors = MAX(1, nerrors); - HDprintf("***** %d H5Dset_extent TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d H5Dset_extent TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } - /*------------------------------------------------------------------------- -* test with several ranks -*------------------------------------------------------------------------- -*/ -static int do_ranks( hid_t fapl, hbool_t new_format ) + * test with several ranks + *------------------------------------------------------------------------- + */ +static int +do_ranks(hid_t fapl, hbool_t new_format) { - hbool_t do_fillvalue = FALSE; - hbool_t disable_edge_filters = FALSE; + hbool_t do_fillvalue = FALSE; + hbool_t disable_edge_filters = FALSE; rank4_index_t index_type; - hid_t dcpl = -1; - int fillvalue = FILL_VALUE; - unsigned config; + hid_t dcpl = -1; + int fillvalue = FILL_VALUE; + unsigned config; TESTING_2("datasets with ranks 1 to 4 (all configurations)"); /* Loop over different configurations for tests */ - for(config=0; config<=CONFIG_ALL; config++) { + for (config = 0; config <= CONFIG_ALL; config++) { /* Create DCPL and add appropriate settings */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(config & CONFIG_COMPRESS) { + if (config & CONFIG_COMPRESS) { #ifdef H5_HAVE_FILTER_DEFLATE - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) TEST_ERROR -#else /* H5_HAVE_FILTER_DEFLATE */ - if(H5Pclose(dcpl) < 0) +#else /* H5_HAVE_FILTER_DEFLATE */ + if (H5Pclose(dcpl) < 0) TEST_ERROR continue; -#endif /* H5_HAVE_FILTER_DEFLATE */ +#endif /* H5_HAVE_FILTER_DEFLATE */ } /* end if */ - if(config & CONFIG_FILL) { + if (config & CONFIG_FILL) { do_fillvalue = TRUE; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0) TEST_ERROR } /* end if */ else do_fillvalue = FALSE; - if(config & CONFIG_EARLY_ALLOC) - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + if (config & CONFIG_EARLY_ALLOC) + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR - if(config & CONFIG_UNFILT_EDGE) + if (config & CONFIG_UNFILT_EDGE) disable_edge_filters = TRUE; else disable_edge_filters = FALSE; /* Run tests */ - if(do_fillvalue) { + if (do_fillvalue) { unsigned ifset; /* Iterate over different fill times */ - for(ifset=0; ifset<=1; ifset++) { - if(ifset) { - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) + for (ifset = 0; ifset <= 1; ifset++) { + if (ifset) { + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) TEST_ERROR } /* end if */ - else - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) - TEST_ERROR + else if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + TEST_ERROR - if(test_rank1(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { + if (test_rank1(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { DO_RANKS_PRINT_CONFIG("Rank 1") - HDprintf(" Fill time: %s\n", (ifset ? "H5D_FILL_TIME_IFSET" - : "H5D_FILL_TIME_ALLOC")); + HDprintf(" Fill time: %s\n", (ifset ? "H5D_FILL_TIME_IFSET" : "H5D_FILL_TIME_ALLOC")); goto error; } /* end if */ - if(test_rank2(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { + if (test_rank2(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { DO_RANKS_PRINT_CONFIG("Rank 2") - HDprintf(" Fill time: %s\n", (ifset ? "H5D_FILL_TIME_IFSET" - : "H5D_FILL_TIME_ALLOC")); + HDprintf(" Fill time: %s\n", (ifset ? "H5D_FILL_TIME_IFSET" : "H5D_FILL_TIME_ALLOC")); goto error; } /* end if */ - if(test_rank3(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { + if (test_rank3(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { DO_RANKS_PRINT_CONFIG("Rank 3") - HDprintf(" Fill time: %s\n", (ifset ? "H5D_FILL_TIME_IFSET" - : "H5D_FILL_TIME_ALLOC")); + HDprintf(" Fill time: %s\n", (ifset ? "H5D_FILL_TIME_IFSET" : "H5D_FILL_TIME_ALLOC")); goto error; } /* end if */ - if(test_rank2(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE) < 0) { + if (test_rank2(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE) < 0) { DO_RANKS_PRINT_CONFIG("Rank 2 with non-default indexed storage B-tree") - HDprintf(" Fill time: %s\n", (ifset ? "H5D_FILL_TIME_IFSET" - : "H5D_FILL_TIME_ALLOC")); + HDprintf(" Fill time: %s\n", (ifset ? "H5D_FILL_TIME_IFSET" : "H5D_FILL_TIME_ALLOC")); goto error; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { /* These tests expect fill values to be written even if there is no * fill value defined */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) TEST_ERROR - if(test_rank1(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { + if (test_rank1(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { DO_RANKS_PRINT_CONFIG("Rank 1") goto error; } /* end if */ - if(test_rank2(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { + if (test_rank2(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { DO_RANKS_PRINT_CONFIG("Rank 2") goto error; } /* end if */ - if(test_rank3(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { + if (test_rank3(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE) < 0) { DO_RANKS_PRINT_CONFIG("Rank 3") goto error; } /* end if */ - if(test_rank2(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE) < 0) { + if (test_rank2(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE) < 0) { DO_RANKS_PRINT_CONFIG("Rank 2 with non-default indexed storage B-tree") goto error; } /* end if */ - } /* end else */ + } /* end else */ /* The rank 4 test expects the fill value to be written only if * defined */ - if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) + if (H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET) < 0) TEST_ERROR /* Iterate over different index types, but only if using the new format */ - for(index_type = RANK4_INDEX_BTREE; index_type < RANK4_NINDICES; index_type++) { + for (index_type = RANK4_INDEX_BTREE; index_type < RANK4_NINDICES; index_type++) { /* Standard test */ - if(test_random_rank4(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE, index_type) < 0) { + if (test_random_rank4(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE, index_type) < 0) { DO_RANKS_PRINT_CONFIG("Randomized rank 4") HDprintf(" Index: %s\n", index_type == RANK4_INDEX_BTREE - ? "btree" : (index_type == RANK4_INDEX_FARRAY ? "farray" - : "earray")); + ? "btree" + : (index_type == RANK4_INDEX_FARRAY ? "farray" : "earray")); goto error; } /* end if */ /* VL test */ - if(test_random_rank4_vl(fapl, dcpl, do_fillvalue, - disable_edge_filters, FALSE, index_type) < 0) { + if (test_random_rank4_vl(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE, index_type) < 0) { DO_RANKS_PRINT_CONFIG("Randomized rank 4 variable length") HDprintf(" Index: %s\n", index_type == RANK4_INDEX_BTREE - ? "btree" : (index_type == RANK4_INDEX_FARRAY ? "farray" - : "earray")); + ? "btree" + : (index_type == RANK4_INDEX_FARRAY ? "farray" : "earray")); goto error; } /* end if */ /* Sparse allocation test (regular and VL) */ - if(!(config & CONFIG_EARLY_ALLOC)) { - if(test_random_rank4(fapl, dcpl, do_fillvalue, - disable_edge_filters, TRUE, index_type) < 0) { + if (!(config & CONFIG_EARLY_ALLOC)) { + if (test_random_rank4(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE, index_type) < 0) { DO_RANKS_PRINT_CONFIG("Randomized rank 4 with sparse allocation") - HDprintf(" Index: %s\n", index_type == RANK4_INDEX_BTREE - ? "btree" : (index_type == RANK4_INDEX_FARRAY - ? "farray" : "earray")); + HDprintf(" Index: %s\n", + index_type == RANK4_INDEX_BTREE + ? "btree" + : (index_type == RANK4_INDEX_FARRAY ? "farray" : "earray")); goto error; } /* end if */ - if(test_random_rank4_vl(fapl, dcpl, do_fillvalue, - disable_edge_filters, TRUE, index_type) < 0) { + if (test_random_rank4_vl(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE, index_type) < + 0) { DO_RANKS_PRINT_CONFIG("Randomized rank 4 variable length with sparse allocation") - HDprintf(" Index: %s\n", index_type == RANK4_INDEX_BTREE - ? "btree" : (index_type == RANK4_INDEX_FARRAY - ? "farray" : "earray")); + HDprintf(" Index: %s\n", + index_type == RANK4_INDEX_BTREE + ? "btree" + : (index_type == RANK4_INDEX_FARRAY ? "farray" : "earray")); goto error; } /* end if */ - } /* end if */ + } /* end if */ /* Break out if using the old format */ - if(!new_format) + if (!new_format) break; } /* end for */ /* Close dcpl */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR } /* end for */ @@ -413,36 +388,40 @@ static int do_ranks( hid_t fapl, hbool_t new_format ) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); - } H5E_END_TRY + } + H5E_END_TRY return -1; } /* end do_ranks */ - /*------------------------------------------------------------------------- -* test with different storage layouts -*------------------------------------------------------------------------- -*/ -static int do_layouts( hid_t fapl ) + * test with different storage layouts + *------------------------------------------------------------------------- + */ +static int +do_layouts(hid_t fapl) { - hid_t new_fapl = -1; + hid_t new_fapl = -1; H5F_libver_t low, high; /* Low and high bounds */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ TESTING("storage layout use - tested with all low/high library format bounds"); /* Loop through all the combinations of low/high library format bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Copy plist to use locally to avoid modifying the original */ new_fapl = H5Pcopy(fapl); /* Set version bounds */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ { @@ -451,16 +430,16 @@ static int do_layouts( hid_t fapl ) continue; } - if (test_layouts( H5D_COMPACT, new_fapl ) < 0) + if (test_layouts(H5D_COMPACT, new_fapl) < 0) goto error; - if (test_layouts( H5D_CONTIGUOUS, new_fapl ) < 0) + if (test_layouts(H5D_CONTIGUOUS, new_fapl) < 0) goto error; if (H5Pclose(new_fapl) < 0) goto error; } /* end for high */ - } /* end for low */ + } /* end for low */ PASSED(); @@ -470,7 +449,8 @@ error: H5E_BEGIN_TRY { H5Pclose(new_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } @@ -479,23 +459,20 @@ error: *------------------------------------------------------------------------- */ -static int test_rank1( hid_t fapl, - hid_t dcpl, - hbool_t do_fill_value, - hbool_t disable_edge_filters, - hbool_t set_istore_k) +static int +test_rank1(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t disable_edge_filters, hbool_t set_istore_k) { - hid_t fid=-1; - hid_t did=-1; - hid_t sid=-1; - hid_t my_dcpl=-1; + hid_t fid = -1; + hid_t did = -1; + hid_t sid = -1; + hid_t my_dcpl = -1; hid_t fcpl; - hsize_t dims_o[RANK1] = {DIM0}; /* original dimensions */ - hsize_t dims_s[RANK1] = {DIMS0}; /* shrinking dimensions */ - hsize_t dims_e[RANK1] = {DIME0}; /* extended dimensions */ - hsize_t dims_c[RANK1] = {2}; /* chunk dimensions */ - hsize_t dims_r[RANK1]; /* read dimensions */ + hsize_t dims_o[RANK1] = {DIM0}; /* original dimensions */ + hsize_t dims_s[RANK1] = {DIMS0}; /* shrinking dimensions */ + hsize_t dims_e[RANK1] = {DIME0}; /* extended dimensions */ + hsize_t dims_c[RANK1] = {2}; /* chunk dimensions */ + hsize_t dims_r[RANK1]; /* read dimensions */ hsize_t maxdims[RANK1] = {H5S_UNLIMITED}; int buf_o[DIM0]; int buf_s[DIMS0]; @@ -505,43 +482,43 @@ static int test_rank1( hid_t fapl, int comp_value; char filename[NAME_BUF_SIZE]; - if(do_fill_value) + if (do_fill_value) comp_value = FILL_VALUE; else comp_value = 0; - for(i = 0; i < DIM0; i++ ) + for (i = 0; i < DIM0; i++) buf_o[i] = 2; /* create a file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR /* set non-default indexed storage B-tree internal 'K' value */ - if(set_istore_k) - if(H5Pset_istore_k(fcpl,ISTORE_IK) < 0) + if (set_istore_k) + if (H5Pset_istore_k(fcpl, ISTORE_IK) < 0) TEST_ERROR /* create a new file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR /* close property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) TEST_ERROR /* create the data space with unlimited dimensions. */ - if((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0) + if ((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0) TEST_ERROR /* modify dataset creation properties, i.e. enable chunking. */ - if((my_dcpl = H5Pcopy (dcpl)) < 0) + if ((my_dcpl = H5Pcopy(dcpl)) < 0) TEST_ERROR - if(H5Pset_chunk(my_dcpl, RANK1, dims_c) < 0) + if (H5Pset_chunk(my_dcpl, RANK1, dims_c) < 0) TEST_ERROR - if(disable_edge_filters) - if(H5Pset_chunk_opts(my_dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + if (disable_edge_filters) + if (H5Pset_chunk_opts(my_dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR /*------------------------------------------------------------------------- @@ -550,21 +527,21 @@ static int test_rank1( hid_t fapl, */ /* create a dataset */ - if((did = H5Dcreate2(fid , "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, my_dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, my_dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* write */ - if(H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, buf_o) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, buf_o) < 0) TEST_ERROR -#if defined (H5_SET_EXTENT_DEBUG) +#if defined(H5_SET_EXTENT_DEBUG) HDprintf("\n buf_o: "); - for (i = 0; i < (int)dims_o[0]; i++ ) + for (i = 0; i < (int)dims_o[0]; i++) HDprintf("%d ", buf_o[i]); HDprintf("\n"); #endif - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /*------------------------------------------------------------------------- @@ -573,22 +550,22 @@ static int test_rank1( hid_t fapl, */ /* set new dimensions for the array. */ - if(H5Dset_extent(did , dims_e) < 0) + if (H5Dset_extent(did, dims_e) < 0) TEST_ERROR /* get the space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) TEST_ERROR /* get dimensions */ - if(H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /* check dimensions */ - for( i = 0; i < RANK1; i++ ) + for (i = 0; i < RANK1; i++) if (dims_r[i] != dims_e[i]) TEST_ERROR @@ -596,89 +573,85 @@ static int test_rank1( hid_t fapl, if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_e) < 0) TEST_ERROR - -#if defined (H5_SET_EXTENT_DEBUG) +#if defined(H5_SET_EXTENT_DEBUG) HDprintf("\n buf_e: "); - for (i = 0; i < (int)dims_r[0]; i++ ) + for (i = 0; i < (int)dims_r[0]; i++) HDprintf("%d ", buf_e[i]); HDprintf("\n"); #endif /* compare the read array with the expanded array */ - for (i = 0; i < (int)dims_r[0]; i++ ) - if(i >= DIM0) { - if(buf_e[i] != comp_value) { + for (i = 0; i < (int)dims_r[0]; i++) + if (i >= DIM0) { + if (buf_e[i] != comp_value) { HDprintf("buf_e[%d] = %d\n", i, buf_e[i]); HDprintf("expected = %d\n", comp_value); TEST_ERROR } /* end if */ - } /* end if */ + } /* end if */ else { - if(buf_e[i] != buf_o[i]) + if (buf_e[i] != buf_o[i]) TEST_ERROR } /* end else */ - - /*------------------------------------------------------------------------- * shrink *------------------------------------------------------------------------- */ /* set new dimensions for the array. */ - if(H5Dset_extent(did , dims_s) < 0) + if (H5Dset_extent(did, dims_s) < 0) TEST_ERROR /* get the space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) TEST_ERROR /* get dimensions */ - if(H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /* check dimensions */ - for( i = 0; i < RANK1; i++ ) + for (i = 0; i < RANK1; i++) if (dims_r[i] != dims_s[i]) TEST_ERROR /* for this case we close and reopen file */ - if(set_istore_k) { - if(H5Dclose(did) < 0) + if (set_istore_k) { + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR - if((fid = H5Fopen( filename, H5F_ACC_RDWR, fapl ))<0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((did = H5Dopen2( fid , "dset1", H5P_DEFAULT ))<0) + if ((did = H5Dopen2(fid, "dset1", H5P_DEFAULT)) < 0) TEST_ERROR } /* end if */ - /*------------------------------------------------------------------------- * read *------------------------------------------------------------------------- */ /* read */ - if(H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s ) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s) < 0) TEST_ERROR -#if defined (H5_SET_EXTENT_DEBUG) +#if defined(H5_SET_EXTENT_DEBUG) HDprintf("\n dims_r: "); - for (i = 0; i < (int)dims_r[0]; i++ ) + for (i = 0; i < (int)dims_r[0]; i++) HDprintf("%d ", buf_s[i]); HDprintf("\n"); #endif /* compare the read array with the shrinked array */ - for( i = 0; i < (int)dims_r[0]; i++ ) - if(buf_s[i] != buf_o[i]) { + for (i = 0; i < (int)dims_r[0]; i++) + if (buf_s[i] != buf_o[i]) { HDprintf("buf_s[%d] = %d\n", i, buf_s[i]); HDprintf("buf_o[%d] = %d\n", i, buf_o[i]); TEST_ERROR @@ -690,51 +663,50 @@ static int test_rank1( hid_t fapl, */ /* set new dimensions for the array */ - if(H5Dset_extent(did, dims_o) < 0) + if (H5Dset_extent(did, dims_o) < 0) TEST_ERROR /* get the space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) TEST_ERROR /* get dimensions. */ - if(H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /* check dimensions */ - for( i = 0; i < RANK1; i++ ) + for (i = 0; i < RANK1; i++) if (dims_r[i] != dims_o[i]) TEST_ERROR /* read */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0) TEST_ERROR -#if defined (H5_SET_EXTENT_DEBUG) +#if defined(H5_SET_EXTENT_DEBUG) HDprintf("\n dims_r: "); - for (i = 0; i < (int)dims_r[0]; i++ ) + for (i = 0; i < (int)dims_r[0]; i++) HDprintf("%d ", buf_r[i]); HDprintf("\n"); #endif /* compare the read array with the original array */ - for(i = 0; i < (int)dims_r[0]; i++ ) - if(i >= DIMS0 ) { - if(buf_r[i] != comp_value) { - HDprintf("buf_r[%d] = %d\n", i, buf_r[i] ); + for (i = 0; i < (int)dims_r[0]; i++) + if (i >= DIMS0) { + if (buf_r[i] != comp_value) { + HDprintf("buf_r[%d] = %d\n", i, buf_r[i]); HDprintf("expected = %d\n", comp_value); TEST_ERROR } /* end if */ - } /* end if */ + } /* end if */ else { - if(buf_r[i] != buf_o[i]) + if (buf_r[i] != buf_o[i]) TEST_ERROR } /* end else */ - /*------------------------------------------------------------------------- * shrink to 0 *------------------------------------------------------------------------- @@ -743,22 +715,22 @@ static int test_rank1( hid_t fapl, dims_s[0] = 0; /* set new dimensions for the array. */ - if(H5Dset_extent(did , dims_s) < 0) + if (H5Dset_extent(did, dims_s) < 0) TEST_ERROR /* get the space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) TEST_ERROR /* get dimensions */ - if(H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /* check dimensions */ - for( i = 0; i < RANK1; i++ ) - if(dims_r[i] != dims_s[i]) + for (i = 0; i < RANK1; i++) + if (dims_r[i] != dims_s[i]) TEST_ERROR /*------------------------------------------------------------------------- @@ -766,7 +738,7 @@ static int test_rank1( hid_t fapl, *------------------------------------------------------------------------- */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR /*------------------------------------------------------------------------- @@ -774,29 +746,28 @@ static int test_rank1( hid_t fapl, *------------------------------------------------------------------------- */ - - if((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0) + if ((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid , "dset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, my_dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, my_dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* set new dimensions for the array */ - dims_o[ 0 ] = 0; - if(H5Dset_extent( did , dims_o ) < 0) + dims_o[0] = 0; + if (H5Dset_extent(did, dims_o) < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR /*------------------------------------------------------------------------- * close property list *------------------------------------------------------------------------- */ - if(H5Pclose(my_dcpl) < 0) + if (H5Pclose(my_dcpl) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR return 0; @@ -805,12 +776,13 @@ error: H5E_BEGIN_TRY { - H5Dclose( did ); - H5Sclose( sid ); - H5Pclose( my_dcpl ); - H5Pclose( fcpl ); - H5Fclose( fid ); - } H5E_END_TRY; + H5Dclose(did); + H5Sclose(sid); + H5Pclose(my_dcpl); + H5Pclose(fcpl); + H5Fclose(fid); + } + H5E_END_TRY; return -1; } /* end test_rank1() */ @@ -820,30 +792,33 @@ error: *------------------------------------------------------------------------- */ -static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t disable_edge_filters, hbool_t set_istore_k) { - - hid_t fid = -1; - hid_t did = -1; - hid_t sid = -1; - hid_t my_dcpl = -1; - hid_t fcpl; - hsize_t dims_o[RANK2] = { DIM0, DIM1 }; /* original dimensions */ - hsize_t dims_s[RANK2] = { DIMS0, DIMS1 }; /* shrinking dimensions */ - hsize_t dims_e[RANK2] = { DIME0, DIME1 }; /* extended dimensions */ - hsize_t dims_c[RANK2] = { 2, 2 }; /* chunk dimensions */ - hsize_t dims_r[RANK2]; /* read dimensions */ - hsize_t maxdims[RANK2] = { H5S_UNLIMITED, H5S_UNLIMITED }; - int buf_o[DIM0][DIM1]; - int buf_s[DIMS0][DIMS1]; - int buf_e[DIME0][DIME1]; - int buf_r[DIM0][DIM1]; - int i, j; - int comp_value; - char filename[NAME_BUF_SIZE]; +static int +test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t disable_edge_filters, hbool_t set_istore_k) +{ + + hid_t fid = -1; + hid_t did = -1; + hid_t sid = -1; + hid_t my_dcpl = -1; + hid_t fcpl; + hsize_t dims_o[RANK2] = {DIM0, DIM1}; /* original dimensions */ + hsize_t dims_s[RANK2] = {DIMS0, DIMS1}; /* shrinking dimensions */ + hsize_t dims_e[RANK2] = {DIME0, DIME1}; /* extended dimensions */ + hsize_t dims_c[RANK2] = {2, 2}; /* chunk dimensions */ + hsize_t dims_r[RANK2]; /* read dimensions */ + hsize_t maxdims[RANK2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + int buf_o[DIM0][DIM1]; + int buf_s[DIMS0][DIMS1]; + int buf_e[DIME0][DIME1]; + int buf_r[DIM0][DIM1]; + int i, j; + int comp_value; + char filename[NAME_BUF_SIZE]; if (do_fill_value) { comp_value = FILL_VALUE; - } else { + } + else { comp_value = 0; } @@ -863,7 +838,6 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if (H5Pset_istore_k(fcpl, ISTORE_IK) < 0) { TEST_ERROR } - } /* create a new file */ @@ -888,25 +862,25 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if (H5Pset_chunk_opts(my_dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR - /*------------------------------------------------------------------------- - * Procedure 1 - * a. Write an array AxB. These are the dimensions for creating the dataset - * b. Define a greater array CxD where C > A and D > B - * c. Read data back - * d. Verify if new dimensions are C and D - * e. Verify if data from A to C and B to D is what it is to be expected - * - * original data is - * - * 2 2 2 2 - * 2 2 2 2 - * 2 2 2 2 - * 2 2 2 2 - * - *------------------------------------------------------------------------- - */ - - /* create a dataset */ + /*------------------------------------------------------------------------- + * Procedure 1 + * a. Write an array AxB. These are the dimensions for creating the dataset + * b. Define a greater array CxD where C > A and D > B + * c. Read data back + * d. Verify if new dimensions are C and D + * e. Verify if data from A to C and B to D is what it is to be expected + * + * original data is + * + * 2 2 2 2 + * 2 2 2 2 + * 2 2 2 2 + * 2 2 2 2 + * + *------------------------------------------------------------------------- + */ + + /* create a dataset */ if ((did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, my_dcpl, H5P_DEFAULT)) < 0) { TEST_ERROR } @@ -916,10 +890,10 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis TEST_ERROR } -#if defined (H5_SET_EXTENT_DEBUG2) +#if defined(H5_SET_EXTENT_DEBUG2) HDprintf("\n"); - for (i = 0; i < (int)dims_o[0]; i++ ) { - for (j = 0; j < (int)dims_o[1]; j++ ) { + for (i = 0; i < (int)dims_o[0]; i++) { + for (j = 0; j < (int)dims_o[1]; j++) { HDprintf("%d ", buf_o[i][j]); } HDprintf("\n"); @@ -931,19 +905,19 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * set new dimensions for the array; expand it - * data is now, extended space was initialized with fill value or default value - * - * 2 2 2 2 1 1 1 - * 2 2 2 2 1 1 1 - * 2 2 2 2 1 1 1 - * 2 2 2 2 1 1 1 - * 1 1 1 1 1 1 1 - * 1 1 1 1 1 1 1 - * 1 1 1 1 1 1 1 - * - *------------------------------------------------------------------------- - */ + * set new dimensions for the array; expand it + * data is now, extended space was initialized with fill value or default value + * + * 2 2 2 2 1 1 1 + * 2 2 2 2 1 1 1 + * 2 2 2 2 1 1 1 + * 2 2 2 2 1 1 1 + * 1 1 1 1 1 1 1 + * 1 1 1 1 1 1 1 + * 1 1 1 1 1 1 1 + * + *------------------------------------------------------------------------- + */ /* set new dimensions for the array. */ if (H5Dset_extent(did, dims_e) < 0) { @@ -974,26 +948,27 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_e) < 0) TEST_ERROR -#if defined (H5_SET_EXTENT_DEBUG2) +#if defined(H5_SET_EXTENT_DEBUG2) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { HDprintf("%d ", buf_e[i][j]); } HDprintf("\n"); } #endif - /* compare the read array with the expanded array */ - for (i = 0; i < (int) dims_r[0]; i++) { - for (j = 0; j < (int) dims_r[1]; j++) { + /* compare the read array with the expanded array */ + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { if (i >= DIM0 || j >= DIM1) { if (buf_e[i][j] != comp_value) { HDprintf("buf_e[%d][%d] = %d\n", i, j, buf_e[i][j]); HDprintf("value = %d\n", comp_value); TEST_ERROR } - } else { + } + else { if (buf_e[i][j] != buf_o[i][j]) TEST_ERROR } @@ -1001,20 +976,20 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * - * Procedure 2 - * a. Define a smaller array ExF where E < A and F < B - * b. Read data back - * c. Verify if new dimensions are E and F - * d. Verify if data up until E and F is what to be expected - * - * data is now - * - * 2 2 - * 2 2 - * - *------------------------------------------------------------------------- - */ + * + * Procedure 2 + * a. Define a smaller array ExF where E < A and F < B + * b. Read data back + * c. Verify if new dimensions are E and F + * d. Verify if data up until E and F is what to be expected + * + * data is now + * + * 2 2 + * 2 2 + * + *------------------------------------------------------------------------- + */ /* set new dimensions for the array. */ if (H5Dset_extent(did, dims_s) < 0) { @@ -1058,23 +1033,22 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if ((did = H5Dopen2(fid, "dset1", H5P_DEFAULT)) < 0) { TEST_ERROR } - } /*------------------------------------------------------------------------- - * read - *------------------------------------------------------------------------- - */ + * read + *------------------------------------------------------------------------- + */ /* read */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s) < 0) { TEST_ERROR } -#if defined (H5_SET_EXTENT_DEBUG2) +#if defined(H5_SET_EXTENT_DEBUG2) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { HDprintf("%d ", buf_s[i][j]); } HDprintf("\n"); @@ -1082,8 +1056,8 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis #endif /* compare the read array with the shrinked array */ - for (i = 0; i < (int) dims_r[0]; i++) { - for (j = 0; j < (int) dims_r[1]; j++) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { if (buf_s[i][j] != buf_o[i][j]) { HDprintf("buf_s[%d][%d] = %d\n", i, j, buf_s[i][j]); HDprintf("buf_o[%d][%d] = %d\n", i, j, buf_o[i][j]); @@ -1093,16 +1067,16 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * set new dimensions for the array; expand it back to original size - * data is now, extended space was initialized with fill value or default value - * - * 2 2 1 1 - * 2 2 1 1 - * 1 1 1 1 - * 1 1 1 1 - * - *------------------------------------------------------------------------- - */ + * set new dimensions for the array; expand it back to original size + * data is now, extended space was initialized with fill value or default value + * + * 2 2 1 1 + * 2 2 1 1 + * 1 1 1 1 + * 1 1 1 1 + * + *------------------------------------------------------------------------- + */ /* set new dimensions for the array */ if (H5Dset_extent(did, dims_o) < 0) { @@ -1130,34 +1104,35 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * read - *------------------------------------------------------------------------- - */ + * read + *------------------------------------------------------------------------- + */ /* read */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0) TEST_ERROR -#if defined (H5_SET_EXTENT_DEBUG2) +#if defined(H5_SET_EXTENT_DEBUG2) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { HDprintf("%d ", buf_r[i][j]); } HDprintf("\n"); } #endif - /* compare the read array with the original array */ - for (i = 0; i < (int) dims_r[0]; i++) { - for (j = 0; j < (int) dims_r[1]; j++) { + /* compare the read array with the original array */ + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { if (i >= DIMS0 || j >= DIMS1) { if (buf_r[i][j] != comp_value) { HDprintf("buf_r[%d][%d] = %d\n", i, j, buf_r[i][j]); HDprintf("value = %d\n", comp_value); TEST_ERROR } - } else { + } + else { if (buf_r[i][j] != buf_o[i][j]) TEST_ERROR } @@ -1165,10 +1140,10 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * shrink to 0 - * - *------------------------------------------------------------------------- - */ + * shrink to 0 + * + *------------------------------------------------------------------------- + */ dims_s[0] = 0; dims_s[1] = 0; @@ -1199,11 +1174,11 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * expand then shrink to 0 in dimension 1 while expanding again in - * dimension 0 - * - *------------------------------------------------------------------------- - */ + * expand then shrink to 0 in dimension 1 while expanding again in + * dimension 0 + * + *------------------------------------------------------------------------- + */ /* expand to original dimensions for the array. */ if (H5Dset_extent(did, dims_o) < 0) { @@ -1239,18 +1214,18 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * close dataset - *------------------------------------------------------------------------- - */ + * close dataset + *------------------------------------------------------------------------- + */ if (H5Dclose(did) < 0) { TEST_ERROR } /*------------------------------------------------------------------------- - * test a dataset with non initialized chunks - *------------------------------------------------------------------------- - */ + * test a dataset with non initialized chunks + *------------------------------------------------------------------------- + */ if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0) { TEST_ERROR @@ -1273,9 +1248,9 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * close property list - *------------------------------------------------------------------------- - */ + * close property list + *------------------------------------------------------------------------- + */ if (H5Pclose(my_dcpl) < 0) { TEST_ERROR @@ -1292,18 +1267,18 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis return 0; - error: +error: H5E_BEGIN_TRY - { - H5Dclose(did); - H5Sclose(sid); - H5Pclose(my_dcpl); - H5Pclose(fcpl); - H5Fclose(fid); - }H5E_END_TRY; + { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(my_dcpl); + H5Pclose(fcpl); + H5Fclose(fid); + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- @@ -1311,30 +1286,33 @@ static int test_rank2(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis *------------------------------------------------------------------------- */ -static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t disable_edge_filters, hbool_t set_istore_k) { - - hid_t fid = -1; - hid_t did = -1; - hid_t sid = -1; - hid_t my_dcpl = -1; - hid_t fcpl; - hsize_t dims_o[RANK3] = { DIM0, DIM1, DIM2 }; /* original dimensions */ - hsize_t dims_s[RANK3] = { DIMS0, DIMS1, DIMS2 }; /* shrinking dimensions */ - hsize_t dims_e[RANK3] = { DIME0, DIME1, DIME2 }; /* extended dimensions */ - hsize_t dims_c[RANK3] = { 2, 2, 2 }; /* chunk dimensions */ - hsize_t dims_r[RANK3]; /* read dimensions */ - hsize_t maxdims[RANK3] = { H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED }; - int buf_o[DIM0][DIM1][DIM2]; - int buf_s[DIMS0][DIMS1][DIMS2]; - int buf_e[DIME0][DIME1][DIME2]; - int buf_r[DIM0][DIM1][DIM2]; - int i, j, k; - int comp_value; - char filename[NAME_BUF_SIZE]; +static int +test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t disable_edge_filters, hbool_t set_istore_k) +{ + + hid_t fid = -1; + hid_t did = -1; + hid_t sid = -1; + hid_t my_dcpl = -1; + hid_t fcpl; + hsize_t dims_o[RANK3] = {DIM0, DIM1, DIM2}; /* original dimensions */ + hsize_t dims_s[RANK3] = {DIMS0, DIMS1, DIMS2}; /* shrinking dimensions */ + hsize_t dims_e[RANK3] = {DIME0, DIME1, DIME2}; /* extended dimensions */ + hsize_t dims_c[RANK3] = {2, 2, 2}; /* chunk dimensions */ + hsize_t dims_r[RANK3]; /* read dimensions */ + hsize_t maxdims[RANK3] = {H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED}; + int buf_o[DIM0][DIM1][DIM2]; + int buf_s[DIMS0][DIMS1][DIMS2]; + int buf_e[DIME0][DIME1][DIME2]; + int buf_r[DIM0][DIM1][DIM2]; + int i, j, k; + int comp_value; + char filename[NAME_BUF_SIZE]; if (do_fill_value) { comp_value = FILL_VALUE; - } else { + } + else { comp_value = 0; } @@ -1356,7 +1334,6 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if (H5Pset_istore_k(fcpl, ISTORE_IK) < 0) { TEST_ERROR } - } /* create a new file */ h5_fixname(FILENAME[2], fapl, filename, sizeof filename); @@ -1385,12 +1362,12 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if (H5Pset_chunk_opts(my_dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR - /*------------------------------------------------------------------------- - * create, write array - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * create, write array + *------------------------------------------------------------------------- + */ - /* create a dataset */ + /* create a dataset */ if ((did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, my_dcpl, H5P_DEFAULT)) < 0) { TEST_ERROR } @@ -1400,17 +1377,16 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis TEST_ERROR } -#if defined (H5_SET_EXTENT_DEBUG3) +#if defined(H5_SET_EXTENT_DEBUG3) HDprintf("\n"); - for (i = 0; i < (int)dims_o[0]; i++ ) { - for (j = 0; j < (int)dims_o[1]; j++ ) { - for( k = 0; k < (int)dims_o[2]; k++ ) { + for (i = 0; i < (int)dims_o[0]; i++) { + for (j = 0; j < (int)dims_o[1]; j++) { + for (k = 0; k < (int)dims_o[2]; k++) { HDprintf("%d ", buf_o[i][j][k]); } HDprintf("[%d] ", j); } HDprintf("\n"); - } HDprintf("\n"); #endif @@ -1420,10 +1396,10 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * set new dimensions for the array; expand it - * - *------------------------------------------------------------------------- - */ + * set new dimensions for the array; expand it + * + *------------------------------------------------------------------------- + */ /* set new dimensions for the array. */ if (H5Dset_extent(did, dims_e) < 0) { @@ -1454,32 +1430,32 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_e) < 0) TEST_ERROR -#if defined (H5_SET_EXTENT_DEBUG3) +#if defined(H5_SET_EXTENT_DEBUG3) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { - for( k = 0; k < (int)dims_r[2]; k++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { + for (k = 0; k < (int)dims_r[2]; k++) { HDprintf("%d ", buf_e[i][j][k]); } HDprintf("[%d] ", j); } HDprintf("\n"); - } HDprintf("\n"); #endif - /* compare the read array with the expanded array */ - for (i = 0; i < (int) dims_r[0]; i++) { - for (j = 0; j < (int) dims_r[1]; j++) { - for (k = 0; k < (int) dims_r[2]; k++) { + /* compare the read array with the expanded array */ + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { + for (k = 0; k < (int)dims_r[2]; k++) { if (i >= DIM0 || j >= DIM1 || k >= DIM2) { if (buf_e[i][j][k] != comp_value) { HDprintf("buf_e[%d][%d][%d] = %d\n", i, j, k, buf_e[i][j][k]); HDprintf("value = %d\n", comp_value); TEST_ERROR } - } else { + } + else { if (buf_e[i][j][k] != buf_o[i][j][k]) TEST_ERROR } @@ -1488,9 +1464,9 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * shrink - *------------------------------------------------------------------------- - */ + * shrink + *------------------------------------------------------------------------- + */ /* set new dimensions for the array. */ if (H5Dset_extent(did, dims_s) < 0) { @@ -1534,38 +1510,36 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if ((did = H5Dopen2(fid, "dset1", H5P_DEFAULT)) < 0) { TEST_ERROR } - } /*------------------------------------------------------------------------- - * read - *------------------------------------------------------------------------- - */ + * read + *------------------------------------------------------------------------- + */ /* read */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s) < 0) { TEST_ERROR } -#if defined (H5_SET_EXTENT_DEBUG3) +#if defined(H5_SET_EXTENT_DEBUG3) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { - for( k = 0; k < (int)dims_r[2]; k++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { + for (k = 0; k < (int)dims_r[2]; k++) { HDprintf("%d ", buf_s[i][j][k]); } - HDprintf("[%d] ", j); + HDprintf("[%d] ", j); } HDprintf("\n"); - } HDprintf("\n"); #endif /* compare the read array with the shrinked array */ - for (i = 0; i < (int) dims_r[0]; i++) { - for (j = 0; j < (int) dims_r[1]; j++) { - for (k = 0; k < (int) dims_r[2]; k++) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { + for (k = 0; k < (int)dims_r[2]; k++) { if (buf_s[i][j][k] != buf_o[i][j][k]) { HDprintf("buf_s[%d][%d][%d] = %d\n", i, j, k, buf_s[i][j][k]); HDprintf("buf_o[%d][%d][%d] = %d\n", i, j, k, buf_o[i][j][k]); @@ -1576,9 +1550,9 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * set new dimensions for the array; expand it back to original size - *------------------------------------------------------------------------- - */ + * set new dimensions for the array; expand it back to original size + *------------------------------------------------------------------------- + */ /* set new dimensions for the array */ if (H5Dset_extent(did, dims_o) < 0) { @@ -1609,33 +1583,33 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0) TEST_ERROR -#if defined (H5_SET_EXTENT_DEBUG3) +#if defined(H5_SET_EXTENT_DEBUG3) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { - for( k = 0; k < (int)dims_r[2]; k++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { + for (k = 0; k < (int)dims_r[2]; k++) { HDprintf("%d ", buf_r[i][j][k]); } - HDprintf("[%d] ", j); + HDprintf("[%d] ", j); } HDprintf("\n"); - } HDprintf("\n"); #endif - /* compare the read array with the original array */ - for (i = 0; i < (int) dims_r[0]; i++) { - for (j = 0; j < (int) dims_r[1]; j++) { - for (k = 0; k < (int) dims_r[2]; k++) { + /* compare the read array with the original array */ + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { + for (k = 0; k < (int)dims_r[2]; k++) { if (i >= DIMS0 || j >= DIMS1 || k >= DIMS2) { if (buf_r[i][j][k] != comp_value) { HDprintf("buf_r[%d][%d][%d] = %d\n", i, j, k, buf_r[i][j][k]); HDprintf("value = %d\n", comp_value); TEST_ERROR } - } else { + } + else { if (buf_r[i][j][k] != buf_o[i][j][k]) TEST_ERROR } @@ -1644,10 +1618,10 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * shrink to 0 - * - *------------------------------------------------------------------------- - */ + * shrink to 0 + * + *------------------------------------------------------------------------- + */ dims_s[0] = 0; dims_s[1] = 0; @@ -1679,18 +1653,18 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * close dataset - *------------------------------------------------------------------------- - */ + * close dataset + *------------------------------------------------------------------------- + */ if (H5Dclose(did) < 0) { TEST_ERROR } /*------------------------------------------------------------------------- - * test a dataset with non initialized chunks - *------------------------------------------------------------------------- - */ + * test a dataset with non initialized chunks + *------------------------------------------------------------------------- + */ if ((sid = H5Screate_simple(RANK3, dims_o, maxdims)) < 0) { TEST_ERROR @@ -1714,9 +1688,9 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis } /*------------------------------------------------------------------------- - * close property list - *------------------------------------------------------------------------- - */ + * close property list + *------------------------------------------------------------------------- + */ if (H5Pclose(my_dcpl) < 0) { TEST_ERROR @@ -1728,49 +1702,51 @@ static int test_rank3(hid_t fapl, hid_t dcpl, hbool_t do_fill_value, hbool_t dis return 0; - error: +error: H5E_BEGIN_TRY - { - H5Dclose(did); - H5Sclose(sid); - H5Pclose(my_dcpl); - H5Pclose(fcpl); - H5Fclose(fid); - }H5E_END_TRY; + { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(my_dcpl); + H5Pclose(fcpl); + H5Fclose(fid); + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- * test usage with external storage *------------------------------------------------------------------------- */ -static int test_external(hid_t fapl) { - - hid_t fid = -1; - hid_t did = -1; - hid_t sid = -1; - hid_t dcpl = -1; - hsize_t dims_o[RANK2] = { DIM0, DIM1 }; /* original dimensions */ - hsize_t dims_s[RANK2] = { DIMS0, DIMS1 }; /* shrinking dimensions */ - hsize_t dims_e[RANK2] = { DIME0, DIM1 }; /* extended dimensions, dimension 1 is the original */ - hsize_t dims_r[RANK2]; /* read dimensions */ - hsize_t maxdims[RANK2] = { DIME0, DIM1 }; /* only the first dimension can be extendible */ - int buf_o[DIM0][DIM1]; /* original buffer, for writing */ - int buf_s[DIMS0][DIMS1]; /* shrinked buffer, for reading */ - int buf_e[DIME0][DIM1]; /* extended buffer, for writing, dimension 1 is the original */ - int buf_ro[DIM0][DIM1]; /* original buffer for reading */ - int i, j; - int comp_value = 0; - char filename[NAME_BUF_SIZE]; +static int +test_external(hid_t fapl) +{ + + hid_t fid = -1; + hid_t did = -1; + hid_t sid = -1; + hid_t dcpl = -1; + hsize_t dims_o[RANK2] = {DIM0, DIM1}; /* original dimensions */ + hsize_t dims_s[RANK2] = {DIMS0, DIMS1}; /* shrinking dimensions */ + hsize_t dims_e[RANK2] = {DIME0, DIM1}; /* extended dimensions, dimension 1 is the original */ + hsize_t dims_r[RANK2]; /* read dimensions */ + hsize_t maxdims[RANK2] = {DIME0, DIM1}; /* only the first dimension can be extendible */ + int buf_o[DIM0][DIM1]; /* original buffer, for writing */ + int buf_s[DIMS0][DIMS1]; /* shrinked buffer, for reading */ + int buf_e[DIME0][DIM1]; /* extended buffer, for writing, dimension 1 is the original */ + int buf_ro[DIM0][DIM1]; /* original buffer for reading */ + int i, j; + int comp_value = 0; + char filename[NAME_BUF_SIZE]; hsize_t size; /* number of bytes reserved in the file for the data */ hsize_t max_size[2]; max_size[0] = dims_e[0]; max_size[1] = dims_e[1]; - size = max_size[0] * max_size[1] * sizeof(int) / 2; + size = max_size[0] * max_size[1] * sizeof(int) / 2; for (i = 0; i < DIM0; i++) { for (j = 0; j < DIM1; j++) { @@ -1785,39 +1761,38 @@ static int test_external(hid_t fapl) { if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - /* modify dataset creation properties */ + /* modify dataset creation properties */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if (H5Pset_external(dcpl, EXT_FILE_NAME1, (off_t) 0, size) < 0) + if (H5Pset_external(dcpl, EXT_FILE_NAME1, (off_t)0, size) < 0) FAIL_STACK_ERROR - if (H5Pset_external(dcpl, EXT_FILE_NAME2, (off_t) 0, size) < 0) + if (H5Pset_external(dcpl, EXT_FILE_NAME2, (off_t)0, size) < 0) FAIL_STACK_ERROR - { - - char name[256]; /*external file name */ - off_t file_offset; /*external file offset */ - hsize_t file_size; /*sizeof external file segment */ + { - if (H5Pget_external(dcpl, 0, sizeof(name), name, &file_offset, &file_size) < 0) - FAIL_STACK_ERROR + char name[256]; /*external file name */ + off_t file_offset; /*external file offset */ + hsize_t file_size; /*sizeof external file segment */ - } + if (H5Pget_external(dcpl, 0, sizeof(name), name, &file_offset, &file_size) < 0) + FAIL_STACK_ERROR + } /*------------------------------------------------------------------------- - * Write an array AxB. These are the dimensions for creating the dataset - * - * original data is - * - * 2 2 2 2 - * 2 2 2 2 - * 2 2 2 2 - * 2 2 2 2 - * - *------------------------------------------------------------------------- - */ + * Write an array AxB. These are the dimensions for creating the dataset + * + * original data is + * + * 2 2 2 2 + * 2 2 2 2 + * 2 2 2 2 + * 2 2 2 2 + * + *------------------------------------------------------------------------- + */ /* create the data space with unlimited dimensions. */ if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0) @@ -1829,61 +1804,61 @@ static int test_external(hid_t fapl) { if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - /*------------------------------------------------------------------------- - * read - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * read + *------------------------------------------------------------------------- + */ - /* read */ + /* read */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_ro) < 0) FAIL_STACK_ERROR -#if defined (H5_SET_EXTENT_DEBUG) +#if defined(H5_SET_EXTENT_DEBUG) HDprintf("\n"); - for (i = 0; i < (int)dims_o[0]; i++ ) { - for (j = 0; j < (int)dims_o[1]; j++ ) { + for (i = 0; i < (int)dims_o[0]; i++) { + for (j = 0; j < (int)dims_o[1]; j++) { HDprintf("%d ", buf_ro[i][j]); } HDprintf("\n"); } #endif - /*------------------------------------------------------------------------- - * expand - *------------------------------------------------------------------------- - */ - - /*------------------------------------------------------------------------- - * set new dimensions for the array; expand it - * data is now, extended space was initialized with default value - * - * 2 2 2 2 - * 2 2 2 2 - * 2 2 2 2 - * 2 2 2 2 - * 0 0 0 0 - * 0 0 0 0 - * 0 0 0 0 - * - *------------------------------------------------------------------------- - */ - - /* set new dimensions for the array. */ + /*------------------------------------------------------------------------- + * expand + *------------------------------------------------------------------------- + */ + + /*------------------------------------------------------------------------- + * set new dimensions for the array; expand it + * data is now, extended space was initialized with default value + * + * 2 2 2 2 + * 2 2 2 2 + * 2 2 2 2 + * 2 2 2 2 + * 0 0 0 0 + * 0 0 0 0 + * 0 0 0 0 + * + *------------------------------------------------------------------------- + */ + + /* set new dimensions for the array. */ if (H5Dset_extent(did, dims_e) < 0) FAIL_STACK_ERROR - /* get the space */ + /* get the space */ if ((sid = H5Dget_space(did)) < 0) FAIL_STACK_ERROR - /* get dimensions */ + /* get dimensions */ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) FAIL_STACK_ERROR if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - /* check dimensions */ + /* check dimensions */ for (i = 0; i < RANK2; i++) { if (dims_r[i] != dims_e[i]) TEST_ERROR @@ -1893,26 +1868,27 @@ static int test_external(hid_t fapl) { if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_e) < 0) FAIL_STACK_ERROR -#if defined (H5_SET_EXTENT_DEBUG) +#if defined(H5_SET_EXTENT_DEBUG) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { HDprintf("%d ", buf_e[i][j]); } HDprintf("\n"); } #endif - /* compare the read array with the expanded array */ - for (i = 0; i < (int) dims_r[0]; i++) { - for (j = 0; j < (int) dims_r[1]; j++) { + /* compare the read array with the expanded array */ + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { if (i >= DIM0 || j >= DIM1) { if (buf_e[i][j] != comp_value) { HDprintf("buf_e[%d][%d] = %d\n", i, j, buf_e[i][j]); HDprintf("value = %d\n", comp_value); TEST_ERROR } - } else { + } + else { if (buf_e[i][j] != buf_o[i][j]) TEST_ERROR } @@ -1920,59 +1896,59 @@ static int test_external(hid_t fapl) { } /*------------------------------------------------------------------------- - * shrink - * - * data is now - * - * 2 2 - * 2 2 - * - *------------------------------------------------------------------------- - */ + * shrink + * + * data is now + * + * 2 2 + * 2 2 + * + *------------------------------------------------------------------------- + */ /* set new dimensions for the array. */ if (H5Dset_extent(did, dims_s) < 0) FAIL_STACK_ERROR - /* get the space */ + /* get the space */ if ((sid = H5Dget_space(did)) < 0) FAIL_STACK_ERROR - /* get dimensions */ + /* get dimensions */ if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) FAIL_STACK_ERROR if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - /* check dimensions */ + /* check dimensions */ for (i = 0; i < RANK2; i++) { if (dims_r[i] != dims_s[i]) TEST_ERROR } /*------------------------------------------------------------------------- - * read - *------------------------------------------------------------------------- - */ + * read + *------------------------------------------------------------------------- + */ /* read */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_s) < 0) FAIL_STACK_ERROR -#if defined (H5_SET_EXTENT_DEBUG) +#if defined(H5_SET_EXTENT_DEBUG) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { HDprintf("%d ", buf_s[i][j]); } HDprintf("\n"); } #endif - /* compare the read array with the shrinked array */ - for (i = 0; i < (int) dims_r[0]; i++) { - for (j = 0; j < (int) dims_r[1]; j++) { + /* compare the read array with the shrinked array */ + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { if (buf_s[i][j] != buf_o[i][j]) { HDprintf("buf_s[%d][%d] = %d\n", i, j, buf_s[i][j]); HDprintf("buf_o[%d][%d] = %d\n", i, j, buf_o[i][j]); @@ -1982,27 +1958,27 @@ static int test_external(hid_t fapl) { } /*------------------------------------------------------------------------- - * negative test - * try to extend dimension above maximum - *------------------------------------------------------------------------- - */ + * negative test + * try to extend dimension above maximum + *------------------------------------------------------------------------- + */ dims_e[1] = DIME1; H5E_BEGIN_TRY - { - - /* set new dimensions for the array. */ - if (H5Dset_extent(did, dims_e) == SUCCEED) { - TEST_ERROR - } + { - }H5E_END_TRY; + /* set new dimensions for the array. */ + if (H5Dset_extent(did, dims_e) == SUCCEED) { + TEST_ERROR + } + } + H5E_END_TRY; /*------------------------------------------------------------------------- - * close property list - *------------------------------------------------------------------------- - */ + * close property list + *------------------------------------------------------------------------- + */ if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR @@ -2017,15 +1993,16 @@ static int test_external(hid_t fapl) { return 0; - error: +error: H5E_BEGIN_TRY - { - H5Dclose(did); - H5Sclose(sid); - H5Pclose(dcpl); - H5Fclose(fid); - }H5E_END_TRY; + { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl); + H5Fclose(fid); + } + H5E_END_TRY; return -1; } @@ -2033,21 +2010,23 @@ static int test_external(hid_t fapl) { * test usage with layouts compact and contiguous *------------------------------------------------------------------------- */ -static int test_layouts(H5D_layout_t layout, hid_t fapl) { - - hid_t fid = -1; - hid_t did = -1; - hid_t sid = -1; - hid_t dcpl = -1; - herr_t ret; - hsize_t dims_o[RANK2] = { DIM0, DIM1 }; /* original dimensions */ - hsize_t dims_s[RANK2] = { DIMS0, DIMS1 }; /* shrinking dimensions */ - hsize_t dims_e[RANK2] = { DIME0, DIME1 }; /* extended dimensions */ - hsize_t dims_r[RANK2]; /* read dimensions */ - int buf_o[DIM0][DIM1]; - int buf_r[DIM0][DIM1]; - int i, j; - char filename[NAME_BUF_SIZE]; +static int +test_layouts(H5D_layout_t layout, hid_t fapl) +{ + + hid_t fid = -1; + hid_t did = -1; + hid_t sid = -1; + hid_t dcpl = -1; + herr_t ret; + hsize_t dims_o[RANK2] = {DIM0, DIM1}; /* original dimensions */ + hsize_t dims_s[RANK2] = {DIMS0, DIMS1}; /* shrinking dimensions */ + hsize_t dims_e[RANK2] = {DIME0, DIME1}; /* extended dimensions */ + hsize_t dims_r[RANK2]; /* read dimensions */ + int buf_o[DIM0][DIM1]; + int buf_r[DIM0][DIM1]; + int i, j; + char filename[NAME_BUF_SIZE]; for (i = 0; i < DIM0; i++) { for (j = 0; j < DIM1; j++) { @@ -2085,10 +2064,10 @@ static int test_layouts(H5D_layout_t layout, hid_t fapl) { TEST_ERROR } -#if defined (H5_SET_EXTENT_DEBUG4) +#if defined(H5_SET_EXTENT_DEBUG4) HDprintf("\n"); - for (i = 0; i < (int)dims_o[0]; i++ ) { - for (j = 0; j < (int)dims_o[1]; j++ ) { + for (i = 0; i < (int)dims_o[0]; i++) { + for (j = 0; j < (int)dims_o[1]; j++) { HDprintf("%d ", buf_o[i][j]); } HDprintf("\n"); @@ -2100,22 +2079,22 @@ static int test_layouts(H5D_layout_t layout, hid_t fapl) { } /*------------------------------------------------------------------------- - * negative test - * try to extend dimension - *------------------------------------------------------------------------- - */ + * negative test + * try to extend dimension + *------------------------------------------------------------------------- + */ H5E_BEGIN_TRY - { - - ret = H5Dset_extent(did, dims_e); + { - }H5E_END_TRY; + ret = H5Dset_extent(did, dims_e); + } + H5E_END_TRY; if (ret >= 0) TEST_ERROR - /* get the space */ + /* get the space */ if ((sid = H5Dget_space(did)) < 0) { TEST_ERROR } @@ -2139,33 +2118,33 @@ static int test_layouts(H5D_layout_t layout, hid_t fapl) { if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0) TEST_ERROR -#if defined (H5_SET_EXTENT_DEBUG4) +#if defined(H5_SET_EXTENT_DEBUG4) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { HDprintf("%d ", buf_r[i][j]); } HDprintf("\n"); } #endif - /*------------------------------------------------------------------------- - * negative test - * try to shrink dimension - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * negative test + * try to shrink dimension + *------------------------------------------------------------------------- + */ H5E_BEGIN_TRY - { - - ret = H5Dset_extent(did, dims_s); + { - }H5E_END_TRY; + ret = H5Dset_extent(did, dims_s); + } + H5E_END_TRY; if (ret >= 0) TEST_ERROR - /* get the space */ + /* get the space */ if ((sid = H5Dget_space(did)) < 0) { TEST_ERROR } @@ -2186,19 +2165,19 @@ static int test_layouts(H5D_layout_t layout, hid_t fapl) { } /*------------------------------------------------------------------------- - * read - *------------------------------------------------------------------------- - */ + * read + *------------------------------------------------------------------------- + */ /* read */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0) { TEST_ERROR } -#if defined (H5_SET_EXTENT_DEBUG4) +#if defined(H5_SET_EXTENT_DEBUG4) HDprintf("\n"); - for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) { + for (i = 0; i < (int)dims_r[0]; i++) { + for (j = 0; j < (int)dims_r[1]; j++) { HDprintf("%d ", buf_r[i][j]); } HDprintf("\n"); @@ -2206,9 +2185,9 @@ static int test_layouts(H5D_layout_t layout, hid_t fapl) { #endif /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + * close + *------------------------------------------------------------------------- + */ if (H5Dclose(did) < 0) { TEST_ERROR @@ -2224,20 +2203,19 @@ static int test_layouts(H5D_layout_t layout, hid_t fapl) { return 0; - error: +error: H5E_BEGIN_TRY - { - H5Dclose(did); - H5Sclose(sid); - H5Pclose(dcpl); - H5Fclose(fid); - }H5E_END_TRY; + { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl); + H5Fclose(fid); + } + H5E_END_TRY; return -1; - } - /*------------------------------------------------------------------------- * Function: test_random_rank4 * @@ -2253,31 +2231,31 @@ static int test_layouts(H5D_layout_t layout, hid_t fapl) { * *------------------------------------------------------------------------- */ -static int test_random_rank4( hid_t fapl, hid_t dcpl, hbool_t do_fillvalue, - hbool_t disable_edge_filters, hbool_t do_sparse, - rank4_index_t index_type ) +static int +test_random_rank4(hid_t fapl, hid_t dcpl, hbool_t do_fillvalue, hbool_t disable_edge_filters, + hbool_t do_sparse, rank4_index_t index_type) { - hid_t file = -1; - hid_t dset = -1; - hid_t fspace = -1; - hid_t mspace = -1; - hid_t my_dcpl = -1; - hsize_t dims[4] = {10, 10, 10, 10}; /* Dataset's dimensions */ - hsize_t max_dims[4] = {10, 10, 10, 10}; /* Maximum dimensions */ - hsize_t old_dims[4]; /* Old dataset dimensions */ - hsize_t min_unwritten_dims[4]; /* Minimum dimensions since last write */ - hsize_t *valid_dims = old_dims; /* Dimensions of region still containing written data */ - hsize_t cdims[4]; /* Chunk dimensions */ - const hsize_t mdims[4] = {10, 10, 10, 10}; /* Memory buffer dimensions */ - const hsize_t start[4] = {0, 0, 0, 0}; /* Start for hyperslabe operations on memory */ - static int rbuf[10][10][10][10]; /* Read buffer */ - static int wbuf[10][10][10][10]; /* Write buffer */ - static hsize_t dim_log[RAND4_NITER+1][4]; /* Log of dataset dimensions */ - hbool_t zero_dim = FALSE; /* Whether a dimension is 0 */ - hbool_t writing = TRUE; /* Whether we're writing to the dset */ - unsigned scalar_iter; /* Iteration to shrink dset to 1x1x1x1 */ - volatile unsigned i, j, k, l, m; /* Local indices */ - char filename[NAME_BUF_SIZE]; + hid_t file = -1; + hid_t dset = -1; + hid_t fspace = -1; + hid_t mspace = -1; + hid_t my_dcpl = -1; + hsize_t dims[4] = {10, 10, 10, 10}; /* Dataset's dimensions */ + hsize_t max_dims[4] = {10, 10, 10, 10}; /* Maximum dimensions */ + hsize_t old_dims[4]; /* Old dataset dimensions */ + hsize_t min_unwritten_dims[4]; /* Minimum dimensions since last write */ + hsize_t * valid_dims = old_dims; /* Dimensions of region still containing written data */ + hsize_t cdims[4]; /* Chunk dimensions */ + const hsize_t mdims[4] = {10, 10, 10, 10}; /* Memory buffer dimensions */ + const hsize_t start[4] = {0, 0, 0, 0}; /* Start for hyperslabe operations on memory */ + static int rbuf[10][10][10][10]; /* Read buffer */ + static int wbuf[10][10][10][10]; /* Write buffer */ + static hsize_t dim_log[RAND4_NITER + 1][4]; /* Log of dataset dimensions */ + hbool_t zero_dim = FALSE; /* Whether a dimension is 0 */ + hbool_t writing = TRUE; /* Whether we're writing to the dset */ + unsigned scalar_iter; /* Iteration to shrink dset to 1x1x1x1 */ + volatile unsigned i, j, k, l, m; /* Local indices */ + char filename[NAME_BUF_SIZE]; /* create a new file */ h5_fixname(FILENAME[4], fapl, filename, sizeof filename); @@ -2285,14 +2263,14 @@ static int test_random_rank4( hid_t fapl, hid_t dcpl, hbool_t do_fillvalue, TEST_ERROR /* Set maximum dimensions as appropriate for index type */ - if(index_type == RANK4_INDEX_BTREE) - for(i=0; i<4; i++) + if (index_type == RANK4_INDEX_BTREE) + for (i = 0; i < 4; i++) max_dims[i] = H5S_UNLIMITED; - else if(index_type == RANK4_INDEX_EARRAY) + else if (index_type == RANK4_INDEX_EARRAY) max_dims[1] = H5S_UNLIMITED; /* Generate random chunk dimensions, 2-4 */ - for(i=0; i<4; i++) + for (i = 0; i < 4; i++) cdims[i] = (hsize_t)((HDrandom() % 3) + 2); /* Pick iteration to shrink dataset to 1x1x1x1 */ @@ -2300,142 +2278,136 @@ static int test_random_rank4( hid_t fapl, hid_t dcpl, hbool_t do_fillvalue, /* Generate initial dataset size, 1-10, unless using fixed array index or * scalar_iter is 0 */ - for(i=0; i<4; i++) { - dims[i] = (hsize_t)(index_type != RANK4_INDEX_FARRAY - ? (0 == scalar_iter ? 1 : ((HDrandom() % 10) + 1)) : 10); + for (i = 0; i < 4; i++) { + dims[i] = (hsize_t)( + index_type != RANK4_INDEX_FARRAY ? (0 == scalar_iter ? 1 : ((HDrandom() % 10) + 1)) : 10); dim_log[0][i] = dims[i]; } /* end for */ /* Create dataset */ - if((fspace = H5Screate_simple(4, dims, max_dims)) < 0) + if ((fspace = H5Screate_simple(4, dims, max_dims)) < 0) TEST_ERROR - if((my_dcpl = H5Pcopy(dcpl)) < 0) + if ((my_dcpl = H5Pcopy(dcpl)) < 0) TEST_ERROR - if(H5Pset_chunk(my_dcpl, 4, cdims) < 0) + if (H5Pset_chunk(my_dcpl, 4, cdims) < 0) TEST_ERROR - if(disable_edge_filters) - if(H5Pset_chunk_opts(my_dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + if (disable_edge_filters) + if (H5Pset_chunk_opts(my_dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) TEST_ERROR - if((dset = H5Dcreate2(file, "dset", H5T_NATIVE_INT, fspace, H5P_DEFAULT, - my_dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "dset", H5T_NATIVE_INT, fspace, H5P_DEFAULT, my_dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Sclose(fspace) < 0) + if (H5Sclose(fspace) < 0) TEST_ERROR /* Create memory space, and set initial selection */ - if((mspace = H5Screate_simple(4, mdims, NULL)) < 0) + if ((mspace = H5Screate_simple(4, mdims, NULL)) < 0) TEST_ERROR - if(H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, NULL, dims, NULL) - < 0) + if (H5Sselect_hyperslab(mspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Main loop */ - for(i=0; i= valid_dims[0] || k >= valid_dims[1] - || l >= valid_dims[2] - || m >= valid_dims[3]) { - if(FILL_VALUE != rbuf[j][k][l][m]) - RAND4_FAIL_DUMP(i+2, (int)j, (int)k, (int)l, (int)m) + if (do_fillvalue) { + for (j = 0; j < dims[0]; j++) + for (k = 0; k < dims[1]; k++) + for (l = 0; l < dims[2]; l++) + for (m = 0; m < dims[3]; m++) + if (j >= valid_dims[0] || k >= valid_dims[1] || l >= valid_dims[2] || + m >= valid_dims[3]) { + if (FILL_VALUE != rbuf[j][k][l][m]) + RAND4_FAIL_DUMP(i + 2, (int)j, (int)k, (int)l, (int)m) } /* end if */ - else - if(wbuf[j][k][l][m] != rbuf[j][k][l][m]) - RAND4_FAIL_DUMP(i+2, (int)j, (int)k, (int)l, (int)m) + else if (wbuf[j][k][l][m] != rbuf[j][k][l][m]) + RAND4_FAIL_DUMP(i + 2, (int)j, (int)k, (int)l, (int)m) } /* end if */ else { - for(j=0; j= valid_dims[0] || k >= valid_dims[1] - || l >= valid_dims[2] - || m >= valid_dims[3]) { - if(((int *)fill_value.p)[0] - != ((int *)rbuf[j][k][l][m].p)[0] - || ((int *)fill_value.p)[1] - != ((int *)rbuf[j][k][l][m].p)[1]) - RAND4_FAIL_DUMP(i+2, (int)j, (int)k, (int)l, (int)m) + if (do_fillvalue) { + for (j = 0; j < dims[0]; j++) + for (k = 0; k < dims[1]; k++) + for (l = 0; l < dims[2]; l++) + for (m = 0; m < dims[3]; m++) + if (j >= valid_dims[0] || k >= valid_dims[1] || l >= valid_dims[2] || + m >= valid_dims[3]) { + if (((int *)fill_value.p)[0] != ((int *)rbuf[j][k][l][m].p)[0] || + ((int *)fill_value.p)[1] != ((int *)rbuf[j][k][l][m].p)[1]) + RAND4_FAIL_DUMP(i + 2, (int)j, (int)k, (int)l, (int)m) } /* end if */ - else - if(((int *)wbuf[j][k][l][m].p)[0] - != ((int *)rbuf[j][k][l][m].p)[0] - || ((int *)wbuf[j][k][l][m].p)[1] - != ((int *)rbuf[j][k][l][m].p)[1]) - RAND4_FAIL_DUMP(i+2, (int)j, (int)k, (int)l, (int)m) + else if (((int *)wbuf[j][k][l][m].p)[0] != ((int *)rbuf[j][k][l][m].p)[0] || + ((int *)wbuf[j][k][l][m].p)[1] != ((int *)rbuf[j][k][l][m].p)[1]) + RAND4_FAIL_DUMP(i + 2, (int)j, (int)k, (int)l, (int)m) } /* end if */ else { - for(j=0; j=0) + for (i = 0; i < ndim_sets; i++) + HDprintf(" Iteration %-3u: ( %2u, %2u, %2u, %2u )\n", i, (unsigned)dim_log[i][0], + (unsigned)dim_log[i][1], (unsigned)dim_log[i][2], (unsigned)dim_log[i][3]); + if (j >= 0) HDprintf(" First incorrect value read: ( %d, %d, %d, %d )\n", j, k, l, m); return; } /* end test_random_rank4_dump */ - diff --git a/test/space_overflow.c b/test/space_overflow.c index 15be9ba..c712ab6 100644 --- a/test/space_overflow.c +++ b/test/space_overflow.c @@ -26,7 +26,6 @@ */ #include "hdf5.h" - /*------------------------------------------------------------------------- * Function: main * @@ -46,20 +45,20 @@ int main(void) { - hid_t file, space, dset; - hsize_t cur_dim[H5S_MAX_RANK]; - int i; + hid_t file, space, dset; + hsize_t cur_dim[H5S_MAX_RANK]; + int i; file = H5Fcreate("th5s.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(file < 0) + if (file < 0) printf("file<0!\n"); - for(i = 0; i < H5S_MAX_RANK; i++) + for (i = 0; i < H5S_MAX_RANK; i++) cur_dim[i] = 1; space = H5Screate_simple(H5S_MAX_RANK, cur_dim, NULL); - if(space < 0) + if (space < 0) printf("space<0!\n"); dset = H5Dcreate2(file, "dset", H5T_NATIVE_UCHAR, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset < 0) + if (dset < 0) printf("dset<0!\n"); H5Sclose(space); H5Dclose(dset); diff --git a/test/stab.c b/test/stab.c index 215d748..6306ebc 100644 --- a/test/stab.c +++ b/test/stab.c @@ -16,70 +16,66 @@ * Tuesday, November 24, 1998 */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ /* Define this macro to indicate that the testing APIs should be available */ #define H5G_TESTING #include "h5test.h" -#include "H5Gpkg.h" /* Groups */ +#include "H5Gpkg.h" /* Groups */ -const char *FILENAME[] = { - "stab", - NULL -}; +const char *FILENAME[] = {"stab", NULL}; -#define NAME_BUF_SIZE 1024 +#define NAME_BUF_SIZE 1024 /* Definitions for 'long' test */ -#define LONG_NAME_LEN 40960 +#define LONG_NAME_LEN 40960 /* Definitions for 'large' test */ -#define LARGE_NOBJS 5000 +#define LARGE_NOBJS 5000 /* Definitions for 'lifecycle' test */ -#define LIFECYCLE_TOP_GROUP "top" -#define LIFECYCLE_BOTTOM_GROUP "bottom %u" -#define LIFECYCLE_LOCAL_HEAP_SIZE_HINT 256 -#define LIFECYCLE_MAX_COMPACT 4 -#define LIFECYCLE_MIN_DENSE 3 -#define LIFECYCLE_EST_NUM_ENTRIES 4 -#define LIFECYCLE_EST_NAME_LEN 8 +#define LIFECYCLE_TOP_GROUP "top" +#define LIFECYCLE_BOTTOM_GROUP "bottom %u" +#define LIFECYCLE_LOCAL_HEAP_SIZE_HINT 256 +#define LIFECYCLE_MAX_COMPACT 4 +#define LIFECYCLE_MIN_DENSE 3 +#define LIFECYCLE_EST_NUM_ENTRIES 4 +#define LIFECYCLE_EST_NAME_LEN 8 /* Definitions for 'long_compact' test */ -#define LONG_COMPACT_LENGTH ((64 * 1024) + 1024) +#define LONG_COMPACT_LENGTH ((64 * 1024) + 1024) /* Definitions for 'read_old' test */ -#define READ_OLD_NGROUPS 100 +#define READ_OLD_NGROUPS 100 /* The group_old.h5 is generated from gen_old_fill.c in HDF5 'test' directory * for version 1.6. To get this data file, simply compile gen_old_group.c with * the HDF5 library in that branch and run it. */ -#define FILE_OLD_GROUPS "group_old.h5" +#define FILE_OLD_GROUPS "group_old.h5" #define FILE_OLD_GROUPS_COPY "group_old_copy.h5" /* Definitions for 'no_compact' test */ -#define NO_COMPACT_TOP_GROUP "top" -#define NO_COMPACT_BOTTOM_GROUP "bottom %u" -#define NO_COMPACT_MAX_COMPACT 0 -#define NO_COMPACT_MIN_DENSE 0 +#define NO_COMPACT_TOP_GROUP "top" +#define NO_COMPACT_BOTTOM_GROUP "bottom %u" +#define NO_COMPACT_MAX_COMPACT 0 +#define NO_COMPACT_MIN_DENSE 0 /* Definitions for 'gcpl_on_root' test */ -#define GCPL_ON_ROOT_MIDDLE_GROUP "/middle" -#define GCPL_ON_ROOT_BOTTOM_GROUP "/middle/bottom" -#define GCPL_ON_ROOT_MAX_COMPACT 4 -#define GCPL_ON_ROOT_MIN_DENSE 2 +#define GCPL_ON_ROOT_MIDDLE_GROUP "/middle" +#define GCPL_ON_ROOT_BOTTOM_GROUP "/middle/bottom" +#define GCPL_ON_ROOT_MAX_COMPACT 4 +#define GCPL_ON_ROOT_MIN_DENSE 2 #ifndef H5_NO_DEPRECATED_SYMBOLS /* Definitions for 'old_api' test */ -#define OLD_API_GROUP "/old_api" +#define OLD_API_GROUP "/old_api" #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Definitions for 'corrupt_stab_msg' test */ -#define CORRUPT_STAB_FILE "corrupt_stab_msg.h5" -#define CORRUPT_STAB_TMP_FILE "corrupt_stab_msg_tmp.h5" -#define CORRUPT_STAB_DSET "DS1" - +#define CORRUPT_STAB_FILE "corrupt_stab_msg.h5" +#define CORRUPT_STAB_TMP_FILE "corrupt_stab_msg_tmp.h5" +#define CORRUPT_STAB_DSET "DS1" /*------------------------------------------------------------------------- * Function: test_misc @@ -98,72 +94,95 @@ const char *FILENAME[] = { static int test_misc(hid_t fcpl, hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t g1 = (-1), g2 = (-1), g3 = (-1); - char filename[NAME_BUF_SIZE]; - char comment[64]; + hid_t fid = (-1); /* File ID */ + hid_t g1 = (-1), g2 = (-1), g3 = (-1); + char filename[NAME_BUF_SIZE]; + char comment[64]; - if(new_format) + if (new_format) TESTING("miscellaneous group tests (w/new group format)") else TESTING("miscellaneous group tests") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR /* Create initial groups for testing, then close */ - if((g1 = H5Gcreate2(fid, "test_1a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((g2 = H5Gcreate2(g1, "sub_1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((g3 = H5Gcreate2(fid, "test_1b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oset_comment(g3, "hello world") < 0) TEST_ERROR - if(H5Gclose(g1) < 0) TEST_ERROR - if(H5Gclose(g2) < 0) TEST_ERROR - if(H5Gclose(g3) < 0) TEST_ERROR + if ((g1 = H5Gcreate2(fid, "test_1a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((g2 = H5Gcreate2(g1, "sub_1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((g3 = H5Gcreate2(fid, "test_1b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oset_comment(g3, "hello world") < 0) + TEST_ERROR + if (H5Gclose(g1) < 0) + TEST_ERROR + if (H5Gclose(g2) < 0) + TEST_ERROR + if (H5Gclose(g3) < 0) + TEST_ERROR /* Open all groups with absolute names to check for exsistence */ - if((g1 = H5Gopen2(fid, "/test_1a", H5P_DEFAULT)) < 0) TEST_ERROR - if((g2 = H5Gopen2(fid, "/test_1a/sub_1", H5P_DEFAULT)) < 0) TEST_ERROR - if((g3 = H5Gopen2(fid, "/test_1b", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Oget_comment_by_name(g3, "././.", comment, sizeof comment, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(comment, "hello world")) { - H5_FAILED(); - HDputs(" Read the wrong comment string from the group."); - HDprintf(" got: \"%s\"\n ans: \"hello world\"\n", comment); - TEST_ERROR + if ((g1 = H5Gopen2(fid, "/test_1a", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((g2 = H5Gopen2(fid, "/test_1a/sub_1", H5P_DEFAULT)) < 0) + TEST_ERROR + if ((g3 = H5Gopen2(fid, "/test_1b", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Oget_comment_by_name(g3, "././.", comment, sizeof comment, H5P_DEFAULT) < 0) + TEST_ERROR + if (HDstrcmp(comment, "hello world")) { + H5_FAILED(); + HDputs(" Read the wrong comment string from the group."); + HDprintf(" got: \"%s\"\n ans: \"hello world\"\n", comment); + TEST_ERROR } - if(H5Gclose(g1) < 0) TEST_ERROR - if(H5Gclose(g2) < 0) TEST_ERROR - if(H5Gclose(g3) < 0) TEST_ERROR + if (H5Gclose(g1) < 0) + TEST_ERROR + if (H5Gclose(g2) < 0) + TEST_ERROR + if (H5Gclose(g3) < 0) + TEST_ERROR /* Check that creating groups with no-op names isn't allowed */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { g1 = H5Gcreate2(fid, "/", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY - if(g1 >= 0) TEST_ERROR + } + H5E_END_TRY + if (g1 >= 0) + TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { g1 = H5Gcreate2(fid, "./././", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY - if(g1 >= 0) TEST_ERROR + } + H5E_END_TRY + if (g1 >= 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Gclose(g1); - H5Gclose(g2); - H5Gclose(g3); +error: + H5E_BEGIN_TRY + { + H5Gclose(g1); + H5Gclose(g2); + H5Gclose(g3); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Purpose: Creates a group with a very long name * @@ -179,43 +198,53 @@ test_misc(hid_t fcpl, hid_t fapl, hbool_t new_format) static int test_long(hid_t fcpl, hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t g1 = (-1), g2 = (-1); - char *name1 = NULL, *name2 = NULL; - char filename[NAME_BUF_SIZE]; - size_t i; + hid_t fid = (-1); /* File ID */ + hid_t g1 = (-1), g2 = (-1); + char * name1 = NULL, *name2 = NULL; + char filename[NAME_BUF_SIZE]; + size_t i; - if(new_format) + if (new_format) TESTING("long names (w/new group format)") else TESTING("long names") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR /* Group names */ name1 = (char *)HDmalloc((size_t)LONG_NAME_LEN); - for(i = 0; i < LONG_NAME_LEN; i++) - name1[i] = (char)('A' + i%26); + for (i = 0; i < LONG_NAME_LEN; i++) + name1[i] = (char)('A' + i % 26); name1[LONG_NAME_LEN - 1] = '\0'; - name2 = (char *)HDmalloc((size_t)((2 * LONG_NAME_LEN) + 2)); + name2 = (char *)HDmalloc((size_t)((2 * LONG_NAME_LEN) + 2)); HDsprintf(name2, "%s/%s", name1, name1); /* Create groups */ - if((g1 = H5Gcreate2(fid, name1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((g2 = H5Gcreate2(g1, name1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(g1) < 0) TEST_ERROR - if(H5Gclose(g2) < 0) TEST_ERROR + if ((g1 = H5Gcreate2(fid, name1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((g2 = H5Gcreate2(g1, name1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(g1) < 0) + TEST_ERROR + if (H5Gclose(g2) < 0) + TEST_ERROR /* Open groups */ - if((g1 = H5Gopen2(fid, name1, H5P_DEFAULT)) < 0) TEST_ERROR - if((g2 = H5Gopen2(fid, name2, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(g1) < 0) TEST_ERROR - if(H5Gclose(g2) < 0) TEST_ERROR + if ((g1 = H5Gopen2(fid, name1, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((g2 = H5Gopen2(fid, name2, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(g1) < 0) + TEST_ERROR + if (H5Gclose(g2) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Release name buffers */ HDfree(name2); @@ -225,17 +254,18 @@ test_long(hid_t fcpl, hid_t fapl, hbool_t new_format) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(g1); H5Gclose(g2); H5Fclose(fid); HDfree(name2); HDfree(name1); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_long() */ - /*------------------------------------------------------------------------- * Function: test_large * @@ -254,53 +284,62 @@ error: static int test_large(hid_t fcpl, hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t cwg = (-1), dir = (-1); /* Group IDs */ - char filename[NAME_BUF_SIZE]; - char name[NAME_BUF_SIZE]; - int i; + hid_t fid = (-1); /* File ID */ + hid_t cwg = (-1), dir = (-1); /* Group IDs */ + char filename[NAME_BUF_SIZE]; + char name[NAME_BUF_SIZE]; + int i; - if(new_format) + if (new_format) TESTING("large directories (w/new group format)") else TESTING("large directories") /* Create file */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR /* * Create a directory that has so many entries that the root * of the B-tree ends up splitting. */ - if((cwg = H5Gcreate2(fid, "/big", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(new_format) - if(H5G__has_stab_test(cwg) != FALSE) TEST_ERROR - for(i = 0; i < LARGE_NOBJS; i++) { + if ((cwg = H5Gcreate2(fid, "/big", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (new_format) + if (H5G__has_stab_test(cwg) != FALSE) + TEST_ERROR + for (i = 0; i < LARGE_NOBJS; i++) { HDsprintf(name, "%05d%05d", (HDrandom() % 100000), i); - if((dir = H5Gcreate2(cwg, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(dir) < 0) TEST_ERROR + if ((dir = H5Gcreate2(cwg, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Gclose(dir) < 0) + TEST_ERROR } - if(new_format) - if(H5G__is_new_dense_test(cwg) != TRUE) TEST_ERROR - if(H5Gclose(cwg) < 0) TEST_ERROR + if (new_format) + if (H5G__is_new_dense_test(cwg) != TRUE) + TEST_ERROR + if (H5Gclose(cwg) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Gclose(dir); - H5Gclose(cwg); +error: + H5E_BEGIN_TRY + { + H5Gclose(dir); + H5Gclose(cwg); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_large() */ - /*------------------------------------------------------------------------- * Function: lifecycle * @@ -320,202 +359,274 @@ test_large(hid_t fcpl, hid_t fapl, hbool_t new_format) static int lifecycle(hid_t fcpl, hid_t fapl2) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Datatype ID */ - hid_t gcpl = (-1); /* Group creation property list ID */ - size_t lheap_size_hint; /* Local heap size hint */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - unsigned est_num_entries; /* Estimated # of entries in group */ - unsigned est_name_len; /* Estimated length of entry name */ - unsigned nmsgs; /* Number of messages in group's header */ - H5O_native_info_t ninfo; /* Object info */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; - h5_stat_size_t empty_size; /* Size of an empty file */ - unsigned u; /* Local index variable */ - h5_stat_size_t file_size; /* Size of each file created */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + hid_t gid2 = (-1); /* Datatype ID */ + hid_t gcpl = (-1); /* Group creation property list ID */ + size_t lheap_size_hint; /* Local heap size hint */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + unsigned est_num_entries; /* Estimated # of entries in group */ + unsigned est_name_len; /* Estimated length of entry name */ + unsigned nmsgs; /* Number of messages in group's header */ + H5O_native_info_t ninfo; /* Object info */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; + h5_stat_size_t empty_size; /* Size of an empty file */ + unsigned u; /* Local index variable */ + h5_stat_size_t file_size; /* Size of each file created */ TESTING("group lifecycle"); /* Create file */ h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Get size of file as empty */ - if((empty_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl2)) < 0) + TEST_ERROR /* Re-open file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + TEST_ERROR /* Set up group creation property list */ - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Query default group creation property settings */ - if(H5Pget_local_heap_size_hint(gcpl, &lheap_size_hint) < 0) TEST_ERROR - if(lheap_size_hint != H5G_CRT_GINFO_LHEAP_SIZE_HINT) TEST_ERROR - if(H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) TEST_ERROR - if(max_compact != H5G_CRT_GINFO_MAX_COMPACT) TEST_ERROR - if(min_dense != H5G_CRT_GINFO_MIN_DENSE) TEST_ERROR - if(H5Pget_est_link_info(gcpl, &est_num_entries, &est_name_len) < 0) TEST_ERROR - if(est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES) TEST_ERROR - if(est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) TEST_ERROR + if (H5Pget_local_heap_size_hint(gcpl, &lheap_size_hint) < 0) + TEST_ERROR + if (lheap_size_hint != H5G_CRT_GINFO_LHEAP_SIZE_HINT) + TEST_ERROR + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) + TEST_ERROR + if (max_compact != H5G_CRT_GINFO_MAX_COMPACT) + TEST_ERROR + if (min_dense != H5G_CRT_GINFO_MIN_DENSE) + TEST_ERROR + if (H5Pget_est_link_info(gcpl, &est_num_entries, &est_name_len) < 0) + TEST_ERROR + if (est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES) + TEST_ERROR + if (est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) + TEST_ERROR /* Set GCPL parameters */ - if(H5Pset_local_heap_size_hint(gcpl, (size_t)LIFECYCLE_LOCAL_HEAP_SIZE_HINT) < 0) TEST_ERROR - if(H5Pset_link_phase_change(gcpl, LIFECYCLE_MAX_COMPACT, LIFECYCLE_MIN_DENSE) < 0) TEST_ERROR - if(H5Pset_est_link_info(gcpl, LIFECYCLE_EST_NUM_ENTRIES, LIFECYCLE_EST_NAME_LEN) < 0) TEST_ERROR + if (H5Pset_local_heap_size_hint(gcpl, (size_t)LIFECYCLE_LOCAL_HEAP_SIZE_HINT) < 0) + TEST_ERROR + if (H5Pset_link_phase_change(gcpl, LIFECYCLE_MAX_COMPACT, LIFECYCLE_MIN_DENSE) < 0) + TEST_ERROR + if (H5Pset_est_link_info(gcpl, LIFECYCLE_EST_NUM_ENTRIES, LIFECYCLE_EST_NAME_LEN) < 0) + TEST_ERROR /* Create group for testing lifecycle */ - if((gid = H5Gcreate2(fid, LIFECYCLE_TOP_GROUP, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, LIFECYCLE_TOP_GROUP, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) + TEST_ERROR /* Query group creation property settings */ - if(H5Pget_local_heap_size_hint(gcpl, &lheap_size_hint) < 0) TEST_ERROR - if(lheap_size_hint != LIFECYCLE_LOCAL_HEAP_SIZE_HINT) TEST_ERROR - if(H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) TEST_ERROR - if(max_compact != LIFECYCLE_MAX_COMPACT) TEST_ERROR - if(min_dense != LIFECYCLE_MIN_DENSE) TEST_ERROR - if(H5Pget_est_link_info(gcpl, &est_num_entries, &est_name_len) < 0) TEST_ERROR - if(est_num_entries != LIFECYCLE_EST_NUM_ENTRIES) TEST_ERROR - if(est_name_len != LIFECYCLE_EST_NAME_LEN) TEST_ERROR + if (H5Pget_local_heap_size_hint(gcpl, &lheap_size_hint) < 0) + TEST_ERROR + if (lheap_size_hint != LIFECYCLE_LOCAL_HEAP_SIZE_HINT) + TEST_ERROR + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) + TEST_ERROR + if (max_compact != LIFECYCLE_MAX_COMPACT) + TEST_ERROR + if (min_dense != LIFECYCLE_MIN_DENSE) + TEST_ERROR + if (H5Pget_est_link_info(gcpl, &est_num_entries, &est_name_len) < 0) + TEST_ERROR + if (est_num_entries != LIFECYCLE_EST_NUM_ENTRIES) + TEST_ERROR + if (est_name_len != LIFECYCLE_EST_NAME_LEN) + TEST_ERROR /* Use internal testing routine to check that the group has no links or symbol table */ - if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) != TRUE) + TEST_ERROR /* Create first "bottom" group */ HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, (unsigned)0); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on bottom group's status */ - if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid2) != TRUE) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Check on top group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR - if(nmsgs != 1) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, &nmsgs) != TRUE) + TEST_ERROR + if (nmsgs != 1) + TEST_ERROR /* Create several more bottom groups, to push the top group almost to a symbol table */ /* (Start counting at '1', since we've already created one bottom group */ - for(u = 1; u < LIFECYCLE_MAX_COMPACT; u++) { + for (u = 1; u < LIFECYCLE_MAX_COMPACT; u++) { HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on bottom group's status */ - if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid2) != TRUE) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR } /* end for */ /* Check on top group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR - if(nmsgs != LIFECYCLE_MAX_COMPACT) TEST_ERROR - if(H5G__is_new_dense_test(gid) != FALSE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, &nmsgs) != TRUE) + TEST_ERROR + if (nmsgs != LIFECYCLE_MAX_COMPACT) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != FALSE) + TEST_ERROR /* Check that the object header is only one chunk and the space has been allocated correctly */ - if(H5Oget_native_info(gid, &ninfo, H5O_NATIVE_INFO_HDR) < 0) TEST_ERROR - if(ninfo.hdr.space.total != 151) TEST_ERROR - if(ninfo.hdr.space.free != 0) TEST_ERROR - if(ninfo.hdr.nmesgs != 6) TEST_ERROR - if(ninfo.hdr.nchunks != 1) TEST_ERROR + if (H5Oget_native_info(gid, &ninfo, H5O_NATIVE_INFO_HDR) < 0) + TEST_ERROR + if (ninfo.hdr.space.total != 151) + TEST_ERROR + if (ninfo.hdr.space.free != 0) + TEST_ERROR + if (ninfo.hdr.nmesgs != 6) + TEST_ERROR + if (ninfo.hdr.nchunks != 1) + TEST_ERROR /* Create one more "bottom" group, which should push top group into using a symbol table */ HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on bottom group's status */ - if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid2) != TRUE) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Check on top group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Check that the object header is still one chunk and the space has been allocated correctly */ - if(H5Oget_native_info(gid, &ninfo, H5O_NATIVE_INFO_HDR) < 0) TEST_ERROR - if(ninfo.hdr.space.total != 151) TEST_ERROR - if(ninfo.hdr.space.free != 92) TEST_ERROR - if(ninfo.hdr.nmesgs != 3) TEST_ERROR - if(ninfo.hdr.nchunks != 1) TEST_ERROR + if (H5Oget_native_info(gid, &ninfo, H5O_NATIVE_INFO_HDR) < 0) + TEST_ERROR + if (ninfo.hdr.space.total != 151) + TEST_ERROR + if (ninfo.hdr.space.free != 92) + TEST_ERROR + if (ninfo.hdr.nmesgs != 3) + TEST_ERROR + if (ninfo.hdr.nchunks != 1) + TEST_ERROR /* Unlink objects from top group */ - while(u >= LIFECYCLE_MIN_DENSE) { + while (u >= LIFECYCLE_MIN_DENSE) { HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR u--; } /* end while */ /* Check on top group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Unlink one more object from the group, which should transform back to using links */ HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR u--; /* Check on top group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR - if(nmsgs != (LIFECYCLE_MIN_DENSE - 1)) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, &nmsgs) != TRUE) + TEST_ERROR + if (nmsgs != (LIFECYCLE_MIN_DENSE - 1)) + TEST_ERROR /* Unlink last two objects from top group */ HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR u--; HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check on top group's status */ - if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) != TRUE) + TEST_ERROR /* Close top group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Unlink top group */ - if(H5Ldelete(fid, LIFECYCLE_TOP_GROUP, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, LIFECYCLE_TOP_GROUP, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close GCPL */ - if(H5Pclose(gcpl) < 0) TEST_ERROR + if (H5Pclose(gcpl) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Get size of file as empty */ - if((file_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl2)) < 0) + TEST_ERROR /* Verify that file is correct size */ - if(file_size != empty_size) TEST_ERROR - + if (file_size != empty_size) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gcpl); H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end lifecycle() */ - /*------------------------------------------------------------------------- * Function: long_compact * @@ -534,124 +645,155 @@ error: static int long_compact(hid_t fcpl, hid_t fapl2) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Group ID */ - char *objname = NULL; /* Object name */ - char filename[NAME_BUF_SIZE]; - h5_stat_size_t empty_size; /* Size of an empty file */ - h5_stat_size_t file_size; /* Size of each file created */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + hid_t gid2 = (-1); /* Group ID */ + char * objname = NULL; /* Object name */ + char filename[NAME_BUF_SIZE]; + h5_stat_size_t empty_size; /* Size of an empty file */ + h5_stat_size_t file_size; /* Size of each file created */ TESTING("long link names in compact groups"); /* Create file */ h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Get size of file as empty */ - if((empty_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl2)) < 0) + TEST_ERROR /* Construct very long object name template */ - if(NULL == (objname = (char *)HDmalloc((size_t)(LONG_COMPACT_LENGTH + 1)))) TEST_ERROR + if (NULL == (objname = (char *)HDmalloc((size_t)(LONG_COMPACT_LENGTH + 1)))) + TEST_ERROR HDmemset(objname, 'a', (size_t)LONG_COMPACT_LENGTH); objname[LONG_COMPACT_LENGTH] = '\0'; /* Re-open file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + TEST_ERROR /* Create top group */ - if((gid = H5Gcreate2(fid, "top", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, "top", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Use internal testing routine to check that the group has no links or dense storage */ - if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) != TRUE) + TEST_ERROR /* Create first group with "long" name */ - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on bottom group's status */ - if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid2) != TRUE) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Check on top group's status */ /* (Should have dense storage to hold links, since name is too long for object header message) */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Create second group with "long" name */ objname[0] = 'b'; - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on bottom group's status */ - if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid2) != TRUE) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Check on top group's status */ /* (Should have dense storage to hold links, since name is too long for object header message) */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Unlink second object from top group */ - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check on top group's status */ /* (Should still be dense storage to hold links, since name is too long for object header message) */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Unlink first object from top group */ objname[0] = 'a'; - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check on top group's status */ /* (Should have deleted the dense storage now) */ - if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) != TRUE) + TEST_ERROR /* Free object name */ HDfree(objname); objname = NULL; /* Close top group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Unlink top group */ - if(H5Ldelete(fid, "top", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "top", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Get size of file as empty */ - if((file_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl2)) < 0) + TEST_ERROR /* Verify that file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; - if(objname) + if (objname) HDfree(objname); return 1; } /* end long_compact() */ - /*------------------------------------------------------------------------- * Function: read_old * @@ -669,76 +811,95 @@ error: static int read_old(void) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Group ID */ - char objname[NAME_BUF_SIZE]; /* Object name */ - unsigned u; /* Local index variable */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + hid_t gid2 = (-1); /* Group ID */ + char objname[NAME_BUF_SIZE]; /* Object name */ + unsigned u; /* Local index variable */ TESTING("reading old groups"); /* Make a copy of the data file from svn. */ - if(h5_make_local_copy(FILE_OLD_GROUPS, FILE_OLD_GROUPS_COPY) < 0) TEST_ERROR + if (h5_make_local_copy(FILE_OLD_GROUPS, FILE_OLD_GROUPS_COPY) < 0) + TEST_ERROR /* Open copied file */ - if((fid = H5Fopen(FILE_OLD_GROUPS_COPY, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fopen(FILE_OLD_GROUPS_COPY, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR /* Attempt to open "old" group */ - if((gid = H5Gopen2(fid, "old", H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gopen2(fid, "old", H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on old group's status */ - if(H5G__is_empty_test(gid) == FALSE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == FALSE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(gid) != TRUE) + TEST_ERROR /* Create a bunch of objects in the group */ - for(u = 0; u < READ_OLD_NGROUPS; u++) { + for (u = 0; u < READ_OLD_NGROUPS; u++) { HDsprintf(objname, "Group %u", u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on bottom group's status */ - if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid2) != TRUE) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR } /* end for */ /* Check on old group's status */ /* (Should stay in old "symbol table" form) */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(gid) != TRUE) + TEST_ERROR /* Delete new objects from old group */ - for(u = 0; u < READ_OLD_NGROUPS; u++) { + for (u = 0; u < READ_OLD_NGROUPS; u++) { HDsprintf(objname, "Group %u", u); - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Check on old group's status */ /* (Should stay in old "symbol table" form, but have no links) */ - if(H5G__is_empty_test(gid) == FALSE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__has_stab_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == FALSE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__has_stab_test(gid) != TRUE) + TEST_ERROR /* Close old group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid)<0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end read_old() */ - /*------------------------------------------------------------------------- * Function: no_compact * @@ -757,103 +918,129 @@ error: static int no_compact(hid_t fcpl, hid_t fapl2) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Datatype ID */ - hid_t gcpl = (-1); /* Group creation property list ID */ - char objname[NAME_BUF_SIZE]; /* Object name */ - char filename[NAME_BUF_SIZE]; - h5_stat_size_t empty_size; /* Size of an empty file */ - h5_stat_size_t file_size; /* Size of each file created */ - unsigned est_num_entries; /* Estimated # of entries in group */ - unsigned est_name_len; /* Estimated length of entry name */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + hid_t gid2 = (-1); /* Datatype ID */ + hid_t gcpl = (-1); /* Group creation property list ID */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char filename[NAME_BUF_SIZE]; + h5_stat_size_t empty_size; /* Size of an empty file */ + h5_stat_size_t file_size; /* Size of each file created */ + unsigned est_num_entries; /* Estimated # of entries in group */ + unsigned est_name_len; /* Estimated length of entry name */ TESTING("group without compact form"); /* Create file */ h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Get size of file as empty */ - if((empty_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl2)) < 0) + TEST_ERROR /* Re-open file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) + TEST_ERROR /* Set up group creation property list */ - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + if ((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR /* Set GCPL parameters */ - if(H5Pset_link_phase_change(gcpl, NO_COMPACT_MAX_COMPACT, NO_COMPACT_MIN_DENSE) < 0) TEST_ERROR + if (H5Pset_link_phase_change(gcpl, NO_COMPACT_MAX_COMPACT, NO_COMPACT_MIN_DENSE) < 0) + TEST_ERROR /* Check information for default group creation */ - if(H5Pget_est_link_info(gcpl, &est_num_entries, &est_name_len) < 0) TEST_ERROR - if(est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES) TEST_ERROR - if(est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) TEST_ERROR + if (H5Pget_est_link_info(gcpl, &est_num_entries, &est_name_len) < 0) + TEST_ERROR + if (est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES) + TEST_ERROR + if (est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) + TEST_ERROR /* Create group for testing no compact form */ - if((gid = H5Gcreate2(fid, NO_COMPACT_TOP_GROUP, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gcreate2(fid, NO_COMPACT_TOP_GROUP, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close GCPL */ - if(H5Pclose(gcpl) < 0) TEST_ERROR + if (H5Pclose(gcpl) < 0) + TEST_ERROR /* Use internal testing routine to check that the group has no links or dense storage */ - if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) != TRUE) + TEST_ERROR /* Create first "bottom" group */ HDsprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Check on bottom group's status */ - if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid2) != TRUE) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Check on top group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Unlink object from top group */ HDsprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0); - if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check on top group's status */ - if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) != TRUE) + TEST_ERROR /* Close top group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Unlink top group */ - if(H5Ldelete(fid, NO_COMPACT_TOP_GROUP, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, NO_COMPACT_TOP_GROUP, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Get size of file as empty */ - if((file_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl2)) < 0) + TEST_ERROR /* Verify that file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gcpl); H5Gclose(gid2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end no_compact() */ - /*------------------------------------------------------------------------- * Function: gcpl_on_root * @@ -871,15 +1058,15 @@ error: static int gcpl_on_root(hid_t fapl2) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Datatype ID */ - hid_t fcpl = (-1); /* File creation property list ID */ - hid_t gcpl = (-1); /* Group creation property list ID */ - hid_t lcpl = (-1); /* Link creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - char filename[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + hid_t gid2 = (-1); /* Datatype ID */ + hid_t fcpl = (-1); /* File creation property list ID */ + hid_t gcpl = (-1); /* Group creation property list ID */ + hid_t lcpl = (-1); /* Link creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + char filename[NAME_BUF_SIZE]; TESTING("setting root group creation properties"); @@ -887,94 +1074,126 @@ gcpl_on_root(hid_t fapl2) h5_fixname(FILENAME[0], fapl2, filename, sizeof(filename)); /* Set up file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR /* Set GCPL parameters */ - if(H5Pset_link_phase_change(fcpl, GCPL_ON_ROOT_MAX_COMPACT, GCPL_ON_ROOT_MIN_DENSE) < 0) TEST_ERROR + if (H5Pset_link_phase_change(fcpl, GCPL_ON_ROOT_MAX_COMPACT, GCPL_ON_ROOT_MIN_DENSE) < 0) + TEST_ERROR /* Query the group creation properties from the FCPL */ - if(H5Pget_link_phase_change(fcpl, &max_compact, &min_dense) < 0) TEST_ERROR - if(max_compact != GCPL_ON_ROOT_MAX_COMPACT) TEST_ERROR - if(min_dense != GCPL_ON_ROOT_MIN_DENSE) TEST_ERROR + if (H5Pget_link_phase_change(fcpl, &max_compact, &min_dense) < 0) + TEST_ERROR + if (max_compact != GCPL_ON_ROOT_MAX_COMPACT) + TEST_ERROR + if (min_dense != GCPL_ON_ROOT_MIN_DENSE) + TEST_ERROR /* Create file with modified root group creation properties */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + TEST_ERROR /* Close FCPL */ - if(H5Pclose(fcpl) < 0) TEST_ERROR + if (H5Pclose(fcpl) < 0) + TEST_ERROR /* Open the root group */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + TEST_ERROR /* Query the group creation properties */ - if((gcpl = H5Gget_create_plist(gid)) < 0) TEST_ERROR - if(H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) TEST_ERROR - if(max_compact != GCPL_ON_ROOT_MAX_COMPACT) TEST_ERROR - if(min_dense != GCPL_ON_ROOT_MIN_DENSE) TEST_ERROR + if ((gcpl = H5Gget_create_plist(gid)) < 0) + TEST_ERROR + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) + TEST_ERROR + if (max_compact != GCPL_ON_ROOT_MAX_COMPACT) + TEST_ERROR + if (min_dense != GCPL_ON_ROOT_MIN_DENSE) + TEST_ERROR /* Close GCPL */ - if(H5Pclose(gcpl) < 0) TEST_ERROR + if (H5Pclose(gcpl) < 0) + TEST_ERROR /* Create a link creation property list, with intermediate group creation set */ - if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl, TRUE) < 0) TEST_ERROR + if ((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) + TEST_ERROR + if (H5Pset_create_intermediate_group(lcpl, TRUE) < 0) + TEST_ERROR /* Create a group and intermediate groups, to check if root group settings are inherited */ - if((gid2 = H5Gcreate2(gid, GCPL_ON_ROOT_BOTTOM_GROUP, lcpl, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gcreate2(gid, GCPL_ON_ROOT_BOTTOM_GROUP, lcpl, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close LCPL */ - if(H5Pclose(lcpl) < 0) TEST_ERROR + if (H5Pclose(lcpl) < 0) + TEST_ERROR /* Query the group creation properties */ - if((gcpl = H5Gget_create_plist(gid2)) < 0) TEST_ERROR - if(H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) TEST_ERROR - if(max_compact != H5G_CRT_GINFO_MAX_COMPACT) TEST_ERROR - if(min_dense != H5G_CRT_GINFO_MIN_DENSE) TEST_ERROR + if ((gcpl = H5Gget_create_plist(gid2)) < 0) + TEST_ERROR + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) + TEST_ERROR + if (max_compact != H5G_CRT_GINFO_MAX_COMPACT) + TEST_ERROR + if (min_dense != H5G_CRT_GINFO_MIN_DENSE) + TEST_ERROR /* Close GCPL */ - if(H5Pclose(gcpl) < 0) TEST_ERROR + if (H5Pclose(gcpl) < 0) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Open the middle group */ - if((gid2 = H5Gopen2(fid, GCPL_ON_ROOT_MIDDLE_GROUP, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gid2 = H5Gopen2(fid, GCPL_ON_ROOT_MIDDLE_GROUP, H5P_DEFAULT)) < 0) + TEST_ERROR /* Query the group creation properties */ - if((gcpl = H5Gget_create_plist(gid2)) < 0) TEST_ERROR - if(H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) TEST_ERROR - if(max_compact != GCPL_ON_ROOT_MAX_COMPACT) TEST_ERROR - if(min_dense != GCPL_ON_ROOT_MIN_DENSE) TEST_ERROR + if ((gcpl = H5Gget_create_plist(gid2)) < 0) + TEST_ERROR + if (H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) + TEST_ERROR + if (max_compact != GCPL_ON_ROOT_MAX_COMPACT) + TEST_ERROR + if (min_dense != GCPL_ON_ROOT_MIN_DENSE) + TEST_ERROR /* Close GCPL */ - if(H5Pclose(gcpl) < 0) TEST_ERROR + if (H5Pclose(gcpl) < 0) + TEST_ERROR /* Close bottom group */ - if(H5Gclose(gid2) < 0) TEST_ERROR + if (H5Gclose(gid2) < 0) + TEST_ERROR /* Close root group */ - if(H5Gclose(gid) < 0) TEST_ERROR + if (H5Gclose(gid) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR - + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(lcpl); H5Gclose(gcpl); H5Gclose(gid2); H5Gclose(gid); H5Gclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end gcpl_on_root() */ - /*------------------------------------------------------------------------- * Function: old_api * @@ -992,11 +1211,11 @@ static int old_api(hid_t fapl) { #ifndef H5_NO_DEPRECATED_SYMBOLS - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - h5_stat_size_t small_file_size; /* Size of small group file */ - h5_stat_size_t large_file_size; /* Size of large group file */ - char filename[NAME_BUF_SIZE]; + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + h5_stat_size_t small_file_size; /* Size of small group file */ + h5_stat_size_t large_file_size; /* Size of large group file */ + char filename[NAME_BUF_SIZE]; #endif /* H5_NO_DEPRECATED_SYMBOLS */ TESTING("old API routines"); @@ -1006,47 +1225,59 @@ old_api(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a group, with the old API routine and a "small" heap */ - if((gid = H5Gcreate1(fid, OLD_API_GROUP, (size_t)0)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate1(fid, OLD_API_GROUP, (size_t)0)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Get the size of the file with a "small" heap for group */ - if((small_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR - + if ((small_file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a group, with the old API routine and a "large" heap */ - if((gid = H5Gcreate1(fid, OLD_API_GROUP, (size_t)10000)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate1(fid, OLD_API_GROUP, (size_t)10000)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Re-open group */ - if((gid = H5Gopen1(fid, OLD_API_GROUP)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen1(fid, OLD_API_GROUP)) < 0) + FAIL_STACK_ERROR /* Close group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Get the size of the file with a "large" heap for group */ - if((large_file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((large_file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Check that the file with a "large" group heap is actually bigger */ - if(large_file_size <= small_file_size) TEST_ERROR + if (large_file_size <= small_file_size) + TEST_ERROR PASSED(); -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ /* Shut compiler up */ fapl = fapl; @@ -1058,15 +1289,16 @@ old_api(hid_t fapl) #ifndef H5_NO_DEPRECATED_SYMBOLS error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; #endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* end old_api() */ - /*------------------------------------------------------------------------- * Function: corrupt_stab_msg * @@ -1084,51 +1316,65 @@ error: static int corrupt_stab_msg(void) { - hid_t fid = (-1); /* File ID */ - hid_t did = (-1); /* Dataset ID */ + hid_t fid = (-1); /* File ID */ + hid_t did = (-1); /* Dataset ID */ TESTING("corrupt symbol table message"); /* Make a copy of the data file from svn. */ - if(h5_make_local_copy(CORRUPT_STAB_FILE, CORRUPT_STAB_TMP_FILE) < 0) TEST_ERROR + if (h5_make_local_copy(CORRUPT_STAB_FILE, CORRUPT_STAB_TMP_FILE) < 0) + TEST_ERROR #ifndef H5_STRICT_FORMAT_CHECKS /* Open temp file through HDF5 library */ - if((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR /* Open dataset */ - if((did = H5Dopen2(fid, CORRUPT_STAB_DSET, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid, CORRUPT_STAB_DSET, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close dataset and file */ - if(H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR /* Now reopen with read only access. This verifies that the issue has been * corrected, as the symbol table message is not patched in read only mode. */ /* Open file */ - if((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR /* Open dataset */ - if((did = H5Dopen2(fid, CORRUPT_STAB_DSET, H5P_DEFAULT)) < 0) TEST_ERROR + if ((did = H5Dopen2(fid, CORRUPT_STAB_DSET, H5P_DEFAULT)) < 0) + TEST_ERROR /* Close dataset and file */ - if(H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Dclose(did) < 0) + TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR #else /* H5_STRICT_FORMAT_CHECKS */ /* Open file */ - if((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR + if ((fid = H5Fopen(CORRUPT_STAB_TMP_FILE, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR /* Verify that an error is thrown when we try to access the dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dopen2(fid, CORRUPT_STAB_DSET, H5P_DEFAULT); - } H5E_END_TRY - if(did >= 0) TEST_ERROR + } + H5E_END_TRY + if (did >= 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR #endif /* H5_STRICT_FORMAT_CHECKS */ @@ -1137,15 +1383,16 @@ corrupt_stab_msg(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end corrupt_stab_msg() */ - /*------------------------------------------------------------------------- * Function: main * @@ -1165,16 +1412,16 @@ error: int main(void) { - hid_t fapl, fapl2; /* File access property list IDs */ - hid_t fcpl, fcpl2; /* File creation property list ID */ - unsigned new_format; /* Whether to use the new format or not */ - const char *env_h5_drvr; /* File Driver value from environment */ - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - int nerrors = 0; + hid_t fapl, fapl2; /* File access property list IDs */ + hid_t fcpl, fcpl2; /* File creation property list ID */ + unsigned new_format; /* Whether to use the new format or not */ + const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + int nerrors = 0; /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; /* VFD that does not support contigous address space */ @@ -1185,31 +1432,35 @@ main(void) fapl = h5_fileaccess(); /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR /* Set up file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR - if((fcpl2 = H5Pcopy(fcpl)) < 0) TEST_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + TEST_ERROR + if ((fcpl2 = H5Pcopy(fcpl)) < 0) + TEST_ERROR /* Set to use paged aggregation strategy and persisting free-space */ /* Skip testing for multi/split drivers */ - if(H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl2, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) < 0) TEST_ERROR /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl = fapl; hid_t my_fcpl = fcpl; - if(!contig_addr_vfd) + if (!contig_addr_vfd) continue; - if(new_format) { + if (new_format) { my_fapl = fapl2; - my_fcpl = fcpl2; /* Set to use paged aggregation and persisting free-space */ + my_fcpl = fcpl2; /* Set to use paged aggregation and persisting free-space */ } /* Perform basic tests, with old & new style groups */ @@ -1219,7 +1470,7 @@ main(void) } /* end for */ /* New format group specific tests (require new format features) */ - if(contig_addr_vfd) { + if (contig_addr_vfd) { nerrors += lifecycle(fcpl2, fapl2); nerrors += long_compact(fcpl2, fapl2); nerrors += read_old(); @@ -1240,7 +1491,7 @@ main(void) nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); /* Check for test errors */ - if(nerrors) + if (nerrors) goto error; HDputs("All symbol table tests passed."); @@ -1258,4 +1509,3 @@ error: HDputs("*** TESTS FAILED ***"); return 1; } - diff --git a/test/stubs.c b/test/stubs.c index c04f1ba..2d5d071 100644 --- a/test/stubs.c +++ b/test/stubs.c @@ -22,4 +22,3 @@ zoo_create_hook(hid_t H5_ATTR_UNUSED fid) { return; } - diff --git a/test/swmr.c b/test/swmr.c index bab91bd..8944b85 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -12,53 +12,49 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: swmr -* -* To test new public routines from SWMR project: -* H5Pget/set_metadata_read_attempts() -* H5Fget_metadata_read_retry_info() -* H5Fstart_swmr_write() -* H5Pget/set_object_flush_cb() -* H5Pget/set_append_flush() -* -*************************************************************/ + * + * Test program: swmr + * + * To test new public routines from SWMR project: + * H5Pget/set_metadata_read_attempts() + * H5Fget_metadata_read_retry_info() + * H5Fstart_swmr_write() + * H5Pget/set_object_flush_cb() + * H5Pget/set_append_flush() + * + *************************************************************/ #include "h5test.h" #include "H5Iprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* * This file needs to access private information from the H5F package. * This file also needs to access the file, file driver, dataset, * and object header testing code. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ #define H5D_TESTING -#include "H5Dpkg.h" /* Datasets */ +#include "H5Dpkg.h" /* Datasets */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING -#include "H5FDpkg.h" /* File drivers */ +#include "H5FDpkg.h" /* File drivers */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ #define H5O_TESTING -#include "H5Opkg.h" /* Object headers */ +#include "H5Opkg.h" /* Object headers */ +const char *FILENAME[] = {"swmr0", /* 0 */ + "swmr1", /* 1 */ + "swmr2", /* 2 */ + NULL}; -const char *FILENAME[] = { - "swmr0", /* 0 */ - "swmr1", /* 1 */ - "swmr2", /* 2 */ - NULL -}; - - -#define NAME_BUF_SIZE 1024 /* Length of file name */ +#define NAME_BUF_SIZE 1024 /* Length of file name */ /* Tests for H5Pget/set_metadata_read_attempts(), H5Fget_metadata_read_retry_info */ static int test_metadata_read_attempts(hid_t in_fapl); @@ -72,15 +68,15 @@ static int test_start_swmr_write_stress_ohdr(hid_t in_fapl); /* Tests for H5Pget/set_object_flush_cb() */ static herr_t flush_cb(hid_t obj_id, void *_udata); -static int test_object_flush_cb(hid_t in_fapl); +static int test_object_flush_cb(hid_t in_fapl); /* Tests for H5Pget/set_append_flush() */ static herr_t append_cb(hid_t dset_id, hsize_t *cur_dims, void *_udata); static herr_t append_cb2(hid_t dset_id, hsize_t *cur_dims, void *_udata); -static int test_append_flush_generic(void); -static int test_append_flush_dataset_chunked(hid_t in_fapl); -static int test_append_flush_dataset_fixed(hid_t in_fapl); -static int test_append_flush_dataset_multiple(hid_t in_fapl); +static int test_append_flush_generic(void); +static int test_append_flush_dataset_chunked(hid_t in_fapl); +static int test_append_flush_dataset_fixed(hid_t in_fapl); +static int test_append_flush_dataset_multiple(hid_t in_fapl); /* Tests for file open flags/SWMR flags: single process access */ static int test_file_lock_same(hid_t fapl); @@ -116,15 +112,15 @@ static int test_multiple_same(hid_t in_fapl, hbool_t new_format); static int test_metadata_read_attempts(hid_t in_fapl) { - hid_t fapl = -1; /* File access property list */ - hid_t file_fapl = -1; /* The file's access property list */ - hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - hbool_t compat_w_default_vfd; /* current VFD compat w/ H5P_DEFAULT? */ - unsigned attempts; /* The # of read attempts */ - char filename[NAME_BUF_SIZE]; /* File name */ - herr_t ret; /* Generic return value */ + hid_t fapl = -1; /* File access property list */ + hid_t file_fapl = -1; /* The file's access property list */ + hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + hbool_t compat_w_default_vfd; /* current VFD compat w/ H5P_DEFAULT? */ + unsigned attempts; /* The # of read attempts */ + char filename[NAME_BUF_SIZE]; /* File name */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ TESTING("H5Pget/set_metadata_read_attempts()"); @@ -148,7 +144,7 @@ test_metadata_read_attempts(hid_t in_fapl) } /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ @@ -161,50 +157,54 @@ test_metadata_read_attempts(hid_t in_fapl) * file access property list. */ /* Get # of read attempts -- should be the default: 1 */ - if(H5Pget_metadata_read_attempts(fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != 1) + if (attempts != 1) TEST_ERROR /* Set the # of read attempts to 0--should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_metadata_read_attempts(fapl, 0); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Set the # of read attempts to a # > 0--should succeed */ - if(H5Pset_metadata_read_attempts(fapl, 9) < 0) + if (H5Pset_metadata_read_attempts(fapl, 9) < 0) TEST_ERROR /* Retrieve the # of read attempts -- should be 9 */ - if(H5Pget_metadata_read_attempts(fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != 9) + if (attempts != 9) TEST_ERROR - /* Set the # of read attempts to the default for non-SWMR access: H5F_METADATA_READ_ATTEMPTS --should succeed */ - if(H5Pset_metadata_read_attempts(fapl, H5F_METADATA_READ_ATTEMPTS) < 0) + /* Set the # of read attempts to the default for non-SWMR access: H5F_METADATA_READ_ATTEMPTS --should + * succeed */ + if (H5Pset_metadata_read_attempts(fapl, H5F_METADATA_READ_ATTEMPTS) < 0) TEST_ERROR /* Retrieve the # of read attempts -- should be H5F_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_METADATA_READ_ATTEMPTS) + if (attempts != H5F_METADATA_READ_ATTEMPTS) TEST_ERROR - /* Set the # of read attempts to the default for SWMR access: H5F_SWMR_METADATA_READ_ATEMPTS --should succeed */ - if(H5Pset_metadata_read_attempts(fapl, H5F_SWMR_METADATA_READ_ATTEMPTS) < 0) + /* Set the # of read attempts to the default for SWMR access: H5F_SWMR_METADATA_READ_ATEMPTS --should + * succeed */ + if (H5Pset_metadata_read_attempts(fapl, H5F_SWMR_METADATA_READ_ATTEMPTS) < 0) TEST_ERROR /* Retrieve the # of read attempts -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* @@ -216,173 +216,173 @@ test_metadata_read_attempts(hid_t in_fapl) */ /* Test 1 */ /* Create a file with non-SWMR access and default fapl */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_METADATA_READ_ATTEMPTS) + if (attempts != H5F_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Test 2 */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Open the file with SWMR access and default read attempts */ - if((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) + if ((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Test 3 */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Set the # of read attempts */ - if(H5Pset_metadata_read_attempts(fapl, 9) < 0) + if (H5Pset_metadata_read_attempts(fapl, 9) < 0) FAIL_STACK_ERROR /* Open the file with SWMR access and fapl (non-default & set to 9) */ - if((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) + if ((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file's fapl -- should be 9 */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != 9) + if (attempts != 9) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Test 4 */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Set the # of read attempts */ - if(H5Pset_metadata_read_attempts(fapl, 1) < 0) + if (H5Pset_metadata_read_attempts(fapl, 1) < 0) FAIL_STACK_ERROR /* Open the file with SWMR access and fapl (non-default & set to 1) */ - if((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) + if ((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file fapl -- should be 1 */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != 1) + if (attempts != 1) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Test 5 */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Open the file with SWMR_READ and fapl (non-default read attempts but unset) */ - if((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) + if ((fid = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* @@ -394,241 +394,241 @@ test_metadata_read_attempts(hid_t in_fapl) */ /* Test 1 */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create a file with non-SWMR access and default read attempts */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Test 2 */ /* Open the file with non-SWMR access and default fapl */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_METADATA_READ_ATTEMPTS) + if (attempts != H5F_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Test 3 */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the # of read attempts */ - if(H5Pset_metadata_read_attempts(fapl, 9) < 0) + if (H5Pset_metadata_read_attempts(fapl, 9) < 0) FAIL_STACK_ERROR /* Open the file with non-SWMR access and fapl (non-default & set to 9) */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file's fapl -- should be 9 */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != 9) + if (attempts != 9) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Test 4 */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the # of read attempts */ - if(H5Pset_metadata_read_attempts(fapl, 1) < 0) + if (H5Pset_metadata_read_attempts(fapl, 1) < 0) FAIL_STACK_ERROR /* Open the file with non-SWMR access and fapl (non-default & set to 1) */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file fapl -- should be 1 */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != 1) + if (attempts != 1) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Test 5 */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Open the file with non-SWMR_READ and fapl (non-default but unset) */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_METADATA_READ_ATTEMPTS) + if (attempts != H5F_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Set the # of read attempts */ - if(H5Pset_metadata_read_attempts(fapl, 9) < 0) + if (H5Pset_metadata_read_attempts(fapl, 9) < 0) FAIL_STACK_ERROR /* Create a file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Open file again with non-SWMR access and default fapl */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_METADATA_READ_ATTEMPTS) + if (attempts != H5F_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Open file again with SWMR access and default read attempts */ - if((fid = H5Fopen(filename, H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -640,85 +640,85 @@ test_metadata_read_attempts(hid_t in_fapl) */ /* Create a file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Open file again with SWMR access and default read attempts */ - if((fid1 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid1 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Set the # of read attempts */ - if(H5Pset_metadata_read_attempts(fapl, 9) < 0) + if (H5Pset_metadata_read_attempts(fapl, 9) < 0) FAIL_STACK_ERROR /* Open file again with SWMR access and fapl (non-default & set to 9) */ - if((fid2 = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) + if ((fid2 = H5Fopen(filename, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Re-open fid1 */ - if((fid = H5Freopen(fid1)) < 0) + if ((fid = H5Freopen(fid1)) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Re-open fid2 */ - if((fid = H5Freopen(fid2)) < 0) + if ((fid = H5Freopen(fid2)) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS, not 9 */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close all the files */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* @@ -730,110 +730,111 @@ test_metadata_read_attempts(hid_t in_fapl) */ /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create a file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Open file again with non-SWMR access and default fapl */ - if((fid1 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get a copy of the parameter fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the # of read attempts */ - if(H5Pset_metadata_read_attempts(fapl, 9) < 0) + if (H5Pset_metadata_read_attempts(fapl, 9) < 0) FAIL_STACK_ERROR /* Open file again with non-SWMR access and fapl (non-default & set to 9) */ - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Close fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR /* Re-open fid1 */ - if((fid = H5Freopen(fid1)) < 0) + if ((fid = H5Freopen(fid1)) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_METADATA_READ_ATTEMPTS) + if (attempts != H5F_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Re-open fid2 */ - if((fid = H5Freopen(fid2)) < 0) + if ((fid = H5Freopen(fid2)) < 0) FAIL_STACK_ERROR /* Get file's fapl */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR - if(attempts != H5F_METADATA_READ_ATTEMPTS) + if (attempts != H5F_METADATA_READ_ATTEMPTS) TEST_ERROR /* Close the file's fapl */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close all the files */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(file_fapl); H5Fclose(fid); H5Fclose(fid1); H5Fclose(fid2); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /* test_metadata_read_attempts() */ /* @@ -846,80 +847,80 @@ error: static int test_metadata_read_retry_info(hid_t in_fapl) { - hid_t fapl, new_fapl; /* File access property list */ - hid_t fid, fid1; /* File IDs */ - H5F_retry_info_t info, info1; /* The collection of metadata retries */ - H5F_t *f = NULL, *f1 = NULL; /* Internal file object pointers */ - unsigned i, j, n; /* Local index variables */ - hid_t did1, did2; /* Dataset IDs */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataset creation property list */ - hsize_t dims[2] = {6, 10}; /* Dataset dimensions */ - char filename[NAME_BUF_SIZE]; /* File name */ - int buf[6][10], chkbuf1[6][10], chkbuf2[6][10]; /* Buffers for data */ - hsize_t max_dims_1un[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Dataset maximum dimensions */ - hsize_t max_dims_2un[2] = {500, H5S_UNLIMITED}; /* Dataset maximum dimensions */ - hsize_t chunk_dims[2] = {2, 2}; /* Chunk dimensions */ + hid_t fapl, new_fapl; /* File access property list */ + hid_t fid, fid1; /* File IDs */ + H5F_retry_info_t info, info1; /* The collection of metadata retries */ + H5F_t * f = NULL, *f1 = NULL; /* Internal file object pointers */ + unsigned i, j, n; /* Local index variables */ + hid_t did1, did2; /* Dataset IDs */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataset creation property list */ + hsize_t dims[2] = {6, 10}; /* Dataset dimensions */ + char filename[NAME_BUF_SIZE]; /* File name */ + int buf[6][10], chkbuf1[6][10], chkbuf2[6][10]; /* Buffers for data */ + hsize_t max_dims_1un[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Dataset maximum dimensions */ + hsize_t max_dims_2un[2] = {500, H5S_UNLIMITED}; /* Dataset maximum dimensions */ + hsize_t chunk_dims[2] = {2, 2}; /* Chunk dimensions */ /* Output message about test being performed */ TESTING("H5Fset_metadata_read_retry_info()"); /* Get a copy of the parameter in_fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create a file without SWMR access */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create a chunked dataset with 1 unlimited dimension: extensible array indexing will be used */ - if((sid = H5Screate_simple(2, dims, max_dims_1un)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims_1un)) < 0) FAIL_STACK_ERROR - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR - if((did1 = H5Dcreate2(fid, "DSET_1UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, "DSET_1UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create a chunked dataset with 2 unlimited dimension: v2 Btree indexing will be used */ - if((sid = H5Screate_simple(2, dims, max_dims_2un)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims_2un)) < 0) FAIL_STACK_ERROR - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR - if((did2 = H5Dcreate2(fid, "DSET_2UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, "DSET_2UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize buffer data */ - for(i = n = 0; i < 6; i++) - for(j = 0; j < 10; j++) - buf[i][j] = (int)n++; + for (i = n = 0; i < 6; i++) + for (j = 0; j < 10; j++) + buf[i][j] = (int)n++; /* Write to the 2 datasets */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) FAIL_STACK_ERROR - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) FAIL_STACK_ERROR /* Closing */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -931,68 +932,67 @@ test_metadata_read_retry_info(hid_t in_fapl) * info.retries should all be NULL */ /* Open the file without SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Open the dataset */ - if((did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1) < 0) + if (H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1) < 0) FAIL_STACK_ERROR /* Open the dataset */ - if((did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2) < 0) + if (H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2) < 0) FAIL_STACK_ERROR /* Retrieve retries information */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Should be 0 */ - if(info.nbins != 0) + if (info.nbins != 0) TEST_ERROR /* Should be all NULL */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) TEST_ERROR /* Closing */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - /* * Open a file with SWMR access, default # of read attempts-- * info.nbins should be 2 * info.retries should all be NULL */ /* Open the file with SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Retrieve retries information */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Should be 2 */ - if(info.nbins != 2) + if (info.nbins != 2) TEST_ERROR /* Should be all NULL */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) TEST_ERROR /* Closing */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -1000,33 +1000,33 @@ test_metadata_read_retry_info(hid_t in_fapl) * info.nbins should be 1 * info.retries should all be NULL */ - if((new_fapl = H5Pcopy(fapl)) < 0) + if ((new_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR - if(H5Pset_metadata_read_attempts(new_fapl, 10) < 0) + if (H5Pset_metadata_read_attempts(new_fapl, 10) < 0) FAIL_STACK_ERROR /* Open the file with SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, new_fapl)) < 0) FAIL_STACK_ERROR /* Retrieve retry information */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Should be 1 */ - if(info.nbins != 1) + if (info.nbins != 1) TEST_ERROR /* Should be all NULL */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) TEST_ERROR /* Closing */ - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -1034,32 +1034,32 @@ test_metadata_read_retry_info(hid_t in_fapl) * info.nbins should be 3 * info.retries should all be NULL */ - if((new_fapl = H5Pcopy(fapl)) < 0) + if ((new_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR - if(H5Pset_metadata_read_attempts(new_fapl, 101) < 0) + if (H5Pset_metadata_read_attempts(new_fapl, 101) < 0) FAIL_STACK_ERROR /* Open the file with SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, new_fapl)) < 0) FAIL_STACK_ERROR /* Retrieve retry information */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Should be 3 */ - if(info.nbins != 3) + if (info.nbins != 3) TEST_ERROR /* Should be all NULL */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) TEST_ERROR /* Closing */ - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -1067,33 +1067,33 @@ test_metadata_read_retry_info(hid_t in_fapl) * info.nbins should be 4 * info.retries should all be NULL */ - if((new_fapl = H5Pcopy(fapl)) < 0) + if ((new_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR - if(H5Pset_metadata_read_attempts(new_fapl, 10000) < 0) + if (H5Pset_metadata_read_attempts(new_fapl, 10000) < 0) FAIL_STACK_ERROR /* Open the file with SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, new_fapl)) < 0) FAIL_STACK_ERROR /* Retrieve retry information */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Should be 4 */ - if(info.nbins != 4) + if (info.nbins != 4) TEST_ERROR /* Should be all NULL */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) TEST_ERROR /* Closing */ - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -1101,75 +1101,74 @@ test_metadata_read_retry_info(hid_t in_fapl) * info.nbins should be 0 * info.retries should all be NULL */ - if((new_fapl = H5Pcopy(fapl)) < 0) + if ((new_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR - if(H5Pset_metadata_read_attempts(new_fapl, 1) < 0) + if (H5Pset_metadata_read_attempts(new_fapl, 1) < 0) FAIL_STACK_ERROR /* Open the file with SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, new_fapl)) < 0) FAIL_STACK_ERROR /* Retrieve retry information */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Should be 0 */ - if(info.nbins != 0) + if (info.nbins != 0) TEST_ERROR /* Should be all NULL */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) TEST_ERROR /* Closing */ - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - /* * Case 2: tests on retries info */ /* Open the file with SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Open the dataset */ - if((did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Read data from the dataset */ - if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1) < 0) + if (H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1) < 0) FAIL_STACK_ERROR /* Open the dataset */ - if((did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Read data from the dataset */ - if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2) < 0) + if (H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2) < 0) FAIL_STACK_ERROR /* Retrieve retry information */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Should be 2 */ - if(info.nbins != 2) + if (info.nbins != 2) TEST_ERROR /* Should be all NULL */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) TEST_ERROR /* Get a pointer to the internal file object */ - if((f = (H5F_t *)H5VL_object(fid)) == NULL) + if ((f = (H5F_t *)H5VL_object(fid)) == NULL) FAIL_STACK_ERROR /* @@ -1180,45 +1179,45 @@ test_metadata_read_retry_info(hid_t in_fapl) */ /* v2 B-tree leaf node: log retry 99 for 500 times */ - for(i = 0; i < 500; i++) { - if(H5F_track_metadata_read_retries(f, H5AC_BT2_LEAF_ID, 99) < 0) + for (i = 0; i < 500; i++) { + if (H5F_track_metadata_read_retries(f, H5AC_BT2_LEAF_ID, 99) < 0) FAIL_STACK_ERROR } /* Extensive array data block: log retry 10 for 1000 times */ - for(i = 0; i < 1000; i++) - if(H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 10) < 0) + for (i = 0; i < 1000; i++) + if (H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 10) < 0) FAIL_STACK_ERROR /* File's superblock: log retry 1 for 1 time */ - if(H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0) + if (H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0) FAIL_STACK_ERROR /* Retrieve the collection of metadata read retries */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Verify retries for v2 B-tree leaf node */ - if(info.retries[4][0] != 0) + if (info.retries[4][0] != 0) TEST_ERROR - if(info.retries[4][1] != 500) + if (info.retries[4][1] != 500) TEST_ERROR /* Verify retries for extensive array data block */ - if(info.retries[15][0] != 0) + if (info.retries[15][0] != 0) TEST_ERROR - if(info.retries[15][1] != 1000) + if (info.retries[15][1] != 1000) TEST_ERROR /* Verify retries for file's superblock */ - if(info.retries[20][0] != 1) + if (info.retries[20][0] != 1) TEST_ERROR - if(info.retries[20][1] != 0) + if (info.retries[20][1] != 0) TEST_ERROR /* Free memory for info.retries */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { + if (info.retries[i] != NULL) H5free_memory(info.retries[i]); } @@ -1231,145 +1230,145 @@ test_metadata_read_retry_info(hid_t in_fapl) */ /* Object header: log retry 5 for 5 times */ - for(i = 0; i < 5; i++) { - if(H5F_track_metadata_read_retries(f, H5AC_OHDR_ID, 5) < 0) + for (i = 0; i < 5; i++) { + if (H5F_track_metadata_read_retries(f, H5AC_OHDR_ID, 5) < 0) TEST_ERROR } /* Extensive array data block: log retry 4 for 1 time */ - if(H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 4) < 0) + if (H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 4) < 0) TEST_ERROR /* Fixed array header : log retry 50 for 10000 times */ - for(i = 0; i < 10000; i++) { - if(H5F_track_metadata_read_retries(f, H5AC_FARRAY_HDR_ID, 50) < 0) + for (i = 0; i < 10000; i++) { + if (H5F_track_metadata_read_retries(f, H5AC_FARRAY_HDR_ID, 50) < 0) TEST_ERROR } /* File's superblock: log retry 1 for 1 more time */ - if(H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0) + if (H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0) FAIL_STACK_ERROR /* Retrieve the collection of metadata read retries */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* * Verify info has both previous + current retries information: */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { - switch(i) { + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { + switch (i) { case 0: /* Object header */ - if(info.retries[i][0] != 5) + if (info.retries[i][0] != 5) TEST_ERROR - if(info.retries[i][1] != 0) + if (info.retries[i][1] != 0) TEST_ERROR break; case 4: /* v2 B-tree leaf node */ - if(info.retries[i][0] != 0) + if (info.retries[i][0] != 0) TEST_ERROR - if(info.retries[i][1] != 500) + if (info.retries[i][1] != 500) TEST_ERROR break; case 15: /* Extensive array data block */ - if(info.retries[i][0] != 1) + if (info.retries[i][0] != 1) TEST_ERROR - if(info.retries[i][1] != 1000) + if (info.retries[i][1] != 1000) TEST_ERROR break; case 17: /* Fixed array header */ - if(info.retries[i][0] != 0) + if (info.retries[i][0] != 0) TEST_ERROR - if(info.retries[i][1] != 10000) + if (info.retries[i][1] != 10000) TEST_ERROR break; case 20: /* File's superblock */ - if(info.retries[i][0] != 2) + if (info.retries[i][0] != 2) TEST_ERROR - if(info.retries[i][1] != 0) + if (info.retries[i][1] != 0) TEST_ERROR break; default: - if(info.retries[i] != NULL) + if (info.retries[i] != NULL) TEST_ERROR break; } } /* Free memory for info.retries */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) H5free_memory(info.retries[i]); /* Closing */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Get a copy of the file access property list */ - if((new_fapl = H5Pcopy(fapl)) < 0) + if ((new_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR /* Set the number of metadata read attempts to 101 */ - if(H5Pset_metadata_read_attempts(new_fapl, 101) < 0) + if (H5Pset_metadata_read_attempts(new_fapl, 101) < 0) FAIL_STACK_ERROR /* Open the file with SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, new_fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if((f = (H5F_t *)H5VL_object(fid)) == NULL) + if ((f = (H5F_t *)H5VL_object(fid)) == NULL) FAIL_STACK_ERROR /* File's superblock: log retry 1 for 1 time */ - if(H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0) + if (H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1) < 0) FAIL_STACK_ERROR /* Retrieve the collection of metadata read retries */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Should be 3 */ - if(info.nbins != 3) + if (info.nbins != 3) TEST_ERROR /* Verify retries info */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { - switch(i) { + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { + switch (i) { case 20: /* File's superblock */ - if(info.retries[i][0] != 1) + if (info.retries[i][0] != 1) TEST_ERROR - if(info.retries[i][1] != 0) + if (info.retries[i][1] != 0) TEST_ERROR - if(info.retries[i][2] != 0) + if (info.retries[i][2] != 0) TEST_ERROR break; default: - if(info.retries[i] != NULL) + if (info.retries[i] != NULL) TEST_ERROR break; } } /* Free memory */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) H5free_memory(info.retries[i]); /* Closing */ - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -1385,39 +1384,39 @@ test_metadata_read_retry_info(hid_t in_fapl) * retries should all be NULL */ /* Open the file without SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Re-open fid */ - if((fid1 = H5Freopen(fid)) < 0) + if ((fid1 = H5Freopen(fid)) < 0) FAIL_STACK_ERROR /* Retrieve retries information for fid */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Retrieve retries information for fid1*/ - if(H5Fget_metadata_read_retry_info(fid1, &info1)< 0) + if (H5Fget_metadata_read_retry_info(fid1, &info1) < 0) FAIL_STACK_ERROR /* Should be 0 */ - if(info.nbins != 0) + if (info.nbins != 0) TEST_ERROR - if(info1.nbins != 0) + if (info1.nbins != 0) TEST_ERROR /* Should be all NULL */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { + if (info.retries[i] != NULL) TEST_ERROR - if(info1.retries[i] != NULL) + if (info1.retries[i] != NULL) TEST_ERROR } /* Closing */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR /* @@ -1427,95 +1426,96 @@ test_metadata_read_retry_info(hid_t in_fapl) * --increment retries for metadata item: free-space sections (retries[9][1])-- */ /* Open the file with SWMR access */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object for fid */ - if((f = (H5F_t *)H5VL_object(fid)) == NULL) + if ((f = (H5F_t *)H5VL_object(fid)) == NULL) FAIL_STACK_ERROR /* Re-open fid */ - if((fid1 = H5Freopen(fid)) < 0) + if ((fid1 = H5Freopen(fid)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object for fid1 */ - if((f1 = (H5F_t *)H5VL_object(fid1)) == NULL) + if ((f1 = (H5F_t *)H5VL_object(fid1)) == NULL) FAIL_STACK_ERROR /* For fid: fixed array data block page--log retry 9 for 500 times */ - for(i = 0; i < 500; i++) { - if(H5F_track_metadata_read_retries(f, H5AC_FARRAY_DBLK_PAGE_ID, 9) < 0) + for (i = 0; i < 500; i++) { + if (H5F_track_metadata_read_retries(f, H5AC_FARRAY_DBLK_PAGE_ID, 9) < 0) FAIL_STACK_ERROR } /* For fid1: free-space sections--log retry 99 for 1000 times */ - for(i = 0; i < 1000; i++) { - if(H5F_track_metadata_read_retries(f1, H5AC_FSPACE_SINFO_ID, 99) < 0) + for (i = 0; i < 1000; i++) { + if (H5F_track_metadata_read_retries(f1, H5AC_FSPACE_SINFO_ID, 99) < 0) FAIL_STACK_ERROR } /* Retrieve the collection of metadata read retries for fid */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) FAIL_STACK_ERROR /* Retrieve the collection of metadata read retries for fid1 */ - if(H5Fget_metadata_read_retry_info(fid1, &info1) < 0) + if (H5Fget_metadata_read_retry_info(fid1, &info1) < 0) FAIL_STACK_ERROR /* Verify nbins for fid & fid1: should be 2 */ - if(info.nbins != 2) + if (info.nbins != 2) TEST_ERROR - if(info1.nbins != 2) + if (info1.nbins != 2) TEST_ERROR /* Verify retries for fid: fixed array data block page */ - if(info.retries[19][0] != 500) + if (info.retries[19][0] != 500) TEST_ERROR - if(info.retries[19][1] != 0) + if (info.retries[19][1] != 0) TEST_ERROR /* Verify retries for fid: free-space sections */ /* (Since file was re-opened) */ - if(info.retries[9][0] != 0) + if (info.retries[9][0] != 0) TEST_ERROR - if(info.retries[9][1] != 1000) + if (info.retries[9][1] != 1000) TEST_ERROR /* Verify retries for fid1: free-space sections */ - if(info1.retries[9][0] != 0) + if (info1.retries[9][0] != 0) TEST_ERROR - if(info1.retries[9][1] != 1000) + if (info1.retries[9][1] != 1000) TEST_ERROR /* Verify retries for fid1: fixed array data block page */ /* (Since file was re-opened) */ - if(info1.retries[19][0] != 500) + if (info1.retries[19][0] != 500) TEST_ERROR - if(info1.retries[19][1] != 0) + if (info1.retries[19][1] != 0) TEST_ERROR /* Free memory for info.retries and info1.retries */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { + if (info.retries[i] != NULL) H5free_memory(info.retries[i]); - if(info1.retries[i] != NULL) + if (info1.retries[i] != NULL) H5free_memory(info1.retries[i]); } /* end for */ /* Closing */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(new_fapl); H5Dclose(did1); @@ -1524,14 +1524,13 @@ error: H5Pclose(dcpl); H5Fclose(fid); H5Fclose(fid1); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_metadata_read_retry_info() */ - - /* * Tests for H5Fstart_swmr_write() */ @@ -1567,39 +1566,39 @@ error: static int test_start_swmr_write(hid_t in_fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property */ - hid_t gid = -1; /* Group ID */ - hid_t dcpl = -1; /* Dataset creation property */ - hid_t file_fapl = -1; /* File access property for the file */ - hid_t did1 = -1, did2 = -1, did3 = -1; /* Dataset IDs */ - hid_t did1_a = -1, did1_b = -1; - hid_t sid1 = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ - hsize_t dim[1] = {1}; /* Dimension sizes */ - hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dim[1] = {2}; /* Chunk dimension sizes */ - hsize_t dim2[2] = {5, 10}; /* Dimension sizes */ - hsize_t max_dim2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dim2[2] = {2, 7}; /* Chunk dimension sizes */ - H5D_chunk_index_t idx_type; /* Dataset chunk index type */ - int wdata = 99; /* Data to write */ - int rdata; /* Data read */ - unsigned attempts; /* The retrieved # of read attempts */ - char filename[NAME_BUF_SIZE]; /* File name */ - herr_t ret; /* Return value */ - + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property */ + hid_t gid = -1; /* Group ID */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t file_fapl = -1; /* File access property for the file */ + hid_t did1 = -1, did2 = -1, did3 = -1; /* Dataset IDs */ + hid_t did1_a = -1, did1_b = -1; + hid_t sid1 = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ + hsize_t dim[1] = {1}; /* Dimension sizes */ + hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dim[1] = {2}; /* Chunk dimension sizes */ + hsize_t dim2[2] = {5, 10}; /* Dimension sizes */ + hsize_t max_dim2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dim2[2] = {2, 7}; /* Chunk dimension sizes */ + H5D_chunk_index_t idx_type; /* Dataset chunk index type */ + int wdata = 99; /* Data to write */ + int rdata; /* Data read */ + unsigned attempts; /* The retrieved # of read attempts */ + char filename[NAME_BUF_SIZE]; /* File name */ + herr_t ret; /* Return value */ /* Get a copy of the parameter fapl (non-latest-format) */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR - if(new_format) { + if (new_format) { TESTING("H5Fstart_swmr_write() when creating/opening a file with latest format"); - /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - FAIL_STACK_ERROR - } else { + /* Set to use the latest library format */ + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + } + else { TESTING("H5Fstart_swmr_write() when creating/opening a file without latest format"); } /* end if */ @@ -1611,89 +1610,94 @@ test_start_swmr_write(hid_t in_fapl, hbool_t new_format) */ /* Create the file with SWMR write + non-latest-format */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, + fapl)) < 0) FAIL_STACK_ERROR /* Get the file's access_property list */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts from the file's fapl */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR /* Should be 100 */ - if(attempts != (new_format ? H5F_METADATA_READ_ATTEMPTS : H5F_SWMR_METADATA_READ_ATTEMPTS)) + if (attempts != (new_format ? H5F_METADATA_READ_ATTEMPTS : H5F_SWMR_METADATA_READ_ATTEMPTS)) TEST_ERROR; /* Close the property list */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR /* Create "dataset1" */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 1, chunk_dim) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dim) < 0) FAIL_STACK_ERROR - if((sid1 = H5Screate_simple(1, dim, max_dim)) < 0) + if ((sid1 = H5Screate_simple(1, dim, max_dim)) < 0) FAIL_STACK_ERROR; - if((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Get the chunk index type */ - if(H5D__layout_idx_type_test(did1, &idx_type) < 0) + if (H5D__layout_idx_type_test(did1, &idx_type) < 0) FAIL_STACK_ERROR; - if(idx_type != H5D_CHUNK_IDX_EARRAY) + if (idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index"); /* Write to the dataset */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR for non-latest-format */ /* Should succeed in enabling SWMR for latest format */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(new_format) { - if(ret < 0) TEST_ERROR - } else if(ret >= 0) + } + H5E_END_TRY; + if (new_format) { + if (ret < 0) + TEST_ERROR + } + else if (ret >= 0) TEST_ERROR /* Read from the dataset */ - if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + if (H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) FAIL_STACK_ERROR; /* Verify the data is correct */ - if(wdata != rdata) + if (wdata != rdata) TEST_ERROR /* Close "dataset1", dataspace, dataset creation property list */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid1) < 0) + if (H5Sclose(sid1) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; /* Get the file's access_property list */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR /* Should be 100 */ - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR; /* Close the file access property list */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* @@ -1701,151 +1705,151 @@ test_start_swmr_write(hid_t in_fapl, hbool_t new_format) */ /* Open the file again with write + non-latest-format */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Get the file's access_property list */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR /* Should be 1 */ - if(attempts != H5F_METADATA_READ_ATTEMPTS) + if (attempts != H5F_METADATA_READ_ATTEMPTS) TEST_ERROR; /* Close the property list */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR; /* open "dataset1", keep it open */ - if((did1 = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* open "dataset1" second time */ - if((did1_a = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) + if ((did1_a = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* open "dataset1" third time */ - if((did1_b = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) + if ((did1_b = H5Dopen2(fid, "dataset1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Write to "dataset1" */ wdata = 88; - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) FAIL_STACK_ERROR; /* Create a group */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create "dataset2" in the group, keep it open */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunk_dim2) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dim2) < 0) FAIL_STACK_ERROR - if((sid2 = H5Screate_simple(2, dim2, max_dim2)) < 0) + if ((sid2 = H5Screate_simple(2, dim2, max_dim2)) < 0) FAIL_STACK_ERROR; - if((did2 = H5Dcreate2(gid, "dataset2", H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, "dataset2", H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Get the chunk index type for "dataset2" */ - if(H5D__layout_idx_type_test(did2, &idx_type) < 0) + if (H5D__layout_idx_type_test(did2, &idx_type) < 0) FAIL_STACK_ERROR; - if(idx_type != H5D_CHUNK_IDX_BT2) + if (idx_type != H5D_CHUNK_IDX_BT2) FAIL_PUTS_ERROR("should be using v2 B-tree chunk indexing"); /* Should succeed in enabling SWMR writing */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) FAIL_STACK_ERROR; /* Get the file's access_property list */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR /* Retrieve the # of read attempts */ - if(H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) + if (H5Pget_metadata_read_attempts(file_fapl, &attempts) < 0) FAIL_STACK_ERROR /* Should be 100 */ - if(attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) + if (attempts != H5F_SWMR_METADATA_READ_ATTEMPTS) TEST_ERROR; /* Close the property list */ - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR; rdata = 0; /* Read from "dataset1" via did1_b (multiple opens) */ - if(H5Dread(did1_b, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + if (H5Dread(did1_b, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) FAIL_STACK_ERROR; - if(wdata != rdata) + if (wdata != rdata) FAIL_STACK_ERROR; - if(H5Dclose(did1_b) < 0) + if (H5Dclose(did1_b) < 0) FAIL_STACK_ERROR; /* Read from "dataset1" */ rdata = 0; - if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + if (H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) FAIL_STACK_ERROR; - if(wdata != rdata) + if (wdata != rdata) FAIL_STACK_ERROR; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; rdata = 0; /* Read from "dataset1" via did1_a (multiple opens) */ - if(H5Dread(did1_a, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + if (H5Dread(did1_a, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) FAIL_STACK_ERROR; - if(wdata != rdata) + if (wdata != rdata) FAIL_STACK_ERROR; - if(H5Dclose(did1_a) < 0) + if (H5Dclose(did1_a) < 0) FAIL_STACK_ERROR; /* Close "dataset2", dataspace, dataset creation property list */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid2) < 0) + if (H5Sclose(sid2) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; /* Create "dataset3" */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunk_dim2) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dim2) < 0) FAIL_STACK_ERROR - if((sid3 = H5Screate_simple(2, dim2, max_dim2)) < 0) + if ((sid3 = H5Screate_simple(2, dim2, max_dim2)) < 0) FAIL_STACK_ERROR; - if((did3 = H5Dcreate2(fid, "dataset3", H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did3 = H5Dcreate2(fid, "dataset3", H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Get the chunk index type for "dataset3" */ - if(H5D__layout_idx_type_test(did3, &idx_type) < 0) + if (H5D__layout_idx_type_test(did3, &idx_type) < 0) FAIL_STACK_ERROR; - if(idx_type != H5D_CHUNK_IDX_BT2) + if (idx_type != H5D_CHUNK_IDX_BT2) FAIL_PUTS_ERROR("should be using v2 B-tree as index"); /* Close "dataset3", dataspace, dataset creation property list */ - if(H5Dclose(did3) < 0) + if (H5Dclose(did3) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid3) < 0) + if (H5Sclose(sid3) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) FAIL_STACK_ERROR; /* Close the file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; PASSED(); @@ -1853,7 +1857,8 @@ test_start_swmr_write(hid_t in_fapl, hbool_t new_format) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fapl); H5Pclose(file_fapl); @@ -1867,7 +1872,8 @@ error: H5Sclose(sid1); H5Sclose(sid2); H5Sclose(sid3); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_start_swmr_write() */ @@ -1928,42 +1934,42 @@ error: static int test_err_start_swmr_write(hid_t in_fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t fid2 = -1; /* File ID */ - hid_t fapl = -1; /* A copy of file access property */ - hid_t new_fapl = -1; /* A copy of file access property */ - hid_t gid = -1; /* Group ID */ - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t bad_fid = -1; /* Test fid (should never represent a real ID) */ - herr_t ret; /* Return value */ - char filename[NAME_BUF_SIZE]; /* File name */ + hid_t fid = -1; /* File ID */ + hid_t fid2 = -1; /* File ID */ + hid_t fapl = -1; /* A copy of file access property */ + hid_t new_fapl = -1; /* A copy of file access property */ + hid_t gid = -1; /* Group ID */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t bad_fid = -1; /* Test fid (should never represent a real ID) */ + herr_t ret; /* Return value */ + char filename[NAME_BUF_SIZE]; /* File name */ /* Create a copy of the input parameter in_fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR - if((new_fapl = H5Pcopy(in_fapl)) < 0) + if ((new_fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use the latest library format */ - if(H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR - if(new_format) { + if (new_format) { TESTING("H5Fstart_swmr_write() on failure conditions for latest format"); - if((fapl = H5Pcopy(new_fapl)) < 0) - FAIL_STACK_ERROR - } else { + if ((fapl = H5Pcopy(new_fapl)) < 0) + FAIL_STACK_ERROR + } + else { TESTING("H5Fstart_swmr_write() on failure conditions for without latest format"); } /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - /* * (A) When creating a file: */ @@ -1971,65 +1977,71 @@ test_err_start_swmr_write(hid_t in_fapl, hbool_t new_format) /* Case 1 */ /* Create the file with SWMR_WRITE + with/without latest format */ - fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl); + fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl); /* Should fail to enable SWMR writing when the file is already in SWMR writing mode */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Case 2 */ - if(new_format) { + if (new_format) { /* Create the file with write + latest format */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create and commit a named datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR; - if(H5Tcommit2(fid, "TID", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(fid, "TID", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR writing when there is an opened named datatype */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the datatype */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) FAIL_STACK_ERROR; /* Should succeed in enabling SWMR writing */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) TEST_ERROR; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - - } else { + } + else { /* Create a file with write + non-latest-format */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Should fail to enable SWMR writing because the file's superblock version is not at least 3 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; } /* end if */ @@ -2038,117 +2050,126 @@ test_err_start_swmr_write(hid_t in_fapl, hbool_t new_format) */ /* Create a file with write + latest format */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, new_fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, new_fapl)) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Case 1 */ /* Open the file with SWMR write + with/without latest format */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR writing when the file is already in SWMR writing mode */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Case 2 */ /* Open the file with read only access + with/without latest format */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR writing when the file is opened with read only access */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Case 3 */ /* Open the file file with SWMR read access + with/without latest format */ - if((fid = H5Fopen(filename, H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR writing when the file is opened with SWMR read access only */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Case 4 */ /* Open the file with write + with/without latest format */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Create and commit a named datatype */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR; - if(H5Tcommit2(fid, "TID", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(fid, "TID", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; /* Create dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR; /* Attach an attribute to the named datatype */ - if((aid = H5Acreate2(tid, "attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(tid, "attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR writing when there are opened named datatype and attribute */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the datatype */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) FAIL_STACK_ERROR; /* Still fail to enable SWMR writing when the attribute is still opened */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) FAIL_STACK_ERROR; /* Should succeed in enabling SWMR writing */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) TEST_ERROR; /* Close the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - /* * (C) Failure cases for multiple opens */ @@ -2156,163 +2177,179 @@ test_err_start_swmr_write(hid_t in_fapl, hbool_t new_format) /* Case 1 */ /* Create a file with write + with/without latest format */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, + fapl)) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Open the file with write + with/without latest format */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Should succeed in enabling SWMR writing mode */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) TEST_ERROR /* Should fail for a second call to enable SWMR writing mode */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - /* Case 2 */ /* Open the file with write + with/without latest format */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Should succeed in enabling SWMR writing mode */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) TEST_ERROR /* Re-open the same file */ - if((fid2 = H5Freopen(fid)) < 0) + if ((fid2 = H5Freopen(fid)) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR writing mode for fid2 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid2); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the files */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Case 3 */ /* Open the file with write + with/without latest format */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Open the same file */ - if((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Should succeed in enabling SWMR writing for fid */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) TEST_ERROR /* Should fail to enable SWMR writing for fid2 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid2); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Close the files */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; - if(!new_format) { + if (!new_format) { /* * (D) When opening a file which is created without the latest format: */ - /* Create a file with write + without latest format */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Create a file with write + without latest format */ + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Case 1 */ - /* Should fail to open the file with SWMR write + latest format due to superblock version not at least 3 */ - H5E_BEGIN_TRY { - bad_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, new_fapl); - } H5E_END_TRY; - if(bad_fid >= 0) + /* Should fail to open the file with SWMR write + latest format due to superblock version not at least + * 3 */ + H5E_BEGIN_TRY + { + bad_fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, new_fapl); + } + H5E_END_TRY; + if (bad_fid >= 0) TEST_ERROR /* Case 2 */ - /* Should fail to open the file with SWMR write + non-latest-format due to superblock version not at least 3 */ - H5E_BEGIN_TRY { - bad_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; - if(bad_fid >= 0) + /* Should fail to open the file with SWMR write + non-latest-format due to superblock version not at + * least 3 */ + H5E_BEGIN_TRY + { + bad_fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; + if (bad_fid >= 0) TEST_ERROR /* Case 3 */ /* Open the file with write + latest format */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, new_fapl)) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR writing due to superblock version not at least 3 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - /* Case 4 */ /* Open the file with write + non-latest-format */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Should fail to enable SWMR writing because the file's superblock version is not at least 3 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fstart_swmr_write(fid); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; } /* not new */ /* Close the file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Gclose(gid); H5Dclose(did); @@ -2324,7 +2361,8 @@ error: * It never needs to be closed in the normal case. */ H5Fclose(bad_fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_err_start_swmr_write() */ @@ -2364,81 +2402,83 @@ test_start_swmr_write_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t H5_ATTR_UNUSE return 0; } /* test_start_swmr_write_concur() */ -#else /* defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID) */ +#else /* defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID) */ static int test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) { - hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ - hid_t fapl; /* File access property list */ - pid_t childpid=0; /* Child process ID */ - pid_t tmppid; /* Child process ID returned by waitpid */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int child_exit_val; /* Exit status of the child */ - char filename[NAME_BUF_SIZE]; /* File name */ - - hid_t did = -1, did1 = -1, did2 = -1, did3 = -1; - hid_t sid = -1; - hid_t dcpl = -1; + hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ + hid_t fapl; /* File access property list */ + pid_t childpid = 0; /* Child process ID */ + pid_t tmppid; /* Child process ID returned by waitpid */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + char filename[NAME_BUF_SIZE]; /* File name */ + + hid_t did = -1, did1 = -1, did2 = -1, did3 = -1; + hid_t sid = -1; + hid_t dcpl = -1; hsize_t chunk_dims[1] = {1}; - hsize_t maxdims[1] = {H5S_UNLIMITED}; - hsize_t dims[1] = {1}; - int wdata = 0; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t dims[1] = {1}; + int wdata = 0; int out_pdf[2]; int in_pdf[2]; int notify = 0; /* Output message about test being performed */ - if(new_format) { + if (new_format) { TESTING("H5Fstart_swmr_write()--concurrent access for latest format"); - } else { + } + else { TESTING("H5Fstart_swmr_write()--concurrent access for non-latest-format"); } /* end if */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if(new_format) { + if (new_format) { /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - } else { + } + else { /* Create the test file without latest format but with SWMR write */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR } /* end if */ - /* Create a chunked dataset with 1 extendible dimension */ - if((sid = H5Screate_simple(1, dims, maxdims)) < 0) + /* Create a chunked dataset with 1 extendible dimension */ + if ((sid = H5Screate_simple(1, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dims) < 0) FAIL_STACK_ERROR; - if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* @@ -2448,67 +2488,70 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) */ /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + int child_notify = 0; - /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + /* Close unused write end for out_pdf */ + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { /* Open the test file */ - fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; - if(fid >= 0) + fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; + if (fid >= 0) HDexit(EXIT_FAILURE); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) - HDexit(EXIT_FAILURE); + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else /* child process terminated abnormally */ + } + else /* child process terminated abnormally */ TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -2518,264 +2561,267 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) */ /* Create 2 pipes */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR - if(HDpipe(in_pdf) < 0) + if (HDpipe(in_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid1 = -1, child_fid2; /* File IDs */ - hid_t child_did1 = -1, child_did2 = -1; /* Dataset IDs */ - int child_notify = 0; - int rdata = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid1 = -1, child_fid2; /* File IDs */ + hid_t child_did1 = -1, child_did2 = -1; /* Dataset IDs */ + int child_notify = 0; + int rdata = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); - /* close unused read end for in_pdf */ - if(HDclose(in_pdf[0]) < 0) + /* close unused read end for in_pdf */ + if (HDclose(in_pdf[0]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Should succeed in opening the test file 2 times */ - if((child_fid1 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((child_fid1 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) HDexit(EXIT_FAILURE); - if((child_fid2 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((child_fid2 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) HDexit(EXIT_FAILURE); - /* open "dataset" 2 times */ - if((child_did1 = H5Dopen2(child_fid1, "dataset", H5P_DEFAULT)) < 0) + /* open "dataset" 2 times */ + if ((child_did1 = H5Dopen2(child_fid1, "dataset", H5P_DEFAULT)) < 0) HDexit(EXIT_FAILURE); - if((child_did2 = H5Dopen2(child_fid2, "dataset", H5P_DEFAULT)) < 0) + if ((child_did2 = H5Dopen2(child_fid2, "dataset", H5P_DEFAULT)) < 0) HDexit(EXIT_FAILURE); - /* Read from "dataset" via child_did1 */ - rdata = 0; - if(H5Dread(child_did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + /* Read from "dataset" via child_did1 */ + rdata = 0; + if (H5Dread(child_did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) HDexit(EXIT_FAILURE); - if(rdata != 88) + if (rdata != 88) HDexit(EXIT_FAILURE); - /* Notify parent process */ + /* Notify parent process */ child_notify = 2; - if(HDwrite(in_pdf[1], &child_notify, sizeof(int)) < 0) - HDexit(EXIT_FAILURE); + if (HDwrite(in_pdf[1], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 3) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 3) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } - /* Refresh "dataset" via child_did2 */ - if(H5Drefresh(child_did2) < 0) + /* Refresh "dataset" via child_did2 */ + if (H5Drefresh(child_did2) < 0) HDexit(EXIT_FAILURE); - /* Read from "dataset" child_did2 */ - rdata = 0; - if(H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + /* Read from "dataset" child_did2 */ + rdata = 0; + if (H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) HDexit(EXIT_FAILURE); - if(rdata != 99) + if (rdata != 99) HDexit(EXIT_FAILURE); - /* Read from "dataset" child_did1 */ - rdata = 0; - if(H5Dread(child_did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) + /* Read from "dataset" child_did1 */ + rdata = 0; + if (H5Dread(child_did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) HDexit(EXIT_FAILURE); - if(rdata != 99) + if (rdata != 99) HDexit(EXIT_FAILURE); - /* Close the dataset */ - if(H5Dclose(child_did1)) + /* Close the dataset */ + if (H5Dclose(child_did1)) HDexit(EXIT_FAILURE); - if(H5Dclose(child_did2)) + if (H5Dclose(child_did2)) HDexit(EXIT_FAILURE); - /* Close the file */ - if(H5Fclose(child_fid1) < 0) + /* Close the file */ + if (H5Fclose(child_fid1) < 0) HDexit(EXIT_FAILURE); - if(H5Fclose(child_fid2) < 0) + if (H5Fclose(child_fid2) < 0) HDexit(EXIT_FAILURE); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) - HDexit(EXIT_FAILURE); - if(HDclose(in_pdf[1]) < 0) - HDexit(EXIT_FAILURE); + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); + if (HDclose(in_pdf[1]) < 0) + HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Close unused write end for in_pdf */ - if(HDclose(in_pdf[1]) < 0) + if (HDclose(in_pdf[1]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* open "dataset", keep it open */ - if((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((did3 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + if ((did3 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - /* Write to "dataset" */ + /* Write to "dataset" */ wdata = 88; - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) FAIL_STACK_ERROR; /* Flush to disk */ - if(H5Fflush(fid1, H5F_SCOPE_LOCAL) < 0) + if (H5Fflush(fid1, H5F_SCOPE_LOCAL) < 0) FAIL_STACK_ERROR; /* Enable SWMR writing mode */ - if(H5Fstart_swmr_write(fid1) < 0) + if (H5Fstart_swmr_write(fid1) < 0) TEST_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Wait for notification from child process */ - while(notify != 2) { - if(HDread(in_pdf[0], ¬ify, sizeof(int)) < 0) + while (notify != 2) { + if (HDread(in_pdf[0], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; } - /* Write to "dataset" */ + /* Write to "dataset" */ wdata = 99; - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) FAIL_STACK_ERROR; /* Flush to disk */ - if(H5Fflush(fid1, H5F_SCOPE_LOCAL) < 0) + if (H5Fflush(fid1, H5F_SCOPE_LOCAL) < 0) FAIL_STACK_ERROR; /* Notify child process */ notify = 3; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the dataset */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR - if(H5Dclose(did3) < 0) + if (H5Dclose(did3) < 0) FAIL_STACK_ERROR /* Close the pipes */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; - if(HDclose(in_pdf[0]) < 0) + if (HDclose(in_pdf[0]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else /* Child process terminated abnormally */ + } + else /* Child process terminated abnormally */ TEST_ERROR /* Close the file */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR - /* * Case (3): * Verify concurrent file open with H5F_ACC_RDONLY * will fail with H5Fstart_swmr_write() */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + int child_notify = 0; - /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + /* Close unused write end for out_pdf */ + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Should fail in opening the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; - if(fid >= 0) + } + H5E_END_TRY; + if (fid >= 0) HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* end if */ /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Enable SWMR writing mode */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) TEST_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else /* Child process terminated abnormally */ + } + else /* Child process terminated abnormally */ TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -2785,74 +2831,77 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + int child_notify = 0; - /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + /* Close unused write end for out_pdf */ + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Should fail in opening the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(filename, H5F_ACC_RDWR, fapl); - } H5E_END_TRY; - if(fid >= 0) + } + H5E_END_TRY; + if (fid >= 0) HDexit(EXIT_FAILURE); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) - HDexit(EXIT_FAILURE); + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* end if */ /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Enable SWMR writing mode */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) TEST_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else /* Child process terminated abnormally */ + } + else /* Child process terminated abnormally */ TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -2862,90 +2911,95 @@ test_start_swmr_write_concur(hid_t in_fapl, hbool_t new_format) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + int child_notify = 0; - /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + /* Close unused write end for out_pdf */ + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Should fail in opening the test file */ - H5E_BEGIN_TRY { - fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; - if(fid >= 0) + H5E_BEGIN_TRY + { + fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; + if (fid >= 0) HDexit(EXIT_FAILURE); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) - HDexit(EXIT_FAILURE); + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Enable SWMR writing mode */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) TEST_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else /* Child process terminated abnormally */ + } + else /* Child process terminated abnormally */ TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Pclose(dcpl); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; @@ -2962,20 +3016,20 @@ error: static int test_start_swmr_write_stress_ohdr(hid_t in_fapl) { - hid_t fid = -1; /* File IDs */ - hid_t fapl; /* File access property list */ - char filename[NAME_BUF_SIZE]; /* File name */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t aid = -1; /* Attribute ID */ - hsize_t chunk_dims[2] = {10, 10}; - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - char fill[256]; /* Fill value for dataset */ - char attr_data[32]; /* Data value for attribute */ - hsize_t dims[2] = {1,1}; - unsigned chunk_num; /* Object header chunk # for dataspace message */ + hid_t fid = -1; /* File IDs */ + hid_t fapl; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* File name */ + hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t aid = -1; /* Attribute ID */ + hsize_t chunk_dims[2] = {10, 10}; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + char fill[256]; /* Fill value for dataset */ + char attr_data[32]; /* Data value for attribute */ + hsize_t dims[2] = {1, 1}; + unsigned chunk_num; /* Object header chunk # for dataspace message */ /* Output message about test being performed */ TESTING("H5Fstart_swmr_write()--stress object header messages"); @@ -2984,122 +3038,123 @@ test_start_swmr_write_stress_ohdr(hid_t in_fapl) HDmemset(fill, 0, sizeof(fill)); HDmemset(attr_data, 0, sizeof(attr_data)); - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(1, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((tid = H5Tcopy(H5T_C_S1)) < 0) + if ((tid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR; - if(H5Tset_size(tid, 256) < 0) + if (H5Tset_size(tid, 256) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dims) < 0) FAIL_STACK_ERROR; - if(H5Pset_fill_value(dcpl, tid, &fill) < 0) + if (H5Pset_fill_value(dcpl, tid, &fill) < 0) FAIL_STACK_ERROR; - if((did = H5Dcreate2(fid, "dataset", tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dataset", tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Retrieve the chunk # for the dataspace message */ chunk_num = UINT_MAX; - if(H5O__msg_get_chunkno_test(did, H5O_SDSPACE_ID, &chunk_num) < 0) + if (H5O__msg_get_chunkno_test(did, H5O_SDSPACE_ID, &chunk_num) < 0) FAIL_STACK_ERROR; /* Should be in chunk #0 for now */ - if(0 != chunk_num) + if (0 != chunk_num) TEST_ERROR; /* Create a second chunked dataset with 2 extendible dimensions */ /* (So that the original dataset's object header can't be extended) */ - if((sid = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(1, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((tid = H5Tcopy(H5T_C_S1)) < 0) + if ((tid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR; - if(H5Tset_size(tid, 256) < 0) + if (H5Tset_size(tid, 256) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dims) < 0) FAIL_STACK_ERROR; - if(H5Pset_fill_value(dcpl, tid, &fill) < 0) + if (H5Pset_fill_value(dcpl, tid, &fill) < 0) FAIL_STACK_ERROR; - if((did2 = H5Dcreate2(fid, "dataset2", tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, "dataset2", tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Close the second dataset */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR /* Close the objects for the dataset creation */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR /* Create attribute on original dataset, to push dataspace header message out of header chunk #0 */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR; - if((tid = H5Tcopy(H5T_C_S1)) < 0) + if ((tid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR; - if(H5Tset_size(tid, 32) < 0) + if (H5Tset_size(tid, 32) < 0) FAIL_STACK_ERROR; - if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) FAIL_STACK_ERROR; - if((aid = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if(H5Awrite(aid, tid, attr_data) < 0) + if (H5Awrite(aid, tid, attr_data) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) FAIL_STACK_ERROR - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) FAIL_STACK_ERROR /* Retrieve the chunk # for the dataspace message */ chunk_num = UINT_MAX; - if(H5O__msg_get_chunkno_test(did, H5O_SDSPACE_ID, &chunk_num) < 0) + if (H5O__msg_get_chunkno_test(did, H5O_SDSPACE_ID, &chunk_num) < 0) FAIL_STACK_ERROR; /* Should be in chunk #0 for now */ - if(1 != chunk_num) + if (1 != chunk_num) TEST_ERROR; /* Enable SWMR write */ - if(H5Fstart_swmr_write(fid) < 0) + if (H5Fstart_swmr_write(fid) < 0) FAIL_STACK_ERROR; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the FAPL */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(aid); H5Sclose(tid); H5Sclose(sid); @@ -3108,7 +3163,8 @@ error: H5Pclose(dcpl); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_start_swmr_write_stress_ohdr() */ @@ -3121,7 +3177,7 @@ error: static herr_t flush_cb(hid_t H5_ATTR_UNUSED obj_id, void *_udata) { - unsigned *flush_ct = (unsigned*)_udata; + unsigned *flush_ct = (unsigned *)_udata; ++(*flush_ct); return 0; } @@ -3145,20 +3201,20 @@ flush_cb(hid_t H5_ATTR_UNUSED obj_id, void *_udata) static int test_object_flush_cb(hid_t in_fapl) { - hid_t fapl = -1; /* A copy of file access property list */ - hid_t ffapl = -1; /* A file's file access property list */ - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t did1 = -1, did2 = -1; /* Dataset IDs */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t dims[2] = {5, 10}; /* Dataset dimension sizes */ - int buf[50]; /* Data buffer */ - H5F_flush_cb_t ret_cb; /* The callback function set in object flush property */ - void *ret_ct; /* The user data set in object flush property */ - unsigned flush_ct = 0; /* The user data for object flush property */ - char filename[NAME_BUF_SIZE]; /* File name */ - int i; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fapl = -1; /* A copy of file access property list */ + hid_t ffapl = -1; /* A file's file access property list */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t did1 = -1, did2 = -1; /* Dataset IDs */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dims[2] = {5, 10}; /* Dataset dimension sizes */ + int buf[50]; /* Data buffer */ + H5F_flush_cb_t ret_cb; /* The callback function set in object flush property */ + void * ret_ct; /* The user data set in object flush property */ + unsigned flush_ct = 0; /* The user data for object flush property */ + char filename[NAME_BUF_SIZE]; /* File name */ + int i; /* Local index variable */ + herr_t ret; /* Generic return value */ TESTING("H5Pget/set_obj_flush_cb()"); @@ -3167,10 +3223,12 @@ test_object_flush_cb(hid_t in_fapl) * To verify the failure condition in setting object flush property */ /* Should fail if the callback function is not defined but user data is defined */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_object_flush_cb(fapl, NULL, &flush_ct); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* @@ -3180,14 +3238,14 @@ test_object_flush_cb(hid_t in_fapl) */ /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR /* Retrieve object flush property values for the default file access property list */ - if(H5Pget_object_flush_cb(fapl, &ret_cb, &ret_ct) < 0) + if (H5Pget_object_flush_cb(fapl, &ret_cb, &ret_ct) < 0) TEST_ERROR /* Should be null */ - if(ret_cb != NULL || ret_ct != NULL) + if (ret_cb != NULL || ret_ct != NULL) TEST_ERROR /* @@ -3196,22 +3254,22 @@ test_object_flush_cb(hid_t in_fapl) * non-default file access property list. */ /* Set the object flush property */ - if(H5Pset_object_flush_cb(fapl, flush_cb, &flush_ct) < 0) + if (H5Pset_object_flush_cb(fapl, flush_cb, &flush_ct) < 0) TEST_ERROR /* Increment the counter */ ++flush_ct; /* Retrieve object flush property values for the non-default file access property list */ - if(H5Pget_object_flush_cb(fapl, &ret_cb, &ret_ct) < 0) + if (H5Pget_object_flush_cb(fapl, &ret_cb, &ret_ct) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != flush_cb || *(unsigned *)ret_ct != 1) + if (ret_cb != flush_cb || *(unsigned *)ret_ct != 1) TEST_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; /* @@ -3222,40 +3280,40 @@ test_object_flush_cb(hid_t in_fapl) /* Reset values */ flush_ct = 0; - ret_cb = NULL; - ret_ct = NULL; + ret_cb = NULL; + ret_ct = NULL; /* Make a copy of the input parameter in_fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the test file: without setting object flush property in fapl */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Retrieve the object flush property values */ - if(H5Pget_object_flush_cb(ffapl, &ret_cb, &ret_ct) < 0) + if (H5Pget_object_flush_cb(ffapl, &ret_cb, &ret_ct) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != NULL || ret_ct != NULL) + if (ret_cb != NULL || ret_ct != NULL) TEST_ERROR /* Closing */ - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* @@ -3267,95 +3325,95 @@ test_object_flush_cb(hid_t in_fapl) */ /* Reset values */ flush_ct = 0; - ret_cb = NULL; - ret_ct = NULL; + ret_cb = NULL; + ret_ct = NULL; /* Set the object flush property */ - if(H5Pset_object_flush_cb(fapl, flush_cb, &flush_ct) < 0) + if (H5Pset_object_flush_cb(fapl, flush_cb, &flush_ct) < 0) FAIL_STACK_ERROR /* Open the test file: with object flush property setting in fapl */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Create a dataset */ - if((sid = H5Screate_simple(2, dims, dims)) < 0) + if ((sid = H5Screate_simple(2, dims, dims)) < 0) FAIL_STACK_ERROR; /* Create a dataset */ - if((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Initialize data buffer */ - for(i = 0; i < 50; i++) - buf[i] = i + 1; + for (i = 0; i < 50; i++) + buf[i] = i + 1; /* Write to the dataset */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) FAIL_STACK_ERROR; /* Flush the dataset object */ - if(H5Oflush(did1) < 0) + if (H5Oflush(did1) < 0) FAIL_STACK_ERROR; /* Get the file's file access property list */ - if((ffapl = H5Fget_access_plist(fid)) < 0) + if ((ffapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Retrieve the object flush property values */ - if(H5Pget_object_flush_cb(ffapl, &ret_cb, &ret_ct) < 0) + if (H5Pget_object_flush_cb(ffapl, &ret_cb, &ret_ct) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != flush_cb || *(unsigned *)ret_ct != 1) + if (ret_cb != flush_cb || *(unsigned *)ret_ct != 1) TEST_ERROR /* Create a group */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Flush the group */ - if(H5Gflush(gid) < 0) + if (H5Gflush(gid) < 0) TEST_ERROR /* Retrieve the object flush property values */ - if(H5Pget_object_flush_cb(ffapl, &ret_cb, &ret_ct) < 0) + if (H5Pget_object_flush_cb(ffapl, &ret_cb, &ret_ct) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != flush_cb || *(unsigned *)ret_ct != 2) + if (ret_cb != flush_cb || *(unsigned *)ret_ct != 2) TEST_ERROR /* Create a dataset */ - if((did2 = H5Dcreate2(gid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Flush the dataset */ - if(H5Dflush(did2) < 0) + if (H5Dflush(did2) < 0) FAIL_STACK_ERROR; /* Retrieve the object flush property values */ - if(H5Pget_object_flush_cb(ffapl, &ret_cb, &ret_ct) < 0) + if (H5Pget_object_flush_cb(ffapl, &ret_cb, &ret_ct) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != flush_cb || *(unsigned *)ret_ct != 3) + if (ret_cb != flush_cb || *(unsigned *)ret_ct != 3) TEST_ERROR /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(ffapl) < 0) + if (H5Pclose(ffapl) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; PASSED(); @@ -3363,7 +3421,8 @@ test_object_flush_cb(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(ffapl); H5Sclose(sid); @@ -3371,7 +3430,8 @@ error: H5Dclose(did2); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_object_flush_cb() */ @@ -3380,7 +3440,6 @@ error: * Tests for H5Pset/get_append_flush() */ - /* The callback function for append flush property */ static herr_t append_cb(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void *_udata) @@ -3390,7 +3449,6 @@ append_cb(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void * return 0; } /* append_cb() */ - /* The callback function for append flush property */ static herr_t append_cb2(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void *_udata) @@ -3400,8 +3458,6 @@ append_cb2(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void return 0; } /* append_cb2() */ - - /* * test_append_flush_generic() * @@ -3423,17 +3479,16 @@ append_cb2(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void static int test_append_flush_generic(void) { - hid_t dapl = -1; /* A copy of dataset access property */ - hsize_t boundary[3]; /* The boundary for append flush property */ - unsigned count = 0; /* The user data for append flush property */ - hsize_t ret_boundary[3]; /* The boundary set in append flush property */ - H5D_append_cb_t ret_cb; /* The callback function set in append flush property */ - unsigned *ret_count; /* The user data set in append flush property */ - herr_t ret; /* The return value */ + hid_t dapl = -1; /* A copy of dataset access property */ + hsize_t boundary[3]; /* The boundary for append flush property */ + unsigned count = 0; /* The user data for append flush property */ + hsize_t ret_boundary[3]; /* The boundary set in append flush property */ + H5D_append_cb_t ret_cb; /* The callback function set in append flush property */ + unsigned * ret_count; /* The user data set in append flush property */ + herr_t ret; /* The return value */ TESTING("H5Fget/set_append_flush() for a generic dataset access property list"); - /* * Case (1) * To verify the retrieved append flush property values: @@ -3441,21 +3496,21 @@ test_append_flush_generic(void) */ /* Create a copy of dataset access property list */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(dapl, 2, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(dapl, 2, ret_boundary, &ret_cb, (void **)&ret_count) < 0) FAIL_STACK_ERROR /* Verify expected values */ - if(ret_boundary[0] != 0 || ret_boundary[1] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 0) TEST_ERROR; - if(ret_cb != NULL || ret_count != NULL) + if (ret_cb != NULL || ret_count != NULL) TEST_ERROR /* Close the property list */ - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; /* @@ -3468,28 +3523,34 @@ test_append_flush_generic(void) */ /* Create a copy of dataset access property list */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR /* Invalid dataset rank: zero value */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_append_flush(dapl, 0, NULL, NULL, &count); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Invalid dataset rank: > H5S_MAX_RANK */ - H5E_BEGIN_TRY { - ret = H5Pset_append_flush(dapl, H5S_MAX_RANK+1, NULL, NULL, &count); - } H5E_END_TRY; - if(ret >= 0) + H5E_BEGIN_TRY + { + ret = H5Pset_append_flush(dapl, H5S_MAX_RANK + 1, NULL, NULL, &count); + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* No boundary specified */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_append_flush(dapl, 2, NULL, NULL, &count); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Set up a valid boundary */ @@ -3497,28 +3558,34 @@ test_append_flush_generic(void) boundary[1] = 1; /* Undefined callback function but defined user data */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_append_flush(dapl, 2, boundary, NULL, &count); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Invalid boundary size: negative value */ boundary[0] = (hsize_t)-1; boundary[1] = 1; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_append_flush(dapl, 2, boundary, append_cb, &count); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Invalid boundary size: H5S_UNLIMITED */ boundary[0] = 1; boundary[1] = H5S_UNLIMITED; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_append_flush(dapl, 2, boundary, append_cb, &count); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* @@ -3529,29 +3596,29 @@ test_append_flush_generic(void) * -- the # of boundary sizes retrieved does not exceed MIN(input ndims, the ndims set) */ boundary[0] = boundary[1] = 1; - boundary[2] = 0; - count = 1; - if(H5Pset_append_flush(dapl, 2, boundary, append_cb, &count) < 0) + boundary[2] = 0; + count = 1; + if (H5Pset_append_flush(dapl, 2, boundary, append_cb, &count) < 0) FAIL_STACK_ERROR; ++count; /* Verify expected values: with boundary rank > set boundary rank */ - if(H5Pget_append_flush(dapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(dapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR - if(ret_boundary[0] != 1 || ret_boundary[1] != 1 || boundary[2] != 0) + if (ret_boundary[0] != 1 || ret_boundary[1] != 1 || boundary[2] != 0) TEST_ERROR; - if(ret_cb == NULL || ret_count == NULL || *ret_count != 2) + if (ret_cb == NULL || ret_count == NULL || *ret_count != 2) TEST_ERROR /* Verify expected values: with boundary rank < set boundary rank */ HDmemset(ret_boundary, 0, sizeof(ret_boundary)); - if(H5Pget_append_flush(dapl, 1, ret_boundary, NULL, NULL) < 0) + if (H5Pget_append_flush(dapl, 1, ret_boundary, NULL, NULL) < 0) TEST_ERROR - if(ret_boundary[0] != 1 || ret_boundary[1] != 0 || boundary[2] != 0) + if (ret_boundary[0] != 1 || ret_boundary[1] != 0 || boundary[2] != 0) TEST_ERROR; /* Closing */ - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -3559,9 +3626,11 @@ test_append_flush_generic(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_append_flush_generic() */ @@ -3585,26 +3654,26 @@ error: static int test_append_flush_dataset_chunked(hid_t in_fapl) { - hid_t fid = -1; /* file ID */ + hid_t fid = -1; /* file ID */ hid_t fapl = -1; /* A copy of file access property */ - hid_t did1 = -1, did2 = -1; /* The datset ID */ - hid_t sid = -1; /* The dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ + hid_t did1 = -1, did2 = -1; /* The datset ID */ + hid_t sid = -1; /* The dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ hid_t ddapl = -1; /* The dataset access property of the opened dataset */ - hsize_t boundary[3]; /* Boundary size */ - unsigned count = 0; /* User data */ + hsize_t boundary[3]; /* Boundary size */ + unsigned count = 0; /* User data */ - hsize_t ret_boundary[3]; /* Boundary size set in the append flush property */ - H5D_append_cb_t ret_cb; /* The callback function set in the append flush property */ - unsigned *ret_count; /* The user data set in the append flush property */ + hsize_t ret_boundary[3]; /* Boundary size set in the append flush property */ + H5D_append_cb_t ret_cb; /* The callback function set in the append flush property */ + unsigned * ret_count; /* The user data set in the append flush property */ - char filename[NAME_BUF_SIZE]; /* file name */ + char filename[NAME_BUF_SIZE]; /* file name */ - hsize_t dims[2] = {100, 0}; /* The dataset dimension sizes */ - hsize_t maxdims[2] = {100, H5S_UNLIMITED}; /* The dataset maximum dimension sizes */ - hsize_t chunk_dims[2] = {5,2}; /* The chunk dimesion sizes */ + hsize_t dims[2] = {100, 0}; /* The dataset dimension sizes */ + hsize_t maxdims[2] = {100, H5S_UNLIMITED}; /* The dataset maximum dimension sizes */ + hsize_t chunk_dims[2] = {5, 2}; /* The chunk dimesion sizes */ TESTING("H5Fget/set_append_flush() for a chunked dataset's access property list"); @@ -3617,47 +3686,46 @@ test_append_flush_dataset_chunked(hid_t in_fapl) */ /* Get a copy of the input parameter in_fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR - /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the test file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create a chunked dataset with 1 extendible dimension */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; - if((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Get the dataset's access property list */ - if((ddapl = H5Dget_access_plist(did1)) < 0) + if ((ddapl = H5Dget_access_plist(did1)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values */ - if(ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) TEST_ERROR; - if(ret_cb != NULL || ret_count != NULL) + if (ret_cb != NULL || ret_count != NULL) TEST_ERROR /* Close the dataset's access property list */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; /* @@ -3670,44 +3738,50 @@ test_append_flush_dataset_chunked(hid_t in_fapl) * -- boundary (non-zero) is set for a non-extendible dimension */ /* Create a copy of dataset access property list */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR /* Set boundary dimension rank > the rank of dataset to be created */ HDmemset(boundary, 0, sizeof(boundary)); - if(H5Pset_append_flush(dapl, 3, boundary, NULL, NULL) < 0) + if (H5Pset_append_flush(dapl, 3, boundary, NULL, NULL) < 0) FAIL_STACK_ERROR /* Should fail to Create the dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did2 = H5Dcreate2(fid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl); - } H5E_END_TRY; - if(did2 >= 0) + } + H5E_END_TRY; + if (did2 >= 0) TEST_ERROR /* Set boundary for a non-extendible dimension */ boundary[0] = boundary[1] = 1; - if(H5Pset_append_flush(dapl, 2, boundary, NULL, NULL) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, NULL, NULL) < 0) FAIL_STACK_ERROR /* Should fail to create the dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did2 = H5Dcreate2(fid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl); - } H5E_END_TRY; - if(did2 >= 0) + } + H5E_END_TRY; + if (did2 >= 0) TEST_ERROR /* Create and close the dataset */ - if((did2 = H5Dcreate2(fid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; /* Should fail to open the dataset */ - H5E_BEGIN_TRY { - did2 = H5Dopen2(fid, "dataset2", dapl); - } H5E_END_TRY; - if(did2 >= 0) + H5E_BEGIN_TRY + { + did2 = H5Dopen2(fid, "dataset2", dapl); + } + H5E_END_TRY; + if (did2 >= 0) TEST_ERROR /* @@ -3721,52 +3795,52 @@ test_append_flush_dataset_chunked(hid_t in_fapl) boundary[0] = 0; boundary[1] = 1; - if(H5Pset_append_flush(dapl, 2, boundary, append_cb, &count) < 0) + if (H5Pset_append_flush(dapl, 2, boundary, append_cb, &count) < 0) FAIL_STACK_ERROR - if((did2 = H5Dopen2(fid, "dataset2", dapl)) < 0) + if ((did2 = H5Dopen2(fid, "dataset2", dapl)) < 0) FAIL_STACK_ERROR /* Get the dataset's access property list */ - if((ddapl = H5Dget_access_plist(did2)) < 0) + if ((ddapl = H5Dget_access_plist(did2)) < 0) FAIL_STACK_ERROR HDmemset(ret_boundary, 0, sizeof(ret_boundary)); - ret_cb = NULL; + ret_cb = NULL; ret_count = NULL; /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != append_cb || ret_count != &count) + if (ret_cb != append_cb || ret_count != &count) TEST_ERROR - if(ret_boundary[0] != 0 || ret_boundary[1] != 1 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 1 || ret_boundary[2] != 0) TEST_ERROR HDmemset(ret_boundary, 0, sizeof(ret_boundary)); /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 1, ret_boundary, NULL, NULL) < 0) + if (H5Pget_append_flush(ddapl, 1, ret_boundary, NULL, NULL) < 0) TEST_ERROR - if(ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) TEST_ERROR /* Closing */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; PASSED(); @@ -3774,7 +3848,8 @@ test_append_flush_dataset_chunked(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(dapl); H5Pclose(ddapl); @@ -3783,7 +3858,8 @@ error: H5Pclose(fapl); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_append_flush_dataset_chunked() */ @@ -3801,21 +3877,21 @@ error: static int test_append_flush_dataset_fixed(hid_t in_fapl) { - hid_t fid = -1; /* file ID */ + hid_t fid = -1; /* file ID */ hid_t fapl = -1; /* A copy of file access property */ - hid_t did1 = -1, did2 = -1; /* The datset ID */ - hid_t sid = -1; /* The dataspace ID */ - hid_t dapl = -1; /* A copy of dataset access property */ + hid_t did1 = -1, did2 = -1; /* The datset ID */ + hid_t sid = -1; /* The dataspace ID */ + hid_t dapl = -1; /* A copy of dataset access property */ hid_t ddapl = -1; /* The dataset access property of the opened dataset */ - hsize_t boundary[3]; /* Boundary size */ - unsigned count = 0; /* User data */ + hsize_t boundary[3]; /* Boundary size */ + unsigned count = 0; /* User data */ - hsize_t ret_boundary[3]; /* Boundary size set in the append flush property */ - H5D_append_cb_t ret_cb; /* The callback function set in the append flush property */ - unsigned *ret_count; /* The user data set in the append flush property */ + hsize_t ret_boundary[3]; /* Boundary size set in the append flush property */ + H5D_append_cb_t ret_cb; /* The callback function set in the append flush property */ + unsigned * ret_count; /* The user data set in the append flush property */ - char filename[NAME_BUF_SIZE]; /* file name */ + char filename[NAME_BUF_SIZE]; /* file name */ hsize_t dims[1] = {100}; @@ -3830,43 +3906,42 @@ test_append_flush_dataset_fixed(hid_t in_fapl) */ /* Get a copy of the input parameter in_fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR - /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the test file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create a dataset */ - if((sid = H5Screate_simple(1, dims, dims)) < 0) + if ((sid = H5Screate_simple(1, dims, dims)) < 0) FAIL_STACK_ERROR; - if((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Get the dataset's access property list */ - if((ddapl = H5Dget_access_plist(did1)) < 0) + if ((ddapl = H5Dget_access_plist(did1)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values */ - if(ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) TEST_ERROR; - if(ret_cb != NULL || ret_count != NULL) + if (ret_cb != NULL || ret_count != NULL) TEST_ERROR /* Close the dataset's access property list */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; /* @@ -3880,57 +3955,57 @@ test_append_flush_dataset_fixed(hid_t in_fapl) * zero boundary, null callback function, null user data */ /* Create a copy of dataset access property list */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR boundary[0] = 1; boundary[1] = boundary[2] = 0; - if(H5Pset_append_flush(dapl, 3, boundary, append_cb, &count) < 0) + if (H5Pset_append_flush(dapl, 3, boundary, append_cb, &count) < 0) FAIL_STACK_ERROR /* Should succeed to create the dataset: append flush property has no effect */ - if((did2 = H5Dcreate2(fid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, dapl)) < 0) + if ((did2 = H5Dcreate2(fid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, dapl)) < 0) TEST_ERROR /* Get the dataset's access property list */ - if((ddapl = H5Dget_access_plist(did2)) < 0) + if ((ddapl = H5Dget_access_plist(did2)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != NULL || ret_count != NULL) + if (ret_cb != NULL || ret_count != NULL) TEST_ERROR - if(ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) TEST_ERROR /* Closing */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; /* Should succeed in opening the dataset: append flush property has no effect */ - if((did2 = H5Dopen2(fid, "dataset2", dapl)) < 0) + if ((did2 = H5Dopen2(fid, "dataset2", dapl)) < 0) TEST_ERROR /* Get the dataset's access property list */ - if((ddapl = H5Dget_access_plist(did2)) < 0) + if ((ddapl = H5Dget_access_plist(did2)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != NULL || ret_count != NULL) + if (ret_cb != NULL || ret_count != NULL) TEST_ERROR - if(ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) TEST_ERROR - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR /* * Case (3)-- @@ -3941,39 +4016,39 @@ test_append_flush_dataset_fixed(hid_t in_fapl) */ HDmemset(boundary, 0, sizeof(boundary)); - if(H5Pset_append_flush(dapl, 1, boundary, append_cb, &count) < 0) + if (H5Pset_append_flush(dapl, 1, boundary, append_cb, &count) < 0) FAIL_STACK_ERROR - if((did2 = H5Dopen2(fid, "dataset2", dapl)) < 0) + if ((did2 = H5Dopen2(fid, "dataset2", dapl)) < 0) FAIL_STACK_ERROR /* Get the dataset's access property list */ - if((ddapl = H5Dget_access_plist(did2)) < 0) + if ((ddapl = H5Dget_access_plist(did2)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 1, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 1, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values */ - if(ret_cb != NULL || ret_count != NULL) + if (ret_cb != NULL || ret_count != NULL) TEST_ERROR - if(ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 0 || ret_boundary[2] != 0) TEST_ERROR /* Closing */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; PASSED(); @@ -3981,7 +4056,8 @@ test_append_flush_dataset_fixed(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dapl); H5Pclose(ddapl); H5Dclose(did1); @@ -3989,7 +4065,8 @@ error: H5Pclose(fapl); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_append_flush_dataset_fixed() */ @@ -4018,29 +4095,29 @@ error: static int test_append_flush_dataset_multiple(hid_t in_fapl) { - hid_t fid = -1; /* file ID */ + hid_t fid = -1; /* file ID */ hid_t fapl = -1; /* A copy of file access property */ - hid_t did1 = -1, did2 = -1; /* The datset ID */ - hid_t sid = -1; /* The dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t did1 = -1, did2 = -1; /* The datset ID */ + hid_t sid = -1; /* The dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ hid_t dapl1 = -1; /* A copy of dataset access property */ hid_t dapl2 = -1; /* A copy of dataset access property */ hid_t ddapl = -1; /* The dataset access property of the opened dataset */ - hsize_t boundary1[3]; /* Boundary size */ - hsize_t boundary2[3]; /* Boundary size */ - unsigned count1 = 0; /* User data */ - unsigned count2 = 0; /* User data */ + hsize_t boundary1[3]; /* Boundary size */ + hsize_t boundary2[3]; /* Boundary size */ + unsigned count1 = 0; /* User data */ + unsigned count2 = 0; /* User data */ - hsize_t ret_boundary[3]; /* Boundary size set in the append flush property */ - H5D_append_cb_t ret_cb; /* The callback function set in the append flush property */ - unsigned *ret_count; /* The user data set in the append flush property */ + hsize_t ret_boundary[3]; /* Boundary size set in the append flush property */ + H5D_append_cb_t ret_cb; /* The callback function set in the append flush property */ + unsigned * ret_count; /* The user data set in the append flush property */ - char filename[NAME_BUF_SIZE]; /* file name */ + char filename[NAME_BUF_SIZE]; /* file name */ - hsize_t dims[2] = {0, 0}; /* The dataset dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* The dataset maximum dimension sizes */ - hsize_t chunk_dims[2] = {5,2}; /* The chunk dimesion sizes */ + hsize_t dims[2] = {0, 0}; /* The dataset dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* The dataset maximum dimension sizes */ + hsize_t chunk_dims[2] = {5, 2}; /* The chunk dimesion sizes */ TESTING("H5Fget/set_append_flush() for multiple opens of a chunked dataset"); @@ -4055,85 +4132,85 @@ test_append_flush_dataset_multiple(hid_t in_fapl) */ /* Create a copy of dataset access property list */ - if((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR - if((dapl2 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl2 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR boundary1[0] = 0; boundary1[1] = 1; - count1 = 0; - if(H5Pset_append_flush(dapl1, 2, boundary1, append_cb, &count1) < 0) + count1 = 0; + if (H5Pset_append_flush(dapl1, 2, boundary1, append_cb, &count1) < 0) FAIL_STACK_ERROR boundary2[0] = 1; boundary2[1] = 0; - count2 = 0; - if(H5Pset_append_flush(dapl2, 2, boundary2, append_cb2, &count2) < 0) + count2 = 0; + if (H5Pset_append_flush(dapl2, 2, boundary2, append_cb2, &count2) < 0) FAIL_STACK_ERROR /* Get a copy of the input parameter in_fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Create the test file to work on */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; - if((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl1)) < 0) + if ((did1 = H5Dcreate2(fid, "dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl1)) < 0) FAIL_STACK_ERROR; /* Open the dataset */ - if((did2 = H5Dopen2(fid, "dataset1", dapl2)) < 0) + if ((did2 = H5Dopen2(fid, "dataset1", dapl2)) < 0) FAIL_STACK_ERROR; /* Get the dataset's access property list for did1 */ - if((ddapl = H5Dget_access_plist(did1)) < 0) + if ((ddapl = H5Dget_access_plist(did1)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values: should be the setting in dapl1 */ - if(ret_boundary[0] != 0 || ret_boundary[1] != 1 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 1 || ret_boundary[2] != 0) TEST_ERROR; - if(ret_cb != append_cb || ret_count != &count1) + if (ret_cb != append_cb || ret_count != &count1) TEST_ERROR /* Close the dataset's access property list */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; /* Get the dataset's access property list for did2 */ - if((ddapl = H5Dget_access_plist(did2)) < 0) + if ((ddapl = H5Dget_access_plist(did2)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values: should be the setting in dapl1 */ - if(ret_boundary[0] != 0 || ret_boundary[1] != 1 || ret_boundary[2] != 0) + if (ret_boundary[0] != 0 || ret_boundary[1] != 1 || ret_boundary[2] != 0) TEST_ERROR; - if(ret_cb != append_cb || ret_count != &count1) + if (ret_cb != append_cb || ret_count != &count1) TEST_ERROR /* Close the dataset's access property list */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; H5Dclose(did1); H5Dclose(did2); @@ -4149,70 +4226,69 @@ test_append_flush_dataset_multiple(hid_t in_fapl) * H5Pget_append_flush(did2, ...) * -- should return append flush property values set in dapl1 */ - if((did1 = H5Dcreate2(fid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, "dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; /* Open the dataset with append flush setting in dapl2 */ - if((did1 = H5Dopen2(fid, "dataset2", dapl2)) < 0) + if ((did1 = H5Dopen2(fid, "dataset2", dapl2)) < 0) FAIL_STACK_ERROR; /* Open the dataset with append flush setting in dapl1 */ - if((did2 = H5Dopen2(fid, "dataset2", dapl1)) < 0) + if ((did2 = H5Dopen2(fid, "dataset2", dapl1)) < 0) FAIL_STACK_ERROR; /* Get the dataset's access property list for did1 */ - if((ddapl = H5Dget_access_plist(did1)) < 0) + if ((ddapl = H5Dget_access_plist(did1)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values: should be the setting in dapl2 */ - if(ret_boundary[0] != 1 || ret_boundary[1] != 0 || ret_boundary[2] != 0) + if (ret_boundary[0] != 1 || ret_boundary[1] != 0 || ret_boundary[2] != 0) TEST_ERROR; - if(ret_cb != append_cb2 || ret_count != &count2) + if (ret_cb != append_cb2 || ret_count != &count2) TEST_ERROR /* Close the access property list */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; - /* Get the dataset's access property list for did2 */ - if((ddapl = H5Dget_access_plist(did2)) < 0) + if ((ddapl = H5Dget_access_plist(did2)) < 0) FAIL_STACK_ERROR /* Retrieve the append flush property values */ - if(H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) + if (H5Pget_append_flush(ddapl, 3, ret_boundary, &ret_cb, (void **)&ret_count) < 0) TEST_ERROR /* Verify expected values: should be the setting in dapl2 */ - if(ret_boundary[0] != 1 || ret_boundary[1] != 0 || ret_boundary[2] != 0) + if (ret_boundary[0] != 1 || ret_boundary[1] != 0 || ret_boundary[2] != 0) TEST_ERROR; - if(ret_cb != append_cb2 || ret_count != &count2) + if (ret_cb != append_cb2 || ret_count != &count2) TEST_ERROR /* Closing */ - if(H5Pclose(ddapl) < 0) + if (H5Pclose(ddapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl2) < 0) + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dapl1) < 0) + if (H5Pclose(dapl1) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; PASSED(); @@ -4220,7 +4296,8 @@ test_append_flush_dataset_multiple(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Pclose(dapl1); H5Pclose(dapl2); @@ -4230,13 +4307,12 @@ error: H5Pclose(fapl); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_append_flush_dataset_multiple() */ - - /**************************************************************** ** ** test_file_lock_same(): @@ -4248,15 +4324,15 @@ error: static int test_file_lock_same(hid_t in_fapl) { - hid_t fid = -1, fid2 = -1; /* File IDs */ - hid_t fapl = -1; /* File access property list */ - unsigned intent; /* File access flags */ - char filename[NAME_BUF_SIZE]; /* file name */ + hid_t fid = -1, fid2 = -1; /* File IDs */ + hid_t fapl = -1; /* File access property list */ + unsigned intent; /* File access flags */ + char filename[NAME_BUF_SIZE]; /* file name */ /* Output message about test being performed */ TESTING("File open with different combinations of flags--single process access"); - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ @@ -4266,122 +4342,124 @@ test_file_lock_same(hid_t in_fapl) * Case 1: 1) RDWR 2) RDWR : should succeed */ /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Get and check file intent */ - if(H5Fget_intent(fid, &intent) < 0) - FAIL_STACK_ERROR + if (H5Fget_intent(fid, &intent) < 0) + FAIL_STACK_ERROR - if(intent != H5F_ACC_RDWR) - TEST_ERROR + if (intent != H5F_ACC_RDWR) + TEST_ERROR /* Open the same file with RDWR */ - if((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Get and check the intent */ - if(H5Fget_intent(fid2, &intent) < 0) - FAIL_STACK_ERROR - if(intent != H5F_ACC_RDWR) - TEST_ERROR + if (H5Fget_intent(fid2, &intent) < 0) + FAIL_STACK_ERROR + if (intent != H5F_ACC_RDWR) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid2) < 0) + FAIL_STACK_ERROR /* * Case 2: 1) RDWR 2) RDONLY : should succeed */ /* Open file with RDWR */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Get and check the intent */ - if(H5Fget_intent(fid, &intent) < 0) - FAIL_STACK_ERROR - if(intent != H5F_ACC_RDWR) - TEST_ERROR + if (H5Fget_intent(fid, &intent) < 0) + FAIL_STACK_ERROR + if (intent != H5F_ACC_RDWR) + TEST_ERROR /* Open file with RDONLY */ - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Get and check the intent: should get intent from 1st open */ - if(H5Fget_intent(fid2, &intent) < 0) - FAIL_STACK_ERROR - if(intent != H5F_ACC_RDWR) - TEST_ERROR + if (H5Fget_intent(fid2, &intent) < 0) + FAIL_STACK_ERROR + if (intent != H5F_ACC_RDWR) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid2) < 0) + FAIL_STACK_ERROR /* * Case 3: 1) RDONLY 2) RDWR : should fail */ /* Open file with RDONLY */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Get and check the intent */ - if(H5Fget_intent(fid, &intent) < 0) - FAIL_STACK_ERROR - if(intent != H5F_ACC_RDONLY) - TEST_ERROR + if (H5Fget_intent(fid, &intent) < 0) + FAIL_STACK_ERROR + if (intent != H5F_ACC_RDONLY) + TEST_ERROR /* Open file with RDWR should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl); - } H5E_END_TRY; - if(fid2 >= 0) - TEST_ERROR + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR /* Close first file */ - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* * Case 4: 1) RDONLY 2) RDONLY : should succeed */ /* Open file with RDONLY */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Get and check the intent */ - if(H5Fget_intent(fid, &intent) < 0) - FAIL_STACK_ERROR - if(intent != H5F_ACC_RDONLY) - TEST_ERROR + if (H5Fget_intent(fid, &intent) < 0) + FAIL_STACK_ERROR + if (intent != H5F_ACC_RDONLY) + TEST_ERROR /* Open file with RDONLY */ - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Get and check the intent */ - if(H5Fget_intent(fid2, &intent) < 0) - FAIL_STACK_ERROR - if(intent != H5F_ACC_RDONLY) - TEST_ERROR + if (H5Fget_intent(fid2, &intent) < 0) + FAIL_STACK_ERROR + if (intent != H5F_ACC_RDONLY) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) - FAIL_STACK_ERROR + if (H5Fclose(fid2) < 0) + FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); @@ -4389,11 +4467,13 @@ test_file_lock_same(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { - H5Pclose(fapl); - H5Fclose(fid); - H5Fclose(fid2); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(fapl); + H5Fclose(fid); + H5Fclose(fid2); + } + H5E_END_TRY; return -1; } /* end test_file_lock_same() */ @@ -4409,30 +4489,30 @@ error: static int test_file_lock_swmr_same(hid_t in_fapl) { - hid_t fid, fid2; /* File IDs */ - hid_t fapl; /* File access property list */ - char filename[NAME_BUF_SIZE]; /* file name */ + hid_t fid, fid2; /* File IDs */ + hid_t fapl; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* file name */ /* Output message about test being performed */ TESTING("File open with different combinations of flags + SWMR flags--single process access"); /* Get a copy of the parameter in_fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create a file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -4442,38 +4522,46 @@ test_file_lock_swmr_same(hid_t in_fapl) /* * Case a: RDWR|SWRM_READ : should fail */ - H5E_BEGIN_TRY { - fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; - if(fid >= 0) - TEST_ERROR + H5E_BEGIN_TRY + { + fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; + if (fid >= 0) + TEST_ERROR /* * Case b: RDWR|SWMM_WRTE|SWMR_READ : should fail */ - H5E_BEGIN_TRY { - fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; - if(fid >= 0) - TEST_ERROR + H5E_BEGIN_TRY + { + fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; + if (fid >= 0) + TEST_ERROR /* * Case c: RDONLY|SWMM_WRITE : should fail */ - H5E_BEGIN_TRY { - fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; - if(fid >= 0) - TEST_ERROR + H5E_BEGIN_TRY + { + fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; + if (fid >= 0) + TEST_ERROR /* * Case d: RDONLY|SWMM_WRITE|SWMR_READ : should fail */ - H5E_BEGIN_TRY { - fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_WRITE|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; - if(fid >= 0) - TEST_ERROR + H5E_BEGIN_TRY + { + fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; + if (fid >= 0) + TEST_ERROR /* * Cases 1 - 12: combinations of different flags for 1st and 2nd opens @@ -4482,195 +4570,205 @@ test_file_lock_swmr_same(hid_t in_fapl) /* * Case 1: 1) RDWR 2) RDWR|SWMR_WRITE : should fail */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - fid2 = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; - if(fid2 >= 0) - TEST_ERROR + H5E_BEGIN_TRY + { + fid2 = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* * Case 2: 1) RDWR 2) RDONLY|SWMR_READ : should succeed */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - TEST_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) - TEST_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* * Case 3: 1) RDWR|SWMR_WRITE 2)RDWR : should succeed */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* * Case 4: 1) RDWR|SWMR_WRITE 2) RDWR|SWMR_WRITE : should succeed */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* * Case 5: 1) RDWR|SWMR_WRITE 2) RDONLY|SWMR_READ : should succeed */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* * Case 6: 1) RDWR|SWMR_WRITE 2) RDONLY : should succeed */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* * Case 7: 1) RDONLY|SWMR_READ 2)RDWR : should fail */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); - } H5E_END_TRY; - if(fid2 >= 0) - TEST_ERROR + H5E_BEGIN_TRY + { + fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* * Case 8: 1) RDONLY|SWMR_READ 2) RDWR|SWMR_WRITE : should fail */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - fid2 = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; - if(fid2 >= 0) - TEST_ERROR + H5E_BEGIN_TRY + { + fid2 = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* * Case 9: 1) RDONLY|SWMR_READ 2) RDONLY|SWMR_READ : should succeed */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* * Case 10: 1) RDONLY|SWMR_READ 2) RDONLY : should succeed */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) TEST_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* * Case 11: 1) RDONLY 2) RDWR|SWMR_WRITE: should fail */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - fid2 = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; - if(fid2 >= 0) - TEST_ERROR + H5E_BEGIN_TRY + { + fid2 = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* * Case 12: 1) RDONLY 2) RDONLY|SWMR_READ : should fail */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - fid2 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; - if(fid2 >=0 ) - TEST_ERROR + H5E_BEGIN_TRY + { + fid2 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); @@ -4678,16 +4776,17 @@ test_file_lock_swmr_same(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { - H5Pclose(fapl); - H5Fclose(fid); - H5Fclose(fid2); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(fapl); + H5Fclose(fid); + H5Fclose(fid2); + } + H5E_END_TRY; return -1; } /* end test_file_lock_swmr_same() */ - /**************************************************************** ** ** test_file_lock_concur(): @@ -4714,30 +4813,30 @@ test_file_lock_concur(hid_t H5_ATTR_UNUSED in_fapl) static int test_file_lock_concur(hid_t in_fapl) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - char filename[NAME_BUF_SIZE]; /* file name */ - pid_t childpid=0; /* Child process ID */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int out_pdf[2]; - int notify = 0; + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* file name */ + pid_t childpid = 0; /* Child process ID */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int out_pdf[2]; + int notify = 0; /* Output message about test being performed */ TESTING("File open with different combinations of flags--concurrent access"); - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -4745,148 +4844,154 @@ test_file_lock_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { child_fid = H5Fopen(filename, H5F_ACC_RDWR, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { - /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) - TEST_ERROR - } else + if (WIFEXITED(child_status)) { + /* Check exit status of the child */ + if (WEXITSTATUS(child_status) != 0) + TEST_ERROR + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* * Case 2: 1) RDWR 2) RDONLY : should fail */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Opens the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { child_fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Opens the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -4894,74 +4999,77 @@ test_file_lock_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Opens the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { child_fid = H5Fopen(filename, H5F_ACC_RDWR, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* end if */ - /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + /* close unused read end for out_pdf */ + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Opens the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -4969,41 +5077,43 @@ test_file_lock_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Opens the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { child_fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should succeed */ - if(child_fid >= 0) { + if (child_fid >= 0) { /* Close the file */ - if(H5Fclose(child_fid) < 0) - HDexit(EXIT_FAILURE); + if (H5Fclose(child_fid) < 0) + HDexit(EXIT_FAILURE); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) - HDexit(EXIT_FAILURE); + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) + HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* end if */ @@ -5012,40 +5122,41 @@ test_file_lock_concur(hid_t in_fapl) } /* end if */ /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Create file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); @@ -5053,10 +5164,12 @@ test_file_lock_concur(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; @@ -5090,34 +5203,34 @@ test_file_lock_swmr_concur(hid_t H5_ATTR_UNUSED in_fapl) static int test_file_lock_swmr_concur(hid_t in_fapl) { - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - char filename[NAME_BUF_SIZE]; /* file name */ - pid_t childpid=0; /* Child process ID */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int out_pdf[2]; - int notify = 0; + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* file name */ + pid_t childpid = 0; /* Child process ID */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int out_pdf[2]; + int notify = 0; /* Output message about test being performed */ TESTING("File open with different combintations of flags + SWMR flags--concurrent access"); - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[2], fapl, filename, sizeof(filename)); /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5125,74 +5238,77 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { - child_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + child_fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5200,74 +5316,77 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) - FAIL_STACK_ERROR + if ((childpid = HDfork()) < 0) + FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; - /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + /* Close unused write end for out_pdf */ + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { - child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + child_fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) - FAIL_STACK_ERROR + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) + FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5275,299 +5394,311 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { child_fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - /* Notify child process */ + /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* * Case 4: 1) RDWR|SWMR_WRITE 2) RDWR|SWMR_WRITE : should fail */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) - FAIL_STACK_ERROR + if ((childpid = HDfork()) < 0) + FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { - child_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + child_fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) + FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) - FAIL_STACK_ERROR + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) + FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* * Case 5: 1) RDWR|SWMR_WRITE 2) RDONLY|SWMR_READ : should succeed */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) - FAIL_STACK_ERROR + if ((childpid = HDfork()) < 0) + FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { - child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + child_fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; /* Should succeed */ - if(child_fid >= 0) { - if(H5Fclose(child_fid) < 0) + if (child_fid >= 0) { + if (H5Fclose(child_fid) < 0) FAIL_STACK_ERROR HDexit(EXIT_SUCCESS); } - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) - FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) + FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) - FAIL_STACK_ERROR + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) + FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* * Case 6: 1) RDWR|SWMR_WRITE 2) RDONLY : should fail */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { child_fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - /* Notify child process */ + /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5575,74 +5706,77 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { child_fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - /* Notify child process */ + /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5650,74 +5784,77 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { - child_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + child_fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5725,77 +5862,80 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { - child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + child_fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; /* Should succeed */ - if(child_fid >= 0) { - if(H5Fclose(child_fid) < 0) + if (child_fid >= 0) { + if (H5Fclose(child_fid) < 0) FAIL_STACK_ERROR HDexit(EXIT_SUCCESS); } /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5803,76 +5943,77 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - if((child_fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((child_fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Should succeed */ - if(child_fid >= 0) { - if(H5Fclose(child_fid) < 0) + if (child_fid >= 0) { + if (H5Fclose(child_fid) < 0) FAIL_STACK_ERROR HDexit(EXIT_SUCCESS); } - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR - /* Notify child process */ + /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5880,74 +6021,77 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) - FAIL_STACK_ERROR + if (HDpipe(out_pdf) < 0) + FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { - child_fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + child_fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl); + } + H5E_END_TRY; /* Should fail */ - if(child_fid == FAIL) + if (child_fid == FAIL) HDexit(EXIT_SUCCESS); - /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + /* Close the pipe */ + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* Close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* @@ -5955,81 +6099,84 @@ test_file_lock_swmr_concur(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + if (childpid == 0) { /* Child process */ + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Open the test file */ - H5E_BEGIN_TRY { - child_fid = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + child_fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl); + } + H5E_END_TRY; /* Should succeed */ - if(child_fid >= 0) { - if(H5Fclose(child_fid) < 0) + if (child_fid >= 0) { + if (H5Fclose(child_fid) < 0) FAIL_STACK_ERROR HDexit(EXIT_SUCCESS); } /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_FAILURE); } /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) FAIL_STACK_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR - } else + } + else FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); @@ -6037,17 +6184,17 @@ test_file_lock_swmr_concur(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_file_lock_swmr_concur() */ - - #endif /* !(defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID)) */ /**************************************************************** @@ -6066,35 +6213,33 @@ test_file_lock_env_var(hid_t in_fapl) HDputs(" Test skipped due to fork or waitpid not defined."); return 0; #else - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - char filename[NAME_BUF_SIZE]; /* file name */ - pid_t childpid=0; /* Child process ID */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int out_pdf[2]; - int notify = 0; - + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* file name */ + pid_t childpid = 0; /* Child process ID */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int out_pdf[2]; + int notify = 0; TESTING("File locking environment variable"); - /* Set the environment variable */ - if(HDsetenv("HDF5_USE_FILE_LOCKING", "FALSE", TRUE) < 0) + if (HDsetenv("HDF5_USE_FILE_LOCKING", "FALSE", TRUE) < 0) TEST_ERROR - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) TEST_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Open a file for read-only and then read-write. This would @@ -6104,77 +6249,77 @@ test_file_lock_env_var(hid_t in_fapl) */ /* Create 1 pipe */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) TEST_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) TEST_ERROR - if(childpid == 0) { + if (childpid == 0) { /* Child process */ - hid_t child_fid; /* File ID */ - int child_notify = 0; + hid_t child_fid; /* File ID */ + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* end while */ /* Open the test file */ - if((child_fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((child_fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Close the pipe */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* end if */ /* close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) TEST_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) TEST_ERROR; /* Close the pipe */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) TEST_ERROR; /* Wait for child process to complete */ - if(HDwaitpid(childpid, &child_status, child_wait_option) < 0) + if (HDwaitpid(childpid, &child_status, child_wait_option) < 0) TEST_ERROR /* Check if child terminated normally */ - if(WIFEXITED(child_status)) { + if (WIFEXITED(child_status)) { /* Check exit status of the child */ - if(WEXITSTATUS(child_status) != 0) + if (WEXITSTATUS(child_status) != 0) TEST_ERROR } /* end if */ else TEST_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Close the copied property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR PASSED(); @@ -6182,64 +6327,66 @@ test_file_lock_env_var(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - #endif /* !(defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID)) */ } /* end test_file_lock_env_var() */ - static int test_swmr_vfd_flag(void) { - hid_t fid = -1; /* file ID */ - hid_t sec2_fapl = -1; /* fapl ID of a VFD that supports SWMR writes (sec2) */ - hid_t bad_fapl = -1; /* fapl ID of a VFD that does not support SWMR writes (stdio) */ - char filename[NAME_BUF_SIZE]; /* file name */ + hid_t fid = -1; /* file ID */ + hid_t sec2_fapl = -1; /* fapl ID of a VFD that supports SWMR writes (sec2) */ + hid_t bad_fapl = -1; /* fapl ID of a VFD that does not support SWMR writes (stdio) */ + char filename[NAME_BUF_SIZE]; /* file name */ TESTING("SWMR-enabled VFD flag functionality"); /* Attempt to open a file using a SWMR-compatible VFD. */ - if((sec2_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((sec2_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_fapl_sec2(sec2_fapl) < 0) + if (H5Pset_fapl_sec2(sec2_fapl) < 0) FAIL_STACK_ERROR; - if(H5Pset_libver_bounds(sec2_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(sec2_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR h5_fixname(FILENAME[0], sec2_fapl, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, sec2_fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, sec2_fapl)) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Attempt to open a file using a non-SWMR-compatible VFD. */ - if((bad_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((bad_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR; - if(H5Pset_fapl_stdio(bad_fapl) < 0) + if (H5Pset_fapl_stdio(bad_fapl) < 0) FAIL_STACK_ERROR; - if(H5Pset_libver_bounds(bad_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(bad_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR fid = -1; h5_fixname(FILENAME[0], bad_fapl, filename, sizeof(filename)); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, bad_fapl); - } H5E_END_TRY; - if(fid >= 0) + } + H5E_END_TRY; + if (fid >= 0) TEST_ERROR; - if(H5Pclose(sec2_fapl) < 0) + if (H5Pclose(sec2_fapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(bad_fapl) < 0) + if (H5Pclose(bad_fapl) < 0) FAIL_STACK_ERROR; PASSED(); @@ -6247,11 +6394,13 @@ test_swmr_vfd_flag(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(sec2_fapl); H5Pclose(bad_fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_swmr_vfd_flag() */ @@ -6265,18 +6414,18 @@ error: static int test_bug_refresh(hid_t in_fapl) { - hid_t fid = -1; /* File ID */ - hid_t fapl; + hid_t fid = -1; /* File ID */ + hid_t fapl; H5F_t *f; - hid_t gid1, gid2, gid3, gid4, gid5, gid6, gid7, gid8, gid9; - char filename[NAME_BUF_SIZE]; /* File name */ + hid_t gid1, gid2, gid3, gid4, gid5, gid6, gid7, gid8, gid9; + char filename[NAME_BUF_SIZE]; /* File name */ /* Create a copy of the input parameter in_fapl */ - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ @@ -6285,45 +6434,54 @@ test_bug_refresh(hid_t in_fapl) TESTING("H5Orefresh failure conditions"); /* Create a file with the latest format */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5VL_object(fid))) + if (NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR /* Create groups: compact to dense storage */ - if((gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((gid2 = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((gid3 = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid3 = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((gid4 = H5Gcreate2(fid, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid4 = H5Gcreate2(fid, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((gid5 = H5Gcreate2(fid, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid5 = H5Gcreate2(fid, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((gid6 = H5Gcreate2(fid, "group6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid6 = H5Gcreate2(fid, "group6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((gid7 = H5Gcreate2(fid, "group7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid7 = H5Gcreate2(fid, "group7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((gid8 = H5Gcreate2(fid, "group8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid8 = H5Gcreate2(fid, "group8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - if((gid9 = H5Gcreate2(fid, "group9", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid9 = H5Gcreate2(fid, "group9", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) TEST_ERROR - if(H5Grefresh(gid1) < 0) TEST_ERROR - if(H5Grefresh(gid2) < 0) TEST_ERROR - if(H5Grefresh(gid3) < 0) TEST_ERROR - if(H5Grefresh(gid4) < 0) TEST_ERROR - if(H5Grefresh(gid5) < 0) TEST_ERROR - if(H5Grefresh(gid6) < 0) TEST_ERROR - if(H5Grefresh(gid7) < 0) TEST_ERROR - if(H5Grefresh(gid8) < 0) TEST_ERROR - if(H5Grefresh(gid9) < 0) TEST_ERROR + if (H5Grefresh(gid1) < 0) + TEST_ERROR + if (H5Grefresh(gid2) < 0) + TEST_ERROR + if (H5Grefresh(gid3) < 0) + TEST_ERROR + if (H5Grefresh(gid4) < 0) + TEST_ERROR + if (H5Grefresh(gid5) < 0) + TEST_ERROR + if (H5Grefresh(gid6) < 0) + TEST_ERROR + if (H5Grefresh(gid7) < 0) + TEST_ERROR + if (H5Grefresh(gid8) < 0) + TEST_ERROR + if (H5Grefresh(gid9) < 0) + TEST_ERROR H5Gclose(gid1); H5Gclose(gid2); @@ -6340,7 +6498,8 @@ test_bug_refresh(hid_t in_fapl) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid1); H5Gclose(gid2); H5Gclose(gid3); @@ -6352,7 +6511,8 @@ error: H5Gclose(gid9); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* test_bug_refresh() */ @@ -6395,27 +6555,27 @@ test_refresh_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t H5_ATTR_UNUSED new_for return 0; } /* test_refresh_concur() */ -#else /* defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID) */ +#else /* defined(H5_HAVE_FORK && defined(H5_HAVE_WAITPID) */ static int test_refresh_concur(hid_t in_fapl, hbool_t new_format) { - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - pid_t childpid=0; /* Child process ID */ - pid_t tmppid; /* Child process ID returned by waitpid */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int child_exit_val; /* Exit status of the child */ - char filename[NAME_BUF_SIZE]; /* File name */ - - hid_t did = -1; - hid_t sid = -1; - hid_t dcpl = -1; + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list */ + pid_t childpid = 0; /* Child process ID */ + pid_t tmppid; /* Child process ID returned by waitpid */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + char filename[NAME_BUF_SIZE]; /* File name */ + + hid_t did = -1; + hid_t sid = -1; + hid_t dcpl = -1; hsize_t chunk_dims[1] = {1}; - hsize_t maxdims[1] = {H5S_UNLIMITED}; - hsize_t dims[1] = { 1 }; - hsize_t new_dims[1] = {2}; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t dims[1] = {1}; + hsize_t new_dims[1] = {2}; int out_pdf[2]; int in_pdf[2]; @@ -6423,271 +6583,274 @@ test_refresh_concur(hid_t in_fapl, hbool_t new_format) int wbuf[2]; /* Output message about test being performed */ - if(new_format) { + if (new_format) { TESTING("H5Drefresh()--concurrent access for latest format"); - } else { + } + else { TESTING("H5Drefresh()--concurrent access for non-latest-format"); } /* end if */ - - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if(new_format) { + if (new_format) { /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - } else { + } + else { /* Create the test file without latest format but with SWMR write */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR } /* end if */ /* Create a chunked dataset with 1 extendible dimension */ - if((sid = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(1, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dims) < 0) FAIL_STACK_ERROR; - if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Create 2 pipes */ - if(HDpipe(out_pdf) < 0) + if (HDpipe(out_pdf) < 0) FAIL_STACK_ERROR - if(HDpipe(in_pdf) < 0) + if (HDpipe(in_pdf) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR - if(childpid == 0) { /* Child process */ - hid_t child_fid1 = -1; /* File ID */ - hid_t child_fid2 = -1; /* File ID */ - hid_t child_did1 = -1, child_did2 = -1; - hid_t child_sid = -1; + if (childpid == 0) { /* Child process */ + hid_t child_fid1 = -1; /* File ID */ + hid_t child_fid2 = -1; /* File ID */ + hid_t child_did1 = -1, child_did2 = -1; + hid_t child_sid = -1; hsize_t tdims[1]; - int rbuf[2] = {0, 0}; - int child_notify = 0; + int rbuf[2] = {0, 0}; + int child_notify = 0; /* Close unused write end for out_pdf */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) HDexit(EXIT_FAILURE); /* close unused read end for in_pdf */ - if(HDclose(in_pdf[0]) < 0) + if (HDclose(in_pdf[0]) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); /* Open the file 2 times */ - if((child_fid1 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((child_fid1 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) HDexit(EXIT_FAILURE); - if((child_fid2 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) + if ((child_fid2 = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) HDexit(EXIT_FAILURE); /* Open the dataset 2 times */ - if((child_did1 = H5Dopen2(child_fid1, "dataset", H5P_DEFAULT)) < 0) + if ((child_did1 = H5Dopen2(child_fid1, "dataset", H5P_DEFAULT)) < 0) HDexit(EXIT_FAILURE); - if((child_did2 = H5Dopen2(child_fid2, "dataset", H5P_DEFAULT)) < 0) + if ((child_did2 = H5Dopen2(child_fid2, "dataset", H5P_DEFAULT)) < 0) HDexit(EXIT_FAILURE); /* Get the dataset's dataspace via did1 */ - if((child_sid = H5Dget_space(child_did1)) < 0) + if ((child_sid = H5Dget_space(child_did1)) < 0) HDexit(EXIT_FAILURE); - if(H5Sget_simple_extent_dims(child_sid, tdims, NULL) < 0) + if (H5Sget_simple_extent_dims(child_sid, tdims, NULL) < 0) HDexit(EXIT_FAILURE); - if(tdims[0] != 1) + if (tdims[0] != 1) HDexit(EXIT_FAILURE); /* Read from the dataset via did2 */ - if(H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) HDexit(EXIT_FAILURE); /* Verify the data is correct */ - if(rbuf[0] != 99) + if (rbuf[0] != 99) HDexit(EXIT_FAILURE); /* Notify parent process */ child_notify = 2; - if(HDwrite(in_pdf[1], &child_notify, sizeof(int)) < 0) + if (HDwrite(in_pdf[1], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 3) - if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 3) + if (HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); /* Refresh dataset via did1 */ - if(H5Drefresh(child_did1) < 0) + if (H5Drefresh(child_did1) < 0) HDexit(EXIT_FAILURE); /* Get the dataset's dataspace and verify */ - if((child_sid = H5Dget_space(child_did1)) < 0) + if ((child_sid = H5Dget_space(child_did1)) < 0) HDexit(EXIT_FAILURE); - if(H5Sget_simple_extent_dims(child_sid, tdims, NULL) < 0) + if (H5Sget_simple_extent_dims(child_sid, tdims, NULL) < 0) HDexit(EXIT_FAILURE); - if(tdims[0] != 2) + if (tdims[0] != 2) HDexit(EXIT_FAILURE); /* Read from the dataset */ - if(H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if (H5Dread(child_did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) HDexit(EXIT_FAILURE); /* Verify the data is correct */ - if(rbuf[0] != 100 || rbuf[1] != 100) + if (rbuf[0] != 100 || rbuf[1] != 100) HDexit(EXIT_FAILURE); /* Close the 2 datasets */ - if(H5Dclose(child_did1) < 0) + if (H5Dclose(child_did1) < 0) HDexit(EXIT_FAILURE); - if(H5Dclose(child_did2) < 0) + if (H5Dclose(child_did2) < 0) HDexit(EXIT_FAILURE); /* Close the 2 files */ - if(H5Fclose(child_fid1) < 0) + if (H5Fclose(child_fid1) < 0) HDexit(EXIT_FAILURE); - if(H5Fclose(child_fid2) < 0) + if (H5Fclose(child_fid2) < 0) HDexit(EXIT_FAILURE); /* Close the pipes */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) HDexit(EXIT_FAILURE); - if(HDclose(in_pdf[1]) < 0) + if (HDclose(in_pdf[1]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* Close unused read end for out_pdf */ - if(HDclose(out_pdf[0]) < 0) + if (HDclose(out_pdf[0]) < 0) FAIL_STACK_ERROR /* Close unused write end for in_pdf */ - if(HDclose(in_pdf[1]) < 0) + if (HDclose(in_pdf[1]) < 0) FAIL_STACK_ERROR /* Open the test file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR /* Open the dataset */ - if((did = H5Dopen2(fid, "dataset", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Write to the dataset */ wbuf[0] = wbuf[1] = 99; - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) FAIL_STACK_ERROR; /* Flush to disk */ - if(H5Fflush(fid, H5F_SCOPE_LOCAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_LOCAL) < 0) FAIL_STACK_ERROR; /* Notify child process */ notify = 1; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; - /* Wait for notification from child process */ - while(notify != 2) { - if(HDread(in_pdf[0], ¬ify, sizeof(int)) < 0) + while (notify != 2) { + if (HDread(in_pdf[0], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; } /* Cork the metadata cache, to prevent the object header from being * flushed before the data has been written */ - if(H5Odisable_mdc_flushes(did) < 0) + if (H5Odisable_mdc_flushes(did) < 0) FAIL_STACK_ERROR; /* Extend the dataset */ - if(H5Dset_extent(did, new_dims) < 0) + if (H5Dset_extent(did, new_dims) < 0) FAIL_STACK_ERROR; /* Write to the dataset */ wbuf[0] = wbuf[1] = 100; - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) FAIL_STACK_ERROR; /* Uncork the metadata cache */ - if(H5Oenable_mdc_flushes(did) < 0) + if (H5Oenable_mdc_flushes(did) < 0) FAIL_STACK_ERROR; /* Flush to disk */ - if(H5Fflush(fid, H5F_SCOPE_LOCAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_LOCAL) < 0) FAIL_STACK_ERROR; /* Notify child process */ notify = 3; - if(HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(out_pdf[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Close the pipes */ - if(HDclose(out_pdf[1]) < 0) + if (HDclose(out_pdf[1]) < 0) FAIL_STACK_ERROR; - if(HDclose(in_pdf[0]) < 0) + if (HDclose(in_pdf[0]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else /* Child process terminated abnormally */ + } + else /* Child process terminated abnormally */ TEST_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); H5Pclose(dcpl); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; @@ -6710,302 +6873,303 @@ error: static int test_multiple_same(hid_t in_fapl, hbool_t new_format) { - hid_t fid = -1, fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ - hid_t fapl; /* File access property list */ - char filename[NAME_BUF_SIZE]; /* File name */ - hid_t did = -1, did1 = -1, did2 = -1, did3 = -1; - hid_t sid = -1; - hid_t dcpl = -1; + hid_t fid = -1, fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ + hid_t fapl; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* File name */ + hid_t did = -1, did1 = -1, did2 = -1, did3 = -1; + hid_t sid = -1; + hid_t dcpl = -1; hsize_t chunk_dims[2] = {1, 2}; - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t dims[2] = {1, 1}; - int rbuf = 0; - int wbuf = 0; + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t dims[2] = {1, 1}; + int rbuf = 0; + int wbuf = 0; /* Output message about test being performed */ - if(new_format) { + if (new_format) { TESTING("multiple--single process access for latest format"); - } else { + } + else { TESTING("multiple--single process access for non-latest-format"); } /* end if */ - - if((fapl = H5Pcopy(in_fapl)) < 0) + if ((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - if(new_format) { + if (new_format) { /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) FAIL_STACK_ERROR /* Create the test file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - } else { + } + else { /* Create the test file without latest format but with SWMR write */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR } /* end if */ /* Create a chunked dataset with 1 extendible dimension */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(2, dims, maxdims)) < 0) FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR; - if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR /* Case 1 */ /* Open the file 3 times: SWMR-write, read-write, read-only */ - if((fid1 = H5Fopen(filename, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid1 = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((fid3 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid3 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Open the dataset 3 times with fid1, fid2, fid3 */ - if((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) + if ((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - /* Write to the dataset via did1 */ wbuf = 88; - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) FAIL_STACK_ERROR; /* Refresh via did2 */ - if(H5Drefresh(did2) < 0) + if (H5Drefresh(did2) < 0) FAIL_STACK_ERROR; /* Read from the dataset via did2 */ rbuf = 0; - if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + if (H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data is correct */ - if(rbuf != 88) + if (rbuf != 88) FAIL_STACK_ERROR; /* Write to the dataset via did3 */ wbuf = 99; - if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + if (H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) FAIL_STACK_ERROR; /* Refresh via did1 */ - if(H5Drefresh(did1) < 0) + if (H5Drefresh(did1) < 0) FAIL_STACK_ERROR; /* Read from the dataset via did1 */ rbuf = 0; - if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + if (H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) FAIL_STACK_ERROR; /* Verify the data is correct */ - if(rbuf != 99) + if (rbuf != 99) FAIL_STACK_ERROR; /* Close datasets */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did3) < 0) + if (H5Dclose(did3) < 0) FAIL_STACK_ERROR; /* Close files */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) FAIL_STACK_ERROR /* Case 2 */ /* Open the file 3 times: read-write, read-only, read-write */ - if((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR - if((fid3 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid3 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR /* Open the dataset 3 times with fid1, fid2, fid3 */ - if((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) + if ((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write to the dataset via did1 */ wbuf = 88; - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) FAIL_STACK_ERROR; /* Refresh via did2 */ - if(H5Drefresh(did2) < 0) + if (H5Drefresh(did2) < 0) FAIL_STACK_ERROR; /* Read from dataset via did2 */ rbuf = 0; - if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + if (H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) FAIL_STACK_ERROR; - if(rbuf != wbuf) + if (rbuf != wbuf) FAIL_STACK_ERROR; /* Write to dataset via did3 */ wbuf = 99; - if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + if (H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) FAIL_STACK_ERROR; /* Enable SWMR write */ - if(H5Fstart_swmr_write(fid1) < 0) + if (H5Fstart_swmr_write(fid1) < 0) FAIL_STACK_ERROR; /* Read from dataset via did1 and verify data is correct */ rbuf = 0; - if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + if (H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) FAIL_STACK_ERROR; - if(rbuf != wbuf) + if (rbuf != wbuf) FAIL_STACK_ERROR; /* Write to dataset via did2 */ wbuf = 100; - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) FAIL_STACK_ERROR; /* Refresh dataset via did3 */ - if(H5Drefresh(did3) < 0) + if (H5Drefresh(did3) < 0) FAIL_STACK_ERROR; /* Read from dataset via did3 and verify data is correct */ rbuf = 0; - if(H5Dread(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + if (H5Dread(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) FAIL_STACK_ERROR; - if(rbuf != wbuf) + if (rbuf != wbuf) FAIL_STACK_ERROR; /* Close datasets */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; - if(H5Dclose(did3) < 0) + if (H5Dclose(did3) < 0) FAIL_STACK_ERROR; /* Close files */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) FAIL_STACK_ERROR /* Case 3 */ /* Open the file 3 times: read-write, read-only, read-only */ - if((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR - if((fid3 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((fid3 = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Open the dataset 3 times with fid1, fid2, fid3 */ - if((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) + if ((did1 = H5Dopen2(fid1, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) + if ((did2 = H5Dopen2(fid2, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) + if ((did3 = H5Dopen2(fid3, "dataset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write to the dataset via did1 */ wbuf = 88; - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) FAIL_STACK_ERROR; /* Refresh dataset via did2 */ - if(H5Drefresh(did2) < 0) + if (H5Drefresh(did2) < 0) FAIL_STACK_ERROR; /* Read from dataset via did2 and verify data is correct */ rbuf = 0; - if(H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + if (H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) FAIL_STACK_ERROR; - if(rbuf != wbuf) + if (rbuf != wbuf) FAIL_STACK_ERROR; /* Close dataset via did2 */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) FAIL_STACK_ERROR; /* Close file via fid2 */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR /* Write to dataset via did3 */ wbuf = 99; - if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) + if (H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wbuf) < 0) FAIL_STACK_ERROR; /* Close dataset via did3 */ - if(H5Dclose(did3) < 0) + if (H5Dclose(did3) < 0) FAIL_STACK_ERROR; /* Close file via fid3 */ - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) FAIL_STACK_ERROR /* Enable SWMR writing */ - if(H5Fstart_swmr_write(fid1) < 0) + if (H5Fstart_swmr_write(fid1) < 0) FAIL_STACK_ERROR; /* Read from dataset via did1 and verify data is correct */ rbuf = 0; - if(H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) + if (H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rbuf) < 0) FAIL_STACK_ERROR; - if(rbuf != wbuf) + if (rbuf != wbuf) FAIL_STACK_ERROR; /* Close dataset via did1 */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) FAIL_STACK_ERROR; /* Close file via fid1 */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR /* Close the property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Dclose(did1); H5Dclose(did2); @@ -7017,7 +7181,8 @@ error: H5Fclose(fid1); H5Fclose(fid2); H5Fclose(fid3); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; @@ -7031,17 +7196,17 @@ error: int main(void) { - int nerrors = 0; /* The # of errors */ - hid_t fapl = -1; /* File access property list ID */ - char *driver = NULL; /* VFD string (from env variable) */ - char *lock_env_var = NULL; /* file locking env var pointer */ - hbool_t use_file_locking; /* read from env var */ + int nerrors = 0; /* The # of errors */ + hid_t fapl = -1; /* File access property list ID */ + char * driver = NULL; /* VFD string (from env variable) */ + char * lock_env_var = NULL; /* file locking env var pointer */ + hbool_t use_file_locking; /* read from env var */ /* Skip this test if SWMR I/O is not supported for the VFD specified * by the environment variable. */ driver = HDgetenv("HDF5_DRIVER"); - if(!H5FD__supports_swmr_test(driver)) { + if (!H5FD__supports_swmr_test(driver)) { HDprintf("This VFD does not support SWMR I/O\n"); return EXIT_SUCCESS; } /* end if */ @@ -7051,7 +7216,7 @@ main(void) * disabled. */ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) + if (lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) use_file_locking = FALSE; else use_file_locking = TRUE; @@ -7097,7 +7262,7 @@ main(void) nerrors += test_append_flush_dataset_fixed(fapl); nerrors += test_append_flush_dataset_multiple(fapl); - if(use_file_locking) { + if (use_file_locking) { /* * Tests for: * file open flags--single process access @@ -7121,7 +7286,7 @@ main(void) /* Tests SWMR VFD compatibility flag. * Only needs to run when the VFD is the default (sec2). */ - if(NULL == driver || !HDstrcmp(driver, "") || !HDstrcmp(driver, "sec2")) + if (NULL == driver || !HDstrcmp(driver, "") || !HDstrcmp(driver, "sec2")) nerrors += test_swmr_vfd_flag(); /* This test changes the HDF5_USE_FILE_LOCKING environment variable @@ -7129,7 +7294,7 @@ main(void) */ nerrors += test_file_lock_env_var(fapl); - if(nerrors) + if (nerrors) goto error; HDprintf("All tests passed.\n"); @@ -7140,9 +7305,7 @@ main(void) error: nerrors = MAX(1, nerrors); - HDprintf("***** %d SWMR TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d SWMR TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return EXIT_FAILURE; } /* end main() */ - diff --git a/test/swmr_addrem_writer.c b/test/swmr_addrem_writer.c index 7c79de4..bb1075f 100644 --- a/test/swmr_addrem_writer.c +++ b/test/swmr_addrem_writer.c @@ -39,18 +39,16 @@ /****************/ /* The maximum # of records to add/remove from the dataset in one step */ -#define MAX_SIZE_CHANGE 10 +#define MAX_SIZE_CHANGE 10 /********************/ /* Local Prototypes */ /********************/ static hid_t open_skeleton(const char *filename, unsigned verbose); -static int addrem_records(hid_t fid, unsigned verbose, unsigned long nops, - unsigned long flush_count); -static void usage(void); +static int addrem_records(hid_t fid, unsigned verbose, unsigned long nops, unsigned long flush_count); +static void usage(void); - /*------------------------------------------------------------------------- * Function: open_skeleton * @@ -72,20 +70,20 @@ static void usage(void); static hid_t open_skeleton(const char *filename, unsigned verbose) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t fapl; /* File access property list */ - hid_t sid; /* Dataspace ID */ - hsize_t dim[2]; /* Dataspace dimension */ - unsigned u, v; /* Local index variable */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t fapl; /* File access property list */ + hid_t sid; /* Dataspace ID */ + hsize_t dim[2]; /* Dataspace dimension */ + unsigned u, v; /* Local index variable */ HDassert(filename); /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; #ifdef QAK @@ -98,7 +96,7 @@ open_skeleton(const char *filename, unsigned verbose) HDfprintf(stderr, "mdc_config.initial_size = %lu\n", (unsigned long)mdc_config.initial_size); HDfprintf(stderr, "mdc_config.epoch_length = %lu\n", (unsigned long)mdc_config.epoch_length); mdc_config.set_initial_size = 1; - mdc_config.initial_size = 16 * 1024 * 1024; + mdc_config.initial_size = 16 * 1024 * 1024; /* mdc_config.epoch_length = 5000; */ H5Pset_mdc_config(fapl, &mdc_config); } @@ -109,27 +107,27 @@ open_skeleton(const char *filename, unsigned verbose) #endif /* QAK */ /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) return -1; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Opening datasets\n"); /* Open the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - if((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + if ((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) return -1; - if((sid = H5Dget_space(symbol_info[u][v].dsid)) < 0) + if ((sid = H5Dget_space(symbol_info[u][v].dsid)) < 0) return -1; - if(2 != H5Sget_simple_extent_ndims(sid)) + if (2 != H5Sget_simple_extent_ndims(sid)) return -1; - if(H5Sget_simple_extent_dims(sid, dim, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dim, NULL) < 0) return -1; symbol_info[u][v].nrecords = dim[1]; } /* end for */ @@ -137,7 +135,6 @@ open_skeleton(const char *filename, unsigned verbose) return fid; } - /*------------------------------------------------------------------------- * Function: addrem_records * @@ -164,13 +161,13 @@ open_skeleton(const char *filename, unsigned verbose) static int addrem_records(hid_t fid, unsigned verbose, unsigned long nops, unsigned long flush_count) { - hid_t tid; /* Datatype ID for records */ - hid_t mem_sid; /* Memory dataspace ID */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ - hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ - symbol_t buf[MAX_SIZE_CHANGE]; /* Write buffer */ - unsigned long op_to_flush; /* # of operations before flush */ - unsigned long u, v; /* Local index variables */ + hid_t tid; /* Datatype ID for records */ + hid_t mem_sid; /* Memory dataspace ID */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + symbol_t buf[MAX_SIZE_CHANGE]; /* Write buffer */ + unsigned long op_to_flush; /* # of operations before flush */ + unsigned long u, v; /* Local index variables */ HDassert(fid > 0); @@ -178,19 +175,19 @@ addrem_records(hid_t fid, unsigned verbose, unsigned long nops, unsigned long fl HDmemset(&buf, 0, sizeof(buf)); /* Create a dataspace for the record to add */ - if((mem_sid = H5Screate_simple(2, count, NULL)) < 0) + if ((mem_sid = H5Screate_simple(2, count, NULL)) < 0) return -1; /* Create datatype for appending records */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) return -1; /* Add and remove records to random datasets, according to frequency * distribution */ op_to_flush = flush_count; - for(u=0; u MAX_SIZE_CHANGE) { + if (count[1] > MAX_SIZE_CHANGE) { /* Add records */ count[1] -= MAX_SIZE_CHANGE; /* Set the buffer's IDs (equal to its position) */ - for(v=0; vnrecords + (uint64_t)v; /* Set the memory space to the correct size */ - if(H5Sset_extent_simple(mem_sid, 2, count, NULL) < 0) + if (H5Sset_extent_simple(mem_sid, 2, count, NULL) < 0) return -1; /* Get the coordinates to write */ @@ -215,71 +212,71 @@ addrem_records(hid_t fid, unsigned verbose, unsigned long nops, unsigned long fl /* Cork the metadata cache, to prevent the object header from being * flushed before the data has been written */ - if(H5Odisable_mdc_flushes(symbol->dsid) < 0) + if (H5Odisable_mdc_flushes(symbol->dsid) < 0) return -1; - /* Extend the dataset's dataspace to hold the new record */ - symbol->nrecords+= count[1]; + /* Extend the dataset's dataspace to hold the new record */ + symbol->nrecords += count[1]; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) return -1; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(symbol->dsid)) < 0) + if ((file_sid = H5Dget_space(symbol->dsid)) < 0) return -1; /* Choose the last record in the dataset */ - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; /* Write record to the dataset */ - if(H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &buf) < 0) + if (H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &buf) < 0) return -1; /* Uncork the metadata cache */ - if(H5Oenable_mdc_flushes(symbol->dsid) < 0) + if (H5Oenable_mdc_flushes(symbol->dsid) < 0) return -1; /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; } /* end if */ else { /* Shrink the dataset's dataspace */ - if(count[1] > symbol->nrecords) + if (count[1] > symbol->nrecords) symbol->nrecords = 0; else symbol->nrecords -= count[1]; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) return -1; } /* end else */ /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ op_to_flush--; /* Check for counter being reached */ - if(0 == op_to_flush) { + if (0 == op_to_flush) { /* Flush contents of file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) return -1; /* Reset flush counter */ op_to_flush = flush_count; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing datasets\n"); /* Close the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) - if(H5Dclose(symbol_info[u][v].dsid) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) + if (H5Dclose(symbol_info[u][v].dsid) < 0) return -1; return 0; @@ -305,29 +302,30 @@ usage(void) HDexit(EXIT_FAILURE); } -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - hid_t fid; /* File ID for file opened */ - long nops = 0; /* # of times to grow or shrink the dataset */ - long flush_count = 1000; /* # of records to write between flushing file */ - unsigned verbose = 1; /* Whether to emit some informational messages */ - unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variable */ - int temp; + hid_t fid; /* File ID for file opened */ + long nops = 0; /* # of times to grow or shrink the dataset */ + long flush_count = 1000; /* # of records to write between flushing file */ + unsigned verbose = 1; /* Whether to emit some informational messages */ + unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variable */ + int temp; /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of records to write between flushing file */ case 'f': flush_count = HDatol(argv[u + 1]); - if(flush_count < 0) + if (flush_count < 0) usage(); u += 2; break; @@ -341,8 +339,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': use_seed = 1; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -353,31 +351,31 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nops = HDatol(argv[u]); - if(nops <= 0) + if (nops <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nops <= 0) + } /* end while */ + } /* end if */ + if (nops <= 0) usage(); - if(flush_count >= nops) + if (flush_count >= nops) usage(); /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "Parameters:\n"); HDfprintf(stderr, "\t# of operations between flushes = %ld\n", flush_count); HDfprintf(stderr, "\t# of operations = %ld\n", nops); } /* end if */ /* Set the random seed */ - if(0 == use_seed) { + if (0 == use_seed) { struct timeval t; HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); @@ -387,19 +385,19 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "Using writer random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Opening skeleton file: %s\n", FILENAME); /* Open file skeleton */ - if((fid = open_skeleton(FILENAME, verbose)) < 0) { + if ((fid = open_skeleton(FILENAME, verbose)) < 0) { HDfprintf(stderr, "Error opening skeleton file!\n"); HDexit(EXIT_FAILURE); } /* end if */ @@ -408,31 +406,31 @@ int main(int argc, const char *argv[]) h5_send_message(WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Adding and removing records\n"); /* Grow and shrink datasets */ - if(addrem_records(fid, verbose, (unsigned long)nops, (unsigned long)flush_count) < 0) { + if (addrem_records(fid, verbose, (unsigned long)nops, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "Error adding and removing records from datasets!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "Error releasing symbols!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing objects\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "Error closing file!\n"); HDexit(EXIT_FAILURE); } /* end if */ diff --git a/test/swmr_check_compat_vfd.c b/test/swmr_check_compat_vfd.c index 9b4fbb5..74b023f 100644 --- a/test/swmr_check_compat_vfd.c +++ b/test/swmr_check_compat_vfd.c @@ -20,11 +20,10 @@ #include "h5test.h" /* This file needs to access the file driver testing code */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5FD_TESTING -#include "H5FDpkg.h" /* File drivers */ +#include "H5FDpkg.h" /* File drivers */ - /*------------------------------------------------------------------------- * Function: main * @@ -46,7 +45,7 @@ main(void) driver = HDgetenv("HDF5_DRIVER"); - if(H5FD__supports_swmr_test(driver)) + if (H5FD__supports_swmr_test(driver)) return EXIT_SUCCESS; else return EXIT_FAILURE; diff --git a/test/swmr_common.c b/test/swmr_common.c index 0290fe5..9ebd133 100644 --- a/test/swmr_common.c +++ b/test/swmr_common.c @@ -74,25 +74,13 @@ unsigned symbol_count[NLEVELS] = {100, 200, 400, 800, 1600}; /* Array of dataset information entries (1 per dataset) */ symbol_info_t *symbol_info[NLEVELS]; -hsize_t PLANES[N_SOURCES][RANK] = { - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH}, - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH}, - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH} -}; - -char FILE_NAMES[N_SOURCES][NAME_LEN] = { - {"vds_swmr_src_a.h5"}, - {"vds_swmr_src_b.h5"}, - {"vds_swmr_src_c.h5"}, - {"vds_swmr_src_d.h5"}, - {"vds_swmr_src_e.h5"}, - {"vds_swmr_src_f.h5"} -}; - -char VDS_FILE_NAME[NAME_LEN] = "vds_swmr.h5"; +hsize_t PLANES[N_SOURCES][RANK] = {{1, SM_HEIGHT, WIDTH}, {1, LG_HEIGHT, WIDTH}, {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH}, {1, SM_HEIGHT, WIDTH}, {1, LG_HEIGHT, WIDTH}}; + +char FILE_NAMES[N_SOURCES][NAME_LEN] = {{"vds_swmr_src_a.h5"}, {"vds_swmr_src_b.h5"}, {"vds_swmr_src_c.h5"}, + {"vds_swmr_src_d.h5"}, {"vds_swmr_src_e.h5"}, {"vds_swmr_src_f.h5"}}; + +char VDS_FILE_NAME[NAME_LEN] = "vds_swmr.h5"; char SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; char VDS_DSET_NAME[NAME_LEN] = "vds_dset"; @@ -112,8 +100,8 @@ symbol_info_t * choose_dataset(unsigned *levelp, unsigned *offsetp) { static unsigned ncalls = 0; - unsigned level; /* The level of the dataset */ - unsigned offset; /* The "offset" of the dataset at that level */ + unsigned level; /* The level of the dataset */ + unsigned offset; /* The "offset" of the dataset at that level */ /* Determine level of dataset */ level = symbol_mapping[HDrandom() % NMAPPING]; @@ -123,8 +111,7 @@ choose_dataset(unsigned *levelp, unsigned *offsetp) ++ncalls; if ((ncalls % 1000) == 0) { - fprintf(stderr, "%s: call %u chose level %u offset %u\n", __func__, - ncalls, level, offset); + fprintf(stderr, "%s: call %u chose level %u offset %u\n", __func__, ncalls, level, offset); } if (levelp != NULL) *levelp = level; @@ -133,7 +120,6 @@ choose_dataset(unsigned *levelp, unsigned *offsetp) return &symbol_info[level][offset]; } /* end choose_dataset() */ - /*------------------------------------------------------------------------- * Function: create_symbol_datatype * @@ -150,31 +136,30 @@ choose_dataset(unsigned *levelp, unsigned *offsetp) hid_t create_symbol_datatype(void) { - hid_t sym_type_id; /* Datatype ID for symbol */ - hid_t opaq_type_id; /* Datatype ID for opaque part of record */ + hid_t sym_type_id; /* Datatype ID for symbol */ + hid_t opaq_type_id; /* Datatype ID for opaque part of record */ /* Create opaque datatype to represent other information for this record */ - if((opaq_type_id = H5Tcreate(H5T_OPAQUE, (size_t)DTYPE_SIZE)) < 0) + if ((opaq_type_id = H5Tcreate(H5T_OPAQUE, (size_t)DTYPE_SIZE)) < 0) return -1; /* Create compound datatype for symbol */ - if((sym_type_id = H5Tcreate(H5T_COMPOUND, sizeof(symbol_t))) < 0) + if ((sym_type_id = H5Tcreate(H5T_COMPOUND, sizeof(symbol_t))) < 0) return -1; /* Insert fields in symbol datatype */ - if(H5Tinsert(sym_type_id, "rec_id", HOFFSET(symbol_t, rec_id), H5T_NATIVE_UINT64) < 0) + if (H5Tinsert(sym_type_id, "rec_id", HOFFSET(symbol_t, rec_id), H5T_NATIVE_UINT64) < 0) return -1; - if(H5Tinsert(sym_type_id, "info", HOFFSET(symbol_t, info), opaq_type_id) < 0) + if (H5Tinsert(sym_type_id, "info", HOFFSET(symbol_t, info), opaq_type_id) < 0) return -1; /* Close opaque datatype */ - if(H5Tclose(opaq_type_id) < 0) + if (H5Tclose(opaq_type_id) < 0) return -1; return sym_type_id; } /* end create_symbol_datatype() */ - /*------------------------------------------------------------------------- * Function: generate_name * @@ -208,7 +193,6 @@ generate_name(char *name_buf, unsigned level, unsigned count) return 0; } /* end generate_name() */ - /*------------------------------------------------------------------------- * Function: generate_symbols * @@ -224,24 +208,23 @@ generate_name(char *name_buf, unsigned level, unsigned count) int generate_symbols(void) { - unsigned u, v; /* Local index variables */ + unsigned u, v; /* Local index variables */ - for(u = 0; u < NLEVELS; u++) { + for (u = 0; u < NLEVELS; u++) { symbol_info[u] = HDmalloc(symbol_count[u] * sizeof(symbol_info_t)); - for(v = 0; v < symbol_count[u]; v++) { + for (v = 0; v < symbol_count[u]; v++) { char name_buf[64]; generate_name(name_buf, u, v); - symbol_info[u][v].name = HDstrdup(name_buf); - symbol_info[u][v].dsid = -1; + symbol_info[u][v].name = HDstrdup(name_buf); + symbol_info[u][v].dsid = -1; symbol_info[u][v].nrecords = 0; } /* end for */ - } /* end for */ + } /* end for */ return 0; } /* end generate_symbols() */ - /*------------------------------------------------------------------------- * Function: shutdown_symbols * @@ -257,11 +240,11 @@ generate_symbols(void) int shutdown_symbols(void) { - unsigned u, v; /* Local index variables */ + unsigned u, v; /* Local index variables */ /* Clean up the symbols */ - for(u = 0; u < NLEVELS; u++) { - for(v = 0; v < symbol_count[u]; v++) + for (u = 0; u < NLEVELS; u++) { + for (v = 0; v < symbol_count[u]; v++) HDfree(symbol_info[u][v].name); HDfree(symbol_info[u]); } /* end for */ @@ -269,7 +252,6 @@ shutdown_symbols(void) return 0; } /* end shutdown_symbols() */ - /*------------------------------------------------------------------------- * Function: print_metadata_retries_info * @@ -286,33 +268,33 @@ int print_metadata_retries_info(hid_t fid) { H5F_retry_info_t info; - unsigned i; + unsigned i; /* Retrieve the collection of retries */ - if(H5Fget_metadata_read_retry_info(fid, &info) < 0) + if (H5Fget_metadata_read_retry_info(fid, &info) < 0) return (-1); /* Print information for each non-NULL retries[i] */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) { unsigned power; unsigned j; - if(NULL == info.retries[i]) + if (NULL == info.retries[i]) continue; HDfprintf(stderr, "Metadata read retries for item %u:\n", i); power = 1; - for(j = 0; j < info.nbins; j++) { - if(info.retries[i][j]) - HDfprintf(stderr, "\t# of retries for %u - %u retries: %u\n", - power, (power * 10) - 1, info.retries[i][j]); + for (j = 0; j < info.nbins; j++) { + if (info.retries[i][j]) + HDfprintf(stderr, "\t# of retries for %u - %u retries: %u\n", power, (power * 10) - 1, + info.retries[i][j]); power *= 10; } /* end for */ - } /* end for */ + } /* end for */ /* Free memory for each non-NULL retries[i] */ - for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) - if(info.retries[i] != NULL) + for (i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) + if (info.retries[i] != NULL) H5free_memory(info.retries[i]); return 0; diff --git a/test/swmr_common.h b/test/swmr_common.h index 47f96b7..0c77599 100644 --- a/test/swmr_common.h +++ b/test/swmr_common.h @@ -24,12 +24,12 @@ /* Macros */ /**********/ -#define NLEVELS 5 /* # of datasets in the SWMR test file */ +#define NLEVELS 5 /* # of datasets in the SWMR test file */ -#define NMAPPING 9 +#define NMAPPING 9 -#define FILENAME "swmr_data.h5" /* SWMR test file name */ -#define DTYPE_SIZE 150 /* Data size in opaque type */ +#define FILENAME "swmr_data.h5" /* SWMR test file name */ +#define DTYPE_SIZE 150 /* Data size in opaque type */ /* The message sent by writer that the file open is done--releasing the file lock */ #define WRITER_MESSAGE "SWMR_WRITER_MESSAGE" @@ -40,22 +40,22 @@ /* Information about a symbol/dataset */ typedef struct { - char *name; /* Dataset name for symbol */ - hid_t dsid; /* Dataset ID for symbol */ - hsize_t nrecords; /* Number of records for the symbol */ + char * name; /* Dataset name for symbol */ + hid_t dsid; /* Dataset ID for symbol */ + hsize_t nrecords; /* Number of records for the symbol */ } symbol_info_t; /* A symbol's record */ typedef struct { - uint64_t rec_id; /* ID for this record (unique in symbol) */ - uint8_t info[DTYPE_SIZE]; /* "Other" information for this record */ + uint64_t rec_id; /* ID for this record (unique in symbol) */ + uint8_t info[DTYPE_SIZE]; /* "Other" information for this record */ } symbol_t; /********************/ /* Global Variables */ /********************/ H5TEST_DLLVAR symbol_info_t *symbol_info[NLEVELS]; -H5TEST_DLLVAR unsigned symbol_count[NLEVELS]; +H5TEST_DLLVAR unsigned symbol_count[NLEVELS]; /**************/ /* Prototypes */ @@ -64,12 +64,12 @@ H5TEST_DLLVAR unsigned symbol_count[NLEVELS]; extern "C" { #endif -H5TEST_DLL symbol_info_t * choose_dataset(unsigned *, unsigned *); -H5TEST_DLL hid_t create_symbol_datatype(void); -H5TEST_DLL int generate_name(char *name_buf, unsigned level, unsigned count); -H5TEST_DLL int generate_symbols(void); -H5TEST_DLL int shutdown_symbols(void); -H5TEST_DLL int print_metadata_retries_info(hid_t fid); +H5TEST_DLL symbol_info_t *choose_dataset(unsigned *, unsigned *); +H5TEST_DLL hid_t create_symbol_datatype(void); +H5TEST_DLL int generate_name(char *name_buf, unsigned level, unsigned count); +H5TEST_DLL int generate_symbols(void); +H5TEST_DLL int shutdown_symbols(void); +H5TEST_DLL int print_metadata_retries_info(hid_t fid); #ifdef __cplusplus } diff --git a/test/swmr_generator.c b/test/swmr_generator.c index f6a4fe2..eedbcbc 100644 --- a/test/swmr_generator.c +++ b/test/swmr_generator.c @@ -31,27 +31,24 @@ /* * This file needs to access testing codefrom the H5O package. */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ #define H5O_TESTING -#include "H5Opkg.h" /* Object headers */ - +#include "H5Opkg.h" /* Object headers */ /****************/ /* Local Macros */ /****************/ -#define CHUNK_SIZE 50 /* Chunk size for created datasets */ +#define CHUNK_SIZE 50 /* Chunk size for created datasets */ /********************/ /* Local Prototypes */ /********************/ -static int gen_skeleton(const char *filename, hbool_t verbose, - hbool_t swmr_write, int comp_level, const char *index_type, - unsigned random_seed); +static int gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, int comp_level, + const char *index_type, unsigned random_seed); static void usage(void); - /*------------------------------------------------------------------------- * Function: gen_skeleton * @@ -83,34 +80,35 @@ static void usage(void); *------------------------------------------------------------------------- */ static int -gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, - int comp_level, const char *index_type, unsigned random_seed) +gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, int comp_level, + const char *index_type, unsigned random_seed) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t fcpl; /* File creation property list */ - hid_t fapl; /* File access property list */ - hid_t dcpl; /* Dataset creation property list */ - hid_t tid; /* Datatype for dataset elements */ - hid_t sid; /* Dataspace ID */ - hid_t aid; /* Attribute ID */ - hsize_t dims[2] = {1, 0}; /* Dataset starting dimensions */ - hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* Dataset maximum dimensions */ - hsize_t chunk_dims[2] = {1, CHUNK_SIZE}; /* Chunk dimensions */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t fcpl; /* File creation property list */ + hid_t fapl; /* File access property list */ + hid_t dcpl; /* Dataset creation property list */ + hid_t tid; /* Datatype for dataset elements */ + hid_t sid; /* Dataspace ID */ + hid_t aid; /* Attribute ID */ + hsize_t dims[2] = {1, 0}; /* Dataset starting dimensions */ + hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* Dataset maximum dimensions */ + hsize_t chunk_dims[2] = {1, CHUNK_SIZE}; /* Chunk dimensions */ #ifdef FILLVAL_WORKS - symbol_t fillval; /* Dataset fill value */ -#endif /* FILLVAL_WORKS */ - unsigned u, v; /* Local index variable */ + symbol_t fillval; /* Dataset fill value */ +#endif /* FILLVAL_WORKS */ + unsigned u, v; /* Local index variable */ HDassert(filename); HDassert(index_type); /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; - /* Can create a file for SWMR support with: (a) (write+latest-format) or (b) (SWMR write+non-latest-format) */ - if(!swmr_write) { - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + /* Can create a file for SWMR support with: (a) (write+latest-format) or (b) (SWMR + * write+non-latest-format) */ + if (!swmr_write) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; } @@ -118,7 +116,7 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, * With one unlimited dimension, we get the extensible array index * type, with two unlimited dimensions, we get a v2 B-tree. */ - if(!HDstrcmp(index_type, "b2")) + if (!HDstrcmp(index_type, "b2")) max_dims[0] = H5S_UNLIMITED; #ifdef QAK @@ -131,7 +129,7 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, HDfprintf(stderr, "mdc_config.initial_size = %lu\n", (unsigned long)mdc_config.initial_size); HDfprintf(stderr, "mdc_config.epoch_length = %lu\n", (unsigned long)mdc_config.epoch_length); mdc_config.set_initial_size = 1; - mdc_config.initial_size = 16 * 1024 * 1024; + mdc_config.initial_size = 16 * 1024 * 1024; /* mdc_config.epoch_length = 5000; */ H5Pset_mdc_config(fapl, &mdc_config); } @@ -146,7 +144,7 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, #endif /* QAK */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; #ifdef QAK @@ -154,46 +152,46 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, #endif /* QAK */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Creating file\n"); /* Create the file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (swmr_write ? H5F_ACC_SWMR_WRITE : 0), fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (swmr_write ? H5F_ACC_SWMR_WRITE : 0), fcpl, fapl)) < 0) return -1; /* Close file creation property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Create attribute with (shared) random number seed - for sparse test */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) return -1; - if((aid = H5Acreate2(fid, "seed", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(fid, "seed", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(H5Awrite(aid, H5T_NATIVE_UINT, &random_seed) < 0) + if (H5Awrite(aid, H5T_NATIVE_UINT, &random_seed) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; /* Create datatype for creating datasets */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) return -1; /* Create dataspace for creating datasets */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) return -1; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) return -1; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) return -1; - if(comp_level >= 0) { - if(H5Pset_deflate(dcpl, (unsigned)comp_level) < 0) + if (comp_level >= 0) { + if (H5Pset_deflate(dcpl, (unsigned)comp_level) < 0) return -1; } /* end if */ #ifdef FILLVAL_WORKS @@ -202,23 +200,24 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, * here when this is fixed. -NAF 8/11/11 */ HDmemset(&fillval, 0, sizeof(fillval)); fillval.rec_id = (uint64_t)ULLONG_MAX; - if(H5Pset_fill_value(dcpl, tid, &fillval) < 0) + if (H5Pset_fill_value(dcpl, tid, &fillval) < 0) return -1; #endif /* FILLVAL_WORKS */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Creating datasets\n"); /* Create the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - hid_t dsid; /* Dataset ID */ - char name_buf[64]; - hbool_t move_dataspace_message = FALSE; /* Whether to move the dataspace message out of object header chunk #0 */ + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + hid_t dsid; /* Dataset ID */ + char name_buf[64]; + hbool_t move_dataspace_message = + FALSE; /* Whether to move the dataspace message out of object header chunk #0 */ generate_name(name_buf, u, v); - if((dsid = H5Dcreate2(fid, name_buf, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, name_buf, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; /* Determine if the dataspace message for this dataset should be @@ -226,38 +225,38 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, * (Set to TRUE for every fourth dataset) */ move_dataspace_message = !(HDrandom() % 4); - if(move_dataspace_message) { - unsigned chunk_num; /* Object header chunk # for dataspace message */ + if (move_dataspace_message) { + unsigned chunk_num; /* Object header chunk # for dataspace message */ /* Move the dataspace message to a new object header chunk */ - if(H5O__msg_move_to_new_chunk_test(dsid, H5O_SDSPACE_ID) < 0) + if (H5O__msg_move_to_new_chunk_test(dsid, H5O_SDSPACE_ID) < 0) return -1; /* Retrieve the chunk # for the dataspace message */ chunk_num = UINT_MAX; - if(H5O__msg_get_chunkno_test(dsid, H5O_SDSPACE_ID, &chunk_num) < 0) + if (H5O__msg_get_chunkno_test(dsid, H5O_SDSPACE_ID, &chunk_num) < 0) return -1; /* Should not be in chunk #0 for now */ - if(0 == chunk_num) + if (0 == chunk_num) return -1; } /* end if */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) return -1; } /* end for */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing objects\n"); /* Close everythign */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; return 0; @@ -286,27 +285,28 @@ usage(void) HDexit(EXIT_FAILURE); } /* end usage() */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - int comp_level = -1; /* Compression level (-1 is no compression) */ - hbool_t verbose = TRUE; /* Whether to emit some informational messages */ - hbool_t swmr_write = FALSE; /* Whether to create file with SWMR_WRITE access */ - const char *index_type = "b1"; /* Chunk index type */ - hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variables */ - int temp; + int comp_level = -1; /* Compression level (-1 is no compression) */ + hbool_t verbose = TRUE; /* Whether to emit some informational messages */ + hbool_t swmr_write = FALSE; /* Whether to create file with SWMR_WRITE access */ + const char *index_type = "b1"; /* Chunk index type */ + hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variables */ + int temp; /* Parse command line options */ - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* Compress dataset chunks */ case 'c': comp_level = HDatoi(argv[u + 1]); - if(comp_level < -1 || comp_level > 9) + if (comp_level < -1 || comp_level > 9) usage(); u += 2; break; @@ -314,8 +314,7 @@ int main(int argc, const char *argv[]) /* Chunk index type */ case 'i': index_type = argv[u + 1]; - if(HDstrcmp(index_type, "ea") - && HDstrcmp(index_type, "b2")) + if (HDstrcmp(index_type, "ea") && HDstrcmp(index_type, "b2")) usage(); u += 2; break; @@ -323,8 +322,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': use_seed = TRUE; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -347,12 +346,12 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ - } /* end while */ - } /* end if */ + } /* end if */ + } /* end while */ + } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "Parameters:\n"); HDfprintf(stderr, "\tswmr writes %s\n", swmr_write ? "on" : "off"); HDfprintf(stderr, "\tcompression level = %d\n", comp_level); @@ -360,7 +359,7 @@ int main(int argc, const char *argv[]) } /* end if */ /* Set the random seed */ - if(!use_seed) { + if (!use_seed) { struct timeval t; HDgettimeofday(&t, NULL); @@ -371,11 +370,11 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "Using generator random seed (used in sparse test only): %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Generating skeleton file: %s\n", FILENAME); /* Generate file skeleton */ - if(gen_skeleton(FILENAME, verbose, swmr_write, comp_level, index_type, random_seed) < 0) { + if (gen_skeleton(FILENAME, verbose, swmr_write, comp_level, index_type, random_seed) < 0) { HDfprintf(stderr, "Error generating skeleton file!\n"); HDexit(EXIT_FAILURE); } /* end if */ diff --git a/test/swmr_reader.c b/test/swmr_reader.c index 28a6597..96eecc2 100644 --- a/test/swmr_reader.c +++ b/test/swmr_reader.c @@ -35,19 +35,17 @@ /* Local Prototypes */ /********************/ -static int check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, - const char *sym_name, symbol_t *record, hid_t rec_sid); -static int read_records(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed, unsigned long nseconds, unsigned poll_time, - unsigned ncommon, unsigned nrandom); +static int check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, const char *sym_name, + symbol_t *record, hid_t rec_sid); +static int read_records(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed, + unsigned long nseconds, unsigned poll_time, unsigned ncommon, unsigned nrandom); /*******************/ /* Local Variables */ /*******************/ -static hid_t symbol_tid = -1; /* The type ID for the SWMR datasets */ +static hid_t symbol_tid = -1; /* The type ID for the SWMR datasets */ - /*------------------------------------------------------------------------- * Function: check_dataset * @@ -81,13 +79,13 @@ static hid_t symbol_tid = -1; /* The type ID for the SWMR datasets */ *------------------------------------------------------------------------- */ static int -check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, - const char *sym_name, symbol_t *record, hid_t rec_sid) +check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, const char *sym_name, symbol_t *record, + hid_t rec_sid) { - hid_t dsid; /* Dataset ID */ - hid_t file_sid; /* Dataset's space ID */ - hssize_t snpoints; /* Number of elements in dataset */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + hid_t dsid; /* Dataset ID */ + hid_t file_sid; /* Dataset's space ID */ + hssize_t snpoints; /* Number of elements in dataset */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ HDassert(fid >= 0); HDassert(sym_name); @@ -95,60 +93,62 @@ check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, HDassert(rec_sid >= 0); /* Open dataset for symbol */ - if((dsid = H5Dopen2(fid, sym_name, H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, sym_name, H5P_DEFAULT)) < 0) return -1; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(dsid)) < 0) + if ((file_sid = H5Dget_space(dsid)) < 0) return -1; /* Get the number of elements (= records, for 1-D datasets) */ - if((snpoints = H5Sget_simple_extent_npoints(file_sid)) < 0) + if ((snpoints = H5Sget_simple_extent_npoints(file_sid)) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Symbol = '%s', # of records = %lld\n", sym_name, (long long)snpoints); /* Check if there are records for symbol */ - if(snpoints > 0) { + if (snpoints > 0) { /* Choose the last record in the dataset */ start[1] = (hsize_t)(snpoints - 1); - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; /* Read record from dataset */ record->rec_id = (uint64_t)ULLONG_MAX; - if(H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) + if (H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) return -1; /* Verify record value */ - if(record->rec_id != start[1]) { + if (record->rec_id != start[1]) { struct timeval tv; HDgettimeofday(&tv, NULL); - if(verbose) { + if (verbose) { HDfprintf(verbose_file, "*** ERROR ***\n"); HDfprintf(verbose_file, "Incorrect record value!\n"); - HDfprintf(verbose_file, "Time = %llu.%llu, Symbol = '%s', # of records = %lld, record->rec_id = %llu\n", (unsigned long long)tv.tv_sec, (unsigned long long)tv.tv_usec, sym_name, (long long)snpoints, (unsigned long long)record->rec_id); + HDfprintf(verbose_file, + "Time = %llu.%llu, Symbol = '%s', # of records = %lld, record->rec_id = %llu\n", + (unsigned long long)tv.tv_sec, (unsigned long long)tv.tv_usec, sym_name, + (long long)snpoints, (unsigned long long)record->rec_id); } /* end if */ return -1; } /* end if */ - } /* end if */ + } /* end if */ /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; /* Close dataset for symbol */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) return -1; return 0; } /* end check_dataset() */ - /*------------------------------------------------------------------------- * Function: read_records * @@ -191,20 +191,19 @@ check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, *------------------------------------------------------------------------- */ static int -read_records(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed, unsigned long nseconds, unsigned poll_time, - unsigned ncommon, unsigned nrandom) +read_records(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed, + unsigned long nseconds, unsigned poll_time, unsigned ncommon, unsigned nrandom) { - time_t start_time; /* Starting time */ - time_t curr_time; /* Current time */ - symbol_info_t **sym_com = NULL; /* Pointers to array of common dataset IDs */ - symbol_info_t **sym_rand = NULL; /* Pointers to array of random dataset IDs */ - hid_t mem_sid; /* Memory dataspace ID */ - hid_t fid; /* SWMR test file ID */ - hid_t fapl; /* file access property list */ - symbol_t record; /* The record to read from the dataset */ - unsigned v; /* Local index variable */ - hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ + time_t start_time; /* Starting time */ + time_t curr_time; /* Current time */ + symbol_info_t **sym_com = NULL; /* Pointers to array of common dataset IDs */ + symbol_info_t **sym_rand = NULL; /* Pointers to array of random dataset IDs */ + hid_t mem_sid; /* Memory dataspace ID */ + hid_t fid; /* SWMR test file ID */ + hid_t fapl; /* file access property list */ + symbol_t record; /* The record to read from the dataset */ + unsigned v; /* Local index variable */ + hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ HDassert(filename); HDassert(nseconds != 0); @@ -215,69 +214,69 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, HDmemset(&record, 0, sizeof(record)); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Choosing datasets\n"); /* Allocate space for 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Allocate array to hold pointers to symbols for common datasets */ - if(NULL == (sym_com = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * ncommon))) + if (NULL == (sym_com = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * ncommon))) return -1; /* Open the common datasets */ - for(v = 0; v < ncommon; v++) { - unsigned offset; /* Offset of symbol to use */ + for (v = 0; v < ncommon; v++) { + unsigned offset; /* Offset of symbol to use */ /* Determine the offset of the symbol, within level 0 symbols */ /* (level 0 symbols are the most common symbols) */ - offset = (unsigned)((unsigned)HDrandom() % symbol_count[0]); + offset = (unsigned)((unsigned)HDrandom() % symbol_count[0]); sym_com[v] = &symbol_info[0][offset]; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Common symbol #%u = '%s'\n", v, symbol_info[0][offset].name); } /* end for */ - } /* end if */ + } /* end if */ /* Allocate space for 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Allocate array to hold pointers to symbols for random datasets */ - if(NULL == (sym_rand = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * nrandom))) + if (NULL == (sym_rand = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * nrandom))) return -1; /* Determine the random datasets */ - for(v = 0; v < nrandom; v++) { - symbol_info_t *sym; /* Symbol to use */ + for (v = 0; v < nrandom; v++) { + symbol_info_t *sym; /* Symbol to use */ /* Determine the symbol, within all symbols */ - if(NULL == (sym = choose_dataset(NULL, NULL))) + if (NULL == (sym = choose_dataset(NULL, NULL))) return -1; sym_rand[v] = sym; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Random symbol #%u = '%s'\n", v, sym->name); } /* end for */ - } /* end if */ + } /* end if */ /* Create a dataspace for the record to read */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Reading records\n"); /* Get the starting time */ start_time = HDtime(NULL); - curr_time = start_time; + curr_time = start_time; /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; /* Log I/O when verbose output it enbabled */ - if(use_log_vfd) { + if (use_log_vfd) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "swmr_reader.log.%u", random_seed); @@ -286,52 +285,52 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, } /* end if */ /* Loop over reading records until [at least] the correct # of seconds have passed */ - while(curr_time < (time_t)(start_time + (time_t)nseconds)) { + while (curr_time < (time_t)(start_time + (time_t)nseconds)) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Opening file: %s\n", filename); /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) return -1; /* Check 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Checking common symbols\n"); /* Iterate over common datasets */ - for(v = 0; v < ncommon; v++) { + for (v = 0; v < ncommon; v++) { /* Check common dataset */ - if(check_dataset(fid, verbose, verbose_file, sym_com[v]->name, &record, mem_sid) < 0) + if (check_dataset(fid, verbose, verbose_file, sym_com[v]->name, &record, mem_sid) < 0) return -1; HDmemset(&record, 0, sizeof(record)); } /* end for */ - } /* end if */ + } /* end if */ /* Check 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Checking random symbols\n"); /* Iterate over random datasets */ - for(v = 0; v < nrandom; v++) { + for (v = 0; v < nrandom; v++) { /* Check random dataset */ - if(check_dataset(fid, verbose, verbose_file, sym_rand[v]->name, &record, mem_sid) < 0) + if (check_dataset(fid, verbose, verbose_file, sym_rand[v]->name, &record, mem_sid) < 0) return -1; HDmemset(&record, 0, sizeof(record)); } /* end for */ - } /* end if */ + } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Closing file\n"); /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /* Sleep for the appropriate # of seconds */ @@ -342,25 +341,25 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, } /* end while */ /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) + if (H5Sclose(mem_sid) < 0) return -1; /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Closing datasets\n"); /* Close 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Release array holding dataset ID's for random datasets */ HDfree(sym_rand); } /* end if */ /* Close 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Release array holding dataset ID's for common datasets */ HDfree(sym_com); } /* end if */ @@ -387,31 +386,32 @@ usage(void) HDexit(EXIT_FAILURE); } -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - long nseconds = 0; /* # of seconds to test */ - int poll_time = 1; /* # of seconds between polling */ - int ncommon = 5; /* # of common symbols to poll */ - int nrandom = 10; /* # of random symbols to poll */ - hbool_t verbose = TRUE; /* Whether to emit some informational messages */ - FILE *verbose_file = NULL; /* File handle for verbose output */ - hbool_t use_seed = FALSE; /* Set to 1 if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variables */ - int temp; + long nseconds = 0; /* # of seconds to test */ + int poll_time = 1; /* # of seconds between polling */ + int ncommon = 5; /* # of common symbols to poll */ + int nrandom = 10; /* # of random symbols to poll */ + hbool_t verbose = TRUE; /* Whether to emit some informational messages */ + FILE * verbose_file = NULL; /* File handle for verbose output */ + hbool_t use_seed = FALSE; /* Set to 1 if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variables */ + int temp; /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of common symbols to poll */ case 'h': ncommon = HDatoi(argv[u + 1]); - if(ncommon < 0) + if (ncommon < 0) usage(); u += 2; break; @@ -419,7 +419,7 @@ int main(int argc, const char *argv[]) /* # of random symbols to poll */ case 'l': nrandom = HDatoi(argv[u + 1]); - if(nrandom < 0) + if (nrandom < 0) usage(); u += 2; break; @@ -433,8 +433,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': use_seed = TRUE; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -444,7 +444,7 @@ int main(int argc, const char *argv[]) /* # of seconds between polling */ case 's': poll_time = HDatoi(argv[u + 1]); - if(poll_time < 0) + if (poll_time < 0) usage(); u += 2; break; @@ -453,24 +453,24 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nseconds = HDatol(argv[u]); - if(nseconds <= 0) + if (nseconds <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nseconds <= 0) + } /* end while */ + } /* end if */ + if (nseconds <= 0) usage(); - if(poll_time >= nseconds) + if (poll_time >= nseconds) usage(); /* Set the random seed */ - if(!use_seed) { + if (!use_seed) { struct timeval t; HDgettimeofday(&t, NULL); @@ -479,18 +479,18 @@ int main(int argc, const char *argv[]) HDsrandom(random_seed); /* Open output file */ - if(verbose) { + if (verbose) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "swmr_reader.out.%u", random_seed); - if(NULL == (verbose_file = HDfopen(verbose_name, "w"))) { + if (NULL == (verbose_file = HDfopen(verbose_name, "w"))) { HDfprintf(stderr, "Can't open verbose output file!\n"); HDexit(EXIT_FAILURE); } } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(verbose_file, "Parameters:\n"); HDfprintf(verbose_file, "\t# of seconds between polling = %d\n", poll_time); HDfprintf(verbose_file, "\t# of common symbols to poll = %d\n", ncommon); @@ -502,45 +502,45 @@ int main(int argc, const char *argv[]) HDfprintf(stdout, "Using reader random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) { + if (generate_symbols() < 0) { HDfprintf(stderr, "Error generating symbol names!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Create datatype for creating datasets */ - if((symbol_tid = create_symbol_datatype()) < 0) + if ((symbol_tid = create_symbol_datatype()) < 0) return -1; /* Reading records from datasets */ - if(read_records(FILENAME, verbose, verbose_file, random_seed, (unsigned long)nseconds, (unsigned)poll_time, (unsigned)ncommon, (unsigned)nrandom) < 0) { + if (read_records(FILENAME, verbose, verbose_file, random_seed, (unsigned long)nseconds, + (unsigned)poll_time, (unsigned)ncommon, (unsigned)nrandom) < 0) { HDfprintf(stderr, "Error reading records from datasets (random_seed = %u)!\n", random_seed); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "Error releasing symbols!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Closing objects\n"); /* Close objects created */ - if(H5Tclose(symbol_tid) < 0) { + if (H5Tclose(symbol_tid) < 0) { HDfprintf(stderr, "Error closing symbol datatype!\n"); HDexit(EXIT_FAILURE); } /* end if */ return 0; } - diff --git a/test/swmr_remove_reader.c b/test/swmr_remove_reader.c index 41f8437..9ca2fb0 100644 --- a/test/swmr_remove_reader.c +++ b/test/swmr_remove_reader.c @@ -42,13 +42,11 @@ static hid_t symbol_tid = -1; /* Local Prototypes */ /********************/ -static int check_dataset(hid_t fid, unsigned verbose, const char *sym_name, - symbol_t *record, hid_t rec_sid); -static int read_records(const char *filename, unsigned verbose, unsigned long nseconds, - unsigned poll_time, unsigned ncommon, unsigned nrandom); +static int check_dataset(hid_t fid, unsigned verbose, const char *sym_name, symbol_t *record, hid_t rec_sid); +static int read_records(const char *filename, unsigned verbose, unsigned long nseconds, unsigned poll_time, + unsigned ncommon, unsigned nrandom); static void usage(void); - /*------------------------------------------------------------------------- * Function: check_dataset * @@ -79,13 +77,12 @@ static void usage(void); *------------------------------------------------------------------------- */ static int -check_dataset(hid_t fid, unsigned verbose, const char *sym_name, symbol_t *record, - hid_t rec_sid) +check_dataset(hid_t fid, unsigned verbose, const char *sym_name, symbol_t *record, hid_t rec_sid) { - hid_t dsid; /* Dataset ID */ - hid_t file_sid; /* Dataset's space ID */ - hssize_t snpoints; /* Number of elements in dataset */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + hid_t dsid; /* Dataset ID */ + hid_t file_sid; /* Dataset's space ID */ + hssize_t snpoints; /* Number of elements in dataset */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ HDassert(fid >= 0); HDassert(sym_name); @@ -93,67 +90,67 @@ check_dataset(hid_t fid, unsigned verbose, const char *sym_name, symbol_t *recor HDassert(rec_sid >= 0); /* Open dataset for symbol */ - if((dsid = H5Dopen2(fid, sym_name, H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, sym_name, H5P_DEFAULT)) < 0) return -1; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(dsid)) < 0) + if ((file_sid = H5Dget_space(dsid)) < 0) return -1; /* Get the number of elements (= records, for 1-D datasets) */ - if((snpoints = H5Sget_simple_extent_npoints(file_sid)) < 0) + if ((snpoints = H5Sget_simple_extent_npoints(file_sid)) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Symbol = '%s', # of records = %lld\n", sym_name, (long long)snpoints); /* Check if there are records for symbol */ - if(snpoints > 0) { + if (snpoints > 0) { /* Choose a random record in the dataset, choosing the last record half * the time */ start[1] = (hsize_t)(HDrandom() % (snpoints * 2)); - if(start[1] > (hsize_t)(snpoints - 1)) + if (start[1] > (hsize_t)(snpoints - 1)) start[1] = (hsize_t)(snpoints - 1); - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; - /* Read record from dataset */ + /* Read record from dataset */ #ifdef FILLVAL_WORKS /* When shrinking the dataset, we cannot guarantee that the buffer will * even be touched, unless there is a fill value. Since fill values do * not work with SWMR currently (see note in swmr_generator.c), we * simply initialize rec_id to 0. */ record->rec_id = (uint64_t)ULLONG_MAX - 1; -#else /* FILLVAL_WORKS */ +#else /* FILLVAL_WORKS */ record->rec_id = (uint64_t)0; #endif /* FILLVAL_WORKS */ - if(H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) + if (H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) return -1; /* Verify record value - note that it may be the fill value, because the * chunk may be deleted before the object header has the updated * dimensions */ - if(record->rec_id != start[1] && record->rec_id != (uint64_t)0) { + if (record->rec_id != start[1] && record->rec_id != (uint64_t)0) { HDfprintf(stderr, "*** ERROR ***\n"); HDfprintf(stderr, "Incorrect record value!\n"); - HDfprintf(stderr, "Symbol = '%s', # of records = %lld, record->rec_id = %llx\n", sym_name, (long long)snpoints, (unsigned long long)record->rec_id); + HDfprintf(stderr, "Symbol = '%s', # of records = %lld, record->rec_id = %llx\n", sym_name, + (long long)snpoints, (unsigned long long)record->rec_id); return -1; } /* end if */ - } /* end if */ + } /* end if */ /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; /* Close dataset for symbol */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) return -1; return 0; } /* end check_dataset() */ - /*------------------------------------------------------------------------- * Function: read_records * @@ -190,18 +187,18 @@ check_dataset(hid_t fid, unsigned verbose, const char *sym_name, symbol_t *recor *------------------------------------------------------------------------- */ static int -read_records(const char *filename, unsigned verbose, unsigned long nseconds, - unsigned poll_time, unsigned ncommon, unsigned nrandom) +read_records(const char *filename, unsigned verbose, unsigned long nseconds, unsigned poll_time, + unsigned ncommon, unsigned nrandom) { - time_t start_time; /* Starting time */ - time_t curr_time; /* Current time */ - symbol_info_t **sym_com = NULL; /* Pointers to array of common dataset IDs */ - symbol_info_t **sym_rand = NULL; /* Pointers to array of random dataset IDs */ - hid_t mem_sid; /* Memory dataspace ID */ - hid_t fid; /* SWMR test file ID */ - hid_t fapl; /* File access property list */ - symbol_t record; /* The record to add to the dataset */ - unsigned v; /* Local index variable */ + time_t start_time; /* Starting time */ + time_t curr_time; /* Current time */ + symbol_info_t **sym_com = NULL; /* Pointers to array of common dataset IDs */ + symbol_info_t **sym_rand = NULL; /* Pointers to array of random dataset IDs */ + hid_t mem_sid; /* Memory dataspace ID */ + hid_t fid; /* SWMR test file ID */ + hid_t fapl; /* File access property list */ + symbol_t record; /* The record to add to the dataset */ + unsigned v; /* Local index variable */ HDassert(filename); HDassert(nseconds != 0); @@ -212,114 +209,114 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, HDmemset(&record, 0, sizeof(record)); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Choosing datasets\n"); /* Allocate space for 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Allocate array to hold pointers to symbols for common datasets */ - if(NULL == (sym_com = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * ncommon))) + if (NULL == (sym_com = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * ncommon))) return -1; /* Open the common datasets */ - for(v = 0; v < ncommon; v++) { - unsigned offset; /* Offset of symbol to use */ + for (v = 0; v < ncommon; v++) { + unsigned offset; /* Offset of symbol to use */ /* Determine the offset of the symbol, within level 0 symbols */ /* (level 0 symbols are the most common symbols) */ - offset = (unsigned)HDrandom() % symbol_count[0]; + offset = (unsigned)HDrandom() % symbol_count[0]; sym_com[v] = &symbol_info[0][offset]; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Common symbol #%u = '%s'\n", v, symbol_info[0][offset].name); } /* end for */ - } /* end if */ + } /* end if */ /* Allocate space for 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Allocate array to hold pointers to symbols for random datasets */ - if(NULL == (sym_rand = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * nrandom))) + if (NULL == (sym_rand = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * nrandom))) return -1; /* Determine the random datasets */ - for(v = 0; v < nrandom; v++) { - symbol_info_t *sym; /* Symbol to use */ + for (v = 0; v < nrandom; v++) { + symbol_info_t *sym; /* Symbol to use */ /* Determine the symbol, within all symbols */ - if(NULL == (sym = choose_dataset(NULL, NULL))) + if (NULL == (sym = choose_dataset(NULL, NULL))) return -1; sym_rand[v] = sym; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Random symbol #%u = '%s'\n", v, sym->name); } /* end for */ - } /* end if */ + } /* end if */ /* Create a dataspace for the record to read */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Reading records\n"); /* Get the starting time */ start_time = HDtime(NULL); - curr_time = start_time; + curr_time = start_time; /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; /* Loop over reading records until [at least] the correct # of seconds have passed */ - while(curr_time < (time_t)(start_time + (time_t)nseconds)) { + while (curr_time < (time_t)(start_time + (time_t)nseconds)) { /* Emit informational message */ - if(verbose) - HDfprintf(stderr, "Opening file: %s\n", filename); + if (verbose) + HDfprintf(stderr, "Opening file: %s\n", filename); /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) return -1; /* Check 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Checking common symbols\n"); /* Iterate over common datasets */ - for(v = 0; v < ncommon; v++) { + for (v = 0; v < ncommon; v++) { /* Check common dataset */ - if(check_dataset(fid, verbose, sym_com[v]->name, &record, mem_sid) < 0) + if (check_dataset(fid, verbose, sym_com[v]->name, &record, mem_sid) < 0) return -1; HDmemset(&record, 0, sizeof(record)); } /* end for */ - } /* end if */ + } /* end if */ /* Check 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Checking random symbols\n"); /* Iterate over random datasets */ - for(v = 0; v < nrandom; v++) { + for (v = 0; v < nrandom; v++) { /* Check random dataset */ - if(check_dataset(fid, verbose, sym_rand[v]->name, &record, mem_sid) < 0) + if (check_dataset(fid, verbose, sym_rand[v]->name, &record, mem_sid) < 0) return -1; HDmemset(&record, 0, sizeof(record)); } /* end for */ - } /* end if */ + } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing file\n"); /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /* Sleep for the appropriate # of seconds */ @@ -330,25 +327,25 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, } /* end while */ /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) + if (H5Sclose(mem_sid) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing datasets\n"); /* Close 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Release array holding dataset ID's for random datasets */ HDfree(sym_rand); } /* end if */ /* Close 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Release array holding dataset ID's for common datasets */ HDfree(sym_com); } /* end if */ @@ -373,30 +370,31 @@ usage(void) HDexit(EXIT_FAILURE); } -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - long nseconds = 0; /* # of seconds to test */ - int poll_time = 1; /* # of seconds between polling */ - int ncommon = 5; /* # of common symbols to poll */ - int nrandom = 10; /* # of random symbols to poll */ - unsigned verbose = 1; /* Whether to emit some informational messages */ - unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variables */ - int temp; + long nseconds = 0; /* # of seconds to test */ + int poll_time = 1; /* # of seconds between polling */ + int ncommon = 5; /* # of common symbols to poll */ + int nrandom = 10; /* # of random symbols to poll */ + unsigned verbose = 1; /* Whether to emit some informational messages */ + unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variables */ + int temp; /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of common symbols to poll */ case 'h': ncommon = HDatoi(argv[u + 1]); - if(ncommon < 0) + if (ncommon < 0) usage(); u += 2; break; @@ -404,7 +402,7 @@ int main(int argc, const char *argv[]) /* # of random symbols to poll */ case 'l': nrandom = HDatoi(argv[u + 1]); - if(nrandom < 0) + if (nrandom < 0) usage(); u += 2; break; @@ -418,8 +416,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': use_seed = 1; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -429,7 +427,7 @@ int main(int argc, const char *argv[]) /* # of seconds between polling */ case 's': poll_time = HDatoi(argv[u + 1]); - if(poll_time < 0) + if (poll_time < 0) usage(); u += 2; break; @@ -438,24 +436,24 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nseconds = HDatol(argv[u]); - if(nseconds <= 0) + if (nseconds <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nseconds <= 0) + } /* end while */ + } /* end if */ + if (nseconds <= 0) usage(); - if(poll_time >= nseconds) + if (poll_time >= nseconds) usage(); /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "Parameters:\n"); HDfprintf(stderr, "\t# of seconds between polling = %d\n", poll_time); HDfprintf(stderr, "\t# of common symbols to poll = %d\n", ncommon); @@ -464,7 +462,7 @@ int main(int argc, const char *argv[]) } /* end if */ /* Set the random seed */ - if(0 == use_seed) { + if (0 == use_seed) { struct timeval t; HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); @@ -474,41 +472,42 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "Using reader random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) { + if (generate_symbols() < 0) { HDfprintf(stderr, "Error generating symbol names!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Create datatype for creating datasets */ - if((symbol_tid = create_symbol_datatype()) < 0) + if ((symbol_tid = create_symbol_datatype()) < 0) return -1; /* Reading records from datasets */ - if(read_records(FILENAME, verbose, (unsigned long)nseconds, (unsigned)poll_time, (unsigned)ncommon, (unsigned)nrandom) < 0) { + if (read_records(FILENAME, verbose, (unsigned long)nseconds, (unsigned)poll_time, (unsigned)ncommon, + (unsigned)nrandom) < 0) { HDfprintf(stderr, "Error reading records from datasets!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "Error releasing symbols!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing objects\n"); /* Close objects created */ - if(H5Tclose(symbol_tid) < 0) { + if (H5Tclose(symbol_tid) < 0) { HDfprintf(stderr, "Error closing symbol datatype!\n"); HDexit(EXIT_FAILURE); } /* end if */ diff --git a/test/swmr_remove_writer.c b/test/swmr_remove_writer.c index 2db9493..5f2b9f8 100644 --- a/test/swmr_remove_writer.c +++ b/test/swmr_remove_writer.c @@ -39,18 +39,16 @@ /****************/ /* The maximum number of records to remove in one step */ -#define MAX_REMOVE_SIZE 10 +#define MAX_REMOVE_SIZE 10 /********************/ /* Local Prototypes */ /********************/ static hid_t open_skeleton(const char *filename, unsigned verbose, unsigned old); -static int remove_records(hid_t fid, unsigned verbose, unsigned long nshrinks, - unsigned long flush_count); -static void usage(void); +static int remove_records(hid_t fid, unsigned verbose, unsigned long nshrinks, unsigned long flush_count); +static void usage(void); - /*------------------------------------------------------------------------- * Function: open_skeleton * @@ -72,26 +70,26 @@ static void usage(void); static hid_t open_skeleton(const char *filename, unsigned verbose, unsigned old) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t fapl; /* File access property list */ - hid_t sid; /* Dataspace ID */ - hsize_t dim[2]; /* Dataspace dimensions */ - unsigned u, v; /* Local index variable */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t fapl; /* File access property list */ + hid_t sid; /* Dataspace ID */ + hsize_t dim[2]; /* Dataspace dimensions */ + unsigned u, v; /* Local index variable */ HDassert(filename); /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; - if(!old) { + if (!old) { /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; } #ifdef QAK -/* Increase the initial size of the metadata cache */ + /* Increase the initial size of the metadata cache */ { H5AC_cache_config_t mdc_config; @@ -100,7 +98,7 @@ open_skeleton(const char *filename, unsigned verbose, unsigned old) HDfprintf(stderr, "mdc_config.initial_size = %lu\n", (unsigned long)mdc_config.initial_size); HDfprintf(stderr, "mdc_config.epoch_length = %lu\n", (unsigned long)mdc_config.epoch_length); mdc_config.set_initial_size = 1; - mdc_config.initial_size = 16 * 1024 * 1024; + mdc_config.initial_size = 16 * 1024 * 1024; /* mdc_config.epoch_length = 5000; */ H5Pset_mdc_config(fapl, &mdc_config); } @@ -111,27 +109,27 @@ open_skeleton(const char *filename, unsigned verbose, unsigned old) #endif /* QAK */ /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) return -1; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Opening datasets\n"); /* Open the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - if((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + if ((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) return -1; - if((sid = H5Dget_space(symbol_info[u][v].dsid)) < 0) + if ((sid = H5Dget_space(symbol_info[u][v].dsid)) < 0) return -1; - if(2 != H5Sget_simple_extent_ndims(sid)) + if (2 != H5Sget_simple_extent_ndims(sid)) return -1; - if(H5Sget_simple_extent_dims(sid, dim, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dim, NULL) < 0) return -1; symbol_info[u][v].nrecords = dim[1]; } /* end for */ @@ -139,7 +137,6 @@ open_skeleton(const char *filename, unsigned verbose, unsigned old) return fid; } - /*------------------------------------------------------------------------- * Function: remove_records * @@ -166,56 +163,56 @@ open_skeleton(const char *filename, unsigned verbose, unsigned old) static int remove_records(hid_t fid, unsigned verbose, unsigned long nshrinks, unsigned long flush_count) { - unsigned long shrink_to_flush; /* # of removals before flush */ - hsize_t dim[2] = {1,0}; /* Dataspace dimensions */ - unsigned long u, v; /* Local index variables */ + unsigned long shrink_to_flush; /* # of removals before flush */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + unsigned long u, v; /* Local index variables */ HDassert(fid >= 0); /* Remove records from random datasets, according to frequency distribution */ shrink_to_flush = flush_count; - for(u = 0; u < nshrinks; u++) { - symbol_info_t *symbol; /* Symbol to remove record from */ - hsize_t remove_size; /* Size to reduce dataset dimension by */ + for (u = 0; u < nshrinks; u++) { + symbol_info_t *symbol; /* Symbol to remove record from */ + hsize_t remove_size; /* Size to reduce dataset dimension by */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(NULL, NULL); /* Shrink the dataset's dataspace */ remove_size = (hsize_t)HDrandom() % MAX_REMOVE_SIZE + 1; - if(remove_size > symbol->nrecords) + if (remove_size > symbol->nrecords) symbol->nrecords = 0; else symbol->nrecords -= remove_size; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) return -1; /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ shrink_to_flush--; /* Check for counter being reached */ - if(0 == shrink_to_flush) { + if (0 == shrink_to_flush) { /* Flush contents of file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) return -1; /* Reset flush counter */ shrink_to_flush = flush_count; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing datasets\n"); /* Close the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) - if(H5Dclose(symbol_info[u][v].dsid) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) + if (H5Dclose(symbol_info[u][v].dsid) < 0) return -1; return 0; @@ -239,30 +236,31 @@ usage(void) HDexit(EXIT_FAILURE); } -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - hid_t fid; /* File ID for file opened */ - long nshrinks = 0; /* # of times to shrink the dataset */ - long flush_count = 1000; /* # of records to write between flushing file */ - unsigned verbose = 1; /* Whether to emit some informational messages */ - unsigned old = 0; /* Whether to use non-latest-format when opening file */ - unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variable */ - int temp; + hid_t fid; /* File ID for file opened */ + long nshrinks = 0; /* # of times to shrink the dataset */ + long flush_count = 1000; /* # of records to write between flushing file */ + unsigned verbose = 1; /* Whether to emit some informational messages */ + unsigned old = 0; /* Whether to use non-latest-format when opening file */ + unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variable */ + int temp; /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of records to write between flushing file */ case 'f': flush_count = HDatol(argv[u + 1]); - if(flush_count < 0) + if (flush_count < 0) usage(); u += 2; break; @@ -275,8 +273,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': - use_seed = 1; - temp = HDatoi(argv[u + 1]); + use_seed = 1; + temp = HDatoi(argv[u + 1]); random_seed = (unsigned)temp; u += 2; break; @@ -291,31 +289,31 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nshrinks = HDatol(argv[u]); - if(nshrinks <= 0) + if (nshrinks <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nshrinks <= 0) + } /* end while */ + } /* end if */ + if (nshrinks <= 0) usage(); - if(flush_count >= nshrinks) + if (flush_count >= nshrinks) usage(); /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "Parameters:\n"); HDfprintf(stderr, "\t# of shrinks between flushes = %ld\n", flush_count); HDfprintf(stderr, "\t# of shrinks = %ld\n", nshrinks); } /* end if */ /* Set the random seed */ - if(0 == use_seed) { + if (0 == use_seed) { struct timeval t; HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); @@ -325,19 +323,19 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "Using writer random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Opening skeleton file: %s\n", FILENAME); /* Open file skeleton */ - if((fid = open_skeleton(FILENAME, verbose, old)) < 0) { + if ((fid = open_skeleton(FILENAME, verbose, old)) < 0) { HDfprintf(stderr, "Error opening skeleton file!\n"); HDexit(EXIT_FAILURE); } /* end if */ @@ -346,31 +344,31 @@ int main(int argc, const char *argv[]) h5_send_message(WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Removing records\n"); /* Remove records from datasets */ - if(remove_records(fid, verbose, (unsigned long)nshrinks, (unsigned long)flush_count) < 0) { + if (remove_records(fid, verbose, (unsigned long)nshrinks, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "Error removing records from datasets!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "Error releasing symbols!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing objects\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "Error closing file!\n"); HDexit(EXIT_FAILURE); } /* end if */ diff --git a/test/swmr_sparse_reader.c b/test/swmr_sparse_reader.c index cdf03ba..738ac14 100644 --- a/test/swmr_sparse_reader.c +++ b/test/swmr_sparse_reader.c @@ -29,7 +29,7 @@ /* Headers */ /***********/ -#include /* for PRIu64 */ +#include /* for PRIu64 */ #include "h5test.h" #include "swmr_common.h" @@ -49,13 +49,12 @@ static hid_t symbol_tid = (-1); /* Local Prototypes */ /********************/ -static int check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, - symbol_t *record, hid_t rec_sid); -static int read_records(const char *filename, unsigned verbose, unsigned long nrecords, - unsigned poll_time, unsigned reopen_count); +static int check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t *record, + hid_t rec_sid); +static int read_records(const char *filename, unsigned verbose, unsigned long nrecords, unsigned poll_time, + unsigned reopen_count); static void usage(void); - /*------------------------------------------------------------------------- * Function: check_dataset * @@ -87,13 +86,12 @@ static void usage(void); *------------------------------------------------------------------------- */ static int -check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t *record, - hid_t rec_sid) +check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t *record, hid_t rec_sid) { - hid_t dsid; /* Dataset ID */ - hid_t file_sid; /* Dataset's space ID */ - hsize_t start[2] = {0, 0}; /* Hyperslab selection values */ - hsize_t count[2] = {1, 1}; /* Hyperslab selection values */ + hid_t dsid; /* Dataset ID */ + hid_t file_sid; /* Dataset's space ID */ + hsize_t start[2] = {0, 0}; /* Hyperslab selection values */ + hsize_t count[2] = {1, 1}; /* Hyperslab selection values */ HDassert(fid >= 0); HDassert(symbol); @@ -101,48 +99,50 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t HDassert(rec_sid >= 0); /* Open dataset for symbol */ - if((dsid = H5Dopen2(fid, symbol->name, H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, symbol->name, H5P_DEFAULT)) < 0) return -1; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(dsid)) < 0) + if ((file_sid = H5Dget_space(dsid)) < 0) return -1; /* Choose the random record in the dataset (will be the same as chosen by * the writer) */ start[1] = (hsize_t)HDrandom() % symbol->nrecords; - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; /* Emit informational message */ - if(verbose) - HDfprintf(stderr, "Symbol = '%s', location = %" PRIuMAX ",%" PRIuMAX "\n", symbol->name, (uintmax_t)start[0], (uintmax_t)start[1]); + if (verbose) + HDfprintf(stderr, "Symbol = '%s', location = %" PRIuMAX ",%" PRIuMAX "\n", symbol->name, + (uintmax_t)start[0], (uintmax_t)start[1]); /* Read record from dataset */ record->rec_id = UINT64_MAX; - if(H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) + if (H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) return -1; /* Verify record value */ - if(record->rec_id != start[1]) { + if (record->rec_id != start[1]) { HDfprintf(stderr, "*** ERROR ***\n"); HDfprintf(stderr, "Incorrect record value!\n"); - HDfprintf(stderr, "Symbol = '%s', location = %" PRIuMAX ",%" PRIuMAX ", record->rec_id = %" PRIu64 "\n", symbol->name, (uintmax_t)start[0], (uintmax_t)start[1], record->rec_id); + HDfprintf(stderr, + "Symbol = '%s', location = %" PRIuMAX ",%" PRIuMAX ", record->rec_id = %" PRIu64 "\n", + symbol->name, (uintmax_t)start[0], (uintmax_t)start[1], record->rec_id); return -1; } /* end if */ /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; /* Close dataset for symbol */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) return -1; return 0; } /* end check_dataset() */ - /*------------------------------------------------------------------------- * Function: read_records * @@ -171,42 +171,42 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t *------------------------------------------------------------------------- */ static int -read_records(const char *filename, unsigned verbose, unsigned long nrecords, - unsigned poll_time, unsigned reopen_count) +read_records(const char *filename, unsigned verbose, unsigned long nrecords, unsigned poll_time, + unsigned reopen_count) { - hid_t fid; /* File ID */ - hid_t aid; /* Attribute ID */ - time_t start_time; /* Starting time */ - hid_t mem_sid; /* Memory dataspace ID */ - symbol_t record; /* The record to add to the dataset */ - unsigned seed; /* Seed for random number generator */ - unsigned iter_to_reopen = reopen_count; /* # of iterations until reopen */ - unsigned long u; /* Local index variable */ - hid_t fapl; + hid_t fid; /* File ID */ + hid_t aid; /* Attribute ID */ + time_t start_time; /* Starting time */ + hid_t mem_sid; /* Memory dataspace ID */ + symbol_t record; /* The record to add to the dataset */ + unsigned seed; /* Seed for random number generator */ + unsigned iter_to_reopen = reopen_count; /* # of iterations until reopen */ + unsigned long u; /* Local index variable */ + hid_t fapl; HDassert(filename); HDassert(poll_time != 0); /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; H5Pset_fclose_degree(fapl, H5F_CLOSE_SEMI); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Opening file: %s\n", filename); /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) return -1; /* Seed the random number generator with the attribute in the file */ - if((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0) return -1; - if(H5Aread(aid, H5T_NATIVE_UINT, &seed) < 0) + if (H5Aread(aid, H5T_NATIVE_UINT, &seed) < 0) return -1; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) return -1; HDsrandom(seed); @@ -215,21 +215,21 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, HDmemset(&record, 0, sizeof(record)); /* Create a dataspace for the record to read */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Reading records\n"); /* Get the starting time */ start_time = HDtime(NULL); /* Read records */ - for(u = 0; u < nrecords; u++) { - symbol_info_t *symbol = NULL; /* Symbol (dataset) */ - htri_t attr_exists; /* Whether the sequence number attribute exists */ - unsigned long file_u; /* Attribute sequence number (writer's "u") */ + for (u = 0; u < nrecords; u++) { + symbol_info_t *symbol = NULL; /* Symbol (dataset) */ + htri_t attr_exists; /* Whether the sequence number attribute exists */ + unsigned long file_u; /* Attribute sequence number (writer's "u") */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(NULL, NULL); @@ -241,26 +241,26 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, /* Wait until we can read the dataset */ do { /* Check if sequence attribute exists */ - if((attr_exists = H5Aexists_by_name(fid, symbol->name, "seq", H5P_DEFAULT)) < 0) + if ((attr_exists = H5Aexists_by_name(fid, symbol->name, "seq", H5P_DEFAULT)) < 0) return -1; - if(attr_exists) { + if (attr_exists) { /* Read sequence number attribute */ - if((aid = H5Aopen_by_name(fid, symbol->name, "seq", H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Aopen_by_name(fid, symbol->name, "seq", H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(H5Aread(aid, H5T_NATIVE_ULONG, &file_u) < 0) + if (H5Aread(aid, H5T_NATIVE_ULONG, &file_u) < 0) return -1; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) return -1; /* Check if sequence number is at least u - if so, this should * guarantee that this record has been written */ - if(file_u >= u) + if (file_u >= u) break; } /* end if */ /* Check for timeout */ - if(HDtime(NULL) >= (time_t)(start_time + (time_t)TIMEOUT)) { + if (HDtime(NULL) >= (time_t)(start_time + (time_t)TIMEOUT)) { HDfprintf(stderr, "Reader timed out\n"); return -1; } /* end if */ @@ -269,56 +269,56 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, HDsleep(poll_time); /* Retrieve and print the collection of metadata read retries */ - if(print_metadata_retries_info(fid) < 0) + if (print_metadata_retries_info(fid) < 0) HDfprintf(stderr, "Warning: could not obtain metadata retries info\n"); /* Reopen the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) return -1; iter_to_reopen = reopen_count; - } while(1); + } while (1); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Checking dataset %lu\n", u); /* Check dataset */ - if(check_dataset(fid, verbose, symbol, &record, mem_sid) < 0) + if (check_dataset(fid, verbose, symbol, &record, mem_sid) < 0) return -1; HDmemset(&record, 0, sizeof(record)); /* Check for reopen */ iter_to_reopen--; - if(iter_to_reopen == 0) { + if (iter_to_reopen == 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Reopening file: %s\n", filename); /* Retrieve and print the collection of metadata read retries */ - if(print_metadata_retries_info(fid) < 0) + if (print_metadata_retries_info(fid) < 0) HDfprintf(stderr, "Warning: could not obtain metadata retries info\n"); /* Reopen the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) return -1; iter_to_reopen = reopen_count; } /* end if */ - } /* end while */ + } /* end while */ /* Retrieve and print the collection of metadata read retries */ - if(print_metadata_retries_info(fid) < 0) + if (print_metadata_retries_info(fid) < 0) HDfprintf(stderr, "Warning: could not obtain metadata retries info\n"); /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) + if (H5Sclose(mem_sid) < 0) return -1; return 0; @@ -342,26 +342,27 @@ usage(void) HDexit(EXIT_FAILURE); } /* end usage() */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - long nrecords = 0; /* # of records to read */ - int poll_time = 1; /* # of seconds to sleep when waiting for writer */ - int reopen_count = 1; /* # of reads between reopens */ - unsigned verbose = 1; /* Whether to emit some informational messages */ - unsigned u; /* Local index variables */ + long nrecords = 0; /* # of records to read */ + int poll_time = 1; /* # of seconds to sleep when waiting for writer */ + int reopen_count = 1; /* # of reads between reopens */ + unsigned verbose = 1; /* Whether to emit some informational messages */ + unsigned u; /* Local index variables */ /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of reads between reopens */ case 'n': reopen_count = HDatoi(argv[u + 1]); - if(reopen_count < 0) + if (reopen_count < 0) usage(); u += 2; break; @@ -375,7 +376,7 @@ int main(int argc, const char *argv[]) /* # of seconds between polling */ case 's': poll_time = HDatoi(argv[u + 1]); - if(poll_time < 0) + if (poll_time < 0) usage(); u += 2; break; @@ -384,20 +385,20 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to read */ nrecords = HDatol(argv[u]); - if(nrecords <= 0) + if (nrecords <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "Parameters:\n"); HDfprintf(stderr, "\t# of seconds between polling = %d\n", poll_time); HDfprintf(stderr, "\t# of reads between reopens = %d\n", reopen_count); @@ -405,41 +406,42 @@ int main(int argc, const char *argv[]) } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) { + if (generate_symbols() < 0) { HDfprintf(stderr, "Error generating symbol names!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Create datatype for creating datasets */ - if((symbol_tid = create_symbol_datatype()) < 0) + if ((symbol_tid = create_symbol_datatype()) < 0) return -1; /* Reading records from datasets */ - if(read_records(FILENAME, verbose, (unsigned long) nrecords, (unsigned)poll_time, (unsigned)reopen_count) < 0) { + if (read_records(FILENAME, verbose, (unsigned long)nrecords, (unsigned)poll_time, + (unsigned)reopen_count) < 0) { HDfprintf(stderr, "Error reading records from datasets!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "Error releasing symbols!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing objects\n"); /* Close objects created */ - if(H5Tclose(symbol_tid) < 0) { + if (H5Tclose(symbol_tid) < 0) { HDfprintf(stderr, "Error closing symbol datatype!\n"); HDexit(EXIT_FAILURE); } /* end if */ diff --git a/test/swmr_sparse_writer.c b/test/swmr_sparse_writer.c index e33ebd4..a8e9db0 100644 --- a/test/swmr_sparse_writer.c +++ b/test/swmr_sparse_writer.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /*------------------------------------------------------------------------- +/*------------------------------------------------------------------------- * * Created: swmr_sparse_writer.c * @@ -44,11 +44,8 @@ /********************/ static hid_t open_skeleton(const char *filename, unsigned verbose); -static int add_records(hid_t fid, unsigned verbose, unsigned long nrecords, - unsigned long flush_count); -static void usage(void); - - +static int add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long flush_count); +static void usage(void); /*------------------------------------------------------------------------- * Function: open_skeleton @@ -71,20 +68,20 @@ static void usage(void); static hid_t open_skeleton(const char *filename, unsigned verbose) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t fapl; /* File access property list */ - hid_t aid; /* Attribute ID */ - unsigned seed; /* Seed for random number generator */ - unsigned u, v; /* Local index variable */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t fapl; /* File access property list */ + hid_t aid; /* Attribute ID */ + unsigned seed; /* Seed for random number generator */ + unsigned u, v; /* Local index variable */ HDassert(filename); /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; #ifdef QAK @@ -95,9 +92,9 @@ open_skeleton(const char *filename, unsigned verbose) mdc_config.version = H5AC__CURR_CACHE_CONFIG_VERSION; H5Pget_mdc_config(fapl, &mdc_config); HDfprintf(stderr, "mdc_config.initial_size = %lu\n", (unsigned long)mdc_config.initial_size); - HDfprintf(stderr,"mdc_config.epoch_length = %lu\n", (unsigned long)mdc_config.epoch_length); + HDfprintf(stderr, "mdc_config.epoch_length = %lu\n", (unsigned long)mdc_config.epoch_length); mdc_config.set_initial_size = 1; - mdc_config.initial_size = 16 * 1024 * 1024; + mdc_config.initial_size = 16 * 1024 * 1024; /* mdc_config.epoch_length = 5000; */ H5Pset_mdc_config(fapl, &mdc_config); } @@ -108,38 +105,37 @@ open_skeleton(const char *filename, unsigned verbose) #endif /* QAK */ /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) return -1; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Opening datasets\n"); /* Seed the random number generator with the attribute in the file */ - if((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0) return -1; - if(H5Aread(aid, H5T_NATIVE_UINT, &seed) < 0) + if (H5Aread(aid, H5T_NATIVE_UINT, &seed) < 0) return -1; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) return -1; HDsrandom(seed); /* Open the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - if((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) - return(-1); + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + if ((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) + return (-1); symbol_info[u][v].nrecords = 0; } /* end for */ return fid; } - /*------------------------------------------------------------------------- * Function: add_records * @@ -166,17 +162,17 @@ open_skeleton(const char *filename, unsigned verbose) static int add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long flush_count) { - hid_t tid; /* Datatype ID for records */ - hid_t mem_sid; /* Memory dataspace ID */ - hsize_t start[2] = {0, 0}; /* Hyperslab selection values */ - hsize_t count[2] = {1, 1}; /* Hyperslab selection values */ - symbol_t record; /* The record to add to the dataset */ - unsigned long rec_to_flush; /* # of records left to write before flush */ + hid_t tid; /* Datatype ID for records */ + hid_t mem_sid; /* Memory dataspace ID */ + hsize_t start[2] = {0, 0}; /* Hyperslab selection values */ + hsize_t count[2] = {1, 1}; /* Hyperslab selection values */ + symbol_t record; /* The record to add to the dataset */ + unsigned long rec_to_flush; /* # of records left to write before flush */ #ifdef OUT - volatile int dummy; /* Dummy varialbe for busy sleep */ -#endif /* OUT */ - hsize_t dim[2] = {1,0}; /* Dataspace dimensions */ - unsigned long u, v; /* Local index variables */ + volatile int dummy; /* Dummy varialbe for busy sleep */ +#endif /* OUT */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + unsigned long u, v; /* Local index variables */ HDassert(fid >= 0); @@ -185,48 +181,49 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f HDmemset(&record, 0, sizeof(record)); /* Create a dataspace for the record to add */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) return -1; /* Create datatype for appending records */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) return -1; /* Add records to random datasets, according to frequency distribution */ rec_to_flush = flush_count; - for(u = 0; u < nrecords; u++) { - symbol_info_t *symbol; /* Symbol to write record to */ - hid_t file_sid; /* Dataset's space ID */ - hid_t aid; /* Attribute ID */ - hbool_t corked; /* Whether the dataset was corked */ + for (u = 0; u < nrecords; u++) { + symbol_info_t *symbol; /* Symbol to write record to */ + hid_t file_sid; /* Dataset's space ID */ + hid_t aid; /* Attribute ID */ + hbool_t corked; /* Whether the dataset was corked */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(NULL, NULL); /* If this is the first time the dataset has been opened, extend it and * add the sequence attribute */ - if(symbol->nrecords == 0) { + if (symbol->nrecords == 0) { symbol->nrecords = nrecords / 5; - dim[1] = symbol->nrecords; + dim[1] = symbol->nrecords; /* Cork the metadata cache, to prevent the object header from being * flushed before the data has been written */ - if(H5Odisable_mdc_flushes(symbol->dsid) < 0) + if (H5Odisable_mdc_flushes(symbol->dsid) < 0) return -1; corked = TRUE; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) return -1; - if((file_sid = H5Screate(H5S_SCALAR)) < 0) + if ((file_sid = H5Screate(H5S_SCALAR)) < 0) return -1; - if((aid = H5Acreate2(symbol->dsid, "seq", H5T_NATIVE_ULONG, file_sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(symbol->dsid, "seq", H5T_NATIVE_ULONG, file_sid, H5P_DEFAULT, + H5P_DEFAULT)) < 0) return -1; - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; } /* end if */ else { - if((aid = H5Aopen(symbol->dsid, "seq", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(symbol->dsid, "seq", H5P_DEFAULT)) < 0) return -1; corked = FALSE; } /* end else */ @@ -238,15 +235,15 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f record.rec_id = start[1]; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(symbol->dsid)) < 0) + if ((file_sid = H5Dget_space(symbol->dsid)) < 0) return -1; /* Choose a random record in the dataset */ - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; /* Write record to the dataset */ - if(H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) + if (H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) return -1; /* Write the sequence number attribute. Since we synchronize the random @@ -255,37 +252,37 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f * flush dependencies on the object header, the reader will be * guaranteed to see the written data if the sequence attribute is >=u. */ - if(H5Awrite(aid, H5T_NATIVE_ULONG, &u) < 0) + if (H5Awrite(aid, H5T_NATIVE_ULONG, &u) < 0) return -1; /* Close the attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) return -1; /* Uncork the metadata cache, if it's been */ - if(corked) - if(H5Oenable_mdc_flushes(symbol->dsid) < 0) + if (corked) + if (H5Oenable_mdc_flushes(symbol->dsid) < 0) return -1; /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ rec_to_flush--; /* Check for counter being reached */ - if(0 == rec_to_flush) { + if (0 == rec_to_flush) { /* Flush contents of file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) return -1; /* Reset flush counter */ rec_to_flush = flush_count; } /* end if */ - } /* end if */ + } /* end if */ #ifdef OUT /* Busy wait, to let readers catch up */ @@ -293,30 +290,30 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f * at the top of the file. */ dummy = 0; - for(v=0; v 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of records to write between flushing file */ case 'f': flush_count = HDatol(argv[u + 1]); - if(flush_count < 0) + if (flush_count < 0) usage(); u += 2; break; @@ -374,43 +372,43 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nrecords = HDatol(argv[u]); - if(nrecords <= 0) + if (nrecords <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nrecords <= 0) + } /* end while */ + } /* end if */ + if (nrecords <= 0) usage(); - if(flush_count >= nrecords) + if (flush_count >= nrecords) usage(); /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "Parameters:\n"); HDfprintf(stderr, "\t# of records between flushes = %ld\n", flush_count); HDfprintf(stderr, "\t# of records to write = %ld\n", nrecords); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Opening skeleton file: %s\n", FILENAME); /* Open file skeleton */ - if((fid = open_skeleton(FILENAME, verbose)) < 0) { + if ((fid = open_skeleton(FILENAME, verbose)) < 0) { HDfprintf(stderr, "Error opening skeleton file!\n"); HDexit(EXIT_FAILURE); } /* end if */ @@ -419,31 +417,31 @@ int main(int argc, const char *argv[]) h5_send_message(WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Adding records\n"); /* Append records to datasets */ - if(add_records(fid, verbose, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { + if (add_records(fid, verbose, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "Error appending records to datasets!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "Error releasing symbols!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing objects\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "Error closing file!\n"); HDexit(EXIT_FAILURE); } /* end if */ diff --git a/test/swmr_start_write.c b/test/swmr_start_write.c index 5522795..50f4397 100644 --- a/test/swmr_start_write.c +++ b/test/swmr_start_write.c @@ -36,17 +36,15 @@ /* Local Prototypes */ /********************/ -static hid_t create_file(const char *filename, hbool_t verbose, - FILE *verbose_file, unsigned random_seed); -static int create_datasets(hid_t fid, int comp_level, hbool_t verbose, - FILE *verbose_file, const char *index_type); -static int add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, - unsigned long nrecords, unsigned long flush_count); -static void usage(void); +static hid_t create_file(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed); +static int create_datasets(hid_t fid, int comp_level, hbool_t verbose, FILE *verbose_file, + const char *index_type); +static int add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, unsigned long nrecords, + unsigned long flush_count); +static void usage(void); -#define CHUNK_SIZE 50 /* Chunk size for created datasets */ +#define CHUNK_SIZE 50 /* Chunk size for created datasets */ - /*------------------------------------------------------------------------- * Function: create_file * @@ -66,71 +64,69 @@ static void usage(void); *------------------------------------------------------------------------- */ static hid_t -create_file(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed) +create_file(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t fcpl; /* File creation property list */ - hid_t fapl; /* File access property list */ - hid_t sid; /* Dataspace ID */ - hid_t aid; /* Attribute ID */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t fcpl; /* File creation property list */ + hid_t fapl; /* File access property list */ + hid_t sid; /* Dataspace ID */ + hid_t aid; /* Attribute ID */ HDassert(filename); /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; /* We ALWAYS select the latest file format for SWMR */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; #ifdef QAK - if(verbose) { + if (verbose) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "swmr_start_write.log.%u", random_seed); H5Pset_fapl_log(fapl, verbose_name, H5FD_LOG_ALL, (size_t)(512 * 1024 * 1024)); - } /* end if */ + } /* end if */ #endif /* QAK */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Creating file without SWMR access\n"); /* Create the file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) return -1; /* Close file creation property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Create attribute with (shared) random number seed - for sparse test */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) return -1; - if((aid = H5Acreate2(fid, "seed", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(fid, "seed", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(H5Awrite(aid, H5T_NATIVE_UINT, &random_seed) < 0) + if (H5Awrite(aid, H5T_NATIVE_UINT, &random_seed) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) return -1; return fid; } /* end create_file() */ - /*------------------------------------------------------------------------- * Function: create_datasets * @@ -150,53 +146,53 @@ create_file(const char *filename, hbool_t verbose, FILE *verbose_file, *------------------------------------------------------------------------- */ static int -create_datasets(hid_t fid, int comp_level, hbool_t verbose, FILE *verbose_file, - const char *index_type) +create_datasets(hid_t fid, int comp_level, hbool_t verbose, FILE *verbose_file, const char *index_type) { - hid_t dcpl; /* Dataset creation property list */ - hid_t tid; /* Datatype for dataset elements */ - hid_t sid; /* Dataspace ID */ - hsize_t dims[2] = {1, 0}; /* Dataset starting dimensions */ - hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* Dataset maximum dimensions */ - hsize_t chunk_dims[2] = {1, CHUNK_SIZE}; /* Chunk dimensions */ - unsigned u, v; /* Local index variable */ + hid_t dcpl; /* Dataset creation property list */ + hid_t tid; /* Datatype for dataset elements */ + hid_t sid; /* Dataspace ID */ + hsize_t dims[2] = {1, 0}; /* Dataset starting dimensions */ + hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* Dataset maximum dimensions */ + hsize_t chunk_dims[2] = {1, CHUNK_SIZE}; /* Chunk dimensions */ + unsigned u, v; /* Local index variable */ HDassert(index_type); /* Create datatype for creating datasets */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) return -1; /* There are two chunk indexes tested here. * With one unlimited dimension, we get the extensible array index * type, with two unlimited dimensions, we get a v-2 B-tree. */ - if(!HDstrcmp(index_type, "b2")) + if (!HDstrcmp(index_type, "b2")) max_dims[0] = H5S_UNLIMITED; /* Create dataspace for creating datasets */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) return -1; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) return -1; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) return -1; - if(comp_level >= 0) { - if(H5Pset_deflate(dcpl, (unsigned)comp_level) < 0) + if (comp_level >= 0) { + if (H5Pset_deflate(dcpl, (unsigned)comp_level) < 0) return -1; } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Creating datasets\n"); /* Create the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { - if((symbol_info[u][v].dsid = H5Dcreate2(fid, symbol_info[u][v].name, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((symbol_info[u][v].dsid = + H5Dcreate2(fid, symbol_info[u][v].name, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; symbol_info[u][v].nrecords = 0; @@ -205,7 +201,6 @@ create_datasets(hid_t fid, int comp_level, hbool_t verbose, FILE *verbose_file, return 0; } /* create_datasets() */ - /*------------------------------------------------------------------------- * Function: add_records * @@ -225,16 +220,15 @@ create_datasets(hid_t fid, int comp_level, hbool_t verbose, FILE *verbose_file, *------------------------------------------------------------------------- */ static int -add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, - unsigned long nrecords, unsigned long flush_count) +add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, unsigned long nrecords, unsigned long flush_count) { - hid_t tid; /* Datatype ID for records */ - hid_t mem_sid; /* Memory dataspace ID */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ - hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ - symbol_t record; /* The record to add to the dataset */ - unsigned long rec_to_flush; /* # of records left to write before flush */ - unsigned long u, v; /* Local index variables */ + hid_t tid; /* Datatype ID for records */ + hid_t mem_sid; /* Memory dataspace ID */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + symbol_t record; /* The record to add to the dataset */ + unsigned long rec_to_flush; /* # of records left to write before flush */ + unsigned long u, v; /* Local index variables */ HDassert(fid >= 0); @@ -243,18 +237,18 @@ add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, HDmemset(&record, 0, sizeof(record)); /* Create a dataspace for the record to add */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) return -1; /* Create datatype for appending records */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) return -1; /* Add records to random datasets, according to frequency distribution */ rec_to_flush = flush_count; - for(u = 0; u < nrecords; u++) { - symbol_info_t *symbol; /* Symbol to write record to */ - hid_t file_sid; /* Dataset's space ID */ + for (u = 0; u < nrecords; u++) { + symbol_info_t *symbol; /* Symbol to write record to */ + hid_t file_sid; /* Dataset's space ID */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(NULL, NULL); @@ -267,68 +261,68 @@ add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, /* Cork the metadata cache, to prevent the object header from being * flushed before the data has been written */ - if(H5Odisable_mdc_flushes(symbol->dsid) < 0) + if (H5Odisable_mdc_flushes(symbol->dsid) < 0) return -1; /* Extend the dataset's dataspace to hold the new record */ symbol->nrecords++; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) return -1; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(symbol->dsid)) < 0) + if ((file_sid = H5Dget_space(symbol->dsid)) < 0) return -1; /* Choose the last record in the dataset */ - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; /* Write record to the dataset */ - if(H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) + if (H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) return -1; /* Uncork the metadata cache */ - if(H5Oenable_mdc_flushes(symbol->dsid) < 0) + if (H5Oenable_mdc_flushes(symbol->dsid) < 0) return -1; /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ rec_to_flush--; /* Check for counter being reached */ - if(0 == rec_to_flush) { + if (0 == rec_to_flush) { /* Flush contents of file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) return -1; /* Reset flush counter */ rec_to_flush = flush_count; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) + if (H5Sclose(mem_sid) < 0) return -1; /* Close the datatype */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Closing datasets\n"); /* Close the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) - if(H5Dclose(symbol_info[u][v].dsid) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) + if (H5Dclose(symbol_info[u][v].dsid) < 0) return -1; return 0; @@ -363,36 +357,37 @@ usage(void) /* * Can test with different scenarios as below: * 1) create_file(), create_datasets(), H5Fstart_swmr_write(), add_records(), H5Fclose(). - * 2) create_file(), create_close_datasets(), open_datasets(), H5Fstart_swmr_write(), add_records(), H5Fclose(). - * 3) create_file(), create_close_datasets(), H5Fclose(), - * open_file(), open_dataset(), H5Fstart_swmr_write(), add_records(), H5Fclose(). + * 2) create_file(), create_close_datasets(), open_datasets(), H5Fstart_swmr_write(), add_records(), + *H5Fclose(). 3) create_file(), create_close_datasets(), H5Fclose(), open_file(), open_dataset(), + *H5Fstart_swmr_write(), add_records(), H5Fclose(). */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - hid_t fid; /* File ID for file opened */ - long nrecords = 0; /* # of records to append */ - long flush_count = 10000; /* # of records to write between flushing file */ - hbool_t verbose = TRUE; /* Whether to emit some informational messages */ - FILE *verbose_file = NULL; /* File handle for verbose output */ - hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - int comp_level = -1; /* Compression level (-1 is no compression) */ - const char *index_type = "b1"; /* Chunk index type */ - unsigned u; /* Local index variable */ - int temp; /* Temporary variable */ + hid_t fid; /* File ID for file opened */ + long nrecords = 0; /* # of records to append */ + long flush_count = 10000; /* # of records to write between flushing file */ + hbool_t verbose = TRUE; /* Whether to emit some informational messages */ + FILE * verbose_file = NULL; /* File handle for verbose output */ + hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + int comp_level = -1; /* Compression level (-1 is no compression) */ + const char *index_type = "b1"; /* Chunk index type */ + unsigned u; /* Local index variable */ + int temp; /* Temporary variable */ /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* Compress dataset chunks */ case 'c': comp_level = HDatoi(argv[u + 1]); - if(comp_level < -1 || comp_level > 9) + if (comp_level < -1 || comp_level > 9) usage(); u += 2; break; @@ -400,8 +395,7 @@ int main(int argc, const char *argv[]) /* Chunk index type */ case 'i': index_type = argv[u + 1]; - if(HDstrcmp(index_type, "ea") - && HDstrcmp(index_type, "b2")) + if (HDstrcmp(index_type, "ea") && HDstrcmp(index_type, "b2")) usage(); u += 2; break; @@ -409,7 +403,7 @@ int main(int argc, const char *argv[]) /* # of records to write between flushing file */ case 'f': flush_count = HDatol(argv[u + 1]); - if(flush_count < 0) + if (flush_count < 0) usage(); u += 2; break; @@ -423,8 +417,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': use_seed = TRUE; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -435,25 +429,25 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nrecords = HDatol(argv[u]); - if(nrecords <= 0) + if (nrecords <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ - if(nrecords <= 0) + if (nrecords <= 0) usage(); - if(flush_count >= nrecords) + if (flush_count >= nrecords) usage(); /* Set the random seed */ - if(!use_seed) { + if (!use_seed) { struct timeval t; HDgettimeofday(&t, NULL); @@ -462,18 +456,18 @@ int main(int argc, const char *argv[]) HDsrandom(random_seed); /* Open output file */ - if(verbose) { + if (verbose) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "swmr_writer.out.%u", random_seed); - if(NULL == (verbose_file = HDfopen(verbose_name, "w"))) { + if (NULL == (verbose_file = HDfopen(verbose_name, "w"))) { HDfprintf(stderr, "Can't open verbose output file!\n"); HDexit(EXIT_FAILURE); } } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(verbose_file, "Parameters:\n"); HDfprintf(verbose_file, "\tindex type = %s\n", index_type); HDfprintf(verbose_file, "\tcompression level = %d\n", comp_level); @@ -485,27 +479,27 @@ int main(int argc, const char *argv[]) HDfprintf(stdout, "Using writer random seed: %u\n", random_seed); /* Create the test file */ - if((fid = create_file(FILENAME, verbose, verbose_file, random_seed)) < 0) { + if ((fid = create_file(FILENAME, verbose, verbose_file, random_seed)) < 0) { HDfprintf(stderr, "Error creating the file...\n"); HDexit(EXIT_FAILURE); } /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Create the datasets in the file */ - if(create_datasets(fid, comp_level, verbose, verbose_file, index_type) < 0) { + if (create_datasets(fid, comp_level, verbose, verbose_file, index_type) < 0) { HDfprintf(stderr, "Error creating datasets...\n"); HDexit(EXIT_FAILURE); } /* Enable SWMR writing mode */ - if(H5Fstart_swmr_write(fid) < 0) { + if (H5Fstart_swmr_write(fid) < 0) { HDfprintf(stderr, "Error starting SWMR writing mode...\n"); HDexit(EXIT_FAILURE); } @@ -514,35 +508,34 @@ int main(int argc, const char *argv[]) h5_send_message(WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Adding records\n"); /* Append records to datasets */ - if(add_records(fid, verbose, verbose_file, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { + if (add_records(fid, verbose, verbose_file, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "Error appending records to datasets!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "Error releasing symbols!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Closing the file\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "Error closing file!\n"); HDexit(EXIT_FAILURE); } /* end if */ return 0; } /* main() */ - diff --git a/test/swmr_writer.c b/test/swmr_writer.c index 5db17ef..f7ca723 100644 --- a/test/swmr_writer.c +++ b/test/swmr_writer.c @@ -35,13 +35,12 @@ /* Local Prototypes */ /********************/ -static hid_t open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed, hbool_t old); -static int add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, - unsigned long nrecords, unsigned long flush_count); -static void usage(void); +static hid_t open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed, + hbool_t old); +static int add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, unsigned long nrecords, + unsigned long flush_count); +static void usage(void); - /*------------------------------------------------------------------------- * Function: open_skeleton * @@ -70,23 +69,22 @@ static void usage(void); *------------------------------------------------------------------------- */ static hid_t -open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed, hbool_t old) +open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed, hbool_t old) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t fapl; /* File access property list */ - unsigned u, v; /* Local index variable */ - hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t fapl; /* File access property list */ + unsigned u, v; /* Local index variable */ + hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ HDassert(filename); /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return -1; - if(!old) { + if (!old) { /* Set to use the latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; } @@ -100,13 +98,13 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, HDfprintf(stderr, "mdc_config.initial_size = %lu\n", (unsigned long)mdc_config.initial_size); HDfprintf(stderr, "mdc_config.epoch_length = %lu\n", (unsigned long)mdc_config.epoch_length); mdc_config.set_initial_size = 1; - mdc_config.initial_size = 16 * 1024 * 1024; + mdc_config.initial_size = 16 * 1024 * 1024; /* mdc_config.epoch_length = 5000; */ H5Pset_mdc_config(fapl, &mdc_config); } #endif /* QAK */ - if(use_log_vfd) { + if (use_log_vfd) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "swmr_writer.log.%u", random_seed); @@ -115,21 +113,21 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, } /* end if */ /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) return -1; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Opening datasets\n"); /* Open the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - if((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + if ((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) return -1; symbol_info[u][v].nrecords = 0; } /* end for */ @@ -137,7 +135,6 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, return fid; } - /*------------------------------------------------------------------------- * Function: add_records * @@ -165,16 +162,15 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, *------------------------------------------------------------------------- */ static int -add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, - unsigned long nrecords, unsigned long flush_count) +add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, unsigned long nrecords, unsigned long flush_count) { - hid_t tid; /* Datatype ID for records */ - hid_t mem_sid; /* Memory dataspace ID */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ - hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ - symbol_t record; /* The record to add to the dataset */ - unsigned long rec_to_flush; /* # of records left to write before flush */ - unsigned long u, v; /* Local index variables */ + hid_t tid; /* Datatype ID for records */ + hid_t mem_sid; /* Memory dataspace ID */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + symbol_t record; /* The record to add to the dataset */ + unsigned long rec_to_flush; /* # of records left to write before flush */ + unsigned long u, v; /* Local index variables */ HDassert(fid >= 0); @@ -183,18 +179,18 @@ add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, HDmemset(&record, 0, sizeof(record)); /* Create a dataspace for the record to add */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) return -1; /* Create datatype for appending records */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) return -1; /* Add records to random datasets, according to frequency distribution */ rec_to_flush = flush_count; - for(u = 0; u < nrecords; u++) { - symbol_info_t *symbol; /* Symbol to write record to */ - hid_t file_sid; /* Dataset's space ID */ + for (u = 0; u < nrecords; u++) { + symbol_info_t *symbol; /* Symbol to write record to */ + hid_t file_sid; /* Dataset's space ID */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(NULL, NULL); @@ -207,68 +203,68 @@ add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, /* Cork the metadata cache, to prevent the object header from being * flushed before the data has been written */ - if(H5Odisable_mdc_flushes(symbol->dsid) < 0) + if (H5Odisable_mdc_flushes(symbol->dsid) < 0) return -1; /* Extend the dataset's dataspace to hold the new record */ symbol->nrecords++; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) return -1; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(symbol->dsid)) < 0) + if ((file_sid = H5Dget_space(symbol->dsid)) < 0) return -1; /* Choose the last record in the dataset */ - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; /* Write record to the dataset */ - if(H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) + if (H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) return -1; /* Uncork the metadata cache */ - if(H5Oenable_mdc_flushes(symbol->dsid) < 0) + if (H5Oenable_mdc_flushes(symbol->dsid) < 0) return -1; /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ rec_to_flush--; /* Check for counter being reached */ - if(0 == rec_to_flush) { + if (0 == rec_to_flush) { /* Flush contents of file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) return -1; /* Reset flush counter */ rec_to_flush = flush_count; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) + if (H5Sclose(mem_sid) < 0) return -1; /* Close the datatype */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Closing datasets\n"); /* Close the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) - if(H5Dclose(symbol_info[u][v].dsid) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) + if (H5Dclose(symbol_info[u][v].dsid) < 0) return -1; return 0; @@ -294,31 +290,32 @@ usage(void) HDexit(EXIT_FAILURE); } -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - hid_t fid; /* File ID for file opened */ - long nrecords = 0; /* # of records to append */ - long flush_count = 10000; /* # of records to write between flushing file */ - hbool_t verbose = TRUE; /* Whether to emit some informational messages */ - FILE *verbose_file = NULL; /* File handle for verbose output */ - hbool_t old = FALSE; /* Whether to use non-latest-format when opening file */ - hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variable */ - int temp; + hid_t fid; /* File ID for file opened */ + long nrecords = 0; /* # of records to append */ + long flush_count = 10000; /* # of records to write between flushing file */ + hbool_t verbose = TRUE; /* Whether to emit some informational messages */ + FILE * verbose_file = NULL; /* File handle for verbose output */ + hbool_t old = FALSE; /* Whether to use non-latest-format when opening file */ + hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variable */ + int temp; /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of records to write between flushing file */ case 'f': flush_count = HDatol(argv[u + 1]); - if(flush_count < 0) + if (flush_count < 0) usage(); u += 2; break; @@ -331,8 +328,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': - use_seed = TRUE; - temp = HDatoi(argv[u + 1]); + use_seed = TRUE; + temp = HDatoi(argv[u + 1]); random_seed = (unsigned)temp; u += 2; break; @@ -347,24 +344,24 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nrecords = HDatol(argv[u]); - if(nrecords <= 0) + if (nrecords <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nrecords <= 0) + } /* end while */ + } /* end if */ + if (nrecords <= 0) usage(); - if(flush_count >= nrecords) + if (flush_count >= nrecords) usage(); /* Set the random seed */ - if(!use_seed) { + if (!use_seed) { struct timeval t; HDgettimeofday(&t, NULL); @@ -373,18 +370,18 @@ int main(int argc, const char *argv[]) HDsrandom(random_seed); /* Open output file */ - if(verbose) { + if (verbose) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "swmr_writer.out.%u", random_seed); - if(NULL == (verbose_file = HDfopen(verbose_name, "w"))) { + if (NULL == (verbose_file = HDfopen(verbose_name, "w"))) { HDfprintf(stderr, "Can't open verbose output file!\n"); HDexit(EXIT_FAILURE); } } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(verbose_file, "Parameters:\n"); HDfprintf(verbose_file, "\t# of records between flushes = %ld\n", flush_count); HDfprintf(verbose_file, "\t# of records to write = %ld\n", nrecords); @@ -394,19 +391,19 @@ int main(int argc, const char *argv[]) HDfprintf(stdout, "Using writer random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Opening skeleton file: %s\n", FILENAME); /* Open file skeleton */ - if((fid = open_skeleton(FILENAME, verbose, verbose_file, random_seed, old)) < 0) { + if ((fid = open_skeleton(FILENAME, verbose, verbose_file, random_seed, old)) < 0) { HDfprintf(stderr, "Error opening skeleton file!\n"); HDexit(EXIT_FAILURE); } /* end if */ @@ -415,35 +412,34 @@ int main(int argc, const char *argv[]) h5_send_message(WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Adding records\n"); /* Append records to datasets */ - if(add_records(fid, verbose, verbose_file, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { + if (add_records(fid, verbose, verbose_file, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "Error appending records to datasets!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "Error releasing symbols!\n"); HDexit(EXIT_FAILURE); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "Closing objects\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "Error closing file!\n"); HDexit(EXIT_FAILURE); } /* end if */ return 0; } - diff --git a/test/tarray.c b/test/tarray.c index e643fb0..3e4a9e3 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -12,59 +12,57 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tarray -* -* Test the Array Datatype functionality -* -*************************************************************/ + * + * Test program: tarray + * + * Test the Array Datatype functionality + * + *************************************************************/ #include "testhdf5.h" #include "H5srcdir.h" -#define FILENAME "tarray1.h5" -#define TESTFILE "tarrold.h5" +#define FILENAME "tarray1.h5" +#define TESTFILE "tarrold.h5" /* 1-D array datatype */ -#define ARRAY1_RANK 1 -#define ARRAY1_DIM1 4 +#define ARRAY1_RANK 1 +#define ARRAY1_DIM1 4 /* 3-D array datatype */ -#define ARRAY2_RANK 3 -#define ARRAY2_DIM1 3 -#define ARRAY2_DIM2 4 -#define ARRAY2_DIM3 5 +#define ARRAY2_RANK 3 +#define ARRAY2_DIM1 3 +#define ARRAY2_DIM2 4 +#define ARRAY2_DIM3 5 /* 2-D array datatype */ -#define ARRAY3_RANK 2 -#define ARRAY3_DIM1 6 -#define ARRAY3_DIM2 3 +#define ARRAY3_RANK 2 +#define ARRAY3_DIM1 6 +#define ARRAY3_DIM2 3 /* 1-D dataset with fixed dimensions */ -#define SPACE1_RANK 1 -#define SPACE1_DIM1 4 +#define SPACE1_RANK 1 +#define SPACE1_DIM1 4 /* Parameters used with the test_array_bkg() test */ -#define FIELDNAME "ArrayofStructures" -#define LENGTH 5 -#define ALEN 10 -#define RANK 1 -#define NMAX 100 +#define FIELDNAME "ArrayofStructures" +#define LENGTH 5 +#define ALEN 10 +#define RANK 1 +#define NMAX 100 /* Struct used with test_array_bkg() test */ -typedef struct -{ - int nsubfields; - char *name[NMAX]; - size_t offset[NMAX]; - hid_t datatype[NMAX]; +typedef struct { + int nsubfields; + char * name[NMAX]; + size_t offset[NMAX]; + hid_t datatype[NMAX]; } CmpDTSinfo; /* Forward declarations for custom vlen memory manager functions */ void *test_array_alloc_custom(size_t size, void *info); -void test_array_free_custom(void *mem, void *info); - +void test_array_free_custom(void *mem, void *info); /*------------------------------------------------------------------------- * Function: test_array_atomic_1d @@ -79,25 +77,25 @@ void test_array_free_custom(void *mem, void *info); static void test_array_atomic_1d(void) { - int wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - int rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int ndims; /* Array rank for reading */ - hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ - int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ + int wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + int rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int ndims; /* Array rank for reading */ + hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ + int i, j; /* counting variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing 1-D Array of Atomic Datatypes Functionality\n")); /* Allocate and initialize array data to write */ - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < ARRAY1_DIM1; j++) + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) wdata[i][j] = i * 10 + j; /* Create file */ @@ -136,7 +134,6 @@ test_array_atomic_1d(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -146,7 +143,7 @@ test_array_atomic_1d(void) CHECK(dataset, FAIL, "H5Dopen2"); /* Get the datatype */ - tid1 = H5Dget_type (dataset); + tid1 = H5Dget_type(dataset); CHECK(tid1, FAIL, "H5Dget_type"); /* Check the array rank */ @@ -158,9 +155,10 @@ test_array_atomic_1d(void) CHECK(ret, FAIL, "H5Tget_array_dims2"); /* Check the array dimensions */ - for(i = 0; i < ndims; i++) - if(rdims1[i] != tdims1[i]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n", (int)i, (int)rdims1[i], (int)i, (int)tdims1[i]); + for (i = 0; i < ndims; i++) + if (rdims1[i] != tdims1[i]) { + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n", + (int)i, (int)rdims1[i], (int)i, (int)tdims1[i]); continue; } /* end if */ @@ -169,10 +167,11 @@ test_array_atomic_1d(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < ARRAY1_DIM1; j++) - if(wdata[i][j] != rdata[i][j]) { - TestErrPrintf("Array data information doesn't match!, wdata[%d][%d]=%d, rdata[%d][%d]=%d\n", (int)i, (int)j, (int)wdata[i][j], (int)i, (int)j, (int)rdata[i][j]); + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) + if (wdata[i][j] != rdata[i][j]) { + TestErrPrintf("Array data information doesn't match!, wdata[%d][%d]=%d, rdata[%d][%d]=%d\n", + (int)i, (int)j, (int)wdata[i][j], (int)i, (int)j, (int)rdata[i][j]); continue; } /* end if */ @@ -189,7 +188,6 @@ test_array_atomic_1d(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_array_atomic_1d() */ - /*------------------------------------------------------------------------- * Function: test_array_funcs * @@ -203,48 +201,52 @@ test_array_atomic_1d(void) static void test_array_funcs(void) { - hid_t type; /* Datatype ID */ - hsize_t tdims1[] = {ARRAY1_DIM1}; - size_t size; - H5T_pad_t inpad; - H5T_norm_t norm; - H5T_cset_t cset; - H5T_str_t strpad; - herr_t ret; /* Generic return value */ + hid_t type; /* Datatype ID */ + hsize_t tdims1[] = {ARRAY1_DIM1}; + size_t size; + H5T_pad_t inpad; + H5T_norm_t norm; + H5T_cset_t cset; + H5T_str_t strpad; + herr_t ret; /* Generic return value */ /* Create a datatype to refer to */ type = H5Tarray_create2(H5T_IEEE_F32BE, ARRAY1_RANK, tdims1); CHECK(type, FAIL, "H5Tarray_create2"); - size=H5Tget_precision(type); + size = H5Tget_precision(type); CHECK(size, 0, "H5Tget_precision"); - size=H5Tget_size(type); + size = H5Tget_size(type); CHECK(size, 0, "H5Tget_size"); - size=H5Tget_ebias(type); + size = H5Tget_ebias(type); CHECK(size, 0, "H5Tget_ebias"); - ret=H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE); + ret = H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE); CHECK(ret, FAIL, "H5Tset_pad"); - inpad=H5Tget_inpad(type); + inpad = H5Tget_inpad(type); CHECK(inpad, FAIL, "H5Tget_inpad"); - norm=H5Tget_norm(type); + norm = H5Tget_norm(type); CHECK(norm, FAIL, "H5Tget_norm"); - ret=H5Tset_offset(type, (size_t)16); + ret = H5Tset_offset(type, (size_t)16); CHECK(ret, FAIL, "H5Tset_offset"); - H5E_BEGIN_TRY { - cset=H5Tget_cset(type); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + cset = H5Tget_cset(type); + } + H5E_END_TRY; VERIFY(cset, FAIL, "H5Tget_cset"); - H5E_BEGIN_TRY { - strpad=H5Tget_strpad(type); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + strpad = H5Tget_strpad(type); + } + H5E_END_TRY; VERIFY(strpad, FAIL, "H5Tget_strpad"); /* Close datatype */ @@ -252,7 +254,6 @@ test_array_funcs(void) CHECK(ret, FAIL, "H5Tclose"); } /* end test_array_funcs() */ - /*------------------------------------------------------------------------- * Function: test_array_atomic_3d * @@ -266,27 +267,27 @@ test_array_funcs(void) static void test_array_atomic_3d(void) { - int wdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information to write */ - int rdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information read in */ - hid_t fid; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims2[] = {ARRAY2_DIM1,ARRAY2_DIM2,ARRAY2_DIM3}; - int ndims; /* Array rank for reading */ - hsize_t rdims2[H5S_MAX_RANK]; /* Array dimensions for reading */ - int i,j,k,l; /* counting variables */ - herr_t ret; /* Generic return value */ + int wdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information to write */ + int rdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information read in */ + hid_t fid; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims2[] = {ARRAY2_DIM1, ARRAY2_DIM2, ARRAY2_DIM3}; + int ndims; /* Array rank for reading */ + hsize_t rdims2[H5S_MAX_RANK]; /* Array dimensions for reading */ + int i, j, k, l; /* counting variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing 3-D Array of Atomic Datatypes Functionality\n")); /* Allocate and initialize array data to write */ - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < ARRAY2_DIM1; j++) - for(k = 0; k < ARRAY2_DIM2; k++) - for(l = 0; l < ARRAY2_DIM3; l++) + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY2_DIM1; j++) + for (k = 0; k < ARRAY2_DIM2; k++) + for (l = 0; l < ARRAY2_DIM3; l++) wdata[i][j][k][l] = i * 1000 + j * 100 + k * 10 + l; /* Create file */ @@ -325,7 +326,6 @@ test_array_atomic_3d(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -335,7 +335,7 @@ test_array_atomic_3d(void) CHECK(dataset, FAIL, "H5Dopen2"); /* Get the datatype */ - tid = H5Dget_type (dataset); + tid = H5Dget_type(dataset); CHECK(tid, FAIL, "H5Dget_type"); /* Check the array rank */ @@ -347,9 +347,10 @@ test_array_atomic_3d(void) CHECK(ret, FAIL, "H5Tget_array_dims2"); /* Check the array dimensions */ - for(i = 0; i < ndims; i++) - if(rdims2[i] != tdims2[i]) { - TestErrPrintf("Array dimension information doesn't match!, rdims2[%d]=%d, tdims2[%d]=%d\n", (int)i, (int)rdims2[i], (int)i, (int)tdims2[i]); + for (i = 0; i < ndims; i++) + if (rdims2[i] != tdims2[i]) { + TestErrPrintf("Array dimension information doesn't match!, rdims2[%d]=%d, tdims2[%d]=%d\n", + (int)i, (int)rdims2[i], (int)i, (int)tdims2[i]); continue; } /* end if */ @@ -358,12 +359,15 @@ test_array_atomic_3d(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < ARRAY2_DIM1; j++) - for(k = 0; k < ARRAY2_DIM2; k++) - for(l = 0; l < ARRAY2_DIM3; l++) - if(wdata[i][j][k][l] != rdata[i][j][k][l]) { - TestErrPrintf("Array data information doesn't match!, wdata[%d][%d][%d][%d]=%d, rdata[%d][%d][%d][%d]=%d\n", (int)i, (int)j, (int)k, (int)l, (int)wdata[i][j][k][l], (int)i, (int)j, (int)k, (int)l, (int)rdata[i][j][k][l]); + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY2_DIM1; j++) + for (k = 0; k < ARRAY2_DIM2; k++) + for (l = 0; l < ARRAY2_DIM3; l++) + if (wdata[i][j][k][l] != rdata[i][j][k][l]) { + TestErrPrintf("Array data information doesn't match!, wdata[%d][%d][%d][%d]=%d, " + "rdata[%d][%d][%d][%d]=%d\n", + (int)i, (int)j, (int)k, (int)l, (int)wdata[i][j][k][l], (int)i, (int)j, + (int)k, (int)l, (int)rdata[i][j][k][l]); continue; } /* end if */ @@ -381,7 +385,6 @@ test_array_atomic_3d(void) } /* end test_array_atomic_3d() */ - /*------------------------------------------------------------------------- * Function: test_array_array_atomic * @@ -395,31 +398,31 @@ test_array_atomic_3d(void) static void test_array_array_atomic(void) { - int wdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information to write */ - int rdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information read in */ - hid_t fid; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid1; /* 1-D array Datatype ID */ - hid_t tid2; /* 2-D array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - hsize_t tdims2[] = {ARRAY3_DIM1,ARRAY3_DIM2}; - int ndims1; /* Array rank for reading */ - int ndims2; /* Array rank for reading */ - hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ - hsize_t rdims2[H5S_MAX_RANK]; /* Array dimensions for reading */ - int i,j,k,l; /* counting variables */ - herr_t ret; /* Generic return value */ + int wdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information to write */ + int rdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information read in */ + hid_t fid; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid1; /* 1-D array Datatype ID */ + hid_t tid2; /* 2-D array Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + hsize_t tdims2[] = {ARRAY3_DIM1, ARRAY3_DIM2}; + int ndims1; /* Array rank for reading */ + int ndims2; /* Array rank for reading */ + hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ + hsize_t rdims2[H5S_MAX_RANK]; /* Array dimensions for reading */ + int i, j, k, l; /* counting variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing 1-D Array 2-D Arrays of Atomic Datatypes Functionality\n")); /* Allocate and initialize array data to write */ - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < ARRAY1_DIM1; j++) - for(k = 0; k < ARRAY3_DIM1; k++) - for(l = 0; l < ARRAY3_DIM2; l++) + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) + for (k = 0; k < ARRAY3_DIM1; k++) + for (l = 0; l < ARRAY3_DIM2; l++) wdata[i][j][k][l] = i * 1000 + j * 100 + k * 10 + l; /* Create file */ @@ -464,7 +467,6 @@ test_array_array_atomic(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -486,9 +488,10 @@ test_array_array_atomic(void) CHECK(ret, FAIL, "H5Tget_array_dims2"); /* Check the array dimensions */ - for(i = 0; i < ndims1; i++) - if(rdims1[i] != tdims1[i]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n", (int)i, (int)rdims1[i], (int)i, (int)tdims1[i]); + for (i = 0; i < ndims1; i++) + if (rdims1[i] != tdims1[i]) { + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n", + (int)i, (int)rdims1[i], (int)i, (int)tdims1[i]); continue; } /* end if */ @@ -505,9 +508,10 @@ test_array_array_atomic(void) CHECK(ret, FAIL, "H5Tget_array_dims2"); /* Check the array dimensions */ - for(i = 0; i < ndims2; i++) - if(rdims2[i] != tdims2[i]) { - TestErrPrintf("Array dimension information doesn't match!, rdims2[%d]=%d, tdims2[%d]=%d\n", (int)i, (int)rdims2[i], (int)i, (int)tdims2[i]); + for (i = 0; i < ndims2; i++) + if (rdims2[i] != tdims2[i]) { + TestErrPrintf("Array dimension information doesn't match!, rdims2[%d]=%d, tdims2[%d]=%d\n", + (int)i, (int)rdims2[i], (int)i, (int)tdims2[i]); continue; } /* end if */ @@ -516,12 +520,15 @@ test_array_array_atomic(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < ARRAY1_DIM1; j++) - for(k = 0; k < ARRAY3_DIM1; k++) - for(l = 0; l < ARRAY3_DIM2; l++) - if(wdata[i][j][k][l] != rdata[i][j][k][l]) { - TestErrPrintf("Array data information doesn't match!, wdata[%d][%d][%d][%d]=%d, rdata[%d][%d][%d][%d]=%d\n", (int)i, (int)j, (int)k, (int)l, (int)wdata[i][j][k][l], (int)i, (int)j, (int)k, (int)l, (int)rdata[i][j][k][l]); + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) + for (k = 0; k < ARRAY3_DIM1; k++) + for (l = 0; l < ARRAY3_DIM2; l++) + if (wdata[i][j][k][l] != rdata[i][j][k][l]) { + TestErrPrintf("Array data information doesn't match!, wdata[%d][%d][%d][%d]=%d, " + "rdata[%d][%d][%d][%d]=%d\n", + (int)i, (int)j, (int)k, (int)l, (int)wdata[i][j][k][l], (int)i, (int)j, + (int)k, (int)l, (int)rdata[i][j][k][l]); continue; } /* end if */ @@ -540,7 +547,6 @@ test_array_array_atomic(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_array_array_atomic() */ - /*------------------------------------------------------------------------- * Function: test_array_compound_atomic * @@ -554,35 +560,35 @@ test_array_array_atomic(void) static void test_array_compound_atomic(void) { - typedef struct { /* Typedef for compound datatype */ - int i; + typedef struct { /* Typedef for compound datatype */ + int i; float f; } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Compound Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int ndims; /* Array rank for reading */ - hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ - int nmemb; /* Number of compound members */ - char *mname; /* Name of compound field */ - size_t off; /* Offset of compound field */ - hid_t mtid; /* Datatype ID for field */ - int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ + s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* Compound Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int ndims; /* Array rank for reading */ + hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ + int nmemb; /* Number of compound members */ + char * mname; /* Name of compound field */ + size_t off; /* Offset of compound field */ + hid_t mtid; /* Datatype ID for field */ + int i, j; /* counting variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing 1-D Array of Compound Atomic Datatypes Functionality\n")); /* Initialize array data to write */ - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < ARRAY1_DIM1; j++) { + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) { wdata[i][j].i = i * 10 + j; wdata[i][j].f = (float)i * 2.5F + (float)j; } /* end for */ @@ -639,7 +645,6 @@ test_array_compound_atomic(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -654,31 +659,32 @@ test_array_compound_atomic(void) /* Check the array rank */ ndims = H5Tget_array_ndims(tid1); - VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims"); + VERIFY(ndims, ARRAY1_RANK, "H5Tget_array_ndims"); /* Get the array dimensions */ ret = H5Tget_array_dims2(tid1, rdims1); CHECK(ret, FAIL, "H5Tget_array_dims2"); /* Check the array dimensions */ - for(i = 0; i < ndims; i++) - if(rdims1[i] != tdims1[i]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n", (int)i, (int)rdims1[i], (int)i, (int)tdims1[i]); + for (i = 0; i < ndims; i++) + if (rdims1[i] != tdims1[i]) { + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%d, tdims1[%d]=%d\n", + (int)i, (int)rdims1[i], (int)i, (int)tdims1[i]); continue; } /* end if */ /* Get the compound datatype */ - tid2 = H5Tget_super (tid1); + tid2 = H5Tget_super(tid1); CHECK(tid2, FAIL, "H5Tget_super"); /* Check the number of members */ nmemb = H5Tget_nmembers(tid2); - VERIFY(nmemb,2,"H5Tget_nmembers"); + VERIFY(nmemb, 2, "H5Tget_nmembers"); /* Check the 1st field's name */ mname = H5Tget_member_name(tid2, 0); CHECK_PTR(mname, "H5Tget_member_name"); - if(HDstrcmp(mname, "i") != 0) + if (HDstrcmp(mname, "i") != 0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); H5free_memory(mname); @@ -689,7 +695,7 @@ test_array_compound_atomic(void) /* Check the 1st field's datatype */ mtid = H5Tget_member_type(tid2, 0); CHECK(mtid, FAIL, "H5Tget_member_type"); - if((ret = H5Tequal(mtid,H5T_NATIVE_INT)) <= 0) + if ((ret = H5Tequal(mtid, H5T_NATIVE_INT)) <= 0) TestErrPrintf("Compound data type is incorrect!, ret=%d\n", (int)ret); ret = H5Tclose(mtid); CHECK(mtid, FAIL, "H5Tclose"); @@ -697,7 +703,7 @@ test_array_compound_atomic(void) /* Check the 2nd field's name */ mname = H5Tget_member_name(tid2, 1); CHECK_PTR(mname, "H5Tget_member_name"); - if(HDstrcmp(mname, "f") != 0) + if (HDstrcmp(mname, "f") != 0) TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); H5free_memory(mname); @@ -708,7 +714,7 @@ test_array_compound_atomic(void) /* Check the 2nd field's datatype */ mtid = H5Tget_member_type(tid2, 1); CHECK(mtid, FAIL, "H5Tget_member_type"); - if((ret = H5Tequal(mtid, H5T_NATIVE_FLOAT)) <= 0) + if ((ret = H5Tequal(mtid, H5T_NATIVE_FLOAT)) <= 0) TestErrPrintf("Compound data type is incorrect!, ret=%d\n", (int)ret); ret = H5Tclose(mtid); CHECK(mtid, FAIL, "H5Tclose"); @@ -722,17 +728,21 @@ test_array_compound_atomic(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < ARRAY1_DIM1; j++) { - if(wdata[i][j].i != rdata[i][j].i) { - TestErrPrintf("Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n", (int)i, (int)j, (int)wdata[i][j].i, (int)i, (int)j, (int)rdata[i][j].i); + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < ARRAY1_DIM1; j++) { + if (wdata[i][j].i != rdata[i][j].i) { + TestErrPrintf( + "Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n", (int)i, + (int)j, (int)wdata[i][j].i, (int)i, (int)j, (int)rdata[i][j].i); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(wdata[i][j].f, rdata[i][j].f)) { - TestErrPrintf("Array data information doesn't match!, wdata[%d][%d].f=%f, rdata[%d][%d].f=%f\n", (int)i, (int)j, (double)wdata[i][j].f, (int)i, (int)j, (double)rdata[i][j].f); + if (!H5_FLT_ABS_EQUAL(wdata[i][j].f, rdata[i][j].f)) { + TestErrPrintf( + "Array data information doesn't match!, wdata[%d][%d].f=%f, rdata[%d][%d].f=%f\n", (int)i, + (int)j, (double)wdata[i][j].f, (int)i, (int)j, (double)rdata[i][j].f); continue; } /* end if */ - } /* end for */ + } /* end for */ /* Close Datatype */ ret = H5Tclose(tid1); @@ -747,7 +757,6 @@ test_array_compound_atomic(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_array_compound_atomic() */ - /*------------------------------------------------------------------------- * Function: test_array_compound_array * @@ -761,39 +770,39 @@ test_array_compound_atomic(void) static void test_array_compound_array(void) { - typedef struct { /* Typedef for compound datatype */ - int i; + typedef struct { /* Typedef for compound datatype */ + int i; float f[ARRAY1_DIM1]; } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Compound Datatype ID */ - hid_t tid3; /* Nested Array Datatype ID */ + s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information read in */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* Compound Datatype ID */ + hid_t tid3; /* Nested Array Datatype ID */ hsize_t sdims1[] = {SPACE1_DIM1}; hsize_t tdims1[] = {ARRAY1_DIM1}; - int ndims; /* Array rank for reading */ - hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ - int nmemb; /* Number of compound members */ - char *mname; /* Name of compound field */ - size_t off; /* Offset of compound field */ - hid_t mtid; /* Datatype ID for field */ - H5T_class_t mclass; /* Datatype class for field */ - int i,j,k; /* counting variables */ - herr_t ret; /* Generic return value */ + int ndims; /* Array rank for reading */ + hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ + int nmemb; /* Number of compound members */ + char * mname; /* Name of compound field */ + size_t off; /* Offset of compound field */ + hid_t mtid; /* Datatype ID for field */ + H5T_class_t mclass; /* Datatype class for field */ + int i, j, k; /* counting variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing 1-D Array of Compound Array Datatypes Functionality\n")); /* Initialize array data to write */ - for(i=0; ioffset[0] = HOFFSET(CmpField, a); - dtsinfo->offset[1] = HOFFSET(CmpField, b); - dtsinfo->offset[2] = HOFFSET(CmpField, c); + dtsinfo->offset[0] = HOFFSET(CmpField, a); + dtsinfo->offset[1] = HOFFSET(CmpField, b); + dtsinfo->offset[2] = HOFFSET(CmpField, c); /* Initialize the data type IDs */ /* ---------------------------- */ @@ -1629,17 +1653,15 @@ test_array_bkg(void) dtsinfo->datatype[1] = H5T_NATIVE_FLOAT; dtsinfo->datatype[2] = H5T_NATIVE_DOUBLE; - /* Initialize the names of data members */ /* ------------------------------------ */ for (i = 0; i < dtsinfo->nsubfields; i++) - dtsinfo->name[i] = (char *)HDcalloc((size_t)20, sizeof(char)); + dtsinfo->name[i] = (char *)HDcalloc((size_t)20, sizeof(char)); HDstrcpy(dtsinfo->name[0], "One"); HDstrcpy(dtsinfo->name[1], "Two"); HDstrcpy(dtsinfo->name[2], "Three"); - /* Create file */ /* ----------- */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1647,22 +1669,21 @@ test_array_bkg(void) /* Create data space */ /* ----------------- */ - space = H5Screate_simple(RANK, dim, NULL); + space = H5Screate_simple(RANK, dim, NULL); CHECK(space, FAIL, "H5Screate_simple"); /* Create the memory data type */ /* --------------------------- */ - type = H5Tcreate(H5T_COMPOUND, sizeof(CmpField)); + type = H5Tcreate(H5T_COMPOUND, sizeof(CmpField)); CHECK(type, FAIL, "H5Tcreate"); - /* Add members to the compound data type */ /* -------------------------------------- */ - for ( i = 0; i < dtsinfo->nsubfields; i++) { + for (i = 0; i < dtsinfo->nsubfields; i++) { array_dt = H5Tarray_create2(dtsinfo->datatype[i], ndims[i], dima); CHECK(array_dt, FAIL, "H5Tarray_create2"); - status = H5Tinsert (type, dtsinfo->name[i], dtsinfo->offset[i], array_dt); + status = H5Tinsert(type, dtsinfo->name[i], dtsinfo->offset[i], array_dt); CHECK(status, FAIL, "H5Tinsert"); status = H5Tclose(array_dt); @@ -1686,28 +1707,29 @@ test_array_bkg(void) /* ------------------- */ for (i = 0; i < LENGTH; i++) { for (j = 0; j < ALEN; j++) { - if(cf[i].a[j]!=cfr[i].a[j]) { - TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); + if (cf[i].a[j] != cfr[i].a[j]) { + TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n", (int)i, + (int)j, (int)cf[i].a[j], (int)i, (int)j, (int)cfr[i].a[j]); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { - TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); + if (!H5_FLT_ABS_EQUAL(cf[i].b[j], cfr[i].b[j])) { + TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n", (int)i, + (int)j, (double)cf[i].b[j], (int)i, (int)j, (double)cfr[i].b[j]); continue; } /* end if */ - if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { - TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); + if (!H5_DBL_ABS_EQUAL(cf[i].c[j], cfr[i].c[j])) { + TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n", (int)i, + (int)j, (double)cf[i].c[j], (int)i, (int)j, (double)cfr[i].c[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ - + } /* end for */ + } /* end for */ /* Release memory resources */ /* ------------------------ */ for (i = 0; i < dtsinfo->nsubfields; i++) HDfree(dtsinfo->name[i]); - /* Release IDs */ /* ----------- */ status = H5Tclose(type); @@ -1722,7 +1744,6 @@ test_array_bkg(void) status = H5Fclose(fid); CHECK(status, FAIL, "H5Fclose"); - /******************************/ /* Reopen the file and update */ /******************************/ @@ -1739,33 +1760,34 @@ test_array_bkg(void) array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, dima); CHECK(array_dt, FAIL, "H5Tarray_create2"); - status = H5Tinsert (type, "Two", HOFFSET(fld_t, b), array_dt); + status = H5Tinsert(type, "Two", HOFFSET(fld_t, b), array_dt); CHECK(status, FAIL, "H5Tinsert"); /* Initialize the data to overwrite */ /* -------------------------------- */ - for (i=0; i< LENGTH; i++) + for (i = 0; i < LENGTH; i++) for (j = 0; j < ALEN; j++) cf[i].b[j] = fld[i].b[j] = 1.313F; - status = H5Dwrite (dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, fld); + status = H5Dwrite(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, fld); CHECK(status, FAIL, "H5Dwrite"); /* Read just the field changed */ - status = H5Dread (dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, fldr); + status = H5Dread(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, fldr); CHECK(status, FAIL, "H5Dread"); - for (i=0; i< LENGTH; i++) + for (i = 0; i < LENGTH; i++) for (j = 0; j < ALEN; j++) - if(!H5_FLT_ABS_EQUAL(fld[i].b[j],fldr[i].b[j])) { - TestErrPrintf("Field data doesn't match, fld[%d].b[%d]=%f, fldr[%d].b[%d]=%f\n",(int)i,(int)j,(double)fld[i].b[j],(int)i,(int)j,(double)fldr[i].b[j]); + if (!H5_FLT_ABS_EQUAL(fld[i].b[j], fldr[i].b[j])) { + TestErrPrintf("Field data doesn't match, fld[%d].b[%d]=%f, fldr[%d].b[%d]=%f\n", (int)i, + (int)j, (double)fld[i].b[j], (int)i, (int)j, (double)fldr[i].b[j]); continue; } /* end if */ - status = H5Tclose (type); + status = H5Tclose(type); CHECK(status, FAIL, "H5Tclose"); - status = H5Tclose (array_dt); + status = H5Tclose(array_dt); CHECK(status, FAIL, "H5Tclose"); type = H5Dget_type(dataset); @@ -1779,25 +1801,28 @@ test_array_bkg(void) /* ------------------- */ for (i = 0; i < LENGTH; i++) { for (j = 0; j < ALEN; j++) { - if(cf[i].a[j]!=cfr[i].a[j]) { - TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); + if (cf[i].a[j] != cfr[i].a[j]) { + TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n", (int)i, + (int)j, (int)cf[i].a[j], (int)i, (int)j, (int)cfr[i].a[j]); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { - TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); + if (!H5_FLT_ABS_EQUAL(cf[i].b[j], cfr[i].b[j])) { + TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n", (int)i, + (int)j, (double)cf[i].b[j], (int)i, (int)j, (double)cfr[i].b[j]); continue; } /* end if */ - if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { - TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); + if (!H5_DBL_ABS_EQUAL(cf[i].c[j], cfr[i].c[j])) { + TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n", (int)i, + (int)j, (double)cf[i].c[j], (int)i, (int)j, (double)cfr[i].c[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ status = H5Dclose(dataset); CHECK(status, FAIL, "H5Dclose"); - status = H5Tclose (type); + status = H5Tclose(type); CHECK(status, FAIL, "H5Tclose"); status = H5Fclose(fid); @@ -1816,10 +1841,9 @@ test_array_bkg(void) type = H5Dget_type(dataset); CHECK(type, FAIL, "H5Dget_type"); - /* Reset the data to read in */ /* ------------------------- */ - HDmemset(cfr, 0, sizeof(CmpField)*LENGTH); + HDmemset(cfr, 0, sizeof(CmpField) * LENGTH); status = H5Dread(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, cfr); CHECK(status, FAIL, "H5Dread"); @@ -1828,25 +1852,28 @@ test_array_bkg(void) /* ------------------- */ for (i = 0; i < LENGTH; i++) { for (j = 0; j < ALEN; j++) { - if(cf[i].a[j]!=cfr[i].a[j]) { - TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); + if (cf[i].a[j] != cfr[i].a[j]) { + TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n", (int)i, + (int)j, (int)cf[i].a[j], (int)i, (int)j, (int)cfr[i].a[j]); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { - TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); + if (!H5_FLT_ABS_EQUAL(cf[i].b[j], cfr[i].b[j])) { + TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n", (int)i, + (int)j, (double)cf[i].b[j], (int)i, (int)j, (double)cfr[i].b[j]); continue; } /* end if */ - if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { - TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); + if (!H5_DBL_ABS_EQUAL(cf[i].c[j], cfr[i].c[j])) { + TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n", (int)i, + (int)j, (double)cf[i].c[j], (int)i, (int)j, (double)cfr[i].c[j]); continue; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ status = H5Dclose(dataset); CHECK(status, FAIL, "H5Dclose"); - status = H5Tclose (type); + status = H5Tclose(type); CHECK(status, FAIL, "H5Tclose"); status = H5Fclose(fid); @@ -1855,7 +1882,6 @@ test_array_bkg(void) HDfree(dtsinfo); } /* end test_array_bkg() */ - /*------------------------------------------------------------------------- * Function: test_compat * @@ -1873,20 +1899,20 @@ static void test_compat(void) { const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Datatype ID */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* Datatype ID */ hsize_t tdims1[] = {ARRAY1_DIM1}; - int ndims; /* Array rank for reading */ - hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ - H5T_class_t mclass; /* Datatype class for VL */ - int nmemb; /* Number of compound members */ - char *mname; /* Name of compound field */ - size_t off; /* Offset of compound field */ - hid_t mtid; /* Datatype ID for field */ - int i; /* Index variables */ - herr_t ret; /* Generic return value */ + int ndims; /* Array rank for reading */ + hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ + H5T_class_t mclass; /* Datatype class for VL */ + int nmemb; /* Number of compound members */ + char * mname; /* Name of compound field */ + size_t off; /* Offset of compound field */ + hid_t mtid; /* Datatype ID for field */ + int i; /* Index variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Array Datatypes Compatibility Functionality\n")); @@ -1906,78 +1932,78 @@ test_compat(void) CHECK_I(fid1, "H5Fopen"); /* Only try to proceed if the file is around */ - if (fid1 >= 0){ + if (fid1 >= 0) { /* Open the first dataset (with no array fields) */ dataset = H5Dopen2(fid1, "Dataset1", H5P_DEFAULT); CHECK_I(dataset, "H5Dopen2"); /* Get the datatype */ - tid1=H5Dget_type(dataset); + tid1 = H5Dget_type(dataset); CHECK_I(tid1, "H5Dget_type"); /* Verify datatype class */ - mclass=H5Tget_class(tid1); + mclass = H5Tget_class(tid1); VERIFY(mclass, H5T_COMPOUND, "H5Tget_class"); /* Get the number of compound datatype fields */ - nmemb=H5Tget_nmembers(tid1); - VERIFY(nmemb,3,"H5Tget_nmembers"); + nmemb = H5Tget_nmembers(tid1); + VERIFY(nmemb, 3, "H5Tget_nmembers"); /* Check the 1st field's name */ - mname=H5Tget_member_name(tid1,0); + mname = H5Tget_member_name(tid1, 0); CHECK_PTR(mname, "H5Tget_member_name"); - if(HDstrcmp(mname,"i")!=0) - TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); + if (HDstrcmp(mname, "i") != 0) + TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); H5free_memory(mname); /* Check the 1st field's offset */ - off=H5Tget_member_offset(tid1,0); + off = H5Tget_member_offset(tid1, 0); VERIFY(off, 0, "H5Tget_member_offset"); /* Check the 1st field's datatype */ - mtid=H5Tget_member_type(tid1,0); + mtid = H5Tget_member_type(tid1, 0); CHECK(mtid, FAIL, "H5Tget_member_type"); - if((ret=H5Tequal(mtid,H5T_STD_I16LE))<=0) - TestErrPrintf("Compound data type is incorrect!, ret=%d\n",(int)ret); - ret=H5Tclose(mtid); + if ((ret = H5Tequal(mtid, H5T_STD_I16LE)) <= 0) + TestErrPrintf("Compound data type is incorrect!, ret=%d\n", (int)ret); + ret = H5Tclose(mtid); CHECK(mtid, FAIL, "H5Tclose"); /* Check the 2nd field's name */ - mname=H5Tget_member_name(tid1,1); + mname = H5Tget_member_name(tid1, 1); CHECK_PTR(mname, "H5Tget_member_name"); - if(HDstrcmp(mname,"f")!=0) - TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); + if (HDstrcmp(mname, "f") != 0) + TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); H5free_memory(mname); /* Check the 2nd field's offset */ - off=H5Tget_member_offset(tid1,1); + off = H5Tget_member_offset(tid1, 1); VERIFY(off, 4, "H5Tget_member_offset"); /* Check the 2nd field's datatype */ - mtid=H5Tget_member_type(tid1,1); + mtid = H5Tget_member_type(tid1, 1); CHECK(mtid, FAIL, "H5Tget_member_type"); - if((ret=H5Tequal(mtid,H5T_IEEE_F32LE))<=0) - TestErrPrintf("Compound data type is incorrect!, ret=%d\n",(int)ret); - ret=H5Tclose(mtid); + if ((ret = H5Tequal(mtid, H5T_IEEE_F32LE)) <= 0) + TestErrPrintf("Compound data type is incorrect!, ret=%d\n", (int)ret); + ret = H5Tclose(mtid); CHECK(mtid, FAIL, "H5Tclose"); /* Check the 3rd field's name */ - mname=H5Tget_member_name(tid1,2); + mname = H5Tget_member_name(tid1, 2); CHECK_PTR(mname, "H5Tget_member_name"); - if(HDstrcmp(mname,"l")!=0) - TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); + if (HDstrcmp(mname, "l") != 0) + TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); H5free_memory(mname); /* Check the 3rd field's offset */ - off=H5Tget_member_offset(tid1,2); + off = H5Tget_member_offset(tid1, 2); VERIFY(off, 8, "H5Tget_member_offset"); /* Check the 3rd field's datatype */ - mtid=H5Tget_member_type(tid1,2); + mtid = H5Tget_member_type(tid1, 2); CHECK(mtid, FAIL, "H5Tget_member_type"); - if((ret=H5Tequal(mtid,H5T_STD_I32LE))<=0) - TestErrPrintf("Compound data type is incorrect!, ret=%d\n",(int)ret); - ret=H5Tclose(mtid); + if ((ret = H5Tequal(mtid, H5T_STD_I32LE)) <= 0) + TestErrPrintf("Compound data type is incorrect!, ret=%d\n", (int)ret); + ret = H5Tclose(mtid); CHECK(mtid, FAIL, "H5Tclose"); /* Close the datatype */ @@ -1988,149 +2014,154 @@ test_compat(void) ret = H5Dclose(dataset); CHECK_I(ret, "H5Dclose"); - /* Open the second dataset (with array fields) */ dataset = H5Dopen2(fid1, "Dataset2", H5P_DEFAULT); CHECK_I(dataset, "H5Dopen2"); /* Get the datatype */ - tid1=H5Dget_type(dataset); + tid1 = H5Dget_type(dataset); CHECK_I(tid1, "H5Dget_type"); /* Verify datatype class */ - mclass=H5Tget_class(tid1); + mclass = H5Tget_class(tid1); VERIFY(mclass, H5T_COMPOUND, "H5Tget_class"); /* Get the number of compound datatype fields */ - nmemb=H5Tget_nmembers(tid1); - VERIFY(nmemb,4,"H5Tget_nmembers"); + nmemb = H5Tget_nmembers(tid1); + VERIFY(nmemb, 4, "H5Tget_nmembers"); /* Check the 1st field's name */ - mname=H5Tget_member_name(tid1,0); + mname = H5Tget_member_name(tid1, 0); CHECK_PTR(mname, "H5Tget_member_name"); - if(mname && HDstrcmp(mname,"i")!=0) - TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); - if(mname) H5free_memory(mname); + if (mname && HDstrcmp(mname, "i") != 0) + TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); + if (mname) + H5free_memory(mname); /* Check the 1st field's offset */ - off=H5Tget_member_offset(tid1,0); + off = H5Tget_member_offset(tid1, 0); VERIFY(off, 0, "H5Tget_member_offset"); /* Check the 1st field's datatype */ - mtid=H5Tget_member_type(tid1,0); + mtid = H5Tget_member_type(tid1, 0); CHECK(mtid, FAIL, "H5Tget_member_type"); - if((ret=H5Tequal(mtid,H5T_STD_I16LE))<=0) - TestErrPrintf("Compound data type is incorrect!, ret=%d\n",(int)ret); - ret=H5Tclose(mtid); + if ((ret = H5Tequal(mtid, H5T_STD_I16LE)) <= 0) + TestErrPrintf("Compound data type is incorrect!, ret=%d\n", (int)ret); + ret = H5Tclose(mtid); CHECK(mtid, FAIL, "H5Tclose"); /* Check the 2nd field's name */ - mname=H5Tget_member_name(tid1,1); + mname = H5Tget_member_name(tid1, 1); CHECK_PTR(mname, "H5Tget_member_name"); - if(mname && HDstrcmp(mname,"f")!=0) - TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname); - if(mname) H5free_memory(mname); + if (mname && HDstrcmp(mname, "f") != 0) + TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname); + if (mname) + H5free_memory(mname); /* Check the 2nd field's offset */ - off=H5Tget_member_offset(tid1,1); + off = H5Tget_member_offset(tid1, 1); VERIFY(off, 4, "H5Tget_member_offset"); /* Check the 2nd field's datatype */ - mtid=H5Tget_member_type(tid1,1); + mtid = H5Tget_member_type(tid1, 1); CHECK(mtid, FAIL, "H5Tget_member_type"); /* Verify datatype class */ - mclass=H5Tget_class(mtid); + mclass = H5Tget_class(mtid); VERIFY(mclass, H5T_ARRAY, "H5Tget_class"); /* Check the array rank */ - ndims=H5Tget_array_ndims(mtid); - VERIFY(ndims,ARRAY1_RANK,"H5Tget_array_ndims"); + ndims = H5Tget_array_ndims(mtid); + VERIFY(ndims, ARRAY1_RANK, "H5Tget_array_ndims"); /* Get the array dimensions */ ret = H5Tget_array_dims2(mtid, rdims1); CHECK(ret, FAIL, "H5Tget_array_dims2"); /* Check the array dimensions */ - for(i=0; i 0) { - attr_name = (char*)HDcalloc((size_t)(attr_name_size + 1), sizeof(char)); + if (attr_name_size > 0) { + attr_name = (char *)HDcalloc((size_t)(attr_name_size + 1), sizeof(char)); CHECK_PTR(attr_name, "HDcalloc"); - if(attr_name) { + if (attr_name) { ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name); CHECK(ret, FAIL, "H5Aget_name"); ret = HDstrcmp(attr_name, ATTR_TMP_NAME); @@ -310,16 +311,17 @@ test_attr_basic_write(hid_t fapl) HDfree(attr_name); attr_name = NULL; } /* end if */ - } /* end if */ + } /* end if */ /* Read attribute information immediately, without closing attribute */ ret = H5Aread(attr, H5T_NATIVE_INT, read_data1); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(attr_data1[i] != read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, + attr_data1[i], i, read_data1[i]); /* Close attribute */ ret = H5Aclose(attr); @@ -333,11 +335,11 @@ test_attr_basic_write(hid_t fapl) attr_name_size = H5Aget_name(attr2, (size_t)0, NULL); CHECK(attr_name_size, FAIL, "H5Aget_name"); - if(attr_name_size > 0) { - attr_name = (char*)HDcalloc((size_t)(attr_name_size+1), sizeof(char)); + if (attr_name_size > 0) { + attr_name = (char *)HDcalloc((size_t)(attr_name_size + 1), sizeof(char)); CHECK_PTR(attr_name, "HDcalloc"); - if(attr_name) { + if (attr_name) { ret = (herr_t)H5Aget_name(attr2, (size_t)(attr_name_size + 1), attr_name); CHECK(ret, FAIL, "H5Aget_name"); ret = HDstrcmp(attr_name, ATTR1A_NAME); @@ -346,16 +348,17 @@ test_attr_basic_write(hid_t fapl) HDfree(attr_name); attr_name = NULL; } /* end if */ - } /* end if */ + } /* end if */ /* Read attribute information immediately, without closing attribute */ ret = H5Aread(attr2, H5T_NATIVE_INT, read_data1); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(attr_data1a[i] != read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1a[i], i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1a[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n", __LINE__, + i, attr_data1a[i], i, read_data1[i]); /* Close attribute */ ret = H5Aclose(attr2); @@ -413,8 +416,7 @@ test_attr_basic_write(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_basic_write() */ - +} /* test_attr_basic_write() */ /**************************************************************** ** @@ -424,15 +426,15 @@ test_attr_basic_write(hid_t fapl) static void test_attr_basic_read(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ - hid_t attr; /* Attribute ID */ - H5O_info2_t oinfo; /* Object info */ - int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t attr; /* Attribute ID */ + H5O_info2_t oinfo; /* Object info */ + int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */ int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */ - int i, j; /* Local index variables */ - herr_t ret; /* Generic return value */ + int i, j; /* Local index variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -459,9 +461,10 @@ test_attr_basic_read(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(attr_data1[i] != read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, + attr_data1[i], i, read_data1[i]); /* Close attribute */ ret = H5Aclose(attr); @@ -488,10 +491,11 @@ test_attr_basic_read(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR2_DIM1; i++) - for(j = 0; j < ATTR2_DIM2; j++) - if(attr_data2[i][j] != read_data2[i][j]) - TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n", __LINE__, i, j, attr_data2[i][j], i, j, read_data1[i]); + for (i = 0; i < ATTR2_DIM1; i++) + for (j = 0; j < ATTR2_DIM2; j++) + if (attr_data2[i][j] != read_data2[i][j]) + TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n", + __LINE__, i, j, attr_data2[i][j], i, j, read_data1[i]); /* Close attribute */ ret = H5Aclose(attr); @@ -504,8 +508,7 @@ test_attr_basic_read(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_basic_read() */ - +} /* test_attr_basic_read() */ /**************************************************************** ** @@ -516,13 +519,13 @@ test_attr_basic_read(hid_t fapl) static void test_attr_flush(hid_t fapl) { - hid_t fil, /* File ID */ - att, /* Attribute ID */ - spc, /* Dataspace ID */ - set; /* Dataset ID */ - double wdata=3.14159F; /* Data to write */ - double rdata; /* Data read in */ - herr_t ret; /* Generic return value */ + hid_t fil, /* File ID */ + att, /* Attribute ID */ + spc, /* Dataspace ID */ + set; /* Dataset ID */ + double wdata = 3.14159F; /* Data to write */ + double rdata; /* Data read in */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Flushing\n")); @@ -539,40 +542,39 @@ test_attr_flush(hid_t fapl) att = H5Acreate2(set, ATTR1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, H5P_DEFAULT); CHECK(att, FAIL, "H5Acreate2"); - ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); + ret = H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); CHECK(ret, FAIL, "H5Awrite"); - if(!H5_DBL_ABS_EQUAL(rdata, 0.0)) - TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,(double)0.0F); + if (!H5_DBL_ABS_EQUAL(rdata, 0.0)) + TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, (double)0.0F); - ret=H5Fflush(fil, H5F_SCOPE_GLOBAL); + ret = H5Fflush(fil, H5F_SCOPE_GLOBAL); CHECK(ret, FAIL, "H5Fflush"); - ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); + ret = H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); CHECK(ret, FAIL, "H5Awrite"); - if(!H5_DBL_ABS_EQUAL(rdata, 0.0)) - TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,(double)0.0F); + if (!H5_DBL_ABS_EQUAL(rdata, 0.0)) + TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, (double)0.0F); - ret=H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata); + ret = H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata); CHECK(ret, FAIL, "H5Awrite"); - ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); + ret = H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); CHECK(ret, FAIL, "H5Awrite"); - if(!H5_DBL_ABS_EQUAL(rdata,wdata)) - TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,wdata); + if (!H5_DBL_ABS_EQUAL(rdata, wdata)) + TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, wdata); - ret=H5Sclose(spc); + ret = H5Sclose(spc); CHECK(ret, FAIL, "H5Sclose"); - ret=H5Aclose(att); + ret = H5Aclose(att); CHECK(ret, FAIL, "H5Aclose"); - ret=H5Dclose(set); + ret = H5Dclose(set); CHECK(ret, FAIL, "H5Dclose"); - ret=H5Fclose(fil); + ret = H5Fclose(fil); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_flush() */ - +} /* test_attr_flush() */ /**************************************************************** ** @@ -582,17 +584,17 @@ test_attr_flush(hid_t fapl) static void test_attr_plist(hid_t fapl) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hid_t dsid = H5I_INVALID_HID; /* Dataspace ID (for dataset) */ - hid_t asid = H5I_INVALID_HID; /* Dataspace ID (for attribute) */ - hid_t aid = H5I_INVALID_HID; /* Attribute ID */ - hid_t acpl_id = H5I_INVALID_HID; /* Attribute creation property list ID */ - hid_t aapl_id = H5I_INVALID_HID; /* Attribute access property list ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - H5T_cset_t cset; /* Character set for attributes */ - herr_t ret; /* Generic return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t dsid = H5I_INVALID_HID; /* Dataspace ID (for dataset) */ + hid_t asid = H5I_INVALID_HID; /* Dataspace ID (for attribute) */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t acpl_id = H5I_INVALID_HID; /* Attribute creation property list ID */ + hid_t aapl_id = H5I_INVALID_HID; /* Attribute access property list ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + H5T_cset_t cset; /* Character set for attributes */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Property Lists\n")); @@ -695,8 +697,7 @@ test_attr_plist(hid_t fapl) CHECK(ret, FAIL, "H5Dclose"); ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_plist() */ - +} /* test_attr_plist() */ /**************************************************************** ** @@ -707,15 +708,15 @@ test_attr_plist(hid_t fapl) static void test_attr_compound_write(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t tid1; /* Attribute datatype ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2}; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t tid1; /* Attribute datatype ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR4_DIM1, ATTR4_DIM2}; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Multiple Attribute Functions\n")); @@ -740,13 +741,13 @@ test_attr_compound_write(hid_t fapl) tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct attr4_struct)); CHECK(tid1, FAIL, "H5Tcreate"); attr4_field1_off = HOFFSET(struct attr4_struct, i); - ret = H5Tinsert(tid1, ATTR4_FIELDNAME1, attr4_field1_off, H5T_NATIVE_INT); + ret = H5Tinsert(tid1, ATTR4_FIELDNAME1, attr4_field1_off, H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); attr4_field2_off = HOFFSET(struct attr4_struct, d); - ret = H5Tinsert(tid1, ATTR4_FIELDNAME2, attr4_field2_off, H5T_NATIVE_DOUBLE); + ret = H5Tinsert(tid1, ATTR4_FIELDNAME2, attr4_field2_off, H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); attr4_field3_off = HOFFSET(struct attr4_struct, c); - ret = H5Tinsert(tid1, ATTR4_FIELDNAME3, attr4_field3_off, H5T_NATIVE_SCHAR); + ret = H5Tinsert(tid1, ATTR4_FIELDNAME3, attr4_field3_off, H5T_NATIVE_SCHAR); CHECK(ret, FAIL, "H5Tinsert"); /* Create dataspace for 1st attribute */ @@ -784,8 +785,7 @@ test_attr_compound_write(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_compound_write() */ - +} /* test_attr_compound_write() */ /**************************************************************** ** @@ -795,26 +795,26 @@ test_attr_compound_write(hid_t fapl) static void test_attr_compound_read(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t space; /* Attribute dataspace */ - hid_t type; /* Attribute datatype */ - hid_t attr; /* Attribute ID */ - char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ - int rank; /* Attribute rank */ - hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */ - H5T_class_t t_class; /* Attribute datatype class */ - H5T_order_t order; /* Attribute datatype order */ - size_t size; /* Attribute datatype size as stored in file */ - int fields; /* # of Attribute datatype fields */ - char *fieldname; /* Name of a field */ - size_t offset; /* Attribute datatype field offset */ - hid_t field; /* Attribute field datatype */ + hid_t fid1; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t space; /* Attribute dataspace */ + hid_t type; /* Attribute datatype */ + hid_t attr; /* Attribute ID */ + char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ + int rank; /* Attribute rank */ + hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */ + H5T_class_t t_class; /* Attribute datatype class */ + H5T_order_t order; /* Attribute datatype order */ + size_t size; /* Attribute datatype size as stored in file */ + int fields; /* # of Attribute datatype fields */ + char * fieldname; /* Name of a field */ + size_t offset; /* Attribute datatype field offset */ + hid_t field; /* Attribute field datatype */ struct attr4_struct read_data4[ATTR4_DIM1][ATTR4_DIM2]; /* Buffer for reading 4th attribute */ - ssize_t name_len; /* Length of attribute name */ - H5O_info2_t oinfo; /* Object info */ - int i, j; /* Local index variables */ - herr_t ret; /* Generic return value */ + ssize_t name_len; /* Length of attribute name */ + H5O_info2_t oinfo; /* Object info */ + int i, j; /* Local index variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -833,7 +833,8 @@ test_attr_compound_read(hid_t fapl) VERIFY(oinfo.num_attrs, 1, "H5Oget_info3"); /* Open 1st attribute for the dataset */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Dataspace */ @@ -843,9 +844,9 @@ test_attr_compound_read(hid_t fapl) VERIFY(rank, ATTR4_RANK, "H5Sget_simple_extent_ndims"); ret = H5Sget_simple_extent_dims(space, dims, NULL); CHECK(ret, FAIL, "H5Sget_simple_extent_dims"); - if(dims[0] != ATTR4_DIM1) + if (dims[0] != ATTR4_DIM1) TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n", (int)dims[0], ATTR4_DIM1); - if(dims[1] != ATTR4_DIM2) + if (dims[1] != ATTR4_DIM2) TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n", (int)dims[1], ATTR4_DIM2); H5Sclose(space); @@ -856,11 +857,10 @@ test_attr_compound_read(hid_t fapl) VERIFY(t_class, H5T_COMPOUND, "H5Tget_class"); fields = H5Tget_nmembers(type); VERIFY(fields, 3, "H5Tget_nmembers"); - for(i = 0; i < fields; i++) { + for (i = 0; i < fields; i++) { fieldname = H5Tget_member_name(type, (unsigned)i); - if(!(HDstrcmp(fieldname, ATTR4_FIELDNAME1) || - HDstrcmp(fieldname, ATTR4_FIELDNAME2) || - HDstrcmp(fieldname, ATTR4_FIELDNAME3))) + if (!(HDstrcmp(fieldname, ATTR4_FIELDNAME1) || HDstrcmp(fieldname, ATTR4_FIELDNAME2) || + HDstrcmp(fieldname, ATTR4_FIELDNAME3))) TestErrPrintf("invalid field name for field #%d: %s\n", i, fieldname); H5free_memory(fieldname); } /* end for */ @@ -905,18 +905,22 @@ test_attr_compound_read(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR4_DIM1; i++) - for(j = 0; j < ATTR4_DIM2; j++) - if(HDmemcmp(&attr_data4[i][j], &read_data4[i][j], sizeof(struct attr4_struct))) { - HDprintf("%d: attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n", __LINE__, i, j, attr_data4[i][j].i, i, j, read_data4[i][j].i); - HDprintf("%d: attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n", __LINE__, i, j, attr_data4[i][j].d, i, j, read_data4[i][j].d); - TestErrPrintf("%d: attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n", __LINE__, i, j, attr_data4[i][j].c, i, j, read_data4[i][j].c); + for (i = 0; i < ATTR4_DIM1; i++) + for (j = 0; j < ATTR4_DIM2; j++) + if (HDmemcmp(&attr_data4[i][j], &read_data4[i][j], sizeof(struct attr4_struct))) { + HDprintf("%d: attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n", + __LINE__, i, j, attr_data4[i][j].i, i, j, read_data4[i][j].i); + HDprintf("%d: attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n", + __LINE__, i, j, attr_data4[i][j].d, i, j, read_data4[i][j].d); + TestErrPrintf( + "%d: attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n", + __LINE__, i, j, attr_data4[i][j].c, i, j, read_data4[i][j].c); } /* end if */ /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR4_NAME), "H5Aget_name"); - if(HDstrcmp(attr_name, ATTR4_NAME)) + if (HDstrcmp(attr_name, ATTR4_NAME)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR4_NAME); /* Close attribute datatype */ @@ -934,8 +938,7 @@ test_attr_compound_read(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_compound_read() */ - +} /* test_attr_compound_read() */ /**************************************************************** ** @@ -945,13 +948,13 @@ test_attr_compound_read(hid_t fapl) static void test_attr_scalar_write(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1000,8 +1003,7 @@ test_attr_scalar_write(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_scalar_write() */ - +} /* test_attr_scalar_write() */ /**************************************************************** ** @@ -1011,14 +1013,14 @@ test_attr_scalar_write(hid_t fapl) static void test_attr_scalar_read(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - H5S_class_t stype; /* Dataspace class */ - float rdata = 0.0F; /* Buffer for reading 1st attribute */ - H5O_info2_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + H5S_class_t stype; /* Dataspace class */ + float rdata = 0.0F; /* Buffer for reading 1st attribute */ + H5O_info2_t oinfo; /* Object info */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Scalar Attribute Reading Functions\n")); @@ -1045,9 +1047,9 @@ test_attr_scalar_read(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_FLT_ABS_EQUAL(rdata, attr_data5)) - HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Aread", (double)attr_data5, (double)rdata, (int)__LINE__, __FILE__); + if (!H5_FLT_ABS_EQUAL(rdata, attr_data5)) + HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Aread", + (double)attr_data5, (double)rdata, (int)__LINE__, __FILE__); /* Get the attribute's dataspace */ sid = H5Aget_space(attr); @@ -1071,8 +1073,7 @@ test_attr_scalar_read(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_scalar_read() */ - +} /* test_attr_scalar_read() */ /**************************************************************** ** @@ -1083,16 +1084,16 @@ test_attr_scalar_read(hid_t fapl) static void test_attr_mult_write(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2}; + hsize_t dims4[] = {ATTR3_DIM1, ATTR3_DIM2, ATTR3_DIM3}; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Multiple Attribute Functions\n")); @@ -1192,8 +1193,7 @@ test_attr_mult_write(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_mult_write() */ - +} /* test_attr_mult_write() */ /**************************************************************** ** @@ -1203,25 +1203,25 @@ test_attr_mult_write(hid_t fapl) static void test_attr_mult_read(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t space; /* Attribute dataspace */ - hid_t type; /* Attribute datatype */ - hid_t attr; /* Attribute ID */ - char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ - char temp_name[ATTR_NAME_LEN]; /* Buffer for mangling attribute names */ - int rank; /* Attribute rank */ - hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */ - H5T_class_t t_class; /* Attribute datatype class */ - H5T_order_t order; /* Attribute datatype order */ - size_t size; /* Attribute datatype size as stored in file */ - int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */ - int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */ + hid_t fid1; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t space; /* Attribute dataspace */ + hid_t type; /* Attribute datatype */ + hid_t attr; /* Attribute ID */ + char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ + char temp_name[ATTR_NAME_LEN]; /* Buffer for mangling attribute names */ + int rank; /* Attribute rank */ + hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */ + H5T_class_t t_class; /* Attribute datatype class */ + H5T_order_t order; /* Attribute datatype order */ + size_t size; /* Attribute datatype size as stored in file */ + int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */ + int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */ double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {{{0}}}; /* Buffer for reading 3rd attribute */ - ssize_t name_len; /* Length of attribute name */ - H5O_info2_t oinfo; /* Object info */ - int i, j, k; /* Local index values */ - herr_t ret; /* Generic return value */ + ssize_t name_len; /* Length of attribute name */ + H5O_info2_t oinfo; /* Object info */ + int i, j, k; /* Local index values */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1240,7 +1240,8 @@ test_attr_mult_read(hid_t fapl) VERIFY(oinfo.num_attrs, 3, "H5Oget_info3"); /* Open 1st attribute for the dataset */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Dataspace */ @@ -1250,7 +1251,7 @@ test_attr_mult_read(hid_t fapl) VERIFY(rank, ATTR1_RANK, "H5Sget_simple_extent_ndims"); ret = H5Sget_simple_extent_dims(space, dims, NULL); CHECK(ret, FAIL, "H5Sget_simple_extent_dims"); - if(dims[0] != ATTR1_DIM1) + if (dims[0] != ATTR1_DIM1) TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n", (int)dims[0], ATTR1_DIM1); H5Sclose(space); @@ -1270,22 +1271,23 @@ test_attr_mult_read(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(attr_data1[i] != read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, + attr_data1[i], i, read_data1[i]); /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name"); - if(HDstrcmp(attr_name, ATTR1_NAME)) + if (HDstrcmp(attr_name, ATTR1_NAME)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR1_NAME); /* Verify Name with too small of a buffer */ - name_len = H5Aget_name(attr,HDstrlen(ATTR1_NAME), attr_name); + name_len = H5Aget_name(attr, HDstrlen(ATTR1_NAME), attr_name); VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name"); - HDstrcpy(temp_name, ATTR1_NAME); /* make a copy of the name */ - temp_name[HDstrlen(ATTR1_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */ - if(HDstrcmp(attr_name, temp_name)) + HDstrcpy(temp_name, ATTR1_NAME); /* make a copy of the name */ + temp_name[HDstrlen(ATTR1_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */ + if (HDstrcmp(attr_name, temp_name)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, temp_name); /* Close attribute */ @@ -1293,7 +1295,8 @@ test_attr_mult_read(hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Open 2nd attribute for the dataset */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)1, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)1, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Dataspace */ @@ -1303,9 +1306,9 @@ test_attr_mult_read(hid_t fapl) VERIFY(rank, ATTR2_RANK, "H5Sget_simple_extent_ndims"); ret = H5Sget_simple_extent_dims(space, dims, NULL); CHECK(ret, FAIL, "H5Sget_simple_extent_dims"); - if(dims[0] != ATTR2_DIM1) + if (dims[0] != ATTR2_DIM1) TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n", (int)dims[0], ATTR2_DIM1); - if(dims[1] != ATTR2_DIM2) + if (dims[1] != ATTR2_DIM2) TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n", (int)dims[1], ATTR2_DIM2); H5Sclose(space); @@ -1325,23 +1328,24 @@ test_attr_mult_read(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR2_DIM1; i++) - for(j = 0; j < ATTR2_DIM2; j++) - if(attr_data2[i][j] != read_data2[i][j]) - TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n", __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]); + for (i = 0; i < ATTR2_DIM1; i++) + for (j = 0; j < ATTR2_DIM2; j++) + if (attr_data2[i][j] != read_data2[i][j]) + TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n", + __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]); /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR2_NAME), "H5Aget_name"); - if(HDstrcmp(attr_name, ATTR2_NAME)) + if (HDstrcmp(attr_name, ATTR2_NAME)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR2_NAME); /* Verify Name with too small of a buffer */ name_len = H5Aget_name(attr, HDstrlen(ATTR2_NAME), attr_name); VERIFY(name_len, HDstrlen(ATTR2_NAME), "H5Aget_name"); - HDstrcpy(temp_name, ATTR2_NAME); /* make a copy of the name */ - temp_name[HDstrlen(ATTR2_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */ - if(HDstrcmp(attr_name, temp_name)) + HDstrcpy(temp_name, ATTR2_NAME); /* make a copy of the name */ + temp_name[HDstrlen(ATTR2_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */ + if (HDstrcmp(attr_name, temp_name)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, temp_name); /* Close attribute */ @@ -1349,7 +1353,8 @@ test_attr_mult_read(hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Open 2nd attribute for the dataset */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)2, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)2, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Dataspace */ @@ -1359,11 +1364,11 @@ test_attr_mult_read(hid_t fapl) VERIFY(rank, ATTR3_RANK, "H5Sget_simple_extent_ndims"); ret = H5Sget_simple_extent_dims(space, dims, NULL); CHECK(ret, FAIL, "H5Sget_simple_extent_dims"); - if(dims[0] != ATTR3_DIM1) + if (dims[0] != ATTR3_DIM1) TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n", (int)dims[0], ATTR3_DIM1); - if(dims[1] != ATTR3_DIM2) + if (dims[1] != ATTR3_DIM2) TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n", (int)dims[1], ATTR3_DIM2); - if(dims[2] != ATTR3_DIM3) + if (dims[2] != ATTR3_DIM3) TestErrPrintf("attribute dimensions different: dims[2]=%d, should be %d\n", (int)dims[2], ATTR3_DIM3); H5Sclose(space); @@ -1383,24 +1388,26 @@ test_attr_mult_read(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR3_DIM1; i++) - for(j = 0; j < ATTR3_DIM2; j++) - for(k = 0; k < ATTR3_DIM3; k++) - if(!H5_DBL_ABS_EQUAL(attr_data3[i][j][k], read_data3[i][j][k])) - TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n", __LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]); + for (i = 0; i < ATTR3_DIM1; i++) + for (j = 0; j < ATTR3_DIM2; j++) + for (k = 0; k < ATTR3_DIM3; k++) + if (!H5_DBL_ABS_EQUAL(attr_data3[i][j][k], read_data3[i][j][k])) + TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, " + "read_data3[%d][%d][%d]=%f\n", + __LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]); /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name"); - if(HDstrcmp(attr_name, ATTR3_NAME)) + if (HDstrcmp(attr_name, ATTR3_NAME)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR3_NAME); /* Verify Name with too small of a buffer */ name_len = H5Aget_name(attr, HDstrlen(ATTR3_NAME), attr_name); VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name"); - HDstrcpy(temp_name, ATTR3_NAME); /* make a copy of the name */ - temp_name[HDstrlen(ATTR3_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */ - if(HDstrcmp(attr_name, temp_name)) + HDstrcpy(temp_name, ATTR3_NAME); /* make a copy of the name */ + temp_name[HDstrlen(ATTR3_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */ + if (HDstrcmp(attr_name, temp_name)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, temp_name); /* Close attribute */ @@ -1414,8 +1421,7 @@ test_attr_mult_read(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_mult_read() */ - +} /* test_attr_mult_read() */ /**************************************************************** ** @@ -1423,40 +1429,38 @@ test_attr_mult_read(hid_t fapl) ** ****************************************************************/ static herr_t -attr_op1(hid_t H5_ATTR_UNUSED loc_id, const char *name, const H5A_info_t H5_ATTR_UNUSED *ainfo, - void *op_data) +attr_op1(hid_t H5_ATTR_UNUSED loc_id, const char *name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *op_data) { - int *count = (int *)op_data; - herr_t ret = 0; + int * count = (int *)op_data; + herr_t ret = 0; - switch(*count) { + switch (*count) { case 0: - if(HDstrcmp(name, ATTR1_NAME)) + if (HDstrcmp(name, ATTR1_NAME)) TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR1_NAME); - (*count)++; - break; + (*count)++; + break; case 1: - if(HDstrcmp(name, ATTR2_NAME)) + if (HDstrcmp(name, ATTR2_NAME)) TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR2_NAME); - (*count)++; - break; + (*count)++; + break; case 2: - if(HDstrcmp(name, ATTR3_NAME)) + if (HDstrcmp(name, ATTR3_NAME)) TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR3_NAME); - (*count)++; - break; + (*count)++; + break; default: ret = -1; break; - } /* end switch() */ + } /* end switch() */ - return(ret); + return (ret); } /* end attr_op1() */ - /**************************************************************** ** ** test_attr_iterate(): Test H5A (attribute) iterator code. @@ -1465,12 +1469,12 @@ attr_op1(hid_t H5_ATTR_UNUSED loc_id, const char *name, const H5A_info_t H5_ATTR static void test_attr_iterate(hid_t fapl) { - hid_t file; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - int count; /* operator data for the iterator */ - H5O_info2_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + hid_t file; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + int count; /* operator data for the iterator */ + H5O_info2_t oinfo; /* Object info */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1498,7 +1502,7 @@ test_attr_iterate(hid_t fapl) /* Iterate over attributes on dataset */ count = 0; - ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count); + ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count); VERIFY(ret, 0, "H5Aiterate2"); /* Close dataset */ @@ -1516,7 +1520,7 @@ test_attr_iterate(hid_t fapl) /* Iterate over attributes on dataset */ count = 0; - ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count); + ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count); VERIFY(ret, 0, "H5Aiterate2"); /* Close dataset */ @@ -1526,8 +1530,7 @@ test_attr_iterate(hid_t fapl) /* Close file */ ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_iterate() */ - +} /* test_attr_iterate() */ /**************************************************************** ** @@ -1537,13 +1540,13 @@ test_attr_iterate(hid_t fapl) static void test_attr_delete(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t attr; /* Attribute ID */ - char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ - ssize_t name_len; /* Length of attribute name */ - H5O_info2_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t attr; /* Attribute ID */ + char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ + ssize_t name_len; /* Length of attribute name */ + H5O_info2_t oinfo; /* Object info */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1580,28 +1583,30 @@ test_attr_delete(hid_t fapl) VERIFY(oinfo.num_attrs, 2, "H5Oget_info3"); /* Open 1st attribute for the dataset */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name"); - if(HDstrcmp(attr_name, ATTR1_NAME)) - TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME); + if (HDstrcmp(attr_name, ATTR1_NAME)) + TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR1_NAME); /* Close attribute */ ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); /* Open last (formally 3rd) attribute for the dataset */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)1, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)1, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name"); - if(HDstrcmp(attr_name, ATTR3_NAME)) - TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME); + if (HDstrcmp(attr_name, ATTR3_NAME)) + TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR3_NAME); /* Close attribute */ ret = H5Aclose(attr); @@ -1617,14 +1622,15 @@ test_attr_delete(hid_t fapl) VERIFY(oinfo.num_attrs, 1, "H5Oget_info3"); /* Open last (formally 3rd) attribute for the dataset */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name"); - if(HDstrcmp(attr_name, ATTR3_NAME)) - TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME); + if (HDstrcmp(attr_name, ATTR3_NAME)) + TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR3_NAME); /* Close attribute */ ret = H5Aclose(attr); @@ -1646,8 +1652,7 @@ test_attr_delete(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_delete() */ - +} /* test_attr_delete() */ /**************************************************************** ** @@ -1658,17 +1663,17 @@ test_attr_delete(hid_t fapl) static void test_attr_dtype_shared(hid_t fapl) { - hid_t file_id; /* File ID */ - hid_t dset_id; /* Dataset ID */ - hid_t space_id; /* Dataspace ID for dataset & attribute */ - hid_t type_id; /* Datatype ID for named datatype */ - hid_t attr_id; /* Attribute ID */ - int data = 8; /* Data to write */ - int rdata = 0; /* Read read in */ - H5O_info2_t oinfo; /* Object's information */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t file_id; /* File ID */ + hid_t dset_id; /* Dataset ID */ + hid_t space_id; /* Dataspace ID for dataset & attribute */ + hid_t type_id; /* Datatype ID for named datatype */ + hid_t attr_id; /* Attribute ID */ + int data = 8; /* Data to write */ + int rdata = 0; /* Read read in */ + H5O_info2_t oinfo; /* Object's information */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Shared Datatypes with Attributes\n")); @@ -1683,7 +1688,7 @@ test_attr_dtype_shared(hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -1771,7 +1776,6 @@ test_attr_dtype_shared(hid_t fapl) ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(file_id, FAIL, "H5Fopen"); @@ -1822,8 +1826,7 @@ test_attr_dtype_shared(hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_dtype_shared() */ - +} /* test_attr_dtype_shared() */ /**************************************************************** ** @@ -1834,17 +1837,17 @@ test_attr_dtype_shared(hid_t fapl) static void test_attr_duplicate_ids(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t gid1, gid2; /* Group ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr, attr2; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */ - int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */ - int i; - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t gid1, gid2; /* Group ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hid_t attr, attr2; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */ + int rewrite_data[ATTR1_DIM1] = {1234, -423, 9907256}; /* Test data for rewrite */ + int i; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing operations with two ID handles\n")); @@ -1861,8 +1864,7 @@ test_attr_duplicate_ids(hid_t fapl) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a dataset */ - dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, - dcpl_g, H5P_DEFAULT); + dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Create dataspace for attribute */ @@ -1915,8 +1917,8 @@ test_attr_duplicate_ids(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(0 != read_data1[i]) + for (i = 0; i < ATTR1_DIM1; i++) + if (0 != read_data1[i]) TestErrPrintf("%d: attribute data different: read_data1[%d]=%d\n", __LINE__, i, read_data1[i]); /* Open attribute for the second time */ @@ -1964,9 +1966,10 @@ test_attr_duplicate_ids(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(attr_data1[i] != read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, + attr_data1[i], i, read_data1[i]); /* Open attribute for the second time */ attr2 = H5Aopen(dataset, ATTR1_NAME, H5P_DEFAULT); @@ -1981,9 +1984,10 @@ test_attr_duplicate_ids(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(read_data1[i] != rewrite_data[i]) - TestErrPrintf("%d: attribute data different: read_data1[%d]=%d, rewrite_data[%d]=%d\n", __LINE__, i, read_data1[i], i, rewrite_data[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (read_data1[i] != rewrite_data[i]) + TestErrPrintf("%d: attribute data different: read_data1[%d]=%d, rewrite_data[%d]=%d\n", __LINE__, + i, read_data1[i], i, rewrite_data[i]); /* Close attribute */ ret = H5Aclose(attr); @@ -2013,8 +2017,7 @@ test_attr_duplicate_ids(hid_t fapl) CHECK(gid1, FAIL, "H5Gcreate2"); /* Create hard link to the first group */ - ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT, - H5P_DEFAULT); + ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lcreate_hard"); /* Try to create an attribute on the group */ @@ -2038,9 +2041,10 @@ test_attr_duplicate_ids(hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(attr_data1[i] != read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, + attr_data1[i], i, read_data1[i]); /* Close attribute */ ret = H5Aclose(attr); @@ -2067,8 +2071,7 @@ test_attr_duplicate_ids(hid_t fapl) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_duplicate_ids() */ - +} /* test_attr_duplicate_ids() */ /**************************************************************** ** @@ -2079,18 +2082,18 @@ test_attr_duplicate_ids(hid_t fapl) static int test_attr_dense_verify(hid_t loc_id, unsigned max_attr) { - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - hid_t attr; /* Attribute ID */ - unsigned value; /* Attribute value */ - unsigned u; /* Local index variable */ - int old_nerrs; /* Number of errors when entering this check */ - herr_t ret; /* Generic return value */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t attr; /* Attribute ID */ + unsigned value; /* Attribute value */ + unsigned u; /* Local index variable */ + int old_nerrs; /* Number of errors when entering this check */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); /* Re-open all the attributes by name and verify the data */ - for(u = 0; u < max_attr; u++) { + for (u = 0; u < max_attr; u++) { /* Open attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Aopen(loc_id, attrname, H5P_DEFAULT); @@ -2107,20 +2110,22 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr) } /* end for */ /* Re-open all the attributes by index and verify the data */ - for(u = 0; u < max_attr; u++) { - ssize_t name_len; /* Length of attribute name */ - char check_name[ATTR_NAME_LEN]; /* Buffer for checking attribute names */ + for (u = 0; u < max_attr; u++) { + ssize_t name_len; /* Length of attribute name */ + char check_name[ATTR_NAME_LEN]; /* Buffer for checking attribute names */ /* Open attribute */ - attr = H5Aopen_by_idx(loc_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT); + attr = H5Aopen_by_idx(loc_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, + H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Name */ HDsprintf(attrname, "attr %02u", u); name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, check_name); VERIFY(name_len, HDstrlen(attrname), "H5Aget_name"); - if(HDstrcmp(check_name, attrname)) - TestErrPrintf("attribute name different: attrname = '%s', should be '%s'\n", check_name, attrname); + if (HDstrcmp(check_name, attrname)) + TestErrPrintf("attribute name different: attrname = '%s', should be '%s'\n", check_name, + attrname); /* Read data from the attribute */ ret = H5Aread(attr, H5T_NATIVE_UINT, &value); @@ -2133,12 +2138,11 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr) } /* end for */ /* Retrieve current # of errors */ - if(old_nerrs == GetTestNumErrs()) - return(0); + if (old_nerrs == GetTestNumErrs()) + return (0); else - return(-1); -} /* test_attr_dense_verify() */ - + return (-1); +} /* test_attr_dense_verify() */ /**************************************************************** ** @@ -2149,19 +2153,19 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr) static void test_attr_dense_create(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dense Attribute Storage Creation\n")); @@ -2176,7 +2180,7 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -2191,7 +2195,8 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -2213,7 +2218,7 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes, until just before converting to dense storage */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -2273,8 +2278,7 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_dense_create() */ - +} /* test_attr_dense_create() */ /**************************************************************** ** @@ -2285,19 +2289,19 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) static void test_attr_dense_open(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Opening Attributes in Dense Storage\n")); @@ -2312,7 +2316,7 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -2327,7 +2331,8 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -2353,7 +2358,7 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes, until just before converting to dense storage */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -2417,8 +2422,7 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_dense_open() */ - +} /* test_attr_dense_open() */ /**************************************************************** ** @@ -2429,21 +2433,21 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) static void test_attr_dense_delete(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - H5O_info2_t oinfo; /* Object info */ - int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + H5O_info2_t oinfo; /* Object info */ + int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Attributes in Dense Storage\n")); @@ -2468,7 +2472,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -2483,7 +2487,8 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) if (use_min_dset_oh) { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); - } else { + } + else { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); } @@ -2509,7 +2514,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes, until well into dense storage */ - for(u = 0; u < (max_compact * 2); u++) { + for (u = 0; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -2545,7 +2550,6 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -2555,7 +2559,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) CHECK(dataset, FAIL, "H5Dopen2"); /* Delete attributes until the attributes revert to compact storage again */ - for(u--; u >= min_dense; u--) { + for (u--; u >= min_dense; u--) { /* Delete attribute */ HDsprintf(attrname, "attr %02u", u); ret = H5Adelete(dataset, attrname); @@ -2611,8 +2615,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_dense_delete() */ - +} /* test_attr_dense_delete() */ /**************************************************************** ** @@ -2623,23 +2626,23 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) static void test_attr_dense_rename(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - char new_attrname[NAME_BUF_SIZE]; /* New name of attribute */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - H5O_info2_t oinfo; /* Object info */ - unsigned u; /* Local index variable */ - int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); - unsigned use_corder; /* Track creation order or not */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char new_attrname[NAME_BUF_SIZE]; /* New name of attribute */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + H5O_info2_t oinfo; /* Object info */ + unsigned u; /* Local index variable */ + int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); + unsigned use_corder; /* Track creation order or not */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Renaming Attributes in Dense Storage\n")); @@ -2664,7 +2667,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -2679,7 +2682,8 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) if (use_min_dset_oh) { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, H5I_INVALID_HID, "H5Pcopy"); - } else { + } + else { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate"); } @@ -2689,9 +2693,9 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Pget_attr_phase_change"); /* Using creation order or not */ - for(use_corder = FALSE; use_corder <= TRUE; use_corder++) { + for (use_corder = FALSE; use_corder <= TRUE; use_corder++) { - if(use_corder) { + if (use_corder) { ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); CHECK(ret, FAIL, "H5Pset_attr_creation_order"); } @@ -2705,7 +2709,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes, until well into dense storage */ - for(u = 0; u < (max_compact * 2); u++) { + for (u = 0; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -2740,13 +2744,13 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - if(!use_corder) { + if (!use_corder) { /* Unlink dataset with attributes */ ret = H5Ldelete(fid, DSET1_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); } - } /* end for use_corder */ + } /* end for use_corder */ /* Close dataspace */ ret = H5Sclose(sid); @@ -2760,7 +2764,6 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, H5I_INVALID_HID, "H5Fopen"); @@ -2770,8 +2773,8 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); /* Verify renamed attributes */ - for(u = 0; u < (max_compact * 2); u++) { - unsigned value; /* Attribute value */ + for (u = 0; u < (max_compact * 2); u++) { + unsigned value; /* Attribute value */ /* Open attribute */ HDsprintf(attrname, "new attr %02u", u); @@ -2803,8 +2806,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_dense_rename() */ - +} /* test_attr_dense_rename() */ /**************************************************************** ** @@ -2815,22 +2817,22 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) static void test_attr_dense_unlink(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - size_t mesg_count; /* # of shared messages */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - H5O_info2_t oinfo; /* Object info */ - unsigned u; /* Local index variable */ - int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + size_t mesg_count; /* # of shared messages */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + H5O_info2_t oinfo; /* Object info */ + unsigned u; /* Local index variable */ + int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Unlinking Object with Attributes in Dense Storage\n")); @@ -2853,7 +2855,7 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -2868,7 +2870,8 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) if (use_min_dset_oh) { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); - } else { + } + else { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); } @@ -2890,7 +2893,7 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes, until well into dense storage */ - for(u = 0; u < (max_compact * 2); u++) { + for (u = 0; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -2926,7 +2929,6 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -2947,8 +2949,7 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_dense_unlink() */ - +} /* test_attr_dense_unlink() */ /**************************************************************** ** @@ -2959,19 +2960,19 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) static void test_attr_dense_limits(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned max_compact, rmax_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense, rmin_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned max_compact, rmax_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense, rmin_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Phase Change Limits For Attributes in Dense Storage\n")); @@ -2986,7 +2987,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -3001,15 +3002,16 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } /* Change limits on compact/dense attribute storage */ max_compact = 0; - min_dense = 0; - ret = H5Pset_attr_phase_change(dcpl, max_compact, min_dense); + min_dense = 0; + ret = H5Pset_attr_phase_change(dcpl, max_compact, min_dense); CHECK(ret, FAIL, "H5Pget_attr_phase_change"); /* Create a dataset */ @@ -3026,12 +3028,10 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) ret = H5Pclose(dcpl); CHECK(ret, FAIL, "H5Pclose"); - /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); - /* Add first attribute, which should be immediately in dense storage */ /* Create attribute */ @@ -3052,7 +3052,6 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); - /* Add second attribute, to allow deletions to be checked easily */ /* Create attribute */ @@ -3073,7 +3072,6 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); - /* Delete second attribute, attributes should still be stored densely */ /* Delete attribute */ @@ -3084,7 +3082,6 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); - /* Delete first attribute, attributes should not be stored densely */ /* Delete attribute */ @@ -3097,7 +3094,6 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); - /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); @@ -3117,8 +3113,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_dense_limits() */ - +} /* test_attr_dense_limits() */ /**************************************************************** ** @@ -3129,23 +3124,23 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) static void test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t gid1, gid2; /* Group ID */ - hid_t sid, sid2; /* Dataspace ID */ - hid_t attr, attr2, add_attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - hsize_t dims[] = {ATTR1_DIM1}; - int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading attribute */ - int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */ - unsigned scalar_data = 1317; /* scalar data for attribute */ - unsigned read_scalar; /* variable for reading attribute*/ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - unsigned u, i; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t gid1, gid2; /* Group ID */ + hid_t sid, sid2; /* Dataspace ID */ + hid_t attr, attr2, add_attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hsize_t dims[] = {ATTR1_DIM1}; + int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading attribute */ + int rewrite_data[ATTR1_DIM1] = {1234, -423, 9907256}; /* Test data for rewrite */ + unsigned scalar_data = 1317; /* scalar data for attribute */ + unsigned read_scalar; /* variable for reading attribute*/ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + unsigned u, i; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing operations with two IDs for Dense Storage\n")); @@ -3173,7 +3168,8 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -3195,7 +3191,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes, until just before converting to dense storage */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -3272,10 +3268,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(0 != read_data1[i]) - TestErrPrintf("%d: attribute data different: read_data1[%d]=%d\n", __LINE__, - i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (0 != read_data1[i]) + TestErrPrintf("%d: attribute data different: read_data1[%d]=%d\n", __LINE__, i, read_data1[i]); /* Open attribute for the second time */ attr2 = H5Aopen(dataset, attrname, H5P_DEFAULT); @@ -3325,9 +3320,10 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(attr_data1[i] != read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, + attr_data1[i], i, read_data1[i]); /* Open attribute for the second time */ attr2 = H5Aopen(dataset, attrname, H5P_DEFAULT); @@ -3342,9 +3338,10 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(read_data1[i] != rewrite_data[i]) - TestErrPrintf("%d: attribute data different: read_data1[%d]=%d, rewrite_data[%d]=%d\n", __LINE__, i, read_data1[i], i, rewrite_data[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (read_data1[i] != rewrite_data[i]) + TestErrPrintf("%d: attribute data different: read_data1[%d]=%d, rewrite_data[%d]=%d\n", __LINE__, + i, read_data1[i], i, rewrite_data[i]); /* Close attribute */ ret = H5Aclose(attr); @@ -3378,13 +3375,11 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); /* Open first attribute for the dataset */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, - H5P_DEFAULT, H5P_DEFAULT); + attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); /* Open attribute for the second time */ - attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, - H5P_DEFAULT, H5P_DEFAULT); + attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); /* Write attribute information with the second ID */ @@ -3396,9 +3391,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - if(read_scalar != scalar_data) - TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", - __LINE__, read_scalar, scalar_data); + if (read_scalar != scalar_data) + TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", __LINE__, read_scalar, + scalar_data); /* Close attribute */ ret = H5Aclose(attr); @@ -3434,14 +3429,12 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); /* Open attribute of the dataset for the first time */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2, - H5P_DEFAULT, H5P_DEFAULT); + attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); /* Delete a few attributes until the storage switches to compact */ - for(u = max_compact; u >= min_dense - 1; u--) { - ret = H5Adelete_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, - H5P_DEFAULT); + for (u = max_compact; u >= min_dense - 1; u--) { + ret = H5Adelete_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT); CHECK(ret, FAIL, "H5Adelete_by_idx"); } @@ -3450,8 +3443,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Open attribute for the second time */ - attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2, - H5P_DEFAULT, H5P_DEFAULT); + attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); /* Write attribute information with the second ID */ @@ -3463,9 +3455,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - if(read_scalar != scalar_data) - TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", - __LINE__, read_scalar, scalar_data); + if (read_scalar != scalar_data) + TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", __LINE__, read_scalar, + scalar_data); /* Close attribute */ ret = H5Aclose(attr); @@ -3501,12 +3493,11 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Open attribute of the dataset for the first time */ - attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3, - H5P_DEFAULT, H5P_DEFAULT); + attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); /* Delete a few attributes until the storage switches to compact */ - for(u = min_dense-1; u <= max_compact; u++) { + for (u = min_dense - 1; u <= max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); add_attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -3526,8 +3517,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); /* Open attribute for the second time */ - attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3, - H5P_DEFAULT, H5P_DEFAULT); + attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); /* Write attribute information with the second ID */ @@ -3539,9 +3529,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - if(read_scalar != scalar_data) - TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", - __LINE__, read_scalar, scalar_data); + if (read_scalar != scalar_data) + TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", __LINE__, read_scalar, + scalar_data); /* Close attribute */ ret = H5Aclose(attr); @@ -3571,12 +3561,11 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) CHECK(gid1, FAIL, "H5Gcreate2"); /* Create hard link to the first group */ - ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT, - H5P_DEFAULT); + ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lcreate_hard"); /* Add attributes, until just before converting to dense storage */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(gid1, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -3616,9 +3605,10 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i = 0; i < ATTR1_DIM1; i++) - if(attr_data1[i] != read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, + attr_data1[i], i, read_data1[i]); /* Close attribute */ ret = H5Aclose(attr); @@ -3645,8 +3635,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) /* Close file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_dense_dup_ids() */ - +} /* test_attr_dense_dup_ids() */ /**************************************************************** ** @@ -3657,24 +3646,24 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) static void test_attr_big(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t big_sid; /* "Big" dataspace ID */ - hsize_t dims[ATTR6_RANK] = {ATTR6_DIM1, ATTR6_DIM2, ATTR6_DIM3}; /* Attribute dimensions */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - unsigned nshared_indices; /* # of shared message indices */ - H5F_libver_t low, high; /* File format bounds */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t big_sid; /* "Big" dataspace ID */ + hsize_t dims[ATTR6_RANK] = {ATTR6_DIM1, ATTR6_DIM2, ATTR6_DIM3}; /* Attribute dimensions */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + unsigned nshared_indices; /* # of shared message indices */ + H5F_libver_t low, high; /* File format bounds */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Storing 'Big' Attributes in Dense Storage\n")); @@ -3689,7 +3678,7 @@ test_attr_big(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -3708,7 +3697,8 @@ test_attr_big(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -3733,14 +3723,12 @@ test_attr_big(hid_t fcpl, hid_t fapl) ret = H5Pclose(dcpl); CHECK(ret, FAIL, "H5Pclose"); - /* Check on dataset's attribute storage status */ is_empty = H5O__is_attr_empty_test(dataset); VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test"); is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); - /* Add first "small" attribute, which should be in compact storage */ /* Create attribute */ @@ -3759,7 +3747,6 @@ test_attr_big(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); - /* Add second "small" attribute, which should stay in compact storage */ /* Create attribute */ @@ -3778,14 +3765,13 @@ test_attr_big(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); - /* Add first "big" attribute, which should push storage into dense form */ /* Create attribute */ u = 2; HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, big_sid, H5P_DEFAULT, H5P_DEFAULT); - if(low == H5F_LIBVER_LATEST) { + if (low == H5F_LIBVER_LATEST) { CHECK(attr, FAIL, "H5Acreate2"); /* Close attribute */ @@ -3802,7 +3788,6 @@ test_attr_big(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O__is_attr_dense_test"); - /* Add second "big" attribute, which should leave storage in dense form */ /* Create attribute */ @@ -3825,7 +3810,6 @@ test_attr_big(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O__is_attr_dense_test"); - /* Delete second "small" attribute, attributes should still be stored densely */ /* Delete attribute */ @@ -3840,7 +3824,6 @@ test_attr_big(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O__is_attr_dense_test"); - /* Delete second "big" attribute, attributes should still be stored densely */ /* Delete attribute */ @@ -3855,7 +3838,6 @@ test_attr_big(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O__is_attr_dense_test"); - /* Delete first "big" attribute, attributes should _not_ be stored densely */ /* Delete attribute */ @@ -3870,7 +3852,6 @@ test_attr_big(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); - /* Delete first "small" attribute, should be no attributes now */ /* Delete attribute */ @@ -3898,7 +3879,6 @@ test_attr_big(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); } /* end else */ - /* Close dataspaces */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); @@ -3920,8 +3900,7 @@ test_attr_big(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_big() */ - +} /* test_attr_big() */ /**************************************************************** ** @@ -3932,20 +3911,20 @@ test_attr_big(hid_t fcpl, hid_t fapl) static void test_attr_null_space(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t null_sid; /* "null" dataspace ID */ - hid_t attr_sid; /* Attribute's dataspace ID */ - hid_t attr; /* Attribute ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned value; /* Attribute value */ - htri_t cmp; /* Results of comparison */ - hsize_t storage_size; /* Size of storage for attribute */ - H5A_info_t ainfo; /* Attribute info */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t null_sid; /* "null" dataspace ID */ + hid_t attr_sid; /* Attribute's dataspace ID */ + hid_t attr; /* Attribute ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned value; /* Attribute value */ + htri_t cmp; /* Results of comparison */ + hsize_t storage_size; /* Size of storage for attribute */ + H5A_info_t ainfo; /* Attribute info */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Storing Attributes with 'null' dataspace\n")); @@ -3960,7 +3939,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); /* Re-open file */ @@ -3979,7 +3958,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); - /* Add attribute with 'null' dataspace */ /* Create attribute */ @@ -3990,7 +3968,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) /* Try to read data from the attribute */ /* (shouldn't fail, but should leave buffer alone) */ value = 23; - ret = H5Aread(attr, H5T_NATIVE_UINT, &value); + ret = H5Aread(attr, H5T_NATIVE_UINT, &value); CHECK(ret, FAIL, "H5Aread"); VERIFY(value, 23, "H5Aread"); @@ -4020,7 +3998,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); - /* Add another attribute with 'null' dataspace */ /* Create attribute */ @@ -4031,7 +4008,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) /* Try to write data to the attribute */ /* (shouldn't fail, but should leave buffer alone) */ value = 23; - ret = H5Awrite(attr, H5T_NATIVE_UINT, &value); + ret = H5Awrite(attr, H5T_NATIVE_UINT, &value); CHECK(ret, FAIL, "H5Awrite"); VERIFY(value, 23, "H5Awrite"); @@ -4047,7 +4024,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open the file and check on the attributes */ /* Re-open file */ @@ -4058,7 +4034,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) dataset = H5Dopen2(fid, DSET1_NAME, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dopen2"); - /* Open first attribute */ HDstrcpy(attrname, "null attr #2"); attr = H5Aopen(dataset, attrname, H5P_DEFAULT); @@ -4067,7 +4042,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) /* Try to read data from the attribute */ /* (shouldn't fail, but should leave buffer alone) */ value = 23; - ret = H5Aread(attr, H5T_NATIVE_UINT, &value); + ret = H5Aread(attr, H5T_NATIVE_UINT, &value); CHECK(ret, FAIL, "H5Aread"); VERIFY(value, 23, "H5Aread"); @@ -4097,7 +4072,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); - /* Open second attribute */ HDstrcpy(attrname, "null attr"); attr = H5Aopen(dataset, attrname, H5P_DEFAULT); @@ -4106,7 +4080,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) /* Try to write data to the attribute */ /* (shouldn't fail, but should leave buffer alone) */ value = 23; - ret = H5Awrite(attr, H5T_NATIVE_UINT, &value); + ret = H5Awrite(attr, H5T_NATIVE_UINT, &value); CHECK(ret, FAIL, "H5Awrite"); VERIFY(value, 23, "H5Awrite"); @@ -4114,7 +4088,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); - /* Close Dataset */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); @@ -4127,19 +4100,16 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Close dataspaces */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(null_sid); CHECK(ret, FAIL, "H5Sclose"); - /* Check size of file */ filesize = h5_get_file_size(FILENAME, fapl); VERIFY(filesize, empty_filesize, "h5_get_file_size"); -} /* test_attr_null_space() */ - +} /* test_attr_null_space() */ /**************************************************************** ** @@ -4151,11 +4121,11 @@ static void test_attr_deprec(hid_t fcpl, hid_t fapl) { #ifndef H5_NO_DEPRECATED_SYMBOLS - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deprecated Attribute Routines\n")); @@ -4172,7 +4142,6 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); - /* Add attribute to dataset */ /* Create attribute */ @@ -4194,7 +4163,6 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open the file and operate on the attribute */ /* Re-open file */ @@ -4205,7 +4173,6 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) dataset = H5Dopen2(fid, DSET1_NAME, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dopen2"); - /* Get number of attributes with bad ID */ ret = H5Aget_num_attrs((hid_t)-1); VERIFY(ret, FAIL, "H5Aget_num_attrs"); @@ -4230,7 +4197,6 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); - /* Close Dataset */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); @@ -4240,14 +4206,14 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); #else /* H5_NO_DEPRECATED_SYMBOLS */ /* Shut compiler up */ - fcpl = fcpl; fapl = fapl; + fcpl = fcpl; + fapl = fapl; /* Output message about test being skipped */ MESSAGE(5, ("Skipping Test On Deprecated Attribute Routines\n")); #endif /* H5_NO_DEPRECATED_SYMBOLS */ -} /* test_attr_deprec() */ - +} /* test_attr_deprec() */ /**************************************************************** ** @@ -4258,15 +4224,15 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) static void test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t gid; /* Group ID */ - hid_t sid; /* Dataspace ID */ - hid_t aid; /* Attribute ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned nattr = (new_format ? NATTR_MANY_NEW : NATTR_MANY_OLD); /* Number of attributes */ - htri_t exists; /* Whether the attribute exists or not */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t gid; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t aid; /* Attribute ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned nattr = (new_format ? NATTR_MANY_NEW : NATTR_MANY_OLD); /* Number of attributes */ + htri_t exists; /* Whether the attribute exists or not */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Storing Many Attributes\n")); @@ -4284,7 +4250,7 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(gid, FAIL, "H5Gcreate2"); /* Create many attributes */ - for(u = 0; u < nattr; u++) { + for (u = 0; u < nattr; u++) { HDsprintf(attrname, "a-%06u", u); exists = H5Aexists(gid, attrname); @@ -4323,7 +4289,6 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open the file and check on the attributes */ /* Re-open file */ @@ -4335,8 +4300,8 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(gid, FAIL, "H5Gopen2"); /* Verify attributes */ - for(u = 0; u < nattr; u++) { - unsigned value; /* Attribute value */ + for (u = 0; u < nattr; u++) { + unsigned value; /* Attribute value */ HDsprintf(attrname, "a-%06u", u); @@ -4371,12 +4336,10 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Close dataspaces */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_many() */ - +} /* test_attr_many() */ /**************************************************************** ** @@ -4387,14 +4350,14 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl) static void test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ hid_t dcpl; /* Dataset creation property list ID */ - unsigned crt_order_flags;/* Creation order flags */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - herr_t ret; /* Generic return value */ + unsigned crt_order_flags; /* Creation order flags */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Code for Attributes with Creation Order Info\n")); @@ -4407,7 +4370,8 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -4429,7 +4393,7 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Pset_attr_creation_order"); ret = H5Pget_attr_creation_order(dcpl, &crt_order_flags); CHECK(ret, FAIL, "H5Pget_attr_creation_order"); - VERIFY(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) , "H5Pget_attr_creation_order"); + VERIFY(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "H5Pget_attr_creation_order"); /* Create dataspace for dataset */ sid = H5Screate(H5S_SCALAR); @@ -4461,7 +4425,6 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -4483,7 +4446,7 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) /* Query the attribute creation properties */ ret = H5Pget_attr_creation_order(dcpl, &crt_order_flags); CHECK(ret, FAIL, "H5Pget_attr_creation_order"); - VERIFY(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) , "H5Pget_attr_creation_order"); + VERIFY(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "H5Pget_attr_creation_order"); /* Close property list */ ret = H5Pclose(dcpl); @@ -4496,8 +4459,7 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) /* Close file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_corder_create_basic() */ - +} /* test_attr_corder_create_basic() */ /**************************************************************** ** @@ -4508,21 +4470,21 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) static void test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Compact Storage of Attributes with Creation Order Info\n")); @@ -4535,7 +4497,8 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -4561,8 +4524,8 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -4586,7 +4549,7 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Create several attributes, but keep storage in compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -4609,7 +4572,7 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); } /* end for */ - } /* end for */ + } /* end for */ /* Close Datasets */ ret = H5Dclose(dset1); @@ -4631,7 +4594,6 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -4645,8 +4607,8 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dopen2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -4674,8 +4636,8 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) /* Loop through attributes, checking their creation order values */ /* (the name index is used, but the creation order value is in the same order) */ - for(u = 0; u < max_compact; u++) { - H5A_info_t ainfo; /* Attribute information */ + for (u = 0; u < max_compact; u++) { + H5A_info_t ainfo; /* Attribute information */ /* Retrieve information for attribute */ HDsprintf(attrname, "attr %02u", u); @@ -4686,7 +4648,7 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) VERIFY(ainfo.corder_valid, TRUE, "H5Aget_info_by_name"); VERIFY(ainfo.corder, u, "H5Aget_info_by_name"); } /* end for */ - } /* end for */ + } /* end for */ /* Close Datasets */ ret = H5Dclose(dset1); @@ -4699,8 +4661,7 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) /* Close file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_corder_create_compact() */ - +} /* test_attr_corder_create_compact() */ /**************************************************************** ** @@ -4711,23 +4672,23 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) static void test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dense Storage of Attributes with Creation Order Info\n")); @@ -4740,7 +4701,8 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -4766,8 +4728,8 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -4791,7 +4753,7 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Create several attributes, but keep storage in compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -4863,7 +4825,6 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -4877,8 +4838,8 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dopen2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -4906,8 +4867,8 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) /* Loop through attributes, checking their creation order values */ /* (the name index is used, but the creation order value is in the same order) */ - for(u = 0; u < (max_compact + 1); u++) { - H5A_info_t ainfo; /* Attribute information */ + for (u = 0; u < (max_compact + 1); u++) { + H5A_info_t ainfo; /* Attribute information */ /* Retrieve information for attribute */ HDsprintf(attrname, "attr %02u", u); @@ -4918,7 +4879,7 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) VERIFY(ainfo.corder_valid, TRUE, "H5Aget_info_by_name"); VERIFY(ainfo.corder, u, "H5Aget_info_by_name"); } /* end for */ - } /* end for */ + } /* end for */ /* Close Datasets */ ret = H5Dclose(dset1); @@ -4931,8 +4892,7 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) /* Close file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* test_attr_corder_create_dense() */ - +} /* test_attr_corder_create_dense() */ /**************************************************************** ** @@ -4944,13 +4904,13 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) static void test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t gcpl_id = -1; /* Group creation property list ID */ - hid_t gid = -1; /* Group ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - int buf; /* Attribute data */ - herr_t ret; /* Generic return value */ + hid_t fid = -1; /* File ID */ + hid_t gcpl_id = -1; /* Group creation property list ID */ + hid_t gid = -1; /* Group ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + int buf; /* Attribute data */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Creating Attributes w/New & Old Format\n")); @@ -4998,7 +4958,6 @@ test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file, without "use the latest format" flag */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -5039,8 +4998,7 @@ test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl) /* Close attribute dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_corder_create_reopen() */ - +} /* test_attr_corder_create_reopen() */ /**************************************************************** ** @@ -5051,23 +5009,23 @@ test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl) static void test_attr_corder_transition(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Storage Transitions of Attributes with Creation Order Info\n")); @@ -5080,7 +5038,8 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -5097,10 +5056,10 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); -/* XXX: Try to find a way to resize dataset's object header so that the object - * header can have one chunk, then retrieve "empty" file size and check - * that size after everything is deleted -QAK - */ + /* XXX: Try to find a way to resize dataset's object header so that the object + * header can have one chunk, then retrieve "empty" file size and check + * that size after everything is deleted -QAK + */ /* Create datasets */ dset1 = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(dset1, FAIL, "H5Dcreate2"); @@ -5110,8 +5069,8 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -5151,7 +5110,6 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -5165,8 +5123,8 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dopen2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -5184,7 +5142,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) } /* end switch */ /* Create several attributes, but keep storage in compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -5236,7 +5194,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); /* Delete several attributes from object, until attribute storage resumes compact form */ - for(u = max_compact; u >= min_dense; u--) { + for (u = max_compact; u >= min_dense; u--) { HDsprintf(attrname, "attr %02u", u); ret = H5Adelete(my_dataset, attrname); CHECK(ret, FAIL, "H5Adelete"); @@ -5271,7 +5229,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Re-add attributes to get back into dense form */ - for(u = (min_dense - 1); u < (max_compact + 1); u++) { + for (u = (min_dense - 1); u < (max_compact + 1); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -5313,7 +5271,6 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -5327,8 +5284,8 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dopen2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -5360,7 +5317,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); /* Delete several attributes from object, until attribute storage resumes compact form */ - for(u = max_compact; u >= min_dense; u--) { + for (u = max_compact; u >= min_dense; u--) { HDsprintf(attrname, "attr %02u", u); ret = H5Adelete(my_dataset, attrname); CHECK(ret, FAIL, "H5Adelete"); @@ -5395,7 +5352,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Re-add attributes to get back into dense form */ - for(u = (min_dense - 1); u < (max_compact + 1); u++) { + for (u = (min_dense - 1); u < (max_compact + 1); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -5425,7 +5382,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); /* Delete all attributes */ - for(u = max_compact; u > 0; u--) { + for (u = max_compact; u > 0; u--) { HDsprintf(attrname, "attr %02u", u); ret = H5Adelete(my_dataset, attrname); CHECK(ret, FAIL, "H5Adelete"); @@ -5450,8 +5407,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_corder_transition() */ - +} /* test_attr_corder_transition() */ /**************************************************************** ** @@ -5462,28 +5418,28 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) static void test_attr_corder_delete(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - unsigned reopen_file; /* Whether to re-open the file before deleting group */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + unsigned reopen_file; /* Whether to re-open the file before deleting group */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ #ifdef LATER - h5_stat_size_t empty_size; /* Size of empty file */ - h5_stat_size_t file_size; /* Size of file after operating on it */ -#endif /* LATER */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + h5_stat_size_t empty_size; /* Size of empty file */ + h5_stat_size_t file_size; /* Size of file after operating on it */ +#endif /* LATER */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Object w/Dense Attribute Storage and Creation Order Info\n")); @@ -5496,7 +5452,8 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -5509,7 +5466,6 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); CHECK(ret, FAIL, "H5Pget_attr_phase_change"); - /* XXX: Try to find a way to resize dataset's object header so that the object * header can have one chunk, then retrieve "empty" file size and check * that size after everything is deleted -QAK @@ -5528,10 +5484,9 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) CHECK(empty_size, FAIL, "h5_get_file_size"); #endif /* LATER */ - /* Loop to leave file open when deleting dataset, or to close & re-open file * before deleting dataset */ - for(reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) { + for (reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) { /* Create test file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -5545,8 +5500,8 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -5570,7 +5525,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Create attributes, until attribute storage is in dense form */ - for(u = 0; u < max_compact * 2; u++) { + for (u = 0; u < max_compact * 2; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -5609,7 +5564,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Dclose"); /* Check for deleting datasets without re-opening file */ - if(!reopen_file) { + if (!reopen_file) { ret = H5Ldelete(fid, DSET1_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); ret = H5Ldelete(fid, DSET2_NAME, H5P_DEFAULT); @@ -5623,7 +5578,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); /* Check for deleting dataset after re-opening file */ - if(reopen_file) { + if (reopen_file) { /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -5647,7 +5602,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) CHECK(file_size, FAIL, "h5_get_file_size"); VERIFY(file_size, empty_size, "h5_get_file_size"); #endif /* LATER */ - } /* end for */ + } /* end for */ /* Close property list */ ret = H5Pclose(dcpl); @@ -5656,8 +5611,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_corder_delete() */ - +} /* test_attr_corder_delete() */ /*------------------------------------------------------------------------- * Function: attr_info_by_idx_check @@ -5677,13 +5631,12 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) *------------------------------------------------------------------------- */ static int -attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, - hbool_t use_index) +attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, hbool_t use_index) { - char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ - H5A_info_t ainfo; /* Attribute info struct */ - int old_nerrs; /* Number of errors when entering this check */ - herr_t ret; /* Generic return value */ + char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ + H5A_info_t ainfo; /* Attribute info struct */ + int old_nerrs; /* Number of errors when entering this check */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); @@ -5702,20 +5655,21 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, /* Verify the name for new link, in increasing creation order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aget_name_by_idx"); - if(HDstrcmp(attrname, tmpname)) + if (HDstrcmp(attrname, tmpname)) TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__); - /* Don't test "native" order if there is no creation order index, since * there's not a good way to easily predict the attribute's order in the name * index. */ - if(use_index) { + if (use_index) { /* Verify the information for first attribute, in native creation order */ HDmemset(&ainfo, 0, sizeof(ainfo)); - ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, (hsize_t)0, &ainfo, H5P_DEFAULT); + ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, (hsize_t)0, &ainfo, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Aget_info_by_idx"); VERIFY(ainfo.corder, 0, "H5Aget_info_by_idx"); @@ -5727,13 +5681,13 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, /* Verify the name for new link, in increasing native order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aget_name_by_idx"); - if(HDstrcmp(attrname, tmpname)) + if (HDstrcmp(attrname, tmpname)) TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__); } /* end if */ - /* Verify the information for first attribute, in decreasing creation order */ HDmemset(&ainfo, 0, sizeof(ainfo)); ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, n, &ainfo, H5P_DEFAULT); @@ -5748,12 +5702,12 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, /* Verify the name for new link, in increasing creation order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aget_name_by_idx"); - if(HDstrcmp(attrname, tmpname)) + if (HDstrcmp(attrname, tmpname)) TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__); - /* Verify the information for first attribute, in increasing name order */ HDmemset(&ainfo, 0, sizeof(ainfo)); ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &ainfo, H5P_DEFAULT); @@ -5768,17 +5722,16 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, /* Verify the name for new link, in increasing name order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aget_name_by_idx"); - if(HDstrcmp(attrname, tmpname)) + if (HDstrcmp(attrname, tmpname)) TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__); - /* Don't test "native" order queries on link name order, since there's not * a good way to easily predict the order of the links in the name index. */ - /* Verify the information for first attribute, in decreasing name order */ HDmemset(&ainfo, 0, sizeof(ainfo)); ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_DEC, n, &ainfo, H5P_DEFAULT); @@ -5793,19 +5746,19 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, /* Verify the name for new link, in increasing name order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, + (size_t)NAME_BUF_SIZE, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aget_name_by_idx"); - if(HDstrcmp(attrname, tmpname)) + if (HDstrcmp(attrname, tmpname)) TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__); /* Retrieve current # of errors */ - if(old_nerrs == GetTestNumErrs()) - return(0); + if (old_nerrs == GetTestNumErrs()) + return (0); else - return(-1); + return (-1); } /* end attr_info_by_idx_check() */ - /**************************************************************** ** ** test_attr_info_by_idx(): Test basic H5A (attribute) code. @@ -5815,26 +5768,26 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, static void test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - H5A_info_t ainfo; /* Attribute information */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - unsigned use_index; /* Use index on creation order values */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + H5A_info_t ainfo; /* Attribute information */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + unsigned use_index; /* Use index on creation order values */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -5844,7 +5797,8 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -5854,9 +5808,9 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Pget_attr_phase_change"); /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Output message about test being performed */ - if(use_index) + if (use_index) MESSAGE(5, ("Testing Querying Attribute Info By Index w/Creation Order Index\n")) else MESSAGE(5, ("Testing Querying Attribute Info By Index w/o Creation Order Index\n")) @@ -5866,8 +5820,9 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(fid, FAIL, "H5Fcreate"); /* Set attribute creation order tracking & indexing for object */ - if(new_format == TRUE) { - ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); + if (new_format == TRUE) { + ret = H5Pset_attr_creation_order( + dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); CHECK(ret, FAIL, "H5Pset_attr_creation_order"); } /* end if */ @@ -5880,8 +5835,8 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -5905,13 +5860,15 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Check for query on non-existant attribute */ - ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &ainfo, H5P_DEFAULT); + ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &ainfo, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aget_info_by_idx"); - ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aget_name_by_idx"); /* Create attributes, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -5940,15 +5897,18 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Check for out of bound offset queries */ - ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &ainfo, H5P_DEFAULT); + ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &ainfo, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aget_info_by_idx"); - ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo, H5P_DEFAULT); + ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aget_info_by_idx"); - ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aget_name_by_idx"); /* Create more attributes, to push into dense form */ - for(; u < (max_compact * 2); u++) { + for (; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -5980,21 +5940,24 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); - if(new_format) { + if (new_format) { /* Retrieve & verify # of records in the name & creation order indices */ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count); CHECK(ret, FAIL, "H5O__attr_dense_info_test"); - if(use_index) + if (use_index) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test"); } /* end if */ /* Check for out of bound offset queries */ - ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &ainfo, H5P_DEFAULT); + ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &ainfo, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aget_info_by_idx"); - ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo, H5P_DEFAULT); + ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aget_info_by_idx"); - ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aget_name_by_idx"); } /* end for */ @@ -6018,8 +5981,7 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_info_by_idx() */ - +} /* test_attr_info_by_idx() */ /*************************************************************** ** @@ -6048,21 +6010,27 @@ test_attr_info_null_info_pointer(hid_t fcpl, hid_t fapl) attr = H5Acreate2(fid, GET_INFO_NULL_POINTER_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Aget_info(attr, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Aget_info"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Aget_info_by_name(fid, ".", GET_INFO_NULL_POINTER_ATTR_NAME, NULL, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Aget_info_by_name"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Aget_info_by_idx(fid, ".", H5_INDEX_NAME, H5_ITER_INC, 0, NULL, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Aget_info_by_idx"); @@ -6079,7 +6047,6 @@ test_attr_info_null_info_pointer(hid_t fcpl, hid_t fapl) CHECK(err_ret, FAIL, "H5Fclose"); } - /*************************************************************** ** ** test_attr_rename_invalid_name(): A test to ensure that @@ -6107,51 +6074,67 @@ test_attr_rename_invalid_name(hid_t fcpl, hid_t fapl) attr = H5Acreate2(fid, INVALID_RENAME_TEST_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Arename(fid, NULL, INVALID_RENAME_TEST_NEW_ATTR_NAME); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Arename"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Arename(fid, "", INVALID_RENAME_TEST_NEW_ATTR_NAME); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Arename"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Arename(fid, INVALID_RENAME_TEST_ATTR_NAME, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Arename"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Arename(fid, INVALID_RENAME_TEST_ATTR_NAME, ""); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Arename"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Arename_by_name(fid, ".", NULL, INVALID_RENAME_TEST_NEW_ATTR_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Arename_by_name"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Arename_by_name(fid, ".", "", INVALID_RENAME_TEST_NEW_ATTR_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Arename_by_name"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Arename_by_name(fid, ".", INVALID_RENAME_TEST_ATTR_NAME, NULL, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Arename_by_name"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Arename_by_name(fid, ".", INVALID_RENAME_TEST_ATTR_NAME, "", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(err_ret, SUCCEED, "H5Arename_by_name"); @@ -6168,7 +6151,6 @@ test_attr_rename_invalid_name(hid_t fcpl, hid_t fapl) CHECK(err_ret, FAIL, "H5Fclose"); } - /*************************************************************** ** ** test_attr_get_name_invalid_buf(): A test to ensure that @@ -6194,18 +6176,23 @@ test_attr_get_name_invalid_buf(hid_t fcpl, hid_t fapl) CHECK(fid, FAIL, "H5Fcreate"); /* Create attribute */ - attr = H5Acreate2(fid, GET_NAME_INVALID_BUF_TEST_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Acreate2(fid, GET_NAME_INVALID_BUF_TEST_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Aget_name(attr, 1, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(err_ret, FAIL, "H5Aget_name"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { err_ret = H5Aget_name_by_idx(fid, ".", H5_INDEX_NAME, H5_ITER_INC, 0, NULL, 1, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(err_ret, FAIL, "H5Aget_name_by_idx"); @@ -6222,7 +6209,6 @@ test_attr_get_name_invalid_buf(hid_t fcpl, hid_t fapl) CHECK(err_ret, FAIL, "H5Fclose"); } - /**************************************************************** ** ** test_attr_delete_by_idx(): Test basic H5A (attribute) code. @@ -6232,28 +6218,28 @@ test_attr_get_name_invalid_buf(hid_t fcpl, hid_t fapl) static void test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - H5A_info_t ainfo; /* Attribute information */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + H5A_info_t ainfo; /* Attribute information */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -6263,7 +6249,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -6273,48 +6260,57 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Pget_attr_phase_change"); /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Increasing Order w/Creation Order Index\n")) + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Increasing " + "Order w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Increasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Increasing " + "Order w/o Creation Order Index\n")) } /* end if */ else { - if(use_index) - MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Decreasing Order w/Creation Order Index\n")) + if (use_index) + MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Decreasing " + "Order w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Decreasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Decreasing " + "Order w/o Creation Order Index\n")) } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) - MESSAGE(5, ("Testing Deleting Attribute By Name Index in Increasing Order w/Creation Order Index\n")) + if (order == H5_ITER_INC) { + if (use_index) + MESSAGE(5, ("Testing Deleting Attribute By Name Index in Increasing Order " + "w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Deleting Attribute By Name Index in Increasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Deleting Attribute By Name Index in Increasing Order w/o " + "Creation Order Index\n")) } /* end if */ else { - if(use_index) - MESSAGE(5, ("Testing Deleting Attribute By Name Index in Decreasing Order w/Creation Order Index\n")) + if (use_index) + MESSAGE(5, ("Testing Deleting Attribute By Name Index in Decreasing Order " + "w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Deleting Attribute By Name Index in Decreasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Deleting Attribute By Name Index in Decreasing Order w/o " + "Creation Order Index\n")) } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fcreate"); /* Set attribute creation order tracking & indexing for object */ - if(new_format == TRUE) { - ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); + if (new_format == TRUE) { + ret = H5Pset_attr_creation_order( + dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); CHECK(ret, FAIL, "H5Pset_attr_creation_order"); } /* end if */ @@ -6327,8 +6323,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -6356,10 +6352,11 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(ret, FAIL, "H5Adelete_by_idx"); /* Create attributes, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); /* Write data into the attribute */ @@ -6390,8 +6387,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end for */ /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -6409,27 +6406,29 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Delete attributes from compact storage */ - for(u = 0; u < (max_compact - 1); u++) { + for (u = 0; u < (max_compact - 1); u++) { /* Delete first attribute in appropriate order */ ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); CHECK(ret, FAIL, "H5Adelete_by_idx"); /* Verify the attribute information for first attribute in appropriate order */ HDmemset(&ainfo, 0, sizeof(ainfo)); - ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, H5P_DEFAULT); - if(new_format) { - if(order == H5_ITER_INC) { + ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, + H5P_DEFAULT); + if (new_format) { + if (order == H5_ITER_INC) { VERIFY(ainfo.corder, (u + 1), "H5Aget_info_by_idx"); } /* end if */ else { VERIFY(ainfo.corder, (max_compact - (u + 2)), "H5Aget_info_by_idx"); } /* end else */ - } /* end if */ + } /* end if */ /* Verify the name for first attribute in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - if(order == H5_ITER_INC) + ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + if (order == H5_ITER_INC) HDsprintf(attrname, "attr %02u", (u + 1)); else HDsprintf(attrname, "attr %02u", (max_compact - (u + 2))); @@ -6447,8 +6446,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end for */ /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -6466,10 +6465,11 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Create more attributes, to push into dense form */ - for(u = 0; u < (max_compact * 2); u++) { + for (u = 0; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); /* Write data into the attribute */ @@ -6481,7 +6481,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Verify state of object */ - if(u >= max_compact) { + if (u >= max_compact) { is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); } /* end if */ @@ -6500,11 +6500,11 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); - if(new_format) { + if (new_format) { /* Retrieve & verify # of records in the name & creation order indices */ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count); CHECK(ret, FAIL, "H5O__attr_dense_info_test"); - if(use_index) + if (use_index) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test"); } /* end if */ @@ -6515,8 +6515,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end for */ /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -6534,27 +6534,29 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Delete attributes from dense storage */ - for(u = 0; u < ((max_compact * 2) - 1); u++) { + for (u = 0; u < ((max_compact * 2) - 1); u++) { /* Delete first attribute in appropriate order */ ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); CHECK(ret, FAIL, "H5Adelete_by_idx"); /* Verify the attribute information for first attribute in appropriate order */ HDmemset(&ainfo, 0, sizeof(ainfo)); - ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, H5P_DEFAULT); - if(new_format) { - if(order == H5_ITER_INC) { + ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, + H5P_DEFAULT); + if (new_format) { + if (order == H5_ITER_INC) { VERIFY(ainfo.corder, (u + 1), "H5Aget_info_by_idx"); } /* end if */ else { VERIFY(ainfo.corder, ((max_compact * 2) - (u + 2)), "H5Aget_info_by_idx"); } /* end else */ - } /* end if */ + } /* end if */ /* Verify the name for first attribute in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - if(order == H5_ITER_INC) + ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + if (order == H5_ITER_INC) HDsprintf(attrname, "attr %02u", (u + 1)); else HDsprintf(attrname, "attr %02u", ((max_compact * 2) - (u + 2))); @@ -6575,13 +6577,11 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(ret, FAIL, "H5Adelete_by_idx"); } /* end for */ - - /* Delete attributes in middle */ - + /* Delete attributes in middle */ /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -6599,10 +6599,11 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Create attributes, to push into dense form */ - for(u = 0; u < (max_compact * 2); u++) { + for (u = 0; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); /* Write data into the attribute */ @@ -6614,7 +6615,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Verify state of object */ - if(u >= max_compact) { + if (u >= max_compact) { is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); } /* end if */ @@ -6623,11 +6624,11 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) ret = attr_info_by_idx_check(my_dataset, attrname, (hsize_t)u, use_index); CHECK(ret, FAIL, "attr_info_by_idx_check"); } /* end for */ - } /* end for */ + } /* end for */ /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -6645,38 +6646,41 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Delete every other attribute from dense storage, in appropriate order */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Delete attribute */ ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT); CHECK(ret, FAIL, "H5Adelete_by_idx"); /* Verify the attribute information for first attribute in appropriate order */ HDmemset(&ainfo, 0, sizeof(ainfo)); - ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, &ainfo, H5P_DEFAULT); - if(new_format) { - if(order == H5_ITER_INC) { + ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, &ainfo, + H5P_DEFAULT); + if (new_format) { + if (order == H5_ITER_INC) { VERIFY(ainfo.corder, ((u * 2) + 1), "H5Aget_info_by_idx"); } /* end if */ else { - VERIFY(ainfo.corder, ((max_compact * 2) - ((u * 2) + 2)), "H5Aget_info_by_idx"); + VERIFY(ainfo.corder, ((max_compact * 2) - ((u * 2) + 2)), + "H5Aget_info_by_idx"); } /* end else */ - } /* end if */ + } /* end if */ /* Verify the name for first attribute in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - if(order == H5_ITER_INC) + ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + if (order == H5_ITER_INC) HDsprintf(attrname, "attr %02u", ((u * 2) + 1)); else HDsprintf(attrname, "attr %02u", ((max_compact * 2) - ((u * 2) + 2))); ret = HDstrcmp(attrname, tmpname); VERIFY(ret, 0, "H5Aget_name_by_idx"); } /* end for */ - } /* end for */ + } /* end for */ /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -6694,27 +6698,30 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Delete remaining attributes from dense storage, in appropriate order */ - for(u = 0; u < (max_compact - 1); u++) { + for (u = 0; u < (max_compact - 1); u++) { /* Delete attribute */ ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT); CHECK(ret, FAIL, "H5Adelete_by_idx"); /* Verify the attribute information for first attribute in appropriate order */ HDmemset(&ainfo, 0, sizeof(ainfo)); - ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, H5P_DEFAULT); - if(new_format) { - if(order == H5_ITER_INC) { + ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, + H5P_DEFAULT); + if (new_format) { + if (order == H5_ITER_INC) { VERIFY(ainfo.corder, ((u * 2) + 3), "H5Aget_info_by_idx"); } /* end if */ else { - VERIFY(ainfo.corder, ((max_compact * 2) - ((u * 2) + 4)), "H5Aget_info_by_idx"); + VERIFY(ainfo.corder, ((max_compact * 2) - ((u * 2) + 4)), + "H5Aget_info_by_idx"); } /* end else */ - } /* end if */ + } /* end if */ /* Verify the name for first attribute in appropriate order */ HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); - ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); - if(order == H5_ITER_INC) + ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, + tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + if (order == H5_ITER_INC) HDsprintf(attrname, "attr %02u", ((u * 2) + 3)); else HDsprintf(attrname, "attr %02u", ((max_compact * 2) - ((u * 2) + 4))); @@ -6747,8 +6754,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close property list */ ret = H5Pclose(dcpl); @@ -6757,8 +6764,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_delete_by_idx() */ - +} /* test_attr_delete_by_idx() */ /**************************************************************** ** @@ -6766,70 +6772,69 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) ** ****************************************************************/ static herr_t -attr_iterate2_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, - void *_op_data) +attr_iterate2_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data) { - attr_iter_info_t *op_data = (attr_iter_info_t *)_op_data; /* User data */ - char attrname[NAME_BUF_SIZE]; /* Object name */ - H5A_info_t my_info; /* Local attribute info */ + attr_iter_info_t *op_data = (attr_iter_info_t *)_op_data; /* User data */ + char attrname[NAME_BUF_SIZE]; /* Object name */ + H5A_info_t my_info; /* Local attribute info */ #ifdef QAK -HDfprintf(stderr, "attr_name = '%s'\n", attr_name); -if(info) - HDfprintf(stderr, "info->corder = %u\n", (unsigned)info->corder); -HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr); + HDfprintf(stderr, "attr_name = '%s'\n", attr_name); + if (info) + HDfprintf(stderr, "info->corder = %u\n", (unsigned)info->corder); + HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr); #endif /* QAK */ /* Increment # of times the callback was called */ op_data->ncalled++; /* Get the attribute information directly to compare */ - if(H5Aget_info_by_name(loc_id, ".", attr_name, &my_info, H5P_DEFAULT) < 0) - return(H5_ITER_ERROR); + if (H5Aget_info_by_name(loc_id, ".", attr_name, &my_info, H5P_DEFAULT) < 0) + return (H5_ITER_ERROR); /* Check more things for revised attribute iteration (vs. older attribute iteration) */ - if(info) { + if (info) { /* Check for correct order of iteration */ /* (if we are operating in increasing or decreasing order) */ - if(op_data->order != H5_ITER_NATIVE) - if(info->corder != op_data->curr) - return(H5_ITER_ERROR); + if (op_data->order != H5_ITER_NATIVE) + if (info->corder != op_data->curr) + return (H5_ITER_ERROR); /* Compare attribute info structs */ - if(info->corder_valid != my_info.corder_valid) - return(H5_ITER_ERROR); - if(info->corder != my_info.corder) - return(H5_ITER_ERROR); - if(info->cset != my_info.cset) - return(H5_ITER_ERROR); - if(info->data_size != my_info.data_size) - return(H5_ITER_ERROR); + if (info->corder_valid != my_info.corder_valid) + return (H5_ITER_ERROR); + if (info->corder != my_info.corder) + return (H5_ITER_ERROR); + if (info->cset != my_info.cset) + return (H5_ITER_ERROR); + if (info->data_size != my_info.data_size) + return (H5_ITER_ERROR); } /* end if */ /* Verify name of link */ HDsprintf(attrname, "attr %02u", (unsigned)my_info.corder); - if(HDstrcmp(attr_name, attrname)) - return(H5_ITER_ERROR); + if (HDstrcmp(attr_name, attrname)) + return (H5_ITER_ERROR); /* Check if we've visited this link before */ - if((size_t)op_data->curr >= op_data->max_visit) - return(H5_ITER_ERROR); - if(op_data->visited[op_data->curr]) - return(H5_ITER_ERROR); + if ((size_t)op_data->curr >= op_data->max_visit) + return (H5_ITER_ERROR); + if (op_data->visited[op_data->curr]) + return (H5_ITER_ERROR); op_data->visited[op_data->curr] = TRUE; /* Advance to next value, in correct direction */ - if(op_data->order != H5_ITER_DEC) + if (op_data->order != H5_ITER_DEC) op_data->curr++; else op_data->curr--; /* Check for stopping in the middle of iterating */ - if(op_data->stop > 0) - if(--op_data->stop == 0) - return(CORDER_ITER_STOP); + if (op_data->stop > 0) + if (--op_data->stop == 0) + return (CORDER_ITER_STOP); - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /* end attr_iterate2_cb() */ #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -6842,11 +6847,10 @@ HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr); static herr_t attr_iterate1_cb(hid_t loc_id, const char *attr_name, void *_op_data) { - return(attr_iterate2_cb(loc_id, attr_name, NULL, _op_data)); + return (attr_iterate2_cb(loc_id, attr_name, NULL, _op_data)); } /* end attr_iterate1_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: attr_iterate2_fail_cb * @@ -6863,12 +6867,11 @@ attr_iterate1_cb(hid_t loc_id, const char *attr_name, void *_op_data) */ static int attr_iterate2_fail_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *attr_name, - const H5A_info_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) + const H5A_info_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) { - return(H5_ITER_ERROR); + return (H5_ITER_ERROR); } /* end attr_iterate2_fail_cb() */ - /*------------------------------------------------------------------------- * Function: attr_iterate_check * @@ -6883,263 +6886,251 @@ attr_iterate2_fail_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED * *------------------------------------------------------------------------- */ static int -attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, - H5_index_t idx_type, H5_iter_order_t order, unsigned max_attrs, - attr_iter_info_t *iter_info) +attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + unsigned max_attrs, attr_iter_info_t *iter_info) { - unsigned v; /* Local index variable */ - hsize_t skip; /* # of attributes to skip on object */ + unsigned v; /* Local index variable */ + hsize_t skip; /* # of attributes to skip on object */ #ifndef H5_NO_DEPRECATED_SYMBOLS - unsigned oskip; /* # of attributes to skip on object, with H5Aiterate1 */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - int old_nerrs; /* Number of errors when entering this check */ - herr_t ret; /* Generic return value */ + unsigned oskip; /* # of attributes to skip on object, with H5Aiterate1 */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + int old_nerrs; /* Number of errors when entering this check */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); /* Iterate over attributes on object */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate2"); /* Verify that we visited all the attributes */ VERIFY(skip, max_attrs, "H5Aiterate2"); - for(v = 0; v < max_attrs; v++) + for (v = 0; v < max_attrs; v++) VERIFY(iter_info->visited[v], TRUE, "H5Aiterate2"); - /* Iterate over attributes on object */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aiterate_by_name"); /* Verify that we visited all the attributes */ VERIFY(skip, max_attrs, "H5Aiterate_by_name"); - for(v = 0; v < max_attrs; v++) + for (v = 0; v < max_attrs; v++) VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name"); - /* Iterate over attributes on object */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aiterate_by_name"); /* Verify that we visited all the attributes */ VERIFY(skip, max_attrs, "H5Aiterate_by_name"); - for(v = 0; v < max_attrs; v++) + for (v = 0; v < max_attrs; v++) VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name"); - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over attributes on object, with H5Aiterate1 */ iter_info->nskipped = oskip = 0; - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate1"); /* Verify that we visited all the attributes */ VERIFY(skip, max_attrs, "H5Aiterate1"); - for(v = 0; v < max_attrs; v++) + for (v = 0; v < max_attrs; v++) VERIFY(iter_info->visited[v], TRUE, "H5Aiterate1"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Skip over some attributes on object */ iter_info->nskipped = (unsigned)(skip = max_attrs / 2); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate2"); /* Verify that we visited all the attributes */ VERIFY(skip, max_attrs, "H5Aiterate2"); - if(order == H5_ITER_INC) { - for(v = 0; v < (max_attrs / 2); v++) + if (order == H5_ITER_INC) { + for (v = 0; v < (max_attrs / 2); v++) VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate2"); } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_attrs / 2); v++) + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_attrs / 2); v++) VERIFY(iter_info->visited[v], TRUE, "H5Aiterate2"); } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_attrs; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_attrs; v++) + if (iter_info->visited[v] == TRUE) nvisit++; VERIFY(skip, (max_attrs / 2), "H5Aiterate2"); } /* end else */ - /* Skip over some attributes on object */ iter_info->nskipped = (unsigned)(skip = max_attrs / 2); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aiterate_by_name"); /* Verify that we visited all the attributes */ VERIFY(skip, max_attrs, "H5Aiterate_by_name"); - if(order == H5_ITER_INC) { - for(v = 0; v < (max_attrs / 2); v++) + if (order == H5_ITER_INC) { + for (v = 0; v < (max_attrs / 2); v++) VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate_by_name"); } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_attrs / 2); v++) + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_attrs / 2); v++) VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name"); } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_attrs; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_attrs; v++) + if (iter_info->visited[v] == TRUE) nvisit++; VERIFY(skip, (max_attrs / 2), "H5Aiterate_by_name"); } /* end else */ - /* Skip over some attributes on object */ iter_info->nskipped = (unsigned)(skip = max_attrs / 2); - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aiterate_by_name"); /* Verify that we visited all the attributes */ VERIFY(skip, max_attrs, "H5Aiterate_by_name"); - if(order == H5_ITER_INC) { - for(v = 0; v < (max_attrs / 2); v++) + if (order == H5_ITER_INC) { + for (v = 0; v < (max_attrs / 2); v++) VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate_by_name"); } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_attrs / 2); v++) + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_attrs / 2); v++) VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name"); } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_attrs; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_attrs; v++) + if (iter_info->visited[v] == TRUE) nvisit++; VERIFY(skip, (max_attrs / 2), "H5Aiterate_by_name"); } /* end else */ - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some attributes on object, with H5Aiterate1 */ iter_info->nskipped = oskip = max_attrs / 2; - iter_info->order = order; - iter_info->stop = -1; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)oskip : ((max_attrs - 1) - oskip); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? (unsigned)oskip : ((max_attrs - 1) - oskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate1"); /* Verify that we visited all the links */ VERIFY(oskip, max_attrs, "H5Aiterate1"); - if(order == H5_ITER_INC) { - for(v = 0; v < (max_attrs / 2); v++) + if (order == H5_ITER_INC) { + for (v = 0; v < (max_attrs / 2); v++) VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate1"); } /* end if */ - else if(order == H5_ITER_DEC) { - for(v = 0; v < (max_attrs / 2); v++) + else if (order == H5_ITER_DEC) { + for (v = 0; v < (max_attrs / 2); v++) VERIFY(iter_info->visited[v], TRUE, "H5Aiterate1"); } /* end if */ else { - unsigned nvisit = 0; /* # of links visited */ + unsigned nvisit = 0; /* # of links visited */ HDassert(order == H5_ITER_NATIVE); - for(v = 0; v < max_attrs; v++) - if(iter_info->visited[v] == TRUE) + for (v = 0; v < max_attrs; v++) + if (iter_info->visited[v] == TRUE) nvisit++; VERIFY(skip, (max_attrs / 2), "H5Aiterate1"); - } /* end else */ + } /* end else */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Iterate over attributes on object, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate2"); VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate2"); VERIFY(iter_info->ncalled, 3, "H5Aiterate2"); - /* Iterate over attributes on object, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aiterate_by_name"); VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate_by_name"); VERIFY(iter_info->ncalled, 3, "H5Aiterate_by_name"); - /* Iterate over attributes on object, stopping in the middle */ iter_info->nskipped = (unsigned)(skip = 0); - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); CHECK(ret, FAIL, "H5Aiterate_by_name"); VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate_by_name"); VERIFY(iter_info->ncalled, 3, "H5Aiterate_by_name"); - #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over attributes on object, stopping in the middle, with H5Aiterate1() */ iter_info->nskipped = oskip = 0; - iter_info->order = order; - iter_info->stop = 3; - iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate1"); @@ -7147,10 +7138,9 @@ attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, VERIFY(iter_info->ncalled, 3, "H5Aiterate1"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* Check for iteration routine indicating failure */ skip = 0; - ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_fail_cb, NULL); + ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_fail_cb, NULL); VERIFY(ret, FAIL, "H5Aiterate2"); skip = 0; @@ -7158,17 +7148,16 @@ attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, VERIFY(ret, FAIL, "H5Aiterate_by_name"); skip = 0; - ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_fail_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_fail_cb, NULL, H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aiterate_by_name"); /* Retrieve current # of errors */ - if(old_nerrs == GetTestNumErrs()) - return(0); + if (old_nerrs == GetTestNumErrs()) + return (0); else - return(-1); + return (-1); } /* end attr_iterate_check() */ - /**************************************************************** ** ** test_attr_iterate2(): Test basic H5A (attribute) code. @@ -7178,30 +7167,30 @@ attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, static void test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - attr_iter_info_t iter_info; /* Iterator info */ - hbool_t *visited = NULL; /* Array of flags for visiting links */ - hsize_t idx; /* Start index for iteration */ - unsigned use_index; /* Use index on creation order values */ - const char *dsetname; /* Name of dataset for attributes */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + attr_iter_info_t iter_info; /* Iterator info */ + hbool_t * visited = NULL; /* Array of flags for visiting links */ + hsize_t idx; /* Start index for iteration */ + unsigned use_index; /* Use index on creation order values */ + const char * dsetname; /* Name of dataset for attributes */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -7211,7 +7200,8 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -7222,53 +7212,62 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Allocate the "visited link" array */ iter_info.max_visit = max_compact * 2; - visited = (hbool_t*)HDmalloc(sizeof(hbool_t) * iter_info.max_visit); + visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit); CHECK_PTR(visited, "HDmalloc"); iter_info.visited = visited; /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Increasing Order w/Creation Order Index\n")) + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in " + "Increasing Order w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Increasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in " + "Increasing Order w/o Creation Order Index\n")) } /* end if */ else { - if(use_index) - MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Decreasing Order w/Creation Order Index\n")) + if (use_index) + MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in " + "Decreasing Order w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Decreasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in " + "Decreasing Order w/o Creation Order Index\n")) } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) - MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order w/Creation Order Index\n")) + if (order == H5_ITER_INC) { + if (use_index) + MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order " + "w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order " + "w/o Creation Order Index\n")) } /* end if */ else { - if(use_index) - MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order w/Creation Order Index\n")) + if (use_index) + MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order " + "w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order " + "w/o Creation Order Index\n")) } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fcreate"); /* Set attribute creation order tracking & indexing for object */ - if(new_format == TRUE) { - ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); + if (new_format == TRUE) { + ret = H5Pset_attr_creation_order( + dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); CHECK(ret, FAIL, "H5Pset_attr_creation_order"); } /* end if */ @@ -7281,21 +7280,21 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; - dsetname = DSET1_NAME; + dsetname = DSET1_NAME; break; case 1: my_dataset = dset2; - dsetname = DSET2_NAME; + dsetname = DSET2_NAME; break; case 2: my_dataset = dset3; - dsetname = DSET3_NAME; + dsetname = DSET3_NAME; break; default: @@ -7312,17 +7311,20 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) ret = H5Aiterate2(my_dataset, idx_type, order, NULL, attr_iterate2_cb, NULL); CHECK(ret, FAIL, "H5Aiterate2"); - ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, NULL, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, NULL, attr_iterate2_cb, NULL, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Aiterate_by_name"); - ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, NULL, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, NULL, attr_iterate2_cb, NULL, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Aiterate_by_name"); /* Create attributes, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); /* Write data into the attribute */ @@ -7353,11 +7355,13 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(ret, FAIL, "H5Aiterate2"); idx = u; - ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aiterate_by_name"); idx = u; - ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aiterate_by_name"); /* Test iteration over attributes stored compactly */ @@ -7365,23 +7369,22 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "attr_iterate_check"); } /* end for */ - /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; - dsetname = DSET1_NAME; + dsetname = DSET1_NAME; break; case 1: my_dataset = dset2; - dsetname = DSET2_NAME; + dsetname = DSET2_NAME; break; case 2: my_dataset = dset3; - dsetname = DSET3_NAME; + dsetname = DSET3_NAME; break; default: @@ -7389,10 +7392,11 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Create more attributes, to push into dense form */ - for(u = max_compact; u < (max_compact * 2); u++) { + for (u = max_compact; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); /* Write data into the attribute */ @@ -7404,7 +7408,7 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Verify state of object */ - if(u >= max_compact) { + if (u >= max_compact) { is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); } /* end if */ @@ -7423,11 +7427,11 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); - if(new_format) { + if (new_format) { /* Retrieve & verify # of records in the name & creation order indices */ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count); CHECK(ret, FAIL, "H5O__attr_dense_info_test"); - if(use_index) + if (use_index) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test"); } /* end if */ @@ -7438,11 +7442,13 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(ret, FAIL, "H5Aiterate2"); idx = u; - ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aiterate_by_name"); idx = u; - ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, + H5P_DEFAULT); VERIFY(ret, FAIL, "H5Aiterate_by_name"); /* Test iteration over attributes stored densely */ @@ -7462,8 +7468,8 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close property list */ ret = H5Pclose(dcpl); @@ -7475,8 +7481,7 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Free the "visited link" array */ HDfree(visited); -} /* test_attr_iterate2() */ - +} /* test_attr_iterate2() */ /*------------------------------------------------------------------------- * Function: attr_open_by_idx_check @@ -7492,20 +7497,19 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) *------------------------------------------------------------------------- */ static int -attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - unsigned max_attrs) +attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, unsigned max_attrs) { - hid_t attr_id; /* ID of attribute to test */ - H5A_info_t ainfo; /* Attribute info */ - int old_nerrs; /* Number of errors when entering this check */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t attr_id; /* ID of attribute to test */ + H5A_info_t ainfo; /* Attribute info */ + int old_nerrs; /* Number of errors when entering this check */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); /* Open each attribute on object by index and check that it's the correct one */ - for(u = 0; u < max_attrs; u++) { + for (u = 0; u < max_attrs; u++) { /* Open the attribute */ attr_id = H5Aopen_by_idx(obj_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr_id, FAIL, "H5Aopen_by_idx"); @@ -7515,10 +7519,10 @@ attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, CHECK(ret, FAIL, "H5Aget_info"); /* Check that the object is the correct one */ - if(order == H5_ITER_INC) { + if (order == H5_ITER_INC) { VERIFY(ainfo.corder, u, "H5Aget_info"); } /* end if */ - else if(order == H5_ITER_DEC) { + else if (order == H5_ITER_DEC) { VERIFY(ainfo.corder, (max_attrs - (u + 1)), "H5Aget_info"); } /* end if */ else { @@ -7531,13 +7535,12 @@ attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, } /* end for */ /* Retrieve current # of errors */ - if(old_nerrs == GetTestNumErrs()) - return(0); + if (old_nerrs == GetTestNumErrs()) + return (0); else - return(-1); + return (-1); } /* end attr_open_by_idx_check() */ - /**************************************************************** ** ** test_attr_open_by_idx(): Test basic H5A (attribute) code. @@ -7547,27 +7550,27 @@ attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, static void test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - H5_index_t idx_type; /* Type of index to operate on */ - H5_iter_order_t order; /* Order within in the index */ - unsigned use_index; /* Use index on creation order values */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + H5_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + unsigned use_index; /* Use index on creation order values */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -7577,7 +7580,8 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -7587,48 +7591,57 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Pget_attr_phase_change"); /* Loop over operating on different indices on link fields */ - for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { + for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) { /* Loop over operating in different orders */ - for(order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { + for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) { /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(idx_type == H5_INDEX_CRT_ORDER) { - if(order == H5_ITER_INC) { - if(use_index) - MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing Order w/Creation Order Index\n")) + if (idx_type == H5_INDEX_CRT_ORDER) { + if (order == H5_ITER_INC) { + if (use_index) + MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing " + "Order w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing " + "Order w/o Creation Order Index\n")) } /* end if */ else { - if(use_index) - MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing Order w/Creation Order Index\n")) + if (use_index) + MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing " + "Order w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing " + "Order w/o Creation Order Index\n")) } /* end else */ - } /* end if */ + } /* end if */ else { - if(order == H5_ITER_INC) { - if(use_index) - MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order w/Creation Order Index\n")) + if (order == H5_ITER_INC) { + if (use_index) + MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order " + "w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order w/o " + "Creation Order Index\n")) } /* end if */ else { - if(use_index) - MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order w/Creation Order Index\n")) + if (use_index) + MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order " + "w/Creation Order Index\n")) else - MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order w/o Creation Order Index\n")) + MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order w/o " + "Creation Order Index\n")) } /* end else */ - } /* end else */ + } /* end else */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fcreate"); /* Set attribute creation order tracking & indexing for object */ - if(new_format == TRUE) { - ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); + if (new_format == TRUE) { + ret = H5Pset_attr_creation_order( + dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); CHECK(ret, FAIL, "H5Pset_attr_creation_order"); } /* end if */ @@ -7641,8 +7654,8 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -7666,14 +7679,16 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Check for opening an attribute on an object with no attributes */ - ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT); + ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT, + H5P_DEFAULT); VERIFY(ret_id, FAIL, "H5Aopen_by_idx"); /* Create attributes, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); /* Write data into the attribute */ @@ -7699,7 +7714,8 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Check for out of bound opening an attribute on an object */ - ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT); + ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, + H5P_DEFAULT); VERIFY(ret_id, FAIL, "H5Aopen_by_idx"); /* Test opening attributes by index stored compactly */ @@ -7707,10 +7723,9 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "attr_open_by_idx_check"); } /* end for */ - /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; break; @@ -7728,10 +7743,11 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Create more attributes, to push into dense form */ - for(u = max_compact; u < (max_compact * 2); u++) { + for (u = max_compact; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + attr = + H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); /* Write data into the attribute */ @@ -7743,7 +7759,7 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Verify state of object */ - if(u >= max_compact) { + if (u >= max_compact) { is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); } /* end if */ @@ -7762,17 +7778,18 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); - if(new_format) { + if (new_format) { /* Retrieve & verify # of records in the name & creation order indices */ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count); CHECK(ret, FAIL, "H5O__attr_dense_info_test"); - if(use_index) + if (use_index) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test"); } /* end if */ /* Check for out of bound opening an attribute on an object */ - ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT); + ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, + H5P_DEFAULT); VERIFY(ret_id, FAIL, "H5Aopen_by_idx"); /* Test opening attributes by index stored compactly */ @@ -7792,8 +7809,8 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close property list */ ret = H5Pclose(dcpl); @@ -7802,8 +7819,7 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_open_by_idx() */ - +} /* test_attr_open_by_idx() */ /*------------------------------------------------------------------------- * Function: attr_open_check @@ -7819,21 +7835,20 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) *------------------------------------------------------------------------- */ static int -attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, - unsigned max_attrs) +attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, unsigned max_attrs) { - hid_t attr_id; /* ID of attribute to test */ - H5A_info_t ainfo; /* Attribute info */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - int old_nerrs; /* Number of errors when entering this check */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t attr_id; /* ID of attribute to test */ + H5A_info_t ainfo; /* Attribute info */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + int old_nerrs; /* Number of errors when entering this check */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); /* Open each attribute on object by index and check that it's the correct one */ - for(u = 0; u < max_attrs; u++) { + for (u = 0; u < max_attrs; u++) { /* Open the attribute */ HDsprintf(attrname, "attr %02u", u); attr_id = H5Aopen(obj_id, attrname, H5P_DEFAULT); @@ -7850,7 +7865,6 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, ret = H5Aclose(attr_id); CHECK(ret, FAIL, "H5Aclose"); - /* Open the attribute */ attr_id = H5Aopen_by_name(obj_id, ".", attrname, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr_id, FAIL, "H5Aopen_by_name"); @@ -7866,7 +7880,6 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, ret = H5Aclose(attr_id); CHECK(ret, FAIL, "H5Aclose"); - /* Open the attribute */ attr_id = H5Aopen_by_name(fid, dsetname, attrname, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr_id, FAIL, "H5Aopen_by_name"); @@ -7884,13 +7897,12 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, } /* end for */ /* Retrieve current # of errors */ - if(old_nerrs == GetTestNumErrs()) - return(0); + if (old_nerrs == GetTestNumErrs()) + return (0); else - return(-1); + return (-1); } /* end attr_open_check() */ - /**************************************************************** ** ** test_attr_open_by_name(): Test basic H5A (attribute) code. @@ -7900,26 +7912,26 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, static void test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - unsigned use_index; /* Use index on creation order values */ - const char *dsetname; /* Name of dataset for attributes */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + unsigned use_index; /* Use index on creation order values */ + const char *dsetname; /* Name of dataset for attributes */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -7929,7 +7941,8 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -7939,9 +7952,9 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Pget_attr_phase_change"); /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(use_index) + if (use_index) MESSAGE(5, ("Testing Opening Attributes By Name w/Creation Order Index\n")) else MESSAGE(5, ("Testing Opening Attributes By Name w/o Creation Order Index\n")) @@ -7951,8 +7964,9 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(fid, FAIL, "H5Fcreate"); /* Set attribute creation order tracking & indexing for object */ - if(new_format == TRUE) { - ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); + if (new_format == TRUE) { + ret = H5Pset_attr_creation_order( + dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); CHECK(ret, FAIL, "H5Pset_attr_creation_order"); } /* end if */ @@ -7965,21 +7979,21 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; - dsetname = DSET1_NAME; + dsetname = DSET1_NAME; break; case 1: my_dataset = dset2; - dsetname = DSET2_NAME; + dsetname = DSET2_NAME; break; case 2: my_dataset = dset3; - dsetname = DSET3_NAME; + dsetname = DSET3_NAME; break; default: @@ -8003,7 +8017,7 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(ret_id, FAIL, "H5Aopen_by_name"); /* Create attributes, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -8046,23 +8060,22 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "attr_open_check"); } /* end for */ - /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; - dsetname = DSET1_NAME; + dsetname = DSET1_NAME; break; case 1: my_dataset = dset2; - dsetname = DSET2_NAME; + dsetname = DSET2_NAME; break; case 2: my_dataset = dset3; - dsetname = DSET3_NAME; + dsetname = DSET3_NAME; break; default: @@ -8070,7 +8083,7 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Create more attributes, to push into dense form */ - for(u = max_compact; u < (max_compact * 2); u++) { + for (u = max_compact; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -8085,7 +8098,7 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Verify state of object */ - if(u >= max_compact) { + if (u >= max_compact) { is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); } /* end if */ @@ -8104,11 +8117,11 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); - if(new_format) { + if (new_format) { /* Retrieve & verify # of records in the name & creation order indices */ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count); CHECK(ret, FAIL, "H5O__attr_dense_info_test"); - if(use_index) + if (use_index) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test"); } /* end if */ @@ -8148,8 +8161,7 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_open_by_name() */ - +} /* test_attr_open_by_name() */ /**************************************************************** ** @@ -8160,25 +8172,25 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) static void test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - unsigned max_compact; /* Maximum # of links to store in group compactly */ - unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - hsize_t nattrs; /* Number of attributes on object */ - hsize_t name_count; /* # of records in name index */ - hsize_t corder_count; /* # of records in creation order index */ - unsigned use_index; /* Use index on creation order values */ - const char *dsetname; /* Name of dataset for attributes */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned curr_dset; /* Current dataset to work on */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + hsize_t nattrs; /* Number of attributes on object */ + hsize_t name_count; /* # of records in name index */ + hsize_t corder_count; /* # of records in creation order index */ + unsigned use_index; /* Use index on creation order values */ + const char *dsetname; /* Name of dataset for attributes */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned curr_dset; /* Current dataset to work on */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -8188,7 +8200,8 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -8198,9 +8211,9 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Pget_attr_phase_change"); /* Loop over using index for creation order value */ - for(use_index = FALSE; use_index <= TRUE; use_index++) { + for (use_index = FALSE; use_index <= TRUE; use_index++) { /* Print appropriate test message */ - if(use_index) + if (use_index) MESSAGE(5, ("Testing Creating Attributes By Name w/Creation Order Index\n")) else MESSAGE(5, ("Testing Creating Attributes By Name w/o Creation Order Index\n")) @@ -8210,8 +8223,9 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(fid, FAIL, "H5Fcreate"); /* Set attribute creation order tracking & indexing for object */ - if(new_format == TRUE) { - ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); + if (new_format == TRUE) { + ret = H5Pset_attr_creation_order( + dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))); CHECK(ret, FAIL, "H5Pset_attr_creation_order"); } /* end if */ @@ -8224,21 +8238,21 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(dset3, FAIL, "H5Dcreate2"); /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; - dsetname = DSET1_NAME; + dsetname = DSET1_NAME; break; case 1: my_dataset = dset2; - dsetname = DSET2_NAME; + dsetname = DSET2_NAME; break; case 2: my_dataset = dset3; - dsetname = DSET3_NAME; + dsetname = DSET3_NAME; break; default: @@ -8252,10 +8266,11 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Create attributes, up to limit of compact form */ - for(u = 0; u < max_compact; u++) { + for (u = 0; u < max_compact; u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate_by_name"); /* Write data into the attribute */ @@ -8285,23 +8300,22 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "attr_open_check"); } /* end for */ - /* Work on all the datasets */ - for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { - switch(curr_dset) { + for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) { + switch (curr_dset) { case 0: my_dataset = dset1; - dsetname = DSET1_NAME; + dsetname = DSET1_NAME; break; case 1: my_dataset = dset2; - dsetname = DSET2_NAME; + dsetname = DSET2_NAME; break; case 2: my_dataset = dset3; - dsetname = DSET3_NAME; + dsetname = DSET3_NAME; break; default: @@ -8309,10 +8323,11 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* end switch */ /* Create more attributes, to push into dense form */ - for(u = max_compact; u < (max_compact * 2); u++) { + for (u = max_compact; u < (max_compact * 2); u++) { /* Create attribute */ HDsprintf(attrname, "attr %02u", u); - attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate_by_name"); /* Write data into the attribute */ @@ -8324,7 +8339,7 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Verify state of object */ - if(u >= max_compact) { + if (u >= max_compact) { is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); } /* end if */ @@ -8343,11 +8358,11 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) is_dense = H5O__is_attr_dense_test(my_dataset); VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test"); - if(new_format) { + if (new_format) { /* Retrieve & verify # of records in the name & creation order indices */ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count); CHECK(ret, FAIL, "H5O__attr_dense_info_test"); - if(use_index) + if (use_index) VERIFY(name_count, corder_count, "H5O__attr_dense_info_test"); VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test"); } /* end if */ @@ -8377,7 +8392,7 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_attr_create_by_name() */ +} /* test_attr_create_by_name() */ /**************************************************************** ** @@ -8388,28 +8403,28 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) static void test_attr_shared_write(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t my_fcpl; /* File creation property list ID */ - hid_t dataset, dataset2; /* Dataset IDs */ - hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid, big_sid; /* Dataspace IDs */ - hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - htri_t is_shared; /* Is attributes shared? */ - hsize_t shared_refcount; /* Reference count of shared attribute */ - unsigned attr_value; /* Attribute value */ - unsigned *big_value; /* Data for "big" attribute */ - size_t mesg_count; /* # of shared messages */ - unsigned test_shared; /* Index over shared component type */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t my_fcpl; /* File creation property list ID */ + hid_t dataset, dataset2; /* Dataset IDs */ + hid_t attr_tid; /* Attribute's datatype ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_shared; /* Is attributes shared? */ + hsize_t shared_refcount; /* Reference count of shared attribute */ + unsigned attr_value; /* Attribute value */ + unsigned * big_value; /* Data for "big" attribute */ + size_t mesg_count; /* # of shared messages */ + unsigned test_shared; /* Index over shared component type */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Writing Shared & Unshared Attributes in Compact & Dense Storage\n")); @@ -8428,7 +8443,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(big_sid, FAIL, "H5Screate_simple"); /* Loop over type of shared components */ - for(test_shared = 0; test_shared < 3; test_shared++) { + for (test_shared = 0; test_shared < 3; test_shared++) { /* Make copy of file creation property list */ my_fcpl = H5Pcopy(fcpl); CHECK(my_fcpl, FAIL, "H5Pcopy"); @@ -8438,7 +8453,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(attr_tid, FAIL, "H5Tcopy"); /* Special setup for each type of shared components */ - if(test_shared == 0) { + if (test_shared == 0) { /* Make attributes > 500 bytes shared */ ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); @@ -8476,16 +8491,15 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); /* Commit datatype to file */ - if(test_shared == 2) { + if (test_shared == 2) { ret = H5Tcommit2(fid, TYPE1_NAME, attr_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); } /* end if */ @@ -8494,7 +8508,8 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -8506,7 +8521,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(dataset2, FAIL, "H5Dcreate2"); /* Check on dataset's message storage status */ - if(test_shared != 0) { + if (test_shared != 0) { /* Datasets' datatypes can be shared */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -8533,12 +8548,12 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes to each dataset, until after converting to dense storage */ - for(u = 0; u < max_compact * 2; u++) { + for (u = 0; u < max_compact * 2; u++) { /* Create attribute name */ HDsprintf(attrname, "attr %02u", u); /* Alternate between creating "small" & "big" attributes */ - if(u % 2) { + if (u % 2) { /* Create "small" attribute on first dataset */ attr = H5Acreate2(dataset, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); @@ -8549,7 +8564,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); + ret = H5Awrite(attr, attr_tid, &attr_value); CHECK(ret, FAIL, "H5Awrite"); } /* end if */ else { @@ -8568,7 +8583,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ big_value[0] = u + 1; - ret = H5Awrite(attr, attr_tid, big_value); + ret = H5Awrite(attr, attr_tid, big_value); CHECK(ret, FAIL, "H5Awrite"); /* Check refcount for attribute */ @@ -8583,14 +8598,13 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset); - if(u < max_compact) + if (u < max_compact) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); else VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); - /* Alternate between creating "small" & "big" attributes */ - if(u % 2) { + if (u % 2) { /* Create "small" attribute on second dataset */ attr = H5Acreate2(dataset2, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); @@ -8601,7 +8615,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); + ret = H5Awrite(attr, attr_tid, &attr_value); CHECK(ret, FAIL, "H5Awrite"); } /* end if */ else { @@ -8620,7 +8634,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ big_value[0] = u + 1; - ret = H5Awrite(attr, attr_tid, big_value); + ret = H5Awrite(attr, attr_tid, big_value); CHECK(ret, FAIL, "H5Awrite"); /* Check refcount for attribute */ @@ -8635,7 +8649,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset2); - if(u < max_compact) + if (u < max_compact) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); else VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); @@ -8652,8 +8666,8 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Dclose"); /* Check on shared message status now */ - if(test_shared != 0) { - if(test_shared == 1) { + if (test_shared != 0) { + if (test_shared == 1) { /* Check on datatype storage status */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -8673,7 +8687,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Ldelete"); /* Unlink committed datatype */ - if(test_shared == 2) { + if (test_shared == 2) { ret = H5Ldelete(fid, TYPE1_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); } /* end if */ @@ -8683,7 +8697,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test"); - if(test_shared != 0) { + if (test_shared != 0) { /* Check on datatype storage status */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -8712,7 +8726,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Release memory */ HDfree(big_value); -} /* test_attr_shared_write() */ +} /* test_attr_shared_write() */ /**************************************************************** ** @@ -8723,29 +8737,29 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) static void test_attr_shared_rename(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t my_fcpl; /* File creation property list ID */ - hid_t dataset, dataset2; /* Dataset ID2 */ - hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid, big_sid; /* Dataspace IDs */ - hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ - char attrname2[NAME_BUF_SIZE]; /* Name of attribute on second dataset */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - htri_t is_shared; /* Is attributes shared? */ - hsize_t shared_refcount; /* Reference count of shared attribute */ - unsigned attr_value; /* Attribute value */ - unsigned *big_value; /* Data for "big" attribute */ - size_t mesg_count; /* # of shared messages */ - unsigned test_shared; /* Index over shared component type */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t my_fcpl; /* File creation property list ID */ + hid_t dataset, dataset2; /* Dataset ID2 */ + hid_t attr_tid; /* Attribute's datatype ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ + char attrname2[NAME_BUF_SIZE]; /* Name of attribute on second dataset */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_shared; /* Is attributes shared? */ + hsize_t shared_refcount; /* Reference count of shared attribute */ + unsigned attr_value; /* Attribute value */ + unsigned * big_value; /* Data for "big" attribute */ + size_t mesg_count; /* # of shared messages */ + unsigned test_shared; /* Index over shared component type */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Renaming Shared & Unshared Attributes in Compact & Dense Storage\n")); @@ -8764,7 +8778,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(big_sid, FAIL, "H5Screate_simple"); /* Loop over type of shared components */ - for(test_shared = 0; test_shared < 3; test_shared++) { + for (test_shared = 0; test_shared < 3; test_shared++) { /* Make copy of file creation property list */ my_fcpl = H5Pcopy(fcpl); CHECK(my_fcpl, FAIL, "H5Pcopy"); @@ -8774,7 +8788,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(attr_tid, FAIL, "H5Tcopy"); /* Special setup for each type of shared components */ - if(test_shared == 0) { + if (test_shared == 0) { /* Make attributes > 500 bytes shared */ ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); @@ -8812,16 +8826,15 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); /* Commit datatype to file */ - if(test_shared == 2) { + if (test_shared == 2) { ret = H5Tcommit2(fid, TYPE1_NAME, attr_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); } /* end if */ @@ -8830,7 +8843,8 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -8842,7 +8856,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(dataset2, FAIL, "H5Dcreate2"); /* Check on dataset's message storage status */ - if(test_shared != 0) { + if (test_shared != 0) { /* Datasets' datatypes can be shared */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -8869,12 +8883,12 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes to each dataset, until after converting to dense storage */ - for(u = 0; u < max_compact * 2; u++) { + for (u = 0; u < max_compact * 2; u++) { /* Create attribute name */ HDsprintf(attrname, "attr %02u", u); /* Alternate between creating "small" & "big" attributes */ - if(u % 2) { + if (u % 2) { /* Create "small" attribute on first dataset */ attr = H5Acreate2(dataset, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); @@ -8885,7 +8899,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); + ret = H5Awrite(attr, attr_tid, &attr_value); CHECK(ret, FAIL, "H5Awrite"); } /* end if */ else { @@ -8904,7 +8918,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ big_value[0] = u + 1; - ret = H5Awrite(attr, attr_tid, big_value); + ret = H5Awrite(attr, attr_tid, big_value); CHECK(ret, FAIL, "H5Awrite"); /* Check refcount for attribute */ @@ -8919,14 +8933,13 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset); - if(u < max_compact) + if (u < max_compact) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); else VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); - /* Alternate between creating "small" & "big" attributes */ - if(u % 2) { + if (u % 2) { /* Create "small" attribute on second dataset */ attr = H5Acreate2(dataset2, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); @@ -8937,7 +8950,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); + ret = H5Awrite(attr, attr_tid, &attr_value); CHECK(ret, FAIL, "H5Awrite"); } /* end if */ else { @@ -8956,7 +8969,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ big_value[0] = u + 1; - ret = H5Awrite(attr, attr_tid, big_value); + ret = H5Awrite(attr, attr_tid, big_value); CHECK(ret, FAIL, "H5Awrite"); /* Check refcount for attribute */ @@ -8971,12 +8984,11 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset2); - if(u < max_compact) + if (u < max_compact) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); else VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); - /* Create new attribute name */ HDsprintf(attrname2, "new attr %02u", u); @@ -8984,14 +8996,13 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) ret = H5Arename_by_name(fid, DSET2_NAME, attrname, attrname2, H5P_DEFAULT); CHECK(ret, FAIL, "H5Arename_by_name"); - /* Check refcount on attributes now */ /* Check refcount on renamed attribute */ attr = H5Aopen(dataset2, attrname2, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); - if(u % 2) { + if (u % 2) { /* Check that attribute is not shared */ is_shared = H5A__is_shared_test(attr); VERIFY(is_shared, FALSE, "H5A__is_shared_test"); @@ -9015,7 +9026,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) attr = H5Aopen(dataset, attrname, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); - if(u % 2) { + if (u % 2) { /* Check that attribute is not shared */ is_shared = H5A__is_shared_test(attr); VERIFY(is_shared, FALSE, "H5A__is_shared_test"); @@ -9035,19 +9046,17 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); - /* Change second dataset's attribute's name back to original */ ret = H5Arename_by_name(fid, DSET2_NAME, attrname2, attrname, H5P_DEFAULT); CHECK(ret, FAIL, "H5Arename_by_name"); - /* Check refcount on attributes now */ /* Check refcount on renamed attribute */ attr = H5Aopen(dataset2, attrname, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); - if(u % 2) { + if (u % 2) { /* Check that attribute is not shared */ is_shared = H5A__is_shared_test(attr); VERIFY(is_shared, FALSE, "H5A__is_shared_test"); @@ -9071,7 +9080,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) attr = H5Aopen(dataset, attrname, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); - if(u % 2) { + if (u % 2) { /* Check that attribute is not shared */ is_shared = H5A__is_shared_test(attr); VERIFY(is_shared, FALSE, "H5A__is_shared_test"); @@ -9092,7 +9101,6 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); } /* end for */ - /* Close attribute's datatype */ ret = H5Tclose(attr_tid); CHECK(ret, FAIL, "H5Tclose"); @@ -9104,8 +9112,8 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Dclose"); /* Check on shared message status now */ - if(test_shared != 0) { - if(test_shared == 1) { + if (test_shared != 0) { + if (test_shared == 1) { /* Check on datatype storage status */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -9125,7 +9133,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Ldelete"); /* Unlink committed datatype */ - if(test_shared == 2) { + if (test_shared == 2) { ret = H5Ldelete(fid, TYPE1_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); } /* end if */ @@ -9135,7 +9143,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test"); - if(test_shared != 0) { + if (test_shared != 0) { /* Check on datatype storage status */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -9164,7 +9172,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Release memory */ HDfree(big_value); -} /* test_attr_shared_rename() */ +} /* test_attr_shared_rename() */ /**************************************************************** ** @@ -9175,28 +9183,28 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) static void test_attr_shared_delete(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t my_fcpl; /* File creation property list ID */ - hid_t dataset, dataset2; /* Dataset IDs */ - hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid, big_sid; /* Dataspace IDs */ - hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - htri_t is_shared; /* Is attributes shared? */ - hsize_t shared_refcount; /* Reference count of shared attribute */ - unsigned attr_value; /* Attribute value */ - unsigned *big_value; /* Data for "big" attribute */ - size_t mesg_count; /* # of shared messages */ - unsigned test_shared; /* Index over shared component type */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t my_fcpl; /* File creation property list ID */ + hid_t dataset, dataset2; /* Dataset IDs */ + hid_t attr_tid; /* Attribute's datatype ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_shared; /* Is attributes shared? */ + hsize_t shared_refcount; /* Reference count of shared attribute */ + unsigned attr_value; /* Attribute value */ + unsigned * big_value; /* Data for "big" attribute */ + size_t mesg_count; /* # of shared messages */ + unsigned test_shared; /* Index over shared component type */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Shared & Unshared Attributes in Compact & Dense Storage\n")); @@ -9215,7 +9223,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(big_sid, FAIL, "H5Screate_simple"); /* Loop over type of shared components */ - for(test_shared = 0; test_shared < 3; test_shared++) { + for (test_shared = 0; test_shared < 3; test_shared++) { /* Make copy of file creation property list */ my_fcpl = H5Pcopy(fcpl); CHECK(my_fcpl, FAIL, "H5Pcopy"); @@ -9225,7 +9233,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(attr_tid, FAIL, "H5Tcopy"); /* Special setup for each type of shared components */ - if(test_shared == 0) { + if (test_shared == 0) { /* Make attributes > 500 bytes shared */ ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); @@ -9263,16 +9271,15 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); /* Commit datatype to file */ - if(test_shared == 2) { + if (test_shared == 2) { ret = H5Tcommit2(fid, TYPE1_NAME, attr_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); } /* end if */ @@ -9281,7 +9288,8 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -9293,7 +9301,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(dataset2, FAIL, "H5Dcreate2"); /* Check on dataset's message storage status */ - if(test_shared != 0) { + if (test_shared != 0) { /* Datasets' datatypes can be shared */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -9320,12 +9328,12 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes to each dataset, until after converting to dense storage */ - for(u = 0; u < max_compact * 2; u++) { + for (u = 0; u < max_compact * 2; u++) { /* Create attribute name */ HDsprintf(attrname, "attr %02u", u); /* Alternate between creating "small" & "big" attributes */ - if(u % 2) { + if (u % 2) { /* Create "small" attribute on first dataset */ attr = H5Acreate2(dataset, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); @@ -9336,7 +9344,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); + ret = H5Awrite(attr, attr_tid, &attr_value); CHECK(ret, FAIL, "H5Awrite"); } /* end if */ else { @@ -9355,7 +9363,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ big_value[0] = u + 1; - ret = H5Awrite(attr, attr_tid, big_value); + ret = H5Awrite(attr, attr_tid, big_value); CHECK(ret, FAIL, "H5Awrite"); /* Check refcount for attribute */ @@ -9370,14 +9378,13 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset); - if(u < max_compact) + if (u < max_compact) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); else VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); - /* Alternate between creating "small" & "big" attributes */ - if(u % 2) { + if (u % 2) { /* Create "small" attribute on second dataset */ attr = H5Acreate2(dataset2, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); @@ -9388,7 +9395,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); + ret = H5Awrite(attr, attr_tid, &attr_value); CHECK(ret, FAIL, "H5Awrite"); } /* end if */ else { @@ -9407,7 +9414,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ big_value[0] = u + 1; - ret = H5Awrite(attr, attr_tid, big_value); + ret = H5Awrite(attr, attr_tid, big_value); CHECK(ret, FAIL, "H5Awrite"); /* Check refcount for attribute */ @@ -9422,15 +9429,14 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset2); - if(u < max_compact) + if (u < max_compact) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); else VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); } /* end for */ - /* Delete attributes from second dataset */ - for(u = 0; u < max_compact * 2; u++) { + for (u = 0; u < max_compact * 2; u++) { /* Create attribute name */ HDsprintf(attrname, "attr %02u", u); @@ -9438,14 +9444,13 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) ret = H5Adelete_by_name(fid, DSET2_NAME, attrname, H5P_DEFAULT); CHECK(ret, FAIL, "H5Adelete_by_name"); - /* Check refcount on attributes now */ /* Check refcount on first dataset's attribute */ attr = H5Aopen(dataset, attrname, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); - if(u % 2) { + if (u % 2) { /* Check that attribute is not shared */ is_shared = H5A__is_shared_test(attr); VERIFY(is_shared, FALSE, "H5A__is_shared_test"); @@ -9466,7 +9471,6 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); } /* end for */ - /* Close attribute's datatype */ ret = H5Tclose(attr_tid); CHECK(ret, FAIL, "H5Tclose"); @@ -9478,8 +9482,8 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Dclose"); /* Check on shared message status now */ - if(test_shared != 0) { - if(test_shared == 1) { + if (test_shared != 0) { + if (test_shared == 1) { /* Check on datatype storage status */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -9499,7 +9503,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Ldelete"); /* Unlink committed datatype */ - if(test_shared == 2) { + if (test_shared == 2) { ret = H5Ldelete(fid, TYPE1_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); } /* end if */ @@ -9509,7 +9513,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test"); - if(test_shared != 0) { + if (test_shared != 0) { /* Check on datatype storage status */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -9538,7 +9542,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Release memory */ HDfree(big_value); -} /* test_attr_shared_delete() */ +} /* test_attr_shared_delete() */ /**************************************************************** ** @@ -9549,28 +9553,28 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) static void test_attr_shared_unlink(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t my_fcpl; /* File creation property list ID */ - hid_t dataset, dataset2; /* Dataset IDs */ - hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid, big_sid; /* Dataspace IDs */ - hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ - unsigned max_compact; /* Maximum # of attributes to store compactly */ - unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - htri_t is_shared; /* Is attributes shared? */ - hsize_t shared_refcount; /* Reference count of shared attribute */ - unsigned attr_value; /* Attribute value */ - unsigned *big_value; /* Data for "big" attribute */ - size_t mesg_count; /* # of shared messages */ - unsigned test_shared; /* Index over shared component type */ - unsigned u; /* Local index variable */ - h5_stat_size_t empty_filesize; /* Size of empty file */ - h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t my_fcpl; /* File creation property list ID */ + hid_t dataset, dataset2; /* Dataset IDs */ + hid_t attr_tid; /* Attribute's datatype ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ + unsigned max_compact; /* Maximum # of attributes to store compactly */ + unsigned min_dense; /* Minimum # of attributes to store "densely" */ + htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_shared; /* Is attributes shared? */ + hsize_t shared_refcount; /* Reference count of shared attribute */ + unsigned attr_value; /* Attribute value */ + unsigned * big_value; /* Data for "big" attribute */ + size_t mesg_count; /* # of shared messages */ + unsigned test_shared; /* Index over shared component type */ + unsigned u; /* Local index variable */ + h5_stat_size_t empty_filesize; /* Size of empty file */ + h5_stat_size_t filesize; /* Size of file after modifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Unlinking Object with Shared Attributes in Compact & Dense Storage\n")); @@ -9589,7 +9593,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) CHECK(big_sid, FAIL, "H5Screate_simple"); /* Loop over type of shared components */ - for(test_shared = 0; test_shared < 3; test_shared++) { + for (test_shared = 0; test_shared < 3; test_shared++) { /* Make copy of file creation property list */ my_fcpl = H5Pcopy(fcpl); CHECK(my_fcpl, FAIL, "H5Pcopy"); @@ -9599,7 +9603,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) CHECK(attr_tid, FAIL, "H5Tcopy"); /* Special setup for each type of shared components */ - if(test_shared == 0) { + if (test_shared == 0) { /* Make attributes > 500 bytes shared */ ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); @@ -9637,16 +9641,15 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); - if(empty_filesize < 0) + if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); - /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); /* Commit datatype to file */ - if(test_shared == 2) { + if (test_shared == 2) { ret = H5Tcommit2(fid, TYPE1_NAME, attr_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); } /* end if */ @@ -9655,7 +9658,8 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) if (dcpl_g == H5P_DEFAULT) { dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - } else { + } + else { dcpl = H5Pcopy(dcpl_g); CHECK(dcpl, FAIL, "H5Pcopy"); } @@ -9667,7 +9671,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) CHECK(dataset2, FAIL, "H5Dcreate2"); /* Check on dataset's message storage status */ - if(test_shared != 0) { + if (test_shared != 0) { /* Datasets' datatypes can be shared */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -9694,12 +9698,12 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); /* Add attributes to each dataset, until after converting to dense storage */ - for(u = 0; u < max_compact * 2; u++) { + for (u = 0; u < max_compact * 2; u++) { /* Create attribute name */ HDsprintf(attrname, "attr %02u", u); /* Alternate between creating "small" & "big" attributes */ - if(u % 2) { + if (u % 2) { /* Create "small" attribute on first dataset */ attr = H5Acreate2(dataset, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); @@ -9710,7 +9714,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); + ret = H5Awrite(attr, attr_tid, &attr_value); CHECK(ret, FAIL, "H5Awrite"); } /* end if */ else { @@ -9729,7 +9733,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ big_value[0] = u + 1; - ret = H5Awrite(attr, attr_tid, big_value); + ret = H5Awrite(attr, attr_tid, big_value); CHECK(ret, FAIL, "H5Awrite"); /* Check refcount for attribute */ @@ -9744,14 +9748,13 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset); - if(u < max_compact) + if (u < max_compact) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); else VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); - /* Alternate between creating "small" & "big" attributes */ - if(u % 2) { + if (u % 2) { /* Create "small" attribute on second dataset */ attr = H5Acreate2(dataset2, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, FAIL, "H5Acreate2"); @@ -9762,7 +9765,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); + ret = H5Awrite(attr, attr_tid, &attr_value); CHECK(ret, FAIL, "H5Awrite"); } /* end if */ else { @@ -9781,7 +9784,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Write data into the attribute */ big_value[0] = u + 1; - ret = H5Awrite(attr, attr_tid, big_value); + ret = H5Awrite(attr, attr_tid, big_value); CHECK(ret, FAIL, "H5Awrite"); /* Check refcount for attribute */ @@ -9796,13 +9799,12 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Check on dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset2); - if(u < max_compact) + if (u < max_compact) VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); else VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); } /* end for */ - /* Close attribute's datatype */ ret = H5Tclose(attr_tid); CHECK(ret, FAIL, "H5Tclose"); @@ -9815,13 +9817,12 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) ret = H5Ldelete(fid, DSET2_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); - /* Check on first dataset's attribute storage status */ is_dense = H5O__is_attr_dense_test(dataset); VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); /* Check ref count on attributes of first dataset */ - for(u = 0; u < max_compact * 2; u++) { + for (u = 0; u < max_compact * 2; u++) { /* Create attribute name */ HDsprintf(attrname, "attr %02u", u); @@ -9829,7 +9830,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) attr = H5Aopen(dataset, attrname, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); - if(u % 2) { + if (u % 2) { /* Check that attribute is not shared */ is_shared = H5A__is_shared_test(attr); VERIFY(is_shared, FALSE, "H5A__is_shared_test"); @@ -9859,7 +9860,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Ldelete"); /* Unlink committed datatype */ - if(test_shared == 2) { + if (test_shared == 2) { ret = H5Ldelete(fid, TYPE1_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); } /* end if */ @@ -9869,7 +9870,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test"); - if(test_shared != 0) { + if (test_shared != 0) { /* Check on datatype storage status */ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); @@ -9898,7 +9899,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Release memory */ HDfree(big_value); -} /* test_attr_shared_unlink() */ +} /* test_attr_shared_unlink() */ /**************************************************************** ** @@ -9914,11 +9915,11 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) static void test_attr_bug1(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ - hid_t aid; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - herr_t ret; /* Generic return status */ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + herr_t ret; /* Generic return status */ /* Output message about test being performed */ MESSAGE(5, ("Testing Allocating and De-allocating Attributes in Unusual Way\n")); @@ -9940,7 +9941,6 @@ test_attr_bug1(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file and create another group, then attribute on first group */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -9969,7 +9969,6 @@ test_attr_bug1(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file and create another group, then another attribute on first group */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -10002,7 +10001,6 @@ test_attr_bug1(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file and re-create attributes on first group */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); CHECK(fid, FAIL, "H5Fopen"); @@ -10039,11 +10037,10 @@ test_attr_bug1(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Close dataspace ID */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Gclose"); -} /* test_attr_bug1() */ +} /* test_attr_bug1() */ /**************************************************************** ** @@ -10059,17 +10056,17 @@ test_attr_bug1(hid_t fcpl, hid_t fapl) static void test_attr_bug2(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ - hid_t aid; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hid_t gcpl; /* Group creation property list */ - hsize_t dims[2] = {10, 100}; /* Attribute dimensions */ - char aname[16]; /* Attribute name */ - unsigned i; /* index */ - herr_t ret; /* Generic return status */ - htri_t tri_ret; /* htri_t return status */ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hid_t gcpl; /* Group creation property list */ + hsize_t dims[2] = {10, 100}; /* Attribute dimensions */ + char aname[16]; /* Attribute name */ + unsigned i; /* index */ + herr_t ret; /* Generic return status */ + htri_t tri_ret; /* htri_t return status */ /* Output message about test being performed */ MESSAGE(5, ("Testing Allocating and De-allocating Attributes in Unusual Way\n")); @@ -10082,7 +10079,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl) /* Not doing this with the latest format actually triggers a different bug. * This will be tested here as soon as it is fixed. -NAF */ - ret = H5Pset_attr_phase_change (gcpl, BUG2_NATTR+10, BUG2_NATTR+5); + ret = H5Pset_attr_phase_change(gcpl, BUG2_NATTR + 10, BUG2_NATTR + 5); CHECK(ret, FAIL, "H5Pset_attr_phase_change"); /* Create dataspace ID for attributes */ @@ -10097,7 +10094,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl) CHECK(gid, FAIL, "H5Gcreate2"); /* Create attributes on group */ - for (i=0; i 0) { pt = *(++av); @@ -70,28 +70,28 @@ parse(int ac, char** av) } else { switch (*(++pt)) { - case 't': /* option -t */ - switch (*(++pt)) { - case 'M': - major++; - break; - case 'm': - minor++; - break; - case 'r': - release++; + case 't': /* option -t */ + switch (*(++pt)) { + case 'M': + major++; + break; + case 'm': + minor++; + break; + case 'r': + release++; + break; + default: + HDfprintf(stderr, "Unknown -v parameter (%s). Aborted.\n", *av); + HDexit(EXIT_FAILURE); + } break; + case 'h': /* help page */ + showhelp(); + HDexit(EXIT_SUCCESS); default: - HDfprintf(stderr, "Unknown -v parameter (%s). Aborted.\n", *av); + HDfprintf(stderr, "Unknown option(%s). Aborted.\n", *av); HDexit(EXIT_FAILURE); - } - break; - case 'h': /* help page */ - showhelp(); - HDexit(EXIT_SUCCESS); - default: - HDfprintf(stderr, "Unknown option(%s). Aborted.\n", *av); - HDexit(EXIT_FAILURE); } } } @@ -119,14 +119,14 @@ abort_intercept(int H5_ATTR_UNUSED sig) * is no need to alert the user with a modal dialog box. */ int -handle_crt_abort(int reportType, char* message, int* returnValue) +handle_crt_abort(int reportType, char *message, int *returnValue) { return TRUE; } #endif int -main(int ac, char** av) +main(int ac, char **av) { #ifdef H5_HAVE_WIN32_API (void)_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, handle_crt_abort); diff --git a/test/tchecksum.c b/test/tchecksum.c index 6e509fb..79da14e 100644 --- a/test/tchecksum.c +++ b/test/tchecksum.c @@ -30,13 +30,12 @@ /**********/ /* Macros */ /**********/ -#define BUF_LEN 3093 /* No particular value */ +#define BUF_LEN 3093 /* No particular value */ /*******************/ /* Local variables */ /*******************/ - /**************************************************************** ** ** test_chksum_size_one(): Checksum 1 byte buffer @@ -45,8 +44,8 @@ static void test_chksum_size_one(void) { - uint8_t buf[1] = {23}; /* Buffer to checksum */ - uint32_t chksum; /* Checksum value */ + uint8_t buf[1] = {23}; /* Buffer to checksum */ + uint32_t chksum; /* Checksum value */ /* Buffer w/real data */ chksum = H5_checksum_fletcher32(buf, sizeof(buf)); @@ -70,7 +69,6 @@ test_chksum_size_one(void) VERIFY(chksum, 0x8ba9414b, "H5_checksum_lookup3"); } /* test_chksum_size_one() */ - /**************************************************************** ** ** test_chksum_size_two(): Checksum 2 byte buffer @@ -79,8 +77,8 @@ test_chksum_size_one(void) static void test_chksum_size_two(void) { - uint8_t buf[2] = {23, 187}; /* Buffer to checksum */ - uint32_t chksum; /* Checksum value */ + uint8_t buf[2] = {23, 187}; /* Buffer to checksum */ + uint32_t chksum; /* Checksum value */ /* Buffer w/real data */ chksum = H5_checksum_fletcher32(buf, sizeof(buf)); @@ -104,7 +102,6 @@ test_chksum_size_two(void) VERIFY(chksum, 0x62cd61b3, "H5_checksum_lookup3"); } /* test_chksum_size_two() */ - /**************************************************************** ** ** test_chksum_size_three(): Checksum 3 byte buffer @@ -113,8 +110,8 @@ test_chksum_size_two(void) static void test_chksum_size_three(void) { - uint8_t buf[3] = {23, 187, 98}; /* Buffer to checksum */ - uint32_t chksum; /* Checksum value */ + uint8_t buf[3] = {23, 187, 98}; /* Buffer to checksum */ + uint32_t chksum; /* Checksum value */ /* Buffer w/real data */ chksum = H5_checksum_fletcher32(buf, sizeof(buf)); @@ -138,7 +135,6 @@ test_chksum_size_three(void) VERIFY(chksum, 0x6bd0060f, "H5_checksum_lookup3"); } /* test_chksum_size_three() */ - /**************************************************************** ** ** test_chksum_size_four(): Checksum 4 byte buffer @@ -147,8 +143,8 @@ test_chksum_size_three(void) static void test_chksum_size_four(void) { - uint8_t buf[4] = {23, 187, 98, 217};/* Buffer to checksum */ - uint32_t chksum; /* Checksum value */ + uint8_t buf[4] = {23, 187, 98, 217}; /* Buffer to checksum */ + uint32_t chksum; /* Checksum value */ /* Buffer w/real data */ chksum = H5_checksum_fletcher32(buf, sizeof(buf)); @@ -172,7 +168,6 @@ test_chksum_size_four(void) VERIFY(chksum, 0x049396b8, "H5_checksum_lookup3"); } /* test_chksum_size_four() */ - /**************************************************************** ** ** test_chksum_large(): Checksum larger buffer @@ -181,16 +176,16 @@ test_chksum_size_four(void) static void test_chksum_large(void) { - uint8_t *large_buf; /* Buffer for checksum calculations */ - uint32_t chksum; /* Checksum value */ - size_t u; /* Local index variable */ + uint8_t *large_buf; /* Buffer for checksum calculations */ + uint32_t chksum; /* Checksum value */ + size_t u; /* Local index variable */ /* Allocate the buffer */ large_buf = (uint8_t *)HDmalloc((size_t)BUF_LEN); CHECK_PTR(large_buf, "HDmalloc"); /* Initialize buffer w/known data */ - for(u = 0; u < BUF_LEN; u++) + for (u = 0; u < BUF_LEN; u++) large_buf[u] = (uint8_t)(u * 3); /* Buffer w/real data */ @@ -218,7 +213,6 @@ test_chksum_large(void) HDfree(large_buf); } /* test_chksum_large() */ - /**************************************************************** ** ** test_checksum(): Main checksum testing routine. @@ -231,15 +225,14 @@ test_checksum(void) MESSAGE(5, ("Testing checksum algorithms\n")); /* Various checks for fletcher32 checksum algorithm */ - test_chksum_size_one(); /* Test buffer w/only 1 byte */ - test_chksum_size_two(); /* Test buffer w/only 2 bytes */ - test_chksum_size_three(); /* Test buffer w/only 3 bytes */ - test_chksum_size_four(); /* Test buffer w/only 4 bytes */ - test_chksum_large(); /* Test buffer w/larger # of bytes */ + test_chksum_size_one(); /* Test buffer w/only 1 byte */ + test_chksum_size_two(); /* Test buffer w/only 2 bytes */ + test_chksum_size_three(); /* Test buffer w/only 3 bytes */ + test_chksum_size_four(); /* Test buffer w/only 4 bytes */ + test_chksum_large(); /* Test buffer w/larger # of bytes */ } /* test_checksum() */ - /*------------------------------------------------------------------------- * Function: cleanup_checksum * @@ -257,4 +250,3 @@ cleanup_checksum(void) { /* no file to clean */ } - diff --git a/test/tconfig.c b/test/tconfig.c index 1a81d50..196ccce 100644 --- a/test/tconfig.c +++ b/test/tconfig.c @@ -12,12 +12,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tconfig -* -* Test the definitions in the H5config.h as much as possible -* -*************************************************************/ + * + * Test program: tconfig + * + * Test the definitions in the H5config.h as much as possible + * + *************************************************************/ #include "testhdf5.h" @@ -25,28 +25,25 @@ /* verify C int type: verify the size of signed and unsigned int type * with the macro size. */ -#define vrfy_cint_type(ctype, uctype, ctype_macro) \ - /* check signed type size */ \ - vrfy_macrosize(ctype, ctype_macro, #ctype_macro);\ - /* check unsigned type size */ \ +#define vrfy_cint_type(ctype, uctype, ctype_macro) \ + /* check signed type size */ \ + vrfy_macrosize(ctype, ctype_macro, #ctype_macro); \ + /* check unsigned type size */ \ vrfy_macrosize(uctype, ctype_macro, #ctype_macro); /* verify C type sizes: verify the sizeof type with the macro size. */ -#define vrfy_ctype(type, macro) \ - vrfy_macrosize(type, macro, #macro); +#define vrfy_ctype(type, macro) vrfy_macrosize(type, macro, #macro); /* verify if the sizeof(type) matches size defined in macro. */ /* Needs this extra step so that we can print the macro name. */ -#define vrfy_macrosize(type, macro, macroname) \ - if (sizeof(type) != macro) \ - TestErrPrintf("Error: sizeof(%s) is %zu but %s is %d\n", \ - #type, sizeof(type), macroname, (int)macro); +#define vrfy_macrosize(type, macro, macroname) \ + if (sizeof(type) != macro) \ + TestErrPrintf("Error: sizeof(%s) is %zu but %s is %d\n", #type, sizeof(type), macroname, (int)macro); /* local routine prototypes */ void test_config_ctypes(void); void test_exit_definitions(void); - /*------------------------------------------------------------------------- * Function: test_configure * @@ -68,7 +65,6 @@ test_configure(void) test_exit_definitions(); } - /*------------------------------------------------------------------------- * Function: cleanup_configure * @@ -89,7 +85,6 @@ cleanup_configure(void) /* no file to clean */ } - /*------------------------------------------------------------------------- * Function: test_config_ctypes * @@ -118,7 +113,7 @@ test_config_ctypes(void) vrfy_cint_type(long, unsigned long, H5_SIZEOF_LONG); vrfy_ctype(float, H5_SIZEOF_FLOAT); vrfy_ctype(double, H5_SIZEOF_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE >0 +#if H5_SIZEOF_LONG_DOUBLE > 0 vrfy_ctype(long double, H5_SIZEOF_LONG_DOUBLE); #endif @@ -197,10 +192,8 @@ test_config_ctypes(void) #if H5_SIZEOF_SSIZE_T > 0 vrfy_ctype(ssize_t, H5_SIZEOF_SSIZE_T); #endif - } - /*------------------------------------------------------------------------- * Function: test_exit_definitions * @@ -220,10 +213,8 @@ test_exit_definitions(void) { /* Verify the EXIT_SUCCESS and EXIT_FAILURE are 0 and 1 respectively. */ /* This should be true for POSIX compliant systems. */ - if (EXIT_SUCCESS != 0) \ - TestErrPrintf("Error: EXIT_SUCCESS is %d, should be %d\n", \ - EXIT_SUCCESS, 0); - if (EXIT_FAILURE != 1) \ - TestErrPrintf("Error: EXIT_FAILURE is %d, should be %d\n", \ - EXIT_FAILURE, 1); + if (EXIT_SUCCESS != 0) + TestErrPrintf("Error: EXIT_SUCCESS is %d, should be %d\n", EXIT_SUCCESS, 0); + if (EXIT_FAILURE != 1) + TestErrPrintf("Error: EXIT_FAILURE is %d, should be %d\n", EXIT_FAILURE, 1); } diff --git a/test/tcoords.c b/test/tcoords.c index f639d4b..e92bdde 100644 --- a/test/tcoords.c +++ b/test/tcoords.c @@ -12,25 +12,25 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tcoords -* -* Test the element coordinates for dataspace selection. For -* chunked dataset, when the hyperslab selection of some -* dimensions is full, the library optimize it by "flattenning" -* the fully selected dimensions. This program tests if the -* coordinates of selected elements are correctly calculated. -* -*************************************************************/ + * + * Test program: tcoords + * + * Test the element coordinates for dataspace selection. For + * chunked dataset, when the hyperslab selection of some + * dimensions is full, the library optimize it by "flattenning" + * the fully selected dimensions. This program tests if the + * coordinates of selected elements are correctly calculated. + * + *************************************************************/ #include "testhdf5.h" -#define FILENAME "coord.h5" +#define FILENAME "coord.h5" -#define SINGLE_END_DSET "single_end_dset" -#define MULTI_ENDS_SEL_HYPER_DSET "multiple_ends_dset" +#define SINGLE_END_DSET "single_end_dset" +#define MULTI_ENDS_SEL_HYPER_DSET "multiple_ends_dset" -#define NAME_LEN 128 +#define NAME_LEN 128 /* Data written to the dataset for single block test. Global variable * for convenience. */ @@ -42,63 +42,37 @@ int da_buffer[2][3][6][2]; ** one block. ** *************************************************************/ -static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked) +static void +test_singleEnd_selElements(hid_t file, hbool_t is_chunked) { - hid_t sid, plid, did, msid; - char dset_name[NAME_LEN]; /* Dataset name */ - size_t elmts_numb; - herr_t ret; /* Generic error return */ - int i, j, k; - hsize_t da_dims[4] = { 2, 3, 6, 2 }; - hsize_t da_chunksize[4] = { 1, 3, 3, 2 }; + hid_t sid, plid, did, msid; + char dset_name[NAME_LEN]; /* Dataset name */ + size_t elmts_numb; + herr_t ret; /* Generic error return */ + int i, j, k; + hsize_t da_dims[4] = {2, 3, 6, 2}; + hsize_t da_chunksize[4] = {1, 3, 3, 2}; /* For testing the full selection in the fastest-growing end */ - int mem1_buffer[1][1][6][2]; - hsize_t mem1_dims[4] = { 1, 1, 6, 2 }; - hsize_t da_elmts1[12][4] = { {0, 0, 0, 0}, - {0, 0, 0, 1}, - {0, 0, 1, 0}, - {0, 0, 1, 1}, - {0, 0, 2, 0}, - {0, 0, 2, 1}, - {0, 0, 3, 0}, - {0, 0, 3, 1}, - {0, 0, 4, 0}, - {0, 0, 4, 1}, - {0, 0, 5, 0}, - {0, 0, 5, 1} }; + int mem1_buffer[1][1][6][2]; + hsize_t mem1_dims[4] = {1, 1, 6, 2}; + hsize_t da_elmts1[12][4] = {{0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 0, 1, 1}, + {0, 0, 2, 0}, {0, 0, 2, 1}, {0, 0, 3, 0}, {0, 0, 3, 1}, + {0, 0, 4, 0}, {0, 0, 4, 1}, {0, 0, 5, 0}, {0, 0, 5, 1}}; /* For testing the full selection in the slowest-growing end */ - int mem2_buffer[2][3][1][1]; - hsize_t mem2_dims[4] = { 2, 3, 1, 1 }; - hsize_t da_elmts2[6][4] = { {0, 0, 0, 0}, - {0, 1, 0, 0}, - {0, 2, 0, 0}, - {1, 0, 0, 0}, - {1, 1, 0, 0}, - {1, 2, 0, 0} }; + int mem2_buffer[2][3][1][1]; + hsize_t mem2_dims[4] = {2, 3, 1, 1}; + hsize_t da_elmts2[6][4] = {{0, 0, 0, 0}, {0, 1, 0, 0}, {0, 2, 0, 0}, + {1, 0, 0, 0}, {1, 1, 0, 0}, {1, 2, 0, 0}}; /* For testing the full selection in the middle dimensions */ - int mem3_buffer[1][3][6][1]; - hsize_t mem3_dims[4] = { 1, 3, 6, 1 }; - hsize_t da_elmts3[18][4] = { {0, 0, 0, 0}, - {0, 0, 1, 0}, - {0, 0, 2, 0}, - {0, 0, 3, 0}, - {0, 0, 4, 0}, - {0, 0, 5, 0}, - {0, 1, 0, 0}, - {0, 1, 1, 0}, - {0, 1, 2, 0}, - {0, 1, 3, 0}, - {0, 1, 4, 0}, - {0, 1, 5, 0}, - {0, 2, 0, 0}, - {0, 2, 1, 0}, - {0, 2, 2, 0}, - {0, 2, 3, 0}, - {0, 2, 4, 0}, - {0, 2, 5, 0} }; + int mem3_buffer[1][3][6][1]; + hsize_t mem3_dims[4] = {1, 3, 6, 1}; + hsize_t da_elmts3[18][4] = {{0, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 2, 0}, {0, 0, 3, 0}, {0, 0, 4, 0}, + {0, 0, 5, 0}, {0, 1, 0, 0}, {0, 1, 1, 0}, {0, 1, 2, 0}, {0, 1, 3, 0}, + {0, 1, 4, 0}, {0, 1, 5, 0}, {0, 2, 0, 0}, {0, 2, 1, 0}, {0, 2, 2, 0}, + {0, 2, 3, 0}, {0, 2, 4, 0}, {0, 2, 5, 0}}; /* Create and write the dataset */ sid = H5Screate_simple(4, da_dims, da_dims); @@ -107,7 +81,7 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked) plid = H5Pcreate(H5P_DATASET_CREATE); CHECK(plid, FAIL, "H5Pcreate"); - if(is_chunked) { + if (is_chunked) { ret = H5Pset_chunk(plid, 4, da_chunksize); CHECK(ret, FAIL, "H5Pset_chunk"); } @@ -115,18 +89,18 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked) /* Construct dataset's name */ memset(dset_name, 0, (size_t)NAME_LEN); strcat(dset_name, SINGLE_END_DSET); - if(is_chunked) + if (is_chunked) strcat(dset_name, "_chunked"); did = H5Dcreate2(file, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, plid, H5P_DEFAULT); CHECK(did, FAIL, "H5Dcreate2"); /* Initialize the data to be written to file */ - for(i=0; i<2; i++) { - for(j=0; j<3; j++) { - for(k=0; k<6; k++) { - da_buffer[i][j][k][0] = i*100 + j*10 + k; - da_buffer[i][j][k][1] = i*100 + j*10 + k + 1; + for (i = 0; i < 2; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 6; k++) { + da_buffer[i][j][k][0] = i * 100 + j * 10 + k; + da_buffer[i][j][k][1] = i * 100 + j * 10 + k + 1; } } } @@ -137,7 +111,6 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked) ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); - /* ****** Case 1: ****** * Testing the full selection in the fastest-growing end */ did = H5Dopen2(file, dset_name, H5P_DEFAULT); @@ -165,9 +138,9 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<6; i++) - for(j=0; j<2; j++) - if(da_buffer[0][0][i][j] != mem1_buffer[0][0][i][j]) { + for (i = 0; i < 6; i++) + for (j = 0; j < 2; j++) + if (da_buffer[0][0][i][j] != mem1_buffer[0][0][i][j]) { TestErrPrintf("%u: Read different values than written at index 0,0,%d,%d\n", __LINE__, i, j); } @@ -198,10 +171,12 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<2; i++) - for(j=0; j<3; j++) - if(da_buffer[i][j][0][0] != mem2_buffer[i][j][0][0]) { - TestErrPrintf("%u: Read different values than written at index %d,%d,0,0, da_buffer = %d, mem2_buffer = %d\n", __LINE__, i, j, da_buffer[i][j][0][0], mem2_buffer[i][j][0][0]); + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) + if (da_buffer[i][j][0][0] != mem2_buffer[i][j][0][0]) { + TestErrPrintf("%u: Read different values than written at index %d,%d,0,0, da_buffer = %d, " + "mem2_buffer = %d\n", + __LINE__, i, j, da_buffer[i][j][0][0], mem2_buffer[i][j][0][0]); } /* ****** Case 3: ****** @@ -231,13 +206,12 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<3; i++) - for(j=0; j<6; j++) - if(da_buffer[0][i][j][0] != mem3_buffer[0][i][j][0]) { + for (i = 0; i < 3; i++) + for (j = 0; j < 6; j++) + if (da_buffer[0][i][j][0] != mem3_buffer[0][i][j][0]) { TestErrPrintf("%u: Read different values than written at index 0,%d,%d,0\n", __LINE__, i, j); } - ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); @@ -251,42 +225,43 @@ static void test_singleEnd_selElements(hid_t file, hbool_t is_chunked) ** of only one block. ** *************************************************************/ -static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked) +static void +test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked) { - hid_t sid, did, msid; - char dset_name[NAME_LEN]; /* Dataset name */ - herr_t ret; /* Generic error return */ - int i, j; - hsize_t da_dims[4] = { 2, 3, 6, 2 }; + hid_t sid, did, msid; + char dset_name[NAME_LEN]; /* Dataset name */ + herr_t ret; /* Generic error return */ + int i, j; + hsize_t da_dims[4] = {2, 3, 6, 2}; /* For testing the full selection in the fastest-growing end */ - int mem1_buffer[1][1][6][2]; - hsize_t mem1_dims[4] = { 1, 1, 6, 2 }; - hsize_t mem1_start[4] = { 0, 0, 0, 0 }; - hsize_t mem1_count[4] = { 1, 1, 1, 1 }; - hsize_t mem1_stride[4] = { 1, 1, 1, 1 }; - hsize_t mem1_block[4] = { 1, 1, 6, 2 }; + int mem1_buffer[1][1][6][2]; + hsize_t mem1_dims[4] = {1, 1, 6, 2}; + hsize_t mem1_start[4] = {0, 0, 0, 0}; + hsize_t mem1_count[4] = {1, 1, 1, 1}; + hsize_t mem1_stride[4] = {1, 1, 1, 1}; + hsize_t mem1_block[4] = {1, 1, 6, 2}; /* For testing the full selection in the slowest-growing end */ - int mem2_buffer[2][3][1][1]; - hsize_t mem2_dims[4] = { 2, 3, 1, 1 }; - hsize_t mem2_start[4] = { 0, 0, 0, 0 }; - hsize_t mem2_count[4] = { 1, 1, 1, 1 }; - hsize_t mem2_stride[4] = { 1, 1, 1, 1 }; - hsize_t mem2_block[4] = { 2, 3, 1, 1 }; + int mem2_buffer[2][3][1][1]; + hsize_t mem2_dims[4] = {2, 3, 1, 1}; + hsize_t mem2_start[4] = {0, 0, 0, 0}; + hsize_t mem2_count[4] = {1, 1, 1, 1}; + hsize_t mem2_stride[4] = {1, 1, 1, 1}; + hsize_t mem2_block[4] = {2, 3, 1, 1}; /* For testing the full selection in the middle dimensions */ - int mem3_buffer[1][3][6][1]; - hsize_t mem3_dims[4] = { 1, 3, 6, 1 }; - hsize_t mem3_start[4] = { 0, 0, 0, 0 }; - hsize_t mem3_count[4] = { 1, 1, 1, 1 }; - hsize_t mem3_stride[4] = { 1, 1, 1, 1 }; - hsize_t mem3_block[4] = { 1, 3, 6, 1 }; + int mem3_buffer[1][3][6][1]; + hsize_t mem3_dims[4] = {1, 3, 6, 1}; + hsize_t mem3_start[4] = {0, 0, 0, 0}; + hsize_t mem3_count[4] = {1, 1, 1, 1}; + hsize_t mem3_stride[4] = {1, 1, 1, 1}; + hsize_t mem3_block[4] = {1, 3, 6, 1}; /* Construct dataset's name */ memset(dset_name, 0, NAME_LEN); strcat(dset_name, SINGLE_END_DSET); - if(is_chunked) + if (is_chunked) strcat(dset_name, "_chunked"); /* Dataspace for the dataset in file */ @@ -318,9 +293,9 @@ static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<6; i++) - for(j=0; j<2; j++) - if(da_buffer[0][0][i][j] != mem1_buffer[0][0][i][j]) { + for (i = 0; i < 6; i++) + for (j = 0; j < 2; j++) + if (da_buffer[0][0][i][j] != mem1_buffer[0][0][i][j]) { TestErrPrintf("%u: Read different values than written at index 0,0,%d,%d\n", __LINE__, i, j); } @@ -349,9 +324,9 @@ static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<2; i++) - for(j=0; j<3; j++) - if(da_buffer[i][j][0][0] != mem2_buffer[i][j][0][0]) { + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) + if (da_buffer[i][j][0][0] != mem2_buffer[i][j][0][0]) { TestErrPrintf("%u: Read different values than written at index %d,%d,0,0\n", __LINE__, i, j); } @@ -380,75 +355,73 @@ static void test_singleEnd_selHyperslab(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<3; i++) - for(j=0; j<6; j++) - if(da_buffer[0][i][j][0] != mem3_buffer[0][i][j][0]) { + for (i = 0; i < 3; i++) + for (j = 0; j < 6; j++) + if (da_buffer[0][i][j][0] != mem3_buffer[0][i][j][0]) { TestErrPrintf("%u: Read different values than written at index 0,%d,%d,0\n", __LINE__, i, j); } - ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); } - - /*********************************************************** ** ** test_multiple_end(): Test full hyperslab selection of ** multiple blocks. ** *************************************************************/ -static void test_multiple_ends(hid_t file, hbool_t is_chunked) +static void +test_multiple_ends(hid_t file, hbool_t is_chunked) { - hid_t sid, plid, did, msid; - char dset_name[NAME_LEN]; /* Dataset name */ - herr_t ret; /* Generic error return */ - int i, j, k, l, m, n, p; - hsize_t da_dims[8] = { 4, 5, 3, 4, 2, 3, 6, 2 }; - hsize_t da_chunksize[8] = { 1, 5, 3, 2, 2, 3, 3, 2 }; - int data_buf[4][5][3][4][2][3][6][2]; + hid_t sid, plid, did, msid; + char dset_name[NAME_LEN]; /* Dataset name */ + herr_t ret; /* Generic error return */ + int i, j, k, l, m, n, p; + hsize_t da_dims[8] = {4, 5, 3, 4, 2, 3, 6, 2}; + hsize_t da_chunksize[8] = {1, 5, 3, 2, 2, 3, 3, 2}; + int data_buf[4][5][3][4][2][3][6][2]; /* For testing the full selections in the fastest-growing end and in the middle dimensions */ - int mem1_buffer[1][1][1][4][2][1][6][2]; - hsize_t mem1_dims[8] = { 1, 1, 1, 4, 2, 1, 6, 2 }; - hsize_t mem1_start[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - hsize_t mem1_count[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem1_stride[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem1_block[8] = { 1, 1, 1, 4, 2, 1, 6, 2 }; + int mem1_buffer[1][1][1][4][2][1][6][2]; + hsize_t mem1_dims[8] = {1, 1, 1, 4, 2, 1, 6, 2}; + hsize_t mem1_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + hsize_t mem1_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem1_stride[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem1_block[8] = {1, 1, 1, 4, 2, 1, 6, 2}; /* For testing the full selections in the slowest-growing end and in the middle dimensions */ - int mem2_buffer[4][5][1][4][2][1][1][1]; - hsize_t mem2_dims[8] = { 4, 5, 1, 4, 2, 1, 1, 1 }; - hsize_t mem2_start[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - hsize_t mem2_count[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem2_stride[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem2_block[8] = { 4, 5, 1, 4, 2, 1, 1, 1 }; + int mem2_buffer[4][5][1][4][2][1][1][1]; + hsize_t mem2_dims[8] = {4, 5, 1, 4, 2, 1, 1, 1}; + hsize_t mem2_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + hsize_t mem2_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem2_stride[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem2_block[8] = {4, 5, 1, 4, 2, 1, 1, 1}; /* For testing two unadjacent full selections in the middle dimensions */ - int mem3_buffer[1][5][3][1][1][3][6][1]; - hsize_t mem3_dims[8] = { 1, 5, 3, 1, 1, 3, 6, 1 }; - hsize_t mem3_start[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - hsize_t mem3_count[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem3_stride[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem3_block[8] = { 1, 5, 3, 1, 1, 3, 6, 1 }; + int mem3_buffer[1][5][3][1][1][3][6][1]; + hsize_t mem3_dims[8] = {1, 5, 3, 1, 1, 3, 6, 1}; + hsize_t mem3_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + hsize_t mem3_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem3_stride[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem3_block[8] = {1, 5, 3, 1, 1, 3, 6, 1}; /* For testing the full selections in the fastest-growing end and the slowest-growing end */ - int mem4_buffer[4][5][1][1][1][1][6][2]; - hsize_t mem4_dims[8] = { 4, 5, 1, 1, 1, 1, 6, 2 }; - hsize_t mem4_start[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - hsize_t mem4_count[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem4_stride[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem4_block[8] = { 4, 5, 1, 1, 1, 1, 6, 2 }; + int mem4_buffer[4][5][1][1][1][1][6][2]; + hsize_t mem4_dims[8] = {4, 5, 1, 1, 1, 1, 6, 2}; + hsize_t mem4_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + hsize_t mem4_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem4_stride[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem4_block[8] = {4, 5, 1, 1, 1, 1, 6, 2}; /* For testing the full selections in the fastest-growing end and slowest-growing end, * also in the middle dimensions */ - int mem5_buffer[4][5][1][4][2][1][6][2]; - hsize_t mem5_dims[8] = { 4, 5, 1, 4, 2, 1, 6, 2 }; - hsize_t mem5_start[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - hsize_t mem5_count[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem5_stride[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - hsize_t mem5_block[8] = { 4, 5, 1, 4, 2, 1, 6, 2 }; + int mem5_buffer[4][5][1][4][2][1][6][2]; + hsize_t mem5_dims[8] = {4, 5, 1, 4, 2, 1, 6, 2}; + hsize_t mem5_start[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + hsize_t mem5_count[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem5_stride[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + hsize_t mem5_block[8] = {4, 5, 1, 4, 2, 1, 6, 2}; /* Create and write the dataset */ sid = H5Screate_simple(8, da_dims, da_dims); @@ -457,7 +430,7 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) plid = H5Pcreate(H5P_DATASET_CREATE); CHECK(plid, FAIL, "H5Pcreate"); - if(is_chunked) { + if (is_chunked) { ret = H5Pset_chunk(plid, 8, da_chunksize); CHECK(ret, FAIL, "H5Pset_chunk"); } @@ -465,21 +438,23 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) /* Construct dataset's name */ memset(dset_name, 0, NAME_LEN); strcat(dset_name, MULTI_ENDS_SEL_HYPER_DSET); - if(is_chunked) + if (is_chunked) strcat(dset_name, "_chunked"); did = H5Dcreate2(file, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, plid, H5P_DEFAULT); CHECK(did, FAIL, "H5Dcreate2"); - for(i=0; i<4; i++) - for(j=0; j<5; j++) - for(k=0; k<3; k++) - for(l=0; l<4; l++) - for(m=0; m<2; m++) - for(n=0; n<3; n++) - for(p=0; p<6; p++) { - data_buf[i][j][k][l][m][n][p][0] = i*1000000 + j*100000 + k*10000 + l*1000 + m*100 + n*10 + p; - data_buf[i][j][k][l][m][n][p][1] = i*1000000 + j*100000 + k*10000 + l*1000 + m*100 + n*10 + p + 1; + for (i = 0; i < 4; i++) + for (j = 0; j < 5; j++) + for (k = 0; k < 3; k++) + for (l = 0; l < 4; l++) + for (m = 0; m < 2; m++) + for (n = 0; n < 3; n++) + for (p = 0; p < 6; p++) { + data_buf[i][j][k][l][m][n][p][0] = + i * 1000000 + j * 100000 + k * 10000 + l * 1000 + m * 100 + n * 10 + p; + data_buf[i][j][k][l][m][n][p][1] = i * 1000000 + j * 100000 + k * 10000 + + l * 1000 + m * 100 + n * 10 + p + 1; } ret = H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data_buf); @@ -512,12 +487,13 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<4; i++) - for(j=0; j<2; j++) - for(k=0; k<6; k++) - for(l=0; l<2; l++) - if(data_buf[0][0][0][i][j][0][k][l] != mem1_buffer[0][0][0][i][j][0][k][l]) { - TestErrPrintf("%u: Read different values than written at index 0,0,0,%d,%d,0,%d,%d\n", __LINE__, i, j, k, l); + for (i = 0; i < 4; i++) + for (j = 0; j < 2; j++) + for (k = 0; k < 6; k++) + for (l = 0; l < 2; l++) + if (data_buf[0][0][0][i][j][0][k][l] != mem1_buffer[0][0][0][i][j][0][k][l]) { + TestErrPrintf("%u: Read different values than written at index 0,0,0,%d,%d,0,%d,%d\n", + __LINE__, i, j, k, l); } /* ****** Case 2: ****** @@ -544,12 +520,13 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<4; i++) - for(j=0; j<5; j++) - for(k=0; k<4; k++) - for(l=0; l<2; l++) - if(data_buf[i][j][0][k][l][0][0][0] != mem2_buffer[i][j][0][k][l][0][0][0]) { - TestErrPrintf("%u: Read different values than written at index %d,%d,0,%d,%d,0,0,0\n", __LINE__, i, j, k, l); + for (i = 0; i < 4; i++) + for (j = 0; j < 5; j++) + for (k = 0; k < 4; k++) + for (l = 0; l < 2; l++) + if (data_buf[i][j][0][k][l][0][0][0] != mem2_buffer[i][j][0][k][l][0][0][0]) { + TestErrPrintf("%u: Read different values than written at index %d,%d,0,%d,%d,0,0,0\n", + __LINE__, i, j, k, l); } /* ****** Case 3: ****** @@ -576,12 +553,13 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<5; i++) - for(j=0; j<3; j++) - for(k=0; k<3; k++) - for(l=0; l<6; l++) - if(data_buf[0][i][j][0][0][k][l][0] != mem3_buffer[0][i][j][0][0][k][l][0]) { - TestErrPrintf("%u: Read different values than written at index 0,%d,%d,0,0,%d,%d,0\n", __LINE__, i, j, k, l); + for (i = 0; i < 5; i++) + for (j = 0; j < 3; j++) + for (k = 0; k < 3; k++) + for (l = 0; l < 6; l++) + if (data_buf[0][i][j][0][0][k][l][0] != mem3_buffer[0][i][j][0][0][k][l][0]) { + TestErrPrintf("%u: Read different values than written at index 0,%d,%d,0,0,%d,%d,0\n", + __LINE__, i, j, k, l); } /* ****** Case 4: ****** @@ -608,15 +586,15 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<4; i++) - for(j=0; j<5; j++) - for(k=0; k<6; k++) - for(l=0; l<2; l++) - if(data_buf[i][j][0][0][0][0][k][l] != mem4_buffer[i][j][0][0][0][0][k][l]) { - TestErrPrintf("%u: Read different values than written at index %d,%d,0,0,0,0,%d,%d\n", __LINE__, i, j, k, l); + for (i = 0; i < 4; i++) + for (j = 0; j < 5; j++) + for (k = 0; k < 6; k++) + for (l = 0; l < 2; l++) + if (data_buf[i][j][0][0][0][0][k][l] != mem4_buffer[i][j][0][0][0][0][k][l]) { + TestErrPrintf("%u: Read different values than written at index %d,%d,0,0,0,0,%d,%d\n", + __LINE__, i, j, k, l); } - /* ****** Case 5: ****** * Testing the full selections in the fastest-growing end and the slowest-growing end, * and also in the middle dimensions */ @@ -642,17 +620,18 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); - for(i=0; i<4; i++) - for(j=0; j<5; j++) - for(k=0; k<4; k++) - for(l=0; l<2; l++) - for(m=0; m<6; m++) - for(n=0; n<2; n++) - if(data_buf[i][j][0][k][l][0][m][n] != mem5_buffer[i][j][0][k][l][0][m][n]) { - TestErrPrintf("%u: Read different values than written at index %d,%d,0,%d,%d,0,%d,%d\n", __LINE__, i, j, k, l, m, n); + for (i = 0; i < 4; i++) + for (j = 0; j < 5; j++) + for (k = 0; k < 4; k++) + for (l = 0; l < 2; l++) + for (m = 0; m < 6; m++) + for (n = 0; n < 2; n++) + if (data_buf[i][j][0][k][l][0][m][n] != mem5_buffer[i][j][0][k][l][0][m][n]) { + TestErrPrintf( + "%u: Read different values than written at index %d,%d,0,%d,%d,0,%d,%d\n", + __LINE__, i, j, k, l, m, n); } - ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); @@ -660,18 +639,18 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) CHECK(ret, FAIL, "H5Pclose"); } - /**************************************************************** ** ** test_coords(): Main testing routine. ** ****************************************************************/ -void test_coords(void) +void +test_coords(void) { hid_t fid; hbool_t is_chunk[2] = {TRUE, FALSE}; int i; - herr_t ret; /* Generic error return */ + herr_t ret; /* Generic error return */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); @@ -691,7 +670,6 @@ void test_coords(void) CHECK(ret, FAIL, "H5Fclose"); } - /*------------------------------------------------------------------------- * Function: cleanup_coords * diff --git a/test/testframe.c b/test/testframe.c index 3c2a335..dbc174a 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -24,38 +24,36 @@ /* * Definitions for the testing structure. */ -#define MAXTESTNAME 16 -#define MAXTESTDESC 64 +#define MAXTESTNAME 16 +#define MAXTESTDESC 64 typedef struct TestStruct { - int NumErrors; - char Description[MAXTESTDESC]; - int SkipFlag; - char Name[MAXTESTNAME]; + int NumErrors; + char Description[MAXTESTDESC]; + int SkipFlag; + char Name[MAXTESTNAME]; void (*Call)(void); void (*Cleanup)(void); const void *Parameters; } TestStruct; - /* * Variables used by testing framework. */ -static int enable_error_stack = 0; /* enable error stack; disable=0 enable=1 */ -static int num_errs = 0; /* Total number of errors during testing */ -int TestVerbosity = VERBO_DEF; /* Default Verbosity is Low */ -static int Summary = 0; /* Show test summary. Default is no. */ -static int CleanUp = 1; /* Do cleanup or not. Default is yes. */ -static int TestExpress = -1; /* Do TestExpress or not. -1 means not set yet. */ -static TestStruct *Test = NULL; /* Array of tests */ -static unsigned TestAlloc = 0; /* Size of the Test array */ -static unsigned Index = 0; -static const void *Test_parameters = NULL; -static const char *TestProgName = NULL; -static void (*TestPrivateUsage)(void) = NULL; +static int enable_error_stack = 0; /* enable error stack; disable=0 enable=1 */ +static int num_errs = 0; /* Total number of errors during testing */ +int TestVerbosity = VERBO_DEF; /* Default Verbosity is Low */ +static int Summary = 0; /* Show test summary. Default is no. */ +static int CleanUp = 1; /* Do cleanup or not. Default is yes. */ +static int TestExpress = -1; /* Do TestExpress or not. -1 means not set yet. */ +static TestStruct *Test = NULL; /* Array of tests */ +static unsigned TestAlloc = 0; /* Size of the Test array */ +static unsigned Index = 0; +static const void *Test_parameters = NULL; +static const char *TestProgName = NULL; +static void (*TestPrivateUsage)(void) = NULL; static int (*TestPrivateParser)(int ac, char *av[]) = NULL; - /* * Setup a test function and add it to the list of tests. * It must have no parameters and returns void. @@ -70,7 +68,8 @@ static int (*TestPrivateParser)(int ac, char *av[]) = NULL; * exit EXIT_FAILURE if error is encountered. */ void -AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr, const void *Parameters) +AddTest(const char *TheName, void (*TheCall)(void), void (*Cleanup)(void), const char *TheDescr, + const void *Parameters) { /* Sanity checking */ if (HDstrlen(TheDescr) >= MAXTESTDESC) { @@ -83,41 +82,41 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con } /* end if */ /* Check for increasing the Test array size */ - if(Index >= TestAlloc) { - TestStruct *newTest = Test; /* New array of tests */ - unsigned newAlloc = MAX(1, TestAlloc * 2); /* New array size */ + if (Index >= TestAlloc) { + TestStruct *newTest = Test; /* New array of tests */ + unsigned newAlloc = MAX(1, TestAlloc * 2); /* New array size */ /* Reallocate array */ - if(NULL == (newTest = (TestStruct *)HDrealloc(Test, newAlloc * sizeof(TestStruct)))) { - HDprintf("Out of memory for tests, Index = %u, TestAlloc = %u, newAlloc = %u\n", Index, TestAlloc, newAlloc); + if (NULL == (newTest = (TestStruct *)HDrealloc(Test, newAlloc * sizeof(TestStruct)))) { + HDprintf("Out of memory for tests, Index = %u, TestAlloc = %u, newAlloc = %u\n", Index, TestAlloc, + newAlloc); HDexit(EXIT_FAILURE); } /* end if */ /* Update info */ - Test = newTest; + Test = newTest; TestAlloc = newAlloc; } /* end if */ /* Set up test function */ HDstrcpy(Test[Index].Description, TheDescr); - if(*TheName != '-') { + if (*TheName != '-') { HDstrcpy(Test[Index].Name, TheName); Test[Index].SkipFlag = 0; } - else { /* skip test by default */ - HDstrcpy(Test[Index].Name, TheName+1); + else { /* skip test by default */ + HDstrcpy(Test[Index].Name, TheName + 1); Test[Index].SkipFlag = 1; } - Test[Index].Call = TheCall; - Test[Index].Cleanup = Cleanup; - Test[Index].NumErrors = -1; + Test[Index].Call = TheCall; + Test[Index].Cleanup = Cleanup; + Test[Index].NumErrors = -1; Test[Index].Parameters = Parameters; /* Increment test count */ Index++; } - /* * Initialize testing framework * @@ -132,7 +131,8 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con * Albert Cheng 2004/08/17 * Added the ProgName, private_usage and private_parser arguments. */ -void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[])) +void +TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[])) { /* * Turn off automatic error reporting since we do it ourselves. Besides, @@ -146,13 +146,12 @@ void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_p * Record the program name and private routines if provided. */ TestProgName = ProgName; - if(NULL != private_usage) + if (NULL != private_usage) TestPrivateUsage = private_usage; - if(NULL != private_parser) + if (NULL != private_parser) TestPrivateParser = private_parser; } - /* * Print test usage. * First print the common test options, then the extra options if provided. @@ -160,12 +159,13 @@ void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_p * Modification: * 2004/08/18 Albert Cheng. Add TestPrivateUsage feature. */ -void TestUsage(void) +void +TestUsage(void) { unsigned i; - print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n", - TestProgName, (TestPrivateUsage ? "" : "")); + print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n", TestProgName, + (TestPrivateUsage ? "" : "")); print_func(" [-[e]x[clude] name]+ \n"); print_func(" [-o[nly] name]+ \n"); print_func(" [-b[egin] name] \n"); @@ -180,7 +180,7 @@ void TestUsage(void) print_func("summary prints a summary of test results at the end\n"); print_func("cleanoff does not delete *.hdf files after execution of tests\n"); print_func("help print out this information\n"); - if (TestPrivateUsage){ + if (TestPrivateUsage) { print_func("\nExtra options\n"); TestPrivateUsage(); } @@ -195,21 +195,20 @@ void TestUsage(void) print_func("\n\n"); } - /* * Print test info. */ -void TestInfo(const char *ProgName) +void +TestInfo(const char *ProgName) { unsigned major, minor, release; H5get_libversion(&major, &minor, &release); - print_func("\nFor help use: %s -help\n",ProgName); + print_func("\nFor help use: %s -help\n", ProgName); print_func("Linked with hdf5 version %u.%u release %u\n", major, minor, release); } - /* * Parse command line information. * argc, argv: the usual command line argument count and strings @@ -220,60 +219,62 @@ void TestInfo(const char *ProgName) * Modification: * 2004/08/18 Albert Cheng. Add extra_parse feature. */ -void TestParseCmdLine(int argc, char *argv[]) +void +TestParseCmdLine(int argc, char *argv[]) { hbool_t skipped_all = FALSE; - int ret_code; + int ret_code; - while (argv++, --argc > 0){ + while (argv++, --argc > 0) { if ((HDstrcmp(*argv, "-verbose") == 0) || (HDstrcmp(*argv, "-v") == 0)) { - if (argc > 0){ - --argc; ++argv; + if (argc > 0) { + --argc; + ++argv; ParseTestVerbosity(*argv); } - else{ + else { TestUsage(); HDexit(EXIT_FAILURE); } } - else if (((HDstrcmp(*argv, "-exclude") == 0) || - (HDstrcmp(*argv, "-x") == 0))) { - if (argc > 0){ - --argc; ++argv; + else if (((HDstrcmp(*argv, "-exclude") == 0) || (HDstrcmp(*argv, "-x") == 0))) { + if (argc > 0) { + --argc; + ++argv; SetTest(*argv, SKIPTEST); } - else{ + else { TestUsage(); HDexit(EXIT_FAILURE); } } - else if (((HDstrcmp(*argv, "-begin") == 0) || - (HDstrcmp(*argv, "-b") == 0))) { - if (argc > 0){ - --argc; ++argv; + else if (((HDstrcmp(*argv, "-begin") == 0) || (HDstrcmp(*argv, "-b") == 0))) { + if (argc > 0) { + --argc; + ++argv; SetTest(*argv, BEGINTEST); } - else{ + else { TestUsage(); HDexit(EXIT_FAILURE); } } - else if (((HDstrcmp(*argv, "-only") == 0) || - (HDstrcmp(*argv, "-o") == 0))) { - if(argc > 0) { + else if (((HDstrcmp(*argv, "-only") == 0) || (HDstrcmp(*argv, "-o") == 0))) { + if (argc > 0) { unsigned Loop; - --argc; ++argv; + --argc; + ++argv; /* Skip all tests, then activate only one. */ - if(!skipped_all) { - for(Loop = 0; Loop < Index; Loop++) + if (!skipped_all) { + for (Loop = 0; Loop < Index; Loop++) Test[Loop].SkipFlag = 1; skipped_all = TRUE; } /* end if */ SetTest(*argv, ONLYTEST); } - else{ + else { TestUsage(); HDexit(EXIT_FAILURE); } @@ -292,33 +293,33 @@ void TestParseCmdLine(int argc, char *argv[]) /* non-standard option. Break out. */ break; } - } /* Call extra parsing function if provided. */ - if (NULL != TestPrivateParser){ - ret_code=TestPrivateParser(argc+1, argv-1); + if (NULL != TestPrivateParser) { + ret_code = TestPrivateParser(argc + 1, argv - 1); if (ret_code != 0) HDexit(EXIT_FAILURE); } } - /* * Perform Tests. */ -void PerformTests(void) +void +PerformTests(void) { - unsigned Loop; + unsigned Loop; for (Loop = 0; Loop < Index; Loop++) if (Test[Loop].SkipFlag) { MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name)); - } else { + } + else { MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name)); MESSAGE(5, ("===============================================\n")); Test[Loop].NumErrors = num_errs; - Test_parameters = Test[Loop].Parameters; + Test_parameters = Test[Loop].Parameters; ALARM_ON; Test[Loop].Call(); ALARM_OFF; @@ -327,22 +328,22 @@ void PerformTests(void) MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors)); } - Test_parameters = NULL; /* clear it. */ + Test_parameters = NULL; /* clear it. */ MESSAGE(2, ("\n\n")) if (num_errs) - print_func("!!! %d Error(s) were detected !!!\n\n", (int) num_errs); + print_func("!!! %d Error(s) were detected !!!\n\n", (int)num_errs); else print_func("All tests were successful. \n\n"); } - /* * Display test summary. */ -void TestSummary(void) +void +TestSummary(void) { - unsigned Loop; + unsigned Loop; print_func("Summary of Test Results:\n"); print_func("Name of Test Errors Description of Test\n"); @@ -358,52 +359,53 @@ void TestSummary(void) print_func("\n\n"); } - /* * Cleanup files from testing */ -void TestCleanup(void) +void +TestCleanup(void) { - unsigned Loop; + unsigned Loop; MESSAGE(2, ("\nCleaning Up temp files...\n\n")); /* call individual cleanup routines in each source module */ for (Loop = 0; Loop < Index; Loop++) - if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL) + if (!Test[Loop].SkipFlag && Test[Loop].Cleanup != NULL) Test[Loop].Cleanup(); } - /* * Shutdown the test infrastructure */ -void TestShutdown(void) +void +TestShutdown(void) { - if(Test) + if (Test) HDfree(Test); } - /* * Retrieve the verbosity level for the testing framework */ -H5_ATTR_PURE int GetTestVerbosity(void) +H5_ATTR_PURE int +GetTestVerbosity(void) { - return(TestVerbosity); + return (TestVerbosity); } /* * Set the verbosity level for the testing framework. * Return previous verbosity level. */ -int SetTestVerbosity(int newval) +int +SetTestVerbosity(int newval) { int oldval; - oldval = TestVerbosity; + oldval = TestVerbosity; TestVerbosity = newval; - return(oldval); + return (oldval); } /* @@ -433,28 +435,28 @@ int SetTestVerbosity(int newval) I think this can be easily implemented in the test library (libh5test.a) so that all tests can just call it to check the status of $HDF5TestExpress. */ -int GetTestExpress(void) +int +GetTestExpress(void) { - char * env_val; + char *env_val; /* set it here for now. Should be done in something like h5test_init(). */ - if(TestExpress==-1) - { + if (TestExpress == -1) { env_val = getenv("HDF5TestExpress"); - if(env_val == NULL) + if (env_val == NULL) SetTestExpress(1); - else if(strcmp(env_val, "0") == 0) + else if (strcmp(env_val, "0") == 0) SetTestExpress(0); - else if(strcmp(env_val, "1") == 0) + else if (strcmp(env_val, "1") == 0) SetTestExpress(1); - else if(strcmp(env_val, "2") == 0) + else if (strcmp(env_val, "2") == 0) SetTestExpress(2); else SetTestExpress(3); } - return(TestExpress); + return (TestExpress); } /* @@ -462,50 +464,55 @@ int GetTestExpress(void) * Return previous TestExpress mode. * Values: non-zero means TestExpress mode is on, 0 means off. */ -int SetTestExpress(int newval) +int +SetTestExpress(int newval) { int oldval; - oldval = TestExpress; + oldval = TestExpress; TestExpress = newval; - return(oldval); + return (oldval); } /* * Retrieve Summary request value. * 0 means no summary, 1 means yes. */ -H5_ATTR_PURE int GetTestSummary(void) +H5_ATTR_PURE int +GetTestSummary(void) { - return(Summary); + return (Summary); } /* * Retrieve Cleanup request value. * 0 means no Cleanup, 1 means yes. */ -H5_ATTR_PURE int GetTestCleanup(void) +H5_ATTR_PURE int +GetTestCleanup(void) { - return(CleanUp); + return (CleanUp); } /* * Set cleanup to no. * Return previous cleanup value. */ -int SetTestNoCleanup(void) +int +SetTestNoCleanup(void) { int oldval; - oldval = CleanUp; + oldval = CleanUp; CleanUp = 0; - return(oldval); + return (oldval); } /* * Parse an argument string for verbosity level and set it. */ -void ParseTestVerbosity(char *argv) +void +ParseTestVerbosity(char *argv) { if (*argv == 'l') SetTestVerbosity(VERBO_LO); @@ -517,34 +524,33 @@ void ParseTestVerbosity(char *argv) SetTestVerbosity(atoi(argv)); } - /* * Retrieve the number of testing errors for the testing framework */ -H5_ATTR_PURE int GetTestNumErrs(void) +H5_ATTR_PURE int +GetTestNumErrs(void) { - return(num_errs); + return (num_errs); } - /* * Increment the number of testing errors */ -void IncTestNumErrs(void) +void +IncTestNumErrs(void) { num_errs++; } - /* * Retrieve the current Test Parameters pointer. */ -H5_ATTR_PURE const void *GetTestParameters(void) +H5_ATTR_PURE const void * +GetTestParameters(void) { - return(Test_parameters); + return (Test_parameters); } - /* * This routine is designed to provide equivalent functionality to 'printf' * and also increment the error count for the testing framework. @@ -553,7 +559,7 @@ int TestErrPrintf(const char *format, ...) { va_list arglist; - int ret_value; + int ret_value; /* Increment the error count */ num_errs++; @@ -567,7 +573,6 @@ TestErrPrintf(const char *format, ...) return ret_value; } - /* * Set (control) which test will be tested. * SKIPTEST: skip this test @@ -575,59 +580,59 @@ TestErrPrintf(const char *format, ...) * BEGINETEST: skip all tests before this test * */ -void SetTest(const char *testname, int action) +void +SetTest(const char *testname, int action) { unsigned Loop; - switch (action){ - case SKIPTEST: - for (Loop = 0; Loop < Index; Loop++) - if (HDstrcmp(testname, Test[Loop].Name) == 0){ - Test[Loop].SkipFlag = 1; - break; - } - break; - case BEGINTEST: - for (Loop = 0; Loop < Index; Loop++) { - if (HDstrcmp(testname, Test[Loop].Name) != 0) - Test[Loop].SkipFlag = 1; - else{ - /* Found it. Set it to run. Done. */ - Test[Loop].SkipFlag = 0; - break; + switch (action) { + case SKIPTEST: + for (Loop = 0; Loop < Index; Loop++) + if (HDstrcmp(testname, Test[Loop].Name) == 0) { + Test[Loop].SkipFlag = 1; + break; + } + break; + case BEGINTEST: + for (Loop = 0; Loop < Index; Loop++) { + if (HDstrcmp(testname, Test[Loop].Name) != 0) + Test[Loop].SkipFlag = 1; + else { + /* Found it. Set it to run. Done. */ + Test[Loop].SkipFlag = 0; + break; + } } - } - break; - case ONLYTEST: - for (Loop = 0; Loop < Index; Loop++) { - if (HDstrcmp(testname, Test[Loop].Name) == 0) { - /* Found it. Set it to run. Break to skip the rest. */ - Test[Loop].SkipFlag = 0; - break; + break; + case ONLYTEST: + for (Loop = 0; Loop < Index; Loop++) { + if (HDstrcmp(testname, Test[Loop].Name) == 0) { + /* Found it. Set it to run. Break to skip the rest. */ + Test[Loop].SkipFlag = 0; + break; + } } - } - break; - default: - /* error */ - HDprintf("*** ERROR: Unknown action (%d) for SetTest\n", action); - break; + break; + default: + /* error */ + HDprintf("*** ERROR: Unknown action (%d) for SetTest\n", action); + break; } } - /* * Enable alarm on test execution, configurable by environment variable */ -void TestAlarmOn(void) +void +TestAlarmOn(void) { - char * env_val = HDgetenv("HDF5_ALARM_SECONDS"); /* Alarm environment */ - unsigned long alarm_sec = H5_ALARM_SEC; /* Number of seconds before alarm goes off */ + char * env_val = HDgetenv("HDF5_ALARM_SECONDS"); /* Alarm environment */ + unsigned long alarm_sec = H5_ALARM_SEC; /* Number of seconds before alarm goes off */ /* Get the alarm value from the environment variable, if set */ - if(env_val != NULL) + if (env_val != NULL) alarm_sec = (unsigned)HDstrtoul(env_val, (char **)NULL, 10); /* Set the number of seconds before alarm goes off */ HDalarm((unsigned)alarm_sec); } - diff --git a/test/testhdf5.c b/test/testhdf5.c index 72acf6c..152719a 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -45,34 +45,34 @@ main(int argc, char *argv[]) AddTest("config", test_configure, cleanup_configure, "Configure definitions", NULL); AddTest("metadata", test_metadata, cleanup_metadata, "Encoding/decoding metadata", NULL); AddTest("checksum", test_checksum, cleanup_checksum, "Checksum algorithm", NULL); - AddTest("tst", test_tst, NULL, "Ternary Search Trees", NULL); - AddTest("heap", test_heap, NULL, "Memory Heaps", NULL); - AddTest("skiplist", test_skiplist, NULL, "Skip Lists", NULL); - AddTest("refstr", test_refstr, NULL, "Reference Counted Strings", NULL); + AddTest("tst", test_tst, NULL, "Ternary Search Trees", NULL); + AddTest("heap", test_heap, NULL, "Memory Heaps", NULL); + AddTest("skiplist", test_skiplist, NULL, "Skip Lists", NULL); + AddTest("refstr", test_refstr, NULL, "Reference Counted Strings", NULL); AddTest("file", test_file, cleanup_file, "Low-Level File I/O", NULL); AddTest("objects", test_h5o, cleanup_h5o, "Generic Object Functions", NULL); - AddTest("h5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); - AddTest("coords", test_coords, cleanup_coords, "Dataspace coordinates", NULL); - AddTest("sohm", test_sohm, cleanup_sohm, "Shared Object Header Messages", NULL); - AddTest("attr", test_attr, cleanup_attr, "Attributes", NULL); - AddTest("select", test_select, cleanup_select, "Selections", NULL); - AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); - AddTest("ref_deprec", test_reference_deprec, cleanup_reference_deprec, "Deprecated References", NULL); - AddTest("ref", test_reference, cleanup_reference, "References", NULL); - AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); - AddTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); - AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); - AddTest("array", test_array, cleanup_array, "Array Datatypes", NULL); - AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); - AddTest("unicode", test_unicode, cleanup_unicode, "UTF-8 Encoding", NULL); - AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); - AddTest("misc", test_misc, cleanup_misc, "Miscellaneous", NULL); + AddTest("h5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); + AddTest("coords", test_coords, cleanup_coords, "Dataspace coordinates", NULL); + AddTest("sohm", test_sohm, cleanup_sohm, "Shared Object Header Messages", NULL); + AddTest("attr", test_attr, cleanup_attr, "Attributes", NULL); + AddTest("select", test_select, cleanup_select, "Selections", NULL); + AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); + AddTest("ref_deprec", test_reference_deprec, cleanup_reference_deprec, "Deprecated References", NULL); + AddTest("ref", test_reference, cleanup_reference, "References", NULL); + AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); + AddTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); + AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); + AddTest("array", test_array, cleanup_array, "Array Datatypes", NULL); + AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); + AddTest("unicode", test_unicode, cleanup_unicode, "UTF-8 Encoding", NULL); + AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); + AddTest("misc", test_misc, cleanup_misc, "Miscellaneous", NULL); /* Display testing information */ TestInfo(argv[0]); /* Parse command line arguments */ - TestParseCmdLine(argc,argv); + TestParseCmdLine(argc, argv); /* Perform requested testing */ PerformTests(); @@ -94,5 +94,4 @@ main(int argc, char *argv[]) HDexit(EXIT_FAILURE); else HDexit(EXIT_SUCCESS); -} /* end main() */ - +} /* end main() */ diff --git a/test/testhdf5.h b/test/testhdf5.h index 6b13cae..872e6b4 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -23,154 +23,178 @@ /* Use %ld to print the value because long should cover most cases. */ /* Used to make certain a return value _is_not_ a value */ -#define CHECK(ret, val, where) do { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d " \ - "in %s returned %ld \n", \ - where, (int)__LINE__, __FILE__, \ - (long)(ret)); \ - } \ - if ((ret) == (val)) { \ - TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} while(0) - -#define CHECK_I(ret,where) { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \ - (where), (int)__LINE__, __FILE__, (long)(ret)); \ - } \ - if ((ret)<0) { \ - TestErrPrintf ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ - (where), (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} +#define CHECK(ret, val, where) \ + do { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d " \ + "in %s returned %ld \n", \ + where, (int)__LINE__, __FILE__, (long)(ret)); \ + } \ + if ((ret) == (val)) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", \ + where, (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } while (0) + +#define CHECK_I(ret, where) \ + { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", (where), (int)__LINE__, \ + __FILE__, (long)(ret)); \ + } \ + if ((ret) < 0) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", (where), (long)(ret), \ + (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } /* Check that a pointer is valid (i.e.: not NULL) */ -#define CHECK_PTR(ret,where) { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ - (where), (int)__LINE__, __FILE__, (ret)); \ - } \ - if (!(ret)) { \ - TestErrPrintf ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ - (where), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} +#define CHECK_PTR(ret, where) \ + { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %p\n", (where), (int)__LINE__, \ + __FILE__, (ret)); \ + } \ + if (!(ret)) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", (where), (int)__LINE__, \ + __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } /* Check that a pointer is NULL */ -#define CHECK_PTR_NULL(ret,where) { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ - (where), (int)__LINE__, __FILE__, (ret)); \ - } \ - if (ret) { \ - TestErrPrintf ("*** UNEXPECTED RETURN from %s is not NULL line %4d in %s\n", \ - (where), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} +#define CHECK_PTR_NULL(ret, where) \ + { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %p\n", (where), (int)__LINE__, \ + __FILE__, (ret)); \ + } \ + if (ret) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is not NULL line %4d in %s\n", (where), \ + (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } /* Check that two pointers are equal */ -#define CHECK_PTR_EQ(ret, val, where) { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ - (where), (int)__LINE__, __FILE__, (const void *)(ret)); \ - } \ - if (ret != val) { \ - TestErrPrintf ("*** UNEXPECTED RETURN from %s: returned value of %p is not equal to %p line %4d in %s\n", \ - (where), (const void *)(ret), (const void *)(val), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} +#define CHECK_PTR_EQ(ret, val, where) \ + { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %p\n", (where), (int)__LINE__, \ + __FILE__, (const void *)(ret)); \ + } \ + if (ret != val) { \ + TestErrPrintf( \ + "*** UNEXPECTED RETURN from %s: returned value of %p is not equal to %p line %4d in %s\n", \ + (where), (const void *)(ret), (const void *)(val), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } /* Used to make certain a return value _is_ a value */ -#define VERIFY(_x, _val, where) do { \ - long __x = (long)_x, __val = (long)_val; \ - if(VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%ld \n", (where), (int)__LINE__, __FILE__, __x); \ - } \ - if((__x) != (__val)) { \ - TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ - "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} while(0) +#define VERIFY(_x, _val, where) \ + do { \ + long __x = (long)_x, __val = (long)_val; \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + "%ld \n", \ + (where), (int)__LINE__, __FILE__, __x); \ + } \ + if ((__x) != (__val)) { \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ + "in %s\n", \ + (where), __val, __x, (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } while (0) /* Used to make certain a (non-'long' type's) return value _is_ a value */ -#define VERIFY_TYPE(_x, _val, _type, _format, where) do { \ - _type __x = (_type)_x, __val = (_type)_val; \ - if(VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s had value " \ - _format " \n", (where), (int)__LINE__, __FILE__, __x); \ - } \ - if((__x) != (__val)) { \ - TestErrPrintf("*** UNEXPECTED VALUE from %s should be " _format ", but is " _format " at line %4d " \ - "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} while(0) +#define VERIFY_TYPE(_x, _val, _type, _format, where) \ + do { \ + _type __x = (_type)_x, __val = (_type)_val; \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " _format " \n", (where), \ + (int)__LINE__, __FILE__, __x); \ + } \ + if ((__x) != (__val)) { \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be " _format ", but is " _format \ + " at line %4d " \ + "in %s\n", \ + (where), __val, __x, (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } while (0) /* Used to make certain a string return value _is_ a value */ -#define VERIFY_STR(x, val, where) do { \ - if (VERBOSE_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%s \n", (where), (int)__LINE__, __FILE__, x); \ - } \ - if (HDstrcmp(x, val)) { \ - TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \ - "in %s\n", where, val, x, (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} while(0) +#define VERIFY_STR(x, val, where) \ + do { \ + if (VERBOSE_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + "%s \n", \ + (where), (int)__LINE__, __FILE__, x); \ + } \ + if (HDstrcmp(x, val)) { \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \ + "in %s\n", \ + where, val, x, (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } while (0) /* Used to document process through a test and to check for errors */ -#define RESULT(ret,func) do { \ - if (VERBOSE_MED) { \ - print_func(" Call to routine: %15s at line %4d in %s returned " \ - "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ - } \ - if (VERBOSE_HI) \ - H5Eprint2(H5E_DEFAULT, stdout); \ - if ((ret) == FAIL) { \ - TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint2(H5E_DEFAULT, stdout); \ - } \ -} while(0) +#define RESULT(ret, func) \ + do { \ + if (VERBOSE_MED) { \ + print_func(" Call to routine: %15s at line %4d in %s returned " \ + "%ld\n", \ + func, (int)__LINE__, __FILE__, (long)(ret)); \ + } \ + if (VERBOSE_HI) \ + H5Eprint2(H5E_DEFAULT, stdout); \ + if ((ret) == FAIL) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", \ + func, (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ + } while (0) /* Used to document process through a test */ #if defined(H5_HAVE_PARALLEL) && defined(H5_PARALLEL_TEST) -#define MESSAGE(V,A) { \ - int mpi_rank; \ - \ - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); \ - if(mpi_rank == 0 && HDGetTestVerbosity() > (V)) \ - print_func A ; \ -} +#define MESSAGE(V, A) \ + { \ + int mpi_rank; \ + \ + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); \ + if (mpi_rank == 0 && HDGetTestVerbosity() > (V)) \ + print_func A; \ + } #else /* H5_HAVE_PARALLEL */ -#define MESSAGE(V,A) {if (HDGetTestVerbosity() > (V)) print_func A;} +#define MESSAGE(V, A) \ + { \ + if (HDGetTestVerbosity() > (V)) \ + print_func A; \ + } #endif /* H5_HAVE_PARALLEL */ /* Used to indicate an error that is complex to check for */ -#define ERROR(where) do { \ - if(VERBOSE_HI) \ - print_func(" Call to routine: %15s at line %4d in %s returned " \ - "invalid result\n", where, (int)__LINE__, __FILE__); \ - TestErrPrintf("*** UNEXPECTED RESULT from %s at line %4d in %s\n", \ - where, (int)__LINE__, __FILE__); \ -} while(0) +#define ERROR(where) \ + do { \ + if (VERBOSE_HI) \ + print_func(" Call to routine: %15s at line %4d in %s returned " \ + "invalid result\n", \ + where, (int)__LINE__, __FILE__); \ + TestErrPrintf("*** UNEXPECTED RESULT from %s at line %4d in %s\n", where, (int)__LINE__, __FILE__); \ + } while (0) /* definitions for command strings */ -#define VERBOSITY_STR "Verbosity" -#define SKIP_STR "Skip" -#define TEST_STR "Test" -#define CLEAN_STR "Cleanup" +#define VERBOSITY_STR "Verbosity" +#define SKIP_STR "Skip" +#define TEST_STR "Test" +#define CLEAN_STR "Cleanup" #ifdef __cplusplus extern "C" { diff --git a/test/testmeta.c b/test/testmeta.c index 9a40e6f..fee1954 100644 --- a/test/testmeta.c +++ b/test/testmeta.c @@ -22,35 +22,35 @@ * but the H5Gcreate2 error does not. */ - #include "h5test.h" -#define FILEN "testmeta.h5" +#define FILEN "testmeta.h5" -#define CHUNK_SIZE 512 +#define CHUNK_SIZE 512 -#define NDATAARRAYS 3 +#define NDATAARRAYS 3 /*#define NPOINTS 2048*/ -#define NPOINTS 20 -#define NEXTARRAYS 10 -#define NDATAOBJECTS 100000 +#define NPOINTS 20 +#define NEXTARRAYS 10 +#define NDATAOBJECTS 100000 -int main(void) +int +main(void) { - hid_t file_id, prop_id, memspace_id, type_id; - hid_t group_id; - hid_t dataset_id, dataspace_id; - herr_t status; - hsize_t dims[1]; - hsize_t maxdims[1]; - float data[NPOINTS]; - float floatval; - unsigned numdataobj = 0; - unsigned i, j; - char name[80]; - hsize_t start[1] = {0}; - hsize_t stride[1] = {1}; - hsize_t count[1] = {1}; + hid_t file_id, prop_id, memspace_id, type_id; + hid_t group_id; + hid_t dataset_id, dataspace_id; + herr_t status; + hsize_t dims[1]; + hsize_t maxdims[1]; + float data[NPOINTS]; + float floatval; + unsigned numdataobj = 0; + unsigned i, j; + char name[80]; + hsize_t start[1] = {0}; + hsize_t stride[1] = {1}; + hsize_t count[1] = {1}; /* Create a file */ file_id = H5Fcreate(FILEN, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -60,8 +60,8 @@ int main(void) dataspace_id = H5Screate(H5S_SCALAR); /* Create dataset */ - dataset_id = H5Dcreate2(file_id, "/NumDataObj", - H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id = H5Dcreate2(file_id, "/NumDataObj", H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); /* Write value to NumDataObj dataset */ status = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &numdataobj); @@ -74,17 +74,18 @@ int main(void) /* Set up for extendible dataset */ prop_id = H5Pcreate(H5P_DATASET_CREATE); dims[0] = CHUNK_SIZE; - status = H5Pset_chunk(prop_id, 1, dims); + status = H5Pset_chunk(prop_id, 1, dims); /* Create dataspace */ - dims[0] = 1; - maxdims[0] = H5S_UNLIMITED; + dims[0] = 1; + maxdims[0] = H5S_UNLIMITED; dataspace_id = H5Screate_simple(1, dims, maxdims); - for(i = 0; i < NEXTARRAYS; i++) { + for (i = 0; i < NEXTARRAYS; i++) { /* Create dataset */ sprintf(name, "/ExtArray%06d", i); - dataset_id = H5Dcreate2(file_id, name, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, prop_id, H5P_DEFAULT); + dataset_id = + H5Dcreate2(file_id, name, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, prop_id, H5P_DEFAULT); /* Close the identifier */ status = H5Dclose(dataset_id); @@ -98,7 +99,7 @@ int main(void) group_id = H5Gcreate2(file_id, "/DataArray", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(group_id); - for(j = 0; j < NDATAOBJECTS; j++) { + for (j = 0; j < NDATAOBJECTS; j++) { /* Removed print statement as it would lock system resources on Windows */ /* * HDprintf("\rWriting Object #%d of %d", j+1, NDATAOBJECTS); @@ -109,23 +110,24 @@ int main(void) /* Create group to hold data arrays for this object */ HDsprintf(name, "/DataArray/%06d", j); group_id = H5Gcreate2(file_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(group_id < 0) { + if (group_id < 0) { HDfprintf(stderr, "Failed to create DataArray group.\n"); status = H5Fclose(file_id); return -1; } /* Loop over data arrays */ - for(i = 0; i < NDATAARRAYS; i++) { + for (i = 0; i < NDATAARRAYS; i++) { /* Create dataspace */ - dims[0]=NPOINTS; - maxdims[0]=NPOINTS; - dataspace_id = H5Screate_simple(1 ,dims, maxdims); + dims[0] = NPOINTS; + maxdims[0] = NPOINTS; + dataspace_id = H5Screate_simple(1, dims, maxdims); /* Create dataset */ HDsprintf(name, "DataArray%06d", i); - dataset_id = H5Dcreate2(group_id, name, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dataset_id < 0) { + dataset_id = H5Dcreate2(group_id, name, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); + if (dataset_id < 0) { HDfprintf(stderr, "Failed to create DataArray dataset.\n"); status = H5Fclose(file_id); return -1; @@ -133,7 +135,7 @@ int main(void) /* Write the data array data */ status = H5Dwrite(dataset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if(status < 0) { + if (status < 0) { HDfprintf(stderr, "Failed to write DataArray dataset.\n"); status = H5Fclose(file_id); return -1; @@ -146,7 +148,7 @@ int main(void) /* Open NumDataObj dataset */ dataset_id = H5Dopen2(file_id, "/NumDataObj", H5P_DEFAULT); - if(dataset_id < 0) { + if (dataset_id < 0) { HDfprintf(stderr, "Failed to open NumDataObj dataset.\n"); status = H5Fclose(file_id); return -1; @@ -154,8 +156,8 @@ int main(void) /* Write value to NumDataObj dataset */ numdataobj = j + 1; - status = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &numdataobj); - if(status < 0) { + status = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &numdataobj); + if (status < 0) { HDfprintf(stderr, "Failed to write NumDataObj dataset.\n"); status = H5Fclose(file_id); return -1; @@ -166,11 +168,11 @@ int main(void) status = H5Gclose(group_id); /* Extend attribute arrays */ - for(i = 0; i < NEXTARRAYS; i++) { + for (i = 0; i < NEXTARRAYS; i++) { /* Open extendable dataset */ HDsprintf(name, "/ExtArray%06d", i); dataset_id = H5Dopen2(file_id, name, H5P_DEFAULT); - if(dataset_id < 0) { + if (dataset_id < 0) { HDfprintf(stderr, "Failed to open ExtArray dataset.\n"); status = H5Fclose(file_id); return -1; @@ -178,25 +180,25 @@ int main(void) /* Extend attribute dataset */ dims[0] = (hsize_t)j + 1; - status = H5Dset_extent(dataset_id, dims); - if(status < 0) { + status = H5Dset_extent(dataset_id, dims); + if (status < 0) { HDfprintf(stderr, "Failed to extend DataArray dataset.\n"); status = H5Fclose(file_id); return -1; } /* end if */ /* Select element and write value to attribute dataset */ - dims[0] = 1; - memspace_id = H5Screate_simple(1, dims, dims); + dims[0] = 1; + memspace_id = H5Screate_simple(1, dims, dims); dataspace_id = H5Dget_space(dataset_id); - type_id = H5Dget_type(dataset_id); + type_id = H5Dget_type(dataset_id); start[0] = 0; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, start, stride, count, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, start, stride, count, NULL); start[0] = (hssize_t)j; - status = H5Sselect_hyperslab(dataspace_id, H5S_SELECT_SET, start, stride, count, NULL); - status = H5Dwrite(dataset_id, type_id, memspace_id, dataspace_id, H5P_DEFAULT, &floatval); - if(status < 0) { + status = H5Sselect_hyperslab(dataspace_id, H5S_SELECT_SET, start, stride, count, NULL); + status = H5Dwrite(dataset_id, type_id, memspace_id, dataspace_id, H5P_DEFAULT, &floatval); + if (status < 0) { HDfprintf(stderr, "Failed to write DataArray dataset.\n"); status = H5Fclose(file_id); return -1; @@ -210,7 +212,6 @@ int main(void) } } - /* Close the file */ status = H5Fclose(file_id); @@ -218,4 +219,3 @@ int main(void) return 0; } - diff --git a/test/tfile.c b/test/tfile.c index d6047dc..3288910 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -12,136 +12,136 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tfile -* -* Test the low-level file I/O features. -* -*************************************************************/ + * + * Test program: tfile + * + * Test the low-level file I/O features. + * + *************************************************************/ #include "testhdf5.h" #include "H5srcdir.h" #include "H5Iprivate.h" #include "H5Pprivate.h" -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5private.h" /* * This file needs to access private information from the H5F package. * This file also needs to access the file testing code. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ -#include "H5Dpkg.h" /* Dataset access */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#include "H5Dpkg.h" /* Dataset access */ -#define H5S_FRIEND /*suppress error about including H5Spkg */ -#include "H5Spkg.h" /* Dataspace */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ +#include "H5Spkg.h" /* Dataspace */ -#define H5T_FRIEND /*suppress error about including H5Tpkg */ -#include "H5Tpkg.h" /* Datatype */ +#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#include "H5Tpkg.h" /* Datatype */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Apkg.h" /* Attributes */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Apkg.h" /* Attributes */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5Opkg.h" /* Object headers */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Opkg.h" /* Object headers */ -#define BAD_USERBLOCK_SIZE1 (hsize_t)1 -#define BAD_USERBLOCK_SIZE2 (hsize_t)2 -#define BAD_USERBLOCK_SIZE3 (hsize_t)3 -#define BAD_USERBLOCK_SIZE4 (hsize_t)64 -#define BAD_USERBLOCK_SIZE5 (hsize_t)511 -#define BAD_USERBLOCK_SIZE6 (hsize_t)513 -#define BAD_USERBLOCK_SIZE7 (hsize_t)6144 +#define BAD_USERBLOCK_SIZE1 (hsize_t)1 +#define BAD_USERBLOCK_SIZE2 (hsize_t)2 +#define BAD_USERBLOCK_SIZE3 (hsize_t)3 +#define BAD_USERBLOCK_SIZE4 (hsize_t)64 +#define BAD_USERBLOCK_SIZE5 (hsize_t)511 +#define BAD_USERBLOCK_SIZE6 (hsize_t)513 +#define BAD_USERBLOCK_SIZE7 (hsize_t)6144 -#define F1_USERBLOCK_SIZE (hsize_t)0 -#define F1_OFFSET_SIZE sizeof(haddr_t) -#define F1_LENGTH_SIZE sizeof(hsize_t) -#define F1_SYM_LEAF_K 4 -#define F1_SYM_INTERN_K 16 -#define FILE1 "tfile1.h5" -#define SFILE1 "sys_file1" +#define F1_USERBLOCK_SIZE (hsize_t)0 +#define F1_OFFSET_SIZE sizeof(haddr_t) +#define F1_LENGTH_SIZE sizeof(hsize_t) +#define F1_SYM_LEAF_K 4 +#define F1_SYM_INTERN_K 16 +#define FILE1 "tfile1.h5" +#define SFILE1 "sys_file1" #define REOPEN_FILE "tfile_reopen.h5" #define REOPEN_DSET "dset" -#define F2_USERBLOCK_SIZE (hsize_t)512 -#define F2_OFFSET_SIZE 8 -#define F2_LENGTH_SIZE 8 -#define F2_SYM_LEAF_K 8 -#define F2_SYM_INTERN_K 32 -#define F2_RANK 2 -#define F2_DIM0 4 -#define F2_DIM1 6 -#define F2_DSET "dset" -#define FILE2 "tfile2.h5" - -#define F3_USERBLOCK_SIZE (hsize_t)0 -#define F3_OFFSET_SIZE F2_OFFSET_SIZE -#define F3_LENGTH_SIZE F2_LENGTH_SIZE -#define F3_SYM_LEAF_K F2_SYM_LEAF_K -#define F3_SYM_INTERN_K F2_SYM_INTERN_K -#define FILE3 "tfile3.h5" - -#define GRP_NAME "/group" -#define DSET_NAME "dataset" -#define ATTR_NAME "attr" -#define TYPE_NAME "type" -#define FILE4 "tfile4.h5" - -#define OBJ_ID_COUNT_0 0 -#define OBJ_ID_COUNT_1 1 -#define OBJ_ID_COUNT_2 2 -#define OBJ_ID_COUNT_3 3 -#define OBJ_ID_COUNT_4 4 -#define OBJ_ID_COUNT_6 6 -#define OBJ_ID_COUNT_8 8 - -#define GROUP1 "Group1" -#define DSET1 "Dataset1" -#define DSET2 "/Group1/Dataset2" - -#define TESTA_GROUPNAME "group" -#define TESTA_DSETNAME "dataset" -#define TESTA_ATTRNAME "attribute" -#define TESTA_DTYPENAME "compound" -#define TESTA_NAME_BUF_SIZE 64 -#define TESTA_RANK 2 -#define TESTA_NX 4 -#define TESTA_NY 5 - -#define USERBLOCK_SIZE ((hsize_t) 512) +#define F2_USERBLOCK_SIZE (hsize_t)512 +#define F2_OFFSET_SIZE 8 +#define F2_LENGTH_SIZE 8 +#define F2_SYM_LEAF_K 8 +#define F2_SYM_INTERN_K 32 +#define F2_RANK 2 +#define F2_DIM0 4 +#define F2_DIM1 6 +#define F2_DSET "dset" +#define FILE2 "tfile2.h5" + +#define F3_USERBLOCK_SIZE (hsize_t)0 +#define F3_OFFSET_SIZE F2_OFFSET_SIZE +#define F3_LENGTH_SIZE F2_LENGTH_SIZE +#define F3_SYM_LEAF_K F2_SYM_LEAF_K +#define F3_SYM_INTERN_K F2_SYM_INTERN_K +#define FILE3 "tfile3.h5" + +#define GRP_NAME "/group" +#define DSET_NAME "dataset" +#define ATTR_NAME "attr" +#define TYPE_NAME "type" +#define FILE4 "tfile4.h5" + +#define OBJ_ID_COUNT_0 0 +#define OBJ_ID_COUNT_1 1 +#define OBJ_ID_COUNT_2 2 +#define OBJ_ID_COUNT_3 3 +#define OBJ_ID_COUNT_4 4 +#define OBJ_ID_COUNT_6 6 +#define OBJ_ID_COUNT_8 8 + +#define GROUP1 "Group1" +#define DSET1 "Dataset1" +#define DSET2 "/Group1/Dataset2" + +#define TESTA_GROUPNAME "group" +#define TESTA_DSETNAME "dataset" +#define TESTA_ATTRNAME "attribute" +#define TESTA_DTYPENAME "compound" +#define TESTA_NAME_BUF_SIZE 64 +#define TESTA_RANK 2 +#define TESTA_NX 4 +#define TESTA_NY 5 + +#define USERBLOCK_SIZE ((hsize_t)512) /* Declarations for test_filespace_*() */ -#define FILENAME_LEN 1024 /* length of file name */ -#define DSETNAME "dset" /* Name of dataset */ -#define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */ -#define READ_OLD_BUFSIZE 1024 /* Buffer for holding file data */ -#define FILE5 "tfile5.h5" /* Test file */ -#define TEST_THRESHOLD10 10 /* Free space section threshold */ -#define FSP_SIZE_DEF 4096 /* File space page size default */ -#define FSP_SIZE512 512 /* File space page size */ -#define FSP_SIZE1G 1024*1024*1024 /* File space page size */ +#define FILENAME_LEN 1024 /* length of file name */ +#define DSETNAME "dset" /* Name of dataset */ +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) /* # of elements */ +#define READ_OLD_BUFSIZE 1024 /* Buffer for holding file data */ +#define FILE5 "tfile5.h5" /* Test file */ +#define TEST_THRESHOLD10 10 /* Free space section threshold */ +#define FSP_SIZE_DEF 4096 /* File space page size default */ +#define FSP_SIZE512 512 /* File space page size */ +#define FSP_SIZE1G 1024 * 1024 * 1024 /* File space page size */ /* Declaration for test_libver_macros2() */ -#define FILE6 "tfile6.h5" /* Test file */ +#define FILE6 "tfile6.h5" /* Test file */ /* Declaration for test_get_obj_ids() */ -#define FILE7 "tfile7.h5" /* Test file */ -#define NGROUPS 2 -#define NDSETS 4 +#define FILE7 "tfile7.h5" /* Test file */ +#define NGROUPS 2 +#define NDSETS 4 /* Declaration for test_incr_filesize() */ -#define FILE8 "tfile8.h5" /* Test file */ +#define FILE8 "tfile8.h5" /* Test file */ /* Files created under 1.6 branch and 1.8 branch--used in test_filespace_compatible() */ const char *OLD_FILENAME[] = { - "filespace_1_6.h5", /* 1.6 HDF5 file */ - "filespace_1_8.h5" /* 1.8 HDF5 file */ + "filespace_1_6.h5", /* 1.6 HDF5 file */ + "filespace_1_8.h5" /* 1.8 HDF5 file */ }; /* Files created in 1.10.0 release --used in test_filespace_1.10.0_compatible() */ @@ -157,27 +157,23 @@ const char *OLD_1_10_0_FILENAME[] = { /* Files used in test_filespace_round_compatible() */ const char *FSPACE_FILENAMES[] = { - "fsm_aggr_nopersist.h5", /* H5F_FILE_SPACE_AGGR, not persisting free-space */ - "fsm_aggr_persist.h5", /* H5F_FILE_SPACE_AGGR, persisting free-space */ - "paged_nopersist.h5", /* H5F_FILE_SPACE_PAGE, not persisting free-space */ - "paged_persist.h5", /* H5F_FILE_SPACE_PAGE, persisting free-space */ - "aggr.h5", /* H5F_FILE_SPACE_AGGR */ - "none.h5" /* H5F_FILE_SPACE_NONE */ -}; - -const char *FILESPACE_NAME[] = { - "tfilespace", - NULL + "fsm_aggr_nopersist.h5", /* H5F_FILE_SPACE_AGGR, not persisting free-space */ + "fsm_aggr_persist.h5", /* H5F_FILE_SPACE_AGGR, persisting free-space */ + "paged_nopersist.h5", /* H5F_FILE_SPACE_PAGE, not persisting free-space */ + "paged_persist.h5", /* H5F_FILE_SPACE_PAGE, persisting free-space */ + "aggr.h5", /* H5F_FILE_SPACE_AGGR */ + "none.h5" /* H5F_FILE_SPACE_NONE */ }; +const char *FILESPACE_NAME[] = {"tfilespace", NULL}; /* Declarations for test_libver_bounds_copy(): */ /* SRC_FILE: source file created under 1.8 branch with latest format */ /* DST_FILE: destination file for copying the dataset in SRC_FILE */ /* DSET_DS1: the dataset created in SRC_FILE to be copied to DST_FILE */ -#define SRC_FILE "fill18.h5" -#define DST_FILE "fill18_copy.h5" -#define DSET_DS1 "DS1" +#define SRC_FILE "fill18.h5" +#define DST_FILE "fill18_copy.h5" +#define DSET_DS1 "DS1" /* Local test function declarations for version bounds */ static void test_libver_bounds_low_high(void); @@ -191,18 +187,15 @@ static void test_libver_bounds_datatype(hid_t fapl); static void test_libver_bounds_datatype_check(hid_t fapl, hid_t tid); static void test_libver_bounds_attributes(hid_t fapl); -#define DSET_NULL "DSET_NULL" -#define DSET "DSET" -#define DSETA "DSETA" -#define DSETB "DSETB" -#define DSETC "DSETC" +#define DSET_NULL "DSET_NULL" +#define DSET "DSET" +#define DSETA "DSETA" +#define DSETB "DSETB" +#define DSETC "DSETC" -static void -create_objects(hid_t, hid_t, hid_t *, hid_t *, hid_t *, hid_t *); -static void -test_obj_count_and_id(hid_t, hid_t, hid_t, hid_t, hid_t, hid_t); -static void -check_file_id(hid_t, hid_t); +static void create_objects(hid_t, hid_t, hid_t *, hid_t *, hid_t *, hid_t *); +static void test_obj_count_and_id(hid_t, hid_t, hid_t, hid_t, hid_t, hid_t); +static void check_file_id(hid_t, hid_t); /* Helper routine used by test_rw_noupdate() */ static int cal_chksum(const char *file, uint32_t *chksum); @@ -217,14 +210,14 @@ static void test_rw_noupdate(void); static void test_file_create(void) { - hid_t fid1, fid2, fid3; /* HDF5 File IDs */ - hid_t tmpl1, tmpl2; /*file creation templates */ - hsize_t ublock; /*sizeof userblock */ - size_t parm; /*file-creation parameters */ - size_t parm2; /*file-creation parameters */ - unsigned iparm; - unsigned iparm2; - herr_t ret; /*generic return value */ + hid_t fid1, fid2, fid3; /* HDF5 File IDs */ + hid_t tmpl1, tmpl2; /*file creation templates */ + hsize_t ublock; /*sizeof userblock */ + size_t parm; /*file-creation parameters */ + size_t parm2; /*file-creation parameters */ + unsigned iparm; + unsigned iparm2; + herr_t ret; /*generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File Creation I/O\n")); @@ -316,33 +309,47 @@ test_file_create(void) CHECK(tmpl1, FAIL, "H5Pcreate"); /* Try setting some bad userblock sizes */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE1); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE2); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE3); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE4); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE5); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE6); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE7); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_userblock"); /* Set the new file-creation parameters */ @@ -368,36 +375,37 @@ test_file_create(void) /* Make certain we can create a dataset properly in the file with the userblock */ { - hid_t dataset_id, dataspace_id; /* identifiers */ - hsize_t dims[F2_RANK]; - unsigned data[F2_DIM0][F2_DIM1]; - unsigned i,j; - - /* Create the data space for the dataset. */ - dims[0] = F2_DIM0; - dims[1] = F2_DIM1; - dataspace_id = H5Screate_simple(F2_RANK, dims, NULL); - CHECK(dataspace_id, FAIL, "H5Screate_simple"); - - /* Create the dataset. */ - dataset_id = H5Dcreate2(fid2, F2_DSET, H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dataset_id, FAIL, "H5Dcreate2"); - - for(i = 0; i < F2_DIM0; i++) - for(j = 0; j < F2_DIM1; j++) - data[i][j] = i * 10 + j; - - /* Write data to the new dataset */ - ret = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - CHECK(ret, FAIL, "H5Dwrite"); - - /* End access to the dataset and release resources used by it. */ - ret = H5Dclose(dataset_id); - CHECK(ret, FAIL, "H5Dclose"); - - /* Terminate access to the data space. */ - ret = H5Sclose(dataspace_id); - CHECK(ret, FAIL, "H5Sclose"); + hid_t dataset_id, dataspace_id; /* identifiers */ + hsize_t dims[F2_RANK]; + unsigned data[F2_DIM0][F2_DIM1]; + unsigned i, j; + + /* Create the data space for the dataset. */ + dims[0] = F2_DIM0; + dims[1] = F2_DIM1; + dataspace_id = H5Screate_simple(F2_RANK, dims, NULL); + CHECK(dataspace_id, FAIL, "H5Screate_simple"); + + /* Create the dataset. */ + dataset_id = + H5Dcreate2(fid2, F2_DSET, H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dataset_id, FAIL, "H5Dcreate2"); + + for (i = 0; i < F2_DIM0; i++) + for (j = 0; j < F2_DIM1; j++) + data[i][j] = i * 10 + j; + + /* Write data to the new dataset */ + ret = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + CHECK(ret, FAIL, "H5Dwrite"); + + /* End access to the dataset and release resources used by it. */ + ret = H5Dclose(dataset_id); + CHECK(ret, FAIL, "H5Dclose"); + + /* Terminate access to the data space. */ + ret = H5Sclose(dataspace_id); + CHECK(ret, FAIL, "H5Sclose"); } /* Get the file-creation template */ @@ -476,7 +484,7 @@ test_file_create(void) /* Close third file */ ret = H5Fclose(fid3); CHECK(ret, FAIL, "H5Fclose"); -} /* test_file_create() */ +} /* test_file_create() */ /**************************************************************** ** @@ -486,17 +494,17 @@ test_file_create(void) static void test_file_open(void) { - hid_t fid1, fid2; /*HDF5 File IDs */ - hid_t did; /*dataset ID */ - hid_t fapl_id; /*file access property list ID */ - hid_t tmpl1; /*file creation templates */ - hsize_t ublock; /*sizeof user block */ - size_t parm; /*file-creation parameters */ - size_t parm2; /*file-creation parameters */ - unsigned iparm; - unsigned iparm2; - unsigned intent; - herr_t ret; /*generic return value */ + hid_t fid1, fid2; /*HDF5 File IDs */ + hid_t did; /*dataset ID */ + hid_t fapl_id; /*file access property list ID */ + hid_t tmpl1; /*file creation templates */ + hsize_t ublock; /*sizeof user block */ + size_t parm; /*file-creation parameters */ + size_t parm2; /*file-creation parameters */ + unsigned iparm; + unsigned iparm2; + unsigned intent; + herr_t ret; /*generic return value */ /* * Test single file open @@ -541,7 +549,6 @@ test_file_open(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* * Test two file opens: one is opened H5F_ACC_RDONLY and H5F_CLOSE_WEAK. * It's closed with an object left open. Then another is opened @@ -594,7 +601,7 @@ test_file_open(void) ret = H5Pclose(fapl_id); CHECK(ret, FAIL, "H5Pclose"); -} /* test_file_open() */ +} /* test_file_open() */ /**************************************************************** ** @@ -604,12 +611,12 @@ test_file_open(void) static void test_file_reopen(void) { - hid_t fid = -1; /* file ID from initial open */ - hid_t rfid = -1; /* file ID from reopen */ - hid_t did = -1; /* dataset ID (both opens) */ - hid_t sid = -1; /* dataspace ID for dataset creation */ - hsize_t dims = 6; /* dataspace size */ - herr_t ret; /* Generic return value */ + hid_t fid = -1; /* file ID from initial open */ + hid_t rfid = -1; /* file ID from reopen */ + hid_t did = -1; /* dataset ID (both opens) */ + hid_t sid = -1; /* dataspace ID for dataset creation */ + hsize_t dims = 6; /* dataspace size */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing File Re-opening\n")); @@ -647,7 +654,7 @@ test_file_reopen(void) CHECK(ret, FAIL, "H5Fclose"); HDremove(REOPEN_FILE); -} /* test_file_reopen() */ +} /* test_file_reopen() */ /**************************************************************** ** @@ -658,11 +665,11 @@ test_file_reopen(void) static void test_file_close(void) { - hid_t fid1, fid2; - hid_t fapl_id, access_id; - hid_t dataset_id, group_id1, group_id2, group_id3; - H5F_close_degree_t fc_degree; - herr_t ret; + hid_t fid1, fid2; + hid_t fapl_id, access_id; + hid_t dataset_id, group_id1, group_id2, group_id3; + H5F_close_degree_t fc_degree; + herr_t ret; /* Test behavior while opening file multiple times with different * file close degree value @@ -698,7 +705,6 @@ test_file_close(void) ret = H5Fclose(fid2); CHECK(ret, FAIL, "H5Fclose"); - /* Test behavior while opening file multiple times with different file * close degree */ @@ -723,7 +729,6 @@ test_file_close(void) ret = H5Fclose(fid2); CHECK(ret, FAIL, "H5Fclose"); - /* Test behavior while opening file multiple times with file close * degree STRONG */ ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG); @@ -757,7 +762,6 @@ test_file_close(void) ret = H5Fclose(fid2); CHECK(ret, FAIL, "H5Fclose"); - /* Test behavior while opening file multiple times with file close * degree SEMI */ ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI); @@ -822,7 +826,6 @@ test_file_close(void) ret = H5Fclose(fid2); CHECK(ret, FAIL, "H5Fclose"); - /* Test behavior while opening file multiple times with file close * degree WEAK */ ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_WEAK); @@ -849,8 +852,7 @@ test_file_close(void) create_objects(fid1, fid2, &dataset_id, &group_id1, &group_id2, &group_id3); /* Create more new files and test object count and ID list functions */ - test_obj_count_and_id(fid1, fid2, dataset_id, group_id1, - group_id2, group_id3); + test_obj_count_and_id(fid1, fid2, dataset_id, group_id1, group_id2, group_id3); /* Close first open */ ret = H5Fclose(fid1); @@ -873,7 +875,6 @@ test_file_close(void) ret = H5Gclose(group_id3); CHECK(ret, FAIL, "H5Gclose"); - /* Test behavior while opening file multiple times with file close * degree DEFAULT */ ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_DEFAULT); @@ -902,10 +903,10 @@ test_file_close(void) access_id = H5Fget_access_plist(fid1); CHECK(access_id, FAIL, "H5Fget_access_plist"); - ret= H5Pget_fclose_degree(access_id, &fc_degree); + ret = H5Pget_fclose_degree(access_id, &fc_degree); CHECK(ret, FAIL, "H5Pget_fclose_degree"); - switch(fc_degree) { + switch (fc_degree) { case H5F_CLOSE_STRONG: /* Close first open */ ret = H5Fclose(fid1); @@ -966,83 +967,83 @@ test_file_close(void) ** ****************************************************************/ static void -create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1, - hid_t *ret_gid2, hid_t *ret_gid3) +create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1, hid_t *ret_gid2, hid_t *ret_gid3) { - ssize_t oid_count; - herr_t ret; + ssize_t oid_count; + herr_t ret; /* Check reference counts of file IDs and opened object IDs. * The verification is hard-coded. If in any case, this testing * is changed, remember to check this part and update the macros. */ { - oid_count = H5Fget_obj_count(fid1, H5F_OBJ_ALL); - CHECK(oid_count, FAIL, "H5Fget_obj_count"); - VERIFY(oid_count, OBJ_ID_COUNT_2, "H5Fget_obj_count"); + oid_count = H5Fget_obj_count(fid1, H5F_OBJ_ALL); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, OBJ_ID_COUNT_2, "H5Fget_obj_count"); - oid_count = H5Fget_obj_count(fid1, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR); - CHECK(oid_count, FAIL, "H5Fget_obj_count"); - VERIFY(oid_count, OBJ_ID_COUNT_0, "H5Fget_obj_count"); + oid_count = H5Fget_obj_count(fid1, H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, OBJ_ID_COUNT_0, "H5Fget_obj_count"); - oid_count = H5Fget_obj_count(fid2, H5F_OBJ_ALL); - CHECK(oid_count, FAIL, "H5Fget_obj_count"); - VERIFY(oid_count, OBJ_ID_COUNT_2, "H5Fget_obj_count"); + oid_count = H5Fget_obj_count(fid2, H5F_OBJ_ALL); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, OBJ_ID_COUNT_2, "H5Fget_obj_count"); - oid_count = H5Fget_obj_count(fid2, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR); - CHECK(oid_count, FAIL, "H5Fget_obj_count"); - VERIFY(oid_count, OBJ_ID_COUNT_0, "H5Fget_obj_count"); + oid_count = H5Fget_obj_count(fid2, H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, OBJ_ID_COUNT_0, "H5Fget_obj_count"); } /* create a dataset in the first file open */ { - hid_t dataset_id, dataspace_id; /* identifiers */ - hsize_t dims[F2_RANK]; - unsigned data[F2_DIM0][F2_DIM1]; - unsigned i,j; - - /* Create the data space for the dataset. */ - dims[0] = F2_DIM0; - dims[1] = F2_DIM1; - dataspace_id = H5Screate_simple(F2_RANK, dims, NULL); - CHECK(dataspace_id, FAIL, "H5Screate_simple"); - - /* Create the dataset. */ - dataset_id = H5Dcreate2(fid1, "/dset", H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dataset_id, FAIL, "H5Dcreate2"); - - for(i = 0; i < F2_DIM0; i++) - for(j = 0; j < F2_DIM1; j++) - data[i][j] = i * 10 + j; - - /* Write data to the new dataset */ - ret = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - CHECK(ret, FAIL, "H5Dwrite"); - - if(ret_did != NULL) - *ret_did = dataset_id; - - /* Terminate access to the data space. */ - ret = H5Sclose(dataspace_id); - CHECK(ret, FAIL, "H5Sclose"); + hid_t dataset_id, dataspace_id; /* identifiers */ + hsize_t dims[F2_RANK]; + unsigned data[F2_DIM0][F2_DIM1]; + unsigned i, j; + + /* Create the data space for the dataset. */ + dims[0] = F2_DIM0; + dims[1] = F2_DIM1; + dataspace_id = H5Screate_simple(F2_RANK, dims, NULL); + CHECK(dataspace_id, FAIL, "H5Screate_simple"); + + /* Create the dataset. */ + dataset_id = + H5Dcreate2(fid1, "/dset", H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dataset_id, FAIL, "H5Dcreate2"); + + for (i = 0; i < F2_DIM0; i++) + for (j = 0; j < F2_DIM1; j++) + data[i][j] = i * 10 + j; + + /* Write data to the new dataset */ + ret = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + CHECK(ret, FAIL, "H5Dwrite"); + + if (ret_did != NULL) + *ret_did = dataset_id; + + /* Terminate access to the data space. */ + ret = H5Sclose(dataspace_id); + CHECK(ret, FAIL, "H5Sclose"); } /* Create a group in the second file open */ { - hid_t gid1, gid2, gid3; + hid_t gid1, gid2, gid3; gid1 = H5Gcreate2(fid2, "/group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid1, FAIL, "H5Gcreate2"); - if(ret_gid1 != NULL) + if (ret_gid1 != NULL) *ret_gid1 = gid1; gid2 = H5Gopen2(fid2, "/group", H5P_DEFAULT); CHECK(gid2, FAIL, "H5Gopen2"); - if(ret_gid2 != NULL) + if (ret_gid2 != NULL) *ret_gid2 = gid2; gid3 = H5Gopen2(fid2, "/group", H5P_DEFAULT); CHECK(gid3, FAIL, "H5Gopen2"); - if(ret_gid3 != NULL) + if (ret_gid3 != NULL) *ret_gid3 = gid3; } @@ -1051,21 +1052,21 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1, * is changed, remember to check this part and update the macros. */ { - oid_count = H5Fget_obj_count(fid1, H5F_OBJ_ALL); - CHECK(oid_count, FAIL, "H5Fget_obj_count"); - VERIFY(oid_count, OBJ_ID_COUNT_6, "H5Fget_obj_count"); + oid_count = H5Fget_obj_count(fid1, H5F_OBJ_ALL); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, OBJ_ID_COUNT_6, "H5Fget_obj_count"); - oid_count = H5Fget_obj_count(fid1, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR); - CHECK(oid_count, FAIL, "H5Fget_obj_count"); - VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count"); + oid_count = H5Fget_obj_count(fid1, H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count"); - oid_count = H5Fget_obj_count(fid2, H5F_OBJ_ALL); - CHECK(oid_count, FAIL, "H5Fget_obj_count"); - VERIFY(oid_count, OBJ_ID_COUNT_6, "H5Fget_obj_count"); + oid_count = H5Fget_obj_count(fid2, H5F_OBJ_ALL); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, OBJ_ID_COUNT_6, "H5Fget_obj_count"); - oid_count = H5Fget_obj_count(fid2, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR); - CHECK(oid_count, FAIL, "H5Fget_obj_count"); - VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count"); + oid_count = H5Fget_obj_count(fid2, H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count"); } } @@ -1080,35 +1081,35 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1, static void test_get_obj_ids(void) { - hid_t fid, gid[NGROUPS], dset[NDSETS]; - hid_t filespace; - hsize_t file_dims[F2_RANK] = {F2_DIM0, F2_DIM1}; - ssize_t oid_count, ret_count; - hid_t *oid_list = NULL; - herr_t ret; - int i, m, n; + hid_t fid, gid[NGROUPS], dset[NDSETS]; + hid_t filespace; + hsize_t file_dims[F2_RANK] = {F2_DIM0, F2_DIM1}; + ssize_t oid_count, ret_count; + hid_t * oid_list = NULL; + herr_t ret; + int i, m, n; ssize_t oid_list_size = NDSETS; - char gname[64], dname[64]; + char gname[64], dname[64]; /* Create a new file */ fid = H5Fcreate(FILE7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); - filespace = H5Screate_simple(F2_RANK, file_dims, NULL); + filespace = H5Screate_simple(F2_RANK, file_dims, NULL); CHECK(filespace, FAIL, "H5Screate_simple"); /* creates NGROUPS groups under the root group */ - for(m = 0; m < NGROUPS; m++) { + for (m = 0; m < NGROUPS; m++) { HDsprintf(gname, "group%d", m); gid[m] = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid[m], FAIL, "H5Gcreate2"); } /* create NDSETS datasets under the root group */ - for(n = 0; n < NDSETS; n++) { - HDsprintf(dname, "dataset%d", n); - dset[n] = H5Dcreate2(fid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset[n], FAIL, "H5Dcreate2"); + for (n = 0; n < NDSETS; n++) { + HDsprintf(dname, "dataset%d", n); + dset[n] = H5Dcreate2(fid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset[n], FAIL, "H5Dcreate2"); } /* The number of opened objects should be NGROUPS + NDSETS + 1. One is opened file. */ @@ -1128,8 +1129,8 @@ test_get_obj_ids(void) /* Close all object IDs on the list except the file ID. The first ID is supposed to be file ID according * to the library design */ - for(i = 0; i< ret_count; i++) { - if(fid != oid_list[i]) { + for (i = 0; i < ret_count; i++) { + if (fid != oid_list[i]) { ret = H5Oclose(oid_list[i]); CHECK(ret, FAIL, "H5Oclose"); } @@ -1147,8 +1148,8 @@ test_get_obj_ids(void) VERIFY(ret_count, oid_list_size, "H5Fget_obj_count"); /* Close all object IDs on the list except the file ID. The first ID is still the file ID */ - for(i = 0; i< ret_count; i++) { - if(fid != oid_list[i]) { + for (i = 0; i < ret_count; i++) { + if (fid != oid_list[i]) { ret = H5Oclose(oid_list[i]); CHECK(ret, FAIL, "H5Oclose"); } @@ -1165,10 +1166,10 @@ test_get_obj_ids(void) CHECK(fid, FAIL, "H5Fopen"); /* Open NDSETS datasets under the root group */ - for(n = 0; n < NDSETS; n++) { - HDsprintf(dname, "dataset%d", n); - dset[n] = H5Dopen2(fid, dname, H5P_DEFAULT); - CHECK(dset[n], FAIL, "H5Dcreate2"); + for (n = 0; n < NDSETS; n++) { + HDsprintf(dname, "dataset%d", n); + dset[n] = H5Dopen2(fid, dname, H5P_DEFAULT); + CHECK(dset[n], FAIL, "H5Dcreate2"); } /* Close the file first */ @@ -1188,8 +1189,8 @@ test_get_obj_ids(void) VERIFY(ret_count, NDSETS, "H5Fget_obj_count"); /* Close all open objects with H5Oclose */ - for(n = 0; n < oid_count; n++) - H5Oclose(oid_list[n]); + for (n = 0; n < oid_count; n++) + H5Oclose(oid_list[n]); HDfree(oid_list); } @@ -1202,12 +1203,12 @@ test_get_obj_ids(void) static void test_get_file_id(void) { - hid_t fid, fid2, fid3; - hid_t datatype_id, dataset_id, dataspace_id, group_id, attr_id; - hid_t plist; - hsize_t dims[F2_RANK]; - unsigned intent; - herr_t ret; + hid_t fid, fid2, fid3; + hid_t datatype_id, dataset_id, dataspace_id, group_id, attr_id; + hid_t plist; + hsize_t dims[F2_RANK]; + unsigned intent; + herr_t ret; /* Create a file */ fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1263,12 +1264,13 @@ test_get_file_id(void) /* Create a dataset in the group. Make a duplicated file ID from the * dataset. And close this duplicated ID. */ - dims[0] = F2_DIM0; - dims[1] = F2_DIM1; + dims[0] = F2_DIM0; + dims[1] = F2_DIM1; dataspace_id = H5Screate_simple(F2_RANK, dims, NULL); CHECK(dataspace_id, FAIL, "H5Screate_simple"); - dataset_id = H5Dcreate2(group_id, DSET_NAME, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id = + H5Dcreate2(group_id, DSET_NAME, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset_id, FAIL, "H5Dcreate2"); /* Test H5Iget_file_id() */ @@ -1301,9 +1303,11 @@ test_get_file_id(void) plist = H5Pcreate(H5P_FILE_ACCESS); CHECK(plist, FAIL, "H5Pcreate"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Iget_file_id(plist); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(fid2, FAIL, "H5Iget_file_id"); /* Close objects */ @@ -1337,15 +1341,15 @@ test_get_file_id(void) static void check_file_id(hid_t fid, hid_t object_id) { - hid_t new_fid; - herr_t ret; + hid_t new_fid; + herr_t ret; /* Return a duplicated file ID even not expecting user to do it. * And close this duplicated ID */ new_fid = H5Iget_file_id(object_id); - if(fid >=0) + if (fid >= 0) VERIFY(new_fid, fid, "H5Iget_file_id"); else CHECK(new_fid, FAIL, "H5Iget_file_id"); @@ -1360,12 +1364,11 @@ check_file_id(hid_t fid, hid_t object_id) ** ****************************************************************/ static void -test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, - hid_t gid2, hid_t gid3) +test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, hid_t gid2, hid_t gid3) { - hid_t fid3, fid4; - ssize_t oid_count, ret_count; - herr_t ret; + hid_t fid3, fid4; + ssize_t oid_count, ret_count; + herr_t ret; /* Create two new files */ fid3 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1403,30 +1406,29 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, CHECK(oid_count, FAIL, "H5Fget_obj_count"); VERIFY(oid_count, OBJ_ID_COUNT_8, "H5Fget_obj_count"); - if(oid_count > 0) { + if (oid_count > 0) { hid_t *oid_list; oid_list = (hid_t *)HDcalloc((size_t)oid_count, sizeof(hid_t)); - if(oid_list != NULL) { - int i; + if (oid_list != NULL) { + int i; - ret_count = H5Fget_obj_ids((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)oid_count, oid_list); - CHECK(ret_count, FAIL, "H5Fget_obj_ids"); + ret_count = H5Fget_obj_ids((hid_t)H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)oid_count, oid_list); + CHECK(ret_count, FAIL, "H5Fget_obj_ids"); - for(i = 0; i < oid_count; i++) { + for (i = 0; i < oid_count; i++) { H5I_type_t id_type; id_type = H5Iget_type(oid_list[i]); - switch(id_type) { + switch (id_type) { case H5I_FILE: - if(oid_list[i] != fid1 && oid_list[i] != fid2 - && oid_list[i] != fid3 && oid_list[i] != fid4) + if (oid_list[i] != fid1 && oid_list[i] != fid2 && oid_list[i] != fid3 && + oid_list[i] != fid4) ERROR("H5Fget_obj_ids"); break; case H5I_GROUP: - if(oid_list[i] != gid1 && oid_list[i] != gid2 - && oid_list[i] != gid3) + if (oid_list[i] != gid1 && oid_list[i] != gid2 && oid_list[i] != gid3) ERROR("H5Fget_obj_ids"); break; @@ -1454,11 +1456,11 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, default: ERROR("H5Fget_obj_ids"); } /* end switch */ - } /* end for */ + } /* end for */ HDfree(oid_list); } /* end if */ - } /* end if */ + } /* end if */ /* close the two new files */ ret = H5Fclose(fid3); @@ -1478,11 +1480,11 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, static void test_file_perm(void) { - hid_t file; /* File opened with read-write permission */ - hid_t filero; /* Same file opened with read-only permission */ - hid_t dspace; /* Dataspace ID */ - hid_t dset; /* Dataset ID */ - herr_t ret; + hid_t file; /* File opened with read-write permission */ + hid_t filero; /* Same file opened with read-only permission */ + hid_t dspace; /* Dataspace ID */ + hid_t dset; /* Dataset ID */ + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File Permissions\n")); @@ -1506,11 +1508,13 @@ test_file_perm(void) CHECK(filero, FAIL, "H5Fopen"); /* Create a dataset with the read-only file handle (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset = H5Dcreate2(filero, F2_DSET, H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(dset, FAIL, "H5Dcreate2"); - if(dset!=FAIL) { + if (dset != FAIL) { ret = H5Dclose(dset); CHECK(ret, FAIL, "H5Dclose"); } /* end if */ @@ -1536,14 +1540,14 @@ test_file_perm(void) static void test_file_perm2(void) { - hid_t file; /* File opened with read-write permission */ - hid_t filero; /* Same file opened with read-only permission */ - hid_t dspace; /* Dataspace ID */ - hid_t group; /* Group ID */ - hid_t dset; /* Dataset ID */ - hid_t type; /* Datatype ID */ - hid_t attr; /* Attribute ID */ - herr_t ret; + hid_t file; /* File opened with read-write permission */ + hid_t filero; /* Same file opened with read-only permission */ + hid_t dspace; /* Dataspace ID */ + hid_t group; /* Group ID */ + hid_t dset; /* Dataset ID */ + hid_t type; /* Datatype ID */ + hid_t attr; /* Attribute ID */ + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File Permissions again\n")); @@ -1563,30 +1567,38 @@ test_file_perm2(void) CHECK(filero, FAIL, "H5Fopen"); /* Create a group with the read-only file handle (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { group = H5Gcreate2(filero, "MY_GROUP", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(group, FAIL, "H5Gcreate2"); /* Create a dataset with the read-only file handle (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset = H5Dcreate2(filero, F2_DSET, H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(dset, FAIL, "H5Dcreate2"); /* Create an attribute with the read-only file handle (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { attr = H5Acreate2(filero, "MY_ATTR", H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(attr, FAIL, "H5Acreate2"); type = H5Tcopy(H5T_NATIVE_SHORT); CHECK(type, FAIL, "H5Tcopy"); /* Commit a datatype with the read-only file handle (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tcommit2(filero, "MY_DTYPE", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Tcommit2"); ret = H5Tclose(type); @@ -1599,7 +1611,6 @@ test_file_perm2(void) CHECK(ret, FAIL, "H5Sclose"); } /* end test_file_perm2() */ - /**************************************************************** ** ** test_file_is_accessible(): low-level file test routine. @@ -1607,22 +1618,22 @@ test_file_perm2(void) ** H5Fis_accessible() API call. ** *****************************************************************/ -#define FILE_IS_ACCESSIBLE "tfile_is_accessible" +#define FILE_IS_ACCESSIBLE "tfile_is_accessible" static void test_file_is_accessible(const char *env_h5_drvr) { - hid_t fid = H5I_INVALID_HID; /* File opened with read-write permission */ - hid_t fcpl_id = H5I_INVALID_HID; /* File creation property list */ - hid_t fapl_id = H5I_INVALID_HID; /* File access property list */ - int fd; /* POSIX file descriptor */ - char filename[FILENAME_LEN]; /* Filename to use */ - char sb_filename[FILENAME_LEN]; /* Name of file w/ superblock */ - ssize_t nbytes; /* Number of bytes written */ - unsigned u; /* Local index variable */ - unsigned char buf[1024]; /* Buffer of data to write */ - htri_t is_hdf5; /* Whether a file is an HDF5 file */ - int posix_ret; /* Return value from POSIX calls */ - herr_t ret; /* Return value from HDF5 calls */ + hid_t fid = H5I_INVALID_HID; /* File opened with read-write permission */ + hid_t fcpl_id = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl_id = H5I_INVALID_HID; /* File access property list */ + int fd; /* POSIX file descriptor */ + char filename[FILENAME_LEN]; /* Filename to use */ + char sb_filename[FILENAME_LEN]; /* Name of file w/ superblock */ + ssize_t nbytes; /* Number of bytes written */ + unsigned u; /* Local index variable */ + unsigned char buf[1024]; /* Buffer of data to write */ + htri_t is_hdf5; /* Whether a file is an HDF5 file */ + int posix_ret; /* Return value from POSIX calls */ + herr_t ret; /* Return value from HDF5 calls */ /* Output message about test being performed */ MESSAGE(5, ("Testing Detection of HDF5 Files\n")); @@ -1662,7 +1673,7 @@ test_file_is_accessible(const char *env_h5_drvr) /* This test is not currently working for the family VFD. * There are failures when creating files with userblocks. */ - if(0 != HDstrcmp(env_h5_drvr, "family")) { + if (0 != HDstrcmp(env_h5_drvr, "family")) { /* Create a file creation property list with a non-default user block size */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl_id, H5I_INVALID_HID, "H5Pcreate"); @@ -1713,7 +1724,7 @@ test_file_is_accessible(const char *env_h5_drvr) /* Initialize information to write */ for (u = 0; u < 1024; u++) - buf[u]=(unsigned char)u; + buf[u] = (unsigned char)u; /* Write some information */ nbytes = HDwrite(fd, buf, (size_t)1024); @@ -1727,7 +1738,6 @@ test_file_is_accessible(const char *env_h5_drvr) is_hdf5 = H5Fis_accessible(filename, fapl_id); VERIFY(is_hdf5, FALSE, "H5Fis_accessible (non-HDF5 file)"); - /* Clean up files */ h5_delete_test_file(filename, fapl_id); @@ -1737,7 +1747,6 @@ test_file_is_accessible(const char *env_h5_drvr) } /* end test_file_is_accessible() */ - /**************************************************************** ** ** test_file_ishdf5(): low-level file test routine. @@ -1749,18 +1758,18 @@ test_file_is_accessible(const char *env_h5_drvr) static void test_file_ishdf5(const char *env_h5_drvr) { - hid_t fid = H5I_INVALID_HID; /* File opened with read-write permission */ - hid_t fcpl_id = H5I_INVALID_HID; /* File creation property list */ - hid_t fapl_id = H5I_INVALID_HID; /* File access property list */ - int fd; /* POSIX file descriptor */ - char filename[FILENAME_LEN]; /* Filename to use */ - char sb_filename[FILENAME_LEN]; /* Name of file w/ superblock */ - ssize_t nbytes; /* Number of bytes written */ - unsigned u; /* Local index variable */ - unsigned char buf[1024]; /* Buffer of data to write */ - htri_t is_hdf5; /* Whether a file is an HDF5 file */ - int posix_ret; /* Return value from POSIX calls */ - herr_t ret; /* Return value from HDF5 calls */ + hid_t fid = H5I_INVALID_HID; /* File opened with read-write permission */ + hid_t fcpl_id = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl_id = H5I_INVALID_HID; /* File access property list */ + int fd; /* POSIX file descriptor */ + char filename[FILENAME_LEN]; /* Filename to use */ + char sb_filename[FILENAME_LEN]; /* Name of file w/ superblock */ + ssize_t nbytes; /* Number of bytes written */ + unsigned u; /* Local index variable */ + unsigned char buf[1024]; /* Buffer of data to write */ + htri_t is_hdf5; /* Whether a file is an HDF5 file */ + int posix_ret; /* Return value from POSIX calls */ + herr_t ret; /* Return value from HDF5 calls */ /* Output message about test being performed */ MESSAGE(5, ("Testing Detection of HDF5 Files (using deprecated H5Fis_hdf5() call)\n")); @@ -1800,7 +1809,7 @@ test_file_ishdf5(const char *env_h5_drvr) /* This test is not currently working for the family VFD. * There are failures when creating files with userblocks. */ - if(0 != HDstrcmp(env_h5_drvr, "family")) { + if (0 != HDstrcmp(env_h5_drvr, "family")) { /* Create a file creation property list with a non-default user block size */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl_id, H5I_INVALID_HID, "H5Pcreate"); @@ -1837,8 +1846,8 @@ test_file_ishdf5(const char *env_h5_drvr) CHECK(fd, (-1), "HDopen"); /* Initialize information to write */ - for(u = 0; u < 1024; u++) - buf[u]=(unsigned char)u; + for (u = 0; u < 1024; u++) + buf[u] = (unsigned char)u; /* Write some information */ nbytes = HDwrite(fd, buf, (size_t)1024); @@ -1852,7 +1861,6 @@ test_file_ishdf5(const char *env_h5_drvr) is_hdf5 = H5Fis_hdf5(sb_filename); VERIFY(is_hdf5, FALSE, "H5Fis_hdf5"); - /* Clean up files */ h5_delete_test_file(filename, fapl_id); @@ -1863,23 +1871,22 @@ test_file_ishdf5(const char *env_h5_drvr) } /* end test_file_ishdf5() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /**************************************************************** ** ** test_file_delete(): tests H5Fdelete for all VFDs ** *****************************************************************/ -#define FILE_DELETE "test_file_delete" -#define FILE_DELETE_NOT_HDF5 "test_file_delete_not_hdf5" +#define FILE_DELETE "test_file_delete" +#define FILE_DELETE_NOT_HDF5 "test_file_delete_not_hdf5" static void test_file_delete(hid_t fapl_id) { - hid_t fid = H5I_INVALID_HID; /* File to be deleted */ - char filename[FILENAME_LEN]; /* Filename to use */ - htri_t is_hdf5; /* Whether a file is an HDF5 file */ - int fd; /* POSIX file descriptor */ - int iret; - herr_t ret; + hid_t fid = H5I_INVALID_HID; /* File to be deleted */ + char filename[FILENAME_LEN]; /* Filename to use */ + htri_t is_hdf5; /* Whether a file is an HDF5 file */ + int fd; /* POSIX file descriptor */ + int iret; + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing Deletion of HDF5 Files\n")); @@ -1908,9 +1915,11 @@ test_file_delete(hid_t fapl_id) VERIFY(is_hdf5, TRUE, "H5Fis_accessible"); /* Attempt to delete the file - should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fdelete(filename, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Fdelete"); /* Verify that the file still exists */ @@ -1941,15 +1950,19 @@ test_file_delete(hid_t fapl_id) * may not have been created since we created it with * open(2) and not the library. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { is_hdf5 = H5Fis_accessible(filename, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; CHECK(is_hdf5, TRUE, "H5Fis_accessible"); /* Try to delete it (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fdelete(filename, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Fdelete"); /* Delete the file */ @@ -1958,7 +1971,6 @@ test_file_delete(hid_t fapl_id) } /* end test_file_delete() */ - /**************************************************************** ** ** test_file_open_dot(): low-level file test routine. @@ -1969,12 +1981,12 @@ test_file_delete(hid_t fapl_id) static void test_file_open_dot(void) { - hid_t fid; /* File ID */ - hid_t gid, gid2; /* Group IDs */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid, tid2; /* Datatype IDs */ - herr_t ret; + hid_t fid; /* File ID */ + hid_t gid, gid2; /* Group IDs */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid, tid2; /* Datatype IDs */ + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing opening objects with \".\" for a name\n")); @@ -1992,27 +2004,35 @@ test_file_open_dot(void) CHECK(sid, FAIL, "H5Screate"); /* Create a dataset with no name using the file ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dcreate2(fid, ".", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(did, FAIL, "H5Dcreate2"); /* Create a dataset with no name using the group ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dcreate2(gid, ".", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(did, FAIL, "H5Dcreate2"); /* Open a dataset with no name using the file ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dopen2(fid, ".", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(did, FAIL, "H5Dopen2"); /* Open a dataset with no name using the group ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dopen2(gid, ".", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(did, FAIL, "H5Dopen2"); /* Make a copy of a datatype to use for creating a named datatype */ @@ -2020,39 +2040,51 @@ test_file_open_dot(void) CHECK(tid, FAIL, "H5Tcopy"); /* Create a named datatype with no name using the file ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tcommit2(fid, ".", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Tcommit2"); /* Create a named datatype with no name using the group ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tcommit2(gid, ".", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Tcommit2"); /* Open a named datatype with no name using the file ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tid2 = H5Topen2(fid, ".", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tid2, FAIL, "H5Topen2"); /* Open a named datatype with no name using the group ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tid2 = H5Topen2(gid, ".", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tid2, FAIL, "H5Topen2"); /* Create a group with no name using the file ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid2 = H5Gcreate2(fid, ".", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(gid2, FAIL, "H5Gcreate2"); /* Create a group with no name using the group ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid2 = H5Gcreate2(gid, ".", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(gid2, FAIL, "H5Gcreate2"); /* Open a group with no name using the file ID (should open the root group) */ @@ -2069,7 +2101,6 @@ test_file_open_dot(void) ret = H5Gclose(gid2); CHECK(ret, FAIL, "H5Gclose"); - /* Close everything */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); @@ -2092,14 +2123,14 @@ test_file_open_dot(void) static void test_file_open_overlap(void) { - hid_t fid1, fid2; - hid_t did1, did2; - hid_t gid; - hid_t sid; - ssize_t nobjs; /* # of open objects */ - unsigned intent; - unsigned long fileno1, fileno2; /* File number */ - herr_t ret; /* Generic return value */ + hid_t fid1, fid2; + hid_t did1, did2; + hid_t gid; + hid_t sid; + ssize_t nobjs; /* # of open objects */ + unsigned intent; + unsigned long fileno1, fileno2; /* File number */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing opening overlapping file opens\n")); @@ -2119,10 +2150,10 @@ test_file_open_overlap(void) /* Check the file numbers */ fileno1 = 0; - ret = H5Fget_fileno(fid1, &fileno1); + ret = H5Fget_fileno(fid1, &fileno1); CHECK(ret, FAIL, "H5Fget_fileno"); fileno2 = 0; - ret = H5Fget_fileno(fid2, &fileno2); + ret = H5Fget_fileno(fid2, &fileno2); CHECK(ret, FAIL, "H5Fget_fileno"); VERIFY(fileno1, fileno2, "H5Fget_fileno"); @@ -2143,8 +2174,8 @@ test_file_open_overlap(void) CHECK(did1, FAIL, "H5Dcreate2"); /* Check number of objects opened in first file */ - nobjs = H5Fget_obj_count(fid1, H5F_OBJ_LOCAL|H5F_OBJ_ALL); - VERIFY(nobjs, 3, "H5Fget_obj_count"); /* 3 == file, dataset & group */ + nobjs = H5Fget_obj_count(fid1, H5F_OBJ_LOCAL | H5F_OBJ_ALL); + VERIFY(nobjs, 3, "H5Fget_obj_count"); /* 3 == file, dataset & group */ /* Close dataset */ ret = H5Dclose(did1); @@ -2158,14 +2189,13 @@ test_file_open_overlap(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Create dataset with second file ID */ did2 = H5Dcreate2(fid2, DSET2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(did2, FAIL, "H5Dcreate2"); /* Check number of objects opened in first file */ nobjs = H5Fget_obj_count(fid2, H5F_OBJ_ALL); - VERIFY(nobjs, 2, "H5Fget_obj_count"); /* 3 == file & dataset */ + VERIFY(nobjs, 2, "H5Fget_obj_count"); /* 3 == file & dataset */ /* Close dataspace */ ret = H5Sclose(sid); @@ -2204,13 +2234,13 @@ test_file_getname(void) hsize_t dims[TESTA_RANK] = {TESTA_NX, TESTA_NY}; char name[TESTA_NAME_BUF_SIZE]; ssize_t name_len; - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing H5Fget_name() functionality\n")); /* Create a new file_id using default properties. */ - file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); + file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file_id, FAIL, "H5Fcreate"); /* Get and verify file name */ @@ -2233,13 +2263,16 @@ test_file_getname(void) /* Try get file name from data space. Supposed to fail because * it's illegal operation. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { name_len = H5Fget_name(space_id, name, (size_t)TESTA_NAME_BUF_SIZE); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(name_len, FAIL, "H5Fget_name"); /* Create a new dataset */ - dataset_id = H5Dcreate2(file_id, TESTA_DSETNAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id = + H5Dcreate2(file_id, TESTA_DSETNAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset_id, FAIL, "H5Dcreate2"); /* Get and verify file name */ @@ -2261,10 +2294,10 @@ test_file_getname(void) CHECK(type_id, FAIL, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert (type_id, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(type_id, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert (type_id, "b", HOFFSET(s1_t,b), H5T_NATIVE_FLOAT); + ret = H5Tinsert(type_id, "b", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save it on file */ @@ -2307,21 +2340,21 @@ test_file_getname(void) static void test_file_double_root_open(void) { - hid_t file1_id, file2_id; - hid_t grp1_id, grp2_id; - herr_t ret; /* Generic return value */ + hid_t file1_id, file2_id; + hid_t grp1_id, grp2_id; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing double root group open\n")); file1_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file1_id, FAIL, "H5Fcreate"); - file2_id = H5Fopen (FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + file2_id = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file2_id, FAIL, "H5Fopen"); - grp1_id = H5Gopen2(file1_id, "/", H5P_DEFAULT); + grp1_id = H5Gopen2(file1_id, "/", H5P_DEFAULT); CHECK(grp1_id, FAIL, "H5Gopen2"); - grp2_id = H5Gopen2(file2_id, "/", H5P_DEFAULT); + grp2_id = H5Gopen2(file2_id, "/", H5P_DEFAULT); CHECK(grp2_id, FAIL, "H5Gopen2"); /* Note "assymetric" close order */ @@ -2346,21 +2379,21 @@ test_file_double_root_open(void) static void test_file_double_group_open(void) { - hid_t file1_id, file2_id; - hid_t grp1_id, grp2_id; - herr_t ret; /* Generic return value */ + hid_t file1_id, file2_id; + hid_t grp1_id, grp2_id; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing double non-root group open\n")); file1_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file1_id, FAIL, "H5Fcreate"); - file2_id = H5Fopen (FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + file2_id = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file2_id, FAIL, "H5Fopen"); - grp1_id = H5Gcreate2(file1_id, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + grp1_id = H5Gcreate2(file1_id, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(grp1_id, FAIL, "H5Gcreate2"); - grp2_id = H5Gopen2(file2_id, GRP_NAME, H5P_DEFAULT); + grp2_id = H5Gopen2(file2_id, GRP_NAME, H5P_DEFAULT); CHECK(grp2_id, FAIL, "H5Gopen2"); /* Note "assymetric" close order */ @@ -2385,26 +2418,27 @@ test_file_double_group_open(void) static void test_file_double_dataset_open(void) { - hid_t file1_id, file2_id; - hid_t dset1_id, dset2_id; - hid_t space_id; - herr_t ret; /* Generic return value */ + hid_t file1_id, file2_id; + hid_t dset1_id, dset2_id; + hid_t space_id; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing double dataset open\n")); file1_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file1_id, FAIL, "H5Fcreate"); - file2_id = H5Fopen (FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + file2_id = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file2_id, FAIL, "H5Fopen"); /* Create dataspace for dataset */ space_id = H5Screate(H5S_SCALAR); CHECK(space_id, FAIL, "H5Screate"); - dset1_id = H5Dcreate2(file1_id, DSET_NAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset1_id = + H5Dcreate2(file1_id, DSET_NAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset1_id, FAIL, "H5Dcreate2"); - dset2_id = H5Dopen2(file2_id, DSET_NAME, H5P_DEFAULT); + dset2_id = H5Dopen2(file2_id, DSET_NAME, H5P_DEFAULT); CHECK(dset2_id, FAIL, "H5Dopen2"); /* Close "supporting" dataspace */ @@ -2436,26 +2470,27 @@ test_file_double_dataset_open(void) static void test_file_double_file_dataset_open(hbool_t new_format) { - hid_t fapl = -1; /* File access property list */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t did1 = -1, did2 = -1; /* Dataset IDs */ - hid_t sid1 = -1, sid2 = -1; /* Dataspace IDs */ - hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */ - hsize_t dims[1] = {5}, dims2[2] = {1, 4}; /* Dimension sizes */ - hsize_t e_ext_dims[1] = {7}; /* Expanded dimension sizes */ - hsize_t s_ext_dims[1] = {3}; /* Shrunk dimension sizes */ - hsize_t max_dims0[1] = {8}; /* Maximum dimension sizes */ - hsize_t max_dims1[1] = {H5S_UNLIMITED}; /* Maximum dimesion sizes for extensible array index */ - hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes for v2 B-tree index */ - hsize_t chunks[1] = {2}, chunks2[2] = {4, 5}; /* Chunk dimension sizes */ - hsize_t size; /* File size */ - char filename[FILENAME_LEN]; /* Filename to use */ - const char* data[] = {"String 1", "String 2", "String 3", "String 4", "String 5"}; /* Input Data */ - const char* e_data[] = {"String 1", "String 2", "String 3", "String 4", "String 5", "String 6", "String 7"}; /* Input Data */ - char* buffer[5]; /* Output buffer */ - int wbuf[4] = {1, 2, 3, 4}; /* Input data */ - herr_t ret; /* Generic return value */ + hid_t fapl = -1; /* File access property list */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t did1 = -1, did2 = -1; /* Dataset IDs */ + hid_t sid1 = -1, sid2 = -1; /* Dataspace IDs */ + hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */ + hsize_t dims[1] = {5}, dims2[2] = {1, 4}; /* Dimension sizes */ + hsize_t e_ext_dims[1] = {7}; /* Expanded dimension sizes */ + hsize_t s_ext_dims[1] = {3}; /* Shrunk dimension sizes */ + hsize_t max_dims0[1] = {8}; /* Maximum dimension sizes */ + hsize_t max_dims1[1] = {H5S_UNLIMITED}; /* Maximum dimesion sizes for extensible array index */ + hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes for v2 B-tree index */ + hsize_t chunks[1] = {2}, chunks2[2] = {4, 5}; /* Chunk dimension sizes */ + hsize_t size; /* File size */ + char filename[FILENAME_LEN]; /* Filename to use */ + const char *data[] = {"String 1", "String 2", "String 3", "String 4", "String 5"}; /* Input Data */ + const char *e_data[] = {"String 1", "String 2", "String 3", "String 4", + "String 5", "String 6", "String 7"}; /* Input Data */ + char * buffer[5]; /* Output buffer */ + int wbuf[4] = {1, 2, 3, 4}; /* Input data */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing double file and dataset open/close\n")); @@ -2463,7 +2498,7 @@ test_file_double_file_dataset_open(hbool_t new_format) /* Setting up test file */ fapl = h5_fileaccess(); CHECK(fapl, FAIL, "H5Pcreate"); - if(new_format) { + if (new_format) { ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); CHECK(ret, FAIL, "H5Pset_libver_bounds"); } /* end if */ @@ -2579,7 +2614,7 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(fid2, FAIL, "H5Fopen"); /* Second file's dataset open */ - did2 = H5Dopen2(fid2, "/dset_fa", H5P_DEFAULT ); + did2 = H5Dopen2(fid2, "/dset_fa", H5P_DEFAULT); CHECK(did2, FAIL, "H5Dopen2"); tid2 = H5Tcopy(did2); @@ -2624,7 +2659,7 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(fid2, FAIL, "H5Fopen"); /* Second file's dataset open */ - did2 = H5Dopen2(fid2, "/dset_ea", H5P_DEFAULT ); + did2 = H5Dopen2(fid2, "/dset_ea", H5P_DEFAULT); CHECK(did2, FAIL, "H5Dopen2"); tid2 = H5Tcopy(did2); @@ -2638,7 +2673,7 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(tid1, FAIL, "H5Tcopy"); /* Second file's dataset read */ - HDmemset(buffer, 0, sizeof(char*) * 5); + HDmemset(buffer, 0, sizeof(char *) * 5); ret = H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer); CHECK(ret, FAIL, "H5Dread"); ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, buffer); @@ -2653,7 +2688,7 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(ret, FAIL, "H5Fclose"); /* First file's dataset read */ - HDmemset(buffer, 0, sizeof(char*) * 5); + HDmemset(buffer, 0, sizeof(char *) * 5); ret = H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer); CHECK(ret, FAIL, "H5Dread"); ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, buffer); @@ -2697,7 +2732,7 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(fid2, FAIL, "H5Fopen"); /* Second file's dataset open */ - did2 = H5Dopen2(fid2, "/dset_bt2", H5P_DEFAULT ); + did2 = H5Dopen2(fid2, "/dset_bt2", H5P_DEFAULT); CHECK(did2, FAIL, "H5Dopen2"); /* First file's dataset close */ @@ -2723,7 +2758,8 @@ test_file_double_file_dataset_open(hbool_t new_format) /* * Scenario 4 * --trigger H5AC_protect: Assertion `f->shared' failed - * from second call to H5Dset_extent->...H5D__earray_idx_remove->H5EA_get...H5EA__iblock_protect...H5AC_protect + * from second call to + * H5Dset_extent->...H5D__earray_idx_remove->H5EA_get...H5EA__iblock_protect...H5AC_protect */ /* First file open */ fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl); @@ -2749,7 +2785,7 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(fid2, FAIL, "H5Fopen"); /* Second file's dataset open */ - did2 = H5Dopen2(fid2, "/dset_ea", H5P_DEFAULT ); + did2 = H5Dopen2(fid2, "/dset_ea", H5P_DEFAULT); CHECK(did2, FAIL, "H5Dopen2"); /* First file's dataset close */ @@ -2791,23 +2827,23 @@ test_file_double_file_dataset_open(hbool_t new_format) static void test_file_double_datatype_open(void) { - hid_t file1_id, file2_id; - hid_t type1_id, type2_id; - herr_t ret; /* Generic return value */ + hid_t file1_id, file2_id; + hid_t type1_id, type2_id; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing double dataset open\n")); file1_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file1_id, FAIL, "H5Fcreate"); - file2_id = H5Fopen (FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + file2_id = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file2_id, FAIL, "H5Fopen"); - type1_id = H5Tcopy(H5T_NATIVE_INT); + type1_id = H5Tcopy(H5T_NATIVE_INT); CHECK(type1_id, FAIL, "H5Tcopy"); - ret = H5Tcommit2(file1_id, TYPE_NAME, type1_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Tcommit2(file1_id, TYPE_NAME, type1_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); - type2_id = H5Topen2(file2_id, TYPE_NAME, H5P_DEFAULT); + type2_id = H5Topen2(file2_id, TYPE_NAME, H5P_DEFAULT); CHECK(type2_id, FAIL, "H5Topen2"); /* Note "assymetric" close order */ @@ -2836,15 +2872,15 @@ test_file_double_datatype_open(void) static void test_userblock_file_size(void) { - hid_t file1_id, file2_id; - hid_t group1_id, group2_id; - hid_t dset1_id, dset2_id; - hid_t space_id; - hid_t fcpl2_id; - hsize_t dims[2] = {3, 4}; - hsize_t filesize1, filesize2, filesize; - unsigned long fileno1, fileno2; /* File number */ - herr_t ret; /* Generic return value */ + hid_t file1_id, file2_id; + hid_t group1_id, group2_id; + hid_t dset1_id, dset2_id; + hid_t space_id; + hid_t fcpl2_id; + hsize_t dims[2] = {3, 4}; + hsize_t filesize1, filesize2, filesize; + unsigned long fileno1, fileno2; /* File number */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing file size with user block\n")); @@ -2863,10 +2899,10 @@ test_userblock_file_size(void) /* Check the file numbers */ fileno1 = 0; - ret = H5Fget_fileno(file1_id, &fileno1); + ret = H5Fget_fileno(file1_id, &fileno1); CHECK(ret, FAIL, "H5Fget_fileno"); fileno2 = 0; - ret = H5Fget_fileno(file2_id, &fileno2); + ret = H5Fget_fileno(file2_id, &fileno2); CHECK(ret, FAIL, "H5Fget_fileno"); CHECK(fileno1, fileno2, "H5Fget_fileno"); @@ -2919,7 +2955,8 @@ test_userblock_file_size(void) CHECK(ret, FAIL, "H5Fget_filesize"); /* Verify that the file sizes differ exactly by the userblock size */ - VERIFY_TYPE((unsigned long long)filesize2, (unsigned long long)(filesize1 + USERBLOCK_SIZE), unsigned long long, "%llu", "H5Fget_filesize"); + VERIFY_TYPE((unsigned long long)filesize2, (unsigned long long)(filesize1 + USERBLOCK_SIZE), + unsigned long long, "%llu", "H5Fget_filesize"); /* Close files */ ret = H5Fclose(file1_id); @@ -2960,9 +2997,9 @@ test_userblock_file_size(void) static void test_cached_stab_info(void) { - hid_t file_id; - hid_t group_id; - herr_t ret; /* Generic return value */ + hid_t file_id; + hid_t group_id; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing cached symbol table information\n")); @@ -3001,12 +3038,12 @@ test_cached_stab_info(void) static int cal_chksum(const char *file, uint32_t *chksum) { - int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */ - int fdes = -1; /* File descriptor */ - void *file_data = NULL; /* Copy of file data */ - ssize_t bytes_read; /* # of bytes read */ + int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */ + int fdes = -1; /* File descriptor */ + void * file_data = NULL; /* Copy of file data */ + ssize_t bytes_read; /* # of bytes read */ h5_stat_t sb; /* Stat buffer for file */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Open the file */ fdes = HDopen(file, O_RDONLY); @@ -3020,7 +3057,7 @@ cal_chksum(const char *file, uint32_t *chksum) file_data = HDmalloc((size_t)sb.st_size); CHECK_PTR(file_data, "HDmalloc"); - if(file_data) { + if (file_data) { /* Read file's data into memory */ bytes_read = HDread(fdes, file_data, (size_t)sb.st_size); CHECK(bytes_read == sb.st_size, FALSE, "HDmalloc"); @@ -3036,7 +3073,7 @@ cal_chksum(const char *file, uint32_t *chksum) ret = HDclose(fdes); CHECK(ret, FAIL, "HDclose"); - return((GetTestNumErrs() == curr_num_errs) ? 0 : -1); + return ((GetTestNumErrs() == curr_num_errs) ? 0 : -1); } /* cal_chksum() */ /**************************************************************** @@ -3055,9 +3092,9 @@ cal_chksum(const char *file, uint32_t *chksum) static void test_rw_noupdate(void) { - herr_t ret; /* Generic return value */ - hid_t fid; /* File ID */ - uint32_t chksum1, chksum2; /* Checksum value */ + herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + uint32_t chksum1, chksum2; /* Checksum value */ /* Output message about test being performed */ MESSAGE(5, ("Testing to verify that nothing is written if nothing is changed.\n")); @@ -3104,20 +3141,20 @@ test_rw_noupdate(void) static int test_userblock_alignment_helper1(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */ + herr_t ret; /* Generic return value */ /* Create a file with FAPL & FCPL */ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fcreate"); /* Only proceed further if file ID is OK */ - if(fid > 0) { - hid_t gid; /* Group ID */ - hid_t sid; /* Dataspace ID */ - hid_t did; /* Dataset ID */ - int val = 2; /* Dataset value */ + if (fid > 0) { + hid_t gid; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ + int val = 2; /* Dataset value */ /* Create a group */ gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -3150,7 +3187,7 @@ test_userblock_alignment_helper1(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); } /* end if */ - return((GetTestNumErrs() == curr_num_errs) ? 0 : -1); + return ((GetTestNumErrs() == curr_num_errs) ? 0 : -1); } /* end test_userblock_alignment_helper1() */ /**************************************************************** @@ -3166,19 +3203,19 @@ test_userblock_alignment_helper1(hid_t fcpl, hid_t fapl) static int test_userblock_alignment_helper2(hid_t fapl, hbool_t open_rw) { - hid_t fid; /* File ID */ - int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */ + herr_t ret; /* Generic return value */ /* Re-open file */ fid = H5Fopen(FILE1, (open_rw ? H5F_ACC_RDWR : H5F_ACC_RDONLY), fapl); CHECK(fid, FAIL, "H5Fopen"); /* Only proceed further if file ID is OK */ - if(fid > 0) { + if (fid > 0) { hid_t gid; /* Group ID */ hid_t did; /* Dataset ID */ - int val = -1; /* Dataset value */ + int val = -1; /* Dataset value */ /* Open group */ gid = H5Gopen2(fid, "group1", H5P_DEFAULT); @@ -3198,8 +3235,8 @@ test_userblock_alignment_helper2(hid_t fapl, hbool_t open_rw) CHECK(ret, FAIL, "H5Dclose"); /* Only create new objects if file is open R/W */ - if(open_rw) { - hid_t gid2; /* Group ID */ + if (open_rw) { + hid_t gid2; /* Group ID */ /* Create a new group */ gid2 = H5Gcreate2(gid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -3219,7 +3256,7 @@ test_userblock_alignment_helper2(hid_t fapl, hbool_t open_rw) CHECK(ret, FAIL, "H5Fclose"); } /* end if */ - return((GetTestNumErrs() == curr_num_errs) ? 0 : -1); + return ((GetTestNumErrs() == curr_num_errs) ? 0 : -1); } /* end test_userblock_alignment_helper2() */ /**************************************************************** @@ -3236,10 +3273,10 @@ test_userblock_alignment_helper2(hid_t fapl, hbool_t open_rw) static void test_userblock_alignment(void) { - hid_t fid; /* File ID */ - hid_t fcpl; /* File creation property list ID */ - hid_t fapl; /* File access property list ID */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t fcpl; /* File creation property list ID */ + hid_t fapl; /* File access property list ID */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing that non-zero userblocks and object alignment interact correctly.\n")); @@ -3273,7 +3310,6 @@ test_userblock_alignment(void) ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); - /* Case 2: * Userblock size = 512, alignment = 16 * (userblock is integral mult. of alignment) @@ -3304,7 +3340,6 @@ test_userblock_alignment(void) ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); - /* Case 3: * Userblock size = 512, alignment = 512 * (userblock is equal to alignment) @@ -3335,7 +3370,6 @@ test_userblock_alignment(void) ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); - /* Case 4: * Userblock size = 512, alignment = 3 * (userblock & alignment each individually valid, but userblock is @@ -3356,9 +3390,11 @@ test_userblock_alignment(void) CHECK(ret, FAIL, "H5Pset_alignment"); /* Create a file with FAPL & FCPL */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(fid, FAIL, "H5Fcreate"); /* Release property lists */ @@ -3367,7 +3403,6 @@ test_userblock_alignment(void) ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); - /* Case 5: * Userblock size = 512, alignment = 1024 * (userblock & alignment each individually valid, but userblock is @@ -3388,9 +3423,11 @@ test_userblock_alignment(void) CHECK(ret, FAIL, "H5Pset_alignment"); /* Create a file with FAPL & FCPL */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(fid, FAIL, "H5Fcreate"); /* Release property lists */ @@ -3399,7 +3436,6 @@ test_userblock_alignment(void) ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); - /* Case 6: * File created with: * Userblock size = 512, alignment = 512 @@ -3455,13 +3491,14 @@ test_userblock_alignment(void) static void test_userblock_alignment_paged(void) { - hid_t fid; /* File ID */ - hid_t fcpl; /* File creation property list ID */ - hid_t fapl; /* File access property list ID */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t fcpl; /* File creation property list ID */ + hid_t fapl; /* File access property list ID */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ - MESSAGE(5, ("Testing interaction between userblock and alignment (via paged aggregation and H5Pset_alignment)\n")); + MESSAGE(5, ("Testing interaction between userblock and alignment (via paged aggregation and " + "H5Pset_alignment)\n")); /* * Case 1: @@ -3562,9 +3599,11 @@ test_userblock_alignment_paged(void) CHECK(ret, FAIL, "H5Pset_alignment"); /* Create a file with FAPL & FCPL */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(fid, FAIL, "H5Fcreate"); /* Release property lists */ @@ -3638,9 +3677,11 @@ test_userblock_alignment_paged(void) CHECK(ret, FAIL, "H5Pset_alignment"); /* Create a file with FAPL & FCPL */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(fid, FAIL, "H5Fcreate"); /* Release property lists */ @@ -3676,9 +3717,11 @@ test_userblock_alignment_paged(void) CHECK(ret, FAIL, "H5Pset_alignment"); /* Create a file with FAPL & FCPL */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(fid, FAIL, "H5Fcreate"); /* Release property lists */ @@ -3752,9 +3795,11 @@ test_userblock_alignment_paged(void) CHECK(ret, FAIL, "H5Pset_alignment"); /* Create a file with FAPL & FCPL */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(fid, FAIL, "H5Fcreate"); /* Release property lists */ @@ -3866,23 +3911,24 @@ test_userblock_alignment_paged(void) static void test_filespace_info(const char *env_h5_drvr) { - hid_t fid; /* File IDs */ - hid_t fapl, new_fapl; /* File access property lists */ - hid_t fcpl, fcpl1, fcpl2; /* File creation property lists */ - H5F_fspace_strategy_t strategy; /* File space strategy */ - hbool_t persist; /* Persist free-space or not */ - hsize_t threshold; /* Free-space section threshold */ - unsigned new_format; /* New or old format */ - H5F_fspace_strategy_t fs_strategy; /* File space strategy--iteration variable */ - unsigned fs_persist; /* Persist free-space or not--iteration variable */ - hsize_t fs_threshold; /* Free-space section threshold--iteration variable */ - hsize_t fsp_size; /* File space page size */ - char filename[FILENAME_LEN]; /* Filename to use */ - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - herr_t ret; /* Return value */ + hid_t fid; /* File IDs */ + hid_t fapl, new_fapl; /* File access property lists */ + hid_t fcpl, fcpl1, fcpl2; /* File creation property lists */ + H5F_fspace_strategy_t strategy; /* File space strategy */ + hbool_t persist; /* Persist free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + unsigned new_format; /* New or old format */ + H5F_fspace_strategy_t fs_strategy; /* File space strategy--iteration variable */ + unsigned fs_persist; /* Persist free-space or not--iteration variable */ + hsize_t fs_threshold; /* Free-space section threshold--iteration variable */ + hsize_t fsp_size; /* File space page size */ + char filename[FILENAME_LEN]; /* Filename to use */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + herr_t ret; /* Return value */ /* Output message about test being performed */ - MESSAGE(5, ("Testing file creation public routines: H5Pget/set_file_space_strategy & H5Pget/set_file_space_page_size\n")); + MESSAGE(5, ("Testing file creation public routines: H5Pget/set_file_space_strategy & " + "H5Pget/set_file_space_page_size\n")); contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); @@ -3942,21 +3988,27 @@ test_filespace_info(const char *env_h5_drvr) CHECK(fcpl, FAIL, "H5Pcreate"); /* Setting to 0: should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_file_space_page_size(fcpl, 0); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_file_space_page_size"); /* Setting to 511: should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_file_space_page_size(fcpl, 511); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_file_space_page_size"); /* Setting to 1GB+1: should fail */ - H5E_BEGIN_TRY { - ret = H5Pset_file_space_page_size(fcpl, FSP_SIZE1G+1); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5Pset_file_space_page_size(fcpl, FSP_SIZE1G + 1); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_file_space_page_size"); /* Setting to 512: should succeed */ @@ -4064,11 +4116,11 @@ test_filespace_info(const char *env_h5_drvr) * File space page size: set to 512 * */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl; /* Set the FAPL for the type of format */ - if(new_format) { + if (new_format) { MESSAGE(5, ("Testing with new group format\n")); my_fapl = new_fapl; } /* end if */ @@ -4078,15 +4130,16 @@ test_filespace_info(const char *env_h5_drvr) } /* end else */ /* Test with TRUE or FALSE for persisting free-space */ - for(fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { + for (fs_persist = FALSE; fs_persist <= TRUE; fs_persist++) { /* Test with free-space section threshold size: 0 to 10 */ - for(fs_threshold = 0; fs_threshold <= TEST_THRESHOLD10; fs_threshold++) { + for (fs_threshold = 0; fs_threshold <= TEST_THRESHOLD10; fs_threshold++) { /* Test with 4 file space strategies */ - for(fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_strategy < H5F_FSPACE_STRATEGY_NTYPES; fs_strategy++) { + for (fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fs_strategy < H5F_FSPACE_STRATEGY_NTYPES; + fs_strategy++) { - if(!contig_addr_vfd && (fs_strategy == H5F_FSPACE_STRATEGY_PAGE || fs_persist)) + if (!contig_addr_vfd && (fs_strategy == H5F_FSPACE_STRATEGY_PAGE || fs_persist)) continue; /* Create file creation property list template */ @@ -4107,10 +4160,11 @@ test_filespace_info(const char *env_h5_drvr) /* Verify file space information */ VERIFY(strategy, fs_strategy, "H5Pget_file_space_strategy"); - if(fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { + if (fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { VERIFY(persist, (hbool_t)fs_persist, "H5Pget_file_space_strategy"); VERIFY(threshold, fs_threshold, "H5Pget_file_space_strategy"); - } else { + } + else { VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); VERIFY(threshold, 1, "H5Pget_file_space_strategy"); } @@ -4135,10 +4189,11 @@ test_filespace_info(const char *env_h5_drvr) /* Verify file space information */ VERIFY(strategy, fs_strategy, "H5Pget_file_space_strategy"); - if(fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { + if (fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { VERIFY(persist, fs_persist, "H5Pget_file_space_strategy"); VERIFY(threshold, fs_threshold, "H5Pget_file_space_strategy"); - } else { + } + else { VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); VERIFY(threshold, 1, "H5Pget_file_space_strategy"); } @@ -4166,10 +4221,11 @@ test_filespace_info(const char *env_h5_drvr) /* Verify file space information */ VERIFY(strategy, fs_strategy, "H5Pget_file_space_strategy"); - if(fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { + if (fs_strategy < H5F_FSPACE_STRATEGY_AGGR) { VERIFY(persist, fs_persist, "H5Pget_file_space_strategy"); VERIFY(threshold, fs_threshold, "H5Pget_file_space_strategy"); - } else { + } + else { VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); VERIFY(threshold, 1, "H5Pget_file_space_strategy"); } @@ -4191,14 +4247,14 @@ test_filespace_info(const char *env_h5_drvr) ret = H5Pclose(fcpl2); CHECK(ret, FAIL, "H5Pclose"); } /* end for file space strategy type */ - } /* end for free-space section threshold */ - } /* end for fs_persist */ + } /* end for free-space section threshold */ + } /* end for fs_persist */ /* close fapl_ and remove the file */ h5_clean_files(FILESPACE_NAME, my_fapl); } /* end for new_format */ -} /* test_filespace_info() */ +} /* test_filespace_info() */ /**************************************************************** ** @@ -4212,42 +4268,44 @@ static int set_multi_split(hid_t fapl, hsize_t pagesize, hbool_t split) { H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; - char *memb_name[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - hbool_t relax; - H5FD_mem_t mt; + hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; + char * memb_name[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + hbool_t relax; + H5FD_mem_t mt; HDassert(split); HDmemset(memb_name, 0, sizeof memb_name); /* Get current split settings */ - if(H5Pget_fapl_multi(fapl, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) + if (H5Pget_fapl_multi(fapl, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) TEST_ERROR - if(split) { + if (split) { /* Set memb_addr aligned */ memb_addr[H5FD_MEM_SUPER] = ((memb_addr[H5FD_MEM_SUPER] + pagesize - 1) / pagesize) * pagesize; - memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + pagesize - 1) / pagesize) * pagesize; - } else { + memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + pagesize - 1) / pagesize) * pagesize; + } + else { /* Set memb_addr aligned */ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) memb_addr[mt] = ((memb_addr[mt] + pagesize - 1) / pagesize) * pagesize; } /* end else */ /* Set multi driver with new FAPLs */ - if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl_arr, (const char * const *)memb_name, memb_addr, relax) < 0) + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl_arr, (const char *const *)memb_name, memb_addr, relax) < + 0) TEST_ERROR /* Free memb_name */ - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) free(memb_name[mt]); return 0; error: - return(-1); + return (-1); } /* set_multi_split() */ @@ -4262,29 +4320,29 @@ error: static void test_file_freespace(const char *env_h5_drvr) { - hid_t file; /* File opened with read-write permission */ - h5_stat_size_t empty_filesize; /* Size of file when empty */ - h5_stat_size_t mod_filesize; /* Size of file after being modified */ - hssize_t free_space; /* Amount of free space in file */ - hid_t fcpl; /* File creation property list */ - hid_t fapl, new_fapl; /* File access property list IDs */ - hid_t dspace; /* Dataspace ID */ - hid_t dset; /* Dataset ID */ - hid_t dcpl; /* Dataset creation property list */ - int k; /* Local index variable */ - unsigned u; /* Local index variable */ - char filename[FILENAME_LEN]; /* Filename to use */ - char name[32]; /* Dataset name */ - unsigned new_format; /* To use old or new format */ - hbool_t split_vfd, multi_vfd; /* Indicate multi/split driver */ - hsize_t expected_freespace; /* Freespace expected */ - hsize_t expected_fs_del; /* Freespace expected after delete */ - herr_t ret; /* Return value */ + hid_t file; /* File opened with read-write permission */ + h5_stat_size_t empty_filesize; /* Size of file when empty */ + h5_stat_size_t mod_filesize; /* Size of file after being modified */ + hssize_t free_space; /* Amount of free space in file */ + hid_t fcpl; /* File creation property list */ + hid_t fapl, new_fapl; /* File access property list IDs */ + hid_t dspace; /* Dataspace ID */ + hid_t dset; /* Dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + int k; /* Local index variable */ + unsigned u; /* Local index variable */ + char filename[FILENAME_LEN]; /* Filename to use */ + char name[32]; /* Dataset name */ + unsigned new_format; /* To use old or new format */ + hbool_t split_vfd, multi_vfd; /* Indicate multi/split driver */ + hsize_t expected_freespace; /* Freespace expected */ + hsize_t expected_fs_del; /* Freespace expected after delete */ + herr_t ret; /* Return value */ split_vfd = !HDstrcmp(env_h5_drvr, "split"); multi_vfd = !HDstrcmp(env_h5_drvr, "multi"); - if(!split_vfd && !multi_vfd) { + if (!split_vfd && !multi_vfd) { fapl = h5_fileaccess(); h5_fixname(FILESPACE_NAME[0], fapl, filename, sizeof filename); @@ -4299,16 +4357,16 @@ test_file_freespace(const char *env_h5_drvr) CHECK(fcpl, FAIL, "H5Pcreate"); /* Test with old & new format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl; /* Set the FAPL for the type of format */ - if(new_format) { + if (new_format) { MESSAGE(5, ("Testing with new group format\n")); my_fapl = new_fapl; - if(multi_vfd || split_vfd) { + if (multi_vfd || split_vfd) { ret = set_multi_split(new_fapl, FSP_SIZE_DEF, split_vfd); CHECK(ret, FAIL, "set_multi_split"); } @@ -4317,17 +4375,21 @@ test_file_freespace(const char *env_h5_drvr) CHECK(ret, FAIL, "H5P_set_file_space_strategy"); expected_freespace = 4534; - if(split_vfd) expected_freespace = 427; - if(multi_vfd) expected_freespace = 248; + if (split_vfd) + expected_freespace = 427; + if (multi_vfd) + expected_freespace = 248; expected_fs_del = 0; } /* end if */ else { MESSAGE(5, ("Testing with old group format\n")); /* Default: non-paged aggregation, non-persistent free-space */ - my_fapl = fapl; + my_fapl = fapl; expected_freespace = 2464; - if(split_vfd) expected_freespace = 264; - if(multi_vfd) expected_freespace = 0; + if (split_vfd) + expected_freespace = 264; + if (multi_vfd) + expected_freespace = 0; expected_fs_del = 4096; } /* end else */ @@ -4364,7 +4426,7 @@ test_file_freespace(const char *env_h5_drvr) CHECK(ret, FAIL, "H5Pset_alloc_time"); /* Create datasets in file */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { HDsprintf(name, "Dataset %u", u); dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate2"); @@ -4387,7 +4449,7 @@ test_file_freespace(const char *env_h5_drvr) VERIFY(free_space, expected_freespace, "H5Fget_freespace"); /* Delete datasets in file */ - for(k = 9; k >= 0; k--) { + for (k = 9; k >= 0; k--) { HDsprintf(name, "Dataset %u", (unsigned)k); ret = H5Ldelete(file, name, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); @@ -4425,30 +4487,30 @@ test_file_freespace(const char *env_h5_drvr) static void test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) { - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file; /* File ID */ - hid_t fcpl; /* File creation property list template */ - hid_t fapl; /* File access property list template */ - hssize_t free_space; /* Amount of free-space in the file */ - hid_t dspace; /* Dataspace ID */ - hid_t dset; /* Dataset ID */ - hid_t dcpl; /* Dataset creation property list */ - char name[32]; /* Dataset name */ - hssize_t nsects = 0; /* # of free-space sections */ - hssize_t nall; /* # of free-space sections for all types of data */ - hssize_t nmeta = 0, nraw = 0; /* # of free-space sections for meta/raw/generic data */ - H5F_sect_info_t sect_info[15]; /* Array to hold free-space information */ - H5F_sect_info_t all_sect_info[15]; /* Array to hold free-space information for all types of data */ - H5F_sect_info_t meta_sect_info[15]; /* Array to hold free-space information for metadata */ - H5F_sect_info_t raw_sect_info[15]; /* Array to hold free-space information for raw data */ - hsize_t total = 0; /* sum of the free-space section sizes */ - hsize_t tmp_tot = 0; /* Sum of the free-space section sizes */ - hsize_t last_size; /* Size of last free-space section */ - hsize_t dims[1]; /* Dimension sizes */ - unsigned u; /* Local index variable */ - H5FD_mem_t type; - hbool_t split_vfd = FALSE, multi_vfd = FALSE; - herr_t ret; /* Return value */ + char filename[FILENAME_LEN]; /* Filename to use */ + hid_t file; /* File ID */ + hid_t fcpl; /* File creation property list template */ + hid_t fapl; /* File access property list template */ + hssize_t free_space; /* Amount of free-space in the file */ + hid_t dspace; /* Dataspace ID */ + hid_t dset; /* Dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + char name[32]; /* Dataset name */ + hssize_t nsects = 0; /* # of free-space sections */ + hssize_t nall; /* # of free-space sections for all types of data */ + hssize_t nmeta = 0, nraw = 0; /* # of free-space sections for meta/raw/generic data */ + H5F_sect_info_t sect_info[15]; /* Array to hold free-space information */ + H5F_sect_info_t all_sect_info[15]; /* Array to hold free-space information for all types of data */ + H5F_sect_info_t meta_sect_info[15]; /* Array to hold free-space information for metadata */ + H5F_sect_info_t raw_sect_info[15]; /* Array to hold free-space information for raw data */ + hsize_t total = 0; /* sum of the free-space section sizes */ + hsize_t tmp_tot = 0; /* Sum of the free-space section sizes */ + hsize_t last_size; /* Size of last free-space section */ + hsize_t dims[1]; /* Dimension sizes */ + unsigned u; /* Local index variable */ + H5FD_mem_t type; + hbool_t split_vfd = FALSE, multi_vfd = FALSE; + herr_t ret; /* Return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing H5Fget_free_sections()--free-space section info in the file\n")); @@ -4456,7 +4518,7 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) split_vfd = !HDstrcmp(env_h5_drvr, "split"); multi_vfd = !HDstrcmp(env_h5_drvr, "multi"); - if(!split_vfd && !multi_vfd) { + if (!split_vfd && !multi_vfd) { fapl = h5_fileaccess(); h5_fixname(FILESPACE_NAME[0], fapl, filename, sizeof filename); @@ -4465,7 +4527,7 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); - if(new_format) { + if (new_format) { ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); CHECK(ret, FAIL, "H5Pset_libver_bounds"); @@ -4474,12 +4536,12 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) CHECK(ret, FAIL, "H5Pget_file_space_strategy"); /* Set up paged aligned address space for multi/split driver */ - if(multi_vfd || split_vfd) { + if (multi_vfd || split_vfd) { ret = set_multi_split(fapl, FSP_SIZE_DEF, split_vfd); CHECK(ret, FAIL, "set_multi_split"); } - - } else { + } + else { ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1); CHECK(ret, FAIL, "H5Pget_file_space_strategy"); } @@ -4498,8 +4560,8 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) /* Create 1 large dataset */ dims[0] = 1200; - dspace = H5Screate_simple(1, dims, NULL); - dset = H5Dcreate2(file, "Dataset_large", H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + dspace = H5Screate_simple(1, dims, NULL); + dset = H5Dcreate2(file, "Dataset_large", H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate2"); /* Close dataset */ @@ -4515,7 +4577,7 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) CHECK(dspace, FAIL, "H5Screate"); /* Create datasets in file */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { HDsprintf(name, "Dataset %u", u); dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate2"); @@ -4533,13 +4595,13 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) CHECK(ret, FAIL, "H5Pclose"); /* Delete odd-numbered datasets in file */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { HDsprintf(name, "Dataset %u", u); - if(u % 2) { + if (u % 2) { ret = H5Ldelete(file, name, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); } /* end if */ - } /* end for */ + } /* end for */ /* Close file */ ret = H5Fclose(file); @@ -4562,26 +4624,26 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) VERIFY(nsects, FAIL, "H5Fget_free_sections"); /* Retrieve and verify free space info for all the sections */ - HDmemset(all_sect_info, 0, sizeof(all_sect_info)); + HDmemset(all_sect_info, 0, sizeof(all_sect_info)); nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)nall, all_sect_info); VERIFY(nsects, nall, "H5Fget_free_sections"); /* Verify the amount of free-space is correct */ - for(u = 0; u < nall; u++) + for (u = 0; u < nall; u++) total += all_sect_info[u].size; VERIFY(free_space, total, "H5Fget_free_sections"); /* Save the last section's size */ - last_size = all_sect_info[nall-1].size; + last_size = all_sect_info[nall - 1].size; /* Retrieve and verify free space info for -1 sections */ - HDmemset(sect_info, 0, sizeof(sect_info)); + HDmemset(sect_info, 0, sizeof(sect_info)); nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)(nall - 1), sect_info); VERIFY(nsects, nall, "H5Fget_free_sections"); /* Verify the amount of free-space is correct */ total = 0; - for(u = 0; u < (nall - 1); u++) { + for (u = 0; u < (nall - 1); u++) { VERIFY(sect_info[u].addr, all_sect_info[u].addr, "H5Fget_free_sections"); VERIFY(sect_info[u].size, all_sect_info[u].size, "H5Fget_free_sections"); total += sect_info[u].size; @@ -4589,13 +4651,13 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) VERIFY(((hsize_t)free_space - last_size), total, "H5Fget_free_sections"); /* Retrieve and verify free-space info for +1 sections */ - HDmemset(sect_info, 0, sizeof(sect_info)); + HDmemset(sect_info, 0, sizeof(sect_info)); nsects = H5Fget_free_sections(file, H5FD_MEM_DEFAULT, (size_t)(nall + 1), sect_info); VERIFY(nsects, nall, "H5Fget_free_sections"); /* Verify amount of free-space is correct */ total = 0; - for(u = 0; u < nall; u++) { + for (u = 0; u < nall; u++) { VERIFY(sect_info[u].addr, all_sect_info[u].addr, "H5Fget_free_sections"); VERIFY(sect_info[u].size, all_sect_info[u].size, "H5Fget_free_sections"); total += sect_info[u].size; @@ -4604,24 +4666,25 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) VERIFY(sect_info[nall].size, 0, "H5Fget_free_sections"); VERIFY(free_space, total, "H5Fget_free_sections"); - HDmemset(meta_sect_info, 0, sizeof(meta_sect_info)); - if(multi_vfd) { + HDmemset(meta_sect_info, 0, sizeof(meta_sect_info)); + if (multi_vfd) { hssize_t ntmp; - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { - if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { + if (type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) continue; /* Get the # of free-space sections in the file for metadata */ ntmp = H5Fget_free_sections(file, type, (size_t)0, NULL); CHECK(ntmp, FAIL, "H5Fget_free_sections"); - if(ntmp > 0) { + if (ntmp > 0) { nsects = H5Fget_free_sections(file, type, (size_t)ntmp, &meta_sect_info[nmeta]); VERIFY(nsects, ntmp, "H5Fget_free_sections"); nmeta += ntmp; } } - } else { + } + else { /* Get the # of free-space sections in the file for metadata */ nmeta = H5Fget_free_sections(file, H5FD_MEM_SUPER, (size_t)0, NULL); CHECK(nmeta, FAIL, "H5Fget_free_sections"); @@ -4636,19 +4699,19 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) CHECK(nraw, FAIL, "H5Fget_free_sections"); /* Retrieve and verify free-space sections for raw data */ - HDmemset(raw_sect_info, 0, sizeof(raw_sect_info)); + HDmemset(raw_sect_info, 0, sizeof(raw_sect_info)); nsects = H5Fget_free_sections(file, H5FD_MEM_DRAW, (size_t)nraw, raw_sect_info); VERIFY(nsects, nraw, "H5Fget_free_sections"); /* Sum all the free-space sections */ - for(u = 0; u < nmeta; u++) + for (u = 0; u < nmeta; u++) tmp_tot += meta_sect_info[u].size; - for(u = 0; u < nraw; u++) + for (u = 0; u < nraw; u++) tmp_tot += raw_sect_info[u].size; /* Verify free-space info */ - VERIFY(nmeta+nraw, nall, "H5Fget_free_sections"); + VERIFY(nmeta + nraw, nall, "H5Fget_free_sections"); VERIFY(tmp_tot, total, "H5Fget_free_sections"); /* Closing */ @@ -4662,7 +4725,6 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) } /* end test_sects_freespace() */ - /**************************************************************** ** ** test_filespace_compatible(): @@ -4675,53 +4737,53 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) static void test_filespace_compatible(void) { - int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */ - hid_t fid = -1; /* File id */ - hid_t did = -1; /* Dataset id */ - hid_t fcpl; /* File creation property list template */ - int check[100]; /* Temporary buffer for verifying dataset data */ - int rdbuf[100]; /* Temporary buffer for reading in dataset data */ - uint8_t buf[READ_OLD_BUFSIZE]; /* temporary buffer for reading */ - ssize_t nread; /* Number of bytes read in */ - unsigned i, j; /* Local index variable */ - hssize_t free_space; /* Amount of free-space in the file */ - hbool_t persist; /* Persist free-space or not */ - hsize_t threshold; /* Free-space section threshold */ - H5F_fspace_strategy_t strategy; /* File space handling strategy */ - herr_t ret; /* Return value */ + int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */ + hid_t fid = -1; /* File id */ + hid_t did = -1; /* Dataset id */ + hid_t fcpl; /* File creation property list template */ + int check[100]; /* Temporary buffer for verifying dataset data */ + int rdbuf[100]; /* Temporary buffer for reading in dataset data */ + uint8_t buf[READ_OLD_BUFSIZE]; /* temporary buffer for reading */ + ssize_t nread; /* Number of bytes read in */ + unsigned i, j; /* Local index variable */ + hssize_t free_space; /* Amount of free-space in the file */ + hbool_t persist; /* Persist free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + H5F_fspace_strategy_t strategy; /* File space handling strategy */ + herr_t ret; /* Return value */ /* Output message about test being performed */ MESSAGE(5, ("File space compatibility testing for 1.6 and 1.8 files\n")); - for(j = 0; j < NELMTS(OLD_FILENAME); j++) { + for (j = 0; j < NELMTS(OLD_FILENAME); j++) { const char *filename = H5_get_srcdir_filename(OLD_FILENAME[j]); /* Corrected test file name */ /* Open and copy the test file into a temporary file */ - fd_old = HDopen(filename, O_RDONLY); - CHECK(fd_old, FAIL, "HDopen"); - fd_new = HDopen(FILE5, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); - CHECK(fd_new, FAIL, "HDopen"); + fd_old = HDopen(filename, O_RDONLY); + CHECK(fd_old, FAIL, "HDopen"); + fd_new = HDopen(FILE5, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + CHECK(fd_new, FAIL, "HDopen"); - /* Copy data */ - while((nread = HDread(fd_old, buf, (size_t)READ_OLD_BUFSIZE)) > 0) { + /* Copy data */ + while ((nread = HDread(fd_old, buf, (size_t)READ_OLD_BUFSIZE)) > 0) { ssize_t write_err = HDwrite(fd_new, buf, (size_t)nread); CHECK(write_err, -1, "HDwrite"); } /* end while */ - /* Close the files */ - ret = HDclose(fd_old); - CHECK(ret, FAIL, "HDclose"); - ret = HDclose(fd_new); - CHECK(ret, FAIL, "HDclose"); + /* Close the files */ + ret = HDclose(fd_old); + CHECK(ret, FAIL, "HDclose"); + ret = HDclose(fd_new); + CHECK(ret, FAIL, "HDclose"); /* Open the temporary test file */ - fid = H5Fopen(FILE5, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK(fid, FAIL, "H5Fopen"); + fid = H5Fopen(FILE5, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); - /* There should not be any free space in the file */ - free_space = H5Fget_freespace(fid); - CHECK(free_space, FAIL, "H5Fget_freespace"); - VERIFY(free_space, (hssize_t)0, "H5Fget_freespace"); + /* There should not be any free space in the file */ + free_space = H5Fget_freespace(fid); + CHECK(free_space, FAIL, "H5Fget_freespace"); + VERIFY(free_space, (hssize_t)0, "H5Fget_freespace"); /* Get the file's file creation property list */ fcpl = H5Fget_create_plist(fid); @@ -4738,27 +4800,27 @@ test_filespace_compatible(void) VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); VERIFY(threshold, 1, "H5Pget_file_space_strategy"); - /* Generate raw data */ - for(i = 0; i < 100; i++) - check[i] = (int)i; + /* Generate raw data */ + for (i = 0; i < 100; i++) + check[i] = (int)i; - /* Open and read the dataset */ - did = H5Dopen2(fid, DSETNAME, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dopen"); - ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf); - CHECK(ret, FAIL, "H5Dread"); + /* Open and read the dataset */ + did = H5Dopen2(fid, DSETNAME, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen"); + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdbuf); + CHECK(ret, FAIL, "H5Dread"); - /* Verify the data read is correct */ - for(i = 0; i < 100; i++) - VERIFY(rdbuf[i], check[i], "test_compatible"); + /* Verify the data read is correct */ + for (i = 0; i < 100; i++) + VERIFY(rdbuf[i], check[i], "test_compatible"); - /* Close the dataset */ - ret = H5Dclose(did); - CHECK(ret, FAIL, "H5Dclose"); + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); - /* Remove the dataset */ - ret = H5Ldelete(fid, DSETNAME, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Ldelete"); + /* Remove the dataset */ + ret = H5Ldelete(fid, DSETNAME, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); /* Close the plist */ ret = H5Pclose(fcpl); @@ -4768,22 +4830,22 @@ test_filespace_compatible(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-Open the file */ - fid = H5Fopen(FILE5, H5F_ACC_RDONLY, H5P_DEFAULT); - CHECK(fid, FAIL, "H5Fopen"); + /* Re-Open the file */ + fid = H5Fopen(FILE5, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); - /* The dataset should not be there */ - did = H5Dopen2(fid, DSETNAME, H5P_DEFAULT); - VERIFY(did, FAIL, "H5Dopen"); + /* The dataset should not be there */ + did = H5Dopen2(fid, DSETNAME, H5P_DEFAULT); + VERIFY(did, FAIL, "H5Dopen"); - /* There should not be any free space in the file */ - free_space = H5Fget_freespace(fid); - CHECK(free_space, FAIL, "H5Fget_freespace"); - VERIFY(free_space, (hssize_t)0, "H5Fget_freespace"); + /* There should not be any free space in the file */ + free_space = H5Fget_freespace(fid); + CHECK(free_space, FAIL, "H5Fget_freespace"); + VERIFY(free_space, (hssize_t)0, "H5Fget_freespace"); - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); } /* end for */ } /* test_filespace_compatible */ @@ -4793,10 +4855,13 @@ test_filespace_compatible(void) ** Verify that the latest file space management can open, read and ** modify 1.10.0 HDF5 files : ** h5fc_ext1_i.h5: H5F_FILE_SPACE_ALL, default threshold; has superblock extension but no fsinfo message -** h5fc_ext1_f.h5: H5F_FILE_SPACE_ALL_PERSIST, default threshold; has superblock extension with fsinfo message -** h5fc_ext2_if.h5: H5F_FILE_SPACE_ALL, non-default threshold; has superblock extension with fsinfo message +** h5fc_ext1_f.h5: H5F_FILE_SPACE_ALL_PERSIST, default threshold; has superblock extension with fsinfo +*message +** h5fc_ext2_if.h5: H5F_FILE_SPACE_ALL, non-default threshold; has superblock extension with fsinfo +*message ** h5fc_ext2_sf.h5: H5F_FILE_SPACE_VFD, default threshold; has superblock extension with fsinfo message -** h5fc_ext3_isf.h5: H5F_FILE_SPACE_AGGR_VFD, default threshold; has superblock extension with fsinfo message +** h5fc_ext3_isf.h5: H5F_FILE_SPACE_AGGR_VFD, default threshold; has superblock extension with fsinfo +*message ** h5fc_ext_none.h5: H5F_FILE_SPACE_ALL, default threshold; without superblock extension ** The above files are copied from release 1.10.0 tools/h5format_convert/testfiles. ** @@ -4804,22 +4869,22 @@ test_filespace_compatible(void) static void test_filespace_1_10_0_compatible(void) { - hid_t fid = -1; /* File id */ - hid_t did = -1; /* Dataset id */ - hid_t fcpl; /* File creation property list */ - hbool_t persist; /* Persist free-space or not */ - hsize_t threshold; /* Free-space section threshold */ - H5F_fspace_strategy_t strategy; /* File space handling strategy */ - int wbuf[24]; /* Buffer for dataset data */ - int rdbuf[24]; /* Buffer for dataset data */ - int status; /* Status from copying the existing file */ - unsigned i, j; /* Local index variable */ - herr_t ret; /* Return value */ + hid_t fid = -1; /* File id */ + hid_t did = -1; /* Dataset id */ + hid_t fcpl; /* File creation property list */ + hbool_t persist; /* Persist free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + H5F_fspace_strategy_t strategy; /* File space handling strategy */ + int wbuf[24]; /* Buffer for dataset data */ + int rdbuf[24]; /* Buffer for dataset data */ + int status; /* Status from copying the existing file */ + unsigned i, j; /* Local index variable */ + herr_t ret; /* Return value */ /* Output message about test being performed */ MESSAGE(5, ("File space compatibility testing for 1.10.0 files\n")); - for(j = 0; j < NELMTS(OLD_1_10_0_FILENAME); j++) { + for (j = 0; j < NELMTS(OLD_1_10_0_FILENAME); j++) { /* Make a copy of the test file */ status = h5_make_local_copy(OLD_1_10_0_FILENAME[j], FILE5); CHECK(status, FAIL, "h5_make_local_copy"); @@ -4836,7 +4901,7 @@ test_filespace_1_10_0_compatible(void) ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); CHECK(ret, FAIL, "H5Pget_file_space_strategy"); - switch(j) { + switch (j) { case 0: VERIFY(strategy, H5F_FILE_SPACE_STRATEGY_DEF, "H5Pget_file_space_strategy"); VERIFY(persist, H5F_FREE_SPACE_PERSIST_DEF, "H5Pget_file_space_strategy"); @@ -4846,8 +4911,8 @@ test_filespace_1_10_0_compatible(void) did = H5Dopen2(fid, "/DSET_EA", H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); - for(i = 0; i < 24; i++) - wbuf[i] = (int)j+1; + for (i = 0; i < 24; i++) + wbuf[i] = (int)j + 1; /* Write to the dataset */ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -4867,8 +4932,8 @@ test_filespace_1_10_0_compatible(void) did = H5Dopen2(fid, "/DSET_NDATA_BT2", H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); - for(i = 0; i < 24; i++) - wbuf[i] = (int)j+1; + for (i = 0; i < 24; i++) + wbuf[i] = (int)j + 1; /* Write to the dataset */ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -4888,8 +4953,8 @@ test_filespace_1_10_0_compatible(void) did = H5Dopen2(fid, "/DSET_NONE", H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); - for(i = 0; i < 24; i++) - wbuf[i] = (int)j+1; + for (i = 0; i < 24; i++) + wbuf[i] = (int)j + 1; /* Write to the dataset */ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -4909,8 +4974,8 @@ test_filespace_1_10_0_compatible(void) did = H5Dopen2(fid, "/GROUP/DSET_NDATA_EA", H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); - for(i = 0; i < 24; i++) - wbuf[i] = (int)j+1; + for (i = 0; i < 24; i++) + wbuf[i] = (int)j + 1; /* Write to the dataset */ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -4930,8 +4995,8 @@ test_filespace_1_10_0_compatible(void) did = H5Dopen2(fid, "/GROUP/DSET_NDATA_FA", H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); - for(i = 0; i < 24; i++) - wbuf[i] = (int)j+1; + for (i = 0; i < 24; i++) + wbuf[i] = (int)j + 1; /* Write to the dataset */ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -4950,8 +5015,8 @@ test_filespace_1_10_0_compatible(void) did = H5Dopen2(fid, "/GROUP/DSET_NDATA_NONE", H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); - for(i = 0; i < 24; i++) - wbuf[i] = (int)j+1; + for (i = 0; i < 24; i++) + wbuf[i] = (int)j + 1; /* Write to the dataset */ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -4963,7 +5028,7 @@ test_filespace_1_10_0_compatible(void) break; default: - break; + break; } /* Close the plist */ @@ -4978,7 +5043,7 @@ test_filespace_1_10_0_compatible(void) fid = H5Fopen(FILE5, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); - switch(j) { + switch (j) { case 0: /* Open and read the dataset */ did = H5Dopen2(fid, "/DSET_EA", H5P_DEFAULT); @@ -4988,8 +5053,8 @@ test_filespace_1_10_0_compatible(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the data read is correct */ - for(i = 0; i < 24; i++) - VERIFY(rdbuf[i], j+1, "test_compatible"); + for (i = 0; i < 24; i++) + VERIFY(rdbuf[i], j + 1, "test_compatible"); /* Close the dataset */ ret = H5Dclose(did); @@ -5005,8 +5070,8 @@ test_filespace_1_10_0_compatible(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the data read is correct */ - for(i = 0; i < 24; i++) - VERIFY(rdbuf[i], j+1, "test_compatible"); + for (i = 0; i < 24; i++) + VERIFY(rdbuf[i], j + 1, "test_compatible"); /* Close the dataset */ ret = H5Dclose(did); @@ -5022,8 +5087,8 @@ test_filespace_1_10_0_compatible(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the data read is correct */ - for(i = 0; i < 24; i++) - VERIFY(rdbuf[i], j+1, "test_compatible"); + for (i = 0; i < 24; i++) + VERIFY(rdbuf[i], j + 1, "test_compatible"); /* Close the dataset */ ret = H5Dclose(did); @@ -5039,8 +5104,8 @@ test_filespace_1_10_0_compatible(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the data read is correct */ - for(i = 0; i < 24; i++) - VERIFY(rdbuf[i], j+1, "test_compatible"); + for (i = 0; i < 24; i++) + VERIFY(rdbuf[i], j + 1, "test_compatible"); /* Close the dataset */ ret = H5Dclose(did); @@ -5057,8 +5122,8 @@ test_filespace_1_10_0_compatible(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the data read is correct */ - for(i = 0; i < 24; i++) - VERIFY(rdbuf[i], j+1, "test_compatible"); + for (i = 0; i < 24; i++) + VERIFY(rdbuf[i], j + 1, "test_compatible"); /* Close the dataset */ ret = H5Dclose(did); @@ -5075,8 +5140,8 @@ test_filespace_1_10_0_compatible(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the data read is correct */ - for(i = 0; i < 24; i++) - VERIFY(rdbuf[i], j+1, "test_compatible"); + for (i = 0; i < 24; i++) + VERIFY(rdbuf[i], j + 1, "test_compatible"); /* Close the dataset */ ret = H5Dclose(did); @@ -5084,7 +5149,7 @@ test_filespace_1_10_0_compatible(void) break; default: - break; + break; } /* Close the file */ @@ -5118,52 +5183,51 @@ test_filespace_1_10_0_compatible(void) static void test_filespace_round_compatible(void) { - hid_t fid = -1; /* File id */ - hid_t fcpl = -1; /* File creation property list ID */ - unsigned j; /* Local index variable */ - H5F_fspace_strategy_t strategy; /* File space strategy */ - hbool_t persist; /* Persist free-space or not */ - hsize_t threshold; /* Free-space section threshold */ - hssize_t free_space; /* Amount of free space in the file */ - int status; /* Status from copying the existing file */ - herr_t ret; /* Return value */ + hid_t fid = -1; /* File id */ + hid_t fcpl = -1; /* File creation property list ID */ + unsigned j; /* Local index variable */ + H5F_fspace_strategy_t strategy; /* File space strategy */ + hbool_t persist; /* Persist free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + hssize_t free_space; /* Amount of free space in the file */ + int status; /* Status from copying the existing file */ + herr_t ret; /* Return value */ /* Output message about test being performed */ MESSAGE(5, ("File space compatibility testing for files from trunk to 1_8 to trunk\n")); - for(j = 0; j < NELMTS(FSPACE_FILENAMES); j++) { + for (j = 0; j < NELMTS(FSPACE_FILENAMES); j++) { /* Make a copy of the test file */ status = h5_make_local_copy(FSPACE_FILENAMES[j], FILE5); - CHECK(status, FAIL, "h5_make_local_copy"); + CHECK(status, FAIL, "h5_make_local_copy"); - /* Open the temporary test file */ - fid = H5Fopen(FILE5, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK(fid, FAIL, "H5Fopen"); + /* Open the temporary test file */ + fid = H5Fopen(FILE5, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); - /* Get the file's creation property list */ - fcpl = H5Fget_create_plist(fid); - CHECK(fcpl, FAIL, "H5Fget_create_plist"); + /* Get the file's creation property list */ + fcpl = H5Fget_create_plist(fid); + CHECK(fcpl, FAIL, "H5Fget_create_plist"); - ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); - CHECK(ret, FAIL, "H5Pget_file_space_strategy"); - VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); - VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); - VERIFY(threshold, 1, "H5Pget_file_space_strategy"); + ret = H5Pget_file_space_strategy(fcpl, &strategy, &persist, &threshold); + CHECK(ret, FAIL, "H5Pget_file_space_strategy"); + VERIFY(strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5Pget_file_space_strategy"); + VERIFY(persist, FALSE, "H5Pget_file_space_strategy"); + VERIFY(threshold, 1, "H5Pget_file_space_strategy"); - /* There should not be any free space in the file */ - free_space = H5Fget_freespace(fid); - CHECK(free_space, FAIL, "H5Fget_freespace"); - VERIFY(free_space, (hssize_t)0, "H5Fget_freespace"); + /* There should not be any free space in the file */ + free_space = H5Fget_freespace(fid); + CHECK(free_space, FAIL, "H5Fget_freespace"); + VERIFY(free_space, (hssize_t)0, "H5Fget_freespace"); - /* Closing */ - ret = H5Fclose(fid); - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Fclose"); + /* Closing */ + ret = H5Fclose(fid); + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Fclose"); } /* end for */ } /* test_filespace_round_compatible */ - /**************************************************************** ** ** test_libver_bounds_real(): @@ -5173,13 +5237,13 @@ test_filespace_round_compatible(void) ** ****************************************************************/ static void -test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, - H5F_libver_t libver_mod, unsigned oh_vers_mod) +test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, H5F_libver_t libver_mod, + unsigned oh_vers_mod) { - hid_t file, group; /* Handles */ - hid_t fapl; /* File access property list */ - H5O_native_info_t ninfo; /* Object info */ - herr_t ret; /* Return value */ + hid_t file, group; /* Handles */ + hid_t fapl; /* File access property list */ + H5O_native_info_t ninfo; /* Object info */ + herr_t ret; /* Return value */ /* * Create a new file using the creation properties. @@ -5258,7 +5322,6 @@ test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, CHECK(ret, FAIL, "H5Pclose"); } /* end test_libver_bounds_real() */ - /*------------------------------------------------------------------------- * Function: test_libver_bounds_open * @@ -5269,22 +5332,22 @@ test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, * *------------------------------------------------------------------------- */ -#define VERBFNAME "tverbounds_dspace.h5" -#define VERBDSNAME "dataset 1" -#define SPACE1_DIM1 3 +#define VERBFNAME "tverbounds_dspace.h5" +#define VERBDSNAME "dataset 1" +#define SPACE1_DIM1 3 static void test_libver_bounds_open(void) { - hid_t file = -1; /* File ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t new_fapl = -1;/* File access property list ID for reopened file */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hsize_t dim[1] = {SPACE1_DIM1}; /* Dataset dimensions */ - H5F_libver_t low, high; /* File format bounds */ - hsize_t chunk_dim[1] = {SPACE1_DIM1}; /* Chunk dimensions */ - herr_t ret; /* Generic return value */ + hid_t file = -1; /* File ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t new_fapl = -1; /* File access property list ID for reopened file */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hsize_t dim[1] = {SPACE1_DIM1}; /* Dataset dimensions */ + H5F_libver_t low, high; /* File format bounds */ + hsize_t chunk_dim[1] = {SPACE1_DIM1}; /* Chunk dimensions */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Opening File in Various Version Bounds\n")); @@ -5313,9 +5376,9 @@ test_libver_bounds_open(void) dataset, then close the file */ /* Set version bounds to (LATEST, LATEST) */ - low = H5F_LIBVER_LATEST; + low = H5F_LIBVER_LATEST; high = H5F_LIBVER_LATEST; - ret = H5Pset_libver_bounds(fapl, low, high); + ret = H5Pset_libver_bounds(fapl, low, high); CHECK(ret, FAIL, "H5Pset_libver_bounds"); /* Create the file */ @@ -5334,23 +5397,26 @@ test_libver_bounds_open(void) /* Attempt to open latest file with (earliest, v18), should fail */ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file = H5Fopen(VERBFNAME, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(file, FAIL, "Attempted to open latest file with earliest version"); /* Attempt to open latest file with (v18, v18), should fail */ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_V18); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file = H5Fopen(VERBFNAME, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(file, FAIL, "Attempted to open latest file with v18 bounds"); /* Opening VERBFNAME in these combination should succeed. For each low bound, verify that it is upgraded properly */ high = H5F_LIBVER_LATEST; - for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) - { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { H5F_libver_t new_low = H5F_LIBVER_EARLIEST; /* Set version bounds for opening file */ @@ -5385,7 +5451,6 @@ test_libver_bounds_open(void) CHECK(ret, FAIL, "H5Pclose"); } /* end test_libver_bounds_open() */ - /*------------------------------------------------------------------------- * Function: test_libver_bounds_copy * @@ -5410,11 +5475,11 @@ test_libver_bounds_open(void) static void test_libver_bounds_copy(void) { - hid_t src_fid = -1; /* File ID */ - hid_t dst_fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - const char *src_fname; /* Source file name */ - herr_t ret; /* Generic return value */ + hid_t src_fid = -1; /* File ID */ + hid_t dst_fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + const char *src_fname; /* Source file name */ + herr_t ret; /* Generic return value */ /* Output message about the test being performed */ MESSAGE(5, ("Testing H5Ocopy a dataset in a 1.8 library file to a 1.10 library file\n")); @@ -5504,9 +5569,9 @@ test_libver_bounds(void) static void test_libver_bounds_low_high(void) { - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - H5F_libver_t low, high; /* Low and high bounds */ - herr_t ret; /* The return value */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* The return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing setting (low, high) format version bounds\n")); @@ -5516,22 +5581,24 @@ test_libver_bounds_low_high(void) CHECK(fapl, H5I_INVALID_HID, "H5Pcreate"); /* Loop through all the combinations of low/high version bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { /* Set the low/high version bounds */ ret = H5Pset_libver_bounds(fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; /* Should fail: invalid combinations */ - if(high == H5F_LIBVER_EARLIEST) { + if (high == H5F_LIBVER_EARLIEST) { VERIFY(ret, FAIL, "H5Pset_libver_bounds"); continue; } /* Should fail: invalid combinations */ - if(high < low) { + if (high < low) { VERIFY(ret, FAIL, "H5Pset_libver_bounds"); continue; } @@ -5553,7 +5620,6 @@ test_libver_bounds_low_high(void) } /* end test_libver_bounds_low_high() */ - /*********************************************************************** ** ** test_libver_bounds_super(): @@ -5576,8 +5642,8 @@ test_libver_bounds_low_high(void) static void test_libver_bounds_super(hid_t fapl) { - hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ - herr_t ret; /* The return value */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + herr_t ret; /* The return value */ /* Create a default fcpl: #A */ /* This will result in superblock version 0 */ @@ -5665,7 +5731,6 @@ test_libver_bounds_super(hid_t fapl) } /* end test_libver_bounds_super() */ - /************************************************************************************************** ** ** test_libver_bounds_super_create(): @@ -5718,19 +5783,21 @@ test_libver_bounds_super(hid_t fapl) static void test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - H5F_t *f = NULL; /* Internal file pointer */ - H5F_libver_t low, high; /* Low and high bounds */ - hbool_t ok; /* The result is ok or not */ - herr_t ret; /* The return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + H5F_t * f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + hbool_t ok; /* The result is ok or not */ + herr_t ret; /* The return value */ /* Try to create the file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILE8, H5F_ACC_TRUNC | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; /* Get the internal file pointer if the create succeeds */ - if(fid >= 0) { + if (fid >= 0) { f = (H5F_t *)H5VL_object(fid); CHECK(f, NULL, "H5VL_object"); } @@ -5739,41 +5806,41 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t n ret = H5Pget_libver_bounds(fapl, &low, &high); CHECK(ret, FAIL, "H5Pget_libver_bounds"); - if(non_def_fsm && high < H5F_LIBVER_V110) + if (non_def_fsm && high < H5F_LIBVER_V110) VERIFY(fid, H5I_INVALID_HID, "H5Fcreate"); - else if(is_swmr) { /* SWMR is enabled */ - if(high >= H5F_LIBVER_V110) { /* Should succeed */ + else if (is_swmr) { /* SWMR is enabled */ + if (high >= H5F_LIBVER_V110) { /* Should succeed */ VERIFY(fid >= 0, TRUE, "H5Fcreate"); VERIFY(HDF5_SUPERBLOCK_VERSION_3, f->shared->sblock->super_vers, "HDF5_superblock_ver_bounds"); VERIFY(f->shared->low_bound >= H5F_LIBVER_V110, TRUE, "HDF5_superblock_ver_bounds"); - - } else /* Should fail */ + } + else /* Should fail */ VERIFY(fid >= 0, FALSE, "H5Fcreate"); - - } else { /* Should succeed */ + } + else { /* Should succeed */ VERIFY(fid >= 0, TRUE, "H5Fcreate"); VERIFY(low, f->shared->low_bound, "HDF5_superblock_ver_bounds"); - switch(low) { + switch (low) { case H5F_LIBVER_EARLIEST: - ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_DEF || - f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1 || - f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2); - VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); - break; + ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_DEF || + f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1 || + f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; case H5F_LIBVER_V18: - ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2); - VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); - break; + ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; case H5F_LIBVER_V110: case H5F_LIBVER_V112: case H5F_LIBVER_V114: - ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_3); - VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); - break; + ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_3); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; case H5F_LIBVER_ERROR: case H5F_LIBVER_NBOUNDS: @@ -5784,7 +5851,7 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t n } /* end else */ - if(fid >= 0) { /* Close the file */ + if (fid >= 0) { /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); } @@ -5882,26 +5949,28 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t n static void test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - H5F_t *f = NULL; /* Internal file pointer */ - hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ - unsigned super_vers; /* Superblock version */ - H5F_libver_t low, high; /* Low and high bounds */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + H5F_t * f = NULL; /* Internal file pointer */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ + unsigned super_vers; /* Superblock version */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* Return value */ /* Create the file with the input fcpl and fapl */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; /* Retrieve the low/high bounds */ ret = H5Pget_libver_bounds(fapl, &low, &high); CHECK(ret, FAIL, "H5Pget_libver_bounds"); - if(non_def_fsm && high < H5F_LIBVER_V110) { + if (non_def_fsm && high < H5F_LIBVER_V110) { VERIFY(fid, H5I_INVALID_HID, "H5Fcreate"); - - } else { + } + else { VERIFY(fid >= 0, TRUE, "H5Fcreate"); /* Get the internal file pointer */ @@ -5920,53 +5989,60 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non CHECK(new_fapl, FAIL, "H5Pcreate"); /* Loop through all the combinations of low/high bounds in new_fapl */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; /* Invalid combinations */ if (ret < 0) continue; /* Open the file with or without SWMR access */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(FILE8, H5F_ACC_RDWR | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), new_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(non_def_fsm && high < H5F_LIBVER_V110) { + if (non_def_fsm && high < H5F_LIBVER_V110) { VERIFY(fid, H5I_INVALID_HID, "H5Fopen"); continue; } /* Get the internal file pointer if the open succeeds */ - if(fid >= 0) { + if (fid >= 0) { f = (H5F_t *)H5VL_object(fid); CHECK(f, NULL, "H5VL_object"); } /* Verify the file open succeeds or fails */ - switch(super_vers) { + switch (super_vers) { case 3: - if(high >= H5F_LIBVER_V110) { + if (high >= H5F_LIBVER_V110) { /* Should succeed */ VERIFY(fid >= 0, TRUE, "H5Fopen"); - VERIFY(f->shared->low_bound >= H5F_LIBVER_V110, TRUE, "HDF5_superblock_ver_bounds"); + VERIFY(f->shared->low_bound >= H5F_LIBVER_V110, TRUE, + "HDF5_superblock_ver_bounds"); /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - } else /* Should fail */ + } + else /* Should fail */ VERIFY(fid >= 0, FALSE, "H5Fopen"); break; case 2: - if(is_swmr) /* Should fail */ + if (is_swmr) /* Should fail */ VERIFY(fid >= 0, FALSE, "H5Fopen"); else { /* Should succeed */ VERIFY(fid >= 0, TRUE, "H5Fopen"); - VERIFY(f->shared->low_bound >= H5F_LIBVER_V18, TRUE, "HDF5_superblock_ver_bounds"); + VERIFY(f->shared->low_bound >= H5F_LIBVER_V18, TRUE, + "HDF5_superblock_ver_bounds"); /* Close the file */ ret = H5Fclose(fid); @@ -5976,7 +6052,7 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non case 1: case 0: - if(is_swmr) /* Should fail */ + if (is_swmr) /* Should fail */ VERIFY(fid >= 0, FALSE, "H5Fopen"); else { /* Should succeed */ VERIFY(fid >= 0, TRUE, "H5Fopen"); @@ -5990,8 +6066,8 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non default: break; } /* end switch */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the file access property list */ ret = H5Pclose(new_fapl); @@ -6029,15 +6105,15 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non static void test_libver_bounds_obj(hid_t fapl) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ - hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ - H5F_t *f = NULL; /* Internal file pointer */ - H5F_libver_t low, high; /* Low and high bounds */ - H5O_native_info_t ninfo; /* Object info */ - H5G_info_t ginfo; /* Group info */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ + H5F_t * f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + H5O_native_info_t ninfo; /* Object info */ + H5G_info_t ginfo; /* Group info */ + herr_t ret; /* Return value */ /* Retrieve the low/high bounds from the input fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); @@ -6096,21 +6172,25 @@ test_libver_bounds_obj(hid_t fapl) /* Loop through all the combinations of low/high bounds in new_fapl */ /* Open the file with the fapl; create a group and verify the object header version, then delete the group and close the file.*/ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid combinations */ continue; /* Open the file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(fid >=0 ) { /* The file open succeeds */ + if (fid >= 0) { /* The file open succeeds */ /* Get the internal file pointer */ f = (H5F_t *)H5VL_object(fid); @@ -6125,7 +6205,7 @@ test_libver_bounds_obj(hid_t fapl) CHECK(ret, FAIL, "H5Gget_info"); /* Verify group storage type */ - if(f->shared->low_bound >= H5F_LIBVER_V18) + if (f->shared->low_bound >= H5F_LIBVER_V18) /* Links in group are stored in object header */ VERIFY(ginfo.storage_type, H5G_STORAGE_TYPE_COMPACT, "H5Gget_info"); else @@ -6152,8 +6232,8 @@ test_libver_bounds_obj(hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the file access property list */ ret = H5Pclose(new_fapl); @@ -6189,20 +6269,20 @@ test_libver_bounds_obj(hid_t fapl) static void test_libver_bounds_dataset(hid_t fapl) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ - H5D_t *dset = NULL; /* Internal dataset pointer */ - H5F_t *f = NULL; /* Internal file pointer */ - H5F_libver_t low, high; /* Low and high bounds */ - herr_t ret; /* Return value */ - hsize_t fix_dims2[2] = {10, 4}; /* Dimension sizes */ - hsize_t fix_chunks2[2] = {4, 3}; /* Chunk dimension sizes */ - hsize_t dims2[2] = {1, 4}; /* Dimension sizes */ - hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunks2[2] = {4, 5}; /* Chunk dimension sizes */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + H5D_t * dset = NULL; /* Internal dataset pointer */ + H5F_t * f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* Return value */ + hsize_t fix_dims2[2] = {10, 4}; /* Dimension sizes */ + hsize_t fix_chunks2[2] = {4, 3}; /* Chunk dimension sizes */ + hsize_t dims2[2] = {1, 4}; /* Dimension sizes */ + hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks2[2] = {4, 5}; /* Chunk dimension sizes */ /* Retrieve the low/high bounds from the input fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); @@ -6225,12 +6305,13 @@ test_libver_bounds_dataset(hid_t fapl) CHECK(dset, NULL, "H5VL_object"); /* Verify version for layout and fill value messages */ - if(low == H5F_LIBVER_EARLIEST) { + if (low == H5F_LIBVER_EARLIEST) { /* For layout message: the earliest version the library will set is 3 */ /* For fill value message: the earliest version the library will set is 2 */ VERIFY(dset->shared->layout.version, H5O_LAYOUT_VERSION_DEFAULT, "H5O_layout_ver_bounds"); VERIFY(dset->shared->dcpl_cache.fill.version, H5O_FILL_VERSION_2, "H5O_fill_ver_bounds"); - } else { + } + else { VERIFY(dset->shared->layout.version, H5O_layout_ver_bounds[low], "H5O_layout_ver_bounds"); VERIFY(dset->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[low], "H5O_fill_ver_bounds"); } @@ -6259,11 +6340,13 @@ test_libver_bounds_dataset(hid_t fapl) CHECK(ret, FAIL, "H5Pset_chunk_opts"); /* Create the chunked dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { did = H5Dcreate2(fid, DSETB, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; - if(did >= 0) { + if (did >= 0) { /* Get the internal dataset pointer */ dset = (H5D_t *)H5VL_object(did); @@ -6307,21 +6390,25 @@ test_libver_bounds_dataset(hid_t fapl) /* Loop through all the combinations of low/high bounds in new_fapl */ /* Open the file with the fapl and create the chunked dataset */ /* Verify the dataset's layout, fill value and filter pipleline message versions */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ continue; /* Open the file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(fid >=0 ) { /* The file open succeeds */ + if (fid >= 0) { /* The file open succeeds */ /* Get the internal file pointer */ f = (H5F_t *)H5VL_object(fid); @@ -6337,21 +6424,25 @@ test_libver_bounds_dataset(hid_t fapl) /* Verify the dataset's layout, fill value and filter pipeline message versions */ /* Also verify the chunk indexing type */ - if(f->shared->low_bound == H5F_LIBVER_EARLIEST) { + if (f->shared->low_bound == H5F_LIBVER_EARLIEST) { /* For layout message: the earliest version the library will set is 3 */ /* For fill value message: the earliest version the library will set is 2 */ VERIFY(dset->shared->layout.version, H5O_LAYOUT_VERSION_DEFAULT, "H5O_layout_ver_bounds"); VERIFY(dset->shared->dcpl_cache.fill.version, H5O_FILL_VERSION_2, "H5O_fill_ver_bounds"); - } else { - VERIFY(dset->shared->layout.version, H5O_layout_ver_bounds[f->shared->low_bound], "H5O_layout_ver_bounds"); - VERIFY(dset->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[f->shared->low_bound], "H5O_fill_ver_bounds"); + } + else { + VERIFY(dset->shared->layout.version, H5O_layout_ver_bounds[f->shared->low_bound], + "H5O_layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[f->shared->low_bound], + "H5O_fill_ver_bounds"); } /* Verify the filter pipeline message version */ - VERIFY(dset->shared->dcpl_cache.pline.version, H5O_pline_ver_bounds[f->shared->low_bound], "H5O_pline_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.pline.version, H5O_pline_ver_bounds[f->shared->low_bound], + "H5O_pline_ver_bounds"); /* Verify the dataset's chunk indexing type */ - if(dset->shared->layout.version == H5O_LAYOUT_VERSION_LATEST) + if (dset->shared->layout.version == H5O_LAYOUT_VERSION_LATEST) VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_BT2, "chunk_index_type"); else VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_BTREE, "chunk_index_type"); @@ -6369,8 +6460,8 @@ test_libver_bounds_dataset(hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the file access property list */ ret = H5Pclose(new_fapl); @@ -6413,22 +6504,22 @@ test_libver_bounds_dataset(hid_t fapl) static void test_libver_bounds_dataspace(hid_t fapl) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ - hid_t did = H5I_INVALID_HID, did_null = H5I_INVALID_HID; /* Dataset IDs */ - hid_t did_compact = H5I_INVALID_HID, did_contig = H5I_INVALID_HID; /* Dataset IDs */ - hid_t sid = H5I_INVALID_HID, sid_null = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid_compact = H5I_INVALID_HID, sid_contig = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ - hid_t dcpl_compact = H5I_INVALID_HID, dcpl_contig = H5I_INVALID_HID; /* Dataset creation property lists */ - H5S_t *space = NULL, *space_null = NULL; /* Internal dataspace pointers */ - H5F_t *f = NULL; /* Internal file pointer */ - H5F_libver_t low, high; /* Low and high bounds */ - hsize_t dims[1] = {1}; /* Dimension sizes */ - hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ - hsize_t max_dims[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunks[1] = {4}; /* Chunk dimension sizes */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ + hid_t did = H5I_INVALID_HID, did_null = H5I_INVALID_HID; /* Dataset IDs */ + hid_t did_compact = H5I_INVALID_HID, did_contig = H5I_INVALID_HID; /* Dataset IDs */ + hid_t sid = H5I_INVALID_HID, sid_null = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid_compact = H5I_INVALID_HID, sid_contig = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hid_t dcpl_compact = H5I_INVALID_HID, dcpl_contig = H5I_INVALID_HID; /* Dataset creation property lists */ + H5S_t * space = NULL, *space_null = NULL; /* Internal dataspace pointers */ + H5F_t * f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + hsize_t dims[1] = {1}; /* Dimension sizes */ + hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ + hsize_t max_dims[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks[1] = {4}; /* Chunk dimension sizes */ + herr_t ret; /* Return value */ /* Retrieve the low/high bounds from the input fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); @@ -6520,24 +6611,28 @@ test_libver_bounds_dataspace(hid_t fapl) /* Loop through all the combinations of low/high bounds in new_fapl */ /* Open the file and create the chunked/compact/contiguous datasets */ /* Verify the dataspace message version for the three datasets */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - hid_t tmp_sid, tmp_sid_compact, tmp_sid_contig; /* Dataspace IDs */ - H5S_t *tmp_space, *tmp_space_compact, *tmp_space_contig; /* Internal dataspace pointers */ + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + hid_t tmp_sid, tmp_sid_compact, tmp_sid_contig; /* Dataspace IDs */ + H5S_t *tmp_space, *tmp_space_compact, *tmp_space_contig; /* Internal dataspace pointers */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ continue; /* Open the file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(fid >=0 ) { /* The file open succeeds */ + if (fid >= 0) { /* The file open succeeds */ /* Get the internal file pointer */ f = (H5F_t *)H5VL_object(fid); @@ -6554,7 +6649,8 @@ test_libver_bounds_dataspace(hid_t fapl) CHECK(tmp_space, NULL, "H5I_object"); /* Create the compact dataset */ - did_compact = H5Dcreate2(fid, DSETB, H5T_NATIVE_INT, sid_compact, H5P_DEFAULT, dcpl_compact, H5P_DEFAULT); + did_compact = H5Dcreate2(fid, DSETB, H5T_NATIVE_INT, sid_compact, H5P_DEFAULT, dcpl_compact, + H5P_DEFAULT); CHECK(did_compact, H5I_INVALID_HID, "H5Dcreate2"); /* Get the internal dataspace pointer for the compact dataset */ @@ -6564,7 +6660,8 @@ test_libver_bounds_dataspace(hid_t fapl) CHECK(tmp_space_compact, NULL, "H5I_object"); /* Create the contiguous dataset */ - did_contig = H5Dcreate2(fid, DSETC, H5T_NATIVE_INT, sid_contig, H5P_DEFAULT, dcpl_contig, H5P_DEFAULT); + did_contig = + H5Dcreate2(fid, DSETC, H5T_NATIVE_INT, sid_contig, H5P_DEFAULT, dcpl_contig, H5P_DEFAULT); CHECK(did_contig, H5I_INVALID_HID, "H5Dcreate2"); /* Get the internal dataspace pointer for the contiguous dataset */ @@ -6574,9 +6671,12 @@ test_libver_bounds_dataspace(hid_t fapl) CHECK(tmp_space_contig, NULL, "H5I_object"); /* Verify versions for the three dataspaces */ - VERIFY(tmp_space->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], "H5O_sdspace_ver_bounds"); - VERIFY(tmp_space_compact->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], "H5O_sdspace_ver_bounds"); - VERIFY(tmp_space_contig->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], "H5O_sdspace_ver_bounds"); + VERIFY(tmp_space->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], + "H5O_sdspace_ver_bounds"); + VERIFY(tmp_space_compact->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], + "H5O_sdspace_ver_bounds"); + VERIFY(tmp_space_contig->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], + "H5O_sdspace_ver_bounds"); /* Close the three datasets */ ret = H5Dclose(did); @@ -6607,8 +6707,8 @@ test_libver_bounds_dataspace(hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the file access property list */ ret = H5Pclose(new_fapl); @@ -6632,7 +6732,6 @@ test_libver_bounds_dataspace(hid_t fapl) } /* end test_libver_bounds_dataspace() */ - /**************************************************************** ** ** test_libver_bounds_datatype(): @@ -6651,15 +6750,15 @@ test_libver_bounds_dataspace(hid_t fapl) static void test_libver_bounds_datatype(hid_t fapl) { - hid_t tid = H5I_INVALID_HID, tid_enum = H5I_INVALID_HID, tid_array = H5I_INVALID_HID; /* Datatype IDs */ - hid_t tid_compound = H5I_INVALID_HID, tid_vlen = H5I_INVALID_HID; /* Datatype IDs */ - int enum_value; /* Value for enum datatype */ + hid_t tid = H5I_INVALID_HID, tid_enum = H5I_INVALID_HID, tid_array = H5I_INVALID_HID; /* Datatype IDs */ + hid_t tid_compound = H5I_INVALID_HID, tid_vlen = H5I_INVALID_HID; /* Datatype IDs */ + int enum_value; /* Value for enum datatype */ typedef struct s1 { /* Data structure for compound datatype */ char c; int i; } s1; - hsize_t dims[1] = {1}; /* Dimension sizes */ - herr_t ret; /* Return value */ + hsize_t dims[1] = {1}; /* Dimension sizes */ + herr_t ret; /* Return value */ /* Create integer datatype */ tid = H5Tcopy(H5T_NATIVE_INT); @@ -6668,7 +6767,7 @@ test_libver_bounds_datatype(hid_t fapl) test_libver_bounds_datatype_check(fapl, tid); /* Create enum datatype */ - tid_enum = H5Tenum_create(tid); + tid_enum = H5Tenum_create(tid); enum_value = 0; H5Tenum_insert(tid_enum, "val1", &enum_value); enum_value = 1; @@ -6743,22 +6842,22 @@ test_libver_bounds_datatype(hid_t fapl) static void test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t new_fapl = H5I_INVALID_HID; /* File acess property list */ - hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ - hid_t dtid = H5I_INVALID_HID; /* Datatype ID for the dataset */ - hid_t str_tid = H5I_INVALID_HID; /* String datatype ID */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hsize_t dims[1] = {1}; /* Dimension sizes */ - hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ - hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunks[2] = {2, 3}; /* Chunk dimension sizes */ - H5T_t *dtype = NULL; /* Internal datatype pointer */ - H5T_t *str_dtype = NULL; /* Internal datatype pointer for the string datatype */ - H5F_t *f = NULL; /* Internal file pointer */ - H5F_libver_t low, high; /* Low and high bounds */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t new_fapl = H5I_INVALID_HID; /* File acess property list */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hid_t dtid = H5I_INVALID_HID; /* Datatype ID for the dataset */ + hid_t str_tid = H5I_INVALID_HID; /* String datatype ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hsize_t dims[1] = {1}; /* Dimension sizes */ + hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ + hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks[2] = {2, 3}; /* Chunk dimension sizes */ + H5T_t * dtype = NULL; /* Internal datatype pointer */ + H5T_t * str_dtype = NULL; /* Internal datatype pointer for the string datatype */ + H5F_t * f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* Return value */ /* Retrieve the low/high version bounds from the input fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); @@ -6803,14 +6902,14 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) * --the library will only use basic version */ - if(dtype->shared->type == H5T_COMPOUND || - dtype->shared->type == H5T_ENUM || - dtype->shared->type == H5T_ARRAY) { - if(dtype->shared->type == H5T_ARRAY && low == H5F_LIBVER_EARLIEST) + if (dtype->shared->type == H5T_COMPOUND || dtype->shared->type == H5T_ENUM || + dtype->shared->type == H5T_ARRAY) { + if (dtype->shared->type == H5T_ARRAY && low == H5F_LIBVER_EARLIEST) VERIFY(dtype->shared->version, H5O_DTYPE_VERSION_2, "H5O_dtype_ver_bounds"); else VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[low], "H5O_dtype_ver_bounds"); - } else + } + else VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "H5O_dtype_ver_bounds"); /* Close the dataset */ @@ -6845,21 +6944,25 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) /* Open the file and create the chunked dataset with the input tid */ /* Verify the dataset's datatype message version */ /* Also verify the committed atatype message version */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ continue; /* Open the file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(fid >= 0 ) { /* The file open succeeds */ + if (fid >= 0) { /* The file open succeeds */ /* Get the internal file pointer */ f = (H5F_t *)H5VL_object(fid); @@ -6872,13 +6975,13 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) CHECK(str_dtype, NULL, "H5VL_object"); /* Verify the committed datatype message version */ - VERIFY(str_dtype->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "H5O_dtype_ver_bounds"); + VERIFY(str_dtype->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], + "H5O_dtype_ver_bounds"); /* Close the committed datatype */ ret = H5Tclose(str_tid); CHECK(ret, FAIL, "H5Tclose"); - /* Create the chunked dataset */ did = H5Dcreate2(fid, DSETNAME, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(did, H5I_INVALID_HID, "H5Dcreate2"); @@ -6898,16 +7001,17 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) * H5T_INTEGER, H5T_FLOAT, H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_REFERENCE: * --the library will only use basic version */ - if(dtype->shared->type == H5T_COMPOUND || - dtype->shared->type == H5T_ENUM || - dtype->shared->type == H5T_ARRAY) { - if(dtype->shared->type == H5T_ARRAY && - f->shared->low_bound == H5F_LIBVER_EARLIEST) + if (dtype->shared->type == H5T_COMPOUND || dtype->shared->type == H5T_ENUM || + dtype->shared->type == H5T_ARRAY) { + if (dtype->shared->type == H5T_ARRAY && f->shared->low_bound == H5F_LIBVER_EARLIEST) VERIFY(dtype->shared->version, H5O_DTYPE_VERSION_2, "H5O_dtype_ver_bounds"); else - VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[f->shared->low_bound], "H5O_dtype_ver_bounds"); - } else - VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "H5O_dtype_ver_bounds"); + VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[f->shared->low_bound], + "H5O_dtype_ver_bounds"); + } + else + VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], + "H5O_dtype_ver_bounds"); /* Close the dataset */ ret = H5Dclose(did); @@ -6926,8 +7030,8 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) CHECK(ret, FAIL, "H5Fclose"); } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the file access property list */ ret = H5Pclose(new_fapl); @@ -6978,18 +7082,18 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) static void test_libver_bounds_attributes(hid_t fapl) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ - hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ - hid_t tid = H5I_INVALID_HID; /* Datatype ID */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hid_t aid = H5I_INVALID_HID; /* Attribute ID */ - hid_t attr_cpl = H5I_INVALID_HID; /* Attribute creation property list */ - H5A_t *attr = NULL; /* Internal attribute pointer */ - H5F_t *f = NULL; /* Internal file pointer */ - H5F_libver_t low, high; /* Low and high bounds */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ + hid_t tid = H5I_INVALID_HID; /* Datatype ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t attr_cpl = H5I_INVALID_HID; /* Attribute creation property list */ + H5A_t * attr = NULL; /* Internal attribute pointer */ + H5F_t * f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* Return value */ /* Retrieve the low/high bounds from the input fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); @@ -7024,7 +7128,7 @@ test_libver_bounds_attributes(hid_t fapl) CHECK(attr, NULL, "H5VL_object"); /* Verify the attribute version */ - if(low == H5F_LIBVER_EARLIEST) + if (low == H5F_LIBVER_EARLIEST) /* The earliest version the library can set for an attribute with committed datatype is 2 */ VERIFY(attr->shared->version, H5O_ATTR_VERSION_2, "H5O_attr_ver_bounds"); else @@ -7064,7 +7168,7 @@ test_libver_bounds_attributes(hid_t fapl) CHECK(attr, NULL, "H5VL_object"); /* Verify attribute version */ - if(low == H5F_LIBVER_EARLIEST) + if (low == H5F_LIBVER_EARLIEST) /* The earliest version the library can set for an attribute with character encoding is 3 */ VERIFY(attr->shared->version, H5O_ATTR_VERSION_3, "H5O_attr_ver_bounds"); else @@ -7129,7 +7233,7 @@ test_libver_bounds_attributes(hid_t fapl) CHECK(attr, NULL, "H5VL_object"); /* Verify the attribute version */ - if(low == H5F_LIBVER_EARLIEST) + if (low == H5F_LIBVER_EARLIEST) /* The earliest version the library can set for an attribute with shared datatype is 2 */ VERIFY(attr->shared->version, H5O_ATTR_VERSION_2, "H5O_attr_ver_bounds"); else @@ -7166,21 +7270,25 @@ test_libver_bounds_attributes(hid_t fapl) /* Loop through all the combinations of low/high bounds */ /* Open the file and group and attach an attribute to the group */ /* Verify the attribute version */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; - if(ret < 0) /* Invalid low/high combinations */ + if (ret < 0) /* Invalid low/high combinations */ continue; /* Open the file */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(fid >=0 ) { /* The file open succeeds */ + if (fid >= 0) { /* The file open succeeds */ /* Get the internal file pointer */ f = (H5F_t *)H5VL_object(fid); @@ -7199,7 +7307,8 @@ test_libver_bounds_attributes(hid_t fapl) CHECK(attr, NULL, "H5VL_object"); /* Verify the attribute message version */ - VERIFY(attr->shared->version, H5O_attr_ver_bounds[f->shared->low_bound], "H5O_attr_ver_bounds"); + VERIFY(attr->shared->version, H5O_attr_ver_bounds[f->shared->low_bound], + "H5O_attr_ver_bounds"); /* Close the attribute */ ret = H5Aclose(aid); @@ -7218,8 +7327,8 @@ test_libver_bounds_attributes(hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Close the file access property list */ ret = H5Pclose(new_fapl); @@ -7240,44 +7349,44 @@ test_libver_bounds_attributes(hid_t fapl) static void test_libver_macros(void) { - int major = H5_VERS_MAJOR; - int minor = H5_VERS_MINOR; - int release = H5_VERS_RELEASE; + int major = H5_VERS_MAJOR; + int minor = H5_VERS_MINOR; + int release = H5_VERS_RELEASE; /* Output message about test being performed */ MESSAGE(5, ("Testing macros for library version comparison\n")); - VERIFY(H5_VERSION_GE(major,minor,release), TRUE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major-1,minor,release), TRUE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major-1,minor+1,release), TRUE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major-1,minor,release+1), TRUE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major,minor-1,release), TRUE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major,minor-1,release+1), TRUE, "H5_VERSION_GE"); - if(H5_VERS_RELEASE > 0) - VERIFY(H5_VERSION_GE(major,minor,release-1), TRUE, "H5_VERSION_GE"); - - VERIFY(H5_VERSION_GE(major+1,minor,release), FALSE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major+1,minor-1,release), FALSE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major+1,minor-1,release-1), FALSE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major,minor+1,release), FALSE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major,minor+1,release-1), FALSE, "H5_VERSION_GE"); - VERIFY(H5_VERSION_GE(major,minor,release+1), FALSE, "H5_VERSION_GE"); - - VERIFY(H5_VERSION_LE(major,minor,release), TRUE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major+1,minor,release), TRUE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major+1,minor-1,release), TRUE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major+1,minor-1,release-1), TRUE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major,minor+1,release), TRUE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major,minor+1,release-1), TRUE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major,minor,release+1), TRUE, "H5_VERSION_LE"); - - VERIFY(H5_VERSION_LE(major-1,minor,release), FALSE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major-1,minor+1,release), FALSE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major-1,minor+1,release+1), FALSE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major,minor-1,release), FALSE, "H5_VERSION_LE"); - VERIFY(H5_VERSION_LE(major,minor-1,release+1), FALSE, "H5_VERSION_LE"); - if(H5_VERS_RELEASE > 0) - VERIFY(H5_VERSION_LE(major,minor,release-1), FALSE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_GE(major, minor, release), TRUE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major - 1, minor, release), TRUE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major - 1, minor + 1, release), TRUE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major - 1, minor, release + 1), TRUE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major, minor - 1, release), TRUE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major, minor - 1, release + 1), TRUE, "H5_VERSION_GE"); + if (H5_VERS_RELEASE > 0) + VERIFY(H5_VERSION_GE(major, minor, release - 1), TRUE, "H5_VERSION_GE"); + + VERIFY(H5_VERSION_GE(major + 1, minor, release), FALSE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major + 1, minor - 1, release), FALSE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major + 1, minor - 1, release - 1), FALSE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major, minor + 1, release), FALSE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major, minor + 1, release - 1), FALSE, "H5_VERSION_GE"); + VERIFY(H5_VERSION_GE(major, minor, release + 1), FALSE, "H5_VERSION_GE"); + + VERIFY(H5_VERSION_LE(major, minor, release), TRUE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major + 1, minor, release), TRUE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major + 1, minor - 1, release), TRUE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major + 1, minor - 1, release - 1), TRUE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major, minor + 1, release), TRUE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major, minor + 1, release - 1), TRUE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major, minor, release + 1), TRUE, "H5_VERSION_LE"); + + VERIFY(H5_VERSION_LE(major - 1, minor, release), FALSE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major - 1, minor + 1, release), FALSE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major - 1, minor + 1, release + 1), FALSE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major, minor - 1, release), FALSE, "H5_VERSION_LE"); + VERIFY(H5_VERSION_LE(major, minor - 1, release + 1), FALSE, "H5_VERSION_LE"); + if (H5_VERS_RELEASE > 0) + VERIFY(H5_VERSION_LE(major, minor, release - 1), FALSE, "H5_VERSION_LE"); } /* test_libver_macros() */ /**************************************************************** @@ -7290,10 +7399,10 @@ test_libver_macros(void) static void test_libver_macros2(void) { - hid_t file; - hid_t grp; - htri_t status; - herr_t ret; /* Return value */ + hid_t file; + hid_t grp; + htri_t status; + herr_t ret; /* Return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing macros for library version comparison with a file\n")); @@ -7320,7 +7429,7 @@ test_libver_macros2(void) * Delete the group using different function based on the library version. * And verify the action. */ -#if H5_VERSION_GE(1,8,0) +#if H5_VERSION_GE(1, 8, 0) ret = H5Ldelete(file, "Group", H5P_DEFAULT); CHECK(ret, FAIL, "H5Lunlink"); @@ -7330,9 +7439,11 @@ test_libver_macros2(void) ret = H5Gunlink(file, "Group"); CHECK(ret, FAIL, "H5Gunlink"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { grp = H5Gopen(file, "Group"); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(grp, FAIL, "H5Gopen"); #endif @@ -7354,20 +7465,20 @@ test_libver_macros2(void) static void test_incr_filesize(void) { - hid_t fid; /* File opened with read-write permission */ - h5_stat_size_t filesize; /* Size of file when empty */ - hid_t fcpl; /* File creation property list */ - hid_t fapl; /* File access property list */ - hid_t dspace; /* Dataspace ID */ - hid_t dset; /* Dataset ID */ - hid_t dcpl; /* Dataset creation property list */ - unsigned u; /* Local index variable */ - char filename[FILENAME_LEN]; /* Filename to use */ - char name[32]; /* Dataset name */ - haddr_t stored_eoa; /* The stored EOA value */ - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - herr_t ret; /* Return value */ + hid_t fid; /* File opened with read-write permission */ + h5_stat_size_t filesize; /* Size of file when empty */ + hid_t fcpl; /* File creation property list */ + hid_t fapl; /* File access property list */ + hid_t dspace; /* Dataspace ID */ + hid_t dset; /* Dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + unsigned u; /* Local index variable */ + char filename[FILENAME_LEN]; /* Filename to use */ + char name[32]; /* Dataset name */ + haddr_t stored_eoa; /* The stored EOA value */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + herr_t ret; /* Return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing H5Fincrement_filesize() and H5Fget_eoa())\n")); @@ -7383,7 +7494,7 @@ test_incr_filesize(void) CHECK(ret, FAIL, "H5PDdriver_query"); /* Check whether the VFD feature flag supports these two public routines */ - if(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO) { + if (driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO) { fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); @@ -7409,7 +7520,7 @@ test_incr_filesize(void) CHECK(ret, FAIL, "H5Pset_alloc_time"); /* Create datasets in file */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { HDsprintf(name, "Dataset %u", u); dset = H5Dcreate2(fid, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate2"); @@ -7456,7 +7567,7 @@ test_incr_filesize(void) filesize = h5_get_file_size(filename, fapl); /* Verify the filesize is the previous stored_eoa + 512 */ - VERIFY(filesize, stored_eoa+512, "file size"); + VERIFY(filesize, stored_eoa + 512, "file size"); /* Close the file access property list */ ret = H5Pclose(fapl); @@ -7481,10 +7592,10 @@ test_incr_filesize(void) static void test_min_dset_ohdr(void) { - const char basename[] = "min_dset_ohdr_testfile"; - char filename[FILENAME_LEN] = ""; - hid_t file_id = -1; - hid_t file2_id = -1; + const char basename[] = "min_dset_ohdr_testfile"; + char filename[FILENAME_LEN] = ""; + hid_t file_id = -1; + hid_t file2_id = -1; hbool_t minimize; herr_t ret; @@ -7567,21 +7678,27 @@ test_min_dset_ohdr(void) */ /* trying to set with invalid file ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fset_dset_no_attrs_hint(-1, TRUE); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Fset_dset_no_attrs_hint"); /* trying to get with invalid file ID */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fget_dset_no_attrs_hint(-1, &minimize); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Fget_dset_no_attrs_hint"); /* trying to get with invalid pointer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fget_dset_no_attrs_hint(file_id, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Fget_dset_no_attrs_hint"); /************/ @@ -7604,17 +7721,17 @@ test_min_dset_ohdr(void) static void test_deprec(void) { - hid_t file; /* File IDs for old & new files */ - hid_t fcpl; /* File creation property list */ - hid_t fapl; /* File creation property list */ - hid_t new_fapl; - hsize_t align; - unsigned super; /* Superblock version # */ - unsigned freelist; /* Free list version # */ - unsigned stab; /* Symbol table entry version # */ - unsigned shhdr; /* Shared object header version # */ - H5F_info1_t finfo; /* global information about file */ - herr_t ret; /* Generic return value */ + hid_t file; /* File IDs for old & new files */ + hid_t fcpl; /* File creation property list */ + hid_t fapl; /* File creation property list */ + hid_t new_fapl; + hsize_t align; + unsigned super; /* Superblock version # */ + unsigned freelist; /* Free list version # */ + unsigned stab; /* Symbol table entry version # */ + unsigned shhdr; /* Shared object header version # */ + H5F_info1_t finfo; /* global information about file */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing deprecated routines\n")); @@ -7624,38 +7741,37 @@ test_deprec(void) */ /* Create file with default file creation property list */ - file= H5Fcreate(FILE1, H5F_ACC_TRUNC , H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); /* Get the file's version information */ ret = H5Fget_info1(file, &finfo); CHECK(ret, FAIL, "H5Fget_info1"); - VERIFY(finfo.super_ext_size, 0,"H5Fget_info1"); - VERIFY(finfo.sohm.hdr_size, 0,"H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.index_size, 0,"H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.heap_size, 0,"H5Fget_info1"); + VERIFY(finfo.super_ext_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.hdr_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.index_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.heap_size, 0, "H5Fget_info1"); /* Get the file's dataset creation property list */ - fcpl = H5Fget_create_plist(file); + fcpl = H5Fget_create_plist(file); CHECK(fcpl, FAIL, "H5Fget_create_plist"); /* Get the file's version information */ - ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + ret = H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); CHECK(ret, FAIL, "H5Pget_version"); - VERIFY(super,0,"H5Pget_version"); - VERIFY(freelist,0,"H5Pget_version"); - VERIFY(stab,0,"H5Pget_version"); - VERIFY(shhdr,0,"H5Pget_version"); + VERIFY(super, 0, "H5Pget_version"); + VERIFY(freelist, 0, "H5Pget_version"); + VERIFY(stab, 0, "H5Pget_version"); + VERIFY(shhdr, 0, "H5Pget_version"); /* Close FCPL */ - ret=H5Pclose(fcpl); + ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); /* Close file */ - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); - /* Create a file creation property list */ fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); @@ -7666,7 +7782,7 @@ test_deprec(void) CHECK(ret, FAIL, "H5Pset_file_space_strategy"); fapl = H5Pcreate(H5P_FILE_ACCESS); - ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024); CHECK(ret, FAIL, "H5Pset_alignment"); /* Creating a file with the non-default file creation property list should @@ -7674,42 +7790,42 @@ test_deprec(void) */ /* Create file with custom file creation property list */ - file= H5Fcreate(FILE1, H5F_ACC_TRUNC , fcpl, fapl); + file = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); CHECK(file, FAIL, "H5Fcreate"); new_fapl = H5Fget_access_plist(file); H5Pget_alignment(new_fapl, NULL, &align); /* Close FCPL */ - ret=H5Pclose(fcpl); + ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); /* Get the file's version information */ ret = H5Fget_info1(file, &finfo); CHECK(ret, FAIL, "H5Fget_info1"); - VERIFY(finfo.super_ext_size, 152,"H5Fget_info1"); - VERIFY(finfo.sohm.hdr_size, 0,"H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.index_size, 0,"H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.heap_size, 0,"H5Fget_info1"); + VERIFY(finfo.super_ext_size, 152, "H5Fget_info1"); + VERIFY(finfo.sohm.hdr_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.index_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.heap_size, 0, "H5Fget_info1"); /* Get the file's dataset creation property list */ - fcpl = H5Fget_create_plist(file); + fcpl = H5Fget_create_plist(file); CHECK(fcpl, FAIL, "H5Fget_create_plist"); /* Get the file's version information */ - ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + ret = H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); CHECK(ret, FAIL, "H5Pget_version"); - VERIFY(super,2,"H5Pget_version"); - VERIFY(freelist,0,"H5Pget_version"); - VERIFY(stab,0,"H5Pget_version"); - VERIFY(shhdr,0,"H5Pget_version"); + VERIFY(super, 2, "H5Pget_version"); + VERIFY(freelist, 0, "H5Pget_version"); + VERIFY(stab, 0, "H5Pget_version"); + VERIFY(shhdr, 0, "H5Pget_version"); /* Close FCPL */ - ret=H5Pclose(fcpl); + ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); /* Close file */ - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Re-open the file */ @@ -7719,37 +7835,37 @@ test_deprec(void) /* Get the file's version information */ ret = H5Fget_info1(file, &finfo); CHECK(ret, FAIL, "H5Fget_info1"); - VERIFY(finfo.super_ext_size, 152,"H5Fget_info1"); - VERIFY(finfo.sohm.hdr_size, 0,"H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.index_size, 0,"H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.heap_size, 0,"H5Fget_info1"); + VERIFY(finfo.super_ext_size, 152, "H5Fget_info1"); + VERIFY(finfo.sohm.hdr_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.index_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.heap_size, 0, "H5Fget_info1"); /* Get the file's creation property list */ - fcpl = H5Fget_create_plist(file); + fcpl = H5Fget_create_plist(file); CHECK(fcpl, FAIL, "H5Fget_create_plist"); /* Get the file's version information */ - ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + ret = H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); CHECK(ret, FAIL, "H5Pget_version"); - VERIFY(super,2,"H5Pget_version"); - VERIFY(freelist,0,"H5Pget_version"); - VERIFY(stab,0,"H5Pget_version"); - VERIFY(shhdr,0,"H5Pget_version"); + VERIFY(super, 2, "H5Pget_version"); + VERIFY(freelist, 0, "H5Pget_version"); + VERIFY(stab, 0, "H5Pget_version"); + VERIFY(shhdr, 0, "H5Pget_version"); /* Close FCPL */ - ret=H5Pclose(fcpl); + ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); /* Close file */ - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); { /* Test deprecated H5Pget/set_file_space() */ H5F_file_space_type_t old_strategy; - hsize_t old_threshold; - hid_t fid; - hid_t ffcpl; + hsize_t old_threshold; + hid_t fid; + hid_t ffcpl; fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); @@ -7778,19 +7894,19 @@ test_deprec(void) VERIFY(old_threshold, 3, "H5Pget_file_space"); /* Create a file */ - fid = H5Fcreate(FILE1, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); - old_strategy = H5F_FILE_SPACE_DEFAULT; + old_strategy = H5F_FILE_SPACE_DEFAULT; old_threshold = 0; - ffcpl = H5Fget_create_plist(fid); - ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); + ffcpl = H5Fget_create_plist(fid); + ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); CHECK(ret, FAIL, "H5Pget_file_space"); VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); VERIFY(old_threshold, 3, "H5Pget_file_space"); /* Close file */ - ret=H5Fclose(fid); + ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); ret = H5Pclose(ffcpl); @@ -7803,10 +7919,10 @@ test_deprec(void) fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); - old_strategy = H5F_FILE_SPACE_DEFAULT; + old_strategy = H5F_FILE_SPACE_DEFAULT; old_threshold = 0; - ffcpl = H5Fget_create_plist(fid); - ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); + ffcpl = H5Fget_create_plist(fid); + ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); CHECK(ret, FAIL, "H5Pget_file_space"); VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); VERIFY(old_threshold, 3, "H5Pget_file_space"); @@ -7814,7 +7930,7 @@ test_deprec(void) ret = H5Pclose(ffcpl); CHECK(ret, FAIL, "H5Pclose"); - ret=H5Fclose(fid); + ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); } @@ -7829,77 +7945,80 @@ test_deprec(void) void test_file(void) { - const char *env_h5_drvr; /* File Driver value from environment */ - hid_t fapl_id = H5I_INVALID_HID; /* VFD-dependent fapl ID */ - herr_t ret; + const char *env_h5_drvr; /* File Driver value from environment */ + hid_t fapl_id = H5I_INVALID_HID; /* VFD-dependent fapl ID */ + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File I/O\n")); /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; /* Improved version of VFD-dependent checks */ fapl_id = h5_fileaccess(); CHECK(fapl_id, H5I_INVALID_HID, "h5_fileaccess"); - test_file_create(); /* Test file creation(also creation templates)*/ - test_file_open(); /* Test file opening */ - test_file_reopen(); /* Test file reopening */ - test_file_close(); /* Test file close behavior */ - test_get_file_id(); /* Test H5Iget_file_id */ - test_get_obj_ids(); /* Test H5Fget_obj_ids for Jira Issue 8528 */ - test_file_perm(); /* Test file access permissions */ - test_file_perm2(); /* Test file access permission again */ - test_file_is_accessible(env_h5_drvr); /* Test detecting HDF5 files correctly */ - test_file_delete(fapl_id); /* Test H5Fdelete */ - test_file_open_dot(); /* Test opening objects with "." for a name */ - test_file_open_overlap(); /* Test opening files in an overlapping manner */ - test_file_getname(); /* Test basic H5Fget_name() functionality */ - test_file_double_root_open(); /* Test opening root group from two files works properly */ - test_file_double_group_open(); /* Test opening same group from two files works properly */ - test_file_double_dataset_open(); /* Test opening same dataset from two files works properly */ - test_file_double_datatype_open(); /* Test opening same named datatype from two files works properly */ + test_file_create(); /* Test file creation(also creation templates)*/ + test_file_open(); /* Test file opening */ + test_file_reopen(); /* Test file reopening */ + test_file_close(); /* Test file close behavior */ + test_get_file_id(); /* Test H5Iget_file_id */ + test_get_obj_ids(); /* Test H5Fget_obj_ids for Jira Issue 8528 */ + test_file_perm(); /* Test file access permissions */ + test_file_perm2(); /* Test file access permission again */ + test_file_is_accessible(env_h5_drvr); /* Test detecting HDF5 files correctly */ + test_file_delete(fapl_id); /* Test H5Fdelete */ + test_file_open_dot(); /* Test opening objects with "." for a name */ + test_file_open_overlap(); /* Test opening files in an overlapping manner */ + test_file_getname(); /* Test basic H5Fget_name() functionality */ + test_file_double_root_open(); /* Test opening root group from two files works properly */ + test_file_double_group_open(); /* Test opening same group from two files works properly */ + test_file_double_dataset_open(); /* Test opening same dataset from two files works properly */ + test_file_double_datatype_open(); /* Test opening same named datatype from two files works properly */ test_file_double_file_dataset_open(TRUE); test_file_double_file_dataset_open(FALSE); - test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */ - test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ - test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */ - test_userblock_alignment(); /* Tests that files created with a userblock and alignment interact properly */ - test_userblock_alignment_paged(); /* Tests files created with a userblock and alignment (via paged aggregation) interact properly */ - test_filespace_info(env_h5_drvr); /* Test file creation public routines: */ - /* H5Pget/set_file_space_strategy() & H5Pget/set_file_space_page_size() */ - /* Skipped testing for multi/split drivers */ - test_file_freespace(env_h5_drvr); /* Test file public routine H5Fget_freespace() */ - /* Skipped testing for multi/split drivers */ - /* Setup for multi/split drivers are there already */ - test_sects_freespace(env_h5_drvr, TRUE); /* Test file public routine H5Fget_free_sections() for new format */ - /* Skipped testing for multi/split drivers */ - /* Setup for multi/split drivers are there already */ - test_sects_freespace(env_h5_drvr, FALSE); /* Test file public routine H5Fget_free_sections() */ - /* Skipped testing for multi/split drivers */ - test_filespace_compatible(); /* Test compatibility for file space management */ - test_filespace_round_compatible(); /* Testing file space compatibility for files from trunk to 1_8 to trunk */ - test_filespace_1_10_0_compatible(); /* Testing file space compatibility for files from release 1.10.0 */ - test_libver_bounds(); /* Test compatibility for file space management */ + test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */ + test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ + test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */ + test_userblock_alignment(); /* Tests that files created with a userblock and alignment interact properly + */ + test_userblock_alignment_paged(); /* Tests files created with a userblock and alignment (via paged + aggregation) interact properly */ + test_filespace_info(env_h5_drvr); /* Test file creation public routines: */ + /* H5Pget/set_file_space_strategy() & H5Pget/set_file_space_page_size() */ + /* Skipped testing for multi/split drivers */ + test_file_freespace(env_h5_drvr); /* Test file public routine H5Fget_freespace() */ + /* Skipped testing for multi/split drivers */ + /* Setup for multi/split drivers are there already */ + test_sects_freespace(env_h5_drvr, + TRUE); /* Test file public routine H5Fget_free_sections() for new format */ + /* Skipped testing for multi/split drivers */ + /* Setup for multi/split drivers are there already */ + test_sects_freespace(env_h5_drvr, FALSE); /* Test file public routine H5Fget_free_sections() */ + /* Skipped testing for multi/split drivers */ + test_filespace_compatible(); /* Test compatibility for file space management */ + test_filespace_round_compatible(); /* Testing file space compatibility for files from trunk to 1_8 to + trunk */ + test_filespace_1_10_0_compatible(); /* Testing file space compatibility for files from release 1.10.0 */ + test_libver_bounds(); /* Test compatibility for file space management */ test_libver_bounds_low_high(); - test_libver_macros(); /* Test the macros for library version comparison */ - test_libver_macros2(); /* Test the macros for library version comparison */ - test_incr_filesize(); /* Test H5Fincrement_filesize() and H5Fget_eoa() */ - test_min_dset_ohdr(); /* Test datset object header minimization */ + test_libver_macros(); /* Test the macros for library version comparison */ + test_libver_macros2(); /* Test the macros for library version comparison */ + test_incr_filesize(); /* Test H5Fincrement_filesize() and H5Fget_eoa() */ + test_min_dset_ohdr(); /* Test datset object header minimization */ #ifndef H5_NO_DEPRECATED_SYMBOLS - test_file_ishdf5(env_h5_drvr); /* Test detecting HDF5 files correctly */ - test_deprec(); /* Test deprecated routines */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ + test_file_ishdf5(env_h5_drvr); /* Test detecting HDF5 files correctly */ + test_deprec(); /* Test deprecated routines */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ ret = H5Pclose(fapl_id); CHECK(ret, FAIL, "H5Pclose"); } /* test_file() */ - /*------------------------------------------------------------------------- * Function: cleanup_file * @@ -7927,4 +8046,3 @@ cleanup_file(void) HDremove(FILE7); HDremove(DST_FILE); } - diff --git a/test/tgenprop.c b/test/tgenprop.c index 7ca7dca..910153c 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -12,65 +12,64 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tgenprop -* -* Test the Generic Property functionality -* -*************************************************************/ + * + * Test program: tgenprop + * + * Test the Generic Property functionality + * + *************************************************************/ -#define H5P_FRIEND /*suppress error about including H5Ppkg */ +#define H5P_FRIEND /*suppress error about including H5Ppkg */ /* Define this macro to indicate that the testing APIs should be available */ #define H5P_TESTING #include "testhdf5.h" -#include "H5Dprivate.h" /* For Dataset creation property list names */ -#include "H5Ppkg.h" /* Generic Properties */ +#include "H5Dprivate.h" /* For Dataset creation property list names */ +#include "H5Ppkg.h" /* Generic Properties */ -#define FILENAME "tgenprop.h5" +#define FILENAME "tgenprop.h5" /* Property definitions */ -#define CLASS1_NAME "Class 1" -#define CLASS1_PATH "root/Class 1" +#define CLASS1_NAME "Class 1" +#define CLASS1_PATH "root/Class 1" -#define CLASS2_NAME "Class 2" -#define CLASS2_PATH "root/Class 1/Class 2" +#define CLASS2_NAME "Class 2" +#define CLASS2_PATH "root/Class 1/Class 2" /* Property definitions */ -#define PROP1_NAME "Property 1" -int prop1_def=10; /* Property 1 default value */ +#define PROP1_NAME "Property 1" +int prop1_def = 10; /* Property 1 default value */ #define PROP1_SIZE sizeof(prop1_def) #define PROP1_DEF_VALUE (&prop1_def) -#define PROP2_NAME "Property 2" -float prop2_def=3.14F; /* Property 2 default value */ +#define PROP2_NAME "Property 2" +float prop2_def = 3.14F; /* Property 2 default value */ #define PROP2_SIZE sizeof(prop2_def) #define PROP2_DEF_VALUE (&prop2_def) -#define PROP3_NAME "Property 3" -char prop3_def[10]="Ten chars"; /* Property 3 default value */ +#define PROP3_NAME "Property 3" +char prop3_def[10] = "Ten chars"; /* Property 3 default value */ #define PROP3_SIZE sizeof(prop3_def) #define PROP3_DEF_VALUE (&prop3_def) -#define PROP4_NAME "Property 4" -double prop4_def=1.41F; /* Property 4 default value */ +#define PROP4_NAME "Property 4" +double prop4_def = 1.41F; /* Property 4 default value */ #define PROP4_SIZE sizeof(prop4_def) #define PROP4_DEF_VALUE (&prop4_def) /* Structs used during iteration */ typedef struct iter_data_t { - int iter_count; - char **names; + int iter_count; + char **names; } iter_data_t; typedef struct count_data_t { - int count; - hid_t id; + int count; + hid_t id; } count_data_t; - /**************************************************************** ** ** test_genprop_basic_class(): Test basic generic property list code. @@ -80,24 +79,24 @@ typedef struct count_data_t { static void test_genprop_basic_class(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t cid2; /* Generic Property class ID */ - hid_t cid3; /* Generic Property class ID */ - char *name; /* Name of class */ - herr_t ret; /* Generic return value */ + hid_t cid1; /* Generic Property class ID */ + hid_t cid2; /* Generic Property class ID */ + hid_t cid3; /* Generic Property class ID */ + char * name; /* Name of class */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Generic Property List Class Creation Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS1_NAME)!=0) - TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); + if (HDstrcmp(name, CLASS1_NAME) != 0) + TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n", name, CLASS1_NAME); H5free_memory(name); /* Check class parent */ @@ -105,11 +104,11 @@ test_genprop_basic_class(void) CHECK_I(cid2, "H5Pget_class_parent"); /* Verify class parent correct */ - ret = H5Pequal(cid2,H5P_ROOT); + ret = H5Pequal(cid2, H5P_ROOT); VERIFY(ret, 1, "H5Pequal"); /* Make certain false postives aren't being returned */ - ret = H5Pequal(cid2,H5P_FILE_CREATE); + ret = H5Pequal(cid2, H5P_FILE_CREATE); VERIFY(ret, 0, "H5Pequal"); /* Close parent class */ @@ -121,14 +120,14 @@ test_genprop_basic_class(void) CHECK_I(ret, "H5Pclose_class"); /* Create another new generic class, derived from file creation class */ - cid1 = H5Pcreate_class(H5P_FILE_CREATE,CLASS2_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid1 = H5Pcreate_class(H5P_FILE_CREATE, CLASS2_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS2_NAME)!=0) - TestErrPrintf("Class names don't match!, name=%s, CLASS2_NAME=%s\n",name,CLASS2_NAME); + if (HDstrcmp(name, CLASS2_NAME) != 0) + TestErrPrintf("Class names don't match!, name=%s, CLASS2_NAME=%s\n", name, CLASS2_NAME); H5free_memory(name); /* Check class parent */ @@ -136,7 +135,7 @@ test_genprop_basic_class(void) CHECK_I(cid2, "H5Pget_class_parent"); /* Verify class parent correct */ - ret = H5Pequal(cid2,H5P_FILE_CREATE); + ret = H5Pequal(cid2, H5P_FILE_CREATE); VERIFY(ret, 1, "H5Pequal"); /* Check class parent's parent */ @@ -144,7 +143,7 @@ test_genprop_basic_class(void) CHECK_I(cid3, "H5Pget_class_parent"); /* Verify class parent's parent correct */ - ret = H5Pequal(cid3,H5P_GROUP_CREATE); + ret = H5Pequal(cid3, H5P_GROUP_CREATE); VERIFY(ret, 1, "H5Pequal"); /* Close parent class's parent */ @@ -169,10 +168,10 @@ test_genprop_basic_class(void) static void test_genprop_basic_class_prop(void) { - hid_t cid1; /* Generic Property class ID */ - size_t size; /* Size of property */ - size_t nprops; /* Number of properties in class */ - herr_t ret; /* Generic return value */ + hid_t cid1; /* Generic Property class ID */ + size_t size; /* Size of property */ + size_t nprops; /* Number of properties in class */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Generic Property List Class Properties Functionality\n")); @@ -191,11 +190,13 @@ test_genprop_basic_class_prop(void) VERIFY(ret, 0, "H5Pexist"); /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Try to insert the first property again (should fail) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); VERIFY(ret, FAIL, "H5Pregister2"); /* Check the existance of the first property */ @@ -213,11 +214,13 @@ test_genprop_basic_class_prop(void) VERIFY(nprops, 1, "H5Pget_nprops"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Try to insert the second property again (should fail) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); VERIFY(ret, FAIL, "H5Pregister2"); /* Check the existance of the second property */ @@ -235,7 +238,8 @@ test_genprop_basic_class_prop(void) VERIFY(nprops, 2, "H5Pget_nprops"); /* Insert third property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Check the existance of the third property */ @@ -294,12 +298,11 @@ test_genprop_basic_class_prop(void) ** ****************************************************************/ static int -test_genprop_iter1(hid_t H5_ATTR_UNUSED id, const char *name, - void *iter_data) +test_genprop_iter1(hid_t H5_ATTR_UNUSED id, const char *name, void *iter_data) { iter_data_t *idata = (iter_data_t *)iter_data; - return HDstrcmp(name,idata->names[idata->iter_count++]); + return HDstrcmp(name, idata->names[idata->iter_count++]); } /**************************************************************** @@ -311,19 +314,16 @@ test_genprop_iter1(hid_t H5_ATTR_UNUSED id, const char *name, static void test_genprop_class_iter(void) { - hid_t cid1; /* Generic Property class ID */ - size_t nprops; /* Number of properties in class */ - int idx; /* Index to start iteration at */ - struct { /* Struct for iterations */ - int iter_count; + hid_t cid1; /* Generic Property class ID */ + size_t nprops; /* Number of properties in class */ + int idx; /* Index to start iteration at */ + struct { /* Struct for iterations */ + int iter_count; const char **names; } iter_struct; - const char *pnames[4]={ /* Names of properties for iterator */ - PROP1_NAME, - PROP2_NAME, - PROP3_NAME, - PROP4_NAME}; - herr_t ret; /* Generic return value */ + const char *pnames[4] = {/* Names of properties for iterator */ + PROP1_NAME, PROP2_NAME, PROP3_NAME, PROP4_NAME}; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Generic Property List Class Property Iteration Functionality\n")); @@ -333,35 +333,39 @@ test_genprop_class_iter(void) CHECK_I(cid1, "H5Pcreate_class"); /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert third property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert third property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Check the number of properties in class */ - ret = H5Pget_nprops(cid1,&nprops); + ret = H5Pget_nprops(cid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 4, "H5Pget_nprops"); /* Iterate over all properties in class */ - iter_struct.iter_count=0; - iter_struct.names=pnames; - ret = H5Piterate(cid1,NULL,test_genprop_iter1,&iter_struct); + iter_struct.iter_count = 0; + iter_struct.names = pnames; + ret = H5Piterate(cid1, NULL, test_genprop_iter1, &iter_struct); VERIFY(ret, 0, "H5Piterate"); /* Iterate over last three properties in class */ - idx=iter_struct.iter_count=1; - ret = H5Piterate(cid1,&idx,test_genprop_iter1,&iter_struct); + idx = iter_struct.iter_count = 1; + ret = H5Piterate(cid1, &idx, test_genprop_iter1, &iter_struct); VERIFY(ret, 0, "H5Piterate"); VERIFY(idx, (int)nprops, "H5Piterate"); @@ -417,49 +421,54 @@ test_genprop_cls_cls_cb1(hid_t list_id, void *create_data) static void test_genprop_class_callback(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t cid2; /* Generic Property class ID */ - hid_t lid1; /* Generic Property list ID */ - hid_t lid2; /* Generic Property list ID */ - hid_t lid3; /* Generic Property list ID */ - size_t nprops; /* Number of properties in class */ - struct { /* Struct for callbacks */ - int count; + hid_t cid1; /* Generic Property class ID */ + hid_t cid2; /* Generic Property class ID */ + hid_t lid1; /* Generic Property list ID */ + hid_t lid2; /* Generic Property list ID */ + hid_t lid3; /* Generic Property list ID */ + size_t nprops; /* Number of properties in class */ + struct { /* Struct for callbacks */ + int count; hid_t id; } crt_cb_struct, cpy_cb_struct, cls_cb_struct; - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Generic Property List Class Callback Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, test_genprop_cls_crt_cb1, &crt_cb_struct, test_genprop_cls_cpy_cb1, &cpy_cb_struct, test_genprop_cls_cls_cb1, &cls_cb_struct); + cid1 = + H5Pcreate_class(H5P_ROOT, CLASS1_NAME, test_genprop_cls_crt_cb1, &crt_cb_struct, + test_genprop_cls_cpy_cb1, &cpy_cb_struct, test_genprop_cls_cls_cb1, &cls_cb_struct); CHECK_I(cid1, "H5Pcreate_class"); /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert third property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Check the number of properties in class */ - ret = H5Pget_nprops(cid1,&nprops); + ret = H5Pget_nprops(cid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 3, "H5Pget_nprops"); /* Initialize class callback structs */ - crt_cb_struct.count=0; - crt_cb_struct.id=(-1); - cpy_cb_struct.count=0; - cpy_cb_struct.id=(-1); - cls_cb_struct.count=0; - cls_cb_struct.id=(-1); + crt_cb_struct.count = 0; + crt_cb_struct.id = (-1); + cpy_cb_struct.count = 0; + cpy_cb_struct.id = (-1); + cls_cb_struct.count = 0; + cls_cb_struct.id = (-1); /* Create a property list from the class */ lid1 = H5Pcreate(cid1); @@ -470,7 +479,7 @@ test_genprop_class_callback(void) VERIFY(crt_cb_struct.id, lid1, "H5Pcreate"); /* Check the number of properties in list */ - ret = H5Pget_nprops(lid1,&nprops); + ret = H5Pget_nprops(lid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 3, "H5Pget_nprops"); @@ -483,7 +492,7 @@ test_genprop_class_callback(void) VERIFY(crt_cb_struct.id, lid2, "H5Pcreate"); /* Check the number of properties in list */ - ret = H5Pget_nprops(lid2,&nprops); + ret = H5Pget_nprops(lid2, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 3, "H5Pget_nprops"); @@ -525,11 +534,14 @@ test_genprop_class_callback(void) VERIFY(cls_cb_struct.id, lid3, "H5Pclose"); /* Create another new generic class, derived from first class */ - cid2 = H5Pcreate_class(cid1, CLASS2_NAME, test_genprop_cls_crt_cb1, &crt_cb_struct, test_genprop_cls_cpy_cb1, &cpy_cb_struct, test_genprop_cls_cls_cb1, &cls_cb_struct); + cid2 = + H5Pcreate_class(cid1, CLASS2_NAME, test_genprop_cls_crt_cb1, &crt_cb_struct, test_genprop_cls_cpy_cb1, + &cpy_cb_struct, test_genprop_cls_cls_cb1, &cls_cb_struct); CHECK_I(cid2, "H5Pcreate_class"); /* Insert fourth property into class (with no callbacks) */ - ret = H5Pregister2(cid2, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid2, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Check the number of properties in class */ @@ -596,34 +608,36 @@ test_genprop_class_callback(void) static void test_genprop_basic_list(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t cid2; /* Generic Property class ID */ - hid_t lid1; /* Generic Property list ID */ - size_t nprops; /* Number of properties */ - size_t size; /* Size of property */ - int prop1_value; /* Value for property #1 */ - float prop2_value; /* Value for property #2 */ - herr_t ret; /* Generic return value */ + hid_t cid1; /* Generic Property class ID */ + hid_t cid2; /* Generic Property class ID */ + hid_t lid1; /* Generic Property list ID */ + size_t nprops; /* Number of properties */ + size_t size; /* Size of property */ + int prop1_value; /* Value for property #1 */ + float prop2_value; /* Value for property #2 */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Generic Property List Creation Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Add several properties (w/default values) */ /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Check the number of properties in class */ - ret = H5Pget_nprops(cid1,&nprops); + ret = H5Pget_nprops(cid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 2, "H5Pget_nprops"); @@ -636,15 +650,15 @@ test_genprop_basic_list(void) CHECK_I(cid2, "H5Pget_class"); /* Check that the list's class is correct */ - ret = H5Pequal(cid1,cid2); + ret = H5Pequal(cid1, cid2); VERIFY(ret, 1, "H5Pequal"); /* Check correct "is a" class/list relationship */ - ret = H5Pisa_class(lid1,cid1); + ret = H5Pisa_class(lid1, cid1); VERIFY(ret, 1, "H5Pisa_class"); /* Check "is a" class/list relationship another way */ - ret = H5Pisa_class(lid1,cid2); + ret = H5Pisa_class(lid1, cid2); VERIFY(ret, 1, "H5Pisa_class"); /* Close class */ @@ -652,7 +666,7 @@ test_genprop_basic_list(void) CHECK_I(ret, "H5Pclose_class"); /* Check the number of properties in list */ - ret = H5Pget_nprops(lid1,&nprops); + ret = H5Pget_nprops(lid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 2, "H5Pget_nprops"); @@ -663,24 +677,23 @@ test_genprop_basic_list(void) VERIFY(ret, 1, "H5Pexist"); /* Check the sizes of the properties */ - ret = H5Pget_size(lid1, PROP1_NAME,&size); + ret = H5Pget_size(lid1, PROP1_NAME, &size); CHECK_I(ret, "H5Pget_size"); VERIFY(size, PROP1_SIZE, "H5Pget_size"); - ret = H5Pget_size(lid1, PROP2_NAME,&size); + ret = H5Pget_size(lid1, PROP2_NAME, &size); CHECK_I(ret, "H5Pget_size"); VERIFY(size, PROP2_SIZE, "H5Pget_size"); /* Check values of properties (set with default values) */ - ret = H5Pget(lid1, PROP1_NAME,&prop1_value); + ret = H5Pget(lid1, PROP1_NAME, &prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); - ret = H5Pget(lid1, PROP2_NAME,&prop2_value); + ret = H5Pget(lid1, PROP2_NAME, &prop2_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_FLT_ABS_EQUAL(prop2_value,*PROP2_DEF_VALUE)) - HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Pget", (double)*PROP2_DEF_VALUE, (double)prop2_value, (int)__LINE__, __FILE__); - + if (!H5_FLT_ABS_EQUAL(prop2_value, *PROP2_DEF_VALUE)) + HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Pget", + (double)*PROP2_DEF_VALUE, (double)prop2_value, (int)__LINE__, __FILE__); /* Close list */ ret = H5Pclose(lid1); @@ -702,30 +715,32 @@ test_genprop_basic_list(void) static void test_genprop_basic_list_prop(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t lid1; /* Generic Property list ID */ - size_t nprops; /* Number of properties */ - int prop1_value; /* Value for property #1 */ - float prop2_value; /* Value for property #2 */ - char prop3_value[10];/* Property #3 value */ - double prop4_value; /* Property #4 value */ - herr_t ret; /* Generic return value */ + hid_t cid1; /* Generic Property class ID */ + hid_t lid1; /* Generic Property list ID */ + size_t nprops; /* Number of properties */ + int prop1_value; /* Value for property #1 */ + float prop2_value; /* Value for property #2 */ + char prop3_value[10]; /* Property #3 value */ + double prop4_value; /* Property #4 value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Generic Property List Property Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Add several properties (several w/default values) */ /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Create a property list from the class */ @@ -733,7 +748,7 @@ test_genprop_basic_list_prop(void) CHECK_I(lid1, "H5Pcreate"); /* Check the number of properties in list */ - ret = H5Pget_nprops(lid1,&nprops); + ret = H5Pget_nprops(lid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 2, "H5Pget_nprops"); @@ -748,7 +763,7 @@ test_genprop_basic_list_prop(void) CHECK_I(ret, "H5Pinsert2"); /* Check the number of properties in list */ - ret = H5Pget_nprops(lid1,&nprops); + ret = H5Pget_nprops(lid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 4, "H5Pget_nprops"); @@ -763,35 +778,34 @@ test_genprop_basic_list_prop(void) VERIFY(ret, 1, "H5Pexist"); /* Check values of permanent properties (set with default values) */ - ret = H5Pget(lid1, PROP1_NAME,&prop1_value); + ret = H5Pget(lid1, PROP1_NAME, &prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); - ret = H5Pget(lid1, PROP2_NAME,&prop2_value); + ret = H5Pget(lid1, PROP2_NAME, &prop2_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_FLT_ABS_EQUAL(prop2_value,*PROP2_DEF_VALUE)) - HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Pget", (double)*PROP2_DEF_VALUE, (double)prop2_value, (int)__LINE__, __FILE__); - + if (!H5_FLT_ABS_EQUAL(prop2_value, *PROP2_DEF_VALUE)) + HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Pget", + (double)*PROP2_DEF_VALUE, (double)prop2_value, (int)__LINE__, __FILE__); /* Check values of temporary properties (set with regular values) */ - ret = H5Pget(lid1, PROP3_NAME,&prop3_value); + ret = H5Pget(lid1, PROP3_NAME, &prop3_value); CHECK_I(ret, "H5Pget"); - if(HDmemcmp(&prop3_value, PROP3_DEF_VALUE, PROP3_SIZE)!=0) - TestErrPrintf("Property #3 doesn't match!, line=%d\n",__LINE__); - ret = H5Pget(lid1, PROP4_NAME,&prop4_value); + if (HDmemcmp(&prop3_value, PROP3_DEF_VALUE, PROP3_SIZE) != 0) + TestErrPrintf("Property #3 doesn't match!, line=%d\n", __LINE__); + ret = H5Pget(lid1, PROP4_NAME, &prop4_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_DBL_ABS_EQUAL(prop4_value, *PROP4_DEF_VALUE)) - HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Pget", *PROP4_DEF_VALUE, prop4_value, (int)__LINE__, __FILE__); + if (!H5_DBL_ABS_EQUAL(prop4_value, *PROP4_DEF_VALUE)) + HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Pget", + *PROP4_DEF_VALUE, prop4_value, (int)__LINE__, __FILE__); /* Delete permanent property */ ret = H5Premove(lid1, PROP2_NAME); CHECK_I(ret, "H5Premove"); /* Check number of properties */ - ret = H5Pget_nprops(lid1,&nprops); + ret = H5Pget_nprops(lid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 3, "H5Pget_nprops"); @@ -800,7 +814,7 @@ test_genprop_basic_list_prop(void) CHECK_I(ret, "H5Premove"); /* Check number of properties */ - ret = H5Pget_nprops(lid1,&nprops); + ret = H5Pget_nprops(lid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 2, "H5Pget_nprops"); @@ -811,17 +825,17 @@ test_genprop_basic_list_prop(void) VERIFY(ret, 1, "H5Pexist"); /* Check values of permanent properties (set with default values) */ - ret = H5Pget(lid1, PROP1_NAME,&prop1_value); + ret = H5Pget(lid1, PROP1_NAME, &prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); /* Check values of temporary properties (set with regular values) */ - ret = H5Pget(lid1, PROP4_NAME,&prop4_value); + ret = H5Pget(lid1, PROP4_NAME, &prop4_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_DBL_ABS_EQUAL(prop4_value, *PROP4_DEF_VALUE)) - HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Pget", *PROP4_DEF_VALUE, prop4_value, (int)__LINE__, __FILE__); + if (!H5_DBL_ABS_EQUAL(prop4_value, *PROP4_DEF_VALUE)) + HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Pget", + *PROP4_DEF_VALUE, prop4_value, (int)__LINE__, __FILE__); /* Close list */ ret = H5Pclose(lid1); @@ -839,12 +853,11 @@ test_genprop_basic_list_prop(void) ** ****************************************************************/ static int -test_genprop_iter2(hid_t H5_ATTR_UNUSED id, const char *name, - void *iter_data) +test_genprop_iter2(hid_t H5_ATTR_UNUSED id, const char *name, void *iter_data) { iter_data_t *idata = (iter_data_t *)iter_data; - return HDstrcmp(name,idata->names[idata->iter_count++]); + return HDstrcmp(name, idata->names[idata->iter_count++]); } /**************************************************************** @@ -856,37 +869,35 @@ test_genprop_iter2(hid_t H5_ATTR_UNUSED id, const char *name, static void test_genprop_list_iter(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t lid1; /* Generic Property list ID */ - size_t nprops; /* Number of properties */ - int idx; /* Index to start iteration at */ - struct { /* Struct for iterations */ - int iter_count; + hid_t cid1; /* Generic Property class ID */ + hid_t lid1; /* Generic Property list ID */ + size_t nprops; /* Number of properties */ + int idx; /* Index to start iteration at */ + struct { /* Struct for iterations */ + int iter_count; const char **names; } iter_struct; - const char *pnames[4]={ /* Names of properties for iterator */ - PROP3_NAME, - PROP4_NAME, - PROP1_NAME, - PROP2_NAME - }; - herr_t ret; /* Generic return value */ + const char *pnames[4] = {/* Names of properties for iterator */ + PROP3_NAME, PROP4_NAME, PROP1_NAME, PROP2_NAME}; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Generic Property List Iteration Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Add several properties (several w/default values) */ /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Create a property list from the class */ @@ -894,7 +905,7 @@ test_genprop_list_iter(void) CHECK_I(lid1, "H5Pcreate"); /* Check the number of properties in list */ - ret = H5Pget_nprops(lid1,&nprops); + ret = H5Pget_nprops(lid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 2, "H5Pget_nprops"); @@ -909,19 +920,19 @@ test_genprop_list_iter(void) CHECK_I(ret, "H5Pinsert2"); /* Check the number of properties in list */ - ret = H5Pget_nprops(lid1,&nprops); + ret = H5Pget_nprops(lid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 4, "H5Pget_nprops"); /* Iterate over all properties in list */ - iter_struct.iter_count=0; - iter_struct.names=pnames; - ret = H5Piterate(lid1,NULL,test_genprop_iter2,&iter_struct); + iter_struct.iter_count = 0; + iter_struct.names = pnames; + ret = H5Piterate(lid1, NULL, test_genprop_iter2, &iter_struct); VERIFY(ret, 0, "H5Piterate"); /* Iterate over last three properties in list */ - idx=iter_struct.iter_count=1; - ret = H5Piterate(lid1,&idx,test_genprop_iter2,&iter_struct); + idx = iter_struct.iter_count = 1; + ret = H5Piterate(lid1, &idx, test_genprop_iter2, &iter_struct); VERIFY(ret, 0, "H5Piterate"); VERIFY(idx, (int)nprops, "H5Piterate"); @@ -937,30 +948,30 @@ test_genprop_list_iter(void) typedef struct { /* Creation information */ - int crt_count; + int crt_count; char *crt_name; void *crt_value; /* Set information */ - int set_count; + int set_count; hid_t set_plist_id; char *set_name; void *set_value; /* Get information */ - int get_count; + int get_count; hid_t get_plist_id; char *get_name; void *get_value; /* Delete information */ - int del_count; + int del_count; hid_t del_plist_id; char *del_name; void *del_value; /* Copy information */ - int cop_count; + int cop_count; char *cop_name; void *cop_value; @@ -968,15 +979,15 @@ typedef struct { int cmp_count; /* Close information */ - int cls_count; + int cls_count; char *cls_name; void *cls_value; } prop_cb_info; /* Global variables for Callback information */ -prop_cb_info prop1_cb_info; /* Callback statistics for property #1 */ -prop_cb_info prop2_cb_info; /* Callback statistics for property #2 */ -prop_cb_info prop3_cb_info; /* Callback statistics for property #3 */ +prop_cb_info prop1_cb_info; /* Callback statistics for property #1 */ +prop_cb_info prop2_cb_info; /* Callback statistics for property #2 */ +prop_cb_info prop3_cb_info; /* Callback statistics for property #3 */ /**************************************************************** ** @@ -1004,11 +1015,11 @@ test_genprop_prop_crt_cb1(const char *name, size_t size, void *def_value) { /* Set the information from the creation call */ prop1_cb_info.crt_count++; - prop1_cb_info.crt_name=HDstrdup(name); - prop1_cb_info.crt_value=HDmalloc(size); - HDmemcpy(prop1_cb_info.crt_value,def_value,size); + prop1_cb_info.crt_name = HDstrdup(name); + prop1_cb_info.crt_value = HDmalloc(size); + HDmemcpy(prop1_cb_info.crt_value, def_value, size); - return(SUCCEED); + return (SUCCEED); } /**************************************************************** @@ -1021,14 +1032,14 @@ test_genprop_prop_set_cb1(hid_t plist_id, const char *name, size_t size, void *v { /* Set the information from the set call */ prop1_cb_info.set_count++; - prop1_cb_info.set_plist_id=plist_id; - if(prop1_cb_info.set_name==NULL) - prop1_cb_info.set_name=HDstrdup(name); - if(prop1_cb_info.set_value==NULL) - prop1_cb_info.set_value=HDmalloc(size); - HDmemcpy(prop1_cb_info.set_value,value,size); - - return(SUCCEED); + prop1_cb_info.set_plist_id = plist_id; + if (prop1_cb_info.set_name == NULL) + prop1_cb_info.set_name = HDstrdup(name); + if (prop1_cb_info.set_value == NULL) + prop1_cb_info.set_value = HDmalloc(size); + HDmemcpy(prop1_cb_info.set_value, value, size); + + return (SUCCEED); } /**************************************************************** @@ -1041,14 +1052,14 @@ test_genprop_prop_get_cb1(hid_t plist_id, const char *name, size_t size, void *v { /* Set the information from the get call */ prop1_cb_info.get_count++; - prop1_cb_info.get_plist_id=plist_id; - if(prop1_cb_info.get_name==NULL) - prop1_cb_info.get_name=HDstrdup(name); - if(prop1_cb_info.get_value==NULL) - prop1_cb_info.get_value=HDmalloc(size); - HDmemcpy(prop1_cb_info.get_value,value,size); - - return(SUCCEED); + prop1_cb_info.get_plist_id = plist_id; + if (prop1_cb_info.get_name == NULL) + prop1_cb_info.get_name = HDstrdup(name); + if (prop1_cb_info.get_value == NULL) + prop1_cb_info.get_value = HDmalloc(size); + HDmemcpy(prop1_cb_info.get_value, value, size); + + return (SUCCEED); } /**************************************************************** @@ -1061,13 +1072,13 @@ test_genprop_prop_cop_cb1(const char *name, size_t size, void *value) { /* Set the information from the get call */ prop1_cb_info.cop_count++; - if(prop1_cb_info.cop_name==NULL) - prop1_cb_info.cop_name=HDstrdup(name); - if(prop1_cb_info.cop_value==NULL) - prop1_cb_info.cop_value=HDmalloc(size); - HDmemcpy(prop1_cb_info.cop_value,value,size); + if (prop1_cb_info.cop_name == NULL) + prop1_cb_info.cop_name = HDstrdup(name); + if (prop1_cb_info.cop_value == NULL) + prop1_cb_info.cop_value = HDmalloc(size); + HDmemcpy(prop1_cb_info.cop_value, value, size); - return(SUCCEED); + return (SUCCEED); } /**************************************************************** @@ -1081,7 +1092,7 @@ test_genprop_prop_cmp_cb1(const void *value1, const void *value2, size_t size) /* Set the information from the comparison call */ prop1_cb_info.cmp_count++; - return(HDmemcmp(value1, value2, size)); + return (HDmemcmp(value1, value2, size)); } /**************************************************************** @@ -1095,7 +1106,7 @@ test_genprop_prop_cmp_cb3(const void *value1, const void *value2, size_t size) /* Set the information from the comparison call */ prop3_cb_info.cmp_count++; - return(HDmemcmp(value1, value2, size)); + return (HDmemcmp(value1, value2, size)); } /**************************************************************** @@ -1108,13 +1119,13 @@ test_genprop_prop_cls_cb1(const char *name, size_t size, void *value) { /* Set the information from the close call */ prop1_cb_info.cls_count++; - if(prop1_cb_info.cls_name==NULL) - prop1_cb_info.cls_name=HDstrdup(name); - if(prop1_cb_info.cls_value==NULL) - prop1_cb_info.cls_value=HDmalloc(size); - HDmemcpy(prop1_cb_info.cls_value,value,size); + if (prop1_cb_info.cls_name == NULL) + prop1_cb_info.cls_name = HDstrdup(name); + if (prop1_cb_info.cls_value == NULL) + prop1_cb_info.cls_value = HDmalloc(size); + HDmemcpy(prop1_cb_info.cls_value, value, size); - return(SUCCEED); + return (SUCCEED); } /**************************************************************** @@ -1127,12 +1138,12 @@ test_genprop_prop_del_cb2(hid_t plist_id, const char *name, size_t size, void *v { /* Set the information from the delete call */ prop2_cb_info.del_count++; - prop2_cb_info.del_plist_id=plist_id; - prop2_cb_info.del_name=HDstrdup(name); - prop2_cb_info.del_value=HDmalloc(size); - HDmemcpy(prop2_cb_info.del_value,value,size); + prop2_cb_info.del_plist_id = plist_id; + prop2_cb_info.del_name = HDstrdup(name); + prop2_cb_info.del_value = HDmalloc(size); + HDmemcpy(prop2_cb_info.del_value, value, size); - return(SUCCEED); + return (SUCCEED); } /**************************************************************** @@ -1144,58 +1155,64 @@ test_genprop_prop_del_cb2(hid_t plist_id, const char *name, size_t size, void *v static void test_genprop_list_callback(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t lid1; /* Generic Property list ID */ - hid_t lid2; /* 2nd Generic Property list ID */ - size_t nprops; /* Number of properties in class */ - int prop1_value; /* Value for property #1 */ - int prop1_new_value=20; /* Property #1 new value */ - float prop2_value; /* Value for property #2 */ - char prop3_value[10];/* Property #3 value */ - char prop3_new_value[10]="10 chairs"; /* Property #3 new value */ - double prop4_value; /* Property #4 value */ - struct { /* Struct for callbacks */ - int count; + hid_t cid1; /* Generic Property class ID */ + hid_t lid1; /* Generic Property list ID */ + hid_t lid2; /* 2nd Generic Property list ID */ + size_t nprops; /* Number of properties in class */ + int prop1_value; /* Value for property #1 */ + int prop1_new_value = 20; /* Property #1 new value */ + float prop2_value; /* Value for property #2 */ + char prop3_value[10]; /* Property #3 value */ + char prop3_new_value[10] = "10 chairs"; /* Property #3 new value */ + double prop4_value; /* Property #4 value */ + struct { /* Struct for callbacks */ + int count; hid_t id; } cop_cb_struct; - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Generic Property List Property Callback Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL,test_genprop_cls_cpy_cb2,&cop_cb_struct,NULL, NULL); + cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, NULL, NULL, test_genprop_cls_cpy_cb2, &cop_cb_struct, NULL, + NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Insert first property into class (with callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE,test_genprop_prop_crt_cb1,test_genprop_prop_set_cb1,test_genprop_prop_get_cb1,NULL,test_genprop_prop_cop_cb1,test_genprop_prop_cmp_cb1,test_genprop_prop_cls_cb1); + ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, test_genprop_prop_crt_cb1, + test_genprop_prop_set_cb1, test_genprop_prop_get_cb1, NULL, test_genprop_prop_cop_cb1, + test_genprop_prop_cmp_cb1, test_genprop_prop_cls_cb1); CHECK_I(ret, "H5Pregister2"); /* Insert second property into class (with only delete callback) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL,test_genprop_prop_del_cb2,NULL, NULL, NULL); + ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, + test_genprop_prop_del_cb2, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert third property into class (with only compare callback) */ - ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, test_genprop_prop_cmp_cb3, NULL); + ret = H5Pregister2(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, + test_genprop_prop_cmp_cb3, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert fourth property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Check the number of properties in class */ - ret = H5Pget_nprops(cid1,&nprops); + ret = H5Pget_nprops(cid1, &nprops); CHECK_I(ret, "H5Pget_nprops"); VERIFY(nprops, 4, "H5Pget_nprops"); /* Initialize class callback structs */ - cop_cb_struct.count=0; - cop_cb_struct.id=(-1); + cop_cb_struct.count = 0; + cop_cb_struct.id = (-1); /* Initialize callback information for properties tracked */ - HDmemset(&prop1_cb_info,0,sizeof(prop_cb_info)); - HDmemset(&prop2_cb_info,0,sizeof(prop_cb_info)); - HDmemset(&prop3_cb_info,0,sizeof(prop_cb_info)); + HDmemset(&prop1_cb_info, 0, sizeof(prop_cb_info)); + HDmemset(&prop2_cb_info, 0, sizeof(prop_cb_info)); + HDmemset(&prop3_cb_info, 0, sizeof(prop_cb_info)); /* Create a property list from the class */ lid1 = H5Pcreate(cid1); @@ -1210,81 +1227,81 @@ test_genprop_list_callback(void) /* Verify creation callback information for properties tracked */ VERIFY(prop1_cb_info.crt_count, 1, "H5Pcreate"); - if(HDstrcmp(prop1_cb_info.crt_name, PROP1_NAME)!=0) - TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); - if(HDmemcmp(prop1_cb_info.crt_value, PROP1_DEF_VALUE, PROP1_SIZE)!=0) - TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); + if (HDstrcmp(prop1_cb_info.crt_name, PROP1_NAME) != 0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n", __LINE__); + if (HDmemcmp(prop1_cb_info.crt_value, PROP1_DEF_VALUE, PROP1_SIZE) != 0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n", __LINE__); /* Check values of permanent properties (set with default values) */ - ret = H5Pget(lid1, PROP1_NAME,&prop1_value); + ret = H5Pget(lid1, PROP1_NAME, &prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); /* The compare callback should not have been called */ VERIFY(prop1_cb_info.cmp_count, 0, "H5Pget"); - ret = H5Pget(lid1, PROP2_NAME,&prop2_value); + ret = H5Pget(lid1, PROP2_NAME, &prop2_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_FLT_ABS_EQUAL(prop2_value,*PROP2_DEF_VALUE)) - HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Pget", (double)*PROP2_DEF_VALUE, (double)prop2_value, (int)__LINE__, __FILE__); + if (!H5_FLT_ABS_EQUAL(prop2_value, *PROP2_DEF_VALUE)) + HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Pget", + (double)*PROP2_DEF_VALUE, (double)prop2_value, (int)__LINE__, __FILE__); /* Check values of temporary properties (set with regular values) */ - ret = H5Pget(lid1, PROP3_NAME,&prop3_value); + ret = H5Pget(lid1, PROP3_NAME, &prop3_value); CHECK_I(ret, "H5Pget"); - if(HDmemcmp(&prop3_value, PROP3_DEF_VALUE, PROP3_SIZE)!=0) - TestErrPrintf("Property #3 doesn't match!, line=%d\n",__LINE__); + if (HDmemcmp(&prop3_value, PROP3_DEF_VALUE, PROP3_SIZE) != 0) + TestErrPrintf("Property #3 doesn't match!, line=%d\n", __LINE__); /* The compare callback should not have been called, as there is no get * callback for this property */ VERIFY(prop3_cb_info.cmp_count, 0, "H5Pget"); - ret = H5Pget(lid1, PROP4_NAME,&prop4_value); + ret = H5Pget(lid1, PROP4_NAME, &prop4_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_DBL_ABS_EQUAL(prop4_value, *PROP4_DEF_VALUE)) - HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Pget", *PROP4_DEF_VALUE, prop4_value, (int)__LINE__, __FILE__); + if (!H5_DBL_ABS_EQUAL(prop4_value, *PROP4_DEF_VALUE)) + HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Pget", + *PROP4_DEF_VALUE, prop4_value, (int)__LINE__, __FILE__); /* Verify get callback information for properties tracked */ VERIFY(prop1_cb_info.get_count, 1, "H5Pget"); VERIFY(prop1_cb_info.get_plist_id, lid1, "H5Pget"); - if(HDstrcmp(prop1_cb_info.get_name, PROP1_NAME)!=0) - TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); - if(HDmemcmp(prop1_cb_info.get_value, PROP1_DEF_VALUE, PROP1_SIZE)!=0) - TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); + if (HDstrcmp(prop1_cb_info.get_name, PROP1_NAME) != 0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n", __LINE__); + if (HDmemcmp(prop1_cb_info.get_value, PROP1_DEF_VALUE, PROP1_SIZE) != 0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n", __LINE__); /* Set value of property #1 to different value */ - ret = H5Pset(lid1, PROP1_NAME,&prop1_new_value); + ret = H5Pset(lid1, PROP1_NAME, &prop1_new_value); CHECK_I(ret, "H5Pset"); /* Verify set callback information for properties tracked */ VERIFY(prop1_cb_info.set_count, 1, "H5Pset"); VERIFY(prop1_cb_info.set_plist_id, lid1, "H5Pset"); - if(HDstrcmp(prop1_cb_info.set_name, PROP1_NAME)!=0) - TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); - if(HDmemcmp(prop1_cb_info.set_value,&prop1_new_value, PROP1_SIZE)!=0) - TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); + if (HDstrcmp(prop1_cb_info.set_name, PROP1_NAME) != 0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n", __LINE__); + if (HDmemcmp(prop1_cb_info.set_value, &prop1_new_value, PROP1_SIZE) != 0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n", __LINE__); /* The compare callback should not have been called */ VERIFY(prop1_cb_info.cmp_count, 0, "H5Pset"); /* Set value of property #3 to different value */ - ret = H5Pset(lid1, PROP3_NAME,prop3_new_value); + ret = H5Pset(lid1, PROP3_NAME, prop3_new_value); CHECK_I(ret, "H5Pset"); /* The compare callback should not have been called */ VERIFY(prop3_cb_info.cmp_count, 0, "H5Pset"); /* Check new value of tracked properties */ - ret = H5Pget(lid1, PROP1_NAME,&prop1_value); + ret = H5Pget(lid1, PROP1_NAME, &prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, prop1_new_value, "H5Pget"); /* Verify get callback information again for properties tracked */ VERIFY(prop1_cb_info.get_count, 2, "H5Pget"); VERIFY(prop1_cb_info.get_plist_id, lid1, "H5Pget"); - if(HDstrcmp(prop1_cb_info.get_name, PROP1_NAME)!=0) - TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); - if(HDmemcmp(prop1_cb_info.get_value,&prop1_new_value, PROP1_SIZE)!=0) - TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); + if (HDstrcmp(prop1_cb_info.get_name, PROP1_NAME) != 0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n", __LINE__); + if (HDmemcmp(prop1_cb_info.get_value, &prop1_new_value, PROP1_SIZE) != 0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n", __LINE__); /* Delete property #2 */ ret = H5Premove(lid1, PROP2_NAME); @@ -1293,10 +1310,10 @@ test_genprop_list_callback(void) /* Verify delete callback information for properties tracked */ VERIFY(prop2_cb_info.del_count, 1, "H5Premove"); VERIFY(prop2_cb_info.del_plist_id, lid1, "H5Premove"); - if(HDstrcmp(prop2_cb_info.del_name, PROP2_NAME)!=0) - TestErrPrintf("Property #2 name doesn't match!, line=%d\n",__LINE__); - if(HDmemcmp(prop2_cb_info.del_value, PROP2_DEF_VALUE, PROP2_SIZE)!=0) - TestErrPrintf("Property #2 value doesn't match!, line=%d\n",__LINE__); + if (HDstrcmp(prop2_cb_info.del_name, PROP2_NAME) != 0) + TestErrPrintf("Property #2 name doesn't match!, line=%d\n", __LINE__); + if (HDmemcmp(prop2_cb_info.del_value, PROP2_DEF_VALUE, PROP2_SIZE) != 0) + TestErrPrintf("Property #2 value doesn't match!, line=%d\n", __LINE__); /* Copy first list */ lid2 = H5Pcopy(lid1); @@ -1304,17 +1321,17 @@ test_genprop_list_callback(void) /* Verify copy callback information for properties tracked */ VERIFY(prop1_cb_info.cop_count, 1, "H5Pcopy"); - if(HDstrcmp(prop1_cb_info.cop_name, PROP1_NAME)!=0) - TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); - if(HDmemcmp(prop1_cb_info.cop_value,&prop1_new_value, PROP1_SIZE)!=0) - TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); + if (HDstrcmp(prop1_cb_info.cop_name, PROP1_NAME) != 0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n", __LINE__); + if (HDmemcmp(prop1_cb_info.cop_value, &prop1_new_value, PROP1_SIZE) != 0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n", __LINE__); /* Verify that the class creation callback occurred */ VERIFY(cop_cb_struct.count, 1, "H5Pcopy"); VERIFY(cop_cb_struct.id, lid2, "H5Pcopy"); /* Compare the two lists */ - ret = H5Pequal(lid1,lid2); + ret = H5Pequal(lid1, lid2); VERIFY(ret, 1, "H5Pequal"); /* Verify compare callback information for properties tracked */ @@ -1327,10 +1344,10 @@ test_genprop_list_callback(void) /* Verify close callback information for properties tracked */ VERIFY(prop1_cb_info.cls_count, 1, "H5Pclose"); - if(HDstrcmp(prop1_cb_info.cls_name, PROP1_NAME)!=0) - TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); - if(HDmemcmp(prop1_cb_info.cls_value,&prop1_new_value, PROP1_SIZE)!=0) - TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); + if (HDstrcmp(prop1_cb_info.cls_name, PROP1_NAME) != 0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n", __LINE__); + if (HDmemcmp(prop1_cb_info.cls_value, &prop1_new_value, PROP1_SIZE) != 0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n", __LINE__); /* Close second list */ ret = H5Pclose(lid2); @@ -1368,12 +1385,12 @@ test_genprop_list_callback(void) static void test_genprop_list_addprop(void) { - hid_t fid; /* File ID */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t pid; /* Property List ID */ - int prop1_value; /* Value for property #1 */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t pid; /* Property List ID */ + int prop1_value; /* Value for property #1 */ + herr_t ret; /* Generic return value */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1396,7 +1413,7 @@ test_genprop_list_addprop(void) VERIFY(ret, 1, "H5Pexist"); /* Check values of property (set with default value) */ - ret = H5Pget(pid, PROP1_NAME,&prop1_value); + ret = H5Pget(pid, PROP1_NAME, &prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); @@ -1442,13 +1459,13 @@ test_genprop_list_addprop(void) static void test_genprop_class_addprop(void) { - hid_t fid; /* File ID */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t cid; /* Property Class ID */ - hid_t pid; /* Property List ID */ - int prop1_value; /* Value for property #1 */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t cid; /* Property Class ID */ + hid_t pid; /* Property List ID */ + int prop1_value; /* Value for property #1 */ + herr_t ret; /* Generic return value */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1467,7 +1484,8 @@ test_genprop_class_addprop(void) VERIFY(ret, 1, "H5Pexist"); /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Check existence of an original property */ @@ -1496,7 +1514,8 @@ test_genprop_class_addprop(void) VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Check existence of an original property (in class) */ @@ -1569,8 +1588,8 @@ test_genprop_class_addprop(void) static void test_genprop_list_add_remove_prop(void) { - hid_t pid; /* Property List ID */ - herr_t ret; /* Generic return value */ + hid_t pid; /* Property List ID */ + herr_t ret; /* Generic return value */ /* Create a dataset creation property list */ pid = H5Pcreate(H5P_DATASET_CREATE); @@ -1607,25 +1626,27 @@ test_genprop_list_add_remove_prop(void) static void test_genprop_equal(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t lid1; /* Generic Property list ID */ - hid_t lid2; /* Generic Property list ID */ - int prop1_new_value = 20; /* Property #1 new value */ - herr_t ret; /* Generic return value */ + hid_t cid1; /* Generic Property class ID */ + hid_t lid1; /* Generic Property list ID */ + hid_t lid2; /* Generic Property list ID */ + int prop1_new_value = 20; /* Property #1 new value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Generic Property List Equal Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Create a property list from the class */ @@ -1756,50 +1777,52 @@ test_genprop_equal(void) static void test_genprop_path(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t cid2; /* Generic Property class ID */ - hid_t cid3; /* Generic Property class ID */ - char *path; /* Class path */ - herr_t ret; /* Generic return value */ + hid_t cid1; /* Generic Property class ID */ + hid_t cid2; /* Generic Property class ID */ + hid_t cid3; /* Generic Property class ID */ + char * path; /* Class path */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Generic Property List Class Path Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Get full path for first class */ path = H5P__get_class_path_test(cid1); CHECK_PTR(path, "H5P__get_class_path_test"); - if(HDstrcmp(path,CLASS1_PATH)!=0) - TestErrPrintf("Class names don't match!, path=%s, CLASS1_PATH=%s\n",path,CLASS1_PATH); + if (HDstrcmp(path, CLASS1_PATH) != 0) + TestErrPrintf("Class names don't match!, path=%s, CLASS1_PATH=%s\n", path, CLASS1_PATH); H5free_memory(path); /* Create another new generic class, derived from first class */ - cid2 = H5Pcreate_class(cid1,CLASS2_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid2 = H5Pcreate_class(cid1, CLASS2_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid2, "H5Pcreate_class"); /* Insert second property into class (with no callbacks) */ - ret = H5Pregister2(cid2, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid2, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Get full path for second class */ path = H5P__get_class_path_test(cid2); CHECK_PTR(path, "H5P__get_class_path_test"); - if(HDstrcmp(path,CLASS2_PATH)!=0) - TestErrPrintf("Class names don't match!, path=%s, CLASS2_PATH=%s\n",path,CLASS2_PATH); + if (HDstrcmp(path, CLASS2_PATH) != 0) + TestErrPrintf("Class names don't match!, path=%s, CLASS2_PATH=%s\n", path, CLASS2_PATH); /* Open a copy of the class with the path name */ cid3 = H5P__open_class_path_test(path); CHECK_I(cid3, "H5P__open_class_path_test"); /* Check that the classes are equal */ - ret = H5Pequal(cid2,cid3); + ret = H5Pequal(cid2, cid3); VERIFY(ret, 1, "H5Pequal"); /* Release the path string */ @@ -1828,20 +1851,21 @@ test_genprop_path(void) static void test_genprop_refcount(void) { - hid_t cid1; /* Generic Property class ID */ - hid_t lid1; /* Generic Property class ID */ - char *name; /* Name of class */ - herr_t ret; /* Generic return value */ + hid_t cid1; /* Generic Property class ID */ + hid_t lid1; /* Generic Property class ID */ + char * name; /* Name of class */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Generic Property List Reference Count Functionality\n")); /* Create a new generic class, derived from the root of the class hierarchy */ - cid1 = H5Pcreate_class(H5P_ROOT,CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); + cid1 = H5Pcreate_class(H5P_ROOT, CLASS1_NAME, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(cid1, "H5Pcreate_class"); /* Insert first property into class (with no callbacks) */ - ret = H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ret = + H5Pregister2(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); CHECK_I(ret, "H5Pregister2"); /* Create a new generic list, derived from the root of the class hierarchy */ @@ -1851,8 +1875,8 @@ test_genprop_refcount(void) /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS1_NAME)!=0) - TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); + if (HDstrcmp(name, CLASS1_NAME) != 0) + TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n", name, CLASS1_NAME); H5free_memory(name); /* Close class */ @@ -1864,14 +1888,14 @@ test_genprop_refcount(void) CHECK_I(cid1, "H5Pget_class"); /* Check correct "is a" class/list relationship */ - ret = H5Pisa_class(lid1,cid1); + ret = H5Pisa_class(lid1, cid1); VERIFY(ret, 1, "H5Pisa_class"); /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS1_NAME)!=0) - TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); + if (HDstrcmp(name, CLASS1_NAME) != 0) + TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n", name, CLASS1_NAME); H5free_memory(name); /* Close list */ @@ -1881,8 +1905,8 @@ test_genprop_refcount(void) /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS1_NAME)!=0) - TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); + if (HDstrcmp(name, CLASS1_NAME) != 0) + TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n", name, CLASS1_NAME); H5free_memory(name); /* Close class */ @@ -1901,10 +1925,10 @@ test_genprop_refcount(void) static void test_genprop_deprec_class(void) { - hid_t cid1; /* Generic Property class ID */ - size_t size; /* Size of property */ - size_t nprops; /* Number of properties in class */ - herr_t ret; /* Generic return value */ + hid_t cid1; /* Generic Property class ID */ + size_t size; /* Size of property */ + size_t nprops; /* Number of properties in class */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deprecated Generic Property List Functions\n")); @@ -2029,12 +2053,12 @@ test_genprop_deprec_class(void) static void test_genprop_deprec_list(void) { - hid_t fid; /* File ID */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t pid; /* Property List ID */ - int prop1_value; /* Value for property #1 */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t pid; /* Property List ID */ + int prop1_value; /* Value for property #1 */ + herr_t ret; /* Generic return value */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2057,7 +2081,7 @@ test_genprop_deprec_list(void) VERIFY(ret, 1, "H5Pexist"); /* Check values of property (set with default value) */ - ret = H5Pget(pid, PROP1_NAME,&prop1_value); + ret = H5Pget(pid, PROP1_NAME, &prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); @@ -2104,32 +2128,32 @@ test_genprop(void) MESSAGE(5, ("Testing Generic Properties\n")); /* These tests use the same file... */ - test_genprop_basic_class(); /* Test basic code for creating a generic class */ + test_genprop_basic_class(); /* Test basic code for creating a generic class */ test_genprop_basic_class_prop(); /* Test basic code for adding properties to a generic class */ - test_genprop_class_iter(); /* Test code for iterating over properties in a generic class */ - test_genprop_class_callback(); /* Test code for property class callbacks */ + test_genprop_class_iter(); /* Test code for iterating over properties in a generic class */ + test_genprop_class_callback(); /* Test code for property class callbacks */ - test_genprop_basic_list(); /* Test basic code for creating a generic property list */ + test_genprop_basic_list(); /* Test basic code for creating a generic property list */ test_genprop_basic_list_prop(); /* Test basic code for adding properties to a generic property list */ - test_genprop_list_iter(); /* Test basic code for iterating over properties in a generic property list */ - test_genprop_list_callback(); /* Test code for property list callbacks */ + test_genprop_list_iter(); /* Test basic code for iterating over properties in a generic property list */ + test_genprop_list_callback(); /* Test code for property list callbacks */ - test_genprop_list_addprop(); /* Test adding properties to HDF5 property list */ - test_genprop_class_addprop(); /* Test adding properties to HDF5 property class */ + test_genprop_list_addprop(); /* Test adding properties to HDF5 property list */ + test_genprop_class_addprop(); /* Test adding properties to HDF5 property class */ - test_genprop_list_add_remove_prop(); /* Test adding and removing the same property several times to HDF5 property list */ + test_genprop_list_add_remove_prop(); /* Test adding and removing the same property several times to HDF5 + property list */ - test_genprop_equal(); /* Tests for more H5Pequal verification */ - test_genprop_path(); /* Tests for class path verification */ - test_genprop_refcount(); /* Tests for class reference counting */ + test_genprop_equal(); /* Tests for more H5Pequal verification */ + test_genprop_path(); /* Tests for class path verification */ + test_genprop_refcount(); /* Tests for class reference counting */ #ifndef H5_NO_DEPRECATED_SYMBOLS - test_genprop_deprec_class(); /* Tests for deprecated routines */ - test_genprop_deprec_list(); /* Tests for deprecated routines */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - -} /* test_genprop() */ + test_genprop_deprec_class(); /* Tests for deprecated routines */ + test_genprop_deprec_list(); /* Tests for deprecated routines */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ +} /* test_genprop() */ /*------------------------------------------------------------------------- * Function: cleanup_genprop @@ -2150,4 +2174,3 @@ cleanup_genprop(void) { remove(FILENAME); } - diff --git a/test/th5o.c b/test/th5o.c index 4bc2096..2c17843 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -12,12 +12,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: th5o -* -* Test public H5O functions for accessing -* -*************************************************************/ + * + * Test program: th5o + * + * Test public H5O functions for accessing + * + *************************************************************/ #include "testhdf5.h" #include "H5Fprivate.h" @@ -33,7 +33,6 @@ #define TEST6_DIM1 100 #define TEST6_DIM2 100 - /**************************************************************** ** ** test_h5o_open(): Test H5Oopen function. @@ -42,13 +41,13 @@ static void test_h5o_open(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ hsize_t dims[RANK]; - H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ - H5G_info_t ginfo; /* Group info struct */ - H5T_class_t type_class; /* Class of the datatype */ - herr_t ret; /* Value returned from API calls */ + H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ + H5G_info_t ginfo; /* Group info struct */ + H5T_class_t type_class; /* Class of the datatype */ + herr_t ret; /* Value returned from API calls */ /* Create a new HDF5 file */ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -72,7 +71,7 @@ test_h5o_open(void) /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; - dspace = H5Screate_simple(RANK, dims, NULL); + dspace = H5Screate_simple(RANK, dims, NULL); CHECK(dspace, FAIL, "H5Screate_simple"); /* Create the dataset. */ @@ -122,28 +121,30 @@ test_h5o_open(void) CHECK(ret, FAIL, "H5Dclose"); /* Trying to open objects with bogus names should fail gracefully */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { grp = H5Oopen(fid, "bogus_group", H5P_DEFAULT); VERIFY(grp, FAIL, "H5Oopen"); dtype = H5Oopen(fid, "group/bogus_datatype", H5P_DEFAULT); VERIFY(dtype, FAIL, "H5Oopen"); dset = H5Oopen(fid, "/bogus_dataset", H5P_DEFAULT); VERIFY(dset, FAIL, "H5Oopen"); - } H5E_END_TRY + } + H5E_END_TRY /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); /* Trying to open an object with a bogus file ID should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset = H5Oopen(fid, "dataset", H5P_DEFAULT); VERIFY(dset, FAIL, "H5Oopen"); - } H5E_END_TRY + } + H5E_END_TRY } /* test_h5o_open() */ - - /**************************************************************** ** ** test_h5o_close(): Test H5Oclose function. @@ -152,10 +153,10 @@ test_h5o_open(void) static void test_h5o_close(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ - hsize_t dims[RANK]; - herr_t ret; /* Value returned from API calls */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ + hsize_t dims[RANK]; + herr_t ret; /* Value returned from API calls */ /* Create a new HDF5 file */ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -180,7 +181,7 @@ test_h5o_close(void) /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; - dspace = H5Screate_simple(RANK, dims, NULL); + dspace = H5Screate_simple(RANK, dims, NULL); CHECK(dspace, FAIL, "H5Screate_simple"); /* Create the dataset. */ @@ -190,10 +191,12 @@ test_h5o_close(void) CHECK(ret, FAIL, "H5Oclose"); /* Attempting to close the data space with H5Oclose should fail */ - H5E_BEGIN_TRY { - ret = H5Oclose(dspace); - VERIFY(ret, FAIL, "H5Oclose"); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Oclose(dspace); + VERIFY(ret, FAIL, "H5Oclose"); + } + H5E_END_TRY /* Close the dataspace for real */ ret = H5Sclose(dspace); CHECK(ret, FAIL, "H5Sclose"); @@ -233,7 +236,6 @@ test_h5o_close(void) CHECK(ret, FAIL, "H5Fclose"); } - #ifndef H5_NO_DEPRECATED_SYMBOLS /**************************************************************** ** @@ -243,17 +245,17 @@ test_h5o_close(void) static void test_h5o_open_by_addr(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5L_info2_t li; /* Buffer for H5Lget_info2 */ - haddr_t grp_addr; /* Addresses for objects */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ + H5L_info2_t li; /* Buffer for H5Lget_info2 */ + haddr_t grp_addr; /* Addresses for objects */ haddr_t dset_addr; haddr_t dtype_addr; hsize_t dims[RANK]; - H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ - H5G_info_t ginfo; /* Group info struct */ - H5T_class_t type_class; /* Class of the datatype */ - herr_t ret; /* Value returned from API calls */ + H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ + H5G_info_t ginfo; /* Group info struct */ + H5T_class_t type_class; /* Class of the datatype */ + herr_t ret; /* Value returned from API calls */ /* Create a new HDF5 file */ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -277,7 +279,7 @@ test_h5o_open_by_addr(void) /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; - dspace = H5Screate_simple(RANK, dims, NULL); + dspace = H5Screate_simple(RANK, dims, NULL); CHECK(dspace, FAIL, "H5Screate_simple"); /* Create the dataset. */ @@ -345,39 +347,46 @@ test_h5o_open_by_addr(void) /* Try giving some bogus values to H5O_open_by_addr. */ /* Try to open an object with a bad address */ grp_addr += 20; - H5E_BEGIN_TRY{ - grp = H5Oopen_by_addr(fid, grp_addr); - }H5E_END_TRY + H5E_BEGIN_TRY + { + grp = H5Oopen_by_addr(fid, grp_addr); + } + H5E_END_TRY VERIFY(grp, FAIL, "H5Oopen_by_addr"); /* For instance, an objectno smaller than the end of the file's superblock should * trigger an error */ grp_addr = 10; - H5E_BEGIN_TRY{ - grp = H5Oopen_by_addr(fid, grp_addr); - }H5E_END_TRY + H5E_BEGIN_TRY + { + grp = H5Oopen_by_addr(fid, grp_addr); + } + H5E_END_TRY VERIFY(grp, FAIL, "H5Oopen_by_addr"); /* Likewise, an objectno larger than the size of the file should fail */ grp_addr = 0; grp_addr = 1000000000; - H5E_BEGIN_TRY{ - grp = H5Oopen_by_addr(fid, grp_addr); - }H5E_END_TRY + H5E_BEGIN_TRY + { + grp = H5Oopen_by_addr(fid, grp_addr); + } + H5E_END_TRY VERIFY(grp, FAIL, "H5Oopen_by_addr"); ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); /* Also, trying to open an object without a valid location should fail */ - H5E_BEGIN_TRY{ - dtype = H5Oopen_by_addr(fid, dtype_addr); - }H5E_END_TRY + H5E_BEGIN_TRY + { + dtype = H5Oopen_by_addr(fid, dtype_addr); + } + H5E_END_TRY VERIFY(dtype, FAIL, "H5Oopen_by_addr"); } /* test_h5o_open_by_addr() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /**************************************************************** ** ** test_h5o_open_by_token(): Test H5Oopen_by_token function. @@ -386,14 +395,14 @@ test_h5o_open_by_addr(void) static void test_h5o_open_by_token(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5L_info2_t li; /* Buffer for H5Lget_info */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ + H5L_info2_t li; /* Buffer for H5Lget_info */ hsize_t dims[RANK]; - H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ - H5G_info_t ginfo; /* Group info struct */ - H5T_class_t type_class; /* Class of the datatype */ - herr_t ret; /* Value returned from API calls */ + H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ + H5G_info_t ginfo; /* Group info struct */ + H5T_class_t type_class; /* Class of the datatype */ + herr_t ret; /* Value returned from API calls */ /* Create a new HDF5 file */ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -417,7 +426,7 @@ test_h5o_open_by_token(void) /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; - dspace = H5Screate_simple(RANK, dims, NULL); + dspace = H5Screate_simple(RANK, dims, NULL); CHECK(dspace, FAIL, "H5Screate_simple"); /* Create the dataset. */ @@ -476,18 +485,22 @@ test_h5o_open_by_token(void) /* Try giving some bogus values to H5O_open_by_token */ /* Try opening an object using H5O_TOKEN_UNDEF (should fail) */ - H5E_BEGIN_TRY{ - dtype = H5Oopen_by_token(fid, H5O_TOKEN_UNDEF); - }H5E_END_TRY + H5E_BEGIN_TRY + { + dtype = H5Oopen_by_token(fid, H5O_TOKEN_UNDEF); + } + H5E_END_TRY VERIFY(dtype, FAIL, "H5Oopen_by_token"); ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); /* Also, trying to open an object without a valid location (should fail) */ - H5E_BEGIN_TRY{ - dtype = H5Oopen_by_token(fid, li.u.token); - }H5E_END_TRY + H5E_BEGIN_TRY + { + dtype = H5Oopen_by_token(fid, li.u.token); + } + H5E_END_TRY VERIFY(dtype, FAIL, "H5Oopen_by_token"); } /* test_h5o_open_by_token() */ @@ -500,11 +513,11 @@ test_h5o_open_by_token(void) static void test_h5o_refcount(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5O_info2_t oinfo; /* Object info struct */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ + H5O_info2_t oinfo; /* Object info struct */ hsize_t dims[RANK]; - herr_t ret; /* Value returned from API calls */ + herr_t ret; /* Value returned from API calls */ /* Create a new HDF5 file */ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -524,7 +537,7 @@ test_h5o_refcount(void) /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; - dspace = H5Screate_simple(RANK, dims, NULL); + dspace = H5Screate_simple(RANK, dims, NULL); CHECK(dspace, FAIL, "H5Screate_simple"); /* Create the dataset. */ @@ -666,7 +679,8 @@ test_h5o_refcount(void) CHECK(ret, FAIL, "H5Dclose"); /* Make sure that bogus IDs return errors properly */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oincr_refcount(grp); VERIFY(ret, FAIL, "H5Oincr_refcount"); ret = H5Oincr_refcount(dtype); @@ -679,14 +693,14 @@ test_h5o_refcount(void) VERIFY(ret, FAIL, "H5Odecr_refcount"); ret = H5Odecr_refcount(dset); VERIFY(ret, FAIL, "H5Odecr_refcount"); - } H5E_END_TRY + } + H5E_END_TRY /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); } /* test_h5o_refcount() */ - /**************************************************************** ** ** test_h5o_plist(): Test object creation properties @@ -695,13 +709,13 @@ test_h5o_refcount(void) static void test_h5o_plist(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ - hid_t fapl; /* File access property list */ - hid_t gcpl, dcpl, tcpl; /* Object creation properties */ - unsigned def_max_compact, def_min_dense; /* Default phase change parameters */ - unsigned max_compact, min_dense; /* Actual phase change parameters */ - herr_t ret; /* Value returned from API calls */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ + hid_t fapl; /* File access property list */ + hid_t gcpl, dcpl, tcpl; /* Object creation properties */ + unsigned def_max_compact, def_min_dense; /* Default phase change parameters */ + unsigned max_compact, min_dense; /* Actual phase change parameters */ + herr_t ret; /* Value returned from API calls */ /* Make a FAPL that uses the "use the latest version of the format" flag */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -880,7 +894,6 @@ test_h5o_plist(void) CHECK(ret, FAIL, "H5Pclose"); } /* test_h5o_plist() */ - /**************************************************************** ** ** test_h5o_link(): Test creating link to object @@ -889,20 +902,20 @@ test_h5o_plist(void) static void test_h5o_link(void) { - hid_t file_id=-1; - hid_t group_id=-1; - hid_t space_id=-1; - hid_t dset_id=-1; - hid_t type_id=-1; - hid_t fapl_id=-1; - hid_t lcpl_id=-1; - hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2}; - htri_t committed; /* Whether the named datatype is committed */ + hid_t file_id = -1; + hid_t group_id = -1; + hid_t space_id = -1; + hid_t dset_id = -1; + hid_t type_id = -1; + hid_t fapl_id = -1; + hid_t lcpl_id = -1; + hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2}; + htri_t committed; /* Whether the named datatype is committed */ H5F_libver_t low, high; /* File format bounds */ - int *wdata; - int *rdata; - int i, n; - herr_t ret; /* Value returned from API calls */ + int * wdata; + int * rdata; + int i, n; + herr_t ret; /* Value returned from API calls */ /* Allocate memory buffers */ /* (These are treated as 2-D buffers) */ @@ -912,11 +925,11 @@ test_h5o_link(void) CHECK_PTR(rdata, "HDmalloc"); /* Initialize the raw data */ - for(i = n = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) - wdata[i] = n++; + for (i = n = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) + wdata[i] = n++; /* Create the dataspace */ - space_id = H5Screate_simple(2 ,dims, NULL); + space_id = H5Screate_simple(2, dims, NULL); CHECK(space_id, FAIL, "H5Screate_simple"); /* Create LCPL with intermediate group creation flag set */ @@ -930,13 +943,15 @@ test_h5o_link(void) CHECK(fapl_id, FAIL, "H5Pcreate"); /* Loop through all the combinations of low/high library format bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Set version bounds */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_libver_bounds(fapl_id, low, high); - } H5E_END_TRY; + } + H5E_END_TRY; if (ret < 0) /* Invalid low/high combinations */ continue; @@ -972,7 +987,7 @@ test_h5o_link(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the data */ - for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) + for (i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) VERIFY(wdata[i], rdata[i], "H5Dread"); /* Create a group with no name*/ @@ -1010,7 +1025,7 @@ test_h5o_link(void) /* Read data from dataset */ ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Dread"); - for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) + for (i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) VERIFY(wdata[i], rdata[i], "H5Dread"); /* Close open IDs */ @@ -1021,7 +1036,7 @@ test_h5o_link(void) ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); } /* for high */ - } /* for low */ + } /* for low */ /* Close remaining IDs */ ret = H5Sclose(space_id); @@ -1034,7 +1049,6 @@ test_h5o_link(void) HDfree(rdata); } /* end test_h5o_link() */ - /**************************************************************** ** ** test_h5o_comment(): Test H5Oset(get)_comment functions. @@ -1043,20 +1057,20 @@ test_h5o_link(void) static void test_h5o_comment(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ hid_t attr_space, attr_id; hsize_t dims[RANK]; - hsize_t attr_dims = 1; - int attr_value = 5; - const char *file_comment = "file comment"; - const char *grp_comment = "group comment"; - const char *dset_comment = "dataset comment"; - const char *dtype_comment = "datatype comment"; + hsize_t attr_dims = 1; + int attr_value = 5; + const char *file_comment = "file comment"; + const char *grp_comment = "group comment"; + const char *dset_comment = "dataset comment"; + const char *dtype_comment = "datatype comment"; char check_comment[64]; ssize_t comment_len = 0; ssize_t len; - herr_t ret; /* Value returned from API calls */ + herr_t ret; /* Value returned from API calls */ int ret_value; /* Create a new HDF5 file */ @@ -1109,7 +1123,7 @@ test_h5o_comment(void) /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; - dspace = H5Screate_simple(RANK, dims, NULL); + dspace = H5Screate_simple(RANK, dims, NULL); CHECK(dspace, FAIL, "H5Screate_simple"); /* Create the dataset. */ @@ -1121,9 +1135,11 @@ test_h5o_comment(void) CHECK(ret, FAIL, "H5Oset_comment"); /* Putting a comment on the dataspace. It's supposed to fail. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oset_comment(dspace, "dataspace comment"); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Oset_comment"); /* Close the file */ @@ -1134,7 +1150,6 @@ test_h5o_comment(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Now make sure that the comments are correct all 4 types of objects */ /* Open file */ fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -1144,7 +1159,7 @@ test_h5o_comment(void) comment_len = H5Oget_comment(fid, NULL, (size_t)0); CHECK(comment_len, FAIL, "H5Oget_comment"); - len = H5Oget_comment(fid, check_comment, (size_t)comment_len+1); + len = H5Oget_comment(fid, check_comment, (size_t)comment_len + 1); CHECK(len, FAIL, "H5Oget_comment"); ret_value = HDstrcmp(file_comment, check_comment); @@ -1158,7 +1173,7 @@ test_h5o_comment(void) comment_len = H5Oget_comment(grp, NULL, (size_t)0); CHECK(comment_len, FAIL, "H5Oget_comment"); - len = H5Oget_comment(grp, check_comment, (size_t)comment_len+1); + len = H5Oget_comment(grp, check_comment, (size_t)comment_len + 1); CHECK(len, FAIL, "H5Oget_comment"); ret_value = HDstrcmp(grp_comment, check_comment); @@ -1172,7 +1187,7 @@ test_h5o_comment(void) comment_len = H5Oget_comment(dtype, NULL, (size_t)0); CHECK(comment_len, FAIL, "H5Oget_comment"); - len = H5Oget_comment(dtype, check_comment, (size_t)comment_len+1); + len = H5Oget_comment(dtype, check_comment, (size_t)comment_len + 1); CHECK(len, FAIL, "H5Oget_comment"); ret_value = HDstrcmp(dtype_comment, check_comment); @@ -1186,13 +1201,12 @@ test_h5o_comment(void) comment_len = H5Oget_comment(dset, NULL, (size_t)0); CHECK(comment_len, FAIL, "H5Oget_comment"); - len = H5Oget_comment(dset, check_comment, (size_t)comment_len+1); + len = H5Oget_comment(dset, check_comment, (size_t)comment_len + 1); CHECK(ret, len, "H5Oget_comment"); ret_value = HDstrcmp(dset_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment"); - /* Close the IDs */ ret = H5Gclose(grp); CHECK(ret, FAIL, "H5Gclose"); @@ -1207,7 +1221,6 @@ test_h5o_comment(void) } /* test_h5o_comment() */ - /**************************************************************** ** ** test_h5o_comment_by_name(): Test H5Oset(get)_comment_by_name functions. @@ -1216,20 +1229,20 @@ test_h5o_comment(void) static void test_h5o_comment_by_name(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ hid_t attr_space, attr_id; hsize_t dims[RANK]; - hsize_t attr_dims = 1; - int attr_value = 5; - const char *file_comment = "file comment by name"; - const char *grp_comment = "group comment by name"; - const char *dset_comment = "dataset comment by name"; - const char *dtype_comment = "datatype comment by name"; + hsize_t attr_dims = 1; + int attr_value = 5; + const char *file_comment = "file comment by name"; + const char *grp_comment = "group comment by name"; + const char *dset_comment = "dataset comment by name"; + const char *dtype_comment = "datatype comment by name"; char check_comment[64]; ssize_t comment_len = 0; ssize_t len; - herr_t ret; /* Value returned from API calls */ + herr_t ret; /* Value returned from API calls */ int ret_value; /* Create a new HDF5 file */ @@ -1282,7 +1295,7 @@ test_h5o_comment_by_name(void) /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; - dspace = H5Screate_simple(RANK, dims, NULL); + dspace = H5Screate_simple(RANK, dims, NULL); CHECK(dspace, FAIL, "H5Screate_simple"); /* Create the dataset. */ @@ -1294,9 +1307,11 @@ test_h5o_comment_by_name(void) CHECK(ret, FAIL, "H5Oset_comment_by_name"); /* Putting a comment on the dataspace. It's supposed to fail. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Oset_comment_by_name(dspace, ".", "dataspace comment", H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Oset_comment"); /* Close the file */ @@ -1316,7 +1331,7 @@ test_h5o_comment_by_name(void) comment_len = H5Oget_comment_by_name(fid, ".", NULL, (size_t)0, H5P_DEFAULT); CHECK(comment_len, FAIL, "H5Oget_comment_by_name"); - len = H5Oget_comment_by_name(fid, ".", check_comment, (size_t)comment_len+1, H5P_DEFAULT); + len = H5Oget_comment_by_name(fid, ".", check_comment, (size_t)comment_len + 1, H5P_DEFAULT); CHECK(len, FAIL, "H5Oget_comment_by_name"); ret_value = HDstrcmp(file_comment, check_comment); @@ -1330,7 +1345,7 @@ test_h5o_comment_by_name(void) comment_len = H5Oget_comment_by_name(fid, "group", NULL, (size_t)0, H5P_DEFAULT); CHECK(comment_len, FAIL, "H5Oget_comment_by_name"); - len = H5Oget_comment_by_name(fid, "group", check_comment, (size_t)comment_len+1, H5P_DEFAULT); + len = H5Oget_comment_by_name(fid, "group", check_comment, (size_t)comment_len + 1, H5P_DEFAULT); CHECK(len, FAIL, "H5Oget_comment_by_name"); ret_value = HDstrcmp(grp_comment, check_comment); @@ -1340,7 +1355,7 @@ test_h5o_comment_by_name(void) comment_len = H5Oget_comment_by_name(grp, "datatype", NULL, (size_t)0, H5P_DEFAULT); CHECK(comment_len, FAIL, "H5Oget_comment_by_name"); - len = H5Oget_comment_by_name(grp, "datatype", check_comment, (size_t)comment_len+1, H5P_DEFAULT); + len = H5Oget_comment_by_name(grp, "datatype", check_comment, (size_t)comment_len + 1, H5P_DEFAULT); CHECK(len, FAIL, "H5Oget_comment"); ret_value = HDstrcmp(dtype_comment, check_comment); @@ -1350,7 +1365,7 @@ test_h5o_comment_by_name(void) comment_len = H5Oget_comment_by_name(fid, "dataset", NULL, (size_t)0, H5P_DEFAULT); CHECK(comment_len, FAIL, "H5Oget_comment_by_name"); - len = H5Oget_comment_by_name(fid, "dataset", check_comment, (size_t)comment_len+1, H5P_DEFAULT); + len = H5Oget_comment_by_name(fid, "dataset", check_comment, (size_t)comment_len + 1, H5P_DEFAULT); CHECK(len, FAIL, "H5Oget_comment_by_name"); ret_value = HDstrcmp(dset_comment, check_comment); @@ -1366,7 +1381,6 @@ test_h5o_comment_by_name(void) } /* test_h5o_comment_by_name() */ - /**************************************************************** ** ** test_h5o_getinfo_same_file(): Test that querying the object info for @@ -1376,10 +1390,10 @@ test_h5o_comment_by_name(void) static void test_h5o_getinfo_same_file(void) { - hid_t fid1, fid2; /* HDF5 File ID */ - hid_t gid1, gid2; /* Group IDs */ - H5O_info2_t oinfo1, oinfo2; /* Object info structs */ - herr_t ret; /* Value returned from API calls */ + hid_t fid1, fid2; /* HDF5 File ID */ + hid_t gid1, gid2; /* Group IDs */ + H5O_info2_t oinfo1, oinfo2; /* Object info structs */ + herr_t ret; /* Value returned from API calls */ /* Create a new HDF5 file */ fid1 = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1423,7 +1437,6 @@ test_h5o_getinfo_same_file(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open file twice */ fid1 = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -1482,17 +1495,17 @@ test_h5o_getinfo_same_file(void) static void test_h5o_open_by_addr_deprec(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5L_info1_t li; /* Buffer for H5Lget_info1 */ - haddr_t grp_addr; /* Addresses for objects */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ + H5L_info1_t li; /* Buffer for H5Lget_info1 */ + haddr_t grp_addr; /* Addresses for objects */ haddr_t dset_addr; haddr_t dtype_addr; hsize_t dims[RANK]; - H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ - H5G_info_t ginfo; /* Group info struct */ - H5T_class_t type_class; /* Class of the datatype */ - herr_t ret; /* Value returned from API calls */ + H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ + H5G_info_t ginfo; /* Group info struct */ + H5T_class_t type_class; /* Class of the datatype */ + herr_t ret; /* Value returned from API calls */ /* Create a new HDF5 file */ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1516,7 +1529,7 @@ test_h5o_open_by_addr_deprec(void) /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; - dspace = H5Screate_simple(RANK, dims, NULL); + dspace = H5Screate_simple(RANK, dims, NULL); CHECK(dspace, FAIL, "H5Screate_simple"); /* Create the dataset. */ @@ -1531,10 +1544,10 @@ test_h5o_open_by_addr_deprec(void) ret = H5Lget_info1(fid, "group", &li, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lget_info"); grp_addr = li.u.address; - ret = H5Lget_info1(fid, "group/datatype", &li, H5P_DEFAULT); + ret = H5Lget_info1(fid, "group/datatype", &li, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lget_info"); dtype_addr = li.u.address; - ret = H5Lget_info1(fid, "dataset", &li, H5P_DEFAULT); + ret = H5Lget_info1(fid, "dataset", &li, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lget_info"); dset_addr = li.u.address; @@ -1579,38 +1592,45 @@ test_h5o_open_by_addr_deprec(void) /* Try giving some bogus values to H5O_open_by_addr. */ /* Try to open an object with a bad address */ grp_addr += 20; - H5E_BEGIN_TRY{ - grp = H5Oopen_by_addr(fid, grp_addr); - }H5E_END_TRY + H5E_BEGIN_TRY + { + grp = H5Oopen_by_addr(fid, grp_addr); + } + H5E_END_TRY VERIFY(grp, FAIL, "H5Oopen_by_addr"); /* For instance, an objectno smaller than the end of the file's superblock should * trigger an error */ grp_addr = 10; - H5E_BEGIN_TRY{ - grp = H5Oopen_by_addr(fid, grp_addr); - }H5E_END_TRY + H5E_BEGIN_TRY + { + grp = H5Oopen_by_addr(fid, grp_addr); + } + H5E_END_TRY VERIFY(grp, FAIL, "H5Oopen_by_addr"); /* Likewise, an objectno larger than the size of the file should fail */ grp_addr = 0; grp_addr = 1000000000; - H5E_BEGIN_TRY{ - grp = H5Oopen_by_addr(fid, grp_addr); - }H5E_END_TRY + H5E_BEGIN_TRY + { + grp = H5Oopen_by_addr(fid, grp_addr); + } + H5E_END_TRY VERIFY(grp, FAIL, "H5Oopen_by_addr"); ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); /* Also, trying to open an object without a valid location should fail */ - H5E_BEGIN_TRY{ - dtype = H5Oopen_by_addr(fid, dtype_addr); - }H5E_END_TRY + H5E_BEGIN_TRY + { + dtype = H5Oopen_by_addr(fid, dtype_addr); + } + H5E_END_TRY VERIFY(dtype, FAIL, "H5Oopen_by_addr"); } /* test_h5o_open_by_addr_deprec() */ - /**************************************************************** ** ** visit_obj_cb(): @@ -1621,29 +1641,31 @@ test_h5o_open_by_addr_deprec(void) ** ****************************************************************/ static int -visit_obj_cb(hid_t group_id, const char *name, const H5O_info1_t *oinfo1, - void H5_ATTR_UNUSED *_op_data) +visit_obj_cb(hid_t group_id, const char *name, const H5O_info1_t *oinfo1, void H5_ATTR_UNUSED *_op_data) { - H5O_info1_t oinfo2; /* Object info structs */ + H5O_info1_t oinfo2; /* Object info structs */ /* Verify the object info for "group1", "group2" and the root group */ - if(!(HDstrcmp(name, "group1"))) { + if (!(HDstrcmp(name, "group1"))) { H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_NUM_ATTRS, H5P_DEFAULT); VERIFY(oinfo1->num_attrs, oinfo2.num_attrs, "obj info from H5Ovisit1"); - } else if(!(HDstrcmp(name, "group2"))) { + } + else if (!(HDstrcmp(name, "group2"))) { H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_HDR, H5P_DEFAULT); VERIFY(oinfo1->hdr.nmesgs, oinfo2.hdr.nmesgs, "obj info from H5Ovisit1/H5Oget_info2"); VERIFY(oinfo1->hdr.nchunks, oinfo2.hdr.nchunks, "obj info from H5Ovisit1/H5Oget_info2"); - } else if(!(HDstrcmp(name, "."))) { + } + else if (!(HDstrcmp(name, "."))) { H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_META_SIZE, H5P_DEFAULT); - VERIFY(oinfo1->meta_size.obj.index_size, oinfo2.meta_size.obj.index_size, "obj info from H5Ovisit1/H5Oget_info2"); - VERIFY(oinfo1->meta_size.obj.heap_size, oinfo2.meta_size.obj.heap_size, "obj info from H5Ovisit1/H5Oget_info2"); + VERIFY(oinfo1->meta_size.obj.index_size, oinfo2.meta_size.obj.index_size, + "obj info from H5Ovisit1/H5Oget_info2"); + VERIFY(oinfo1->meta_size.obj.heap_size, oinfo2.meta_size.obj.heap_size, + "obj info from H5Ovisit1/H5Oget_info2"); } - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /* end visit_obj_cb() */ - /**************************************************************** ** ** test_h5o_getinfo_visit(): @@ -1656,14 +1678,14 @@ visit_obj_cb(hid_t group_id, const char *name, const H5O_info1_t *oinfo1, static void test_h5o_getinfo_visit(void) { - hid_t fid = -1; /* HDF5 File ID */ - hid_t gid1 = -1, gid2 = -1; /* Group IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - H5O_info1_t oinfo1, oinfo2; /* Object info structs */ - char attrname[25]; /* Attribute name */ - int j; /* Local index variable */ - herr_t ret; /* Value returned from API calls */ + hid_t fid = -1; /* HDF5 File ID */ + hid_t gid1 = -1, gid2 = -1; /* Group IDs */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + H5O_info1_t oinfo1, oinfo2; /* Object info structs */ + char attrname[25]; /* Attribute name */ + int j; /* Local index variable */ + herr_t ret; /* Value returned from API calls */ /* Create an HDF5 file */ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1678,7 +1700,7 @@ test_h5o_getinfo_visit(void) CHECK(sid, FAIL, "H5Screate"); /* Attach 10 attributes to "group1" */ - for(j = 0; j <10; j++) { + for (j = 0; j < 10; j++) { /* Create the attribute name */ HDsprintf(attrname, "attr%u", j); /* Create the attribute */ @@ -1700,7 +1722,7 @@ test_h5o_getinfo_visit(void) /* Query the object info for "group1" via H5Oget_info1 and H5Oget_info2 */ ret = H5Oget_info1(gid1, &oinfo1); CHECK(ret, FAIL, "H5Oget_info1"); - ret = H5Oget_info2(gid1, &oinfo2, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS); + ret = H5Oget_info2(gid1, &oinfo2, H5O_INFO_BASIC | H5O_INFO_NUM_ATTRS); CHECK(ret, FAIL, "H5Oget_info2"); /* Verify the object info for "group1" is correct */ @@ -1714,7 +1736,7 @@ test_h5o_getinfo_visit(void) /* Query the object info for "group2" via H5Oget_info1 and H5Oget_info2 */ ret = H5Oget_info_by_name1(fid, "group2", &oinfo1, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_native_info_by_name"); - ret = H5Oget_info_by_name2(fid, "group2", &oinfo2, H5O_INFO_HDR|H5O_INFO_META_SIZE, H5P_DEFAULT); + ret = H5Oget_info_by_name2(fid, "group2", &oinfo2, H5O_INFO_HDR | H5O_INFO_META_SIZE, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_native_info_by_name"); /* Verify the object info for "group2" is correct */ @@ -1740,7 +1762,6 @@ test_h5o_getinfo_visit(void) #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /**************************************************************** ** ** test_h5o(): Main H5O (generic object) testing routine. @@ -1752,25 +1773,24 @@ test_h5o(void) /* Output message about test being performed */ MESSAGE(5, ("Testing Objects\n")); - test_h5o_open(); /* Test generic open function */ + test_h5o_open(); /* Test generic open function */ #ifndef H5_NO_DEPRECATED_SYMBOLS - test_h5o_open_by_addr(); /* Test opening objects by address */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - test_h5o_open_by_token(); /* Test opening objects by token */ - test_h5o_close(); /* Test generic close function */ - test_h5o_refcount(); /* Test incrementing and decrementing reference count */ - test_h5o_plist(); /* Test object creation properties */ - test_h5o_link(); /* Test object link routine */ - test_h5o_comment(); /* Test routines for comment */ - test_h5o_comment_by_name(); /* Test routines for comment by name */ - test_h5o_getinfo_same_file(); /* Test info for objects in the same file */ + test_h5o_open_by_addr(); /* Test opening objects by address */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + test_h5o_open_by_token(); /* Test opening objects by token */ + test_h5o_close(); /* Test generic close function */ + test_h5o_refcount(); /* Test incrementing and decrementing reference count */ + test_h5o_plist(); /* Test object creation properties */ + test_h5o_link(); /* Test object link routine */ + test_h5o_comment(); /* Test routines for comment */ + test_h5o_comment_by_name(); /* Test routines for comment by name */ + test_h5o_getinfo_same_file(); /* Test info for objects in the same file */ #ifndef H5_NO_DEPRECATED_SYMBOLS test_h5o_open_by_addr_deprec(); /* Test opening objects by address with H5Lget_info1 */ test_h5o_getinfo_visit(); /* Test object info for H5Oget_info1/2 and H5Ovisit1 */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* test_h5o() */ - /*------------------------------------------------------------------------- * Function: cleanup_h5o * @@ -1788,4 +1808,3 @@ cleanup_h5o(void) { remove(TEST_FILENAME); } - diff --git a/test/th5s.c b/test/th5s.c index bb84353..7ce86ba 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -12,12 +12,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: th5s -* -* Test the dataspace functionality -* -*************************************************************/ + * + * Test program: th5s + * + * Test the dataspace functionality + * + *************************************************************/ #include "testhdf5.h" #include "H5srcdir.h" @@ -29,69 +29,69 @@ * This file needs to access private information from the H5S package. * This file also needs to access the dataspace testing code. */ -#define H5S_FRIEND /*suppress error about including H5Spkg */ -#define H5S_TESTING /*suppress warning about H5S testing funcs*/ -#include "H5Spkg.h" /* Dataspaces */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ +#define H5S_TESTING /*suppress warning about H5S testing funcs*/ +#include "H5Spkg.h" /* Dataspaces */ /* * This file needs to access private information from the H5O package. * This file also needs to access the dataspace testing code. */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ #define H5O_TESTING -#include "H5Opkg.h" /* Object header */ +#include "H5Opkg.h" /* Object header */ -#define TESTFILE "th5s.h5" -#define DATAFILE "th5s1.h5" -#define NULLFILE "th5s2.h5" -#define BASICFILE "th5s3.h5" -#define ZEROFILE "th5s4.h5" +#define TESTFILE "th5s.h5" +#define DATAFILE "th5s1.h5" +#define NULLFILE "th5s2.h5" +#define BASICFILE "th5s3.h5" +#define ZEROFILE "th5s4.h5" #define BASICDATASET "basic_dataset" #define BASICDATASET1 "basic_dataset1" #define BASICDATASET2 "basic_dataset2" #define BASICDATASET3 "basic_dataset3" #define BASICDATASET4 "basic_dataset4" -#define BASICATTR "basic_attribute" -#define NULLDATASET "null_dataset" -#define NULLATTR "null_attribute" -#define EXTFILE_NAME "ext_file" +#define BASICATTR "basic_attribute" +#define NULLDATASET "null_dataset" +#define NULLATTR "null_attribute" +#define EXTFILE_NAME "ext_file" /* 3-D dataset with fixed dimensions */ -#define SPACE1_RANK 3 -#define SPACE1_DIM1 3 -#define SPACE1_DIM2 15 -#define SPACE1_DIM3 13 +#define SPACE1_RANK 3 +#define SPACE1_DIM1 3 +#define SPACE1_DIM2 15 +#define SPACE1_DIM3 13 /* 4-D dataset with one unlimited dimension */ -#define SPACE2_RANK 4 -#define SPACE2_DIM1 0 -#define SPACE2_DIM2 15 -#define SPACE2_DIM3 13 -#define SPACE2_DIM4 23 -#define SPACE2_MAX1 H5S_UNLIMITED -#define SPACE2_MAX2 15 -#define SPACE2_MAX3 13 -#define SPACE2_MAX4 23 +#define SPACE2_RANK 4 +#define SPACE2_DIM1 0 +#define SPACE2_DIM2 15 +#define SPACE2_DIM3 13 +#define SPACE2_DIM4 23 +#define SPACE2_MAX1 H5S_UNLIMITED +#define SPACE2_MAX2 15 +#define SPACE2_MAX3 13 +#define SPACE2_MAX4 23 /* Scalar dataset with simple datatype */ -#define SPACE3_RANK 0 -unsigned space3_data=65; +#define SPACE3_RANK 0 +unsigned space3_data = 65; /* Scalar dataset with compound datatype */ -#define SPACE4_FIELDNAME1 "c1" -#define SPACE4_FIELDNAME2 "u" -#define SPACE4_FIELDNAME3 "f" -#define SPACE4_FIELDNAME4 "c2" -size_t space4_field1_off=0; -size_t space4_field2_off=0; -size_t space4_field3_off=0; -size_t space4_field4_off=0; +#define SPACE4_FIELDNAME1 "c1" +#define SPACE4_FIELDNAME2 "u" +#define SPACE4_FIELDNAME3 "f" +#define SPACE4_FIELDNAME4 "c2" +size_t space4_field1_off = 0; +size_t space4_field2_off = 0; +size_t space4_field3_off = 0; +size_t space4_field4_off = 0; struct space4_struct { - char c1; + char c1; unsigned u; - float f; - char c2; -} space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */ + float f; + char c2; +} space4_data = {'v', 987123, -3.14F, 'g'}; /* Test data for 4th dataspace */ /* * Testing configuration defines used by: @@ -99,13 +99,12 @@ struct space4_struct { * test_h5s_encode_irregular_hyper() * test_h5s_encode_points() */ -#define CONFIG_8 1 -#define CONFIG_16 2 -#define CONFIG_32 3 -#define POWER8 256 /* 2^8 */ -#define POWER16 65536 /* 2^16 */ -#define POWER32 4294967296 /* 2^32 */ - +#define CONFIG_8 1 +#define CONFIG_16 2 +#define CONFIG_32 3 +#define POWER8 256 /* 2^8 */ +#define POWER16 65536 /* 2^16 */ +#define POWER32 4294967296 /* 2^32 */ /**************************************************************** ** @@ -115,21 +114,19 @@ struct space4_struct { static void test_h5s_basic(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t sid1, sid2; /* Dataspace ID */ - hid_t dset1; /* Dataset ID */ - hid_t aid1; /* Attribute ID */ - int rank; /* Logical rank of dataspace */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, - SPACE2_DIM4}; - hsize_t dims3[H5S_MAX_RANK+1]; - hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, - SPACE2_MAX4}; - hsize_t tdims[4]; /* Dimension array to test with */ - hsize_t tmax[4]; - hssize_t n; /* Number of dataspace elements */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t sid1, sid2; /* Dataspace ID */ + hid_t dset1; /* Dataset ID */ + hid_t aid1; /* Attribute ID */ + int rank; /* Logical rank of dataspace */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}; + hsize_t dims3[H5S_MAX_RANK + 1]; + hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; + hsize_t tdims[4]; /* Dimension array to test with */ + hsize_t tmax[4]; + hssize_t n; /* Number of dataspace elements */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace Manipulation\n")); @@ -139,8 +136,7 @@ test_h5s_basic(void) n = H5Sget_simple_extent_npoints(sid1); CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); - VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, - "H5Sget_simple_extent_npoints"); + VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Sget_simple_extent_npoints"); rank = H5Sget_simple_extent_ndims(sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); @@ -148,16 +144,14 @@ test_h5s_basic(void) rank = H5Sget_simple_extent_dims(sid1, tdims, NULL); CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); - VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, - "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); sid2 = H5Screate_simple(SPACE2_RANK, dims2, max2); CHECK(sid2, FAIL, "H5Screate_simple"); n = H5Sget_simple_extent_npoints(sid2); CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); - VERIFY(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4, - "H5Sget_simple_extent_npoints"); + VERIFY(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4, "H5Sget_simple_extent_npoints"); rank = H5Sget_simple_extent_ndims(sid2); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); @@ -165,20 +159,16 @@ test_h5s_basic(void) rank = H5Sget_simple_extent_dims(sid2, tdims, tmax); CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); - VERIFY(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(hsize_t)), 0, - "H5Sget_simple_extent_dims"); - VERIFY(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(hsize_t)), 0, - "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); /* Change max dims to be equal to the dimensions */ ret = H5Sset_extent_simple(sid1, SPACE1_RANK, dims1, NULL); CHECK(ret, FAIL, "H5Sset_extent_simple"); rank = H5Sget_simple_extent_dims(sid1, tdims, tmax); CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); - VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, - "H5Sget_simple_extent_dims"); - VERIFY(HDmemcmp(tmax, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, - "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tmax, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); ret = H5Sclose(sid1); CHECK(ret, FAIL, "H5Sclose"); @@ -190,9 +180,11 @@ test_h5s_basic(void) * Check to be sure we can't create a simple dataspace that has too many * dimensions. */ - H5E_BEGIN_TRY { - sid1 = H5Screate_simple(H5S_MAX_RANK+1, dims3, NULL); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + sid1 = H5Screate_simple(H5S_MAX_RANK + 1, dims3, NULL); + } + H5E_END_TRY; VERIFY(sid1, FAIL, "H5Screate_simple"); /* @@ -203,30 +195,30 @@ test_h5s_basic(void) * the instructions in space_overflow.c for regenerating the th5s.h5 file. */ { - const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */ - - fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - CHECK_I(fid1, "H5Fopen"); - if (fid1 >= 0){ - dset1 = H5Dopen2(fid1, "dset", H5P_DEFAULT); - VERIFY(dset1, FAIL, "H5Dopen2"); - ret = H5Fclose(fid1); - CHECK_I(ret, "H5Fclose"); - } - else - HDprintf("***cannot open the pre-created H5S_MAX_RANK test file (%s)\n", testfile); + const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */ + + fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK_I(fid1, "H5Fopen"); + if (fid1 >= 0) { + dset1 = H5Dopen2(fid1, "dset", H5P_DEFAULT); + VERIFY(dset1, FAIL, "H5Dopen2"); + ret = H5Fclose(fid1); + CHECK_I(ret, "H5Fclose"); + } + else + HDprintf("***cannot open the pre-created H5S_MAX_RANK test file (%s)\n", testfile); } /* Verify that incorrect dimensions don't work */ dims1[0] = H5S_UNLIMITED; - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); VERIFY(sid1, FAIL, "H5Screate_simple"); dims1[0] = H5S_UNLIMITED; - sid1 = H5Screate(H5S_SIMPLE); + sid1 = H5Screate(H5S_SIMPLE); CHECK(sid1, FAIL, "H5Screate"); - ret = H5Sset_extent_simple(sid1,SPACE1_RANK,dims1,NULL); + ret = H5Sset_extent_simple(sid1, SPACE1_RANK, dims1, NULL); VERIFY(ret, FAIL, "H5Sset_extent_simple"); ret = H5Sclose(sid1); @@ -239,7 +231,7 @@ test_h5s_basic(void) fid1 = H5Fcreate(BASICFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fcreate"); - dims1[0]=SPACE1_DIM1; + dims1[0] = SPACE1_DIM1; sid1 = H5Screate(H5S_SIMPLE); CHECK(sid1, FAIL, "H5Screate"); @@ -247,62 +239,82 @@ test_h5s_basic(void) CHECK(sid2, FAIL, "H5Screate"); /* This dataset's space has no extent; it should not be created */ - H5E_BEGIN_TRY { - dset1 = H5Dcreate2(fid1, BASICDATASET, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY + H5E_BEGIN_TRY + { + dset1 = H5Dcreate2(fid1, BASICDATASET, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY VERIFY(dset1, FAIL, "H5Dcreate2"); dset1 = H5Dcreate2(fid1, BASICDATASET2, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset1, FAIL, "H5Dcreate2"); /* Try some writes with the bad dataspace (sid1) */ - H5E_BEGIN_TRY { - ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, &n); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, &n); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dwrite"); - H5E_BEGIN_TRY { - ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &n); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &n); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dwrite"); - H5E_BEGIN_TRY { - ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, sid1, H5P_DEFAULT, &n); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, sid1, H5P_DEFAULT, &n); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dwrite"); /* Try to iterate using the bad dataspace */ - H5E_BEGIN_TRY { - ret = H5Diterate(&n, H5T_NATIVE_INT, sid1, NULL, NULL); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Diterate(&n, H5T_NATIVE_INT, sid1, NULL, NULL); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Diterate"); /* Try to fill using the bad dataspace */ - H5E_BEGIN_TRY { - ret = H5Dfill(NULL, H5T_NATIVE_INT, &n, H5T_NATIVE_INT, sid1); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Dfill(NULL, H5T_NATIVE_INT, &n, H5T_NATIVE_INT, sid1); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dfill"); /* Now use the bad dataspace as the space for an attribute */ - H5E_BEGIN_TRY { - aid1 = H5Acreate2(dset1, BASICATTR, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY + H5E_BEGIN_TRY + { + aid1 = H5Acreate2(dset1, BASICATTR, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY VERIFY(aid1, FAIL, "H5Acreate2"); /* Make sure that dataspace reads using the bad dataspace fail */ - H5E_BEGIN_TRY { - ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, &n); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, &n); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dread"); - H5E_BEGIN_TRY { - ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &n); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &n); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dread"); - H5E_BEGIN_TRY { - ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, sid1, H5P_DEFAULT, &n); - } H5E_END_TRY + H5E_BEGIN_TRY + { + ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, sid1, H5P_DEFAULT, &n); + } + H5E_END_TRY VERIFY(ret, FAIL, "H5Dread"); /* Clean up */ @@ -314,7 +326,7 @@ test_h5s_basic(void) CHECK(ret, FAIL, "H5Sclose"); ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_basic() */ +} /* test_h5s_basic() */ /**************************************************************** ** @@ -324,20 +336,20 @@ test_h5s_basic(void) static void test_h5s_null(void) { - hid_t fid; /* File ID */ - hid_t sid; /* Dataspace IDs */ - hid_t dset_sid, dset_sid2; /* Dataspace IDs */ - hid_t attr_sid; /* Dataspace IDs */ - hid_t did; /* Dataset ID */ - hid_t attr; /*Attribute ID */ - H5S_class_t stype; /* dataspace type */ - hssize_t nelem; /* Number of elements */ - unsigned uval=2; /* Buffer for writing to dataset */ - int val=1; /* Buffer for writing to attribute */ - H5S_sel_type sel_type; /* Type of selection currently */ - hsize_t dims[1]={10}; /* Dimensions for converting null dataspace to simple */ - H5S_class_t space_type; /* Type of dataspace */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t sid; /* Dataspace IDs */ + hid_t dset_sid, dset_sid2; /* Dataspace IDs */ + hid_t attr_sid; /* Dataspace IDs */ + hid_t did; /* Dataset ID */ + hid_t attr; /*Attribute ID */ + H5S_class_t stype; /* dataspace type */ + hssize_t nelem; /* Number of elements */ + unsigned uval = 2; /* Buffer for writing to dataset */ + int val = 1; /* Buffer for writing to attribute */ + H5S_sel_type sel_type; /* Type of selection currently */ + hsize_t dims[1] = {10}; /* Dimensions for converting null dataspace to simple */ + H5S_class_t space_type; /* Type of dataspace */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Null Dataspace\n")); @@ -370,21 +382,25 @@ test_h5s_null(void) VERIFY(nelem, 0, "H5Sget_select_npoints"); /* Check to be sure we can't set a hyperslab selection on a null dataspace */ - H5E_BEGIN_TRY { - hsize_t start[1]={0}; - hsize_t count[1]={0}; + H5E_BEGIN_TRY + { + hsize_t start[1] = {0}; + hsize_t count[1] = {0}; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL); - } H5E_END_TRY; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sselect_hyperslab"); /* Check to be sure we can't set a point selection on a null dataspace */ - H5E_BEGIN_TRY { - hsize_t coord[1][1]; /* Coordinates for point selection */ + H5E_BEGIN_TRY + { + hsize_t coord[1][1]; /* Coordinates for point selection */ - coord[0][0]=0; - ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord); - } H5E_END_TRY; + coord[0][0] = 0; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sselect_elements"); /* Create first dataset */ @@ -432,7 +448,7 @@ test_h5s_null(void) VERIFY(uval, 2, "H5Aread"); /* Close attribute */ - ret=H5Aclose(attr); + ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); /* Close the dataset */ @@ -524,7 +540,7 @@ test_h5s_null(void) VERIFY(val, 1, "H5Aread"); /* Close attribute */ - ret=H5Aclose(attr); + ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); /* Close the dataset */ @@ -544,61 +560,61 @@ test_h5s_null(void) static void test_h5s_zero_dim(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t sid1, attr_sid; /* Dataspace ID */ - hid_t sid_chunk; /* Dataspace ID for chunked dataset */ - hid_t dset1; /* Dataset ID */ - hid_t plist_id; /* Dataset creation property list */ - hid_t attr; /* Attribute ID */ - int rank; /* Logical rank of dataspace */ - hsize_t dims1[] = {0, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t max_dims[] = {SPACE1_DIM1+1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t extend_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t chunk_dims[] = {SPACE1_DIM1, SPACE1_DIM2/3, SPACE1_DIM3}; - hsize_t tdims[SPACE1_RANK]; /* Dimension array to test with */ - int wdata[SPACE1_DIM2][SPACE1_DIM3]; - int rdata[SPACE1_DIM2][SPACE1_DIM3]; - short wdata_short[SPACE1_DIM2][SPACE1_DIM3]; - short rdata_short[SPACE1_DIM2][SPACE1_DIM3]; - int wdata_real[SPACE1_DIM1][SPACE1_DIM2][SPACE1_DIM3]; - int rdata_real[SPACE1_DIM1][SPACE1_DIM2][SPACE1_DIM3]; - int val = 3; - hsize_t start[] = {0, 0, 0}; - hsize_t count[] = {3, 15, 13}; - hsize_t coord[1][3]; /* Coordinates for point selection */ - hssize_t nelem; /* Number of elements */ - H5S_sel_type sel_type; /* Type of selection currently */ - H5S_class_t stype; /* dataspace type */ - H5D_alloc_time_t alloc_time; /* Space allocation time */ - herr_t ret; /* Generic return value */ - unsigned int i, j, k; + hid_t fid1; /* HDF5 File IDs */ + hid_t sid1, attr_sid; /* Dataspace ID */ + hid_t sid_chunk; /* Dataspace ID for chunked dataset */ + hid_t dset1; /* Dataset ID */ + hid_t plist_id; /* Dataset creation property list */ + hid_t attr; /* Attribute ID */ + int rank; /* Logical rank of dataspace */ + hsize_t dims1[] = {0, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t max_dims[] = {SPACE1_DIM1 + 1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t extend_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t chunk_dims[] = {SPACE1_DIM1, SPACE1_DIM2 / 3, SPACE1_DIM3}; + hsize_t tdims[SPACE1_RANK]; /* Dimension array to test with */ + int wdata[SPACE1_DIM2][SPACE1_DIM3]; + int rdata[SPACE1_DIM2][SPACE1_DIM3]; + short wdata_short[SPACE1_DIM2][SPACE1_DIM3]; + short rdata_short[SPACE1_DIM2][SPACE1_DIM3]; + int wdata_real[SPACE1_DIM1][SPACE1_DIM2][SPACE1_DIM3]; + int rdata_real[SPACE1_DIM1][SPACE1_DIM2][SPACE1_DIM3]; + int val = 3; + hsize_t start[] = {0, 0, 0}; + hsize_t count[] = {3, 15, 13}; + hsize_t coord[1][3]; /* Coordinates for point selection */ + hssize_t nelem; /* Number of elements */ + H5S_sel_type sel_type; /* Type of selection currently */ + H5S_class_t stype; /* dataspace type */ + H5D_alloc_time_t alloc_time; /* Space allocation time */ + herr_t ret; /* Generic return value */ + unsigned int i, j, k; /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace with zero dimension size\n")); /* Initialize the data */ - for(i = 0; i < SPACE1_DIM2; i++) - for(j = 0; j < SPACE1_DIM3; j++) { - wdata[i][j] = (int)(i + j); - rdata[i][j] = 7; + for (i = 0; i < SPACE1_DIM2; i++) + for (j = 0; j < SPACE1_DIM3; j++) { + wdata[i][j] = (int)(i + j); + rdata[i][j] = 7; wdata_short[i][j] = (short)(i + j); rdata_short[i][j] = 7; } - for(i = 0; i < SPACE1_DIM1; i++) - for(j = 0; j < SPACE1_DIM2; j++) - for(k = 0; k < SPACE1_DIM3; k++) + for (i = 0; i < SPACE1_DIM1; i++) + for (j = 0; j < SPACE1_DIM2; j++) + for (k = 0; k < SPACE1_DIM3; k++) wdata_real[i][j][k] = (int)(i + j + k); /* Test with different space allocation times */ - for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + for (alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { /* Make sure we can create the space with the dimension size 0 (starting from v1.8.7). * The dimension doesn't need to be unlimited. */ dims1[0] = 0; dims1[1] = SPACE1_DIM2; dims1[2] = SPACE1_DIM3; - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); ret = H5Sclose(sid1); @@ -609,7 +625,7 @@ test_h5s_zero_dim(void) /* SID1 has the 1st dimension size as zero. The maximal dimension will be * the same as the dimension because of the NULL passed in. */ - ret = H5Sset_extent_simple(sid1,SPACE1_RANK,dims1,NULL); + ret = H5Sset_extent_simple(sid1, SPACE1_RANK, dims1, NULL); CHECK(ret, FAIL, "H5Sset_extent_simple"); /* Check that the dataspace actually has 0 elements */ @@ -679,12 +695,11 @@ test_h5s_zero_dim(void) CHECK(ret, FAIL, "H5Dread"); /* Check results */ - for(i=0; i0) { - sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + if (sbuf_size > 0) { + sbuf = (unsigned char *)HDcalloc((size_t)1, sbuf_size); CHECK(sbuf, NULL, "HDcalloc"); } /* Try decoding bogus buffer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret_id = H5Sdecode(sbuf); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret_id, FAIL, "H5Sdecode"); /* Encode the simple dataspace in a buffer with the fapl setting */ @@ -1247,25 +1262,23 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "H5Sencode"); /* Decode from the dataspace buffer and return an object handle */ - decoded_sid1=H5Sdecode(sbuf); + decoded_sid1 = H5Sdecode(sbuf); CHECK(decoded_sid1, FAIL, "H5Sdecode"); /* Verify the decoded dataspace */ n = H5Sget_simple_extent_npoints(decoded_sid1); CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); - VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, - "H5Sget_simple_extent_npoints"); + VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Sget_simple_extent_npoints"); /* Retrieve and verify the dataspace rank */ rank = H5Sget_simple_extent_ndims(decoded_sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); - /* Retrieve and verify the dataspace dimensions */ + /* Retrieve and verify the dataspace dimensions */ rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL); CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); - VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, - "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); /* Verify the type of dataspace selection */ sel_type = H5Sget_select_type(decoded_sid1); @@ -1273,7 +1286,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) /* Verify the number of hyperslab blocks */ nblocks = H5Sget_select_hyper_nblocks(decoded_sid1); - VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks"); + VERIFY(nblocks, 2 * 2 * 2, "H5Sget_select_hyper_nblocks"); /* Close the dataspaces */ ret = H5Sclose(sid1); @@ -1293,8 +1306,8 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) ret = H5Sencode2(sid2, NULL, &null_size, fapl); CHECK(ret, FAIL, "H5Sencode"); - if(null_size>0) { - null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size); + if (null_size > 0) { + null_sbuf = (unsigned char *)HDcalloc((size_t)1, null_size); CHECK(null_sbuf, NULL, "HDcalloc"); } @@ -1303,7 +1316,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "H5Sencode2"); /* Decode from the dataspace buffer and return an object handle */ - decoded_sid2=H5Sdecode(null_sbuf); + decoded_sid2 = H5Sdecode(null_sbuf); CHECK(decoded_sid2, FAIL, "H5Sdecode"); /* Verify the decoded dataspace type */ @@ -1329,8 +1342,8 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) ret = H5Sencode2(sid3, NULL, &scalar_size, fapl); CHECK(ret, FAIL, "H5Sencode"); - if(scalar_size>0) { - scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size); + if (scalar_size > 0) { + scalar_buf = (unsigned char *)HDcalloc((size_t)1, scalar_size); CHECK(scalar_buf, NULL, "HDcalloc"); } @@ -1339,7 +1352,7 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "H5Sencode2"); /* Decode from the dataspace buffer and return an object handle */ - decoded_sid3=H5Sdecode(scalar_buf); + decoded_sid3 = H5Sdecode(scalar_buf); CHECK(decoded_sid3, FAIL, "H5Sdecode"); /* Verify extent type */ @@ -1363,16 +1376,16 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) ret = H5Sclose(decoded_sid3); CHECK(ret, FAIL, "H5Sclose"); - /* Close the file access property list */ + /* Close the file access property list */ ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); /* Release resources */ - if(sbuf) + if (sbuf) HDfree(sbuf); - if(null_sbuf) + if (null_sbuf) HDfree(null_sbuf); - if(scalar_buf) + if (scalar_buf) HDfree(scalar_buf); } /* test_h5s_encode() */ @@ -1386,23 +1399,23 @@ test_h5s_encode(H5F_libver_t low, H5F_libver_t high) static void test_h5s_encode1(void) { - hid_t sid1, sid2, sid3; /* Dataspace ID */ - hid_t decoded_sid1, decoded_sid2, decoded_sid3; - int rank; /* Logical rank of dataspace */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - size_t sbuf_size=0, null_size=0, scalar_size=0; - unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - hsize_t start[] = {0, 0, 0}; - hsize_t stride[] = {2, 5, 3}; - hsize_t count[] = {2, 2, 2}; - hsize_t block[] = {1, 3, 1}; - H5S_sel_type sel_type; - H5S_class_t space_type; - hssize_t nblocks; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t sid1, sid2, sid3; /* Dataspace ID */ + hid_t decoded_sid1, decoded_sid2, decoded_sid3; + int rank; /* Logical rank of dataspace */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + size_t sbuf_size = 0, null_size = 0, scalar_size = 0; + unsigned char *sbuf = NULL, *null_sbuf = NULL, *scalar_buf = NULL; + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + hsize_t start[] = {0, 0, 0}; + hsize_t stride[] = {2, 5, 3}; + hsize_t count[] = {2, 2, 2}; + hsize_t block[] = {1, 3, 1}; + H5S_sel_type sel_type; + H5S_class_t space_type; + hssize_t nblocks; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace Encoding (H5Sencode1) and Decoding\n")); @@ -1423,15 +1436,17 @@ test_h5s_encode1(void) ret = H5Sencode1(sid1, NULL, &sbuf_size); CHECK(ret, FAIL, "H5Sencode2"); - if(sbuf_size>0) { - sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + if (sbuf_size > 0) { + sbuf = (unsigned char *)HDcalloc((size_t)1, sbuf_size); CHECK(sbuf, NULL, "HDcalloc"); } /* Try decoding bogus buffer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret_id = H5Sdecode(sbuf); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret_id, FAIL, "H5Sdecode"); /* Encode the simple dataspace in a buffer */ @@ -1439,25 +1454,23 @@ test_h5s_encode1(void) CHECK(ret, FAIL, "H5Sencode"); /* Decode from the dataspace buffer and return an object handle */ - decoded_sid1=H5Sdecode(sbuf); + decoded_sid1 = H5Sdecode(sbuf); CHECK(decoded_sid1, FAIL, "H5Sdecode"); /* Verify the decoded dataspace */ n = H5Sget_simple_extent_npoints(decoded_sid1); CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); - VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, - "H5Sget_simple_extent_npoints"); + VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Sget_simple_extent_npoints"); /* Retrieve and verify the dataspace rank */ rank = H5Sget_simple_extent_ndims(decoded_sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); - /* Retrieve and verify the dataspace dimensions */ + /* Retrieve and verify the dataspace dimensions */ rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL); CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); - VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, - "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); /* Verify the type of dataspace selection */ sel_type = H5Sget_select_type(decoded_sid1); @@ -1465,7 +1478,7 @@ test_h5s_encode1(void) /* Verify the number of hyperslab blocks */ nblocks = H5Sget_select_hyper_nblocks(decoded_sid1); - VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks"); + VERIFY(nblocks, 2 * 2 * 2, "H5Sget_select_hyper_nblocks"); /* Close the dataspaces */ ret = H5Sclose(sid1); @@ -1485,8 +1498,8 @@ test_h5s_encode1(void) ret = H5Sencode1(sid2, NULL, &null_size); CHECK(ret, FAIL, "H5Sencode"); - if(null_size>0) { - null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size); + if (null_size > 0) { + null_sbuf = (unsigned char *)HDcalloc((size_t)1, null_size); CHECK(null_sbuf, NULL, "HDcalloc"); } @@ -1495,7 +1508,7 @@ test_h5s_encode1(void) CHECK(ret, FAIL, "H5Sencode2"); /* Decode from the dataspace buffer and return an object handle */ - decoded_sid2=H5Sdecode(null_sbuf); + decoded_sid2 = H5Sdecode(null_sbuf); CHECK(decoded_sid2, FAIL, "H5Sdecode"); /* Verify the decoded dataspace type */ @@ -1521,8 +1534,8 @@ test_h5s_encode1(void) ret = H5Sencode1(sid3, NULL, &scalar_size); CHECK(ret, FAIL, "H5Sencode"); - if(scalar_size>0) { - scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size); + if (scalar_size > 0) { + scalar_buf = (unsigned char *)HDcalloc((size_t)1, scalar_size); CHECK(scalar_buf, NULL, "HDcalloc"); } @@ -1531,7 +1544,7 @@ test_h5s_encode1(void) CHECK(ret, FAIL, "H5Sencode2"); /* Decode from the dataspace buffer and return an object handle */ - decoded_sid3=H5Sdecode(scalar_buf); + decoded_sid3 = H5Sdecode(scalar_buf); CHECK(decoded_sid3, FAIL, "H5Sdecode"); /* Verify extent type */ @@ -1556,17 +1569,16 @@ test_h5s_encode1(void) CHECK(ret, FAIL, "H5Sclose"); /* Release resources */ - if(sbuf) + if (sbuf) HDfree(sbuf); - if(null_sbuf) + if (null_sbuf) HDfree(null_sbuf); - if(scalar_buf) + if (scalar_buf) HDfree(scalar_buf); } /* test_h5s_encode1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /**************************************************************** ** ** test_h5s_check_encoding(): @@ -1582,27 +1594,30 @@ test_h5s_encode1(void) ** ****************************************************************/ static herr_t -test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, - uint32_t expected_version, uint8_t expected_enc_size, hbool_t expected_to_fail) +test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, uint32_t expected_version, uint8_t expected_enc_size, + hbool_t expected_to_fail) { - char *buf = NULL; /* Pointer to the encoded buffer */ - size_t buf_size; /* Size of the encoded buffer */ - hid_t d_sid = -1; /* The decoded dataspace ID */ - htri_t check; - hsize_t in_low_bounds[1]; /* The low bounds for the selection for in_sid */ - hsize_t in_high_bounds[1]; /* The high bounds for the selection for in_sid */ - hsize_t d_low_bounds[1]; /* The low bounds for the selection for d_sid */ - hsize_t d_high_bounds[1]; /* The high bounds for the selection for d_sid */ - herr_t ret; /* Return value */ + char * buf = NULL; /* Pointer to the encoded buffer */ + size_t buf_size; /* Size of the encoded buffer */ + hid_t d_sid = -1; /* The decoded dataspace ID */ + htri_t check; + hsize_t in_low_bounds[1]; /* The low bounds for the selection for in_sid */ + hsize_t in_high_bounds[1]; /* The high bounds for the selection for in_sid */ + hsize_t d_low_bounds[1]; /* The low bounds for the selection for d_sid */ + hsize_t d_high_bounds[1]; /* The high bounds for the selection for d_sid */ + herr_t ret; /* Return value */ /* Get buffer size for encoding with the format setting in in_fapl */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sencode2(in_sid, NULL, &buf_size, in_fapl); - } H5E_END_TRY + } + H5E_END_TRY - if(expected_to_fail) { + if (expected_to_fail) { VERIFY(ret, FAIL, "H5Screate_simple"); - } else { + } + else { CHECK(ret, FAIL, "H5Sencode2"); @@ -1643,35 +1658,34 @@ test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, * --the expected encoded size (version 3 hyperslab selection info) */ - if(H5Sget_select_type(in_sid) == H5S_SEL_POINTS) { + if (H5Sget_select_type(in_sid) == H5S_SEL_POINTS) { /* Verify the version */ VERIFY((uint32_t)buf[35], expected_version, "Version for point selection"); /* Verify the encoded size for version 2 */ - if(expected_version == 2) + if (expected_version == 2) VERIFY((uint8_t)buf[39], expected_enc_size, "Encoded size of point selection info"); } - if(H5Sget_select_type(in_sid) == H5S_SEL_HYPERSLABS) { + if (H5Sget_select_type(in_sid) == H5S_SEL_HYPERSLABS) { /* Verify the version */ VERIFY((uint32_t)buf[35], expected_version, "Version for hyperslab selection info"); /* Verify the encoded size for version 3 */ - if(expected_version == 3) + if (expected_version == 3) VERIFY((uint8_t)buf[40], expected_enc_size, "Encoded size of selection info"); } /* hyperslab selection */ ret = H5Sclose(d_sid); CHECK(ret, FAIL, "H5Sclose"); - if(buf) + if (buf) HDfree(buf); - } - return(0); + return (0); } /* test_h5s_check_encoding */ @@ -1686,18 +1700,18 @@ test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, static void test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) { - hid_t fapl = -1; /* File access property list ID */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t numparticles = 8388608; /* Used to calculate dimension size */ - unsigned num_dsets = 513; /* Used to calculate dimension size */ - hsize_t total_particles = numparticles * num_dsets; - hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ - hsize_t start, stride, count, block; /* Selection info */ - unsigned config; /* Testing configuration */ - unsigned unlim; /* H5S_UNLIMITED setting or not */ - herr_t ret; /* Generic return value */ - uint32_t expected_version = 0; /* Expected version for selection info */ - uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimension size */ + unsigned num_dsets = 513; /* Used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t start, stride, count, block; /* Selection info */ + unsigned config; /* Testing configuration */ + unsigned unlim; /* H5S_UNLIMITED setting or not */ + herr_t ret; /* Generic return value */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace encoding of regular hyperslabs\n")); @@ -1715,35 +1729,34 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) CHECK(sid, FAIL, "H5Screate_simple"); /* Testing with each configuration */ - for(config = CONFIG_16; config <= CONFIG_32; config++) { + for (config = CONFIG_16; config <= CONFIG_32; config++) { hbool_t expected_to_fail = FALSE; /* Testing with unlimited or not */ - for(unlim = 0; unlim <= 1; unlim++) { + for (unlim = 0; unlim <= 1; unlim++) { start = 0; - count = unlim? H5S_UNLIMITED : 2; + count = unlim ? H5S_UNLIMITED : 2; - if((high <= H5F_LIBVER_V18) && - (unlim || config == CONFIG_32)) + if ((high <= H5F_LIBVER_V18) && (unlim || config == CONFIG_32)) expected_to_fail = TRUE; - if(low >= H5F_LIBVER_V112) + if (low >= H5F_LIBVER_V112) expected_version = 3; - else if(config == CONFIG_16 && !unlim) + else if (config == CONFIG_16 && !unlim) expected_version = 1; else expected_version = 2; /* test 1 */ - switch(config) { + switch (config) { case CONFIG_16: - stride = POWER16 - 1; - block = 4; + stride = POWER16 - 1; + block = 4; expected_enc_size = (uint8_t)(expected_version == 3 ? 2 : 4); break; case CONFIG_32: - stride = POWER32 - 1; - block = 4; + stride = POWER32 - 1; + block = 4; expected_enc_size = (uint8_t)(expected_version == 3 ? 4 : 8); break; @@ -1761,15 +1774,15 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "test_h5s_check_encoding"); /* test 2 */ - switch(config) { + switch (config) { case CONFIG_16: - stride = POWER16 - 1; - block = POWER16 - 2; + stride = POWER16 - 1; + block = POWER16 - 2; expected_enc_size = (uint8_t)(expected_version == 3 ? 2 : 4); break; case CONFIG_32: - stride = POWER32 - 1; - block = POWER32 - 2; + stride = POWER32 - 1; + block = POWER32 - 2; expected_enc_size = (uint8_t)(expected_version == 3 ? 4 : 8); break; default: @@ -1786,15 +1799,15 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "test_h5s_check_encoding"); /* test 3 */ - switch(config) { + switch (config) { case CONFIG_16: - stride = POWER16 - 1; - block = POWER16 - 1; + stride = POWER16 - 1; + block = POWER16 - 1; expected_enc_size = 4; break; case CONFIG_32: - stride = POWER32 - 1; - block = POWER32 - 1; + stride = POWER32 - 1; + block = POWER32 - 1; expected_enc_size = 8; break; default: @@ -1811,15 +1824,15 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "test_h5s_check_encoding"); /* test 4 */ - switch(config) { + switch (config) { case CONFIG_16: - stride = POWER16; - block = POWER16 - 2; + stride = POWER16; + block = POWER16 - 2; expected_enc_size = 4; break; case CONFIG_32: - stride = POWER32; - block = POWER32 - 2; + stride = POWER32; + block = POWER32 - 2; expected_enc_size = 8; break; default: @@ -1836,15 +1849,15 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "test_h5s_check_encoding"); /* test 5 */ - switch(config) { + switch (config) { case CONFIG_16: - stride = POWER16; - block = 1; + stride = POWER16; + block = 1; expected_enc_size = 4; break; case CONFIG_32: - stride = POWER32; - block = 1; + stride = POWER32; + block = 1; expected_enc_size = 8; break; default: @@ -1861,7 +1874,7 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "test_h5s_check_encoding"); } /* for unlim */ - } /* for config */ + } /* for config */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); @@ -1882,16 +1895,16 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) static void test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) { - hid_t fapl = -1; /* File access property list ID */ - hid_t sid; /* Dataspace ID */ - hsize_t numparticles = 8388608; /* Used to calculate dimension size */ - unsigned num_dsets = 513; /* Used to calculate dimension size */ - hsize_t total_particles = numparticles * num_dsets; - hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ - hsize_t start, stride, count, block; /* Selection info */ - htri_t is_regular; /* Is this a regular hyperslab */ - unsigned config; /* Testing configuration */ - herr_t ret; /* Generic return value */ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimension size */ + unsigned num_dsets = 513; /* Used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t start, stride, count, block; /* Selection info */ + htri_t is_regular; /* Is this a regular hyperslab */ + unsigned config; /* Testing configuration */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace encoding of irregular hyperslabs\n")); @@ -1909,9 +1922,9 @@ test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) CHECK(sid, FAIL, "H5Screate_simple"); /* Testing with each configuration */ - for(config = CONFIG_8; config <= CONFIG_32; config++) { - hbool_t expected_to_fail = FALSE; /* Whether H5Sencode2 is expected to fail */ - uint32_t expected_version = 0; /* Expected version for selection info */ + for (config = CONFIG_8; config <= CONFIG_32; config++) { + hbool_t expected_to_fail = FALSE; /* Whether H5Sencode2 is expected to fail */ + uint32_t expected_version = 0; /* Expected version for selection info */ uint32_t expected_enc_size = 0; /* Expected encoded size for selection info */ start = 0; @@ -1920,15 +1933,15 @@ test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) /* H5Sencode2 is expected to fail for library v110 and below when the selection exceeds the 32 bits integer limit */ - if(high <= H5F_LIBVER_V110 && config == CONFIG_32) + if (high <= H5F_LIBVER_V110 && config == CONFIG_32) expected_to_fail = TRUE; - if(low >= H5F_LIBVER_V112 || config == CONFIG_32) + if (low >= H5F_LIBVER_V112 || config == CONFIG_32) expected_version = 3; else expected_version = 1; - switch(config) { + switch (config) { case CONFIG_8: stride = POWER8 - 2; break; @@ -1954,19 +1967,19 @@ test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) count = 5; block = 2; - switch(config) { + switch (config) { case CONFIG_8: - stride = POWER8; + stride = POWER8; expected_enc_size = expected_version == 3 ? 2 : 4; break; case CONFIG_16: - stride = POWER16; + stride = POWER16; expected_enc_size = 4; break; case CONFIG_32: - stride = POWER32; + stride = POWER32; expected_enc_size = 8; break; @@ -1985,7 +1998,8 @@ test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) /* Verify the version and encoded size expected for the configuration */ HDassert(expected_enc_size <= 255); - ret = test_h5s_check_encoding(fapl, sid, expected_version, (uint8_t)expected_enc_size, expected_to_fail); + ret = test_h5s_check_encoding(fapl, sid, expected_version, (uint8_t)expected_enc_size, + expected_to_fail); CHECK(ret, FAIL, "test_h5s_check_encoding"); } /* for config */ @@ -2006,17 +2020,17 @@ test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) static void test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) { - hid_t fapl = -1; /* File access property list ID */ - hid_t sid; /* Dataspace ID */ - hsize_t numparticles = 8388608; /* Used to calculate dimenion size */ - unsigned num_dsets = 513; /* used to calculate dimension size */ - hsize_t total_particles = numparticles * num_dsets; - hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ - hsize_t coord[4]; /* The point coordinates */ - herr_t ret; /* Generic return value */ - hbool_t expected_to_fail = FALSE; /* Expected to fail or not */ - uint32_t expected_version = 0; /* Expected version for selection info */ - uint8_t expected_enc_size = 0; /* Expected encoded size of selection info */ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimenion size */ + unsigned num_dsets = 513; /* used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t coord[4]; /* The point coordinates */ + herr_t ret; /* Generic return value */ + hbool_t expected_to_fail = FALSE; /* Expected to fail or not */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size of selection info */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace encoding of points selection\n")); @@ -2038,14 +2052,14 @@ test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) coord[1] = 15; coord[2] = POWER16; coord[3] = 19; - ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); CHECK(ret, FAIL, "H5Sselect_elements"); - expected_to_fail = FALSE; + expected_to_fail = FALSE; expected_enc_size = 4; - expected_version = 1; + expected_version = 1; - if(low >= H5F_LIBVER_V112) + if (low >= H5F_LIBVER_V112) expected_version = 2; /* Verify the version and encoded size expected for the configuration */ @@ -2057,7 +2071,7 @@ test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) coord[1] = 15; coord[2] = POWER32 - 1; coord[3] = 19; - ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); CHECK(ret, FAIL, "H5Sselect_elements"); /* Expected result same as test 1 */ @@ -2065,11 +2079,11 @@ test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) CHECK(ret, FAIL, "test_h5s_check_encoding"); /* test 3 */ - if(high <= H5F_LIBVER_V110) + if (high <= H5F_LIBVER_V110) expected_to_fail = TRUE; - if(high >= H5F_LIBVER_V112) { - expected_version = 2; + if (high >= H5F_LIBVER_V112) { + expected_version = 2; expected_enc_size = 8; } @@ -2077,7 +2091,7 @@ test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) coord[1] = 15; coord[2] = POWER32 + 1; coord[3] = 19; - ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); CHECK(ret, FAIL, "H5Sselect_elements"); /* Verify the version and encoded size expected for the configuration */ @@ -2103,13 +2117,13 @@ test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) static void test_h5s_encode_length(void) { - hid_t sid; /* Dataspace ID */ - hid_t decoded_sid; /* Dataspace ID from H5Sdecode2 */ - size_t sbuf_size=0; /* Buffer size for H5Sencode2/1 */ - unsigned char *sbuf=NULL; /* Buffer for H5Sencode2/1 */ - hsize_t dims[1] = {500}; /* Dimension size */ - hsize_t start, count, block, stride; /* Hyperslab selection specifications */ - herr_t ret; /* Generic return value */ + hid_t sid; /* Dataspace ID */ + hid_t decoded_sid; /* Dataspace ID from H5Sdecode2 */ + size_t sbuf_size = 0; /* Buffer size for H5Sencode2/1 */ + unsigned char *sbuf = NULL; /* Buffer for H5Sencode2/1 */ + hsize_t dims[1] = {500}; /* Dimension size */ + hsize_t start, count, block, stride; /* Hyperslab selection specifications */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Version 2 Hyperslab Encoding Length is correct\n")); @@ -2119,10 +2133,10 @@ test_h5s_encode_length(void) CHECK(sid, FAIL, "H5Screate_simple"); /* Setting H5S_UNLIMITED in count will use version 2 for hyperslab encoding */ - start = 0; + start = 0; stride = 10; - block = 4; - count = H5S_UNLIMITED; + block = 4; + count = H5S_UNLIMITED; /* Set hyperslab selection */ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); @@ -2133,8 +2147,8 @@ test_h5s_encode_length(void) CHECK(ret, FAIL, "H5Sencode"); /* Allocate the buffer */ - if(sbuf_size > 0) { - sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + if (sbuf_size > 0) { + sbuf = (unsigned char *)HDcalloc((size_t)1, sbuf_size); CHECK(sbuf, NULL, "H5Sencode2"); } @@ -2158,7 +2172,7 @@ test_h5s_encode_length(void) CHECK(ret, FAIL, "H5Sclose"); /* Free the buffer */ - if(sbuf) + if (sbuf) HDfree(sbuf); /* Close the original dataspace */ @@ -2175,14 +2189,14 @@ test_h5s_encode_length(void) static void test_h5s_scalar_write(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - int rank; /* Logical rank of dataspace */ - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - H5S_class_t ext_type; /* Extent type */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + int rank; /* Logical rank of dataspace */ + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + H5S_class_t ext_type; /* Extent type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Scalar Dataspace Manipulation during Writing\n")); @@ -2192,9 +2206,11 @@ test_h5s_scalar_write(void) CHECK(fid1, FAIL, "H5Fcreate"); /* Verify a non-zero rank fails with a NULL dimension. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { sid1 = H5Screate_simple(SPACE1_RANK, NULL, NULL); - } H5E_END_TRY + } + H5E_END_TRY VERIFY(sid1, FAIL, "H5Screate_simple"); /* Create scalar dataspace */ @@ -2238,7 +2254,7 @@ test_h5s_scalar_write(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_scalar_write() */ +} /* test_h5s_scalar_write() */ /**************************************************************** ** @@ -2248,15 +2264,15 @@ test_h5s_scalar_write(void) static void test_h5s_scalar_read(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - int rank; /* Logical rank of dataspace */ - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - unsigned rdata; /* Scalar data read in */ - herr_t ret; /* Generic return value */ - H5S_class_t ext_type; /* Extent type */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + int rank; /* Logical rank of dataspace */ + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + unsigned rdata; /* Scalar data read in */ + herr_t ret; /* Generic return value */ + H5S_class_t ext_type; /* Extent type */ /* Output message about test being performed */ MESSAGE(5, ("Testing Scalar Dataspace Manipulation during Reading\n")); @@ -2302,7 +2318,7 @@ test_h5s_scalar_read(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_scalar_read() */ +} /* test_h5s_scalar_read() */ /**************************************************************** ** @@ -2313,14 +2329,14 @@ test_h5s_scalar_read(void) static void test_h5s_compound_scalar_write(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t tid1; /* Attribute datatype ID */ - hid_t sid1; /* Dataspace ID */ - int rank; /* Logical rank of dataspace */ - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t tid1; /* Attribute datatype ID */ + hid_t sid1; /* Dataspace ID */ + int rank; /* Logical rank of dataspace */ + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Scalar Dataspace Manipulation for Writing Compound Datatypes\n")); @@ -2330,23 +2346,19 @@ test_h5s_compound_scalar_write(void) CHECK(fid1, FAIL, "H5Fcreate"); /* Create the compound datatype. */ - tid1 = H5Tcreate (H5T_COMPOUND, sizeof(struct space4_struct)); + tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct space4_struct)); CHECK(tid1, FAIL, "H5Tcreate"); - space4_field1_off=HOFFSET(struct space4_struct, c1); - ret = H5Tinsert(tid1, SPACE4_FIELDNAME1, space4_field1_off, - H5T_NATIVE_SCHAR); + space4_field1_off = HOFFSET(struct space4_struct, c1); + ret = H5Tinsert(tid1, SPACE4_FIELDNAME1, space4_field1_off, H5T_NATIVE_SCHAR); CHECK(ret, FAIL, "H5Tinsert"); - space4_field2_off=HOFFSET(struct space4_struct, u); - ret = H5Tinsert(tid1, SPACE4_FIELDNAME2, space4_field2_off, - H5T_NATIVE_UINT); + space4_field2_off = HOFFSET(struct space4_struct, u); + ret = H5Tinsert(tid1, SPACE4_FIELDNAME2, space4_field2_off, H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); - space4_field3_off=HOFFSET(struct space4_struct, f); - ret = H5Tinsert(tid1, SPACE4_FIELDNAME3, space4_field3_off, - H5T_NATIVE_FLOAT); + space4_field3_off = HOFFSET(struct space4_struct, f); + ret = H5Tinsert(tid1, SPACE4_FIELDNAME3, space4_field3_off, H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); - space4_field4_off=HOFFSET(struct space4_struct, c2); - ret = H5Tinsert(tid1, SPACE4_FIELDNAME4, space4_field4_off, - H5T_NATIVE_SCHAR); + space4_field4_off = HOFFSET(struct space4_struct, c2); + ret = H5Tinsert(tid1, SPACE4_FIELDNAME4, space4_field4_off, H5T_NATIVE_SCHAR); CHECK(ret, FAIL, "H5Tinsert"); /* Create scalar dataspace */ @@ -2386,7 +2398,7 @@ test_h5s_compound_scalar_write(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_compound_scalar_write() */ +} /* test_h5s_compound_scalar_write() */ /**************************************************************** ** @@ -2397,15 +2409,15 @@ test_h5s_compound_scalar_write(void) static void test_h5s_compound_scalar_read(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t type; /* Datatype */ - int rank; /* Logical rank of dataspace */ - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - struct space4_struct rdata; /* Scalar data read in */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t type; /* Datatype */ + int rank; /* Logical rank of dataspace */ + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + struct space4_struct rdata; /* Scalar data read in */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Scalar Dataspace Manipulation for Reading Compound Datatypes\n")); @@ -2432,17 +2444,19 @@ test_h5s_compound_scalar_read(void) rank = H5Sget_simple_extent_dims(sid1, tdims, NULL); VERIFY(rank, 0, "H5Sget_simple_extent_dims"); - type=H5Dget_type(dataset); + type = H5Dget_type(dataset); CHECK(type, FAIL, "H5Dget_type"); ret = H5Dread(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(HDmemcmp(&space4_data,&rdata,sizeof(struct space4_struct))) { - HDprintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n",space4_data.c1,rdata.c1); - HDprintf("scalar data different: space4_data.u=%u, read_data4.u=%u\n",space4_data.u,rdata.u); - HDprintf("scalar data different: space4_data.f=%f, read_data4.f=%f\n",(double)space4_data.f,(double)rdata.f); - TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n",space4_data.c1,rdata.c2); - } /* end if */ + if (HDmemcmp(&space4_data, &rdata, sizeof(struct space4_struct))) { + HDprintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", space4_data.c1, rdata.c1); + HDprintf("scalar data different: space4_data.u=%u, read_data4.u=%u\n", space4_data.u, rdata.u); + HDprintf("scalar data different: space4_data.f=%f, read_data4.f=%f\n", (double)space4_data.f, + (double)rdata.f); + TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", space4_data.c1, + rdata.c2); + } /* end if */ /* Close datatype */ ret = H5Tclose(type); @@ -2459,12 +2473,11 @@ test_h5s_compound_scalar_read(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* end test_h5s_compound_scalar_read() */ - +} /* end test_h5s_compound_scalar_read() */ /* Data array sizes for chunk test */ -#define CHUNK_DATA_NX 50000 -#define CHUNK_DATA_NY 3 +#define CHUNK_DATA_NX 50000 +#define CHUNK_DATA_NY 3 /**************************************************************** ** @@ -2476,17 +2489,17 @@ test_h5s_compound_scalar_read(void) static void test_h5s_chunk(void) { - herr_t status; - hid_t fileID, dsetID; - hid_t plist_id; - hid_t space_id; - hsize_t dims[2]; - hsize_t csize[2]; - double **chunk_data_dbl = NULL; - double *chunk_data_dbl_data = NULL; - float **chunk_data_flt = NULL; - float *chunk_data_flt_data = NULL; - int i,j; + herr_t status; + hid_t fileID, dsetID; + hid_t plist_id; + hid_t space_id; + hsize_t dims[2]; + hsize_t csize[2]; + double **chunk_data_dbl = NULL; + double * chunk_data_dbl_data = NULL; + float ** chunk_data_flt = NULL; + float * chunk_data_flt_data = NULL; + int i, j; /* Allocate memory */ chunk_data_dbl_data = (double *)HDcalloc(CHUNK_DATA_NX * CHUNK_DATA_NY, sizeof(double)); @@ -2511,12 +2524,12 @@ test_h5s_chunk(void) csize[0] = CHUNK_DATA_NX; csize[1] = CHUNK_DATA_NY; - status = H5Pset_chunk(plist_id, 2, csize); + status = H5Pset_chunk(plist_id, 2, csize); CHECK(status, FAIL, "H5Pset_chunk"); /* Create the dataspace */ - dims[0] = CHUNK_DATA_NX; - dims[1] = CHUNK_DATA_NY; + dims[0] = CHUNK_DATA_NX; + dims[1] = CHUNK_DATA_NY; space_id = H5Screate_simple(2, dims, NULL); CHECK(space_id, FAIL, "H5Screate_simple"); @@ -2524,8 +2537,8 @@ test_h5s_chunk(void) CHECK(dsetID, FAIL, "H5Dcreate2"); /* Initialize float array */ - for(i = 0; i < CHUNK_DATA_NX; i++) - for(j = 0; j < CHUNK_DATA_NY; j++) + for (i = 0; i < CHUNK_DATA_NX; i++) + for (j = 0; j < CHUNK_DATA_NY; j++) chunk_data_flt[i][j] = (float)(i + 1) * 2.5F - (float)j * 100.3F; status = H5Dwrite(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt_data); @@ -2549,9 +2562,9 @@ test_h5s_chunk(void) dsetID = H5Dopen2(fileID, "coords", H5P_DEFAULT); CHECK(dsetID, FAIL, "H5Dopen2"); - status= H5Dread(dsetID, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_dbl_data); + status = H5Dread(dsetID, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_dbl_data); CHECK(status, FAIL, "H5Dread"); - status= H5Dread(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt_data); + status = H5Dread(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt_data); CHECK(status, FAIL, "H5Dread"); status = H5Dclose(dsetID); @@ -2559,13 +2572,15 @@ test_h5s_chunk(void) status = H5Fclose(fileID); CHECK(status, FAIL, "H5Fclose"); - for(i = 0; i < CHUNK_DATA_NX; i++) { - for(j = 0; j < CHUNK_DATA_NY; j++) { + for (i = 0; i < CHUNK_DATA_NX; i++) { + for (j = 0; j < CHUNK_DATA_NY; j++) { /* Check if the two values are within 0.001% range. */ - if(!H5_DBL_REL_EQUAL(chunk_data_dbl[i][j], (double)chunk_data_flt[i][j], (double)0.00001F)) - TestErrPrintf("%u: chunk_data_dbl[%d][%d]=%e, chunk_data_flt[%d][%d]=%e\n", (unsigned)__LINE__, i, j, chunk_data_dbl[i][j], i, j, (double)chunk_data_flt[i][j]); + if (!H5_DBL_REL_EQUAL(chunk_data_dbl[i][j], (double)chunk_data_flt[i][j], (double)0.00001F)) + TestErrPrintf("%u: chunk_data_dbl[%d][%d]=%e, chunk_data_flt[%d][%d]=%e\n", + (unsigned)__LINE__, i, j, chunk_data_dbl[i][j], i, j, + (double)chunk_data_flt[i][j]); } /* end for */ - } /* end for */ + } /* end for */ HDfree(chunk_data_dbl); HDfree(chunk_data_dbl_data); @@ -2581,22 +2596,19 @@ test_h5s_chunk(void) static void test_h5s_extent_equal(void) { - hid_t null_space; /* Null dataspace */ - hid_t scalar_space; /* Scalar dataspace */ - hid_t d1_space1, d1_space2, d1_space3, d1_space4; /* 1-D dataspaces */ - hid_t d2_space1, d2_space2, d2_space3, d2_space4; /* 2-D dataspaces */ - hid_t d3_space1, d3_space2, d3_space3, d3_space4; /* 3-D dataspaces */ - hsize_t d1_dims1[1] = {10}, /* 1-D dimensions */ - d1_dims2[1] = {20}, - d1_dims3[1] = {H5S_UNLIMITED}; - hsize_t d2_dims1[2] = {10, 10}, /* 2-D dimensions */ - d2_dims2[2] = {20, 20}, - d2_dims3[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t d3_dims1[3] = {10, 10, 10}, /* 3-D dimensions */ - d3_dims2[3] = {20, 20, 20}, - d3_dims3[3] = {H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED}; - htri_t ext_equal; /* Whether two dataspace extents are equal */ - herr_t ret; /* Generic error return */ + hid_t null_space; /* Null dataspace */ + hid_t scalar_space; /* Scalar dataspace */ + hid_t d1_space1, d1_space2, d1_space3, d1_space4; /* 1-D dataspaces */ + hid_t d2_space1, d2_space2, d2_space3, d2_space4; /* 2-D dataspaces */ + hid_t d3_space1, d3_space2, d3_space3, d3_space4; /* 3-D dataspaces */ + hsize_t d1_dims1[1] = {10}, /* 1-D dimensions */ + d1_dims2[1] = {20}, d1_dims3[1] = {H5S_UNLIMITED}; + hsize_t d2_dims1[2] = {10, 10}, /* 2-D dimensions */ + d2_dims2[2] = {20, 20}, d2_dims3[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t d3_dims1[3] = {10, 10, 10}, /* 3-D dimensions */ + d3_dims2[3] = {20, 20, 20}, d3_dims3[3] = {H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED}; + htri_t ext_equal; /* Whether two dataspace extents are equal */ + herr_t ret; /* Generic error return */ /* Create dataspaces */ null_space = H5Screate(H5S_NULL); @@ -3098,22 +3110,19 @@ static void test_h5s_extent_copy(void) { hid_t spaces[14] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; /* Array of all dataspaces */ - hid_t tmp_space = -1; + hid_t tmp_space = -1; hsize_t d1_dims1[1] = {10}, /* 1-D dimensions */ - d1_dims2[1] = {20}, - d1_dims3[1] = {H5S_UNLIMITED}; - hsize_t d2_dims1[2] = {10, 10}, /* 2-D dimensions */ - d2_dims2[2] = {20, 20}, - d2_dims3[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t d3_dims1[3] = {10, 10, 10}, /* 3-D dimensions */ - d3_dims2[3] = {20, 20, 20}, - d3_dims3[3] = {H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t npoints[14]; /* Expected number of points in selection for each element in spaces */ - hssize_t npoints_ret; /* Number of points returned by H5Sget_select_npoints() */ - htri_t ext_equal; /* Whether two dataspace extents are equal */ + d1_dims2[1] = {20}, d1_dims3[1] = {H5S_UNLIMITED}; + hsize_t d2_dims1[2] = {10, 10}, /* 2-D dimensions */ + d2_dims2[2] = {20, 20}, d2_dims3[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t d3_dims1[3] = {10, 10, 10}, /* 3-D dimensions */ + d3_dims2[3] = {20, 20, 20}, d3_dims3[3] = {H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t npoints[14]; /* Expected number of points in selection for each element in spaces */ + hssize_t npoints_ret; /* Number of points returned by H5Sget_select_npoints() */ + htri_t ext_equal; /* Whether two dataspace extents are equal */ const unsigned num_spaces = sizeof(spaces) / sizeof(spaces[0]); - unsigned i, j; - herr_t ret; /* Generic error return */ + unsigned i, j; + herr_t ret; /* Generic error return */ /* Create dataspaces */ spaces[0] = H5Screate(H5S_NULL); @@ -3127,39 +3136,39 @@ test_h5s_extent_copy(void) spaces[2] = H5Screate_simple(1, d1_dims1, NULL); CHECK(spaces[2], FAIL, "H5Screate"); npoints[2] = d1_dims1[0]; - spaces[3] = H5Screate_simple(1, d1_dims2, NULL); + spaces[3] = H5Screate_simple(1, d1_dims2, NULL); CHECK(spaces[3], FAIL, "H5Screate"); npoints[3] = d1_dims2[0]; - spaces[4] = H5Screate_simple(1, d1_dims1, d1_dims2); + spaces[4] = H5Screate_simple(1, d1_dims1, d1_dims2); CHECK(spaces[4], FAIL, "H5Screate"); npoints[4] = d1_dims1[0]; - spaces[5] = H5Screate_simple(1, d1_dims1, d1_dims3); + spaces[5] = H5Screate_simple(1, d1_dims1, d1_dims3); CHECK(spaces[5], FAIL, "H5Screate"); npoints[5] = d1_dims1[0]; spaces[6] = H5Screate_simple(2, d2_dims1, NULL); CHECK(spaces[6], FAIL, "H5Screate"); npoints[6] = d2_dims1[0] * d2_dims1[1]; - spaces[7] = H5Screate_simple(2, d2_dims2, NULL); + spaces[7] = H5Screate_simple(2, d2_dims2, NULL); CHECK(spaces[7], FAIL, "H5Screate"); npoints[7] = d2_dims2[0] * d2_dims2[1]; - spaces[8] = H5Screate_simple(2, d2_dims1, d2_dims2); + spaces[8] = H5Screate_simple(2, d2_dims1, d2_dims2); CHECK(spaces[8], FAIL, "H5Screate"); npoints[8] = d2_dims1[0] * d2_dims1[1]; - spaces[9] = H5Screate_simple(2, d2_dims1, d2_dims3); + spaces[9] = H5Screate_simple(2, d2_dims1, d2_dims3); CHECK(spaces[9], FAIL, "H5Screate"); npoints[9] = d2_dims1[0] * d2_dims1[1]; spaces[10] = H5Screate_simple(3, d3_dims1, NULL); CHECK(spaces[10], FAIL, "H5Screate"); npoints[10] = d3_dims1[0] * d3_dims1[1] * d3_dims1[2]; - spaces[11] = H5Screate_simple(3, d3_dims2, NULL); + spaces[11] = H5Screate_simple(3, d3_dims2, NULL); CHECK(spaces[11], FAIL, "H5Screate"); npoints[11] = d3_dims2[0] * d3_dims2[1] * d3_dims2[2]; - spaces[12] = H5Screate_simple(3, d3_dims1, d3_dims2); + spaces[12] = H5Screate_simple(3, d3_dims1, d3_dims2); CHECK(spaces[12], FAIL, "H5Screate"); npoints[12] = d3_dims1[0] * d3_dims1[1] * d3_dims1[2]; - spaces[13] = H5Screate_simple(3, d3_dims1, d3_dims3); + spaces[13] = H5Screate_simple(3, d3_dims1, d3_dims3); CHECK(spaces[13], FAIL, "H5Screate"); npoints[13] = d3_dims1[0] * d3_dims1[1] * d3_dims1[2]; @@ -3168,8 +3177,8 @@ test_h5s_extent_copy(void) /* Copy between all dataspace combinations. Note there are a few * duplicates. */ - for(i = 0; i < num_spaces; i++) - for(j = i; j < num_spaces; j++) { + for (i = 0; i < num_spaces; i++) + for (j = i; j < num_spaces; j++) { /* Copy from i to j, unless the inner loop just restarted, in which * case i and j are the same, so the second call to H5Sextent_copy() * will test copying from i/j to i/j */ @@ -3198,7 +3207,7 @@ test_h5s_extent_copy(void) } /* end for */ /* Close dataspaces */ - for(i = 0; i < num_spaces; i++) { + for (i = 0; i < num_spaces; i++) { ret = H5Sclose(spaces[i]); CHECK(ret, FAIL, "H5Sclose"); spaces[i] = -1; @@ -3217,12 +3226,12 @@ test_h5s_extent_copy(void) static void test_h5s_bug1(void) { - hid_t space1; /* Dataspace to copy extent to */ - hid_t space2; /* Scalar dataspace */ - hsize_t dims[2] = {10, 10}; /* Dimensions */ - hsize_t start[2] = {0, 0}; /* Hyperslab start */ - htri_t select_valid; /* Whether the dataspace selection is valid */ - herr_t ret; /* Generic error return */ + hid_t space1; /* Dataspace to copy extent to */ + hid_t space2; /* Scalar dataspace */ + hsize_t dims[2] = {10, 10}; /* Dimensions */ + hsize_t start[2] = {0, 0}; /* Hyperslab start */ + htri_t select_valid; /* Whether the dataspace selection is valid */ + herr_t ret; /* Generic error return */ /* Create dataspaces */ space1 = H5Screate(H5S_SIMPLE); @@ -3250,7 +3259,6 @@ test_h5s_bug1(void) CHECK(ret, FAIL, "H5Sclose"); } /* test_h5s_bug1() */ - /*------------------------------------------------------------------------- * Function: test_versionbounds * @@ -3266,21 +3274,21 @@ test_h5s_bug1(void) * *------------------------------------------------------------------------- */ -#define VERBFNAME "tverbounds_dspace.h5" -#define BASIC_DSET "Basic Dataset" -#define LATEST_DSET "Latest Dataset" +#define VERBFNAME "tverbounds_dspace.h5" +#define BASIC_DSET "Basic Dataset" +#define LATEST_DSET "Latest Dataset" static void test_versionbounds(void) { - hid_t file = -1; /* File ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t dset_space = -1; /* Retrieved dataset's dataspace ID */ - hsize_t dim[1]; /* Dataset dimensions */ - H5F_libver_t low, high; /* File format bounds */ - H5S_t *spacep = NULL; /* Pointer to internal dataspace */ - herr_t ret = 0; /* Generic return value */ + hid_t file = -1; /* File ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t dset_space = -1; /* Retrieved dataset's dataspace ID */ + hsize_t dim[1]; /* Dataset dimensions */ + H5F_libver_t low, high; /* File format bounds */ + H5S_t * spacep = NULL; /* Pointer to internal dataspace */ + herr_t ret = 0; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Version Bounds\n")); @@ -3291,7 +3299,7 @@ test_versionbounds(void) /* Create dataspace */ dim[0] = 10; - space = H5Screate_simple(1, dim, NULL); + space = H5Screate_simple(1, dim, NULL); CHECK(space, FAIL, "H5Screate"); /* Its version should be H5O_SDSPACE_VERSION_1 */ @@ -3300,9 +3308,9 @@ test_versionbounds(void) VERIFY(spacep->extent.version, H5O_SDSPACE_VERSION_1, "basic dataspace version bound"); /* Set high bound to V18 */ - low = H5F_LIBVER_EARLIEST; + low = H5F_LIBVER_EARLIEST; high = H5F_LIBVER_V18; - ret = H5Pset_libver_bounds(fapl, low, high); + ret = H5Pset_libver_bounds(fapl, low, high); CHECK(ret, FAIL, "H5Pset_libver_bounds"); /* Create the file */ @@ -3335,9 +3343,9 @@ test_versionbounds(void) /* Set low and high bounds to latest to trigger the increment of the dataspace version */ - low = H5F_LIBVER_LATEST; + low = H5F_LIBVER_LATEST; high = H5F_LIBVER_LATEST; - ret = H5Pset_libver_bounds(fapl, low, high); + ret = H5Pset_libver_bounds(fapl, low, high); CHECK(ret, FAIL, "H5Pset_libver_bounds"); /* Reopen the file with new version bounds, LATEST/LATEST */ @@ -3373,7 +3381,6 @@ test_versionbounds(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_versionbounds() */ - /**************************************************************** ** ** test_h5s(): Main H5S (dataspace) testing routine. @@ -3382,21 +3389,21 @@ test_versionbounds(void) void test_h5s(void) { - H5F_libver_t low, high; /* Low and high bounds */ + H5F_libver_t low, high; /* Low and high bounds */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspaces\n")); - test_h5s_basic(); /* Test basic H5S code */ - test_h5s_null(); /* Test Null dataspace H5S code */ - test_h5s_zero_dim(); /* Test dataspace with zero dimension size */ + test_h5s_basic(); /* Test basic H5S code */ + test_h5s_null(); /* Test Null dataspace H5S code */ + test_h5s_zero_dim(); /* Test dataspace with zero dimension size */ /* Loop through all the combinations of low/high version bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Invalid combinations, just continue */ - if(high == H5F_LIBVER_EARLIEST || high < low) + if (high == H5F_LIBVER_EARLIEST || high < low) continue; test_h5s_encode(low, high); /* Test encoding and decoding */ @@ -3405,29 +3412,28 @@ test_h5s(void) test_h5s_encode_points(low, high); /* Test encoding points */ } /* end high bound */ - } /* end low bound */ + } /* end low bound */ - test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ + test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ #ifndef H5_NO_DEPRECATED_SYMBOLS - test_h5s_encode1(); /* Test operations with old API routine (H5Sencode1) */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ + test_h5s_encode1(); /* Test operations with old API routine (H5Sencode1) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ - test_h5s_scalar_write(); /* Test scalar H5S writing code */ - test_h5s_scalar_read(); /* Test scalar H5S reading code */ + test_h5s_scalar_write(); /* Test scalar H5S writing code */ + test_h5s_scalar_read(); /* Test scalar H5S reading code */ - test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */ - test_h5s_compound_scalar_read(); /* Test compound datatype scalar H5S reading code */ + test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */ + test_h5s_compound_scalar_read(); /* Test compound datatype scalar H5S reading code */ /* This test was added later to exercise a bug in chunked I/O */ - test_h5s_chunk(); /* Exercise bug fix for chunked I/O */ + test_h5s_chunk(); /* Exercise bug fix for chunked I/O */ - test_h5s_extent_equal(); /* Test extent comparison code */ - test_h5s_extent_copy(); /* Test extent copy code */ - test_h5s_bug1(); /* Test bug in offset initialization */ - test_versionbounds(); /* Test version bounds with dataspace */ + test_h5s_extent_equal(); /* Test extent comparison code */ + test_h5s_extent_copy(); /* Test extent copy code */ + test_h5s_bug1(); /* Test bug in offset initialization */ + test_versionbounds(); /* Test version bounds with dataspace */ } /* test_h5s() */ - /*------------------------------------------------------------------------- * Function: cleanup_h5s * diff --git a/test/theap.c b/test/theap.c index 7b2fadb..73b8f5b 100644 --- a/test/theap.c +++ b/test/theap.c @@ -33,12 +33,12 @@ #include "H5HPprivate.h" /* The number of elements in testing arrays */ -#define NUM_ELEMS 1000 +#define NUM_ELEMS 1000 /* Objects for testing in heaps */ typedef struct test_obj { - H5HP_info_t heap_info; /* Information required for heap. _MUST_ be first */ - int val; /* Actual information for object */ + H5HP_info_t heap_info; /* Information required for heap. _MUST_ be first */ + int val; /* Actual information for object */ } test_obj; /* Array of random element values */ @@ -50,28 +50,30 @@ static test_obj *inc_sort_num; /* Array of random elements values, sorted in decreasing order */ static test_obj *dec_sort_num; -static int tst_dec_sort(const void *_i1, const void *_i2) +static int +tst_dec_sort(const void *_i1, const void *_i2) { - const test_obj *i1=(const test_obj *)_i1; - const test_obj *i2=(const test_obj *)_i2; - - if(i1->valval) - return(1); - else if(i1->val>i2->val) - return(-1); - return(0); + const test_obj *i1 = (const test_obj *)_i1; + const test_obj *i2 = (const test_obj *)_i2; + + if (i1->val < i2->val) + return (1); + else if (i1->val > i2->val) + return (-1); + return (0); } -static int tst_inc_sort(const void *_i1, const void *_i2) +static int +tst_inc_sort(const void *_i1, const void *_i2) { - const test_obj *i1=(const test_obj *)_i1; - const test_obj *i2=(const test_obj *)_i2; - - if(i1->valval) - return(-1); - else if(i1->val>i2->val) - return(1); - return(0); + const test_obj *i1 = (const test_obj *)_i1; + const test_obj *i2 = (const test_obj *)_i2; + + if (i1->val < i2->val) + return (-1); + else if (i1->val > i2->val) + return (1); + return (0); } /**************************************************************** @@ -83,8 +85,8 @@ static int tst_inc_sort(const void *_i1, const void *_i2) static void test_heap_init(void) { - time_t curr_time; /* Current time, for seeding random number generator */ - size_t u; /* Local index variables */ + time_t curr_time; /* Current time, for seeding random number generator */ + size_t u; /* Local index variables */ /* Allocate arrays */ rand_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); @@ -97,7 +99,7 @@ test_heap_init(void) /* Create randomized set of numbers */ curr_time = HDtime(NULL); HDsrandom((unsigned)curr_time); - for(u = 0; u < NUM_ELEMS; u++) + for (u = 0; u < NUM_ELEMS; u++) /* Generate random numbers from -1000 to 1000 */ rand_num[u].val = (int)(HDrandom() % 2001) - 1001; @@ -119,26 +121,26 @@ test_heap_init(void) static void test_heap_create(void) { - H5HP_t *heap; /* Heap created */ - herr_t ret; /* Generic return value */ + H5HP_t *heap; /* Heap created */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing Creating & Closing Heaps\n")); /* Try creating a maximum Heap */ - heap=H5HP_create(H5HP_MAX_HEAP); + heap = H5HP_create(H5HP_MAX_HEAP); CHECK_PTR(heap, "H5HP_create"); /* Try closing the heap */ - ret=H5HP_close(heap); + ret = H5HP_close(heap); CHECK(ret, FAIL, "H5HP_close"); /* Try creating a minimum Heap */ - heap=H5HP_create(H5HP_MIN_HEAP); + heap = H5HP_create(H5HP_MIN_HEAP); CHECK_PTR(heap, "H5HP_create"); /* Try closing the heap */ - ret=H5HP_close(heap); + ret = H5HP_close(heap); CHECK(ret, FAIL, "H5HP_close"); } /* end test_heap_create() */ @@ -152,67 +154,67 @@ test_heap_create(void) static void test_heap_insert_min(void) { - H5HP_t *heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ + H5HP_t * heap; /* Heap created */ + ssize_t num; /* Number of elements in heap */ + int val; /* Value of object on heap */ + test_obj obj1, obj2, obj3; /* Test objects to insert */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Inserting Into Minimum Heaps\n")); /* Create a Heap */ - heap=H5HP_create(H5HP_MIN_HEAP); + heap = H5HP_create(H5HP_MIN_HEAP); CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 0, "H5HP_count"); /* Insert an object into the heap */ - obj1.val=100; - ret=H5HP_insert(heap,10,&obj1); + obj1.val = 100; + ret = H5HP_insert(heap, 10, &obj1); CHECK(ret, FAIL, "H5HP_insert"); /* Check that the heap has one element */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 1, "H5HP_count"); /* Check the minimum value on the heap */ - ret=H5HP_top(heap, &val); + ret = H5HP_top(heap, &val); CHECK(ret, FAIL, "H5HP_top"); VERIFY(val, 10, "H5HP_top"); /* Insert another object into the heap, with value less than top element */ - obj2.val=50; - ret=H5HP_insert(heap,5,&obj2); + obj2.val = 50; + ret = H5HP_insert(heap, 5, &obj2); CHECK(ret, FAIL, "H5HP_insert"); /* Check that the heap has two elements */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 2, "H5HP_count"); /* Check the minimum value on the heap */ - ret=H5HP_top(heap, &val); + ret = H5HP_top(heap, &val); CHECK(ret, FAIL, "H5HP_top"); VERIFY(val, 5, "H5HP_top"); /* Insert third object into the heap, with value greater than top element */ - obj3.val=200; - ret=H5HP_insert(heap,20,&obj3); + obj3.val = 200; + ret = H5HP_insert(heap, 20, &obj3); CHECK(ret, FAIL, "H5HP_insert"); /* Check that the heap has three elements */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 3, "H5HP_count"); /* Check the minimum value on the heap */ - ret=H5HP_top(heap, &val); + ret = H5HP_top(heap, &val); CHECK(ret, FAIL, "H5HP_top"); VERIFY(val, 5, "H5HP_top"); /* Close the heap */ - ret=H5HP_close(heap); + ret = H5HP_close(heap); CHECK(ret, FAIL, "H5HP_close"); } /* end test_heap_insert_min() */ @@ -226,67 +228,67 @@ test_heap_insert_min(void) static void test_heap_insert_max(void) { - H5HP_t *heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ + H5HP_t * heap; /* Heap created */ + ssize_t num; /* Number of elements in heap */ + int val; /* Value of object on heap */ + test_obj obj1, obj2, obj3; /* Test objects to insert */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Inserting Into Maximum Heaps\n")); /* Create a Heap */ - heap=H5HP_create(H5HP_MAX_HEAP); + heap = H5HP_create(H5HP_MAX_HEAP); CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 0, "H5HP_count"); /* Insert an object into the heap */ - obj1.val=100; - ret=H5HP_insert(heap,10,&obj1); + obj1.val = 100; + ret = H5HP_insert(heap, 10, &obj1); CHECK(ret, FAIL, "H5HP_insert"); /* Check that the heap has one element */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 1, "H5HP_count"); /* Check the maximum value on the heap */ - ret=H5HP_top(heap, &val); + ret = H5HP_top(heap, &val); CHECK(ret, FAIL, "H5HP_top"); VERIFY(val, 10, "H5HP_top"); /* Insert another object into the heap, with value less than top element */ - obj2.val=50; - ret=H5HP_insert(heap,5,&obj2); + obj2.val = 50; + ret = H5HP_insert(heap, 5, &obj2); CHECK(ret, FAIL, "H5HP_insert"); /* Check that the heap has two elements */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 2, "H5HP_count"); /* Check the maximum value on the heap */ - ret=H5HP_top(heap, &val); + ret = H5HP_top(heap, &val); CHECK(ret, FAIL, "H5HP_top"); VERIFY(val, 10, "H5HP_top"); /* Insert third object into the heap, with value greater than top element */ - obj3.val=200; - ret=H5HP_insert(heap,20,&obj3); + obj3.val = 200; + ret = H5HP_insert(heap, 20, &obj3); CHECK(ret, FAIL, "H5HP_insert"); /* Check that the heap has three elements */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 3, "H5HP_count"); /* Check the maximum value on the heap */ - ret=H5HP_top(heap, &val); + ret = H5HP_top(heap, &val); CHECK(ret, FAIL, "H5HP_top"); VERIFY(val, 20, "H5HP_top"); /* Close the heap */ - ret=H5HP_close(heap); + ret = H5HP_close(heap); CHECK(ret, FAIL, "H5HP_close"); } /* end test_heap_insert_max() */ @@ -317,38 +319,38 @@ test_heap_insert(void) static void test_heap_insert_many_core(H5HP_type_t heap_type, test_obj *arr, size_t nelem, int top_val) { - H5HP_t *heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - size_t u; /* Local index variable */ - herr_t ret; /* Generic return value */ + H5HP_t *heap; /* Heap created */ + ssize_t num; /* Number of elements in heap */ + int val; /* Value of object on heap */ + size_t u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Create a Heap */ - heap=H5HP_create(heap_type); + heap = H5HP_create(heap_type); CHECK_PTR(heap, "H5HP_create"); /* Check that the heap has no elements */ - num=H5HP_count(heap); + num = H5HP_count(heap); VERIFY(num, 0, "H5HP_count"); /* Insert the array elements into the heap */ - for(u=0; uval, "H5HP_remove"); /* Check that the value is correct, based on the heap type */ - if(heap_type==H5HP_MAX_HEAP) { - if(val>last_val) - TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n",__LINE__,val,last_val); + if (heap_type == H5HP_MAX_HEAP) { + if (val > last_val) + TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val, + last_val); } /* end if */ else { - if(valval, "H5HP_remove"); /* Check that the value is correct, based on the heap type */ - if(heap_type==H5HP_MAX_HEAP) { - if(val>last_val) - TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n",__LINE__,val,last_val); + if (heap_type == H5HP_MAX_HEAP) { + if (val > last_val) + TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val, + last_val); } /* end if */ else { - if(valmtx)) != 0) { - my_errx(EXIT_FAILURE, "%s: pthread_mutex_lock: %s", __func__, - strerror(rc)); + my_errx(EXIT_FAILURE, "%s: pthread_mutex_lock: %s", __func__, strerror(rc)); } } @@ -109,8 +106,7 @@ barrier_unlock(pthread_barrier_t *barrier) int rc; if ((rc = pthread_mutex_unlock(&barrier->mtx)) != 0) { - my_errx(EXIT_FAILURE, "%s: pthread_mutex_unlock: %s", __func__, - strerror(rc)); + my_errx(EXIT_FAILURE, "%s: pthread_mutex_unlock: %s", __func__, strerror(rc)); } } @@ -125,7 +121,7 @@ pthread_barrier_destroy(pthread_barrier_t *barrier) else if (barrier->nentered % barrier->count != 0) rc = EBUSY; else { - rc = 0; + rc = 0; barrier->magic = ~barrier->magic; } barrier_unlock(barrier); @@ -142,7 +138,7 @@ pthread_barrier_destroy(pthread_barrier_t *barrier) int pthread_barrier_wait(pthread_barrier_t *barrier) { - int rc; + int rc; uint64_t threshold; if (barrier == NULL) @@ -170,7 +166,7 @@ out: return rc; } -#endif /* H5_HAVE_DARWIN */ +#endif /* H5_HAVE_DARWIN */ static void my_err(int, const char *, ...) H5_ATTR_FORMAT(printf, 2, 3); @@ -178,7 +174,7 @@ static void my_err(int code, const char *fmt, ...) { va_list ap; - int errno_copy = errno; + int errno_copy = errno; (void)HDfprintf(stderr, "thread_id: "); HDva_start(ap, fmt); @@ -188,22 +184,22 @@ my_err(int code, const char *fmt, ...) HDexit(code); } -#define threads_failure(_call, _result) do { \ - my_errx(EXIT_FAILURE, "%s.%d: " #_call ": %s", __func__, \ - __LINE__, HDstrerror(_result)); \ -} while (false) +#define threads_failure(_call, _result) \ + do { \ + my_errx(EXIT_FAILURE, "%s.%d: " #_call ": %s", __func__, __LINE__, HDstrerror(_result)); \ + } while (false) #define NTHREADS 5 -static volatile bool failed = false; +static volatile bool failed = false; static pthread_barrier_t barrier; -static bool used[NTHREADS]; -static pthread_mutex_t used_lock; +static bool used[NTHREADS]; +static pthread_mutex_t used_lock; static void atomic_printf(const char *fmt, ...) { - char buf[80]; + char buf[80]; va_list ap; ssize_t nprinted, nwritten; @@ -218,8 +214,7 @@ atomic_printf(const char *fmt, ...) nwritten = write(STDOUT_FILENO, buf, (size_t)nprinted); if (nwritten < nprinted) { - my_errx(EXIT_FAILURE, "%s.%d: write error or short write", - __func__, __LINE__); + my_errx(EXIT_FAILURE, "%s.%d: write error or short write", __func__, __LINE__); } } @@ -261,8 +256,7 @@ thread_main(void H5_ATTR_UNUSED *arg) ntid = H5TS_thread_id(); if (ntid != tid) { - atomic_printf("tid changed from %" PRIu64 " to %" PRIu64 " FAIL\n", - tid, ntid); + atomic_printf("tid changed from %" PRIu64 " to %" PRIu64 " FAIL\n", tid, ntid); failed = true; } return NULL; @@ -275,7 +269,7 @@ pre_barrier_error: int main(void) { - int i, rc, times; + int i, rc, times; pthread_t threads[NTHREADS]; /* Run H5open() to initialize the library's thread-ID freelist, @@ -296,7 +290,7 @@ main(void) for (times = 0; times < 2; times++) { for (i = 0; i < NTHREADS; i++) - used[i] = false; // access synchronized by thread create/join + used[i] = false; // access synchronized by thread create/join for (i = 0; i < NTHREADS; i++) { rc = pthread_create(&threads[i], NULL, thread_main, NULL); @@ -320,7 +314,7 @@ main(void) return failed ? EXIT_FAILURE : EXIT_SUCCESS; } -#else /*H5_HAVE_THREADSAFE && !H5_HAVE_WIN_THREADS*/ +#else /*H5_HAVE_THREADSAFE && !H5_HAVE_WIN_THREADS*/ int main(void) { diff --git a/test/tid.c b/test/tid.c index 7a839d2..27135fc 100644 --- a/test/tid.c +++ b/test/tid.c @@ -16,7 +16,7 @@ #include "testhdf5.h" /* Include H5Ipkg.h to calculate max number of groups */ -#define H5I_FRIEND /*suppress error about including H5Ipkg */ +#define H5I_FRIEND /*suppress error about including H5Ipkg */ #include "H5Ipkg.h" static herr_t @@ -27,59 +27,59 @@ free_wrapper(void *p) } /* Test basic functionality of registering and deleting types and IDs */ -static int basic_id_test(void) +static int +basic_id_test(void) { - H5I_type_t myType = H5I_BADID; - hid_t arrayID = H5I_INVALID_HID; - void* testObj = NULL; - void* testPtr = NULL; - char nameString[10]; - hid_t testID; - ssize_t testSize = -1; - herr_t err; - int num_ref; - hsize_t num_members; - + H5I_type_t myType = H5I_BADID; + hid_t arrayID = H5I_INVALID_HID; + void * testObj = NULL; + void * testPtr = NULL; + char nameString[10]; + hid_t testID; + ssize_t testSize = -1; + herr_t err; + int num_ref; + hsize_t num_members; /* Try to register an ID with ficticious types */ H5E_BEGIN_TRY - arrayID = H5Iregister((H5I_type_t) 420, testObj); + arrayID = H5Iregister((H5I_type_t)420, testObj); H5E_END_TRY VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister"); - if(arrayID != H5I_INVALID_HID) + if (arrayID != H5I_INVALID_HID) goto out; H5E_BEGIN_TRY - arrayID = H5Iregister((H5I_type_t) -1, testObj); + arrayID = H5Iregister((H5I_type_t)-1, testObj); H5E_END_TRY VERIFY(arrayID, H5I_INVALID_HID, "H5Iregister"); - if(arrayID != H5I_INVALID_HID) + if (arrayID != H5I_INVALID_HID) goto out; - /* Try to access IDs with ficticious types */ + /* Try to access IDs with ficticious types */ H5E_BEGIN_TRY - testPtr = H5Iobject_verify((hid_t)100, (H5I_type_t) 0); + testPtr = H5Iobject_verify((hid_t)100, (H5I_type_t)0); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); - if(testPtr != NULL) + if (testPtr != NULL) goto out; H5E_BEGIN_TRY - testPtr = H5Iobject_verify((hid_t)700, (H5I_type_t) 700); + testPtr = H5Iobject_verify((hid_t)700, (H5I_type_t)700); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); - if(testPtr != NULL) + if (testPtr != NULL) goto out; /* Register a type */ myType = H5Iregister_type((size_t)64, 0, free_wrapper); CHECK(myType, H5I_BADID, "H5Iregister_type"); - if(myType == H5I_BADID) + if (myType == H5I_BADID) goto out; /* Register an ID and retrieve the object it points to. @@ -90,7 +90,7 @@ static int basic_id_test(void) arrayID = H5Iregister(myType, testObj); CHECK(arrayID, H5I_INVALID_HID, "H5Iregister"); - if(arrayID == H5I_INVALID_HID) { + if (arrayID == H5I_INVALID_HID) { HDfree(testObj); goto out; } @@ -98,58 +98,58 @@ static int basic_id_test(void) testPtr = (int *)H5Iobject_verify(arrayID, myType); CHECK_PTR_EQ(testPtr, testObj, "H5Iobject_verify"); - if(testPtr != testObj) + if (testPtr != testObj) goto out; /* Ensure that H5Iget_file_id and H5Iget_name() fail, since this * is an hid_t for the wrong kind of object */ H5E_BEGIN_TRY - testID = H5Iget_file_id(arrayID); + testID = H5Iget_file_id(arrayID); H5E_END_TRY VERIFY(testID, H5I_INVALID_HID, "H5Iget_file_id"); - if(testID != H5I_INVALID_HID) + if (testID != H5I_INVALID_HID) goto out; H5E_BEGIN_TRY - testSize = H5Iget_name(arrayID, nameString, (size_t)9); + testSize = H5Iget_name(arrayID, nameString, (size_t)9); H5E_END_TRY VERIFY(testSize, -1, "H5Iget_name"); - if(testSize != -1) + if (testSize != -1) goto out; /* Make sure H5Iremove_verify catches objects of the wrong type */ H5E_BEGIN_TRY - testPtr = (int*) H5Iremove_verify(arrayID, (H5I_type_t) 0); + testPtr = (int *)H5Iremove_verify(arrayID, (H5I_type_t)0); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Iremove_verify"); - if(testPtr != NULL) + if (testPtr != NULL) goto out; H5E_BEGIN_TRY - testPtr = (int*) H5Iremove_verify(arrayID, (H5I_type_t) ((int) myType-1)); + testPtr = (int *)H5Iremove_verify(arrayID, (H5I_type_t)((int)myType - 1)); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Iremove_verify"); - if(testPtr != NULL) + if (testPtr != NULL) goto out; /* Remove an ID and make sure we can't access it */ - testPtr = (int*) H5Iremove_verify(arrayID, myType); + testPtr = (int *)H5Iremove_verify(arrayID, myType); CHECK_PTR(testPtr, "H5Iremove_verify"); - if(testPtr == NULL) + if (testPtr == NULL) goto out; H5E_BEGIN_TRY - testPtr = (int*) H5Iobject_verify(arrayID, myType); + testPtr = (int *)H5Iobject_verify(arrayID, myType); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); - if(testPtr != NULL) + if (testPtr != NULL) goto out; /* Delete the type and make sure we can't access objects within it */ @@ -157,23 +157,23 @@ static int basic_id_test(void) err = H5Idestroy_type(myType); VERIFY(err, 0, "H5Idestroy_type"); - if( err != 0) + if (err != 0) goto out; VERIFY(H5Itype_exists(myType), 0, "H5Itype_exists"); - if(H5Itype_exists(myType) != 0) + if (H5Itype_exists(myType) != 0) goto out; H5E_BEGIN_TRY - VERIFY(H5Inmembers(myType, NULL), -1, "H5Inmembers"); - if(H5Inmembers(myType, NULL) != -1) - goto out; + VERIFY(H5Inmembers(myType, NULL), -1, "H5Inmembers"); + if (H5Inmembers(myType, NULL) != -1) + goto out; H5E_END_TRY /* Register another type and another object in that type */ myType = H5Iregister_type((size_t)64, 0, free_wrapper); CHECK(myType, H5I_BADID, "H5Iregister_type"); - if(myType == H5I_BADID) + if (myType == H5I_BADID) goto out; /* The memory that testObj pointed to should already have been @@ -184,7 +184,7 @@ static int basic_id_test(void) arrayID = H5Iregister(myType, testObj); CHECK(arrayID, H5I_INVALID_HID, "H5Iregister"); - if(arrayID == H5I_INVALID_HID) { + if (arrayID == H5I_INVALID_HID) { HDfree(testObj); goto out; } @@ -194,7 +194,7 @@ static int basic_id_test(void) if (err < 0) goto out; VERIFY(num_members, 1, "H5Inmembers"); - if(num_members != 1) + if (num_members != 1) goto out; /* Increment references to type and ensure that dec_type_ref @@ -202,33 +202,33 @@ static int basic_id_test(void) */ num_ref = H5Iinc_type_ref(myType); VERIFY(num_ref, 2, "H5Iinc_type_ref"); - if( num_ref != 2) + if (num_ref != 2) goto out; num_ref = H5Idec_type_ref(myType); VERIFY(num_ref, 1, "H5Idec_type_ref"); - if(num_ref != 1) + if (num_ref != 1) goto out; err = H5Inmembers(myType, &num_members); CHECK(err, -1, "H5Inmembers"); if (err < 0) goto out; VERIFY(num_members, 1, "H5Inmembers"); - if(num_members != 1) + if (num_members != 1) goto out; /* This call to dec_type_ref should destroy the type */ num_ref = H5Idec_type_ref(myType); VERIFY(num_ref, 0, "H5Idec_type_ref"); - if(num_ref != 0) + if (num_ref != 0) goto out; VERIFY(H5Itype_exists(myType), 0, "H5Itype_exists"); if (H5Itype_exists(myType) != 0) goto out; H5E_BEGIN_TRY - err = H5Inmembers(myType, &num_members); - if(err >= 0) - goto out; + err = H5Inmembers(myType, &num_members); + if (err >= 0) + goto out; H5E_END_TRY return 0; @@ -237,22 +237,26 @@ out: /* Clean up type if it has been allocated and free memory used * by testObj */ - if(myType >= 0) + if (myType >= 0) H5Idestroy_type(myType); return -1; } +/* A dummy search function for the next test */ +static int +test_search_func(void H5_ATTR_UNUSED *ptr1, hid_t H5_ATTR_UNUSED id, void H5_ATTR_UNUSED *ptr2) +{ + return 0; +} - /* A dummy search function for the next test */ -static int test_search_func(void H5_ATTR_UNUSED * ptr1, hid_t H5_ATTR_UNUSED id, void H5_ATTR_UNUSED * ptr2) { return 0; } - - /* Ensure that public functions cannot access "predefined" ID types */ -static int id_predefined_test(void ) +/* Ensure that public functions cannot access "predefined" ID types */ +static int +id_predefined_test(void) { void * testObj; - hid_t testID; - hid_t typeID = H5I_INVALID_HID; + hid_t testID; + hid_t typeID = H5I_INVALID_HID; void * testPtr; herr_t testErr; @@ -263,59 +267,59 @@ static int id_predefined_test(void ) */ H5E_BEGIN_TRY - testID = H5Iregister(H5I_FILE, testObj); + testID = H5Iregister(H5I_FILE, testObj); H5E_END_TRY VERIFY(testID, H5I_INVALID_HID, "H5Iregister"); - if(testID != H5I_INVALID_HID) + if (testID != H5I_INVALID_HID) goto out; H5E_BEGIN_TRY - testPtr = H5Isearch(H5I_GENPROP_LST, test_search_func, testObj); + testPtr = H5Isearch(H5I_GENPROP_LST, test_search_func, testObj); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Isearch"); - if(testPtr != NULL) + if (testPtr != NULL) goto out; H5E_BEGIN_TRY - testErr = H5Inmembers(H5I_ERROR_STACK, NULL); + testErr = H5Inmembers(H5I_ERROR_STACK, NULL); H5E_END_TRY VERIFY(testErr, -1, "H5Inmembers"); - if(testErr != -1) + if (testErr != -1) goto out; H5E_BEGIN_TRY - testErr = H5Iclear_type(H5I_FILE, 0); + testErr = H5Iclear_type(H5I_FILE, 0); H5E_END_TRY VERIFY((testErr >= 0), 0, "H5Iclear_type"); - if(testErr >= 0) + if (testErr >= 0) goto out; H5E_BEGIN_TRY - testErr = H5Idestroy_type(H5I_DATASET); + testErr = H5Idestroy_type(H5I_DATASET); H5E_END_TRY VERIFY((testErr >= 0), 0, "H5Idestroy_type"); - if(testErr >= 0) + if (testErr >= 0) goto out; H5E_BEGIN_TRY - testErr = H5Itype_exists(H5I_GROUP); + testErr = H5Itype_exists(H5I_GROUP); H5E_END_TRY VERIFY(testErr, -1, "H5Itype_exists"); - if(testErr != -1) + if (testErr != -1) goto out; H5E_BEGIN_TRY - testErr = H5Itype_exists(H5I_ATTR); + testErr = H5Itype_exists(H5I_ATTR); H5E_END_TRY VERIFY(testErr, -1, "H5Itype_exists"); - if(testErr != -1) + if (testErr != -1) goto out; /* @@ -324,23 +328,23 @@ static int id_predefined_test(void ) typeID = H5Tcreate(H5T_OPAQUE, (size_t)42); CHECK(typeID, H5I_INVALID_HID, "H5Tcreate"); - if(typeID == H5I_INVALID_HID) + if (typeID == H5I_INVALID_HID) goto out; H5E_BEGIN_TRY - testPtr = H5Iremove_verify(typeID, H5I_DATATYPE); + testPtr = H5Iremove_verify(typeID, H5I_DATATYPE); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Iremove_verify"); - if(testPtr != NULL) + if (testPtr != NULL) goto out; H5E_BEGIN_TRY - testPtr = H5Iobject_verify(typeID, H5I_DATATYPE); + testPtr = H5Iobject_verify(typeID, H5I_DATATYPE); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Iobject_verify"); - if(testPtr != NULL) + if (testPtr != NULL) goto out; H5Tclose(typeID); @@ -351,23 +355,23 @@ static int id_predefined_test(void ) return 0; out: - if(typeID != H5I_INVALID_HID) + if (typeID != H5I_INVALID_HID) H5Tclose(typeID); - if(testObj != NULL) + if (testObj != NULL) HDfree(testObj); return -1; } - /* Test the H5Iis_valid function */ -static int test_is_valid(void) +static int +test_is_valid(void) { - hid_t dtype; /* datatype id */ - int64_t nmembs1; /* number of type memnbers */ + hid_t dtype; /* datatype id */ + int64_t nmembs1; /* number of type memnbers */ int64_t nmembs2; - htri_t tri_ret; /* htri_t return value */ - herr_t ret; /* return value */ + htri_t tri_ret; /* htri_t return value */ + herr_t ret; /* return value */ /* Create a datatype id */ dtype = H5Tcopy(H5T_NATIVE_INT); @@ -437,10 +441,11 @@ out: } /* Test the H5Iget_type function */ -static int test_get_type(void) +static int +test_get_type(void) { - hid_t dtype; /* datatype id */ - H5I_type_t type_ret; /* return value */ + hid_t dtype; /* datatype id */ + H5I_type_t type_ret; /* return value */ /* Create a datatype id */ dtype = H5Tcopy(H5T_NATIVE_INT); @@ -471,13 +476,13 @@ static int test_get_type(void) return 0; out: - if(dtype != H5I_INVALID_HID) - H5Tclose(dtype); + if (dtype != H5I_INVALID_HID) + H5Tclose(dtype); return -1; } - /* Test boundary cases with lots of types */ +/* Test boundary cases with lots of types */ /* Type IDs range from H5I_NTYPES to H5I_MAX_NUM_TYPES. The system will assign */ /* IDs in sequential order until H5I_MAX_NUM_TYPES IDs have been given out, at which */ @@ -492,50 +497,48 @@ out: /* destroy it, this test will mysteriously fail (because it will expect there to */ /* be one more "free" type ID than there is). */ /* H5I_NTYPES is defined in h5public.h, H5I_MAX_NUM_TYPES is defined in h5pkg.h */ -static int test_id_type_list(void) +static int +test_id_type_list(void) { - H5I_type_t startType; /* The first type ID we were assigned in this test */ + H5I_type_t startType; /* The first type ID we were assigned in this test */ H5I_type_t currentType; H5I_type_t testType; - int i; /* Just a counter variable */ + int i; /* Just a counter variable */ startType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(startType, H5I_BADID, "H5Iregister_type"); - if(startType == H5I_BADID) + if (startType == H5I_BADID) goto out; /* Sanity check */ - if((int)startType >= H5I_MAX_NUM_TYPES || startType < H5I_NTYPES) - { + if ((int)startType >= H5I_MAX_NUM_TYPES || startType < H5I_NTYPES) { /* Error condition, throw an error */ CHECK(1, 1, "H5Iregister_type"); goto out; } /* Create types up to H5I_MAX_NUM_TYPES */ - for(i = startType + 1; i < H5I_MAX_NUM_TYPES; i++) - { + for (i = startType + 1; i < H5I_MAX_NUM_TYPES; i++) { currentType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(currentType, H5I_BADID, "H5Iregister_type"); - if(currentType == H5I_BADID) + if (currentType == H5I_BADID) goto out; } /* Wrap around to low type ID numbers */ - for(i = H5I_NTYPES; i < startType; i++) - { + for (i = H5I_NTYPES; i < startType; i++) { currentType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(currentType, H5I_BADID, "H5Iregister_type"); - if(currentType == H5I_BADID) + if (currentType == H5I_BADID) goto out; } /* There should be no room at the inn for a new ID type*/ H5E_BEGIN_TRY - testType = H5Iregister_type((size_t)8, 0, free_wrapper); + testType = H5Iregister_type((size_t)8, 0, free_wrapper); H5E_END_TRY VERIFY(testType, H5I_BADID, "H5Iregister_type"); - if(testType != H5I_BADID) + if (testType != H5I_BADID) goto out; /* Now delete a type and try to insert again */ @@ -543,25 +546,25 @@ static int test_id_type_list(void) testType = H5Iregister_type((size_t)8, 0, free_wrapper); VERIFY(testType, H5I_NTYPES, "H5Iregister_type"); - if(testType != H5I_NTYPES) + if (testType != H5I_NTYPES) goto out; /* Cleanup. Destroy all types. */ - for(i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES; i++) - H5Idestroy_type((H5I_type_t) i); + for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES; i++) + H5Idestroy_type((H5I_type_t)i); return 0; out: /* Cleanup. For simplicity, just destroy all types and ignore errors. */ H5E_BEGIN_TRY - for(i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES; i++) - H5Idestroy_type((H5I_type_t) i); + for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES; i++) + H5Idestroy_type((H5I_type_t)i); H5E_END_TRY return -1; } - /* Test removing ids in callback for H5Iclear_type */ +/* Test removing ids in callback for H5Iclear_type */ /* There was a rare bug where, if an id free callback being called by * H5I_clear_type() removed another id in that type, a segfault could occur. @@ -570,48 +573,50 @@ out: /* Macro definitions */ #define TEST_RCT_MAX_NOBJS 25 #define TEST_RCT_MIN_NOBJS 5 -#define TEST_RCT_NITER 50 +#define TEST_RCT_NITER 50 /* Structure to hold the list of objects */ typedef struct { - struct test_rct_obj_t *list; /* List of objects */ - long nobjs; /* Number of objects in list */ - long nobjs_rem; /* Number of objects in list that have not been freed */ + struct test_rct_obj_t *list; /* List of objects */ + long nobjs; /* Number of objects in list */ + long nobjs_rem; /* Number of objects in list that have not been freed */ } test_rct_list_t; /* Structure for an object */ typedef struct test_rct_obj_t { - hid_t id; /* ID for this object */ - int nfrees; /* Number of times this object has been freed */ - hbool_t freeing; /* Whether we are currently freeing this object directly (through H5Idec_ref()) */ - test_rct_list_t *obj_list; /* List of all objects */ + hid_t id; /* ID for this object */ + int nfrees; /* Number of times this object has been freed */ + hbool_t freeing; /* Whether we are currently freeing this object directly (through H5Idec_ref()) */ + test_rct_list_t *obj_list; /* List of all objects */ } test_rct_obj_t; /* Free callback */ -static herr_t test_rct_free(void *_obj) { +static herr_t +test_rct_free(void *_obj) +{ test_rct_obj_t *obj = (test_rct_obj_t *)_obj; - long rem_idx, i; - herr_t ret; /* return value */ + long rem_idx, i; + herr_t ret; /* return value */ /* Mark this object as freed */ obj->nfrees++; obj->obj_list->nobjs_rem--; /* Check freeing and nobjs_rem */ - if(!obj->freeing && (obj->obj_list->nobjs_rem > 0)) { + if (!obj->freeing && (obj->obj_list->nobjs_rem > 0)) { /* Remove a random object from the list */ rem_idx = HDrandom() % obj->obj_list->nobjs_rem; /* Scan the list, finding the rem_idx'th object that has not been * freed */ - for(i = 0; i < obj->obj_list->nobjs; i++) - if(obj->obj_list->list[i].nfrees == 0) { - if(rem_idx == 0) + for (i = 0; i < obj->obj_list->nobjs; i++) + if (obj->obj_list->list[i].nfrees == 0) { + if (rem_idx == 0) break; else rem_idx--; } /* end if */ - if(i == obj->obj_list->nobjs) { + if (i == obj->obj_list->nobjs) { ERROR("invalid obj_list"); goto out; } /* end if */ @@ -619,16 +624,16 @@ static herr_t test_rct_free(void *_obj) { /* Remove the object. Mark as "freeing" so its own callback does * not free another object. */ obj->obj_list->list[i].freeing = TRUE; - ret = H5Idec_ref(obj->obj_list->list[i].id); + ret = H5Idec_ref(obj->obj_list->list[i].id); CHECK(ret, FAIL, "H5Idec_ref"); - if(ret == FAIL) + if (ret == FAIL) goto out; obj->obj_list->list[i].freeing = FALSE; } /* end else */ - } /* end if */ + } /* end if */ /* Verify nobjs_rem is non-negative */ - if(obj->obj_list->nobjs_rem < 0) { + if (obj->obj_list->nobjs_rem < 0) { ERROR("invalid nobjs_rem"); goto out; } /* end if */ @@ -640,110 +645,112 @@ out: } /* end test_rct_free() */ /* Test function */ -static int test_remove_clear_type(void) +static int +test_remove_clear_type(void) { - H5I_type_t obj_type; + H5I_type_t obj_type; test_rct_list_t obj_list; - test_rct_obj_t list[TEST_RCT_MAX_NOBJS]; - long i, j; - long nobjs_found; - hsize_t nmembers; - herr_t ret; /* return value */ + test_rct_obj_t list[TEST_RCT_MAX_NOBJS]; + long i, j; + long nobjs_found; + hsize_t nmembers; + herr_t ret; /* return value */ /* Register type */ obj_type = H5Iregister_type((size_t)8, 0, test_rct_free); CHECK(obj_type, H5I_BADID, "H5Iregister_type"); - if(obj_type == H5I_BADID) + if (obj_type == H5I_BADID) goto out; /* Init obj_list.list */ obj_list.list = list; - for(i = 0; i < TEST_RCT_NITER; i++) { + for (i = 0; i < TEST_RCT_NITER; i++) { /* Build object list */ - obj_list.nobjs = obj_list.nobjs_rem = TEST_RCT_MIN_NOBJS + (HDrandom() % (long)(TEST_RCT_MAX_NOBJS - TEST_RCT_MIN_NOBJS + 1)); - for(j = 0; j < obj_list.nobjs; j++) { - list[j].nfrees = 0; - list[j].freeing = FALSE; + obj_list.nobjs = obj_list.nobjs_rem = + TEST_RCT_MIN_NOBJS + (HDrandom() % (long)(TEST_RCT_MAX_NOBJS - TEST_RCT_MIN_NOBJS + 1)); + for (j = 0; j < obj_list.nobjs; j++) { + list[j].nfrees = 0; + list[j].freeing = FALSE; list[j].obj_list = &obj_list; - list[j].id = H5Iregister(obj_type, &list[j]); + list[j].id = H5Iregister(obj_type, &list[j]); CHECK(list[j].id, FAIL, "H5Iregister"); - if(list[j].id == FAIL) + if (list[j].id == FAIL) goto out; - if(HDrandom() % 2) { + if (HDrandom() % 2) { ret = H5Iinc_ref(list[j].id); CHECK(ret, FAIL, "H5Iinc_ref"); - if(ret == FAIL) + if (ret == FAIL) goto out; } /* end if */ - } /* end for */ + } /* end for */ /* Clear the type */ ret = H5Iclear_type(obj_type, FALSE); CHECK(ret, FAIL, "H5Iclear_type"); - if(ret == FAIL) + if (ret == FAIL) goto out; /* Verify list */ nobjs_found = 0; - for(j = 0; j < obj_list.nobjs; j++) { - if(list[j].nfrees == 0) + for (j = 0; j < obj_list.nobjs; j++) { + if (list[j].nfrees == 0) nobjs_found++; else { VERIFY(list[j].nfrees, (long)1, "list[j].nfrees"); - if(list[j].nfrees != (long)1) + if (list[j].nfrees != (long)1) goto out; } /* end else */ VERIFY(list[j].freeing, FALSE, "list[j].freeing"); - if(list[j].freeing != FALSE) + if (list[j].freeing != FALSE) goto out; } /* end for */ /* Verify number of objects */ VERIFY(obj_list.nobjs_rem, nobjs_found, "obj_list.nobjs_rem"); - if(obj_list.nobjs_rem != nobjs_found) + if (obj_list.nobjs_rem != nobjs_found) goto out; ret = H5Inmembers(obj_type, &nmembers); CHECK(ret, FAIL, "H5Inmembers"); - if(ret == FAIL) + if (ret == FAIL) goto out; VERIFY(nmembers, (size_t)nobjs_found, "H5Inmembers"); - if(nmembers != (size_t)nobjs_found) + if (nmembers != (size_t)nobjs_found) goto out; /* Clear the type with force set to TRUE */ ret = H5Iclear_type(obj_type, TRUE); CHECK(ret, FAIL, "H5Iclear_type"); - if(ret == FAIL) + if (ret == FAIL) goto out; /* Verify list */ - for(j = 0; j < obj_list.nobjs; j++) { + for (j = 0; j < obj_list.nobjs; j++) { VERIFY(list[j].nfrees, (long)1, "list[j].nfrees"); - if(list[j].nfrees != (long)1) + if (list[j].nfrees != (long)1) goto out; VERIFY(list[j].freeing, FALSE, "list[j].freeing"); - if(list[j].freeing != FALSE) + if (list[j].freeing != FALSE) goto out; } /* end for */ /* Verify number of objects is 0 */ VERIFY(obj_list.nobjs_rem, (long)0, "obj_list.nobjs_rem"); - if(obj_list.nobjs_rem != (long)0) + if (obj_list.nobjs_rem != (long)0) goto out; ret = H5Inmembers(obj_type, &nmembers); CHECK(ret, FAIL, "H5Inmembers"); - if(ret == FAIL) + if (ret == FAIL) goto out; VERIFY(nmembers, (size_t)0, "H5Inmembers"); - if(nmembers != (size_t)0) + if (nmembers != (size_t)0) goto out; } /* end for */ /* Destroy type */ ret = H5Idestroy_type(obj_type); CHECK(ret, FAIL, "H5Idestroy_type"); - if(ret == FAIL) + if (ret == FAIL) goto out; return 0; @@ -751,21 +758,27 @@ static int test_remove_clear_type(void) out: /* Cleanup. For simplicity, just destroy the types and ignore errors. */ H5E_BEGIN_TRY - H5Idestroy_type(obj_type); + H5Idestroy_type(obj_type); H5E_END_TRY return -1; } /* end test_remove_clear_type() */ -void test_ids(void) +void +test_ids(void) { /* Set the random # seed */ HDsrandom((unsigned)HDtime(NULL)); - if (basic_id_test() < 0) TestErrPrintf("Basic ID test failed\n"); - if (id_predefined_test() < 0) TestErrPrintf("Predefined ID type test failed\n"); - if (test_is_valid() < 0) TestErrPrintf("H5Iis_valid test failed\n"); - if (test_get_type() < 0) TestErrPrintf("H5Iget_type test failed\n"); - if (test_id_type_list() < 0) TestErrPrintf("ID type list test failed\n"); - if (test_remove_clear_type() < 0) TestErrPrintf("ID remove during H5Iclear_type test failed\n"); - + if (basic_id_test() < 0) + TestErrPrintf("Basic ID test failed\n"); + if (id_predefined_test() < 0) + TestErrPrintf("Predefined ID type test failed\n"); + if (test_is_valid() < 0) + TestErrPrintf("H5Iis_valid test failed\n"); + if (test_get_type() < 0) + TestErrPrintf("H5Iget_type test failed\n"); + if (test_id_type_list() < 0) + TestErrPrintf("ID type list test failed\n"); + if (test_remove_clear_type() < 0) + TestErrPrintf("ID remove during H5Iclear_type test failed\n"); } diff --git a/test/timer.c b/test/timer.c index 1014e75..e907655 100644 --- a/test/timer.c +++ b/test/timer.c @@ -22,9 +22,6 @@ #include "h5test.h" - - - /*------------------------------------------------------------------------- * Function: test_time_formatting * @@ -47,55 +44,55 @@ test_time_formatting(void) /* < 0, N/A */ s = H5_timer_get_time_string(-1.0F); - if(NULL == s || HDstrcmp(s, "N/A") != 0) + if (NULL == s || HDstrcmp(s, "N/A") != 0) TEST_ERROR; HDfree(s); /* 0 0 */ s = H5_timer_get_time_string(0.0F); - if(NULL == s || HDstrcmp(s, "0.0 s") != 0) + if (NULL == s || HDstrcmp(s, "0.0 s") != 0) TEST_ERROR; HDfree(s); /* < 1 us nanoseconds */ s = H5_timer_get_time_string(123.0E-9F); - if(NULL == s || HDstrcmp(s, "123 ns") != 0) + if (NULL == s || HDstrcmp(s, "123 ns") != 0) TEST_ERROR; HDfree(s); /* < 1 ms microseconds */ s = H5_timer_get_time_string(23.456E-6F); - if(NULL == s || HDstrcmp(s, "23.5 us") != 0) + if (NULL == s || HDstrcmp(s, "23.5 us") != 0) TEST_ERROR; HDfree(s); /* < 1 s milliseconds */ s = H5_timer_get_time_string(4.56789E-3F); - if(NULL == s || HDstrcmp(s, "4.6 ms") != 0) + if (NULL == s || HDstrcmp(s, "4.6 ms") != 0) TEST_ERROR; HDfree(s); /* < 1 min seconds */ s = H5_timer_get_time_string(3.14F); - if(NULL == s || HDstrcmp(s, "3.14 s") != 0) + if (NULL == s || HDstrcmp(s, "3.14 s") != 0) TEST_ERROR; HDfree(s); /* < 1 hr mins, secs */ s = H5_timer_get_time_string(2521.0F); - if(NULL == s || HDstrcmp(s, "42 m 1 s") != 0) + if (NULL == s || HDstrcmp(s, "42 m 1 s") != 0) TEST_ERROR; HDfree(s); /* < 1 d hrs, mins, secs */ s = H5_timer_get_time_string(9756.0F); - if(NULL == s || HDstrcmp(s, "2 h 42 m 36 s") != 0) + if (NULL == s || HDstrcmp(s, "2 h 42 m 36 s") != 0) TEST_ERROR; HDfree(s); /* > 1 d days, hrs, mins, secs */ s = H5_timer_get_time_string(280802.0F); - if(NULL == s || HDstrcmp(s, "3 d 6 h 0 m 2 s") != 0) + if (NULL == s || HDstrcmp(s, "3 d 6 h 0 m 2 s") != 0) TEST_ERROR; HDfree(s); @@ -103,13 +100,11 @@ test_time_formatting(void) return 0; error: - if(s) + if (s) HDfree(s); return -1; - } - /*------------------------------------------------------------------------- * Function: test_timer_system_user * @@ -130,47 +125,47 @@ error: static herr_t test_timer_system_user(void) { - int i; - char *buf = NULL; - H5_timer_t timer; - H5_timevals_t times; - herr_t err; + int i; + char * buf = NULL; + H5_timer_t timer; + H5_timevals_t times; + herr_t err; TESTING("system/user times"); err = H5_timer_init(&timer); - if(err < 0) + if (err < 0) TEST_ERROR; err = H5_timer_start(&timer); - if(err < 0) + if (err < 0) TEST_ERROR; /* The system and user times may not be present on some systems. They - * will be -1.0 if they are not. + * will be -1.0 if they are not. */ - if(timer.initial.system < (double)0.0f || timer.initial.user < (double)0.0f) { + if (timer.initial.system < (double)0.0f || timer.initial.user < (double)0.0f) { SKIPPED(); printf("NOTE: No suitable way to get system/user times on this platform.\n"); return 0; } /* Do some fake work */ - for(i=0; i < 1024; i++) { + for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } err = H5_timer_stop(&timer); - if(err < 0) + if (err < 0) TEST_ERROR; err = H5_timer_get_times(timer, ×); - if(err < 0) + if (err < 0) TEST_ERROR; /* System and user times should be non-negative. */ - if(times.system < (double)0.0f || times.user < (double)0.0f) + if (times.system < (double)0.0f || times.user < (double)0.0f) TEST_ERROR; PASSED(); @@ -180,7 +175,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: test_timer_elapsed * @@ -199,38 +193,38 @@ error: static herr_t test_timer_elapsed(void) { - int i; - char *buf = NULL; - H5_timer_t timer; - H5_timevals_t times; - herr_t err; + int i; + char * buf = NULL; + H5_timer_t timer; + H5_timevals_t times; + herr_t err; TESTING("elapsed times"); err = H5_timer_init(&timer); - if(err < 0) + if (err < 0) TEST_ERROR; err = H5_timer_start(&timer); - if(err < 0) + if (err < 0) TEST_ERROR; /* Do some fake work */ - for(i=0; i < 1024; i++) { + for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } err = H5_timer_stop(&timer); - if(err < 0) + if (err < 0) TEST_ERROR; err = H5_timer_get_times(timer, ×); - if(err < 0) + if (err < 0) TEST_ERROR; /* Elapsed time should be non-negative. */ - if(times.elapsed < (double)0.0f) + if (times.elapsed < (double)0.0f) TEST_ERROR; PASSED(); @@ -240,20 +234,18 @@ error: return -1; } - - static herr_t test_timer_functionality(void) { - int i; - char *buf = NULL; - H5_timer_t timer; + int i; + char * buf = NULL; + H5_timer_t timer; - H5_timevals_t times; - double prev_etime; - double prev_total_etime; + H5_timevals_t times; + double prev_etime; + double prev_total_etime; - herr_t err; + herr_t err; TESTING("timer functionality"); @@ -263,109 +255,106 @@ test_timer_functionality(void) /* Timer should be running after start */ err = H5_timer_init(&timer); - if(err < 0 || timer.is_running) + if (err < 0 || timer.is_running) TEST_ERROR; /* Times should be initialized to zero */ err = H5_timer_get_times(timer, ×); - if(err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) TEST_ERROR; err = H5_timer_get_total_times(timer, ×); - if(err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) TEST_ERROR; - /******************** * CHECK START/STOP * ********************/ /* Running state should change after start */ err = H5_timer_start(&timer); - if(err < 0 || !timer.is_running) + if (err < 0 || !timer.is_running) TEST_ERROR; /* Do some fake work */ - for(i=0; i < 1024; i++) { + for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } /* Running state should change after stop */ err = H5_timer_stop(&timer); - if(err < 0 || timer.is_running) + if (err < 0 || timer.is_running) TEST_ERROR; /* Times should be positive and non-negative */ err = H5_timer_get_times(timer, ×); - if(err < 0 || times.elapsed < (double)0.0f) + if (err < 0 || times.elapsed < (double)0.0f) TEST_ERROR; err = H5_timer_get_total_times(timer, ×); - if(err < 0 || times.elapsed < (double)0.0f) + if (err < 0 || times.elapsed < (double)0.0f) TEST_ERROR; - /********************** * CHECK INTERRUPTING * **********************/ /* Timer should change stat and refresh to 0s */ err = H5_timer_init(&timer); - if(err < 0 || timer.is_running) + if (err < 0 || timer.is_running) TEST_ERROR; err = H5_timer_get_times(timer, ×); - if(err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) TEST_ERROR; err = H5_timer_get_total_times(timer, ×); - if(err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) TEST_ERROR; /* Timer state should flip */ err = H5_timer_start(&timer); - if(err < 0 || !timer.is_running) + if (err < 0 || !timer.is_running) TEST_ERROR; /* Do some fake work */ - for(i=0; i < 1024; i++) { + for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } /* Times should be non-negative */ err = H5_timer_get_times(timer, ×); - if(err < 0 || times.elapsed < (double)0.0f) + if (err < 0 || times.elapsed < (double)0.0f) TEST_ERROR; prev_etime = times.elapsed; err = H5_timer_get_total_times(timer, ×); - if(err < 0 || times.elapsed < (double)0.0f) + if (err < 0 || times.elapsed < (double)0.0f) TEST_ERROR; prev_total_etime = times.elapsed; /* Do some fake work */ - for(i=0; i < 1024; i++) { + for (i = 0; i < 1024; i++) { buf = (char *)HDmalloc(1024 * (size_t)i); HDfree(buf); } /* State should flip on stop */ err = H5_timer_stop(&timer); - if(err < 0 || timer.is_running) + if (err < 0 || timer.is_running) TEST_ERROR; /* Times should be >= than the cached intermediate times */ err = H5_timer_get_times(timer, ×); - if(err < 0 || times.elapsed < prev_etime) + if (err < 0 || times.elapsed < prev_etime) TEST_ERROR; err = H5_timer_get_total_times(timer, ×); - if(err < 0 || times.elapsed < prev_total_etime) + if (err < 0 || times.elapsed < prev_total_etime) TEST_ERROR; - PASSED(); return 0; @@ -373,7 +362,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: main * @@ -391,24 +379,23 @@ error: int main(void) { - int nerrors = 0; + int nerrors = 0; h5_reset(); printf("Testing platform-independent timer functionality.\n"); - nerrors += test_time_formatting() < 0 ? 1 : 0; - nerrors += test_timer_system_user() < 0 ? 1 : 0; - nerrors += test_timer_elapsed() < 0 ? 1 : 0; - nerrors += test_timer_functionality() < 0 ? 1 : 0; + nerrors += test_time_formatting() < 0 ? 1 : 0; + nerrors += test_timer_system_user() < 0 ? 1 : 0; + nerrors += test_timer_elapsed() < 0 ? 1 : 0; + nerrors += test_timer_functionality() < 0 ? 1 : 0; - if(nerrors) { - printf("***** %d platform-independent timer TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + if (nerrors) { + printf("***** %d platform-independent timer TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); return 1; - } else { + } + else { printf("All platform-independent timer tests passed.\n"); return 0; } } - diff --git a/test/titerate.c b/test/titerate.c index 9d60915..aead4e2 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -12,17 +12,17 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: titerate -* -* Test the Group & Attribute functionality -* -*************************************************************/ + * + * Test program: titerate + * + * Test the Group & Attribute functionality + * + *************************************************************/ #include "testhdf5.h" #include "H5srcdir.h" -#define DATAFILE "titerate.h5" +#define DATAFILE "titerate.h5" /* Number of datasets for group iteration test */ #define NDATASETS 50 @@ -34,29 +34,24 @@ #define ITER_NGROUPS 150 /* General maximum length of names used */ -#define NAMELEN 80 +#define NAMELEN 80 /* 1-D dataset with fixed dimensions */ -#define SPACE1_RANK 1 -#define SPACE1_DIM1 4 +#define SPACE1_RANK 1 +#define SPACE1_DIM1 4 -typedef enum { - RET_ZERO, - RET_TWO, - RET_CHANGE, - RET_CHANGE2 -} iter_enum; +typedef enum { RET_ZERO, RET_TWO, RET_CHANGE, RET_CHANGE2 } iter_enum; /* Custom group iteration callback data */ typedef struct { - char name[NAMELEN]; /* The name of the object */ - H5O_type_t type; /* The type of the object */ - iter_enum command; /* The type of return value */ + char name[NAMELEN]; /* The name of the object */ + H5O_type_t type; /* The type of the object */ + iter_enum command; /* The type of return value */ } iter_info; /* Definition for test_corrupted_attnamelen */ -#define CORRUPTED_ATNAMELEN_FILE "memleak_H5O_dtype_decode_helper_H5Odtype.h5" -#define DSET_NAME "image" +#define CORRUPTED_ATNAMELEN_FILE "memleak_H5O_dtype_decode_helper_H5Odtype.h5" +#define DSET_NAME "image" typedef struct searched_err_t { char message[256]; bool found; @@ -66,23 +61,21 @@ typedef struct searched_err_t { static int find_err_msg_cb(unsigned n, const H5E_error2_t *err_desc, void *_client_data); /* Local functions */ -int iter_strcmp(const void *s1, const void *s2); -int iter_strcmp2(const void *s1, const void *s2); -static herr_t liter_cb(hid_t group, const char *name, const H5L_info2_t *info, - void *op_data); -static herr_t liter_cb2(hid_t group, const char *name, const H5L_info2_t *info, - void *op_data); -herr_t aiter_cb(hid_t group, const char *name, const H5A_info_t *ainfo, - void *op_data); +int iter_strcmp(const void *s1, const void *s2); +int iter_strcmp2(const void *s1, const void *s2); +static herr_t liter_cb(hid_t group, const char *name, const H5L_info2_t *info, void *op_data); +static herr_t liter_cb2(hid_t group, const char *name, const H5L_info2_t *info, void *op_data); +herr_t aiter_cb(hid_t group, const char *name, const H5A_info_t *ainfo, void *op_data); /**************************************************************** ** ** iter_strcmp(): String comparison routine for qsort ** ****************************************************************/ -H5_ATTR_PURE int iter_strcmp(const void *s1, const void *s2) +H5_ATTR_PURE int +iter_strcmp(const void *s1, const void *s2) { - return(HDstrcmp(*(const char * const *)s1,*(const char * const *)s2)); + return (HDstrcmp(*(const char *const *)s1, *(const char *const *)s2)); } /**************************************************************** @@ -92,32 +85,32 @@ H5_ATTR_PURE int iter_strcmp(const void *s1, const void *s2) ****************************************************************/ static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, - void *op_data) + void *op_data) { - iter_info *info = (iter_info *)op_data; - static int count = 0; + iter_info *info = (iter_info *)op_data; + static int count = 0; static int count2 = 0; HDstrcpy(info->name, name); - switch(info->command) { + switch (info->command) { case RET_ZERO: - return(0); + return (0); case RET_TWO: - return(2); + return (2); case RET_CHANGE: count++; - return(count > 10 ? 1 : 0); + return (count > 10 ? 1 : 0); case RET_CHANGE2: count2++; - return(count2 > 10 ? 1 : 0); + return (count2 > 10 ? 1 : 0); default: HDprintf("invalid iteration command"); - return(-1); + return (-1); } /* end switch */ } /* end liter_cb() */ @@ -129,19 +122,19 @@ liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR static void test_iter_group(hid_t fapl, hbool_t new_format) { - hid_t file; /* File ID */ - hid_t dataset; /* Dataset ID */ - hid_t datatype; /* Common datatype ID */ - hid_t filespace; /* Common dataspace ID */ - hid_t root_group,grp; /* Root group ID */ - int i; /* counting variable */ - hsize_t idx; /* Index in the group */ - char name[NAMELEN]; /* temporary name buffer */ - char *lnames[NDATASETS + 2];/* Names of the links created */ - char dataset_name[NAMELEN]; /* dataset name */ - iter_info info; /* Custom iteration information */ - H5G_info_t ginfo; /* Buffer for querying object's info */ - herr_t ret; /* Generic return value */ + hid_t file; /* File ID */ + hid_t dataset; /* Dataset ID */ + hid_t datatype; /* Common datatype ID */ + hid_t filespace; /* Common dataspace ID */ + hid_t root_group, grp; /* Root group ID */ + int i; /* counting variable */ + hsize_t idx; /* Index in the group */ + char name[NAMELEN]; /* temporary name buffer */ + char * lnames[NDATASETS + 2]; /* Names of the links created */ + char dataset_name[NAMELEN]; /* dataset name */ + iter_info info; /* Custom iteration information */ + H5G_info_t ginfo; /* Buffer for querying object's info */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Group Iteration Functionality\n")); @@ -152,18 +145,18 @@ test_iter_group(hid_t fapl, hbool_t new_format) /* Test iterating over empty group */ info.command = RET_ZERO; - idx = 0; - ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); + idx = 0; + ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); VERIFY(ret, SUCCEED, "H5Literate2"); datatype = H5Tcopy(H5T_NATIVE_INT); CHECK(datatype, FAIL, "H5Tcopy"); - filespace=H5Screate(H5S_SCALAR); + filespace = H5Screate(H5S_SCALAR); CHECK(filespace, FAIL, "H5Screate"); - for(i=0; i< NDATASETS; i++) { - HDsprintf(name,"Dataset %d",i); + for (i = 0; i < NDATASETS; i++) { + HDsprintf(name, "Dataset %d", i); dataset = H5Dcreate2(file, name, datatype, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); @@ -204,7 +197,6 @@ test_iter_group(hid_t fapl, hbool_t new_format) /* Sort the dataset names */ HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp); - /* Iterate through the datasets in the root group in various ways */ file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); CHECK(file, FAIL, "H5Fopen"); @@ -219,19 +211,25 @@ test_iter_group(hid_t fapl, hbool_t new_format) CHECK(ret, FAIL, "H5Gget_info"); VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info"); - for(i = 0; i< (int)ginfo.nlinks; i++) { - H5O_info2_t oinfo; /* Object info */ + for (i = 0; i < (int)ginfo.nlinks; i++) { + H5O_info2_t oinfo; /* Object info */ - ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT); + ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, + dataset_name, (size_t)NAMELEN, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lget_name_by_idx"); - ret = H5Oget_info_by_idx3(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, + H5O_INFO_BASIC, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_idx"); } /* end for */ - H5E_BEGIN_TRY { - ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)(NDATASETS+3), dataset_name, (size_t)NAMELEN, H5P_DEFAULT); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = + (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)(NDATASETS + 3), + dataset_name, (size_t)NAMELEN, H5P_DEFAULT); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Lget_name_by_idx"); ret = H5Gclose(root_group); @@ -245,55 +243,66 @@ test_iter_group(hid_t fapl, hbool_t new_format) CHECK(ret, FAIL, "H5Gget_info"); VERIFY(ginfo.nlinks, NDATASETS + 2, "H5Gget_info"); - for(i = 0; i< (int)ginfo.nlinks; i++) { - H5O_info2_t oinfo; /* Object info */ + for (i = 0; i < (int)ginfo.nlinks; i++) { + H5O_info2_t oinfo; /* Object info */ - ret = (herr_t)H5Lget_name_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT); + ret = (herr_t)H5Lget_name_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, + (size_t)NAMELEN, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lget_name_by_idx"); - ret = H5Oget_info_by_idx3(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5O_INFO_BASIC, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_idx3"); } /* end for */ - H5E_BEGIN_TRY { - ret = (herr_t)H5Lget_name_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)(NDATASETS + 3), dataset_name, (size_t)NAMELEN, H5P_DEFAULT); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = (herr_t)H5Lget_name_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)(NDATASETS + 3), + dataset_name, (size_t)NAMELEN, H5P_DEFAULT); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Lget_name_by_idx"); /* Test invalid indices for starting iteration */ info.command = RET_ZERO; - idx = (hsize_t)-1; - H5E_BEGIN_TRY { + idx = (hsize_t)-1; + H5E_BEGIN_TRY + { ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Literate2"); /* Test skipping exactly as many entries as in the group */ idx = NDATASETS + 2; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Literate2"); /* Test skipping more entries than are in the group */ idx = NDATASETS + 3; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Literate2"); /* Test all objects in group, when callback always returns 0 */ info.command = RET_ZERO; - idx = 0; - if((ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) > 0) + idx = 0; + if ((ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) > 0) TestErrPrintf("Group iteration function didn't return zero correctly!\n"); /* Test all objects in group, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ info.command = RET_TWO; - i = 0; - idx = 0; - while((ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) > 0) { + i = 0; + idx = 0; + while ((ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 2, "H5Literate2"); @@ -302,24 +311,27 @@ test_iter_group(hid_t fapl, hbool_t new_format) /* Verify that the index is the correct value */ VERIFY(idx, (hsize_t)i, "H5Literate2"); - if(idx > (NDATASETS + 2)) + if (idx > (NDATASETS + 2)) TestErrPrintf("Group iteration function walked too far!\n"); /* Verify that the correct name is retrieved */ - if(HDstrcmp(info.name, lnames[(size_t)(idx - 1)]) != 0) - TestErrPrintf("Group iteration function didn't return name correctly for link - lnames[%u] = '%s'!\n", (unsigned)(idx - 1), lnames[(size_t)(idx - 1)]); + if (HDstrcmp(info.name, lnames[(size_t)(idx - 1)]) != 0) + TestErrPrintf( + "Group iteration function didn't return name correctly for link - lnames[%u] = '%s'!\n", + (unsigned)(idx - 1), lnames[(size_t)(idx - 1)]); } /* end while */ VERIFY(ret, -1, "H5Literate2"); - if(i != (NDATASETS + 2)) - TestErrPrintf("%u: Group iteration function didn't perform multiple iterations correctly!\n", __LINE__); + if (i != (NDATASETS + 2)) + TestErrPrintf("%u: Group iteration function didn't perform multiple iterations correctly!\n", + __LINE__); /* Test all objects in group, when callback changes return value */ /* This also tests the "restarting" ability, because the index changes */ info.command = new_format ? RET_CHANGE2 : RET_CHANGE; - i = 0; - idx = 0; - while((ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) >= 0) { + i = 0; + idx = 0; + while ((ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) >= 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 1, "H5Literate2"); @@ -328,23 +340,26 @@ test_iter_group(hid_t fapl, hbool_t new_format) /* Verify that the index is the correct value */ VERIFY(idx, (hsize_t)(i + 10), "H5Literate2"); - if(idx > (NDATASETS + 2)) + if (idx > (NDATASETS + 2)) TestErrPrintf("Group iteration function walked too far!\n"); /* Verify that the correct name is retrieved */ - if(HDstrcmp(info.name, lnames[(size_t)(idx - 1)]) != 0) - TestErrPrintf("Group iteration function didn't return name correctly for link - lnames[%u] = '%s'!\n", (unsigned)(idx - 1), lnames[(size_t)(idx - 1)]); + if (HDstrcmp(info.name, lnames[(size_t)(idx - 1)]) != 0) + TestErrPrintf( + "Group iteration function didn't return name correctly for link - lnames[%u] = '%s'!\n", + (unsigned)(idx - 1), lnames[(size_t)(idx - 1)]); } /* end while */ VERIFY(ret, -1, "H5Literate2"); - if(i != 42 || idx != 52) - TestErrPrintf("%u: Group iteration function didn't perform multiple iterations correctly!\n", __LINE__); + if (i != 42 || idx != 52) + TestErrPrintf("%u: Group iteration function didn't perform multiple iterations correctly!\n", + __LINE__); ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Free the dataset names */ - for(i = 0; i< (NDATASETS + 2); i++) + for (i = 0; i < (NDATASETS + 2); i++) HDfree(lnames[i]); } /* test_iter_group() */ @@ -354,33 +369,32 @@ test_iter_group(hid_t fapl, hbool_t new_format) ** ****************************************************************/ herr_t -aiter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5A_info_t H5_ATTR_UNUSED *ainfo, - void *op_data) +aiter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *op_data) { - iter_info *info = (iter_info *)op_data; - static int count = 0; + iter_info *info = (iter_info *)op_data; + static int count = 0; static int count2 = 0; HDstrcpy(info->name, name); - switch(info->command) { + switch (info->command) { case RET_ZERO: - return(0); + return (0); case RET_TWO: - return(2); + return (2); case RET_CHANGE: count++; - return(count > 10 ? 1 : 0); + return (count > 10 ? 1 : 0); case RET_CHANGE2: count2++; - return(count2 > 10 ? 1 : 0); + return (count2 > 10 ? 1 : 0); default: HDprintf("invalid iteration command"); - return(-1); + return (-1); } /* end switch */ } /* end aiter_cb() */ @@ -389,18 +403,19 @@ aiter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5A_info_t H5_ATTR_ ** test_iter_attr(): Test attribute iteration functionality ** ****************************************************************/ -static void test_iter_attr(hid_t fapl, hbool_t new_format) +static void +test_iter_attr(hid_t fapl, hbool_t new_format) { - hid_t file; /* File ID */ - hid_t dataset; /* Common Dataset ID */ - hid_t filespace; /* Common dataspace ID */ - hid_t attribute; /* Attribute ID */ - int i; /* counting variable */ - hsize_t idx; /* Index in the attribute list */ - char name[NAMELEN]; /* temporary name buffer */ - char *anames[NATTR]; /* Names of the attributes created */ - iter_info info; /* Custom iteration information */ - herr_t ret; /* Generic return value */ + hid_t file; /* File ID */ + hid_t dataset; /* Common Dataset ID */ + hid_t filespace; /* Common dataspace ID */ + hid_t attribute; /* Attribute ID */ + int i; /* counting variable */ + hsize_t idx; /* Index in the attribute list */ + char name[NAMELEN]; /* temporary name buffer */ + char * anames[NATTR]; /* Names of the attributes created */ + iter_info info; /* Custom iteration information */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Iteration Functionality\n")); @@ -415,7 +430,7 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) dataset = H5Dcreate2(file, "Dataset", H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); - for(i = 0; i < NATTR; i++) { + for (i = 0; i < NATTR; i++) { HDsprintf(name, "Attribute %02d", i); attribute = H5Acreate2(dataset, name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT); CHECK(attribute, FAIL, "H5Acreate2"); @@ -438,7 +453,6 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); - /* Iterate through the attributes on the dataset in various ways */ file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); CHECK(file, FAIL, "H5Fopen"); @@ -451,30 +465,34 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) /* Test skipping exactly as many attributes as there are */ idx = NATTR; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Aiterate2"); /* Test skipping more attributes than there are */ idx = NATTR + 1; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Aiterate2"); /* Test all attributes on dataset, when callback always returns 0 */ info.command = RET_ZERO; - idx = 0; - if((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) + idx = 0; + if ((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) TestErrPrintf("Attribute iteration function didn't return zero correctly!\n"); /* Test all attributes on dataset, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ info.command = RET_TWO; - i = 0; - idx = 0; - while((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) { + i = 0; + idx = 0; + while ((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 2, "H5Aiterate2"); @@ -485,23 +503,25 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) VERIFY(idx, (unsigned)i, "H5Aiterate2"); /* Don't check name when new format is used */ - if(!new_format) { + if (!new_format) { /* Verify that the correct name is retrieved */ - if(HDstrcmp(info.name, anames[(size_t)idx - 1]) != 0) - TestErrPrintf("%u: Attribute iteration function didn't set names correctly, info.name = '%s', anames[%u] = '%s'!\n", __LINE__, info.name, (unsigned)(idx - 1), anames[(size_t)idx - 1]); + if (HDstrcmp(info.name, anames[(size_t)idx - 1]) != 0) + TestErrPrintf("%u: Attribute iteration function didn't set names correctly, info.name = " + "'%s', anames[%u] = '%s'!\n", + __LINE__, info.name, (unsigned)(idx - 1), anames[(size_t)idx - 1]); } /* end if */ - } /* end while */ + } /* end while */ VERIFY(ret, -1, "H5Aiterate2"); - if(i != 50 || idx != 50) - TestErrPrintf("%u: Attribute iteration function didn't perform multiple iterations correctly!\n", __LINE__); - + if (i != 50 || idx != 50) + TestErrPrintf("%u: Attribute iteration function didn't perform multiple iterations correctly!\n", + __LINE__); /* Test all attributes on dataset, when callback changes return value */ /* This also tests the "restarting" ability, because the index changes */ info.command = new_format ? RET_CHANGE2 : RET_CHANGE; - i = 0; - idx = 0; - while((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) { + i = 0; + idx = 0; + while ((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 1, "H5Aiterate2"); @@ -512,24 +532,27 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) VERIFY(idx, (unsigned)i + 10, "H5Aiterate2"); /* Don't check name when new format is used */ - if(!new_format) { + if (!new_format) { /* Verify that the correct name is retrieved */ - if(HDstrcmp(info.name, anames[(size_t)idx - 1]) != 0) - TestErrPrintf("%u: Attribute iteration function didn't set names correctly, info.name = '%s', anames[%u] = '%s'!\n", __LINE__, info.name, (unsigned)(idx - 1), anames[(size_t)idx - 1]); + if (HDstrcmp(info.name, anames[(size_t)idx - 1]) != 0) + TestErrPrintf("%u: Attribute iteration function didn't set names correctly, info.name = " + "'%s', anames[%u] = '%s'!\n", + __LINE__, info.name, (unsigned)(idx - 1), anames[(size_t)idx - 1]); } /* end if */ - } /* end while */ + } /* end while */ VERIFY(ret, -1, "H5Aiterate2"); - if(i != 40 || idx != 50) - TestErrPrintf("%u: Attribute iteration function didn't perform multiple iterations correctly!\n", __LINE__); + if (i != 40 || idx != 50) + TestErrPrintf("%u: Attribute iteration function didn't perform multiple iterations correctly!\n", + __LINE__); - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); - ret=H5Dclose(dataset); + ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); /* Free the attribute names */ - for(i=0; i< NATTR; i++) + for (i = 0; i < NATTR; i++) HDfree(anames[i]); } /* test_iter_attr() */ @@ -539,9 +562,10 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) ** iter_strcmp2(): String comparison routine for qsort ** ****************************************************************/ -H5_ATTR_PURE int iter_strcmp2(const void *s1, const void *s2) +H5_ATTR_PURE int +iter_strcmp2(const void *s1, const void *s2) { - return(HDstrcmp((const char *)s1, (const char *)s2)); + return (HDstrcmp((const char *)s1, (const char *)s2)); } /* end iter_strcmp2() */ /**************************************************************** @@ -550,16 +574,15 @@ H5_ATTR_PURE int iter_strcmp2(const void *s1, const void *s2) ** ****************************************************************/ static herr_t -liter_cb2(hid_t loc_id, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, - void *opdata) +liter_cb2(hid_t loc_id, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, void *opdata) { const iter_info *test_info = (const iter_info *)opdata; - H5O_info2_t oinfo; - herr_t ret; /* Generic return value */ + H5O_info2_t oinfo; + herr_t ret; /* Generic return value */ - if(HDstrcmp(name, test_info->name)) { + if (HDstrcmp(name, test_info->name)) { TestErrPrintf("name = '%s', test_info = '%s'\n", name, test_info->name); - return(H5_ITER_ERROR); + return (H5_ITER_ERROR); } /* end if */ /* @@ -568,12 +591,12 @@ liter_cb2(hid_t loc_id, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link ret = H5Oget_info_by_name3(loc_id, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name3"); - if(test_info->type != oinfo.type) { + if (test_info->type != oinfo.type) { TestErrPrintf("test_info->type = %d, oinfo.type = %d\n", test_info->type, (int)oinfo.type); - return(H5_ITER_ERROR); + return (H5_ITER_ERROR); } /* end if */ - return(H5_ITER_STOP); + return (H5_ITER_STOP); } /* liter_cb2() */ /**************************************************************** @@ -585,23 +608,23 @@ liter_cb2(hid_t loc_id, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link static void test_iter_group_large(hid_t fapl) { - hid_t file; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hsize_t dims[] = {SPACE1_DIM1}; - herr_t ret; /* Generic return value */ - char gname[20]; /* Temporary group name */ - iter_info *names; /* Names of objects in the root group */ - iter_info *curr_name; /* Pointer to the current name in the root group */ - int i; + hid_t file; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t dims[] = {SPACE1_DIM1}; + herr_t ret; /* Generic return value */ + char gname[20]; /* Temporary group name */ + iter_info *names; /* Names of objects in the root group */ + iter_info *curr_name; /* Pointer to the current name in the root group */ + int i; /* Compound datatype */ typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; /* Allocate & initialize array */ @@ -620,7 +643,7 @@ test_iter_group_large(hid_t fapl) CHECK(sid, FAIL, "H5Screate_simple"); /* Create a bunch of groups */ - for(i = 0; i < ITER_NGROUPS; i++) { + for (i = 0; i < ITER_NGROUPS; i++) { HDsprintf(gname, "Group_%d", i); /* Add the name to the list of objects in the root group */ @@ -683,13 +706,13 @@ test_iter_group_large(hid_t fapl) /* Iterate through the file to see members of the root group */ curr_name = &names[0]; - ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, NULL, liter_cb2, curr_name); + ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, NULL, liter_cb2, curr_name); CHECK(ret, FAIL, "H5Literate2"); - for(i = 1; i < 100; i++) { + for (i = 1; i < 100; i++) { hsize_t idx = (hsize_t)i; curr_name = &names[i]; - ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb2, curr_name); + ret = H5Literate2(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb2, curr_name); CHECK(ret, FAIL, "H5Literate2"); } /* end for */ @@ -707,21 +730,22 @@ test_iter_group_large(hid_t fapl) ** functionality ** ****************************************************************/ -static void test_grp_memb_funcs(hid_t fapl) +static void +test_grp_memb_funcs(hid_t fapl) { - hid_t file; /* File ID */ - hid_t dataset; /* Dataset ID */ - hid_t datatype; /* Common datatype ID */ - hid_t filespace; /* Common dataspace ID */ - hid_t root_group,grp; /* Root group ID */ - int i; /* counting variable */ - char name[NAMELEN]; /* temporary name buffer */ - char *dnames[NDATASETS+2];/* Names of the datasets created */ - char *obj_names[NDATASETS+2];/* Names of the objects in group */ - char dataset_name[NAMELEN]; /* dataset name */ - ssize_t name_len; /* Length of object's name */ - H5G_info_t ginfo; /* Buffer for querying object's info */ - herr_t ret = SUCCEED; /* Generic return value */ + hid_t file; /* File ID */ + hid_t dataset; /* Dataset ID */ + hid_t datatype; /* Common datatype ID */ + hid_t filespace; /* Common dataspace ID */ + hid_t root_group, grp; /* Root group ID */ + int i; /* counting variable */ + char name[NAMELEN]; /* temporary name buffer */ + char * dnames[NDATASETS + 2]; /* Names of the datasets created */ + char * obj_names[NDATASETS + 2]; /* Names of the objects in group */ + char dataset_name[NAMELEN]; /* dataset name */ + ssize_t name_len; /* Length of object's name */ + H5G_info_t ginfo; /* Buffer for querying object's info */ + herr_t ret = SUCCEED; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Group Member Information Functionality\n")); @@ -736,7 +760,7 @@ static void test_grp_memb_funcs(hid_t fapl) filespace = H5Screate(H5S_SCALAR); CHECK(filespace, FAIL, "H5Screate"); - for(i = 0; i < NDATASETS; i++) { + for (i = 0; i < NDATASETS; i++) { HDsprintf(name, "Dataset %d", i); dataset = H5Dcreate2(file, name, datatype, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); @@ -792,14 +816,16 @@ static void test_grp_memb_funcs(hid_t fapl) CHECK(ret, FAIL, "H5Gget_info"); VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info"); - for(i = 0; i < (int)ginfo.nlinks; i++) { - H5O_info2_t oinfo; /* Object info */ + for (i = 0; i < (int)ginfo.nlinks; i++) { + H5O_info2_t oinfo; /* Object info */ /* Test with NULL for name, to query length */ - name_len = H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, NULL, (size_t)NAMELEN, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, NULL, + (size_t)NAMELEN, H5P_DEFAULT); CHECK(name_len, FAIL, "H5Lget_name_by_idx"); - ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)(name_len + 1), H5P_DEFAULT); + ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, + dataset_name, (size_t)(name_len + 1), H5P_DEFAULT); CHECK(ret, FAIL, "H5Lget_name_by_idx"); /* Double-check that the length is the same */ @@ -809,27 +835,32 @@ static void test_grp_memb_funcs(hid_t fapl) obj_names[i] = HDstrdup(dataset_name); CHECK_PTR(obj_names[i], "strdup"); - ret = H5Oget_info_by_idx3(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, + H5O_INFO_BASIC, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_idx3"); - if(!HDstrcmp(dataset_name, "grp")) + if (!HDstrcmp(dataset_name, "grp")) VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx"); - if(!HDstrcmp(dataset_name, "dtype")) + if (!HDstrcmp(dataset_name, "dtype")) VERIFY(oinfo.type, H5O_TYPE_NAMED_DATATYPE, "H5Lget_name_by_idx"); - if(!HDstrncmp(dataset_name, "Dataset", (size_t)7)) + if (!HDstrncmp(dataset_name, "Dataset", (size_t)7)) VERIFY(oinfo.type, H5O_TYPE_DATASET, "H5Lget_name_by_idx"); } /* end for */ - H5E_BEGIN_TRY { - ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)(NDATASETS+3), dataset_name, (size_t)NAMELEN, H5P_DEFAULT); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = + (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)(NDATASETS + 3), + dataset_name, (size_t)NAMELEN, H5P_DEFAULT); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Lget_name_by_idx"); /* Sort the dataset names */ HDqsort(obj_names, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp); /* Compare object names */ - for(i = 0; i< (int)ginfo.nlinks; i++) { + for (i = 0; i < (int)ginfo.nlinks; i++) { ret = HDstrcmp(dnames[i], obj_names[i]); VERIFY(ret, 0, "HDstrcmp"); } /* end for */ @@ -837,12 +868,11 @@ static void test_grp_memb_funcs(hid_t fapl) ret = H5Gclose(root_group); CHECK(ret, FAIL, "H5Gclose"); - ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Free the dataset names */ - for(i = 0; i< (NDATASETS + 2); i++) { + for (i = 0; i < (NDATASETS + 2); i++) { HDfree(dnames[i]); HDfree(obj_names[i]); } /* end for */ @@ -853,15 +883,16 @@ static void test_grp_memb_funcs(hid_t fapl) ** test_links(): Test soft and hard link iteration ** ****************************************************************/ -static void test_links(hid_t fapl) +static void +test_links(hid_t fapl) { - hid_t file; /* File ID */ - char obj_name[NAMELEN]; /* Names of the object in group */ - ssize_t name_len; /* Length of object's name */ - hid_t gid, gid1; - H5G_info_t ginfo; /* Buffer for querying object's info */ - hsize_t i; - herr_t ret; /* Generic return value */ + hid_t file; /* File ID */ + char obj_name[NAMELEN]; /* Names of the object in group */ + ssize_t name_len; /* Length of object's name */ + hid_t gid, gid1; + H5G_info_t ginfo; /* Buffer for querying object's info */ + hsize_t i; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Soft and Hard Link Iteration Functionality\n")); @@ -889,12 +920,13 @@ static void test_links(hid_t fapl) VERIFY(ginfo.nlinks, 3, "H5Gget_info"); /* Test these two functions, H5Oget_info_by_idx and H5Lget_name_by_idx */ - for(i = 0; i < ginfo.nlinks; i++) { - H5O_info2_t oinfo; /* Object info */ - H5L_info2_t linfo; /* Link info */ + for (i = 0; i < ginfo.nlinks; i++) { + H5O_info2_t oinfo; /* Object info */ + H5L_info2_t linfo; /* Link info */ /* Get link name */ - name_len = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, i, obj_name, (size_t)NAMELEN, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, i, obj_name, (size_t)NAMELEN, + H5P_DEFAULT); CHECK(name_len, FAIL, "H5Lget_name_by_idx"); /* Get link type */ @@ -902,16 +934,17 @@ static void test_links(hid_t fapl) CHECK(ret, FAIL, "H5Lget_info_by_idx2"); /* Get object type */ - if(linfo.type == H5L_TYPE_HARD) { - ret = H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + if (linfo.type == H5L_TYPE_HARD) { + ret = H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, + H5O_INFO_BASIC, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_idx3"); } /* end if */ - if(!HDstrcmp(obj_name, "g1.1")) + if (!HDstrcmp(obj_name, "g1.1")) VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx"); - else if(!HDstrcmp(obj_name, "hardlink")) + else if (!HDstrcmp(obj_name, "hardlink")) VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx"); - else if(!HDstrcmp(obj_name, "softlink")) + else if (!HDstrcmp(obj_name, "softlink")) VERIFY(linfo.type, H5L_TYPE_SOFT, "H5Lget_name_by_idx"); else CHECK(0, 0, "unknown object name"); @@ -941,17 +974,16 @@ static void test_links(hid_t fapl) static int find_err_msg_cb(unsigned H5_ATTR_UNUSED n, const H5E_error2_t *err_desc, void *_client_data) { - int status = H5_ITER_CONT; + int status = H5_ITER_CONT; searched_err_t *searched_err = (searched_err_t *)_client_data; if (searched_err == NULL) return H5_ITER_ERROR; /* If the searched error message is found, stop the iteration */ - if (err_desc->desc != NULL && strcmp(err_desc->desc, searched_err->message) == 0) - { + if (err_desc->desc != NULL && strcmp(err_desc->desc, searched_err->message) == 0) { searched_err->found = true; - status = H5_ITER_STOP; + status = H5_ITER_STOP; } return status; @@ -964,17 +996,18 @@ find_err_msg_cb(unsigned H5_ATTR_UNUSED n, const H5E_error2_t *err_desc, void *_ ** detected and invalid read can be avoided. ** **************************************************************************/ -static void test_corrupted_attnamelen(void) +static void +test_corrupted_attnamelen(void) { - hid_t fid = -1; /* File ID */ - hid_t did = -1; /* Dataset ID */ - searched_err_t err_caught; /* Data to be passed to callback func */ - int err_status; /* Status returned by H5Aiterate2 */ - herr_t ret; /* Return value */ - const char *testfile = H5_get_srcdir_filename(CORRUPTED_ATNAMELEN_FILE); /* Corrected test file name */ + hid_t fid = -1; /* File ID */ + hid_t did = -1; /* Dataset ID */ + searched_err_t err_caught; /* Data to be passed to callback func */ + int err_status; /* Status returned by H5Aiterate2 */ + herr_t ret; /* Return value */ + const char * testfile = H5_get_srcdir_filename(CORRUPTED_ATNAMELEN_FILE); /* Corrected test file name */ const char *err_message = "attribute name has different length than stored length"; - /* the error message produced when the failure occurs */ + /* the error message produced when the failure occurs */ /* Output message about test being performed */ MESSAGE(5, ("Testing the Handling of Corrupted Attribute's Name Length\n")); @@ -992,8 +1025,7 @@ static void test_corrupted_attnamelen(void) VERIFY(err_status, FAIL, "H5Aiterate2"); /* Make sure the intended error was caught */ - if(err_status == -1) - { + if (err_status == -1) { /* Initialize client data */ HDstrcpy(err_caught.message, err_message); err_caught.found = false; @@ -1021,15 +1053,16 @@ static void test_corrupted_attnamelen(void) ** test_links_deprec(): Test soft and hard link iteration ** ****************************************************************/ -static void test_links_deprec(hid_t fapl) +static void +test_links_deprec(hid_t fapl) { - hid_t file; /* File ID */ - char obj_name[NAMELEN]; /* Names of the object in group */ - ssize_t name_len; /* Length of object's name */ - hid_t gid, gid1; - H5G_info_t ginfo; /* Buffer for querying object's info */ - hsize_t i; - herr_t ret; /* Generic return value */ + hid_t file; /* File ID */ + char obj_name[NAMELEN]; /* Names of the object in group */ + ssize_t name_len; /* Length of object's name */ + hid_t gid, gid1; + H5G_info_t ginfo; /* Buffer for querying object's info */ + hsize_t i; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Soft and Hard Link Iteration Functionality Using Deprecated Routines\n")); @@ -1057,12 +1090,13 @@ static void test_links_deprec(hid_t fapl) VERIFY(ginfo.nlinks, 3, "H5Gget_info"); /* Test these two functions, H5Oget_info_by_idx and H5Lget_name_by_idx */ - for(i = 0; i < ginfo.nlinks; i++) { - H5O_info2_t oinfo; /* Object info */ - H5L_info2_t linfo; /* Link info */ + for (i = 0; i < ginfo.nlinks; i++) { + H5O_info2_t oinfo; /* Object info */ + H5L_info2_t linfo; /* Link info */ /* Get link name */ - name_len = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, i, obj_name, (size_t)NAMELEN, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, i, obj_name, (size_t)NAMELEN, + H5P_DEFAULT); CHECK(name_len, FAIL, "H5Lget_name_by_idx"); /* Get link type */ @@ -1070,16 +1104,17 @@ static void test_links_deprec(hid_t fapl) CHECK(ret, FAIL, "H5Lget_info_by_idx1"); /* Get object type */ - if(linfo.type == H5L_TYPE_HARD) { - ret = H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + if (linfo.type == H5L_TYPE_HARD) { + ret = H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, + H5O_INFO_BASIC, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_idx"); } /* end if */ - if(!HDstrcmp(obj_name, "g1.1")) + if (!HDstrcmp(obj_name, "g1.1")) VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx"); - else if(!HDstrcmp(obj_name, "hardlink")) + else if (!HDstrcmp(obj_name, "hardlink")) VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx"); - else if(!HDstrcmp(obj_name, "softlink")) + else if (!HDstrcmp(obj_name, "softlink")) VERIFY(linfo.type, H5L_TYPE_SOFT, "H5Lget_name_by_idx"); else CHECK(0, 0, "unknown object name"); @@ -1104,9 +1139,9 @@ static void test_links_deprec(hid_t fapl) void test_iterate(void) { - hid_t fapl, fapl2; /* File access property lists */ - unsigned new_format; /* Whether to use the new format or not */ - herr_t ret; /* Generic return value */ + hid_t fapl, fapl2; /* File access property lists */ + unsigned new_format; /* Whether to use the new format or not */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Iteration Operations\n")); @@ -1124,14 +1159,14 @@ test_iterate(void) CHECK(ret, FAIL, "H5Pset_libver_bounds"); /* These next tests use the same file */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { test_iter_group(new_format ? fapl2 : fapl, new_format); /* Test group iteration */ - test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ - test_iter_attr(new_format ? fapl2 : fapl, new_format); /* Test attribute iteration */ - test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ - test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ + test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ + test_iter_attr(new_format ? fapl2 : fapl, new_format); /* Test attribute iteration */ + test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ + test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ #ifndef H5_NO_DEPRECATED_SYMBOLS - test_links_deprec(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ + test_links_deprec(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ #endif } /* end for */ @@ -1143,8 +1178,7 @@ test_iterate(void) CHECK(ret, FAIL, "H5Pclose"); ret = H5Pclose(fapl2); CHECK(ret, FAIL, "H5Pclose"); -} /* test_iterate() */ - +} /* test_iterate() */ /*------------------------------------------------------------------------- * Function: cleanup_iterate @@ -1165,4 +1199,3 @@ cleanup_iterate(void) { HDremove(DATAFILE); } - diff --git a/test/tmeta.c b/test/tmeta.c index ceb7d2b..03ebf01 100644 --- a/test/tmeta.c +++ b/test/tmeta.c @@ -12,36 +12,41 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tmeta -* -* Test the basic meta-data encode/decode macros calls. -* -*************************************************************/ + * + * Test program: tmeta + * + * Test the basic meta-data encode/decode macros calls. + * + *************************************************************/ #include "testhdf5.h" #include "H5Fprivate.h" -#define TEST_INT16_VALUE -7641 -#define TEST_UINT16_VALUE 45002 -#define TEST_INT32_VALUE -981236 -#define TEST_UINT32_VALUE 3476589 +#define TEST_INT16_VALUE -7641 +#define TEST_UINT16_VALUE 45002 +#define TEST_INT32_VALUE -981236 +#define TEST_UINT32_VALUE 3476589 -uint8_t compar_buffer[] = -{ +uint8_t compar_buffer[] = { /* Little-endian encoded version of the 16-bit signed integer */ - (uint8_t) ((TEST_INT16_VALUE) & 0xff), (uint8_t) ((TEST_INT16_VALUE >> 8) & 0xff), + (uint8_t)((TEST_INT16_VALUE)&0xff), + (uint8_t)((TEST_INT16_VALUE >> 8) & 0xff), /* Little-endian encoded version of the 16-bit unsigned integer */ - (uint8_t) ((TEST_UINT16_VALUE) & 0xff), (uint8_t) ((TEST_UINT16_VALUE >> 8) & 0xff), + (uint8_t)((TEST_UINT16_VALUE)&0xff), + (uint8_t)((TEST_UINT16_VALUE >> 8) & 0xff), /* Little-endian encoded version of the 32-bit signed integer */ - (uint8_t) ((TEST_INT32_VALUE) & 0xff), (uint8_t) ((TEST_INT32_VALUE >> 8) & 0xff), - (uint8_t) ((TEST_INT32_VALUE >> 16) & 0xff), (uint8_t) ((TEST_INT32_VALUE >> 24) & 0xff), + (uint8_t)((TEST_INT32_VALUE)&0xff), + (uint8_t)((TEST_INT32_VALUE >> 8) & 0xff), + (uint8_t)((TEST_INT32_VALUE >> 16) & 0xff), + (uint8_t)((TEST_INT32_VALUE >> 24) & 0xff), /* Little-endian encoded version of the 32-bit unsigned integer */ - (uint8_t) ((TEST_UINT32_VALUE) & 0xff), (uint8_t) ((TEST_UINT32_VALUE >> 8) & 0xff), - (uint8_t) ((TEST_UINT32_VALUE >> 16) & 0xff), (uint8_t) ((TEST_UINT32_VALUE >> 24) & 0xff), + (uint8_t)((TEST_UINT32_VALUE)&0xff), + (uint8_t)((TEST_UINT32_VALUE >> 8) & 0xff), + (uint8_t)((TEST_UINT32_VALUE >> 16) & 0xff), + (uint8_t)((TEST_UINT32_VALUE >> 24) & 0xff), }; -uint8_t encode_buffer[sizeof(compar_buffer)]; +uint8_t encode_buffer[sizeof(compar_buffer)]; /**************************************************************** ** @@ -51,62 +56,62 @@ uint8_t encode_buffer[sizeof(compar_buffer)]; void test_metadata(void) { - int16_t ei16 = TEST_INT16_VALUE; /* variables to hold the values to encode */ - uint16_t eu16 = TEST_UINT16_VALUE; - int32_t ei32 = TEST_INT32_VALUE; - uint32_t eu32 = TEST_UINT32_VALUE; - int16_t di16; /* variables to hold the decoded values */ - uint16_t du16; - int32_t di32; - uint32_t du32; - uint8_t *p; /* pointer into the buffer being en/de-coded */ + int16_t ei16 = TEST_INT16_VALUE; /* variables to hold the values to encode */ + uint16_t eu16 = TEST_UINT16_VALUE; + int32_t ei32 = TEST_INT32_VALUE; + uint32_t eu32 = TEST_UINT32_VALUE; + int16_t di16; /* variables to hold the decoded values */ + uint16_t du16; + int32_t di32; + uint32_t du32; + uint8_t *p; /* pointer into the buffer being en/de-coded */ /* Output message about test being performed */ MESSAGE(5, ("Testing Metadata Encoding/decoding\n")); /* Start by encoding the values above */ p = encode_buffer; - INT16ENCODE(p, ei16); /* Encode the int16 value */ - UINT16ENCODE(p, eu16); /* Encode the uint16 value */ - INT32ENCODE(p, ei32); /* Encode the int32 value */ - UINT32ENCODE(p, eu32); /* Encode the uint32 value */ + INT16ENCODE(p, ei16); /* Encode the int16 value */ + UINT16ENCODE(p, eu16); /* Encode the uint16 value */ + INT32ENCODE(p, ei32); /* Encode the int32 value */ + UINT32ENCODE(p, eu32); /* Encode the uint32 value */ /* Check if we got what we asked for */ if (HDmemcmp(encode_buffer, compar_buffer, sizeof(compar_buffer)) != 0) { - unsigned u; /* local counting variable */ + unsigned u; /* local counting variable */ for (u = 0; u < sizeof(compar_buffer); u++) { if (compar_buffer[u] != encode_buffer[u]) - TestErrPrintf("Error encoding meta-data at offset %u, wanted: %u, got: %u\n", (unsigned) u, (unsigned) compar_buffer[u], (unsigned) encode_buffer[u]); - } /* end for */ - } /* end if */ + TestErrPrintf("Error encoding meta-data at offset %u, wanted: %u, got: %u\n", (unsigned)u, + (unsigned)compar_buffer[u], (unsigned)encode_buffer[u]); + } /* end for */ + } /* end if */ /* Test decoding macros */ p = encode_buffer; - INT16DECODE(p, di16); /* Decode the int16 value */ - UINT16DECODE(p, du16); /* Decode the uint16 value */ - INT32DECODE(p, di32); /* Decode the int32 value */ - UINT32DECODE(p, du32); /* Decode the uint32 value */ + INT16DECODE(p, di16); /* Decode the int16 value */ + UINT16DECODE(p, du16); /* Decode the uint16 value */ + INT32DECODE(p, di32); /* Decode the int32 value */ + UINT32DECODE(p, du32); /* Decode the uint32 value */ /* Check the values decoded */ if (di16 != TEST_INT16_VALUE) TestErrPrintf("Error decoding int16 meta-data wanted: %d, got: %d " - "at %s:%d\n", (int) TEST_INT16_VALUE, (int) di16, - __FILE__, __LINE__); + "at %s:%d\n", + (int)TEST_INT16_VALUE, (int)di16, __FILE__, __LINE__); if (du16 != TEST_UINT16_VALUE) TestErrPrintf("Error decoding uint16 meta-data wanted: %u, got: %u " - "at %s:%d\n", (unsigned) TEST_UINT16_VALUE, (unsigned) du16, - __FILE__, __LINE__); + "at %s:%d\n", + (unsigned)TEST_UINT16_VALUE, (unsigned)du16, __FILE__, __LINE__); if (di32 != TEST_INT32_VALUE) TestErrPrintf("Error decoding int32 meta-data wanted: %ld, got: %ld " - "at %s:%d\n", (long) TEST_INT32_VALUE, (long) di32, - __FILE__, __LINE__); + "at %s:%d\n", + (long)TEST_INT32_VALUE, (long)di32, __FILE__, __LINE__); if (du32 != TEST_UINT32_VALUE) TestErrPrintf("Error decoding uint32 meta-data wanted: %lu, got: %lu " - "at %s:%d\n", (unsigned long) TEST_UINT32_VALUE, (unsigned long) du32, - __FILE__, __LINE__); -} /* test_metadata() */ + "at %s:%d\n", + (unsigned long)TEST_UINT32_VALUE, (unsigned long)du32, __FILE__, __LINE__); +} /* test_metadata() */ - /*------------------------------------------------------------------------- * Function: cleanup_metadata * @@ -126,4 +131,3 @@ cleanup_metadata(void) { /* no file to clean */ } - diff --git a/test/tmisc.c b/test/tmisc.c index f35daac..1d16e5a 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -12,331 +12,324 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tmisc -* -* Test miscellaneous features not tested elsewhere. Generally -* regression tests for bugs that are reported and don't -* have an existing test to add them to. -* -*************************************************************/ + * + * Test program: tmisc + * + * Test miscellaneous features not tested elsewhere. Generally + * regression tests for bugs that are reported and don't + * have an existing test to add them to. + * + *************************************************************/ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ /* Define this macro to indicate that the testing APIs should be available */ #define H5D_TESTING #include "testhdf5.h" #include "H5srcdir.h" -#include "H5Dpkg.h" /* Datasets */ -#include "H5MMprivate.h" /* Memory */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5MMprivate.h" /* Memory */ /* Definitions for misc. test #1 */ -#define MISC1_FILE "tmisc1.h5" -#define MISC1_VAL (13417386) /* 0xccbbaa */ -#define MISC1_VAL2 (15654348) /* 0xeeddcc */ +#define MISC1_FILE "tmisc1.h5" +#define MISC1_VAL (13417386) /* 0xccbbaa */ +#define MISC1_VAL2 (15654348) /* 0xeeddcc */ #define MISC1_DSET_NAME "/scalar_set" /* Definitions for misc. test #2 */ -#define MISC2_FILE_1 "tmisc2a.h5" -#define MISC2_FILE_2 "tmisc2b.h5" +#define MISC2_FILE_1 "tmisc2a.h5" +#define MISC2_FILE_2 "tmisc2b.h5" #define MISC2_ATT_NAME_1 "scalar_att_1" #define MISC2_ATT_NAME_2 "scalar_att_2" typedef struct { - char *string; + char *string; } misc2_struct; /* Definitions for misc. test #3 */ -#define MISC3_FILE "tmisc3.h5" -#define MISC3_RANK 2 -#define MISC3_DIM1 6 -#define MISC3_DIM2 6 -#define MISC3_CHUNK_DIM1 2 -#define MISC3_CHUNK_DIM2 2 -#define MISC3_FILL_VALUE 2 -#define MISC3_DSET_NAME "/chunked" +#define MISC3_FILE "tmisc3.h5" +#define MISC3_RANK 2 +#define MISC3_DIM1 6 +#define MISC3_DIM2 6 +#define MISC3_CHUNK_DIM1 2 +#define MISC3_CHUNK_DIM2 2 +#define MISC3_FILL_VALUE 2 +#define MISC3_DSET_NAME "/chunked" /* Definitions for misc. test #4 */ -#define MISC4_FILE_1 "tmisc4a.h5" -#define MISC4_FILE_2 "tmisc4b.h5" -#define MISC4_GROUP_1 "/Group1" -#define MISC4_GROUP_2 "/Group2" +#define MISC4_FILE_1 "tmisc4a.h5" +#define MISC4_FILE_2 "tmisc4b.h5" +#define MISC4_GROUP_1 "/Group1" +#define MISC4_GROUP_2 "/Group2" /* Definitions for misc. test #5 */ -#define MISC5_FILE "tmisc5.h5" -#define MISC5_DSETNAME "dset1" -#define MISC5_DSETRANK 1 -#define MISC5_NELMTOPLVL 1 -#define MISC5_DBGNELM1 2 -#define MISC5_DBGNELM2 1 -#define MISC5_DBGNELM3 1 -#define MISC5_DBGELVAL1 999999999 -#define MISC5_DBGELVAL2 888888888 -#define MISC5_DBGELVAL3 777777777 - -typedef struct -{ - int st1_el1; +#define MISC5_FILE "tmisc5.h5" +#define MISC5_DSETNAME "dset1" +#define MISC5_DSETRANK 1 +#define MISC5_NELMTOPLVL 1 +#define MISC5_DBGNELM1 2 +#define MISC5_DBGNELM2 1 +#define MISC5_DBGNELM3 1 +#define MISC5_DBGELVAL1 999999999 +#define MISC5_DBGELVAL2 888888888 +#define MISC5_DBGELVAL3 777777777 + +typedef struct { + int st1_el1; hvl_t st1_el2; } misc5_struct1; -typedef struct -{ - int st2_el1; +typedef struct { + int st2_el1; hvl_t st2_el2; } misc5_struct2; -typedef struct -{ +typedef struct { int st3_el1; } misc5_struct3; -typedef struct -{ - hid_t st3h_base; - hid_t st3h_id; +typedef struct { + hid_t st3h_base; + hid_t st3h_id; } misc5_struct3_hndl; -typedef struct -{ - hid_t st2h_base; - hid_t st2h_id; +typedef struct { + hid_t st2h_base; + hid_t st2h_id; misc5_struct3_hndl *st2h_st3hndl; } misc5_struct2_hndl; -typedef struct -{ - hid_t st1h_base; - hid_t st1h_id; +typedef struct { + hid_t st1h_base; + hid_t st1h_id; misc5_struct2_hndl *st1h_st2hndl; } misc5_struct1_hndl; /* Definitions for misc. test #6 */ -#define MISC6_FILE "tmisc6.h5" -#define MISC6_DSETNAME1 "dset1" -#define MISC6_DSETNAME2 "dset2" -#define MISC6_NUMATTR 16 +#define MISC6_FILE "tmisc6.h5" +#define MISC6_DSETNAME1 "dset1" +#define MISC6_DSETNAME2 "dset2" +#define MISC6_NUMATTR 16 /* Definitions for misc. test #7 */ -#define MISC7_FILE "tmisc7.h5" -#define MISC7_DSETNAME1 "Dataset1" -#define MISC7_DSETNAME2 "Dataset2" -#define MISC7_TYPENAME1 "Datatype1" -#define MISC7_TYPENAME2 "Datatype2" +#define MISC7_FILE "tmisc7.h5" +#define MISC7_DSETNAME1 "Dataset1" +#define MISC7_DSETNAME2 "Dataset2" +#define MISC7_TYPENAME1 "Datatype1" +#define MISC7_TYPENAME2 "Datatype2" /* Definitions for misc. test #8 */ -#define MISC8_FILE "tmisc8.h5" -#define MISC8_DSETNAME1 "Dataset1" -#define MISC8_DSETNAME4 "Dataset4" -#define MISC8_DSETNAME5 "Dataset5" -#define MISC8_DSETNAME8 "Dataset8" +#define MISC8_FILE "tmisc8.h5" +#define MISC8_DSETNAME1 "Dataset1" +#define MISC8_DSETNAME4 "Dataset4" +#define MISC8_DSETNAME5 "Dataset5" +#define MISC8_DSETNAME8 "Dataset8" #ifndef H5_HAVE_PARALLEL -#define MISC8_DSETNAME2 "Dataset2" -#define MISC8_DSETNAME3 "Dataset3" -#define MISC8_DSETNAME4 "Dataset4" -#define MISC8_DSETNAME6 "Dataset6" -#define MISC8_DSETNAME7 "Dataset7" -#define MISC8_DSETNAME9 "Dataset9" -#define MISC8_DSETNAME10 "Dataset10" +#define MISC8_DSETNAME2 "Dataset2" +#define MISC8_DSETNAME3 "Dataset3" +#define MISC8_DSETNAME4 "Dataset4" +#define MISC8_DSETNAME6 "Dataset6" +#define MISC8_DSETNAME7 "Dataset7" +#define MISC8_DSETNAME9 "Dataset9" +#define MISC8_DSETNAME10 "Dataset10" #endif -#define MISC8_RANK 2 -#define MISC8_DIM0 50 -#define MISC8_DIM1 50 -#define MISC8_CHUNK_DIM0 10 -#define MISC8_CHUNK_DIM1 10 +#define MISC8_RANK 2 +#define MISC8_DIM0 50 +#define MISC8_DIM1 50 +#define MISC8_CHUNK_DIM0 10 +#define MISC8_CHUNK_DIM1 10 /* Definitions for misc. test #9 */ -#define MISC9_FILE "tmisc9.h5" +#define MISC9_FILE "tmisc9.h5" /* Definitions for misc. test #10 */ -#define MISC10_FILE_OLD "tmtimeo.h5" -#define MISC10_FILE_NEW "tmisc10.h5" -#define MISC10_DSETNAME "Dataset1" +#define MISC10_FILE_OLD "tmtimeo.h5" +#define MISC10_FILE_NEW "tmisc10.h5" +#define MISC10_DSETNAME "Dataset1" /* Definitions for misc. test #11 */ -#define MISC11_FILE "tmisc11.h5" -#define MISC11_USERBLOCK 1024 -#define MISC11_SIZEOF_OFF 4 -#define MISC11_SIZEOF_LEN 4 -#define MISC11_SYM_LK 8 -#define MISC11_SYM_IK 32 -#define MISC11_ISTORE_IK 64 -#define MISC11_NINDEXES 1 +#define MISC11_FILE "tmisc11.h5" +#define MISC11_USERBLOCK 1024 +#define MISC11_SIZEOF_OFF 4 +#define MISC11_SIZEOF_LEN 4 +#define MISC11_SYM_LK 8 +#define MISC11_SYM_IK 32 +#define MISC11_ISTORE_IK 64 +#define MISC11_NINDEXES 1 /* Definitions for misc. test #12 */ -#define MISC12_FILE "tmisc12.h5" -#define MISC12_DSET_NAME "Dataset" -#define MISC12_SPACE1_RANK 1 -#define MISC12_SPACE1_DIM1 4 -#define MISC12_CHUNK_SIZE 2 -#define MISC12_APPEND_SIZE 5 +#define MISC12_FILE "tmisc12.h5" +#define MISC12_DSET_NAME "Dataset" +#define MISC12_SPACE1_RANK 1 +#define MISC12_SPACE1_DIM1 4 +#define MISC12_CHUNK_SIZE 2 +#define MISC12_APPEND_SIZE 5 /* Definitions for misc. test #13 */ -#define MISC13_FILE_1 "tmisc13a.h5" -#define MISC13_FILE_2 "tmisc13b.h5" -#define MISC13_DSET1_NAME "Dataset1" -#define MISC13_DSET2_NAME "Dataset2" -#define MISC13_DSET3_NAME "Dataset3" -#define MISC13_GROUP1_NAME "Group1" -#define MISC13_GROUP2_NAME "Group2" -#define MISC13_DTYPE_NAME "Datatype" -#define MISC13_RANK 1 -#define MISC13_DIM1 600 -#define MISC13_CHUNK_DIM1 10 -#define MISC13_USERBLOCK_SIZE 512 -#define MISC13_COPY_BUF_SIZE 4096 +#define MISC13_FILE_1 "tmisc13a.h5" +#define MISC13_FILE_2 "tmisc13b.h5" +#define MISC13_DSET1_NAME "Dataset1" +#define MISC13_DSET2_NAME "Dataset2" +#define MISC13_DSET3_NAME "Dataset3" +#define MISC13_GROUP1_NAME "Group1" +#define MISC13_GROUP2_NAME "Group2" +#define MISC13_DTYPE_NAME "Datatype" +#define MISC13_RANK 1 +#define MISC13_DIM1 600 +#define MISC13_CHUNK_DIM1 10 +#define MISC13_USERBLOCK_SIZE 512 +#define MISC13_COPY_BUF_SIZE 4096 /* Definitions for misc. test #14 */ -#define MISC14_FILE "tmisc14.h5" -#define MISC14_DSET1_NAME "Dataset1" -#define MISC14_DSET2_NAME "Dataset2" -#define MISC14_DSET3_NAME "Dataset3" -#define MISC14_METADATA_SIZE 4096 +#define MISC14_FILE "tmisc14.h5" +#define MISC14_DSET1_NAME "Dataset1" +#define MISC14_DSET2_NAME "Dataset2" +#define MISC14_DSET3_NAME "Dataset3" +#define MISC14_METADATA_SIZE 4096 /* Definitions for misc. test #15 */ -#define MISC15_FILE "tmisc15.h5" +#define MISC15_FILE "tmisc15.h5" /* Definitions for misc. test #16 */ -#define MISC16_FILE "tmisc16.h5" -#define MISC16_SPACE_DIM 4 -#define MISC16_SPACE_RANK 1 -#define MISC16_STR_SIZE 8 -#define MISC16_DSET_NAME "Dataset" +#define MISC16_FILE "tmisc16.h5" +#define MISC16_SPACE_DIM 4 +#define MISC16_SPACE_RANK 1 +#define MISC16_STR_SIZE 8 +#define MISC16_DSET_NAME "Dataset" /* Definitions for misc. test #17 */ -#define MISC17_FILE "tmisc17.h5" -#define MISC17_SPACE_RANK 2 -#define MISC17_SPACE_DIM1 4 -#define MISC17_SPACE_DIM2 8 -#define MISC17_DSET_NAME "Dataset" +#define MISC17_FILE "tmisc17.h5" +#define MISC17_SPACE_RANK 2 +#define MISC17_SPACE_DIM1 4 +#define MISC17_SPACE_DIM2 8 +#define MISC17_DSET_NAME "Dataset" /* Definitions for misc. test #18 */ -#define MISC18_FILE "tmisc18.h5" -#define MISC18_DSET1_NAME "Dataset1" -#define MISC18_DSET2_NAME "Dataset2" +#define MISC18_FILE "tmisc18.h5" +#define MISC18_DSET1_NAME "Dataset1" +#define MISC18_DSET2_NAME "Dataset2" /* Definitions for misc. test #19 */ -#define MISC19_FILE "tmisc19.h5" -#define MISC19_DSET_NAME "Dataset" -#define MISC19_ATTR_NAME "Attribute" -#define MISC19_GROUP_NAME "Group" +#define MISC19_FILE "tmisc19.h5" +#define MISC19_DSET_NAME "Dataset" +#define MISC19_ATTR_NAME "Attribute" +#define MISC19_GROUP_NAME "Group" /* Definitions for misc. test #20 */ -#define MISC20_FILE "tmisc20.h5" -#define MISC20_FILE_OLD "tlayouto.h5" -#define MISC20_DSET_NAME "Dataset" -#define MISC20_DSET2_NAME "Dataset2" -#define MISC20_SPACE_RANK 2 +#define MISC20_FILE "tmisc20.h5" +#define MISC20_FILE_OLD "tlayouto.h5" +#define MISC20_DSET_NAME "Dataset" +#define MISC20_DSET2_NAME "Dataset2" +#define MISC20_SPACE_RANK 2 /* Make sure the product of the following 2 does not get too close to */ /* 64 bits, risking an overflow. */ -#define MISC20_SPACE_DIM0 (8*1024*1024*(uint64_t)1024) -#define MISC20_SPACE_DIM1 ((256*1024*(uint64_t)1024)+1) -#define MISC20_SPACE2_DIM0 8 -#define MISC20_SPACE2_DIM1 4 +#define MISC20_SPACE_DIM0 (8 * 1024 * 1024 * (uint64_t)1024) +#define MISC20_SPACE_DIM1 ((256 * 1024 * (uint64_t)1024) + 1) +#define MISC20_SPACE2_DIM0 8 +#define MISC20_SPACE2_DIM1 4 #ifdef H5_HAVE_FILTER_SZIP /* Definitions for misc. test #21 */ -#define MISC21_FILE "tmisc21.h5" -#define MISC21_DSET_NAME "Dataset" -#define MISC21_SPACE_RANK 2 -#define MISC21_SPACE_DIM0 7639 -#define MISC21_SPACE_DIM1 6308 -#define MISC21_CHUNK_DIM0 2048 -#define MISC21_CHUNK_DIM1 2048 +#define MISC21_FILE "tmisc21.h5" +#define MISC21_DSET_NAME "Dataset" +#define MISC21_SPACE_RANK 2 +#define MISC21_SPACE_DIM0 7639 +#define MISC21_SPACE_DIM1 6308 +#define MISC21_CHUNK_DIM0 2048 +#define MISC21_CHUNK_DIM1 2048 /* Definitions for misc. test #22 */ -#define MISC22_FILE "tmisc22.h5" -#define MISC22_DSET_NAME "Dataset" -#define MISC22_SPACE_RANK 2 -#define MISC22_CHUNK_DIM0 512 -#define MISC22_CHUNK_DIM1 512 -#define MISC22_SPACE_DIM0 639 -#define MISC22_SPACE_DIM1 1308 +#define MISC22_FILE "tmisc22.h5" +#define MISC22_DSET_NAME "Dataset" +#define MISC22_SPACE_RANK 2 +#define MISC22_CHUNK_DIM0 512 +#define MISC22_CHUNK_DIM1 512 +#define MISC22_SPACE_DIM0 639 +#define MISC22_SPACE_DIM1 1308 #endif /* H5_HAVE_FILTER_SZIP */ /* Definitions for misc. test #23 */ -#define MISC23_FILE "tmisc23.h5" -#define MISC23_NAME_BUF_SIZE 40 +#define MISC23_FILE "tmisc23.h5" +#define MISC23_NAME_BUF_SIZE 40 /* Definitions for misc. test #24 */ -#define MISC24_FILE "tmisc24.h5" -#define MISC24_GROUP_NAME "group" -#define MISC24_GROUP_LINK "group_link" -#define MISC24_DATASET_NAME "dataset" -#define MISC24_DATASET_LINK "dataset_link" -#define MISC24_DATATYPE_NAME "datatype" -#define MISC24_DATATYPE_LINK "datatype_link" +#define MISC24_FILE "tmisc24.h5" +#define MISC24_GROUP_NAME "group" +#define MISC24_GROUP_LINK "group_link" +#define MISC24_DATASET_NAME "dataset" +#define MISC24_DATASET_LINK "dataset_link" +#define MISC24_DATATYPE_NAME "datatype" +#define MISC24_DATATYPE_LINK "datatype_link" /* Definitions for misc. test #25 'a', 'b' & 'c' */ -#define MISC25A_FILE "foo.h5" -#define MISC25A_GROUP0_NAME "grp0" -#define MISC25A_GROUP1_NAME "/grp0/grp1" -#define MISC25A_GROUP2_NAME "/grp0/grp2" -#define MISC25A_GROUP3_NAME "/grp0/grp3" -#define MISC25A_ATTR1_NAME "_long attribute_" -#define MISC25A_ATTR1_LEN 11 -#define MISC25A_ATTR2_NAME "_short attr__" -#define MISC25A_ATTR2_LEN 11 -#define MISC25A_ATTR3_NAME "_short attr__" -#define MISC25A_ATTR3_LEN 1 -#define MISC25B_FILE "mergemsg.h5" -#define MISC25B_GROUP "grp1" -#define MISC25C_FILE "nc4_rename.h5" -#define MISC25C_DSETNAME "da" -#define MISC25C_DSETNAME2 "dz" -#define MISC25C_DSETGRPNAME "ga" -#define MISC25C_GRPNAME "gb" -#define MISC25C_GRPNAME2 "gc" -#define MISC25C_ATTRNAME "aa" -#define MISC25C_ATTRNAME2 "ab" +#define MISC25A_FILE "foo.h5" +#define MISC25A_GROUP0_NAME "grp0" +#define MISC25A_GROUP1_NAME "/grp0/grp1" +#define MISC25A_GROUP2_NAME "/grp0/grp2" +#define MISC25A_GROUP3_NAME "/grp0/grp3" +#define MISC25A_ATTR1_NAME "_long attribute_" +#define MISC25A_ATTR1_LEN 11 +#define MISC25A_ATTR2_NAME "_short attr__" +#define MISC25A_ATTR2_LEN 11 +#define MISC25A_ATTR3_NAME "_short attr__" +#define MISC25A_ATTR3_LEN 1 +#define MISC25B_FILE "mergemsg.h5" +#define MISC25B_GROUP "grp1" +#define MISC25C_FILE "nc4_rename.h5" +#define MISC25C_DSETNAME "da" +#define MISC25C_DSETNAME2 "dz" +#define MISC25C_DSETGRPNAME "ga" +#define MISC25C_GRPNAME "gb" +#define MISC25C_GRPNAME2 "gc" +#define MISC25C_ATTRNAME "aa" +#define MISC25C_ATTRNAME2 "ab" /* Definitions for misc. test #26 */ -#define MISC26_FILE "dcpl_file" +#define MISC26_FILE "dcpl_file" /* Definitions for misc. test #27 */ /* (Note that this test file is generated by the "gen_bad_ohdr.c" code) */ -#define MISC27_FILE "tbad_msg_count.h5" -#define MISC27_GROUP "Group" +#define MISC27_FILE "tbad_msg_count.h5" +#define MISC27_GROUP "Group" /* Definitions for misc. test #28 */ -#define MISC28_FILE "tmisc28.h5" -#define MISC28_SIZE 10 -#define MISC28_NSLOTS 10000 +#define MISC28_FILE "tmisc28.h5" +#define MISC28_SIZE 10 +#define MISC28_NSLOTS 10000 /* Definitions for misc. test #29 */ -#define MISC29_ORIG_FILE "specmetaread.h5" -#define MISC29_COPY_FILE "tmisc29.h5" -#define MISC29_DSETNAME "dset2" +#define MISC29_ORIG_FILE "specmetaread.h5" +#define MISC29_COPY_FILE "tmisc29.h5" +#define MISC29_DSETNAME "dset2" /* Definitions for misc. test #30 */ -#define MISC30_FILE "tmisc30.h5" +#define MISC30_FILE "tmisc30.h5" #ifndef H5_NO_DEPRECATED_SYMBOLS /* Definitions for misc. test #31 */ -#define MISC31_FILE "tmisc31.h5" -#define MISC31_DSETNAME "dset" -#define MISC31_ATTRNAME1 "attr1" -#define MISC31_ATTRNAME2 "attr2" -#define MISC31_GROUPNAME "group" -#define MISC31_PROPNAME "misc31_prop" -#define MISC31_DTYPENAME "dtype" +#define MISC31_FILE "tmisc31.h5" +#define MISC31_DSETNAME "dset" +#define MISC31_ATTRNAME1 "attr1" +#define MISC31_ATTRNAME2 "attr2" +#define MISC31_GROUPNAME "group" +#define MISC31_PROPNAME "misc31_prop" +#define MISC31_DTYPENAME "dtype" #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Definitions for misc. test #33 */ /* Note that this test file is generated by "gen_bad_offset.c" */ /* and bad offset values are written to that file for testing */ -#define MISC33_FILE "bad_offset.h5" +#define MISC33_FILE "bad_offset.h5" /* Definitions for misc. test #35 */ -#define MISC35_SPACE_RANK 3 -#define MISC35_SPACE_DIM1 3 -#define MISC35_SPACE_DIM2 15 -#define MISC35_SPACE_DIM3 13 -#define MISC35_NPOINTS 10 - +#define MISC35_SPACE_RANK 3 +#define MISC35_SPACE_DIM1 3 +#define MISC35_SPACE_DIM2 15 +#define MISC35_SPACE_DIM3 13 +#define MISC35_NPOINTS 10 /**************************************************************** ** @@ -347,9 +340,9 @@ typedef struct static void test_misc1(void) { - int i; - int i_check; - hid_t file, dataspace, dataset; + int i; + int i_check; + hid_t file, dataspace, dataset; herr_t ret; /* Output message about test being performed */ @@ -362,10 +355,11 @@ test_misc1(void) CHECK(dataspace, FAIL, "H5Screate"); /* Write the dataset the first time. */ - dataset = H5Dcreate2(file, MISC1_DSET_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = + H5Dcreate2(file, MISC1_DSET_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); - i = MISC1_VAL; + i = MISC1_VAL; ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i); CHECK(ret, FAIL, "H5Dwrite"); @@ -377,10 +371,11 @@ test_misc1(void) CHECK(ret, FAIL, "H5Ldelete"); /* Write the dataset for the second time with a different value. */ - dataset = H5Dcreate2(file, MISC1_DSET_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = + H5Dcreate2(file, MISC1_DSET_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); - i = MISC1_VAL2; + i = MISC1_VAL2; ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i); CHECK(ret, FAIL, "H5Dwrite"); @@ -405,7 +400,7 @@ test_misc1(void) ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i_check); CHECK(ret, FAIL, "H5Dread"); - VERIFY(i_check,MISC1_VAL2,"H5Dread"); + VERIFY(i_check, MISC1_VAL2, "H5Dread"); ret = H5Sclose(dataspace); CHECK(ret, FAIL, "H5Sclose"); @@ -418,12 +413,13 @@ test_misc1(void) } /* end test_misc1() */ -static hid_t misc2_create_type(void) +static hid_t +misc2_create_type(void) { - hid_t type, type_tmp; + hid_t type, type_tmp; herr_t ret; - type_tmp = H5Tcopy (H5T_C_S1); + type_tmp = H5Tcopy(H5T_C_S1); CHECK(type_tmp, FAIL, "H5Tcopy"); ret = H5Tset_size(type_tmp, H5T_VARIABLE); @@ -441,14 +437,15 @@ static hid_t misc2_create_type(void) return type; } -static void test_misc2_write_attribute(void) +static void +test_misc2_write_attribute(void) { - hid_t file1, file2, root1, root2, dataspace, att1, att2; - hid_t type; - herr_t ret; + hid_t file1, file2, root1, root2, dataspace, att1, att2; + hid_t type; + herr_t ret; misc2_struct data, data_check; - char *string_att1 = HDstrdup("string attribute in file one"); - char *string_att2 = HDstrdup("string attribute in file two"); + char * string_att1 = HDstrdup("string attribute in file one"); + char * string_att2 = HDstrdup("string attribute in file two"); type = misc2_create_type(); @@ -524,13 +521,13 @@ static void test_misc2_write_attribute(void) return; } - -static void test_misc2_read_attribute(const char *filename, const char *att_name) +static void +test_misc2_read_attribute(const char *filename, const char *att_name) { - hid_t file, root, att; - hid_t type; - hid_t space; - herr_t ret; + hid_t file, root, att; + hid_t type; + hid_t space; + herr_t ret; misc2_struct data_check; type = misc2_create_type(); @@ -597,14 +594,14 @@ test_misc2(void) static void test_misc3(void) { - hid_t file, dataspace, dataset, dcpl; - int rank=MISC3_RANK; - hsize_t dims[MISC3_RANK]={MISC3_DIM1,MISC3_DIM2}; - hsize_t chunk_dims[MISC3_RANK]={MISC3_CHUNK_DIM1,MISC3_CHUNK_DIM2}; - int fill=MISC3_FILL_VALUE; - int read_buf[MISC3_DIM1][MISC3_DIM2]; - int i,j; - herr_t ret; + hid_t file, dataspace, dataset, dcpl; + int rank = MISC3_RANK; + hsize_t dims[MISC3_RANK] = {MISC3_DIM1, MISC3_DIM2}; + hsize_t chunk_dims[MISC3_RANK] = {MISC3_CHUNK_DIM1, MISC3_CHUNK_DIM2}; + int fill = MISC3_FILL_VALUE; + int read_buf[MISC3_DIM1][MISC3_DIM2]; + int i, j; + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing reading from chunked dataset with non-zero fill-value\n")); @@ -613,7 +610,7 @@ test_misc3(void) CHECK(file, FAIL, "H5Fcreate"); /* Create a simple dataspace */ - dataspace = H5Screate_simple(rank,dims,NULL); + dataspace = H5Screate_simple(rank, dims, NULL); CHECK(dataspace, FAIL, "H5Screate_simple"); /* Create a dataset creation property list */ @@ -621,11 +618,11 @@ test_misc3(void) CHECK(dcpl, FAIL, "H5Pcreate"); /* Set the chunk information */ - ret = H5Pset_chunk(dcpl,rank,chunk_dims); + ret = H5Pset_chunk(dcpl, rank, chunk_dims); CHECK(dcpl, FAIL, "H5Pset_chunk"); /* Set the fill-value information */ - ret = H5Pset_fill_value(dcpl,H5T_NATIVE_INT,&fill); + ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill); CHECK(dcpl, FAIL, "H5Pset_fill_value"); /* Create the dataset */ @@ -636,9 +633,9 @@ test_misc3(void) ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &read_buf); CHECK(ret, FAIL, "H5Dread"); - for(i=0; ist3h_base = H5Tcreate(H5T_COMPOUND, sizeof(misc5_struct3)); CHECK(str3hndl->st3h_base, FAIL, "H5Tcreate"); - ret = H5Tinsert(str3hndl->st3h_base, "st3_el1", HOFFSET( misc5_struct3, st3_el1), H5T_NATIVE_INT); - CHECK(ret,FAIL,"H5Tinsert"); + ret = H5Tinsert(str3hndl->st3h_base, "st3_el1", HOFFSET(misc5_struct3, st3_el1), H5T_NATIVE_INT); + CHECK(ret, FAIL, "H5Tinsert"); str3hndl->st3h_id = H5Tvlen_create(str3hndl->st3h_base); - CHECK(str3hndl->st3h_id,FAIL,"H5Tvlen_create"); + CHECK(str3hndl->st3h_id, FAIL, "H5Tvlen_create"); return str3hndl; } @@ -754,13 +751,13 @@ create_struct3(void) static void delete_struct3(misc5_struct3_hndl *str3hndl) { - herr_t ret; /* For error checking */ + herr_t ret; /* For error checking */ ret = H5Tclose(str3hndl->st3h_id); - CHECK(ret,FAIL,"H5Tclose"); + CHECK(ret, FAIL, "H5Tclose"); ret = H5Tclose(str3hndl->st3h_base); - CHECK(ret,FAIL,"H5Tclose"); + CHECK(ret, FAIL, "H5Tclose"); HDfree(str3hndl); } @@ -768,7 +765,7 @@ delete_struct3(misc5_struct3_hndl *str3hndl) static void set_struct3(misc5_struct3 *buf) { - buf->st3_el1=MISC5_DBGELVAL3; + buf->st3_el1 = MISC5_DBGELVAL3; } /*********************** struct2 ***********************/ @@ -776,8 +773,8 @@ set_struct3(misc5_struct3 *buf) static misc5_struct2_hndl * create_struct2(void) { - misc5_struct2_hndl *str2hndl; /* New 'struct2' created */ - herr_t ret; /* For error checking */ + misc5_struct2_hndl *str2hndl; /* New 'struct2' created */ + herr_t ret; /* For error checking */ str2hndl = (misc5_struct2_hndl *)HDmalloc(sizeof(misc5_struct2_hndl)); CHECK_PTR(str2hndl, "HDmalloc"); @@ -791,11 +788,12 @@ create_struct2(void) str2hndl->st2h_st3hndl = create_struct3(); CHECK_PTR(str2hndl->st2h_st3hndl, "create_struct3"); - ret = H5Tinsert(str2hndl->st2h_base, "st2_el2", HOFFSET(misc5_struct2, st2_el2), str2hndl->st2h_st3hndl->st3h_id); - CHECK(ret,FAIL,"H5Tinsert"); + ret = H5Tinsert(str2hndl->st2h_base, "st2_el2", HOFFSET(misc5_struct2, st2_el2), + str2hndl->st2h_st3hndl->st3h_id); + CHECK(ret, FAIL, "H5Tinsert"); str2hndl->st2h_id = H5Tvlen_create(str2hndl->st2h_base); - CHECK(str2hndl->st2h_id,FAIL,"H5Tvlen_create"); + CHECK(str2hndl->st2h_id, FAIL, "H5Tvlen_create"); return str2hndl; } @@ -803,15 +801,15 @@ create_struct2(void) static void delete_struct2(misc5_struct2_hndl *str2hndl) { - herr_t ret; /* For error checking */ + herr_t ret; /* For error checking */ - ret=H5Tclose(str2hndl->st2h_id); - CHECK(ret,FAIL,"H5Tclose"); + ret = H5Tclose(str2hndl->st2h_id); + CHECK(ret, FAIL, "H5Tclose"); delete_struct3(str2hndl->st2h_st3hndl); H5Tclose(str2hndl->st2h_base); - CHECK(ret,FAIL,"H5Tclose"); + CHECK(ret, FAIL, "H5Tclose"); HDfree(str2hndl); } @@ -819,15 +817,15 @@ delete_struct2(misc5_struct2_hndl *str2hndl) static void set_struct2(misc5_struct2 *buf) { - unsigned i; /* Local index variable */ + unsigned i; /* Local index variable */ - buf->st2_el1 = MISC5_DBGELVAL2; + buf->st2_el1 = MISC5_DBGELVAL2; buf->st2_el2.len = MISC5_DBGNELM3; - buf->st2_el2.p = HDmalloc((buf->st2_el2.len)*sizeof(misc5_struct3)); + buf->st2_el2.p = HDmalloc((buf->st2_el2.len) * sizeof(misc5_struct3)); CHECK_PTR(buf->st2_el2.p, "HDmalloc"); - for(i=0; i<(buf->st2_el2.len); i++) + for (i = 0; i < (buf->st2_el2.len); i++) set_struct3(&(((misc5_struct3 *)(buf->st2_el2.p))[i])); } @@ -842,8 +840,8 @@ clear_struct2(misc5_struct2 *buf) static misc5_struct1_hndl * create_struct1(void) { - misc5_struct1_hndl *str1hndl; /* New 'struct1' created */ - herr_t ret; /* For error checking */ + misc5_struct1_hndl *str1hndl; /* New 'struct1' created */ + herr_t ret; /* For error checking */ str1hndl = (misc5_struct1_hndl *)HDmalloc(sizeof(misc5_struct1_hndl)); CHECK_PTR(str1hndl, "HDmalloc"); @@ -854,14 +852,15 @@ create_struct1(void) ret = H5Tinsert(str1hndl->st1h_base, "st1_el1", HOFFSET(misc5_struct1, st1_el1), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - str1hndl->st1h_st2hndl=create_struct2(); + str1hndl->st1h_st2hndl = create_struct2(); CHECK_PTR(str1hndl->st1h_st2hndl, "create_struct2"); - ret = H5Tinsert(str1hndl->st1h_base, "st1_el2", HOFFSET(misc5_struct1, st1_el2), str1hndl->st1h_st2hndl->st2h_id); - CHECK(ret,FAIL,"H5Tinsert"); + ret = H5Tinsert(str1hndl->st1h_base, "st1_el2", HOFFSET(misc5_struct1, st1_el2), + str1hndl->st1h_st2hndl->st2h_id); + CHECK(ret, FAIL, "H5Tinsert"); str1hndl->st1h_id = H5Tvlen_create(str1hndl->st1h_base); - CHECK(str1hndl->st1h_id,FAIL,"H5Tvlen_create"); + CHECK(str1hndl->st1h_id, FAIL, "H5Tvlen_create"); return str1hndl; } @@ -869,15 +868,15 @@ create_struct1(void) static void delete_struct1(misc5_struct1_hndl *str1hndl) { - herr_t ret; /* For error checking */ + herr_t ret; /* For error checking */ ret = H5Tclose(str1hndl->st1h_id); - CHECK(ret,FAIL,"H5Tclose"); + CHECK(ret, FAIL, "H5Tclose"); delete_struct2(str1hndl->st1h_st2hndl); ret = H5Tclose(str1hndl->st1h_base); - CHECK(ret,FAIL,"H5Tclose"); + CHECK(ret, FAIL, "H5Tclose"); HDfree(str1hndl); } @@ -885,15 +884,15 @@ delete_struct1(misc5_struct1_hndl *str1hndl) static void set_struct1(misc5_struct1 *buf) { - unsigned i; /* Local index variable */ + unsigned i; /* Local index variable */ - buf->st1_el1=MISC5_DBGELVAL1; - buf->st1_el2.len=MISC5_DBGNELM2; + buf->st1_el1 = MISC5_DBGELVAL1; + buf->st1_el2.len = MISC5_DBGNELM2; - buf->st1_el2.p=HDmalloc((buf->st1_el2.len)*sizeof(misc5_struct2)); + buf->st1_el2.p = HDmalloc((buf->st1_el2.len) * sizeof(misc5_struct2)); CHECK_PTR(buf->st1_el2.p, "HDmalloc"); - for(i=0; i<(buf->st1_el2.len); i++) + for (i = 0; i < (buf->st1_el2.len); i++) set_struct2(&(((misc5_struct2 *)(buf->st1_el2.p))[i])); } @@ -902,21 +901,21 @@ clear_struct1(misc5_struct1 *buf) { unsigned i; - for(i=0;ist1_el2.len;i++) - clear_struct2(&((( misc5_struct2 *)(buf->st1_el2.p))[i])); + for (i = 0; i < buf->st1_el2.len; i++) + clear_struct2(&(((misc5_struct2 *)(buf->st1_el2.p))[i])); HDfree(buf->st1_el2.p); } static void test_misc5(void) { - hid_t loc_id, space_id, dataset_id; - hid_t mem_type_id; + hid_t loc_id, space_id, dataset_id; + hid_t mem_type_id; misc5_struct1_hndl *str1hndl; - hsize_t dims[MISC5_DSETRANK]; - hvl_t buf; - unsigned i,j,k; - herr_t ret; + hsize_t dims[MISC5_DSETRANK]; + hvl_t buf; + unsigned i, j, k; + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing several level deep nested compound & VL datatypes \n")); @@ -930,21 +929,22 @@ test_misc5(void) CHECK_PTR(str1hndl, "create_struct1"); /* Create the dataspace */ - dims[0] = MISC5_NELMTOPLVL; + dims[0] = MISC5_NELMTOPLVL; space_id = H5Screate_simple(MISC5_DSETRANK, dims, NULL); CHECK(space_id, FAIL, "H5Screate_simple"); /* Create the dataset */ - dataset_id = H5Dcreate2(loc_id, MISC5_DSETNAME, str1hndl->st1h_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id = H5Dcreate2(loc_id, MISC5_DSETNAME, str1hndl->st1h_id, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(dataset_id, FAIL, "H5Dcreate2"); /* Create the variable-length buffer */ buf.len = MISC5_DBGNELM1; - buf.p = HDmalloc((buf.len) * sizeof(misc5_struct1)); + buf.p = HDmalloc((buf.len) * sizeof(misc5_struct1)); CHECK_PTR(buf.p, "HDmalloc"); /* Create the top-level VL information */ - for(i = 0; i < MISC5_DBGNELM1; i++) + for (i = 0; i < MISC5_DBGNELM1; i++) set_struct1(&(((misc5_struct1 *)(buf.p))[i])); /* Write the data out */ @@ -952,7 +952,7 @@ test_misc5(void) CHECK(ret, FAIL, "H5Dwrite"); /* Release the top-level VL information */ - for(j = 0; j < MISC5_DBGNELM1; j++) + for (j = 0; j < MISC5_DBGNELM1; j++) clear_struct1(&(((misc5_struct1 *)(buf.p))[j])); /* Free the variable-length buffer */ @@ -963,16 +963,15 @@ test_misc5(void) CHECK(ret, FAIL, "H5Dclose"); /* Close dataspace */ - ret=H5Sclose(space_id); - CHECK(ret,FAIL,"H5Sclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); /* Delete memory structures */ delete_struct1(str1hndl); /* Close file */ - ret=H5Fclose(loc_id); - CHECK(ret,FAIL,"H5Fclose"); - + ret = H5Fclose(loc_id); + CHECK(ret, FAIL, "H5Fclose"); /* Read the dataset back in & verify it */ loc_id = H5Fopen(MISC5_FILE, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -995,38 +994,45 @@ test_misc5(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the correct information was read in */ - for(i=0; i<(buf.len); i++) { + for (i = 0; i < (buf.len); i++) { /* HDprintf("[%d]=%d\n",i, ((misc5_struct1 *)(buf.p))[i].st1_el1); */ - VERIFY(((misc5_struct1 *)(buf.p))[i].st1_el1,MISC5_DBGELVAL1,"H5Dread"); - for(j=0; j<(((misc5_struct1 *)(buf.p)) [i].st1_el2.len); j++) { - /* HDprintf(" [%d]=%d\n",j, ((misc5_struct2 *)(((misc5_struct1 *) (buf.p))[i].st1_el2.p))[j].st2_el1); */ - VERIFY(((misc5_struct2 *)(((misc5_struct1 *) (buf.p))[i].st1_el2.p))[j].st2_el1, MISC5_DBGELVAL2,"H5Dread"); - for(k=0; k<(((misc5_struct2 *) (((misc5_struct1 *)(buf.p))[i]. st1_el2.p))[j].st2_el2.len); k++) { - /* HDprintf(" [%d]=%d\n",k, ((misc5_struct3 *)(((misc5_struct2 *) (((misc5_struct1 *)(buf.p))[i]. st1_el2.p))[j].st2_el2.p))[k].st3_el1); */ - VERIFY(((misc5_struct3 *)(((misc5_struct2 *) (((misc5_struct1 *)(buf.p))[i]. st1_el2.p))[j].st2_el2.p))[k].st3_el1, MISC5_DBGELVAL3,"H5Dread"); + VERIFY(((misc5_struct1 *)(buf.p))[i].st1_el1, MISC5_DBGELVAL1, "H5Dread"); + for (j = 0; j < (((misc5_struct1 *)(buf.p))[i].st1_el2.len); j++) { + /* HDprintf(" [%d]=%d\n",j, ((misc5_struct2 *)(((misc5_struct1 *) + * (buf.p))[i].st1_el2.p))[j].st2_el1); */ + VERIFY(((misc5_struct2 *)(((misc5_struct1 *)(buf.p))[i].st1_el2.p))[j].st2_el1, MISC5_DBGELVAL2, + "H5Dread"); + for (k = 0; k < (((misc5_struct2 *)(((misc5_struct1 *)(buf.p))[i].st1_el2.p))[j].st2_el2.len); + k++) { + /* HDprintf(" [%d]=%d\n",k, ((misc5_struct3 *)(((misc5_struct2 *) (((misc5_struct1 + * *)(buf.p))[i]. st1_el2.p))[j].st2_el2.p))[k].st3_el1); */ + VERIFY(((misc5_struct3 *)(((misc5_struct2 *)(((misc5_struct1 *)(buf.p))[i].st1_el2.p))[j] + .st2_el2.p))[k] + .st3_el1, + MISC5_DBGELVAL3, "H5Dread"); } /* end for */ } } /* Reclaim the memory for the VL information */ - ret=H5Treclaim(mem_type_id, space_id, H5P_DEFAULT, &buf); - CHECK(ret,FAIL,"H5Treclaim"); + ret = H5Treclaim(mem_type_id, space_id, H5P_DEFAULT, &buf); + CHECK(ret, FAIL, "H5Treclaim"); /* Close dataspace */ - ret=H5Sclose(space_id); - CHECK(ret,FAIL,"H5Sclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); /* Close dataset */ - ret=H5Tclose(mem_type_id); - CHECK(ret,FAIL,"H5Tclose"); + ret = H5Tclose(mem_type_id); + CHECK(ret, FAIL, "H5Tclose"); /* Close dataset */ - ret=H5Dclose(dataset_id); - CHECK(ret,FAIL,"H5Dclose"); + ret = H5Dclose(dataset_id); + CHECK(ret, FAIL, "H5Dclose"); /* Close file */ - ret=H5Fclose(loc_id); - CHECK(ret,FAIL,"H5Fclose"); + ret = H5Fclose(loc_id); + CHECK(ret, FAIL, "H5Fclose"); } /* end test_misc5() */ @@ -1039,11 +1045,11 @@ test_misc5(void) static void test_misc6(void) { - hid_t loc_id, space_id, dataset_id; - hid_t attr_id; - char attr_name[16]; + hid_t loc_id, space_id, dataset_id; + hid_t attr_id; + char attr_name[16]; unsigned u; - herr_t ret; + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing object header continuation code \n")); @@ -1057,7 +1063,8 @@ test_misc6(void) CHECK(space_id, FAIL, "H5Screate"); /* Create the first dataset */ - dataset_id = H5Dcreate2(loc_id, MISC6_DSETNAME1, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id = + H5Dcreate2(loc_id, MISC6_DSETNAME1, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset_id, FAIL, "H5Dcreate2"); /* Close dataset */ @@ -1065,7 +1072,8 @@ test_misc6(void) CHECK(ret, FAIL, "H5Dclose"); /* Create the second dataset */ - dataset_id = H5Dcreate2(loc_id, MISC6_DSETNAME2, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id = + H5Dcreate2(loc_id, MISC6_DSETNAME2, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset_id, FAIL, "H5Dcreate2"); /* Close dataset */ @@ -1077,7 +1085,7 @@ test_misc6(void) CHECK(ret, FAIL, "H5Fclose"); /* Loop through adding attributes to each dataset */ - for(u = 0; u < MISC6_NUMATTR; u++) { + for (u = 0; u < MISC6_NUMATTR; u++) { /* Create name for attribute */ HDsprintf(attr_name, "Attr#%u", u); @@ -1085,7 +1093,6 @@ test_misc6(void) loc_id = H5Fopen(MISC6_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(loc_id, FAIL, "H5Fopen"); - /* Open first dataset */ dataset_id = H5Dopen2(loc_id, MISC6_DSETNAME1, H5P_DEFAULT); CHECK(dataset_id, FAIL, "H5Dopen2"); @@ -1102,7 +1109,6 @@ test_misc6(void) ret = H5Dclose(dataset_id); CHECK(ret, FAIL, "H5Dclose"); - /* Open second dataset */ dataset_id = H5Dopen2(loc_id, MISC6_DSETNAME2, H5P_DEFAULT); CHECK(dataset_id, FAIL, "H5Dopen2"); @@ -1119,15 +1125,14 @@ test_misc6(void) ret = H5Dclose(dataset_id); CHECK(ret, FAIL, "H5Dclose"); - /* Close file */ ret = H5Fclose(loc_id); - CHECK(ret,FAIL,"H5Fclose"); + CHECK(ret, FAIL, "H5Fclose"); } /* end for */ /* Close dataspace */ - ret=H5Sclose(space_id); - CHECK(ret,FAIL,"H5Sclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); } /* end test_misc6() */ @@ -1140,8 +1145,8 @@ test_misc6(void) static void test_misc7(void) { - hid_t fid, did, tid, sid; - int enum_value=1; + hid_t fid, did, tid, sid; + int enum_value = 1; herr_t ret; /* Output message about test being performed */ @@ -1240,27 +1245,27 @@ test_misc7(void) static void test_misc8(void) { - hid_t fid, did, sid; - hid_t fapl; /* File access property list */ - hid_t dcpl; /* Dataset creation property list */ - int rank=MISC8_RANK; - hsize_t dims[MISC8_RANK]={MISC8_DIM0,MISC8_DIM1}; - hsize_t chunk_dims[MISC8_RANK]={MISC8_CHUNK_DIM0,MISC8_CHUNK_DIM1}; - hsize_t storage_size; /* Number of bytes of raw data storage used */ - int *wdata; /* Data to write */ - int *tdata; /* Temporary pointer to data write */ + hid_t fid, did, sid; + hid_t fapl; /* File access property list */ + hid_t dcpl; /* Dataset creation property list */ + int rank = MISC8_RANK; + hsize_t dims[MISC8_RANK] = {MISC8_DIM0, MISC8_DIM1}; + hsize_t chunk_dims[MISC8_RANK] = {MISC8_CHUNK_DIM0, MISC8_CHUNK_DIM1}; + hsize_t storage_size; /* Number of bytes of raw data storage used */ + int * wdata; /* Data to write */ + int * tdata; /* Temporary pointer to data write */ #ifdef VERIFY_DATA int *rdata; /* Data to read */ int *tdata2; /* Temporary pointer to data to read */ -#endif /* VERIFY_DATA */ - unsigned u,v; /* Local index variables */ - int mdc_nelmts; /* Metadata number of elements */ - size_t rdcc_nelmts; /* Raw data number of elements */ - size_t rdcc_nbytes; /* Raw data number of bytes */ - double rdcc_w0; /* Raw data write percentage */ - hsize_t start[MISC8_RANK]; /* Hyperslab start */ - hsize_t count[MISC8_RANK]; /* Hyperslab block count */ - herr_t ret; +#endif /* VERIFY_DATA */ + unsigned u, v; /* Local index variables */ + int mdc_nelmts; /* Metadata number of elements */ + size_t rdcc_nelmts; /* Raw data number of elements */ + size_t rdcc_nbytes; /* Raw data number of bytes */ + double rdcc_w0; /* Raw data write percentage */ + hsize_t start[MISC8_RANK]; /* Hyperslab start */ + hsize_t count[MISC8_RANK]; /* Hyperslab block count */ + herr_t ret; /* Output message about test being performed */ MESSAGE(5, ("Testing dataset storage sizes\n")); @@ -1274,9 +1279,9 @@ test_misc8(void) #endif /* VERIFY_DATA */ /* Initialize values */ - tdata=wdata; - for(u=0; u= (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); -#else /* Compression is not configured */ - if(storage_size != (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); + if (storage_size >= (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n", __LINE__, + (unsigned)storage_size); +#else /* Compression is not configured */ + if (storage_size != (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n", __LINE__, + (unsigned)storage_size); #endif /* H5_HAVE_FILTER_DEFLATE */ /* Close dataset ID */ @@ -1593,11 +1610,13 @@ test_misc8(void) storage_size = H5Dget_storage_size(did); CHECK(storage_size, 0, "H5Dget_storage_size"); #ifdef H5_HAVE_FILTER_DEFLATE - if(storage_size >= (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); -#else /* Compression is not configured */ - if(storage_size != (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); + if (storage_size >= (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n", __LINE__, + (unsigned)storage_size); +#else /* Compression is not configured */ + if (storage_size != (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n", __LINE__, + (unsigned)storage_size); #endif /* H5_HAVE_FILTER_DEFLATE */ /* Write entire dataset */ @@ -1610,23 +1629,26 @@ test_misc8(void) CHECK(ret, FAIL, "H5Dread"); /* Check values written */ - tdata=wdata; - tdata2=rdata; - for(u=0; u=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); + if (storage_size >= (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n", __LINE__, + (unsigned)storage_size); #else - if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); + if (storage_size != (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n", __LINE__, + (unsigned)storage_size); #endif /*H5_HAVE_FILTER_DEFLATE*/ /* Close dataset ID */ @@ -1653,11 +1675,13 @@ test_misc8(void) storage_size = H5Dget_storage_size(did); CHECK(storage_size, 0, "H5Dget_storage_size"); #ifdef H5_HAVE_FILTER_DEFLATE - if(storage_size >= (4 * MISC8_CHUNK_DIM0 * MISC8_CHUNK_DIM1 * H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); -#else /* Compression is not configured */ - if(storage_size != (4 * MISC8_CHUNK_DIM0 * MISC8_CHUNK_DIM1 * H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); + if (storage_size >= (4 * MISC8_CHUNK_DIM0 * MISC8_CHUNK_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n", __LINE__, + (unsigned)storage_size); +#else /* Compression is not configured */ + if (storage_size != (4 * MISC8_CHUNK_DIM0 * MISC8_CHUNK_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n", __LINE__, + (unsigned)storage_size); #endif /* H5_HAVE_FILTER_DEFLATE */ /* Write entire dataset */ @@ -1670,23 +1694,26 @@ test_misc8(void) CHECK(ret, FAIL, "H5Dread"); /* Check values written */ - tdata=wdata; - tdata2=rdata; - for(u=0; u=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); + if (storage_size >= (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n", __LINE__, + (unsigned)storage_size); #else - if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) - TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); + if (storage_size != (MISC8_DIM0 * MISC8_DIM1 * H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n", __LINE__, + (unsigned)storage_size); #endif /*H5_HAVE_FILTER_DEFLATE*/ /* Close dataset ID */ @@ -1695,15 +1722,15 @@ test_misc8(void) #endif /* H5_HAVE_PARALLEL */ /* Close dataset creation property list */ - ret=H5Pclose(dcpl); + ret = H5Pclose(dcpl); CHECK(ret, FAIL, "H5Pclose"); /* Close dataspace */ - ret=H5Sclose(sid); + ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); /* Close file */ - ret=H5Fclose(fid); + ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); /* Free the read & write buffers */ @@ -1722,7 +1749,7 @@ test_misc8(void) static void test_misc9(void) { - hid_t fapl, fid; + hid_t fapl, fid; herr_t ret; /* Output message about test being performed */ @@ -1735,9 +1762,9 @@ test_misc9(void) CHECK(ret, FAIL, "H5Pset_fapl_core"); fid = H5Fopen(MISC9_FILE, H5F_ACC_RDWR, fapl); - VERIFY(fid,FAIL,"H5Fopen"); + VERIFY(fid, FAIL, "H5Fopen"); - ret=H5Pclose(fapl); + ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pset_fapl_core"); } /* end test_misc9() */ @@ -1754,11 +1781,11 @@ test_misc9(void) static void test_misc10(void) { - hid_t file, file_new; /* File IDs for old & new files */ - hid_t fcpl; /* File creation property list */ - hid_t dataset, dataset_new; /* Dataset IDs for old & new datasets */ - hid_t dcpl; /* Dataset creation property list */ - hid_t space, type; /* Old dataset's dataspace & datatype */ + hid_t file, file_new; /* File IDs for old & new files */ + hid_t fcpl; /* File creation property list */ + hid_t dataset, dataset_new; /* Dataset IDs for old & new datasets */ + hid_t dcpl; /* Dataset creation property list */ + hid_t space, type; /* Old dataset's dataspace & datatype */ const char *testfile = H5_get_srcdir_filename(MISC10_FILE_OLD); /* Corrected test file name */ herr_t ret; @@ -1768,22 +1795,22 @@ test_misc10(void) /* * Open the old file and the dataset and get old settings. */ - file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file, FAIL, "H5Fopen"); - fcpl = H5Fget_create_plist(file); + fcpl = H5Fget_create_plist(file); CHECK(fcpl, FAIL, "H5Fget_create_plist"); dataset = H5Dopen2(file, MISC10_DSETNAME, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dopen2"); - dcpl = H5Dget_create_plist(dataset); + dcpl = H5Dget_create_plist(dataset); CHECK(dcpl, FAIL, "H5Dget_create_plist"); - space = H5Dget_space(dataset); + space = H5Dget_space(dataset); CHECK(space, FAIL, "H5Dget_space"); - type = H5Dget_type(dataset); + type = H5Dget_type(dataset); CHECK(type, FAIL, "H5Dget_type"); /* Create new file & dataset */ - file_new = H5Fcreate(MISC10_FILE_NEW, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); + file_new = H5Fcreate(MISC10_FILE_NEW, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); CHECK(file_new, FAIL, "H5Fcreate"); dataset_new = H5Dcreate2(file_new, MISC10_DSETNAME, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -1822,20 +1849,20 @@ test_misc10(void) static void test_misc11(void) { - hid_t file; /* File IDs for old & new files */ - hid_t fcpl; /* File creation property list */ - hsize_t userblock; /* Userblock size retrieved from FCPL */ - size_t off_size; /* Size of offsets in the file */ - size_t len_size; /* Size of lengths in the file */ - unsigned sym_ik; /* Symbol table B-tree initial 'K' value */ - unsigned istore_ik; /* Indexed storage B-tree initial 'K' value */ - unsigned sym_lk; /* Symbol table B-tree leaf 'K' value */ - unsigned nindexes; /* Shared message number of indexes */ - H5F_info2_t finfo; /* global information about file */ + hid_t file; /* File IDs for old & new files */ + hid_t fcpl; /* File creation property list */ + hsize_t userblock; /* Userblock size retrieved from FCPL */ + size_t off_size; /* Size of offsets in the file */ + size_t len_size; /* Size of lengths in the file */ + unsigned sym_ik; /* Symbol table B-tree initial 'K' value */ + unsigned istore_ik; /* Indexed storage B-tree initial 'K' value */ + unsigned sym_lk; /* Symbol table B-tree leaf 'K' value */ + unsigned nindexes; /* Shared message number of indexes */ + H5F_info2_t finfo; /* global information about file */ H5F_fspace_strategy_t strategy; /* File space strategy */ - hsize_t threshold; /* Free-space section threshold */ - hbool_t persist; /* To persist free-space or not */ - herr_t ret; /* Generic return value */ + hsize_t threshold; /* Free-space section threshold */ + hbool_t persist; /* To persist free-space or not */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing file creation properties retrieved correctly\n")); @@ -1845,51 +1872,54 @@ test_misc11(void) */ /* Create file with default file creation property list */ - file= H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC , H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); /* Get the file's version information */ ret = H5Fget_info2(file, &finfo); CHECK(ret, FAIL, "H5Fget_info2"); - VERIFY(finfo.super.version, 0,"H5Fget_info2"); - VERIFY(finfo.free.version, 0,"H5Fget_info2"); - VERIFY(finfo.sohm.version, 0,"H5Fget_info2"); + VERIFY(finfo.super.version, 0, "H5Fget_info2"); + VERIFY(finfo.free.version, 0, "H5Fget_info2"); + VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); /* Close file */ - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); - /* Create a file creation property list */ fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); /* Set all the properties in the FCPL */ - ret=H5Pset_userblock(fcpl,(hsize_t)MISC11_USERBLOCK); + ret = H5Pset_userblock(fcpl, (hsize_t)MISC11_USERBLOCK); CHECK(ret, FAIL, "H5Pset_userblock"); ret = H5Pset_sizes(fcpl, (size_t)MISC11_SIZEOF_OFF, (size_t)MISC11_SIZEOF_LEN); CHECK(ret, FAIL, "H5Pset_sizes"); /* This should fail as (32770*2) will exceed ^16 - 2 bytes for storing btree entries */ - H5E_BEGIN_TRY { - ret=H5Pset_sym_k(fcpl, 32770, 0); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5Pset_sym_k(fcpl, 32770, 0); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_sym_k"); - ret=H5Pset_sym_k(fcpl,MISC11_SYM_IK,MISC11_SYM_LK); + ret = H5Pset_sym_k(fcpl, MISC11_SYM_IK, MISC11_SYM_LK); CHECK(ret, FAIL, "H5Pset_sym_k"); /* This should fail as (32770*2) will exceed ^16 - 2 bytes for storing btree entries */ - H5E_BEGIN_TRY { - ret=H5Pset_istore_k(fcpl, 32770); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5Pset_istore_k(fcpl, 32770); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pset_istore_k"); - ret=H5Pset_istore_k(fcpl,MISC11_ISTORE_IK); + ret = H5Pset_istore_k(fcpl, MISC11_ISTORE_IK); CHECK(ret, FAIL, "H5Pset_istore_k"); - ret=H5Pset_shared_mesg_nindexes(fcpl,MISC11_NINDEXES); + ret = H5Pset_shared_mesg_nindexes(fcpl, MISC11_NINDEXES); CHECK(ret, FAIL, "H5Pset_shared_mesg"); ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); @@ -1900,22 +1930,22 @@ test_misc11(void) */ /* Create file with custom file creation property list */ - file= H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); + file = H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); /* Close FCPL */ - ret=H5Pclose(fcpl); + ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); /* Get the file's version information */ ret = H5Fget_info2(file, &finfo); CHECK(ret, FAIL, "H5Fget_info2"); - VERIFY(finfo.super.version, 2,"H5Fget_info2"); - VERIFY(finfo.free.version, 0,"H5Fget_info2"); - VERIFY(finfo.sohm.version, 0,"H5Fget_info2"); + VERIFY(finfo.super.version, 2, "H5Fget_info2"); + VERIFY(finfo.free.version, 0, "H5Fget_info2"); + VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); /* Close file */ - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Re-open the file */ @@ -1923,36 +1953,36 @@ test_misc11(void) CHECK(file, FAIL, "H5Fcreate"); /* Get the file's creation property list */ - fcpl = H5Fget_create_plist(file); + fcpl = H5Fget_create_plist(file); CHECK(fcpl, FAIL, "H5Fget_create_plist"); /* Get the file's version information */ ret = H5Fget_info2(file, &finfo); CHECK(ret, FAIL, "H5Fget_info2"); - VERIFY(finfo.super.version, 2,"H5Fget_info2"); - VERIFY(finfo.free.version, 0,"H5Fget_info2"); - VERIFY(finfo.sohm.version, 0,"H5Fget_info2"); + VERIFY(finfo.super.version, 2, "H5Fget_info2"); + VERIFY(finfo.free.version, 0, "H5Fget_info2"); + VERIFY(finfo.sohm.version, 0, "H5Fget_info2"); /* Retrieve all the property values & check them */ - ret=H5Pget_userblock(fcpl,&userblock); + ret = H5Pget_userblock(fcpl, &userblock); CHECK(ret, FAIL, "H5Pget_userblock"); VERIFY(userblock, MISC11_USERBLOCK, "H5Pget_userblock"); - ret=H5Pget_sizes(fcpl,&off_size,&len_size); + ret = H5Pget_sizes(fcpl, &off_size, &len_size); CHECK(ret, FAIL, "H5Pget_sizes"); VERIFY(off_size, MISC11_SIZEOF_OFF, "H5Pget_sizes"); VERIFY(len_size, MISC11_SIZEOF_LEN, "H5Pget_sizes"); - ret=H5Pget_sym_k(fcpl,&sym_ik,&sym_lk); + ret = H5Pget_sym_k(fcpl, &sym_ik, &sym_lk); CHECK(ret, FAIL, "H5Pget_sym_k"); VERIFY(sym_ik, MISC11_SYM_IK, "H5Pget_sym_k"); VERIFY(sym_lk, MISC11_SYM_LK, "H5Pget_sym_k"); - ret=H5Pget_istore_k(fcpl,&istore_ik); + ret = H5Pget_istore_k(fcpl, &istore_ik); CHECK(ret, FAIL, "H5Pget_istore_k"); VERIFY(istore_ik, MISC11_ISTORE_IK, "H5Pget_istore_k"); - ret=H5Pget_shared_mesg_nindexes(fcpl,&nindexes); + ret = H5Pget_shared_mesg_nindexes(fcpl, &nindexes); CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes"); VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); @@ -1963,11 +1993,11 @@ test_misc11(void) VERIFY(threshold, 1, "H5Pget_file_space_strategy"); /* Close file */ - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Close FCPL */ - ret=H5Pclose(fcpl); + ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); } /* end test_misc11() */ @@ -1980,33 +2010,30 @@ test_misc11(void) static void test_misc12(void) { - const char *wdata [MISC12_SPACE1_DIM1]= { + const char *wdata[MISC12_SPACE1_DIM1] = { "Four score and seven years ago our forefathers brought forth on this continent a new nation,", "conceived in liberty and dedicated to the proposition that all men are created equal.", "Now we are engaged in a great civil war,", - "testing whether that nation or any nation so conceived and so dedicated can long endure." - }; - const char *wdata1 [MISC12_APPEND_SIZE]= { - "O Gloria inmarcesible! O Jubilo inmortal! En surcos de dolores, el", - "bien germina ya! Ceso la horrible noche, La libertad sublime", - "derrama las auroras de su invencible luz.", - "La humanidad entera, que entre cadenas gime, comprende", - "las palabras del que murio en la cruz." - }; - char *rdata [MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE]; /* Information read in */ - hid_t fid1; - hid_t dataset; - hid_t sid1, space, memspace; - hid_t tid1, cparms; - hsize_t dims1[] = {MISC12_SPACE1_DIM1}; - hsize_t dimsn[] = {MISC12_APPEND_SIZE}; - hsize_t maxdims1[1] = {H5S_UNLIMITED}; - hsize_t chkdims1[1] = {MISC12_CHUNK_SIZE}; - hsize_t newsize[1] = {MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE}; - hsize_t offset[1] = {MISC12_SPACE1_DIM1}; - hsize_t count[1] = {MISC12_APPEND_SIZE}; - int i; /* counting variable */ - herr_t ret; /* Generic return value */ + "testing whether that nation or any nation so conceived and so dedicated can long endure."}; + const char *wdata1[MISC12_APPEND_SIZE] = { + "O Gloria inmarcesible! O Jubilo inmortal! En surcos de dolores, el", + "bien germina ya! Ceso la horrible noche, La libertad sublime", + "derrama las auroras de su invencible luz.", "La humanidad entera, que entre cadenas gime, comprende", + "las palabras del que murio en la cruz."}; + char * rdata[MISC12_SPACE1_DIM1 + MISC12_APPEND_SIZE]; /* Information read in */ + hid_t fid1; + hid_t dataset; + hid_t sid1, space, memspace; + hid_t tid1, cparms; + hsize_t dims1[] = {MISC12_SPACE1_DIM1}; + hsize_t dimsn[] = {MISC12_APPEND_SIZE}; + hsize_t maxdims1[1] = {H5S_UNLIMITED}; + hsize_t chkdims1[1] = {MISC12_CHUNK_SIZE}; + hsize_t newsize[1] = {MISC12_SPACE1_DIM1 + MISC12_APPEND_SIZE}; + hsize_t offset[1] = {MISC12_SPACE1_DIM1}; + hsize_t count[1] = {MISC12_APPEND_SIZE}; + int i; /* counting variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing VL-type in chunked dataset\n")); @@ -2065,12 +2092,14 @@ test_misc12(void) ret = H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Dread"); - for(i = 0; i < MISC12_SPACE1_DIM1; i++) - if(HDstrcmp(wdata[i], rdata[i])) - TestErrPrintf("Error on line %d: wdata[%d]=%s, rdata[%d]=%s\n", __LINE__, i, wdata[i], i, rdata[i]); - for(; i < (MISC12_SPACE1_DIM1 + MISC12_APPEND_SIZE); i++) - if(HDstrcmp(wdata1[i - MISC12_SPACE1_DIM1], rdata[i])) - TestErrPrintf("Error on line %d: wdata1[%d]=%s, rdata[%d]=%s\n", __LINE__, i - MISC12_SPACE1_DIM1, wdata1[i - MISC12_SPACE1_DIM1], i, rdata[i]); + for (i = 0; i < MISC12_SPACE1_DIM1; i++) + if (HDstrcmp(wdata[i], rdata[i])) + TestErrPrintf("Error on line %d: wdata[%d]=%s, rdata[%d]=%s\n", __LINE__, i, wdata[i], i, + rdata[i]); + for (; i < (MISC12_SPACE1_DIM1 + MISC12_APPEND_SIZE); i++) + if (HDstrcmp(wdata1[i - MISC12_SPACE1_DIM1], rdata[i])) + TestErrPrintf("Error on line %d: wdata1[%d]=%s, rdata[%d]=%s\n", __LINE__, i - MISC12_SPACE1_DIM1, + wdata1[i - MISC12_SPACE1_DIM1], i, rdata[i]); ret = H5Sselect_all(space); CHECK(ret, FAIL, "H5Sselect_all"); @@ -2102,7 +2131,7 @@ misc13_init_data(unsigned *original_data) { unsigned u; - for(u = 0; u < MISC13_DIM1; u++) + for (u = 0; u < MISC13_DIM1; u++) original_data[u] = u; } @@ -2111,8 +2140,8 @@ misc13_verify_data_match(const unsigned *original_data, const unsigned *read_dat { unsigned u; - for(u = 0; u < MISC13_DIM1; u++) - if(original_data[u] != read_data[u]) + for (u = 0; u < MISC13_DIM1; u++) + if (original_data[u] != read_data[u]) return FALSE; return TRUE; @@ -2121,14 +2150,14 @@ misc13_verify_data_match(const unsigned *original_data, const unsigned *read_dat static void misc13_create_dataset(hid_t loc_id, const char *name, hid_t dcpl, const unsigned *data) { - hid_t dsid = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t dims[MISC13_RANK]; /* Dataset dimensions */ - herr_t ret; /* Generic return value */ + hid_t dsid = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dims[MISC13_RANK]; /* Dataset dimensions */ + herr_t ret; /* Generic return value */ /* Create dataspace for use with dataset */ dims[0] = MISC13_DIM1; - sid = H5Screate_simple(MISC13_RANK, dims, NULL); + sid = H5Screate_simple(MISC13_RANK, dims, NULL); CHECK(sid, FAIL, "H5Screate_simple"); /* Create contiguous dataset in root group */ @@ -2152,9 +2181,9 @@ misc13_create_dataset(hid_t loc_id, const char *name, hid_t dcpl, const unsigned static void misc13_verify_dataset(hid_t loc_id, const char *name, const unsigned *data) { - unsigned *read_data = NULL; /* Data to write to dataset */ - hid_t dsid = -1; /* Dataset ID */ - herr_t ret; /* Generic return value */ + unsigned *read_data = NULL; /* Data to write to dataset */ + hid_t dsid = -1; /* Dataset ID */ + herr_t ret; /* Generic return value */ /* Create a data buffer for the dataset read */ read_data = (unsigned *)HDcalloc(MISC13_DIM1, sizeof(unsigned)); @@ -2184,13 +2213,13 @@ misc13_verify_dataset(hid_t loc_id, const char *name, const unsigned *data) static void misc13_create_hdf_file(const char *name, const unsigned *data) { - hid_t fid = -1; /* File ID */ - hid_t gid1 = -1; /* Group ID (level 1) */ - hid_t gid2 = -1; /* Group ID (level 2) */ - hid_t tid = -1; /* Datatype ID */ - hid_t dcplid = -1; /* Dataset creation property list ID */ - hsize_t chunk_dims[MISC13_RANK]; /* Chunk dimensions */ - herr_t ret; /* Generic return value */ + hid_t fid = -1; /* File ID */ + hid_t gid1 = -1; /* Group ID (level 1) */ + hid_t gid2 = -1; /* Group ID (level 2) */ + hid_t tid = -1; /* Datatype ID */ + hid_t dcplid = -1; /* Dataset creation property list ID */ + hsize_t chunk_dims[MISC13_RANK]; /* Chunk dimensions */ + herr_t ret; /* Generic return value */ /* Create file */ fid = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2206,7 +2235,7 @@ misc13_create_hdf_file(const char *name, const unsigned *data) /* Use chunked storage for this DCPL */ chunk_dims[0] = MISC13_CHUNK_DIM1; - ret = H5Pset_chunk(dcplid, MISC13_RANK, chunk_dims); + ret = H5Pset_chunk(dcplid, MISC13_RANK, chunk_dims); CHECK(ret, FAIL, "H5Pset_chunk"); /* Create contiguous dataset in root group */ @@ -2274,13 +2303,13 @@ misc13_create_hdf_file(const char *name, const unsigned *data) static void misc13_insert_user_block(const char *old_name, const char *new_name, const char *str, size_t size) { - FILE *new_fp = NULL; /* Pointers to new & old files */ - FILE *old_fp = NULL; - void *user_block = NULL; /* Pointer to user block to write to file */ - void *copy_buf = NULL; /* Pointer to buffer for copying data */ - size_t written; /* Amount of data written to new file */ - size_t read_in; /* Amount of data read in from old file */ - int ret; /* Generic status value */ + FILE * new_fp = NULL; /* Pointers to new & old files */ + FILE * old_fp = NULL; + void * user_block = NULL; /* Pointer to user block to write to file */ + void * copy_buf = NULL; /* Pointer to buffer for copying data */ + size_t written; /* Amount of data written to new file */ + size_t read_in; /* Amount of data read in from old file */ + int ret; /* Generic status value */ /* Allocate space for the user block */ user_block = HDcalloc(size, (size_t)1); @@ -2290,7 +2319,7 @@ misc13_insert_user_block(const char *old_name, const char *new_name, const char HDmemcpy(user_block, str, HDstrlen(str)); /* Open the new file */ - new_fp = HDfopen(new_name,"wb"); + new_fp = HDfopen(new_name, "wb"); CHECK_PTR(new_fp, "HDfopen"); /* Write the user block to the new file */ @@ -2298,7 +2327,7 @@ misc13_insert_user_block(const char *old_name, const char *new_name, const char VERIFY(written, size, "HDfwrite"); /* Open the old file */ - old_fp = HDfopen(old_name,"rb"); + old_fp = HDfopen(old_name, "rb"); CHECK_PTR(old_fp, "HDfopen"); /* Allocate space for the copy buffer */ @@ -2306,7 +2335,7 @@ misc13_insert_user_block(const char *old_name, const char *new_name, const char CHECK_PTR(copy_buf, "HDmalloc"); /* Copy data from the old file to the new file */ - while((read_in = HDfread(copy_buf, (size_t)1, (size_t)MISC13_COPY_BUF_SIZE, old_fp)) > 0) { + while ((read_in = HDfread(copy_buf, (size_t)1, (size_t)MISC13_COPY_BUF_SIZE, old_fp)) > 0) { /* Write the data to the new file */ written = HDfwrite(copy_buf, (size_t)1, read_in, new_fp); VERIFY(written, read_in, "HDfwrite"); @@ -2330,15 +2359,15 @@ misc13_insert_user_block(const char *old_name, const char *new_name, const char static void misc13_verify_file(const char *name, const unsigned *data, hsize_t userblock_size, - hbool_t check_for_new_dataset) + hbool_t check_for_new_dataset) { - hid_t fid = -1; /* File ID */ - hid_t gid1 = -1; /* Group IDs */ - hid_t gid2 = -1; /* Group IDs */ - hid_t tid = -1; /* Datatype ID */ - hid_t fcplid = -1; /* File creation property list ID */ - hsize_t ub_size_out; /* Userblock size retrieved from FCPL */ - herr_t ret; /* Generic return value */ + hid_t fid = -1; /* File ID */ + hid_t gid1 = -1; /* Group IDs */ + hid_t gid2 = -1; /* Group IDs */ + hid_t tid = -1; /* Datatype ID */ + hid_t fcplid = -1; /* File creation property list ID */ + hsize_t ub_size_out; /* Userblock size retrieved from FCPL */ + herr_t ret; /* Generic return value */ /* Open the file */ fid = H5Fopen(name, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -2366,7 +2395,7 @@ misc13_verify_file(const char *name, const unsigned *data, hsize_t userblock_siz misc13_verify_dataset(fid, MISC13_DSET2_NAME, data); /* Verify the "new" contiguous dataset in the root group, if asked */ - if(check_for_new_dataset) + if (check_for_new_dataset) misc13_verify_dataset(fid, MISC13_DSET3_NAME, data); /* Open the named datatype in the root group */ @@ -2422,8 +2451,8 @@ misc13_verify_file(const char *name, const unsigned *data, hsize_t userblock_siz static void misc13_add_to_new_file(const char *name, const unsigned *data) { - hid_t fid = -1; /* File ID */ - herr_t ret; /* Generic return value */ + hid_t fid = -1; /* File ID */ + herr_t ret; /* Generic return value */ /* Open the file */ fid = H5Fopen(name, H5F_ACC_RDWR, H5P_DEFAULT); @@ -2447,9 +2476,9 @@ misc13_add_to_new_file(const char *name, const unsigned *data) static void test_misc13(void) { - unsigned *data = NULL; /* Data to write to dataset */ - hsize_t userblock_size; /* Correct size of userblock */ - hbool_t check_for_new_dataset; /* Whether to check for the post-userblock-creation dataset */ + unsigned *data = NULL; /* Data to write to dataset */ + hsize_t userblock_size; /* Correct size of userblock */ + hbool_t check_for_new_dataset; /* Whether to check for the post-userblock-creation dataset */ /* Create a data buffer for the datasets */ data = (unsigned *)HDcalloc(MISC13_DIM1, sizeof(unsigned)); @@ -2462,7 +2491,7 @@ test_misc13(void) misc13_create_hdf_file(MISC13_FILE_1, data); /* Verify file contents are correct */ - userblock_size = 0; + userblock_size = 0; check_for_new_dataset = FALSE; misc13_verify_file(MISC13_FILE_1, data, userblock_size, check_for_new_dataset); @@ -2470,7 +2499,7 @@ test_misc13(void) misc13_insert_user_block(MISC13_FILE_1, MISC13_FILE_2, "Test String", (size_t)MISC13_USERBLOCK_SIZE); /* Verify file contents are still correct */ - userblock_size = MISC13_USERBLOCK_SIZE; + userblock_size = MISC13_USERBLOCK_SIZE; check_for_new_dataset = FALSE; misc13_verify_file(MISC13_FILE_2, data, userblock_size, check_for_new_dataset); @@ -2478,7 +2507,7 @@ test_misc13(void) misc13_add_to_new_file(MISC13_FILE_2, data); /* Verify file contents are still correct */ - userblock_size = MISC13_USERBLOCK_SIZE; + userblock_size = MISC13_USERBLOCK_SIZE; check_for_new_dataset = TRUE; misc13_verify_file(MISC13_FILE_2, data, userblock_size, check_for_new_dataset); @@ -2496,17 +2525,17 @@ test_misc13(void) static void test_misc14(void) { - hid_t file_id; /* File ID */ - hid_t fapl; /* File access property list ID */ - hid_t DataSpace; /* Dataspace ID */ - hid_t Dataset1; /* Dataset ID #1 */ - hid_t Dataset2; /* Dataset ID #2 */ - hid_t Dataset3; /* Dataset ID #3 */ - double data1 = 5.0F; /* Data to write for dataset #1 */ - double data2 = 10.0F; /* Data to write for dataset #2 */ - double data3 = 15.0F; /* Data to write for dataset #3 */ - double rdata; /* Data read in */ - herr_t ret; /* Generic return value */ + hid_t file_id; /* File ID */ + hid_t fapl; /* File access property list ID */ + hid_t DataSpace; /* Dataspace ID */ + hid_t Dataset1; /* Dataset ID #1 */ + hid_t Dataset2; /* Dataset ID #2 */ + hid_t Dataset3; /* Dataset ID #3 */ + double data1 = 5.0F; /* Data to write for dataset #1 */ + double data2 = 10.0F; /* Data to write for dataset #2 */ + double data3 = 15.0F; /* Data to write for dataset #3 */ + double rdata; /* Data read in */ + herr_t ret; /* Generic return value */ /* Test creating two datasets and deleting the second */ @@ -2527,14 +2556,16 @@ test_misc14(void) CHECK(file_id, FAIL, "H5Fcreate"); /* Create first dataset & write data */ - Dataset1 = H5Dcreate2(file_id, MISC14_DSET1_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + Dataset1 = H5Dcreate2(file_id, MISC14_DSET1_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(Dataset1, FAIL, "H5Dcreate2"); ret = H5Dwrite(Dataset1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data1); CHECK(ret, FAIL, "H5Dwrite"); /* Create second dataset (to be unlinked). */ - Dataset2 = H5Dcreate2(file_id, MISC14_DSET2_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + Dataset2 = H5Dcreate2(file_id, MISC14_DSET2_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(Dataset2, FAIL, "H5Dcreate2"); ret = H5Dwrite(Dataset2, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data2); @@ -2543,8 +2574,8 @@ test_misc14(void) /* Check data from first dataset */ ret = H5Dread(Dataset1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(!H5_DBL_ABS_EQUAL(rdata, data1)) - TestErrPrintf("Error on line %d: data1!=rdata\n",__LINE__); + if (!H5_DBL_ABS_EQUAL(rdata, data1)) + TestErrPrintf("Error on line %d: data1!=rdata\n", __LINE__); /* Unlink second dataset */ ret = H5Ldelete(file_id, MISC14_DSET2_NAME, H5P_DEFAULT); @@ -2557,15 +2588,15 @@ test_misc14(void) /* Verify the data from dataset #1 */ ret = H5Dread(Dataset1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(!H5_DBL_ABS_EQUAL(rdata,data1)) - TestErrPrintf("Error on line %d: data1!=rdata\n",__LINE__); + if (!H5_DBL_ABS_EQUAL(rdata, data1)) + TestErrPrintf("Error on line %d: data1!=rdata\n", __LINE__); /* Close first dataset */ ret = H5Dclose(Dataset1); CHECK(ret, FAIL, "H5Dclose"); /* Close the file */ - ret = H5Fclose (file_id); + ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); /* Test creating two datasets and deleting the first */ @@ -2575,14 +2606,16 @@ test_misc14(void) CHECK(file_id, FAIL, "H5Fcreate"); /* Create first dataset & write data */ - Dataset1 = H5Dcreate2(file_id, MISC14_DSET1_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + Dataset1 = H5Dcreate2(file_id, MISC14_DSET1_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(Dataset1, FAIL, "H5Dcreate2"); ret = H5Dwrite(Dataset1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data1); CHECK(ret, FAIL, "H5Dwrite"); /* Create second dataset */ - Dataset2 = H5Dcreate2(file_id, MISC14_DSET2_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + Dataset2 = H5Dcreate2(file_id, MISC14_DSET2_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(Dataset2, FAIL, "H5Dcreate2"); ret = H5Dwrite(Dataset2, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data2); @@ -2591,8 +2624,8 @@ test_misc14(void) /* Check data from second dataset */ ret = H5Dread(Dataset2, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(!H5_DBL_ABS_EQUAL(rdata,data2)) - TestErrPrintf("Error on line %d: data2!=rdata\n",__LINE__); + if (!H5_DBL_ABS_EQUAL(rdata, data2)) + TestErrPrintf("Error on line %d: data2!=rdata\n", __LINE__); /* Unlink first dataset */ ret = H5Ldelete(file_id, MISC14_DSET1_NAME, H5P_DEFAULT); @@ -2605,15 +2638,15 @@ test_misc14(void) /* Verify the data from dataset #2 */ ret = H5Dread(Dataset2, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(!H5_DBL_ABS_EQUAL(rdata,data2)) - TestErrPrintf("Error on line %d: data2!=rdata\n",__LINE__); + if (!H5_DBL_ABS_EQUAL(rdata, data2)) + TestErrPrintf("Error on line %d: data2!=rdata\n", __LINE__); /* Close second dataset */ ret = H5Dclose(Dataset2); CHECK(ret, FAIL, "H5Dclose"); /* Close the file */ - ret = H5Fclose (file_id); + ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); /* Test creating three datasets and deleting the second */ @@ -2623,21 +2656,24 @@ test_misc14(void) CHECK(file_id, FAIL, "H5Fcreate"); /* Create first dataset & write data */ - Dataset1 = H5Dcreate2(file_id, MISC14_DSET1_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + Dataset1 = H5Dcreate2(file_id, MISC14_DSET1_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(Dataset1, FAIL, "H5Dcreate2"); ret = H5Dwrite(Dataset1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data1); CHECK(ret, FAIL, "H5Dwrite"); /* Create second dataset */ - Dataset2 = H5Dcreate2(file_id, MISC14_DSET2_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + Dataset2 = H5Dcreate2(file_id, MISC14_DSET2_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(Dataset2, FAIL, "H5Dcreate2"); ret = H5Dwrite(Dataset2, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data2); CHECK(ret, FAIL, "H5Dwrite"); /* Create third dataset */ - Dataset3 = H5Dcreate2(file_id, MISC14_DSET3_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + Dataset3 = H5Dcreate2(file_id, MISC14_DSET3_NAME, H5T_NATIVE_DOUBLE, DataSpace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(Dataset2, FAIL, "H5Dcreate2"); ret = H5Dwrite(Dataset3, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data3); @@ -2646,14 +2682,14 @@ test_misc14(void) /* Check data from first dataset */ ret = H5Dread(Dataset1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(!H5_DBL_ABS_EQUAL(rdata,data1)) - TestErrPrintf("Error on line %d: data1!=rdata\n",__LINE__); + if (!H5_DBL_ABS_EQUAL(rdata, data1)) + TestErrPrintf("Error on line %d: data1!=rdata\n", __LINE__); /* Check data from third dataset */ ret = H5Dread(Dataset3, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(!H5_DBL_ABS_EQUAL(rdata,data3)) - TestErrPrintf("Error on line %d: data3!=rdata\n",__LINE__); + if (!H5_DBL_ABS_EQUAL(rdata, data3)) + TestErrPrintf("Error on line %d: data3!=rdata\n", __LINE__); /* Unlink second dataset */ ret = H5Ldelete(file_id, MISC14_DSET2_NAME, H5P_DEFAULT); @@ -2666,14 +2702,14 @@ test_misc14(void) /* Verify the data from dataset #1 */ ret = H5Dread(Dataset1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(!H5_DBL_ABS_EQUAL(rdata,data1)) - TestErrPrintf("Error on line %d: data1!=rdata\n",__LINE__); + if (!H5_DBL_ABS_EQUAL(rdata, data1)) + TestErrPrintf("Error on line %d: data1!=rdata\n", __LINE__); /* Verify the data from dataset #3 */ ret = H5Dread(Dataset3, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata); CHECK(ret, FAIL, "H5Dread"); - if(!H5_DBL_ABS_EQUAL(rdata,data3)) - TestErrPrintf("Error on line %d: data3!=rdata\n",__LINE__); + if (!H5_DBL_ABS_EQUAL(rdata, data3)) + TestErrPrintf("Error on line %d: data3!=rdata\n", __LINE__); /* Close first dataset */ ret = H5Dclose(Dataset1); @@ -2684,13 +2720,13 @@ test_misc14(void) CHECK(ret, FAIL, "H5Dclose"); /* Close the file */ - ret = H5Fclose (file_id); + ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); /* Close shared objects (dataspace & fapl) */ - ret = H5Sclose (DataSpace); + ret = H5Sclose(DataSpace); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Pclose (fapl); + ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); } /* end test_misc14() */ @@ -2704,9 +2740,9 @@ test_misc14(void) static void test_misc15(void) { - hid_t file; /* File ID */ - hid_t fapl; /* File access property list */ - herr_t ret; /* Generic return value */ + hid_t file; /* File ID */ + hid_t fapl; /* File access property list */ + herr_t ret; /* Generic return value */ /* Create the file & get it's FAPL */ file = H5Fcreate(MISC15_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2756,15 +2792,15 @@ test_misc15(void) static void test_misc16(void) { - hid_t file; /* File ID */ - herr_t ret; /* Generic return value */ - char wdata[MISC16_SPACE_DIM][MISC16_STR_SIZE]; - char rdata[MISC16_SPACE_DIM][MISC16_STR_SIZE]; /* Information read in */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hsize_t dims[] = {MISC16_SPACE_DIM}; - int i; + hid_t file; /* File ID */ + herr_t ret; /* Generic return value */ + char wdata[MISC16_SPACE_DIM][MISC16_STR_SIZE]; + char rdata[MISC16_SPACE_DIM][MISC16_STR_SIZE]; /* Information read in */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t dims[] = {MISC16_SPACE_DIM}; + int i; /* Initialize the data */ /* (Note that these are supposed to stress the code, so are a little weird) */ @@ -2804,16 +2840,19 @@ test_misc16(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < MISC16_SPACE_DIM; i++) { - if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) { - TestErrPrintf("Line %u: VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(unsigned)__LINE__, (int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i])); + for (i = 0; i < MISC16_SPACE_DIM; i++) { + if (HDstrlen(wdata[i]) != HDstrlen(rdata[i])) { + TestErrPrintf( + "Line %u: VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", + (unsigned)__LINE__, (int)i, (int)strlen(wdata[i]), (int)i, (int)strlen(rdata[i])); continue; } /* end if */ - if(HDstrcmp(wdata[i], rdata[i]) != 0 ) { - TestErrPrintf("Line %u: VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(unsigned)__LINE__, (int)i,wdata[i],(int)i,rdata[i]); + if (HDstrcmp(wdata[i], rdata[i]) != 0) { + TestErrPrintf("Line %u: VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", + (unsigned)__LINE__, (int)i, wdata[i], (int)i, rdata[i]); continue; } /* end if */ - } /* end for */ + } /* end for */ /* Close Dataset */ ret = H5Dclose(dataset); @@ -2841,15 +2880,15 @@ test_misc16(void) static void test_misc17(void) { - hid_t file; /* File ID */ - herr_t ret; /* Generic return value */ - char wdata[MISC17_SPACE_DIM1][MISC17_SPACE_DIM2]; - char rdata[MISC17_SPACE_DIM1][MISC17_SPACE_DIM2]; /* Information read in */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hsize_t dims[] = {MISC17_SPACE_DIM1, MISC17_SPACE_DIM2}; - int i; + hid_t file; /* File ID */ + herr_t ret; /* Generic return value */ + char wdata[MISC17_SPACE_DIM1][MISC17_SPACE_DIM2]; + char rdata[MISC17_SPACE_DIM1][MISC17_SPACE_DIM2]; /* Information read in */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t dims[] = {MISC17_SPACE_DIM1, MISC17_SPACE_DIM2}; + int i; /* Initialize the data */ /* (Note that these are supposed to stress the code, so are a little weird) */ @@ -2867,10 +2906,10 @@ test_misc17(void) CHECK(sid, FAIL, "H5Screate_simple"); /* Create a datatype to refer to */ - tid = H5Tcopy (H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); CHECK(tid, FAIL, "H5Tcopy"); - ret = H5Tset_strpad (tid,H5T_STR_NULLPAD); + ret = H5Tset_strpad(tid, H5T_STR_NULLPAD); CHECK(ret, FAIL, "H5Tset_strpad"); /* Create a dataset */ @@ -2886,16 +2925,19 @@ test_misc17(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data in the way of strings. */ - for(i = 0; i < MISC17_SPACE_DIM1; i++) { - if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) { - TestErrPrintf("Line %u: VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(unsigned)__LINE__, (int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i])); + for (i = 0; i < MISC17_SPACE_DIM1; i++) { + if (HDstrlen(wdata[i]) != HDstrlen(rdata[i])) { + TestErrPrintf( + "Line %u: VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", + (unsigned)__LINE__, (int)i, (int)strlen(wdata[i]), (int)i, (int)strlen(rdata[i])); continue; } /* end if */ - if(HDstrcmp(wdata[i], rdata[i]) != 0 ) { - TestErrPrintf("Line %u: VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(unsigned)__LINE__, (int)i,wdata[i],(int)i,rdata[i]); + if (HDstrcmp(wdata[i], rdata[i]) != 0) { + TestErrPrintf("Line %u: VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", + (unsigned)__LINE__, (int)i, wdata[i], (int)i, rdata[i]); continue; } /* end if */ - } /* end for */ + } /* end for */ /* Close Dataset */ ret = H5Dclose(dataset); @@ -2922,18 +2964,18 @@ test_misc17(void) static void test_misc18(void) { - hid_t fid; /* File ID */ - hid_t sid; /* 'Space ID */ - hid_t did1, did2; /* Dataset IDs */ - hid_t aid; /* Attribute ID */ + hid_t fid; /* File ID */ + hid_t sid; /* 'Space ID */ + hid_t did1, did2; /* Dataset IDs */ + hid_t aid; /* Attribute ID */ #ifndef H5_NO_DEPRECATED_SYMBOLS - H5O_info1_t old_oinfo; /* (deprecated) information about object */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5O_info2_t oinfo; /* Data model information about object */ - H5O_native_info_t ninfo; /* Native file format information about object */ - char attr_name[32]; /* Attribute name buffer */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + H5O_info1_t old_oinfo; /* (deprecated) information about object */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5O_info2_t oinfo; /* Data model information about object */ + H5O_native_info_t ninfo; /* Native file format information about object */ + char attr_name[32]; /* Attribute name buffer */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Create the file */ fid = H5Fcreate(MISC18_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2952,7 +2994,8 @@ test_misc18(void) CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(oinfo.num_attrs, 0, "H5Oget_info_by_name"); #ifndef H5_NO_DEPRECATED_SYMBOLS - ret = H5Oget_info_by_name2(fid, MISC18_DSET1_NAME, &old_oinfo, H5O_INFO_HDR|H5O_INFO_NUM_ATTRS, H5P_DEFAULT); + ret = H5Oget_info_by_name2(fid, MISC18_DSET1_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(old_oinfo.hdr.nmesgs, 6, "H5Oget_info_by_name"); VERIFY(old_oinfo.hdr.nchunks, 1, "H5Oget_info_by_name"); @@ -2976,7 +3019,8 @@ test_misc18(void) CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(oinfo.num_attrs, 0, "H5Oget_info_by_name"); #ifndef H5_NO_DEPRECATED_SYMBOLS - ret = H5Oget_info_by_name2(fid, MISC18_DSET2_NAME, &old_oinfo, H5O_INFO_HDR|H5O_INFO_NUM_ATTRS, H5P_DEFAULT); + ret = H5Oget_info_by_name2(fid, MISC18_DSET2_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(old_oinfo.hdr.nmesgs, 6, "H5Oget_info_by_name"); VERIFY(old_oinfo.hdr.nchunks, 1, "H5Oget_info_by_name"); @@ -2992,7 +3036,7 @@ test_misc18(void) VERIFY(ninfo.hdr.space.free, 152, "H5Oget_native_info_by_name"); /* Loop creating attributes on each dataset, flushing them to the file each time */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { /* Set up attribute name */ HDsprintf(attr_name, "Attr %u", u); @@ -3011,7 +3055,7 @@ test_misc18(void) CHECK(ret, FAIL, "H5Aclose"); /* Flush file, to 'fix' size of dataset object headers */ - ret = H5Fflush(fid,H5F_SCOPE_GLOBAL); + ret = H5Fflush(fid, H5F_SCOPE_GLOBAL); CHECK(ret, FAIL, "H5Fflush"); } /* end for */ @@ -3020,7 +3064,8 @@ test_misc18(void) CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(oinfo.num_attrs, 10, "H5Oget_info_by_name"); #ifndef H5_NO_DEPRECATED_SYMBOLS - ret = H5Oget_info_by_name2(fid, MISC18_DSET1_NAME, &old_oinfo, H5O_INFO_HDR|H5O_INFO_NUM_ATTRS, H5P_DEFAULT); + ret = H5Oget_info_by_name2(fid, MISC18_DSET1_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(old_oinfo.hdr.nmesgs, 24, "H5Oget_info_by_name"); VERIFY(old_oinfo.hdr.nchunks, 9, "H5Oget_info_by_name"); @@ -3040,7 +3085,8 @@ test_misc18(void) CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(oinfo.num_attrs, 10, "H5Oget_info_by_name"); #ifndef H5_NO_DEPRECATED_SYMBOLS - ret = H5Oget_info_by_name2(fid, MISC18_DSET2_NAME, &old_oinfo, H5O_INFO_HDR|H5O_INFO_NUM_ATTRS, H5P_DEFAULT); + ret = H5Oget_info_by_name2(fid, MISC18_DSET2_NAME, &old_oinfo, H5O_INFO_HDR | H5O_INFO_NUM_ATTRS, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_name"); VERIFY(old_oinfo.hdr.nmesgs, 24, "H5Oget_info_by_name"); VERIFY(old_oinfo.hdr.nchunks, 9, "H5Oget_info_by_name"); @@ -3079,25 +3125,25 @@ test_misc18(void) static void test_misc19(void) { - hid_t fid = -1; /* File ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t plid = -1; /* Property List ID */ - hid_t pcid = -1; /* Property Class ID */ - hid_t gid = -1; /* Group ID */ - hid_t ecid = -1; /* Error Class ID */ - hid_t emid = -1; /* Error Message ID */ - hid_t esid = -1; /* Error Stack ID */ - hid_t vfdid = -1; /* Virtual File Driver ID */ - hid_t volid = -1; /* Virtual Object Layer ID */ - H5FD_class_t *vfd_cls = NULL; /* VFD class */ - H5VL_class_t *vol_cls = NULL; /* VOL class */ - int rc; /* Reference count */ - herr_t ret; /* Generic return value */ - -/* Check H5I operations on files */ + hid_t fid = -1; /* File ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t plid = -1; /* Property List ID */ + hid_t pcid = -1; /* Property Class ID */ + hid_t gid = -1; /* Group ID */ + hid_t ecid = -1; /* Error Class ID */ + hid_t emid = -1; /* Error Message ID */ + hid_t esid = -1; /* Error Stack ID */ + hid_t vfdid = -1; /* Virtual File Driver ID */ + hid_t volid = -1; /* Virtual Object Layer ID */ + H5FD_class_t *vfd_cls = NULL; /* VFD class */ + H5VL_class_t *vol_cls = NULL; /* VOL class */ + int rc; /* Reference count */ + herr_t ret; /* Generic return value */ + + /* Check H5I operations on files */ /* Create the file */ fid = H5Fcreate(MISC19_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3124,12 +3170,14 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the file again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Fclose"); -/* Check H5I operations on property lists */ + /* Check H5I operations on property lists */ /* Create the property list */ plid = H5Pcreate(H5P_DATASET_CREATE); @@ -3156,15 +3204,17 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the property list again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pclose(plid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pclose"); -/* Check H5I operations on property classes */ + /* Check H5I operations on property classes */ /* Create a property class */ - pcid = H5Pcreate_class(H5P_DATASET_CREATE,"foo",NULL,NULL,NULL,NULL,NULL,NULL); + pcid = H5Pcreate_class(H5P_DATASET_CREATE, "foo", NULL, NULL, NULL, NULL, NULL, NULL); CHECK(pcid, FAIL, "H5Pcreate_class"); /* Check the reference count */ @@ -3188,12 +3238,14 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the property class again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pclose_class(pcid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Pclose_class"); -/* Check H5I operations on datatypes */ + /* Check H5I operations on datatypes */ /* Create a datatype */ tid = H5Tcreate(H5T_OPAQUE, (size_t)16); @@ -3220,12 +3272,14 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the datatype again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Tclose"); -/* Check H5I operations on dataspaces */ + /* Check H5I operations on dataspaces */ /* Create a dataspace */ sid = H5Screate(H5S_SCALAR); @@ -3252,12 +3306,14 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the dataspace again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sclose"); -/* Check H5I operations on datasets */ + /* Check H5I operations on datasets */ /* Create a file */ fid = H5Fcreate(MISC19_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3292,9 +3348,11 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the dataset again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Dclose"); /* Close the dataspace */ @@ -3305,7 +3363,7 @@ test_misc19(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -/* Check H5I operations on attributes */ + /* Check H5I operations on attributes */ /* Create a file */ fid = H5Fcreate(MISC19_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3344,9 +3402,11 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the attribute again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Aclose"); /* Close the root group */ @@ -3361,7 +3421,7 @@ test_misc19(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -/* Check H5I operations on groups */ + /* Check H5I operations on groups */ /* Create a file */ fid = H5Fcreate(MISC19_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3392,19 +3452,21 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the group again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Gclose(gid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Gclose"); /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -/* Check H5I operations on error classes */ + /* Check H5I operations on error classes */ /* Create an error class */ - ecid = H5Eregister_class("foo","bar","baz"); + ecid = H5Eregister_class("foo", "bar", "baz"); CHECK(ecid, FAIL, "H5Eregister_class"); /* Check the reference count */ @@ -3428,19 +3490,21 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the error class again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Eunregister_class(ecid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Eunregister_class"); -/* Check H5I operations on error messages */ + /* Check H5I operations on error messages */ /* Create an error class */ - ecid = H5Eregister_class("foo","bar","baz"); + ecid = H5Eregister_class("foo", "bar", "baz"); CHECK(ecid, FAIL, "H5Eregister_class"); /* Create an error message */ - emid = H5Ecreate_msg(ecid,H5E_MAJOR,"mumble"); + emid = H5Ecreate_msg(ecid, H5E_MAJOR, "mumble"); CHECK(emid, FAIL, "H5Ecreate_msg"); /* Check the reference count */ @@ -3464,16 +3528,18 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the error message again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Eclose_msg(emid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Eclose_msg"); /* Close the error class */ ret = H5Eunregister_class(ecid); CHECK(ret, FAIL, "H5Eunregister_class"); -/* Check H5I operations on error stacks */ + /* Check H5I operations on error stacks */ /* Create an error stack */ esid = H5Eget_current_stack(); @@ -3500,13 +3566,14 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try closing the error stack again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Eclose_stack(esid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Eclose_stack"); - -/* Check H5I operations on virtual file drivers */ + /* Check H5I operations on virtual file drivers */ /* Get a VFD class to register */ vfd_cls = h5_get_dummy_vfd_class(); @@ -3537,14 +3604,16 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try unregistering the VFD again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5FDunregister(vfdid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5FDunregister"); HDfree(vfd_cls); -/* Check H5I operations on virtual object connectors */ + /* Check H5I operations on virtual object connectors */ /* Get a VOL class to register */ vol_cls = h5_get_dummy_vol_class(); @@ -3575,9 +3644,11 @@ test_misc19(void) VERIFY(rc, 0, "H5Idec_ref"); /* Try unregistering the VOL connector again (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5VLunregister_connector(volid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5VLunregister_connector"); HDfree(vol_cls); @@ -3593,17 +3664,17 @@ test_misc19(void) static void test_misc20(void) { - hid_t fid; /* File ID */ - hid_t sid; /* 'Space ID */ - hid_t did; /* Dataset ID */ - hid_t dcpl; /* Dataset creation property list ID */ - int rank=MISC20_SPACE_RANK; /* Rank of dataspace */ - hsize_t big_dims[MISC20_SPACE_RANK]={MISC20_SPACE_DIM0,MISC20_SPACE_DIM1}; /* Large dimensions */ - hsize_t small_dims[MISC20_SPACE_RANK]={MISC20_SPACE2_DIM0,MISC20_SPACE2_DIM1}; /* Small dimensions */ - unsigned version; /* Version of storage layout info */ - hsize_t contig_size; /* Size of contiguous storage size from layout into */ + hid_t fid; /* File ID */ + hid_t sid; /* 'Space ID */ + hid_t did; /* Dataset ID */ + hid_t dcpl; /* Dataset creation property list ID */ + int rank = MISC20_SPACE_RANK; /* Rank of dataspace */ + hsize_t big_dims[MISC20_SPACE_RANK] = {MISC20_SPACE_DIM0, MISC20_SPACE_DIM1}; /* Large dimensions */ + hsize_t small_dims[MISC20_SPACE_RANK] = {MISC20_SPACE2_DIM0, MISC20_SPACE2_DIM1}; /* Small dimensions */ + unsigned version; /* Version of storage layout info */ + hsize_t contig_size; /* Size of contiguous storage size from layout into */ const char *testfile = H5_get_srcdir_filename(MISC20_FILE_OLD); /* Corrected test file name */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing large dimension truncation fix\n")); @@ -3679,14 +3750,15 @@ test_misc20(void) CHECK(did, FAIL, "H5Dopen2"); /* Get the layout version */ - ret = H5D__layout_version_test(did,&version); + ret = H5D__layout_version_test(did, &version); CHECK(ret, FAIL, "H5D__layout_version_test"); VERIFY(version, 3, "H5D__layout_version_test"); /* Get the layout contiguous storage size */ - ret = H5D__layout_contig_size_test(did,&contig_size); + ret = H5D__layout_contig_size_test(did, &contig_size); CHECK(ret, FAIL, "H5D__layout_contig_size_test"); - VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_NATIVE_INT)), "H5D__layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_NATIVE_INT)), + "H5D__layout_contig_size_test"); /* Close datasset */ ret = H5Dclose(did); @@ -3697,14 +3769,15 @@ test_misc20(void) CHECK(did, FAIL, "H5Dopen2"); /* Get the layout version */ - ret = H5D__layout_version_test(did,&version); + ret = H5D__layout_version_test(did, &version); CHECK(ret, FAIL, "H5D__layout_version_test"); VERIFY(version, 3, "H5D__layout_version_test"); /* Get the layout contiguous storage size */ - ret = H5D__layout_contig_size_test(did,&contig_size); + ret = H5D__layout_contig_size_test(did, &contig_size); CHECK(ret, FAIL, "H5D__layout_contig_size_test"); - VERIFY(contig_size, (MISC20_SPACE2_DIM0 * MISC20_SPACE2_DIM1 * H5Tget_size(H5T_NATIVE_INT)), "H5D__layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE2_DIM0 * MISC20_SPACE2_DIM1 * H5Tget_size(H5T_NATIVE_INT)), + "H5D__layout_contig_size_test"); /* Close datasset */ ret = H5Dclose(did); @@ -3727,14 +3800,15 @@ test_misc20(void) CHECK(did, FAIL, "H5Dopen2"); /* Get the layout version */ - ret = H5D__layout_version_test(did,&version); + ret = H5D__layout_version_test(did, &version); CHECK(ret, FAIL, "H5D__layout_version_test"); VERIFY(version, 2, "H5D__layout_version_test"); /* Get the layout contiguous storage size */ - ret = H5D__layout_contig_size_test(did,&contig_size); + ret = H5D__layout_contig_size_test(did, &contig_size); CHECK(ret, FAIL, "H5D__layout_contig_size_test"); - VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_STD_I32LE)), "H5D__layout_contig_size_test"); + VERIFY(contig_size, (MISC20_SPACE_DIM0 * MISC20_SPACE_DIM1 * H5Tget_size(H5T_STD_I32LE)), + "H5D__layout_contig_size_test"); /* Close datasset */ ret = H5Dclose(did); @@ -3764,13 +3838,14 @@ test_misc20(void) static void test_misc21(void) { - hid_t fid, sid, dcpl, dsid; - char *buf; - hsize_t dims[2]={MISC21_SPACE_DIM0,MISC21_SPACE_DIM1}, - chunk_size[2]={MISC21_CHUNK_DIM0,MISC21_CHUNK_DIM1}; - herr_t ret; /* Generic return value */ - - if (h5_szip_can_encode() != 1) return; + hid_t fid, sid, dcpl, dsid; + char * buf; + hsize_t dims[2] = {MISC21_SPACE_DIM0, MISC21_SPACE_DIM1}, + chunk_size[2] = {MISC21_CHUNK_DIM0, MISC21_CHUNK_DIM1}; + herr_t ret; /* Generic return value */ + + if (h5_szip_can_encode() != 1) + return; /* Output message about test being performed */ MESSAGE(5, ("Testing late allocation time w/chunks & filters\n")); @@ -3829,37 +3904,38 @@ test_misc21(void) static void test_misc22(void) { - hid_t fid, sid, dcpl, dsid, dcpl2; - char *buf; - hsize_t dims[2]={MISC22_SPACE_DIM0,MISC22_SPACE_DIM1}, - chunk_size[2]={MISC22_CHUNK_DIM0,MISC22_CHUNK_DIM1}; - herr_t ret; /* Generic return value */ - hid_t dtype; + hid_t fid, sid, dcpl, dsid, dcpl2; + char * buf; + hsize_t dims[2] = {MISC22_SPACE_DIM0, MISC22_SPACE_DIM1}, + chunk_size[2] = {MISC22_CHUNK_DIM0, MISC22_CHUNK_DIM1}; + herr_t ret; /* Generic return value */ + hid_t dtype; /* should extend test to signed ints */ hid_t idts[4]; -/* do the same for floats - hid_t fdts[2]={H5T_NATIVE_FLOAT32, - H5T_NATIVE_FLOAT64} -*/ - size_t prec[4] = {3,11,19,27}; - size_t offsets[5] = {0,3,11,19,27}; - int i,j,k; + /* do the same for floats + hid_t fdts[2]={H5T_NATIVE_FLOAT32, + H5T_NATIVE_FLOAT64} + */ + size_t prec[4] = {3, 11, 19, 27}; + size_t offsets[5] = {0, 3, 11, 19, 27}; + int i, j, k; unsigned int flags; - size_t cd_nelmts=32; + size_t cd_nelmts = 32; unsigned int cd_values[32]; - unsigned correct; + unsigned correct; - if (h5_szip_can_encode() != 1) return; - idts[0]=H5Tcopy(H5T_NATIVE_UINT8); - idts[1]=H5Tcopy(H5T_NATIVE_UINT16); - idts[2]=H5Tcopy(H5T_NATIVE_UINT32); - idts[3]=H5Tcopy(H5T_NATIVE_UINT64); + if (h5_szip_can_encode() != 1) + return; + idts[0] = H5Tcopy(H5T_NATIVE_UINT8); + idts[1] = H5Tcopy(H5T_NATIVE_UINT16); + idts[2] = H5Tcopy(H5T_NATIVE_UINT32); + idts[3] = H5Tcopy(H5T_NATIVE_UINT64); /* Output message about test being performed */ MESSAGE(5, ("Testing datatypes with SZIP filter\n")); /* Allocate space for the buffer */ - buf = (char *)HDcalloc(MISC22_SPACE_DIM0*MISC22_SPACE_DIM1, 8); + buf = (char *)HDcalloc(MISC22_SPACE_DIM0 * MISC22_SPACE_DIM1, 8); CHECK(buf, NULL, "HDcalloc"); /* Create the file */ @@ -3872,12 +3948,16 @@ test_misc22(void) for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - if (prec[j] > (H5Tget_size(idts[i])*8)) continue; /* skip irrelevant combination */ + if (prec[j] > (H5Tget_size(idts[i]) * 8)) + continue; /* skip irrelevant combination */ for (k = 0; k < 5; k++) { - if (offsets[k] > (H5Tget_size(idts[i])*8)) continue; /* skip irrelevant combinations */ - if ((prec[j]+offsets[k]) > (H5Tget_size(idts[i])*8)) continue; + if (offsets[k] > (H5Tget_size(idts[i]) * 8)) + continue; /* skip irrelevant combinations */ + if ((prec[j] + offsets[k]) > (H5Tget_size(idts[i]) * 8)) + continue; - MESSAGE(5, (" Testing datatypes size=%d precision=%u offset=%d\n",H5Tget_size(idts[i]),(unsigned)prec[j],(unsigned)offsets[k])); + MESSAGE(5, (" Testing datatypes size=%d precision=%u offset=%d\n", H5Tget_size(idts[i]), + (unsigned)prec[j], (unsigned)offsets[k])); /* Create the DCPL */ dcpl = H5Pcreate(H5P_DATASET_CREATE); @@ -3887,26 +3967,26 @@ test_misc22(void) ret = H5Pset_chunk(dcpl, MISC22_SPACE_RANK, chunk_size); CHECK(ret, FAIL, "H5Pset_chunk"); /* Set custom DCPL properties */ - ret = H5Pset_szip(dcpl, H5_SZIP_NN_OPTION_MASK, 32); /* vary the PPB */ + ret = H5Pset_szip(dcpl, H5_SZIP_NN_OPTION_MASK, 32); /* vary the PPB */ CHECK(ret, FAIL, "H5Pset_szip"); /* set up the datatype according to the loop */ dtype = H5Tcopy(idts[i]); CHECK(dtype, FAIL, "H5Tcopy"); - ret = H5Tset_precision(dtype,prec[j]); + ret = H5Tset_precision(dtype, prec[j]); CHECK(ret, FAIL, "H5Tset_precision"); - ret = H5Tset_offset(dtype,offsets[k]); + ret = H5Tset_offset(dtype, offsets[k]); CHECK(ret, FAIL, "H5Tset_precision"); /* compute the correct PPB that should be set by SZIP */ - if(offsets[k] == 0) + if (offsets[k] == 0) correct = prec[j]; else correct = H5Tget_size(idts[i]) * 8; - if(correct > 24) { - if(correct <= 32) + if (correct > 24) { + if (correct <= 32) correct = 32; - else if(correct <= 64) + else if (correct <= 64) correct = 64; } /* end if */ @@ -3932,8 +4012,8 @@ test_misc22(void) dcpl2 = H5Dget_create_plist(dsid); CHECK(dcpl2, FAIL, "H5Dget_create_plist"); - ret = H5Pget_filter_by_id2(dcpl2, H5Z_FILTER_SZIP, &flags, - &cd_nelmts, cd_values, 0, NULL , NULL); + ret = H5Pget_filter_by_id2(dcpl2, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, + NULL); CHECK(ret, FAIL, "H5Pget_filter_by_id2"); VERIFY(cd_values[2], correct, "SZIP filter returned value for precision"); @@ -3974,10 +4054,10 @@ test_misc22(void) static void test_misc23(void) { - hsize_t dims[] = {10}; - hid_t file_id=0, group_id=0, type_id=0, space_id=0, - tmp_id=0, create_id=H5P_DEFAULT, access_id=H5P_DEFAULT; - char objname[MISC23_NAME_BUF_SIZE]; /* Name of object */ + hsize_t dims[] = {10}; + hid_t file_id = 0, group_id = 0, type_id = 0, space_id = 0, tmp_id = 0, create_id = H5P_DEFAULT, + access_id = H5P_DEFAULT; + char objname[MISC23_NAME_BUF_SIZE]; /* Name of object */ H5O_info2_t oinfo; htri_t tri_status; ssize_t namelen; @@ -3990,7 +4070,6 @@ test_misc23(void) file_id = H5Fcreate(MISC23_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file_id, FAIL, "H5Fcreate"); - /* Build some infrastructure */ group_id = H5Gcreate2(file_id, "/A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(group_id, FAIL, "H5Gcreate2"); @@ -3998,34 +4077,34 @@ test_misc23(void) space_id = H5Screate_simple(1, dims, NULL); CHECK(space_id, FAIL, "H5Screate_simple"); - type_id = H5Tcopy( H5T_STD_I32BE); + type_id = H5Tcopy(H5T_STD_I32BE); CHECK(type_id, FAIL, "H5Tcopy"); - #ifndef H5_NO_DEPRECATED_SYMBOLS /********************************************************************** * test the old APIs **********************************************************************/ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gcreate1(file_id, "/A/B00a/grp", (size_t)0); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gcreate1"); - tmp_id = H5Gcreate1(file_id, "/A/grp", (size_t)0); CHECK(tmp_id, FAIL, "H5Gcreate1"); status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dcreate1(file_id, "/A/B00c/dset", type_id, space_id, create_id); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dcreate1"); - tmp_id = H5Dcreate1(file_id, "/A/dset", type_id, space_id, create_id); CHECK(tmp_id, FAIL, "H5Dcreate1"); @@ -4045,7 +4124,6 @@ test_misc23(void) status = H5Pset_create_intermediate_group(create_id, TRUE); CHECK(status, FAIL, "H5Pset_create_intermediate_group"); - tmp_id = H5Gcreate2(file_id, "/A/B01/grp", create_id, H5P_DEFAULT, access_id); CHECK(tmp_id, FAIL, "H5Gcreate2"); @@ -4068,39 +4146,33 @@ test_misc23(void) status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - tmp_id = H5Gcreate2(file_id, "/A/B02/C02/grp", create_id, H5P_DEFAULT, access_id); CHECK(tmp_id, FAIL, "H5Gcreate2"); status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - tmp_id = H5Gcreate2(group_id, "B03/grp/", create_id, H5P_DEFAULT, access_id); CHECK(tmp_id, FAIL, "H5Gcreate2"); status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - tmp_id = H5Gcreate2(group_id, "/A/B04/grp/", create_id, H5P_DEFAULT, access_id); CHECK(tmp_id, FAIL, "H5Gcreate2"); status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - tmp_id = H5Gcreate2(file_id, "/A/B05/C05/A", create_id, H5P_DEFAULT, access_id); CHECK(tmp_id, FAIL, "H5Gcreate2"); status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - status = H5Pclose(create_id); CHECK(status, FAIL, "H5Pclose"); - /********************************************************************** * test H5Dcreate2() **********************************************************************/ @@ -4113,42 +4185,36 @@ test_misc23(void) status = H5Pset_create_intermediate_group(create_id, TRUE); CHECK(status, FAIL, "H5Pset_create_intermediate_group"); - tmp_id = H5Dcreate2(file_id, "/A/B06/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate2"); status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - tmp_id = H5Dcreate2(file_id, "/A/B07/B07/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate2"); status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - tmp_id = H5Dcreate2(group_id, "B08/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate2"); status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - tmp_id = H5Dcreate2(group_id, "/A/B09/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate2"); status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - tmp_id = H5Dcreate2(file_id, "/A/B10/C10/A/dset", type_id, space_id, create_id, H5P_DEFAULT, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate2"); status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - status = H5Tclose(type_id); CHECK(status, FAIL, "H5Tclose"); @@ -4158,10 +4224,9 @@ test_misc23(void) status = H5Pclose(create_id); CHECK(status, FAIL, "H5Pclose"); - /********************************************************************** - * test H5Tcommit2() - **********************************************************************/ + * test H5Tcommit2() + **********************************************************************/ /* Create link creation property list */ create_id = H5Pcreate(H5P_LINK_CREATE); @@ -4180,7 +4245,6 @@ test_misc23(void) status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); - tmp_id = H5Tcopy(H5T_NATIVE_INT32); CHECK(tmp_id, FAIL, "H5Tcopy"); @@ -4190,7 +4254,6 @@ test_misc23(void) status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); - tmp_id = H5Tcopy(H5T_NATIVE_INT64); CHECK(tmp_id, FAIL, "H5Tcopy"); @@ -4200,7 +4263,6 @@ test_misc23(void) status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); - tmp_id = H5Tcopy(H5T_NATIVE_FLOAT); CHECK(tmp_id, FAIL, "H5Tcopy"); @@ -4210,7 +4272,6 @@ test_misc23(void) status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); - tmp_id = H5Tcopy(H5T_NATIVE_DOUBLE); CHECK(tmp_id, FAIL, "H5Tcopy"); @@ -4220,13 +4281,12 @@ test_misc23(void) status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); - status = H5Pclose(create_id); CHECK(status, FAIL, "H5Pclose"); /********************************************************************** - * test H5Lcopy() - **********************************************************************/ + * test H5Lcopy() + **********************************************************************/ /* Create link creation property list */ create_id = H5Pcreate(H5P_LINK_CREATE); @@ -4246,8 +4306,8 @@ test_misc23(void) VERIFY(tri_status, TRUE, "H5Lexists"); /********************************************************************** - * test H5Lmove() - **********************************************************************/ + * test H5Lmove() + **********************************************************************/ status = H5Lmove(file_id, "/A/B16/grp", file_id, "/A/B17/grp", create_id, access_id); CHECK(status, FAIL, "H5Lmove"); @@ -4259,8 +4319,8 @@ test_misc23(void) VERIFY(tri_status, FALSE, "H5Lexists"); /********************************************************************** - * test H5Lcreate_hard() - **********************************************************************/ + * test H5Lcreate_hard() + **********************************************************************/ status = H5Lcreate_hard(file_id, "/A/B01/grp", file_id, "/A/B18/grp", create_id, access_id); CHECK(status, FAIL, "H5Lcreate_hard"); @@ -4269,8 +4329,8 @@ test_misc23(void) VERIFY(tri_status, TRUE, "H5Lexists"); /********************************************************************** - * test H5Lcreate_soft() - **********************************************************************/ + * test H5Lcreate_soft() + **********************************************************************/ status = H5Lcreate_soft("/A/B01/grp", file_id, "/A/B19/grp", create_id, access_id); CHECK(status, FAIL, "H5Lcreate_soft"); @@ -4279,8 +4339,8 @@ test_misc23(void) VERIFY(tri_status, TRUE, "H5Lexists"); /********************************************************************** - * test H5Lcreate_external() - **********************************************************************/ + * test H5Lcreate_external() + **********************************************************************/ status = H5Lcreate_external("fake_filename", "fake_path", file_id, "/A/B20/grp", create_id, access_id); CHECK(status, FAIL, "H5Lcreate_external"); @@ -4289,18 +4349,19 @@ test_misc23(void) VERIFY(tri_status, TRUE, "H5Lexists"); /********************************************************************** - * test H5Lcreate_ud() - **********************************************************************/ + * test H5Lcreate_ud() + **********************************************************************/ - status = H5Lcreate_ud(file_id, "/A/B21/grp", H5L_TYPE_EXTERNAL, "file\0obj", (size_t) 9, create_id, access_id); + status = + H5Lcreate_ud(file_id, "/A/B21/grp", H5L_TYPE_EXTERNAL, "file\0obj", (size_t)9, create_id, access_id); CHECK(status, FAIL, "H5Lcreate_ud"); tri_status = H5Lexists(file_id, "/A/B21/grp", access_id); VERIFY(tri_status, TRUE, "H5Lexists"); /********************************************************************** - * close - **********************************************************************/ + * close + **********************************************************************/ status = H5Pclose(create_id); CHECK(status, FAIL, "H5Pclose"); @@ -4321,9 +4382,8 @@ test_misc23(void) static void test_misc24(void) { - hid_t file_id = 0, group_id = 0, type_id = 0, space_id = 0, - dset_id = 0, tmp_id = 0; - herr_t ret; /* Generic return value */ + hid_t file_id = 0, group_id = 0, type_id = 0, space_id = 0, dset_id = 0, tmp_id = 0; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing opening objects with inappropriate APIs\n")); @@ -4340,7 +4400,8 @@ test_misc24(void) group_id = H5Gcreate2(file_id, MISC24_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(group_id, FAIL, "H5Gcreate2"); - dset_id = H5Dcreate2(file_id, MISC24_DATASET_NAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, MISC24_DATASET_NAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dcreate2"); type_id = H5Tcopy(H5T_NATIVE_INT); @@ -4373,64 +4434,88 @@ test_misc24(void) CHECK(ret, FAIL, "H5Tclose"); /* Attempt to open each kind of object with wrong API, including using soft links */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dopen2(file_id, MISC24_GROUP_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dopen2(file_id, MISC24_GROUP_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Topen2(file_id, MISC24_GROUP_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Topen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Topen2(file_id, MISC24_GROUP_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Topen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gopen2(file_id, MISC24_DATASET_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gopen2(file_id, MISC24_DATASET_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Topen2(file_id, MISC24_DATASET_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Topen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Topen2(file_id, MISC24_DATASET_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Topen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gopen2(file_id, MISC24_DATATYPE_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gopen2(file_id, MISC24_DATATYPE_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dopen2(file_id, MISC24_DATATYPE_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dopen2(file_id, MISC24_DATATYPE_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dopen2"); /* Try again, with the object already open through valid call */ @@ -4438,24 +4523,32 @@ test_misc24(void) group_id = H5Gopen2(file_id, MISC24_GROUP_NAME, H5P_DEFAULT); CHECK(group_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dopen2(file_id, MISC24_GROUP_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dopen2(file_id, MISC24_GROUP_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Topen2(file_id, MISC24_GROUP_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Topen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Topen2(file_id, MISC24_GROUP_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Topen2"); ret = H5Gclose(group_id); @@ -4465,24 +4558,32 @@ test_misc24(void) dset_id = H5Dopen2(file_id, MISC24_DATASET_NAME, H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gopen2(file_id, MISC24_DATASET_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gopen2(file_id, MISC24_DATASET_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Topen2(file_id, MISC24_DATASET_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Topen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Topen2(file_id, MISC24_DATASET_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Topen2"); ret = H5Dclose(dset_id); @@ -4492,24 +4593,32 @@ test_misc24(void) type_id = H5Topen2(file_id, MISC24_DATATYPE_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Topen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gopen2(file_id, MISC24_DATATYPE_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Gopen2(file_id, MISC24_DATATYPE_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Gopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dopen2(file_id, MISC24_DATATYPE_NAME, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dopen2"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_id = H5Dopen2(file_id, MISC24_DATATYPE_LINK, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(tmp_id, FAIL, "H5Dopen2"); ret = H5Tclose(type_id); @@ -4529,12 +4638,12 @@ test_misc24(void) static void test_misc25a(void) { - hid_t fid; /* File ID */ - hid_t gid, gid2, gid3; /* Group IDs */ - hid_t aid; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t gid, gid2, gid3; /* Group IDs */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Exercise null object header message bug\n")); @@ -4571,7 +4680,6 @@ test_misc25a(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4640,7 +4748,6 @@ test_misc25a(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4669,7 +4776,6 @@ test_misc25a(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4712,7 +4818,6 @@ test_misc25a(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4759,7 +4864,6 @@ test_misc25a(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4780,7 +4884,6 @@ test_misc25a(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4824,7 +4927,6 @@ test_misc25a(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_misc25a() */ - /**************************************************************** ** ** test_misc25b(): Exercise null object header message merge bug @@ -4835,10 +4937,10 @@ test_misc25a(void) static void test_misc25b(void) { - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ const char *testfile = H5_get_srcdir_filename(MISC25B_FILE); /* Corrected test file name */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Exercise null object header message bug\n")); @@ -4860,7 +4962,6 @@ test_misc25b(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_misc25b() */ - /**************************************************************** ** ** test_misc25c(): Exercise another null object header message merge bug. @@ -4869,15 +4970,15 @@ test_misc25b(void) static void test_misc25c(void) { - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list ID */ - hid_t gcpl; /* Group creation property list ID */ - hid_t sid; /* Dataspace ID */ - hid_t did; /* Dataset ID */ - hid_t gid; /* Group ID */ - hid_t gid2; /* Group ID */ - hid_t aid; /* Attribute ID */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t fapl; /* File access property list ID */ + hid_t gcpl; /* Group creation property list ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ + hid_t gid; /* Group ID */ + hid_t gid2; /* Group ID */ + hid_t aid; /* Attribute ID */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Exercise another null object header message bug\n")); @@ -4968,7 +5069,6 @@ test_misc25c(void) ret = H5Pclose(gcpl); CHECK(ret, FAIL, "H5Pclose"); - /* Re-open the file */ fid = H5Fopen(MISC25C_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4994,7 +5094,6 @@ test_misc25c(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_misc25c() */ - /**************************************************************** ** ** test_misc26(): Regression test: ensure that copying filter @@ -5004,12 +5103,12 @@ test_misc25c(void) static void test_misc26(void) { - hid_t fid; /* File ID */ - hid_t sid; /* Dataspace ID */ - hid_t did; /* Dataset ID */ - hid_t dcpl1, dcpl2, dcpl3; /* Property List IDs */ + hid_t fid; /* File ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ + hid_t dcpl1, dcpl2, dcpl3; /* Property List IDs */ hsize_t dims[] = {1}; - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Copying filter pipelines\n")); @@ -5040,7 +5139,6 @@ test_misc26(void) ret = H5Pset_deflate(dcpl3, 2); CHECK_I(ret, "H5Pset_deflate"); - /* Create a new file and datasets within that file that use these * property lists */ @@ -5080,7 +5178,6 @@ test_misc26(void) CHECK_I(ret, "H5Pclose"); } - /**************************************************************** ** ** test_misc27(): Ensure that objects with incorrect # of object @@ -5092,10 +5189,10 @@ test_misc26(void) static void test_misc27(void) { - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ const char *testfile = H5_get_srcdir_filename(MISC27_FILE); /* Corrected test file name */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Corrupt object header handling\n")); @@ -5106,11 +5203,13 @@ test_misc27(void) #ifdef H5_STRICT_FORMAT_CHECKS /* Open group with incorrect # of object header messages (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { gid = H5Gopen2(fid, MISC27_GROUP, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(gid, FAIL, "H5Gopen2"); -#else /* H5_STRICT_FORMAT_CHECKS */ +#else /* H5_STRICT_FORMAT_CHECKS */ /* Open group with incorrect # of object header messages */ gid = H5Gopen2(fid, MISC27_GROUP, H5P_DEFAULT); CHECK(gid, FAIL, "H5Gopen2"); @@ -5125,7 +5224,6 @@ test_misc27(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_misc27() */ - /**************************************************************** ** ** test_misc28(): Ensure that the dataset chunk cache will hold @@ -5136,21 +5234,21 @@ test_misc27(void) static void test_misc28(void) { - hid_t fid; /* File ID */ - hid_t sidf; /* File Dataspace ID */ - hid_t sidm; /* Memory Dataspace ID */ - hid_t did; /* Dataset ID */ - hid_t dcpl, fapl; /* Property List IDs */ - hsize_t dims[] = {MISC28_SIZE, MISC28_SIZE}; + hid_t fid; /* File ID */ + hid_t sidf; /* File Dataspace ID */ + hid_t sidm; /* Memory Dataspace ID */ + hid_t did; /* Dataset ID */ + hid_t dcpl, fapl; /* Property List IDs */ + hsize_t dims[] = {MISC28_SIZE, MISC28_SIZE}; hsize_t mdims[] = {MISC28_SIZE}; hsize_t cdims[] = {1, 1}; - hsize_t start[] = {0,0}; + hsize_t start[] = {0, 0}; hsize_t count[] = {MISC28_SIZE, 1}; size_t nbytes_used; int nused; char buf[MISC28_SIZE]; int i; - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Dataset chunk cache\n")); @@ -5170,7 +5268,6 @@ test_misc28(void) ret = H5Pset_chunk(dcpl, 2, cdims); CHECK(ret, FAIL, "H5Pset_chunk"); - /* Create a new file and datasets within that file that use these * property lists */ @@ -5186,11 +5283,11 @@ test_misc28(void) /* Verify that the chunk cache is empty */ ret = H5D__current_cache_size_test(did, &nbytes_used, &nused); CHECK(ret, FAIL, "H5D__current_cache_size_test"); - VERIFY(nbytes_used, (size_t) 0, "H5D__current_cache_size_test"); + VERIFY(nbytes_used, (size_t)0, "H5D__current_cache_size_test"); VERIFY(nused, 0, "H5D__current_cache_size_test"); /* Initialize write buffer */ - for(i=0; i reg_size_start) + if (reg_size_final > reg_size_start) ERROR("reg_size_final > reg_size_start"); - if(arr_size_final > arr_size_start) + if (arr_size_final > arr_size_start) ERROR("arr_size_final > arr_size_start"); - if(blk_size_final > blk_size_start) + if (blk_size_final > blk_size_start) ERROR("blk_size_final > blk_size_start"); - if(fac_size_final > fac_size_start) + if (fac_size_final > fac_size_start) ERROR("fac_size_final > fac_size_start"); /* Retrieve memory allocation statistics */ @@ -5789,7 +5875,7 @@ test_misc35(void) CHECK(alloc_stats.total_alloc_blocks_count, 0, "H5get_alloc_stats"); CHECK(alloc_stats.curr_alloc_blocks_count, 0, "H5get_alloc_stats"); CHECK(alloc_stats.peak_alloc_blocks_count, 0, "H5get_alloc_stats"); -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* All the values should be == 0 */ VERIFY(alloc_stats.total_alloc_bytes, 0, "H5get_alloc_stats"); VERIFY(alloc_stats.curr_alloc_bytes, 0, "H5get_alloc_stats"); @@ -5802,7 +5888,6 @@ test_misc35(void) } /* end test_misc35() */ - /**************************************************************** ** ** test_misc(): Main misc. test routine. @@ -5814,49 +5899,49 @@ test_misc(void) /* Output message about test being performed */ MESSAGE(5, ("Testing Miscellaneous Routines\n")); - test_misc1(); /* Test unlinking a dataset & immediately re-using name */ - test_misc2(); /* Test storing a VL-derived datatype in two different files */ - test_misc3(); /* Test reading from chunked dataset with non-zero fill value */ - test_misc4(); /* Test retrieving the fileno for various objects with H5Oget_info() */ - test_misc5(); /* Test several level deep nested compound & VL datatypes */ - test_misc6(); /* Test object header continuation code */ - test_misc7(); /* Test for sensible datatypes stored on disk */ - test_misc8(); /* Test storage sizes of various types of dataset storage */ - test_misc9(); /* Test for opening (not creating) core files */ - test_misc10(); /* Test for using dataset creation property lists from old files */ - test_misc11(); /* Test for all properties of a file creation property list being stored */ - test_misc12(); /* Test VL-strings in chunked datasets operating correctly */ - test_misc13(); /* Test that a user block can be insert in front of file contents */ - test_misc14(); /* Test that deleted dataset's data is removed from sieve buffer correctly */ - test_misc15(); /* Test that checking a file's access property list more than once works */ - test_misc16(); /* Test array of fixed-length string */ - test_misc17(); /* Test array of ASCII character */ - test_misc18(); /* Test new object header information in H5O_info_t struct */ - test_misc19(); /* Test incrementing & decrementing ref count on IDs */ - test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */ + test_misc1(); /* Test unlinking a dataset & immediately re-using name */ + test_misc2(); /* Test storing a VL-derived datatype in two different files */ + test_misc3(); /* Test reading from chunked dataset with non-zero fill value */ + test_misc4(); /* Test retrieving the fileno for various objects with H5Oget_info() */ + test_misc5(); /* Test several level deep nested compound & VL datatypes */ + test_misc6(); /* Test object header continuation code */ + test_misc7(); /* Test for sensible datatypes stored on disk */ + test_misc8(); /* Test storage sizes of various types of dataset storage */ + test_misc9(); /* Test for opening (not creating) core files */ + test_misc10(); /* Test for using dataset creation property lists from old files */ + test_misc11(); /* Test for all properties of a file creation property list being stored */ + test_misc12(); /* Test VL-strings in chunked datasets operating correctly */ + test_misc13(); /* Test that a user block can be insert in front of file contents */ + test_misc14(); /* Test that deleted dataset's data is removed from sieve buffer correctly */ + test_misc15(); /* Test that checking a file's access property list more than once works */ + test_misc16(); /* Test array of fixed-length string */ + test_misc17(); /* Test array of ASCII character */ + test_misc18(); /* Test new object header information in H5O_info_t struct */ + test_misc19(); /* Test incrementing & decrementing ref count on IDs */ + test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */ #ifdef H5_HAVE_FILTER_SZIP - test_misc21(); /* Test that "late" allocation time is treated the same as "incremental", for chunked datasets w/a filters */ - test_misc22(); /* check szip bits per pixel */ -#endif /* H5_HAVE_FILTER_SZIP */ - test_misc23(); /* Test intermediate group creation */ - test_misc24(); /* Test inappropriate API opens of objects */ - test_misc25a(); /* Exercise null object header message merge bug */ - test_misc25b(); /* Exercise null object header message merge bug on existing file */ - test_misc25c(); /* Exercise another null object header message merge bug */ - test_misc26(); /* Test closing property lists with long filter pipelines */ - test_misc27(); /* Test opening file with object that has bad # of object header messages */ - test_misc28(); /* Test that chunks are cached appropriately */ - test_misc29(); /* Test that speculative metadata reads are handled correctly */ - test_misc30(); /* Exercise local heap loading bug where free lists were getting dropped */ - test_misc31(); /* Test Reentering library through deprecated routines after H5close() */ - test_misc32(); /* Test filter memory allocation functions */ - test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */ - test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */ - test_misc35(); /* Test behavior of free-list & allocation statistics API calls */ + test_misc21(); /* Test that "late" allocation time is treated the same as "incremental", for chunked + datasets w/a filters */ + test_misc22(); /* check szip bits per pixel */ +#endif /* H5_HAVE_FILTER_SZIP */ + test_misc23(); /* Test intermediate group creation */ + test_misc24(); /* Test inappropriate API opens of objects */ + test_misc25a(); /* Exercise null object header message merge bug */ + test_misc25b(); /* Exercise null object header message merge bug on existing file */ + test_misc25c(); /* Exercise another null object header message merge bug */ + test_misc26(); /* Test closing property lists with long filter pipelines */ + test_misc27(); /* Test opening file with object that has bad # of object header messages */ + test_misc28(); /* Test that chunks are cached appropriately */ + test_misc29(); /* Test that speculative metadata reads are handled correctly */ + test_misc30(); /* Exercise local heap loading bug where free lists were getting dropped */ + test_misc31(); /* Test Reentering library through deprecated routines after H5close() */ + test_misc32(); /* Test filter memory allocation functions */ + test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */ + test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */ + test_misc35(); /* Test behavior of free-list & allocation statistics API calls */ } /* test_misc() */ - /*------------------------------------------------------------------------- * Function: cleanup_misc * @@ -5910,4 +5995,3 @@ cleanup_misc(void) HDremove(MISC31_FILE); #endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* end cleanup_misc() */ - diff --git a/test/trefer.c b/test/trefer.c index 68fef09..984aa7a 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -12,39 +12,39 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: trefer -* -* Test the Reference functionality -* -*************************************************************/ + * + * Test program: trefer + * + * Test the Reference functionality + * + *************************************************************/ #include "testhdf5.h" -#define FILE_REF_PARAM "trefer_param.h5" -#define FILE_REF_OBJ "trefer_obj.h5" -#define FILE_REF_VL_OBJ "trefer_vl_obj.h5" -#define FILE_REF_REG "trefer_reg.h5" -#define FILE_REF_REG_1D "trefer_reg_1d.h5" -#define FILE_REF_OBJ_DEL "trefer_obj_del.h5" -#define FILE_REF_GRP "trefer_grp.h5" -#define FILE_REF_ATTR "trefer_attr.h5" -#define FILE_REF_EXT1 "trefer_ext1.h5" -#define FILE_REF_EXT2 "trefer_ext2.h5" -#define FILE_REF_COMPAT "trefer_compat.h5" +#define FILE_REF_PARAM "trefer_param.h5" +#define FILE_REF_OBJ "trefer_obj.h5" +#define FILE_REF_VL_OBJ "trefer_vl_obj.h5" +#define FILE_REF_REG "trefer_reg.h5" +#define FILE_REF_REG_1D "trefer_reg_1d.h5" +#define FILE_REF_OBJ_DEL "trefer_obj_del.h5" +#define FILE_REF_GRP "trefer_grp.h5" +#define FILE_REF_ATTR "trefer_attr.h5" +#define FILE_REF_EXT1 "trefer_ext1.h5" +#define FILE_REF_EXT2 "trefer_ext2.h5" +#define FILE_REF_COMPAT "trefer_compat.h5" /* 1-D dataset with fixed dimensions */ -#define SPACE1_RANK 1 -#define SPACE1_DIM1 4 +#define SPACE1_RANK 1 +#define SPACE1_DIM1 4 /* 2-D dataset with fixed dimensions */ -#define SPACE2_RANK 2 -#define SPACE2_DIM1 10 -#define SPACE2_DIM2 10 +#define SPACE2_RANK 2 +#define SPACE2_DIM1 10 +#define SPACE2_DIM2 10 /* Larger 1-D dataset with fixed dimensions */ -#define SPACE3_RANK 1 -#define SPACE3_DIM1 100 +#define SPACE3_RANK 1 +#define SPACE3_DIM1 100 /* Element selection information */ #define POINT1_NPOINTS 10 @@ -53,21 +53,20 @@ typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; -#define GROUPNAME "/group" -#define GROUPNAME2 "group2" -#define GROUPNAME3 "group3" -#define DSETNAME "/dset" -#define DSETNAME2 "dset2" -#define NAME_SIZE 16 +#define GROUPNAME "/group" +#define GROUPNAME2 "group2" +#define GROUPNAME3 "group3" +#define DSETNAME "/dset" +#define DSETNAME2 "dset2" +#define NAME_SIZE 16 #define MAX_ITER_CREATE 1000 #define MAX_ITER_WRITE MAX_ITER_CREATE #define MAX_ITER_READ MAX_ITER_CREATE - /**************************************************************** ** ** test_reference_params(): Test basic H5R (reference) parameters @@ -77,26 +76,26 @@ typedef struct s1_t { static void test_reference_params(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t group; /* Group ID */ - hid_t attr; /* Attribute ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hid_t aapl_id; /* Attribute access property list */ - hid_t dapl_id; /* Dataset access property list */ - hsize_t dims1[] = {SPACE1_DIM1}; - H5R_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ - unsigned *obuf; - H5R_type_t type; /* Reference type */ - unsigned int i; /* Counters */ - const char *write_comment = "Foo!"; /* Comments for group */ - hid_t ret_id; /* Generic hid_t return value */ - ssize_t name_size; /* Size of reference name */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t attr; /* Attribute ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hid_t aapl_id; /* Attribute access property list */ + hid_t dapl_id; /* Dataset access property list */ + hsize_t dims1[] = {SPACE1_DIM1}; + H5R_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ + unsigned * obuf; + H5R_type_t type; /* Reference type */ + unsigned int i; /* Counters */ + const char * write_comment = "Foo!"; /* Comments for group */ + hid_t ret_id; /* Generic hid_t return value */ + ssize_t name_size; /* Size of reference name */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Reference Parameters\n")); @@ -107,7 +106,7 @@ test_reference_params(void) tbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); obuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) obuf[i] = i * 3; /* Create file */ @@ -171,13 +170,13 @@ test_reference_params(void) CHECK(tid1, H5I_INVALID_HID, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -301,7 +300,7 @@ test_reference_params(void) HDfree(rbuf); HDfree(tbuf); HDfree(obuf); -} /* test_reference_params() */ +} /* test_reference_params() */ /**************************************************************** ** @@ -312,20 +311,20 @@ test_reference_params(void) static void test_reference_obj(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hid_t dapl_id; /* Dataset access property list */ - H5R_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - unsigned *ibuf, *obuf; - unsigned i, j; /* Counters */ - H5O_type_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hid_t dapl_id; /* Dataset access property list */ + H5R_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + unsigned * ibuf, *obuf; + unsigned i, j; /* Counters */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Object Reference Functions\n")); @@ -380,13 +379,13 @@ test_reference_obj(void) CHECK(tid1, H5I_INVALID_HID, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -476,7 +475,7 @@ test_reference_obj(void) ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); CHECK(ret, FAIL, "H5Dread"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) VERIFY(ibuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ @@ -502,7 +501,7 @@ test_reference_obj(void) tclass = H5Tget_class(tid1); VERIFY(tclass, H5T_COMPOUND, "H5Tget_class"); - ret= H5Tget_nmembers(tid1); + ret = H5Tget_nmembers(tid1); VERIFY(ret, 3, "H5Tget_nmembers"); } @@ -523,7 +522,7 @@ test_reference_obj(void) CHECK(ret, FAIL, "H5Fclose"); /* Destroy references */ - for(j = 0; j < SPACE1_DIM1; j++) { + for (j = 0; j < SPACE1_DIM1; j++) { ret = H5Rdestroy(&wbuf[j]); CHECK(ret, FAIL, "H5Rdestroy"); ret = H5Rdestroy(&rbuf[j]); @@ -535,7 +534,7 @@ test_reference_obj(void) HDfree(rbuf); HDfree(ibuf); HDfree(obuf); -} /* test_reference_obj() */ +} /* test_reference_obj() */ /**************************************************************** ** @@ -547,22 +546,22 @@ test_reference_obj(void) static void test_reference_vlen_obj(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t vl_dims[] = {1}; - hid_t dapl_id; /* Dataset access property list */ - H5R_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - unsigned *ibuf, *obuf; - unsigned i, j; /* Counters */ - H5O_type_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ - hvl_t vl_wbuf = {0, NULL}, vl_rbuf = {0, NULL}; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t vl_dims[] = {1}; + hid_t dapl_id; /* Dataset access property list */ + H5R_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + unsigned * ibuf, *obuf; + unsigned i, j; /* Counters */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ + hvl_t vl_wbuf = {0, NULL}, vl_rbuf = {0, NULL}; /* Output message about test being performed */ MESSAGE(5, ("Testing Object Reference Functions within VLEN type\n")); @@ -621,13 +620,13 @@ test_reference_vlen_obj(void) CHECK(tid1, H5I_INVALID_HID, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -684,7 +683,7 @@ test_reference_vlen_obj(void) /* Store references into vlen */ vl_wbuf.len = SPACE1_DIM1; - vl_wbuf.p = wbuf; + vl_wbuf.p = wbuf; /* Write selection to disk */ ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vl_wbuf); @@ -743,7 +742,7 @@ test_reference_vlen_obj(void) ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); CHECK(ret, FAIL, "H5Dread"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) VERIFY(ibuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ @@ -769,7 +768,7 @@ test_reference_vlen_obj(void) tclass = H5Tget_class(tid1); VERIFY(tclass, H5T_COMPOUND, "H5Tget_class"); - ret= H5Tget_nmembers(tid1); + ret = H5Tget_nmembers(tid1); VERIFY(ret, 3, "H5Tget_nmembers"); } @@ -790,7 +789,7 @@ test_reference_vlen_obj(void) CHECK(ret, FAIL, "H5Fclose"); /* Destroy references */ - for(j = 0; j < SPACE1_DIM1; j++) { + for (j = 0; j < SPACE1_DIM1; j++) { ret = H5Rdestroy(&wbuf[j]); CHECK(ret, FAIL, "H5Rdestroy"); ret = H5Rdestroy(&rbuf[j]); @@ -802,7 +801,7 @@ test_reference_vlen_obj(void) HDfree(rbuf); HDfree(ibuf); HDfree(obuf); -} /* test_reference_vlen_obj() */ +} /* test_reference_vlen_obj() */ /**************************************************************** ** @@ -817,49 +816,48 @@ test_reference_vlen_obj(void) static void test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) { - hid_t fid1; /* HDF5 File IDs */ - hid_t fapl; /* File access property list */ - hid_t dset1, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid2; /* Dataspace ID #2 */ - hid_t dapl_id; /* Dataset access property list */ - hsize_t dims1[] = {SPACE1_DIM1}, - dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hsize_t *coords; /* Coordinate buffer */ - hsize_t low[SPACE2_RANK]; /* Selection bounds */ - hsize_t high[SPACE2_RANK]; /* Selection bounds */ - H5R_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - H5R_ref_t nvrbuf[3]={{{{0}}},{{{101}}},{{{255}}}}; /* buffer with non-valid refs */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - H5O_type_t obj_type; /* Type of object */ - int i, j; /* Counters */ - hssize_t hssize_ret; /* hssize_t return value */ - htri_t tri_ret; /* htri_t return value */ - herr_t ret; /* Generic return value */ - hid_t dset_NA; /* Dataset id for undefined reference */ - hid_t space_NA; /* Dataspace id for undefined reference */ - hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ - H5R_ref_t rdata_NA[1]; /* Read buffer */ + hid_t fid1; /* HDF5 File IDs */ + hid_t fapl; /* File access property list */ + hid_t dset1, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t sid1, /* Dataspace ID #1 */ + sid2; /* Dataspace ID #2 */ + hid_t dapl_id; /* Dataset access property list */ + hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hsize_t * coords; /* Coordinate buffer */ + hsize_t low[SPACE2_RANK]; /* Selection bounds */ + hsize_t high[SPACE2_RANK]; /* Selection bounds */ + H5R_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + H5R_ref_t nvrbuf[3] = {{{{0}}}, {{{101}}}, {{{255}}}}; /* buffer with non-valid refs */ + uint8_t * dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t * tu8; /* Temporary pointer to uint8 data */ + H5O_type_t obj_type; /* Type of object */ + int i, j; /* Counters */ + hssize_t hssize_ret; /* hssize_t return value */ + htri_t tri_ret; /* htri_t return value */ + herr_t ret; /* Generic return value */ + hid_t dset_NA; /* Dataset id for undefined reference */ + hid_t space_NA; /* Dataspace id for undefined reference */ + hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ + H5R_ref_t rdata_NA[1]; /* Read buffer */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + wbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); dwbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); - for(tu8 = dwbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++) + for (tu8 = dwbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++) *tu8++ = (uint8_t)(i * 3); /* Create file access property list */ @@ -899,11 +897,13 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(sid1, H5I_INVALID_HID, "H5Screate_simple"); /* Create a dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; - if(dset1 < 0) { + if (dset1 < 0) { VERIFY(libver_high <= H5F_LIBVER_V110, TRUE, "H5Dcreate2"); ret = H5Sclose(sid1); @@ -917,18 +917,23 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - } else { + } + else { CHECK(dset1, H5I_INVALID_HID, "H5Dcreate2"); /* Create references */ /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 6; block[1] = 6; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 6; + block[1] = 6; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); ret = (int)H5Sget_select_npoints(sid2); @@ -942,16 +947,26 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); /* Select sequence of ten points for second reference */ - coord1[0][0] = 6; coord1[0][1] = 9; - coord1[1][0] = 2; coord1[1][1] = 2; - coord1[2][0] = 8; coord1[2][1] = 4; - coord1[3][0] = 1; coord1[3][1] = 6; - coord1[4][0] = 2; coord1[4][1] = 8; - coord1[5][0] = 3; coord1[5][1] = 2; - coord1[6][0] = 0; coord1[6][1] = 4; - coord1[7][0] = 9; coord1[7][1] = 0; - coord1[8][0] = 7; coord1[8][1] = 1; - coord1[9][0] = 3; coord1[9][1] = 3; + coord1[0][0] = 6; + coord1[0][1] = 9; + coord1[1][0] = 2; + coord1[1][1] = 2; + coord1[2][0] = 8; + coord1[2][1] = 4; + coord1[3][0] = 1; + coord1[3][1] = 6; + coord1[4][0] = 2; + coord1[4][1] = 8; + coord1[5][0] = 3; + coord1[5][1] = 2; + coord1[6][0] = 0; + coord1[6][1] = 4; + coord1[7][0] = 9; + coord1[7][1] = 0; + coord1[8][0] = 7; + coord1[8][1] = 1; + coord1[9][0] = 3; + coord1[9][1] = 3; ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); @@ -963,15 +978,15 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Rcreate_region"); /* Select unlimited hyperslab for third reference */ - start[0] = 1; - start[1] = 8; + start[0] = 1; + start[1] = 8; stride[0] = 4; stride[1] = 1; - count[0] = H5S_UNLIMITED; - count[1] = 1; - block[0] = 2; - block[1] = 2; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + count[0] = H5S_UNLIMITED; + count[1] = 1; + block[0] = 2; + block[1] = 2; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); hssize_ret = H5Sget_select_npoints(sid2); @@ -1001,8 +1016,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(space_NA, H5I_INVALID_HID, "H5Screate_simple"); /* Create the dataset and write the region references to it */ - dset_NA = H5Dcreate2(fid1, "DS_NA", H5T_STD_REF, space_NA, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dset_NA = H5Dcreate2(fid1, "DS_NA", H5T_STD_REF, space_NA, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset_NA, H5I_INVALID_HID, "H5Dcreate"); /* Close and release resources for undefined region reference tests */ @@ -1046,9 +1060,11 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) /* * Dereference an undefined reference (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset2 = H5Ropen_object(&rdata_NA[0], H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object"); /* Close and release resources. */ @@ -1057,20 +1073,22 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) /* This close should fail since H5Ropen_object never created * the id of the referenced object. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dclose(dset2); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Dclose"); /* * End the test of an undefined reference */ - /* Open the dataset */ - dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); - CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); + /* Open the dataset */ + dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); + CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); - /* Read selection from disk */ + /* Read selection from disk */ ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); CHECK(ret, FAIL, "H5Dread"); @@ -1094,7 +1112,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Dread(dset2, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf); CHECK(ret, FAIL, "H5Dread"); - for(tu8 = (uint8_t *)drbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++, tu8++) + for (tu8 = (uint8_t *)drbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++, tu8++) VERIFY(*tu8, (uint8_t)(i * 3), "Data"); /* Get the hyperslab selection */ @@ -1209,10 +1227,12 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Dclose"); /* Attempting to retrieve type of object using non-valid refs */ - for(j = 0; j < 3; j++) { - H5E_BEGIN_TRY { + for (j = 0; j < 3; j++) { + H5E_BEGIN_TRY + { ret = H5Rget_obj_type3(&nvrbuf[j], H5P_DEFAULT, &obj_type); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Rget_obj_type3"); } /* end for */ @@ -1229,7 +1249,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Fclose"); /* Destroy references */ - for(j = 0; j < SPACE1_DIM1; j++) { + for (j = 0; j < SPACE1_DIM1; j++) { ret = H5Rdestroy(&wbuf[j]); CHECK(ret, FAIL, "H5Rdestroy"); ret = H5Rdestroy(&rbuf[j]); @@ -1241,9 +1261,8 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) HDfree(rbuf); HDfree(dwbuf); HDfree(drbuf); - } -} /* test_reference_region() */ +} /* test_reference_region() */ /**************************************************************** ** @@ -1258,42 +1277,42 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) static void test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) { - hid_t fid1; /* HDF5 File IDs */ - hid_t fapl; /* File access property list */ - hid_t dset1, /* Dataset ID */ - dset3; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid3; /* Dataspace ID #3 */ - hid_t dapl_id; /* Dataset access property list */ - hsize_t dims1[] = {2}, /* Must be 2 */ - dims3[] = {SPACE3_DIM1}; - hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ - hsize_t *coords; /* Coordinate buffer */ - hsize_t low[SPACE3_RANK]; /* Selection bounds */ - hsize_t high[SPACE3_RANK]; /* Selection bounds */ - H5R_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - H5O_type_t obj_type; /* Object type */ - int i; /* Counter */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t fapl; /* File access property list */ + hid_t dset1, /* Dataset ID */ + dset3; /* Dereferenced dataset ID */ + hid_t sid1, /* Dataspace ID #1 */ + sid3; /* Dataspace ID #3 */ + hid_t dapl_id; /* Dataset access property list */ + hsize_t dims1[] = {2}, /* Must be 2 */ + dims3[] = {SPACE3_DIM1}; + hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ + hsize_t * coords; /* Coordinate buffer */ + hsize_t low[SPACE3_RANK]; /* Selection bounds */ + hsize_t high[SPACE3_RANK]; /* Selection bounds */ + H5R_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t * tu8; /* Temporary pointer to uint8 data */ + H5O_type_t obj_type; /* Object type */ + int i; /* Counter */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing 1-D Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = HDcalloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); - rbuf = HDcalloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); + wbuf = HDcalloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); + rbuf = HDcalloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); dwbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); - for(tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) + for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) *tu8++ = (uint8_t)(i * 3); /* Create the file access property list */ @@ -1333,11 +1352,13 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(sid1, H5I_INVALID_HID, "H5Screate_simple"); /* Create a dataset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; - if(dset1 < 0) { + if (dset1 < 0) { VERIFY(libver_high <= H5F_LIBVER_V110, TRUE, "H5Dcreate2"); @@ -1352,8 +1373,8 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - - } else { + } + else { CHECK(ret, FAIL, "H5Dcreate2"); @@ -1364,7 +1385,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) stride[0] = 5; count[0] = 15; block[0] = 2; - ret = H5Sselect_hyperslab(sid3, H5S_SELECT_SET, start, stride, count, block); + ret = H5Sselect_hyperslab(sid3, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); ret = (int)H5Sget_select_npoints(sid3); @@ -1450,7 +1471,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Dread(dset3, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf); CHECK(ret, FAIL, "H5Dread"); - for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) + for (tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) VERIFY(*tu8, (uint8_t)(i * 3), "Data"); /* Get the hyperslab selection */ @@ -1468,16 +1489,16 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Sget_select_hyper_blocklist(sid3, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); - VERIFY(coords[0], 2, "Hyperslab Coordinates"); - VERIFY(coords[1], 3, "Hyperslab Coordinates"); - VERIFY(coords[2], 7, "Hyperslab Coordinates"); - VERIFY(coords[3], 8, "Hyperslab Coordinates"); - VERIFY(coords[4], 12, "Hyperslab Coordinates"); - VERIFY(coords[5], 13, "Hyperslab Coordinates"); - VERIFY(coords[6], 17, "Hyperslab Coordinates"); - VERIFY(coords[7], 18, "Hyperslab Coordinates"); - VERIFY(coords[8], 22, "Hyperslab Coordinates"); - VERIFY(coords[9], 23, "Hyperslab Coordinates"); + VERIFY(coords[0], 2, "Hyperslab Coordinates"); + VERIFY(coords[1], 3, "Hyperslab Coordinates"); + VERIFY(coords[2], 7, "Hyperslab Coordinates"); + VERIFY(coords[3], 8, "Hyperslab Coordinates"); + VERIFY(coords[4], 12, "Hyperslab Coordinates"); + VERIFY(coords[5], 13, "Hyperslab Coordinates"); + VERIFY(coords[6], 17, "Hyperslab Coordinates"); + VERIFY(coords[7], 18, "Hyperslab Coordinates"); + VERIFY(coords[8], 22, "Hyperslab Coordinates"); + VERIFY(coords[9], 23, "Hyperslab Coordinates"); VERIFY(coords[10], 27, "Hyperslab Coordinates"); VERIFY(coords[11], 28, "Hyperslab Coordinates"); VERIFY(coords[12], 32, "Hyperslab Coordinates"); @@ -1568,7 +1589,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Fclose"); /* Destroy references */ - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { ret = H5Rdestroy(&wbuf[i]); CHECK(ret, FAIL, "H5Rdestroy"); ret = H5Rdestroy(&rbuf[i]); @@ -1580,9 +1601,8 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) HDfree(rbuf); HDfree(dwbuf); HDfree(drbuf); - } -} /* test_reference_region_1D() */ +} /* test_reference_region_1D() */ /**************************************************************** ** @@ -1593,13 +1613,13 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) static void test_reference_obj_deleted(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t sid1; /* Dataspace ID */ - H5R_ref_t oref; /* Object Reference to test */ - H5O_type_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t sid1; /* Dataspace ID */ + H5R_ref_t oref; /* Object Reference to test */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ /* Create file */ fid1 = H5Fcreate(FILE_REF_OBJ_DEL, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1679,7 +1699,7 @@ test_reference_obj_deleted(void) /* Destroy reference */ ret = H5Rdestroy(&oref); CHECK(ret, FAIL, "H5Rdestroy"); -} /* test_reference_obj_deleted() */ +} /* test_reference_obj_deleted() */ /**************************************************************** ** @@ -1689,26 +1709,26 @@ test_reference_obj_deleted(void) ****************************************************************/ static herr_t test_deref_iter_op(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *info, - void *op_data) + void *op_data) { - int *count = (int *)op_data; /* Pointer to name counter */ + int * count = (int *)op_data; /* Pointer to name counter */ herr_t ret_value; /* Simple check for correct names */ - if(*count == 0) { - if(HDstrcmp(name, DSETNAME2) == 0) + if (*count == 0) { + if (HDstrcmp(name, DSETNAME2) == 0) ret_value = 0; else ret_value = -1; } /* end if */ - else if(*count == 1) { - if(HDstrcmp(name, GROUPNAME2) == 0) + else if (*count == 1) { + if (HDstrcmp(name, GROUPNAME2) == 0) ret_value = 0; else ret_value = -1; } /* end if */ - else if(*count == 2) { - if(HDstrcmp(name, GROUPNAME3) == 0) + else if (*count == 2) { + if (HDstrcmp(name, GROUPNAME3) == 0) ret_value = 0; else ret_value = -1; @@ -1718,7 +1738,7 @@ test_deref_iter_op(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2 (*count)++; - return(ret_value); + return (ret_value); } /* end test_deref_iter_op() */ /**************************************************************** @@ -1730,18 +1750,18 @@ test_deref_iter_op(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2 static void test_reference_group(void) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - H5R_ref_t wref; /* Reference to write */ - H5R_ref_t rref; /* Reference to read */ - H5G_info_t ginfo; /* Group info struct */ - char objname[NAME_SIZE]; /* Buffer to store name */ - H5O_info2_t oinfo; /* Object info struct */ - int count = 0; /* Count within iterated group */ - ssize_t size; /* Name length */ - herr_t ret; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + H5R_ref_t wref; /* Reference to write */ + H5R_ref_t rref; /* Reference to read */ + H5G_info_t ginfo; /* Group info struct */ + char objname[NAME_SIZE]; /* Buffer to store name */ + H5O_info2_t oinfo; /* Object info struct */ + int count = 0; /* Count within iterated group */ + ssize_t size; /* Name length */ + herr_t ret; /* Create file with a group and a dataset containing an object reference to the group */ fid = H5Fcreate(FILE_REF_GRP, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1752,16 +1772,16 @@ test_reference_group(void) CHECK(sid, H5I_INVALID_HID, "H5Screate"); /* Create group to refer to */ - gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid, H5I_INVALID_HID, "H5Gcreate2"); /* Create nested groups */ - gid2 = H5Gcreate2(gid, GROUPNAME2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid2 = H5Gcreate2(gid, GROUPNAME2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid2, H5I_INVALID_HID, "H5Gcreate2"); ret = H5Gclose(gid2); CHECK(ret, FAIL, "H5Gclose"); - gid2 = H5Gcreate2(gid, GROUPNAME3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid2 = H5Gcreate2(gid, GROUPNAME3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid2, H5I_INVALID_HID, "H5Gcreate2"); ret = H5Gclose(gid2); CHECK(ret, FAIL, "H5Gclose"); @@ -1824,11 +1844,13 @@ test_reference_group(void) CHECK(ret, FAIL, "H5Gget_info"); VERIFY(ginfo.nlinks, 3, "H5Gget_info"); - size = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, objname, (size_t)NAME_SIZE, H5P_DEFAULT); + size = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, objname, (size_t)NAME_SIZE, + H5P_DEFAULT); CHECK(size, (-1), "H5Lget_name_by_idx"); VERIFY_STR(objname, DSETNAME2, "H5Lget_name_by_idx"); - ret = H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &oinfo, H5O_INFO_BASIC, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_idx3"); VERIFY(oinfo.type, H5O_TYPE_DATASET, "H5Oget_info_by_idx3"); @@ -1851,7 +1873,7 @@ test_reference_group(void) /* Destroy reference */ ret = H5Rdestroy(&rref); CHECK(ret, FAIL, "H5Rdestroy"); -} /* test_reference_group() */ +} /* test_reference_group() */ /**************************************************************** ** @@ -1862,20 +1884,20 @@ test_reference_group(void) static void test_reference_attr(void) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ - hid_t attr; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hsize_t dims[] = {SPACE1_DIM1}; - hid_t dapl_id; /* Dataset access property list */ - H5R_ref_t ref_wbuf[SPACE1_DIM1], /* Buffer to write to disk */ - ref_rbuf[SPACE1_DIM1]; /* Buffer read from disk */ - unsigned wbuf[SPACE1_DIM1], rbuf[SPACE1_DIM1]; - unsigned i; /* Local index variables */ - H5O_type_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t attr; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t dims[] = {SPACE1_DIM1}; + hid_t dapl_id; /* Dataset access property list */ + H5R_ref_t ref_wbuf[SPACE1_DIM1], /* Buffer to write to disk */ + ref_rbuf[SPACE1_DIM1]; /* Buffer read from disk */ + unsigned wbuf[SPACE1_DIM1], rbuf[SPACE1_DIM1]; + unsigned i; /* Local index variables */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Reference Functions\n")); @@ -1900,7 +1922,7 @@ test_reference_attr(void) attr = H5Acreate2(group, "Attr2", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) wbuf[i] = (i * 3) + 1; /* Write attribute to disk */ @@ -1919,7 +1941,7 @@ test_reference_attr(void) attr = H5Acreate2(dataset, "Attr1", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) wbuf[i] = i * 3; /* Write attribute to disk */ @@ -1947,13 +1969,13 @@ test_reference_attr(void) CHECK(tid, H5I_INVALID_HID, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -1964,7 +1986,7 @@ test_reference_attr(void) attr = H5Acreate2(tid, "Attr3", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) wbuf[i] = (i * 3) + 2; /* Write attribute to disk */ @@ -2058,7 +2080,7 @@ test_reference_attr(void) ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) VERIFY(rbuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ @@ -2073,7 +2095,7 @@ test_reference_attr(void) ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) VERIFY(rbuf[i], (i * 3) + 1, "Data"); /* Close attribute */ @@ -2088,7 +2110,7 @@ test_reference_attr(void) ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) VERIFY(rbuf[i], (i * 3) + 2, "Data"); /* Close attribute */ @@ -2114,7 +2136,7 @@ test_reference_attr(void) ret = H5Rdestroy(&ref_rbuf[i]); CHECK(ret, FAIL, "H5Rdestroy"); } -} /* test_reference_attr() */ +} /* test_reference_attr() */ /**************************************************************** ** @@ -2125,20 +2147,20 @@ test_reference_attr(void) static void test_reference_external(void) { - hid_t fid1, fid2; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ - hid_t attr; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hsize_t dims[] = {SPACE1_DIM1}; - hid_t dapl_id; /* Dataset access property list */ - H5R_ref_t ref_wbuf[SPACE1_DIM1], /* Buffer to write to disk */ - ref_rbuf[SPACE1_DIM1]; /* Buffer read from disk */ - unsigned wbuf[SPACE1_DIM1], rbuf[SPACE1_DIM1]; - unsigned i; /* Local index variables */ - H5O_type_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ + hid_t fid1, fid2; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t attr; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t dims[] = {SPACE1_DIM1}; + hid_t dapl_id; /* Dataset access property list */ + H5R_ref_t ref_wbuf[SPACE1_DIM1], /* Buffer to write to disk */ + ref_rbuf[SPACE1_DIM1]; /* Buffer read from disk */ + unsigned wbuf[SPACE1_DIM1], rbuf[SPACE1_DIM1]; + unsigned i; /* Local index variables */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing External References Functions\n")); @@ -2163,7 +2185,7 @@ test_reference_external(void) attr = H5Acreate2(group, "Attr2", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) wbuf[i] = (i * 3) + 1; /* Write attribute to disk */ @@ -2182,7 +2204,7 @@ test_reference_external(void) attr = H5Acreate2(dataset, "Attr1", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) wbuf[i] = i * 3; /* Write attribute to disk */ @@ -2210,13 +2232,13 @@ test_reference_external(void) CHECK(tid, H5I_INVALID_HID, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -2227,7 +2249,7 @@ test_reference_external(void) attr = H5Acreate2(tid, "Attr3", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) wbuf[i] = (i * 3) + 2; /* Write attribute to disk */ @@ -2337,7 +2359,7 @@ test_reference_external(void) ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) VERIFY(rbuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ @@ -2352,7 +2374,7 @@ test_reference_external(void) ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) VERIFY(rbuf[i], (i * 3) + 1, "Data"); /* Close attribute */ @@ -2367,7 +2389,7 @@ test_reference_external(void) ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) VERIFY(rbuf[i], (i * 3) + 2, "Data"); /* Close attribute */ @@ -2393,7 +2415,7 @@ test_reference_external(void) ret = H5Rdestroy(&ref_rbuf[i]); CHECK(ret, FAIL, "H5Rdestroy"); } -} /* test_reference_external() */ +} /* test_reference_external() */ /**************************************************************** ** @@ -2404,26 +2426,25 @@ test_reference_external(void) static void test_reference_compat_conv(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, dset2; /* Dataset ID */ - hid_t group, group2; /* Group ID */ - hid_t sid1, sid2, sid3; /* Dataspace IDs */ - hid_t tid1, tid2; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}, - dims2[] = {SPACE2_DIM1, SPACE2_DIM2}, - dims3[] = {SPACE1_DIM1}; /* Purposedly set dimension larger to test NULL references */ - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK];/* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hobj_ref_t *wbuf_obj; /* Buffer to write to disk */ - H5R_ref_t *rbuf_obj; /* Buffer read from disk */ - hdset_reg_ref_t *wbuf_reg; /* Buffer to write to disk */ - H5R_ref_t *rbuf_reg; /* Buffer read from disk */ - H5O_type_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ - unsigned int i; /* Counter */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, dset2; /* Dataset ID */ + hid_t group, group2; /* Group ID */ + hid_t sid1, sid2, sid3; /* Dataspace IDs */ + hid_t tid1, tid2; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}, + dims3[] = {SPACE1_DIM1}; /* Purposedly set dimension larger to test NULL references */ + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hobj_ref_t * wbuf_obj; /* Buffer to write to disk */ + H5R_ref_t * rbuf_obj; /* Buffer read from disk */ + hdset_reg_ref_t *wbuf_reg; /* Buffer to write to disk */ + H5R_ref_t * rbuf_reg; /* Buffer read from disk */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ + unsigned int i; /* Counter */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deprecated Object Reference Functions\n")); @@ -2475,13 +2496,13 @@ test_reference_compat_conv(void) CHECK(tid1, H5I_INVALID_HID, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -2537,7 +2558,7 @@ test_reference_compat_conv(void) count[1] = 1; block[0] = 6; block[1] = 6; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create first dataset region */ @@ -2545,17 +2566,27 @@ test_reference_compat_conv(void) CHECK(ret, FAIL, "H5Rcreate"); /* Select sequence of ten points for second reference */ - coord1[0][0] = 6; coord1[0][1] = 9; - coord1[1][0] = 2; coord1[1][1] = 2; - coord1[2][0] = 8; coord1[2][1] = 4; - coord1[3][0] = 1; coord1[3][1] = 6; - coord1[4][0] = 2; coord1[4][1] = 8; - coord1[5][0] = 3; coord1[5][1] = 2; - coord1[6][0] = 0; coord1[6][1] = 4; - coord1[7][0] = 9; coord1[7][1] = 0; - coord1[8][0] = 7; coord1[8][1] = 1; - coord1[9][0] = 3; coord1[9][1] = 3; - ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + coord1[0][0] = 6; + coord1[0][1] = 9; + coord1[1][0] = 2; + coord1[1][1] = 2; + coord1[2][0] = 8; + coord1[2][1] = 4; + coord1[3][0] = 1; + coord1[3][1] = 6; + coord1[4][0] = 2; + coord1[4][1] = 8; + coord1[5][0] = 3; + coord1[5][1] = 2; + coord1[6][0] = 0; + coord1[6][1] = 4; + coord1[7][0] = 9; + coord1[7][1] = 0; + coord1[8][0] = 7; + coord1[8][1] = 1; + coord1[9][0] = 3; + coord1[9][1] = 3; + ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); /* Create second dataset region */ @@ -2611,7 +2642,6 @@ test_reference_compat_conv(void) CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_NAMED_DATATYPE, "H5Rget_obj_type3"); - /* Make sure the referenced objects can be opened */ dset2 = H5Ropen_object(&rbuf_obj[0], H5P_DEFAULT, H5P_DEFAULT); CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); @@ -2641,7 +2671,6 @@ test_reference_compat_conv(void) ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - /* Open the dataset region reference dataset */ dataset = H5Dopen2(fid1, "/Dataset4", H5P_DEFAULT); CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); @@ -2681,11 +2710,11 @@ test_reference_compat_conv(void) CHECK(ret, FAIL, "H5Fclose"); /* Destroy references */ - for(i = 0; i < dims1[0]; i++) { + for (i = 0; i < dims1[0]; i++) { ret = H5Rdestroy(&rbuf_obj[i]); CHECK(ret, FAIL, "H5Rdestroy"); } - for(i = 0; i < dims3[0]; i++) { + for (i = 0; i < dims3[0]; i++) { ret = H5Rdestroy(&rbuf_reg[i]); CHECK(ret, FAIL, "H5Rdestroy"); } @@ -2695,7 +2724,7 @@ test_reference_compat_conv(void) HDfree(rbuf_obj); HDfree(wbuf_reg); HDfree(rbuf_reg); -} /* test_reference_compat() */ +} /* test_reference_compat() */ /**************************************************************** ** @@ -2706,46 +2735,46 @@ test_reference_compat_conv(void) static void test_reference_perf(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {1}; - hid_t dapl_id; /* Dataset access property list */ - H5R_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ - H5R_ref_t *wbuf_reg, /* buffer to write to disk */ - *rbuf_reg; /* buffer read from disk */ - hobj_ref_t *wbuf_deprec,/* deprecated references */ - *rbuf_deprec;/* deprecated references */ - hdset_reg_ref_t *wbuf_reg_deprec, /* deprecated references*/ - *rbuf_reg_deprec; /* deprecated references*/ - unsigned *ibuf, *obuf; - unsigned i, j; /* Counters */ - H5O_type_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ - double t1, t2, t; /* Timers */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {1}; + hid_t dapl_id; /* Dataset access property list */ + H5R_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ + H5R_ref_t *wbuf_reg, /* buffer to write to disk */ + *rbuf_reg; /* buffer read from disk */ + hobj_ref_t *wbuf_deprec, /* deprecated references */ + *rbuf_deprec; /* deprecated references */ + hdset_reg_ref_t *wbuf_reg_deprec, /* deprecated references*/ + *rbuf_reg_deprec; /* deprecated references*/ + unsigned * ibuf, *obuf; + unsigned i, j; /* Counters */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ + double t1, t2, t; /* Timers */ /* Output message about test being performed */ MESSAGE(5, ("Testing Object Reference Performance\n")); /* Allocate write & read buffers */ - wbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); - obuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); - ibuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); - wbuf_deprec = (hobj_ref_t *)HDcalloc(sizeof(hobj_ref_t), SPACE1_DIM1); - rbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf_deprec = (hobj_ref_t *)HDcalloc(sizeof(hobj_ref_t), SPACE1_DIM1); - tbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); - wbuf_reg = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf_reg = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + wbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + obuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); + ibuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); + wbuf_deprec = (hobj_ref_t *)HDcalloc(sizeof(hobj_ref_t), SPACE1_DIM1); + rbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf_deprec = (hobj_ref_t *)HDcalloc(sizeof(hobj_ref_t), SPACE1_DIM1); + tbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + wbuf_reg = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf_reg = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); wbuf_reg_deprec = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); rbuf_reg_deprec = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - for(i = 0; i < SPACE1_DIM1; i++) + for (i = 0; i < SPACE1_DIM1; i++) obuf[i] = i * 3; /* Create file */ @@ -2789,13 +2818,13 @@ test_reference_perf(void) CHECK(tid1, H5I_INVALID_HID, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -2815,8 +2844,8 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); t = 0; - for(i = 0; i < MAX_ITER_CREATE; i++) { - t1 = H5_get_time(); + for (i = 0; i < MAX_ITER_CREATE; i++) { + t1 = H5_get_time(); ret = H5Rcreate_object(fid1, "/Group1/Dataset1", H5P_DEFAULT, &wbuf[0]); CHECK(ret, FAIL, "H5Rcreate_object"); t2 = H5_get_time(); @@ -2824,7 +2853,7 @@ test_reference_perf(void) ret = H5Rdestroy(&wbuf[0]); CHECK(ret, FAIL, "H5Rdestroy"); } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Object reference create time: %lfs\n", t / MAX_ITER_CREATE); /* Create reference to dataset */ @@ -2835,7 +2864,7 @@ test_reference_perf(void) VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); t = 0; - for(i = 0; i < MAX_ITER_WRITE; i++) { + for (i = 0; i < MAX_ITER_WRITE; i++) { t1 = H5_get_time(); /* Write selection to disk */ ret = H5Dwrite(dataset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -2843,7 +2872,7 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Object reference write time: %lfs\n", t / MAX_ITER_WRITE); /* Close Dataset */ @@ -2855,14 +2884,14 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); t = 0; - for(i = 0; i < MAX_ITER_CREATE; i++) { - t1 = H5_get_time(); + for (i = 0; i < MAX_ITER_CREATE; i++) { + t1 = H5_get_time(); ret = H5Rcreate(&wbuf_deprec[0], fid1, "/Group1/Dataset1", H5R_OBJECT1, H5I_INVALID_HID); CHECK(ret, FAIL, "H5Rcreate"); t2 = H5_get_time(); t += t2 - t1; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Deprecated object reference create time: %lfs\n", t / MAX_ITER_CREATE); /* Create reference to dataset */ @@ -2870,7 +2899,7 @@ test_reference_perf(void) CHECK(ret, FAIL, "H5Rcreate"); t = 0; - for(i = 0; i < MAX_ITER_WRITE; i++) { + for (i = 0; i < MAX_ITER_WRITE; i++) { t1 = H5_get_time(); /* Write selection to disk */ ret = H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf_deprec); @@ -2878,7 +2907,7 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Deprecated object reference write time: %lfs\n", t / MAX_ITER_WRITE); /* Close Dataset */ @@ -2890,7 +2919,7 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); t = 0; - for(i = 0; i < MAX_ITER_CREATE; i++) { + for (i = 0; i < MAX_ITER_CREATE; i++) { t1 = H5_get_time(); /* Store first dataset region */ ret = H5Rcreate_region(fid1, "/Group1/Dataset1", sid1, H5P_DEFAULT, &wbuf_reg[0]); @@ -2900,7 +2929,7 @@ test_reference_perf(void) ret = H5Rdestroy(&wbuf_reg[0]); CHECK(ret, FAIL, "H5Rdestroy"); } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Region reference create time: %lfs\n", t / MAX_ITER_CREATE); /* Store first dataset region */ @@ -2908,7 +2937,7 @@ test_reference_perf(void) CHECK(ret, FAIL, "H5Rcreate_region"); t = 0; - for(i = 0; i < MAX_ITER_WRITE; i++) { + for (i = 0; i < MAX_ITER_WRITE; i++) { t1 = H5_get_time(); /* Write selection to disk */ ret = H5Dwrite(dataset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf_reg); @@ -2916,7 +2945,7 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Region reference write time: %lfs\n", t / MAX_ITER_WRITE); /* Close Dataset */ @@ -2928,7 +2957,7 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); t = 0; - for(i = 0; i < MAX_ITER_CREATE; i++) { + for (i = 0; i < MAX_ITER_CREATE; i++) { t1 = H5_get_time(); /* Store first dataset region */ ret = H5Rcreate(&wbuf_reg_deprec[0], fid1, "/Group1/Dataset1", H5R_DATASET_REGION1, sid1); @@ -2936,11 +2965,11 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Deprecated region reference create time: %lfs\n", t / MAX_ITER_CREATE); t = 0; - for(i = 0; i < MAX_ITER_WRITE; i++) { + for (i = 0; i < MAX_ITER_WRITE; i++) { t1 = H5_get_time(); /* Write selection to disk */ ret = H5Dwrite(dataset, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf_reg_deprec); @@ -2948,7 +2977,7 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Deprecated region reference write time: %lfs\n", t / MAX_ITER_WRITE); /* Close Dataset */ @@ -2972,7 +3001,7 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); t = 0; - for(i = 0; i < MAX_ITER_READ; i++) { + for (i = 0; i < MAX_ITER_READ; i++) { t1 = H5_get_time(); /* Read selection from disk */ ret = H5Dread(dataset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); @@ -2982,7 +3011,7 @@ test_reference_perf(void) ret = H5Rdestroy(&rbuf[0]); CHECK(ret, FAIL, "H5Rdestroy"); } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Object reference read time: %lfs\n", t / MAX_ITER_READ); /* Read selection from disk */ @@ -3004,7 +3033,7 @@ test_reference_perf(void) ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); CHECK(ret, FAIL, "H5Dread"); - for(i = 0; i < dims1[0]; i++) + for (i = 0; i < dims1[0]; i++) VERIFY(ibuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ @@ -3020,7 +3049,7 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); t = 0; - for(i = 0; i < MAX_ITER_READ; i++) { + for (i = 0; i < MAX_ITER_READ; i++) { t1 = H5_get_time(); /* Read selection from disk */ ret = H5Dread(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_deprec); @@ -3028,7 +3057,7 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Deprecated object reference read time: %lfs\n", t / MAX_ITER_READ); /* Close Dataset */ @@ -3040,7 +3069,7 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); t = 0; - for(i = 0; i < MAX_ITER_READ; i++) { + for (i = 0; i < MAX_ITER_READ; i++) { t1 = H5_get_time(); /* Read selection from disk */ ret = H5Dread(dataset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_reg); @@ -3050,7 +3079,7 @@ test_reference_perf(void) ret = H5Rdestroy(&rbuf_reg[0]); CHECK(ret, FAIL, "H5Rdestroy"); } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Region reference read time: %lfs\n", t / MAX_ITER_READ); /* Read selection from disk */ @@ -3066,7 +3095,7 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); t = 0; - for(i = 0; i < MAX_ITER_READ; i++) { + for (i = 0; i < MAX_ITER_READ; i++) { t1 = H5_get_time(); /* Read selection from disk */ ret = H5Dread(dataset, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_reg_deprec); @@ -3074,7 +3103,7 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("--- Deprecated region reference read time: %lfs\n", t / MAX_ITER_READ); /* Close Dataset */ @@ -3090,7 +3119,7 @@ test_reference_perf(void) CHECK(ret, FAIL, "H5Fclose"); /* Destroy references */ - for(j = 0; j < dims1[0]; j++) { + for (j = 0; j < dims1[0]; j++) { ret = H5Rdestroy(&wbuf[j]); CHECK(ret, FAIL, "H5Rdestroy"); ret = H5Rdestroy(&wbuf_reg[j]); @@ -3113,7 +3142,7 @@ test_reference_perf(void) HDfree(tbuf); HDfree(ibuf); HDfree(obuf); -} /* test_reference_perf() */ +} /* test_reference_perf() */ /**************************************************************** ** @@ -3123,39 +3152,38 @@ test_reference_perf(void) void test_reference(void) { - H5F_libver_t low, high; /* Low and high bounds */ + H5F_libver_t low, high; /* Low and high bounds */ /* Output message about test being performed */ MESSAGE(5, ("Testing References\n")); - test_reference_params(); /* Test for correct parameter checking */ - test_reference_obj(); /* Test basic H5R object reference code */ - test_reference_vlen_obj(); /* Test reference within vlen */ + test_reference_params(); /* Test for correct parameter checking */ + test_reference_obj(); /* Test basic H5R object reference code */ + test_reference_vlen_obj(); /* Test reference within vlen */ /* Loop through all the combinations of low/high version bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Invalid combinations, just continue */ - if(high == H5F_LIBVER_EARLIEST || high < low) + if (high == H5F_LIBVER_EARLIEST || high < low) continue; - test_reference_region(low, high); /* Test basic H5R dataset region reference code */ - test_reference_region_1D(low, high); /* Test H5R dataset region reference code for 1-D datasets */ + test_reference_region(low, high); /* Test basic H5R dataset region reference code */ + test_reference_region_1D(low, high); /* Test H5R dataset region reference code for 1-D datasets */ } /* end high bound */ - } /* end low bound */ + } /* end low bound */ - test_reference_obj_deleted(); /* Test H5R object reference code for deleted objects */ - test_reference_group(); /* Test operations on dereferenced groups */ - test_reference_attr(); /* Test attribute references */ - test_reference_external(); /* Test external references */ - test_reference_compat_conv(); /* Test operations with old types */ + test_reference_obj_deleted(); /* Test H5R object reference code for deleted objects */ + test_reference_group(); /* Test operations on dereferenced groups */ + test_reference_attr(); /* Test attribute references */ + test_reference_external(); /* Test external references */ + test_reference_compat_conv(); /* Test operations with old types */ test_reference_perf(); -} /* test_reference() */ - +} /* test_reference() */ /*------------------------------------------------------------------------- * Function: cleanup_reference diff --git a/test/trefer_deprec.c b/test/trefer_deprec.c index db91b8e..4f729b6 100644 --- a/test/trefer_deprec.c +++ b/test/trefer_deprec.c @@ -12,31 +12,31 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: trefer_deprec -* -* Test the Reference functionality -* -*************************************************************/ + * + * Test program: trefer_deprec + * + * Test the Reference functionality + * + *************************************************************/ #include "testhdf5.h" -#define FILE1 "trefer1.h5" -#define FILE2 "trefer2.h5" -#define FILE3 "trefer3.h5" +#define FILE1 "trefer1.h5" +#define FILE2 "trefer2.h5" +#define FILE3 "trefer3.h5" /* 1-D dataset with fixed dimensions */ -#define SPACE1_RANK 1 -#define SPACE1_DIM1 4 +#define SPACE1_RANK 1 +#define SPACE1_DIM1 4 /* 2-D dataset with fixed dimensions */ -#define SPACE2_RANK 2 -#define SPACE2_DIM1 10 -#define SPACE2_DIM2 10 +#define SPACE2_RANK 2 +#define SPACE2_DIM1 10 +#define SPACE2_DIM2 10 /* Larger 1-D dataset with fixed dimensions */ -#define SPACE3_RANK 1 -#define SPACE3_DIM1 100 +#define SPACE3_RANK 1 +#define SPACE3_DIM1 100 /* Element selection information */ #define POINT1_NPOINTS 10 @@ -45,16 +45,15 @@ typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; -#define GROUPNAME "/group" -#define GROUPNAME2 "group2" -#define GROUPNAME3 "group3" -#define DSETNAME "/dset" -#define DSETNAME2 "dset2" -#define NAME_SIZE 16 - +#define GROUPNAME "/group" +#define GROUPNAME2 "group2" +#define GROUPNAME3 "group3" +#define DSETNAME "/dset" +#define DSETNAME2 "dset2" +#define NAME_SIZE 16 /**************************************************************** ** @@ -65,23 +64,23 @@ typedef struct s1_t { static void test_reference_params(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hid_t dapl_id; /* Dataset access property list */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hid_t dapl_id; /* Dataset access property list */ hsize_t dims1[] = {SPACE1_DIM1}; - hobj_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i; /* counting variables */ + hobj_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ + unsigned * tu32; /* Temporary pointer to uint32 data */ + int i; /* counting variables */ const char *write_comment = "Foo!"; /* Comments for group */ - hid_t ret_id; /* Generic hid_t return value */ - ssize_t name_size; /* Size of reference name */ - herr_t ret; /* Generic return value */ + hid_t ret_id; /* Generic hid_t return value */ + ssize_t name_size; /* Size of reference name */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Reference Parameters\n")); @@ -115,7 +114,7 @@ test_reference_params(void) dataset = H5Dcreate2(group, "Dataset1", H5T_NATIVE_UINT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) + for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) *tu32++ = (unsigned)i * 3; /* Write selection to disk */ @@ -139,13 +138,13 @@ test_reference_params(void) CHECK(tid1, FAIL, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -234,7 +233,7 @@ test_reference_params(void) HDfree(wbuf); HDfree(rbuf); HDfree(tbuf); -} /* test_reference_obj() */ +} /* test_reference_obj() */ /**************************************************************** ** @@ -245,25 +244,25 @@ test_reference_params(void) static void test_reference_obj(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hid_t dapl_id; /* Dataset access property list */ - hobj_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ - hobj_ref_t nvrbuf[3]={0,101,1000000000}; /* buffer with non-valid refs */ - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i, j; /* counting variables */ - const char *write_comment="Foo!"; /* Comments for group */ - char read_comment[10]; - H5O_type_t obj_type; /* Object type */ - ssize_t size; /* Comment length */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hid_t dapl_id; /* Dataset access property list */ + hobj_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ + hobj_ref_t nvrbuf[3] = {0, 101, 1000000000}; /* buffer with non-valid refs */ + unsigned * tu32; /* Temporary pointer to uint32 data */ + int i, j; /* counting variables */ + const char *write_comment = "Foo!"; /* Comments for group */ + char read_comment[10]; + H5O_type_t obj_type; /* Object type */ + ssize_t size; /* Comment length */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Object Reference Functions\n")); @@ -297,7 +296,7 @@ test_reference_obj(void) dataset = H5Dcreate2(group, "Dataset1", H5T_NATIVE_UINT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) + for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) *tu32++ = (unsigned)i * 3; /* Write selection to disk */ @@ -321,13 +320,13 @@ test_reference_obj(void) CHECK(tid1, FAIL, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -417,8 +416,8 @@ test_reference_obj(void) ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tbuf); CHECK(ret, FAIL, "H5Dread"); - for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - VERIFY(*tu32, (uint32_t)(i*3), "Data"); + for (tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) + VERIFY(*tu32, (uint32_t)(i * 3), "Data"); /* Close dereferenced Dataset */ ret = H5Dclose(dset2); @@ -433,8 +432,8 @@ test_reference_obj(void) CHECK(size, FAIL, "H5Oget_comment"); /* Check for correct comment value */ - if(HDstrcmp(write_comment, read_comment) != 0) - TestErrPrintf("Error! Incorrect group comment, wanted: %s, got: %s\n",write_comment,read_comment); + if (HDstrcmp(write_comment, read_comment) != 0) + TestErrPrintf("Error! Incorrect group comment, wanted: %s, got: %s\n", write_comment, read_comment); /* Close group */ ret = H5Gclose(group); @@ -451,15 +450,17 @@ test_reference_obj(void) tclass = H5Tget_class(tid1); VERIFY(tclass, H5T_COMPOUND, "H5Tget_class"); - ret= H5Tget_nmembers(tid1); + ret = H5Tget_nmembers(tid1); VERIFY(ret, 3, "H5Tget_nmembers"); } /* Attempting to retrieve type of object using non-valid refs */ - for(j = 0; j < 3; j++) { - H5E_BEGIN_TRY { + for (j = 0; j < 3; j++) { + H5E_BEGIN_TRY + { ret = H5Rget_obj_type2(dataset, H5R_OBJECT, &nvrbuf[j], &obj_type); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Rget_obj_type2"); } /* end for */ @@ -483,7 +484,7 @@ test_reference_obj(void) HDfree(wbuf); HDfree(rbuf); HDfree(tbuf); -} /* test_reference_obj() */ +} /* test_reference_obj() */ /**************************************************************** ** @@ -498,47 +499,46 @@ test_reference_obj(void) static void test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) { - hid_t fid1; /* HDF5 File IDs */ - hid_t fapl = -1; /* File access property list */ - hid_t dset1, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid2; /* Dataspace ID #2 */ - hid_t dapl_id; /* Dataset access property list */ - hsize_t dims1[] = {SPACE1_DIM1}, - dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hsize_t *coords; /* Coordinate buffer */ - hsize_t low[SPACE2_RANK]; /* Selection bounds */ - hsize_t high[SPACE2_RANK]; /* Selection bounds */ - hdset_reg_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - hdset_reg_ref_t nvrbuf[3]={{{0}},{{101}},{{255}}}; /* buffer with non-valid refs */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - H5O_type_t obj_type; /* Type of object */ - int i, j; /* counting variables */ - hssize_t hssize_ret; /* hssize_t return value */ - htri_t tri_ret; /* htri_t return value */ - herr_t ret; /* Generic return value */ - hdset_reg_ref_t undef_reg[1]; /* test for undefined reference */ - hid_t dset_NA; /* Dataset id for undefined reference */ - hid_t space_NA; /* Dataspace id for undefined reference */ - hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ - hdset_reg_ref_t wdata_NA[1], /* Write buffer */ - rdata_NA[1]; /* Read buffer */ + hid_t fid1; /* HDF5 File IDs */ + hid_t fapl = -1; /* File access property list */ + hid_t dset1, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t sid1, /* Dataspace ID #1 */ + sid2; /* Dataspace ID #2 */ + hid_t dapl_id; /* Dataset access property list */ + hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hsize_t * coords; /* Coordinate buffer */ + hsize_t low[SPACE2_RANK]; /* Selection bounds */ + hsize_t high[SPACE2_RANK]; /* Selection bounds */ + hdset_reg_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + hdset_reg_ref_t nvrbuf[3] = {{{0}}, {{101}}, {{255}}}; /* buffer with non-valid refs */ + uint8_t * dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t * tu8; /* Temporary pointer to uint8 data */ + H5O_type_t obj_type; /* Type of object */ + int i, j; /* counting variables */ + hssize_t hssize_ret; /* hssize_t return value */ + htri_t tri_ret; /* htri_t return value */ + herr_t ret; /* Generic return value */ + hdset_reg_ref_t undef_reg[1]; /* test for undefined reference */ + hid_t dset_NA; /* Dataset id for undefined reference */ + hid_t space_NA; /* Dataspace id for undefined reference */ + hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ + hdset_reg_ref_t wdata_NA[1], /* Write buffer */ + rdata_NA[1]; /* Read buffer */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); @@ -566,7 +566,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset2, FAIL, "H5Dcreate2"); - for(tu8 = dwbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++) + for (tu8 = dwbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++) *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ @@ -588,11 +588,15 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) /* Create references */ /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 6; block[1] = 6; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 6; + block[1] = 6; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); ret = (int)H5Sget_select_npoints(sid2); @@ -606,17 +610,27 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type2"); /* Select sequence of ten points for second reference */ - coord1[0][0] = 6; coord1[0][1] = 9; - coord1[1][0] = 2; coord1[1][1] = 2; - coord1[2][0] = 8; coord1[2][1] = 4; - coord1[3][0] = 1; coord1[3][1] = 6; - coord1[4][0] = 2; coord1[4][1] = 8; - coord1[5][0] = 3; coord1[5][1] = 2; - coord1[6][0] = 0; coord1[6][1] = 4; - coord1[7][0] = 9; coord1[7][1] = 0; - coord1[8][0] = 7; coord1[8][1] = 1; - coord1[9][0] = 3; coord1[9][1] = 3; - ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + coord1[0][0] = 6; + coord1[0][1] = 9; + coord1[1][0] = 2; + coord1[1][1] = 2; + coord1[2][0] = 8; + coord1[2][1] = 4; + coord1[3][0] = 1; + coord1[3][1] = 6; + coord1[4][0] = 2; + coord1[4][1] = 8; + coord1[5][0] = 3; + coord1[5][1] = 2; + coord1[6][0] = 0; + coord1[6][1] = 4; + coord1[7][0] = 9; + coord1[7][1] = 0; + coord1[8][0] = 7; + coord1[8][1] = 1; + coord1[9][0] = 3; + coord1[9][1] = 3; + ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); ret = (int)H5Sget_select_npoints(sid2); @@ -627,22 +641,28 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Rcreate"); /* Select unlimited hyperslab for third reference */ - start[0] = 1; start[1] = 8; - stride[0] = 4; stride[1] = 1; - count[0] = H5S_UNLIMITED; count[1] = 1; - block[0] = 2; block[1] = 2; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + start[0] = 1; + start[1] = 8; + stride[0] = 4; + stride[1] = 1; + count[0] = H5S_UNLIMITED; + count[1] = 1; + block[0] = 2; + block[1] = 2; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); hssize_ret = H5Sget_select_npoints(sid2); VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints"); /* Store third dataset region */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); - } H5E_END_TRY; + } + H5E_END_TRY; - if(libver_high < H5F_LIBVER_V110) + if (libver_high < H5F_LIBVER_V110) VERIFY(ret, FAIL, "H5Rcreate"); else CHECK(ret, FAIL, "H5Rcreate"); @@ -670,8 +690,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(space_NA, FAIL, "H5Screate_simple"); /* Create the dataset and write the region references to it */ - dset_NA = H5Dcreate2(fid1, "DS_NA", H5T_STD_REF_DSETREG, space_NA, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dset_NA = H5Dcreate2(fid1, "DS_NA", H5T_STD_REF_DSETREG, space_NA, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset_NA, FAIL, "H5Dcreate"); /* Close and release resources for undefined region reference tests */ @@ -715,9 +734,11 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) /* * Dereference an undefined reference (should fail) */ - H5E_BEGIN_TRY { - dset2 = H5Rdereference2(dset_NA, H5P_DEFAULT, H5R_DATASET_REGION, &rdata_NA[0]); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + dset2 = H5Rdereference2(dset_NA, H5P_DEFAULT, H5R_DATASET_REGION, &rdata_NA[0]); + } + H5E_END_TRY; VERIFY(dset2, FAIL, "H5Rdereference2"); /* Close and release resources. */ @@ -726,9 +747,11 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) /* This close should fail since H5Rdereference2 never created * the id of the referenced object. */ - H5E_BEGIN_TRY { - ret = H5Dclose(dset2); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + ret = H5Dclose(dset2); + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Dclose"); /* @@ -767,7 +790,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Dread(dset2, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf); CHECK(ret, FAIL, "H5Dread"); - for(tu8 = (uint8_t *)drbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++, tu8++) + for (tu8 = (uint8_t *)drbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++, tu8++) VERIFY(*tu8, (uint8_t)(i * 3), "Data"); /* Get the hyperslab selection */ @@ -779,8 +802,9 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(ret, 36, "H5Sget_select_npoints"); ret = (int)H5Sget_select_hyper_nblocks(sid2); VERIFY(ret, 1, "H5Sget_select_hyper_nblocks"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ - ret = H5Sget_select_hyper_blocklist(sid2, (hsize_t)0, (hsize_t)ret, coords); + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t) * + 2); /* allocate space for the hyperslab blocks */ + ret = H5Sget_select_hyper_blocklist(sid2, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); VERIFY(coords[0], 2, "Hyperslab Coordinates"); VERIFY(coords[1], 2, "Hyperslab Coordinates"); @@ -807,8 +831,9 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(ret, 10, "H5Sget_select_npoints"); ret = (int)H5Sget_select_elem_npoints(sid2); VERIFY(ret, 10, "H5Sget_select_elem_npoints"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t)); /* allocate space for the element points */ - ret = H5Sget_select_elem_pointlist(sid2, (hsize_t)0, (hsize_t)ret, coords); + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * + sizeof(hsize_t)); /* allocate space for the element points */ + ret = H5Sget_select_elem_pointlist(sid2, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); VERIFY(coords[0], coord1[0][0], "Element Coordinates"); VERIFY(coords[1], coord1[0][1], "Element Coordinates"); @@ -842,7 +867,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Sclose(sid2); CHECK(ret, FAIL, "H5Sclose"); - if(libver_high >= H5F_LIBVER_V110) { + if (libver_high >= H5F_LIBVER_V110) { /* Get the unlimited selection */ sid2 = H5Rget_region(dset1, H5R_DATASET_REGION, &rbuf[2]); CHECK(sid2, FAIL, "H5Rget_region"); @@ -878,10 +903,12 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Dclose"); /* Attempting to retrieve type of object using non-valid refs */ - for(j = 0; j < 3; j++) { - H5E_BEGIN_TRY { + for (j = 0; j < 3; j++) { + H5E_BEGIN_TRY + { ret = H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &nvrbuf[j], &obj_type); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Rget_obj_type2"); } /* end for */ @@ -902,7 +929,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) HDfree(rbuf); HDfree(dwbuf); HDfree(drbuf); -} /* test_reference_region() */ +} /* test_reference_region() */ /**************************************************************** ** @@ -917,38 +944,37 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) static void test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) { - hid_t fid1; /* HDF5 File IDs */ - hid_t fapl = -1; /* File access property list */ - hid_t dset1, /* Dataset ID */ - dset3; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid3; /* Dataspace ID #3 */ - hid_t dapl_id; /* Dataset access property list */ - hsize_t dims1[] = {SPACE1_DIM1}, - dims3[] = {SPACE3_DIM1}; - hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ - hsize_t *coords; /* Coordinate buffer */ - hsize_t low[SPACE3_RANK]; /* Selection bounds */ - hsize_t high[SPACE3_RANK]; /* Selection bounds */ - hdset_reg_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - H5O_type_t obj_type; /* Object type */ - int i; /* counting variables */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t fapl = -1; /* File access property list */ + hid_t dset1, /* Dataset ID */ + dset3; /* Dereferenced dataset ID */ + hid_t sid1, /* Dataspace ID #1 */ + sid3; /* Dataspace ID #3 */ + hid_t dapl_id; /* Dataset access property list */ + hsize_t dims1[] = {SPACE1_DIM1}, dims3[] = {SPACE3_DIM1}; + hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ + hsize_t * coords; /* Coordinate buffer */ + hsize_t low[SPACE3_RANK]; /* Selection bounds */ + hsize_t high[SPACE3_RANK]; /* Selection bounds */ + hdset_reg_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t * tu8; /* Temporary pointer to uint8 data */ + H5O_type_t obj_type; /* Object type */ + int i; /* counting variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing 1-D Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); @@ -976,7 +1002,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) dset3 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8LE, sid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset3, FAIL, "H5Dcreate2"); - for(tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) + for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ @@ -998,11 +1024,11 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) /* Create references */ /* Select 15 2x1 hyperslabs for first reference */ - start[0] = 2; + start[0] = 2; stride[0] = 5; - count[0] = 15; - block[0] = 2; - ret = H5Sselect_hyperslab(sid3, H5S_SELECT_SET, start, stride, count, block); + count[0] = 15; + block[0] = 2; + ret = H5Sselect_hyperslab(sid3, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); ret = (int)H5Sget_select_npoints(sid3); @@ -1026,7 +1052,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) coord1[7][0] = 89; coord1[8][0] = 97; coord1[9][0] = 03; - ret = H5Sselect_elements(sid3, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + ret = H5Sselect_elements(sid3, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); ret = (int)H5Sget_select_npoints(sid3); @@ -1088,7 +1114,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Dread(dset3, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf); CHECK(ret, FAIL, "H5Dread"); - for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) + for (tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) VERIFY(*tu8, (uint8_t)(i * 3), "Data"); /* Get the hyperslab selection */ @@ -1100,19 +1126,20 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(ret, 30, "H5Sget_select_npoints"); ret = (int)H5Sget_select_hyper_nblocks(sid3); VERIFY(ret, 15, "H5Sget_select_hyper_nblocks"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ - ret = H5Sget_select_hyper_blocklist(sid3, (hsize_t)0, (hsize_t)ret, coords); + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t) * + 2); /* allocate space for the hyperslab blocks */ + ret = H5Sget_select_hyper_blocklist(sid3, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); - VERIFY(coords[0], 2, "Hyperslab Coordinates"); - VERIFY(coords[1], 3, "Hyperslab Coordinates"); - VERIFY(coords[2], 7, "Hyperslab Coordinates"); - VERIFY(coords[3], 8, "Hyperslab Coordinates"); - VERIFY(coords[4], 12, "Hyperslab Coordinates"); - VERIFY(coords[5], 13, "Hyperslab Coordinates"); - VERIFY(coords[6], 17, "Hyperslab Coordinates"); - VERIFY(coords[7], 18, "Hyperslab Coordinates"); - VERIFY(coords[8], 22, "Hyperslab Coordinates"); - VERIFY(coords[9], 23, "Hyperslab Coordinates"); + VERIFY(coords[0], 2, "Hyperslab Coordinates"); + VERIFY(coords[1], 3, "Hyperslab Coordinates"); + VERIFY(coords[2], 7, "Hyperslab Coordinates"); + VERIFY(coords[3], 8, "Hyperslab Coordinates"); + VERIFY(coords[4], 12, "Hyperslab Coordinates"); + VERIFY(coords[5], 13, "Hyperslab Coordinates"); + VERIFY(coords[6], 17, "Hyperslab Coordinates"); + VERIFY(coords[7], 18, "Hyperslab Coordinates"); + VERIFY(coords[8], 22, "Hyperslab Coordinates"); + VERIFY(coords[9], 23, "Hyperslab Coordinates"); VERIFY(coords[10], 27, "Hyperslab Coordinates"); VERIFY(coords[11], 28, "Hyperslab Coordinates"); VERIFY(coords[12], 32, "Hyperslab Coordinates"); @@ -1152,8 +1179,9 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(ret, 10, "H5Sget_select_npoints"); ret = (int)H5Sget_select_elem_npoints(sid3); VERIFY(ret, 10, "H5Sget_select_elem_npoints"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t)); /* allocate space for the element points */ - ret = H5Sget_select_elem_pointlist(sid3, (hsize_t)0, (hsize_t)ret, coords); + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * + sizeof(hsize_t)); /* allocate space for the element points */ + ret = H5Sget_select_elem_pointlist(sid3, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); VERIFY(coords[0], coord1[0][0], "Element Coordinates"); VERIFY(coords[1], coord1[1][0], "Element Coordinates"); @@ -1204,7 +1232,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) HDfree(rbuf); HDfree(dwbuf); HDfree(drbuf); -} /* test_reference_region_1D() */ +} /* test_reference_region_1D() */ /**************************************************************** ** @@ -1215,14 +1243,14 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) static void test_reference_obj_deleted(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t sid1; /* Dataspace ID */ - hobj_ref_t oref; /* Object Reference to test */ - H5O_type_t obj_type; /* Object type */ - haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t sid1; /* Dataspace ID */ + hobj_ref_t oref; /* Object Reference to test */ + H5O_type_t obj_type; /* Object type */ + haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ + herr_t ret; /* Generic return value */ /* Create file */ fid1 = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1304,7 +1332,7 @@ test_reference_obj_deleted(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_reference_obj_deleted() */ +} /* test_reference_obj_deleted() */ /**************************************************************** ** @@ -1314,26 +1342,26 @@ test_reference_obj_deleted(void) ****************************************************************/ static herr_t test_deref_iter_op(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *info, - void *op_data) + void *op_data) { - int *count = (int *)op_data; /* Pointer to name counter */ + int * count = (int *)op_data; /* Pointer to name counter */ herr_t ret_value; /* Simple check for correct names */ - if(*count == 0) { - if(HDstrcmp(name, DSETNAME2) == 0) + if (*count == 0) { + if (HDstrcmp(name, DSETNAME2) == 0) ret_value = 0; else ret_value = -1; } /* end if */ - else if(*count == 1) { - if(HDstrcmp(name, GROUPNAME2) == 0) + else if (*count == 1) { + if (HDstrcmp(name, GROUPNAME2) == 0) ret_value = 0; else ret_value = -1; } /* end if */ - else if(*count == 2) { - if(HDstrcmp(name, GROUPNAME3) == 0) + else if (*count == 2) { + if (HDstrcmp(name, GROUPNAME3) == 0) ret_value = 0; else ret_value = -1; @@ -1343,7 +1371,7 @@ test_deref_iter_op(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2 (*count)++; - return(ret_value); + return (ret_value); } /* end test_deref_iter_op() */ /**************************************************************** @@ -1355,18 +1383,18 @@ test_deref_iter_op(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2 static void test_reference_group(void) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hobj_ref_t wref; /* Reference to write */ - hobj_ref_t rref; /* Reference to read */ - H5G_info_t ginfo; /* Group info struct */ - char objname[NAME_SIZE]; /* Buffer to store name */ - H5O_info2_t oinfo; /* Object info struct */ - int count = 0; /* Count within iterated group */ - ssize_t size; /* Name length */ - herr_t ret; + hid_t fid = -1; /* File ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hobj_ref_t wref; /* Reference to write */ + hobj_ref_t rref; /* Reference to read */ + H5G_info_t ginfo; /* Group info struct */ + char objname[NAME_SIZE]; /* Buffer to store name */ + H5O_info2_t oinfo; /* Object info struct */ + int count = 0; /* Count within iterated group */ + ssize_t size; /* Name length */ + herr_t ret; /* Create file with a group and a dataset containing an object reference to the group */ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1377,16 +1405,16 @@ test_reference_group(void) CHECK(sid, FAIL, "H5Screate"); /* Create group to refer to */ - gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid = H5Gcreate2(fid, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid, FAIL, "H5Gcreate2"); /* Create nested groups */ - gid2 = H5Gcreate2(gid, GROUPNAME2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid2 = H5Gcreate2(gid, GROUPNAME2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid2, FAIL, "H5Gcreate2"); ret = H5Gclose(gid2); CHECK(ret, FAIL, "H5Gclose"); - gid2 = H5Gcreate2(gid, GROUPNAME3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid2 = H5Gcreate2(gid, GROUPNAME3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid2, FAIL, "H5Gcreate2"); ret = H5Gclose(gid2); CHECK(ret, FAIL, "H5Gclose"); @@ -1420,7 +1448,6 @@ test_reference_group(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -1446,11 +1473,13 @@ test_reference_group(void) CHECK(ret, FAIL, "H5Gget_info"); VERIFY(ginfo.nlinks, 3, "H5Gget_info"); - size = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, objname, (size_t)NAME_SIZE, H5P_DEFAULT); + size = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, objname, (size_t)NAME_SIZE, + H5P_DEFAULT); CHECK(size, FAIL, "H5Lget_name_by_idx"); VERIFY_STR(objname, DSETNAME2, "H5Lget_name_by_idx"); - ret = H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &oinfo, H5O_INFO_BASIC, + H5P_DEFAULT); CHECK(ret, FAIL, "H5Oget_info_by_idx3"); VERIFY(oinfo.type, H5O_TYPE_DATASET, "H5Oget_info_by_idx3"); @@ -1469,7 +1498,7 @@ test_reference_group(void) CHECK(ret, FAIL, "H5Gclose"); ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* test_reference_group() */ +} /* test_reference_group() */ #ifndef H5_NO_DEPRECATED_SYMBOLS /**************************************************************** @@ -1481,25 +1510,24 @@ test_reference_group(void) static void test_reference_compat(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, dset2; /* Dataset ID */ - hid_t group, group2; /* Group ID */ - hid_t sid1, /* Dataspace IDs */ - sid2; - hid_t tid1, tid2; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}, - dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hobj_ref_t *wbuf_obj, /* Buffer to write to disk */ - *rbuf_obj; /* Buffer read from disk */ - hdset_reg_ref_t *wbuf_reg, /* Buffer to write to disk */ - *rbuf_reg; /* Buffer read from disk */ - H5G_obj_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, dset2; /* Dataset ID */ + hid_t group, group2; /* Group ID */ + hid_t sid1, /* Dataspace IDs */ + sid2; + hid_t tid1, tid2; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hobj_ref_t *wbuf_obj, /* Buffer to write to disk */ + *rbuf_obj; /* Buffer read from disk */ + hdset_reg_ref_t *wbuf_reg, /* Buffer to write to disk */ + *rbuf_reg; /* Buffer read from disk */ + H5G_obj_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deprecated Object Reference Functions\n")); @@ -1547,13 +1575,13 @@ test_reference_compat(void) CHECK(tid1, FAIL, "H5Tcreate"); /* Insert fields */ - ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_INT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT); CHECK(ret, FAIL, "H5Tinsert"); /* Save datatype for later */ @@ -1568,7 +1596,6 @@ test_reference_compat(void) ret = H5Gclose(group); CHECK(ret, FAIL, "H5Gclose"); - /* Create a dataset with object reference datatype */ dataset = H5Dcreate2(fid1, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); @@ -1597,17 +1624,20 @@ test_reference_compat(void) ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - /* Create a dataset with region reference datatype */ dataset = H5Dcreate2(fid1, "Dataset4", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 6; block[1] = 6; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 6; + block[1] = 6; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create first dataset region */ @@ -1615,17 +1645,27 @@ test_reference_compat(void) CHECK(ret, FAIL, "H5Rcreate"); /* Select sequence of ten points for second reference */ - coord1[0][0] = 6; coord1[0][1] = 9; - coord1[1][0] = 2; coord1[1][1] = 2; - coord1[2][0] = 8; coord1[2][1] = 4; - coord1[3][0] = 1; coord1[3][1] = 6; - coord1[4][0] = 2; coord1[4][1] = 8; - coord1[5][0] = 3; coord1[5][1] = 2; - coord1[6][0] = 0; coord1[6][1] = 4; - coord1[7][0] = 9; coord1[7][1] = 0; - coord1[8][0] = 7; coord1[8][1] = 1; - coord1[9][0] = 3; coord1[9][1] = 3; - ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + coord1[0][0] = 6; + coord1[0][1] = 9; + coord1[1][0] = 2; + coord1[1][1] = 2; + coord1[2][0] = 8; + coord1[2][1] = 4; + coord1[3][0] = 1; + coord1[3][1] = 6; + coord1[4][0] = 2; + coord1[4][1] = 8; + coord1[5][0] = 3; + coord1[5][1] = 2; + coord1[6][0] = 0; + coord1[6][1] = 4; + coord1[7][0] = 9; + coord1[7][1] = 0; + coord1[8][0] = 7; + coord1[8][1] = 1; + coord1[9][0] = 3; + coord1[9][1] = 3; + ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); /* Create second dataset region */ @@ -1640,7 +1680,6 @@ test_reference_compat(void) ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - /* Close disk dataspaces */ ret = H5Sclose(sid1); CHECK(ret, FAIL, "H5Sclose"); @@ -1651,7 +1690,6 @@ test_reference_compat(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Re-open the file */ fid1 = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -1681,7 +1719,6 @@ test_reference_compat(void) CHECK(obj_type, H5G_UNKNOWN, "H5Rget_obj_type1"); VERIFY(obj_type, H5G_TYPE, "H5Rget_obj_type1"); - /* Make sure the referenced objects can be opened */ dset2 = H5Rdereference1(dataset, H5R_OBJECT, &rbuf_obj[0]); CHECK(dset2, FAIL, "H5Rdereference1"); @@ -1711,7 +1748,6 @@ test_reference_compat(void) ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - /* Open the dataset region reference dataset */ dataset = H5Dopen2(fid1, "/Dataset4", H5P_DEFAULT); CHECK(ret, FAIL, "H5Dopen2"); @@ -1761,7 +1797,7 @@ test_reference_compat(void) HDfree(rbuf_obj); HDfree(wbuf_reg); HDfree(rbuf_reg); -} /* test_reference_compat() */ +} /* test_reference_compat() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ /**************************************************************** @@ -1772,36 +1808,35 @@ test_reference_compat(void) void test_reference_deprec(void) { - H5F_libver_t low, high; /* Low and high bounds */ + H5F_libver_t low, high; /* Low and high bounds */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deprecated References\n")); - test_reference_params(); /* Test for correct parameter checking */ - test_reference_obj(); /* Test basic H5R object reference code */ + test_reference_params(); /* Test for correct parameter checking */ + test_reference_obj(); /* Test basic H5R object reference code */ /* Loop through all the combinations of low/high version bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Invalid combinations, just continue */ - if(high == H5F_LIBVER_EARLIEST || high < low) + if (high == H5F_LIBVER_EARLIEST || high < low) continue; - test_reference_region(low, high); /* Test basic H5R dataset region reference code */ - test_reference_region_1D(low, high); /* Test H5R dataset region reference code for 1-D datasets */ + test_reference_region(low, high); /* Test basic H5R dataset region reference code */ + test_reference_region_1D(low, high); /* Test H5R dataset region reference code for 1-D datasets */ } /* end high bound */ - } /* end low bound */ + } /* end low bound */ test_reference_obj_deleted(); /* Test H5R object reference code for deleted objects */ - test_reference_group(); /* Test operations on dereferenced groups */ + test_reference_group(); /* Test operations on dereferenced groups */ #ifndef H5_NO_DEPRECATED_SYMBOLS - test_reference_compat(); /* Test operations with old API routines */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - -} /* test_reference() */ + test_reference_compat(); /* Test operations with old API routines */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ +} /* test_reference() */ /*------------------------------------------------------------------------- * Function: cleanup_reference @@ -1824,4 +1859,3 @@ cleanup_reference_deprec(void) HDremove(FILE2); HDremove(FILE3); } - diff --git a/test/trefer_shutdown.c b/test/trefer_shutdown.c index b1c43e0..50bdb26 100644 --- a/test/trefer_shutdown.c +++ b/test/trefer_shutdown.c @@ -7,7 +7,7 @@ main(int argc, char **argv) hid_t fid; hid_t did; hid_t sid; - int i; + int i; if ((fid = H5Fcreate("HDFFV-10992.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "H5Fcreate failed\n"); diff --git a/test/trefstr.c b/test/trefstr.c index c33b5eb..18e357e 100644 --- a/test/trefstr.c +++ b/test/trefstr.c @@ -58,23 +58,23 @@ test_refstr_init(void) static void test_refstr_create(void) { - H5RS_str_t *rs; /* Ref-counted string created */ - unsigned count; /* Reference count on string */ - herr_t ret; /* Generic return value */ + H5RS_str_t *rs; /* Ref-counted string created */ + unsigned count; /* Reference count on string */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Creating & Closing Ref-Counted Strings\n")); /* Try creating a ref-counted string */ - rs=H5RS_create("foo"); + rs = H5RS_create("foo"); CHECK_PTR(rs, "H5RS_create"); /* Get the reference count on the string */ - count=H5RS_get_count(rs); + count = H5RS_get_count(rs); VERIFY(count, 1, "H5RS_get_count"); /* Try closing a real ref-counted string */ - ret=H5RS_decr(rs); + ret = H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr"); } /* end test_refstr_create() */ @@ -88,39 +88,39 @@ test_refstr_create(void) static void test_refstr_count(void) { - H5RS_str_t *rs; /* Ref-counted string created */ - unsigned count; /* Reference count on string */ - herr_t ret; /* Generic return value */ + H5RS_str_t *rs; /* Ref-counted string created */ + unsigned count; /* Reference count on string */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Incrementing & Decrementing Ref-Counted Strings\n")); /* Try creating a ref-counted string */ - rs=H5RS_create("foo"); + rs = H5RS_create("foo"); CHECK_PTR(rs, "H5RS_create"); /* Get the reference count on the string */ - count=H5RS_get_count(rs); + count = H5RS_get_count(rs); VERIFY(count, 1, "H5RS_get_count"); /* Increment reference count */ - ret=H5RS_incr(rs); + ret = H5RS_incr(rs); CHECK(ret, FAIL, "H5RS_incr"); /* Get the reference count on the string */ - count=H5RS_get_count(rs); + count = H5RS_get_count(rs); VERIFY(count, 2, "H5RS_get_count"); /* Decrement reference count for string */ - ret=H5RS_decr(rs); + ret = H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr"); /* Get the reference count on the string */ - count=H5RS_get_count(rs); + count = H5RS_get_count(rs); VERIFY(count, 1, "H5RS_get_count"); /* Decrement reference count for string */ - ret=H5RS_decr(rs); + ret = H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr"); } /* end test_refstr_count() */ @@ -134,42 +134,42 @@ test_refstr_count(void) static void test_refstr_dup(void) { - H5RS_str_t *rs1; /* Ref-counted string created */ - H5RS_str_t *rs2; /* Ref-counted string created */ - unsigned count; /* Reference count on string */ - herr_t ret; /* Generic return value */ + H5RS_str_t *rs1; /* Ref-counted string created */ + H5RS_str_t *rs2; /* Ref-counted string created */ + unsigned count; /* Reference count on string */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Duplicating Ref-Counted Strings\n")); /* Try creating a ref-counted string */ - rs1=H5RS_create("foo"); + rs1 = H5RS_create("foo"); CHECK_PTR(rs1, "H5RS_create"); /* Get the reference count on the string */ - count=H5RS_get_count(rs1); + count = H5RS_get_count(rs1); VERIFY(count, 1, "H5RS_get_count"); /* Duplicate r-string */ - rs2=H5RS_dup(rs1); + rs2 = H5RS_dup(rs1); CHECK_PTR(rs2, "H5RS_dup"); /* Get the reference count on the strings */ - count=H5RS_get_count(rs1); + count = H5RS_get_count(rs1); VERIFY(count, 2, "H5RS_get_count"); - count=H5RS_get_count(rs2); + count = H5RS_get_count(rs2); VERIFY(count, 2, "H5RS_get_count"); /* Decrement reference count for string */ - ret=H5RS_decr(rs2); + ret = H5RS_decr(rs2); CHECK(ret, FAIL, "H5RS_decr"); /* Get the reference count on the string */ - count=H5RS_get_count(rs1); + count = H5RS_get_count(rs1); VERIFY(count, 1, "H5RS_get_count"); /* Decrement reference count for string */ - ret=H5RS_decr(rs1); + ret = H5RS_decr(rs1); CHECK(ret, FAIL, "H5RS_decr"); } /* end test_refstr_dup() */ @@ -183,42 +183,42 @@ test_refstr_dup(void) static void test_refstr_cmp(void) { - H5RS_str_t *rs1; /* Ref-counted string created */ - H5RS_str_t *rs2; /* Ref-counted string created */ - int cmp; /* Comparison value */ - ssize_t len; /* Length of string */ - herr_t ret; /* Generic return value */ + H5RS_str_t *rs1; /* Ref-counted string created */ + H5RS_str_t *rs2; /* Ref-counted string created */ + int cmp; /* Comparison value */ + ssize_t len; /* Length of string */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Comparing Ref-Counted Strings\n")); /* Create first reference counted string */ - rs1=H5RS_create("foo"); + rs1 = H5RS_create("foo"); CHECK_PTR(rs1, "H5RS_create"); /* Create second reference counted string */ - rs2=H5RS_create("foo2"); + rs2 = H5RS_create("foo2"); CHECK_PTR(rs2, "H5RS_create"); /* Compare the strings in various ways */ - cmp=H5RS_cmp(rs1,rs1); + cmp = H5RS_cmp(rs1, rs1); VERIFY(cmp, 0, "H5RS_cmp"); - cmp=H5RS_cmp(rs2,rs2); + cmp = H5RS_cmp(rs2, rs2); VERIFY(cmp, 0, "H5RS_cmp"); - cmp=H5RS_cmp(rs1,rs2); - if(cmp>=0) - TestErrPrintf("%d: string comparison incorrect!\n",__LINE__); + cmp = H5RS_cmp(rs1, rs2); + if (cmp >= 0) + TestErrPrintf("%d: string comparison incorrect!\n", __LINE__); /* Check the lengths of the strings also */ - len=H5RS_len(rs1); + len = H5RS_len(rs1); VERIFY(len, 3, "H5RS_len"); - len=H5RS_len(rs2); + len = H5RS_len(rs2); VERIFY(len, 4, "H5RS_len"); /* Decrement reference count for strings */ - ret=H5RS_decr(rs2); + ret = H5RS_decr(rs2); CHECK(ret, FAIL, "H5RS_decr"); - ret=H5RS_decr(rs1); + ret = H5RS_decr(rs1); CHECK(ret, FAIL, "H5RS_decr"); } /* end test_refstr_cmp() */ @@ -232,48 +232,48 @@ test_refstr_cmp(void) static void test_refstr_wrap(void) { - H5RS_str_t *rs; /* Ref-counted string created */ - const char *s; /* Pointer to raw string in ref-counted string */ - char buf[16]; /* Buffer to wrap */ - int cmp; /* Comparison value */ - herr_t ret; /* Generic return value */ + H5RS_str_t *rs; /* Ref-counted string created */ + const char *s; /* Pointer to raw string in ref-counted string */ + char buf[16]; /* Buffer to wrap */ + int cmp; /* Comparison value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Wrapping Ref-Counted Strings\n")); /* Initialize buffer */ - HDstrcpy(buf,"foo"); + HDstrcpy(buf, "foo"); /* Wrap ref-counted string around existing buffer */ - rs=H5RS_wrap(buf); + rs = H5RS_wrap(buf); CHECK_PTR(rs, "H5RS_wrap"); /* Get pointer to raw string in ref-counted string */ - s=H5RS_get_str(rs); + s = H5RS_get_str(rs); CHECK_PTR(s, "H5RS_get_str"); CHECK_PTR_EQ(s, buf, "wrapping"); - cmp=HDstrcmp(s,buf); + cmp = HDstrcmp(s, buf); VERIFY(cmp, 0, "HDstrcmp"); /* Increment reference count (should duplicate string) */ - ret=H5RS_incr(rs); + ret = H5RS_incr(rs); CHECK(ret, FAIL, "H5RS_incr"); /* Change the buffer initially wrapped */ - buf[0]='F'; + buf[0] = 'F'; /* Get pointer to raw string in ref-counted string */ - s=H5RS_get_str(rs); + s = H5RS_get_str(rs); CHECK_PTR(s, "H5RS_get_str"); CHECK(s, buf, "wrapping"); - cmp=HDstrcmp(s,buf); - if(cmp<=0) - TestErrPrintf("%d: string comparison incorrect!\n",__LINE__); + cmp = HDstrcmp(s, buf); + if (cmp <= 0) + TestErrPrintf("%d: string comparison incorrect!\n", __LINE__); /* Decrement reference count for string */ - ret=H5RS_decr(rs); + ret = H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr"); - ret=H5RS_decr(rs); + ret = H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr"); } /* end test_refstr_wrap() */ @@ -288,49 +288,49 @@ test_refstr_wrap(void) static void test_refstr_own(void) { - H5RS_str_t *rs; /* Ref-counted string created */ - char *s; /* Pointer to string to transfer */ - const char *t; /* Temporary pointers to string */ - int cmp; /* Comparison value */ - herr_t ret; /* Generic return value */ + H5RS_str_t *rs; /* Ref-counted string created */ + char * s; /* Pointer to string to transfer */ + const char *t; /* Temporary pointers to string */ + int cmp; /* Comparison value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Transferring Ref-Counted Strings\n")); /* Initialize buffer */ - s = (char *)H5FL_BLK_MALLOC(str_buf,HDstrlen("foo") + 1); + s = (char *)H5FL_BLK_MALLOC(str_buf, HDstrlen("foo") + 1); CHECK_PTR(s, "H5FL_BLK_MALLOC"); HDstrcpy(s, "foo"); /* Transfer ownership of dynamically allocated string to ref-counted string */ - rs=H5RS_own(s); + rs = H5RS_own(s); CHECK_PTR(rs, "H5RS_own"); /* Get pointer to raw string in ref-counted string */ - t=H5RS_get_str(rs); + t = H5RS_get_str(rs); CHECK_PTR(t, "H5RS_get_str"); CHECK_PTR_EQ(t, s, "transferring"); - cmp=HDstrcmp(s,t); + cmp = HDstrcmp(s, t); VERIFY(cmp, 0, "HDstrcmp"); /* Increment reference count (should NOT duplicate string) */ - ret=H5RS_incr(rs); + ret = H5RS_incr(rs); CHECK(ret, FAIL, "H5RS_incr"); /* Change the buffer initially wrapped */ - *s='F'; + *s = 'F'; /* Get pointer to raw string in ref-counted string */ - t=H5RS_get_str(rs); + t = H5RS_get_str(rs); CHECK_PTR(t, "H5RS_get_str"); CHECK_PTR_EQ(t, s, "transferring"); - cmp=HDstrcmp(t,s); + cmp = HDstrcmp(t, s); VERIFY(cmp, 0, "HDstrcmp"); /* Decrement reference count for string */ - ret=H5RS_decr(rs); + ret = H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr"); - ret=H5RS_decr(rs); + ret = H5RS_decr(rs); CHECK(ret, FAIL, "H5RS_decr"); } /* end test_refstr_own() */ @@ -361,14 +361,13 @@ test_refstr(void) test_refstr_init(); /* Actual ref-counted strings tests */ - test_refstr_create(); /* Test ref-counted string creation */ - test_refstr_count(); /* Test ref-counted string counting */ - test_refstr_dup(); /* Test ref-counted string duplication */ - test_refstr_cmp(); /* Test ref-counted string comparison */ - test_refstr_wrap(); /* Test ref-counted string wrapping */ - test_refstr_own(); /* Test ref-counted string ownership transfer */ + test_refstr_create(); /* Test ref-counted string creation */ + test_refstr_count(); /* Test ref-counted string counting */ + test_refstr_dup(); /* Test ref-counted string duplication */ + test_refstr_cmp(); /* Test ref-counted string comparison */ + test_refstr_wrap(); /* Test ref-counted string wrapping */ + test_refstr_own(); /* Test ref-counted string ownership transfer */ /* Finalize ref-counted strings testing data */ test_refstr_finalize(); -} /* end test_refstr() */ - +} /* end test_refstr() */ diff --git a/test/tselect.c b/test/tselect.c index c98db5d..38ba69c 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -12,50 +12,50 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: tselect -* -* Test the Dataspace selection functionality -* -*************************************************************/ + * + * Test program: tselect + * + * Test the Dataspace selection functionality + * + *************************************************************/ -#define H5S_FRIEND /*suppress error about including H5Spkg */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ /* Define this macro to indicate that the testing APIs should be available */ #define H5S_TESTING #include "testhdf5.h" -#include "H5Spkg.h" /* Dataspaces */ +#include "H5Spkg.h" /* Dataspaces */ -#define FILENAME "tselect.h5" +#define FILENAME "tselect.h5" /* 3-D dataset with fixed dimensions */ -#define SPACE1_NAME "Space1" -#define SPACE1_RANK 3 -#define SPACE1_DIM1 3 -#define SPACE1_DIM2 15 -#define SPACE1_DIM3 13 +#define SPACE1_NAME "Space1" +#define SPACE1_RANK 3 +#define SPACE1_DIM1 3 +#define SPACE1_DIM2 15 +#define SPACE1_DIM3 13 /* 2-D dataset with fixed dimensions */ #define SPACE2_NAME "Space2" -#define SPACE2_RANK 2 -#define SPACE2_DIM1 30 -#define SPACE2_DIM2 26 -#define SPACE2A_RANK 1 -#define SPACE2A_DIM1 (SPACE2_DIM1*SPACE2_DIM2) +#define SPACE2_RANK 2 +#define SPACE2_DIM1 30 +#define SPACE2_DIM2 26 +#define SPACE2A_RANK 1 +#define SPACE2A_DIM1 (SPACE2_DIM1 * SPACE2_DIM2) /* 2-D dataset with fixed dimensions */ -#define SPACE3_NAME "Space3" -#define SPACE3_RANK 2 -#define SPACE3_DIM1 15 -#define SPACE3_DIM2 26 +#define SPACE3_NAME "Space3" +#define SPACE3_RANK 2 +#define SPACE3_DIM1 15 +#define SPACE3_DIM2 26 /* 3-D dataset with fixed dimensions */ -#define SPACE4_NAME "Space4" -#define SPACE4_RANK 3 -#define SPACE4_DIM1 11 -#define SPACE4_DIM2 13 -#define SPACE4_DIM3 17 +#define SPACE4_NAME "Space4" +#define SPACE4_RANK 3 +#define SPACE4_DIM1 11 +#define SPACE4_DIM2 13 +#define SPACE4_DIM3 17 /* Number of random hyperslabs to test */ #define NHYPERSLABS 10 @@ -64,63 +64,63 @@ #define NRAND_HYPER 100 /* 5-D dataset with fixed dimensions */ -#define SPACE5_NAME "Space5" -#define SPACE5_RANK 5 -#define SPACE5_DIM1 10 -#define SPACE5_DIM2 10 -#define SPACE5_DIM3 10 -#define SPACE5_DIM4 10 -#define SPACE5_DIM5 10 +#define SPACE5_NAME "Space5" +#define SPACE5_RANK 5 +#define SPACE5_DIM1 10 +#define SPACE5_DIM2 10 +#define SPACE5_DIM3 10 +#define SPACE5_DIM4 10 +#define SPACE5_DIM5 10 /* 1-D dataset with same size as 5-D dataset */ -#define SPACE6_RANK 1 -#define SPACE6_DIM1 (SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5) +#define SPACE6_RANK 1 +#define SPACE6_DIM1 (SPACE5_DIM1 * SPACE5_DIM2 * SPACE5_DIM3 * SPACE5_DIM4 * SPACE5_DIM5) /* 2-D dataset with easy dimension sizes */ -#define SPACE7_NAME "Space7" -#define SPACE7_RANK 2 -#define SPACE7_DIM1 10 -#define SPACE7_DIM2 10 -#define SPACE7_FILL 254 +#define SPACE7_NAME "Space7" +#define SPACE7_RANK 2 +#define SPACE7_DIM1 10 +#define SPACE7_DIM2 10 +#define SPACE7_FILL 254 #define SPACE7_CHUNK_DIM1 5 #define SPACE7_CHUNK_DIM2 5 -#define SPACE7_NPOINTS 8 +#define SPACE7_NPOINTS 8 /* 4-D dataset with fixed dimensions */ -#define SPACE8_NAME "Space8" -#define SPACE8_RANK 4 -#define SPACE8_DIM1 11 -#define SPACE8_DIM2 13 -#define SPACE8_DIM3 17 -#define SPACE8_DIM4 19 +#define SPACE8_NAME "Space8" +#define SPACE8_RANK 4 +#define SPACE8_DIM1 11 +#define SPACE8_DIM2 13 +#define SPACE8_DIM3 17 +#define SPACE8_DIM4 19 /* Another 2-D dataset with easy dimension sizes */ -#define SPACE9_RANK 2 -#define SPACE9_DIM1 12 -#define SPACE9_DIM2 12 +#define SPACE9_RANK 2 +#define SPACE9_DIM1 12 +#define SPACE9_DIM2 12 /* Element selection information */ #define POINT1_NPOINTS 10 /* Chunked dataset information */ #define DATASETNAME "ChunkArray" -#define NX_SUB 87 /* hyperslab dimensions */ -#define NY_SUB 61 -#define NZ_SUB 181 -#define NX 87 /* output buffer dimensions */ -#define NY 61 -#define NZ 181 -#define RANK_F 3 /* File dataspace rank */ -#define RANK_M 3 /* Memory dataspace rank */ -#define X 87 /* dataset dimensions */ -#define Y 61 -#define Z 181 -#define CHUNK_X 87 /* chunk dimensions */ -#define CHUNK_Y 61 -#define CHUNK_Z 181 +#define NX_SUB 87 /* hyperslab dimensions */ +#define NY_SUB 61 +#define NZ_SUB 181 +#define NX 87 /* output buffer dimensions */ +#define NY 61 +#define NZ 181 +#define RANK_F 3 /* File dataspace rank */ +#define RANK_M 3 /* Memory dataspace rank */ +#define X 87 /* dataset dimensions */ +#define Y 61 +#define Z 181 +#define CHUNK_X 87 /* chunk dimensions */ +#define CHUNK_Y 61 +#define CHUNK_Z 181 /* Basic chunk size */ -#define SPACE10_DIM1 180 +#define SPACE10_DIM1 180 #define SPACE10_CHUNK_SIZE 12 /* Information for bounds checking test */ @@ -130,40 +130,40 @@ #define SPACE11_NPOINTS 4 /* Information for offsets w/chunks test #2 */ -#define SPACE12_RANK 1 -#define SPACE12_DIM0 25 -#define SPACE12_CHUNK_DIM0 5 +#define SPACE12_RANK 1 +#define SPACE12_DIM0 25 +#define SPACE12_CHUNK_DIM0 5 /* Information for Space rebuild test */ -#define SPACERE1_RANK 1 -#define SPACERE1_DIM0 20 -#define SPACERE2_RANK 2 -#define SPACERE2_DIM0 8 -#define SPACERE2_DIM1 12 -#define SPACERE3_RANK 3 -#define SPACERE3_DIM0 8 -#define SPACERE3_DIM1 12 -#define SPACERE3_DIM2 8 -#define SPACERE4_RANK 4 -#define SPACERE4_DIM0 8 -#define SPACERE4_DIM1 12 -#define SPACERE4_DIM2 8 -#define SPACERE4_DIM3 12 -#define SPACERE5_RANK 5 -#define SPACERE5_DIM0 8 -#define SPACERE5_DIM1 12 -#define SPACERE5_DIM2 8 -#define SPACERE5_DIM3 12 -#define SPACERE5_DIM4 8 +#define SPACERE1_RANK 1 +#define SPACERE1_DIM0 20 +#define SPACERE2_RANK 2 +#define SPACERE2_DIM0 8 +#define SPACERE2_DIM1 12 +#define SPACERE3_RANK 3 +#define SPACERE3_DIM0 8 +#define SPACERE3_DIM1 12 +#define SPACERE3_DIM2 8 +#define SPACERE4_RANK 4 +#define SPACERE4_DIM0 8 +#define SPACERE4_DIM1 12 +#define SPACERE4_DIM2 8 +#define SPACERE4_DIM3 12 +#define SPACERE5_RANK 5 +#define SPACERE5_DIM0 8 +#define SPACERE5_DIM1 12 +#define SPACERE5_DIM2 8 +#define SPACERE5_DIM3 12 +#define SPACERE5_DIM4 8 /* Information for Space update diminfo test */ -#define SPACEUD1_DIM0 20 -#define SPACEUD3_DIM0 9 -#define SPACEUD3_DIM1 12 -#define SPACEUD3_DIM2 13 +#define SPACEUD1_DIM0 20 +#define SPACEUD3_DIM0 9 +#define SPACEUD3_DIM1 12 +#define SPACEUD3_DIM2 13 /* #defines for shape same / different rank tests */ -#define SS_DR_MAX_RANK 5 +#define SS_DR_MAX_RANK 5 /* Information for regular hyperslab query test */ #define SPACE13_RANK 3 @@ -173,25 +173,30 @@ #define SPACE13_NPOINTS 4 /* Information for testing selection iterators */ -#define SEL_ITER_MAX_SEQ 256 - +#define SEL_ITER_MAX_SEQ 256 /* Defines for test_hyper_io_1d() */ -#define DNAME "DSET_1D" -#define RANK 1 -#define NUMCHUNKS 3 -#define CHUNKSZ 20 -#define NUM_ELEMENTS NUMCHUNKS * CHUNKSZ +#define DNAME "DSET_1D" +#define RANK 1 +#define NUMCHUNKS 3 +#define CHUNKSZ 20 +#define NUM_ELEMENTS NUMCHUNKS *CHUNKSZ /* Location comparison function */ static int compare_size_t(const void *s1, const void *s2); -static herr_t test_select_hyper_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data); -static herr_t test_select_point_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data); -static herr_t test_select_all_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data); -static herr_t test_select_none_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data); -static herr_t test_select_hyper_iter2(void *_elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_operator_data); -static herr_t test_select_hyper_iter3(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data); +static herr_t test_select_hyper_iter1(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *operator_data); +static herr_t test_select_point_iter1(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *operator_data); +static herr_t test_select_all_iter1(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *operator_data); +static herr_t test_select_none_iter1(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *operator_data); +static herr_t test_select_hyper_iter2(void *_elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *_operator_data); +static herr_t test_select_hyper_iter3(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *operator_data); /**************************************************************** ** @@ -199,18 +204,19 @@ static herr_t test_select_hyper_iter3(void *elem,hid_t type_id, unsigned ndim, c ** ****************************************************************/ static herr_t -test_select_hyper_iter1(void *_elem, hid_t H5_ATTR_UNUSED type_id, unsigned H5_ATTR_UNUSED ndim, const hsize_t H5_ATTR_UNUSED *point, void *_operator_data) +test_select_hyper_iter1(void *_elem, hid_t H5_ATTR_UNUSED type_id, unsigned H5_ATTR_UNUSED ndim, + const hsize_t H5_ATTR_UNUSED *point, void *_operator_data) { - uint8_t *tbuf=(uint8_t *)_elem, /* temporary buffer pointer */ - **tbuf2=(uint8_t **)_operator_data; /* temporary buffer handle */ + uint8_t *tbuf = (uint8_t *)_elem, /* temporary buffer pointer */ + **tbuf2 = (uint8_t **)_operator_data; /* temporary buffer handle */ - if(*tbuf!=**tbuf2) - return(-1); + if (*tbuf != **tbuf2) + return (-1); else { (*tbuf2)++; - return(0); + return (0); } -} /* end test_select_hyper_iter1() */ +} /* end test_select_hyper_iter1() */ /**************************************************************** ** @@ -221,22 +227,22 @@ test_select_hyper_iter1(void *_elem, hid_t H5_ATTR_UNUSED type_id, unsigned H5_A static void test_select_hyper(hid_t xfer_plist) { - hid_t fid1; /* HDF5 File IDs */ + hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; - hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temporary buffer pointer */ - int i,j; /* Counters */ - herr_t ret; /* Generic return value */ - H5S_class_t ext_type; /* Extent type */ + hid_t sid1, sid2; /* Dataspace ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; + hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ + uint8_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temporary buffer pointer */ + int i, j; /* Counters */ + herr_t ret; /* Generic return value */ + H5S_class_t ext_type; /* Extent type */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslab Selection Functions\n")); @@ -248,9 +254,9 @@ test_select_hyper(hid_t xfer_plist) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; ibuf+(pnt_info->coord[pnt_info->offset][0]*SPACE2_DIM2)+pnt_info->coord[pnt_info->offset][1]; - if(*elem!=*tmp) - return(-1); + uint8_t * elem = (uint8_t *)_elem; /* Pointer to the element to examine */ + uint8_t * tmp; /* temporary ptr to element in operator data */ + struct pnt_iter *pnt_info = (struct pnt_iter *)_operator_data; + + tmp = pnt_info->buf + (pnt_info->coord[pnt_info->offset][0] * SPACE2_DIM2) + + pnt_info->coord[pnt_info->offset][1]; + if (*elem != *tmp) + return (-1); else { pnt_info->offset++; - return(0); + return (0); } -} /* end test_select_point_iter1() */ +} /* end test_select_point_iter1() */ /**************************************************************** ** @@ -423,24 +479,24 @@ test_select_point_iter1(void *_elem, hid_t H5_ATTR_UNUSED type_id, unsigned H5_A static void test_select_point(hid_t xfer_plist) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; - hsize_t coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */ - hsize_t temp_coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */ - hsize_t coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hsize_t temp_coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hsize_t coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ - hsize_t temp_coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temporary buffer pointer */ - int i,j; /* Counters */ - struct pnt_iter pi; /* Custom Pointer iterator struct */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; + hsize_t coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */ + hsize_t temp_coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */ + hsize_t coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hsize_t temp_coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hsize_t coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ + hsize_t temp_coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ + uint8_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temporary buffer pointer */ + int i, j; /* Counters */ + struct pnt_iter pi; /* Custom Pointer iterator struct */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Element Selection Functions\n")); @@ -452,9 +508,9 @@ test_select_point(hid_t xfer_plist) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i *(const size_t *)s2) + return (1); else - if(*(const size_t *)s1>*(const size_t *)s2) - return(1); - else - return(0); + return (0); } /**************************************************************** @@ -1075,46 +1250,47 @@ compare_size_t(const void *s1, const void *s2) static void test_select_hyper_stride(hid_t xfer_plist) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; - hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ - uint16_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf, /* temporary buffer pointer */ - *tbuf2; /* temporary buffer pointer */ - size_t loc1[72]={ /* Gruesomely ugly way to make certain hyperslab locations are checked correctly */ - 27, 28, 29, 53, 54, 55, 79, 80, 81, /* Block #1 */ - 32, 33, 34, 58, 59, 60, 84, 85, 86, /* Block #2 */ - 157,158,159,183,184,185,209,210,211, /* Block #3 */ - 162,163,164,188,189,190,214,215,216, /* Block #4 */ - 287,288,289,313,314,315,339,340,341, /* Block #5 */ - 292,293,294,318,319,320,344,345,346, /* Block #6 */ - 417,418,419,443,444,445,469,470,471, /* Block #7 */ - 422,423,424,448,449,450,474,475,476, /* Block #8 */ - }; - size_t loc2[72]={ - 0, 1, 2, 26, 27, 28, /* Block #1 */ - 4, 5, 6, 30, 31, 32, /* Block #2 */ - 8, 9, 10, 34, 35, 36, /* Block #3 */ - 12, 13, 14, 38, 39, 40, /* Block #4 */ - 104,105,106,130,131,132, /* Block #5 */ - 108,109,110,134,135,136, /* Block #6 */ - 112,113,114,138,139,140, /* Block #7 */ - 116,117,118,142,143,144, /* Block #8 */ - 208,209,210,234,235,236, /* Block #9 */ - 212,213,214,238,239,240, /* Block #10 */ - 216,217,218,242,243,244, /* Block #11 */ - 220,221,222,246,247,248, /* Block #12 */ - }; - int i,j; /* Counters */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; + hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ + uint16_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf, /* temporary buffer pointer */ + *tbuf2; /* temporary buffer pointer */ + size_t loc1[72] = { + /* Gruesomely ugly way to make certain hyperslab locations are checked correctly */ + 27, 28, 29, 53, 54, 55, 79, 80, 81, /* Block #1 */ + 32, 33, 34, 58, 59, 60, 84, 85, 86, /* Block #2 */ + 157, 158, 159, 183, 184, 185, 209, 210, 211, /* Block #3 */ + 162, 163, 164, 188, 189, 190, 214, 215, 216, /* Block #4 */ + 287, 288, 289, 313, 314, 315, 339, 340, 341, /* Block #5 */ + 292, 293, 294, 318, 319, 320, 344, 345, 346, /* Block #6 */ + 417, 418, 419, 443, 444, 445, 469, 470, 471, /* Block #7 */ + 422, 423, 424, 448, 449, 450, 474, 475, 476, /* Block #8 */ + }; + size_t loc2[72] = { + 0, 1, 2, 26, 27, 28, /* Block #1 */ + 4, 5, 6, 30, 31, 32, /* Block #2 */ + 8, 9, 10, 34, 35, 36, /* Block #3 */ + 12, 13, 14, 38, 39, 40, /* Block #4 */ + 104, 105, 106, 130, 131, 132, /* Block #5 */ + 108, 109, 110, 134, 135, 136, /* Block #6 */ + 112, 113, 114, 138, 139, 140, /* Block #7 */ + 116, 117, 118, 142, 143, 144, /* Block #8 */ + 208, 209, 210, 234, 235, 236, /* Block #9 */ + 212, 213, 214, 238, 239, 240, /* Block #10 */ + 216, 217, 218, 242, 243, 244, /* Block #11 */ + 220, 221, 222, 246, 247, 248, /* Block #12 */ + }; + int i, j; /* Counters */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n")); @@ -1126,9 +1302,9 @@ test_select_hyper_stride(hid_t xfer_plist) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i=start[0] && i<(start[0]+count[0])) && - (j>=start[1] && j<(start[1]+count[1])) && - (k>=start[2] && k<(start[2]+count[2])) && - (l>=start[3] && l<(start[3]+count[3])) ) { - if(*tbuf!=*tbuf2) { + for (i = 0, tbuf = wbuf, tbuf2 = rbuf; i < SPACE8_DIM4; i++) + for (j = 0; j < SPACE8_DIM3; j++) + for (k = 0; k < SPACE8_DIM2; k++) + for (l = 0; l < SPACE8_DIM1; l++, tbuf++, tbuf2++) + if ((i >= start[0] && i < (start[0] + count[0])) && + (j >= start[1] && j < (start[1] + count[1])) && + (k >= start[2] && k < (start[2] + count[2])) && + (l >= start[3] && l < (start[3] + count[3]))) { + if (*tbuf != *tbuf2) { HDprintf("Error: hyperslab values don't match!\n"); - TestErrPrintf("Line: %d, i=%u, j=%u, k=%u, l=%u, *tbuf=%u,*tbuf2=%u\n",__LINE__,i,j,k,l,(unsigned)*tbuf,(unsigned)*tbuf2); + TestErrPrintf("Line: %d, i=%u, j=%u, k=%u, l=%u, *tbuf=%u,*tbuf2=%u\n", __LINE__, + i, j, k, l, (unsigned)*tbuf, (unsigned)*tbuf2); } /* end if */ - } /* end if */ + } /* end if */ else { - if(*tbuf2!=0) { + if (*tbuf2 != 0) { HDprintf("Error: invalid data in read buffer!\n"); - TestErrPrintf("Line: %d, i=%u, j=%u, k=%u, l=%u, *tbuf=%u,*tbuf2=%u\n",__LINE__,i,j,k,l,(unsigned)*tbuf,(unsigned)*tbuf2); + TestErrPrintf("Line: %d, i=%u, j=%u, k=%u, l=%u, *tbuf=%u,*tbuf2=%u\n", __LINE__, + i, j, k, l, (unsigned)*tbuf, (unsigned)*tbuf2); } /* end if */ - } /* end else */ + } /* end else */ /* Close memory dataspace */ ret = H5Sclose(sid2); @@ -1601,8 +1863,7 @@ test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist) /* Free memory buffers */ HDfree(wbuf); HDfree(rbuf); -} /* test_select_hyper_contig3() */ - +} /* test_select_hyper_contig3() */ /**************************************************************** ** @@ -1611,23 +1872,23 @@ test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist) ** ****************************************************************/ static void -verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf, - size_t H5_ATTR_NDEBUG_UNUSED cube_size, unsigned edge_size, unsigned cube_rank) +verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf, size_t H5_ATTR_NDEBUG_UNUSED cube_size, + unsigned edge_size, unsigned cube_rank) { - const uint16_t *cube_ptr; /* Pointer into the cube buffer */ - uint16_t expected_value; /* Expected value in dataset */ - unsigned i, j, k, l, m; /* Local index variables */ - size_t s; /* Local index variable */ - hbool_t mis_match; /* Flag to indicate mis-match in expected value */ + const uint16_t *cube_ptr; /* Pointer into the cube buffer */ + uint16_t expected_value; /* Expected value in dataset */ + unsigned i, j, k, l, m; /* Local index variables */ + size_t s; /* Local index variable */ + hbool_t mis_match; /* Flag to indicate mis-match in expected value */ HDassert(cube_buf); HDassert(cube_size > 0); expected_value = 0; - mis_match = FALSE; - cube_ptr = cube_buf; - s = 0; - i = 0; + mis_match = FALSE; + cube_ptr = cube_buf; + s = 0; + i = 0; do { j = 0; do { @@ -1641,7 +1902,7 @@ verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf, HDassert(s < cube_size); /* Check for correct value */ - if(*cube_ptr != expected_value) + if (*cube_ptr != expected_value) mis_match = TRUE; /* Advance to next element */ @@ -1649,19 +1910,18 @@ verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf, expected_value++; s++; m++; - } while((cube_rank > 0) && (m < edge_size)); + } while ((cube_rank > 0) && (m < edge_size)); l++; - } while((cube_rank > 1) && (l < edge_size)); + } while ((cube_rank > 1) && (l < edge_size)); k++; - } while((cube_rank > 2) && (k < edge_size)); + } while ((cube_rank > 2) && (k < edge_size)); j++; - } while((cube_rank > 3) && (j < edge_size)); + } while ((cube_rank > 3) && (j < edge_size)); i++; - } while((cube_rank > 4) && (i < edge_size)); - if(mis_match) + } while ((cube_rank > 4) && (i < edge_size)); + if (mis_match) TestErrPrintf("Initial cube data don't match! Line = %d\n", __LINE__); -} /* verify_select_hyper_contig_dr__run_test() */ - +} /* verify_select_hyper_contig_dr__run_test() */ /**************************************************************** ** @@ -1673,44 +1933,45 @@ verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf, ** ****************************************************************/ static void -test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, - const uint16_t *zero_buf, unsigned edge_size, unsigned chunk_edge_size, - unsigned small_rank, unsigned large_rank, hid_t dset_type, hid_t xfer_plist) +test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, const uint16_t *zero_buf, + unsigned edge_size, unsigned chunk_edge_size, unsigned small_rank, + unsigned large_rank, hid_t dset_type, hid_t xfer_plist) { - hbool_t mis_match; /* Flag indicating a value read in wasn't what was expected */ - hid_t fapl; /* File access property list */ - hid_t fid1; /* File ID */ - hid_t small_cube_sid; /* Dataspace ID for small cube in memory & file */ - hid_t mem_large_cube_sid; /* Dataspace ID for large cube in memory */ - hid_t file_large_cube_sid; /* Dataspace ID for large cube in file */ - hid_t small_cube_dcpl_id = H5P_DEFAULT; /* DCPL for small cube dataset */ - hid_t large_cube_dcpl_id = H5P_DEFAULT; /* DCPL for large cube dataset */ - hid_t small_cube_dataset; /* Dataset ID */ - hid_t large_cube_dataset; /* Dataset ID */ - size_t start_index; /* Offset within buffer to begin inspecting */ - size_t stop_index; /* Offset within buffer to end inspecting */ - uint16_t expected_value; /* Expected value in dataset */ - uint16_t * small_cube_buf_1; /* Buffer for small cube data */ - uint16_t * large_cube_buf_1; /* Buffer for large cube data */ - uint16_t * ptr_1; /* Temporary pointer into cube data */ - hsize_t dims[SS_DR_MAX_RANK]; /* Dataspace dimensions */ - hsize_t start[SS_DR_MAX_RANK]; /* Shared hyperslab start offset */ - hsize_t stride[SS_DR_MAX_RANK]; /* Shared hyperslab stride */ - hsize_t count[SS_DR_MAX_RANK]; /* Shared hyperslab count */ - hsize_t block[SS_DR_MAX_RANK]; /* Shared hyperslab block size */ - hsize_t * start_ptr; /* Actual hyperslab start offset */ - hsize_t * stride_ptr; /* Actual hyperslab stride */ - hsize_t * count_ptr; /* Actual hyperslab count */ - hsize_t * block_ptr; /* Actual hyperslab block size */ - size_t small_cube_size; /* Number of elements in small cube */ - size_t large_cube_size; /* Number of elements in large cube */ - unsigned u, v, w, x; /* Local index variables */ - size_t s; /* Local index variable */ - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hbool_t mis_match; /* Flag indicating a value read in wasn't what was expected */ + hid_t fapl; /* File access property list */ + hid_t fid1; /* File ID */ + hid_t small_cube_sid; /* Dataspace ID for small cube in memory & file */ + hid_t mem_large_cube_sid; /* Dataspace ID for large cube in memory */ + hid_t file_large_cube_sid; /* Dataspace ID for large cube in file */ + hid_t small_cube_dcpl_id = H5P_DEFAULT; /* DCPL for small cube dataset */ + hid_t large_cube_dcpl_id = H5P_DEFAULT; /* DCPL for large cube dataset */ + hid_t small_cube_dataset; /* Dataset ID */ + hid_t large_cube_dataset; /* Dataset ID */ + size_t start_index; /* Offset within buffer to begin inspecting */ + size_t stop_index; /* Offset within buffer to end inspecting */ + uint16_t expected_value; /* Expected value in dataset */ + uint16_t *small_cube_buf_1; /* Buffer for small cube data */ + uint16_t *large_cube_buf_1; /* Buffer for large cube data */ + uint16_t *ptr_1; /* Temporary pointer into cube data */ + hsize_t dims[SS_DR_MAX_RANK]; /* Dataspace dimensions */ + hsize_t start[SS_DR_MAX_RANK]; /* Shared hyperslab start offset */ + hsize_t stride[SS_DR_MAX_RANK]; /* Shared hyperslab stride */ + hsize_t count[SS_DR_MAX_RANK]; /* Shared hyperslab count */ + hsize_t block[SS_DR_MAX_RANK]; /* Shared hyperslab block size */ + hsize_t * start_ptr; /* Actual hyperslab start offset */ + hsize_t * stride_ptr; /* Actual hyperslab stride */ + hsize_t * count_ptr; /* Actual hyperslab count */ + hsize_t * block_ptr; /* Actual hyperslab block size */ + size_t small_cube_size; /* Number of elements in small cube */ + size_t large_cube_size; /* Number of elements in large cube */ + unsigned u, v, w, x; /* Local index variables */ + size_t s; /* Local index variable */ + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ MESSAGE(7, ("\tn-cube slice through m-cube I/O test %d.\n", test_num)); - MESSAGE(7, ("\tranks = %u/%u, edge_size = %u, chunk_edge_size = %u.\n", small_rank, large_rank, edge_size, chunk_edge_size)); + MESSAGE(7, ("\tranks = %u/%u, edge_size = %u, chunk_edge_size = %u.\n", small_rank, large_rank, edge_size, + chunk_edge_size)); HDassert(edge_size >= 6); HDassert(edge_size >= chunk_edge_size); @@ -1721,8 +1982,8 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, /* Compute cube sizes */ small_cube_size = large_cube_size = (size_t)1; - for(u = 0; u < large_rank; u++) { - if(u < small_rank) + for (u = 0; u < large_rank; u++) { + if (u < small_rank) small_cube_size *= (size_t)edge_size; large_cube_size *= (size_t)edge_size; @@ -1775,11 +2036,11 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, * large data set creation property lists to specify chunked * datasets. */ - if(chunk_edge_size > 0) { - hsize_t chunk_dims[SS_DR_MAX_RANK]; /* Chunk dimensions */ + if (chunk_edge_size > 0) { + hsize_t chunk_dims[SS_DR_MAX_RANK]; /* Chunk dimensions */ - chunk_dims[0] = chunk_dims[1] = - chunk_dims[2] = chunk_dims[3] = chunk_dims[4] = (hsize_t)chunk_edge_size; + chunk_dims[0] = chunk_dims[1] = chunk_dims[2] = chunk_dims[3] = chunk_dims[4] = + (hsize_t)chunk_edge_size; small_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE); CHECK(small_cube_dcpl_id, FAIL, "H5Pcreate"); @@ -1790,7 +2051,6 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, ret = H5Pset_chunk(small_cube_dcpl_id, (int)small_rank, chunk_dims); CHECK(ret, FAIL, "H5Pset_chunk"); - large_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE); CHECK(large_cube_dcpl_id, FAIL, "H5Pcreate"); @@ -1802,54 +2062,50 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, } /* end if */ /* create the small cube dataset */ - small_cube_dataset = H5Dcreate2(fid1, "small_cube_dataset", dset_type, - small_cube_sid, H5P_DEFAULT, small_cube_dcpl_id, H5P_DEFAULT); + small_cube_dataset = H5Dcreate2(fid1, "small_cube_dataset", dset_type, small_cube_sid, H5P_DEFAULT, + small_cube_dcpl_id, H5P_DEFAULT); CHECK(small_cube_dataset, FAIL, "H5Dcreate2"); /* Close non-default small dataset DCPL */ - if(small_cube_dcpl_id != H5P_DEFAULT) { + if (small_cube_dcpl_id != H5P_DEFAULT) { ret = H5Pclose(small_cube_dcpl_id); CHECK(ret, FAIL, "H5Pclose"); } /* end if */ /* create the large cube dataset */ - large_cube_dataset = H5Dcreate2(fid1, "large_cube_dataset", dset_type, - file_large_cube_sid, H5P_DEFAULT, large_cube_dcpl_id, H5P_DEFAULT); + large_cube_dataset = H5Dcreate2(fid1, "large_cube_dataset", dset_type, file_large_cube_sid, H5P_DEFAULT, + large_cube_dcpl_id, H5P_DEFAULT); CHECK(large_cube_dataset, FAIL, "H5Dcreate2"); /* Close non-default large dataset DCPL */ - if(large_cube_dcpl_id != H5P_DEFAULT) { + if (large_cube_dcpl_id != H5P_DEFAULT) { ret = H5Pclose(large_cube_dcpl_id); CHECK(ret, FAIL, "H5Pclose"); } /* end if */ - /* write initial data to the on disk datasets */ - ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, - small_cube_sid, xfer_plist, cube_buf); + ret = + H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, small_cube_sid, xfer_plist, cube_buf); CHECK(ret, FAIL, "H5Dwrite"); - ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, - file_large_cube_sid, xfer_plist, cube_buf); + ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, file_large_cube_sid, xfer_plist, + cube_buf); CHECK(ret, FAIL, "H5Dwrite"); /* read initial data from disk and verify that it is as expected. */ - ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, - small_cube_sid, xfer_plist, small_cube_buf_1); + ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, small_cube_sid, xfer_plist, + small_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); /* Check that the data is valid */ - verify_select_hyper_contig_dr__run_test(small_cube_buf_1, small_cube_size, - edge_size, small_rank); + verify_select_hyper_contig_dr__run_test(small_cube_buf_1, small_cube_size, edge_size, small_rank); - ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, - file_large_cube_sid, xfer_plist, large_cube_buf_1); + ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, file_large_cube_sid, xfer_plist, + large_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); /* Check that the data is valid */ - verify_select_hyper_contig_dr__run_test(large_cube_buf_1, large_cube_size, - edge_size, large_rank); - + verify_select_hyper_contig_dr__run_test(large_cube_buf_1, large_cube_size, edge_size, large_rank); /* first, verify that we can read from disk correctly using selections * of different rank that H5Sselect_shape_same() views as being of the @@ -1860,15 +2116,14 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, * returns true on the memory and file selections. */ - /* set up start, stride, count, and block -- note that we will * change start[] so as to read slices of the large cube. */ - for(u = 0; u < SS_DR_MAX_RANK; u++) { - start[u] = 0; + for (u = 0; u < SS_DR_MAX_RANK; u++) { + start[u] = 0; stride[u] = 1; - count[u] = 1; - if((SS_DR_MAX_RANK - u) > small_rank) + count[u] = 1; + if ((SS_DR_MAX_RANK - u) > small_rank) block[u] = 1; else block[u] = (hsize_t)edge_size; @@ -1892,12 +2147,8 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, start[3] = (hsize_t)x; start[4] = (hsize_t)0; - ret = H5Sselect_hyperslab(file_large_cube_sid, - H5S_SELECT_SET, - start_ptr, - stride_ptr, - count_ptr, - block_ptr); + ret = H5Sselect_hyperslab(file_large_cube_sid, H5S_SELECT_SET, start_ptr, stride_ptr, + count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* verify that H5Sselect_shape_same() reports the two @@ -1907,39 +2158,33 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Read selection from disk */ - ret = H5Dread(large_cube_dataset, - H5T_NATIVE_UINT16, - small_cube_sid, - file_large_cube_sid, - xfer_plist, - small_cube_buf_1); + ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, file_large_cube_sid, + xfer_plist, small_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); /* verify that expected data is retrieved */ - mis_match = FALSE; - ptr_1 = small_cube_buf_1; + mis_match = FALSE; + ptr_1 = small_cube_buf_1; expected_value = (uint16_t)((u * edge_size * edge_size * edge_size * edge_size) + - (v * edge_size * edge_size * edge_size) + - (w * edge_size * edge_size) + - (x * edge_size)); - for(s = 0; s < small_cube_size; s++ ) { - if(*ptr_1 != expected_value ) + (v * edge_size * edge_size * edge_size) + + (w * edge_size * edge_size) + (x * edge_size)); + for (s = 0; s < small_cube_size; s++) { + if (*ptr_1 != expected_value) mis_match = TRUE; ptr_1++; expected_value++; } /* end for */ - if(mis_match) - TestErrPrintf("small cube read from largecube has bad data! Line=%d\n",__LINE__); + if (mis_match) + TestErrPrintf("small cube read from largecube has bad data! Line=%d\n", __LINE__); x++; - } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size)); + } while ((large_rank >= 2) && (small_rank <= 1) && (x < edge_size)); w++; - } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size)); + } while ((large_rank >= 3) && (small_rank <= 2) && (w < edge_size)); v++; - } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size)); + } while ((large_rank >= 4) && (small_rank <= 3) && (v < edge_size)); u++; - } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size)); - + } while ((large_rank >= 5) && (small_rank <= 4) && (u < edge_size)); /* similarly, read the on disk small cube into slices through the in memory * large cube, and verify that the correct data (and only the correct data) @@ -1967,78 +2212,65 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, start[3] = (hsize_t)x; start[4] = (hsize_t)0; - ret = H5Sselect_hyperslab(mem_large_cube_sid, - H5S_SELECT_SET, - start_ptr, - stride_ptr, - count_ptr, - block_ptr); + ret = H5Sselect_hyperslab(mem_large_cube_sid, H5S_SELECT_SET, start_ptr, stride_ptr, + count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. */ check = H5Sselect_shape_same(small_cube_sid, mem_large_cube_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Read selection from disk */ - ret = H5Dread(small_cube_dataset, - H5T_NATIVE_UINT16, - mem_large_cube_sid, - small_cube_sid, - xfer_plist, - large_cube_buf_1); + ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, small_cube_sid, + xfer_plist, large_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); - /* verify that the expected data and only the * expected data was read. */ start_index = (u * edge_size * edge_size * edge_size * edge_size) + - (v * edge_size * edge_size * edge_size) + - (w * edge_size * edge_size) + + (v * edge_size * edge_size * edge_size) + (w * edge_size * edge_size) + (x * edge_size); stop_index = start_index + small_cube_size - 1; HDassert(start_index < stop_index); HDassert(stop_index <= large_cube_size); - mis_match = FALSE; - ptr_1 = large_cube_buf_1; + mis_match = FALSE; + ptr_1 = large_cube_buf_1; expected_value = 0; - for(s = 0; s < start_index; s++) { - if(*ptr_1 != 0) + for (s = 0; s < start_index; s++) { + if (*ptr_1 != 0) mis_match = TRUE; ptr_1++; } /* end for */ - for(; s <= stop_index; s++) { - if(*ptr_1 != expected_value) + for (; s <= stop_index; s++) { + if (*ptr_1 != expected_value) mis_match = TRUE; expected_value++; ptr_1++; } /* end for */ - for(; s < large_cube_size; s++) { - if(*ptr_1 != 0) + for (; s < large_cube_size; s++) { + if (*ptr_1 != 0) mis_match = TRUE; ptr_1++; } /* end for */ - if(mis_match) + if (mis_match) TestErrPrintf("large cube read from small cube has bad data! Line=%u\n", __LINE__); /* Zero out the buffer for the next pass */ HDmemset(large_cube_buf_1 + start_index, 0, small_cube_size * sizeof(uint16_t)); x++; - } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size)); + } while ((large_rank >= 2) && (small_rank <= 1) && (x < edge_size)); w++; - } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size)); + } while ((large_rank >= 3) && (small_rank <= 2) && (w < edge_size)); v++; - } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size)); + } while ((large_rank >= 4) && (small_rank <= 3) && (v < edge_size)); u++; - } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size)); - + } while ((large_rank >= 5) && (small_rank <= 4) && (u < edge_size)); /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that @@ -2065,12 +2297,8 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, */ /* zero out the on disk small cube */ - ret = H5Dwrite(small_cube_dataset, - H5T_NATIVE_UINT16, - small_cube_sid, - small_cube_sid, - xfer_plist, - zero_buf); + ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, small_cube_sid, + xfer_plist, zero_buf); CHECK(ret, FAIL, "H5Dwrite"); /* select the portion of the in memory large cube from which we @@ -2082,15 +2310,10 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, start[3] = (hsize_t)x; start[4] = (hsize_t)0; - ret = H5Sselect_hyperslab(mem_large_cube_sid, - H5S_SELECT_SET, - start_ptr, - stride_ptr, - count_ptr, - block_ptr); + ret = H5Sselect_hyperslab(mem_large_cube_sid, H5S_SELECT_SET, start_ptr, stride_ptr, + count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* verify that H5Sselect_shape_same() reports the in * memory slice through the cube selection and the * on disk full small cube selections as having the same shape. @@ -2098,52 +2321,39 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, check = H5Sselect_shape_same(small_cube_sid, mem_large_cube_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); - - /* write the slice from the in memory large cube to the on disk small cube */ - ret = H5Dwrite(small_cube_dataset, - H5T_NATIVE_UINT16, - mem_large_cube_sid, - small_cube_sid, - xfer_plist, - cube_buf); + /* write the slice from the in memory large cube to the on disk small cube */ + ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, small_cube_sid, + xfer_plist, cube_buf); CHECK(ret, FAIL, "H5Dwrite"); - /* read the on disk small cube into memory */ - ret = H5Dread(small_cube_dataset, - H5T_NATIVE_UINT16, - small_cube_sid, - small_cube_sid, - xfer_plist, - small_cube_buf_1); + ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, small_cube_sid, + xfer_plist, small_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); - /* verify that expected data is retrieved */ - mis_match = FALSE; - ptr_1 = small_cube_buf_1; + mis_match = FALSE; + ptr_1 = small_cube_buf_1; expected_value = (uint16_t)((u * edge_size * edge_size * edge_size * edge_size) + - (v * edge_size * edge_size * edge_size) + - (w * edge_size * edge_size) + - (x * edge_size)); - for(s = 0; s < small_cube_size; s++) { - if(*ptr_1 != expected_value) + (v * edge_size * edge_size * edge_size) + + (w * edge_size * edge_size) + (x * edge_size)); + for (s = 0; s < small_cube_size; s++) { + if (*ptr_1 != expected_value) mis_match = TRUE; expected_value++; ptr_1++; } /* end for */ - if(mis_match ) - TestErrPrintf("small cube data don't match! Line=%d\n",__LINE__); + if (mis_match) + TestErrPrintf("small cube data don't match! Line=%d\n", __LINE__); x++; - } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size)); + } while ((large_rank >= 2) && (small_rank <= 1) && (x < edge_size)); w++; - } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size)); + } while ((large_rank >= 3) && (small_rank <= 2) && (w < edge_size)); v++; - } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size)); + } while ((large_rank >= 4) && (small_rank <= 3) && (v < edge_size)); u++; - } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size)); - + } while ((large_rank >= 5) && (small_rank <= 4) && (u < edge_size)); /* Now write the contents of the in memory small cube to slices of * the on disk cube. After each write, read the on disk cube @@ -2173,15 +2383,10 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, */ /* zero out the on disk cube */ - ret = H5Dwrite(large_cube_dataset, - H5T_NATIVE_USHORT, - mem_large_cube_sid, - file_large_cube_sid, - xfer_plist, - zero_buf); + ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_USHORT, mem_large_cube_sid, + file_large_cube_sid, xfer_plist, zero_buf); CHECK(ret, FAIL, "H5Dwrite"); - /* select the portion of the in memory large cube to which we * are going to write data. */ @@ -2191,15 +2396,10 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, start[3] = (hsize_t)x; start[4] = (hsize_t)0; - ret = H5Sselect_hyperslab(file_large_cube_sid, - H5S_SELECT_SET, - start_ptr, - stride_ptr, - count_ptr, - block_ptr); + ret = H5Sselect_hyperslab(file_large_cube_sid, H5S_SELECT_SET, start_ptr, stride_ptr, + count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* verify that H5Sselect_shape_same() reports the in * memory full selection of the small cube and the * on disk slice through the large cube selection @@ -2208,72 +2408,60 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, check = H5Sselect_shape_same(small_cube_sid, file_large_cube_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); - - /* write the cube from memory to the target slice of the disk cube */ - ret = H5Dwrite(large_cube_dataset, - H5T_NATIVE_UINT16, - small_cube_sid, - file_large_cube_sid, - xfer_plist, - cube_buf); + /* write the cube from memory to the target slice of the disk cube */ + ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, file_large_cube_sid, + xfer_plist, cube_buf); CHECK(ret, FAIL, "H5Dwrite"); - /* read the on disk cube into memory */ ret = H5Sselect_all(file_large_cube_sid); CHECK(ret, FAIL, "H5Sselect_all"); - ret = H5Dread(large_cube_dataset, - H5T_NATIVE_UINT16, - mem_large_cube_sid, - file_large_cube_sid, - xfer_plist, - large_cube_buf_1); + ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, + file_large_cube_sid, xfer_plist, large_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); - /* verify that the expected data and only the * expected data was read. */ start_index = (u * edge_size * edge_size * edge_size * edge_size) + - (v * edge_size * edge_size * edge_size) + - (w * edge_size * edge_size) + + (v * edge_size * edge_size * edge_size) + (w * edge_size * edge_size) + (x * edge_size); stop_index = start_index + small_cube_size - 1; HDassert(start_index < stop_index); HDassert(stop_index <= large_cube_size); - mis_match = FALSE; - ptr_1 = large_cube_buf_1; + mis_match = FALSE; + ptr_1 = large_cube_buf_1; expected_value = 0; - for(s = 0; s < start_index; s++) { - if(*ptr_1 != 0) + for (s = 0; s < start_index; s++) { + if (*ptr_1 != 0) mis_match = TRUE; ptr_1++; } /* end for */ - for(; s <= stop_index; s++) { - if(*ptr_1 != expected_value) + for (; s <= stop_index; s++) { + if (*ptr_1 != expected_value) mis_match = TRUE; expected_value++; ptr_1++; } /* end for */ - for(; s < large_cube_size; s++) { - if(*ptr_1 != 0) + for (; s < large_cube_size; s++) { + if (*ptr_1 != 0) mis_match = TRUE; ptr_1++; } /* end for */ - if(mis_match) + if (mis_match) TestErrPrintf("large cube written from small cube has bad data! Line=%d\n", __LINE__); x++; - } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size)); + } while ((large_rank >= 2) && (small_rank <= 1) && (x < edge_size)); w++; - } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size)); + } while ((large_rank >= 3) && (small_rank <= 2) && (w < edge_size)); v++; - } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size)); + } while ((large_rank >= 4) && (small_rank <= 3) && (v < edge_size)); u++; - } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size)); + } while ((large_rank >= 5) && (small_rank <= 4) && (u < edge_size)); /* Close memory dataspaces */ ret = H5Sclose(small_cube_sid); @@ -2282,12 +2470,10 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, ret = H5Sclose(mem_large_cube_sid); CHECK(ret, FAIL, "H5Sclose"); - /* Close disk dataspace */ ret = H5Sclose(file_large_cube_sid); CHECK(ret, FAIL, "H5Sclose"); - /* Close Datasets */ ret = H5Dclose(small_cube_dataset); CHECK(ret, FAIL, "H5Dclose"); @@ -2303,8 +2489,7 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, HDfree(small_cube_buf_1); HDfree(large_cube_buf_1); -} /* test_select_hyper_contig_dr__run_test() */ - +} /* test_select_hyper_contig_dr__run_test() */ /**************************************************************** ** @@ -2318,25 +2503,25 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, static void test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist) { - int test_num = 0; - unsigned chunk_edge_size; /* Size of chunk's dataspace dimensions */ - unsigned edge_size = 6; /* Size of dataset's dataspace dimensions */ - unsigned small_rank; /* Current rank of small dataset */ - unsigned large_rank; /* Current rank of large dataset */ - uint16_t *cube_buf; /* Buffer for writing cube data */ - uint16_t *zero_buf; /* Buffer for writing zeroed cube data */ - uint16_t *cube_ptr; /* Temporary pointer into cube data */ - unsigned max_rank = 5; /* Max. rank to use */ - size_t max_cube_size; /* Max. number of elements in largest cube */ - size_t s; /* Local index variable */ - unsigned u; /* Local index variable */ + int test_num = 0; + unsigned chunk_edge_size; /* Size of chunk's dataspace dimensions */ + unsigned edge_size = 6; /* Size of dataset's dataspace dimensions */ + unsigned small_rank; /* Current rank of small dataset */ + unsigned large_rank; /* Current rank of large dataset */ + uint16_t *cube_buf; /* Buffer for writing cube data */ + uint16_t *zero_buf; /* Buffer for writing zeroed cube data */ + uint16_t *cube_ptr; /* Temporary pointer into cube data */ + unsigned max_rank = 5; /* Max. rank to use */ + size_t max_cube_size; /* Max. number of elements in largest cube */ + size_t s; /* Local index variable */ + unsigned u; /* Local index variable */ /* Output message about test being performed */ MESSAGE(5, ("Testing Contiguous Hyperslabs With Different Rank I/O Functionality\n")); /* Compute max. cube size */ max_cube_size = (size_t)1; - for(u = 0; u < max_rank; u++) + for (u = 0; u < max_rank; u++) max_cube_size *= (size_t)edge_size; /* Allocate cube buffer for writing values */ @@ -2345,34 +2530,31 @@ test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist) /* Initialize the cube buffer */ cube_ptr = cube_buf; - for(s = 0; s < max_cube_size; s++) + for (s = 0; s < max_cube_size; s++) *cube_ptr++ = (uint16_t)s; /* Allocate cube buffer for zeroing values on disk */ zero_buf = (uint16_t *)HDcalloc(sizeof(uint16_t), max_cube_size); CHECK_PTR(zero_buf, "HDcalloc"); - for(large_rank = 1; large_rank <= max_rank; large_rank++) { - for(small_rank = 1; small_rank < large_rank; small_rank++) { + for (large_rank = 1; large_rank <= max_rank; large_rank++) { + for (small_rank = 1; small_rank < large_rank; small_rank++) { chunk_edge_size = 0; - test_select_hyper_contig_dr__run_test(test_num, cube_buf, zero_buf, - edge_size, chunk_edge_size, small_rank, large_rank, - dset_type, xfer_plist); + test_select_hyper_contig_dr__run_test(test_num, cube_buf, zero_buf, edge_size, chunk_edge_size, + small_rank, large_rank, dset_type, xfer_plist); test_num++; chunk_edge_size = 3; - test_select_hyper_contig_dr__run_test(test_num, cube_buf, zero_buf, - edge_size, chunk_edge_size, small_rank, large_rank, - dset_type, xfer_plist); + test_select_hyper_contig_dr__run_test(test_num, cube_buf, zero_buf, edge_size, chunk_edge_size, + small_rank, large_rank, dset_type, xfer_plist); test_num++; } /* for loop on small rank */ - } /* for loop on large rank */ + } /* for loop on large rank */ HDfree(cube_buf); HDfree(zero_buf); -} /* test_select_hyper_contig_dr() */ - +} /* test_select_hyper_contig_dr() */ /**************************************************************** ** @@ -2395,22 +2577,22 @@ test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist) ** ****************************************************************/ static void -test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, - unsigned tgt_n_cube_rank, unsigned edge_size, unsigned checker_edge_size, - unsigned sel_rank, hsize_t sel_start[]) +test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, unsigned tgt_n_cube_rank, + unsigned edge_size, unsigned checker_edge_size, + unsigned sel_rank, hsize_t sel_start[]) { - hbool_t first_selection = TRUE; - unsigned n_cube_offset; - unsigned sel_offset; - hsize_t base_count; - hsize_t offset_count; - hsize_t start[SS_DR_MAX_RANK]; /* Offset of hyperslab selection */ - hsize_t stride[SS_DR_MAX_RANK]; /* Stride of hyperslab selection */ - hsize_t count[SS_DR_MAX_RANK]; /* Count of hyperslab selection */ - hsize_t block[SS_DR_MAX_RANK]; /* Block size of hyperslab selection */ - unsigned i, j, k, l, m; /* Local index variable */ - unsigned u; /* Local index variables */ - herr_t ret; /* Generic return value */ + hbool_t first_selection = TRUE; + unsigned n_cube_offset; + unsigned sel_offset; + hsize_t base_count; + hsize_t offset_count; + hsize_t start[SS_DR_MAX_RANK]; /* Offset of hyperslab selection */ + hsize_t stride[SS_DR_MAX_RANK]; /* Stride of hyperslab selection */ + hsize_t count[SS_DR_MAX_RANK]; /* Count of hyperslab selection */ + hsize_t block[SS_DR_MAX_RANK]; /* Block size of hyperslab selection */ + unsigned i, j, k, l, m; /* Local index variable */ + unsigned u; /* Local index variables */ + herr_t ret; /* Generic return value */ HDassert(edge_size >= 6); HDassert(0 < checker_edge_size); @@ -2419,7 +2601,7 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, HDassert(sel_rank <= tgt_n_cube_rank); HDassert(tgt_n_cube_rank <= SS_DR_MAX_RANK); - sel_offset = SS_DR_MAX_RANK - sel_rank; + sel_offset = SS_DR_MAX_RANK - sel_rank; n_cube_offset = SS_DR_MAX_RANK - tgt_n_cube_rank; HDassert(n_cube_offset <= sel_offset); @@ -2429,11 +2611,11 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, * offset). */ base_count = edge_size / (checker_edge_size * 2); - if((edge_size % (checker_edge_size * 2)) > 0) + if ((edge_size % (checker_edge_size * 2)) > 0) base_count++; offset_count = (edge_size - checker_edge_size) / (checker_edge_size * 2); - if(((edge_size - checker_edge_size) % (checker_edge_size * 2)) > 0) + if (((edge_size - checker_edge_size) % (checker_edge_size * 2)) > 0) offset_count++; /* Now set up the stride and block arrays, and portions of the start @@ -2441,36 +2623,36 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, * the checker board. */ u = 0; - while(u < n_cube_offset) { + while (u < n_cube_offset) { /* these values should never be used */ - start[u] = 0; + start[u] = 0; stride[u] = 0; - count[u] = 0; - block[u] = 0; + count[u] = 0; + block[u] = 0; u++; } /* end while */ - while(u < sel_offset) { - start[u] = sel_start[u]; + while (u < sel_offset) { + start[u] = sel_start[u]; stride[u] = 2 * edge_size; - count[u] = 1; - block[u] = 1; + count[u] = 1; + block[u] = 1; u++; } /* end while */ - while(u < SS_DR_MAX_RANK) { + while (u < SS_DR_MAX_RANK) { stride[u] = 2 * checker_edge_size; - block[u] = checker_edge_size; + block[u] = checker_edge_size; u++; } /* end while */ i = 0; do { - if(0 >= sel_offset) { - if(i == 0) { + if (0 >= sel_offset) { + if (i == 0) { start[0] = 0; count[0] = base_count; } /* end if */ @@ -2478,12 +2660,12 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, start[0] = checker_edge_size; count[0] = offset_count; } /* end else */ - } /* end if */ + } /* end if */ j = 0; do { - if(1 >= sel_offset) { - if(j == 0 ) { + if (1 >= sel_offset) { + if (j == 0) { start[1] = 0; count[1] = base_count; } /* end if */ @@ -2491,12 +2673,12 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, start[1] = checker_edge_size; count[1] = offset_count; } /* end else */ - } /* end if */ + } /* end if */ k = 0; do { - if(2 >= sel_offset) { - if(k == 0) { + if (2 >= sel_offset) { + if (k == 0) { start[2] = 0; count[2] = base_count; } /* end if */ @@ -2504,12 +2686,12 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, start[2] = checker_edge_size; count[2] = offset_count; } /* end else */ - } /* end if */ + } /* end if */ l = 0; do { - if(3 >= sel_offset) { - if(l == 0) { + if (3 >= sel_offset) { + if (l == 0) { start[3] = 0; count[3] = base_count; } /* end if */ @@ -2517,12 +2699,12 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, start[3] = checker_edge_size; count[3] = offset_count; } /* end else */ - } /* end if */ + } /* end if */ m = 0; do { - if(4 >= sel_offset) { - if(m == 0) { + if (4 >= sel_offset) { + if (m == 0) { start[4] = 0; count[4] = base_count; } /* end if */ @@ -2530,41 +2712,35 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, start[4] = checker_edge_size; count[4] = offset_count; } /* end else */ - } /* end if */ + } /* end if */ - if(((i + j + k + l + m) % 2) == 0) { - if(first_selection) { + if (((i + j + k + l + m) % 2) == 0) { + if (first_selection) { first_selection = FALSE; - ret = H5Sselect_hyperslab(tgt_n_cube_sid, - H5S_SELECT_SET, - &(start[n_cube_offset]), - &(stride[n_cube_offset]), - &(count[n_cube_offset]), - &(block[n_cube_offset])); + ret = H5Sselect_hyperslab(tgt_n_cube_sid, H5S_SELECT_SET, + &(start[n_cube_offset]), &(stride[n_cube_offset]), + &(count[n_cube_offset]), &(block[n_cube_offset])); CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end if */ else { - ret = H5Sselect_hyperslab(tgt_n_cube_sid, - H5S_SELECT_OR, - &(start[n_cube_offset]), - &(stride[n_cube_offset]), - &(count[n_cube_offset]), - &(block[n_cube_offset])); + ret = H5Sselect_hyperslab(tgt_n_cube_sid, H5S_SELECT_OR, + &(start[n_cube_offset]), &(stride[n_cube_offset]), + &(count[n_cube_offset]), &(block[n_cube_offset])); CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end else */ - } /* end if */ + } /* end if */ m++; - } while((m <= 1) && (4 >= sel_offset)); + } while ((m <= 1) && (4 >= sel_offset)); l++; - } while((l <= 1) && (3 >= sel_offset)); + } while ((l <= 1) && (3 >= sel_offset)); k++; - } while((k <= 1) && (2 >= sel_offset)); + } while ((k <= 1) && (2 >= sel_offset)); j++; - } while((j <= 1) && (1 >= sel_offset)); + } while ((j <= 1) && (1 >= sel_offset)); i++; - } while((i <= 1) && (0 >= sel_offset)); + } while ((i <= 1) && (0 >= sel_offset)); /* Wierdness alert: * @@ -2573,7 +2749,7 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, * code to manually clip the selection back to the dataspace * proper. */ - for(u = 0; u < SS_DR_MAX_RANK; u++) { + for (u = 0; u < SS_DR_MAX_RANK; u++) { start[u] = 0; stride[u] = edge_size; count[u] = 1; @@ -2584,7 +2760,6 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* test_select_hyper_checker_board_dr__select_checker_board() */ - /**************************************************************** ** ** test_select_hyper_checker_board_dr__verify_data(): @@ -2628,18 +2803,18 @@ test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid, ** ****************************************************************/ H5_ATTR_PURE static hbool_t -test_select_hyper_checker_board_dr__verify_data(uint16_t * buf_ptr, - unsigned rank, unsigned edge_size, unsigned checker_edge_size, - uint16_t first_expected_val, hbool_t buf_starts_in_checker) +test_select_hyper_checker_board_dr__verify_data(uint16_t *buf_ptr, unsigned rank, unsigned edge_size, + unsigned checker_edge_size, uint16_t first_expected_val, + hbool_t buf_starts_in_checker) { - hbool_t good_data = TRUE; - hbool_t in_checker; - hbool_t start_in_checker[5]; - uint16_t expected_value; - uint16_t * val_ptr; - unsigned i, j, k, l, m; /* to track position in n-cube */ - unsigned v, w, x, y, z; /* to track position in checker */ - const unsigned test_max_rank = 5; /* code changes needed if this is increased */ + hbool_t good_data = TRUE; + hbool_t in_checker; + hbool_t start_in_checker[5]; + uint16_t expected_value; + uint16_t * val_ptr; + unsigned i, j, k, l, m; /* to track position in n-cube */ + unsigned v, w, x, y, z; /* to track position in checker */ + const unsigned test_max_rank = 5; /* code changes needed if this is increased */ HDassert(buf_ptr != NULL); HDassert(0 < rank); @@ -2649,60 +2824,60 @@ test_select_hyper_checker_board_dr__verify_data(uint16_t * buf_ptr, HDassert(checker_edge_size <= edge_size); HDassert(test_max_rank <= SS_DR_MAX_RANK); - val_ptr = buf_ptr; + val_ptr = buf_ptr; expected_value = first_expected_val; - i = 0; - v = 0; + i = 0; + v = 0; start_in_checker[0] = buf_starts_in_checker; do { - if(v >= checker_edge_size) { + if (v >= checker_edge_size) { start_in_checker[0] = !start_in_checker[0]; - v = 0; + v = 0; } /* end if */ - j = 0; - w = 0; + j = 0; + w = 0; start_in_checker[1] = start_in_checker[0]; do { - if(w >= checker_edge_size) { + if (w >= checker_edge_size) { start_in_checker[1] = !start_in_checker[1]; - w = 0; + w = 0; } /* end if */ - k = 0; - x = 0; + k = 0; + x = 0; start_in_checker[2] = start_in_checker[1]; do { - if(x >= checker_edge_size) { + if (x >= checker_edge_size) { start_in_checker[2] = !start_in_checker[2]; - x = 0; + x = 0; } /* end if */ - l = 0; - y = 0; + l = 0; + y = 0; start_in_checker[3] = start_in_checker[2]; do { - if(y >= checker_edge_size) { - start_in_checker[3] = ! start_in_checker[3]; - y = 0; + if (y >= checker_edge_size) { + start_in_checker[3] = !start_in_checker[3]; + y = 0; } /* end if */ - m = 0; - z = 0; + m = 0; + z = 0; in_checker = start_in_checker[3]; do { - if(z >= checker_edge_size) { - in_checker = ! in_checker; - z = 0; + if (z >= checker_edge_size) { + in_checker = !in_checker; + z = 0; } /* end if */ - if(in_checker) { - if(*val_ptr != expected_value) + if (in_checker) { + if (*val_ptr != expected_value) good_data = FALSE; } /* end if */ else { - if(*val_ptr != 0) + if (*val_ptr != 0) good_data = FALSE; } /* end else */ @@ -2711,24 +2886,23 @@ test_select_hyper_checker_board_dr__verify_data(uint16_t * buf_ptr, m++; z++; - } while((rank >= (test_max_rank - 4)) && (m < edge_size)); + } while ((rank >= (test_max_rank - 4)) && (m < edge_size)); l++; y++; - } while((rank >= (test_max_rank - 3)) && (l < edge_size)); + } while ((rank >= (test_max_rank - 3)) && (l < edge_size)); k++; x++; - } while((rank >= (test_max_rank - 2)) && (k < edge_size)); + } while ((rank >= (test_max_rank - 2)) && (k < edge_size)); j++; w++; - } while((rank >= (test_max_rank - 1)) && (j < edge_size)); + } while ((rank >= (test_max_rank - 1)) && (j < edge_size)); i++; v++; - } while((rank >= test_max_rank) && (i < edge_size)); + } while ((rank >= test_max_rank) && (i < edge_size)); - return(good_data); + return (good_data); } /* test_select_hyper_checker_board_dr__verify_data() */ - /**************************************************************** ** ** test_select_hyper_checker_board_dr__run_test(): Test H5S @@ -2739,44 +2913,45 @@ test_select_hyper_checker_board_dr__verify_data(uint16_t * buf_ptr, ** ****************************************************************/ static void -test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_buf, - const uint16_t *zero_buf, unsigned edge_size, unsigned checker_edge_size, - unsigned chunk_edge_size, unsigned small_rank, unsigned large_rank, - hid_t dset_type, hid_t xfer_plist) +test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_buf, const uint16_t *zero_buf, + unsigned edge_size, unsigned checker_edge_size, + unsigned chunk_edge_size, unsigned small_rank, + unsigned large_rank, hid_t dset_type, hid_t xfer_plist) { hbool_t data_ok; - hid_t fapl; /* File access property list */ - hid_t fid; /* HDF5 File IDs */ - hid_t full_small_cube_sid; /* Dataspace for small cube w/all selection */ - hid_t mem_small_cube_sid; - hid_t file_small_cube_sid; - hid_t full_large_cube_sid; /* Dataspace for large cube w/all selection */ - hid_t mem_large_cube_sid; - hid_t file_large_cube_sid; - hid_t small_cube_dcpl_id = H5P_DEFAULT; /* DCPL for small cube dataset */ - hid_t large_cube_dcpl_id = H5P_DEFAULT; /* DCPL for large cube dataset */ - hid_t small_cube_dataset; /* Dataset ID */ - hid_t large_cube_dataset; /* Dataset ID */ - unsigned small_rank_offset; /* Rank offset of slice */ - const unsigned test_max_rank = 5; /* must update code if this changes */ - size_t start_index; /* Offset within buffer to begin inspecting */ - size_t stop_index; /* Offset within buffer to end inspecting */ - uint16_t expected_value; - uint16_t * small_cube_buf_1; - uint16_t * large_cube_buf_1; - uint16_t * ptr_1; - size_t small_cube_size; /* Number of elements in small cube */ - size_t large_cube_size; /* Number of elements in large cube */ + hid_t fapl; /* File access property list */ + hid_t fid; /* HDF5 File IDs */ + hid_t full_small_cube_sid; /* Dataspace for small cube w/all selection */ + hid_t mem_small_cube_sid; + hid_t file_small_cube_sid; + hid_t full_large_cube_sid; /* Dataspace for large cube w/all selection */ + hid_t mem_large_cube_sid; + hid_t file_large_cube_sid; + hid_t small_cube_dcpl_id = H5P_DEFAULT; /* DCPL for small cube dataset */ + hid_t large_cube_dcpl_id = H5P_DEFAULT; /* DCPL for large cube dataset */ + hid_t small_cube_dataset; /* Dataset ID */ + hid_t large_cube_dataset; /* Dataset ID */ + unsigned small_rank_offset; /* Rank offset of slice */ + const unsigned test_max_rank = 5; /* must update code if this changes */ + size_t start_index; /* Offset within buffer to begin inspecting */ + size_t stop_index; /* Offset within buffer to end inspecting */ + uint16_t expected_value; + uint16_t * small_cube_buf_1; + uint16_t * large_cube_buf_1; + uint16_t * ptr_1; + size_t small_cube_size; /* Number of elements in small cube */ + size_t large_cube_size; /* Number of elements in large cube */ hsize_t dims[SS_DR_MAX_RANK]; hsize_t chunk_dims[SS_DR_MAX_RANK]; - hsize_t sel_start[SS_DR_MAX_RANK]; - unsigned u, v, w, x; /* Local index variables */ - size_t s; /* Local index variable */ - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hsize_t sel_start[SS_DR_MAX_RANK]; + unsigned u, v, w, x; /* Local index variables */ + size_t s; /* Local index variable */ + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ MESSAGE(7, ("\tn-cube slice through m-cube I/O test %d.\n", test_num)); - MESSAGE(7, ("\tranks = %d/%d, edge_size = %d, checker_edge_size = %d, chunk_edge_size = %d.\n", small_rank, large_rank, edge_size, checker_edge_size, chunk_edge_size)); + MESSAGE(7, ("\tranks = %d/%d, edge_size = %d, checker_edge_size = %d, chunk_edge_size = %d.\n", + small_rank, large_rank, edge_size, checker_edge_size, chunk_edge_size)); HDassert(edge_size >= 6); HDassert(checker_edge_size > 0); @@ -2790,8 +2965,8 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* Compute cube sizes */ small_cube_size = large_cube_size = (size_t)1; - for(u = 0; u < large_rank; u++) { - if(u < small_rank) + for (u = 0; u < large_rank; u++) { + if (u < small_rank) small_cube_size *= (size_t)edge_size; large_cube_size *= (size_t)edge_size; @@ -2807,14 +2982,12 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ */ HDassert(large_cube_size < (size_t)(64 * 1024)); - /* Allocate & initialize buffers */ small_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), small_cube_size); CHECK_PTR(small_cube_buf_1, "HDcalloc"); large_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), large_cube_size); CHECK_PTR(large_cube_buf_1, "HDcalloc"); - /* Create a dataset transfer property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(fapl, FAIL, "H5Pcreate"); @@ -2831,11 +3004,9 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); - /* setup dims: */ dims[0] = dims[1] = dims[2] = dims[3] = dims[4] = edge_size; - /* Create small cube dataspaces */ full_small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL); CHECK(full_small_cube_sid, FAIL, "H5Screate_simple"); @@ -2846,7 +3017,6 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ file_small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL); CHECK(file_small_cube_sid, FAIL, "H5Screate_simple"); - /* Create large cube dataspace */ full_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL); CHECK(full_large_cube_sid, FAIL, "H5Screate_simple"); @@ -2857,14 +3027,12 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ file_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL); CHECK(file_large_cube_sid, FAIL, "H5Screate_simple"); - /* if chunk edge size is greater than zero, set up the small and * large data set creation property lists to specify chunked * datasets. */ - if(chunk_edge_size > 0) { - chunk_dims[0] = chunk_dims[1] = - chunk_dims[2] = chunk_dims[3] = chunk_dims[4] = chunk_edge_size; + if (chunk_edge_size > 0) { + chunk_dims[0] = chunk_dims[1] = chunk_dims[2] = chunk_dims[3] = chunk_dims[4] = chunk_edge_size; small_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE); CHECK(small_cube_dcpl_id, FAIL, "H5Pcreate"); @@ -2875,7 +3043,6 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ ret = H5Pset_chunk(small_cube_dcpl_id, (int)small_rank, chunk_dims); CHECK(ret, FAIL, "H5Pset_chunk"); - large_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE); CHECK(large_cube_dcpl_id, FAIL, "H5Pcreate"); @@ -2886,58 +3053,52 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ CHECK(ret, FAIL, "H5Pset_chunk"); } /* end if */ - /* create the small cube dataset */ - small_cube_dataset = H5Dcreate2(fid, "small_cube_dataset", dset_type, - file_small_cube_sid, H5P_DEFAULT, small_cube_dcpl_id, H5P_DEFAULT); + small_cube_dataset = H5Dcreate2(fid, "small_cube_dataset", dset_type, file_small_cube_sid, H5P_DEFAULT, + small_cube_dcpl_id, H5P_DEFAULT); CHECK(small_cube_dataset, FAIL, "H5Dcreate2"); /* Close non-default small dataset DCPL */ - if(small_cube_dcpl_id != H5P_DEFAULT) { + if (small_cube_dcpl_id != H5P_DEFAULT) { ret = H5Pclose(small_cube_dcpl_id); CHECK(ret, FAIL, "H5Pclose"); } /* end if */ /* create the large cube dataset */ - large_cube_dataset = H5Dcreate2(fid, "large_cube_dataset", dset_type, - file_large_cube_sid, H5P_DEFAULT, large_cube_dcpl_id, H5P_DEFAULT); + large_cube_dataset = H5Dcreate2(fid, "large_cube_dataset", dset_type, file_large_cube_sid, H5P_DEFAULT, + large_cube_dcpl_id, H5P_DEFAULT); CHECK(large_cube_dataset, FAIL, "H5Dcreate2"); /* Close non-default large dataset DCPL */ - if(large_cube_dcpl_id != H5P_DEFAULT) { + if (large_cube_dcpl_id != H5P_DEFAULT) { ret = H5Pclose(large_cube_dcpl_id); CHECK(ret, FAIL, "H5Pclose"); } /* end if */ - /* write initial data to the on disk datasets */ - ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid, - full_small_cube_sid, xfer_plist, cube_buf); + ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid, full_small_cube_sid, + xfer_plist, cube_buf); CHECK(ret, FAIL, "H5Dwrite"); - ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid, - full_large_cube_sid, xfer_plist, cube_buf); + ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid, full_large_cube_sid, + xfer_plist, cube_buf); CHECK(ret, FAIL, "H5Dwrite"); - /* read initial small cube data from disk and verify that it is as expected. */ - ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid, - full_small_cube_sid, xfer_plist, small_cube_buf_1); + ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid, full_small_cube_sid, xfer_plist, + small_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); /* Check that the data is valid */ - verify_select_hyper_contig_dr__run_test(small_cube_buf_1, small_cube_size, - edge_size, small_rank); + verify_select_hyper_contig_dr__run_test(small_cube_buf_1, small_cube_size, edge_size, small_rank); /* read initial large cube data from disk and verify that it is as expected. */ - ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid, - full_large_cube_sid, xfer_plist, large_cube_buf_1); + ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid, full_large_cube_sid, xfer_plist, + large_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); /* Check that the data is valid */ - verify_select_hyper_contig_dr__run_test(large_cube_buf_1, large_cube_size, - edge_size, large_rank); - + verify_select_hyper_contig_dr__run_test(large_cube_buf_1, large_cube_size, edge_size, large_rank); /* first, verify that we can read from disk correctly using selections * of different rank that H5Sselect_shape_same() views as being of the @@ -2953,12 +3114,8 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0; - test_select_hyper_checker_board_dr__select_checker_board(mem_small_cube_sid, - small_rank, - edge_size, - checker_edge_size, - small_rank, - sel_start); + test_select_hyper_checker_board_dr__select_checker_board(mem_small_cube_sid, small_rank, edge_size, + checker_edge_size, small_rank, sel_start); /* now read slices from the large, on-disk cube into the small cube. * Note how we adjust sel_start only in the dimensions peculiar to the @@ -2967,22 +3124,22 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ u = 0; do { - if(small_rank_offset > 0) + if (small_rank_offset > 0) sel_start[0] = u; v = 0; do { - if(small_rank_offset > 1) + if (small_rank_offset > 1) sel_start[1] = v; w = 0; do { - if(small_rank_offset > 2) + if (small_rank_offset > 2) sel_start[2] = w; x = 0; do { - if(small_rank_offset > 3) + if (small_rank_offset > 3) sel_start[3] = x; /* we know that small_rank >= 1 and that large_rank > small_rank @@ -2996,15 +3153,8 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ HDassert((sel_start[3] == 0) || (3 < small_rank_offset)); HDassert((sel_start[4] == 0) || (4 < small_rank_offset)); - test_select_hyper_checker_board_dr__select_checker_board - ( - file_large_cube_sid, - large_rank, - edge_size, - checker_edge_size, - small_rank, - sel_start - ); + test_select_hyper_checker_board_dr__select_checker_board( + file_large_cube_sid, large_rank, edge_size, checker_edge_size, small_rank, sel_start); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -3016,45 +3166,31 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ HDmemset(small_cube_buf_1, 0, sizeof(*small_cube_buf_1) * small_cube_size); /* Read selection from disk */ - ret = H5Dread(large_cube_dataset, - H5T_NATIVE_UINT16, - mem_small_cube_sid, - file_large_cube_sid, - xfer_plist, - small_cube_buf_1); + ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, mem_small_cube_sid, + file_large_cube_sid, xfer_plist, small_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); - expected_value = (uint16_t) - ((u * edge_size * edge_size * edge_size * edge_size) + - (v * edge_size * edge_size * edge_size) + - (w * edge_size * edge_size) + - (x * edge_size)); - - data_ok = test_select_hyper_checker_board_dr__verify_data - ( - small_cube_buf_1, - small_rank, - edge_size, - checker_edge_size, - expected_value, - (hbool_t)TRUE - ); - if(!data_ok) - TestErrPrintf("small cube read from largecube has bad data! Line=%d\n",__LINE__); + expected_value = (uint16_t)((u * edge_size * edge_size * edge_size * edge_size) + + (v * edge_size * edge_size * edge_size) + + (w * edge_size * edge_size) + (x * edge_size)); + + data_ok = test_select_hyper_checker_board_dr__verify_data(small_cube_buf_1, small_rank, + edge_size, checker_edge_size, + expected_value, (hbool_t)TRUE); + if (!data_ok) + TestErrPrintf("small cube read from largecube has bad data! Line=%d\n", __LINE__); x++; - } while((large_rank >= (test_max_rank - 3)) && - (small_rank <= (test_max_rank - 4)) && (x < edge_size)); + } while ((large_rank >= (test_max_rank - 3)) && (small_rank <= (test_max_rank - 4)) && + (x < edge_size)); w++; - } while((large_rank >= (test_max_rank - 2)) && - (small_rank <= (test_max_rank - 3)) && (w < edge_size)); + } while ((large_rank >= (test_max_rank - 2)) && (small_rank <= (test_max_rank - 3)) && + (w < edge_size)); v++; - } while((large_rank >= (test_max_rank - 1)) && - (small_rank <= (test_max_rank - 2)) && (v < edge_size)); + } while ((large_rank >= (test_max_rank - 1)) && (small_rank <= (test_max_rank - 2)) && + (v < edge_size)); u++; - } while((large_rank >= test_max_rank) && - (small_rank <= (test_max_rank - 1)) && (u < edge_size)); - + } while ((large_rank >= test_max_rank) && (small_rank <= (test_max_rank - 1)) && (u < edge_size)); /* similarly, read the on disk small cube into slices through the in memory * large cube, and verify that the correct data (and only the correct data) @@ -3063,32 +3199,27 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* select a checker board in the file small cube dataspace */ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0; - test_select_hyper_checker_board_dr__select_checker_board(file_small_cube_sid, - small_rank, - edge_size, - checker_edge_size, - small_rank, - sel_start); - + test_select_hyper_checker_board_dr__select_checker_board(file_small_cube_sid, small_rank, edge_size, + checker_edge_size, small_rank, sel_start); u = 0; do { - if(0 < small_rank_offset) + if (0 < small_rank_offset) sel_start[0] = u; v = 0; do { - if(1 < small_rank_offset) + if (1 < small_rank_offset) sel_start[1] = v; w = 0; do { - if(2 < small_rank_offset) + if (2 < small_rank_offset) sel_start[2] = w; x = 0; do { - if(3 < small_rank_offset) + if (3 < small_rank_offset) sel_start[3] = x; /* we know that small_rank >= 1 and that large_rank > small_rank @@ -3102,15 +3233,8 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ HDassert((sel_start[3] == 0) || (3 < small_rank_offset)); HDassert((sel_start[4] == 0) || (4 < small_rank_offset)); - test_select_hyper_checker_board_dr__select_checker_board - ( - mem_large_cube_sid, - large_rank, - edge_size, - checker_edge_size, - small_rank, - sel_start - ); + test_select_hyper_checker_board_dr__select_checker_board( + mem_large_cube_sid, large_rank, edge_size, checker_edge_size, small_rank, sel_start); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -3118,52 +3242,38 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ check = H5Sselect_shape_same(file_small_cube_sid, mem_large_cube_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* zero out the in memory large cube */ HDmemset(large_cube_buf_1, 0, sizeof(*large_cube_buf_1) * large_cube_size); /* Read selection from disk */ - ret = H5Dread(small_cube_dataset, - H5T_NATIVE_UINT16, - mem_large_cube_sid, - file_small_cube_sid, - xfer_plist, - large_cube_buf_1); + ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, + file_small_cube_sid, xfer_plist, large_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); - /* verify that the expected data and only the * expected data was read. */ - data_ok = TRUE; - ptr_1 = large_cube_buf_1; + data_ok = TRUE; + ptr_1 = large_cube_buf_1; expected_value = 0; - start_index = (u * edge_size * edge_size * edge_size * edge_size) + - (v * edge_size * edge_size * edge_size) + - (w * edge_size * edge_size) + + start_index = (u * edge_size * edge_size * edge_size * edge_size) + + (v * edge_size * edge_size * edge_size) + (w * edge_size * edge_size) + (x * edge_size); stop_index = start_index + small_cube_size - 1; - HDassert( start_index < stop_index ); - HDassert( stop_index <= large_cube_size ); + HDassert(start_index < stop_index); + HDassert(stop_index <= large_cube_size); /* verify that the large cube contains only zeros before the slice */ - for(s = 0; s < start_index; s++) { - if(*ptr_1 != 0) + for (s = 0; s < start_index; s++) { + if (*ptr_1 != 0) data_ok = FALSE; ptr_1++; } /* end for */ HDassert(s == start_index); - data_ok &= test_select_hyper_checker_board_dr__verify_data - ( - ptr_1, - small_rank, - edge_size, - checker_edge_size, - (uint16_t)0, - (hbool_t)TRUE - ); + data_ok &= test_select_hyper_checker_board_dr__verify_data( + ptr_1, small_rank, edge_size, checker_edge_size, (uint16_t)0, (hbool_t)TRUE); ptr_1 += small_cube_size; s += small_cube_size; @@ -3171,27 +3281,25 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ HDassert(s == stop_index + 1); /* verify that the large cube contains only zeros after the slice */ - for(s = stop_index + 1; s < large_cube_size; s++) { - if(*ptr_1 != 0) + for (s = stop_index + 1; s < large_cube_size; s++) { + if (*ptr_1 != 0) data_ok = FALSE; ptr_1++; } /* end for */ - if(!data_ok) - TestErrPrintf("large cube read from small cube has bad data! Line=%d\n",__LINE__); + if (!data_ok) + TestErrPrintf("large cube read from small cube has bad data! Line=%d\n", __LINE__); x++; - } while((large_rank >= (test_max_rank - 3)) && - (small_rank <= (test_max_rank - 4)) && (x < edge_size)); + } while ((large_rank >= (test_max_rank - 3)) && (small_rank <= (test_max_rank - 4)) && + (x < edge_size)); w++; - } while((large_rank >= (test_max_rank - 2)) && - (small_rank <= (test_max_rank - 3)) && (w < edge_size)); + } while ((large_rank >= (test_max_rank - 2)) && (small_rank <= (test_max_rank - 3)) && + (w < edge_size)); v++; - } while((large_rank >= (test_max_rank - 1)) && - (small_rank <= (test_max_rank - 2)) && (v < edge_size)); + } while ((large_rank >= (test_max_rank - 1)) && (small_rank <= (test_max_rank - 2)) && + (v < edge_size)); u++; - } while((large_rank >= test_max_rank) && - (small_rank <= (test_max_rank - 1)) && (u < edge_size)); - + } while ((large_rank >= test_max_rank) && (small_rank <= (test_max_rank - 1)) && (u < edge_size)); /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that @@ -3206,43 +3314,34 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* select a checker board in the file small cube dataspace */ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0; - test_select_hyper_checker_board_dr__select_checker_board(file_small_cube_sid, - small_rank, - edge_size, - checker_edge_size, - small_rank, - sel_start); + test_select_hyper_checker_board_dr__select_checker_board(file_small_cube_sid, small_rank, edge_size, + checker_edge_size, small_rank, sel_start); u = 0; do { - if(small_rank_offset > 0) + if (small_rank_offset > 0) sel_start[0] = u; v = 0; do { - if(small_rank_offset > 1) + if (small_rank_offset > 1) sel_start[1] = v; w = 0; do { - if(small_rank_offset > 2) + if (small_rank_offset > 2) sel_start[2] = w; x = 0; do { - if(small_rank_offset > 3) + if (small_rank_offset > 3) sel_start[3] = x; /* zero out the on disk small cube */ - ret = H5Dwrite(small_cube_dataset, - H5T_NATIVE_UINT16, - full_small_cube_sid, - full_small_cube_sid, - xfer_plist, - zero_buf); + ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid, + full_small_cube_sid, xfer_plist, zero_buf); CHECK(ret, FAIL, "H5Dwrite"); - /* we know that small_rank >= 1 and that large_rank > small_rank * by the assertions at the head of this function. Thus no * need for another inner loop. @@ -3254,15 +3353,8 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ HDassert((sel_start[3] == 0) || (3 < small_rank_offset)); HDassert((sel_start[4] == 0) || (4 < small_rank_offset)); - test_select_hyper_checker_board_dr__select_checker_board - ( - mem_large_cube_sid, - large_rank, - edge_size, - checker_edge_size, - small_rank, - sel_start - ); + test_select_hyper_checker_board_dr__select_checker_board( + mem_large_cube_sid, large_rank, edge_size, checker_edge_size, small_rank, sel_start); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -3270,62 +3362,42 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ check = H5Sselect_shape_same(file_small_cube_sid, mem_large_cube_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); - - /* write the slice from the in memory large cube to the + /* write the slice from the in memory large cube to the * on disk small cube */ - ret = H5Dwrite(small_cube_dataset, - H5T_NATIVE_UINT16, - mem_large_cube_sid, - file_small_cube_sid, - xfer_plist, - cube_buf); + ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, + file_small_cube_sid, xfer_plist, cube_buf); CHECK(ret, FAIL, "H5Dwrite"); - /* zero the buffer that we will be using for reading */ HDmemset(small_cube_buf_1, 0, sizeof(*small_cube_buf_1) * small_cube_size); /* read the on disk small cube into memory */ - ret = H5Dread(small_cube_dataset, - H5T_NATIVE_UINT16, - full_small_cube_sid, - full_small_cube_sid, - xfer_plist, - small_cube_buf_1); + ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid, + full_small_cube_sid, xfer_plist, small_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); - expected_value = (uint16_t) - ((u * edge_size * edge_size * edge_size * edge_size) + - (v * edge_size * edge_size * edge_size) + - (w * edge_size * edge_size) + - (x * edge_size)); - - data_ok = test_select_hyper_checker_board_dr__verify_data - ( - small_cube_buf_1, - small_rank, - edge_size, - checker_edge_size, - expected_value, - (hbool_t)TRUE - ); - if(!data_ok) - TestErrPrintf("small cube read from largecube has bad data! Line=%d\n",__LINE__); + expected_value = (uint16_t)((u * edge_size * edge_size * edge_size * edge_size) + + (v * edge_size * edge_size * edge_size) + + (w * edge_size * edge_size) + (x * edge_size)); + + data_ok = test_select_hyper_checker_board_dr__verify_data(small_cube_buf_1, small_rank, + edge_size, checker_edge_size, + expected_value, (hbool_t)TRUE); + if (!data_ok) + TestErrPrintf("small cube read from largecube has bad data! Line=%d\n", __LINE__); x++; - } while((large_rank >= (test_max_rank - 3)) && - (small_rank <= (test_max_rank - 4)) && (x < edge_size)); + } while ((large_rank >= (test_max_rank - 3)) && (small_rank <= (test_max_rank - 4)) && + (x < edge_size)); w++; - } while((large_rank >= (test_max_rank - 2)) && - (small_rank <= (test_max_rank - 3)) && (w < edge_size)); + } while ((large_rank >= (test_max_rank - 2)) && (small_rank <= (test_max_rank - 3)) && + (w < edge_size)); v++; - } while((large_rank >= (test_max_rank - 1)) && - (small_rank <= (test_max_rank - 2)) && (v < edge_size)); + } while ((large_rank >= (test_max_rank - 1)) && (small_rank <= (test_max_rank - 2)) && + (v < edge_size)); u++; - } while((large_rank >= test_max_rank) && - (small_rank <= (test_max_rank - 1)) && (u < edge_size)); - + } while ((large_rank >= test_max_rank) && (small_rank <= (test_max_rank - 1)) && (u < edge_size)); /* Now write checker board selections of the entries in memory * small cube to slices of the on disk cube. After each write, @@ -3337,40 +3409,32 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* select a checker board in the in memory small cube dataspace */ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0; - test_select_hyper_checker_board_dr__select_checker_board(mem_small_cube_sid, - small_rank, - edge_size, - checker_edge_size, - small_rank, - sel_start); + test_select_hyper_checker_board_dr__select_checker_board(mem_small_cube_sid, small_rank, edge_size, + checker_edge_size, small_rank, sel_start); u = 0; do { - if(small_rank_offset > 0) + if (small_rank_offset > 0) sel_start[0] = u; v = 0; do { - if(small_rank_offset > 1) + if (small_rank_offset > 1) sel_start[1] = v; w = 0; do { - if(small_rank_offset > 2) + if (small_rank_offset > 2) sel_start[2] = w; x = 0; do { - if(small_rank_offset > 3) + if (small_rank_offset > 3) sel_start[3] = x; /* zero out the on disk cube */ - ret = H5Dwrite(large_cube_dataset, - H5T_NATIVE_USHORT, - full_large_cube_sid, - full_large_cube_sid, - xfer_plist, - zero_buf); + ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_USHORT, full_large_cube_sid, + full_large_cube_sid, xfer_plist, zero_buf); CHECK(ret, FAIL, "H5Dwrite"); /* we know that small_rank >= 1 and that large_rank > small_rank @@ -3384,16 +3448,8 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ HDassert((sel_start[3] == 0) || (3 < small_rank_offset)); HDassert((sel_start[4] == 0) || (4 < small_rank_offset)); - - test_select_hyper_checker_board_dr__select_checker_board - ( - file_large_cube_sid, - large_rank, - edge_size, - checker_edge_size, - small_rank, - sel_start - ); + test_select_hyper_checker_board_dr__select_checker_board( + file_large_cube_sid, large_rank, edge_size, checker_edge_size, small_rank, sel_start); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -3401,67 +3457,48 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ check = H5Sselect_shape_same(file_large_cube_sid, mem_small_cube_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); - - /* write the checker board selection of the in memory + /* write the checker board selection of the in memory * small cube to a slice through the on disk large * cube. */ - ret = H5Dwrite(large_cube_dataset, - H5T_NATIVE_UINT16, - mem_small_cube_sid, - file_large_cube_sid, - xfer_plist, - cube_buf); + ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, mem_small_cube_sid, + file_large_cube_sid, xfer_plist, cube_buf); CHECK(ret, FAIL, "H5Dwrite"); - /* zero out the in memory large cube */ HDmemset(large_cube_buf_1, 0, sizeof(*large_cube_buf_1) * large_cube_size); /* read the on disk large cube into memory */ - ret = H5Dread(large_cube_dataset, - H5T_NATIVE_UINT16, - full_large_cube_sid, - full_large_cube_sid, - xfer_plist, - large_cube_buf_1); + ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid, + full_large_cube_sid, xfer_plist, large_cube_buf_1); CHECK(ret, FAIL, "H5Dread"); - /* verify that the expected data and only the * expected data was written to the on disk large * cube. */ - data_ok = TRUE; - ptr_1 = large_cube_buf_1; + data_ok = TRUE; + ptr_1 = large_cube_buf_1; expected_value = 0; - start_index = (u * edge_size * edge_size * edge_size * edge_size) + - (v * edge_size * edge_size * edge_size) + - (w * edge_size * edge_size) + + start_index = (u * edge_size * edge_size * edge_size * edge_size) + + (v * edge_size * edge_size * edge_size) + (w * edge_size * edge_size) + (x * edge_size); stop_index = start_index + small_cube_size - 1; - HDassert( start_index < stop_index ); - HDassert( stop_index <= large_cube_size ); + HDassert(start_index < stop_index); + HDassert(stop_index <= large_cube_size); /* verify that the large cube contains only zeros before the slice */ - for(s = 0; s < start_index; s++) { - if(*ptr_1 != 0) + for (s = 0; s < start_index; s++) { + if (*ptr_1 != 0) data_ok = FALSE; ptr_1++; } /* end for */ HDassert(s == start_index); /* verify that the slice contains the expected data */ - data_ok &= test_select_hyper_checker_board_dr__verify_data - ( - ptr_1, - small_rank, - edge_size, - checker_edge_size, - (uint16_t)0, - (hbool_t)TRUE - ); + data_ok &= test_select_hyper_checker_board_dr__verify_data( + ptr_1, small_rank, edge_size, checker_edge_size, (uint16_t)0, (hbool_t)TRUE); ptr_1 += small_cube_size; s += small_cube_size; @@ -3469,27 +3506,25 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ HDassert(s == stop_index + 1); /* verify that the large cube contains only zeros after the slice */ - for(s = stop_index + 1; s < large_cube_size; s++) { - if(*ptr_1 != 0) + for (s = stop_index + 1; s < large_cube_size; s++) { + if (*ptr_1 != 0) data_ok = FALSE; ptr_1++; } /* end for */ - if(!data_ok) - TestErrPrintf("large cube written from small cube has bad data! Line=%d\n",__LINE__); + if (!data_ok) + TestErrPrintf("large cube written from small cube has bad data! Line=%d\n", __LINE__); x++; - } while((large_rank >= (test_max_rank - 3)) && - (small_rank <= (test_max_rank - 4)) && (x < edge_size)); + } while ((large_rank >= (test_max_rank - 3)) && (small_rank <= (test_max_rank - 4)) && + (x < edge_size)); w++; - } while((large_rank >= (test_max_rank - 2)) && - (small_rank <= (test_max_rank - 3)) && (w < edge_size)); + } while ((large_rank >= (test_max_rank - 2)) && (small_rank <= (test_max_rank - 3)) && + (w < edge_size)); v++; - } while((large_rank >= (test_max_rank - 1)) && - (small_rank <= (test_max_rank - 2)) && (v < edge_size)); + } while ((large_rank >= (test_max_rank - 1)) && (small_rank <= (test_max_rank - 2)) && + (v < edge_size)); u++; - } while((large_rank >= test_max_rank) && - (small_rank <= (test_max_rank - 1)) && (u < edge_size)); - + } while ((large_rank >= test_max_rank) && (small_rank <= (test_max_rank - 1)) && (u < edge_size)); /* Close memory dataspaces */ ret = H5Sclose(full_small_cube_sid); @@ -3504,7 +3539,6 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ ret = H5Sclose(mem_large_cube_sid); CHECK(ret, FAIL, "H5Sclose"); - /* Close disk dataspace */ ret = H5Sclose(file_small_cube_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -3527,8 +3561,7 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ HDfree(small_cube_buf_1); HDfree(large_cube_buf_1); -} /* test_select_hyper_checker_board_dr__run_test() */ - +} /* test_select_hyper_checker_board_dr__run_test() */ /**************************************************************** ** @@ -3545,26 +3578,26 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ static void test_select_hyper_checker_board_dr(hid_t dset_type, hid_t xfer_plist) { - uint16_t *cube_buf; /* Buffer for writing cube data */ - uint16_t *cube_ptr; /* Temporary pointer into cube data */ - uint16_t *zero_buf; /* Buffer for writing zeroed cube data */ - int test_num = 0; - unsigned checker_edge_size = 2; /* Size of checkerboard dimension */ - unsigned chunk_edge_size; /* Size of chunk's dataspace dimensions */ - unsigned edge_size = 6; /* Size of dataset's dataspace dimensions */ - unsigned small_rank; /* Current rank of small dataset */ - unsigned large_rank; /* Current rank of large dataset */ - unsigned max_rank = 5; /* Max. rank to use */ - size_t max_cube_size; /* Max. number of elements in largest cube */ - size_t s; /* Local index variable */ - unsigned u; /* Local index variable */ + uint16_t *cube_buf; /* Buffer for writing cube data */ + uint16_t *cube_ptr; /* Temporary pointer into cube data */ + uint16_t *zero_buf; /* Buffer for writing zeroed cube data */ + int test_num = 0; + unsigned checker_edge_size = 2; /* Size of checkerboard dimension */ + unsigned chunk_edge_size; /* Size of chunk's dataspace dimensions */ + unsigned edge_size = 6; /* Size of dataset's dataspace dimensions */ + unsigned small_rank; /* Current rank of small dataset */ + unsigned large_rank; /* Current rank of large dataset */ + unsigned max_rank = 5; /* Max. rank to use */ + size_t max_cube_size; /* Max. number of elements in largest cube */ + size_t s; /* Local index variable */ + unsigned u; /* Local index variable */ /* Output message about test being performed */ MESSAGE(5, ("Testing Checker Board Hyperslabs With Different Rank I/O Functionality\n")); /* Compute max. cube size */ max_cube_size = (size_t)1; - for(u = 0; u < max_rank; u++) + for (u = 0; u < max_rank; u++) max_cube_size *= (size_t)(edge_size + 1); /* Allocate cube buffer for writing values */ @@ -3573,47 +3606,43 @@ test_select_hyper_checker_board_dr(hid_t dset_type, hid_t xfer_plist) /* Initialize the cube buffer */ cube_ptr = cube_buf; - for(s = 0; s < max_cube_size; s++) + for (s = 0; s < max_cube_size; s++) *cube_ptr++ = (uint16_t)s; /* Allocate cube buffer for zeroing values on disk */ zero_buf = (uint16_t *)HDcalloc(sizeof(uint16_t), max_cube_size); CHECK_PTR(zero_buf, "HDcalloc"); - for(large_rank = 1; large_rank <= max_rank; large_rank++) { - for(small_rank = 1; small_rank < large_rank; small_rank++) { + for (large_rank = 1; large_rank <= max_rank; large_rank++) { + for (small_rank = 1; small_rank < large_rank; small_rank++) { chunk_edge_size = 0; - test_select_hyper_checker_board_dr__run_test(test_num, cube_buf, - zero_buf, edge_size, checker_edge_size, chunk_edge_size, small_rank, - large_rank, dset_type, xfer_plist); + test_select_hyper_checker_board_dr__run_test(test_num, cube_buf, zero_buf, edge_size, + checker_edge_size, chunk_edge_size, small_rank, + large_rank, dset_type, xfer_plist); test_num++; - test_select_hyper_checker_board_dr__run_test(test_num, cube_buf, - zero_buf, - edge_size + 1, checker_edge_size, chunk_edge_size, small_rank, - large_rank, dset_type, xfer_plist); + test_select_hyper_checker_board_dr__run_test(test_num, cube_buf, zero_buf, edge_size + 1, + checker_edge_size, chunk_edge_size, small_rank, + large_rank, dset_type, xfer_plist); test_num++; chunk_edge_size = 3; - test_select_hyper_checker_board_dr__run_test(test_num, cube_buf, - zero_buf, - edge_size, checker_edge_size, chunk_edge_size, small_rank, - large_rank, dset_type, xfer_plist); + test_select_hyper_checker_board_dr__run_test(test_num, cube_buf, zero_buf, edge_size, + checker_edge_size, chunk_edge_size, small_rank, + large_rank, dset_type, xfer_plist); test_num++; - test_select_hyper_checker_board_dr__run_test(test_num, cube_buf, - zero_buf, - edge_size + 1, checker_edge_size, chunk_edge_size, small_rank, - large_rank, dset_type, xfer_plist); + test_select_hyper_checker_board_dr__run_test(test_num, cube_buf, zero_buf, edge_size + 1, + checker_edge_size, chunk_edge_size, small_rank, + large_rank, dset_type, xfer_plist); test_num++; } /* for loop on small rank */ - } /* for loop on large rank */ + } /* for loop on large rank */ HDfree(cube_buf); HDfree(zero_buf); -} /* test_select_hyper_checker_board_dr() */ - +} /* test_select_hyper_checker_board_dr() */ /**************************************************************** ** @@ -3624,22 +3653,22 @@ test_select_hyper_checker_board_dr(hid_t dset_type, hid_t xfer_plist) static void test_select_hyper_copy(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t data1,data2; /* Dataset IDs */ - hid_t sid1,sid2,sid3; /* Dataspace IDs */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; - hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ - uint16_t *wbuf, /* buffer to write to disk */ - *rbuf, /* 1st buffer read from disk */ - *rbuf2, /* 2nd buffer read from disk */ - *tbuf; /* temporary buffer pointer */ - int i,j; /* Counters */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t data1, data2; /* Dataset IDs */ + hid_t sid1, sid2, sid3; /* Dataspace IDs */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; + hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ + uint16_t *wbuf, /* buffer to write to disk */ + *rbuf, /* 1st buffer read from disk */ + *rbuf2, /* 2nd buffer read from disk */ + *tbuf; /* temporary buffer pointer */ + int i, j; /* Counters */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n")); @@ -3653,9 +3682,9 @@ test_select_hyper_copy(void) CHECK_PTR(rbuf2, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i=POINT1_NPOINTS); + assert(SPACE9_DIM2 >= POINT1_NPOINTS); /* Create dataspace for single point selection */ single_pt_sid = H5Screate_simple(SPACE9_RANK, dims2D, NULL); CHECK(single_pt_sid, FAIL, "H5Screate_simple"); /* Select sequence of ten points for multiple point selection */ - coord1[0][0] = 2; coord1[0][1] = 2; - ret = H5Sselect_elements(single_pt_sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord1); + coord1[0][0] = 2; + coord1[0][1] = 2; + ret = H5Sselect_elements(single_pt_sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); /* Create dataspace for single hyperslab selection */ @@ -5317,11 +5572,15 @@ test_select_hyper_valid_combination(void) CHECK(single_hyper_sid, FAIL, "H5Screate_simple"); /* Select 10x10 hyperslab for single hyperslab selection */ - start[0]=1; start[1]=1; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=(SPACE9_DIM1-2); block[1]=(SPACE9_DIM2-2); - ret = H5Sselect_hyperslab(single_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 1; + start[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = (SPACE9_DIM1 - 2); + block[1] = (SPACE9_DIM2 - 2); + ret = H5Sselect_hyperslab(single_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for regular hyperslab selection */ @@ -5329,14 +5588,21 @@ test_select_hyper_valid_combination(void) CHECK(regular_hyper_sid, FAIL, "H5Screate_simple"); /* Select regular, strided hyperslab selection */ - start[0]=2; start[1]=2; start[2]=2; - stride[0]=2; stride[1]=2; stride[2]=2; - count[0]=5; count[1]=2; count[2]=5; - block[0]=1; block[1]=1; block[2]=1; - ret = H5Sselect_hyperslab(regular_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + start[2] = 2; + stride[0] = 2; + stride[1] = 2; + stride[2] = 2; + count[0] = 5; + count[1] = 2; + count[2] = 5; + block[0] = 1; + block[1] = 1; + block[2] = 1; + ret = H5Sselect_hyperslab(regular_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Test all the selections created */ /* Test the invalid combinations between point and hyperslab */ @@ -5374,8 +5640,7 @@ test_select_hyper_valid_combination(void) CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(regular_hyper_sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_select_hyper_valid_combination() */ - +} /* test_select_hyper_valid_combination() */ /**************************************************************** ** @@ -5386,22 +5651,22 @@ test_select_hyper_valid_combination(void) static void test_select_hyper_and_2d(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hsize_t dims1[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t dims2[] = {SPACE2A_DIM1}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf, /* temporary buffer pointer */ - *tbuf2; /* temporary buffer pointer */ - int i,j; /* Counters */ - herr_t ret; /* Generic return value */ - hssize_t npoints; /* Number of elements in selection */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hsize_t dims1[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t dims2[] = {SPACE2A_DIM1}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + uint8_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf, /* temporary buffer pointer */ + *tbuf2; /* temporary buffer pointer */ + int i, j; /* Counters */ + herr_t ret; /* Generic return value */ + hssize_t npoints; /* Number of elements in selection */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslab Selection Functions with intersection of 2-D hyperslabs\n")); @@ -5413,9 +5678,9 @@ test_select_hyper_and_2d(void) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i=5 && i<=9) && (j>=5 && j<=9)) { - if(*tbuf!=*tbuf2) - HDprintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2); + for (i = 0, tbuf = rbuf, tbuf2 = wbuf; i < SPACE2_DIM1; i++) + for (j = 0; j < SPACE2_DIM2; j++, tbuf++) { + if ((i >= 5 && i <= 9) && (j >= 5 && j <= 9)) { + if (*tbuf != *tbuf2) + HDprintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n", __LINE__, + i, j, (int)*tbuf, (int)*tbuf2); tbuf2++; } /* end if */ else { - if(*tbuf!=0) - HDprintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n",__LINE__,i,j,(int)*tbuf); + if (*tbuf != 0) + HDprintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n", __LINE__, i, j, + (int)*tbuf); } /* end else */ - } /* end for */ + } /* end for */ /* Close memory dataspace */ ret = H5Sclose(sid2); @@ -5504,7 +5779,7 @@ test_select_hyper_and_2d(void) /* Free memory buffers */ HDfree(wbuf); HDfree(rbuf); -} /* test_select_hyper_and_2d() */ +} /* test_select_hyper_and_2d() */ /**************************************************************** ** @@ -5515,22 +5790,22 @@ test_select_hyper_and_2d(void) static void test_select_hyper_xor_2d(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hsize_t dims1[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t dims2[] = {SPACE2A_DIM1}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf, /* temporary buffer pointer */ - *tbuf2; /* temporary buffer pointer */ - int i,j; /* Counters */ - herr_t ret; /* Generic return value */ - hssize_t npoints; /* Number of elements in selection */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hsize_t dims1[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t dims2[] = {SPACE2A_DIM1}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + uint8_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf, /* temporary buffer pointer */ + *tbuf2; /* temporary buffer pointer */ + int i, j; /* Counters */ + herr_t ret; /* Generic return value */ + hssize_t npoints; /* Number of elements in selection */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslab Selection Functions with XOR of 2-D hyperslabs\n")); @@ -5542,9 +5817,9 @@ test_select_hyper_xor_2d(void) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i=0 && i<=4) && (j>=0 && j<=9)) || - ((i>=5 && i<=9) && ((j>=0 && j<=4) || (j>=10 && j<=14))) || - ((i>=10 && i<=14) && (j>=5 && j<=14))) { - if(*tbuf!=*tbuf2) - HDprintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2); + for (i = 0, tbuf = rbuf, tbuf2 = wbuf; i < SPACE2_DIM1; i++) + for (j = 0; j < SPACE2_DIM2; j++, tbuf++) { + if (((i >= 0 && i <= 4) && (j >= 0 && j <= 9)) || + ((i >= 5 && i <= 9) && ((j >= 0 && j <= 4) || (j >= 10 && j <= 14))) || + ((i >= 10 && i <= 14) && (j >= 5 && j <= 14))) { + if (*tbuf != *tbuf2) + HDprintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n", __LINE__, + i, j, (int)*tbuf, (int)*tbuf2); tbuf2++; } /* end if */ else { - if(*tbuf!=0) - HDprintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n",__LINE__,i,j,(int)*tbuf); + if (*tbuf != 0) + HDprintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n", __LINE__, i, j, + (int)*tbuf); } /* end else */ - } /* end for */ + } /* end for */ /* Close memory dataspace */ ret = H5Sclose(sid2); @@ -5635,7 +5920,7 @@ test_select_hyper_xor_2d(void) /* Free memory buffers */ HDfree(wbuf); HDfree(rbuf); -} /* test_select_hyper_xor_2d() */ +} /* test_select_hyper_xor_2d() */ /**************************************************************** ** @@ -5646,22 +5931,22 @@ test_select_hyper_xor_2d(void) static void test_select_hyper_notb_2d(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hsize_t dims1[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t dims2[] = {SPACE2A_DIM1}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf, /* temporary buffer pointer */ - *tbuf2; /* temporary buffer pointer */ - int i,j; /* Counters */ - herr_t ret; /* Generic return value */ - hssize_t npoints; /* Number of elements in selection */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hsize_t dims1[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t dims2[] = {SPACE2A_DIM1}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + uint8_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf, /* temporary buffer pointer */ + *tbuf2; /* temporary buffer pointer */ + int i, j; /* Counters */ + herr_t ret; /* Generic return value */ + hssize_t npoints; /* Number of elements in selection */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslab Selection Functions with NOTB of 2-D hyperslabs\n")); @@ -5673,9 +5958,9 @@ test_select_hyper_notb_2d(void) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i=0 && i<=4) && (j>=0 && j<=9)) || - ((i>=5 && i<=9) && (j>=0 && j<=4))) { - if(*tbuf!=*tbuf2) - HDprintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2); + for (i = 0, tbuf = rbuf, tbuf2 = wbuf; i < SPACE2_DIM1; i++) + for (j = 0; j < SPACE2_DIM2; j++, tbuf++) { + if (((i >= 0 && i <= 4) && (j >= 0 && j <= 9)) || ((i >= 5 && i <= 9) && (j >= 0 && j <= 4))) { + if (*tbuf != *tbuf2) + HDprintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n", __LINE__, + i, j, (int)*tbuf, (int)*tbuf2); tbuf2++; } /* end if */ else { - if(*tbuf!=0) - HDprintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n",__LINE__,i,j,(int)*tbuf); + if (*tbuf != 0) + HDprintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n", __LINE__, i, j, + (int)*tbuf); } /* end else */ - } /* end for */ + } /* end for */ /* Close memory dataspace */ ret = H5Sclose(sid2); @@ -5765,7 +6059,7 @@ test_select_hyper_notb_2d(void) /* Free memory buffers */ HDfree(wbuf); HDfree(rbuf); -} /* test_select_hyper_notb_2d() */ +} /* test_select_hyper_notb_2d() */ /**************************************************************** ** @@ -5776,22 +6070,22 @@ test_select_hyper_notb_2d(void) static void test_select_hyper_nota_2d(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hsize_t dims1[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t dims2[] = {SPACE2A_DIM1}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf, /* temporary buffer pointer */ - *tbuf2; /* temporary buffer pointer */ - int i,j; /* Counters */ - herr_t ret; /* Generic return value */ - hssize_t npoints; /* Number of elements in selection */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1, sid2; /* Dataspace ID */ + hsize_t dims1[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t dims2[] = {SPACE2A_DIM1}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + uint8_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf, /* temporary buffer pointer */ + *tbuf2; /* temporary buffer pointer */ + int i, j; /* Counters */ + herr_t ret; /* Generic return value */ + hssize_t npoints; /* Number of elements in selection */ /* Output message about test being performed */ MESSAGE(5, ("Testing Hyperslab Selection Functions with NOTA of 2-D hyperslabs\n")); @@ -5803,9 +6097,9 @@ test_select_hyper_nota_2d(void) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i=10 && i<=14) && (j>=5 && j<=14)) || - ((i>=5 && i<=9) && (j>=10 && j<=14))) { - if(*tbuf!=*tbuf2) - TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2); + for (i = 0, tbuf = rbuf, tbuf2 = wbuf; i < SPACE2_DIM1; i++) + for (j = 0; j < SPACE2_DIM2; j++, tbuf++) { + if (((i >= 10 && i <= 14) && (j >= 5 && j <= 14)) || + ((i >= 5 && i <= 9) && (j >= 10 && j <= 14))) { + if (*tbuf != *tbuf2) + TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n", + __LINE__, i, j, (int)*tbuf, (int)*tbuf2); tbuf2++; } /* end if */ else { - if(*tbuf!=0) - TestErrPrintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n",__LINE__,i,j,(int)*tbuf); + if (*tbuf != 0) + TestErrPrintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n", __LINE__, + i, j, (int)*tbuf); } /* end else */ - } /* end for */ + } /* end for */ /* Close memory dataspace */ ret = H5Sclose(sid2); @@ -5895,7 +6199,7 @@ test_select_hyper_nota_2d(void) /* Free memory buffers */ HDfree(wbuf); HDfree(rbuf); -} /* test_select_hyper_nota_2d() */ +} /* test_select_hyper_nota_2d() */ /**************************************************************** ** @@ -5903,29 +6207,30 @@ test_select_hyper_nota_2d(void) ** ****************************************************************/ static herr_t -test_select_hyper_iter2(void *_elem, hid_t H5_ATTR_UNUSED type_id, unsigned ndim, const hsize_t *point, void *_operator_data) +test_select_hyper_iter2(void *_elem, hid_t H5_ATTR_UNUSED type_id, unsigned ndim, const hsize_t *point, + void *_operator_data) { - int *tbuf=(int *)_elem, /* temporary buffer pointer */ - **tbuf2=(int **)_operator_data; /* temporary buffer handle */ - unsigned u; /* Local counting variable */ + int *tbuf = (int *)_elem, /* temporary buffer pointer */ + **tbuf2 = (int **)_operator_data; /* temporary buffer handle */ + unsigned u; /* Local counting variable */ - if(*tbuf!=**tbuf2) { + if (*tbuf != **tbuf2) { TestErrPrintf("Error in hyperslab iteration!\n"); HDprintf("location: { "); - for(u=0; ufill_value) - return(-1); + if (*tbuf != iter_info->fill_value) + return (-1); else { /* Check number of dimensions */ - if(ndim != SPACE7_RANK) - return(-1); + if (ndim != SPACE7_RANK) + return (-1); else { /* Check Coordinates */ coord_ptr = iter_info->coords + (2 * iter_info->curr_coord); iter_info->curr_coord++; - if(coord_ptr[0] != point[0]) - return(-1); - else if(coord_ptr[1] != point[1]) - return(-1); + if (coord_ptr[0] != point[0]) + return (-1); + else if (coord_ptr[1] != point[1]) + return (-1); else - return(0); + return (0); } /* end else */ - } /* end else */ -} /* end test_select_hyper_iter3() */ + } /* end else */ +} /* end test_select_hyper_iter3() */ /**************************************************************** ** @@ -7087,15 +7396,15 @@ test_select_hyper_iter3(void *_elem, hid_t H5_ATTR_UNUSED type_id, unsigned ndim static void test_select_fill_all(void) { - hid_t sid1; /* Dataspace ID */ - hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; - unsigned fill_value; /* Fill value */ - fill_iter_info iter_info; /* Iterator information structure */ - hsize_t points[SPACE7_DIM1*SPACE7_DIM2][SPACE7_RANK]; /* Coordinates of selection */ - unsigned *wbuf, /* buffer to write to disk */ - *tbuf; /* temporary buffer pointer */ - unsigned u, v; /* Counters */ - herr_t ret; /* Generic return value */ + hid_t sid1; /* Dataspace ID */ + hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; + unsigned fill_value; /* Fill value */ + fill_iter_info iter_info; /* Iterator information structure */ + hsize_t points[SPACE7_DIM1 * SPACE7_DIM2][SPACE7_RANK]; /* Coordinates of selection */ + unsigned * wbuf, /* buffer to write to disk */ + *tbuf; /* temporary buffer pointer */ + unsigned u, v; /* Counters */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Filling 'all' Selections\n")); @@ -7105,8 +7414,8 @@ test_select_fill_all(void) CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++) + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++) *tbuf++ = (u * SPACE7_DIM2) + v; /* Create dataspace for dataset on disk */ @@ -7123,14 +7432,14 @@ test_select_fill_all(void) CHECK(ret, FAIL, "H5Dfill"); /* Verify memory buffer the hard way... */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++) - if(*tbuf != fill_value) + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++) + if (*tbuf != fill_value) TestErrPrintf("Error! v=%d, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, fill_value); /* Set the coordinates of the selection */ - for(u = 0; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++) { + for (u = 0; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++) { points[(u * SPACE7_DIM2) + v][0] = u; points[(u * SPACE7_DIM2) + v][1] = v; } /* end for */ @@ -7138,7 +7447,7 @@ test_select_fill_all(void) /* Initialize the iterator structure */ iter_info.fill_value = SPACE7_FILL; iter_info.curr_coord = 0; - iter_info.coords = (hsize_t *)points; + iter_info.coords = (hsize_t *)points; /* Iterate through selection, verifying correct data */ ret = H5Diterate(wbuf, H5T_NATIVE_UINT, sid1, test_select_hyper_iter3, &iter_info); @@ -7150,7 +7459,7 @@ test_select_fill_all(void) /* Free memory buffers */ HDfree(wbuf); -} /* test_select_fill_all() */ +} /* test_select_fill_all() */ /**************************************************************** ** @@ -7161,17 +7470,17 @@ test_select_fill_all(void) static void test_select_fill_point(hssize_t *offset) { - hid_t sid1; /* Dataspace ID */ - hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; - hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */ - hsize_t points[5][SPACE7_RANK] = {{2,4}, {3,8}, {8,4}, {7,5}, {7,7}}; - size_t num_points = 5; /* Number of points selected */ - int fill_value; /* Fill value */ - fill_iter_info iter_info; /* Iterator information structure */ - unsigned *wbuf, /* buffer to write to disk */ - *tbuf; /* temporary buffer pointer */ - unsigned u, v, w; /* Counters */ - herr_t ret; /* Generic return value */ + hid_t sid1; /* Dataspace ID */ + hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; + hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */ + hsize_t points[5][SPACE7_RANK] = {{2, 4}, {3, 8}, {8, 4}, {7, 5}, {7, 7}}; + size_t num_points = 5; /* Number of points selected */ + int fill_value; /* Fill value */ + fill_iter_info iter_info; /* Iterator information structure */ + unsigned * wbuf, /* buffer to write to disk */ + *tbuf; /* temporary buffer pointer */ + unsigned u, v, w; /* Counters */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Filling 'point' Selections\n")); @@ -7181,8 +7490,8 @@ test_select_fill_point(hssize_t *offset) CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++) + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++) *tbuf++ = (unsigned short)(u * SPACE7_DIM2) + v; /* Create dataspace for dataset on disk */ @@ -7193,7 +7502,7 @@ test_select_fill_point(hssize_t *offset) ret = H5Sselect_elements(sid1, H5S_SELECT_SET, num_points, (const hsize_t *)points); CHECK(ret, FAIL, "H5Sselect_elements"); - if(offset != NULL) { + if (offset != NULL) { HDmemcpy(real_offset, offset, SPACE7_RANK * sizeof(hssize_t)); /* Set offset, if provided */ @@ -7211,26 +7520,29 @@ test_select_fill_point(hssize_t *offset) CHECK(ret, FAIL, "H5Dfill"); /* Verify memory buffer the hard way... */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++, tbuf++) { - for(w = 0; w < (unsigned)num_points; w++) { - if(u == (unsigned)(points[w][0] + (hsize_t)real_offset[0]) && v == (unsigned)(points[w][1] + (hsize_t)real_offset[1])) { - if(*tbuf != (unsigned)fill_value) - TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, (unsigned)fill_value); + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++, tbuf++) { + for (w = 0; w < (unsigned)num_points; w++) { + if (u == (unsigned)(points[w][0] + (hsize_t)real_offset[0]) && + v == (unsigned)(points[w][1] + (hsize_t)real_offset[1])) { + if (*tbuf != (unsigned)fill_value) + TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, + (unsigned)fill_value); break; } /* end if */ - } /* end for */ - if(w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v)) - TestErrPrintf("Error! v=%d, u=%d, *tbuf=%u, should be: %u\n", v, u, *tbuf, ((u * SPACE7_DIM2) + v)); + } /* end for */ + if (w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v)) + TestErrPrintf("Error! v=%d, u=%d, *tbuf=%u, should be: %u\n", v, u, *tbuf, + ((u * SPACE7_DIM2) + v)); } /* end for */ /* Initialize the iterator structure */ iter_info.fill_value = SPACE7_FILL; iter_info.curr_coord = 0; - iter_info.coords = (hsize_t *)points; + iter_info.coords = (hsize_t *)points; /* Add in the offset */ - for(u = 0; u < (unsigned)num_points; u++) { + for (u = 0; u < (unsigned)num_points; u++) { points[u][0] = (hsize_t)((hssize_t)points[u][0] + real_offset[0]); points[u][1] = (hsize_t)((hssize_t)points[u][1] + real_offset[1]); } /* end for */ @@ -7245,7 +7557,7 @@ test_select_fill_point(hssize_t *offset) /* Free memory buffers */ HDfree(wbuf); -} /* test_select_fill_point() */ +} /* test_select_fill_point() */ /**************************************************************** ** @@ -7256,19 +7568,19 @@ test_select_fill_point(hssize_t *offset) static void test_select_fill_hyper_simple(hssize_t *offset) { - hid_t sid1; /* Dataspace ID */ - hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; - hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */ - hsize_t start[SPACE7_RANK]; /* Hyperslab start */ - hsize_t count[SPACE7_RANK]; /* Hyperslab block size */ - size_t num_points; /* Number of points in selection */ - hsize_t points[16][SPACE7_RANK]; /* Coordinates selected */ - int fill_value; /* Fill value */ - fill_iter_info iter_info; /* Iterator information structure */ - unsigned *wbuf, /* buffer to write to disk */ - *tbuf; /* temporary buffer pointer */ - unsigned u, v; /* Counters */ - herr_t ret; /* Generic return value */ + hid_t sid1; /* Dataspace ID */ + hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; + hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */ + hsize_t start[SPACE7_RANK]; /* Hyperslab start */ + hsize_t count[SPACE7_RANK]; /* Hyperslab block size */ + size_t num_points; /* Number of points in selection */ + hsize_t points[16][SPACE7_RANK]; /* Coordinates selected */ + int fill_value; /* Fill value */ + fill_iter_info iter_info; /* Iterator information structure */ + unsigned * wbuf, /* buffer to write to disk */ + *tbuf; /* temporary buffer pointer */ + unsigned u, v; /* Counters */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Filling Simple 'hyperslab' Selections\n")); @@ -7278,8 +7590,8 @@ test_select_fill_hyper_simple(hssize_t *offset) CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++) + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++) *tbuf++ = (unsigned short)(u * SPACE7_DIM2) + v; /* Create dataspace for dataset on disk */ @@ -7287,12 +7599,14 @@ test_select_fill_hyper_simple(hssize_t *offset) CHECK(sid1, FAIL, "H5Screate_simple"); /* Select "hyperslab" selection */ - start[0] = 3; start[1] = 3; - count[0] = 4; count[1] = 4; - ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL); + start[0] = 3; + start[1] = 3; + count[0] = 4; + count[1] = 4; + ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - if(offset != NULL) { + if (offset != NULL) { HDmemcpy(real_offset, offset, SPACE7_RANK * sizeof(hssize_t)); /* Set offset, if provided */ @@ -7310,27 +7624,31 @@ test_select_fill_hyper_simple(hssize_t *offset) CHECK(ret, FAIL, "H5Dfill"); /* Verify memory buffer the hard way... */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++, tbuf++) { - if((u >= (unsigned)((hssize_t)start[0] + real_offset[0]) && u < (unsigned)((hssize_t)(start[0] + count[0]) + real_offset[0])) - && (v >= (unsigned)((hssize_t)start[1] + real_offset[1]) && v < (unsigned)((hssize_t)(start[1] + count[1]) + real_offset[1]))) { - if(*tbuf != (unsigned)fill_value) - TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, (unsigned)fill_value); - } /* end if */ + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++, tbuf++) { + if ((u >= (unsigned)((hssize_t)start[0] + real_offset[0]) && + u < (unsigned)((hssize_t)(start[0] + count[0]) + real_offset[0])) && + (v >= (unsigned)((hssize_t)start[1] + real_offset[1]) && + v < (unsigned)((hssize_t)(start[1] + count[1]) + real_offset[1]))) { + if (*tbuf != (unsigned)fill_value) + TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, + (unsigned)fill_value); + } /* end if */ else { - if(*tbuf != ((unsigned)(u * SPACE7_DIM2) + v)) - TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, should be: %u\n", v, u, *tbuf, ((u * SPACE7_DIM2) + v)); + if (*tbuf != ((unsigned)(u * SPACE7_DIM2) + v)) + TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, should be: %u\n", v, u, *tbuf, + ((u * SPACE7_DIM2) + v)); } /* end else */ - } /* end for */ + } /* end for */ /* Initialize the iterator structure */ iter_info.fill_value = SPACE7_FILL; iter_info.curr_coord = 0; - iter_info.coords = (hsize_t *)points; + iter_info.coords = (hsize_t *)points; /* Set the coordinates of the selection (with the offset) */ - for(u = 0, num_points = 0; u < (unsigned)count[0]; u++) - for(v = 0; v < (unsigned)count[1]; v++, num_points++) { + for (u = 0, num_points = 0; u < (unsigned)count[0]; u++) + for (v = 0; v < (unsigned)count[1]; v++, num_points++) { points[num_points][0] = (hsize_t)((hssize_t)(u + start[0]) + real_offset[0]); points[num_points][1] = (hsize_t)((hssize_t)(v + start[1]) + real_offset[1]); } /* end for */ @@ -7345,7 +7663,7 @@ test_select_fill_hyper_simple(hssize_t *offset) /* Free memory buffers */ HDfree(wbuf); -} /* test_select_fill_hyper_simple() */ +} /* test_select_fill_hyper_simple() */ /**************************************************************** ** @@ -7356,26 +7674,24 @@ test_select_fill_hyper_simple(hssize_t *offset) static void test_select_fill_hyper_regular(hssize_t *offset) { - hid_t sid1; /* Dataspace ID */ - hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; - hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */ - hsize_t start[SPACE7_RANK]; /* Hyperslab start */ - hsize_t stride[SPACE7_RANK]; /* Hyperslab stride size */ - hsize_t count[SPACE7_RANK]; /* Hyperslab block count */ - hsize_t block[SPACE7_RANK]; /* Hyperslab block size */ - hsize_t points[16][SPACE7_RANK] = { - {2,2}, {2,3}, {2,6}, {2,7}, - {3,2}, {3,3}, {3,6}, {3,7}, - {6,2}, {6,3}, {6,6}, {6,7}, - {7,2}, {7,3}, {7,6}, {7,7}, - }; - size_t num_points=16; /* Number of points selected */ - int fill_value; /* Fill value */ - fill_iter_info iter_info; /* Iterator information structure */ - unsigned *wbuf, /* buffer to write to disk */ - *tbuf; /* temporary buffer pointer */ - unsigned u, v, w; /* Counters */ - herr_t ret; /* Generic return value */ + hid_t sid1; /* Dataspace ID */ + hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; + hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */ + hsize_t start[SPACE7_RANK]; /* Hyperslab start */ + hsize_t stride[SPACE7_RANK]; /* Hyperslab stride size */ + hsize_t count[SPACE7_RANK]; /* Hyperslab block count */ + hsize_t block[SPACE7_RANK]; /* Hyperslab block size */ + hsize_t points[16][SPACE7_RANK] = { + {2, 2}, {2, 3}, {2, 6}, {2, 7}, {3, 2}, {3, 3}, {3, 6}, {3, 7}, + {6, 2}, {6, 3}, {6, 6}, {6, 7}, {7, 2}, {7, 3}, {7, 6}, {7, 7}, + }; + size_t num_points = 16; /* Number of points selected */ + int fill_value; /* Fill value */ + fill_iter_info iter_info; /* Iterator information structure */ + unsigned * wbuf, /* buffer to write to disk */ + *tbuf; /* temporary buffer pointer */ + unsigned u, v, w; /* Counters */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Filling Regular 'hyperslab' Selections\n")); @@ -7385,23 +7701,27 @@ test_select_fill_hyper_regular(hssize_t *offset) CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++) - *tbuf++ =(u * SPACE7_DIM2) + v; + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++) + *tbuf++ = (u * SPACE7_DIM2) + v; /* Create dataspace for dataset on disk */ sid1 = H5Screate_simple(SPACE7_RANK, dims1, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); /* Select "hyperslab" selection */ - start[0] = 2; start[1] = 2; - stride[0] = 4; stride[1] = 4; - count[0] = 2; count[1] = 2; - block[0] = 2; block[1] = 2; - ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - - if(offset != NULL) { + start[0] = 2; + start[1] = 2; + stride[0] = 4; + stride[1] = 4; + count[0] = 2; + count[1] = 2; + block[0] = 2; + block[1] = 2; + ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + if (offset != NULL) { HDmemcpy(real_offset, offset, SPACE7_RANK * sizeof(hssize_t)); /* Set offset, if provided */ @@ -7419,26 +7739,29 @@ test_select_fill_hyper_regular(hssize_t *offset) CHECK(ret, FAIL, "H5Dfill"); /* Verify memory buffer the hard way... */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++, tbuf++) { - for(w = 0; w < (unsigned)num_points; w++) { - if(u == (unsigned)((hssize_t)points[w][0] + real_offset[0]) && v == (unsigned)((hssize_t)points[w][1] + real_offset[1])) { - if(*tbuf != (unsigned)fill_value) - TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, (unsigned)fill_value); + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++, tbuf++) { + for (w = 0; w < (unsigned)num_points; w++) { + if (u == (unsigned)((hssize_t)points[w][0] + real_offset[0]) && + v == (unsigned)((hssize_t)points[w][1] + real_offset[1])) { + if (*tbuf != (unsigned)fill_value) + TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, + (unsigned)fill_value); break; } /* end if */ - } /* end for */ - if(w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v)) - TestErrPrintf("Error! v=%d, u=%d, *tbuf=%u, should be: %u\n", v, u, *tbuf, ((u * SPACE7_DIM2) + v)); + } /* end for */ + if (w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v)) + TestErrPrintf("Error! v=%d, u=%d, *tbuf=%u, should be: %u\n", v, u, *tbuf, + ((u * SPACE7_DIM2) + v)); } /* end for */ /* Initialize the iterator structure */ iter_info.fill_value = SPACE7_FILL; iter_info.curr_coord = 0; - iter_info.coords = (hsize_t *)points; + iter_info.coords = (hsize_t *)points; /* Add in the offset */ - for(u = 0; u < (unsigned)num_points; u++) { + for (u = 0; u < (unsigned)num_points; u++) { points[u][0] = (hsize_t)((hssize_t)points[u][0] + real_offset[0]); points[u][1] = (hsize_t)((hssize_t)points[u][1] + real_offset[1]); } /* end for */ @@ -7453,7 +7776,7 @@ test_select_fill_hyper_regular(hssize_t *offset) /* Free memory buffers */ HDfree(wbuf); -} /* test_select_fill_hyper_regular() */ +} /* test_select_fill_hyper_regular() */ /**************************************************************** ** @@ -7464,37 +7787,31 @@ test_select_fill_hyper_regular(hssize_t *offset) static void test_select_fill_hyper_irregular(hssize_t *offset) { - hid_t sid1; /* Dataspace ID */ - hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; - hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */ - hsize_t start[SPACE7_RANK]; /* Hyperslab start */ - hsize_t count[SPACE7_RANK]; /* Hyperslab block count */ - hsize_t points[32][SPACE7_RANK] = { /* Yes, some of the are duplicated.. */ - {2,2}, {2,3}, {2,4}, {2,5}, - {3,2}, {3,3}, {3,4}, {3,5}, - {4,2}, {4,3}, {4,4}, {4,5}, - {5,2}, {5,3}, {5,4}, {5,5}, - {4,4}, {4,5}, {4,6}, {4,7}, - {5,4}, {5,5}, {5,6}, {5,7}, - {6,4}, {6,5}, {6,6}, {6,7}, - {7,4}, {7,5}, {7,6}, {7,7}, - }; - hsize_t iter_points[28][SPACE7_RANK] = { /* Coordinates, as iterated through */ - {2,2}, {2,3}, {2,4}, {2,5}, - {3,2}, {3,3}, {3,4}, {3,5}, - {4,2}, {4,3}, {4,4}, {4,5}, {4,6}, {4,7}, - {5,2}, {5,3}, {5,4}, {5,5}, {5,6}, {5,7}, - {6,4}, {6,5}, {6,6}, {6,7}, - {7,4}, {7,5}, {7,6}, {7,7}, - }; - size_t num_points = 32; /* Number of points selected */ - size_t num_iter_points = 28; /* Number of resulting points */ - int fill_value; /* Fill value */ - fill_iter_info iter_info; /* Iterator information structure */ - unsigned *wbuf, /* buffer to write to disk */ - *tbuf; /* temporary buffer pointer */ - unsigned u, v, w; /* Counters */ - herr_t ret; /* Generic return value */ + hid_t sid1; /* Dataspace ID */ + hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; + hssize_t real_offset[SPACE7_RANK]; /* Actual offset to use */ + hsize_t start[SPACE7_RANK]; /* Hyperslab start */ + hsize_t count[SPACE7_RANK]; /* Hyperslab block count */ + hsize_t points[32][SPACE7_RANK] = { + /* Yes, some of the are duplicated.. */ + {2, 2}, {2, 3}, {2, 4}, {2, 5}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {4, 2}, {4, 3}, {4, 4}, + {4, 5}, {5, 2}, {5, 3}, {5, 4}, {5, 5}, {4, 4}, {4, 5}, {4, 6}, {4, 7}, {5, 4}, {5, 5}, + {5, 6}, {5, 7}, {6, 4}, {6, 5}, {6, 6}, {6, 7}, {7, 4}, {7, 5}, {7, 6}, {7, 7}, + }; + hsize_t iter_points[28][SPACE7_RANK] = { + /* Coordinates, as iterated through */ + {2, 2}, {2, 3}, {2, 4}, {2, 5}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {4, 2}, {4, 3}, + {4, 4}, {4, 5}, {4, 6}, {4, 7}, {5, 2}, {5, 3}, {5, 4}, {5, 5}, {5, 6}, {5, 7}, + {6, 4}, {6, 5}, {6, 6}, {6, 7}, {7, 4}, {7, 5}, {7, 6}, {7, 7}, + }; + size_t num_points = 32; /* Number of points selected */ + size_t num_iter_points = 28; /* Number of resulting points */ + int fill_value; /* Fill value */ + fill_iter_info iter_info; /* Iterator information structure */ + unsigned * wbuf, /* buffer to write to disk */ + *tbuf; /* temporary buffer pointer */ + unsigned u, v, w; /* Counters */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Filling Irregular 'hyperslab' Selections\n")); @@ -7504,8 +7821,8 @@ test_select_fill_hyper_irregular(hssize_t *offset) CHECK_PTR(wbuf, "HDmalloc"); /* Initialize memory buffer */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++) + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++) *tbuf++ = (u * SPACE7_DIM2) + v; /* Create dataspace for dataset on disk */ @@ -7513,18 +7830,22 @@ test_select_fill_hyper_irregular(hssize_t *offset) CHECK(sid1, FAIL, "H5Screate_simple"); /* Select first "hyperslab" selection */ - start[0] = 2; start[1] = 2; - count[0] = 4; count[1] = 4; - ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL); + start[0] = 2; + start[1] = 2; + count[0] = 4; + count[1] = 4; + ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Combine with second "hyperslab" selection */ - start[0] = 4; start[1] = 4; - count[0] = 4; count[1] = 4; - ret = H5Sselect_hyperslab(sid1, H5S_SELECT_OR, start, NULL, count, NULL); + start[0] = 4; + start[1] = 4; + count[0] = 4; + count[1] = 4; + ret = H5Sselect_hyperslab(sid1, H5S_SELECT_OR, start, NULL, count, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - if(offset != NULL) { + if (offset != NULL) { HDmemcpy(real_offset, offset, SPACE7_RANK * sizeof(hssize_t)); /* Set offset, if provided */ @@ -7542,26 +7863,29 @@ test_select_fill_hyper_irregular(hssize_t *offset) CHECK(ret, FAIL, "H5Dfill"); /* Verify memory buffer the hard way... */ - for(u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) - for(v = 0; v < SPACE7_DIM2; v++, tbuf++) { - for(w = 0; w < (unsigned)num_points; w++) { - if(u == (unsigned)((hssize_t)points[w][0] + real_offset[0]) && v == (unsigned)((hssize_t)points[w][1] + real_offset[1])) { - if(*tbuf != (unsigned)fill_value) - TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, (unsigned)fill_value); + for (u = 0, tbuf = wbuf; u < SPACE7_DIM1; u++) + for (v = 0; v < SPACE7_DIM2; v++, tbuf++) { + for (w = 0; w < (unsigned)num_points; w++) { + if (u == (unsigned)((hssize_t)points[w][0] + real_offset[0]) && + v == (unsigned)((hssize_t)points[w][1] + real_offset[1])) { + if (*tbuf != (unsigned)fill_value) + TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, fill_value=%u\n", v, u, *tbuf, + (unsigned)fill_value); break; } /* end if */ - } /* end for */ - if(w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v)) - TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, should be: %u\n", v, u, *tbuf, ((u * SPACE7_DIM2) + v)); + } /* end for */ + if (w == (unsigned)num_points && *tbuf != ((u * SPACE7_DIM2) + v)) + TestErrPrintf("Error! v=%u, u=%u, *tbuf=%u, should be: %u\n", v, u, *tbuf, + ((u * SPACE7_DIM2) + v)); } /* end for */ /* Initialize the iterator structure */ iter_info.fill_value = SPACE7_FILL; iter_info.curr_coord = 0; - iter_info.coords = (hsize_t *)iter_points; + iter_info.coords = (hsize_t *)iter_points; /* Add in the offset */ - for(u = 0; u < (unsigned)num_iter_points; u++) { + for (u = 0; u < (unsigned)num_iter_points; u++) { iter_points[u][0] = (hsize_t)((hssize_t)iter_points[u][0] + real_offset[0]); iter_points[u][1] = (hsize_t)((hssize_t)iter_points[u][1] + real_offset[1]); } /* end for */ @@ -7576,7 +7900,7 @@ test_select_fill_hyper_irregular(hssize_t *offset) /* Free memory buffers */ HDfree(wbuf); -} /* test_select_fill_hyper_irregular() */ +} /* test_select_fill_hyper_irregular() */ /**************************************************************** ** @@ -7587,16 +7911,16 @@ test_select_fill_hyper_irregular(hssize_t *offset) static void test_select_none(void) { - hid_t fid1; /* HDF5 File IDs */ + hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; - hsize_t dims2[] = {SPACE7_DIM1, SPACE7_DIM2}; - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer to read from disk */ - *tbuf; /* temporary buffer pointer */ - int i,j; /* Counters */ - herr_t ret; /* Generic return value */ + hid_t sid1, sid2; /* Dataspace ID */ + hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2}; + hsize_t dims2[] = {SPACE7_DIM1, SPACE7_DIM2}; + uint8_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer to read from disk */ + *tbuf; /* temporary buffer pointer */ + int i, j; /* Counters */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing I/O on 0-sized Selections\n")); @@ -7608,9 +7932,9 @@ test_select_none(void) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i=POINT1_NPOINTS); + assert(SPACE9_DIM2 >= POINT1_NPOINTS); /* Create dataspace for "all" selection */ all_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); @@ -8082,8 +8424,9 @@ test_shape_same(void) CHECK(single_pt_sid, FAIL, "H5Screate_simple"); /* Select sequence of ten points for multiple point selection */ - coord1[0][0] = 2; coord1[0][1] = 2; - ret = H5Sselect_elements(single_pt_sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord1); + coord1[0][0] = 2; + coord1[0][1] = 2; + ret = H5Sselect_elements(single_pt_sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); /* Create dataspace for multiple point selection */ @@ -8091,16 +8434,26 @@ test_shape_same(void) CHECK(mult_pt_sid, FAIL, "H5Screate_simple"); /* Select sequence of ten points for multiple point selection */ - coord2[0][0]=2; coord2[0][1]=2; - coord2[1][0]=7; coord2[1][1]=2; - coord2[2][0]=1; coord2[2][1]=4; - coord2[3][0]=2; coord2[3][1]=6; - coord2[4][0]=0; coord2[4][1]=8; - coord2[5][0]=3; coord2[5][1]=2; - coord2[6][0]=4; coord2[6][1]=4; - coord2[7][0]=1; coord2[7][1]=0; - coord2[8][0]=5; coord2[8][1]=1; - coord2[9][0]=9; coord2[9][1]=3; + coord2[0][0] = 2; + coord2[0][1] = 2; + coord2[1][0] = 7; + coord2[1][1] = 2; + coord2[2][0] = 1; + coord2[2][1] = 4; + coord2[3][0] = 2; + coord2[3][1] = 6; + coord2[4][0] = 0; + coord2[4][1] = 8; + coord2[5][0] = 3; + coord2[5][1] = 2; + coord2[6][0] = 4; + coord2[6][1] = 4; + coord2[7][0] = 1; + coord2[7][1] = 0; + coord2[8][0] = 5; + coord2[8][1] = 1; + coord2[9][0] = 9; + coord2[9][1] = 3; ret = H5Sselect_elements(mult_pt_sid, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2); CHECK(ret, FAIL, "H5Sselect_elements"); @@ -8109,11 +8462,15 @@ test_shape_same(void) CHECK(single_hyper_sid, FAIL, "H5Screate_simple"); /* Select 10x10 hyperslab for single hyperslab selection */ - start[0]=1; start[1]=1; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=(SPACE9_DIM1-2); block[1]=(SPACE9_DIM2-2); - ret = H5Sselect_hyperslab(single_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 1; + start[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = (SPACE9_DIM1 - 2); + block[1] = (SPACE9_DIM2 - 2); + ret = H5Sselect_hyperslab(single_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for single hyperslab selection with entire extent selected */ @@ -8121,11 +8478,15 @@ test_shape_same(void) CHECK(single_hyper_all_sid, FAIL, "H5Screate_simple"); /* Select entire extent for hyperslab selection */ - start[0]=0; start[1]=0; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=SPACE9_DIM1; block[1]=SPACE9_DIM2; - ret = H5Sselect_hyperslab(single_hyper_all_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 0; + start[1] = 0; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = SPACE9_DIM1; + block[1] = SPACE9_DIM2; + ret = H5Sselect_hyperslab(single_hyper_all_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for single hyperslab selection with single point selected */ @@ -8133,11 +8494,15 @@ test_shape_same(void) CHECK(single_hyper_pt_sid, FAIL, "H5Screate_simple"); /* Select entire extent for hyperslab selection */ - start[0]=2; start[1]=2; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(single_hyper_pt_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(single_hyper_pt_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for regular hyperslab selection */ @@ -8145,11 +8510,15 @@ test_shape_same(void) CHECK(regular_hyper_sid, FAIL, "H5Screate_simple"); /* Select regular, strided hyperslab selection */ - start[0]=2; start[1]=2; - stride[0]=2; stride[1]=2; - count[0]=5; count[1]=2; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(regular_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + stride[0] = 2; + stride[1] = 2; + count[0] = 5; + count[1] = 2; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(regular_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for irregular hyperslab selection */ @@ -8157,18 +8526,26 @@ test_shape_same(void) CHECK(irreg_hyper_sid, FAIL, "H5Screate_simple"); /* Create irregular hyperslab selection by OR'ing two blocks together */ - start[0]=2; start[1]=2; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(irreg_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(irreg_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0]=4; start[1]=4; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=3; block[1]=3; - ret = H5Sselect_hyperslab(irreg_hyper_sid,H5S_SELECT_OR,start,stride,count,block); + start[0] = 4; + start[1] = 4; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 3; + block[1] = 3; + ret = H5Sselect_hyperslab(irreg_hyper_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for "no" hyperslab selection */ @@ -8176,14 +8553,18 @@ test_shape_same(void) CHECK(none_hyper_sid, FAIL, "H5Screate_simple"); /* Create "no" hyperslab selection by XOR'ing same blocks together */ - start[0]=2; start[1]=2; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(none_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(none_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5Sselect_hyperslab(none_hyper_sid,H5S_SELECT_XOR,start,stride,count,block); + ret = H5Sselect_hyperslab(none_hyper_sid, H5S_SELECT_XOR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create scalar dataspace for "all" selection */ @@ -8199,868 +8580,890 @@ test_shape_same(void) CHECK(ret, FAIL, "H5Sselect_none"); /* Compare "all" selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(all_sid ,all_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(all_sid, all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(all_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(all_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5Sselect_shape_same(all_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(all_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "none" selection */ - check = H5Sselect_shape_same(all_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(all_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against single point selection */ - check = H5Sselect_shape_same(all_sid, single_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(all_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(all_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(all_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(all_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(all_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(all_sid, single_hyper_all_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(all_sid, single_hyper_all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(all_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(all_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(all_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(all_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(all_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(all_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(all_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(all_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(all_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(all_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(all_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(all_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare "none" selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(none_sid, none_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(none_sid, none_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(none_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(none_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5Sselect_shape_same(none_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(none_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(none_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(none_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against single point selection */ - check = H5Sselect_shape_same(none_sid, single_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(none_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(none_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(none_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(none_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(none_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(none_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(none_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(none_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(none_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(none_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(none_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(none_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(none_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(none_sid, none_hyper_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(none_sid, none_hyper_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(none_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(none_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(none_sid, scalar_none_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(none_sid, scalar_none_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); /* Compare single point selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(single_pt_sid, single_pt_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(single_pt_sid, single_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(single_pt_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(single_pt_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5Sselect_shape_same(single_pt_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(single_pt_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(single_pt_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(single_pt_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "none" selection */ - check = H5Sselect_shape_same(single_pt_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(single_pt_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(single_pt_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(single_pt_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(single_pt_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(single_pt_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(single_pt_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(single_pt_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(single_pt_sid, single_hyper_pt_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(single_pt_sid, single_hyper_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(single_pt_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(single_pt_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(single_pt_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(single_pt_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(single_pt_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(single_pt_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(single_pt_sid, scalar_all_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(single_pt_sid, scalar_all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(single_pt_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(single_pt_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare multiple point selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(mult_pt_sid, mult_pt_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(mult_pt_sid, mult_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(mult_pt_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(mult_pt_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5Sselect_shape_same(mult_pt_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(mult_pt_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(mult_pt_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(mult_pt_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "none" selection */ - check = H5Sselect_shape_same(mult_pt_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(mult_pt_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against single point selection */ - check = H5Sselect_shape_same(mult_pt_sid, single_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(mult_pt_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(mult_pt_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(mult_pt_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(mult_pt_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(mult_pt_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(mult_pt_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(mult_pt_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(mult_pt_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(mult_pt_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(mult_pt_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(mult_pt_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(mult_pt_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(mult_pt_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(mult_pt_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(mult_pt_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(mult_pt_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(mult_pt_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare single "normal" hyperslab selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(single_hyper_sid, single_hyper_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(single_hyper_sid, single_hyper_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(single_hyper_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(single_hyper_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(single_hyper_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(single_hyper_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "none" selection */ - check = H5Sselect_shape_same(single_hyper_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(single_hyper_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against single point selection */ - check = H5Sselect_shape_same(single_hyper_sid, single_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(single_hyper_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(single_hyper_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(single_hyper_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); #ifdef NOT_YET -/* In theory, these two selections are the same shape, but the - * H5Sselect_shape_same() routine is just not this sophisticated yet and it - * would take too much effort to make this work. The worst case is that the - * non-optimized chunk mapping routines will be invoked instead of the more - * optimized routines, so this only hurts performance, not correctness - */ - /* Construct point selection which matches "plain" hyperslab selection */ - /* Create dataspace for point selection */ - tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); - CHECK(tmp_sid, FAIL, "H5Screate_simple"); - - /* Select sequence of points for point selection */ - for(u = 1; u < (SPACE9_DIM1 - 1); u++) { - for(v = 1; v < (SPACE9_DIM2 - 1); v++) { - coord2[v - 1][0] = u; - coord2[v - 1][1] = v; - } /* end for */ - - ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, (SPACE9_DIM2 - 2), coord2); - CHECK(ret, FAIL, "H5Sselect_elements"); - } /* end for */ + /* In theory, these two selections are the same shape, but the + * H5Sselect_shape_same() routine is just not this sophisticated yet and it + * would take too much effort to make this work. The worst case is that the + * non-optimized chunk mapping routines will be invoked instead of the more + * optimized routines, so this only hurts performance, not correctness + */ + /* Construct point selection which matches "plain" hyperslab selection */ + /* Create dataspace for point selection */ + tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); + CHECK(tmp_sid, FAIL, "H5Screate_simple"); + + /* Select sequence of points for point selection */ + for (u = 1; u < (SPACE9_DIM1 - 1); u++) { + for (v = 1; v < (SPACE9_DIM2 - 1); v++) { + coord2[v - 1][0] = u; + coord2[v - 1][1] = v; + } /* end for */ - /* Compare against hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, (SPACE9_DIM2 - 2), coord2); + CHECK(ret, FAIL, "H5Sselect_elements"); + } /* end for */ - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Compare against hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); + + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); #endif /* NOT_YET */ - /* Construct hyperslab selection which matches "plain" hyperslab selection */ - /* Create dataspace for hyperslab selection */ - tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); - CHECK(tmp_sid, FAIL, "H5Screate_simple"); - - /* Un-select entire extent */ - ret = H5Sselect_none(tmp_sid); - CHECK(ret, FAIL, "H5Sselect_none"); - - /* Select sequence of rows for hyperslab selection */ - for(u = 1; u < (SPACE9_DIM1 - 1); u++) { - start[0] = u; start[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 1; block[1] = (SPACE9_DIM2 - 2); - ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - } /* end for */ + /* Construct hyperslab selection which matches "plain" hyperslab selection */ + /* Create dataspace for hyperslab selection */ + tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); + CHECK(tmp_sid, FAIL, "H5Screate_simple"); - /* Compare against hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Un-select entire extent */ + ret = H5Sselect_none(tmp_sid); + CHECK(ret, FAIL, "H5Sselect_none"); + + /* Select sequence of rows for hyperslab selection */ + for (u = 1; u < (SPACE9_DIM1 - 1); u++) { + start[0] = u; + start[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = (SPACE9_DIM2 - 2); + ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + } /* end for */ - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Compare against hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare single "all" hyperslab selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_all_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(single_hyper_all_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(single_hyper_all_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5Sselect_shape_same(single_hyper_all_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(single_hyper_all_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, all_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against "none" selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against single point selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, single_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); #ifdef NOT_YET -/* In theory, these two selections are the same shape, but the - * H5S_select_shape_same() routine is just not this sophisticated yet and it - * would take too much effort to make this work. The worst case is that the - * non-optimized chunk mapping routines will be invoked instead of the more - * optimized routines, so this only hurts performance, not correctness - */ - /* Construct point selection which matches "all" hyperslab selection */ - /* Create dataspace for point selection */ - tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); - CHECK(tmp_sid, FAIL, "H5Screate_simple"); - - /* Select sequence of points for point selection */ - for(u = 0; u < SPACE9_DIM1; u++) { - for(v = 0; v < SPACE9_DIM2; v++) { - coord2[v][0] = u; - coord2[v][1] = v; - } /* end for */ - ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, SPACE9_DIM2, coord2); - CHECK(ret, FAIL, "H5Sselect_elements"); - } /* end for */ + /* In theory, these two selections are the same shape, but the + * H5S_select_shape_same() routine is just not this sophisticated yet and it + * would take too much effort to make this work. The worst case is that the + * non-optimized chunk mapping routines will be invoked instead of the more + * optimized routines, so this only hurts performance, not correctness + */ + /* Construct point selection which matches "all" hyperslab selection */ + /* Create dataspace for point selection */ + tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); + CHECK(tmp_sid, FAIL, "H5Screate_simple"); + + /* Select sequence of points for point selection */ + for (u = 0; u < SPACE9_DIM1; u++) { + for (v = 0; v < SPACE9_DIM2; v++) { + coord2[v][0] = u; + coord2[v][1] = v; + } /* end for */ + ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, SPACE9_DIM2, coord2); + CHECK(ret, FAIL, "H5Sselect_elements"); + } /* end for */ - /* Compare against hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); #endif /* NOT_YET */ - /* Construct hyperslab selection which matches "all" hyperslab selection */ - /* Create dataspace for hyperslab selection */ - tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); - CHECK(tmp_sid, FAIL, "H5Screate_simple"); - - /* Un-select entire extent */ - ret = H5Sselect_none(tmp_sid); - CHECK(ret, FAIL, "H5Sselect_none"); - - /* Select sequence of rows for hyperslab selection */ - for(u = 0; u < SPACE9_DIM2; u++) { - start[0] = u; start[1] = 0; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 1; block[1] = SPACE9_DIM2; - ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - } /* end for */ + /* Construct hyperslab selection which matches "all" hyperslab selection */ + /* Create dataspace for hyperslab selection */ + tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); + CHECK(tmp_sid, FAIL, "H5Screate_simple"); + + /* Un-select entire extent */ + ret = H5Sselect_none(tmp_sid); + CHECK(ret, FAIL, "H5Sselect_none"); + + /* Select sequence of rows for hyperslab selection */ + for (u = 0; u < SPACE9_DIM2; u++) { + start[0] = u; + start[1] = 0; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = SPACE9_DIM2; + ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + } /* end for */ - /* Compare against hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_all_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_all_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare single "point" hyperslab selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(single_hyper_pt_sid, single_hyper_pt_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(single_hyper_pt_sid, single_hyper_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(single_hyper_pt_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(single_hyper_pt_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5Sselect_shape_same(single_hyper_pt_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(single_hyper_pt_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "none" selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against single point selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, single_pt_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, single_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, scalar_all_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, scalar_all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(single_hyper_pt_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(single_hyper_pt_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Compare regular, strided hyperslab selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(regular_hyper_sid, regular_hyper_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(regular_hyper_sid, regular_hyper_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(regular_hyper_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(regular_hyper_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5Sselect_shape_same(regular_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(regular_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(regular_hyper_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Compare against "none" selection */ - check = H5Sselect_shape_same(regular_hyper_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Compare against single point selection */ - check = H5Sselect_shape_same(regular_hyper_sid, single_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(regular_hyper_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); - - /* Construct point selection which matches regular, strided hyperslab selection */ - /* Create dataspace for point selection */ - tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); - CHECK(tmp_sid, FAIL, "H5Screate_simple"); - - /* Select sequence of points for point selection */ - for(u = 2; u < 11; u += 2) { - for(v = 0; v < 2; v++) { - coord2[v][0] = u; - coord2[v][1] = (v * 2) + 2; - } /* end for */ - ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, (size_t)2, (const hsize_t *)coord2); - CHECK(ret, FAIL, "H5Sselect_elements"); - } /* end for */ + /* Compare against "all" selection */ + check = H5Sselect_shape_same(regular_hyper_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); - - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); - - /* Construct hyperslab selection which matches regular, strided hyperslab selection */ - /* Create dataspace for hyperslab selection */ - tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); - CHECK(tmp_sid, FAIL, "H5Screate_simple"); - - /* Un-select entire extent */ - ret = H5Sselect_none(tmp_sid); - CHECK(ret, FAIL, "H5Sselect_none"); - - /* Select sequence of rows for hyperslab selection */ - for(u = 2; u < 11; u += 2) { - start[0] = u; start[1] = 3; - stride[0] = 1; stride[1] = 2; - count[0] = 1; count[1] = 2; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - } /* end for */ + /* Compare against "none" selection */ + check = H5Sselect_shape_same(regular_hyper_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(regular_hyper_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(regular_hyper_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Construct regular hyperslab selection with an offset which matches regular, strided hyperslab selection */ - /* Create dataspace for hyperslab selection */ - tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); - CHECK(tmp_sid, FAIL, "H5Screate_simple"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Select regular, strided hyperslab selection at an offset */ - start[0] = 1; start[1] = 1; - stride[0] = 2; stride[1] = 2; - count[0] = 5; count[1] = 2; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(regular_hyper_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Construct point selection which matches regular, strided hyperslab selection */ + /* Create dataspace for point selection */ + tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); + CHECK(tmp_sid, FAIL, "H5Screate_simple"); - /* Compare irregular hyperslab selection to all the selections created */ - /* Compare against itself */ - check = H5Sselect_shape_same(irreg_hyper_sid, irreg_hyper_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Select sequence of points for point selection */ + for (u = 2; u < 11; u += 2) { + for (v = 0; v < 2; v++) { + coord2[v][0] = u; + coord2[v][1] = (v * 2) + 2; + } /* end for */ + ret = H5Sselect_elements(tmp_sid, H5S_SELECT_APPEND, (size_t)2, (const hsize_t *)coord2); + CHECK(ret, FAIL, "H5Sselect_elements"); + } /* end for */ - /* Compare against copy of itself */ - tmp_sid = H5Scopy(irreg_hyper_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - check = H5Sselect_shape_same(irreg_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Construct hyperslab selection which matches regular, strided hyperslab selection */ + /* Create dataspace for hyperslab selection */ + tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); + CHECK(tmp_sid, FAIL, "H5Screate_simple"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Un-select entire extent */ + ret = H5Sselect_none(tmp_sid); + CHECK(ret, FAIL, "H5Sselect_none"); - /* Compare against "none" selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Select sequence of rows for hyperslab selection */ + for (u = 2; u < 11; u += 2) { + start[0] = u; + start[1] = 3; + stride[0] = 1; + stride[1] = 2; + count[0] = 1; + count[1] = 2; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + } /* end for */ - /* Compare against single point selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, single_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Construct regular hyperslab selection with an offset which matches regular, strided hyperslab selection + */ + /* Create dataspace for hyperslab selection */ + tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); + CHECK(tmp_sid, FAIL, "H5Screate_simple"); + + /* Select regular, strided hyperslab selection at an offset */ + start[0] = 1; + start[1] = 1; + stride[0] = 2; + stride[1] = 2; + count[0] = 5; + count[1] = 2; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Compare against hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(regular_hyper_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare irregular hyperslab selection to all the selections created */ + /* Compare against itself */ + check = H5Sselect_shape_same(irreg_hyper_sid, irreg_hyper_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Construct hyperslab selection which matches irregular hyperslab selection */ - /* Create dataspace for hyperslab selection */ - tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); - CHECK(tmp_sid, FAIL, "H5Screate_simple"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(irreg_hyper_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + check = H5Sselect_shape_same(irreg_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Select sequence of columns for hyperslab selection */ - for(u = 0; u < 3; u++) { - start[0] = 4; start[1] = u + 4; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 3; block[1] = 1; - ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - } /* end for */ + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against hyperslab selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(irreg_hyper_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare scalar "all" dataspace with all selections created */ + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against itself */ - check = H5Sselect_shape_same(scalar_all_sid, scalar_all_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(scalar_all_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - check = H5Sselect_shape_same(scalar_all_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Construct hyperslab selection which matches irregular hyperslab selection */ + /* Create dataspace for hyperslab selection */ + tmp_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); + CHECK(tmp_sid, FAIL, "H5Screate_simple"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(scalar_all_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Select sequence of columns for hyperslab selection */ + for (u = 0; u < 3; u++) { + start[0] = 4; + start[1] = u + 4; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 3; + block[1] = 1; + ret = H5Sselect_hyperslab(tmp_sid, H5S_SELECT_OR, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + } /* end for */ - /* Compare against "none" selection */ - check = H5Sselect_shape_same(scalar_all_sid, none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against hyperslab selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against single point selection */ - check = H5Sselect_shape_same(scalar_all_sid, single_pt_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(scalar_all_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(scalar_all_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(irreg_hyper_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(scalar_all_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare scalar "all" dataspace with all selections created */ - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(scalar_all_sid, single_hyper_pt_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(scalar_all_sid, scalar_all_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(scalar_all_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(scalar_all_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(scalar_all_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(scalar_all_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(scalar_all_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against scalar "none" hyperslab selection */ - check = H5Sselect_shape_same(scalar_all_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(scalar_all_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(scalar_all_sid, none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare scalar "none" dataspace with all selections created */ + /* Compare against single point selection */ + check = H5Sselect_shape_same(scalar_all_sid, single_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against itself */ - check = H5Sselect_shape_same(scalar_none_sid, scalar_none_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(scalar_all_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against copy of itself */ - tmp_sid = H5Scopy(scalar_none_sid); - CHECK(tmp_sid, FAIL, "H5Scopy"); + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(scalar_all_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - check = H5Sselect_shape_same(scalar_none_sid, tmp_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(scalar_all_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - ret = H5Sclose(tmp_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(scalar_all_sid, single_hyper_pt_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against "all" selection */ - check = H5Sselect_shape_same(scalar_none_sid, all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(scalar_all_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "none" selection */ - check = H5Sselect_shape_same(scalar_none_sid, none_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(scalar_all_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against single point selection */ - check = H5Sselect_shape_same(scalar_none_sid, single_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(scalar_all_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against multiple point selection */ - check = H5Sselect_shape_same(scalar_none_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against scalar "none" hyperslab selection */ + check = H5Sselect_shape_same(scalar_all_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "plain" single hyperslab selection */ - check = H5Sselect_shape_same(scalar_none_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare scalar "none" dataspace with all selections created */ - /* Compare against "all" single hyperslab selection */ - check = H5Sselect_shape_same(scalar_none_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against itself */ + check = H5Sselect_shape_same(scalar_none_sid, scalar_none_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against "single point" single hyperslab selection */ - check = H5Sselect_shape_same(scalar_none_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against copy of itself */ + tmp_sid = H5Scopy(scalar_none_sid); + CHECK(tmp_sid, FAIL, "H5Scopy"); - /* Compare against regular, strided hyperslab selection */ - check = H5Sselect_shape_same(scalar_none_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + check = H5Sselect_shape_same(scalar_none_sid, tmp_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Compare against irregular hyperslab selection */ - check = H5Sselect_shape_same(scalar_none_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + ret = H5Sclose(tmp_sid); + CHECK(ret, FAIL, "H5Sclose"); - /* Compare against "no" hyperslab selection */ - check = H5Sselect_shape_same(scalar_none_sid, none_hyper_sid); - VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against "all" selection */ + check = H5Sselect_shape_same(scalar_none_sid, all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against scalar "all" hyperslab selection */ - check = H5Sselect_shape_same(scalar_none_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5Sselect_shape_same"); + /* Compare against "none" selection */ + check = H5Sselect_shape_same(scalar_none_sid, none_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); + /* Compare against single point selection */ + check = H5Sselect_shape_same(scalar_none_sid, single_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + + /* Compare against multiple point selection */ + check = H5Sselect_shape_same(scalar_none_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + + /* Compare against "plain" single hyperslab selection */ + check = H5Sselect_shape_same(scalar_none_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + + /* Compare against "all" single hyperslab selection */ + check = H5Sselect_shape_same(scalar_none_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + + /* Compare against "single point" single hyperslab selection */ + check = H5Sselect_shape_same(scalar_none_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + + /* Compare against regular, strided hyperslab selection */ + check = H5Sselect_shape_same(scalar_none_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + + /* Compare against irregular hyperslab selection */ + check = H5Sselect_shape_same(scalar_none_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); + + /* Compare against "no" hyperslab selection */ + check = H5Sselect_shape_same(scalar_none_sid, none_hyper_sid); + VERIFY(check, TRUE, "H5Sselect_shape_same"); + + /* Compare against scalar "all" hyperslab selection */ + check = H5Sselect_shape_same(scalar_none_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5Sselect_shape_same"); /* Close dataspaces */ ret = H5Sclose(all_sid); @@ -9087,7 +9490,7 @@ test_shape_same(void) CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(scalar_none_sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_shape_same() */ +} /* test_shape_same() */ /**************************************************************** ** @@ -9118,25 +9521,25 @@ test_shape_same(void) static void test_shape_same_dr__smoke_check_1(void) { - hid_t small_square_sid; - hid_t small_cube_xy_slice_0_sid; - hid_t small_cube_xy_slice_1_sid; - hid_t small_cube_xy_slice_2_sid; - hid_t small_cube_xz_slice_0_sid; - hid_t small_cube_xz_slice_1_sid; - hid_t small_cube_xz_slice_2_sid; - hid_t small_cube_yz_slice_0_sid; - hid_t small_cube_yz_slice_1_sid; - hid_t small_cube_yz_slice_2_sid; - hid_t small_cube_yz_slice_3_sid; - hid_t small_cube_yz_slice_4_sid; - hsize_t small_cube_dims[] = {10, 10, 10}; - hsize_t start[3]; - hsize_t stride[3]; - hsize_t count[3]; - hsize_t block[3]; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hid_t small_square_sid; + hid_t small_cube_xy_slice_0_sid; + hid_t small_cube_xy_slice_1_sid; + hid_t small_cube_xy_slice_2_sid; + hid_t small_cube_xz_slice_0_sid; + hid_t small_cube_xz_slice_1_sid; + hid_t small_cube_xz_slice_2_sid; + hid_t small_cube_yz_slice_0_sid; + hid_t small_cube_yz_slice_1_sid; + hid_t small_cube_yz_slice_2_sid; + hid_t small_cube_yz_slice_3_sid; + hid_t small_cube_yz_slice_4_sid; + hsize_t small_cube_dims[] = {10, 10, 10}; + hsize_t start[3]; + hsize_t stride[3]; + hsize_t count[3]; + hsize_t block[3]; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ MESSAGE(7, (" Smoke check 1: Slices through a cube.\n")); @@ -9154,39 +9557,35 @@ test_shape_same_dr__smoke_check_1(void) small_cube_xy_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xy_slice_2_sid, FAIL, "H5Screate_simple"); - start[0] = 0; /* x */ - start[1] = 0; /* y */ - start[2] = 0; /* z */ + start[0] = 0; /* x */ + start[1] = 0; /* y */ + start[2] = 0; /* z */ /* stride is a bit silly here, since we are only selecting a single */ /* contiguous plane, but include it anyway, with values large enough */ /* to ensure that we will only get the single block selected. */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 10; /* x */ - block[1] = 10; /* y */ - block[2] = 1; /* z */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 10; /* x */ + block[1] = 10; /* y */ + block[2] = 1; /* z */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[2] = 5; - ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[2] = 9; - ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xz axis */ small_cube_xz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xz_slice_0_sid, FAIL, "H5Screate_simple"); @@ -9197,39 +9596,35 @@ test_shape_same_dr__smoke_check_1(void) small_cube_xz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xz_slice_2_sid, FAIL, "H5Screate_simple"); - start[0] = 0; /* x */ - start[1] = 0; /* y */ - start[2] = 0; /* z */ + start[0] = 0; /* x */ + start[1] = 0; /* y */ + start[2] = 0; /* z */ /* stride is a bit silly here, since we are only selecting a single */ /* contiguous chunk, but include it anyway, with values large enough */ /* to ensure that we will only get the single chunk. */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 10; /* x */ - block[1] = 1; /* y */ - block[2] = 10; /* z */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 10; /* x */ + block[1] = 1; /* y */ + block[2] = 10; /* z */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[1] = 4; - ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[1] = 9; - ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the 10 X 10 X 10 dataspaces for the hyperslabs parallel to the yz axis */ small_cube_yz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_yz_slice_0_sid, FAIL, "H5Screate_simple"); @@ -9246,57 +9641,50 @@ test_shape_same_dr__smoke_check_1(void) small_cube_yz_slice_4_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_yz_slice_4_sid, FAIL, "H5Screate_simple"); - start[0] = 0; /* x */ - start[1] = 0; /* y */ - start[2] = 0; /* z */ + start[0] = 0; /* x */ + start[1] = 0; /* y */ + start[2] = 0; /* z */ /* stride is a bit silly here, since we are only selecting a single */ /* contiguous chunk, but include it anyway, with values large enough */ /* to ensure that we will only get the single chunk. */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 1; /* x */ - block[1] = 10; /* y */ - block[2] = 10; /* z */ + block[0] = 1; /* x */ + block[1] = 10; /* y */ + block[2] = 10; /* z */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 4; - ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 9; - ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 4; block[0] = 2; - ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 3; block[0] = 1; - ret = H5Sselect_hyperslab(small_cube_yz_slice_4_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_4_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 6; - ret = H5Sselect_hyperslab(small_cube_yz_slice_4_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_4_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* setup is done -- run the tests: */ /* Compare against "xy" selection */ @@ -9309,7 +9697,6 @@ test_shape_same_dr__smoke_check_1(void) check = H5Sselect_shape_same(small_cube_xy_slice_2_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "xz" selection */ check = H5Sselect_shape_same(small_cube_xz_slice_0_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); @@ -9320,7 +9707,6 @@ test_shape_same_dr__smoke_check_1(void) check = H5Sselect_shape_same(small_cube_xz_slice_2_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "yz" selection */ check = H5Sselect_shape_same(small_cube_yz_slice_0_sid, small_square_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); @@ -9337,12 +9723,10 @@ test_shape_same_dr__smoke_check_1(void) check = H5Sselect_shape_same(small_cube_yz_slice_4_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Close dataspaces */ ret = H5Sclose(small_square_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_xy_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -9352,7 +9736,6 @@ test_shape_same_dr__smoke_check_1(void) ret = H5Sclose(small_cube_xy_slice_2_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_xz_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -9362,7 +9745,6 @@ test_shape_same_dr__smoke_check_1(void) ret = H5Sclose(small_cube_xz_slice_2_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_yz_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -9425,24 +9807,24 @@ test_shape_same_dr__smoke_check_1(void) static void test_shape_same_dr__smoke_check_2(void) { - hid_t small_square_sid; - hid_t small_cube_xy_slice_0_sid; - hid_t small_cube_xy_slice_1_sid; - hid_t small_cube_xy_slice_2_sid; - hid_t small_cube_xz_slice_0_sid; - hid_t small_cube_xz_slice_1_sid; - hid_t small_cube_xz_slice_2_sid; - hid_t small_cube_yz_slice_0_sid; - hid_t small_cube_yz_slice_1_sid; - hid_t small_cube_yz_slice_2_sid; - hid_t small_cube_yz_slice_3_sid; - hsize_t small_cube_dims[] = {10, 10, 10}; - hsize_t start[3]; - hsize_t stride[3]; - hsize_t count[3]; - hsize_t block[3]; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hid_t small_square_sid; + hid_t small_cube_xy_slice_0_sid; + hid_t small_cube_xy_slice_1_sid; + hid_t small_cube_xy_slice_2_sid; + hid_t small_cube_xz_slice_0_sid; + hid_t small_cube_xz_slice_1_sid; + hid_t small_cube_xz_slice_2_sid; + hid_t small_cube_yz_slice_0_sid; + hid_t small_cube_yz_slice_1_sid; + hid_t small_cube_yz_slice_2_sid; + hid_t small_cube_yz_slice_3_sid; + hsize_t small_cube_dims[] = {10, 10, 10}; + hsize_t start[3]; + hsize_t stride[3]; + hsize_t count[3]; + hsize_t block[3]; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ MESSAGE(7, (" Smoke check 2: Checker board slices through a cube.\n")); @@ -9450,37 +9832,34 @@ test_shape_same_dr__smoke_check_2(void) small_square_sid = H5Screate_simple(2, small_cube_dims, NULL); CHECK(small_square_sid, FAIL, "H5Screate_simple"); - start[0] = 0; /* x */ - start[1] = 0; /* y */ + start[0] = 0; /* x */ + start[1] = 0; /* y */ - stride[0] = 4; /* x */ - stride[1] = 4; /* y */ + stride[0] = 4; /* x */ + stride[1] = 4; /* y */ - count[0] = 3; /* x */ - count[1] = 3; /* y */ + count[0] = 3; /* x */ + count[1] = 3; /* y */ - block[0] = 2; /* x */ - block[1] = 2; /* y */ - ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 2; /* y */ + ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 2; /* x */ - start[1] = 2; /* y */ + start[0] = 2; /* x */ + start[1] = 2; /* y */ - stride[0] = 4; /* x */ - stride[1] = 4; /* y */ + stride[0] = 4; /* x */ + stride[1] = 4; /* y */ - count[0] = 2; /* x */ - count[1] = 2; /* y */ + count[0] = 2; /* x */ + count[1] = 2; /* y */ - block[0] = 2; /* x */ - block[1] = 2; /* y */ - ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 2; /* y */ + ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xy axis */ small_cube_xy_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xy_slice_0_sid, FAIL, "H5Screate_simple"); @@ -9491,67 +9870,58 @@ test_shape_same_dr__smoke_check_2(void) small_cube_xy_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xy_slice_2_sid, FAIL, "H5Screate_simple"); + start[0] = 0; /* x */ + start[1] = 0; /* y */ + start[2] = 0; /* z */ - start[0] = 0; /* x */ - start[1] = 0; /* y */ - start[2] = 0; /* z */ - - stride[0] = 4; /* x */ - stride[1] = 4; /* y */ - stride[2] = 20; /* z -- large enough that there will only be one slice */ + stride[0] = 4; /* x */ + stride[1] = 4; /* y */ + stride[2] = 20; /* z -- large enough that there will only be one slice */ - count[0] = 3; /* x */ - count[1] = 3; /* y */ - count[2] = 1; /* z */ + count[0] = 3; /* x */ + count[1] = 3; /* y */ + count[2] = 1; /* z */ - block[0] = 2; /* x */ - block[1] = 2; /* y */ - block[2] = 1; /* z */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 2; /* y */ + block[2] = 1; /* z */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[2] = 3; - ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[2] = 9; - ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); + start[0] = 2; /* x */ + start[1] = 2; /* y */ + start[2] = 0; /* z */ - start[0] = 2; /* x */ - start[1] = 2; /* y */ - start[2] = 0; /* z */ - - stride[0] = 4; /* x */ - stride[1] = 4; /* y */ - stride[2] = 20; /* z -- large enough that there will only be one slice */ + stride[0] = 4; /* x */ + stride[1] = 4; /* y */ + stride[2] = 20; /* z -- large enough that there will only be one slice */ - count[0] = 2; /* x */ - count[1] = 2; /* y */ - count[2] = 1; /* z */ + count[0] = 2; /* x */ + count[1] = 2; /* y */ + count[2] = 1; /* z */ - block[0] = 2; /* x */ - block[1] = 2; /* y */ - block[2] = 1; /* z */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 2; /* y */ + block[2] = 1; /* z */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[2] = 3; - ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[2] = 9; - ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xz axis */ small_cube_xz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xz_slice_0_sid, FAIL, "H5Screate_simple"); @@ -9562,66 +9932,58 @@ test_shape_same_dr__smoke_check_2(void) small_cube_xz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xz_slice_2_sid, FAIL, "H5Screate_simple"); + start[0] = 0; /* x */ + start[1] = 0; /* y */ + start[2] = 0; /* z */ - start[0] = 0; /* x */ - start[1] = 0; /* y */ - start[2] = 0; /* z */ - - stride[0] = 4; /* x */ - stride[1] = 20; /* y -- large enough that there will only be one slice */ - stride[2] = 4; /* z */ + stride[0] = 4; /* x */ + stride[1] = 20; /* y -- large enough that there will only be one slice */ + stride[2] = 4; /* z */ - count[0] = 3; /* x */ - count[1] = 1; /* y */ - count[2] = 3; /* z */ + count[0] = 3; /* x */ + count[1] = 1; /* y */ + count[2] = 3; /* z */ - block[0] = 2; /* x */ - block[1] = 1; /* y */ - block[2] = 2; /* z */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 1; /* y */ + block[2] = 2; /* z */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[1] = 5; - ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[1] = 9; - ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 2; /* x */ - start[1] = 0; /* y */ - start[2] = 2; /* z */ + start[0] = 2; /* x */ + start[1] = 0; /* y */ + start[2] = 2; /* z */ - stride[0] = 4; /* x */ - stride[1] = 20; /* y -- large enough that there will only be one slice */ - stride[2] = 4; /* z */ + stride[0] = 4; /* x */ + stride[1] = 20; /* y -- large enough that there will only be one slice */ + stride[2] = 4; /* z */ - count[0] = 2; /* x */ - count[1] = 1; /* y */ - count[2] = 2; /* z */ + count[0] = 2; /* x */ + count[1] = 1; /* y */ + count[2] = 2; /* z */ - block[0] = 2; /* x */ - block[1] = 1; /* y */ - block[2] = 2; /* z */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 1; /* y */ + block[2] = 2; /* z */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[1] = 5; - ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[1] = 9; - ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the 10 X 10 X 10 dataspaces for the hyperslabs parallel to the yz axis */ small_cube_yz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_yz_slice_0_sid, FAIL, "H5Screate_simple"); @@ -9635,68 +9997,60 @@ test_shape_same_dr__smoke_check_2(void) small_cube_yz_slice_3_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_yz_slice_3_sid, FAIL, "H5Screate_simple"); - start[0] = 0; /* x */ - start[1] = 0; /* y */ - start[2] = 0; /* z */ + start[0] = 0; /* x */ + start[1] = 0; /* y */ + start[2] = 0; /* z */ - stride[0] = 20; /* x -- large enough that there will only be one slice */ - stride[1] = 4; /* y */ - stride[2] = 4; /* z */ + stride[0] = 20; /* x -- large enough that there will only be one slice */ + stride[1] = 4; /* y */ + stride[2] = 4; /* z */ - count[0] = 1; /* x */ - count[1] = 3; /* y */ - count[2] = 3; /* z */ + count[0] = 1; /* x */ + count[1] = 3; /* y */ + count[2] = 3; /* z */ - block[0] = 1; /* x */ - block[1] = 2; /* y */ - block[2] = 2; /* z */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 1; /* x */ + block[1] = 2; /* y */ + block[2] = 2; /* z */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 8; - ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 9; - ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 3; - ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); + start[0] = 0; /* x */ + start[1] = 2; /* y */ + start[2] = 2; /* z */ - start[0] = 0; /* x */ - start[1] = 2; /* y */ - start[2] = 2; /* z */ + stride[0] = 20; /* x -- large enough that there will only be one slice */ + stride[1] = 4; /* y */ + stride[2] = 4; /* z */ - stride[0] = 20; /* x -- large enough that there will only be one slice */ - stride[1] = 4; /* y */ - stride[2] = 4; /* z */ + count[0] = 1; /* x */ + count[1] = 2; /* y */ + count[2] = 2; /* z */ - count[0] = 1; /* x */ - count[1] = 2; /* y */ - count[2] = 2; /* z */ - - block[0] = 1; /* x */ - block[1] = 2; /* y */ - block[2] = 2; /* z */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 1; /* x */ + block[1] = 2; /* y */ + block[2] = 2; /* z */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 8; - ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 9; - ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start[0] = 4; @@ -9705,11 +10059,9 @@ test_shape_same_dr__smoke_check_2(void) * the oddness looks like it is not related to my code. * -- JRM */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(small_cube_yz_slice_3_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* setup is done -- run the tests: */ /* Compare against "xy" selection */ @@ -9722,7 +10074,6 @@ test_shape_same_dr__smoke_check_2(void) check = H5Sselect_shape_same(small_cube_xy_slice_2_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "xz" selection */ check = H5Sselect_shape_same(small_cube_xz_slice_0_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); @@ -9733,7 +10084,6 @@ test_shape_same_dr__smoke_check_2(void) check = H5Sselect_shape_same(small_cube_xz_slice_2_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "yz" selection */ check = H5Sselect_shape_same(small_cube_yz_slice_0_sid, small_square_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); @@ -9747,12 +10097,10 @@ test_shape_same_dr__smoke_check_2(void) check = H5Sselect_shape_same(small_cube_yz_slice_3_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Close dataspaces */ ret = H5Sclose(small_square_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_xy_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -9762,7 +10110,6 @@ test_shape_same_dr__smoke_check_2(void) ret = H5Sclose(small_cube_xy_slice_2_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_xz_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -9772,7 +10119,6 @@ test_shape_same_dr__smoke_check_2(void) ret = H5Sclose(small_cube_xz_slice_2_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_yz_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -9787,7 +10133,6 @@ test_shape_same_dr__smoke_check_2(void) } /* test_shape_same_dr__smoke_check_2() */ - /**************************************************************** ** ** test_shape_same_dr__smoke_check_3(): @@ -9830,23 +10175,23 @@ test_shape_same_dr__smoke_check_2(void) static void test_shape_same_dr__smoke_check_3(void) { - hid_t small_square_sid; - hid_t small_cube_xy_slice_0_sid; - hid_t small_cube_xy_slice_1_sid; - hid_t small_cube_xy_slice_2_sid; - hid_t small_cube_xz_slice_0_sid; - hid_t small_cube_xz_slice_1_sid; - hid_t small_cube_xz_slice_2_sid; - hid_t small_cube_yz_slice_0_sid; - hid_t small_cube_yz_slice_1_sid; - hid_t small_cube_yz_slice_2_sid; - hsize_t small_cube_dims[] = {10, 10, 10}; - hsize_t start[3]; - hsize_t stride[3]; - hsize_t count[3]; - hsize_t block[3]; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hid_t small_square_sid; + hid_t small_cube_xy_slice_0_sid; + hid_t small_cube_xy_slice_1_sid; + hid_t small_cube_xy_slice_2_sid; + hid_t small_cube_xz_slice_0_sid; + hid_t small_cube_xz_slice_1_sid; + hid_t small_cube_xz_slice_2_sid; + hid_t small_cube_yz_slice_0_sid; + hid_t small_cube_yz_slice_1_sid; + hid_t small_cube_yz_slice_2_sid; + hsize_t small_cube_dims[] = {10, 10, 10}; + hsize_t start[3]; + hsize_t stride[3]; + hsize_t count[3]; + hsize_t block[3]; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ MESSAGE(7, (" Smoke check 3: Offset subsets of slices through a cube.\n")); @@ -9854,52 +10199,48 @@ test_shape_same_dr__smoke_check_3(void) small_square_sid = H5Screate_simple(2, small_cube_dims, NULL); CHECK(small_square_sid, FAIL, "H5Screate_simple"); - start[0] = 2; /* x */ - start[1] = 3; /* y */ + start[0] = 2; /* x */ + start[1] = 3; /* y */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ - block[0] = 2; /* x */ - block[1] = 4; /* y */ - ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 4; /* y */ + ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 3; /* x */ - start[1] = 6; /* y */ + start[0] = 3; /* x */ + start[1] = 6; /* y */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ - block[0] = 4; /* x */ - block[1] = 2; /* y */ - ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 4; /* x */ + block[1] = 2; /* y */ + ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 5; /* x */ - start[1] = 3; /* y */ + start[0] = 5; /* x */ + start[1] = 3; /* y */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ - block[0] = 2; /* x */ - block[1] = 2; /* y */ - ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 2; /* y */ + ret = H5Sselect_hyperslab(small_square_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xy axis */ small_cube_xy_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xy_slice_0_sid, FAIL, "H5Screate_simple"); @@ -9910,107 +10251,96 @@ test_shape_same_dr__smoke_check_3(void) small_cube_xy_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xy_slice_2_sid, FAIL, "H5Screate_simple"); + start[0] = 2; /* x */ + start[1] = 3; /* y */ + start[2] = 5; /* z */ - start[0] = 2; /* x */ - start[1] = 3; /* y */ - start[2] = 5; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ - - block[0] = 2; /* x */ - block[1] = 4; /* y */ - block[2] = 1; /* z */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 4; /* y */ + block[2] = 1; /* z */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[0] -= 1; /* x */ - start[1] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + start[0] -= 1; /* x */ + start[1] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[1] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + start[0] += 5; /* x */ + start[1] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 3; /* x */ - start[1] = 6; /* y */ - start[2] = 5; /* z */ + start[0] = 3; /* x */ + start[1] = 6; /* y */ + start[2] = 5; /* z */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 4; /* x */ - block[1] = 2; /* y */ - block[2] = 1; /* z */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 4; /* x */ + block[1] = 2; /* y */ + block[2] = 1; /* z */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[0] -= 1; /* x */ - start[1] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] -= 1; /* x */ + start[1] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[1] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] += 5; /* x */ + start[1] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 5; /* x */ - start[1] = 3; /* y */ - start[2] = 5; /* z */ + start[0] = 5; /* x */ + start[1] = 3; /* y */ + start[2] = 5; /* z */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 2; /* x */ - block[1] = 2; /* y */ - block[2] = 1; /* z */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 2; /* y */ + block[2] = 1; /* z */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[0] -= 1; /* x */ - start[1] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] -= 1; /* x */ + start[1] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[1] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] += 5; /* x */ + start[1] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_xy_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the 10 X 10 X 10 dataspaces for the hyperslab parallel to the xz axis */ small_cube_xz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xz_slice_0_sid, FAIL, "H5Screate_simple"); @@ -10021,108 +10351,98 @@ test_shape_same_dr__smoke_check_3(void) small_cube_xz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_xz_slice_2_sid, FAIL, "H5Screate_simple"); - start[0] = 2; /* x */ - start[1] = 5; /* y */ - start[2] = 3; /* z */ + start[0] = 2; /* x */ + start[1] = 5; /* y */ + start[2] = 3; /* z */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 2; /* x */ - block[1] = 1; /* y */ - block[2] = 4; /* z */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 1; /* y */ + block[2] = 4; /* z */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[0] -= 1; /* x */ - start[2] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + start[0] -= 1; /* x */ + start[2] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[2] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + start[0] += 5; /* x */ + start[2] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 3; /* x */ - start[1] = 5; /* y */ - start[2] = 6; /* z */ + start[0] = 3; /* x */ + start[1] = 5; /* y */ + start[2] = 6; /* z */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 4; /* x */ - block[1] = 1; /* y */ - block[2] = 2; /* z */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 4; /* x */ + block[1] = 1; /* y */ + block[2] = 2; /* z */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[0] -= 1; /* x */ - start[2] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] -= 1; /* x */ + start[2] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[2] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] += 5; /* x */ + start[2] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 5; /* x */ - start[1] = 5; /* y */ - start[2] = 3; /* z */ + start[0] = 5; /* x */ + start[1] = 5; /* y */ + start[2] = 3; /* z */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 2; /* x */ - block[1] = 1; /* y */ - block[2] = 2; /* z */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 2; /* x */ + block[1] = 1; /* y */ + block[2] = 2; /* z */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[0] -= 1; /* x */ - start[2] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] -= 1; /* x */ + start[2] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[2] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] += 5; /* x */ + start[2] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_xz_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - -/* QAK: Start here. - */ + /* QAK: Start here. + */ /* Create the 10 X 10 X 10 dataspaces for the hyperslabs parallel to the yz axis */ small_cube_yz_slice_0_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_yz_slice_0_sid, FAIL, "H5Screate_simple"); @@ -10133,106 +10453,96 @@ test_shape_same_dr__smoke_check_3(void) small_cube_yz_slice_2_sid = H5Screate_simple(3, small_cube_dims, NULL); CHECK(small_cube_yz_slice_2_sid, FAIL, "H5Screate_simple"); - start[0] = 8; /* x */ - start[1] = 2; /* y */ - start[2] = 3; /* z */ + start[0] = 8; /* x */ + start[1] = 2; /* y */ + start[2] = 3; /* z */ - stride[0] = 20; /* x -- large enough that there will only be one slice */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x -- large enough that there will only be one slice */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 1; /* x */ - block[1] = 2; /* y */ - block[2] = 4; /* z */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET, - start, stride, count, block); + block[0] = 1; /* x */ + block[1] = 2; /* y */ + block[2] = 4; /* z */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[1] -= 1; /* x */ - start[2] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET, - start, stride, count, block); + start[1] -= 1; /* x */ + start[2] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[2] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET, - start, stride, count, block); + start[0] += 5; /* x */ + start[2] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 8; /* x */ - start[1] = 3; /* y */ - start[2] = 6; /* z */ + start[0] = 8; /* x */ + start[1] = 3; /* y */ + start[2] = 6; /* z */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 1; /* x */ - block[1] = 4; /* y */ - block[2] = 2; /* z */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 1; /* x */ + block[1] = 4; /* y */ + block[2] = 2; /* z */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[1] -= 1; /* x */ - start[2] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + start[1] -= 1; /* x */ + start[2] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[2] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] += 5; /* x */ + start[2] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 8; /* x */ - start[1] = 5; /* y */ - start[2] = 3; /* z */ + start[0] = 8; /* x */ + start[1] = 5; /* y */ + start[2] = 3; /* z */ - stride[0] = 20; /* x */ - stride[1] = 20; /* y */ - stride[2] = 20; /* z */ + stride[0] = 20; /* x */ + stride[1] = 20; /* y */ + stride[2] = 20; /* z */ - count[0] = 1; /* x */ - count[1] = 1; /* y */ - count[2] = 1; /* z */ + count[0] = 1; /* x */ + count[1] = 1; /* y */ + count[2] = 1; /* z */ - block[0] = 1; /* x */ - block[1] = 2; /* y */ - block[2] = 2; /* z */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR, - start, stride, count, block); + block[0] = 1; /* x */ + block[1] = 2; /* y */ + block[2] = 2; /* z */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the starting point to the origin */ - start[1] -= 1; /* x */ - start[2] -= 2; /* y */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR, - start, stride, count, block); + start[1] -= 1; /* x */ + start[2] -= 2; /* y */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_1_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* move the irregular selection to the upper right hand corner */ - start[0] += 5; /* x */ - start[2] += 5; /* y */ - ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR, - start, stride, count, block); + start[0] += 5; /* x */ + start[2] += 5; /* y */ + ret = H5Sselect_hyperslab(small_cube_yz_slice_2_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* setup is done -- run the tests: */ /* Compare against "xy" selection */ @@ -10245,7 +10555,6 @@ test_shape_same_dr__smoke_check_3(void) check = H5Sselect_shape_same(small_cube_xy_slice_2_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "xz" selection */ check = H5Sselect_shape_same(small_cube_xz_slice_0_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); @@ -10256,7 +10565,6 @@ test_shape_same_dr__smoke_check_3(void) check = H5Sselect_shape_same(small_cube_xz_slice_2_sid, small_square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Compare against "yz" selection */ check = H5Sselect_shape_same(small_cube_yz_slice_0_sid, small_square_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); @@ -10267,12 +10575,10 @@ test_shape_same_dr__smoke_check_3(void) check = H5Sselect_shape_same(small_cube_yz_slice_2_sid, small_square_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); - /* Close dataspaces */ ret = H5Sclose(small_square_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_xy_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -10282,7 +10588,6 @@ test_shape_same_dr__smoke_check_3(void) ret = H5Sclose(small_cube_xy_slice_2_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_xz_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -10292,7 +10597,6 @@ test_shape_same_dr__smoke_check_3(void) ret = H5Sclose(small_cube_xz_slice_2_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(small_cube_yz_slice_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -10303,7 +10607,6 @@ test_shape_same_dr__smoke_check_3(void) CHECK(ret, FAIL, "H5Sclose"); } /* test_shape_same_dr__smoke_check_3() */ - /**************************************************************** ** ** test_shape_same_dr__smoke_check_4(): @@ -10337,21 +10640,21 @@ test_shape_same_dr__smoke_check_3(void) static void test_shape_same_dr__smoke_check_4(void) { - hid_t square_sid; - hid_t three_d_space_0_sid; - hid_t three_d_space_1_sid; - hid_t three_d_space_2_sid; - hid_t three_d_space_3_sid; - hid_t four_d_space_0_sid; - hid_t four_d_space_1_sid; - hid_t four_d_space_2_sid; - hid_t four_d_space_3_sid; - hid_t four_d_space_4_sid; - hid_t four_d_space_5_sid; - hid_t four_d_space_6_sid; - hsize_t dims[] = {10, 10, 10, 10}; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hid_t square_sid; + hid_t three_d_space_0_sid; + hid_t three_d_space_1_sid; + hid_t three_d_space_2_sid; + hid_t three_d_space_3_sid; + hid_t four_d_space_0_sid; + hid_t four_d_space_1_sid; + hid_t four_d_space_2_sid; + hid_t four_d_space_3_sid; + hid_t four_d_space_4_sid; + hid_t four_d_space_5_sid; + hid_t four_d_space_6_sid; + hsize_t dims[] = {10, 10, 10, 10}; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ MESSAGE(7, (" Smoke check 4: Spaces of different dimension but same size.\n")); @@ -10360,91 +10663,89 @@ test_shape_same_dr__smoke_check_4(void) CHECK(square_sid, FAIL, "H5Screate_simple"); /* create (1 X 10 X 10) dataspace */ - dims[0] = 1; - dims[1] = 10; - dims[2] = 10; + dims[0] = 1; + dims[1] = 10; + dims[2] = 10; three_d_space_0_sid = H5Screate_simple(3, dims, NULL); CHECK(three_d_space_0_sid, FAIL, "H5Screate_simple"); /* create (10 X 1 X 10) dataspace */ - dims[0] = 10; - dims[1] = 1; - dims[2] = 10; + dims[0] = 10; + dims[1] = 1; + dims[2] = 10; three_d_space_1_sid = H5Screate_simple(3, dims, NULL); CHECK(three_d_space_1_sid, FAIL, "H5Screate_simple"); /* create (10 X 10 X 1) dataspace */ - dims[0] = 10; - dims[1] = 10; - dims[2] = 1; + dims[0] = 10; + dims[1] = 10; + dims[2] = 1; three_d_space_2_sid = H5Screate_simple(3, dims, NULL); CHECK(three_d_space_2_sid, FAIL, "H5Screate_simple"); /* create (10 X 10 X 10) dataspace */ - dims[0] = 10; - dims[1] = 10; - dims[2] = 10; + dims[0] = 10; + dims[1] = 10; + dims[2] = 10; three_d_space_3_sid = H5Screate_simple(3, dims, NULL); CHECK(three_d_space_3_sid, FAIL, "H5Screate_simple"); - /* create (1 X 1 X 10 X 10) dataspace */ - dims[0] = 1; - dims[1] = 1; - dims[2] = 10; - dims[3] = 10; + dims[0] = 1; + dims[1] = 1; + dims[2] = 10; + dims[3] = 10; four_d_space_0_sid = H5Screate_simple(4, dims, NULL); CHECK(four_d_space_0_sid, FAIL, "H5Screate_simple"); /* create (1 X 10 X 1 X 10) dataspace */ - dims[0] = 1; - dims[1] = 10; - dims[2] = 1; - dims[3] = 10; + dims[0] = 1; + dims[1] = 10; + dims[2] = 1; + dims[3] = 10; four_d_space_1_sid = H5Screate_simple(4, dims, NULL); CHECK(four_d_space_1_sid, FAIL, "H5Screate_simple"); /* create (1 X 10 X 10 X 1) dataspace */ - dims[0] = 1; - dims[1] = 10; - dims[2] = 10; - dims[3] = 1; + dims[0] = 1; + dims[1] = 10; + dims[2] = 10; + dims[3] = 1; four_d_space_2_sid = H5Screate_simple(4, dims, NULL); CHECK(four_d_space_2_sid, FAIL, "H5Screate_simple"); /* create (10 X 1 X 1 X 10) dataspace */ - dims[0] = 10; - dims[1] = 1; - dims[2] = 1; - dims[3] = 10; + dims[0] = 10; + dims[1] = 1; + dims[2] = 1; + dims[3] = 10; four_d_space_3_sid = H5Screate_simple(4, dims, NULL); CHECK(four_d_space_3_sid, FAIL, "H5Screate_simple"); /* create (10 X 1 X 10 X 1) dataspace */ - dims[0] = 10; - dims[1] = 1; - dims[2] = 10; - dims[3] = 1; + dims[0] = 10; + dims[1] = 1; + dims[2] = 10; + dims[3] = 1; four_d_space_4_sid = H5Screate_simple(4, dims, NULL); CHECK(four_d_space_4_sid, FAIL, "H5Screate_simple"); /* create (10 X 10 X 1 X 1) dataspace */ - dims[0] = 10; - dims[1] = 10; - dims[2] = 1; - dims[3] = 1; + dims[0] = 10; + dims[1] = 10; + dims[2] = 1; + dims[3] = 1; four_d_space_5_sid = H5Screate_simple(4, dims, NULL); CHECK(four_d_space_5_sid, FAIL, "H5Screate_simple"); /* create (10 X 1 X 10 X 10) dataspace */ - dims[0] = 10; - dims[1] = 1; - dims[2] = 10; - dims[3] = 10; + dims[0] = 10; + dims[1] = 1; + dims[2] = 10; + dims[3] = 10; four_d_space_6_sid = H5Screate_simple(4, dims, NULL); CHECK(four_d_space_6_sid, FAIL, "H5Screate_simple"); - /* setup is done -- run the tests: */ check = H5Sselect_shape_same(three_d_space_0_sid, square_sid); @@ -10459,7 +10760,6 @@ test_shape_same_dr__smoke_check_4(void) check = H5Sselect_shape_same(three_d_space_3_sid, square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - check = H5Sselect_shape_same(four_d_space_0_sid, square_sid); VERIFY(check, TRUE, "H5Sselect_shape_same"); @@ -10481,12 +10781,10 @@ test_shape_same_dr__smoke_check_4(void) check = H5Sselect_shape_same(four_d_space_6_sid, square_sid); VERIFY(check, FALSE, "H5Sselect_shape_same"); - /* Close dataspaces */ ret = H5Sclose(square_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(three_d_space_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -10499,7 +10797,6 @@ test_shape_same_dr__smoke_check_4(void) ret = H5Sclose(three_d_space_3_sid); CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(four_d_space_0_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -10537,73 +10834,60 @@ test_shape_same_dr__smoke_check_4(void) ** ****************************************************************/ static void -test_shape_same_dr__full_space_vs_slice(int test_num, - int small_rank, - int large_rank, - int offset, - hsize_t edge_size, - hbool_t dim_selected[], - hbool_t expected_result) +test_shape_same_dr__full_space_vs_slice(int test_num, int small_rank, int large_rank, int offset, + hsize_t edge_size, hbool_t dim_selected[], hbool_t expected_result) { - char test_desc_0[128]; - char test_desc_1[256]; - int i; - hid_t n_cube_0_sid; /* the fully selected hyper cube */ - hid_t n_cube_1_sid; /* the hyper cube in which a slice is selected */ - hsize_t dims[SS_DR_MAX_RANK]; - hsize_t start[SS_DR_MAX_RANK]; - hsize_t * start_ptr; - hsize_t stride[SS_DR_MAX_RANK]; - hsize_t * stride_ptr; - hsize_t count[SS_DR_MAX_RANK]; - hsize_t * count_ptr; - hsize_t block[SS_DR_MAX_RANK]; - hsize_t * block_ptr; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ - - HDassert( 0 < small_rank ); - HDassert( small_rank <= large_rank ); - HDassert( large_rank <= SS_DR_MAX_RANK ); - HDassert( 0 <= offset ); - HDassert( offset < large_rank ); - HDassert( edge_size > 0 ); - HDassert( edge_size <= 1000 ); - - HDsprintf(test_desc_0, - "\tn-cube slice through m-cube (n <= m) test %d.\n", - test_num); + char test_desc_0[128]; + char test_desc_1[256]; + int i; + hid_t n_cube_0_sid; /* the fully selected hyper cube */ + hid_t n_cube_1_sid; /* the hyper cube in which a slice is selected */ + hsize_t dims[SS_DR_MAX_RANK]; + hsize_t start[SS_DR_MAX_RANK]; + hsize_t *start_ptr; + hsize_t stride[SS_DR_MAX_RANK]; + hsize_t *stride_ptr; + hsize_t count[SS_DR_MAX_RANK]; + hsize_t *count_ptr; + hsize_t block[SS_DR_MAX_RANK]; + hsize_t *block_ptr; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ + + HDassert(0 < small_rank); + HDassert(small_rank <= large_rank); + HDassert(large_rank <= SS_DR_MAX_RANK); + HDassert(0 <= offset); + HDassert(offset < large_rank); + HDassert(edge_size > 0); + HDassert(edge_size <= 1000); + + HDsprintf(test_desc_0, "\tn-cube slice through m-cube (n <= m) test %d.\n", test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ - HDsprintf(test_desc_1, - "\t\tranks: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d.\n", - small_rank, large_rank, offset, - (int)dim_selected[0], - (int)dim_selected[1], - (int)dim_selected[2], - (int)dim_selected[3], - (int)dim_selected[4]); + HDsprintf(test_desc_1, "\t\tranks: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d.\n", small_rank, + large_rank, offset, (int)dim_selected[0], (int)dim_selected[1], (int)dim_selected[2], + (int)dim_selected[3], (int)dim_selected[4]); MESSAGE(7, (test_desc_1)); /* copy the edge size into the dims array */ - for(i = 0; i < SS_DR_MAX_RANK; i++) + for (i = 0; i < SS_DR_MAX_RANK; i++) dims[i] = edge_size; /* Create the small n-cube */ n_cube_0_sid = H5Screate_simple(small_rank, dims, NULL); CHECK(n_cube_0_sid, FAIL, "H5Screate_simple"); - /* Create the large n-cube */ n_cube_1_sid = H5Screate_simple(large_rank, dims, NULL); CHECK(n_cube_1_sid, FAIL, "H5Screate_simple"); /* set up start, stride, count, and block for the hyperslab selection */ - for(i = 0; i < SS_DR_MAX_RANK; i++) { + for (i = 0; i < SS_DR_MAX_RANK; i++) { stride[i] = 2 * edge_size; /* a bit silly in this case */ - count[i] = 1; - if(dim_selected[i]) { + count[i] = 1; + if (dim_selected[i]) { start[i] = 0; block[i] = edge_size; } /* end if */ @@ -10611,7 +10895,7 @@ test_shape_same_dr__full_space_vs_slice(int test_num, start[i] = (hsize_t)offset; block[i] = 1; } /* end else */ - } /* end for */ + } /* end for */ /* since large rank may be less than SS_DR_MAX_RANK, we may not * use the entire start, stride, count, and block arrays. This @@ -10633,26 +10917,21 @@ test_shape_same_dr__full_space_vs_slice(int test_num, count_ptr = &(count[i]); block_ptr = &(block[i]); - /* select the hyperslab */ - ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_SET, - start_ptr, stride_ptr, count_ptr, block_ptr); + ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_SET, start_ptr, stride_ptr, count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* setup is done -- run the test: */ check = H5Sselect_shape_same(n_cube_0_sid, n_cube_1_sid); VERIFY(check, expected_result, "H5Sselect_shape_same"); - /* Close dataspaces */ ret = H5Sclose(n_cube_0_sid); CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(n_cube_1_sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_shape_same_dr__full_space_vs_slice() */ - +} /* test_shape_same_dr__full_space_vs_slice() */ /**************************************************************** ** @@ -10685,123 +10964,100 @@ test_shape_same_dr__run_full_space_vs_slice_tests(void) { hbool_t dim_selected[5]; hbool_t expected_result; - int i, j; - int v, w, x, y, z; - int test_num = 0; - int small_rank; - int large_rank; + int i, j; + int v, w, x, y, z; + int test_num = 0; + int small_rank; + int large_rank; hsize_t edge_size = 10; - for(large_rank = 1; large_rank <= 5; large_rank++) { - for(small_rank = 1; small_rank <= large_rank; small_rank++) { + for (large_rank = 1; large_rank <= 5; large_rank++) { + for (small_rank = 1; small_rank <= large_rank; small_rank++) { v = 0; do { - if(v == 0) + if (v == 0) dim_selected[0] = FALSE; else dim_selected[0] = TRUE; w = 0; do { - if(w == 0) + if (w == 0) dim_selected[1] = FALSE; else dim_selected[1] = TRUE; x = 0; do { - if(x == 0) + if (x == 0) dim_selected[2] = FALSE; else dim_selected[2] = TRUE; y = 0; do { - if(y == 0) + if (y == 0) dim_selected[3] = FALSE; else dim_selected[3] = TRUE; z = 0; do { - if(z == 0) + if (z == 0) dim_selected[4] = FALSE; else dim_selected[4] = TRUE; /* compute the expected result: */ - i = 0; - j = 4; + i = 0; + j = 4; expected_result = TRUE; - while((i < small_rank) && expected_result) { - if(!dim_selected[j]) + while ((i < small_rank) && expected_result) { + if (!dim_selected[j]) expected_result = FALSE; i++; j--; } /* end while */ - while((i < large_rank) && expected_result) { - if(dim_selected[j]) + while ((i < large_rank) && expected_result) { + if (dim_selected[j]) expected_result = FALSE; i++; j--; } /* end while */ - /* everything is set up -- run the tests */ - test_shape_same_dr__full_space_vs_slice - ( - test_num++, - small_rank, - large_rank, - 0, - edge_size, - dim_selected, - expected_result - ); - - test_shape_same_dr__full_space_vs_slice - ( - test_num++, - small_rank, - large_rank, - large_rank / 2, - edge_size, - dim_selected, - expected_result - ); - - test_shape_same_dr__full_space_vs_slice - ( - test_num++, - small_rank, - large_rank, - large_rank - 1, - edge_size, - dim_selected, - expected_result - ); + test_shape_same_dr__full_space_vs_slice(test_num++, small_rank, large_rank, 0, + edge_size, dim_selected, + expected_result); + + test_shape_same_dr__full_space_vs_slice(test_num++, small_rank, large_rank, + large_rank / 2, edge_size, + dim_selected, expected_result); + + test_shape_same_dr__full_space_vs_slice(test_num++, small_rank, large_rank, + large_rank - 1, edge_size, + dim_selected, expected_result); z++; - } while((z < 2) && (large_rank >= 1)); + } while ((z < 2) && (large_rank >= 1)); y++; - } while((y < 2) && (large_rank >= 2)); + } while ((y < 2) && (large_rank >= 2)); x++; - } while((x < 2) && (large_rank >= 3)); + } while ((x < 2) && (large_rank >= 3)); w++; - } while((w < 2) && (large_rank >= 4)); + } while ((w < 2) && (large_rank >= 4)); v++; - } while((v < 2) && (large_rank >= 5)); + } while ((v < 2) && (large_rank >= 5)); } /* end for */ - } /* end for */ + } /* end for */ } /* test_shape_same_dr__run_full_space_vs_slice_tests() */ - /**************************************************************** ** ** test_shape_same_dr__checkerboard(): Tests selection of a @@ -10819,78 +11075,64 @@ test_shape_same_dr__run_full_space_vs_slice_tests(void) ** ****************************************************************/ static void -test_shape_same_dr__checkerboard(int test_num, - int small_rank, - int large_rank, - int offset, - hsize_t edge_size, - hsize_t checker_size, - hbool_t dim_selected[], - hbool_t expected_result) +test_shape_same_dr__checkerboard(int test_num, int small_rank, int large_rank, int offset, hsize_t edge_size, + hsize_t checker_size, hbool_t dim_selected[], hbool_t expected_result) { - char test_desc_0[128]; - char test_desc_1[256]; - int i; - int dims_selected = 0; - hid_t n_cube_0_sid; /* the checker board selected - * hyper cube - */ - hid_t n_cube_1_sid; /* the hyper cube in which a - * checkerboard slice is selected - */ - hsize_t dims[SS_DR_MAX_RANK]; - hsize_t base_start[2]; - hsize_t start[SS_DR_MAX_RANK]; - hsize_t * start_ptr; - hsize_t base_stride[2]; - hsize_t stride[SS_DR_MAX_RANK]; - hsize_t * stride_ptr; - hsize_t base_count[2]; - hsize_t count[SS_DR_MAX_RANK]; - hsize_t * count_ptr; - hsize_t base_block[2]; - hsize_t block[SS_DR_MAX_RANK]; - hsize_t * block_ptr; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ - - HDassert( 0 < small_rank ); - HDassert( small_rank <= large_rank ); - HDassert( large_rank <= SS_DR_MAX_RANK ); - HDassert( 0 < checker_size ); - HDassert( checker_size <= edge_size ); - HDassert( edge_size <= 1000 ); - HDassert( 0 <= offset ); - HDassert( offset < (int)edge_size ); - - for(i = SS_DR_MAX_RANK - large_rank; i < SS_DR_MAX_RANK; i++) - if(dim_selected[i] == TRUE) + char test_desc_0[128]; + char test_desc_1[256]; + int i; + int dims_selected = 0; + hid_t n_cube_0_sid; /* the checker board selected + * hyper cube + */ + hid_t n_cube_1_sid; /* the hyper cube in which a + * checkerboard slice is selected + */ + hsize_t dims[SS_DR_MAX_RANK]; + hsize_t base_start[2]; + hsize_t start[SS_DR_MAX_RANK]; + hsize_t *start_ptr; + hsize_t base_stride[2]; + hsize_t stride[SS_DR_MAX_RANK]; + hsize_t *stride_ptr; + hsize_t base_count[2]; + hsize_t count[SS_DR_MAX_RANK]; + hsize_t *count_ptr; + hsize_t base_block[2]; + hsize_t block[SS_DR_MAX_RANK]; + hsize_t *block_ptr; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ + + HDassert(0 < small_rank); + HDassert(small_rank <= large_rank); + HDassert(large_rank <= SS_DR_MAX_RANK); + HDassert(0 < checker_size); + HDassert(checker_size <= edge_size); + HDassert(edge_size <= 1000); + HDassert(0 <= offset); + HDassert(offset < (int)edge_size); + + for (i = SS_DR_MAX_RANK - large_rank; i < SS_DR_MAX_RANK; i++) + if (dim_selected[i] == TRUE) dims_selected++; - HDassert( dims_selected >= 0 ); - HDassert( dims_selected <= large_rank ); + HDassert(dims_selected >= 0); + HDassert(dims_selected <= large_rank); - HDsprintf(test_desc_0, - "\tcheckerboard n-cube slice through m-cube (n <= m) test %d.\n", - test_num); + HDsprintf(test_desc_0, "\tcheckerboard n-cube slice through m-cube (n <= m) test %d.\n", test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ HDsprintf(test_desc_1, "\tranks: %d/%d edge/chkr size: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d:%d.\n", - small_rank, large_rank, - (int)edge_size, (int)checker_size, - offset, - (int)dim_selected[0], - (int)dim_selected[1], - (int)dim_selected[2], - (int)dim_selected[3], - (int)dim_selected[4], + small_rank, large_rank, (int)edge_size, (int)checker_size, offset, (int)dim_selected[0], + (int)dim_selected[1], (int)dim_selected[2], (int)dim_selected[3], (int)dim_selected[4], dims_selected); MESSAGE(7, (test_desc_1)); /* copy the edge size into the dims array */ - for(i = 0; i < SS_DR_MAX_RANK; i++) + for (i = 0; i < SS_DR_MAX_RANK; i++) dims[i] = edge_size; /* Create the small n-cube */ @@ -10966,11 +11208,11 @@ test_shape_same_dr__checkerboard(int test_num, */ base_count[0] = edge_size / (checker_size * 2); - if((edge_size % (checker_size * 2)) > 0) - base_count[0]++; + if ((edge_size % (checker_size * 2)) > 0) + base_count[0]++; base_count[1] = (edge_size - checker_size) / (checker_size * 2); - if(((edge_size - checker_size) % (checker_size * 2)) > 0) + if (((edge_size - checker_size) % (checker_size * 2)) > 0) base_count[1]++; base_block[0] = checker_size; @@ -10979,15 +11221,14 @@ test_shape_same_dr__checkerboard(int test_num, /* now setup start, stride, count, and block arrays for * the first call to H5Sselect_hyperslab(). */ - for(i = 0; i < SS_DR_MAX_RANK; i++) { + for (i = 0; i < SS_DR_MAX_RANK; i++) { start[i] = base_start[0]; stride[i] = base_stride[0]; count[i] = base_count[0]; block[i] = base_block[0]; } /* end for */ - ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_SET, - start, stride, count, block); + ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* if small_rank == 1, or if edge_size == checker_size, we @@ -10998,16 +11239,15 @@ test_shape_same_dr__checkerboard(int test_num, * make the additional selection. */ - if((small_rank > 1) && (checker_size < edge_size)) { - for(i = 0; i < SS_DR_MAX_RANK; i++) { + if ((small_rank > 1) && (checker_size < edge_size)) { + for (i = 0; i < SS_DR_MAX_RANK; i++) { start[i] = base_start[1]; stride[i] = base_stride[1]; count[i] = base_count[1]; block[i] = base_block[1]; } /* end for */ - ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_OR, - start, stride, count, block); + ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end if */ @@ -11018,31 +11258,28 @@ test_shape_same_dr__checkerboard(int test_num, * code to manually clip the selection back to the dataspace * proper. */ - for(i = 0; i < SS_DR_MAX_RANK; i++) { + for (i = 0; i < SS_DR_MAX_RANK; i++) { start[i] = 0; stride[i] = edge_size; count[i] = 1; block[i] = edge_size; } /* end for */ - ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_AND, - start, stride, count, block); + ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_AND, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the large n-cube */ n_cube_1_sid = H5Screate_simple(large_rank, dims, NULL); CHECK(n_cube_1_sid, FAIL, "H5Screate_simple"); - /* Now select the checkerboard selection in the (possibly larger) n-cube. * * Since we have already calculated the base start, stride, count, * and block, re-use the values in setting up start, stride, count, * and block. */ - for(i = 0; i < SS_DR_MAX_RANK; i++) { - if(dim_selected[i]) { + for (i = 0; i < SS_DR_MAX_RANK; i++) { + if (dim_selected[i]) { start[i] = base_start[0]; stride[i] = base_stride[0]; count[i] = base_count[0]; @@ -11054,7 +11291,7 @@ test_shape_same_dr__checkerboard(int test_num, count[i] = 1; block[i] = 1; } /* end else */ - } /* end for */ + } /* end for */ /* Since large rank may be less than SS_DR_MAX_RANK, we may not * use the entire start, stride, count, and block arrays. This @@ -11069,7 +11306,7 @@ test_shape_same_dr__checkerboard(int test_num, */ i = SS_DR_MAX_RANK - large_rank; - HDassert( i >= 0 ); + HDassert(i >= 0); start_ptr = &(start[i]); stride_ptr = &(stride[i]); @@ -11077,8 +11314,7 @@ test_shape_same_dr__checkerboard(int test_num, block_ptr = &(block[i]); /* select the hyperslab */ - ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_SET, - start_ptr, stride_ptr, count_ptr, block_ptr); + ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_SET, start_ptr, stride_ptr, count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* As before, if the number of dimensions selected is less than or @@ -11090,9 +11326,9 @@ test_shape_same_dr__checkerboard(int test_num, * Otherwise, set up start, stride, count and block, and * make the additional selection. */ - if((dims_selected > 1) && (checker_size < edge_size)) { - for(i = 0; i < SS_DR_MAX_RANK; i++) { - if(dim_selected[i]) { + if ((dims_selected > 1) && (checker_size < edge_size)) { + for (i = 0; i < SS_DR_MAX_RANK; i++) { + if (dim_selected[i]) { start[i] = base_start[1]; stride[i] = base_stride[1]; count[i] = base_count[1]; @@ -11104,14 +11340,12 @@ test_shape_same_dr__checkerboard(int test_num, count[i] = 1; block[i] = 1; } /* end else */ - } /* end for */ + } /* end for */ - ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_OR, - start_ptr, stride_ptr, count_ptr, block_ptr); + ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_OR, start_ptr, stride_ptr, count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end if */ - /* Wierdness alert: * * Again, it seems that selections can extend beyond the @@ -11119,30 +11353,27 @@ test_shape_same_dr__checkerboard(int test_num, * code to manually clip the selection back to the dataspace * proper. */ - for(i = 0; i < SS_DR_MAX_RANK; i++) { + for (i = 0; i < SS_DR_MAX_RANK; i++) { start[i] = 0; stride[i] = edge_size; count[i] = 1; block[i] = edge_size; } /* end for */ - ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_AND, - start, stride, count, block); + ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_AND, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* setup is done -- run the test: */ check = H5Sselect_shape_same(n_cube_0_sid, n_cube_1_sid); VERIFY(check, expected_result, "H5Sselect_shape_same"); - /* Close dataspaces */ ret = H5Sclose(n_cube_0_sid); CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(n_cube_1_sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_shape_same_dr__checkerboard() */ - +} /* test_shape_same_dr__checkerboard() */ /**************************************************************** ** @@ -11171,249 +11402,171 @@ test_shape_same_dr__run_checkerboard_tests(void) { hbool_t dim_selected[5]; hbool_t expected_result; - int i, j; - int v, w, x, y, z; - int test_num = 0; - int small_rank; - int large_rank; - - for(large_rank = 1; large_rank <= 5; large_rank++) { - for(small_rank = 1; small_rank <= large_rank; small_rank++) { + int i, j; + int v, w, x, y, z; + int test_num = 0; + int small_rank; + int large_rank; + + for (large_rank = 1; large_rank <= 5; large_rank++) { + for (small_rank = 1; small_rank <= large_rank; small_rank++) { v = 0; do { - if(v == 0) + if (v == 0) dim_selected[0] = FALSE; else dim_selected[0] = TRUE; w = 0; do { - if(w == 0) + if (w == 0) dim_selected[1] = FALSE; else dim_selected[1] = TRUE; x = 0; do { - if(x == 0) + if (x == 0) dim_selected[2] = FALSE; else dim_selected[2] = TRUE; y = 0; do { - if(y == 0) + if (y == 0) dim_selected[3] = FALSE; else dim_selected[3] = TRUE; z = 0; do { - if(z == 0) + if (z == 0) dim_selected[4] = FALSE; else dim_selected[4] = TRUE; - /* compute the expected result: */ - i = 0; - j = 4; + i = 0; + j = 4; expected_result = TRUE; - while((i < small_rank) && expected_result) { - if(!dim_selected[j]) + while ((i < small_rank) && expected_result) { + if (!dim_selected[j]) expected_result = FALSE; i++; j--; } /* end while */ - while((i < large_rank) && expected_result) { - if(dim_selected[j]) + while ((i < large_rank) && expected_result) { + if (dim_selected[j]) expected_result = FALSE; i++; j--; } /* end while */ - /* everything is set up -- run the tests */ /* run test with edge size 16, checker * size 1, and a variety of offsets */ - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 0, - /* edge_size */ 16, - /* checker_size */ 1, - dim_selected, - expected_result - ); - - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 5, - /* edge_size */ 16, - /* checker_size */ 1, - dim_selected, - expected_result - ); - - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 15, - /* edge_size */ 16, - /* checker_size */ 1, - dim_selected, - expected_result - ); - + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 0, + /* edge_size */ 16, + /* checker_size */ 1, dim_selected, + expected_result); + + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 5, + /* edge_size */ 16, + /* checker_size */ 1, dim_selected, + expected_result); + + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 15, + /* edge_size */ 16, + /* checker_size */ 1, dim_selected, + expected_result); /* run test with edge size 10, checker * size 2, and a variety of offsets */ - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 0, - /* edge_size */ 10, - /* checker_size */ 2, - dim_selected, - expected_result - ); - - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 5, - /* edge_size */ 10, - /* checker_size */ 2, - dim_selected, - expected_result - ); - - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 9, - /* edge_size */ 10, - /* checker_size */ 2, - dim_selected, - expected_result - ); - + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 0, + /* edge_size */ 10, + /* checker_size */ 2, dim_selected, + expected_result); + + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 5, + /* edge_size */ 10, + /* checker_size */ 2, dim_selected, + expected_result); + + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 9, + /* edge_size */ 10, + /* checker_size */ 2, dim_selected, + expected_result); /* run test with edge size 10, checker * size 3, and a variety of offsets */ - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 0, - /* edge_size */ 10, - /* checker_size */ 3, - dim_selected, - expected_result - ); - - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 5, - /* edge_size */ 10, - /* checker_size */ 3, - dim_selected, - expected_result - ); - - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 9, - /* edge_size */ 10, - /* checker_size */ 3, - dim_selected, - expected_result - ); - + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 0, + /* edge_size */ 10, + /* checker_size */ 3, dim_selected, + expected_result); + + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 5, + /* edge_size */ 10, + /* checker_size */ 3, dim_selected, + expected_result); + + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 9, + /* edge_size */ 10, + /* checker_size */ 3, dim_selected, + expected_result); /* run test with edge size 8, checker * size 8, and a variety of offsets */ - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 0, - /* edge_size */ 8, - /* checker_size */ 8, - dim_selected, - expected_result - ); - - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 4, - /* edge_size */ 8, - /* checker_size */ 8, - dim_selected, - expected_result - ); - - test_shape_same_dr__checkerboard - ( - test_num++, - small_rank, - large_rank, - /* offset */ 7, - /* edge_size */ 8, - /* checker_size */ 8, - dim_selected, - expected_result - ); + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 0, + /* edge_size */ 8, + /* checker_size */ 8, dim_selected, + expected_result); + + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 4, + /* edge_size */ 8, + /* checker_size */ 8, dim_selected, + expected_result); + + test_shape_same_dr__checkerboard(test_num++, small_rank, large_rank, + /* offset */ 7, + /* edge_size */ 8, + /* checker_size */ 8, dim_selected, + expected_result); z++; - } while((z < 2) && (large_rank >= 1)); + } while ((z < 2) && (large_rank >= 1)); y++; - } while((y < 2) && (large_rank >= 2)); + } while ((y < 2) && (large_rank >= 2)); x++; - } while((x < 2) && (large_rank >= 3)); + } while ((x < 2) && (large_rank >= 3)); w++; - } while((w < 2) && (large_rank >= 4)); + } while ((w < 2) && (large_rank >= 4)); v++; - } while((v < 2) && (large_rank >= 5)); + } while ((v < 2) && (large_rank >= 5)); } /* end for */ - } /* end for */ + } /* end for */ } /* test_shape_same_dr__run_checkerboard_tests() */ - /**************************************************************** ** ** test_shape_same_dr__irregular(): @@ -11430,118 +11583,100 @@ test_shape_same_dr__run_checkerboard_tests(void) ** ****************************************************************/ static void -test_shape_same_dr__irregular(int test_num, - int small_rank, - int large_rank, - int pattern_offset, - int slice_offset, - hbool_t dim_selected[], - hbool_t expected_result) +test_shape_same_dr__irregular(int test_num, int small_rank, int large_rank, int pattern_offset, + int slice_offset, hbool_t dim_selected[], hbool_t expected_result) { - char test_desc_0[128]; - char test_desc_1[256]; - int edge_size = 10; - int i; - int j; - int k; - int dims_selected = 0; - hid_t n_cube_0_sid; /* the hyper cube containing - * an irregular selection - */ - hid_t n_cube_1_sid; /* the hyper cube in which a - * slice contains an irregular - * selection. - */ - hsize_t dims[SS_DR_MAX_RANK]; - hsize_t start_0[SS_DR_MAX_RANK] = { 2, 2, 2, 2, 5}; - hsize_t stride_0[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; - hsize_t count_0[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1}; - hsize_t block_0[SS_DR_MAX_RANK] = { 2, 2, 2, 2, 3}; - - hsize_t start_1[SS_DR_MAX_RANK] = { 2, 2, 2, 5, 2}; - hsize_t stride_1[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; - hsize_t count_1[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1}; - hsize_t block_1[SS_DR_MAX_RANK] = { 2, 2, 2, 3, 2}; - - hsize_t start_2[SS_DR_MAX_RANK] = { 2, 2, 5, 2, 2}; - hsize_t stride_2[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; - hsize_t count_2[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1}; - hsize_t block_2[SS_DR_MAX_RANK] = { 2, 2, 3, 2, 2}; - - hsize_t start_3[SS_DR_MAX_RANK] = { 2, 5, 2, 2, 2}; - hsize_t stride_3[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; - hsize_t count_3[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1}; - hsize_t block_3[SS_DR_MAX_RANK] = { 2, 3, 2, 2, 2}; - - hsize_t start_4[SS_DR_MAX_RANK] = { 5, 2, 2, 2, 2}; - hsize_t stride_4[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; - hsize_t count_4[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1}; - hsize_t block_4[SS_DR_MAX_RANK] = { 3, 2, 2, 2, 2}; - - hsize_t clip_start[SS_DR_MAX_RANK] = { 0, 0, 0, 0, 0}; - hsize_t clip_stride[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; - hsize_t clip_count[SS_DR_MAX_RANK] = { 1, 1, 1, 1, 1}; - hsize_t clip_block[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; - - - hsize_t *(starts[SS_DR_MAX_RANK]) = - {start_0, start_1, start_2, start_3, start_4}; - hsize_t *(strides[SS_DR_MAX_RANK]) = - {stride_0, stride_1, stride_2, stride_3, stride_4}; - hsize_t *(counts[SS_DR_MAX_RANK]) = - {count_0, count_1, count_2, count_3, count_4}; - hsize_t *(blocks[SS_DR_MAX_RANK]) = - {block_0, block_1, block_2, block_3, block_4}; - - hsize_t start[SS_DR_MAX_RANK]; - hsize_t * start_ptr; - hsize_t stride[SS_DR_MAX_RANK]; - hsize_t * stride_ptr; - hsize_t count[SS_DR_MAX_RANK]; - hsize_t * count_ptr; - hsize_t block[SS_DR_MAX_RANK]; - hsize_t * block_ptr; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ - - HDassert( 0 < small_rank ); - HDassert( small_rank <= large_rank ); - HDassert( large_rank <= SS_DR_MAX_RANK ); - HDassert( 9 <= edge_size ); - HDassert( edge_size <= 1000 ); - HDassert( 0 <= slice_offset ); - HDassert( slice_offset < edge_size ); - HDassert( -2 <= pattern_offset ); - HDassert( pattern_offset <= 2 ); - - for(i = SS_DR_MAX_RANK - large_rank; i < SS_DR_MAX_RANK; i++) - if(dim_selected[i] == TRUE) + char test_desc_0[128]; + char test_desc_1[256]; + int edge_size = 10; + int i; + int j; + int k; + int dims_selected = 0; + hid_t n_cube_0_sid; /* the hyper cube containing + * an irregular selection + */ + hid_t n_cube_1_sid; /* the hyper cube in which a + * slice contains an irregular + * selection. + */ + hsize_t dims[SS_DR_MAX_RANK]; + hsize_t start_0[SS_DR_MAX_RANK] = {2, 2, 2, 2, 5}; + hsize_t stride_0[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; + hsize_t count_0[SS_DR_MAX_RANK] = {1, 1, 1, 1, 1}; + hsize_t block_0[SS_DR_MAX_RANK] = {2, 2, 2, 2, 3}; + + hsize_t start_1[SS_DR_MAX_RANK] = {2, 2, 2, 5, 2}; + hsize_t stride_1[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; + hsize_t count_1[SS_DR_MAX_RANK] = {1, 1, 1, 1, 1}; + hsize_t block_1[SS_DR_MAX_RANK] = {2, 2, 2, 3, 2}; + + hsize_t start_2[SS_DR_MAX_RANK] = {2, 2, 5, 2, 2}; + hsize_t stride_2[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; + hsize_t count_2[SS_DR_MAX_RANK] = {1, 1, 1, 1, 1}; + hsize_t block_2[SS_DR_MAX_RANK] = {2, 2, 3, 2, 2}; + + hsize_t start_3[SS_DR_MAX_RANK] = {2, 5, 2, 2, 2}; + hsize_t stride_3[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; + hsize_t count_3[SS_DR_MAX_RANK] = {1, 1, 1, 1, 1}; + hsize_t block_3[SS_DR_MAX_RANK] = {2, 3, 2, 2, 2}; + + hsize_t start_4[SS_DR_MAX_RANK] = {5, 2, 2, 2, 2}; + hsize_t stride_4[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; + hsize_t count_4[SS_DR_MAX_RANK] = {1, 1, 1, 1, 1}; + hsize_t block_4[SS_DR_MAX_RANK] = {3, 2, 2, 2, 2}; + + hsize_t clip_start[SS_DR_MAX_RANK] = {0, 0, 0, 0, 0}; + hsize_t clip_stride[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; + hsize_t clip_count[SS_DR_MAX_RANK] = {1, 1, 1, 1, 1}; + hsize_t clip_block[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; + + hsize_t *(starts[SS_DR_MAX_RANK]) = {start_0, start_1, start_2, start_3, start_4}; + hsize_t *(strides[SS_DR_MAX_RANK]) = {stride_0, stride_1, stride_2, stride_3, stride_4}; + hsize_t *(counts[SS_DR_MAX_RANK]) = {count_0, count_1, count_2, count_3, count_4}; + hsize_t *(blocks[SS_DR_MAX_RANK]) = {block_0, block_1, block_2, block_3, block_4}; + + hsize_t start[SS_DR_MAX_RANK]; + hsize_t *start_ptr; + hsize_t stride[SS_DR_MAX_RANK]; + hsize_t *stride_ptr; + hsize_t count[SS_DR_MAX_RANK]; + hsize_t *count_ptr; + hsize_t block[SS_DR_MAX_RANK]; + hsize_t *block_ptr; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ + + HDassert(0 < small_rank); + HDassert(small_rank <= large_rank); + HDassert(large_rank <= SS_DR_MAX_RANK); + HDassert(9 <= edge_size); + HDassert(edge_size <= 1000); + HDassert(0 <= slice_offset); + HDassert(slice_offset < edge_size); + HDassert(-2 <= pattern_offset); + HDassert(pattern_offset <= 2); + + for (i = SS_DR_MAX_RANK - large_rank; i < SS_DR_MAX_RANK; i++) + if (dim_selected[i] == TRUE) dims_selected++; - HDassert( dims_selected >= 0 ); - HDassert( dims_selected <= large_rank ); + HDassert(dims_selected >= 0); + HDassert(dims_selected <= large_rank); - HDsprintf(test_desc_0, - "\tirregular sub set of n-cube slice through m-cube (n <= m) test %d.\n", + HDsprintf(test_desc_0, "\tirregular sub set of n-cube slice through m-cube (n <= m) test %d.\n", test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ - HDsprintf(test_desc_1, - "\tranks: %d/%d edge: %d s/p offset: %d/%d dim_selected: %d/%d/%d/%d/%d:%d.\n", - small_rank, large_rank, - edge_size, - slice_offset, pattern_offset, - (int)dim_selected[0], - (int)dim_selected[1], - (int)dim_selected[2], - (int)dim_selected[3], - (int)dim_selected[4], + HDsprintf(test_desc_1, "\tranks: %d/%d edge: %d s/p offset: %d/%d dim_selected: %d/%d/%d/%d/%d:%d.\n", + small_rank, large_rank, edge_size, slice_offset, pattern_offset, (int)dim_selected[0], + (int)dim_selected[1], (int)dim_selected[2], (int)dim_selected[3], (int)dim_selected[4], dims_selected); MESSAGE(7, (test_desc_1)); /* copy the edge size into the dims array */ - for(i = 0; i < SS_DR_MAX_RANK; i++) + for (i = 0; i < SS_DR_MAX_RANK; i++) dims[i] = (hsize_t)edge_size; /* Create the small n-cube */ @@ -11592,20 +11727,17 @@ test_shape_same_dr__irregular(int test_num, CHECK(ret, FAIL, "H5Sselect_none"); /* now, select the irregular pattern */ - for(i = 0; i < SS_DR_MAX_RANK; i++) { - ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_OR, - starts[i], strides[i], counts[i], blocks[i]); + for (i = 0; i < SS_DR_MAX_RANK; i++) { + ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_OR, starts[i], strides[i], counts[i], blocks[i]); CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end for */ /* finally, clip the selection to ensure that it lies fully * within the n-cube. */ - ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_AND, - clip_start, clip_stride, clip_count, clip_block); + ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_AND, clip_start, clip_stride, clip_count, clip_block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Create the large n-cube */ n_cube_1_sid = H5Screate_simple(large_rank, dims, NULL); CHECK(n_cube_1_sid, FAIL, "H5Screate_simple"); @@ -11614,7 +11746,6 @@ test_shape_same_dr__irregular(int test_num, H5Sselect_none(n_cube_1_sid); CHECK(ret, FAIL, "H5Sselect_none"); - /* Since large rank may be less than SS_DR_MAX_RANK, we may not * use the entire start, stride, count, and block arrays. This * is a problem, since it is inconvenient to set up the dim_selected @@ -11628,24 +11759,23 @@ test_shape_same_dr__irregular(int test_num, */ i = SS_DR_MAX_RANK - large_rank; - HDassert( i >= 0 ); + HDassert(i >= 0); start_ptr = &(start[i]); stride_ptr = &(stride[i]); count_ptr = &(count[i]); block_ptr = &(block[i]); - /* Now select the irregular selection in the (possibly larger) n-cube. * * Basic idea is to project the pattern used in the smaller n-cube * onto the dimensions selected in the larger n-cube, with the displacement * specified. */ - for(i = 0; i < SS_DR_MAX_RANK; i++) { + for (i = 0; i < SS_DR_MAX_RANK; i++) { j = 0; - for(k = 0; k < SS_DR_MAX_RANK; k++) { - if(dim_selected[k]) { + for (k = 0; k < SS_DR_MAX_RANK; k++) { + if (dim_selected[k]) { start[k] = (starts[i])[j] + (hsize_t)pattern_offset; stride[k] = (strides[i])[j]; count[k] = (counts[i])[j]; @@ -11658,35 +11788,30 @@ test_shape_same_dr__irregular(int test_num, count[k] = 1; block[k] = 1; } /* end else */ - } /* end for */ + } /* end for */ /* select the hyperslab */ - ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_OR, - start_ptr, stride_ptr, count_ptr, block_ptr); + ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_OR, start_ptr, stride_ptr, count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end for */ /* it is possible that the selection extends beyond the dataspace. * clip the selection to ensure that it doesn't. */ - ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_AND, - clip_start, clip_stride, clip_count, clip_block); + ret = H5Sselect_hyperslab(n_cube_1_sid, H5S_SELECT_AND, clip_start, clip_stride, clip_count, clip_block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* setup is done -- run the test: */ check = H5Sselect_shape_same(n_cube_0_sid, n_cube_1_sid); VERIFY(check, expected_result, "H5Sselect_shape_same"); - /* Close dataspaces */ ret = H5Sclose(n_cube_0_sid); CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(n_cube_1_sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_shape_same_dr__irregular() */ - +} /* test_shape_same_dr__irregular() */ /**************************************************************** ** @@ -11717,191 +11842,132 @@ test_shape_same_dr__run_irregular_tests(void) { hbool_t dim_selected[5]; hbool_t expected_result; - int i, j; - int v, w, x, y, z; - int test_num = 0; - int small_rank; - int large_rank; - - for(large_rank = 1; large_rank <= 5; large_rank++) { - for(small_rank = 1; small_rank <= large_rank; small_rank++) { + int i, j; + int v, w, x, y, z; + int test_num = 0; + int small_rank; + int large_rank; + + for (large_rank = 1; large_rank <= 5; large_rank++) { + for (small_rank = 1; small_rank <= large_rank; small_rank++) { v = 0; do { - if(v == 0) + if (v == 0) dim_selected[0] = FALSE; else dim_selected[0] = TRUE; w = 0; do { - if(w == 0) + if (w == 0) dim_selected[1] = FALSE; else dim_selected[1] = TRUE; x = 0; do { - if(x == 0) + if (x == 0) dim_selected[2] = FALSE; else dim_selected[2] = TRUE; y = 0; do { - if(y == 0) + if (y == 0) dim_selected[3] = FALSE; else dim_selected[3] = TRUE; z = 0; do { - if(z == 0) + if (z == 0) dim_selected[4] = FALSE; else dim_selected[4] = TRUE; - /* compute the expected result: */ - i = 0; - j = 4; + i = 0; + j = 4; expected_result = TRUE; - while((i < small_rank) && expected_result) { - if(!dim_selected[j]) + while ((i < small_rank) && expected_result) { + if (!dim_selected[j]) expected_result = FALSE; i++; j--; } /* end while */ - while((i < large_rank) && expected_result) { - if(dim_selected[j]) + while ((i < large_rank) && expected_result) { + if (dim_selected[j]) expected_result = FALSE; i++; j--; } /* end while */ - /* everything is set up -- run the tests */ - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ -2, - /* slice_offset */ 0, - dim_selected, - expected_result - ); - - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ -2, - /* slice_offset */ 4, - dim_selected, - expected_result - ); - - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ -2, - /* slice_offset */ 9, - dim_selected, - expected_result - ); - - - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ 0, - /* slice_offset */ 0, - dim_selected, - expected_result - ); - - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ 0, - /* slice_offset */ 6, - dim_selected, - expected_result - ); - - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ 0, - /* slice_offset */ 9, - dim_selected, - expected_result - ); - - - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ 2, - /* slice_offset */ 0, - dim_selected, - expected_result - ); - - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ 2, - /* slice_offset */ 5, - dim_selected, - expected_result - ); - - test_shape_same_dr__irregular - ( - test_num++, - small_rank, - large_rank, - /* pattern_offset */ 2, - /* slice_offset */ 9, - dim_selected, - expected_result - ); + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ -2, + /* slice_offset */ 0, dim_selected, + expected_result); + + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ -2, + /* slice_offset */ 4, dim_selected, + expected_result); + + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ -2, + /* slice_offset */ 9, dim_selected, + expected_result); + + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ 0, + /* slice_offset */ 0, dim_selected, + expected_result); + + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ 0, + /* slice_offset */ 6, dim_selected, + expected_result); + + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ 0, + /* slice_offset */ 9, dim_selected, + expected_result); + + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ 2, + /* slice_offset */ 0, dim_selected, + expected_result); + + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ 2, + /* slice_offset */ 5, dim_selected, + expected_result); + + test_shape_same_dr__irregular(test_num++, small_rank, large_rank, + /* pattern_offset */ 2, + /* slice_offset */ 9, dim_selected, + expected_result); z++; - } while((z < 2) && (large_rank >= 1)); + } while ((z < 2) && (large_rank >= 1)); y++; - } while((y < 2) && (large_rank >= 2)); + } while ((y < 2) && (large_rank >= 2)); x++; - } while((x < 2) && (large_rank >= 3)); + } while ((x < 2) && (large_rank >= 3)); w++; - } while((w < 2) && (large_rank >= 4)); + } while ((w < 2) && (large_rank >= 4)); v++; - } while((v < 2 ) && (large_rank >= 5)); + } while ((v < 2) && (large_rank >= 5)); } /* end for */ - } /* end for */ + } /* end for */ } /* test_shape_same_dr__run_irregular_tests() */ - /**************************************************************** ** ** test_shape_same_dr(): Tests selections on dataspace with @@ -11925,8 +11991,7 @@ test_shape_same_dr(void) test_shape_same_dr__run_full_space_vs_slice_tests(); test_shape_same_dr__run_checkerboard_tests(); test_shape_same_dr__run_irregular_tests(); -} /* test_shape_same_dr() */ - +} /* test_shape_same_dr() */ /**************************************************************** ** @@ -11939,67 +12004,61 @@ test_shape_same_dr(void) static void test_space_rebuild(void) { - /* regular space IDs in span-tree form */ - hid_t sid_reg1,sid_reg2,sid_reg3,sid_reg4,sid_reg5; - - /* Original regular Space IDs */ - hid_t sid_reg_ori1,sid_reg_ori2,sid_reg_ori3,sid_reg_ori4,sid_reg_ori5; + /* regular space IDs in span-tree form */ + hid_t sid_reg1, sid_reg2, sid_reg3, sid_reg4, sid_reg5; - /* Irregular space IDs */ - hid_t sid_irreg1,sid_irreg2,sid_irreg3,sid_irreg4,sid_irreg5; + /* Original regular Space IDs */ + hid_t sid_reg_ori1, sid_reg_ori2, sid_reg_ori3, sid_reg_ori4, sid_reg_ori5; - /* rebuild status state */ - H5S_diminfo_valid_t rebuild_stat1,rebuild_stat2; - htri_t rebuild_check; - herr_t ret; + /* Irregular space IDs */ + hid_t sid_irreg1, sid_irreg2, sid_irreg3, sid_irreg4, sid_irreg5; - /* dimensions of rank 1 to rank 5 */ - hsize_t dims1[] ={SPACERE1_DIM0}; - hsize_t dims2[] ={SPACERE2_DIM0,SPACERE2_DIM1}; - hsize_t dims3[] ={SPACERE3_DIM0,SPACERE3_DIM1,SPACERE3_DIM2}; - hsize_t dims4[] ={SPACERE4_DIM0,SPACERE4_DIM1,SPACERE4_DIM2,SPACERE4_DIM3}; - hsize_t dims5[] ={SPACERE5_DIM0,SPACERE5_DIM1,SPACERE5_DIM2,SPACERE5_DIM3,SPACERE5_DIM4}; + /* rebuild status state */ + H5S_diminfo_valid_t rebuild_stat1, rebuild_stat2; + htri_t rebuild_check; + herr_t ret; - /* The start of the hyperslab */ - hsize_t start1[SPACERE1_RANK],start2[SPACERE2_RANK], - start3[SPACERE3_RANK],start4[SPACERE4_RANK], - start5[SPACERE5_RANK]; + /* dimensions of rank 1 to rank 5 */ + hsize_t dims1[] = {SPACERE1_DIM0}; + hsize_t dims2[] = {SPACERE2_DIM0, SPACERE2_DIM1}; + hsize_t dims3[] = {SPACERE3_DIM0, SPACERE3_DIM1, SPACERE3_DIM2}; + hsize_t dims4[] = {SPACERE4_DIM0, SPACERE4_DIM1, SPACERE4_DIM2, SPACERE4_DIM3}; + hsize_t dims5[] = {SPACERE5_DIM0, SPACERE5_DIM1, SPACERE5_DIM2, SPACERE5_DIM3, SPACERE5_DIM4}; - /* The stride of the hyperslab */ - hsize_t stride1[SPACERE1_RANK],stride2[SPACERE2_RANK], - stride3[SPACERE3_RANK],stride4[SPACERE4_RANK], - stride5[SPACERE5_RANK]; + /* The start of the hyperslab */ + hsize_t start1[SPACERE1_RANK], start2[SPACERE2_RANK], start3[SPACERE3_RANK], start4[SPACERE4_RANK], + start5[SPACERE5_RANK]; - /* The number of blocks for the hyperslab */ - hsize_t count1[SPACERE1_RANK],count2[SPACERE2_RANK], - count3[SPACERE3_RANK],count4[SPACERE4_RANK], - count5[SPACERE5_RANK]; + /* The stride of the hyperslab */ + hsize_t stride1[SPACERE1_RANK], stride2[SPACERE2_RANK], stride3[SPACERE3_RANK], stride4[SPACERE4_RANK], + stride5[SPACERE5_RANK]; - /* The size of each block for the hyperslab */ - hsize_t block1[SPACERE1_RANK],block2[SPACERE2_RANK], - block3[SPACERE3_RANK],block4[SPACERE4_RANK], - block5[SPACERE5_RANK]; + /* The number of blocks for the hyperslab */ + hsize_t count1[SPACERE1_RANK], count2[SPACERE2_RANK], count3[SPACERE3_RANK], count4[SPACERE4_RANK], + count5[SPACERE5_RANK]; - /* Declarations for special test of rebuild */ - hid_t sid_spec; + /* The size of each block for the hyperslab */ + hsize_t block1[SPACERE1_RANK], block2[SPACERE2_RANK], block3[SPACERE3_RANK], block4[SPACERE4_RANK], + block5[SPACERE5_RANK]; + /* Declarations for special test of rebuild */ + hid_t sid_spec; /* Output message about test being performed */ MESSAGE(6, ("Testing functionality to rebuild regular hyperslab selection\n")); - MESSAGE(7, ("Testing functionality to rebuild 1-D hyperslab selection\n")); /* Create 1-D dataspace */ - sid_reg1 = H5Screate_simple(SPACERE1_RANK,dims1,NULL); - sid_reg_ori1 = H5Screate_simple(SPACERE1_RANK,dims1,NULL); + sid_reg1 = H5Screate_simple(SPACERE1_RANK, dims1, NULL); + sid_reg_ori1 = H5Screate_simple(SPACERE1_RANK, dims1, NULL); /* Build up the original one dimensional regular selection */ start1[0] = 1; count1[0] = 3; stride1[0] = 5; block1[0] = 4; - ret = H5Sselect_hyperslab(sid_reg_ori1,H5S_SELECT_SET,start1,stride1,count1,block1); + ret = H5Sselect_hyperslab(sid_reg_ori1, H5S_SELECT_SET, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Build up one dimensional regular selection with H5_SELECT_OR, @@ -12009,71 +12068,70 @@ test_space_rebuild(void) count1[0] = 2; stride1[0] = 5; block1[0] = 4; - ret = H5Sselect_hyperslab(sid_reg1,H5S_SELECT_SET,start1,stride1,count1,block1); + ret = H5Sselect_hyperslab(sid_reg1, H5S_SELECT_SET, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start1[0] = 11; count1[0] = 1; stride1[0] = 5; block1[0] = 4; - ret = H5Sselect_hyperslab(sid_reg1,H5S_SELECT_OR,start1,stride1,count1,block1); + ret = H5Sselect_hyperslab(sid_reg1, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_reg1,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_reg1, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 and rebuild_stat2 should be * H5S_DIMINFO_VALID_YES. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(ret != FAIL) { - /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5Sselect_shape_same(sid_reg1, sid_reg_ori1); - CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); + if (ret != FAIL) { + /* In this case, rebuild_check should be TRUE. */ + rebuild_check = H5Sselect_shape_same(sid_reg1, sid_reg_ori1); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } /* For irregular hyperslab */ - sid_irreg1 = H5Screate_simple(SPACERE1_RANK,dims1,NULL); + sid_irreg1 = H5Screate_simple(SPACERE1_RANK, dims1, NULL); /* Build up one dimensional irregular selection with H5_SELECT_OR */ start1[0] = 1; count1[0] = 2; stride1[0] = 5; block1[0] = 4; - ret = H5Sselect_hyperslab(sid_irreg1,H5S_SELECT_SET,start1,stride1,count1,block1); + ret = H5Sselect_hyperslab(sid_irreg1, H5S_SELECT_SET, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start1[0] = 12; /* Just one position switch */ count1[0] = 1; stride1[0] = 5; block1[0] = 4; - ret = H5Sselect_hyperslab(sid_irreg1,H5S_SELECT_OR,start1,stride1,count1,block1); + ret = H5Sselect_hyperslab(sid_irreg1, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_irreg1,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_irreg1, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 should be H5S_DIMINFO_VALID_NO and * rebuild_stat2 should be H5S_DIMINFO_VALID_IMPOSSIBLE. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* No need to do shape comparision */ - MESSAGE(7, ("Testing functionality to rebuild 2-D hyperslab selection\n")); /* Create 2-D dataspace */ - sid_reg2 = H5Screate_simple(SPACERE2_RANK,dims2,NULL); - sid_reg_ori2 = H5Screate_simple(SPACERE2_RANK,dims2,NULL); + sid_reg2 = H5Screate_simple(SPACERE2_RANK, dims2, NULL); + sid_reg_ori2 = H5Screate_simple(SPACERE2_RANK, dims2, NULL); /* Build up the original two dimensional regular selection */ start2[0] = 2; @@ -12085,7 +12143,7 @@ test_space_rebuild(void) stride2[1] = 3; block2[1] = 2; - ret = H5Sselect_hyperslab(sid_reg_ori2,H5S_SELECT_SET,start2,stride2,count2,block2); + ret = H5Sselect_hyperslab(sid_reg_ori2, H5S_SELECT_SET, start2, stride2, count2, block2); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Build up two dimensional regular selection with H5_SELECT_OR, inside HDF5, @@ -12096,7 +12154,7 @@ test_space_rebuild(void) stride2[1] = 3; block2[1] = 2; - ret = H5Sselect_hyperslab(sid_reg2,H5S_SELECT_SET,start2,stride2,count2,block2); + ret = H5Sselect_hyperslab(sid_reg2, H5S_SELECT_SET, start2, stride2, count2, block2); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start2[1] = 7; /* 7 = start(1) + count(2) * stride(3) */ @@ -12104,29 +12162,29 @@ test_space_rebuild(void) stride2[1] = 3; block2[1] = 2; - ret = H5Sselect_hyperslab(sid_reg2,H5S_SELECT_OR,start2,stride2,count2,block2); + ret = H5Sselect_hyperslab(sid_reg2, H5S_SELECT_OR, start2, stride2, count2, block2); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_reg2,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_reg2, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 and rebuild_stat2 should be * H5S_DIMINFO_VALID_YES. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* end if */ - if(ret != FAIL) { - /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5Sselect_shape_same(sid_reg2, sid_reg_ori2); - CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); + if (ret != FAIL) { + /* In this case, rebuild_check should be TRUE. */ + rebuild_check = H5Sselect_shape_same(sid_reg2, sid_reg_ori2); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } /* 2-D irregular case */ - sid_irreg2 = H5Screate_simple(SPACERE2_RANK,dims2,NULL); + sid_irreg2 = H5Screate_simple(SPACERE2_RANK, dims2, NULL); /* Build up two dimensional irregular selection with H5_SELECT_OR */ start2[0] = 2; @@ -12137,7 +12195,7 @@ test_space_rebuild(void) count2[1] = 1; stride2[1] = 3; block2[1] = 2; - ret = H5Sselect_hyperslab(sid_irreg2,H5S_SELECT_SET,start2,stride2,count2,block2); + ret = H5Sselect_hyperslab(sid_irreg2, H5S_SELECT_SET, start2, stride2, count2, block2); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start2[1] = 4; @@ -12145,28 +12203,28 @@ test_space_rebuild(void) stride2[1] = 4; block2[1] = 3; /* Just add one element for the block */ - ret = H5Sselect_hyperslab(sid_irreg2,H5S_SELECT_OR,start2,stride2,count2,block2); + ret = H5Sselect_hyperslab(sid_irreg2, H5S_SELECT_OR, start2, stride2, count2, block2); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_irreg2,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_irreg2, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 should be H5S_DIMINFO_VALID_NO and * rebuild_stat2 should be H5S_DIMINFO_VALID_IMPOSSIBLE. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* No need to do shape comparision */ MESSAGE(7, ("Testing functionality to rebuild 3-D hyperslab selection\n")); /* Create 3-D dataspace */ - sid_reg3 = H5Screate_simple(SPACERE3_RANK,dims3,NULL); - sid_reg_ori3 = H5Screate_simple(SPACERE3_RANK,dims3,NULL); + sid_reg3 = H5Screate_simple(SPACERE3_RANK, dims3, NULL); + sid_reg_ori3 = H5Screate_simple(SPACERE3_RANK, dims3, NULL); /* Build up the original three dimensional regular selection */ start3[0] = 2; @@ -12183,8 +12241,7 @@ test_space_rebuild(void) stride3[2] = 4; block3[2] = 2; - - ret = H5Sselect_hyperslab(sid_reg_ori3,H5S_SELECT_SET,start3,stride3,count3,block3); + ret = H5Sselect_hyperslab(sid_reg_ori3, H5S_SELECT_SET, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Build up three dimensional regular selection with H5_SELECT_OR, inside HDF5, @@ -12194,7 +12251,7 @@ test_space_rebuild(void) stride3[2] = 4; block3[2] = 2; - ret = H5Sselect_hyperslab(sid_reg3,H5S_SELECT_SET,start3,stride3,count3,block3); + ret = H5Sselect_hyperslab(sid_reg3, H5S_SELECT_SET, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start3[2] = 5; @@ -12202,28 +12259,28 @@ test_space_rebuild(void) stride3[2] = 4; block3[2] = 2; - ret = H5Sselect_hyperslab(sid_reg3,H5S_SELECT_OR,start3,stride3,count3,block3); + ret = H5Sselect_hyperslab(sid_reg3, H5S_SELECT_OR, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_reg3,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_reg3, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 and rebuild_stat2 should be * H5S_DIMINFO_VALID_YES. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(ret != FAIL) { - /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5Sselect_shape_same(sid_reg3, sid_reg_ori3); - CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); + if (ret != FAIL) { + /* In this case, rebuild_check should be TRUE. */ + rebuild_check = H5Sselect_shape_same(sid_reg3, sid_reg_ori3); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } - sid_irreg3 = H5Screate_simple(SPACERE3_RANK,dims3,NULL); + sid_irreg3 = H5Screate_simple(SPACERE3_RANK, dims3, NULL); /* Build up three dimensional irregular selection with H5_SELECT_OR */ start3[0] = 2; @@ -12240,7 +12297,7 @@ test_space_rebuild(void) stride3[2] = 2; block3[2] = 1; - ret = H5Sselect_hyperslab(sid_irreg3,H5S_SELECT_SET,start3,stride3,count3,block3); + ret = H5Sselect_hyperslab(sid_irreg3, H5S_SELECT_SET, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start3[2] = 3; @@ -12248,28 +12305,28 @@ test_space_rebuild(void) stride3[2] = 3; /* Just add one element for the stride */ block3[2] = 1; - ret = H5Sselect_hyperslab(sid_irreg3,H5S_SELECT_OR,start3,stride3,count3,block3); + ret = H5Sselect_hyperslab(sid_irreg3, H5S_SELECT_OR, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_irreg3,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_irreg3, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 should be H5S_DIMINFO_VALID_NO and * rebuild_stat2 should be H5S_DIMINFO_VALID_IMPOSSIBLE. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* No need to do shape comparision */ MESSAGE(7, ("Testing functionality to rebuild 4-D hyperslab selection\n")); /* Create 4-D dataspace */ - sid_reg4 = H5Screate_simple(SPACERE4_RANK,dims4,NULL); - sid_reg_ori4 = H5Screate_simple(SPACERE4_RANK,dims4,NULL); + sid_reg4 = H5Screate_simple(SPACERE4_RANK, dims4, NULL); + sid_reg_ori4 = H5Screate_simple(SPACERE4_RANK, dims4, NULL); /* Build up the original four dimensional regular selection */ start4[0] = 2; @@ -12292,8 +12349,7 @@ test_space_rebuild(void) stride4[3] = 4; block4[3] = 2; - - ret = H5Sselect_hyperslab(sid_reg_ori4,H5S_SELECT_SET,start4,stride4,count4,block4); + ret = H5Sselect_hyperslab(sid_reg_ori4, H5S_SELECT_SET, start4, stride4, count4, block4); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Build up four dimensional regular selection with H5_SELECT_OR, inside HDF5, @@ -12303,7 +12359,7 @@ test_space_rebuild(void) stride4[3] = 4; block4[3] = 2; - ret = H5Sselect_hyperslab(sid_reg4,H5S_SELECT_SET,start4,stride4,count4,block4); + ret = H5Sselect_hyperslab(sid_reg4, H5S_SELECT_SET, start4, stride4, count4, block4); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start4[3] = 5; @@ -12311,31 +12367,29 @@ test_space_rebuild(void) stride4[3] = 4; block4[3] = 2; - - ret = H5Sselect_hyperslab(sid_reg4,H5S_SELECT_OR,start4,stride4,count4,block4); + ret = H5Sselect_hyperslab(sid_reg4, H5S_SELECT_OR, start4, stride4, count4, block4); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - - ret = H5S__get_rebuild_status_test(sid_reg4,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_reg4, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 and rebuild_stat2 should be * H5S_DIMINFO_VALID_YES. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(ret != FAIL) { - /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5Sselect_shape_same(sid_reg4, sid_reg_ori4); - CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); + if (ret != FAIL) { + /* In this case, rebuild_check should be TRUE. */ + rebuild_check = H5Sselect_shape_same(sid_reg4, sid_reg_ori4); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } /* Testing irregular selection */ - sid_irreg4 = H5Screate_simple(SPACERE4_RANK,dims4,NULL); + sid_irreg4 = H5Screate_simple(SPACERE4_RANK, dims4, NULL); /* Build up four dimensional irregular selection with H5_SELECT_OR */ start4[0] = 2; @@ -12357,7 +12411,7 @@ test_space_rebuild(void) stride4[3] = 4; block4[3] = 2; /* sub-block is one element difference */ - ret = H5Sselect_hyperslab(sid_irreg4,H5S_SELECT_SET,start4,stride4,count4,block4); + ret = H5Sselect_hyperslab(sid_irreg4, H5S_SELECT_SET, start4, stride4, count4, block4); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start4[2] = 5; @@ -12368,30 +12422,30 @@ test_space_rebuild(void) start4[3] = 1; count4[3] = 2; stride4[3] = 4; - block4[3] = 3; /* sub-block is one element difference */ + block4[3] = 3; /* sub-block is one element difference */ - ret = H5Sselect_hyperslab(sid_irreg4,H5S_SELECT_OR,start4,stride4,count4,block4); + ret = H5Sselect_hyperslab(sid_irreg4, H5S_SELECT_OR, start4, stride4, count4, block4); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_irreg4,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_irreg4, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 should be H5S_DIMINFO_VALID_NO and * rebuild_stat2 should be H5S_DIMINFO_VALID_IMPOSSIBLE. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* No need to do shape comparision */ MESSAGE(7, ("Testing functionality to rebuild 5-D hyperslab selection\n")); /* Create 5-D dataspace */ - sid_reg5 = H5Screate_simple(SPACERE5_RANK,dims5,NULL); - sid_reg_ori5 = H5Screate_simple(SPACERE5_RANK,dims5,NULL); + sid_reg5 = H5Screate_simple(SPACERE5_RANK, dims5, NULL); + sid_reg_ori5 = H5Screate_simple(SPACERE5_RANK, dims5, NULL); /* Build up the original five dimensional regular selection */ start5[0] = 2; @@ -12419,7 +12473,7 @@ test_space_rebuild(void) stride5[4] = 4; block5[4] = 2; - ret = H5Sselect_hyperslab(sid_reg_ori5,H5S_SELECT_SET,start5,stride5,count5,block5); + ret = H5Sselect_hyperslab(sid_reg_ori5, H5S_SELECT_SET, start5, stride5, count5, block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Build up five dimensional regular selection with H5_SELECT_OR, inside HDF5, @@ -12429,7 +12483,7 @@ test_space_rebuild(void) stride5[4] = 4; block5[4] = 2; - ret = H5Sselect_hyperslab(sid_reg5,H5S_SELECT_SET,start5,stride5,count5,block5); + ret = H5Sselect_hyperslab(sid_reg5, H5S_SELECT_SET, start5, stride5, count5, block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start5[4] = 5; @@ -12437,30 +12491,28 @@ test_space_rebuild(void) stride5[4] = 4; block5[4] = 2; - - ret = H5Sselect_hyperslab(sid_reg5,H5S_SELECT_OR,start5,stride5,count5,block5); + ret = H5Sselect_hyperslab(sid_reg5, H5S_SELECT_OR, start5, stride5, count5, block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - - ret = H5S__get_rebuild_status_test(sid_reg5,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_reg5, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 and rebuild_stat2 should be * H5S_DIMINFO_VALID_YES. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(ret != FAIL) { - /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5Sselect_shape_same(sid_reg5, sid_reg_ori5); - CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); + if (ret != FAIL) { + /* In this case, rebuild_check should be TRUE. */ + rebuild_check = H5Sselect_shape_same(sid_reg5, sid_reg_ori5); + CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); } - sid_irreg5 = H5Screate_simple(SPACERE5_RANK,dims5,NULL); + sid_irreg5 = H5Screate_simple(SPACERE5_RANK, dims5, NULL); /* Build up five dimensional irregular selection with H5_SELECT_OR */ start5[0] = 2; @@ -12488,7 +12540,7 @@ test_space_rebuild(void) stride5[4] = 4; block5[4] = 2; - ret = H5Sselect_hyperslab(sid_irreg5,H5S_SELECT_SET,start5,stride5,count5,block5); + ret = H5Sselect_hyperslab(sid_irreg5, H5S_SELECT_SET, start5, stride5, count5, block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start5[3] = 5; @@ -12501,26 +12553,26 @@ test_space_rebuild(void) stride5[4] = 4; block5[4] = 2; - ret = H5Sselect_hyperslab(sid_irreg5,H5S_SELECT_OR,start5,stride5,count5,block5); + ret = H5Sselect_hyperslab(sid_irreg5, H5S_SELECT_OR, start5, stride5, count5, block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_irreg5,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_irreg5, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 should be H5S_DIMINFO_VALID_NO and * rebuild_stat2 should be H5S_DIMINFO_VALID_IMPOSSIBLE. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* No need to do shape comparision */ - /* We use 5-D to test a special case with - rebuilding routine TRUE, FALSE and TRUE */ - sid_spec = H5Screate_simple(SPACERE5_RANK,dims5,NULL); + /* We use 5-D to test a special case with + rebuilding routine TRUE, FALSE and TRUE */ + sid_spec = H5Screate_simple(SPACERE5_RANK, dims5, NULL); /* Build up the original five dimensional regular selection */ start5[0] = 2; @@ -12548,20 +12600,20 @@ test_space_rebuild(void) stride5[4] = 4; block5[4] = 2; - ret = H5Sselect_hyperslab(sid_spec,H5S_SELECT_SET,start5,stride5,count5,block5); + ret = H5Sselect_hyperslab(sid_spec, H5S_SELECT_SET, start5, stride5, count5, block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_spec,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_spec, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 and rebuild_stat2 should both be * H5S_DIMINFO_VALID_YES. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* No need to do shape comparision */ @@ -12576,20 +12628,20 @@ test_space_rebuild(void) stride5[4] = 4; block5[4] = 2; - ret = H5Sselect_hyperslab(sid_spec,H5S_SELECT_OR,start5,stride5,count5,block5); + ret = H5Sselect_hyperslab(sid_spec, H5S_SELECT_OR, start5, stride5, count5, block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_spec,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_spec, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 should be H5S_DIMINFO_VALID_NO and * rebuild_stat2 should be H5S_DIMINFO_VALID_IMPOSSIBLE. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* No need to do shape comparision */ @@ -12604,20 +12656,20 @@ test_space_rebuild(void) stride5[4] = 4; block5[4] = 2; - ret = H5Sselect_hyperslab(sid_spec,H5S_SELECT_OR,start5,stride5,count5,block5); + ret = H5Sselect_hyperslab(sid_spec, H5S_SELECT_OR, start5, stride5, count5, block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5S__get_rebuild_status_test(sid_spec,&rebuild_stat1,&rebuild_stat2); + ret = H5S__get_rebuild_status_test(sid_spec, &rebuild_stat1, &rebuild_stat2); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); /* In this case, rebuild_stat1 should be H5S_DIMINFO_VALID_NO and * rebuild_stat2 should be H5S_DIMINFO_VALID_YES. */ - if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat1 != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } - if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret,FAIL,"H5S_hyper_rebuild"); + if (rebuild_stat2 != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* No need to do shape comparision */ @@ -12650,7 +12702,6 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sclose"); } - /**************************************************************** ** ** test_space_update_diminfo(): Tests selection diminfo update @@ -12662,33 +12713,31 @@ test_space_rebuild(void) static void test_space_update_diminfo(void) { - hid_t space_id; /* Dataspace id */ - H5S_diminfo_valid_t diminfo_valid; /* Diminfo status */ - H5S_diminfo_valid_t rebuild_status; /* Diminfo status after rebuid */ - H5S_sel_type sel_type; /* Selection type */ - herr_t ret; /* Return value */ - - /* dimensions of rank 1 to rank 5 */ - hsize_t dims1[] ={SPACEUD1_DIM0}; - hsize_t dims3[] ={SPACEUD3_DIM0, SPACEUD3_DIM1, SPACEUD3_DIM2}; + hid_t space_id; /* Dataspace id */ + H5S_diminfo_valid_t diminfo_valid; /* Diminfo status */ + H5S_diminfo_valid_t rebuild_status; /* Diminfo status after rebuid */ + H5S_sel_type sel_type; /* Selection type */ + herr_t ret; /* Return value */ - /* The start of the hyperslab */ - hsize_t start1[1], start3[3]; + /* dimensions of rank 1 to rank 5 */ + hsize_t dims1[] = {SPACEUD1_DIM0}; + hsize_t dims3[] = {SPACEUD3_DIM0, SPACEUD3_DIM1, SPACEUD3_DIM2}; - /* The stride of the hyperslab */ - hsize_t stride1[1], stride3[3]; + /* The start of the hyperslab */ + hsize_t start1[1], start3[3]; - /* The number of blocks for the hyperslab */ - hsize_t count1[1], count3[3]; + /* The stride of the hyperslab */ + hsize_t stride1[1], stride3[3]; - /* The size of each block for the hyperslab */ - hsize_t block1[1], block3[3]; + /* The number of blocks for the hyperslab */ + hsize_t count1[1], count3[3]; + /* The size of each block for the hyperslab */ + hsize_t block1[1], block3[3]; /* Output message about test being performed */ MESSAGE(6, ("Testing functionality to update hyperslab dimension info\n")); - MESSAGE(7, ("Testing functionality to update 1-D hyperslab dimension info\n")); /* @@ -12696,51 +12745,51 @@ test_space_update_diminfo(void) */ /* Create 1-D dataspace */ - space_id = H5Screate_simple(1, dims1, NULL); + space_id = H5Screate_simple(1, dims1, NULL); /* Create single block */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add block after first, with OR */ - start1[0] = 6; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 6; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add block before first, this time with XOR */ - start1[0] = 0; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); + start1[0] = 0; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add two blocks after current block */ @@ -12748,15 +12797,15 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add two blocks overlapping current block, with OR */ @@ -12764,15 +12813,15 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add two blocks partially overlapping current block, with OR */ @@ -12780,15 +12829,15 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add two blocks partially overlapping current block, with XOR */ @@ -12796,40 +12845,38 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO, after rebuild it should be IMPOSSIBLE */ - ret = H5S__get_rebuild_status_test(space_id, &diminfo_valid, - &rebuild_status); + ret = H5S__get_rebuild_status_test(space_id, &diminfo_valid, &rebuild_status); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ - if(rebuild_status != H5S_DIMINFO_VALID_IMPOSSIBLE) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_rebuild"); + if (rebuild_status != H5S_DIMINFO_VALID_IMPOSSIBLE) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* end if */ /* Fill in missing block */ - start1[0] = 15; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); + start1[0] = 15; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO, after rebuild it should be YES */ - ret = H5S__get_rebuild_status_test(space_id, &diminfo_valid, - &rebuild_status); + ret = H5S__get_rebuild_status_test(space_id, &diminfo_valid, &rebuild_status); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ - if(rebuild_status != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_rebuild"); + if (rebuild_status != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* end if */ /* @@ -12837,63 +12884,63 @@ test_space_update_diminfo(void) */ /* Create single block */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add block immediately after first, with OR */ - start1[0] = 5; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 5; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add block immediately before first, with XOR */ - start1[0] = 1; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 1; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add differently size block immediately after current, with OR */ - start1[0] = 7; - count1[0] = 1; - block1[0] = 7; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 7; + count1[0] = 1; + block1[0] = 7; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* @@ -12901,155 +12948,153 @@ test_space_update_diminfo(void) */ /* Create single block */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add block completely overlapping first, with OR */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add block parially overlapping first, with OR */ - start1[0] = 4; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 4; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add block completely enclosing current, with OR */ - start1[0] = 2; - count1[0] = 1; - block1[0] = 5; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 2; + count1[0] = 1; + block1[0] = 5; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add block completely enclosed by current, with OR */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add equally sized block parially overlapping current, with XOR */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 5; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 5; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Fill in hole in block */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 4; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 4; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO, after rebuild it should be YES */ - ret = H5S__get_rebuild_status_test(space_id, &diminfo_valid, - &rebuild_status); + ret = H5S__get_rebuild_status_test(space_id, &diminfo_valid, &rebuild_status); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ - if(rebuild_status != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_rebuild"); + if (rebuild_status != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* end if */ /* Add differently sized block parially overlapping current, with XOR */ - start1[0] = 4; - count1[0] = 1; - block1[0] = 5; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); + start1[0] = 4; + count1[0] = 1; + block1[0] = 5; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Fill in hole in block */ - start1[0] = 4; - count1[0] = 1; - block1[0] = 4; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 4; + count1[0] = 1; + block1[0] = 4; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO, after rebuild it should be YES */ - ret = H5S__get_rebuild_status_test(space_id, &diminfo_valid, - &rebuild_status); + ret = H5S__get_rebuild_status_test(space_id, &diminfo_valid, &rebuild_status); CHECK(ret, FAIL, "H5S__get_rebuild_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ - if(rebuild_status != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_rebuild"); + if (rebuild_status != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_rebuild"); } /* end if */ /* Add block completely overlapping current, with XOR */ - start1[0] = 2; - count1[0] = 1; - block1[0] = 7; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); + start1[0] = 2; + count1[0] = 1; + block1[0] = 7; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_XOR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); sel_type = H5Sget_select_type(space_id); @@ -13064,30 +13109,30 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create single block with start out of phase */ - start1[0] = 8; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 8; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks */ @@ -13095,15 +13140,15 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks with start out of phase */ @@ -13111,15 +13156,15 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks */ @@ -13127,15 +13172,15 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks with wrong stride */ @@ -13143,60 +13188,60 @@ test_space_update_diminfo(void) stride1[0] = 4; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create single block */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create single block with wrong size */ - start1[0] = 6; - count1[0] = 1; - block1[0] = 1; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 6; + count1[0] = 1; + block1[0] = 1; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create single block */ - start1[0] = 3; - count1[0] = 1; - block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); + start1[0] = 3; + count1[0] = 1; + block1[0] = 2; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks with wrong size */ @@ -13204,15 +13249,15 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 1; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks */ @@ -13220,30 +13265,30 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create single block with wrong size */ - start1[0] = 9; - count1[0] = 1; - block1[0] = 1; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); + start1[0] = 9; + count1[0] = 1; + block1[0] = 1; + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, NULL, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks */ @@ -13251,15 +13296,15 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks with wrong size */ @@ -13267,25 +13312,24 @@ test_space_update_diminfo(void) stride1[0] = 3; count1[0] = 2; block1[0] = 1; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start1, stride1, count1, block1); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ ret = H5Sclose(space_id); CHECK(ret, FAIL, "H5Sclose"); - MESSAGE(7, ("Testing functionality to update 3-D hyperslab dimension info\n")); /* Create 3-D dataspace */ - space_id = H5Screate_simple(3, dims3, NULL); + space_id = H5Screate_simple(3, dims3, NULL); /* Create multiple blocks */ start3[0] = 0; @@ -13300,15 +13344,15 @@ test_space_update_diminfo(void) block3[0] = 1; block3[1] = 2; block3[2] = 3; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start3, stride3, count3, block3); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add blocks with same values in all dimensions */ @@ -13318,9 +13362,9 @@ test_space_update_diminfo(void) /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add blocks with same values in two dimensions */ @@ -13328,15 +13372,15 @@ test_space_update_diminfo(void) stride3[0] = 1; count3[0] = 1; block3[0] = 1; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start3, stride3, count3, block3); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks */ @@ -13352,15 +13396,15 @@ test_space_update_diminfo(void) block3[0] = 1; block3[1] = 2; block3[2] = 3; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start3, stride3, count3, block3); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add blocks with same values in one dimension */ @@ -13372,15 +13416,15 @@ test_space_update_diminfo(void) count3[1] = 1; block3[0] = 1; block3[1] = 2; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start3, stride3, count3, block3); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Create multiple blocks */ @@ -13396,15 +13440,15 @@ test_space_update_diminfo(void) block3[0] = 1; block3[1] = 2; block3[2] = 3; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start3, stride3, count3, block3); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be YES */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_YES) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_YES) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ /* Add blocks with same values in no dimensions */ @@ -13420,22 +13464,21 @@ test_space_update_diminfo(void) block3[0] = 1; block3[1] = 2; block3[2] = 3; - ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start3, stride3, count3, block3); + ret = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, start3, stride3, count3, block3); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* diminfo_valid should be NO */ ret = H5S__get_diminfo_status_test(space_id, &diminfo_valid); CHECK(ret, FAIL, "H5S__get_diminfo_status_test"); - if(diminfo_valid != H5S_DIMINFO_VALID_NO) { - ret = FAIL; - CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); + if (diminfo_valid != H5S_DIMINFO_VALID_NO) { + ret = FAIL; + CHECK(ret, FAIL, "H5S_hyper_update_diminfo"); } /* end if */ ret = H5Sclose(space_id); CHECK(ret, FAIL, "H5Sclose"); } /* end test_space_update_diminfo() */ - /**************************************************************** ** ** test_select_hyper_chunk_offset(): Tests selections on dataspace, @@ -13446,21 +13489,21 @@ test_space_update_diminfo(void) static void test_select_hyper_chunk_offset(void) { - hid_t fid; /* File ID */ - hid_t sid; /* Dataspace ID */ - hid_t msid; /* Memory dataspace ID */ - hid_t did; /* Dataset ID */ - const hsize_t mem_dims[1] = { SPACE10_DIM1 }; /* Dataspace dimensions for memory */ - const hsize_t dims[1] = { 0 }; /* Dataspace initial dimensions */ - const hsize_t maxdims[1] = { H5S_UNLIMITED }; /* Dataspace mam dims */ - int *wbuf; /* Buffer for writing data */ - int *rbuf; /* Buffer for reading data */ - hid_t dcpl; /* Dataset creation property list ID */ - hsize_t chunks[1]={SPACE10_CHUNK_SIZE }; /* Chunk size */ - hsize_t start[1] = { 0 }; /* The start of the hyperslab */ - hsize_t count[1] = { SPACE10_CHUNK_SIZE }; /* The size of the hyperslab */ - int i,j; /* Local index */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t sid; /* Dataspace ID */ + hid_t msid; /* Memory dataspace ID */ + hid_t did; /* Dataset ID */ + const hsize_t mem_dims[1] = {SPACE10_DIM1}; /* Dataspace dimensions for memory */ + const hsize_t dims[1] = {0}; /* Dataspace initial dimensions */ + const hsize_t maxdims[1] = {H5S_UNLIMITED}; /* Dataspace mam dims */ + int * wbuf; /* Buffer for writing data */ + int * rbuf; /* Buffer for reading data */ + hid_t dcpl; /* Dataset creation property list ID */ + hsize_t chunks[1] = {SPACE10_CHUNK_SIZE}; /* Chunk size */ + hsize_t start[1] = {0}; /* The start of the hyperslab */ + hsize_t count[1] = {SPACE10_CHUNK_SIZE}; /* The size of the hyperslab */ + int i, j; /* Local index */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing hyperslab selections using offsets in chunked datasets\n")); @@ -13472,8 +13515,8 @@ test_select_hyper_chunk_offset(void) CHECK_PTR(rbuf, "HDcalloc"); /* Initialize the write buffer */ - for(i=0; i=((2*SPACE10_CHUNK_SIZE)/3)) - if(wbuf[i+j]!=rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j]) - TestErrPrintf("Line: %d - Error! i=%d, j=%d, rbuf=%d, wbuf=%d\n",__LINE__,i,j,rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j],wbuf[i+j]); + if (j < (SPACE10_CHUNK_SIZE / 3) || j >= ((2 * SPACE10_CHUNK_SIZE) / 3)) + if (wbuf[i + j] != rbuf[((SPACE10_DIM1 - i) - SPACE10_CHUNK_SIZE) + j]) + TestErrPrintf("Line: %d - Error! i=%d, j=%d, rbuf=%d, wbuf=%d\n", __LINE__, i, j, + rbuf[((SPACE10_DIM1 - i) - SPACE10_CHUNK_SIZE) + j], wbuf[i + j]); /* Close the memory dataspace */ - ret=H5Sclose (msid); + ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); /* Close the dataset */ - ret=H5Dclose (did); + ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); /* Close the file */ - ret=H5Fclose (fid); + ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); /* Free the buffers */ HDfree(wbuf); HDfree(rbuf); -} /* test_select_hyper_chunk_offset() */ +} /* test_select_hyper_chunk_offset() */ /**************************************************************** ** @@ -13661,19 +13706,19 @@ test_select_hyper_chunk_offset(void) static void test_select_hyper_chunk_offset2(void) { - hid_t file, dataset; /* handles */ - hid_t dataspace; - hid_t memspace; - hid_t dcpl; /* Dataset creation property list */ - herr_t status; - unsigned data_out[SPACE12_DIM0]; /* output buffer */ - unsigned data_in[SPACE12_CHUNK_DIM0]; /* input buffer */ - hsize_t dims[SPACE12_RANK]={SPACE12_DIM0}; /* Dimension size */ - hsize_t chunk_dims[SPACE12_RANK]={SPACE12_CHUNK_DIM0}; /* Chunk size */ - hsize_t start[SPACE12_RANK]; /* Start of hyperslab */ - hsize_t count[SPACE12_RANK]; /* Size of hyperslab */ - hssize_t offset[SPACE12_RANK]; /* hyperslab offset in the file */ - unsigned u, v; /* Local index variables */ + hid_t file, dataset; /* handles */ + hid_t dataspace; + hid_t memspace; + hid_t dcpl; /* Dataset creation property list */ + herr_t status; + unsigned data_out[SPACE12_DIM0]; /* output buffer */ + unsigned data_in[SPACE12_CHUNK_DIM0]; /* input buffer */ + hsize_t dims[SPACE12_RANK] = {SPACE12_DIM0}; /* Dimension size */ + hsize_t chunk_dims[SPACE12_RANK] = {SPACE12_CHUNK_DIM0}; /* Chunk size */ + hsize_t start[SPACE12_RANK]; /* Start of hyperslab */ + hsize_t count[SPACE12_RANK]; /* Size of hyperslab */ + hssize_t offset[SPACE12_RANK]; /* hyperslab offset in the file */ + unsigned u, v; /* Local index variables */ /* Output message about test being performed */ MESSAGE(6, ("Testing more hyperslab selections using offsets in chunked datasets\n")); @@ -13719,25 +13764,25 @@ test_select_hyper_chunk_offset2(void) */ start[0] = 0; count[0] = SPACE12_CHUNK_DIM0; - status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, NULL, count, NULL); + status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, NULL, count, NULL); CHECK(status, FAIL, "H5Sselect_hyperslab"); /* Loop through retrieving data from file, checking it against data written */ - for(u = 0; u < SPACE12_DIM0; u += SPACE12_CHUNK_DIM0) { + for (u = 0; u < SPACE12_DIM0; u += SPACE12_CHUNK_DIM0) { /* Set the offset of the file selection */ offset[0] = u; - status = H5Soffset_simple(dataspace, offset); + status = H5Soffset_simple(dataspace, offset); CHECK(status, FAIL, "H5Soffset_simple"); /* Read in buffer of data */ - status = H5Dread(dataset, H5T_NATIVE_UINT, memspace, dataspace, - H5P_DEFAULT, data_in); + status = H5Dread(dataset, H5T_NATIVE_UINT, memspace, dataspace, H5P_DEFAULT, data_in); CHECK(status, FAIL, "H5Dread"); /* Check data read in */ - for(v = 0; v < SPACE12_CHUNK_DIM0; v++) - if(data_out[u + v] != data_in[v]) - TestErrPrintf("Error! data_out[%u]=%u, data_in[%u]=%u\n",(unsigned)(u + v), data_out[u + v], v, data_in[v]); + for (v = 0; v < SPACE12_CHUNK_DIM0; v++) + if (data_out[u + v] != data_in[v]) + TestErrPrintf("Error! data_out[%u]=%u, data_in[%u]=%u\n", (unsigned)(u + v), data_out[u + v], + v, data_in[v]); } /* end for */ status = H5Dclose(dataset); @@ -13751,7 +13796,7 @@ test_select_hyper_chunk_offset2(void) status = H5Fclose(file); CHECK(status, FAIL, "H5Fclose"); -} /* test_select_hyper_chunk_offset2() */ +} /* test_select_hyper_chunk_offset2() */ /**************************************************************** ** @@ -13762,23 +13807,23 @@ test_select_hyper_chunk_offset2(void) static void test_select_bounds(void) { - hid_t sid; /* Dataspace ID */ - const hsize_t dims[SPACE11_RANK] = {SPACE11_DIM1, SPACE11_DIM2}; /* Dataspace dimensions */ - hsize_t coord[SPACE11_NPOINTS][SPACE11_RANK]; /* Coordinates for point selection */ - hsize_t start[SPACE11_RANK]; /* The start of the hyperslab */ - hsize_t stride[SPACE11_RANK]; /* The stride between block starts for the hyperslab */ - hsize_t count[SPACE11_RANK]; /* The number of blocks for the hyperslab */ - hsize_t block[SPACE11_RANK]; /* The size of each block for the hyperslab */ - hssize_t offset[SPACE11_RANK]; /* Offset amount for selection */ - hsize_t low_bounds[SPACE11_RANK]; /* The low bounds for the selection */ - hsize_t high_bounds[SPACE11_RANK]; /* The high bounds for the selection */ - herr_t ret; /* Generic return value */ + hid_t sid; /* Dataspace ID */ + const hsize_t dims[SPACE11_RANK] = {SPACE11_DIM1, SPACE11_DIM2}; /* Dataspace dimensions */ + hsize_t coord[SPACE11_NPOINTS][SPACE11_RANK]; /* Coordinates for point selection */ + hsize_t start[SPACE11_RANK]; /* The start of the hyperslab */ + hsize_t stride[SPACE11_RANK]; /* The stride between block starts for the hyperslab */ + hsize_t count[SPACE11_RANK]; /* The number of blocks for the hyperslab */ + hsize_t block[SPACE11_RANK]; /* The size of each block for the hyperslab */ + hssize_t offset[SPACE11_RANK]; /* Offset amount for selection */ + hsize_t low_bounds[SPACE11_RANK]; /* The low bounds for the selection */ + hsize_t high_bounds[SPACE11_RANK]; /* The high bounds for the selection */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing selection bounds\n")); /* Create dataspace */ - sid = H5Screate_simple (SPACE11_RANK, dims, NULL); + sid = H5Screate_simple(SPACE11_RANK, dims, NULL); CHECK(sid, FAIL, "H5Screate_simple"); /* Get bounds for 'all' selection */ @@ -13790,8 +13835,9 @@ test_select_bounds(void) VERIFY(high_bounds[1], SPACE11_DIM2 - 1, "H5Sget_select_bounds"); /* Set offset for selection */ - offset[0] = 1; offset[1] = 1; - ret = H5Soffset_simple(sid, offset); + offset[0] = 1; + offset[1] = 1; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Get bounds for 'all' selection with offset (which should be ignored) */ @@ -13803,8 +13849,9 @@ test_select_bounds(void) VERIFY(high_bounds[1], SPACE11_DIM2 - 1, "H5Sget_select_bounds"); /* Reset offset for selection */ - offset[0] = 0; offset[1] = 0; - ret = H5Soffset_simple(sid, offset); + offset[0] = 0; + offset[1] = 0; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Set 'none' selection */ @@ -13812,17 +13859,23 @@ test_select_bounds(void) CHECK(ret, FAIL, "H5Sselect_none"); /* Get bounds for 'none' selection */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sget_select_bounds(sid, low_bounds, high_bounds); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sget_select_bo unds"); /* Set point selection */ - coord[0][0] = 3; coord[0][1] = 3; - coord[1][0] = 3; coord[1][1] = 96; - coord[2][0] = 96; coord[2][1] = 3; - coord[3][0] = 96; coord[3][1] = 96; - ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)SPACE11_NPOINTS, (const hsize_t *)coord); + coord[0][0] = 3; + coord[0][1] = 3; + coord[1][0] = 3; + coord[1][1] = 96; + coord[2][0] = 96; + coord[2][1] = 3; + coord[3][0] = 96; + coord[3][1] = 96; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)SPACE11_NPOINTS, (const hsize_t *)coord); CHECK(ret, FAIL, "H5Sselect_elements"); /* Get bounds for point selection */ @@ -13834,19 +13887,23 @@ test_select_bounds(void) VERIFY(high_bounds[1], SPACE11_DIM2 - 4, "H5Sget_select_bounds"); /* Set bad offset for selection */ - offset[0] = 5; offset[1] = -5; - ret = H5Soffset_simple(sid, offset); + offset[0] = 5; + offset[1] = -5; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Get bounds for hyperslab selection with negative offset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sget_select_bounds(sid, low_bounds, high_bounds); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sget_select_bounds"); /* Set valid offset for selection */ - offset[0] = 2; offset[1] = -2; - ret = H5Soffset_simple(sid, offset); + offset[0] = 2; + offset[1] = -2; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Get bounds for point selection with offset */ @@ -13858,16 +13915,21 @@ test_select_bounds(void) VERIFY(high_bounds[1], SPACE11_DIM2 - 6, "H5Sget_select_bounds"); /* Reset offset for selection */ - offset[0] = 0; offset[1] = 0; - ret = H5Soffset_simple(sid, offset); + offset[0] = 0; + offset[1] = 0; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Set "regular" hyperslab selection */ - start[0] = 2; start[1] = 2; - stride[0] = 10; stride[1] = 10; - count[0] = 4; count[1] = 4; - block[0] = 5; block[1] = 5; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 2; + start[1] = 2; + stride[0] = 10; + stride[1] = 10; + count[0] = 4; + count[1] = 4; + block[0] = 5; + block[1] = 5; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Get bounds for hyperslab selection */ @@ -13879,19 +13941,23 @@ test_select_bounds(void) VERIFY(high_bounds[1], 36, "H5Sget_select_bounds"); /* Set bad offset for selection */ - offset[0] = 5; offset[1] = -5; - ret = H5Soffset_simple(sid, offset); + offset[0] = 5; + offset[1] = -5; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Get bounds for hyperslab selection with negative offset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sget_select_bounds(sid, low_bounds, high_bounds); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sget_select_bounds"); /* Set valid offset for selection */ - offset[0] = 5; offset[1] = -2; - ret = H5Soffset_simple(sid, offset); + offset[0] = 5; + offset[1] = -2; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Get bounds for hyperslab selection with offset */ @@ -13903,16 +13969,21 @@ test_select_bounds(void) VERIFY(high_bounds[1], 34, "H5Sget_select_bounds"); /* Reset offset for selection */ - offset[0] = 0; offset[1] = 0; - ret = H5Soffset_simple(sid, offset); + offset[0] = 0; + offset[1] = 0; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Make "irregular" hyperslab selection */ - start[0] = 20; start[1] = 20; - stride[0] = 20; stride[1] = 20; - count[0] = 2; count[1] = 2; - block[0] = 10; block[1] = 10; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); + start[0] = 20; + start[1] = 20; + stride[0] = 20; + stride[1] = 20; + count[0] = 2; + count[1] = 2; + block[0] = 10; + block[1] = 10; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Get bounds for hyperslab selection */ @@ -13924,19 +13995,23 @@ test_select_bounds(void) VERIFY(high_bounds[1], 49, "H5Sget_select_bounds"); /* Set bad offset for selection */ - offset[0] = 5; offset[1] = -5; - ret = H5Soffset_simple(sid, offset); + offset[0] = 5; + offset[1] = -5; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Get bounds for hyperslab selection with negative offset */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sget_select_bounds(sid, low_bounds, high_bounds); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sget_select_bounds"); /* Set valid offset for selection */ - offset[0] = 5; offset[1] = -2; - ret = H5Soffset_simple(sid, offset); + offset[0] = 5; + offset[1] = -2; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Get bounds for hyperslab selection with offset */ @@ -13948,15 +14023,15 @@ test_select_bounds(void) VERIFY(high_bounds[1], 47, "H5Sget_select_bounds"); /* Reset offset for selection */ - offset[0] = 0; offset[1] = 0; - ret = H5Soffset_simple(sid, offset); + offset[0] = 0; + offset[1] = 0; + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Close the dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_select_bounds() */ - +} /* test_select_bounds() */ /**************************************************************** ** @@ -13966,22 +14041,22 @@ test_select_bounds(void) static void test_hyper_regular(void) { - hid_t sid; /* Dataspace ID */ - const hsize_t dims[SPACE13_RANK] = {SPACE13_DIM1, SPACE13_DIM2, SPACE13_DIM3}; /* Dataspace dimensions */ - hsize_t coord[SPACE13_NPOINTS][SPACE13_RANK]; /* Coordinates for point selection */ - hsize_t start[SPACE13_RANK]; /* The start of the hyperslab */ - hsize_t stride[SPACE13_RANK]; /* The stride between block starts for the hyperslab */ - hsize_t count[SPACE13_RANK]; /* The number of blocks for the hyperslab */ - hsize_t block[SPACE13_RANK]; /* The size of each block for the hyperslab */ - hsize_t t_start[SPACE13_RANK]; /* Temporary start of the hyperslab */ - hsize_t t_count[SPACE13_RANK]; /* Temporary number of blocks for the hyperslab */ - hsize_t q_start[SPACE13_RANK]; /* The queried start of the hyperslab */ - hsize_t q_stride[SPACE13_RANK]; /* The queried stride between block starts for the hyperslab */ - hsize_t q_count[SPACE13_RANK]; /* The queried number of blocks for the hyperslab */ - hsize_t q_block[SPACE13_RANK]; /* The queried size of each block for the hyperslab */ - htri_t is_regular; /* Whether a hyperslab selection is regular */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t sid; /* Dataspace ID */ + const hsize_t dims[SPACE13_RANK] = {SPACE13_DIM1, SPACE13_DIM2, SPACE13_DIM3}; /* Dataspace dimensions */ + hsize_t coord[SPACE13_NPOINTS][SPACE13_RANK]; /* Coordinates for point selection */ + hsize_t start[SPACE13_RANK]; /* The start of the hyperslab */ + hsize_t stride[SPACE13_RANK]; /* The stride between block starts for the hyperslab */ + hsize_t count[SPACE13_RANK]; /* The number of blocks for the hyperslab */ + hsize_t block[SPACE13_RANK]; /* The size of each block for the hyperslab */ + hsize_t t_start[SPACE13_RANK]; /* Temporary start of the hyperslab */ + hsize_t t_count[SPACE13_RANK]; /* Temporary number of blocks for the hyperslab */ + hsize_t q_start[SPACE13_RANK]; /* The queried start of the hyperslab */ + hsize_t q_stride[SPACE13_RANK]; /* The queried stride between block starts for the hyperslab */ + hsize_t q_count[SPACE13_RANK]; /* The queried number of blocks for the hyperslab */ + hsize_t q_block[SPACE13_RANK]; /* The queried size of each block for the hyperslab */ + htri_t is_regular; /* Whether a hyperslab selection is regular */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing queries on regular hyperslabs\n")); @@ -13991,15 +14066,19 @@ test_hyper_regular(void) CHECK(sid, FAIL, "H5Screate_simple"); /* Query if 'all' selection is regular hyperslab (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { is_regular = H5Sis_regular_hyperslab(sid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); /* Query regular hyperslab selection info (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); /* Set 'none' selection */ @@ -14007,43 +14086,67 @@ test_hyper_regular(void) CHECK(ret, FAIL, "H5Sselect_none"); /* Query if 'none' selection is regular hyperslab (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { is_regular = H5Sis_regular_hyperslab(sid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); /* Query regular hyperslab selection info (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); /* Set point selection */ - coord[0][0] = 3; coord[0][1] = 3; coord[0][2] = 3; - coord[1][0] = 3; coord[1][1] = 48; coord[1][2] = 48; - coord[2][0] = 48; coord[2][1] = 3; coord[2][2] = 3; - coord[3][0] = 48; coord[3][1] = 48; coord[3][2] = 48; - ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)SPACE13_NPOINTS, (const hsize_t *)coord); + coord[0][0] = 3; + coord[0][1] = 3; + coord[0][2] = 3; + coord[1][0] = 3; + coord[1][1] = 48; + coord[1][2] = 48; + coord[2][0] = 48; + coord[2][1] = 3; + coord[2][2] = 3; + coord[3][0] = 48; + coord[3][1] = 48; + coord[3][2] = 48; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)SPACE13_NPOINTS, (const hsize_t *)coord); CHECK(ret, FAIL, "H5Sselect_elements"); /* Query if 'point' selection is regular hyperslab (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { is_regular = H5Sis_regular_hyperslab(sid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); /* Query regular hyperslab selection info (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); /* Set "regular" hyperslab selection */ - start[0] = 2; start[1] = 2; start[2] = 2; - stride[0] = 5; stride[1] = 5; stride[2] = 5; - count[0] = 3; count[1] = 3; count[2] = 3; - block[0] = 4; block[1] = 4; block[2] = 4; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 2; + start[1] = 2; + start[2] = 2; + stride[0] = 5; + stride[1] = 5; + stride[2] = 5; + count[0] = 3; + count[1] = 3; + count[2] = 3; + block[0] = 4; + block[1] = 4; + block[2] = 4; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Query if 'hyperslab' selection is regular hyperslab (should be TRUE) */ @@ -14055,21 +14158,25 @@ test_hyper_regular(void) CHECK(ret, FAIL, "H5Sget_regular_hyperslab"); /* Verify the hyperslab parameters */ - for(u = 0; u < SPACE13_RANK; u++) { - if(start[u] != q_start[u]) + for (u = 0; u < SPACE13_RANK; u++) { + if (start[u] != q_start[u]) ERROR("H5Sget_regular_hyperslab, start"); - if(stride[u] != q_stride[u]) + if (stride[u] != q_stride[u]) ERROR("H5Sget_regular_hyperslab, stride"); - if(count[u] != q_count[u]) + if (count[u] != q_count[u]) ERROR("H5Sget_regular_hyperslab, count"); - if(block[u] != q_block[u]) + if (block[u] != q_block[u]) ERROR("H5Sget_regular_hyperslab, block"); } /* end for */ /* 'OR' in another point */ - t_start[0] = 0; t_start[1] = 0; t_start[2] = 0; - t_count[0] = 1; t_count[1] = 1; t_count[2] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, t_start, NULL, t_count, NULL); + t_start[0] = 0; + t_start[1] = 0; + t_start[2] = 0; + t_count[0] = 1; + t_count[1] = 1; + t_count[2] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, t_start, NULL, t_count, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Query if 'hyperslab' selection is regular hyperslab (should be FALSE) */ @@ -14077,15 +14184,21 @@ test_hyper_regular(void) VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab"); /* Query regular hyperslab selection info (should fail) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); /* 'XOR' in the point again, to remove it, which should make it regular again */ - t_start[0] = 0; t_start[1] = 0; t_start[2] = 0; - t_count[0] = 1; t_count[1] = 1; t_count[2] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_XOR, t_start, NULL, t_count, NULL); + t_start[0] = 0; + t_start[1] = 0; + t_start[2] = 0; + t_count[0] = 1; + t_count[1] = 1; + t_count[2] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_XOR, t_start, NULL, t_count, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Query if 'hyperslab' selection is regular hyperslab (should be TRUE) */ @@ -14097,21 +14210,21 @@ test_hyper_regular(void) CHECK(ret, FAIL, "H5Sget_regular_hyperslab"); /* Verify the hyperslab parameters */ - for(u = 0; u < SPACE13_RANK; u++) { - if(start[u] != q_start[u]) + for (u = 0; u < SPACE13_RANK; u++) { + if (start[u] != q_start[u]) ERROR("H5Sget_regular_hyperslab, start"); - if(stride[u] != q_stride[u]) + if (stride[u] != q_stride[u]) ERROR("H5Sget_regular_hyperslab, stride"); - if(count[u] != q_count[u]) + if (count[u] != q_count[u]) ERROR("H5Sget_regular_hyperslab, count"); - if(block[u] != q_block[u]) + if (block[u] != q_block[u]) ERROR("H5Sget_regular_hyperslab, block"); } /* end for */ /* Close the dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_hyper_regular() */ +} /* test_hyper_regular() */ /**************************************************************** ** @@ -14119,16 +14232,16 @@ test_hyper_regular(void) ** ****************************************************************/ static void -test_hyper_unlim_check(hid_t sid, hsize_t *dims, hssize_t enpoints, - hssize_t enblocks, hsize_t *eblock1, hsize_t *eblock2) +test_hyper_unlim_check(hid_t sid, hsize_t *dims, hssize_t enpoints, hssize_t enblocks, hsize_t *eblock1, + hsize_t *eblock2) { - hid_t lim_sid; - hsize_t start[3]; + hid_t lim_sid; + hsize_t start[3]; H5S_sel_type sel_type; - hssize_t npoints; - hssize_t nblocks; - hsize_t blocklist[12]; - herr_t ret; + hssize_t npoints; + hssize_t nblocks; + hsize_t blocklist[12]; + herr_t ret; HDassert(enblocks <= 2); @@ -14151,39 +14264,37 @@ test_hyper_unlim_check(hid_t sid, hsize_t *dims, hssize_t enpoints, CHECK(sel_type, H5S_SEL_ERROR, "H5Sget_select_type"); /* Only examine blocks for hyperslab selection */ - if(sel_type == H5S_SEL_HYPERSLABS) { + if (sel_type == H5S_SEL_HYPERSLABS) { /* Get number of blocks */ nblocks = H5Sget_select_hyper_nblocks(lim_sid); CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks"); VERIFY(nblocks, enblocks, "H5Sget_select_hyper_nblocks"); - if(nblocks > 0) { + if (nblocks > 0) { /* Get blocklist */ ret = H5Sget_select_hyper_blocklist(lim_sid, (hsize_t)0, (hsize_t)nblocks, blocklist); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); /* Verify blocklist */ - if(nblocks == (hssize_t)1) { - if(HDmemcmp(blocklist, eblock1, 6 * sizeof(eblock1[0]))) + if (nblocks == (hssize_t)1) { + if (HDmemcmp(blocklist, eblock1, 6 * sizeof(eblock1[0]))) ERROR("H5Sget_select_hyper_blocklist"); } /* end if */ else { HDassert(nblocks == (hssize_t)2); - if(HDmemcmp(blocklist, eblock1, 6 * sizeof(eblock1[0]))) { - if(HDmemcmp(blocklist, eblock2, 6 * sizeof(eblock2[0]))) + if (HDmemcmp(blocklist, eblock1, 6 * sizeof(eblock1[0]))) { + if (HDmemcmp(blocklist, eblock2, 6 * sizeof(eblock2[0]))) ERROR("H5Sget_select_hyper_blocklist"); - if(HDmemcmp(&blocklist[6], eblock1, 6 * sizeof(eblock1[0]))) + if (HDmemcmp(&blocklist[6], eblock1, 6 * sizeof(eblock1[0]))) ERROR("H5Sget_select_hyper_blocklist"); } /* end if */ - else - if(HDmemcmp(&blocklist[6], eblock2, 6 * sizeof(eblock2[0]))) - ERROR("H5Sget_select_hyper_blocklist"); + else if (HDmemcmp(&blocklist[6], eblock2, 6 * sizeof(eblock2[0]))) + ERROR("H5Sget_select_hyper_blocklist"); } /* end else */ - } /* end if */ - } /* end if */ - else - if(sel_type != H5S_SEL_NONE) - ERROR("H5Sget_select_type"); + } /* end if */ + } /* end if */ + else if (sel_type != H5S_SEL_NONE) + ERROR("H5Sget_select_type"); /* Close the limited dataspace */ ret = H5Sclose(lim_sid); @@ -14193,20 +14304,20 @@ test_hyper_unlim_check(hid_t sid, hsize_t *dims, hssize_t enpoints, static void test_hyper_unlim(void) { - hid_t sid; - hsize_t dims[3] = {4, 4, 7}; - hsize_t mdims[3] = {4, H5S_UNLIMITED, 7}; - hsize_t start[3] = {1, 2, 1}; - hsize_t stride[3] = {1, 1, 3}; - hsize_t count[3] = {1, 1, 2}; - hsize_t block[3] = {2, H5S_UNLIMITED, 2}; - hsize_t start2[3]; - hsize_t count2[3]; - hsize_t eblock1[6] = {1, 2, 1, 2, 3, 2}; - hsize_t eblock2[6] = {1, 2, 4, 2, 3, 5}; - hssize_t offset[3] = {0, -1, 0}; - hssize_t ssize_out; - herr_t ret; + hid_t sid; + hsize_t dims[3] = {4, 4, 7}; + hsize_t mdims[3] = {4, H5S_UNLIMITED, 7}; + hsize_t start[3] = {1, 2, 1}; + hsize_t stride[3] = {1, 1, 3}; + hsize_t count[3] = {1, 1, 2}; + hsize_t block[3] = {2, H5S_UNLIMITED, 2}; + hsize_t start2[3]; + hsize_t count2[3]; + hsize_t eblock1[6] = {1, 2, 1, 2, 3, 2}; + hsize_t eblock2[6] = {1, 2, 4, 2, 3, 5}; + hssize_t offset[3] = {0, -1, 0}; + hssize_t ssize_out; + herr_t ret; /* Output message about test being performed */ MESSAGE(6, ("Testing unlimited hyperslab selections\n")); @@ -14223,7 +14334,7 @@ test_hyper_unlim(void) test_hyper_unlim_check(sid, dims, (hssize_t)16, (hssize_t)2, eblock1, eblock2); /* Check with unlimited dimension clipped to 3 */ - dims[1] = 3; + dims[1] = 3; eblock1[4] = 2; eblock2[4] = 2; test_hyper_unlim_check(sid, dims, (hssize_t)8, (hssize_t)2, eblock1, eblock2); @@ -14237,7 +14348,7 @@ test_hyper_unlim(void) test_hyper_unlim_check(sid, dims, (hssize_t)0, (hssize_t)0, eblock1, eblock2); /* Check with unlimited dimension clipped to 7 */ - dims[1] = 7; + dims[1] = 7; eblock1[4] = 6; eblock2[4] = 6; test_hyper_unlim_check(sid, dims, (hssize_t)40, (hssize_t)2, eblock1, eblock2); @@ -14251,7 +14362,7 @@ test_hyper_unlim(void) /* Reset offset of selection */ offset[1] = (hssize_t)0; - ret = H5Soffset_simple(sid, offset); + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* @@ -14259,9 +14370,9 @@ test_hyper_unlim(void) */ stride[1] = 3; stride[2] = 1; - count[1] = H5S_UNLIMITED; - count[2] = 1; - block[1] = 2; + count[1] = H5S_UNLIMITED; + count[2] = 1; + block[1] = 2; /* Select unlimited hyperslab */ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); @@ -14277,29 +14388,29 @@ test_hyper_unlim(void) test_hyper_unlim_check(sid, dims, (hssize_t)16, (hssize_t)2, eblock1, eblock2); /* Check with unlimited dimension clipped to 3 */ - dims[1] = 3; + dims[1] = 3; eblock1[4] = 2; test_hyper_unlim_check(sid, dims, (hssize_t)4, (hssize_t)1, eblock1, eblock2); /* Check with unlimited dimension clipped to 4 */ - dims[1] = 4; + dims[1] = 4; eblock1[4] = 3; test_hyper_unlim_check(sid, dims, (hssize_t)8, (hssize_t)1, eblock1, eblock2); /* Check with unlimited dimension clipped to 5 */ - dims[1] = 5; + dims[1] = 5; eblock1[4] = 3; test_hyper_unlim_check(sid, dims, (hssize_t)8, (hssize_t)1, eblock1, eblock2); /* Check with unlimited dimension clipped to 6 */ - dims[1] = 6; + dims[1] = 6; eblock1[4] = 3; eblock2[4] = 5; test_hyper_unlim_check(sid, dims, (hssize_t)12, (hssize_t)2, eblock1, eblock2); /* Set offset of selection */ offset[1] = (hssize_t)-1; - ret = H5Soffset_simple(sid, offset); + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Check with adjusted offset (should not affect result) */ @@ -14307,7 +14418,7 @@ test_hyper_unlim(void) /* Set offset of selection */ offset[1] = (hssize_t)3; - ret = H5Soffset_simple(sid, offset); + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* Check with adjusted offset (should not affect result) */ @@ -14315,41 +14426,44 @@ test_hyper_unlim(void) /* Reset offset of selection */ offset[1] = (hssize_t)0; - ret = H5Soffset_simple(sid, offset); + ret = H5Soffset_simple(sid, offset); CHECK(ret, FAIL, "H5Soffset_simple"); /* * Now try invalid operations */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { /* Try multiple unlimited dimensions */ - start[0] = 1; - start[1] = 2; - start[2] = 1; + start[0] = 1; + start[1] = 2; + start[2] = 1; stride[0] = 1; stride[1] = 3; stride[2] = 3; - count[0] = 1; - count[1] = H5S_UNLIMITED; - count[2] = H5S_UNLIMITED; - block[0] = 2; - block[1] = 2; - block[2] = 2; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + count[0] = 1; + count[1] = H5S_UNLIMITED; + count[2] = H5S_UNLIMITED; + block[0] = 2; + block[1] = 2; + block[2] = 2; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); /* Try unlimited count and block */ count[2] = 2; block[1] = H5S_UNLIMITED; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); - } H5E_END_TRY + } + H5E_END_TRY /* Try operations with two unlimited selections */ block[1] = 2; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - H5E_BEGIN_TRY { + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + H5E_BEGIN_TRY + { ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, NULL, count, NULL); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_AND, start, NULL, count, NULL); @@ -14360,27 +14474,32 @@ test_hyper_unlim(void) VERIFY(ret, FAIL, "H5Sselect_hyperslab"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_NOTA, start, NULL, count, NULL); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); - } H5E_END_TRY + } + H5E_END_TRY /* Try invalid combination operations */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, NULL, block, NULL); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_XOR, start, NULL, block, NULL); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, block, NULL); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); - } H5E_END_TRY + } + H5E_END_TRY ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, block, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_XOR, start, stride, count, block); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_NOTA, start, stride, count, block); VERIFY(ret, FAIL, "H5Sselect_hyperslab"); - } H5E_END_TRY + } + H5E_END_TRY /* * Now test valid combination operations @@ -14392,7 +14511,7 @@ test_hyper_unlim(void) block[0] = 2; block[1] = 2; block[2] = 2; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start2[0] = 2; start2[1] = 2; @@ -14400,7 +14519,7 @@ test_hyper_unlim(void) count2[0] = 5; count2[1] = 4; count2[2] = 2; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_AND, start2, NULL, count2, NULL); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_AND, start2, NULL, count2, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); eblock1[0] = 2; eblock1[3] = 2; @@ -14414,9 +14533,9 @@ test_hyper_unlim(void) eblock2[4] = 5; eblock2[2] = 1; eblock2[5] = 1; - dims[0] = 50; - dims[1] = 50; - dims[2] = 50; + dims[0] = 50; + dims[1] = 50; + dims[2] = 50; test_hyper_unlim_check(sid, dims, (hssize_t)3, (hssize_t)2, eblock1, eblock2); /* unlim NOTA non-unlim */ @@ -14426,7 +14545,7 @@ test_hyper_unlim(void) block[0] = 2; block[1] = 2; block[2] = 2; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); start2[0] = 1; start2[1] = 5; @@ -14434,7 +14553,7 @@ test_hyper_unlim(void) count2[0] = 2; count2[1] = 2; count2[2] = 6; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_NOTA, start2, NULL, count2, NULL); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_NOTA, start2, NULL, count2, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); eblock1[0] = 1; eblock1[3] = 2; @@ -14448,9 +14567,9 @@ test_hyper_unlim(void) eblock2[4] = 6; eblock2[2] = 6; eblock2[5] = 7; - dims[0] = 50; - dims[1] = 50; - dims[2] = 50; + dims[0] = 50; + dims[1] = 50; + dims[2] = 50; test_hyper_unlim_check(sid, dims, (hssize_t)12, (hssize_t)2, eblock1, eblock2); /* non-unlim AND unlim */ @@ -14460,7 +14579,7 @@ test_hyper_unlim(void) count2[0] = 5; count2[1] = 4; count2[2] = 2; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start2, NULL, count2, NULL); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start2, NULL, count2, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); count[0] = 1; count[1] = H5S_UNLIMITED; @@ -14468,7 +14587,7 @@ test_hyper_unlim(void) block[0] = 2; block[1] = 2; block[2] = 2; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_AND, start, stride, count, block); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_AND, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); eblock1[0] = 2; eblock1[3] = 2; @@ -14482,9 +14601,9 @@ test_hyper_unlim(void) eblock2[4] = 5; eblock2[2] = 1; eblock2[5] = 1; - dims[0] = 50; - dims[1] = 50; - dims[2] = 50; + dims[0] = 50; + dims[1] = 50; + dims[2] = 50; test_hyper_unlim_check(sid, dims, (hssize_t)3, (hssize_t)2, eblock1, eblock2); /* non-unlim NOTB unlim */ @@ -14494,7 +14613,7 @@ test_hyper_unlim(void) count2[0] = 2; count2[1] = 2; count2[2] = 6; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start2, NULL, count2, NULL); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start2, NULL, count2, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); count[0] = 1; count[1] = H5S_UNLIMITED; @@ -14502,7 +14621,7 @@ test_hyper_unlim(void) block[0] = 2; block[1] = 2; block[2] = 2; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, stride, count, block); + ret = H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); eblock1[0] = 1; eblock1[3] = 2; @@ -14516,9 +14635,9 @@ test_hyper_unlim(void) eblock2[4] = 6; eblock2[2] = 6; eblock2[5] = 7; - dims[0] = 50; - dims[1] = 50; - dims[2] = 50; + dims[0] = 50; + dims[1] = 50; + dims[2] = 50; test_hyper_unlim_check(sid, dims, (hssize_t)12, (hssize_t)2, eblock1, eblock2); /* Test H5Sget_select_npoints() */ @@ -14556,37 +14675,37 @@ test_hyper_unlim(void) static void test_internal_consistency(void) { - hid_t all_sid; /* Dataspace ID with "all" selection */ - hid_t none_sid; /* Dataspace ID with "none" selection */ - hid_t single_pt_sid; /* Dataspace ID with single point selection */ - hid_t mult_pt_sid; /* Dataspace ID with multiple point selection */ - hid_t single_hyper_sid; /* Dataspace ID with single block hyperslab selection */ - hid_t single_hyper_all_sid; /* Dataspace ID with single block hyperslab - * selection that is the entire dataspace - */ - hid_t single_hyper_pt_sid; /* Dataspace ID with single block hyperslab - * selection that is the same as the single - * point selection - */ - hid_t regular_hyper_sid; /* Dataspace ID with regular hyperslab selection */ - hid_t irreg_hyper_sid; /* Dataspace ID with irregular hyperslab selection */ - hid_t none_hyper_sid; /* Dataspace ID with "no hyperslabs" selection */ - hid_t scalar_all_sid; /* ID for scalar dataspace with "all" selection */ - hid_t scalar_none_sid; /* ID for scalar dataspace with "none" selection */ - hid_t tmp_sid; /* Temporary dataspace ID */ - hsize_t dims[] = {SPACE9_DIM1, SPACE9_DIM2}; - hsize_t coord1[1][SPACE2_RANK]; /* Coordinates for single point selection */ - hsize_t coord2[SPACE9_DIM2][SPACE9_RANK]; /* Coordinates for multiple point selection */ - hsize_t start[SPACE9_RANK]; /* Hyperslab start */ - hsize_t stride[SPACE9_RANK]; /* Hyperslab stride */ - hsize_t count[SPACE9_RANK]; /* Hyperslab block count */ - hsize_t block[SPACE9_RANK]; /* Hyperslab block size */ - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hid_t all_sid; /* Dataspace ID with "all" selection */ + hid_t none_sid; /* Dataspace ID with "none" selection */ + hid_t single_pt_sid; /* Dataspace ID with single point selection */ + hid_t mult_pt_sid; /* Dataspace ID with multiple point selection */ + hid_t single_hyper_sid; /* Dataspace ID with single block hyperslab selection */ + hid_t single_hyper_all_sid; /* Dataspace ID with single block hyperslab + * selection that is the entire dataspace + */ + hid_t single_hyper_pt_sid; /* Dataspace ID with single block hyperslab + * selection that is the same as the single + * point selection + */ + hid_t regular_hyper_sid; /* Dataspace ID with regular hyperslab selection */ + hid_t irreg_hyper_sid; /* Dataspace ID with irregular hyperslab selection */ + hid_t none_hyper_sid; /* Dataspace ID with "no hyperslabs" selection */ + hid_t scalar_all_sid; /* ID for scalar dataspace with "all" selection */ + hid_t scalar_none_sid; /* ID for scalar dataspace with "none" selection */ + hid_t tmp_sid; /* Temporary dataspace ID */ + hsize_t dims[] = {SPACE9_DIM1, SPACE9_DIM2}; + hsize_t coord1[1][SPACE2_RANK]; /* Coordinates for single point selection */ + hsize_t coord2[SPACE9_DIM2][SPACE9_RANK]; /* Coordinates for multiple point selection */ + hsize_t start[SPACE9_RANK]; /* Hyperslab start */ + hsize_t stride[SPACE9_RANK]; /* Hyperslab stride */ + hsize_t count[SPACE9_RANK]; /* Hyperslab block count */ + hsize_t block[SPACE9_RANK]; /* Hyperslab block size */ + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing Consistency of Internal States\n")); - assert(SPACE9_DIM2>=POINT1_NPOINTS); + assert(SPACE9_DIM2 >= POINT1_NPOINTS); /* Create dataspace for "all" selection */ all_sid = H5Screate_simple(SPACE9_RANK, dims, NULL); @@ -14609,8 +14728,9 @@ test_internal_consistency(void) CHECK(single_pt_sid, FAIL, "H5Screate_simple"); /* Select sequence of ten points for multiple point selection */ - coord1[0][0] = 2; coord1[0][1] = 2; - ret = H5Sselect_elements(single_pt_sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord1); + coord1[0][0] = 2; + coord1[0][1] = 2; + ret = H5Sselect_elements(single_pt_sid, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); /* Create dataspace for multiple point selection */ @@ -14618,16 +14738,26 @@ test_internal_consistency(void) CHECK(mult_pt_sid, FAIL, "H5Screate_simple"); /* Select sequence of ten points for multiple point selection */ - coord2[0][0]=2; coord2[0][1]=2; - coord2[1][0]=7; coord2[1][1]=2; - coord2[2][0]=1; coord2[2][1]=4; - coord2[3][0]=2; coord2[3][1]=6; - coord2[4][0]=0; coord2[4][1]=8; - coord2[5][0]=3; coord2[5][1]=2; - coord2[6][0]=4; coord2[6][1]=4; - coord2[7][0]=1; coord2[7][1]=0; - coord2[8][0]=5; coord2[8][1]=1; - coord2[9][0]=9; coord2[9][1]=3; + coord2[0][0] = 2; + coord2[0][1] = 2; + coord2[1][0] = 7; + coord2[1][1] = 2; + coord2[2][0] = 1; + coord2[2][1] = 4; + coord2[3][0] = 2; + coord2[3][1] = 6; + coord2[4][0] = 0; + coord2[4][1] = 8; + coord2[5][0] = 3; + coord2[5][1] = 2; + coord2[6][0] = 4; + coord2[6][1] = 4; + coord2[7][0] = 1; + coord2[7][1] = 0; + coord2[8][0] = 5; + coord2[8][1] = 1; + coord2[9][0] = 9; + coord2[9][1] = 3; ret = H5Sselect_elements(mult_pt_sid, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2); CHECK(ret, FAIL, "H5Sselect_elements"); @@ -14636,11 +14766,15 @@ test_internal_consistency(void) CHECK(single_hyper_sid, FAIL, "H5Screate_simple"); /* Select 10x10 hyperslab for single hyperslab selection */ - start[0]=1; start[1]=1; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=(SPACE9_DIM1-2); block[1]=(SPACE9_DIM2-2); - ret = H5Sselect_hyperslab(single_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 1; + start[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = (SPACE9_DIM1 - 2); + block[1] = (SPACE9_DIM2 - 2); + ret = H5Sselect_hyperslab(single_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for single hyperslab selection with entire extent selected */ @@ -14648,11 +14782,15 @@ test_internal_consistency(void) CHECK(single_hyper_all_sid, FAIL, "H5Screate_simple"); /* Select entire extent for hyperslab selection */ - start[0]=0; start[1]=0; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=SPACE9_DIM1; block[1]=SPACE9_DIM2; - ret = H5Sselect_hyperslab(single_hyper_all_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 0; + start[1] = 0; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = SPACE9_DIM1; + block[1] = SPACE9_DIM2; + ret = H5Sselect_hyperslab(single_hyper_all_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for single hyperslab selection with single point selected */ @@ -14660,11 +14798,15 @@ test_internal_consistency(void) CHECK(single_hyper_pt_sid, FAIL, "H5Screate_simple"); /* Select entire extent for hyperslab selection */ - start[0]=2; start[1]=2; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(single_hyper_pt_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(single_hyper_pt_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for regular hyperslab selection */ @@ -14672,11 +14814,15 @@ test_internal_consistency(void) CHECK(regular_hyper_sid, FAIL, "H5Screate_simple"); /* Select regular, strided hyperslab selection */ - start[0]=2; start[1]=2; - stride[0]=2; stride[1]=2; - count[0]=5; count[1]=2; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(regular_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + stride[0] = 2; + stride[1] = 2; + count[0] = 5; + count[1] = 2; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(regular_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for irregular hyperslab selection */ @@ -14684,18 +14830,26 @@ test_internal_consistency(void) CHECK(irreg_hyper_sid, FAIL, "H5Screate_simple"); /* Create irregular hyperslab selection by OR'ing two blocks together */ - start[0]=2; start[1]=2; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(irreg_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(irreg_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0]=4; start[1]=4; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=3; block[1]=3; - ret = H5Sselect_hyperslab(irreg_hyper_sid,H5S_SELECT_OR,start,stride,count,block); + start[0] = 4; + start[1] = 4; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 3; + block[1] = 3; + ret = H5Sselect_hyperslab(irreg_hyper_sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for "no" hyperslab selection */ @@ -14703,14 +14857,18 @@ test_internal_consistency(void) CHECK(none_hyper_sid, FAIL, "H5Screate_simple"); /* Create "no" hyperslab selection by XOR'ing same blocks together */ - start[0]=2; start[1]=2; - stride[0]=1; stride[1]=1; - count[0]=1; count[1]=1; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(none_hyper_sid,H5S_SELECT_SET,start,stride,count,block); + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 1; + count[1] = 1; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(none_hyper_sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - ret = H5Sselect_hyperslab(none_hyper_sid,H5S_SELECT_XOR,start,stride,count,block); + ret = H5Sselect_hyperslab(none_hyper_sid, H5S_SELECT_XOR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create scalar dataspace for "all" selection */ @@ -14728,7 +14886,7 @@ test_internal_consistency(void) /* Test all the selections created */ /* Test the copy of itself */ - tmp_sid=H5Scopy(all_sid); + tmp_sid = H5Scopy(all_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); check = H5S__internal_consistency_test(tmp_sid); @@ -14806,7 +14964,7 @@ test_internal_consistency(void) CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(scalar_none_sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_internal_consistency() */ +} /* test_internal_consistency() */ /**************************************************************** ** @@ -14817,22 +14975,22 @@ test_internal_consistency(void) static void test_irreg_io(void) { - hid_t fid; /* File ID */ - hid_t did; /* Dataset ID */ - hid_t dcpl_id; /* Dataset creation property list ID */ - hid_t sid; /* File dataspace ID */ - hid_t mem_sid; /* Memory dataspace ID */ - hsize_t dims[] = {6, 12}; /* Dataspace dimensions */ - hsize_t chunk_dims[] = {2, 2}; /* Chunk dimensions */ - hsize_t mem_dims[] = {32}; /* Memory dataspace dimensions */ - hsize_t start[2]; /* Hyperslab start */ - hsize_t stride[2]; /* Hyperslab stride */ - hsize_t count[2]; /* Hyperslab block count */ - hsize_t block[2]; /* Hyperslab block size */ - unsigned char wbuf[72]; /* Write buffer */ - unsigned char rbuf[32]; /* Read buffer */ - unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* File ID */ + hid_t did; /* Dataset ID */ + hid_t dcpl_id; /* Dataset creation property list ID */ + hid_t sid; /* File dataspace ID */ + hid_t mem_sid; /* Memory dataspace ID */ + hsize_t dims[] = {6, 12}; /* Dataspace dimensions */ + hsize_t chunk_dims[] = {2, 2}; /* Chunk dimensions */ + hsize_t mem_dims[] = {32}; /* Memory dataspace dimensions */ + hsize_t start[2]; /* Hyperslab start */ + hsize_t stride[2]; /* Hyperslab stride */ + hsize_t count[2]; /* Hyperslab block count */ + hsize_t block[2]; /* Hyperslab block size */ + unsigned char wbuf[72]; /* Write buffer */ + unsigned char rbuf[32]; /* Read buffer */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing Irregular Hyperslab I/O\n")); @@ -14856,7 +15014,7 @@ test_irreg_io(void) CHECK(did, FAIL, "H5Dcreate2"); /* Initialize the write buffer */ - for(u = 0; u < 72; u++) + for (u = 0; u < 72; u++) wbuf[u] = (unsigned char)u; /* Write entire dataset to disk */ @@ -14872,18 +15030,26 @@ test_irreg_io(void) CHECK(mem_sid, FAIL, "H5Screate_simple"); /* Select 'L'-shaped region within dataset */ - start[0] = 0; start[1] = 10; - stride[0] = 1; stride[1] = 1; - count[0] = 4; count[1] = 2; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 0; + start[1] = 10; + stride[0] = 1; + stride[1] = 1; + count[0] = 4; + count[1] = 2; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 4; start[1] = 0; - stride[0] = 1; stride[1] = 1; - count[0] = 2; count[1] = 12; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); + start[0] = 4; + start[1] = 0; + stride[0] = 1; + stride[1] = 1; + count[0] = 2; + count[1] = 12; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Reset the buffer */ @@ -14893,7 +15059,6 @@ test_irreg_io(void) ret = H5Dread(did, H5T_NATIVE_UCHAR, mem_sid, sid, H5P_DEFAULT, rbuf); CHECK(ret, FAIL, "H5Dread"); - /* Close everything */ ret = H5Sclose(mem_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -14903,7 +15068,7 @@ test_irreg_io(void) CHECK(ret, FAIL, "H5Dclose"); ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* test_irreg_io() */ +} /* test_irreg_io() */ /**************************************************************** ** @@ -14913,22 +15078,22 @@ test_irreg_io(void) static void test_sel_iter(void) { - hid_t sid; /* Dataspace ID */ - hid_t iter_id; /* Dataspace selection iterator ID */ - hsize_t dims1[] = {6, 12}; /* 2-D Dataspace dimensions */ - hsize_t coord1[POINT1_NPOINTS][2]; /* Coordinates for point selection */ - hsize_t start[2]; /* Hyperslab start */ - hsize_t stride[2]; /* Hyperslab stride */ - hsize_t count[2]; /* Hyperslab block count */ - hsize_t block[2]; /* Hyperslab block size */ - size_t nseq; /* # of sequences retrieved */ - size_t nbytes; /* # of bytes retrieved */ - hsize_t off[SEL_ITER_MAX_SEQ]; /* Offsets for retrieved sequences */ - size_t len[SEL_ITER_MAX_SEQ]; /* Lengths for retrieved sequences */ - H5S_sel_type sel_type; /* Selection type */ - unsigned sel_share; /* Whether to share selection with dataspace */ - unsigned sel_iter_flags; /* Flags for selection iterator creation */ - herr_t ret; /* Generic return value */ + hid_t sid; /* Dataspace ID */ + hid_t iter_id; /* Dataspace selection iterator ID */ + hsize_t dims1[] = {6, 12}; /* 2-D Dataspace dimensions */ + hsize_t coord1[POINT1_NPOINTS][2]; /* Coordinates for point selection */ + hsize_t start[2]; /* Hyperslab start */ + hsize_t stride[2]; /* Hyperslab stride */ + hsize_t count[2]; /* Hyperslab block count */ + hsize_t block[2]; /* Hyperslab block size */ + size_t nseq; /* # of sequences retrieved */ + size_t nbytes; /* # of bytes retrieved */ + hsize_t off[SEL_ITER_MAX_SEQ]; /* Offsets for retrieved sequences */ + size_t len[SEL_ITER_MAX_SEQ]; /* Lengths for retrieved sequences */ + H5S_sel_type sel_type; /* Selection type */ + unsigned sel_share; /* Whether to share selection with dataspace */ + unsigned sel_iter_flags; /* Flags for selection iterator creation */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing Dataspace Selection Iterators\n")); @@ -14937,36 +15102,44 @@ test_sel_iter(void) sid = H5Screate_simple(2, dims1, NULL); CHECK(sid, FAIL, "H5Screate_simple"); - /* Try creating selection iterator object with bad parameters */ - H5E_BEGIN_TRY { /* Bad dataspace ID */ + H5E_BEGIN_TRY + { /* Bad dataspace ID */ iter_id = H5Ssel_iter_create(H5I_INVALID_HID, (size_t)1, (unsigned)0); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(iter_id, FAIL, "H5Ssel_iter_create"); - H5E_BEGIN_TRY { /* Bad element size */ + H5E_BEGIN_TRY + { /* Bad element size */ iter_id = H5Ssel_iter_create(sid, (size_t)0, (unsigned)0); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(iter_id, FAIL, "H5Ssel_iter_create"); - H5E_BEGIN_TRY { /* Bad flag(s) */ + H5E_BEGIN_TRY + { /* Bad flag(s) */ iter_id = H5Ssel_iter_create(sid, (size_t)1, (unsigned)0xffff); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(iter_id, FAIL, "H5Ssel_iter_create"); /* Try closing selection iterator, with bad parameters */ - H5E_BEGIN_TRY { /* Invalid ID */ + H5E_BEGIN_TRY + { /* Invalid ID */ ret = H5Ssel_iter_close(H5I_INVALID_HID); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Ssel_iter_close"); - H5E_BEGIN_TRY { /* Not a selection iterator ID */ + H5E_BEGIN_TRY + { /* Not a selection iterator ID */ ret = H5Ssel_iter_close(sid); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Ssel_iter_close"); - /* Try with no selection sharing, and with sharing */ - for(sel_share = 0; sel_share < 2; sel_share++) { + for (sel_share = 0; sel_share < 2; sel_share++) { /* Set selection iterator sharing flags */ - if(sel_share) + if (sel_share) sel_iter_flags = H5S_SEL_ITER_SHARE_WITH_DATASPACE; else sel_iter_flags = 0; @@ -14980,78 +15153,103 @@ test_sel_iter(void) CHECK(ret, FAIL, "H5Ssel_iter_close"); /* Try closing selection iterator twice */ - H5E_BEGIN_TRY { /* Invalid ID */ + H5E_BEGIN_TRY + { /* Invalid ID */ ret = H5Ssel_iter_close(iter_id); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Ssel_iter_close"); - /* Create selection iterator object */ iter_id = H5Ssel_iter_create(sid, (size_t)1, (unsigned)sel_iter_flags); CHECK(iter_id, FAIL, "H5Ssel_iter_create"); /* Try retrieving sequences, with bad parameters */ - H5E_BEGIN_TRY { /* Invalid ID */ + H5E_BEGIN_TRY + { /* Invalid ID */ ret = H5Ssel_iter_get_seq_list(H5I_INVALID_HID, (size_t)1, (size_t)1, &nseq, &nbytes, off, len); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Ssel_iter_get_seq_list"); - H5E_BEGIN_TRY { /* Invalid nseq pointer */ + H5E_BEGIN_TRY + { /* Invalid nseq pointer */ ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)1, (size_t)1, NULL, &nbytes, off, len); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Ssel_iter_get_seq_list"); - H5E_BEGIN_TRY { /* Invalid nbytes pointer */ + H5E_BEGIN_TRY + { /* Invalid nbytes pointer */ ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)1, (size_t)1, &nseq, NULL, off, len); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Ssel_iter_get_seq_list"); - H5E_BEGIN_TRY { /* Invalid offset array */ + H5E_BEGIN_TRY + { /* Invalid offset array */ ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)1, (size_t)1, &nseq, &nbytes, NULL, len); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Ssel_iter_get_seq_list"); - H5E_BEGIN_TRY { /* Invalid length array */ + H5E_BEGIN_TRY + { /* Invalid length array */ ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)1, (size_t)1, &nseq, &nbytes, off, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(ret, FAIL, "H5Ssel_iter_get_seq_list"); /* Close selection iterator */ ret = H5Ssel_iter_close(iter_id); CHECK(ret, FAIL, "H5Ssel_iter_close"); - /* Test iterators on various basic selection types */ - for(sel_type = H5S_SEL_NONE; sel_type <= H5S_SEL_ALL; sel_type = (H5S_sel_type)(sel_type + 1)) { - switch(sel_type) { - case H5S_SEL_NONE: /* "None" selection */ + for (sel_type = H5S_SEL_NONE; sel_type <= H5S_SEL_ALL; sel_type = (H5S_sel_type)(sel_type + 1)) { + switch (sel_type) { + case H5S_SEL_NONE: /* "None" selection */ ret = H5Sselect_none(sid); CHECK(ret, FAIL, "H5Sselect_none"); break; - case H5S_SEL_POINTS: /* Point selection */ + case H5S_SEL_POINTS: /* Point selection */ /* Select sequence of ten points */ - coord1[0][0] = 0; coord1[0][1] = 9; - coord1[1][0] = 1; coord1[1][1] = 2; - coord1[2][0] = 2; coord1[2][1] = 4; - coord1[3][0] = 0; coord1[3][1] = 6; - coord1[4][0] = 1; coord1[4][1] = 8; - coord1[5][0] = 2; coord1[5][1] = 10; - coord1[6][0] = 0; coord1[6][1] = 11; - coord1[7][0] = 1; coord1[7][1] = 4; - coord1[8][0] = 2; coord1[8][1] = 1; - coord1[9][0] = 0; coord1[9][1] = 3; - ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + coord1[0][0] = 0; + coord1[0][1] = 9; + coord1[1][0] = 1; + coord1[1][1] = 2; + coord1[2][0] = 2; + coord1[2][1] = 4; + coord1[3][0] = 0; + coord1[3][1] = 6; + coord1[4][0] = 1; + coord1[4][1] = 8; + coord1[5][0] = 2; + coord1[5][1] = 10; + coord1[6][0] = 0; + coord1[6][1] = 11; + coord1[7][0] = 1; + coord1[7][1] = 4; + coord1[8][0] = 2; + coord1[8][1] = 1; + coord1[9][0] = 0; + coord1[9][1] = 3; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, + (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); break; - case H5S_SEL_HYPERSLABS: /* Hyperslab selection */ + case H5S_SEL_HYPERSLABS: /* Hyperslab selection */ /* Select regular hyperslab */ - start[0] = 3; start[1] = 0; - stride[0] = 2; stride[1] = 2; - count[0] = 2; count[1] = 5; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 3; + start[1] = 0; + stride[0] = 2; + stride[1] = 2; + count[0] = 2; + count[1] = 5; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); break; - case H5S_SEL_ALL: /* "All" selection */ + case H5S_SEL_ALL: /* "All" selection */ ret = H5Sselect_all(sid); CHECK(ret, FAIL, "H5Sselect_all"); break; @@ -15078,27 +15276,28 @@ test_sel_iter(void) VERIFY(nbytes, 0, "H5Ssel_iter_get_seq_list"); /* Try retrieving all sequences */ - ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)SEL_ITER_MAX_SEQ, (size_t)(1024 * 1024), &nseq, &nbytes, off, len); + ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)SEL_ITER_MAX_SEQ, (size_t)(1024 * 1024), &nseq, + &nbytes, off, len); CHECK(ret, FAIL, "H5Ssel_iter_get_seq_list"); /* Check results from retrieving sequence list */ - switch(sel_type) { - case H5S_SEL_NONE: /* "None" selection */ + switch (sel_type) { + case H5S_SEL_NONE: /* "None" selection */ VERIFY(nseq, 0, "H5Ssel_iter_get_seq_list"); VERIFY(nbytes, 0, "H5Ssel_iter_get_seq_list"); break; - case H5S_SEL_POINTS: /* Point selection */ + case H5S_SEL_POINTS: /* Point selection */ VERIFY(nseq, 10, "H5Ssel_iter_get_seq_list"); VERIFY(nbytes, 10, "H5Ssel_iter_get_seq_list"); break; - case H5S_SEL_HYPERSLABS: /* Hyperslab selection */ + case H5S_SEL_HYPERSLABS: /* Hyperslab selection */ VERIFY(nseq, 10, "H5Ssel_iter_get_seq_list"); VERIFY(nbytes, 10, "H5Ssel_iter_get_seq_list"); break; - case H5S_SEL_ALL: /* "All" selection */ + case H5S_SEL_ALL: /* "All" selection */ VERIFY(nseq, 1, "H5Ssel_iter_get_seq_list"); VERIFY(nbytes, 72, "H5Ssel_iter_get_seq_list"); break; @@ -15116,16 +15315,26 @@ test_sel_iter(void) } /* end for */ /* Point selection which will merge into smaller # of sequences */ - coord1[0][0] = 0; coord1[0][1] = 9; - coord1[1][0] = 0; coord1[1][1] = 10; - coord1[2][0] = 0; coord1[2][1] = 11; - coord1[3][0] = 0; coord1[3][1] = 6; - coord1[4][0] = 1; coord1[4][1] = 8; - coord1[5][0] = 2; coord1[5][1] = 10; - coord1[6][0] = 0; coord1[6][1] = 11; - coord1[7][0] = 1; coord1[7][1] = 4; - coord1[8][0] = 1; coord1[8][1] = 5; - coord1[9][0] = 1; coord1[9][1] = 6; + coord1[0][0] = 0; + coord1[0][1] = 9; + coord1[1][0] = 0; + coord1[1][1] = 10; + coord1[2][0] = 0; + coord1[2][1] = 11; + coord1[3][0] = 0; + coord1[3][1] = 6; + coord1[4][0] = 1; + coord1[4][1] = 8; + coord1[5][0] = 2; + coord1[5][1] = 10; + coord1[6][0] = 0; + coord1[6][1] = 11; + coord1[7][0] = 1; + coord1[7][1] = 4; + coord1[8][0] = 1; + coord1[8][1] = 5; + coord1[9][0] = 1; + coord1[9][1] = 6; ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); CHECK(ret, FAIL, "H5Sselect_elements"); @@ -15134,7 +15343,8 @@ test_sel_iter(void) CHECK(iter_id, FAIL, "H5Ssel_iter_create"); /* Try retrieving all sequences */ - ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)SEL_ITER_MAX_SEQ, (size_t)(1024 * 1024), &nseq, &nbytes, off, len); + ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)SEL_ITER_MAX_SEQ, (size_t)(1024 * 1024), &nseq, + &nbytes, off, len); CHECK(ret, FAIL, "H5Ssel_iter_get_seq_list"); VERIFY(nseq, 6, "H5Ssel_iter_get_seq_list"); VERIFY(nbytes, 10, "H5Ssel_iter_get_seq_list"); @@ -15143,20 +15353,27 @@ test_sel_iter(void) ret = H5Ssel_iter_close(iter_id); CHECK(ret, FAIL, "H5Ssel_iter_close"); - /* Select irregular hyperslab, which will merge into smaller # of sequences */ - start[0] = 3; start[1] = 0; - stride[0] = 2; stride[1] = 2; - count[0] = 2; count[1] = 5; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 3; + start[1] = 0; + stride[0] = 2; + stride[1] = 2; + count[0] = 2; + count[1] = 5; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - start[0] = 3; start[1] = 3; - stride[0] = 2; stride[1] = 2; - count[0] = 2; count[1] = 5; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); + start[0] = 3; + start[1] = 3; + stride[0] = 2; + stride[1] = 2; + count[0] = 2; + count[1] = 5; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create selection iterator object */ @@ -15164,7 +15381,8 @@ test_sel_iter(void) CHECK(iter_id, FAIL, "H5Ssel_iter_create"); /* Try retrieving all sequences */ - ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)SEL_ITER_MAX_SEQ, (size_t)(1024 * 1024), &nseq, &nbytes, off, len); + ret = H5Ssel_iter_get_seq_list(iter_id, (size_t)SEL_ITER_MAX_SEQ, (size_t)(1024 * 1024), &nseq, + &nbytes, off, len); CHECK(ret, FAIL, "H5Ssel_iter_get_seq_list"); VERIFY(nseq, 6, "H5Ssel_iter_get_seq_list"); VERIFY(nbytes, 20, "H5Ssel_iter_get_seq_list"); @@ -15178,7 +15396,7 @@ test_sel_iter(void) /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_sel_iter() */ +} /* test_sel_iter() */ /**************************************************************** ** @@ -15189,20 +15407,20 @@ test_sel_iter(void) static void test_select_intersect_block(void) { - hid_t sid; /* Dataspace ID */ - hsize_t dims1[] = {6, 12}; /* 2-D Dataspace dimensions */ - hsize_t block_start[] = {1, 3}; /* Start offset for block */ - hsize_t block_end[] = {2, 5}; /* End offset for block */ - hsize_t block_end2[] = {0, 5}; /* Bad end offset for block */ - hsize_t block_end3[] = {2, 2}; /* Another bad end offset for block */ - hsize_t block_end4[] = {1, 3}; /* End offset that makes a single element block */ - hsize_t coord[10][2]; /* Coordinates for point selection */ - hsize_t start[2]; /* Starting location of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Element count of hyperslab */ - hsize_t block[2]; /* Block size of hyperslab */ - htri_t status; /* Intersection status */ - herr_t ret; /* Generic return value */ + hid_t sid; /* Dataspace ID */ + hsize_t dims1[] = {6, 12}; /* 2-D Dataspace dimensions */ + hsize_t block_start[] = {1, 3}; /* Start offset for block */ + hsize_t block_end[] = {2, 5}; /* End offset for block */ + hsize_t block_end2[] = {0, 5}; /* Bad end offset for block */ + hsize_t block_end3[] = {2, 2}; /* Another bad end offset for block */ + hsize_t block_end4[] = {1, 3}; /* End offset that makes a single element block */ + hsize_t coord[10][2]; /* Coordinates for point selection */ + hsize_t start[2]; /* Starting location of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Element count of hyperslab */ + hsize_t block[2]; /* Block size of hyperslab */ + htri_t status; /* Intersection status */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing Dataspace Selection Block Intersection\n")); @@ -15211,30 +15429,38 @@ test_select_intersect_block(void) sid = H5Screate_simple(2, dims1, NULL); CHECK(sid, FAIL, "H5Screate_simple"); - /* Try intersection calls with bad parameters */ - H5E_BEGIN_TRY { /* Bad dataspace ID */ + H5E_BEGIN_TRY + { /* Bad dataspace ID */ status = H5Sselect_intersect_block(H5I_INVALID_HID, block_start, block_end); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(status, FAIL, "H5Sselect_intersect_block"); - H5E_BEGIN_TRY { /* Bad start pointer */ + H5E_BEGIN_TRY + { /* Bad start pointer */ status = H5Sselect_intersect_block(sid, NULL, block_end); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(status, FAIL, "H5Sselect_intersect_block"); - H5E_BEGIN_TRY { /* Bad end pointer */ + H5E_BEGIN_TRY + { /* Bad end pointer */ status = H5Sselect_intersect_block(sid, block_start, NULL); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(status, FAIL, "H5Sselect_intersect_block"); - H5E_BEGIN_TRY { /* Invalid block */ + H5E_BEGIN_TRY + { /* Invalid block */ status = H5Sselect_intersect_block(sid, block_start, block_end2); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(status, FAIL, "H5Sselect_intersect_block"); - H5E_BEGIN_TRY { /* Another invalid block */ + H5E_BEGIN_TRY + { /* Another invalid block */ status = H5Sselect_intersect_block(sid, block_start, block_end3); - } H5E_END_TRY; + } + H5E_END_TRY; VERIFY(status, FAIL, "H5Sselect_intersect_block"); - /* Set selection to 'none' */ ret = H5Sselect_none(sid); CHECK(ret, FAIL, "H5Sselect_none"); @@ -15243,7 +15469,6 @@ test_select_intersect_block(void) status = H5Sselect_intersect_block(sid, block_start, block_end); VERIFY(status, FALSE, "H5Sselect_intersect_block"); - /* Set selection to 'all' */ ret = H5Sselect_all(sid); CHECK(ret, FAIL, "H5Sselect_all"); @@ -15252,19 +15477,28 @@ test_select_intersect_block(void) status = H5Sselect_intersect_block(sid, block_start, block_end); VERIFY(status, TRUE, "H5Sselect_intersect_block"); - /* Select sequence of ten points */ - coord[0][0] = 0; coord[0][1] = 10; - coord[1][0] = 1; coord[1][1] = 2; - coord[2][0] = 2; coord[2][1] = 4; - coord[3][0] = 0; coord[3][1] = 6; - coord[4][0] = 1; coord[4][1] = 8; - coord[5][0] = 2; coord[5][1] = 11; - coord[6][0] = 0; coord[6][1] = 4; - coord[7][0] = 1; coord[7][1] = 0; - coord[8][0] = 2; coord[8][1] = 1; - coord[9][0] = 0; coord[9][1] = 3; - ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)10, (const hsize_t *)coord); + coord[0][0] = 0; + coord[0][1] = 10; + coord[1][0] = 1; + coord[1][1] = 2; + coord[2][0] = 2; + coord[2][1] = 4; + coord[3][0] = 0; + coord[3][1] = 6; + coord[4][0] = 1; + coord[4][1] = 8; + coord[5][0] = 2; + coord[5][1] = 11; + coord[6][0] = 0; + coord[6][1] = 4; + coord[7][0] = 1; + coord[7][1] = 0; + coord[8][0] = 2; + coord[8][1] = 1; + coord[9][0] = 0; + coord[9][1] = 3; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)10, (const hsize_t *)coord); CHECK(ret, FAIL, "H5Sselect_elements"); /* Test block intersection with 'point' selection */ @@ -15273,13 +15507,16 @@ test_select_intersect_block(void) status = H5Sselect_intersect_block(sid, block_start, block_end4); VERIFY(status, FALSE, "H5Sselect_intersect_block"); - /* Select single 4x6 hyperslab block at (2,1) */ - start[0] = 2; start[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 4; count[1] = 6; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 2; + start[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 4; + count[1] = 6; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Test block intersection with single 'hyperslab' selection */ @@ -15289,11 +15526,15 @@ test_select_intersect_block(void) VERIFY(status, FALSE, "H5Sselect_intersect_block"); /* 'OR' another hyperslab block in, making an irregular hyperslab selection */ - start[0] = 3; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 4; count[1] = 6; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); + start[0] = 3; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 4; + count[1] = 6; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Test block intersection with 'hyperslab' selection */ @@ -15303,11 +15544,15 @@ test_select_intersect_block(void) VERIFY(status, FALSE, "H5Sselect_intersect_block"); /* Select regular, strided hyperslab selection */ - start[0] = 2; start[1] = 1; - stride[0] = 2; stride[1] = 2; - count[0] = 2; count[1] = 4; - block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + start[0] = 2; + start[1] = 1; + stride[0] = 2; + stride[1] = 2; + count[0] = 2; + count[1] = 4; + block[0] = 1; + block[1] = 1; + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Test block intersection with single 'hyperslab' selection */ @@ -15316,13 +15561,11 @@ test_select_intersect_block(void) status = H5Sselect_intersect_block(sid, block_start, block_end4); VERIFY(status, FALSE, "H5Sselect_intersect_block"); - /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} /* test_select_intersect_block() */ +} /* test_select_intersect_block() */ - /**************************************************************** ** ** test_hyper_io_1d(): @@ -15337,20 +15580,20 @@ test_select_intersect_block(void) static void test_hyper_io_1d(void) { - hid_t fid; /* File ID */ - hid_t did; /* Dataset ID */ - hid_t sid, mid; /* Dataspace IDs */ - hid_t dcpl; /* Dataset creation property list ID */ - hsize_t dims[1], maxdims[1], dimsm[1]; /* Dataset dimension sizes */ - hsize_t chunk_dims[1]; /* Chunk dimension size */ - hsize_t offset[1]; /* Starting offset for hyperslab */ - hsize_t stride[1]; /* Distance between blocks in the hyperslab selection */ - hsize_t count[1]; /* # of blocks in the the hyperslab selection */ - hsize_t block[1]; /* Size of block in the hyperslab selection */ - unsigned int wdata[CHUNKSZ]; /* Data to be written */ - unsigned int rdata[NUM_ELEMENTS/10]; /* Data to be read */ - herr_t ret; /* Generic return value */ - unsigned i; /* Local index variable */ + hid_t fid; /* File ID */ + hid_t did; /* Dataset ID */ + hid_t sid, mid; /* Dataspace IDs */ + hid_t dcpl; /* Dataset creation property list ID */ + hsize_t dims[1], maxdims[1], dimsm[1]; /* Dataset dimension sizes */ + hsize_t chunk_dims[1]; /* Chunk dimension size */ + hsize_t offset[1]; /* Starting offset for hyperslab */ + hsize_t stride[1]; /* Distance between blocks in the hyperslab selection */ + hsize_t count[1]; /* # of blocks in the the hyperslab selection */ + hsize_t block[1]; /* Size of block in the hyperslab selection */ + unsigned int wdata[CHUNKSZ]; /* Data to be written */ + unsigned int rdata[NUM_ELEMENTS / 10]; /* Data to be read */ + herr_t ret; /* Generic return value */ + unsigned i; /* Local index variable */ /* Output message about test being performed */ MESSAGE(6, ("Testing Hyperslab I/O for 1-d single block memory space\n")); @@ -15363,14 +15606,14 @@ test_hyper_io_1d(void) CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Create file dataspace */ - dims[0] = CHUNKSZ; + dims[0] = CHUNKSZ; maxdims[0] = H5S_UNLIMITED; - sid = H5Screate_simple(RANK, dims, maxdims); + sid = H5Screate_simple(RANK, dims, maxdims); CHECK(sid, H5I_INVALID_HID, "H5Pcreate"); /* Create memory dataspace */ dimsm[0] = CHUNKSZ; - mid = H5Screate_simple(RANK, dimsm, NULL); + mid = H5Screate_simple(RANK, dimsm, NULL); CHECK(mid, H5I_INVALID_HID, "H5Pcreate"); /* Set up to create a chunked dataset */ @@ -15378,7 +15621,7 @@ test_hyper_io_1d(void) CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate"); chunk_dims[0] = CHUNKSZ; - ret = H5Pset_chunk(dcpl, RANK, chunk_dims); + ret = H5Pset_chunk(dcpl, RANK, chunk_dims); CHECK(ret, FAIL, "H5Pset_chunk"); /* Create a chunked dataset */ @@ -15388,8 +15631,8 @@ test_hyper_io_1d(void) /* Set up hyperslab selection for file dataspace */ offset[0] = 0; stride[0] = 1; - count[0] = 1; - block[0] = CHUNKSZ; + count[0] = 1; + block[0] = CHUNKSZ; /* Write to each chunk in the dataset */ for (i = 0; i < NUMCHUNKS; i++) { @@ -15402,10 +15645,10 @@ test_hyper_io_1d(void) CHECK(ret, FAIL, "H5Dwrite"); /* Extend the dataset's dataspace */ - if(i < (NUMCHUNKS - 1)) { + if (i < (NUMCHUNKS - 1)) { offset[0] = offset[0] + CHUNKSZ; - dims[0] = dims[0] + CHUNKSZ; - ret = H5Dset_extent(did, dims); + dims[0] = dims[0] + CHUNKSZ; + ret = H5Dset_extent(did, dims); CHECK(ret, FAIL, "H5Dset_extent"); /* Get the dataset's current dataspace */ @@ -15437,8 +15680,8 @@ test_hyper_io_1d(void) /* Set up to read every 10th element in file dataspace */ offset[0] = 1; stride[0] = 10; - count[0] = NUM_ELEMENTS/10; - block[0] = 1; + count[0] = NUM_ELEMENTS / 10; + block[0] = 1; /* Get the dataset's dataspace */ sid = H5Dget_space(did); @@ -15448,7 +15691,7 @@ test_hyper_io_1d(void) /* Set up contiguous memory dataspace for the selected elements */ dimsm[0] = count[0]; - mid = H5Screate_simple(RANK, dimsm, NULL); + mid = H5Screate_simple(RANK, dimsm, NULL); CHECK(mid, H5I_INVALID_HID, "H5Screate_simple"); /* Read all the selected 10th elements in the dataset into "rdata" */ @@ -15456,9 +15699,9 @@ test_hyper_io_1d(void) CHECK(ret, FAIL, "H5Dread"); /* Verify data read is correct */ - for(i = 0; i < 6; i += 2) { + for (i = 0; i < 6; i += 2) { VERIFY(rdata[i], 1, "H5Dread\n"); - VERIFY(rdata[i+1], 11, "H5Dread\n"); + VERIFY(rdata[i + 1], 11, "H5Dread\n"); } /* Closing */ @@ -15471,9 +15714,8 @@ test_hyper_io_1d(void) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* test_hyper_io_1d() */ +} /* test_hyper_io_1d() */ - /**************************************************************** ** ** test_h5s_set_extent_none: @@ -15484,18 +15726,18 @@ test_hyper_io_1d(void) static void test_h5s_set_extent_none(void) { - hid_t sid = H5I_INVALID_HID; - hid_t dst_sid = H5I_INVALID_HID; - hid_t null_sid = H5I_INVALID_HID; - int rank = 1; - hsize_t current_dims = 123; + hid_t sid = H5I_INVALID_HID; + hid_t dst_sid = H5I_INVALID_HID; + hid_t null_sid = H5I_INVALID_HID; + int rank = 1; + hsize_t current_dims = 123; H5S_class_t cls; - int out_rank; - hsize_t out_dims; - hsize_t out_maxdims; - hssize_t out_points; - htri_t equal; - herr_t ret; + int out_rank; + hsize_t out_dims; + hsize_t out_maxdims; + hssize_t out_points; + htri_t equal; + herr_t ret; /* Specific values here don't matter as we're just going to reset */ sid = H5Screate_simple(rank, ¤t_dims, NULL); @@ -15544,7 +15786,6 @@ test_h5s_set_extent_none(void) } /* test_h5s_set_extent_none() */ - /**************************************************************** ** ** test_select(): Main H5S selection testing routine. @@ -15553,14 +15794,14 @@ test_h5s_set_extent_none(void) void test_select(void) { - hid_t plist_id; /* Property list for reading random hyperslabs */ - hid_t fapl; /* Property list accessing the file */ - int mdc_nelmts; /* Metadata number of elements */ - size_t rdcc_nelmts; /* Raw data number of elements */ - size_t rdcc_nbytes; /* Raw data number of bytes */ - double rdcc_w0; /* Raw data write percentage */ + hid_t plist_id; /* Property list for reading random hyperslabs */ + hid_t fapl; /* Property list accessing the file */ + int mdc_nelmts; /* Metadata number of elements */ + size_t rdcc_nelmts; /* Raw data number of elements */ + size_t rdcc_nbytes; /* Raw data number of bytes */ + double rdcc_w0; /* Raw data write percentage */ hssize_t offset[SPACE7_RANK] = {1, 1}; /* Offset for testing selection offsets */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Selections\n")); @@ -15574,31 +15815,39 @@ test_select(void) CHECK(ret, FAIL, "H5Pset_buffer"); /* These next tests use the same file */ - test_select_hyper(H5P_DEFAULT); /* Test basic H5S hyperslab selection code */ - test_select_hyper(plist_id); /* Test basic H5S hyperslab selection code */ - test_select_point(H5P_DEFAULT); /* Test basic H5S element selection code, also tests appending to existing element selections */ - test_select_point(plist_id); /* Test basic H5S element selection code, also tests appending to existing element selections */ - test_select_all(H5P_DEFAULT); /* Test basic all & none selection code */ - test_select_all(plist_id); /* Test basic all & none selection code */ - test_select_all_hyper(H5P_DEFAULT); /* Test basic all & none selection code */ - test_select_all_hyper(plist_id); /* Test basic all & none selection code */ + test_select_hyper(H5P_DEFAULT); /* Test basic H5S hyperslab selection code */ + test_select_hyper(plist_id); /* Test basic H5S hyperslab selection code */ + test_select_point(H5P_DEFAULT); /* Test basic H5S element selection code, also tests appending to existing + element selections */ + test_select_point(plist_id); /* Test basic H5S element selection code, also tests appending to existing + element selections */ + test_select_all(H5P_DEFAULT); /* Test basic all & none selection code */ + test_select_all(plist_id); /* Test basic all & none selection code */ + test_select_all_hyper(H5P_DEFAULT); /* Test basic all & none selection code */ + test_select_all_hyper(plist_id); /* Test basic all & none selection code */ /* These next tests use the same file */ - test_select_combo(); /* Test combined hyperslab & element selection code */ + test_select_combo(); /* Test combined hyperslab & element selection code */ test_select_hyper_stride(H5P_DEFAULT); /* Test strided hyperslab selection code */ - test_select_hyper_stride(plist_id); /* Test strided hyperslab selection code */ + test_select_hyper_stride(plist_id); /* Test strided hyperslab selection code */ test_select_hyper_contig(H5T_STD_U16LE, H5P_DEFAULT); /* Test contiguous hyperslab selection code */ - test_select_hyper_contig(H5T_STD_U16LE, plist_id); /* Test contiguous hyperslab selection code */ + test_select_hyper_contig(H5T_STD_U16LE, plist_id); /* Test contiguous hyperslab selection code */ test_select_hyper_contig(H5T_STD_U16BE, H5P_DEFAULT); /* Test contiguous hyperslab selection code */ - test_select_hyper_contig(H5T_STD_U16BE, plist_id); /* Test contiguous hyperslab selection code */ - test_select_hyper_contig2(H5T_STD_U16LE, H5P_DEFAULT); /* Test more contiguous hyperslab selection cases */ + test_select_hyper_contig(H5T_STD_U16BE, plist_id); /* Test contiguous hyperslab selection code */ + test_select_hyper_contig2(H5T_STD_U16LE, + H5P_DEFAULT); /* Test more contiguous hyperslab selection cases */ test_select_hyper_contig2(H5T_STD_U16LE, plist_id); /* Test more contiguous hyperslab selection cases */ - test_select_hyper_contig2(H5T_STD_U16BE, H5P_DEFAULT); /* Test more contiguous hyperslab selection cases */ + test_select_hyper_contig2(H5T_STD_U16BE, + H5P_DEFAULT); /* Test more contiguous hyperslab selection cases */ test_select_hyper_contig2(H5T_STD_U16BE, plist_id); /* Test more contiguous hyperslab selection cases */ - test_select_hyper_contig3(H5T_STD_U16LE, H5P_DEFAULT); /* Test yet more contiguous hyperslab selection cases */ - test_select_hyper_contig3(H5T_STD_U16LE, plist_id); /* Test yet more contiguous hyperslab selection cases */ - test_select_hyper_contig3(H5T_STD_U16BE, H5P_DEFAULT); /* Test yet more contiguous hyperslab selection cases */ - test_select_hyper_contig3(H5T_STD_U16BE, plist_id); /* Test yet more contiguous hyperslab selection cases */ + test_select_hyper_contig3(H5T_STD_U16LE, + H5P_DEFAULT); /* Test yet more contiguous hyperslab selection cases */ + test_select_hyper_contig3(H5T_STD_U16LE, + plist_id); /* Test yet more contiguous hyperslab selection cases */ + test_select_hyper_contig3(H5T_STD_U16BE, + H5P_DEFAULT); /* Test yet more contiguous hyperslab selection cases */ + test_select_hyper_contig3(H5T_STD_U16BE, + plist_id); /* Test yet more contiguous hyperslab selection cases */ test_select_hyper_contig_dr(H5T_STD_U16LE, H5P_DEFAULT); test_select_hyper_contig_dr(H5T_STD_U16LE, plist_id); test_select_hyper_contig_dr(H5T_STD_U16BE, H5P_DEFAULT); @@ -15607,28 +15856,28 @@ test_select(void) test_select_hyper_checker_board_dr(H5T_STD_U16LE, plist_id); test_select_hyper_checker_board_dr(H5T_STD_U16BE, H5P_DEFAULT); test_select_hyper_checker_board_dr(H5T_STD_U16BE, plist_id); - test_select_hyper_copy(); /* Test hyperslab selection copying code */ - test_select_point_copy(); /* Test point selection copying code */ - test_select_hyper_offset(); /* Test selection offset code with hyperslabs */ - test_select_hyper_offset2();/* Test more selection offset code with hyperslabs */ - test_select_point_offset(); /* Test selection offset code with elements */ - test_select_hyper_union(); /* Test hyperslab union code */ + test_select_hyper_copy(); /* Test hyperslab selection copying code */ + test_select_point_copy(); /* Test point selection copying code */ + test_select_hyper_offset(); /* Test selection offset code with hyperslabs */ + test_select_hyper_offset2(); /* Test more selection offset code with hyperslabs */ + test_select_point_offset(); /* Test selection offset code with elements */ + test_select_hyper_union(); /* Test hyperslab union code */ /* Fancy hyperslab API tests */ - test_select_hyper_union_stagger(); /* Test hyperslab union code for staggered slabs */ - test_select_hyper_union_3d(); /* Test hyperslab union code for 3-D dataset */ + test_select_hyper_union_stagger(); /* Test hyperslab union code for staggered slabs */ + test_select_hyper_union_3d(); /* Test hyperslab union code for 3-D dataset */ test_select_hyper_valid_combination(); /* Test different input combinations */ - test_select_hyper_and_2d(); /* Test hyperslab intersection (AND) code for 2-D dataset */ - test_select_hyper_xor_2d(); /* Test hyperslab XOR code for 2-D dataset */ + test_select_hyper_and_2d(); /* Test hyperslab intersection (AND) code for 2-D dataset */ + test_select_hyper_xor_2d(); /* Test hyperslab XOR code for 2-D dataset */ test_select_hyper_notb_2d(); /* Test hyperslab NOTB code for 2-D dataset */ test_select_hyper_nota_2d(); /* Test hyperslab NOTA code for 2-D dataset */ /* test the random hyperslab I/O with the default property list for reading */ - test_select_hyper_union_random_5d(H5P_DEFAULT); /* Test hyperslab union code for random 5-D hyperslabs */ + test_select_hyper_union_random_5d(H5P_DEFAULT); /* Test hyperslab union code for random 5-D hyperslabs */ /* test random hyperslab I/O with a small buffer for reads */ - test_select_hyper_union_random_5d(plist_id); /* Test hyperslab union code for random 5-D hyperslabs */ + test_select_hyper_union_random_5d(plist_id); /* Test hyperslab union code for random 5-D hyperslabs */ /* Create a dataset transfer property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -15736,8 +15985,7 @@ test_select(void) */ test_h5s_set_extent_none(); -} /* test_select() */ - +} /* test_select() */ /*------------------------------------------------------------------------- * Function: cleanup_select @@ -15756,4 +16004,3 @@ cleanup_select(void) { HDremove(FILENAME); } - diff --git a/test/tskiplist.c b/test/tskiplist.c index 2806afe..9ad4ea4 100644 --- a/test/tskiplist.c +++ b/test/tskiplist.c @@ -33,21 +33,23 @@ #include "H5SLprivate.h" /* The number of elements in testing arrays */ -#define NUM_ELEMS 1000 +#define NUM_ELEMS 1000 /* Random numbers */ static int *rand_num; static int *sort_rand_num; static int *rev_sort_rand_num; -static int tst_sort(const void *i1, const void *i2) +static int +tst_sort(const void *i1, const void *i2) { - return(*(const int *)i1-*(const int *)i2); + return (*(const int *)i1 - *(const int *)i2); } -static int tst_rev_sort(const void *i1, const void *i2) +static int +tst_rev_sort(const void *i1, const void *i2) { - return(*(const int *)i2-*(const int *)i1); + return (*(const int *)i2 - *(const int *)i1); } /**************************************************************** @@ -59,10 +61,10 @@ static int tst_rev_sort(const void *i1, const void *i2) static void test_skiplist_init(void) { - time_t curr_time; /* Current time, for seeding random number generator */ - int new_val; /* New value to insert */ + time_t curr_time; /* Current time, for seeding random number generator */ + int new_val; /* New value to insert */ unsigned found; /* Flag to indicate value was inserted already */ - size_t u,v; /* Local index variables */ + size_t u, v; /* Local index variables */ /* Allocate arrays */ rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS); @@ -77,7 +79,7 @@ test_skiplist_init(void) HDsrandom((unsigned)curr_time); /* Create randomized set of numbers */ - for(u = 0; u < NUM_ELEMS; u++) { + for (u = 0; u < NUM_ELEMS; u++) { do { /* Reset flag */ found = 0; @@ -86,13 +88,13 @@ test_skiplist_init(void) new_val = (int)(HDrandom() % 10001) - 5001; /* Check if the value is already in the array */ - for(v = 0; v < u; v++) - if(rand_num[v] == new_val) + for (v = 0; v < u; v++) + if (rand_num[v] == new_val) found = 1; - } while(found); + } while (found); /* Set unique value in array */ - rand_num[u]=new_val; + rand_num[u] = new_val; } /* end for */ /* Copy random values to sorted array */ @@ -117,8 +119,8 @@ test_skiplist_init(void) static void test_skiplist_create(void) { - H5SL_t *slist; /* Skip list created */ - herr_t ret; /* Generic return value */ + H5SL_t *slist; /* Skip list created */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(6, ("Testing Creating & Closing Skip Lists\n")); @@ -128,7 +130,7 @@ test_skiplist_create(void) CHECK_PTR(slist, "H5SL_create"); /* Try closing the skip list */ - ret=H5SL_close(slist); + ret = H5SL_close(slist); CHECK(ret, FAIL, "H5SL_close"); } /* end test_skiplist_create() */ @@ -142,13 +144,13 @@ test_skiplist_create(void) static void test_skiplist_insert(void) { - H5SL_t *slist; /* Skip list created */ - int key, /* Key of item to insert */ - item; /* Item to insert */ - int search_key; /* Key of item to search for in skip list */ - int *found_item; /* Item found in skip list */ - size_t num; /* Number of elements in skip list */ - herr_t ret; /* Generic return value */ + H5SL_t *slist; /* Skip list created */ + int key, /* Key of item to insert */ + item; /* Item to insert */ + int search_key; /* Key of item to search for in skip list */ + int * found_item; /* Item found in skip list */ + size_t num; /* Number of elements in skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Insertion Into Skip List\n")); @@ -158,40 +160,41 @@ test_skiplist_insert(void) CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ - num=H5SL_count(slist); + num = H5SL_count(slist); VERIFY(num, 0, "H5SL_count"); /* Try searching for item in empty skip list */ - key=37; - found_item=(int *)H5SL_search(slist,&key); + key = 37; + found_item = (int *)H5SL_search(slist, &key); CHECK_PTR_NULL(found_item, "H5SL_search"); /* Insert an object into the skip list */ - key=2; item=10; - ret=H5SL_insert(slist,&item,&key); + key = 2; + item = 10; + ret = H5SL_insert(slist, &item, &key); CHECK(ret, FAIL, "H5SL_insert"); /* Check that the skip list has one element */ - num=H5SL_count(slist); + num = H5SL_count(slist); VERIFY(num, 1, "H5SL_count"); /* Search for the item just inserted */ - found_item=(int *)H5SL_search(slist,&key); + found_item = (int *)H5SL_search(slist, &key); CHECK_PTR(found_item, "H5SL_search"); VERIFY(*found_item, item, "H5SL_search"); /* Search for an item not in list */ - search_key=37; - found_item=(int *)H5SL_search(slist,&search_key); + search_key = 37; + found_item = (int *)H5SL_search(slist, &search_key); CHECK_PTR_NULL(found_item, "H5SL_search"); /* Attempt to insert duplicate key (should fail) */ - search_key=2; - ret=H5SL_insert(slist,&search_key,&search_key); + search_key = 2; + ret = H5SL_insert(slist, &search_key, &search_key); VERIFY(ret, FAIL, "H5SL_insert"); /* Close the skip list */ - ret=H5SL_close(slist); + ret = H5SL_close(slist); CHECK(ret, FAIL, "H5SL_close"); } /* end test_skiplist_insert() */ @@ -206,10 +209,10 @@ static void test_skiplist_insert_many(void) { H5SL_t *slist; /* Skip list created */ - size_t num; /* Number of elements in skip list */ - size_t u; /* Local index variable */ - int *found_item; /* Item found in skip list */ - herr_t ret; /* Generic return value */ + size_t num; /* Number of elements in skip list */ + size_t u; /* Local index variable */ + int * found_item; /* Item found in skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Insertion of Many Items Into Skip List\n")); @@ -219,50 +222,50 @@ test_skiplist_insert_many(void) CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ - num=H5SL_count(slist); + num = H5SL_count(slist); VERIFY(num, 0, "H5SL_count"); /* Insert many objects into the skip list */ - for(u=0; ui, hashed_data[u].i, "H5SL_next"); u++; - node=H5SL_next(node); + node = H5SL_next(node); } /* end while */ /* Close the skip list */ - ret=H5SL_close(slist); + ret = H5SL_close(slist); CHECK(ret, FAIL, "H5SL_close"); } /* end test_skiplist_string() */ @@ -597,12 +583,12 @@ test_skiplist_string(void) static herr_t test_skiplist_iter(void *item, void H5_ATTR_UNUSED *key, void *op_data) { - size_t *up=(size_t *)op_data; + size_t *up = (size_t *)op_data; - VERIFY(*(int *)item,sort_rand_num[*up],"H5SL_iterate"); + VERIFY(*(int *)item, sort_rand_num[*up], "H5SL_iterate"); (*up)++; - return(0); + return (0); } /**************************************************************** @@ -614,10 +600,10 @@ test_skiplist_iter(void *item, void H5_ATTR_UNUSED *key, void *op_data) static void test_skiplist_iterate(void) { - H5SL_t *slist; /* Skip list created */ - size_t num; /* Number of elements in skip list */ - size_t u; /* Local index variable */ - herr_t ret; /* Generic return value */ + H5SL_t *slist; /* Skip list created */ + size_t num; /* Number of elements in skip list */ + size_t u; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Iterating Over Skip List\n")); @@ -627,26 +613,26 @@ test_skiplist_iterate(void) CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ - num=H5SL_count(slist); + num = H5SL_count(slist); VERIFY(num, 0, "H5SL_count"); /* Insert many objects into the skip list */ - for(u=0; ufileno,sorted_data[u].fileno,"H5SL_next"); - VERIFY(found_item->addr,sorted_data[u].addr,"H5SL_next"); + node = H5SL_first(slist); + u = 0; + while (node != NULL) { + found_item = (H5_obj_t *)H5SL_item(node); + VERIFY(found_item->fileno, sorted_data[u].fileno, "H5SL_next"); + VERIFY(found_item->addr, sorted_data[u].addr, "H5SL_next"); u++; - node=H5SL_next(node); + node = H5SL_next(node); } /* end while */ /* Close the skip list */ - ret=H5SL_close(slist); + ret = H5SL_close(slist); CHECK(ret, FAIL, "H5SL_close"); } /* end test_skiplist_obj() */ @@ -833,13 +821,14 @@ typedef struct generic_t { static int test_skiplist_generic_cmp(const void *_key1, const void *_key2) { - const generic_t *key1 = (const generic_t *)_key1; - const generic_t *key2 = (const generic_t *)_key2; - long long result = (long long)(key1->a) - (long long)(key1->b) - (long long)(key2->a) + (long long)(key2->b); + const generic_t *key1 = (const generic_t *)_key1; + const generic_t *key2 = (const generic_t *)_key2; + long long result = + (long long)(key1->a) - (long long)(key1->b) - (long long)(key2->a) + (long long)(key2->b); - if(result < 0) + if (result < 0) return -1; - else if(result > 0) + else if (result > 0) return 1; else return 0; @@ -848,14 +837,16 @@ test_skiplist_generic_cmp(const void *_key1, const void *_key2) static void test_skiplist_generic(void) { - H5SL_t *slist; /* Skip list created */ + H5SL_t * slist; /* Skip list created */ H5SL_node_t *node; /* Skip list node */ - size_t num; /* Number of elements in skip list */ - size_t u; /* Local index variable */ - generic_t data[10]={ {10, 1}, {20, 13}, {15, 32}, {5, 2}, {50, 37}, {30, 100}, {31, 38}, {32, 34}, {80, 32}, {90, 0} }; - generic_t sorted_data[10]={ {30, 100}, {15, 32}, {31, 38}, {32, 34}, {5, 2}, {20, 13}, {10, 1}, {50, 37}, {80, 32}, {90, 0} }; - generic_t *found_item; /* Item found in skip list */ - herr_t ret; /* Generic return value */ + size_t num; /* Number of elements in skip list */ + size_t u; /* Local index variable */ + generic_t data[10] = {{10, 1}, {20, 13}, {15, 32}, {5, 2}, {50, 37}, + {30, 100}, {31, 38}, {32, 34}, {80, 32}, {90, 0}}; + generic_t sorted_data[10] = {{30, 100}, {15, 32}, {31, 38}, {32, 34}, {5, 2}, + {20, 13}, {10, 1}, {50, 37}, {80, 32}, {90, 0}}; + generic_t * found_item; /* Item found in skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Skip List With generic Keys\n")); @@ -865,32 +856,32 @@ test_skiplist_generic(void) CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ - num=H5SL_count(slist); + num = H5SL_count(slist); VERIFY(num, 0, "H5SL_count"); /* Insert objects into the skip list */ - for(u=0; u<10; u++) { - ret=H5SL_insert(slist,&data[u],&data[u]); + for (u = 0; u < 10; u++) { + ret = H5SL_insert(slist, &data[u], &data[u]); CHECK(ret, FAIL, "H5SL_insert"); } /* end for */ /* Check that the skip list has correct # of elements */ - num=H5SL_count(slist); + num = H5SL_count(slist); VERIFY(num, 10, "H5SL_count"); /* Iterate over all the nodes in the skip list */ - node=H5SL_first(slist); - u=0; - while(node!=NULL) { - found_item=(generic_t *)H5SL_item(node); - VERIFY(found_item->a,sorted_data[u].a,"H5SL_next"); - VERIFY(found_item->b,sorted_data[u].b,"H5SL_next"); + node = H5SL_first(slist); + u = 0; + while (node != NULL) { + found_item = (generic_t *)H5SL_item(node); + VERIFY(found_item->a, sorted_data[u].a, "H5SL_next"); + VERIFY(found_item->b, sorted_data[u].b, "H5SL_next"); u++; - node=H5SL_next(node); + node = H5SL_next(node); } /* end while */ /* Close the skip list */ - ret=H5SL_close(slist); + ret = H5SL_close(slist); CHECK(ret, FAIL, "H5SL_close"); } /* end test_skiplist_generic() */ @@ -904,12 +895,12 @@ test_skiplist_generic(void) static void test_skiplist_lastprev(void) { - H5SL_t *slist; /* Skip list created */ - H5SL_node_t *node; /* Skip list node */ - size_t num; /* Number of elements in skip list */ - size_t u; /* Local index variable */ - int *found_item; /* Item found in skip list */ - herr_t ret; /* Generic return value */ + H5SL_t * slist; /* Skip list created */ + H5SL_node_t *node; /* Skip list node */ + size_t num; /* Number of elements in skip list */ + size_t u; /* Local index variable */ + int * found_item; /* Item found in skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Iterating Over Skip List With Last/Prev\n")); @@ -919,44 +910,44 @@ test_skiplist_lastprev(void) CHECK_PTR(slist, "H5SL_create"); /* Check that the skip list has no elements */ - num=H5SL_count(slist); + num = H5SL_count(slist); VERIFY(num, 0, "H5SL_count"); /* Check that the list appears empty */ - node=H5SL_last(slist); + node = H5SL_last(slist); CHECK_PTR_NULL(node, "H5SL_last"); /* Insert many objects into the skip list */ - for(u=0; ulast_idx++; - } while(udata->obj_list->list[udata->last_idx].nfrees != 0); + } while (udata->obj_list->list[udata->last_idx].nfrees != 0); VERIFY(udata->last_idx, obj->idx, "H5SL_iterate"); return 0; } /* end test_tfs_iter() */ /* try_free_safe callback */ -static htri_t test_tfs_free(void *_obj, void *key, void *_obj_list) { - test_tfs_obj_t *obj = (test_tfs_obj_t *)_obj; +static htri_t +test_tfs_free(void *_obj, void *key, void *_obj_list) +{ + test_tfs_obj_t * obj = (test_tfs_obj_t *)_obj; test_tfs_list_t *obj_list = (test_tfs_list_t *)_obj_list; test_tfs_it_ud_t iter_ud; - int nrems, rem_idx, i, j; - test_tfs_obj_t *obj_ret; - herr_t ret; /* return value */ - htri_t ret_value; + int nrems, rem_idx, i, j; + test_tfs_obj_t * obj_ret; + herr_t ret; /* return value */ + htri_t ret_value; /* Check consistency */ CHECK_PTR_EQ((void *)&obj->idx, key, "obj->idx"); @@ -1249,22 +1244,22 @@ static htri_t test_tfs_free(void *_obj, void *key, void *_obj_list) { nrems = (int)(HDrandom() % (long)3); /* Remove objects */ - for(i = 0; i < nrems; i++) + for (i = 0; i < nrems; i++) /* Check nobjs_rem */ - if(obj_list->nobjs_rem > 0) { + if (obj_list->nobjs_rem > 0) { /* Remove a random object from the list */ rem_idx = (int)(HDrandom() % (long)obj_list->nobjs_rem); /* Scan the list, finding the rem_idx'th object that has not been * freed */ - for(j = 0; j < obj_list->nobjs; j++) - if(obj_list->list[j].nfrees == 0) { - if(rem_idx == 0) + for (j = 0; j < obj_list->nobjs; j++) + if (obj_list->list[j].nfrees == 0) { + if (rem_idx == 0) break; else rem_idx--; } /* end if */ - if(j == obj_list->nobjs) + if (j == obj_list->nobjs) ERROR("invalid obj_list"); else { /* Remove the object */ @@ -1273,7 +1268,7 @@ static htri_t test_tfs_free(void *_obj, void *key, void *_obj_list) { obj_ret->nfrees++; obj_list->nobjs_rem--; } /* end else */ - } /* end if */ + } /* end if */ /* Mark this object as not freed so we know to expect it in the iterate call */ @@ -1281,21 +1276,21 @@ static htri_t test_tfs_free(void *_obj, void *key, void *_obj_list) { obj_list->nobjs_rem++; /* Iterate over skip list (maybe) */ - if(HDrandom() % (long)5) { + if (HDrandom() % (long)5) { iter_ud.obj_list = obj_list; iter_ud.last_idx = -1; - iter_ud.ncalls = 0; - ret = H5SL_iterate(obj_list->slist, test_tfs_iter, &iter_ud); + iter_ud.ncalls = 0; + ret = H5SL_iterate(obj_list->slist, test_tfs_iter, &iter_ud); CHECK(ret, FAIL, "H5SL_iterate"); VERIFY(iter_ud.ncalls, obj_list->nobjs_rem, "H5SL_iterate"); } /* end if */ /* Verify nobjs_rem is non-negative */ - if(obj_list->nobjs_rem < 0) + if (obj_list->nobjs_rem < 0) ERROR("invalid nobjs_rem"); /* Decide whether this object should be freed */ - if(HDrandom() % (long)2) { + if (HDrandom() % (long)2) { /* Free the object */ ret_value = TRUE; obj->nfrees++; @@ -1313,11 +1308,11 @@ static void test_skiplist_try_free_safe(void) { test_tfs_list_t obj_list; - test_tfs_obj_t list[TEST_TFS_MAX_NOBJS]; - int i, j; - int nobjs_found; - hsize_t count; - herr_t ret; /* Generic return value */ + test_tfs_obj_t list[TEST_TFS_MAX_NOBJS]; + int i, j; + int nobjs_found; + hsize_t count; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Skip List 'Try Free Safe' Operation\n")); @@ -1328,15 +1323,16 @@ test_skiplist_try_free_safe(void) /* Init obj_list.list */ obj_list.list = list; - for(j = 0; j < TEST_TFS_MAX_NOBJS; j++) + for (j = 0; j < TEST_TFS_MAX_NOBJS; j++) list[j].idx = j; - for(i = 0; i < TEST_TFS_NITER; i++) { + for (i = 0; i < TEST_TFS_NITER; i++) { /* Build object list */ - obj_list.nobjs = obj_list.nobjs_rem = (int)(TEST_TFS_MIN_NOBJS + (HDrandom() % (long)(TEST_TFS_MAX_NOBJS - TEST_TFS_MIN_NOBJS + 1))); - for(j = 0; j < obj_list.nobjs; j++) { + obj_list.nobjs = obj_list.nobjs_rem = + (int)(TEST_TFS_MIN_NOBJS + (HDrandom() % (long)(TEST_TFS_MAX_NOBJS - TEST_TFS_MIN_NOBJS + 1))); + for (j = 0; j < obj_list.nobjs; j++) { list[j].nfrees = 0; - ret = H5SL_insert(obj_list.slist, &list[j], &list[j].idx); + ret = H5SL_insert(obj_list.slist, &list[j], &list[j].idx); CHECK(ret, FAIL, "H5SL_insert"); } /* end for */ @@ -1347,8 +1343,8 @@ test_skiplist_try_free_safe(void) /* Verify list */ nobjs_found = 0; - for(j = 0; j < obj_list.nobjs; j++) - if(list[j].nfrees == 0) + for (j = 0; j < obj_list.nobjs; j++) + if (list[j].nfrees == 0) nobjs_found++; else VERIFY(list[j].nfrees, (long)1, "list[j].nfrees"); @@ -1383,13 +1379,13 @@ test_skiplist_try_free_safe(void) static void test_skiplist_less(void) { - H5SL_t *slist; /* Skip list created */ - size_t u; /* Local index variable */ - unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; + H5SL_t * slist; /* Skip list created */ + size_t u; /* Local index variable */ + unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; /* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */ - unsigned *found_item; /* Item found in skip list */ - unsigned find_item; /* Item to add to skip list */ - herr_t ret; /* Generic return value */ + unsigned *found_item; /* Item found in skip list */ + unsigned find_item; /* Item to add to skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Skip List 'Less' Operation\n")); @@ -1399,41 +1395,41 @@ test_skiplist_less(void) CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ - for(u=0; u<10; u++) { - ret=H5SL_insert(slist,&data[u],&data[u]); + for (u = 0; u < 10; u++) { + ret = H5SL_insert(slist, &data[u], &data[u]); CHECK(ret, FAIL, "H5SL_insert"); } /* end for */ /* Check for exact match of items in various positions */ - find_item=20; - found_item=(unsigned *)H5SL_less(slist,&find_item); - VERIFY(*found_item,find_item,"H5SL_less"); - find_item=90; - found_item=(unsigned *)H5SL_less(slist,&find_item); - VERIFY(*found_item,find_item,"H5SL_less"); - find_item=5; - found_item=(unsigned *)H5SL_less(slist,&find_item); - VERIFY(*found_item,find_item,"H5SL_less"); + find_item = 20; + found_item = (unsigned *)H5SL_less(slist, &find_item); + VERIFY(*found_item, find_item, "H5SL_less"); + find_item = 90; + found_item = (unsigned *)H5SL_less(slist, &find_item); + VERIFY(*found_item, find_item, "H5SL_less"); + find_item = 5; + found_item = (unsigned *)H5SL_less(slist, &find_item); + VERIFY(*found_item, find_item, "H5SL_less"); /* Find item less than a missing key, in various positions */ - find_item=19; - found_item=(unsigned *)H5SL_less(slist,&find_item); - VERIFY(*found_item,15,"H5SL_less"); - find_item=89; - found_item=(unsigned *)H5SL_less(slist,&find_item); - VERIFY(*found_item,80,"H5SL_less"); - find_item=100; - found_item=(unsigned *)H5SL_less(slist,&find_item); - VERIFY(*found_item,90,"H5SL_less"); - find_item=9; - found_item=(unsigned *)H5SL_less(slist,&find_item); - VERIFY(*found_item,5,"H5SL_less"); - find_item=4; - found_item=(unsigned *)H5SL_less(slist,&find_item); + find_item = 19; + found_item = (unsigned *)H5SL_less(slist, &find_item); + VERIFY(*found_item, 15, "H5SL_less"); + find_item = 89; + found_item = (unsigned *)H5SL_less(slist, &find_item); + VERIFY(*found_item, 80, "H5SL_less"); + find_item = 100; + found_item = (unsigned *)H5SL_less(slist, &find_item); + VERIFY(*found_item, 90, "H5SL_less"); + find_item = 9; + found_item = (unsigned *)H5SL_less(slist, &find_item); + VERIFY(*found_item, 5, "H5SL_less"); + find_item = 4; + found_item = (unsigned *)H5SL_less(slist, &find_item); CHECK_PTR_NULL(found_item, "H5SL_less"); /* Close the skip list */ - ret=H5SL_close(slist); + ret = H5SL_close(slist); CHECK(ret, FAIL, "H5SL_close"); } /* end test_skiplist_less() */ @@ -1447,13 +1443,13 @@ test_skiplist_less(void) static void test_skiplist_greater(void) { - H5SL_t *slist; /* Skip list created */ - size_t u; /* Local index variable */ - unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; + H5SL_t * slist; /* Skip list created */ + size_t u; /* Local index variable */ + unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; /* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */ - unsigned *found_item; /* Item found in skip list */ - unsigned find_item; /* Item to add to skip list */ - herr_t ret; /* Generic return value */ + unsigned *found_item; /* Item found in skip list */ + unsigned find_item; /* Item to add to skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Skip List 'Greater' Operation\n")); @@ -1463,36 +1459,36 @@ test_skiplist_greater(void) CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { ret = H5SL_insert(slist, &data[u], &data[u]); CHECK(ret, FAIL, "H5SL_insert"); } /* end for */ /* Check for exact match of items in various positions */ - find_item = 20; + find_item = 20; found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, find_item, "H5SL_greater"); - find_item = 90; + find_item = 90; found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, find_item, "H5SL_greater"); - find_item = 5; + find_item = 5; found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, find_item, "H5SL_greater"); /* Find item greater than a missing key, in various positions */ - find_item = 19; - found_item = (unsigned *)H5SL_greater(slist,&find_item); + find_item = 19; + found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, 20, "H5SL_greater"); - find_item = 89; + find_item = 89; found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, 90, "H5SL_greater"); - find_item = 100; + find_item = 100; found_item = (unsigned *)H5SL_greater(slist, &find_item); CHECK_PTR_NULL(found_item, "H5SL_greater"); - find_item = 6; + find_item = 6; found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, 10, "H5SL_greater"); - find_item = 4; + find_item = 4; found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, 5, "H5SL_greater"); @@ -1511,14 +1507,14 @@ test_skiplist_greater(void) static void test_skiplist_below(void) { - H5SL_t *slist; /* Skip list created */ + H5SL_t * slist; /* Skip list created */ H5SL_node_t *node; /* Skip list node */ - size_t u; /* Local index variable */ - unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; + size_t u; /* Local index variable */ + unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; /* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */ - unsigned *found_item; /* Item found in skip list */ - unsigned find_item; /* Item to add to skip list */ - herr_t ret; /* Generic return value */ + unsigned *found_item; /* Item found in skip list */ + unsigned find_item; /* Item to add to skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Skip List 'Below' Operation\n")); @@ -1528,51 +1524,51 @@ test_skiplist_below(void) CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { ret = H5SL_insert(slist, &data[u], &data[u]); CHECK(ret, FAIL, "H5SL_insert"); } /* end for */ /* Check for exact match of items in various positions */ find_item = 20; - node = H5SL_below(slist, &find_item); + node = H5SL_below(slist, &find_item); CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); find_item = 90; - node = H5SL_below(slist, &find_item); + node = H5SL_below(slist, &find_item); CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); find_item = 5; - node = H5SL_below(slist, &find_item); + node = H5SL_below(slist, &find_item); CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); /* Find item less than a missing key, in various positions */ find_item = 19; - node = H5SL_below(slist, &find_item); + node = H5SL_below(slist, &find_item); CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 15, "H5SL_below"); find_item = 89; - node = H5SL_below(slist, &find_item); + node = H5SL_below(slist, &find_item); CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 80, "H5SL_below"); find_item = 100; - node = H5SL_below(slist, &find_item); + node = H5SL_below(slist, &find_item); CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 90, "H5SL_below"); find_item = 9; - node = H5SL_below(slist, &find_item); + node = H5SL_below(slist, &find_item); CHECK_PTR(node, "H5SL_below"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 5, "H5SL_below"); find_item = 4; - node = (H5SL_node_t *)H5SL_less(slist, &find_item); + node = (H5SL_node_t *)H5SL_less(slist, &find_item); CHECK_PTR_NULL(node, "H5SL_below"); /* Close the skip list */ @@ -1590,14 +1586,14 @@ test_skiplist_below(void) static void test_skiplist_above(void) { - H5SL_t *slist; /* Skip list created */ + H5SL_t * slist; /* Skip list created */ H5SL_node_t *node; /* Skip list node */ - size_t u; /* Local index variable */ - unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; + size_t u; /* Local index variable */ + unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; /* unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; */ - unsigned *found_item; /* Item found in skip list */ - unsigned find_item; /* Item to add to skip list */ - herr_t ret; /* Generic return value */ + unsigned *found_item; /* Item found in skip list */ + unsigned find_item; /* Item to add to skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Skip List 'Above' Operation\n")); @@ -1607,49 +1603,49 @@ test_skiplist_above(void) CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { ret = H5SL_insert(slist, &data[u], &data[u]); CHECK(ret, FAIL, "H5SL_insert"); } /* end for */ /* Check for exact match of items in various positions */ find_item = 20; - node = H5SL_above(slist, &find_item); + node = H5SL_above(slist, &find_item); CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); find_item = 90; - node = H5SL_above(slist, &find_item); + node = H5SL_above(slist, &find_item); CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); find_item = 5; - node = H5SL_above(slist, &find_item); + node = H5SL_above(slist, &find_item); CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); /* Find item greater than a missing key, in various positions */ find_item = 19; - node = H5SL_above(slist, &find_item); + node = H5SL_above(slist, &find_item); CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 20, "H5SL_above"); find_item = 89; - node = H5SL_above(slist, &find_item); + node = H5SL_above(slist, &find_item); CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 90, "H5SL_above"); find_item = 100; - node = H5SL_above(slist, &find_item); + node = H5SL_above(slist, &find_item); CHECK_PTR_NULL(node, "H5SL_above"); find_item = 6; - node = H5SL_above(slist, &find_item); + node = H5SL_above(slist, &find_item); CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 10, "H5SL_above"); find_item = 4; - node = H5SL_above(slist, &find_item); + node = H5SL_above(slist, &find_item); CHECK_PTR(node, "H5SL_above"); found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 5, "H5SL_above"); @@ -1669,12 +1665,12 @@ test_skiplist_above(void) static void test_skiplist_remove_first(void) { - H5SL_t *slist; /* Skip list created */ - size_t u; /* Local index variable */ - unsigned data[10]={ 10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; - unsigned sorted_data[10]={ 5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; - unsigned *found_item; /* Item found in skip list */ - herr_t ret; /* Generic return value */ + H5SL_t * slist; /* Skip list created */ + size_t u; /* Local index variable */ + unsigned data[10] = {10, 20, 15, 5, 50, 30, 31, 32, 80, 90}; + unsigned sorted_data[10] = {5, 10, 15, 20, 30, 31, 32, 50, 80, 90}; + unsigned *found_item; /* Item found in skip list */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n")); @@ -1684,13 +1680,13 @@ test_skiplist_remove_first(void) CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { ret = H5SL_insert(slist, &data[u], &data[u]); CHECK(ret, FAIL, "H5SL_insert"); } /* end for */ /* Remove objects from the skip list */ - for(u = 0; u < 10; u++) { + for (u = 0; u < 10; u++) { found_item = (unsigned *)H5SL_remove_first(slist); VERIFY(*found_item, sorted_data[u], "H5SL_remove_first"); } /* end for */ @@ -1714,11 +1710,11 @@ test_skiplist_remove_first(void) static void test_skiplist_remove_first_many(void) { - H5SL_t *slist; /* Skip list created */ - size_t u; /* Local index variable */ - int *found_item; /* Item found in skip list */ + H5SL_t *slist; /* Skip list created */ + size_t u; /* Local index variable */ + int * found_item; /* Item found in skip list */ int prev_item = INT_MIN; /* Previously found item in skip list */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n")); @@ -1728,13 +1724,13 @@ test_skiplist_remove_first_many(void) CHECK_PTR(slist, "H5SL_create"); /* Insert objects into the skip list */ - for(u = 0; u < NUM_ELEMS; u++) { + for (u = 0; u < NUM_ELEMS; u++) { ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]); CHECK(ret, FAIL, "H5SL_insert"); } /* end for */ /* Remove objects from the skip list */ - for(u = 0; u < NUM_ELEMS; u++) { + for (u = 0; u < NUM_ELEMS; u++) { found_item = (int *)H5SL_remove_first(slist); VERIFY(*found_item > prev_item, TRUE, "H5SL_remove_first"); prev_item = *found_item; @@ -1760,11 +1756,11 @@ static void test_skiplist_term(void) { /* Release arrays */ - if(rand_num) + if (rand_num) HDfree(rand_num); - if(sort_rand_num) + if (sort_rand_num) HDfree(sort_rand_num); - if(rev_sort_rand_num) + if (rev_sort_rand_num) HDfree(rev_sort_rand_num); } /* end test_skiplist_term() */ @@ -1783,33 +1779,32 @@ test_skiplist(void) test_skiplist_init(); /* Actual skip list tests */ - test_skiplist_create(); /* Test skip list creation */ - test_skiplist_insert(); /* Test basic skip list insertion */ - test_skiplist_insert_many(); /* Test insertion of many items into skip list */ - test_skiplist_remove(); /* Test basic skip list removal */ - test_skiplist_remove_many(); /* Test removal of many items from skip list */ - test_skiplist_firstnext(); /* Test iteration over skip list nodes with first/next */ - test_skiplist_string(); /* Test skip list string keys */ - test_skiplist_iterate(); /* Test iteration over skip list nodes with callback */ - test_skiplist_hsize(); /* Test skip list hsize_t keys */ - test_skiplist_unsigned(); /* Test skip list unsigned keys */ - test_skiplist_obj(); /* Test skip list H5_obj_t keys */ - test_skiplist_generic(); /* Test skip list generic keys */ - test_skiplist_lastprev(); /* Test iteration over skip list nodes with last/prev */ - test_skiplist_find(); /* Test 'find' operation */ - test_skiplist_add(); /* Test 'add' operation */ - test_skiplist_destroy(); /* Test 'destroy' operation */ - test_skiplist_free(); /* Test 'free' operation */ - test_skiplist_try_free_safe(); /* Test 'try_free_safe' operation */ - test_skiplist_less(); /* Test 'less' operation */ - test_skiplist_greater(); /* Test 'greater' operation */ - test_skiplist_below(); /* Test 'below' operation */ - test_skiplist_above(); /* Test 'above' operation */ - test_skiplist_remove_first(); /* Test 'remove first' operation */ - test_skiplist_remove_first_many(); /* Test 'remove first' operation on large skip lists */ + test_skiplist_create(); /* Test skip list creation */ + test_skiplist_insert(); /* Test basic skip list insertion */ + test_skiplist_insert_many(); /* Test insertion of many items into skip list */ + test_skiplist_remove(); /* Test basic skip list removal */ + test_skiplist_remove_many(); /* Test removal of many items from skip list */ + test_skiplist_firstnext(); /* Test iteration over skip list nodes with first/next */ + test_skiplist_string(); /* Test skip list string keys */ + test_skiplist_iterate(); /* Test iteration over skip list nodes with callback */ + test_skiplist_hsize(); /* Test skip list hsize_t keys */ + test_skiplist_unsigned(); /* Test skip list unsigned keys */ + test_skiplist_obj(); /* Test skip list H5_obj_t keys */ + test_skiplist_generic(); /* Test skip list generic keys */ + test_skiplist_lastprev(); /* Test iteration over skip list nodes with last/prev */ + test_skiplist_find(); /* Test 'find' operation */ + test_skiplist_add(); /* Test 'add' operation */ + test_skiplist_destroy(); /* Test 'destroy' operation */ + test_skiplist_free(); /* Test 'free' operation */ + test_skiplist_try_free_safe(); /* Test 'try_free_safe' operation */ + test_skiplist_less(); /* Test 'less' operation */ + test_skiplist_greater(); /* Test 'greater' operation */ + test_skiplist_below(); /* Test 'below' operation */ + test_skiplist_above(); /* Test 'above' operation */ + test_skiplist_remove_first(); /* Test 'remove first' operation */ + test_skiplist_remove_first_many(); /* Test 'remove first' operation on large skip lists */ /* Release skip list testing data */ test_skiplist_term(); -} /* end test_skiplist() */ - +} /* end test_skiplist() */ diff --git a/test/tsohm.c b/test/tsohm.c index f39b5e5..71e42e6 100644 --- a/test/tsohm.c +++ b/test/tsohm.c @@ -21,114 +21,90 @@ * This file needs to access private information from the H5F package. * This file also needs to access the file testing code. */ -#define H5F_FRIEND /* suppress error about including H5Fpkg */ +#define H5F_FRIEND /* suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ /* Default SOHM values */ #define DEF_NUM_INDEXES 0 -const unsigned def_type_flags[H5O_SHMESG_MAX_NINDEXES] = {0,0,0,0,0,0}; -const unsigned def_minsizes[H5O_SHMESG_MAX_NINDEXES] = {250,250,250,250,250,250}; +const unsigned def_type_flags[H5O_SHMESG_MAX_NINDEXES] = {0, 0, 0, 0, 0, 0}; +const unsigned def_minsizes[H5O_SHMESG_MAX_NINDEXES] = {250, 250, 250, 250, 250, 250}; #define DEF_L2B 50 #define DEF_B2L 40 /* Non-default SOHM values for testing */ #define TEST_NUM_INDEXES 4 -const unsigned test_type_flags[H5O_SHMESG_MAX_NINDEXES] = - {H5O_SHMESG_FILL_FLAG, - H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_ATTR_FLAG, - H5O_SHMESG_SDSPACE_FLAG, - H5O_SHMESG_PLINE_FLAG, - 0, 0}; -const unsigned test_minsizes[H5O_SHMESG_MAX_NINDEXES] = {0, 2, 40, 100, 3, 1000}; +const unsigned test_type_flags[H5O_SHMESG_MAX_NINDEXES] = {H5O_SHMESG_FILL_FLAG, + H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_ATTR_FLAG, + H5O_SHMESG_SDSPACE_FLAG, + H5O_SHMESG_PLINE_FLAG, + 0, + 0}; +const unsigned test_minsizes[H5O_SHMESG_MAX_NINDEXES] = {0, 2, 40, 100, 3, 1000}; #define TEST_L2B 65 #define TEST_B2L 64 -#define FILENAME "tsohm.h5" -#define FILENAME_SRC "tsohm_src.h5" -#define FILENAME_DST "tsohm_dst.h5" +#define FILENAME "tsohm.h5" +#define FILENAME_SRC "tsohm_src.h5" +#define FILENAME_DST "tsohm_dst.h5" #define NAME_BUF_SIZE 512 /* How much overhead counts as "not much" when converting B-trees, etc. */ #define OVERHEAD_ALLOWED 1.15F -#define NUM_DATASETS 10 +#define NUM_DATASETS 10 #define NUM_ATTRIBUTES 100 typedef struct dtype1_struct { - int i1; - char str[10]; - int i2; - int i3; - int i4; - int i5; - int i6; - int i7; - int i8; - float f1; + int i1; + char str[10]; + int i2; + int i3; + int i4; + int i5; + int i6; + int i7; + int i8; + float f1; } dtype1_struct; #define DTYPE2_SIZE 1024 -const char *DSETNAME[] = { - "dataset0", "dataset1", - "dataset2", "dataset3", - "dataset4", "dataset5", - "dataset6", "dataset7", - "dataset8", "dataset9", - "dataset10", "dataset11", - NULL -}; -const char *EXTRA_DSETNAME[] = { - "ex_dataset0", "ex_dataset1", - "ex_dataset2", "ex_dataset3", - "ex_dataset4", "ex_dataset5", - "ex_dataset6", "ex_dataset7", - "ex_dataset8", "ex_dataset9", - "ex_dataset10", "ex_dataset11", - "ex_dataset12", "ex_dataset13", - "ex_dataset14", "ex_dataset15", - "ex_dataset16", "ex_dataset17", - "ex_dataset18", "ex_dataset19", - NULL -}; +const char *DSETNAME[] = {"dataset0", "dataset1", "dataset2", "dataset3", "dataset4", + "dataset5", "dataset6", "dataset7", "dataset8", "dataset9", + "dataset10", "dataset11", NULL}; +const char *EXTRA_DSETNAME[] = {"ex_dataset0", "ex_dataset1", "ex_dataset2", + "ex_dataset3", "ex_dataset4", "ex_dataset5", + "ex_dataset6", "ex_dataset7", "ex_dataset8", + "ex_dataset9", "ex_dataset10", "ex_dataset11", + "ex_dataset12", "ex_dataset13", "ex_dataset14", + "ex_dataset15", "ex_dataset16", "ex_dataset17", + "ex_dataset18", "ex_dataset19", NULL}; #define SOHM_HELPER_NUM_EX_DSETS 20 typedef struct complex_t { - double re; - double im; + double re; + double im; } complex_t; #define ENUM_NUM_MEMBS 20 -const char *ENUM_NAME[] = { - "enum_member0", "enum_member1", - "enum_member2", "enum_member3", - "enum_member4", "enum_member5", - "enum_member6", "enum_member7", - "enum_member8", "enum_member9", - "enum_member10", "enum_member11", - "enum_member12", "enum_member13", - "enum_member14", "enum_member15", - "enum_member16", "enum_member17", - "enum_member18", "enum_member19", - NULL -}; -const int ENUM_VAL[] = { - 0, 13, - -500, 63, - 64, -64, - 65, 2048, - 1, 2, - -1, 7, - 130, -5000, - 630, 640, - -640, 650, - 20480, 10, - -1001, -10 -}; +const char *ENUM_NAME[] = {"enum_member0", "enum_member1", "enum_member2", + "enum_member3", "enum_member4", "enum_member5", + "enum_member6", "enum_member7", "enum_member8", + "enum_member9", "enum_member10", "enum_member11", + "enum_member12", "enum_member13", "enum_member14", + "enum_member15", "enum_member16", "enum_member17", + "enum_member18", "enum_member19", NULL}; +const int ENUM_VAL[] = {0, 13, -500, 63, 64, -64, 65, 2048, 1, 2, -1, + 7, 130, -5000, 630, 640, -640, 650, 20480, 10, -1001, -10}; #define SIZE2_RANK1 6 #define SIZE2_RANK2 10 -#define SIZE2_DIMS {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} +#define SIZE2_DIMS \ + { \ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 \ + } -#define LONG_STRING "00 index. A long string used for testing. To create new strings, set the first two characters to be some ASCII number other than 00, such as 01." +#define LONG_STRING \ + "00 index. A long string used for testing. To create new strings, set the first two characters to be " \ + "some ASCII number other than 00, such as 01." /* Struct returned from size2_helper function */ typedef struct size2_helper_struct { @@ -143,25 +119,27 @@ typedef struct size2_helper_struct { } size2_helper_struct; /* Number of distinct messages for the sohm_delete test */ -#define DELETE_NUM_MESGS 7 +#define DELETE_NUM_MESGS 7 #define HALF_DELETE_NUM_MESGS 3 -#define DELETE_DIMS {1,1,1,1,1,1,1} +#define DELETE_DIMS \ + { \ + 1, 1, 1, 1, 1, 1, 1 \ + } #define DELETE_MIN_MESG_SIZE 10 #define DELETE_MAX_MESG_SIZE 60 - /* Number of dimensions in extend_dset test */ #define EXTEND_NDIMS 2 /* Dimensions for external_dtype test */ -#define NX 10 -#define NY 10 +#define NX 10 +#define NY 10 /* Helper function prototypes */ static hid_t make_dtype_1(void); static hid_t make_dtype_2(void); -static hid_t close_reopen_file(hid_t file, const char* filename, hid_t fapl_id); -static void test_sohm_attrs(void); +static hid_t close_reopen_file(hid_t file, const char *filename, hid_t fapl_id); +static void test_sohm_attrs(void); #ifdef NOT_NOW static void size2_dump_struct(const char *name, size2_helper_struct *sizes); #endif /* NOT_NOW */ @@ -170,21 +148,20 @@ static void test_sohm_delete(void); static void test_sohm_delete_revert(void); static void test_sohm_extlink(void); - - /**************************************************************** ** ** verify_fcpl_values(): Verifies that FCPL is set as expected. ** ****************************************************************/ static void -verify_fcpl_values(hid_t fcpl_id, const unsigned nindexes_expected, const unsigned *flags_expected, const unsigned *minsizes_expected, unsigned l2b, unsigned b2l) +verify_fcpl_values(hid_t fcpl_id, const unsigned nindexes_expected, const unsigned *flags_expected, + const unsigned *minsizes_expected, unsigned l2b, unsigned b2l) { - unsigned nindexes_actual; - unsigned list_size; - unsigned btree_size; - unsigned x; - herr_t ret; + unsigned nindexes_actual; + unsigned list_size; + unsigned btree_size; + unsigned x; + herr_t ret; /* Number of indexes */ ret = H5Pget_shared_mesg_nindexes(fcpl_id, &nindexes_actual); @@ -192,7 +169,7 @@ verify_fcpl_values(hid_t fcpl_id, const unsigned nindexes_expected, const unsign VERIFY(nindexes_actual, nindexes_expected, "H5Pget_shared_mesg_nindexes"); /* Index flags and minsizes */ - for(x=0; x H5Dread((dset_id), (dtype_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata)) { \ - H5_FAILED(); AT(); \ - HDprintf("Can't read data\n"); \ - goto error; \ - } \ - if ((rdata.i1 != wdata.i1) || (rdata.i2 != wdata.i2) || HDstrcmp(rdata.str, wdata.str)) { \ - H5_FAILED(); AT(); \ - HDprintf("incorrect read data\n"); \ - goto error; \ - } \ -} /* TSOHM_S1H_VERIFY_DATA() definition */ +#define TSOHM_S1H_VERIFY_DATA(dset_id, dtype_id) \ + { \ + HDmemset(&rdata, 0, sizeof(rdata)); \ + if (0 > H5Dread((dset_id), (dtype_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata)) { \ + H5_FAILED(); \ + AT(); \ + HDprintf("Can't read data\n"); \ + goto error; \ + } \ + if ((rdata.i1 != wdata.i1) || (rdata.i2 != wdata.i2) || HDstrcmp(rdata.str, wdata.str)) { \ + H5_FAILED(); \ + AT(); \ + HDprintf("incorrect read data\n"); \ + goto error; \ + } \ + } /* TSOHM_S1H_VERIFY_DATA() definition */ /* Closing and re-opening the file takes a long time on systems without * local disks. Don't close and reopen if express testing is enabled. */ - if(GetTestExpress() > 1) - test_file_closing = FALSE; + if (GetTestExpress() > 1) + test_file_closing = FALSE; /* Intialize wdata */ HDmemset(&wdata, 0, sizeof(wdata)); @@ -650,86 +653,111 @@ size1_helper(hid_t file, const char *filename, hid_t fapl_id, hbool_t test_file_ HDmemset(&rdata, 0, sizeof(rdata)); dtype1_id = make_dtype_1(); - if(dtype1_id < 0) TEST_ERROR + if (dtype1_id < 0) + TEST_ERROR - dim1[0] = 1; + dim1[0] = 1; space_id = H5Screate_simple(1, dim1, NULL); - if(space_id < 0) TEST_ERROR + if (space_id < 0) + TEST_ERROR dset_id = H5Dcreate2(file, DSETNAME[0], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset_id < 0) FAIL_STACK_ERROR + if (dset_id < 0) + FAIL_STACK_ERROR /* Test writing and reading */ - if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) + FAIL_STACK_ERROR TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id) - if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset_id) < 0) + FAIL_STACK_ERROR - if(test_file_closing) - if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR + if (test_file_closing) + if ((file = close_reopen_file(file, filename, fapl_id)) < 0) + TEST_ERROR /* Create 3 more datasets with the same datatype/dataspace */ for (x = 1; x < 4; x++) { dset_id = H5Dcreate2(file, DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (0 > dset_id) FAIL_STACK_ERROR + if (0 > dset_id) + FAIL_STACK_ERROR if (x == 3) - if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) TEST_ERROR - if (H5Dclose(dset_id) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) + TEST_ERROR + if (H5Dclose(dset_id) < 0) + FAIL_STACK_ERROR if (test_file_closing) - if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR + if ((file = close_reopen_file(file, filename, fapl_id)) < 0) + TEST_ERROR } - if(H5Tclose(dtype1_id) < 0) TEST_ERROR + if (H5Tclose(dtype1_id) < 0) + TEST_ERROR /* Make sure the data has been written successfully */ dset_id = H5Dopen2(file, DSETNAME[0], H5P_DEFAULT); - if(dset_id < 0) TEST_ERROR + if (dset_id < 0) + TEST_ERROR dtype1_id = H5Dget_type(dset_id); - if(dtype1_id < 0) TEST_ERROR + if (dtype1_id < 0) + TEST_ERROR TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id) - if(H5Dclose(dset_id) < 0) TEST_ERROR + if (H5Dclose(dset_id) < 0) + TEST_ERROR /* Create several copies of the dataset * this increases the amount of space saved by sharing the datatype message */ - for(x = 0; x < SOHM_HELPER_NUM_EX_DSETS; x++) { - dset_id = H5Dcreate2(file, EXTRA_DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset_id < 0) TEST_ERROR - if(H5Dclose(dset_id) < 0) TEST_ERROR + for (x = 0; x < SOHM_HELPER_NUM_EX_DSETS; x++) { + dset_id = + H5Dcreate2(file, EXTRA_DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset_id < 0) + TEST_ERROR + if (H5Dclose(dset_id) < 0) + TEST_ERROR - if(test_file_closing) - if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR + if (test_file_closing) + if ((file = close_reopen_file(file, filename, fapl_id)) < 0) + TEST_ERROR } - if(H5Tclose(dtype1_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR + if (H5Tclose(dtype1_id) < 0) + TEST_ERROR + if (H5Sclose(space_id) < 0) + TEST_ERROR /* Ensure that we can still read data back from dataset 3 */ dset_id = H5Dopen2(file, DSETNAME[3], H5P_DEFAULT); - if(dset_id < 0) TEST_ERROR + if (dset_id < 0) + TEST_ERROR dtype1_id = H5Dget_type(dset_id); - if(dtype1_id < 0) TEST_ERROR + if (dtype1_id < 0) + TEST_ERROR TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id) - if(H5Dclose(dset_id) < 0) TEST_ERROR - if(H5Tclose(dtype1_id) < 0) TEST_ERROR + if (H5Dclose(dset_id) < 0) + TEST_ERROR + if (H5Tclose(dtype1_id) < 0) + TEST_ERROR return file; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Sclose(space_id); H5Tclose(dtype1_id); H5Dclose(dset_id); H5Fclose(file); - } H5E_END_TRY + } + H5E_END_TRY return H5I_INVALID_HID; #undef TSOHM_S1H_VERIFY_DATA /* macro is exclusive to this function */ } /* size1_helper */ - /*---------------------------------------------------------------------------- * Function: getsize_testsize1 * @@ -742,10 +770,10 @@ size1_helper(hid_t file, const char *filename, hid_t fapl_id, hbool_t test_file_ *---------------------------------------------------------------------------- */ static h5_stat_size_t -getsize_testsize1(const char *filename, hid_t fcpl_id, hid_t fapl_id, - hbool_t test_file_closing, H5O_native_info_t *ninfo) +getsize_testsize1(const char *filename, hid_t fcpl_id, hid_t fapl_id, hbool_t test_file_closing, + H5O_native_info_t *ninfo) { - hid_t fid = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; herr_t ret; fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); @@ -767,7 +795,6 @@ getsize_testsize1(const char *filename, hid_t fcpl_id, hid_t fapl_id, return h5_get_file_size(filename, fapl_id); } /* getsize_testsize1() */ - /*------------------------------------------------------------------------- * Function: test_sohm_size1 * @@ -781,18 +808,18 @@ getsize_testsize1(const char *filename, hid_t fcpl_id, hid_t fapl_id, static void test_sohm_size1(void) { - hid_t file = -1; - hid_t fcpl_id = -1; - hid_t fapl_id = -1; + hid_t file = -1; + hid_t fcpl_id = -1; + hid_t fapl_id = -1; unsigned use_shared = 0; - unsigned use_btree = 0; + unsigned use_btree = 0; h5_stat_size_t file_sizes[9]; unsigned size_index = 0; hsize_t oh_sizes[3]; unsigned oh_size_index = 0; -#if 0 /* TBD: lying comment or bug. See Jira HDFFV-10646 */ +#if 0 /* TBD: lying comment or bug. See Jira HDFFV-10646 */ hsize_t norm_oh_size; #endif /* Jira HDFFV-10646 */ hsize_t sohm_oh_size; @@ -807,13 +834,13 @@ test_sohm_size1(void) h5_stat_size_t sohm_final_filesize2; h5_stat_size_t sohm_btree_final_filesize2; - H5O_native_info_t ninfo; - unsigned num_indexes = 1; - unsigned index_flags = H5O_SHMESG_DTYPE_FLAG; - unsigned min_mesg_size = 50; - unsigned list_max = 11; - unsigned btree_min = 10; - herr_t ret; + H5O_native_info_t ninfo; + unsigned num_indexes = 1; + unsigned index_flags = H5O_SHMESG_DTYPE_FLAG; + unsigned min_mesg_size = 50; + unsigned list_max = 11; + unsigned btree_min = 10; + herr_t ret; MESSAGE(5, ("Testing that shared datatypes save space\n")); @@ -847,11 +874,13 @@ test_sohm_size1(void) if (use_btree) { ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); - } else { + } + else { ret = H5Pset_shared_mesg_phase_change(fcpl_id, list_max, btree_min); } CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - } else { + } + else { ret = H5Pset_shared_mesg_nindexes(fcpl_id, 0); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); } @@ -865,16 +894,16 @@ test_sohm_size1(void) file_sizes[size_index++] = h5_get_file_size(FILENAME, fapl_id); /* size of populated file, with different populating behaviors */ - test_open_close = TRUE; + test_open_close = TRUE; file_sizes[size_index++] = getsize_testsize1(FILENAME, fcpl_id, fapl_id, test_open_close, &ninfo); - test_open_close = FALSE; + test_open_close = FALSE; file_sizes[size_index++] = getsize_testsize1(FILENAME, fcpl_id, fapl_id, test_open_close, &ninfo); oh_sizes[oh_size_index++] = ninfo.hdr.space.total; ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); } /* for btree/listed messages */ - } /* for normal/shared messages */ + } /* for normal/shared messages */ ret = H5Pclose(fapl_id); CHECK_I(ret, "H5Pclose"); @@ -890,29 +919,29 @@ test_sohm_size1(void) /* Put result sizes into human-readable symbolic names. * Order dependent on loop execution above. */ - norm_empty_filesize = file_sizes[0]; - norm_final_filesize = file_sizes[1]; + norm_empty_filesize = file_sizes[0]; + norm_final_filesize = file_sizes[1]; norm_final_filesize2 = file_sizes[2]; -#if 0 /* TBD: lying comment or bug. See Jira HDFFV-10646 */ +#if 0 /* TBD: lying comment or bug. See Jira HDFFV-10646 */ norm_oh_size = oh_sizes[0]; #endif /* Jira HDFFV-10646 */ - sohm_empty_filesize = file_sizes[3]; - sohm_final_filesize = file_sizes[4]; + sohm_empty_filesize = file_sizes[3]; + sohm_final_filesize = file_sizes[4]; sohm_final_filesize2 = file_sizes[5]; - sohm_oh_size = oh_sizes[1]; + sohm_oh_size = oh_sizes[1]; - sohm_btree_empty_filesize = file_sizes[6]; - sohm_btree_final_filesize = file_sizes[7]; + sohm_btree_empty_filesize = file_sizes[6]; + sohm_btree_final_filesize = file_sizes[7]; sohm_btree_final_filesize2 = file_sizes[8]; - sohm_btree_oh_size = oh_sizes[2]; + sohm_btree_oh_size = oh_sizes[2]; /* How the SOHM messages are stored shouldn't affect the * size of the object header. */ VERIFY(sohm_btree_oh_size, sohm_oh_size, "H5Oget_info_by_name"); -#if 0 /* TBD: lying comment or bug. See Jira HDFFV-10646 */ +#if 0 /* TBD: lying comment or bug. See Jira HDFFV-10646 */ /* Object headers in SOHM files should be smaller than normal object * headers. */ @@ -926,31 +955,30 @@ test_sohm_size1(void) * The sizes here shouldn't really be 1; it's just used to ensure that the * error code triggers. */ - if(sohm_empty_filesize <= norm_empty_filesize) + if (sohm_empty_filesize <= norm_empty_filesize) VERIFY(sohm_empty_filesize, 1, "h5_get_file_size"); - if(sohm_btree_empty_filesize <= norm_empty_filesize) + if (sohm_btree_empty_filesize <= norm_empty_filesize) VERIFY(sohm_btree_empty_filesize, 1, "h5_get_file_size"); /* When full, the sohm btree file should be smaller than the normal file. * The sohm list file should be at least as small, since it doesn't need * the overhead of a B-tree. */ - if(sohm_btree_final_filesize >= norm_final_filesize) + if (sohm_btree_final_filesize >= norm_final_filesize) VERIFY(sohm_btree_final_filesize, 1, "h5_get_file_size"); - if(sohm_final_filesize > sohm_btree_final_filesize) + if (sohm_final_filesize > sohm_btree_final_filesize) VERIFY(sohm_final_filesize, 1, "h5_get_file_size"); /* Comparative sizes shouldn't change even if we open and close the file */ - if(sohm_btree_final_filesize2 >= norm_final_filesize2) + if (sohm_btree_final_filesize2 >= norm_final_filesize2) VERIFY(sohm_btree_final_filesize2, 1, "h5_get_file_size"); - if(sohm_final_filesize2 > sohm_btree_final_filesize2) + if (sohm_final_filesize2 > sohm_btree_final_filesize2) VERIFY(sohm_final_filesize2, 1, "h5_get_file_size"); } /* test_sohm_size1 */ - /*--------------------------------------------------------------------------- * Function: test_sohm_size_consistency_open_create * @@ -964,7 +992,7 @@ test_sohm_size1(void) * *--------------------------------------------------------------------------- */ -#if 0 /* TODO: REVEALS BUG TO BE FIXED - SEE JIRA HDFFV-10645 */ +#if 0 /* TODO: REVEALS BUG TO BE FIXED - SEE JIRA HDFFV-10645 */ static void test_sohm_size_consistency_open_create(void) { @@ -1057,7 +1085,6 @@ test_sohm_size_consistency_open_create(void) } /* test_sohm_size_consistency_open_create */ #endif /* Jira HDFFV-10645 */ - /*------------------------------------------------------------------------- * Function: sohm_attr_helper * @@ -1076,14 +1103,14 @@ test_sohm_size_consistency_open_create(void) static void sohm_attr_helper(hid_t fcpl_id) { - hid_t file_id; - hid_t space_id; - hsize_t dims = 2; - int wdata[2] = {7, 42}; - int rdata[2]; - herr_t ret; - size_t x; - unsigned op_index=0; + hid_t file_id; + hid_t space_id; + hsize_t dims = 2; + int wdata[2] = {7, 42}; + int rdata[2]; + herr_t ret; + size_t x; + unsigned op_index = 0; #define TSOHM_SAH_OP_COUNT 3 const char *groupnames[TSOHM_SAH_OP_COUNT] = { "group_for_nothing_special", @@ -1150,12 +1177,12 @@ sohm_attr_helper(hid_t fcpl_id) HDmemset(rdata, 0, sizeof(rdata)); ret = H5Aread(attr_read_id, H5T_NATIVE_INT, rdata); CHECK_I(ret, "H5Aread"); - for(x = 0; x < (size_t)dims; ++x) + for (x = 0; x < (size_t)dims; ++x) VERIFY(rdata[x], wdata[x], "H5Aread"); ret = H5Aclose(attr_id); CHECK_I(ret, "H5Aclose"); - if (attr_id2 > -1 ) { + if (attr_id2 > -1) { ret = H5Aclose(attr_id2); CHECK_I(ret, "H5Aclose"); } @@ -1168,7 +1195,6 @@ sohm_attr_helper(hid_t fcpl_id) #undef TSOHM_SAH_OP_COUNT } /* sohm_attr_helper */ - /*------------------------------------------------------------------------- * Function: test_sohm_attrs * @@ -1186,9 +1212,9 @@ sohm_attr_helper(hid_t fcpl_id) static void test_sohm_attrs(void) { - hid_t bad_fid = H5I_INVALID_HID; - hid_t fcpl_id = H5I_INVALID_HID; - unsigned i = 0; + hid_t bad_fid = H5I_INVALID_HID; + hid_t fcpl_id = H5I_INVALID_HID; + unsigned i = 0; #define TSOHM_TSA_NFLAGS_1 7 unsigned flags1[TSOHM_TSA_NFLAGS_1] = { H5O_SHMESG_ATTR_FLAG, @@ -1201,44 +1227,55 @@ test_sohm_attrs(void) }; #define TSOHM_TSA_NFLAGS_2 6 unsigned flags2[TSOHM_TSA_NFLAGS_2][2] = { - { H5O_SHMESG_ATTR_FLAG, + { + H5O_SHMESG_ATTR_FLAG, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, }, - { H5O_SHMESG_SDSPACE_FLAG, + { + H5O_SHMESG_SDSPACE_FLAG, H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, }, - { H5O_SHMESG_DTYPE_FLAG, + { + H5O_SHMESG_DTYPE_FLAG, H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG, }, - { H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, + { + H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, H5O_SHMESG_ATTR_FLAG, }, - { H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, + { + H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, H5O_SHMESG_SDSPACE_FLAG, }, - { H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG, + { + H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG, H5O_SHMESG_DTYPE_FLAG, }, }; #define TSOHM_TSA_NFLAGS_3 5 unsigned flags3[TSOHM_TSA_NFLAGS_3][3] = { - { H5O_SHMESG_ATTR_FLAG, + { + H5O_SHMESG_ATTR_FLAG, H5O_SHMESG_SDSPACE_FLAG, H5O_SHMESG_DTYPE_FLAG, }, - { H5O_SHMESG_DTYPE_FLAG, + { + H5O_SHMESG_DTYPE_FLAG, H5O_SHMESG_ATTR_FLAG, H5O_SHMESG_SDSPACE_FLAG, }, - { H5O_SHMESG_SDSPACE_FLAG, + { + H5O_SHMESG_SDSPACE_FLAG, H5O_SHMESG_DTYPE_FLAG, H5O_SHMESG_ATTR_FLAG, }, - { 0, /* first index does not hold a shared message type? */ + { + 0, /* first index does not hold a shared message type? */ H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, H5O_SHMESG_ATTR_FLAG, }, - { 0, /* missing SDSPACE flag */ + { + 0, /* missing SDSPACE flag */ H5O_SHMESG_DTYPE_FLAG, H5O_SHMESG_ATTR_FLAG, }, @@ -1261,7 +1298,7 @@ test_sohm_attrs(void) /* One shared message index */ - for (i=0; i < TSOHM_TSA_NFLAGS_1; i++) { + for (i = 0; i < TSOHM_TSA_NFLAGS_1; i++) { fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); @@ -1277,7 +1314,7 @@ test_sohm_attrs(void) /* two shared message indices */ - for (i=0; i < TSOHM_TSA_NFLAGS_2; i++) { + for (i = 0; i < TSOHM_TSA_NFLAGS_2; i++) { fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2); @@ -1295,7 +1332,8 @@ test_sohm_attrs(void) /* duplicate flags in separate indices causes problems */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2); @@ -1310,11 +1348,12 @@ test_sohm_attrs(void) ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); - } H5E_END_TRY; + } + H5E_END_TRY; /* three shared message indices */ - for (i=0; i < TSOHM_TSA_NFLAGS_3; i++) { + for (i = 0; i < TSOHM_TSA_NFLAGS_3; i++) { fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); ret = H5Pset_shared_mesg_nindexes(fcpl_id, 3); @@ -1338,7 +1377,6 @@ test_sohm_attrs(void) } /* test_sohm_attrs */ - /*------------------------------------------------------------------------- * Function: size2_verify_plist1 * @@ -1354,41 +1392,40 @@ test_sohm_attrs(void) static void size2_verify_plist1(hid_t plist) { - size_t cd_nelmts; - unsigned int cd_value; - char name[NAME_BUF_SIZE]; - H5Z_filter_t filter; - hid_t dtype1_id; + size_t cd_nelmts; + unsigned int cd_value; + char name[NAME_BUF_SIZE]; + H5Z_filter_t filter; + hid_t dtype1_id; dtype1_struct fill1; dtype1_struct fill1_correct; - herr_t ret; + herr_t ret; /* Hardcoded to correspond to dcpl1_id created in size2_helper */ /* Check filters */ cd_nelmts = 1; - filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_SHUFFLE, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 1, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_SHUFFLE, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_FLETCHER32, "H5Pget_filter2"); - /* Check fill value */ - dtype1_id=make_dtype_1(); + dtype1_id = make_dtype_1(); CHECK_I(dtype1_id, "make_dtype_1"); HDmemset(&fill1_correct, '1', sizeof(fill1_correct)); @@ -1402,7 +1439,6 @@ size2_verify_plist1(hid_t plist) CHECK_I(ret, "H5Tclose"); } /* size2_verify_plist1 */ - /*------------------------------------------------------------------------- * Function: size2_verify_plist2 * @@ -1418,48 +1454,47 @@ size2_verify_plist1(hid_t plist) static void size2_verify_plist2(hid_t plist) { - size_t cd_nelmts; + size_t cd_nelmts; unsigned int cd_value; - char name[NAME_BUF_SIZE]; + char name[NAME_BUF_SIZE]; H5Z_filter_t filter; - hid_t dtype2_id; - char fill2[DTYPE2_SIZE]; - char fill2_correct[DTYPE2_SIZE]; - herr_t ret; + hid_t dtype2_id; + char fill2[DTYPE2_SIZE]; + char fill2_correct[DTYPE2_SIZE]; + herr_t ret; /* Hardcoded to correspond to dcpl1_id created in size2_helper */ /* Check filters */ cd_nelmts = 1; - filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 1, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 2, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 2, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 1, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 4, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 4, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 5, "H5Pget_filter2"); - /* Check fill value */ dtype2_id = make_dtype_2(); CHECK_I(dtype2_id, "make_dtype_2"); @@ -1476,7 +1511,7 @@ size2_verify_plist2(hid_t plist) } /* size2_verify_plist2 */ #ifdef NOT_NOW - + /*------------------------------------------------------------------------- * Function: size2_dump_struct * @@ -1494,19 +1529,25 @@ size2_verify_plist2(hid_t plist) static void size2_dump_struct(const char *name, size2_helper_struct *sizes) { - HDputs(name); - HDprintf(" empty size: %llu\n", (unsigned long long)sizes->empty_size); - HDprintf(" first dataset: %llu \tdelta: %llu\n", (unsigned long long)sizes->first_dset, (unsigned long long)(sizes->first_dset - sizes->empty_size)); - HDprintf("second dataset: %llu \tdelta: %llu\n", (unsigned long long)sizes->second_dset, (unsigned long long)(sizes->second_dset - sizes->first_dset)); - HDprintf(" dsets 1: %llu \tdelta: %llu\n", (unsigned long long)sizes->dsets1, (unsigned long long)(sizes->dsets1 - sizes->second_dset)); - HDprintf(" dsets 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->dsets2, (unsigned long long)(sizes->dsets2 - sizes->dsets1)); - HDprintf(" interleaved: %llu \tdelta: %llu\n", (unsigned long long)sizes->interleaved, (unsigned long long)(sizes->interleaved - sizes->dsets2)); - HDprintf(" attributes: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs1, (unsigned long long)(sizes->attrs1 - sizes->interleaved)); - HDprintf(" attributes 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs2, (unsigned long long)(sizes->attrs2 - sizes->attrs1)); + HDputs(name); + HDprintf(" empty size: %llu\n", (unsigned long long)sizes->empty_size); + HDprintf(" first dataset: %llu \tdelta: %llu\n", (unsigned long long)sizes->first_dset, + (unsigned long long)(sizes->first_dset - sizes->empty_size)); + HDprintf("second dataset: %llu \tdelta: %llu\n", (unsigned long long)sizes->second_dset, + (unsigned long long)(sizes->second_dset - sizes->first_dset)); + HDprintf(" dsets 1: %llu \tdelta: %llu\n", (unsigned long long)sizes->dsets1, + (unsigned long long)(sizes->dsets1 - sizes->second_dset)); + HDprintf(" dsets 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->dsets2, + (unsigned long long)(sizes->dsets2 - sizes->dsets1)); + HDprintf(" interleaved: %llu \tdelta: %llu\n", (unsigned long long)sizes->interleaved, + (unsigned long long)(sizes->interleaved - sizes->dsets2)); + HDprintf(" attributes: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs1, + (unsigned long long)(sizes->attrs1 - sizes->interleaved)); + HDprintf(" attributes 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs2, + (unsigned long long)(sizes->attrs2 - sizes->attrs1)); } /* size2_dump_struct */ #endif /* NOT_NOW */ - /*------------------------------------------------------------------------- * Function: size2_helper * @@ -1532,35 +1573,35 @@ size2_dump_struct(const char *name, size2_helper_struct *sizes) static int size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_sizes) { - hid_t file_id = -1; - hid_t dtype1_id = -1; - hid_t dtype2_id = -1; - hid_t dspace1_id = -1; - hid_t dspace2_id = -1; - hid_t dcpl1_id = -1; - hid_t dcpl2_id = -1; - hid_t dset_id = -1; - hid_t attr_type_id = -1; - hid_t attr_space_id = -1; - hid_t attr_id = -1; - hid_t group_id = -1; - char attr_string1[NAME_BUF_SIZE]; - char attr_string2[NAME_BUF_SIZE]; - char attr_name[NAME_BUF_SIZE]; - int x; + hid_t file_id = -1; + hid_t dtype1_id = -1; + hid_t dtype2_id = -1; + hid_t dspace1_id = -1; + hid_t dspace2_id = -1; + hid_t dcpl1_id = -1; + hid_t dcpl2_id = -1; + hid_t dset_id = -1; + hid_t attr_type_id = -1; + hid_t attr_space_id = -1; + hid_t attr_id = -1; + hid_t group_id = -1; + char attr_string1[NAME_BUF_SIZE]; + char attr_string2[NAME_BUF_SIZE]; + char attr_name[NAME_BUF_SIZE]; + int x; herr_t ret; /* Constants used in this function */ - const int rank1 = SIZE2_RANK1; - const int rank2 = SIZE2_RANK2; + const int rank1 = SIZE2_RANK1; + const int rank2 = SIZE2_RANK2; const hsize_t dims[SIZE2_RANK2] = SIZE2_DIMS; dtype1_struct fill1; - char fill2[DTYPE2_SIZE]; + char fill2[DTYPE2_SIZE]; /* Closing and re-opening the file takes a long time on systems without * local disks. Don't close and reopen if express testing is enabled. */ - if(GetTestExpress() > 1) + if (GetTestExpress() > 1) test_file_closing = 0; /* Create a file and get its size */ @@ -1640,7 +1681,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size HDmemset(attr_string2, 0, (size_t)NAME_BUF_SIZE); HDstrcpy(attr_string1, LONG_STRING); HDstrcpy(attr_string2, LONG_STRING); - attr_string2[1] = '1'; /* The second string starts "01 index..." */ + attr_string2[1] = '1'; /* The second string starts "01 index..." */ /* Set up attribute metadata */ attr_type_id = H5Tcopy(H5T_C_S1); @@ -1653,7 +1694,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size /* Create datasets with a big datatype, dataspace, fill value, * and filter pipeline. */ - for(x = 0; x < NUM_DATASETS; ++x) { + for (x = 0; x < NUM_DATASETS; ++x) { dset_id = H5Dcreate2(file_id, DSETNAME[x], dtype1_id, dspace1_id, H5P_DEFAULT, dcpl1_id, H5P_DEFAULT); CHECK_I(dset_id, "H5Dcreate2"); @@ -1668,12 +1709,12 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size CHECK_I(ret, "H5Dclose"); /* Gather extra statistics on first two datasets in file */ - if(x < 2) { + if (x < 2) { ret = H5Fclose(file_id); CHECK_I(ret, "H5Fclose"); /* Get the file's size now */ - if(x == 0) + if (x == 0) ret_sizes->first_dset = h5_get_file_size(FILENAME, H5P_DEFAULT); else ret_sizes->second_dset = h5_get_file_size(FILENAME, H5P_DEFAULT); @@ -1682,18 +1723,17 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size CHECK_I(file_id, "H5Fopen"); } /* end if */ /* Close & reopen file if requested */ - else if(test_file_closing) { + else if (test_file_closing) { file_id = close_reopen_file(file_id, FILENAME, H5P_DEFAULT); CHECK_I(file_id, "H5Fopen"); } /* end if */ - } /* end for */ + } /* end for */ /* Close file and get its size now */ ret = H5Fclose(file_id); CHECK_I(ret, "H5Fclose"); ret_sizes->dsets1 = h5_get_file_size(FILENAME, H5P_DEFAULT); - /* Create new group filled with datasets that use all different messages */ file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK_I(file_id, "H5Fopen"); @@ -1701,8 +1741,9 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size CHECK_I(group_id, "H5Gcreate2"); /* Create NUM_DATASETS datasets in the new group */ - for(x=0; xdsets2 = h5_get_file_size(FILENAME, H5P_DEFAULT); - /* Create a new group and interleave writes of datasets types 1 and 2. */ file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK_I(file_id, "H5Fopen"); @@ -1741,9 +1781,9 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size CHECK_I(group_id, "H5Gcreate2"); /* Create NUM_DATASETS datasets in the new group */ - for(x=0; xattrs1 = h5_get_file_size(FILENAME, H5P_DEFAULT); - /* Create all of the attributes again on the other group */ file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK_I(file_id, "H5Fopen"); group_id = H5Gopen2(file_id, "interleaved group", H5P_DEFAULT); CHECK_I(group_id, "H5Gopen2"); - for(x=0; xattrs2 = h5_get_file_size(FILENAME, H5P_DEFAULT); - /* Close everything */ ret = H5Sclose(attr_space_id); CHECK_I(ret, "H5Sclose"); @@ -1890,7 +1928,6 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size return 0; } /* size2_helper */ - /*------------------------------------------------------------------------- * Function: size2_verify * @@ -1908,30 +1945,29 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size static void size2_verify(void) { - hid_t file_id = -1; - hid_t dset_id=-1; - hid_t plist_id=-1; - hid_t space_id=-1; - hid_t group1_id, group2_id; - hid_t attr1_id, attr2_id; - hid_t attr_type_id; - int x, y; - herr_t ret; - char attr_string[NAME_BUF_SIZE]; - char attr_correct_string[NAME_BUF_SIZE]; - char attr_name[NAME_BUF_SIZE]; - int ndims; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t plist_id = -1; + hid_t space_id = -1; + hid_t group1_id, group2_id; + hid_t attr1_id, attr2_id; + hid_t attr_type_id; + int x, y; + herr_t ret; + char attr_string[NAME_BUF_SIZE]; + char attr_correct_string[NAME_BUF_SIZE]; + char attr_name[NAME_BUF_SIZE]; + int ndims; hsize_t dims[SIZE2_RANK2]; hsize_t correct_dims[SIZE2_RANK2] = SIZE2_DIMS; file_id = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK_I(file_id, "H5Fopen"); - /* Verify property lists and dataspaces */ /* Get property lists from first batch of datasets */ - for(x = 0; x < NUM_DATASETS; ++x) { + for (x = 0; x < NUM_DATASETS; ++x) { dset_id = H5Dopen2(file_id, DSETNAME[x], H5P_DEFAULT); CHECK_I(dset_id, "H5Dopen2"); plist_id = H5Dget_create_plist(dset_id); @@ -1945,7 +1981,7 @@ size2_verify(void) ndims = H5Sget_simple_extent_dims(space_id, dims, NULL); CHECK_I(ndims, "H5Sget_simple_extent_dims"); VERIFY(ndims, SIZE2_RANK1, "H5Sget_simple_extent_dims"); - for(y = 0; y < ndims; ++y) + for (y = 0; y < ndims; ++y) VERIFY(dims[y], correct_dims[y], "H5Sget_simple_extent_dims"); ret = H5Sclose(space_id); @@ -1958,7 +1994,7 @@ size2_verify(void) /* Get property lists from second batch of datasets */ group1_id = H5Gopen2(file_id, "group", H5P_DEFAULT); CHECK_I(group1_id, "H5Gopen2"); - for(x = 0; x < NUM_DATASETS; ++x) { + for (x = 0; x < NUM_DATASETS; ++x) { dset_id = H5Dopen2(group1_id, DSETNAME[x], H5P_DEFAULT); CHECK_I(dset_id, "H5Dopen2"); plist_id = H5Dget_create_plist(dset_id); @@ -1972,7 +2008,7 @@ size2_verify(void) ndims = H5Sget_simple_extent_dims(space_id, dims, NULL); CHECK_I(ndims, "H5Sget_simple_extent_dims"); VERIFY(ndims, SIZE2_RANK2, "H5Sget_simple_extent_dims"); - for(y = 0; y < ndims; ++y) + for (y = 0; y < ndims; ++y) VERIFY(dims[y], correct_dims[y], "H5Sget_simple_extent_dims"); ret = H5Sclose(space_id); @@ -1987,7 +2023,7 @@ size2_verify(void) /* Get property lists from interleaved group of datasets */ group1_id = H5Gopen2(file_id, "interleaved group", H5P_DEFAULT); CHECK_I(group1_id, "H5Gopen2"); - for(x = 0; x < NUM_DATASETS; x += 2) { + for (x = 0; x < NUM_DATASETS; x += 2) { /* First "type 1" dataset */ dset_id = H5Dopen2(group1_id, DSETNAME[x], H5P_DEFAULT); CHECK_I(dset_id, "H5Dopen2"); @@ -2002,7 +2038,7 @@ size2_verify(void) ndims = H5Sget_simple_extent_dims(space_id, dims, NULL); CHECK_I(ndims, "H5Sget_simple_extent_dims"); VERIFY(ndims, SIZE2_RANK1, "H5Sget_simple_extent_dims"); - for(y = 0; y < ndims; ++y) + for (y = 0; y < ndims; ++y) VERIFY(dims[y], correct_dims[y], "H5Sget_simple_extent_dims"); ret = H5Sclose(space_id); @@ -2025,7 +2061,7 @@ size2_verify(void) ndims = H5Sget_simple_extent_dims(space_id, dims, NULL); CHECK_I(ndims, "H5Sget_simple_extent_dims"); VERIFY(ndims, SIZE2_RANK2, "H5Sget_simple_extent_dims"); - for(y = 0; y < ndims; ++y) + for (y = 0; y < ndims; ++y) VERIFY(dims[y], correct_dims[y], "H5Sget_simple_extent_dims"); ret = H5Sclose(space_id); @@ -2037,7 +2073,6 @@ size2_verify(void) ret = H5Gclose(group1_id); CHECK_I(ret, "H5Gclose"); - /* Verify attributes */ /* Create attribute data type */ @@ -2057,7 +2092,7 @@ size2_verify(void) HDstrcpy(attr_correct_string, LONG_STRING); HDstrcpy(attr_name, "00 index"); - for(x = 0; x < NUM_ATTRIBUTES; ++x) { + for (x = 0; x < NUM_ATTRIBUTES; ++x) { /* Create the name and correct value for each attribute */ attr_correct_string[0] = attr_name[0] = (char)((x / 10) + '0'); attr_correct_string[1] = attr_name[1] = (char)((x % 10) + '0'); @@ -2091,7 +2126,6 @@ size2_verify(void) CHECK_I(ret, "H5Fclose"); } /* size2_verify */ - /*------------------------------------------------------------------------- * Function: test_sohm_size2 * @@ -2117,7 +2151,7 @@ size2_verify(void) static void test_sohm_size2(int close_reopen) { - hid_t fcpl_id = -1; + hid_t fcpl_id = -1; /* Sizes for file with no shared messages at all */ size2_helper_struct norm_sizes; /* Sizes for files with all messages in one index */ @@ -2129,9 +2163,9 @@ test_sohm_size2(int close_reopen) size2_helper_struct share_some_med, share_some_btree; /* Sizes for files that share different sizes of messages */ size2_helper_struct share_some_toobig_index, share_tiny_index, type_space_index; - herr_t ret; + herr_t ret; - if(close_reopen == 0) + if (close_reopen == 0) MESSAGE(5, ("Testing that shared object header messages save space\n")) else MESSAGE(5, ("Testing that shared messages save space when file is closed and reopened\n")) @@ -2150,7 +2184,6 @@ test_sohm_size2(int close_reopen) ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); - /* Create an fcpl with one big index */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); @@ -2168,7 +2201,6 @@ test_sohm_size2(int close_reopen) size2_helper(fcpl_id, close_reopen, &list_index_med); size2_verify(); - /* Try making the list really big */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 1000, 900); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -2177,7 +2209,6 @@ test_sohm_size2(int close_reopen) size2_helper(fcpl_id, close_reopen, &list_index_big); size2_verify(); - /* Use a B-tree instead of a list */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -2186,7 +2217,6 @@ test_sohm_size2(int close_reopen) size2_helper(fcpl_id, close_reopen, &btree_index); size2_verify(); - /* Use such a small list that it'll become a B-tree */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 10, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -2198,7 +2228,6 @@ test_sohm_size2(int close_reopen) ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); - /* Create a new property list that puts messages in different indexes. */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); @@ -2222,7 +2251,6 @@ test_sohm_size2(int close_reopen) size2_helper(fcpl_id, close_reopen, &mult_index_med); size2_verify(); - /* Use all B-trees */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -2231,7 +2259,6 @@ test_sohm_size2(int close_reopen) size2_helper(fcpl_id, close_reopen, &mult_index_btree); size2_verify(); - /* Edit the same property list (this should work) and don't share all messages. */ ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_PLINE_FLAG, 20); @@ -2257,7 +2284,6 @@ test_sohm_size2(int close_reopen) size2_helper(fcpl_id, close_reopen, &share_some_btree); size2_verify(); - /* Change the second index to hold only gigantic messages. Result should * be the same as the previous file. */ @@ -2268,7 +2294,6 @@ test_sohm_size2(int close_reopen) size2_helper(fcpl_id, close_reopen, &share_some_toobig_index); size2_verify(); - /* Share even tiny dataspace and datatype messages. This should result in * attribute datatypes being shared. Make this one use "really big" lists. * It turns out that attribute dataspaces are just big enough that it saves @@ -2294,143 +2319,130 @@ test_sohm_size2(int close_reopen) ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); - - /* Check that all sizes make sense. There is lots of room for inexact * results here since so many different factors contribute to file size. */ - /* Check sizes of all files created using a single index first */ /* The empty size of each file with shared messages enabled should be the * same and should be bigger than a normal file. */ - if(norm_sizes.empty_size > list_index_med.empty_size) + if (norm_sizes.empty_size > list_index_med.empty_size) VERIFY(norm_sizes.empty_size, 1, "h5_get_file_size"); - if(list_index_med.empty_size != list_index_big.empty_size) + if (list_index_med.empty_size != list_index_big.empty_size) VERIFY(list_index_med.empty_size, list_index_big.empty_size, "h5_get_file_size"); - if(list_index_med.empty_size != btree_index.empty_size) + if (list_index_med.empty_size != btree_index.empty_size) VERIFY(list_index_med.empty_size, btree_index.empty_size, "h5_get_file_size"); - if(list_index_med.empty_size != list_index_small.empty_size) + if (list_index_med.empty_size != list_index_small.empty_size) VERIFY(list_index_med.empty_size, list_index_small.empty_size, "h5_get_file_size"); /* The files with indexes shouldn't be that much bigger than an * empty file. */ - if(list_index_med.empty_size > (h5_stat_size_t)((float)norm_sizes.empty_size * OVERHEAD_ALLOWED)) + if (list_index_med.empty_size > (h5_stat_size_t)((float)norm_sizes.empty_size * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - /* Once one dataset has been created (with one of every kind of message), * the normal file should still be smallest. The very small list * btree_convert should be smaller than the B-tree since it has no * extra overhead. The small list should also be smaller than the B-tree. * The very large list should be much larger than anything else. */ - if(norm_sizes.first_dset >= list_index_small.first_dset) + if (norm_sizes.first_dset >= list_index_small.first_dset) VERIFY(norm_sizes.first_dset, 1, "h5_get_file_size"); - if(list_index_small.first_dset >= btree_index.first_dset) + if (list_index_small.first_dset >= btree_index.first_dset) VERIFY(list_index_small.first_dset, 1, "h5_get_file_size"); - if(list_index_med.first_dset >= btree_index.first_dset) + if (list_index_med.first_dset >= btree_index.first_dset) VERIFY(btree_index.first_dset, 1, "h5_get_file_size"); - if(btree_index.first_dset >= list_index_big.first_dset) + if (btree_index.first_dset >= list_index_big.first_dset) VERIFY(list_index_med.first_dset, 1, "h5_get_file_size"); - /* Once a few copies of the same dataset have been created, the * very small list shouldn't have become a B-tree yet, so it should * be the smallest file. A larger list should be next, followed * by a B-tree, followed by a normal file, followed by a * list that is too large. */ - if(list_index_small.dsets1 >= list_index_med.dsets1) + if (list_index_small.dsets1 >= list_index_med.dsets1) VERIFY(btree_index.dsets1, 1, "h5_get_file_size"); - if(list_index_med.dsets1 >= btree_index.dsets1) + if (list_index_med.dsets1 >= btree_index.dsets1) VERIFY(list_index_med.dsets1, 1, "h5_get_file_size"); - if(btree_index.dsets1 >= norm_sizes.dsets1) + if (btree_index.dsets1 >= norm_sizes.dsets1) VERIFY(btree_index.dsets1, 1, "h5_get_file_size"); - if(norm_sizes.dsets1 >= list_index_big.dsets1) + if (norm_sizes.dsets1 >= list_index_big.dsets1) VERIFY(list_index_big.dsets1, 1, "h5_get_file_size"); /* The size gain should have been the same for each of the lists; * their overhead is fixed. The B-tree should have gained at least * as much, and the normal file more than that. */ - if((list_index_small.dsets1 - list_index_small.first_dset) != - (list_index_med.dsets1 - list_index_med.first_dset)) + if ((list_index_small.dsets1 - list_index_small.first_dset) != + (list_index_med.dsets1 - list_index_med.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_med.dsets1 - list_index_med.first_dset) != - (list_index_big.dsets1 - list_index_big.first_dset)) + if ((list_index_med.dsets1 - list_index_med.first_dset) != + (list_index_big.dsets1 - list_index_big.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_big.dsets1 - list_index_big.first_dset) > - (btree_index.dsets1 - btree_index.first_dset)) + if ((list_index_big.dsets1 - list_index_big.first_dset) > (btree_index.dsets1 - btree_index.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - if((btree_index.dsets1 - btree_index.first_dset) >= - (norm_sizes.dsets1 - norm_sizes.first_dset)) + if ((btree_index.dsets1 - btree_index.first_dset) >= (norm_sizes.dsets1 - norm_sizes.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - /* Once another kind of each message has been written, the very small list * should convert into a B-tree. Now the list should be smallest, then * the B-trees (although the converted B-tree file may be a little bigger), * then the normal file. The largest list may or may not be bigger than * the normal file. */ - if(list_index_med.dsets2 >= btree_index.dsets2) + if (list_index_med.dsets2 >= btree_index.dsets2) VERIFY(list_index_med.dsets2, 1, "h5_get_file_size"); - if(btree_index.dsets2 > (h5_stat_size_t)((float)list_index_small.dsets2 * OVERHEAD_ALLOWED)) + if (btree_index.dsets2 > (h5_stat_size_t)((float)list_index_small.dsets2 * OVERHEAD_ALLOWED)) VERIFY(btree_index.dsets2, list_index_small.dsets2, "h5_get_file_size"); - if(list_index_small.dsets2 >= norm_sizes.dsets2) + if (list_index_small.dsets2 >= norm_sizes.dsets2) VERIFY(btree_index.dsets2, 1, "h5_get_file_size"); /* If the small list (now a B-tree) is bigger than the existing B-tree, * it shouldn't be much bigger. * It seems that the small lists tends to be pretty big anyway. Allow * for it to have twice as much overhead. */ - if(list_index_small.dsets2 > (h5_stat_size_t)((float)btree_index.dsets2 * OVERHEAD_ALLOWED * OVERHEAD_ALLOWED)) + if (list_index_small.dsets2 > + (h5_stat_size_t)((float)btree_index.dsets2 * OVERHEAD_ALLOWED * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); /* The lists should have grown the least since they share messages and * have no extra overhead. The normal file should have grown more than * either the lists or the B-tree. The B-tree may not have grown more * than the lists, depending on whether it needed to split nodes or not. */ - if((list_index_med.dsets2 - list_index_med.dsets1) != - (list_index_big.dsets2 - list_index_big.dsets1)) + if ((list_index_med.dsets2 - list_index_med.dsets1) != (list_index_big.dsets2 - list_index_big.dsets1)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_big.dsets2 - list_index_big.dsets1) > - (btree_index.dsets2 - btree_index.dsets1)) + if ((list_index_big.dsets2 - list_index_big.dsets1) > (btree_index.dsets2 - btree_index.dsets1)) VERIFY(0, 1, "h5_get_file_size"); - if((btree_index.dsets2 - btree_index.dsets1) >= - (norm_sizes.dsets2 - norm_sizes.dsets1)) + if ((btree_index.dsets2 - btree_index.dsets1) >= (norm_sizes.dsets2 - norm_sizes.dsets1)) VERIFY(0, 1, "h5_get_file_size"); - /* Interleaving the writes should have no effect on how the messages are * shared. No new messages should be written to the indexes, so the * sohm files will only get a little bit bigger. */ - if(list_index_med.interleaved >= btree_index.interleaved) + if (list_index_med.interleaved >= btree_index.interleaved) VERIFY(0, 1, "h5_get_file_size"); - if(btree_index.interleaved > (h5_stat_size_t)((float)list_index_small.interleaved * OVERHEAD_ALLOWED)) + if (btree_index.interleaved > (h5_stat_size_t)((float)list_index_small.interleaved * OVERHEAD_ALLOWED)) VERIFY(btree_index.interleaved, list_index_small.interleaved, "h5_get_file_size"); - if(list_index_small.interleaved >= norm_sizes.interleaved) + if (list_index_small.interleaved >= norm_sizes.interleaved) VERIFY(0, 1, "h5_get_file_size"); /* The lists should still have grown the same amount. The converted * B-tree shouldn't have grown more than the index that was originally * a B-tree (although it might have grown less if there was extra free * space within the file). */ - if((list_index_med.interleaved - list_index_med.dsets2) != - (list_index_big.interleaved - list_index_big.dsets2)) + if ((list_index_med.interleaved - list_index_med.dsets2) != + (list_index_big.interleaved - list_index_big.dsets2)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_big.interleaved - list_index_big.dsets2) > - (btree_index.interleaved - btree_index.dsets2)) + if ((list_index_big.interleaved - list_index_big.dsets2) > (btree_index.interleaved - btree_index.dsets2)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_small.interleaved - list_index_small.dsets2) > - (btree_index.interleaved - btree_index.dsets2)) + if ((list_index_small.interleaved - list_index_small.dsets2) > + (btree_index.interleaved - btree_index.dsets2)) VERIFY(0, 1, "h5_get_file_size"); - if((btree_index.interleaved - btree_index.dsets2) >= - (norm_sizes.interleaved - norm_sizes.dsets2)) + if ((btree_index.interleaved - btree_index.dsets2) >= (norm_sizes.interleaved - norm_sizes.dsets2)) VERIFY(0, 1, "h5_get_file_size"); /* After many attributes have been written, both the small and medium lists @@ -2439,75 +2451,68 @@ test_sohm_size2(int close_reopen) * Add in OVERHEAD_ALLOWED as a fudge factor here, since the allocation * of file space can be hard to predict. */ - if(btree_index.attrs1 > (h5_stat_size_t)((float)list_index_small.attrs1 * OVERHEAD_ALLOWED)) + if (btree_index.attrs1 > (h5_stat_size_t)((float)list_index_small.attrs1 * OVERHEAD_ALLOWED)) VERIFY(btree_index.attrs1, list_index_small.attrs1, "h5_get_file_size"); - if(btree_index.attrs1 > (h5_stat_size_t)((float)list_index_med.attrs1 * OVERHEAD_ALLOWED)) + if (btree_index.attrs1 > (h5_stat_size_t)((float)list_index_med.attrs1 * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if(list_index_med.attrs1 > (h5_stat_size_t)((float)btree_index.attrs1 * OVERHEAD_ALLOWED)) + if (list_index_med.attrs1 > (h5_stat_size_t)((float)btree_index.attrs1 * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if(list_index_small.attrs1 > (h5_stat_size_t)((float)btree_index.attrs1 * OVERHEAD_ALLOWED)) + if (list_index_small.attrs1 > (h5_stat_size_t)((float)btree_index.attrs1 * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); /* Neither of the converted lists should be too much bigger than * the index that was originally a B-tree. */ - if(list_index_small.attrs1 > (h5_stat_size_t)((float)btree_index.attrs1 * OVERHEAD_ALLOWED)) + if (list_index_small.attrs1 > (h5_stat_size_t)((float)btree_index.attrs1 * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if(list_index_med.attrs1 > (h5_stat_size_t)((float)btree_index.attrs1 * OVERHEAD_ALLOWED)) + if (list_index_med.attrs1 > (h5_stat_size_t)((float)btree_index.attrs1 * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); /* The "normal" file should have had less overhead, so should gain less * size than any of the other indexes since none of these attribute * messages could be shared. The large list should have gained * less overhead than the B-tree indexes. */ - if((norm_sizes.attrs1 - norm_sizes.interleaved) >= - (list_index_big.attrs1 - list_index_big.interleaved)) + if ((norm_sizes.attrs1 - norm_sizes.interleaved) >= (list_index_big.attrs1 - list_index_big.interleaved)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_big.attrs1 - list_index_big.interleaved) >= - (list_index_small.attrs1 - list_index_small.interleaved)) + if ((list_index_big.attrs1 - list_index_big.interleaved) >= + (list_index_small.attrs1 - list_index_small.interleaved)) VERIFY(0, 1, "h5_get_file_size"); /* Give it some overhead (for checkin to move messages into continuation message) */ - if((list_index_small.attrs1 - list_index_small.interleaved) > - (h5_stat_size_t)((float)(btree_index.attrs1 - btree_index.interleaved) * OVERHEAD_ALLOWED)) + if ((list_index_small.attrs1 - list_index_small.interleaved) > + (h5_stat_size_t)((float)(btree_index.attrs1 - btree_index.interleaved) * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - /* Writing another copy of each attribute shouldn't change the ordering * of sizes. The big list index is still too big to be smaller than a * normal file. The B-tree indexes should all be about the same size. */ - if(btree_index.attrs2 > (h5_stat_size_t)((float)list_index_small.attrs2 * OVERHEAD_ALLOWED)) + if (btree_index.attrs2 > (h5_stat_size_t)((float)list_index_small.attrs2 * OVERHEAD_ALLOWED)) VERIFY(btree_index.attrs2, list_index_small.attrs2, "h5_get_file_size"); - if(list_index_small.attrs2 > (h5_stat_size_t)((float)btree_index.attrs2 * OVERHEAD_ALLOWED)) + if (list_index_small.attrs2 > (h5_stat_size_t)((float)btree_index.attrs2 * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if(btree_index.attrs2 > (h5_stat_size_t)((float)list_index_med.attrs2 * OVERHEAD_ALLOWED)) + if (btree_index.attrs2 > (h5_stat_size_t)((float)list_index_med.attrs2 * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if(list_index_med.attrs2 > (h5_stat_size_t)((float)btree_index.attrs2 * OVERHEAD_ALLOWED)) + if (list_index_med.attrs2 > (h5_stat_size_t)((float)btree_index.attrs2 * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if(list_index_med.attrs2 >= norm_sizes.attrs2) + if (list_index_med.attrs2 >= norm_sizes.attrs2) VERIFY(0, 1, "h5_get_file_size"); - if(list_index_big.attrs2 >= norm_sizes.attrs2) + if (list_index_big.attrs2 >= norm_sizes.attrs2) VERIFY(0, 1, "h5_get_file_size"); /* All of the B-tree indexes should have gained about the same amount * of space; at least as much as the list index and less than a normal * file. */ - if((list_index_small.attrs2 - list_index_small.attrs1) > - (btree_index.attrs2 - btree_index.attrs1)) + if ((list_index_small.attrs2 - list_index_small.attrs1) > (btree_index.attrs2 - btree_index.attrs1)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_med.attrs2 - list_index_med.attrs1) > - (btree_index.attrs2 - btree_index.attrs1)) + if ((list_index_med.attrs2 - list_index_med.attrs1) > (btree_index.attrs2 - btree_index.attrs1)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_big.attrs2 - list_index_big.attrs1) > - (list_index_med.attrs2 - list_index_med.attrs1)) + if ((list_index_big.attrs2 - list_index_big.attrs1) > (list_index_med.attrs2 - list_index_med.attrs1)) VERIFY(0, 1, "h5_get_file_size"); - if((btree_index.attrs2 - btree_index.attrs1) >= - (norm_sizes.attrs2 - norm_sizes.attrs1)) + if ((btree_index.attrs2 - btree_index.attrs1) >= (norm_sizes.attrs2 - norm_sizes.attrs1)) VERIFY(0, 1, "h5_get_file_size"); /* Done checking the first few files that use a single index. */ - /* Start comparing other kinds of files with these "standard" * one-index files */ @@ -2516,45 +2521,45 @@ test_sohm_size2(int close_reopen) /* These files should be larger when first created than one-index * files. */ - if(mult_index_med.empty_size <= list_index_med.empty_size) + if (mult_index_med.empty_size <= list_index_med.empty_size) VERIFY(0, 1, "h5_get_file_size"); - if(mult_index_btree.empty_size != mult_index_med.empty_size) + if (mult_index_btree.empty_size != mult_index_med.empty_size) VERIFY(0, 1, "h5_get_file_size"); /* When the first dataset is written, they should grow quite a bit as * many different indexes must be created. */ - if((mult_index_med.first_dset - mult_index_med.empty_size) <= - (list_index_med.first_dset - list_index_med.empty_size)) + if ((mult_index_med.first_dset - mult_index_med.empty_size) <= + (list_index_med.first_dset - list_index_med.empty_size)) VERIFY(0, 1, "h5_get_file_size"); - if((mult_index_btree.first_dset - mult_index_btree.empty_size) <= - (btree_index.first_dset - btree_index.empty_size)) + if ((mult_index_btree.first_dset - mult_index_btree.empty_size) <= + (btree_index.first_dset - btree_index.empty_size)) VERIFY(0, 1, "h5_get_file_size"); /* When the second dataset is written, they should grow less as * some extra heap space is allocated, but no more indices. */ - if((mult_index_med.second_dset - mult_index_med.first_dset) > - (mult_index_med.first_dset - mult_index_med.empty_size)) + if ((mult_index_med.second_dset - mult_index_med.first_dset) > + (mult_index_med.first_dset - mult_index_med.empty_size)) VERIFY(0, 1, "h5_get_file_size"); - if((list_index_med.second_dset - list_index_med.first_dset) > - (list_index_med.first_dset - list_index_med.empty_size)) + if ((list_index_med.second_dset - list_index_med.first_dset) > + (list_index_med.first_dset - list_index_med.empty_size)) VERIFY(0, 1, "h5_get_file_size"); - if((mult_index_btree.second_dset - mult_index_btree.first_dset) > - (mult_index_btree.first_dset - mult_index_btree.empty_size)) + if ((mult_index_btree.second_dset - mult_index_btree.first_dset) > + (mult_index_btree.first_dset - mult_index_btree.empty_size)) VERIFY(0, 1, "h5_get_file_size"); - if((btree_index.second_dset - btree_index.first_dset) > - (btree_index.first_dset - btree_index.empty_size)) + if ((btree_index.second_dset - btree_index.first_dset) > + (btree_index.first_dset - btree_index.empty_size)) VERIFY(0, 1, "h5_get_file_size"); /* And the size delta for the second dataset is less in files with only * one index. */ - if((mult_index_med.second_dset - mult_index_med.first_dset) <= - (list_index_med.second_dset - list_index_med.first_dset)) + if ((mult_index_med.second_dset - mult_index_med.first_dset) <= + (list_index_med.second_dset - list_index_med.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - if((mult_index_btree.first_dset - mult_index_btree.empty_size) <= - (btree_index.first_dset - btree_index.empty_size)) + if ((mult_index_btree.first_dset - mult_index_btree.empty_size) <= + (btree_index.first_dset - btree_index.empty_size)) VERIFY(0, 1, "h5_get_file_size"); /* Once that initial overhead is out of the way and the lists/btrees @@ -2562,25 +2567,27 @@ test_sohm_size2(int close_reopen) * the same rate or slightly faster than files with just one index * and one heap. */ - if((mult_index_med.dsets1 - mult_index_med.second_dset) != - (list_index_med.dsets1 - list_index_med.second_dset)) - VERIFY((mult_index_med.dsets1 - mult_index_med.second_dset), (list_index_med.dsets1 - list_index_med.second_dset), "h5_get_file_size"); - if((mult_index_btree.dsets1 - mult_index_btree.second_dset) != - (btree_index.dsets1 - btree_index.second_dset)) - VERIFY((mult_index_btree.dsets1 - mult_index_btree.second_dset), (btree_index.dsets1 - btree_index.second_dset), "h5_get_file_size"); + if ((mult_index_med.dsets1 - mult_index_med.second_dset) != + (list_index_med.dsets1 - list_index_med.second_dset)) + VERIFY((mult_index_med.dsets1 - mult_index_med.second_dset), + (list_index_med.dsets1 - list_index_med.second_dset), "h5_get_file_size"); + if ((mult_index_btree.dsets1 - mult_index_btree.second_dset) != + (btree_index.dsets1 - btree_index.second_dset)) + VERIFY((mult_index_btree.dsets1 - mult_index_btree.second_dset), + (btree_index.dsets1 - btree_index.second_dset), "h5_get_file_size"); - if((mult_index_med.dsets2 - mult_index_med.dsets1) > - (h5_stat_size_t)((float)(list_index_med.dsets2 - list_index_med.dsets1) * OVERHEAD_ALLOWED)) + if ((mult_index_med.dsets2 - mult_index_med.dsets1) > + (h5_stat_size_t)((float)(list_index_med.dsets2 - list_index_med.dsets1) * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if((mult_index_btree.dsets2 - mult_index_btree.dsets1) > - (h5_stat_size_t)((float)(btree_index.dsets2 - btree_index.dsets1) * OVERHEAD_ALLOWED)) + if ((mult_index_btree.dsets2 - mult_index_btree.dsets1) > + (h5_stat_size_t)((float)(btree_index.dsets2 - btree_index.dsets1) * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if((mult_index_med.interleaved - mult_index_med.dsets2) > - (h5_stat_size_t)((float)(list_index_med.interleaved - list_index_med.dsets2) * OVERHEAD_ALLOWED)) + if ((mult_index_med.interleaved - mult_index_med.dsets2) > + (h5_stat_size_t)((float)(list_index_med.interleaved - list_index_med.dsets2) * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if((mult_index_btree.interleaved - mult_index_btree.dsets2) > - (h5_stat_size_t)((float)(btree_index.interleaved - btree_index.dsets2) * OVERHEAD_ALLOWED)) + if ((mult_index_btree.interleaved - mult_index_btree.dsets2) > + (h5_stat_size_t)((float)(btree_index.interleaved - btree_index.dsets2) * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); /* When all the attributes are added, only the index holding attributes @@ -2588,81 +2595,78 @@ test_sohm_size2(int close_reopen) * this happens because it's hard to predict exactly how much space this * will take. */ - if((mult_index_med.attrs2 - mult_index_med.attrs1) > - (h5_stat_size_t)((float)(list_index_med.attrs2 - list_index_med.attrs1) * OVERHEAD_ALLOWED)) + if ((mult_index_med.attrs2 - mult_index_med.attrs1) > + (h5_stat_size_t)((float)(list_index_med.attrs2 - list_index_med.attrs1) * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); - if((mult_index_btree.attrs2 - mult_index_btree.attrs1) > - (h5_stat_size_t)((float)(btree_index.attrs2 - btree_index.attrs1) * OVERHEAD_ALLOWED)) + if ((mult_index_btree.attrs2 - mult_index_btree.attrs1) > + (h5_stat_size_t)((float)(btree_index.attrs2 - btree_index.attrs1) * OVERHEAD_ALLOWED)) VERIFY(0, 1, "h5_get_file_size"); /* The final file size for both of the multiple index files should be * smaller than a normal file but bigger than any of the one-index files. */ - if(mult_index_med.attrs2 >= norm_sizes.attrs2) + if (mult_index_med.attrs2 >= norm_sizes.attrs2) VERIFY(0, 1, "h5_get_file_size"); - if(mult_index_btree.attrs2 >= norm_sizes.attrs2) + if (mult_index_btree.attrs2 >= norm_sizes.attrs2) VERIFY(0, 1, "h5_get_file_size"); - if((h5_stat_size_t)((float)mult_index_med.attrs2 * OVERHEAD_ALLOWED) < btree_index.attrs2) + if ((h5_stat_size_t)((float)mult_index_med.attrs2 * OVERHEAD_ALLOWED) < btree_index.attrs2) VERIFY(0, 1, "h5_get_file_size"); - if((h5_stat_size_t)((float)mult_index_btree.attrs2 * OVERHEAD_ALLOWED) < btree_index.attrs2) + if ((h5_stat_size_t)((float)mult_index_btree.attrs2 * OVERHEAD_ALLOWED) < btree_index.attrs2) VERIFY(0, 1, "h5_get_file_size"); - /* Check files that don't share all messages. */ /* These files have three indexes like the files above, so they should be * the same size when created. */ - if(share_some_med.empty_size != mult_index_med.empty_size) + if (share_some_med.empty_size != mult_index_med.empty_size) VERIFY(0, 1, "h5_get_file_size"); - if(share_some_med.empty_size != share_some_btree.empty_size) + if (share_some_med.empty_size != share_some_btree.empty_size) VERIFY(0, 1, "h5_get_file_size"); /* When the first dataset is created, they should be not quite as big * as equivalent files that share all messages (since shared messages * have a little bit of overhead). */ - if(share_some_med.first_dset >= mult_index_med.first_dset) + if (share_some_med.first_dset >= mult_index_med.first_dset) VERIFY(0, 1, "h5_get_file_size"); - if(share_some_btree.first_dset >= mult_index_btree.first_dset) + if (share_some_btree.first_dset >= mult_index_btree.first_dset) VERIFY(0, 1, "h5_get_file_size"); /* The files that share some should have a growth rate in between * files that share all messages and normal files */ - if((share_some_med.interleaved - share_some_med.first_dset) <= - (mult_index_med.interleaved - mult_index_med.first_dset)) + if ((share_some_med.interleaved - share_some_med.first_dset) <= + (mult_index_med.interleaved - mult_index_med.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - if((share_some_med.interleaved - share_some_med.first_dset) >= - (norm_sizes.interleaved - norm_sizes.first_dset)) + if ((share_some_med.interleaved - share_some_med.first_dset) >= + (norm_sizes.interleaved - norm_sizes.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - if((share_some_btree.interleaved - share_some_btree.first_dset) <= - (mult_index_btree.interleaved - mult_index_btree.first_dset)) + if ((share_some_btree.interleaved - share_some_btree.first_dset) <= + (mult_index_btree.interleaved - mult_index_btree.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - if((share_some_btree.interleaved - share_some_btree.first_dset) >= - (norm_sizes.interleaved - norm_sizes.first_dset)) + if ((share_some_btree.interleaved - share_some_btree.first_dset) >= + (norm_sizes.interleaved - norm_sizes.first_dset)) VERIFY(0, 1, "h5_get_file_size"); - /* Check the file that only stored gigantic messages in its second * index. Since no messages were that big, it should be identical * to the file with an empty index. */ - if(share_some_btree.empty_size != share_some_toobig_index.empty_size) + if (share_some_btree.empty_size != share_some_toobig_index.empty_size) VERIFY(0, 1, "h5_get_file_size"); - if(share_some_btree.first_dset != share_some_toobig_index.first_dset) + if (share_some_btree.first_dset != share_some_toobig_index.first_dset) VERIFY(0, 1, "h5_get_file_size"); - if(share_some_btree.dsets1 != share_some_toobig_index.dsets1) + if (share_some_btree.dsets1 != share_some_toobig_index.dsets1) VERIFY(0, 1, "h5_get_file_size"); - if(share_some_btree.dsets2 != share_some_toobig_index.dsets2) + if (share_some_btree.dsets2 != share_some_toobig_index.dsets2) VERIFY(0, 1, "h5_get_file_size"); - if(share_some_btree.interleaved != share_some_toobig_index.interleaved) + if (share_some_btree.interleaved != share_some_toobig_index.interleaved) VERIFY(0, 1, "h5_get_file_size"); - if(share_some_btree.attrs1 != share_some_toobig_index.attrs1) + if (share_some_btree.attrs1 != share_some_toobig_index.attrs1) VERIFY(0, 1, "h5_get_file_size"); - if(share_some_btree.attrs2 != share_some_toobig_index.attrs2) + if (share_some_btree.attrs2 != share_some_toobig_index.attrs2) VERIFY(0, 1, "h5_get_file_size"); - /* Check the file that shares even very tiny messages. Once messages * are written to it, it should gain a little space from sharing the * messages and lose a little space to overhead so that it's just slightly @@ -2670,46 +2674,48 @@ test_sohm_size2(int close_reopen) * If the overhead increases or the size of messages decreases, these * numbers may be off. */ - if(share_tiny_index.empty_size != type_space_index.empty_size) + if (share_tiny_index.empty_size != type_space_index.empty_size) VERIFY(share_tiny_index.empty_size, type_space_index.empty_size, "h5_get_file_size"); - if(share_tiny_index.first_dset >= (h5_stat_size_t)((float)type_space_index.first_dset * OVERHEAD_ALLOWED)) + if (share_tiny_index.first_dset >= + (h5_stat_size_t)((float)type_space_index.first_dset * OVERHEAD_ALLOWED)) VERIFY(share_tiny_index.first_dset, type_space_index.first_dset, "h5_get_file_size"); - if(share_tiny_index.first_dset < type_space_index.first_dset) + if (share_tiny_index.first_dset < type_space_index.first_dset) VERIFY(0, 1, "h5_get_file_size"); - if(share_tiny_index.second_dset >= type_space_index.second_dset) + if (share_tiny_index.second_dset >= type_space_index.second_dset) VERIFY(share_tiny_index.second_dset, type_space_index.second_dset, "h5_get_file_size"); - if((h5_stat_size_t)((float)share_tiny_index.second_dset * OVERHEAD_ALLOWED) < type_space_index.second_dset) + if ((h5_stat_size_t)((float)share_tiny_index.second_dset * OVERHEAD_ALLOWED) < + type_space_index.second_dset) VERIFY(0, 1, "h5_get_file_size"); - if(share_tiny_index.dsets1 >= type_space_index.dsets1) + if (share_tiny_index.dsets1 >= type_space_index.dsets1) VERIFY(0, 1, "h5_get_file_size"); - if((h5_stat_size_t)((float)share_tiny_index.dsets1 * OVERHEAD_ALLOWED) < type_space_index.dsets1) + if ((h5_stat_size_t)((float)share_tiny_index.dsets1 * OVERHEAD_ALLOWED) < type_space_index.dsets1) VERIFY(0, 1, "h5_get_file_size"); - if(share_tiny_index.dsets2 >= type_space_index.dsets2) + if (share_tiny_index.dsets2 >= type_space_index.dsets2) VERIFY(0, 1, "h5_get_file_size"); - if((h5_stat_size_t)((float)share_tiny_index.dsets2 * OVERHEAD_ALLOWED) < type_space_index.dsets2) + if ((h5_stat_size_t)((float)share_tiny_index.dsets2 * OVERHEAD_ALLOWED) < type_space_index.dsets2) VERIFY(0, 1, "h5_get_file_size"); - if(share_tiny_index.interleaved >= type_space_index.interleaved) + if (share_tiny_index.interleaved >= type_space_index.interleaved) VERIFY(0, 1, "h5_get_file_size"); - if((h5_stat_size_t)((float)share_tiny_index.interleaved * OVERHEAD_ALLOWED) < type_space_index.interleaved) + if ((h5_stat_size_t)((float)share_tiny_index.interleaved * OVERHEAD_ALLOWED) < + type_space_index.interleaved) VERIFY(0, 1, "h5_get_file_size"); - if(share_tiny_index.attrs1 >= type_space_index.attrs1) + if (share_tiny_index.attrs1 >= type_space_index.attrs1) VERIFY(0, 1, "h5_get_file_size"); - if((h5_stat_size_t)((float)share_tiny_index.attrs1 * OVERHEAD_ALLOWED) < type_space_index.attrs1) + if ((h5_stat_size_t)((float)share_tiny_index.attrs1 * OVERHEAD_ALLOWED) < type_space_index.attrs1) VERIFY(0, 1, "h5_get_file_size"); - if(share_tiny_index.attrs2 >= type_space_index.attrs2) + if (share_tiny_index.attrs2 >= type_space_index.attrs2) VERIFY(0, 1, "h5_get_file_size"); - if((h5_stat_size_t)((float)share_tiny_index.attrs2 * OVERHEAD_ALLOWED) < type_space_index.attrs2) + if ((h5_stat_size_t)((float)share_tiny_index.attrs2 * OVERHEAD_ALLOWED) < type_space_index.attrs2) VERIFY(0, 1, "h5_get_file_size"); } /* test_sohm_size2 */ - /*------------------------------------------------------------------------- * Function: delete_helper_write * @@ -2731,10 +2737,11 @@ delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, int x) char wdata; herr_t ret; - dset_id = H5Dcreate2(file_id, DSETNAME[x], H5T_NATIVE_CHAR, dspace_id[x], H5P_DEFAULT, dcpl_id[x], H5P_DEFAULT); + dset_id = + H5Dcreate2(file_id, DSETNAME[x], H5T_NATIVE_CHAR, dspace_id[x], H5P_DEFAULT, dcpl_id[x], H5P_DEFAULT); CHECK_I(dset_id, "H5Dcreate2"); wdata = (char)(x + 'a'); - ret = H5Dwrite(dset_id, H5T_NATIVE_CHAR, dspace_id[x], dspace_id[x], H5P_DEFAULT, &wdata); + ret = H5Dwrite(dset_id, H5T_NATIVE_CHAR, dspace_id[x], dspace_id[x], H5P_DEFAULT, &wdata); CHECK_I(ret, "H5Dwrite"); attr_id = H5Acreate2(dset_id, "attr_name", H5T_NATIVE_CHAR, dspace_id[x], H5P_DEFAULT, H5P_DEFAULT); @@ -2748,7 +2755,6 @@ delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, int x) CHECK_I(ret, "H5Dclose"); } /* delete_helper_write */ - /*------------------------------------------------------------------------- * Function: delete_helper_read * @@ -2765,22 +2771,22 @@ delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, int x) static void delete_helper_read(hid_t file_id, hid_t *dspace_id, int x) { - hid_t dset_id = -1; - hid_t attr_id = -1; - char rdata; + hid_t dset_id = -1; + hid_t attr_id = -1; + char rdata; herr_t ret; dset_id = H5Dopen2(file_id, DSETNAME[x], H5P_DEFAULT); CHECK_I(dset_id, "H5Dopen2"); rdata = '\0'; - ret = H5Dread(dset_id, H5T_NATIVE_CHAR, dspace_id[x], dspace_id[x], H5P_DEFAULT, &rdata); + ret = H5Dread(dset_id, H5T_NATIVE_CHAR, dspace_id[x], dspace_id[x], H5P_DEFAULT, &rdata); CHECK_I(ret, "H5Dread"); VERIFY(rdata, (x + 'a'), "H5Dread"); attr_id = H5Aopen(dset_id, "attr_name", H5P_DEFAULT); CHECK_I(attr_id, "H5Aopen"); rdata = '\0'; - ret = H5Aread(attr_id, H5T_NATIVE_CHAR, &rdata); + ret = H5Aread(attr_id, H5T_NATIVE_CHAR, &rdata); CHECK_I(ret, "H5Dread"); VERIFY(rdata, (x + 'a'), "H5Dread"); @@ -2790,7 +2796,6 @@ delete_helper_read(hid_t file_id, hid_t *dspace_id, int x) CHECK_I(ret, "H5Dclose"); } /* delete_helper_read */ - /*------------------------------------------------------------------------- * Function: delete_helper * @@ -2815,23 +2820,23 @@ delete_helper_read(hid_t file_id, hid_t *dspace_id, int x) static void delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id) { - hid_t file_id=-1; - int x; + hid_t file_id = -1; + int x; h5_stat_size_t norm_filesize; h5_stat_size_t deleted_filesize; - herr_t ret; + herr_t ret; /* Get the size of a "normal" file with no deleted messages */ file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); CHECK_I(file_id, "H5Fcreate"); /* Create batch of messages in the file starting at message 2 */ - for(x=HALF_DELETE_NUM_MESGS; x (h5_stat_size_t)((float)deleted_filesize * OVERHEAD_ALLOWED)) + if (norm_filesize > (h5_stat_size_t)((float)deleted_filesize * OVERHEAD_ALLOWED)) VERIFY(norm_filesize, deleted_filesize, "h5_get_file_size"); - if(deleted_filesize > (h5_stat_size_t)((float)norm_filesize * OVERHEAD_ALLOWED)) + if (deleted_filesize > (h5_stat_size_t)((float)norm_filesize * OVERHEAD_ALLOWED)) VERIFY(deleted_filesize, norm_filesize, "h5_get_file_size"); } /* delete_helper */ - /*------------------------------------------------------------------------- * Function: test_sohm_delete * @@ -2904,19 +2908,19 @@ test_sohm_delete(void) /* We'll use dataspaces and filter pipelines for this test. * Create a number of distinct messages of each type. */ - hid_t dspace_id[DELETE_NUM_MESGS] = {0}; - hid_t dcpl_id[DELETE_NUM_MESGS] = {0}; + hid_t dspace_id[DELETE_NUM_MESGS] = {0}; + hid_t dcpl_id[DELETE_NUM_MESGS] = {0}; unsigned u; - int x; - hsize_t dims[] = DELETE_DIMS; - herr_t ret; + int x; + hsize_t dims[] = DELETE_DIMS; + herr_t ret; MESSAGE(5, ("Testing deletion of SOHMs\n")); /* Create a number of different dataspaces. * For simplicity, each dataspace has only one element. */ - for(u = 0; u < DELETE_NUM_MESGS; ++u) { + for (u = 0; u < DELETE_NUM_MESGS; ++u) { dspace_id[u] = H5Screate_simple((int)(u + 1), dims, dims); CHECK_I(dspace_id[u], "H5Screate_simple"); } /* end for */ @@ -2930,7 +2934,7 @@ test_sohm_delete(void) ret = H5Pset_shuffle(dcpl_id[0]); CHECK_I(ret, "H5Pset_shuffle"); - for(u = 1; u < DELETE_NUM_MESGS; u += 2) { + for (u = 1; u < DELETE_NUM_MESGS; u += 2) { dcpl_id[u] = H5Pcopy(dcpl_id[u - 1]); CHECK_I(dcpl_id[u], "H5Pcopy"); ret = H5Pset_chunk(dcpl_id[u], (int)(u + 1), dims); @@ -2954,7 +2958,6 @@ test_sohm_delete(void) ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 16); CHECK_I(ret, "H5Pset_shared_mesg_index"); - /* Use big list indexes */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 4 * DELETE_NUM_MESGS, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -2968,14 +2971,12 @@ test_sohm_delete(void) delete_helper(fcpl_id, dspace_id, dcpl_id); - /* Use small list indexes that will convert from lists to B-trees and back */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, HALF_DELETE_NUM_MESGS, HALF_DELETE_NUM_MESGS - 1); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); delete_helper(fcpl_id, dspace_id, dcpl_id); - /* Use two indexes */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); @@ -2988,27 +2989,24 @@ test_sohm_delete(void) ret = H5Pset_shared_mesg_phase_change(fcpl_id, 5000, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - /* Use B-tree indexes */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); delete_helper(fcpl_id, dspace_id, dcpl_id); - /* Set phase change values so that one index converts to a B-tree and one doesn't */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, HALF_DELETE_NUM_MESGS + 1, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); delete_helper(fcpl_id, dspace_id, dcpl_id); - /* Test with varying message sizes (ideally, so some messages are too * small to be written but some are big enough that they are still written */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - for(u = DELETE_MIN_MESG_SIZE; u <= DELETE_MAX_MESG_SIZE; u += 10) { + for (u = DELETE_MIN_MESG_SIZE; u <= DELETE_MAX_MESG_SIZE; u += 10) { ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, u); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); delete_helper(fcpl_id, dspace_id, dcpl_id); @@ -3018,7 +3016,7 @@ test_sohm_delete(void) ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); - for(x = DELETE_NUM_MESGS - 1; x >= 0; --x) { + for (x = DELETE_NUM_MESGS - 1; x >= 0; --x) { ret = H5Sclose(dspace_id[x]); CHECK_I(ret, "H5Sclose"); ret = H5Pclose(dcpl_id[x]); @@ -3026,7 +3024,6 @@ test_sohm_delete(void) } /* end for */ } /* test_sohm_delete */ - /*------------------------------------------------------------------------- * Function: verify_dset_create_and_delete_does_not_grow_file * @@ -3047,13 +3044,13 @@ test_sohm_delete(void) static int verify_dset_create_and_delete_does_not_grow_file(hid_t fcpl_id) { - hid_t file_id; - hid_t dspace_id; - hid_t dset_id; - hsize_t dims[1] = {1}; + hid_t file_id; + hid_t dspace_id; + hid_t dset_id; + hsize_t dims[1] = {1}; h5_stat_size_t initial_filesize, deleted_filesize; - int old_nerrs; /* Number of errors when entering this routine */ - herr_t ret; + int old_nerrs; /* Number of errors when entering this routine */ + herr_t ret; /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); @@ -3071,7 +3068,6 @@ verify_dset_create_and_delete_does_not_grow_file(hid_t fcpl_id) CHECK_I(ret, "H5Fclose"); initial_filesize = h5_get_file_size(FILENAME, H5P_DEFAULT); - /* Re-create the file and create a dataset in it */ file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); CHECK_I(file_id, "H5Fcreate"); @@ -3092,7 +3088,6 @@ verify_dset_create_and_delete_does_not_grow_file(hid_t fcpl_id) VERIFY(deleted_filesize, initial_filesize, "h5_get_file_size"); - /* Repeat, creating two datasets in the file */ file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); CHECK_I(file_id, "H5Fcreate"); @@ -3104,7 +3099,8 @@ verify_dset_create_and_delete_does_not_grow_file(hid_t fcpl_id) CHECK_I(ret, "H5Dclose"); /* Create and close the second. These messages should be shared */ - dset_id = H5Dcreate2(file_id, "dset2", H5T_NATIVE_SHORT, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = + H5Dcreate2(file_id, "dset2", H5T_NATIVE_SHORT, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK_I(dset_id, "H5Dcreate2"); ret = H5Dclose(dset_id); CHECK_I(ret, "H5Dclose"); @@ -3122,19 +3118,17 @@ verify_dset_create_and_delete_does_not_grow_file(hid_t fcpl_id) VERIFY(deleted_filesize, initial_filesize, "h5_get_file_size"); - /* Cleanup */ ret = H5Sclose(dspace_id); CHECK_I(ret, "H5Sclose"); /* Retrieve current # of errors */ - if(old_nerrs == GetTestNumErrs()) - return(0); + if (old_nerrs == GetTestNumErrs()) + return (0); else - return(-1); + return (-1); } /* verify_dset_create_and_delete_does_not_grow_file */ - /*------------------------------------------------------------------------- * Function: test_sohm_delete_revert * @@ -3151,7 +3145,7 @@ verify_dset_create_and_delete_does_not_grow_file(hid_t fcpl_id) static void test_sohm_delete_revert(void) { - hid_t fcpl_id; + hid_t fcpl_id; herr_t ret; MESSAGE(5, ("Testing that file reverts to original size on SOHM deletion\n")); @@ -3176,7 +3170,6 @@ test_sohm_delete_revert(void) ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id); CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file"); - /* Try sharing all messages */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); @@ -3203,7 +3196,6 @@ test_sohm_delete_revert(void) ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id); CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file"); - /* Try with shared messages enabled, but when messages are too big * to be shared. */ @@ -3216,7 +3208,6 @@ test_sohm_delete_revert(void) CHECK_I(ret, "H5Pclose"); } /* test_sohm_delete_revert */ - /*------------------------------------------------------------------------- * Function: verify_dset_create_and_open_through_extlink_with_sohm * @@ -3234,12 +3225,12 @@ test_sohm_delete_revert(void) static void verify_dset_create_and_open_through_extlink_with_sohm(hid_t src_fcpl_id, hid_t dst_fcpl_id) { - hid_t src_file_id = -1; - hid_t dst_file_id = -1; - hid_t space_id = -1; - hid_t dset_id = -1; - hsize_t dims[] = {1, 1}; - herr_t ret; + hid_t src_file_id = -1; + hid_t dst_file_id = -1; + hid_t space_id = -1; + hid_t dset_id = -1; + hsize_t dims[] = {1, 1}; + herr_t ret; /* Create files */ src_file_id = H5Fcreate(FILENAME_SRC, H5F_ACC_TRUNC, src_fcpl_id, H5P_DEFAULT); @@ -3254,7 +3245,8 @@ verify_dset_create_and_open_through_extlink_with_sohm(hid_t src_fcpl_id, hid_t d /* Create a dataset through the external link */ space_id = H5Screate_simple(2, dims, dims); CHECK_I(space_id, "H5Screate_simple"); - dset_id = H5Dcreate2(src_file_id, "ext_link/dataset", H5T_NATIVE_FLOAT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(src_file_id, "ext_link/dataset", H5T_NATIVE_FLOAT, space_id, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); CHECK_I(dset_id, "H5Dcreate2"); /* Close the dataset and both files to make sure everything gets flushed @@ -3285,7 +3277,6 @@ verify_dset_create_and_open_through_extlink_with_sohm(hid_t src_fcpl_id, hid_t d CHECK_I(ret, "H5Fclose"); } /* verify_dset_create_and_open_through_extlink_with_sohm */ - /*------------------------------------------------------------------------- * Function: test_sohm_extlink * @@ -3302,7 +3293,7 @@ verify_dset_create_and_open_through_extlink_with_sohm(hid_t src_fcpl_id, hid_t d static void test_sohm_extlink(void) { - hid_t fcpl_id = -1; + hid_t fcpl_id = -1; herr_t ret; MESSAGE(5, ("Testing SOHM creation through external links\n")); @@ -3322,7 +3313,6 @@ test_sohm_extlink(void) CHECK_I(ret, "H5Pclose"); } /* test_sohm_extlink */ - /*------------------------------------------------------------------------- * Function: verify_dataset_extension * @@ -3342,19 +3332,19 @@ test_sohm_extlink(void) static int verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) { - hid_t file_id = H5I_INVALID_HID; - hid_t orig_space_id = H5I_INVALID_HID; - hid_t space1_id, space2_id, space3_id; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t dset1_id, dset2_id = H5I_INVALID_HID, dset3_id = H5I_INVALID_HID; - hsize_t dims1[] = {1, 2}; + hid_t file_id = H5I_INVALID_HID; + hid_t orig_space_id = H5I_INVALID_HID; + hid_t space1_id, space2_id, space3_id; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dset1_id, dset2_id = H5I_INVALID_HID, dset3_id = H5I_INVALID_HID; + hsize_t dims1[] = {1, 2}; hsize_t max_dims[] = {H5S_UNLIMITED, 2}; - hsize_t dims2[] = {5, 2}; + hsize_t dims2[] = {5, 2}; hsize_t out_dims[2]; hsize_t out_maxdims[2]; - int x; - int old_nerrs; /* Number of errors when entering this routine */ - herr_t ret; + int x; + int old_nerrs; /* Number of errors when entering this routine */ + herr_t ret; hsize_t *space_dims[3]; @@ -3368,42 +3358,42 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) * 2018 November 5 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#define TSOHM_VDE_VERIFY_SPACES(dims) \ -{ \ - /* Open dataspaces \ - */ \ - space1_id = H5Dget_space(dset1_id); \ - CHECK_I(space1_id, "H5Dget_space"); \ - space2_id = H5Dget_space(dset2_id); \ - CHECK_I(space2_id, "H5Dget_space"); \ - space3_id = H5Dget_space(dset3_id); \ - CHECK_I(space3_id, "H5Dget_space"); \ - /* Verify dataspaces \ - */ \ - ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims); \ - CHECK_I(ret, "H5Sget_simple_extent_dims"); \ - for(x=0; x 1) \ - CHECK_I(H5Dclose(dset2_id), "H5Dclose"); \ - if ((n) > 2) \ - CHECK_I(H5Dclose(dset3_id), "H5Dclose"); \ - CHECK_I(H5Fclose(file_id), "H5Fclose"); \ - \ - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); \ - CHECK_I(file_id, "H5Fopen"); \ - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); \ - CHECK_I(dset1_id, "H5Dopen2"); \ - if ((n) > 1) { \ - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); \ - CHECK_I(dset2_id, "H5Dopen2"); \ - } \ - if ((n) > 2) { \ - dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); \ - CHECK_I(dset3_id, "H5Dopen2"); \ - } \ -} /* define TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS */ +#define TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(n) \ + { \ + CHECK_I(H5Dclose(dset1_id), "H5Dclose"); \ + if ((n) > 1) \ + CHECK_I(H5Dclose(dset2_id), "H5Dclose"); \ + if ((n) > 2) \ + CHECK_I(H5Dclose(dset3_id), "H5Dclose"); \ + CHECK_I(H5Fclose(file_id), "H5Fclose"); \ + \ + file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); \ + CHECK_I(file_id, "H5Fopen"); \ + dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); \ + CHECK_I(dset1_id, "H5Dopen2"); \ + if ((n) > 1) { \ + dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); \ + CHECK_I(dset2_id, "H5Dopen2"); \ + } \ + if ((n) > 2) { \ + dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); \ + CHECK_I(dset3_id, "H5Dopen2"); \ + } \ + } /* define TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS */ /* Remember the current # of reported errors */ old_nerrs = GetTestNumErrs(); @@ -3457,19 +3447,22 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) /* Create a dataspace and a dataset*/ orig_space_id = H5Screate_simple(EXTEND_NDIMS, dims1, max_dims); CHECK_I(orig_space_id, "H5Screate_simple"); - dset1_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset1_id = + H5Dcreate2(file_id, "dataset", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset1_id, "H5Dcreate2"); - if(close_reopen) + if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(1); /* Create another dataset starting with the same dataspace */ - dset2_id = H5Dcreate2(file_id, "dataset2", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset2_id = + H5Dcreate2(file_id, "dataset2", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset2_id, "H5Dcreate2"); if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(2); /* Create a third dataset with the same dataspace */ - dset3_id = H5Dcreate2(file_id, "dataset3", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset3_id = + H5Dcreate2(file_id, "dataset3", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset3_id, "H5Dcreate2"); if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); @@ -3488,7 +3481,7 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) /* Extend the second dataset */ ret = H5Dset_extent(dset2_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) + if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); space_dims[1] = dims2; @@ -3497,7 +3490,7 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) /* Extend the third dataset */ ret = H5Dset_extent(dset3_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) + if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); space_dims[2] = dims2; @@ -3513,15 +3506,14 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) ret = H5Fclose(file_id); CHECK_I(ret, "H5Fclose"); - - /* Change the order in which datasets are extended to ensure that there * are no problems if a dataspace goes from being shared to not being * shared or vice versa. */ file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); CHECK_I(file_id, "H5Fcreate"); - dset1_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset1_id = + H5Dcreate2(file_id, "dataset", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset1_id, "H5Dcreate2"); if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(1); @@ -3535,7 +3527,8 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) /* Create the second dataset. Its dataspace will be unshared and then * become shared when extended. */ - dset2_id = H5Dcreate2(file_id, "dataset2", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset2_id = + H5Dcreate2(file_id, "dataset2", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset2_id, "H5Dcreate2"); if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(2); @@ -3549,15 +3542,16 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) /* Create the third dataset. Its dataspace will be unshared and then * become shared when extended. */ - dset3_id = H5Dcreate2(file_id, "dataset3", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset3_id = + H5Dcreate2(file_id, "dataset3", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset3_id, "H5Dcreate2"); - if(close_reopen) + if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); /* Extend the third dataset */ ret = H5Dset_extent(dset3_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) + if (close_reopen) TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); TSOHM_VDE_VERIFY_SPACES(space_dims); @@ -3579,16 +3573,15 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) CHECK_I(ret, "H5Pclose"); /* Complain if this test generated errors */ - if(old_nerrs == GetTestNumErrs()) - return(0); + if (old_nerrs == GetTestNumErrs()) + return (0); else - return(-1); + return (-1); /* macros are exclusive to this function */ #undef TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS #undef TSOHM_VDE_VERIFY_SPACES } /* verify_dataset_extension */ - /*------------------------------------------------------------------------- * Function: test_sohm_extend_dset * @@ -3606,7 +3599,7 @@ verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) static void test_sohm_extend_dset(void) { - hid_t fcpl_id = -1; + hid_t fcpl_id = -1; herr_t ret; MESSAGE(5, ("Testing extending shared dataspaces\n")); @@ -3622,7 +3615,6 @@ test_sohm_extend_dset(void) ret = verify_dataset_extension(fcpl_id, TRUE); CHECK_I(ret, "verify_dataset_extension"); - /* Only dataspaces */ ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG, 16); CHECK_I(ret, "H5Pset_shared_mesg_index"); @@ -3641,7 +3633,6 @@ test_sohm_extend_dset(void) ret = verify_dataset_extension(fcpl_id, TRUE); CHECK_I(ret, "verify_dataset_extension"); - /* All messages in lists */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 100, 50); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -3651,7 +3642,6 @@ test_sohm_extend_dset(void) ret = verify_dataset_extension(fcpl_id, TRUE); CHECK_I(ret, "verify_dataset_extension"); - /* All messages in lists converted to B-trees */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 1, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -3661,7 +3651,6 @@ test_sohm_extend_dset(void) ret = verify_dataset_extension(fcpl_id, TRUE); CHECK_I(ret, "verify_dataset_extension"); - /* All messages in B-trees */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -3675,7 +3664,6 @@ test_sohm_extend_dset(void) CHECK_I(ret, "H5Pclose"); } /* test_sohm_extend_dset */ - /*------------------------------------------------------------------------- * Function: test_sohm_external_dtype * @@ -3697,15 +3685,15 @@ test_sohm_external_dtype(void) int a; int b; } s1_t; - s1_t *s_ptr, *orig; - hid_t fcpl, file1, file2; - hid_t dataset1, dataset2; - hid_t s1_tid, dset1_tid, dset2_tid, space; - hsize_t dims[2] = {NX, NY}; + s1_t * s_ptr, *orig; + hid_t fcpl, file1, file2; + hid_t dataset1, dataset2; + hid_t s1_tid, dset1_tid, dset2_tid, space; + hsize_t dims[2] = {NX, NY}; H5T_class_t dtype_class; - size_t dmsg_count; - unsigned x, i; - herr_t ret; + size_t dmsg_count; + unsigned x, i; + herr_t ret; MESSAGE(5, ("Testing shared external datatype\n")); @@ -3713,7 +3701,7 @@ test_sohm_external_dtype(void) CHECK_I(fcpl, "H5Pcreate"); ret = H5Pset_shared_mesg_nindexes(fcpl, TEST_NUM_INDEXES); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - for(x=0; xa = (int)(i * 3 + 1); s_ptr->b = (int)(i * 3 + 2); } @@ -3775,8 +3762,7 @@ test_sohm_external_dtype(void) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(dmsg_count, 0, "H5F__get_sohm_mesg_count_test"); - dataset2 = H5Dcreate2(file2, "dataset_2", dset1_tid, space, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + dataset2 = H5Dcreate2(file2, "dataset_2", dset1_tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK_I(dataset2, "H5Dcreate2"); /* Check on datatype storage status. It should be 1 now. */ @@ -3821,7 +3807,6 @@ test_sohm_external_dtype(void) HDfree(orig); } /* test_sohm_external_dtype */ - /**************************************************************** ** ** test_sohm(): Main Shared Object Header Message testing routine. @@ -3832,27 +3817,26 @@ test_sohm(void) { MESSAGE(5, ("Testing Shared Object Header Messages\n")); - test_sohm_fcpl(); /* Test SOHMs and file creation plists */ - test_sohm_fcpl_errors(); /* Bogus H5P* calls for SOHMs */ - test_sohm_size1(); /* Tests the sizes of files with one SOHM */ -#if 0 /* TODO: REVEALS BUG TO BE FIXED - SEE JIRA HDFFV-10645 */ + test_sohm_fcpl(); /* Test SOHMs and file creation plists */ + test_sohm_fcpl_errors(); /* Bogus H5P* calls for SOHMs */ + test_sohm_size1(); /* Tests the sizes of files with one SOHM */ +#if 0 /* TODO: REVEALS BUG TO BE FIXED - SEE JIRA HDFFV-10645 */ test_sohm_size_consistency_open_create(); -#endif /* Jira HDFFV-10645 */ - test_sohm_attrs(); /* Tests shared messages in attributes */ - test_sohm_size2(0); /* Tests the sizes of files with multiple SOHMs */ - test_sohm_size2(1); /* Tests the sizes of files with multiple - * SOHMs, closing and reopening file after - * each write. */ - test_sohm_delete(); /* Test deleting shared messages */ - test_sohm_delete_revert(); /* Test that a file with SOHMs becomes an - * empty file again when they are deleted. */ - test_sohm_extlink(); /* Test SOHMs when external links are used */ +#endif /* Jira HDFFV-10645 */ + test_sohm_attrs(); /* Tests shared messages in attributes */ + test_sohm_size2(0); /* Tests the sizes of files with multiple SOHMs */ + test_sohm_size2(1); /* Tests the sizes of files with multiple + * SOHMs, closing and reopening file after + * each write. */ + test_sohm_delete(); /* Test deleting shared messages */ + test_sohm_delete_revert(); /* Test that a file with SOHMs becomes an + * empty file again when they are deleted. */ + test_sohm_extlink(); /* Test SOHMs when external links are used */ test_sohm_extend_dset(); /* Test extending shared datasets */ test_sohm_external_dtype(); /* Test using datatype in another file */ } /* test_sohm */ - /*------------------------------------------------------------------------- * Function: cleanup_sohm * @@ -3874,4 +3858,3 @@ cleanup_sohm(void) HDremove(FILENAME_SRC); HDremove(FILENAME_DST); } /* cleanup_sohm */ - diff --git a/test/ttime.c b/test/ttime.c index 5b3436d..63906ff 100644 --- a/test/ttime.c +++ b/test/ttime.c @@ -12,18 +12,18 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: ttime -* -* Test the Time Datatype functionality -* -*************************************************************/ + * + * Test program: ttime + * + * Test the Time Datatype functionality + * + *************************************************************/ #include "testhdf5.h" -#define DATAFILE "ttime.h5" +#define DATAFILE "ttime.h5" #ifdef NOT_YET -#define DATASETNAME "Dataset" +#define DATASETNAME "Dataset" #endif /* NOT_YET */ /**************************************************************** @@ -34,8 +34,8 @@ static void test_time_commit(void) { - hid_t file_id, tid; /* identifiers */ - herr_t status; + hid_t file_id, tid; /* identifiers */ + herr_t status; /* Output message about test being performed */ MESSAGE(5, ("Testing Committing Time Datatypes\n")); @@ -44,32 +44,32 @@ test_time_commit(void) file_id = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file_id, FAIL, "H5Fcreate"); - tid = H5Tcopy (H5T_UNIX_D32LE); + tid = H5Tcopy(H5T_UNIX_D32LE); CHECK(tid, FAIL, "H5Tcopy"); status = H5Tcommit2(file_id, "Committed D32LE type", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(status, FAIL, "H5Tcommit2"); - status = H5Tclose (tid); + status = H5Tclose(tid); CHECK(status, FAIL, "H5Tclose"); - tid = H5Tcopy (H5T_UNIX_D32BE); + tid = H5Tcopy(H5T_UNIX_D32BE); CHECK(tid, FAIL, "H5Tcopy"); status = H5Tcommit2(file_id, "Committed D32BE type", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(status, FAIL, "H5Tcommit2"); - status = H5Tclose (tid); + status = H5Tclose(tid); CHECK(status, FAIL, "H5Tclose"); - tid = H5Tcopy (H5T_UNIX_D64LE); + tid = H5Tcopy(H5T_UNIX_D64LE); CHECK(tid, FAIL, "H5Tcopy"); status = H5Tcommit2(file_id, "Committed D64LE type", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(status, FAIL, "H5Tcommit2"); - status = H5Tclose (tid); + status = H5Tclose(tid); CHECK(status, FAIL, "H5Tclose"); - tid = H5Tcopy (H5T_UNIX_D64BE); + tid = H5Tcopy(H5T_UNIX_D64BE); CHECK(tid, FAIL, "H5Tcopy"); status = H5Tcommit2(file_id, "Committed D64BE type", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(status, FAIL, "H5Tcommit2"); - status = H5Tclose (tid); + status = H5Tclose(tid); CHECK(status, FAIL, "H5Tclose"); /* Close the file. */ @@ -82,42 +82,41 @@ test_time_commit(void) tid = H5Topen2(file_id, "Committed D32LE type", H5P_DEFAULT); CHECK(tid, FAIL, "H5Topen2"); - if(!H5Tequal(tid, H5T_UNIX_D32LE)) + if (!H5Tequal(tid, H5T_UNIX_D32LE)) TestErrPrintf("H5T_UNIX_D32LE datatype not found\n"); - status = H5Tclose (tid); + status = H5Tclose(tid); CHECK(status, FAIL, "H5Tclose"); tid = H5Topen2(file_id, "Committed D32BE type", H5P_DEFAULT); CHECK(tid, FAIL, "H5Topen2"); - if(!H5Tequal(tid, H5T_UNIX_D32BE)) + if (!H5Tequal(tid, H5T_UNIX_D32BE)) TestErrPrintf("H5T_UNIX_D32BE datatype not found\n"); - status = H5Tclose (tid); + status = H5Tclose(tid); CHECK(status, FAIL, "H5Tclose"); tid = H5Topen2(file_id, "Committed D64LE type", H5P_DEFAULT); CHECK(tid, FAIL, "H5Topen2"); - if(!H5Tequal(tid, H5T_UNIX_D64LE)) + if (!H5Tequal(tid, H5T_UNIX_D64LE)) TestErrPrintf("H5T_UNIX_D64LE datatype not found"); - status = H5Tclose (tid); + status = H5Tclose(tid); CHECK(status, FAIL, "H5Tclose"); tid = H5Topen2(file_id, "Committed D64BE type", H5P_DEFAULT); CHECK(tid, FAIL, "H5Topen2"); - if(!H5Tequal(tid, H5T_UNIX_D64BE)) + if (!H5Tequal(tid, H5T_UNIX_D64BE)) TestErrPrintf("H5T_UNIX_D64BE datatype not found"); - status = H5Tclose (tid); + status = H5Tclose(tid); CHECK(status, FAIL, "H5Tclose"); status = H5Fclose(file_id); CHECK(status, FAIL, "H5Fclose"); - } #ifdef NOT_YET @@ -129,12 +128,12 @@ test_time_commit(void) static void test_time_io(void) { - hid_t fid; /* File identifier */ - hid_t dsid; /* Dataset identifier */ - hid_t tid; /* Datatype identifier */ - hid_t sid; /* Dataspace identifier */ - time_t timenow, timethen; /* Times */ - herr_t status; + hid_t fid; /* File identifier */ + hid_t dsid; /* Dataset identifier */ + hid_t tid; /* Datatype identifier */ + hid_t sid; /* Dataspace identifier */ + time_t timenow, timethen; /* Times */ + herr_t status; /* Output message about test being performed */ MESSAGE(5, ("Testing Committing Time Datatypes\n")); @@ -155,7 +154,7 @@ test_time_io(void) timenow = HDtime(NULL); /* Write time to dataset */ - status = H5Dwrite (dsid, H5T_UNIX_D32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &timenow); + status = H5Dwrite(dsid, H5T_UNIX_D32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &timenow); CHECK(status, FAIL, "H5Dwrite"); /* Close objects */ @@ -165,7 +164,7 @@ test_time_io(void) status = H5Sclose(sid); CHECK(status, FAIL, "H5Sclose"); - status = H5Fclose (fid); + status = H5Fclose(fid); CHECK(status, FAIL, "H5Fclose"); /* Open file and dataset, read time back and print it in calendar format */ @@ -175,23 +174,22 @@ test_time_io(void) dsid = H5Dopen2(fid, DATASETNAME, H5P_DEFAULT); CHECK(dsid, FAIL, "H5Dopen2"); -tid = H5Dget_type(dsid); -CHECK(tid, FAIL, "H5Dget_type"); -if( H5Tget_class (tid) == H5T_TIME) - HDfprintf(stderr,"datatype class is H5T_TIME\n"); -status = H5Tclose (tid); -CHECK(status, FAIL, "H5Tclose"); + tid = H5Dget_type(dsid); + CHECK(tid, FAIL, "H5Dget_type"); + if (H5Tget_class(tid) == H5T_TIME) + HDfprintf(stderr, "datatype class is H5T_TIME\n"); + status = H5Tclose(tid); + CHECK(status, FAIL, "H5Tclose"); - status = H5Dread (dsid, H5T_UNIX_D32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &timethen); + status = H5Dread(dsid, H5T_UNIX_D32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &timethen); CHECK(status, FAIL, "H5Dread"); -HDfprintf(stderr,"time written was: %s\n", HDctime(&timethen)); + HDfprintf(stderr, "time written was: %s\n", HDctime(&timethen)); status = H5Dclose(dsid); CHECK(status, FAIL, "H5Dclose"); status = H5Fclose(fid); CHECK(status, FAIL, "H5Fclose"); - } #endif /* NOT_YET */ @@ -206,13 +204,12 @@ test_time(void) /* Output message about test being performed */ MESSAGE(5, ("Testing Time Datatypes\n")); - test_time_commit(); /* Test committing time datatypes to a file */ + test_time_commit(); /* Test committing time datatypes to a file */ #ifdef NOT_YET - test_time_io(); /* Test writing time data to a dataset */ -#endif /* NOT_YET */ - -} /* test_time() */ + test_time_io(); /* Test writing time data to a dataset */ +#endif /* NOT_YET */ +} /* test_time() */ /*------------------------------------------------------------------------- * Function: cleanup_time @@ -233,4 +230,3 @@ cleanup_time(void) { HDremove(DATAFILE); } - diff --git a/test/ttsafe.c b/test/ttsafe.c index 2de460b..d2085b9 100644 --- a/test/ttsafe.c +++ b/test/ttsafe.c @@ -32,9 +32,8 @@ /* ANY new test needs to have a prototype in ttsafe.h */ #include "ttsafe.h" - #define MAX_NUM_NAME 1000 -#define NAME_OFFSET 6 /* offset for "name" */ +#define NAME_OFFSET 6 /* offset for "name" */ /* pre-condition: num must be a non-negative number */ H5_ATTR_PURE static unsigned @@ -42,10 +41,10 @@ num_digits(int num) { unsigned u; - if(num == 0) + if (num == 0) return 1; - for(u = 0; num > 0; u++) + for (u = 0; num > 0; u++) num = num / 10; return u; @@ -59,43 +58,45 @@ tts_is_threadsafe(void) hbool_t should_be; #ifdef H5_HAVE_THREADSAFE - is_ts = FALSE; + is_ts = FALSE; should_be = TRUE; -#else /* H5_HAVE_THREADSAFE */ - is_ts = TRUE; +#else /* H5_HAVE_THREADSAFE */ + is_ts = TRUE; should_be = FALSE; #endif /* H5_HAVE_THREADSAFE */ - if(H5is_library_threadsafe(&is_ts) != SUCCEED) - TestErrPrintf("H5_is_library_threadsafe() call failed - test failed\n"); + if (H5is_library_threadsafe(&is_ts) != SUCCEED) + TestErrPrintf("H5_is_library_threadsafe() call failed - test failed\n"); - if(is_ts != should_be) - TestErrPrintf("Thread-safety value incorrect - test failed\n"); + if (is_ts != should_be) + TestErrPrintf("Thread-safety value incorrect - test failed\n"); return; } /* Routine to generate attribute names for numeric values */ -char *gen_name(int value) +char * +gen_name(int value) { - char *temp; + char * temp; unsigned length; - int i; + int i; - length = num_digits(MAX_NUM_NAME - 1); - temp = (char *)HDmalloc(NAME_OFFSET + length + 1); - temp = HDstrcpy(temp, "attrib"); + length = num_digits(MAX_NUM_NAME - 1); + temp = (char *)HDmalloc(NAME_OFFSET + length + 1); + temp = HDstrcpy(temp, "attrib"); temp[NAME_OFFSET + length] = '\0'; for (i = (int)(length - 1); i >= 0; i--) { temp[NAME_OFFSET + i] = (char)((int)'0' + value % 10); - value = value / 10; + value = value / 10; } return temp; } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { /* Initialize testing framework */ @@ -123,7 +124,7 @@ int main(int argc, char *argv[]) TestInfo(argv[0]); /* Parse command line arguments */ - TestParseCmdLine(argc,argv); + TestParseCmdLine(argc, argv); /* Perform requested testing */ PerformTests(); @@ -142,4 +143,3 @@ int main(int argc, char *argv[]) return GetTestNumErrs(); } /* end main() */ - diff --git a/test/ttsafe.h b/test/ttsafe.h index f1cbe4d..e48d121 100644 --- a/test/ttsafe.h +++ b/test/ttsafe.h @@ -24,26 +24,24 @@ */ #include "testhdf5.h" - /* Prototypes for the support routines */ -extern char* gen_name(int); +extern char *gen_name(int); /* Prototypes for the test routines */ -void tts_is_threadsafe(void); +void tts_is_threadsafe(void); #ifdef H5_HAVE_THREADSAFE -void tts_dcreate(void); -void tts_error(void); -void tts_cancel(void); -void tts_acreate(void); -void tts_attr_vlen(void); +void tts_dcreate(void); +void tts_error(void); +void tts_cancel(void); +void tts_acreate(void); +void tts_attr_vlen(void); /* Prototypes for the cleanup routines */ -void cleanup_dcreate(void); -void cleanup_error(void); -void cleanup_cancel(void); -void cleanup_acreate(void); -void cleanup_attr_vlen(void); +void cleanup_dcreate(void); +void cleanup_error(void); +void cleanup_cancel(void); +void cleanup_acreate(void); +void cleanup_attr_vlen(void); #endif /* H5_HAVE_THREADSAFE */ #endif /* TTSAFE_H */ - diff --git a/test/ttsafe_acreate.c b/test/ttsafe_acreate.c index 5c08d09..58e8d9d 100644 --- a/test/ttsafe_acreate.c +++ b/test/ttsafe_acreate.c @@ -35,17 +35,17 @@ #ifdef H5_HAVE_THREADSAFE -#define FILENAME "ttsafe_acreate.h5" -#define DATASETNAME "IntData" -#define NUM_THREADS 16 +#define FILENAME "ttsafe_acreate.h5" +#define DATASETNAME "IntData" +#define NUM_THREADS 16 void *tts_acreate_thread(void *); typedef struct acreate_data_struct { - hid_t dataset; - hid_t datatype; - hid_t dataspace; - int current_index; + hid_t dataset; + hid_t datatype; + hid_t dataspace; + int current_index; } ttsafe_name_data_t; void @@ -55,17 +55,17 @@ tts_acreate(void) H5TS_thread_t threads[NUM_THREADS]; /* HDF5 data declarations */ - hid_t file = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - hid_t dataspace = H5I_INVALID_HID; - hid_t datatype = H5I_INVALID_HID; - hid_t attribute = H5I_INVALID_HID; - hsize_t dimsf[1]; /* dataset dimensions */ + hid_t file = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t dataspace = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t attribute = H5I_INVALID_HID; + hsize_t dimsf[1]; /* dataset dimensions */ /* data declarations */ - int data; /* data to write */ - int buffer, i; - herr_t status; + int data; /* data to write */ + int buffer, i; + herr_t status; ttsafe_name_data_t *attrib_data; @@ -77,7 +77,7 @@ tts_acreate(void) CHECK(file, H5I_INVALID_HID, "H5Fcreate"); /* create a simple dataspace for the dataset */ - dimsf[0] = 1; + dimsf[0] = 1; dataspace = H5Screate_simple(1, dimsf, NULL); CHECK(dataspace, H5I_INVALID_HID, "H5Screate_simple"); @@ -92,7 +92,7 @@ tts_acreate(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); /* initialize data for dataset and write value to dataset */ - data = NUM_THREADS; + data = NUM_THREADS; status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data); CHECK(status, FAIL, "H5Dwrite"); @@ -100,24 +100,24 @@ tts_acreate(void) * Simultaneously create a large number of attributes to be associated * with the dataset */ - for(i = 0; i < NUM_THREADS; i++) { - attrib_data = (ttsafe_name_data_t *)HDmalloc(sizeof(ttsafe_name_data_t)); - attrib_data->dataset = dataset; - attrib_data->datatype = datatype; - attrib_data->dataspace = dataspace; + for (i = 0; i < NUM_THREADS; i++) { + attrib_data = (ttsafe_name_data_t *)HDmalloc(sizeof(ttsafe_name_data_t)); + attrib_data->dataset = dataset; + attrib_data->datatype = datatype; + attrib_data->dataspace = dataspace; attrib_data->current_index = i; - threads[i] = H5TS_create_thread(tts_acreate_thread, NULL, attrib_data); + threads[i] = H5TS_create_thread(tts_acreate_thread, NULL, attrib_data); } - for(i = 0; i < NUM_THREADS; i++) + for (i = 0; i < NUM_THREADS; i++) H5TS_wait_for_thread(threads[i]); /* verify the correctness of the test */ - for(i = 0; i < NUM_THREADS; i++) { + for (i = 0; i < NUM_THREADS; i++) { attribute = H5Aopen(dataset, gen_name(i), H5P_DEFAULT); CHECK(attribute, H5I_INVALID_HID, "H5Aopen"); - if(attribute < 0) + if (attribute < 0) TestErrPrintf("unable to open appropriate attribute. Test failed!\n"); else { status = H5Aread(attribute, H5T_NATIVE_INT, &buffer); @@ -143,10 +143,10 @@ tts_acreate(void) void * tts_acreate_thread(void *client_data) { - hid_t attribute = H5I_INVALID_HID; - char *attribute_name; - int *attribute_data; /* data for attributes */ - herr_t status; + hid_t attribute = H5I_INVALID_HID; + char * attribute_name; + int * attribute_data; /* data for attributes */ + herr_t status; ttsafe_name_data_t *attrib_data; @@ -154,15 +154,14 @@ tts_acreate_thread(void *client_data) /* Create attribute */ attribute_name = gen_name(attrib_data->current_index); - attribute = H5Acreate2(attrib_data->dataset, attribute_name, - attrib_data->datatype, attrib_data->dataspace, - H5P_DEFAULT, H5P_DEFAULT); + attribute = H5Acreate2(attrib_data->dataset, attribute_name, attrib_data->datatype, + attrib_data->dataspace, H5P_DEFAULT, H5P_DEFAULT); CHECK(attribute, H5I_INVALID_HID, "H5Acreate2"); /* Write data to the attribute */ - attribute_data = (int *)HDmalloc(sizeof(int)); + attribute_data = (int *)HDmalloc(sizeof(int)); *attribute_data = attrib_data->current_index; - status = H5Awrite(attribute, H5T_NATIVE_INT, attribute_data); + status = H5Awrite(attribute, H5T_NATIVE_INT, attribute_data); CHECK(status, FAIL, "H5Awrite"); status = H5Aclose(attribute); CHECK(status, FAIL, "H5Aclose"); @@ -176,4 +175,3 @@ cleanup_acreate(void) } #endif /*H5_HAVE_THREADSAFE*/ - diff --git a/test/ttsafe_attr_vlen.c b/test/ttsafe_attr_vlen.c index b07e362..e2aa5a0 100644 --- a/test/ttsafe_attr_vlen.c +++ b/test/ttsafe_attr_vlen.c @@ -16,7 +16,7 @@ * Testing for thread safety in H5A library operations. * ------------------------------------------------------------------ * - * Purpose: Verify that the segmentation fault described in HDFFV-11080 + * Purpose: Verify that the segmentation fault described in HDFFV-11080 * is fixed. * * This test simulates what the user did to trigger the error: @@ -30,13 +30,13 @@ * --Open the test file * --Open and read the attribute for each opened file * - * The cause of the problem in this jira issue is due to the file pointer - * that is set in the variable length string datatype for the attribute. - * That file pointer is already closed and therefore needs to be set to + * The cause of the problem in this jira issue is due to the file pointer + * that is set in the variable length string datatype for the attribute. + * That file pointer is already closed and therefore needs to be set to * the current opened file pointer when the attribute is accessed. * Similar patch up was done before when reading dataset in H5D__read() * in src/H5Aint.c. - * Hopefully this kind of patch can go away when we resolve the + * Hopefully this kind of patch can go away when we resolve the * shared file pointer issue. * ********************************************************************/ @@ -45,24 +45,24 @@ #ifdef H5_HAVE_THREADSAFE -#define FILENAME "ttsafe_attr_vlen.h5" +#define FILENAME "ttsafe_attr_vlen.h5" #define ATTR_NAME "root_attr" -#define NUM_THREADS 32 +#define NUM_THREADS 32 void *tts_attr_vlen_thread(void *); void tts_attr_vlen(void) { - pthread_t threads[NUM_THREADS] = {0}; /* Thread declaration */ - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - hid_t atid = H5I_INVALID_HID; /* Datatype ID for attribute */ - hid_t asid = H5I_INVALID_HID; /* Dataspace ID for attribute */ - hid_t aid = H5I_INVALID_HID; /* The attribute ID */ - char *string_attr = "2.0"; /* The attribute data */ - int ret; /* Return value */ - int i; /* Local index variable */ + pthread_t threads[NUM_THREADS] = {0}; /* Thread declaration */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t atid = H5I_INVALID_HID; /* Datatype ID for attribute */ + hid_t asid = H5I_INVALID_HID; /* Dataspace ID for attribute */ + hid_t aid = H5I_INVALID_HID; /* The attribute ID */ + char * string_attr = "2.0"; /* The attribute data */ + int ret; /* Return value */ + int i; /* Local index variable */ /* Create the HDF5 test file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -106,11 +106,11 @@ tts_attr_vlen(void) CHECK(ret, H5I_INVALID_HID, "H5Tclose"); /* Start multiple threads and execute tts_attr_vlen_thread() for each thread */ - for(i = 0; i < NUM_THREADS; i++) + for (i = 0; i < NUM_THREADS; i++) pthread_create(&threads[i], NULL, tts_attr_vlen_thread, NULL); /* Wait for the threads to end */ - for(i = 0; i < NUM_THREADS; i++) + for (i = 0; i < NUM_THREADS; i++) pthread_join(threads[i], NULL); } /* end tts_attr_vlen() */ @@ -119,13 +119,13 @@ tts_attr_vlen(void) void * tts_attr_vlen_thread(void *client_data) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - hid_t aid = H5I_INVALID_HID; /* Attribute ID */ - hid_t atid = H5I_INVALID_HID; /* Datatype ID for the attribute */ - char *string_attr_check; /* The attribute data being read */ - char *string_attr = "2.0"; /* The expected attribute data */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t atid = H5I_INVALID_HID; /* Datatype ID for the attribute */ + char * string_attr_check; /* The attribute data being read */ + char * string_attr = "2.0"; /* The expected attribute data */ + herr_t ret; /* Return value */ /* Open the test file */ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -146,10 +146,10 @@ tts_attr_vlen_thread(void *client_data) /* Read the attribute */ ret = H5Aread(aid, atid, &string_attr_check); CHECK(ret, FAIL, "H5Aclose"); - + /* Verify the attribute data is as expected */ VERIFY_STR(string_attr_check, string_attr, "H5Aread"); - + /* Close IDs */ ret = H5Aclose(aid); CHECK(ret, FAIL, "H5Aclose"); @@ -173,4 +173,3 @@ cleanup_attr_vlen(void) } #endif /*H5_HAVE_THREADSAFE*/ - diff --git a/test/ttsafe_cancel.c b/test/ttsafe_cancel.c index f6bcd0d..1e40c58 100644 --- a/test/ttsafe_cancel.c +++ b/test/ttsafe_cancel.c @@ -36,92 +36,91 @@ #ifdef H5_HAVE_THREADSAFE #ifndef H5_HAVE_WIN_THREADS -#define FILENAME "ttsafe_cancel.h5" -#define DATASETNAME "commonname" +#define FILENAME "ttsafe_cancel.h5" +#define DATASETNAME "commonname" -void *tts_cancel_thread(void *); -void tts_cancel_barrier(void); -herr_t tts_cancel_callback(void *, hid_t, unsigned , const hsize_t *, void *); -void cancellation_cleanup(void *); +void * tts_cancel_thread(void *); +void tts_cancel_barrier(void); +herr_t tts_cancel_callback(void *, hid_t, unsigned, const hsize_t *, void *); +void cancellation_cleanup(void *); hid_t cancel_file; typedef struct cleanup_struct { - hid_t dataset; - hid_t datatype; - hid_t dataspace; + hid_t dataset; + hid_t datatype; + hid_t dataspace; } cancel_cleanup_t; -pthread_t childthread; +pthread_t childthread; pthread_mutex_t mutex; -pthread_cond_t cond; +pthread_cond_t cond; void tts_cancel(void) { - pthread_attr_t attribute; - hid_t dataset; - int buffer; + pthread_attr_t attribute; + hid_t dataset; + int buffer; int H5_ATTR_NDEBUG_UNUSED ret; /* make thread scheduling global */ - ret=pthread_attr_init(&attribute); - assert(ret==0); + ret = pthread_attr_init(&attribute); + assert(ret == 0); #ifdef H5_HAVE_SYSTEM_SCOPE_THREADS - ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM); - assert(ret==0); + ret = pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM); + assert(ret == 0); #endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */ - /* Initialize mutex & condition variables */ - ret=pthread_mutex_init(&mutex,NULL); - assert(ret==0); - ret=pthread_cond_init(&cond,NULL); - assert(ret==0); + ret = pthread_mutex_init(&mutex, NULL); + assert(ret == 0); + ret = pthread_cond_init(&cond, NULL); + assert(ret == 0); /* * Create a hdf5 file using H5F_ACC_TRUNC access, default file * creation plist and default file access plist */ cancel_file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - assert(cancel_file>=0); - ret=pthread_create(&childthread, &attribute, tts_cancel_thread, NULL); - assert(ret==0); + assert(cancel_file >= 0); + ret = pthread_create(&childthread, &attribute, tts_cancel_thread, NULL); + assert(ret == 0); tts_cancel_barrier(); - ret=pthread_cancel(childthread); - assert(ret==0); + ret = pthread_cancel(childthread); + assert(ret == 0); dataset = H5Dopen2(cancel_file, DATASETNAME, H5P_DEFAULT); - assert(dataset>=0); - ret=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buffer); - assert(ret>=0); + assert(dataset >= 0); + ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buffer); + assert(ret >= 0); if (buffer != 11) TestErrPrintf("operation unsuccessful with value at %d instead of 11\n", buffer); - ret=H5Dclose(dataset); - assert(ret>=0); - ret=H5Fclose(cancel_file); - assert(ret>=0); + ret = H5Dclose(dataset); + assert(ret >= 0); + ret = H5Fclose(cancel_file); + assert(ret >= 0); /* Destroy the thread attribute */ - ret=pthread_attr_destroy(&attribute); - assert(ret==0); + ret = pthread_attr_destroy(&attribute); + assert(ret == 0); } /* end tts_cancel() */ void * tts_cancel_thread(void H5_ATTR_UNUSED *arg) { - hid_t dataspace = H5I_INVALID_HID; - hid_t datatype = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - int datavalue; - int buffer; - hsize_t dimsf[1]; /* dataset dimensions */ + hid_t dataspace = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + int datavalue; + int buffer; + hsize_t dimsf[1]; /* dataset dimensions */ cancel_cleanup_t *cleanup_structure; - herr_t status; + herr_t status; /* define dataspace for dataset */ - dimsf[0] = 1; + dimsf[0] = 1; dataspace = H5Screate_simple(1, dimsf, NULL); CHECK(dataspace, H5I_INVALID_HID, "H5Screate_simple"); @@ -132,19 +131,19 @@ tts_cancel_thread(void H5_ATTR_UNUSED *arg) CHECK(status, FAIL, "H5Tset_order"); /* create a new dataset within the file */ - dataset = H5Dcreate2(cancel_file, DATASETNAME, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = + H5Dcreate2(cancel_file, DATASETNAME, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); /* If thread is cancelled, make cleanup call */ - cleanup_structure = (cancel_cleanup_t*)HDmalloc(sizeof(cancel_cleanup_t)); - cleanup_structure->dataset = dataset; - cleanup_structure->datatype = datatype; + cleanup_structure = (cancel_cleanup_t *)HDmalloc(sizeof(cancel_cleanup_t)); + cleanup_structure->dataset = dataset; + cleanup_structure->datatype = datatype; cleanup_structure->dataspace = dataspace; pthread_cleanup_push(cancellation_cleanup, cleanup_structure); - datavalue = 1; - status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue); + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue); CHECK(status, FAIL, "H5Dwrite"); status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buffer); @@ -155,7 +154,7 @@ tts_cancel_thread(void H5_ATTR_UNUSED *arg) HDsleep(3); datavalue = 100; - status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue); + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue); CHECK(status, FAIL, "H5Dwrite"); status = H5Dclose(dataset); @@ -176,10 +175,10 @@ tts_cancel_thread(void H5_ATTR_UNUSED *arg) herr_t tts_cancel_callback(void *elem, hid_t H5_ATTR_UNUSED type_id, unsigned H5_ATTR_UNUSED ndim, - const hsize_t H5_ATTR_UNUSED *point, void *operator_data) + const hsize_t H5_ATTR_UNUSED *point, void *operator_data) { - hid_t dataset = *(hid_t *)operator_data; - int value = *(int *)elem; + hid_t dataset = *(hid_t *)operator_data; + int value = *(int *)elem; herr_t status; tts_cancel_barrier(); @@ -205,7 +204,7 @@ void cancellation_cleanup(void *arg) { cancel_cleanup_t *cleanup_structure = (cancel_cleanup_t *)arg; - herr_t status; + herr_t status; status = H5Dclose(cleanup_structure->dataset); CHECK(status, FAIL, "H5Dclose"); @@ -226,7 +225,7 @@ void tts_cancel_barrier(void) { static int count = 2; - int status; + int status; status = pthread_mutex_lock(&mutex); VERIFY(status, 0, "pthread_mutex_lock"); @@ -245,11 +244,11 @@ tts_cancel_barrier(void) VERIFY(status, 0, "pthread_mutex_unlock"); } /* end tts_cancel_barrier() */ -void cleanup_cancel(void) +void +cleanup_cancel(void) { HDunlink(FILENAME); } #endif /*H5_HAVE_WIN_THREADS*/ #endif /*H5_HAVE_THREADSAFE*/ - diff --git a/test/ttsafe_dcreate.c b/test/ttsafe_dcreate.c index 36b5f1f..cedafd0 100644 --- a/test/ttsafe_dcreate.c +++ b/test/ttsafe_dcreate.c @@ -31,39 +31,24 @@ #ifdef H5_HAVE_THREADSAFE -#define FILENAME "ttsafe_dcreate.h5" -#define NUM_THREAD 16 +#define FILENAME "ttsafe_dcreate.h5" +#define NUM_THREAD 16 void *tts_dcreate_creator(void *); typedef struct thread_info { - int id; - hid_t file; - const char *dsetname; + int id; + hid_t file; + const char *dsetname; } thread_info; /* * Set individual dataset names (rather than generated the names * automatically) */ -const char *dsetname[NUM_THREAD]={ - "zero", - "one", - "two", - "three", - "four", - "five", - "six", - "seven", - "eight", - "nine", - "ten", - "eleven", - "twelve", - "thirteen", - "fourteen", - "fifteen" -}; +const char *dsetname[NUM_THREAD] = {"zero", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven", + "twelve", "thirteen", "fourteen", "fifteen"}; thread_info thread_out[NUM_THREAD]; @@ -79,11 +64,11 @@ tts_dcreate(void) H5TS_thread_t threads[NUM_THREAD]; /* HDF5 data definitions */ - hid_t file = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - int datavalue, i; + hid_t file = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + int datavalue, i; H5TS_attr_t attribute; - herr_t status; + herr_t status; /* set pthread attribute to perform global scheduling */ H5TS_attr_init(&attribute); @@ -101,30 +86,31 @@ tts_dcreate(void) CHECK(file, H5I_INVALID_HID, "H5Fcreate"); /* simultaneously create a large number of datasets within the file */ - for(i = 0; i < NUM_THREAD; i++) { - thread_out[i].id = i; - thread_out[i].file = file; + for (i = 0; i < NUM_THREAD; i++) { + thread_out[i].id = i; + thread_out[i].file = file; thread_out[i].dsetname = dsetname[i]; - threads[i] = H5TS_create_thread(tts_dcreate_creator, NULL, &thread_out[i]); + threads[i] = H5TS_create_thread(tts_dcreate_creator, NULL, &thread_out[i]); } - for(i = 0;i < NUM_THREAD; i++) + for (i = 0; i < NUM_THREAD; i++) H5TS_wait_for_thread(threads[i]); /* compare data to see if it is written correctly */ - for(i = 0; i < NUM_THREAD; i++) { - if((dataset = H5Dopen2(file, dsetname[i], H5P_DEFAULT)) < 0) { + for (i = 0; i < NUM_THREAD; i++) { + if ((dataset = H5Dopen2(file, dsetname[i], H5P_DEFAULT)) < 0) { TestErrPrintf("Dataset name not found - test failed\n"); H5Fclose(file); return; - } else { + } + else { status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue); CHECK(status, FAIL, "H5Dread"); - if(datavalue != i) { - TestErrPrintf("Wrong value read %d for dataset name %s - test failed\n", - datavalue, dsetname[i]); + if (datavalue != i) { + TestErrPrintf("Wrong value read %d for dataset name %s - test failed\n", datavalue, + dsetname[i]); status = H5Dclose(dataset); CHECK(status, FAIL, "H5Dclose"); status = H5Fclose(file); @@ -132,7 +118,7 @@ tts_dcreate(void) return; } - status= H5Dclose(dataset); + status = H5Dclose(dataset); CHECK(status, FAIL, "H5Dclose"); } } @@ -148,27 +134,26 @@ tts_dcreate(void) void * tts_dcreate_creator(void *_thread_data) { - hid_t dataspace = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - herr_t status; - hsize_t dimsf[1]; /* dataset dimensions */ + hid_t dataspace = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + herr_t status; + hsize_t dimsf[1]; /* dataset dimensions */ struct thread_info thread_data; memcpy(&thread_data, _thread_data, sizeof(struct thread_info)); /* define dataspace for dataset */ - dimsf[0] = 1; + dimsf[0] = 1; dataspace = H5Screate_simple(1, dimsf, NULL); CHECK(dataspace, H5I_INVALID_HID, "H5Screate_simple"); /* create a new dataset within the file */ - dataset = H5Dcreate2(thread_data.file, thread_data.dsetname, - H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(thread_data.file, thread_data.dsetname, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); /* initialize data for dataset and write value to dataset */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, &thread_data.id); + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &thread_data.id); CHECK(status, FAIL, "H5Dwrite"); /* close dataset and dataspace resources */ @@ -186,4 +171,3 @@ cleanup_dcreate(void) HDunlink(FILENAME); } #endif /*H5_HAVE_THREADSAFE*/ - diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index 9eeaa24..f92c65e 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -33,13 +33,13 @@ #ifdef H5_HAVE_THREADSAFE -#define NUM_THREAD 16 -#define FILENAME "ttsafe_error.h5" +#define NUM_THREAD 16 +#define FILENAME "ttsafe_error.h5" /* Having a common dataset name is an error */ -#define DATASETNAME "commonname" -#define EXPECTED_ERROR_DEPTH 10 -#define WRITE_NUMBER 37 +#define DATASETNAME "commonname" +#define EXPECTED_ERROR_DEPTH 10 +#define WRITE_NUMBER 37 /* Typedefs */ typedef struct err_num_struct { @@ -48,28 +48,27 @@ typedef struct err_num_struct { } err_num_t; /* Global variables */ -hid_t error_file_g = H5I_INVALID_HID; -int error_flag_g = 0; -int error_count_g = 0; +hid_t error_file_g = H5I_INVALID_HID; +int error_flag_g = 0; +int error_count_g = 0; err_num_t expected_g[EXPECTED_ERROR_DEPTH]; H5TS_mutex_simple_t error_mutex_g; /* Prototypes */ -static herr_t error_callback(hid_t , void *); +static herr_t error_callback(hid_t, void *); static herr_t walk_error_callback(unsigned, const H5E_error2_t *, void *); -static void *tts_error_thread(void *); - +static void * tts_error_thread(void *); void tts_error(void) { - hid_t def_fapl = H5I_INVALID_HID; - hid_t vol_id = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - H5TS_thread_t threads[NUM_THREAD]; - H5TS_attr_t attribute; - int value, i; - herr_t status; + hid_t def_fapl = H5I_INVALID_HID; + hid_t vol_id = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + H5TS_thread_t threads[NUM_THREAD]; + H5TS_attr_t attribute; + int value, i; + herr_t status; /* Must initialize these at runtime */ expected_g[0].maj_num = H5E_DATASET; @@ -119,7 +118,7 @@ tts_error(void) status = H5Pget_vol_id(def_fapl, &vol_id); CHECK(status, FAIL, "H5Pget_vol_id"); - if(vol_id == H5VL_NATIVE) { + if (vol_id == H5VL_NATIVE) { /* Create a hdf5 file using H5F_ACC_TRUNC access, default file * creation plist and default file access plist */ @@ -133,12 +132,13 @@ tts_error(void) H5TS_wait_for_thread(threads[i]); if (error_flag_g) { - TestErrPrintf("At least one thread reported a value that was different from the expected value\n"); + TestErrPrintf( + "At least one thread reported a value that was different from the expected value\n"); HDprintf("(Update this test if the error stack changed!)\n"); } if (error_count_g != NUM_THREAD - 1) - TestErrPrintf("Error: %d threads failed instead of %d\n", error_count_g, NUM_THREAD-1); + TestErrPrintf("Error: %d threads failed instead of %d\n", error_count_g, NUM_THREAD - 1); dataset = H5Dopen2(error_file_g, DATASETNAME, H5P_DEFAULT); CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); @@ -166,14 +166,14 @@ tts_error(void) static void * tts_error_thread(void H5_ATTR_UNUSED *arg) { - hid_t dataspace = H5I_INVALID_HID; - hid_t datatype = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - hsize_t dimsf[1]; /* dataset dimensions */ + hid_t dataspace = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hsize_t dimsf[1]; /* dataset dimensions */ H5E_auto2_t old_error_cb; - void *old_error_client_data; - int value; - herr_t status; + void * old_error_client_data; + int value; + herr_t status; /* preserve previous error stack handler */ status = H5Eget_auto2(H5E_DEFAULT, &old_error_cb, &old_error_client_data); @@ -184,7 +184,7 @@ tts_error_thread(void H5_ATTR_UNUSED *arg) CHECK(status, FAIL, "H5Eset_auto2"); /* define dataspace for dataset */ - dimsf[0] = 1; + dimsf[0] = 1; dataspace = H5Screate_simple(1, dimsf, NULL); CHECK(dataspace, H5I_INVALID_HID, "H5Screate_simple"); @@ -195,10 +195,11 @@ tts_error_thread(void H5_ATTR_UNUSED *arg) CHECK(status, FAIL, "H5Tset_order"); /* create a new dataset within the file */ - dataset = H5Dcreate2(error_file_g, DATASETNAME, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = + H5Dcreate2(error_file_g, DATASETNAME, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Most of these will fail, so don't check the error here */ if (dataset >= 0) { - value = WRITE_NUMBER; + value = WRITE_NUMBER; status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &value); CHECK(status, FAIL, "H5Dwrite"); status = H5Dclose(dataset); @@ -229,8 +230,8 @@ error_callback(hid_t H5_ATTR_UNUSED estack_id, void *client_data) static herr_t walk_error_callback(unsigned n, const H5E_error2_t *err_desc, void H5_ATTR_UNUSED *client_data) { - hid_t maj_num = H5I_INVALID_HID; - hid_t min_num = H5I_INVALID_HID; + hid_t maj_num = H5I_INVALID_HID; + hid_t min_num = H5I_INVALID_HID; if (err_desc) { maj_num = err_desc->maj_num; @@ -251,4 +252,3 @@ cleanup_error(void) } #endif /*H5_HAVE_THREADSAFE*/ - diff --git a/test/ttst.c b/test/ttst.c index c5912c5..4d6cdf0 100644 --- a/test/ttst.c +++ b/test/ttst.c @@ -35,13 +35,12 @@ #include "H5STprivate.h" /* Test words to insert into s TST */ -static const char *words[]={ - "We", "hold", "these", "truths", "to", "be", "self-evident,", "that", - "all", "men", "are", "created", "equal,", "that", "they", "are", "endowed", - "by", "their", "Creator", "with", "certain", "unalienable", "Rights,", - "that", "among", "these", "are", "Life,", "Liberty", "and", "the", - "pursuit", "of", "Happiness." -}; +static const char *words[] = { + "We", "hold", "these", "truths", "to", "be", "self-evident,", + "that", "all", "men", "are", "created", "equal,", "that", + "they", "are", "endowed", "by", "their", "Creator", "with", + "certain", "unalienable", "Rights,", "that", "among", "these", "are", + "Life,", "Liberty", "and", "the", "pursuit", "of", "Happiness."}; /* Number of words in test words set */ size_t num_words; @@ -54,9 +53,10 @@ char **rand_uniq_words; /* Sorted order version of words in test word set */ char **sort_uniq_words; -static int tst_strcmp(const void *_s1, const void *_s2) +static int +tst_strcmp(const void *_s1, const void *_s2) { - return(HDstrcmp(*(const char * const *)_s1,*(const char * const *)_s2)); + return (HDstrcmp(*(const char *const *)_s1, *(const char *const *)_s2)); } /**************************************************************** @@ -68,71 +68,71 @@ static int tst_strcmp(const void *_s1, const void *_s2) static void test_tst_init(void) { - time_t curr_time; /* Current time, for seeding random number generator */ - char *tmp_word;/* Temporary pointer to word in word set */ - size_t u,v,w; /* Local index variables */ + time_t curr_time; /* Current time, for seeding random number generator */ + char * tmp_word; /* Temporary pointer to word in word set */ + size_t u, v, w; /* Local index variables */ /* Compute the number of words in the test set */ - num_words=sizeof(words)/sizeof(words[0]); + num_words = sizeof(words) / sizeof(words[0]); /* Determine the number of unique words in test set */ /* (Not particularly efficient, be careful if many words are added to set) */ - num_uniq_words=0; - for(u=0; ueqkid,uniq_words[u])) - TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,uniq_words[u]); + if (HDstrcmp((const char *)found->eqkid, uniq_words[u])) + TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, uniq_words[%u]=%s\n", __LINE__, + (char *)found->eqkid, (unsigned)u, uniq_words[u]); - obj=H5ST_locate(tree,uniq_words[u]); + obj = H5ST_locate(tree, uniq_words[u]); CHECK_PTR(obj, "H5ST_locate"); - if(HDstrcmp((const char *)obj,uniq_words[u])) - TestErrPrintf("%d: TST objects don't match!, obj=%s, uniq_words[%u]=%s\n",__LINE__,(char *)obj,(unsigned)u,uniq_words[u]); + if (HDstrcmp((const char *)obj, uniq_words[u])) + TestErrPrintf("%d: TST objects don't match!, obj=%s, uniq_words[%u]=%s\n", __LINE__, (char *)obj, + (unsigned)u, uniq_words[u]); } /* end for */ /* Verify that words not in the TST aren't found */ - check=H5ST_search(tree,"foo"); + check = H5ST_search(tree, "foo"); VERIFY(check, FALSE, "H5ST_search"); - check=H5ST_search(tree,"bar"); + check = H5ST_search(tree, "bar"); VERIFY(check, FALSE, "H5ST_search"); - check=H5ST_search(tree,"baz"); + check = H5ST_search(tree, "baz"); VERIFY(check, FALSE, "H5ST_search"); /* Close the TST */ - ret=H5ST_close(tree); + ret = H5ST_close(tree); CHECK(ret, FAIL, "H5ST_close"); } /* end test_tst_insert() */ @@ -237,39 +239,40 @@ static void test_tst_iterate(void) { H5ST_tree_t *tree; /* TST created */ - H5ST_ptr_t found; /* Pointer to TST node found */ - size_t u; /* Local index counter */ - herr_t ret; /* Generic return value */ + H5ST_ptr_t found; /* Pointer to TST node found */ + size_t u; /* Local index counter */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Iterating Over TSTs\n")); /* Create the TST */ - tree=H5ST_create(); + tree = H5ST_create(); CHECK_PTR(tree, "H5ST_create"); /* Insert unique words into TST, in random order */ - for(u=0; ueqkid,sort_uniq_words[u])) - TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, sort_uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,sort_uniq_words[u]); + if (HDstrcmp((const char *)found->eqkid, sort_uniq_words[u])) + TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, sort_uniq_words[%u]=%s\n", + __LINE__, (char *)found->eqkid, (unsigned)u, sort_uniq_words[u]); /* Advance to next string in TST */ - found=H5ST_findnext(found); + found = H5ST_findnext(found); u++; - } while(found!=NULL); + } while (found != NULL); /* Close the TST */ - ret=H5ST_close(tree); + ret = H5ST_close(tree); CHECK(ret, FAIL, "H5ST_close"); } /* end test_tst_iterate() */ @@ -283,66 +286,68 @@ static void test_tst_remove(void) { H5ST_tree_t *tree; /* TST created */ - H5ST_ptr_t found; /* Pointer to TST node found */ - void *obj; /* Pointer to object removed from TST */ - htri_t check; /* Is string in TST? */ - size_t u; /* Local index counter */ - herr_t ret; /* Generic return value */ + H5ST_ptr_t found; /* Pointer to TST node found */ + void * obj; /* Pointer to object removed from TST */ + htri_t check; /* Is string in TST? */ + size_t u; /* Local index counter */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Removing String Values from TSTs\n")); /* Create the TST */ - tree=H5ST_create(); + tree = H5ST_create(); CHECK_PTR(tree, "H5ST_create"); /* Insert unique words into TST, in random order */ - for(u=0; ueqkid,rand_uniq_words[u])) - TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, rand_uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,rand_uniq_words[u]); + if (HDstrcmp((const char *)found->eqkid, rand_uniq_words[u])) + TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, rand_uniq_words[%u]=%s\n", + __LINE__, (char *)found->eqkid, (unsigned)u, rand_uniq_words[u]); /* Remove the node */ - ret=H5ST_delete(tree,found); + ret = H5ST_delete(tree, found); CHECK(ret, FAIL, "H5ST_delete"); /* Check that the string can't be found in the TST any longer */ - check=H5ST_search(tree,rand_uniq_words[u]); + check = H5ST_search(tree, rand_uniq_words[u]); VERIFY(check, FALSE, "H5ST_search"); } /* end for */ /* Close the TST */ - ret=H5ST_close(tree); + ret = H5ST_close(tree); CHECK(ret, FAIL, "H5ST_close"); } /* end test_tst_remove() */ @@ -376,12 +381,11 @@ test_tst(void) test_tst_init(); /* Actual TST tests */ - test_tst_create(); /* Test TST creation */ - test_tst_insert(); /* Test TST insertion */ - test_tst_iterate(); /* Test TST iteration */ - test_tst_remove(); /* Test TST deletion */ + test_tst_create(); /* Test TST creation */ + test_tst_insert(); /* Test TST insertion */ + test_tst_iterate(); /* Test TST iteration */ + test_tst_remove(); /* Test TST deletion */ /* Finalize TST testing data */ test_tst_finalize(); -} /* end test_tst() */ - +} /* end test_tst() */ diff --git a/test/tunicode.c b/test/tunicode.c index 6f7431b..28f819b 100644 --- a/test/tunicode.c +++ b/test/tunicode.c @@ -14,26 +14,26 @@ /* Unicode test */ #include "testhdf5.h" -#define NUM_CHARS 16 -#define MAX_STRING_LENGTH ((NUM_CHARS * 4) + 1) /* Max length in bytes */ -#define MAX_PATH_LENGTH (MAX_STRING_LENGTH + 20) /* Max length in bytes */ -#define MAX_CODE_POINT 0x200000 -#define FILENAME "unicode.h5" +#define NUM_CHARS 16 +#define MAX_STRING_LENGTH ((NUM_CHARS * 4) + 1) /* Max length in bytes */ +#define MAX_PATH_LENGTH (MAX_STRING_LENGTH + 20) /* Max length in bytes */ +#define MAX_CODE_POINT 0x200000 +#define FILENAME "unicode.h5" /* A buffer to hold two copies of the UTF-8 string */ #define LONG_BUF_SIZE (2 * MAX_STRING_LENGTH + 4) -#define DSET1_NAME "fl_string_dataset" -#define DSET3_NAME "dataset3" -#define DSET4_NAME "dataset4" +#define DSET1_NAME "fl_string_dataset" +#define DSET3_NAME "dataset3" +#define DSET4_NAME "dataset4" #define VL_DSET1_NAME "vl_dset_1" -#define GROUP1_NAME "group1" -#define GROUP2_NAME "group2" -#define GROUP3_NAME "group3" -#define GROUP4_NAME "group4" - -#define RANK 1 -#define COMP_INT_VAL 7 -#define COMP_FLOAT_VAL -42.0F +#define GROUP1_NAME "group1" +#define GROUP2_NAME "group2" +#define GROUP3_NAME "group3" +#define GROUP4_NAME "group4" + +#define RANK 1 +#define COMP_INT_VAL 7 +#define COMP_FLOAT_VAL -42.0F #define COMP_DOUBLE_VAL 42.0F /* Test function prototypes */ @@ -48,62 +48,63 @@ void test_opaque(hid_t fid, const char *string); /* Utility function prototypes */ static hid_t mkstr(size_t len, H5T_str_t strpad); -unsigned int write_char(unsigned int c, char * test_string, unsigned int cur_pos); -void dump_string(const char * string); +unsigned int write_char(unsigned int c, char *test_string, unsigned int cur_pos); +void dump_string(const char *string); /* * test_fl_string * Tests that UTF-8 can be used for fixed-length string data. * Writes the string to a dataset and reads it back again. */ -void test_fl_string(hid_t fid, const char *string) +void +test_fl_string(hid_t fid, const char *string) { - hid_t dtype_id, space_id, dset_id; - hsize_t dims = 1; - char read_buf[MAX_STRING_LENGTH]; - H5T_cset_t cset; - herr_t ret; - - /* Create the datatype, ensure that the character set behaves - * correctly (it should default to ASCII and can be set to UTF8) - */ - dtype_id = H5Tcopy(H5T_C_S1); - CHECK(dtype_id, FAIL, "H5Tcopy"); - ret = H5Tset_size(dtype_id, (size_t)MAX_STRING_LENGTH); - CHECK(ret, FAIL, "H5Tset_size"); - cset = H5Tget_cset(dtype_id); - VERIFY(cset, H5T_CSET_ASCII, "H5Tget_cset"); - ret = H5Tset_cset(dtype_id, H5T_CSET_UTF8); - CHECK(ret, FAIL, "H5Tset_cset"); - cset = H5Tget_cset(dtype_id); - VERIFY(cset, H5T_CSET_UTF8, "H5Tget_cset"); - - /* Create dataspace for a dataset */ - space_id = H5Screate_simple(RANK, &dims, NULL); - CHECK(space_id, FAIL, "H5Screate_simple"); - - /* Create a dataset */ - dset_id = H5Dcreate2(fid, DSET1_NAME, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dcreate2"); - - /* Write UTF-8 string to dataset */ - ret = H5Dwrite(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, string); - CHECK(ret, FAIL, "H5Dwrite"); - - /* Read string back and make sure it is unchanged */ - ret = H5Dread(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf); - CHECK(ret, FAIL, "H5Dread"); - - VERIFY(HDstrcmp(string, read_buf), 0, "strcmp"); - - /* Close all */ - ret = H5Dclose(dset_id); - CHECK(ret, FAIL, "H5Dclose"); - - ret = H5Tclose(dtype_id); - CHECK(ret, FAIL, "H5Tclose"); - ret = H5Sclose(space_id); - CHECK(ret, FAIL, "H5Sclose"); + hid_t dtype_id, space_id, dset_id; + hsize_t dims = 1; + char read_buf[MAX_STRING_LENGTH]; + H5T_cset_t cset; + herr_t ret; + + /* Create the datatype, ensure that the character set behaves + * correctly (it should default to ASCII and can be set to UTF8) + */ + dtype_id = H5Tcopy(H5T_C_S1); + CHECK(dtype_id, FAIL, "H5Tcopy"); + ret = H5Tset_size(dtype_id, (size_t)MAX_STRING_LENGTH); + CHECK(ret, FAIL, "H5Tset_size"); + cset = H5Tget_cset(dtype_id); + VERIFY(cset, H5T_CSET_ASCII, "H5Tget_cset"); + ret = H5Tset_cset(dtype_id, H5T_CSET_UTF8); + CHECK(ret, FAIL, "H5Tset_cset"); + cset = H5Tget_cset(dtype_id); + VERIFY(cset, H5T_CSET_UTF8, "H5Tget_cset"); + + /* Create dataspace for a dataset */ + space_id = H5Screate_simple(RANK, &dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + + /* Create a dataset */ + dset_id = H5Dcreate2(fid, DSET1_NAME, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dcreate2"); + + /* Write UTF-8 string to dataset */ + ret = H5Dwrite(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, string); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Read string back and make sure it is unchanged */ + ret = H5Dread(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf); + CHECK(ret, FAIL, "H5Dread"); + + VERIFY(HDstrcmp(string, read_buf), 0, "strcmp"); + + /* Close all */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Tclose(dtype_id); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); } /* @@ -113,52 +114,52 @@ void test_fl_string(hid_t fid, const char *string) * Borrows heavily from dtypes.c, but is more complicated because * the string is randomly generated. */ -void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) +void +test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) { /* buf is used to hold the data that H5Tconvert operates on. */ - char buf[LONG_BUF_SIZE]; + char buf[LONG_BUF_SIZE]; /* cmpbuf holds the output that H5Tconvert should produce, * to compare against the actual output. */ - char cmpbuf[LONG_BUF_SIZE]; + char cmpbuf[LONG_BUF_SIZE]; /* new_string is a slightly modified version of the UTF-8 * string to make the tests run more smoothly. */ - char new_string[MAX_STRING_LENGTH + 2]; + char new_string[MAX_STRING_LENGTH + 2]; - size_t length; /* Length of new_string in bytes */ - size_t small_len; /* Size of the small datatype */ - size_t big_len; /* Size of the larger datatype */ - hid_t src_type, dst_type; - herr_t ret; + size_t length; /* Length of new_string in bytes */ + size_t small_len; /* Size of the small datatype */ + size_t big_len; /* Size of the larger datatype */ + hid_t src_type, dst_type; + herr_t ret; /* The following tests are simpler if the UTF-8 string contains * the right number of bytes (even or odd, depending on the test). * We create a 'new_string' whose length is convenient by prepending * an 'x' to 'string' when necessary. */ length = HDstrlen(string); - if(length % 2 != 1) - { - HDstrcpy(new_string, "x"); - HDstrcat(new_string, string); - length++; - } else { - HDstrcpy(new_string, string); + if (length % 2 != 1) { + HDstrcpy(new_string, "x"); + HDstrcat(new_string, string); + length++; + } + else { + HDstrcpy(new_string, string); } - /* Convert a null-terminated string to a shorter and longer null * terminated string. */ /* Create a src_type that holds the UTF-8 string and its final NULL */ - big_len = length + 1; /* +1 byte for final NULL */ - HDassert((2*big_len)<=sizeof(cmpbuf)); + big_len = length + 1; /* +1 byte for final NULL */ + HDassert((2 * big_len) <= sizeof(cmpbuf)); src_type = mkstr(big_len, H5T_STR_NULLTERM); CHECK(src_type, FAIL, "mkstr"); /* Create a dst_type that holds half of the UTF-8 string and a final * NULL */ small_len = (length + 1) / 2; - dst_type = mkstr(small_len, H5T_STR_NULLTERM); + dst_type = mkstr(small_len, H5T_STR_NULLTERM); CHECK(dst_type, FAIL, "mkstr"); /* Fill the buffer with two copies of the UTF-8 string, each with a @@ -176,11 +177,11 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) * string manually. */ HDstrncpy(cmpbuf, new_string, small_len - 1); cmpbuf[small_len - 1] = '\0'; - HDstrncpy(&cmpbuf[small_len], new_string, small_len -1); + HDstrncpy(&cmpbuf[small_len], new_string, small_len - 1); cmpbuf[2 * small_len - 1] = '\0'; HDstrcpy(&cmpbuf[2 * small_len], new_string); - VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp"); + VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp"); /* Now convert from smaller datatype to bigger datatype. This should * leave our buffer looking like: "abc\0\0\0\0\0abc\0\0\0\0\0" */ @@ -190,38 +191,37 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) /* First fill the buffer with NULLs */ HDmemset(cmpbuf, '\0', (size_t)LONG_BUF_SIZE); /* Copy in the characters */ - HDstrncpy(cmpbuf, new_string, small_len -1); - HDstrncpy(&cmpbuf[big_len], new_string, small_len -1); + HDstrncpy(cmpbuf, new_string, small_len - 1); + HDstrncpy(&cmpbuf[big_len], new_string, small_len - 1); - VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp"); + VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp"); ret = H5Tclose(src_type); CHECK(ret, FAIL, "H5Tclose"); ret = H5Tclose(dst_type); CHECK(ret, FAIL, "H5Tclose"); - /* Now test null padding. Null-padded strings do *not* need * terminating NULLs, so the sizes of the datatypes are slightly * different and we want a string with an even number of characters. */ length = HDstrlen(string); - if(length % 2 != 0) - { - HDstrcpy(new_string, "x"); - HDstrcat(new_string, string); - length++; - } else { - HDstrcpy(new_string, string); + if (length % 2 != 0) { + HDstrcpy(new_string, "x"); + HDstrcat(new_string, string); + length++; + } + else { + HDstrcpy(new_string, string); } /* Create a src_type that holds the UTF-8 string */ big_len = length; - HDassert((2*big_len)<=sizeof(cmpbuf)); + HDassert((2 * big_len) <= sizeof(cmpbuf)); src_type = mkstr(big_len, H5T_STR_NULLPAD); CHECK(src_type, FAIL, "mkstr"); /* Create a dst_type that holds half of the UTF-8 string */ small_len = length / 2; - dst_type = mkstr(small_len, H5T_STR_NULLPAD); + dst_type = mkstr(small_len, H5T_STR_NULLPAD); CHECK(dst_type, FAIL, "mkstr"); /* Fill the buffer with two copies of the UTF-8 string. @@ -241,7 +241,7 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) HDstrncpy(&cmpbuf[small_len], new_string, small_len); HDstrncpy(&cmpbuf[2 * small_len], new_string, big_len); - VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp"); + VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp"); /* Now convert from smaller datatype to bigger datatype. This should * leave our buffer looking like: "abcd\0\0\0\0abcd\0\0\0\0" */ @@ -254,14 +254,13 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) HDstrncpy(cmpbuf, new_string, small_len); HDstrncpy(&cmpbuf[big_len], new_string, small_len); - VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp"); + VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp"); ret = H5Tclose(src_type); CHECK(ret, FAIL, "H5Tclose"); ret = H5Tclose(dst_type); CHECK(ret, FAIL, "H5Tclose"); - /* Test space padding. This is very similar to null-padding; we can use the same values of length, small_len, and big_len. */ @@ -287,7 +286,7 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) HDstrncpy(&cmpbuf[small_len], new_string, small_len); HDstrncpy(&cmpbuf[2 * small_len], new_string, big_len); - VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp"); + VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp"); /* Now convert from smaller datatype to bigger datatype. This should * leave our buffer looking like: "abcd abcd " */ @@ -300,7 +299,7 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) HDstrncpy(cmpbuf, new_string, small_len); HDstrncpy(&cmpbuf[big_len], new_string, small_len); - VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp"); + VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp"); ret = H5Tclose(src_type); CHECK(ret, FAIL, "H5Tclose"); @@ -308,60 +307,60 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string) CHECK(ret, FAIL, "H5Tclose"); } - /* * test_vl_string * Tests variable-length string datatype with UTF-8 strings. */ -void test_vl_string(hid_t fid, const char *string) +void +test_vl_string(hid_t fid, const char *string) { - hid_t type_id, space_id, dset_id; - hsize_t dims = 1; - hsize_t size; /* Number of bytes used */ - char *read_buf[1]; - herr_t ret; - - /* Create dataspace for datasets */ - space_id = H5Screate_simple(RANK, &dims, NULL); - CHECK(space_id, FAIL, "H5Screate_simple"); - - /* Create a datatype to refer to */ - type_id = H5Tcopy(H5T_C_S1); - CHECK(type_id, FAIL, "H5Tcopy"); - ret = H5Tset_size(type_id, H5T_VARIABLE); - CHECK(ret, FAIL, "H5Tset_size"); - - /* Create a dataset */ - dset_id = H5Dcreate2(fid, VL_DSET1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dcreate2"); - - /* Write dataset to disk */ - ret = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string); - CHECK(ret, FAIL, "H5Dwrite"); - - /* Make certain the correct amount of memory will be used */ - ret = H5Dvlen_get_buf_size(dset_id, type_id, space_id, &size); - CHECK(ret, FAIL, "H5Dvlen_get_buf_size"); - VERIFY(size, (hsize_t)HDstrlen(string) + 1, "H5Dvlen_get_buf_size"); - - /* Read dataset from disk */ - ret = H5Dread(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf); - CHECK(ret, FAIL, "H5Dread"); - - /* Compare data read in */ - VERIFY(HDstrcmp(string, read_buf[0]), 0, "strcmp"); - - /* Reclaim the read VL data */ - ret = H5Treclaim(type_id, space_id, H5P_DEFAULT, read_buf); - CHECK(ret, FAIL, "H5Treclaim"); - - /* Close all */ - ret = H5Dclose(dset_id); - CHECK(ret, FAIL, "H5Dclose"); - ret = H5Tclose(type_id); - CHECK(ret, FAIL, "H5Tclose"); - ret = H5Sclose(space_id); - CHECK(ret, FAIL, "H5Sclose"); + hid_t type_id, space_id, dset_id; + hsize_t dims = 1; + hsize_t size; /* Number of bytes used */ + char * read_buf[1]; + herr_t ret; + + /* Create dataspace for datasets */ + space_id = H5Screate_simple(RANK, &dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + + /* Create a datatype to refer to */ + type_id = H5Tcopy(H5T_C_S1); + CHECK(type_id, FAIL, "H5Tcopy"); + ret = H5Tset_size(type_id, H5T_VARIABLE); + CHECK(ret, FAIL, "H5Tset_size"); + + /* Create a dataset */ + dset_id = H5Dcreate2(fid, VL_DSET1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dcreate2"); + + /* Write dataset to disk */ + ret = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Make certain the correct amount of memory will be used */ + ret = H5Dvlen_get_buf_size(dset_id, type_id, space_id, &size); + CHECK(ret, FAIL, "H5Dvlen_get_buf_size"); + VERIFY(size, (hsize_t)HDstrlen(string) + 1, "H5Dvlen_get_buf_size"); + + /* Read dataset from disk */ + ret = H5Dread(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf); + CHECK(ret, FAIL, "H5Dread"); + + /* Compare data read in */ + VERIFY(HDstrcmp(string, read_buf[0]), 0, "strcmp"); + + /* Reclaim the read VL data */ + ret = H5Treclaim(type_id, space_id, H5P_DEFAULT, read_buf); + CHECK(ret, FAIL, "H5Treclaim"); + + /* Close all */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); } /* @@ -374,347 +373,348 @@ void test_vl_string(hid_t fid, const char *string) * was added to links it didn't change how they were stored in the file, * -JML 2/2/2006 */ -void test_objnames(hid_t fid, const char* string) +void +test_objnames(hid_t fid, const char *string) { - hid_t grp_id, grp1_id, grp2_id, grp3_id; - hid_t type_id, dset_id, space_id; - char read_buf[MAX_STRING_LENGTH]; - char path_buf[MAX_PATH_LENGTH]; - hsize_t dims=1; - hobj_ref_t obj_ref; - ssize_t size; - herr_t ret; - - /* Create a group with a UTF-8 name */ - grp_id = H5Gcreate2(fid, string, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(grp_id, FAIL, "H5Gcreate2"); - - /* Set a comment on the group to test that we can access the group - * Also test that UTF-8 comments can be read. - */ - ret = H5Oset_comment_by_name(fid, string, string, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oset_comment_by_name"); - size = H5Oget_comment_by_name(fid, string, read_buf, (size_t)MAX_STRING_LENGTH, H5P_DEFAULT); - CHECK(size, FAIL, "H5Oget_comment_by_name"); - - ret = H5Gclose(grp_id); - CHECK(ret, FAIL, "H5Gclose"); - - VERIFY(HDstrcmp(string, read_buf), 0, "strcmp"); - - /* Create a new dataset with a UTF-8 name */ - grp1_id = H5Gcreate2(fid, GROUP1_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(grp1_id, FAIL, "H5Gcreate2"); - - space_id = H5Screate_simple(RANK, &dims, NULL); - CHECK(space_id, FAIL, "H5Screate_simple"); - dset_id = H5Dcreate2(grp1_id, string, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dcreate2"); - - /* Make sure that dataset can be opened again */ - ret = H5Dclose(dset_id); - CHECK(ret, FAIL, "H5Dclose"); - ret = H5Sclose(space_id); - CHECK(ret, FAIL, "H5Sclose"); - - dset_id = H5Dopen2(grp1_id, string, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Dopen2"); - ret = H5Dclose(dset_id); - CHECK(ret, FAIL, "H5Dclose"); - ret = H5Gclose(grp1_id); - CHECK(ret, FAIL, "H5Gclose"); - - /* Do the same for a named datatype */ - grp2_id = H5Gcreate2(fid, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(grp2_id, FAIL, "H5Gcreate2"); - - type_id = H5Tcreate(H5T_OPAQUE, (size_t)1); - CHECK(type_id, FAIL, "H5Tcreate"); - ret = H5Tcommit2(grp2_id, string, type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(type_id, FAIL, "H5Tcommit2"); - ret = H5Tclose(type_id); - CHECK(type_id, FAIL, "H5Tclose"); - - type_id = H5Topen2(grp2_id, string, H5P_DEFAULT); - CHECK(type_id, FAIL, "H5Topen2"); - ret = H5Tclose(type_id); - CHECK(type_id, FAIL, "H5Tclose"); - - /* Don't close the group -- use it to test that object references - * can refer to objects named in UTF-8 */ - - space_id = H5Screate_simple(RANK, &dims, NULL); - CHECK(space_id, FAIL, "H5Screate_simple"); - dset_id = H5Dcreate2(grp2_id, DSET3_NAME, H5T_STD_REF_OBJ, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Dcreate2"); - - /* Create reference to named datatype */ - ret = H5Rcreate(&obj_ref, grp2_id, string, H5R_OBJECT, (hid_t)-1); - CHECK(ret, FAIL, "H5Rcreate"); - /* Write selection and read it back*/ - ret = H5Dwrite(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &obj_ref); - CHECK(ret, FAIL, "H5Dwrite"); - ret = H5Dread(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &obj_ref); - CHECK(ret, FAIL, "H5Dread"); - - /* Ensure that we can open named datatype using object reference */ - type_id = H5Rdereference2(dset_id, H5P_DEFAULT, H5R_OBJECT, &obj_ref); - CHECK(type_id, FAIL, "H5Rdereference2"); - ret = H5Tcommitted(type_id); - VERIFY(ret, 1, "H5Tcommitted"); - - ret = H5Tclose(type_id); - CHECK(type_id, FAIL, "H5Tclose"); - ret = H5Dclose(dset_id); - CHECK(ret, FAIL, "H5Dclose"); - ret = H5Sclose(space_id); - CHECK(ret, FAIL, "H5Sclose"); - - ret = H5Gclose(grp2_id); - CHECK(ret, FAIL, "H5Gclose"); - - /* Create "group3". Build a hard link from group3 to group2, which has - * a datatype with the UTF-8 name. Create a soft link in group3 - * pointing through the hard link to the datatype. Give the soft - * link a name in UTF-8. Ensure that the soft link works. */ - - grp3_id = H5Gcreate2(fid, GROUP3_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(grp3_id, FAIL, "H5Gcreate2"); - - ret = H5Lcreate_hard(fid, GROUP2_NAME, grp3_id, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Lcreate_hard"); - HDstrcpy(path_buf, GROUP2_NAME); - HDstrcat(path_buf, "/"); - HDstrcat(path_buf, string); - ret = H5Lcreate_hard(grp3_id, path_buf, H5L_SAME_LOC, string, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Lcreate_hard"); - - /* Open named datatype using soft link */ - type_id = H5Topen2(grp3_id, string, H5P_DEFAULT); - CHECK(type_id, FAIL, "H5Topen2"); - - ret = H5Tclose(type_id); - CHECK(type_id, FAIL, "H5Tclose"); - ret = H5Gclose(grp3_id); - CHECK(ret, FAIL, "H5Gclose"); + hid_t grp_id, grp1_id, grp2_id, grp3_id; + hid_t type_id, dset_id, space_id; + char read_buf[MAX_STRING_LENGTH]; + char path_buf[MAX_PATH_LENGTH]; + hsize_t dims = 1; + hobj_ref_t obj_ref; + ssize_t size; + herr_t ret; + + /* Create a group with a UTF-8 name */ + grp_id = H5Gcreate2(fid, string, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(grp_id, FAIL, "H5Gcreate2"); + + /* Set a comment on the group to test that we can access the group + * Also test that UTF-8 comments can be read. + */ + ret = H5Oset_comment_by_name(fid, string, string, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oset_comment_by_name"); + size = H5Oget_comment_by_name(fid, string, read_buf, (size_t)MAX_STRING_LENGTH, H5P_DEFAULT); + CHECK(size, FAIL, "H5Oget_comment_by_name"); + + ret = H5Gclose(grp_id); + CHECK(ret, FAIL, "H5Gclose"); + + VERIFY(HDstrcmp(string, read_buf), 0, "strcmp"); + + /* Create a new dataset with a UTF-8 name */ + grp1_id = H5Gcreate2(fid, GROUP1_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(grp1_id, FAIL, "H5Gcreate2"); + + space_id = H5Screate_simple(RANK, &dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + dset_id = H5Dcreate2(grp1_id, string, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dcreate2"); + + /* Make sure that dataset can be opened again */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); + + dset_id = H5Dopen2(grp1_id, string, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Dopen2"); + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Gclose(grp1_id); + CHECK(ret, FAIL, "H5Gclose"); + + /* Do the same for a named datatype */ + grp2_id = H5Gcreate2(fid, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(grp2_id, FAIL, "H5Gcreate2"); + + type_id = H5Tcreate(H5T_OPAQUE, (size_t)1); + CHECK(type_id, FAIL, "H5Tcreate"); + ret = H5Tcommit2(grp2_id, string, type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(type_id, FAIL, "H5Tcommit2"); + ret = H5Tclose(type_id); + CHECK(type_id, FAIL, "H5Tclose"); + + type_id = H5Topen2(grp2_id, string, H5P_DEFAULT); + CHECK(type_id, FAIL, "H5Topen2"); + ret = H5Tclose(type_id); + CHECK(type_id, FAIL, "H5Tclose"); + + /* Don't close the group -- use it to test that object references + * can refer to objects named in UTF-8 */ + + space_id = H5Screate_simple(RANK, &dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + dset_id = + H5Dcreate2(grp2_id, DSET3_NAME, H5T_STD_REF_OBJ, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Dcreate2"); + + /* Create reference to named datatype */ + ret = H5Rcreate(&obj_ref, grp2_id, string, H5R_OBJECT, (hid_t)-1); + CHECK(ret, FAIL, "H5Rcreate"); + /* Write selection and read it back*/ + ret = H5Dwrite(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &obj_ref); + CHECK(ret, FAIL, "H5Dwrite"); + ret = H5Dread(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &obj_ref); + CHECK(ret, FAIL, "H5Dread"); + + /* Ensure that we can open named datatype using object reference */ + type_id = H5Rdereference2(dset_id, H5P_DEFAULT, H5R_OBJECT, &obj_ref); + CHECK(type_id, FAIL, "H5Rdereference2"); + ret = H5Tcommitted(type_id); + VERIFY(ret, 1, "H5Tcommitted"); + + ret = H5Tclose(type_id); + CHECK(type_id, FAIL, "H5Tclose"); + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Gclose(grp2_id); + CHECK(ret, FAIL, "H5Gclose"); + + /* Create "group3". Build a hard link from group3 to group2, which has + * a datatype with the UTF-8 name. Create a soft link in group3 + * pointing through the hard link to the datatype. Give the soft + * link a name in UTF-8. Ensure that the soft link works. */ + + grp3_id = H5Gcreate2(fid, GROUP3_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(grp3_id, FAIL, "H5Gcreate2"); + + ret = H5Lcreate_hard(fid, GROUP2_NAME, grp3_id, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Lcreate_hard"); + HDstrcpy(path_buf, GROUP2_NAME); + HDstrcat(path_buf, "/"); + HDstrcat(path_buf, string); + ret = H5Lcreate_hard(grp3_id, path_buf, H5L_SAME_LOC, string, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Lcreate_hard"); + + /* Open named datatype using soft link */ + type_id = H5Topen2(grp3_id, string, H5P_DEFAULT); + CHECK(type_id, FAIL, "H5Topen2"); + + ret = H5Tclose(type_id); + CHECK(type_id, FAIL, "H5Tclose"); + ret = H5Gclose(grp3_id); + CHECK(ret, FAIL, "H5Gclose"); } /* * test_attrname * Test that attributes can deal with UTF-8 strings */ -void test_attrname(hid_t fid, const char * string) +void +test_attrname(hid_t fid, const char *string) { - hid_t group_id, attr_id; - hid_t dtype_id, space_id; - hsize_t dims=1; - char read_buf[MAX_STRING_LENGTH]; - ssize_t size; - herr_t ret; - - /* Create a new group and give it an attribute whose - * name and value are UTF-8 strings. - */ - group_id = H5Gcreate2(fid, GROUP4_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(group_id, FAIL, "H5Gcreate2"); - - space_id = H5Screate_simple(RANK, &dims, NULL); - CHECK(space_id, FAIL, "H5Screate_simple"); - dtype_id = H5Tcopy(H5T_C_S1); - CHECK(dtype_id, FAIL, "H5Tcopy"); - ret = H5Tset_size(dtype_id, (size_t)MAX_STRING_LENGTH); - CHECK(ret, FAIL, "H5Tset_size"); - - /* Create the attribute and check that its name is correct */ - attr_id = H5Acreate2(group_id, string, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT); - CHECK(attr_id, FAIL, "H5Acreate2"); - size = H5Aget_name(attr_id, (size_t)MAX_STRING_LENGTH, read_buf); - CHECK(size, FAIL, "H5Aget_name"); - ret = strcmp(read_buf, string); - VERIFY(ret, 0, "strcmp"); - read_buf[0] = '\0'; - - /* Try writing and reading from the attribute */ - ret = H5Awrite(attr_id, dtype_id, string); - CHECK(ret, FAIL, "H5Awrite"); - ret = H5Aread(attr_id, dtype_id, read_buf); - CHECK(ret, FAIL, "H5Aread"); - ret = strcmp(read_buf, string); - VERIFY(ret, 0, "strcmp"); - - /* Clean up */ - ret = H5Aclose(attr_id); - CHECK(ret, FAIL, "H5Aclose"); - ret = H5Tclose(dtype_id); - CHECK(ret, FAIL, "H5Tclose"); - ret = H5Sclose(space_id); - CHECK(ret, FAIL, "H5Sclose"); - ret = H5Gclose(group_id); - CHECK(ret, FAIL, "H5Gclose"); + hid_t group_id, attr_id; + hid_t dtype_id, space_id; + hsize_t dims = 1; + char read_buf[MAX_STRING_LENGTH]; + ssize_t size; + herr_t ret; + + /* Create a new group and give it an attribute whose + * name and value are UTF-8 strings. + */ + group_id = H5Gcreate2(fid, GROUP4_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group_id, FAIL, "H5Gcreate2"); + + space_id = H5Screate_simple(RANK, &dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + dtype_id = H5Tcopy(H5T_C_S1); + CHECK(dtype_id, FAIL, "H5Tcopy"); + ret = H5Tset_size(dtype_id, (size_t)MAX_STRING_LENGTH); + CHECK(ret, FAIL, "H5Tset_size"); + + /* Create the attribute and check that its name is correct */ + attr_id = H5Acreate2(group_id, string, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(attr_id, FAIL, "H5Acreate2"); + size = H5Aget_name(attr_id, (size_t)MAX_STRING_LENGTH, read_buf); + CHECK(size, FAIL, "H5Aget_name"); + ret = strcmp(read_buf, string); + VERIFY(ret, 0, "strcmp"); + read_buf[0] = '\0'; + + /* Try writing and reading from the attribute */ + ret = H5Awrite(attr_id, dtype_id, string); + CHECK(ret, FAIL, "H5Awrite"); + ret = H5Aread(attr_id, dtype_id, read_buf); + CHECK(ret, FAIL, "H5Aread"); + ret = strcmp(read_buf, string); + VERIFY(ret, 0, "strcmp"); + + /* Clean up */ + ret = H5Aclose(attr_id); + CHECK(ret, FAIL, "H5Aclose"); + ret = H5Tclose(dtype_id); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Gclose(group_id); + CHECK(ret, FAIL, "H5Gclose"); } /* * test_compound * Test that compound datatypes can have UTF-8 field names. */ -void test_compound(hid_t fid, const char * string) +void +test_compound(hid_t fid, const char *string) { - /* Define two compound structures, s1_t and s2_t. - * s2_t is a subset of s1_t, with two out of three - * fields. - * This is stolen from the h5_compound example. - */ - typedef struct s1_t { - int a; - double c; - float b; - } s1_t; - typedef struct s2_t { - double c; - int a; - } s2_t; - /* Actual variable declarations */ - s1_t s1; - s2_t s2; - hid_t s1_tid, s2_tid; - hid_t space_id, dset_id; - hsize_t dim = 1; - char *readbuf; - herr_t ret; - - /* Initialize compound data */ - HDmemset(&s1, 0, sizeof(s1_t)); /* To make purify happy */ - s1.a = COMP_INT_VAL; - s1.c = COMP_DOUBLE_VAL; - s1.b = COMP_FLOAT_VAL; - - /* Create compound datatypes using UTF-8 field name */ - s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); - CHECK(s1_tid, FAIL, "H5Tcreate"); - ret = H5Tinsert(s1_tid, string, HOFFSET(s1_t, a), H5T_NATIVE_INT); - CHECK(ret, FAIL, "H5Tinsert"); - - /* Check that the field name was stored correctly */ - readbuf = H5Tget_member_name(s1_tid, 0); - ret = HDstrcmp(readbuf, string); - VERIFY(ret, 0, "strcmp"); - H5free_memory(readbuf); - - /* Add the other fields to the datatype */ - ret = H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); - CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); - CHECK(ret, FAIL, "H5Tinsert"); - - /* Create second datatype, with only two fields. */ - s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)); - CHECK(s2_tid, FAIL, "H5Tcreate"); - ret = H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE); - CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(s2_tid, string, HOFFSET(s2_t, a), H5T_NATIVE_INT); - CHECK(ret, FAIL, "H5Tinsert"); - - /* Create the dataspace and dataset. */ - space_id = H5Screate_simple(1, &dim, NULL); - CHECK(space_id, FAIL, "H5Screate_simple"); - dset_id = H5Dcreate2(fid, DSET4_NAME, s1_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dcreate2"); - - /* Write data to the dataset. */ - ret = H5Dwrite(dset_id, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s1); - CHECK(ret, FAIL, "H5Dwrite"); - - /* Ensure that data can be read back by field name into s2 struct */ - ret = H5Dread(dset_id, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s2); - CHECK(ret, FAIL, "H5Dread"); - - VERIFY(s2.a, COMP_INT_VAL, "H5Dread"); - VERIFY(s2.c, COMP_DOUBLE_VAL, "H5Dread"); - - /* Clean up */ - ret = H5Tclose(s1_tid); - CHECK(ret, FAIL, "H5Tclose"); - ret = H5Tclose(s2_tid); - CHECK(ret, FAIL, "H5Tclose"); - ret = H5Sclose(space_id); - CHECK(ret, FAIL, "H5Sclose"); - ret = H5Dclose(dset_id); - CHECK(ret, FAIL, "H5Dclose"); + /* Define two compound structures, s1_t and s2_t. + * s2_t is a subset of s1_t, with two out of three + * fields. + * This is stolen from the h5_compound example. + */ + typedef struct s1_t { + int a; + double c; + float b; + } s1_t; + typedef struct s2_t { + double c; + int a; + } s2_t; + /* Actual variable declarations */ + s1_t s1; + s2_t s2; + hid_t s1_tid, s2_tid; + hid_t space_id, dset_id; + hsize_t dim = 1; + char * readbuf; + herr_t ret; + + /* Initialize compound data */ + HDmemset(&s1, 0, sizeof(s1_t)); /* To make purify happy */ + s1.a = COMP_INT_VAL; + s1.c = COMP_DOUBLE_VAL; + s1.b = COMP_FLOAT_VAL; + + /* Create compound datatypes using UTF-8 field name */ + s1_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); + CHECK(s1_tid, FAIL, "H5Tcreate"); + ret = H5Tinsert(s1_tid, string, HOFFSET(s1_t, a), H5T_NATIVE_INT); + CHECK(ret, FAIL, "H5Tinsert"); + + /* Check that the field name was stored correctly */ + readbuf = H5Tget_member_name(s1_tid, 0); + ret = HDstrcmp(readbuf, string); + VERIFY(ret, 0, "strcmp"); + H5free_memory(readbuf); + + /* Add the other fields to the datatype */ + ret = H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); + CHECK(ret, FAIL, "H5Tinsert"); + ret = H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); + CHECK(ret, FAIL, "H5Tinsert"); + + /* Create second datatype, with only two fields. */ + s2_tid = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); + CHECK(s2_tid, FAIL, "H5Tcreate"); + ret = H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE); + CHECK(ret, FAIL, "H5Tinsert"); + ret = H5Tinsert(s2_tid, string, HOFFSET(s2_t, a), H5T_NATIVE_INT); + CHECK(ret, FAIL, "H5Tinsert"); + + /* Create the dataspace and dataset. */ + space_id = H5Screate_simple(1, &dim, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + dset_id = H5Dcreate2(fid, DSET4_NAME, s1_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dcreate2"); + + /* Write data to the dataset. */ + ret = H5Dwrite(dset_id, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s1); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Ensure that data can be read back by field name into s2 struct */ + ret = H5Dread(dset_id, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s2); + CHECK(ret, FAIL, "H5Dread"); + + VERIFY(s2.a, COMP_INT_VAL, "H5Dread"); + VERIFY(s2.c, COMP_DOUBLE_VAL, "H5Dread"); + + /* Clean up */ + ret = H5Tclose(s1_tid); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Tclose(s2_tid); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); } /* * test_enum * Test that enumerated datatypes can have UTF-8 member names. */ -void test_enum(hid_t H5_ATTR_UNUSED fid, const char * string) +void +test_enum(hid_t H5_ATTR_UNUSED fid, const char *string) { - /* Define an enumerated type */ - typedef enum { - E1_RED, - E1_GREEN, - E1_BLUE, - E1_WHITE - } c_e1; - /* Variable declarations */ - c_e1 val; - herr_t ret; - hid_t type_id; - char readbuf[MAX_STRING_LENGTH]; - - /* Create an enumerated datatype in HDF5 with a UTF-8 member name*/ - type_id = H5Tcreate(H5T_ENUM, sizeof(c_e1)); - CHECK(type_id, FAIL, "H5Tcreate"); - val = E1_RED; - ret = H5Tenum_insert(type_id, "RED", &val); - CHECK(ret, FAIL, "H5Tenum_insert"); - val = E1_GREEN; - ret = H5Tenum_insert(type_id, "GREEN", &val); - CHECK(ret, FAIL, "H5Tenum_insert"); - val = E1_BLUE; - ret = H5Tenum_insert(type_id, "BLUE", &val); - CHECK(ret, FAIL, "H5Tenum_insert"); - val = E1_WHITE; - ret = H5Tenum_insert(type_id, string, &val); - CHECK(ret, FAIL, "H5Tenum_insert"); - - /* Ensure that UTF-8 member name gives the right value and vice versa. */ - ret = H5Tenum_valueof(type_id, string, &val); - CHECK(ret, FAIL, "H5Tenum_valueof"); - VERIFY(val, E1_WHITE, "H5Tenum_valueof"); - ret = H5Tenum_nameof(type_id, &val, readbuf, (size_t)MAX_STRING_LENGTH); - CHECK(ret, FAIL, "H5Tenum_nameof"); - ret = strcmp(readbuf, string); - VERIFY(ret, 0, "strcmp"); - - /* Close the datatype */ - ret = H5Tclose(type_id); - CHECK(ret, FAIL, "H5Tclose"); + /* Define an enumerated type */ + typedef enum { E1_RED, E1_GREEN, E1_BLUE, E1_WHITE } c_e1; + /* Variable declarations */ + c_e1 val; + herr_t ret; + hid_t type_id; + char readbuf[MAX_STRING_LENGTH]; + + /* Create an enumerated datatype in HDF5 with a UTF-8 member name*/ + type_id = H5Tcreate(H5T_ENUM, sizeof(c_e1)); + CHECK(type_id, FAIL, "H5Tcreate"); + val = E1_RED; + ret = H5Tenum_insert(type_id, "RED", &val); + CHECK(ret, FAIL, "H5Tenum_insert"); + val = E1_GREEN; + ret = H5Tenum_insert(type_id, "GREEN", &val); + CHECK(ret, FAIL, "H5Tenum_insert"); + val = E1_BLUE; + ret = H5Tenum_insert(type_id, "BLUE", &val); + CHECK(ret, FAIL, "H5Tenum_insert"); + val = E1_WHITE; + ret = H5Tenum_insert(type_id, string, &val); + CHECK(ret, FAIL, "H5Tenum_insert"); + + /* Ensure that UTF-8 member name gives the right value and vice versa. */ + ret = H5Tenum_valueof(type_id, string, &val); + CHECK(ret, FAIL, "H5Tenum_valueof"); + VERIFY(val, E1_WHITE, "H5Tenum_valueof"); + ret = H5Tenum_nameof(type_id, &val, readbuf, (size_t)MAX_STRING_LENGTH); + CHECK(ret, FAIL, "H5Tenum_nameof"); + ret = strcmp(readbuf, string); + VERIFY(ret, 0, "strcmp"); + + /* Close the datatype */ + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); } /* * test_opaque * Test comments on opaque datatypes */ -void test_opaque(hid_t H5_ATTR_UNUSED fid, const char * string) +void +test_opaque(hid_t H5_ATTR_UNUSED fid, const char *string) { - hid_t type_id; - char * read_buf; - herr_t ret; - - /* Create an opaque type and give it a UTF-8 tag */ - type_id = H5Tcreate(H5T_OPAQUE, (size_t)4); - CHECK(type_id, FAIL, "H5Tcreate"); - ret = H5Tset_tag(type_id, string); - CHECK(ret, FAIL, "H5Tset_tag"); - - /* Read the tag back. */ - read_buf = H5Tget_tag(type_id); - ret = strcmp(read_buf, string); - VERIFY(ret, 0, "H5Tget_tag"); - H5free_memory(read_buf); - - ret = H5Tclose(type_id); - CHECK(ret, FAIL, "H5Tclose"); + hid_t type_id; + char * read_buf; + herr_t ret; + + /* Create an opaque type and give it a UTF-8 tag */ + type_id = H5Tcreate(H5T_OPAQUE, (size_t)4); + CHECK(type_id, FAIL, "H5Tcreate"); + ret = H5Tset_tag(type_id, string); + CHECK(ret, FAIL, "H5Tset_tag"); + + /* Read the tag back. */ + read_buf = H5Tget_tag(type_id); + ret = strcmp(read_buf, string); + VERIFY(ret, 0, "H5Tget_tag"); + H5free_memory(read_buf); + + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); } /*********************/ @@ -724,12 +724,16 @@ void test_opaque(hid_t H5_ATTR_UNUSED fid, const char * string) /* mkstr * Borrwed from dtypes.c. * Creates a new string data type. Used in string padding tests */ -static hid_t mkstr(size_t len, H5T_str_t strpad) +static hid_t +mkstr(size_t len, H5T_str_t strpad) { - hid_t t; - if((t = H5Tcopy(H5T_C_S1)) < 0) return -1; - if(H5Tset_size(t, len) < 0) return -1; - if(H5Tset_strpad(t, strpad) < 0) return -1; + hid_t t; + if ((t = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if (H5Tset_size(t, len) < 0) + return -1; + if (H5Tset_strpad(t, strpad) < 0) + return -1; return t; } @@ -737,124 +741,124 @@ static hid_t mkstr(size_t len, H5T_str_t strpad) * Append a unicode code point c to test_string in UTF-8 encoding. * Return the new end of the string. */ -unsigned int write_char(unsigned int c, char * test_string, unsigned int cur_pos) +unsigned int +write_char(unsigned int c, char *test_string, unsigned int cur_pos) { - if (c < 0x80) { - test_string[cur_pos] = (char)c; - cur_pos++; - } - else if (c < 0x800) { - test_string[cur_pos] = (char)(0xC0 | c >> 6); - test_string[cur_pos + 1] = (char)(0x80 | (c & 0x3F)); - cur_pos += 2; - } - else if (c < 0x10000) { - test_string[cur_pos] = (char)(0xE0 | c >> 12); - test_string[cur_pos + 1] = (char)(0x80 | (c >> 6 & 0x3F)); - test_string[cur_pos + 2] = (char)(0x80 | (c & 0x3F)); - cur_pos += 3; - } - else if (c < 0x200000) { - test_string[cur_pos] = (char)(0xF0 | c >> 18); - test_string[cur_pos + 1] = (char)(0x80 | (c >> 12 & 0x3F)); - test_string[cur_pos + 2] = (char)(0x80 | (c >> 6 & 0x3F)); - test_string[cur_pos + 3] = (char)(0x80 | (c & 0x3F)); - cur_pos += 4; - } - - return cur_pos; + if (c < 0x80) { + test_string[cur_pos] = (char)c; + cur_pos++; + } + else if (c < 0x800) { + test_string[cur_pos] = (char)(0xC0 | c >> 6); + test_string[cur_pos + 1] = (char)(0x80 | (c & 0x3F)); + cur_pos += 2; + } + else if (c < 0x10000) { + test_string[cur_pos] = (char)(0xE0 | c >> 12); + test_string[cur_pos + 1] = (char)(0x80 | (c >> 6 & 0x3F)); + test_string[cur_pos + 2] = (char)(0x80 | (c & 0x3F)); + cur_pos += 3; + } + else if (c < 0x200000) { + test_string[cur_pos] = (char)(0xF0 | c >> 18); + test_string[cur_pos + 1] = (char)(0x80 | (c >> 12 & 0x3F)); + test_string[cur_pos + 2] = (char)(0x80 | (c >> 6 & 0x3F)); + test_string[cur_pos + 3] = (char)(0x80 | (c & 0x3F)); + cur_pos += 4; + } + + return cur_pos; } /* dump_string * Print a string both as text (which will look like garbage) and as hex. * The text display is not guaranteed to be accurate--certain characters * could confuse printf (e.g., '\n'). */ -void dump_string(const char * string) +void +dump_string(const char *string) { - size_t length; - size_t x; + size_t length; + size_t x; - HDprintf("The string was:\n %s", string); - HDprintf("Or in hex:\n"); + HDprintf("The string was:\n %s", string); + HDprintf("Or in hex:\n"); - length = HDstrlen(string); + length = HDstrlen(string); - for(x=0; xp = HDmalloc((j + L2_INCM) * sizeof(unsigned int)); + for (t1 = (hvl_t *)((wdata[i].v).p), j = 0; j < (i + L1_INCM); j++, t1++) { + t1->p = HDmalloc((j + L2_INCM) * sizeof(unsigned int)); t1->len = j + L2_INCM; - for(k = 0; k < j + L2_INCM; k++) - ((unsigned int*)t1->p)[k] = i * 100 + j * 10 + k; + for (k = 0; k < j + L2_INCM; k++) + ((unsigned int *)t1->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1039,11 +1075,11 @@ test_vltypes_compound_vlen_vlen(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a VL datatype to refer to */ - tid3 = H5Tvlen_create (H5T_NATIVE_UINT); + tid3 = H5Tvlen_create(H5T_NATIVE_UINT); CHECK(tid3, FAIL, "H5Tvlen_create"); /* Create a VL datatype to refer to */ - tid1 = H5Tvlen_create (tid3); + tid1 = H5Tvlen_create(tid3); CHECK(tid1, FAIL, "H5Tvlen_create"); /* Create the base compound type */ @@ -1074,7 +1110,6 @@ test_vltypes_compound_vlen_vlen(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -1088,41 +1123,47 @@ test_vltypes_compound_vlen_vlen(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE3_DIM1; i++) { - if(wdata[i].i != rdata[i].i) { - TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n",(int)i,(int)wdata[i].i,(int)i,(int)rdata[i].i); + for (i = 0; i < SPACE3_DIM1; i++) { + if (wdata[i].i != rdata[i].i) { + TestErrPrintf("Integer components don't match!, wdata[%d].i=%d, rdata[%d].i=%d\n", (int)i, + (int)wdata[i].i, (int)i, (int)rdata[i].i); continue; } /* end if */ - if(!H5_FLT_ABS_EQUAL(wdata[i].f,rdata[i].f)) { - TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n",(int)i,(double)wdata[i].f,(int)i,(double)rdata[i].f); + if (!H5_FLT_ABS_EQUAL(wdata[i].f, rdata[i].f)) { + TestErrPrintf("Float components don't match!, wdata[%d].f=%f, rdata[%d].f=%f\n", (int)i, + (double)wdata[i].f, (int)i, (double)rdata[i].f); continue; } /* end if */ - if(wdata[i].v.len != rdata[i].v.len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n",__LINE__,(int)i,(int)wdata[i].v.len,(int)i,(int)rdata[i].v.len); + if (wdata[i].v.len != rdata[i].v.len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n", + __LINE__, (int)i, (int)wdata[i].v.len, (int)i, (int)rdata[i].v.len); continue; } /* end if */ - for(t1=(hvl_t *)(wdata[i].v.p), t2=(hvl_t *)(rdata[i].v.p), j=0; jlen != t2->len) { - TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + for (t1 = (hvl_t *)(wdata[i].v.p), t2 = (hvl_t *)(rdata[i].v.p), j = 0; j < rdata[i].v.len; + j++, t1++, t2++) { + if (t1->len != t2->len) { + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n", + __LINE__, (int)i, (int)j, (int)t1->len, (int)t2->len); continue; } /* end if */ - for(k=0; klen; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k]) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n", (int)k, + (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -1165,48 +1206,44 @@ test_vltypes_compound_vlen_vlen(void) static void test_vltypes_compound_vlstr(void) { - typedef enum { - red, - blue, - green - } e1; + typedef enum { red, blue, green } e1; typedef struct { char *string; - e1 color; + e1 color; } s2; - typedef struct { /* Struct that the compound type are composed of */ + typedef struct { /* Struct that the compound type are composed of */ hvl_t v; } s1; - s1 wdata[SPACE1_DIM1]; /* data to write */ - s1 wdata2[SPACE1_DIM1]; /* data to write */ - s1 rdata[SPACE1_DIM1]; /* data to read */ - s1 rdata2[SPACE1_DIM1]; /* data to read */ - char str[64] = "a\0"; - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, dset2; /* Dataset ID */ - hid_t sid1, sid2, filespace, filespace2; /* Dataspace ID */ - hid_t tid1, tid2, tid3, tid4, tid5; /* Datatype IDs */ + s1 wdata[SPACE1_DIM1]; /* data to write */ + s1 wdata2[SPACE1_DIM1]; /* data to write */ + s1 rdata[SPACE1_DIM1]; /* data to read */ + s1 rdata2[SPACE1_DIM1]; /* data to read */ + char str[64] = "a\0"; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, dset2; /* Dataset ID */ + hid_t sid1, sid2, filespace, filespace2; /* Dataspace ID */ + hid_t tid1, tid2, tid3, tid4, tid5; /* Datatype IDs */ hid_t cparms; - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t chunk_dims[] = {SPACE1_DIM1/2}; - hsize_t maxdims[] = {H5S_UNLIMITED}; - hsize_t size[] = {SPACE1_DIM1}; - hsize_t offset[] = {0}; - unsigned i,j; /* counting variables */ - s2 *t1, *t2; /* Temporary pointer to VL information */ - int val; - herr_t ret; /* Generic return value */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t chunk_dims[] = {SPACE1_DIM1 / 2}; + hsize_t maxdims[] = {H5S_UNLIMITED}; + hsize_t size[] = {SPACE1_DIM1}; + hsize_t offset[] = {0}; + unsigned i, j; /* counting variables */ + s2 * t1, *t2; /* Temporary pointer to VL information */ + int val; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing VL Datatype of Compound Datatype with VL String Functionality\n")); /* Allocate and initialize VL data to write */ - for(i=0; istring = (char*)HDmalloc(HDstrlen(str)*sizeof(char)+1); + t1->string = (char *)HDmalloc(HDstrlen(str) * sizeof(char) + 1); HDstrcpy(t1->string, str); /*t1->color = red;*/ t1->color = blue; @@ -1222,15 +1259,15 @@ test_vltypes_compound_vlstr(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a VL string type*/ - tid4 = H5Tcopy (H5T_C_S1); + tid4 = H5Tcopy(H5T_C_S1); CHECK(tid4, FAIL, "H5Tcopy"); - ret = H5Tset_size (tid4,H5T_VARIABLE); + ret = H5Tset_size(tid4, H5T_VARIABLE); CHECK(ret, FAIL, "H5Tset_size"); /* Create an enum type */ tid3 = H5Tenum_create(H5T_STD_I32LE); - val = 0; - ret = H5Tenum_insert(tid3, "RED", &val); + val = 0; + ret = H5Tenum_insert(tid3, "RED", &val); CHECK(ret, FAIL, "H5Tenum_insert"); val = 1; ret = H5Tenum_insert(tid3, "BLUE", &val); @@ -1243,13 +1280,12 @@ test_vltypes_compound_vlstr(void) tid5 = H5Tcreate(H5T_COMPOUND, sizeof(s2)); CHECK(tid5, FAIL, "H5Tcreate"); /* Insert fields */ - ret=H5Tinsert(tid5, "string", HOFFSET(s2, string), tid4); + ret = H5Tinsert(tid5, "string", HOFFSET(s2, string), tid4); CHECK(ret, FAIL, "H5Tinsert"); /* Insert fields */ - ret=H5Tinsert(tid5, "enumerate", HOFFSET(s2, color), tid3); + ret = H5Tinsert(tid5, "enumerate", HOFFSET(s2, color), tid3); CHECK(ret, FAIL, "H5Tinsert"); - /* Create a VL datatype of first layer compound type */ tid1 = H5Tvlen_create(tid5); CHECK(tid1, FAIL, "H5Tvlen_create"); @@ -1264,7 +1300,7 @@ test_vltypes_compound_vlstr(void) /* Modify dataset creation properties, i.e. enable chunking */ cparms = H5Pcreate(H5P_DATASET_CREATE); - ret = H5Pset_chunk(cparms, SPACE1_RANK, chunk_dims); + ret = H5Pset_chunk(cparms, SPACE1_RANK, chunk_dims); CHECK(ret, FAIL, "H5Pset_chunk"); /* Create a dataset */ @@ -1277,7 +1313,7 @@ test_vltypes_compound_vlstr(void) /* Select a hyperslab */ filespace = H5Dget_space(dataset); - ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims1, NULL); + ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims1, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Write dataset to disk */ @@ -1323,7 +1359,6 @@ test_vltypes_compound_vlstr(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -1341,49 +1376,52 @@ test_vltypes_compound_vlstr(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < SPACE1_DIM1; i++) { - if(wdata[i].v.len != rdata[i].v.len) { - TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n",__LINE__,(int)i,(int)wdata[i].v.len,(int)i,(int)rdata[i].v.len); + for (i = 0; i < SPACE1_DIM1; i++) { + if (wdata[i].v.len != rdata[i].v.len) { + TestErrPrintf("%d: VL data length don't match!, wdata[%d].v.len=%d, rdata[%d].v.len=%d\n", + __LINE__, (int)i, (int)wdata[i].v.len, (int)i, (int)rdata[i].v.len); continue; } /* end if */ - for(t1=(s2 *)(wdata[i].v.p), t2=(s2 *)(rdata[i].v.p), j=0; jstring, t2->string)) { - TestErrPrintf("VL data values don't match!, t1->string=%s, t2->string=%s\n",t1->string, t2->string); - continue; - } /* end if */ - if(t1->color != t2->color) { - TestErrPrintf("VL data values don't match!, t1->color=%d, t2->color=%d\n",t1->color, t2->color); - continue; - } /* end if */ - } /* end for */ - } /* end for */ + for (t1 = (s2 *)(wdata[i].v.p), t2 = (s2 *)(rdata[i].v.p), j = 0; j < rdata[i].v.len; + j++, t1++, t2++) { + if (HDstrcmp(t1->string, t2->string)) { + TestErrPrintf("VL data values don't match!, t1->string=%s, t2->string=%s\n", t1->string, + t2->string); + continue; + } /* end if */ + if (t1->color != t2->color) { + TestErrPrintf("VL data values don't match!, t1->color=%d, t2->color=%d\n", t1->color, + t2->color); + continue; + } /* end if */ + } /* end for */ + } /* end for */ /* Reclaim the VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Use this part for new data */ HDstrcpy(str, "bbbbbbbb\0"); - for(i=0; istring = (char*)HDmalloc(HDstrlen(str)*sizeof(char)+1); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata2[i].v.p = (s2 *)HDmalloc((i + 1) * sizeof(s2)); + wdata2[i].v.len = i + 1; + for (t1 = (s2 *)(wdata2[i].v).p, j = 0; j < i + 1; j++, t1++) { + HDstrcat(str, "pp"); + t1->string = (char *)HDmalloc(HDstrlen(str) * sizeof(char) + 1); HDstrcpy(t1->string, str); - t1->color = green; + t1->color = green; } } /* end for */ /* Select a hyperslab */ - filespace2 = H5Dget_space (dset2); - ret = H5Sselect_hyperslab (filespace2, H5S_SELECT_SET, offset, NULL, - dims1, NULL); + filespace2 = H5Dget_space(dset2); + ret = H5Sselect_hyperslab(filespace2, H5S_SELECT_SET, offset, NULL, dims1, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create dataspace for datasets */ @@ -1391,38 +1429,42 @@ test_vltypes_compound_vlstr(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Write dataset to disk */ - ret=H5Dwrite(dset2,tid2,sid2,filespace2,H5P_DEFAULT, &wdata2); + ret = H5Dwrite(dset2, tid2, sid2, filespace2, H5P_DEFAULT, &wdata2); CHECK(ret, FAIL, "H5Dwrite"); /* Read dataset from disk */ - ret=H5Dread(dset2,tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata2); + ret = H5Dread(dset2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata2); CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i=0; istring, t2->string)) { - TestErrPrintf("VL data values don't match!, t1->string=%s, t2->string=%s\n",t1->string, t2->string); - continue; - } /* end if */ - if(t1->color != t2->color) { - TestErrPrintf("VL data values don't match!, t1->color=%d, t2->color=%d\n",t1->color, t2->color); - continue; - } /* end if */ - } /* end for */ - } /* end for */ + for (t1 = (s2 *)(wdata2[i].v.p), t2 = (s2 *)(rdata2[i].v.p), j = 0; j < rdata2[i].v.len; + j++, t1++, t2++) { + if (HDstrcmp(t1->string, t2->string)) { + TestErrPrintf("VL data values don't match!, t1->string=%s, t2->string=%s\n", t1->string, + t2->string); + continue; + } /* end if */ + if (t1->color != t2->color) { + TestErrPrintf("VL data values don't match!, t1->color=%d, t2->color=%d\n", t1->color, + t2->color); + continue; + } /* end if */ + } /* end for */ + } /* end for */ /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata2); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata2); CHECK(ret, FAIL, "H5Treclaim"); /* Reclaim the VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,rdata2); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, rdata2); CHECK(ret, FAIL, "H5Treclaim"); ret = H5Dclose(dset2); @@ -1458,36 +1500,36 @@ test_vltypes_compound_vlstr(void) static void test_vltypes_compound_vlen_atomic(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; hvl_t v; } s1; - s1 wdata[SPACE1_DIM1]; /* Information to write */ - s1 rdata[SPACE1_DIM1]; /* Information read in */ - s1 fill; /* Fill value */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hid_t dcpl_pid; /* Dataset creation property list ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - herr_t ret; /* Generic return value */ + s1 wdata[SPACE1_DIM1]; /* Information to write */ + s1 rdata[SPACE1_DIM1]; /* Information read in */ + s1 fill; /* Fill value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hid_t dcpl_pid; /* Dataset creation property list ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Compound Datatypes with VL Atomic Datatype Component Functionality\n")); /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { - wdata[i].i = (int)(i * 10); - wdata[i].f = (float)(i * 20) / 3.0F; - wdata[i].v.p = HDmalloc((i + 1)*sizeof(unsigned int)); + for (i = 0; i < SPACE1_DIM1; i++) { + wdata[i].i = (int)(i * 10); + wdata[i].f = (float)(i * 20) / 3.0F; + wdata[i].v.p = HDmalloc((i + 1) * sizeof(unsigned int)); wdata[i].v.len = i + 1; - for(j = 0; j < (i + 1); j++) + for (j = 0; j < (i + 1); j++) ((unsigned int *)wdata[i].v.p)[j] = i * 10 + j; } /* end for */ @@ -1500,7 +1542,7 @@ test_vltypes_compound_vlen_atomic(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a VL datatype to refer to */ - tid1 = H5Tvlen_create (H5T_NATIVE_UINT); + tid1 = H5Tvlen_create(H5T_NATIVE_UINT); CHECK(tid1, FAIL, "H5Tvlen_create"); /* Create the base compound type */ @@ -1527,7 +1569,8 @@ test_vltypes_compound_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory will be used */ @@ -1543,29 +1586,34 @@ test_vltypes_compound_vlen_atomic(void) /* Make certain the correct amount of memory has been used */ /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(mem_used,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dread"); + VERIFY(mem_used, ((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(unsigned int), "H5Dread"); /* Compare data read in */ - for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); - if(t1->p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + wdata[i].len = i + 1; + for (t1 = (hvl_t *)(wdata[i].p), j = 0; j < (i + 1); j++, t1++) { + t1->p = HDmalloc((j + 1) * sizeof(unsigned int)); + if (t1->p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return; } /* end if */ - t1->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)t1->p)[k]=i*100+j*10+k; + t1->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)t1->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1897,11 +1962,11 @@ test_vltypes_vlen_vlen_atomic(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a VL datatype to refer to */ - tid1 = H5Tvlen_create (H5T_NATIVE_UINT); + tid1 = H5Tvlen_create(H5T_NATIVE_UINT); CHECK(tid1, FAIL, "H5Tvlen_create"); /* Create the base VL type */ - tid2 = H5Tvlen_create (tid1); + tid2 = H5Tvlen_create(tid1); CHECK(tid2, FAIL, "H5Tvlen_create"); /* Create a dataset */ @@ -1956,7 +2021,8 @@ test_vltypes_vlen_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory was used */ @@ -1965,7 +2031,10 @@ test_vltypes_vlen_vlen_atomic(void) /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(size, (hsize_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), "H5Dvlen_get_buf_size"); + VERIFY(size, + (hsize_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), + "H5Dvlen_get_buf_size"); /* Read dataset from disk */ ret = H5Dread(dataset, tid2, H5S_ALL, H5S_ALL, xfer_pid, rdata); @@ -1974,37 +2043,43 @@ test_vltypes_vlen_vlen_atomic(void) /* Make certain the correct amount of memory has been used */ /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(mem_used, (size_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), "H5Dread"); + VERIFY(mem_used, + (size_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), + "H5Dread"); /* Compare data read in */ - for(i=0; ilen!=t2->len) { - TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + for (t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)(rdata[i].p), j = 0; j < rdata[i].len; j++, t1++, t2++) { + if (t1->len != t2->len) { + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n", + __LINE__, (int)i, (int)j, (int)t1->len, (int)t2->len); continue; } /* end if */ - for(k=0; klen; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k]) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n", (int)k, + (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim all the (nested) VL data */ - ret=H5Treclaim(tid2,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid2, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -2042,42 +2117,42 @@ test_vltypes_vlen_vlen_atomic(void) static void rewrite_longer_vltypes_vlen_vlen_atomic(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hvl_t *t1, *t2; /* Temporary pointer to VL information */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j,k; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - unsigned increment=1; - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hvl_t * t1, *t2; /* Temporary pointer to VL information */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j, k; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + unsigned increment = 1; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Check memory leak for VL Datatypes with VL Atomic Datatype Component Functionality\n")); /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { wdata[i].p = HDmalloc((i + increment) * sizeof(hvl_t)); - if(wdata[i].p == NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u\n",i); + if (wdata[i].p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u\n", i); return; } /* end if */ wdata[i].len = i + increment; - for(t1 = (hvl_t *)(wdata[i].p), j = 0; j < (i + increment); j++, t1++) { + for (t1 = (hvl_t *)(wdata[i].p), j = 0; j < (i + increment); j++, t1++) { t1->p = HDmalloc((j + 1) * sizeof(unsigned int)); - if(t1->p == NULL) { + if (t1->p == NULL) { TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return; } /* end if */ t1->len = j + 1; - for(k = 0; k < (j + 1); k++) + for (k = 0; k < (j + 1); k++) ((unsigned int *)t1->p)[k] = i * 1000 + j * 100 + k * 10; } /* end for */ - } /* end for */ + } /* end for */ /* Open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); @@ -2115,7 +2190,6 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open the file for data checking */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -2136,7 +2210,8 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory was used */ @@ -2157,34 +2232,38 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) /*VERIFY(mem_used,18*sizeof(hvl_t)+52*sizeof(unsigned int),"H5Dread");*/ /* Compare data read in */ - for(i=0; ilen!=t2->len) { - TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + for (t1 = (hvl_t *)(wdata[i].p), t2 = (hvl_t *)(rdata[i].p), j = 0; j < rdata[i].len; + j++, t1++, t2++) { + if (t1->len != t2->len) { + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n", + __LINE__, (int)i, (int)j, (int)t1->len, (int)t2->len); continue; } /* end if */ - for(k=0; klen; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k]) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n", (int)k, + (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim all the (nested) VL data */ - ret=H5Treclaim(tid2,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid2, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -2218,42 +2297,42 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) static void rewrite_shorter_vltypes_vlen_vlen_atomic(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t rdata[SPACE1_DIM1]; /* Information read in */ - hvl_t *t1, *t2; /* Temporary pointer to VL information */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid2; /* Datatype IDs */ - hid_t xfer_pid; /* Dataset transfer property list ID */ - hsize_t size; /* Number of bytes which will be used */ - unsigned i,j,k; /* counting variables */ - size_t mem_used=0; /* Memory used during allocation */ - unsigned increment=1; - herr_t ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t rdata[SPACE1_DIM1]; /* Information read in */ + hvl_t * t1, *t2; /* Temporary pointer to VL information */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid2; /* Datatype IDs */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t size; /* Number of bytes which will be used */ + unsigned i, j, k; /* counting variables */ + size_t mem_used = 0; /* Memory used during allocation */ + unsigned increment = 1; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Check memory leak for VL Datatypes with VL Atomic Datatype Component Functionality\n")); /* Allocate and initialize VL data to write */ - for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); - if(t1->p==NULL) { - TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + wdata[i].len = i + increment; + for (t1 = (hvl_t *)(wdata[i].p), j = 0; j < (i + increment); j++, t1++) { + t1->p = HDmalloc((j + 1) * sizeof(unsigned int)); + if (t1->p == NULL) { + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return; } /* end if */ - t1->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)t1->p)[k]=i*100000+j*1000+k*10; + t1->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)t1->p)[k] = i * 100000 + j * 1000 + k * 10; } /* end for */ - } /* end for */ + } /* end for */ /* Open file */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); @@ -2291,7 +2370,6 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void) ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - /* Open the file for data checking */ fid1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); @@ -2312,7 +2390,8 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void) xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, &mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Make certain the correct amount of memory was used */ @@ -2321,46 +2400,56 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void) /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(size, (hsize_t)(((SPACE1_DIM1*(SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), "H5Dvlen_get_buf_size"); + VERIFY(size, + (hsize_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), + "H5Dvlen_get_buf_size"); /* Read dataset from disk */ - ret=H5Dread(dataset,tid2,H5S_ALL,H5S_ALL,xfer_pid,rdata); + ret = H5Dread(dataset, tid2, H5S_ALL, H5S_ALL, xfer_pid, rdata); CHECK(ret, FAIL, "H5Dread"); /* Make certain the correct amount of memory has been used */ /* 10 hvl_t elements allocated = 1 + 2 + 3 + 4 elements for each array position */ /* 20 unsigned int elements allocated = 1 + 3 + 6 + 10 elements */ - VERIFY(mem_used, (size_t)(((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(hvl_t)+vlen_size_func((unsigned long)SPACE1_DIM1)*sizeof(unsigned int)),"H5Dread"); + VERIFY(mem_used, + (size_t)(((SPACE1_DIM1 * (SPACE1_DIM1 + 1)) / 2) * sizeof(hvl_t) + + vlen_size_func((unsigned long)SPACE1_DIM1) * sizeof(unsigned int)), + "H5Dread"); /* Compare data read in */ - for(i=0; ilen!=t2->len) { - TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + for (t1 = (hvl_t *)(wdata[i].p), t2 = (hvl_t *)(rdata[i].p), j = 0; j < rdata[i].len; + j++, t1++, t2++) { + if (t1->len != t2->len) { + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n", + __LINE__, (int)i, (int)j, (int)t1->len, (int)t2->len); continue; } /* end if */ - for(k=0; klen; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + for (k = 0; k < t2->len; k++) { + if (((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k]) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n", (int)k, + (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ - } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ /* Reclaim all the (nested) VL data */ - ret=H5Treclaim(tid2,sid1,xfer_pid,rdata); + ret = H5Treclaim(tid2, sid1, xfer_pid, rdata); CHECK(ret, FAIL, "H5Treclaim"); /* Make certain the VL memory has been freed */ - VERIFY(mem_used,0,"H5Treclaim"); + VERIFY(mem_used, 0, "H5Treclaim"); /* Reclaim the write VL data */ - ret=H5Treclaim(tid2,sid1,H5P_DEFAULT,wdata); + ret = H5Treclaim(tid2, sid1, H5P_DEFAULT, wdata); CHECK(ret, FAIL, "H5Treclaim"); /* Close Dataset */ @@ -2396,52 +2485,55 @@ static void test_vltypes_fill_value(void) { typedef struct dtype1_struct { - unsigned int gui; - unsigned int pgui; - const char *str_id; - const char *str_name; - const char *str_desc; - const char *str_orig; - const char *str_stat; - unsigned int ver; - double val; - double ma; - double mi; - const char *str_form; - const char *str_unit; + unsigned int gui; + unsigned int pgui; + const char * str_id; + const char * str_name; + const char * str_desc; + const char * str_orig; + const char * str_stat; + unsigned int ver; + double val; + double ma; + double mi; + const char * str_form; + const char * str_unit; } dtype1_struct; - herr_t ret; - hid_t file_id; - hid_t dtype1_id = -1; - hid_t str_id = -1; - hid_t small_dspace_id; /* Dataspace ID for small datasets */ - hid_t large_dspace_id; /* Dataspace ID for large datasets */ - hid_t small_select_dspace_id; /* Dataspace ID for selection in small datasets */ - hid_t large_select_dspace_id; /* Dataspace ID for selection in large datasets */ - hid_t dset_dspace_id; /* Dataspace ID for a particular dataset */ - hid_t dset_select_dspace_id; /* Dataspace ID for selection in a particular dataset */ - hid_t scalar_dspace_id; /* Dataspace ID for scalar dataspace */ - hid_t single_dspace_id; /* Dataspace ID for single element selection */ - hsize_t single_offset[] = {2}; /* Offset of single element selection */ - hsize_t single_block[] = {1}; /* Block size of single element selection */ - hsize_t select_offset[] = {0}; /* Offset of non-contiguous element selection */ - hsize_t select_stride[] = {2}; /* Stride size of non-contiguous element selection */ - hsize_t small_select_count[] = {SPACE4_DIM_SMALL / 2}; /* Count of small non-contiguous element selection */ - hsize_t large_select_count[] = {SPACE4_DIM_LARGE / 2}; /* Count of large non-contiguous element selection */ - hsize_t select_block[] = {1}; /* Block size of non-contiguous element selection */ - hid_t dcpl_id, xfer_pid; - hid_t dset_id; - hsize_t small_dims[] = {SPACE4_DIM_SMALL}; - hsize_t large_dims[] = {SPACE4_DIM_LARGE}; - size_t dset_elmts; /* Number of elements in a particular dataset */ - const dtype1_struct fill1 = {1, 2, "foobar", "", NULL, "\0", "dead", 3, 4.0F, 100.0F, 1.0F, "liquid", "meter"}; + herr_t ret; + hid_t file_id; + hid_t dtype1_id = -1; + hid_t str_id = -1; + hid_t small_dspace_id; /* Dataspace ID for small datasets */ + hid_t large_dspace_id; /* Dataspace ID for large datasets */ + hid_t small_select_dspace_id; /* Dataspace ID for selection in small datasets */ + hid_t large_select_dspace_id; /* Dataspace ID for selection in large datasets */ + hid_t dset_dspace_id; /* Dataspace ID for a particular dataset */ + hid_t dset_select_dspace_id; /* Dataspace ID for selection in a particular dataset */ + hid_t scalar_dspace_id; /* Dataspace ID for scalar dataspace */ + hid_t single_dspace_id; /* Dataspace ID for single element selection */ + hsize_t single_offset[] = {2}; /* Offset of single element selection */ + hsize_t single_block[] = {1}; /* Block size of single element selection */ + hsize_t select_offset[] = {0}; /* Offset of non-contiguous element selection */ + hsize_t select_stride[] = {2}; /* Stride size of non-contiguous element selection */ + hsize_t small_select_count[] = {SPACE4_DIM_SMALL / + 2}; /* Count of small non-contiguous element selection */ + hsize_t large_select_count[] = {SPACE4_DIM_LARGE / + 2}; /* Count of large non-contiguous element selection */ + hsize_t select_block[] = {1}; /* Block size of non-contiguous element selection */ + hid_t dcpl_id, xfer_pid; + hid_t dset_id; + hsize_t small_dims[] = {SPACE4_DIM_SMALL}; + hsize_t large_dims[] = {SPACE4_DIM_LARGE}; + size_t dset_elmts; /* Number of elements in a particular dataset */ + const dtype1_struct fill1 = {1, 2, "foobar", "", NULL, "\0", "dead", + 3, 4.0F, 100.0F, 1.0F, "liquid", "meter"}; const dtype1_struct wdata = {3, 4, "", NULL, "\0", "foo", "two", 6, 8.0F, 200.0F, 2.0F, "solid", "yard"}; - dtype1_struct *rbuf = NULL; /* Buffer for reading data */ - size_t mem_used = 0; /* Memory used during allocation */ - H5D_layout_t layout; /* Dataset storage layout */ - char dset_name1[64], dset_name2[64]; /* Dataset names */ - unsigned i; + dtype1_struct * rbuf = NULL; /* Buffer for reading data */ + size_t mem_used = 0; /* Memory used during allocation */ + H5D_layout_t layout; /* Dataset storage layout */ + char dset_name1[64], dset_name2[64]; /* Dataset names */ + unsigned i; /* Output message about test being performed */ MESSAGE(5, ("Check fill value for VL data\n")); @@ -2449,62 +2541,60 @@ test_vltypes_fill_value(void) /* Create a string datatype */ str_id = H5Tcopy(H5T_C_S1); CHECK(str_id, FAIL, "H5Tcopy"); - ret = H5Tset_size(str_id,H5T_VARIABLE); + ret = H5Tset_size(str_id, H5T_VARIABLE); CHECK(ret, FAIL, "H5Tset_size"); /* Create a compound data type */ dtype1_id = H5Tcreate(H5T_COMPOUND, sizeof(struct dtype1_struct)); CHECK(dtype1_id, FAIL, "H5Tcreate"); - ret = H5Tinsert(dtype1_id,"guid",HOFFSET(struct dtype1_struct,gui),H5T_NATIVE_UINT); + ret = H5Tinsert(dtype1_id, "guid", HOFFSET(struct dtype1_struct, gui), H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"pguid",HOFFSET(struct dtype1_struct,pgui),H5T_NATIVE_UINT); + ret = H5Tinsert(dtype1_id, "pguid", HOFFSET(struct dtype1_struct, pgui), H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_id",HOFFSET(dtype1_struct,str_id),str_id); + ret = H5Tinsert(dtype1_id, "str_id", HOFFSET(dtype1_struct, str_id), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_name",HOFFSET(dtype1_struct,str_name),str_id); + ret = H5Tinsert(dtype1_id, "str_name", HOFFSET(dtype1_struct, str_name), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_desc",HOFFSET(dtype1_struct,str_desc),str_id); + ret = H5Tinsert(dtype1_id, "str_desc", HOFFSET(dtype1_struct, str_desc), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_orig",HOFFSET(dtype1_struct,str_orig),str_id); + ret = H5Tinsert(dtype1_id, "str_orig", HOFFSET(dtype1_struct, str_orig), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_stat",HOFFSET(dtype1_struct,str_stat),str_id); + ret = H5Tinsert(dtype1_id, "str_stat", HOFFSET(dtype1_struct, str_stat), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"ver",HOFFSET(struct dtype1_struct,ver),H5T_NATIVE_UINT); + ret = H5Tinsert(dtype1_id, "ver", HOFFSET(struct dtype1_struct, ver), H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"val",HOFFSET(struct dtype1_struct,val),H5T_NATIVE_DOUBLE); + ret = H5Tinsert(dtype1_id, "val", HOFFSET(struct dtype1_struct, val), H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"ma",HOFFSET(struct dtype1_struct,ma),H5T_NATIVE_DOUBLE); + ret = H5Tinsert(dtype1_id, "ma", HOFFSET(struct dtype1_struct, ma), H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"mi",HOFFSET(struct dtype1_struct,mi),H5T_NATIVE_DOUBLE); + ret = H5Tinsert(dtype1_id, "mi", HOFFSET(struct dtype1_struct, mi), H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_form",HOFFSET(dtype1_struct,str_form),str_id); + ret = H5Tinsert(dtype1_id, "str_form", HOFFSET(dtype1_struct, str_form), str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"str_unit",HOFFSET(dtype1_struct,str_unit),str_id); + ret = H5Tinsert(dtype1_id, "str_unit", HOFFSET(dtype1_struct, str_unit), str_id); CHECK(ret, FAIL, "H5Tinsert"); /* Close string datatype */ ret = H5Tclose(str_id); CHECK(ret, FAIL, "H5Tclose"); - /* Allocate space for the buffer to read data */ rbuf = (dtype1_struct *)HDmalloc(SPACE4_DIM_LARGE * sizeof(dtype1_struct)); CHECK_PTR(rbuf, "HDmalloc"); - /* Create the small & large dataspaces to use */ small_dspace_id = H5Screate_simple(SPACE4_RANK, small_dims, NULL); CHECK(small_dspace_id, FAIL, "H5Screate_simple"); @@ -2516,15 +2606,15 @@ test_vltypes_fill_value(void) small_select_dspace_id = H5Scopy(small_dspace_id); CHECK(small_select_dspace_id, FAIL, "H5Scopy"); - ret = H5Sselect_hyperslab(small_select_dspace_id, H5S_SELECT_SET, - select_offset, select_stride, small_select_count, select_block); + ret = H5Sselect_hyperslab(small_select_dspace_id, H5S_SELECT_SET, select_offset, select_stride, + small_select_count, select_block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); large_select_dspace_id = H5Scopy(large_dspace_id); CHECK(large_select_dspace_id, FAIL, "H5Scopy"); - ret = H5Sselect_hyperslab(large_select_dspace_id, H5S_SELECT_SET, - select_offset, select_stride, large_select_count, select_block); + ret = H5Sselect_hyperslab(large_select_dspace_id, H5S_SELECT_SET, select_offset, select_stride, + large_select_count, select_block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Create a scalar dataspace */ @@ -2543,32 +2633,32 @@ test_vltypes_fill_value(void) CHECK(file_id, FAIL, "H5Fcreate"); /* Create datasets with different storage layouts */ - for(layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { - unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ - unsigned test_loop; /* Loop over datasets */ + for (layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { + unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ + unsigned test_loop; /* Loop over datasets */ #ifdef H5_HAVE_FILTER_DEFLATE - if(layout == H5D_CHUNKED) + if (layout == H5D_CHUNKED) compress_loop = 2; else #endif /* H5_HAVE_FILTER_DEFLATE */ compress_loop = 1; /* Loop over dataset operations */ - for(test_loop = 0; test_loop < compress_loop; test_loop++) { - hid_t tmp_dcpl_id; /* Temporary copy of the dataset creation property list */ + for (test_loop = 0; test_loop < compress_loop; test_loop++) { + hid_t tmp_dcpl_id; /* Temporary copy of the dataset creation property list */ /* Make a copy of the dataset creation property list */ tmp_dcpl_id = H5Pcopy(dcpl_id); CHECK(tmp_dcpl_id, FAIL, "H5Pcopy"); /* Layout specific actions */ - switch(layout) { + switch (layout) { case H5D_COMPACT: HDstrcpy(dset_name1, "dataset1-compact"); HDstrcpy(dset_name2, "dataset2-compact"); dset_dspace_id = small_dspace_id; - ret = H5Pset_layout(tmp_dcpl_id, H5D_COMPACT); + ret = H5Pset_layout(tmp_dcpl_id, H5D_COMPACT); CHECK(ret, FAIL, "H5Pset_layout"); break; @@ -2578,29 +2668,27 @@ test_vltypes_fill_value(void) dset_dspace_id = large_dspace_id; break; - case H5D_CHUNKED: - { - hsize_t chunk_dims[1] = {SPACE4_DIM_LARGE / 4}; + case H5D_CHUNKED: { + hsize_t chunk_dims[1] = {SPACE4_DIM_LARGE / 4}; - dset_dspace_id = large_dspace_id; - ret = H5Pset_chunk(tmp_dcpl_id, 1, chunk_dims); - CHECK(ret, FAIL, "H5Pset_chunk"); + dset_dspace_id = large_dspace_id; + ret = H5Pset_chunk(tmp_dcpl_id, 1, chunk_dims); + CHECK(ret, FAIL, "H5Pset_chunk"); #ifdef H5_HAVE_FILTER_DEFLATE - if(test_loop == 1) { - HDstrcpy(dset_name1, "dataset1-chunked-compressed"); - HDstrcpy(dset_name2, "dataset2-chunked-compressed"); - ret = H5Pset_deflate(tmp_dcpl_id, 3); - CHECK(ret, FAIL, "H5Pset_deflate"); - } /* end if */ - else { + if (test_loop == 1) { + HDstrcpy(dset_name1, "dataset1-chunked-compressed"); + HDstrcpy(dset_name2, "dataset2-chunked-compressed"); + ret = H5Pset_deflate(tmp_dcpl_id, 3); + CHECK(ret, FAIL, "H5Pset_deflate"); + } /* end if */ + else { #endif /* H5_HAVE_FILTER_DEFLATE */ - HDstrcpy(dset_name1, "dataset1-chunked"); - HDstrcpy(dset_name2, "dataset2-chunked"); + HDstrcpy(dset_name1, "dataset1-chunked"); + HDstrcpy(dset_name2, "dataset2-chunked"); #ifdef H5_HAVE_FILTER_DEFLATE - } /* end else */ -#endif /* H5_HAVE_FILTER_DEFLATE */ - } - break; + } /* end else */ +#endif /* H5_HAVE_FILTER_DEFLATE */ + } break; case H5D_VIRTUAL: assert(0 && "Invalid layout type!"); @@ -2614,13 +2702,13 @@ test_vltypes_fill_value(void) } /* end switch */ /* Create first data set with default setting - no space is allocated */ - dset_id = H5Dcreate2(file_id, dset_name1, dtype1_id, dset_dspace_id, H5P_DEFAULT, tmp_dcpl_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, dset_name1, dtype1_id, dset_dspace_id, H5P_DEFAULT, tmp_dcpl_id, + H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dcreate2"); ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); - /* Create a second data set with space allocated and fill value written */ ret = H5Pset_fill_time(tmp_dcpl_id, H5D_FILL_TIME_IFSET); CHECK(ret, FAIL, "H5Pset_fill_time"); @@ -2628,7 +2716,8 @@ test_vltypes_fill_value(void) ret = H5Pset_alloc_time(tmp_dcpl_id, H5D_ALLOC_TIME_EARLY); CHECK(ret, FAIL, "H5Pset_alloc_time"); - dset_id = H5Dcreate2(file_id, dset_name2, dtype1_id, dset_dspace_id, H5P_DEFAULT, tmp_dcpl_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, dset_name2, dtype1_id, dset_dspace_id, H5P_DEFAULT, tmp_dcpl_id, + H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dcreate2"); ret = H5Dclose(dset_id); @@ -2638,7 +2727,7 @@ test_vltypes_fill_value(void) ret = H5Pclose(tmp_dcpl_id); CHECK(ret, FAIL, "H5Pclose"); } /* end for */ - } /* end for */ + } /* end for */ ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); @@ -2646,12 +2735,12 @@ test_vltypes_fill_value(void) ret = H5Pclose(dcpl_id); CHECK(ret, FAIL, "H5Pclose"); - /* Change to the custom memory allocation routines for reading VL data */ - xfer_pid=H5Pcreate(H5P_DATASET_XFER); + xfer_pid = H5Pcreate(H5P_DATASET_XFER); CHECK(xfer_pid, FAIL, "H5Pcreate"); - ret=H5Pset_vlen_mem_manager(xfer_pid,test_vltypes_alloc_custom,&mem_used,test_vltypes_free_custom,&mem_used); + ret = H5Pset_vlen_mem_manager(xfer_pid, test_vltypes_alloc_custom, &mem_used, test_vltypes_free_custom, + &mem_used); CHECK(ret, FAIL, "H5Pset_vlen_mem_manager"); /* Open the file to check data set value */ @@ -2659,41 +2748,41 @@ test_vltypes_fill_value(void) CHECK(file_id, FAIL, "H5Fopen"); /* Read empty datasets with different storage layouts */ - for(layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { - unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ - unsigned test_loop; /* Loop over datasets */ + for (layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { + unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ + unsigned test_loop; /* Loop over datasets */ #ifdef H5_HAVE_FILTER_DEFLATE - if(layout == H5D_CHUNKED) + if (layout == H5D_CHUNKED) compress_loop = 2; else #endif /* H5_HAVE_FILTER_DEFLATE */ compress_loop = 1; /* Loop over dataset operations */ - for(test_loop = 0; test_loop < compress_loop; test_loop++) { + for (test_loop = 0; test_loop < compress_loop; test_loop++) { /* Layout specific actions */ - switch(layout) { + switch (layout) { case H5D_COMPACT: HDstrcpy(dset_name1, "dataset1-compact"); HDstrcpy(dset_name2, "dataset2-compact"); - dset_dspace_id = small_dspace_id; + dset_dspace_id = small_dspace_id; dset_select_dspace_id = small_select_dspace_id; - dset_elmts = SPACE4_DIM_SMALL; + dset_elmts = SPACE4_DIM_SMALL; break; case H5D_CONTIGUOUS: HDstrcpy(dset_name1, "dataset1-contig"); HDstrcpy(dset_name2, "dataset2-contig"); - dset_dspace_id = large_dspace_id; + dset_dspace_id = large_dspace_id; dset_select_dspace_id = large_select_dspace_id; - dset_elmts = SPACE4_DIM_LARGE; + dset_elmts = SPACE4_DIM_LARGE; break; case H5D_CHUNKED: #ifdef H5_HAVE_FILTER_DEFLATE - if(test_loop == 1) { + if (test_loop == 1) { HDstrcpy(dset_name1, "dataset1-chunked-compressed"); HDstrcpy(dset_name2, "dataset2-chunked-compressed"); } /* end if */ @@ -2703,10 +2792,10 @@ test_vltypes_fill_value(void) HDstrcpy(dset_name2, "dataset2-chunked"); #ifdef H5_HAVE_FILTER_DEFLATE } /* end else */ -#endif /* H5_HAVE_FILTER_DEFLATE */ - dset_dspace_id = large_dspace_id; +#endif /* H5_HAVE_FILTER_DEFLATE */ + dset_dspace_id = large_dspace_id; dset_select_dspace_id = large_select_dspace_id; - dset_elmts = SPACE4_DIM_LARGE; + dset_elmts = SPACE4_DIM_LARGE; break; case H5D_VIRTUAL: @@ -2729,18 +2818,15 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + for (i = 0; i < dset_elmts; i++) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end for */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -2754,28 +2840,24 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if((i % 2) == select_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + for (i = 0; i < dset_elmts; i++) { + if ((i % 2) == select_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc - || rbuf[i].str_orig || rbuf[i].str_stat - || rbuf[i].str_form || rbuf[i].str_unit) { + if (rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc || rbuf[i].str_orig || + rbuf[i].str_stat || rbuf[i].str_form || rbuf[i].str_unit) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -2784,7 +2866,6 @@ test_vltypes_fill_value(void) ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); - /* Open the second data set to check the value of data */ dset_id = H5Dopen2(file_id, dset_name2, H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dopen2"); @@ -2794,18 +2875,15 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end for */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -2819,28 +2897,24 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if((i % 2) == select_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + for (i = 0; i < dset_elmts; i++) { + if ((i % 2) == select_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc - || rbuf[i].str_orig || rbuf[i].str_stat - || rbuf[i].str_form || rbuf[i].str_unit) { + if (rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc || rbuf[i].str_orig || + rbuf[i].str_stat || rbuf[i].str_form || rbuf[i].str_unit) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); @@ -2849,52 +2923,51 @@ test_vltypes_fill_value(void) ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); } /* end for */ - } /* end for */ + } /* end for */ ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); - /* Open the file to check data set value */ file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(file_id, FAIL, "H5Fopen"); /* Write one element & fill values to datasets with different storage layouts */ - for(layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { - unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ - unsigned test_loop; /* Loop over datasets */ + for (layout = H5D_COMPACT; layout <= H5D_CHUNKED; layout++) { + unsigned compress_loop; /* # of times to run loop, for testing compressed chunked dataset */ + unsigned test_loop; /* Loop over datasets */ #ifdef H5_HAVE_FILTER_DEFLATE - if(layout == H5D_CHUNKED) + if (layout == H5D_CHUNKED) compress_loop = 2; else #endif /* H5_HAVE_FILTER_DEFLATE */ compress_loop = 1; /* Loop over dataset operations */ - for(test_loop = 0; test_loop < compress_loop; test_loop++) { + for (test_loop = 0; test_loop < compress_loop; test_loop++) { /* Layout specific actions */ - switch(layout) { + switch (layout) { case H5D_COMPACT: HDstrcpy(dset_name1, "dataset1-compact"); HDstrcpy(dset_name2, "dataset2-compact"); - dset_dspace_id = small_dspace_id; + dset_dspace_id = small_dspace_id; dset_select_dspace_id = small_select_dspace_id; - dset_elmts = SPACE4_DIM_SMALL; + dset_elmts = SPACE4_DIM_SMALL; break; case H5D_CONTIGUOUS: HDstrcpy(dset_name1, "dataset1-contig"); HDstrcpy(dset_name2, "dataset2-contig"); - dset_dspace_id = large_dspace_id; + dset_dspace_id = large_dspace_id; dset_select_dspace_id = large_select_dspace_id; - dset_elmts = SPACE4_DIM_LARGE; + dset_elmts = SPACE4_DIM_LARGE; break; case H5D_CHUNKED: #ifdef H5_HAVE_FILTER_DEFLATE - if(test_loop == 1) { + if (test_loop == 1) { HDstrcpy(dset_name1, "dataset1-chunked-compressed"); HDstrcpy(dset_name2, "dataset2-chunked-compressed"); } /* end if */ @@ -2904,10 +2977,10 @@ test_vltypes_fill_value(void) HDstrcpy(dset_name2, "dataset2-chunked"); #ifdef H5_HAVE_FILTER_DEFLATE } /* end else */ -#endif /* H5_HAVE_FILTER_DEFLATE */ - dset_dspace_id = large_dspace_id; +#endif /* H5_HAVE_FILTER_DEFLATE */ + dset_dspace_id = large_dspace_id; dset_select_dspace_id = large_select_dspace_id; - dset_elmts = SPACE4_DIM_LARGE; + dset_elmts = SPACE4_DIM_LARGE; break; case H5D_VIRTUAL: @@ -2926,8 +2999,8 @@ test_vltypes_fill_value(void) CHECK(single_dspace_id, FAIL, "H5Scopy"); /* Set a single element in the dataspace */ - ret = H5Sselect_hyperslab(single_dspace_id, H5S_SELECT_SET, single_offset, - NULL, single_block, NULL); + ret = H5Sselect_hyperslab(single_dspace_id, H5S_SELECT_SET, single_offset, NULL, single_block, + NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Open first data set */ @@ -2942,32 +3015,28 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(i == single_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, wdata.str_id) - || rbuf[i].str_name - || HDstrcmp(rbuf[i].str_desc, wdata.str_desc) - || HDstrcmp(rbuf[i].str_orig, wdata.str_orig) - || HDstrcmp(rbuf[i].str_stat, wdata.str_stat) - || HDstrcmp(rbuf[i].str_form, wdata.str_form) - || HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (i == single_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, wdata.str_id) || rbuf[i].str_name || + HDstrcmp(rbuf[i].str_desc, wdata.str_desc) || + HDstrcmp(rbuf[i].str_orig, wdata.str_orig) || + HDstrcmp(rbuf[i].str_stat, wdata.str_stat) || + HDstrcmp(rbuf[i].str_form, wdata.str_form) || + HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig,"\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -2981,42 +3050,37 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(i == single_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, wdata.str_id) - || rbuf[i].str_name - || HDstrcmp(rbuf[i].str_desc, wdata.str_desc) - || HDstrcmp(rbuf[i].str_orig, wdata.str_orig) - || HDstrcmp(rbuf[i].str_stat, wdata.str_stat) - || HDstrcmp(rbuf[i].str_form, wdata.str_form) - || HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (i == single_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, wdata.str_id) || rbuf[i].str_name || + HDstrcmp(rbuf[i].str_desc, wdata.str_desc) || + HDstrcmp(rbuf[i].str_orig, wdata.str_orig) || + HDstrcmp(rbuf[i].str_stat, wdata.str_stat) || + HDstrcmp(rbuf[i].str_form, wdata.str_form) || + HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if((i % 2) == select_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + if ((i % 2) == select_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc - || rbuf[i].str_orig || rbuf[i].str_stat - || rbuf[i].str_form || rbuf[i].str_unit) { + if (rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc || rbuf[i].str_orig || + rbuf[i].str_stat || rbuf[i].str_form || rbuf[i].str_unit) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end else */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end else */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); @@ -3025,7 +3089,6 @@ test_vltypes_fill_value(void) ret = H5Dclose(dset_id); CHECK(ret, FAIL, "H5Dclose"); - /* Open the second data set to check the value of data */ dset_id = H5Dopen2(file_id, dset_name2, H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dopen2"); @@ -3038,32 +3101,28 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(i == single_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, wdata.str_id) - || rbuf[i].str_name - || HDstrcmp(rbuf[i].str_desc, wdata.str_desc) - || HDstrcmp(rbuf[i].str_orig, wdata.str_orig) - || HDstrcmp(rbuf[i].str_stat, wdata.str_stat) - || HDstrcmp(rbuf[i].str_form, wdata.str_form) - || HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (i == single_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, wdata.str_id) || rbuf[i].str_name || + HDstrcmp(rbuf[i].str_desc, wdata.str_desc) || + HDstrcmp(rbuf[i].str_orig, wdata.str_orig) || + HDstrcmp(rbuf[i].str_stat, wdata.str_stat) || + HDstrcmp(rbuf[i].str_form, wdata.str_form) || + HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig,"\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf); @@ -3077,42 +3136,37 @@ test_vltypes_fill_value(void) CHECK(ret, FAIL, "H5Dread"); /* Compare data read in */ - for(i = 0; i < dset_elmts; i++) { - if(i == single_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, wdata.str_id) - || rbuf[i].str_name - || HDstrcmp(rbuf[i].str_desc, wdata.str_desc) - || HDstrcmp(rbuf[i].str_orig, wdata.str_orig) - || HDstrcmp(rbuf[i].str_stat, wdata.str_stat) - || HDstrcmp(rbuf[i].str_form, wdata.str_form) - || HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { - TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + for (i = 0; i < dset_elmts; i++) { + if (i == single_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, wdata.str_id) || rbuf[i].str_name || + HDstrcmp(rbuf[i].str_desc, wdata.str_desc) || + HDstrcmp(rbuf[i].str_orig, wdata.str_orig) || + HDstrcmp(rbuf[i].str_stat, wdata.str_stat) || + HDstrcmp(rbuf[i].str_form, wdata.str_form) || + HDstrcmp(rbuf[i].str_unit, wdata.str_unit)) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if((i % 2) == select_offset[0]) { - if(HDstrcmp(rbuf[i].str_id, "foobar") - || HDstrcmp(rbuf[i].str_name, "") - || rbuf[i].str_desc - || HDstrcmp(rbuf[i].str_orig, "\0") - || HDstrcmp(rbuf[i].str_stat, "dead") - || HDstrcmp(rbuf[i].str_form, "liquid") - || HDstrcmp(rbuf[i].str_unit, "meter")) { + if ((i % 2) == select_offset[0]) { + if (HDstrcmp(rbuf[i].str_id, "foobar") || HDstrcmp(rbuf[i].str_name, "") || + rbuf[i].str_desc || HDstrcmp(rbuf[i].str_orig, "\0") || + HDstrcmp(rbuf[i].str_stat, "dead") || HDstrcmp(rbuf[i].str_form, "liquid") || + HDstrcmp(rbuf[i].str_unit, "meter")) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end if */ + } /* end if */ else { - if(rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc - || rbuf[i].str_orig || rbuf[i].str_stat - || rbuf[i].str_form || rbuf[i].str_unit) { + if (rbuf[i].str_id || rbuf[i].str_name || rbuf[i].str_desc || rbuf[i].str_orig || + rbuf[i].str_stat || rbuf[i].str_form || rbuf[i].str_unit) { TestErrPrintf("%d: VL data doesn't match!, index(i) = %d\n", __LINE__, (int)i); continue; } /* end if */ - } /* end else */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end else */ + } /* end for */ /* Release the space */ ret = H5Treclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf); @@ -3125,12 +3179,11 @@ test_vltypes_fill_value(void) ret = H5Sclose(single_dspace_id); CHECK(ret, FAIL, "H5Sclose"); } /* end for */ - } /* end for */ + } /* end for */ ret = H5Fclose(file_id); CHECK(ret, FAIL, "H5Fclose"); - /* Clean up rest of IDs */ ret = H5Pclose(xfer_pid); CHECK(ret, FAIL, "H5Pclose"); @@ -3169,23 +3222,22 @@ test_vltypes(void) MESSAGE(5, ("Testing Variable-Length Datatypes\n")); /* These next tests use the same file */ - test_vltypes_dataset_create(); /* Check dataset of VL when fill value - * won't be rewritten to it.*/ - test_vltypes_funcs(); /* Test functions with VL types */ - test_vltypes_vlen_atomic(); /* Test VL atomic datatypes */ - rewrite_vltypes_vlen_atomic(); /* Check VL memory leak */ - test_vltypes_vlen_compound(); /* Test VL compound datatypes */ - rewrite_vltypes_vlen_compound(); /* Check VL memory leak */ - test_vltypes_compound_vlen_atomic(); /* Test compound datatypes with VL atomic components */ - rewrite_vltypes_compound_vlen_atomic();/* Check VL memory leak */ - test_vltypes_vlen_vlen_atomic(); /* Test VL datatype with VL atomic components */ + test_vltypes_dataset_create(); /* Check dataset of VL when fill value + * won't be rewritten to it.*/ + test_vltypes_funcs(); /* Test functions with VL types */ + test_vltypes_vlen_atomic(); /* Test VL atomic datatypes */ + rewrite_vltypes_vlen_atomic(); /* Check VL memory leak */ + test_vltypes_vlen_compound(); /* Test VL compound datatypes */ + rewrite_vltypes_vlen_compound(); /* Check VL memory leak */ + test_vltypes_compound_vlen_atomic(); /* Test compound datatypes with VL atomic components */ + rewrite_vltypes_compound_vlen_atomic(); /* Check VL memory leak */ + test_vltypes_vlen_vlen_atomic(); /* Test VL datatype with VL atomic components */ rewrite_longer_vltypes_vlen_vlen_atomic(); /*overwrite with VL data of longer sequence*/ - rewrite_shorter_vltypes_vlen_vlen_atomic(); /*overwrite with VL data of shorted sequence*/ - test_vltypes_compound_vlen_vlen();/* Test compound datatypes with VL atomic components */ - test_vltypes_compound_vlstr(); /* Test data rewritten of nested VL data */ - test_vltypes_fill_value(); /* Test fill value for VL data */ -} /* test_vltypes() */ - + rewrite_shorter_vltypes_vlen_vlen_atomic(); /*overwrite with VL data of shorted sequence*/ + test_vltypes_compound_vlen_vlen(); /* Test compound datatypes with VL atomic components */ + test_vltypes_compound_vlstr(); /* Test data rewritten of nested VL data */ + test_vltypes_fill_value(); /* Test fill value for VL data */ +} /* test_vltypes() */ /*------------------------------------------------------------------------- * Function: cleanup_vltypes diff --git a/test/twriteorder.c b/test/twriteorder.c index 04f3bc5..83a615c 100644 --- a/test/twriteorder.c +++ b/test/twriteorder.c @@ -11,52 +11,52 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: twriteorder -* -* Test to verify that the write order is strictly consistent. -* The SWMR feature requires that the order of write is strictly consistent. -* "Strict consistency in computer science is the most stringent consistency -* model. It says that a read operation has to return the result of the -* latest write operation which occurred on that data item."-- -* (http://en.wikipedia.org/wiki/Linearizability#Definition_of_linearizability). -* This is also an alternative form of what POSIX write require that after a -* write operation has returned success, all reads issued afterward should -* get the same data the write has written. -* -* Created: Albert Cheng, 2013/8/28. -*************************************************************/ + * + * Test program: twriteorder + * + * Test to verify that the write order is strictly consistent. + * The SWMR feature requires that the order of write is strictly consistent. + * "Strict consistency in computer science is the most stringent consistency + * model. It says that a read operation has to return the result of the + * latest write operation which occurred on that data item."-- + * (http://en.wikipedia.org/wiki/Linearizability#Definition_of_linearizability). + * This is also an alternative form of what POSIX write require that after a + * write operation has returned success, all reads issued afterward should + * get the same data the write has written. + * + * Created: Albert Cheng, 2013/8/28. + *************************************************************/ /*********************************************************** -* -* Algorithm -* -* The test simulates what SWMR does by writing chained blocks and see if -* they can be read back correctly. -* There is a writer process and multiple read processes. -* The file is divided into 2KB partitions. Then writer writes 1 chained -* block, each of 1KB big, in each partition after the first partition. -* Each chained block has this structure: -* Byte 0-3: offset address of its child block. The last child uses 0 as NULL. -* Byte 4-1023: some artificial data. -* The child block address of Block 1 is NULL (0). -* The child block address of Block 2 is the offset address of Block 1. -* The child block address of Block n is the offset address of Block n-1. -* After all n blocks are written, the offset address of Block n is written -* to the offset 0 of the first partition. -* Therefore, by the time the offset address of Block n is written to this -* position, all n chain-linked blocks have been written. -* -* The other reader processes will try to read the address value at the -* offset 0. The value is initially NULL(0). When it changes to non-zero, -* it signifies the writer process has written all the chain-link blocks -* and they are ready for the reader processes to access. -* -* If the system, in which the writer and reader processes run, the readers -* will always get all chain-linked blocks correctly. If the order of write -* is not maintained, some reader processes may found unexpect block data. -* -*************************************************************/ + * + * Algorithm + * + * The test simulates what SWMR does by writing chained blocks and see if + * they can be read back correctly. + * There is a writer process and multiple read processes. + * The file is divided into 2KB partitions. Then writer writes 1 chained + * block, each of 1KB big, in each partition after the first partition. + * Each chained block has this structure: + * Byte 0-3: offset address of its child block. The last child uses 0 as NULL. + * Byte 4-1023: some artificial data. + * The child block address of Block 1 is NULL (0). + * The child block address of Block 2 is the offset address of Block 1. + * The child block address of Block n is the offset address of Block n-1. + * After all n blocks are written, the offset address of Block n is written + * to the offset 0 of the first partition. + * Therefore, by the time the offset address of Block n is written to this + * position, all n chain-linked blocks have been written. + * + * The other reader processes will try to read the address value at the + * offset 0. The value is initially NULL(0). When it changes to non-zero, + * it signifies the writer process has written all the chain-link blocks + * and they are ready for the reader processes to access. + * + * If the system, in which the writer and reader processes run, the readers + * will always get all chain-linked blocks correctly. If the order of write + * is not maintained, some reader processes may found unexpect block data. + * + *************************************************************/ #include "h5test.h" @@ -67,34 +67,38 @@ */ #ifdef H5_HAVE_FORK -#define DATAFILE "twriteorder.dat" -/* #define READERS_MAX 10 */ /* max number of readers */ -#define BLOCKSIZE_DFT 1024 /* 1KB */ -#define PARTITION_DFT 2048 /* 2KB */ -#define NLINKEDBLOCKS_DFT 512 /* default 512 */ -#define SIZE_BLKADDR 4 /* expected sizeof blkaddr */ -#define Hgoto_error(val) {ret_value=val; goto done;} +#define DATAFILE "twriteorder.dat" +/* #define READERS_MAX 10 */ /* max number of readers */ +#define BLOCKSIZE_DFT 1024 /* 1KB */ +#define PARTITION_DFT 2048 /* 2KB */ +#define NLINKEDBLOCKS_DFT 512 /* default 512 */ +#define SIZE_BLKADDR 4 /* expected sizeof blkaddr */ +#define Hgoto_error(val) \ + { \ + ret_value = val; \ + goto done; \ + } /* type declarations */ typedef enum part_t { - UC_READWRITE = 0, /* both writer and reader */ - UC_WRITER, /* writer only */ - UC_READER /* reader only */ + UC_READWRITE = 0, /* both writer and reader */ + UC_WRITER, /* writer only */ + UC_READER /* reader only */ } part_t; /* prototypes */ -int create_wo_file(void); -int write_wo_file(void); -int read_wo_file(void); +int create_wo_file(void); +int write_wo_file(void); +int read_wo_file(void); void usage(const char *prog); -int setup_parameters(int argc, char * const argv[]); -int parse_option(int argc, char * const argv[]); +int setup_parameters(int argc, char *const argv[]); +int parse_option(int argc, char *const argv[]); /* Global Variable definitions */ -const char *progname_g="twriteorder"; /* program name */ -int write_fd_g; -int blocksize_g, part_size_g, nlinkedblock_g; -part_t launch_g; +const char *progname_g = "twriteorder"; /* program name */ +int write_fd_g; +int blocksize_g, part_size_g, nlinkedblock_g; +part_t launch_g; /* Function definitions */ @@ -116,9 +120,9 @@ usage(const char *prog) /* Setup test parameters by parsing command line options. * Setup default values if not set by options. */ int -parse_option(int argc, char * const argv[]) +parse_option(int argc, char *const argv[]) { - int ret_value=0; + int ret_value = 0; int c; /* command line options: See function usage for a description */ const char *cmd_options = "hb:l:n:p:"; @@ -127,7 +131,7 @@ parse_option(int argc, char * const argv[]) opterr = 0; while (1) { - c = getopt (argc, argv, cmd_options); + c = getopt(argc, argv, cmd_options); if (-1 == c) break; @@ -136,33 +140,33 @@ parse_option(int argc, char * const argv[]) usage(progname_g); HDexit(EXIT_SUCCESS); break; - case 'b': /* number of planes to write/read */ + case 'b': /* number of planes to write/read */ if ((blocksize_g = atoi(optarg)) <= 0) { HDfprintf(stderr, "bad blocksize %s, must be a positive integer\n", optarg); usage(progname_g); Hgoto_error(-1); }; break; - case 'n': /* number of planes to write/read */ + case 'n': /* number of planes to write/read */ if ((nlinkedblock_g = atoi(optarg)) < 2) { HDfprintf(stderr, "bad number of linked blocks %s, must be greater than 1.\n", optarg); usage(progname_g); Hgoto_error(-1); }; break; - case 'p': /* number of planes to write/read */ + case 'p': /* number of planes to write/read */ if ((part_size_g = atoi(optarg)) <= 0) { HDfprintf(stderr, "bad partition size %s, must be a positive integer\n", optarg); usage(progname_g); Hgoto_error(-1); }; break; - case 'l': /* launch reader or writer only */ + case 'l': /* launch reader or writer only */ switch (*optarg) { - case 'r': /* reader only */ + case 'r': /* reader only */ launch_g = UC_READER; break; - case 'w': /* writer only */ + case 'w': /* writer only */ launch_g = UC_WRITER; break; default: @@ -182,11 +186,12 @@ parse_option(int argc, char * const argv[]) HDfprintf(stderr, "Unexpected value is %d\n", c); Hgoto_error(-1); } /* end outer switch */ - } /* end while */ + } /* end while */ /* verify partition size must be >= blocksize */ - if (part_size_g < blocksize_g ){ - HDfprintf(stderr, "Blocksize %d should not be bigger than partition size %d\n", blocksize_g, part_size_g); + if (part_size_g < blocksize_g) { + HDfprintf(stderr, "Blocksize %d should not be bigger than partition size %d\n", blocksize_g, + part_size_g); Hgoto_error(-1); } @@ -198,16 +203,17 @@ done: /* Setup parameters for the test case. * Return: 0 succeed; -1 fail. */ -int setup_parameters(int argc, char * const argv[]) +int +setup_parameters(int argc, char *const argv[]) { /* test case defaults */ - blocksize_g = BLOCKSIZE_DFT; - part_size_g = PARTITION_DFT; + blocksize_g = BLOCKSIZE_DFT; + part_size_g = PARTITION_DFT; nlinkedblock_g = NLINKEDBLOCKS_DFT; - launch_g = UC_READWRITE; + launch_g = UC_READWRITE; /* parse options */ - if (parse_option(argc, argv) < 0){ + if (parse_option(argc, argv) < 0) { return -1; } @@ -225,19 +231,20 @@ int setup_parameters(int argc, char * const argv[]) * * Return: 0 succeed; -1 fail. */ -int create_wo_file(void) +int +create_wo_file(void) { - int blkaddr = 0; /* blkaddress of next linked block */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ + int blkaddr = 0; /* blkaddress of next linked block */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Create the data file */ - if ((write_fd_g = HDopen(DATAFILE, O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) { + if ((write_fd_g = HDopen(DATAFILE, O_RDWR | O_TRUNC | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) { HDprintf("WRITER: error from open\n"); return -1; } blkaddr = 0; /* write it to partition 0 */ - if ((bytes_wrote = HDwrite(write_fd_g, &blkaddr, (size_t)SIZE_BLKADDR)) != SIZE_BLKADDR){ + if ((bytes_wrote = HDwrite(write_fd_g, &blkaddr, (size_t)SIZE_BLKADDR)) != SIZE_BLKADDR) { HDprintf("blkaddr write failed\n"); return -1; } @@ -246,14 +253,14 @@ int create_wo_file(void) return 0; } -int write_wo_file(void) +int +write_wo_file(void) { - int blkaddr; - int blkaddr_old=0; - int i; - char buffer[BLOCKSIZE_DFT]; - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ - + int blkaddr; + int blkaddr_old = 0; + int i; + char buffer[BLOCKSIZE_DFT]; + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* write block 1, 2, ... */ for (i = 1; i < nlinkedblock_g; i++) { @@ -265,14 +272,14 @@ int write_wo_file(void) HDmemcpy(&buffer[0], &blkaddr_old, sizeof(blkaddr_old)); /* fill the rest with the lowest byte of i */ - HDmemset(&buffer[4], i & 0xff, (size_t) (BLOCKSIZE_DFT-4)); + HDmemset(&buffer[4], i & 0xff, (size_t)(BLOCKSIZE_DFT - 4)); /* write the block */ #ifdef DEBUG HDprintf("writing block at %d\n", blkaddr); #endif HDlseek(write_fd_g, (HDoff_t)blkaddr, SEEK_SET); - if ((bytes_wrote = HDwrite(write_fd_g, buffer, (size_t)blocksize_g)) != blocksize_g){ + if ((bytes_wrote = HDwrite(write_fd_g, buffer, (size_t)blocksize_g)) != blocksize_g) { HDprintf("blkaddr write failed in partition %d\n", i); return -1; } @@ -283,7 +290,8 @@ int write_wo_file(void) /* write the last blkaddr in partition 0 */ HDlseek(write_fd_g, (HDoff_t)0, SEEK_SET); - if ((bytes_wrote = HDwrite(write_fd_g, &blkaddr_old, (size_t)sizeof(blkaddr_old))) != sizeof(blkaddr_old)){ + if ((bytes_wrote = HDwrite(write_fd_g, &blkaddr_old, (size_t)sizeof(blkaddr_old))) != + sizeof(blkaddr_old)) { HDprintf("blkaddr write failed in partition %d\n", 0); return -1; } @@ -295,13 +303,14 @@ int write_wo_file(void) return 0; } -int read_wo_file(void) +int +read_wo_file(void) { - int read_fd; - int blkaddr = 0; - h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ - int linkedblocks_read = 0; - char buffer[BLOCKSIZE_DFT]; + int read_fd; + int blkaddr = 0; + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ + int linkedblocks_read = 0; + char buffer[BLOCKSIZE_DFT]; /* Open the data file */ if ((read_fd = HDopen(DATAFILE, O_RDONLY)) < 0) { @@ -325,7 +334,7 @@ int read_wo_file(void) #endif while (blkaddr != 0) { HDlseek(read_fd, (HDoff_t)blkaddr, SEEK_SET); - if ((bytes_read = HDread(read_fd, buffer, (size_t)blocksize_g)) != blocksize_g){ + if ((bytes_read = HDread(read_fd, buffer, (size_t)blocksize_g)) != blocksize_g) { HDprintf("blkaddr read failed in partition %d\n", 0); return -1; } @@ -344,7 +353,6 @@ int read_wo_file(void) return 0; } - /* Overall Algorithm: * Parse options from user; * Generate/pre-created the test file needed and close it; @@ -357,15 +365,15 @@ main(int argc, char *argv[]) { /*pid_t childpid[READERS_MAX]; int child_ret_value[READERS_MAX];*/ - pid_t childpid=0; - int child_ret_value; + pid_t childpid = 0; + int child_ret_value; pid_t mypid, tmppid; - int child_status; - int child_wait_option=0; - int ret_value = 0; + int child_status; + int child_wait_option = 0; + int ret_value = 0; /* initialization */ - if (setup_parameters(argc, argv) < 0){ + if (setup_parameters(argc, argv) < 0) { Hgoto_error(1); } @@ -389,9 +397,9 @@ main(int argc, char *argv[]) /* flush output before possible fork */ HDfflush(stdout); - if (launch_g==UC_READWRITE) { + if (launch_g == UC_READWRITE) { /* fork process */ - if((childpid = HDfork()) < 0) { + if ((childpid = HDfork()) < 0) { HDperror("fork"); Hgoto_error(1); }; @@ -403,7 +411,7 @@ main(int argc, char *argv[]) /* ============= */ if (launch_g != UC_WRITER) { /* child process launch the reader */ - if(0 == childpid) { + if (0 == childpid) { HDprintf("%d: launch reader process\n", mypid); if (read_wo_file() < 0) { HDfprintf(stderr, "read_wo_file encountered error\n"); @@ -437,7 +445,7 @@ main(int argc, char *argv[]) Hgoto_error(1); } if (WIFEXITED(child_status)) { - if ((child_ret_value=WEXITSTATUS(child_status)) != 0) { + if ((child_ret_value = WEXITSTATUS(child_status)) != 0) { HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(2); } @@ -450,7 +458,7 @@ main(int argc, char *argv[]) done: /* Print result and exit */ - if (ret_value != 0){ + if (ret_value != 0) { HDprintf("Error(s) encountered\n"); } else { @@ -470,4 +478,3 @@ main(void) } /* end main() */ #endif /* H5_HAVE_FORK */ - diff --git a/test/unlink.c b/test/unlink.c index 16d5d0c..e148e77 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -18,65 +18,53 @@ * Purpose: Test unlinking operations. */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ /* Define this macro to indicate that the testing APIs should be available */ #define H5G_TESTING #include "h5test.h" -#include "H5Gpkg.h" /* Groups */ - -const char *FILENAME[] = { - "unlink", - "new_move_a", - "new_move_b", - "lunlink", - "filespace", - "slashes", - "resurrect_set", - "resurrect_type", - "resurrect_group", - "unlink_chunked", - "full_group", - NULL -}; +#include "H5Gpkg.h" /* Groups */ -/* Macros for test_create_unlink() & test_filespace */ -#define GROUPNAME "group" -#define GROUP2NAME "group2" -#define UNLINK_NGROUPS 1000 -#define DATASETNAME "dataset" -#define DATASET2NAME "dataset2" -#define ATTRNAME "attribute" -#define TYPENAME "datatype" -#define TYPE2NAME "datatype2" -#define FILESPACE_NDIMS 3 -#define FILESPACE_DIM0 20 -#define FILESPACE_DIM1 20 -#define FILESPACE_DIM2 20 -#define FILESPACE_CHUNK0 10 -#define FILESPACE_CHUNK1 10 -#define FILESPACE_CHUNK2 10 -#define FILESPACE_DEFLATE_LEVEL 6 -#define FILESPACE_REWRITE 10 -#define FILESPACE_NATTR 100 -#define FILESPACE_ATTR_NDIMS 2 -#define FILESPACE_ATTR_DIM0 5 -#define FILESPACE_ATTR_DIM1 5 -#define FILESPACE_TOP_GROUPS 10 -#define FILESPACE_NESTED_GROUPS 50 -#define FILESPACE_NDATASETS 50 -#define SLASHES_GROUP_NAME "Group///" -#define SLASHES_HARDLINK_NAME "Hard///" -#define SLASHES_SOFTLINK_NAME "Soft///" -#define SLASHES_SOFTLINK2_NAME "Soft2///" -#define SLASHES_ROOTLINK_NAME "Root///" -#define FULL_GROUP_NUM_KEEP 2 -#define FULL_GROUP_NUM_DELETE_COMPACT 2 -#define FULL_GROUP_NUM_DELETE_DENSE 16 -#define FULL_GROUP_EST_NUM_ENTRIES 8 -#define FULL_GROUP_EST_ENTRY_LEN 9 +const char *FILENAME[] = {"unlink", "new_move_a", "new_move_b", "lunlink", + "filespace", "slashes", "resurrect_set", "resurrect_type", + "resurrect_group", "unlink_chunked", "full_group", NULL}; +/* Macros for test_create_unlink() & test_filespace */ +#define GROUPNAME "group" +#define GROUP2NAME "group2" +#define UNLINK_NGROUPS 1000 +#define DATASETNAME "dataset" +#define DATASET2NAME "dataset2" +#define ATTRNAME "attribute" +#define TYPENAME "datatype" +#define TYPE2NAME "datatype2" +#define FILESPACE_NDIMS 3 +#define FILESPACE_DIM0 20 +#define FILESPACE_DIM1 20 +#define FILESPACE_DIM2 20 +#define FILESPACE_CHUNK0 10 +#define FILESPACE_CHUNK1 10 +#define FILESPACE_CHUNK2 10 +#define FILESPACE_DEFLATE_LEVEL 6 +#define FILESPACE_REWRITE 10 +#define FILESPACE_NATTR 100 +#define FILESPACE_ATTR_NDIMS 2 +#define FILESPACE_ATTR_DIM0 5 +#define FILESPACE_ATTR_DIM1 5 +#define FILESPACE_TOP_GROUPS 10 +#define FILESPACE_NESTED_GROUPS 50 +#define FILESPACE_NDATASETS 50 +#define SLASHES_GROUP_NAME "Group///" +#define SLASHES_HARDLINK_NAME "Hard///" +#define SLASHES_SOFTLINK_NAME "Soft///" +#define SLASHES_SOFTLINK2_NAME "Soft2///" +#define SLASHES_ROOTLINK_NAME "Root///" +#define FULL_GROUP_NUM_KEEP 2 +#define FULL_GROUP_NUM_DELETE_COMPACT 2 +#define FULL_GROUP_NUM_DELETE_DENSE 16 +#define FULL_GROUP_EST_NUM_ENTRIES 8 +#define FULL_GROUP_EST_ENTRY_LEN 9 /*------------------------------------------------------------------------- * Function: test_one @@ -98,51 +86,64 @@ const char *FILENAME[] = { static int test_one(hid_t file) { - hid_t work = -1, grp = -1; - herr_t status; + hid_t work = -1, grp = -1; + herr_t status; /* Create a test group */ - if((work = H5Gcreate2(file, "/test_one", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((work = H5Gcreate2(file, "/test_one", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete by absolute name */ TESTING("unlink by absolute name"); - if((grp = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR - if(H5Ldelete(file, "/test_one/foo", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((grp = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grp) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(file, "/test_one/foo", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR PASSED(); /* Delete by local name */ TESTING("unlink by local name"); - if((grp = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR - if(H5Ldelete(work, "foo", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((grp = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grp) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(work, "foo", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR PASSED(); /* Delete directly - should fail */ TESTING("unlink without a name"); - if((grp = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - H5E_BEGIN_TRY { - status = H5Ldelete(grp, ".", H5P_DEFAULT); - } H5E_END_TRY; - if(status>=0) - FAIL_PUTS_ERROR(" Unlinking object w/o a name should have failed.") - if(H5Gclose(grp) < 0) FAIL_STACK_ERROR + if ((grp = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + H5E_BEGIN_TRY + { + status = H5Ldelete(grp, ".", H5P_DEFAULT); + } + H5E_END_TRY; + if (status >= 0) + FAIL_PUTS_ERROR(" Unlinking object w/o a name should have failed.") + if (H5Gclose(grp) < 0) + FAIL_STACK_ERROR /* Cleanup */ - if(H5Gclose(work) < 0) FAIL_STACK_ERROR + if (H5Gclose(work) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Gclose(work); - H5Gclose(grp); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Gclose(work); + H5Gclose(grp); + } + H5E_END_TRY; return 1; } /* end test_one() */ - /*------------------------------------------------------------------------- * Function: test_many * @@ -162,84 +163,96 @@ test_one(hid_t file) static int test_many(hid_t file) { - hid_t work=-1, grp=-1; - int i; - const int how_many=500; - char name[32]; + hid_t work = -1, grp = -1; + int i; + const int how_many = 500; + char name[32]; /* Create a test group */ - if((work = H5Gcreate2(file, "/test_many", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((grp = H5Gcreate2(work, "/test_many_foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; + if ((work = H5Gcreate2(file, "/test_many", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if ((grp = H5Gcreate2(work, "/test_many_foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if (H5Gclose(grp) < 0) + goto error; /* Create a bunch of names and unlink them in order */ TESTING("forward unlink"); - for(i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); - if(H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + for (i = 0; i < how_many; i++) { + HDsprintf(name, "obj_%05d", i); + if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ - for(i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); - if(H5Ldelete(work, name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + for (i = 0; i < how_many; i++) { + HDsprintf(name, "obj_%05d", i); + if (H5Ldelete(work, name, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ PASSED(); /* Create a bunch of names and unlink them in reverse order */ TESTING("backward unlink"); - for(i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); - if(H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + for (i = 0; i < how_many; i++) { + HDsprintf(name, "obj_%05d", i); + if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ - for(i = (how_many - 1); i >= 0; --i) { - HDsprintf(name, "obj_%05d", i); - if(H5Ldelete(work, name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + for (i = (how_many - 1); i >= 0; --i) { + HDsprintf(name, "obj_%05d", i); + if (H5Ldelete(work, name, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ PASSED(); /* Create a bunch of names and unlink them from both directions */ TESTING("inward unlink"); - for(i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); - if(H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + for (i = 0; i < how_many; i++) { + HDsprintf(name, "obj_%05d", i); + if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ - for(i = 0; i < how_many; i++) { - if(i % 2) - HDsprintf(name, "obj_%05d", how_many - (1 + i / 2)); - else - HDsprintf(name, "obj_%05d", i / 2); - if(H5Ldelete(work, name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + for (i = 0; i < how_many; i++) { + if (i % 2) + HDsprintf(name, "obj_%05d", how_many - (1 + i / 2)); + else + HDsprintf(name, "obj_%05d", i / 2); + if (H5Ldelete(work, name, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ PASSED(); /* Create a bunch of names and unlink them from the midle */ TESTING("outward unlink"); - for(i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); - if(H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + for (i = 0; i < how_many; i++) { + HDsprintf(name, "obj_%05d", i); + if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ - for(i = (how_many - 1); i >= 0; --i) { - if(i % 2) - HDsprintf(name, "obj_%05d", how_many - (1 + i / 2)); - else - HDsprintf(name, "obj_%05d", i / 2); - if(H5Ldelete(work, name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + for (i = (how_many - 1); i >= 0; --i) { + if (i % 2) + HDsprintf(name, "obj_%05d", how_many - (1 + i / 2)); + else + HDsprintf(name, "obj_%05d", i / 2); + if (H5Ldelete(work, name, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ PASSED(); - /* Cleanup */ - if (H5Gclose(work) < 0) goto error; + if (H5Gclose(work) < 0) + goto error; return 0; - error: - H5E_BEGIN_TRY { - H5Gclose(work); - H5Gclose(grp); - } H5E_END_TRY; +error: + H5E_BEGIN_TRY + { + H5Gclose(work); + H5Gclose(grp); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: test_symlink * @@ -257,29 +270,34 @@ test_many(hid_t file) static int test_symlink(hid_t file) { - hid_t work=-1; + hid_t work = -1; TESTING("symlink removal"); /* Create a test group and symlink */ - if((work = H5Gcreate2(file, "/test_symlink", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("link_value", work, "link", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(work, "link", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((work = H5Gcreate2(file, "/test_symlink", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("link_value", work, "link", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(work, "link", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Cleanup */ - if(H5Gclose(work) < 0) FAIL_STACK_ERROR + if (H5Gclose(work) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(work); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(work); + } + H5E_END_TRY; return 1; } /* end test_symlink() */ - /*------------------------------------------------------------------------- * Function: test_rename * @@ -299,41 +317,53 @@ error: static int test_rename(hid_t file) { - hid_t work=-1, foo=-1, inner=-1; + hid_t work = -1, foo = -1, inner = -1; /* Create a test group and rename something */ TESTING("object renaming"); - if((work = H5Gcreate2(file, "/test_rename", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((foo = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Lmove(work, "foo", H5L_SAME_LOC, "bar", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if((inner = H5Gcreate2(foo, "inner", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(inner) < 0) FAIL_STACK_ERROR - if(H5Gclose(foo) < 0) FAIL_STACK_ERROR - if((inner = H5Gopen2(work, "bar/inner", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(inner) < 0) FAIL_STACK_ERROR + if ((work = H5Gcreate2(file, "/test_rename", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((foo = H5Gcreate2(work, "foo", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Lmove(work, "foo", H5L_SAME_LOC, "bar", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if ((inner = H5Gcreate2(foo, "inner", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(inner) < 0) + FAIL_STACK_ERROR + if (H5Gclose(foo) < 0) + FAIL_STACK_ERROR + if ((inner = H5Gopen2(work, "bar/inner", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(inner) < 0) + FAIL_STACK_ERROR PASSED(); /* Try renaming a symlink */ TESTING("symlink renaming"); - if(H5Lcreate_soft("link_value", work, "link_one", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lmove(work, "link_one", H5L_SAME_LOC, "link_two", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("link_value", work, "link_one", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lmove(work, "link_one", H5L_SAME_LOC, "link_two", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Cleanup */ - if (H5Gclose(work) < 0) FAIL_STACK_ERROR + if (H5Gclose(work) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(work); - H5Gclose(foo); - H5Gclose(inner); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(work); + H5Gclose(foo); + H5Gclose(inner); + } + H5E_END_TRY; return 1; } /* end test_rename() */ - /*------------------------------------------------------------------------- * Function: test_new_move * @@ -353,67 +383,90 @@ error: static int test_new_move(hid_t fapl) { - hid_t file_a, file_b=(-1); - hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); - char filename[1024]; + hid_t file_a, file_b = (-1); + hid_t grp_1 = (-1), grp_2 = (-1), grp_move = (-1), moved_grp = (-1); + char filename[1024]; TESTING("new move"); /* Create a second file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create groups in first file */ - if((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((grp_2 = H5Gcreate2(file_a, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((grp_move = H5Gcreate2(grp_1, "group_move", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((grp_2 = H5Gcreate2(file_a, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((grp_move = H5Gcreate2(grp_1, "group_move", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create hard and soft links. */ - if(H5Lcreate_hard(grp_1, "group_move", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Lcreate_soft("/group1/group_move", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(grp_1, "group_move", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Lcreate_soft("/group1/group_move", grp_2, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Move a group within the file. Both of source and destination use * H5L_SAME_LOC. Should fail. */ - H5E_BEGIN_TRY { - if(H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != + FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Move a group across files. Should fail. */ - H5E_BEGIN_TRY { - if(H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) TEST_ERROR - } H5E_END_TRY; + H5E_BEGIN_TRY + { + if (H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) + TEST_ERROR + } + H5E_END_TRY; /* Move a group across groups in the same file. */ - if(H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Open the group just moved to the new location. */ - if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR - if(H5Gclose(grp_1) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp_2) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp_move) < 0) FAIL_STACK_ERROR - if(H5Gclose(moved_grp) < 0) FAIL_STACK_ERROR - if(H5Fclose(file_a) < 0) FAIL_STACK_ERROR - if(H5Fclose(file_b) < 0) FAIL_STACK_ERROR + if (H5Gclose(grp_1) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grp_2) < 0) + FAIL_STACK_ERROR + if (H5Gclose(grp_move) < 0) + FAIL_STACK_ERROR + if (H5Gclose(moved_grp) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file_a) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file_b) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { - H5Gclose(grp_1); - H5Gclose(grp_2); - H5Gclose(grp_move); +error: + H5E_BEGIN_TRY + { + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); H5Gclose(moved_grp); - H5Fclose(file_a); - H5Fclose(file_b); - } H5E_END_TRY; + H5Fclose(file_a); + H5Fclose(file_b); + } + H5E_END_TRY; return 1; } - /*------------------------------------------------------------------------- * Function: check_new_move * @@ -443,31 +496,32 @@ check_new_move(hid_t fapl) /* Open file */ h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Get hard link info */ - if(H5Oget_info_by_name3(file, "/group2/group_new_name", &oi_hard1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + if (H5Oget_info_by_name3(file, "/group2/group_new_name", &oi_hard1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Oget_info_by_name3(file, "/group1/hard", &oi_hard2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + if (H5Oget_info_by_name3(file, "/group1/hard", &oi_hard2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Check hard links */ - if(H5O_TYPE_GROUP != oi_hard1.type || H5O_TYPE_GROUP != oi_hard2.type) + if (H5O_TYPE_GROUP != oi_hard1.type || H5O_TYPE_GROUP != oi_hard2.type) FAIL_PUTS_ERROR(" Unexpected object type, should have been a group") - if(H5Otoken_cmp(file, &oi_hard1.token, &oi_hard2.token, &token_cmp) < 0) + if (H5Otoken_cmp(file, &oi_hard1.token, &oi_hard2.token, &token_cmp) < 0) FAIL_PUTS_ERROR(" H5Otoken_cmp failed") - if(token_cmp) + if (token_cmp) FAIL_PUTS_ERROR(" Hard link test failed. Link seems not to point to the expected file location.") /* Check soft links */ - if(H5Lget_val(file, "group2/soft", linkval, sizeof(linkval), H5P_DEFAULT) < 0) + if (H5Lget_val(file, "group2/soft", linkval, sizeof(linkval), H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(HDstrcmp(linkval, "/group1/group_move")) + if (HDstrcmp(linkval, "/group1/group_move")) FAIL_PUTS_ERROR(" Soft link test failed. Wrong link value") /* Cleanup */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; @@ -476,7 +530,6 @@ error: return 1; } /* end check_new_move() */ - /*------------------------------------------------------------------------- * Function: test_filespace * @@ -495,33 +548,35 @@ error: static int test_filespace(hid_t fapl) { - hid_t fapl_nocache; /* File access property list with raw data cache turned off */ - hid_t contig_dcpl; /* Dataset creation property list for contiguous dataset */ - hid_t early_chunk_dcpl; /* Dataset creation property list for chunked dataset & early allocation */ - hid_t late_chunk_dcpl; /* Dataset creation property list for chunked dataset & late allocation */ - hid_t comp_dcpl; /* Dataset creation property list for compressed, chunked dataset */ - hid_t compact_dcpl; /* Dataset creation property list for compact dataset */ - hid_t file; /* File ID */ - hid_t group, group2; /* Group IDs */ - hid_t dataset, dataset2; /* Dataset IDs */ - hid_t space; /* Dataspace ID */ - hid_t type; /* Datatype ID */ - hid_t attr_space; /* Dataspace ID for attributes */ - hid_t attr; /* Attribute ID */ - char filename[1024]; /* Name of file to create */ - char objname[128]; /* Name of object to create */ - hsize_t dims[FILESPACE_NDIMS]= {FILESPACE_DIM0, FILESPACE_DIM1, FILESPACE_DIM2}; /* Dataset dimensions */ - hsize_t chunk_dims[FILESPACE_NDIMS]= {FILESPACE_CHUNK0, FILESPACE_CHUNK1, FILESPACE_CHUNK2}; /* Chunk dimensions */ - hsize_t attr_dims[FILESPACE_ATTR_NDIMS]= {FILESPACE_ATTR_DIM0, FILESPACE_ATTR_DIM1}; /* Attribute dimensions */ - int *data = NULL; /* Pointer to dataset buffer */ - int *tmp_data; /* Temporary pointer to dataset buffer */ - h5_stat_size_t empty_size; /* Size of an empty file */ - h5_stat_size_t file_size; /* Size of each file created */ - herr_t status; /* Function status return value */ - unsigned u,v,w; /* Local index variables */ + hid_t fapl_nocache; /* File access property list with raw data cache turned off */ + hid_t contig_dcpl; /* Dataset creation property list for contiguous dataset */ + hid_t early_chunk_dcpl; /* Dataset creation property list for chunked dataset & early allocation */ + hid_t late_chunk_dcpl; /* Dataset creation property list for chunked dataset & late allocation */ + hid_t comp_dcpl; /* Dataset creation property list for compressed, chunked dataset */ + hid_t compact_dcpl; /* Dataset creation property list for compact dataset */ + hid_t file; /* File ID */ + hid_t group, group2; /* Group IDs */ + hid_t dataset, dataset2; /* Dataset IDs */ + hid_t space; /* Dataspace ID */ + hid_t type; /* Datatype ID */ + hid_t attr_space; /* Dataspace ID for attributes */ + hid_t attr; /* Attribute ID */ + char filename[1024]; /* Name of file to create */ + char objname[128]; /* Name of object to create */ + hsize_t dims[FILESPACE_NDIMS] = {FILESPACE_DIM0, FILESPACE_DIM1, FILESPACE_DIM2}; /* Dataset dimensions */ + hsize_t chunk_dims[FILESPACE_NDIMS] = {FILESPACE_CHUNK0, FILESPACE_CHUNK1, + FILESPACE_CHUNK2}; /* Chunk dimensions */ + hsize_t attr_dims[FILESPACE_ATTR_NDIMS] = {FILESPACE_ATTR_DIM0, + FILESPACE_ATTR_DIM1}; /* Attribute dimensions */ + int * data = NULL; /* Pointer to dataset buffer */ + int * tmp_data; /* Temporary pointer to dataset buffer */ + h5_stat_size_t empty_size; /* Size of an empty file */ + h5_stat_size_t file_size; /* Size of each file created */ + herr_t status; /* Function status return value */ + unsigned u, v, w; /* Local index variables */ /* Metadata cache parameters */ - int mdc_nelmts; + int mdc_nelmts; size_t rdcc_nelmts; size_t rdcc_nbytes; double rdcc_w0; @@ -531,697 +586,877 @@ test_filespace(hid_t fapl) /* Open file */ h5_fixname(FILENAME[4], fapl, filename, sizeof filename); -/* Create FAPL with raw data cache disabled */ + /* Create FAPL with raw data cache disabled */ /* Create file access property list with raw data cache disabled */ - if ((fapl_nocache=H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl_nocache = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Get the cache settings */ - if(H5Pget_cache(fapl_nocache,&mdc_nelmts,&rdcc_nelmts,&rdcc_nbytes,&rdcc_w0) < 0) TEST_ERROR + if (H5Pget_cache(fapl_nocache, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) + TEST_ERROR /* Disable the raw data cache */ - rdcc_nelmts=0; - rdcc_nbytes=0; - if(H5Pset_cache(fapl_nocache,mdc_nelmts,rdcc_nelmts,rdcc_nbytes,rdcc_w0) < 0) TEST_ERROR + rdcc_nelmts = 0; + rdcc_nbytes = 0; + if (H5Pset_cache(fapl_nocache, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + TEST_ERROR -/* Create empty file for size comparisons later */ + /* Create empty file for size comparisons later */ /* Create file */ - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR /* Close file */ - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR /* Get the size of an empty file */ - if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((empty_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR -/* Create common objects for datasets */ + /* Create common objects for datasets */ /* Create dataset creation property list for contigous storage */ - if ((contig_dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + if ((contig_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR /* Make certain that space is allocated early */ - if(H5Pset_alloc_time(contig_dcpl, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR + if (H5Pset_alloc_time(contig_dcpl, H5D_ALLOC_TIME_EARLY) < 0) + TEST_ERROR /* Create dataset creation property list for chunked storage & early allocation */ - if ((early_chunk_dcpl=H5Pcopy(contig_dcpl)) < 0) TEST_ERROR + if ((early_chunk_dcpl = H5Pcopy(contig_dcpl)) < 0) + TEST_ERROR /* Set chunk dimensions */ - if(H5Pset_chunk(early_chunk_dcpl, FILESPACE_NDIMS, chunk_dims) < 0) TEST_ERROR + if (H5Pset_chunk(early_chunk_dcpl, FILESPACE_NDIMS, chunk_dims) < 0) + TEST_ERROR /* Create dataset creation property list for chunked storage & late allocation */ - if ((late_chunk_dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + if ((late_chunk_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR /* Set chunk dimensions */ - if(H5Pset_chunk(late_chunk_dcpl, FILESPACE_NDIMS, chunk_dims) < 0) TEST_ERROR + if (H5Pset_chunk(late_chunk_dcpl, FILESPACE_NDIMS, chunk_dims) < 0) + TEST_ERROR /* Create dataset creation property list for compressed, chunked storage & early allocation */ - if ((comp_dcpl=H5Pcopy(early_chunk_dcpl)) < 0) TEST_ERROR + if ((comp_dcpl = H5Pcopy(early_chunk_dcpl)) < 0) + TEST_ERROR /* Enable compression & set level */ - if(H5Pset_deflate(comp_dcpl, FILESPACE_DEFLATE_LEVEL) < 0) TEST_ERROR + if (H5Pset_deflate(comp_dcpl, FILESPACE_DEFLATE_LEVEL) < 0) + TEST_ERROR /* Create dataset creation property list for compact storage */ - if ((compact_dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + if ((compact_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR /* Set to compact storage */ - if(H5Pset_layout(compact_dcpl, H5D_COMPACT) < 0) TEST_ERROR + if (H5Pset_layout(compact_dcpl, H5D_COMPACT) < 0) + TEST_ERROR /* Create dataspace for datasets */ - if((space = H5Screate_simple(FILESPACE_NDIMS, dims, NULL)) < 0) TEST_ERROR + if ((space = H5Screate_simple(FILESPACE_NDIMS, dims, NULL)) < 0) + TEST_ERROR /* Create buffer for writing dataset */ - if(NULL == (data = (int *)HDmalloc(sizeof(int) * FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2))) TEST_ERROR - + if (NULL == (data = (int *)HDmalloc(sizeof(int) * FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2))) + TEST_ERROR -/* Create single dataset (with contiguous storage & late allocation), remove it & verify file size */ + /* Create single dataset (with contiguous storage & late allocation), remove it & verify file size */ TESTING(" contiguous dataset with late allocation"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single dataset to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if ((dataset = + H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create single dataset (with contiguous storage & early allocation), remove it & verify file size */ + /* Create single dataset (with contiguous storage & early allocation), remove it & verify file size */ TESTING(" contiguous dataset with early allocation"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single dataset to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, contig_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if ((dataset = + H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, contig_dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create single dataset (with chunked storage & late allocation), remove it & verify file size */ + /* Create single dataset (with chunked storage & late allocation), remove it & verify file size */ TESTING(" chunked dataset with late allocation"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single dataset to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, late_chunk_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if ((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, late_chunk_dcpl, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create single dataset (with chunked storage & early allocation), remove it & verify file size */ + /* Create single dataset (with chunked storage & early allocation), remove it & verify file size */ TESTING(" chunked dataset with early allocation"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single dataset to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, early_chunk_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if ((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, early_chunk_dcpl, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create single dataset (with compressed storage & early allocation), remove it & verify file size */ + /* Create single dataset (with compressed storage & early allocation), remove it & verify file size */ TESTING(" compressed, chunked dataset"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single dataset to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, comp_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if ((dataset = + H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, comp_dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create single dataset (with compressed storage & early allocation), re-write it a bunch of - * times (which should re-allocate blocks many times) and remove it & verify - * file size. - */ + /* Create single dataset (with compressed storage & early allocation), re-write it a bunch of + * times (which should re-allocate blocks many times) and remove it & verify + * file size. + */ TESTING(" re-writing compressed, chunked dataset"); /* Create file (using FAPL with disabled raw data cache) */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_nocache)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_nocache)) < 0) + FAIL_STACK_ERROR /* Create a single dataset to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, comp_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset = + H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, comp_dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Alternate re-writing dataset with compressible & random data */ - for(u = 0; u < FILESPACE_REWRITE; u++) { + for (u = 0; u < FILESPACE_REWRITE; u++) { /* Set buffer to some compressible values */ - for(v = 0, tmp_data = data; v < (FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2); v++) + for (v = 0, tmp_data = data; v < (FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2); v++) *tmp_data++ = (int)(v * u); /* Write the buffer to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + FAIL_STACK_ERROR /* Set buffer to different random numbers each time */ - for(v = 0, tmp_data = data; v < (FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2); v++) + for (v = 0, tmp_data = data; v < (FILESPACE_DIM0 * FILESPACE_DIM1 * FILESPACE_DIM2); v++) *tmp_data++ = (int)HDrandom(); /* Write the buffer to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close dataset */ - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl_nocache)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl_nocache)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create single dataset (with compact storage), remove it & verify file size */ + /* Create single dataset (with compact storage), remove it & verify file size */ TESTING(" compact dataset"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single dataset to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, compact_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if ((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, compact_dcpl, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create two datasets (with contiguous storage), alternate adding attributes - * to each one (which creates many object header continuations), - * remove both & verify file size. - */ + /* Create two datasets (with contiguous storage), alternate adding attributes + * to each one (which creates many object header continuations), + * remove both & verify file size. + */ TESTING(" object header continuations"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create datasets to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, contig_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((dataset2 = H5Dcreate2(file, DATASET2NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, contig_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset = + H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, contig_dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((dataset2 = H5Dcreate2(file, DATASET2NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, contig_dcpl, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a dataspace for the attributes */ - if((attr_space = H5Screate_simple(FILESPACE_ATTR_NDIMS, attr_dims, NULL)) < 0) FAIL_STACK_ERROR + if ((attr_space = H5Screate_simple(FILESPACE_ATTR_NDIMS, attr_dims, NULL)) < 0) + FAIL_STACK_ERROR /* Alternate adding attributes to each one */ - for(u = 0; u < FILESPACE_NATTR; u++) { + for (u = 0; u < FILESPACE_NATTR; u++) { /* Set the name of the attribute to create */ - HDsprintf(objname,"%s %u",ATTRNAME,u); + HDsprintf(objname, "%s %u", ATTRNAME, u); /* Create an attribute on the first dataset */ - if((attr = H5Acreate2(dataset, objname, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((attr = H5Acreate2(dataset, objname, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Don't worry about writing the attribute - it will have a fill value */ /* Close the attribute on the first dataset */ - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + if (H5Aclose(attr) < 0) + FAIL_STACK_ERROR /* Create an attribute on the second dataset */ - if((attr = H5Acreate2(dataset2, objname, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((attr = H5Acreate2(dataset2, objname, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Don't worry about writing the attribute - it will have a fill value */ /* Close the attribute on the second dataset */ - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + if (H5Aclose(attr) < 0) + FAIL_STACK_ERROR /* Flush the file (to fix the sizes of object header buffers, etc) */ - if(H5Fflush(file,H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR + if (H5Fflush(file, H5F_SCOPE_GLOBAL) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close the dataspace for the attributes */ - if(H5Sclose(attr_space) < 0) FAIL_STACK_ERROR + if (H5Sclose(attr_space) < 0) + FAIL_STACK_ERROR /* Close datasets */ - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset2) < 0) + FAIL_STACK_ERROR /* Remove the datasets */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(file, DATASET2NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(file, DATASET2NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create single named datatype, remove it & verify file size */ + /* Create single named datatype, remove it & verify file size */ TESTING(" named datatype"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create datatype to commit */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR /* Create a single named datatype to remove */ - if(H5Tcommit2(file, TYPENAME, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Tclose(type) < 0) FAIL_STACK_ERROR + if (H5Tcommit2(file, TYPENAME, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR /* Remove the named datatype */ - if(H5Ldelete(file, TYPENAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, TYPENAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create single group, remove it & verify file size */ + /* Create single group, remove it & verify file size */ TESTING(" single group"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single group to remove */ - if((group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group) < 0) FAIL_STACK_ERROR + if ((group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR /* Remove the group */ - if(H5Ldelete(file, GROUPNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, GROUPNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create many groups, remove them & verify file size */ + /* Create many groups, remove them & verify file size */ TESTING(" multiple groups"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a many groups to remove */ - for(u = 0; u < UNLINK_NGROUPS; u++) { + for (u = 0; u < UNLINK_NGROUPS; u++) { HDsprintf(objname, "%s %u", GROUPNAME, u); - if((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group) < 0) FAIL_STACK_ERROR + if ((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR } /* end for */ /* Remove the all the groups */ /* (Remove them in reverse order just to make file size calculation easier -QAK) */ - for(u = UNLINK_NGROUPS; u > 0; u--) { + for (u = UNLINK_NGROUPS; u > 0; u--) { HDsprintf(objname, "%s %u", GROUPNAME, (u - 1)); - if(H5Ldelete(file, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create simple group hiearchy, remove it & verify file size */ + /* Create simple group hiearchy, remove it & verify file size */ TESTING(" simple group hierarchy"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a small group hierarchy to remove */ - if((group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((group2 = H5Gcreate2(group, GROUP2NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2) < 0) FAIL_STACK_ERROR - if(H5Gclose(group) < 0) FAIL_STACK_ERROR + if ((group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((group2 = H5Gcreate2(group, GROUP2NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group2) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR /* Remove the second group */ - if(H5Ldelete(file, GROUPNAME "/" GROUP2NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, GROUPNAME "/" GROUP2NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Remove the first group */ - if(H5Ldelete(file, GROUPNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, GROUPNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create complex group hiearchy, remove it & verify file size */ + /* Create complex group hiearchy, remove it & verify file size */ TESTING(" complex group hierarchy"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a complex group hierarchy to remove */ - for(u = 0; u < FILESPACE_TOP_GROUPS; u++) { + for (u = 0; u < FILESPACE_TOP_GROUPS; u++) { /* Create group */ - HDsprintf(objname,"%s %u",GROUPNAME,u); - if((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + HDsprintf(objname, "%s %u", GROUPNAME, u); + if ((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create nested groups inside top groups */ - for(v = 0; v < FILESPACE_NESTED_GROUPS; v++) { + for (v = 0; v < FILESPACE_NESTED_GROUPS; v++) { /* Create group */ HDsprintf(objname, "%s %u", GROUP2NAME, v); - if((group2 = H5Gcreate2(group, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2 = H5Gcreate2(group, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create datasets inside nested groups */ - for(w = 0; w < FILESPACE_NDATASETS; w++) { + for (w = 0; w < FILESPACE_NDATASETS; w++) { /* Create & close a dataset */ HDsprintf(objname, "%s %u", DATASETNAME, w); - if((dataset = H5Dcreate2(group2, objname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if ((dataset = H5Dcreate2(group2, objname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close nested group */ - if(H5Gclose(group2) < 0) FAIL_STACK_ERROR + if (H5Gclose(group2) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close top group */ - if(H5Gclose(group) < 0) FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR } /* end for */ /* Remove complex group hierarchy */ /* (Remove them in reverse order just to make file size calculation easier -QAK) */ - for(u = FILESPACE_TOP_GROUPS; u > 0; u--) { + for (u = FILESPACE_TOP_GROUPS; u > 0; u--) { /* Open group */ HDsprintf(objname, "%s %u", GROUPNAME, (u - 1)); - if((group = H5Gopen2(file, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group = H5Gopen2(file, objname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Open nested groups inside top groups */ - for(v = 0; v < FILESPACE_NESTED_GROUPS; v++) { + for (v = 0; v < FILESPACE_NESTED_GROUPS; v++) { /* Create group */ HDsprintf(objname, "%s %u", GROUP2NAME, v); - if((group2 = H5Gopen2(group, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group2 = H5Gopen2(group, objname, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Remove datasets inside nested groups */ - for(w = 0; w < FILESPACE_NDATASETS; w++) { + for (w = 0; w < FILESPACE_NDATASETS; w++) { /* Remove dataset */ HDsprintf(objname, "%s %u", DATASETNAME, w); - if(H5Ldelete(group2, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(group2, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close nested group */ - if(H5Gclose(group2) < 0) FAIL_STACK_ERROR + if (H5Gclose(group2) < 0) + FAIL_STACK_ERROR /* Remove nested group */ - HDsprintf(objname, "%s %u",GROUP2NAME, v); - if(H5Ldelete(group, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + HDsprintf(objname, "%s %u", GROUP2NAME, v); + if (H5Ldelete(group, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close top group */ - if(H5Gclose(group) < 0) FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR /* Remove top group */ HDsprintf(objname, "%s %u", GROUPNAME, (u - 1)); - if(H5Ldelete(file, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, objname, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create dataset and duplicate dataset, remove original & verify file size */ + /* Create dataset and duplicate dataset, remove original & verify file size */ TESTING(" duplicate dataset"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single dataset to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if ((dataset = + H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Create another dataset with same name */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(dataset >= 0) { + } + H5E_END_TRY; + if (dataset >= 0) { H5Dclose(dataset); TEST_ERROR } /* end if */ /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create group and duplicate group, remove original & verify file size */ + /* Create group and duplicate group, remove original & verify file size */ TESTING(" duplicate group"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a single group to remove */ - if((group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group) < 0) FAIL_STACK_ERROR + if ((group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR /* Create another group with same name */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(group >= 0) { + } + H5E_END_TRY; + if (group >= 0) { H5Gclose(group); TEST_ERROR } /* end if */ /* Remove the group */ - if(H5Ldelete(file, GROUPNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, GROUPNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create named datatype and duplicate named datatype, remove original & verify file size */ + /* Create named datatype and duplicate named datatype, remove original & verify file size */ TESTING(" duplicate named datatype"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create datatype to commit */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR /* Create a single named datatype to remove */ - if(H5Tcommit2(file, TYPENAME, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Tclose(type) < 0) FAIL_STACK_ERROR + if (H5Tcommit2(file, TYPENAME, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR /* Create datatype to commit */ - if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR /* Create another named datatype with same name */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5Tcommit2(file, TYPENAME, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(status >= 0) TEST_ERROR - if(H5Tclose(type) < 0) FAIL_STACK_ERROR + } + H5E_END_TRY; + if (status >= 0) + TEST_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR /* Remove the named datatype */ - if(H5Ldelete(file, TYPENAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, TYPENAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Create named datatype and duplicate named datatype, remove original & verify file size */ + /* Create named datatype and duplicate named datatype, remove original & verify file size */ TESTING(" duplicate attribute"); /* Create file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create datasets to remove */ - if((dataset = H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, contig_dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dataset = + H5Dcreate2(file, DATASETNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, contig_dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a dataspace for the attributes */ - if((attr_space = H5Screate_simple(FILESPACE_ATTR_NDIMS, attr_dims, NULL)) < 0) FAIL_STACK_ERROR + if ((attr_space = H5Screate_simple(FILESPACE_ATTR_NDIMS, attr_dims, NULL)) < 0) + FAIL_STACK_ERROR /* Create an attribute on the dataset */ - if((attr = H5Acreate2(dataset, ATTRNAME, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((attr = H5Acreate2(dataset, ATTRNAME, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Don't worry about writing the attribute - it will have a fill value */ /* Close the attribute on the dataset */ - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + if (H5Aclose(attr) < 0) + FAIL_STACK_ERROR /* Create another attribute with same name */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { attr = H5Acreate2(dataset, ATTRNAME, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - if(attr >= 0) { + } + H5E_END_TRY; + if (attr >= 0) { H5Aclose(attr); TEST_ERROR } /* end if */ /* Close the dataspace for the attributes */ - if(H5Sclose(attr_space) < 0) FAIL_STACK_ERROR + if (H5Sclose(attr_space) < 0) + FAIL_STACK_ERROR /* Close dataset */ - if(H5Dclose(dataset) < 0) FAIL_STACK_ERROR + if (H5Dclose(dataset) < 0) + FAIL_STACK_ERROR /* Remove the dataset */ - if(H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close file */ - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != empty_size) TEST_ERROR + if (file_size != empty_size) + TEST_ERROR PASSED(); - -/* Cleanup common objects */ + /* Cleanup common objects */ /* Release dataset buffer */ HDfree(data); /* Close property lists */ - if(H5Pclose(fapl_nocache) < 0) FAIL_STACK_ERROR - if(H5Pclose(contig_dcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(early_chunk_dcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(late_chunk_dcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(comp_dcpl) < 0) FAIL_STACK_ERROR - if(H5Pclose(compact_dcpl) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_nocache) < 0) + FAIL_STACK_ERROR + if (H5Pclose(contig_dcpl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(early_chunk_dcpl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(late_chunk_dcpl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(comp_dcpl) < 0) + FAIL_STACK_ERROR + if (H5Pclose(compact_dcpl) < 0) + FAIL_STACK_ERROR /* Close dataspace */ - if(H5Sclose(space) < 0) FAIL_STACK_ERROR + if (H5Sclose(space) < 0) + FAIL_STACK_ERROR /* Indicate success */ /* Don't print final "PASSED", since we aren't on the correct line anymore */ @@ -1229,13 +1464,12 @@ test_filespace(hid_t fapl) error: /* Release dataset buffer */ - if(data) + if (data) HDfree(data); return 1; } /* end test_filespace() */ - /*------------------------------------------------------------------------- * Function: test_create_unlink * @@ -1254,45 +1488,45 @@ error: static int test_create_unlink(const char *msg, hid_t fapl) { - hid_t file, group; + hid_t file, group; unsigned u; char groupname[1024]; - char filename[1024]; + char filename[1024]; TESTING("%s", msg); /* Create file */ h5_fixname(FILENAME[3], fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_PUTS_ERROR(" Creating file failed") /* Create a many groups to remove */ - for(u = 0; u < UNLINK_NGROUPS; u++) { + for (u = 0; u < UNLINK_NGROUPS; u++) { HDsprintf(groupname, "%s %u", GROUPNAME, u); - if((group = H5Gcreate2(file, groupname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((group = H5Gcreate2(file, groupname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); HDprintf("group %s creation failed\n", groupname); goto error; } /* end if */ - if(H5Gclose (group) < 0) { + if (H5Gclose(group) < 0) { H5_FAILED(); HDprintf("closing group %s failed\n", groupname); goto error; } /* end if */ - } /* end for */ + } /* end for */ /* Remove the all the groups */ - for(u = 0; u < UNLINK_NGROUPS; u++) { + for (u = 0; u < UNLINK_NGROUPS; u++) { HDsprintf(groupname, "%s %u", GROUPNAME, u); - if(H5Ldelete(file, groupname, H5P_DEFAULT) < 0) { + if (H5Ldelete(file, groupname, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Unlinking group %s failed\n", groupname); goto error; } /* end if */ - } /* end for */ + } /* end for */ /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) FAIL_PUTS_ERROR("Closing file failed") PASSED(); @@ -1302,7 +1536,6 @@ error: return 1; } /* end test_create_unlink() */ - /*------------------------------------------------------------------------- * Function: test_link_slashes * @@ -1321,9 +1554,9 @@ error: static int test_link_slashes(hid_t fapl) { - hid_t fid; /* File ID */ - hid_t gid, gid2; /* Group ID */ - char filename[1024]; + hid_t fid; /* File ID */ + hid_t gid, gid2; /* Group ID */ + char filename[1024]; TESTING("creating links with multiple slashes"); @@ -1331,37 +1564,51 @@ test_link_slashes(hid_t fapl) h5_fixname(FILENAME[5], fapl, filename, sizeof filename); /* Create a file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a group in the root group */ - if((gid = H5Gcreate2(fid, SLASHES_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(fid, SLASHES_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create a nested group in the root group */ - if((gid2 = H5Gcreate2(gid, SLASHES_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, SLASHES_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close the nested group */ - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR /* Create a hard link to the nested group */ - if(H5Lcreate_hard(gid, SLASHES_GROUP_NAME, H5L_SAME_LOC, SLASHES_HARDLINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(gid, SLASHES_GROUP_NAME, H5L_SAME_LOC, SLASHES_HARDLINK_NAME, H5P_DEFAULT, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create a soft link with a relative path to the nested group */ - if(H5Lcreate_soft(SLASHES_GROUP_NAME, gid, SLASHES_SOFTLINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft(SLASHES_GROUP_NAME, gid, SLASHES_SOFTLINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create a soft link with the full path to the nested group */ - if(H5Lcreate_soft("////"SLASHES_GROUP_NAME""SLASHES_GROUP_NAME, gid, SLASHES_SOFTLINK2_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("////" SLASHES_GROUP_NAME "" SLASHES_GROUP_NAME, gid, SLASHES_SOFTLINK2_NAME, + H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create a soft link to the root group */ - if(H5Lcreate_soft("////", gid, SLASHES_ROOTLINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("////", gid, SLASHES_ROOTLINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Create a hard link to the existing group */ - if(H5Lcreate_hard(fid, SLASHES_GROUP_NAME, H5L_SAME_LOC, SLASHES_HARDLINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(fid, SLASHES_GROUP_NAME, H5L_SAME_LOC, SLASHES_HARDLINK_NAME, H5P_DEFAULT, + H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return 0; @@ -1370,7 +1617,6 @@ error: return 1; } /* end test_link_slashes() */ - /*------------------------------------------------------------------------- * Function: test_unlink_slashes * @@ -1389,9 +1635,9 @@ error: static int test_unlink_slashes(hid_t fapl) { - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ - char filename[1024]; + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + char filename[1024]; TESTING("deleting links with multiple slashes"); @@ -1399,37 +1645,48 @@ test_unlink_slashes(hid_t fapl) h5_fixname(FILENAME[5], fapl, filename, sizeof filename); /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Open the top level group */ - if((gid = H5Gopen2(fid, SLASHES_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gopen2(fid, SLASHES_GROUP_NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Delete the root link */ - if(H5Ldelete(gid,SLASHES_ROOTLINK_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, SLASHES_ROOTLINK_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Delete the soft link with the full path */ - if(H5Ldelete(gid,SLASHES_SOFTLINK2_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, SLASHES_SOFTLINK2_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Delete the soft link with the relative path */ - if(H5Ldelete(gid,SLASHES_SOFTLINK_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, SLASHES_SOFTLINK_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Delete the hard link */ - if(H5Ldelete(gid,SLASHES_HARDLINK_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, SLASHES_HARDLINK_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Delete the group itself */ - if(H5Ldelete(gid,SLASHES_GROUP_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(gid, SLASHES_GROUP_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close the group */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Delete the hard link */ - if(H5Ldelete(fid,SLASHES_HARDLINK_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, SLASHES_HARDLINK_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Delete the group itself */ - if(H5Ldelete(fid,SLASHES_GROUP_NAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, SLASHES_GROUP_NAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(fid) < 0) TEST_ERROR + if (H5Fclose(fid) < 0) + TEST_ERROR PASSED(); return 0; @@ -1444,30 +1701,34 @@ error: static int delete_node(hid_t pid, hid_t id) { - char name[256]; /* Name of object to close */ + char name[256]; /* Name of object to close */ /* Get the name of the object to delete */ - if(H5Iget_name(id, name, sizeof(name)) < 0) return (-1); + if (H5Iget_name(id, name, sizeof(name)) < 0) + return (-1); /* Close the object */ - if(H5Gclose(id) < 0) return(-1); + if (H5Gclose(id) < 0) + return (-1); /* Unlink the object */ - if(H5Ldelete(pid, name, H5P_DEFAULT) < 0) return(-1); + if (H5Ldelete(pid, name, H5P_DEFAULT) < 0) + return (-1); /* If this object is the right-most child, try opening the previous object */ - if(HDstrcmp(name,"/Zone81") == 0) { + if (HDstrcmp(name, "/Zone81") == 0) { hid_t gid; - if((gid = H5Gopen2(pid, "/Zone80", H5P_DEFAULT)) < 0) return(-1); - if(H5Gclose(gid) < 0) return(-1); + if ((gid = H5Gopen2(pid, "/Zone80", H5P_DEFAULT)) < 0) + return (-1); + if (H5Gclose(gid) < 0) + return (-1); } /* end if */ /* Indicate success */ - return(0); + return (0); } - /*------------------------------------------------------------------------- * Function: test_unlink_rightleaf * @@ -1487,40 +1748,47 @@ delete_node(hid_t pid, hid_t id) static int test_unlink_rightleaf(hid_t fid) { - hid_t rootid = -1, /* Group ID for root group */ - *gids = NULL; /* Array of IDs for groups created */ - int n, /* Local index variable */ - ngroups = 150; /* Number of groups to create */ - char name[256]; /* Name of object to create */ + hid_t rootid = -1, /* Group ID for root group */ + *gids = NULL; /* Array of IDs for groups created */ + int n, /* Local index variable */ + ngroups = 150; /* Number of groups to create */ + char name[256]; /* Name of object to create */ TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ - if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR + if (NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) + TEST_ERROR - if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create all the groups */ for (n = 0; n < ngroups; n++) { HDsprintf(name, "Zone%d", n + 1); - if((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR } /* end for */ /* Unlink & re-create each group */ for (n = 0; n < ngroups; n++) { - if(delete_node (rootid, gids[n]) < 0) TEST_ERROR + if (delete_node(rootid, gids[n]) < 0) + TEST_ERROR HDsprintf(name, "Zone%d", n + 1); - if((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR } /* end for */ /* Close all the groups */ for (n = 0; n < ngroups; n++) { - if(H5Gclose(gids[n]) < 0) TEST_ERROR + if (H5Gclose(gids[n]) < 0) + TEST_ERROR gids[n] = 0; } /* end for */ /* Close root group ID */ - if(H5Gclose(rootid) < 0) TEST_ERROR + if (H5Gclose(rootid) < 0) + TEST_ERROR /* Free memory */ HDfree(gids); @@ -1529,24 +1797,27 @@ test_unlink_rightleaf(hid_t fid) return 0; error: - if(gids) { + if (gids) { /* Close any open groups */ for (n = 0; n < ngroups; n++) - if(gids[n]) { - H5E_BEGIN_TRY { + if (gids[n]) { + H5E_BEGIN_TRY + { H5Gclose(gids[n]); - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ HDfree(gids); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(rootid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_unlink_rightleaf() */ - /*------------------------------------------------------------------------- * Function: test_unlink_rightnode * @@ -1566,40 +1837,50 @@ error: static int test_unlink_rightnode(hid_t fid) { - hid_t rootid = -1, /* Group ID for root group */ - *gids = NULL; /* Array of IDs for groups created */ - int n, /* Local index variable */ - ngroups = 150; /* Number of groups to create */ - char name[256]; /* Name of object to create */ + hid_t rootid = -1, /* Group ID for root group */ + *gids = NULL; /* Array of IDs for groups created */ + int n, /* Local index variable */ + ngroups = 150; /* Number of groups to create */ + char name[256]; /* Name of object to create */ TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ - if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR + if (NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) + TEST_ERROR - if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create all the groups */ for (n = 0; n < ngroups; n++) { HDsprintf(name, "ZoneB%d", n + 1); - if((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close all the groups */ for (n = 0; n < ngroups; n++) { - if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR + if (H5Gclose(gids[n]) < 0) + FAIL_STACK_ERROR gids[n] = 0; } /* end for */ /* Unlink specific objects to trigger deletion of right leaf in non-leaf node */ - if(H5Ldelete(fid, "/ZoneB77", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneB78", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneB79", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneB8", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneB80", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneB77", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneB78", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneB79", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneB8", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneB80", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close root group ID */ - if(H5Gclose(rootid) < 0) FAIL_STACK_ERROR + if (H5Gclose(rootid) < 0) + FAIL_STACK_ERROR /* Free memory */ HDfree(gids); @@ -1608,24 +1889,27 @@ test_unlink_rightnode(hid_t fid) return 0; error: - if(gids) { + if (gids) { /* Close any open groups */ for (n = 0; n < ngroups; n++) - if(gids[n]) { - H5E_BEGIN_TRY { + if (gids[n]) { + H5E_BEGIN_TRY + { H5Gclose(gids[n]); - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ HDfree(gids); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(rootid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_unlink_rightnode() */ - /*------------------------------------------------------------------------- * Function: test_unlink_middlenode * @@ -1645,183 +1929,336 @@ error: static int test_unlink_middlenode(hid_t fid) { - hid_t rootid = -1, /* Group ID for root group */ - *gids = NULL; /* Array of IDs for groups created */ - int n, /* Local index variable */ - ngroups = 250; /* Number of groups to create */ - char name[256]; /* Name of object to create */ + hid_t rootid = -1, /* Group ID for root group */ + *gids = NULL; /* Array of IDs for groups created */ + int n, /* Local index variable */ + ngroups = 250; /* Number of groups to create */ + char name[256]; /* Name of object to create */ TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ - if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR + if (NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) + TEST_ERROR - if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create all the groups */ for (n = 0; n < ngroups; n++) { HDsprintf(name, "ZoneC%d", n + 1); - if((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close all the groups */ for (n = 0; n < ngroups; n++) { - if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR + if (H5Gclose(gids[n]) < 0) + FAIL_STACK_ERROR gids[n] = 0; } /* end for */ /* Unlink specific objects to trigger deletion of all leafs in "interior" non-leaf node */ - if(H5Ldelete(fid, "/ZoneC11", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC110", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC111", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC112", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC113", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC114", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC115", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC116", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC117", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC118", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC119", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC12", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC120", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC121", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC122", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC123", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC124", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC125", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC126", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC127", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC128", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC129", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC13", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC130", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC131", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC132", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC133", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC134", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC135", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC136", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC137", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC138", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC139", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC14", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC140", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC141", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC142", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC143", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC144", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC145", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC146", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC147", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC148", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC149", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC15", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC150", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC151", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC152", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC153", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC154", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC155", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC156", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC157", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC158", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC159", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC16", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC160", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC161", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC162", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC163", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC164", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC165", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC166", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC167", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC168", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC169", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC17", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC170", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC171", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC172", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC173", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC174", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC175", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC176", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC177", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC178", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC179", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC18", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC180", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC19", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC2", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC20", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC21", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC22", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC23", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC24", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC25", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC26", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC27", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC28", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC29", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC3", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC30", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC31", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC32", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC33", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC34", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC35", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC36", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC37", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC38", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC39", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC4", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC40", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC41", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC42", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC43", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC44", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC45", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC46", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC47", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC48", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC49", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC5", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC50", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC51", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC52", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC53", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC54", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC55", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC56", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC57", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC58", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC59", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC6", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC60", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC61", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC62", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC63", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC64", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC65", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC66", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC67", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC68", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC69", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC7", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC70", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC71", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC72", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC73", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC74", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC75", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC76", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC77", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC78", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC79", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC8", H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(H5Ldelete(fid, "/ZoneC80", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC11", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC110", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC111", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC112", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC113", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC114", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC115", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC116", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC117", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC118", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC119", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC12", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC120", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC121", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC122", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC123", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC124", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC125", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC126", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC127", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC128", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC129", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC13", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC130", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC131", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC132", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC133", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC134", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC135", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC136", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC137", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC138", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC139", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC14", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC140", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC141", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC142", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC143", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC144", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC145", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC146", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC147", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC148", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC149", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC15", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC150", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC151", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC152", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC153", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC154", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC155", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC156", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC157", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC158", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC159", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC16", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC160", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC161", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC162", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC163", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC164", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC165", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC166", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC167", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC168", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC169", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC17", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC170", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC171", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC172", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC173", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC174", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC175", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC176", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC177", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC178", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC179", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC18", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC180", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC19", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC2", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC20", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC21", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC22", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC23", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC24", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC25", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC26", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC27", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC28", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC29", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC3", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC30", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC31", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC32", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC33", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC34", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC35", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC36", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC37", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC38", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC39", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC4", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC40", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC41", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC42", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC43", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC44", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC45", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC46", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC47", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC48", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC49", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC5", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC50", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC51", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC52", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC53", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC54", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC55", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC56", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC57", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC58", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC59", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC6", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC60", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC61", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC62", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC63", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC64", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC65", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC66", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC67", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC68", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC69", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC7", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC70", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC71", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC72", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC73", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC74", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC75", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC76", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC77", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC78", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC79", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC8", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (H5Ldelete(fid, "/ZoneC80", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close root group ID */ - if(H5Gclose(rootid) < 0) FAIL_STACK_ERROR + if (H5Gclose(rootid) < 0) + FAIL_STACK_ERROR /* Free memory */ HDfree(gids); @@ -1830,24 +2267,27 @@ test_unlink_middlenode(hid_t fid) return 0; error: - if(gids) { + if (gids) { /* Close any open groups */ for (n = 0; n < ngroups; n++) - if(gids[n]) { - H5E_BEGIN_TRY { + if (gids[n]) { + H5E_BEGIN_TRY + { H5Gclose(gids[n]); - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ HDfree(gids); } /* end if */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(rootid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_unlink_middlenode() */ - /*------------------------------------------------------------------------- * Function: test_resurrect_dataset * @@ -1867,8 +2307,8 @@ error: static int test_resurrect_dataset(hid_t fapl) { - hid_t f = -1, s = -1, d = -1; - char filename[1024]; + hid_t f = -1, s = -1, d = -1; + char filename[1024]; TESTING("resurrecting dataset after deletion"); @@ -1876,49 +2316,63 @@ test_resurrect_dataset(hid_t fapl) h5_fixname(FILENAME[6], fapl, filename, sizeof filename); /* Create the file */ - if((f = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((f = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a dataset in the file */ - if((s = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR - if((d = H5Dcreate2(f, DATASETNAME, H5T_NATIVE_INT, s, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Sclose(s) < 0) FAIL_STACK_ERROR + if ((s = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR + if ((d = H5Dcreate2(f, DATASETNAME, H5T_NATIVE_INT, s, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Sclose(s) < 0) + FAIL_STACK_ERROR /* Unlink the dataset while it's open (will mark it for deletion when closed) */ - if(H5Ldelete(f, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(f, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check that dataset name is NULL */ - if(H5Iget_name(d, NULL, (size_t)0) != 0) FAIL_STACK_ERROR + if (H5Iget_name(d, NULL, (size_t)0) != 0) + FAIL_STACK_ERROR /* Re-link the dataset to the group hierarchy (shouldn't get deleted now) */ - if(H5Lcreate_hard(d, ".", f, DATASET2NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(d, ".", f, DATASET2NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close things */ - if(H5Dclose(d) < 0) FAIL_STACK_ERROR - if(H5Fclose(f) < 0) FAIL_STACK_ERROR + if (H5Dclose(d) < 0) + FAIL_STACK_ERROR + if (H5Fclose(f) < 0) + FAIL_STACK_ERROR /* Re-open the file */ - if((f = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((f = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Attempt to open the dataset under the new name */ - if((d = H5Dopen2(f, DATASET2NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((d = H5Dopen2(f, DATASET2NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close things */ - if(H5Dclose(d) < 0) FAIL_STACK_ERROR - if(H5Fclose(f) < 0) FAIL_STACK_ERROR + if (H5Dclose(d) < 0) + FAIL_STACK_ERROR + if (H5Fclose(f) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Sclose(s); - H5Dclose(d); - H5Fclose(f); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Sclose(s); + H5Dclose(d); + H5Fclose(f); + } + H5E_END_TRY; return 1; } /* end test_resurrect_dataset() */ - /*------------------------------------------------------------------------- * Function: test_resurrect_datatype * @@ -1938,8 +2392,8 @@ error: static int test_resurrect_datatype(hid_t fapl) { - hid_t file = -1, type = -1; - char filename[1024]; + hid_t file = -1, type = -1; + char filename[1024]; TESTING("resurrecting datatype after deletion"); @@ -1947,47 +2401,60 @@ test_resurrect_datatype(hid_t fapl) h5_fixname(FILENAME[7], fapl, filename, sizeof filename); /* Create the file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a named datatype in the file */ - if((type = H5Tcopy (H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR - if(H5Tcommit2(file, TYPENAME, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if ((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR + if (H5Tcommit2(file, TYPENAME, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Unlink the datatype while it's open (will mark it for deletion when closed) */ - if(H5Ldelete(file, TYPENAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, TYPENAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check that datatype name is NULL */ - if(H5Iget_name(type, NULL, (size_t)0) != 0) FAIL_STACK_ERROR + if (H5Iget_name(type, NULL, (size_t)0) != 0) + FAIL_STACK_ERROR /* Re-link the datatype to the group hierarchy (shouldn't get deleted now) */ - if(H5Lcreate_hard(type, ".", file, TYPE2NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(type, ".", file, TYPE2NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close things */ - if(H5Tclose(type) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Attempt to open the datatype under the new name */ - if((type = H5Topen2(file,TYPE2NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((type = H5Topen2(file, TYPE2NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close things */ - if(H5Tclose(type) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Tclose(type) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Tclose(type); - H5Fclose(file); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Tclose(type); + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* end test_resurrect_datatype() */ - /*------------------------------------------------------------------------- * Function: test_resurrect_group * @@ -2007,8 +2474,8 @@ error: static int test_resurrect_group(hid_t fapl) { - hid_t file = -1, group = -1; - char filename[1024]; + hid_t file = -1, group = -1; + char filename[1024]; TESTING("resurrecting group after deletion"); @@ -2016,46 +2483,58 @@ test_resurrect_group(hid_t fapl) h5_fixname(FILENAME[8], fapl, filename, sizeof filename); /* Create the file */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create a group in the file */ - if((group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group = H5Gcreate2(file, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Unlink the group while it's open (will mark it for deletion when closed) */ - if(H5Ldelete(file, GROUPNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file, GROUPNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check that group's name is NULL */ - if(H5Iget_name(group, NULL, (size_t)0) != 0) FAIL_STACK_ERROR + if (H5Iget_name(group, NULL, (size_t)0) != 0) + FAIL_STACK_ERROR /* Re-link the group into the group hierarchy (shouldn't get deleted now) */ - if(H5Lcreate_hard(group, ".", file, GROUP2NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(group, ".", file, GROUP2NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close things */ - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR + if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR /* Attempt to open the datatype under the new name */ - if((group = H5Gopen2(file, GROUP2NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((group = H5Gopen2(file, GROUP2NAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close things */ - if(H5Gclose(group) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR + if (H5Gclose(group) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(group); - H5Fclose(file); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(group); + H5Fclose(file); + } + H5E_END_TRY; return 1; } /* end test_resurrect_group() */ - /*------------------------------------------------------------------------- * Function: test_unlink_chunked_dataset * @@ -2074,14 +2553,14 @@ error: static int test_unlink_chunked_dataset(hid_t fapl) { - hid_t file_id = -1; - hid_t dset_id = -1; - hid_t space_id = -1; - hid_t dcpl_id = -1; - hsize_t dims[FILESPACE_NDIMS] = {FILESPACE_DIM0, FILESPACE_DIM1, FILESPACE_DIM2}; - hsize_t max_dims[FILESPACE_NDIMS] = {H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED}; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t space_id = -1; + hid_t dcpl_id = -1; + hsize_t dims[FILESPACE_NDIMS] = {FILESPACE_DIM0, FILESPACE_DIM1, FILESPACE_DIM2}; + hsize_t max_dims[FILESPACE_NDIMS] = {H5S_UNLIMITED, H5S_UNLIMITED, H5S_UNLIMITED}; hsize_t chunk_dims[FILESPACE_NDIMS] = {FILESPACE_CHUNK0, FILESPACE_CHUNK1, FILESPACE_CHUNK2}; - char filename[1024]; + char filename[1024]; TESTING("unlinking chunked dataset"); @@ -2089,58 +2568,73 @@ test_unlink_chunked_dataset(hid_t fapl) h5_fixname(FILENAME[9], fapl, filename, sizeof filename); /* Create the file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create the dataspace */ - if((space_id = H5Screate_simple(FILESPACE_NDIMS, dims, max_dims)) < 0) FAIL_STACK_ERROR + if ((space_id = H5Screate_simple(FILESPACE_NDIMS, dims, max_dims)) < 0) + FAIL_STACK_ERROR /* Create the dataset creation filter */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR /* Set to chunked storage */ - if(H5Pset_chunk(dcpl_id, FILESPACE_NDIMS, chunk_dims) < 0) FAIL_STACK_ERROR + if (H5Pset_chunk(dcpl_id, FILESPACE_NDIMS, chunk_dims) < 0) + FAIL_STACK_ERROR /* Set to early space allocation */ - if(H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY) < 0) FAIL_STACK_ERROR + if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY) < 0) + FAIL_STACK_ERROR /* Create the dataset */ - if((dset_id = H5Dcreate2(file_id, DATASETNAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dset_id = H5Dcreate2(file_id, DATASETNAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, + H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close the dataspace */ - if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR + if (H5Sclose(space_id) < 0) + FAIL_STACK_ERROR /* Close the dataset creation property list */ - if(H5Pclose(dcpl_id) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl_id) < 0) + FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR + if (H5Dclose(dset_id) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Delete the dataset */ - if(H5Ldelete(file_id, DATASETNAME, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, DATASETNAME, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Pclose(dcpl_id); - H5Sclose(space_id); - H5Dclose(dset_id); - H5Fclose(file_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Pclose(dcpl_id); + H5Sclose(space_id); + H5Dclose(dset_id); + H5Fclose(file_id); + } + H5E_END_TRY; return 1; } /* end test_unlink_chunked_dataset() */ - /*------------------------------------------------------------------------- * Function: test_full_group_compact * @@ -2157,15 +2651,15 @@ error: static int test_full_group_compact(hid_t fapl) { - hid_t file_id = -1; - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5O_info2_t oi; /* Stat buffer for object */ - char objname[128]; /* Buffer for name of objects to create */ - char objname2[128]; /* Buffer for name of objects to create */ - char filename[1024]; /* Buffer for filename */ - h5_stat_size_t keep_size; /* Size of the file with objects to keep */ - h5_stat_size_t file_size; /* Size of each file created */ - unsigned u; /* Local index variable */ + hid_t file_id = -1; + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5O_info2_t oi; /* Stat buffer for object */ + char objname[128]; /* Buffer for name of objects to create */ + char objname2[128]; /* Buffer for name of objects to create */ + char filename[1024]; /* Buffer for filename */ + h5_stat_size_t keep_size; /* Size of the file with objects to keep */ + h5_stat_size_t file_size; /* Size of each file created */ + unsigned u; /* Local index variable */ TESTING("unlinking non-empty compact group"); @@ -2173,107 +2667,135 @@ test_full_group_compact(hid_t fapl) h5_fixname(FILENAME[10], fapl, filename, sizeof filename); /* Create the file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create group to link objects to */ - if((gid = H5Gcreate2(file_id, "/keep", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(file_id, "/keep", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create several objects to link to */ - for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { + for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { HDsprintf(objname, "keep %u\n", u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close group with objects to keep */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Get the size of the file with only the objects to keep */ - if((keep_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((keep_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Create group to delete */ - if((gid = H5Gcreate2(file_id, "/delete", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(file_id, "/delete", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create external link (doesn't matter if it dangles) */ - if(H5Lcreate_external("foo.h5", "/dst", gid, "external", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_external("foo.h5", "/dst", gid, "external", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create soft link (doesn't matter if it dangles) */ - if(H5Lcreate_soft("/foo", gid, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/foo", gid, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create hard links to objects in group to keep */ - for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { + for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { HDsprintf(objname, "/keep/keep %u\n", u); HDsprintf(objname2, "keep %u\n", u); - if(H5Lcreate_hard(file_id, objname, gid, objname2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(file_id, objname, gid, objname2, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Create several objects to delete */ - for(u = 0; u < FULL_GROUP_NUM_DELETE_COMPACT; u++) { + for (u = 0; u < FULL_GROUP_NUM_DELETE_COMPACT; u++) { HDsprintf(objname, "delete %u\n", u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR } /* end for */ /* Check on group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) != TRUE) TEST_ERROR - if(H5G__has_stab_test(gid) == TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) != TRUE) + TEST_ERROR + if (H5G__has_stab_test(gid) == TRUE) + TEST_ERROR /* Close group with objects to delete */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Check reference count on objects to keep */ - for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { + for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { HDsprintf(objname, "/keep/keep %u\n", u); - if(H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(oi.rc != 2) TEST_ERROR + if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (oi.rc != 2) + TEST_ERROR } /* end for */ /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR - + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Delete the full group */ - if(H5Ldelete(file_id, "/delete", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/delete", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check reference count on objects to keep */ - for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { + for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { HDsprintf(objname, "/keep/keep %u\n", u); - if(H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(oi.rc != 1) TEST_ERROR + if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (oi.rc != 1) + TEST_ERROR } /* end for */ /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != keep_size) TEST_ERROR + if (file_size != keep_size) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(file_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(file_id); + } + H5E_END_TRY; return 1; } /* end test_full_group_compact() */ - /*------------------------------------------------------------------------- * Function: test_full_group_dense * @@ -2290,16 +2812,16 @@ error: static int test_full_group_dense(hid_t fapl) { - hid_t file_id = -1; - hid_t gcpl = (-1); /* Group creation property list ID */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5O_info2_t oi; /* Stat buffer for object */ - char objname[128]; /* Buffer for name of objects to create */ - char objname2[128]; /* Buffer for name of objects to create */ - char filename[1024]; /* Buffer for filename */ - h5_stat_size_t keep_size; /* Size of the file with objects to keep */ - h5_stat_size_t file_size; /* Size of each file created */ - unsigned u; /* Local index variable */ + hid_t file_id = -1; + hid_t gcpl = (-1); /* Group creation property list ID */ + hid_t gid = -1, gid2 = -1; /* Group IDs */ + H5O_info2_t oi; /* Stat buffer for object */ + char objname[128]; /* Buffer for name of objects to create */ + char objname2[128]; /* Buffer for name of objects to create */ + char filename[1024]; /* Buffer for filename */ + h5_stat_size_t keep_size; /* Size of the file with objects to keep */ + h5_stat_size_t file_size; /* Size of each file created */ + unsigned u; /* Local index variable */ TESTING("unlinking non-empty dense group"); @@ -2307,33 +2829,43 @@ test_full_group_dense(hid_t fapl) h5_fixname(FILENAME[10], fapl, filename, sizeof filename); /* Create the file */ - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR /* Create group to link objects to */ - if((gid = H5Gcreate2(file_id, "/keep", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(file_id, "/keep", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Create several objects to link to */ - for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { + for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { HDsprintf(objname, "keep %u\n", u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR } /* end for */ /* Close group with objects to keep */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Get the size of the file with only the objects to keep */ - if((keep_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((keep_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Set group creation "est. link info" closer to what will actually occur */ - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) FAIL_STACK_ERROR - if(H5Pset_est_link_info(gcpl, FULL_GROUP_EST_NUM_ENTRIES, FULL_GROUP_EST_ENTRY_LEN) < 0) FAIL_STACK_ERROR + if ((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + FAIL_STACK_ERROR + if (H5Pset_est_link_info(gcpl, FULL_GROUP_EST_NUM_ENTRIES, FULL_GROUP_EST_ENTRY_LEN) < 0) + FAIL_STACK_ERROR /* Create group to delete */ /* (use non-default GCPL, in order to make certain that the group's object @@ -2341,86 +2873,107 @@ test_full_group_dense(hid_t fapl) * another object header message chunk - in order to make the file size * computation below easier/correct - QAK) */ - if((gid = H5Gcreate2(file_id, "/delete", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((gid = H5Gcreate2(file_id, "/delete", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR /* Close GCPL */ - if(H5Pclose(gcpl) < 0) FAIL_STACK_ERROR + if (H5Pclose(gcpl) < 0) + FAIL_STACK_ERROR /* Create external link (doesn't matter if it dangles) */ - if(H5Lcreate_external("foo.h5", "/dst", gid, "external", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_external("foo.h5", "/dst", gid, "external", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create soft link (doesn't matter if it dangles) */ - if(H5Lcreate_soft("/foo", gid, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_soft("/foo", gid, "soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Create hard links to objects in group to keep */ - for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { + for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { HDsprintf(objname, "/keep/keep %u\n", u); HDsprintf(objname2, "keep %u\n", u); - if(H5Lcreate_hard(file_id, objname, gid, objname2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Lcreate_hard(file_id, objname, gid, objname2, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR } /* end for */ /* Create several objects to delete */ - for(u = 0; u < FULL_GROUP_NUM_DELETE_DENSE; u++) { + for (u = 0; u < FULL_GROUP_NUM_DELETE_DENSE; u++) { HDsprintf(objname, "delete %u\n", u); - if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(gid2) < 0) FAIL_STACK_ERROR + if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if (H5Gclose(gid2) < 0) + FAIL_STACK_ERROR } /* end for */ /* Check on group's status */ - if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR + if (H5G__is_empty_test(gid) == TRUE) + TEST_ERROR + if (H5G__has_links_test(gid, NULL) == TRUE) + TEST_ERROR + if (H5G__is_new_dense_test(gid) != TRUE) + TEST_ERROR /* Close group with objects to delete */ - if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR /* Check reference count on objects to keep */ - for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { + for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { HDsprintf(objname, "/keep/keep %u\n", u); - if(H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(oi.rc != 2) TEST_ERROR + if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (oi.rc != 2) + TEST_ERROR } /* end for */ /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR - + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Re-open the file */ - if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if ((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR /* Delete the full group */ - if(H5Ldelete(file_id, "/delete", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if (H5Ldelete(file_id, "/delete", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Check reference count on objects to keep */ - for(u = 0; u < FULL_GROUP_NUM_KEEP; u++) { + for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { HDsprintf(objname, "/keep/keep %u\n", u); - if(H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - if(oi.rc != 1) TEST_ERROR + if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + if (oi.rc != 1) + TEST_ERROR } /* end for */ /* Close the file */ - if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR + if (H5Fclose(file_id) < 0) + FAIL_STACK_ERROR /* Get the size of the file */ - if((file_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + if ((file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR /* Verify the file is correct size */ - if(file_size != keep_size) TEST_ERROR + if (file_size != keep_size) + TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { - H5Gclose(gid2); - H5Gclose(gid); + H5E_BEGIN_TRY + { + H5Gclose(gid2); + H5Gclose(gid); H5Pclose(gcpl); - H5Fclose(file_id); - } H5E_END_TRY; + H5Fclose(file_id); + } + H5E_END_TRY; return 1; } /* end test_full_group_dense() */ - /*------------------------------------------------------------------------- * Function: main * @@ -2437,12 +2990,12 @@ int main(void) { hid_t fapl, fapl2, file; - int nerrors = 0; - char filename[1024]; - unsigned new_format; + int nerrors = 0; + char filename[1024]; + unsigned new_format; /* Metadata cache parameters */ - int mdc_nelmts; + int mdc_nelmts; size_t rdcc_nelmts; size_t rdcc_nbytes; double rdcc_w0; @@ -2455,17 +3008,19 @@ main(void) fapl = h5_fileaccess(); /* Copy the file access property list */ - if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((fapl2 = H5Pcopy(fapl)) < 0) + TEST_ERROR /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR + if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR /* Test with old & new format groups */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl; /* Set the FAPL for the type of format */ - if(new_format) { + if (new_format) { HDputs("\nTesting with new group format:"); my_fapl = fapl2; } /* end if */ @@ -2475,7 +3030,8 @@ main(void) } /* end else */ h5_fixname(FILENAME[0], my_fapl, filename, sizeof filename); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) + TEST_ERROR /* Tests */ nerrors += test_one(file); @@ -2494,22 +3050,24 @@ main(void) hid_t fapl_small_mdc; /* Make copy of regular fapl, to turn down the elements in the metadata cache */ - if((fapl_small_mdc = H5Pcopy(my_fapl)) < 0) + if ((fapl_small_mdc = H5Pcopy(my_fapl)) < 0) goto error; /* Get FAPL cache settings */ - if(H5Pget_cache(fapl_small_mdc, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) + if (H5Pget_cache(fapl_small_mdc, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) HDprintf("H5Pget_cache failed\n"); /* Change FAPL cache settings */ - mdc_nelmts=1; - if(H5Pset_cache(fapl_small_mdc, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + mdc_nelmts = 1; + if (H5Pset_cache(fapl_small_mdc, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) HDprintf("H5Pset_cache failed\n"); /* Test creating & unlinking lots of objects with a 1-element metadata cache FAPL */ - nerrors += test_create_unlink("create and unlink large number of objects with small cache", fapl_small_mdc); + nerrors += test_create_unlink("create and unlink large number of objects with small cache", + fapl_small_mdc); - if(H5Pclose(fapl_small_mdc) < 0) TEST_ERROR + if (H5Pclose(fapl_small_mdc) < 0) + TEST_ERROR } /* end block */ nerrors += test_link_slashes(my_fapl); @@ -2517,7 +3075,7 @@ main(void) /* Test specific B-tree removal issues */ /* (only for old format groups) */ - if(!new_format) { + if (!new_format) { nerrors += test_unlink_rightleaf(file); nerrors += test_unlink_rightnode(file); nerrors += test_unlink_middlenode(file); @@ -2533,13 +3091,14 @@ main(void) /* Test unlinked groups which still have objects in them */ /* (only for new format groups) */ - if(new_format) { + if (new_format) { nerrors += test_full_group_compact(my_fapl); nerrors += test_full_group_dense(my_fapl); } /* end if */ /* Close */ - if(H5Fclose(file) < 0) TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR } /* end for */ /* Close 2nd FAPL */ @@ -2549,7 +3108,7 @@ main(void) nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); if (nerrors) { - HDprintf("***** %d FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S"); + HDprintf("***** %d FAILURE%s! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } @@ -2562,4 +3121,3 @@ main(void) error: HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/unregister.c b/test/unregister.c index a2a507d..edc6a19 100644 --- a/test/unregister.c +++ b/test/unregister.c @@ -17,40 +17,35 @@ */ #include "h5test.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ -const char *FILENAME[] = { - "unregister_filter_1", - "unregister_filter_2", - NULL -}; +const char *FILENAME[] = {"unregister_filter_1", "unregister_filter_2", NULL}; -#define GROUP_NAME "test_group" -#define DSET_NAME "test_dataset" -#define FILENAME_BUF_SIZE 1024 -#define DSET_DIM1 100 -#define DSET_DIM2 200 -#define FILTER_CHUNK_DIM1 2 -#define FILTER_CHUNK_DIM2 25 -#define GROUP_ITERATION 1000 +#define GROUP_NAME "test_group" +#define DSET_NAME "test_dataset" +#define FILENAME_BUF_SIZE 1024 +#define DSET_DIM1 100 +#define DSET_DIM2 200 +#define FILTER_CHUNK_DIM1 2 +#define FILTER_CHUNK_DIM2 25 +#define GROUP_ITERATION 1000 -#define H5Z_FILTER_DUMMY 312 +#define H5Z_FILTER_DUMMY 312 -static size_t do_nothing(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t do_nothing(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); /* Dummy filter for test_unregister_filters only */ const H5Z_class2_t H5Z_DUMMY[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DUMMY, /* Filter ID number */ - 1, 1, /* Encoding and decoding enabled */ - "dummy", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - do_nothing, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DUMMY, /* Filter ID number */ + 1, 1, /* Encoding and decoding enabled */ + "dummy", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + do_nothing, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: do_nothing * @@ -64,8 +59,8 @@ const H5Z_class2_t H5Z_DUMMY[1] = {{ */ static size_t do_nothing(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { return nbytes; } @@ -82,41 +77,41 @@ do_nothing(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, static herr_t test_unregister_filters(hid_t fapl_id) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t gid_loop = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - int i, j, n; - char group_name[32]; - char filename[FILENAME_BUF_SIZE]; - const hsize_t chunk_dims[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ - hsize_t dims[2]; - int **buf = NULL; - int *buf_data = NULL; - herr_t ret; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t gcpl_id = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t gid_loop = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + int i, j, n; + char group_name[32]; + char filename[FILENAME_BUF_SIZE]; + const hsize_t chunk_dims[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ + hsize_t dims[2]; + int ** buf = NULL; + int * buf_data = NULL; + herr_t ret; TESTING("Unregistering filter"); /* Set up data array */ - if(NULL == (buf_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + if (NULL == (buf_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) TEST_ERROR; - if(NULL == (buf = (int **)HDcalloc(DSET_DIM1, sizeof(buf_data)))) + if (NULL == (buf = (int **)HDcalloc(DSET_DIM1, sizeof(buf_data)))) TEST_ERROR; for (i = 0; i < DSET_DIM1; i++) buf[i] = buf_data + (i * DSET_DIM2); /* Create first file */ h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); - if((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) goto error; /* Create second file */ h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)); - if((fid2 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid2 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) goto error; /* Register DUMMY filter */ @@ -130,44 +125,46 @@ test_unregister_filters(hid_t fapl_id) *******************/ /* Use DUMMY filter for creating groups */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error; - if(H5Pset_filter(gcpl_id, H5Z_FILTER_DUMMY, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) + if (H5Pset_filter(gcpl_id, H5Z_FILTER_DUMMY, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) goto error; /* Create a group using this filter */ - if((gid = H5Gcreate2(fid1, GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid1, GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto error; /* Create multiple groups under the main group */ - for(i = 0; i < GROUP_ITERATION; i++) { + for (i = 0; i < GROUP_ITERATION; i++) { HDsprintf(group_name, "group_%d", i); - if((gid_loop = H5Gcreate2(gid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid_loop = H5Gcreate2(gid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid_loop) < 0) + if (H5Gclose(gid_loop) < 0) goto error; } /* Flush the file containing the groups */ - if(H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) goto error; /* Unregister the filter before closing the group. It should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Zunregister(H5Z_FILTER_DUMMY); - } H5E_END_TRY; - if(ret >= 0) { + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf(" Line %d: Should not be able to unregister filter\n", __LINE__); goto error; } /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; /* Clean up objects used for this test */ - if(H5Pclose (gcpl_id) < 0) + if (H5Pclose(gcpl_id) < 0) goto error; /********************* @@ -175,70 +172,72 @@ test_unregister_filters(hid_t fapl_id) *********************/ /* Use DUMMY filter for creating datasets */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) goto error; - if(H5Pset_filter(dcpl_id, H5Z_FILTER_DUMMY, 0, (size_t)0, NULL) < 0) + if (H5Pset_filter(dcpl_id, H5Z_FILTER_DUMMY, 0, (size_t)0, NULL) < 0) goto error; /* Initialize the data for writing */ - for(i = n = 0; i < DSET_DIM1; i++) - for(j = 0; j < DSET_DIM2; j++) + for (i = n = 0; i < DSET_DIM1; i++) + for (j = 0; j < DSET_DIM2; j++) buf[i][j] = n++; /* Create the dataspace */ dims[0] = DSET_DIM1; dims[1] = DSET_DIM2; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) goto error; /* Create a dataset in the first file */ - if((did = H5Dcreate2(fid1, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid1, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) goto error; /* Unregister the filter before closing the dataset. It should fail */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Zunregister(H5Z_FILTER_DUMMY); - } H5E_END_TRY; - if(ret >= 0) { + } + H5E_END_TRY; + if (ret >= 0) { H5_FAILED(); HDprintf(" Line %d: Should not be able to unregister filter\n", __LINE__); goto error; } /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create a dataset in the second file */ - if((did = H5Dcreate2(fid2, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid2, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) goto error; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) goto error; /* Close the dataset in the second file */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Unregister the filter after closing all objects but before closing files. * It should flush all files. */ - if(H5Zunregister(H5Z_FILTER_DUMMY) < 0) + if (H5Zunregister(H5Z_FILTER_DUMMY) < 0) goto error; /* Clean up objects used for this test */ - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) goto error; - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) goto error; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) goto error; HDfree(buf); @@ -248,7 +247,8 @@ test_unregister_filters(hid_t fapl_id) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid1); H5Fclose(fid2); H5Pclose(dcpl_id); @@ -257,7 +257,8 @@ error: H5Gclose(gid_loop); H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); HDfree(buf_data); @@ -265,7 +266,6 @@ error: return FAIL; } - /*------------------------------------------------------------------------- * Function: main * @@ -278,20 +278,21 @@ error: int main(void) { - hid_t fapl_id = H5I_INVALID_HID; - int nerrors = 0; - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t fapl_id = H5I_INVALID_HID; + int nerrors = 0; + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Testing setup */ h5_reset(); fapl_id = h5_fileaccess(); /* Push API context */ - if(H5CX_push() < 0) FAIL_STACK_ERROR + if (H5CX_push() < 0) + FAIL_STACK_ERROR api_ctx_pushed = TRUE; /* Test unregistering filter in its own file */ - nerrors += (test_unregister_filters(fapl_id) < 0 ? 1 : 0); + nerrors += (test_unregister_filters(fapl_id) < 0 ? 1 : 0); h5_cleanup(FILENAME, fapl_id); @@ -300,19 +301,18 @@ main(void) HDprintf("All filter unregistration tests passed.\n"); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if (api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; - HDexit(EXIT_SUCCESS); error: nerrors = MAX(1, nerrors); - HDprintf("***** %d FILTER UNREGISTRATION TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d FILTER UNREGISTRATION TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/test/use.h b/test/use.h index 52537d6..0ea86e2d 100644 --- a/test/use.h +++ b/test/use.h @@ -16,46 +16,52 @@ #include "h5test.h" /* Macro definitions */ -#define Hgoto_error(val) {ret_value=val; goto done;} -#define Hgoto_done {goto done;} -#define Chunksize_DFT 256 /* chunksize default */ -#define ErrorReportMax 10 /* max number of errors reported */ +#define Hgoto_error(val) \ + { \ + ret_value = val; \ + goto done; \ + } +#define Hgoto_done \ + { \ + goto done; \ + } +#define Chunksize_DFT 256 /* chunksize default */ +#define ErrorReportMax 10 /* max number of errors reported */ /* these two definitions must match each other */ -#define UC_DATATYPE H5T_NATIVE_SHORT /* use case HDF5 data type */ -#define UC_CTYPE short /* use case C data type */ -#define UC_RANK 3 /* use case dataset rank */ +#define UC_DATATYPE H5T_NATIVE_SHORT /* use case HDF5 data type */ +#define UC_CTYPE short /* use case C data type */ +#define UC_RANK 3 /* use case dataset rank */ /* Name of message file that is sent by the writer */ -#define WRITER_MESSAGE "USE_WRITER_MESSAGE" +#define WRITER_MESSAGE "USE_WRITER_MESSAGE" /* type declarations */ typedef enum part_t { - UC_READWRITE = 0, /* both writer and reader */ - UC_WRITER, /* writer only */ - UC_READER /* reader only */ + UC_READWRITE = 0, /* both writer and reader */ + UC_WRITER, /* writer only */ + UC_READER /* reader only */ } part_t; typedef struct options_t { - hsize_t chunksize; /* chunks are chunksize^2 planes */ - hsize_t chunkplanes; /* number of planes per chunk, default 1 */ - hsize_t chunkdims[UC_RANK]; /* chunk dims is (chunkplan, chunksize, chunksize) */ - hsize_t dims[UC_RANK]; /* dataset initial dims */ - hsize_t max_dims[UC_RANK]; /* dataset max dims */ - hsize_t nplanes; /* number of planes to write, default proportional to chunksize */ - char *filename; /* use case data filename */ - part_t launch; /* launch writer, reader or both */ - hbool_t use_swmr; /* use swmr open (1) or not */ - int iterations; /* iterations, default 1 */ - hid_t fapl_id; /* instance-specific FAPL ID */ - const char *progname; /* Program name (used in usage and dset name) */ + hsize_t chunksize; /* chunks are chunksize^2 planes */ + hsize_t chunkplanes; /* number of planes per chunk, default 1 */ + hsize_t chunkdims[UC_RANK]; /* chunk dims is (chunkplan, chunksize, chunksize) */ + hsize_t dims[UC_RANK]; /* dataset initial dims */ + hsize_t max_dims[UC_RANK]; /* dataset max dims */ + hsize_t nplanes; /* number of planes to write, default proportional to chunksize */ + char * filename; /* use case data filename */ + part_t launch; /* launch writer, reader or both */ + hbool_t use_swmr; /* use swmr open (1) or not */ + int iterations; /* iterations, default 1 */ + hid_t fapl_id; /* instance-specific FAPL ID */ + const char *progname; /* Program name (used in usage and dset name) */ } options_t; /* prototype declarations */ -int parse_option(int argc, char * const argv[], options_t * opts); -int setup_parameters(int argc, char * const argv[], options_t * opts); -void show_parameters(options_t * opts); +int parse_option(int argc, char *const argv[], options_t *opts); +int setup_parameters(int argc, char *const argv[], options_t *opts); +void show_parameters(options_t *opts); void usage(const char *prog); -int create_uc_file(options_t * opts); -int write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts); -int read_uc_file(hbool_t towait, options_t * opts); - +int create_uc_file(options_t *opts); +int write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts); +int read_uc_file(hbool_t towait, options_t *opts); diff --git a/test/use_append_chunk.c b/test/use_append_chunk.c index 8fcf0d3..349ab24 100644 --- a/test/use_append_chunk.c +++ b/test/use_append_chunk.c @@ -77,23 +77,23 @@ static options_t UC_opts; /* Use Case Options */ * Return: 0 succeed; -1 fail. */ int -setup_parameters(int argc, char * const argv[], options_t * opts) +setup_parameters(int argc, char *const argv[], options_t *opts) { /* use case defaults */ HDmemset(opts, 0, sizeof(options_t)); - opts->chunksize = Chunksize_DFT; - opts->use_swmr = TRUE; /* use swmr open */ - opts->iterations = 1; + opts->chunksize = Chunksize_DFT; + opts->use_swmr = TRUE; /* use swmr open */ + opts->iterations = 1; opts->chunkplanes = 1; - opts->progname = USE_APPEND_CHUNK_PROGNAME; + opts->progname = USE_APPEND_CHUNK_PROGNAME; if (parse_option(argc, argv, opts) < 0) - return(-1); + return (-1); opts->chunkdims[0] = opts->chunkplanes; opts->chunkdims[1] = opts->chunkdims[2] = opts->chunksize; - opts->dims[0] = 0; + opts->dims[0] = 0; opts->max_dims[0] = H5S_UNLIMITED; opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = opts->chunksize; @@ -101,10 +101,9 @@ setup_parameters(int argc, char * const argv[], options_t * opts) opts->nplanes = (hsize_t)opts->chunksize; show_parameters(opts); - return(0); + return (0); } /* setup_parameters() */ - /* Overall Algorithm: * Parse options from user; * Generate/pre-created test files needed and close it; @@ -115,15 +114,15 @@ setup_parameters(int argc, char * const argv[], options_t * opts) int main(int argc, char *argv[]) { - pid_t childpid=0; - pid_t mypid, tmppid; - int child_status; - int child_wait_option=0; - int ret_value = 0; - int child_ret_value; + pid_t childpid = 0; + pid_t mypid, tmppid; + int child_status; + int child_wait_option = 0; + int ret_value = 0; + int child_ret_value; hbool_t send_wait = FALSE; - hid_t fapl = -1; /* File access property list */ - hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t fid = -1; /* File ID */ if (setup_parameters(argc, argv, &UC_opts) < 0) { Hgoto_error(1); @@ -156,7 +155,8 @@ main(int argc, char *argv[]) if (create_uc_file(&UC_opts) < 0) { HDfprintf(stderr, "***encounter error\n"); Hgoto_error(1); - } else { + } + else { HDprintf("File created.\n"); } /* Close FAPL to prevent issues with forking later */ @@ -219,7 +219,8 @@ main(int argc, char *argv[]) } } - if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { + if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < + 0) { HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } @@ -250,11 +251,11 @@ main(int argc, char *argv[]) if (WIFEXITED(child_status)) { if ((child_ret_value = WEXITSTATUS(child_status)) != 0) { - HDprintf("%d: child process exited with non-zero code (%d)\n", - mypid, child_ret_value); + HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(2); } - } else { + } + else { HDprintf("%d: child process terminated abnormally\n", mypid); Hgoto_error(2); } @@ -263,11 +264,12 @@ main(int argc, char *argv[]) done: if (ret_value != 0) { HDprintf("Error(s) encountered\n"); - } else { + } + else { HDprintf("All passed\n"); } - return(ret_value); + return (ret_value); } #else /* H5_HAVE_FORK */ @@ -280,4 +282,3 @@ main(void) } /* end main() */ #endif /* H5_HAVE_FORK */ - diff --git a/test/use_append_chunk_mirror.c b/test/use_append_chunk_mirror.c index 6ee01c0..4b7845d 100644 --- a/test/use_append_chunk_mirror.c +++ b/test/use_append_chunk_mirror.c @@ -106,9 +106,9 @@ #if CONNECT_WITH_JELLY #define SERVER_IP "10.10.10.248" /* hard-coded IP address */ #else -#define SERVER_IP "127.0.0.1" /* localhost */ -#endif /* CONNECT_WITH_JELLY */ -#define SERVER_PORT 3000 /* hard-coded port number */ +#define SERVER_IP "127.0.0.1" /* localhost */ +#endif /* CONNECT_WITH_JELLY */ +#define SERVER_PORT 3000 /* hard-coded port number */ #define MIRROR_FILE_NAME "shinano.h5" /* hard-coded duplicate/mirror filename */ static options_t UC_opts; /* Use Case Options */ @@ -117,23 +117,23 @@ static options_t UC_opts; /* Use Case Options */ * Return: 0 succeed; -1 fail. */ int -setup_parameters(int argc, char * const argv[], options_t * opts) +setup_parameters(int argc, char *const argv[], options_t *opts) { /* use case defaults */ HDmemset(opts, 0, sizeof(options_t)); - opts->chunksize = Chunksize_DFT; - opts->use_swmr = TRUE; - opts->iterations = 1; + opts->chunksize = Chunksize_DFT; + opts->use_swmr = TRUE; + opts->iterations = 1; opts->chunkplanes = 1; - opts->progname = THIS_PROGNAME; + opts->progname = THIS_PROGNAME; if (parse_option(argc, argv, opts) < 0) - return(-1); + return (-1); opts->chunkdims[0] = opts->chunkplanes; opts->chunkdims[1] = opts->chunkdims[2] = opts->chunksize; - opts->dims[0] = 0; + opts->dims[0] = 0; opts->max_dims[0] = H5S_UNLIMITED; opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = opts->chunksize; @@ -141,10 +141,9 @@ setup_parameters(int argc, char * const argv[], options_t * opts) opts->nplanes = (hsize_t)opts->chunksize; show_parameters(opts); - return(0); + return (0); } /* setup_parameters() */ - /* Overall Algorithm: * Parse options from user; * Generate/pre-created test files needed and close it; @@ -155,17 +154,17 @@ setup_parameters(int argc, char * const argv[], options_t * opts) int main(int argc, char *argv[]) { - pid_t childpid=0; - pid_t mypid, tmppid; - int child_status; - int child_wait_option=0; - int ret_value = 0; - int child_ret_value; - hbool_t send_wait = FALSE; - hid_t fid = -1; /* File ID */ - H5FD_mirror_fapl_t mirr_fa; + pid_t childpid = 0; + pid_t mypid, tmppid; + int child_status; + int child_wait_option = 0; + int ret_value = 0; + int child_ret_value; + hbool_t send_wait = FALSE; + hid_t fid = -1; /* File ID */ + H5FD_mirror_fapl_t mirr_fa; H5FD_splitter_vfd_config_t split_fa; - hid_t mirr_fapl_id = H5I_INVALID_HID; + hid_t mirr_fapl_id = H5I_INVALID_HID; if (setup_parameters(argc, argv, &UC_opts) < 0) { Hgoto_error(1); @@ -176,7 +175,6 @@ main(int argc, char *argv[]) mirr_fa.handshake_port = SERVER_PORT; HDstrncpy(mirr_fa.remote_ip, SERVER_IP, H5FD_MIRROR_MAX_IP_LEN); - split_fa.wo_fapl_id = H5I_INVALID_HID; split_fa.rw_fapl_id = H5I_INVALID_HID; split_fa.magic = H5FD_SPLITTER_MAGIC; @@ -215,9 +213,9 @@ main(int argc, char *argv[]) } /* Prepare parent "splitter" driver in UC_opts */ - split_fa.wo_fapl_id = mirr_fapl_id; - split_fa.rw_fapl_id = H5P_DEFAULT; - UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS); + split_fa.wo_fapl_id = mirr_fapl_id; + split_fa.rw_fapl_id = H5P_DEFAULT; + UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS); if (UC_opts.fapl_id == H5I_INVALID_HID) { HDfprintf(stderr, "can't create creation FAPL\n"); Hgoto_error(1); @@ -237,7 +235,8 @@ main(int argc, char *argv[]) if (create_uc_file(&UC_opts) < 0) { HDfprintf(stderr, "***encounter error\n"); Hgoto_error(1); - } else { + } + else { HDprintf("File created.\n"); } @@ -303,9 +302,9 @@ main(int argc, char *argv[]) } /* Prepare parent "splitter" driver in UC_opts */ - split_fa.wo_fapl_id = mirr_fapl_id; - split_fa.rw_fapl_id = H5P_DEFAULT; - UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS); + split_fa.wo_fapl_id = mirr_fapl_id; + split_fa.rw_fapl_id = H5P_DEFAULT; + UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS); if (UC_opts.fapl_id == H5I_INVALID_HID) { HDfprintf(stderr, "can't create creation FAPL\n"); Hgoto_error(1); @@ -323,7 +322,8 @@ main(int argc, char *argv[]) } } - if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), UC_opts.fapl_id)) < 0) { + if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), + UC_opts.fapl_id)) < 0) { HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } @@ -359,11 +359,11 @@ main(int argc, char *argv[]) if (WIFEXITED(child_status)) { if ((child_ret_value = WEXITSTATUS(child_status)) != 0) { - HDprintf("%d: child process exited with non-zero code (%d)\n", - mypid, child_ret_value); + HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(2); } - } else { + } + else { HDprintf("%d: child process terminated abnormally\n", mypid); Hgoto_error(2); } @@ -372,11 +372,12 @@ main(int argc, char *argv[]) done: if (ret_value != 0) { HDprintf("Error(s) encountered\n"); - } else { + } + else { HDprintf("All passed\n"); } - return(ret_value); + return (ret_value); } #else /* H5_HAVE_MIRROR_VFD */ @@ -400,4 +401,3 @@ main(void) } /* end main() */ #endif /* H5_HAVE_FORK */ - diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c index 2eb5a1d..0b2c409 100644 --- a/test/use_append_mchunks.c +++ b/test/use_append_mchunks.c @@ -69,25 +69,25 @@ static options_t UC_opts; /* Use Case Options */ * Return: 0 succeed; -1 fail. */ int -setup_parameters(int argc, char * const argv[], options_t * opts) +setup_parameters(int argc, char *const argv[], options_t *opts) { /* use case defaults */ HDmemset(opts, 0, sizeof(options_t)); - opts->chunksize = Chunksize_DFT; - opts->use_swmr = 1; /* use swmr open */ - opts->iterations = 1; + opts->chunksize = Chunksize_DFT; + opts->use_swmr = 1; /* use swmr open */ + opts->iterations = 1; opts->chunkplanes = 1; - opts->progname = USE_APPEND_MCHUNKS_PROGNAME; - opts->fapl_id = H5I_INVALID_HID; + opts->progname = USE_APPEND_MCHUNKS_PROGNAME; + opts->fapl_id = H5I_INVALID_HID; if (parse_option(argc, argv, opts) < 0) { - return(-1); + return (-1); } opts->chunkdims[0] = (hsize_t)opts->chunkplanes; opts->chunkdims[1] = opts->chunkdims[2] = (hsize_t)opts->chunksize; - opts->dims[0] = 0; + opts->dims[0] = 0; opts->max_dims[0] = H5S_UNLIMITED; opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = 2 * (hsize_t)opts->chunksize; @@ -95,10 +95,9 @@ setup_parameters(int argc, char * const argv[], options_t * opts) opts->nplanes = 2 * (hsize_t)opts->chunksize; show_parameters(opts); - return(0); + return (0); } /* end setup_parameters() */ - /* Overall Algorithm: * Parse options from user; * Generate/pre-created test files needed and close it; @@ -109,15 +108,15 @@ setup_parameters(int argc, char * const argv[], options_t * opts) int main(int argc, char *argv[]) { - pid_t childpid=0; - pid_t mypid, tmppid; - int child_status; - int child_wait_option=0; - int ret_value = 0; - int child_ret_value; + pid_t childpid = 0; + pid_t mypid, tmppid; + int child_status; + int child_wait_option = 0; + int ret_value = 0; + int child_ret_value; hbool_t send_wait = 0; - hid_t fapl = -1; /* File access property list */ - hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t fid = -1; /* File ID */ if (setup_parameters(argc, argv, &UC_opts) < 0) { Hgoto_error(1); @@ -150,7 +149,8 @@ main(int argc, char *argv[]) if (create_uc_file(&UC_opts) < 0) { HDfprintf(stderr, "***encounter error\n"); Hgoto_error(1); - } else { + } + else { HDprintf("File created.\n"); } /* Close FAPL to prevent issues with forking later */ @@ -164,7 +164,7 @@ main(int argc, char *argv[]) /* ============ */ /* Fork process */ /* ============ */ - if (UC_opts.launch==UC_READWRITE) { + if (UC_opts.launch == UC_READWRITE) { if ((childpid = fork()) < 0) { perror("fork"); Hgoto_error(1); @@ -214,7 +214,8 @@ main(int argc, char *argv[]) } } - if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { + if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < + 0) { HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } @@ -244,12 +245,12 @@ main(int argc, char *argv[]) } if (WIFEXITED(child_status)) { - if ((child_ret_value=WEXITSTATUS(child_status)) != 0) { - HDprintf("%d: child process exited with non-zero code (%d)\n", - mypid, child_ret_value); + if ((child_ret_value = WEXITSTATUS(child_status)) != 0) { + HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(1); } - } else { + } + else { HDprintf("%d: child process terminated abnormally\n", mypid); Hgoto_error(2); } @@ -258,11 +259,12 @@ main(int argc, char *argv[]) done: if (ret_value != 0) { HDprintf("Error(s) encountered\n"); - } else { + } + else { HDprintf("All passed\n"); } - return(ret_value); + return (ret_value); } /* end main() */ #else /* H5_HAVE_FORK */ @@ -275,4 +277,3 @@ main(void) } /* end main() */ #endif /* H5_HAVE_FORK */ - diff --git a/test/use_common.c b/test/use_common.c index 7e19167..ccebd0b 100644 --- a/test/use_common.c +++ b/test/use_common.c @@ -33,7 +33,8 @@ usage(const char *prog) HDfprintf(stderr, " OPTIONS\n"); HDfprintf(stderr, " -h, --help Print a usage message and exit\n"); HDfprintf(stderr, " -f FN Test file name [default: %s.h5]\n", prog); - HDfprintf(stderr, " -i N, --iteration=N Number of iterations to repeat the whole thing. [default: 1]\n"); + HDfprintf(stderr, + " -i N, --iteration=N Number of iterations to repeat the whole thing. [default: 1]\n"); HDfprintf(stderr, " -l w|r launch writer or reader only. [default: launch both]\n"); HDfprintf(stderr, " -n N, --nplanes=N Number of planes to write/read. [default: 1000]\n"); HDfprintf(stderr, " -s N, --swmr=N Use SWMR mode (0: no, non-0: yes) default is yes\n"); @@ -48,11 +49,11 @@ usage(const char *prog) * ---------------------------------------------------------------------------- */ int -parse_option(int argc, char * const argv[], options_t * opts) +parse_option(int argc, char *const argv[], options_t *opts) { - int ret_value=0; + int ret_value = 0; int c; - int use_swmr; /* Need an int to detect errors */ + int use_swmr; /* Need an int to detect errors */ /* command line options: See function usage for a description */ const char *nagg_options = "f:hi:l:n:s:y:z:"; @@ -65,79 +66,80 @@ parse_option(int argc, char * const argv[], options_t * opts) if (-1 == c) break; switch (c) { - case 'h': - usage(opts->progname); - exit(EXIT_SUCCESS); - break; - case 'f': /* usecase data file name */ - opts->filename = HDstrdup(optarg); - break; - case 'i': /* iterations */ - if ((opts->iterations = HDatoi(optarg)) <= 0) { - HDfprintf(stderr, "bad iterations number %s, must be a positive integer\n", optarg); + case 'h': usage(opts->progname); - Hgoto_error(-1); - } - break; - case 'l': /* launch reader or writer only */ - switch (*optarg) { - case 'r': /* reader only */ - opts->launch = UC_READER; + exit(EXIT_SUCCESS); break; - case 'w': /* writer only */ - opts->launch = UC_WRITER; + case 'f': /* usecase data file name */ + opts->filename = HDstrdup(optarg); break; - default: - HDfprintf(stderr, "launch value(%c) should be w or r only.\n", *optarg); - usage(opts->progname); - Hgoto_error(-1); + case 'i': /* iterations */ + if ((opts->iterations = HDatoi(optarg)) <= 0) { + HDfprintf(stderr, "bad iterations number %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } break; - } /* end switch (reader/writer-only mode toggle) */ - break; - case 'n': /* number of planes to write/read */ - if ((opts->nplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); - usage(opts->progname); - Hgoto_error(-1); - } - break; - case 's': /* use swmr file open mode */ - use_swmr = HDatoi(optarg); - if (use_swmr != 0 && use_swmr != 1) { - HDfprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); - usage(opts->progname); - Hgoto_error(-1); - } - opts->use_swmr = (hbool_t)use_swmr; - break; - case 'y': /* Number of planes per chunk */ - if ((opts->chunkplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n", optarg); - usage(opts->progname); + case 'l': /* launch reader or writer only */ + switch (*optarg) { + case 'r': /* reader only */ + opts->launch = UC_READER; + break; + case 'w': /* writer only */ + opts->launch = UC_WRITER; + break; + default: + HDfprintf(stderr, "launch value(%c) should be w or r only.\n", *optarg); + usage(opts->progname); + Hgoto_error(-1); + break; + } /* end switch (reader/writer-only mode toggle) */ + break; + case 'n': /* number of planes to write/read */ + if ((opts->nplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case 's': /* use swmr file open mode */ + use_swmr = HDatoi(optarg); + if (use_swmr != 0 && use_swmr != 1) { + HDfprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); + usage(opts->progname); + Hgoto_error(-1); + } + opts->use_swmr = (hbool_t)use_swmr; + break; + case 'y': /* Number of planes per chunk */ + if ((opts->chunkplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n", + optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case 'z': /* size of chunk=(z,z) */ + if ((opts->chunksize = HDstrtoull(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case '?': + HDfprintf(stderr, "getopt returned '%c'.\n", c); Hgoto_error(-1); - } - break; - case 'z': /* size of chunk=(z,z) */ - if ((opts->chunksize = HDstrtoull(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); - usage(opts->progname); + default: + HDfprintf(stderr, "getopt returned unexpected value.\n"); + HDfprintf(stderr, "Unexpected value is %d\n", c); Hgoto_error(-1); - } - break; - case '?': - HDfprintf(stderr, "getopt returned '%c'.\n", c); - Hgoto_error(-1); - default: - HDfprintf(stderr, "getopt returned unexpected value.\n"); - HDfprintf(stderr, "Unexpected value is %d\n", c); - Hgoto_error(-1); } /* end switch (argument symbol) */ - } /* end while (there are still arguments) */ + } /* end while (there are still arguments) */ /* set test file name if not given */ if (!opts->filename) { /* default data file name is .h5 */ - if ((opts->filename=(char*)HDmalloc(HDstrlen(opts->progname)+4))==NULL) { + if ((opts->filename = (char *)HDmalloc(HDstrlen(opts->progname) + 4)) == NULL) { HDfprintf(stderr, "malloc: failed\n"); Hgoto_error(-1); } @@ -146,7 +148,7 @@ parse_option(int argc, char * const argv[], options_t * opts) } done: - return(ret_value); + return (ret_value); } /* end parse_option() */ /* ---------------------------------------------------------------------------- @@ -154,18 +156,18 @@ done: * ---------------------------------------------------------------------------- */ void -show_parameters(options_t * opts) +show_parameters(options_t *opts) { HDprintf("===Parameters used:===\n"); HDprintf("chunk dims=(%llu, %llu, %llu)\n", (unsigned long long)opts->chunkdims[0], - (unsigned long long)opts->chunkdims[1], (unsigned long long)opts->chunkdims[2]); + (unsigned long long)opts->chunkdims[1], (unsigned long long)opts->chunkdims[2]); HDprintf("dataset max dims=(%llu, %llu, %llu)\n", (unsigned long long)opts->max_dims[0], - (unsigned long long)opts->max_dims[1], (unsigned long long)opts->max_dims[2]); + (unsigned long long)opts->max_dims[1], (unsigned long long)opts->max_dims[2]); HDprintf("number of planes to write=%llu\n", (unsigned long long)opts->nplanes); HDprintf("using SWMR mode=%s\n", opts->use_swmr ? "yes(1)" : "no(0)"); HDprintf("data filename=%s\n", opts->filename); HDprintf("launch part="); - switch (opts->launch) { + switch (opts->launch) { case UC_READWRITE: HDprintf("Reader/Writer\n"); break; @@ -178,7 +180,7 @@ show_parameters(options_t * opts) default: /* should not happen */ HDprintf("Illegal part(%d)\n", opts->launch); - } + } HDprintf("number of iterations=%d (not used yet)\n", opts->iterations); HDprintf("===Parameters shown===\n"); } /* end show_parameters() */ @@ -194,13 +196,13 @@ show_parameters(options_t * opts) * ---------------------------------------------------------------------------- */ int -create_uc_file(options_t * opts) +create_uc_file(options_t *opts) { - hsize_t dims[3]; /* Dataset starting dimensions */ - hid_t fid; /* File ID for new HDF5 file */ - hid_t dcpl; /* Dataset creation property list */ - hid_t sid; /* Dataspace ID */ - hid_t dsid; /* Dataset ID */ + hsize_t dims[3]; /* Dataset starting dimensions */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t dcpl; /* Dataset creation property list */ + hid_t sid; /* Dataspace ID */ + hid_t dsid; /* Dataset ID */ H5D_chunk_index_t idx_type; /* Chunk index type */ if ((fid = H5Fcreate(opts->filename, H5F_ACC_TRUNC, H5P_DEFAULT, opts->fapl_id)) < 0) @@ -258,19 +260,19 @@ create_uc_file(options_t * opts) * ---------------------------------------------------------------------------- */ int -write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) +write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts) { - hid_t dsid; /* dataset ID */ - hid_t dcpl; /* Dataset creation property list */ - UC_CTYPE *buffer, *bufptr; /* data buffer */ - hsize_t cz=opts->chunksize; /* Chunk size */ - hid_t f_sid; /* dataset file space id */ - hid_t m_sid; /* memory space id */ - int rank; /* rank */ - hsize_t chunk_dims[3]; /* Chunk dimensions */ - hsize_t dims[3]; /* Dataspace dimensions */ - hsize_t memdims[3]; /* Memory space dimensions */ - hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ + hid_t dsid; /* dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + UC_CTYPE *buffer, *bufptr; /* data buffer */ + hsize_t cz = opts->chunksize; /* Chunk size */ + hid_t f_sid; /* dataset file space id */ + hid_t m_sid; /* memory space id */ + int rank; /* rank */ + hsize_t chunk_dims[3]; /* Chunk dimensions */ + hsize_t dims[3]; /* Dataspace dimensions */ + hsize_t memdims[3]; /* Memory space dimensions */ + hsize_t start[3] = {0, 0, 0}, count[3]; /* Hyperslab selection values */ hsize_t i, j, k; if (TRUE == tosend) { @@ -299,18 +301,18 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) } /* verify chunk_dims against set paramenters */ - if (chunk_dims[0]!=opts->chunkdims[0] || chunk_dims[1] != cz || chunk_dims[2] != cz) { + if (chunk_dims[0] != opts->chunkdims[0] || chunk_dims[1] != cz || chunk_dims[2] != cz) { HDfprintf(stderr, "chunk size is not as expected. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)chunk_dims[0], (unsigned long long)chunk_dims[1], - (unsigned long long)chunk_dims[2]); + (unsigned long long)chunk_dims[0], (unsigned long long)chunk_dims[1], + (unsigned long long)chunk_dims[2]); return -1; } /* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ - memdims[0]=1; + memdims[0] = 1; memdims[1] = opts->dims[1]; memdims[2] = opts->dims[2]; - if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) { + if ((buffer = (UC_CTYPE *)HDmalloc((size_t)memdims[1] * (size_t)memdims[2] * sizeof(UC_CTYPE))) == NULL) { HDfprintf(stderr, "malloc: failed\n"); return -1; } @@ -318,7 +320,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) /* * Get dataset rank and dimension. */ - f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ + f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(f_sid); if (rank != UC_RANK) { HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); @@ -328,32 +330,30 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); return -1; } - HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", - rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), - (unsigned long long)(dims[2])); + HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]), + (unsigned long long)(dims[1]), (unsigned long long)(dims[2])); /* verify that file space dims are as expected and are consistent with memory space dims */ if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]) { - HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)dims[0], (unsigned long long)dims[1], - (unsigned long long)dims[2]); + HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", (unsigned long long)dims[0], + (unsigned long long)dims[1], (unsigned long long)dims[2]); return -1; } /* setup mem-space for buffer */ - if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0) { + if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) { HDfprintf(stderr, "H5Screate_simple for memory failed\n"); return -1; } /* write planes */ - count[0]=1; - count[1]=dims[1]; - count[2]=dims[2]; - for (i=0; i < opts->nplanes; i++) { + count[0] = 1; + count[1] = dims[1]; + count[2] = dims[2]; + for (i = 0; i < opts->nplanes; i++) { /* fill buffer with value i+1 */ bufptr = buffer; - for (j=0; j < dims[1]; j++) { - for (k=0; k < dims[2]; k++) { + for (j = 0; j < dims[1]; j++) { + for (k = 0; k < dims[2]; k++) { *bufptr++ = (UC_CTYPE)i; } } @@ -367,7 +367,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) } /* extend the dataset by one for new plane */ - dims[0]=i+1; + dims[0] = i + 1; if (H5Dset_extent(dsid, dims) < 0) { HDfprintf(stderr, "H5Dset_extent failed\n"); return -1; @@ -379,7 +379,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) return -1; } - start[0]=i; + start[0] = i; /* Choose the next plane to write */ if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { HDfprintf(stderr, "Failed H5Sselect_hyperslab\n"); @@ -438,20 +438,20 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) * ---------------------------------------------------------------------------- */ int -read_uc_file(hbool_t towait, options_t * opts) +read_uc_file(hbool_t towait, options_t *opts) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t dsid; /* dataset ID */ - UC_CTYPE *buffer, *bufptr; /* read data buffer */ - hid_t f_sid; /* dataset file space id */ - hid_t m_sid; /* memory space id */ - int rank; /* rank */ - hsize_t dims[3]; /* Dataspace dimensions */ - hsize_t memdims[3]; /* Memory space dimensions */ - hsize_t nplane=0, nplanes_seen=0; /* nth plane, last nth plane */ - hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t dsid; /* dataset ID */ + UC_CTYPE *buffer, *bufptr; /* read data buffer */ + hid_t f_sid; /* dataset file space id */ + hid_t m_sid; /* memory space id */ + int rank; /* rank */ + hsize_t dims[3]; /* Dataspace dimensions */ + hsize_t memdims[3]; /* Memory space dimensions */ + hsize_t nplane = 0, nplanes_seen = 0; /* nth plane, last nth plane */ + hsize_t start[3] = {0, 0, 0}, count[3]; /* Hyperslab selection values */ hsize_t j, k; - int nreadererr=0; + int nreadererr = 0; int nerrs; int loops_waiting_for_plane; @@ -462,7 +462,8 @@ read_uc_file(hbool_t towait, options_t * opts) } HDfprintf(stderr, "Opening to read %s\n", opts->filename); - if ((fid = H5Fopen(opts->filename, H5F_ACC_RDONLY | (opts->use_swmr ? H5F_ACC_SWMR_READ : 0), opts->fapl_id)) < 0) { + if ((fid = H5Fopen(opts->filename, H5F_ACC_RDONLY | (opts->use_swmr ? H5F_ACC_SWMR_READ : 0), + opts->fapl_id)) < 0) { HDfprintf(stderr, "H5Fopen failed\n"); return -1; } @@ -476,7 +477,7 @@ read_uc_file(hbool_t towait, options_t * opts) memdims[0] = 1; memdims[1] = opts->dims[1]; memdims[2] = opts->dims[2]; - if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) { + if ((buffer = (UC_CTYPE *)HDmalloc((size_t)memdims[1] * (size_t)memdims[2] * sizeof(UC_CTYPE))) == NULL) { HDfprintf(stderr, "malloc: failed\n"); return -1; } @@ -485,7 +486,7 @@ read_uc_file(hbool_t towait, options_t * opts) * Get dataset rank and dimension. * Verify dimension is as expected (unlimited,2*chunksize,2*chunksize). */ - f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ + f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(f_sid); if (rank != UC_RANK) { HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); @@ -495,22 +496,19 @@ read_uc_file(hbool_t towait, options_t * opts) HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); return -1; } - HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", - rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), - (unsigned long long)(dims[2])); + HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]), + (unsigned long long)(dims[1]), (unsigned long long)(dims[2])); /* verify that file space dims are as expected and are consistent with memory space dims */ if (dims[1] != memdims[1] || dims[2] != memdims[2]) { HDfprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)dims[0], (unsigned long long)dims[1], - (unsigned long long)dims[2]); - HDfprintf(stderr, "But memdims=(%llu,%llu,%llu)\n", - (unsigned long long)memdims[0], (unsigned long long)memdims[1], - (unsigned long long)memdims[2]); + (unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]); + HDfprintf(stderr, "But memdims=(%llu,%llu,%llu)\n", (unsigned long long)memdims[0], + (unsigned long long)memdims[1], (unsigned long long)memdims[2]); return -1; } /* Setup mem-space for buffer */ - if ((m_sid=H5Screate_simple(rank, memdims, NULL)) < 0) { + if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) { HDfprintf(stderr, "H5Screate_simple for memory failed\n"); return -1; } @@ -520,22 +518,22 @@ read_uc_file(hbool_t towait, options_t * opts) count[1] = dims[1]; count[2] = dims[2]; /* quit when all nplanes have been read */ - loops_waiting_for_plane=0; + loops_waiting_for_plane = 0; while (nplanes_seen < opts->nplanes) { /* print progress message according to if new planes are availalbe */ if (nplanes_seen < dims[0]) { if (loops_waiting_for_plane) { /* end the previous message */ HDprintf("\n"); - loops_waiting_for_plane=0; + loops_waiting_for_plane = 0; } HDprintf("reading planes %llu to %llu\n", (unsigned long long)nplanes_seen, - (unsigned long long)dims[0]); + (unsigned long long)dims[0]); } else { if (loops_waiting_for_plane) { HDprintf("."); - if (loops_waiting_for_plane>=30) { + if (loops_waiting_for_plane >= 30) { HDfprintf(stderr, "waited too long for new plane, quit.\n"); return -1; } @@ -549,7 +547,7 @@ read_uc_file(hbool_t towait, options_t * opts) HDsleep(1); } - for (nplane=nplanes_seen; nplane < dims[0]; nplane++) { + for (nplane = nplanes_seen; nplane < dims[0]; nplane++) { /* read planes between last old nplanes and current extent */ /* Get the dataset's dataspace */ if ((f_sid = H5Dget_space(dsid)) < 0) { @@ -557,7 +555,7 @@ read_uc_file(hbool_t towait, options_t * opts) return -1; } - start[0]=nplane; + start[0] = nplane; /* Choose the next plane to read */ if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { HDfprintf(stderr, "H5Sselect_hyperslab failed\n"); @@ -572,31 +570,30 @@ read_uc_file(hbool_t towait, options_t * opts) /* compare read data with expected data value which is nplane */ bufptr = buffer; - nerrs=0; - for (j=0; j < dims[1]; j++) { - for (k=0; k < dims[2]; k++) { + nerrs = 0; + for (j = 0; j < dims[1]; j++) { + for (k = 0; k < dims[2]; k++) { if ((hsize_t)*bufptr++ != nplane) { if (++nerrs < ErrorReportMax) { - HDfprintf(stderr, - "found error %llu plane(%llu,%llu), expected %llu, got %d\n", - (unsigned long long)nplane, (unsigned long long)j, - (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1)); + HDfprintf(stderr, "found error %llu plane(%llu,%llu), expected %llu, got %d\n", + (unsigned long long)nplane, (unsigned long long)j, + (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr - 1)); } /* end if should print error */ - } /* end if value mismatch */ - } /* end for plane second dimension */ - } /* end for plane first dimension */ + } /* end if value mismatch */ + } /* end for plane second dimension */ + } /* end for plane first dimension */ if (nerrs) { nreadererr++; HDfprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs, - (unsigned long long)nplane); + (unsigned long long)nplane); } } /* end for each plane added since last read */ - nplanes_seen=dims[0]; + nplanes_seen = dims[0]; /* check if dataset has grown since last time (update dims) */ H5Drefresh(dsid); - f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ + f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); return -1; @@ -615,4 +612,3 @@ read_uc_file(hbool_t towait, options_t * opts) } /* end read_uc_file() */ #endif /* H5_HAVE_FORK */ - diff --git a/test/use_disable_mdc_flushes.c b/test/use_disable_mdc_flushes.c index 32a8244..1f0e3d4 100644 --- a/test/use_disable_mdc_flushes.c +++ b/test/use_disable_mdc_flushes.c @@ -24,35 +24,38 @@ */ #ifdef H5_HAVE_FORK -#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ #define H5D_TESTING #include "H5Dpkg.h" /* Global Variable definitions */ -const char *progname_g="use_disable_mdc_flushes"; /* program name */ +const char *progname_g = "use_disable_mdc_flushes"; /* program name */ /* these two definitions must match each other */ -#define UC_DATATYPE H5T_NATIVE_SHORT /* use case HDF5 data type */ -#define UC_CTYPE short /* use case C data type */ -#define UC_RANK 3 /* use case dataset rank */ -#define Chunksize_DFT 256 /* chunksize default */ -#define Hgoto_error(val) {ret_value=val; goto done;} - +#define UC_DATATYPE H5T_NATIVE_SHORT /* use case HDF5 data type */ +#define UC_CTYPE short /* use case C data type */ +#define UC_RANK 3 /* use case dataset rank */ +#define Chunksize_DFT 256 /* chunksize default */ +#define Hgoto_error(val) \ + { \ + ret_value = val; \ + goto done; \ + } -char *filename_g; +char * filename_g; hsize_t nplanes_g; -int use_swmr_g; -int chunkplanes_g; -int chunksize_g; +int use_swmr_g; +int chunkplanes_g; +int chunksize_g; hsize_t dims_g[UC_RANK]; hsize_t max_dims_g[UC_RANK]; hsize_t chunkdims_g[UC_RANK]; static void usage(const char *prog); -static int parse_option(int argc, char * const argv[]); +static int parse_option(int argc, char *const argv[]); static void show_parameters(void); -static int create_file(void); -static int setup_parameters(int argc, char * const argv[]); +static int create_file(void); +static int setup_parameters(int argc, char *const argv[]); /* * Note: Long options are not yet implemented. @@ -80,14 +83,13 @@ usage(const char *prog) HDfprintf(stderr, "\n"); } /* usage() */ - /* * Setup Use Case parameters by parsing command line options. * Setup default values if not set by options. */ static int -parse_option(int argc, char * const argv[]) +parse_option(int argc, char *const argv[]) { - int ret_value=0; + int ret_value = 0; int c; /* command line options: See function usage for a description */ const char *cmd_options = "f:hn:s:y:z:"; @@ -95,70 +97,71 @@ parse_option(int argc, char * const argv[]) /* suppress getopt from printing error */ opterr = 0; - while (1){ - c = getopt (argc, argv, cmd_options); - if (-1 == c) - break; - switch (c) { - case 'h': - usage(progname_g); - HDexit(EXIT_SUCCESS); - break; - case 'f': /* usecase data file name */ - filename_g = optarg; - break; - case 'n': /* number of planes to write/read */ - if ((nplanes_g = (hsize_t)HDatoi(optarg)) <= 0){ - HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 's': /* use swmr file open mode */ - if ((use_swmr_g = HDatoi(optarg)) < 0){ - HDfprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 'y': /* Number of planes per chunk */ - if ((chunkplanes_g = HDatoi(optarg)) <= 0){ - HDfprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 'z': /* size of chunk=(z,z) */ - if ((chunksize_g = HDatoi(optarg)) <= 0){ - HDfprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case '?': - HDfprintf(stderr, "getopt returned '%c'.\n", c); - Hgoto_error(-1); - default: - HDfprintf(stderr, "getopt returned unexpected value.\n"); - HDfprintf(stderr, "Unexpected value is %d\n", c); - Hgoto_error(-1); - } + while (1) { + c = getopt(argc, argv, cmd_options); + if (-1 == c) + break; + switch (c) { + case 'h': + usage(progname_g); + HDexit(EXIT_SUCCESS); + break; + case 'f': /* usecase data file name */ + filename_g = optarg; + break; + case 'n': /* number of planes to write/read */ + if ((nplanes_g = (hsize_t)HDatoi(optarg)) <= 0) { + HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); + usage(progname_g); + Hgoto_error(-1); + }; + break; + case 's': /* use swmr file open mode */ + if ((use_swmr_g = HDatoi(optarg)) < 0) { + HDfprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); + usage(progname_g); + Hgoto_error(-1); + }; + break; + case 'y': /* Number of planes per chunk */ + if ((chunkplanes_g = HDatoi(optarg)) <= 0) { + HDfprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n", + optarg); + usage(progname_g); + Hgoto_error(-1); + }; + break; + case 'z': /* size of chunk=(z,z) */ + if ((chunksize_g = HDatoi(optarg)) <= 0) { + HDfprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); + usage(progname_g); + Hgoto_error(-1); + }; + break; + case '?': + HDfprintf(stderr, "getopt returned '%c'.\n", c); + Hgoto_error(-1); + default: + HDfprintf(stderr, "getopt returned unexpected value.\n"); + HDfprintf(stderr, "Unexpected value is %d\n", c); + Hgoto_error(-1); + } } /* set test file name if not given */ - if (!filename_g){ - /* default data file name is .h5 */ - if ((filename_g = (char*)HDmalloc(HDstrlen(progname_g)+4))==NULL) { - HDfprintf(stderr, "malloc: failed\n"); - Hgoto_error(-1); - }; - HDstrcpy(filename_g, progname_g); - HDstrcat(filename_g, ".h5"); + if (!filename_g) { + /* default data file name is .h5 */ + if ((filename_g = (char *)HDmalloc(HDstrlen(progname_g) + 4)) == NULL) { + HDfprintf(stderr, "malloc: failed\n"); + Hgoto_error(-1); + }; + HDstrcpy(filename_g, progname_g); + HDstrcat(filename_g, ".h5"); } done: /* All done. */ - return(ret_value); + return (ret_value); } /* parse_option() */ /* Show parameters used for this use case */ @@ -167,9 +170,9 @@ show_parameters(void) { HDprintf("===Parameters used:===\n"); HDprintf("chunk dims=(%llu, %llu, %llu)\n", (unsigned long long)chunkdims_g[0], - (unsigned long long)chunkdims_g[1], (unsigned long long)chunkdims_g[2]); + (unsigned long long)chunkdims_g[1], (unsigned long long)chunkdims_g[2]); HDprintf("dataset max dims=(%llu, %llu, %llu)\n", (unsigned long long)max_dims_g[0], - (unsigned long long)max_dims_g[1], (unsigned long long)max_dims_g[2]); + (unsigned long long)max_dims_g[1], (unsigned long long)max_dims_g[2]); HDprintf("number of planes to write=%llu\n", (unsigned long long)nplanes_g); HDprintf("using SWMR mode=%s\n", use_swmr_g ? "yes(1)" : "no(0)"); HDprintf("data filename=%s\n", filename_g); @@ -181,23 +184,23 @@ show_parameters(void) * Return: 0 succeed; -1 fail. */ static int -setup_parameters(int argc, char * const argv[]) +setup_parameters(int argc, char *const argv[]) { /* use case defaults */ - chunksize_g = Chunksize_DFT; - use_swmr_g = 1; /* use swmr open */ + chunksize_g = Chunksize_DFT; + use_swmr_g = 1; /* use swmr open */ chunkplanes_g = 1; /* parse options */ - if (parse_option(argc, argv) < 0){ - return(-1); + if (parse_option(argc, argv) < 0) { + return (-1); } /* set chunk dims */ chunkdims_g[0] = (hsize_t)chunkplanes_g; - chunkdims_g[1]= chunkdims_g[2] = (hsize_t)chunksize_g; + chunkdims_g[1] = chunkdims_g[2] = (hsize_t)chunksize_g; /* set dataset initial and max dims */ - dims_g[0] = 0; + dims_g[0] = 0; max_dims_g[0] = H5S_UNLIMITED; dims_g[1] = dims_g[2] = max_dims_g[1] = max_dims_g[2] = (hsize_t)chunksize_g; @@ -207,7 +210,7 @@ setup_parameters(int argc, char * const argv[]) /* show parameters and return */ show_parameters(); - return(0); + return (0); } /* setup_parameters() */ /* @@ -222,20 +225,20 @@ setup_parameters(int argc, char * const argv[]) static int create_file(void) { - hsize_t dims[3]; /* Dataset starting dimensions */ - hid_t fid; /* File ID for new HDF5 file */ - hid_t dcpl; /* Dataset creation property list */ - hid_t sid; /* Dataspace ID */ - hid_t dsid; /* Dataset ID */ - hid_t fapl; /* File access property list */ + hsize_t dims[3]; /* Dataset starting dimensions */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t dcpl; /* Dataset creation property list */ + hid_t sid; /* Dataspace ID */ + hid_t dsid; /* Dataset ID */ + hid_t fapl; /* File access property list */ H5D_chunk_index_t idx_type; /* Chunk index type */ /* Create the file */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) return -1; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; - if((fid = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) return -1; /* Set up dimension sizes */ @@ -243,39 +246,39 @@ create_file(void) dims[1] = dims[2] = max_dims_g[1]; /* Create dataspace for creating datasets */ - if((sid = H5Screate_simple(3, dims, max_dims_g)) < 0) + if ((sid = H5Screate_simple(3, dims, max_dims_g)) < 0) return -1; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) return -1; - if(H5Pset_chunk(dcpl, 3, chunkdims_g) < 0) + if (H5Pset_chunk(dcpl, 3, chunkdims_g) < 0) return -1; /* create dataset of progname */ - if((dsid = H5Dcreate2(fid, progname_g, UC_DATATYPE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - return -1; + if ((dsid = H5Dcreate2(fid, progname_g, UC_DATATYPE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + return -1; /* Check that the chunk index type is not version 1 B-tree. * Version 1 B-trees are not supported under SWMR. */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) + if (H5D__layout_idx_type_test(dsid, &idx_type) < 0) return -1; - if(idx_type == H5D_CHUNK_IDX_BTREE) { + if (idx_type == H5D_CHUNK_IDX_BTREE) { HDfprintf(stderr, "ERROR: Chunk index is version 1 B-tree: aborting.\n"); return -1; } /* Close everything */ - if(H5Dclose(dsid) < 0) - return -1; - if(H5Pclose(fapl) < 0) + if (H5Dclose(dsid) < 0) + return -1; + if (H5Pclose(fapl) < 0) return -1; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; return 0; @@ -293,211 +296,208 @@ create_file(void) static int write_file(void) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t dsid; /* dataset ID */ - hid_t fapl; /* File access property list */ - hid_t dcpl; /* Dataset creation property list */ - char *name; - UC_CTYPE *buffer, *bufptr; /* data buffer */ - hsize_t cz=(hsize_t)chunksize_g; /* Chunk size */ - hid_t f_sid; /* dataset file space id */ - hid_t m_sid; /* memory space id */ - int rank; /* rank */ - hsize_t chunk_dims[3]; /* Chunk dimensions */ - hsize_t dims[3]; /* Dataspace dimensions */ - hsize_t memdims[3]; /* Memory space dimensions */ - hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ - hbool_t disabled; /* Object's disabled status */ - hsize_t i, j, k; + hid_t fid; /* File ID for new HDF5 file */ + hid_t dsid; /* dataset ID */ + hid_t fapl; /* File access property list */ + hid_t dcpl; /* Dataset creation property list */ + char * name; + UC_CTYPE *buffer, *bufptr; /* data buffer */ + hsize_t cz = (hsize_t)chunksize_g; /* Chunk size */ + hid_t f_sid; /* dataset file space id */ + hid_t m_sid; /* memory space id */ + int rank; /* rank */ + hsize_t chunk_dims[3]; /* Chunk dimensions */ + hsize_t dims[3]; /* Dataspace dimensions */ + hsize_t memdims[3]; /* Memory space dimensions */ + hsize_t start[3] = {0, 0, 0}, count[3]; /* Hyperslab selection values */ + hbool_t disabled; /* Object's disabled status */ + hsize_t i, j, k; name = filename_g; /* Open the file */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) return -1; - if(use_swmr_g) - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (use_swmr_g) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; - if((fid = H5Fopen(name, H5F_ACC_RDWR | (use_swmr_g ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0){ - HDfprintf(stderr, "H5Fopen failed\n"); + if ((fid = H5Fopen(name, H5F_ACC_RDWR | (use_swmr_g ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { + HDfprintf(stderr, "H5Fopen failed\n"); return -1; } /* Open the dataset of the program name */ - if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){ - HDfprintf(stderr, "H5Dopen2 failed\n"); - return -1; + if ((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0) { + HDfprintf(stderr, "H5Dopen2 failed\n"); + return -1; } /* Disabled mdc flushed for the dataset */ - if(H5Odisable_mdc_flushes(dsid) < 0) { - HDfprintf(stderr, "H5Odisable_mdc_flushes failed\n"); - return -1; + if (H5Odisable_mdc_flushes(dsid) < 0) { + HDfprintf(stderr, "H5Odisable_mdc_flushes failed\n"); + return -1; } /* Get mdc disabled status of the dataset */ - if(H5Oare_mdc_flushes_disabled(dsid, &disabled) < 0) { - HDfprintf(stderr, "H5Oare_mdc_flushes_disabled failed\n"); - return -1; - } else if(disabled) - HDprintf("Dataset has disabled mdc flushes.\n"); + if (H5Oare_mdc_flushes_disabled(dsid, &disabled) < 0) { + HDfprintf(stderr, "H5Oare_mdc_flushes_disabled failed\n"); + return -1; + } + else if (disabled) + HDprintf("Dataset has disabled mdc flushes.\n"); else - HDprintf("Dataset should have disabled its mdc flushes.\n"); + HDprintf("Dataset should have disabled its mdc flushes.\n"); /* Find chunksize used */ - if ((dcpl = H5Dget_create_plist(dsid)) < 0){ - HDfprintf(stderr, "H5Dget_create_plist failed\n"); - return -1; + if ((dcpl = H5Dget_create_plist(dsid)) < 0) { + HDfprintf(stderr, "H5Dget_create_plist failed\n"); + return -1; } - if (H5D_CHUNKED != H5Pget_layout(dcpl)){ - HDfprintf(stderr, "storage layout is not chunked\n"); - return -1; + if (H5D_CHUNKED != H5Pget_layout(dcpl)) { + HDfprintf(stderr, "storage layout is not chunked\n"); + return -1; } - if ((rank = H5Pget_chunk(dcpl, 3, chunk_dims)) != 3){ - HDfprintf(stderr, "storage rank is not 3\n"); - return -1; + if ((rank = H5Pget_chunk(dcpl, 3, chunk_dims)) != 3) { + HDfprintf(stderr, "storage rank is not 3\n"); + return -1; } /* verify chunk_dims against set paramenters */ - if (chunk_dims[0]!= chunkdims_g[0] || chunk_dims[1] != cz || chunk_dims[2] != cz){ - HDfprintf(stderr, "chunk size is not as expected. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)chunk_dims[0], (unsigned long long)chunk_dims[1], - (unsigned long long)chunk_dims[2]); - return -1; + if (chunk_dims[0] != chunkdims_g[0] || chunk_dims[1] != cz || chunk_dims[2] != cz) { + HDfprintf(stderr, "chunk size is not as expected. Got dims=(%llu,%llu,%llu)\n", + (unsigned long long)chunk_dims[0], (unsigned long long)chunk_dims[1], + (unsigned long long)chunk_dims[2]); + return -1; } /* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ - memdims[0]=1; + memdims[0] = 1; memdims[1] = dims_g[1]; memdims[2] = dims_g[2]; - if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) { - HDfprintf(stderr, "malloc: failed\n"); - return -1; + if ((buffer = (UC_CTYPE *)HDmalloc((size_t)memdims[1] * (size_t)memdims[2] * sizeof(UC_CTYPE))) == NULL) { + HDfprintf(stderr, "malloc: failed\n"); + return -1; }; /* * Get dataset rank and dimension. */ - f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ + f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(f_sid); - if (rank != UC_RANK){ - HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); - return -1; + if (rank != UC_RANK) { + HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); + return -1; } - if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){ - HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); - return -1; + if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { + HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); + return -1; } - HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", - rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), - (unsigned long long)(dims[2])); + HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]), + (unsigned long long)(dims[1]), (unsigned long long)(dims[2])); /* verify that file space dims are as expected and are consistent with memory space dims */ - if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]){ - HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)dims[0], (unsigned long long)dims[1], - (unsigned long long)dims[2]); - return -1; + if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]) { + HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", (unsigned long long)dims[0], + (unsigned long long)dims[1], (unsigned long long)dims[2]); + return -1; } /* setup mem-space for buffer */ - if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0){ - HDfprintf(stderr, "H5Screate_simple for memory failed\n"); - return -1; + if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) { + HDfprintf(stderr, "H5Screate_simple for memory failed\n"); + return -1; }; /* write planes */ - count[0]=1; - count[1]=dims[1]; - count[2]=dims[2]; - for (i=0; i SHRT_MAX) { - HDfprintf(stderr, "rank(%d) of dataset overflow\n", rank); - return -1; + count[0] = 1; + count[1] = dims[1]; + count[2] = dims[2]; + for (i = 0; i < nplanes_g; i++) { + /* fill buffer with value i+1 */ + bufptr = buffer; + for (j = 0; j < dims[1]; j++) + for (k = 0; k < dims[2]; k++) { + if (i > SHRT_MAX) { + HDfprintf(stderr, "rank(%d) of dataset overflow\n", rank); + return -1; + } + *bufptr++ = (short)i; } - *bufptr++ = (short)i; - } - /* extend the dataset by one for new plane */ - dims[0]=i+1; - if(H5Dset_extent(dsid, dims) < 0){ - HDfprintf(stderr, "H5Dset_extent failed\n"); + /* extend the dataset by one for new plane */ + dims[0] = i + 1; + if (H5Dset_extent(dsid, dims) < 0) { + HDfprintf(stderr, "H5Dset_extent failed\n"); return -1; - } + } /* Get the dataset's dataspace */ - if((f_sid = H5Dget_space(dsid)) < 0){ - HDfprintf(stderr, "H5Dset_extent failed\n"); + if ((f_sid = H5Dget_space(dsid)) < 0) { + HDfprintf(stderr, "H5Dset_extent failed\n"); return -1; - } + } - start[0]=i; + start[0] = i; /* Choose the next plane to write */ - if(H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0){ - HDfprintf(stderr, "Failed H5Sselect_hyperslab\n"); + if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { + HDfprintf(stderr, "Failed H5Sselect_hyperslab\n"); return -1; - } + } /* Write plane to the dataset */ - if(H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0){ - HDfprintf(stderr, "Failed H5Dwrite\n"); + if (H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) { + HDfprintf(stderr, "Failed H5Dwrite\n"); return -1; - } + } - /* Flush the dataset for every "chunkplanes_g" planes */ - if(!((i + 1) % (hsize_t)chunkplanes_g)) { - if(H5Dflush(dsid) < 0) { - HDfprintf(stderr, "Failed to H5Dflush dataset\n"); - return -1; + /* Flush the dataset for every "chunkplanes_g" planes */ + if (!((i + 1) % (hsize_t)chunkplanes_g)) { + if (H5Dflush(dsid) < 0) { + HDfprintf(stderr, "Failed to H5Dflush dataset\n"); + return -1; + } } } - } - if(H5Dflush(dsid) < 0) { - HDfprintf(stderr, "Failed to H5Dflush dataset\n"); - return -1; + if (H5Dflush(dsid) < 0) { + HDfprintf(stderr, "Failed to H5Dflush dataset\n"); + return -1; } /* Enable mdc flushes for the dataset */ /* Closing the dataset later will enable mdc flushes automatically if this is not done */ - if(disabled) - if(H5Oenable_mdc_flushes(dsid) < 0) { - HDfprintf(stderr, "Failed to H5Oenable_mdc_flushes\n"); - return -1; - } + if (disabled) + if (H5Oenable_mdc_flushes(dsid) < 0) { + HDfprintf(stderr, "Failed to H5Oenable_mdc_flushes\n"); + return -1; + } /* Done writing. Free/Close all resources including data file */ HDfree(buffer); - if(H5Dclose(dsid) < 0){ - HDfprintf(stderr, "Failed to close datasete\n"); - return -1; + if (H5Dclose(dsid) < 0) { + HDfprintf(stderr, "Failed to close datasete\n"); + return -1; } - if(H5Sclose(m_sid) < 0){ - HDfprintf(stderr, "Failed to close memory space\n"); - return -1; + if (H5Sclose(m_sid) < 0) { + HDfprintf(stderr, "Failed to close memory space\n"); + return -1; } - if(H5Sclose(f_sid) < 0){ - HDfprintf(stderr, "Failed to close file space\n"); - return -1; + if (H5Sclose(f_sid) < 0) { + HDfprintf(stderr, "Failed to close file space\n"); + return -1; } - if(H5Pclose(fapl) < 0){ - HDfprintf(stderr, "Failed to property list\n"); - return -1; + if (H5Pclose(fapl) < 0) { + HDfprintf(stderr, "Failed to property list\n"); + return -1; } - if(H5Fclose(fid) < 0){ - HDfprintf(stderr, "Failed to close file id\n"); - return -1; + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "Failed to close file id\n"); + return -1; } return 0; } /* write_file() */ - - /* Overall Algorithm: * Parse options from user; * Generate/pre-created test files needed and close it; @@ -509,14 +509,14 @@ main(int argc, char *argv[]) int ret_value = 0; /* initialization */ - if(setup_parameters(argc, argv) < 0) - Hgoto_error(1); + if (setup_parameters(argc, argv) < 0) + Hgoto_error(1); /* ============*/ /* Create file */ /* ============*/ HDprintf("Creating skeleton data file for testing H5Odisable_mdc_flushes()...\n"); - if(create_file() < 0) { + if (create_file() < 0) { HDfprintf(stderr, "***encounter error\n"); Hgoto_error(1); } /* end if */ @@ -524,19 +524,19 @@ main(int argc, char *argv[]) HDprintf("File created.\n"); HDprintf("writing to the file\n"); - if(write_file() < 0) { + if (write_file() < 0) { HDfprintf(stderr, "write_file encountered error\n"); Hgoto_error(1); } done: /* Print result and exit */ - if(ret_value != 0) + if (ret_value != 0) HDprintf("Error(s) encountered\n"); else HDprintf("All passed\n"); - return(ret_value); + return (ret_value); } #else /* H5_HAVE_FORK */ @@ -549,4 +549,3 @@ main(void) } /* end main() */ #endif /* H5_HAVE_FORK */ - diff --git a/test/vds.c b/test/vds.c index c4d1391..7be1429 100644 --- a/test/vds.c +++ b/test/vds.c @@ -29,35 +29,22 @@ typedef enum { TEST_API_NTESTS } test_api_config_t; -const char *FILENAME[] = { - "vds_virt_0", - "vds_virt_1", - "vds_src_0", - "vds_src_1", - "vds%%_src", - "vds_dapl", - "vds_virt_2", - "vds_virt_3", - "vds_src_2", - "vds_src_3", - "vds%%_src2", - "vds_dapl2", - NULL -}; +const char *FILENAME[] = {"vds_virt_0", "vds_virt_1", "vds_src_0", "vds_src_1", "vds%%_src", + "vds_dapl", "vds_virt_2", "vds_virt_3", "vds_src_2", "vds_src_3", + "vds%%_src2", "vds_dapl2", NULL}; /* I/O test config flags */ -#define TEST_IO_CLOSE_SRC 0x01u -#define TEST_IO_DIFFERENT_FILE 0x02u -#define TEST_IO_REOPEN_VIRT 0x04u -#define TEST_IO_NTESTS 0x08u +#define TEST_IO_CLOSE_SRC 0x01u +#define TEST_IO_DIFFERENT_FILE 0x02u +#define TEST_IO_REOPEN_VIRT 0x04u +#define TEST_IO_NTESTS 0x08u #define LIST_DOUBLE_SIZE (H5D_VIRTUAL_DEF_LIST_SIZE + 1) -#define FILENAME_BUF_SIZE 1024 +#define FILENAME_BUF_SIZE 1024 -#define TMPDIR "tmp_vds/" +#define TMPDIR "tmp_vds/" - /*------------------------------------------------------------------------- * Function: vds_select_equal * @@ -71,126 +58,126 @@ const char *FILENAME[] = { static htri_t vds_select_equal(hid_t space1, hid_t space2) { - H5S_sel_type type1; - H5S_sel_type type2; - hsize_t *buf1 = NULL; - hsize_t *buf2 = NULL; - size_t i; - htri_t ret_value = TRUE; + H5S_sel_type type1; + H5S_sel_type type2; + hsize_t * buf1 = NULL; + hsize_t * buf2 = NULL; + size_t i; + htri_t ret_value = TRUE; /* Get and compare selection types */ - if((type1 = H5Sget_select_type(space1)) < 0) + if ((type1 = H5Sget_select_type(space1)) < 0) TEST_ERROR - if((type2 = H5Sget_select_type(space2)) < 0) + if ((type2 = H5Sget_select_type(space2)) < 0) TEST_ERROR - if(type1 != type2) + if (type1 != type2) return FALSE; /* Check selection type */ - switch(type1) { + switch (type1) { case H5S_SEL_NONE: case H5S_SEL_ALL: break; - case H5S_SEL_POINTS: - { - int rank1; - int rank2; - hssize_t npoints1; - hssize_t npoints2; + case H5S_SEL_POINTS: { + int rank1; + int rank2; + hssize_t npoints1; + hssize_t npoints2; - /* Get and compare rank */ - if((rank1 = H5Sget_simple_extent_ndims(space1)) < 0) - TEST_ERROR - if((rank2 = H5Sget_simple_extent_ndims(space2)) < 0) - TEST_ERROR - if(rank1 != rank2) - return FALSE; + /* Get and compare rank */ + if ((rank1 = H5Sget_simple_extent_ndims(space1)) < 0) + TEST_ERROR + if ((rank2 = H5Sget_simple_extent_ndims(space2)) < 0) + TEST_ERROR + if (rank1 != rank2) + return FALSE; - /* Get and compare number of points */ - if((npoints1 = H5Sget_select_elem_npoints(space1)) < 0) - TEST_ERROR - if((npoints2 = H5Sget_select_elem_npoints(space2)) < 0) - TEST_ERROR - if(npoints1 != npoints2) - return FALSE; + /* Get and compare number of points */ + if ((npoints1 = H5Sget_select_elem_npoints(space1)) < 0) + TEST_ERROR + if ((npoints2 = H5Sget_select_elem_npoints(space2)) < 0) + TEST_ERROR + if (npoints1 != npoints2) + return FALSE; - /* Allocate point lists. Do not return directly after - * allocating, to make sure buffers are freed. */ - if(NULL == (buf1 = (hsize_t *)HDmalloc((size_t)rank1 * (size_t)npoints1 * sizeof(hsize_t)))) - TEST_ERROR - if(NULL == (buf2 = (hsize_t *)HDmalloc((size_t)rank1 * (size_t)npoints1 * sizeof(hsize_t)))) - TEST_ERROR + /* Allocate point lists. Do not return directly after + * allocating, to make sure buffers are freed. */ + if (NULL == (buf1 = (hsize_t *)HDmalloc((size_t)rank1 * (size_t)npoints1 * sizeof(hsize_t)))) + TEST_ERROR + if (NULL == (buf2 = (hsize_t *)HDmalloc((size_t)rank1 * (size_t)npoints1 * sizeof(hsize_t)))) + TEST_ERROR - /* Get and compare point lists */ - if(H5Sget_select_elem_pointlist(space1, (hsize_t)0, (hsize_t)npoints1, buf1) < 0) - TEST_ERROR - if(H5Sget_select_elem_pointlist(space2, (hsize_t)0, (hsize_t)npoints1, buf2) < 0) - TEST_ERROR - for(i = 0; i < ((size_t)rank1 * (size_t)npoints1); i++) - if(buf1[i] != buf2[i]) { - ret_value = FALSE; - break; - } + /* Get and compare point lists */ + if (H5Sget_select_elem_pointlist(space1, (hsize_t)0, (hsize_t)npoints1, buf1) < 0) + TEST_ERROR + if (H5Sget_select_elem_pointlist(space2, (hsize_t)0, (hsize_t)npoints1, buf2) < 0) + TEST_ERROR + for (i = 0; i < ((size_t)rank1 * (size_t)npoints1); i++) + if (buf1[i] != buf2[i]) { + ret_value = FALSE; + break; + } - /* Free buffers */ - HDfree(buf1); - buf1 = NULL; - HDfree(buf2); - buf2 = NULL; - } /* end block */ + /* Free buffers */ + HDfree(buf1); + buf1 = NULL; + HDfree(buf2); + buf2 = NULL; + } /* end block */ - break; + break; - case H5S_SEL_HYPERSLABS: - { - int rank1; - int rank2; - hssize_t nblocks1; - hssize_t nblocks2; + case H5S_SEL_HYPERSLABS: { + int rank1; + int rank2; + hssize_t nblocks1; + hssize_t nblocks2; - /* Get and compare rank */ - if((rank1 = H5Sget_simple_extent_ndims(space1)) < 0) - TEST_ERROR - if((rank2 = H5Sget_simple_extent_ndims(space2)) < 0) - TEST_ERROR - if(rank1 != rank2) - return FALSE; + /* Get and compare rank */ + if ((rank1 = H5Sget_simple_extent_ndims(space1)) < 0) + TEST_ERROR + if ((rank2 = H5Sget_simple_extent_ndims(space2)) < 0) + TEST_ERROR + if (rank1 != rank2) + return FALSE; - /* Get and compare number of blocks */ - if((nblocks1 = H5Sget_select_hyper_nblocks(space1)) < 0) - TEST_ERROR - if((nblocks2 = H5Sget_select_hyper_nblocks(space2)) < 0) - TEST_ERROR - if(nblocks1 != nblocks2) - return FALSE; + /* Get and compare number of blocks */ + if ((nblocks1 = H5Sget_select_hyper_nblocks(space1)) < 0) + TEST_ERROR + if ((nblocks2 = H5Sget_select_hyper_nblocks(space2)) < 0) + TEST_ERROR + if (nblocks1 != nblocks2) + return FALSE; - /* Allocate block lists. Do not return directly afer - * allocating, to make sure buffers are freed. */ - if(NULL == (buf1 = (hsize_t *)HDmalloc((size_t)2 * (size_t)rank1 * (size_t)nblocks1 * sizeof(*buf1)))) - TEST_ERROR - if(NULL == (buf2 = (hsize_t *)HDmalloc((size_t)2 * (size_t)rank1 * (size_t)nblocks1 * sizeof(*buf2)))) - TEST_ERROR + /* Allocate block lists. Do not return directly afer + * allocating, to make sure buffers are freed. */ + if (NULL == + (buf1 = (hsize_t *)HDmalloc((size_t)2 * (size_t)rank1 * (size_t)nblocks1 * sizeof(*buf1)))) + TEST_ERROR + if (NULL == + (buf2 = (hsize_t *)HDmalloc((size_t)2 * (size_t)rank1 * (size_t)nblocks1 * sizeof(*buf2)))) + TEST_ERROR - /* Get and compare block lists */ - if(H5Sget_select_hyper_blocklist(space1, (hsize_t)0, (hsize_t)nblocks1, buf1) < 0) - TEST_ERROR - if(H5Sget_select_hyper_blocklist(space2, (hsize_t)0, (hsize_t)nblocks1, buf2) < 0) - TEST_ERROR - for(i = 0; i < ((size_t)2 * (size_t)rank1 * (size_t)nblocks1); i++) - if(buf1[i] != buf2[i]) { - ret_value = FALSE; - break; - } + /* Get and compare block lists */ + if (H5Sget_select_hyper_blocklist(space1, (hsize_t)0, (hsize_t)nblocks1, buf1) < 0) + TEST_ERROR + if (H5Sget_select_hyper_blocklist(space2, (hsize_t)0, (hsize_t)nblocks1, buf2) < 0) + TEST_ERROR + for (i = 0; i < ((size_t)2 * (size_t)rank1 * (size_t)nblocks1); i++) + if (buf1[i] != buf2[i]) { + ret_value = FALSE; + break; + } - /* Free buffers */ - HDfree(buf1); - buf1 = NULL; - HDfree(buf2); - buf2 = NULL; - } /* end block */ + /* Free buffers */ + HDfree(buf1); + buf1 = NULL; + HDfree(buf2); + buf2 = NULL; + } /* end block */ - break; + break; case H5S_SEL_ERROR: case H5S_SEL_N: @@ -201,15 +188,14 @@ vds_select_equal(hid_t space1, hid_t space2) return ret_value; error: - if(buf1) + if (buf1) HDfree(buf1); - if(buf2) + if (buf2) HDfree(buf2); return -1; } /* end vds_select_equal() */ - /*------------------------------------------------------------------------- * Function: vds_check_mapping * @@ -222,13 +208,13 @@ error: *------------------------------------------------------------------------- */ static int -vds_check_mapping(hid_t dcpl, size_t i, hid_t vspace, hid_t srcspace, - const char *filename, const char *dsetname) +vds_check_mapping(hid_t dcpl, size_t i, hid_t vspace, hid_t srcspace, const char *filename, + const char *dsetname) { - hid_t space_out = -1; - char name_out[32]; - htri_t tri_ret; - ssize_t str_len; + hid_t space_out = -1; + char name_out[32]; + htri_t tri_ret; + ssize_t str_len; HDassert(dcpl >= 0); HDassert(vspace >= 0); @@ -237,68 +223,69 @@ vds_check_mapping(hid_t dcpl, size_t i, hid_t vspace, hid_t srcspace, HDassert(dsetname); /* Check vspace */ - if((space_out = H5Pget_virtual_vspace(dcpl, i)) < 0) + if ((space_out = H5Pget_virtual_vspace(dcpl, i)) < 0) TEST_ERROR - if((tri_ret = H5Sextent_equal(space_out, vspace)) < 0) + if ((tri_ret = H5Sextent_equal(space_out, vspace)) < 0) TEST_ERROR - if(!tri_ret) + if (!tri_ret) TEST_ERROR - if((tri_ret = vds_select_equal(space_out, vspace)) < 0) + if ((tri_ret = vds_select_equal(space_out, vspace)) < 0) TEST_ERROR - if(!tri_ret) + if (!tri_ret) TEST_ERROR - if(H5Sclose(space_out) < 0) + if (H5Sclose(space_out) < 0) TEST_ERROR space_out = -1; /* Check srcspace */ - if((space_out = H5Pget_virtual_srcspace(dcpl, i)) < 0) + if ((space_out = H5Pget_virtual_srcspace(dcpl, i)) < 0) TEST_ERROR - if((tri_ret = vds_select_equal(space_out, srcspace)) < 0) + if ((tri_ret = vds_select_equal(space_out, srcspace)) < 0) TEST_ERROR - if(!tri_ret) + if (!tri_ret) TEST_ERROR - if(H5Sclose(space_out) < 0) + if (H5Sclose(space_out) < 0) TEST_ERROR space_out = -1; /* Check filename */ - if((str_len = H5Pget_virtual_filename(dcpl, i, NULL, (size_t)0)) < 0) + if ((str_len = H5Pget_virtual_filename(dcpl, i, NULL, (size_t)0)) < 0) TEST_ERROR - if((size_t)str_len != HDstrlen(filename)) + if ((size_t)str_len != HDstrlen(filename)) TEST_ERROR HDassert((size_t)str_len < sizeof(name_out)); - if((str_len = H5Pget_virtual_filename(dcpl, i, name_out, sizeof(name_out))) < 0) + if ((str_len = H5Pget_virtual_filename(dcpl, i, name_out, sizeof(name_out))) < 0) TEST_ERROR - if((size_t)str_len != HDstrlen(filename)) + if ((size_t)str_len != HDstrlen(filename)) TEST_ERROR - if(HDstrncmp(name_out, filename, (size_t)str_len + 1) != 0) + if (HDstrncmp(name_out, filename, (size_t)str_len + 1) != 0) TEST_ERROR /* Check dsetname */ - if((str_len = H5Pget_virtual_dsetname(dcpl, i, NULL, (size_t)0)) < 0) + if ((str_len = H5Pget_virtual_dsetname(dcpl, i, NULL, (size_t)0)) < 0) TEST_ERROR - if((size_t)str_len != HDstrlen(dsetname)) + if ((size_t)str_len != HDstrlen(dsetname)) TEST_ERROR HDassert((size_t)str_len < sizeof(name_out)); - if((str_len = H5Pget_virtual_dsetname(dcpl, i, name_out, sizeof(name_out))) < 0) + if ((str_len = H5Pget_virtual_dsetname(dcpl, i, name_out, sizeof(name_out))) < 0) TEST_ERROR - if((size_t)str_len != HDstrlen(dsetname)) + if ((size_t)str_len != HDstrlen(dsetname)) TEST_ERROR - if(HDstrncmp(name_out, dsetname, (size_t)str_len + 1) != 0) + if (HDstrncmp(name_out, dsetname, (size_t)str_len + 1) != 0) TEST_ERROR return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space_out); - } H5E_END_TRY + } + H5E_END_TRY return -1; } /* end vds_check_mapping() */ - /*------------------------------------------------------------------------- * Function: test_api_get_ex_dcpl * @@ -310,15 +297,15 @@ error: */ /* Helper function to get DCPL for examination depending on config */ static int -test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, - hid_t *ex_dcpl, hid_t vspace, char *filename, hsize_t exp_meta_size) +test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, hid_t *ex_dcpl, hid_t vspace, + char *filename, hsize_t exp_meta_size) { - hid_t file = -1; /* File */ - hid_t dset = -1; /* Virtual dataset */ - H5D_space_status_t space_status; /* Dataset space status */ - void *plist_buf = NULL; /* Serialized property list buffer */ - H5O_native_info_t ninfo; /* Object info struct */ - htri_t tri_ret; + hid_t file = -1; /* File */ + hid_t dset = -1; /* Virtual dataset */ + H5D_space_status_t space_status; /* Dataset space status */ + void * plist_buf = NULL; /* Serialized property list buffer */ + H5O_native_info_t ninfo; /* Object info struct */ + htri_t tri_ret; HDassert((config >= TEST_API_BASIC) && (config < TEST_API_NTESTS)); HDassert(fapl >= 0); @@ -329,106 +316,107 @@ test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, HDassert(filename); /* Take different action depending on test configuration */ - if(config >= TEST_API_CREATE_DSET) { + if (config >= TEST_API_CREATE_DSET) { /* Create file and dataset */ - 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((dset = H5Dcreate2(file, "vdset", H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dset = H5Dcreate2(file, "vdset", H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Test H5Dget_space_status */ - if(H5Dget_space_status(dset, &space_status) < 0) + if (H5Dget_space_status(dset, &space_status) < 0) TEST_ERROR - if(space_status != H5D_SPACE_STATUS_ALLOCATED) + if (space_status != H5D_SPACE_STATUS_ALLOCATED) TEST_ERROR /* Reopen dataset if requested */ - if(config >= TEST_API_REOPEN_DSET) { + if (config >= TEST_API_REOPEN_DSET) { /* Close dataset */ - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) TEST_ERROR dset = -1; /* Reopen file if requested */ - if(config == TEST_API_REOPEN_FILE) { - if(H5Fclose(file) < 0) + if (config == TEST_API_REOPEN_FILE) { + if (H5Fclose(file) < 0) TEST_ERROR file = -1; - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } /* Open dataset */ - if((dset = H5Dopen2(file, "vdset", H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(file, "vdset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get DCPL from dataset */ - if((*ex_dcpl = H5Dget_create_plist(dset)) < 0) + if ((*ex_dcpl = H5Dget_create_plist(dset)) < 0) TEST_ERROR /* Test H5Dget_offset() (just returns HADDR_UNDEF) */ - if(HADDR_UNDEF != H5Dget_offset(dset)) + if (HADDR_UNDEF != H5Dget_offset(dset)) TEST_ERROR /* Test H5Oget_info returns correct metadata size */ - if(H5Oget_native_info(dset, &ninfo, H5O_NATIVE_INFO_META_SIZE) < 0) + if (H5Oget_native_info(dset, &ninfo, H5O_NATIVE_INFO_META_SIZE) < 0) TEST_ERROR - if(ninfo.meta_size.obj.index_size != (hsize_t)0) + if (ninfo.meta_size.obj.index_size != (hsize_t)0) TEST_ERROR - if(config == TEST_API_REOPEN_FILE) { - if(ninfo.meta_size.obj.heap_size != exp_meta_size) { - HDprintf("VDS metadata size: %llu Expected: %llu\n", (long long unsigned)ninfo.meta_size.obj.heap_size, (long long unsigned)exp_meta_size); + if (config == TEST_API_REOPEN_FILE) { + if (ninfo.meta_size.obj.heap_size != exp_meta_size) { + HDprintf("VDS metadata size: %llu Expected: %llu\n", + (long long unsigned)ninfo.meta_size.obj.heap_size, + (long long unsigned)exp_meta_size); TEST_ERROR } } - else - if((ninfo.meta_size.obj.heap_size != exp_meta_size) - && (ninfo.meta_size.obj.heap_size != (hsize_t)0)) - TEST_ERROR - if(ninfo.meta_size.attr.index_size != (hsize_t)0) + else if ((ninfo.meta_size.obj.heap_size != exp_meta_size) && + (ninfo.meta_size.obj.heap_size != (hsize_t)0)) + TEST_ERROR + if (ninfo.meta_size.attr.index_size != (hsize_t)0) TEST_ERROR - if(ninfo.meta_size.attr.index_size != (hsize_t)0) + if (ninfo.meta_size.attr.index_size != (hsize_t)0) TEST_ERROR /* Test H5Dget_space_status */ - if(H5Dget_space_status(dset, &space_status) < 0) + if (H5Dget_space_status(dset, &space_status) < 0) TEST_ERROR - if(space_status != H5D_SPACE_STATUS_ALLOCATED) + if (space_status != H5D_SPACE_STATUS_ALLOCATED) TEST_ERROR /* Close dataset */ - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) TEST_ERROR dset = -1; /* Delete dataset */ - if(H5Ldelete(file, "vdset", H5P_DEFAULT) < 0) + if (H5Ldelete(file, "vdset", H5P_DEFAULT) < 0) TEST_ERROR /* Close file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR file = -1; } - else if(config == TEST_API_COPY_PLIST) { + else if (config == TEST_API_COPY_PLIST) { /* Copy property list */ - if((*ex_dcpl = H5Pcopy(dcpl)) < 0) + if ((*ex_dcpl = H5Pcopy(dcpl)) < 0) TEST_ERROR } - else if(config == TEST_API_ENCDEC_PLIST) { + else if (config == TEST_API_ENCDEC_PLIST) { size_t plist_buf_size; /* Encode property list to plist_buf */ - if(H5Pencode2(dcpl, NULL, &plist_buf_size, fapl) < 0) + if (H5Pencode2(dcpl, NULL, &plist_buf_size, fapl) < 0) TEST_ERROR - if(NULL == (plist_buf = HDmalloc(plist_buf_size))) + if (NULL == (plist_buf = HDmalloc(plist_buf_size))) TEST_ERROR - if(H5Pencode2(dcpl, plist_buf, &plist_buf_size, fapl) < 0) + if (H5Pencode2(dcpl, plist_buf, &plist_buf_size, fapl) < 0) TEST_ERROR /* Decode serialized property list to *ex_dcpl */ - if((*ex_dcpl = H5Pdecode(plist_buf)) < 0) + if ((*ex_dcpl = H5Pdecode(plist_buf)) < 0) TEST_ERROR /* Free plist_buf */ @@ -438,7 +426,7 @@ test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, else { /* Simply copy the id to ex_dcpl and increment the ref count so ex_dcpl * can be closed */ - if(H5Iinc_ref(dcpl) < 0) + if (H5Iinc_ref(dcpl) < 0) TEST_ERROR *ex_dcpl = dcpl; } @@ -447,21 +435,23 @@ test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, * plist to itself, and do not do the comparison if we reopened the file, * because in that case the extent of the source dset will not be corrent. */ - if((*ex_dcpl != dcpl) && (config != TEST_API_REOPEN_FILE)) { - if((tri_ret = H5Pequal(dcpl, *ex_dcpl)) < 0) + if ((*ex_dcpl != dcpl) && (config != TEST_API_REOPEN_FILE)) { + if ((tri_ret = H5Pequal(dcpl, *ex_dcpl)) < 0) TEST_ERROR - if(!tri_ret) + if (!tri_ret) TEST_ERROR } return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); H5Dclose(dset); - } H5E_END_TRY; - if(plist_buf) + } + H5E_END_TRY; + if (plist_buf) HDfree(plist_buf); return -1; @@ -472,29 +462,31 @@ static int test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) { char filename[FILENAME_BUF_SIZE]; - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t ex_dcpl = -1; /* Temporary dcpl for examination */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t ex_dcpl = -1; /* Temporary dcpl for examination */ hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ - hid_t vspace[LIST_DOUBLE_SIZE]; /* Virtual dset dataspaces */ - const char *src_file[4] = {"src_file1", "src_file2.", "src_file3..", "src_file4..."}; /* Source file names (different lengths) */ - const char *src_dset[4] = {"src_dset1....", "src_dset2.....", "src_dset3......", "src_dset4......."}; /* Source dataset names (different lengths) */ + hid_t vspace[LIST_DOUBLE_SIZE]; /* Virtual dset dataspaces */ + const char *src_file[4] = {"src_file1", "src_file2.", "src_file3..", + "src_file4..."}; /* Source file names (different lengths) */ + const char *src_dset[4] = {"src_dset1....", "src_dset2.....", "src_dset3......", + "src_dset4......."}; /* Source dataset names (different lengths) */ char tmp_filename[32]; char tmp_dsetname[32]; hsize_t dims[2] = {10, 20}; /* Data space current size */ - hsize_t start[2]; /* Hyperslab start */ - hsize_t stride[2]; /* Hyperslab stride */ - hsize_t count[2]; /* Hyperslab count */ - hsize_t block[2]; /* Hyperslab block */ - hsize_t coord[10]; /* Point selection array */ + hsize_t start[2]; /* Hyperslab start */ + hsize_t stride[2]; /* Hyperslab stride */ + hsize_t count[2]; /* Hyperslab count */ + hsize_t block[2]; /* Hyperslab block */ + hsize_t coord[10]; /* Point selection array */ size_t size_out; herr_t ret; unsigned i; /* Initialize vspace */ - for(i = 0; i < (unsigned)(sizeof(vspace) / sizeof(vspace[0])); i++) + for (i = 0; i < (unsigned)(sizeof(vspace) / sizeof(vspace[0])); i++) vspace[i] = -1; - switch(config) { + switch (config) { case TEST_API_BASIC: TESTING("virtual dataset API functions") break; @@ -521,82 +513,80 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - /* * Test 1: All - all selection */ /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR - if(H5Sselect_all(vspace[0]) < 0) + if (H5Sselect_all(vspace[0]) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]) < 0) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)69) < 0) + if (test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)69) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ - if(H5Pget_virtual_count(ex_dcpl, &size_out) < 0) + if (H5Pget_virtual_count(ex_dcpl, &size_out) < 0) TEST_ERROR - if(size_out != (size_t)1) + if (size_out != (size_t)1) TEST_ERROR /* Check that the mapping in the DCPL is correct */ - if(vds_check_mapping(ex_dcpl, (size_t)0, vspace[0], srcspace[0], src_file[0], src_dset[0]) < 0) + if (vds_check_mapping(ex_dcpl, (size_t)0, vspace[0], srcspace[0], src_file[0], src_dset[0]) < 0) TEST_ERROR /* Close */ - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Pclose(ex_dcpl) < 0) + if (H5Pclose(ex_dcpl) < 0) TEST_ERROR ex_dcpl = -1; - /* * Test 2: Hyper - hyper selection */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select regular hyperslab in source space */ - start[0] = 2; - start[1] = 1; + start[0] = 2; + start[1] = 1; stride[0] = 3; stride[1] = 5; - count[0] = 2; - count[1] = 3; - block[0] = 2; - block[1] = 4; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 2; + count[1] = 3; + block[0] = 2; + block[1] = 4; + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Select composite hyperslab in virtual space */ @@ -604,60 +594,60 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) count[1] = 1; block[0] = 5; block[1] = 6; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, block) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, block) < 0) TEST_ERROR start[0] = 7; start[1] = 0; block[0] = 1; block[1] = 18; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, NULL, count, block) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, NULL, count, block) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]) < 0) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, - (low >= H5F_LIBVER_V112)?(hsize_t)99:(low >= H5F_LIBVER_V110?174:213)) < 0) + if (test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, + (low >= H5F_LIBVER_V112) ? (hsize_t)99 : (low >= H5F_LIBVER_V110 ? 174 : 213)) < + 0) TEST_ERROR /* Test H5Pget_virtual_count */ - if(H5Pget_virtual_count(ex_dcpl, &size_out) < 0) + if (H5Pget_virtual_count(ex_dcpl, &size_out) < 0) TEST_ERROR - if(size_out != (size_t)1) + if (size_out != (size_t)1) TEST_ERROR /* Check that the mapping in the DCPL is correct */ - if(vds_check_mapping(ex_dcpl, (size_t)0, vspace[0], srcspace[0], src_file[0], src_dset[0]) < 0) + if (vds_check_mapping(ex_dcpl, (size_t)0, vspace[0], srcspace[0], src_file[0], src_dset[0]) < 0) TEST_ERROR /* Close */ - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Pclose(ex_dcpl) < 0) + if (H5Pclose(ex_dcpl) < 0) TEST_ERROR ex_dcpl = -1; - #ifdef VDS_POINT_SELECTIONS /* VDS does not currently support point selections */ /* * Test 3: Point - point selection */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select points in source space */ @@ -671,7 +661,7 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) coord[7] = 14; coord[8] = 8; coord[9] = 18; - if(H5Sselect_elements(srcspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) + if (H5Sselect_elements(srcspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) TEST_ERROR /* Select points in virtual space */ @@ -685,52 +675,51 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) coord[7] = 11; coord[8] = 5; coord[9] = 5; - if(H5Sselect_elements(vspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) + if (H5Sselect_elements(vspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]) < 0) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)0) < 0) + if (test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)0) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ - if(H5Pget_virtual_count(ex_dcpl, &size_out) < 0) + if (H5Pget_virtual_count(ex_dcpl, &size_out) < 0) TEST_ERROR - if(size_out != (size_t)1) + if (size_out != (size_t)1) TEST_ERROR /* Check that the mapping in the DCPL is correct */ - if(vds_check_mapping(ex_dcpl, (size_t)0, vspace[0], srcspace[0], src_file[0], src_dset[0]) < 0) + if (vds_check_mapping(ex_dcpl, (size_t)0, vspace[0], srcspace[0], src_file[0], src_dset[0]) < 0) TEST_ERROR /* Close */ - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Pclose(ex_dcpl) < 0) + if (H5Pclose(ex_dcpl) < 0) TEST_ERROR ex_dcpl = -1; - /* * Test 4: Point - hyper selection */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select hyperslab in source space */ @@ -740,7 +729,7 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) count[1] = 1; block[0] = 1; block[1] = 5; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, block) < 0) + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, block) < 0) TEST_ERROR /* Select points in virtual space */ @@ -754,73 +743,72 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) coord[7] = 13; coord[8] = 7; coord[9] = 16; - if(H5Sselect_elements(vspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) + if (H5Sselect_elements(vspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]) < 0) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)0) < 0) + if (test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)0) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ - if(H5Pget_virtual_count(ex_dcpl, &size_out) < 0) + if (H5Pget_virtual_count(ex_dcpl, &size_out) < 0) TEST_ERROR - if(size_out != (size_t)1) + if (size_out != (size_t)1) TEST_ERROR /* Check that the mapping in the DCPL is correct */ - if(vds_check_mapping(ex_dcpl, (size_t)0, vspace[0], srcspace[0], src_file[0], src_dset[0]) < 0) + if (vds_check_mapping(ex_dcpl, (size_t)0, vspace[0], srcspace[0], src_file[0], src_dset[0]) < 0) TEST_ERROR /* Close */ - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Pclose(ex_dcpl) < 0) + if (H5Pclose(ex_dcpl) < 0) TEST_ERROR ex_dcpl = -1; - /* * Test 5: All previous mappings together */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create dataspaces */ - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { /* Create source dataspace */ - if((srcspace[i] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[i] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[i] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[i] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR } /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR - if(H5Sselect_all(vspace[0]) < 0) + if (H5Sselect_all(vspace[0]) < 0) TEST_ERROR /* Select regular hyperslab in source space */ - start[0] = 2; - start[1] = 1; + start[0] = 2; + start[1] = 1; stride[0] = 3; stride[1] = 5; - count[0] = 2; - count[1] = 3; - block[0] = 2; - block[1] = 4; - if(H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 2; + count[1] = 3; + block[0] = 2; + block[1] = 4; + if (H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Select composite hyperslab in virtual space */ @@ -828,13 +816,13 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) count[1] = 1; block[0] = 5; block[1] = 6; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, block) < 0) TEST_ERROR start[0] = 7; start[1] = 0; block[0] = 1; block[1] = 18; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, NULL, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, NULL, count, block) < 0) TEST_ERROR /* Select points in source space */ @@ -848,7 +836,7 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) coord[7] = 14; coord[8] = 8; coord[9] = 18; - if(H5Sselect_elements(srcspace[2], H5S_SELECT_SET, (size_t)5, coord) < 0) + if (H5Sselect_elements(srcspace[2], H5S_SELECT_SET, (size_t)5, coord) < 0) TEST_ERROR /* Select points in virtual space */ @@ -862,7 +850,7 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) coord[7] = 11; coord[8] = 5; coord[9] = 5; - if(H5Sselect_elements(vspace[2], H5S_SELECT_SET, (size_t)5, coord) < 0) + if (H5Sselect_elements(vspace[2], H5S_SELECT_SET, (size_t)5, coord) < 0) TEST_ERROR /* Select hyperslab in source space */ @@ -872,7 +860,7 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) count[1] = 1; block[0] = 1; block[1] = 5; - if(H5Sselect_hyperslab(srcspace[3], H5S_SELECT_SET, start, NULL, count, block) < 0) + if (H5Sselect_hyperslab(srcspace[3], H5S_SELECT_SET, start, NULL, count, block) < 0) TEST_ERROR /* Select points in virtual space */ @@ -886,57 +874,57 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) coord[7] = 13; coord[8] = 7; coord[9] = 16; - if(H5Sselect_elements(vspace[3], H5S_SELECT_SET, (size_t)5, coord) < 0) + if (H5Sselect_elements(vspace[3], H5S_SELECT_SET, (size_t)5, coord) < 0) TEST_ERROR /* Add virtual layout mappings */ - for(i = 0; i < 4; i++) - if(H5Pset_virtual(dcpl, vspace[i], src_file[i], src_dset[i], srcspace[i]) < 0) + for (i = 0; i < 4; i++) + if (H5Pset_virtual(dcpl, vspace[i], src_file[i], src_dset[i], srcspace[i]) < 0) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)0) < 0) + if (test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)0) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ - if(H5Pget_virtual_count(ex_dcpl, &size_out) < 0) + if (H5Pget_virtual_count(ex_dcpl, &size_out) < 0) TEST_ERROR - if(size_out != (size_t)4) + if (size_out != (size_t)4) TEST_ERROR /* Check that the mappings in the DCPL are correct */ - for(i = 0; i < 4; i++) - if(vds_check_mapping(ex_dcpl, (size_t)i, vspace[i], srcspace[i], src_file[i], src_dset[i]) < 0) + for (i = 0; i < 4; i++) + if (vds_check_mapping(ex_dcpl, (size_t)i, vspace[i], srcspace[i], src_file[i], src_dset[i]) < 0) TEST_ERROR /* Close */ - for(i = 0; i < 4; i++) { - if(H5Sclose(srcspace[i]) < 0) + for (i = 0; i < 4; i++) { + if (H5Sclose(srcspace[i]) < 0) TEST_ERROR srcspace[i] = -1; - if(H5Sclose(vspace[i]) < 0) + if (H5Sclose(vspace[i]) < 0) TEST_ERROR vspace[i] = -1; } - if(H5Pclose(ex_dcpl) < 0) + if (H5Pclose(ex_dcpl) < 0) TEST_ERROR ex_dcpl = -1; -#else /* VDS_POINT_SELECTIONS */ +#else /* VDS_POINT_SELECTIONS */ /* * Test 3: Verify point selections fail */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select points in source space */ @@ -950,7 +938,7 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) coord[7] = 14; coord[8] = 8; coord[9] = 18; - if(H5Sselect_elements(srcspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) + if (H5Sselect_elements(srcspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) TEST_ERROR /* Select points in virtual space */ @@ -964,32 +952,33 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) coord[7] = 11; coord[8] = 5; coord[9] = 5; - if(H5Sselect_elements(vspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) + if (H5Sselect_elements(vspace[0], H5S_SELECT_SET, (size_t)5, coord) < 0) TEST_ERROR /* Attempt to add virtual layout mapping */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_virtual(dcpl, vspace[0], src_file[0], src_dset[0], srcspace[0]); - } H5E_END_TRY - if(ret >= 0) + } + H5E_END_TRY + if (ret >= 0) TEST_ERROR #endif /* VDS_POINT_SELECTIONS */ - /* * Test 6: Enough Selections to trigger doubling of mapping list */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create source dataspace */ dims[0] = 1; - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all in source space (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR /* Init virtual space extent */ @@ -1004,40 +993,40 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) block[1] = 20; /* Build virtual layout */ - for(i = 0; i < LIST_DOUBLE_SIZE; i++) { + for (i = 0; i < LIST_DOUBLE_SIZE; i++) { /* Create virtual dataspace */ - if((vspace[i] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[i] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select row in virual dataspace */ start[0] = (hsize_t)i; - if(H5Sselect_hyperslab(vspace[i], H5S_SELECT_SET, start, NULL, count, block) < 0) + if (H5Sselect_hyperslab(vspace[i], H5S_SELECT_SET, start, NULL, count, block) < 0) TEST_ERROR - /* Create file and dataset names */ - (void)HDsnprintf(tmp_filename, sizeof(tmp_filename), "src_file%u", i); + /* Create file and dataset names */ + (void) HDsnprintf(tmp_filename, sizeof(tmp_filename), "src_file%u", i); tmp_filename[sizeof(tmp_filename) - 1] = '\0'; (void)HDsnprintf(tmp_dsetname, sizeof(tmp_dsetname), "src_dset%u", i); tmp_dsetname[sizeof(tmp_dsetname) - 1] = '\0'; /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[i], tmp_filename, tmp_dsetname, srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[i], tmp_filename, tmp_dsetname, srcspace[0]) < 0) TEST_ERROR } /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, - (low >= H5F_LIBVER_V112)?(hsize_t)607:(hsize_t)697) < 0) + if (test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, + (low >= H5F_LIBVER_V112) ? (hsize_t)607 : (hsize_t)697) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ - if(H5Pget_virtual_count(ex_dcpl, &size_out) < 0) + if (H5Pget_virtual_count(ex_dcpl, &size_out) < 0) TEST_ERROR - if(size_out != (size_t)LIST_DOUBLE_SIZE) + if (size_out != (size_t)LIST_DOUBLE_SIZE) TEST_ERROR /* Verify virtual layout */ - for(i = 0; i < LIST_DOUBLE_SIZE; i++) { + for (i = 0; i < LIST_DOUBLE_SIZE; i++) { /* Generate source file name */ (void)HDsnprintf(tmp_filename, sizeof(tmp_filename), "src_file%u", i); tmp_filename[sizeof(tmp_filename) - 1] = '\0'; @@ -1047,60 +1036,58 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) tmp_dsetname[sizeof(tmp_dsetname) - 1] = '\0'; /* Check that the mapping in the DCPL is correct */ - if(vds_check_mapping(ex_dcpl, (size_t)i, vspace[i], srcspace[0], tmp_filename, tmp_dsetname) < 0) + if (vds_check_mapping(ex_dcpl, (size_t)i, vspace[i], srcspace[0], tmp_filename, tmp_dsetname) < 0) TEST_ERROR } /* Close */ - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - for(i = 0; i < LIST_DOUBLE_SIZE; i++) { - if(H5Sclose(vspace[i]) < 0) + for (i = 0; i < LIST_DOUBLE_SIZE; i++) { + if (H5Sclose(vspace[i]) < 0) TEST_ERROR vspace[i] = -1; } - if(H5Pclose(ex_dcpl) < 0) + if (H5Pclose(ex_dcpl) < 0) TEST_ERROR ex_dcpl = -1; - /* * Test 7: Empty VDS */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(vspace[0]) < 0) + if (H5Sselect_all(vspace[0]) < 0) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)0) < 0) + if (test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)0) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ - if(H5Pget_virtual_count(ex_dcpl, &size_out) < 0) + if (H5Pget_virtual_count(ex_dcpl, &size_out) < 0) TEST_ERROR - if(size_out != (size_t)0) + if (size_out != (size_t)0) TEST_ERROR /* Close */ - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Pclose(ex_dcpl) < 0) + if (H5Pclose(ex_dcpl) < 0) TEST_ERROR ex_dcpl = -1; - /* Close */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR dcpl = -1; @@ -1108,16 +1095,18 @@ test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) return 0; error: - H5E_BEGIN_TRY { - for(i = 0; i < (sizeof(srcspace) / sizeof(srcspace[0])); i++) + H5E_BEGIN_TRY + { + for (i = 0; i < (sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); - for(i = 0; i < (sizeof(vspace) / sizeof(vspace[0])); i++) + for (i = 0; i < (sizeof(vspace) / sizeof(vspace[0])); i++) H5Sclose(vspace[i]); H5Pclose(dcpl); H5Pclose(ex_dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; - return 1; + return 1; } /* end test_api() */ /*------------------------------------------------------------------------- @@ -1134,39 +1123,39 @@ error: static int test_vds_prefix_first(unsigned config, hid_t fapl) { - char *srcfilename = NULL; - char *srcfilename_map = NULL; - char *vfilename = NULL; - char *srcfilenamepct = NULL; - char *srcfilenamepct_map = NULL; + char * srcfilename = NULL; + char * srcfilename_map = NULL; + char * vfilename = NULL; + char * srcfilenamepct = NULL; + char * srcfilenamepct_map = NULL; const char *srcfilenamepct_map_orig = "vds%%%%_src"; - hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ - hid_t vfile = -1; /* File with virtual dset */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t dapl = -1; /* Dataset access property list */ - hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ - hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ - hid_t memspace = -1; /* Memory dataspace */ - hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ - hid_t vdset = -1; /* Virtual dataset */ - hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ - int buf[10][26]; /* Write and expected read buffer */ - int rbuf[10][26]; /* Read buffer */ - int fill = -1; /* Fill value */ + hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t dapl = -1; /* Dataset access property list */ + hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ + hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ + int buf[10][26]; /* Write and expected read buffer */ + int rbuf[10][26]; /* Read buffer */ + int fill = -1; /* Fill value */ int i, j; - char buffer[1024]; /* buffer to read vds_prefix */ + char buffer[1024]; /* buffer to read vds_prefix */ TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection") - if((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; h5_fixname(FILENAME[0], fapl, vfilename, FILENAME_BUF_SIZE); @@ -1180,180 +1169,182 @@ test_vds_prefix_first(unsigned config, hid_t fapl) TEST_ERROR /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) TEST_ERROR /* Initialize VDS prefix items */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR - if(H5Pset_virtual_prefix(dapl, TMPDIR) < 0) + if (H5Pset_virtual_prefix(dapl, TMPDIR) < 0) TEST_ERROR - if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) + if (H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) TEST_ERROR - if(HDstrcmp(buffer, TMPDIR) != 0) + if (HDstrcmp(buffer, TMPDIR) != 0) FAIL_PUTS_ERROR("vds prefix not set correctly"); /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR - if(H5Sselect_all(vspace[0]) < 0) + if (H5Sselect_all(vspace[0]) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", + srcspace[0]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if(NULL == HDgetcwd(buffer, 1024)) + if (config & TEST_IO_DIFFERENT_FILE) { + if (NULL == HDgetcwd(buffer, 1024)) TEST_ERROR - if(HDchdir(TMPDIR) < 0) + if (HDchdir(TMPDIR) < 0) TEST_ERROR - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(HDchdir(buffer) < 0) + if (HDchdir(buffer) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Write data directly to source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Read data through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) { + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) { TEST_ERROR } } /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Reopen srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) { - if(NULL == HDgetcwd(buffer, 1024)) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) { + if (NULL == HDgetcwd(buffer, 1024)) TEST_ERROR - if(HDchdir(TMPDIR) < 0) + if (HDchdir(TMPDIR) < 0) TEST_ERROR - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if(HDchdir(buffer) < 0) + if (HDchdir(buffer) < 0) TEST_ERROR } - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data directly from source dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) TEST_ERROR dapl = -1; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR dcpl = -1; @@ -1366,24 +1357,26 @@ test_vds_prefix_first(unsigned config, hid_t fapl) PASSED(); return 0; - error: - H5E_BEGIN_TRY { - for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) +error: + H5E_BEGIN_TRY + { + for (i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) H5Dclose(srcdset[i]); H5Dclose(vdset); - for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) + for (i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) H5Fclose(srcfile[i]); H5Fclose(vfile); - for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) + for (i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); - for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + for (i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) H5Sclose(vspace[i]); H5Sclose(memspace); H5Pclose(dapl); H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(HDsetenv("HDF5_VDS_PREFIX", "", 1) < 0) + if (HDsetenv("HDF5_VDS_PREFIX", "", 1) < 0) TEST_ERROR HDfree(srcfilename); @@ -1395,7 +1388,6 @@ test_vds_prefix_first(unsigned config, hid_t fapl) return 1; } /* end test_vds_prefix */ - /*------------------------------------------------------------------------- * Function: test_basic_io * @@ -1409,50 +1401,50 @@ test_vds_prefix_first(unsigned config, hid_t fapl) static int test_basic_io(unsigned config, hid_t fapl) { - char *srcfilename = NULL; - char *srcfilename_map = NULL; - char *vfilename = NULL; - char *vfilename2 = NULL; - char *srcfilenamepct = NULL; - char *srcfilenamepct_map = NULL; + char * srcfilename = NULL; + char * srcfilename_map = NULL; + char * vfilename = NULL; + char * vfilename2 = NULL; + char * srcfilenamepct = NULL; + char * srcfilenamepct_map = NULL; const char *srcfilenamepct_map_orig = "vds%%%%_src"; - hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ - hid_t vfile = -1; /* File with virtual dset */ - hid_t vfile2 = -1; /* File with copied virtual dset */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ - hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ - hid_t memspace = -1; /* Memory dataspace */ - hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ - hid_t vdset = -1; /* Virtual dataset */ - hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ - hsize_t start[4]; /* Hyperslab start */ - hsize_t stride[4]; /* Hyperslab stride */ - hsize_t count[4]; /* Hyperslab count */ - hsize_t block[4]; /* Hyperslab block */ - hssize_t offset[2] = {0, 0}; /* Selection offset */ - int buf[10][26]; /* Write and expected read buffer */ - int rbuf[10][26]; /* Read buffer */ - int rbuf99[9][9]; /* 9x9 Read buffer */ - int evbuf[10][26]; /* Expected VDS "buffer" */ - int erbuf[10][26]; /* Expected read buffer */ - int fill = -1; /* Fill value */ - herr_t ret; /* Generic return value */ + hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t vfile2 = -1; /* File with copied virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ + hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ + hsize_t start[4]; /* Hyperslab start */ + hsize_t stride[4]; /* Hyperslab stride */ + hsize_t count[4]; /* Hyperslab count */ + hsize_t block[4]; /* Hyperslab block */ + hssize_t offset[2] = {0, 0}; /* Selection offset */ + int buf[10][26]; /* Write and expected read buffer */ + int rbuf[10][26]; /* Read buffer */ + int rbuf99[9][9]; /* 9x9 Read buffer */ + int evbuf[10][26]; /* Expected VDS "buffer" */ + int erbuf[10][26]; /* Expected read buffer */ + int fill = -1; /* Fill value */ + herr_t ret; /* Generic return value */ int i, j, u, v; TESTING("basic virtual dataset I/O") - if((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((vfilename2 = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((vfilename2 = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; h5_fixname(FILENAME[0], fapl, vfilename, FILENAME_BUF_SIZE); @@ -1463,897 +1455,905 @@ test_basic_io(unsigned config, hid_t fapl) h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, FILENAME_BUF_SIZE); /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) TEST_ERROR /* * Test 1: All - all selection */ /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR - if(H5Sselect_all(vspace[0]) < 0) + if (H5Sselect_all(vspace[0]) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", + srcspace[0]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Write data directly to source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Reopen srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data directly from source dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - /* * Test 2: 2 Source datasets, hyperslab virtual mappings, '%' in source * dataset name, also test H5Ocopy() */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 13; - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all in source space (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR start[1] = 13; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "%%src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "%%src_dset1", srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2%%", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "src_dset2%%", srcspace[0]) < 0) TEST_ERROR /* Reset dims */ dims[1] = 26; /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "%src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "%src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2%", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2%", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Write data directly to source datasets */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Reopen srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data directly from source datasets */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR - if(H5Dread(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Test H5Ocopy() to same file */ /* Copy virtual dataset */ - if(H5Ocopy(vfile, "v_dset", vfile, "v_dset2", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Ocopy(vfile, "v_dset", vfile, "v_dset2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close v_dset */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data directly to source datasets */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } /* Open v_dset2 */ - if((vdset = H5Dopen2(vfile, "v_dset2", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset2", H5P_DEFAULT)) < 0) TEST_ERROR /* Read data through copied virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Reopen srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) TEST_ERROR } /* Only copy to a different file if the source datasets are in a different * file */ - if(config & TEST_IO_DIFFERENT_FILE) { + if (config & TEST_IO_DIFFERENT_FILE) { /* Close v_dset2 */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; /* Create file to copy virtual dataset to */ - if((vfile2 = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile2 = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Copy virtual dataset */ - if(H5Ocopy(vfile, "v_dset", vfile2, "v_dset3", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Ocopy(vfile, "v_dset", vfile2, "v_dset3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data directly to source datasets */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen copied virtual file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile2) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile2) < 0) TEST_ERROR vfile2 = -1; - if((vfile2 = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile2 = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } /* Open v_dset3 */ - if((vdset = H5Dopen2(vfile2, "v_dset3", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile2, "v_dset3", H5P_DEFAULT)) < 0) TEST_ERROR /* Read data through copied virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Reopen srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) TEST_ERROR } /* Close copied virtual file */ - if(H5Fclose(vfile2) < 0) + if (H5Fclose(vfile2) < 0) TEST_ERROR vfile2 = -1; } /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* * Test 3: 2 Source datasets, hyperslab virtual mappings with offsets */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 13; - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all in source space (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ start[0] = 0; start[1] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Add virtual layout mappings */ offset[1] = -3; - if(H5Soffset_simple(vspace[0], offset) < 0) + if (H5Soffset_simple(vspace[0], offset) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "%%src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "%%src_dset1", srcspace[0]) < 0) TEST_ERROR offset[1] = 10; - if(H5Soffset_simple(vspace[0], offset) < 0) + if (H5Soffset_simple(vspace[0], offset) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2%%", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "src_dset2%%", srcspace[0]) < 0) TEST_ERROR /* Reset dims */ dims[1] = 26; /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "%src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "%src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2%", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2%", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Write data directly to source datasets */ offset[1] = -3; - if(H5Soffset_simple(vspace[0], offset) < 0) + if (H5Soffset_simple(vspace[0], offset) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR offset[1] = 10; - if(H5Soffset_simple(vspace[0], offset) < 0) + if (H5Soffset_simple(vspace[0], offset) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Reopen srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data directly from source datasets */ HDmemset(rbuf[0], 0, sizeof(rbuf)); offset[1] = -3; - if(H5Soffset_simple(vspace[0], offset) < 0) + if (H5Soffset_simple(vspace[0], offset) < 0) TEST_ERROR - if(H5Dread(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR offset[1] = 10; - if(H5Soffset_simple(vspace[0], offset) < 0) + if (H5Soffset_simple(vspace[0], offset) < 0) TEST_ERROR - if(H5Dread(srcdset[1], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[1], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - /* * Test 4: 2 Source datasets, hyperslab virtual mappings on one mapping at a * time, '%' in source file name */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 13; - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all in source space (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR start[1] = 13; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_map : ".", + "src_dset1", srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_map : ".", "src_dset2", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_map : ".", + "src_dset2", srcspace[0]) < 0) TEST_ERROR /* Reset dims */ dims[1] = 26; /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilenamepct, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilenamepct, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Write data directly to source datasets */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read first source dataset through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, vspace[0], vspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, vspace[0], vspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != (j < (int)(sizeof(buf[0]) / sizeof(buf[0][0]) / 2) - ? buf[i][j] : 0)) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != (j < (int)(sizeof(buf[0]) / sizeof(buf[0][0]) / 2) ? buf[i][j] : 0)) TEST_ERROR /* Read second source dataset through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, vspace[1], vspace[1], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, vspace[1], vspace[1], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != (j < (int)(sizeof(buf[0]) / sizeof(buf[0][0]) / 2) - ? 0 : buf[i][j])) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != (j < (int)(sizeof(buf[0]) / sizeof(buf[0][0]) / 2) ? 0 : buf[i][j])) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write first source dataset through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, vspace[0], vspace[0], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, vspace[0], vspace[0], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write second source dataset through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, vspace[1], vspace[1], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, vspace[1], vspace[1], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Reopen srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilenamepct, H5F_ACC_RDONLY, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilenamepct, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data directly from source datasets */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR - if(H5Dread(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[1], H5T_NATIVE_INT, vspace[1], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != (j < (int)(sizeof(buf[0]) / sizeof(buf[0][0]) / 2) - ? (buf[i][j] - (int)(sizeof(buf) / sizeof(buf[0][0]))) - : buf[i][j])) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != (j < (int)(sizeof(buf[0]) / sizeof(buf[0][0]) / 2) + ? (buf[i][j] - (int)(sizeof(buf) / sizeof(buf[0][0]))) + : buf[i][j])) TEST_ERROR /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* * Test 5: 2 Source datasets, hyperslab virtual mappings and selections */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create source dataspaces */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((srcspace[1] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[1] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select hyperslabs in source space */ @@ -2361,10 +2361,10 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 10; count[1] = 13; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[1] = 13; - if(H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ @@ -2372,105 +2372,109 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 5; count[1] = 26; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[0] = 5; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[1]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[1]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[1], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[1], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Write data directly to source datasets */ /* Write first dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update evbuf */ - for(i = 0; i < 5; i++) { - for(j = 0; j < 13; j++) + for (i = 0; i < 5; i++) { + for (j = 0; j < 13; j++) evbuf[i][j] = buf[2 * i][j]; - for(/* j = 13 */; j < 26; j++) + for (/* j = 13 */; j < 26; j++) evbuf[i][j] = buf[2 * i + 1][j - 13]; } /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write second dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update evbuf */ - for(i = 0; i < 5; i++) { - for(j = 0; j < 13; j++) + for (i = 0; i < 5; i++) { + for (j = 0; j < 13; j++) evbuf[i + 5][j] = buf[2 * i][j + 13]; - for(/* j = 13 */; j < 26; j++) + for (/* j = 13 */; j < 26; j++) evbuf[i + 5][j] = buf[2 * i + 1][j]; } /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } @@ -2479,78 +2483,78 @@ test_basic_io(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read first slice */ - if(H5Dread(vdset, H5T_NATIVE_INT, vspace[0], srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, vspace[0], srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) { - for(j = 0; j < 13; j++) + for (i = 0; i < 5; i++) { + for (j = 0; j < 13; j++) erbuf[i][j] = evbuf[2 * i][j]; - for(/* j = 13 */; j < 26; j++) + for (/* j = 13 */; j < 26; j++) erbuf[i][j] = evbuf[2 * i + 1][j - 13]; } /* Read second slice */ - if(H5Dread(vdset, H5T_NATIVE_INT, vspace[1], srcspace[1], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, vspace[1], srcspace[1], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) { - for(j = 0; j < 13; j++) + for (i = 0; i < 5; i++) { + for (j = 0; j < 13; j++) erbuf[i + 5][j] = evbuf[2 * i][j + 13]; - for(/* j = 13 */; j < 26; j++) + for (/* j = 13 */; j < 26; j++) erbuf[i + 5][j] = evbuf[2 * i + 1][j]; } /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset */ /* Write first slice */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, vspace[0], srcspace[0], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, vspace[0], srcspace[0], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update evbuf */ - for(i = 0; i < 5; i++) { - for(j = 0; j < 13; j++) + for (i = 0; i < 5; i++) { + for (j = 0; j < 13; j++) evbuf[2 * i][j] = buf[i][j]; - for(/* j = 13 */; j < 26; j++) + for (/* j = 13 */; j < 26; j++) evbuf[2 * i + 1][j - 13] = buf[i][j]; } /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write second slice */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, vspace[1], srcspace[1], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, vspace[1], srcspace[1], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update evbuf */ - for(i = 0; i < 5; i++) { - for(j = 0; j < 13; j++) + for (i = 0; i < 5; i++) { + for (j = 0; j < 13; j++) evbuf[2 * i][j + 13] = buf[i + 5][j]; - for(/* j = 13 */; j < 26; j++) + for (/* j = 13 */; j < 26; j++) evbuf[2 * i + 1][j] = buf[i + 5][j]; } /* Reopen srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR } @@ -2559,89 +2563,88 @@ test_basic_io(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read first dataset */ - if(H5Dread(srcdset[0], H5T_NATIVE_INT, srcspace[0], srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, srcspace[0], srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) { - for(j = 0; j < 13; j++) + for (i = 0; i < 5; i++) { + for (j = 0; j < 13; j++) erbuf[2 * i][j] = evbuf[i][j]; - for(/* j = 13 */; j < 26; j++) + for (/* j = 13 */; j < 26; j++) erbuf[2 * i + 1][j - 13] = evbuf[i][j]; } /* Read second dataset */ - if(H5Dread(srcdset[1], H5T_NATIVE_INT, srcspace[1], srcspace[1], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[1], H5T_NATIVE_INT, srcspace[1], srcspace[1], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) { - for(j = 0; j < 13; j++) + for (i = 0; i < 5; i++) { + for (j = 0; j < 13; j++) erbuf[2 * i][j + 13] = evbuf[i + 5][j]; - for(/* j = 13 */; j < 26; j++) + for (/* j = 13 */; j < 26; j++) erbuf[2 * i + 1][j] = evbuf[i + 5][j]; } /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(srcspace[1]) < 0) + if (H5Sclose(srcspace[1]) < 0) TEST_ERROR srcspace[1] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* * Test 6: 2 Source datasets, checkerboard/stripe pattern to trigger * sequence list refresh internally */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create memory dataspace */ - if((memspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((memspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspaces */ dims[1] = 52; - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create source dataspace and file space for second operation (srcspace[1]) */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((srcspace[1] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[1] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Reset dims */ @@ -2649,130 +2652,134 @@ test_basic_io(unsigned config, hid_t fapl) /* Select hyperslabs (stripe) in source space and file space for second * operation (srcspace[1]) */ - start[0] = 0; - start[1] = 0; + start[0] = 0; + start[1] = 0; stride[0] = 1; stride[1] = 2; - count[0] = 1; - count[1] = 26; - block[0] = 10; - block[1] = 1; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = 26; + block[0] = 10; + block[1] = 1; + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 1; - if(H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Select hyperslabs (checkerboard) in virtual spaces */ - start[0] = 0; - start[1] = 0; + start[0] = 0; + start[1] = 0; stride[0] = 2; stride[1] = 2; - count[0] = 5; - count[1] = 26; - block[0] = 1; - block[1] = 1; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 5; + count[1] = 26; + block[0] = 1; + block[1] = 1; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[0] = 1; start[1] = 1; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride, count, block) < 0) TEST_ERROR start[0] = 0; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[0] = 1; start[1] = 0; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[0]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Write data directly to source datasets */ /* Write first dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i += 2) - for(j = 0; j < 26; j++) + for (i = 0; i < 10; i += 2) + for (j = 0; j < 26; j++) erbuf[i][j] = buf[i][j]; /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write second dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 1; i < 10; i += 2) - for(j = 0; j < 26; j++) + for (i = 1; i < 10; i += 2) + for (j = 0; j < 26; j++) erbuf[i][j] = buf[i][j]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } @@ -2781,69 +2788,69 @@ test_basic_io(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read first stripe pattern */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Read second stripe pattern */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, srcspace[1], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, srcspace[1], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i += 2) - for(j = 0; j < 26; j++) { + for (i = 0; i < 10; i += 2) + for (j = 0; j < 26; j++) { erbuf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); erbuf[i + 1][j] -= (int)(sizeof(buf) / sizeof(buf[0][0])); } /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset */ /* Write first slice */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i += 2) - for(j = 0; j < 26; j++) + for (i = 0; i < 10; i += 2) + for (j = 0; j < 26; j++) erbuf[i][j] = buf[i][j]; /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write second slice */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, memspace, srcspace[1], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, memspace, srcspace[1], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 1; i < 10; i += 2) - for(j = 0; j < 26; j++) + for (i = 1; i < 10; i += 2) + for (j = 0; j < 26; j++) erbuf[i][j] = buf[i][j]; /* Reopen srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR } @@ -2852,75 +2859,74 @@ test_basic_io(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read first dataset */ - if(H5Dread(srcdset[0], H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i += 2) - for(j = 0; j < 26; j++) { + for (i = 0; i < 10; i += 2) + for (j = 0; j < 26; j++) { erbuf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); erbuf[i + 1][j] -= (int)(sizeof(buf) / sizeof(buf[0][0])); } /* Read second dataset */ - if(H5Dread(srcdset[1], H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[1], H5T_NATIVE_INT, memspace, srcspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(srcspace[1]) < 0) + if (H5Sclose(srcspace[1]) < 0) TEST_ERROR srcspace[1] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR memspace = -1; - /* * Test 7: 1 Source dataset, two mappings, 4 dimensional virtual dataset * and 3 dimensional source dataset */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create memory dataspace */ - if((memspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((memspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspaces */ @@ -2928,18 +2934,18 @@ test_basic_io(unsigned config, hid_t fapl) dims[1] = 3; dims[2] = 3; dims[3] = 3; - if((vspace[0] = H5Screate_simple(4, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(4, dims, NULL)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(4, dims, NULL)) < 0) + if ((vspace[1] = H5Screate_simple(4, dims, NULL)) < 0) TEST_ERROR /* Create source dataspaces */ dims[0] = 2; dims[1] = 4; dims[2] = 4; - if((srcspace[0] = H5Screate_simple(3, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(3, dims, NULL)) < 0) TEST_ERROR - if((srcspace[1] = H5Screate_simple(3, dims, NULL)) < 0) + if ((srcspace[1] = H5Screate_simple(3, dims, NULL)) < 0) TEST_ERROR /* Reset dims */ @@ -2947,118 +2953,121 @@ test_basic_io(unsigned config, hid_t fapl) dims[1] = 26; /* Select hyperslabs (stripes) in source spaces */ - start[0] = 0; - start[1] = 0; - start[2] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; stride[0] = 1; stride[1] = 2; stride[2] = 1; - count[0] = 1; - count[1] = 2; - count[2] = 1; - block[0] = 2; - block[1] = 1; - block[2] = 4; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = 2; + count[2] = 1; + block[0] = 2; + block[1] = 1; + block[2] = 4; + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 1; - if(H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Select hyperslabs (corners) in first virtual space */ - start[0] = 0; - start[1] = 0; - start[2] = 0; - start[3] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; + start[3] = 0; stride[0] = 2; stride[1] = 2; stride[2] = 2; stride[3] = 2; - count[0] = 2; - count[1] = 2; - count[2] = 2; - count[3] = 2; - block[0] = 1; - block[1] = 1; - block[2] = 1; - block[3] = 1; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 2; + count[1] = 2; + count[2] = 2; + count[3] = 2; + block[0] = 1; + block[1] = 1; + block[2] = 1; + block[3] = 1; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Select hyperslabs ("+" pattern) in second virtual space */ - start[0] = 1; - start[1] = 1; - start[2] = 0; - start[3] = 0; + start[0] = 1; + start[1] = 1; + start[2] = 0; + start[3] = 0; stride[0] = 2; stride[1] = 2; stride[2] = 2; stride[3] = 2; - count[0] = 1; - count[1] = 1; - count[2] = 2; - count[3] = 2; - block[0] = 1; - block[1] = 1; - block[2] = 1; - block[3] = 1; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = 1; + count[2] = 2; + count[3] = 2; + block[0] = 1; + block[1] = 1; + block[2] = 1; + block[3] = 1; + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 0; start[2] = 1; count[1] = 2; count[2] = 1; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) TEST_ERROR start[0] = 0; start[1] = 1; count[0] = 2; count[1] = 1; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) TEST_ERROR start[0] = 1; count[0] = 1; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) TEST_ERROR start[1] = 0; start[3] = 1; count[1] = 2; count[3] = 1; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_OR, start, stride, count, block) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[1]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[1]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Select hyperslab in memory space */ @@ -3066,37 +3075,37 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 2; count[1] = 16; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data directly to source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } @@ -3109,7 +3118,7 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 9; count[1] = 3; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Read data through virtual dataset by hyperslab */ @@ -3125,17 +3134,17 @@ test_basic_io(unsigned config, hid_t fapl) count[1] = 3; count[2] = 1; count[3] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Read first stripe pattern */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ HDmemset(erbuf, 0, sizeof(erbuf)); - for(i = 0; i < 9; i++) - for(j = 0; j < 3; j++) + for (i = 0; i < 9; i++) + for (j = 0; j < 3; j++) erbuf[i][j] = fill; erbuf[0][0] = buf[0][0]; erbuf[0][2] = buf[0][1]; @@ -3149,9 +3158,9 @@ test_basic_io(unsigned config, hid_t fapl) erbuf[4][2] = buf[0][14]; /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Reset rbuf */ @@ -3166,7 +3175,7 @@ test_basic_io(unsigned config, hid_t fapl) count[1] = 3; count[2] = 1; count[3] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslab in memory space */ @@ -3174,16 +3183,16 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 3; count[0] = 9; count[1] = 3; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Read second stripe pattern */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 9; i++) - for(j = 3; j < 6; j++) + for (i = 0; i < 9; i++) + for (j = 3; j < 6; j++) erbuf[i][j] = fill; erbuf[1][3] = buf[0][4]; erbuf[1][5] = buf[0][5]; @@ -3199,15 +3208,14 @@ test_basic_io(unsigned config, hid_t fapl) erbuf[7][5] = buf[1][15]; /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if((j >= 3) && (j < 6)) { - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if ((j >= 3) && (j < 6)) { + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR } - else - if(rbuf[i][j] != 0) - TEST_ERROR + else if (rbuf[i][j] != 0) + TEST_ERROR /* Reset rbuf */ HDmemset(rbuf[0], 0, sizeof(rbuf)); @@ -3221,7 +3229,7 @@ test_basic_io(unsigned config, hid_t fapl) count[1] = 3; count[2] = 1; count[3] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslab in memory space */ @@ -3229,16 +3237,16 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 6; count[0] = 9; count[1] = 3; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Read third stripe pattern */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 9; i++) - for(j = 6; j < 9; j++) + for (i = 0; i < 9; i++) + for (j = 6; j < 9; j++) erbuf[i][j] = fill; erbuf[0][6] = buf[0][2]; erbuf[0][8] = buf[0][3]; @@ -3252,135 +3260,134 @@ test_basic_io(unsigned config, hid_t fapl) erbuf[4][8] = buf[1][6]; /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if((j >= 6) && (j < 9)) { - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if ((j >= 6) && (j < 9)) { + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR } - else - if(rbuf[i][j] != 0) - TEST_ERROR + else if (rbuf[i][j] != 0) + TEST_ERROR /* Now read entire VDS */ /* Set memory space extent to 9x9, select all in order to reach part of the * code in H5S_select_subtract() */ dims[0] = 9; dims[1] = 9; - if(H5Sset_extent_simple(memspace, 2, dims, NULL) < 0) + if (H5Sset_extent_simple(memspace, 2, dims, NULL) < 0) TEST_ERROR - if(H5Sselect_all(memspace) < 0) + if (H5Sselect_all(memspace) < 0) TEST_ERROR /* Read third stripe pattern */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf99[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf99[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(rbuf99) / sizeof(rbuf99[0])); i++) - for(j = 0; j < (int)(sizeof(rbuf99[0]) / sizeof(rbuf99[0][0])); j++) - if(rbuf99[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(rbuf99) / sizeof(rbuf99[0])); i++) + for (j = 0; j < (int)(sizeof(rbuf99[0]) / sizeof(rbuf99[0][0])); j++) + if (rbuf99[i][j] != erbuf[i][j]) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset by hyperslab */ /* Select stripe (only select mapped elements) */ - start[0] = 0; - start[1] = 0; - start[2] = 0; - start[3] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; + start[3] = 0; stride[0] = 2; stride[1] = 2; stride[2] = 1; stride[3] = 2; - count[0] = 2; - count[1] = 2; - count[2] = 1; - count[3] = 2; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride ,count, NULL) < 0) - TEST_ERROR - start[0] = 1; - start[1] = 1; - start[2] = 0; - start[3] = 0; + count[0] = 2; + count[1] = 2; + count[2] = 1; + count[3] = 2; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, NULL) < 0) + TEST_ERROR + start[0] = 1; + start[1] = 1; + start[2] = 0; + start[3] = 0; stride[0] = 1; stride[1] = 1; stride[2] = 1; stride[3] = 2; - count[0] = 1; - count[1] = 1; - count[2] = 1; - count[3] = 2; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride ,count, NULL) < 0) + count[0] = 1; + count[1] = 1; + count[2] = 1; + count[3] = 2; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride, count, NULL) < 0) TEST_ERROR /* Reset extent of memspace, select hyperslab */ dims[0] = 10; dims[1] = 26; - if(H5Sset_extent_simple(memspace, 2, dims, NULL) < 0) + if (H5Sset_extent_simple(memspace, 2, dims, NULL) < 0) TEST_ERROR start[0] = 0; start[1] = 0; count[0] = 1; count[1] = 10; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data through virtual dataset by hyperslab */ /* Write first stripe pattern */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ HDmemset(erbuf, 0, sizeof(erbuf)); - erbuf[0][0] = buf[0][0]; - erbuf[0][1] = buf[0][1]; - erbuf[0][8] = buf[0][2]; - erbuf[0][9] = buf[0][3]; - erbuf[1][0] = buf[0][6]; - erbuf[1][1] = buf[0][7]; - erbuf[1][8] = buf[0][8]; - erbuf[1][9] = buf[0][9]; + erbuf[0][0] = buf[0][0]; + erbuf[0][1] = buf[0][1]; + erbuf[0][8] = buf[0][2]; + erbuf[0][9] = buf[0][3]; + erbuf[1][0] = buf[0][6]; + erbuf[1][1] = buf[0][7]; + erbuf[1][8] = buf[0][8]; + erbuf[1][9] = buf[0][9]; erbuf[0][13] = buf[0][4]; erbuf[0][14] = buf[0][5]; /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Select stripe (only select mapped elements) */ - start[0] = 0; - start[1] = 1; - start[2] = 1; - start[3] = 0; + start[0] = 0; + start[1] = 1; + start[2] = 1; + start[3] = 0; stride[0] = 1; stride[1] = 1; stride[2] = 1; stride[3] = 2; - count[0] = 3; - count[1] = 1; - count[2] = 1; - count[3] = 2; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride ,count, NULL) < 0) - TEST_ERROR - start[0] = 1; - start[1] = 0; - start[2] = 1; - start[3] = 0; + count[0] = 3; + count[1] = 1; + count[2] = 1; + count[3] = 2; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, NULL) < 0) + TEST_ERROR + start[0] = 1; + start[1] = 0; + start[2] = 1; + start[3] = 0; stride[0] = 1; stride[1] = 2; stride[2] = 1; stride[3] = 1; - count[0] = 1; - count[1] = 2; - count[2] = 1; - count[3] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride ,count, NULL) < 0) + count[0] = 1; + count[1] = 2; + count[2] = 1; + count[3] = 3; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride, count, NULL) < 0) TEST_ERROR /* Select hyperslab in memory space */ @@ -3388,60 +3395,60 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 1; count[1] = 12; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write second slice */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - erbuf[0][4] = buf[0][0]; - erbuf[0][5] = buf[0][1]; - erbuf[0][6] = buf[0][2]; - erbuf[0][7] = buf[0][3]; + erbuf[0][4] = buf[0][0]; + erbuf[0][5] = buf[0][1]; + erbuf[0][6] = buf[0][2]; + erbuf[0][7] = buf[0][3]; erbuf[0][12] = buf[0][4]; erbuf[0][15] = buf[0][5]; - erbuf[1][4] = buf[0][6]; - erbuf[1][7] = buf[0][7]; + erbuf[1][4] = buf[0][6]; + erbuf[1][7] = buf[0][7]; erbuf[1][12] = buf[0][8]; erbuf[1][13] = buf[0][9]; erbuf[1][14] = buf[0][10]; erbuf[1][15] = buf[0][11]; /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Select stripe (only select mapped elements) */ - start[0] = 0; - start[1] = 0; - start[2] = 2; - start[3] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 2; + start[3] = 0; stride[0] = 2; stride[1] = 2; stride[2] = 1; stride[3] = 2; - count[0] = 2; - count[1] = 2; - count[2] = 1; - count[3] = 2; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride ,count, NULL) < 0) - TEST_ERROR - start[0] = 1; - start[1] = 1; - start[2] = 2; - start[3] = 0; + count[0] = 2; + count[1] = 2; + count[2] = 1; + count[3] = 2; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, NULL) < 0) + TEST_ERROR + start[0] = 1; + start[1] = 1; + start[2] = 2; + start[3] = 0; stride[0] = 1; stride[1] = 1; stride[2] = 1; stride[3] = 2; - count[0] = 1; - count[1] = 1; - count[2] = 1; - count[3] = 2; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride ,count, NULL) < 0) + count[0] = 1; + count[1] = 1; + count[2] = 1; + count[3] = 2; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_OR, start, stride, count, NULL) < 0) TEST_ERROR /* Select hyperslab in memory space */ @@ -3449,31 +3456,31 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 1; count[1] = 10; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write third slice */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - erbuf[0][2] = buf[0][0]; - erbuf[0][3] = buf[0][1]; + erbuf[0][2] = buf[0][0]; + erbuf[0][3] = buf[0][1]; erbuf[0][10] = buf[0][2]; erbuf[0][11] = buf[0][3]; - erbuf[1][2] = buf[0][6]; - erbuf[1][3] = buf[0][7]; + erbuf[1][2] = buf[0][6]; + erbuf[1][3] = buf[0][7]; erbuf[1][10] = buf[0][8]; erbuf[1][11] = buf[0][9]; - erbuf[1][5] = buf[0][4]; - erbuf[1][6] = buf[0][5]; + erbuf[1][5] = buf[0][4]; + erbuf[1][6] = buf[0][5]; /* Reopen srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR } @@ -3483,106 +3490,109 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 2; count[1] = 16; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL ,count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Reset rbuf */ HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read dataset */ - if(H5Dread(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Now try writing to whole VDS (should fail due to unmapped elements) */ count[0] = 9; count[1] = 9; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Dwrite(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]); - } H5E_END_TRY - if(ret >= 0) + } + H5E_END_TRY + if (ret >= 0) TEST_ERROR /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(srcspace[1]) < 0) + if (H5Sclose(srcspace[1]) < 0) TEST_ERROR srcspace[1] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR memspace = -1; - /* * Test 8: For code coverage: Horizontal block virtual mappings, and file * selection, grid memory selection */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create memory dataspace */ - if((memspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((memspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspaces */ dims[0] = 8; dims[1] = 15; - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create source dataspace */ dims[0] = 4; - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all in source space (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR start[0] = 4; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[0]) < 0) TEST_ERROR /* Reset dims */ @@ -3590,36 +3600,38 @@ test_basic_io(unsigned config, hid_t fapl) dims[1] = 26; /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Reset erbuf */ HDmemset(erbuf[0], 0, sizeof(rbuf)); /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Select hyperslab in memory */ @@ -3627,21 +3639,21 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 4; count[1] = 15; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data directly to first source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ u = 0; v = 0; - for(i = 2; i < 4; i++) - for(j = 0; j < 15; j++) { + for (i = 2; i < 4; i++) + for (j = 0; j < 15; j++) { erbuf[u][v] = buf[i][j]; v += 2; - if(v >= 24) { + if (v >= 24) { u += 2; v = 0; } @@ -3649,61 +3661,61 @@ test_basic_io(unsigned config, hid_t fapl) /* Select hyperslab in memory */ start[0] = 4; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data directly to second source dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 4; i < 6; i++) - for(j = 0; j < 15; j++) { + for (i = 4; i < 6; i++) + for (j = 0; j < 15; j++) { erbuf[u][v] = buf[i][j]; v += 2; - if(v >= 24) { + if (v >= 24) { u += 2; v = 0; } } /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Select hyperslab in memory */ - start[0] = 0; - start[1] = 0; + start[0] = 0; + start[1] = 0; stride[0] = 2; stride[1] = 2; - count[0] = 5; - count[1] = 12; - block[0] = 1; - block[1] = 1; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 5; + count[1] = 12; + block[0] = 1; + block[1] = 1; + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Select hyperslab in file */ @@ -3711,104 +3723,106 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 4; count[1] = 15; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Read data through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR memspace = -1; - /* * Test 9: For code coverage: Horizontal block virtual mappings, and file * selection, grid memory selection, 3 mappings, 3D memory space */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create memory dataspace */ dims[1] = 13; dims[2] = 2; - if((memspace = H5Screate_simple(3, dims, NULL)) < 0) + if ((memspace = H5Screate_simple(3, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspaces */ dims[0] = 6; dims[1] = 10; - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((vspace[2] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[2] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create source dataspace */ dims[0] = 2; - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all in source space (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR start[0] = 2; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR start[0] = 4; - if(H5Sselect_hyperslab(vspace[2], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(vspace[2], H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[2], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset3", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[2], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset3", + srcspace[0]) < 0) TEST_ERROR /* Reset dims */ @@ -3816,38 +3830,41 @@ test_basic_io(unsigned config, hid_t fapl) dims[1] = 26; /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset3", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset3", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Reset erbuf */ HDmemset(erbuf[0], 0, sizeof(rbuf)); /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Select hyperslab in memory */ @@ -3857,22 +3874,22 @@ test_basic_io(unsigned config, hid_t fapl) count[0] = 2; count[1] = 5; count[2] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data directly to first source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ u = 0; v = 0; - for(i = 0; i < 2; i++) - for(j = 0; j < 10; j++) { + for (i = 0; i < 2; i++) + for (j = 0; j < 10; j++) { erbuf[u][v] = buf[i][j]; - if(++v == 6) + if (++v == 6) v += 2; - else if(v == 14) { + else if (v == 14) { u += 2; v = 0; } @@ -3880,20 +3897,20 @@ test_basic_io(unsigned config, hid_t fapl) /* Select hyperslab in memory */ start[0] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data directly to second source dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 2; i < 4; i++) - for(j = 0; j < 10; j++) { + for (i = 2; i < 4; i++) + for (j = 0; j < 10; j++) { erbuf[u][v] = buf[i][j]; - if(++v == 6) + if (++v == 6) v += 2; - else if(v == 14) { + else if (v == 14) { u += 2; v = 0; } @@ -3901,174 +3918,175 @@ test_basic_io(unsigned config, hid_t fapl) /* Select hyperslab in memory */ start[0] = 4; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data directly to third source dataset */ - if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 4; i < 6; i++) - for(j = 0; j < 10; j++) { + for (i = 4; i < 6; i++) + for (j = 0; j < 10; j++) { erbuf[u][v] = buf[i][j]; - if(++v == 6) + if (++v == 6) v += 2; - else if(v == 14) { + else if (v == 14) { u += 2; v = 0; } } /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(srcdset[2]) < 0) + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Select hyperslab in memory */ - start[0] = 0; - start[1] = 0; - start[2] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; stride[0] = 2; stride[1] = 4; stride[2] = 1; - count[0] = 5; - count[1] = 2; - count[2] = 1; - block[0] = 1; - block[1] = 3; - block[2] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 5; + count[1] = 2; + count[2] = 1; + block[0] = 1; + block[1] = 3; + block[2] = 2; + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Read data through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(srcdset[2]) < 0) + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - if(H5Sclose(vspace[2]) < 0) + if (H5Sclose(vspace[2]) < 0) TEST_ERROR vspace[2] = -1; - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR memspace = -1; - /* * Test 10: For code coverage: Vertical stripe virtual mappings, vertical * block file selection, block memory selection, 3D VDS */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create memory dataspace */ - if((memspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((memspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspaces */ dims[0] = 10; dims[1] = 9; dims[2] = 6; - if((vspace[0] = H5Screate_simple(3, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(3, dims, NULL)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(3, dims, NULL)) < 0) + if ((vspace[1] = H5Screate_simple(3, dims, NULL)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 12; - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all in source space (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ - start[0] = 0; - start[1] = 0; - start[2] = 0; - count[0] = 1; - count[1] = 4; - count[2] = 3; + start[0] = 0; + start[1] = 0; + start[2] = 0; + count[0] = 1; + count[1] = 4; + count[2] = 3; stride[0] = 1; stride[1] = 2; stride[2] = 2; - block[0] = 10; - block[1] = 1; - block[2] = 1; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + block[0] = 10; + block[1] = 1; + block[2] = 1; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[2] = 1; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[0]) < 0) TEST_ERROR /* Reset dims */ @@ -4076,41 +4094,43 @@ test_basic_io(unsigned config, hid_t fapl) dims[1] = 26; /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Initialize erbuf */ HDmemset(erbuf[0], 0, sizeof(rbuf)); - for(i = 0; i < 10; i++) - for(j = 0; j < 24; j += 6) { - erbuf[i][j] = -1; + for (i = 0; i < 10; i++) + for (j = 0; j < 24; j += 6) { + erbuf[i][j] = -1; erbuf[i][j + 1] = -1; } /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Select hyperslab in memory */ @@ -4118,24 +4138,24 @@ test_basic_io(unsigned config, hid_t fapl) start[1] = 0; count[0] = 10; count[1] = 12; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data directly to first source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ u = 0; v = 0; - for(i = 0; i < 10; i++) - for(j = 0; j < 8; j++) { - if(v == 0 || v == 12) + for (i = 0; i < 10; i++) + for (j = 0; j < 8; j++) { + if (v == 0 || v == 12) erbuf[u][v] = buf[i][j]; v += 2; - if(!(v % 6)) + if (!(v % 6)) v += 6; - if(v >= 28) { + if (v >= 28) { u++; v = 0; } @@ -4143,66 +4163,66 @@ test_basic_io(unsigned config, hid_t fapl) /* Select hyperslab in memory */ start[1] = 8; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write data directly to second source dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ u = 0; v = 1; - for(i = 0; i < 10; i++) - for(j = 8; j < 16; j++) { - if(v == 1 || v == 13) + for (i = 0; i < 10; i++) + for (j = 8; j < 16; j++) { + if (v == 1 || v == 13) erbuf[u][v] = buf[i][j]; v += 2; - if(!((v - 1) % 6)) + if (!((v - 1) % 6)) v += 6; - if(v >= 28) { + if (v >= 28) { u++; v = 1; } } /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Select hyperslab in memory */ - start[0] = 0; - start[1] = 0; + start[0] = 0; + start[1] = 0; stride[0] = 1; stride[1] = 6; - count[0] = 1; - count[1] = 4; - block[0] = 10; - block[1] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = 4; + block[0] = 10; + block[1] = 2; + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Select hyperslab in file */ @@ -4212,54 +4232,53 @@ test_basic_io(unsigned config, hid_t fapl) count[0] = 10; count[1] = 4; count[2] = 2; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Read data through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR memspace = -1; - /* Close */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR dcpl = -1; @@ -4274,21 +4293,23 @@ test_basic_io(unsigned config, hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) + H5E_BEGIN_TRY + { + for (i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) H5Dclose(srcdset[i]); H5Dclose(vdset); - for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) + for (i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) H5Fclose(srcfile[i]); H5Fclose(vfile); H5Fclose(vfile2); - for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) + for (i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); - for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + for (i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) H5Sclose(vspace[i]); H5Sclose(memspace); H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(srcfilename); HDfree(srcfilename_map); @@ -4297,10 +4318,9 @@ error: HDfree(srcfilenamepct); HDfree(srcfilenamepct_map); - return 1; + return 1; } /* end test_basic_io() */ - /*------------------------------------------------------------------------- * Function: test_unlim * @@ -4313,34 +4333,34 @@ error: static int test_unlim(unsigned config, hid_t fapl) { - char srcfilename[FILENAME_BUF_SIZE]; - char srcfilename_map[FILENAME_BUF_SIZE]; - char vfilename[FILENAME_BUF_SIZE]; - hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ - hid_t vfile = -1; /* File with virtual dset */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t srcdcpl = -1; /* DCPL for source dset */ - hid_t dapl = -1; /* Dataset access property list */ - hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ - hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ - hid_t memspace = -1; /* Memory dataspace */ - hid_t filespace = -1; /* File dataspace */ - hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ - hid_t vdset = -1; /* Virtual dataset */ - hsize_t dims[2] = {10, 10}; /* Data space current size */ - hsize_t mdims[2] = {10, 20}; /* Data space maximum size */ - hsize_t cdims[2] = {4, 4}; /* Chunk dimensions */ - hsize_t start[4]; /* Hyperslab start */ - hsize_t stride[4]; /* Hyperslab stride */ - hsize_t count[4]; /* Hyperslab count */ - hsize_t block[4]; /* Hyperslab block */ - int buf[10][20]; /* Write and expected read buffer */ - int rbuf[10][20]; /* Read buffer */ - int erbuf[10][20]; /* Expected read buffer */ - int ndims; /* Number of dimensions */ - int fill = -1; /* Fill value */ - H5D_vds_view_t virtual_view; /* Virtual view property */ - int i, j; + char srcfilename[FILENAME_BUF_SIZE]; + char srcfilename_map[FILENAME_BUF_SIZE]; + char vfilename[FILENAME_BUF_SIZE]; + hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t srcdcpl = -1; /* DCPL for source dset */ + hid_t dapl = -1; /* Dataset access property list */ + hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ + hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t filespace = -1; /* File dataspace */ + hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[2] = {10, 10}; /* Data space current size */ + hsize_t mdims[2] = {10, 20}; /* Data space maximum size */ + hsize_t cdims[2] = {4, 4}; /* Chunk dimensions */ + hsize_t start[4]; /* Hyperslab start */ + hsize_t stride[4]; /* Hyperslab stride */ + hsize_t count[4]; /* Hyperslab count */ + hsize_t block[4]; /* Hyperslab block */ + int buf[10][20]; /* Write and expected read buffer */ + int rbuf[10][20]; /* Read buffer */ + int erbuf[10][20]; /* Expected read buffer */ + int ndims; /* Number of dimensions */ + int fill = -1; /* Fill value */ + H5D_vds_view_t virtual_view; /* Virtual view property */ + int i, j; TESTING("virtual dataset I/O with unlimited selections") @@ -4349,45 +4369,44 @@ test_unlim(unsigned config, hid_t fapl) h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); /* Create DCPLs */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if((srcdcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((srcdcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) TEST_ERROR /* Set chunk dimensions */ - if(H5Pset_chunk(srcdcpl, 2, cdims) < 0) + if (H5Pset_chunk(srcdcpl, 2, cdims) < 0) TEST_ERROR /* Create DAPL */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR /* Create memory space */ - if((memspace = H5Screate_simple(2, mdims, NULL)) < 0) + if ((memspace = H5Screate_simple(2, mdims, NULL)) < 0) TEST_ERROR - /* * Test 1: 2 Source datasets, single unlimited hyperslab virtual mappings */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace */ - dims[0] = 5; + dims[0] = 5; mdims[0] = 5; - if((srcspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR mdims[0] = 10; @@ -4396,139 +4415,143 @@ test_unlim(unsigned config, hid_t fapl) start[1] = 0; count[0] = 5; count[1] = H5S_UNLIMITED; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[0] = 5; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[0]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write data directly to source datasets */ /* Select hyperslab in memory */ start[0] = 0; count[1] = 10; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write first dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 10; j++) erbuf[i][j] = buf[i][j]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write second dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 10; j++) erbuf[i + 5][j] = buf[i][j]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -4537,75 +4560,74 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Test H5Pget_virtual_view() */ - if(H5Pget_virtual_view(dapl, &virtual_view) < 0) + if (H5Pget_virtual_view(dapl, &virtual_view) < 0) TEST_ERROR - if(virtual_view != H5D_VDS_LAST_AVAILABLE) + if (virtual_view != H5D_VDS_LAST_AVAILABLE) TEST_ERROR /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Test H5Pget_virtual_view() */ - if(H5Pget_virtual_view(dapl, &virtual_view) < 0) + if (H5Pget_virtual_view(dapl, &virtual_view) < 0) TEST_ERROR - if(virtual_view != H5D_VDS_FIRST_MISSING) + if (virtual_view != H5D_VDS_FIRST_MISSING) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -4613,106 +4635,105 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[0] */ dims[0] = 5; dims[1] = 15; - if(H5Dset_extent(srcdset[0], dims) < 0) + if (H5Dset_extent(srcdset[0], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset */ count[1] = 5; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[0])) < 0) + if ((filespace = H5Dget_space(srcdset[0])) < 0) TEST_ERROR start[1] = 10; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Close srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. Note that since we are using * H5D_VDS_FIRST_MISSING and we only extended one source dataset the * dimensions will not have changed. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -4721,69 +4742,68 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Update erbuf to reflect new data that is now visible due to the change to * H5D_VDS_LAST_AVAILABLE */ - for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 5; j++) erbuf[i][j + 10] = buf[i][j]; /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 15) + if (dims[1] != 15) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -4792,113 +4812,112 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[1] */ dims[0] = 5; dims[1] = 20; - if(H5Dset_extent(srcdset[1], dims) < 0) + if (H5Dset_extent(srcdset[1], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset */ count[1] = 10; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[1])) < 0) + if ((filespace = H5Dget_space(srcdset[1])) < 0) TEST_ERROR start[1] = 10; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 10; j++) erbuf[i + 5][j + 10] = buf[i][j]; /* Close srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 20) + if (dims[1] != 20) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -4907,17 +4926,17 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Now just read middle 2 rows */ @@ -4925,35 +4944,34 @@ test_unlim(unsigned config, hid_t fapl) start[0] = 4; count[0] = 2; count[1] = 20; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, memspace, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, memspace, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data - algorithmically check for only 2 middle rows being * read so we don't have to wipe out erbuf and then restore it afterwards */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if((i == 4) || (i == 5)) { - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) + if ((i == 4) || (i == 5)) { + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR } - else - if(rbuf[i][j] != 0) - TEST_ERROR + else if (rbuf[i][j] != 0) + TEST_ERROR /* Now test reopening virtual dataset without calling H5Dget_space, if * REOPEN_VIRT flag set */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -4963,23 +4981,23 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Now try setting extent manually */ /* Shrink to 18 */ dims[1] = 18; - if(H5Dset_extent(vdset, dims) < 0) + if (H5Dset_extent(vdset, dims) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -4989,28 +5007,27 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Shrink to 15 */ dims[1] = 15; - if(H5Dset_extent(vdset, dims) < 0) + if (H5Dset_extent(vdset, dims) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5020,64 +5037,63 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 15) + if (dims[1] != 15) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5087,37 +5103,36 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Now test reopening virtual dataset without calling H5Dget_space, if * REOPEN_VIRT flag set */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5126,29 +5141,28 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Now try setting extent manually */ /* Grow to 18 */ dims[1] = 18; - if(H5Dset_extent(vdset, dims) < 0) + if (H5Dset_extent(vdset, dims) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5158,28 +5172,27 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Grow to 20 */ dims[1] = 20; - if(H5Dset_extent(vdset, dims) < 0) + if (H5Dset_extent(vdset, dims) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5189,73 +5202,72 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR } /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile[0]) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* * Test 2: 2 Source datasets, interleaved slices, single element wide */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ dims[0] = 10; dims[1] = 10; - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace */ - dims[1] = 5; + dims[1] = 5; mdims[1] = 10; - if((srcspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR mdims[1] = 20; @@ -5264,146 +5276,150 @@ test_unlim(unsigned config, hid_t fapl) start[1] = 0; count[0] = 10; count[1] = H5S_UNLIMITED; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ stride[0] = 1; stride[1] = 2; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 1; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 1; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 1; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 0; /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[0]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write data directly to source datasets */ /* Select hyperslab in memory */ count[0] = 10; count[1] = 5; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write first dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][2 * j] = buf[i][j]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write second dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][(2 * j) + 1] = buf[i][j]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5411,63 +5427,62 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5475,111 +5490,110 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[0] */ dims[1] = 7; - if(H5Dset_extent(srcdset[0], dims) < 0) + if (H5Dset_extent(srcdset[0], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset */ count[1] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[0])) < 0) + if ((filespace = H5Dget_space(srcdset[0])) < 0) TEST_ERROR start[1] = 5; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[1] = 0; - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Update erbuf to reflect only new data that is now visible under * H5D_VDS_FIRST_MISSING (first slice) */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][10] = buf[i][0]; /* Close srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. Note that since we are using * H5D_VDS_FIRST_MISSING and we only extended one source dataset the * dimension will only have changed to add one more slice. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 11) + if (dims[1] != 11) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5587,68 +5601,67 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Update erbuf to reflect new data that is now visible due to the change to * H5D_VDS_LAST_AVAILABLE (second new slice) */ - for(i = 0; i < 10; i++) - erbuf[i][12] = buf[i][1]; + for (i = 0; i < 10; i++) + erbuf[i][12] = buf[i][1]; /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 13) + if (dims[1] != 13) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5656,113 +5669,112 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[1] */ dims[1] = 10; - if(H5Dset_extent(srcdset[1], dims) < 0) + if (H5Dset_extent(srcdset[1], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset */ count[1] = 5; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[1])) < 0) + if ((filespace = H5Dget_space(srcdset[1])) < 0) TEST_ERROR start[1] = 5; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[1] = 0; - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][(2 * j) + 11] = buf[i][j]; /* Close srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 20) + if (dims[1] != 20) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5770,17 +5782,17 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Now just read middle 2 rows */ @@ -5788,68 +5800,67 @@ test_unlim(unsigned config, hid_t fapl) start[0] = 4; count[0] = 2; count[1] = 20; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[0] = 0; - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, memspace, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, memspace, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data - algorithmically check for only 2 middle rows being * read so we don't have to wipe out erbuf and then restore it afterwards */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if((i == 4) || (i == 5)) { - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) + if ((i == 4) || (i == 5)) { + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR } - else - if(rbuf[i][j] != 0) - TEST_ERROR + else if (rbuf[i][j] != 0) + TEST_ERROR /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Update erbuf to reflect new data that is no longer visible due to the * change to H5D_VDS_FIRST_MISSING */ - for(i = 0; i < 10; i++) - for(j = 15; j < 20; j += 2) + for (i = 0; i < 10; i++) + for (j = 15; j < 20; j += 2) erbuf[i][j] = fill; /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 14) + if (dims[1] != 14) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -5857,88 +5868,86 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile[0]) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* * Test 3: 3 Source datasets, interleaved slices, two elements wide */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ dims[0] = 10; dims[1] = 10; - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - if((vspace[2] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[2] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspaces */ - dims[1] = 4; + dims[1] = 4; mdims[1] = 8; - if((srcspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - dims[1] = 4; + dims[1] = 4; mdims[1] = 6; - if((srcspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((srcspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - dims[1] = 2; + dims[1] = 2; mdims[1] = 6; - if((srcspace[2] = H5Screate_simple(2, dims, mdims)) < 0) + if ((srcspace[2] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR mdims[1] = 20; @@ -5947,185 +5956,191 @@ test_unlim(unsigned config, hid_t fapl) start[1] = 0; count[0] = 10; count[1] = H5S_UNLIMITED; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Sselect_hyperslab(srcspace[2], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[2], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ stride[0] = 1; stride[1] = 6; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 2; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 2; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 2; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 4; - if(H5Sselect_hyperslab(vspace[2], H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[2], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 0; /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[1]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[1]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[2], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset3", srcspace[2]) < 0) + if (H5Pset_virtual(dcpl, vspace[2], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset3", + srcspace[2]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[1], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[1], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset3", H5T_NATIVE_INT, srcspace[2], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset3", H5T_NATIVE_INT, srcspace[2], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write data directly to source datasets */ /* Select hyperslab in memory */ count[0] = 10; count[1] = 4; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write first dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 2; j++) { - erbuf[i][6 * j] = buf[i][2 * j]; + for (i = 0; i < 10; i++) + for (j = 0; j < 2; j++) { + erbuf[i][6 * j] = buf[i][2 * j]; erbuf[i][(6 * j) + 1] = buf[i][(2 * j) + 1]; } /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write second dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 2; j++) { + for (i = 0; i < 10; i++) + for (j = 0; j < 2; j++) { erbuf[i][(6 * j) + 2] = buf[i][2 * j]; erbuf[i][(6 * j) + 3] = buf[i][(2 * j) + 1]; } /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Select hyperslab in memory */ count[0] = 10; count[1] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write third dataset */ - if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { erbuf[i][4] = buf[i][0]; erbuf[i][5] = buf[i][1]; } /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(srcdset[2]) < 0) + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -6133,63 +6148,62 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -6197,105 +6211,104 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[0] */ dims[1] = 7; - if(H5Dset_extent(srcdset[0], dims) < 0) + if (H5Dset_extent(srcdset[0], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset */ count[1] = 3; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[0])) < 0) + if ((filespace = H5Dget_space(srcdset[0])) < 0) TEST_ERROR start[1] = 4; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[1] = 0; - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Close srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. Note that since we are using * H5D_VDS_FIRST_MISSING the size will not have changed. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -6303,71 +6316,70 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Update erbuf to reflect new data that is now visible due to the change to * H5D_VDS_LAST_AVAILABLE */ - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { erbuf[i][12] = buf[i][0]; erbuf[i][13] = buf[i][1]; erbuf[i][18] = buf[i][2]; } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 19) + if (dims[1] != 19) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -6375,116 +6387,115 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[2] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[2] = H5Dopen2(srcfile[0], "src_dset3", H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dopen2(srcfile[0], "src_dset3", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[2] */ dims[1] = 5; - if(H5Dset_extent(srcdset[2], dims) < 0) + if (H5Dset_extent(srcdset[2], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset */ count[1] = 3; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[2])) < 0) + if ((filespace = H5Dget_space(srcdset[2])) < 0) TEST_ERROR start[1] = 2; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[1] = 0; - if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { erbuf[i][10] = buf[i][0]; erbuf[i][11] = buf[i][1]; erbuf[i][16] = buf[i][2]; } /* Close srcdset[2] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[2]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. Note that the dimensions will not have * changed. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 19) + if (dims[1] != 19) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -6492,63 +6503,62 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 14) + if (dims[1] != 14) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -6556,114 +6566,113 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[1] */ dims[1] = 6; - if(H5Dset_extent(srcdset[1], dims) < 0) + if (H5Dset_extent(srcdset[1], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset */ count[1] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[1])) < 0) + if ((filespace = H5Dget_space(srcdset[1])) < 0) TEST_ERROR start[1] = 4; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[1] = 0; - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { erbuf[i][14] = buf[i][0]; erbuf[i][15] = buf[i][1]; } /* Close srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 17) + if (dims[1] != 17) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -6671,59 +6680,58 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 19) + if (dims[1] != 19) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Read data through virtual dataset */ @@ -6731,23 +6739,22 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Now just read middle 2 rows */ @@ -6755,98 +6762,96 @@ test_unlim(unsigned config, hid_t fapl) start[0] = 4; count[0] = 2; count[1] = 19; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[0] = 0; - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Verify read data - algorithmically check for only 2 middle rows being * read */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else if((i == 4) || (i == 5)) { - if(rbuf[i][j] != erbuf[i][j]) + else if ((i == 4) || (i == 5)) { + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR } - else - if(rbuf[i][j] != 0) - TEST_ERROR + else if (rbuf[i][j] != 0) + TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(srcdset[2]) < 0) + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile[0]) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(srcspace[1]) < 0) + if (H5Sclose(srcspace[1]) < 0) TEST_ERROR srcspace[1] = -1; - if(H5Sclose(srcspace[2]) < 0) + if (H5Sclose(srcspace[2]) < 0) TEST_ERROR srcspace[2] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* * Test 4: 2 Source datasets, offset starts */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspaces */ - dims[0] = 5; - dims[1] = 0; + dims[0] = 5; + dims[1] = 0; mdims[0] = 5; - if((srcspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR dims[1] = 5; - if((srcspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((srcspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR mdims[0] = 10; @@ -6855,59 +6860,63 @@ test_unlim(unsigned config, hid_t fapl) start[1] = 0; count[0] = 5; count[1] = H5S_UNLIMITED; - if(H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ start[1] = 10; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR start[0] = 5; start[1] = 0; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", + srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[1]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", + srcspace[1]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[1], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[1], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write data directly to second source dataset */ @@ -6916,70 +6925,70 @@ test_unlim(unsigned config, hid_t fapl) start[1] = 0; count[0] = 5; count[1] = 5; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Write second dataset */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 5; j++) erbuf[i + 5][j] = buf[i][j]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 5) + if (dims[1] != 5) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -6989,63 +6998,62 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 5) + if (dims[1] != 5) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -7053,39 +7061,38 @@ test_unlim(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[0] */ dims[0] = 5; dims[1] = 5; - if(H5Dset_extent(srcdset[0], dims) < 0) + if (H5Dset_extent(srcdset[0], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[0] */ @@ -7093,65 +7100,65 @@ test_unlim(unsigned config, hid_t fapl) start[1] = 0; count[0] = 5; count[1] = 5; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 5; j++) erbuf[i][j + 10] = buf[i][j]; /* Close srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 5) + if (dims[1] != 5) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -7161,63 +7168,62 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 15) + if (dims[1] != 15) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -7227,73 +7233,71 @@ test_unlim(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile[0]) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(srcspace[1]) < 0) + if (H5Sclose(srcspace[1]) < 0) TEST_ERROR srcspace[1] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* Close */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR dcpl = -1; - if(H5Pclose(srcdcpl) < 0) + if (H5Pclose(srcdcpl) < 0) TEST_ERROR dcpl = -1; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) TEST_ERROR dapl = -1; - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR memspace = -1; @@ -7301,28 +7305,29 @@ test_unlim(unsigned config, hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) + H5E_BEGIN_TRY + { + for (i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) H5Dclose(srcdset[i]); H5Dclose(vdset); - for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) + for (i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) H5Fclose(srcfile[i]); H5Fclose(vfile); - for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) + for (i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); - for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + for (i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) H5Sclose(vspace[i]); H5Sclose(filespace); H5Sclose(memspace); H5Pclose(dcpl); H5Pclose(srcdcpl); H5Pclose(dapl); - } H5E_END_TRY; + } + H5E_END_TRY; - return 1; + return 1; } /* end test_unlim() */ - /*------------------------------------------------------------------------- * Function: test_printf * @@ -7336,57 +7341,57 @@ error: static int test_printf(unsigned config, hid_t fapl) { - char *srcfilename = NULL; - char *srcfilename_map = NULL; - char *srcfilename2 = NULL; - char *srcfilename2_map = NULL; - char *vfilename = NULL; - char *printf_srcfilename_map = NULL; - char *srcfilenamepct = NULL; - char *srcfilenamepct_map = NULL; + char * srcfilename = NULL; + char * srcfilename_map = NULL; + char * srcfilename2 = NULL; + char * srcfilename2_map = NULL; + char * vfilename = NULL; + char * printf_srcfilename_map = NULL; + char * srcfilenamepct = NULL; + char * srcfilenamepct_map = NULL; const char *printf_srcfilename_map_orig = "vds_src_%b"; - const char *srcfilenamepct_map_orig = "vds%%%%_src"; - hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ - hid_t vfile = -1; /* File with virtual dset */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t dapl = -1; /* Dataset access property list */ - hid_t srcspace = -1; /* Source dataspace */ - hid_t vspace[2] = {-1, -1}; /* Virtual dset dataspaces */ - hid_t memspace = -1; /* Memory dataspace */ - hid_t filespace = -1; /* File dataspace */ - hid_t srcdset[6] = {-1, -1, -1, -1, -1, -1}; /* Source datsets */ - hid_t vdset = -1; /* Virtual dataset */ - hsize_t dims[2] = {10, 0}; /* Data space current size */ - hsize_t mdims[2] = {10, 20}; /* Data space maximum size */ - hsize_t start[2] = {0, 0}; /* Hyperslab start */ - hsize_t stride[2]; /* Hyperslab stride */ - hsize_t count[2]; /* Hyperslab count */ - hsize_t block[2]; /* Hyperslab block */ - int buf[10][20]; /* Write and expected read buffer */ - int rbuf[10][20]; /* Read buffer */ - int erbuf[10][20]; /* Expected read buffer */ - int ndims; /* Number of dimensions */ - int fill = -1; /* Fill value */ - hsize_t gap_size; /* Gap size property */ + const char *srcfilenamepct_map_orig = "vds%%%%_src"; + hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t dapl = -1; /* Dataset access property list */ + hid_t srcspace = -1; /* Source dataspace */ + hid_t vspace[2] = {-1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t filespace = -1; /* File dataspace */ + hid_t srcdset[6] = {-1, -1, -1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[2] = {10, 0}; /* Data space current size */ + hsize_t mdims[2] = {10, 20}; /* Data space maximum size */ + hsize_t start[2] = {0, 0}; /* Hyperslab start */ + hsize_t stride[2]; /* Hyperslab stride */ + hsize_t count[2]; /* Hyperslab count */ + hsize_t block[2]; /* Hyperslab block */ + int buf[10][20]; /* Write and expected read buffer */ + int rbuf[10][20]; /* Read buffer */ + int erbuf[10][20]; /* Expected read buffer */ + int ndims; /* Number of dimensions */ + int fill = -1; /* Fill value */ + hsize_t gap_size; /* Gap size property */ int i, j; TESTING("virtual dataset I/O with printf source") - if((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilename2 = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilename2 = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilename2_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilename2_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((printf_srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((printf_srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; - if((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + if ((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) TEST_ERROR; h5_fixname(FILENAME[0], fapl, vfilename, FILENAME_BUF_SIZE); @@ -7399,216 +7404,218 @@ test_printf(unsigned config, hid_t fapl) h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, FILENAME_BUF_SIZE); /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) TEST_ERROR /* Create DAPL */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR /* Create memory space */ - if((memspace = H5Screate_simple(2, mdims, NULL)) < 0) + if ((memspace = H5Screate_simple(2, mdims, NULL)) < 0) TEST_ERROR - /* * Test 1: 1 Source dataset mapping, 10x5 blocks */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 5; - if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select hyperslabs in virtual space */ stride[0] = 1; stride[1] = 5; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 5; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 5; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset%b", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset%b", + srcspace) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Close srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 0) + if (dims[1] != 0) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Reopen srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 2 source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write to srcdset[0] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][j] = buf[i][j]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[1] */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][j + 5] = buf[i][j]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -7616,95 +7623,95 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile if config option specified */ - if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 3rd source dataset */ - if((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[2] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][j + 10] = buf[i][j]; /* Close srcdset[2] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[2]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 15) + if (dims[1] != 15) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Read data through virtual dataset */ @@ -7712,407 +7719,411 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Now try with different selections */ count[0] = 10; - for(start[1] = (hsize_t)0; start[1] < (hsize_t)5; start[1]++) - for(count[1] = (hsize_t)1; count[1] < (hsize_t)11; count[1]++) { + for (start[1] = (hsize_t)0; start[1] < (hsize_t)5; start[1]++) + for (count[1] = (hsize_t)1; count[1] < (hsize_t)11; count[1]++) { /* Reset rbuf */ HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslab in file space */ - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if((j < (int)start[1]) || (j >= (int)(start[1] + count[1]))) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if ((j < (int)start[1]) || (j >= (int)(start[1] + count[1]))) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } } start[1] = 0; /* Now try writing through VDS */ /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Select hyperslab in file space */ - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write data through VDS */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Reopen srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset0", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset0", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[2] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read srcdset[0] */ count[0] = 10; count[1] = 5; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Dread(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Read srcdset[1] */ - if(H5Dread(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) - if(rbuf[i][j] != buf[i][j + 5]) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) + if (rbuf[i][j] != buf[i][j + 5]) TEST_ERROR /* Read srcdset[2] */ - if(H5Dread(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) - if(rbuf[i][j] != buf[i][j + 10]) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) + if (rbuf[i][j] != buf[i][j + 10]) TEST_ERROR /* Close */ - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Dclose(srcdset[2]) < 0) + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace) < 0) + if (H5Sclose(srcspace) < 0) TEST_ERROR srcspace = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - /* * Test 2: 1 Source dataset mapping, 10x1 blocks, test printf gap setting, * '%' in source file name */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 1; - if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select hyperslabs in virtual space */ stride[0] = 1; stride[1] = 1; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 1; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 1; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_map : ".", "src_dset%b", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_map : ".", + "src_dset%b", srcspace) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilenamepct, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilenamepct, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Close srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 0) + if (dims[1] != 0) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Reopen srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilenamepct, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilenamepct, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create source datasets in a pattern with increasing gaps: * XX-X--X---X----X */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset3", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset3", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[3] = H5Dcreate2(srcfile[0], "src_dset6", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[3] = H5Dcreate2(srcfile[0], "src_dset6", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[4] = H5Dcreate2(srcfile[0], "src_dset10", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[4] = H5Dcreate2(srcfile[0], "src_dset10", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[5] = H5Dcreate2(srcfile[0], "src_dset15", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[5] = H5Dcreate2(srcfile[0], "src_dset15", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write to srcdset[0] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][0] = buf[i][0]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[1] */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][1] = buf[i][0]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[2] */ - if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][3] = buf[i][0]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[3] */ - if(H5Dwrite(srcdset[3], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[3], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][6] = buf[i][0]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[4] */ - if(H5Dwrite(srcdset[4], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[4], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][10] = buf[i][0]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[5] */ - if(H5Dwrite(srcdset[5], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[5], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][15] = buf[i][0]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - for(i = 0; i < 6; i++) { - if(H5Dclose(srcdset[i]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + for (i = 0; i < 6; i++) { + if (H5Dclose(srcdset[i]) < 0) TEST_ERROR srcdset[i] = -1; } - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 2) + if (dims[1] != 2) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -8120,75 +8131,74 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Test H5Pget_virtual_printf_gap() */ - if(H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) + if (H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) TEST_ERROR - if(gap_size != (hsize_t)0) + if (gap_size != (hsize_t)0) TEST_ERROR /* Close VDS and reopen with printf gap set to 1, reopen file as well if * config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)1) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)1) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Test H5Pget_virtual_printf_gap() */ - if(H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) + if (H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) TEST_ERROR - if(gap_size != (hsize_t)1) + if (gap_size != (hsize_t)1) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 4) + if (dims[1] != 4) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -8196,69 +8206,68 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with printf gap set to 2, reopen file as well if * config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)2) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)2) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Test H5Pget_virtual_printf_gap() */ - if(H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) + if (H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) TEST_ERROR - if(gap_size != (hsize_t)2) + if (gap_size != (hsize_t)2) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 7) + if (dims[1] != 7) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -8266,69 +8275,68 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with printf gap set to 3, reopen file as well if * config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)3) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)3) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Test H5Pget_virtual_printf_gap() */ - if(H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) + if (H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) TEST_ERROR - if(gap_size != (hsize_t)3) + if (gap_size != (hsize_t)3) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 11) + if (dims[1] != 11) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -8336,69 +8344,68 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with printf gap set to 4, reopen file as well if * config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)4) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)4) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Test H5Pget_virtual_printf_gap() */ - if(H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) + if (H5Pget_virtual_printf_gap(dapl, &gap_size) < 0) TEST_ERROR - if(gap_size != (hsize_t)4) + if (gap_size != (hsize_t)4) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 16) + if (dims[1] != 16) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -8406,63 +8413,62 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 2) + if (dims[1] != 2) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -8470,223 +8476,222 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reset dapl */ - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)0) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)0) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - for(i = 0; i < 6; i++) { - if(H5Dclose(srcdset[i]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + for (i = 0; i < 6; i++) { + if (H5Dclose(srcdset[i]) < 0) TEST_ERROR srcdset[i] = -1; } - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile[0]) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace) < 0) + if (H5Sclose(srcspace) < 0) TEST_ERROR srcspace = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - /* Next 2 tests are always run with a different source file, so only run if * that config option is set (so they're not run twice with the same * configuration) */ - if(config & TEST_IO_DIFFERENT_FILE) { + if (config & TEST_IO_DIFFERENT_FILE) { /* * Test 3: 1 Source dataset mapping, 10x5 blocks, printf source file */ /* Clean up files so the source files do not exist yet */ - H5Iinc_ref(fapl); /* Prevent FAPL from being closed */ + H5Iinc_ref(fapl); /* Prevent FAPL from being closed */ h5_clean_files(FILENAME, fapl); /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 5; - if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select hyperslabs in virtual space */ stride[0] = 1; stride[1] = 5; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 5; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 5; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], printf_srcfilename_map, "src_dset", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[0], printf_srcfilename_map, "src_dset", srcspace) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 0) + if (dims[1] != 0) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Create 2 source files, one source dataset */ - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcfile[1] = H5Fcreate(srcfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((srcfile[1] = H5Fcreate(srcfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write to srcdset[0] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][j] = buf[i][j]; /* Close srcdset and srcfiles if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(srcfile[1]) < 0) + if (H5Fclose(srcfile[1]) < 0) TEST_ERROR srcfile[1] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 5) + if (dims[1] != 5) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -8694,96 +8699,96 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile[1] if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if((srcfile[1] = H5Fopen(srcfilename2, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) + if ((srcfile[1] = H5Fopen(srcfilename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 2nd source dataset */ - if((srcdset[1] = H5Dcreate2(srcfile[1], "src_dset", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[1], "src_dset", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[1] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][j + 5] = buf[i][j]; /* Close srcdset[1] and srcfile[1] if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[1]) < 0) + if (H5Fclose(srcfile[1]) < 0) TEST_ERROR srcfile[1] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -8791,213 +8796,212 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(srcfile[1]) < 0) + if (H5Fclose(srcfile[1]) < 0) TEST_ERROR srcfile[1] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace) < 0) + if (H5Sclose(srcspace) < 0) TEST_ERROR srcspace = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - /* * Test 4: 1 Source dataset mapping, 10x5 blocks, printf source file and * source dset, extra %%s in source dataset name */ /* Clean up files so the source files do not exist yet */ - H5Iinc_ref(fapl); /* Prevent FAPL from being closed */ + H5Iinc_ref(fapl); /* Prevent FAPL from being closed */ h5_clean_files(FILENAME, fapl); /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 5; - if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select hyperslabs in virtual space */ stride[0] = 1; stride[1] = 5; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 5; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 5; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], printf_srcfilename_map, "%%src%%_dset%%%b", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[0], printf_srcfilename_map, "%%src%%_dset%%%b", srcspace) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 0) + if (dims[1] != 0) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Create 2 source files, one source dataset */ - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if((srcdset[0] = H5Dcreate2(srcfile[0], "%src%_dset%0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "%src%_dset%0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcfile[1] = H5Fcreate(srcfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((srcfile[1] = H5Fcreate(srcfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write to srcdset[0] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][j] = buf[i][j]; /* Close srcdset and srcfiles if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(srcfile[1]) < 0) + if (H5Fclose(srcfile[1]) < 0) TEST_ERROR srcfile[1] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 5) + if (dims[1] != 5) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -9005,96 +9009,96 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile[1] if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if((srcfile[1] = H5Fopen(srcfilename2, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) + if ((srcfile[1] = H5Fopen(srcfilename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 2nd source dataset */ - if((srcdset[1] = H5Dcreate2(srcfile[1], "%src%_dset%1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[1], "%src%_dset%1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[1] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 5; j++) erbuf[i][j + 5] = buf[i][j]; /* Close srcdset[1] and srcfile[1] if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[1]) < 0) + if (H5Fclose(srcfile[1]) < 0) TEST_ERROR srcfile[1] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -9102,266 +9106,268 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(srcfile[1]) < 0) + if (H5Fclose(srcfile[1]) < 0) TEST_ERROR srcfile[1] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace) < 0) + if (H5Sclose(srcspace) < 0) TEST_ERROR srcspace = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; } - /* * Test 5: 2 Source mappings, interleaved slices, single element wide, * hyperslab selection in source, extra %%s in source dataset names */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ dims[0] = 10; dims[1] = 10; - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace (2 elements wide) */ dims[1] = 2; - if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select hyperslab in source space */ count[0] = 10; count[1] = 1; - if(H5Sselect_hyperslab(srcspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ stride[0] = 1; stride[1] = 2; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 1; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 1; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 1; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[1] = 0; /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "%bsrc_dset_a%b%%", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "%bsrc_dset_a%b%%", srcspace) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset_b%b%%%%", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "src_dset_b%b%%%%", srcspace) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Close srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 0) + if (dims[1] != 0) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Reopen srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 2 source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "0src_dset_a0%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "0src_dset_a0%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset_b0%%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset_b0%%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write to srcdset[0] */ block[0] = 10; block[1] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][0] = buf[i][0]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[1] */ - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][1] = buf[i][0]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 2) + if (dims[1] != 2) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -9369,98 +9375,98 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile if config option specified */ - if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 3rd source dataset */ - if((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset_b1%%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset_b1%%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[2] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][3] = buf[i][0]; /* Close srcdset[2] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[2]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 4) + if (dims[1] != 4) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -9468,64 +9474,63 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. Make sure that the 4th slice is no longer * visible due to the change to H5D_VDS_FIRST_MISSING. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 2) + if (dims[1] != 2) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -9533,98 +9538,98 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile if config option specified */ - if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 4th source dataset */ - if((srcdset[3] = H5Dcreate2(srcfile[0], "2src_dset_a2%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[3] = H5Dcreate2(srcfile[0], "2src_dset_a2%", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[3] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[3], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[3], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][4] = buf[i][0]; /* Close srcdset[3] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[3]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[3]) < 0) TEST_ERROR srcdset[3] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 2) + if (dims[1] != 2) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -9632,64 +9637,63 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. Make sure that the 4th slice is now visible * due to the change to H5D_VDS_LAST_AVAILABLE. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 4) + if (dims[1] != 4) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -9697,64 +9701,63 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with printf_gap set to 1, reopen file as well if * config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)1) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)1) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. Make sure that the 6th slice is now visible * due to the change to printf_gap. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 5) + if (dims[1] != 5) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -9762,288 +9765,290 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reset dapl */ - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)0) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)0) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - for(i = 0; i < 4; i++) { - if(H5Dclose(srcdset[i]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + for (i = 0; i < 4; i++) { + if (H5Dclose(srcdset[i]) < 0) TEST_ERROR srcdset[i] = -1; } - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile[0]) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace) < 0) + if (H5Sclose(srcspace) < 0) TEST_ERROR srcspace = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* * Test 6: 2 Source mappings, side-by-side, 5x5 and 5x10 blocks */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ dims[0] = 10; dims[1] = 10; - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - if((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace (1 dimensional) */ dims[0] = 50; - if((srcspace = H5Screate_simple(1, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR /* Select hyperslab in source space */ count[0] = 25; - if(H5Sselect_hyperslab(srcspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR /* Select hyperslabs in virtual spaces */ stride[0] = 1; stride[1] = 5; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 5; - block[1] = 5; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 5; + block[1] = 5; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR - start[0] = 5; + start[0] = 5; stride[1] = 10; - block[1] = 10; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) + block[1] = 10; + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR start[0] = 0; /* Add virtual layout mappings (select ALL in source space for second * mapping) */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset_a%b", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "src_dset_a%b", srcspace) < 0) TEST_ERROR - if(H5Sselect_all(srcspace) < 0) + if (H5Sselect_all(srcspace) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset_b%b", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "src_dset_b%b", srcspace) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Close srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 0) + if (dims[1] != 0) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Reopen srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 2 source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset_a0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset_a0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset_b0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset_b0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write to srcdset[0] */ block[0] = 5; block[1] = 5; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR count[0] = 25; - if(H5Sselect_hyperslab(srcspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, srcspace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, srcspace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 5; j++) erbuf[i][j] = buf[i][j]; /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[1] */ block[1] = 10; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Sselect_all(srcspace) < 0) + if (H5Sselect_all(srcspace) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, srcspace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, srcspace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 10; j++) erbuf[i + 5][j] = buf[i][j]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Dclose(srcdset[1]) < 0) + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10051,64 +10056,63 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. Make sure that the 4th slice is no longer * visible due to the change to H5D_VDS_FIRST_MISSING. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 5) + if (dims[1] != 5) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10116,102 +10120,102 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile if config option specified */ - if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 3rd source dataset */ - if((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset_a1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset_a1", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[2] */ block[1] = 5; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Sselect_hyperslab(srcspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(srcspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, srcspace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, srcspace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 5; j++) erbuf[i][j + 5] = buf[i][j]; /* Close srcdset[2] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[2]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10219,63 +10223,62 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with view set to H5D_VDS_LAST_AVAILABLE, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions. There should be no change. */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10283,99 +10286,99 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile if config option specified */ - if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 4th source dataset */ - if((srcdset[3] = H5Dcreate2(srcfile[0], "src_dset_a2", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[3] = H5Dcreate2(srcfile[0], "src_dset_a2", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[3] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[3], H5T_NATIVE_INT, memspace, srcspace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[3], H5T_NATIVE_INT, memspace, srcspace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 5; i++) + for (j = 0; j < 5; j++) erbuf[i][j + 10] = buf[i][j]; /* Close srcdset[3] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[3]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[3]) < 0) TEST_ERROR srcdset[3] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 15) + if (dims[1] != 15) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10383,37 +10386,36 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Now test reopening virtual dataset without calling H5Dget_space, if * REOPEN_VIRT flag set */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10421,29 +10423,28 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Now try setting extent manually */ /* Shrink to 12 */ dims[1] = 12; - if(H5Dset_extent(vdset, dims) < 0) + if (H5Dset_extent(vdset, dims) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10451,28 +10452,27 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Shrink to 10 */ dims[1] = 12; - if(H5Dset_extent(vdset, dims) < 0) + if (H5Dset_extent(vdset, dims) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10480,64 +10480,63 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } } /* Close VDS and reopen with view set to H5D_VDS_FIRST_MISSING, reopen file * as well if config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_FIRST_MISSING) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10545,37 +10544,36 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Now test reopening virtual dataset without calling H5Dget_space, if * REOPEN_VIRT flag set */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10583,29 +10581,28 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Now try setting extent manually */ /* Grow to 12 */ dims[1] = 12; - if(H5Dset_extent(vdset, dims) < 0) + if (H5Dset_extent(vdset, dims) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10613,28 +10610,27 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Grow to 15 */ dims[1] = 15; - if(H5Dset_extent(vdset, dims) < 0) + if (H5Dset_extent(vdset, dims) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10642,238 +10638,238 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } } /* Reset dapl */ - if(H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl, H5D_VDS_LAST_AVAILABLE) < 0) TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - for(i = 0; i < 4; i++) { - if(H5Dclose(srcdset[i]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + for (i = 0; i < 4; i++) { + if (H5Dclose(srcdset[i]) < 0) TEST_ERROR srcdset[i] = -1; } - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile[0]) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace) < 0) + if (H5Sclose(srcspace) < 0) TEST_ERROR srcspace = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Sclose(vspace[1]) < 0) + if (H5Sclose(vspace[1]) < 0) TEST_ERROR vspace[1] = -1; - /* * Test 7: 1 Source dataset mapping, 10x1 blocks, test reallocating sub_dset * array */ /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create virtual dataspaces */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR /* Create source dataspace */ dims[1] = 1; - if((srcspace = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select hyperslabs in virtual space */ stride[0] = 1; stride[1] = 1; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 10; - block[1] = 1; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 10; + block[1] = 1; + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_map : ".", "src_dset%b", srcspace) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_map : ".", + "src_dset%b", srcspace) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilenamepct, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile[0] = H5Fcreate(srcfilenamepct, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Close srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 0) + if (dims[1] != 0) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Reopen srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilenamepct, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile[0] = H5Fopen(srcfilenamepct, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create 1 source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset0", H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write to srcdset[0] */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) erbuf[i][0] = buf[i][0]; /* Close srcdset[0] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 1) + if (dims[1] != 1) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10881,63 +10877,62 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Close VDS and reopen with printf gap set to 127, reopen file as well if * config option specified */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)127) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)127) < 0) TEST_ERROR - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Fclose(vfile) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR } - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 1) + if (dims[1] != 1) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 20) + if (mdims[1] != 20) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -10945,65 +10940,63 @@ test_printf(unsigned config, hid_t fapl) HDmemset(rbuf[0], 0, sizeof(rbuf)); /* Select hyperslab in memory space */ - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reset dapl */ - if(H5Pset_virtual_printf_gap(dapl, (hsize_t)0) < 0) + if (H5Pset_virtual_printf_gap(dapl, (hsize_t)0) < 0) TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - if(H5Dclose(srcdset[0]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile[0]) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace) < 0) + if (H5Sclose(srcspace) < 0) TEST_ERROR srcspace = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - /* Close */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR dcpl = -1; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) TEST_ERROR dapl = -1; - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR memspace = -1; @@ -11020,21 +11013,23 @@ test_printf(unsigned config, hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) + H5E_BEGIN_TRY + { + for (i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) H5Dclose(srcdset[i]); H5Dclose(vdset); - for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) + for (i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) H5Fclose(srcfile[i]); H5Fclose(vfile); H5Sclose(srcspace); - for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + for (i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) H5Sclose(vspace[i]); H5Sclose(filespace); H5Sclose(memspace); H5Pclose(dcpl); H5Pclose(dapl); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(srcfilename); HDfree(srcfilename_map); @@ -11045,10 +11040,9 @@ error: HDfree(srcfilenamepct); HDfree(srcfilenamepct_map); - return 1; + return 1; } /* end test_printf() */ - /*------------------------------------------------------------------------- * Function: test_all * @@ -11062,32 +11056,32 @@ error: static int test_all(unsigned config, hid_t fapl) { - char vfilename[FILENAME_BUF_SIZE]; - char srcfilename[FILENAME_BUF_SIZE]; - char srcfilename_map[FILENAME_BUF_SIZE]; - hid_t srcfile = -1; /* File with source dsets */ - hid_t vfile = -1; /* File with virtual dset */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t srcdcpl = -1; /* DCPL for source dset */ - hid_t srcspace[3] = {-1, -1, -1}; /* Source dataspaces */ - hid_t vspace[3] = {-1, -1, -1}; /* Virtual dset dataspaces */ - hid_t memspace = -1; /* Memory dataspace */ - hid_t filespace = -1; /* File dataspace */ - hid_t srcdset[5] = {-1, -1, -1, -1, -1}; /* Source datsets */ - hid_t vdset = -1; /* Virtual dataset */ - hsize_t dims[2] = {6, 6}; /* Data space current size */ - hsize_t mdims[2] = {10, 10}; /* Data space maximum size */ - hsize_t cdims[2] = {2, 2}; /* Chunk dimensions */ - hsize_t start[2]; /* Hyperslab start */ - hsize_t stride[2]; /* Hyperslab stride */ - hsize_t count[2]; /* Hyperslab count */ - hsize_t block[2]; /* Hyperslab block */ - int buf[10][10]; /* Write and expected read buffer */ - int rbuf[10][10]; /* Read buffer */ - int erbuf[10][10]; /* Expected read buffer */ - int ndims; /* Number of dimensions */ - int fill = -1; /* Fill value */ - int i, j; + char vfilename[FILENAME_BUF_SIZE]; + char srcfilename[FILENAME_BUF_SIZE]; + char srcfilename_map[FILENAME_BUF_SIZE]; + hid_t srcfile = -1; /* File with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t srcdcpl = -1; /* DCPL for source dset */ + hid_t srcspace[3] = {-1, -1, -1}; /* Source dataspaces */ + hid_t vspace[3] = {-1, -1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t filespace = -1; /* File dataspace */ + hid_t srcdset[5] = {-1, -1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[2] = {6, 6}; /* Data space current size */ + hsize_t mdims[2] = {10, 10}; /* Data space maximum size */ + hsize_t cdims[2] = {2, 2}; /* Chunk dimensions */ + hsize_t start[2]; /* Hyperslab start */ + hsize_t stride[2]; /* Hyperslab stride */ + hsize_t count[2]; /* Hyperslab count */ + hsize_t block[2]; /* Hyperslab block */ + int buf[10][10]; /* Write and expected read buffer */ + int rbuf[10][10]; /* Read buffer */ + int erbuf[10][10]; /* Expected read buffer */ + int ndims; /* Number of dimensions */ + int fill = -1; /* Fill value */ + int i, j; TESTING("virtual dataset I/O with mixed selection types") @@ -11096,43 +11090,44 @@ test_all(unsigned config, hid_t fapl) h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); /* Create DCPLs */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if((srcdcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((srcdcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) TEST_ERROR /* Set chunk dimensions */ - if(H5Pset_chunk(srcdcpl, 2, cdims) < 0) + if (H5Pset_chunk(srcdcpl, 2, cdims) < 0) TEST_ERROR /* Create memory space */ - if((memspace = H5Screate_simple(2, mdims, NULL)) < 0) + if ((memspace = H5Screate_simple(2, mdims, NULL)) < 0) TEST_ERROR /* Clear virtual layout in DCPL */ - if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + if (H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) TEST_ERROR /* Create fixed mapping */ - if((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR start[0] = 3; start[1] = 3; count[0] = 3; count[1] = 3; - if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0) TEST_ERROR - if((srcspace[0] = H5Screate_simple(2, count, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, count, NULL)) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset_fixed", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "src_dset_fixed", srcspace[0]) < 0) TEST_ERROR /* Create unlimited mapping */ - if((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[1] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR start[0] = 3; start[1] = 0; @@ -11140,123 +11135,127 @@ test_all(unsigned config, hid_t fapl) count[1] = 1; block[0] = H5S_UNLIMITED; block[1] = 3; - if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, block) < 0) + if (H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, count, block) < 0) TEST_ERROR dims[0] = 0; dims[1] = 3; - if((srcspace[1] = H5Screate_simple(2, dims, block)) < 0) + if ((srcspace[1] = H5Screate_simple(2, dims, block)) < 0) TEST_ERROR start[0] = 0; - if(H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(srcspace[1], H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset_unlim", srcspace[1]) < 0) + if (H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "src_dset_unlim", srcspace[1]) < 0) TEST_ERROR /* Create printf mapping */ - if((vspace[2] = H5Screate_simple(2, dims, mdims)) < 0) + if ((vspace[2] = H5Screate_simple(2, dims, mdims)) < 0) TEST_ERROR - start[0] = 0; - start[1] = 2; + start[0] = 0; + start[1] = 2; stride[0] = 1; stride[1] = 3; - count[0] = 1; - count[1] = H5S_UNLIMITED; - block[0] = 3; - block[1] = 2; - if(H5Sselect_hyperslab(vspace[2], H5S_SELECT_SET, start, stride, count, block) < 0) + count[0] = 1; + count[1] = H5S_UNLIMITED; + block[0] = 3; + block[1] = 2; + if (H5Sselect_hyperslab(vspace[2], H5S_SELECT_SET, start, stride, count, block) < 0) TEST_ERROR - if((srcspace[2] = H5Screate_simple(2, block, NULL)) < 0) + if ((srcspace[2] = H5Screate_simple(2, block, NULL)) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[2], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset_printf_%b", srcspace[2]) < 0) + if (H5Pset_virtual(dcpl, vspace[2], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", + "src_dset_printf_%b", srcspace[2]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if ((srcfile = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } else { srcfile = vfile; - if(H5Iinc_ref(srcfile) < 0) + if (H5Iinc_ref(srcfile) < 0) TEST_ERROR } /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Close srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 6) + if (dims[0] != 6) TEST_ERROR - if(dims[1] != 6) + if (dims[1] != 6) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 10) + if (mdims[1] != 10) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Reopen srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create fixed source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile, "src_dset_fixed", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile, "src_dset_fixed", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR /* Create unlimited source_dataset */ - if((srcdset[1] = H5Dcreate2(srcfile, "src_dset_unlim", H5T_NATIVE_INT, srcspace[1], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dcreate2(srcfile, "src_dset_unlim", H5T_NATIVE_INT, srcspace[1], H5P_DEFAULT, srcdcpl, + H5P_DEFAULT)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] = (i * (int)mdims[1]) + j; /* Initialize erbuf */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) erbuf[i][j] = fill; /* Write to srcdset[0] */ @@ -11264,67 +11263,67 @@ test_all(unsigned config, hid_t fapl) start[1] = 0; block[0] = 3; block[1] = 3; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 3; i++) - for(j = 0; j < 3; j++) + for (i = 0; i < 3; i++) + for (j = 0; j < 3; j++) erbuf[i + 3][j + 3] = buf[i][j]; /* Close srcdsets and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - for(i = 0; i < 2; i++) { - if(H5Dclose(srcdset[i]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + for (i = 0; i < 2; i++) { + if (H5Dclose(srcdset[i]) < 0) TEST_ERROR srcdset[i] = -1; } - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 6) + if (dims[0] != 6) TEST_ERROR - if(dims[1] != 6) + if (dims[1] != 6) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 10) + if (mdims[1] != 10) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -11334,106 +11333,105 @@ test_all(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if((i >= (int)dims[0]) || (j >= (int)dims[1])) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if ((i >= (int)dims[0]) || (j >= (int)dims[1])) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile, "src_dset_unlim", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile, "src_dset_unlim", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[1] */ dims[0] = 2; dims[1] = 3; - if(H5Dset_extent(srcdset[1], dims) < 0) + if (H5Dset_extent(srcdset[1], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[1] */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 2; i++) - for(j = 0; j < 3; j++) + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) erbuf[i + 3][j] = buf[i][j]; /* Close srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 6) + if (dims[0] != 6) TEST_ERROR - if(dims[1] != 6) + if (dims[1] != 6) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 10) + if (mdims[1] != 10) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -11443,37 +11441,37 @@ test_all(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if((i >= (int)dims[0]) || (j >= (int)dims[1])) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if ((i >= (int)dims[0]) || (j >= (int)dims[1])) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile if config option specified */ - if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) - if((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) + if ((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create first printf source dataset */ - if((srcdset[2] = H5Dcreate2(srcfile, "src_dset_printf_0", H5T_NATIVE_INT, srcspace[2], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[2] = H5Dcreate2(srcfile, "src_dset_printf_0", H5T_NATIVE_INT, srcspace[2], H5P_DEFAULT, + srcdcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[2] */ @@ -11481,64 +11479,64 @@ test_all(unsigned config, hid_t fapl) start[1] = 0; block[0] = 3; block[1] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 3; i++) - for(j = 0; j < 2; j++) + for (i = 0; i < 3; i++) + for (j = 0; j < 2; j++) erbuf[i][j + 2] = buf[i][j]; /* Close srcdset[2] srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[2]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[2]) < 0) TEST_ERROR srcdset[2] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 6) + if (dims[0] != 6) TEST_ERROR - if(dims[1] != 6) + if (dims[1] != 6) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 10) + if (mdims[1] != 10) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -11548,43 +11546,42 @@ test_all(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if((i >= (int)dims[0]) || (j >= (int)dims[1])) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if ((i >= (int)dims[0]) || (j >= (int)dims[1])) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile, "src_dset_unlim", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile, "src_dset_unlim", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[1] */ dims[0] = 3; dims[1] = 3; - if(H5Dset_extent(srcdset[1], dims) < 0) + if (H5Dset_extent(srcdset[1], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset[1] */ @@ -11592,71 +11589,71 @@ test_all(unsigned config, hid_t fapl) start[1] = 0; block[0] = 1; block[1] = 3; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[1])) < 0) + if ((filespace = H5Dget_space(srcdset[1])) < 0) TEST_ERROR start[0] = 2; start[1] = 0; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 3; i++) + for (i = 0; i < 3; i++) erbuf[5][i] = buf[0][i]; /* Close srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 6) + if (dims[0] != 6) TEST_ERROR - if(dims[1] != 6) + if (dims[1] != 6) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 10) + if (mdims[1] != 10) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -11666,37 +11663,37 @@ test_all(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if((i >= (int)dims[0]) || (j >= (int)dims[1])) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if ((i >= (int)dims[0]) || (j >= (int)dims[1])) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile if config option specified */ - if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) - if((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) + if ((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create second printf source dataset, this time without using srcdcpl */ - if((srcdset[3] = H5Dcreate2(srcfile, "src_dset_printf_1", H5T_NATIVE_INT, srcspace[2], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[3] = H5Dcreate2(srcfile, "src_dset_printf_1", H5T_NATIVE_INT, srcspace[2], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[3] */ @@ -11704,64 +11701,64 @@ test_all(unsigned config, hid_t fapl) start[1] = 0; block[0] = 3; block[1] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[3], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[3], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 3; i++) - for(j = 0; j < 2; j++) + for (i = 0; i < 3; i++) + for (j = 0; j < 2; j++) erbuf[i][j + 5] = buf[i][j]; /* Close srcdset[3] srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[3]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[3]) < 0) TEST_ERROR srcdset[3] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 6) + if (dims[0] != 6) TEST_ERROR - if(dims[1] != 7) + if (dims[1] != 7) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 10) + if (mdims[1] != 10) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -11771,43 +11768,42 @@ test_all(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if((i >= (int)dims[0]) || (j >= (int)dims[1])) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if ((i >= (int)dims[0]) || (j >= (int)dims[1])) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) + if ((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile, "src_dset_unlim", H5P_DEFAULT)) < 0) + if ((srcdset[1] = H5Dopen2(srcfile, "src_dset_unlim", H5P_DEFAULT)) < 0) TEST_ERROR } /* Extend srcdset[1] */ dims[0] = 7; dims[1] = 3; - if(H5Dset_extent(srcdset[1], dims) < 0) + if (H5Dset_extent(srcdset[1], dims) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to new area of srcdset[1] */ @@ -11815,72 +11811,72 @@ test_all(unsigned config, hid_t fapl) start[1] = 0; block[0] = 4; block[1] = 3; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if((filespace = H5Dget_space(srcdset[1])) < 0) + if ((filespace = H5Dget_space(srcdset[1])) < 0) TEST_ERROR start[0] = 3; start[1] = 0; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) + for (i = 0; i < 4; i++) + for (j = 0; j < 3; j++) erbuf[i + 6][j] = buf[i][j]; /* Close srcdset[1] and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[1]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[1]) < 0) TEST_ERROR srcdset[1] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 7) + if (dims[1] != 7) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 10) + if (mdims[1] != 10) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -11890,37 +11886,37 @@ test_all(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) { - if(j >= (int)dims[1]) { - if(rbuf[i][j] != 0) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) { + if (j >= (int)dims[1]) { + if (rbuf[i][j] != 0) TEST_ERROR } - else - if(rbuf[i][j] != erbuf[i][j]) - TEST_ERROR + else if (rbuf[i][j] != erbuf[i][j]) + TEST_ERROR } /* Reopen srcfile if config option specified */ - if((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) - if((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((config & TEST_IO_CLOSE_SRC) && (config & TEST_IO_DIFFERENT_FILE)) + if ((srcfile = H5Fopen(srcfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR /* Create third printf source dataset */ - if((srcdset[4] = H5Dcreate2(srcfile, "src_dset_printf_2", H5T_NATIVE_INT, srcspace[2], H5P_DEFAULT, srcdcpl, H5P_DEFAULT)) < 0) + if ((srcdset[4] = H5Dcreate2(srcfile, "src_dset_printf_2", H5T_NATIVE_INT, srcspace[2], H5P_DEFAULT, + srcdcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Adjust write buffer */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) buf[i][j] += (int)mdims[0] * (int)mdims[1]; /* Write to srcdset[4] */ @@ -11928,64 +11924,64 @@ test_all(unsigned config, hid_t fapl) start[1] = 0; block[0] = 3; block[1] = 2; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, block, NULL) < 0) TEST_ERROR - if(H5Dwrite(srcdset[4], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[4], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Update erbuf */ - for(i = 0; i < 3; i++) - for(j = 0; j < 2; j++) + for (i = 0; i < 3; i++) + for (j = 0; j < 2; j++) erbuf[i][j + 8] = buf[i][j]; /* Close srcdset[4] srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[4]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[4]) < 0) TEST_ERROR srcdset[4] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Get VDS space */ - if((filespace = H5Dget_space(vdset)) < 0) + if ((filespace = H5Dget_space(vdset)) < 0) TEST_ERROR /* Get VDS space dimensions */ - if((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) + if ((ndims = H5Sget_simple_extent_ndims(filespace)) < 0) TEST_ERROR - if(ndims != 2) + if (ndims != 2) TEST_ERROR - if(H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) + if (H5Sget_simple_extent_dims(filespace, dims, mdims) < 0) TEST_ERROR - if(dims[0] != 10) + if (dims[0] != 10) TEST_ERROR - if(dims[1] != 10) + if (dims[1] != 10) TEST_ERROR - if(mdims[0] != 10) + if (mdims[0] != 10) TEST_ERROR - if(mdims[1] != 10) + if (mdims[1] != 10) TEST_ERROR /* Close filespace */ - if(H5Sclose(filespace) < 0) + if (H5Sclose(filespace) < 0) TEST_ERROR /* Read data through virtual dataset */ @@ -11995,58 +11991,58 @@ test_all(unsigned config, hid_t fapl) /* Select hyperslab in memory space */ start[0] = 0; start[1] = 0; - if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) + if (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, dims, NULL) < 0) TEST_ERROR /* Read data */ - if(H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)mdims[0]; i++) - for(j = 0; j < (int)mdims[1]; j++) - if(rbuf[i][j] != erbuf[i][j]) + for (i = 0; i < (int)mdims[0]; i++) + for (j = 0; j < (int)mdims[1]; j++) + if (rbuf[i][j] != erbuf[i][j]) TEST_ERROR /* Close */ - if(!(config & TEST_IO_CLOSE_SRC)) { - for(i = 0; i < 5; i++) { - if(H5Dclose(srcdset[i]) < 0) + if (!(config & TEST_IO_CLOSE_SRC)) { + for (i = 0; i < 5; i++) { + if (H5Dclose(srcdset[i]) < 0) TEST_ERROR srcdset[i] = -1; } - if(H5Fclose(srcfile) < 0) + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } - else if(!(config & TEST_IO_DIFFERENT_FILE)) { - if(H5Fclose(srcfile) < 0) + else if (!(config & TEST_IO_DIFFERENT_FILE)) { + if (H5Fclose(srcfile) < 0) TEST_ERROR srcfile = -1; } - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) { - if(H5Sclose(srcspace[i]) < 0) + for (i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) { + if (H5Sclose(srcspace[i]) < 0) TEST_ERROR srcspace[i] = -1; } - for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) { - if(H5Sclose(vspace[i]) < 0) + for (i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) { + if (H5Sclose(vspace[i]) < 0) TEST_ERROR vspace[i] = -1; } - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR dcpl = -1; - if(H5Pclose(srcdcpl) < 0) + if (H5Pclose(srcdcpl) < 0) TEST_ERROR srcdcpl = -1; - if(H5Sclose(memspace) < 0) + if (H5Sclose(memspace) < 0) TEST_ERROR memspace = -1; @@ -12054,26 +12050,27 @@ test_all(unsigned config, hid_t fapl) return 0; error: - H5E_BEGIN_TRY { - for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) + H5E_BEGIN_TRY + { + for (i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) H5Dclose(srcdset[i]); H5Dclose(vdset); H5Fclose(srcfile); H5Fclose(vfile); - for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) + for (i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); - for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + for (i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) H5Sclose(vspace[i]); H5Sclose(filespace); H5Sclose(memspace); H5Pclose(dcpl); H5Pclose(srcdcpl); - } H5E_END_TRY; + } + H5E_END_TRY; - return 1; + return 1; } /* end test_all() */ - /*------------------------------------------------------------------------- * Function: test_dapl_values * @@ -12086,51 +12083,51 @@ error: static int test_dapl_values(hid_t fapl_id) { - hid_t fid = -1; /* file to write to */ - hid_t dcpl_id = -1; /* dataset creation properties */ - hid_t dapl_id1 = -1; /* dataset access properties */ - hid_t dapl_id2 = -1; /* dataset access properties */ - hid_t vds_sid = -1; /* vds data space */ - hid_t src_sid = -1; /* source data space */ - hid_t did1 = -1; /* dataset */ - hid_t did2 = -1; /* dataset */ - hsize_t start; /* hyperslab start */ - hsize_t stride; /* hyperslab count */ - hsize_t count; /* hyperslab count */ - hsize_t block; /* hyperslab count */ - hsize_t dims; /* dataset size */ - hsize_t max_dims; /* dataset max size */ - H5D_vds_view_t view; /* view from dapl */ - hsize_t gap_size; /* gap size from dapl */ - char filename[1024]; /* file names */ + hid_t fid = -1; /* file to write to */ + hid_t dcpl_id = -1; /* dataset creation properties */ + hid_t dapl_id1 = -1; /* dataset access properties */ + hid_t dapl_id2 = -1; /* dataset access properties */ + hid_t vds_sid = -1; /* vds data space */ + hid_t src_sid = -1; /* source data space */ + hid_t did1 = -1; /* dataset */ + hid_t did2 = -1; /* dataset */ + hsize_t start; /* hyperslab start */ + hsize_t stride; /* hyperslab count */ + hsize_t count; /* hyperslab count */ + hsize_t block; /* hyperslab count */ + hsize_t dims; /* dataset size */ + hsize_t max_dims; /* dataset max size */ + H5D_vds_view_t view; /* view from dapl */ + hsize_t gap_size; /* gap size from dapl */ + char filename[1024]; /* file names */ TESTING("H5Dget_access_plist() returns dapl w/ correct values"); /* Create the file */ h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) FAIL_STACK_ERROR /* Create the dcpl and set up VDS mapping */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* source */ dims = 42; - if((src_sid = H5Screate_simple(1, &dims, NULL)) < 0) + if ((src_sid = H5Screate_simple(1, &dims, NULL)) < 0) FAIL_STACK_ERROR /* vds */ - dims = 0; + dims = 0; max_dims = H5S_UNLIMITED; - if((vds_sid = H5Screate_simple(1, &dims, &max_dims)) < 0) + if ((vds_sid = H5Screate_simple(1, &dims, &max_dims)) < 0) FAIL_STACK_ERROR - start = 0; + start = 0; stride = 42; - count = H5S_UNLIMITED; - block = 42; - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, &start, &stride, &count, &block) < 0) + count = H5S_UNLIMITED; + block = 42; + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, &start, &stride, &count, &block) < 0) FAIL_STACK_ERROR /* map */ - if(H5Pset_virtual(dcpl_id, vds_sid, "f-%b.h5", "/dset1", src_sid) < 0) + if (H5Pset_virtual(dcpl_id, vds_sid, "f-%b.h5", "/dset1", src_sid) < 0) FAIL_STACK_ERROR /* Create the dapls and set values @@ -12139,70 +12136,79 @@ test_dapl_values(hid_t fapl_id) * default isn't the best way to test setting and getting the view. */ /* dapl 1 */ - if((dapl_id1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl_id1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR - if(H5Pset_virtual_view(dapl_id1, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl_id1, H5D_VDS_FIRST_MISSING) < 0) FAIL_STACK_ERROR /* dapl 2 */ - if((dapl_id2 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl_id2 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR /* default but we set it explicitly to be sure */ - if(H5Pset_virtual_view(dapl_id2, H5D_VDS_LAST_AVAILABLE) < 0) + if (H5Pset_virtual_view(dapl_id2, H5D_VDS_LAST_AVAILABLE) < 0) FAIL_STACK_ERROR - if(H5Pset_virtual_printf_gap(dapl_id2, 123) < 0) + if (H5Pset_virtual_printf_gap(dapl_id2, 123) < 0) FAIL_STACK_ERROR /* Create the datasets */ - if((did1 = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, vds_sid, H5P_DEFAULT, dcpl_id, dapl_id1)) < 0) + if ((did1 = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, vds_sid, H5P_DEFAULT, dcpl_id, dapl_id1)) < 0) FAIL_STACK_ERROR - if((did2 = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, vds_sid, H5P_DEFAULT, dcpl_id, dapl_id2)) < 0) + if ((did2 = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, vds_sid, H5P_DEFAULT, dcpl_id, dapl_id2)) < 0) FAIL_STACK_ERROR /* Close the dapls */ - if(H5Pclose(dapl_id1) < 0) + if (H5Pclose(dapl_id1) < 0) FAIL_STACK_ERROR dapl_id1 = -1; - if(H5Pclose(dapl_id2) < 0) + if (H5Pclose(dapl_id2) < 0) FAIL_STACK_ERROR dapl_id2 = -1; /* Get a data access property lists from the dataset */ - if((dapl_id1 = H5Dget_access_plist(did1)) < 0) + if ((dapl_id1 = H5Dget_access_plist(did1)) < 0) FAIL_STACK_ERROR - if((dapl_id2 = H5Dget_access_plist(did2)) < 0) + if ((dapl_id2 = H5Dget_access_plist(did2)) < 0) FAIL_STACK_ERROR /* Check the values from the dapls */ /* dapl 1 */ - if(H5Pget_virtual_view(dapl_id1, &view) < 0) + if (H5Pget_virtual_view(dapl_id1, &view) < 0) FAIL_STACK_ERROR - if(H5D_VDS_FIRST_MISSING != view) + if (H5D_VDS_FIRST_MISSING != view) TEST_ERROR /* dapl 2 */ - if(H5Pget_virtual_view(dapl_id2, &view) < 0) + if (H5Pget_virtual_view(dapl_id2, &view) < 0) FAIL_STACK_ERROR - if(H5D_VDS_LAST_AVAILABLE != view) + if (H5D_VDS_LAST_AVAILABLE != view) TEST_ERROR - if(H5Pget_virtual_printf_gap(dapl_id2, &gap_size) < 0) + if (H5Pget_virtual_printf_gap(dapl_id2, &gap_size) < 0) FAIL_STACK_ERROR - if(gap_size != 123) + if (gap_size != 123) TEST_ERROR /* Close everything */ - if(H5Sclose(vds_sid) < 0) FAIL_STACK_ERROR - if(H5Sclose(src_sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(did1) < 0) FAIL_STACK_ERROR - if(H5Dclose(did2) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl_id1) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl_id2) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl_id) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + if (H5Sclose(vds_sid) < 0) + FAIL_STACK_ERROR + if (H5Sclose(src_sid) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did1) < 0) + FAIL_STACK_ERROR + if (H5Dclose(did2) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dapl_id1) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dapl_id2) < 0) + FAIL_STACK_ERROR + if (H5Pclose(dcpl_id) < 0) + FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR PASSED(); return 0; - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Dclose(did1); H5Dclose(did2); H5Pclose(dapl_id1); @@ -12211,11 +12217,11 @@ test_dapl_values(hid_t fapl_id) H5Sclose(vds_sid); H5Sclose(src_sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_dapl_values() */ - /*------------------------------------------------------------------------- * Function: main * @@ -12232,13 +12238,13 @@ test_dapl_values(hid_t fapl_id) int main(void) { - char filename[FILENAME_BUF_SIZE]; - hid_t fapl; - hid_t my_fapl = -1; /* File access property list */ - int test_api_config; - unsigned bit_config; - H5F_libver_t low, high; /* Low and high bounds */ - int nerrors = 0; + char filename[FILENAME_BUF_SIZE]; + hid_t fapl; + hid_t my_fapl = -1; /* File access property list */ + int test_api_config; + unsigned bit_config; + H5F_libver_t low, high; /* Low and high bounds */ + int nerrors = 0; /* Testing setup */ h5_reset(); @@ -12247,37 +12253,42 @@ main(void) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); /* Set to use the latest file format */ - if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((my_fapl = H5Pcopy(fapl)) < 0) + TEST_ERROR - /* Loop through all the combinations of low/high version bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - char msg[80]; /* Message for file version bounds */ - const char *low_string; /* The low bound string */ - const char *high_string; /* The high bound string */ + /* Loop through all the combinations of low/high version bounds */ + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + const char *low_string; /* The low bound string */ + const char *high_string; /* The high bound string */ /* Invalid combinations, just continue */ - if(high == H5F_LIBVER_EARLIEST || high < low) + if (high == H5F_LIBVER_EARLIEST || high < low) continue; /* Test virtual dataset only for V110 and above */ - if(high < H5F_LIBVER_V110) + if (high < H5F_LIBVER_V110) continue; /* Set the low/high version bounds */ - if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + if (H5Pset_libver_bounds(my_fapl, low, high) < 0) TEST_ERROR /* Display testing info */ - low_string = h5_get_version_string(low); + low_string = h5_get_version_string(low); high_string = h5_get_version_string(high); - HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, + high_string); HDputs(msg); - for(test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; test_api_config++) + for (test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; + test_api_config++) nerrors += test_api((test_api_config_t)test_api_config, my_fapl, low); - for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { - HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + for (bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", + bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", + bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); nerrors += test_basic_io(bit_config, my_fapl); nerrors += test_vds_prefix_first(bit_config, my_fapl); nerrors += test_unlim(bit_config, my_fapl); @@ -12290,13 +12301,13 @@ main(void) /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); - } /* end for high */ - } /* end for low */ + } /* end for high */ + } /* end for low */ - if(H5Pclose(my_fapl) < 0) + if (H5Pclose(my_fapl) < 0) TEST_ERROR - if(nerrors) + if (nerrors) goto error; HDprintf("All virtual dataset tests passed.\n"); h5_cleanup(FILENAME, fapl); @@ -12305,8 +12316,6 @@ main(void) error: nerrors = MAX(1, nerrors); - HDprintf("***** %d VIRTUAL DATASET TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d VIRTUAL DATASET TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return EXIT_FAILURE; } /* end main() */ - diff --git a/test/vds_env.c b/test/vds_env.c index 3d5b5dd..df5eab5 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -18,23 +18,17 @@ */ #include "h5test.h" -const char *FILENAME[] = { - "vds_env_virt_0", - "vds_env_virt_3", - "vds_env_src_2", - "vds_env%%_src2", - NULL -}; +const char *FILENAME[] = {"vds_env_virt_0", "vds_env_virt_3", "vds_env_src_2", "vds_env%%_src2", NULL}; /* I/O test config flags */ -#define TEST_IO_CLOSE_SRC 0x01u -#define TEST_IO_DIFFERENT_FILE 0x02u -#define TEST_IO_REOPEN_VIRT 0x04u -#define TEST_IO_NTESTS 0x08u +#define TEST_IO_CLOSE_SRC 0x01u +#define TEST_IO_DIFFERENT_FILE 0x02u +#define TEST_IO_REOPEN_VIRT 0x04u +#define TEST_IO_NTESTS 0x08u -#define FILENAME_BUF_SIZE 1024 +#define FILENAME_BUF_SIZE 1024 -#define TMPDIR "tmp_vds_env/" +#define TMPDIR "tmp_vds_env/" /*------------------------------------------------------------------------- * Function: test_vds_prefix_second @@ -57,21 +51,21 @@ test_vds_prefix_second(unsigned config, hid_t fapl) char srcfilenamepct[FILENAME_BUF_SIZE]; char srcfilenamepct_map[FILENAME_BUF_SIZE]; const char *srcfilenamepct_map_orig = "vds%%%%_src"; - hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ - hid_t vfile = -1; /* File with virtual dset */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t dapl = -1; /* Dataset access property list */ - hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ - hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ - hid_t memspace = -1; /* Memory dataspace */ - hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ - hid_t vdset = -1; /* Virtual dataset */ - hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ - int buf[10][26]; /* Write and expected read buffer */ - int rbuf[10][26]; /* Read buffer */ - int fill = -1; /* Fill value */ + hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t dapl = -1; /* Dataset access property list */ + hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ + hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ + int buf[10][26]; /* Write and expected read buffer */ + int rbuf[10][26]; /* Read buffer */ + int fill = -1; /* Fill value */ int i, j; - char buffer[1024]; /* buffer to read vds_prefix */ + char buffer[1024]; /* buffer to read vds_prefix */ TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix") @@ -87,207 +81,210 @@ test_vds_prefix_second(unsigned config, hid_t fapl) TEST_ERROR /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) TEST_ERROR /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR - if(H5Pset_virtual_prefix(dapl, "someprefix") < 0) + if (H5Pset_virtual_prefix(dapl, "someprefix") < 0) TEST_ERROR - if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) + if (H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) TEST_ERROR - if(HDstrcmp(buffer, "someprefix") != 0) + if (HDstrcmp(buffer, "someprefix") != 0) FAIL_PUTS_ERROR("vds prefix not set correctly"); /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + if ((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) + if (H5Sselect_all(srcspace[0]) < 0) TEST_ERROR - if(H5Sselect_all(vspace[0]) < 0) + if (H5Sselect_all(vspace[0]) < 0) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) + if (H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", + srcspace[0]) < 0) TEST_ERROR /* Create virtual file */ - if((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - if(NULL == HDgetcwd(buffer, 1024)) + if (config & TEST_IO_DIFFERENT_FILE) { + if (NULL == HDgetcwd(buffer, 1024)) TEST_ERROR - if(HDchdir(TMPDIR) < 0) + if (HDchdir(TMPDIR) < 0) TEST_ERROR - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(HDchdir(buffer) < 0) + if (HDchdir(buffer) < 0) TEST_ERROR } else { srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) + if (H5Iinc_ref(srcfile[0]) < 0) TEST_ERROR } /* Create source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + if ((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) TEST_ERROR /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; /* Write data directly to source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Close srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) + if (config & TEST_IO_CLOSE_SRC) { + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) + if (config & TEST_IO_DIFFERENT_FILE) { + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; } } /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) + if (config & TEST_IO_REOPEN_VIRT) { + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if((vfile = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) + if ((vfile = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + if ((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) TEST_ERROR } /* Read data through virtual dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) { + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) { TEST_ERROR } } /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); /* Write data through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) TEST_ERROR /* Reopen srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) { - if(NULL == HDgetcwd(buffer, 1024)) + if (config & TEST_IO_CLOSE_SRC) { + if (config & TEST_IO_DIFFERENT_FILE) { + if (NULL == HDgetcwd(buffer, 1024)) TEST_ERROR - if(HDchdir(TMPDIR) < 0) + if (HDchdir(TMPDIR) < 0) TEST_ERROR - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + if ((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR - if(HDchdir(buffer) < 0) + if (HDchdir(buffer) < 0) TEST_ERROR } - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) + if ((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) TEST_ERROR } /* Read data directly from source dataset */ HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + if (H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) TEST_ERROR /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) + for (i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for (j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if (rbuf[i][j] != buf[i][j]) TEST_ERROR /* Close */ - if(H5Dclose(vdset) < 0) + if (H5Dclose(vdset) < 0) TEST_ERROR vdset = -1; - if(H5Dclose(srcdset[0]) < 0) + if (H5Dclose(srcdset[0]) < 0) TEST_ERROR srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) + if (H5Fclose(srcfile[0]) < 0) TEST_ERROR srcfile[0] = -1; - if(H5Fclose(vfile) < 0) + if (H5Fclose(vfile) < 0) TEST_ERROR vfile = -1; - if(H5Sclose(srcspace[0]) < 0) + if (H5Sclose(srcspace[0]) < 0) TEST_ERROR srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) + if (H5Sclose(vspace[0]) < 0) TEST_ERROR vspace[0] = -1; - if(H5Pclose(dapl) < 0) + if (H5Pclose(dapl) < 0) TEST_ERROR dapl = -1; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) TEST_ERROR dcpl = -1; PASSED(); return 0; - error: - H5E_BEGIN_TRY { - for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) +error: + H5E_BEGIN_TRY + { + for (i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) H5Dclose(srcdset[i]); H5Dclose(vdset); - for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) + for (i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) H5Fclose(srcfile[i]); H5Fclose(vfile); - for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) + for (i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); - for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + for (i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) H5Sclose(vspace[i]); H5Sclose(memspace); H5Pclose(dapl); H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* end test_vds_prefix2 */ - /*------------------------------------------------------------------------- * Function: main * @@ -299,58 +296,62 @@ test_vds_prefix_second(unsigned config, hid_t fapl) int main(void) { - hid_t fapl, my_fapl; - unsigned bit_config; - H5F_libver_t low, high; /* Low and high bounds */ - int nerrors = 0; + hid_t fapl, my_fapl; + unsigned bit_config; + H5F_libver_t low, high; /* Low and high bounds */ + int nerrors = 0; /* Testing setup */ h5_reset(); fapl = h5_fileaccess(); /* Set to use the latest file format */ - if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + if ((my_fapl = H5Pcopy(fapl)) < 0) + TEST_ERROR - /* Loop through all the combinations of low/high version bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - char msg[80]; /* Message for file version bounds */ - const char *low_string; /* The low bound string */ - const char *high_string; /* The high bound string */ + /* Loop through all the combinations of low/high version bounds */ + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for (high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + const char *low_string; /* The low bound string */ + const char *high_string; /* The high bound string */ /* Invalid combinations, just continue */ - if(high == H5F_LIBVER_EARLIEST || high < low) + if (high == H5F_LIBVER_EARLIEST || high < low) continue; /* Test virtual dataset only for V110 and above */ - if(high < H5F_LIBVER_V110) + if (high < H5F_LIBVER_V110) continue; /* Set the low/high version bounds */ - if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + if (H5Pset_libver_bounds(my_fapl, low, high) < 0) TEST_ERROR /* Display testing info */ - low_string = h5_get_version_string(low); + low_string = h5_get_version_string(low); high_string = h5_get_version_string(high); - HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, + high_string); HDputs(msg); - for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { - HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + for (bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", + bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", + bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); nerrors += test_vds_prefix_second(bit_config, fapl); } /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); - } /* end for high */ - } /* end for low */ + } /* end for high */ + } /* end for low */ - if(H5Pclose(my_fapl) < 0) + if (H5Pclose(my_fapl) < 0) TEST_ERROR - if(nerrors) + if (nerrors) goto error; HDprintf("All virtual dataset tests passed.\n"); h5_cleanup(FILENAME, fapl); @@ -359,7 +360,6 @@ main(void) error: nerrors = MAX(1, nerrors); - HDprintf("***** %d VIRTUAL DATASET TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d VIRTUAL DATASET TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return EXIT_FAILURE; } /* end main() */ diff --git a/test/vds_swmr.h b/test/vds_swmr.h index 0a194ff..676d831 100644 --- a/test/vds_swmr.h +++ b/test/vds_swmr.h @@ -61,27 +61,26 @@ "empty" regions will contain the VDS fill value. */ - /* All datasets are 3D */ -#define RANK 3 +#define RANK 3 /* Lengths of string identifiers (file, dataset names, etc.) */ -#define NAME_LEN 32 +#define NAME_LEN 32 /* Compression level */ -#define COMPRESSION_LEVEL 7 +#define COMPRESSION_LEVEL 7 /* Number of source files */ -#define N_SOURCES 6 +#define N_SOURCES 6 /* Dataset dimensions */ -#define SM_HEIGHT 2 /* K */ -#define LG_HEIGHT 4 /* N */ -#define FULL_HEIGHT 18 /* (3 * K) + (3 * N) */ -#define WIDTH 8 /* M */ +#define SM_HEIGHT 2 /* K */ +#define LG_HEIGHT 4 /* N */ +#define FULL_HEIGHT 18 /* (3 * K) + (3 * N) */ +#define WIDTH 8 /* M */ /* Number of planes each writer will write */ -#define N_PLANES_TO_WRITE 25 +#define N_PLANES_TO_WRITE 25 /* Planes */ H5TEST_DLLVAR hsize_t PLANES[N_SOURCES][RANK]; @@ -96,4 +95,3 @@ H5TEST_DLLVAR char VDS_FILE_NAME[NAME_LEN]; H5TEST_DLLVAR char SOURCE_DSET_PATH[NAME_LEN]; H5TEST_DLLVAR char VDS_DSET_NAME[NAME_LEN]; #endif /* VDS_SWMR_H */ - diff --git a/test/vds_swmr_gen.c b/test/vds_swmr_gen.c index b14ecc2..50687a9 100644 --- a/test/vds_swmr_gen.c +++ b/test/vds_swmr_gen.c @@ -15,22 +15,16 @@ #include "vds_swmr.h" /* Max number of planes in the dataset */ -#define N_MAX_PLANES H5S_UNLIMITED +#define N_MAX_PLANES H5S_UNLIMITED /* Dataset datatypes */ -#define SOURCE_DATATYPE H5T_STD_I32LE -#define VDS_DATATYPE H5T_STD_I32LE +#define SOURCE_DATATYPE H5T_STD_I32LE +#define VDS_DATATYPE H5T_STD_I32LE /* Starting size of datasets, both source and VDS */ -static hsize_t DIMS[N_SOURCES][RANK] = { - {0, SM_HEIGHT, WIDTH}, - {0, LG_HEIGHT, WIDTH}, - {0, SM_HEIGHT, WIDTH}, - {0, LG_HEIGHT, WIDTH}, - {0, SM_HEIGHT, WIDTH}, - {0, LG_HEIGHT, WIDTH} -}; -static hsize_t VDS_DIMS[RANK] = {0, FULL_HEIGHT, WIDTH}; +static hsize_t DIMS[N_SOURCES][RANK] = {{0, SM_HEIGHT, WIDTH}, {0, LG_HEIGHT, WIDTH}, {0, SM_HEIGHT, WIDTH}, + {0, LG_HEIGHT, WIDTH}, {0, SM_HEIGHT, WIDTH}, {0, LG_HEIGHT, WIDTH}}; +static hsize_t VDS_DIMS[RANK] = {0, FULL_HEIGHT, WIDTH}; /* Maximum size of datasets, both source and VDS. * NOTE: Theoretical (i.e.: H5S_UNLIMITED), not the actual max @@ -38,47 +32,34 @@ static hsize_t VDS_DIMS[RANK] = {0, FULL_HEIGHT, WIDTH}; * That number is specified separately. */ static hsize_t MAX_DIMS[N_SOURCES][RANK] = { - {N_MAX_PLANES, SM_HEIGHT, WIDTH}, - {N_MAX_PLANES, LG_HEIGHT, WIDTH}, - {N_MAX_PLANES, SM_HEIGHT, WIDTH}, - {N_MAX_PLANES, LG_HEIGHT, WIDTH}, - {N_MAX_PLANES, SM_HEIGHT, WIDTH}, - {N_MAX_PLANES, LG_HEIGHT, WIDTH} -}; + {N_MAX_PLANES, SM_HEIGHT, WIDTH}, {N_MAX_PLANES, LG_HEIGHT, WIDTH}, {N_MAX_PLANES, SM_HEIGHT, WIDTH}, + {N_MAX_PLANES, LG_HEIGHT, WIDTH}, {N_MAX_PLANES, SM_HEIGHT, WIDTH}, {N_MAX_PLANES, LG_HEIGHT, WIDTH}}; static hsize_t VDS_MAX_DIMS[RANK] = {N_MAX_PLANES, FULL_HEIGHT, WIDTH}; static char SOURCE_DSET_NAME[NAME_LEN] = "source_dset"; -static int32_t FILL_VALUES[N_SOURCES] = { - -1, - -2, - -3, - -4, - -5, - -6 -}; +static int32_t FILL_VALUES[N_SOURCES] = {-1, -2, -3, -4, -5, -6}; static int32_t VDS_FILL_VALUE = -9; int main(void) { - hid_t faplid = -1; /* file access property list ID (all files) */ + hid_t faplid = -1; /* file access property list ID (all files) */ - hid_t src_sid = -1; /* source dataset's dataspace ID */ - hid_t src_dcplid = -1; /* source dataset property list ID */ + hid_t src_sid = -1; /* source dataset's dataspace ID */ + hid_t src_dcplid = -1; /* source dataset property list ID */ - hid_t vds_sid = -1; /* VDS dataspace ID */ - hid_t vds_dcplid = -1; /* VDS dataset property list ID */ + hid_t vds_sid = -1; /* VDS dataspace ID */ + hid_t vds_dcplid = -1; /* VDS dataset property list ID */ - hid_t fid = -1; /* HDF5 file ID */ - hid_t did = -1; /* dataset ID */ + hid_t fid = -1; /* HDF5 file ID */ + hid_t did = -1; /* dataset ID */ - hsize_t start[RANK]; /* starting point for hyperslab */ - int map_start = -1; /* starting point in the VDS map */ - - int i; /* iterator */ + hsize_t start[RANK]; /* starting point for hyperslab */ + int map_start = -1; /* starting point in the VDS map */ + int i; /* iterator */ /* Start by creating the virtual dataset (VDS) dataspace and creation * property list. The individual source datasets are then created @@ -86,139 +67,129 @@ main(void) */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_fill_value(vds_dcplid, VDS_DATATYPE, - &VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, VDS_DATATYPE, &VDS_FILL_VALUE) < 0) TEST_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, VDS_DIMS, - VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, VDS_DIMS, VDS_MAX_DIMS)) < 0) TEST_ERROR /************************************ * Create source files and datasets * ************************************/ - start[0] = 0; - start[1] = 0; - start[2] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; map_start = 0; /* All SWMR files need to use the latest file format */ - if((faplid = h5_fileaccess()) < 0) + if ((faplid = h5_fileaccess()) < 0) TEST_ERROR - if(H5Pset_libver_bounds(faplid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(faplid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR - for(i = 0; i < N_SOURCES; i++) { + for (i = 0; i < N_SOURCES; i++) { /* source dataset dcpl */ - if((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR - if(H5Pset_chunk(src_dcplid, RANK, PLANES[i]) < 0) + if (H5Pset_chunk(src_dcplid, RANK, PLANES[i]) < 0) TEST_ERROR - if(H5Pset_fill_value(src_dcplid, SOURCE_DATATYPE, - &FILL_VALUES[i]) < 0) + if (H5Pset_fill_value(src_dcplid, SOURCE_DATATYPE, &FILL_VALUES[i]) < 0) TEST_ERROR /* Use a mix of compressed and uncompressed datasets */ - if(0 != i % 2) - if(H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) + if (0 != i % 2) + if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) TEST_ERROR /* Create source file, dataspace, and dataset */ - if((fid = H5Fcreate(FILE_NAMES[i], H5F_ACC_TRUNC, - H5P_DEFAULT, faplid)) < 0) + if ((fid = H5Fcreate(FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, faplid)) < 0) TEST_ERROR - if((src_sid = H5Screate_simple(RANK, DIMS[i], - MAX_DIMS[i])) < 0) + if ((src_sid = H5Screate_simple(RANK, DIMS[i], MAX_DIMS[i])) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, SOURCE_DSET_NAME, - SOURCE_DATATYPE, src_sid, - H5P_DEFAULT, src_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, SOURCE_DSET_NAME, SOURCE_DATATYPE, src_sid, H5P_DEFAULT, src_dcplid, + H5P_DEFAULT)) < 0) TEST_ERROR /* set up hyperslabs for source and destination datasets */ start[1] = 0; - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, MAX_DIMS[i], NULL) < 0) TEST_ERROR start[1] = (hsize_t)map_start; - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, NULL, - MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, NULL, MAX_DIMS[i], NULL) < 0) TEST_ERROR - if(PLANES[i][1] > INT_MAX) + if (PLANES[i][1] > INT_MAX) TEST_ERROR map_start += (int)PLANES[i][1]; /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, FILE_NAMES[i], - SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, FILE_NAMES[i], SOURCE_DSET_PATH, src_sid) < 0) TEST_ERROR /* close */ - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) TEST_ERROR - if(H5Pclose(src_dcplid) < 0) + if (H5Pclose(src_dcplid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR } /* end for */ - /******************* * Create VDS file * *******************/ /* file */ - if((fid = H5Fcreate(VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, faplid)) < 0) + if ((fid = H5Fcreate(VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, faplid)) < 0) TEST_ERROR /* dataset */ - if((did = H5Dcreate2(fid, VDS_DSET_NAME, VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, VDS_DSET_NAME, VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < + 0) TEST_ERROR /* close */ - if(H5Pclose(faplid) < 0) + if (H5Pclose(faplid) < 0) TEST_ERROR - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) TEST_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { - if(faplid >= 0) + H5E_BEGIN_TRY + { + if (faplid >= 0) (void)H5Pclose(faplid); - if(src_sid >= 0) + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main */ - diff --git a/test/vds_swmr_reader.c b/test/vds_swmr_reader.c index 1ee65a0..bdb73b8 100644 --- a/test/vds_swmr_reader.c +++ b/test/vds_swmr_reader.c @@ -19,78 +19,77 @@ static hsize_t VDS_PLANE[RANK] = {1, FULL_HEIGHT, WIDTH}; int main(void) { - hid_t fid = -1; /* HDF5 file ID */ - hid_t faplid = -1; /* file access property list ID */ - hid_t did = -1; /* dataset ID */ - hid_t msid = -1; /* memory dataspace ID */ - hid_t fsid = -1; /* file dataspace ID */ + hid_t fid = -1; /* HDF5 file ID */ + hid_t faplid = -1; /* file access property list ID */ + hid_t did = -1; /* dataset ID */ + hid_t msid = -1; /* memory dataspace ID */ + hid_t fsid = -1; /* file dataspace ID */ - hsize_t start[RANK]; /* hyperslab start point */ + hsize_t start[RANK]; /* hyperslab start point */ - int n_elements = 0; /* size of buffer (elements) */ - size_t size = 0; /* size of buffer (bytes) */ - int *buffer = NULL; /* data buffer */ - - int n_dims = -1; /* # dimensions in dataset */ - hsize_t dims[RANK]; /* current size of dataset */ - hsize_t max_dims[RANK]; /* max size of dataset */ + int n_elements = 0; /* size of buffer (elements) */ + size_t size = 0; /* size of buffer (bytes) */ + int * buffer = NULL; /* data buffer */ + int n_dims = -1; /* # dimensions in dataset */ + hsize_t dims[RANK]; /* current size of dataset */ + hsize_t max_dims[RANK]; /* max size of dataset */ /* Open the VDS file and dataset */ - if((faplid = h5_fileaccess()) < 0) + if ((faplid = h5_fileaccess()) < 0) TEST_ERROR - if((fid = H5Fopen(VDS_FILE_NAME, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, faplid)) < 0) + if ((fid = H5Fopen(VDS_FILE_NAME, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, faplid)) < 0) TEST_ERROR - if((did = H5Dopen2(fid, VDS_DSET_NAME, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, VDS_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR /* Create the read buffer */ - if(VDS_PLANE[1] * VDS_PLANE[2] > INT_MAX) + if (VDS_PLANE[1] * VDS_PLANE[2] > INT_MAX) TEST_ERROR n_elements = (int)(VDS_PLANE[1] * VDS_PLANE[2]); - size = (size_t)n_elements * sizeof(int); - if(NULL == (buffer = (int *)HDmalloc(size))) + size = (size_t)n_elements * sizeof(int); + if (NULL == (buffer = (int *)HDmalloc(size))) TEST_ERROR /* Create memory dataspace */ - if((msid = H5Screate_simple(RANK, VDS_PLANE, NULL)) < 0) + if ((msid = H5Screate_simple(RANK, VDS_PLANE, NULL)) < 0) TEST_ERROR /* Read data until the dataset is full (via the writer) */ do { /* Refresh metadata */ - if(H5Drefresh(did) < 0) + if (H5Drefresh(did) < 0) TEST_ERROR /* Get the dataset dimensions */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) TEST_ERROR - if(H5Sget_simple_extent_dims(fsid, dims, max_dims) < 0) + if (H5Sget_simple_extent_dims(fsid, dims, max_dims) < 0) TEST_ERROR /* Check the reported size of the VDS */ - if((n_dims = H5Sget_simple_extent_ndims(fsid)) < 0) + if ((n_dims = H5Sget_simple_extent_ndims(fsid)) < 0) TEST_ERROR - if(n_dims != RANK) + if (n_dims != RANK) TEST_ERROR - if(H5Sget_simple_extent_dims(fsid, dims, max_dims) < 0) + if (H5Sget_simple_extent_dims(fsid, dims, max_dims) < 0) TEST_ERROR /* NOTE: Don't care what dims[0] is. */ - if(dims[1] != FULL_HEIGHT) + if (dims[1] != FULL_HEIGHT) TEST_ERROR - if(dims[2] != WIDTH) + if (dims[2] != WIDTH) TEST_ERROR - if(max_dims[0] != H5S_UNLIMITED) + if (max_dims[0] != H5S_UNLIMITED) TEST_ERROR - if(max_dims[1] != FULL_HEIGHT) + if (max_dims[1] != FULL_HEIGHT) TEST_ERROR - if(max_dims[2] != WIDTH) + if (max_dims[2] != WIDTH) TEST_ERROR /* Continue if there's nothing to read */ - if(0 == dims[0]) { - if(H5Sclose(fsid) < 0) + if (0 == dims[0]) { + if (H5Sclose(fsid) < 0) TEST_ERROR continue; } @@ -100,23 +99,23 @@ main(void) start[0] = dims[0] - 1; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, VDS_PLANE, NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, VDS_PLANE, NULL) < 0) TEST_ERROR - if(H5Dread(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dread(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) TEST_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) TEST_ERROR } while (dims[0] < N_PLANES_TO_WRITE); /* Close file and dataset */ - if(H5Pclose(faplid) < 0) + if (H5Pclose(faplid) < 0) TEST_ERROR - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR HDfree(buffer); @@ -126,23 +125,24 @@ main(void) error: - H5E_BEGIN_TRY { - if(fid >= 0) + H5E_BEGIN_TRY + { + if (fid >= 0) (void)H5Fclose(fid); - if(faplid >= 0) + if (faplid >= 0) (void)H5Pclose(faplid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) HDfree(buffer); - } H5E_END_TRY + } + H5E_END_TRY HDfprintf(stderr, "ERROR: SWMR reader exited with errors\n"); return EXIT_FAILURE; } /* end main */ - diff --git a/test/vds_swmr_writer.c b/test/vds_swmr_writer.c index d70352d..32ef4c7 100644 --- a/test/vds_swmr_writer.c +++ b/test/vds_swmr_writer.c @@ -11,32 +11,30 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #include "h5test.h" #include "vds_swmr.h" int main(int argc, char *argv[]) { - int file_number = -1; /* Source file number */ - - hid_t fid = -1; /* HDF5 file ID */ - hid_t faplid = -1; /* file access property list ID */ - hid_t did = -1; /* dataset ID */ - hid_t msid = -1; /* memory dataspace ID */ - hid_t fsid = -1; /* file dataspace ID */ + int file_number = -1; /* Source file number */ - hsize_t extent[RANK]; /* dataset extents */ - hsize_t start[RANK]; /* hyperslab start point */ + hid_t fid = -1; /* HDF5 file ID */ + hid_t faplid = -1; /* file access property list ID */ + hid_t did = -1; /* dataset ID */ + hid_t msid = -1; /* memory dataspace ID */ + hid_t fsid = -1; /* file dataspace ID */ - int *buffer = NULL; /* data buffer */ - int value = -1; /* value written to datasets */ + hsize_t extent[RANK]; /* dataset extents */ + hsize_t start[RANK]; /* hyperslab start point */ - hsize_t n_elements = 0; /* number of elements in a plane */ + int *buffer = NULL; /* data buffer */ + int value = -1; /* value written to datasets */ - hsize_t i; /* iterator */ - hsize_t j; /* iterator */ + hsize_t n_elements = 0; /* number of elements in a plane */ + hsize_t i; /* iterator */ + hsize_t j; /* iterator */ /****************************** * Fill a source dataset file * @@ -45,96 +43,95 @@ main(int argc, char *argv[]) /* The file number is passed on the command line. * This is an integer index into the FILE_NAMES array. */ - if(argc != 2) { + if (argc != 2) { HDfprintf(stderr, "ERROR: Must pass the source file number on the command line.\n"); return EXIT_FAILURE; } file_number = HDatoi(argv[1]); - if(file_number < 0 || file_number >= N_SOURCES) + if (file_number < 0 || file_number >= N_SOURCES) TEST_ERROR /* Open the source file and dataset */ /* All SWMR files need to use the latest file format */ - if((faplid = h5_fileaccess()) < 0) + if ((faplid = h5_fileaccess()) < 0) TEST_ERROR - if(H5Pset_libver_bounds(faplid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(faplid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR - if((fid = H5Fopen(FILE_NAMES[file_number], H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, faplid)) < 0) + if ((fid = H5Fopen(FILE_NAMES[file_number], H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, faplid)) < 0) TEST_ERROR - if((did = H5Dopen2(fid, SOURCE_DSET_PATH, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, SOURCE_DSET_PATH, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create a data buffer that represents a plane */ n_elements = PLANES[file_number][1] * PLANES[file_number][2]; - if(NULL == (buffer = (int *)HDmalloc(n_elements * sizeof(int)))) + if (NULL == (buffer = (int *)HDmalloc(n_elements * sizeof(int)))) TEST_ERROR /* Create the memory dataspace */ - if((msid = H5Screate_simple(RANK, PLANES[file_number], NULL)) < 0) + if ((msid = H5Screate_simple(RANK, PLANES[file_number], NULL)) < 0) TEST_ERROR /* Write planes to the dataset */ - for(i = 0; i < N_PLANES_TO_WRITE; i++) { + for (i = 0; i < N_PLANES_TO_WRITE; i++) { - time_t delay; /* Time interval between plane writes */ + time_t delay; /* Time interval between plane writes */ /* Cork the dataset's metadata in the cache */ - if(H5Odisable_mdc_flushes(did) < 0) + if (H5Odisable_mdc_flushes(did) < 0) TEST_ERROR /* Set the dataset's extent. This is inefficient but that's ok here. */ extent[0] = i + 1; extent[1] = PLANES[file_number][1]; extent[2] = PLANES[file_number][2]; - if(H5Dset_extent(did, extent) < 0) + if (H5Dset_extent(did, extent) < 0) TEST_ERROR /* Get the file dataspace */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) TEST_ERROR /* Each plane is filled with the plane number as a data value. */ value = (((int)i + 1) * 10) + (int)i; - for(j = 0; j < n_elements; j++) - buffer[j] = value; + for (j = 0; j < n_elements; j++) + buffer[j] = value; /* Set up the hyperslab for writing. */ start[0] = i; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, PLANES[file_number], NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, PLANES[file_number], NULL) < 0) TEST_ERROR /* Write the plane to the dataset. */ - if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) TEST_ERROR /* Uncork the dataset's metadata from the cache */ - if(H5Oenable_mdc_flushes(did) < 0) + if (H5Oenable_mdc_flushes(did) < 0) TEST_ERROR /* Wait one second between writing planes */ delay = HDtime(0) + (time_t)1; - while(HDtime(0) < delay) + while (HDtime(0) < delay) ; /* Flush */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) TEST_ERROR } /* end for */ - if(H5Pclose(faplid) < 0) + if (H5Pclose(faplid) < 0) TEST_ERROR - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) TEST_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) TEST_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR HDfree(buffer); @@ -143,23 +140,24 @@ main(int argc, char *argv[]) error: - H5E_BEGIN_TRY { - if(fid >= 0) + H5E_BEGIN_TRY + { + if (fid >= 0) (void)H5Fclose(fid); - if(faplid >= 0) + if (faplid >= 0) (void)H5Pclose(faplid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) HDfree(buffer); - } H5E_END_TRY + } + H5E_END_TRY HDfprintf(stderr, "ERROR: SWMR writer exited with errors\n"); return EXIT_FAILURE; } /* end main */ - diff --git a/test/vfd.c b/test/vfd.c index 929e875..12ab733 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 * * Purpose: Tests the basic features of Virtual File Drivers @@ -20,55 +20,53 @@ #include "h5test.h" -#define KB 1024U -#define FAMILY_NUMBER 4 -#define FAMILY_SIZE (1*KB) -#define FAMILY_SIZE2 (5*KB) -#define MULTI_SIZE 128 -#define SPLITTER_SIZE 8 /* dimensions of a dataset */ +#define KB 1024U +#define FAMILY_NUMBER 4 +#define FAMILY_SIZE (1 * KB) +#define FAMILY_SIZE2 (5 * KB) +#define MULTI_SIZE 128 +#define SPLITTER_SIZE 8 /* dimensions of a dataset */ -#define CORE_INCREMENT (4*KB) -#define CORE_PAGE_SIZE (1024*KB) -#define CORE_DSET_NAME "core dset" -#define CORE_DSET_DIM1 1024 -#define CORE_DSET_DIM2 32 +#define CORE_INCREMENT (4 * KB) +#define CORE_PAGE_SIZE (1024 * KB) +#define CORE_DSET_NAME "core dset" +#define CORE_DSET_DIM1 1024 +#define CORE_DSET_DIM2 32 -#define DSET1_NAME "dset1" -#define DSET1_DIM1 1024 -#define DSET1_DIM2 32 -#define DSET3_NAME "dset3" +#define DSET1_NAME "dset1" +#define DSET1_DIM1 1024 +#define DSET1_DIM2 32 +#define DSET3_NAME "dset3" /* Macros for Direct VFD */ #ifdef H5_HAVE_DIRECT -#define MBOUNDARY 512 -#define FBSIZE (4*KB) -#define CBSIZE (8*KB) -#define THRESHOLD 1 -#define DSET2_NAME "dset2" -#define DSET2_DIM 4 +#define MBOUNDARY 512 +#define FBSIZE (4 * KB) +#define CBSIZE (8 * KB) +#define THRESHOLD 1 +#define DSET2_NAME "dset2" +#define DSET2_DIM 4 #endif /* H5_HAVE_DIRECT */ -const char *FILENAME[] = { - "sec2_file", /*0*/ - "core_file", /*1*/ - "family_file", /*2*/ - "new_family_v16_", /*3*/ - "multi_file", /*4*/ - "direct_file", /*5*/ - "log_file", /*6*/ - "stdio_file", /*7*/ - "windows_file", /*8*/ - "new_multi_file_v16",/*9*/ - "ro_s3_file", /*10*/ - "splitter_rw_file", /*11*/ - "splitter_wo_file", /*12*/ - "splitter.log", /*13*/ - NULL -}; +const char *FILENAME[] = {"sec2_file", /*0*/ + "core_file", /*1*/ + "family_file", /*2*/ + "new_family_v16_", /*3*/ + "multi_file", /*4*/ + "direct_file", /*5*/ + "log_file", /*6*/ + "stdio_file", /*7*/ + "windows_file", /*8*/ + "new_multi_file_v16", /*9*/ + "ro_s3_file", /*10*/ + "splitter_rw_file", /*11*/ + "splitter_wo_file", /*12*/ + "splitter.log", /*13*/ + NULL}; #define LOG_FILENAME "log_vfd_out.log" -#define COMPAT_BASENAME "family_v16_" +#define COMPAT_BASENAME "family_v16_" #define MULTI_COMPAT_BASENAME "multi_file_v16" #define SPLITTER_DATASET_NAME "dataset" @@ -78,36 +76,31 @@ const char *FILENAME[] = { * four-byte data. */ static int __k; -#define HEXPRINT(size, buf) \ -for (__k = 0; __k < (size); __k++) { \ - if (__k % 16 == 0) { \ - HDprintf("\n%04x", __k); \ - } \ - HDprintf((__k%4 == 0) ? " %02X" : " %02X", (unsigned char)(buf)[__k]); \ -} /* end #define HEXPRINT() */ - +#define HEXPRINT(size, buf) \ + for (__k = 0; __k < (size); __k++) { \ + if (__k % 16 == 0) { \ + HDprintf("\n%04x", __k); \ + } \ + HDprintf((__k % 4 == 0) ? " %02X" : " %02X", (unsigned char)(buf)[__k]); \ + } /* end #define HEXPRINT() */ /* Helper structure to pass around dataset information. */ struct splitter_dataset_def { - void *buf; /* contents of dataset */ - const char *dset_name; /* dataset name, always added to root group */ - hid_t mem_type_id; /* datatype */ - const hsize_t *dims; /* dimensions */ - int n_dims; /* rank */ + void * buf; /* contents of dataset */ + const char * dset_name; /* dataset name, always added to root group */ + hid_t mem_type_id; /* datatype */ + const hsize_t *dims; /* dimensions */ + int n_dims; /* rank */ }; -static int splitter_prepare_file_paths(H5FD_splitter_vfd_config_t *vfd_config, - char *filename_rw_out); +static int splitter_prepare_file_paths(H5FD_splitter_vfd_config_t *vfd_config, char *filename_rw_out); static int splitter_create_single_file_at(const char *filename, hid_t fapl_id, - const struct splitter_dataset_def *data); -static int splitter_compare_expected_data(hid_t file_id, - const struct splitter_dataset_def *data); -static int run_splitter_test(const struct splitter_dataset_def *data, - hbool_t ignore_wo_errors, hbool_t provide_logfile_path, - hid_t sub_fapl_ids[2]); -static int splitter_RO_test(const struct splitter_dataset_def *data, - hid_t child_fapl_id); + const struct splitter_dataset_def *data); +static int splitter_compare_expected_data(hid_t file_id, const struct splitter_dataset_def *data); +static int run_splitter_test(const struct splitter_dataset_def *data, hbool_t ignore_wo_errors, + hbool_t provide_logfile_path, hid_t sub_fapl_ids[2]); +static int splitter_RO_test(const struct splitter_dataset_def *data, hid_t child_fapl_id); static int splitter_tentative_open_test(hid_t child_fapl_id); static int file_exists(const char *filename, hid_t fapl_id); @@ -127,21 +120,21 @@ static int file_exists(const char *filename, hid_t fapl_id); static herr_t test_sec2(void) { - hid_t fid = -1; /* file ID */ - hid_t fapl_id = -1; /* file access property list ID */ - hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - char filename[1024]; /* filename */ - void *os_file_handle = NULL; /* OS file handle */ - hsize_t file_size; /* file size */ + hid_t fid = -1; /* file ID */ + hid_t fapl_id = -1; /* file access property list ID */ + hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + char filename[1024]; /* filename */ + void * os_file_handle = NULL; /* OS file handle */ + hsize_t file_size; /* file size */ TESTING("SEC2 file driver"); /* Set property list and file name for SEC2 driver. */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_fapl_sec2(fapl_id) < 0) + if (H5Pset_fapl_sec2(fapl_id) < 0) TEST_ERROR; h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); @@ -150,79 +143,82 @@ test_sec2(void) TEST_ERROR if (H5FDdriver_query(driver_id, &driver_flags) < 0) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_POSIX_COMPAT_HANDLE)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_DATA_SIEVE)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_POSIX_COMPAT_HANDLE)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + TEST_ERROR /* Check for extra flags not accounted for above */ - if(driver_flags != (H5FD_FEAT_AGGREGATE_METADATA - | H5FD_FEAT_ACCUMULATE_METADATA - | H5FD_FEAT_DATA_SIEVE - | H5FD_FEAT_AGGREGATE_SMALLDATA - | H5FD_FEAT_POSIX_COMPAT_HANDLE - | H5FD_FEAT_SUPPORTS_SWMR_IO - | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + if (driver_flags != (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | + H5FD_FEAT_SUPPORTS_SWMR_IO | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; /* Retrieve the access property list... */ - if((fapl_id_out = H5Fget_access_plist(fid)) < 0) + if ((fapl_id_out = H5Fget_access_plist(fid)) < 0) TEST_ERROR; /* Check that the driver is correct */ - if(H5FD_SEC2 != H5Pget_driver(fapl_id_out)) + if (H5FD_SEC2 != H5Pget_driver(fapl_id_out)) TEST_ERROR; /* ...and close the property list */ - if(H5Pclose(fapl_id_out) < 0) + if (H5Pclose(fapl_id_out) < 0) TEST_ERROR; /* Check that we can get an operating-system-specific handle from * the library. */ - if(H5Fget_vfd_handle(fid, H5P_DEFAULT, &os_file_handle) < 0) + if (H5Fget_vfd_handle(fid, H5P_DEFAULT, &os_file_handle) < 0) TEST_ERROR; - if(os_file_handle == NULL) + if (os_file_handle == NULL) FAIL_PUTS_ERROR("NULL os-specific vfd/file handle was returned from H5Fget_vfd_handle"); - /* There is no garantee the size of metadata in file is constant. * Just try to check if it's reasonable. * * Currently it should be around 2 KB. */ - if(H5Fget_filesize(fid, &file_size) < 0) + if (H5Fget_filesize(fid, &file_size) < 0) TEST_ERROR; - if(file_size < 1 * KB || file_size > 4 * KB) + if (file_size < 1 * KB || file_size > 4 * KB) FAIL_PUTS_ERROR("suspicious file size obtained from H5Fget_filesize"); /* Close and delete the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[0], fapl_id); /* Close the fapl */ - if(H5Pclose(fapl_id) < 0) + if (H5Pclose(fapl_id) < 0) TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_id); H5Pclose(fapl_id_out); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_sec2() */ - /*------------------------------------------------------------------------- * Function: test_core * @@ -239,33 +235,33 @@ error: static herr_t test_core(void) { - hid_t fid = -1; /* file ID */ - hid_t fapl_id = -1; /* file access property list ID */ - hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ - hid_t driver_id = -1; /* ID for this VFD */ + hid_t fid = -1; /* file ID */ + hid_t fapl_id = -1; /* file access property list ID */ + hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ + hid_t driver_id = -1; /* ID for this VFD */ unsigned long driver_flags = 0; /* VFD feature flags */ - hid_t did = -1; /* dataset ID */ - hid_t sid = -1; /* dataspace ID */ - char filename[1024]; /* filename */ - void *os_file_handle = NULL; /* OS file handle */ - hsize_t file_size; /* file size */ - size_t increment; /* core VFD increment */ - hbool_t backing_store; /* use backing store? */ - hbool_t use_write_tracking; /* write tracking flag */ - size_t write_tracking_page_size; /* write tracking page size */ - int *data_w = NULL; /* data written to the dataset */ - int *data_r = NULL; /* data read from the dataset */ - int val; /* data value */ - int *pw = NULL, *pr = NULL; /* pointers for iterating over + hid_t did = -1; /* dataset ID */ + hid_t sid = -1; /* dataspace ID */ + char filename[1024]; /* filename */ + void * os_file_handle = NULL; /* OS file handle */ + hsize_t file_size; /* file size */ + size_t increment; /* core VFD increment */ + hbool_t backing_store; /* use backing store? */ + hbool_t use_write_tracking; /* write tracking flag */ + size_t write_tracking_page_size; /* write tracking page size */ + int * data_w = NULL; /* data written to the dataset */ + int * data_r = NULL; /* data read from the dataset */ + int val; /* data value */ + int * pw = NULL, *pr = NULL; /* pointers for iterating over data arrays (write & read) */ - hsize_t dims[2]; /* dataspace dimensions */ - int i, j; /* iterators */ - htri_t status; /* return value from H5Lexists */ + hsize_t dims[2]; /* dataspace dimensions */ + int i, j; /* iterators */ + htri_t status; /* return value from H5Lexists */ TESTING("CORE file driver"); /* Get a file access property list and fix up the file name */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)); @@ -275,12 +271,12 @@ test_core(void) ************************************************************************/ /* Make sure it's not present at the start of the test */ - if(HDaccess(filename, F_OK) != -1) - if(HDremove(filename) < 0) + if (HDaccess(filename, F_OK) != -1) + if (HDremove(filename) < 0) FAIL_PUTS_ERROR("unable to remove backing store file"); /* Create and close file w/ backing store off */ - if(H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, FALSE) < 0) + if (H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, FALSE) < 0) TEST_ERROR; /* Check that the VFD feature flags are correct. @@ -291,27 +287,30 @@ test_core(void) TEST_ERROR if (H5FDdriver_query(driver_id, &driver_flags) < 0) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_ALLOW_FILE_IMAGE)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_DATA_SIEVE)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_ALLOW_FILE_IMAGE)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS)) + TEST_ERROR /* Check for extra flags not accounted for above */ - if(driver_flags != (H5FD_FEAT_AGGREGATE_METADATA - | H5FD_FEAT_ACCUMULATE_METADATA - | H5FD_FEAT_DATA_SIEVE - | H5FD_FEAT_AGGREGATE_SMALLDATA - | H5FD_FEAT_ALLOW_FILE_IMAGE - | H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS)) + if (driver_flags != + (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_ALLOW_FILE_IMAGE | H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS)) TEST_ERROR - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; /* Check for the backing store file */ - if(HDaccess(filename, F_OK) != -1) + if (HDaccess(filename, F_OK) != -1) FAIL_PUTS_ERROR("file created when backing store set to FALSE"); /************************************************************************ @@ -320,43 +319,43 @@ test_core(void) ************************************************************************/ /* Turn the backing store on */ - if(H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, TRUE) < 0) + if (H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, TRUE) < 0) TEST_ERROR; /* Check that write tracking is off by default and that the default * page size is non-zero. */ - if(H5Pget_core_write_tracking(fapl_id, &use_write_tracking, &write_tracking_page_size) < 0) + if (H5Pget_core_write_tracking(fapl_id, &use_write_tracking, &write_tracking_page_size) < 0) TEST_ERROR; - if(FALSE != use_write_tracking) + if (FALSE != use_write_tracking) FAIL_PUTS_ERROR("write tracking should be off by default"); - if(0 == write_tracking_page_size) + if (0 == write_tracking_page_size) FAIL_PUTS_ERROR("write tracking page size should never be zero"); /* Set core VFD properties */ - if(H5Pset_core_write_tracking(fapl_id, TRUE, CORE_PAGE_SIZE) < 0) + if (H5Pset_core_write_tracking(fapl_id, TRUE, CORE_PAGE_SIZE) < 0) TEST_ERROR; /* Create the file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; /* Retrieve the access property list... */ - if((fapl_id_out = H5Fget_access_plist(fid)) < 0) + if ((fapl_id_out = H5Fget_access_plist(fid)) < 0) TEST_ERROR; /* Check that the driver is correct */ - if(H5FD_CORE != H5Pget_driver(fapl_id_out)) + if (H5FD_CORE != H5Pget_driver(fapl_id_out)) TEST_ERROR; /* Get the basic VFD properties from the fapl and ensure that * they are correct. */ - if(H5Pget_fapl_core(fapl_id_out, &increment, &backing_store) < 0) + if (H5Pget_fapl_core(fapl_id_out, &increment, &backing_store) < 0) TEST_ERROR - if(increment != (size_t)CORE_INCREMENT) + if (increment != (size_t)CORE_INCREMENT) FAIL_PUTS_ERROR("incorrect increment from file fapl"); - if(backing_store != TRUE) + if (backing_store != TRUE) FAIL_PUTS_ERROR("incorrect backing store flag from file fapl"); /* Check that the backing store write tracking info was saved */ @@ -364,23 +363,23 @@ test_core(void) * the write tracking properties. Until this bug is fixed, just * test the main fapl_id. */ - if(H5Pget_core_write_tracking(fapl_id, &use_write_tracking, &write_tracking_page_size) < 0) + if (H5Pget_core_write_tracking(fapl_id, &use_write_tracking, &write_tracking_page_size) < 0) TEST_ERROR; - if(TRUE != use_write_tracking) + if (TRUE != use_write_tracking) FAIL_PUTS_ERROR("write tracking flag incorrect in fapl obtained from H5Fget_access_plist"); - if(CORE_PAGE_SIZE != write_tracking_page_size) + if (CORE_PAGE_SIZE != write_tracking_page_size) FAIL_PUTS_ERROR("write tracking page size incorrect in fapl obtained from H5Fget_access_plist"); /* Close the property list */ - if(H5Pclose(fapl_id_out) < 0) + if (H5Pclose(fapl_id_out) < 0) TEST_ERROR; /* Check that we can get an operating-system-specific handle from * the library. */ - if(H5Fget_vfd_handle(fid, H5P_DEFAULT, &os_file_handle) < 0) + if (H5Fget_vfd_handle(fid, H5P_DEFAULT, &os_file_handle) < 0) TEST_ERROR; - if(os_file_handle == NULL) + if (os_file_handle == NULL) FAIL_PUTS_ERROR("NULL os-specific vfd/file handle was returned from H5Fget_vfd_handle"); /* There is no garantee the size of metadata in file is constant. @@ -388,16 +387,15 @@ test_core(void) * * TODO: Needs justification of why is this is a reasonable size. */ - if(H5Fget_filesize(fid, &file_size) < 0) + if (H5Fget_filesize(fid, &file_size) < 0) TEST_ERROR; - if(file_size < 2 * KB || file_size > 6 * KB) + if (file_size < 2 * KB || file_size > 6 * KB) FAIL_PUTS_ERROR("suspicious file size obtained from H5Fget_filesize"); /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; - /************************************************************************ * Make changes to the file with the backing store flag OFF to ensure * that they ARE NOT propagated. @@ -406,55 +404,56 @@ test_core(void) /* Open the file with backing store off for read and write. * Changes won't be saved in file. */ - if(H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, FALSE) < 0) + if (H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, FALSE) < 0) TEST_ERROR; - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; /* Allocate memory for data set. */ - if(NULL == (data_w = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + if (NULL == (data_w = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) FAIL_PUTS_ERROR("unable to allocate memory for input array"); - if(NULL == (data_r = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + if (NULL == (data_r = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) FAIL_PUTS_ERROR("unable to allocate memory for output array"); /* Initialize the buffers */ val = 0; - pw = data_w; - for(i = 0; i < CORE_DSET_DIM1; i++) - for(j = 0; j < CORE_DSET_DIM2; j++) + pw = data_w; + for (i = 0; i < CORE_DSET_DIM1; i++) + for (j = 0; j < CORE_DSET_DIM2; j++) *pw++ = val++; HDmemset(data_r, 0, DSET1_DIM1 * DSET1_DIM2 * sizeof(int)); /* Create the dataspace */ dims[0] = CORE_DSET_DIM1; dims[1] = CORE_DSET_DIM2; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, CORE_DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, CORE_DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_w) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_w) < 0) TEST_ERROR; /* Close and reopen the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if((did = H5Dopen2(fid, CORE_DSET_NAME, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, CORE_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Read the data back from dset1 */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_r) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_r) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ pw = data_w; pr = data_r; - for(i = 0; i < CORE_DSET_DIM1; i++) - for(j = 0; j < CORE_DSET_DIM2; j++) - if(*pr++ != *pw++) { + for (i = 0; i < CORE_DSET_DIM1; i++) + for (j = 0; j < CORE_DSET_DIM2; j++) + if (*pr++ != *pw++) { H5_FAILED(); HDprintf(" Read different values than written in data set.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -462,25 +461,24 @@ test_core(void) } /* end if */ /* Close everything except the dataspace ID (needed below)*/ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; /* Reopen the file and ensure that the dataset does not exist */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; status = H5Lexists(fid, CORE_DSET_NAME, H5P_DEFAULT); - if(status < 0) + if (status < 0) TEST_ERROR; - if(status > 0) + if (status > 0) FAIL_PUTS_ERROR("core VFD dataset created in file when backing store disabled"); /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; - /************************************************************************ * Make changes to the file with the backing store flag ON to ensure * that they ARE propagated. @@ -489,40 +487,41 @@ test_core(void) /* Open the file with backing store on for read and write. * Changes will be saved in file. */ - if(H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, TRUE) < 0) + if (H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, TRUE) < 0) TEST_ERROR; - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, CORE_DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, CORE_DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) TEST_ERROR; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_w) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_w) < 0) TEST_ERROR; /* Close everything and reopen */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((did = H5Dopen2(fid, CORE_DSET_NAME, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, CORE_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Read the data back from the dataset */ HDmemset(data_r, 0, DSET1_DIM1 * DSET1_DIM2 * sizeof(int)); - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_r) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_r) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ pw = data_w; pr = data_r; - for(i = 0; i < CORE_DSET_DIM1; i++) - for(j = 0; j < CORE_DSET_DIM2; j++) - if(*pw++ != *pr++) { + for (i = 0; i < CORE_DSET_DIM1; i++) + for (j = 0; j < CORE_DSET_DIM2; j++) + if (*pw++ != *pr++) { H5_FAILED(); HDprintf(" Read different values than written in data set.\n"); HDprintf(" At index %d,%d\n", i, j); @@ -535,50 +534,51 @@ test_core(void) * * TODO: Needs justification of why is this is a reasonable size. */ - if(H5Fget_filesize(fid, &file_size) < 0) + if (H5Fget_filesize(fid, &file_size) < 0) TEST_ERROR; - if(file_size < 64 * KB || file_size > 256 * KB) + if (file_size < 64 * KB || file_size > 256 * KB) FAIL_PUTS_ERROR("suspicious file size obtained from H5Fget_filesize"); /* Close everything */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) TEST_ERROR; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) TEST_ERROR; HDfree(data_w); HDfree(data_r); /* Close and delete the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[1], fapl_id); /* Close the fapl */ - if(H5Pclose(fapl_id) < 0) + if (H5Pclose(fapl_id) < 0) TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Dclose(did); H5Pclose(fapl_id_out); H5Pclose(fapl_id); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; - if(data_w) + if (data_w) HDfree(data_w); - if(data_r) + if (data_r) HDfree(data_r); return -1; } /* end test_core() */ - /*------------------------------------------------------------------------- * Function: test_direct * @@ -596,20 +596,20 @@ static herr_t test_direct(void) { #ifdef H5_HAVE_DIRECT - hid_t file=-1, fapl=-1, access_fapl = -1; - hid_t dset1=-1, dset2=-1, space1=-1, space2=-1; - char filename[1024]; - int *fhandle=NULL; - hsize_t file_size; - hsize_t dims1[2], dims2[1]; + hid_t file = -1, fapl = -1, access_fapl = -1; + hid_t dset1 = -1, dset2 = -1, space1 = -1, space2 = -1; + char filename[1024]; + int * fhandle = NULL; + hsize_t file_size; + hsize_t dims1[2], dims2[1]; 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]; - int i, j, n; + 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]; + int i, j, n; #endif /*H5_HAVE_DIRECT*/ TESTING("DIRECT I/O file driver"); @@ -617,30 +617,32 @@ test_direct(void) #ifndef H5_HAVE_DIRECT SKIPPED(); return 0; -#else /*H5_HAVE_DIRECT*/ +#else /*H5_HAVE_DIRECT*/ /* Set property list and file name for Direct driver. Set memory alignment boundary * and file block size to 512 which is the minimum for Linux 2.6. */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_fapl_direct(fapl, MBOUNDARY, FBSIZE, CBSIZE) < 0) + if (H5Pset_fapl_direct(fapl, MBOUNDARY, FBSIZE, CBSIZE) < 0) TEST_ERROR; h5_fixname(FILENAME[5], fapl, filename, sizeof filename); /* Verify the file access properties */ - if(H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0) + if (H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0) TEST_ERROR; - if(mbound != MBOUNDARY || fbsize != FBSIZE || cbsize != CBSIZE) + if (mbound != MBOUNDARY || fbsize != FBSIZE || cbsize != CBSIZE) TEST_ERROR; - if(H5Pset_alignment(fapl, (hsize_t)THRESHOLD, (hsize_t)FBSIZE) < 0) + if (H5Pset_alignment(fapl, (hsize_t)THRESHOLD, (hsize_t)FBSIZE) < 0) TEST_ERROR; - H5E_BEGIN_TRY { - file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - } H5E_END_TRY; - if(file<0) { - H5Pclose (fapl); + H5E_BEGIN_TRY + { + file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + } + H5E_END_TRY; + if (file < 0) { + H5Pclose(fapl); SKIPPED(); HDprintf(" Probably the file system doesn't support Direct I/O\n"); return 0; @@ -651,7 +653,7 @@ test_direct(void) TEST_ERROR; /* Check that the driver is correct */ - if(H5FD_DIRECT != H5Pget_driver(access_fapl)) + if (H5FD_DIRECT != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ @@ -659,149 +661,152 @@ test_direct(void) TEST_ERROR; /* Check file handle API */ - if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) + if (H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; - if(*fhandle<0) + if (*fhandle < 0) TEST_ERROR; /* Check file size API */ - if(H5Fget_filesize(file, &file_size) < 0) + if (H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* There is no guarantee of the number of metadata allocations, but it's * 4 currently and the size of the file should be between 3 & 4 file buffer * sizes.. */ - if(file_size < (FBSIZE * 3) || file_size >= (FBSIZE * 4)) + if (file_size < (FBSIZE * 3) || file_size >= (FBSIZE * 4)) TEST_ERROR; /* 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(&proto_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; points = proto_points; - if(0 != HDposix_memalign(&proto_check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + 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; - for(i = n = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) + for (i = n = 0; i < DSET1_DIM1; i++) + for (j = 0; j < DSET1_DIM2; j++) *p1++ = n++; /* Create the data space1 */ dims1[0] = DSET1_DIM1; dims1[1] = DSET1_DIM2; - if((space1 = H5Screate_simple(2, dims1, NULL)) < 0) + if ((space1 = H5Screate_simple(2, dims1, NULL)) < 0) TEST_ERROR; /* Create the dset1 */ - if((dset1 = H5Dcreate2(file, DSET1_NAME, H5T_NATIVE_INT, space1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset1 = + H5Dcreate2(file, DSET1_NAME, H5T_NATIVE_INT, space1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Write the data to the dset1 */ - if(H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + if (H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR; - if(H5Dclose(dset1) < 0) + if (H5Dclose(dset1) < 0) TEST_ERROR; - if((dset1 = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) + if ((dset1 = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Read the data back from dset1 */ - if(H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) + if (H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ p1 = points; p2 = check; - for(i = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - if(*p1++ != *p2++) { + for (i = 0; i < DSET1_DIM1; i++) + for (j = 0; j < DSET1_DIM2; j++) + if (*p1++ != *p2++) { H5_FAILED(); HDprintf(" Read different values than written in data set 1.\n"); HDprintf(" At index %d,%d\n", i, j); TEST_ERROR; - } /* end if */ + } /* end if */ /* Create the data space2. For data set 2, memory address and data size are not aligned. */ dims2[0] = DSET2_DIM; - if((space2 = H5Screate_simple(1, dims2, NULL)) < 0) + if ((space2 = H5Screate_simple(1, dims2, NULL)) < 0) TEST_ERROR; /* Create the dset2 */ - if((dset2 = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset2 = + H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Write the data to the dset1 */ - if(H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata2) < 0) + if (H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata2) < 0) TEST_ERROR; - if(H5Dclose(dset2) < 0) + if (H5Dclose(dset2) < 0) TEST_ERROR; - if((dset2 = H5Dopen2(file, DSET2_NAME, H5P_DEFAULT)) < 0) + if ((dset2 = H5Dopen2(file, DSET2_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Read the data back from dset1 */ - if(H5Dread(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata2) < 0) + if (H5Dread(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata2) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ - for(i = 0; i < DSET2_DIM; i++) - if(wdata2[i] != rdata2[i]) { + for (i = 0; i < DSET2_DIM; i++) + if (wdata2[i] != rdata2[i]) { H5_FAILED(); HDprintf(" Read different values than written in data set 2.\n"); HDprintf(" At index %d\n", i); TEST_ERROR; } /* end if */ - if(H5Sclose(space1) < 0) + if (H5Sclose(space1) < 0) TEST_ERROR; - if(H5Dclose(dset1) < 0) + if (H5Dclose(dset1) < 0) TEST_ERROR; - if(H5Sclose(space2) < 0) + if (H5Sclose(space2) < 0) TEST_ERROR; - if(H5Dclose(dset2) < 0) + if (H5Dclose(dset2) < 0) TEST_ERROR; HDfree(points); HDfree(check); /* Close and delete the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[5], fapl); /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Sclose(space1); H5Dclose(dset1); H5Sclose(space2); H5Dclose(dset2); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; - if(proto_points) + if (proto_points) HDfree(proto_points); - if(proto_check) + if (proto_check) HDfree(proto_check); return -1; #endif /*H5_HAVE_DIRECT*/ } - /*------------------------------------------------------------------------- * Function: test_family_opens * @@ -822,56 +827,64 @@ 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. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static herr_t test_family_opens(char *fname, hid_t fa_pl) { - hid_t file=-1; - char first_name[1024]; - char wrong_name[1024]; - int i; + hid_t file = -1; + char first_name[1024]; + char wrong_name[1024]; + int i; /* Case 1: reopen file with 1st member file name and default property list */ HDsnprintf(first_name, sizeof(first_name), fname, 0); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file = H5Fopen(first_name, H5F_ACC_RDWR, H5P_DEFAULT); - } H5E_END_TRY; - if(file >= 0) + } + H5E_END_TRY; + if (file >= 0) TEST_ERROR /* Case 2: reopen file with correct name template but default property list */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); - } H5E_END_TRY; - if(file >= 0) + } + H5E_END_TRY; + if (file >= 0) TEST_ERROR /* Case 3: reopen file with wrong member size */ - if(H5Pset_fapl_family(fa_pl, (hsize_t)128, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fa_pl, (hsize_t)128, H5P_DEFAULT) < 0) TEST_ERROR; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file = H5Fopen(fname, H5F_ACC_RDWR, fa_pl); - } H5E_END_TRY; - if(file >= 0) + } + H5E_END_TRY; + if (file >= 0) TEST_ERROR /* Case 4: reopen file with wrong name template */ HDstrcpy(wrong_name, fname); - for(i = 0; i < 1024; i++) - if(wrong_name[i] == '5') { + for (i = 0; i < 1024; i++) + if (wrong_name[i] == '5') { wrong_name[i] = '4'; break; } - if(H5Pset_fapl_family(fa_pl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fa_pl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) TEST_ERROR; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file = H5Fopen(wrong_name, H5F_ACC_RDWR, fa_pl); - } H5E_END_TRY; - if(file >= 0) + } + H5E_END_TRY; + if (file >= 0) TEST_ERROR return 0; @@ -879,8 +892,7 @@ test_family_opens(char *fname, hid_t fa_pl) error: return -1; } /* end test_family_opens() */ -H5_GCC_DIAG_ON(format-nonliteral) - +H5_GCC_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- * Function: test_family @@ -897,33 +909,33 @@ H5_GCC_DIAG_ON(format-nonliteral) static herr_t test_family(void) { - hid_t file=-1, fapl=-1, fapl2=-1, space=-1, dset=-1; - hid_t access_fapl = -1; - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - char filename[1024]; - char dname[] = "dataset"; - unsigned int i, j; - int *fhandle=NULL, *fhandle2=NULL; - int **buf = NULL; - int *buf_data = NULL; - hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; - hsize_t file_size; + hid_t file = -1, fapl = -1, fapl2 = -1, space = -1, dset = -1; + hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + char filename[1024]; + char dname[] = "dataset"; + unsigned int i, j; + int * fhandle = NULL, *fhandle2 = NULL; + 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)))) + if (NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) TEST_ERROR; - if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) + 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) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) TEST_ERROR; h5_fixname(FILENAME[2], fapl, filename, sizeof(filename)); @@ -932,45 +944,47 @@ test_family(void) TEST_ERROR if (H5FDdriver_query(driver_id, &driver_flags) < 0) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_DATA_SIEVE)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) + TEST_ERROR /* Check for extra flags not accounted for above */ - if(driver_flags != (H5FD_FEAT_AGGREGATE_METADATA - | H5FD_FEAT_ACCUMULATE_METADATA - | H5FD_FEAT_DATA_SIEVE - | H5FD_FEAT_AGGREGATE_SMALLDATA)) + if (driver_flags != (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + 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) + if (H5Fclose(file) < 0) TEST_ERROR; /* Test different wrong ways to reopen family files where there's only * one member file existing. */ - if(test_family_opens(filename, fapl) < 0) + if (test_family_opens(filename, fapl) < 0) TEST_ERROR; /* Reopen the file with default member file size */ - if(H5Pset_fapl_family(fapl, (hsize_t)H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) + 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 */ - if(H5Fget_filesize(file, &file_size) < 0) + if (H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* The file size is supposed to be about 800 bytes right now. */ - if(file_size < (KB / 2) || file_size > KB) + if (file_size < (KB / 2) || file_size > KB) 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... */ @@ -978,83 +992,83 @@ test_family(void) TEST_ERROR; /* Check that the driver is correct */ - if(H5FD_FAMILY != H5Pget_driver(access_fapl)) + if (H5FD_FAMILY != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ 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++) + 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_data) < 0) + if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR; /* check file handle API */ - if((fapl2 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl2 = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_family_offset(fapl2, (hsize_t)0) < 0) + if (H5Pset_family_offset(fapl2, (hsize_t)0) < 0) TEST_ERROR; - if(H5Fget_vfd_handle(file, fapl2, (void **)&fhandle) < 0) + if (H5Fget_vfd_handle(file, fapl2, (void **)&fhandle) < 0) TEST_ERROR; - if(*fhandle < 0) + if (*fhandle < 0) TEST_ERROR; - if(H5Pset_family_offset(fapl2, (hsize_t)(FAMILY_SIZE*2)) < 0) + if (H5Pset_family_offset(fapl2, (hsize_t)(FAMILY_SIZE * 2)) < 0) TEST_ERROR; - if(H5Fget_vfd_handle(file, fapl2, (void **)&fhandle2) < 0) + if (H5Fget_vfd_handle(file, fapl2, (void **)&fhandle2) < 0) TEST_ERROR; - if(*fhandle2 < 0) + if (*fhandle2 < 0) TEST_ERROR; /* Check file size API */ - if(H5Fget_filesize(file, &file_size) < 0) + if (H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; - /* Some data has been written. The file size should be bigger (18KB+976) - * bytes if int size is 4 bytes) now. */ + /* Some data has been written. The file size should be bigger (18KB+976) + * bytes if int size is 4 bytes) now. */ #if H5_SIZEOF_INT <= 4 - if(file_size < (18 * KB) || file_size > (20 * KB)) + if (file_size < (18 * KB) || file_size > (20 * KB)) TEST_ERROR; #elif H5_SIZEOF_INT >= 8 - if(file_size < (32 * KB) || file_size > (40 * KB)) + if (file_size < (32 * KB) || file_size > (40 * KB)) TEST_ERROR; #endif - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) TEST_ERROR; - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; /* Test different wrong ways to reopen family files when there're multiple * member files existing. */ - if(test_family_opens(filename, fapl) < 0) + if (test_family_opens(filename, fapl) < 0) TEST_ERROR; /* Reopen the file with correct member file size. */ - if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, 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; /* Close and delete the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[2], fapl); /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; HDfree(buf); @@ -1064,13 +1078,15 @@ test_family(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Dclose(dset); H5Pclose(fapl); H5Pclose(fapl2); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); HDfree(buf_data); @@ -1078,7 +1094,6 @@ error: return FAIL; } /* end test_family() */ - /*------------------------------------------------------------------------- * Function: test_family_compat * @@ -1103,24 +1118,24 @@ 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. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static herr_t test_family_compat(void) { - hid_t file = -1, fapl = -1; - hid_t dset = -1; - char dname[]="dataset"; - char filename[1024]; - char pathname[1024], pathname_individual[1024]; - char newname[1024], newname_individual[1024]; - int counter = 0; + hid_t file = -1, fapl = -1; + hid_t dset = -1; + char dname[] = "dataset"; + char filename[1024]; + char pathname[1024], pathname_individual[1024]; + char newname[1024], newname_individual[1024]; + int counter = 0; TESTING("FAMILY file driver backward compatibility"); /* Set property list and file name for FAMILY driver */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE2, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE2, H5P_DEFAULT) < 0) TEST_ERROR; h5_fixname(COMPAT_BASENAME, fapl, filename, sizeof(filename)); @@ -1136,7 +1151,7 @@ test_family_compat(void) HDsnprintf(newname_individual, sizeof(newname_individual), newname, counter); HDsnprintf(pathname_individual, sizeof(pathname_individual), pathname, counter); - while(h5_make_local_copy(pathname_individual, newname_individual) >= 0) { + while (h5_make_local_copy(pathname_individual, newname_individual) >= 0) { counter++; HDsnprintf(newname_individual, sizeof(newname_individual), newname, counter); HDsnprintf(pathname_individual, sizeof(pathname_individual), pathname, counter); @@ -1144,35 +1159,35 @@ test_family_compat(void) /* Make sure we can open the file. Use the read and write mode to flush the * superblock. */ - if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; - if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; /* Open the file again to make sure it isn't corrupted. */ - if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) + if ((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; - if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) + if ((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) TEST_ERROR; /* Close and delete the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[3], fapl); /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; PASSED(); @@ -1180,15 +1195,16 @@ test_family_compat(void) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(file); H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end test_family_compat() */ -H5_GCC_DIAG_ON(format-nonliteral) - +H5_GCC_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- * Function: test_family_member_fapl @@ -1205,33 +1221,33 @@ H5_GCC_DIAG_ON(format-nonliteral) static herr_t test_family_member_fapl(void) { - hid_t file = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t memb_fapl_id = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t dset = H5I_INVALID_HID; + hid_t file = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t memb_fapl_id = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; char filename[1024]; - char dname[] = "dataset"; - unsigned i = 0; - unsigned j = 0; - int **buf = NULL; - int *buf_data = NULL; - hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; + char dname[] = "dataset"; + unsigned i = 0; + unsigned j = 0; + int ** buf = NULL; + int * buf_data = NULL; + hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; TESTING("Family member FAPL"); /* Set up data array */ - if(NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) + if (NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) TEST_ERROR; - if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) + 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); - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) TEST_ERROR; - if((memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) + if ((memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) TEST_ERROR; if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) @@ -1241,15 +1257,16 @@ test_family_member_fapl(void) h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) == H5I_INVALID_HID) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) == H5I_INVALID_HID) TEST_ERROR; - if((space = H5Screate_simple(2, dims, NULL)) == H5I_INVALID_HID) + if ((space = H5Screate_simple(2, dims, NULL)) == H5I_INVALID_HID) TEST_ERROR; /* Create and write to dataset, then close file. */ - if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) == H5I_INVALID_HID) + if ((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) == + H5I_INVALID_HID) TEST_ERROR; for (i = 0; i < FAMILY_NUMBER; i++) { @@ -1292,13 +1309,15 @@ test_family_member_fapl(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Dclose(dset); H5Pclose(memb_fapl_id); H5Pclose(fapl_id); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); HDfree(buf_data); @@ -1306,7 +1325,6 @@ error: return FAIL; } /* end test_family_member_fapl() */ - /*------------------------------------------------------------------------- * Function: test_multi_opens * @@ -1326,26 +1344,27 @@ 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. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static herr_t test_multi_opens(char *fname) { hid_t fid = H5I_INVALID_HID; - char super_name[1024]; /*name string "%%s-s.h5"*/ - char sf_name[1024]; /*name string "multi_file-s.h5"*/ + char super_name[1024]; /*name string "%%s-s.h5"*/ + char sf_name[1024]; /*name string "multi_file-s.h5"*/ /* Case: reopen with the name of super file and default property list */ HDsnprintf(super_name, sizeof(super_name), "%%s-%c.h5", 's'); HDsnprintf(sf_name, sizeof(sf_name), super_name, fname); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(sf_name, H5F_ACC_RDWR, H5P_DEFAULT); - } H5E_END_TRY; + } + H5E_END_TRY; - return(fid >= 0 ? FAIL : SUCCEED); + return (fid >= 0 ? FAIL : SUCCEED); } /* end test_multi_opens() */ -H5_GCC_DIAG_ON(format-nonliteral) - +H5_GCC_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- * Function: test_multi @@ -1362,52 +1381,52 @@ H5_GCC_DIAG_ON(format-nonliteral) static herr_t test_multi(void) { - hid_t file=-1, fapl=-1, fapl2=-1, dset=-1, space=-1; - hid_t root=-1, attr=-1, aspace=-1, atype=-1; - hid_t access_fapl = -1; - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - char filename[1024]; - int *fhandle2=NULL, *fhandle=NULL; - hsize_t file_size; - H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][32]; - hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE}; - hsize_t adims[1]={1}; - char dname[]="dataset"; - char meta[] = "this is some metadata on this file"; - int i, j; - int **buf = NULL; - int *buf_data = NULL; + hid_t file = -1, fapl = -1, fapl2 = -1, dset = -1, space = -1; + hid_t root = -1, attr = -1, aspace = -1, atype = -1; + hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + char filename[1024]; + int * fhandle2 = NULL, *fhandle = NULL; + hsize_t file_size; + H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + const char * memb_name[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][32]; + hsize_t dims[2] = {MULTI_SIZE, MULTI_SIZE}; + hsize_t adims[1] = {1}; + char dname[] = "dataset"; + char meta[] = "this is some metadata on this file"; + int i, j; + 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)))) + if (NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int)))) TEST_ERROR; - if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data)))) + 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) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - HDmemset(memb_map, 0, sizeof(memb_map)); + HDmemset(memb_map, 0, sizeof(memb_map)); HDmemset(memb_fapl, 0, sizeof(memb_fapl)); HDmemset(memb_name, 0, sizeof(memb_name)); HDmemset(memb_addr, 0, sizeof(memb_addr)); HDmemset(sv, 0, sizeof(sv)); - for(mt=H5FD_MEM_DEFAULT; mt HADDR_MAX/2) + if (file_size < HADDR_MAX / 4 || file_size > HADDR_MAX / 2) 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 HADDR_MAX) + if (file_size < HADDR_MAX / 2 || file_size > HADDR_MAX) TEST_ERROR; - if(H5Sclose(space) < 0) + if (H5Sclose(space) < 0) TEST_ERROR; - if(H5Dclose(dset) < 0) + if (H5Dclose(dset) < 0) TEST_ERROR; - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) TEST_ERROR; /* Create and write attribute for the root group. */ - if((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0) + if ((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0) TEST_ERROR /* Attribute string. */ - if((atype = H5Tcopy(H5T_C_S1)) < 0) + if ((atype = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR; - if(H5Tset_size(atype, HDstrlen(meta) + 1) < 0) + if (H5Tset_size(atype, HDstrlen(meta) + 1) < 0) TEST_ERROR; - if(H5Tset_strpad(atype, H5T_STR_NULLTERM) < 0) + if (H5Tset_strpad(atype, H5T_STR_NULLTERM) < 0) TEST_ERROR; /* Create and write attribute */ - if((aspace = H5Screate_simple(1, adims, NULL)) < 0) + if ((aspace = H5Screate_simple(1, adims, NULL)) < 0) TEST_ERROR; - if((attr = H5Acreate2(root, "Metadata", atype, aspace, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr = H5Acreate2(root, "Metadata", atype, aspace, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Awrite(attr, atype, meta) < 0) + if (H5Awrite(attr, atype, meta) < 0) TEST_ERROR; /* Close IDs */ - if(H5Tclose(atype) < 0) + if (H5Tclose(atype) < 0) TEST_ERROR; - if(H5Sclose(aspace) < 0) + if (H5Sclose(aspace) < 0) TEST_ERROR; - if(H5Aclose(attr) < 0) + if (H5Aclose(attr) < 0) TEST_ERROR; /* Close and delete the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[4], fapl); /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; HDfree(buf); @@ -1581,14 +1600,16 @@ test_multi(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(space); H5Dclose(dset); H5Pclose(fapl); H5Pclose(fapl2); H5Fclose(file); H5Aclose(attr); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); HDfree(buf_data); @@ -1596,7 +1617,6 @@ error: return FAIL; } /* end test_multi() */ - /*------------------------------------------------------------------------- * Function: test_multi_compat * @@ -1620,41 +1640,41 @@ error: static herr_t test_multi_compat(void) { - hid_t file=-1, fapl=-1, dset=-1, space=-1; + hid_t file = -1, fapl = -1, dset = -1, space = -1; char newname[1024]; char filename_s[1024], newname_s[1024]; char filename_r[1024], newname_r[1024]; H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; char sv[H5FD_MEM_NTYPES][32]; - hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE}; + hsize_t dims[2] = {MULTI_SIZE, MULTI_SIZE}; int i, j; - int **buf = NULL; - int *buf_data = NULL; + 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)))) + if (NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int)))) TEST_ERROR; - if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data)))) + 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) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - HDmemset(memb_map, 0, sizeof memb_map); + HDmemset(memb_map, 0, sizeof memb_map); HDmemset(memb_fapl, 0, sizeof memb_fapl); HDmemset(memb_name, 0, sizeof memb_name); HDmemset(memb_addr, 0, sizeof memb_addr); HDmemset(sv, 0, sizeof sv); - for(mt=H5FD_MEM_DEFAULT; mt 4 * KB) + if (file_size < 1 * KB || file_size > 4 * KB) TEST_ERROR; /* Close and delete the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[6], fapl); /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- * Function: test_stdio * @@ -1914,21 +1940,21 @@ error: static herr_t test_stdio(void) { - hid_t file = -1; - hid_t fapl = -1; - hid_t access_fapl = -1; - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - char filename[1024]; - FILE *fhandle = NULL; - hsize_t file_size = 0; + hid_t file = -1; + hid_t fapl = -1; + hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + char filename[1024]; + FILE * fhandle = NULL; + hsize_t file_size = 0; TESTING("STDIO file driver"); /* Set property list and file name for STDIO driver. */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_fapl_stdio(fapl) < 0) + if (H5Pset_fapl_stdio(fapl) < 0) TEST_ERROR; h5_fixname(FILENAME[7], fapl, filename, sizeof filename); @@ -1937,72 +1963,74 @@ test_stdio(void) TEST_ERROR if (H5FDdriver_query(driver_id, &driver_flags) < 0) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_DATA_SIEVE)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + TEST_ERROR /* Check for extra flags not accounted for above */ - if(driver_flags != (H5FD_FEAT_AGGREGATE_METADATA - | H5FD_FEAT_ACCUMULATE_METADATA - | H5FD_FEAT_DATA_SIEVE - | H5FD_FEAT_AGGREGATE_SMALLDATA - | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + if (driver_flags != (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) 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; /* Retrieve the access property list... */ - if((access_fapl = H5Fget_access_plist(file)) < 0) + if ((access_fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; /* Check that the driver is correct */ - if(H5FD_STDIO != H5Pget_driver(access_fapl)) + if (H5FD_STDIO != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ - if(H5Pclose(access_fapl) < 0) + if (H5Pclose(access_fapl) < 0) TEST_ERROR; /* Check file handle API */ - if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) + if (H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; - if(NULL == fhandle) + if (NULL == fhandle) TEST_ERROR; /* Check file size API */ - if(H5Fget_filesize(file, &file_size) < 0) + if (H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* There is no guarantee the size of metadata in file is constant. * Just try to check if it's reasonable. It's 2KB right now. */ - if(file_size < 1 * KB || file_size > 4 * KB) + if (file_size < 1 * KB || file_size > 4 * KB) TEST_ERROR; /* Close and delete the file */ - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[7], fapl); /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - /*------------------------------------------------------------------------- * Function: test_windows * @@ -2021,14 +2049,14 @@ test_windows(void) { #ifdef H5_HAVE_WINDOWS - hid_t file = -1; - hid_t fapl = -1; - hid_t access_fapl = -1; - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - char filename[1024]; - int *fhandle = NULL; - hsize_t file_size = 0; + hid_t file = -1; + hid_t fapl = -1; + hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + char filename[1024]; + int * fhandle = NULL; + hsize_t file_size = 0; #endif /*H5_HAVE_WINDOWS*/ @@ -2042,9 +2070,9 @@ test_windows(void) #else /* H5_HAVE_WINDOWS */ /* Set property list and file name for WINDOWS driver. */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_fapl_windows(fapl) < 0) + if (H5Pset_fapl_windows(fapl) < 0) TEST_ERROR; h5_fixname(FILENAME[8], fapl, filename, sizeof filename); @@ -2053,77 +2081,81 @@ test_windows(void) TEST_ERROR if (H5FDdriver_query(driver_id, &driver_flags) < 0) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_POSIX_COMPAT_HANDLE)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) TEST_ERROR - if(!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_DATA_SIEVE)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_POSIX_COMPAT_HANDLE)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) + TEST_ERROR + if (!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + TEST_ERROR /* Check for extra flags not accounted for above */ - if(driver_flags != (H5FD_FEAT_AGGREGATE_METADATA - | H5FD_FEAT_ACCUMULATE_METADATA - | H5FD_FEAT_DATA_SIEVE - | H5FD_FEAT_AGGREGATE_SMALLDATA - | H5FD_FEAT_POSIX_COMPAT_HANDLE - | H5FD_FEAT_SUPPORTS_SWMR_IO - | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + if (driver_flags != (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | + H5FD_FEAT_SUPPORTS_SWMR_IO | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) 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; /* Retrieve the access property list... */ - if((access_fapl = H5Fget_access_plist(file)) < 0) + if ((access_fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; /* Check that the driver is correct */ - if(H5FD_WINDOWS!= H5Pget_driver(access_fapl)) + if (H5FD_WINDOWS != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ - if(H5Pclose(access_fapl) < 0) + if (H5Pclose(access_fapl) < 0) TEST_ERROR; /* Check file handle API */ - if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) + if (H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; - if(*fhandle < 0) + if (*fhandle < 0) TEST_ERROR; /* Check file size API */ - if(H5Fget_filesize(file, &file_size) < 0) + if (H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* There is no guarantee the size of metadata in file is constant. * Just try to check if it's reasonable. It's 2KB right now. */ - if(file_size < 1 * KB || file_size > 4 * KB) + if (file_size < 1 * KB || file_size > 4 * KB) TEST_ERROR; - /* Close and delete the file */ - if(H5Fclose(file) < 0) + /* Close and delete the file */ + if (H5Fclose(file) < 0) TEST_ERROR; h5_delete_test_file(FILENAME[8], fapl); /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) TEST_ERROR; PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; #endif /* H5_HAVE_WINDOWS */ } /* end test_windows() */ - /*------------------------------------------------------------------------- * Function: test_ros3 * @@ -2148,17 +2180,16 @@ static herr_t test_ros3(void) { #ifdef H5_HAVE_ROS3_VFD - hid_t fid = -1; /* file ID */ - hid_t fapl_id = -1; /* file access property list ID */ - hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ - hid_t driver_id = -1; /* ID for this VFD */ - unsigned long driver_flags = 0; /* VFD feature flags */ - char filename[1024]; /* filename */ - void *os_file_handle = NULL; /* OS file handle */ - hsize_t file_size; /* file size */ + hid_t fid = -1; /* file ID */ + hid_t fapl_id = -1; /* file access property list ID */ + hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ + char filename[1024]; /* filename */ + void * os_file_handle = NULL; /* OS file handle */ + hsize_t file_size; /* file size */ H5FD_ros3_fapl_t test_ros3_fa; - H5FD_ros3_fapl_t ros3_fa_0 = - { + H5FD_ros3_fapl_t ros3_fa_0 = { /* version = */ H5FD_CURR_ROS3_FAPL_T_VERSION, /* authenticate = */ FALSE, /* aws_region = */ "", @@ -2172,25 +2203,25 @@ test_ros3(void) #ifndef H5_HAVE_ROS3_VFD SKIPPED(); return 0; -#else /* H5_HAVE_ROS3_VFD */ +#else /* H5_HAVE_ROS3_VFD */ /* Set property list and file name for ROS3 driver. */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; - if(H5Pset_fapl_ros3(fapl_id, &ros3_fa_0) < 0) + if (H5Pset_fapl_ros3(fapl_id, &ros3_fa_0) < 0) TEST_ERROR; /* verify that the ROS3 FAPL entry is set as expected */ - if(H5Pget_fapl_ros3(fapl_id, &test_ros3_fa) < 0) + if (H5Pget_fapl_ros3(fapl_id, &test_ros3_fa) < 0) TEST_ERROR; /* need a macro to compare instances of H5FD_ros3_fapl_t */ - if((test_ros3_fa.version != ros3_fa_0.version) || - (test_ros3_fa.authenticate != ros3_fa_0.authenticate) || - (strcmp(test_ros3_fa.aws_region, ros3_fa_0.aws_region) != 0) || - (strcmp(test_ros3_fa.secret_id, ros3_fa_0.secret_id) != 0) || - (strcmp(test_ros3_fa.secret_key, ros3_fa_0.secret_key) != 0)) + if ((test_ros3_fa.version != ros3_fa_0.version) || + (test_ros3_fa.authenticate != ros3_fa_0.authenticate) || + (strcmp(test_ros3_fa.aws_region, ros3_fa_0.aws_region) != 0) || + (strcmp(test_ros3_fa.secret_id, ros3_fa_0.secret_id) != 0) || + (strcmp(test_ros3_fa.secret_key, ros3_fa_0.secret_key) != 0)) TEST_ERROR; h5_fixname(FILENAME[10], fapl_id, filename, sizeof(filename)); @@ -2202,27 +2233,28 @@ test_ros3(void) if (H5FDdriver_query(driver_id, &driver_flags) < 0) TEST_ERROR; - if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) + if (!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR /* Check for extra flags not accounted for above */ - if(driver_flags != (H5FD_FEAT_DATA_SIEVE)) + if (driver_flags != (H5FD_FEAT_DATA_SIEVE)) TEST_ERROR PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_id); H5Pclose(fapl_id_out); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; #endif /* H5_HAVE_ROS3_VFD */ } /* end test_ros3() */ - /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Macro: SPLITTER_TEST_FAULT() * @@ -2232,16 +2264,16 @@ error: * * label `done` for exit on fault * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#define SPLITTER_TEST_FAULT(mesg) { \ - H5_FAILED(); \ - AT(); \ - HDfprintf(stderr, mesg); \ - H5Eprint2(H5E_DEFAULT, stderr); \ - fflush(stderr); \ - ret_value = -1; \ - goto done; \ -} - +#define SPLITTER_TEST_FAULT(mesg) \ + { \ + H5_FAILED(); \ + AT(); \ + HDfprintf(stderr, mesg); \ + H5Eprint2(H5E_DEFAULT, stderr); \ + fflush(stderr); \ + ret_value = -1; \ + goto done; \ + } /*------------------------------------------------------------------------- * Function: compare_splitter_config_info @@ -2257,11 +2289,11 @@ error: static int compare_splitter_config_info(hid_t fapl_id, H5FD_splitter_vfd_config_t *info) { - int ret_value = 0; - H5FD_splitter_vfd_config_t fetched_info; + int ret_value = 0; + H5FD_splitter_vfd_config_t fetched_info; - fetched_info.magic = H5FD_SPLITTER_MAGIC; - fetched_info.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + fetched_info.magic = H5FD_SPLITTER_MAGIC; + fetched_info.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; fetched_info.rw_fapl_id = H5I_INVALID_HID; fetched_info.wo_fapl_id = H5I_INVALID_HID; @@ -2288,9 +2320,8 @@ compare_splitter_config_info(hid_t fapl_id, H5FD_splitter_vfd_config_t *info) SPLITTER_TEST_FAULT("Write-Only driver mismatch\n"); } } - if ( (HDstrlen(info->wo_path) != HDstrlen(fetched_info.wo_path)) || - HDstrncmp(info->wo_path, fetched_info.wo_path, H5FD_SPLITTER_PATH_MAX)) - { + if ((HDstrlen(info->wo_path) != HDstrlen(fetched_info.wo_path)) || + HDstrncmp(info->wo_path, fetched_info.wo_path, H5FD_SPLITTER_PATH_MAX)) { HDfprintf(stderr, "MISMATCH: '%s' :: '%s'\n", info->wo_path, fetched_info.wo_path); HEXPRINT(H5FD_SPLITTER_PATH_MAX, info->wo_path); HEXPRINT(H5FD_SPLITTER_PATH_MAX, fetched_info.wo_path); @@ -2301,7 +2332,6 @@ done: return ret_value; } /* end compare_splitter_config_info() */ - /*------------------------------------------------------------------------- * Function: run_splitter_test * @@ -2320,27 +2350,25 @@ done: *------------------------------------------------------------------------- */ static int -run_splitter_test(const struct splitter_dataset_def *data, - hbool_t ignore_wo_errors, - hbool_t provide_logfile_path, - hid_t sub_fapl_ids[2]) +run_splitter_test(const struct splitter_dataset_def *data, hbool_t ignore_wo_errors, + hbool_t provide_logfile_path, hid_t sub_fapl_ids[2]) { - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t fapl_id_out = H5I_INVALID_HID; - hid_t fapl_id_cpy = H5I_INVALID_HID; - H5FD_splitter_vfd_config_t vfd_config; - char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; - FILE *logfile = NULL; - int ret_value = 0; - - vfd_config.magic = H5FD_SPLITTER_MAGIC; - vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t fapl_id_out = H5I_INVALID_HID; + hid_t fapl_id_cpy = H5I_INVALID_HID; + H5FD_splitter_vfd_config_t vfd_config; + char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; + FILE * logfile = NULL; + int ret_value = 0; + + vfd_config.magic = H5FD_SPLITTER_MAGIC; + vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; vfd_config.ignore_wo_errs = ignore_wo_errors; - vfd_config.rw_fapl_id = sub_fapl_ids[0]; - vfd_config.wo_fapl_id = sub_fapl_ids[1]; + vfd_config.rw_fapl_id = sub_fapl_ids[0]; + vfd_config.wo_fapl_id = sub_fapl_ids[1]; if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) { SPLITTER_TEST_FAULT("can't prepare file paths\n"); @@ -2396,7 +2424,6 @@ run_splitter_test(const struct splitter_dataset_def *data, fapl_id_out = H5Fget_access_plist(file_id); if (H5I_INVALID_HID == fapl_id_out) { SPLITTER_TEST_FAULT("can't get file's FAPL\n"); - } if (H5Pget_driver(fapl_id_out) != H5FD_SPLITTER) { SPLITTER_TEST_FAULT("wrong file FAPL driver\n"); @@ -2416,7 +2443,8 @@ run_splitter_test(const struct splitter_dataset_def *data, if (space_id < 0) { SPLITTER_TEST_FAULT("can't create dataspace\n"); } - dset_id = H5Dcreate2(file_id, data->dset_name, data->mem_type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, data->dset_name, data->mem_type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); if (dset_id < 0) { SPLITTER_TEST_FAULT("can't create dataset\n"); } @@ -2445,22 +2473,23 @@ run_splitter_test(const struct splitter_dataset_def *data, /* Verify existence of logfile if appropriate */ logfile = fopen(vfd_config.log_file_path, "r"); - if ( (TRUE == provide_logfile_path && NULL == logfile) || - (FALSE == provide_logfile_path && NULL != logfile) ) - { + if ((TRUE == provide_logfile_path && NULL == logfile) || + (FALSE == provide_logfile_path && NULL != logfile)) { SPLITTER_TEST_FAULT("no logfile when one was expected\n"); } done: if (ret_value < 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Dclose(dset_id); (void)H5Sclose(space_id); (void)H5Pclose(fapl_id_out); (void)H5Pclose(fapl_id_cpy); (void)H5Pclose(fapl_id); (void)H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; } if (logfile != NULL) { fclose(logfile); @@ -2469,7 +2498,6 @@ done: } /* end run_splitter_test() */ - /*------------------------------------------------------------------------- * Function: driver_is_splitter_compatible * @@ -2488,26 +2516,28 @@ done: static int driver_is_splitter_compatible(hid_t fapl_id) { - H5FD_splitter_vfd_config_t vfd_config; - hid_t split_fapl_id = H5I_INVALID_HID; - herr_t ret = SUCCEED; - int ret_value = 0; + H5FD_splitter_vfd_config_t vfd_config; + hid_t split_fapl_id = H5I_INVALID_HID; + herr_t ret = SUCCEED; + int ret_value = 0; split_fapl_id = H5Pcreate(H5P_FILE_ACCESS); if (H5I_INVALID_HID == split_fapl_id) { FAIL_PUTS_ERROR("Can't create contained FAPL"); } - vfd_config.magic = H5FD_SPLITTER_MAGIC; - vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + vfd_config.magic = H5FD_SPLITTER_MAGIC; + vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; vfd_config.ignore_wo_errs = FALSE; - vfd_config.rw_fapl_id = H5P_DEFAULT; - vfd_config.wo_fapl_id = fapl_id; + vfd_config.rw_fapl_id = H5P_DEFAULT; + vfd_config.wo_fapl_id = fapl_id; HDstrncpy(vfd_config.wo_path, "nonesuch", H5FD_SPLITTER_PATH_MAX); *vfd_config.log_file_path = '\0'; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_fapl_splitter(split_fapl_id, &vfd_config); - } H5E_END_TRY; + } + H5E_END_TRY; if (SUCCEED == ret) { ret_value = -1; } @@ -2520,13 +2550,14 @@ driver_is_splitter_compatible(hid_t fapl_id) return ret_value; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(split_fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end driver_is_splitter_compatible() */ - /*------------------------------------------------------------------------- * Function: splitter_RO_test * @@ -2541,21 +2572,19 @@ error: *------------------------------------------------------------------------- */ static int -splitter_RO_test( - const struct splitter_dataset_def *data, - hid_t child_fapl_id) +splitter_RO_test(const struct splitter_dataset_def *data, hid_t child_fapl_id) { - char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; - H5FD_splitter_vfd_config_t vfd_config; - hid_t fapl_id = H5I_INVALID_HID; - int ret_value = 0; - hid_t file_id = H5I_INVALID_HID; - - vfd_config.magic = H5FD_SPLITTER_MAGIC; - vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; + H5FD_splitter_vfd_config_t vfd_config; + hid_t fapl_id = H5I_INVALID_HID; + int ret_value = 0; + hid_t file_id = H5I_INVALID_HID; + + vfd_config.magic = H5FD_SPLITTER_MAGIC; + vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; vfd_config.ignore_wo_errs = FALSE; - vfd_config.rw_fapl_id = child_fapl_id; - vfd_config.wo_fapl_id = child_fapl_id; + vfd_config.rw_fapl_id = child_fapl_id; + vfd_config.wo_fapl_id = child_fapl_id; if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) { SPLITTER_TEST_FAULT("can't prepare splitter file paths\n"); @@ -2577,9 +2606,11 @@ splitter_RO_test( * Should fail. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (file_id >= 0) { SPLITTER_TEST_FAULT("R/O open on nonexistent files unexpectedly successful\n"); } @@ -2591,9 +2622,11 @@ splitter_RO_test( if (splitter_create_single_file_at(vfd_config.wo_path, vfd_config.wo_fapl_id, data) < 0) { SPLITTER_TEST_FAULT("can't write W/O file\n"); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (file_id >= 0) { SPLITTER_TEST_FAULT("R/O open with extant W/O file unexpectedly successful\n"); } @@ -2606,9 +2639,11 @@ splitter_RO_test( if (splitter_create_single_file_at(filename_rw, vfd_config.rw_fapl_id, data) < 0) { SPLITTER_TEST_FAULT("can't create R/W file\n"); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (file_id >= 0) { SPLITTER_TEST_FAULT("R/O open with extant R/W file unexpectedly successful\n"); } @@ -2641,15 +2676,16 @@ splitter_RO_test( done: if (ret_value < 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); (void)H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if error */ return ret_value; } /* end splitter_RO_test() */ - /*------------------------------------------------------------------------- * Function: splitter_prepare_file_paths * @@ -2693,7 +2729,8 @@ splitter_prepare_file_paths(H5FD_splitter_vfd_config_t *vfd_config, char *filena */ h5_fixname(FILENAME[11], vfd_config->rw_fapl_id, filename_rw_out, H5FD_SPLITTER_PATH_MAX); h5_fixname(FILENAME[12], vfd_config->wo_fapl_id, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); - h5_fixname_no_suffix(FILENAME[13], vfd_config->wo_fapl_id, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); + h5_fixname_no_suffix(FILENAME[13], vfd_config->wo_fapl_id, vfd_config->log_file_path, + H5FD_SPLITTER_PATH_MAX); /* Delete any existing files on disk. */ @@ -2705,7 +2742,6 @@ done: return ret_value; } /* end splitter_prepare_file_paths() */ - /*------------------------------------------------------------------------- * Function: splitter_crate_single_file_at * @@ -2726,15 +2762,12 @@ done: *------------------------------------------------------------------------- */ static int -splitter_create_single_file_at( - const char *filename, - hid_t fapl_id, - const struct splitter_dataset_def *data) +splitter_create_single_file_at(const char *filename, hid_t fapl_id, const struct splitter_dataset_def *data) { - hid_t file_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - int ret_value = 0; + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + int ret_value = 0; if (filename == NULL || *filename == '\0') { SPLITTER_TEST_FAULT("filename is invalid\n"); @@ -2753,14 +2786,8 @@ splitter_create_single_file_at( SPLITTER_TEST_FAULT("can't create dataspace\n"); } - dset_id = H5Dcreate2( - file_id, - data->dset_name, - data->mem_type_id, - space_id, - H5P_DEFAULT, - H5P_DEFAULT, - H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, data->dset_name, data->mem_type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); if (dset_id < 0) { SPLITTER_TEST_FAULT("can't create dataset\n"); } @@ -2783,16 +2810,17 @@ splitter_create_single_file_at( done: if (ret_value < 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Dclose(dset_id); (void)H5Sclose(space_id); (void)H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if error */ return ret_value; } /* end splitter_create_single_file_at() */ - /*------------------------------------------------------------------------- * Function: splitter_compare_expected_data * @@ -2808,15 +2836,14 @@ done: *------------------------------------------------------------------------- */ static int -splitter_compare_expected_data(hid_t file_id, - const struct splitter_dataset_def *data) +splitter_compare_expected_data(hid_t file_id, const struct splitter_dataset_def *data) { - hid_t dset_id = H5I_INVALID_HID; - int buf[SPLITTER_SIZE][SPLITTER_SIZE]; - int expected[SPLITTER_SIZE][SPLITTER_SIZE]; - size_t i = 0; - size_t j = 0; - int ret_value = 0; + hid_t dset_id = H5I_INVALID_HID; + int buf[SPLITTER_SIZE][SPLITTER_SIZE]; + int expected[SPLITTER_SIZE][SPLITTER_SIZE]; + size_t i = 0; + size_t j = 0; + int ret_value = 0; if (sizeof((void *)buf) != sizeof(data->buf)) { SPLITTER_TEST_FAULT("invariant size of expected data does not match that received!\n"); @@ -2832,8 +2859,8 @@ splitter_compare_expected_data(hid_t file_id, SPLITTER_TEST_FAULT("can't read dataset\n"); } - for (i=0; i < SPLITTER_SIZE; i++) { - for (j=0; j < SPLITTER_SIZE; j++) { + for (i = 0; i < SPLITTER_SIZE; i++) { + for (j = 0; j < SPLITTER_SIZE; j++) { if (buf[i][j] != expected[i][j]) { SPLITTER_TEST_FAULT("mismatch in expected data\n"); } @@ -2846,14 +2873,15 @@ splitter_compare_expected_data(hid_t file_id, done: if (ret_value < 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Dclose(dset_id); - } H5E_END_TRY; + } + H5E_END_TRY; } return ret_value; } /* end splitter_compare_expected_data() */ - /*------------------------------------------------------------------------- * Function: splitter_tentative_open_test() * @@ -2880,37 +2908,37 @@ done: static int splitter_tentative_open_test(hid_t child_fapl_id) { - const char filename_tmp[H5FD_SPLITTER_PATH_MAX + 1] = "splitter_tmp.h5"; - char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; + const char filename_tmp[H5FD_SPLITTER_PATH_MAX + 1] = "splitter_tmp.h5"; + char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; H5FD_splitter_vfd_config_t vfd_config; - hid_t fapl_id = H5I_INVALID_HID; - hid_t file_id = H5I_INVALID_HID; - int buf[SPLITTER_SIZE][SPLITTER_SIZE]; /* for comparison */ - hsize_t dims[2] = { SPLITTER_SIZE, SPLITTER_SIZE }; /* for comparison */ - int i = 0; /* for comparison */ - int j = 0; /* for comparison */ - struct splitter_dataset_def data; /* for comparison */ - int ret_value = 0; + hid_t fapl_id = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; + int buf[SPLITTER_SIZE][SPLITTER_SIZE]; /* for comparison */ + hsize_t dims[2] = {SPLITTER_SIZE, SPLITTER_SIZE}; /* for comparison */ + int i = 0; /* for comparison */ + int j = 0; /* for comparison */ + struct splitter_dataset_def data; /* for comparison */ + int ret_value = 0; /* pre-fill data buffer to write */ - for (i=0; i < SPLITTER_SIZE; i++) { - for (j=0; j < SPLITTER_SIZE; j++) { - buf[i][j] = i*100+j; + for (i = 0; i < SPLITTER_SIZE; i++) { + for (j = 0; j < SPLITTER_SIZE; j++) { + buf[i][j] = i * 100 + j; } } /* Dataset info */ - data.buf = (void *)buf; + data.buf = (void *)buf; data.mem_type_id = H5T_NATIVE_INT; - data.dims = dims; - data.n_dims = 2; - data.dset_name = SPLITTER_DATASET_NAME; + data.dims = dims; + data.n_dims = 2; + data.dset_name = SPLITTER_DATASET_NAME; - vfd_config.magic = H5FD_SPLITTER_MAGIC; - vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + vfd_config.magic = H5FD_SPLITTER_MAGIC; + vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; vfd_config.ignore_wo_errs = FALSE; - vfd_config.rw_fapl_id = child_fapl_id; - vfd_config.wo_fapl_id = child_fapl_id; + vfd_config.rw_fapl_id = child_fapl_id; + vfd_config.wo_fapl_id = child_fapl_id; if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) { SPLITTER_TEST_FAULT("can't prepare splitter file paths\n"); @@ -2941,9 +2969,11 @@ splitter_tentative_open_test(hid_t child_fapl_id) * Should fail. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (file_id != H5I_INVALID_HID) { SPLITTER_TEST_FAULT("open with both nonexistent files unexpectedly succeeded\n"); } @@ -2963,9 +2993,11 @@ splitter_tentative_open_test(hid_t child_fapl_id) if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config.wo_path) < 0) { SPLITTER_TEST_FAULT("Can't create W/O file copy.\n"); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (file_id != H5I_INVALID_HID) { SPLITTER_TEST_FAULT("open with nonexistent R/W file unexpectedly succeeded\n"); } @@ -2989,9 +3021,11 @@ splitter_tentative_open_test(hid_t child_fapl_id) if (h5_duplicate_file_by_bytes(filename_tmp, filename_rw) < 0) { SPLITTER_TEST_FAULT("Can't create R/W file copy.\n"); } - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (file_id != H5I_INVALID_HID) { SPLITTER_TEST_FAULT("open with nonexistent W/O unexpectedly succeeded\n"); } @@ -3124,15 +3158,16 @@ splitter_tentative_open_test(hid_t child_fapl_id) done: if (ret_value < 0) { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Pclose(fapl_id); (void)H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if error */ return ret_value; } /* end splitter_tentative_open_test() */ - /*------------------------------------------------------------------------- * Function: file_exists() * @@ -3148,12 +3183,14 @@ done: static int file_exists(const char *filename, hid_t fapl_id) { - hid_t file_id = H5I_INVALID_HID; - int ret_value = 0; + hid_t file_id = H5I_INVALID_HID; + int ret_value = 0; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (file_id != H5I_INVALID_HID) { ret_value = 1; if (H5Fclose(file_id) < 0) { @@ -3164,13 +3201,14 @@ file_exists(const char *filename, hid_t fapl_id) return ret_value; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { (void)H5Fclose(file_id); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } /* end file_exists() */ - /*------------------------------------------------------------------------- * Function: test_splitter * @@ -3189,28 +3227,28 @@ error: static herr_t test_splitter(void) { - int buf[SPLITTER_SIZE][SPLITTER_SIZE]; - hsize_t dims[2] = { SPLITTER_SIZE, SPLITTER_SIZE }; - hid_t child_fapl_id = H5I_INVALID_HID; - int i = 0; - int j = 0; + int buf[SPLITTER_SIZE][SPLITTER_SIZE]; + hsize_t dims[2] = {SPLITTER_SIZE, SPLITTER_SIZE}; + hid_t child_fapl_id = H5I_INVALID_HID; + int i = 0; + int j = 0; struct splitter_dataset_def data; TESTING("SPLITTER file driver"); /* pre-fill data buffer to write */ - for (i=0; i < SPLITTER_SIZE; i++) { - for (j=0; j < SPLITTER_SIZE; j++) { - buf[i][j] = i*100+j; + for (i = 0; i < SPLITTER_SIZE; i++) { + for (j = 0; j < SPLITTER_SIZE; j++) { + buf[i][j] = i * 100 + j; } } /* Dataset info */ - data.buf = (void *)buf; + data.buf = (void *)buf; data.mem_type_id = H5T_NATIVE_INT; - data.dims = dims; - data.n_dims = 2; - data.dset_name = SPLITTER_DATASET_NAME; + data.dims = dims; + data.n_dims = 2; + data.dset_name = SPLITTER_DATASET_NAME; /* Stand-in for manual FAPL creation * Enables verification with arbitrary VFDs via `make check-vfd` @@ -3242,13 +3280,13 @@ test_splitter(void) /* Test file creation, utilizing different child FAPLs (default vs. * specified), logfile, and Write Channel error ignoring behavior. */ - for (i=0; i < 4; i++) { - hbool_t ignore_wo_errors = (i & 1) ? TRUE : FALSE; + for (i = 0; i < 4; i++) { + hbool_t ignore_wo_errors = (i & 1) ? TRUE : FALSE; hbool_t provide_logfile_path = (i & 2) ? TRUE : FALSE; - hid_t child_fapl_ids[2] = { H5P_DEFAULT, H5P_DEFAULT }; + hid_t child_fapl_ids[2] = {H5P_DEFAULT, H5P_DEFAULT}; /* Test child driver definition/default combination */ - for (j=0; j < 4; j++) { + for (j = 0; j < 4; j++) { child_fapl_ids[0] = (j & 1) ? child_fapl_id : H5P_DEFAULT; child_fapl_ids[1] = (j & 2) ? child_fapl_id : H5P_DEFAULT; @@ -3261,8 +3299,8 @@ test_splitter(void) } /* end for behavior-flag loops */ -/* TODO: SWMR open? */ -/* Concurrent opens with both drivers using the Splitter */ + /* TODO: SWMR open? */ + /* Concurrent opens with both drivers using the Splitter */ if (H5Pclose(child_fapl_id) == FAIL) { TEST_ERROR; @@ -3280,7 +3318,6 @@ error: #undef SPLITTER_TEST_FAULT - /*------------------------------------------------------------------------- * Function: main * @@ -3299,28 +3336,26 @@ main(void) HDprintf("Testing basic Virtual File Driver functionality.\n"); - nerrors += test_sec2() < 0 ? 1 : 0; - nerrors += test_core() < 0 ? 1 : 0; - nerrors += test_direct() < 0 ? 1 : 0; - nerrors += test_family() < 0 ? 1 : 0; - nerrors += test_family_compat() < 0 ? 1 : 0; - nerrors += test_family_member_fapl() < 0 ? 1 : 0; - nerrors += test_multi() < 0 ? 1 : 0; - nerrors += test_multi_compat() < 0 ? 1 : 0; - nerrors += test_log() < 0 ? 1 : 0; - nerrors += test_stdio() < 0 ? 1 : 0; - nerrors += test_windows() < 0 ? 1 : 0; - nerrors += test_ros3() < 0 ? 1 : 0; - nerrors += test_splitter() < 0 ? 1 : 0; - - if(nerrors) { - HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + nerrors += test_sec2() < 0 ? 1 : 0; + nerrors += test_core() < 0 ? 1 : 0; + nerrors += test_direct() < 0 ? 1 : 0; + nerrors += test_family() < 0 ? 1 : 0; + nerrors += test_family_compat() < 0 ? 1 : 0; + nerrors += test_family_member_fapl() < 0 ? 1 : 0; + nerrors += test_multi() < 0 ? 1 : 0; + nerrors += test_multi_compat() < 0 ? 1 : 0; + nerrors += test_log() < 0 ? 1 : 0; + nerrors += test_stdio() < 0 ? 1 : 0; + nerrors += test_windows() < 0 ? 1 : 0; + nerrors += test_ros3() < 0 ? 1 : 0; + nerrors += test_splitter() < 0 ? 1 : 0; + + if (nerrors) { + HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); return EXIT_FAILURE; - } /* end if */ + } HDprintf("All Virtual File Driver tests passed.\n"); return EXIT_SUCCESS; } /* end main() */ - diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c index 8c5b853..cb63c2a 100644 --- a/test/vfd_swmr.c +++ b/test/vfd_swmr.c @@ -12,12 +12,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** -* -* Test program: -* -* Tests the VFD SWMR Feature. -* -*************************************************************/ + * + * Test program: + * + * Tests the VFD SWMR Feature. + * + *************************************************************/ #include "H5queue.h" #include "h5test.h" @@ -27,8 +27,8 @@ * This file needs to access private information from the H5F package. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #define H5F_TESTING #define H5FD_TESTING #include "H5FDprivate.h" @@ -36,20 +36,20 @@ #include "H5FDpkg.h" #include "H5Iprivate.h" -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ #include "H5FDpkg.h" -#define FS_PAGE_SIZE 512 -#define FILENAME "vfd_swmr_file.h5" -#define MD_FILENAME "vfd_swmr_metadata_file" +#define FS_PAGE_SIZE 512 +#define FILENAME "vfd_swmr_file.h5" +#define MD_FILENAME "vfd_swmr_metadata_file" -#define FILENAME2 "vfd_swmr_file2.h5" -#define MD_FILENAME2 "vfd_swmr_metadata_file2" +#define FILENAME2 "vfd_swmr_file2.h5" +#define MD_FILENAME2 "vfd_swmr_metadata_file2" -#define FILENAME3 "vfd_swmr_file3.h5" -#define MD_FILENAME3 "vfd_swmr_metadata_file3" +#define FILENAME3 "vfd_swmr_file3.h5" +#define MD_FILENAME3 "vfd_swmr_metadata_file3" -#define FNAME "non_vfd_swmr_file.h5" +#define FNAME "non_vfd_swmr_file.h5" /* test routines for VFD SWMR */ static unsigned test_fapl(void); @@ -58,9 +58,9 @@ static unsigned test_file_fapl(void); static unsigned test_writer_md(void); /* helper routines */ -static hid_t -init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, - hbool_t is_writer, uint32_t md_pages_reserved, const char *md_file_path, size_t pbuf_size); +static hid_t init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, + hbool_t is_writer, uint32_t md_pages_reserved, + const char *md_file_path, size_t pbuf_size); /*------------------------------------------------------------------------- * Function: init_vfd_swmr_config_fapl @@ -72,31 +72,32 @@ init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint *------------------------------------------------------------------------- */ static hid_t -init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, - hbool_t is_writer, uint32_t md_pages_reserved, const char *md_file_path, size_t pbuf_size) +init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, + hbool_t is_writer, uint32_t md_pages_reserved, const char *md_file_path, + size_t pbuf_size) { hid_t fapl; HDmemset(config, 0, sizeof(*config)); - config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; - config->tick_len = tick_len; - config->max_lag = max_lag; - config->writer = is_writer; + config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; + config->tick_len = tick_len; + config->max_lag = max_lag; + config->writer = is_writer; config->md_pages_reserved = md_pages_reserved; HDstrcpy(config->md_file_path, md_file_path); /* Create a copy of the file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) return H5I_INVALID_HID; - if(H5Pset_vfd_swmr_config(fapl, config) < 0) { + if (H5Pset_vfd_swmr_config(fapl, config) < 0) { (void)H5Pclose(fapl); return H5I_INVALID_HID; } /* Enable page buffering */ - if(pbuf_size != 0 && H5Pset_page_buffer_size(fapl, pbuf_size, 0, 0) < 0) { + if (pbuf_size != 0 && H5Pset_page_buffer_size(fapl, pbuf_size, 0, 0) < 0) { (void)H5Pclose(fapl); return H5I_INVALID_HID; } @@ -104,7 +105,6 @@ init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint return fapl; } /* init_vfd_swmr_config_fapl() */ - /*------------------------------------------------------------------------- * Function: test_fapl() * @@ -127,65 +127,73 @@ init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint static unsigned test_fapl(void) { - hid_t fapl = -1; /* File access property list */ - H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */ - herr_t ret; /* Return value */ + hid_t fapl = -1; /* File access property list */ + H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */ + herr_t ret; /* Return value */ TESTING("Configure VFD SWMR with fapl"); /* Allocate memory for the configuration structure */ - if((my_config = HDmalloc(sizeof(*my_config))) == NULL) + if ((my_config = HDmalloc(sizeof(*my_config))) == NULL) FAIL_STACK_ERROR; HDmemset(my_config, 0, sizeof(*my_config)); /* Get a copy of the file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Should get invalid VFD SWMR config info */ - if(H5Pget_vfd_swmr_config(fapl, my_config) < 0) + if (H5Pget_vfd_swmr_config(fapl, my_config) < 0) TEST_ERROR; /* Verify that the version is incorrect */ - if(my_config->version >= H5F__CURR_VFD_SWMR_CONFIG_VERSION) + if (my_config->version >= H5F__CURR_VFD_SWMR_CONFIG_VERSION) TEST_ERROR; /* Should fail: version is 0 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_vfd_swmr_config(fapl, my_config); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR; /* Set valid version */ my_config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; /* Set valid tick_len */ - my_config->tick_len = 3; + my_config->tick_len = 3; /* Should fail: max_lag is 2 */ my_config->max_lag = 2; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_vfd_swmr_config(fapl, my_config); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR; /* Set valid max_lag */ my_config->max_lag = 3; /* Should fail: md_pages_reserved is 0 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_vfd_swmr_config(fapl, my_config); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR; /* Set valid md_pages_reserved */ my_config->md_pages_reserved = 2; /* Should fail: empty md_file_path */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Pset_vfd_swmr_config(fapl, my_config); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR; /* Set md_file_path */ @@ -193,44 +201,45 @@ test_fapl(void) my_config->writer = TRUE; /* Should succeed in setting the configuration info */ - if(H5Pset_vfd_swmr_config(fapl, my_config) < 0) + if (H5Pset_vfd_swmr_config(fapl, my_config) < 0) TEST_ERROR; /* Clear the configuration structure */ HDmemset(my_config, 0, sizeof(H5F_vfd_swmr_config_t)); /* Retrieve the configuration info just set */ - if(H5Pget_vfd_swmr_config(fapl, my_config) < 0) + if (H5Pget_vfd_swmr_config(fapl, my_config) < 0) TEST_ERROR; /* Verify the configuration info */ - if(my_config->version < H5F__CURR_VFD_SWMR_CONFIG_VERSION) + if (my_config->version < H5F__CURR_VFD_SWMR_CONFIG_VERSION) TEST_ERROR; - if(my_config->md_pages_reserved != 2) + if (my_config->md_pages_reserved != 2) TEST_ERROR; - if(HDstrcmp(my_config->md_file_path, MD_FILENAME) != 0) + if (HDstrcmp(my_config->md_file_path, MD_FILENAME) != 0) TEST_ERROR; /* Close the file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(my_config) + if (my_config) HDfree(my_config); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; - if(my_config) + } + H5E_END_TRY; + if (my_config) HDfree(my_config); return 1; } /* test_fapl() */ - /*------------------------------------------------------------------------- * Function: test_file_fapl() * @@ -254,166 +263,174 @@ error: static unsigned test_file_fapl(void) { - hid_t fid = -1; /* File ID */ - hid_t fid2 = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t fapl1 = -1; /* File access property list ID */ - hid_t fapl2 = -1; /* File access property list ID */ - hid_t file_fapl = -1; /* File access property list ID associated with the file */ - H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *file_config = NULL; /* Configuration for VFD SWMR */ + hid_t fid = -1; /* File ID */ + hid_t fid2 = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl1 = -1; /* File access property list ID */ + hid_t fapl2 = -1; /* File access property list ID */ + hid_t file_fapl = -1; /* File access property list ID associated with the file */ + H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *file_config = NULL; /* Configuration for VFD SWMR */ TESTING("VFD SWMR configuration for the file and fapl"); /* Should succeed without VFD SWMR configured */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Allocate memory for the configuration structure */ - if((config1 = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((config1 = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) FAIL_STACK_ERROR; - if((config2 = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((config2 = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) FAIL_STACK_ERROR; - if((file_config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((file_config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) FAIL_STACK_ERROR; /* Configured as VFD SWMR reader + no page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, FALSE, 2, MD_FILENAME, 0); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) TEST_ERROR /* Should fail to create: file access is writer but VFD SWMR config is reader */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl1); - } H5E_END_TRY; - if(fid >= 0) + } + H5E_END_TRY; + if (fid >= 0) TEST_ERROR; - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR /* Configured as VFD SWMR writer + no page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, TRUE, 2, MD_FILENAME, 0); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) TEST_ERROR /* Should fail to create: page buffering and paged aggregation not enabled */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl1); - } H5E_END_TRY; - if(fid >= 0) + } + H5E_END_TRY; + if (fid >= 0) TEST_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; /* Should fail to create: no page buffering */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1); - } H5E_END_TRY; - if(fid >= 0) + } + H5E_END_TRY; + if (fid >= 0) TEST_ERROR; - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR /* Configured as VFD SWMR writer + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, TRUE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) TEST_ERROR /* Should succeed to create the file: paged aggregation and page buffering enabled */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) TEST_ERROR; /* Get the file's file access property list */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Retrieve the VFD SWMR configuration from file_fapl */ - if(H5Pget_vfd_swmr_config(file_fapl, file_config) < 0) + if (H5Pget_vfd_swmr_config(file_fapl, file_config) < 0) TEST_ERROR; /* Verify the retrieved info is the same as config1 */ - if(HDmemcmp(config1, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) + if (HDmemcmp(config1, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) TEST_ERROR; /* Closing */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR; /* Should fail to open: file access is reader but VFD SWMR config is writer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl1); - } H5E_END_TRY; - if(fid >= 0) + } + H5E_END_TRY; + if (fid >= 0) TEST_ERROR; /* Should succeed to open: file access and VFD SWMR config are consistent */ - if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR; /* Get the file's file access property list */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Clear info in file_config */ HDmemset(file_config, 0, sizeof(H5F_vfd_swmr_config_t)); /* Retrieve the VFD SWMR configuration from file_fapl */ - if(H5Pget_vfd_swmr_config(file_fapl, file_config) < 0) + if (H5Pget_vfd_swmr_config(file_fapl, file_config) < 0) TEST_ERROR; /* Verify the retrieved info is the same as config1 */ - if(HDmemcmp(config1, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) + if (HDmemcmp(config1, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) TEST_ERROR; /* Closing */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; /* Set up different VFD SWMR configuration + page_buffering */ fapl2 = init_vfd_swmr_config_fapl(config2, 4, 10, TRUE, 2, MD_FILENAME, 4096); - if(fapl2 == H5I_INVALID_HID) + if (fapl2 == H5I_INVALID_HID) TEST_ERROR /* Should succeed to open the file as VFD SWMR writer */ - if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl2)) < 0) + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR; /* Get the file's file access property list */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Clear info in file_config */ HDmemset(file_config, 0, sizeof(H5F_vfd_swmr_config_t)); /* Retrieve the VFD SWMR configuration from file_fapl */ - if(H5Pget_vfd_swmr_config(file_fapl, file_config) < 0) + if (H5Pget_vfd_swmr_config(file_fapl, file_config) < 0) TEST_ERROR; /* Verify the retrieved info is NOT the same as config1 */ - if(HDmemcmp(config1, file_config, sizeof(H5F_vfd_swmr_config_t)) == 0) + if (HDmemcmp(config1, file_config, sizeof(H5F_vfd_swmr_config_t)) == 0) TEST_ERROR; /* Verify the retrieved info is the same as config2 */ - if(HDmemcmp(config2, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) + if (HDmemcmp(config2, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) TEST_ERROR; /* The file previously opened as VDF SWMR writer is still open */ @@ -421,96 +438,99 @@ test_file_fapl(void) /* Set up as VFD SWMR writer in config1 but different from config2 */ fapl1 = init_vfd_swmr_config_fapl(config1, 3, 8, TRUE, 3, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) TEST_ERROR; /* Re-open the same file with config1 */ /* Should fail to open since config1 is different from config2 setting */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1); - } H5E_END_TRY; - if(fid2 >= 0) + } + H5E_END_TRY; + if (fid2 >= 0) TEST_ERROR; /* Close fapl1 */ - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; /* Set up as VFD SWMR reader in config1 which is same as config2 */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, TRUE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) TEST_ERROR; /* Re-open the same file as VFD SWMR writer */ /* Should succeed since config1 is same as the setting in config2 */ - if((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR /* Close fapl1 */ - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; HDmemset(file_config, 0, sizeof(H5F_vfd_swmr_config_t)); /* Get the file's file access property list */ - if((file_fapl = H5Fget_access_plist(fid)) < 0) + if ((file_fapl = H5Fget_access_plist(fid)) < 0) FAIL_STACK_ERROR; /* Retrieve the VFD SWMR configuration from file_fapl */ - if(H5Pget_vfd_swmr_config(file_fapl, file_config) < 0) + if (H5Pget_vfd_swmr_config(file_fapl, file_config) < 0) TEST_ERROR; /* Should be the same as config1 */ - if(HDmemcmp(config1, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) + if (HDmemcmp(config1, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) TEST_ERROR; /* Should be the the same as config2 */ - if(HDmemcmp(config2, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) + if (HDmemcmp(config2, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0) TEST_ERROR; /* Closing */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR; - if(H5Pclose(file_fapl) < 0) + if (H5Pclose(file_fapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free buffers */ - if(config1) + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); - if(file_config) + if (file_config) HDfree(file_config); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl1); H5Pclose(fapl2); H5Pclose(file_fapl); H5Pclose(fcpl); H5Fclose(fid); H5Fclose(fid2); - } H5E_END_TRY; - if(config1) + } + H5E_END_TRY; + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); - if(file_config) + if (file_config) HDfree(file_config); return 1; } /* test_file_fapl() */ - /*------------------------------------------------------------------------- * Function: test_file_end_tick() * @@ -527,96 +547,98 @@ error: static unsigned test_file_end_tick(void) { - hid_t fid1 = H5I_INVALID_HID; /* File ID */ - hid_t fid2 = H5I_INVALID_HID; /* File ID */ - hid_t fid3 = H5I_INVALID_HID; /* File ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ - hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ - hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ - hid_t fapl3 = H5I_INVALID_HID; /* File access property list ID */ - H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config3 = NULL; /* Configuration for VFD SWMR */ - H5F_t *f1, *f2, *f3; /* File pointer */ - uint64_t s1 = 0; /* Saved tick_num */ - uint64_t s2 = 0; /* Saved tick_num */ - uint64_t s3 = 0; /* Saved tick_num */ - int ret; /* Return status */ + hid_t fid1 = H5I_INVALID_HID; /* File ID */ + hid_t fid2 = H5I_INVALID_HID; /* File ID */ + hid_t fid3 = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ + hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ + hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ + hid_t fapl3 = H5I_INVALID_HID; /* File access property list ID */ + H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config3 = NULL; /* Configuration for VFD SWMR */ + H5F_t * f1, *f2, *f3; /* File pointer */ + uint64_t s1 = 0; /* Saved tick_num */ + uint64_t s2 = 0; /* Saved tick_num */ + uint64_t s3 = 0; /* Saved tick_num */ + int ret; /* Return status */ TESTING("H5Fvfd_swmr_end_tick()"); /* Create a file without VFD SWMR configured */ - if((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Should fail to trigger EOT */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fvfd_swmr_end_tick(fid1); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR; /* Close the file */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR; /* Allocate memory for the configuration structure */ - if((config1 = HDmalloc(sizeof(*config1))) == NULL) + if ((config1 = HDmalloc(sizeof(*config1))) == NULL) FAIL_STACK_ERROR; - if((config2 = HDmalloc(sizeof(*config2))) == NULL) + if ((config2 = HDmalloc(sizeof(*config2))) == NULL) FAIL_STACK_ERROR; - if((config3 = HDmalloc(sizeof(*config3))) == NULL) + if ((config3 = HDmalloc(sizeof(*config3))) == NULL) FAIL_STACK_ERROR; /* Configured file 1 as VFD SWMR writer + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 10, 15, TRUE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Configured file 2 as VFD SWMR writer + page buffering */ fapl2 = init_vfd_swmr_config_fapl(config2, 5, 6, TRUE, 2, MD_FILENAME2, 4096); - if(fapl2 == H5I_INVALID_HID) + if (fapl2 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Configured file 3 as VFD SWMR writer + page buffering */ fapl3 = init_vfd_swmr_config_fapl(config3, 3, 6, TRUE, 2, MD_FILENAME3, 4096); - if(fapl3 == H5I_INVALID_HID) + if (fapl3 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; /* Create file 1 with VFD SWMR writer */ - if((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) + if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) TEST_ERROR; /* Keep file 1 opened */ /* Create file 2 with VFD SWMR writer */ - if((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Create file 3 with VFD SWMR writer */ - if((fid3 = H5Fcreate(FILENAME3, H5F_ACC_TRUNC, fcpl, fapl3)) < 0) + if ((fid3 = H5Fcreate(FILENAME3, H5F_ACC_TRUNC, fcpl, fapl3)) < 0) TEST_ERROR; - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) FAIL_STACK_ERROR; /* Open file 2 as VFD SWMR writer */ - if((fid2 = H5Fopen(FILENAME2, H5F_ACC_RDWR, fapl2)) < 0) + if ((fid2 = H5Fopen(FILENAME2, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR; /* Open file 3 as VFD SWMR writer */ - if((fid3 = H5Fopen(FILENAME3, H5F_ACC_RDWR, fapl3)) < 0) + if ((fid3 = H5Fopen(FILENAME3, H5F_ACC_RDWR, fapl3)) < 0) TEST_ERROR; - /* Get file pointer for the 3 files */ + /* Get file pointer for the 3 files */ f1 = H5VL_object(fid1); f2 = H5VL_object(fid2); f3 = H5VL_object(fid3); @@ -627,74 +649,75 @@ test_file_end_tick(void) s3 = f3->shared->tick_num; /* Trigger EOT for file 2 */ - if(H5Fvfd_swmr_end_tick(fid2) < 0) + if (H5Fvfd_swmr_end_tick(fid2) < 0) TEST_ERROR; /* file 2: tick_num should increase or at least same as previous tick_num */ - if(f2->shared->tick_num < s2) + if (f2->shared->tick_num < s2) TEST_ERROR; /* Disable EOT for file 2 */ - if(H5Fvfd_swmr_disable_end_of_tick(fid2) < 0) + if (H5Fvfd_swmr_disable_end_of_tick(fid2) < 0) TEST_ERROR; /* Should fail to trigger end of tick processing for file 2 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fvfd_swmr_end_tick(fid2); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Trigger EOT for file 1 */ - if(H5Fvfd_swmr_end_tick(fid1) < 0) + if (H5Fvfd_swmr_end_tick(fid1) < 0) TEST_ERROR; /* file 1: tick_num should increase or at least same as previous tick_num */ - if(f1->shared->tick_num < s1) + if (f1->shared->tick_num < s1) TEST_ERROR; - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR; - /* Trigger EOT for file 3 */ - if(H5Fvfd_swmr_end_tick(fid3) < 0) + if (H5Fvfd_swmr_end_tick(fid3) < 0) TEST_ERROR; /* file 3: tick_num should increase or at least same as previous tick_num */ - if(f3->shared->tick_num < s3) + if (f3->shared->tick_num < s3) TEST_ERROR; - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) FAIL_STACK_ERROR; - /* Closing */ - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl3) < 0) + if (H5Pclose(fapl3) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free buffers */ - if(config1) + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); - if(config3) + if (config3) HDfree(config3); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl1); H5Pclose(fapl2); H5Pclose(fapl3); @@ -702,19 +725,19 @@ error: H5Fclose(fid1); H5Fclose(fid2); H5Fclose(fid3); - } H5E_END_TRY; + } + H5E_END_TRY; - if(config1) + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); - if(config3) + if (config3) HDfree(config3); return 1; } /* test_file_end_tick() */ - /*------------------------------------------------------------------------- * Function: test_writer_create_open_flush() * @@ -722,7 +745,7 @@ error: * --creating the HDF5 file * --flushing the HDF5 file * --opening an existing HDF5 file - * It will call the internal testing routine + * It will call the internal testing routine * H5F__vfd_swmr_writer_create_open_flush_test() to do the following: * --Open the metadata file * --Verify the file size is as expected (md_pages_reserved) @@ -743,83 +766,85 @@ error: static unsigned test_writer_create_open_flush(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t fcpl = -1; /* File creation property list */ - H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t fcpl = -1; /* File creation property list */ + H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */ TESTING("Create/Open/Flush an HDF5 file for VFD SWMR"); /* Allocate memory for the configuration structure */ - if((my_config = HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((my_config = HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) FAIL_STACK_ERROR; /* Set up the VFD SWMR configuration + page buffering */ fapl = init_vfd_swmr_config_fapl(my_config, 1, 3, TRUE, 2, MD_FILENAME, 4096); - if(fapl == H5I_INVALID_HID) + if (fapl == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; /* Create an HDF5 file with VFD SWMR configured */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Verify info in metadata file when creating the HDF5 file */ - if(H5F__vfd_swmr_writer_create_open_flush_test(fid, TRUE) < 0) + if (H5F__vfd_swmr_writer_create_open_flush_test(fid, TRUE) < 0) FAIL_STACK_ERROR; #ifdef LATER /* Will activate the test when flush is implemented */ /* Flush the HDF5 file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) FAIL_STACK_ERROR /* Verify info in metadata file when flushing the HDF5 file */ - if(H5F__vfd_swmr_writer_create_open_flush_test(fid, FALSE) < 0) + if (H5F__vfd_swmr_writer_create_open_flush_test(fid, FALSE) < 0) FAIL_STACK_ERROR #endif /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Re-open the file as VFD SWMR writer */ - if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Verify info in metadata file when reopening the HDF5 file */ - if(H5F__vfd_swmr_writer_create_open_flush_test(fid, FALSE) < 0) + if (H5F__vfd_swmr_writer_create_open_flush_test(fid, FALSE) < 0) FAIL_STACK_ERROR; /* Closing */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; - if(my_config) + if (my_config) HDfree(my_config); PASSED(); return 0; error: - if(my_config) + if (my_config) HDfree(my_config); - - H5E_BEGIN_TRY { + + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_writer_create_open_flush() */ @@ -833,17 +858,16 @@ decisleep(uint32_t tenths) H5_nanosleep(nsec); } - /*------------------------------------------------------------------------- * Function: test_writer_md() * - * Purpose: Verify info in the metadata file after updating with the + * Purpose: Verify info in the metadata file after updating with the * constructed index: (A), (B), (C), (D) - * It will call the internal testing routine + * It will call the internal testing routine * H5F__vfd_swmr_writer_md_test() to do the following: * --Update the metadata file with the input index via the * internal library routine H5F_update_vfd_swmr_metadata_file() - * --Verify the entries in the delayed list is as expected: + * --Verify the entries in the delayed list is as expected: * --num_dl_entries * --Open the metadata file, read and decode the header and index * --Verify header and index info just read from the metadata @@ -860,169 +884,169 @@ decisleep(uint32_t tenths) static unsigned test_writer_md(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t fcpl = -1; /* File creation property list */ - const unsigned num_entries = 10; /* index size */ - unsigned i = 0; /* Local index variables */ - uint8_t *buf = NULL; /* Data page from the page buffer */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - int *rwbuf = NULL; /* Data buffer for writing */ - H5O_info_t oinfo; /* Object metadata information */ - char dname[100]; /* Name of dataset */ - hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */ - hsize_t max_dims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ - hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - H5FD_vfd_swmr_idx_entry_t *index = NULL; /* Pointer to the index entries */ - H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t fcpl = -1; /* File creation property list */ + const unsigned num_entries = 10; /* index size */ + unsigned i = 0; /* Local index variables */ + uint8_t * buf = NULL; /* Data page from the page buffer */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + int * rwbuf = NULL; /* Data buffer for writing */ + H5O_info_t oinfo; /* Object metadata information */ + char dname[100]; /* Name of dataset */ + hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */ + hsize_t max_dims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ + hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ + H5FD_vfd_swmr_idx_entry_t *index = NULL; /* Pointer to the index entries */ + H5F_vfd_swmr_config_t * my_config = NULL; /* Configuration for VFD SWMR */ TESTING("Verify the metadata file for VFD SWMR writer"); /* Allocate memory for the configuration structure */ - if((my_config = HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((my_config = HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) FAIL_STACK_ERROR; /* Set up the VFD SWMR configuration + page buffering */ fapl = init_vfd_swmr_config_fapl(my_config, 1, 3, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE); - if(fapl == H5I_INVALID_HID) + if (fapl == H5I_INVALID_HID) FAIL_STACK_ERROR - + /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) + if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) FAIL_STACK_ERROR; /* Create an HDF5 file with VFD SWMR configured */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Allocate num_entries for the data buffer */ - if((buf = HDcalloc(num_entries, FS_PAGE_SIZE)) == NULL) + if ((buf = HDcalloc(num_entries, FS_PAGE_SIZE)) == NULL) FAIL_STACK_ERROR; /* Allocate memory for num_entries index */ index = HDcalloc(num_entries, sizeof(H5FD_vfd_swmr_idx_entry_t)); - if(NULL == index) + if (NULL == index) FAIL_STACK_ERROR; /* (A) Construct index for updating the metadata file */ - for(i = 0; i < num_entries; i++) { - index[i].hdf5_page_offset = 3 + 7 * i; + for (i = 0; i < num_entries; i++) { + index[i].hdf5_page_offset = 3 + 7 * i; index[i].md_file_page_offset = 1 + (num_entries - i) * 5; - index[i].length = (uint32_t)FS_PAGE_SIZE; - index[i].entry_ptr = &buf[i * FS_PAGE_SIZE]; + index[i].length = (uint32_t)FS_PAGE_SIZE; + index[i].entry_ptr = &buf[i * FS_PAGE_SIZE]; } /* Update with index and verify info in the metadata file */ /* Also verify that 0 entries will be on the delayed list */ - if(H5F__vfd_swmr_writer_md_test(fid, num_entries, index, 0) < 0) + if (H5F__vfd_swmr_writer_md_test(fid, num_entries, index, 0) < 0) TEST_ERROR /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* Set to use chunked dataset */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR /* Create dataspace */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) FAIL_STACK_ERROR /* Perform activities to ensure that max_lag ticks elapse */ - for(i = 0; i < my_config->max_lag + 1; i++) { + for (i = 0; i < my_config->max_lag + 1; i++) { decisleep(my_config->tick_len); /* Create a chunked dataset */ HDsprintf(dname, "dset %d", i); - if((did = H5Dcreate2(fid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get dataset object header address */ - if(H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR } /* (B) Update every other entry in the index */ - for(i = 0; i < num_entries; i+= 2) + for (i = 0; i < num_entries; i += 2) index[i].entry_ptr = &buf[i * FS_PAGE_SIZE]; /* Update with index and verify info in the metadata file */ /* Also verify that 5 entries will be on the delayed list */ - if(H5F__vfd_swmr_writer_md_test(fid, num_entries, index, 5) < 0) + if (H5F__vfd_swmr_writer_md_test(fid, num_entries, index, 5) < 0) TEST_ERROR /* Allocate memory for the read/write buffer */ - if((rwbuf = HDmalloc(sizeof(*rwbuf) * (50 * 20))) == NULL) + if ((rwbuf = HDmalloc(sizeof(*rwbuf) * (50 * 20))) == NULL) FAIL_STACK_ERROR; - for(i = 0; i < (50 * 20); i++) + for (i = 0; i < (50 * 20); i++) rwbuf[i] = (int)i; /* Perform activities to ensure that max_lag ticks elapse */ - for(i = 0; i < my_config->max_lag + 1; i++) { + for (i = 0; i < my_config->max_lag + 1; i++) { decisleep(my_config->tick_len); /* Open the dataset */ HDsprintf(dname, "dset %d", i); - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rwbuf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rwbuf) < 0) FAIL_STACK_ERROR /* Get dataset object info */ - if(H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR } /* (C) Update every 3 entry in the index */ - for(i = 0; i < num_entries; i+= 3) + for (i = 0; i < num_entries; i += 3) index[i].entry_ptr = &buf[i * FS_PAGE_SIZE]; /* Update with index and verify info in the metadata file */ /* Also verify that 4 entries will be on the delayed list */ - if(H5F__vfd_swmr_writer_md_test(fid, num_entries, index, 4) < 0) + if (H5F__vfd_swmr_writer_md_test(fid, num_entries, index, 4) < 0) TEST_ERROR /* Clear the read/write buffer */ HDmemset(rwbuf, 0, sizeof(sizeof(int) * (50 * 20))); /* Perform activities to ensure that max_lag ticks elapse */ - for(i = 0; i < my_config->max_lag + 1; i++) { + for (i = 0; i < my_config->max_lag + 1; i++) { decisleep(my_config->tick_len); /* Open the dataset */ HDsprintf(dname, "dset %d", i); - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Read from the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rwbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rwbuf) < 0) FAIL_STACK_ERROR /* Get dataset object info */ - if(H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR } @@ -1032,52 +1056,54 @@ test_writer_md(void) /* Update with index and verify info in the metadata file */ /* Also verify that 2 entries will be on the delayed list */ - if(H5F__vfd_swmr_writer_md_test(fid, num_entries, index, 2) < 0) + if (H5F__vfd_swmr_writer_md_test(fid, num_entries, index, 2) < 0) TEST_ERROR /* Closing */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free resources */ - if(my_config) + if (my_config) HDfree(my_config); - if(buf) + if (buf) HDfree(buf); - if(rwbuf) + if (rwbuf) HDfree(rwbuf); - if(index) + if (index) HDfree(index); PASSED(); return 0; error: - if(my_config) + if (my_config) HDfree(my_config); - if(buf) + if (buf) HDfree(buf); - if(rwbuf) + if (rwbuf) HDfree(rwbuf); - if(index) + if (index) HDfree(index); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); H5Pclose(dcpl); H5Pclose(fapl); H5Pclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_writer__md() */ @@ -1104,7 +1130,7 @@ test_multiple_file_opens_concur(void) HDputs(" Test skipped (unistd.h not present)"); return 0; -} /* test_multiple_file_opens_concur() */ +} /* test_multiple_file_opens_concur() */ static unsigned test_disable_enable_eot_concur(void) @@ -1133,7 +1159,7 @@ test_file_end_tick_concur(void) /*------------------------------------------------------------------------- * Function: test_reader_md_concur() * - * Purpose: Verify metadata file info updated by the writer is + * Purpose: Verify metadata file info updated by the writer is * what the reader obtained from the metadata file: * --Cases (A), (B), (C), (D), (E) * NOTE: Changes for page buffering/cache are not in place yet. @@ -1150,571 +1176,555 @@ test_file_end_tick_concur(void) static unsigned test_reader_md_concur(void) { - unsigned i = 0; /* Local index variables */ - uint8_t *buf = NULL; /* Data page from the page buffer */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t sid = -1; /* Dataspace ID */ - hid_t did = -1; /* Dataset ID */ - int *rwbuf = NULL; /* Data buffer for writing */ - H5O_info_t oinfo; /* Object metadata information */ - char dname[100]; /* Name of dataset */ - hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */ - hsize_t max_dims[2] = /* Dataset maximum dimension sizes */ + unsigned i = 0; /* Local index variables */ + uint8_t * buf = NULL; /* Data page from the page buffer */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did = -1; /* Dataset ID */ + int * rwbuf = NULL; /* Data buffer for writing */ + H5O_info_t oinfo; /* Object metadata information */ + char dname[100]; /* Name of dataset */ + hsize_t dims[2] = {50, 20}; /* Dataset dimension sizes */ + hsize_t max_dims[2] = /* Dataset maximum dimension sizes */ {H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - unsigned num_entries = 0 ; /* Number of entries in the index */ - H5FD_vfd_swmr_idx_entry_t *index = NULL; /* Pointer to the index entries */ - - hid_t fcpl = -1; /* File creation property list */ - hid_t fid_writer = -1; /* File ID for writer */ - hid_t fapl_writer = -1; /* File access property list for writer */ - H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */ - pid_t tmppid; /* Child process ID returned by waitpid */ - pid_t childpid = 0; /* Child process ID */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int child_exit_val; /* Exit status of the child */ - - int parent_pfd[2]; /* Pipe for parent process as writer */ - int child_pfd[2]; /* Pipe for child process as reader */ - int notify = 0; /* Notification between parent and child */ - H5F_t *file_writer; /* File pointer for writer */ + hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ + unsigned num_entries = 0; /* Number of entries in the index */ + H5FD_vfd_swmr_idx_entry_t *index = NULL; /* Pointer to the index entries */ + + hid_t fcpl = -1; /* File creation property list */ + hid_t fid_writer = -1; /* File ID for writer */ + hid_t fapl_writer = -1; /* File access property list for writer */ + H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */ + pid_t tmppid; /* Child process ID returned by waitpid */ + pid_t childpid = 0; /* Child process ID */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + + int parent_pfd[2]; /* Pipe for parent process as writer */ + int child_pfd[2]; /* Pipe for child process as reader */ + int notify = 0; /* Notification between parent and child */ + H5F_t *file_writer; /* File pointer for writer */ TESTING("Verify the metadata file for VFD SWMR reader"); /* Allocate memory for the configuration structure */ - if((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) + if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) FAIL_STACK_ERROR; /* Set up the VFD SWMR configuration + page buffering */ fapl_writer = init_vfd_swmr_config_fapl(config_writer, 1, 3, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE); - if(fapl_writer == H5I_INVALID_HID) + if (fapl_writer == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) + if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) FAIL_STACK_ERROR; /* Create an HDF5 file with VFD SWMR configured */ - if((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) + if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid_writer) < 0) + if (H5Fclose(fid_writer) < 0) FAIL_STACK_ERROR; /* Create 2 pipes */ - if(HDpipe(parent_pfd) < 0) + if (HDpipe(parent_pfd) < 0) FAIL_STACK_ERROR - if(HDpipe(child_pfd) < 0) + if (HDpipe(child_pfd) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR /* * Child process as reader */ - if(childpid == 0) { - int child_notify = 0; /* Notification between child and parent */ - hid_t fid_reader = -1; /* File ID for reader */ - hid_t fapl_reader = -1; /* File access property list for reader */ - H5F_t *file_reader; /* File pointer for reader */ - H5F_vfd_swmr_config_t *config_reader = NULL; /* VFD SWMR configuration for reader */ - unsigned child_num_entries = 0; /* Number of entries passed to reader */ - H5FD_vfd_swmr_idx_entry_t *child_index = NULL; /* Index passed to reader */ + if (childpid == 0) { + int child_notify = 0; /* Notification between child and parent */ + hid_t fid_reader = -1; /* File ID for reader */ + hid_t fapl_reader = -1; /* File access property list for reader */ + H5F_t * file_reader; /* File pointer for reader */ + H5F_vfd_swmr_config_t * config_reader = NULL; /* VFD SWMR configuration for reader */ + unsigned child_num_entries = 0; /* Number of entries passed to reader */ + H5FD_vfd_swmr_idx_entry_t *child_index = NULL; /* Index passed to reader */ /* Close unused write end for writer pipe */ - if(HDclose(parent_pfd[1]) < 0) + if (HDclose(parent_pfd[1]) < 0) HDexit(EXIT_FAILURE); /* Close unused read end for reader pipe */ - if(HDclose(child_pfd[0]) < 0) + if (HDclose(child_pfd[0]) < 0) HDexit(EXIT_FAILURE); /* Free unused configuration */ - if(config_writer) + if (config_writer) HDfree(config_writer); - /* + /* * Case A: reader - * --verify an empty index + * --verify an empty index */ /* Wait for notification 1 from parent to start verification */ - while(child_notify != 1) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Allocate memory for the configuration structure */ - if((config_reader = HDmalloc(sizeof(*config_reader))) == NULL) + if ((config_reader = HDmalloc(sizeof(*config_reader))) == NULL) HDexit(EXIT_FAILURE); /* Set up the VFD SWMR configuration as reader + page buffering */ fapl_reader = init_vfd_swmr_config_fapl(config_reader, 1, 3, FALSE, 256, MD_FILENAME, FS_PAGE_SIZE); - if(fapl_reader == H5I_INVALID_HID) + if (fapl_reader == H5I_INVALID_HID) HDexit(EXIT_FAILURE); /* Open the test file as reader */ - if((fid_reader = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Get file pointer */ file_reader = H5VL_object(fid_reader); /* Read and verify header and an empty index in the metadata file */ - if(H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, 0, NULL) < 0) + if (H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, 0, NULL) < 0) HDexit(EXIT_FAILURE); /* Send notification 2 to parent that the verification is complete */ child_notify = 2; - if(HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) + if (HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - /* + /* * Case B: reader * --verify index as sent from writer */ /* Wait for notification 3 from parent to start verification */ - while(child_notify != 3) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 3) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Read num_entries from writer pipe */ - if(HDread(parent_pfd[0], &child_num_entries, sizeof(int)) < 0) + if (HDread(parent_pfd[0], &child_num_entries, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - + /* Free previous index */ - if(child_index) + if (child_index) HDfree(child_index); - if(child_num_entries) { + if (child_num_entries) { /* Allocate memory for num_entries index */ - if((child_index = HDcalloc(child_num_entries, - sizeof(*child_index))) == NULL) + if ((child_index = HDcalloc(child_num_entries, sizeof(*child_index))) == NULL) HDexit(EXIT_FAILURE); /* Read index from writer pipe */ - if(HDread(parent_pfd[0], child_index, - child_num_entries * sizeof(*child_index)) < 0) + if (HDread(parent_pfd[0], child_index, child_num_entries * sizeof(*child_index)) < 0) HDexit(EXIT_FAILURE); } - /* Read and verify the expected header and index info in the - * metadata file - */ - if(H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, - child_num_entries, child_index) < 0) + /* Read and verify the expected header and index info in the + * metadata file + */ + if (H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, child_num_entries, child_index) < 0) HDexit(EXIT_FAILURE); /* Send notification 4 to parent that the verification is complete */ child_notify = 4; - if(HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) + if (HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - /* + /* * Case C: reader * --verify index as sent from writer */ /* Wait for notification 5 from parent to start verification */ - while(child_notify != 5) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 5) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Read num_entries from writer pipe */ - if(HDread(parent_pfd[0], &child_num_entries, sizeof(int)) < 0) + if (HDread(parent_pfd[0], &child_num_entries, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - + /* Free previous index */ - if(child_index) + if (child_index) HDfree(child_index); - if(child_num_entries) { + if (child_num_entries) { /* Allocate memory for num_entries index */ - if((child_index = (H5FD_vfd_swmr_idx_entry_t *) - HDcalloc(child_num_entries, - sizeof(H5FD_vfd_swmr_idx_entry_t))) == NULL) + if ((child_index = (H5FD_vfd_swmr_idx_entry_t *)HDcalloc( + child_num_entries, sizeof(H5FD_vfd_swmr_idx_entry_t))) == NULL) HDexit(EXIT_FAILURE); /* Read index from writer pipe */ - if(HDread(parent_pfd[0], child_index, - child_num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) + if (HDread(parent_pfd[0], child_index, child_num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) HDexit(EXIT_FAILURE); } - /* Read and verify the expected header and index info in the - * metadata file + /* Read and verify the expected header and index info in the + * metadata file */ - if(H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, - child_num_entries, child_index) < 0) + if (H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, child_num_entries, child_index) < 0) HDexit(EXIT_FAILURE); /* Send notification 6 to parent that the verification is complete */ child_notify = 6; - if(HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) + if (HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - /* + /* * Case D: reader * --verify index as sent from writer */ /* Wait for notification 7 from parent to start verification */ - while(child_notify != 7) { + while (child_notify != 7) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Read num_entries from writer pipe */ - if(HDread(parent_pfd[0], &child_num_entries, sizeof(int)) < 0) + if (HDread(parent_pfd[0], &child_num_entries, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - + /* Free previous index */ - if(child_index) + if (child_index) HDfree(child_index); - if(child_num_entries) { + if (child_num_entries) { /* Allocate memory for num_entries index */ - if((child_index = (H5FD_vfd_swmr_idx_entry_t *) - HDcalloc(child_num_entries, - sizeof(H5FD_vfd_swmr_idx_entry_t))) == NULL) + if ((child_index = (H5FD_vfd_swmr_idx_entry_t *)HDcalloc( + child_num_entries, sizeof(H5FD_vfd_swmr_idx_entry_t))) == NULL) HDexit(EXIT_FAILURE); /* Read index from writer pipe */ - if(HDread(parent_pfd[0], child_index, - child_num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) + if (HDread(parent_pfd[0], child_index, child_num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) HDexit(EXIT_FAILURE); } - /* Read and verify the expected header and index info in the - * metadata file + /* Read and verify the expected header and index info in the + * metadata file */ - if(H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, - child_num_entries, child_index) < 0) + if (H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, child_num_entries, child_index) < 0) HDexit(EXIT_FAILURE); /* Send notification 8 to parent that the verification is complete */ child_notify = 8; - if(HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) + if (HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - /* + /* * Case E: reader - * --verify an empty index + * --verify an empty index */ /* Wait for notification 9 from parent to start verification */ - while(child_notify != 9) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 9) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Read and verify header and an empty index in the metadata file */ - if(H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, 0, NULL) < 0) + if (H5FD__vfd_swmr_reader_md_test(file_reader->shared->lf, 0, NULL) < 0) HDexit(EXIT_FAILURE); /* Free resources */ - if(child_index) + if (child_index) HDfree(child_index); - if(config_reader) + if (config_reader) HDfree(config_reader); /* Closing */ - if(H5Fclose(fid_reader) < 0) + if (H5Fclose(fid_reader) < 0) HDexit(EXIT_FAILURE); - if(H5Pclose(fapl_reader) < 0) + if (H5Pclose(fapl_reader) < 0) HDexit(EXIT_FAILURE); /* Close the pipes */ - if(HDclose(parent_pfd[0]) < 0) + if (HDclose(parent_pfd[0]) < 0) HDexit(EXIT_FAILURE); - if(HDclose(child_pfd[1]) < 0) + if (HDclose(child_pfd[1]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* end child process */ - /* + /* * Parent process as writer */ /* Close unused read end for writer pipe */ - if(HDclose(parent_pfd[0]) < 0) + if (HDclose(parent_pfd[0]) < 0) FAIL_STACK_ERROR /* Close unused write end for reader pipe */ - if(HDclose(child_pfd[1]) < 0) + if (HDclose(child_pfd[1]) < 0) FAIL_STACK_ERROR - /* + /* * Case A: writer * --open the file as VFD SWMR writer */ /* Open as VFD SWMR writer */ - if((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) + if ((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Send notification 1 to reader to start verfication */ notify = 1; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; - /* + /* * Case B: writer * --create datasets to ensure ticks elapse - * --construct 12 entries in the index + * --construct 12 entries in the index * --update the metadata file with the index */ /* Wait for notification 2 from reader that the verifcation is complete */ - while(notify != 2) { - if(HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) + while (notify != 2) { + if (HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; } /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR /* Set to use chunked dataset */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) FAIL_STACK_ERROR /* Create dataspace */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) FAIL_STACK_ERROR /* Perform activities to ensure that ticks elapse */ - for(i = 0; i < config_writer->max_lag + 1; i++) { + for (i = 0; i < config_writer->max_lag + 1; i++) { decisleep(config_writer->tick_len); /* Create a chunked dataset */ HDsprintf(dname, "dset %d", i); - if((did = H5Dcreate2(fid_writer, dname, H5T_NATIVE_INT, sid, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid_writer, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get dataset object header address */ - if(H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info(did, &oinfo, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR } num_entries = 12; /* Allocate num_entries for the data buffer */ - if((buf = HDcalloc(num_entries, FS_PAGE_SIZE)) == NULL) + if ((buf = HDcalloc(num_entries, FS_PAGE_SIZE)) == NULL) FAIL_STACK_ERROR; /* Allocate memory for num_entries index */ index = HDcalloc(num_entries, sizeof(H5FD_vfd_swmr_idx_entry_t)); - if(NULL == index) + if (NULL == index) FAIL_STACK_ERROR; /* Construct index for updating the metadata file */ - for(i = 0; i < num_entries; i++) { - index[i].hdf5_page_offset = 3 + 7 * i; + for (i = 0; i < num_entries; i++) { + index[i].hdf5_page_offset = 3 + 7 * i; index[i].md_file_page_offset = 1 + (num_entries - i) * 5; - index[i].length = (uint32_t)FS_PAGE_SIZE; - index[i].entry_ptr = &buf[i * FS_PAGE_SIZE]; + index[i].length = (uint32_t)FS_PAGE_SIZE; + index[i].entry_ptr = &buf[i * FS_PAGE_SIZE]; } /* Get the file pointer */ file_writer = H5VL_object(fid_writer); /* Update the metadata file with the index */ - if(H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0) + if (H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0) TEST_ERROR; /* Send notification 3 to child to start verification */ notify = 3; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Send num_entries to the reader */ - if(HDwrite(parent_pfd[1], &num_entries, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], &num_entries, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Send index to the reader */ - if(HDwrite(parent_pfd[1], index, - num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) + if (HDwrite(parent_pfd[1], index, num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) FAIL_STACK_ERROR; - /* + /* * Case C: writer * --write to the datasets to ensure ticks elapse - * --update 3 entries in the index + * --update 3 entries in the index * --update the metadata file with the index */ /* Wait for notification 4 from reader that the verifcation is complete */ - while(notify != 4) { - if(HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) + while (notify != 4) { + if (HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; } /* Allocate memory for the read/write buffer */ - if((rwbuf = HDmalloc(sizeof(*rwbuf) * (50 * 20))) == NULL) + if ((rwbuf = HDmalloc(sizeof(*rwbuf) * (50 * 20))) == NULL) FAIL_STACK_ERROR; - for(i = 0; i < (50 * 20); i++) + for (i = 0; i < (50 * 20); i++) rwbuf[i] = (int)i; /* Perform activities to ensure that max_lag ticks elapse */ - for(i = 0; i < config_writer->max_lag + 1; i++) { + for (i = 0; i < config_writer->max_lag + 1; i++) { decisleep(config_writer->tick_len); /* Open the dataset */ HDsprintf(dname, "dset %d", i); - if((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, rwbuf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rwbuf) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR } /* Update 3 entries in the index */ num_entries = 3; - for(i = 0; i < num_entries; i++) + for (i = 0; i < num_entries; i++) index[i].entry_ptr = &buf[i * FS_PAGE_SIZE]; - + /* Update the metadata file with the index */ - if(H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0) + if (H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0) TEST_ERROR; /* Send notification 5 to reader to start verification */ notify = 5; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Send num_entries to the reader */ - if(HDwrite(parent_pfd[1], &num_entries, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], &num_entries, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Send index to the reader */ - if(HDwrite(parent_pfd[1], index, - num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) + if (HDwrite(parent_pfd[1], index, num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) FAIL_STACK_ERROR; - /* + /* * Case D: writer * --read from the datasets to ensure ticks elapse - * --update 5 entries in the index + * --update 5 entries in the index * --update the metadata file with the index */ /* Wait for notification 6 from reader that the verifcation is complete */ - while(notify != 6) { - if(HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) + while (notify != 6) { + if (HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; } /* Perform activities to ensure that max_lag ticks elapse */ - for(i = 0; i < config_writer->max_lag + 1; i++) { + for (i = 0; i < config_writer->max_lag + 1; i++) { decisleep(config_writer->tick_len); /* Open the dataset */ HDsprintf(dname, "dset %d", i); - if((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Read from the dataset */ - if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, rwbuf) < 0) + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rwbuf) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR } /* Update 5 entries in the index */ num_entries = 5; - for(i = 0; i < num_entries; i++) + for (i = 0; i < num_entries; i++) index[i].entry_ptr = &buf[i * FS_PAGE_SIZE]; - + /* Update the metadata file with the index */ - if(H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0) + if (H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0) TEST_ERROR; /* Send notification 7 to reader to start verification */ notify = 7; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Send num_entries to the reader */ - if(HDwrite(parent_pfd[1], &num_entries, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], &num_entries, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Send index to the reader */ - if(HDwrite(parent_pfd[1], index, - num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) + if (HDwrite(parent_pfd[1], index, num_entries * sizeof(H5FD_vfd_swmr_idx_entry_t)) < 0) FAIL_STACK_ERROR; - /* + /* * Case E: writer * --write to the datasets again to ensure ticks elapse * --update the metadata file with an empty index */ /* Wait for notification 8 from reader that the verifcation is complete */ - while(notify != 8) { - if(HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) + while (notify != 8) { + if (HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; } /* Perform activities to ensure that ticks elapse */ - for(i = 0; i < config_writer->max_lag + 1; i++) { + for (i = 0; i < config_writer->max_lag + 1; i++) { decisleep(config_writer->tick_len); /* Open the dataset */ HDsprintf(dname, "dset %d", i); - if((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid_writer, dname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, rwbuf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rwbuf) < 0) FAIL_STACK_ERROR /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) FAIL_STACK_ERROR } /* Update the metadata file with 0 entries and NULL index */ - if(H5F_update_vfd_swmr_metadata_file(file_writer, 0, NULL) < 0) + if (H5F_update_vfd_swmr_metadata_file(file_writer, 0, NULL) < 0) TEST_ERROR; /* Send notification 8 to reader to start verification */ notify = 9; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* @@ -1722,64 +1732,66 @@ test_reader_md_concur(void) */ /* Close the pipes */ - if(HDclose(parent_pfd[1]) < 0) + if (HDclose(parent_pfd[1]) < 0) FAIL_STACK_ERROR; - if(HDclose(child_pfd[0]) < 0) + if (HDclose(child_pfd[0]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else { /* child process terminated abnormally */ + } + else { /* child process terminated abnormally */ TEST_ERROR } /* Closing */ - if(H5Fclose(fid_writer) < 0) + if (H5Fclose(fid_writer) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl_writer) < 0) + if (H5Pclose(fapl_writer) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free resources */ - if(config_writer) + if (config_writer) HDfree(config_writer); - if(buf) + if (buf) HDfree(buf); - if(rwbuf) + if (rwbuf) HDfree(rwbuf); - if(index) + if (index) HDfree(index); PASSED(); return 0; error: - if(config_writer) + if (config_writer) HDfree(config_writer); - if(buf) + if (buf) HDfree(buf); - if(rwbuf) + if (rwbuf) HDfree(rwbuf); - if(index) + if (index) HDfree(index); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_writer); H5Fclose(fid_writer); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_reader_md_concur() */ - /*------------------------------------------------------------------------- * Function: test_multiple_file_opens_concur() * @@ -1796,225 +1808,223 @@ error: static unsigned test_multiple_file_opens_concur(void) { - hid_t fcpl = H5I_INVALID_HID; - pid_t tmppid; /* Child process ID returned by waitpid */ - pid_t childpid = 0; /* Child process ID */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int child_exit_val; /* Exit status of the child */ - int parent_pfd[2]; /* Pipe for parent process as writer */ - int child_pfd[2]; /* Pipe for child process as reader */ - int notify = 0; /* Notification between parent and child */ - hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; - hid_t fapl1 = H5I_INVALID_HID, fapl2 = H5I_INVALID_HID; - H5F_vfd_swmr_config_t *config1 = NULL; /* VFD SWMR configuration */ - H5F_vfd_swmr_config_t *config2 = NULL; /* VFD SWMR configuration */ - H5F_t *f1, *f2; /* File pointer */ - eot_queue_entry_t *curr; + hid_t fcpl = H5I_INVALID_HID; + pid_t tmppid; /* Child process ID returned by waitpid */ + pid_t childpid = 0; /* Child process ID */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + int parent_pfd[2]; /* Pipe for parent process as writer */ + int child_pfd[2]; /* Pipe for child process as reader */ + int notify = 0; /* Notification between parent and child */ + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; + hid_t fapl1 = H5I_INVALID_HID, fapl2 = H5I_INVALID_HID; + H5F_vfd_swmr_config_t *config1 = NULL; /* VFD SWMR configuration */ + H5F_vfd_swmr_config_t *config2 = NULL; /* VFD SWMR configuration */ + H5F_t * f1, *f2; /* File pointer */ + eot_queue_entry_t * curr; TESTING("EOT queue entries when opening files concurrently with VFD SWMR"); /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) + if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) FAIL_STACK_ERROR; /* Create file A */ - if((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR; /* Create file B */ - if((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Create 2 pipes */ - if(HDpipe(parent_pfd) < 0) + if (HDpipe(parent_pfd) < 0) FAIL_STACK_ERROR - if(HDpipe(child_pfd) < 0) + if (HDpipe(child_pfd) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR /* * Child process */ - if(childpid == 0) { - int child_notify = 0; /* Notification between child and parent */ - hid_t fid_writer = -1; /* File ID for writer */ - hid_t fapl_writer = -1; /* File access property list for writer */ - H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR configuration for reader */ + if (childpid == 0) { + int child_notify = 0; /* Notification between child and parent */ + hid_t fid_writer = -1; /* File ID for writer */ + hid_t fapl_writer = -1; /* File access property list for writer */ + H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR configuration for reader */ /* Close unused write end for writer pipe */ - if(HDclose(parent_pfd[1]) < 0) + if (HDclose(parent_pfd[1]) < 0) HDexit(EXIT_FAILURE); /* Close unused read end for reader pipe */ - if(HDclose(child_pfd[0]) < 0) + if (HDclose(child_pfd[0]) < 0) HDexit(EXIT_FAILURE); - /* + /* * Set up and open file B as VFD SWMR writer */ /* Wait for notification 1 from parent before opening file B */ - while(child_notify != 1) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Allocate memory for VFD SMWR configuration */ - if((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) + if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) HDexit(EXIT_FAILURE); - /* Set the VFD SWMR configuration in fapl_writer + page buffering */ fapl_writer = init_vfd_swmr_config_fapl(config_writer, 1, 3, TRUE, 256, MD_FILENAME2, FS_PAGE_SIZE); - if(fapl_writer == H5I_INVALID_HID) + if (fapl_writer == H5I_INVALID_HID) HDexit(EXIT_FAILURE); /* Open file B as VFD SWMR writer */ - if((fid_writer = H5Fopen(FILENAME2, H5F_ACC_RDWR, fapl_writer)) < 0) + if ((fid_writer = H5Fopen(FILENAME2, H5F_ACC_RDWR, fapl_writer)) < 0) HDexit(EXIT_FAILURE); /* Send notification 2 to parent that file B is open */ child_notify = 2; - if(HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) + if (HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); /* Wait for notification 3 from parent before closing file B */ - while(child_notify != 3) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 3) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } - if(config_writer ) + if (config_writer) HDfree(config_writer); /* Close the file */ - if(H5Fclose(fid_writer) < 0) + if (H5Fclose(fid_writer) < 0) HDexit(EXIT_FAILURE); - if(H5Pclose(fapl_writer) < 0) + if (H5Pclose(fapl_writer) < 0) HDexit(EXIT_FAILURE); /* Send notification 4 to parent that file B is closed */ child_notify = 4; - if(HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) + if (HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); /* Close the pipes */ - if(HDclose(parent_pfd[0]) < 0) + if (HDclose(parent_pfd[0]) < 0) HDexit(EXIT_FAILURE); - if(HDclose(child_pfd[1]) < 0) + if (HDclose(child_pfd[1]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* end child process */ - /* + /* * Parent process */ /* Close unused read end for writer pipe */ - if(HDclose(parent_pfd[0]) < 0) + if (HDclose(parent_pfd[0]) < 0) FAIL_STACK_ERROR /* Close unused write end for reader pipe */ - if(HDclose(child_pfd[1]) < 0) + if (HDclose(child_pfd[1]) < 0) FAIL_STACK_ERROR - /* + /* * Set up and open file A as VFD SWMR writer */ /* Allocate memory for VFD SWMR configuration */ - if((config1 = HDmalloc(sizeof(*config1))) == NULL) + if ((config1 = HDmalloc(sizeof(*config1))) == NULL) FAIL_STACK_ERROR /* Set the VFD SWMR configuration in fapl1 + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 7, 10, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) FAIL_STACK_ERROR /* Open file A as VFD SWMR writer */ - if((fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f1 = H5VL_object(fid1))) + if (NULL == (f1 = H5VL_object(fid1))) FAIL_STACK_ERROR /* Head of EOT queue should be a writer */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || !curr->vfd_swmr_writer) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || !curr->vfd_swmr_writer) TEST_ERROR; /* The EOT queue's first entry should be f1 */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f1) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f1) TEST_ERROR; - /* Send notification 1 to child to open file B */ notify = 1; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Wait for notification 2 from child that file B is open */ - while(notify != 2) { - if(HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) + while (notify != 2) { + if (HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; } /* Open file B as VFD SWMR reader */ /* Allocate memory for VFD SWMR configuration */ - if((config2 = HDmalloc(sizeof(*config2))) == NULL) + if ((config2 = HDmalloc(sizeof(*config2))) == NULL) FAIL_STACK_ERROR /* Set the VFD SWMR configuration in fapl2 + page buffering */ fapl2 = init_vfd_swmr_config_fapl(config2, 1, 3, FALSE, 256, MD_FILENAME2, FS_PAGE_SIZE); - if(fapl2 == H5I_INVALID_HID) + if (fapl2 == H5I_INVALID_HID) FAIL_STACK_ERROR /* Open file B as VFD SWMR reader */ - if((fid2 = H5Fopen(FILENAME2, H5F_ACC_RDONLY, fapl2)) < 0) + if ((fid2 = H5Fopen(FILENAME2, H5F_ACC_RDONLY, fapl2)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f2 = H5VL_object(fid2))) + if (NULL == (f2 = H5VL_object(fid2))) FAIL_STACK_ERROR /* Head of EOT queue should NOT be a writer */ - if((curr = TAILQ_FIRST(&eot_queue_g)) != NULL && curr->vfd_swmr_writer) + if ((curr = TAILQ_FIRST(&eot_queue_g)) != NULL && curr->vfd_swmr_writer) TEST_ERROR; /* The EOT queue's first entry should be f2 */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f2) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f2) TEST_ERROR; /* Send notification 3 to child to close file B */ notify = 3; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* Wait for notification 4 from child that file B is closed */ - while(notify != 4) { - if(HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) + while (notify != 4) { + if (HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; } @@ -2023,62 +2033,64 @@ test_multiple_file_opens_concur(void) */ /* Close the pipes */ - if(HDclose(parent_pfd[1]) < 0) + if (HDclose(parent_pfd[1]) < 0) FAIL_STACK_ERROR; - if(HDclose(child_pfd[0]) < 0) + if (HDclose(child_pfd[0]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else { /* child process terminated abnormally */ + } + else { /* child process terminated abnormally */ TEST_ERROR } /* Closing */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free resources */ - if(config1) + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); PASSED(); return 0; error: - if(config1) + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl1); H5Pclose(fapl2); H5Fclose(fid1); H5Fclose(fid2); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_multiple_file_opens_concur() */ - /*------------------------------------------------------------------------- * Function: test_enable_disable_eot_concur() * @@ -2098,212 +2110,214 @@ error: static unsigned test_disable_enable_eot_concur(void) { - hid_t fcpl = -1; /* File creation property list */ - hid_t fid_writer = -1; /* File ID for writer */ - hid_t fapl_writer = -1; /* File access property list for writer */ - H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */ - pid_t tmppid; /* Child process ID returned by waitpid */ - pid_t childpid = 0; /* Child process ID */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int child_exit_val; /* Exit status of the child */ - - int parent_pfd[2]; /* Pipe for parent process as writer */ - int child_pfd[2]; /* Pipe for child process as reader */ - int notify = 0; /* Notification between parent and child */ + hid_t fcpl = -1; /* File creation property list */ + hid_t fid_writer = -1; /* File ID for writer */ + hid_t fapl_writer = -1; /* File access property list for writer */ + H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */ + pid_t tmppid; /* Child process ID returned by waitpid */ + pid_t childpid = 0; /* Child process ID */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + + int parent_pfd[2]; /* Pipe for parent process as writer */ + int child_pfd[2]; /* Pipe for child process as reader */ + int notify = 0; /* Notification between parent and child */ TESTING("Verify concurrent H5Fvfd_swmr_enable/disable_end_of_tick()"); /* Allocate memory for the configuration structure */ - if((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) + if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) FAIL_STACK_ERROR; /* Set up the VFD SWMR configuration + page buffering */ fapl_writer = init_vfd_swmr_config_fapl(config_writer, 1, 3, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE); - if(fapl_writer == H5I_INVALID_HID) + if (fapl_writer == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) + if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) FAIL_STACK_ERROR; /* Create an HDF5 file with VFD SWMR configured */ - if((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) + if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid_writer) < 0) + if (H5Fclose(fid_writer) < 0) FAIL_STACK_ERROR; /* Create 2 pipes */ - if(HDpipe(parent_pfd) < 0) + if (HDpipe(parent_pfd) < 0) FAIL_STACK_ERROR - if(HDpipe(child_pfd) < 0) + if (HDpipe(child_pfd) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR /* * Child process as reader */ - if(childpid == 0) { - int child_notify = 0; /* Notification between child and parent */ - hid_t fid_reader = H5I_INVALID_HID; /* File ID for reader */ - hid_t fid_reader2 = H5I_INVALID_HID; /* File ID for reader */ - hid_t fid_reader3 = H5I_INVALID_HID; /* File ID for reader */ - hid_t fapl_reader = H5I_INVALID_HID; /* File access property list for reader */ - H5F_vfd_swmr_config_t *config_reader = NULL; /* VFD SWMR configuration */ - H5F_t *file_reader; /* File pointer */ - eot_queue_entry_t *curr; /* Pointer to an entry on the EOT queue */ - unsigned count = 0; /* Counter */ + if (childpid == 0) { + int child_notify = 0; /* Notification between child and parent */ + hid_t fid_reader = H5I_INVALID_HID; /* File ID for reader */ + hid_t fid_reader2 = H5I_INVALID_HID; /* File ID for reader */ + hid_t fid_reader3 = H5I_INVALID_HID; /* File ID for reader */ + hid_t fapl_reader = H5I_INVALID_HID; /* File access property list for reader */ + H5F_vfd_swmr_config_t *config_reader = NULL; /* VFD SWMR configuration */ + H5F_t * file_reader; /* File pointer */ + eot_queue_entry_t * curr; /* Pointer to an entry on the EOT queue */ + unsigned count = 0; /* Counter */ /* Close unused write end for writer pipe */ - if(HDclose(parent_pfd[1]) < 0) + if (HDclose(parent_pfd[1]) < 0) HDexit(EXIT_FAILURE); /* Close unused read end for reader pipe */ - if(HDclose(child_pfd[0]) < 0) + if (HDclose(child_pfd[0]) < 0) HDexit(EXIT_FAILURE); /* Free unused configuration */ - if(config_writer) + if (config_writer) HDfree(config_writer); - /* + /* * Open the file 3 times as VFD SWMR reader * Enable and disable EOT for a file * Verify the state of the EOT queue */ /* Wait for notification 1 from parent to start verification */ - while(child_notify != 1) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Allocate memory for the configuration structure */ - if((config_reader = HDmalloc(sizeof(*config_reader))) == NULL) + if ((config_reader = HDmalloc(sizeof(*config_reader))) == NULL) HDexit(EXIT_FAILURE); /* Set up the VFD SWMR configuration as reader + page buffering */ fapl_reader = init_vfd_swmr_config_fapl(config_reader, 1, 3, FALSE, 256, MD_FILENAME, FS_PAGE_SIZE); - if(fapl_reader == H5I_INVALID_HID) + if (fapl_reader == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Open the test file as reader */ - if((fid_reader = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Open the same test file as reader (a second time) */ - if((fid_reader2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Open the same test file as reader (a third time) */ - if((fid_reader3 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader3 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Verify the # of files on the EOT queue is 3 */ count = 0; TAILQ_FOREACH(curr, &eot_queue_g, link) - count++; - if(count != 3) + count++; + if (count != 3) HDexit(EXIT_FAILURE); /* Disable EOT for the second opened file */ - if(H5Fvfd_swmr_disable_end_of_tick(fid_reader2) < 0) + if (H5Fvfd_swmr_disable_end_of_tick(fid_reader2) < 0) HDexit(EXIT_FAILURE); /* Verify the # of files on the EOT queue is 2 */ count = 0; TAILQ_FOREACH(curr, &eot_queue_g, link) - count++; - if(count != 2) + count++; + if (count != 2) HDexit(EXIT_FAILURE); /* Get file pointer */ file_reader = H5VL_object(fid_reader2); /* Should not find the second opened file on the EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { - if(curr->vfd_swmr_file == file_reader) + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == file_reader) break; } - if(curr != NULL && curr->vfd_swmr_file == file_reader) + if (curr != NULL && curr->vfd_swmr_file == file_reader) HDexit(EXIT_FAILURE); /* Enable EOT for the second opened file again */ - if(H5Fvfd_swmr_enable_end_of_tick(fid_reader2) < 0) + if (H5Fvfd_swmr_enable_end_of_tick(fid_reader2) < 0) HDexit(EXIT_FAILURE); /* Verify the # of files on the EOT queue is 3 */ count = 0; TAILQ_FOREACH(curr, &eot_queue_g, link) - count++; - if(count != 3) + count++; + if (count != 3) HDexit(EXIT_FAILURE); /* Should find the second opened file on the EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { - if(curr->vfd_swmr_file == file_reader) + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == file_reader) break; } - if(curr == NULL || curr->vfd_swmr_file != file_reader) + if (curr == NULL || curr->vfd_swmr_file != file_reader) HDexit(EXIT_FAILURE); /* Closing */ - if(H5Fclose(fid_reader) < 0) + if (H5Fclose(fid_reader) < 0) HDexit(EXIT_FAILURE); - if(H5Fclose(fid_reader2) < 0) + if (H5Fclose(fid_reader2) < 0) HDexit(EXIT_FAILURE); - if(H5Fclose(fid_reader3) < 0) + if (H5Fclose(fid_reader3) < 0) HDexit(EXIT_FAILURE); - if(H5Pclose(fapl_reader) < 0) + if (H5Pclose(fapl_reader) < 0) HDexit(EXIT_FAILURE); - if(config_reader) + if (config_reader) HDfree(config_reader); /* Close the pipes */ - if(HDclose(parent_pfd[0]) < 0) + if (HDclose(parent_pfd[0]) < 0) HDexit(EXIT_FAILURE); - if(HDclose(child_pfd[1]) < 0) + if (HDclose(child_pfd[1]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* end child process */ - /* + /* * Parent process as writer */ /* Close unused read end for writer pipe */ - if(HDclose(parent_pfd[0]) < 0) + if (HDclose(parent_pfd[0]) < 0) FAIL_STACK_ERROR /* Close unused write end for reader pipe */ - if(HDclose(child_pfd[1]) < 0) + if (HDclose(child_pfd[1]) < 0) FAIL_STACK_ERROR - /* + /* * Open the file as VFD SWMR writer */ /* Open as VFD SWMR writer */ - if((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) + if ((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Send notification 1 to reader to start verfication */ notify = 1; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* @@ -2311,52 +2325,54 @@ test_disable_enable_eot_concur(void) */ /* Close the pipes */ - if(HDclose(parent_pfd[1]) < 0) + if (HDclose(parent_pfd[1]) < 0) FAIL_STACK_ERROR; - if(HDclose(child_pfd[0]) < 0) + if (HDclose(child_pfd[0]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else { /* child process terminated abnormally */ + } + else { /* child process terminated abnormally */ TEST_ERROR } /* Closing */ - if(H5Fclose(fid_writer) < 0) + if (H5Fclose(fid_writer) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl_writer) < 0) + if (H5Pclose(fapl_writer) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free resources */ - if(config_writer) + if (config_writer) HDfree(config_writer); PASSED(); return 0; error: - if(config_writer) + if (config_writer) HDfree(config_writer); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_writer); H5Fclose(fid_writer); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_disable_enable_eot_concur() */ - /*------------------------------------------------------------------------- * Function: test_file_end_tick_concur() * @@ -2374,118 +2390,118 @@ error: static unsigned test_file_end_tick_concur(void) { - hid_t fcpl = -1; /* File creation property list */ - hid_t fid_writer = -1; /* File ID for writer */ - hid_t fapl_writer = -1; /* File access property list for writer */ - H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */ - pid_t tmppid; /* Child process ID returned by waitpid */ - pid_t childpid = 0; /* Child process ID */ - int child_status; /* Status passed to waitpid */ - int child_wait_option=0; /* Options passed to waitpid */ - int child_exit_val; /* Exit status of the child */ - - int parent_pfd[2]; /* Pipe for parent process as writer */ - int child_pfd[2]; /* Pipe for child process as reader */ - int notify = 0; /* Notification between parent and child */ + hid_t fcpl = -1; /* File creation property list */ + hid_t fid_writer = -1; /* File ID for writer */ + hid_t fapl_writer = -1; /* File access property list for writer */ + H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR Configuration for writer */ + pid_t tmppid; /* Child process ID returned by waitpid */ + pid_t childpid = 0; /* Child process ID */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + + int parent_pfd[2]; /* Pipe for parent process as writer */ + int child_pfd[2]; /* Pipe for child process as reader */ + int notify = 0; /* Notification between parent and child */ TESTING("Verify concurrent H5Fvfd_swmr_end_tick()"); /* Allocate memory for the configuration structure */ - if((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) + if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) FAIL_STACK_ERROR; /* Set up the VFD SWMR configuration + page buffering */ fapl_writer = init_vfd_swmr_config_fapl(config_writer, 1, 3, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE); - if(fapl_writer == H5I_INVALID_HID) + if (fapl_writer == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; - if(H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) + if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0) FAIL_STACK_ERROR; /* Create an HDF5 file with VFD SWMR configured */ - if((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) + if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Close the file */ - if(H5Fclose(fid_writer) < 0) + if (H5Fclose(fid_writer) < 0) FAIL_STACK_ERROR; /* Create 2 pipes */ - if(HDpipe(parent_pfd) < 0) + if (HDpipe(parent_pfd) < 0) FAIL_STACK_ERROR - if(HDpipe(child_pfd) < 0) + if (HDpipe(child_pfd) < 0) FAIL_STACK_ERROR /* Fork child process */ - if((childpid = HDfork()) < 0) + if ((childpid = HDfork()) < 0) FAIL_STACK_ERROR /* * Child process as reader */ - if(childpid == 0) { - int child_notify = 0; /* Notification between child and parent */ - hid_t fid_reader1 = H5I_INVALID_HID; /* File ID for reader */ - hid_t fid_reader2 = H5I_INVALID_HID; /* File ID for reader */ - hid_t fid_reader3 = H5I_INVALID_HID; /* File ID for reader */ - hid_t fapl_reader = H5I_INVALID_HID; /* File access property list for reader */ - H5F_vfd_swmr_config_t *config_reader = NULL; /* VFD SWMR configuration */ - H5F_t *f1, *f2, *f3; /* File pointer */ - uint64_t s1 = 0; /* Saved tick_num */ - uint64_t s2 = 0; /* Saved tick_num */ - uint64_t s3 = 0; /* Saved tick_num */ + if (childpid == 0) { + int child_notify = 0; /* Notification between child and parent */ + hid_t fid_reader1 = H5I_INVALID_HID; /* File ID for reader */ + hid_t fid_reader2 = H5I_INVALID_HID; /* File ID for reader */ + hid_t fid_reader3 = H5I_INVALID_HID; /* File ID for reader */ + hid_t fapl_reader = H5I_INVALID_HID; /* File access property list for reader */ + H5F_vfd_swmr_config_t *config_reader = NULL; /* VFD SWMR configuration */ + H5F_t * f1, *f2, *f3; /* File pointer */ + uint64_t s1 = 0; /* Saved tick_num */ + uint64_t s2 = 0; /* Saved tick_num */ + uint64_t s3 = 0; /* Saved tick_num */ /* Close unused write end for writer pipe */ - if(HDclose(parent_pfd[1]) < 0) + if (HDclose(parent_pfd[1]) < 0) HDexit(EXIT_FAILURE); /* Close unused read end for reader pipe */ - if(HDclose(child_pfd[0]) < 0) + if (HDclose(child_pfd[0]) < 0) HDexit(EXIT_FAILURE); /* Free unused configuration */ - if(config_writer) + if (config_writer) HDfree(config_writer); - /* + /* * Open the file 3 times as VFD SWMR reader * Trigger EOT for the files */ /* Wait for notification 1 from parent to start verification */ - while(child_notify != 1) { - if(HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + while (child_notify != 1) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); } /* Allocate memory for the configuration structure */ - if((config_reader = HDmalloc(sizeof(*config_reader))) == NULL) + if ((config_reader = HDmalloc(sizeof(*config_reader))) == NULL) HDexit(EXIT_FAILURE); /* Set up the VFD SWMR configuration as reader + page buffering */ fapl_reader = init_vfd_swmr_config_fapl(config_reader, 1, 3, FALSE, 256, MD_FILENAME, FS_PAGE_SIZE); - if(fapl_reader == H5I_INVALID_HID) + if (fapl_reader == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Open the test file as reader */ - if((fid_reader1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Open the same test file as reader (a second time) */ - if((fid_reader2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Open the same test file as reader (a third time) */ - if((fid_reader3 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader3 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Get file pointer */ @@ -2499,75 +2515,75 @@ test_file_end_tick_concur(void) s3 = f3->shared->tick_num; /* Trigger EOT for the second opened file */ - if(H5Fvfd_swmr_end_tick(fid_reader2) < 0) + if (H5Fvfd_swmr_end_tick(fid_reader2) < 0) HDexit(EXIT_FAILURE); /* Verify tick_num should not be less than the previous tick_num */ - if(f2->shared->tick_num < s2) + if (f2->shared->tick_num < s2) HDexit(EXIT_FAILURE); - if(H5Fclose(fid_reader2) < 0) + if (H5Fclose(fid_reader2) < 0) HDexit(EXIT_FAILURE); /* Trigger EOT for the first opened file */ - if(H5Fvfd_swmr_end_tick(fid_reader1) < 0) + if (H5Fvfd_swmr_end_tick(fid_reader1) < 0) HDexit(EXIT_FAILURE); /* Verify tick_num should not be less than the previous tick_num */ - if(f1->shared->tick_num < s1) + if (f1->shared->tick_num < s1) HDexit(EXIT_FAILURE); - if(H5Fclose(fid_reader1) < 0) + if (H5Fclose(fid_reader1) < 0) HDexit(EXIT_FAILURE); /* Trigger end tick processing for the third opened file */ - if(H5Fvfd_swmr_end_tick(fid_reader3) < 0) + if (H5Fvfd_swmr_end_tick(fid_reader3) < 0) HDexit(EXIT_FAILURE); /* Verify tick_num should not be less than the previous tick_num */ - if(f3->shared->tick_num < s3) + if (f3->shared->tick_num < s3) HDexit(EXIT_FAILURE); - if(H5Fclose(fid_reader3) < 0) + if (H5Fclose(fid_reader3) < 0) HDexit(EXIT_FAILURE); - if(H5Pclose(fapl_reader) < 0) + if (H5Pclose(fapl_reader) < 0) HDexit(EXIT_FAILURE); - if(config_reader) + if (config_reader) HDfree(config_reader); /* Close the pipes */ - if(HDclose(parent_pfd[0]) < 0) + if (HDclose(parent_pfd[0]) < 0) HDexit(EXIT_FAILURE); - if(HDclose(child_pfd[1]) < 0) + if (HDclose(child_pfd[1]) < 0) HDexit(EXIT_FAILURE); HDexit(EXIT_SUCCESS); } /* end child process */ - /* + /* * Parent process as writer */ /* Close unused read end for writer pipe */ - if(HDclose(parent_pfd[0]) < 0) + if (HDclose(parent_pfd[0]) < 0) FAIL_STACK_ERROR /* Close unused write end for reader pipe */ - if(HDclose(child_pfd[1]) < 0) + if (HDclose(child_pfd[1]) < 0) FAIL_STACK_ERROR - /* + /* * Open the file as VFD SWMR writer */ /* Open as VFD SWMR writer */ - if((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) + if ((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Send notification 1 to reader to start verfication */ notify = 1; - if(HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) FAIL_STACK_ERROR; /* @@ -2575,54 +2591,56 @@ test_file_end_tick_concur(void) */ /* Close the pipes */ - if(HDclose(parent_pfd[1]) < 0) + if (HDclose(parent_pfd[1]) < 0) FAIL_STACK_ERROR; - if(HDclose(child_pfd[0]) < 0) + if (HDclose(child_pfd[0]) < 0) FAIL_STACK_ERROR; /* Wait for child process to complete */ - if((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) FAIL_STACK_ERROR /* Check exit status of child process */ - if(WIFEXITED(child_status)) { - if((child_exit_val = WEXITSTATUS(child_status)) != 0) + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) TEST_ERROR - } else { /* child process terminated abnormally */ + } + else { /* child process terminated abnormally */ TEST_ERROR } /* Closing */ - if(H5Fclose(fid_writer) < 0) + if (H5Fclose(fid_writer) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl_writer) < 0) + if (H5Pclose(fapl_writer) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free resources */ - if(config_writer) + if (config_writer) HDfree(config_writer); PASSED(); return 0; error: - if(config_writer) + if (config_writer) HDfree(config_writer); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl_writer); H5Fclose(fid_writer); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* test_file_end_tick_concur() */ #endif /* H5_HAVE_UNISTD_H */ - /*------------------------------------------------------------------------- * Function: test_multiple_file_opens() * @@ -2638,168 +2656,169 @@ error: */ static unsigned -test_multiple_file_opens(void) +test_multiple_file_opens(void) { - hid_t fid1 = -1; /* File ID */ - hid_t fid2 = -1; /* File ID */ - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t fapl1 = -1; /* File access property list ID */ - hid_t fapl2 = -1; /* File access property list ID */ - H5F_t *f1, *f2, *f; /* File pointer */ - H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ - eot_queue_entry_t *curr; + hid_t fid1 = -1; /* File ID */ + hid_t fid2 = -1; /* File ID */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl1 = -1; /* File access property list ID */ + hid_t fapl2 = -1; /* File access property list ID */ + H5F_t * f1, *f2, *f; /* File pointer */ + H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ + eot_queue_entry_t * curr; TESTING("EOT queue entries when opening files with/without VFD SWMR"); /* Allocate memory for the configuration structure */ - if((config1 = HDmalloc(sizeof(*config1))) == NULL) + if ((config1 = HDmalloc(sizeof(*config1))) == NULL) FAIL_STACK_ERROR; - if((config2 = HDmalloc(sizeof(*config2))) == NULL) + if ((config2 = HDmalloc(sizeof(*config2))) == NULL) FAIL_STACK_ERROR; /* Configured as VFD SWMR writer + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, TRUE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Configured as VFD SWMR writer + page buffering */ fapl2 = init_vfd_swmr_config_fapl(config2, 4, 6, TRUE, 2, MD_FILENAME2, 4096); - if(fapl2 == H5I_INVALID_HID) + if (fapl2 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; /* Create a file without VFD SWMR */ - if((fid = H5Fcreate(FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f = H5VL_object(fid))) + if (NULL == (f = H5VL_object(fid))) FAIL_STACK_ERROR /* Verify the global vfd_swmr_writer_g is not set */ - if((curr = TAILQ_FIRST(&eot_queue_g)) != NULL && curr->vfd_swmr_writer) + if ((curr = TAILQ_FIRST(&eot_queue_g)) != NULL && curr->vfd_swmr_writer) TEST_ERROR; /* The EOT queue should be empty */ - if(!TAILQ_EMPTY(&eot_queue_g)) + if (!TAILQ_EMPTY(&eot_queue_g)) TEST_ERROR; /* Create a file with VFD SWMR writer */ - if((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) + if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) TEST_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f1 = H5VL_object(fid1))) + if (NULL == (f1 = H5VL_object(fid1))) FAIL_STACK_ERROR /* Head of EOT queue should be a writer */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || !curr->vfd_swmr_writer) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || !curr->vfd_swmr_writer) TEST_ERROR; /* The EOT queue should be initialized with the first entry equals to f1 */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f1) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f1) TEST_ERROR; /* Create another file with VFD SWMR writer */ - if((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR; /* Get a pointer to the internal file object */ - if(NULL == (f2 = H5VL_object(fid2))) + if (NULL == (f2 = H5VL_object(fid2))) FAIL_STACK_ERROR /* Head of EOT queue should be a writer */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || !curr->vfd_swmr_writer) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || !curr->vfd_swmr_writer) TEST_ERROR; /* The EOT queue's first entry should be f1 */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f1) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f1) TEST_ERROR; /* The file without VFD SWMR should not exist on the EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { - if(curr->vfd_swmr_file == f) + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == f) TEST_ERROR } /* Close the first file with VFD SWMR */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR; /* Head of EOT queue should be a writer */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || !curr->vfd_swmr_writer) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || !curr->vfd_swmr_writer) TEST_ERROR; /* The EOT queue's first entry should be f2 */ - if((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f2) + if ((curr = TAILQ_FIRST(&eot_queue_g)) == NULL || curr->vfd_swmr_file != f2) TEST_ERROR; /* Close the second file with VFD SWMR */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Head of EOT queue should not be a writer */ - if((curr = TAILQ_FIRST(&eot_queue_g)) != NULL && curr->vfd_swmr_writer) + if ((curr = TAILQ_FIRST(&eot_queue_g)) != NULL && curr->vfd_swmr_writer) TEST_ERROR; /* The EOT queue should be empty */ - if(!TAILQ_EMPTY(&eot_queue_g)) + if (!TAILQ_EMPTY(&eot_queue_g)) TEST_ERROR; /* Closing */ - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Free buffers */ - if(config1) + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl1); H5Pclose(fapl2); H5Pclose(fcpl); H5Fclose(fid); H5Fclose(fid1); H5Fclose(fid2); - } H5E_END_TRY; - if(config1) + } + H5E_END_TRY; + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); return 1; } /* test_multiple_file_opens() */ - - /*------------------------------------------------------------------------- * Function: test_same_file_opens() * * Purpose: Verify multiple opens of the same file as listed below: * - * #1st open# - * #2nd open# VW VR W R + * #1st open# + * #2nd open# VW VR W R * ------------------ - * VW | s f f f | - * VR | f f f f | - * W | f f s f | - * R | f f s s | + * VW | s f f f | + * VR | f f f f | + * W | f f s f | + * R | f f s s | * ------------------ * * Notations: @@ -2808,8 +2827,8 @@ error: * VW: VFD SWMR writer * VR: VFD SWMR reader * - * f: the open fails - * s: the open succeeds + * f: the open fails + * s: the open succeeds * * Return: 0 if test is sucessful * 1 if test fails @@ -2821,290 +2840,302 @@ error: static unsigned test_same_file_opens(void) { - hid_t fid = -1; /* File ID */ - hid_t fid2 = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t fapl1 = -1; /* File access property list ID */ - hid_t fapl2 = -1; /* File access property list ID */ - H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ + hid_t fid = -1; /* File ID */ + hid_t fid2 = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl1 = -1; /* File access property list ID */ + hid_t fapl2 = -1; /* File access property list ID */ + H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ TESTING("Multiple opens of the same file with VFD SWMR configuration"); /* Should succeed without VFD SWMR configured */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; /* Allocate memory for the configuration structure */ - if((config1 = HDmalloc(sizeof(*config1))) == NULL) + if ((config1 = HDmalloc(sizeof(*config1))) == NULL) FAIL_STACK_ERROR; - if((config2 = HDmalloc(sizeof(*config2))) == NULL) + if ((config2 = HDmalloc(sizeof(*config2))) == NULL) FAIL_STACK_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; - /* + /* * Tests for first column */ /* Create the test file */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - /* Set the VFD SWMR configuration in fapl1 + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, TRUE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Open the file as VFD SWMR writer */ /* Keep the file open */ - if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR; /* Open the same file again as VFD SWMR writer */ /* Should succeed: 1st open--VFD SWMR writer, 2nd open--VFD SWMR writer */ - if((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR; /* Close the second file open */ - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Set the VFD SWMR configuration in fapl2 + page buffering */ fapl2 = init_vfd_swmr_config_fapl(config2, 3, 8, FALSE, 3, MD_FILENAME, 4096); - if(fapl2 == H5I_INVALID_HID) + if (fapl2 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Open the same file again as VFD SWMR reader */ /* Should fail: 1st open--VFD SWMR writer, 2nd open--VFD SWMR reader */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl2); - } H5E_END_TRY; - if(fid2 >= 0) + } + H5E_END_TRY; + if (fid2 >= 0) TEST_ERROR; - - if(H5Pclose(fapl2) < 0) + + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR; /* Open the same file again as regular writer */ /* Should fail: 1st open--VFD SWMR writer, 2nd open--regular writer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - } H5E_END_TRY; - if(fid2 >= 0) + } + H5E_END_TRY; + if (fid2 >= 0) TEST_ERROR; /* Open the same file again as regular reader */ /* Should fail: 1st open--VFD SWMR writer, 2nd open--regular reader */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); - } H5E_END_TRY; - if(fid2 >= 0) + } + H5E_END_TRY; + if (fid2 >= 0) TEST_ERROR; /* Close the 1st open file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - - /* + /* * Tests for second column */ /* Set up as VFD SWMR reader + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, FALSE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Open the file as VFD SWMR reader */ /* Should fail because there is no metadata file */ /* Take a while to complete due to retries */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl1); - } H5E_END_TRY; - if(fid >= 0) + } + H5E_END_TRY; + if (fid >= 0) TEST_ERROR; - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; - /* + /* * Tests for third column */ /* Open the file as regular writer */ /* Keep the file open */ - if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; /* Set up as VFD SWMR writer + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, TRUE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Open the same file again as VFD SWMR writer */ /* Should fail: 1st open--regular writer, 2nd open--VFD SWMR writer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1); - } H5E_END_TRY; - if(fid2 >= 0) + } + H5E_END_TRY; + if (fid2 >= 0) TEST_ERROR; - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; - /* Open the same file again as regular writer */ /* Should succeed: 1st open--regular writer, 2nd open--regular writer */ - if((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; - /* Open the same file again as regular reader */ /* Should succeed: 1st open is writer, 2nd open is the same file as reader */ - if((fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Close the 1st open file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - /* + /* * Tests for fourth column */ /* Open the file as regular reader */ /* keep the file open */ - if((fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR; /* Set up as VFD SWMR writer + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, TRUE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Open the same file again as VFD SMWR writer */ /* Should fail: 1st open--regular reader, 2nd open--VFD SWMR writer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1); - } H5E_END_TRY; - if(fid2 >= 0) + } + H5E_END_TRY; + if (fid2 >= 0) TEST_ERROR; - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; /* Open the same file again as regular reader */ /* Should succeed: 1st open--regular reader, 2nd open--regular reader */ - if((fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Open the same file again as regular writer */ /* Should fail: 1st open--regular reader, 2nd open--regular writer */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - } H5E_END_TRY; - if(fid2 >= 0) + } + H5E_END_TRY; + if (fid2 >= 0) TEST_ERROR; /* Close the 1st open file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free buffers */ - if(config1) + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl1); H5Pclose(fapl2); H5Pclose(fcpl); H5Fclose(fid); H5Fclose(fid2); - } H5E_END_TRY; - if(config1) + } + H5E_END_TRY; + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); return 1; } /* test_same_file_opens() */ #ifndef _arraycount -#define _arraycount(_a) (sizeof(_a)/sizeof(_a[0])) +#define _arraycount(_a) (sizeof(_a) / sizeof(_a[0])) #endif static unsigned test_shadow_index_lookup(void) { - unsigned nerrors = 0; + unsigned nerrors = 0; H5FD_vfd_swmr_idx_entry_t *idx; - uint32_t size[] = {0, 1, 2, 3, 4, 0}; - unsigned seed = 1; - unsigned i, j, failj = UINT_MAX; - hbool_t have_failj = FALSE; - unsigned long tmpl; - const char *seedvar = "H5_SHADOW_INDEX_SEED"; - const char *failvar = "H5_SHADOW_INDEX_FAIL"; + uint32_t size[] = {0, 1, 2, 3, 4, 0}; + unsigned seed = 1; + unsigned i, j, failj = UINT_MAX; + hbool_t have_failj = FALSE; + unsigned long tmpl; + const char * seedvar = "H5_SHADOW_INDEX_SEED"; + const char * failvar = "H5_SHADOW_INDEX_FAIL"; TESTING("Shadow-index lookups"); /* get seed from environment or else from time(3) */ switch (fetch_env_ulong(seedvar, UINT_MAX, &tmpl)) { - case -1: - nerrors = 1; - goto out; - case 0: - seed = (unsigned int)HDtime(NULL); - break; - default: - seed = (unsigned int)tmpl; - break; + case -1: + nerrors = 1; + goto out; + case 0: + seed = (unsigned int)HDtime(NULL); + break; + default: + seed = (unsigned int)tmpl; + break; } /* get forced-fail index from environment */ switch (fetch_env_ulong(failvar, UINT_MAX, &tmpl)) { - case -1: - nerrors = 1; - goto out; - case 0: - break; - default: - failj = (unsigned int)tmpl; - have_failj = TRUE; - break; + case -1: + nerrors = 1; + goto out; + case 0: + break; + default: + failj = (unsigned int)tmpl; + have_failj = TRUE; + break; } HDsrandom(seed); @@ -3112,35 +3143,31 @@ test_shadow_index_lookup(void) size[5] = (uint32_t)(1024 + HDrandom() % (16 * 1024 * 1024 - 1024)); for (i = 0; i < _arraycount(size); i++) { - uint32_t cursize = size[i]; + uint32_t cursize = size[i]; const uint64_t modulus = UINT64_MAX / MAX(1, cursize); - uint64_t pageno; + uint64_t pageno; HDassert(modulus > 1); // so that modulus - 1 > 0, below - idx = (cursize == 0) ? NULL : HDcalloc(cursize, sizeof(*idx)); + idx = (cursize == 0) ? NULL : HDcalloc(cursize, sizeof(*idx)); if (idx == NULL && cursize != 0) { - HDfprintf(stderr, "couldn't allocate %" PRIu32 " indices\n", - cursize); + HDfprintf(stderr, "couldn't allocate %" PRIu32 " indices\n", cursize); HDexit(EXIT_FAILURE); } - for (pageno = (uint64_t)HDrandom() % modulus, j = 0; - j < cursize; + for (pageno = (uint64_t)HDrandom() % modulus, j = 0; j < cursize; j++, pageno += 1 + (uint64_t)HDrandom() % (modulus - 1)) { idx[j].hdf5_page_offset = pageno; } for (j = 0; j < cursize; j++) { H5FD_vfd_swmr_idx_entry_t *found; - found = vfd_swmr_pageno_to_mdf_idx_entry(idx, cursize, - idx[j].hdf5_page_offset, FALSE); + found = vfd_swmr_pageno_to_mdf_idx_entry(idx, cursize, idx[j].hdf5_page_offset, FALSE); if ((have_failj && failj == j) || found != &idx[j]) break; } if (j < cursize) { - HDprintf("\nshadow-index entry %d lookup, pageno %" PRIu64 - ", index size %" PRIu32 ", seed %u", j, - idx[j].hdf5_page_offset, cursize, seed); + HDprintf("\nshadow-index entry %d lookup, pageno %" PRIu64 ", index size %" PRIu32 ", seed %u", j, + idx[j].hdf5_page_offset, cursize, seed); nerrors++; } if (idx != NULL) @@ -3171,208 +3198,222 @@ out: *------------------------------------------------------------------------- */ static unsigned -test_enable_disable_eot(void) +test_enable_disable_eot(void) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fid1 = H5I_INVALID_HID; /* File ID */ - hid_t fid2 = H5I_INVALID_HID; /* File ID */ - hid_t fid3 = H5I_INVALID_HID; /* File ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ - hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ - hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ - hid_t fapl3 = H5I_INVALID_HID; /* File access property list ID */ - H5F_t *f1, *f2, *f3; /* File pointer */ - H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config3 = NULL; /* Configuration for VFD SWMR */ - eot_queue_entry_t *curr; /* Pointer to an entry on the EOT queue */ - unsigned count = 0; /* Counter */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fid1 = H5I_INVALID_HID; /* File ID */ + hid_t fid2 = H5I_INVALID_HID; /* File ID */ + hid_t fid3 = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ + hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ + hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ + hid_t fapl3 = H5I_INVALID_HID; /* File access property list ID */ + H5F_t * f1, *f2, *f3; /* File pointer */ + H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config3 = NULL; /* Configuration for VFD SWMR */ + eot_queue_entry_t * curr; /* Pointer to an entry on the EOT queue */ + unsigned count = 0; /* Counter */ + herr_t ret; /* Return value */ TESTING("H5Fvfd_swmr_enable/disable_end_of_tick()"); /* Allocate memory for the configuration structure */ - if((config1 = HDmalloc(sizeof(*config1))) == NULL) + if ((config1 = HDmalloc(sizeof(*config1))) == NULL) FAIL_STACK_ERROR; - if((config2 = HDmalloc(sizeof(*config2))) == NULL) + if ((config2 = HDmalloc(sizeof(*config2))) == NULL) FAIL_STACK_ERROR; - if((config3 = HDmalloc(sizeof(*config3))) == NULL) + if ((config3 = HDmalloc(sizeof(*config3))) == NULL) FAIL_STACK_ERROR; /* Configured first file as VFD SWMR writer + page buffering */ fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, TRUE, 2, MD_FILENAME, 4096); - if(fapl1 == H5I_INVALID_HID) + if (fapl1 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Configured second file as VFD SWMR writer + page buffering */ fapl2 = init_vfd_swmr_config_fapl(config2, 4, 6, TRUE, 2, MD_FILENAME2, 4096); - if(fapl2 == H5I_INVALID_HID) + if (fapl2 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Configured third file as VFD SWMR writer + page buffering */ fapl3 = init_vfd_swmr_config_fapl(config3, 4, 6, TRUE, 2, MD_FILENAME3, 4096); - if(fapl3 == H5I_INVALID_HID) + if (fapl3 == H5I_INVALID_HID) FAIL_STACK_ERROR; /* Create a copy of the file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR /* Set file space strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) FAIL_STACK_ERROR; /* Create a file without VFD SWMR */ - if((fid = H5Fcreate(FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Should fail to disable the file because VFD SWMR is not configured */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fvfd_swmr_disable_end_of_tick(fid); - } H5E_END_TRY; - if(ret >=0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR /* Create file 1 with VFD SWMR writer */ - if((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) + if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) TEST_ERROR; /* Create file 2 with VFD SWMR writer */ - if((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR; /* Create file 3 with VFD SWMR writer */ - if((fid3 = H5Fcreate(FILENAME3, H5F_ACC_TRUNC, fcpl, fapl3)) < 0) + if ((fid3 = H5Fcreate(FILENAME3, H5F_ACC_TRUNC, fcpl, fapl3)) < 0) TEST_ERROR; /* Should have 3 files on the EOT queue */ TAILQ_FOREACH(curr, &eot_queue_g, link) - count++; - if(count != 3) + count++; + if (count != 3) TEST_ERROR; /* Disable EOT for file 1 */ - if(H5Fvfd_swmr_disable_end_of_tick(fid1) < 0) + if (H5Fvfd_swmr_disable_end_of_tick(fid1) < 0) TEST_ERROR /* Disable file 1 again should fail because the file has just been disabled */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fvfd_swmr_disable_end_of_tick(fid1); - } H5E_END_TRY; - if(ret >=0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Should have 2 files on the EOT queue */ count = 0; TAILQ_FOREACH(curr, &eot_queue_g, link) - count++; - if(count != 2) + count++; + if (count != 2) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f1 = H5VL_object(fid1))) + if (NULL == (f1 = H5VL_object(fid1))) FAIL_STACK_ERROR /* Should not find file 1 on the EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { - if(curr->vfd_swmr_file == f1) + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == f1) break; } - if(curr != NULL && curr->vfd_swmr_file == f1) + if (curr != NULL && curr->vfd_swmr_file == f1) TEST_ERROR /* Enable EOT for file 2 should fail because the file has not been disabled */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fvfd_swmr_enable_end_of_tick(fid2); - } H5E_END_TRY; - if(ret >=0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f2 = H5VL_object(fid2))) + if (NULL == (f2 = H5VL_object(fid2))) FAIL_STACK_ERROR /* File 2 should be on the EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { - if(curr->vfd_swmr_file == f2) + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == f2) break; } - if(curr == NULL || curr->vfd_swmr_file != f2) + if (curr == NULL || curr->vfd_swmr_file != f2) TEST_ERROR /* Close file 3 */ - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) TEST_ERROR /* Open file 3 again without VFD SWMR writer */ - if((fid3 = H5Fopen(FILENAME3, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fopen(FILENAME3, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR /* Get a pointer to the internal file object for file 3 */ - if(NULL == (f3 = H5VL_object(fid3))) + if (NULL == (f3 = H5VL_object(fid3))) FAIL_STACK_ERROR /* File 3 should not exist on the EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) { - if(curr->vfd_swmr_file == f3) + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == f3) break; } - if(curr != NULL && curr->vfd_swmr_file == f3) + if (curr != NULL && curr->vfd_swmr_file == f3) TEST_ERROR /* Should have 2 files on the EOT queue */ count = 0; TAILQ_FOREACH(curr, &eot_queue_g, link) - count++; - if(count != 1) + count++; + if (count != 1) TEST_ERROR; /* Should fail to enable file 3 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fvfd_swmr_enable_end_of_tick(fid3); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Should fail to disable file 3 */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5Fvfd_swmr_disable_end_of_tick(fid3); - } H5E_END_TRY; - if(ret >= 0) + } + H5E_END_TRY; + if (ret >= 0) TEST_ERROR /* Closing */ - if(H5Fclose(fid1) < 0) + if (H5Fclose(fid1) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; - if(H5Fclose(fid3) < 0) + if (H5Fclose(fid3) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl1) < 0) + if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl2) < 0) + if (H5Pclose(fapl2) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fapl3) < 0) + if (H5Pclose(fapl3) < 0) FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; /* Free buffers */ - if(config1) + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); - if(config3) + if (config3) HDfree(config3); PASSED(); return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl1); H5Pclose(fapl2); H5Pclose(fapl3); @@ -3381,18 +3422,18 @@ error: H5Fclose(fid1); H5Fclose(fid2); H5Fclose(fid3); - } H5E_END_TRY; - if(config1) + } + H5E_END_TRY; + if (config1) HDfree(config1); - if(config2) + if (config2) HDfree(config2); - if(config3) + if (config3) HDfree(config3); return 1; } /* test_enable_disable_eot() */ - /*------------------------------------------------------------------------- * Function: main() * @@ -3406,34 +3447,33 @@ error: int main(void) { - hid_t fapl = -1; /* File access property list for */ - /* data files */ - unsigned nerrors = 0; /* Cumulative error count */ - char *lock_env_var = NULL; /* File locking env var pointer */ - const char *env_h5_drvr = NULL; /* File Driver value from environment */ - hbool_t use_file_locking; /* Read from env var */ + hid_t fapl = -1; /* File access property list for */ + /* data files */ + unsigned nerrors = 0; /* Cumulative error count */ + char * lock_env_var = NULL; /* File locking env var pointer */ + const char *env_h5_drvr = NULL; /* File Driver value from environment */ + hbool_t use_file_locking; /* Read from env var */ /* Check the environment variable that determines if we care * about file locking. File locking should be used unless explicitly * disabled. */ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) + if (lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) use_file_locking = FALSE; else use_file_locking = TRUE; /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; /* Temporary skip testing with multi/split drivers: * Page buffering depends on paged aggregation which is * currently disabled for multi/split drivers. */ - if((0 == HDstrcmp(env_h5_drvr, "multi")) || - (0 == HDstrcmp(env_h5_drvr, "split"))) { + if ((0 == HDstrcmp(env_h5_drvr, "multi")) || (0 == HDstrcmp(env_h5_drvr, "split"))) { SKIPPED() HDputs("Skip VFD SWMR test because paged aggregation is disabled for multi/split drivers"); @@ -3443,14 +3483,14 @@ main(void) /* Set up */ h5_reset(); - if((fapl = h5_fileaccess()) < 0) { + if ((fapl = h5_fileaccess()) < 0) { nerrors++; PUTS_ERROR("Can't get VFD-dependent fapl") } /* end if */ nerrors += test_fapl(); - if(use_file_locking) { + if (use_file_locking) { nerrors += test_shadow_index_lookup(); nerrors += test_file_fapl(); @@ -3473,7 +3513,7 @@ main(void) nerrors += test_file_end_tick_concur(); } - if(nerrors) + if (nerrors) goto error; HDputs("All VFD SWMR tests passed."); @@ -3481,12 +3521,13 @@ main(void) HDexit(EXIT_SUCCESS); error: - HDprintf("***** %d VFD SWMR TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + HDprintf("***** %d VFD SWMR TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; HDexit(EXIT_FAILURE); } diff --git a/test/vfd_swmr_addrem_writer.c b/test/vfd_swmr_addrem_writer.c index 9af54cc..5b153e1 100644 --- a/test/vfd_swmr_addrem_writer.c +++ b/test/vfd_swmr_addrem_writer.c @@ -32,8 +32,6 @@ /* Headers */ /***********/ - - #include "h5test.h" #include "vfd_swmr_common.h" #include "swmr_common.h" @@ -51,11 +49,9 @@ #include /* errx(3) */ static hid_t open_skeleton(const char *filename, unsigned verbose); -static int addrem_records(hid_t fid, unsigned verbose, unsigned long nops, - unsigned long flush_count); -static void usage(void); +static int addrem_records(hid_t fid, unsigned verbose, unsigned long nops, unsigned long flush_count); +static void usage(void); - /*------------------------------------------------------------------------- * Function: open_skeleton * @@ -77,92 +73,92 @@ static void usage(void); static hid_t open_skeleton(const char *filename, unsigned verbose) { - hid_t dapl = H5I_INVALID_HID; - hid_t fid = -1; /* File ID for new HDF5 file */ - hid_t fapl = -1; /* File access property list */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t dim[2]; /* Dataspace dimension */ - unsigned u, v; /* Local index variable */ - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + hid_t dapl = H5I_INVALID_HID; + hid_t fid = -1; /* File ID for new HDF5 file */ + hid_t fapl = -1; /* File access property list */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim[2]; /* Dataspace dimension */ + unsigned u, v; /* Local index variable */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ HDassert(filename); if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", __func__, __LINE__); - if (H5Pset_chunk_cache(dapl, H5D_CHUNK_CACHE_NSLOTS_DEFAULT, 0, - H5D_CHUNK_CACHE_W0_DEFAULT) < 0) + if (H5Pset_chunk_cache(dapl, H5D_CHUNK_CACHE_NSLOTS_DEFAULT, 0, H5D_CHUNK_CACHE_W0_DEFAULT) < 0) errx(EXIT_FAILURE, "H5Pset_chunk_cache failed"); - /* Allocate memory for the configuration structure */ - if((config = calloc(1, sizeof(*config))) == NULL) + /* Allocate memory for the configuration structure */ + if ((config = calloc(1, sizeof(*config))) == NULL) goto error; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5 , TRUE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, config)) < 0) + if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, config)) < 0) goto error; /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) goto error; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(config) + if (config) HDfree(config); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Opening datasets\n"); /* Open the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { hid_t dsid; - if((dsid = H5Dopen2(fid, symbol_info[u][v].name, dapl)) < 0) + if ((dsid = H5Dopen2(fid, symbol_info[u][v].name, dapl)) < 0) goto error; symbol_info[u][v].dsid = dsid; - if((sid = H5Dget_space(symbol_info[u][v].dsid)) < 0) + if ((sid = H5Dget_space(symbol_info[u][v].dsid)) < 0) goto error; - if(2 != H5Sget_simple_extent_ndims(sid)) + if (2 != H5Sget_simple_extent_ndims(sid)) goto error; - if(H5Sget_simple_extent_dims(sid, dim, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dim, NULL) < 0) goto error; symbol_info[u][v].nrecords = dim[1]; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; } /* end for */ return fid; error: - if(config) + if (config) HDfree(config); - H5E_BEGIN_TRY { - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) + H5E_BEGIN_TRY + { + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) H5Dclose(symbol_info[u][v].dsid); H5Sclose(sid); H5Pclose(fapl); H5Fclose(fid); H5Pclose(dapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* open_skeleton() */ - /*------------------------------------------------------------------------- * Function: addrem_records * @@ -189,14 +185,14 @@ error: static int addrem_records(hid_t fid, unsigned verbose, unsigned long nops, unsigned long flush_count) { - hid_t tid = -1; /* Datatype ID for records */ - hid_t mem_sid = -1; /* Memory dataspace ID */ - hid_t file_sid = -1; /* Dataset's space ID */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ - hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ - symbol_t buf[MAX_SIZE_CHANGE]; /* Write buffer */ - unsigned long op_to_flush; /* # of operations before flush */ - unsigned long u, v; /* Local index variables */ + hid_t tid = -1; /* Datatype ID for records */ + hid_t mem_sid = -1; /* Memory dataspace ID */ + hid_t file_sid = -1; /* Dataset's space ID */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + symbol_t buf[MAX_SIZE_CHANGE]; /* Write buffer */ + unsigned long op_to_flush; /* # of operations before flush */ + unsigned long u, v; /* Local index variables */ HDassert(fid > 0); @@ -204,18 +200,18 @@ addrem_records(hid_t fid, unsigned verbose, unsigned long nops, unsigned long fl HDmemset(&buf, 0, sizeof(buf)); /* Create a dataspace for the record to add */ - if((mem_sid = H5Screate_simple(2, count, NULL)) < 0) + if ((mem_sid = H5Screate_simple(2, count, NULL)) < 0) goto error; /* Create datatype for appending records */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) goto error; /* Add and remove records to random datasets, according to frequency * distribution */ op_to_flush = flush_count; - for(u=0; u MAX_SIZE_CHANGE) { + if (count[1] > MAX_SIZE_CHANGE) { /* Add records */ count[1] -= MAX_SIZE_CHANGE; /* Set the buffer's IDs (equal to its position) */ - for(v=0; vnrecords + (uint64_t)v; /* Set the memory space to the correct size */ - if(H5Sset_extent_simple(mem_sid, 2, count, NULL) < 0) + if (H5Sset_extent_simple(mem_sid, 2, count, NULL) < 0) goto error; /* Get the coordinates to write */ start[1] = symbol->nrecords; - /* Extend the dataset's dataspace to hold the new record */ - symbol->nrecords+= count[1]; + /* Extend the dataset's dataspace to hold the new record */ + symbol->nrecords += count[1]; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) goto error; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(symbol->dsid)) < 0) + if ((file_sid = H5Dget_space(symbol->dsid)) < 0) goto error; /* Choose the last record in the dataset */ - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; /* Write record to the dataset */ - if(H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &buf) < 0) + if (H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &buf) < 0) goto error; - if(H5Dflush(symbol->dsid) < 0) + if (H5Dflush(symbol->dsid) < 0) goto error; /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) goto error; } /* end if */ else { /* Shrink the dataset's dataspace */ - if(count[1] > symbol->nrecords) + if (count[1] > symbol->nrecords) symbol->nrecords = 0; else symbol->nrecords -= count[1]; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) goto error; } /* end else */ /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ op_to_flush--; /* Check for counter being reached */ - if(0 == op_to_flush) { + if (0 == op_to_flush) { /* Reset flush counter */ op_to_flush = flush_count; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Closing datasets\n"); /* Close the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) - if(H5Dclose(symbol_info[u][v].dsid) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) + if (H5Dclose(symbol_info[u][v].dsid) < 0) return -1; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(mem_sid); H5Sclose(file_sid); H5Tclose(tid); - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) H5Dclose(symbol_info[u][v].dsid); - - } H5E_END_TRY; + } + H5E_END_TRY; return -1; @@ -335,32 +332,33 @@ usage(void) HDexit(1); } /* usage() */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { sigset_t oldset; - hid_t fid; /* File ID for file opened */ - long nops = 0; /* # of times to grow or shrink the dataset */ - long flush_count = 1000; /* # of records to write between flushing file */ - unsigned verbose = 1; /* Whether to emit some informational messages */ - unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variable */ - int temp; + hid_t fid; /* File ID for file opened */ + long nops = 0; /* # of times to grow or shrink the dataset */ + long flush_count = 1000; /* # of records to write between flushing file */ + unsigned verbose = 1; /* Whether to emit some informational messages */ + unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variable */ + int temp; block_signals(&oldset); /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of records to write between flushing file */ case 'f': flush_count = HDatol(argv[u + 1]); - if(flush_count < 0) + if (flush_count < 0) usage(); u += 2; break; @@ -370,12 +368,12 @@ int main(int argc, const char *argv[]) verbose = 0; u++; break; - + /* Random # seed */ case 'r': use_seed = 1; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -386,31 +384,31 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nops = HDatol(argv[u]); - if(nops <= 0) + if (nops <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nops <= 0) + } /* end while */ + } /* end if */ + if (nops <= 0) usage(); - if(flush_count >= nops) + if (flush_count >= nops) usage(); /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "WRITER: Parameters:\n"); HDfprintf(stderr, "\t# of operations between flushes = %ld\n", flush_count); HDfprintf(stderr, "\t# of operations = %ld\n", nops); } /* end if */ /* Set the random seed */ - if(0 == use_seed) { + if (0 == use_seed) { struct timeval t; HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); @@ -420,21 +418,20 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "WRITER: Using writer random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Emit informational message */ - if(verbose) { - HDfprintf(stderr, "WRITER: Opening skeleton file: %s\n", - VFD_SWMR_FILENAME); + if (verbose) { + HDfprintf(stderr, "WRITER: Opening skeleton file: %s\n", VFD_SWMR_FILENAME); } /* Open file skeleton */ - if((fid = open_skeleton(VFD_SWMR_FILENAME, verbose)) < 0) { + if ((fid = open_skeleton(VFD_SWMR_FILENAME, verbose)) < 0) { HDfprintf(stderr, "WRITER: Error opening skeleton file!\n"); HDexit(1); } /* end if */ @@ -443,21 +440,21 @@ int main(int argc, const char *argv[]) h5_send_message(VFD_SWMR_WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Adding and removing records\n"); /* Grow and shrink datasets */ - if(addrem_records(fid, verbose, (unsigned long)nops, (unsigned long)flush_count) < 0) { + if (addrem_records(fid, verbose, (unsigned long)nops, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "WRITER: Error adding and removing records from datasets!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "WRITER: Error releasing symbols!\n"); HDexit(1); } /* end if */ @@ -467,11 +464,11 @@ int main(int argc, const char *argv[]) restore_signals(&oldset); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Closing objects\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "WRITER: Error closing file!\n"); HDexit(1); } /* end if */ diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c index 4d1ccbe..dad33ce 100644 --- a/test/vfd_swmr_bigset_writer.c +++ b/test/vfd_swmr_bigset_writer.c @@ -66,8 +66,8 @@ * user-selectable. */ -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "hdf5.h" @@ -105,7 +105,7 @@ typedef struct _quadrant { hsize_t stride[RANK]; hsize_t block[RANK]; hsize_t count[RANK]; - hid_t space, src_space; + hid_t space, src_space; } quadrant_t; typedef struct _sources { @@ -115,58 +115,55 @@ typedef struct _sources { #define MANY_FILES 4 typedef struct { - hid_t *dataset; - sources_t *sources; - hid_t file[MANY_FILES]; - hid_t dapl, filetype, memspace, one_by_one_sid, quadrant_dcpl; - unsigned ndatasets; - const char *filename[MANY_FILES]; - char progname[PATH_MAX]; - struct timespec update_interval; - struct { - quadrant_t ul, ur, bl, br, src; - } quadrants; - unsigned int cols, rows; - unsigned int asteps; - unsigned int nsteps; - bool two_dee; - bool wait_for_signal; - enum {vds_off, vds_single, vds_multi} vds; - bool use_vfd_swmr; - bool writer; - bool fixed_array; - hsize_t chunk_dims[RANK]; - hsize_t one_dee_max_dims[RANK]; + hid_t * dataset; + sources_t * sources; + hid_t file[MANY_FILES]; + hid_t dapl, filetype, memspace, one_by_one_sid, quadrant_dcpl; + unsigned ndatasets; + const char * filename[MANY_FILES]; + char progname[PATH_MAX]; + struct timespec update_interval; + struct { + quadrant_t ul, ur, bl, br, src; + } quadrants; + unsigned int cols, rows; + unsigned int asteps; + unsigned int nsteps; + bool two_dee; + bool wait_for_signal; + enum { vds_off, vds_single, vds_multi } vds; + bool use_vfd_swmr; + bool writer; + bool fixed_array; + hsize_t chunk_dims[RANK]; + hsize_t one_dee_max_dims[RANK]; } state_t; static inline state_t state_initializer(void) { - return (state_t){ - .memspace = H5I_INVALID_HID - , .dapl = H5I_INVALID_HID - , .file = {H5I_INVALID_HID, H5I_INVALID_HID, - H5I_INVALID_HID, H5I_INVALID_HID} - , .filetype = H5T_NATIVE_UINT32 - , .one_by_one_sid = H5I_INVALID_HID - , .quadrant_dcpl = H5I_INVALID_HID - , .rows = ROWS - , .cols = COLS - , .ndatasets = 5 - , .asteps = 10 - , .nsteps = 100 - , .filename = {"", "", "", ""} - , .two_dee = false - , .wait_for_signal = true - , .vds = vds_off - , .use_vfd_swmr = true - , .writer = true - , .fixed_array = false - , .one_dee_max_dims = {ROWS, H5S_UNLIMITED} - , .chunk_dims = {ROWS, COLS} - , .update_interval = (struct timespec){ - .tv_sec = 0 - , .tv_nsec = 1000000000UL / 30 /* 1/30 second */}}; + return (state_t){.memspace = H5I_INVALID_HID, + .dapl = H5I_INVALID_HID, + .file = {H5I_INVALID_HID, H5I_INVALID_HID, H5I_INVALID_HID, H5I_INVALID_HID}, + .filetype = H5T_NATIVE_UINT32, + .one_by_one_sid = H5I_INVALID_HID, + .quadrant_dcpl = H5I_INVALID_HID, + .rows = ROWS, + .cols = COLS, + .ndatasets = 5, + .asteps = 10, + .nsteps = 100, + .filename = {"", "", "", ""}, + .two_dee = false, + .wait_for_signal = true, + .vds = vds_off, + .use_vfd_swmr = true, + .writer = true, + .fixed_array = false, + .one_dee_max_dims = {ROWS, H5S_UNLIMITED}, + .chunk_dims = {ROWS, COLS}, + .update_interval = + (struct timespec){.tv_sec = 0, .tv_nsec = 1000000000UL / 30 /* 1/30 second */}}; } static void state_init(state_t *, int, char **); @@ -210,65 +207,61 @@ newmat(unsigned rows, unsigned cols) static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-F] [-M] [-S] [-V] [-W] [-a steps] [-b] [-c cols]\n" - " [-d dims]\n" - " [-n iterations] [-r rows] [-s datasets]\n" - " [-u milliseconds]\n" - "\n" - "-F: fixed maximal dimension for the chunked datasets\n" - "-M: use virtual datasets and many source\n" - " files\n" - "-S: do not use VFD SWMR\n" - "-V: use virtual datasets and a single\n" - " source file\n" - "-W: do not wait for a signal before\n" - " exiting\n" - "-a steps: `steps` between adding attributes\n" - "-b: write data in big-endian byte order\n" - "-c cols: `cols` columns per chunk\n" - "-d 1|one|2|two|both: select dataset expansion in one or\n" - " both dimensions\n" - "-n iterations: how many times to expand each dataset\n" - "-r rows: `rows` rows per chunk\n" - "-s datasets: number of datasets to create\n" - "-u ms: milliseconds interval between updates\n" - " to %s.h5\n" - "\n", - progname, progname); - exit(EXIT_FAILURE); + fprintf(stderr, + "usage: %s [-F] [-M] [-S] [-V] [-W] [-a steps] [-b] [-c cols]\n" + " [-d dims]\n" + " [-n iterations] [-r rows] [-s datasets]\n" + " [-u milliseconds]\n" + "\n" + "-F: fixed maximal dimension for the chunked datasets\n" + "-M: use virtual datasets and many source\n" + " files\n" + "-S: do not use VFD SWMR\n" + "-V: use virtual datasets and a single\n" + " source file\n" + "-W: do not wait for a signal before\n" + " exiting\n" + "-a steps: `steps` between adding attributes\n" + "-b: write data in big-endian byte order\n" + "-c cols: `cols` columns per chunk\n" + "-d 1|one|2|two|both: select dataset expansion in one or\n" + " both dimensions\n" + "-n iterations: how many times to expand each dataset\n" + "-r rows: `rows` rows per chunk\n" + "-s datasets: number of datasets to create\n" + "-u ms: milliseconds interval between updates\n" + " to %s.h5\n" + "\n", + progname, progname); + exit(EXIT_FAILURE); } static void make_quadrant_dataspace(state_t *s, quadrant_t *q) { q->space = H5Screate_simple(NELMTS(s->chunk_dims), s->chunk_dims, - s->two_dee ? two_dee_max_dims : s->one_dee_max_dims); + s->two_dee ? two_dee_max_dims : s->one_dee_max_dims); if (q->space < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); } - if (H5Sselect_hyperslab(q->space, H5S_SELECT_SET, q->start, q->stride, - q->count, q->block) < 0) + if (H5Sselect_hyperslab(q->space, H5S_SELECT_SET, q->start, q->stride, q->count, q->block) < 0) errx(EXIT_FAILURE, "%s: H5Sselect_hyperslab failed", __func__); } static void state_init(state_t *s, int argc, char **argv) { - unsigned long tmp; - int ch; - unsigned i; - const hsize_t dims = 1; - char tfile[PATH_MAX]; - char *end; - unsigned long millis; - quadrant_t * const ul = &s->quadrants.ul, - * const ur = &s->quadrants.ur, - * const bl = &s->quadrants.bl, - * const br = &s->quadrants.br, - * const src = &s->quadrants.src; + unsigned long tmp; + int ch; + unsigned i; + const hsize_t dims = 1; + char tfile[PATH_MAX]; + char * end; + unsigned long millis; + quadrant_t *const ul = &s->quadrants.ul, *const ur = &s->quadrants.ur, *const bl = &s->quadrants.bl, + *const br = &s->quadrants.br, *const src = &s->quadrants.src; const char *personality; *s = state_initializer(); @@ -277,91 +270,86 @@ state_init(state_t *s, int argc, char **argv) while ((ch = getopt(argc, argv, "FMSVWa:bc:d:n:qr:s:u:")) != -1) { switch (ch) { - case 'F': - /* The flag to indicate whether the maximal dimension of the chunked datasets is fixed or unlimited */ - s->fixed_array = true; - break; - case 'M': - s->vds = vds_multi; - break; - case 'S': - s->use_vfd_swmr = false; - break; - case 'V': - s->vds = vds_single; - break; - case 'W': - s->wait_for_signal = false; - break; - case 'd': - if (strcmp(optarg, "1") == 0 || - strcmp(optarg, "one") == 0) - s->two_dee = false; - else if (strcmp(optarg, "2") == 0 || - strcmp(optarg, "two") == 0 || - strcmp(optarg, "both") == 0) - s->two_dee = true; - else { - errx(EXIT_FAILURE, - "bad -d argument \"%s\"", optarg); - } - break; - case 'a': - case 'c': - case 'n': - case 'r': - case 's': - errno = 0; - tmp = strtoul(optarg, &end, 0); - if (end == optarg || *end != '\0') { - errx(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, - optarg); - } else if (errno != 0) { - err(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, - optarg); - } else if (tmp > UINT_MAX) - errx(EXIT_FAILURE, "`-%c` argument `%lu` too large", ch, tmp); - - if ((ch == 'c' || ch == 'r') && tmp == 0) { - errx(EXIT_FAILURE, "`-%c` argument `%lu` must be >= 1", ch, - tmp); - } - - if (ch == 'a') - s->asteps = (unsigned)tmp; - else if (ch == 'c') - s->cols = (unsigned)tmp; - else if (ch == 'n') - s->nsteps = (unsigned)tmp; - else if (ch == 'r') - s->rows = (unsigned)tmp; - else - s->ndatasets = (unsigned)tmp; - break; - case 'b': - s->filetype = H5T_STD_U32BE; - break; - case 'q': - verbosity = 0; - break; - case 'u': - errno = 0; - millis = strtoul(optarg, &end, 0); - if (millis == ULONG_MAX && errno == ERANGE) { - err(EXIT_FAILURE, - "option -p argument \"%s\"", optarg); - } else if (*end != '\0') { - errx(EXIT_FAILURE, - "garbage after -p argument \"%s\"", optarg); - } - s->update_interval.tv_sec = (time_t)(millis / 1000UL); - s->update_interval.tv_nsec = - (long)((millis * 1000000UL) % 1000000000UL); - break; - case '?': - default: - usage(s->progname); - break; + case 'F': + /* The flag to indicate whether the maximal dimension of the chunked datasets is fixed or + * unlimited */ + s->fixed_array = true; + break; + case 'M': + s->vds = vds_multi; + break; + case 'S': + s->use_vfd_swmr = false; + break; + case 'V': + s->vds = vds_single; + break; + case 'W': + s->wait_for_signal = false; + break; + case 'd': + if (strcmp(optarg, "1") == 0 || strcmp(optarg, "one") == 0) + s->two_dee = false; + else if (strcmp(optarg, "2") == 0 || strcmp(optarg, "two") == 0 || + strcmp(optarg, "both") == 0) + s->two_dee = true; + else { + errx(EXIT_FAILURE, "bad -d argument \"%s\"", optarg); + } + break; + case 'a': + case 'c': + case 'n': + case 'r': + case 's': + errno = 0; + tmp = strtoul(optarg, &end, 0); + if (end == optarg || *end != '\0') { + errx(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, optarg); + } + else if (errno != 0) { + err(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, optarg); + } + else if (tmp > UINT_MAX) + errx(EXIT_FAILURE, "`-%c` argument `%lu` too large", ch, tmp); + + if ((ch == 'c' || ch == 'r') && tmp == 0) { + errx(EXIT_FAILURE, "`-%c` argument `%lu` must be >= 1", ch, tmp); + } + + if (ch == 'a') + s->asteps = (unsigned)tmp; + else if (ch == 'c') + s->cols = (unsigned)tmp; + else if (ch == 'n') + s->nsteps = (unsigned)tmp; + else if (ch == 'r') + s->rows = (unsigned)tmp; + else + s->ndatasets = (unsigned)tmp; + break; + case 'b': + s->filetype = H5T_STD_U32BE; + break; + case 'q': + verbosity = 0; + break; + case 'u': + errno = 0; + millis = strtoul(optarg, &end, 0); + if (millis == ULONG_MAX && errno == ERANGE) { + err(EXIT_FAILURE, "option -p argument \"%s\"", optarg); + } + else if (*end != '\0') { + errx(EXIT_FAILURE, "garbage after -p argument \"%s\"", optarg); + } + s->update_interval.tv_sec = (time_t)(millis / 1000UL); + s->update_interval.tv_nsec = (long)((millis * 1000000UL) % 1000000000UL); + break; + case '?': + default: + usage(s->progname); + break; } } argc -= optind; @@ -371,115 +359,104 @@ state_init(state_t *s, int argc, char **argv) errx(EXIT_FAILURE, "unexpected command-line arguments"); if (s->vds != vds_off && s->two_dee) { - errx(EXIT_FAILURE, - "virtual datasets and 2D datasets are mutually exclusive"); + errx(EXIT_FAILURE, "virtual datasets and 2D datasets are mutually exclusive"); } - s->chunk_dims[0] = s->rows; - s->chunk_dims[1] = s->cols; + s->chunk_dims[0] = s->rows; + s->chunk_dims[1] = s->cols; s->one_dee_max_dims[0] = s->rows; - if(s->fixed_array) { + if (s->fixed_array) { s->one_dee_max_dims[1] = s->cols * s->nsteps; - two_dee_max_dims[0] = s->rows * s->nsteps; - two_dee_max_dims[1] = s->cols * s->nsteps; - } else { + two_dee_max_dims[0] = s->rows * s->nsteps; + two_dee_max_dims[1] = s->cols * s->nsteps; + } + else { s->one_dee_max_dims[1] = H5S_UNLIMITED; two_dee_max_dims[0] = two_dee_max_dims[1] = H5S_UNLIMITED; } if (s->vds != vds_off) { const hsize_t half_chunk_dims[RANK] = {s->rows / 2, s->cols / 2}; - hsize_t half_max_dims[RANK]; + hsize_t half_max_dims[RANK]; - if(s->fixed_array) { + if (s->fixed_array) { half_max_dims[0] = s->rows / 2; half_max_dims[1] = (s->cols * s->nsteps) / 2; - } else { + } + else { half_max_dims[0] = s->rows / 2; half_max_dims[1] = H5S_UNLIMITED; } if ((s->quadrant_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", __func__, __LINE__); } if (H5Pset_chunk(s->quadrant_dcpl, RANK, half_chunk_dims) < 0) errx(EXIT_FAILURE, "H5Pset_chunk failed"); - *ul = (quadrant_t){ - .start = {0, 0} - , .stride = {s->rows, s->cols} - , .block = {s->rows / 2, s->cols / 2} - , .count = {1, H5S_UNLIMITED}}; - - *ur = (quadrant_t){ - .start = {s->rows / 2, 0} - , .stride = {s->rows, s->cols} - , .block = {s->rows / 2, s->cols / 2} - , .count = {1, H5S_UNLIMITED}}; - - *bl = (quadrant_t){ - .start = {0, s->cols / 2} - , .stride = {s->rows, s->cols} - , .block = {s->rows / 2, s->cols / 2} - , .count = {1, H5S_UNLIMITED}}; - - *br = (quadrant_t){ - .start = {s->rows / 2, s->cols / 2} - , .stride = {s->rows, s->cols} - , .block = {s->rows / 2, s->cols / 2} - , .count = {1, H5S_UNLIMITED}}; + *ul = (quadrant_t){.start = {0, 0}, + .stride = {s->rows, s->cols}, + .block = {s->rows / 2, s->cols / 2}, + .count = {1, H5S_UNLIMITED}}; + + *ur = (quadrant_t){.start = {s->rows / 2, 0}, + .stride = {s->rows, s->cols}, + .block = {s->rows / 2, s->cols / 2}, + .count = {1, H5S_UNLIMITED}}; + + *bl = (quadrant_t){.start = {0, s->cols / 2}, + .stride = {s->rows, s->cols}, + .block = {s->rows / 2, s->cols / 2}, + .count = {1, H5S_UNLIMITED}}; + + *br = (quadrant_t){.start = {s->rows / 2, s->cols / 2}, + .stride = {s->rows, s->cols}, + .block = {s->rows / 2, s->cols / 2}, + .count = {1, H5S_UNLIMITED}}; make_quadrant_dataspace(s, ul); make_quadrant_dataspace(s, ur); make_quadrant_dataspace(s, bl); make_quadrant_dataspace(s, br); - *src = (quadrant_t){ - .start = {0, 0} - , .stride = {s->rows / 2, s->cols / 2} - , .block = {s->rows / 2, s->cols / 2} - , .count = {1, H5S_UNLIMITED}}; + *src = (quadrant_t){.start = {0, 0}, + .stride = {s->rows / 2, s->cols / 2}, + .block = {s->rows / 2, s->cols / 2}, + .count = {1, H5S_UNLIMITED}}; - src->space = H5Screate_simple(RANK, half_chunk_dims, - half_max_dims); + src->space = H5Screate_simple(RANK, half_chunk_dims, half_max_dims); if (src->space < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); } - if (H5Sselect_hyperslab(src->space, H5S_SELECT_SET, src->start, - src->stride, src->count, src->block) < 0) + if (H5Sselect_hyperslab(src->space, H5S_SELECT_SET, src->start, src->stride, src->count, src->block) < + 0) errx(EXIT_FAILURE, "%s: H5Sselect_hyperslab failed", __func__); ul->src_space = H5Screate_simple(RANK, half_chunk_dims, half_max_dims); if (ul->src_space < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); } ur->src_space = H5Screate_simple(RANK, half_chunk_dims, half_max_dims); if (ur->src_space < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); } bl->src_space = H5Screate_simple(RANK, half_chunk_dims, half_max_dims); if (bl->src_space < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); } br->src_space = H5Screate_simple(RANK, half_chunk_dims, half_max_dims); if (br->src_space < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); } } @@ -496,16 +473,14 @@ state_init(state_t *s, int argc, char **argv) err(EXIT_FAILURE, "could not allocate quadrant dataset handles"); for (i = 0; i < s->ndatasets; i++) { - s->dataset[i] = badhid; - s->sources[i].ul = s->sources[i].ur = s->sources[i].bl = - s->sources[i].br = badhid; + s->dataset[i] = badhid; + s->sources[i].ul = s->sources[i].ur = s->sources[i].bl = s->sources[i].br = badhid; } s->memspace = H5Screate_simple(RANK, s->chunk_dims, NULL); if (s->memspace < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); } s->filename[0] = "vfd_swmr_bigset.h5"; @@ -513,7 +488,8 @@ state_init(state_t *s, int argc, char **argv) s->filename[1] = "vfd_swmr_bigset-ur.h5"; s->filename[2] = "vfd_swmr_bigset-bl.h5"; s->filename[3] = "vfd_swmr_bigset-br.h5"; - } else { + } + else { s->filename[1] = s->filename[0]; s->filename[2] = s->filename[0]; s->filename[3] = s->filename[0]; @@ -521,26 +497,21 @@ state_init(state_t *s, int argc, char **argv) personality = strstr(s->progname, "vfd_swmr_bigset_"); - if (personality != NULL && - strcmp(personality, "vfd_swmr_bigset_writer") == 0) + if (personality != NULL && strcmp(personality, "vfd_swmr_bigset_writer") == 0) s->writer = true; - else if (personality != NULL && - strcmp(personality, "vfd_swmr_bigset_reader") == 0) + else if (personality != NULL && strcmp(personality, "vfd_swmr_bigset_reader") == 0) s->writer = false; else { - errx(EXIT_FAILURE, - "unknown personality, expected vfd_swmr_bigset_{reader,writer}"); + errx(EXIT_FAILURE, "unknown personality, expected vfd_swmr_bigset_{reader,writer}"); } if ((s->dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", __func__, __LINE__); - if (H5Pset_chunk_cache(s->dapl, 0, 0, - H5D_CHUNK_CACHE_W0_DEFAULT) < 0) + if (H5Pset_chunk_cache(s->dapl, 0, 0, H5D_CHUNK_CACHE_W0_DEFAULT) < 0) errx(EXIT_FAILURE, "H5Pset_chunk_cache failed"); - if (s->vds != vds_off && - H5Pset_virtual_view(s->dapl, H5D_VDS_FIRST_MISSING) < 0) + if (s->vds != vds_off && H5Pset_virtual_view(s->dapl, H5D_VDS_FIRST_MISSING) < 0) errx(EXIT_FAILURE, "H5Pset_virtual_view failed"); } @@ -555,14 +526,10 @@ state_destroy(state_t *s) s->dapl = badhid; if (s->vds != vds_off) { - quadrant_t * const ul = &s->quadrants.ul, - * const ur = &s->quadrants.ur, - * const bl = &s->quadrants.bl, - * const br = &s->quadrants.br; - - if (H5Sclose(ul->src_space) < 0 || - H5Sclose(ur->src_space) < 0 || - H5Sclose(bl->src_space) < 0 || + quadrant_t *const ul = &s->quadrants.ul, *const ur = &s->quadrants.ur, *const bl = &s->quadrants.bl, + *const br = &s->quadrants.br; + + if (H5Sclose(ul->src_space) < 0 || H5Sclose(ur->src_space) < 0 || H5Sclose(bl->src_space) < 0 || H5Sclose(br->src_space) < 0) errx(EXIT_FAILURE, "H5Sclose failed"); @@ -592,16 +559,11 @@ state_destroy(state_t *s) static void create_extensible_dset(state_t *s, unsigned int which) { - quadrant_t * const ul = &s->quadrants.ul, - * const ur = &s->quadrants.ur, - * const bl = &s->quadrants.bl, - * const br = &s->quadrants.br, - * const src = &s->quadrants.src; + quadrant_t *const ul = &s->quadrants.ul, *const ur = &s->quadrants.ur, *const bl = &s->quadrants.bl, + *const br = &s->quadrants.br, *const src = &s->quadrants.src; char dname[sizeof("/dataset-9999999999")]; - char ul_dname[sizeof("/ul-dataset-9999999999")], - ur_dname[sizeof("/ur-dataset-9999999999")], - bl_dname[sizeof("/bl-dataset-9999999999")], - br_dname[sizeof("/br-dataset-9999999999")]; + char ul_dname[sizeof("/ul-dataset-9999999999")], ur_dname[sizeof("/ur-dataset-9999999999")], + bl_dname[sizeof("/bl-dataset-9999999999")], br_dname[sizeof("/br-dataset-9999999999")]; hid_t dcpl, ds, filespace; assert(which < s->ndatasets); @@ -610,72 +572,65 @@ create_extensible_dset(state_t *s, unsigned int which) esnprintf(dname, sizeof(dname), "/dataset-%d", which); if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", __func__, __LINE__); } if (H5Pset_chunk(dcpl, RANK, s->chunk_dims) < 0) errx(EXIT_FAILURE, "H5Pset_chunk failed"); if (s->vds != vds_off) { - sources_t * const srcs = &s->sources[which]; + sources_t *const srcs = &s->sources[which]; esnprintf(ul_dname, sizeof(ul_dname), "/ul-dataset-%d", which); esnprintf(ur_dname, sizeof(ur_dname), "/ur-dataset-%d", which); esnprintf(bl_dname, sizeof(bl_dname), "/bl-dataset-%d", which); esnprintf(br_dname, sizeof(br_dname), "/br-dataset-%d", which); - srcs->ul = H5Dcreate2(s->file[0], ul_dname, s->filetype, ul->src_space, - H5P_DEFAULT, s->quadrant_dcpl, s->dapl); + srcs->ul = H5Dcreate2(s->file[0], ul_dname, s->filetype, ul->src_space, H5P_DEFAULT, s->quadrant_dcpl, + s->dapl); if (srcs->ul < 0) errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", ul_dname); - srcs->ur = H5Dcreate2(s->file[1], ur_dname, s->filetype, ur->src_space, - H5P_DEFAULT, s->quadrant_dcpl, s->dapl); + srcs->ur = H5Dcreate2(s->file[1], ur_dname, s->filetype, ur->src_space, H5P_DEFAULT, s->quadrant_dcpl, + s->dapl); if (srcs->ur < 0) errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", ur_dname); - srcs->bl = H5Dcreate2(s->file[2], bl_dname, s->filetype, bl->src_space, - H5P_DEFAULT, s->quadrant_dcpl, s->dapl); + srcs->bl = H5Dcreate2(s->file[2], bl_dname, s->filetype, bl->src_space, H5P_DEFAULT, s->quadrant_dcpl, + s->dapl); if (srcs->bl < 0) errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", bl_dname); - srcs->br = H5Dcreate2(s->file[3], br_dname, s->filetype, br->src_space, - H5P_DEFAULT, s->quadrant_dcpl, s->dapl); + srcs->br = H5Dcreate2(s->file[3], br_dname, s->filetype, br->src_space, H5P_DEFAULT, s->quadrant_dcpl, + s->dapl); if (srcs->br < 0) errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", br_dname); - if (H5Pset_virtual(dcpl, ul->space, s->filename[0], ul_dname, - src->space) < 0) + if (H5Pset_virtual(dcpl, ul->space, s->filename[0], ul_dname, src->space) < 0) errx(EXIT_FAILURE, "%s: H5Pset_virtual failed", __func__); - if (H5Pset_virtual(dcpl, ur->space, s->filename[1], ur_dname, - src->space) < 0) + if (H5Pset_virtual(dcpl, ur->space, s->filename[1], ur_dname, src->space) < 0) errx(EXIT_FAILURE, "%s: H5Pset_virtual failed", __func__); - if (H5Pset_virtual(dcpl, bl->space, s->filename[2], bl_dname, - src->space) < 0) + if (H5Pset_virtual(dcpl, bl->space, s->filename[2], bl_dname, src->space) < 0) errx(EXIT_FAILURE, "%s: H5Pset_virtual failed", __func__); - if (H5Pset_virtual(dcpl, br->space, s->filename[3], br_dname, - src->space) < 0) + if (H5Pset_virtual(dcpl, br->space, s->filename[3], br_dname, src->space) < 0) errx(EXIT_FAILURE, "%s: H5Pset_virtual failed", __func__); } filespace = H5Screate_simple(NELMTS(s->chunk_dims), s->chunk_dims, - s->two_dee ? two_dee_max_dims : s->one_dee_max_dims); + s->two_dee ? two_dee_max_dims : s->one_dee_max_dims); if (filespace < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Screate_simple failed", __func__, __LINE__); } - ds = H5Dcreate2(s->file[0], dname, s->filetype, filespace, - H5P_DEFAULT, dcpl, s->dapl); + ds = H5Dcreate2(s->file[0], dname, s->filetype, filespace, H5P_DEFAULT, dcpl, s->dapl); if (ds < 0) errx(EXIT_FAILURE, "H5Dcreate(, \"%s\", ) failed", dname); @@ -692,7 +647,7 @@ create_extensible_dset(state_t *s, unsigned int which) static void close_extensible_dset(state_t *s, unsigned int which) { - char dname[sizeof("/dataset-9999999999")]; + char dname[sizeof("/dataset-9999999999")]; hid_t ds; assert(which < s->ndatasets); @@ -707,10 +662,10 @@ close_extensible_dset(state_t *s, unsigned int which) s->dataset[which] = badhid; if (s->vds != vds_off && s->writer) { - sources_t * const srcs = &s->sources[which]; + sources_t *const srcs = &s->sources[which]; - if (H5Dclose(srcs->ul) < 0 || H5Dclose(srcs->ur) < 0 || - H5Dclose(srcs->bl) < 0 || H5Dclose(srcs->br) < 0) + if (H5Dclose(srcs->ul) < 0 || H5Dclose(srcs->ur) < 0 || H5Dclose(srcs->bl) < 0 || + H5Dclose(srcs->br) < 0) errx(EXIT_FAILURE, "H5Dclose failed"); srcs->ul = srcs->ur = srcs->bl = srcs->br = badhid; @@ -720,14 +675,14 @@ close_extensible_dset(state_t *s, unsigned int which) static void open_extensible_dset(state_t *s, unsigned int which) { - hsize_t dims[RANK], maxdims[RANK]; - char dname[sizeof("/dataset-9999999999")]; - hid_t ds, filespace, ty; - const int tries = 10000; - int i; - struct timespec last = {0, 0}; + hsize_t dims[RANK], maxdims[RANK]; + char dname[sizeof("/dataset-9999999999")]; + hid_t ds, filespace, ty; + const int tries = 10000; + int i; + struct timespec last = {0, 0}; static const struct timespec ival = {5, 0}; - estack_state_t es; + estack_state_t es; assert(which < s->ndatasets); assert(s->dataset[which] == badhid); @@ -736,8 +691,7 @@ open_extensible_dset(state_t *s, unsigned int which) es = disable_estack(); for (i = 0; i < tries; i++) { - struct timespec one_tenth = {.tv_sec = 0, - .tv_nsec = 1000000000L / 10}; + struct timespec one_tenth = {.tv_sec = 0, .tv_nsec = 1000000000L / 10}; ds = H5Dopen(s->file[0], dname, s->dapl); @@ -745,8 +699,7 @@ open_extensible_dset(state_t *s, unsigned int which) break; if (below_speed_limit(&last, &ival)) { - warnx("H5Dopen(, \"%s\", ) transient failure, %d retries remain", - dname, tries - i - 1); + warnx("H5Dopen(, \"%s\", ) transient failure, %d retries remain", dname, tries - i - 1); } while (nanosleep(&one_tenth, &one_tenth) == -1 && errno == EINTR) ; // do nothing @@ -754,8 +707,7 @@ open_extensible_dset(state_t *s, unsigned int which) restore_estack(es); if (i == tries) { - errx(EXIT_FAILURE, "H5Dopen(, \"%s\", ) failed after %d tries", - dname, tries); + errx(EXIT_FAILURE, "H5Dopen(, \"%s\", ) failed after %d tries", dname, tries); } if ((ty = H5Dget_type(ds)) < 0) @@ -779,18 +731,17 @@ open_extensible_dset(state_t *s, unsigned int which) filespace = badhid; if (s->two_dee) { - if (maxdims[0] != two_dee_max_dims[0] || - maxdims[1] != two_dee_max_dims[1] || + if (maxdims[0] != two_dee_max_dims[0] || maxdims[1] != two_dee_max_dims[1] || maxdims[0] != maxdims[1]) { - errx(EXIT_FAILURE, "Unexpected maximum dimensions %" - PRIuHSIZE " x %" PRIuHSIZE, maxdims[0], maxdims[1]); + errx(EXIT_FAILURE, "Unexpected maximum dimensions %" PRIuHSIZE " x %" PRIuHSIZE, maxdims[0], + maxdims[1]); } - } else if (maxdims[0] != s->one_dee_max_dims[0] || - maxdims[1] != s->one_dee_max_dims[1] || - dims[0] != s->chunk_dims[0]) { - errx(EXIT_FAILURE, "Unexpected maximum dimensions %" - PRIuHSIZE " x %" PRIuHSIZE " or columns %" PRIuHSIZE, - maxdims[0], maxdims[1], dims[1]); + } + else if (maxdims[0] != s->one_dee_max_dims[0] || maxdims[1] != s->one_dee_max_dims[1] || + dims[0] != s->chunk_dims[0]) { + errx(EXIT_FAILURE, + "Unexpected maximum dimensions %" PRIuHSIZE " x %" PRIuHSIZE " or columns %" PRIuHSIZE, + maxdims[0], maxdims[1], dims[1]); } s->dataset[which] = ds; @@ -830,9 +781,7 @@ set_or_verify_matrix(mat_t *mat, unsigned int which, base_t base, bool do_set) for (row = 0; row < mat->rows; row++) { for (col = 0; col < mat->cols; col++) { uint32_t v; - hsize_t i = base.row + row, - j = base.col + col, - u; + hsize_t i = base.row + row, j = base.col + col, u; if (j <= i) u = (i + 1) * (i + 1) - 1 - j; @@ -844,10 +793,11 @@ set_or_verify_matrix(mat_t *mat, unsigned int which, base_t base, bool do_set) if (do_set) matset(mat, row, col, v); else if (matget(mat, row, col) != v) { - errx(EXIT_FAILURE, "matrix mismatch " - "at %" PRIuHSIZE ", %" PRIuHSIZE " (%u, %u), " - "read %" PRIu32 " expecting %" PRIu32, - i, j, row, col, matget(mat, row, col), v); + errx(EXIT_FAILURE, + "matrix mismatch " + "at %" PRIuHSIZE ", %" PRIuHSIZE " (%u, %u), " + "read %" PRIu32 " expecting %" PRIu32, + i, j, row, col, matget(mat, row, col), v); } } } @@ -866,28 +816,24 @@ verify_matrix(mat_t *mat, unsigned int which, base_t base) } static void -verify_chunk(state_t *s, hid_t filespace, - mat_t *mat, unsigned which, base_t base) +verify_chunk(state_t *s, hid_t filespace, mat_t *mat, unsigned which, base_t base) { hsize_t offset[RANK] = {base.row, base.col}; - herr_t status; - hid_t ds; + herr_t status; + hid_t ds; assert(which < s->ndatasets); - dbgf(1, "verifying chunk %" PRIuHSIZE ", %" PRIuHSIZE "\n", - base.row, base.col); + dbgf(1, "verifying chunk %" PRIuHSIZE ", %" PRIuHSIZE "\n", base.row, base.col); ds = s->dataset[which]; - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, - NULL, s->chunk_dims, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, s->chunk_dims, NULL); if (status < 0) errx(EXIT_FAILURE, "H5Sselect_hyperslab failed"); - status = H5Dread(ds, H5T_NATIVE_UINT32, s->memspace, filespace, - H5P_DEFAULT, mat->elt); + status = H5Dread(ds, H5T_NATIVE_UINT32, s->memspace, filespace, H5P_DEFAULT, mat->elt); if (status < 0) errx(EXIT_FAILURE, "H5Dread failed"); @@ -896,12 +842,11 @@ verify_chunk(state_t *s, hid_t filespace, } static void -init_and_write_chunk(state_t *s, hid_t filespace, - mat_t *mat, unsigned which, base_t base) +init_and_write_chunk(state_t *s, hid_t filespace, mat_t *mat, unsigned which, base_t base) { hsize_t offset[RANK] = {base.row, base.col}; - herr_t status; - hid_t ds; + herr_t status; + hid_t ds; assert(which < s->ndatasets); @@ -909,14 +854,12 @@ init_and_write_chunk(state_t *s, hid_t filespace, init_matrix(mat, which, base); - status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, - NULL, s->chunk_dims, NULL); + status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, s->chunk_dims, NULL); if (status < 0) errx(EXIT_FAILURE, "H5Sselect_hyperslab failed"); - status = H5Dwrite(ds, H5T_NATIVE_UINT32, s->memspace, filespace, - H5P_DEFAULT, mat->elt); + status = H5Dwrite(ds, H5T_NATIVE_UINT32, s->memspace, filespace, H5P_DEFAULT, mat->elt); if (status < 0) errx(EXIT_FAILURE, "H5Dwrite failed"); @@ -926,13 +869,12 @@ static void verify_dset_attribute(hid_t ds, unsigned int which, unsigned int step) { unsigned int read_step; - hid_t aid; - char name[sizeof("attr-9999999999")]; + hid_t aid; + char name[sizeof("attr-9999999999")]; esnprintf(name, sizeof(name), "attr-%u", step); - dbgf(1, "verifying attribute %s on dataset %u equals %u\n", name, which, - step); + dbgf(1, "verifying attribute %s on dataset %u equals %u\n", name, which, step); if ((aid = H5Aopen(ds, name, H5P_DEFAULT)) < 0) errx(EXIT_FAILURE, "H5Aopen failed"); @@ -948,12 +890,11 @@ verify_dset_attribute(hid_t ds, unsigned int which, unsigned int step) } static void -verify_extensible_dset(state_t *s, unsigned int which, mat_t *mat, - unsigned *stepp) +verify_extensible_dset(state_t *s, unsigned int which, mat_t *mat, unsigned *stepp) { - hid_t ds, filespace; - hsize_t size[RANK]; - base_t base, last; + hid_t ds, filespace; + hsize_t size[RANK]; + base_t base, last; unsigned int ncols, last_step, step; assert(which < s->ndatasets); @@ -983,27 +924,26 @@ verify_extensible_dset(state_t *s, unsigned int which, mat_t *mat, dbgf(1, "%s: which %u step %u\n", __func__, which, step); if (s->two_dee) { - size[0] = s->chunk_dims[0] * (1 + step); - size[1] = s->chunk_dims[1] * (1 + step); + size[0] = s->chunk_dims[0] * (1 + step); + size[1] = s->chunk_dims[1] * (1 + step); last.row = s->chunk_dims[0] * step + ofs; last.col = s->chunk_dims[1] * step + ofs; - } else { - size[0] = s->chunk_dims[0]; - size[1] = s->chunk_dims[1] * (1 + step); + } + else { + size[0] = s->chunk_dims[0]; + size[1] = s->chunk_dims[1] * (1 + step); last.row = 0; last.col = s->chunk_dims[1] * step + ofs; } dbgf(1, "new size %" PRIuHSIZE ", %" PRIuHSIZE "\n", size[0], size[1]); - dbgf(1, "last row %" PRIuHSIZE " col %" PRIuHSIZE "\n", last.row, - last.col); + dbgf(1, "last row %" PRIuHSIZE " col %" PRIuHSIZE "\n", last.row, last.col); if (s->two_dee) { /* Down the right side, intersecting the bottom row. */ base.col = last.col; - for (base.row = ofs; base.row <= last.row; - base.row += s->chunk_dims[0]) { + for (base.row = ofs; base.row <= last.row; base.row += s->chunk_dims[0]) { verify_chunk(s, filespace, mat, which, base); } @@ -1011,11 +951,11 @@ verify_extensible_dset(state_t *s, unsigned int which, mat_t *mat, * avoid re-reading the bottom-right chunk. */ base.row = last.row; - for (base.col = ofs; base.col < last.col; - base.col += s->chunk_dims[1]) { + for (base.col = ofs; base.col < last.col; base.col += s->chunk_dims[1]) { verify_chunk(s, filespace, mat, which, base); } - } else { + } + else { verify_chunk(s, filespace, mat, which, last); } if (s->asteps != 0 && step % s->asteps == 0) @@ -1030,18 +970,16 @@ out: } static void -add_dset_attribute(const state_t *s, hid_t ds, hid_t sid, unsigned int which, - unsigned int step) +add_dset_attribute(const state_t *s, hid_t ds, hid_t sid, unsigned int which, unsigned int step) { hid_t aid; - char name[sizeof("attr-9999999999")]; + char name[sizeof("attr-9999999999")]; esnprintf(name, sizeof(name), "attr-%u", step); dbgf(1, "setting attribute %s on dataset %u to %u\n", name, which, step); - if ((aid = H5Acreate2(ds, name, s->filetype, sid, H5P_DEFAULT, - H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(ds, name, s->filetype, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) errx(EXIT_FAILURE, "H5Acreate2 failed"); if (H5Awrite(aid, H5T_NATIVE_UINT, &step) < 0) @@ -1051,12 +989,11 @@ add_dset_attribute(const state_t *s, hid_t ds, hid_t sid, unsigned int which, } static void -write_extensible_dset(state_t *s, unsigned int which, unsigned int step, - mat_t *mat) +write_extensible_dset(state_t *s, unsigned int which, unsigned int step, mat_t *mat) { - hid_t ds, filespace; + hid_t ds, filespace; hsize_t size[RANK]; - base_t base, last; + base_t base, last; dbgf(1, "%s: which %u step %u\n", __func__, which, step); @@ -1068,13 +1005,14 @@ write_extensible_dset(state_t *s, unsigned int which, unsigned int step, add_dset_attribute(s, ds, s->one_by_one_sid, which, step); if (s->two_dee) { - size[0] = s->chunk_dims[0] * (1 + step); - size[1] = s->chunk_dims[1] * (1 + step); + size[0] = s->chunk_dims[0] * (1 + step); + size[1] = s->chunk_dims[1] * (1 + step); last.row = s->chunk_dims[0] * step; last.col = s->chunk_dims[1] * step; - } else { - size[0] = s->chunk_dims[0]; - size[1] = s->chunk_dims[1] * (1 + step); + } + else { + size[0] = s->chunk_dims[0]; + size[1] = s->chunk_dims[1] * (1 + step); last.row = 0; last.col = s->chunk_dims[1] * step; } @@ -1082,27 +1020,23 @@ write_extensible_dset(state_t *s, unsigned int which, unsigned int step, dbgf(1, "new size %" PRIuHSIZE ", %" PRIuHSIZE "\n", size[0], size[1]); if (s->vds != vds_off) { - const hsize_t half_size[RANK] = {size[0] / 2, size[1] / 2}; - sources_t * const srcs = &s->sources[which]; + const hsize_t half_size[RANK] = {size[0] / 2, size[1] / 2}; + sources_t *const srcs = &s->sources[which]; if (H5Dset_extent(srcs->ul, half_size) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Dset_extent failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Dset_extent failed", __func__, __LINE__); } if (H5Dset_extent(srcs->ur, half_size) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Dset_extent failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Dset_extent failed", __func__, __LINE__); } if (H5Dset_extent(srcs->bl, half_size) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Dset_extent failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Dset_extent failed", __func__, __LINE__); } if (H5Dset_extent(srcs->br, half_size) < 0) { - errx(EXIT_FAILURE, "%s.%d: H5Dset_extent failed", - __func__, __LINE__); + errx(EXIT_FAILURE, "%s.%d: H5Dset_extent failed", __func__, __LINE__); } - - } else if (H5Dset_extent(ds, size) < 0) + } + else if (H5Dset_extent(ds, size) < 0) errx(EXIT_FAILURE, "H5Dset_extent failed"); filespace = H5Dget_space(ds); @@ -1113,35 +1047,34 @@ write_extensible_dset(state_t *s, unsigned int which, unsigned int step, if (s->two_dee) { base.col = last.col; for (base.row = 0; base.row <= last.row; base.row += s->chunk_dims[0]) { - dbgf(1, "writing chunk %" PRIuHSIZE ", %" PRIuHSIZE "\n", - base.row, base.col); + dbgf(1, "writing chunk %" PRIuHSIZE ", %" PRIuHSIZE "\n", base.row, base.col); init_and_write_chunk(s, filespace, mat, which, base); } base.row = last.row; for (base.col = 0; base.col < last.col; base.col += s->chunk_dims[1]) { - dbgf(1, "writing chunk %" PRIuHSIZE ", %" PRIuHSIZE "\n", - base.row, base.col); + dbgf(1, "writing chunk %" PRIuHSIZE ", %" PRIuHSIZE "\n", base.row, base.col); init_and_write_chunk(s, filespace, mat, which, base); } - } else { + } + else { init_and_write_chunk(s, filespace, mat, which, last); } if (H5Sclose(filespace) < 0) - errx(EXIT_FAILURE, "H5Sclose failed"); + errx(EXIT_FAILURE, "H5Sclose failed"); } int main(int argc, char **argv) { - mat_t *mat; - hid_t fcpl; + mat_t * mat; + hid_t fcpl; sigset_t oldsigs; - herr_t ret; + herr_t ret; unsigned step, which; - state_t s; - size_t i; + state_t s; + size_t i; state_init(&s, argc, argv); @@ -1156,7 +1089,7 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "H5Pset_file_space_strategy"); for (i = 0; i < NELMTS(s.file); i++) { - hid_t fapl; + hid_t fapl; H5F_vfd_swmr_config_t config; if (s.vds != vds_multi && i > 0) { @@ -1173,9 +1106,8 @@ main(int argc, char **argv) if (fapl < 0) errx(EXIT_FAILURE, "vfd_swmr_create_fapl"); - s.file[i] = - s.writer ? H5Fcreate(s.filename[i], H5F_ACC_TRUNC, fcpl, fapl) - : H5Fopen(s.filename[i], H5F_ACC_RDONLY, fapl); + s.file[i] = s.writer ? H5Fcreate(s.filename[i], H5F_ACC_TRUNC, fcpl, fapl) + : H5Fopen(s.filename[i], H5F_ACC_RDONLY, fapl); if (s.file[i] == badhid) errx(EXIT_FAILURE, s.writer ? "H5Fcreate" : "H5Fopen"); @@ -1200,9 +1132,10 @@ main(int argc, char **argv) if (s.ndatasets > s.nsteps) nanosleep(&s.update_interval, NULL); } - } else { + } + else { unsigned *nextstep = calloc(s.ndatasets, sizeof(*nextstep)); - unsigned finished_step; + unsigned finished_step; if (nextstep == NULL) err(EXIT_FAILURE, "could not allocate `nextstep` array"); @@ -1211,11 +1144,11 @@ main(int argc, char **argv) open_extensible_dset(&s, which - 1); do { - finished_step = UINT_MAX; /* the greatest step finished on - * *all* datasets - */ + finished_step = UINT_MAX; /* the greatest step finished on + * *all* datasets + */ - for (which = s.ndatasets; which-- > 0; ) { + for (which = s.ndatasets; which-- > 0;) { dbgf(2, "step %d which %d\n", nextstep[which], which); verify_extensible_dset(&s, which, mat, &nextstep[which]); if (nextstep[which] < finished_step) diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c index ea9ab50..89c8bca 100644 --- a/test/vfd_swmr_common.c +++ b/test/vfd_swmr_common.c @@ -23,7 +23,6 @@ #include "vfd_swmr_common.h" #include "swmr_common.h" - /* Only need the pthread solution if sigtimedwait(2) isn't available. * There's currently no Windows solution, so ignore that for now. */ @@ -46,7 +45,7 @@ hbool_t below_speed_limit(struct timespec *last, const struct timespec *ival) { struct timespec now; - hbool_t result; + hbool_t result; HDassert(0 <= last->tv_nsec && last->tv_nsec < 1000000000L); HDassert(0 <= ival->tv_nsec && ival->tv_nsec < 1000000000L); @@ -153,7 +152,6 @@ restore_estack(estack_state_t es) (void)H5Eset_auto(H5E_DEFAULT, es.efunc, es.edata); } - #ifndef H5_HAVE_WIN32_API /* Store the signal mask at `oldset` and then block all signals. */ void @@ -203,18 +201,18 @@ strsignal(int signum) typedef struct timer_params_t { struct timespec *tick; - hid_t fid; + hid_t fid; } timer_params_t; pthread_mutex_t timer_mutex; -hbool_t timer_stop = FALSE; +hbool_t timer_stop = FALSE; static void * timer_function(void *arg) { timer_params_t *params = (timer_params_t *)arg; - sigset_t sleepset; - hbool_t done = FALSE; + sigset_t sleepset; + hbool_t done = FALSE; /* Ignore any signals */ sigfillset(&sleepset); @@ -257,7 +255,7 @@ void await_signal(hid_t fid) { struct timespec tick = {.tv_sec = 0, .tv_nsec = 1000000000 / 100}; - sigset_t sleepset; + sigset_t sleepset; if (sigfillset(&sleepset) == -1) { HDfprintf(stderr, "%s.%d: could not initialize signal mask", __func__, __LINE__); @@ -280,11 +278,11 @@ await_signal(hid_t fid) * sigtimedwait(2) */ timer_params_t params; - int rc; - pthread_t timer; + int rc; + pthread_t timer; params.tick = &tick; - params.fid = fid; + params.fid = fid; pthread_mutex_init(&timer_mutex, NULL); @@ -310,8 +308,7 @@ await_signal(hid_t fid) const int rc = sigtimedwait(&sleepset, NULL, &tick); if (rc != -1) { - HDfprintf(stderr, "Received %s, wrapping things up.\n", - strsignal(rc)); + HDfprintf(stderr, "Received %s, wrapping things up.\n", strsignal(rc)); break; } else if (rc == -1 && errno == EAGAIN) { @@ -325,8 +322,7 @@ await_signal(hid_t fid) * so squelch errors. */ es = disable_estack(); - (void)H5Aexists_by_name(fid, "nonexistent", "nonexistent", - H5P_DEFAULT); + (void)H5Aexists_by_name(fid, "nonexistent", "nonexistent", H5P_DEFAULT); restore_estack(es); } else if (rc == -1) { @@ -344,24 +340,23 @@ await_signal(hid_t fid) /* Initialize fields in config with the input parameters */ void init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, hbool_t writer, - hbool_t flush_raw_data, uint32_t md_pages_reserved, const char *md_file_fmtstr, ...) + hbool_t flush_raw_data, uint32_t md_pages_reserved, const char *md_file_fmtstr, ...) { va_list ap; - + HDmemset(config, 0, sizeof(H5F_vfd_swmr_config_t)); - config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; - config->pb_expansion_threshold = 0; + config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; + config->pb_expansion_threshold = 0; - config->tick_len = tick_len; - config->max_lag = max_lag; - config->writer = writer; - config->flush_raw_data = flush_raw_data; + config->tick_len = tick_len; + config->max_lag = max_lag; + config->writer = writer; + config->flush_raw_data = flush_raw_data; config->md_pages_reserved = md_pages_reserved; HDva_start(ap, md_file_fmtstr); - evsnprintf(config->md_file_path, sizeof(config->md_file_path), - md_file_fmtstr, ap); + evsnprintf(config->md_file_path, sizeof(config->md_file_path), md_file_fmtstr, ap); HDva_end(ap); } /* init_vfd_swmr_config() */ @@ -375,28 +370,29 @@ init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t * --configure for VFD SWMR or not */ hid_t -vfd_swmr_create_fapl(bool use_latest_format, bool use_vfd_swmr, bool only_meta_pages, H5F_vfd_swmr_config_t *config) +vfd_swmr_create_fapl(bool use_latest_format, bool use_vfd_swmr, bool only_meta_pages, + H5F_vfd_swmr_config_t *config) { hid_t fapl = H5I_INVALID_HID; /* Create file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) return H5I_INVALID_HID; - if(use_latest_format) { - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (use_latest_format) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return H5I_INVALID_HID; } /* Enable page buffering */ - if(H5Pset_page_buffer_size(fapl, 4096, only_meta_pages ? 100 : 0, 0) < 0) + if (H5Pset_page_buffer_size(fapl, 4096, only_meta_pages ? 100 : 0, 0) < 0) return H5I_INVALID_HID; /* * Set up to open the file with VFD SWMR configured. */ /* Enable VFD SWMR configuration */ - if(use_vfd_swmr && H5Pset_vfd_swmr_config(fapl, config) < 0) + if (use_vfd_swmr && H5Pset_vfd_swmr_config(fapl, config) < 0) return H5I_INVALID_HID; return fapl; @@ -411,15 +407,15 @@ vfd_swmr_create_fapl(bool use_latest_format, bool use_vfd_swmr, bool only_meta_p int fetch_env_ulong(const char *varname, unsigned long limit, unsigned long *valp) { - char *end; + char * end; unsigned long ul; - char *tmp; + char * tmp; if ((tmp = HDgetenv(varname)) == NULL) return 0; errno = 0; - ul = HDstrtoul(tmp, &end, 0); + ul = HDstrtoul(tmp, &end, 0); if (ul == ULONG_MAX && errno != 0) { HDfprintf(stderr, "could not parse %s: %s\n", varname, HDstrerror(errno)); return -1; diff --git a/test/vfd_swmr_common.h b/test/vfd_swmr_common.h index c764df8..83472dc 100644 --- a/test/vfd_swmr_common.h +++ b/test/vfd_swmr_common.h @@ -27,9 +27,9 @@ /* The maximum # of records to add/remove from the dataset in one step, * used by vfd_swmr_addrem_writer and vfd_swmr_remove_reader. */ -#define MAX_SIZE_CHANGE 10 +#define MAX_SIZE_CHANGE 10 -#define VFD_SWMR_FILENAME "vfd_swmr_data.h5" /* SWMR test file name */ +#define VFD_SWMR_FILENAME "vfd_swmr_data.h5" /* SWMR test file name */ /* The message sent by writer that the file open is done--releasing the file lock */ #define VFD_SWMR_WRITER_MESSAGE "VFD_SWMR_WRITER_MESSAGE" @@ -40,14 +40,10 @@ typedef struct _estack_state { H5E_auto_t efunc; - void *edata; + void * edata; } estack_state_t; -typedef enum _testsel { - TEST_NONE = 0, - TEST_NULL, - TEST_OOB -} testsel_t; +typedef enum _testsel { TEST_NONE = 0, TEST_NULL, TEST_OOB } testsel_t; /********************/ /* Global Variables */ @@ -66,7 +62,7 @@ H5TEST_DLL hbool_t below_speed_limit(struct timespec *, const struct timespec *) H5TEST_DLL estack_state_t estack_get_state(void); H5TEST_DLL estack_state_t disable_estack(void); -H5TEST_DLL void restore_estack(estack_state_t); +H5TEST_DLL void restore_estack(estack_state_t); #ifndef H5_HAVE_WIN32_API H5TEST_DLL void block_signals(sigset_t *); @@ -74,19 +70,16 @@ H5TEST_DLL void restore_signals(sigset_t *); H5TEST_DLL void await_signal(hid_t); #endif /* H5_HAVE_WIN32_API */ -H5TEST_DLL hid_t -vfd_swmr_create_fapl(bool use_latest_format, bool use_vfd_swmr, bool only_meta_pages, - H5F_vfd_swmr_config_t *config); +H5TEST_DLL hid_t vfd_swmr_create_fapl(bool use_latest_format, bool use_vfd_swmr, bool only_meta_pages, + H5F_vfd_swmr_config_t *config); -H5TEST_DLL void -init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, hbool_t writer, - hbool_t flush_raw_data, uint32_t md_pages_reserved, const char *md_file_fmtstr, ...) - H5_ATTR_FORMAT(printf, 7, 8); +H5TEST_DLL void init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, + hbool_t writer, hbool_t flush_raw_data, uint32_t md_pages_reserved, + const char *md_file_fmtstr, ...) H5_ATTR_FORMAT(printf, 7, 8); H5TEST_DLL void dbgf(int, const char *, ...) H5_ATTR_FORMAT(printf, 2, 3); H5TEST_DLL void evsnprintf(char *, size_t, const char *, va_list); -H5TEST_DLL void esnprintf(char *, size_t, const char *, ...) - H5_ATTR_FORMAT(printf, 3, 4); +H5TEST_DLL void esnprintf(char *, size_t, const char *, ...) H5_ATTR_FORMAT(printf, 3, 4); H5TEST_DLL int fetch_env_ulong(const char *, unsigned long, unsigned long *); diff --git a/test/vfd_swmr_generator.c b/test/vfd_swmr_generator.c index ff20ba7..bfb9371 100644 --- a/test/vfd_swmr_generator.c +++ b/test/vfd_swmr_generator.c @@ -33,9 +33,9 @@ /* * This file needs to access testing codefrom the H5O package. */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ #define H5O_TESTING -#include "H5Opkg.h" /* Object headers */ +#include "H5Opkg.h" /* Object headers */ #ifndef H5_HAVE_WIN32_API @@ -43,18 +43,16 @@ /* Local Macros */ /****************/ -#define CHUNK_SIZE 50 /* Chunk size for created datasets */ +#define CHUNK_SIZE 50 /* Chunk size for created datasets */ /********************/ /* Local Prototypes */ /********************/ -static int gen_skeleton(const char *filename, hbool_t verbose, - hbool_t vfd_swmr_write, int comp_level, const char *index_type, - unsigned random_seed); +static int gen_skeleton(const char *filename, hbool_t verbose, hbool_t vfd_swmr_write, int comp_level, + const char *index_type, unsigned random_seed); static void usage(void); - /*------------------------------------------------------------------------- * Function: gen_skeleton * @@ -86,24 +84,24 @@ static void usage(void); *------------------------------------------------------------------------- */ static int -gen_skeleton(const char *filename, hbool_t verbose, hbool_t vfd_swmr_write, - int comp_level, const char *index_type, unsigned random_seed) +gen_skeleton(const char *filename, hbool_t verbose, hbool_t vfd_swmr_write, int comp_level, + const char *index_type, unsigned random_seed) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t fcpl; /* File creation property list */ - hid_t fapl; /* File access property list */ - hid_t dcpl; /* Dataset creation property list */ - hid_t tid; /* Datatype for dataset elements */ - hid_t sid; /* Dataspace ID */ - hid_t aid; /* Attribute ID */ - hsize_t dims[2] = {1, 0}; /* Dataset starting dimensions */ - hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* Dataset maximum dimensions */ - hsize_t chunk_dims[2] = {1, CHUNK_SIZE}; /* Chunk dimensions */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t fcpl; /* File creation property list */ + hid_t fapl; /* File access property list */ + hid_t dcpl; /* Dataset creation property list */ + hid_t tid; /* Datatype for dataset elements */ + hid_t sid; /* Dataspace ID */ + hid_t aid; /* Attribute ID */ + hsize_t dims[2] = {1, 0}; /* Dataset starting dimensions */ + hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* Dataset maximum dimensions */ + hsize_t chunk_dims[2] = {1, CHUNK_SIZE}; /* Chunk dimensions */ #ifdef FILLVAL_WORKS - symbol_t fillval; /* Dataset fill value */ -#endif /* FILLVAL_WORKS */ - unsigned u, v; /* Local index variable */ - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + symbol_t fillval; /* Dataset fill value */ +#endif /* FILLVAL_WORKS */ + unsigned u, v; /* Local index variable */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ HDassert(filename); HDassert(index_type); @@ -112,77 +110,77 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t vfd_swmr_write, * With one unlimited dimension, we get the extensible array index * type, with two unlimited dimensions, we get a v2 B-tree. */ - if(!HDstrcmp(index_type, "b2")) + if (!HDstrcmp(index_type, "b2")) max_dims[0] = H5S_UNLIMITED; /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Creating file\n"); /* * Set up to create the file with VFD SWMR write configured. */ - if(vfd_swmr_write) { + if (vfd_swmr_write) { /* Allocate memory for the VFD SWMR configuration structure */ - if((config = HDcalloc(1, sizeof(*config))) == NULL) + if ((config = HDcalloc(1, sizeof(*config))) == NULL) return -1; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 10 , vfd_swmr_write, FALSE, 128, "generator-shadow"); + init_vfd_swmr_config(config, 4, 10, vfd_swmr_write, FALSE, 128, "generator-shadow"); } /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(TRUE, vfd_swmr_write, FALSE, config)) < 0) + if ((fapl = vfd_swmr_create_fapl(TRUE, vfd_swmr_write, FALSE, config)) < 0) return -1; /* Set file space strategy to paged aggregation in fcpl */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0) return -1; /* Create the file with VFD SWMR write configured */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) return -1; /* Close file creation property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; /* Create attribute with (shared) random number seed - for sparse test */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) return -1; - if((aid = H5Acreate2(fid, "seed", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(fid, "seed", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(H5Awrite(aid, H5T_NATIVE_UINT, &random_seed) < 0) + if (H5Awrite(aid, H5T_NATIVE_UINT, &random_seed) < 0) return -1; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; /* Create datatype for creating datasets */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) return -1; /* Create dataspace for creating datasets */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) return -1; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) return -1; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) return -1; - if(comp_level >= 0) { - if(H5Pset_deflate(dcpl, (unsigned)comp_level) < 0) + if (comp_level >= 0) { + if (H5Pset_deflate(dcpl, (unsigned)comp_level) < 0) return -1; } /* end if */ #ifdef FILLVAL_WORKS @@ -191,27 +189,28 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t vfd_swmr_write, * here when this is fixed. -NAF 8/11/11 */ HDmemset(&fillval, 0, sizeof(fillval)); fillval.rec_id = (uint64_t)ULLONG_MAX; - if(H5Pset_fill_value(dcpl, tid, &fillval) < 0) + if (H5Pset_fill_value(dcpl, tid, &fillval) < 0) return -1; #endif /* FILLVAL_WORKS */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Creating datasets\n"); #if 0 /* delete this once the race condiditon bug is fixed */ /* JRM */ sleep(1); -#endif /* JRM */ +#endif /* JRM */ /* Create the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - hid_t dsid; /* Dataset ID */ - char name_buf[64]; - hbool_t move_dataspace_message = FALSE; /* Whether to move the dataspace message out of object header chunk #0 */ + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + hid_t dsid; /* Dataset ID */ + char name_buf[64]; + hbool_t move_dataspace_message = + FALSE; /* Whether to move the dataspace message out of object header chunk #0 */ generate_name(name_buf, u, v); - if((dsid = H5Dcreate2(fid, name_buf, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(fid, name_buf, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; /* Determine if the dataspace message for this dataset should be @@ -219,46 +218,46 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t vfd_swmr_write, * (Set to TRUE for every fourth dataset) */ move_dataspace_message = !(HDrandom() % 4); - if(move_dataspace_message) { - unsigned chunk_num; /* Object header chunk # for dataspace message */ + if (move_dataspace_message) { + unsigned chunk_num; /* Object header chunk # for dataspace message */ /* Move the dataspace message to a new object header chunk */ - if(H5O__msg_move_to_new_chunk_test(dsid, H5O_SDSPACE_ID) < 0) + if (H5O__msg_move_to_new_chunk_test(dsid, H5O_SDSPACE_ID) < 0) return -1; /* Retrieve the chunk # for the dataspace message */ chunk_num = UINT_MAX; - if(H5O__msg_get_chunkno_test(dsid, H5O_SDSPACE_ID, &chunk_num) < 0) + if (H5O__msg_get_chunkno_test(dsid, H5O_SDSPACE_ID, &chunk_num) < 0) return -1; /* Should not be in chunk #0 for now */ - if(0 == chunk_num) + if (0 == chunk_num) return -1; } /* end if */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) return -1; } /* end for */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Closing objects\n"); /* Close everythign */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) return -1; - if(verbose) + if (verbose) HDfprintf(stderr, "Closing file\n"); - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /* Free the config structure */ - if(config) + if (config) HDfree(config); return 0; } /* end gen_skeleton() */ @@ -286,27 +285,28 @@ usage(void) HDexit(1); } /* end usage() */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - int comp_level = -1; /* Compression level (-1 is no compression) */ - hbool_t verbose = TRUE; /* Whether to emit some informational messages */ - hbool_t vfd_swmr_write = FALSE; /* Whether to create file with VFD SWMR access */ - const char *index_type = "b1"; /* Chunk index type */ - hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variables */ - int temp; + int comp_level = -1; /* Compression level (-1 is no compression) */ + hbool_t verbose = TRUE; /* Whether to emit some informational messages */ + hbool_t vfd_swmr_write = FALSE; /* Whether to create file with VFD SWMR access */ + const char *index_type = "b1"; /* Chunk index type */ + hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variables */ + int temp; /* Parse command line options */ - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* Compress dataset chunks */ case 'c': comp_level = HDatoi(argv[u + 1]); - if(comp_level < -1 || comp_level > 9) + if (comp_level < -1 || comp_level > 9) usage(); u += 2; break; @@ -314,8 +314,7 @@ int main(int argc, const char *argv[]) /* Chunk index type */ case 'i': index_type = argv[u + 1]; - if(HDstrcmp(index_type, "ea") - && HDstrcmp(index_type, "b2")) + if (HDstrcmp(index_type, "ea") && HDstrcmp(index_type, "b2")) usage(); u += 2; break; @@ -323,8 +322,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': use_seed = TRUE; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -347,20 +346,20 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ - } /* end while */ - } /* end if */ + } /* end if */ + } /* end while */ + } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "Parameters:\n"); HDfprintf(stderr, "\tswmr writes %s\n", vfd_swmr_write ? "on" : "off"); HDfprintf(stderr, "\tcompression level = %d\n", comp_level); HDfprintf(stderr, "\tindex type = %s\n", index_type); } /* end if */ - + /* Set the random seed */ - if(!use_seed) { + if (!use_seed) { struct timeval t; HDgettimeofday(&t, NULL); @@ -371,11 +370,11 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "Using generator random seed (used in sparse test only): %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "Generating skeleton file: %s\n", VFD_SWMR_FILENAME); /* Generate file skeleton */ - if(gen_skeleton(VFD_SWMR_FILENAME, verbose, vfd_swmr_write, comp_level, index_type, random_seed) < 0) { + if (gen_skeleton(VFD_SWMR_FILENAME, verbose, vfd_swmr_write, comp_level, index_type, random_seed) < 0) { HDfprintf(stderr, "Error generating skeleton file!\n"); HDexit(1); } /* end if */ diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 561254a..e960919 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "hdf5.h" @@ -28,26 +28,23 @@ #include typedef struct { - hid_t file, filetype, one_by_one_sid; - char filename[PATH_MAX]; - char progname[PATH_MAX]; - unsigned int asteps; - unsigned int csteps; - unsigned int nsteps; - bool wait_for_signal; - bool use_vfd_swmr; + hid_t file, filetype, one_by_one_sid; + char filename[PATH_MAX]; + char progname[PATH_MAX]; + unsigned int asteps; + unsigned int csteps; + unsigned int nsteps; + bool wait_for_signal; + bool use_vfd_swmr; } state_t; -#define ALL_HID_INITIALIZER (state_t){ \ - .file = H5I_INVALID_HID \ - , .one_by_one_sid = H5I_INVALID_HID \ - , .filename = "" \ - , .filetype = H5T_NATIVE_UINT32 \ - , .asteps = 10 \ - , .csteps = 10 \ - , .nsteps = 100 \ - , .wait_for_signal = true \ - , .use_vfd_swmr = true} +#define ALL_HID_INITIALIZER \ + (state_t) \ + { \ + .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ + .filetype = H5T_NATIVE_UINT32, .asteps = 10, .csteps = 10, .nsteps = 100, .wait_for_signal = true, \ + .use_vfd_swmr = true \ + } static void state_init(state_t *, int, char **); @@ -56,29 +53,30 @@ static const hid_t badhid = H5I_INVALID_HID; static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-S] [-W] [-a steps] [-b] [-c]\n" - " [-n iterations]\n" - "\n" - "-S: do not use VFD SWMR\n" - "-W: do not wait for a signal before\n" - " exiting\n" - "-a steps: `steps` between adding attributes\n" - "-b: write data in big-endian byte order\n" - "-c steps: `steps` between communication between the writer and reader\n" - "-n ngroups: the number of groups\n" - "\n", - progname); - exit(EXIT_FAILURE); + fprintf(stderr, + "usage: %s [-S] [-W] [-a steps] [-b] [-c]\n" + " [-n iterations]\n" + "\n" + "-S: do not use VFD SWMR\n" + "-W: do not wait for a signal before\n" + " exiting\n" + "-a steps: `steps` between adding attributes\n" + "-b: write data in big-endian byte order\n" + "-c steps: `steps` between communication between the writer and reader\n" + "-n ngroups: the number of groups\n" + "\n", + progname); + exit(EXIT_FAILURE); } static void state_init(state_t *s, int argc, char **argv) { unsigned long tmp; - int ch; + int ch; const hsize_t dims = 1; - char tfile[PATH_MAX]; - char *end; + char tfile[PATH_MAX]; + char * end; *s = ALL_HID_INITIALIZER; esnprintf(tfile, sizeof(tfile), "%s", argv[0]); @@ -86,43 +84,43 @@ state_init(state_t *s, int argc, char **argv) while ((ch = getopt(argc, argv, "SWa:bc:n:q")) != -1) { switch (ch) { - case 'S': - s->use_vfd_swmr = false; - break; - case 'W': - s->wait_for_signal = false; - break; - case 'a': - case 'c': - case 'n': - errno = 0; - tmp = strtoul(optarg, &end, 0); - if (end == optarg || *end != '\0') { - errx(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, - optarg); - } else if (errno != 0) { - err(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, - optarg); - } else if (tmp > UINT_MAX) - errx(EXIT_FAILURE, "`-%c` argument `%lu` too large", ch, tmp); - - if (ch == 'a') - s->asteps = (unsigned)tmp; - else if (ch == 'c') - s->csteps = (unsigned)tmp; - else if (ch == 'n') - s->nsteps = (unsigned)tmp; - break; - case 'b': - s->filetype = H5T_STD_U32BE; - break; - case 'q': - verbosity = 0; - break; - case '?': - default: - usage(s->progname); - break; + case 'S': + s->use_vfd_swmr = false; + break; + case 'W': + s->wait_for_signal = false; + break; + case 'a': + case 'c': + case 'n': + errno = 0; + tmp = strtoul(optarg, &end, 0); + if (end == optarg || *end != '\0') { + errx(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, optarg); + } + else if (errno != 0) { + err(EXIT_FAILURE, "couldn't parse `-%c` argument `%s`", ch, optarg); + } + else if (tmp > UINT_MAX) + errx(EXIT_FAILURE, "`-%c` argument `%lu` too large", ch, tmp); + + if (ch == 'a') + s->asteps = (unsigned)tmp; + else if (ch == 'c') + s->csteps = (unsigned)tmp; + else if (ch == 'n') + s->nsteps = (unsigned)tmp; + break; + case 'b': + s->filetype = H5T_STD_U32BE; + break; + case 'q': + verbosity = 0; + break; + case '?': + default: + usage(s->progname); + break; } } argc -= optind; @@ -132,10 +130,10 @@ state_init(state_t *s, int argc, char **argv) if ((s->one_by_one_sid = H5Screate_simple(1, &dims, &dims)) < 0) errx(EXIT_FAILURE, "H5Screate_simple failed"); - if( s->csteps < 1 || s->csteps > s->nsteps) + if (s->csteps < 1 || s->csteps > s->nsteps) errx(EXIT_FAILURE, "communication interval is out of bounds"); - if( s->asteps < 1 || s->asteps > s->nsteps) + if (s->asteps < 1 || s->asteps > s->nsteps) errx(EXIT_FAILURE, "attribute interval is out of bounds"); if (argc > 0) @@ -148,14 +146,13 @@ static void add_group_attribute(const state_t *s, hid_t g, hid_t sid, unsigned int which) { hid_t aid; - char name[sizeof("attr-9999999999")]; + char name[sizeof("attr-9999999999")]; esnprintf(name, sizeof(name), "attr-%u", which); dbgf(1, "setting attribute %s on group %u to %u\n", name, which, which); - if ((aid = H5Acreate2(g, name, s->filetype, sid, H5P_DEFAULT, - H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(g, name, s->filetype, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) errx(EXIT_FAILURE, "H5Acreate2 failed"); if (H5Awrite(aid, H5T_NATIVE_UINT, &which) < 0) @@ -164,11 +161,10 @@ add_group_attribute(const state_t *s, hid_t g, hid_t sid, unsigned int which) errx(EXIT_FAILURE, "H5Aclose failed"); } - static void write_group(state_t *s, unsigned int which) { - char name[sizeof("/group-9999999999")]; + char name[sizeof("/group-9999999999")]; hid_t g; assert(which < s->nsteps); @@ -191,14 +187,13 @@ static bool verify_group_attribute(hid_t g, unsigned int which) { estack_state_t es; - unsigned int read_which; - hid_t aid; - char name[sizeof("attr-9999999999")]; + unsigned int read_which; + hid_t aid; + char name[sizeof("attr-9999999999")]; esnprintf(name, sizeof(name), "attr-%u", which); - dbgf(1, "verifying attribute %s on group %u equals %u\n", name, which, - which); + dbgf(1, "verifying attribute %s on group %u equals %u\n", name, which, which); es = disable_estack(); if ((aid = H5Aopen(g, name, H5P_DEFAULT)) < 0) { @@ -224,17 +219,17 @@ verify_group_attribute(hid_t g, unsigned int which) static bool verify_group(state_t *s, unsigned int which) { - char name[sizeof("/group-9999999999")]; - hid_t g; + char name[sizeof("/group-9999999999")]; + hid_t g; estack_state_t es; - bool result; + bool result; assert(which < s->nsteps); esnprintf(name, sizeof(name), "/group-%d", which); es = disable_estack(); - g = H5Gopen(s->file, name, H5P_DEFAULT); + g = H5Gopen(s->file, name, H5P_DEFAULT); restore_estack(es); if (g < 0) @@ -263,32 +258,29 @@ decisleep(uint32_t tenths) int main(int argc, char **argv) { - hid_t fapl, fcpl; - herr_t ret; - unsigned step; - bool writer; - state_t s; - const char *personality; + hid_t fapl, fcpl; + herr_t ret; + unsigned step; + bool writer; + state_t s; + const char * personality; H5F_vfd_swmr_config_t config; - const char *fifo_writer_to_reader = "./fifo_group_writer_to_reader"; - const char *fifo_reader_to_writer = "./fifo_group_reader_to_writer"; - int fd_writer_to_reader, fd_reader_to_writer; - int notify = 0, verify = 0; - unsigned int i; + const char * fifo_writer_to_reader = "./fifo_group_writer_to_reader"; + const char * fifo_reader_to_writer = "./fifo_group_reader_to_writer"; + int fd_writer_to_reader, fd_reader_to_writer; + int notify = 0, verify = 0; + unsigned int i; state_init(&s, argc, argv); personality = strstr(s.progname, "vfd_swmr_group_"); - if (personality != NULL && - strcmp(personality, "vfd_swmr_group_writer") == 0) + if (personality != NULL && strcmp(personality, "vfd_swmr_group_writer") == 0) writer = true; - else if (personality != NULL && - strcmp(personality, "vfd_swmr_group_reader") == 0) + else if (personality != NULL && strcmp(personality, "vfd_swmr_group_reader") == 0) writer = false; else { - errx(EXIT_FAILURE, - "unknown personality, expected vfd_swmr_group_{reader,writer}"); + errx(EXIT_FAILURE, "unknown personality, expected vfd_swmr_group_{reader,writer}"); } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ @@ -350,7 +342,7 @@ main(int argc, char **argv) /* During the wait, writer makes repeated HDF5 API calls * to trigger EOT at approximately the correct time */ - for(i = 0; i < config.max_lag + 1; i++) { + for (i = 0; i < config.max_lag + 1; i++) { decisleep(config.tick_len); H5Aexists(s.file, "nonexistent"); } @@ -365,11 +357,13 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "received message %d, expecting %d", notify, verify); } } - } else { + } + else { for (step = 0; step < s.nsteps; step++) { dbgf(2, "reader: step %d\n", step); - /* At communication interval, waits for the writer to finish creation before starting verification */ + /* At communication interval, waits for the writer to finish creation before starting verification + */ if (step % s.csteps == 0) { /* The writer should have bumped up the value of notify. * Do the same with verify and confirm it */ @@ -412,11 +406,11 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "HDclose"); /* Reader finishes last and deletes the named pipes */ - if(!writer) { - if(HDremove(fifo_writer_to_reader) != 0) + if (!writer) { + if (HDremove(fifo_writer_to_reader) != 0) errx(EXIT_FAILURE, "fifo_writer_to_reader deletion failed"); - if(HDremove(fifo_reader_to_writer) != 0) + if (HDremove(fifo_reader_to_writer) != 0) errx(EXIT_FAILURE, "fifo_reader_to_writer deletion failed"); } diff --git a/test/vfd_swmr_reader.c b/test/vfd_swmr_reader.c index 111d37c..4fb36b3 100644 --- a/test/vfd_swmr_reader.c +++ b/test/vfd_swmr_reader.c @@ -39,19 +39,17 @@ /* Local Prototypes */ /********************/ -static int check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, - const char *sym_name, symbol_t *record, hid_t rec_sid); -static int read_records(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed, unsigned long nseconds, unsigned poll_time, - unsigned ncommon, unsigned nrandom); +static int check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, const char *sym_name, + symbol_t *record, hid_t rec_sid); +static int read_records(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed, + unsigned long nseconds, unsigned poll_time, unsigned ncommon, unsigned nrandom); /*******************/ /* Local Variables */ /*******************/ -static hid_t symbol_tid = -1; /* The type ID for the SWMR datasets */ +static hid_t symbol_tid = -1; /* The type ID for the SWMR datasets */ - /*------------------------------------------------------------------------- * Function: check_dataset * @@ -85,16 +83,16 @@ static hid_t symbol_tid = -1; /* The type ID for the SWMR datasets */ *------------------------------------------------------------------------- */ static int -check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, - const char *sym_name, symbol_t *record, hid_t rec_sid) +check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, const char *sym_name, symbol_t *record, + hid_t rec_sid) { - int fill_count = 0; /* # of times fill value (0) was read - * instead of the expected value. - */ - hid_t dsid = H5I_INVALID_HID; /* Dataset ID */ - hid_t file_sid = H5I_INVALID_HID; /* Dataset's space ID */ - hssize_t snpoints; /* Number of elements in dataset */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + int fill_count = 0; /* # of times fill value (0) was read + * instead of the expected value. + */ + hid_t dsid = H5I_INVALID_HID; /* Dataset ID */ + hid_t file_sid = H5I_INVALID_HID; /* Dataset's space ID */ + hssize_t snpoints; /* Number of elements in dataset */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ HDassert(fid >= 0); HDassert(sym_name); @@ -102,41 +100,40 @@ check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, HDassert(rec_sid >= 0); /* Open dataset for symbol */ - if((dsid = H5Dopen2(fid, sym_name, H5P_DEFAULT)) < 0) { + if ((dsid = H5Dopen2(fid, sym_name, H5P_DEFAULT)) < 0) { fprintf(stderr, "%s.%d: H5Dopen2 failed\n", __func__, __LINE__); goto error; } /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(dsid)) < 0) { + if ((file_sid = H5Dget_space(dsid)) < 0) { fprintf(stderr, "%s.%d: H5Dget_space failed\n", __func__, __LINE__); goto error; } /* Get the number of elements (= records, for 1-D datasets) */ - if((snpoints = H5Sget_simple_extent_npoints(file_sid)) < 0) { - fprintf(stderr, "%s.%d: H5Sget_simple_extent_npoints failed\n", - __func__, __LINE__); + if ((snpoints = H5Sget_simple_extent_npoints(file_sid)) < 0) { + fprintf(stderr, "%s.%d: H5Sget_simple_extent_npoints failed\n", __func__, __LINE__); goto error; } /* Emit informational message */ - if(verbose) - HDfprintf(verbose_file, "READER: Symbol = '%s', # of records = %lld\n", sym_name, (long long)snpoints); + if (verbose) + HDfprintf(verbose_file, "READER: Symbol = '%s', # of records = %lld\n", sym_name, + (long long)snpoints); /* Check if there are records for symbol */ - if(snpoints > 0) { + if (snpoints > 0) { /* Choose the last record in the dataset */ start[1] = (hsize_t)(snpoints - 1); - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { - fprintf(stderr, "%s.%d: H5Sselect_hyperslab failed\n", - __func__, __LINE__); + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { + fprintf(stderr, "%s.%d: H5Sselect_hyperslab failed\n", __func__, __LINE__); goto error; } /* Read record from dataset */ record->rec_id = UINT64_MAX; - if(H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) { + if (H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) { fprintf(stderr, "%s.%d: H5Dread failed\n", __func__, __LINE__); goto error; } @@ -149,31 +146,28 @@ check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, HDgettimeofday(&tv, NULL); - if(verbose) { + if (verbose) { HDfprintf(verbose_file, "*** READER ERROR ***\n"); HDfprintf(verbose_file, "Incorrect record value!\n"); HDfprintf(verbose_file, - "Time = %jd.%06jd, Symbol = '%s'" - ", # of records = %" PRIdHSIZE - ", record->rec_id = %" PRIu64 "\n", - (intmax_t)tv.tv_sec, (intmax_t)tv.tv_usec, - sym_name, snpoints, record->rec_id); + "Time = %jd.%06jd, Symbol = '%s'" + ", # of records = %" PRIdHSIZE ", record->rec_id = %" PRIu64 "\n", + (intmax_t)tv.tv_sec, (intmax_t)tv.tv_usec, sym_name, snpoints, record->rec_id); } /* end if */ - fprintf(stderr, - "%s.%d: record value %" PRIu64 " != %" PRIuHSIZE "\n", - __func__, __LINE__, record->rec_id, start[1]); + fprintf(stderr, "%s.%d: record value %" PRIu64 " != %" PRIuHSIZE "\n", __func__, __LINE__, + record->rec_id, start[1]); goto error; } /* end if */ - } /* end if */ + } /* end if */ /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) { + if (H5Sclose(file_sid) < 0) { fprintf(stderr, "%s.%d: H5Sclose failed\n", __func__, __LINE__); goto error; } /* Close dataset for symbol */ - if(H5Dclose(dsid) < 0) { + if (H5Dclose(dsid) < 0) { fprintf(stderr, "%s.%d: H5Dclose failed\n", __func__, __LINE__); goto error; } @@ -181,15 +175,16 @@ check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, return fill_count; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(file_sid); H5Dclose(dsid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end check_dataset() */ - /*------------------------------------------------------------------------- * Function: read_records * @@ -232,21 +227,20 @@ error: *------------------------------------------------------------------------- */ static int -read_records(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed, unsigned long nseconds, unsigned poll_time, - unsigned ncommon, unsigned nrandom) +read_records(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed, + unsigned long nseconds, unsigned poll_time, unsigned ncommon, unsigned nrandom) { - time_t start_time; /* Starting time */ - time_t curr_time; /* Current time */ - symbol_info_t **sym_com = NULL; /* Pointers to array of common dataset IDs */ - symbol_info_t **sym_rand = NULL; /* Pointers to array of random dataset IDs */ - hid_t mem_sid = H5I_INVALID_HID; /* Memory dataspace ID */ - hid_t fid = H5I_INVALID_HID; /* SWMR test file ID */ - hid_t fapl = H5I_INVALID_HID; /* file access property list */ - symbol_t record; /* The record to read from the dataset */ - unsigned v; /* Local index variable */ - hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + time_t start_time; /* Starting time */ + time_t curr_time; /* Current time */ + symbol_info_t ** sym_com = NULL; /* Pointers to array of common dataset IDs */ + symbol_info_t ** sym_rand = NULL; /* Pointers to array of random dataset IDs */ + hid_t mem_sid = H5I_INVALID_HID; /* Memory dataspace ID */ + hid_t fid = H5I_INVALID_HID; /* SWMR test file ID */ + hid_t fapl = H5I_INVALID_HID; /* file access property list */ + symbol_t record; /* The record to read from the dataset */ + unsigned v; /* Local index variable */ + hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ HDassert(filename); HDassert(nseconds != 0); @@ -257,86 +251,86 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, HDmemset(&record, 0, sizeof(record)); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Choosing datasets\n"); /* Allocate space for 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Allocate array to hold pointers to symbols for common datasets */ - if(NULL == (sym_com = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * ncommon))) { + if (NULL == (sym_com = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * ncommon))) { fprintf(stderr, "%s.%d: malloc failed\n", __func__, __LINE__); goto error; } /* Open the common datasets */ - for(v = 0; v < ncommon; v++) { - unsigned offset; /* Offset of symbol to use */ + for (v = 0; v < ncommon; v++) { + unsigned offset; /* Offset of symbol to use */ /* Determine the offset of the symbol, within level 0 symbols */ /* (level 0 symbols are the most common symbols) */ - offset = (unsigned)((unsigned)HDrandom() % symbol_count[0]); + offset = (unsigned)((unsigned)HDrandom() % symbol_count[0]); sym_com[v] = &symbol_info[0][offset]; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Common symbol #%u = '%s'\n", v, symbol_info[0][offset].name); } /* end for */ - } /* end if */ + } /* end if */ /* Allocate space for 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Allocate array to hold pointers to symbols for random datasets */ - if(NULL == (sym_rand = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * nrandom))) { + if (NULL == (sym_rand = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * nrandom))) { fprintf(stderr, "%s.%d: malloc failed\n", __func__, __LINE__); goto error; } /* Determine the random datasets */ - for(v = 0; v < nrandom; v++) { - symbol_info_t *sym; /* Symbol to use */ + for (v = 0; v < nrandom; v++) { + symbol_info_t *sym; /* Symbol to use */ /* Determine the symbol, within all symbols */ - if(NULL == (sym = choose_dataset(NULL, NULL))) + if (NULL == (sym = choose_dataset(NULL, NULL))) return -1; sym_rand[v] = sym; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Random symbol #%u = '%s'\n", v, sym->name); } /* end for */ - } /* end if */ + } /* end if */ /* Create a dataspace for the record to read */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) { + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) { fprintf(stderr, "%s.%d: H5Screate failed\n", __func__, __LINE__); goto error; } /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Going to open file and read records\n"); /* Get the starting time */ start_time = HDtime(NULL); - curr_time = start_time; + curr_time = start_time; /* Allocate memory for the configuration structure */ - if((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) { + if ((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) { fprintf(stderr, "%s.%d: malloc failed\n", __func__, __LINE__); goto error; } /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5 , FALSE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, config)) < 0) { + if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, config)) < 0) { fprintf(stderr, "%s.%d: vfd_swmr_create_fapl failed\n", __func__, __LINE__); goto error; } /* Log I/O when verbose output it enbabled */ - if(use_log_vfd) { + if (use_log_vfd) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "vfd_swmr_reader.log.%u", random_seed); @@ -345,77 +339,74 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, } /* end if */ /* Loop over reading records until [at least] the correct # of seconds have passed */ - while(curr_time < (time_t)(start_time + (time_t)nseconds)) { + while (curr_time < (time_t)(start_time + (time_t)nseconds)) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Opening file: %s\n", filename); /* Open the file with VFD SWMR configured */ /* Remove H5E_BEGIN_TRY/END_TRY if you want to see the error stack */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; - if(fid < 0) { + } + H5E_END_TRY; + if (fid < 0) { HDfprintf(stderr, "READER: Error in opening the file: %s\n", filename); goto error; } /* Check 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Checking common symbols after FILE OPEN\n"); /* Iterate over common datasets */ - for(v = 0; v < ncommon; v++) { + for (v = 0; v < ncommon; v++) { /* Check common dataset */ const int fill_count = - check_dataset(fid, verbose, verbose_file, sym_com[v]->name, - &record, mem_sid); - if(fill_count < 0) { - fprintf(stderr, "%s.%d: check_dataset failed\n", - __func__, __LINE__); + check_dataset(fid, verbose, verbose_file, sym_com[v]->name, &record, mem_sid); + if (fill_count < 0) { + fprintf(stderr, "%s.%d: check_dataset failed\n", __func__, __LINE__); goto error; } HDmemset(&record, 0, sizeof(record)); if (fill_count > 0) { - fprintf(stderr, "common dataset: read fill at %d records\n", - fill_count); + fprintf(stderr, "common dataset: read fill at %d records\n", fill_count); } } /* end for */ - } /* end if */ + } /* end if */ /* Check 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Checking random symbols after FILE OPEN\n"); /* Iterate over random datasets */ - for(v = 0; v < nrandom; v++) { + for (v = 0; v < nrandom; v++) { /* Check random dataset */ - const int fill_count = check_dataset(fid, verbose, verbose_file, - sym_rand[v]->name, &record, mem_sid); - if(fill_count < 0) { - fprintf(stderr, "%s.%d: check_dataset failed\n", - __func__, __LINE__); + const int fill_count = + check_dataset(fid, verbose, verbose_file, sym_rand[v]->name, &record, mem_sid); + if (fill_count < 0) { + fprintf(stderr, "%s.%d: check_dataset failed\n", __func__, __LINE__); goto error; } HDmemset(&record, 0, sizeof(record)); if (fill_count > 0) { - fprintf(stderr, "random dataset: read fill at %d records\n", - fill_count); + fprintf(stderr, "random dataset: read fill at %d records\n", fill_count); } } /* end for */ - } /* end if */ + } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Closing file\n"); - + /* Close the file */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { fprintf(stderr, "%s.%d: H5Fclose failed\n", __func__, __LINE__); goto error; } @@ -428,32 +419,32 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, } /* end while */ /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) { + if (H5Sclose(mem_sid) < 0) { fprintf(stderr, "%s.%d: H5Sclose failed\n", __func__, __LINE__); goto error; } /* Close the fapl */ - if(H5Pclose(fapl) < 0) { + if (H5Pclose(fapl) < 0) { fprintf(stderr, "%s.%d: H5Pclose failed\n", __func__, __LINE__); goto error; } - if(config) + if (config) HDfree(config); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Closing datasets\n"); /* Close 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Release array holding dataset ID's for random datasets */ HDfree(sym_rand); } /* end if */ /* Close 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Release array holding dataset ID's for common datasets */ HDfree(sym_com); } /* end if */ @@ -461,20 +452,22 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, return 0; error: - if(config) + if (config) HDfree(config); - if(sym_rand) + if (sym_rand) HDfree(sym_rand); - if(sym_com) + if (sym_com) HDfree(sym_com); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(mem_sid); H5Fclose(fid); H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end read_records() */ @@ -498,31 +491,32 @@ usage(void) HDexit(1); } -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - long nseconds = 0; /* # of seconds to test */ - int poll_time = 1; /* # of seconds between polling */ - int ncommon = 5; /* # of common symbols to poll */ - int nrandom = 10; /* # of random symbols to poll */ - hbool_t verbose = TRUE; /* Whether to emit some informational messages */ - FILE *verbose_file = NULL; /* File handle for verbose output */ - hbool_t use_seed = FALSE; /* Set to 1 if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variables */ - int temp; + long nseconds = 0; /* # of seconds to test */ + int poll_time = 1; /* # of seconds between polling */ + int ncommon = 5; /* # of common symbols to poll */ + int nrandom = 10; /* # of random symbols to poll */ + hbool_t verbose = TRUE; /* Whether to emit some informational messages */ + FILE * verbose_file = NULL; /* File handle for verbose output */ + hbool_t use_seed = FALSE; /* Set to 1 if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variables */ + int temp; /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of common symbols to poll */ case 'h': ncommon = HDatoi(argv[u + 1]); - if(ncommon < 0) + if (ncommon < 0) usage(); u += 2; break; @@ -530,7 +524,7 @@ int main(int argc, const char *argv[]) /* # of random symbols to poll */ case 'l': nrandom = HDatoi(argv[u + 1]); - if(nrandom < 0) + if (nrandom < 0) usage(); u += 2; break; @@ -544,8 +538,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': use_seed = TRUE; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -555,7 +549,7 @@ int main(int argc, const char *argv[]) /* # of seconds between polling */ case 's': poll_time = HDatoi(argv[u + 1]); - if(poll_time < 0) + if (poll_time < 0) usage(); u += 2; break; @@ -564,24 +558,24 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nseconds = HDatol(argv[u]); - if(nseconds <= 0) + if (nseconds <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nseconds <= 0) + } /* end while */ + } /* end if */ + if (nseconds <= 0) usage(); - if(poll_time >= nseconds) + if (poll_time >= nseconds) usage(); /* Set the random seed */ - if(!use_seed) { + if (!use_seed) { struct timeval t; HDgettimeofday(&t, NULL); @@ -590,18 +584,18 @@ int main(int argc, const char *argv[]) HDsrandom(random_seed); /* Open output file */ - if(verbose) { + if (verbose) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "vfd_swmr_reader.out.%u", random_seed); - if(NULL == (verbose_file = HDfopen(verbose_name, "w"))) { + if (NULL == (verbose_file = HDfopen(verbose_name, "w"))) { HDfprintf(stderr, "READER: Can't open verbose output file!\n"); HDexit(1); } } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(verbose_file, "READER: Parameters:\n"); HDfprintf(verbose_file, "\t# of seconds between polling = %d\n", poll_time); HDfprintf(verbose_file, "\t# of common symbols to poll = %d\n", ncommon); @@ -613,49 +607,50 @@ int main(int argc, const char *argv[]) HDfprintf(stdout, "READER: Using reader random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) { + if (generate_symbols() < 0) { HDfprintf(stderr, "READER: Error generating symbol names!\n"); HDexit(1); } /* end if */ /* Create datatype for creating datasets */ - if((symbol_tid = create_symbol_datatype()) < 0) { + if ((symbol_tid = create_symbol_datatype()) < 0) { HDfprintf(stderr, "READER: Error creating symbol datatype!\n"); HDexit(1); } /* Reading records from datasets */ - if(read_records(VFD_SWMR_FILENAME, verbose, verbose_file, random_seed, (unsigned long)nseconds, (unsigned)poll_time, (unsigned)ncommon, (unsigned)nrandom) < 0) { + if (read_records(VFD_SWMR_FILENAME, verbose, verbose_file, random_seed, (unsigned long)nseconds, + (unsigned)poll_time, (unsigned)ncommon, (unsigned)nrandom) < 0) { HDfprintf(stderr, "READER: Error reading records from datasets (random_seed = %u)!\n", random_seed); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "READER: Error releasing symbols!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "READER: Closing objects\n"); /* Close objects created */ - if(H5Tclose(symbol_tid) < 0) { + if (H5Tclose(symbol_tid) < 0) { HDfprintf(stderr, "READER: Error closing symbol datatype!\n"); HDexit(1); } /* end if */ /* Close the output file */ - if(verbose) + if (verbose) HDfclose(verbose_file); return 0; diff --git a/test/vfd_swmr_remove_reader.c b/test/vfd_swmr_remove_reader.c index d63b2cd..6a84dba 100644 --- a/test/vfd_swmr_remove_reader.c +++ b/test/vfd_swmr_remove_reader.c @@ -45,13 +45,10 @@ static hid_t symbol_tid = -1; /* Local Prototypes */ /********************/ -static int check_dataset(hid_t, hid_t, unsigned, const char *, - symbol_t *, hid_t); -static int read_records(const char *, unsigned, unsigned long, - unsigned, unsigned, unsigned); +static int check_dataset(hid_t, hid_t, unsigned, const char *, symbol_t *, hid_t); +static int read_records(const char *, unsigned, unsigned long, unsigned, unsigned, unsigned); static void usage(void); - /*------------------------------------------------------------------------- * Function: check_dataset * @@ -82,13 +79,12 @@ static void usage(void); *------------------------------------------------------------------------- */ static int -check_dataset(hid_t fid, hid_t dapl, unsigned verbose, const char *sym_name, symbol_t *record, - hid_t rec_sid) +check_dataset(hid_t fid, hid_t dapl, unsigned verbose, const char *sym_name, symbol_t *record, hid_t rec_sid) { - hid_t dsid; /* Dataset ID */ - hid_t file_sid; /* Dataset's space ID */ - hssize_t snpoints; /* Number of elements in dataset */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + hid_t dsid; /* Dataset ID */ + hid_t file_sid; /* Dataset's space ID */ + hssize_t snpoints; /* Number of elements in dataset */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ HDassert(fid >= 0); HDassert(sym_name); @@ -96,15 +92,15 @@ check_dataset(hid_t fid, hid_t dapl, unsigned verbose, const char *sym_name, sym HDassert(rec_sid >= 0); /* Open dataset for symbol */ - if((dsid = H5Dopen2(fid, sym_name, dapl)) < 0) + if ((dsid = H5Dopen2(fid, sym_name, dapl)) < 0) goto error; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(dsid)) < 0) + if ((file_sid = H5Dget_space(dsid)) < 0) goto error; /* Get the number of elements (= records, for 1-D datasets) */ - if((snpoints = H5Sget_simple_extent_npoints(file_sid)) < 0) + if ((snpoints = H5Sget_simple_extent_npoints(file_sid)) < 0) goto error; /* Back off by one: it's possible that the metadata indicating @@ -114,67 +110,71 @@ check_dataset(hid_t fid, hid_t dapl, unsigned verbose, const char *sym_name, sym snpoints -= MAX_SIZE_CHANGE; /* Emit informational message */ - if(verbose) { - HDfprintf(stderr, "READER: Symbol = '%s'" - ", # of records = %" PRIdHSIZE "\n", sym_name, snpoints); + if (verbose) { + HDfprintf(stderr, + "READER: Symbol = '%s'" + ", # of records = %" PRIdHSIZE "\n", + sym_name, snpoints); } /* Check if there are records for symbol */ - if(snpoints > 0) { + if (snpoints > 0) { /* Choose a random record in the dataset, choosing the last record half * the time */ start[1] = (hsize_t)(HDrandom() % (snpoints * 2)); - if(start[1] > (hsize_t)(snpoints - 1)) + if (start[1] > (hsize_t)(snpoints - 1)) start[1] = (hsize_t)(snpoints - 1); - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; - /* Read record from dataset */ + /* Read record from dataset */ #ifdef FILLVAL_WORKS /* When shrinking the dataset, we cannot guarantee that the buffer will * even be touched, unless there is a fill value. Since fill values do * not work with SWMR currently (see note in swmr_generator.c), we * simply initialize rec_id to 0. */ record->rec_id = (uint64_t)ULLONG_MAX - 1; -#else /* FILLVAL_WORKS */ +#else /* FILLVAL_WORKS */ record->rec_id = (uint64_t)0; #endif /* FILLVAL_WORKS */ - if(H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) + if (H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) goto error; /* Verify record value - note that it may be the fill value, because the * chunk may be deleted before the object header has the updated * dimensions */ - if(record->rec_id != start[1] && record->rec_id != 0) { + if (record->rec_id != start[1] && record->rec_id != 0) { HDfprintf(stderr, "*** READER: ERROR ***\n"); HDfprintf(stderr, "Incorrect record value!\n"); - HDfprintf(stderr, "Symbol = '%s', # of records = %" PRIdHSIZE - ", record->rec_id = %" PRIx64 ", expected %" PRIxHSIZE "\n", - sym_name, snpoints, record->rec_id, start[1]); + HDfprintf(stderr, + "Symbol = '%s', # of records = %" PRIdHSIZE ", record->rec_id = %" PRIx64 + ", expected %" PRIxHSIZE "\n", + sym_name, snpoints, record->rec_id, start[1]); return -1; } /* end if */ - } /* end if */ + } /* end if */ /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) goto error; /* Close dataset for symbol */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(file_sid); H5Dclose(dsid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end check_dataset() */ - /*------------------------------------------------------------------------- * Function: read_records * @@ -211,20 +211,20 @@ error: *------------------------------------------------------------------------- */ static int -read_records(const char *filename, unsigned verbose, unsigned long nseconds, - unsigned poll_time, unsigned ncommon, unsigned nrandom) +read_records(const char *filename, unsigned verbose, unsigned long nseconds, unsigned poll_time, + unsigned ncommon, unsigned nrandom) { - time_t start_time; /* Starting time */ - time_t curr_time; /* Current time */ - symbol_info_t **sym_com = NULL; /* Pointers to array of common dataset IDs */ - symbol_info_t **sym_rand = NULL; /* Pointers to array of random dataset IDs */ - hid_t dapl; - hid_t mem_sid; /* Memory dataspace ID */ - hid_t fid; /* SWMR test file ID */ - hid_t fapl; /* File access property list */ - symbol_t record; /* The record to add to the dataset */ - unsigned v; /* Local index variable */ - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + time_t start_time; /* Starting time */ + time_t curr_time; /* Current time */ + symbol_info_t ** sym_com = NULL; /* Pointers to array of common dataset IDs */ + symbol_info_t ** sym_rand = NULL; /* Pointers to array of random dataset IDs */ + hid_t dapl; + hid_t mem_sid; /* Memory dataspace ID */ + hid_t fid; /* SWMR test file ID */ + hid_t fapl; /* File access property list */ + symbol_t record; /* The record to add to the dataset */ + unsigned v; /* Local index variable */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ HDassert(filename); HDassert(nseconds != 0); @@ -237,134 +237,135 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) errx(EXIT_FAILURE, "%s.%d: H5Pcreate failed", __func__, __LINE__); - if (H5Pset_chunk_cache(dapl, H5D_CHUNK_CACHE_NSLOTS_DEFAULT, 0, - H5D_CHUNK_CACHE_W0_DEFAULT) < 0) + if (H5Pset_chunk_cache(dapl, H5D_CHUNK_CACHE_NSLOTS_DEFAULT, 0, H5D_CHUNK_CACHE_W0_DEFAULT) < 0) errx(EXIT_FAILURE, "H5Pset_chunk_cache failed"); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Choosing datasets\n"); /* Allocate space for 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Allocate array to hold pointers to symbols for common datasets */ - if(NULL == (sym_com = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * ncommon))) + if (NULL == (sym_com = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * ncommon))) goto error; /* Open the common datasets */ - for(v = 0; v < ncommon; v++) { - unsigned offset; /* Offset of symbol to use */ + for (v = 0; v < ncommon; v++) { + unsigned offset; /* Offset of symbol to use */ /* Determine the offset of the symbol, within level 0 symbols */ /* (level 0 symbols are the most common symbols) */ - offset = (unsigned)HDrandom() % symbol_count[0]; + offset = (unsigned)HDrandom() % symbol_count[0]; sym_com[v] = &symbol_info[0][offset]; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Common symbol #%u = '%s'\n", v, symbol_info[0][offset].name); } /* end for */ - } /* end if */ + } /* end if */ /* Allocate space for 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Allocate array to hold pointers to symbols for random datasets */ - if(NULL == (sym_rand = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * nrandom))) + if (NULL == (sym_rand = (symbol_info_t **)HDmalloc(sizeof(symbol_info_t *) * nrandom))) goto error; /* Determine the random datasets */ - for(v = 0; v < nrandom; v++) { - symbol_info_t *sym; /* Symbol to use */ + for (v = 0; v < nrandom; v++) { + symbol_info_t *sym; /* Symbol to use */ /* Determine the symbol, within all symbols */ - if(NULL == (sym = choose_dataset(NULL, NULL))) + if (NULL == (sym = choose_dataset(NULL, NULL))) goto error; sym_rand[v] = sym; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Random symbol #%u = '%s'\n", v, sym->name); } /* end for */ - } /* end if */ + } /* end if */ /* Create a dataspace for the record to read */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) goto error; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Reading records\n"); /* Get the starting time */ start_time = HDtime(NULL); - curr_time = start_time; + curr_time = start_time; /* Allocate memory for the configuration structure */ - if((config = HDcalloc(1, sizeof(*config))) == NULL) + if ((config = HDcalloc(1, sizeof(*config))) == NULL) goto error; - /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5 , FALSE, FALSE, 128, "./rw-shadow"); + /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, config)) < 0) { + if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, config)) < 0) { fprintf(stderr, "%s.%d: vfd_swmr_create_fapl failed\n", __func__, __LINE__); goto error; } /* Loop over reading records until [at least] the correct # of seconds have passed */ - while(curr_time < (time_t)(start_time + (time_t)nseconds)) { + while (curr_time < (time_t)(start_time + (time_t)nseconds)) { /* Emit informational message */ - if(verbose) - HDfprintf(stderr, "READER: Opening file: %s\n", filename); + if (verbose) + HDfprintf(stderr, "READER: Opening file: %s\n", filename); /* Open the file */ /* Remove H5E_BEGIN_TRY/END_TRY if you want to see the error stack */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; - if(fid < 0) { + } + H5E_END_TRY; + if (fid < 0) { HDfprintf(stderr, "READER: Error in opening the file: %s\n", filename); goto error; } /* Check 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Checking common symbols\n"); /* Iterate over common datasets */ - for(v = 0; v < ncommon; v++) { + for (v = 0; v < ncommon; v++) { /* Check common dataset */ - if(check_dataset(fid, dapl, verbose, sym_com[v]->name, &record, mem_sid) < 0) + if (check_dataset(fid, dapl, verbose, sym_com[v]->name, &record, mem_sid) < 0) goto error; HDmemset(&record, 0, sizeof(record)); } /* end for */ - } /* end if */ + } /* end if */ /* Check 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Checking random symbols\n"); /* Iterate over random datasets */ - for(v = 0; v < nrandom; v++) { + for (v = 0; v < nrandom; v++) { /* Check random dataset */ - if(check_dataset(fid, dapl, verbose, sym_rand[v]->name, &record, mem_sid) < 0) + if (check_dataset(fid, dapl, verbose, sym_rand[v]->name, &record, mem_sid) < 0) goto error; HDmemset(&record, 0, sizeof(record)); } /* end for */ - } /* end if */ + } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Closing file\n"); /* Close the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* Sleep for the appropriate # of seconds */ @@ -375,28 +376,28 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, } /* end while */ /* Close the fapl */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(config) + if (config) HDfree(config); /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) + if (H5Sclose(mem_sid) < 0) goto error; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Closing datasets\n"); /* Close 'random' datasets, if any */ - if(nrandom > 0) { + if (nrandom > 0) { /* Release array holding dataset ID's for random datasets */ HDfree(sym_rand); } /* end if */ /* Close 'common' datasets, if any */ - if(ncommon > 0) { + if (ncommon > 0) { /* Release array holding dataset ID's for common datasets */ HDfree(sym_com); } /* end if */ @@ -404,21 +405,23 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, return 0; error: - if(config) + if (config) HDfree(config); - if(sym_rand) + if (sym_rand) HDfree(sym_rand); - if(sym_com) + if (sym_com) HDfree(sym_com); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(mem_sid); H5Fclose(fid); H5Pclose(fapl); H5Pclose(dapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; @@ -439,32 +442,33 @@ usage(void) printf("and will generate a random seed (no -r given).\n"); printf("\n"); HDexit(1); -} +} -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - long nseconds = 0; /* # of seconds to test */ - int poll_time = 1; /* # of seconds between polling */ - int ncommon = 5; /* # of common symbols to poll */ - int nrandom = 10; /* # of random symbols to poll */ - unsigned verbose = 1; /* Whether to emit some informational messages */ - unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variables */ - int temp; + long nseconds = 0; /* # of seconds to test */ + int poll_time = 1; /* # of seconds between polling */ + int ncommon = 5; /* # of common symbols to poll */ + int nrandom = 10; /* # of random symbols to poll */ + unsigned verbose = 1; /* Whether to emit some informational messages */ + unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variables */ + int temp; /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of common symbols to poll */ case 'h': ncommon = HDatoi(argv[u + 1]); - if(ncommon < 0) + if (ncommon < 0) usage(); u += 2; break; @@ -472,7 +476,7 @@ int main(int argc, const char *argv[]) /* # of random symbols to poll */ case 'l': nrandom = HDatoi(argv[u + 1]); - if(nrandom < 0) + if (nrandom < 0) usage(); u += 2; break; @@ -486,8 +490,8 @@ int main(int argc, const char *argv[]) /* Random # seed */ case 'r': use_seed = 1; - temp = HDatoi(argv[u + 1]); - if(temp < 0) + temp = HDatoi(argv[u + 1]); + if (temp < 0) usage(); else random_seed = (unsigned)temp; @@ -497,7 +501,7 @@ int main(int argc, const char *argv[]) /* # of seconds between polling */ case 's': poll_time = HDatoi(argv[u + 1]); - if(poll_time < 0) + if (poll_time < 0) usage(); u += 2; break; @@ -506,24 +510,24 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nseconds = HDatol(argv[u]); - if(nseconds <= 0) + if (nseconds <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nseconds <= 0) + } /* end while */ + } /* end if */ + if (nseconds <= 0) usage(); - if(poll_time >= nseconds) + if (poll_time >= nseconds) usage(); /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "READER: Parameters:\n"); HDfprintf(stderr, "\t# of seconds between polling = %d\n", poll_time); HDfprintf(stderr, "\t# of common symbols to poll = %d\n", ncommon); @@ -532,7 +536,7 @@ int main(int argc, const char *argv[]) } /* end if */ /* Set the random seed */ - if(0 == use_seed) { + if (0 == use_seed) { struct timeval t; HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); @@ -542,41 +546,42 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "READER: Using reader random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) { + if (generate_symbols() < 0) { HDfprintf(stderr, "READER: Error generating symbol names!\n"); HDexit(1); } /* end if */ /* Create datatype for creating datasets */ - if((symbol_tid = create_symbol_datatype()) < 0) + if ((symbol_tid = create_symbol_datatype()) < 0) return -1; /* Reading records from datasets */ - if(read_records(VFD_SWMR_FILENAME, verbose, (unsigned long)nseconds, (unsigned)poll_time, (unsigned)ncommon, (unsigned)nrandom) < 0) { + if (read_records(VFD_SWMR_FILENAME, verbose, (unsigned long)nseconds, (unsigned)poll_time, + (unsigned)ncommon, (unsigned)nrandom) < 0) { HDfprintf(stderr, "READER: Error reading records from datasets!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "READER: Error releasing symbols!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Closing objects\n"); /* Close objects created */ - if(H5Tclose(symbol_tid) < 0) { + if (H5Tclose(symbol_tid) < 0) { HDfprintf(stderr, "READER: Error closing symbol datatype!\n"); HDexit(1); } /* end if */ diff --git a/test/vfd_swmr_remove_writer.c b/test/vfd_swmr_remove_writer.c index e8dd998..10de126 100644 --- a/test/vfd_swmr_remove_writer.c +++ b/test/vfd_swmr_remove_writer.c @@ -43,18 +43,16 @@ /****************/ /* The maximum number of records to remove in one step */ -#define MAX_REMOVE_SIZE 10 +#define MAX_REMOVE_SIZE 10 /********************/ /* Local Prototypes */ /********************/ static hid_t open_skeleton(const char *filename, unsigned verbose, unsigned old); -static int remove_records(hid_t fid, unsigned verbose, unsigned long nshrinks, - unsigned long flush_count); -static void usage(void); +static int remove_records(hid_t fid, unsigned verbose, unsigned long nshrinks, unsigned long flush_count); +static void usage(void); - /*------------------------------------------------------------------------- * Function: open_skeleton * @@ -74,81 +72,81 @@ static void usage(void); *------------------------------------------------------------------------- */ static hid_t -open_skeleton(const char *filename, unsigned verbose, - unsigned old H5_ATTR_UNUSED) +open_skeleton(const char *filename, unsigned verbose, unsigned old H5_ATTR_UNUSED) { - hid_t fid = -1; /* File ID for new HDF5 file */ - hid_t fapl = -1; /* File access property list */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t dim[2]; /* Dataspace dimensions */ - unsigned u, v; /* Local index variable */ - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + hid_t fid = -1; /* File ID for new HDF5 file */ + hid_t fapl = -1; /* File access property list */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dim[2]; /* Dataspace dimensions */ + unsigned u, v; /* Local index variable */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ HDassert(filename); /* Allocate memory for the configuration structure */ - if((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) goto error; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5 , TRUE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, config)) < 0) + if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, config)) < 0) goto error; /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) goto error; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(config) + if (config) HDfree(config); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Opening datasets\n"); /* Open the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - if((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + if ((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) goto error; - if((sid = H5Dget_space(symbol_info[u][v].dsid)) < 0) + if ((sid = H5Dget_space(symbol_info[u][v].dsid)) < 0) goto error; - if(2 != H5Sget_simple_extent_ndims(sid)) + if (2 != H5Sget_simple_extent_ndims(sid)) goto error; - if(H5Sget_simple_extent_dims(sid, dim, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dim, NULL) < 0) goto error; symbol_info[u][v].nrecords = dim[1]; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; } /* end for */ return fid; -error: - if(config) +error: + if (config) HDfree(config); - H5E_BEGIN_TRY { - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) + H5E_BEGIN_TRY + { + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) H5Dclose(symbol_info[u][v].dsid); H5Sclose(sid); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* open_skeleton() */ - /*------------------------------------------------------------------------- * Function: remove_records * @@ -175,63 +173,64 @@ error: static int remove_records(hid_t fid, unsigned verbose, unsigned long nshrinks, unsigned long flush_count) { - unsigned long shrink_to_flush; /* # of removals before flush */ - hsize_t dim[2] = {1,0}; /* Dataspace dimensions */ - unsigned long u, v; /* Local index variables */ + unsigned long shrink_to_flush; /* # of removals before flush */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + unsigned long u, v; /* Local index variables */ HDassert(fid >= 0); /* Remove records from random datasets, according to frequency distribution */ shrink_to_flush = flush_count; - for(u = 0; u < nshrinks; u++) { - symbol_info_t *symbol; /* Symbol to remove record from */ - hsize_t remove_size; /* Size to reduce dataset dimension by */ + for (u = 0; u < nshrinks; u++) { + symbol_info_t *symbol; /* Symbol to remove record from */ + hsize_t remove_size; /* Size to reduce dataset dimension by */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(NULL, NULL); /* Shrink the dataset's dataspace */ remove_size = (hsize_t)HDrandom() % MAX_REMOVE_SIZE + 1; - if(remove_size > symbol->nrecords) + if (remove_size > symbol->nrecords) symbol->nrecords = 0; else symbol->nrecords -= remove_size; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) goto error; /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ shrink_to_flush--; /* Check for counter being reached */ - if(0 == shrink_to_flush) { + if (0 == shrink_to_flush) { /* Reset flush counter */ shrink_to_flush = flush_count; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Closing datasets\n"); /* Close the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) - if(H5Dclose(symbol_info[u][v].dsid) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) + if (H5Dclose(symbol_info[u][v].dsid) < 0) goto error; return 0; error: - H5E_BEGIN_TRY { - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) + H5E_BEGIN_TRY + { + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) H5Dclose(symbol_info[u][v].dsid); - - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* remove_records() */ @@ -254,33 +253,34 @@ usage(void) HDexit(1); } /* usage() */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { sigset_t oldset; - hid_t fid; /* File ID for file opened */ - long nshrinks = 0; /* # of times to shrink the dataset */ - long flush_count = 1000; /* # of records to write between flushing file */ - unsigned verbose = 1; /* Whether to emit some informational messages */ - unsigned old = 0; /* Whether to use non-latest-format when opening file */ - unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ - unsigned random_seed = 0; /* Random # seed */ - unsigned u; /* Local index variable */ - int temp; + hid_t fid; /* File ID for file opened */ + long nshrinks = 0; /* # of times to shrink the dataset */ + long flush_count = 1000; /* # of records to write between flushing file */ + unsigned verbose = 1; /* Whether to emit some informational messages */ + unsigned old = 0; /* Whether to use non-latest-format when opening file */ + unsigned use_seed = 0; /* Set to 1 if a seed was set on the command line */ + unsigned random_seed = 0; /* Random # seed */ + unsigned u; /* Local index variable */ + int temp; block_signals(&oldset); /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of records to write between flushing file */ case 'f': flush_count = HDatol(argv[u + 1]); - if(flush_count < 0) + if (flush_count < 0) usage(); u += 2; break; @@ -290,11 +290,11 @@ int main(int argc, const char *argv[]) verbose = 0; u++; break; - + /* Random # seed */ case 'r': - use_seed = 1; - temp = HDatoi(argv[u + 1]); + use_seed = 1; + temp = HDatoi(argv[u + 1]); random_seed = (unsigned)temp; u += 2; break; @@ -309,31 +309,31 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nshrinks = HDatol(argv[u]); - if(nshrinks <= 0) + if (nshrinks <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nshrinks <= 0) + } /* end while */ + } /* end if */ + if (nshrinks <= 0) usage(); - if(flush_count >= nshrinks) + if (flush_count >= nshrinks) usage(); /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "WRITER: Parameters:\n"); HDfprintf(stderr, "\t# of shrinks between flushes = %ld\n", flush_count); HDfprintf(stderr, "\t# of shrinks = %ld\n", nshrinks); } /* end if */ /* Set the random seed */ - if(0 == use_seed) { + if (0 == use_seed) { struct timeval t; HDgettimeofday(&t, NULL); random_seed = (unsigned)(t.tv_usec); @@ -343,21 +343,20 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "WRITER: Using writer random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Emit informational message */ - if(verbose) { - HDfprintf(stderr, "WRITER: Opening skeleton file: %s\n", - VFD_SWMR_FILENAME); + if (verbose) { + HDfprintf(stderr, "WRITER: Opening skeleton file: %s\n", VFD_SWMR_FILENAME); } /* Open file skeleton */ - if((fid = open_skeleton(VFD_SWMR_FILENAME, verbose, old)) < 0) { + if ((fid = open_skeleton(VFD_SWMR_FILENAME, verbose, old)) < 0) { HDfprintf(stderr, "WRITER: Error opening skeleton file!\n"); HDexit(1); } /* end if */ @@ -366,21 +365,21 @@ int main(int argc, const char *argv[]) h5_send_message(VFD_SWMR_WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Removing records\n"); /* Remove records from datasets */ - if(remove_records(fid, verbose, (unsigned long)nshrinks, (unsigned long)flush_count) < 0) { + if (remove_records(fid, verbose, (unsigned long)nshrinks, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "WRITER: Error removing records from datasets!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "WRITER: Error releasing symbols!\n"); HDexit(1); } /* end if */ @@ -390,11 +389,11 @@ int main(int argc, const char *argv[]) restore_signals(&oldset); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Closing objects\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "WRITER: Error closing file!\n"); HDexit(1); } /* end if */ diff --git a/test/vfd_swmr_sparse_reader.c b/test/vfd_swmr_sparse_reader.c index 2726df9..e79d44e 100644 --- a/test/vfd_swmr_sparse_reader.c +++ b/test/vfd_swmr_sparse_reader.c @@ -36,7 +36,6 @@ #ifndef H5_HAVE_WIN32_API - /****************/ /* Local Macros */ /****************/ @@ -53,13 +52,12 @@ static hid_t symbol_tid = (-1); /* Local Prototypes */ /********************/ -static int check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, - symbol_t *record, hid_t rec_sid); -static int read_records(const char *filename, unsigned verbose, unsigned long nrecords, - unsigned poll_time, unsigned reopen_count); +static int check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t *record, + hid_t rec_sid); +static int read_records(const char *filename, unsigned verbose, unsigned long nrecords, unsigned poll_time, + unsigned reopen_count); static void usage(void); - /*------------------------------------------------------------------------- * Function: check_dataset * @@ -91,13 +89,12 @@ static void usage(void); *------------------------------------------------------------------------- */ static int -check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t *record, - hid_t rec_sid) +check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t *record, hid_t rec_sid) { - hid_t dsid = -1; /* Dataset ID */ - hid_t file_sid = -1; /* Dataset's space ID */ - hsize_t start[2] = {0, 0}; /* Hyperslab selection values */ - hsize_t count[2] = {1, 1}; /* Hyperslab selection values */ + hid_t dsid = -1; /* Dataset ID */ + hid_t file_sid = -1; /* Dataset's space ID */ + hsize_t start[2] = {0, 0}; /* Hyperslab selection values */ + hsize_t count[2] = {1, 1}; /* Hyperslab selection values */ HDassert(fid >= 0); HDassert(symbol); @@ -105,58 +102,60 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t HDassert(rec_sid >= 0); /* Open dataset for symbol */ - if((dsid = H5Dopen2(fid, symbol->name, H5P_DEFAULT)) < 0) + if ((dsid = H5Dopen2(fid, symbol->name, H5P_DEFAULT)) < 0) goto error; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(dsid)) < 0) + if ((file_sid = H5Dget_space(dsid)) < 0) goto error; /* Choose the random record in the dataset (will be the same as chosen by * the writer) */ start[1] = (hsize_t)HDrandom() % symbol->nrecords; - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; /* Emit informational message */ - if(verbose) - HDfprintf(stderr, "READER: Symbol = '%s', nrecords = %Hu, name = %s, location = %Hu, %Hu\n", \ + if (verbose) + HDfprintf(stderr, "READER: Symbol = '%s', nrecords = %Hu, name = %s, location = %Hu, %Hu\n", symbol->name, symbol->nrecords, symbol->name, start[0], start[1]); /* Read record from dataset */ record->rec_id = UINT64_MAX; - if(H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) + if (H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0) goto error; /* Verify record value */ - if(record->rec_id != start[1]) { + if (record->rec_id != start[1]) { HDfprintf(stderr, "*** READER: ERROR ***\n"); HDfprintf(stderr, "Incorrect record value!\n"); - HDfprintf(stderr, "Symbol = '%s', location = %Hu, %Hu, record->rec_id = %" PRIu64 "\n", symbol->name, start[0], start[1], record->rec_id); + HDfprintf(stderr, "Symbol = '%s', location = %Hu, %Hu, record->rec_id = %" PRIu64 "\n", symbol->name, + start[0], start[1], record->rec_id); goto error; } /* end if */ /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) goto error; /* Close dataset for symbol */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(file_sid); H5Dclose(dsid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end check_dataset() */ - /*------------------------------------------------------------------------- * Function: read_records * @@ -177,7 +176,7 @@ error: * The amount of time to sleep (s). * * unsigned reopen_count - * + * * * Return: Success: 0 * Failure: -1 @@ -185,60 +184,63 @@ error: *------------------------------------------------------------------------- */ static int -read_records(const char *filename, unsigned verbose, unsigned long nrecords, - unsigned poll_time, unsigned reopen_count) +read_records(const char *filename, unsigned verbose, unsigned long nrecords, unsigned poll_time, + unsigned reopen_count) { - hid_t fid = H5I_INVALID_HID; - hid_t aid = H5I_INVALID_HID; - time_t start_time; /* Starting time */ - hid_t mem_sid = H5I_INVALID_HID; - symbol_t record; /* The record to add to the dataset */ - unsigned seed; /* Seed for random number generator */ - unsigned iter_to_reopen = reopen_count; /* # of iterations until reopen */ - unsigned long u; /* Local index variable */ - hid_t fapl = H5I_INVALID_HID; - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + hid_t fid = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + time_t start_time; /* Starting time */ + hid_t mem_sid = H5I_INVALID_HID; + symbol_t record; /* The record to add to the dataset */ + unsigned seed; /* Seed for random number generator */ + unsigned iter_to_reopen = reopen_count; /* # of iterations until reopen */ + unsigned long u; /* Local index variable */ + hid_t fapl = H5I_INVALID_HID; + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ HDassert(filename); HDassert(poll_time != 0); - + /* Allocate memory for the configuration structure */ - if((config = HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((config = HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) goto error; - /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5 , FALSE, FALSE, 128, "./rw-shadow"); + /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, config)) < 0) { + if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, config)) < 0) { fprintf(stderr, "%s.%d: vfd_swmr_create_fapl failed\n", __func__, __LINE__); goto error; } - if(H5Pset_fclose_degree(fapl, H5F_CLOSE_SEMI) < 0) + if (H5Pset_fclose_degree(fapl, H5F_CLOSE_SEMI) < 0) goto error; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Opening file: %s\n", filename); /* Open the file */ /* Remove H5E_BEGIN_TRY/END_TRY to see the error stack if error */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; - if(fid < 0) { + } + H5E_END_TRY; + if (fid < 0) { HDfprintf(stderr, "READER: Error in opening the file: %s\n", filename); goto error; - } else + } + else HDfprintf(stderr, "READER: SUCCESS in opening the file: %s\n", filename); /* Seed the random number generator with the attribute in the file */ - if((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0) goto error; - if(H5Aread(aid, H5T_NATIVE_UINT, &seed) < 0) + if (H5Aread(aid, H5T_NATIVE_UINT, &seed) < 0) goto error; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto error; HDsrandom(seed); @@ -247,19 +249,19 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, HDmemset(&record, 0, sizeof(record)); /* Create a dataspace for the record to read */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) goto error; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Reading records\n"); /* Read records */ - for(u = 0; u < nrecords; u++) { - unsigned level, offset; - symbol_info_t *symbol = NULL; /* Symbol (dataset) */ - htri_t attr_exists; /* Whether the sequence number attribute exists */ - unsigned long file_u; /* Attribute sequence number (writer's "u") */ + for (u = 0; u < nrecords; u++) { + unsigned level, offset; + symbol_info_t *symbol = NULL; /* Symbol (dataset) */ + htri_t attr_exists; /* Whether the sequence number attribute exists */ + unsigned long file_u; /* Attribute sequence number (writer's "u") */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(&level, &offset); @@ -276,29 +278,27 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, /* Wait until we can read the dataset */ for (;;) { - if((attr_exists = H5Aexists_by_name(fid, symbol->name, "seq", H5P_DEFAULT)) < 0) + if ((attr_exists = H5Aexists_by_name(fid, symbol->name, "seq", H5P_DEFAULT)) < 0) goto error; - if(attr_exists) { - if((aid = H5Aopen_by_name(fid, symbol->name, "seq", - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if (attr_exists) { + if ((aid = H5Aopen_by_name(fid, symbol->name, "seq", H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aread(aid, H5T_NATIVE_ULONG, &file_u) < 0) + if (H5Aread(aid, H5T_NATIVE_ULONG, &file_u) < 0) goto error; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto error; - if(file_u >= u) + if (file_u >= u) break; } - if(HDtime(NULL) >= (time_t)(start_time + (time_t)TIMEOUT)) { - HDfprintf(stderr, - "READER: Reader timed at record %lu level %u offset %u", - u, level, offset); + if (HDtime(NULL) >= (time_t)(start_time + (time_t)TIMEOUT)) { + HDfprintf(stderr, "READER: Reader timed at record %lu level %u offset %u", u, level, offset); if (attr_exists) { HDfprintf(stderr, ", read sequence %lu\n", file_u); - } else { + } + else { HDfprintf(stderr, ", read no sequence\n"); HDfprintf(stderr, ", read no sequence\n"); } @@ -307,93 +307,97 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, HDsleep(poll_time); - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Reopening file (do while loop): %s\n", filename); - if(print_metadata_retries_info(fid) < 0) + if (print_metadata_retries_info(fid) < 0) HDfprintf(stderr, "READER: Warning: could not obtain metadata retries info\n"); - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - } H5E_END_TRY; - if(fid < 0) { + } + H5E_END_TRY; + if (fid < 0) { HDfprintf(stderr, "READER: Error in reopening the file (do while loop): %s\n", filename); goto error; - } + } iter_to_reopen = reopen_count; } /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Checking dataset %lu\n", u); /* Check dataset */ - if(check_dataset(fid, verbose, symbol, &record, mem_sid) < 0) + if (check_dataset(fid, verbose, symbol, &record, mem_sid) < 0) goto error; HDmemset(&record, 0, sizeof(record)); /* Check for reopen */ iter_to_reopen--; - if(iter_to_reopen == 0) { + if (iter_to_reopen == 0) { /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Reopening file (iter_to_reopen): %s\n", filename); /* Retrieve and print the collection of metadata read retries */ - if(print_metadata_retries_info(fid) < 0) + if (print_metadata_retries_info(fid) < 0) HDfprintf(stderr, "READER: Warning: could not obtain metadata retries info\n"); /* Reopen the file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* Remove H5E_BEGIN_TRY/END_TRY to see the error stack if error */ -// H5E_BEGIN_TRY { - fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); - // } H5E_END_TRY; - if(fid < 0) { + // H5E_BEGIN_TRY { + fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); + // } H5E_END_TRY; + if (fid < 0) { HDfprintf(stderr, "READER: Error in reopening the file (iter_to_reopen): %s\n", filename); goto error; - } + } iter_to_reopen = reopen_count; } /* end if */ - } /* end while */ + } /* end while */ /* Retrieve and print the collection of metadata read retries */ - if(print_metadata_retries_info(fid) < 0) + if (print_metadata_retries_info(fid) < 0) HDfprintf(stderr, "READER: Warning: could not obtain metadata retries info\n"); /* Close file */ - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) + if (H5Sclose(mem_sid) < 0) goto error; /* Close the file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(config) + if (config) HDfree(config); return 0; error: - if(config) + if (config) HDfree(config); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Sclose(mem_sid); H5Fclose(fid); H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end read_records() */ @@ -416,26 +420,27 @@ usage(void) HDexit(1); } /* end usage() */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - long nrecords = 0; /* # of records to read */ - int poll_time = 1; /* # of seconds to sleep when waiting for writer */ - int reopen_count = 1; /* # of reads between reopens */ - unsigned verbose = 1; /* Whether to emit some informational messages */ - unsigned u; /* Local index variables */ + long nrecords = 0; /* # of records to read */ + int poll_time = 1; /* # of seconds to sleep when waiting for writer */ + int reopen_count = 1; /* # of reads between reopens */ + unsigned verbose = 1; /* Whether to emit some informational messages */ + unsigned u; /* Local index variables */ /* Parse command line options */ - if(argc < 2) + if (argc < 2) usage(); - if(argc > 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of reads between reopens */ case 'n': reopen_count = HDatoi(argv[u + 1]); - if(reopen_count < 0) + if (reopen_count < 0) usage(); u += 2; break; @@ -449,7 +454,7 @@ int main(int argc, const char *argv[]) /* # of seconds between polling */ case 's': poll_time = HDatoi(argv[u + 1]); - if(poll_time < 0) + if (poll_time < 0) usage(); u += 2; break; @@ -458,20 +463,20 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to read */ nrecords = HDatol(argv[u]); - if(nrecords <= 0) + if (nrecords <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "READER: Parameters:\n"); HDfprintf(stderr, "\t# of seconds between polling = %d\n", poll_time); HDfprintf(stderr, "\t# of reads between reopens = %d\n", reopen_count); @@ -479,43 +484,44 @@ int main(int argc, const char *argv[]) } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) { + if (generate_symbols() < 0) { HDfprintf(stderr, "READER: Error generating symbol names!\n"); HDexit(1); } /* end if */ /* Create datatype for creating datasets */ - if((symbol_tid = create_symbol_datatype()) < 0) { + if ((symbol_tid = create_symbol_datatype()) < 0) { HDfprintf(stderr, "READER: Error creating symbol datatype!\n"); HDexit(1); } /* Reading records from datasets */ - if(read_records(VFD_SWMR_FILENAME, verbose, (unsigned long) nrecords, (unsigned)poll_time, (unsigned)reopen_count) < 0) { + if (read_records(VFD_SWMR_FILENAME, verbose, (unsigned long)nrecords, (unsigned)poll_time, + (unsigned)reopen_count) < 0) { HDfprintf(stderr, "READER: Error reading records from datasets!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "READER: Error releasing symbols!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "READER: Closing objects\n"); /* Close objects created */ - if(H5Tclose(symbol_tid) < 0) { + if (H5Tclose(symbol_tid) < 0) { HDfprintf(stderr, "READER: Error closing symbol datatype!\n"); HDexit(1); } /* end if */ diff --git a/test/vfd_swmr_sparse_writer.c b/test/vfd_swmr_sparse_writer.c index a9c6e23..9135df4 100644 --- a/test/vfd_swmr_sparse_writer.c +++ b/test/vfd_swmr_sparse_writer.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /*------------------------------------------------------------------------- +/*------------------------------------------------------------------------- * * Created: vfd_swmr_sparse_writer.c * (copied and modified from swmr_sparse_writer.c) @@ -50,12 +50,9 @@ /********************/ static hid_t open_skeleton(const char *filename, unsigned verbose); -static int add_records(hid_t fid, unsigned verbose, unsigned long nrecords, - unsigned long flush_count); -static void usage(void); - +static int add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long flush_count); +static void usage(void); - /*------------------------------------------------------------------------- * Function: open_skeleton * @@ -77,78 +74,79 @@ static void usage(void); static hid_t open_skeleton(const char *filename, unsigned verbose) { - hid_t fid = -1; /* File ID for new HDF5 file */ - hid_t fapl = -1; /* File access property list */ - hid_t aid = -1; /* Attribute ID */ - unsigned seed; /* Seed for random number generator */ - unsigned u, v; /* Local index variable */ - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + hid_t fid = -1; /* File ID for new HDF5 file */ + hid_t fapl = -1; /* File access property list */ + hid_t aid = -1; /* Attribute ID */ + unsigned seed; /* Seed for random number generator */ + unsigned u, v; /* Local index variable */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ HDassert(filename); /* Allocate memory for the configuration structure */ - if((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) goto error; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5 , TRUE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, config)) < 0) + if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, config)) < 0) goto error; /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) goto error; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - - if(config) + + if (config) HDfree(config); /* Emit informational message */ - if(verbose) + if (verbose) fprintf(stderr, "WRITER: Opening datasets\n"); /* Seed the random number generator with the attribute in the file */ - if((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0) goto error; - if(H5Aread(aid, H5T_NATIVE_UINT, &seed) < 0) + if (H5Aread(aid, H5T_NATIVE_UINT, &seed) < 0) goto error; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto error; HDsrandom(seed); /* Open the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - if((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) - return(-1); + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + if ((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) + return (-1); symbol_info[u][v].nrecords = 0; } /* end for */ return fid; error: - if(config) + if (config) HDfree(config); - H5E_BEGIN_TRY { - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) + H5E_BEGIN_TRY + { + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) H5Dclose(symbol_info[u][v].dsid); H5Aclose(aid); H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* open_skeleton() */ - /*------------------------------------------------------------------------- * Function: add_records * @@ -175,19 +173,19 @@ error: static int add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long flush_count) { - hid_t tid = -1; /* Datatype ID for records */ - hid_t mem_sid = -1; /* Memory dataspace ID */ - hid_t file_sid = -1; /* Dataset's space ID */ - hid_t aid = -1; /* Attribute ID */ - hsize_t start[2] = {0, 0}; /* Hyperslab selection values */ - hsize_t count[2] = {1, 1}; /* Hyperslab selection values */ - symbol_t record; /* The record to add to the dataset */ - unsigned long rec_to_flush; /* # of records left to write before flush */ + hid_t tid = -1; /* Datatype ID for records */ + hid_t mem_sid = -1; /* Memory dataspace ID */ + hid_t file_sid = -1; /* Dataset's space ID */ + hid_t aid = -1; /* Attribute ID */ + hsize_t start[2] = {0, 0}; /* Hyperslab selection values */ + hsize_t count[2] = {1, 1}; /* Hyperslab selection values */ + symbol_t record; /* The record to add to the dataset */ + unsigned long rec_to_flush; /* # of records left to write before flush */ #ifdef OUT - volatile int dummy; /* Dummy varialbe for busy sleep */ -#endif /* OUT */ - hsize_t dim[2] = {1,0}; /* Dataspace dimensions */ - unsigned long u, v; /* Local index variables */ + volatile int dummy; /* Dummy varialbe for busy sleep */ +#endif /* OUT */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + unsigned long u, v; /* Local index variables */ HDassert(fid >= 0); @@ -196,38 +194,40 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f HDmemset(&record, 0, sizeof(record)); /* Create a dataspace for the record to add */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) goto error; /* Create datatype for appending records */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) goto error; /* Add records to random datasets, according to frequency distribution */ rec_to_flush = flush_count; - for(u = 0; u < nrecords; u++) { - symbol_info_t *symbol; /* Symbol to write record to */ + for (u = 0; u < nrecords; u++) { + symbol_info_t *symbol; /* Symbol to write record to */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(NULL, NULL); /* If this is the first time the dataset has been opened, extend it and * add the sequence attribute */ - if(symbol->nrecords == 0) { + if (symbol->nrecords == 0) { symbol->nrecords = nrecords / 5; - dim[1] = symbol->nrecords; + dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) goto error; - if((file_sid = H5Screate(H5S_SCALAR)) < 0) - goto error; - if((aid = H5Acreate2(symbol->dsid, "seq", H5T_NATIVE_ULONG, file_sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file_sid = H5Screate(H5S_SCALAR)) < 0) goto error; - if(H5Sclose(file_sid) < 0) + if ((aid = H5Acreate2(symbol->dsid, "seq", H5T_NATIVE_ULONG, file_sid, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - } else if ((aid = H5Aopen(symbol->dsid, "seq", H5P_DEFAULT)) < 0) + if (H5Sclose(file_sid) < 0) goto error; + } + else if ((aid = H5Aopen(symbol->dsid, "seq", H5P_DEFAULT)) < 0) + goto error; /* Get the coordinate to write */ start[1] = (hsize_t)HDrandom() % symbol->nrecords; @@ -236,15 +236,15 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f record.rec_id = start[1]; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(symbol->dsid)) < 0) + if ((file_sid = H5Dget_space(symbol->dsid)) < 0) goto error; /* Choose a random record in the dataset */ - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; /* Write record to the dataset */ - if(H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) + if (H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) goto error; /* Write the sequence number attribute. Since we synchronize the random @@ -253,28 +253,28 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f * flush dependencies on the object header, the reader will be * guaranteed to see the written data if the sequence attribute is >=u. */ - if(H5Awrite(aid, H5T_NATIVE_ULONG, &u) < 0) + if (H5Awrite(aid, H5T_NATIVE_ULONG, &u) < 0) goto error; /* Close the attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto error; /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) goto error; /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ rec_to_flush--; /* Check for counter being reached */ - if(0 == rec_to_flush) { + if (0 == rec_to_flush) { /* Reset flush counter */ rec_to_flush = flush_count; } /* end if */ - } /* end if */ + } /* end if */ #ifdef OUT /* Busy wait, to let readers catch up */ @@ -282,46 +282,47 @@ add_records(hid_t fid, unsigned verbose, unsigned long nrecords, unsigned long f * at the top of the file. */ dummy = 0; - for(v=0; v 1) { + if (argc > 1) { u = 1; - while(u < (unsigned)argc) { - if(argv[u][0] == '-') { - switch(argv[u][1]) { + while (u < (unsigned)argc) { + if (argv[u][0] == '-') { + switch (argv[u][1]) { /* # of records to write between flushing file */ case 'f': flush_count = HDatol(argv[u + 1]); - if(flush_count < 0) + if (flush_count < 0) usage(); u += 2; break; @@ -381,45 +383,44 @@ int main(int argc, const char *argv[]) usage(); break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* Get the number of records to append */ nrecords = HDatol(argv[u]); - if(nrecords <= 0) + if (nrecords <= 0) usage(); u++; } /* end else */ - } /* end while */ - } /* end if */ - if(nrecords <= 0) + } /* end while */ + } /* end if */ + if (nrecords <= 0) usage(); - if(flush_count >= nrecords) + if (flush_count >= nrecords) usage(); /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(stderr, "WRITER: Parameters:\n"); HDfprintf(stderr, "\t# of records between flushes = %ld\n", flush_count); HDfprintf(stderr, "\t# of records to write = %ld\n", nrecords); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Emit informational message */ - if(verbose) { - HDfprintf(stderr, "WRITER: Opening skeleton file: %s\n", - VFD_SWMR_FILENAME); + if (verbose) { + HDfprintf(stderr, "WRITER: Opening skeleton file: %s\n", VFD_SWMR_FILENAME); } /* Open file skeleton */ - if((fid = open_skeleton(VFD_SWMR_FILENAME, verbose)) < 0) { + if ((fid = open_skeleton(VFD_SWMR_FILENAME, verbose)) < 0) { HDfprintf(stderr, "WRITER: Error opening skeleton file!\n"); HDexit(1); } /* end if */ @@ -428,21 +429,21 @@ int main(int argc, const char *argv[]) h5_send_message(VFD_SWMR_WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Adding records\n"); /* Append records to datasets */ - if(add_records(fid, verbose, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { + if (add_records(fid, verbose, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "WRITER: Error appending records to datasets!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "WRITER: Error releasing symbols!\n"); HDexit(1); } /* end if */ @@ -452,11 +453,11 @@ int main(int argc, const char *argv[]) restore_signals(&oldset); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(stderr, "WRITER: Closing objects/file\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "WRITER: Error closing file!\n"); HDexit(1); } /* end if */ diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c index 5905a3d..f9b3eef 100644 --- a/test/vfd_swmr_vlstr_reader.c +++ b/test/vfd_swmr_vlstr_reader.c @@ -11,8 +11,8 @@ * help@hdfgroup.org. */ -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "hdf5.h" @@ -29,25 +29,19 @@ #include -typedef enum _step { - CREATE = 0 -, LENGTHEN -, SHORTEN -, DELETE -, NSTEPS -} step_t; +typedef enum _step { CREATE = 0, LENGTHEN, SHORTEN, DELETE, NSTEPS } step_t; -static const hid_t badhid = H5I_INVALID_HID; // abbreviate -static bool caught_out_of_bounds = false; -static bool read_null = false; +static const hid_t badhid = H5I_INVALID_HID; // abbreviate +static bool caught_out_of_bounds = false; +static bool read_null = false; static bool read_vl_dset(hid_t dset, hid_t type, char **data) { - bool success; + bool success; estack_state_t es; - es = disable_estack(); + es = disable_estack(); success = H5Dread(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) >= 0; if (*data == NULL) { read_null = true; @@ -63,9 +57,9 @@ usage(const char *progname) { fprintf(stderr, "usage: %s [-W] [-V] [-t (oob|null)] \n", progname); fprintf(stderr, "\n -S: do not use VFD SWMR\n"); - fprintf(stderr, " -n: number of test steps to perform\n"); - fprintf(stderr, " -q: be quiet: few/no progress messages\n"); - fprintf(stderr, " -t (oob|null): select out-of-bounds or NULL test\n"); + fprintf(stderr, " -n: number of test steps to perform\n"); + fprintf(stderr, " -q: be quiet: few/no progress messages\n"); + fprintf(stderr, " -t (oob|null): select out-of-bounds or NULL test\n"); exit(EXIT_FAILURE); } @@ -82,52 +76,51 @@ H5HG_trap(const char *reason) int main(int argc, char **argv) { - hid_t fapl, fid, space, type; - hid_t dset[2]; - char *content[2]; - char name[2][96]; - int ch, i, ntimes = 100; - unsigned long tmp; - bool use_vfd_swmr = true; - char *end; - const long millisec_in_nanosecs = 1000 * 1000; - const struct timespec delay = - {.tv_sec = 0, .tv_nsec = millisec_in_nanosecs * 11 / 10}; - testsel_t sel = TEST_NONE; + hid_t fapl, fid, space, type; + hid_t dset[2]; + char * content[2]; + char name[2][96]; + int ch, i, ntimes = 100; + unsigned long tmp; + bool use_vfd_swmr = true; + char * end; + const long millisec_in_nanosecs = 1000 * 1000; + const struct timespec delay = {.tv_sec = 0, .tv_nsec = millisec_in_nanosecs * 11 / 10}; + testsel_t sel = TEST_NONE; H5F_vfd_swmr_config_t config; assert(H5T_C_S1 != badhid); while ((ch = getopt(argc, argv, "Sn:qt:")) != -1) { - switch(ch) { - case 'S': - use_vfd_swmr = false; - break; - case 'n': - errno = 0; - tmp = strtoul(optarg, &end, 0); - if (end == optarg || *end != '\0') - errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); - else if (errno != 0) - err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); - else if (tmp > INT_MAX) - errx(EXIT_FAILURE, "`-n` argument `%lu` too large", tmp); - ntimes = (int)tmp; - break; - case 'q': - verbosity = 1; - break; - case 't': - if (strcmp(optarg, "oob") == 0) - sel = TEST_OOB; - else if (strcmp(optarg, "null") == 0) - sel = TEST_NULL; - else + switch (ch) { + case 'S': + use_vfd_swmr = false; + break; + case 'n': + errno = 0; + tmp = strtoul(optarg, &end, 0); + if (end == optarg || *end != '\0') + errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); + else if (errno != 0) + err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); + else if (tmp > INT_MAX) + errx(EXIT_FAILURE, "`-n` argument `%lu` too large", tmp); + ntimes = (int)tmp; + break; + case 'q': + verbosity = 1; + break; + case 't': + if (strcmp(optarg, "oob") == 0) + sel = TEST_OOB; + else if (strcmp(optarg, "null") == 0) + sel = TEST_NULL; + else + usage(argv[0]); + break; + default: usage(argv[0]); - break; - default: - usage(argv[0]); - break; + break; } } argv += optind; @@ -165,23 +158,20 @@ main(int argc, char **argv) * content 1 seq 1 long long long long long long long long * content 1 seq 1 medium medium medium */ - for (i = 0; - !caught_out_of_bounds && i < ntimes; - (i % 2 == 0) ? nanosleep(&delay, NULL) : 0, i++) { + for (i = 0; !caught_out_of_bounds && i < ntimes; (i % 2 == 0) ? nanosleep(&delay, NULL) : 0, i++) { estack_state_t es; - const int ndsets = 2; - const int which = i % ndsets; - int nconverted; + const int ndsets = 2; + const int which = i % ndsets; + int nconverted; struct { - int which; - int seq; + int which; + int seq; char tail[96]; } scanned_content; dbgf(2, "iteration %d which %d", i, which); - (void)snprintf(name[which], sizeof(name[which]), - "dset-%d", which); - es = disable_estack(); + (void)snprintf(name[which], sizeof(name[which]), "dset-%d", which); + es = disable_estack(); dset[which] = H5Dopen(fid, name[which], H5P_DEFAULT); restore_estack(es); if (caught_out_of_bounds || dset[which] == badhid) { @@ -193,14 +183,14 @@ main(int argc, char **argv) dbgf(2, ": couldn't read\n"); continue; } - nconverted = sscanf(content[which], "content %d seq %d %96s", - &scanned_content.which, &scanned_content.seq, scanned_content.tail); + nconverted = sscanf(content[which], "content %d seq %d %96s", &scanned_content.which, + &scanned_content.seq, scanned_content.tail); if (nconverted != 3) { dbgf(2, ": couldn't scan\n"); continue; } - dbgf(2, ": read which %d seq %d tail %s\n", - scanned_content.which, scanned_content.seq, scanned_content.tail); + dbgf(2, ": read which %d seq %d tail %s\n", scanned_content.which, scanned_content.seq, + scanned_content.tail); H5Dclose(dset[which]); } diff --git a/test/vfd_swmr_vlstr_writer.c b/test/vfd_swmr_vlstr_writer.c index 57d08ec..07d13d0 100644 --- a/test/vfd_swmr_vlstr_writer.c +++ b/test/vfd_swmr_vlstr_writer.c @@ -11,8 +11,8 @@ * help@hdfgroup.org. */ -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "hdf5.h" @@ -29,16 +29,10 @@ #include -enum _step { - CREATE = 0 -, LENGTHEN -, SHORTEN -, DELETE -, NSTEPS -} step_t; +enum _step { CREATE = 0, LENGTHEN, SHORTEN, DELETE, NSTEPS } step_t; -static const hid_t badhid = H5I_INVALID_HID; // abbreviate -static bool caught_out_of_bounds = false; +static const hid_t badhid = H5I_INVALID_HID; // abbreviate +static bool caught_out_of_bounds = false; static void write_vl_dset(hid_t dset, hid_t type, hid_t space, char *data) @@ -86,8 +80,7 @@ create_vl_dset(hid_t file, hid_t type, hid_t space, const char *name) { hid_t dset; - dset = H5Dcreate2(file, name, type, space, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + dset = H5Dcreate2(file, name, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (dset == badhid) errx(EXIT_FAILURE, "H5Dcreate2"); @@ -102,13 +95,15 @@ print_cache_hits(H5C_t *cache) int i; for (i = 0; i < H5AC_NTYPES; i++) { - dbgf(3, "type-%d cache hits %" PRId64 "%s\n", - i, cache->hits[i], (i == H5AC_GHEAP_ID) ? " *" : ""); + dbgf(3, "type-%d cache hits %" PRId64 "%s\n", i, cache->hits[i], (i == H5AC_GHEAP_ID) ? " *" : ""); } dbgf(3, "\n"); } #else -print_cache_hits(H5C_t H5_ATTR_UNUSED *cache) { return; } +print_cache_hits(H5C_t H5_ATTR_UNUSED *cache) +{ + return; +} #endif static void @@ -117,11 +112,11 @@ usage(const char *progname) fprintf(stderr, "usage: %s [-W] [-V]\n", progname); fprintf(stderr, "\n -W: do not wait for SIGINT or SIGUSR1\n"); fprintf(stderr, "\n -S: do not use VFD SWMR\n"); - fprintf(stderr, " -f: use fixed-length string\n"); - fprintf(stderr, " (default: variable-length string)\n"); - fprintf(stderr, " -n: number of test steps to perform\n"); - fprintf(stderr, " -q: be quiet: few/no progress messages\n"); - fprintf(stderr, " -t (oob|null): select out-of-bounds or NULL test\n"); + fprintf(stderr, " -f: use fixed-length string\n"); + fprintf(stderr, " (default: variable-length string)\n"); + fprintf(stderr, " -n: number of test steps to perform\n"); + fprintf(stderr, " -q: be quiet: few/no progress messages\n"); + fprintf(stderr, " -t (oob|null): select out-of-bounds or NULL test\n"); exit(EXIT_FAILURE); } @@ -138,63 +133,62 @@ H5HG_trap(const char *reason) int main(int argc, char **argv) { - hid_t fapl, fcpl, fid, space, type; - hid_t dset[2]; - char content[2][96]; - char name[2][96]; - H5F_t *f; - H5C_t *cache; - sigset_t oldsigs; - herr_t ret; - bool variable = true, wait_for_signal = true; - const hsize_t dims = 1; - int ch, i, ntimes = 100; - unsigned long tmp; - char *end; - bool use_vfd_swmr = true; - const struct timespec delay = - {.tv_sec = 0, .tv_nsec = 1000 * 1000 * 1000 / 10}; - testsel_t sel = TEST_NONE; + hid_t fapl, fcpl, fid, space, type; + hid_t dset[2]; + char content[2][96]; + char name[2][96]; + H5F_t * f; + H5C_t * cache; + sigset_t oldsigs; + herr_t ret; + bool variable = true, wait_for_signal = true; + const hsize_t dims = 1; + int ch, i, ntimes = 100; + unsigned long tmp; + char * end; + bool use_vfd_swmr = true; + const struct timespec delay = {.tv_sec = 0, .tv_nsec = 1000 * 1000 * 1000 / 10}; + testsel_t sel = TEST_NONE; H5F_vfd_swmr_config_t config; assert(H5T_C_S1 != badhid); while ((ch = getopt(argc, argv, "SWfn:qt:")) != -1) { - switch(ch) { - case 'S': - use_vfd_swmr = false; - break; - case 'W': - wait_for_signal = false; - break; - case 'f': - variable = false; - break; - case 'n': - errno = 0; - tmp = strtoul(optarg, &end, 0); - if (end == optarg || *end != '\0') - errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); - else if (errno != 0) - err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); - else if (tmp > INT_MAX) - errx(EXIT_FAILURE, "`-n` argument `%lu` too large", tmp); - ntimes = (int)tmp; - break; - case 'q': - verbosity = 1; - break; - case 't': - if (strcmp(optarg, "oob") == 0) - sel = TEST_OOB; - else if (strcmp(optarg, "null") == 0) - sel = TEST_NULL; - else + switch (ch) { + case 'S': + use_vfd_swmr = false; + break; + case 'W': + wait_for_signal = false; + break; + case 'f': + variable = false; + break; + case 'n': + errno = 0; + tmp = strtoul(optarg, &end, 0); + if (end == optarg || *end != '\0') + errx(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); + else if (errno != 0) + err(EXIT_FAILURE, "couldn't parse `-n` argument `%s`", optarg); + else if (tmp > INT_MAX) + errx(EXIT_FAILURE, "`-n` argument `%lu` too large", tmp); + ntimes = (int)tmp; + break; + case 'q': + verbosity = 1; + break; + case 't': + if (strcmp(optarg, "oob") == 0) + sel = TEST_OOB; + else if (strcmp(optarg, "null") == 0) + sel = TEST_NULL; + else + usage(argv[0]); + break; + default: usage(argv[0]); - break; - default: - usage(argv[0]); - break; + break; } } argv += optind; @@ -231,7 +225,8 @@ main(int argc, char **argv) if (H5Tset_size(type, 32) < 0) errx(EXIT_FAILURE, "H5Tset_size"); space = H5Screate_simple(1, &dims, NULL); - } else { + } + else { if (H5Tset_size(type, H5T_VARIABLE) < 0) errx(EXIT_FAILURE, "H5Tset_size"); space = H5Screate(H5S_SCALAR); @@ -258,43 +253,36 @@ main(int argc, char **argv) */ for (i = 0; i < ntimes; i++) { const int ndsets = 2; - const int step = i % NSTEPS; - const int which = (i / NSTEPS) % ndsets; - const int seq = i / (ndsets * NSTEPS); - dbgf(2, "iteration %d which %d step %d seq %d\n", - i, which, step, seq); + const int step = i % NSTEPS; + const int which = (i / NSTEPS) % ndsets; + const int seq = i / (ndsets * NSTEPS); + dbgf(2, "iteration %d which %d step %d seq %d\n", i, which, step, seq); switch (step) { - case CREATE: - (void)snprintf(name[which], sizeof(name[which]), - "dset-%d", which); - (void)snprintf(content[which], sizeof(content[which]), - "content %d seq %d short", which, seq); - dset[which] = - create_vl_dset(fid, type, space, name[which]); - write_vl_dset(dset[which], type, space, content[which]); - break; - case LENGTHEN: - (void)snprintf(content[which], sizeof(content[which]), - "content %d seq %d long long long long long long long long", - which, seq); - write_vl_dset(dset[which], type, space, content[which]); - break; - case SHORTEN: - (void)snprintf(content[which], sizeof(content[which]), - "content %d seq %d medium medium medium", - which, seq); - write_vl_dset(dset[which], type, space, content[which]); - break; - case DELETE: - if (H5Dclose(dset[which]) < 0) - errx(EXIT_FAILURE, "H5Dclose"); - if (H5Ldelete(fid, name[which], H5P_DEFAULT) < 0) { - errx(EXIT_FAILURE, "%s: H5Ldelete(, \"%s\", ) failed", - __func__, name[which]); - } - break; - default: - errx(EXIT_FAILURE, "%s: unknown step %d", __func__, step); + case CREATE: + (void)snprintf(name[which], sizeof(name[which]), "dset-%d", which); + (void)snprintf(content[which], sizeof(content[which]), "content %d seq %d short", which, seq); + dset[which] = create_vl_dset(fid, type, space, name[which]); + write_vl_dset(dset[which], type, space, content[which]); + break; + case LENGTHEN: + (void)snprintf(content[which], sizeof(content[which]), + "content %d seq %d long long long long long long long long", which, seq); + write_vl_dset(dset[which], type, space, content[which]); + break; + case SHORTEN: + (void)snprintf(content[which], sizeof(content[which]), + "content %d seq %d medium medium medium", which, seq); + write_vl_dset(dset[which], type, space, content[which]); + break; + case DELETE: + if (H5Dclose(dset[which]) < 0) + errx(EXIT_FAILURE, "H5Dclose"); + if (H5Ldelete(fid, name[which], H5P_DEFAULT) < 0) { + errx(EXIT_FAILURE, "%s: H5Ldelete(, \"%s\", ) failed", __func__, name[which]); + } + break; + default: + errx(EXIT_FAILURE, "%s: unknown step %d", __func__, step); } if (caught_out_of_bounds) { fprintf(stderr, "caught out of bounds\n"); diff --git a/test/vfd_swmr_writer.c b/test/vfd_swmr_writer.c index 3ef1009..6bfc72c 100644 --- a/test/vfd_swmr_writer.c +++ b/test/vfd_swmr_writer.c @@ -40,13 +40,12 @@ /* Local Prototypes */ /********************/ -static hid_t open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed, hbool_t old); -static int add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, - unsigned long nrecords, unsigned long flush_count); -static void usage(void); +static hid_t open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed, + hbool_t old); +static int add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, unsigned long nrecords, + unsigned long flush_count); +static void usage(void); - /*------------------------------------------------------------------------- * Function: open_skeleton * @@ -75,29 +74,29 @@ static void usage(void); *------------------------------------------------------------------------- */ static hid_t -open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, - unsigned random_seed, hbool_t old H5_ATTR_UNUSED) +open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned random_seed, + hbool_t old H5_ATTR_UNUSED) { - hid_t fid; /* File ID for new HDF5 file */ - hid_t fapl; /* File access property list */ - unsigned u, v; /* Local index variable */ - hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t fapl; /* File access property list */ + unsigned u, v; /* Local index variable */ + hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ HDassert(filename); /* Allocate memory for the configuration structure */ - if((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) + if ((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) return -1; /* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */ - init_vfd_swmr_config(config, 4, 5 , TRUE, FALSE, 128, "./rw-shadow"); + init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow"); /* use_latest_format, use_vfd_swmr, only_meta_page, config */ - if((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, config)) < 0) + if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, config)) < 0) return -1; - if(use_log_vfd) { + if (use_log_vfd) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "vfd_swmr_writer.log.%u", random_seed); @@ -106,24 +105,24 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, } /* end if */ /* Open the file with VFD SWMR configured */ - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) return -1; /* Close file access property list */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; - if(config) + if (config) HDfree(config); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "WRITER: Opening datasets\n"); /* Open the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) { - if((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) { + if ((symbol_info[u][v].dsid = H5Dopen2(fid, symbol_info[u][v].name, H5P_DEFAULT)) < 0) return -1; symbol_info[u][v].nrecords = 0; } /* end for */ @@ -131,7 +130,6 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, return fid; } /* open_skeleton() */ - /*------------------------------------------------------------------------- * Function: add_records * @@ -159,16 +157,15 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, *------------------------------------------------------------------------- */ static int -add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, - unsigned long nrecords, unsigned long flush_count) +add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, unsigned long nrecords, unsigned long flush_count) { - hid_t tid; /* Datatype ID for records */ - hid_t mem_sid; /* Memory dataspace ID */ - hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ - hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ - symbol_t record; /* The record to add to the dataset */ - unsigned long rec_to_flush; /* # of records left to write before flush */ - unsigned long u, v; /* Local index variables */ + hid_t tid; /* Datatype ID for records */ + hid_t mem_sid; /* Memory dataspace ID */ + hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ + hsize_t dim[2] = {1, 0}; /* Dataspace dimensions */ + symbol_t record; /* The record to add to the dataset */ + unsigned long rec_to_flush; /* # of records left to write before flush */ + unsigned long u, v; /* Local index variables */ HDassert(fid >= 0); @@ -177,18 +174,18 @@ add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, HDmemset(&record, 0, sizeof(record)); /* Create a dataspace for the record to add */ - if((mem_sid = H5Screate(H5S_SCALAR)) < 0) + if ((mem_sid = H5Screate(H5S_SCALAR)) < 0) return -1; /* Create datatype for appending records */ - if((tid = create_symbol_datatype()) < 0) + if ((tid = create_symbol_datatype()) < 0) return -1; /* Add records to random datasets, according to frequency distribution */ rec_to_flush = flush_count; - for(u = 0; u < nrecords; u++) { - symbol_info_t *symbol; /* Symbol to write record to */ - hid_t file_sid; /* Dataset's space ID */ + for (u = 0; u < nrecords; u++) { + symbol_info_t *symbol; /* Symbol to write record to */ + hid_t file_sid; /* Dataset's space ID */ /* Get a random dataset, according to the symbol distribution */ symbol = choose_dataset(NULL, NULL); @@ -202,54 +199,54 @@ add_records(hid_t fid, hbool_t verbose, FILE *verbose_file, /* Extend the dataset's dataspace to hold the new record */ symbol->nrecords++; dim[1] = symbol->nrecords; - if(H5Dset_extent(symbol->dsid, dim) < 0) + if (H5Dset_extent(symbol->dsid, dim) < 0) return -1; /* Get the dataset's dataspace */ - if((file_sid = H5Dget_space(symbol->dsid)) < 0) + if ((file_sid = H5Dget_space(symbol->dsid)) < 0) return -1; /* Choose the last record in the dataset */ - if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) return -1; /* Write record to the dataset */ - if(H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) + if (H5Dwrite(symbol->dsid, tid, mem_sid, file_sid, H5P_DEFAULT, &record) < 0) return -1; /* Close the dataset's dataspace */ - if(H5Sclose(file_sid) < 0) + if (H5Sclose(file_sid) < 0) return -1; /* Check for flushing file */ - if(flush_count > 0) { + if (flush_count > 0) { /* Decrement count of records to write before flushing */ rec_to_flush--; /* Check for counter being reached */ - if(0 == rec_to_flush) { + if (0 == rec_to_flush) { /* Reset flush counter */ rec_to_flush = flush_count; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Close the memory dataspace */ - if(H5Sclose(mem_sid) < 0) + if (H5Sclose(mem_sid) < 0) return -1; /* Close the datatype */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) return -1; /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "WRITER: Closing datasets\n"); /* Close the datasets */ - for(u = 0; u < NLEVELS; u++) - for(v = 0; v < symbol_count[u]; v++) - if(H5Dclose(symbol_info[u][v].dsid) < 0) + for (u = 0; u < NLEVELS; u++) + for (v = 0; v < symbol_count[u]; v++) + if (H5Dclose(symbol_info[u][v].dsid) < 0) return -1; return 0; @@ -276,69 +273,69 @@ usage(void) } int -main(int argc, char * const *argv) +main(int argc, char *const *argv) { sigset_t oldset; - hid_t fid; /* File ID for file opened */ - long nrecords = 0; /* # of records to append */ - long flush_count = 10000; /* # of records to write between flushing file */ - hbool_t verbose = TRUE; /* Whether to emit some informational messages */ - FILE *verbose_file = NULL; /* File handle for verbose output */ - hbool_t old = FALSE; /* Whether to use non-latest-format when opening file */ - hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ - hbool_t wait_for_signal = TRUE; - unsigned random_seed = 0; /* Random # seed */ - int ch, temp; + hid_t fid; /* File ID for file opened */ + long nrecords = 0; /* # of records to append */ + long flush_count = 10000; /* # of records to write between flushing file */ + hbool_t verbose = TRUE; /* Whether to emit some informational messages */ + FILE * verbose_file = NULL; /* File handle for verbose output */ + hbool_t old = FALSE; /* Whether to use non-latest-format when opening file */ + hbool_t use_seed = FALSE; /* Set to TRUE if a seed was set on the command line */ + hbool_t wait_for_signal = TRUE; + unsigned random_seed = 0; /* Random # seed */ + int ch, temp; block_signals(&oldset); while ((ch = getopt(argc, argv, "Wf:qr:o")) != -1) { - switch(ch) { - /* # of records to write between flushing file */ - case 'f': - flush_count = HDatol(optarg); - if(flush_count < 0) + switch (ch) { + /* # of records to write between flushing file */ + case 'f': + flush_count = HDatol(optarg); + if (flush_count < 0) + usage(); + break; + + /* Be quiet */ + case 'q': + verbose = FALSE; + break; + + /* Random # seed */ + case 'r': + use_seed = TRUE; + temp = HDatoi(optarg); + random_seed = (unsigned)temp; + break; + + case 'W': + wait_for_signal = FALSE; + break; + + /* Use non-latest-format when opening file */ + case 'o': + old = TRUE; + break; + + default: usage(); - break; - - /* Be quiet */ - case 'q': - verbose = FALSE; - break; - - /* Random # seed */ - case 'r': - use_seed = TRUE; - temp = HDatoi(optarg); - random_seed = (unsigned)temp; - break; - - case 'W': - wait_for_signal = FALSE; - break; - - /* Use non-latest-format when opening file */ - case 'o': - old = TRUE; - break; - - default: - usage(); - break; + break; } } argv += optind; argc -= optind; /* Parse command line options */ - if(argc < 1) + if (argc < 1) usage(); /* Get the number of records to append */ nrecords = HDatol(argv[0]); - if(nrecords <= 0 || flush_count >= nrecords) + if (nrecords <= 0 || flush_count >= nrecords) usage(); /* Set the random seed */ - if(!use_seed) { + if (!use_seed) { struct timeval t; HDgettimeofday(&t, NULL); @@ -347,18 +344,18 @@ main(int argc, char * const *argv) HDsrandom(random_seed); /* Open output file */ - if(verbose) { + if (verbose) { char verbose_name[1024]; HDsnprintf(verbose_name, sizeof(verbose_name), "vfd_swmr_writer.out.%u", random_seed); - if(NULL == (verbose_file = HDfopen(verbose_name, "w"))) { + if (NULL == (verbose_file = HDfopen(verbose_name, "w"))) { HDfprintf(stderr, "WRITER: Can't open verbose output file!\n"); HDexit(1); } } /* end if */ /* Emit informational message */ - if(verbose) { + if (verbose) { HDfprintf(verbose_file, "WRITER: Parameters:\n"); HDfprintf(verbose_file, "\t# of records between flushes = %ld\n", flush_count); HDfprintf(verbose_file, "\t# of records to write = %ld\n", nrecords); @@ -368,21 +365,20 @@ main(int argc, char * const *argv) HDfprintf(stdout, "Using writer random seed: %u\n", random_seed); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "WRITER: Generating symbol names\n"); /* Generate dataset names */ - if(generate_symbols() < 0) + if (generate_symbols() < 0) return -1; /* Emit informational message */ - if(verbose) { - HDfprintf(verbose_file, "WRITER: Opening skeleton file: %s\n", - VFD_SWMR_FILENAME); + if (verbose) { + HDfprintf(verbose_file, "WRITER: Opening skeleton file: %s\n", VFD_SWMR_FILENAME); } /* Open file skeleton */ - if((fid = open_skeleton(VFD_SWMR_FILENAME, verbose, verbose_file, random_seed, old)) < 0) { + if ((fid = open_skeleton(VFD_SWMR_FILENAME, verbose, verbose_file, random_seed, old)) < 0) { HDfprintf(stderr, "WRITER: Error opening skeleton file!\n"); HDexit(1); } /* end if */ @@ -391,21 +387,21 @@ main(int argc, char * const *argv) h5_send_message(VFD_SWMR_WRITER_MESSAGE, NULL, NULL); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "WRITER: Adding records\n"); /* Append records to datasets */ - if(add_records(fid, verbose, verbose_file, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { + if (add_records(fid, verbose, verbose_file, (unsigned long)nrecords, (unsigned long)flush_count) < 0) { HDfprintf(stderr, "WRITER: Error appending records to datasets!\n"); HDexit(1); } /* end if */ /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "WRITER: Releasing symbols\n"); /* Clean up the symbols */ - if(shutdown_symbols() < 0) { + if (shutdown_symbols() < 0) { HDfprintf(stderr, "WRITER: Error releasing symbols!\n"); HDexit(1); } /* end if */ @@ -416,11 +412,11 @@ main(int argc, char * const *argv) restore_signals(&oldset); /* Emit informational message */ - if(verbose) + if (verbose) HDfprintf(verbose_file, "WRITER: Closing objects/file\n"); /* Close objects opened */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "WRITER: Error closing file!\n"); HDexit(1); } /* end if */ diff --git a/test/vfd_swmr_zoo_writer.c b/test/vfd_swmr_zoo_writer.c index 07d3ae4..5fe6134 100644 --- a/test/vfd_swmr_zoo_writer.c +++ b/test/vfd_swmr_zoo_writer.c @@ -14,8 +14,8 @@ #include #include -#define H5C_FRIEND /* suppress error about including H5Cpkg */ -#define H5F_FRIEND /* suppress error about including H5Fpkg */ +#define H5C_FRIEND /* suppress error about including H5Cpkg */ +#define H5F_FRIEND /* suppress error about including H5Fpkg */ #include "hdf5.h" @@ -31,7 +31,7 @@ #include "vfd_swmr_common.h" #ifndef _arraycount -#define _arraycount(_a) (sizeof(_a)/sizeof(_a[0])) +#define _arraycount(_a) (sizeof(_a) / sizeof(_a[0])) #endif typedef struct _shared_ticks { @@ -42,19 +42,19 @@ typedef struct _tick_stats { uint64_t writer_tried_increase; uint64_t writer_aborted_increase; uint64_t writer_read_shared_file; - uint64_t reader_tick_was_zero; // writer read reader tick equal to 0 - uint64_t reader_tick_lead_writer; // writer read reader tick greater than - // proposed writer tick - uint64_t writer_lead_reader_by[1]; // proposed writer tick lead reader - // tick by `lead` ticks - // `writer_lead_reader_by[lead]` - // times, for `0 <= lead <= max_lag - 1` + uint64_t reader_tick_was_zero; // writer read reader tick equal to 0 + uint64_t reader_tick_lead_writer; // writer read reader tick greater than + // proposed writer tick + uint64_t writer_lead_reader_by[1]; // proposed writer tick lead reader + // tick by `lead` ticks + // `writer_lead_reader_by[lead]` + // times, for `0 <= lead <= max_lag - 1` } tick_stats_t; static H5F_vfd_swmr_config_t swmr_config; -static tick_stats_t *tick_stats = NULL; -static const hid_t badhid = H5I_INVALID_HID; -static bool writer; +static tick_stats_t * tick_stats = NULL; +static const hid_t badhid = H5I_INVALID_HID; +static bool writer; static void #ifndef H5C_COLLECT_CACHE_STATS @@ -63,13 +63,15 @@ print_cache_hits(H5C_t *cache) int i; for (i = 0; i < H5AC_NTYPES; i++) { - dbgf(3, "type-%d cache hits %" PRId64 "%s\n", - i, cache->hits[i], (i == H5AC_GHEAP_ID) ? " *" : ""); + dbgf(3, "type-%d cache hits %" PRId64 "%s\n", i, cache->hits[i], (i == H5AC_GHEAP_ID) ? " *" : ""); } dbgf(3, "\n"); } #else -print_cache_hits(H5C_t H5_ATTR_UNUSED *cache) { return; } +print_cache_hits(H5C_t H5_ATTR_UNUSED *cache) +{ + return; +} #endif void @@ -83,28 +85,27 @@ zoo_create_hook(hid_t fid) static void usage(const char *progname) { - fprintf(stderr, "usage: %s [-C] [-S] [-W] [-a] [-e] [-m] [-q] [-v]\n", - progname); + fprintf(stderr, "usage: %s [-C] [-S] [-W] [-a] [-e] [-m] [-q] [-v]\n", progname); fprintf(stderr, "\n -C: skip compact dataset tests\n"); - fprintf(stderr, " -S: do not use VFD SWMR\n"); - fprintf(stderr, " -W: do not wait for SIGINT or SIGUSR1\n"); - fprintf(stderr, " -a: run all tests, including variable-length data\n"); - fprintf(stderr, " -e: print error stacks\n"); - fprintf(stderr, " -m ms: maximum `ms` milliseconds pause between\n"); - fprintf(stderr, " each create/delete step\n"); - fprintf(stderr, " -q: be quiet: few/no progress messages\n"); - fprintf(stderr, " -v: be verbose: most progress messages\n"); + fprintf(stderr, " -S: do not use VFD SWMR\n"); + fprintf(stderr, " -W: do not wait for SIGINT or SIGUSR1\n"); + fprintf(stderr, " -a: run all tests, including variable-length data\n"); + fprintf(stderr, " -e: print error stacks\n"); + fprintf(stderr, " -m ms: maximum `ms` milliseconds pause between\n"); + fprintf(stderr, " each create/delete step\n"); + fprintf(stderr, " -q: be quiet: few/no progress messages\n"); + fprintf(stderr, " -v: be verbose: most progress messages\n"); exit(EXIT_FAILURE); } bool vfd_swmr_writer_may_increase_tick_to(uint64_t new_tick, bool wait_for_reader) { - static int fd = -1; + static int fd = -1; shared_ticks_t shared; - ssize_t nread; - h5_retry_t retry; - bool do_try; + ssize_t nread; + h5_retry_t retry; + bool do_try; dbgf(3, "%s: enter\n", __func__); @@ -116,17 +117,14 @@ vfd_swmr_writer_may_increase_tick_to(uint64_t new_tick, bool wait_for_reader) } assert(tick_stats == NULL); tick_stats = calloc(1, sizeof(*tick_stats) + - (swmr_config.max_lag - 1) * - sizeof(tick_stats->writer_lead_reader_by[0])); + (swmr_config.max_lag - 1) * sizeof(tick_stats->writer_lead_reader_by[0])); if (tick_stats == NULL) err(EXIT_FAILURE, "%s: calloc", __func__); } tick_stats->writer_tried_increase++; - for (do_try = h5_retry_init(&retry, 14, 10 * 1000 * 1000, - 100 * 1000 * 1000); - do_try; + for (do_try = h5_retry_init(&retry, 14, 10 * 1000 * 1000, 100 * 1000 * 1000); do_try; do_try = wait_for_reader && h5_retry_next(&retry)) { tick_stats->writer_read_shared_file++; @@ -166,16 +164,16 @@ vfd_swmr_writer_may_increase_tick_to(uint64_t new_tick, bool wait_for_reader) void vfd_swmr_reader_did_increase_tick_to(uint64_t new_tick) { - static int fd = -1; + static int fd = -1; shared_ticks_t shared; - ssize_t nwritten; + ssize_t nwritten; dbgf(3, "%s: enter\n", __func__); if (fd == -1) { // TBD create a temporary file, here, and move it to its final path // after writing it. - fd = open("./shared_tick_num", O_RDWR|O_CREAT, 0600); + fd = open("./shared_tick_num", O_RDWR | O_CREAT, 0600); if (fd == -1) err(EXIT_FAILURE, "%s: open", __func__); } @@ -202,83 +200,79 @@ vfd_swmr_reader_did_increase_tick_to(uint64_t new_tick) int main(int argc, char **argv) { - hid_t fapl, fcpl, fid; - H5F_t *f; - H5C_t *cache; - sigset_t oldsigs; - herr_t ret; - zoo_config_t config = { - .proc_num = 0 - , .skip_compact = false - , .skip_varlen = true - , .max_pause_msecs = 0 - , .msgival = {.tv_sec = 5, .tv_nsec = 0} - }; - struct timespec lastmsgtime = {.tv_sec = 0, .tv_nsec = 0}; - bool wait_for_signal; - int ch; - unsigned seed; - unsigned long tmpl; - char *end; - const char *seedvar = "H5_ZOO_STEP_SEED"; - bool use_vfd_swmr = true; - bool print_estack = false; - const char *progname = basename(argv[0]); - const char *personality = strstr(progname, "vfd_swmr_zoo_"); - estack_state_t es; - char step = 'b'; + hid_t fapl, fcpl, fid; + H5F_t * f; + H5C_t * cache; + sigset_t oldsigs; + herr_t ret; + zoo_config_t config = {.proc_num = 0, + .skip_compact = false, + .skip_varlen = true, + .max_pause_msecs = 0, + .msgival = {.tv_sec = 5, .tv_nsec = 0}}; + struct timespec lastmsgtime = {.tv_sec = 0, .tv_nsec = 0}; + bool wait_for_signal; + int ch; + unsigned seed; + unsigned long tmpl; + char * end; + const char * seedvar = "H5_ZOO_STEP_SEED"; + bool use_vfd_swmr = true; + bool print_estack = false; + const char * progname = basename(argv[0]); + const char * personality = strstr(progname, "vfd_swmr_zoo_"); + estack_state_t es; + char step = 'b'; H5F_vfd_swmr_config_t vfd_swmr_config; if (personality != NULL && strcmp(personality, "vfd_swmr_zoo_writer") == 0) writer = wait_for_signal = true; - else if (personality != NULL && - strcmp(personality, "vfd_swmr_zoo_reader") == 0) + else if (personality != NULL && strcmp(personality, "vfd_swmr_zoo_reader") == 0) writer = false; else { - errx(EXIT_FAILURE, - "unknown personality, expected vfd_swmr_zoo_{reader,writer}"); + errx(EXIT_FAILURE, "unknown personality, expected vfd_swmr_zoo_{reader,writer}"); } if (writer) config.max_pause_msecs = 50; while ((ch = getopt(argc, argv, "CSWaem:qv")) != -1) { - switch(ch) { - case 'C': - config.skip_compact = true; - break; - case 'S': - use_vfd_swmr = false; - break; - case 'W': - wait_for_signal = false; - break; - case 'a': - config.skip_varlen = false; - break; - case 'e': - print_estack = true; - break; - case 'm': - errno = 0; - tmpl = strtoul(optarg, &end, 0); - if (end == optarg || *end != '\0') - errx(EXIT_FAILURE, "couldn't parse `-m` argument `%s`", optarg); - else if (errno != 0) - err(EXIT_FAILURE, "couldn't parse `-m` argument `%s`", optarg); - else if (tmpl > UINT_MAX) - errx(EXIT_FAILURE, "`-m` argument `%lu` too large", tmpl); - config.max_pause_msecs = (unsigned)tmpl; - break; - case 'q': - verbosity = 1; - break; - case 'v': - verbosity = 3; - break; - default: - usage(argv[0]); - break; + switch (ch) { + case 'C': + config.skip_compact = true; + break; + case 'S': + use_vfd_swmr = false; + break; + case 'W': + wait_for_signal = false; + break; + case 'a': + config.skip_varlen = false; + break; + case 'e': + print_estack = true; + break; + case 'm': + errno = 0; + tmpl = strtoul(optarg, &end, 0); + if (end == optarg || *end != '\0') + errx(EXIT_FAILURE, "couldn't parse `-m` argument `%s`", optarg); + else if (errno != 0) + err(EXIT_FAILURE, "couldn't parse `-m` argument `%s`", optarg); + else if (tmpl > UINT_MAX) + errx(EXIT_FAILURE, "`-m` argument `%lu` too large", tmpl); + config.max_pause_msecs = (unsigned)tmpl; + break; + case 'q': + verbosity = 1; + break; + case 'v': + verbosity = 3; + break; + default: + usage(argv[0]); + break; } } argv += optind; @@ -300,7 +294,7 @@ main(int argc, char **argv) if (fapl < 0) errx(EXIT_FAILURE, "vfd_swmr_create_fapl"); - if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0){ + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) { errx(EXIT_FAILURE, "%s.%d: H5Pset_libver_bounds", __func__, __LINE__); } @@ -336,14 +330,14 @@ main(int argc, char **argv) /* get seed from environment or else from time(3) */ switch (fetch_env_ulong(seedvar, UINT_MAX, &tmpl)) { - case -1: - errx(EXIT_FAILURE, "%s: fetch_env_ulong", __func__); - case 0: - seed = (unsigned int)time(NULL); - break; - default: - seed = (unsigned int)tmpl; - break; + case -1: + errx(EXIT_FAILURE, "%s: fetch_env_ulong", __func__); + case 0: + seed = (unsigned int)time(NULL); + break; + default: + seed = (unsigned int)tmpl; + break; } dbgf(1, "To reproduce, set seed (%s) to %u.\n", seedvar, seed); @@ -367,7 +361,8 @@ main(int argc, char **argv) if (!delete_zoo(fid, ".", &lastmsgtime, config)) errx(EXIT_FAILURE, "delete_zoo failed"); - } else { + } + else { dbgf(2, "Reading zoo...\n"); while (!validate_zoo(fid, ".", &lastmsgtime, config)) @@ -386,20 +381,15 @@ main(int argc, char **argv) if (writer && tick_stats != NULL) { uint64_t lead; - dbgf(2, "writer tried tick increase %" PRIu64 "\n", - tick_stats->writer_tried_increase); - dbgf(2, "writer aborted tick increase %" PRIu64 "\n", - tick_stats->writer_aborted_increase); - dbgf(2, "writer read shared file %" PRIu64 "\n", - tick_stats->writer_read_shared_file); - dbgf(2, "writer read reader tick equal to 0 %" PRIu64 "\n", - tick_stats->reader_tick_was_zero); - dbgf(2, "writer read reader tick leading writer %" PRIu64 "\n", - tick_stats->reader_tick_lead_writer); + dbgf(2, "writer tried tick increase %" PRIu64 "\n", tick_stats->writer_tried_increase); + dbgf(2, "writer aborted tick increase %" PRIu64 "\n", tick_stats->writer_aborted_increase); + dbgf(2, "writer read shared file %" PRIu64 "\n", tick_stats->writer_read_shared_file); + dbgf(2, "writer read reader tick equal to 0 %" PRIu64 "\n", tick_stats->reader_tick_was_zero); + dbgf(2, "writer read reader tick leading writer %" PRIu64 "\n", tick_stats->reader_tick_lead_writer); for (lead = 0; lead < swmr_config.max_lag; lead++) { - dbgf(2, "writer tick lead writer by %" PRIu64 " %" PRIu64 "\n", - lead, tick_stats->writer_lead_reader_by[lead]); + dbgf(2, "writer tick lead writer by %" PRIu64 " %" PRIu64 "\n", lead, + tick_stats->writer_lead_reader_by[lead]); } } diff --git a/test/vol.c b/test/vol.c index 0f8af4f..6abdccb 100644 --- a/test/vol.c +++ b/test/vol.c @@ -21,136 +21,145 @@ #include "h5test.h" /* Filename */ -const char *FILENAME[] = { - "native_vol_test", - NULL -}; +const char *FILENAME[] = {"native_vol_test", NULL}; -#define NATIVE_VOL_TEST_GROUP_NAME "test_group" -#define NATIVE_VOL_TEST_DATASET_NAME "test_dataset" -#define NATIVE_VOL_TEST_ATTRIBUTE_NAME "test_dataset" -#define NATIVE_VOL_TEST_HARD_LINK_NAME "test_hard_link" -#define NATIVE_VOL_TEST_SOFT_LINK_NAME "test_soft_link" -#define NATIVE_VOL_TEST_MOVE_LINK_NAME "test_move_link" -#define NATIVE_VOL_TEST_COPY_LINK_NAME "test_copy_link" -#define NATIVE_VOL_TEST_DATATYPE_NAME "test_datatype" +#define NATIVE_VOL_TEST_GROUP_NAME "test_group" +#define NATIVE_VOL_TEST_DATASET_NAME "test_dataset" +#define NATIVE_VOL_TEST_ATTRIBUTE_NAME "test_dataset" +#define NATIVE_VOL_TEST_HARD_LINK_NAME "test_hard_link" +#define NATIVE_VOL_TEST_SOFT_LINK_NAME "test_soft_link" +#define NATIVE_VOL_TEST_MOVE_LINK_NAME "test_move_link" +#define NATIVE_VOL_TEST_COPY_LINK_NAME "test_copy_link" +#define NATIVE_VOL_TEST_DATATYPE_NAME "test_datatype" -#define N_ELEMENTS 10 +#define N_ELEMENTS 10 -#define FAKE_VOL_NAME "fake" +#define FAKE_VOL_NAME "fake" #define FAKE_VOL_VALUE ((H5VL_class_value_t)501) /* A VOL class struct that describes a VOL class with no * functionality. */ static const H5VL_class_t fake_vol_g = { - 0, /* version */ - FAKE_VOL_VALUE, /* value */ - FAKE_VOL_NAME, /* name */ - 0, /* capability flags */ - NULL, /* initialize */ - NULL, /* terminate */ - { /* info_cls */ - (size_t)0, /* size */ - NULL, /* copy */ - NULL, /* compare */ - NULL, /* free */ - NULL, /* to_str */ - NULL, /* from_str */ + 0, /* version */ + FAKE_VOL_VALUE, /* value */ + FAKE_VOL_NAME, /* name */ + 0, /* capability flags */ + NULL, /* initialize */ + NULL, /* terminate */ + { + /* info_cls */ + (size_t)0, /* size */ + NULL, /* copy */ + NULL, /* compare */ + NULL, /* free */ + NULL, /* to_str */ + NULL, /* from_str */ }, - { /* wrap_cls */ - NULL, /* get_object */ - NULL, /* get_wrap_ctx */ - NULL, /* wrap_object */ - NULL, /* unwrap_object */ - NULL, /* free_wrap_ctx */ + { + /* wrap_cls */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL, /* free_wrap_ctx */ }, - { /* attribute_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* attribute_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* dataset_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* dataset_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* datatype_cls */ - NULL, /* commit */ - NULL, /* open */ - NULL, /* get_size */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* datatype_cls */ + NULL, /* commit */ + NULL, /* open */ + NULL, /* get_size */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* file_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* file_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* group_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + { + /* group_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, - { /* link_cls */ - NULL, /* create */ - NULL, /* copy */ - NULL, /* move */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + { + /* link_cls */ + NULL, /* create */ + NULL, /* copy */ + NULL, /* move */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, - { /* object_cls */ - NULL, /* open */ - NULL, /* copy */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + { + /* object_cls */ + NULL, /* open */ + NULL, /* copy */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, - { /* introspect_cls */ - NULL, /* get_conn_cls */ - NULL, /* opt_query */ + { + /* introspect_cls */ + NULL, /* get_conn_cls */ + NULL, /* opt_query */ }, - { /* request_cls */ - NULL, /* wait */ - NULL, /* notify */ - NULL, /* cancel */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* free */ + { + /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ }, - { /* blob_cls */ - NULL, /* put */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + { + /* blob_cls */ + NULL, /* put */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, - { /* token_cls */ - NULL, /* cmp */ - NULL, /* to_str */ - NULL /* from_str */ + { + /* token_cls */ + NULL, /* cmp */ + NULL, /* to_str */ + NULL /* from_str */ }, - NULL /* optional */ + NULL /* optional */ }; - /*------------------------------------------------------------------------- * Function: test_vol_registration() * @@ -164,13 +173,13 @@ static const H5VL_class_t fake_vol_g = { static herr_t test_vol_registration(void) { - hid_t native_id = H5I_INVALID_HID; - hid_t lapl_id = H5I_INVALID_HID; - hid_t vipl_id = H5I_INVALID_HID; - herr_t ret = SUCCEED; + hid_t native_id = H5I_INVALID_HID; + hid_t lapl_id = H5I_INVALID_HID; + hid_t vipl_id = H5I_INVALID_HID; + herr_t ret = SUCCEED; htri_t is_registered = FAIL; - hid_t vol_id = H5I_INVALID_HID; - hid_t vol_id2 = H5I_INVALID_HID; + hid_t vol_id = H5I_INVALID_HID; + hid_t vol_id2 = H5I_INVALID_HID; TESTING("VOL registration"); @@ -187,9 +196,11 @@ test_vol_registration(void) /* Test registering a connector with an incorrect property list (SHOULD FAIL) */ if ((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { vol_id = H5VLregister_connector(&fake_vol_g, lapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (H5I_INVALID_HID != vol_id) FAIL_PUTS_ERROR("should not be able to register a connector with an incorrect property list"); if (H5Pclose(lapl_id) < 0) @@ -252,9 +263,11 @@ test_vol_registration(void) /* Try to unregister the native VOL connector (should fail) */ if (H5I_INVALID_HID == (native_id = H5VLget_connector_id_by_name(H5VL_NATIVE_NAME))) TEST_ERROR; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5VLunregister_connector(native_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (FAIL != ret) FAIL_PUTS_ERROR("should not be able to unregister the native VOL connector"); @@ -262,16 +275,17 @@ test_vol_registration(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5VLunregister_connector(vol_id); H5Pclose(lapl_id); H5Pclose(vipl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_vol_registration() */ - /*------------------------------------------------------------------------- * Function: test_native_vol_init() * @@ -307,7 +321,6 @@ error: } /* end test_native_vol_init() */ - /*------------------------------------------------------------------------- * Function: test_basic_file_operation() * @@ -320,20 +333,20 @@ error: static herr_t test_basic_file_operation(const char *env_h5_drvr) { - hid_t fid = H5I_INVALID_HID; - hid_t fid_reopen = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t fapl_id2 = H5I_INVALID_HID; - hid_t fcpl_id = H5I_INVALID_HID; - - char filename[1024]; - ssize_t obj_count; - hid_t obj_id_list[1]; - hsize_t file_size; - unsigned intent; - void *os_file_handle = NULL; - H5F_info2_t finfo; - char name[32]; + hid_t fid = H5I_INVALID_HID; + hid_t fid_reopen = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t fapl_id2 = H5I_INVALID_HID; + hid_t fcpl_id = H5I_INVALID_HID; + + char filename[1024]; + ssize_t obj_count; + hid_t obj_id_list[1]; + hsize_t file_size; + unsigned intent; + void * os_file_handle = NULL; + H5F_info2_t finfo; + char name[32]; TESTING("Basic VOL file operations"); @@ -350,9 +363,9 @@ test_basic_file_operation(const char *env_h5_drvr) * I'm not fighting it, just getting the testing to verify that the VOL * connector property is returned correctly. -QAK, 2018/11/17 */ - if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI) < 0) + if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI) < 0) TEST_ERROR; - if(H5Pset_metadata_read_attempts(fapl_id, 9) < 0) + if (H5Pset_metadata_read_attempts(fapl_id, 9) < 0) TEST_ERROR /* H5Fcreate */ @@ -374,7 +387,8 @@ test_basic_file_operation(const char *env_h5_drvr) TEST_ERROR; /* Can't compare VFD properties for split / multi / family VFDs */ - if((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"))) { + if ((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && + HDstrcmp(env_h5_drvr, "family"))) { /* H5Fget_access_plist */ if ((fapl_id2 = H5Fget_access_plist(fid)) < 0) TEST_ERROR; @@ -395,7 +409,8 @@ test_basic_file_operation(const char *env_h5_drvr) TEST_ERROR; /* Can't retrieve VFD handle for split / multi / family VFDs */ - if((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"))) { + if ((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && + HDstrcmp(env_h5_drvr, "family"))) { /* H5Fget_vfd_handle */ if (H5Fget_vfd_handle(fid, H5P_DEFAULT, &os_file_handle) < 0) TEST_ERROR; @@ -434,13 +449,14 @@ test_basic_file_operation(const char *env_h5_drvr) TEST_ERROR; /* Can't compare VFD properties for split / multi / family VFDs */ - if((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"))) { + if ((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && + HDstrcmp(env_h5_drvr, "family"))) { /* H5Fget_access_plist */ - if((fapl_id2 = H5Fget_access_plist(fid)) < 0) + if ((fapl_id2 = H5Fget_access_plist(fid)) < 0) TEST_ERROR; - if(H5Pequal(fapl_id, fapl_id2) != TRUE) + if (H5Pequal(fapl_id, fapl_id2) != TRUE) TEST_ERROR; - if(H5Pclose(fapl_id2) < 0) + if (H5Pclose(fapl_id2) < 0) TEST_ERROR; } /* end if */ @@ -448,13 +464,14 @@ test_basic_file_operation(const char *env_h5_drvr) TEST_ERROR; /* Can't compare VFD properties for split / multi / family VFDs */ - if((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family"))) { + if ((hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && + HDstrcmp(env_h5_drvr, "family"))) { /* H5Fget_access_plist */ - if((fapl_id2 = H5Fget_access_plist(fid_reopen)) < 0) + if ((fapl_id2 = H5Fget_access_plist(fid_reopen)) < 0) TEST_ERROR; - if(H5Pequal(fapl_id, fapl_id2) != TRUE) + if (H5Pequal(fapl_id, fapl_id2) != TRUE) TEST_ERROR; - if(H5Pclose(fapl_id2) < 0) + if (H5Pclose(fapl_id2) < 0) TEST_ERROR; } /* end if */ @@ -473,19 +490,20 @@ test_basic_file_operation(const char *env_h5_drvr) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Fclose(fid_reopen); H5Pclose(fapl_id); H5Pclose(fapl_id2); H5Pclose(fcpl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_basic_file_operation() */ - /*------------------------------------------------------------------------- * Function: test_basic_group_operation() * @@ -498,12 +516,12 @@ error: static herr_t test_basic_group_operation(void) { - hid_t fid = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t gid_a = H5I_INVALID_HID; - hid_t gcpl_id = H5I_INVALID_HID; - char filename[1024]; + hid_t fid = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t gid_a = H5I_INVALID_HID; + hid_t gcpl_id = H5I_INVALID_HID; + char filename[1024]; H5G_info_t info; TESTING("Basic VOL group operations"); @@ -576,18 +594,19 @@ test_basic_group_operation(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Gclose(gid); H5Pclose(fapl_id); H5Pclose(gcpl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_basic_group_operation() */ - /*------------------------------------------------------------------------- * Function: test_basic_dataset_operation() * @@ -600,22 +619,22 @@ error: static herr_t test_basic_dataset_operation(void) { - hid_t fid = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t dapl_id = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t did_a = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dapl_id = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t did_a = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; char filename[1024]; - hsize_t curr_dims = 0; - hsize_t max_dims = H5S_UNLIMITED; + hsize_t curr_dims = 0; + hsize_t max_dims = H5S_UNLIMITED; - hsize_t storage_size; - haddr_t offset; + hsize_t storage_size; + haddr_t offset; H5D_space_status_t status; int in_buf[N_ELEMENTS]; @@ -632,7 +651,7 @@ test_basic_dataset_operation(void) if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; for (i = 0; i < N_ELEMENTS; i++) { - in_buf[i] = i; + in_buf[i] = i; out_buf[i] = 0; } @@ -645,7 +664,8 @@ test_basic_dataset_operation(void) TEST_ERROR; if (H5Pset_chunk(dcpl_id, 1, &curr_dims) < 0) TEST_ERROR; - if ((did = H5Dcreate2(fid, NATIVE_VOL_TEST_DATASET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, NATIVE_VOL_TEST_DATASET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, + H5P_DEFAULT)) < 0) TEST_ERROR; /* H5Dcreate_anon */ @@ -753,7 +773,8 @@ test_basic_dataset_operation(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Dclose(did); H5Dclose(did_a); @@ -762,13 +783,13 @@ error: H5Pclose(fapl_id); H5Pclose(dapl_id); H5Pclose(dcpl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_basic_dataset_operation() */ - /*------------------------------------------------------------------------- * Function: test_basic_attribute_operation() * @@ -781,19 +802,19 @@ error: static herr_t test_basic_attribute_operation(void) { - hid_t fid = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t aid = H5I_INVALID_HID; - hid_t aid_name = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + hid_t aid_name = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; - char filename[1024]; + char filename[1024]; - hsize_t dims = 1; + hsize_t dims = 1; - int data_in = 42; - int data_out = 0; + int data_in = 42; + int data_out = 0; TESTING("Basic VOL attribute operations"); @@ -810,7 +831,8 @@ test_basic_attribute_operation(void) TEST_ERROR; /* H5Acreate */ - if ((aid = H5Acreate2(fid, NATIVE_VOL_TEST_ATTRIBUTE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(fid, NATIVE_VOL_TEST_ATTRIBUTE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, + H5P_DEFAULT)) < 0) TEST_ERROR; /* H5Awrite */ @@ -838,7 +860,8 @@ test_basic_attribute_operation(void) TEST_ERROR; /* H5Acreate_by_name */ - if ((aid_name = H5Acreate_by_name(fid, NATIVE_VOL_TEST_GROUP_NAME, NATIVE_VOL_TEST_ATTRIBUTE_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid_name = H5Acreate_by_name(fid, NATIVE_VOL_TEST_GROUP_NAME, NATIVE_VOL_TEST_ATTRIBUTE_NAME, + H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* H5Aclose */ if (H5Aclose(aid_name) < 0) @@ -865,20 +888,21 @@ test_basic_attribute_operation(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fapl_id); H5Gclose(gid); H5Sclose(sid); H5Aclose(aid); H5Aclose(aid_name); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_basic_attribute_operation() */ - /*------------------------------------------------------------------------- * Function: test_basic_object_operation() * @@ -891,12 +915,12 @@ error: static herr_t test_basic_object_operation(void) { - hid_t fid = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t oid = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t oid = H5I_INVALID_HID; - char filename[1024]; + char filename[1024]; H5O_info2_t object_info; TESTING("Basic VOL object operations"); @@ -939,22 +963,22 @@ test_basic_object_operation(void) if (H5Pclose(fapl_id) < 0) TEST_ERROR; - PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Pclose(fapl_id); H5Gclose(gid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_basic_object_operation() */ - /*------------------------------------------------------------------------- * Function: test_basic_link_operation() * @@ -967,10 +991,10 @@ error: static herr_t test_basic_link_operation(void) { - hid_t fid = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - char filename[1024]; + hid_t fid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + char filename[1024]; TESTING("Basic VOL link operations"); @@ -998,11 +1022,13 @@ test_basic_link_operation(void) TEST_ERROR; /* H5Lcopy */ - if (H5Lcopy(gid, NATIVE_VOL_TEST_HARD_LINK_NAME, fid, NATIVE_VOL_TEST_COPY_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcopy(gid, NATIVE_VOL_TEST_HARD_LINK_NAME, fid, NATIVE_VOL_TEST_COPY_LINK_NAME, H5P_DEFAULT, + H5P_DEFAULT) < 0) TEST_ERROR; /* H5Lmove */ - if (H5Lmove(fid, NATIVE_VOL_TEST_COPY_LINK_NAME, gid, NATIVE_VOL_TEST_MOVE_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lmove(fid, NATIVE_VOL_TEST_COPY_LINK_NAME, gid, NATIVE_VOL_TEST_MOVE_LINK_NAME, H5P_DEFAULT, + H5P_DEFAULT) < 0) TEST_ERROR; if (H5Fclose(fid) < 0) @@ -1016,22 +1042,22 @@ test_basic_link_operation(void) if (H5Pclose(fapl_id) < 0) TEST_ERROR; - PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid); H5Fclose(gid); H5Pclose(fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_basic_link_operation() */ - /*------------------------------------------------------------------------- * Function: test_basic_datatype_operation() * @@ -1044,12 +1070,12 @@ error: static herr_t test_basic_datatype_operation(void) { - hid_t fid = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; - hid_t tid_anon = H5I_INVALID_HID; - hid_t tcpl_id = H5I_INVALID_HID; - char filename[1024]; + hid_t fid = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t tid_anon = H5I_INVALID_HID; + hid_t tcpl_id = H5I_INVALID_HID; + char filename[1024]; TESTING("Basic VOL datatype operations"); @@ -1111,19 +1137,20 @@ test_basic_datatype_operation(void) return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(tcpl_id); H5Fclose(fid); H5Pclose(fapl_id); H5Tclose(tid); H5Tclose(tid_anon); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_basic_datatype_operation() */ - /*------------------------------------------------------------------------- * Function: main * @@ -1136,31 +1163,30 @@ error: int main(void) { - const char *env_h5_drvr; /* File driver value from environment */ - int nerrors = 0; + const char *env_h5_drvr; /* File driver value from environment */ + int nerrors = 0; /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) + if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; h5_reset(); HDputs("Testing basic Virtual Object Layer (VOL) functionality."); - nerrors += test_vol_registration() < 0 ? 1 : 0; - nerrors += test_native_vol_init() < 0 ? 1 : 0; + nerrors += test_vol_registration() < 0 ? 1 : 0; + nerrors += test_native_vol_init() < 0 ? 1 : 0; nerrors += test_basic_file_operation(env_h5_drvr) < 0 ? 1 : 0; - nerrors += test_basic_group_operation() < 0 ? 1 : 0; - nerrors += test_basic_dataset_operation() < 0 ? 1 : 0; + nerrors += test_basic_group_operation() < 0 ? 1 : 0; + nerrors += test_basic_dataset_operation() < 0 ? 1 : 0; nerrors += test_basic_attribute_operation() < 0 ? 1 : 0; - nerrors += test_basic_object_operation() < 0 ? 1 : 0; - nerrors += test_basic_link_operation() < 0 ? 1 : 0; - nerrors += test_basic_datatype_operation() < 0 ? 1 : 0; + nerrors += test_basic_object_operation() < 0 ? 1 : 0; + nerrors += test_basic_link_operation() < 0 ? 1 : 0; + nerrors += test_basic_datatype_operation() < 0 ? 1 : 0; if (nerrors) { - HDprintf("***** %d Virtual Object Layer TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + HDprintf("***** %d Virtual Object Layer TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); HDexit(EXIT_FAILURE); } @@ -1169,4 +1195,3 @@ main(void) HDexit(EXIT_SUCCESS); } /* end main() */ - diff --git a/test/vol_plugin.c b/test/vol_plugin.c index 565c847..a4052ce 100644 --- a/test/vol_plugin.c +++ b/test/vol_plugin.c @@ -23,7 +23,6 @@ #include "null_vol_connector.h" - /*------------------------------------------------------------------------- * Function: test_registration_by_value() * @@ -37,49 +36,50 @@ static herr_t test_registration_by_value(void) { - htri_t is_registered = FAIL; - hid_t vol_id = H5I_INVALID_HID; + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; TESTING("VOL registration by value"); /* The null VOL connector should not be registered at the start of the test */ - if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + if ((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); /* Register the connector by value */ - if((vol_id = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) + if ((vol_id = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) TEST_ERROR; /* The connector should be registered now */ - if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + if ((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if(FALSE == is_registered) + if (FALSE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector was not registered"); /* Unregister the connector */ - if(H5VLunregister_connector(vol_id) < 0) + if (H5VLunregister_connector(vol_id) < 0) TEST_ERROR; /* The connector should not be registered now */ - if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + if ((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5VLunregister_connector(vol_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_registration_by_value() */ - /*------------------------------------------------------------------------- * Function: test_registration_by_name() * @@ -93,49 +93,50 @@ error: static herr_t test_registration_by_name(void) { - htri_t is_registered = FAIL; - hid_t vol_id = H5I_INVALID_HID; + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; TESTING("VOL registration by name"); /* The null VOL connector should not be registered at the start of the test */ - if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); /* Register the connector by name */ - if((vol_id = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) + if ((vol_id = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* The connector should be registered now */ - if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if(FALSE == is_registered) + if (FALSE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector was not registered"); /* Unregister the connector */ - if(H5VLunregister_connector(vol_id) < 0) + if (H5VLunregister_connector(vol_id) < 0) TEST_ERROR; /* The connector should not be registered now */ - if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5VLunregister_connector(vol_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_registration_by_name() */ - /*------------------------------------------------------------------------- * Function: test_multiple_registration() * @@ -149,97 +150,98 @@ error: static herr_t test_multiple_registration(void) { - htri_t is_registered = FAIL; - hid_t vol_ids[N_REGISTRATIONS]; - int i; + htri_t is_registered = FAIL; + hid_t vol_ids[N_REGISTRATIONS]; + int i; TESTING("registering a VOL connector multiple times"); /* The null VOL connector should not be registered at the start of the test */ - if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); /* Register the connector multiple times */ - for(i = 0; i < N_REGISTRATIONS; i++) { - if((vol_ids[i] = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) + for (i = 0; i < N_REGISTRATIONS; i++) { + if ((vol_ids[i] = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; } /* The connector should be registered now */ - if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if(FALSE == is_registered) + if (FALSE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector was not registered"); /* Unregister the connector */ - for(i = 0; i < N_REGISTRATIONS; i++) { - if(H5VLunregister_connector(vol_ids[i]) < 0) + for (i = 0; i < N_REGISTRATIONS; i++) { + if (H5VLunregister_connector(vol_ids[i]) < 0) TEST_ERROR; /* Also test close on some of the IDs. This call currently works * identically to unregister. */ i++; - if(H5VLclose(vol_ids[i]) < 0) + if (H5VLclose(vol_ids[i]) < 0) TEST_ERROR; } /* The connector should not be registered now */ - if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); /* Repeat testing with the _by_value routines */ - if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + if ((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); /* Register the connector multiple times */ - for(i = 0; i < N_REGISTRATIONS; i++) { - if((vol_ids[i] = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) + for (i = 0; i < N_REGISTRATIONS; i++) { + if ((vol_ids[i] = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) TEST_ERROR; } /* The connector should be registered now */ - if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + if ((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if(FALSE == is_registered) + if (FALSE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector was not registered"); /* Unregister the connector */ - for(i = 0; i < N_REGISTRATIONS; i++) { - if(H5VLunregister_connector(vol_ids[i]) < 0) + for (i = 0; i < N_REGISTRATIONS; i++) { + if (H5VLunregister_connector(vol_ids[i]) < 0) TEST_ERROR; /* Also test close on some of the IDs. This call currently works * identically to unregister. */ i++; - if(H5VLclose(vol_ids[i]) < 0) + if (H5VLclose(vol_ids[i]) < 0) TEST_ERROR; } /* The connector should not be registered now */ - if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + if ((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { - for(i = 0; i < N_REGISTRATIONS; i++) + H5E_BEGIN_TRY + { + for (i = 0; i < N_REGISTRATIONS; i++) H5VLunregister_connector(vol_ids[i]); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_multiple_registration() */ - /*------------------------------------------------------------------------- * Function: test_getters() * @@ -252,69 +254,70 @@ error: static herr_t test_getters(void) { - htri_t is_registered = FAIL; - hid_t vol_id = H5I_INVALID_HID; - hid_t vol_id_out = H5I_INVALID_HID; + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; + hid_t vol_id_out = H5I_INVALID_HID; TESTING("VOL getters"); /* The null VOL connector should not be registered at the start of the test */ - if((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + if ((is_registered = H5VLis_connector_registered_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); /* Register the connector by name */ - if((vol_id = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) + if ((vol_id = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Get the connector's ID by name */ - if((vol_id_out = H5VLget_connector_id_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) + if ((vol_id_out = H5VLget_connector_id_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if(vol_id != vol_id_out) + if (vol_id != vol_id_out) FAIL_PUTS_ERROR("VOL connector IDs don't match"); - if(H5VLclose(vol_id_out) < 0) + if (H5VLclose(vol_id_out) < 0) TEST_ERROR; /* Unregister the connector */ - if(H5VLunregister_connector(vol_id) < 0) + if (H5VLunregister_connector(vol_id) < 0) TEST_ERROR; /* Repeat testing with the _by_value routines */ - if((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + if ((is_registered = H5VLis_connector_registered_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if(TRUE == is_registered) + if (TRUE == is_registered) FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); /* Register the connector by value */ - if((vol_id = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) + if ((vol_id = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) TEST_ERROR; /* Get the connector's ID by value */ - if((vol_id_out = H5VLget_connector_id_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) + if ((vol_id_out = H5VLget_connector_id_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if(vol_id != vol_id_out) + if (vol_id != vol_id_out) FAIL_PUTS_ERROR("VOL connector IDs don't match"); - if(H5VLclose(vol_id_out) < 0) + if (H5VLclose(vol_id_out) < 0) TEST_ERROR; /* Unregister the connector */ - if(H5VLunregister_connector(vol_id) < 0) + if (H5VLunregister_connector(vol_id) < 0) TEST_ERROR; PASSED(); return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5VLclose(vol_id_out); H5VLunregister_connector(vol_id); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end test_getters() */ - /*------------------------------------------------------------------------- * Function: main * @@ -333,14 +336,13 @@ main(void) HDputs("Testing VOL connector plugin functionality."); - nerrors += test_registration_by_name() < 0 ? 1 : 0; - nerrors += test_registration_by_value() < 0 ? 1 : 0; - nerrors += test_multiple_registration() < 0 ? 1 : 0; - nerrors += test_getters() < 0 ? 1 : 0; + nerrors += test_registration_by_name() < 0 ? 1 : 0; + nerrors += test_registration_by_value() < 0 ? 1 : 0; + nerrors += test_multiple_registration() < 0 ? 1 : 0; + nerrors += test_getters() < 0 ? 1 : 0; - if(nerrors) { - HDprintf("***** %d VOL connector plugin TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); + if (nerrors) { + HDprintf("***** %d VOL connector plugin TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); HDexit(EXIT_FAILURE); } @@ -349,4 +351,3 @@ main(void) HDexit(EXIT_SUCCESS); } /* end main() */ - diff --git a/testpar/t_2Gio.c b/testpar/t_2Gio.c index ee19b5f..9632bc0 100644 --- a/testpar/t_2Gio.c +++ b/testpar/t_2Gio.c @@ -32,7 +32,6 @@ #include "mpi.h" - /* For this test, we don't want to inherit the RANK definition * from testphdf5.h. We'll define MAX_RANK to accomodate 3D arrays * and use that definition rather than RANK. @@ -57,8 +56,8 @@ #endif #ifndef PATH_MAX -#define PATH_MAX 512 -#endif /* !PATH_MAX */ +#define PATH_MAX 512 +#endif /* !PATH_MAX */ /* global variables */ int dim0; @@ -66,25 +65,22 @@ int dim1; int dim2; int chunkdim0; int chunkdim1; -int nerrors = 0; /* errors count */ -int ndatasets = 300; /* number of datasets to create*/ -int ngroups = 512; /* number of groups to create in root - * group. */ -int facc_type = FACC_MPIO; /*Test file access type */ +int nerrors = 0; /* errors count */ +int ndatasets = 300; /* number of datasets to create*/ +int ngroups = 512; /* number of groups to create in root + * group. */ +int facc_type = FACC_MPIO; /*Test file access type */ int dxfer_coll_type = DXFER_COLLECTIVE_IO; -H5E_auto2_t old_func; /* previous error handler */ -void *old_client_data; /* previous error handler arg.*/ +H5E_auto2_t old_func; /* previous error handler */ +void * old_client_data; /* previous error handler arg.*/ -#define NFILENAME 3 +#define NFILENAME 3 #define PARATESTFILE filenames[0] -const char *FILENAME[NFILENAME]={ - "ParaTest", - "Hugefile", - NULL}; -char filenames[NFILENAME][PATH_MAX]; -hid_t fapl; /* file access property list */ -MPI_Comm test_comm = MPI_COMM_WORLD; +const char *FILENAME[NFILENAME] = {"ParaTest", "Hugefile", NULL}; +char filenames[NFILENAME][PATH_MAX]; +hid_t fapl; /* file access property list */ +MPI_Comm test_comm = MPI_COMM_WORLD; // static int enable_error_stack = 0; /* enable error stack; disable=0 enable=1 */ // static const char *TestProgName = NULL; @@ -95,7 +91,6 @@ MPI_Comm test_comm = MPI_COMM_WORLD; * The following are various utility routines used by the tests. */ - /* * Show command usage */ @@ -103,15 +98,15 @@ static void usage(void) { HDprintf(" [-r] [-w] [-m] [-n] " - "[-o] [-f ] [-d ]\n"); + "[-o] [-f ] [-d ]\n"); HDprintf("\t-m" - "\tset number of datasets for the multiple dataset test\n"); + "\tset number of datasets for the multiple dataset test\n"); HDprintf("\t-n" - "\tset number of groups for the multiple group test\n"); + "\tset number of groups for the multiple group test\n"); HDprintf("\t-f \tfilename prefix\n"); HDprintf("\t-2\t\tuse Split-file together with MPIO\n"); - HDprintf("\t-d \tdataset dimensions factors. Defaults (%d,%d)\n", - BIG_X_FACTOR, BIG_Y_FACTOR); + HDprintf("\t-d \tdataset dimensions factors. Defaults (%d,%d)\n", BIG_X_FACTOR, + BIG_Y_FACTOR); HDprintf("\t-c \tdataset chunk dimensions. Defaults (dim0/10,dim1/10)\n"); HDprintf("\n"); } @@ -122,124 +117,127 @@ usage(void) static int parse_options(int argc, char **argv) { - int mpi_size, mpi_rank; /* mpi variables */ + int mpi_size, mpi_rank; /* mpi variables */ MPI_Comm_size(test_comm, &mpi_size); MPI_Comm_rank(test_comm, &mpi_rank); /* setup default chunk-size. Make sure sizes are > 0 */ - chunkdim0 = (dim0+9)/10; - chunkdim1 = (dim1+9)/10; + chunkdim0 = (dim0 + 9) / 10; + chunkdim1 = (dim1 + 9) / 10; - while (--argc){ - if (**(++argv) != '-'){ - break; - }else{ - switch(*(*argv+1)){ - case 'm': ndatasets = atoi((*argv+1)+1); - if (ndatasets < 0){ - nerrors++; - return(1); - } + while (--argc) { + if (**(++argv) != '-') { break; - case 'n': ngroups = atoi((*argv+1)+1); - if (ngroups < 0){ - nerrors++; - return(1); - } - break; - case 'f': if (--argc < 1) { - nerrors++; - return(1); - } - if (**(++argv) == '-') { - nerrors++; - return(1); - } - paraprefix = *argv; - break; - case 'i': /* Collective MPI-IO access with independent IO */ - dxfer_coll_type = DXFER_INDEPENDENT_IO; - break; - case '2': /* Use the split-file driver with MPIO access */ - /* Can use $HDF5_METAPREFIX to define the */ - /* meta-file-prefix. */ - facc_type = FACC_MPIO | FACC_SPLIT; - break; - case 'd': /* dimensizes */ - if (--argc < 2){ - nerrors++; - return(1); - } - dim0 = atoi(*(++argv))*mpi_size; - argc--; - dim1 = atoi(*(++argv))*mpi_size; - /* set default chunkdim sizes too */ - chunkdim0 = (dim0+9)/10; - chunkdim1 = (dim1+9)/10; - break; - case 'c': /* chunk dimensions */ - if (--argc < 2){ + } + else { + switch (*(*argv + 1)) { + case 'm': + ndatasets = atoi((*argv + 1) + 1); + if (ndatasets < 0) { + nerrors++; + return (1); + } + break; + case 'n': + ngroups = atoi((*argv + 1) + 1); + if (ngroups < 0) { + nerrors++; + return (1); + } + break; + case 'f': + if (--argc < 1) { + nerrors++; + return (1); + } + if (**(++argv) == '-') { + nerrors++; + return (1); + } + paraprefix = *argv; + break; + case 'i': /* Collective MPI-IO access with independent IO */ + dxfer_coll_type = DXFER_INDEPENDENT_IO; + break; + case '2': /* Use the split-file driver with MPIO access */ + /* Can use $HDF5_METAPREFIX to define the */ + /* meta-file-prefix. */ + facc_type = FACC_MPIO | FACC_SPLIT; + break; + case 'd': /* dimensizes */ + if (--argc < 2) { + nerrors++; + return (1); + } + dim0 = atoi(*(++argv)) * mpi_size; + argc--; + dim1 = atoi(*(++argv)) * mpi_size; + /* set default chunkdim sizes too */ + chunkdim0 = (dim0 + 9) / 10; + chunkdim1 = (dim1 + 9) / 10; + break; + case 'c': /* chunk dimensions */ + if (--argc < 2) { + nerrors++; + return (1); + } + chunkdim0 = atoi(*(++argv)); + argc--; + chunkdim1 = atoi(*(++argv)); + break; + case 'h': /* print help message--return with nerrors set */ + return (1); + default: + HDprintf("Illegal option(%s)\n", *argv); nerrors++; - return(1); - } - chunkdim0 = atoi(*(++argv)); - argc--; - chunkdim1 = atoi(*(++argv)); - break; - case 'h': /* print help message--return with nerrors set */ - return(1); - default: HDprintf("Illegal option(%s)\n", *argv); - nerrors++; - return(1); + return (1); } } } /*while*/ /* check validity of dimension and chunk sizes */ - if (dim0 <= 0 || dim1 <= 0){ + if (dim0 <= 0 || dim1 <= 0) { HDprintf("Illegal dim sizes (%d, %d)\n", dim0, dim1); nerrors++; - return(1); + return (1); } - if (chunkdim0 <= 0 || chunkdim1 <= 0){ + if (chunkdim0 <= 0 || chunkdim1 <= 0) { HDprintf("Illegal chunkdim sizes (%d, %d)\n", chunkdim0, chunkdim1); nerrors++; - return(1); + return (1); } /* Make sure datasets can be divided into equal portions by the processes */ - if ((dim0 % mpi_size) || (dim1 % mpi_size)){ + if ((dim0 % mpi_size) || (dim1 % mpi_size)) { if (MAINPROCESS) - HDprintf("dim0(%d) and dim1(%d) must be multiples of processes(%d)\n", - dim0, dim1, mpi_size); + HDprintf("dim0(%d) and dim1(%d) must be multiples of processes(%d)\n", dim0, dim1, mpi_size); nerrors++; - return(1); + return (1); } /* compose the test filenames */ { int i, n; - n = sizeof(FILENAME)/sizeof(FILENAME[0]) - 1; /* exclude the NULL */ + n = sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; /* exclude the NULL */ - for (i=0; i < n; i++) - if (h5_fixname(FILENAME[i],fapl,filenames[i],sizeof(filenames[i])) - == NULL){ + for (i = 0; i < n; i++) + if (h5_fixname(FILENAME[i], fapl, filenames[i], sizeof(filenames[i])) == NULL) { HDprintf("h5_fixname failed\n"); nerrors++; - return(1); + return (1); } if (MAINPROCESS) { - HDprintf("Test filenames are:\n"); - for (i=0; i < n; i++) - HDprintf(" %s\n", filenames[i]); - } + HDprintf("Test filenames are:\n"); + for (i = 0; i < n; i++) + HDprintf(" %s\n", filenames[i]); + } } - return(0); + return (0); } /* @@ -248,20 +246,20 @@ parse_options(int argc, char **argv) hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) { - hid_t ret_pl = -1; - herr_t ret; /* generic return value */ - int mpi_rank; /* mpi variables */ + hid_t ret_pl = -1; + herr_t ret; /* generic return value */ + int mpi_rank; /* mpi variables */ /* need the rank for error checking macros */ MPI_Comm_rank(test_comm, &mpi_rank); - ret_pl = H5Pcreate (H5P_FILE_ACCESS); + ret_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY((ret_pl >= 0), "H5P_FILE_ACCESS"); if (l_facc_type == FACC_DEFAULT) return (ret_pl); - if (l_facc_type == FACC_MPIO){ + if (l_facc_type == FACC_MPIO) { /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(ret_pl, comm, info); VRFY((ret >= 0), ""); @@ -269,33 +267,32 @@ create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) VRFY((ret >= 0), ""); ret = H5Pset_coll_metadata_write(ret_pl, TRUE); VRFY((ret >= 0), ""); - return(ret_pl); + return (ret_pl); } - if (l_facc_type == (FACC_MPIO | FACC_SPLIT)){ + if (l_facc_type == (FACC_MPIO | FACC_SPLIT)) { hid_t mpio_pl; - mpio_pl = H5Pcreate (H5P_FILE_ACCESS); + mpio_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY((mpio_pl >= 0), ""); /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(mpio_pl, comm, info); VRFY((ret >= 0), ""); /* setup file access template */ - ret_pl = H5Pcreate (H5P_FILE_ACCESS); + ret_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY((ret_pl >= 0), ""); /* set Parallel access with communicator */ ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); VRFY((ret >= 0), "H5Pset_fapl_split succeeded"); H5Pclose(mpio_pl); - return(ret_pl); + return (ret_pl); } /* unknown file access types */ return (ret_pl); } - /* * Setup the dimensions of the hyperslab. * Two modes--by rows or by columns. @@ -306,227 +303,222 @@ create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) * ZCOL same as BYCOL except process 0 gets 0 columns */ static void -slab_set(int mpi_rank, int mpi_size, hsize_t start[], hsize_t count[], - hsize_t stride[], hsize_t block[], int mode) +slab_set(int mpi_rank, int mpi_size, hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], + int mode) { switch (mode) { - case BYROW: - /* Each process takes a slabs of rows. */ - block[0] = (hsize_t)dim0 / (hsize_t)mpi_size; - block[1] = (hsize_t)dim1; - stride[0] = block[0]; - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)mpi_rank * block[0]; - start[1] = 0; - if (VERBOSE_MED) - HDprintf("slab_set BYROW\n"); - break; - case BYCOL: - /* Each process takes a block of columns. */ - block[0] = (hsize_t)dim0; - block[1] = (hsize_t)dim1 / (hsize_t)mpi_size; - stride[0] = block[0]; - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = (hsize_t)mpi_rank * block[1]; - if (VERBOSE_MED) - HDprintf("slab_set BYCOL\n"); - break; - case ZROW: - /* Similar to BYROW except process 0 gets 0 row */ - block[0] = (hsize_t)(mpi_rank ? dim0 / mpi_size : 0); - block[1] = (hsize_t)dim1; - stride[0] = (mpi_rank ? block[0] : 1); /* avoid setting stride to 0 */ - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)(mpi_rank ? (hsize_t)mpi_rank * block[0] : 0); - start[1] = 0; - if (VERBOSE_MED) - HDprintf("slab_set ZROW\n"); - break; - case ZCOL: - /* Similar to BYCOL except process 0 gets 0 column */ - block[0] = (hsize_t)dim0; - block[1] = (hsize_t)(mpi_rank ? dim1 / mpi_size : 0); - stride[0] = block[0]; - stride[1] = (mpi_rank ? block[1] : 1); /* avoid setting stride to 0 */ - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = (hsize_t)(mpi_rank ? (hsize_t)mpi_rank * block[1] : 0); - if (VERBOSE_MED) - HDprintf("slab_set ZCOL\n"); - break; - default: - /* Unknown mode. Set it to cover the whole dataset. */ - HDprintf("unknown slab_set mode (%d)\n", mode); - block[0] = (hsize_t)dim0; - block[1] = (hsize_t)dim1; - stride[0] = block[0]; - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = 0; - if (VERBOSE_MED) - HDprintf("slab_set wholeset\n"); - break; + case BYROW: + /* Each process takes a slabs of rows. */ + block[0] = (hsize_t)dim0 / (hsize_t)mpi_size; + block[1] = (hsize_t)dim1; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)mpi_rank * block[0]; + start[1] = 0; + if (VERBOSE_MED) + HDprintf("slab_set BYROW\n"); + break; + case BYCOL: + /* Each process takes a block of columns. */ + block[0] = (hsize_t)dim0; + block[1] = (hsize_t)dim1 / (hsize_t)mpi_size; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = (hsize_t)mpi_rank * block[1]; + if (VERBOSE_MED) + HDprintf("slab_set BYCOL\n"); + break; + case ZROW: + /* Similar to BYROW except process 0 gets 0 row */ + block[0] = (hsize_t)(mpi_rank ? dim0 / mpi_size : 0); + block[1] = (hsize_t)dim1; + stride[0] = (mpi_rank ? block[0] : 1); /* avoid setting stride to 0 */ + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)(mpi_rank ? (hsize_t)mpi_rank * block[0] : 0); + start[1] = 0; + if (VERBOSE_MED) + HDprintf("slab_set ZROW\n"); + break; + case ZCOL: + /* Similar to BYCOL except process 0 gets 0 column */ + block[0] = (hsize_t)dim0; + block[1] = (hsize_t)(mpi_rank ? dim1 / mpi_size : 0); + stride[0] = block[0]; + stride[1] = (mpi_rank ? block[1] : 1); /* avoid setting stride to 0 */ + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = (hsize_t)(mpi_rank ? (hsize_t)mpi_rank * block[1] : 0); + if (VERBOSE_MED) + HDprintf("slab_set ZCOL\n"); + break; + default: + /* Unknown mode. Set it to cover the whole dataset. */ + HDprintf("unknown slab_set mode (%d)\n", mode); + block[0] = (hsize_t)dim0; + block[1] = (hsize_t)dim1; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = 0; + if (VERBOSE_MED) + HDprintf("slab_set wholeset\n"); + break; } if (VERBOSE_MED) { - HDprintf( - "start[]=(%lu,%lu), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long) start[0], (unsigned long) start[1], - (unsigned long) count[0], (unsigned long) count[1], - (unsigned long) stride[0], (unsigned long) stride[1], - (unsigned long) block[0], (unsigned long) block[1], - (unsigned long) (block[0] * block[1] * count[0] * count[1])); + HDprintf("start[]=(%lu,%lu), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); } } /* * Setup the coordinates for point selection. */ -void point_set(hsize_t start[], - hsize_t count[], - hsize_t stride[], - hsize_t block[], - size_t num_points, - hsize_t coords[], - int order) +void +point_set(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], size_t num_points, + hsize_t coords[], int order) { - hsize_t i,j, k = 0, m ,n, s1 ,s2; + hsize_t i, j, k = 0, m, n, s1, s2; // HDcompile_assert(MAX_RANK == 3); HDcompile_assert(MAX_RANK == 2); - if(OUT_OF_ORDER == order) + if (OUT_OF_ORDER == order) k = (num_points * MAX_RANK) - 1; - else if(IN_ORDER == order) + else if (IN_ORDER == order) k = 0; s1 = start[0]; s2 = start[1]; - for(i = 0 ; i < count[0]; i++) - for(j = 0 ; j < count[1]; j++) - for(m = 0 ; m < block[0]; m++) - for(n = 0 ; n < block[1]; n++) - if(OUT_OF_ORDER == order) { + for (i = 0; i < count[0]; i++) + for (j = 0; j < count[1]; j++) + for (m = 0; m < block[0]; m++) + for (n = 0; n < block[1]; n++) + if (OUT_OF_ORDER == order) { coords[k--] = s2 + (stride[1] * j) + n; coords[k--] = s1 + (stride[0] * i) + m; } - else if(IN_ORDER == order) { + else if (IN_ORDER == order) { coords[k++] = s1 + stride[0] * i + m; coords[k++] = s2 + stride[1] * j + n; } - if(VERBOSE_MED) { - HDprintf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1], - (unsigned long)(block[0] * block[1] * count[0] * count[1])); + if (VERBOSE_MED) { + HDprintf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); k = 0; - for(i = 0; i < num_points ; i++) { + for (i = 0; i < num_points; i++) { HDprintf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); k += 2; } } } - /* * Fill the dataset with trivial data for testing. * Assume dimension rank is 2 and data is stored contiguous. */ static void -dataset_fill(hsize_t start[], hsize_t block[], DATATYPE * dataset) +dataset_fill(hsize_t start[], hsize_t block[], DATATYPE *dataset) { DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* put some trivial data in the data_array */ - for (i=0; i < block[0]; i++){ - for (j=0; j < block[1]; j++){ - *dataptr = (DATATYPE)((i+start[0])*100 + (j+start[1]+1)); - dataptr++; - } + for (i = 0; i < block[0]; i++) { + for (j = 0; j < block[1]; j++) { + *dataptr = (DATATYPE)((i + start[0]) * 100 + (j + start[1] + 1)); + dataptr++; + } } } - /* * Print the content of the dataset. */ static void -dataset_print(hsize_t start[], hsize_t block[], DATATYPE * dataset) +dataset_print(hsize_t start[], hsize_t block[], DATATYPE *dataset) { DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* print the column heading */ HDprintf("%-8s", "Cols:"); - for (j=0; j < block[1]; j++){ - HDprintf("%3lu ", (unsigned long)(start[1]+j)); + for (j = 0; j < block[1]; j++) { + HDprintf("%3lu ", (unsigned long)(start[1] + j)); } HDprintf("\n"); /* print the slab data */ - for (i=0; i < block[0]; i++){ - HDprintf("Row %2lu: ", (unsigned long)(i+start[0])); - for (j=0; j < block[1]; j++){ - HDprintf("%03d ", *dataptr++); - } - HDprintf("\n"); + for (i = 0; i < block[0]; i++) { + HDprintf("Row %2lu: ", (unsigned long)(i + start[0])); + for (j = 0; j < block[1]; j++) { + HDprintf("%03d ", *dataptr++); + } + HDprintf("\n"); } } - /* * Print the content of the dataset. */ int -dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, DATATYPE *original) +dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, + DATATYPE *original) { hsize_t i, j; - int vrfyerrs; + int vrfyerrs; /* print it if VERBOSE_MED */ - if(VERBOSE_MED) { - HDprintf("dataset_vrfy dumping:::\n"); - HDprintf("start(%lu, %lu), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1]); - HDprintf("original values:\n"); - dataset_print(start, block, original); - HDprintf("compared values:\n"); - dataset_print(start, block, dataset); + if (VERBOSE_MED) { + HDprintf("dataset_vrfy dumping:::\n"); + HDprintf("start(%lu, %lu), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1]); + HDprintf("original values:\n"); + dataset_print(start, block, original); + HDprintf("compared values:\n"); + dataset_print(start, block, dataset); } vrfyerrs = 0; - for (i=0; i < block[0]; i++){ - for (j=0; j < block[1]; j++){ - if(*dataset != *original){ - if(vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED){ - HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n", - (unsigned long)i, (unsigned long)j, - (unsigned long)(i+start[0]), (unsigned long)(j+start[1]), - *(original), *(dataset)); - } - dataset++; - original++; + for (i = 0; i < block[0]; i++) { + for (j = 0; j < block[1]; j++) { + if (*dataset != *original) { + if (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED) { + HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n", + (unsigned long)i, (unsigned long)j, (unsigned long)(i + start[0]), + (unsigned long)(j + start[1]), *(original), *(dataset)); + } + dataset++; + original++; + } } } - } - if(vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) - HDprintf("[more errors ...]\n"); - if(vrfyerrs) - HDprintf("%d errors found in dataset_vrfy\n", vrfyerrs); - return(vrfyerrs); + if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) + HDprintf("[more errors ...]\n"); + if (vrfyerrs) + HDprintf("%d errors found in dataset_vrfy\n", vrfyerrs); + return (vrfyerrs); } /* NOTE: This is a memory intensive test and is only run @@ -549,26 +541,27 @@ dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[] * -n 1 ./h5_mpi_big_dataset.x 1024 1024 1024 */ -#define H5FILE_NAME "hugefile.h5" -#define DATASETNAME "dataset" +#define H5FILE_NAME "hugefile.h5" +#define DATASETNAME "dataset" -static int MpioTest2G( MPI_Comm comm ) +static int +MpioTest2G(MPI_Comm comm) { /* * HDF5 APIs definitions */ - herr_t status; - hid_t file_id, dset_id; /* file and dataset identifiers */ - hid_t plist_id; /* property list identifier */ - hid_t filespace; /* file and memory dataspace identifiers */ - int *data; /* pointer to data buffer to write */ - size_t tot_size_bytes; - hid_t dcpl_id; - hid_t memorydataspace; - hid_t filedataspace; - size_t slice_per_process; - size_t data_size; - size_t data_size_bytes; + herr_t status; + hid_t file_id, dset_id; /* file and dataset identifiers */ + hid_t plist_id; /* property list identifier */ + hid_t filespace; /* file and memory dataspace identifiers */ + int * data; /* pointer to data buffer to write */ + size_t tot_size_bytes; + hid_t dcpl_id; + hid_t memorydataspace; + hid_t filedataspace; + size_t slice_per_process; + size_t data_size; + size_t data_size_bytes; hsize_t chunk[3]; hsize_t h5_counts[3]; @@ -578,24 +571,24 @@ static int MpioTest2G( MPI_Comm comm ) /* * MPI variables */ - int mpi_size, mpi_rank; - MPI_Info info = MPI_INFO_NULL; + int mpi_size, mpi_rank; + MPI_Info info = MPI_INFO_NULL; MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - if(mpi_rank == 0) { - HDprintf("Using %d process on dataset shape [%llu, %llu, %llu]\n", - mpi_size, shape[0], shape[1], shape[2]); + if (mpi_rank == 0) { + HDprintf("Using %d process on dataset shape [%llu, %llu, %llu]\n", mpi_size, shape[0], shape[1], + shape[2]); } /* * Set up file access property list with parallel I/O access */ - plist_id = H5Pcreate(H5P_FILE_ACCESS); - VRFY((plist_id >= 0), "H5Pcreate file_access succeeded"); - status = H5Pset_fapl_mpio(plist_id, comm, info); - VRFY((status >= 0), "H5Pset_dxpl_mpio succeeded"); + plist_id = H5Pcreate(H5P_FILE_ACCESS); + VRFY((plist_id >= 0), "H5Pcreate file_access succeeded"); + status = H5Pset_fapl_mpio(plist_id, comm, info); + VRFY((status >= 0), "H5Pset_dxpl_mpio succeeded"); /* * Create a new file collectively and release property list identifier. @@ -610,10 +603,10 @@ static int MpioTest2G( MPI_Comm comm ) */ tot_size_bytes = sizeof(int); for (int i = 0; i < 3; i++) { - tot_size_bytes *= shape[i]; + tot_size_bytes *= shape[i]; } - if(mpi_rank == 0) { - HDprintf("Dataset of %llu bytes\n", tot_size_bytes); + if (mpi_rank == 0) { + HDprintf("Dataset of %llu bytes\n", tot_size_bytes); } filespace = H5Screate_simple(3, shape, NULL); VRFY((filespace >= 0), "H5Screate_simple succeeded"); @@ -621,20 +614,18 @@ static int MpioTest2G( MPI_Comm comm ) /* * Select chunking */ - dcpl_id = H5Pcreate (H5P_DATASET_CREATE); + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((dcpl_id >= 0), "H5P_DATASET_CREATE"); chunk[0] = 4; chunk[1] = shape[1]; chunk[2] = shape[2]; - status = H5Pset_chunk(dcpl_id, 3, chunk); + status = H5Pset_chunk(dcpl_id, 3, chunk); VRFY((status >= 0), "H5Pset_chunk succeeded"); /* * Create the dataset with default properties and close filespace. */ - dset_id = H5Dcreate2(file_id, DATASETNAME, - H5T_NATIVE_INT, filespace, - H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, DATASETNAME, H5T_NATIVE_INT, filespace, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); VRFY((dset_id >= 0), "H5Dcreate2 succeeded"); H5Sclose(filespace); @@ -646,19 +637,20 @@ static int MpioTest2G( MPI_Comm comm ) status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE); VRFY((status >= 0), ""); - H5_CHECKED_ASSIGN(slice_per_process, size_t, (shape[0] + (hsize_t)mpi_size - 1) / (hsize_t)mpi_size, hsize_t); - data_size = slice_per_process * shape[1] * shape[2]; + H5_CHECKED_ASSIGN(slice_per_process, size_t, (shape[0] + (hsize_t)mpi_size - 1) / (hsize_t)mpi_size, + hsize_t); + data_size = slice_per_process * shape[1] * shape[2]; data_size_bytes = sizeof(int) * data_size; - data = HDmalloc(data_size_bytes); + data = HDmalloc(data_size_bytes); VRFY((data != NULL), "data HDmalloc succeeded"); for (size_t i = 0; i < data_size; i++) { data[i] = mpi_rank; } - h5_counts[0] = slice_per_process; - h5_counts[1] = shape[1]; - h5_counts[2] = shape[2]; + h5_counts[0] = slice_per_process; + h5_counts[1] = shape[1]; + h5_counts[2] = shape[2]; h5_offsets[0] = (size_t)mpi_rank * slice_per_process; h5_offsets[1] = 0; h5_offsets[2] = 0; @@ -666,19 +658,17 @@ static int MpioTest2G( MPI_Comm comm ) VRFY((filedataspace >= 0), "H5Screate_simple succeeded"); // fix reminder along first dimension multiple of chunk[0] - if ( h5_offsets[0] + h5_counts[0] > shape[0]) { - h5_counts[0] = shape[0] - h5_offsets[0]; + if (h5_offsets[0] + h5_counts[0] > shape[0]) { + h5_counts[0] = shape[0] - h5_offsets[0]; } - status = H5Sselect_hyperslab(filedataspace, H5S_SELECT_SET, - h5_offsets, NULL, h5_counts, NULL); + status = H5Sselect_hyperslab(filedataspace, H5S_SELECT_SET, h5_offsets, NULL, h5_counts, NULL); VRFY((status >= 0), "H5Sselect_hyperslab succeeded"); memorydataspace = H5Screate_simple(3, h5_counts, NULL); VRFY((memorydataspace >= 0), "H5Screate_simple succeeded"); - status = H5Dwrite(dset_id, H5T_NATIVE_INT, - memorydataspace, filedataspace, plist_id, data); + status = H5Dwrite(dset_id, H5T_NATIVE_INT, memorydataspace, filedataspace, plist_id, data); VRFY((status >= 0), "H5Dwrite succeeded"); H5Pclose(plist_id); @@ -694,11 +684,10 @@ static int MpioTest2G( MPI_Comm comm ) HDprintf("Proc %d - MpioTest2G test succeeded\n", mpi_rank, data_size_bytes); if (mpi_rank == 0) - HDremove(FILENAME[1]); + HDremove(FILENAME[1]); return 0; } - /* * Part 1.a--Independent read/write for fixed dimension datasets. */ @@ -714,35 +703,37 @@ static int MpioTest2G( MPI_Comm comm ) void dataset_writeInd(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t sid; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - hsize_t dims[MAX_RANK] = {1,}; /* dataset dim sizes */ - hsize_t data_size; - DATATYPE *data_array1 = NULL; /* data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t sid; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + hsize_t dims[MAX_RANK] = { + 1, + }; /* dataset dim sizes */ + hsize_t data_size; + DATATYPE * data_array1 = NULL; /* data buffer */ const char *filename; - hsize_t start[MAX_RANK]; /* for hyperslab setting */ + hsize_t start[MAX_RANK]; /* for hyperslab setting */ hsize_t count[MAX_RANK]; - hsize_t stride[MAX_RANK]; /* for hyperslab setting */ - hsize_t block[MAX_RANK]; /* for hyperslab setting */ + hsize_t stride[MAX_RANK]; /* for hyperslab setting */ + hsize_t block[MAX_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = test_comm; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Independent write test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Independent write test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* allocate memory for data buffer */ data_size = sizeof(DATATYPE); @@ -765,7 +756,6 @@ dataset_writeInd(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* --------------------------------------------- * Define the dimensions of the overall datasets * and the slabs local to the MPI process. @@ -773,21 +763,17 @@ dataset_writeInd(void) /* setup dimensionality object */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (MAX_RANK, dims, NULL); + sid = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); - /* create a dataset collectively */ - dataset1 = H5Dcreate2(fid, DATASETNAME1, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset1 = H5Dcreate2(fid, DATASETNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset1 >= 0), "H5Dcreate2 succeeded"); /* create another dataset collectively */ - dataset2 = H5Dcreate2(fid, DATASETNAME2, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset2 = H5Dcreate2(fid, DATASETNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset2 >= 0), "H5Dcreate2 succeeded"); - /* * To test the independent orders of writes between processes, all * even number processes write to dataset1 first, then dataset2. @@ -802,43 +788,40 @@ dataset_writeInd(void) MESG("data_array initialized"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* write data independently */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded"); /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dwrite dataset2 succeeded"); /* setup dimensions again to write with zero rows for process 0 */ - if(VERBOSE_MED) - HDprintf("writeInd by some with zero row\n"); + if (VERBOSE_MED) + HDprintf("writeInd by some with zero row\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZROW); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("writeInd by some with zero row"); -if((mpi_rank/2)*2 != mpi_rank){ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); - VRFY((ret >= 0), "H5Dwrite dataset1 by ZROW succeeded"); -} + if ((mpi_rank / 2) * 2 != mpi_rank) { + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); + VRFY((ret >= 0), "H5Dwrite dataset1 by ZROW succeeded"); + } #ifdef BARRIER_CHECKS -MPI_Barrier(test_comm); + MPI_Barrier(test_comm); #endif /* BARRIER_CHECKS */ /* release dataspace ID */ @@ -857,44 +840,45 @@ MPI_Barrier(test_comm); H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); + if (data_array1) + HDfree(data_array1); } /* Example of using the parallel HDF5 library to read a dataset */ void dataset_readInd(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - DATATYPE *data_array1 = NULL; /* data buffer */ - DATATYPE *data_origin1 = NULL; /* expected data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + DATATYPE * data_array1 = NULL; /* data buffer */ + DATATYPE * data_origin1 = NULL; /* expected data buffer */ const char *filename; - hsize_t start[MAX_RANK]; /* for hyperslab setting */ - hsize_t count[MAX_RANK], stride[MAX_RANK]; /* for hyperslab setting */ - hsize_t block[MAX_RANK]; /* for hyperslab setting */ + hsize_t start[MAX_RANK]; /* for hyperslab setting */ + hsize_t count[MAX_RANK], stride[MAX_RANK]; /* for hyperslab setting */ + hsize_t block[MAX_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = test_comm; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Independent read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Independent read test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 HDmalloc succeeded"); /* setup file access template */ @@ -917,40 +901,39 @@ dataset_readInd(void) dataset2 = H5Dopen2(fid, DATASETNAME1, H5P_DEFAULT); VRFY((dataset2 >= 0), ""); - /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); /* read data independently */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), ""); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* read data independently */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), ""); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* close dataset collectively */ ret = H5Dclose(dataset1); @@ -965,11 +948,12 @@ dataset_readInd(void) H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); - if(data_origin1) HDfree(data_origin1); + if (data_array1) + HDfree(data_array1); + if (data_origin1) + HDfree(data_origin1); } - /* * Part 1.b--Collective read/write for fixed dimension datasets. */ @@ -986,49 +970,51 @@ dataset_readInd(void) void dataset_writeAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t sid; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2, dataset3, dataset4; /* Dataset ID */ - hid_t dataset5, dataset6, dataset7; /* Dataset ID */ - hid_t datatype; /* Datatype ID */ - hsize_t dims[MAX_RANK] = {1,}; /* dataset dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t sid; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2, dataset3, dataset4; /* Dataset ID */ + hid_t dataset5, dataset6, dataset7; /* Dataset ID */ + hid_t datatype; /* Datatype ID */ + hsize_t dims[MAX_RANK] = { + 1, + }; /* dataset dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ const char *filename; - hsize_t start[MAX_RANK]; /* for hyperslab setting */ + hsize_t start[MAX_RANK]; /* for hyperslab setting */ hsize_t count[MAX_RANK]; - hsize_t stride[MAX_RANK]; /* for hyperslab setting */ - hsize_t block[MAX_RANK]; /* for hyperslab setting */ + hsize_t stride[MAX_RANK]; /* for hyperslab setting */ + hsize_t block[MAX_RANK]; /* for hyperslab setting */ - size_t num_points; /* for point selection */ - hsize_t *coords = NULL; /* for point selection */ - hsize_t current_dims; /* for point selection */ + size_t num_points; /* for point selection */ + hsize_t *coords = NULL; /* for point selection */ + hsize_t current_dims; /* for point selection */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = test_comm; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Collective write test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Collective write test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* set up the coords array selection */ num_points = (size_t)dim1; - coords = (hsize_t *)HDmalloc((size_t)dim1 * (size_t)MAX_RANK * sizeof(hsize_t)); + coords = (hsize_t *)HDmalloc((size_t)dim1 * (size_t)MAX_RANK * sizeof(hsize_t)); VRFY((coords != NULL), "coords malloc succeeded"); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); /* ------------------- @@ -1046,7 +1032,6 @@ dataset_writeAll(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* -------------------------- * Define the dimensions of the overall datasets * and create the dataset @@ -1054,17 +1039,16 @@ dataset_writeAll(void) /* setup 2-D dimensionality object */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (MAX_RANK, dims, NULL); + sid = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); - /* create a dataset collectively */ dataset1 = H5Dcreate2(fid, DATASETNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset1 >= 0), "H5Dcreate2 succeeded"); /* create another dataset collectively */ datatype = H5Tcopy(H5T_NATIVE_INT); - ret = H5Tset_order(datatype, H5T_ORDER_LE); + ret = H5Tset_order(datatype, H5T_ORDER_LE); VRFY((ret >= 0), "H5Tset_order succeeded"); dataset2 = H5Dcreate2(fid, DATASETNAME2, datatype, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -1103,54 +1087,51 @@ dataset_writeAll(void) slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill the local slab with some trivial data */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* write data collectively */ MESG("writeAll by Row"); - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded"); /* setup dimensions again to writeAll with zero rows for process 0 */ - if(VERBOSE_MED) - HDprintf("writeAll by some with zero row\n"); + if (VERBOSE_MED) + HDprintf("writeAll by some with zero row\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZROW); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("writeAll by some with zero row"); - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset1 by ZROW succeeded"); /* release all temporary handles. */ @@ -1166,59 +1147,56 @@ dataset_writeAll(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill the local slab with some trivial data */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset2 succeeded"); /* setup dimensions again to writeAll with zero columns for process 0 */ - if(VERBOSE_MED) - HDprintf("writeAll by some with zero col\n"); + if (VERBOSE_MED) + HDprintf("writeAll by some with zero col\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZCOL); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("writeAll by some with zero col"); - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset1 by ZCOL succeeded"); /* release all temporary handles. */ @@ -1228,16 +1206,15 @@ dataset_writeAll(void) H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - /* Dataset3: each process takes a block of rows, except process zero uses "none" selection. */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset3); + file_dataspace = H5Dget_space(dataset3); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); - if(MAINPROCESS) { - ret = H5Sselect_none(file_dataspace); - VRFY((ret >= 0), "H5Sselect_none file_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_none(file_dataspace); + VRFY((ret >= 0), "H5Sselect_none file_dataspace succeeded"); } /* end if */ else { ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); @@ -1245,42 +1222,39 @@ dataset_writeAll(void) } /* end else */ /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); - if(MAINPROCESS) { - ret = H5Sselect_none(mem_dataspace); - VRFY((ret >= 0), "H5Sselect_none mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_none(mem_dataspace); + VRFY((ret >= 0), "H5Sselect_none mem_dataspace succeeded"); } /* end if */ /* fill the local slab with some trivial data */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED) { - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* end if */ /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* write data collectively */ MESG("writeAll with none"); - ret = H5Dwrite(dataset3, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset3, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset3 succeeded"); /* write data collectively (with datatype conversion) */ MESG("writeAll with none"); - ret = H5Dwrite(dataset3, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset3, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset3 succeeded"); /* release all temporary handles. */ @@ -1294,11 +1268,11 @@ dataset_writeAll(void) /* Additionally, these are in a scalar dataspace */ /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset4); + file_dataspace = H5Dget_space(dataset4); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); - if(MAINPROCESS) { - ret = H5Sselect_none(file_dataspace); - VRFY((ret >= 0), "H5Sselect_all file_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_none(file_dataspace); + VRFY((ret >= 0), "H5Sselect_all file_dataspace succeeded"); } /* end if */ else { ret = H5Sselect_all(file_dataspace); @@ -1308,9 +1282,9 @@ dataset_writeAll(void) /* create a memory dataspace independently */ mem_dataspace = H5Screate(H5S_SCALAR); VRFY((mem_dataspace >= 0), ""); - if(MAINPROCESS) { - ret = H5Sselect_none(mem_dataspace); - VRFY((ret >= 0), "H5Sselect_all mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_none(mem_dataspace); + VRFY((ret >= 0), "H5Sselect_all mem_dataspace succeeded"); } /* end if */ else { ret = H5Sselect_all(mem_dataspace); @@ -1320,31 +1294,29 @@ dataset_writeAll(void) /* fill the local slab with some trivial data */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED) { - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* end if */ /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* write data collectively */ MESG("writeAll with scalar dataspace"); - ret = H5Dwrite(dataset4, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset4, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset4 succeeded"); /* write data collectively (with datatype conversion) */ MESG("writeAll with scalar dataspace"); - ret = H5Dwrite(dataset4, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset4, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset4 succeeded"); /* release all temporary handles. */ @@ -1352,55 +1324,54 @@ dataset_writeAll(void) H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - - if(data_array1) free(data_array1); - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + if (data_array1) + free(data_array1); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); - block[0] = 1; - block[1] = (hsize_t)dim1; + block[0] = 1; + block[1] = (hsize_t)dim1; stride[0] = 1; stride[1] = (hsize_t)dim1; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)dim0/(hsize_t)mpi_size * (hsize_t)mpi_rank; - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; + start[1] = 0; dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* Dataset5: point selection in File - Hyperslab selection in Memory*/ /* create a file dataspace independently */ - point_set (start, count, stride, block, num_points, coords, OUT_OF_ORDER); - file_dataspace = H5Dget_space (dataset5); + point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + file_dataspace = H5Dget_space(dataset5); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); - start[0] = 0; - start[1] = 0; - mem_dataspace = H5Dget_space (dataset5); + start[0] = 0; + start[1] = 0; + mem_dataspace = H5Dget_space(dataset5); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* write data collectively */ - ret = H5Dwrite(dataset5, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset5, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset5 succeeded"); /* release all temporary handles. */ @@ -1410,35 +1381,34 @@ dataset_writeAll(void) /* Dataset6: point selection in File - Point selection in Memory*/ /* create a file dataspace independently */ - start[0] = (hsize_t)dim0/(hsize_t)mpi_size * (hsize_t)mpi_rank; + start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, OUT_OF_ORDER); - file_dataspace = H5Dget_space (dataset6); + point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + file_dataspace = H5Dget_space(dataset6); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); start[0] = 0; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, IN_ORDER); - mem_dataspace = H5Dget_space (dataset6); + point_set(start, count, stride, block, num_points, coords, IN_ORDER); + mem_dataspace = H5Dget_space(dataset6); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* write data collectively */ - ret = H5Dwrite(dataset6, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset6, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset6 succeeded"); /* release all temporary handles. */ @@ -1448,34 +1418,33 @@ dataset_writeAll(void) /* Dataset7: point selection in File - All selection in Memory*/ /* create a file dataspace independently */ - start[0] = (hsize_t)dim0/(hsize_t)mpi_size * (hsize_t)mpi_rank; + start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, IN_ORDER); - file_dataspace = H5Dget_space (dataset7); + point_set(start, count, stride, block, num_points, coords, IN_ORDER); + file_dataspace = H5Dget_space(dataset7); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); - current_dims = num_points; - mem_dataspace = H5Screate_simple (1, ¤t_dims, NULL); + current_dims = num_points; + mem_dataspace = H5Screate_simple(1, ¤t_dims, NULL); VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); ret = H5Sselect_all(mem_dataspace); VRFY((ret >= 0), "H5Sselect_all succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* write data collectively */ - ret = H5Dwrite(dataset7, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset7, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset7 succeeded"); /* release all temporary handles. */ @@ -1505,8 +1474,10 @@ dataset_writeAll(void) H5Fclose(fid); /* release data buffers */ - if(coords) HDfree(coords); - if(data_array1) HDfree(data_array1); + if (coords) + HDfree(coords); + if (data_array1) + HDfree(data_array1); } /* @@ -1521,47 +1492,47 @@ dataset_writeAll(void) void dataset_readAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2, dataset5, dataset6, dataset7; /* Dataset ID */ - DATATYPE *data_array1 = NULL; /* data buffer */ - DATATYPE *data_origin1 = NULL; /* expected data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2, dataset5, dataset6, dataset7; /* Dataset ID */ + DATATYPE * data_array1 = NULL; /* data buffer */ + DATATYPE * data_origin1 = NULL; /* expected data buffer */ const char *filename; - hsize_t start[MAX_RANK]; /* for hyperslab setting */ - hsize_t count[MAX_RANK], stride[MAX_RANK]; /* for hyperslab setting */ - hsize_t block[MAX_RANK]; /* for hyperslab setting */ + hsize_t start[MAX_RANK]; /* for hyperslab setting */ + hsize_t count[MAX_RANK], stride[MAX_RANK]; /* for hyperslab setting */ + hsize_t block[MAX_RANK]; /* for hyperslab setting */ - size_t num_points; /* for point selection */ - hsize_t *coords = NULL; /* for point selection */ - int i,j,k; + size_t num_points; /* for point selection */ + hsize_t *coords = NULL; /* for point selection */ + int i, j, k; - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = test_comm; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Collective read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Collective read test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* set up the coords array selection */ num_points = (size_t)dim1; - coords = (hsize_t *)HDmalloc((size_t)dim0 * (size_t)dim1 * MAX_RANK * sizeof(hsize_t)); + coords = (hsize_t *)HDmalloc((size_t)dim0 * (size_t)dim1 * MAX_RANK * sizeof(hsize_t)); VRFY((coords != NULL), "coords malloc succeeded"); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 HDmalloc succeeded"); /* ------------------- @@ -1572,14 +1543,13 @@ dataset_readAll(void) VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); VRFY((fid >= 0), "H5Fopen succeeded"); /* Release file-access template */ ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* -------------------------- * Open the datasets in it * ------------------------- */ @@ -1607,62 +1577,61 @@ dataset_readAll(void) slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_origin1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_origin1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* read data collectively */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset1 succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* setup dimensions again to readAll with zero columns for process 0 */ - if(VERBOSE_MED) - HDprintf("readAll by some with zero col\n"); + if (VERBOSE_MED) + HDprintf("readAll by some with zero col\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZCOL); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("readAll by some with zero col"); - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset1 by ZCOL succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* release all temporary handles. */ /* Could have used them for dataset2 but it is cleaner */ @@ -1675,218 +1644,221 @@ dataset_readAll(void) slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_origin1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_origin1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* read data collectively */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset2 succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* setup dimensions again to readAll with zero rows for process 0 */ - if(VERBOSE_MED) - HDprintf("readAll by some with zero row\n"); + if (VERBOSE_MED) + HDprintf("readAll by some with zero row\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZROW); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("readAll by some with zero row"); - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset1 by ZROW succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - if(data_array1) free(data_array1); - if(data_origin1) free(data_origin1); - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + if (data_array1) + free(data_array1); + if (data_origin1) + free(data_origin1); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 malloc succeeded"); - block[0] = 1; - block[1] = (hsize_t)dim1; + block[0] = 1; + block[1] = (hsize_t)dim1; stride[0] = 1; stride[1] = (hsize_t)dim1; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)dim0/(hsize_t)mpi_size * (hsize_t)mpi_rank; - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; + start[1] = 0; dataset_fill(start, block, data_origin1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_origin1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_origin1); } /* Dataset5: point selection in memory - Hyperslab selection in file*/ /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset5); + file_dataspace = H5Dget_space(dataset5); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); start[0] = 0; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, OUT_OF_ORDER); - mem_dataspace = H5Dget_space (dataset5); + point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + mem_dataspace = H5Dget_space(dataset5); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset5, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset5, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset5 succeeded"); - ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - if(data_array1) free(data_array1); - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + if (data_array1) + free(data_array1); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); /* Dataset6: point selection in File - Point selection in Memory*/ /* create a file dataspace independently */ - start[0] = (hsize_t)dim0/(hsize_t)mpi_size * (hsize_t)mpi_rank; + start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, IN_ORDER); - file_dataspace = H5Dget_space (dataset6); + point_set(start, count, stride, block, num_points, coords, IN_ORDER); + file_dataspace = H5Dget_space(dataset6); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); start[0] = 0; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, OUT_OF_ORDER); - mem_dataspace = H5Dget_space (dataset6); + point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + mem_dataspace = H5Dget_space(dataset6); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset6, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset6, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset6 succeeded"); ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - if(data_array1) free(data_array1); - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + if (data_array1) + free(data_array1); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); /* Dataset7: point selection in memory - All selection in file*/ /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset7); + file_dataspace = H5Dget_space(dataset7); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_all(file_dataspace); VRFY((ret >= 0), "H5Sselect_all succeeded"); num_points = (size_t)dim0 * (size_t)dim1; - k=0; - for (i=0 ; i= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset7, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset7, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset7 succeeded"); - start[0] = (hsize_t)dim0/(hsize_t)mpi_size * (hsize_t)mpi_rank; + start[0] = (hsize_t)dim0 / (hsize_t)mpi_size * (hsize_t)mpi_rank; start[1] = 0; - ret = dataset_vrfy(start, count, stride, block, data_array1+(dim0/mpi_size * dim1 * mpi_rank), data_origin1); - if(ret) nerrors++; + ret = dataset_vrfy(start, count, stride, block, data_array1 + (dim0 / mpi_size * dim1 * mpi_rank), + data_origin1); + if (ret) + nerrors++; /* release all temporary handles. */ H5Sclose(file_dataspace); @@ -1911,12 +1883,14 @@ dataset_readAll(void) H5Fclose(fid); /* release data buffers */ - if(coords) HDfree(coords); - if(data_array1) HDfree(data_array1); - if(data_origin1) HDfree(data_origin1); + if (coords) + HDfree(coords); + if (data_array1) + HDfree(data_array1); + if (data_origin1) + HDfree(data_origin1); } - /* * Part 2--Independent read/write for extendible datasets. */ @@ -1932,45 +1906,44 @@ dataset_readAll(void) void extend_writeInd(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t sid; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t sid; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ const char *filename; - hsize_t dims[MAX_RANK]; /* dataset dim sizes */ - hsize_t max_dims[MAX_RANK] = - {H5S_UNLIMITED, H5S_UNLIMITED}; /* dataset maximum dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ - hsize_t chunk_dims[MAX_RANK]; /* chunk sizes */ - hid_t dataset_pl; /* dataset create prop. list */ + hsize_t dims[MAX_RANK]; /* dataset dim sizes */ + hsize_t max_dims[MAX_RANK] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dataset maximum dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ + hsize_t chunk_dims[MAX_RANK]; /* chunk sizes */ + hid_t dataset_pl; /* dataset create prop. list */ - hsize_t start[MAX_RANK]; /* for hyperslab setting */ - hsize_t count[MAX_RANK]; /* for hyperslab setting */ - hsize_t stride[MAX_RANK]; /* for hyperslab setting */ - hsize_t block[MAX_RANK]; /* for hyperslab setting */ + hsize_t start[MAX_RANK]; /* for hyperslab setting */ + hsize_t count[MAX_RANK]; /* for hyperslab setting */ + hsize_t stride[MAX_RANK]; /* for hyperslab setting */ + hsize_t block[MAX_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = test_comm; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent write test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent write test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* setup chunk-size. Make sure sizes are > 0 */ chunk_dims[0] = (hsize_t)chunkdim0; chunk_dims[1] = (hsize_t)chunkdim1; /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); /* ------------------- @@ -1980,22 +1953,22 @@ extend_writeInd(void) acc_tpl = create_faccess_plist(comm, info, facc_type); VRFY((acc_tpl >= 0), ""); -/* Reduce the number of metadata cache slots, so that there are cache - * collisions during the raw data I/O on the chunked dataset. This stresses - * the metadata cache and tests for cache bugs. -QAK - */ -{ - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - - ret = H5Pget_cache(acc_tpl,&mdc_nelmts,&rdcc_nelmts,&rdcc_nbytes,&rdcc_w0); - VRFY((ret >= 0), "H5Pget_cache succeeded"); - mdc_nelmts=4; - ret = H5Pset_cache(acc_tpl,mdc_nelmts,rdcc_nelmts,rdcc_nbytes,rdcc_w0); - VRFY((ret >= 0), "H5Pset_cache succeeded"); -} + /* Reduce the number of metadata cache slots, so that there are cache + * collisions during the raw data I/O on the chunked dataset. This stresses + * the metadata cache and tests for cache bugs. -QAK + */ + { + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + + ret = H5Pget_cache(acc_tpl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0); + VRFY((ret >= 0), "H5Pget_cache succeeded"); + mdc_nelmts = 4; + ret = H5Pset_cache(acc_tpl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0); + VRFY((ret >= 0), "H5Pset_cache succeeded"); + } /* create the file collectively */ fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); @@ -2005,14 +1978,13 @@ extend_writeInd(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* -------------------------------------------------------------- * Define the dimensions of the overall datasets and create them. * ------------------------------------------------------------- */ /* set up dataset storage chunk sizes and creation property list */ - if(VERBOSE_MED) - HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); + if (VERBOSE_MED) + HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); dataset_pl = H5Pcreate(H5P_DATASET_CREATE); VRFY((dataset_pl >= 0), "H5Pcreate succeeded"); ret = H5Pset_chunk(dataset_pl, MAX_RANK, chunk_dims); @@ -2021,7 +1993,7 @@ extend_writeInd(void) /* setup dimensionality object */ /* start out with no rows, extend it later. */ dims[0] = dims[1] = 0; - sid = H5Screate_simple (MAX_RANK, dims, max_dims); + sid = H5Screate_simple(MAX_RANK, dims, max_dims); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* create an extendible dataset collectively */ @@ -2036,8 +2008,6 @@ extend_writeInd(void) H5Sclose(sid); H5Pclose(dataset_pl); - - /* ------------------------- * Test writing to dataset1 * -------------------------*/ @@ -2047,37 +2017,35 @@ extend_writeInd(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED) { - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* Extend its current dim sizes before writing */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - ret = H5Dset_extent(dataset1, dims); + ret = H5Dset_extent(dataset1, dims); VRFY((ret >= 0), "H5Dset_extent succeeded"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release resource */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); - /* ------------------------- * Test writing to dataset2 * -------------------------*/ @@ -2087,13 +2055,13 @@ extend_writeInd(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* Try write to dataset2 beyond its current dim sizes. Should fail. */ @@ -2102,14 +2070,13 @@ extend_writeInd(void) H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently. Should fail. */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret < 0), "H5Dwrite failed as expected"); /* restore auto error reporting */ @@ -2119,18 +2086,17 @@ extend_writeInd(void) /* Extend dataset2 and try again. Should succeed. */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - ret = H5Dset_extent(dataset2, dims); + ret = H5Dset_extent(dataset2, dims); VRFY((ret >= 0), "H5Dset_extent succeeded"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release resource */ @@ -2139,7 +2105,6 @@ extend_writeInd(void) ret = H5Sclose(mem_dataspace); VRFY((ret >= 0), "H5Sclose succeeded"); - /* close dataset collectively */ ret = H5Dclose(dataset1); VRFY((ret >= 0), "H5Dclose1 succeeded"); @@ -2150,7 +2115,8 @@ extend_writeInd(void) H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); + if (data_array1) + HDfree(data_array1); } /* @@ -2163,30 +2129,30 @@ void extend_writeInd2(void) { const char *filename; - hid_t fid; /* HDF5 file ID */ - hid_t fapl_id; /* File access templates */ - hid_t fs; /* File dataspace ID */ - hid_t ms; /* Memory dataspace ID */ - hid_t dataset; /* Dataset ID */ - hsize_t orig_size=10; /* Original dataset dim size */ - hsize_t new_size=20; /* Extended dataset dim size */ - hsize_t one=1; - hsize_t max_size = H5S_UNLIMITED; /* dataset maximum dim size */ - hsize_t chunk_size = 16384; /* chunk size */ - hid_t dcpl; /* dataset create prop. list */ - int written[10], /* Data to write */ - retrieved[10]; /* Data read in */ - int mpi_size, mpi_rank; /* MPI settings */ - int i; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 file ID */ + hid_t fapl_id; /* File access templates */ + hid_t fs; /* File dataspace ID */ + hid_t ms; /* Memory dataspace ID */ + hid_t dataset; /* Dataset ID */ + hsize_t orig_size = 10; /* Original dataset dim size */ + hsize_t new_size = 20; /* Extended dataset dim size */ + hsize_t one = 1; + hsize_t max_size = H5S_UNLIMITED; /* dataset maximum dim size */ + hsize_t chunk_size = 16384; /* chunk size */ + hid_t dcpl; /* dataset create prop. list */ + int written[10], /* Data to write */ + retrieved[10]; /* Data read in */ + int mpi_size, mpi_rank; /* MPI settings */ + int i; /* Local index variable */ + herr_t ret; /* Generic return value */ filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent write test #2 on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent write test #2 on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* ------------------- * START AN HDF5 FILE @@ -2203,7 +2169,6 @@ extend_writeInd2(void) ret = H5Pclose(fapl_id); VRFY((ret >= 0), "H5Pclose succeeded"); - /* -------------------------------------------------------------- * Define the dimensions of the overall datasets and create them. * ------------------------------------------------------------- */ @@ -2215,7 +2180,7 @@ extend_writeInd2(void) VRFY((ret >= 0), "H5Pset_chunk succeeded"); /* setup dimensionality object */ - fs = H5Screate_simple (1, &orig_size, &max_size); + fs = H5Screate_simple(1, &orig_size, &max_size); VRFY((fs >= 0), "H5Screate_simple succeeded"); /* create an extendible dataset collectively */ @@ -2226,7 +2191,6 @@ extend_writeInd2(void) ret = H5Pclose(dcpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /* ------------------------- * Test writing to dataset * -------------------------*/ @@ -2235,13 +2199,13 @@ extend_writeInd2(void) VRFY((ms >= 0), "H5Screate_simple succeeded"); /* put some trivial data in the data_array */ - for(i = 0; i < (int)orig_size; i++) + for (i = 0; i < (int)orig_size; i++) written[i] = i; MESG("data array initialized"); - if(VERBOSE_MED) { - MESG("writing at offset zero: "); - for(i = 0; i < (int)orig_size; i++) - HDprintf("%s%d", i?", ":"", written[i]); + if (VERBOSE_MED) { + MESG("writing at offset zero: "); + for (i = 0; i < (int)orig_size; i++) + HDprintf("%s%d", i ? ", " : "", written[i]); HDprintf("\n"); } ret = H5Dwrite(dataset, H5T_NATIVE_INT, ms, fs, H5P_DEFAULT, written); @@ -2252,16 +2216,16 @@ extend_writeInd2(void) * -------------------------*/ ret = H5Dread(dataset, H5T_NATIVE_INT, ms, fs, H5P_DEFAULT, retrieved); VRFY((ret >= 0), "H5Dread succeeded"); - for (i=0; i<(int)orig_size; i++) - if(written[i]!=retrieved[i]) { - HDprintf("Line #%d: written!=retrieved: written[%d]=%d, retrieved[%d]=%d\n",__LINE__, - i,written[i], i,retrieved[i]); + for (i = 0; i < (int)orig_size; i++) + if (written[i] != retrieved[i]) { + HDprintf("Line #%d: written!=retrieved: written[%d]=%d, retrieved[%d]=%d\n", __LINE__, i, + written[i], i, retrieved[i]); nerrors++; } - if(VERBOSE_MED){ - MESG("read at offset zero: "); - for (i=0; i<(int)orig_size; i++) - HDprintf("%s%d", i?", ":"", retrieved[i]); + if (VERBOSE_MED) { + MESG("read at offset zero: "); + for (i = 0; i < (int)orig_size; i++) + HDprintf("%s%d", i ? ", " : "", retrieved[i]); HDprintf("\n"); } @@ -2278,13 +2242,13 @@ extend_writeInd2(void) /* ------------------------- * Write to the second half of the dataset * -------------------------*/ - for (i=0; i<(int)orig_size; i++) + for (i = 0; i < (int)orig_size; i++) H5_CHECKED_ASSIGN(written[i], int, orig_size + (hsize_t)i, hsize_t); MESG("data array re-initialized"); - if(VERBOSE_MED) { - MESG("writing at offset 10: "); - for (i=0; i<(int)orig_size; i++) - HDprintf("%s%d", i?", ":"", written[i]); + if (VERBOSE_MED) { + MESG("writing at offset 10: "); + for (i = 0; i < (int)orig_size; i++) + HDprintf("%s%d", i ? ", " : "", written[i]); HDprintf("\n"); } ret = H5Sselect_hyperslab(fs, H5S_SELECT_SET, &orig_size, NULL, &one, &orig_size); @@ -2297,20 +2261,19 @@ extend_writeInd2(void) * -------------------------*/ ret = H5Dread(dataset, H5T_NATIVE_INT, ms, fs, H5P_DEFAULT, retrieved); VRFY((ret >= 0), "H5Dread succeeded"); - for (i=0; i<(int)orig_size; i++) - if(written[i]!=retrieved[i]) { - HDprintf("Line #%d: written!=retrieved: written[%d]=%d, retrieved[%d]=%d\n",__LINE__, - i,written[i], i,retrieved[i]); + for (i = 0; i < (int)orig_size; i++) + if (written[i] != retrieved[i]) { + HDprintf("Line #%d: written!=retrieved: written[%d]=%d, retrieved[%d]=%d\n", __LINE__, i, + written[i], i, retrieved[i]); nerrors++; } - if(VERBOSE_MED){ - MESG("read at offset 10: "); - for (i=0; i<(int)orig_size; i++) - HDprintf("%s%d", i?", ":"", retrieved[i]); + if (VERBOSE_MED) { + MESG("read at offset 10: "); + for (i = 0; i < (int)orig_size; i++) + HDprintf("%s%d", i ? ", " : "", retrieved[i]); HDprintf("\n"); } - /* Close dataset collectively */ ret = H5Dclose(dataset); VRFY((ret >= 0), "H5Dclose succeeded"); @@ -2324,41 +2287,41 @@ extend_writeInd2(void) void extend_readInd(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - hsize_t dims[MAX_RANK]; /* dataset dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ - DATATYPE *data_array2 = NULL; /* data buffer */ - DATATYPE *data_origin1 = NULL; /* expected data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + hsize_t dims[MAX_RANK]; /* dataset dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ + DATATYPE * data_array2 = NULL; /* data buffer */ + DATATYPE * data_origin1 = NULL; /* expected data buffer */ const char *filename; - hsize_t start[MAX_RANK]; /* for hyperslab setting */ - hsize_t count[MAX_RANK], stride[MAX_RANK]; /* for hyperslab setting */ - hsize_t block[MAX_RANK]; /* for hyperslab setting */ + hsize_t start[MAX_RANK]; /* for hyperslab setting */ + hsize_t count[MAX_RANK], stride[MAX_RANK]; /* for hyperslab setting */ + hsize_t block[MAX_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = test_comm; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent read test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); - data_array2 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array2 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array2 != NULL), "data_array2 HDmalloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 HDmalloc succeeded"); /* ------------------- @@ -2369,7 +2332,7 @@ extend_readInd(void) VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); VRFY((fid >= 0), ""); /* Release file-access template */ @@ -2389,7 +2352,7 @@ extend_readInd(void) H5Eget_auto2(H5E_DEFAULT, &old_func, &old_client_data); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sget_simple_extent_dims(file_dataspace, dims, NULL); VRFY((ret > 0), "H5Sget_simple_extent_dims succeeded"); @@ -2401,72 +2364,70 @@ extend_readInd(void) H5Eset_auto2(H5E_DEFAULT, old_func, old_client_data); H5Sclose(file_dataspace); - /* Read dataset1 using BYROW pattern */ /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* read data independently */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dread succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); VRFY((ret == 0), "dataset1 read verified correct"); - if(ret) nerrors++; + if (ret) + nerrors++; H5Sclose(mem_dataspace); H5Sclose(file_dataspace); - /* Read dataset2 using BYCOL pattern */ /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* read data independently */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dread succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); VRFY((ret == 0), "dataset2 read verified correct"); - if(ret) nerrors++; + if (ret) + nerrors++; H5Sclose(mem_dataspace); H5Sclose(file_dataspace); @@ -2477,14 +2438,16 @@ extend_readInd(void) ret = H5Dclose(dataset2); VRFY((ret >= 0), ""); - /* close the file collectively */ H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); - if(data_array2) HDfree(data_array2); - if(data_origin1) HDfree(data_origin1); + if (data_array1) + HDfree(data_array1); + if (data_array2) + HDfree(data_array2); + if (data_origin1) + HDfree(data_origin1); } /* @@ -2502,46 +2465,45 @@ extend_readInd(void) void extend_writeAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t sid; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t sid; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ const char *filename; - hsize_t dims[MAX_RANK]; /* dataset dim sizes */ - hsize_t max_dims[MAX_RANK] = - {H5S_UNLIMITED, H5S_UNLIMITED}; /* dataset maximum dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ - hsize_t chunk_dims[MAX_RANK]; /* chunk sizes */ - hid_t dataset_pl; /* dataset create prop. list */ + hsize_t dims[MAX_RANK]; /* dataset dim sizes */ + hsize_t max_dims[MAX_RANK] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dataset maximum dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ + hsize_t chunk_dims[MAX_RANK]; /* chunk sizes */ + hid_t dataset_pl; /* dataset create prop. list */ - hsize_t start[MAX_RANK]; /* for hyperslab setting */ - hsize_t count[MAX_RANK]; /* for hyperslab setting */ - hsize_t stride[MAX_RANK]; /* for hyperslab setting */ - hsize_t block[MAX_RANK]; /* for hyperslab setting */ + hsize_t start[MAX_RANK]; /* for hyperslab setting */ + hsize_t count[MAX_RANK]; /* for hyperslab setting */ + hsize_t stride[MAX_RANK]; /* for hyperslab setting */ + hsize_t block[MAX_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = test_comm; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent write test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent write test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* setup chunk-size. Make sure sizes are > 0 */ chunk_dims[0] = (hsize_t)chunkdim0; chunk_dims[1] = (hsize_t)chunkdim1; /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); /* ------------------- @@ -2551,22 +2513,22 @@ extend_writeAll(void) acc_tpl = create_faccess_plist(comm, info, facc_type); VRFY((acc_tpl >= 0), ""); -/* Reduce the number of metadata cache slots, so that there are cache - * collisions during the raw data I/O on the chunked dataset. This stresses - * the metadata cache and tests for cache bugs. -QAK - */ -{ - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - - ret = H5Pget_cache(acc_tpl,&mdc_nelmts,&rdcc_nelmts,&rdcc_nbytes,&rdcc_w0); - VRFY((ret >= 0), "H5Pget_cache succeeded"); - mdc_nelmts=4; - ret = H5Pset_cache(acc_tpl,mdc_nelmts,rdcc_nelmts,rdcc_nbytes,rdcc_w0); - VRFY((ret >= 0), "H5Pset_cache succeeded"); -} + /* Reduce the number of metadata cache slots, so that there are cache + * collisions during the raw data I/O on the chunked dataset. This stresses + * the metadata cache and tests for cache bugs. -QAK + */ + { + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + + ret = H5Pget_cache(acc_tpl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0); + VRFY((ret >= 0), "H5Pget_cache succeeded"); + mdc_nelmts = 4; + ret = H5Pset_cache(acc_tpl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0); + VRFY((ret >= 0), "H5Pset_cache succeeded"); + } /* create the file collectively */ fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); @@ -2576,14 +2538,13 @@ extend_writeAll(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* -------------------------------------------------------------- * Define the dimensions of the overall datasets and create them. * ------------------------------------------------------------- */ /* set up dataset storage chunk sizes and creation property list */ - if(VERBOSE_MED) - HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); + if (VERBOSE_MED) + HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); dataset_pl = H5Pcreate(H5P_DATASET_CREATE); VRFY((dataset_pl >= 0), "H5Pcreate succeeded"); ret = H5Pset_chunk(dataset_pl, MAX_RANK, chunk_dims); @@ -2592,7 +2553,7 @@ extend_writeAll(void) /* setup dimensionality object */ /* start out with no rows, extend it later. */ dims[0] = dims[1] = 0; - sid = H5Screate_simple (MAX_RANK, dims, max_dims); + sid = H5Screate_simple(MAX_RANK, dims, max_dims); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* create an extendible dataset collectively */ @@ -2607,8 +2568,6 @@ extend_writeAll(void) H5Sclose(sid); H5Pclose(dataset_pl); - - /* ------------------------- * Test writing to dataset1 * -------------------------*/ @@ -2618,41 +2577,39 @@ extend_writeAll(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED) { - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* Extend its current dim sizes before writing */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - ret = H5Dset_extent(dataset1, dims); + ret = H5Dset_extent(dataset1, dims); VRFY((ret >= 0), "H5Dset_extent succeeded"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* write data collectively */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release resource */ @@ -2660,7 +2617,6 @@ extend_writeAll(void) H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - /* ------------------------- * Test writing to dataset2 * -------------------------*/ @@ -2670,40 +2626,38 @@ extend_writeAll(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* Try write to dataset2 beyond its current dim sizes. Should fail. */ /* Temporary turn off auto error reporting */ H5Eget_auto2(H5E_DEFAULT, &old_func, &old_client_data); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently. Should fail. */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret < 0), "H5Dwrite failed as expected"); /* restore auto error reporting */ @@ -2713,18 +2667,17 @@ extend_writeAll(void) /* Extend dataset2 and try again. Should succeed. */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - ret = H5Dset_extent(dataset2, dims); + ret = H5Dset_extent(dataset2, dims); VRFY((ret >= 0), "H5Dset_extent succeeded"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release resource */ @@ -2735,7 +2688,6 @@ extend_writeAll(void) ret = H5Pclose(xfer_plist); VRFY((ret >= 0), "H5Pclose succeeded"); - /* close dataset collectively */ ret = H5Dclose(dataset1); VRFY((ret >= 0), "H5Dclose1 succeeded"); @@ -2746,49 +2698,50 @@ extend_writeAll(void) H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); + if (data_array1) + HDfree(data_array1); } /* Example of using the parallel HDF5 library to read an extendible dataset */ void extend_readAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ const char *filename; - hsize_t dims[MAX_RANK]; /* dataset dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ - DATATYPE *data_array2 = NULL; /* data buffer */ - DATATYPE *data_origin1 = NULL; /* expected data buffer */ + hsize_t dims[MAX_RANK]; /* dataset dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ + DATATYPE * data_array2 = NULL; /* data buffer */ + DATATYPE * data_origin1 = NULL; /* expected data buffer */ - hsize_t start[MAX_RANK]; /* for hyperslab setting */ - hsize_t count[MAX_RANK], stride[MAX_RANK]; /* for hyperslab setting */ - hsize_t block[MAX_RANK]; /* for hyperslab setting */ + hsize_t start[MAX_RANK]; /* for hyperslab setting */ + hsize_t count[MAX_RANK], stride[MAX_RANK]; /* for hyperslab setting */ + hsize_t block[MAX_RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = test_comm; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent read test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); - data_array2 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array2 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array2 != NULL), "data_array2 HDmalloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 HDmalloc succeeded"); /* ------------------- @@ -2799,7 +2752,7 @@ extend_readAll(void) VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); VRFY((fid >= 0), ""); /* Release file-access template */ @@ -2819,7 +2772,7 @@ extend_readAll(void) H5Eget_auto2(H5E_DEFAULT, &old_func, &old_client_data); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sget_simple_extent_dims(file_dataspace, dims, NULL); VRFY((ret > 0), "H5Sget_simple_extent_dims succeeded"); @@ -2831,95 +2784,91 @@ extend_readAll(void) H5Eset_auto2(H5E_DEFAULT, old_func, old_client_data); H5Sclose(file_dataspace); - /* Read dataset1 using BYROW pattern */ /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* read data collectively */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); VRFY((ret == 0), "dataset1 read verified correct"); - if(ret) nerrors++; + if (ret) + nerrors++; H5Sclose(mem_dataspace); H5Sclose(file_dataspace); H5Pclose(xfer_plist); - /* Read dataset2 using BYCOL pattern */ /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* read data collectively */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); VRFY((ret == 0), "dataset2 read verified correct"); - if(ret) nerrors++; + if (ret) + nerrors++; H5Sclose(mem_dataspace); H5Sclose(file_dataspace); @@ -2931,14 +2880,16 @@ extend_readAll(void) ret = H5Dclose(dataset2); VRFY((ret >= 0), ""); - /* close the file collectively */ H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); - if(data_array2) HDfree(data_array2); - if(data_origin1) HDfree(data_origin1); + if (data_array1) + HDfree(data_array1); + if (data_array2) + HDfree(data_array2); + if (data_origin1) + HDfree(data_origin1); } /* @@ -2949,49 +2900,49 @@ extend_readAll(void) void compress_readAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t dcpl; /* Dataset creation property list */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t dataspace; /* Dataspace ID */ - hid_t dataset; /* Dataset ID */ - int rank=1; /* Dataspace rank */ - hsize_t dim=(hsize_t)dim0; /* Dataspace dimensions */ - unsigned u; /* Local index variable */ - unsigned chunk_opts; /* Chunk options */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t dcpl; /* Dataset creation property list */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t dataspace; /* Dataspace ID */ + hid_t dataset; /* Dataset ID */ + int rank = 1; /* Dataspace rank */ + hsize_t dim = (hsize_t)dim0; /* Dataspace dimensions */ + unsigned u; /* Local index variable */ + unsigned chunk_opts; /* Chunk options */ unsigned disable_partial_chunk_filters; /* Whether filters are disabled on partial chunks */ - DATATYPE *data_read = NULL; /* data buffer */ - DATATYPE *data_orig = NULL; /* expected data buffer */ + DATATYPE * data_read = NULL; /* data buffer */ + DATATYPE * data_orig = NULL; /* expected data buffer */ const char *filename; - MPI_Comm comm = test_comm; - MPI_Info info = MPI_INFO_NULL; - int mpi_size, mpi_rank; - herr_t ret; /* Generic return value */ + MPI_Comm comm = test_comm; + MPI_Info info = MPI_INFO_NULL; + int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Collective chunked dataset read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Collective chunked dataset read test on file %s\n", filename); /* Retrieve MPI parameters */ - MPI_Comm_size(comm,&mpi_size); - MPI_Comm_rank(comm,&mpi_rank); + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); /* Allocate data buffer */ - data_orig = (DATATYPE *)HDmalloc((size_t)dim*sizeof(DATATYPE)); + data_orig = (DATATYPE *)HDmalloc((size_t)dim * sizeof(DATATYPE)); VRFY((data_orig != NULL), "data_origin1 HDmalloc succeeded"); - data_read = (DATATYPE *)HDmalloc((size_t)dim*sizeof(DATATYPE)); + data_read = (DATATYPE *)HDmalloc((size_t)dim * sizeof(DATATYPE)); VRFY((data_read != NULL), "data_array1 HDmalloc succeeded"); /* Initialize data buffers */ - for(u=0; u= 0), "H5Pset_chunk succeeded"); /* Set chunk options appropriately */ - if(disable_partial_chunk_filters) { + if (disable_partial_chunk_filters) { ret = H5Pget_chunk_opts(dcpl, &chunk_opts); - VRFY((ret>=0),"H5Pget_chunk_opts succeeded"); + VRFY((ret >= 0), "H5Pget_chunk_opts succeeded"); chunk_opts |= H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS; ret = H5Pset_chunk_opts(dcpl, chunk_opts); - VRFY((ret>=0),"H5Pset_chunk_opts succeeded"); + VRFY((ret >= 0), "H5Pset_chunk_opts succeeded"); } /* end if */ ret = H5Pset_deflate(dcpl, 9); @@ -3028,7 +2979,8 @@ compress_readAll(void) VRFY((dataspace > 0), "H5Screate_simple succeeded"); /* Create dataset */ - dataset = H5Dcreate2(fid, "compressed_data", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + dataset = + H5Dcreate2(fid, "compressed_data", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); VRFY((dataset > 0), "H5Dcreate2 succeeded"); /* Write compressed data */ @@ -3050,49 +3002,47 @@ compress_readAll(void) MPI_Barrier(comm); /* ------------------- - * OPEN AN HDF5 FILE - * -------------------*/ + * OPEN AN HDF5 FILE + * -------------------*/ /* setup file access template */ acc_tpl = create_faccess_plist(comm, info, facc_type); VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDWR,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDWR, acc_tpl); VRFY((fid > 0), "H5Fopen succeeded"); /* Release file-access template */ ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /* Open dataset with compressed chunks */ dataset = H5Dopen2(fid, "compressed_data", H5P_DEFAULT); VRFY((dataset > 0), "H5Dopen2 succeeded"); /* Try reading & writing data */ - if(dataset>0) { + if (dataset > 0) { /* Create dataset transfer property list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist > 0), "H5Pcreate succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* Try reading the data */ ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer_plist, data_read); VRFY((ret >= 0), "H5Dread succeeded"); /* Verify data read */ - for(u=0; u 0 */ chunk_dims[0] = (hsize_t)chunkdim0; @@ -3191,8 +3143,8 @@ none_selection_chunk(void) * ------------------------------------------------------------- */ /* set up dataset storage chunk sizes and creation property list */ - if(VERBOSE_MED) - HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); + if (VERBOSE_MED) + HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); dataset_pl = H5Pcreate(H5P_DATASET_CREATE); VRFY((dataset_pl >= 0), "H5Pcreate succeeded"); ret = H5Pset_chunk(dataset_pl, MAX_RANK, chunk_dims); @@ -3201,7 +3153,7 @@ none_selection_chunk(void) /* setup dimensionality object */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple(MAX_RANK, dims, NULL); + sid = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* create an extendible dataset collectively */ @@ -3224,65 +3176,64 @@ none_selection_chunk(void) /* allocate memory for data buffer. Only allocate enough buffer for * each processor's data. */ - if(mpi_rank) { - data_origin = (DATATYPE *)HDmalloc(block[0]*block[1]*sizeof(DATATYPE)); + if (mpi_rank) { + data_origin = (DATATYPE *)HDmalloc(block[0] * block[1] * sizeof(DATATYPE)); VRFY((data_origin != NULL), "data_origin HDmalloc succeeded"); - data_array = (DATATYPE *)HDmalloc(block[0]*block[1]*sizeof(DATATYPE)); + data_array = (DATATYPE *)HDmalloc(block[0] * block[1] * sizeof(DATATYPE)); VRFY((data_array != NULL), "data_array HDmalloc succeeded"); /* put some trivial data in the data_array */ mstart[0] = mstart[1] = 0; dataset_fill(mstart, block, data_origin); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(mstart, block, data_origin); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(mstart, block, data_origin); } } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (MAX_RANK, block, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* Process 0 has no selection */ - if(!mpi_rank) { + if (!mpi_rank) { ret = H5Sselect_none(mem_dataspace); VRFY((ret >= 0), "H5Sselect_none succeeded"); } /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* Process 0 has no selection */ - if(!mpi_rank) { + if (!mpi_rank) { ret = H5Sselect_none(file_dataspace); VRFY((ret >= 0), "H5Sselect_none succeeded"); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); /* write data collectively */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_origin); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_origin); VRFY((ret >= 0), "H5Dwrite succeeded"); /* read data independently */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array); VRFY((ret >= 0), ""); /* verify the read data with original expected data */ - if(mpi_rank) { + if (mpi_rank) { ret = dataset_vrfy(mstart, count, stride, block, data_array, data_origin); - if(ret) nerrors++; + if (ret) + nerrors++; } /* ------------------------- @@ -3292,19 +3243,18 @@ none_selection_chunk(void) VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); /* write data collectively */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_origin); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_origin); VRFY((ret >= 0), "H5Dwrite succeeded"); /* read data independently */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array); VRFY((ret >= 0), ""); /* verify the read data with original expected data */ - if(mpi_rank) { + if (mpi_rank) { ret = dataset_vrfy(mstart, count, stride, block, data_array, data_origin); - if(ret) nerrors++; + if (ret) + nerrors++; } /* release resource */ @@ -3315,7 +3265,6 @@ none_selection_chunk(void) ret = H5Pclose(xfer_plist); VRFY((ret >= 0), "H5Pclose succeeded"); - /* close dataset collectively */ ret = H5Dclose(dataset1); VRFY((ret >= 0), "H5Dclose1 succeeded"); @@ -3326,11 +3275,12 @@ none_selection_chunk(void) H5Fclose(fid); /* release data buffers */ - if(data_origin) HDfree(data_origin); - if(data_array) HDfree(data_array); + if (data_origin) + HDfree(data_origin); + if (data_array) + HDfree(data_array); } - /* Function: test_actual_io_mode * * Purpose: tests one specific case of collective I/O and checks that the @@ -3394,63 +3344,61 @@ none_selection_chunk(void) * Date: 2011-04-06 */ static void -test_actual_io_mode(int selection_mode) { - H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_write = -1; - H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_read = -1; - H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_expected = -1; - H5D_mpio_actual_io_mode_t actual_io_mode_write = -1; - H5D_mpio_actual_io_mode_t actual_io_mode_read = -1; - H5D_mpio_actual_io_mode_t actual_io_mode_expected = -1; - const char * filename; - const char * test_name; - hbool_t direct_multi_chunk_io; - hbool_t multi_chunk_io; - hbool_t is_chunked; - hbool_t is_collective; - int mpi_size = -1; - int mpi_rank = -1; - int length; - int * buffer; - int i; - MPI_Comm mpi_comm = MPI_COMM_NULL; - MPI_Info mpi_info = MPI_INFO_NULL; - hid_t fid = -1; - hid_t sid = -1; - hid_t dataset = -1; - hid_t data_type = H5T_NATIVE_INT; - hid_t fapl_id = -1; - hid_t mem_space = -1; - hid_t file_space = -1; - hid_t dcpl = -1; - hid_t dxpl_write = -1; - hid_t dxpl_read = -1; - hsize_t dims[MAX_RANK]; - hsize_t chunk_dims[MAX_RANK]; - hsize_t start[MAX_RANK]; - hsize_t stride[MAX_RANK]; - hsize_t count[MAX_RANK]; - hsize_t block[MAX_RANK]; - char message[256]; - herr_t ret; +test_actual_io_mode(int selection_mode) +{ + H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_write = -1; + H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_read = -1; + H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_expected = -1; + H5D_mpio_actual_io_mode_t actual_io_mode_write = -1; + H5D_mpio_actual_io_mode_t actual_io_mode_read = -1; + H5D_mpio_actual_io_mode_t actual_io_mode_expected = -1; + const char * filename; + const char * test_name; + hbool_t direct_multi_chunk_io; + hbool_t multi_chunk_io; + hbool_t is_chunked; + hbool_t is_collective; + int mpi_size = -1; + int mpi_rank = -1; + int length; + int * buffer; + int i; + MPI_Comm mpi_comm = MPI_COMM_NULL; + MPI_Info mpi_info = MPI_INFO_NULL; + hid_t fid = -1; + hid_t sid = -1; + hid_t dataset = -1; + hid_t data_type = H5T_NATIVE_INT; + hid_t fapl_id = -1; + hid_t mem_space = -1; + hid_t file_space = -1; + hid_t dcpl = -1; + hid_t dxpl_write = -1; + hid_t dxpl_read = -1; + hsize_t dims[MAX_RANK]; + hsize_t chunk_dims[MAX_RANK]; + hsize_t start[MAX_RANK]; + hsize_t stride[MAX_RANK]; + hsize_t count[MAX_RANK]; + hsize_t block[MAX_RANK]; + char message[256]; + herr_t ret; /* Set up some flags to make some future if statements slightly more readable */ - direct_multi_chunk_io = ( - selection_mode == TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_IND || - selection_mode == TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_COL ); + direct_multi_chunk_io = (selection_mode == TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_IND || + selection_mode == TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_COL); /* Note: RESET performs the same tests as MULTI_CHUNK_MIX_DISAGREE and then * tests independent I/O */ - multi_chunk_io = ( - selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_IND || - selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_COL || - selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_MIX || - selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_MIX_DISAGREE || - selection_mode == TEST_ACTUAL_IO_RESET ); + multi_chunk_io = + (selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_IND || + selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_COL || + selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_MIX || + selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_MIX_DISAGREE || selection_mode == TEST_ACTUAL_IO_RESET); - is_chunked = ( - selection_mode != TEST_ACTUAL_IO_CONTIGUOUS && - selection_mode != TEST_ACTUAL_IO_NO_COLLECTIVE); + is_chunked = + (selection_mode != TEST_ACTUAL_IO_CONTIGUOUS && selection_mode != TEST_ACTUAL_IO_NO_COLLECTIVE); is_collective = selection_mode != TEST_ACTUAL_IO_NO_COLLECTIVE; @@ -3479,7 +3427,7 @@ test_actual_io_mode(int selection_mode) { /* Create the basic Space */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (MAX_RANK, dims, NULL); + sid = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* Create the dataset creation plist */ @@ -3487,17 +3435,16 @@ test_actual_io_mode(int selection_mode) { VRFY((dcpl >= 0), "dataset creation plist created successfully"); /* If we are not testing contiguous datasets */ - if(is_chunked) { + if (is_chunked) { /* Set up chunk information. */ - chunk_dims[0] = dims[0]/(hsize_t)mpi_size; + chunk_dims[0] = dims[0] / (hsize_t)mpi_size; chunk_dims[1] = dims[1]; - ret = H5Pset_chunk(dcpl, 2, chunk_dims); - VRFY((ret >= 0),"chunk creation property list succeeded"); + ret = H5Pset_chunk(dcpl, 2, chunk_dims); + VRFY((ret >= 0), "chunk creation property list succeeded"); } /* Create the dataset */ - dataset = H5Dcreate2(fid, "actual_io", data_type, sid, H5P_DEFAULT, - dcpl, H5P_DEFAULT); + dataset = H5Dcreate2(fid, "actual_io", data_type, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dcreate2() dataset succeeded"); /* Create the file dataspace */ @@ -3506,7 +3453,7 @@ test_actual_io_mode(int selection_mode) { /* Choose a selection method based on the type of I/O we want to occur, * and also set up some selection-dependeent test info. */ - switch(selection_mode) { + switch (selection_mode) { /* Independent I/O with optimization */ case TEST_ACTUAL_IO_MULTI_CHUNK_IND: @@ -3517,9 +3464,9 @@ test_actual_io_mode(int selection_mode) { */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); - test_name = "Multi Chunk - Independent"; + test_name = "Multi Chunk - Independent"; actual_chunk_opt_mode_expected = H5D_MPIO_MULTI_CHUNK; - actual_io_mode_expected = H5D_MPIO_CHUNK_INDEPENDENT; + actual_io_mode_expected = H5D_MPIO_CHUNK_INDEPENDENT; break; /* Collective I/O with optimization */ @@ -3531,9 +3478,9 @@ test_actual_io_mode(int selection_mode) { */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); - test_name = "Multi Chunk - Collective"; + test_name = "Multi Chunk - Collective"; actual_chunk_opt_mode_expected = H5D_MPIO_MULTI_CHUNK; - if(mpi_size > 1) + if (mpi_size > 1) actual_io_mode_expected = H5D_MPIO_CHUNK_COLLECTIVE; else actual_io_mode_expected = H5D_MPIO_CHUNK_INDEPENDENT; @@ -3550,24 +3497,25 @@ test_actual_io_mode(int selection_mode) { * and at least one chunk independently, reporting mixed I/O. */ - if(mpi_rank == 0) { - /* Select the first column */ - slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); - } else { + if (mpi_rank == 0) { + /* Select the first column */ + slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); + } + else { /* Select the first and the nth chunk in the nth column */ - block[0] = (hsize_t)(dim0 / mpi_size); - block[1] = (hsize_t)(dim1 / mpi_size); - count[0] = 2; - count[1] = 1; + block[0] = (hsize_t)(dim0 / mpi_size); + block[1] = (hsize_t)(dim1 / mpi_size); + count[0] = 2; + count[1] = 1; stride[0] = (hsize_t)mpi_rank * block[0]; stride[1] = 1; - start[0] = 0; - start[1] = (hsize_t)mpi_rank*block[1]; + start[0] = 0; + start[1] = (hsize_t)mpi_rank * block[1]; } - test_name = "Multi Chunk - Mixed"; + test_name = "Multi Chunk - Mixed"; actual_chunk_opt_mode_expected = H5D_MPIO_MULTI_CHUNK; - actual_io_mode_expected = H5D_MPIO_CHUNK_MIXED; + actual_io_mode_expected = H5D_MPIO_CHUNK_MIXED; break; /* RESET tests that the properties are properly reset to defaults each time I/O is @@ -3590,20 +3538,21 @@ test_actual_io_mode(int selection_mode) { * collectively, and their other chunk indpendently, reporting mixed I/O. */ - if(mpi_rank == 0) { - /* Select the first chunk in the first column */ - slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); - block[0] = block[0] / (hsize_t)mpi_size; - } else { + if (mpi_rank == 0) { + /* Select the first chunk in the first column */ + slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); + block[0] = block[0] / (hsize_t)mpi_size; + } + else { /* Select the first and the nth chunk in the nth column */ - block[0] = (hsize_t)(dim0 / mpi_size); - block[1] = (hsize_t)(dim1 / mpi_size); - count[0] = 2; - count[1] = 1; + block[0] = (hsize_t)(dim0 / mpi_size); + block[1] = (hsize_t)(dim1 / mpi_size); + count[0] = 2; + count[1] = 1; stride[0] = (hsize_t)mpi_rank * block[0]; stride[1] = 1; - start[0] = 0; - start[1] = (hsize_t)mpi_rank*block[1]; + start[0] = 0; + start[1] = (hsize_t)mpi_rank * block[1]; } /* If the testname was not already set by the RESET case */ @@ -3613,8 +3562,8 @@ test_actual_io_mode(int selection_mode) { test_name = "Multi Chunk - Mixed (Disagreement)"; actual_chunk_opt_mode_expected = H5D_MPIO_MULTI_CHUNK; - if(mpi_size > 1) { - if(mpi_rank == 0) + if (mpi_size > 1) { + if (mpi_rank == 0) actual_io_mode_expected = H5D_MPIO_CHUNK_COLLECTIVE; else actual_io_mode_expected = H5D_MPIO_CHUNK_MIXED; @@ -3629,9 +3578,9 @@ test_actual_io_mode(int selection_mode) { /* Nothing special; link chunk I/O is forced in the dxpl settings. */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); - test_name = "Link Chunk"; + test_name = "Link Chunk"; actual_chunk_opt_mode_expected = H5D_MPIO_LINK_CHUNK; - actual_io_mode_expected = H5D_MPIO_CHUNK_COLLECTIVE; + actual_io_mode_expected = H5D_MPIO_CHUNK_COLLECTIVE; break; /* Contiguous Dataset */ @@ -3640,23 +3589,23 @@ test_actual_io_mode(int selection_mode) { * collective I/O */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); - test_name = "Contiguous"; + test_name = "Contiguous"; actual_chunk_opt_mode_expected = H5D_MPIO_NO_CHUNK_OPTIMIZATION; - actual_io_mode_expected = H5D_MPIO_CONTIGUOUS_COLLECTIVE; + actual_io_mode_expected = H5D_MPIO_CONTIGUOUS_COLLECTIVE; break; case TEST_ACTUAL_IO_NO_COLLECTIVE: slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); - test_name = "Independent"; + test_name = "Independent"; actual_chunk_opt_mode_expected = H5D_MPIO_NO_CHUNK_OPTIMIZATION; - actual_io_mode_expected = H5D_MPIO_NO_COLLECTIVE; + actual_io_mode_expected = H5D_MPIO_NO_COLLECTIVE; break; default: - test_name = "Undefined Selection Mode"; + test_name = "Undefined Selection Mode"; actual_chunk_opt_mode_expected = -1; - actual_io_mode_expected = -1; + actual_io_mode_expected = -1; break; } @@ -3666,7 +3615,7 @@ test_actual_io_mode(int selection_mode) { /* Create a memory dataspace mirroring the dataset and select the same hyperslab * as in the file space. */ - mem_space = H5Screate_simple (MAX_RANK, dims, NULL); + mem_space = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((mem_space >= 0), "mem_space created"); ret = H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, start, stride, count, block); @@ -3678,7 +3627,7 @@ test_actual_io_mode(int selection_mode) { /* Allocate and initialize the buffer */ buffer = (int *)HDmalloc(sizeof(int) * (size_t)length); VRFY((buffer != NULL), "HDmalloc of buffer succeeded"); - for(i = 0; i < length; i++) + for (i = 0; i < length; i++) buffer[i] = i; /* Set up the dxpl for the write */ @@ -3686,7 +3635,7 @@ test_actual_io_mode(int selection_mode) { VRFY((dxpl_write >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded"); /* Set collective I/O properties in the dxpl. */ - if(is_collective) { + if (is_collective) { /* Request collective I/O */ ret = H5Pset_dxpl_mpio(dxpl_write, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); @@ -3696,19 +3645,19 @@ test_actual_io_mode(int selection_mode) { * multi chunk io instead of link chunk io. * This is via deault. */ - if(multi_chunk_io) { + if (multi_chunk_io) { /* force multi-chunk-io by threshold */ - ret = H5Pset_dxpl_mpio_chunk_opt_num(dxpl_write, (unsigned) mpi_size*2); + ret = H5Pset_dxpl_mpio_chunk_opt_num(dxpl_write, (unsigned)mpi_size * 2); VRFY((ret >= 0), "H5Pset_dxpl_mpio_chunk_opt_num succeeded"); /* set this to manipulate testing senario about allocating processes * to chunks */ - ret = H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl_write, (unsigned) 99); + ret = H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl_write, (unsigned)99); VRFY((ret >= 0), "H5Pset_dxpl_mpio_chunk_opt_ratio succeeded"); } /* Set directly go to multi-chunk-io without threshold calc. */ - if(direct_multi_chunk_io) { + if (direct_multi_chunk_io) { /* set for multi chunk io by property*/ ret = H5Pset_dxpl_mpio_chunk_opt(dxpl_write, H5FD_MPIO_CHUNK_MULTI_IO); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); @@ -3721,43 +3670,47 @@ test_actual_io_mode(int selection_mode) { /* Write */ ret = H5Dwrite(dataset, data_type, mem_space, file_space, dxpl_write, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dwrite() dataset multichunk write succeeded"); /* Retreive Actual io valuess */ ret = H5Pget_mpio_actual_io_mode(dxpl_write, &actual_io_mode_write); - VRFY((ret >= 0), "retriving actual io mode suceeded" ); + VRFY((ret >= 0), "retriving actual io mode suceeded"); ret = H5Pget_mpio_actual_chunk_opt_mode(dxpl_write, &actual_chunk_opt_mode_write); - VRFY((ret >= 0), "retriving actual chunk opt mode succeeded" ); + VRFY((ret >= 0), "retriving actual chunk opt mode succeeded"); /* Read */ ret = H5Dread(dataset, data_type, mem_space, file_space, dxpl_read, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dread() dataset multichunk read succeeded"); /* Retreive Actual io values */ ret = H5Pget_mpio_actual_io_mode(dxpl_read, &actual_io_mode_read); - VRFY((ret >= 0), "retriving actual io mode succeeded" ); + VRFY((ret >= 0), "retriving actual io mode succeeded"); ret = H5Pget_mpio_actual_chunk_opt_mode(dxpl_read, &actual_chunk_opt_mode_read); - VRFY((ret >= 0), "retriving actual chunk opt mode succeeded" ); + VRFY((ret >= 0), "retriving actual chunk opt mode succeeded"); /* Check write vs read */ VRFY((actual_io_mode_read == actual_io_mode_write), - "reading and writing are the same for actual_io_mode"); + "reading and writing are the same for actual_io_mode"); VRFY((actual_chunk_opt_mode_read == actual_chunk_opt_mode_write), - "reading and writing are the same for actual_chunk_opt_mode"); + "reading and writing are the same for actual_chunk_opt_mode"); /* Test values */ - if(actual_chunk_opt_mode_expected != (H5D_mpio_actual_chunk_opt_mode_t) -1 && actual_io_mode_expected != (H5D_mpio_actual_io_mode_t) -1) { - HDsprintf(message, "Actual Chunk Opt Mode has the correct value for %s.\n",test_name); + if (actual_chunk_opt_mode_expected != (H5D_mpio_actual_chunk_opt_mode_t)-1 && + actual_io_mode_expected != (H5D_mpio_actual_io_mode_t)-1) { + HDsprintf(message, "Actual Chunk Opt Mode has the correct value for %s.\n", test_name); VRFY((actual_chunk_opt_mode_write == actual_chunk_opt_mode_expected), message); - HDsprintf(message, "Actual IO Mode has the correct value for %s.\n",test_name); + HDsprintf(message, "Actual IO Mode has the correct value for %s.\n", test_name); VRFY((actual_io_mode_write == actual_io_mode_expected), message); - } else { - HDfprintf(stderr, "%s %d -> (%d,%d)\n", test_name, mpi_rank, - actual_chunk_opt_mode_write, actual_io_mode_write); + } + else { + HDfprintf(stderr, "%s %d -> (%d,%d)\n", test_name, mpi_rank, actual_chunk_opt_mode_write, + actual_io_mode_write); } /* To test that the property is succesfully reset to the default, we perform some @@ -3777,14 +3730,14 @@ test_actual_io_mode(int selection_mode) { /* Check Properties */ ret = H5Pget_mpio_actual_io_mode(dxpl_write, &actual_io_mode_write); - VRFY( (ret >= 0), "retriving actual io mode succeeded" ); + VRFY((ret >= 0), "retriving actual io mode succeeded"); ret = H5Pget_mpio_actual_chunk_opt_mode(dxpl_write, &actual_chunk_opt_mode_write); - VRFY( (ret >= 0), "retriving actual chunk opt mode succeeded" ); + VRFY((ret >= 0), "retriving actual chunk opt mode succeeded"); VRFY(actual_chunk_opt_mode_write == H5D_MPIO_NO_CHUNK_OPTIMIZATION, - "actual_chunk_opt_mode has correct value for reset write (independent)"); + "actual_chunk_opt_mode has correct value for reset write (independent)"); VRFY(actual_io_mode_write == H5D_MPIO_NO_COLLECTIVE, - "actual_io_mode has correct value for reset write (independent)"); + "actual_io_mode has correct value for reset write (independent)"); /* Read */ ret = H5Dread(dataset, data_type, H5S_ALL, H5S_ALL, dxpl_read, buffer); @@ -3792,15 +3745,15 @@ test_actual_io_mode(int selection_mode) { /* Check Properties */ ret = H5Pget_mpio_actual_io_mode(dxpl_read, &actual_io_mode_read); - VRFY( (ret >= 0), "retriving actual io mode succeeded" ); + VRFY((ret >= 0), "retriving actual io mode succeeded"); ret = H5Pget_mpio_actual_chunk_opt_mode(dxpl_read, &actual_chunk_opt_mode_read); - VRFY( (ret >= 0), "retriving actual chunk opt mode succeeded" ); + VRFY((ret >= 0), "retriving actual chunk opt mode succeeded"); VRFY(actual_chunk_opt_mode_read == H5D_MPIO_NO_CHUNK_OPTIMIZATION, - "actual_chunk_opt_mode has correct value for reset read (independent)"); + "actual_chunk_opt_mode has correct value for reset read (independent)"); VRFY(actual_io_mode_read == H5D_MPIO_NO_COLLECTIVE, - "actual_io_mode has correct value for reset read (independent)"); - } + "actual_io_mode has correct value for reset read (independent)"); + } } /* Release some resources */ @@ -3817,7 +3770,6 @@ test_actual_io_mode(int selection_mode) { return; } - /* Function: actual_io_mode_tests * * Purpose: Tests all possible cases of the actual_io_mode property. @@ -3826,7 +3778,8 @@ test_actual_io_mode(int selection_mode) { * Date: 2011-04-06 */ void -actual_io_mode_tests(void) { +actual_io_mode_tests(void) +{ int mpi_size = -1; int mpi_rank = -1; MPI_Comm_size(test_comm, &mpi_size); @@ -3901,47 +3854,48 @@ actual_io_mode_tests(void) { * * TEST_FILTERS: * Test for using filter (checksum) as the cause of breaking collective I/O. - * Note: TEST_FILTERS mode will not work until H5Dcreate and H5write is supported for mpio and filter feature. Use test_no_collective_cause_mode_filter() function instead. + * Note: TEST_FILTERS mode will not work until H5Dcreate and H5write is supported for mpio and filter + * feature. Use test_no_collective_cause_mode_filter() function instead. * * * Programmer: Jonathan Kim * Date: Aug, 2012 */ #define DSET_NOCOLCAUSE "nocolcause" -#define NELM 2 -#define FILE_EXTERNAL "nocolcause_extern.data" +#define NELM 2 +#define FILE_EXTERNAL "nocolcause_extern.data" static void test_no_collective_cause_mode(int selection_mode) { - uint32_t no_collective_cause_local_write = 0; - uint32_t no_collective_cause_local_read = 0; - uint32_t no_collective_cause_local_expected = 0; - uint32_t no_collective_cause_global_write = 0; - uint32_t no_collective_cause_global_read = 0; + uint32_t no_collective_cause_local_write = 0; + uint32_t no_collective_cause_local_read = 0; + uint32_t no_collective_cause_local_expected = 0; + uint32_t no_collective_cause_global_write = 0; + uint32_t no_collective_cause_global_read = 0; uint32_t no_collective_cause_global_expected = 0; // hsize_t coord[NELM][MAX_RANK]; - const char * filename; - const char * test_name; - hbool_t is_chunked=1; - hbool_t is_independent=0; - int mpi_size = -1; - int mpi_rank = -1; + const char *filename; + const char *test_name; + hbool_t is_chunked = 1; + hbool_t is_independent = 0; + int mpi_size = -1; + int mpi_rank = -1; int length; - int * buffer; + int * buffer; int i; MPI_Comm mpi_comm; MPI_Info mpi_info; - hid_t fid = -1; - hid_t sid = -1; - hid_t dataset = -1; - hid_t data_type = H5T_NATIVE_INT; - hid_t fapl_id = -1; - hid_t dcpl = -1; + hid_t fid = -1; + hid_t sid = -1; + hid_t dataset = -1; + hid_t data_type = H5T_NATIVE_INT; + hid_t fapl_id = -1; + hid_t dcpl = -1; hid_t dxpl_write = -1; - hid_t dxpl_read = -1; + hid_t dxpl_read = -1; hsize_t dims[MAX_RANK]; - hid_t mem_space = -1; + hid_t mem_space = -1; hid_t file_space = -1; hsize_t chunk_dims[MAX_RANK]; herr_t ret; @@ -3949,7 +3903,7 @@ test_no_collective_cause_mode(int selection_mode) H5Z_filter_t filter_info; #endif /* LATER */ /* set to global value as default */ - int l_facc_type = facc_type; + int l_facc_type = facc_type; char message[256]; /* Set up MPI parameters */ @@ -3968,27 +3922,29 @@ test_no_collective_cause_mode(int selection_mode) VRFY((dcpl >= 0), "dataset creation plist created successfully"); if (selection_mode & TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_COMPACT) { - ret = H5Pset_layout (dcpl, H5D_COMPACT); - VRFY((ret >= 0),"set COMPACT layout succeeded"); + ret = H5Pset_layout(dcpl, H5D_COMPACT); + VRFY((ret >= 0), "set COMPACT layout succeeded"); is_chunked = 0; } if (selection_mode & TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL) { - ret = H5Pset_external (dcpl, FILE_EXTERNAL, (off_t) 0, H5F_UNLIMITED); - VRFY((ret >= 0),"set EXTERNAL file layout succeeded"); + ret = H5Pset_external(dcpl, FILE_EXTERNAL, (off_t)0, H5F_UNLIMITED); + VRFY((ret >= 0), "set EXTERNAL file layout succeeded"); is_chunked = 0; } #ifdef LATER /* fletcher32 */ if (selection_mode & TEST_FILTERS) { ret = H5Zfilter_avail(H5Z_FILTER_FLETCHER32); - VRFY ((ret >=0 ), "Fletcher32 filter is available.\n"); + VRFY((ret >= 0), "Fletcher32 filter is available.\n"); - ret = H5Zget_filter_info (H5Z_FILTER_FLETCHER32, &filter_info); - VRFY ( ( (filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) || (filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED) ) , "Fletcher32 filter encoding and decoding available.\n"); + ret = H5Zget_filter_info(H5Z_FILTER_FLETCHER32, &filter_info); + VRFY(((filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) || + (filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED)), + "Fletcher32 filter encoding and decoding available.\n"); ret = H5Pset_fletcher32(dcpl); - VRFY((ret >= 0),"set filter (flecher32) succeeded"); + VRFY((ret >= 0), "set filter (flecher32) succeeded"); } #endif /* LATER */ @@ -4008,11 +3964,10 @@ test_no_collective_cause_mode(int selection_mode) dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; } - sid = H5Screate_simple (MAX_RANK, dims, NULL); + sid = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); } - filename = (const char *)GetTestParameters(); HDassert(filename != NULL); @@ -4026,20 +3981,18 @@ test_no_collective_cause_mode(int selection_mode) VRFY((fid >= 0), "H5Fcreate succeeded"); /* If we are not testing contiguous datasets */ - if(is_chunked) { + if (is_chunked) { /* Set up chunk information. */ - chunk_dims[0] = dims[0]/(hsize_t)mpi_size; + chunk_dims[0] = dims[0] / (hsize_t)mpi_size; chunk_dims[1] = dims[1]; - ret = H5Pset_chunk(dcpl, 2, chunk_dims); - VRFY((ret >= 0),"chunk creation property list succeeded"); + ret = H5Pset_chunk(dcpl, 2, chunk_dims); + VRFY((ret >= 0), "chunk creation property list succeeded"); } - /* Create the dataset */ dataset = H5Dcreate2(fid, "nocolcause", data_type, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dcreate2() dataset succeeded"); - /* * Set expected causes and some tweaks based on the type of test */ @@ -4079,14 +4032,14 @@ test_no_collective_cause_mode(int selection_mode) #endif /* LATER */ if (selection_mode & TEST_COLLECTIVE) { - test_name = "Broken Collective I/O - Not Broken"; - no_collective_cause_local_expected = H5D_MPIO_COLLECTIVE; + test_name = "Broken Collective I/O - Not Broken"; + no_collective_cause_local_expected = H5D_MPIO_COLLECTIVE; no_collective_cause_global_expected = H5D_MPIO_COLLECTIVE; } if (selection_mode & TEST_SET_INDEPENDENT) { - test_name = "Broken Collective I/O - Independent"; - no_collective_cause_local_expected = H5D_MPIO_SET_INDEPENDENT; + test_name = "Broken Collective I/O - Independent"; + no_collective_cause_local_expected = H5D_MPIO_SET_INDEPENDENT; no_collective_cause_global_expected = H5D_MPIO_SET_INDEPENDENT; /* switch to independent io */ is_independent = 1; @@ -4096,7 +4049,7 @@ test_no_collective_cause_mode(int selection_mode) if (selection_mode & TEST_NOT_SIMPLE_OR_SCALAR_DATASPACES || selection_mode & TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL) { file_space = H5S_ALL; - mem_space = H5S_ALL; + mem_space = H5S_ALL; } else { /* Get the file dataspace */ @@ -4104,7 +4057,7 @@ test_no_collective_cause_mode(int selection_mode) VRFY((file_space >= 0), "H5Dget_space succeeded"); /* Create the memory dataspace */ - mem_space = H5Screate_simple (MAX_RANK, dims, NULL); + mem_space = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((mem_space >= 0), "mem_space created"); } @@ -4114,14 +4067,14 @@ test_no_collective_cause_mode(int selection_mode) /* Allocate and initialize the buffer */ buffer = (int *)HDmalloc(sizeof(int) * (size_t)length); VRFY((buffer != NULL), "HDmalloc of buffer succeeded"); - for(i = 0; i < length; i++) + for (i = 0; i < length; i++) buffer[i] = i; /* Set up the dxpl for the write */ dxpl_write = H5Pcreate(H5P_DATASET_XFER); VRFY((dxpl_write >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded"); - if(is_independent) { + if (is_independent) { /* Set Independent I/O */ ret = H5Pset_dxpl_mpio(dxpl_write, H5FD_MPIO_INDEPENDENT); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); @@ -4130,11 +4083,10 @@ test_no_collective_cause_mode(int selection_mode) /* Set Collective I/O */ ret = H5Pset_dxpl_mpio(dxpl_write, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - } if (selection_mode & TEST_DATA_TRANSFORMS) { - ret = H5Pset_data_transform (dxpl_write, "x+1"); + ret = H5Pset_data_transform(dxpl_write, "x+1"); VRFY((ret >= 0), "H5Pset_data_transform succeeded"); } @@ -4144,14 +4096,14 @@ test_no_collective_cause_mode(int selection_mode) /* Write */ ret = H5Dwrite(dataset, data_type, mem_space, file_space, dxpl_write, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dwrite() dataset multichunk write succeeded"); - /* Get the cause of broken collective I/O */ - ret = H5Pget_mpio_no_collective_cause (dxpl_write, &no_collective_cause_local_write, &no_collective_cause_global_write); - VRFY((ret >= 0), "retriving no collective cause succeeded" ); - + ret = H5Pget_mpio_no_collective_cause(dxpl_write, &no_collective_cause_local_write, + &no_collective_cause_global_write); + VRFY((ret >= 0), "retriving no collective cause succeeded"); /*--------------------- * Test Read access @@ -4164,25 +4116,27 @@ test_no_collective_cause_mode(int selection_mode) /* Read */ ret = H5Dread(dataset, data_type, mem_space, file_space, dxpl_read, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dread() dataset multichunk read succeeded"); /* Get the cause of broken collective I/O */ - ret = H5Pget_mpio_no_collective_cause (dxpl_read, &no_collective_cause_local_read, &no_collective_cause_global_read); - VRFY((ret >= 0), "retriving no collective cause succeeded" ); + ret = H5Pget_mpio_no_collective_cause(dxpl_read, &no_collective_cause_local_read, + &no_collective_cause_global_read); + VRFY((ret >= 0), "retriving no collective cause succeeded"); /* Check write vs read */ VRFY((no_collective_cause_local_read == no_collective_cause_local_write), - "reading and writing are the same for local cause of Broken Collective I/O"); + "reading and writing are the same for local cause of Broken Collective I/O"); VRFY((no_collective_cause_global_read == no_collective_cause_global_write), - "reading and writing are the same for global cause of Broken Collective I/O"); + "reading and writing are the same for global cause of Broken Collective I/O"); /* Test values */ - HDmemset (message, 0, sizeof (message)); - HDsprintf(message, "Local cause of Broken Collective I/O has the correct value for %s.\n",test_name); + HDmemset(message, 0, sizeof(message)); + HDsprintf(message, "Local cause of Broken Collective I/O has the correct value for %s.\n", test_name); VRFY((no_collective_cause_local_write == no_collective_cause_local_expected), message); - HDmemset (message, 0, sizeof (message)); - HDsprintf(message, "Global cause of Broken Collective I/O has the correct value for %s.\n",test_name); + HDmemset(message, 0, sizeof(message)); + HDsprintf(message, "Global cause of Broken Collective I/O has the correct value for %s.\n", test_name); VRFY((no_collective_cause_global_write == no_collective_cause_global_expected), message); /* Release some resources */ @@ -4213,7 +4167,6 @@ test_no_collective_cause_mode(int selection_mode) return; } - #if 0 /* * Function: test_no_collective_cause_mode_filter @@ -4268,7 +4221,7 @@ test_no_collective_cause_mode_filter(int selection_mode) herr_t ret; #ifdef LATER /* fletcher32 */ H5Z_filter_t filter_info; -#endif /* LATER */ +#endif /* LATER */ char message[256]; /* Set up MPI parameters */ @@ -4296,7 +4249,7 @@ test_no_collective_cause_mode_filter(int selection_mode) ret = H5Pset_fletcher32(dcpl); VRFY((ret >= 0),"set filter (flecher32) succeeded"); -#endif /* LATER */ +#endif /* LATER */ } else { VRFY(0, "Unexpected mode, only test for TEST_FILTERS_READ."); @@ -4338,7 +4291,7 @@ test_no_collective_cause_mode_filter(int selection_mode) test_name = "Broken Collective I/O - Filter is required"; no_collective_cause_local_expected = H5D_MPIO_FILTERS; no_collective_cause_global_expected = H5D_MPIO_FILTERS; -#endif /* LATER */ +#endif /* LATER */ /* Get the file dataspace */ file_space = H5Dget_space(dataset); @@ -4461,27 +4414,28 @@ no_collective_cause_tests(void) /* * Test individual cause */ - test_no_collective_cause_mode (TEST_COLLECTIVE); - test_no_collective_cause_mode (TEST_SET_INDEPENDENT); - test_no_collective_cause_mode (TEST_DATATYPE_CONVERSION); - test_no_collective_cause_mode (TEST_DATA_TRANSFORMS); - test_no_collective_cause_mode (TEST_NOT_SIMPLE_OR_SCALAR_DATASPACES); - test_no_collective_cause_mode (TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_COMPACT); - test_no_collective_cause_mode (TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL); + test_no_collective_cause_mode(TEST_COLLECTIVE); + test_no_collective_cause_mode(TEST_SET_INDEPENDENT); + test_no_collective_cause_mode(TEST_DATATYPE_CONVERSION); + test_no_collective_cause_mode(TEST_DATA_TRANSFORMS); + test_no_collective_cause_mode(TEST_NOT_SIMPLE_OR_SCALAR_DATASPACES); + test_no_collective_cause_mode(TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_COMPACT); + test_no_collective_cause_mode(TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL); #ifdef LATER /* fletcher32 */ - /* TODO: use this instead of below TEST_FILTERS_READ when H5Dcreate and - * H5Dwrite is ready for mpio + filter feature. - */ + /* TODO: use this instead of below TEST_FILTERS_READ when H5Dcreate and + * H5Dwrite is ready for mpio + filter feature. + */ /* test_no_collective_cause_mode (TEST_FILTERS); */ - test_no_collective_cause_mode_filter (TEST_FILTERS_READ); + test_no_collective_cause_mode_filter(TEST_FILTERS_READ); #endif /* LATER */ /* * Test combined causes */ - test_no_collective_cause_mode (TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL | TEST_DATATYPE_CONVERSION); - test_no_collective_cause_mode (TEST_DATATYPE_CONVERSION | TEST_DATA_TRANSFORMS); - test_no_collective_cause_mode (TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL | TEST_DATATYPE_CONVERSION | TEST_DATA_TRANSFORMS); + test_no_collective_cause_mode(TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL | TEST_DATATYPE_CONVERSION); + test_no_collective_cause_mode(TEST_DATATYPE_CONVERSION | TEST_DATA_TRANSFORMS); + test_no_collective_cause_mode(TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL | TEST_DATATYPE_CONVERSION | + TEST_DATA_TRANSFORMS); return; } @@ -4500,41 +4454,42 @@ no_collective_cause_tests(void) void dataset_atomicity(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t sid; /* Dataspace ID */ - hid_t dataset1; /* Dataset IDs */ - hsize_t dims[MAX_RANK]; /* dataset dim sizes */ - int *write_buf = NULL; /* data buffer */ - int *read_buf = NULL; /* data buffer */ - int buf_size; - hid_t dataset2; - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* Memory dataspace ID */ - hsize_t start[MAX_RANK]; - hsize_t stride[MAX_RANK]; - hsize_t count[MAX_RANK]; - hsize_t block[MAX_RANK]; + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t sid; /* Dataspace ID */ + hid_t dataset1; /* Dataset IDs */ + hsize_t dims[MAX_RANK]; /* dataset dim sizes */ + int * write_buf = NULL; /* data buffer */ + int * read_buf = NULL; /* data buffer */ + int buf_size; + hid_t dataset2; + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* Memory dataspace ID */ + hsize_t start[MAX_RANK]; + hsize_t stride[MAX_RANK]; + hsize_t count[MAX_RANK]; + hsize_t block[MAX_RANK]; const char *filename; - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; - int i, j, k; - hbool_t atomicity = FALSE; - MPI_Comm comm = test_comm; - MPI_Info info = MPI_INFO_NULL; - - dim0 = 64; dim1 = 32; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; + int i, j, k; + hbool_t atomicity = FALSE; + MPI_Comm comm = test_comm; + MPI_Info info = MPI_INFO_NULL; + + dim0 = 64; + dim1 = 32; filename = GetTestParameters(); if (facc_type != FACC_MPIO) { HDprintf("Atomicity tests will not work without the MPIO VFD\n"); return; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("atomic writes to file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); buf_size = dim0 * dim1; /* allocate memory for data buffer */ @@ -4559,26 +4514,22 @@ dataset_atomicity(void) /* setup dimensionality object */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (MAX_RANK, dims, NULL); + sid = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* create datasets */ - dataset1 = H5Dcreate2(fid, DATASETNAME5, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset1 = H5Dcreate2(fid, DATASETNAME5, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset1 >= 0), "H5Dcreate2 succeeded"); - dataset2 = H5Dcreate2(fid, DATASETNAME6, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset2 = H5Dcreate2(fid, DATASETNAME6, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset2 >= 0), "H5Dcreate2 succeeded"); /* initialize datasets to 0s */ if (0 == mpi_rank) { - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, write_buf); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded"); - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, write_buf); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf); VRFY((ret >= 0), "H5Dwrite dataset2 succeeded"); } @@ -4591,39 +4542,39 @@ dataset_atomicity(void) ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded"); - MPI_Barrier (comm); + MPI_Barrier(comm); /* make sure setting atomicity fails on a serial file ID */ /* file locking allows only one file open (serial) for writing */ - if(MAINPROCESS){ - fid=H5Fopen(filename,H5F_ACC_RDWR,H5P_DEFAULT); + if (MAINPROCESS) { + fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); VRFY((fid >= 0), "H5Fopen succeeed"); } /* should fail */ - ret = H5Fset_mpi_atomicity(fid , TRUE); + ret = H5Fset_mpi_atomicity(fid, TRUE); VRFY((ret == FAIL), "H5Fset_mpi_atomicity failed"); - if(MAINPROCESS){ + if (MAINPROCESS) { ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded"); } - MPI_Barrier (comm); + MPI_Barrier(comm); /* setup file access template */ acc_tpl = create_faccess_plist(comm, info, facc_type); VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDWR,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDWR, acc_tpl); VRFY((fid >= 0), "H5Fopen succeeded"); /* Release file-access template */ ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose succeeded"); - ret = H5Fset_mpi_atomicity(fid , TRUE); + ret = H5Fset_mpi_atomicity(fid, TRUE); VRFY((ret >= 0), "H5Fset_mpi_atomicity succeeded"); /* open dataset1 (contiguous case) */ @@ -4631,22 +4582,22 @@ dataset_atomicity(void) VRFY((dataset1 >= 0), "H5Dopen2 succeeded"); if (0 == mpi_rank) { - for (i=0 ; i= 0), "atomcity get failed"); VRFY((atomicity == TRUE), "atomcity set failed"); - MPI_Barrier (comm); + MPI_Barrier(comm); /* Process 0 writes contiguously to the entire dataset */ if (0 == mpi_rank) { @@ -4659,12 +4610,14 @@ dataset_atomicity(void) VRFY((ret >= 0), "H5Dwrite() dataset multichunk write succeeded"); } - if(VERBOSE_MED) { - i=0;j=0;k=0; - for (i=0 ; i= 0), "H5D close succeeded"); /* release data buffers */ - if(write_buf) HDfree(write_buf); - if(read_buf) HDfree(read_buf); + if (write_buf) + HDfree(write_buf); + if (read_buf) + HDfree(read_buf); /* open dataset2 (non-contiguous case) */ dataset2 = H5Dopen2(fid, DATASETNAME6, H5P_DEFAULT); @@ -4702,69 +4658,68 @@ dataset_atomicity(void) read_buf = (int *)HDcalloc((size_t)buf_size, sizeof(int)); VRFY((read_buf != NULL), "read_buf HDcalloc succeeded"); - for (i=0 ; i= 0), "atomcity get failed"); VRFY((atomicity == TRUE), "atomcity set failed"); - - block[0] = (hsize_t)(dim0/mpi_size) - 1; - block[1] = (hsize_t)(dim1/mpi_size) - 1; + block[0] = (hsize_t)(dim0 / mpi_size) - 1; + block[1] = (hsize_t)(dim1 / mpi_size) - 1; stride[0] = block[0] + 1; stride[1] = block[1] + 1; - count[0] = (hsize_t)mpi_size; - count[1] = (hsize_t)mpi_size; - start[0] = 0; - start[1] = 0; + count[0] = (hsize_t)mpi_size; + count[1] = (hsize_t)mpi_size; + start[0] = 0; + start[1] = 0; /* create a file dataspace */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace */ - mem_dataspace = H5Screate_simple (MAX_RANK, dims, NULL); + mem_dataspace = H5Screate_simple(MAX_RANK, dims, NULL); VRFY((mem_dataspace >= 0), ""); ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); - MPI_Barrier (comm); + MPI_Barrier(comm); /* Process 0 writes to the dataset */ if (0 == mpi_rank) { - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, write_buf); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, write_buf); VRFY((ret >= 0), "H5Dwrite dataset2 succeeded"); } /* All processes wait for the write to finish. This works because atomicity is set to true */ - MPI_Barrier (comm); + MPI_Barrier(comm); /* The other processes read the entire dataset */ if (0 != mpi_rank) { - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, read_buf); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, read_buf); VRFY((ret >= 0), "H5Dread dataset2 succeeded"); } - if(VERBOSE_MED) { + if (VERBOSE_MED) { if (mpi_rank == 1) { - i=0;j=0;k=0; - for (i=0 ; i= (hsize_t)mpi_rank*(block[0]+1)) { + for (i = 0; i < dim0; i++) { + if ((hsize_t)i >= (hsize_t)mpi_rank * (block[0] + 1)) { break; } - if (((hsize_t)i+1)%(block[0]+1)==0) { + if (((hsize_t)i + 1) % (block[0] + 1) == 0) { k += dim1; continue; } - for (j=0 ; j= (hsize_t)mpi_rank*(block[1]+1)) { - H5_CHECKED_ASSIGN(k, int, (hsize_t)dim1 - (hsize_t)mpi_rank*(block[1]+1) + (hsize_t)k, hsize_t); + for (j = 0; j < dim1; j++) { + if ((hsize_t)j >= (hsize_t)mpi_rank * (block[1] + 1)) { + H5_CHECKED_ASSIGN(k, int, (hsize_t)dim1 - (hsize_t)mpi_rank * (block[1] + 1) + (hsize_t)k, + hsize_t); break; } - if (((hsize_t)j+1)%(block[1]+1)==0) { + if (((hsize_t)j + 1) % (block[1] + 1) == 0) { k++; continue; } else if (compare != read_buf[k]) { - HDprintf("Atomicity Test Failed Process %d: read_buf[%d] is %d, should be %d\n", mpi_rank, k, read_buf[k], compare); + HDprintf("Atomicity Test Failed Process %d: read_buf[%d] is %d, should be %d\n", mpi_rank, + k, read_buf[k], compare); nerrors++; } - k ++; + k++; } } } @@ -4810,12 +4769,13 @@ dataset_atomicity(void) VRFY((ret >= 0), "H5Sclose succeeded"); /* release data buffers */ - if(write_buf) HDfree(write_buf); - if(read_buf) HDfree(read_buf); + if (write_buf) + HDfree(write_buf); + if (read_buf) + HDfree(read_buf); ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded"); - } /* Function: dense_attr_test @@ -4828,21 +4788,21 @@ dataset_atomicity(void) void test_dense_attr(void) { - int mpi_size, mpi_rank; - hid_t fpid, fid; - hid_t gid, gpid; - hid_t atFileSpace, atid; - hsize_t atDims[1] = {10000}; - herr_t status; + int mpi_size, mpi_rank; + hid_t fpid, fid; + hid_t gid, gpid; + hid_t atFileSpace, atid; + hsize_t atDims[1] = {10000}; + herr_t status; const char *filename; /* get filename */ filename = (const char *)GetTestParameters(); - HDassert( filename != NULL ); + HDassert(filename != NULL); /* set up MPI parameters */ - MPI_Comm_size(test_comm,&mpi_size); - MPI_Comm_rank(test_comm,&mpi_rank); + MPI_Comm_size(test_comm, &mpi_size); + MPI_Comm_rank(test_comm, &mpi_rank); fpid = H5Pcreate(H5P_FILE_ACCESS); VRFY((fpid > 0), "H5Pcreate succeeded"); @@ -4882,12 +4842,11 @@ test_dense_attr(void) return; } - int main(int argc, char **argv) { - int express_test; - int mpi_size, mpi_rank; /* mpi variables */ + int express_test; + int mpi_size, mpi_rank; /* mpi variables */ hsize_t oldsize, newsize = 1048576; #ifndef H5_HAVE_WIN32_API @@ -4896,7 +4855,6 @@ main(int argc, char **argv) HDsetbuf(stdout, NULL); #endif - MPI_Init(&argc, &argv); MPI_Comm_size(test_comm, &mpi_size); MPI_Comm_rank(test_comm, &mpi_rank); @@ -4905,7 +4863,7 @@ main(int argc, char **argv) dim1 = BIG_Y_FACTOR; dim2 = BIG_Z_FACTOR; - if (MAINPROCESS){ + if (MAINPROCESS) { HDprintf("===================================\n"); HDprintf("2 GByte IO TESTS START\n"); HDprintf("2 MPI ranks will run the tests...\n"); @@ -4913,7 +4871,7 @@ main(int argc, char **argv) h5_show_hostname(); } - if (H5dont_atexit() < 0){ + if (H5dont_atexit() < 0) { HDprintf("Failed to turn off atexit processing. Continue.\n"); }; H5open(); @@ -4924,52 +4882,46 @@ main(int argc, char **argv) if (mpi_size > 2) { int rank_color = 0; - if (mpi_rank >= 2) rank_color = 1; + if (mpi_rank >= 2) + rank_color = 1; if (MPI_Comm_split(test_comm, rank_color, mpi_rank, &test_comm) != MPI_SUCCESS) { HDprintf("MPI returned an error. Exiting\n"); - } + } } /* Initialize testing framework */ if (mpi_rank < 2) { - TestInit(argv[0], usage, parse_options); + TestInit(argv[0], usage, parse_options); - /* Parse command line arguments */ - TestParseCmdLine(argc, argv); + /* Parse command line arguments */ + TestParseCmdLine(argc, argv); - AddTest("idsetw", dataset_writeInd, NULL, - "dataset independent write", PARATESTFILE); + AddTest("idsetw", dataset_writeInd, NULL, "dataset independent write", PARATESTFILE); - AddTest("idsetr", dataset_readInd, NULL, - "dataset independent read", PARATESTFILE); + AddTest("idsetr", dataset_readInd, NULL, "dataset independent read", PARATESTFILE); - AddTest("cdsetw", dataset_writeAll, NULL, - "dataset collective write", PARATESTFILE); + AddTest("cdsetw", dataset_writeAll, NULL, "dataset collective write", PARATESTFILE); - AddTest("cdsetr", dataset_readAll, NULL, - "dataset collective read", PARATESTFILE); + AddTest("cdsetr", dataset_readAll, NULL, "dataset collective read", PARATESTFILE); - AddTest("eidsetw2", extend_writeInd2, NULL, - "extendible dataset independent write #2", PARATESTFILE); + AddTest("eidsetw2", extend_writeInd2, NULL, "extendible dataset independent write #2", PARATESTFILE); - AddTest("selnone", none_selection_chunk, NULL, - "chunked dataset with none-selection", PARATESTFILE); + AddTest("selnone", none_selection_chunk, NULL, "chunked dataset with none-selection", PARATESTFILE); #ifdef H5_HAVE_FILTER_DEFLATE - AddTest("cmpdsetr", compress_readAll, NULL, - "compressed dataset collective read", PARATESTFILE); + AddTest("cmpdsetr", compress_readAll, NULL, "compressed dataset collective read", PARATESTFILE); #endif /* H5_HAVE_FILTER_DEFLATE */ - /* Display testing information */ - if (MAINPROCESS) - TestInfo(argv[0]); + /* Display testing information */ + if (MAINPROCESS) + TestInfo(argv[0]); - /* setup file access property list */ - fapl = H5Pcreate (H5P_FILE_ACCESS); - H5Pset_fapl_mpio(fapl, test_comm, MPI_INFO_NULL); + /* setup file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_mpio(fapl, test_comm, MPI_INFO_NULL); - /* Perform requested testing */ - PerformTests(); + /* Perform requested testing */ + PerformTests(); } MPI_Barrier(MPI_COMM_WORLD); diff --git a/testpar/t_bigio.c b/testpar/t_bigio.c index f86852a..60faf68 100644 --- a/testpar/t_bigio.c +++ b/testpar/t_bigio.c @@ -1,16 +1,13 @@ #include "hdf5.h" #include "testphdf5.h" -#include "H5Dprivate.h" /* For Chunk tests */ +#include "H5Dprivate.h" /* For Chunk tests */ /* FILENAME and filenames must have the same number of names */ -const char *FILENAME[3]={ "bigio_test.h5", - "single_rank_independent_io.h5", - NULL - }; +const char *FILENAME[3] = {"bigio_test.h5", "single_rank_independent_io.h5", NULL}; /* Constants definitions */ -#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */ +#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */ /* Define some handy debugging shorthands, routines, ... */ /* debugging tools */ @@ -18,70 +15,65 @@ const char *FILENAME[3]={ "bigio_test.h5", #define MAIN_PROCESS (mpi_rank_g == 0) /* define process 0 as main process */ /* Constants definitions */ -#define RANK 2 +#define RANK 2 #define IN_ORDER 1 #define OUT_OF_ORDER 2 -#define DATASET1 "DSET1" -#define DATASET2 "DSET2" -#define DATASET3 "DSET3" -#define DATASET4 "DSET4" -#define DXFER_COLLECTIVE_IO 0x1 /* Collective IO*/ +#define DATASET1 "DSET1" +#define DATASET2 "DSET2" +#define DATASET3 "DSET3" +#define DATASET4 "DSET4" +#define DXFER_COLLECTIVE_IO 0x1 /* Collective IO*/ #define DXFER_INDEPENDENT_IO 0x2 /* Independent IO collectively */ -#define DXFER_BIGCOUNT (1 < 29) -#define LARGE_DIM 1610612736 +#define DXFER_BIGCOUNT (1 < 29) +#define LARGE_DIM 1610612736 #define HYPER 1 #define POINT 2 -#define ALL 3 +#define ALL 3 /* Dataset data type. Int's can be easily octo dumped. */ typedef hsize_t B_DATATYPE; -int facc_type = FACC_MPIO; /*Test file access type */ -int dxfer_coll_type = DXFER_COLLECTIVE_IO; -size_t bigcount = (size_t)DXFER_BIGCOUNT; -int nerrors = 0; +int facc_type = FACC_MPIO; /*Test file access type */ +int dxfer_coll_type = DXFER_COLLECTIVE_IO; +size_t bigcount = (size_t)DXFER_BIGCOUNT; +int nerrors = 0; static int mpi_size_g, mpi_rank_g; hsize_t space_dim1 = SPACE_DIM1 * 256; // 4096 hsize_t space_dim2 = SPACE_DIM2; -static void coll_chunktest(const char* filename, int chunk_factor, int select_factor, - int api_option, int file_selection, int mem_selection, int mode); +static void coll_chunktest(const char *filename, int chunk_factor, int select_factor, int api_option, + int file_selection, int mem_selection, int mode); /* * Setup the coordinates for point selection. */ static void -set_coords(hsize_t start[], - hsize_t count[], - hsize_t stride[], - hsize_t block[], - size_t num_points, - hsize_t coords[], - int order) +set_coords(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], size_t num_points, + hsize_t coords[], int order) { - hsize_t i,j, k = 0, m ,n, s1 ,s2; + hsize_t i, j, k = 0, m, n, s1, s2; - if(OUT_OF_ORDER == order) + if (OUT_OF_ORDER == order) k = (num_points * RANK) - 1; - else if(IN_ORDER == order) + else if (IN_ORDER == order) k = 0; s1 = start[0]; s2 = start[1]; - for(i = 0 ; i < count[0]; i++) - for(j = 0 ; j < count[1]; j++) - for(m = 0 ; m < block[0]; m++) - for(n = 0 ; n < block[1]; n++) - if(OUT_OF_ORDER == order) { + for (i = 0; i < count[0]; i++) + for (j = 0; j < count[1]; j++) + for (m = 0; m < block[0]; m++) + for (n = 0; n < block[1]; n++) + if (OUT_OF_ORDER == order) { coords[k--] = s2 + (stride[1] * j) + n; coords[k--] = s1 + (stride[0] * i) + m; } - else if(IN_ORDER == order) { + else if (IN_ORDER == order) { coords[k++] = s1 + stride[0] * i + m; coords[k++] = s2 + stride[1] * j + n; } @@ -92,63 +84,61 @@ set_coords(hsize_t start[], * Assume dimension rank is 2 and data is stored contiguous. */ static void -fill_datasets(hsize_t start[], hsize_t block[], B_DATATYPE * dataset) +fill_datasets(hsize_t start[], hsize_t block[], B_DATATYPE *dataset) { B_DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* put some trivial data in the data_array */ - for (i=0; i < block[0]; i++){ - for (j=0; j < block[1]; j++){ - *dataptr = (B_DATATYPE)((i+start[0])*100 + (j+start[1]+1)); - dataptr++; - } + for (i = 0; i < block[0]; i++) { + for (j = 0; j < block[1]; j++) { + *dataptr = (B_DATATYPE)((i + start[0]) * 100 + (j + start[1] + 1)); + dataptr++; + } } } /* * Setup the coordinates for point selection. */ -void point_set(hsize_t start[], - hsize_t count[], - hsize_t stride[], - hsize_t block[], - size_t num_points, - hsize_t coords[], - int order) +void +point_set(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], size_t num_points, + hsize_t coords[], int order) { - hsize_t i,j, k = 0, m ,n, s1 ,s2; + hsize_t i, j, k = 0, m, n, s1, s2; HDcompile_assert(RANK == 2); - if(OUT_OF_ORDER == order) + if (OUT_OF_ORDER == order) k = (num_points * RANK) - 1; - else if(IN_ORDER == order) + else if (IN_ORDER == order) k = 0; s1 = start[0]; s2 = start[1]; - for(i = 0 ; i < count[0]; i++) - for(j = 0 ; j < count[1]; j++) - for(m = 0 ; m < block[0]; m++) - for(n = 0 ; n < block[1]; n++) - if(OUT_OF_ORDER == order) { + for (i = 0; i < count[0]; i++) + for (j = 0; j < count[1]; j++) + for (m = 0; m < block[0]; m++) + for (n = 0; n < block[1]; n++) + if (OUT_OF_ORDER == order) { coords[k--] = s2 + (stride[1] * j) + n; coords[k--] = s1 + (stride[0] * i) + m; } - else if(IN_ORDER == order) { + else if (IN_ORDER == order) { coords[k++] = s1 + stride[0] * i + m; coords[k++] = s2 + stride[1] * j + n; } - if(VERBOSE_MED) { - HDprintf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1], - (unsigned long)(block[0] * block[1] * count[0] * count[1])); + if (VERBOSE_MED) { + HDprintf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); k = 0; - for(i = 0; i < num_points ; i++) { + for (i = 0; i < num_points; i++) { HDprintf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); k += 2; } @@ -159,44 +149,45 @@ void point_set(hsize_t start[], * Print the content of the dataset. */ static void -dataset_print(hsize_t start[], hsize_t block[], B_DATATYPE * dataset) +dataset_print(hsize_t start[], hsize_t block[], B_DATATYPE *dataset) { B_DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* print the column heading */ HDprintf("%-8s", "Cols:"); - for (j=0; j < block[1]; j++){ - HDprintf("%3lu ", (unsigned long)(start[1]+j)); + for (j = 0; j < block[1]; j++) { + HDprintf("%3lu ", (unsigned long)(start[1] + j)); } HDprintf("\n"); /* print the slab data */ - for (i=0; i < block[0]; i++){ - HDprintf("Row %2lu: ", (unsigned long)(i+start[0])); - for (j=0; j < block[1]; j++){ - HDprintf("%llu ", *dataptr++); - } - HDprintf("\n"); + for (i = 0; i < block[0]; i++) { + HDprintf("Row %2lu: ", (unsigned long)(i + start[0])); + for (j = 0; j < block[1]; j++) { + HDprintf("%llu ", *dataptr++); + } + HDprintf("\n"); } } - /* * Print the content of the dataset. */ static int -verify_data(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], B_DATATYPE *dataset, B_DATATYPE *original) +verify_data(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], B_DATATYPE *dataset, + B_DATATYPE *original) { hsize_t i, j; - int vrfyerrs; + int vrfyerrs; /* print it if VERBOSE_MED */ - if(VERBOSE_MED) { + if (VERBOSE_MED) { HDprintf("verify_data dumping:::\n"); HDprintf("start(%lu, %lu), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1]); + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1]); HDprintf("original values:\n"); dataset_print(start, block, original); HDprintf("compared values:\n"); @@ -204,147 +195,140 @@ verify_data(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], } vrfyerrs = 0; - for (i=0; i < block[0]; i++){ - for (j=0; j < block[1]; j++){ - if(*dataset != *original){ - if(vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED){ - HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %llu, got %llu\n", - (unsigned long)i, (unsigned long)j, - (unsigned long)(i+start[0]), (unsigned long)(j+start[1]), - *(original), *(dataset)); - } - dataset++; - original++; + for (i = 0; i < block[0]; i++) { + for (j = 0; j < block[1]; j++) { + if (*dataset != *original) { + if (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED) { + HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %llu, got %llu\n", + (unsigned long)i, (unsigned long)j, (unsigned long)(i + start[0]), + (unsigned long)(j + start[1]), *(original), *(dataset)); + } + dataset++; + original++; + } } } - } - if(vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) + if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) HDprintf("[more errors ...]\n"); - if(vrfyerrs) + if (vrfyerrs) HDprintf("%d errors found in verify_data\n", vrfyerrs); - return(vrfyerrs); + return (vrfyerrs); } /* Set up the selection */ static void -ccslab_set(int mpi_rank, - int mpi_size, - hsize_t start[], - hsize_t count[], - hsize_t stride[], - hsize_t block[], - int mode) +ccslab_set(int mpi_rank, int mpi_size, hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], + int mode) { - switch (mode){ - - case BYROW_CONT: - /* Each process takes a slabs of rows. */ - block[0] = 1; - block[1] = 1; - stride[0] = 1; - stride[1] = 1; - count[0] = space_dim1; - count[1] = space_dim2; - start[0] = (hsize_t)mpi_rank*count[0]; - start[1] = 0; - - break; - - case BYROW_DISCONT: - /* Each process takes several disjoint blocks. */ - block[0] = 1; - block[1] = 1; - stride[0] = 3; - stride[1] = 3; - count[0] = space_dim1/(stride[0]*block[0]); - count[1] = (space_dim2)/(stride[1]*block[1]); - start[0] = space_dim1*(hsize_t)mpi_rank; - start[1] = 0; - - break; - - case BYROW_SELECTNONE: - /* Each process takes a slabs of rows, there are - no selections for the last process. */ - block[0] = 1; - block[1] = 1; - stride[0] = 1; - stride[1] = 1; - count[0] = ((mpi_rank >= MAX(1,(mpi_size-2)))?0:space_dim1); - count[1] = space_dim2; - start[0] = (hsize_t)mpi_rank*count[0]; - start[1] = 0; - - break; - - case BYROW_SELECTUNBALANCE: - /* The first one-third of the number of processes only - select top half of the domain, The rest will select the bottom - half of the domain. */ - - block[0] = 1; - count[0] = 2; - stride[0] = (hsize_t)(space_dim1*(hsize_t)mpi_size/4+1); - block[1] = space_dim2; - count[1] = 1; - start[1] = 0; - stride[1] = 1; - if((mpi_rank *3)<(mpi_size*2)) start[0] = (hsize_t)mpi_rank; - else start[0] = 1 + space_dim1*(hsize_t)mpi_size/2 + (hsize_t)(mpi_rank-2*mpi_size/3); - break; - - case BYROW_SELECTINCHUNK: - /* Each process will only select one chunk */ - - block[0] = 1; - count[0] = 1; - start[0] = (hsize_t)mpi_rank*space_dim1; - stride[0]= 1; - block[1] = space_dim2; - count[1] = 1; - stride[1]= 1; - start[1] = 0; - - break; - - default: - /* Unknown mode. Set it to cover the whole dataset. */ - block[0] = space_dim1*(hsize_t)mpi_size; - block[1] = space_dim2; - stride[0] = block[0]; - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = 0; - - break; + switch (mode) { + + case BYROW_CONT: + /* Each process takes a slabs of rows. */ + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = space_dim1; + count[1] = space_dim2; + start[0] = (hsize_t)mpi_rank * count[0]; + start[1] = 0; + + break; + + case BYROW_DISCONT: + /* Each process takes several disjoint blocks. */ + block[0] = 1; + block[1] = 1; + stride[0] = 3; + stride[1] = 3; + count[0] = space_dim1 / (stride[0] * block[0]); + count[1] = (space_dim2) / (stride[1] * block[1]); + start[0] = space_dim1 * (hsize_t)mpi_rank; + start[1] = 0; + + break; + + case BYROW_SELECTNONE: + /* Each process takes a slabs of rows, there are + no selections for the last process. */ + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = ((mpi_rank >= MAX(1, (mpi_size - 2))) ? 0 : space_dim1); + count[1] = space_dim2; + start[0] = (hsize_t)mpi_rank * count[0]; + start[1] = 0; + + break; + + case BYROW_SELECTUNBALANCE: + /* The first one-third of the number of processes only + select top half of the domain, The rest will select the bottom + half of the domain. */ + + block[0] = 1; + count[0] = 2; + stride[0] = (hsize_t)(space_dim1 * (hsize_t)mpi_size / 4 + 1); + block[1] = space_dim2; + count[1] = 1; + start[1] = 0; + stride[1] = 1; + if ((mpi_rank * 3) < (mpi_size * 2)) + start[0] = (hsize_t)mpi_rank; + else + start[0] = 1 + space_dim1 * (hsize_t)mpi_size / 2 + (hsize_t)(mpi_rank - 2 * mpi_size / 3); + break; + + case BYROW_SELECTINCHUNK: + /* Each process will only select one chunk */ + + block[0] = 1; + count[0] = 1; + start[0] = (hsize_t)mpi_rank * space_dim1; + stride[0] = 1; + block[1] = space_dim2; + count[1] = 1; + stride[1] = 1; + start[1] = 0; + + break; + + default: + /* Unknown mode. Set it to cover the whole dataset. */ + block[0] = space_dim1 * (hsize_t)mpi_size; + block[1] = space_dim2; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = 0; + + break; } - if (VERBOSE_MED){ - HDprintf("start[]=(%lu,%lu), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1], - (unsigned long)(block[0]*block[1]*count[0]*count[1])); + if (VERBOSE_MED) { + HDprintf("start[]=(%lu,%lu), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); } } - /* * Fill the dataset with trivial data for testing. * Assume dimension rank is 2. */ static void -ccdataset_fill(hsize_t start[], - hsize_t stride[], - hsize_t count[], - hsize_t block[], - DATATYPE * dataset, +ccdataset_fill(hsize_t start[], hsize_t stride[], hsize_t count[], hsize_t block[], DATATYPE *dataset, int mem_selection) { DATATYPE *dataptr = dataset; DATATYPE *tmptr; - hsize_t i,j,k1,k2,k=0; + hsize_t i, j, k1, k2, k = 0; /* put some trivial data in the data_array */ tmptr = dataptr; @@ -352,23 +336,23 @@ ccdataset_fill(hsize_t start[], through the pointer */ for (k1 = 0; k1 < count[0]; k1++) { - for(i = 0; i < block[0]; i++) { - for(k2 = 0; k2 < count[1]; k2++) { - for(j = 0;j < block[1]; j++) { + for (i = 0; i < block[0]; i++) { + for (k2 = 0; k2 < count[1]; k2++) { + for (j = 0; j < block[1]; j++) { - if (ALL != mem_selection) { - dataptr = tmptr + ((start[0]+k1*stride[0]+i)*space_dim2+ - start[1]+k2*stride[1]+j); - } - else { - dataptr = tmptr + k; - k++; - } + if (ALL != mem_selection) { + dataptr = tmptr + ((start[0] + k1 * stride[0] + i) * space_dim2 + start[1] + + k2 * stride[1] + j); + } + else { + dataptr = tmptr + k; + k++; + } - *dataptr = (DATATYPE)(k1+k2+i+j); - } + *dataptr = (DATATYPE)(k1 + k2 + i + j); + } + } } - } } } @@ -376,26 +360,24 @@ ccdataset_fill(hsize_t start[], * Print the first block of the content of the dataset. */ static void -ccdataset_print(hsize_t start[], - hsize_t block[], - DATATYPE * dataset) +ccdataset_print(hsize_t start[], hsize_t block[], DATATYPE *dataset) { DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* print the column heading */ HDprintf("Print only the first block of the dataset\n"); HDprintf("%-8s", "Cols:"); - for (j=0; j < block[1]; j++){ - HDprintf("%3lu ", (unsigned long)(start[1]+j)); + for (j = 0; j < block[1]; j++) { + HDprintf("%3lu ", (unsigned long)(start[1] + j)); } HDprintf("\n"); /* print the slab data */ - for (i=0; i < block[0]; i++){ - HDprintf("Row %2lu: ", (unsigned long)(i+start[0])); - for (j=0; j < block[1]; j++){ + for (i = 0; i < block[0]; i++) { + HDprintf("Row %2lu: ", (unsigned long)(i + start[0])); + for (j = 0; j < block[1]; j++) { HDprintf("%03d ", *dataptr++); } HDprintf("\n"); @@ -406,24 +388,20 @@ ccdataset_print(hsize_t start[], * Print the content of the dataset. */ static int -ccdataset_vrfy(hsize_t start[], - hsize_t count[], - hsize_t stride[], - hsize_t block[], - DATATYPE *dataset, - DATATYPE *original, - int mem_selection) +ccdataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, + DATATYPE *original, int mem_selection) { - hsize_t i, j,k1,k2,k=0; - int vrfyerrs; - DATATYPE *dataptr,*oriptr; + hsize_t i, j, k1, k2, k = 0; + int vrfyerrs; + DATATYPE *dataptr, *oriptr; /* print it if VERBOSE_MED */ if (VERBOSE_MED) { HDprintf("dataset_vrfy dumping:::\n"); HDprintf("start(%lu, %lu), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1]); + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1]); HDprintf("original values:\n"); ccdataset_print(start, block, original); HDprintf("compared values:\n"); @@ -432,26 +410,25 @@ ccdataset_vrfy(hsize_t start[], vrfyerrs = 0; - for (k1=0;k1= 0), "H5P_FILE_ACCESS"); H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); @@ -512,7 +488,6 @@ dataset_big_write(void) ret = H5Pclose(acc_tpl); VRFY_G((ret >= 0), ""); - /* Each process takes a slabs of rows. */ if (mpi_rank_g == 0) HDprintf("\nTesting Dataset1 write by ROW\n"); @@ -520,51 +495,50 @@ dataset_big_write(void) dims[0] = bigcount; dims[1] = (hsize_t)mpi_size_g; - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY_G((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET1, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dcreate2 succeeded"); H5Sclose(sid); - block[0] = dims[0]/(hsize_t)mpi_size_g; - block[1] = dims[1]; + block[0] = dims[0] / (hsize_t)mpi_size_g; + block[1] = dims[1]; stride[0] = block[0]; stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)mpi_rank_g*block[0]; - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)mpi_rank_g * block[0]; + start[1] = 0; /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset); + file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY_G((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY_G((mem_dataspace >= 0), ""); /* fill the local slab with some trivial data */ fill_datasets(start, block, wdata); MESG("data_array initialized"); - if(VERBOSE_MED){ + if (VERBOSE_MED) { MESG("data_array created"); dataset_print(start, block, wdata); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } - ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, - xfer_plist, wdata); + ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, wdata); VRFY_G((ret >= 0), "H5Dwrite dataset1 succeeded"); /* release all temporary handles. */ @@ -575,7 +549,6 @@ dataset_big_write(void) ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); - /* Each process takes a slabs of cols. */ if (mpi_rank_g == 0) HDprintf("\nTesting Dataset2 write by COL\n"); @@ -583,51 +556,50 @@ dataset_big_write(void) dims[0] = bigcount; dims[1] = (hsize_t)mpi_size_g; - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY_G((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET2, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dcreate2 succeeded"); H5Sclose(sid); - block[0] = dims[0]; - block[1] = dims[1]/(hsize_t)mpi_size_g; + block[0] = dims[0]; + block[1] = dims[1] / (hsize_t)mpi_size_g; stride[0] = block[0]; stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = (hsize_t)mpi_rank_g*block[1]; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = (hsize_t)mpi_rank_g * block[1]; /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset); + file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY_G((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY_G((mem_dataspace >= 0), ""); /* fill the local slab with some trivial data */ fill_datasets(start, block, wdata); MESG("data_array initialized"); - if(VERBOSE_MED){ + if (VERBOSE_MED) { MESG("data_array created"); dataset_print(start, block, wdata); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } - ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, - xfer_plist, wdata); + ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, wdata); VRFY_G((ret >= 0), "H5Dwrite dataset1 succeeded"); /* release all temporary handles. */ @@ -638,8 +610,6 @@ dataset_big_write(void) ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); - - /* ALL selection */ if (mpi_rank_g == 0) HDprintf("\nTesting Dataset3 write select ALL proc 0, NONE others\n"); @@ -647,16 +617,16 @@ dataset_big_write(void) dims[0] = bigcount; dims[1] = 1; - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY_G((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET3, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dcreate2 succeeded"); H5Sclose(sid); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset); + file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); - if(mpi_rank_g == 0) { + if (mpi_rank_g == 0) { ret = H5Sselect_all(file_dataspace); VRFY_G((ret >= 0), "H5Sset_all succeeded"); } @@ -666,32 +636,31 @@ dataset_big_write(void) } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, dims, NULL); + mem_dataspace = H5Screate_simple(RANK, dims, NULL); VRFY_G((mem_dataspace >= 0), ""); - if(mpi_rank_g != 0) { + if (mpi_rank_g != 0) { ret = H5Sselect_none(mem_dataspace); VRFY_G((ret >= 0), "H5Sset_none succeeded"); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* fill the local slab with some trivial data */ fill_datasets(start, dims, wdata); MESG("data_array initialized"); - if(VERBOSE_MED){ + if (VERBOSE_MED) { MESG("data_array created"); } - ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, - xfer_plist, wdata); + ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, wdata); VRFY_G((ret >= 0), "H5Dwrite dataset1 succeeded"); /* release all temporary handles. */ @@ -709,38 +678,39 @@ dataset_big_write(void) dims[0] = bigcount; dims[1] = (hsize_t)(mpi_size_g * 4); - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY_G((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET4, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dcreate2 succeeded"); H5Sclose(sid); - block[0] = dims[0]/2; - block[1] = 2; - stride[0] = dims[0]/2; + block[0] = dims[0] / 2; + block[1] = 2; + stride[0] = dims[0] / 2; stride[1] = 2; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = dims[1]/(hsize_t)mpi_size_g * (hsize_t)mpi_rank_g; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = dims[1] / (hsize_t)mpi_size_g * (hsize_t)mpi_rank_g; num_points = bigcount; coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); VRFY_G((coords != NULL), "coords malloc succeeded"); - set_coords (start, count, stride, block, num_points, coords, IN_ORDER); + set_coords(start, count, stride, block, num_points, coords, IN_ORDER); /* create a file dataspace */ - file_dataspace = H5Dget_space (dataset); + file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY_G((ret >= 0), "H5Sselect_elements succeeded"); - if(coords) free(coords); + if (coords) + free(coords); fill_datasets(start, block, wdata); MESG("data_array initialized"); - if(VERBOSE_MED){ + if (VERBOSE_MED) { MESG("data_array created"); dataset_print(start, block, wdata); } @@ -750,21 +720,20 @@ dataset_big_write(void) * even if we only pass only a single value. Attempting anything else * appears to cause problems with 32 bit compilers. */ - mem_dataspace = H5Screate_simple (1, dims, NULL); + mem_dataspace = H5Screate_simple(1, dims, NULL); VRFY_G((mem_dataspace >= 0), ""); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } - ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, - xfer_plist, wdata); + ret = H5Dwrite(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, wdata); VRFY_G((ret >= 0), "H5Dwrite dataset1 succeeded"); /* release all temporary handles. */ @@ -791,37 +760,37 @@ dataset_big_write(void) static void dataset_big_read(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset; - B_DATATYPE *rdata = NULL; /* data buffer */ - B_DATATYPE *wdata = NULL; /* expected data buffer */ - hsize_t dims[RANK]; /* dataset dim sizes */ - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ - size_t num_points; - hsize_t *coords = NULL; - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset; + B_DATATYPE *rdata = NULL; /* data buffer */ + B_DATATYPE *wdata = NULL; /* expected data buffer */ + hsize_t dims[RANK]; /* dataset dim sizes */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ + size_t num_points; + hsize_t * coords = NULL; + herr_t ret; /* Generic return value */ /* allocate memory for data buffer */ - rdata = (B_DATATYPE *)HDmalloc(bigcount*sizeof(B_DATATYPE)); + rdata = (B_DATATYPE *)HDmalloc(bigcount * sizeof(B_DATATYPE)); VRFY_G((rdata != NULL), "rdata malloc succeeded"); - wdata = (B_DATATYPE *)HDmalloc(bigcount*sizeof(B_DATATYPE)); + wdata = (B_DATATYPE *)HDmalloc(bigcount * sizeof(B_DATATYPE)); VRFY_G((wdata != NULL), "wdata malloc succeeded"); - HDmemset(rdata, 0, bigcount*sizeof(B_DATATYPE)); + HDmemset(rdata, 0, bigcount * sizeof(B_DATATYPE)); /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); + acc_tpl = H5Pcreate(H5P_FILE_ACCESS); VRFY_G((acc_tpl >= 0), "H5P_FILE_ACCESS"); H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); /* open the file collectively */ - fid=H5Fopen(FILENAME[0],H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(FILENAME[0], H5F_ACC_RDONLY, acc_tpl); VRFY_G((fid >= 0), "H5Fopen succeeded"); /* Release file-access template */ @@ -837,50 +806,52 @@ dataset_big_read(void) dims[0] = bigcount; dims[1] = (hsize_t)mpi_size_g; /* Each process takes a slabs of cols. */ - block[0] = dims[0]; - block[1] = dims[1]/(hsize_t)mpi_size_g; + block[0] = dims[0]; + block[1] = dims[1] / (hsize_t)mpi_size_g; stride[0] = block[0]; stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = (hsize_t)mpi_rank_g*block[1]; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = (hsize_t)mpi_rank_g * block[1]; /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset); + file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY_G((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY_G((mem_dataspace >= 0), ""); /* fill dataset with test data */ fill_datasets(start, block, wdata); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); + if (VERBOSE_MED) { + MESG("data_array created"); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, - xfer_plist, rdata); + ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, rdata); VRFY_G((ret >= 0), "H5Dread dataset1 succeeded"); /* verify the read data with original expected data */ ret = verify_data(start, count, stride, block, rdata, wdata); - if(ret) {HDfprintf(stderr, "verify failed\n"); exit(1);} + if (ret) { + HDfprintf(stderr, "verify failed\n"); + exit(1); + } /* release all temporary handles. */ H5Sclose(file_dataspace); @@ -889,60 +860,61 @@ dataset_big_read(void) ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); - if (mpi_rank_g == 0) HDprintf("\nRead Testing Dataset2 by ROW\n"); - HDmemset(rdata, 0, bigcount*sizeof(B_DATATYPE)); + HDmemset(rdata, 0, bigcount * sizeof(B_DATATYPE)); dataset = H5Dopen2(fid, DATASET2, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dopen2 succeeded"); dims[0] = bigcount; dims[1] = (hsize_t)mpi_size_g; /* Each process takes a slabs of rows. */ - block[0] = dims[0]/(hsize_t)mpi_size_g; - block[1] = dims[1]; + block[0] = dims[0] / (hsize_t)mpi_size_g; + block[1] = dims[1]; stride[0] = block[0]; stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)mpi_rank_g*block[0]; - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)mpi_rank_g * block[0]; + start[1] = 0; /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset); + file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY_G((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY_G((mem_dataspace >= 0), ""); /* fill dataset with test data */ fill_datasets(start, block, wdata); MESG("data_array initialized"); - if(VERBOSE_MED){ + if (VERBOSE_MED) { MESG("data_array created"); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, - xfer_plist, rdata); + ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, rdata); VRFY_G((ret >= 0), "H5Dread dataset2 succeeded"); /* verify the read data with original expected data */ ret = verify_data(start, count, stride, block, rdata, wdata); - if(ret) {HDfprintf(stderr, "verify failed\n"); exit(1);} + if (ret) { + HDfprintf(stderr, "verify failed\n"); + exit(1); + } /* release all temporary handles. */ H5Sclose(file_dataspace); @@ -953,7 +925,7 @@ dataset_big_read(void) if (mpi_rank_g == 0) HDprintf("\nRead Testing Dataset3 read select ALL proc 0, NONE others\n"); - HDmemset(rdata, 0, bigcount*sizeof(B_DATATYPE)); + HDmemset(rdata, 0, bigcount * sizeof(B_DATATYPE)); dataset = H5Dopen2(fid, DATASET3, H5P_DEFAULT); VRFY_G((dataset >= 0), "H5Dopen2 succeeded"); @@ -961,9 +933,9 @@ dataset_big_read(void) dims[1] = 1; /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset); + file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); - if(mpi_rank_g == 0) { + if (mpi_rank_g == 0) { ret = H5Sselect_all(file_dataspace); VRFY_G((ret >= 0), "H5Sset_all succeeded"); } @@ -973,9 +945,9 @@ dataset_big_read(void) } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, dims, NULL); + mem_dataspace = H5Screate_simple(RANK, dims, NULL); VRFY_G((mem_dataspace >= 0), ""); - if(mpi_rank_g != 0) { + if (mpi_rank_g != 0) { ret = H5Sselect_none(mem_dataspace); VRFY_G((ret >= 0), "H5Sset_none succeeded"); } @@ -983,29 +955,31 @@ dataset_big_read(void) /* fill dataset with test data */ fill_datasets(start, dims, wdata); MESG("data_array initialized"); - if(VERBOSE_MED){ + if (VERBOSE_MED) { MESG("data_array created"); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, - xfer_plist, rdata); + ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, rdata); VRFY_G((ret >= 0), "H5Dread dataset3 succeeded"); - if(mpi_rank_g == 0) { + if (mpi_rank_g == 0) { /* verify the read data with original expected data */ ret = verify_data(start, count, stride, block, rdata, wdata); - if(ret) {HDfprintf(stderr, "verify failed\n"); exit(1);} + if (ret) { + HDfprintf(stderr, "verify failed\n"); + exit(1); + } } /* release all temporary handles. */ @@ -1023,18 +997,18 @@ dataset_big_read(void) dims[0] = bigcount; dims[1] = (hsize_t)(mpi_size_g * 4); - block[0] = dims[0]/2; - block[1] = 2; - stride[0] = dims[0]/2; + block[0] = dims[0] / 2; + block[1] = 2; + stride[0] = dims[0] / 2; stride[1] = 2; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = dims[1]/(hsize_t)mpi_size_g * (hsize_t)mpi_rank_g; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = dims[1] / (hsize_t)mpi_size_g * (hsize_t)mpi_rank_g; fill_datasets(start, block, wdata); MESG("data_array initialized"); - if(VERBOSE_MED){ + if (VERBOSE_MED) { MESG("data_array created"); dataset_print(start, block, wdata); } @@ -1044,40 +1018,43 @@ dataset_big_read(void) coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); VRFY_G((coords != NULL), "coords malloc succeeded"); - set_coords (start, count, stride, block, num_points, coords, IN_ORDER); + set_coords(start, count, stride, block, num_points, coords, IN_ORDER); /* create a file dataspace */ - file_dataspace = H5Dget_space (dataset); + file_dataspace = H5Dget_space(dataset); VRFY_G((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY_G((ret >= 0), "H5Sselect_elements succeeded"); - if(coords) HDfree(coords); + if (coords) + HDfree(coords); /* create a memory dataspace */ /* Warning: H5Screate_simple requires an array of hsize_t elements * even if we only pass only a single value. Attempting anything else * appears to cause problems with 32 bit compilers. */ - mem_dataspace = H5Screate_simple (1, dims, NULL); + mem_dataspace = H5Screate_simple(1, dims, NULL); VRFY_G((mem_dataspace >= 0), ""); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY_G((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY_G((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, - xfer_plist, rdata); + ret = H5Dread(dataset, H5T_NATIVE_LLONG, mem_dataspace, file_dataspace, xfer_plist, rdata); VRFY_G((ret >= 0), "H5Dread dataset1 succeeded"); ret = verify_data(start, count, stride, block, rdata, wdata); - if(ret) {HDfprintf(stderr, "verify failed\n"); exit(1);} + if (ret) { + HDfprintf(stderr, "verify failed\n"); + exit(1); + } /* release all temporary handles. */ H5Sclose(file_dataspace); @@ -1095,14 +1072,17 @@ dataset_big_read(void) * expect to read it... */ file_dataspace = -1; - mem_dataspace = -1; - xfer_plist = -1; - dataset = -1; + mem_dataspace = -1; + xfer_plist = -1; + dataset = -1; /* release all temporary handles. */ - if (file_dataspace != -1) H5Sclose(file_dataspace); - if (mem_dataspace != -1) H5Sclose(mem_dataspace); - if (xfer_plist != -1) H5Pclose(xfer_plist); + if (file_dataspace != -1) + H5Sclose(file_dataspace); + if (mem_dataspace != -1) + H5Sclose(mem_dataspace); + if (xfer_plist != -1) + H5Pclose(xfer_plist); if (dataset != -1) { ret = H5Dclose(dataset); VRFY_G((ret >= 0), "H5Dclose1 succeeded"); @@ -1110,8 +1090,10 @@ dataset_big_read(void) H5Fclose(fid); /* release data buffers */ - if(rdata) HDfree(rdata); - if(wdata) HDfree(wdata); + if (rdata) + HDfree(rdata); + if (wdata) + HDfree(wdata); } /* dataset_large_readAll */ @@ -1122,13 +1104,13 @@ single_rank_independent_io(void) HDprintf("single_rank_independent_io\n"); if (MAIN_PROCESS) { - hsize_t dims[] = { LARGE_DIM }; - hid_t file_id = -1; - hid_t fapl_id = -1; - hid_t dset_id = -1; - hid_t fspace_id = -1; - hid_t mspace_id = -1; - void *data = NULL; + hsize_t dims[] = {LARGE_DIM}; + hid_t file_id = -1; + hid_t fapl_id = -1; + hid_t dset_id = -1; + hid_t fspace_id = -1; + hid_t mspace_id = -1; + void * data = NULL; fapl_id = H5Pcreate(H5P_FILE_ACCESS); VRFY_G((fapl_id >= 0), "H5P_FILE_ACCESS"); @@ -1143,8 +1125,8 @@ single_rank_independent_io(void) /* * Create and write to a >2GB dataset from a single rank. */ - dset_id = H5Dcreate2(file_id, "test_dset", H5T_NATIVE_INT, fspace_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, "test_dset", H5T_NATIVE_INT, fspace_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); VRFY_G((dset_id >= 0), "H5Dcreate2 succeeded"); @@ -1155,7 +1137,7 @@ single_rank_independent_io(void) else H5Sselect_none(fspace_id); - dims[0] = LARGE_DIM; + dims[0] = LARGE_DIM; mspace_id = H5Screate_simple(1, dims, NULL); VRFY_G((mspace_id >= 0), "H5Screate_simple mspace_id succeeded"); H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); @@ -1168,7 +1150,6 @@ single_rank_independent_io(void) H5Fclose(file_id); HDremove(FILENAME[1]); - } MPI_Barrier(MPI_COMM_WORLD); } @@ -1179,54 +1160,53 @@ single_rank_independent_io(void) hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) { - hid_t ret_pl = -1; - herr_t ret; /* generic return value */ - int mpi_rank; /* mpi variables */ + hid_t ret_pl = -1; + herr_t ret; /* generic return value */ + int mpi_rank; /* mpi variables */ /* need the rank for error checking macros */ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - ret_pl = H5Pcreate (H5P_FILE_ACCESS); + ret_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY_G((ret_pl >= 0), "H5P_FILE_ACCESS"); if (l_facc_type == FACC_DEFAULT) - return (ret_pl); + return (ret_pl); - if (l_facc_type == FACC_MPIO){ - /* set Parallel access with communicator */ - ret = H5Pset_fapl_mpio(ret_pl, comm, info); - VRFY_G((ret >= 0), ""); + if (l_facc_type == FACC_MPIO) { + /* set Parallel access with communicator */ + ret = H5Pset_fapl_mpio(ret_pl, comm, info); + VRFY_G((ret >= 0), ""); ret = H5Pset_all_coll_metadata_ops(ret_pl, TRUE); - VRFY_G((ret >= 0), ""); + VRFY_G((ret >= 0), ""); ret = H5Pset_coll_metadata_write(ret_pl, TRUE); - VRFY_G((ret >= 0), ""); - return(ret_pl); + VRFY_G((ret >= 0), ""); + return (ret_pl); } - if (l_facc_type == (FACC_MPIO | FACC_SPLIT)){ - hid_t mpio_pl; - - mpio_pl = H5Pcreate (H5P_FILE_ACCESS); - VRFY_G((mpio_pl >= 0), ""); - /* set Parallel access with communicator */ - ret = H5Pset_fapl_mpio(mpio_pl, comm, info); - VRFY_G((ret >= 0), ""); - - /* setup file access template */ - ret_pl = H5Pcreate (H5P_FILE_ACCESS); - VRFY_G((ret_pl >= 0), ""); - /* set Parallel access with communicator */ - ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); - VRFY_G((ret >= 0), "H5Pset_fapl_split succeeded"); - H5Pclose(mpio_pl); - return(ret_pl); + if (l_facc_type == (FACC_MPIO | FACC_SPLIT)) { + hid_t mpio_pl; + + mpio_pl = H5Pcreate(H5P_FILE_ACCESS); + VRFY_G((mpio_pl >= 0), ""); + /* set Parallel access with communicator */ + ret = H5Pset_fapl_mpio(mpio_pl, comm, info); + VRFY_G((ret >= 0), ""); + + /* setup file access template */ + ret_pl = H5Pcreate(H5P_FILE_ACCESS); + VRFY_G((ret_pl >= 0), ""); + /* set Parallel access with communicator */ + ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); + VRFY_G((ret >= 0), "H5Pset_fapl_split succeeded"); + H5Pclose(mpio_pl); + return (ret_pl); } /* unknown file access types */ return (ret_pl); } - /*------------------------------------------------------------------------- * Function: coll_chunk1 * @@ -1280,7 +1260,6 @@ coll_chunk1(void) coll_chunktest(filename, 1, BYROW_CONT, API_NONE, POINT, HYPER, IN_ORDER); } - /*------------------------------------------------------------------------- * Function: coll_chunk2 * @@ -1299,7 +1278,7 @@ coll_chunk1(void) *------------------------------------------------------------------------- */ - /* ------------------------------------------------------------------------ +/* ------------------------------------------------------------------------ * Descriptions for the selection: many disjoint selections inside one chunk * Two dimensions, * @@ -1334,7 +1313,6 @@ coll_chunk2(void) coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, POINT, HYPER, IN_ORDER); } - /*------------------------------------------------------------------------- * Function: coll_chunk3 * @@ -1389,7 +1367,6 @@ coll_chunk3(void) coll_chunktest(filename, mpi_size_g, BYROW_CONT, API_NONE, POINT, HYPER, IN_ORDER); } - //------------------------------------------------------------------------- // Borrowed/Modified (slightly) from t_coll_chunk.c /*------------------------------------------------------------------------- @@ -1420,454 +1397,450 @@ coll_chunk3(void) */ static void -coll_chunktest(const char* filename, - int chunk_factor, - int select_factor, - int api_option, - int file_selection, - int mem_selection, - int mode) +coll_chunktest(const char *filename, int chunk_factor, int select_factor, int api_option, int file_selection, + int mem_selection, int mode) { - hid_t file, dataset, file_dataspace, mem_dataspace; - hid_t acc_plist,xfer_plist,crp_plist; + hid_t file, dataset, file_dataspace, mem_dataspace; + hid_t acc_plist, xfer_plist, crp_plist; - hsize_t dims[RANK], chunk_dims[RANK]; - int* data_array1 = NULL; - int* data_origin1 = NULL; + hsize_t dims[RANK], chunk_dims[RANK]; + int * data_array1 = NULL; + int * data_origin1 = NULL; - hsize_t start[RANK],count[RANK],stride[RANK],block[RANK]; + hsize_t start[RANK], count[RANK], stride[RANK], block[RANK]; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - unsigned prop_value; + unsigned prop_value; #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - herr_t status; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - - size_t num_points; /* for point selection */ - hsize_t *coords = NULL; /* for point selection */ - - /* Create the data space */ - - acc_plist = create_faccess_plist(comm,info,facc_type); - VRFY_G((acc_plist >= 0),""); - - file = H5Fcreate(filename,H5F_ACC_TRUNC,H5P_DEFAULT,acc_plist); - VRFY_G((file >= 0),"H5Fcreate succeeded"); - - status = H5Pclose(acc_plist); - VRFY_G((status >= 0),""); - - /* setup dimensionality object */ - dims[0] = space_dim1*(hsize_t)mpi_size_g; - dims[1] = space_dim2; - - /* allocate memory for data buffer */ - data_array1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); - VRFY_G((data_array1 != NULL), "data_array1 malloc succeeded"); - - /* set up dimensions of the slab this process accesses */ - ccslab_set(mpi_rank_g, mpi_size_g, start, count, stride, block, select_factor); - - /* set up the coords array selection */ - num_points = block[0] * block[1] * count[0] * count[1]; - coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); - VRFY_G((coords != NULL), "coords malloc succeeded"); - point_set(start, count, stride, block, num_points, coords, mode); - - /* Warning: H5Screate_simple requires an array of hsize_t elements - * even if we only pass only a single value. Attempting anything else - * appears to cause problems with 32 bit compilers. - */ - file_dataspace = H5Screate_simple(2, dims, NULL); - VRFY_G((file_dataspace >= 0), "file dataspace created succeeded"); - - if(ALL != mem_selection) { - mem_dataspace = H5Screate_simple(2, dims, NULL); - VRFY_G((mem_dataspace >= 0), "mem dataspace created succeeded"); - } - else { - /* Putting the warning about H5Screate_simple (above) into practice... */ - hsize_t dsdims[1] = {num_points}; - mem_dataspace = H5Screate_simple (1, dsdims, NULL); - VRFY_G((mem_dataspace >= 0), "mem_dataspace create succeeded"); - } - - crp_plist = H5Pcreate(H5P_DATASET_CREATE); - VRFY_G((crp_plist >= 0),""); - - /* Set up chunk information. */ - chunk_dims[0] = dims[0]/(hsize_t)chunk_factor; - - /* to decrease the testing time, maintain bigger chunk size */ - (chunk_factor == 1) ? (chunk_dims[1] = space_dim2) : (chunk_dims[1] = space_dim2/2); - status = H5Pset_chunk(crp_plist, 2, chunk_dims); - VRFY_G((status >= 0),"chunk creation property list succeeded"); - - dataset = H5Dcreate2(file, DSET_COLLECTIVE_CHUNK_NAME, H5T_NATIVE_INT, - file_dataspace, H5P_DEFAULT, crp_plist, H5P_DEFAULT); - VRFY_G((dataset >= 0),"dataset created succeeded"); - - status = H5Pclose(crp_plist); - VRFY_G((status >= 0), ""); - - /*put some trivial data in the data array */ - ccdataset_fill(start, stride, count,block, data_array1, mem_selection); - - MESG("data_array initialized"); - - switch (file_selection) { - case HYPER: - status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY_G((status >= 0),"hyperslab selection succeeded"); - break; - - case POINT: - if (num_points) { - status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); - VRFY_G((status >= 0),"Element selection succeeded"); - } - else { - status = H5Sselect_none(file_dataspace); - VRFY_G((status >= 0),"none selection succeeded"); - } - break; - - case ALL: - status = H5Sselect_all(file_dataspace); - VRFY_G((status >= 0), "H5Sselect_all succeeded"); - break; - } - - switch (mem_selection) { - case HYPER: - status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY_G((status >= 0),"hyperslab selection succeeded"); - break; - - case POINT: - if (num_points) { - status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); - VRFY_G((status >= 0),"Element selection succeeded"); - } - else { - status = H5Sselect_none(mem_dataspace); - VRFY_G((status >= 0),"none selection succeeded"); - } - break; - - case ALL: - status = H5Sselect_all(mem_dataspace); - VRFY_G((status >= 0), "H5Sselect_all succeeded"); - break; - } - - /* set up the collective transfer property list */ - xfer_plist = H5Pcreate(H5P_DATASET_XFER); - VRFY_G((xfer_plist >= 0), ""); - - status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); - VRFY_G((status>= 0),"MPIO collective transfer property succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - status = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((status>= 0),"set independent IO collectively succeeded"); - } - - switch(api_option){ - case API_LINK_HARD: - status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist,H5FD_MPIO_CHUNK_ONE_IO); - VRFY_G((status>= 0),"collective chunk optimization succeeded"); - break; - - case API_MULTI_HARD: - status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist,H5FD_MPIO_CHUNK_MULTI_IO); - VRFY_G((status>= 0),"collective chunk optimization succeeded "); - break; - - case API_LINK_TRUE: - status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist,2); - VRFY_G((status>= 0),"collective chunk optimization set chunk number succeeded"); - break; - - case API_LINK_FALSE: - status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist,6); - VRFY_G((status>= 0),"collective chunk optimization set chunk number succeeded"); - break; - - case API_MULTI_COLL: - status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist,8);/* make sure it is using multi-chunk IO */ - VRFY_G((status>= 0),"collective chunk optimization set chunk number succeeded"); - status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist,50); - VRFY_G((status>= 0),"collective chunk optimization set chunk ratio succeeded"); - break; - - case API_MULTI_IND: - status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist,8);/* make sure it is using multi-chunk IO */ - VRFY_G((status>= 0),"collective chunk optimization set chunk number succeeded"); - status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist,100); - VRFY_G((status>= 0),"collective chunk optimization set chunk ratio succeeded"); - break; - - default: - ; - } + herr_t status; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + size_t num_points; /* for point selection */ + hsize_t *coords = NULL; /* for point selection */ + + /* Create the data space */ + + acc_plist = create_faccess_plist(comm, info, facc_type); + VRFY_G((acc_plist >= 0), ""); + + file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_plist); + VRFY_G((file >= 0), "H5Fcreate succeeded"); + + status = H5Pclose(acc_plist); + VRFY_G((status >= 0), ""); + + /* setup dimensionality object */ + dims[0] = space_dim1 * (hsize_t)mpi_size_g; + dims[1] = space_dim2; + + /* allocate memory for data buffer */ + data_array1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); + VRFY_G((data_array1 != NULL), "data_array1 malloc succeeded"); + + /* set up dimensions of the slab this process accesses */ + ccslab_set(mpi_rank_g, mpi_size_g, start, count, stride, block, select_factor); + + /* set up the coords array selection */ + num_points = block[0] * block[1] * count[0] * count[1]; + coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); + VRFY_G((coords != NULL), "coords malloc succeeded"); + point_set(start, count, stride, block, num_points, coords, mode); + + /* Warning: H5Screate_simple requires an array of hsize_t elements + * even if we only pass only a single value. Attempting anything else + * appears to cause problems with 32 bit compilers. + */ + file_dataspace = H5Screate_simple(2, dims, NULL); + VRFY_G((file_dataspace >= 0), "file dataspace created succeeded"); + + if (ALL != mem_selection) { + mem_dataspace = H5Screate_simple(2, dims, NULL); + VRFY_G((mem_dataspace >= 0), "mem dataspace created succeeded"); + } + else { + /* Putting the warning about H5Screate_simple (above) into practice... */ + hsize_t dsdims[1] = {num_points}; + mem_dataspace = H5Screate_simple(1, dsdims, NULL); + VRFY_G((mem_dataspace >= 0), "mem_dataspace create succeeded"); + } + + crp_plist = H5Pcreate(H5P_DATASET_CREATE); + VRFY_G((crp_plist >= 0), ""); + + /* Set up chunk information. */ + chunk_dims[0] = dims[0] / (hsize_t)chunk_factor; + + /* to decrease the testing time, maintain bigger chunk size */ + (chunk_factor == 1) ? (chunk_dims[1] = space_dim2) : (chunk_dims[1] = space_dim2 / 2); + status = H5Pset_chunk(crp_plist, 2, chunk_dims); + VRFY_G((status >= 0), "chunk creation property list succeeded"); + + dataset = H5Dcreate2(file, DSET_COLLECTIVE_CHUNK_NAME, H5T_NATIVE_INT, file_dataspace, H5P_DEFAULT, + crp_plist, H5P_DEFAULT); + VRFY_G((dataset >= 0), "dataset created succeeded"); + + status = H5Pclose(crp_plist); + VRFY_G((status >= 0), ""); + + /*put some trivial data in the data array */ + ccdataset_fill(start, stride, count, block, data_array1, mem_selection); + + MESG("data_array initialized"); + + switch (file_selection) { + case HYPER: + status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY_G((status >= 0), "hyperslab selection succeeded"); + break; + + case POINT: + if (num_points) { + status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); + VRFY_G((status >= 0), "Element selection succeeded"); + } + else { + status = H5Sselect_none(file_dataspace); + VRFY_G((status >= 0), "none selection succeeded"); + } + break; + + case ALL: + status = H5Sselect_all(file_dataspace); + VRFY_G((status >= 0), "H5Sselect_all succeeded"); + break; + } + + switch (mem_selection) { + case HYPER: + status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY_G((status >= 0), "hyperslab selection succeeded"); + break; + + case POINT: + if (num_points) { + status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); + VRFY_G((status >= 0), "Element selection succeeded"); + } + else { + status = H5Sselect_none(mem_dataspace); + VRFY_G((status >= 0), "none selection succeeded"); + } + break; + + case ALL: + status = H5Sselect_all(mem_dataspace); + VRFY_G((status >= 0), "H5Sselect_all succeeded"); + break; + } + + /* set up the collective transfer property list */ + xfer_plist = H5Pcreate(H5P_DATASET_XFER); + VRFY_G((xfer_plist >= 0), ""); + + status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + VRFY_G((status >= 0), "MPIO collective transfer property succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + status = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((status >= 0), "set independent IO collectively succeeded"); + } + + switch (api_option) { + case API_LINK_HARD: + status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist, H5FD_MPIO_CHUNK_ONE_IO); + VRFY_G((status >= 0), "collective chunk optimization succeeded"); + break; + + case API_MULTI_HARD: + status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist, H5FD_MPIO_CHUNK_MULTI_IO); + VRFY_G((status >= 0), "collective chunk optimization succeeded "); + break; + + case API_LINK_TRUE: + status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 2); + VRFY_G((status >= 0), "collective chunk optimization set chunk number succeeded"); + break; + + case API_LINK_FALSE: + status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 6); + VRFY_G((status >= 0), "collective chunk optimization set chunk number succeeded"); + break; + + case API_MULTI_COLL: + status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 8); /* make sure it is using multi-chunk IO */ + VRFY_G((status >= 0), "collective chunk optimization set chunk number succeeded"); + status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist, 50); + VRFY_G((status >= 0), "collective chunk optimization set chunk ratio succeeded"); + break; + + case API_MULTI_IND: + status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 8); /* make sure it is using multi-chunk IO */ + VRFY_G((status >= 0), "collective chunk optimization set chunk number succeeded"); + status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist, 100); + VRFY_G((status >= 0), "collective chunk optimization set chunk ratio succeeded"); + break; + + default:; + } #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if(facc_type == FACC_MPIO) { - switch(api_option) { + if (facc_type == FACC_MPIO) { + switch (api_option) { case API_LINK_HARD: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY_G((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY_G((status >= 0), "testing property list inserted succeeded"); + break; case API_MULTI_HARD: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY_G((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY_G((status >= 0), "testing property list inserted succeeded"); + break; case API_LINK_TRUE: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY_G((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = + H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY_G((status >= 0), "testing property list inserted succeeded"); + break; case API_LINK_FALSE: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY_G((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = + H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY_G((status >= 0), "testing property list inserted succeeded"); + break; case API_MULTI_COLL: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY_G((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = + H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, + H5D_XFER_COLL_CHUNK_SIZE, &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY_G((status >= 0), "testing property list inserted succeeded"); + break; case API_MULTI_IND: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY_G((status >= 0),"testing property list inserted succeeded"); - break; - - default: - ; - } - } + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = + H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY_G((status >= 0), "testing property list inserted succeeded"); + break; + + default:; + } + } #endif - /* write data collectively */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); - VRFY_G((status >= 0),"dataset write succeeded"); + /* write data collectively */ + status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); + VRFY_G((status >= 0), "dataset write succeeded"); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if(facc_type == FACC_MPIO) { - switch(api_option){ + if (facc_type == FACC_MPIO) { + switch (api_option) { case API_LINK_HARD: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_LINK_HARD_NAME,&prop_value); - VRFY_G((status >= 0),"testing property list get succeeded"); - VRFY_G((prop_value == 0),"API to set LINK COLLECTIVE IO directly succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, &prop_value); + VRFY_G((status >= 0), "testing property list get succeeded"); + VRFY_G((prop_value == 0), "API to set LINK COLLECTIVE IO directly succeeded"); + break; case API_MULTI_HARD: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME,&prop_value); - VRFY_G((status >= 0),"testing property list get succeeded"); - VRFY_G((prop_value == 0),"API to set MULTI-CHUNK COLLECTIVE IO optimization succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, &prop_value); + VRFY_G((status >= 0), "testing property list get succeeded"); + VRFY_G((prop_value == 0), "API to set MULTI-CHUNK COLLECTIVE IO optimization succeeded"); + break; case API_LINK_TRUE: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME,&prop_value); - VRFY_G((status >= 0),"testing property list get succeeded"); - VRFY_G((prop_value == 0),"API to set LINK COLLECTIVE IO succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, &prop_value); + VRFY_G((status >= 0), "testing property list get succeeded"); + VRFY_G((prop_value == 0), "API to set LINK COLLECTIVE IO succeeded"); + break; case API_LINK_FALSE: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME,&prop_value); - VRFY_G((status >= 0),"testing property list get succeeded"); - VRFY_G((prop_value == 0),"API to set LINK IO transferring to multi-chunk IO succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, &prop_value); + VRFY_G((status >= 0), "testing property list get succeeded"); + VRFY_G((prop_value == 0), "API to set LINK IO transferring to multi-chunk IO succeeded"); + break; case API_MULTI_COLL: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME,&prop_value); - VRFY_G((status >= 0),"testing property list get succeeded"); - VRFY_G((prop_value == 0),"API to set MULTI-CHUNK COLLECTIVE IO with optimization succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, &prop_value); + VRFY_G((status >= 0), "testing property list get succeeded"); + VRFY_G((prop_value == 0), "API to set MULTI-CHUNK COLLECTIVE IO with optimization succeeded"); + break; case API_MULTI_IND: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME,&prop_value); - VRFY_G((status >= 0),"testing property list get succeeded"); - VRFY_G((prop_value == 0),"API to set MULTI-CHUNK IO transferring to independent IO succeeded"); - break; - - default: - ; - } - } + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, &prop_value); + VRFY_G((status >= 0), "testing property list get succeeded"); + VRFY_G((prop_value == 0), + "API to set MULTI-CHUNK IO transferring to independent IO succeeded"); + break; + + default:; + } + } #endif - status = H5Dclose(dataset); - VRFY_G((status >= 0),""); - - status = H5Pclose(xfer_plist); - VRFY_G((status >= 0),"property list closed"); - - status = H5Sclose(file_dataspace); - VRFY_G((status >= 0),""); - - status = H5Sclose(mem_dataspace); - VRFY_G((status >= 0),""); - - - status = H5Fclose(file); - VRFY_G((status >= 0),""); - - if (data_array1) HDfree(data_array1); - - /* Use collective read to verify the correctness of collective write. */ - - /* allocate memory for data buffer */ - data_array1 = (int *)HDmalloc(dims[0]*dims[1]*sizeof(int)); - VRFY_G((data_array1 != NULL), "data_array1 malloc succeeded"); - - /* allocate memory for data buffer */ - data_origin1 = (int *)HDmalloc(dims[0]*dims[1]*sizeof(int)); - VRFY_G((data_origin1 != NULL), "data_origin1 malloc succeeded"); - - acc_plist = create_faccess_plist(comm, info, facc_type); - VRFY_G((acc_plist >= 0),"MPIO creation property list succeeded"); - - file = H5Fopen(FILENAME[0],H5F_ACC_RDONLY,acc_plist); - VRFY_G((file >= 0),"H5Fcreate succeeded"); - - status = H5Pclose(acc_plist); - VRFY_G((status >= 0),""); - - /* open the collective dataset*/ - dataset = H5Dopen2(file, DSET_COLLECTIVE_CHUNK_NAME, H5P_DEFAULT); - VRFY_G((dataset >= 0), ""); - - /* set up dimensions of the slab this process accesses */ - ccslab_set(mpi_rank_g, mpi_size_g, start, count, stride, block, select_factor); - - /* obtain the file and mem dataspace*/ - file_dataspace = H5Dget_space (dataset); - VRFY_G((file_dataspace >= 0), ""); - - if (ALL != mem_selection) { - mem_dataspace = H5Dget_space (dataset); - VRFY_G((mem_dataspace >= 0), ""); - } - else { - /* Warning: H5Screate_simple requires an array of hsize_t elements - * even if we only pass only a single value. Attempting anything else - * appears to cause problems with 32 bit compilers. - */ - hsize_t dsdims[1] = {num_points}; - mem_dataspace = H5Screate_simple (1, dsdims, NULL); - VRFY_G((mem_dataspace >= 0), "mem_dataspace create succeeded"); - } - - switch (file_selection) { - case HYPER: - status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY_G((status >= 0),"hyperslab selection succeeded"); - break; - - case POINT: - if (num_points) { - status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); - VRFY_G((status >= 0),"Element selection succeeded"); - } - else { - status = H5Sselect_none(file_dataspace); - VRFY_G((status >= 0),"none selection succeeded"); - } - break; - - case ALL: - status = H5Sselect_all(file_dataspace); - VRFY_G((status >= 0), "H5Sselect_all succeeded"); - break; - } - - switch (mem_selection) { - case HYPER: - status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY_G((status >= 0),"hyperslab selection succeeded"); - break; - - case POINT: - if (num_points) { - status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); - VRFY_G((status >= 0),"Element selection succeeded"); - } - else { - status = H5Sselect_none(mem_dataspace); - VRFY_G((status >= 0),"none selection succeeded"); - } - break; - - case ALL: - status = H5Sselect_all(mem_dataspace); - VRFY_G((status >= 0), "H5Sselect_all succeeded"); - break; - } - - /* fill dataset with test data */ - ccdataset_fill(start, stride,count,block, data_origin1, mem_selection); - xfer_plist = H5Pcreate (H5P_DATASET_XFER); - VRFY_G((xfer_plist >= 0),""); - - status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); - VRFY_G((status>= 0),"MPIO collective transfer property succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - status = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY_G((status>= 0),"set independent IO collectively succeeded"); - } - - status = H5Dread(dataset, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); - VRFY_G((status >=0),"dataset read succeeded"); - - /* verify the read data with original expected data */ - status = ccdataset_vrfy(start, count, stride, block, data_array1, data_origin1, mem_selection); - if (status) nerrors++; - - status = H5Pclose(xfer_plist); - VRFY_G((status >= 0),"property list closed"); - - /* close dataset collectively */ - status=H5Dclose(dataset); - VRFY_G((status >= 0), "H5Dclose"); - - /* release all IDs created */ - status = H5Sclose(file_dataspace); - VRFY_G((status >= 0),"H5Sclose"); - - status = H5Sclose(mem_dataspace); - VRFY_G((status >= 0),"H5Sclose"); - - /* close the file collectively */ - status = H5Fclose(file); - VRFY_G((status >= 0),"H5Fclose"); - - /* release data buffers */ - if(coords) HDfree(coords); - if(data_array1) HDfree(data_array1); - if(data_origin1) HDfree(data_origin1); + status = H5Dclose(dataset); + VRFY_G((status >= 0), ""); -} + status = H5Pclose(xfer_plist); + VRFY_G((status >= 0), "property list closed"); + + status = H5Sclose(file_dataspace); + VRFY_G((status >= 0), ""); + + status = H5Sclose(mem_dataspace); + VRFY_G((status >= 0), ""); + + status = H5Fclose(file); + VRFY_G((status >= 0), ""); + if (data_array1) + HDfree(data_array1); + /* Use collective read to verify the correctness of collective write. */ + + /* allocate memory for data buffer */ + data_array1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); + VRFY_G((data_array1 != NULL), "data_array1 malloc succeeded"); + + /* allocate memory for data buffer */ + data_origin1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); + VRFY_G((data_origin1 != NULL), "data_origin1 malloc succeeded"); + + acc_plist = create_faccess_plist(comm, info, facc_type); + VRFY_G((acc_plist >= 0), "MPIO creation property list succeeded"); + + file = H5Fopen(FILENAME[0], H5F_ACC_RDONLY, acc_plist); + VRFY_G((file >= 0), "H5Fcreate succeeded"); + + status = H5Pclose(acc_plist); + VRFY_G((status >= 0), ""); + + /* open the collective dataset*/ + dataset = H5Dopen2(file, DSET_COLLECTIVE_CHUNK_NAME, H5P_DEFAULT); + VRFY_G((dataset >= 0), ""); + + /* set up dimensions of the slab this process accesses */ + ccslab_set(mpi_rank_g, mpi_size_g, start, count, stride, block, select_factor); + + /* obtain the file and mem dataspace*/ + file_dataspace = H5Dget_space(dataset); + VRFY_G((file_dataspace >= 0), ""); + + if (ALL != mem_selection) { + mem_dataspace = H5Dget_space(dataset); + VRFY_G((mem_dataspace >= 0), ""); + } + else { + /* Warning: H5Screate_simple requires an array of hsize_t elements + * even if we only pass only a single value. Attempting anything else + * appears to cause problems with 32 bit compilers. + */ + hsize_t dsdims[1] = {num_points}; + mem_dataspace = H5Screate_simple(1, dsdims, NULL); + VRFY_G((mem_dataspace >= 0), "mem_dataspace create succeeded"); + } + + switch (file_selection) { + case HYPER: + status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY_G((status >= 0), "hyperslab selection succeeded"); + break; + + case POINT: + if (num_points) { + status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); + VRFY_G((status >= 0), "Element selection succeeded"); + } + else { + status = H5Sselect_none(file_dataspace); + VRFY_G((status >= 0), "none selection succeeded"); + } + break; + + case ALL: + status = H5Sselect_all(file_dataspace); + VRFY_G((status >= 0), "H5Sselect_all succeeded"); + break; + } + + switch (mem_selection) { + case HYPER: + status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY_G((status >= 0), "hyperslab selection succeeded"); + break; + + case POINT: + if (num_points) { + status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); + VRFY_G((status >= 0), "Element selection succeeded"); + } + else { + status = H5Sselect_none(mem_dataspace); + VRFY_G((status >= 0), "none selection succeeded"); + } + break; + + case ALL: + status = H5Sselect_all(mem_dataspace); + VRFY_G((status >= 0), "H5Sselect_all succeeded"); + break; + } + + /* fill dataset with test data */ + ccdataset_fill(start, stride, count, block, data_origin1, mem_selection); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); + VRFY_G((xfer_plist >= 0), ""); + + status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + VRFY_G((status >= 0), "MPIO collective transfer property succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + status = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY_G((status >= 0), "set independent IO collectively succeeded"); + } + + status = H5Dread(dataset, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); + VRFY_G((status >= 0), "dataset read succeeded"); + + /* verify the read data with original expected data */ + status = ccdataset_vrfy(start, count, stride, block, data_array1, data_origin1, mem_selection); + if (status) + nerrors++; + + status = H5Pclose(xfer_plist); + VRFY_G((status >= 0), "property list closed"); + + /* close dataset collectively */ + status = H5Dclose(dataset); + VRFY_G((status >= 0), "H5Dclose"); + + /* release all IDs created */ + status = H5Sclose(file_dataspace); + VRFY_G((status >= 0), "H5Sclose"); + + status = H5Sclose(mem_dataspace); + VRFY_G((status >= 0), "H5Sclose"); + + /* close the file collectively */ + status = H5Fclose(file); + VRFY_G((status >= 0), "H5Fclose"); + + /* release data buffers */ + if (coords) + HDfree(coords); + if (data_array1) + HDfree(data_array1); + if (data_origin1) + HDfree(data_origin1); +} /***************************************************************************** * @@ -1898,31 +1871,26 @@ do_express_test(int world_mpi_rank) express_test = GetTestExpress(); - result = MPI_Allreduce((void *)&express_test, - (void *)&max_express_test, - 1, - MPI_INT, - MPI_MAX, - MPI_COMM_WORLD); + result = + MPI_Allreduce((void *)&express_test, (void *)&max_express_test, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); - if ( result != MPI_SUCCESS ) { + if (result != MPI_SUCCESS) { nerrors++; max_express_test = -1; - if ( VERBOSE_MED && (world_mpi_rank == 0)) { - HDfprintf(stdout, "%d:%s: MPI_Allreduce() failed.\n", - world_mpi_rank, FUNC ); + if (VERBOSE_MED && (world_mpi_rank == 0)) { + HDfprintf(stdout, "%d:%s: MPI_Allreduce() failed.\n", world_mpi_rank, FUNC); } } - return(max_express_test); + return (max_express_test); } /* do_express_test() */ - -int main(int argc, char **argv) +int +main(int argc, char **argv) { - int ExpressMode = 0; - hsize_t newsize = 1048576; + int ExpressMode = 0; + hsize_t newsize = 1048576; /* Set the bigio processing limit to be 'newsize' bytes */ hsize_t oldsize = H5_mpi_set_bigio_count(newsize); @@ -1932,20 +1900,20 @@ int main(int argc, char **argv) * envoked and tested. */ if (newsize != oldsize) { - bigcount = newsize * 2; + bigcount = newsize * 2; } MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size_g); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank_g); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size_g); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank_g); /* Attempt to turn off atexit post processing so that in case errors * happen during the test and the process is aborted, it will not get * hang in the atexit post processing in which it may try to make MPI * calls. By then, MPI calls may not work. */ - if (H5dont_atexit() < 0){ - HDprintf("Failed to turn off atexit processing. Continue.\n"); + if (H5dont_atexit() < 0) { + HDprintf("Failed to turn off atexit processing. Continue.\n"); }; /* set alarm. */ @@ -1960,17 +1928,17 @@ int main(int argc, char **argv) MPI_Barrier(MPI_COMM_WORLD); if (ExpressMode > 0) { - if (mpi_rank_g == 0) - HDprintf("***Express test mode on. Several tests are skipped\n"); + if (mpi_rank_g == 0) + HDprintf("***Express test mode on. Several tests are skipped\n"); } else { - coll_chunk1(); - MPI_Barrier(MPI_COMM_WORLD); - coll_chunk2(); - MPI_Barrier(MPI_COMM_WORLD); - coll_chunk3(); - MPI_Barrier(MPI_COMM_WORLD); - single_rank_independent_io(); + coll_chunk1(); + MPI_Barrier(MPI_COMM_WORLD); + coll_chunk2(); + MPI_Barrier(MPI_COMM_WORLD); + coll_chunk3(); + MPI_Barrier(MPI_COMM_WORLD); + single_rank_independent_io(); } /* turn off alarm */ @@ -1986,4 +1954,3 @@ int main(int argc, char **argv) return 0; } - diff --git a/testpar/t_cache.c b/testpar/t_cache.c index efa17f8..a7afe4f 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -18,9 +18,9 @@ #include "testpar.h" -#define H5AC_FRIEND /*suppress error about including H5ACpkg */ -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5AC_FRIEND /*suppress error about including H5ACpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #include "H5ACpkg.h" #include "H5Cpkg.h" @@ -30,58 +30,53 @@ #include "H5MFprivate.h" #include "H5private.h" -#define BASE_ADDR (haddr_t)1024 +#define BASE_ADDR (haddr_t)1024 - -int nerrors = 0; -int failures = 0; -hbool_t verbose = TRUE; /* used to control error messages */ +int nerrors = 0; +int failures = 0; +hbool_t verbose = TRUE; /* used to control error messages */ #define NFILENAME 2 -const char *FILENAME[NFILENAME]={"CacheTestDummy", NULL}; +const char *FILENAME[NFILENAME] = {"CacheTestDummy", NULL}; #ifndef PATH_MAX -#define PATH_MAX 512 -#endif /* !PATH_MAX */ +#define PATH_MAX 512 +#endif /* !PATH_MAX */ char filenames[NFILENAME][PATH_MAX]; -hid_t fapl; /* file access property list */ -haddr_t max_addr = 0; /* used to store the end of - * the address space used by - * the data array (see below). - */ -hbool_t callbacks_verbose = FALSE; /* flag used to control whether - * the callback functions are in - * verbose mode. - */ - - -int world_mpi_size = -1; -int world_mpi_rank = -1; -int world_server_mpi_rank = -1; -MPI_Comm world_mpi_comm = MPI_COMM_NULL; -int file_mpi_size = -1; -int file_mpi_rank = -1; -MPI_Comm file_mpi_comm = MPI_COMM_NULL; - +hid_t fapl; /* file access property list */ +haddr_t max_addr = 0; /* used to store the end of + * the address space used by + * the data array (see below). + */ +hbool_t callbacks_verbose = FALSE; /* flag used to control whether + * the callback functions are in + * verbose mode. + */ + +int world_mpi_size = -1; +int world_mpi_rank = -1; +int world_server_mpi_rank = -1; +MPI_Comm world_mpi_comm = MPI_COMM_NULL; +int file_mpi_size = -1; +int file_mpi_rank = -1; +MPI_Comm file_mpi_comm = MPI_COMM_NULL; /* the following globals are used to maintain rudementary statistics * to check the validity of the statistics maintained by H5C.c */ -long datum_clears = 0; -long datum_pinned_clears = 0; -long datum_destroys = 0; -long datum_flushes = 0; -long datum_pinned_flushes = 0; -long datum_loads = 0; -long global_pins = 0; -long global_dirty_pins = 0; +long datum_clears = 0; +long datum_pinned_clears = 0; +long datum_destroys = 0; +long datum_flushes = 0; +long datum_pinned_flushes = 0; +long datum_loads = 0; +long global_pins = 0; +long global_dirty_pins = 0; long local_pins = 0; - /* the following fields are used by the server process only */ -int total_reads = 0; -int total_writes = 0; - +int total_reads = 0; +int total_writes = 0; /***************************************************************************** * struct datum @@ -161,24 +156,23 @@ int total_writes = 0; * *****************************************************************************/ -struct datum -{ - H5C_cache_entry_t header; - haddr_t base_addr; - size_t len; - size_t local_len; - int ver; - hbool_t dirty; - hbool_t valid; - hbool_t locked; - hbool_t global_pinned; - hbool_t local_pinned; - hbool_t cleared; - hbool_t flushed; - int reads; - int writes; - int index; - struct H5AC_aux_t * aux_ptr; +struct datum { + H5C_cache_entry_t header; + haddr_t base_addr; + size_t len; + size_t local_len; + int ver; + hbool_t dirty; + hbool_t valid; + hbool_t locked; + hbool_t global_pinned; + hbool_t local_pinned; + hbool_t cleared; + hbool_t flushed; + int reads; + int writes; + int index; + struct H5AC_aux_t *aux_ptr; }; /***************************************************************************** @@ -196,11 +190,10 @@ struct datum * *****************************************************************************/ -#define NUM_DATA_ENTRIES 100000 +#define NUM_DATA_ENTRIES 100000 struct datum data[NUM_DATA_ENTRIES]; - /* Many tests use the size of data array as the size of test loops. * On some machines, this results in unacceptably long test runs. * @@ -215,16 +208,15 @@ struct datum data[NUM_DATA_ENTRIES]; * Further, this value must be consistant across all processes. */ -#define STD_VIRT_NUM_DATA_ENTRIES NUM_DATA_ENTRIES -#define EXPRESS_VIRT_NUM_DATA_ENTRIES (NUM_DATA_ENTRIES / 10) +#define STD_VIRT_NUM_DATA_ENTRIES NUM_DATA_ENTRIES +#define EXPRESS_VIRT_NUM_DATA_ENTRIES (NUM_DATA_ENTRIES / 10) /* Use a smaller test size to avoid creating huge MPE logfiles. */ #ifdef H5_HAVE_MPE -#define MPE_VIRT_NUM_DATA_ENTIES (NUM_DATA_ENTRIES / 100) +#define MPE_VIRT_NUM_DATA_ENTIES (NUM_DATA_ENTRIES / 100) #endif int virt_num_data_entries = NUM_DATA_ENTRIES; - /***************************************************************************** * data_index array * @@ -241,7 +233,6 @@ int virt_num_data_entries = NUM_DATA_ENTRIES; int data_index[NUM_DATA_ENTRIES]; - /***************************************************************************** * The following two #defines are used to control code that is in turn used * to force "POSIX" semantics on the server process used to simulate metadata @@ -271,8 +262,7 @@ int data_index[NUM_DATA_ENTRIES]; *****************************************************************************/ #define DO_WRITE_REQ_ACK TRUE -#define DO_SYNC_AFTER_WRITE FALSE - +#define DO_SYNC_AFTER_WRITE FALSE /***************************************************************************** * struct mssg @@ -302,42 +292,40 @@ int data_index[NUM_DATA_ENTRIES]; * *****************************************************************************/ -#define WRITE_REQ_CODE 0 -#define WRITE_REQ_ACK_CODE 1 -#define READ_REQ_CODE 2 -#define READ_REQ_REPLY_CODE 3 -#define SYNC_REQ_CODE 4 -#define SYNC_ACK_CODE 5 -#define REQ_TTL_WRITES_CODE 6 -#define REQ_TTL_WRITES_RPLY_CODE 7 -#define REQ_TTL_READS_CODE 8 +#define WRITE_REQ_CODE 0 +#define WRITE_REQ_ACK_CODE 1 +#define READ_REQ_CODE 2 +#define READ_REQ_REPLY_CODE 3 +#define SYNC_REQ_CODE 4 +#define SYNC_ACK_CODE 5 +#define REQ_TTL_WRITES_CODE 6 +#define REQ_TTL_WRITES_RPLY_CODE 7 +#define REQ_TTL_READS_CODE 8 #define REQ_TTL_READS_RPLY_CODE 9 #define REQ_ENTRY_WRITES_CODE 10 -#define REQ_ENTRY_WRITES_RPLY_CODE 11 -#define REQ_ENTRY_READS_CODE 12 -#define REQ_ENTRY_READS_RPLY_CODE 13 -#define REQ_RW_COUNT_RESET_CODE 14 -#define REQ_RW_COUNT_RESET_RPLY_CODE 15 -#define DONE_REQ_CODE 16 -#define MAX_REQ_CODE 16 - -#define MSSG_MAGIC 0x1248 - -struct mssg_t -{ - int req; - int src; - int dest; - long int mssg_num; - haddr_t base_addr; - unsigned len; - int ver; - unsigned count; - unsigned magic; +#define REQ_ENTRY_WRITES_RPLY_CODE 11 +#define REQ_ENTRY_READS_CODE 12 +#define REQ_ENTRY_READS_RPLY_CODE 13 +#define REQ_RW_COUNT_RESET_CODE 14 +#define REQ_RW_COUNT_RESET_RPLY_CODE 15 +#define DONE_REQ_CODE 16 +#define MAX_REQ_CODE 16 + +#define MSSG_MAGIC 0x1248 + +struct mssg_t { + int req; + int src; + int dest; + long int mssg_num; + haddr_t base_addr; + unsigned len; + int ver; + unsigned count; + unsigned magic; }; -MPI_Datatype mpi_mssg_t; /* for MPI derived type created from mssg */ - +MPI_Datatype mpi_mssg_t; /* for MPI derived type created from mssg */ /*****************************************************************************/ /************************** function declarations ****************************/ @@ -351,19 +339,16 @@ static void reset_stats(void); static hbool_t set_up_file_communicator(void); - /* data array manipulation functions */ -static int addr_to_datum_index(haddr_t base_addr); +static int addr_to_datum_index(haddr_t base_addr); static void init_data(void); - /* test coodination related functions */ -static int do_express_test(void); +static int do_express_test(void); static void do_sync(void); -static int get_max_nerrors(void); - +static int get_max_nerrors(void); /* mssg xfer related functions */ @@ -372,48 +357,37 @@ static hbool_t send_mssg(struct mssg_t *mssg_ptr, hbool_t add_req_to_tag); static hbool_t setup_derived_types(void); static hbool_t takedown_derived_types(void); - /* server functions */ static hbool_t reset_server_counters(void); static hbool_t server_main(void); -static hbool_t serve_read_request(struct mssg_t * mssg_ptr); -static hbool_t serve_sync_request(struct mssg_t * mssg_ptr); -static hbool_t serve_write_request(struct mssg_t * mssg_ptr); -static hbool_t serve_total_writes_request(struct mssg_t * mssg_ptr); -static hbool_t serve_total_reads_request(struct mssg_t * mssg_ptr); -static hbool_t serve_entry_writes_request(struct mssg_t * mssg_ptr); -static hbool_t serve_entry_reads_request(struct mssg_t * mssg_ptr); -static hbool_t serve_rw_count_reset_request(struct mssg_t * mssg_ptr); - +static hbool_t serve_read_request(struct mssg_t *mssg_ptr); +static hbool_t serve_sync_request(struct mssg_t *mssg_ptr); +static hbool_t serve_write_request(struct mssg_t *mssg_ptr); +static hbool_t serve_total_writes_request(struct mssg_t *mssg_ptr); +static hbool_t serve_total_reads_request(struct mssg_t *mssg_ptr); +static hbool_t serve_entry_writes_request(struct mssg_t *mssg_ptr); +static hbool_t serve_entry_reads_request(struct mssg_t *mssg_ptr); +static hbool_t serve_rw_count_reset_request(struct mssg_t *mssg_ptr); /* call back functions & related data structures */ -static herr_t datum_get_initial_load_size(void *udata_ptr, - size_t *image_len_ptr); +static herr_t datum_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr); -static void * datum_deserialize(const void * image_ptr, - size_t len, - void * udata_ptr, - hbool_t * dirty_ptr); +static void *datum_deserialize(const void *image_ptr, size_t len, void *udata_ptr, hbool_t *dirty_ptr); -static herr_t datum_image_len(const void *thing, - size_t *image_len_ptr); +static herr_t datum_image_len(const void *thing, size_t *image_len_ptr); -static herr_t datum_serialize(const H5F_t *f, - void *image_ptr, - size_t len, - void *thing_ptr); +static herr_t datum_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing_ptr); static herr_t datum_notify(H5C_notify_action_t action, void *thing); -static herr_t datum_free_icr(void * thing); +static herr_t datum_free_icr(void *thing); /* Masquerade as object header entries to the cache */ -#define DATUM_ENTRY_TYPE H5AC_OHDR_ID - -#define NUMBER_OF_ENTRY_TYPES 1 +#define DATUM_ENTRY_TYPE H5AC_OHDR_ID +#define NUMBER_OF_ENTRY_TYPES 1 /* Note the use of the H5AC__CLASS_SKIP_READS and H5AC__CLASS_SKIP_WRITES * flags. As a result of these flags, the metadata cache does no file I/O @@ -429,9 +403,7 @@ static herr_t datum_free_icr(void * thing); * * JRM -- 1/13/15 */ -const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = -{ - { +const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = {{ /* id */ DATUM_ENTRY_TYPE, /* name */ "datum", /* mem_type */ H5FD_MEM_OHDR, @@ -446,48 +418,38 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = /* notify */ datum_notify, /* free_icr */ datum_free_icr, /* fsf_size */ NULL, - } -}; - +}}; /* test utility functions */ -static void expunge_entry(H5F_t * file_ptr, int32_t idx); -static void insert_entry(H5C_t * cache_ptr, H5F_t * file_ptr, - int32_t idx, unsigned int flags); -static void local_pin_and_unpin_random_entries(H5F_t * file_ptr, int min_idx, - int max_idx, int min_count, - int max_count); -static void local_pin_random_entry(H5F_t * file_ptr, int min_idx, int max_idx); -static void local_unpin_all_entries(H5F_t * file_ptr, hbool_t via_unprotect); -static int local_unpin_next_pinned_entry(H5F_t * file_ptr, int start_idx, - hbool_t via_unprotect); -static void lock_and_unlock_random_entries(H5F_t * file_ptr, int min_idx, int max_idx, - int min_count, int max_count); -static void lock_and_unlock_random_entry(H5F_t * file_ptr, - int min_idx, int max_idx); -static void lock_entry(H5F_t * file_ptr, int32_t idx); -static void mark_entry_dirty(int32_t idx); -static void pin_entry(H5F_t * file_ptr, int32_t idx, hbool_t global, hbool_t dirty); -static void pin_protected_entry(int32_t idx, hbool_t global); -static void move_entry(H5F_t * file_ptr, int32_t old_idx, int32_t new_idx); +static void expunge_entry(H5F_t *file_ptr, int32_t idx); +static void insert_entry(H5C_t *cache_ptr, H5F_t *file_ptr, int32_t idx, unsigned int flags); +static void local_pin_and_unpin_random_entries(H5F_t *file_ptr, int min_idx, int max_idx, int min_count, + int max_count); +static void local_pin_random_entry(H5F_t *file_ptr, int min_idx, int max_idx); +static void local_unpin_all_entries(H5F_t *file_ptr, hbool_t via_unprotect); +static int local_unpin_next_pinned_entry(H5F_t *file_ptr, int start_idx, hbool_t via_unprotect); +static void lock_and_unlock_random_entries(H5F_t *file_ptr, int min_idx, int max_idx, int min_count, + int max_count); +static void lock_and_unlock_random_entry(H5F_t *file_ptr, int min_idx, int max_idx); +static void lock_entry(H5F_t *file_ptr, int32_t idx); +static void mark_entry_dirty(int32_t idx); +static void pin_entry(H5F_t *file_ptr, int32_t idx, hbool_t global, hbool_t dirty); +static void pin_protected_entry(int32_t idx, hbool_t global); +static void move_entry(H5F_t *file_ptr, int32_t old_idx, int32_t new_idx); static hbool_t reset_server_counts(void); -static void resize_entry(int32_t idx, size_t new_size); -static hbool_t setup_cache_for_test(hid_t * fid_ptr, - H5F_t ** file_ptr_ptr, - H5C_t ** cache_ptr_ptr, - int metadata_write_strategy); -static void setup_rand(void); -static hbool_t take_down_cache(hid_t fid, H5C_t * cache_ptr); +static void resize_entry(int32_t idx, size_t new_size); +static hbool_t setup_cache_for_test(hid_t *fid_ptr, H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr, + int metadata_write_strategy); +static void setup_rand(void); +static hbool_t take_down_cache(hid_t fid, H5C_t *cache_ptr); static hbool_t verify_entry_reads(haddr_t addr, int expected_entry_reads); static hbool_t verify_entry_writes(haddr_t addr, int expected_entry_writes); static hbool_t verify_total_reads(int expected_total_reads); static hbool_t verify_total_writes(unsigned expected_total_writes); -static void verify_writes(unsigned num_writes, haddr_t * written_entries_tbl); -static void unlock_entry(H5F_t * file_ptr, int32_t type, unsigned int flags); -static void unpin_entry(H5F_t * file_ptr, int32_t idx, hbool_t global, - hbool_t dirty, hbool_t via_unprotect); - +static void verify_writes(unsigned num_writes, haddr_t *written_entries_tbl); +static void unlock_entry(H5F_t *file_ptr, int32_t type, unsigned int flags); +static void unpin_entry(H5F_t *file_ptr, int32_t idx, hbool_t global, hbool_t dirty, hbool_t via_unprotect); /* test functions */ @@ -500,7 +462,6 @@ static hbool_t smoke_check_5(int metadata_write_strategy); static hbool_t smoke_check_6(int metadata_write_strategy); static hbool_t trace_file_check(int metadata_write_strategy); - /*****************************************************************************/ /****************************** stats functions ******************************/ /*****************************************************************************/ @@ -528,17 +489,12 @@ static hbool_t trace_file_check(int metadata_write_strategy); static void print_stats(void) { - HDfprintf(stdout, - "%d: datum clears / pinned clears / destroys = %ld / %ld / %ld\n", - world_mpi_rank, datum_clears, datum_pinned_clears, - datum_destroys ); - HDfprintf(stdout, - "%d: datum flushes / pinned flushes / loads = %ld / %ld / %ld\n", - world_mpi_rank, datum_flushes, datum_pinned_flushes, - datum_loads ); - HDfprintf(stdout, - "%d: pins: global / global dirty / local = %ld / %ld / %ld\n", - world_mpi_rank, global_pins, global_dirty_pins, local_pins); + HDfprintf(stdout, "%d: datum clears / pinned clears / destroys = %ld / %ld / %ld\n", world_mpi_rank, + datum_clears, datum_pinned_clears, datum_destroys); + HDfprintf(stdout, "%d: datum flushes / pinned flushes / loads = %ld / %ld / %ld\n", world_mpi_rank, + datum_flushes, datum_pinned_flushes, datum_loads); + HDfprintf(stdout, "%d: pins: global / global dirty / local = %ld / %ld / %ld\n", world_mpi_rank, + global_pins, global_dirty_pins, local_pins); HDfflush(stdout); return; @@ -546,7 +502,6 @@ print_stats(void) } /* print_stats() */ #endif /* NOT_USED */ - /***************************************************************************** * * Function: reset_stats() @@ -566,21 +521,20 @@ print_stats(void) static void reset_stats(void) { - datum_clears = 0; - datum_pinned_clears = 0; - datum_destroys = 0; - datum_flushes = 0; - datum_pinned_flushes = 0; - datum_loads = 0; + datum_clears = 0; + datum_pinned_clears = 0; + datum_destroys = 0; + datum_flushes = 0; + datum_pinned_flushes = 0; + datum_loads = 0; global_pins = 0; - global_dirty_pins = 0; - local_pins = 0; + global_dirty_pins = 0; + local_pins = 0; return; } /* reset_stats() */ - /*****************************************************************************/ /**************************** MPI setup functions ****************************/ /*****************************************************************************/ @@ -607,132 +561,121 @@ reset_stats(void) static hbool_t set_up_file_communicator(void) { - hbool_t success = TRUE; - int mpi_result; - int num_excluded_ranks; - int excluded_ranks[1]; + hbool_t success = TRUE; + int mpi_result; + int num_excluded_ranks; + int excluded_ranks[1]; MPI_Group file_group; MPI_Group world_group; - if ( success ) { + if (success) { mpi_result = MPI_Comm_group(world_mpi_comm, &world_group); - if ( mpi_result != MPI_SUCCESS ) { + if (mpi_result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: MPI_Comm_group() failed with error %d.\n", - world_mpi_rank, FUNC, mpi_result); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Comm_group() failed with error %d.\n", world_mpi_rank, FUNC, + mpi_result); } } } - if ( success ) { + if (success) { num_excluded_ranks = 1; - excluded_ranks[0] = world_server_mpi_rank; - mpi_result = MPI_Group_excl(world_group, num_excluded_ranks, - excluded_ranks, &file_group); + excluded_ranks[0] = world_server_mpi_rank; + mpi_result = MPI_Group_excl(world_group, num_excluded_ranks, excluded_ranks, &file_group); - if ( mpi_result != MPI_SUCCESS ) { + if (mpi_result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: MPI_Group_excl() failed with error %d.\n", - world_mpi_rank, FUNC, mpi_result); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Group_excl() failed with error %d.\n", world_mpi_rank, FUNC, + mpi_result); } } } - if ( success ) { + if (success) { - mpi_result = MPI_Comm_create(world_mpi_comm, file_group, - &file_mpi_comm); + mpi_result = MPI_Comm_create(world_mpi_comm, file_group, &file_mpi_comm); - if ( mpi_result != MPI_SUCCESS ) { + if (mpi_result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: MPI_Comm_create() failed with error %d.\n", - world_mpi_rank, FUNC, mpi_result); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Comm_create() failed with error %d.\n", world_mpi_rank, FUNC, + mpi_result); } + } + else { - } else { - - if ( world_mpi_rank != world_server_mpi_rank ) { + if (world_mpi_rank != world_server_mpi_rank) { - if ( file_mpi_comm == MPI_COMM_NULL ) { + if (file_mpi_comm == MPI_COMM_NULL) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: file_mpi_comm == MPI_COMM_NULL.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: file_mpi_comm == MPI_COMM_NULL.\n", world_mpi_rank, FUNC); } } - } else { + } + else { file_mpi_size = world_mpi_size - 1; /* needed by the server */ - if ( file_mpi_comm != MPI_COMM_NULL ) { + if (file_mpi_comm != MPI_COMM_NULL) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: file_mpi_comm != MPI_COMM_NULL.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: file_mpi_comm != MPI_COMM_NULL.\n", world_mpi_rank, FUNC); } } } } } - if ( ( success ) && ( world_mpi_rank != world_server_mpi_rank ) ) { + if ((success) && (world_mpi_rank != world_server_mpi_rank)) { mpi_result = MPI_Comm_size(file_mpi_comm, &file_mpi_size); - if ( mpi_result != MPI_SUCCESS ) { + if (mpi_result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: MPI_Comm_size() failed with error %d.\n", - world_mpi_rank, FUNC, mpi_result); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Comm_size() failed with error %d.\n", world_mpi_rank, FUNC, + mpi_result); } } } - if ( ( success ) && ( world_mpi_rank != world_server_mpi_rank ) ) { + if ((success) && (world_mpi_rank != world_server_mpi_rank)) { mpi_result = MPI_Comm_rank(file_mpi_comm, &file_mpi_rank); - if ( mpi_result != MPI_SUCCESS ) { + if (mpi_result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: MPI_Comm_rank() failed with error %d.\n", - world_mpi_rank, FUNC, mpi_result); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Comm_rank() failed with error %d.\n", world_mpi_rank, FUNC, + mpi_result); } } } - return(success); + return (success); } /* set_up_file_communicator() */ - /*****************************************************************************/ /******************** data array manipulation functions **********************/ /*****************************************************************************/ @@ -754,36 +697,33 @@ set_up_file_communicator(void) static int addr_to_datum_index(haddr_t base_addr) { - int top = NUM_DATA_ENTRIES - 1; - int bottom = 0; - int middle = (NUM_DATA_ENTRIES - 1) / 2; + int top = NUM_DATA_ENTRIES - 1; + int bottom = 0; + int middle = (NUM_DATA_ENTRIES - 1) / 2; int ret_value = -1; - while ( top >= bottom ) - { - if ( base_addr < data[data_index[middle]].base_addr ) { + while (top >= bottom) { + if (base_addr < data[data_index[middle]].base_addr) { - top = middle - 1; + top = middle - 1; middle = (top + bottom) / 2; - - } else if ( base_addr > data[data_index[middle]].base_addr ) { + } + else if (base_addr > data[data_index[middle]].base_addr) { bottom = middle + 1; middle = (top + bottom) / 2; - - } else /* ( base_addr == data[data_index[middle]].base_addr ) */ { + } + else /* ( base_addr == data[data_index[middle]].base_addr ) */ { ret_value = data_index[middle]; - bottom = top + 1; /* to force exit from while loop */ - + bottom = top + 1; /* to force exit from while loop */ } } - return(ret_value); + return (ret_value); } /* addr_to_datum_index() */ - /***************************************************************************** * * Function: init_data() @@ -808,21 +748,18 @@ init_data(void) * At present, I am using the first 20 entries of the Fibonacci * sequence multiplied by 2. We will see how it works. */ - const int num_addr_offsets = 20; - const haddr_t addr_offsets[20] = { 2, 2, 4, 6, 10, - 16, 26, 42, 68, 110, - 178, 288, 466, 754, 1220, - 1974, 3194, 5168, 8362, 13539}; - int i; - int j = 0; - haddr_t addr = BASE_ADDR; + const int num_addr_offsets = 20; + const haddr_t addr_offsets[20] = {2, 2, 4, 6, 10, 16, 26, 42, 68, 110, + 178, 288, 466, 754, 1220, 1974, 3194, 5168, 8362, 13539}; + int i; + int j = 0; + haddr_t addr = BASE_ADDR; /* this must hold so moves don't change entry size. */ - HDassert( (NUM_DATA_ENTRIES / 2) % 20 == 0 ); - HDassert( (virt_num_data_entries / 2) % 20 == 0 ); + HDassert((NUM_DATA_ENTRIES / 2) % 20 == 0); + HDassert((virt_num_data_entries / 2) % 20 == 0); - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { + for (i = 0; i < NUM_DATA_ENTRIES; i++) { data[i].base_addr = addr; data[i].len = (size_t)(addr_offsets[j]); data[i].local_len = (size_t)(addr_offsets[j]); @@ -830,19 +767,19 @@ init_data(void) data[i].dirty = FALSE; data[i].valid = FALSE; data[i].locked = FALSE; - data[i].global_pinned = FALSE; - data[i].local_pinned = FALSE; - data[i].cleared = FALSE; + data[i].global_pinned = FALSE; + data[i].local_pinned = FALSE; + data[i].cleared = FALSE; data[i].flushed = FALSE; data[i].reads = 0; data[i].writes = 0; - data[i].index = i; - data[i].aux_ptr = NULL; + data[i].index = i; + data[i].aux_ptr = NULL; - data_index[i] = i; + data_index[i] = i; addr += addr_offsets[j]; - HDassert( addr > data[i].base_addr ); + HDassert(addr > data[i].base_addr); j = (j + 1) % num_addr_offsets; } @@ -854,7 +791,6 @@ init_data(void) } /* init_data() */ - /*****************************************************************************/ /******************** test coodination related functions *********************/ /*****************************************************************************/ @@ -888,28 +824,22 @@ do_express_test(void) express_test = GetTestExpress(); - result = MPI_Allreduce((void *)&express_test, - (void *)&max_express_test, - 1, - MPI_INT, - MPI_MAX, - world_mpi_comm); + result = + MPI_Allreduce((void *)&express_test, (void *)&max_express_test, 1, MPI_INT, MPI_MAX, world_mpi_comm); - if ( result != MPI_SUCCESS ) { + if (result != MPI_SUCCESS) { nerrors++; max_express_test = -1; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: MPI_Allreduce() failed.\n", - world_mpi_rank, FUNC ); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Allreduce() failed.\n", world_mpi_rank, FUNC); } } - return(max_express_test); + return (max_express_test); } /* do_express_test() */ - /***************************************************************************** * * Function: do_sync() @@ -933,10 +863,10 @@ do_sync(void) struct mssg_t mssg; - if ( nerrors <= 0 ) { + if (nerrors <= 0) { /* compose the message */ - mssg.req = SYNC_REQ_CODE; + mssg.req = SYNC_REQ_CODE; mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ @@ -946,43 +876,38 @@ do_sync(void) mssg.count = 0; mssg.magic = MSSG_MAGIC; - if ( ! send_mssg(&mssg, FALSE) ) { + if (!send_mssg(&mssg, FALSE)) { - nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", - world_mpi_rank, FUNC); + nerrors++; + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( nerrors <= 0 ) { + if (nerrors <= 0) { - if ( ! recv_mssg(&mssg, SYNC_ACK_CODE) ) { + if (!recv_mssg(&mssg, SYNC_ACK_CODE)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } - } else if ( ( mssg.req != SYNC_ACK_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.magic != MSSG_MAGIC ) ) { + } + else if ((mssg.req != SYNC_ACK_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.magic != MSSG_MAGIC)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad data in sync ack.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in sync ack.\n", world_mpi_rank, FUNC); } - } + } } return; } /* do_sync() */ - /***************************************************************************** * * Function: get_max_nerrors() @@ -1004,28 +929,21 @@ get_max_nerrors(void) int max_nerrors; int result; - result = MPI_Allreduce((void *)&nerrors, - (void *)&max_nerrors, - 1, - MPI_INT, - MPI_MAX, - world_mpi_comm); + result = MPI_Allreduce((void *)&nerrors, (void *)&max_nerrors, 1, MPI_INT, MPI_MAX, world_mpi_comm); - if ( result != MPI_SUCCESS ) { + if (result != MPI_SUCCESS) { nerrors++; max_nerrors = -1; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: MPI_Allreduce() failed.\n", - world_mpi_rank, FUNC ); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Allreduce() failed.\n", world_mpi_rank, FUNC); } } - return(max_nerrors); + return (max_nerrors); } /* get_max_nerrors() */ - /*****************************************************************************/ /************************ mssg xfer related functions ************************/ /*****************************************************************************/ @@ -1050,70 +968,63 @@ get_max_nerrors(void) * *****************************************************************************/ -#define CACHE_TEST_TAG 99 /* different from any used by the library */ +#define CACHE_TEST_TAG 99 /* different from any used by the library */ static hbool_t -recv_mssg(struct mssg_t *mssg_ptr, - int mssg_tag_offset) +recv_mssg(struct mssg_t *mssg_ptr, int mssg_tag_offset) { - hbool_t success = TRUE; - int mssg_tag = CACHE_TEST_TAG; - int result; + hbool_t success = TRUE; + int mssg_tag = CACHE_TEST_TAG; + int result; MPI_Status status; - if ( ( mssg_ptr == NULL ) || - ( mssg_tag_offset < 0 ) || - ( mssg_tag_offset> MAX_REQ_CODE ) ) { + if ((mssg_ptr == NULL) || (mssg_tag_offset < 0) || (mssg_tag_offset > MAX_REQ_CODE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: bad param(s) on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: bad param(s) on entry.\n", world_mpi_rank, FUNC); } - } else { + } + else { mssg_tag += mssg_tag_offset; } - if ( success ) { + if (success) { - result = MPI_Recv((void *)mssg_ptr, 1, mpi_mssg_t, MPI_ANY_SOURCE, - mssg_tag, world_mpi_comm, &status); + result = MPI_Recv((void *)mssg_ptr, 1, mpi_mssg_t, MPI_ANY_SOURCE, mssg_tag, world_mpi_comm, &status); - if ( result != MPI_SUCCESS ) { + if (result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: MPI_Recv() failed.\n", - world_mpi_rank, FUNC ); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Recv() failed.\n", world_mpi_rank, FUNC); } - } else if ( mssg_ptr->magic != MSSG_MAGIC ) { + } + else if (mssg_ptr->magic != MSSG_MAGIC) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: invalid magic.\n", world_mpi_rank, - FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: invalid magic.\n", world_mpi_rank, FUNC); } - } else if ( mssg_ptr->src != status.MPI_SOURCE ) { + } + else if (mssg_ptr->src != status.MPI_SOURCE) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: mssg_ptr->src != status.MPI_SOURCE.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: mssg_ptr->src != status.MPI_SOURCE.\n", world_mpi_rank, FUNC); } } } - return(success); + return (success); } /* recv_mssg() */ - /***************************************************************************** * * Function: send_mssg() @@ -1136,59 +1047,49 @@ recv_mssg(struct mssg_t *mssg_ptr, * *****************************************************************************/ static hbool_t -send_mssg(struct mssg_t *mssg_ptr, - hbool_t add_req_to_tag) +send_mssg(struct mssg_t *mssg_ptr, hbool_t add_req_to_tag) { - hbool_t success = TRUE; - int mssg_tag = CACHE_TEST_TAG; - int result; + hbool_t success = TRUE; + int mssg_tag = CACHE_TEST_TAG; + int result; static long mssg_num = 0; - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->src != world_mpi_rank ) || - ( mssg_ptr->dest < 0 ) || - ( mssg_ptr->dest == mssg_ptr->src ) || - ( mssg_ptr->dest >= world_mpi_size ) || - ( mssg_ptr->req < 0 ) || - ( mssg_ptr->req > MAX_REQ_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->src != world_mpi_rank) || (mssg_ptr->dest < 0) || + (mssg_ptr->dest == mssg_ptr->src) || (mssg_ptr->dest >= world_mpi_size) || (mssg_ptr->req < 0) || + (mssg_ptr->req > MAX_REQ_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Invalid mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Invalid mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { mssg_ptr->mssg_num = mssg_num++; - if ( add_req_to_tag ) { + if (add_req_to_tag) { - mssg_tag += mssg_ptr->req; - } + mssg_tag += mssg_ptr->req; + } - result = MPI_Send((void *)mssg_ptr, 1, mpi_mssg_t, - mssg_ptr->dest, mssg_tag, world_mpi_comm); + result = MPI_Send((void *)mssg_ptr, 1, mpi_mssg_t, mssg_ptr->dest, mssg_tag, world_mpi_comm); - if ( result != MPI_SUCCESS ) { + if (result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: MPI_Send() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Send() failed.\n", world_mpi_rank, FUNC); } } } - return(success); + return (success); } /* send_mssg() */ - /***************************************************************************** * * Function: setup_derived_types() @@ -1206,78 +1107,72 @@ send_mssg(struct mssg_t *mssg_ptr, static hbool_t setup_derived_types(void) { - hbool_t success = TRUE; - int i; - int result; - MPI_Datatype mpi_types[9] = {MPI_INT, MPI_INT, MPI_INT, MPI_LONG, - HADDR_AS_MPI_TYPE, MPI_INT, MPI_INT, - MPI_UNSIGNED, MPI_UNSIGNED}; - int block_len[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1}; - MPI_Aint displs[9]; + hbool_t success = TRUE; + int i; + int result; + MPI_Datatype mpi_types[9] = {MPI_INT, MPI_INT, MPI_INT, MPI_LONG, HADDR_AS_MPI_TYPE, + MPI_INT, MPI_INT, MPI_UNSIGNED, MPI_UNSIGNED}; + int block_len[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1}; + MPI_Aint displs[9]; struct mssg_t sample; /* used to compute displacements */ /* setup the displacements array */ - if ( ( MPI_SUCCESS != MPI_Get_address(&sample.req, &displs[0]) ) || - ( MPI_SUCCESS != MPI_Get_address(&sample.src, &displs[1]) ) || - ( MPI_SUCCESS != MPI_Get_address(&sample.dest, &displs[2]) ) || - ( MPI_SUCCESS != MPI_Get_address(&sample.mssg_num, &displs[3]) ) || - ( MPI_SUCCESS != MPI_Get_address(&sample.base_addr, &displs[4]) ) || - ( MPI_SUCCESS != MPI_Get_address(&sample.len, &displs[5]) ) || - ( MPI_SUCCESS != MPI_Get_address(&sample.ver, &displs[6]) ) || - ( MPI_SUCCESS != MPI_Get_address(&sample.count, &displs[7]) ) || - ( MPI_SUCCESS != MPI_Get_address(&sample.magic, &displs[8]) ) ) { + if ((MPI_SUCCESS != MPI_Get_address(&sample.req, &displs[0])) || + (MPI_SUCCESS != MPI_Get_address(&sample.src, &displs[1])) || + (MPI_SUCCESS != MPI_Get_address(&sample.dest, &displs[2])) || + (MPI_SUCCESS != MPI_Get_address(&sample.mssg_num, &displs[3])) || + (MPI_SUCCESS != MPI_Get_address(&sample.base_addr, &displs[4])) || + (MPI_SUCCESS != MPI_Get_address(&sample.len, &displs[5])) || + (MPI_SUCCESS != MPI_Get_address(&sample.ver, &displs[6])) || + (MPI_SUCCESS != MPI_Get_address(&sample.count, &displs[7])) || + (MPI_SUCCESS != MPI_Get_address(&sample.magic, &displs[8]))) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: MPI_Get_address() call failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Get_address() call failed.\n", world_mpi_rank, FUNC); } - - } else { + } + else { /* Now calculate the actual displacements */ - for ( i = 8; i >= 0; --i) - { + for (i = 8; i >= 0; --i) { displs[i] -= displs[0]; } } - if ( success ) { + if (success) { result = MPI_Type_create_struct(9, block_len, displs, mpi_types, &mpi_mssg_t); - if ( result != MPI_SUCCESS ) { + if (result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: MPI_Type_create_struct() call failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Type_create_struct() call failed.\n", world_mpi_rank, FUNC); } } } - if ( success ) { + if (success) { result = MPI_Type_commit(&mpi_mssg_t); - if ( result != MPI_SUCCESS) { + if (result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: MPI_Type_commit() call failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Type_commit() call failed.\n", world_mpi_rank, FUNC); } } } - return(success); + return (success); } /* setup_derived_types */ - /***************************************************************************** * * Function: takedown_derived_types() @@ -1296,25 +1191,23 @@ static hbool_t takedown_derived_types(void) { hbool_t success = TRUE; - int result; + int result; result = MPI_Type_free(&mpi_mssg_t); - if ( result != MPI_SUCCESS ) { + if (result != MPI_SUCCESS) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: MPI_Type_free() call failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: MPI_Type_free() call failed.\n", world_mpi_rank, FUNC); } } - return(success); + return (success); } /* takedown_derived_types() */ - /*****************************************************************************/ /***************************** server functions ******************************/ /*****************************************************************************/ @@ -1337,55 +1230,51 @@ static hbool_t reset_server_counters(void) { hbool_t success = TRUE; - int i; - long actual_total_reads = 0; - long actual_total_writes = 0; + int i; + long actual_total_reads = 0; + long actual_total_writes = 0; - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { - if ( data[i].reads > 0 ) { + for (i = 0; i < NUM_DATA_ENTRIES; i++) { + if (data[i].reads > 0) { actual_total_reads += data[i].reads; data[i].reads = 0; } - if ( data[i].writes > 0 ) { + if (data[i].writes > 0) { actual_total_writes += data[i].writes; data[i].writes = 0; } } - if ( actual_total_reads != total_reads ) { + if (actual_total_reads != total_reads) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: actual/total reads mismatch (%ld/%ld).\n", - world_mpi_rank, FUNC, + if (verbose) { + HDfprintf(stdout, "%d:%s: actual/total reads mismatch (%ld/%ld).\n", world_mpi_rank, FUNC, actual_total_reads, total_reads); } } - if ( actual_total_writes != total_writes ) { + if (actual_total_writes != total_writes) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: actual/total writes mismatch (%ld/%ld).\n", - world_mpi_rank, FUNC, + if (verbose) { + HDfprintf(stdout, "%d:%s: actual/total writes mismatch (%ld/%ld).\n", world_mpi_rank, FUNC, actual_total_writes, total_writes); } } - total_reads = 0; + total_reads = 0; total_writes = 0; - return(success); + return (success); } /* reset_server_counters() */ - /***************************************************************************** * * Function: server_main() @@ -1412,131 +1301,126 @@ reset_server_counters(void) static hbool_t server_main(void) { - hbool_t done = FALSE; - hbool_t success = TRUE; - int done_count = 0; + hbool_t done = FALSE; + hbool_t success = TRUE; + int done_count = 0; struct mssg_t mssg; - if ( world_mpi_rank != world_server_mpi_rank ) { + if (world_mpi_rank != world_server_mpi_rank) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: This isn't the server process?!?!?\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: This isn't the server process?!?!?\n", world_mpi_rank, FUNC); } } - - while ( ( success ) && ( ! done ) ) - { + while ((success) && (!done)) { success = recv_mssg(&mssg, 0); - if ( success ) { + if (success) { - switch ( mssg.req ) - { - case WRITE_REQ_CODE: - success = serve_write_request(&mssg); - break; + switch (mssg.req) { + case WRITE_REQ_CODE: + success = serve_write_request(&mssg); + break; - case WRITE_REQ_ACK_CODE: + case WRITE_REQ_ACK_CODE: success = FALSE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Received write ack?!?.\n", FUNC); - break; + break; - case READ_REQ_CODE: + case READ_REQ_CODE: success = serve_read_request(&mssg); - break; + break; - case READ_REQ_REPLY_CODE: + case READ_REQ_REPLY_CODE: success = FALSE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Received read req reply?!?.\n", FUNC); - break; + break; - case SYNC_REQ_CODE: + case SYNC_REQ_CODE: success = serve_sync_request(&mssg); - break; + break; - case SYNC_ACK_CODE: + case SYNC_ACK_CODE: success = FALSE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Received sync ack?!?.\n", FUNC); - break; + break; - case REQ_TTL_WRITES_CODE: - success = serve_total_writes_request(&mssg); - break; + case REQ_TTL_WRITES_CODE: + success = serve_total_writes_request(&mssg); + break; - case REQ_TTL_WRITES_RPLY_CODE: + case REQ_TTL_WRITES_RPLY_CODE: success = FALSE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Received total writes reply?!?.\n", FUNC); - break; + break; - case REQ_TTL_READS_CODE: - success = serve_total_reads_request(&mssg); - break; + case REQ_TTL_READS_CODE: + success = serve_total_reads_request(&mssg); + break; - case REQ_TTL_READS_RPLY_CODE: + case REQ_TTL_READS_RPLY_CODE: success = FALSE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Received total reads reply?!?.\n", FUNC); - break; + break; - case REQ_ENTRY_WRITES_CODE: - success = serve_entry_writes_request(&mssg); - break; + case REQ_ENTRY_WRITES_CODE: + success = serve_entry_writes_request(&mssg); + break; - case REQ_ENTRY_WRITES_RPLY_CODE: + case REQ_ENTRY_WRITES_RPLY_CODE: success = FALSE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Received entry writes reply?!?.\n", FUNC); - break; + break; - case REQ_ENTRY_READS_CODE: - success = serve_entry_reads_request(&mssg); - break; + case REQ_ENTRY_READS_CODE: + success = serve_entry_reads_request(&mssg); + break; - case REQ_ENTRY_READS_RPLY_CODE: + case REQ_ENTRY_READS_RPLY_CODE: success = FALSE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Received entry reads reply?!?.\n", FUNC); - break; + break; - case REQ_RW_COUNT_RESET_CODE: - success = serve_rw_count_reset_request(&mssg); - break; + case REQ_RW_COUNT_RESET_CODE: + success = serve_rw_count_reset_request(&mssg); + break; - case REQ_RW_COUNT_RESET_RPLY_CODE: + case REQ_RW_COUNT_RESET_RPLY_CODE: success = FALSE; - if(verbose) + if (verbose) HDfprintf(stdout, "%s: Received RW count reset reply?!?.\n", FUNC); - break; + break; - case DONE_REQ_CODE: - done_count++; - if(done_count >= file_mpi_size) - done = TRUE; - break; + case DONE_REQ_CODE: + done_count++; + if (done_count >= file_mpi_size) + done = TRUE; + break; - default: + default: nerrors++; success = FALSE; - if(verbose) - HDfprintf(stdout, "%d:%s: Unknown request code.\n", world_mpi_rank, FUNC); - break; + if (verbose) + HDfprintf(stdout, "%d:%s: Unknown request code.\n", world_mpi_rank, FUNC); + break; } } } - return(success); + return (success); } /* server_main() */ - /***************************************************************************** * * Function: serve_read_request() @@ -1556,62 +1440,55 @@ server_main(void) * *****************************************************************************/ static hbool_t -serve_read_request(struct mssg_t * mssg_ptr) +serve_read_request(struct mssg_t *mssg_ptr) { - hbool_t report_mssg = FALSE; - hbool_t success = TRUE; - int target_index; - haddr_t target_addr; + hbool_t report_mssg = FALSE; + hbool_t success = TRUE; + int target_index; + haddr_t target_addr; struct mssg_t reply; - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->req != READ_REQ_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->req != READ_REQ_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { - target_addr = mssg_ptr->base_addr; + target_addr = mssg_ptr->base_addr; target_index = addr_to_datum_index(target_addr); - if ( target_index < 0 ) { + if (target_index < 0) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: addr lookup failed for %a.\n", - world_mpi_rank, FUNC, target_addr); + if (verbose) { + HDfprintf(stdout, "%d:%s: addr lookup failed for %a.\n", world_mpi_rank, FUNC, target_addr); } - } else if ( data[target_index].len != mssg_ptr->len ) { + } + else if (data[target_index].len != mssg_ptr->len) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: data[i].len = %Zu != mssg->len = %d.\n", - world_mpi_rank, FUNC, - data[target_index].len, mssg_ptr->len); + if (verbose) { + HDfprintf(stdout, "%d:%s: data[i].len = %Zu != mssg->len = %d.\n", world_mpi_rank, FUNC, + data[target_index].len, mssg_ptr->len); } - } else if ( ! (data[target_index].valid) ) { + } + else if (!(data[target_index].valid)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: proc %d read invalid entry. idx/base_addr = %d/%a.\n", - world_mpi_rank, FUNC, - mssg_ptr->src, - target_index, - data[target_index].base_addr); + if (verbose) { + HDfprintf(stdout, "%d:%s: proc %d read invalid entry. idx/base_addr = %d/%a.\n", + world_mpi_rank, FUNC, mssg_ptr->src, target_index, data[target_index].base_addr); } - } else { + } + else { /* compose the reply message */ reply.req = READ_REQ_REPLY_CODE; @@ -1620,47 +1497,41 @@ serve_read_request(struct mssg_t * mssg_ptr) reply.mssg_num = -1; /* set by send function */ reply.base_addr = data[target_index].base_addr; H5_CHECKED_ASSIGN(reply.len, unsigned, data[target_index].len, size_t); - reply.ver = data[target_index].ver; - reply.count = 0; - reply.magic = MSSG_MAGIC; + reply.ver = data[target_index].ver; + reply.count = 0; + reply.magic = MSSG_MAGIC; - /* and update the counters */ - total_reads++; + /* and update the counters */ + total_reads++; (data[target_index].reads)++; } } - if ( success ) { + if (success) { success = send_mssg(&reply, TRUE); } - if ( report_mssg ) { + if (report_mssg) { - if ( success ) { + if (success) { - HDfprintf(stdout, "%d read 0x%llx. len = %d. ver = %d.\n", - (int)(mssg_ptr->src), - (long long)(data[target_index].base_addr), - (int)(data[target_index].len), + HDfprintf(stdout, "%d read 0x%llx. len = %d. ver = %d.\n", (int)(mssg_ptr->src), + (long long)(data[target_index].base_addr), (int)(data[target_index].len), (int)(data[target_index].ver)); + } + else { - } else { - - HDfprintf(stdout, "%d read 0x%llx FAILED. len = %d. ver = %d.\n", - (int)(mssg_ptr->src), - (long long)(data[target_index].base_addr), - (int)(data[target_index].len), + HDfprintf(stdout, "%d read 0x%llx FAILED. len = %d. ver = %d.\n", (int)(mssg_ptr->src), + (long long)(data[target_index].base_addr), (int)(data[target_index].len), (int)(data[target_index].ver)); - } } - return(success); + return (success); } /* serve_read_request() */ - /***************************************************************************** * * Function: serve_sync_request() @@ -1683,25 +1554,22 @@ serve_read_request(struct mssg_t * mssg_ptr) * *****************************************************************************/ static hbool_t -serve_sync_request(struct mssg_t * mssg_ptr) +serve_sync_request(struct mssg_t *mssg_ptr) { - hbool_t report_mssg = FALSE; - hbool_t success = TRUE; + hbool_t report_mssg = FALSE; + hbool_t success = TRUE; struct mssg_t reply; - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->req != SYNC_REQ_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->req != SYNC_REQ_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { /* compose the reply message */ reply.req = SYNC_ACK_CODE; @@ -1711,33 +1579,31 @@ serve_sync_request(struct mssg_t * mssg_ptr) reply.base_addr = 0; reply.len = 0; reply.ver = 0; - reply.count = 0; + reply.count = 0; reply.magic = MSSG_MAGIC; } - if ( success ) { + if (success) { success = send_mssg(&reply, TRUE); } - if ( report_mssg ) { + if (report_mssg) { - if ( success ) { + if (success) { HDfprintf(stdout, "%d sync.\n", (int)(mssg_ptr->src)); - - } else { + } + else { HDfprintf(stdout, "%d sync FAILED.\n", (int)(mssg_ptr->src)); - } } - return(success); + return (success); } /* serve_sync_request() */ - /***************************************************************************** * * Function: serve_write_request() @@ -1757,80 +1623,74 @@ serve_sync_request(struct mssg_t * mssg_ptr) * *****************************************************************************/ static hbool_t -serve_write_request(struct mssg_t * mssg_ptr) +serve_write_request(struct mssg_t *mssg_ptr) { hbool_t report_mssg = FALSE; - hbool_t success = TRUE; - int target_index; - int new_ver_num = 0; + hbool_t success = TRUE; + int target_index; + int new_ver_num = 0; haddr_t target_addr; #if DO_WRITE_REQ_ACK struct mssg_t reply; #endif /* DO_WRITE_REQ_ACK */ - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->req != WRITE_REQ_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->req != WRITE_REQ_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { - target_addr = mssg_ptr->base_addr; + target_addr = mssg_ptr->base_addr; target_index = addr_to_datum_index(target_addr); - if ( target_index < 0 ) { + if (target_index < 0) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: addr lookup failed for %a.\n", - world_mpi_rank, FUNC, target_addr); + if (verbose) { + HDfprintf(stdout, "%d:%s: addr lookup failed for %a.\n", world_mpi_rank, FUNC, target_addr); } - } else if ( data[target_index].len != mssg_ptr->len ) { + } + else if (data[target_index].len != mssg_ptr->len) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: data[i].len = %Zu != mssg->len = %d.\n", - world_mpi_rank, FUNC, + if (verbose) { + HDfprintf(stdout, "%d:%s: data[i].len = %Zu != mssg->len = %d.\n", world_mpi_rank, FUNC, data[target_index].len, mssg_ptr->len); } } } - if ( success ) { + if (success) { new_ver_num = mssg_ptr->ver; /* this check should catch duplicate writes */ - if ( new_ver_num <= data[target_index].ver ) { + if (new_ver_num <= data[target_index].ver) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: new ver = %d <= old ver = %d.\n", - world_mpi_rank, FUNC, - new_ver_num, data[target_index].ver); + if (verbose) { + HDfprintf(stdout, "%d:%s: new ver = %d <= old ver = %d.\n", world_mpi_rank, FUNC, new_ver_num, + data[target_index].ver); } } } - if ( success ) { + if (success) { - /* process the write */ - data[target_index].ver = new_ver_num; + /* process the write */ + data[target_index].ver = new_ver_num; data[target_index].valid = TRUE; /* and update the counters */ - total_writes++; + total_writes++; (data[target_index].writes)++; #if DO_WRITE_REQ_ACK @@ -1842,43 +1702,36 @@ serve_write_request(struct mssg_t * mssg_ptr) reply.mssg_num = -1; /* set by send function */ reply.base_addr = data[target_index].base_addr; H5_CHECKED_ASSIGN(reply.len, unsigned, data[target_index].len, size_t); - reply.ver = data[target_index].ver; - reply.count = 0; - reply.magic = MSSG_MAGIC; + reply.ver = data[target_index].ver; + reply.count = 0; + reply.magic = MSSG_MAGIC; - /* and send it */ + /* and send it */ success = send_mssg(&reply, TRUE); #endif /* DO_WRITE_REQ_ACK */ - } - if ( report_mssg ) { + if (report_mssg) { - if ( success ) { + if (success) { - HDfprintf(stdout, "%d write 0x%llx. len = %d. ver = %d.\n", - (int)(mssg_ptr->src), - (long long)(data[target_index].base_addr), - (int)(data[target_index].len), + HDfprintf(stdout, "%d write 0x%llx. len = %d. ver = %d.\n", (int)(mssg_ptr->src), + (long long)(data[target_index].base_addr), (int)(data[target_index].len), (int)(data[target_index].ver)); + } + else { - } else { - - HDfprintf(stdout, "%d write 0x%llx FAILED. len = %d. ver = %d.\n", - (int)(mssg_ptr->src), - (long long)(data[target_index].base_addr), - (int)(data[target_index].len), + HDfprintf(stdout, "%d write 0x%llx FAILED. len = %d. ver = %d.\n", (int)(mssg_ptr->src), + (long long)(data[target_index].base_addr), (int)(data[target_index].len), (int)(data[target_index].ver)); - } } - return(success); + return (success); } /* serve_write_request() */ - /***************************************************************************** * * Function: serve_total_writes_request() @@ -1899,25 +1752,22 @@ serve_write_request(struct mssg_t * mssg_ptr) * *****************************************************************************/ static hbool_t -serve_total_writes_request(struct mssg_t * mssg_ptr) +serve_total_writes_request(struct mssg_t *mssg_ptr) { - hbool_t report_mssg = FALSE; - hbool_t success = TRUE; + hbool_t report_mssg = FALSE; + hbool_t success = TRUE; struct mssg_t reply; - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->req != REQ_TTL_WRITES_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->req != REQ_TTL_WRITES_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { /* compose the reply message */ reply.req = REQ_TTL_WRITES_RPLY_CODE; @@ -1931,33 +1781,27 @@ serve_total_writes_request(struct mssg_t * mssg_ptr) reply.magic = MSSG_MAGIC; } - if ( success ) { + if (success) { success = send_mssg(&reply, TRUE); } - if ( report_mssg ) { - - if ( success ) { - - HDfprintf(stdout, "%d request total writes %ld.\n", - (int)(mssg_ptr->src), - total_writes); + if (report_mssg) { - } else { + if (success) { - HDfprintf(stdout, "%d request total writes %ld -- FAILED.\n", - (int)(mssg_ptr->src), - total_writes); + HDfprintf(stdout, "%d request total writes %ld.\n", (int)(mssg_ptr->src), total_writes); + } + else { + HDfprintf(stdout, "%d request total writes %ld -- FAILED.\n", (int)(mssg_ptr->src), total_writes); } } - return(success); + return (success); } /* serve_total_writes_request() */ - /***************************************************************************** * * Function: serve_total_reads_request() @@ -1978,25 +1822,22 @@ serve_total_writes_request(struct mssg_t * mssg_ptr) * *****************************************************************************/ static hbool_t -serve_total_reads_request(struct mssg_t * mssg_ptr) +serve_total_reads_request(struct mssg_t *mssg_ptr) { - hbool_t report_mssg = FALSE; - hbool_t success = TRUE; + hbool_t report_mssg = FALSE; + hbool_t success = TRUE; struct mssg_t reply; - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->req != REQ_TTL_READS_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->req != REQ_TTL_READS_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { /* compose the reply message */ reply.req = REQ_TTL_READS_RPLY_CODE; @@ -2010,33 +1851,27 @@ serve_total_reads_request(struct mssg_t * mssg_ptr) reply.magic = MSSG_MAGIC; } - if ( success ) { + if (success) { success = send_mssg(&reply, TRUE); } - if ( report_mssg ) { - - if ( success ) { + if (report_mssg) { - HDfprintf(stdout, "%d request total reads %ld.\n", - (int)(mssg_ptr->src), - total_reads); + if (success) { - } else { - - HDfprintf(stdout, "%d request total reads %ld -- FAILED.\n", - (int)(mssg_ptr->src), - total_reads); + HDfprintf(stdout, "%d request total reads %ld.\n", (int)(mssg_ptr->src), total_reads); + } + else { + HDfprintf(stdout, "%d request total reads %ld -- FAILED.\n", (int)(mssg_ptr->src), total_reads); } } - return(success); + return (success); } /* serve_total_reads_request() */ - /***************************************************************************** * * Function: serve_entry_writes_request() @@ -2057,40 +1892,37 @@ serve_total_reads_request(struct mssg_t * mssg_ptr) * *****************************************************************************/ static hbool_t -serve_entry_writes_request(struct mssg_t * mssg_ptr) +serve_entry_writes_request(struct mssg_t *mssg_ptr) { - hbool_t report_mssg = FALSE; - hbool_t success = TRUE; - int target_index; - haddr_t target_addr; + hbool_t report_mssg = FALSE; + hbool_t success = TRUE; + int target_index; + haddr_t target_addr; struct mssg_t reply; - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->req != REQ_ENTRY_WRITES_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->req != REQ_ENTRY_WRITES_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { - target_addr = mssg_ptr->base_addr; + target_addr = mssg_ptr->base_addr; target_index = addr_to_datum_index(target_addr); - if ( target_index < 0 ) { + if (target_index < 0) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: addr lookup failed for %a.\n", - world_mpi_rank, FUNC, target_addr); + if (verbose) { + HDfprintf(stdout, "%d:%s: addr lookup failed for %a.\n", world_mpi_rank, FUNC, target_addr); } - } else { + } + else { /* compose the reply message */ reply.req = REQ_ENTRY_WRITES_RPLY_CODE; @@ -2105,35 +1937,29 @@ serve_entry_writes_request(struct mssg_t * mssg_ptr) } } - if ( success ) { + if (success) { success = send_mssg(&reply, TRUE); } - if ( report_mssg ) { - - if ( success ) { + if (report_mssg) { - HDfprintf(stdout, "%d request entry 0x%llx writes = %ld.\n", - (int)(mssg_ptr->src), - (long long)(data[target_index].base_addr), - (long)(data[target_index].writes)); + if (success) { - } else { - - HDfprintf(stdout, "%d request entry 0x%llx writes = %ld FAILED.\n", - (int)(mssg_ptr->src), - (long long)(data[target_index].base_addr), - (long)(data[target_index].writes)); + HDfprintf(stdout, "%d request entry 0x%llx writes = %ld.\n", (int)(mssg_ptr->src), + (long long)(data[target_index].base_addr), (long)(data[target_index].writes)); + } + else { + HDfprintf(stdout, "%d request entry 0x%llx writes = %ld FAILED.\n", (int)(mssg_ptr->src), + (long long)(data[target_index].base_addr), (long)(data[target_index].writes)); } } - return(success); + return (success); } /* serve_entry_writes_request() */ - /***************************************************************************** * * Function: serve_entry_reads_request() @@ -2154,40 +1980,37 @@ serve_entry_writes_request(struct mssg_t * mssg_ptr) * *****************************************************************************/ static hbool_t -serve_entry_reads_request(struct mssg_t * mssg_ptr) +serve_entry_reads_request(struct mssg_t *mssg_ptr) { - hbool_t report_mssg = FALSE; - hbool_t success = TRUE; - int target_index; - haddr_t target_addr; + hbool_t report_mssg = FALSE; + hbool_t success = TRUE; + int target_index; + haddr_t target_addr; struct mssg_t reply; - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->req != REQ_ENTRY_READS_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->req != REQ_ENTRY_READS_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { - target_addr = mssg_ptr->base_addr; + target_addr = mssg_ptr->base_addr; target_index = addr_to_datum_index(target_addr); - if ( target_index < 0 ) { + if (target_index < 0) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: addr lookup failed for %a.\n", - world_mpi_rank, FUNC, target_addr); + if (verbose) { + HDfprintf(stdout, "%d:%s: addr lookup failed for %a.\n", world_mpi_rank, FUNC, target_addr); } - } else { + } + else { /* compose the reply message */ reply.req = REQ_ENTRY_READS_RPLY_CODE; @@ -2202,35 +2025,29 @@ serve_entry_reads_request(struct mssg_t * mssg_ptr) } } - if ( success ) { + if (success) { success = send_mssg(&reply, TRUE); } - if ( report_mssg ) { - - if ( success ) { + if (report_mssg) { - HDfprintf(stdout, "%d request entry 0x%llx reads = %ld.\n", - (int)(mssg_ptr->src), - (long long)(data[target_index].base_addr), - (long)(data[target_index].reads)); + if (success) { - } else { - - HDfprintf(stdout, "%d request entry 0x%llx reads = %ld FAILED.\n", - (int)(mssg_ptr->src), - (long long)(data[target_index].base_addr), - (long)(data[target_index].reads)); + HDfprintf(stdout, "%d request entry 0x%llx reads = %ld.\n", (int)(mssg_ptr->src), + (long long)(data[target_index].base_addr), (long)(data[target_index].reads)); + } + else { + HDfprintf(stdout, "%d request entry 0x%llx reads = %ld FAILED.\n", (int)(mssg_ptr->src), + (long long)(data[target_index].base_addr), (long)(data[target_index].reads)); } } - return(success); + return (success); } /* serve_entry_reads_request() */ - /***************************************************************************** * * Function: serve_rw_count_reset_request() @@ -2250,30 +2067,27 @@ serve_entry_reads_request(struct mssg_t * mssg_ptr) * *****************************************************************************/ static hbool_t -serve_rw_count_reset_request(struct mssg_t * mssg_ptr) +serve_rw_count_reset_request(struct mssg_t *mssg_ptr) { - hbool_t report_mssg = FALSE; - hbool_t success = TRUE; + hbool_t report_mssg = FALSE; + hbool_t success = TRUE; struct mssg_t reply; - if ( ( mssg_ptr == NULL ) || - ( mssg_ptr->req != REQ_RW_COUNT_RESET_CODE ) || - ( mssg_ptr->magic != MSSG_MAGIC ) ) { + if ((mssg_ptr == NULL) || (mssg_ptr->req != REQ_RW_COUNT_RESET_CODE) || (mssg_ptr->magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad mssg on entry.\n", world_mpi_rank, FUNC); } } - if ( success ) { + if (success) { success = reset_server_counters(); } - if ( success ) { + if (success) { /* compose the reply message */ reply.req = REQ_RW_COUNT_RESET_RPLY_CODE; @@ -2287,36 +2101,31 @@ serve_rw_count_reset_request(struct mssg_t * mssg_ptr) reply.magic = MSSG_MAGIC; } - if ( success ) { + if (success) { success = send_mssg(&reply, TRUE); } - if ( report_mssg ) { + if (report_mssg) { - if ( success ) { + if (success) { - HDfprintf(stdout, "%d request R/W counter reset.\n", - (int)(mssg_ptr->src)); - - } else { - - HDfprintf(stdout, "%d request R/w counter reset FAILED.\n", - (int)(mssg_ptr->src)); + HDfprintf(stdout, "%d request R/W counter reset.\n", (int)(mssg_ptr->src)); + } + else { + HDfprintf(stdout, "%d request R/w counter reset FAILED.\n", (int)(mssg_ptr->src)); } } - return(success); + return (success); } /* serve_rw_count_reset_request() */ - /*****************************************************************************/ /**************************** Call back functions ****************************/ /*****************************************************************************/ - /*------------------------------------------------------------------------- * Function: datum_get_initial_load_size * @@ -2332,40 +2141,38 @@ serve_rw_count_reset_request(struct mssg_t * mssg_ptr) static herr_t datum_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr) { - haddr_t addr = *(haddr_t *)udata_ptr; - int idx; - struct datum * entry_ptr; + haddr_t addr = *(haddr_t *)udata_ptr; + int idx; + struct datum *entry_ptr; - HDassert( udata_ptr ); - HDassert( image_len_ptr ); + HDassert(udata_ptr); + HDassert(image_len_ptr); idx = addr_to_datum_index(addr); - HDassert( idx >= 0 ); - HDassert( idx < NUM_DATA_ENTRIES ); - HDassert( idx < virt_num_data_entries ); + HDassert(idx >= 0); + HDassert(idx < NUM_DATA_ENTRIES); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( addr == entry_ptr->base_addr ); - HDassert( ! entry_ptr->global_pinned ); - HDassert( ! entry_ptr->local_pinned ); + HDassert(addr == entry_ptr->base_addr); + HDassert(!entry_ptr->global_pinned); + HDassert(!entry_ptr->local_pinned); - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: get_initial_load_size() idx = %d, addr = %ld, len = %d.\n", - world_mpi_rank, idx, (long)addr, (int)entry_ptr->local_len); - fflush(stdout); + HDfprintf(stdout, "%d: get_initial_load_size() idx = %d, addr = %ld, len = %d.\n", world_mpi_rank, + idx, (long)addr, (int)entry_ptr->local_len); + fflush(stdout); } /* Set image length size */ *image_len_ptr = entry_ptr->local_len; - return(SUCCEED); + return (SUCCEED); } /* get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: datum_deserialize * @@ -2379,54 +2186,48 @@ datum_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr) *------------------------------------------------------------------------- */ static void * -datum_deserialize(const void H5_ATTR_SANITY_CHECK *image_ptr, - H5_ATTR_UNUSED size_t len, - void * udata_ptr, - hbool_t * dirty_ptr) +datum_deserialize(const void H5_ATTR_SANITY_CHECK *image_ptr, H5_ATTR_UNUSED size_t len, void *udata_ptr, + hbool_t *dirty_ptr) { - haddr_t addr = *(haddr_t *)udata_ptr; - hbool_t success = TRUE; - int idx; - struct datum * entry_ptr = NULL; + haddr_t addr = *(haddr_t *)udata_ptr; + hbool_t success = TRUE; + int idx; + struct datum *entry_ptr = NULL; - HDassert( image_ptr != NULL ); + HDassert(image_ptr != NULL); idx = addr_to_datum_index(addr); - HDassert( idx >= 0 ); - HDassert( idx < NUM_DATA_ENTRIES ); - HDassert( idx < virt_num_data_entries ); + HDassert(idx >= 0); + HDassert(idx < NUM_DATA_ENTRIES); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( addr == entry_ptr->base_addr ); - HDassert( ! entry_ptr->global_pinned ); - HDassert( ! entry_ptr->local_pinned ); + HDassert(addr == entry_ptr->base_addr); + HDassert(!entry_ptr->global_pinned); + HDassert(!entry_ptr->local_pinned); - HDassert( dirty_ptr ); + HDassert(dirty_ptr); - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: deserialize() idx = %d, addr = %ld, len = %d, is_dirty = %d.\n", - world_mpi_rank, idx, (long)addr, (int)len, - (int)(entry_ptr->header.is_dirty)); - fflush(stdout); + HDfprintf(stdout, "%d: deserialize() idx = %d, addr = %ld, len = %d, is_dirty = %d.\n", + world_mpi_rank, idx, (long)addr, (int)len, (int)(entry_ptr->header.is_dirty)); + fflush(stdout); } *dirty_ptr = FALSE; - if ( ! success ) { + if (!success) { entry_ptr = NULL; - } - return(entry_ptr); + return (entry_ptr); } /* deserialize() */ - /*------------------------------------------------------------------------- * Function: datum_image_len * @@ -2445,39 +2246,36 @@ datum_deserialize(const void H5_ATTR_SANITY_CHECK *image_ptr, static herr_t datum_image_len(const void *thing, size_t *image_len) { - int idx; - struct datum * entry_ptr; + int idx; + struct datum *entry_ptr; - HDassert( thing ); - HDassert( image_len ); + HDassert(thing); + HDassert(image_len); entry_ptr = (struct datum *)thing; idx = addr_to_datum_index(entry_ptr->base_addr); - HDassert( idx >= 0 ); - HDassert( idx < NUM_DATA_ENTRIES ); - HDassert( idx < virt_num_data_entries ); - HDassert( &(data[idx]) == entry_ptr ); - HDassert( entry_ptr->local_len > 0 ); - HDassert( entry_ptr->local_len <= entry_ptr->len ); + HDassert(idx >= 0); + HDassert(idx < NUM_DATA_ENTRIES); + HDassert(idx < virt_num_data_entries); + HDassert(&(data[idx]) == entry_ptr); + HDassert(entry_ptr->local_len > 0); + HDassert(entry_ptr->local_len <= entry_ptr->len); - if(callbacks_verbose) { - HDfprintf(stdout, - "%d: image_len() idx = %d, addr = %ld, len = %d.\n", - world_mpi_rank, idx, (long)(entry_ptr->base_addr), - (int)(entry_ptr->local_len)); - fflush(stdout); + if (callbacks_verbose) { + HDfprintf(stdout, "%d: image_len() idx = %d, addr = %ld, len = %d.\n", world_mpi_rank, idx, + (long)(entry_ptr->base_addr), (int)(entry_ptr->local_len)); + fflush(stdout); } - HDassert( entry_ptr->header.addr == entry_ptr->base_addr ); + HDassert(entry_ptr->header.addr == entry_ptr->base_addr); *image_len = entry_ptr->local_len; - return(SUCCEED); + return (SUCCEED); } /* datum_image_len() */ - /*------------------------------------------------------------------------- * Function: datum_serialize * @@ -2491,68 +2289,62 @@ datum_image_len(const void *thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -datum_serialize(const H5F_t *f, - void H5_ATTR_SANITY_CHECK *image_ptr, - size_t len, - void *thing_ptr) +datum_serialize(const H5F_t *f, void H5_ATTR_SANITY_CHECK *image_ptr, size_t len, void *thing_ptr) { - herr_t ret_value = SUCCEED; - int idx; - struct datum * entry_ptr; - struct H5AC_aux_t * aux_ptr; + herr_t ret_value = SUCCEED; + int idx; + struct datum * entry_ptr; + struct H5AC_aux_t *aux_ptr; - HDassert( thing_ptr ); - HDassert( image_ptr ); + HDassert(thing_ptr); + HDassert(image_ptr); entry_ptr = (struct datum *)thing_ptr; - HDassert( f ); - HDassert( f->shared ); - HDassert( f->shared->cache ); - HDassert( f->shared->cache->magic == H5C__H5C_T_MAGIC ); - HDassert( f->shared->cache->aux_ptr ); + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->cache); + HDassert(f->shared->cache->magic == H5C__H5C_T_MAGIC); + HDassert(f->shared->cache->aux_ptr); aux_ptr = (H5AC_aux_t *)(f->shared->cache->aux_ptr); - HDassert( aux_ptr ); - HDassert( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC ); + HDassert(aux_ptr); + HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); entry_ptr->aux_ptr = aux_ptr; idx = addr_to_datum_index(entry_ptr->base_addr); - HDassert( idx >= 0 ); - HDassert( idx < NUM_DATA_ENTRIES ); - HDassert( idx < virt_num_data_entries ); - HDassert( &(data[idx]) == entry_ptr ); + HDassert(idx >= 0); + HDassert(idx < NUM_DATA_ENTRIES); + HDassert(idx < virt_num_data_entries); + HDassert(&(data[idx]) == entry_ptr); - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: serialize() idx = %d, addr = %ld, len = %d.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr, (int)len); - fflush(stdout); + HDfprintf(stdout, "%d: serialize() idx = %d, addr = %ld, len = %d.\n", world_mpi_rank, idx, + (long)entry_ptr->header.addr, (int)len); + fflush(stdout); } - HDassert( entry_ptr->header.addr == entry_ptr->base_addr ); - HDassert( ( entry_ptr->header.size == entry_ptr->len ) || - ( entry_ptr->header.size == entry_ptr->local_len ) ); + HDassert(entry_ptr->header.addr == entry_ptr->base_addr); + HDassert((entry_ptr->header.size == entry_ptr->len) || (entry_ptr->header.size == entry_ptr->local_len)); - HDassert( entry_ptr->header.is_dirty == entry_ptr->dirty ); + HDassert(entry_ptr->header.is_dirty == entry_ptr->dirty); datum_flushes++; - if ( entry_ptr->header.is_pinned ) { + if (entry_ptr->header.is_pinned) { datum_pinned_flushes++; - HDassert( entry_ptr->global_pinned || entry_ptr->local_pinned ); + HDassert(entry_ptr->global_pinned || entry_ptr->local_pinned); } - return(ret_value); + return (ret_value); } /* datum_serialize() */ - /*------------------------------------------------------------------------- * Function: datum_notify * @@ -2569,61 +2361,56 @@ datum_serialize(const H5F_t *f, static herr_t datum_notify(H5C_notify_action_t action, void *thing) { - hbool_t was_dirty = FALSE; - herr_t ret_value = SUCCEED; - struct datum * entry_ptr; - struct H5AC_aux_t * aux_ptr; - struct mssg_t mssg; - int idx; + hbool_t was_dirty = FALSE; + herr_t ret_value = SUCCEED; + struct datum * entry_ptr; + struct H5AC_aux_t *aux_ptr; + struct mssg_t mssg; + int idx; - HDassert( thing ); + HDassert(thing); entry_ptr = (struct datum *)thing; idx = addr_to_datum_index(entry_ptr->base_addr); - HDassert( idx >= 0 ); - HDassert( idx < NUM_DATA_ENTRIES ); - HDassert( idx < virt_num_data_entries ); - HDassert( &(data[idx]) == entry_ptr ); + HDassert(idx >= 0); + HDassert(idx < NUM_DATA_ENTRIES); + HDassert(idx < virt_num_data_entries); + HDassert(&(data[idx]) == entry_ptr); - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = %d, idx = %d, addr = %ld.\n", - world_mpi_rank, (int) action, idx, - (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = %d, idx = %d, addr = %ld.\n", world_mpi_rank, (int)action, + idx, (long)entry_ptr->header.addr); fflush(stdout); } - HDassert( entry_ptr->header.addr == entry_ptr->base_addr ); + HDassert(entry_ptr->header.addr == entry_ptr->base_addr); /* Skip this check when the entry is being dirtied, since the resize * operation sends the message before the len/local_len is updated * (after the resize operation completes successfully) (QAK - 2016/10/19) */ - if(H5AC_NOTIFY_ACTION_ENTRY_DIRTIED != action) - HDassert( ( entry_ptr->header.size == entry_ptr->len ) || - ( entry_ptr->header.size == entry_ptr->local_len ) ); + if (H5AC_NOTIFY_ACTION_ENTRY_DIRTIED != action) + HDassert((entry_ptr->header.size == entry_ptr->len) || + (entry_ptr->header.size == entry_ptr->local_len)); - switch ( action ) - { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = insert, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = insert, idx = %d, addr = %ld.\n", world_mpi_rank, + idx, (long)entry_ptr->header.addr); fflush(stdout); } /* do nothing */ break; case H5AC_NOTIFY_ACTION_AFTER_LOAD: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = load, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = load, idx = %d, addr = %ld.\n", world_mpi_rank, idx, + (long)entry_ptr->header.addr); fflush(stdout); } @@ -2634,52 +2421,45 @@ datum_notify(H5C_notify_action_t action, void *thing) mssg.mssg_num = -1; /* set by send function */ mssg.base_addr = entry_ptr->base_addr; H5_CHECKED_ASSIGN(mssg.len, unsigned, entry_ptr->len, size_t); - mssg.ver = 0; /* bogus -- should be corrected by server */ - mssg.count = 0; /* not used */ - mssg.magic = MSSG_MAGIC; + mssg.ver = 0; /* bogus -- should be corrected by server */ + mssg.count = 0; /* not used */ + mssg.magic = MSSG_MAGIC; - if ( ! send_mssg(&mssg, FALSE) ) { + if (!send_mssg(&mssg, FALSE)) { nerrors++; ret_value = FAIL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", world_mpi_rank, FUNC); } } - if ( ret_value == SUCCEED ) { + if (ret_value == SUCCEED) { - if ( ! recv_mssg(&mssg, READ_REQ_REPLY_CODE) ) { + if (!recv_mssg(&mssg, READ_REQ_REPLY_CODE)) { nerrors++; ret_value = FAIL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( ret_value == SUCCEED ) { + if (ret_value == SUCCEED) { - if ( ( mssg.req != READ_REQ_REPLY_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != entry_ptr->base_addr ) || - ( mssg.len != entry_ptr->len ) || - ( mssg.ver < entry_ptr->ver ) || - ( mssg.magic != MSSG_MAGIC ) ) { + if ((mssg.req != READ_REQ_REPLY_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != entry_ptr->base_addr) || + (mssg.len != entry_ptr->len) || (mssg.ver < entry_ptr->ver) || + (mssg.magic != MSSG_MAGIC)) { nerrors++; ret_value = FAIL; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: Bad data in read req reply.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in read req reply.\n", world_mpi_rank, FUNC); } -#if 0 /* This has been useful debugging code -- keep it for now. */ +#if 0 /* This has been useful debugging code -- keep it for now. */ if ( mssg.req != READ_REQ_REPLY_CODE ) { HDfprintf(stdout, @@ -2738,48 +2518,44 @@ datum_notify(H5C_notify_action_t action, void *thing) world_mpi_rank, FUNC); } #endif /* JRM */ + } + else { - } else { - - entry_ptr->ver = mssg.ver; + entry_ptr->ver = mssg.ver; entry_ptr->dirty = FALSE; datum_loads++; } } break; - case H5C_NOTIFY_ACTION_AFTER_FLUSH: - if ( callbacks_verbose ) { + case H5C_NOTIFY_ACTION_AFTER_FLUSH: + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = flush, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = flush, idx = %d, addr = %ld.\n", world_mpi_rank, idx, + (long)entry_ptr->header.addr); fflush(stdout); } - HDassert( entry_ptr->aux_ptr ); - HDassert( entry_ptr->aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC ); - aux_ptr = entry_ptr->aux_ptr; + HDassert(entry_ptr->aux_ptr); + HDassert(entry_ptr->aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); + aux_ptr = entry_ptr->aux_ptr; entry_ptr->aux_ptr = NULL; - HDassert(entry_ptr->header.is_dirty); /* JRM */ + HDassert(entry_ptr->header.is_dirty); /* JRM */ - if ( ( file_mpi_rank != 0 ) && - ( entry_ptr->dirty ) && - ( aux_ptr->metadata_write_strategy == - H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY ) ) { + if ((file_mpi_rank != 0) && (entry_ptr->dirty) && + (aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY)) { ret_value = FAIL; - HDfprintf(stdout, - "%d:%s: Flushed dirty entry from non-zero file process.", - world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: Flushed dirty entry from non-zero file process.", world_mpi_rank, + FUNC); } - if ( ret_value == SUCCEED ) { + if (ret_value == SUCCEED) { - if ( entry_ptr->header.is_dirty ) { + if (entry_ptr->header.is_dirty) { - was_dirty = TRUE; /* so we will receive the ack + was_dirty = TRUE; /* so we will receive the ack * if requested */ @@ -2790,53 +2566,46 @@ datum_notify(H5C_notify_action_t action, void *thing) mssg.mssg_num = -1; /* set by send function */ mssg.base_addr = entry_ptr->base_addr; H5_CHECKED_ASSIGN(mssg.len, unsigned, entry_ptr->len, size_t); - mssg.ver = entry_ptr->ver; - mssg.count = 0; - mssg.magic = MSSG_MAGIC; + mssg.ver = entry_ptr->ver; + mssg.count = 0; + mssg.magic = MSSG_MAGIC; - if ( ! send_mssg(&mssg, FALSE) ) { + if (!send_mssg(&mssg, FALSE)) { nerrors++; ret_value = FAIL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", world_mpi_rank, FUNC); } } - else - { - entry_ptr->dirty = FALSE; - entry_ptr->flushed = TRUE; + else { + entry_ptr->dirty = FALSE; + entry_ptr->flushed = TRUE; } } } #if DO_WRITE_REQ_ACK - if ( ( ret_value == SUCCEED ) && ( was_dirty ) ) { + if ((ret_value == SUCCEED) && (was_dirty)) { - if ( ! recv_mssg(&mssg, WRITE_REQ_ACK_CODE) ) { + if (!recv_mssg(&mssg, WRITE_REQ_ACK_CODE)) { nerrors++; ret_value = FAIL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } - } else if ( ( mssg.req != WRITE_REQ_ACK_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != entry_ptr->base_addr ) || - ( mssg.len != entry_ptr->len ) || - ( mssg.ver != entry_ptr->ver ) || - ( mssg.magic != MSSG_MAGIC ) ) { + } + else if ((mssg.req != WRITE_REQ_ACK_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != entry_ptr->base_addr) || + (mssg.len != entry_ptr->len) || (mssg.ver != entry_ptr->ver) || + (mssg.magic != MSSG_MAGIC)) { nerrors++; ret_value = FAIL; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: Bad data in write req ack.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in write req ack.\n", world_mpi_rank, FUNC); } } } @@ -2845,19 +2614,18 @@ datum_notify(H5C_notify_action_t action, void *thing) datum_flushes++; - if ( entry_ptr->header.is_pinned ) { + if (entry_ptr->header.is_pinned) { datum_pinned_flushes++; HDassert(entry_ptr->global_pinned || entry_ptr->local_pinned); } - break; + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = evict, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = evict, idx = %d, addr = %ld.\n", world_mpi_rank, idx, + (long)entry_ptr->header.addr); fflush(stdout); } @@ -2865,11 +2633,10 @@ datum_notify(H5C_notify_action_t action, void *thing) break; case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = entry dirty, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = entry dirty, idx = %d, addr = %ld.\n", + world_mpi_rank, idx, (long)entry_ptr->header.addr); fflush(stdout); } @@ -2877,32 +2644,30 @@ datum_notify(H5C_notify_action_t action, void *thing) break; case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = entry clean, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = entry clean, idx = %d, addr = %ld.\n", + world_mpi_rank, idx, (long)entry_ptr->header.addr); fflush(stdout); } entry_ptr->cleared = TRUE; - entry_ptr->dirty = FALSE; + entry_ptr->dirty = FALSE; datum_clears++; - if(entry_ptr->header.is_pinned) { + if (entry_ptr->header.is_pinned) { datum_pinned_clears++; - HDassert( entry_ptr->global_pinned || entry_ptr->local_pinned ); + HDassert(entry_ptr->global_pinned || entry_ptr->local_pinned); } /* end if */ break; case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = child entry dirty, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = child entry dirty, idx = %d, addr = %ld.\n", + world_mpi_rank, idx, (long)entry_ptr->header.addr); fflush(stdout); } @@ -2910,11 +2675,10 @@ datum_notify(H5C_notify_action_t action, void *thing) break; case H5AC_NOTIFY_ACTION_CHILD_CLEANED: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = child entry clean, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = child entry clean, idx = %d, addr = %ld.\n", + world_mpi_rank, idx, (long)entry_ptr->header.addr); fflush(stdout); } @@ -2922,11 +2686,10 @@ datum_notify(H5C_notify_action_t action, void *thing) break; case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = child entry unserialized, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = child entry unserialized, idx = %d, addr = %ld.\n", + world_mpi_rank, idx, (long)entry_ptr->header.addr); fflush(stdout); } @@ -2934,32 +2697,29 @@ datum_notify(H5C_notify_action_t action, void *thing) break; case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: notify() action = child entry serialized, idx = %d, addr = %ld.\n", - world_mpi_rank, idx, (long)entry_ptr->header.addr); + HDfprintf(stdout, "%d: notify() action = child entry serialized, idx = %d, addr = %ld.\n", + world_mpi_rank, idx, (long)entry_ptr->header.addr); fflush(stdout); } /* do nothing */ break; - default: + default: nerrors++; ret_value = FAIL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Unknown notify action.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Unknown notify action.\n", world_mpi_rank, FUNC); } - break; + break; } - return(ret_value); + return (ret_value); } /* datum_notify() */ - /*------------------------------------------------------------------------- * Function: datum_free_icr * @@ -2977,45 +2737,42 @@ datum_notify(H5C_notify_action_t action, void *thing) *------------------------------------------------------------------------- */ static herr_t -datum_free_icr(void * thing) +datum_free_icr(void *thing) { - int idx; - struct datum * entry_ptr; + int idx; + struct datum *entry_ptr; - HDassert( thing ); + HDassert(thing); entry_ptr = (struct datum *)thing; idx = addr_to_datum_index(entry_ptr->base_addr); - HDassert( idx >= 0 ); - HDassert( idx < NUM_DATA_ENTRIES ); - HDassert( idx < virt_num_data_entries ); - HDassert( &(data[idx]) == entry_ptr ); + HDassert(idx >= 0); + HDassert(idx < NUM_DATA_ENTRIES); + HDassert(idx < virt_num_data_entries); + HDassert(&(data[idx]) == entry_ptr); - if ( callbacks_verbose ) { + if (callbacks_verbose) { - HDfprintf(stdout, - "%d: free_icr() idx = %d, dirty = %d.\n", - world_mpi_rank, idx, (int)(entry_ptr->dirty)); - fflush(stdout); + HDfprintf(stdout, "%d: free_icr() idx = %d, dirty = %d.\n", world_mpi_rank, idx, + (int)(entry_ptr->dirty)); + fflush(stdout); } - HDassert( entry_ptr->header.addr == entry_ptr->base_addr ); - HDassert( ( entry_ptr->header.size == entry_ptr->len ) || - ( entry_ptr->header.size == entry_ptr->local_len ) ); + HDassert(entry_ptr->header.addr == entry_ptr->base_addr); + HDassert((entry_ptr->header.size == entry_ptr->len) || (entry_ptr->header.size == entry_ptr->local_len)); - HDassert( !(entry_ptr->header.is_dirty) ); - HDassert( !(entry_ptr->global_pinned) ); - HDassert( !(entry_ptr->local_pinned) ); - HDassert( !(entry_ptr->header.is_pinned) ); + HDassert(!(entry_ptr->header.is_dirty)); + HDassert(!(entry_ptr->global_pinned)); + HDassert(!(entry_ptr->local_pinned)); + HDassert(!(entry_ptr->header.is_pinned)); datum_destroys++; - return(SUCCEED); + return (SUCCEED); } /* datum_free_icr() */ - /*****************************************************************************/ /************************** test utility functions ***************************/ /*****************************************************************************/ @@ -3035,57 +2792,54 @@ datum_free_icr(void * thing) * *****************************************************************************/ static void -expunge_entry(H5F_t * file_ptr, - int32_t idx) +expunge_entry(H5F_t *file_ptr, int32_t idx) { - hbool_t in_cache; - herr_t result; - struct datum * entry_ptr; + hbool_t in_cache; + herr_t result; + struct datum *entry_ptr; - HDassert( file_ptr ); - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert(file_ptr); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( !(entry_ptr->locked) ); - HDassert( !(entry_ptr->global_pinned) ); - HDassert( !(entry_ptr->local_pinned) ); + HDassert(!(entry_ptr->locked)); + HDassert(!(entry_ptr->global_pinned)); + HDassert(!(entry_ptr->local_pinned)); entry_ptr->dirty = FALSE; - if ( nerrors == 0 ) { + if (nerrors == 0) { result = H5AC_expunge_entry(file_ptr, &(types[0]), entry_ptr->header.addr, H5AC__NO_FLAGS_SET); - if ( result < 0 ) { + if (result < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Error in H5AC_expunge_entry().\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Error in H5AC_expunge_entry().\n", world_mpi_rank, FUNC); } } - HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); - HDassert( ! ((entry_ptr->header).is_dirty) ); + HDassert(((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); + HDassert(!((entry_ptr->header).is_dirty)); - result = H5C_get_entry_status(file_ptr, entry_ptr->base_addr, - NULL, &in_cache, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + result = H5C_get_entry_status(file_ptr, entry_ptr->base_addr, NULL, &in_cache, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); - if ( result < 0 ) { + if (result < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Error in H5C_get_entry_status().\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Error in H5C_get_entry_status().\n", world_mpi_rank, FUNC); } - } else if ( in_cache ) { + } + else if (in_cache) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Expunged entry still in cache?!?\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Expunged entry still in cache?!?\n", world_mpi_rank, FUNC); } } } @@ -3094,7 +2848,6 @@ expunge_entry(H5F_t * file_ptr, } /* expunge_entry() */ - /***************************************************************************** * Function: insert_entry() * @@ -3117,93 +2870,83 @@ expunge_entry(H5F_t * file_ptr, * *****************************************************************************/ static void -insert_entry(H5C_t * cache_ptr, - H5F_t * file_ptr, - int32_t idx, - unsigned int flags) +insert_entry(H5C_t *cache_ptr, H5F_t *file_ptr, int32_t idx, unsigned int flags) { - hbool_t insert_pinned; - herr_t result; - struct datum * entry_ptr; + hbool_t insert_pinned; + herr_t result; + struct datum *entry_ptr; - HDassert( cache_ptr ); - HDassert( file_ptr ); - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert(cache_ptr); + HDassert(file_ptr); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( !(entry_ptr->locked) ); + HDassert(!(entry_ptr->locked)); - insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0 ); + insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0); - if ( nerrors == 0 ) { + if (nerrors == 0) { (entry_ptr->ver)++; entry_ptr->dirty = TRUE; - result = H5AC_insert_entry(file_ptr, &(types[0]), - entry_ptr->base_addr, (void *)(&(entry_ptr->header)), flags); + result = H5AC_insert_entry(file_ptr, &(types[0]), entry_ptr->base_addr, + (void *)(&(entry_ptr->header)), flags); - if ( ( result < 0 ) || - ( entry_ptr->header.type != &(types[0]) ) || - ( entry_ptr->len != entry_ptr->header.size ) || - ( entry_ptr->base_addr != entry_ptr->header.addr ) ) { + if ((result < 0) || (entry_ptr->header.type != &(types[0])) || + (entry_ptr->len != entry_ptr->header.size) || (entry_ptr->base_addr != entry_ptr->header.addr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Error in H5AC_insert_entry().\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Error in H5AC_insert_entry().\n", world_mpi_rank, FUNC); } } - if ( ! (entry_ptr->header.is_dirty) ) { + if (!(entry_ptr->header.is_dirty)) { - /* it is possible that we just exceeded the dirty bytes - * threshold, triggering a write of the newly inserted - * entry. Test for this, and only flag an error if this - * is not the case. - */ + /* it is possible that we just exceeded the dirty bytes + * threshold, triggering a write of the newly inserted + * entry. Test for this, and only flag an error if this + * is not the case. + */ - struct H5AC_aux_t * aux_ptr; + struct H5AC_aux_t *aux_ptr; - aux_ptr = ((H5AC_aux_t *)(cache_ptr->aux_ptr)); + aux_ptr = ((H5AC_aux_t *)(cache_ptr->aux_ptr)); - if ( ! ( ( aux_ptr != NULL ) && - ( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC ) && - ( aux_ptr->dirty_bytes == 0 ) ) ) { + if (!((aux_ptr != NULL) && (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC) && + (aux_ptr->dirty_bytes == 0))) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: data[%d].header.is_dirty = %d.\n", - world_mpi_rank, FUNC, idx, + if (verbose) { + HDfprintf(stdout, "%d:%s: data[%d].header.is_dirty = %d.\n", world_mpi_rank, FUNC, idx, (int)(data[idx].header.is_dirty)); - } + } } } - if ( insert_pinned ) { + if (insert_pinned) { - HDassert( entry_ptr->header.is_pinned ); + HDassert(entry_ptr->header.is_pinned); entry_ptr->global_pinned = TRUE; - global_pins++; - - } else { + global_pins++; + } + else { - HDassert( ! ( entry_ptr->header.is_pinned ) ); + HDassert(!(entry_ptr->header.is_pinned)); entry_ptr->global_pinned = FALSE; - } /* HDassert( entry_ptr->header.is_dirty ); */ - HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + HDassert(((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); } return; } /* insert_entry() */ - /***************************************************************************** * Function: local_pin_and_unpin_random_entries() * @@ -3219,59 +2962,52 @@ insert_entry(H5C_t * cache_ptr, * *****************************************************************************/ static void -local_pin_and_unpin_random_entries(H5F_t * file_ptr, - int min_idx, - int max_idx, - int min_count, - int max_count) +local_pin_and_unpin_random_entries(H5F_t *file_ptr, int min_idx, int max_idx, int min_count, int max_count) { - if ( nerrors == 0 ) { + if (nerrors == 0) { hbool_t via_unprotect; - int count; - int i; - int idx; - - HDassert( file_ptr ); - HDassert( 0 <= min_idx ); - HDassert( min_idx < max_idx ); - HDassert( max_idx < NUM_DATA_ENTRIES ); - HDassert( max_idx < virt_num_data_entries ); - HDassert( 0 <= min_count ); - HDassert( min_count < max_count ); + int count; + int i; + int idx; + + HDassert(file_ptr); + HDassert(0 <= min_idx); + HDassert(min_idx < max_idx); + HDassert(max_idx < NUM_DATA_ENTRIES); + HDassert(max_idx < virt_num_data_entries); + HDassert(0 <= min_count); + HDassert(min_count < max_count); - count = (HDrand() % (max_count - min_count)) + min_count; + count = (HDrand() % (max_count - min_count)) + min_count; - HDassert( min_count <= count ); - HDassert( count <= max_count ); + HDassert(min_count <= count); + HDassert(count <= max_count); - for ( i = 0; i < count; i++ ) - { + for (i = 0; i < count; i++) { local_pin_random_entry(file_ptr, min_idx, max_idx); - } + } - count = (HDrand() % (max_count - min_count)) + min_count; + count = (HDrand() % (max_count - min_count)) + min_count; - HDassert( min_count <= count ); - HDassert( count <= max_count ); + HDassert(min_count <= count); + HDassert(count <= max_count); - i = 0; - idx = 0; + i = 0; + idx = 0; - while ( ( i < count ) && ( idx >= 0 ) ) - { - via_unprotect = ( (((unsigned)i) & 0x0001) == 0 ); - idx = local_unpin_next_pinned_entry(file_ptr, idx, via_unprotect); - i++; - } + while ((i < count) && (idx >= 0)) { + via_unprotect = ((((unsigned)i) & 0x0001) == 0); + idx = local_unpin_next_pinned_entry(file_ptr, idx, via_unprotect); + i++; + } } return; } /* local_pin_and_unpin_random_entries() */ - /***************************************************************************** * Function: local_pin_random_entry() * @@ -3289,27 +3025,23 @@ local_pin_and_unpin_random_entries(H5F_t * file_ptr, * *****************************************************************************/ static void -local_pin_random_entry(H5F_t * file_ptr, - int min_idx, - int max_idx) +local_pin_random_entry(H5F_t *file_ptr, int min_idx, int max_idx) { int idx; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( file_ptr ); - HDassert( 0 <= min_idx ); - HDassert( min_idx < max_idx ); - HDassert( max_idx < NUM_DATA_ENTRIES ); - HDassert( max_idx < virt_num_data_entries ); + HDassert(file_ptr); + HDassert(0 <= min_idx); + HDassert(min_idx < max_idx); + HDassert(max_idx < NUM_DATA_ENTRIES); + HDassert(max_idx < virt_num_data_entries); - do - { + do { idx = (HDrand() % (max_idx - min_idx)) + min_idx; - HDassert( min_idx <= idx ); - HDassert( idx <= max_idx ); - } - while ( data[idx].global_pinned || data[idx].local_pinned ); + HDassert(min_idx <= idx); + HDassert(idx <= max_idx); + } while (data[idx].global_pinned || data[idx].local_pinned); pin_entry(file_ptr, idx, FALSE, FALSE); } @@ -3318,7 +3050,6 @@ local_pin_random_entry(H5F_t * file_ptr, } /* local_pin_random_entry() */ - /***************************************************************************** * Function: local_unpin_all_entries() * @@ -3333,30 +3064,26 @@ local_pin_random_entry(H5F_t * file_ptr, * *****************************************************************************/ static void -local_unpin_all_entries(H5F_t * file_ptr, - hbool_t via_unprotect) +local_unpin_all_entries(H5F_t *file_ptr, hbool_t via_unprotect) { - if ( nerrors == 0 ) { + if (nerrors == 0) { int idx; - HDassert( file_ptr ); + HDassert(file_ptr); - idx = 0; + idx = 0; - while ( idx >= 0 ) - { - idx = local_unpin_next_pinned_entry(file_ptr, - idx, via_unprotect); - } + while (idx >= 0) { + idx = local_unpin_next_pinned_entry(file_ptr, idx, via_unprotect); + } } return; } /* local_unpin_all_entries() */ - /***************************************************************************** * Function: local_unpin_next_pinned_entry() * @@ -3374,47 +3101,42 @@ local_unpin_all_entries(H5F_t * file_ptr, * *****************************************************************************/ static int -local_unpin_next_pinned_entry(H5F_t * file_ptr, - int start_idx, - hbool_t via_unprotect) +local_unpin_next_pinned_entry(H5F_t *file_ptr, int start_idx, hbool_t via_unprotect) { - int i = 0; + int i = 0; int idx = -1; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( file_ptr ); - HDassert( 0 <= start_idx ); - HDassert( start_idx < NUM_DATA_ENTRIES ); - HDassert( start_idx < virt_num_data_entries ); + HDassert(file_ptr); + HDassert(0 <= start_idx); + HDassert(start_idx < NUM_DATA_ENTRIES); + HDassert(start_idx < virt_num_data_entries); - idx = start_idx; + idx = start_idx; - while ( ( i < virt_num_data_entries ) && - ( ! ( data[idx].local_pinned ) ) ) - { - i++; - idx++; - if ( idx >= virt_num_data_entries ) { - idx = 0; + while ((i < virt_num_data_entries) && (!(data[idx].local_pinned))) { + i++; + idx++; + if (idx >= virt_num_data_entries) { + idx = 0; + } } - } - - if ( data[idx].local_pinned ) { - unpin_entry(file_ptr, idx, FALSE, FALSE, via_unprotect); + if (data[idx].local_pinned) { - } else { + unpin_entry(file_ptr, idx, FALSE, FALSE, via_unprotect); + } + else { - idx = -1; - } + idx = -1; + } } - return(idx); + return (idx); } /* local_unpin_next_pinned_entry() */ - /***************************************************************************** * Function: lock_and_unlock_random_entries() * @@ -3431,28 +3153,23 @@ local_unpin_next_pinned_entry(H5F_t * file_ptr, * *****************************************************************************/ static void -lock_and_unlock_random_entries(H5F_t * file_ptr, - int min_idx, - int max_idx, - int min_count, - int max_count) +lock_and_unlock_random_entries(H5F_t *file_ptr, int min_idx, int max_idx, int min_count, int max_count) { int count; int i; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( file_ptr ); - HDassert( 0 <= min_count ); - HDassert( min_count < max_count ); + HDassert(file_ptr); + HDassert(0 <= min_count); + HDassert(min_count < max_count); count = (HDrand() % (max_count - min_count)) + min_count; - HDassert( min_count <= count ); - HDassert( count <= max_count ); + HDassert(min_count <= count); + HDassert(count <= max_count); - for ( i = 0; i < count; i++ ) - { + for (i = 0; i < count; i++) { lock_and_unlock_random_entry(file_ptr, min_idx, max_idx); } } @@ -3461,7 +3178,6 @@ lock_and_unlock_random_entries(H5F_t * file_ptr, } /* lock_and_unlock_random_entries() */ - /***************************************************************************** * Function: lock_and_unlock_random_entry() * @@ -3477,34 +3193,31 @@ lock_and_unlock_random_entries(H5F_t * file_ptr, * *****************************************************************************/ static void -lock_and_unlock_random_entry(H5F_t * file_ptr, - int min_idx, - int max_idx) +lock_and_unlock_random_entry(H5F_t *file_ptr, int min_idx, int max_idx) { int idx; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( file_ptr ); - HDassert( 0 <= min_idx ); - HDassert( min_idx < max_idx ); - HDassert( max_idx < NUM_DATA_ENTRIES ); - HDassert( max_idx < virt_num_data_entries ); + HDassert(file_ptr); + HDassert(0 <= min_idx); + HDassert(min_idx < max_idx); + HDassert(max_idx < NUM_DATA_ENTRIES); + HDassert(max_idx < virt_num_data_entries); idx = (HDrand() % (max_idx - min_idx)) + min_idx; - HDassert( min_idx <= idx ); - HDassert( idx <= max_idx ); + HDassert(min_idx <= idx); + HDassert(idx <= max_idx); - lock_entry(file_ptr, idx); - unlock_entry(file_ptr, idx, H5AC__NO_FLAGS_SET); + lock_entry(file_ptr, idx); + unlock_entry(file_ptr, idx, H5AC__NO_FLAGS_SET); } return; } /* lock_and_unlock_random_entry() */ - /***************************************************************************** * Function: lock_entry() * @@ -3525,51 +3238,45 @@ lock_and_unlock_random_entry(H5F_t * file_ptr, * *****************************************************************************/ static void -lock_entry(H5F_t * file_ptr, - int32_t idx) +lock_entry(H5F_t *file_ptr, int32_t idx) { - struct datum * entry_ptr; - H5C_cache_entry_t * cache_entry_ptr; + struct datum * entry_ptr; + H5C_cache_entry_t *cache_entry_ptr; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( ! (entry_ptr->locked) ); + HDassert(!(entry_ptr->locked)); - cache_entry_ptr = (H5C_cache_entry_t *)H5AC_protect(file_ptr, - &(types[0]), entry_ptr->base_addr, - &entry_ptr->base_addr, - H5AC__NO_FLAGS_SET); + cache_entry_ptr = (H5C_cache_entry_t *)H5AC_protect(file_ptr, &(types[0]), entry_ptr->base_addr, + &entry_ptr->base_addr, H5AC__NO_FLAGS_SET); - if ( ( cache_entry_ptr != (void *)(&(entry_ptr->header)) ) || - ( entry_ptr->header.type != &(types[0]) ) || - ( ( entry_ptr->len != entry_ptr->header.size ) && - ( entry_ptr->local_len != entry_ptr->header.size ) ) || - ( entry_ptr->base_addr != entry_ptr->header.addr ) ) { + if ((cache_entry_ptr != (void *)(&(entry_ptr->header))) || (entry_ptr->header.type != &(types[0])) || + ((entry_ptr->len != entry_ptr->header.size) && + (entry_ptr->local_len != entry_ptr->header.size)) || + (entry_ptr->base_addr != entry_ptr->header.addr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: error in H5AC_protect().\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: error in H5AC_protect().\n", world_mpi_rank, FUNC); } - } else { - - entry_ptr->locked = TRUE; + } + else { - } + entry_ptr->locked = TRUE; + } - HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + HDassert(((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); } return; } /* lock_entry() */ - /***************************************************************************** * Function: mark_entry_dirty() * @@ -3586,44 +3293,40 @@ lock_entry(H5F_t * file_ptr, static void mark_entry_dirty(int32_t idx) { - herr_t result; - struct datum * entry_ptr; + herr_t result; + struct datum *entry_ptr; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert ( entry_ptr->locked || entry_ptr->global_pinned ); - HDassert ( ! (entry_ptr->local_pinned) ); + HDassert(entry_ptr->locked || entry_ptr->global_pinned); + HDassert(!(entry_ptr->local_pinned)); (entry_ptr->ver)++; entry_ptr->dirty = TRUE; - result = H5AC_mark_entry_dirty( (void *)entry_ptr); + result = H5AC_mark_entry_dirty((void *)entry_ptr); - if ( result < 0 ) { + if (result < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: error in H5AC_mark_entry_dirty().\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: error in H5AC_mark_entry_dirty().\n", world_mpi_rank, FUNC); } } - else if ( ! ( entry_ptr->locked ) ) - { - global_dirty_pins++; - } + else if (!(entry_ptr->locked)) { + global_dirty_pins++; + } } return; } /* mark_entry_dirty() */ - /***************************************************************************** * Function: pin_entry() * @@ -3638,58 +3341,53 @@ mark_entry_dirty(int32_t idx) * *****************************************************************************/ static void -pin_entry(H5F_t * file_ptr, - int32_t idx, - hbool_t global, - hbool_t dirty) +pin_entry(H5F_t *file_ptr, int32_t idx, hbool_t global, hbool_t dirty) { - unsigned int flags = H5AC__PIN_ENTRY_FLAG; - struct datum * entry_ptr; + unsigned int flags = H5AC__PIN_ENTRY_FLAG; + struct datum *entry_ptr; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( file_ptr ); - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert(file_ptr); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert ( ! (entry_ptr->global_pinned) ); - HDassert ( ! (entry_ptr->local_pinned) ); - HDassert ( ! ( dirty && ( ! global ) ) ); + HDassert(!(entry_ptr->global_pinned)); + HDassert(!(entry_ptr->local_pinned)); + HDassert(!(dirty && (!global))); - lock_entry(file_ptr, idx); - - if ( dirty ) { - - flags |= H5AC__DIRTIED_FLAG; - } + lock_entry(file_ptr, idx); - unlock_entry(file_ptr, idx, flags); + if (dirty) { - HDassert( (entry_ptr->header).is_pinned ); - HDassert( ( ! dirty ) || ( (entry_ptr->header).is_dirty ) ); + flags |= H5AC__DIRTIED_FLAG; + } - if ( global ) { + unlock_entry(file_ptr, idx, flags); - entry_ptr->global_pinned = TRUE; + HDassert((entry_ptr->header).is_pinned); + HDassert((!dirty) || ((entry_ptr->header).is_dirty)); - global_pins++; + if (global) { - } else { + entry_ptr->global_pinned = TRUE; - entry_ptr->local_pinned = TRUE; + global_pins++; + } + else { - local_pins++; + entry_ptr->local_pinned = TRUE; - } + local_pins++; + } } return; } /* pin_entry() */ - /***************************************************************************** * Function: pin_protected_entry() * @@ -3705,60 +3403,53 @@ pin_entry(H5F_t * file_ptr, * *****************************************************************************/ static void -pin_protected_entry(int32_t idx, - hbool_t global) +pin_protected_entry(int32_t idx, hbool_t global) { - herr_t result; - struct datum * entry_ptr; + herr_t result; + struct datum *entry_ptr; - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( entry_ptr->locked ); + HDassert(entry_ptr->locked); - if ( nerrors == 0 ) { + if (nerrors == 0) { - result = H5AC_pin_protected_entry((void *)entry_ptr); + result = H5AC_pin_protected_entry((void *)entry_ptr); - if ( ( result < 0 ) || - ( entry_ptr->header.type != &(types[0]) ) || - ( ( entry_ptr->len != entry_ptr->header.size ) && - ( entry_ptr->local_len != entry_ptr->header.size ) )|| - ( entry_ptr->base_addr != entry_ptr->header.addr ) || - ( ! ( (entry_ptr->header).is_pinned ) ) ) { + if ((result < 0) || (entry_ptr->header.type != &(types[0])) || + ((entry_ptr->len != entry_ptr->header.size) && + (entry_ptr->local_len != entry_ptr->header.size)) || + (entry_ptr->base_addr != entry_ptr->header.addr) || (!((entry_ptr->header).is_pinned))) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: Error in H5AC_pin_protected entry().\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Error in H5AC_pin_protected entry().\n", world_mpi_rank, FUNC); } } - if ( global ) { - - entry_ptr->global_pinned = TRUE; - - global_pins++; + if (global) { - } else { + entry_ptr->global_pinned = TRUE; - entry_ptr->local_pinned = TRUE; + global_pins++; + } + else { - local_pins++; + entry_ptr->local_pinned = TRUE; - } + local_pins++; + } - HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + HDassert(((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); } return; } /* pin_protected_entry() */ - /***************************************************************************** * Function: move_entry() * @@ -3776,33 +3467,31 @@ pin_protected_entry(int32_t idx, * *****************************************************************************/ static void -move_entry(H5F_t * file_ptr, - int32_t old_idx, - int32_t new_idx) +move_entry(H5F_t *file_ptr, int32_t old_idx, int32_t new_idx) { - herr_t result; + herr_t result; int tmp; - size_t tmp_len; - haddr_t old_addr = HADDR_UNDEF; - haddr_t new_addr = HADDR_UNDEF; - struct datum * old_entry_ptr; - struct datum * new_entry_ptr; + size_t tmp_len; + haddr_t old_addr = HADDR_UNDEF; + haddr_t new_addr = HADDR_UNDEF; + struct datum *old_entry_ptr; + struct datum *new_entry_ptr; - if ( ( nerrors == 0 ) && ( old_idx != new_idx ) ) { + if ((nerrors == 0) && (old_idx != new_idx)) { - HDassert( file_ptr ); - HDassert( ( 0 <= old_idx ) && ( old_idx < NUM_DATA_ENTRIES ) ); - HDassert( old_idx < virt_num_data_entries ); - HDassert( ( 0 <= new_idx ) && ( new_idx < NUM_DATA_ENTRIES ) ); - HDassert( new_idx < virt_num_data_entries ); + HDassert(file_ptr); + HDassert((0 <= old_idx) && (old_idx < NUM_DATA_ENTRIES)); + HDassert(old_idx < virt_num_data_entries); + HDassert((0 <= new_idx) && (new_idx < NUM_DATA_ENTRIES)); + HDassert(new_idx < virt_num_data_entries); old_entry_ptr = &(data[old_idx]); new_entry_ptr = &(data[new_idx]); - HDassert( ((old_entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); - HDassert( !(old_entry_ptr->header.is_protected) ); - HDassert( !(old_entry_ptr->locked) ); - HDassert( old_entry_ptr->len == new_entry_ptr->len ); + HDassert(((old_entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); + HDassert(!(old_entry_ptr->header.is_protected)); + HDassert(!(old_entry_ptr->locked)); + HDassert(old_entry_ptr->len == new_entry_ptr->len); old_addr = old_entry_ptr->base_addr; new_addr = new_entry_ptr->base_addr; @@ -3814,8 +3503,8 @@ move_entry(H5F_t * file_ptr, * now as it is possible that the rename will trigger a * sync point. */ - if(old_entry_ptr->ver < new_entry_ptr->ver) - old_entry_ptr->ver = new_entry_ptr->ver; + if (old_entry_ptr->ver < new_entry_ptr->ver) + old_entry_ptr->ver = new_entry_ptr->ver; else (old_entry_ptr->ver)++; @@ -3829,60 +3518,56 @@ move_entry(H5F_t * file_ptr, old_entry_ptr->index = new_entry_ptr->index; new_entry_ptr->index = tmp; - if(old_entry_ptr->local_len != new_entry_ptr->local_len) { - tmp_len = old_entry_ptr->local_len; - old_entry_ptr->local_len = new_entry_ptr->local_len; - new_entry_ptr->local_len = tmp_len; - } /* end if */ + if (old_entry_ptr->local_len != new_entry_ptr->local_len) { + tmp_len = old_entry_ptr->local_len; + old_entry_ptr->local_len = new_entry_ptr->local_len; + new_entry_ptr->local_len = tmp_len; + } /* end if */ result = H5AC_move_entry(file_ptr, &(types[0]), old_addr, new_addr); - if ( ( result < 0 ) || ( old_entry_ptr->header.addr != new_addr ) ) { + if ((result < 0) || (old_entry_ptr->header.addr != new_addr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5AC_move_entry() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5AC_move_entry() failed.\n", world_mpi_rank, FUNC); } + } + else { - } else { - - HDassert( ((old_entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + HDassert(((old_entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); - if ( ! (old_entry_ptr->header.is_dirty) ) { + if (!(old_entry_ptr->header.is_dirty)) { - /* it is possible that we just exceeded the dirty bytes - * threshold, triggering a write of the newly inserted - * entry. Test for this, and only flag an error if this - * is not the case. - */ + /* it is possible that we just exceeded the dirty bytes + * threshold, triggering a write of the newly inserted + * entry. Test for this, and only flag an error if this + * is not the case. + */ - struct H5AC_aux_t * aux_ptr; + struct H5AC_aux_t *aux_ptr; - aux_ptr = ((H5AC_aux_t *)(file_ptr->shared->cache->aux_ptr)); + aux_ptr = ((H5AC_aux_t *)(file_ptr->shared->cache->aux_ptr)); - if ( ! ( ( aux_ptr != NULL ) && - ( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC ) && - ( aux_ptr->dirty_bytes == 0 ) ) ) { + if (!((aux_ptr != NULL) && (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC) && + (aux_ptr->dirty_bytes == 0))) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: data[%d].header.is_dirty = %d.\n", - world_mpi_rank, FUNC, new_idx, - (int)(data[new_idx].header.is_dirty)); - } + if (verbose) { + HDfprintf(stdout, "%d:%s: data[%d].header.is_dirty = %d.\n", world_mpi_rank, FUNC, + new_idx, (int)(data[new_idx].header.is_dirty)); + } } - } else { + } + else { - HDassert( old_entry_ptr->header.is_dirty ); + HDassert(old_entry_ptr->header.is_dirty); } } } } /* move_entry() */ - /***************************************************************************** * * Function: reset_server_counts() @@ -3900,10 +3585,10 @@ move_entry(H5F_t * file_ptr, static hbool_t reset_server_counts(void) { - hbool_t success = TRUE; /* will set to FALSE if appropriate. */ + hbool_t success = TRUE; /* will set to FALSE if appropriate. */ struct mssg_t mssg; - if ( success ) { + if (success) { /* compose the message */ mssg.req = REQ_RW_COUNT_RESET_CODE; @@ -3916,51 +3601,42 @@ reset_server_counts(void) mssg.count = 0; mssg.magic = MSSG_MAGIC; - if ( ! send_mssg(&mssg, FALSE) ) { + if (!send_mssg(&mssg, FALSE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( success ) { + if (success) { - if ( ! recv_mssg(&mssg, REQ_RW_COUNT_RESET_RPLY_CODE) ) { + if (!recv_mssg(&mssg, REQ_RW_COUNT_RESET_RPLY_CODE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } - } else if ( ( mssg.req != REQ_RW_COUNT_RESET_RPLY_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != 0 ) || - ( mssg.len != 0 ) || - ( mssg.ver != 0 ) || - ( mssg.count != 0 ) || - ( mssg.magic != MSSG_MAGIC ) ) { + } + else if ((mssg.req != REQ_RW_COUNT_RESET_RPLY_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != 0) || (mssg.len != 0) || + (mssg.ver != 0) || (mssg.count != 0) || (mssg.magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: Bad data in req r/w counter reset reply.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in req r/w counter reset reply.\n", world_mpi_rank, FUNC); } } } - return(success); + return (success); } /* reset_server_counts() */ - /***************************************************************************** * Function: resize_entry() * @@ -3977,46 +3653,43 @@ reset_server_counts(void) * *****************************************************************************/ static void -resize_entry(int32_t idx, - size_t new_size) +resize_entry(int32_t idx, size_t new_size) { - herr_t result; - struct datum * entry_ptr; + herr_t result; + struct datum *entry_ptr; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); - HDassert( !(entry_ptr->locked) ); - HDassert( ( entry_ptr->global_pinned ) && - ( ! entry_ptr->local_pinned ) ); - HDassert( ( entry_ptr->header.size == entry_ptr->len ) || - ( entry_ptr->header.size == entry_ptr->local_len ) ); - HDassert( new_size > 0 ); - HDassert( new_size <= entry_ptr->len ); + HDassert(((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); + HDassert(!(entry_ptr->locked)); + HDassert((entry_ptr->global_pinned) && (!entry_ptr->local_pinned)); + HDassert((entry_ptr->header.size == entry_ptr->len) || + (entry_ptr->header.size == entry_ptr->local_len)); + HDassert(new_size > 0); + HDassert(new_size <= entry_ptr->len); - result = H5AC_resize_entry((void *)entry_ptr, new_size); + result = H5AC_resize_entry((void *)entry_ptr, new_size); - if ( result < 0 ) { + if (result < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5AC_resize_entry() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5AC_resize_entry() failed.\n", world_mpi_rank, FUNC); } + } + else { - } else { - - HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); - HDassert( entry_ptr->header.is_dirty ); - HDassert( entry_ptr->header.size == new_size ); + HDassert(((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); + HDassert(entry_ptr->header.is_dirty); + HDassert(entry_ptr->header.size == new_size); - entry_ptr->dirty = TRUE; - entry_ptr->local_len = new_size; + entry_ptr->dirty = TRUE; + entry_ptr->local_len = new_size; /* touch up version. */ @@ -4028,7 +3701,6 @@ resize_entry(int32_t idx, } /* resize_entry() */ - /***************************************************************************** * * Function: setup_cache_for_test() @@ -4049,103 +3721,94 @@ resize_entry(int32_t idx, * *****************************************************************************/ static hbool_t -setup_cache_for_test(hid_t * fid_ptr, - H5F_t ** file_ptr_ptr, - H5C_t ** cache_ptr_ptr, - int metadata_write_strategy) +setup_cache_for_test(hid_t *fid_ptr, H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr, int metadata_write_strategy) { - hbool_t success = FALSE; /* will set to TRUE if appropriate. */ - hbool_t enable_rpt_fcn = FALSE; - hid_t fid = -1; + hbool_t success = FALSE; /* will set to TRUE if appropriate. */ + hbool_t enable_rpt_fcn = FALSE; + hid_t fid = -1; H5AC_cache_config_t config; H5AC_cache_config_t test_config; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - haddr_t actual_base_addr; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + haddr_t actual_base_addr; - HDassert ( fid_ptr != NULL ); - HDassert ( file_ptr_ptr != NULL ); - HDassert ( cache_ptr_ptr != NULL ); + HDassert(fid_ptr != NULL); + HDassert(file_ptr_ptr != NULL); + HDassert(cache_ptr_ptr != NULL); fid = H5Fcreate(filenames[0], H5F_ACC_TRUNC, H5P_DEFAULT, fapl); /* Push API context */ H5CX_push(); - if ( fid < 0 ) { + if (fid < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fcreate() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Fcreate() failed.\n", world_mpi_rank, FUNC); } - } else if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { + } + else if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", world_mpi_rank, FUNC); } - } else { + } + else { file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE); } - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Can't get file_ptr.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Can't get file_ptr.\n", world_mpi_rank, FUNC); } - } else { + } + else { cache_ptr = file_ptr->shared->cache; } - if ( cache_ptr == NULL ) { + if (cache_ptr == NULL) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Can't get cache_ptr.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Can't get cache_ptr.\n", world_mpi_rank, FUNC); } - } else if ( cache_ptr->magic != H5C__H5C_T_MAGIC ) { + } + else if (cache_ptr->magic != H5C__H5C_T_MAGIC) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad cache_ptr magic.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad cache_ptr magic.\n", world_mpi_rank, FUNC); } - } else { + } + else { cache_ptr->ignore_tags = TRUE; - *fid_ptr = fid; - *file_ptr_ptr = file_ptr; - *cache_ptr_ptr = cache_ptr; + *fid_ptr = fid; + *file_ptr_ptr = file_ptr; + *cache_ptr_ptr = cache_ptr; H5C_stats__reset(cache_ptr); success = TRUE; } - if ( success ) { + if (success) { config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if ( H5AC_get_cache_auto_resize_config(cache_ptr, &config) - != SUCCEED ) { + if (H5AC_get_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { - HDfprintf(stdout, - "%d:%s: H5AC_get_cache_auto_resize_config(1) failed.\n", - world_mpi_rank, FUNC); - - } else { + HDfprintf(stdout, "%d:%s: H5AC_get_cache_auto_resize_config(1) failed.\n", world_mpi_rank, FUNC); + } + else { config.rpt_fcn_enabled = enable_rpt_fcn; config.metadata_write_strategy = metadata_write_strategy; - if ( H5AC_set_cache_auto_resize_config(cache_ptr, &config) - != SUCCEED ) { - - HDfprintf(stdout, - "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", - world_mpi_rank, FUNC); + if (H5AC_set_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { - } else if ( enable_rpt_fcn ) { + HDfprintf(stdout, "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", world_mpi_rank, + FUNC); + } + else if (enable_rpt_fcn) { - HDfprintf(stdout, "%d:%s: rpt_fcn enabled.\n", - world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: rpt_fcn enabled.\n", world_mpi_rank, FUNC); } } } @@ -4155,32 +3818,29 @@ setup_cache_for_test(hid_t * fid_ptr, * we can't do our usual checks in the serial case. */ - if ( success ) /* verify that the metadata write strategy is as expected */ + if (success) /* verify that the metadata write strategy is as expected */ { - if ( cache_ptr->aux_ptr == NULL ) { + if (cache_ptr->aux_ptr == NULL) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: cache_ptr->aux_ptr == NULL.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: cache_ptr->aux_ptr == NULL.\n", world_mpi_rank, FUNC); } - } else if ( ((H5AC_aux_t *)(cache_ptr->aux_ptr))->magic != - H5AC__H5AC_AUX_T_MAGIC ) { + } + else if (((H5AC_aux_t *)(cache_ptr->aux_ptr))->magic != H5AC__H5AC_AUX_T_MAGIC) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: cache_ptr->aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: cache_ptr->aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC.\n", + world_mpi_rank, FUNC); } - } else if( ((H5AC_aux_t *)(cache_ptr->aux_ptr))->metadata_write_strategy - != metadata_write_strategy ) { + } + else if (((H5AC_aux_t *)(cache_ptr->aux_ptr))->metadata_write_strategy != metadata_write_strategy) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: bad cache_ptr->aux_ptr->metadata_write_strategy\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: bad cache_ptr->aux_ptr->metadata_write_strategy\n", world_mpi_rank, + FUNC); } } } @@ -4189,27 +3849,21 @@ setup_cache_for_test(hid_t * fid_ptr, * when we get the current configuration. */ - if ( success ) { + if (success) { test_config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if ( H5AC_get_cache_auto_resize_config(cache_ptr, &test_config) - != SUCCEED ) { - - HDfprintf(stdout, - "%d:%s: H5AC_get_cache_auto_resize_config(2) failed.\n", - world_mpi_rank, FUNC); + if (H5AC_get_cache_auto_resize_config(cache_ptr, &test_config) != SUCCEED) { - } else if ( test_config.metadata_write_strategy != - metadata_write_strategy ) { + HDfprintf(stdout, "%d:%s: H5AC_get_cache_auto_resize_config(2) failed.\n", world_mpi_rank, FUNC); + } + else if (test_config.metadata_write_strategy != metadata_write_strategy) { nerrors++; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "%d:%s: unexpected metadata_write_strategy.\n", - world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: unexpected metadata_write_strategy.\n", world_mpi_rank, FUNC); } } } @@ -4219,85 +3873,76 @@ setup_cache_for_test(hid_t * fid_ptr, * another flush. If the sync point done callback is set, this will * cause a spurious failure. */ - if ( success ) { /* allocate space for test entries */ + if (success) { /* allocate space for test entries */ - actual_base_addr = H5MF_alloc(file_ptr, H5FD_MEM_DEFAULT, - (hsize_t)(max_addr + BASE_ADDR)); + actual_base_addr = H5MF_alloc(file_ptr, H5FD_MEM_DEFAULT, (hsize_t)(max_addr + BASE_ADDR)); - if ( actual_base_addr == HADDR_UNDEF ) { + if (actual_base_addr == HADDR_UNDEF) { success = FALSE; - nerrors++; + nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5MF_alloc() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5MF_alloc() failed.\n", world_mpi_rank, FUNC); } - - } else if ( actual_base_addr > BASE_ADDR ) { + } + else if (actual_base_addr > BASE_ADDR) { /* If this happens, must increase BASE_ADDR so that the * actual_base_addr is <= BASE_ADDR. This should only happen * if the size of the superblock is increase. */ success = FALSE; - nerrors++; + nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: actual_base_addr > BASE_ADDR.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: actual_base_addr > BASE_ADDR.\n", world_mpi_rank, FUNC); } } } - /* flush the file again -- space allocation dirtied superblock */ - if ( success ) { + if (success) { - if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: second H5Fflush() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: second H5Fflush() failed.\n", world_mpi_rank, FUNC); } } } #if DO_SYNC_AFTER_WRITE - if ( success ) { + if (success) { - if ( H5AC__set_write_done_callback(cache_ptr, do_sync) != SUCCEED ) { + if (H5AC__set_write_done_callback(cache_ptr, do_sync) != SUCCEED) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: H5C_set_write_done_callback failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5C_set_write_done_callback failed.\n", world_mpi_rank, FUNC); } - } + } } #endif /* DO_SYNC_AFTER_WRITE */ - if ( success ) { + if (success) { - if ( H5AC__set_sync_point_done_callback(cache_ptr, verify_writes) != SUCCEED ) { + if (H5AC__set_sync_point_done_callback(cache_ptr, verify_writes) != SUCCEED) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: H5AC__set_sync_point_done_callback failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5AC__set_sync_point_done_callback failed.\n", world_mpi_rank, + FUNC); } - } + } } - return(success); + return (success); } /* setup_cache_for_test() */ - /***************************************************************************** * * Function: verify_writes() @@ -4328,34 +3973,32 @@ setup_cache_for_test(hid_t * fid_ptr, static void verify_writes(unsigned num_writes, haddr_t *written_entries_tbl) { - const hbool_t report = FALSE; - hbool_t proceed = TRUE; - unsigned u = 0; + const hbool_t report = FALSE; + hbool_t proceed = TRUE; + unsigned u = 0; - HDassert( world_mpi_rank != world_server_mpi_rank ); - HDassert( ( num_writes == 0 ) || - ( written_entries_tbl != NULL ) ); + HDassert(world_mpi_rank != world_server_mpi_rank); + HDassert((num_writes == 0) || (written_entries_tbl != NULL)); /* barrier to ensure that all other processes are ready to leave * the sync point as well. */ - if ( proceed ) { + if (proceed) { - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { proceed = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: barrier 1 failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: barrier 1 failed.\n", world_mpi_rank, FUNC); } } } - if(proceed) + if (proceed) proceed = verify_total_writes(num_writes); - while(proceed && u < num_writes) { + while (proceed && u < num_writes) { proceed = verify_entry_writes(written_entries_tbl[u], 1); u++; } @@ -4363,37 +4006,33 @@ verify_writes(unsigned num_writes, haddr_t *written_entries_tbl) /* barrier to ensure that all other processes have finished verifying * the number of writes before we reset the counters. */ - if ( proceed ) { + if (proceed) { - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { proceed = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: barrier 2 failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: barrier 2 failed.\n", world_mpi_rank, FUNC); } } } - if ( proceed ) { + if (proceed) { proceed = reset_server_counts(); } /* if requested, display status of check to stdout */ - if ( ( report ) && ( file_mpi_rank == 0 ) ) { - - if ( proceed ) { + if ((report) && (file_mpi_rank == 0)) { - HDfprintf(stdout, "%d:%s: verified %u writes.\n", - world_mpi_rank, FUNC, num_writes); + if (proceed) { - } else { - - HDfprintf(stdout, "%d:%s: FAILED to verify %u writes.\n", - world_mpi_rank, FUNC, num_writes); + HDfprintf(stdout, "%d:%s: verified %u writes.\n", world_mpi_rank, FUNC, num_writes); + } + else { + HDfprintf(stdout, "%d:%s: FAILED to verify %u writes.\n", world_mpi_rank, FUNC, num_writes); } } @@ -4403,15 +4042,14 @@ verify_writes(unsigned num_writes, haddr_t *written_entries_tbl) * but I can think of at least one likely change to the metadata write * strategies that will require it -- hence its insertion now. */ - if ( proceed ) { + if (proceed) { - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { proceed = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: barrier 3 failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: barrier 3 failed.\n", world_mpi_rank, FUNC); } } } @@ -4420,7 +4058,6 @@ verify_writes(unsigned num_writes, haddr_t *written_entries_tbl) } /* verify_writes() */ - /***************************************************************************** * * Function: setup_rand() @@ -4443,38 +4080,35 @@ verify_writes(unsigned num_writes, haddr_t *written_entries_tbl) static void setup_rand(void) { - hbool_t use_predefined_seeds = FALSE; - int num_predefined_seeds = 3; - unsigned predefined_seeds[3] = {18669, 89925, 12577}; - unsigned seed; + hbool_t use_predefined_seeds = FALSE; + int num_predefined_seeds = 3; + unsigned predefined_seeds[3] = {18669, 89925, 12577}; + unsigned seed; struct timeval tv; - if ( ( use_predefined_seeds ) && - ( world_mpi_size == num_predefined_seeds ) ) { + if ((use_predefined_seeds) && (world_mpi_size == num_predefined_seeds)) { - HDassert( world_mpi_rank >= 0 ); - HDassert( world_mpi_rank < world_mpi_size ); + HDassert(world_mpi_rank >= 0); + HDassert(world_mpi_rank < world_mpi_size); - seed = predefined_seeds[world_mpi_rank]; - HDfprintf(stdout, "%d:%s: predefined_seed = %d.\n", - world_mpi_rank, FUNC, seed); + seed = predefined_seeds[world_mpi_rank]; + HDfprintf(stdout, "%d:%s: predefined_seed = %d.\n", world_mpi_rank, FUNC, seed); fflush(stdout); - HDsrand(seed); - - } else { + HDsrand(seed); + } + else { - if ( HDgettimeofday(&tv, NULL) != 0 ) { + if (HDgettimeofday(&tv, NULL) != 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: gettimeofday() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: gettimeofday() failed.\n", world_mpi_rank, FUNC); } - } else { + } + else { seed = (unsigned)tv.tv_usec; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: seed = %d.\n", - world_mpi_rank, FUNC, seed); + if (verbose) { + HDfprintf(stdout, "%d:%s: seed = %d.\n", world_mpi_rank, FUNC, seed); fflush(stdout); } HDsrand(seed); @@ -4485,7 +4119,6 @@ setup_rand(void) } /* setup_rand() */ - /***************************************************************************** * * Function: take_down_cache() @@ -4503,20 +4136,19 @@ setup_rand(void) * *****************************************************************************/ static hbool_t -take_down_cache(hid_t fid, H5C_t * cache_ptr) +take_down_cache(hid_t fid, H5C_t *cache_ptr) { hbool_t success = TRUE; /* will set to FALSE if appropriate. */ /* flush the file -- this should write out any remaining test * entries in the cache. */ - if ( ( success ) && ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) ) { + if ((success) && (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", world_mpi_rank, FUNC); } } @@ -4525,65 +4157,58 @@ take_down_cache(hid_t fid, H5C_t * cache_ptr) * un-related to the test entries, and thereby corrupt our counts * of entry writes. */ - if ( success ) { + if (success) { - if ( H5AC__set_sync_point_done_callback(cache_ptr, NULL) != SUCCEED ) { + if (H5AC__set_sync_point_done_callback(cache_ptr, NULL) != SUCCEED) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: H5AC__set_sync_point_done_callback failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5AC__set_sync_point_done_callback failed.\n", world_mpi_rank, + FUNC); } } - - } /* close the file */ - if ( ( success ) && ( H5Fclose(fid) < 0 ) ) { + if ((success) && (H5Fclose(fid) < 0)) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fclose() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Fclose() failed.\n", world_mpi_rank, FUNC); } - } /* Pop API context */ H5CX_pop(); - if ( success ) { + if (success) { - if ( world_mpi_rank == world_server_mpi_rank ) { + if (world_mpi_rank == world_server_mpi_rank) { - if ( HDremove(filenames[0]) < 0 ) { + if (HDremove(filenames[0]) < 0) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: HDremove() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: HDremove() failed.\n", world_mpi_rank, FUNC); } } - } else { + } + else { - /* verify that there have been no further writes of test + /* verify that there have been no further writes of test * entries during the close */ success = verify_total_writes(0); - } } - return(success); + return (success); } /* take_down_cache() */ - /***************************************************************************** * Function: verify_entry_reads * @@ -4605,14 +4230,13 @@ take_down_cache(hid_t fid, H5C_t * cache_ptr) *------------------------------------------------------------------------- */ static hbool_t -verify_entry_reads(haddr_t addr, - int expected_entry_reads) +verify_entry_reads(haddr_t addr, int expected_entry_reads) { - hbool_t success = TRUE; - int reported_entry_reads = 0; + hbool_t success = TRUE; + int reported_entry_reads = 0; struct mssg_t mssg; - if ( success ) { + if (success) { /* compose the message */ mssg.req = REQ_ENTRY_READS_CODE; @@ -4625,72 +4249,63 @@ verify_entry_reads(haddr_t addr, mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( ! send_mssg(&mssg, FALSE) ) { + if (!send_mssg(&mssg, FALSE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( success ) { + if (success) { - if ( ! recv_mssg(&mssg, REQ_ENTRY_READS_RPLY_CODE) ) { + if (!recv_mssg(&mssg, REQ_ENTRY_READS_RPLY_CODE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( success ) { + if (success) { - if ( ( mssg.req != REQ_ENTRY_READS_RPLY_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != addr ) || - ( mssg.len != 0 ) || - ( mssg.ver != 0 ) || - ( mssg.magic != MSSG_MAGIC ) ) { + if ((mssg.req != REQ_ENTRY_READS_RPLY_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != addr) || (mssg.len != 0) || (mssg.ver != 0) || + (mssg.magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad data in req entry reads reply.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in req entry reads reply.\n", world_mpi_rank, FUNC); } - } else { + } + else { H5_CHECKED_ASSIGN(reported_entry_reads, int, mssg.count, unsigned); } } - if ( success ) { + if (success) { - if ( reported_entry_reads != expected_entry_reads ) { + if (reported_entry_reads != expected_entry_reads) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: rep/exp entry 0x%llx reads mismatch (%ld/%ld).\n", - world_mpi_rank, FUNC, (long long)addr, - reported_entry_reads, expected_entry_reads); + if (verbose) { + HDfprintf(stdout, "%d:%s: rep/exp entry 0x%llx reads mismatch (%ld/%ld).\n", world_mpi_rank, + FUNC, (long long)addr, reported_entry_reads, expected_entry_reads); } } } - return(success); + return (success); } /* verify_entry_reads() */ - /***************************************************************************** * Function: verify_entry_writes * @@ -4712,14 +4327,13 @@ verify_entry_reads(haddr_t addr, *------------------------------------------------------------------------- */ static hbool_t -verify_entry_writes(haddr_t addr, - int expected_entry_writes) +verify_entry_writes(haddr_t addr, int expected_entry_writes) { - hbool_t success = TRUE; - int reported_entry_writes = 0; + hbool_t success = TRUE; + int reported_entry_writes = 0; struct mssg_t mssg; - if ( success ) { + if (success) { /* compose the message */ mssg.req = REQ_ENTRY_WRITES_CODE; @@ -4732,72 +4346,63 @@ verify_entry_writes(haddr_t addr, mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( ! send_mssg(&mssg, FALSE) ) { + if (!send_mssg(&mssg, FALSE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( success ) { + if (success) { - if ( ! recv_mssg(&mssg, REQ_ENTRY_WRITES_RPLY_CODE) ) { + if (!recv_mssg(&mssg, REQ_ENTRY_WRITES_RPLY_CODE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( success ) { + if (success) { - if ( ( mssg.req != REQ_ENTRY_WRITES_RPLY_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != addr ) || - ( mssg.len != 0 ) || - ( mssg.ver != 0 ) || - ( mssg.magic != MSSG_MAGIC ) ) { + if ((mssg.req != REQ_ENTRY_WRITES_RPLY_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != addr) || (mssg.len != 0) || (mssg.ver != 0) || + (mssg.magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad data in req entry writes reply.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in req entry writes reply.\n", world_mpi_rank, FUNC); } - } else { + } + else { H5_CHECKED_ASSIGN(reported_entry_writes, int, mssg.count, unsigned); } } - if ( success ) { + if (success) { - if ( reported_entry_writes != expected_entry_writes ) { + if (reported_entry_writes != expected_entry_writes) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: rep/exp entry 0x%llx writes mismatch (%ld/%ld).\n", - world_mpi_rank, FUNC, (long long)addr, - reported_entry_writes, expected_entry_writes); + if (verbose) { + HDfprintf(stdout, "%d:%s: rep/exp entry 0x%llx writes mismatch (%ld/%ld).\n", world_mpi_rank, + FUNC, (long long)addr, reported_entry_writes, expected_entry_writes); } } } - return(success); + return (success); } /* verify_entry_writes() */ - /***************************************************************************** * * Function: verify_total_reads() @@ -4820,11 +4425,11 @@ verify_entry_writes(haddr_t addr, static hbool_t verify_total_reads(int expected_total_reads) { - hbool_t success = TRUE; /* will set to FALSE if appropriate. */ - long reported_total_reads; + hbool_t success = TRUE; /* will set to FALSE if appropriate. */ + long reported_total_reads; struct mssg_t mssg; - if ( success ) { + if (success) { /* compose the message */ mssg.req = REQ_TTL_READS_CODE; @@ -4837,68 +4442,59 @@ verify_total_reads(int expected_total_reads) mssg.count = 0; mssg.magic = MSSG_MAGIC; - if ( ! send_mssg(&mssg, FALSE) ) { + if (!send_mssg(&mssg, FALSE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( success ) { + if (success) { - if ( ! recv_mssg(&mssg, REQ_TTL_READS_RPLY_CODE) ) { + if (!recv_mssg(&mssg, REQ_TTL_READS_RPLY_CODE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } - } else if ( ( mssg.req != REQ_TTL_READS_RPLY_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != 0 ) || - ( mssg.len != 0 ) || - ( mssg.ver != 0 ) || - ( mssg.magic != MSSG_MAGIC ) ) { + } + else if ((mssg.req != REQ_TTL_READS_RPLY_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != 0) || (mssg.len != 0) || + (mssg.ver != 0) || (mssg.magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad data in req total reads reply.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in req total reads reply.\n", world_mpi_rank, FUNC); } - } else { + } + else { reported_total_reads = mssg.count; } } - if ( success ) { + if (success) { - if ( reported_total_reads != expected_total_reads ) { + if (reported_total_reads != expected_total_reads) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: reported/expected total reads mismatch (%ld/%ld).\n", - world_mpi_rank, FUNC, - reported_total_reads, expected_total_reads); - + if (verbose) { + HDfprintf(stdout, "%d:%s: reported/expected total reads mismatch (%ld/%ld).\n", + world_mpi_rank, FUNC, reported_total_reads, expected_total_reads); } } } - return(success); + return (success); } /* verify_total_reads() */ - /***************************************************************************** * * Function: verify_total_writes() @@ -4921,11 +4517,11 @@ verify_total_reads(int expected_total_reads) static hbool_t verify_total_writes(unsigned expected_total_writes) { - hbool_t success = TRUE; /* will set to FALSE if appropriate. */ - unsigned reported_total_writes; + hbool_t success = TRUE; /* will set to FALSE if appropriate. */ + unsigned reported_total_writes; struct mssg_t mssg; - if ( success ) { + if (success) { /* compose the message */ mssg.req = REQ_TTL_WRITES_CODE; @@ -4938,67 +4534,59 @@ verify_total_writes(unsigned expected_total_writes) mssg.count = 0; mssg.magic = MSSG_MAGIC; - if ( ! send_mssg(&mssg, FALSE) ) { + if (!send_mssg(&mssg, FALSE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed.\n", world_mpi_rank, FUNC); } } } - if ( success ) { + if (success) { - if ( ! recv_mssg(&mssg, REQ_TTL_WRITES_RPLY_CODE) ) { + if (!recv_mssg(&mssg, REQ_TTL_WRITES_RPLY_CODE)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } - } else if ( ( mssg.req != REQ_TTL_WRITES_RPLY_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != 0 ) || - ( mssg.len != 0 ) || - ( mssg.ver != 0 ) || - ( mssg.magic != MSSG_MAGIC ) ) { + } + else if ((mssg.req != REQ_TTL_WRITES_RPLY_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != 0) || (mssg.len != 0) || + (mssg.ver != 0) || (mssg.magic != MSSG_MAGIC)) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad data in req total reads reply.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in req total reads reply.\n", world_mpi_rank, FUNC); } - } else { + } + else { reported_total_writes = mssg.count; } } - if ( success ) { + if (success) { - if ( reported_total_writes != expected_total_writes ) { + if (reported_total_writes != expected_total_writes) { nerrors++; success = FALSE; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: reported/expected total writes mismatch (%u/%u).\n", - world_mpi_rank, FUNC, - reported_total_writes, expected_total_writes); + if (verbose) { + HDfprintf(stdout, "%d:%s: reported/expected total writes mismatch (%u/%u).\n", world_mpi_rank, + FUNC, reported_total_writes, expected_total_writes); } } } - return(success); + return (success); } /* verify_total_writes() */ - /***************************************************************************** * Function: unlock_entry() * @@ -5018,64 +4606,55 @@ verify_total_writes(unsigned expected_total_writes) * *****************************************************************************/ static void -unlock_entry(H5F_t * file_ptr, - int32_t idx, - unsigned int flags) +unlock_entry(H5F_t *file_ptr, int32_t idx, unsigned int flags) { - herr_t dirtied; - herr_t result; - struct datum * entry_ptr; + herr_t dirtied; + herr_t result; + struct datum *entry_ptr; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( file_ptr ); - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert(file_ptr); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( entry_ptr->locked ); + HDassert(entry_ptr->locked); - dirtied = ((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG ); + dirtied = ((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG); - if ( dirtied ) { + if (dirtied) { (entry_ptr->ver)++; entry_ptr->dirty = TRUE; } - result = H5AC_unprotect(file_ptr, &(types[0]), - entry_ptr->base_addr, (void *)(&(entry_ptr->header)), flags); + result = H5AC_unprotect(file_ptr, &(types[0]), entry_ptr->base_addr, (void *)(&(entry_ptr->header)), + flags); - if ( ( result < 0 ) || - ( entry_ptr->header.type != &(types[0]) ) || - ( ( entry_ptr->len != entry_ptr->header.size ) && - ( entry_ptr->local_len != entry_ptr->header.size ) ) || - ( entry_ptr->base_addr != entry_ptr->header.addr ) ) { + if ((result < 0) || (entry_ptr->header.type != &(types[0])) || + ((entry_ptr->len != entry_ptr->header.size) && + (entry_ptr->local_len != entry_ptr->header.size)) || + (entry_ptr->base_addr != entry_ptr->header.addr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: error in H5AC_unprotect().\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: error in H5AC_unprotect().\n", world_mpi_rank, FUNC); } - } else { + } + else { entry_ptr->locked = FALSE; + } - } - - HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + HDassert(((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE); - if ( ( (flags & H5AC__DIRTIED_FLAG) != 0 ) && - ( (flags & H5C__DELETED_FLAG) == 0 ) && - ( ! ( ( ( world_mpi_rank == 0 ) && ( entry_ptr->flushed ) ) - || - ( ( world_mpi_rank != 0 ) && ( entry_ptr->cleared ) ) - ) - ) - ) { - HDassert( entry_ptr->header.is_dirty ); - HDassert( entry_ptr->dirty ); + if (((flags & H5AC__DIRTIED_FLAG) != 0) && ((flags & H5C__DELETED_FLAG) == 0) && + (!(((world_mpi_rank == 0) && (entry_ptr->flushed)) || + ((world_mpi_rank != 0) && (entry_ptr->cleared))))) { + HDassert(entry_ptr->header.is_dirty); + HDassert(entry_ptr->dirty); } } @@ -5083,7 +4662,6 @@ unlock_entry(H5F_t * file_ptr, } /* unlock_entry() */ - /***************************************************************************** * Function: unpin_entry() * @@ -5103,84 +4681,74 @@ unlock_entry(H5F_t * file_ptr, * *****************************************************************************/ static void -unpin_entry(H5F_t * file_ptr, - int32_t idx, - hbool_t global, - hbool_t dirty, - hbool_t via_unprotect) +unpin_entry(H5F_t *file_ptr, int32_t idx, hbool_t global, hbool_t dirty, hbool_t via_unprotect) { - herr_t result; - unsigned int flags = H5AC__UNPIN_ENTRY_FLAG; - struct datum * entry_ptr; + herr_t result; + unsigned int flags = H5AC__UNPIN_ENTRY_FLAG; + struct datum *entry_ptr; - if ( nerrors == 0 ) { + if (nerrors == 0) { - HDassert( file_ptr ); - HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); - HDassert( idx < virt_num_data_entries ); + HDassert(file_ptr); + HDassert((0 <= idx) && (idx < NUM_DATA_ENTRIES)); + HDassert(idx < virt_num_data_entries); entry_ptr = &(data[idx]); - HDassert( (entry_ptr->header).is_pinned ); - HDassert ( ! ( entry_ptr->global_pinned && entry_ptr->local_pinned) ); - HDassert ( ( global && entry_ptr->global_pinned ) || - ( ! global && entry_ptr->local_pinned ) ); - HDassert ( ! ( dirty && ( ! global ) ) ); - - if ( via_unprotect ) { - - lock_entry(file_ptr, idx); + HDassert((entry_ptr->header).is_pinned); + HDassert(!(entry_ptr->global_pinned && entry_ptr->local_pinned)); + HDassert((global && entry_ptr->global_pinned) || (!global && entry_ptr->local_pinned)); + HDassert(!(dirty && (!global))); - if ( dirty ) { + if (via_unprotect) { - flags |= H5AC__DIRTIED_FLAG; - } + lock_entry(file_ptr, idx); - unlock_entry(file_ptr, idx, flags); + if (dirty) { - } else { + flags |= H5AC__DIRTIED_FLAG; + } - if ( dirty ) { + unlock_entry(file_ptr, idx, flags); + } + else { - mark_entry_dirty(idx); + if (dirty) { - } + mark_entry_dirty(idx); + } - result = H5AC_unpin_entry(entry_ptr); + result = H5AC_unpin_entry(entry_ptr); - if ( result < 0 ) { + if (result < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: error in H5AC_unpin_entry().\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: error in H5AC_unpin_entry().\n", world_mpi_rank, FUNC); } + } } - } - - HDassert( ! ((entry_ptr->header).is_pinned) ); - - if ( global ) { - entry_ptr->global_pinned = FALSE; + HDassert(!((entry_ptr->header).is_pinned)); - } else { + if (global) { - entry_ptr->local_pinned = FALSE; + entry_ptr->global_pinned = FALSE; + } + else { - } + entry_ptr->local_pinned = FALSE; + } } return; } /* unpin_entry() */ - /*****************************************************************************/ /****************************** test functions *******************************/ /*****************************************************************************/ - /***************************************************************************** * * Function: server_smoke_check() @@ -5197,11 +4765,11 @@ unpin_entry(H5F_t * file_ptr, static hbool_t server_smoke_check(void) { - hbool_t success = TRUE; - int max_nerrors; + hbool_t success = TRUE; + int max_nerrors; struct mssg_t mssg; - if ( world_mpi_rank == 0 ) { + if (world_mpi_rank == 0) { TESTING("server smoke check"); } @@ -5210,15 +4778,14 @@ server_smoke_check(void) init_data(); reset_stats(); - if ( world_mpi_rank == world_server_mpi_rank ) { + if (world_mpi_rank == world_server_mpi_rank) { - if ( ! server_main() ) { + if (!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } } @@ -5231,101 +4798,93 @@ server_smoke_check(void) mssg.mssg_num = -1; /* set by send function */ mssg.base_addr = data[world_mpi_rank].base_addr; H5_CHECKED_ASSIGN(mssg.len, unsigned, data[world_mpi_rank].len, size_t); - mssg.ver = ++(data[world_mpi_rank].ver); - mssg.count = 0; - mssg.magic = MSSG_MAGIC; + mssg.ver = ++(data[world_mpi_rank].ver); + mssg.count = 0; + mssg.magic = MSSG_MAGIC; - if ( ! ( success = send_mssg(&mssg, FALSE) ) ) { + if (!(success = send_mssg(&mssg, FALSE))) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on write.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on write.\n", world_mpi_rank, FUNC); } } #if DO_WRITE_REQ_ACK /* try to receive the write ack from the server */ - if ( success ) { + if (success) { success = recv_mssg(&mssg, WRITE_REQ_ACK_CODE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } } } /* verify that we received the expected ack message */ - if ( success ) { + if (success) { - if ( ( mssg.req != WRITE_REQ_ACK_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != data[world_mpi_rank].base_addr ) || - ( mssg.len != data[world_mpi_rank].len ) || - ( mssg.ver != data[world_mpi_rank].ver ) || - ( mssg.magic != MSSG_MAGIC ) ) { + if ((mssg.req != WRITE_REQ_ACK_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != data[world_mpi_rank].base_addr) || + (mssg.len != data[world_mpi_rank].len) || (mssg.ver != data[world_mpi_rank].ver) || + (mssg.magic != MSSG_MAGIC)) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad data in write req ack.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in write req ack.\n", world_mpi_rank, FUNC); } } } #endif /* DO_WRITE_REQ_ACK */ - do_sync(); + do_sync(); - /* barrier to allow all writes to complete */ - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + /* barrier to allow all writes to complete */ + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: barrier 1 failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: barrier 1 failed.\n", world_mpi_rank, FUNC); } } /* verify that the expected entries have been written, the total */ - if ( success ) { + if (success) { success = verify_entry_writes(data[world_mpi_rank].base_addr, 1); } - if ( success ) { + if (success) { success = verify_entry_reads(data[world_mpi_rank].base_addr, 0); } - if ( success ) { + if (success) { success = verify_total_writes((unsigned)(world_mpi_size - 1)); } - if ( success ) { + if (success) { success = verify_total_reads(0); } - /* barrier to allow all writes to complete */ - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + /* barrier to allow all writes to complete */ + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { success = FALSE; nerrors++; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, "%d:%s: barrier 2 failed.\n", - world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: barrier 2 failed.\n", world_mpi_rank, FUNC); } } @@ -5336,148 +4895,138 @@ server_smoke_check(void) mssg.mssg_num = -1; /* set by send function */ mssg.base_addr = data[world_mpi_rank].base_addr; H5_CHECKED_ASSIGN(mssg.len, unsigned, data[world_mpi_rank].len, size_t); - mssg.ver = 0; /* bogus -- should be corrected by server */ - mssg.count = 0; - mssg.magic = MSSG_MAGIC; + mssg.ver = 0; /* bogus -- should be corrected by server */ + mssg.count = 0; + mssg.magic = MSSG_MAGIC; - if ( success ) { + if (success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on write.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on write.\n", world_mpi_rank, FUNC); } } } /* try to receive the reply from the server */ - if ( success ) { + if (success) { success = recv_mssg(&mssg, READ_REQ_REPLY_CODE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: recv_mssg() failed.\n", world_mpi_rank, FUNC); } } } /* verify that we got the expected result */ - if ( success ) { + if (success) { - if ( ( mssg.req != READ_REQ_REPLY_CODE ) || - ( mssg.src != world_server_mpi_rank ) || - ( mssg.dest != world_mpi_rank ) || - ( mssg.base_addr != data[world_mpi_rank].base_addr ) || - ( mssg.len != data[world_mpi_rank].len ) || - ( mssg.ver != data[world_mpi_rank].ver ) || - ( mssg.magic != MSSG_MAGIC ) ) { + if ((mssg.req != READ_REQ_REPLY_CODE) || (mssg.src != world_server_mpi_rank) || + (mssg.dest != world_mpi_rank) || (mssg.base_addr != data[world_mpi_rank].base_addr) || + (mssg.len != data[world_mpi_rank].len) || (mssg.ver != data[world_mpi_rank].ver) || + (mssg.magic != MSSG_MAGIC)) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Bad data in read req reply.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Bad data in read req reply.\n", world_mpi_rank, FUNC); } } } - /* barrier to allow all writes to complete */ - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + /* barrier to allow all writes to complete */ + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { success = FALSE; nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: barrier 3 failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: barrier 3 failed.\n", world_mpi_rank, FUNC); } } /* verify that the expected entries have been read, and the total */ - if ( success ) { + if (success) { success = verify_entry_writes(data[world_mpi_rank].base_addr, 1); } - if ( success ) { + if (success) { success = verify_entry_reads(data[world_mpi_rank].base_addr, 1); } - if ( success ) { + if (success) { success = verify_total_writes((unsigned)(world_mpi_size - 1)); } - if ( success ) { + if (success) { success = verify_total_reads(world_mpi_size - 1); } - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { success = FALSE; nerrors++; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, "%d:%s: barrier 4 failed.\n", - world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: barrier 4 failed.\n", world_mpi_rank, FUNC); } } /* reset the counters */ - if ( success ) { + if (success) { success = reset_server_counts(); } - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { success = FALSE; nerrors++; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, "%d:%s: barrier 5 failed.\n", - world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: barrier 5 failed.\n", world_mpi_rank, FUNC); } } /* verify that the counters have been reset */ - if ( success ) { + if (success) { success = verify_entry_writes(data[world_mpi_rank].base_addr, 0); } - if ( success ) { + if (success) { success = verify_entry_reads(data[world_mpi_rank].base_addr, 0); } - if ( success ) { + if (success) { success = verify_total_writes(0); } - if ( success ) { + if (success) { success = verify_total_reads(0); } - if ( MPI_SUCCESS != MPI_Barrier(file_mpi_comm) ) { + if (MPI_SUCCESS != MPI_Barrier(file_mpi_comm)) { success = FALSE; nerrors++; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, "%d:%s: barrier 6 failed.\n", - world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: barrier 6 failed.\n", world_mpi_rank, FUNC); } } @@ -5486,22 +5035,21 @@ server_smoke_check(void) mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ - mssg.base_addr = 0; /* not used */ - mssg.len = 0; /* not used */ - mssg.ver = 0; /* not used */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ mssg.count = 0; mssg.magic = MSSG_MAGIC; - if ( success ) { + if (success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } } } @@ -5509,26 +5057,25 @@ server_smoke_check(void) max_nerrors = get_max_nerrors(); - if ( world_mpi_rank == 0 ) { - - if ( max_nerrors == 0 ) { + if (world_mpi_rank == 0) { - PASSED(); + if (max_nerrors == 0) { - } else { + PASSED(); + } + else { failures++; H5_FAILED(); } } - success = ( ( success ) && ( max_nerrors == 0 ) ); + success = ((success) && (max_nerrors == 0)); - return(success); + return (success); } /* server_smoke_check() */ - /***************************************************************************** * * Function: smoke_check_1() @@ -5545,100 +5092,92 @@ server_smoke_check(void) static hbool_t smoke_check_1(int metadata_write_strategy) { - hbool_t success = TRUE; - int i; - int max_nerrors; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + hbool_t success = TRUE; + int i; + int max_nerrors; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; struct mssg_t mssg; - switch ( metadata_write_strategy ) { + switch (metadata_write_strategy) { - case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #1 -- process 0 only md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: + if (world_mpi_rank == 0) { + TESTING("smoke check #1 -- process 0 only md write strategy"); } - break; + break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #1 -- distributed md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + if (world_mpi_rank == 0) { + TESTING("smoke check #1 -- distributed md write strategy"); } - break; + break; default: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #1 -- unknown md write strategy"); + if (world_mpi_rank == 0) { + TESTING("smoke check #1 -- unknown md write strategy"); } - break; + break; } nerrors = 0; init_data(); reset_stats(); - if ( world_mpi_rank == world_server_mpi_rank ) { + if (world_mpi_rank == world_server_mpi_rank) { - if ( ! server_main() ) { + if (!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } } else /* run the clients */ { - if ( ! setup_cache_for_test(&fid, &file_ptr, &cache_ptr, - metadata_write_strategy) ) { + if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; - fid = -1; + fid = -1; cache_ptr = NULL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } } - for ( i = 0; i < (virt_num_data_entries / 2); i++ ) - { + for (i = 0; i < (virt_num_data_entries / 2); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); } - for ( i = (virt_num_data_entries / 2) - 1; i >= 0; i-- ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + for (i = (virt_num_data_entries / 2) - 1; i >= 0; i--) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); } /* Move the first half of the entries... */ - for ( i = 0; i < (virt_num_data_entries / 2); i++ ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); + for (i = 0; i < (virt_num_data_entries / 2); i++) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); } /* ...and then move them back. */ - for ( i = (virt_num_data_entries / 2) - 1; i >= 0; i-- ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); + for (i = (virt_num_data_entries / 2) - 1; i >= 0; i--) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); } - if ( fid >= 0 ) { + if (fid >= 0) { - if ( ! take_down_cache(fid, cache_ptr) ) { + if (!take_down_cache(fid, cache_ptr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", world_mpi_rank, FUNC); } } } @@ -5647,10 +5186,9 @@ smoke_check_1(int metadata_write_strategy) * and are clean. */ - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { - HDassert( data_index[i] == i ); - HDassert( ! (data[i].dirty) ); + for (i = 0; i < NUM_DATA_ENTRIES; i++) { + HDassert(data_index[i] == i); + HDassert(!(data[i].dirty)); } /* compose the done message */ @@ -5658,22 +5196,21 @@ smoke_check_1(int metadata_write_strategy) mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ - mssg.base_addr = 0; /* not used */ - mssg.len = 0; /* not used */ - mssg.ver = 0; /* not used */ - mssg.count = 0; /* not used */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ + mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( success ) { + if (success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } } } @@ -5681,26 +5218,25 @@ smoke_check_1(int metadata_write_strategy) max_nerrors = get_max_nerrors(); - if ( world_mpi_rank == 0 ) { + if (world_mpi_rank == 0) { - if ( max_nerrors == 0 ) { + if (max_nerrors == 0) { - PASSED(); - - } else { + PASSED(); + } + else { failures++; H5_FAILED(); } } - success = ( ( success ) && ( max_nerrors == 0 ) ); + success = ((success) && (max_nerrors == 0)); - return(success); + return (success); } /* smoke_check_1() */ - /***************************************************************************** * * Function: smoke_check_2() @@ -5720,147 +5256,126 @@ smoke_check_1(int metadata_write_strategy) static hbool_t smoke_check_2(int metadata_write_strategy) { - hbool_t success = TRUE; - int i; - int max_nerrors; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + hbool_t success = TRUE; + int i; + int max_nerrors; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; struct mssg_t mssg; - switch ( metadata_write_strategy ) { + switch (metadata_write_strategy) { - case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #2 -- process 0 only md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: + if (world_mpi_rank == 0) { + TESTING("smoke check #2 -- process 0 only md write strategy"); } - break; + break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #2 -- distributed md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + if (world_mpi_rank == 0) { + TESTING("smoke check #2 -- distributed md write strategy"); } - break; + break; default: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #2 -- unknown md write strategy"); + if (world_mpi_rank == 0) { + TESTING("smoke check #2 -- unknown md write strategy"); } - break; + break; } nerrors = 0; init_data(); reset_stats(); - if ( world_mpi_rank == world_server_mpi_rank ) { + if (world_mpi_rank == world_server_mpi_rank) { - if ( ! server_main() ) { + if (!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } } else /* run the clients */ { - if ( ! setup_cache_for_test(&fid, &file_ptr, &cache_ptr, - metadata_write_strategy) ) { + if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; - fid = -1; + fid = -1; cache_ptr = NULL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } } - for ( i = 0; i < (virt_num_data_entries / 2); i++ ) - { + for (i = 0; i < (virt_num_data_entries / 2); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); - if ( i > 100 ) { + if (i > 100) { - lock_and_unlock_random_entries(file_ptr, (i - 100), i, 0, 10); + lock_and_unlock_random_entries(file_ptr, (i - 100), i, 0, 10); } } - for ( i = 0; i < (virt_num_data_entries / 2); i+=61 ) - { - /* Make sure we don't step on any locally pinned entries */ - if ( data[i].local_pinned ) { - unpin_entry(file_ptr, i, FALSE, FALSE, FALSE); - } + for (i = 0; i < (virt_num_data_entries / 2); i += 61) { + /* Make sure we don't step on any locally pinned entries */ + if (data[i].local_pinned) { + unpin_entry(file_ptr, i, FALSE, FALSE, FALSE); + } - pin_entry(file_ptr, i, TRUE, FALSE); - } + pin_entry(file_ptr, i, TRUE, FALSE); + } - for ( i = (virt_num_data_entries / 2) - 1; i >= 0; i-=2 ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - lock_and_unlock_random_entries(file_ptr, 0, - (virt_num_data_entries / 20), - 0, 100); - local_pin_and_unpin_random_entries(file_ptr, 0, - (virt_num_data_entries / 4), - 0, 3); + for (i = (virt_num_data_entries / 2) - 1; i >= 0; i -= 2) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + lock_and_unlock_random_entries(file_ptr, 0, (virt_num_data_entries / 20), 0, 100); + local_pin_and_unpin_random_entries(file_ptr, 0, (virt_num_data_entries / 4), 0, 3); } - for ( i = 0; i < (virt_num_data_entries / 2); i+=2 ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - lock_and_unlock_random_entries(file_ptr, 0, - (virt_num_data_entries / 10), - 0, 100); + for (i = 0; i < (virt_num_data_entries / 2); i += 2) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + lock_and_unlock_random_entries(file_ptr, 0, (virt_num_data_entries / 10), 0, 100); } - /* we can't move pinned entries, so release any local pins now. */ - local_unpin_all_entries(file_ptr, FALSE); + /* we can't move pinned entries, so release any local pins now. */ + local_unpin_all_entries(file_ptr, FALSE); /* Move the first half of the entries... */ - for ( i = 0; i < (virt_num_data_entries / 2); i++ ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); - lock_and_unlock_random_entries(file_ptr, 0, - ((virt_num_data_entries / 50) - 1), - 0, 100); + for (i = 0; i < (virt_num_data_entries / 2); i++) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); + lock_and_unlock_random_entries(file_ptr, 0, ((virt_num_data_entries / 50) - 1), 0, 100); } /* ...and then move them back. */ - for ( i = (virt_num_data_entries / 2) - 1; i >= 0; i-- ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); - lock_and_unlock_random_entries(file_ptr, 0, - (virt_num_data_entries / 100), - 0, 100); + for (i = (virt_num_data_entries / 2) - 1; i >= 0; i--) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); + lock_and_unlock_random_entries(file_ptr, 0, (virt_num_data_entries / 100), 0, 100); } - for ( i = 0; i < (virt_num_data_entries / 2); i+=61 ) - { - hbool_t via_unprotect = ( (((unsigned)i) & 0x01) == 0 ); - hbool_t dirty = ( (((unsigned)i) & 0x02) == 0 ); + for (i = 0; i < (virt_num_data_entries / 2); i += 61) { + hbool_t via_unprotect = ((((unsigned)i) & 0x01) == 0); + hbool_t dirty = ((((unsigned)i) & 0x02) == 0); - unpin_entry(file_ptr, i, TRUE, dirty, via_unprotect); - } + unpin_entry(file_ptr, i, TRUE, dirty, via_unprotect); + } - if ( fid >= 0 ) { + if (fid >= 0) { - if ( ! take_down_cache(fid, cache_ptr) ) { + if (!take_down_cache(fid, cache_ptr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", world_mpi_rank, FUNC); } } } @@ -5869,10 +5384,9 @@ smoke_check_2(int metadata_write_strategy) * and are clean. */ - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { - HDassert( data_index[i] == i ); - HDassert( ! (data[i].dirty) ); + for (i = 0; i < NUM_DATA_ENTRIES; i++) { + HDassert(data_index[i] == i); + HDassert(!(data[i].dirty)); } /* compose the done message */ @@ -5880,22 +5394,21 @@ smoke_check_2(int metadata_write_strategy) mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ - mssg.base_addr = 0; /* not used */ - mssg.len = 0; /* not used */ - mssg.ver = 0; /* not used */ - mssg.count = 0; /* not used */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ + mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( success ) { + if (success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } } } @@ -5903,26 +5416,25 @@ smoke_check_2(int metadata_write_strategy) max_nerrors = get_max_nerrors(); - if ( world_mpi_rank == 0 ) { - - if ( max_nerrors == 0 ) { + if (world_mpi_rank == 0) { - PASSED(); + if (max_nerrors == 0) { - } else { + PASSED(); + } + else { failures++; H5_FAILED(); } } - success = ( ( success ) && ( max_nerrors == 0 ) ); + success = ((success) && (max_nerrors == 0)); - return(success); + return (success); } /* smoke_check_2() */ - /***************************************************************************** * * Function: smoke_check_3() @@ -5945,182 +5457,158 @@ smoke_check_2(int metadata_write_strategy) static hbool_t smoke_check_3(int metadata_write_strategy) { - hbool_t success = TRUE; - int i; - int max_nerrors; - int min_count; - int max_count; - int min_idx; - int max_idx; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + hbool_t success = TRUE; + int i; + int max_nerrors; + int min_count; + int max_count; + int min_idx; + int max_idx; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; struct mssg_t mssg; - switch ( metadata_write_strategy ) { + switch (metadata_write_strategy) { - case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #3 -- process 0 only md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: + if (world_mpi_rank == 0) { + TESTING("smoke check #3 -- process 0 only md write strategy"); } - break; + break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #3 -- distributed md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + if (world_mpi_rank == 0) { + TESTING("smoke check #3 -- distributed md write strategy"); } - break; + break; default: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #3 -- unknown md write strategy"); + if (world_mpi_rank == 0) { + TESTING("smoke check #3 -- unknown md write strategy"); } - break; + break; } nerrors = 0; init_data(); reset_stats(); - if ( world_mpi_rank == world_server_mpi_rank ) { + if (world_mpi_rank == world_server_mpi_rank) { - if ( ! server_main() ) { + if (!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } } else /* run the clients */ { - if ( ! setup_cache_for_test(&fid, &file_ptr, &cache_ptr, - metadata_write_strategy) ) { + if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; - fid = -1; + fid = -1; cache_ptr = NULL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } } min_count = 100 / ((file_mpi_rank + 1) * (file_mpi_rank + 1)); max_count = min_count + 50; - for ( i = 0; i < (virt_num_data_entries / 4); i++ ) - { + for (i = 0; i < (virt_num_data_entries / 4); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); - if ( i > 100 ) { + if (i > 100) { - lock_and_unlock_random_entries(file_ptr, (i - 100), i, - min_count, max_count); + lock_and_unlock_random_entries(file_ptr, (i - 100), i, min_count, max_count); } } - min_count = 100 / ((file_mpi_rank + 2) * (file_mpi_rank + 2)); max_count = min_count + 50; - for ( i = (virt_num_data_entries / 4); - i < (virt_num_data_entries / 2); - i++ ) - { + for (i = (virt_num_data_entries / 4); i < (virt_num_data_entries / 2); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); - if ( i % 59 == 0 ) { - - hbool_t dirty = ( (i % 2) == 0); + if (i % 59 == 0) { - if ( data[i].local_pinned ) { - unpin_entry(file_ptr, i, FALSE, FALSE, FALSE); - } + hbool_t dirty = ((i % 2) == 0); - pin_entry(file_ptr, i, TRUE, dirty); - - HDassert( !dirty || data[i].header.is_dirty ); - HDassert( data[i].header.is_pinned ); - HDassert( data[i].global_pinned ); - HDassert( ! data[i].local_pinned ); - } + if (data[i].local_pinned) { + unpin_entry(file_ptr, i, FALSE, FALSE, FALSE); + } - if ( i > 100 ) { + pin_entry(file_ptr, i, TRUE, dirty); - lock_and_unlock_random_entries(file_ptr, (i - 100), i, - min_count, max_count); + HDassert(!dirty || data[i].header.is_dirty); + HDassert(data[i].header.is_pinned); + HDassert(data[i].global_pinned); + HDassert(!data[i].local_pinned); } - local_pin_and_unpin_random_entries(file_ptr, 0, - virt_num_data_entries / 4, - 0, (file_mpi_rank + 2)); + if (i > 100) { - } + lock_and_unlock_random_entries(file_ptr, (i - 100), i, min_count, max_count); + } + local_pin_and_unpin_random_entries(file_ptr, 0, virt_num_data_entries / 4, 0, + (file_mpi_rank + 2)); + } - /* flush the file to be sure that we have no problems flushing - * pinned entries - */ - if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { + /* flush the file to be sure that we have no problems flushing + * pinned entries + */ + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", world_mpi_rank, FUNC); } } - min_idx = 0; - max_idx = ((virt_num_data_entries / 10) / - ((file_mpi_rank + 1) * (file_mpi_rank + 1))) - 1; - if ( max_idx <= min_idx ) { + max_idx = ((virt_num_data_entries / 10) / ((file_mpi_rank + 1) * (file_mpi_rank + 1))) - 1; + if (max_idx <= min_idx) { max_idx = min_idx + 10; } - for ( i = (virt_num_data_entries / 2) - 1; i >= 0; i-- ) - { - if ( ( i >= (virt_num_data_entries / 4) ) && ( i % 59 == 0 ) ) { + for (i = (virt_num_data_entries / 2) - 1; i >= 0; i--) { + if ((i >= (virt_num_data_entries / 4)) && (i % 59 == 0)) { - hbool_t via_unprotect = ( (((unsigned)i) & 0x02) == 0 ); - hbool_t dirty = ( (((unsigned)i) & 0x04) == 0 ); + hbool_t via_unprotect = ((((unsigned)i) & 0x02) == 0); + hbool_t dirty = ((((unsigned)i) & 0x04) == 0); - HDassert( data[i].global_pinned ); - HDassert( ! data[i].local_pinned ); + HDassert(data[i].global_pinned); + HDassert(!data[i].local_pinned); - unpin_entry(file_ptr, i, TRUE, dirty, - via_unprotect); - } - if ( i % 2 == 0 ) { + unpin_entry(file_ptr, i, TRUE, dirty, via_unprotect); + } + if (i % 2 == 0) { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - local_pin_and_unpin_random_entries(file_ptr, 0, - virt_num_data_entries / 2, - 0, 2); - lock_and_unlock_random_entries(file_ptr, - min_idx, max_idx, 0, 100); - } + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + local_pin_and_unpin_random_entries(file_ptr, 0, virt_num_data_entries / 2, 0, 2); + lock_and_unlock_random_entries(file_ptr, min_idx, max_idx, 0, 100); + } } min_idx = 0; - max_idx = ((virt_num_data_entries / 10) / - ((file_mpi_rank + 3) * (file_mpi_rank + 3))) - 1; - if ( max_idx <= min_idx ) { + max_idx = ((virt_num_data_entries / 10) / ((file_mpi_rank + 3) * (file_mpi_rank + 3))) - 1; + if (max_idx <= min_idx) { max_idx = min_idx + 10; } - for ( i = 0; i < (virt_num_data_entries / 2); i+=2 ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - lock_and_unlock_random_entries(file_ptr, - min_idx, max_idx, 0, 100); + for (i = 0; i < (virt_num_data_entries / 2); i += 2) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + lock_and_unlock_random_entries(file_ptr, min_idx, max_idx, 0, 100); } /* we can't move pinned entries, so release any local pins now. */ @@ -6130,25 +5618,19 @@ smoke_check_3(int metadata_write_strategy) max_count = min_count + 100; /* move the first half of the entries... */ - for ( i = 0; i < (virt_num_data_entries / 2); i++ ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); - lock_and_unlock_random_entries(file_ptr, 0, - (virt_num_data_entries / 20), - min_count, max_count); + for (i = 0; i < (virt_num_data_entries / 2); i++) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); + lock_and_unlock_random_entries(file_ptr, 0, (virt_num_data_entries / 20), min_count, max_count); } /* ...and then move them back. */ - for ( i = (virt_num_data_entries / 2) - 1; i >= 0; i-- ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); - lock_and_unlock_random_entries(file_ptr, 0, - (virt_num_data_entries / 40), - min_count, max_count); + for (i = (virt_num_data_entries / 2) - 1; i >= 0; i--) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); + lock_and_unlock_random_entries(file_ptr, 0, (virt_num_data_entries / 40), min_count, max_count); } /* finally, do some dirty lock/unlocks while we give the cache @@ -6157,33 +5639,28 @@ smoke_check_3(int metadata_write_strategy) min_count = 200 / ((file_mpi_rank + 1) * (file_mpi_rank + 1)); max_count = min_count + 100; - for ( i = 0; i < (virt_num_data_entries / 2); i+=2 ) - { - local_pin_and_unpin_random_entries(file_ptr, 0, - (virt_num_data_entries / 2), - 0, 5); + for (i = 0; i < (virt_num_data_entries / 2); i += 2) { + local_pin_and_unpin_random_entries(file_ptr, 0, (virt_num_data_entries / 2), 0, 5); - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - if ( i > 100 ) { + if (i > 100) { - lock_and_unlock_random_entries(file_ptr, (i - 100), i, - min_count, max_count); + lock_and_unlock_random_entries(file_ptr, (i - 100), i, min_count, max_count); } } /* release any local pins before we take down the cache. */ local_unpin_all_entries(file_ptr, FALSE); - if ( fid >= 0 ) { + if (fid >= 0) { - if ( ! take_down_cache(fid, cache_ptr) ) { + if (!take_down_cache(fid, cache_ptr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", world_mpi_rank, FUNC); } } } @@ -6192,10 +5669,9 @@ smoke_check_3(int metadata_write_strategy) * and are clean. */ - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { - HDassert( data_index[i] == i ); - HDassert( ! (data[i].dirty) ); + for (i = 0; i < NUM_DATA_ENTRIES; i++) { + HDassert(data_index[i] == i); + HDassert(!(data[i].dirty)); } /* compose the done message */ @@ -6203,23 +5679,21 @@ smoke_check_3(int metadata_write_strategy) mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ - mssg.base_addr = 0; /* not used */ - mssg.len = 0; /* not used */ - mssg.ver = 0; /* not used */ - mssg.count = 0; /* not used */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ + mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( success ) { - + if (success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } } } @@ -6227,26 +5701,25 @@ smoke_check_3(int metadata_write_strategy) max_nerrors = get_max_nerrors(); - if ( world_mpi_rank == 0 ) { - - if ( max_nerrors == 0 ) { + if (world_mpi_rank == 0) { - PASSED(); + if (max_nerrors == 0) { - } else { + PASSED(); + } + else { failures++; H5_FAILED(); } } - success = ( ( success ) && ( max_nerrors == 0 ) ); + success = ((success) && (max_nerrors == 0)); - return(success); + return (success); } /* smoke_check_3() */ - /***************************************************************************** * * Function: smoke_check_4() @@ -6269,210 +5742,184 @@ smoke_check_3(int metadata_write_strategy) static hbool_t smoke_check_4(int metadata_write_strategy) { - hbool_t success = TRUE; - int i; - int max_nerrors; - int min_count; - int max_count; - int min_idx; - int max_idx; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + hbool_t success = TRUE; + int i; + int max_nerrors; + int min_count; + int max_count; + int min_idx; + int max_idx; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; struct mssg_t mssg; - switch ( metadata_write_strategy ) { + switch (metadata_write_strategy) { - case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #4 -- process 0 only md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: + if (world_mpi_rank == 0) { + TESTING("smoke check #4 -- process 0 only md write strategy"); } - break; + break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #4 -- distributed md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + if (world_mpi_rank == 0) { + TESTING("smoke check #4 -- distributed md write strategy"); } - break; + break; default: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #4 -- unknown md write strategy"); + if (world_mpi_rank == 0) { + TESTING("smoke check #4 -- unknown md write strategy"); } - break; + break; } nerrors = 0; init_data(); reset_stats(); - if ( world_mpi_rank == world_server_mpi_rank ) { + if (world_mpi_rank == world_server_mpi_rank) { - if ( ! server_main() ) { + if (!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } } else /* run the clients */ { - if ( ! setup_cache_for_test(&fid, &file_ptr, &cache_ptr, - metadata_write_strategy) ) { + if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; - fid = -1; + fid = -1; cache_ptr = NULL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } } - min_count = 100 * (file_mpi_rank % 4); max_count = min_count + 50; - for ( i = 0; i < (virt_num_data_entries / 4); i++ ) - { + for (i = 0; i < (virt_num_data_entries / 4); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); - if ( i > 100 ) { + if (i > 100) { - lock_and_unlock_random_entries(file_ptr, (i - 100), i, - min_count, max_count); + lock_and_unlock_random_entries(file_ptr, (i - 100), i, min_count, max_count); } } min_count = 10 * (file_mpi_rank % 4); max_count = min_count + 100; - for ( i = (virt_num_data_entries / 4); - i < (virt_num_data_entries / 2); - i++ ) - { - if ( i % 2 == 0 ) { + for (i = (virt_num_data_entries / 4); i < (virt_num_data_entries / 2); i++) { + if (i % 2 == 0) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); + } + else { - } else { - - /* Insert some entries pinned, and then unpin them - * immediately. We have tested pinned entries elsewhere, - * so it should be sufficient to verify that the - * entries are in fact pinned (which unpin_entry() should do). - */ + /* Insert some entries pinned, and then unpin them + * immediately. We have tested pinned entries elsewhere, + * so it should be sufficient to verify that the + * entries are in fact pinned (which unpin_entry() should do). + */ insert_entry(cache_ptr, file_ptr, i, H5C__PIN_ENTRY_FLAG); unpin_entry(file_ptr, i, TRUE, FALSE, FALSE); - } + } - if ( i % 59 == 0 ) { + if (i % 59 == 0) { - hbool_t dirty = ( (i % 2) == 0); + hbool_t dirty = ((i % 2) == 0); - if ( data[i].local_pinned ) { + if (data[i].local_pinned) { unpin_entry(file_ptr, i, FALSE, FALSE, FALSE); } pin_entry(file_ptr, i, TRUE, dirty); - HDassert( !dirty || data[i].header.is_dirty ); - HDassert( data[i].header.is_pinned ); - HDassert( data[i].global_pinned ); - HDassert( ! data[i].local_pinned ); + HDassert(!dirty || data[i].header.is_dirty); + HDassert(data[i].header.is_pinned); + HDassert(data[i].global_pinned); + HDassert(!data[i].local_pinned); } - if ( i > 100 ) { + if (i > 100) { - lock_and_unlock_random_entries(file_ptr, (i - 100), i, - min_count, max_count); + lock_and_unlock_random_entries(file_ptr, (i - 100), i, min_count, max_count); } - local_pin_and_unpin_random_entries(file_ptr, 0, - (virt_num_data_entries / 4), - 0, (file_mpi_rank + 2)); + local_pin_and_unpin_random_entries(file_ptr, 0, (virt_num_data_entries / 4), 0, + (file_mpi_rank + 2)); } - /* flush the file to be sure that we have no problems flushing - * pinned entries - */ - if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { + * pinned entries + */ + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", world_mpi_rank, FUNC); } } - min_idx = 0; - max_idx = (((virt_num_data_entries / 10) / 4) * - ((file_mpi_rank % 4) + 1)) - 1; + max_idx = (((virt_num_data_entries / 10) / 4) * ((file_mpi_rank % 4) + 1)) - 1; - for ( i = (virt_num_data_entries / 2) - 1; i >= 0; i-- ) - { - if ( ( i >= (virt_num_data_entries / 4) ) && ( i % 59 == 0 ) ) { + for (i = (virt_num_data_entries / 2) - 1; i >= 0; i--) { + if ((i >= (virt_num_data_entries / 4)) && (i % 59 == 0)) { - hbool_t via_unprotect = ( (((unsigned)i) & 0x02) == 0 ); - hbool_t dirty = ( (((unsigned)i) & 0x04) == 0 ); + hbool_t via_unprotect = ((((unsigned)i) & 0x02) == 0); + hbool_t dirty = ((((unsigned)i) & 0x04) == 0); - HDassert( data[i].global_pinned ); - HDassert( ! data[i].local_pinned ); + HDassert(data[i].global_pinned); + HDassert(!data[i].local_pinned); unpin_entry(file_ptr, i, TRUE, dirty, via_unprotect); } - if ( i % 2 == 0 ) { + if (i % 2 == 0) { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - lock_and_unlock_random_entries(file_ptr, - min_idx, max_idx, 0, 100); - } + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + lock_and_unlock_random_entries(file_ptr, min_idx, max_idx, 0, 100); + } } min_idx = 0; - max_idx = (((virt_num_data_entries / 10) / 8) * - ((file_mpi_rank % 4) + 1)) - 1; + max_idx = (((virt_num_data_entries / 10) / 8) * ((file_mpi_rank % 4) + 1)) - 1; - for ( i = 0; i < (virt_num_data_entries / 2); i+=2 ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - lock_and_unlock_random_entries(file_ptr, - min_idx, max_idx, 0, 100); + for (i = 0; i < (virt_num_data_entries / 2); i += 2) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + lock_and_unlock_random_entries(file_ptr, min_idx, max_idx, 0, 100); } - /* we can't move pinned entries, so release any local pins now. */ - local_unpin_all_entries(file_ptr, FALSE); + /* we can't move pinned entries, so release any local pins now. */ + local_unpin_all_entries(file_ptr, FALSE); min_count = 10 * (file_mpi_rank % 4); max_count = min_count + 100; /* move the first half of the entries... */ - for ( i = 0; i < (virt_num_data_entries / 2); i++ ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); - lock_and_unlock_random_entries(file_ptr, 0, - (virt_num_data_entries / 20), - min_count, max_count); + for (i = 0; i < (virt_num_data_entries / 2); i++) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); + lock_and_unlock_random_entries(file_ptr, 0, (virt_num_data_entries / 20), min_count, max_count); } /* ...and then move them back. */ - for ( i = (virt_num_data_entries / 2) - 1; i >= 0; i-- ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); - lock_and_unlock_random_entries(file_ptr, 0, - (virt_num_data_entries / 40), - min_count, max_count); + for (i = (virt_num_data_entries / 2) - 1; i >= 0; i--) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + move_entry(file_ptr, i, (i + (virt_num_data_entries / 2))); + lock_and_unlock_random_entries(file_ptr, 0, (virt_num_data_entries / 40), min_count, max_count); } /* finally, do some dirty lock/unlocks while we give the cache @@ -6481,26 +5928,23 @@ smoke_check_4(int metadata_write_strategy) min_count = 100 * (file_mpi_rank % 4); max_count = min_count + 100; - for ( i = 0; i < (virt_num_data_entries / 2); i+=2 ) - { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + for (i = 0; i < (virt_num_data_entries / 2); i += 2) { + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - if ( i > 100 ) { + if (i > 100) { - lock_and_unlock_random_entries(file_ptr, (i - 100), i, - min_count, max_count); + lock_and_unlock_random_entries(file_ptr, (i - 100), i, min_count, max_count); } } - if ( fid >= 0 ) { + if (fid >= 0) { - if ( ! take_down_cache(fid, cache_ptr) ) { + if (!take_down_cache(fid, cache_ptr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", world_mpi_rank, FUNC); } } } @@ -6509,10 +5953,9 @@ smoke_check_4(int metadata_write_strategy) * and are clean. */ - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { - HDassert( data_index[i] == i ); - HDassert( ! (data[i].dirty) ); + for (i = 0; i < NUM_DATA_ENTRIES; i++) { + HDassert(data_index[i] == i); + HDassert(!(data[i].dirty)); } /* compose the done message */ @@ -6520,23 +5963,21 @@ smoke_check_4(int metadata_write_strategy) mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ - mssg.base_addr = 0; /* not used */ - mssg.len = 0; /* not used */ - mssg.ver = 0; /* not used */ - mssg.count = 0; /* not used */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ + mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( success ) { - + if (success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } } } @@ -6544,26 +5985,25 @@ smoke_check_4(int metadata_write_strategy) max_nerrors = get_max_nerrors(); - if ( world_mpi_rank == 0 ) { + if (world_mpi_rank == 0) { - if ( max_nerrors == 0 ) { + if (max_nerrors == 0) { - PASSED(); - - } else { + PASSED(); + } + else { failures++; H5_FAILED(); } } - success = ( ( success ) && ( max_nerrors == 0 ) ); + success = ((success) && (max_nerrors == 0)); - return(success); + return (success); } /* smoke_check_4() */ - /***************************************************************************** * * Function: smoke_check_5() @@ -6581,136 +6021,122 @@ smoke_check_4(int metadata_write_strategy) static hbool_t smoke_check_5(int metadata_write_strategy) { - hbool_t success = TRUE; - int i; - int max_nerrors; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + hbool_t success = TRUE; + int i; + int max_nerrors; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; struct mssg_t mssg; - switch ( metadata_write_strategy ) { + switch (metadata_write_strategy) { - case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #5 -- process 0 only md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: + if (world_mpi_rank == 0) { + TESTING("smoke check #5 -- process 0 only md write strategy"); } - break; + break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #5 -- distributed md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + if (world_mpi_rank == 0) { + TESTING("smoke check #5 -- distributed md write strategy"); } - break; + break; default: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #5 -- unknown md write strategy"); + if (world_mpi_rank == 0) { + TESTING("smoke check #5 -- unknown md write strategy"); } - break; + break; } - nerrors = 0; init_data(); reset_stats(); - if ( world_mpi_rank == world_server_mpi_rank ) { + if (world_mpi_rank == world_server_mpi_rank) { - if ( ! server_main() ) { + if (!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } } else /* run the clients */ { - if ( ! setup_cache_for_test(&fid, &file_ptr, &cache_ptr, - metadata_write_strategy) ) { + if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; - fid = -1; + fid = -1; cache_ptr = NULL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } } - for ( i = 0; i < (virt_num_data_entries / 2); i++ ) - { + for (i = 0; i < (virt_num_data_entries / 2); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); } - /* flush the file so we can lock known clean entries. */ - if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { + /* flush the file so we can lock known clean entries. */ + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", world_mpi_rank, FUNC); } } - for ( i = 0; i < (virt_num_data_entries / 4); i++ ) - { - lock_entry(file_ptr, i); + for (i = 0; i < (virt_num_data_entries / 4); i++) { + lock_entry(file_ptr, i); - if ( i % 2 == 0 ) - { - mark_entry_dirty(i); - } + if (i % 2 == 0) { + mark_entry_dirty(i); + } - unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); + unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); - if ( i % 2 == 1 ) - { - if ( i % 4 == 1 ) { + if (i % 2 == 1) { + if (i % 4 == 1) { - lock_entry(file_ptr, i); - unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); - } + lock_entry(file_ptr, i); + unlock_entry(file_ptr, i, H5AC__DIRTIED_FLAG); + } - expunge_entry(file_ptr, i); - } + expunge_entry(file_ptr, i); + } } - for ( i = (virt_num_data_entries / 2) - 1; - i >= (virt_num_data_entries / 4); - i-- ) - { - pin_entry(file_ptr, i, TRUE, FALSE); + for (i = (virt_num_data_entries / 2) - 1; i >= (virt_num_data_entries / 4); i--) { + pin_entry(file_ptr, i, TRUE, FALSE); - if ( i % 2 == 0 ) - { - if ( i % 8 <= 4 ) { + if (i % 2 == 0) { + if (i % 8 <= 4) { - resize_entry(i, data[i].len / 2); - } + resize_entry(i, data[i].len / 2); + } mark_entry_dirty(i); - if ( i % 8 <= 4 ) { + if (i % 8 <= 4) { - resize_entry(i, data[i].len); - } - } + resize_entry(i, data[i].len); + } + } - unpin_entry(file_ptr, i, TRUE, FALSE, FALSE); + unpin_entry(file_ptr, i, TRUE, FALSE, FALSE); } - if ( fid >= 0 ) { + if (fid >= 0) { - if ( ! take_down_cache(fid, cache_ptr) ) { + if (!take_down_cache(fid, cache_ptr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", world_mpi_rank, FUNC); } } } @@ -6719,10 +6145,9 @@ smoke_check_5(int metadata_write_strategy) * and are clean. */ - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { - HDassert( data_index[i] == i ); - HDassert( ! (data[i].dirty) ); + for (i = 0; i < NUM_DATA_ENTRIES; i++) { + HDassert(data_index[i] == i); + HDassert(!(data[i].dirty)); } /* compose the done message */ @@ -6730,22 +6155,21 @@ smoke_check_5(int metadata_write_strategy) mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ - mssg.base_addr = 0; /* not used */ - mssg.len = 0; /* not used */ - mssg.ver = 0; /* not used */ - mssg.count = 0; /* not used */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ + mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( success ) { + if (success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } } } @@ -6753,26 +6177,25 @@ smoke_check_5(int metadata_write_strategy) max_nerrors = get_max_nerrors(); - if ( world_mpi_rank == 0 ) { + if (world_mpi_rank == 0) { - if ( max_nerrors == 0 ) { + if (max_nerrors == 0) { - PASSED(); - - } else { + PASSED(); + } + else { failures++; H5_FAILED(); } } - success = ( ( success ) && ( max_nerrors == 0 ) ); + success = ((success) && (max_nerrors == 0)); - return(success); + return (success); } /* smoke_check_5() */ - /***************************************************************************** * * Function: trace_file_check() @@ -6815,87 +6238,80 @@ trace_file_check(int metadata_write_strategy) { hbool_t success = TRUE; - const char *((* expected_output)[]) = NULL; - const char * expected_output_0[] = - { - "### HDF5 metadata cache trace file version 1 ###\n", - "H5AC_set_cache_auto_resize_config", - "H5AC_insert_entry", - "H5AC_insert_entry", - "H5AC_insert_entry", - "H5AC_insert_entry", - "H5AC_protect", - "H5AC_mark_entry_dirty", - "H5AC_unprotect", - "H5AC_protect", - "H5AC_pin_protected_entry", - "H5AC_unprotect", - "H5AC_unpin_entry", - "H5AC_expunge_entry", - "H5AC_protect", - "H5AC_pin_protected_entry", - "H5AC_unprotect", - "H5AC_mark_entry_dirty", - "H5AC_resize_entry", - "H5AC_resize_entry", - "H5AC_unpin_entry", - "H5AC_move_entry", - "H5AC_move_entry", - "H5AC_flush", - "H5AC_flush", - NULL - }; - const char * expected_output_1[] = - { - "### HDF5 metadata cache trace file version 1 ###\n", - "H5AC_set_cache_auto_resize_config", - "H5AC_insert_entry", - "H5AC_insert_entry", - "H5AC_insert_entry", - "H5AC_insert_entry", - "H5AC_protect", - "H5AC_mark_entry_dirty", - "H5AC_unprotect", - "H5AC_protect", - "H5AC_pin_protected_entry", - "H5AC_unprotect", - "H5AC_unpin_entry", - "H5AC_expunge_entry", - "H5AC_protect", - "H5AC_pin_protected_entry", - "H5AC_unprotect", - "H5AC_mark_entry_dirty", - "H5AC_resize_entry", - "H5AC_resize_entry", - "H5AC_unpin_entry", - "H5AC_move_entry", - "H5AC_move_entry", - "H5AC_flush", - "H5AC_flush", - NULL - }; - char buffer[256]; - char trace_file_name[64]; - hbool_t done = FALSE; - int i; - int max_nerrors; - size_t expected_line_len; - size_t actual_line_len; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - FILE * trace_file_ptr = NULL; + const char *((*expected_output)[]) = NULL; + const char * expected_output_0[] = {"### HDF5 metadata cache trace file version 1 ###\n", + "H5AC_set_cache_auto_resize_config", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_protect", + "H5AC_mark_entry_dirty", + "H5AC_unprotect", + "H5AC_protect", + "H5AC_pin_protected_entry", + "H5AC_unprotect", + "H5AC_unpin_entry", + "H5AC_expunge_entry", + "H5AC_protect", + "H5AC_pin_protected_entry", + "H5AC_unprotect", + "H5AC_mark_entry_dirty", + "H5AC_resize_entry", + "H5AC_resize_entry", + "H5AC_unpin_entry", + "H5AC_move_entry", + "H5AC_move_entry", + "H5AC_flush", + "H5AC_flush", + NULL}; + const char * expected_output_1[] = {"### HDF5 metadata cache trace file version 1 ###\n", + "H5AC_set_cache_auto_resize_config", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_protect", + "H5AC_mark_entry_dirty", + "H5AC_unprotect", + "H5AC_protect", + "H5AC_pin_protected_entry", + "H5AC_unprotect", + "H5AC_unpin_entry", + "H5AC_expunge_entry", + "H5AC_protect", + "H5AC_pin_protected_entry", + "H5AC_unprotect", + "H5AC_mark_entry_dirty", + "H5AC_resize_entry", + "H5AC_resize_entry", + "H5AC_unpin_entry", + "H5AC_move_entry", + "H5AC_move_entry", + "H5AC_flush", + "H5AC_flush", + NULL}; + char buffer[256]; + char trace_file_name[64]; + hbool_t done = FALSE; + int i; + int max_nerrors; + size_t expected_line_len; + size_t actual_line_len; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + FILE * trace_file_ptr = NULL; H5AC_cache_config_t config; - struct mssg_t mssg; - + struct mssg_t mssg; - switch(metadata_write_strategy) { + switch (metadata_write_strategy) { case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: expected_output = &expected_output_0; - if(world_mpi_rank == 0) + if (world_mpi_rank == 0) TESTING("trace file collection -- process 0 only md write strategy"); break; @@ -6903,7 +6319,7 @@ trace_file_check(int metadata_write_strategy) expected_output = &expected_output_1; - if(world_mpi_rank == 0) + if (world_mpi_rank == 0) TESTING("trace file collection -- distributed md write strategy"); break; @@ -6914,53 +6330,54 @@ trace_file_check(int metadata_write_strategy) */ expected_output = &expected_output_0; - if(world_mpi_rank == 0) + if (world_mpi_rank == 0) TESTING("trace file collection -- unknown md write strategy"); break; } /* end switch */ - nerrors = 0; init_data(); reset_stats(); - if(world_mpi_rank == world_server_mpi_rank) { + if (world_mpi_rank == world_server_mpi_rank) { - if(!server_main()) { + if (!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) + if (verbose) HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } else { /* run the clients */ - if(!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy) ) { + if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; - fid = -1; + fid = -1; cache_ptr = NULL; - if(verbose) + if (verbose) HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } - if(nerrors == 0) { + if (nerrors == 0) { config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if(H5AC_get_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { + if (H5AC_get_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { nerrors++; - HDfprintf(stdout, "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", world_mpi_rank, + FUNC); } else { config.open_trace_file = TRUE; strcpy(config.trace_file_name, "t_cache_trace.txt"); - if(H5AC_set_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { + if (H5AC_set_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { nerrors++; - HDfprintf(stdout, "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", world_mpi_rank, + FUNC); } } } /* end if */ @@ -6992,36 +6409,38 @@ trace_file_check(int metadata_write_strategy) move_entry(file_ptr, 0, 20); move_entry(file_ptr, 0, 20); - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { nerrors++; - if(verbose) + if (verbose) HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", world_mpi_rank, FUNC); } - if(nerrors == 0) { + if (nerrors == 0) { config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if(H5AC_get_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { + if (H5AC_get_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { nerrors++; - HDfprintf(stdout, "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", world_mpi_rank, + FUNC); } else { - config.open_trace_file = FALSE; - config.close_trace_file = TRUE; + config.open_trace_file = FALSE; + config.close_trace_file = TRUE; config.trace_file_name[0] = '\0'; - if(H5AC_set_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { + if (H5AC_set_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { nerrors++; - HDfprintf(stdout, "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", world_mpi_rank, FUNC); + HDfprintf(stdout, "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", world_mpi_rank, + FUNC); } } } /* end if */ - if(fid >= 0) { - if(!take_down_cache(fid, cache_ptr)) { + if (fid >= 0) { + if (!take_down_cache(fid, cache_ptr)) { nerrors++; - if(verbose) + if (verbose) HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", world_mpi_rank, FUNC); } } /* end if */ @@ -7030,7 +6449,7 @@ trace_file_check(int metadata_write_strategy) * and are clean. */ - for(i = 0; i < NUM_DATA_ENTRIES; i++) { + for (i = 0; i < NUM_DATA_ENTRIES; i++) { HDassert(data_index[i] == i); HDassert(!(data[i].dirty)); } @@ -7040,80 +6459,88 @@ trace_file_check(int metadata_write_strategy) mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ - mssg.base_addr = 0; /* not used */ - mssg.len = 0; /* not used */ - mssg.ver = 0; /* not used */ - mssg.count = 0; /* not used */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ + mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if(success) { + if (success) { success = send_mssg(&mssg, FALSE); - if(!success) { + if (!success) { nerrors++; - if(verbose) + if (verbose) HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } } /* end if */ - if(nerrors == 0) { + if (nerrors == 0) { HDsprintf(trace_file_name, "t_cache_trace.txt.%d", (int)file_mpi_rank); - if((trace_file_ptr = HDfopen(trace_file_name, "r")) == NULL ) { + if ((trace_file_ptr = HDfopen(trace_file_name, "r")) == NULL) { nerrors++; - if(verbose) + if (verbose) HDfprintf(stdout, "%d:%s: HDfopen failed.\n", world_mpi_rank, FUNC); } } /* end if */ - i = 0; - while((nerrors == 0) && (!done)) { + while ((nerrors == 0) && (!done)) { /* Get lines of actual and expected data */ - if((*expected_output)[i] == NULL) + if ((*expected_output)[i] == NULL) expected_line_len = (size_t)0; else expected_line_len = HDstrlen((*expected_output)[i]); - if(HDfgets(buffer, 255, trace_file_ptr) != NULL) + if (HDfgets(buffer, 255, trace_file_ptr) != NULL) actual_line_len = HDstrlen(buffer); else actual_line_len = (size_t)0; /* Compare the lines */ /* Handle running out of data */ - if((actual_line_len == 0) || (expected_line_len == 0)) { - if((actual_line_len == 0) && (expected_line_len == 0)) { + if ((actual_line_len == 0) || (expected_line_len == 0)) { + if ((actual_line_len == 0) && (expected_line_len == 0)) { /* Both ran out at the same time - we're done */ done = TRUE; } else { /* One ran out before the other - BADNESS */ nerrors++; - if(verbose) { - HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, FUNC, i); - if(expected_line_len == 0) { - HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, "", expected_line_len); - HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, buffer, actual_line_len); + if (verbose) { + HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, + FUNC, i); + if (expected_line_len == 0) { + HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, + "", expected_line_len); + HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, buffer, + actual_line_len); } - if(actual_line_len == 0) { - HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, (*expected_output)[i], expected_line_len); - HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, "", actual_line_len); + if (actual_line_len == 0) { + HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, + (*expected_output)[i], expected_line_len); + HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, + "", actual_line_len); } } HDfprintf(stdout, "BADNESS BADNESS BADNESS\n"); } } /* We directly compare the header line (line 0) */ - else if(0 == i) { - if((actual_line_len != expected_line_len) || (HDstrcmp(buffer, (*expected_output)[i]) != 0 )) { + else if (0 == i) { + if ((actual_line_len != expected_line_len) || + (HDstrcmp(buffer, (*expected_output)[i]) != 0)) { nerrors++; - if(verbose) { - HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, FUNC, i); - HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, (*expected_output)[i], expected_line_len); - HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, buffer, actual_line_len); + if (verbose) { + HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, + FUNC, i); + HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, + (*expected_output)[i], expected_line_len); + HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, buffer, + actual_line_len); } } } @@ -7121,16 +6548,18 @@ trace_file_check(int metadata_write_strategy) * keeps the test from being too fragile. */ else { - char *tok = NULL; /* token for actual line */ + char *tok = NULL; /* token for actual line */ tok = HDstrtok(buffer, " "); - if(HDstrcmp(tok, (*expected_output)[i]) != 0 ) { + if (HDstrcmp(tok, (*expected_output)[i]) != 0) { nerrors++; - if(verbose) { - HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, FUNC, i); - HDfprintf(stdout, "%d:%s: expected = \"%s\"\n", world_mpi_rank, FUNC, (*expected_output)[i]); + if (verbose) { + HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, + FUNC, i); + HDfprintf(stdout, "%d:%s: expected = \"%s\"\n", world_mpi_rank, FUNC, + (*expected_output)[i]); HDfprintf(stdout, "%d:%s: actual = \"%s\"\n", world_mpi_rank, FUNC, tok); } } @@ -7140,7 +6569,7 @@ trace_file_check(int metadata_write_strategy) } /* end while */ /* Clean up the trace file */ - if(trace_file_ptr != NULL) { + if (trace_file_ptr != NULL) { HDfclose(trace_file_ptr); trace_file_ptr = NULL; HDremove(trace_file_name); @@ -7149,9 +6578,9 @@ trace_file_check(int metadata_write_strategy) max_nerrors = get_max_nerrors(); - if(world_mpi_rank == 0) { + if (world_mpi_rank == 0) { - if(max_nerrors == 0) { + if (max_nerrors == 0) { PASSED(); } else { @@ -7162,11 +6591,10 @@ trace_file_check(int metadata_write_strategy) success = ((success) && (max_nerrors == 0)); - return(success); + return (success); } /* trace_file_check() */ - /***************************************************************************** * * Function: smoke_check_6() @@ -7183,48 +6611,47 @@ trace_file_check(int metadata_write_strategy) static hbool_t smoke_check_6(int metadata_write_strategy) { - hbool_t success = TRUE; - int i; - int max_nerrors; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + hbool_t success = TRUE; + int i; + int max_nerrors; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; struct mssg_t mssg; - switch ( metadata_write_strategy ) { + switch (metadata_write_strategy) { - case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #6 -- process 0 only md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: + if (world_mpi_rank == 0) { + TESTING("smoke check #6 -- process 0 only md write strategy"); } - break; + break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #6 -- distributed md write strategy"); + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + if (world_mpi_rank == 0) { + TESTING("smoke check #6 -- distributed md write strategy"); } - break; + break; default: - if ( world_mpi_rank == 0 ) { - TESTING("smoke check #6 -- unknown md write strategy"); + if (world_mpi_rank == 0) { + TESTING("smoke check #6 -- unknown md write strategy"); } - break; + break; } nerrors = 0; init_data(); reset_stats(); - if ( world_mpi_rank == world_server_mpi_rank ) { + if (world_mpi_rank == world_server_mpi_rank) { - if ( ! server_main() ) { + if (!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } } @@ -7232,128 +6659,119 @@ smoke_check_6(int metadata_write_strategy) { int temp; - if ( ! setup_cache_for_test(&fid, &file_ptr, &cache_ptr, - metadata_write_strategy) ) { + if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; - fid = -1; + fid = -1; cache_ptr = NULL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } } - temp = virt_num_data_entries; + temp = virt_num_data_entries; virt_num_data_entries = NUM_DATA_ENTRIES; /* insert the first half collectively */ H5CX_set_coll_metadata_read(TRUE); - for ( i = 0; i < virt_num_data_entries/2; i++ ) - { - struct datum * entry_ptr; + for (i = 0; i < virt_num_data_entries / 2; i++) { + struct datum *entry_ptr; entry_ptr = &(data[i]); insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); - if(TRUE != entry_ptr->header.coll_access) { + if (TRUE != entry_ptr->header.coll_access) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Entry inserted not marked as collective.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Entry inserted not marked as collective.\n", world_mpi_rank, + FUNC); } } /* Make sure coll entries do not cross the 80% threshold */ H5_CHECK_OVERFLOW(cache_ptr->max_cache_size, size_t, double); - HDassert((double)cache_ptr->max_cache_size*0.8 > cache_ptr->coll_list_size); + HDassert((double)cache_ptr->max_cache_size * 0.8 > cache_ptr->coll_list_size); } /* insert the other half independently */ H5CX_set_coll_metadata_read(FALSE); - for ( i = virt_num_data_entries/2; i < virt_num_data_entries; i++ ) - { - struct datum * entry_ptr; + for (i = virt_num_data_entries / 2; i < virt_num_data_entries; i++) { + struct datum *entry_ptr; entry_ptr = &(data[i]); insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); - if(FALSE != entry_ptr->header.coll_access) { + if (FALSE != entry_ptr->header.coll_access) { nerrors++; - if ( verbose ) { + if (verbose) { HDfprintf(stdout, "%d:%s: Entry inserted indepedently marked as collective.\n", world_mpi_rank, FUNC); } } /* Make sure coll entries do not cross the 80% threshold */ - HDassert((double)cache_ptr->max_cache_size*0.8 > cache_ptr->coll_list_size); + HDassert((double)cache_ptr->max_cache_size * 0.8 > cache_ptr->coll_list_size); } /* flush the file */ - if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", world_mpi_rank, FUNC); } } /* Protect the first half of the entries collectively */ H5CX_set_coll_metadata_read(TRUE); - for ( i = 0; i < (virt_num_data_entries / 2); i++ ) - { - struct datum * entry_ptr; + for (i = 0; i < (virt_num_data_entries / 2); i++) { + struct datum *entry_ptr; entry_ptr = &(data[i]); - lock_entry(file_ptr, i); + lock_entry(file_ptr, i); - if(TRUE != entry_ptr->header.coll_access) { + if (TRUE != entry_ptr->header.coll_access) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: Entry protected not marked as collective.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: Entry protected not marked as collective.\n", world_mpi_rank, + FUNC); } } /* Make sure coll entries do not cross the 80% threshold */ - HDassert((double)cache_ptr->max_cache_size*0.8 > cache_ptr->coll_list_size); + HDassert((double)cache_ptr->max_cache_size * 0.8 > cache_ptr->coll_list_size); } /* protect the other half independently */ H5CX_set_coll_metadata_read(FALSE); - for ( i = virt_num_data_entries/2; i < virt_num_data_entries; i++ ) - { - struct datum * entry_ptr; + for (i = virt_num_data_entries / 2; i < virt_num_data_entries; i++) { + struct datum *entry_ptr; entry_ptr = &(data[i]); lock_entry(file_ptr, i); - if(FALSE != entry_ptr->header.coll_access) { + if (FALSE != entry_ptr->header.coll_access) { nerrors++; - if ( verbose ) { + if (verbose) { HDfprintf(stdout, "%d:%s: Entry inserted indepedently marked as collective.\n", world_mpi_rank, FUNC); } } /* Make sure coll entries do not cross the 80% threshold */ - HDassert((double)cache_ptr->max_cache_size*0.8 > cache_ptr->coll_list_size); + HDassert((double)cache_ptr->max_cache_size * 0.8 > cache_ptr->coll_list_size); } - for ( i = 0; i < (virt_num_data_entries); i++ ) - { + for (i = 0; i < (virt_num_data_entries); i++) { unlock_entry(file_ptr, i, H5AC__NO_FLAGS_SET); } - if ( fid >= 0 ) { + if (fid >= 0) { - if ( ! take_down_cache(fid, cache_ptr) ) { + if (!take_down_cache(fid, cache_ptr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", world_mpi_rank, FUNC); } } } @@ -7362,10 +6780,9 @@ smoke_check_6(int metadata_write_strategy) * and are clean. */ - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { - HDassert( data_index[i] == i ); - HDassert( ! (data[i].dirty) ); + for (i = 0; i < NUM_DATA_ENTRIES; i++) { + HDassert(data_index[i] == i); + HDassert(!(data[i].dirty)); } /* compose the done message */ @@ -7373,23 +6790,21 @@ smoke_check_6(int metadata_write_strategy) mssg.src = world_mpi_rank; mssg.dest = world_server_mpi_rank; mssg.mssg_num = -1; /* set by send function */ - mssg.base_addr = 0; /* not used */ - mssg.len = 0; /* not used */ - mssg.ver = 0; /* not used */ - mssg.count = 0; /* not used */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ + mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( success ) { - + if (success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { + if (!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } } } @@ -7398,26 +6813,25 @@ smoke_check_6(int metadata_write_strategy) max_nerrors = get_max_nerrors(); - if ( world_mpi_rank == 0 ) { + if (world_mpi_rank == 0) { - if ( max_nerrors == 0 ) { + if (max_nerrors == 0) { - PASSED(); - - } else { + PASSED(); + } + else { failures++; H5_FAILED(); } } - success = ( ( success ) && ( max_nerrors == 0 ) ); + success = ((success) && (max_nerrors == 0)); - return(success); + return (success); } /* smoke_check_6() */ - /***************************************************************************** * * Function: main() @@ -7434,62 +6848,62 @@ smoke_check_6(int metadata_write_strategy) int main(int argc, char **argv) { - int express_test; + int express_test; unsigned u; - int mpi_size; - int mpi_rank; - int max_nerrors; + int mpi_size; + int mpi_rank; + int max_nerrors; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - world_mpi_size = mpi_size; - world_mpi_rank = mpi_rank; + world_mpi_size = mpi_size; + world_mpi_rank = mpi_rank; world_server_mpi_rank = mpi_size - 1; - world_mpi_comm = MPI_COMM_WORLD; + world_mpi_comm = MPI_COMM_WORLD; /* Attempt to turn off atexit post processing so that in case errors * happen during the test and the process is aborted, it will not get * hang in the atexit post processing in which it may try to make MPI * calls. By then, MPI calls may not work. */ - if (H5dont_atexit() < 0){ - HDprintf("%d:Failed to turn off atexit processing. Continue.\n", - mpi_rank); + if (H5dont_atexit() < 0) { + HDprintf("%d:Failed to turn off atexit processing. Continue.\n", mpi_rank); }; H5open(); express_test = do_express_test(); -#if 0 /* JRM */ +#if 0 /* JRM */ express_test = 0; #endif /* JRM */ - if ( express_test ) { - - virt_num_data_entries = EXPRESS_VIRT_NUM_DATA_ENTRIES; + if (express_test) { - } else { + virt_num_data_entries = EXPRESS_VIRT_NUM_DATA_ENTRIES; + } + else { - virt_num_data_entries = STD_VIRT_NUM_DATA_ENTRIES; + virt_num_data_entries = STD_VIRT_NUM_DATA_ENTRIES; } #ifdef H5_HAVE_MPE - if ( MAINPROCESS ) { HDprintf(" Tests compiled for MPE.\n"); } + if (MAINPROCESS) { + HDprintf(" Tests compiled for MPE.\n"); + } virt_num_data_entries = MPE_VIRT_NUM_DATA_ENTIES; #endif /* H5_HAVE_MPE */ - - if (MAINPROCESS){ - HDprintf("===================================\n"); - HDprintf("Parallel metadata cache tests\n"); - HDprintf(" mpi_size = %d\n", mpi_size); - HDprintf(" express_test = %d\n", express_test); - HDprintf("===================================\n"); + if (MAINPROCESS) { + HDprintf("===================================\n"); + HDprintf("Parallel metadata cache tests\n"); + HDprintf(" mpi_size = %d\n", mpi_size); + HDprintf(" express_test = %d\n", express_test); + HDprintf("===================================\n"); } - if ( mpi_size < 3 ) { + if (mpi_size < 3) { - if ( MAINPROCESS ) { + if (MAINPROCESS) { HDprintf(" Need at least 3 processes. Exiting.\n"); } @@ -7508,65 +6922,57 @@ main(int argc, char **argv) */ /* setup file access property list with the world communicator */ - if ( FAIL == (fapl = H5Pcreate(H5P_FILE_ACCESS)) ) { + if (FAIL == (fapl = H5Pcreate(H5P_FILE_ACCESS))) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Pcreate() failed 1.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Pcreate() failed 1.\n", world_mpi_rank, FUNC); } } - if ( H5Pset_fapl_mpio(fapl, world_mpi_comm, MPI_INFO_NULL) < 0 ) { + if (H5Pset_fapl_mpio(fapl, world_mpi_comm, MPI_INFO_NULL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Pset_fapl_mpio() failed 1.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Pset_fapl_mpio() failed 1.\n", world_mpi_rank, FUNC); } } /* fix the file names */ - for ( u = 0; u < sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; ++u ) - { - if ( h5_fixname(FILENAME[u], fapl, filenames[u], - sizeof(filenames[u])) == NULL ) { + for (u = 0; u < sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; ++u) { + if (h5_fixname(FILENAME[u], fapl, filenames[u], sizeof(filenames[u])) == NULL) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: h5_fixname() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: h5_fixname() failed.\n", world_mpi_rank, FUNC); } break; } } /* close the fapl before we set it up again */ - if ( H5Pclose(fapl) < 0 ) { + if (H5Pclose(fapl) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Pclose() failed.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Pclose() failed.\n", world_mpi_rank, FUNC); } } /* now create the fapl again, excluding the server process. */ - if ( world_mpi_rank != world_server_mpi_rank ) { + if (world_mpi_rank != world_server_mpi_rank) { /* setup file access property list */ - if ( FAIL == (fapl = H5Pcreate(H5P_FILE_ACCESS)) ) { - nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Pcreate() failed 2.\n", - world_mpi_rank, FUNC); + if (FAIL == (fapl = H5Pcreate(H5P_FILE_ACCESS))) { + nerrors++; + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Pcreate() failed 2.\n", world_mpi_rank, FUNC); } } - if ( H5Pset_fapl_mpio(fapl, file_mpi_comm, MPI_INFO_NULL) < 0 ) { + if (H5Pset_fapl_mpio(fapl, file_mpi_comm, MPI_INFO_NULL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Pset_fapl_mpio() failed 2.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Pset_fapl_mpio() failed 2.\n", world_mpi_rank, FUNC); } } } @@ -7575,15 +6981,15 @@ main(int argc, char **argv) max_nerrors = get_max_nerrors(); - if ( max_nerrors != 0 ) { + if (max_nerrors != 0) { /* errors in setup -- no point in continuing */ - if ( world_mpi_rank == 0 ) { + if (world_mpi_rank == 0) { HDfprintf(stdout, "Errors in test initialization. Exiting.\n"); } - goto finish; + goto finish; } /* run the tests */ @@ -7611,13 +7017,12 @@ main(int argc, char **argv) smoke_check_5(H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); #endif /* enable the collective metadata read property */ - if ( world_mpi_rank != world_server_mpi_rank ) { - if ( H5Pset_all_coll_metadata_ops(fapl, TRUE) < 0 ) { + if (world_mpi_rank != world_server_mpi_rank) { + if (H5Pset_all_coll_metadata_ops(fapl, TRUE) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Pset_all_coll_metadata_ops() failed 1.\n", - world_mpi_rank, FUNC); + if (verbose) { + HDfprintf(stdout, "%d:%s: H5Pset_all_coll_metadata_ops() failed 1.\n", world_mpi_rank, FUNC); } } } @@ -7636,16 +7041,15 @@ finish: * and exit. */ MPI_Barrier(MPI_COMM_WORLD); - if (MAINPROCESS){ /* only process 0 reports */ - HDprintf("===================================\n"); - if (failures){ - HDprintf("***metadata cache tests detected %d failures***\n", - failures); - } - else{ - HDprintf("metadata cache tests finished with no failures\n"); - } - HDprintf("===================================\n"); + if (MAINPROCESS) { /* only process 0 reports */ + HDprintf("===================================\n"); + if (failures) { + HDprintf("***metadata cache tests detected %d failures***\n", failures); + } + else { + HDprintf("metadata cache tests finished with no failures\n"); + } + HDprintf("===================================\n"); } takedown_derived_types(); @@ -7657,6 +7061,5 @@ finish: MPI_Finalize(); /* cannot just return (failures) because exit code is limited to 1byte */ - return(failures != 0); + return (failures != 0); } - diff --git a/testpar/t_cache_image.c b/testpar/t_cache_image.c index 14e3d10..39cfbf3 100644 --- a/testpar/t_cache_image.c +++ b/testpar/t_cache_image.c @@ -27,18 +27,12 @@ #define DSET_SIZE (40 * CHUNK_SIZE) #define MAX_NUM_DSETS 256 #define PAR_NUM_DSETS 32 -#define PAGE_SIZE (4 * 1024) +#define PAGE_SIZE (4 * 1024) #define PB_SIZE (64 * PAGE_SIZE) /* global variable declarations: */ - -const char *FILENAMES[] = { - "t_cache_image_00", - "t_cache_image_01", - "t_cache_image_02", - NULL -}; +const char *FILENAMES[] = {"t_cache_image_00", "t_cache_image_01", "t_cache_image_02", NULL}; /* local utility function declarations */ @@ -47,49 +41,34 @@ static void create_data_sets(hid_t file_id, int min_dset, int max_dset); static void delete_data_sets(hid_t file_id, int min_dset, int max_dset); #endif -static void open_hdf5_file(const hbool_t create_file, - const hbool_t mdci_sbem_expected, - const hbool_t read_only, - const hbool_t set_mdci_fapl, - const hbool_t config_fsm, - const hbool_t enable_page_buffer, - const char * hdf_file_name, - const unsigned cache_image_flags, - hid_t * file_id_ptr, - H5F_t ** file_ptr_ptr, - H5C_t ** cache_ptr_ptr, - MPI_Comm comm, - MPI_Info info, - int l_facc_type, - const hbool_t all_coll_metadata_ops, - const hbool_t coll_metadata_write, - const int md_write_strat); +static void open_hdf5_file(const hbool_t create_file, const hbool_t mdci_sbem_expected, + const hbool_t read_only, const hbool_t set_mdci_fapl, const hbool_t config_fsm, + const hbool_t enable_page_buffer, const char *hdf_file_name, + const unsigned cache_image_flags, hid_t *file_id_ptr, H5F_t **file_ptr_ptr, + H5C_t **cache_ptr_ptr, MPI_Comm comm, MPI_Info info, int l_facc_type, + const hbool_t all_coll_metadata_ops, const hbool_t coll_metadata_write, + const int md_write_strat); static void verify_data_sets(hid_t file_id, int min_dset, int max_dset); /* local test function declarations */ -static hbool_t parse_flags(int argc, char * argv[], hbool_t * setup_ptr, - hbool_t * ici_ptr, int * file_idx_ptr, int * mpi_size_ptr, hbool_t display); -static void usage(void); +static hbool_t parse_flags(int argc, char *argv[], hbool_t *setup_ptr, hbool_t *ici_ptr, int *file_idx_ptr, + int *mpi_size_ptr, hbool_t display); +static void usage(void); static unsigned construct_test_file(int test_file_index); -static void par_create_dataset(int dset_num, hid_t file_id, int mpi_rank, - int mpi_size); -static void par_delete_dataset(int dset_num, hid_t file_id, int mpi_rank); -static void par_verify_dataset(int dset_num, hid_t file_id, int mpi_rank); +static void par_create_dataset(int dset_num, hid_t file_id, int mpi_rank, int mpi_size); +static void par_delete_dataset(int dset_num, hid_t file_id, int mpi_rank); +static void par_verify_dataset(int dset_num, hid_t file_id, int mpi_rank); static hbool_t serial_insert_cache_image(int file_name_idx, int mpi_size); -static void serial_verify_dataset(int dset_num, hid_t file_id, int mpi_size); +static void serial_verify_dataset(int dset_num, hid_t file_id, int mpi_size); /* top level test function declarations */ -static unsigned verify_cache_image_RO(int file_name_id, - int md_write_strat, int mpi_rank); -static unsigned verify_cache_image_RW(int file_name_id, - int md_write_strat, int mpi_rank); - -static hbool_t smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, - int mpi_rank, int mpi_size); +static unsigned verify_cache_image_RO(int file_name_id, int md_write_strat, int mpi_rank); +static unsigned verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank); +static hbool_t smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size); /****************************************************************************/ /***************************** Utility Functions ****************************/ @@ -160,42 +139,38 @@ static hbool_t smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, static unsigned construct_test_file(int test_file_index) { - const char * fcn_name = "construct_test_file()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; - int min_dset = 0; - int max_dset = 0; - MPI_Comm dummy_comm = MPI_COMM_WORLD; - MPI_Info dummy_info = MPI_INFO_NULL; + const char *fcn_name = "construct_test_file()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; + int min_dset = 0; + int max_dset = 0; + MPI_Comm dummy_comm = MPI_COMM_WORLD; + MPI_Info dummy_info = MPI_INFO_NULL; pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { HDassert(FILENAMES[test_file_index]); - if ( h5_fixname(FILENAMES[test_file_index], H5P_DEFAULT, - filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[test_file_index], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a HDF5 file with the cache image FAPL entry. * * Verify that the cache is informed of the cache image FAPL entry. @@ -203,13 +178,13 @@ construct_test_file(int test_file_index) * Set flags forcing full function of the cache image feature. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ TRUE, + /* config_fsm */ TRUE, /* enable_page_buffer */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, @@ -224,50 +199,45 @@ construct_test_file(int test_file_index) /* md_write_strat */ 0); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create a data set in the file. */ - if ( pass ) { + if (pass) { create_data_sets(file_id, min_dset++, max_dset++); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - - while ( ( pass ) && ( max_dset < MAX_NUM_DSETS ) ) - { + while ((pass) && (max_dset < MAX_NUM_DSETS)) { /* 4) Open the file. * @@ -275,13 +245,13 @@ construct_test_file(int test_file_index) * metadata cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ TRUE, - /* config_fsm */ FALSE, + /* config_fsm */ FALSE, /* enable_page_buffer */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, @@ -296,66 +266,59 @@ construct_test_file(int test_file_index) /* md_write_strat */ 0); } - if ( show_progress ) - HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp, max_dset, pass); - + if (show_progress) + HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp, max_dset, pass); /* 5) Create a data set in the file. */ - if ( pass ) { + if (pass) { create_data_sets(file_id, min_dset++, max_dset++); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) - HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp + 1, max_dset, pass); - + if (show_progress) + HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp + 1, max_dset, pass); /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) - HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n", - fcn_name, cp + 2, max_dset, pass); + if (show_progress) + HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n", fcn_name, cp + 2, max_dset, pass); } /* end while */ cp += 3; - /* 7) Open the file R/O. * * Verify that the file contains a metadata cache image * superblock extension message. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, + /* config_fsm */ FALSE, /* enable_page_buffer */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, @@ -370,41 +333,40 @@ construct_test_file(int test_file_index) /* md_write_strat */ 0); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Open and close all data sets. * * Verify that the cache image has been loaded. */ - if ( pass ) { + if (pass) { - verify_data_sets(file_id, 0, max_dset - 1); + verify_data_sets(file_id, 0, max_dset - 1); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded == 0 ) { + if (cache_ptr->images_loaded == 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* 9) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } @@ -413,7 +375,6 @@ construct_test_file(int test_file_index) } /* construct_test_file() */ - /*------------------------------------------------------------------------- * Function: create_data_sets() * @@ -446,26 +407,27 @@ construct_test_file(int test_file_index) static void create_data_sets(hid_t file_id, int min_dset, int max_dset) { - const char * fcn_name = "create_data_sets()"; - char dset_name[64]; - hbool_t show_progress = FALSE; - hbool_t valid_chunk; - hbool_t verbose = FALSE; - int cp = 0; - int i, j, k, l, m; - int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; - herr_t status; - hid_t dataspace_id = -1; - hid_t filespace_ids[MAX_NUM_DSETS]; - hid_t memspace_id = -1; - hid_t dataset_ids[MAX_NUM_DSETS]; - hid_t properties = -1; - hsize_t dims[2]; - hsize_t a_size[2]; - hsize_t offset[2]; - hsize_t chunk_size[2]; - - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + const char *fcn_name = "create_data_sets()"; + char dset_name[64]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l, m; + int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; + herr_t status; + hid_t dataspace_id = -1; + hid_t filespace_ids[MAX_NUM_DSETS]; + hid_t memspace_id = -1; + hid_t dataset_ids[MAX_NUM_DSETS]; + hid_t properties = -1; + hsize_t dims[2]; + hsize_t a_size[2]; + hsize_t offset[2]; + hsize_t chunk_size[2]; + + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); HDassert(0 <= min_dset); HDassert(min_dset <= max_dset); @@ -473,20 +435,19 @@ create_data_sets(hid_t file_id, int min_dset, int max_dset) /* create the datasets */ - if ( pass ) { + if (pass) { i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { + while ((pass) && (i <= max_dset)) { /* create a dataspace for the chunked dataset */ - dims[0] = DSET_SIZE; - dims[1] = DSET_SIZE; + dims[0] = DSET_SIZE; + dims[1] = DSET_SIZE; dataspace_id = H5Screate_simple(2, dims, NULL); - if ( dataspace_id < 0 ) { + if (dataspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } @@ -494,51 +455,50 @@ create_data_sets(hid_t file_id, int min_dset, int max_dset) * to be partioned into 10X10 element chunks. */ - if ( pass ) { + if (pass) { chunk_size[0] = CHUNK_SIZE; chunk_size[1] = CHUNK_SIZE; - properties = H5Pcreate(H5P_DATASET_CREATE); + properties = H5Pcreate(H5P_DATASET_CREATE); - if ( properties < 0 ) { + if (properties < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate() failed."; } } - if ( pass ) { + if (pass) { - if ( H5Pset_chunk(properties, 2, chunk_size) < 0 ) { + if (H5Pset_chunk(properties, 2, chunk_size) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_chunk() failed."; } } /* create the dataset */ - if ( pass ) { + if (pass) { HDsprintf(dset_name, "/dset%03d", i); - dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, - dataspace_id, H5P_DEFAULT, + dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, properties, H5P_DEFAULT); - if ( dataset_ids[i] < 0 ) { + if (dataset_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dcreate() failed."; } } /* get the file space ID */ - if ( pass ) { + if (pass) { filespace_ids[i] = H5Dget_space(dataset_ids[i]); - if ( filespace_ids[i] < 0 ) { + if (filespace_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dget_space() failed."; } } @@ -547,84 +507,79 @@ create_data_sets(hid_t file_id, int min_dset, int max_dset) } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* create the mem space to be used to read and write chunks */ - if ( pass ) { + if (pass) { - dims[0] = CHUNK_SIZE; - dims[1] = CHUNK_SIZE; + dims[0] = CHUNK_SIZE; + dims[1] = CHUNK_SIZE; memspace_id = H5Screate_simple(2, dims, NULL); - if ( memspace_id < 0 ) { + if (memspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* select in memory hyperslab */ - if ( pass ) { + if (pass) { - offset[0] = 0; /*offset of hyperslab in memory*/ + offset[0] = 0; /*offset of hyperslab in memory*/ offset[1] = 0; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, - a_size, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* initialize all datasets on a round robin basis */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { m = min_dset; - while ( ( pass ) && ( m <= max_dset ) ) - { + while ((pass) && (m <= max_dset)) { /* initialize the slab */ - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l; + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l; } } /* select on disk hyperslab */ offset[0] = (hsize_t)i; /*offset of hyperslab in file*/ offset[1] = (hsize_t)j; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "disk H5Sselect_hyperslab() failed."; } /* write the chunk to file */ - status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, - filespace_ids[m], H5P_DEFAULT, data_chunk); + status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, + data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dwrite() failed."; } m++; @@ -635,88 +590,75 @@ create_data_sets(hid_t file_id, int min_dset, int max_dset) i += CHUNK_SIZE; } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* read data from data sets and validate it */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { m = min_dset; - while ( ( pass ) && ( m <= max_dset ) ) - { + while ((pass) && (m <= max_dset)) { /* select on disk hyperslab */ offset[0] = (hsize_t)i; /* offset of hyperslab in file */ offset[1] = (hsize_t)j; a_size[0] = CHUNK_SIZE; /* size of hyperslab */ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, - memspace_id, filespace_ids[m], + status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - if ( data_chunk[k][l] - != - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l) ) { + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + if (data_chunk[k][l] != + ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)) { valid_chunk = FALSE; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "data_chunk[%0d][%0d] = %0d, expect %0d.\n", - k, l, data_chunk[k][l], - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l)); - HDfprintf(stdout, - "m = %d, i = %d, j = %d, k = %d, l = %d\n", - m, i, j, k, l); - } + HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", k, l, + data_chunk[k][l], + ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)); + HDfprintf(stdout, "m = %d, i = %d, j = %d, k = %d, l = %d\n", m, i, j, k, + l); + } } } } - if ( ! valid_chunk ) { + if (!valid_chunk) { - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "Chunk (%0d, %0d) in /dset%03d is invalid.\n", - i, j, m); - } + HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", i, j, m); + } } } m++; @@ -726,39 +668,37 @@ create_data_sets(hid_t file_id, int min_dset, int max_dset) i += CHUNK_SIZE; } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* close the file spaces */ i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { - if ( H5Sclose(filespace_ids[i]) < 0 ) { + while ((pass) && (i <= max_dset)) { + if (H5Sclose(filespace_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose() failed."; } i++; } - /* close the datasets */ i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { - if ( H5Dclose(dataset_ids[i]) < 0 ) { + while ((pass) && (i <= max_dset)) { + if (H5Dclose(dataset_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose() failed."; } i++; } /* close the mem space */ - if ( pass ) { + if (pass) { - if ( H5Sclose(memspace_id) < 0 ) { + if (H5Sclose(memspace_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(memspace_id) failed."; } } @@ -767,7 +707,6 @@ create_data_sets(hid_t file_id, int min_dset, int max_dset) } /* create_data_sets() */ - /*------------------------------------------------------------------------- * Function: delete_data_sets() * @@ -849,7 +788,6 @@ delete_data_sets(hid_t file_id, int min_dset, int max_dset) } /* delete_data_sets() */ #endif - /*------------------------------------------------------------------------- * Function: open_hdf5_file() * @@ -901,277 +839,248 @@ delete_data_sets(hid_t file_id, int min_dset, int max_dset) */ static void -open_hdf5_file(const hbool_t create_file, - const hbool_t mdci_sbem_expected, - const hbool_t read_only, - const hbool_t set_mdci_fapl, - const hbool_t config_fsm, - const hbool_t enable_page_buffer, - const char * hdf_file_name, - const unsigned cache_image_flags, - hid_t * file_id_ptr, - H5F_t ** file_ptr_ptr, - H5C_t ** cache_ptr_ptr, - MPI_Comm comm, - MPI_Info info, - int l_facc_type, - const hbool_t all_coll_metadata_ops, - const hbool_t coll_metadata_write, +open_hdf5_file(const hbool_t create_file, const hbool_t mdci_sbem_expected, const hbool_t read_only, + const hbool_t set_mdci_fapl, const hbool_t config_fsm, const hbool_t enable_page_buffer, + const char *hdf_file_name, const unsigned cache_image_flags, hid_t *file_id_ptr, + H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr, MPI_Comm comm, MPI_Info info, int l_facc_type, + const hbool_t all_coll_metadata_ops, const hbool_t coll_metadata_write, const int md_write_strat) { - const char * fcn_name = "open_hdf5_file()"; - hbool_t show_progress = FALSE; - hbool_t verbose = FALSE; - int cp = 0; - hid_t fapl_id = -1; - hid_t fcpl_id = -1; - hid_t file_id = -1; - herr_t result; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5C_cache_image_ctl_t image_ctl; - H5AC_cache_image_config_t cache_image_config = { - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, - FALSE, - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + const char * fcn_name = "open_hdf5_file()"; + hbool_t show_progress = FALSE; + hbool_t verbose = FALSE; + int cp = 0; + hid_t fapl_id = -1; + hid_t fcpl_id = -1; + hid_t file_id = -1; + herr_t result; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5C_cache_image_ctl_t image_ctl; + H5AC_cache_image_config_t cache_image_config = {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; HDassert(!create_file || config_fsm); - if ( pass ) - { - /* opening the file both read only and with a cache image + if (pass) { + /* opening the file both read only and with a cache image * requested is a contradiction. We resolve it by ignoring * the cache image request silently. */ - if ( ( create_file && mdci_sbem_expected ) || - ( create_file && read_only ) || - ( config_fsm && !create_file ) || - ( create_file && enable_page_buffer && ! config_fsm ) || - ( hdf_file_name == NULL ) || - ( ( set_mdci_fapl ) && ( cache_image_flags == 0 ) ) || - ( ( set_mdci_fapl ) && - ( (cache_image_flags & ~H5C_CI__ALL_FLAGS) != 0 ) ) || - ( file_id_ptr == NULL ) || - ( file_ptr_ptr == NULL ) || - ( cache_ptr_ptr == NULL ) || - ( l_facc_type != (l_facc_type & (FACC_MPIO)) ) ) { - - failure_mssg = - "Bad param(s) on entry to open_hdf5_file().\n"; + if ((create_file && mdci_sbem_expected) || (create_file && read_only) || + (config_fsm && !create_file) || (create_file && enable_page_buffer && !config_fsm) || + (hdf_file_name == NULL) || ((set_mdci_fapl) && (cache_image_flags == 0)) || + ((set_mdci_fapl) && ((cache_image_flags & ~H5C_CI__ALL_FLAGS) != 0)) || (file_id_ptr == NULL) || + (file_ptr_ptr == NULL) || (cache_ptr_ptr == NULL) || + (l_facc_type != (l_facc_type & (FACC_MPIO)))) { + + failure_mssg = "Bad param(s) on entry to open_hdf5_file().\n"; pass = FALSE; - } else if ( verbose ) { + } + else if (verbose) { - HDfprintf(stdout, "%s: HDF file name = \"%s\".\n", - fcn_name, hdf_file_name); + HDfprintf(stdout, "%s: HDF file name = \"%s\".\n", fcn_name, hdf_file_name); } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* create a file access propertly list. */ - if ( pass ) { + if (pass) { fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if ( fapl_id < 0 ) { + if (fapl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* call H5Pset_libver_bounds() on the fapl_id */ - if ( pass ) { + if (pass) { - if ( H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) - < 0 ) { + if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_libver_bounds() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* get metadata cache image config -- verify that it is the default */ - if ( pass ) { + if (pass) { result = H5Pget_mdc_image_config(fapl_id, &cache_image_config); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_image_config() failed.\n"; } - if ( ( cache_image_config.version != - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || - ( cache_image_config.generate_image != FALSE ) || - ( cache_image_config.save_resize_status != FALSE ) || - ( cache_image_config.entry_ageout != - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) ) { + if ((cache_image_config.version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) || + (cache_image_config.generate_image != FALSE) || + (cache_image_config.save_resize_status != FALSE) || + (cache_image_config.entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected default cache image config.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* set metadata cache image fapl entry if indicated */ - if ( ( pass ) && ( set_mdci_fapl ) ) { + if ((pass) && (set_mdci_fapl)) { /* set cache image config fields to taste */ - cache_image_config.generate_image = TRUE; + cache_image_config.generate_image = TRUE; cache_image_config.save_resize_status = FALSE; - cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; + cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; result = H5Pset_mdc_image_config(fapl_id, &cache_image_config); - if ( result < 0 ) { + if (result < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_image_config() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the persistant free space manager if indicated */ - if ( ( pass ) && ( config_fsm ) ) { + if ((pass) && (config_fsm)) { - fcpl_id = H5Pcreate(H5P_FILE_CREATE); + fcpl_id = H5Pcreate(H5P_FILE_CREATE); - if ( fcpl_id <= 0 ) { + if (fcpl_id <= 0) { - pass = FALSE; - failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed."; - } + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed."; + } } - if ( ( pass ) && ( config_fsm ) ) { + if ((pass) && (config_fsm)) { - if ( H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, - TRUE, (hsize_t)1) == FAIL ) { - pass = FALSE; + if (H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) == FAIL) { + pass = FALSE; failure_mssg = "H5Pset_file_space_strategy() failed.\n"; } } - if ( ( pass ) && ( config_fsm ) ) { + if ((pass) && (config_fsm)) { - if ( H5Pset_file_space_page_size(fcpl_id, PAGE_SIZE) == FAIL ) { + if (H5Pset_file_space_page_size(fcpl_id, PAGE_SIZE) == FAIL) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_file_space_page_size() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the page buffer if indicated */ - if ( ( pass ) && ( enable_page_buffer ) ) { + if ((pass) && (enable_page_buffer)) { - if ( H5Pset_page_buffer_size(fapl_id, PB_SIZE, 0, 0) < 0 ) { + if (H5Pset_page_buffer_size(fapl_id, PB_SIZE, 0, 0) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_page_buffer_size() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - - if ( ( pass ) && ( l_facc_type == FACC_MPIO ) ) { + if ((pass) && (l_facc_type == FACC_MPIO)) { /* set Parallel access with communicator */ - if ( H5Pset_fapl_mpio(fapl_id, comm, info) < 0 ) { + if (H5Pset_fapl_mpio(fapl_id, comm, info) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_fapl_mpio() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( ( pass ) && ( l_facc_type == FACC_MPIO ) ) { + if ((pass) && (l_facc_type == FACC_MPIO)) { if (H5Pset_all_coll_metadata_ops(fapl_id, all_coll_metadata_ops) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_all_coll_metadata_ops() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( ( pass ) && ( l_facc_type == FACC_MPIO ) ) { + if ((pass) && (l_facc_type == FACC_MPIO)) { - if ( H5Pset_coll_metadata_write(fapl_id, coll_metadata_write) < 0 ) { + if (H5Pset_coll_metadata_write(fapl_id, coll_metadata_write) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_coll_metadata_write() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( ( pass ) && ( l_facc_type == FACC_MPIO ) ) { + if ((pass) && (l_facc_type == FACC_MPIO)) { /* set the desired parallel metadata write strategy */ H5AC_cache_config_t mdc_config; mdc_config.version = H5C__CURR_AUTO_SIZE_CTL_VER; - if ( H5Pget_mdc_config(fapl_id, &mdc_config) < 0 ) { + if (H5Pget_mdc_config(fapl_id, &mdc_config) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pget_mdc_config() failed.\n"; } mdc_config.metadata_write_strategy = md_write_strat; - if ( H5Pset_mdc_config(fapl_id, &mdc_config) < 0 ) { + if (H5Pset_mdc_config(fapl_id, &mdc_config) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_mdc_config() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* open the file */ - if ( pass ) { + if (pass) { - if ( create_file ) { + if (create_file) { - if ( fcpl_id != -1 ) + if (fcpl_id != -1) - file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, - fcpl_id, fapl_id); - else - - file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, - H5P_DEFAULT, fapl_id); + file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, fcpl_id, fapl_id); + else - } else { + file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + } + else { - if ( read_only ) + if (read_only) file_id = H5Fopen(hdf_file_name, H5F_ACC_RDONLY, fapl_id); @@ -1180,74 +1089,71 @@ open_hdf5_file(const hbool_t create_file, file_id = H5Fopen(hdf_file_name, H5F_ACC_RDWR, fapl_id); } - if ( file_id < 0 ) { + if (file_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fcreate() or H5Fopen() failed.\n"; - - } else { + } + else { file_ptr = (struct H5F_t *)H5VL_object_verify(file_id, H5I_FILE); - if ( file_ptr == NULL ) { + if (file_ptr == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "Can't get file_ptr."; - if ( verbose ) { + if (verbose) { HDfprintf(stdout, "%s: Can't get file_ptr.\n", fcn_name); } } } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* get a pointer to the files internal data structure and then * to the cache structure */ - if ( pass ) { + if (pass) { - if ( file_ptr->shared->cache == NULL ) { + if (file_ptr->shared->cache == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "can't get cache pointer(1).\n"; - - } else { + } + else { cache_ptr = file_ptr->shared->cache; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* verify expected page buffer status. At present, page buffering * must be disabled in parallel -- hopefully this will change in the * future. */ - if ( pass ) { + if (pass) { - if ( ( file_ptr->shared->page_buf ) && - ( ( ! enable_page_buffer ) || ( l_facc_type == FACC_MPIO ) ) ) { + if ((file_ptr->shared->page_buf) && ((!enable_page_buffer) || (l_facc_type == FACC_MPIO))) { - pass = FALSE; + pass = FALSE; failure_mssg = "page buffer unexepectedly enabled."; + } + else if ((file_ptr->shared->page_buf != NULL) && + ((enable_page_buffer) || (l_facc_type != FACC_MPIO))) { - } else if ( ( file_ptr->shared->page_buf != NULL ) && - ( ( enable_page_buffer ) || ( l_facc_type != FACC_MPIO ) ) ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "page buffer unexepectedly disabled."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* verify expected metadata cache status */ /* get the cache image control structure from the cache, and verify @@ -1255,145 +1161,133 @@ open_hdf5_file(const hbool_t create_file, * * Then set the flags in this structure to the specified value. */ - if ( pass ) { + if (pass) { - if ( H5C_get_cache_image_config(cache_ptr, &image_ctl) < 0 ) { + if (H5C_get_cache_image_config(cache_ptr, &image_ctl) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "error returned by H5C_get_cache_image_config()."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + if (pass) { - if ( pass ) { - - if ( set_mdci_fapl ) { + if (set_mdci_fapl) { - if ( read_only ) { + if (read_only) { - if ( ( image_ctl.version != - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || - ( image_ctl.generate_image != FALSE ) || - ( image_ctl.save_resize_status != FALSE ) || - ( image_ctl.entry_ageout != - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || - ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + if ((image_ctl.version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) || + (image_ctl.generate_image != FALSE) || (image_ctl.save_resize_status != FALSE) || + (image_ctl.entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) || + (image_ctl.flags != H5C_CI__ALL_FLAGS)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected image_ctl values(1).\n"; } - } else { + } + else { - if ( ( image_ctl.version != - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || - ( image_ctl.generate_image != TRUE ) || - ( image_ctl.save_resize_status != FALSE ) || - ( image_ctl.entry_ageout != - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || - ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + if ((image_ctl.version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) || + (image_ctl.generate_image != TRUE) || (image_ctl.save_resize_status != FALSE) || + (image_ctl.entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) || + (image_ctl.flags != H5C_CI__ALL_FLAGS)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected image_ctl values(2).\n"; } } - } else { + } + else { - if ( ( image_ctl.version != - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) || - ( image_ctl.generate_image != FALSE ) || - ( image_ctl.save_resize_status != FALSE ) || - ( image_ctl.entry_ageout != - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) || - ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) { + if ((image_ctl.version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) || + (image_ctl.generate_image != FALSE) || (image_ctl.save_resize_status != FALSE) || + (image_ctl.entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) || + (image_ctl.flags != H5C_CI__ALL_FLAGS)) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected image_ctl values(3).\n"; } } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( ( pass ) && ( set_mdci_fapl ) ) { + if ((pass) && (set_mdci_fapl)) { image_ctl.flags = cache_image_flags; - if ( H5C_set_cache_image_config(file_ptr, cache_ptr, &image_ctl) < 0 ) { + if (H5C_set_cache_image_config(file_ptr, cache_ptr, &image_ctl) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "error returned by H5C_set_cache_image_config()."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { - if ( cache_ptr->close_warning_received == TRUE ) { + if (cache_ptr->close_warning_received == TRUE) { - pass = FALSE; + pass = FALSE; failure_mssg = "Unexpected value of close_warning_received.\n"; } - if ( mdci_sbem_expected ) { + if (mdci_sbem_expected) { - if ( read_only ) { + if (read_only) { - if ( ( cache_ptr->load_image != TRUE ) || - ( cache_ptr->delete_image != FALSE ) ) { + if ((cache_ptr->load_image != TRUE) || (cache_ptr->delete_image != FALSE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "mdci sb extension message not present?\n"; } - } else { + } + else { - if ( ( cache_ptr->load_image != TRUE ) || - ( cache_ptr->delete_image != TRUE ) ) { + if ((cache_ptr->load_image != TRUE) || (cache_ptr->delete_image != TRUE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "mdci sb extension message not present?\n"; } + } } - } else { + else { - if ( ( cache_ptr->load_image == TRUE ) || - ( cache_ptr->delete_image == TRUE ) ) { + if ((cache_ptr->load_image == TRUE) || (cache_ptr->delete_image == TRUE)) { - pass = FALSE; + pass = FALSE; failure_mssg = "mdci sb extension message present?\n"; - } + } } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { - *file_id_ptr = file_id; - *file_ptr_ptr = file_ptr; + *file_id_ptr = file_id; + *file_ptr_ptr = file_ptr; *cache_ptr_ptr = cache_ptr; } - if ( show_progress ) { - HDfprintf(stdout, "%s: cp = %d, pass = %d -- exiting.\n", - fcn_name, cp++, pass); + if (show_progress) { + HDfprintf(stdout, "%s: cp = %d, pass = %d -- exiting.\n", fcn_name, cp++, pass); - if ( ! pass ) - HDfprintf(stdout, "%s: failure_mssg = %s\n", - fcn_name, failure_mssg); + if (!pass) + HDfprintf(stdout, "%s: failure_mssg = %s\n", fcn_name, failure_mssg); } return; } /* open_hdf5_file() */ - /*------------------------------------------------------------------------- * Function: par_create_dataset() * @@ -1418,252 +1312,236 @@ open_hdf5_file(const hbool_t create_file, */ static void -par_create_dataset(int dset_num, - hid_t file_id, - int mpi_rank, - int mpi_size) +par_create_dataset(int dset_num, hid_t file_id, int mpi_rank, int mpi_size) { - const char * fcn_name = "par_create_dataset()"; - char dset_name[256]; - hbool_t show_progress = FALSE; - hbool_t valid_chunk; - hbool_t verbose = FALSE; - int cp = 0; - int i, j, k, l; - int data_chunk[1][CHUNK_SIZE][CHUNK_SIZE]; - hsize_t dims[3]; - hsize_t a_size[3]; - hsize_t offset[3]; - hsize_t chunk_size[3]; - hid_t status; - hid_t dataspace_id = -1; - hid_t memspace_id = -1; - hid_t dset_id = -1; - hid_t filespace_id = -1; - hid_t dcpl_id = -1; - hid_t dxpl_id = -1; + const char *fcn_name = "par_create_dataset()"; + char dset_name[256]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l; + int data_chunk[1][CHUNK_SIZE][CHUNK_SIZE]; + hsize_t dims[3]; + hsize_t a_size[3]; + hsize_t offset[3]; + hsize_t chunk_size[3]; + hid_t status; + hid_t dataspace_id = -1; + hid_t memspace_id = -1; + hid_t dset_id = -1; + hid_t filespace_id = -1; + hid_t dcpl_id = -1; + hid_t dxpl_id = -1; show_progress = (show_progress && (mpi_rank == 0)); verbose = (verbose && (mpi_rank == 0)); HDsprintf(dset_name, "/dset%03d", dset_num); - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: dset name = \"%s\".\n", fcn_name, dset_name); HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); } - if ( pass ) { + if (pass) { /* create a dataspace for the chunked dataset */ - dims[0] = (hsize_t)mpi_size; - dims[1] = DSET_SIZE; - dims[2] = DSET_SIZE; + dims[0] = (hsize_t)mpi_size; + dims[1] = DSET_SIZE; + dims[2] = DSET_SIZE; dataspace_id = H5Screate_simple(3, dims, NULL); - if ( dataspace_id < 0 ) { + if (dataspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* set the dataset creation plist to specify that the raw data is * to be partioned into 1X10X10 element chunks. */ - if ( pass ) { + if (pass) { dcpl_id = H5Pcreate(H5P_DATASET_CREATE); - if ( dcpl_id < 0 ) { + if (dcpl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate(H5P_DATASET_CREATE) failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { chunk_size[0] = 1; chunk_size[1] = CHUNK_SIZE; chunk_size[2] = CHUNK_SIZE; - if ( H5Pset_chunk(dcpl_id, 3, chunk_size) < 0 ) { + if (H5Pset_chunk(dcpl_id, 3, chunk_size) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_chunk() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* create the dataset */ - if ( pass ) { + if (pass) { - dset_id = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, - dataspace_id, H5P_DEFAULT, - dcpl_id, H5P_DEFAULT); + dset_id = + H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); - if ( dset_id < 0 ) { + if (dset_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dcreate() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* get the file space ID */ - if ( pass ) { + if (pass) { filespace_id = H5Dget_space(dset_id); - if ( filespace_id < 0 ) { + if (filespace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dget_space() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* create the mem space to be used to read and write chunks */ - if ( pass ) { + if (pass) { - dims[0] = 1; - dims[1] = CHUNK_SIZE; - dims[2] = CHUNK_SIZE; + dims[0] = 1; + dims[1] = CHUNK_SIZE; + dims[2] = CHUNK_SIZE; memspace_id = H5Screate_simple(3, dims, NULL); - if ( memspace_id < 0 ) { + if (memspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* select in memory hyperslab */ - if ( pass ) { + if (pass) { - offset[0] = 0; /* offset of hyperslab in memory */ + offset[0] = 0; /* offset of hyperslab in memory */ offset[1] = 0; offset[2] = 0; - a_size[0] = 1; /* size of hyperslab */ + a_size[0] = 1; /* size of hyperslab */ a_size[1] = CHUNK_SIZE; a_size[2] = CHUNK_SIZE; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, - a_size, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the DXPL for collective I/O */ - if ( pass ) { + if (pass) { dxpl_id = H5Pcreate(H5P_DATASET_XFER); - if ( dxpl_id < 0 ) { + if (dxpl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate(H5P_DATASET_XFER) failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { - if ( H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0 ) { + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_dxpl_mpio() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* initialize the dataset with collective writes */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { - if ( show_progress ) - HDfprintf(stdout, "%s: cp = %d.0, pass = %d.\n", - fcn_name, cp, pass); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.0, pass = %d.\n", fcn_name, cp, pass); /* initialize the slab */ - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - data_chunk[0][k][l] = (DSET_SIZE * DSET_SIZE * mpi_rank) + - (DSET_SIZE * (i + k)) + j + l + - dset_num; + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + data_chunk[0][k][l] = + (DSET_SIZE * DSET_SIZE * mpi_rank) + (DSET_SIZE * (i + k)) + j + l + dset_num; } } - if ( show_progress ) - HDfprintf(stdout, "%s: cp = %d.1, pass = %d.\n", - fcn_name, cp, pass); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.1, pass = %d.\n", fcn_name, cp, pass); /* select on disk hyperslab */ offset[0] = (hsize_t)mpi_rank; /* offset of hyperslab in file */ offset[1] = (hsize_t)i; offset[2] = (hsize_t)j; - a_size[0] = (hsize_t)1; /* size of hyperslab */ + a_size[0] = (hsize_t)1; /* size of hyperslab */ a_size[1] = CHUNK_SIZE; a_size[2] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "disk H5Sselect_hyperslab() failed."; } - if ( show_progress ) - HDfprintf(stdout, "%s: cp = %d.2, pass = %d.\n", - fcn_name, cp, pass); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.2, pass = %d.\n", fcn_name, cp, pass); /* write the chunk to file */ - status = H5Dwrite(dset_id, H5T_NATIVE_INT, memspace_id, - filespace_id, dxpl_id, data_chunk); + status = H5Dwrite(dset_id, H5T_NATIVE_INT, memspace_id, filespace_id, dxpl_id, data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dwrite() failed."; } - if ( show_progress ) - HDfprintf(stdout, "%s: cp = %d.3, pass = %d.\n", - fcn_name, cp, pass); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.3, pass = %d.\n", fcn_name, cp, pass); j += CHUNK_SIZE; } @@ -1672,16 +1550,14 @@ par_create_dataset(int dset_num, } cp++; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* read data from data sets and validate it */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { /* select on disk hyperslab */ offset[0] = (hsize_t)mpi_rank; offset[1] = (hsize_t)i; /* offset of hyperslab in file */ @@ -1690,69 +1566,58 @@ par_create_dataset(int dset_num, a_size[1] = CHUNK_SIZE; /* size of hyperslab */ a_size[2] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dset_id, H5T_NATIVE_INT, - memspace_id, filespace_id, - dxpl_id, data_chunk); + status = H5Dread(dset_id, H5T_NATIVE_INT, memspace_id, filespace_id, dxpl_id, data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "chunk read failed."; + pass = FALSE; + failure_mssg = "chunk read failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - if ( data_chunk[0][k][l] - != - ((DSET_SIZE * DSET_SIZE * mpi_rank) + - (DSET_SIZE * (i + k)) + j + l + dset_num) ) { + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + if (data_chunk[0][k][l] != + ((DSET_SIZE * DSET_SIZE * mpi_rank) + (DSET_SIZE * (i + k)) + j + l + dset_num)) { valid_chunk = FALSE; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "data_chunk[%0d][%0d] = %0d, expect %0d.\n", - k, l, data_chunk[0][k][l], - ((DSET_SIZE * DSET_SIZE * mpi_rank) + - (DSET_SIZE * (i + k)) + j + l + dset_num)); - HDfprintf(stdout, - "dset_num = %d, i = %d, j = %d, k = %d, l = %d\n", - dset_num, i, j, k, l); + HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", k, l, + data_chunk[0][k][l], + ((DSET_SIZE * DSET_SIZE * mpi_rank) + (DSET_SIZE * (i + k)) + j + + l + dset_num)); + HDfprintf(stdout, "dset_num = %d, i = %d, j = %d, k = %d, l = %d\n", dset_num, + i, j, k, l); } } } } - if ( ! valid_chunk ) { + if (!valid_chunk) { - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "Chunk (%0d, %0d) in /dset%03d is invalid.\n", - i, j, dset_num); + HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", i, j, dset_num); } } } @@ -1761,59 +1626,58 @@ par_create_dataset(int dset_num, i += CHUNK_SIZE; } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* close the data space */ - if ( ( pass ) && ( H5Sclose(dataspace_id) < 0 ) ) { + if ((pass) && (H5Sclose(dataspace_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(dataspace_id) failed."; } /* close the file space */ - if ( ( pass ) && ( H5Sclose(filespace_id) < 0 ) ) { + if ((pass) && (H5Sclose(filespace_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(filespace_id) failed."; } /* close the dataset */ - if ( ( pass ) && ( H5Dclose(dset_id) < 0 ) ) { + if ((pass) && (H5Dclose(dset_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose(dset_id) failed."; } /* close the mem space */ - if ( ( pass ) && ( H5Sclose(memspace_id) < 0 ) ) { + if ((pass) && (H5Sclose(memspace_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(memspace_id) failed."; } /* close the dataset creation property list */ - if ( ( pass ) && ( H5Pclose(dcpl_id) < 0 ) ) { + if ((pass) && (H5Pclose(dcpl_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pclose(dcpl) failed."; } /* close the data access property list */ - if ( ( pass ) && ( H5Pclose(dxpl_id) < 0 ) ) { + if ((pass) && (H5Pclose(dxpl_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pclose(dxpl) failed."; } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); return; } /* par_create_dataset() */ - /*------------------------------------------------------------------------- * Function: par_delete_dataset() * @@ -1837,51 +1701,48 @@ par_create_dataset(int dset_num, */ static void -par_delete_dataset(int dset_num, - hid_t file_id, - int mpi_rank) +par_delete_dataset(int dset_num, hid_t file_id, int mpi_rank) { - const char * fcn_name = "par_delete_dataset()"; - char dset_name[256]; - hbool_t show_progress = FALSE; - int cp = 0; + const char *fcn_name = "par_delete_dataset()"; + char dset_name[256]; + hbool_t show_progress = FALSE; + int cp = 0; show_progress = (show_progress && (mpi_rank == 0)); HDsprintf(dset_name, "/dset%03d", dset_num); - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: dset name = \"%s\".\n", fcn_name, dset_name); HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); } /* verify the target dataset */ - if ( pass ) { + if (pass) { par_verify_dataset(dset_num, file_id, mpi_rank); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* delete the target dataset */ - if ( pass ) { + if (pass) { - if ( H5Ldelete(file_id, dset_name, H5P_DEFAULT) < 0) { + if (H5Ldelete(file_id, dset_name, H5P_DEFAULT) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Ldelete() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); return; } /* par_delete_dataset() */ - /* This test uses many POSIX things that are not available on * Windows. We're using a check for fork(2) here as a proxy for * all POSIX/Unix/Linux things until this test can be made @@ -1889,7 +1750,6 @@ par_delete_dataset(int dset_num, */ #ifdef H5_HAVE_FORK - /*------------------------------------------------------------------------- * Function: par_insert_cache_image() * @@ -1919,17 +1779,17 @@ par_delete_dataset(int dset_num, */ static void -par_insert_cache_image(int file_name_idx, int mpi_rank, int mpi_size ) +par_insert_cache_image(int file_name_idx, int mpi_rank, int mpi_size) { hbool_t show_progress = FALSE; - if ( pass ) { + if (pass) { - if ( mpi_rank == 0 ) { /* insert cache image in supplied test file */ + if (mpi_rank == 0) { /* insert cache image in supplied test file */ - char file_name_idx_str[32]; - char mpi_size_str[32]; - int child_status; + char file_name_idx_str[32]; + char mpi_size_str[32]; + int child_status; pid_t child_pid; HDsprintf(file_name_idx_str, "%d", file_name_idx); @@ -1937,57 +1797,52 @@ par_insert_cache_image(int file_name_idx, int mpi_rank, int mpi_size ) child_pid = fork(); - if ( child_pid == 0 ) { /* this is the child process */ + if (child_pid == 0) { /* this is the child process */ /* fun and games to shutup the compiler */ - char param0[32] = "t_cache_image"; - char param1[32] = "ici"; - char * child_argv[] = {param0, - param1, - file_name_idx_str, - mpi_size_str, - NULL}; + char param0[32] = "t_cache_image"; + char param1[32] = "ici"; + char *child_argv[] = {param0, param1, file_name_idx_str, mpi_size_str, NULL}; /* we may need to play with the path here */ - if ( execv("t_cache_image", child_argv) == -1 ) { + if (execv("t_cache_image", child_argv) == -1) { - HDfprintf(stdout, - "execl() of ici process failed. errno = %d(%s)\n", - errno, strerror(errno)); + HDfprintf(stdout, "execl() of ici process failed. errno = %d(%s)\n", errno, + strerror(errno)); HDexit(1); } - - } else if ( child_pid != -1 ) { + } + else if (child_pid != -1) { /* this is the parent process -- wait until child is done */ - if ( -1 == waitpid(child_pid, &child_status, WUNTRACED)) { + if (-1 == waitpid(child_pid, &child_status, WUNTRACED)) { HDfprintf(stdout, "can't wait on ici process.\n"); pass = FALSE; - - } else if ( ! WIFEXITED(child_status) ) { + } + else if (!WIFEXITED(child_status)) { HDfprintf(stdout, "ici process hasn't exitied.\n"); pass = FALSE; - - } else if ( WEXITSTATUS(child_status) != 0 ) { + } + else if (WEXITSTATUS(child_status) != 0) { HDfprintf(stdout, "ici process reports failure.\n"); pass = FALSE; - - } else if ( show_progress ) { + } + else if (show_progress) { HDfprintf(stdout, "cache image insertion complete.\n"); } - } else { /* fork failed */ + } + else { /* fork failed */ - HDfprintf(stdout, - "can't create process to insert cache image.\n"); + HDfprintf(stdout, "can't create process to insert cache image.\n"); pass = FALSE; } } } - if ( pass ) { + if (pass) { /* make sure insertion of the cache image is complete * before proceeding @@ -2001,14 +1856,13 @@ par_insert_cache_image(int file_name_idx, int mpi_rank, int mpi_size ) #else /* H5_HAVE_FORK */ static void -par_insert_cache_image(int file_name_idx, int mpi_rank, int mpi_size ) +par_insert_cache_image(int file_name_idx, int mpi_rank, int mpi_size) { return; } /* par_insert_cache_image() */ #endif /* H5_HAVE_FORK */ - /*------------------------------------------------------------------------- * Function: par_verify_dataset() * @@ -2032,139 +1886,134 @@ par_insert_cache_image(int file_name_idx, int mpi_rank, int mpi_size ) */ static void -par_verify_dataset(int dset_num, - hid_t file_id, - int mpi_rank) +par_verify_dataset(int dset_num, hid_t file_id, int mpi_rank) { - const char * fcn_name = "par_verify_dataset()"; - char dset_name[256]; - hbool_t show_progress = FALSE; - hbool_t valid_chunk; - hbool_t verbose = FALSE; - int cp = 0; - int i, j, k, l; - int data_chunk[1][CHUNK_SIZE][CHUNK_SIZE]; - hsize_t dims[3]; - hsize_t a_size[3]; - hsize_t offset[3]; - hid_t status; - hid_t memspace_id = -1; - hid_t dset_id = -1; - hid_t filespace_id = -1; - hid_t dxpl_id = -1; + const char *fcn_name = "par_verify_dataset()"; + char dset_name[256]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l; + int data_chunk[1][CHUNK_SIZE][CHUNK_SIZE]; + hsize_t dims[3]; + hsize_t a_size[3]; + hsize_t offset[3]; + hid_t status; + hid_t memspace_id = -1; + hid_t dset_id = -1; + hid_t filespace_id = -1; + hid_t dxpl_id = -1; show_progress = (show_progress && (mpi_rank == 0)); verbose = (verbose && (mpi_rank == 0)); HDsprintf(dset_name, "/dset%03d", dset_num); - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: dset name = \"%s\".\n", fcn_name, dset_name); HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); } - if ( pass ) { + if (pass) { /* open the dataset */ dset_id = H5Dopen2(file_id, dset_name, H5P_DEFAULT); - if ( dset_id < 0 ) { + if (dset_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dopen2() failed."; } } /* get the file space ID */ - if ( pass ) { + if (pass) { filespace_id = H5Dget_space(dset_id); - if ( filespace_id < 0 ) { + if (filespace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dget_space() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* create the mem space to be used to read */ - if ( pass ) { + if (pass) { - dims[0] = 1; - dims[1] = CHUNK_SIZE; - dims[2] = CHUNK_SIZE; + dims[0] = 1; + dims[1] = CHUNK_SIZE; + dims[2] = CHUNK_SIZE; memspace_id = H5Screate_simple(3, dims, NULL); - if ( memspace_id < 0 ) { + if (memspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* select in memory hyperslab */ - if ( pass ) { + if (pass) { - offset[0] = 0; /* offset of hyperslab in memory */ + offset[0] = 0; /* offset of hyperslab in memory */ offset[1] = 0; offset[2] = 0; - a_size[0] = 1; /* size of hyperslab */ + a_size[0] = 1; /* size of hyperslab */ a_size[1] = CHUNK_SIZE; a_size[2] = CHUNK_SIZE; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, - a_size, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the DXPL for collective I/O */ - if ( pass ) { + if (pass) { dxpl_id = H5Pcreate(H5P_DATASET_XFER); - if ( dxpl_id < 0 ) { + if (dxpl_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pcreate(H5P_DATASET_XFER) failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - if ( pass ) { + if (pass) { - if ( H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0 ) { + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pset_dxpl_mpio() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* read data from data sets and validate it */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { /* select on disk hyperslab */ offset[0] = (hsize_t)mpi_rank; offset[1] = (hsize_t)i; /* offset of hyperslab in file */ @@ -2173,69 +2022,58 @@ par_verify_dataset(int dset_num, a_size[1] = CHUNK_SIZE; /* size of hyperslab */ a_size[2] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dset_id, H5T_NATIVE_INT, - memspace_id, filespace_id, - dxpl_id, data_chunk); + status = H5Dread(dset_id, H5T_NATIVE_INT, memspace_id, filespace_id, dxpl_id, data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "chunk read failed."; + pass = FALSE; + failure_mssg = "chunk read failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - if ( data_chunk[0][k][l] - != - ((DSET_SIZE * DSET_SIZE * mpi_rank) + - (DSET_SIZE * (i + k)) + j + l + dset_num) ) { + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + if (data_chunk[0][k][l] != + ((DSET_SIZE * DSET_SIZE * mpi_rank) + (DSET_SIZE * (i + k)) + j + l + dset_num)) { valid_chunk = FALSE; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "data_chunk[%0d][%0d] = %0d, expect %0d.\n", - k, l, data_chunk[0][k][l], - ((DSET_SIZE * DSET_SIZE * mpi_rank) + - (DSET_SIZE * (i + k)) + j + l + dset_num)); - HDfprintf(stdout, - "dset_num = %d, i = %d, j = %d, k = %d, l = %d\n", - dset_num, i, j, k, l); + HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", k, l, + data_chunk[0][k][l], + ((DSET_SIZE * DSET_SIZE * mpi_rank) + (DSET_SIZE * (i + k)) + j + + l + dset_num)); + HDfprintf(stdout, "dset_num = %d, i = %d, j = %d, k = %d, l = %d\n", dset_num, + i, j, k, l); } } } } - if ( ! valid_chunk ) { + if (!valid_chunk) { - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "Chunk (%0d, %0d) in /dset%03d is invalid.\n", - i, j, dset_num); + HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", i, j, dset_num); } } } @@ -2244,45 +2082,44 @@ par_verify_dataset(int dset_num, i += CHUNK_SIZE; } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* close the file space */ - if ( ( pass ) && ( H5Sclose(filespace_id) < 0 ) ) { + if ((pass) && (H5Sclose(filespace_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(filespace_id) failed."; } /* close the dataset */ - if ( ( pass ) && ( H5Dclose(dset_id) < 0 ) ) { + if ((pass) && (H5Dclose(dset_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose(dset_id) failed."; } /* close the mem space */ - if ( ( pass ) && ( H5Sclose(memspace_id) < 0 ) ) { + if ((pass) && (H5Sclose(memspace_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(memspace_id) failed."; } /* close the data access property list */ - if ( ( pass ) && ( H5Pclose(dxpl_id) < 0 ) ) { + if ((pass) && (H5Pclose(dxpl_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Pclose(dxpl) failed."; } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); return; } /* par_verify_dataset() */ - /*------------------------------------------------------------------------- * Function: serial_insert_cache_image() * @@ -2307,48 +2144,44 @@ par_verify_dataset(int dset_num, */ static hbool_t -serial_insert_cache_image(int file_name_idx, int mpi_size ) +serial_insert_cache_image(int file_name_idx, int mpi_size) { - const char * fcn_name = "serial_insert_cache_image()"; - char filename[512]; - hbool_t show_progress = FALSE; - int cp = 0; - int i; - int num_dsets = PAR_NUM_DSETS; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - MPI_Comm dummy_comm = MPI_COMM_WORLD; - MPI_Info dummy_info = MPI_INFO_NULL; + const char *fcn_name = "serial_insert_cache_image()"; + char filename[512]; + hbool_t show_progress = FALSE; + int cp = 0; + int i; + int num_dsets = PAR_NUM_DSETS; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + MPI_Comm dummy_comm = MPI_COMM_WORLD; + MPI_Info dummy_info = MPI_INFO_NULL; pass = TRUE; - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) setup the file name */ - if ( pass ) { + if (pass) { HDassert(FILENAMES[file_name_idx]); - if ( h5_fixname(FILENAMES[file_name_idx], H5P_DEFAULT, - filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[file_name_idx], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { pass = FALSE; HDfprintf(stdout, "h5_fixname() failed.\n"); } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Open the PHDF5 file with the cache image FAPL entry. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ FALSE, @@ -2369,42 +2202,39 @@ serial_insert_cache_image(int file_name_idx, int mpi_size ) /* md_write_strat */ 1); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Validate contents of the file */ i = 0; - while ( ( pass ) && ( i < num_dsets ) ) { + while ((pass) && (i < num_dsets)) { serial_verify_dataset(i, file_id, mpi_size); i++; } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Close the file */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); return pass; } /* serial_insert_cache_image() */ - /*------------------------------------------------------------------------- * Function: serial_verify_dataset() * @@ -2428,112 +2258,105 @@ serial_insert_cache_image(int file_name_idx, int mpi_size ) */ static void -serial_verify_dataset(int dset_num, - hid_t file_id, - int mpi_size) +serial_verify_dataset(int dset_num, hid_t file_id, int mpi_size) { - const char * fcn_name = "serial_verify_dataset()"; - char dset_name[256]; - hbool_t show_progress = FALSE; - hbool_t valid_chunk; - hbool_t verbose = FALSE; - int cp = 0; - int i, j, k, l, m; - int data_chunk[1][CHUNK_SIZE][CHUNK_SIZE]; - hsize_t dims[3]; - hsize_t a_size[3]; - hsize_t offset[3]; - hid_t status; - hid_t memspace_id = -1; - hid_t dset_id = -1; - hid_t filespace_id = -1; + const char *fcn_name = "serial_verify_dataset()"; + char dset_name[256]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l, m; + int data_chunk[1][CHUNK_SIZE][CHUNK_SIZE]; + hsize_t dims[3]; + hsize_t a_size[3]; + hsize_t offset[3]; + hid_t status; + hid_t memspace_id = -1; + hid_t dset_id = -1; + hid_t filespace_id = -1; HDsprintf(dset_name, "/dset%03d", dset_num); - if ( show_progress ) { + if (show_progress) { HDfprintf(stdout, "%s: dset name = \"%s\".\n", fcn_name, dset_name); HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); } - if ( pass ) { + if (pass) { /* open the dataset */ dset_id = H5Dopen2(file_id, dset_name, H5P_DEFAULT); - if ( dset_id < 0 ) { + if (dset_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dopen2() failed."; } } /* get the file space ID */ - if ( pass ) { + if (pass) { filespace_id = H5Dget_space(dset_id); - if ( filespace_id < 0 ) { + if (filespace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dget_space() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* create the mem space to be used to read */ - if ( pass ) { + if (pass) { - dims[0] = 1; - dims[1] = CHUNK_SIZE; - dims[2] = CHUNK_SIZE; + dims[0] = 1; + dims[1] = CHUNK_SIZE; + dims[2] = CHUNK_SIZE; memspace_id = H5Screate_simple(3, dims, NULL); - if ( memspace_id < 0 ) { + if (memspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* select in memory hyperslab */ - if ( pass ) { + if (pass) { - offset[0] = 0; /* offset of hyperslab in memory */ + offset[0] = 0; /* offset of hyperslab in memory */ offset[1] = 0; offset[2] = 0; - a_size[0] = 1; /* size of hyperslab */ + a_size[0] = 1; /* size of hyperslab */ a_size[1] = CHUNK_SIZE; a_size[2] = CHUNK_SIZE; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, - a_size, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed."; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* read data from data sets and validate it */ i = 0; - while ( ( pass ) && ( i < mpi_size ) ) - { + while ((pass) && (i < mpi_size)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { k = 0; - while ( ( pass ) && ( k < DSET_SIZE ) ) - { + while ((pass) && (k < DSET_SIZE)) { /* select on disk hyperslab */ offset[0] = (hsize_t)i; /* offset of hyperslab in file */ offset[1] = (hsize_t)j; /* offset of hyperslab in file */ @@ -2542,70 +2365,61 @@ serial_verify_dataset(int dset_num, a_size[1] = CHUNK_SIZE; /* size of hyperslab */ a_size[2] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dset_id, H5T_NATIVE_INT, - memspace_id, filespace_id, - H5P_DEFAULT, data_chunk); + status = + H5Dread(dset_id, H5T_NATIVE_INT, memspace_id, filespace_id, H5P_DEFAULT, data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "chunk read failed."; + pass = FALSE; + failure_mssg = "chunk read failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - for ( m = 0; m < CHUNK_SIZE; m++ ) - { - if ( data_chunk[0][l][m] - != - ((DSET_SIZE * DSET_SIZE * i) + - (DSET_SIZE * (j + l)) + k + m + dset_num) ) { + for (l = 0; l < CHUNK_SIZE; l++) { + for (m = 0; m < CHUNK_SIZE; m++) { + if (data_chunk[0][l][m] != + ((DSET_SIZE * DSET_SIZE * i) + (DSET_SIZE * (j + l)) + k + m + dset_num)) { valid_chunk = FALSE; - if ( verbose ) { + if (verbose) { + HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", j, k, + data_chunk[0][j][k], + ((DSET_SIZE * DSET_SIZE * i) + (DSET_SIZE * (j + l)) + k + m + + dset_num)); HDfprintf(stdout, - "data_chunk[%0d][%0d] = %0d, expect %0d.\n", - j, k, data_chunk[0][j][k], - ((DSET_SIZE * DSET_SIZE * i) + - (DSET_SIZE * (j + l)) + k + m + dset_num)); - HDfprintf(stdout, - "dset_num = %d, i = %d, j = %d, k = %d, l = %d, m = %d\n", - dset_num, i, j, k, l, m); + "dset_num = %d, i = %d, j = %d, k = %d, l = %d, m = %d\n", + dset_num, i, j, k, l, m); } } } } - if ( ! valid_chunk ) { + if (!valid_chunk) { - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "Chunk (%0d, %0d) in /dset%03d is invalid.\n", - j, k, dset_num); + HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", j, k, dset_num); } } } @@ -2616,39 +2430,37 @@ serial_verify_dataset(int dset_num, i++; } - - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* close the file space */ - if ( ( pass ) && ( H5Sclose(filespace_id) < 0 ) ) { + if ((pass) && (H5Sclose(filespace_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(filespace_id) failed."; } /* close the dataset */ - if ( ( pass ) && ( H5Dclose(dset_id) < 0 ) ) { + if ((pass) && (H5Dclose(dset_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose(dset_id) failed."; } /* close the mem space */ - if ( ( pass ) && ( H5Sclose(memspace_id) < 0 ) ) { + if ((pass) && (H5Sclose(memspace_id) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(memspace_id) failed."; } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); return; } /* serial_verify_dataset() */ - /*------------------------------------------------------------------------- * Function: parse_flags * @@ -2664,12 +2476,12 @@ serial_verify_dataset(int dset_num, *------------------------------------------------------------------------- */ static hbool_t -parse_flags(int argc, char * argv[], hbool_t * setup_ptr, - hbool_t * ici_ptr, int * file_idx_ptr, int * mpi_size_ptr, hbool_t display) +parse_flags(int argc, char *argv[], hbool_t *setup_ptr, hbool_t *ici_ptr, int *file_idx_ptr, + int *mpi_size_ptr, hbool_t display) { - const char * fcn_name = "parse_flags()"; - const char * (ops[]) = {"setup", "ici"}; - int success = TRUE; + const char *fcn_name = "parse_flags()"; + const char *(ops[]) = {"setup", "ici"}; + int success = TRUE; HDassert(setup_ptr); HDassert(*setup_ptr == FALSE); @@ -2678,73 +2490,67 @@ parse_flags(int argc, char * argv[], hbool_t * setup_ptr, HDassert(file_idx_ptr); HDassert(mpi_size_ptr); - if ( setup_ptr == NULL ) { + if (setup_ptr == NULL) { success = FALSE; HDfprintf(stdout, "%s: bad arg(s) on entry.\n", fcn_name); } - - if ( ( success ) && - ( ( argc != 1 ) && ( argc != 2 ) && ( argc != 4 ) ) ) { + if ((success) && ((argc != 1) && (argc != 2) && (argc != 4))) { success = FALSE; usage(); } + if ((success) && (argc >= 2)) { - if ( ( success ) && ( argc >= 2 ) ) { + if (strcmp(argv[1], ops[0]) == 0) { - if ( strcmp(argv[1], ops[0]) == 0 ) { - - if ( argc != 2 ) { + if (argc != 2) { success = FALSE; usage(); - - } else { + } + else { *setup_ptr = TRUE; - } - } else if ( strcmp(argv[1], ops[1]) == 0 ) { + } + else if (strcmp(argv[1], ops[1]) == 0) { - if ( argc != 4 ) { + if (argc != 4) { success = FALSE; usage(); + } + else { - } else { - - *ici_ptr = TRUE; + *ici_ptr = TRUE; *file_idx_ptr = atoi(argv[2]); *mpi_size_ptr = atoi(argv[3]); - } } } - if ( ( success ) && ( display ) ) { + if ((success) && (display)) { - if ( *setup_ptr ) + if (*setup_ptr) HDfprintf(stdout, "t_cache_image setup\n"); - else if ( *ici_ptr ) + else if (*ici_ptr) - HDfprintf(stdout, "t_cache_image ici %d %d\n", - *file_idx_ptr, *mpi_size_ptr); + HDfprintf(stdout, "t_cache_image ici %d %d\n", *file_idx_ptr, *mpi_size_ptr); else HDfprintf(stdout, "t_cache_image\n"); } - return(success); + return (success); } /* parse_flags() */ - /*------------------------------------------------------------------------- * Function: usage * @@ -2763,8 +2569,7 @@ parse_flags(int argc, char * argv[], hbool_t * setup_ptr, void usage(void) { - const char * s[] = - { + const char *s[] = { "\n", "t_cache_image:\n", "\n", @@ -2800,7 +2605,7 @@ usage(void) }; int i = 0; - while(s[i] != NULL) { + while (s[i] != NULL) { HDfprintf(stdout, "%s", s[i]); i++; } @@ -2808,7 +2613,6 @@ usage(void) return; } /* usage() */ - /*------------------------------------------------------------------------- * Function: verify_data_sets() * @@ -2843,23 +2647,24 @@ usage(void) static void verify_data_sets(hid_t file_id, int min_dset, int max_dset) { - const char * fcn_name = "verify_data_sets()"; - char dset_name[64]; - hbool_t show_progress = FALSE; - hbool_t valid_chunk; - hbool_t verbose = FALSE; - int cp = 0; - int i, j, k, l, m; - int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; - herr_t status; - hid_t filespace_ids[MAX_NUM_DSETS]; - hid_t memspace_id = -1; - hid_t dataset_ids[MAX_NUM_DSETS]; - hsize_t dims[2]; - hsize_t a_size[2]; - hsize_t offset[2]; - - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + const char *fcn_name = "verify_data_sets()"; + char dset_name[64]; + hbool_t show_progress = FALSE; + hbool_t valid_chunk; + hbool_t verbose = FALSE; + int cp = 0; + int i, j, k, l, m; + int data_chunk[CHUNK_SIZE][CHUNK_SIZE]; + herr_t status; + hid_t filespace_ids[MAX_NUM_DSETS]; + hid_t memspace_id = -1; + hid_t dataset_ids[MAX_NUM_DSETS]; + hsize_t dims[2]; + hsize_t a_size[2]; + hsize_t offset[2]; + + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); HDassert(0 <= min_dset); HDassert(min_dset <= max_dset); @@ -2867,33 +2672,32 @@ verify_data_sets(hid_t file_id, int min_dset, int max_dset) /* open the datasets */ - if ( pass ) { + if (pass) { i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { + while ((pass) && (i <= max_dset)) { /* open the dataset */ - if ( pass ) { + if (pass) { HDsprintf(dset_name, "/dset%03d", i); dataset_ids[i] = H5Dopen2(file_id, dset_name, H5P_DEFAULT); - if ( dataset_ids[i] < 0 ) { + if (dataset_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dopen2() failed."; } } /* get the file space ID */ - if ( pass ) { + if (pass) { filespace_ids[i] = H5Dget_space(dataset_ids[i]); - if ( filespace_ids[i] < 0 ) { + if (filespace_ids[i] < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dget_space() failed."; } } @@ -2902,124 +2706,111 @@ verify_data_sets(hid_t file_id, int min_dset, int max_dset) } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* create the mem space to be used to read and write chunks */ - if ( pass ) { + if (pass) { - dims[0] = CHUNK_SIZE; - dims[1] = CHUNK_SIZE; + dims[0] = CHUNK_SIZE; + dims[1] = CHUNK_SIZE; memspace_id = H5Screate_simple(2, dims, NULL); - if ( memspace_id < 0 ) { + if (memspace_id < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Screate_simple() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* select in memory hyperslab */ - if ( pass ) { + if (pass) { - offset[0] = 0; /*offset of hyperslab in memory*/ + offset[0] = 0; /*offset of hyperslab in memory*/ offset[1] = 0; - a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ + a_size[0] = CHUNK_SIZE; /*size of hyperslab*/ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, - a_size, NULL); + status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed."; } } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); - + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* read data from data sets and validate it */ i = 0; - while ( ( pass ) && ( i < DSET_SIZE ) ) - { + while ((pass) && (i < DSET_SIZE)) { j = 0; - while ( ( pass ) && ( j < DSET_SIZE ) ) - { + while ((pass) && (j < DSET_SIZE)) { m = min_dset; - while ( ( pass ) && ( m <= max_dset ) ) - { + while ((pass) && (m <= max_dset)) { /* select on disk hyperslab */ offset[0] = (hsize_t)i; /* offset of hyperslab in file */ offset[1] = (hsize_t)j; a_size[0] = CHUNK_SIZE; /* size of hyperslab */ a_size[1] = CHUNK_SIZE; - status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, - offset, NULL, a_size, NULL); + status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } /* read the chunk from file */ - if ( pass ) { + if (pass) { - status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, - memspace_id, filespace_ids[m], + status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT, data_chunk); - if ( status < 0 ) { + if (status < 0) { - pass = FALSE; - failure_mssg = "disk hyperslab create failed."; + pass = FALSE; + failure_mssg = "disk hyperslab create failed."; } } /* validate the slab */ - if ( pass ) { + if (pass) { valid_chunk = TRUE; - for ( k = 0; k < CHUNK_SIZE; k++ ) - { - for ( l = 0; l < CHUNK_SIZE; l++ ) - { - if ( data_chunk[k][l] - != - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l) ) { + for (k = 0; k < CHUNK_SIZE; k++) { + for (l = 0; l < CHUNK_SIZE; l++) { + if (data_chunk[k][l] != + ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)) { valid_chunk = FALSE; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "data_chunk[%0d][%0d] = %0d, expect %0d.\n", - k, l, data_chunk[k][l], - ((DSET_SIZE * DSET_SIZE * m) + - (DSET_SIZE * (i + k)) + j + l)); - HDfprintf(stdout, - "m = %d, i = %d, j = %d, k = %d, l = %d\n", - m, i, j, k, l); - } + HDfprintf(stdout, "data_chunk[%0d][%0d] = %0d, expect %0d.\n", k, l, + data_chunk[k][l], + ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)); + HDfprintf(stdout, "m = %d, i = %d, j = %d, k = %d, l = %d\n", m, i, j, k, + l); + } } } } - if ( ! valid_chunk ) { + if (!valid_chunk) { - pass = FALSE; + pass = FALSE; failure_mssg = "slab validation failed."; - if ( verbose ) { + if (verbose) { - HDfprintf(stdout, - "Chunk (%0d, %0d) in /dset%03d is invalid.\n", - i, j, m); - } + HDfprintf(stdout, "Chunk (%0d, %0d) in /dset%03d is invalid.\n", i, j, m); + } } } m++; @@ -3029,39 +2820,37 @@ verify_data_sets(hid_t file_id, int min_dset, int max_dset) i += CHUNK_SIZE; } - if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); + if (show_progress) + HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++); /* close the file spaces */ i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { - if ( H5Sclose(filespace_ids[i]) < 0 ) { + while ((pass) && (i <= max_dset)) { + if (H5Sclose(filespace_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose() failed."; } i++; } - /* close the datasets */ i = min_dset; - while ( ( pass ) && ( i <= max_dset ) ) - { - if ( H5Dclose(dataset_ids[i]) < 0 ) { + while ((pass) && (i <= max_dset)) { + if (H5Dclose(dataset_ids[i]) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Dclose() failed."; } i++; } /* close the mem space */ - if ( pass ) { + if (pass) { - if ( H5Sclose(memspace_id) < 0 ) { + if (H5Sclose(memspace_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Sclose(memspace_id) failed."; } } @@ -3070,7 +2859,6 @@ verify_data_sets(hid_t file_id, int min_dset, int max_dset) } /* verify_data_sets() */ - /****************************************************************************/ /******************************* Test Functions *****************************/ /****************************************************************************/ @@ -3120,19 +2908,19 @@ verify_data_sets(hid_t file_id, int min_dset, int max_dset) static unsigned verify_cache_image_RO(int file_name_id, int md_write_strat, int mpi_rank) { - const char * fcn_name = "verify_cache_image_RO()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "verify_cache_image_RO()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; pass = TRUE; - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { - switch(md_write_strat) { + switch (md_write_strat) { case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: TESTING("parallel CI load test -- proc0 md write -- R/O"); @@ -3149,39 +2937,36 @@ verify_cache_image_RO(int file_name_id, int md_write_strat, int mpi_rank) } } - show_progress = ( ( show_progress ) && ( mpi_rank == 0 ) ); + show_progress = ((show_progress) && (mpi_rank == 0)); - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[file_name_id], H5P_DEFAULT, - filename, sizeof(filename)) == NULL ) { + if (h5_fixname(FILENAMES[file_name_id], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Open the test file created at the beginning of this test. * * Verify that the file contains a cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, + /* config_fsm */ FALSE, /* enable_page_buffer */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, @@ -3196,10 +2981,9 @@ verify_cache_image_RO(int file_name_id, int md_write_strat, int mpi_rank) /* md_write_strat */ md_write_strat); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Verify that the file contains the expected data. * * Verify that only process 0 reads the cache image. @@ -3208,74 +2992,71 @@ verify_cache_image_RO(int file_name_id, int md_write_strat, int mpi_rank) * image block from process 0. */ - if ( pass ) { + if (pass) { - verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); + verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); } /* Verify that only process 0 reads the cache image. */ #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( ( ( mpi_rank == 0 ) && ( cache_ptr->images_read != 1 ) ) || - ( ( mpi_rank > 0 ) && ( cache_ptr->images_read != 0 ) ) ) { + if (((mpi_rank == 0) && (cache_ptr->images_read != 1)) || + ((mpi_rank > 0) && (cache_ptr->images_read != 0))) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected images_read."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* Verify that all other processes receive the cache image block - * from process 0. - * - * Since we have alread verified that only process 0 has read the - * image, it is sufficient to verify that the image was loaded on - * all processes. - */ + /* Verify that all other processes receive the cache image block + * from process 0. + * + * Since we have alread verified that only process 0 has read the + * image, it is sufficient to verify that the image was loaded on + * all processes. + */ #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "Image not loaded?."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file, and verify that it doesn't contain a cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ TRUE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, + /* config_fsm */ FALSE, /* enable_page_buffer */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, @@ -3290,67 +3071,61 @@ verify_cache_image_RO(int file_name_id, int md_write_strat, int mpi_rank) /* md_write_strat */ md_write_strat); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Verify that the file contains the expected data. */ - if ( pass ) { + if (pass) { - verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); + verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block not loaded(2)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* report results */ - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { - if ( pass ) { + if (pass) { PASSED(); - - } else { + } + else { H5_FAILED(); - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", failure_mssg); } } - return !pass; } /* verify_cache_image_RO() */ - /*------------------------------------------------------------------------- * Function: verify_cache_image_RW() * @@ -3399,19 +3174,19 @@ verify_cache_image_RO(int file_name_id, int md_write_strat, int mpi_rank) static unsigned verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank) { - const char * fcn_name = "verify_cache_imageRW()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; + const char *fcn_name = "verify_cache_imageRW()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; pass = TRUE; - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { - switch(md_write_strat) { + switch (md_write_strat) { case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: TESTING("parallel CI load test -- proc0 md write -- R/W"); @@ -3428,27 +3203,24 @@ verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank) } } - show_progress = ( ( show_progress ) && ( mpi_rank == 0 ) ); + show_progress = ((show_progress) && (mpi_rank == 0)); - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* setup the file name */ - if ( pass ) { + if (pass) { - if ( h5_fixname(FILENAMES[file_name_id], H5P_DEFAULT, - filename, sizeof(filename)) == NULL ) { + if (h5_fixname(FILENAMES[file_name_id], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Open the test file created at the beginning of this test. * * Verify that the file contains a cache image. @@ -3459,13 +3231,13 @@ verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank) * image block from process 0. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, + /* config_fsm */ FALSE, /* enable_page_buffer */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, @@ -3480,10 +3252,9 @@ verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank) /* md_write_strat */ md_write_strat); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Verify that the file contains the expected data. * * Verify that only process 0 reads the cache image. @@ -3491,74 +3262,71 @@ verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank) * Verify that all other processes receive the cache * image block from process 0. */ - if ( pass ) { + if (pass) { - verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); + verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); } /* Verify that only process 0 reads the cache image. */ #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( ( ( mpi_rank == 0 ) && ( cache_ptr->images_read != 1 ) ) || - ( ( mpi_rank > 0 ) && ( cache_ptr->images_read != 0 ) ) ) { + if (((mpi_rank == 0) && (cache_ptr->images_read != 1)) || + ((mpi_rank > 0) && (cache_ptr->images_read != 0))) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected images_read."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* Verify that all other processes receive the cache image block - * from process 0. - * - * Since we have alread verified that only process 0 has read the - * image, it is sufficient to verify that the image was loaded on - * all processes. - */ + /* Verify that all other processes receive the cache image block + * from process 0. + * + * Since we have alread verified that only process 0 has read the + * image, it is sufficient to verify that the image was loaded on + * all processes. + */ #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "Image not loaded?."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 4) Open the file, and verify that it doesn't contain a cache image. */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ FALSE, /* read_only */ FALSE, /* set_mdci_fapl */ FALSE, - /* config_fsm */ FALSE, + /* config_fsm */ FALSE, /* enable_page_buffer */ FALSE, /* hdf_file_name */ filename, /* cache_image_flags */ H5C_CI__ALL_FLAGS, @@ -3573,82 +3341,75 @@ verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank) /* md_write_strat */ md_write_strat); } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5) Verify that the file contains the expected data. */ - if ( pass ) { + if (pass) { - verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); + verify_data_sets(file_id, 0, MAX_NUM_DSETS - 1); } #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 0 ) { + if (cache_ptr->images_loaded != 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "metadata cache image block loaded(1)."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - /* 6) Close the file. */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Delete the file. */ - if ( pass ) { + if (pass) { /* wait for everyone to close the file */ MPI_Barrier(MPI_COMM_WORLD); - if ( ( mpi_rank == 0 ) && ( HDremove(filename) < 0 ) ) { + if ((mpi_rank == 0) && (HDremove(filename) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - /* report results */ - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { - if ( pass ) { + if (pass) { PASSED(); - - } else { + } + else { H5_FAILED(); - if ( show_progress ) + if (show_progress) HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", failure_mssg); } } - return !pass; } /* verify_cache_imageRW() */ - /***************************************************************************** * * Function: smoke_check_1() @@ -3676,52 +3437,49 @@ verify_cache_image_RW(int file_name_id, int md_write_strat, int mpi_rank) static hbool_t smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) { - const char * fcn_name = "smoke_check_1()"; - char filename[512]; - hbool_t show_progress = FALSE; - hid_t file_id = -1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - int cp = 0; - int i; - int num_dsets = PAR_NUM_DSETS; - int test_file_index = 2; + const char * fcn_name = "smoke_check_1()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + int cp = 0; + int i; + int num_dsets = PAR_NUM_DSETS; + int test_file_index = 2; h5_stat_size_t file_size; pass = TRUE; - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { TESTING("parallel cache image smoke check 1"); } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); /* setup the file name */ - if ( pass ) { + if (pass) { HDassert(FILENAMES[test_file_index]); - if ( h5_fixname(FILENAMES[test_file_index], H5P_DEFAULT, - filename, sizeof(filename)) - == NULL ) { + if (h5_fixname(FILENAMES[test_file_index], H5P_DEFAULT, filename, sizeof(filename)) == NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname() failed.\n"; } } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 1) Create a PHDF5 file without the cache image FAPL entry. * * Verify that a cache image is not requested */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ TRUE, /* mdci_sbem_expected */ FALSE, @@ -3742,63 +3500,57 @@ smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) /* md_write_strat */ 1); } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 2) Create datasets in the file */ i = 0; - while ( ( pass ) && ( i < num_dsets ) ) { + while ((pass) && (i < num_dsets)) { par_create_dataset(i, file_id, mpi_rank, mpi_size); i++; } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 3) Verify the datasets in the file */ i = 0; - while ( ( pass ) && ( i < num_dsets ) ) { + while ((pass) && (i < num_dsets)) { par_verify_dataset(i, file_id, mpi_rank); i++; } - /* 4) Close the file */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; - } } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 5 Insert a cache image into the file */ - if ( pass ) { + if (pass) { - par_insert_cache_image(test_file_index, mpi_rank, mpi_size); + par_insert_cache_image(test_file_index, mpi_rank, mpi_size); } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 6) Open the file R/O */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, @@ -3819,10 +3571,9 @@ smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) /* md_write_strat */ 1); } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 7) Verify the datasets in the file backwards * * Verify that only process 0 reads the cache image. @@ -3832,72 +3583,69 @@ smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) */ i = num_dsets - 1; - while ( ( pass ) && ( i >= 0 ) ) { + while ((pass) && (i >= 0)) { par_verify_dataset(i, file_id, mpi_rank); i--; } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* Verify that only process 0 reads the cache image. */ + /* Verify that only process 0 reads the cache image. */ #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( ( ( mpi_rank == 0 ) && ( cache_ptr->images_read != 1 ) ) || - ( ( mpi_rank > 0 ) && ( cache_ptr->images_read != 0 ) ) ) { + if (((mpi_rank == 0) && (cache_ptr->images_read != 1)) || + ((mpi_rank > 0) && (cache_ptr->images_read != 0))) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected images_read."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* Verify that all other processes receive the cache image block - * from process 0. - * - * Since we have alread verified that only process 0 has read the - * image, it is sufficient to verify that the image was loaded on - * all processes. - */ + /* Verify that all other processes receive the cache image block + * from process 0. + * + * Since we have alread verified that only process 0 has read the + * image, it is sufficient to verify that the image was loaded on + * all processes. + */ #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "Image not loaded?."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 8) Close the file */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed."; - } } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 9) Open the file */ - if ( pass ) { + if (pass) { open_hdf5_file(/* create_file */ FALSE, /* mdci_sbem_expected */ TRUE, @@ -3918,10 +3666,9 @@ smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) /* md_write_strat */ 1); } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 10) Verify the datasets in the file * * Verify that only process 0 reads the cache image. @@ -3931,82 +3678,78 @@ smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) */ i = 0; - while ( ( pass ) && ( i < num_dsets ) ) { + while ((pass) && (i < num_dsets)) { par_verify_dataset(i, file_id, mpi_rank); i++; } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* Verify that only process 0 reads the cache image. */ + /* Verify that only process 0 reads the cache image. */ #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( ( ( mpi_rank == 0 ) && ( cache_ptr->images_read != 1 ) ) || - ( ( mpi_rank > 0 ) && ( cache_ptr->images_read != 0 ) ) ) { + if (((mpi_rank == 0) && (cache_ptr->images_read != 1)) || + ((mpi_rank > 0) && (cache_ptr->images_read != 0))) { - pass = FALSE; + pass = FALSE; failure_mssg = "unexpected images_read."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* Verify that all other processes receive the cache image block - * from process 0. - * - * Since we have alread verified that only process 0 has read the - * image, it is sufficient to verify that the image was loaded on - * all processes. - */ + /* Verify that all other processes receive the cache image block + * from process 0. + * + * Since we have alread verified that only process 0 has read the + * image, it is sufficient to verify that the image was loaded on + * all processes. + */ #if H5C_COLLECT_CACHE_STATS - if ( pass ) { + if (pass) { - if ( cache_ptr->images_loaded != 1 ) { + if (cache_ptr->images_loaded != 1) { - pass = FALSE; + pass = FALSE; failure_mssg = "Image not loaded?."; } } #endif /* H5C_COLLECT_CACHE_STATS */ - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Delete the datasets in the file */ i = 0; - while ( ( pass ) && ( i < num_dsets ) ) { + while ((pass) && (i < num_dsets)) { par_delete_dataset(i, file_id, mpi_rank); i++; } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Close the file */ - if ( pass ) { + if (pass) { - if ( H5Fclose(file_id) < 0 ) { + if (H5Fclose(file_id) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "H5Fclose() failed."; - } } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 13) Get the size of the file. Verify that it is less * than 20 KB. Without deletions and persistant free * space managers, size size is about 30 MB, so this @@ -4016,55 +3759,52 @@ smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) * Note that this test will have to change if we use * a larger page size. */ - if ( pass ) { + if (pass) { - if ( ( file_size = h5_get_file_size(filename, H5P_DEFAULT) ) < 0 ) { + if ((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_get_file_size() failed."; + } + else if (file_size > 20 * 1024) { - } else if ( file_size > 20 * 1024 ) { - - pass = FALSE; + pass = FALSE; failure_mssg = "unexpectedly large file size."; } } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Delete the file */ - if ( pass ) { + if (pass) { /* wait for everyone to close the file */ MPI_Barrier(MPI_COMM_WORLD); - if ( ( mpi_rank == 0 ) && ( HDremove(filename) < 0 ) ) { + if ((mpi_rank == 0) && (HDremove(filename) < 0)) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDremove() failed.\n"; } } - if ( ( mpi_rank == 0 ) && ( show_progress ) ) + if ((mpi_rank == 0) && (show_progress)) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* report results */ - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { - if ( pass ) { + if (pass) { PASSED(); - - } else { + } + else { H5_FAILED(); - HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", - fcn_name, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", fcn_name, failure_mssg); } } @@ -4072,7 +3812,6 @@ smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) } /* smoke_check_1() */ - /* This test uses many POSIX things that are not available on * Windows. We're using a check for fork(2) here as a proxy for * all POSIX/Unix/Linux things until this test can be made @@ -4109,38 +3848,38 @@ smoke_check_1(MPI_Comm mpi_comm, MPI_Info mpi_info, int mpi_rank, int mpi_size) int main(int argc, char **argv) { - hbool_t setup = FALSE; - hbool_t ici = FALSE; + hbool_t setup = FALSE; + hbool_t ici = FALSE; unsigned nerrs = 0; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - int file_idx; - int i; - int mpi_size; - int mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + int file_idx; + int i; + int mpi_size; + int mpi_rank; - if ( ! parse_flags(argc, argv, &setup, &ici, &file_idx, &mpi_size, FALSE) ) - exit(1); /* exit now if unable to parse flags */ + if (!parse_flags(argc, argv, &setup, &ici, &file_idx, &mpi_size, FALSE)) + exit(1); /* exit now if unable to parse flags */ - if ( setup ) { /* construct test files and exit */ + if (setup) { /* construct test files and exit */ H5open(); HDfprintf(stdout, "Constructing test files: \n"); HDfflush(stdout); i = 0; - while ( ( FILENAMES[i] != NULL ) && ( i < TEST_FILES_TO_CONSTRUCT ) ) { + while ((FILENAMES[i] != NULL) && (i < TEST_FILES_TO_CONSTRUCT)) { HDfprintf(stdout, " writing %s ... ", FILENAMES[i]); HDfflush(stdout); construct_test_file(i); - if ( pass ) { + if (pass) { HDprintf("done.\n"); HDfflush(stdout); - - } else { + } + else { HDprintf("failed.\n"); HDexit(1); @@ -4150,14 +3889,14 @@ main(int argc, char **argv) HDfprintf(stdout, "Test file construction complete.\n"); HDexit(0); + } + else if (ici) { - } else if ( ici ) { - - if ( serial_insert_cache_image(file_idx, mpi_size) ) { + if (serial_insert_cache_image(file_idx, mpi_size)) { HDexit(0); - - } else { + } + else { HDfprintf(stderr, "\n\nCache image insertion failed.\n"); HDfprintf(stderr, " failure mssg = \"%s\"\n", failure_mssg); @@ -4177,72 +3916,70 @@ main(int argc, char **argv) * hang in the atexit post processing in which it may try to make MPI * calls. By then, MPI calls may not work. */ - if (H5dont_atexit() < 0){ - HDprintf("%d:Failed to turn off atexit processing. Continue.\n", - mpi_rank); + if (H5dont_atexit() < 0) { + HDprintf("%d:Failed to turn off atexit processing. Continue.\n", mpi_rank); }; H5open(); - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { HDprintf("===================================\n"); HDprintf("Parallel metadata cache image tests\n"); HDprintf(" mpi_size = %d\n", mpi_size); HDprintf("===================================\n"); } - if ( mpi_size < 2 ) { + if (mpi_size < 2) { - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { HDprintf(" Need at least 2 processes. Exiting.\n"); } goto finish; } - if ( mpi_rank == 0 ) { /* create test files */ + if (mpi_rank == 0) { /* create test files */ - int child_status; + int child_status; pid_t child_pid; child_pid = fork(); - if ( child_pid == 0 ) { /* this is the child process */ + if (child_pid == 0) { /* this is the child process */ /* fun and games to shutup the compiler */ - char param0[32] = "t_cache_image"; - char param1[32] = "setup"; - char * child_argv[] = {param0, param1, NULL}; + char param0[32] = "t_cache_image"; + char param1[32] = "setup"; + char *child_argv[] = {param0, param1, NULL}; /* we may need to play with the path here */ - if ( execv("t_cache_image", child_argv) == -1 ) { + if (execv("t_cache_image", child_argv) == -1) { - HDfprintf(stdout, - "execl() of setup process failed. errno = %d(%s)\n", - errno, strerror(errno)); + HDfprintf(stdout, "execl() of setup process failed. errno = %d(%s)\n", errno, + strerror(errno)); HDexit(1); } - - } else if ( child_pid != -1 ) { + } + else if (child_pid != -1) { /* this is the parent process -- wait until child is done */ - if ( -1 == waitpid(child_pid, &child_status, WUNTRACED)) { + if (-1 == waitpid(child_pid, &child_status, WUNTRACED)) { HDfprintf(stdout, "can't wait on setup process.\n"); - - } else if ( ! WIFEXITED(child_status) ) { + } + else if (!WIFEXITED(child_status)) { HDfprintf(stdout, "setup process hasn't exitied.\n"); - - } else if ( WEXITSTATUS(child_status) != 0 ) { + } + else if (WEXITSTATUS(child_status) != 0) { HDfprintf(stdout, "setup process reports failure.\n"); + } + else { - } else { - - HDfprintf(stdout, - "testfile construction complete -- proceeding with tests.\n"); + HDfprintf(stdout, "testfile construction complete -- proceeding with tests.\n"); } - } else { /* fork failed */ + } + else { /* fork failed */ HDfprintf(stdout, "can't create process to construct test file.\n"); } @@ -4251,16 +3988,11 @@ main(int argc, char **argv) /* can't start test until test files exist */ MPI_Barrier(MPI_COMM_WORLD); - - nerrs += verify_cache_image_RO(0, - H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY, mpi_rank); + nerrs += verify_cache_image_RO(0, H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY, mpi_rank); #if 1 - nerrs += verify_cache_image_RO(1, - H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED, mpi_rank); - nerrs += verify_cache_image_RW(0, - H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY, mpi_rank); - nerrs += verify_cache_image_RW(1, - H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED, mpi_rank); + nerrs += verify_cache_image_RO(1, H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED, mpi_rank); + nerrs += verify_cache_image_RW(0, H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY, mpi_rank); + nerrs += verify_cache_image_RW(1, H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED, mpi_rank); nerrs += smoke_check_1(comm, info, mpi_rank, mpi_size); #endif finish: @@ -4270,12 +4002,11 @@ finish: */ MPI_Barrier(MPI_COMM_WORLD); - if ( mpi_rank == 0 ) { /* only process 0 reports */ + if (mpi_rank == 0) { /* only process 0 reports */ HDsleep(10); HDprintf("===================================\n"); - if ( nerrs > 0 ) { - HDprintf("***metadata cache image tests detected %d failures***\n", - nerrs); + if (nerrs > 0) { + HDprintf("***metadata cache image tests detected %d failures***\n", nerrs); } else { HDprintf("metadata cache image tests finished with no failures\n"); @@ -4292,7 +4023,7 @@ finish: MPI_Finalize(); /* cannot just return (nerrs) because exit code is limited to 1byte */ - return(nerrs > 0); + return (nerrs > 0); } /* main() */ #else /* H5_HAVE_FORK */ @@ -4305,4 +4036,3 @@ main(void) } /* end main() */ #endif /* H5_HAVE_FORK */ - diff --git a/testpar/t_chunk_alloc.c b/testpar/t_chunk_alloc.c index e716f41..8b9eb36 100644 --- a/testpar/t_chunk_alloc.c +++ b/testpar/t_chunk_alloc.c @@ -22,21 +22,20 @@ #include "testphdf5.h" static int mpi_size, mpi_rank; -#define DSET_NAME "ExtendibleArray" -#define CHUNK_SIZE 1000 /* #elements per chunk */ -#define CHUNK_FACTOR 200 /* default dataset size in terms of chunks */ -#define CLOSE 1 -#define NO_CLOSE 0 +#define DSET_NAME "ExtendibleArray" +#define CHUNK_SIZE 1000 /* #elements per chunk */ +#define CHUNK_FACTOR 200 /* default dataset size in terms of chunks */ +#define CLOSE 1 +#define NO_CLOSE 0 static MPI_Offset get_filesize(const char *filename) { int mpierr; - MPI_File fd; - MPI_Offset filesize; + MPI_File fd; + MPI_Offset filesize; - mpierr = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, - MPI_INFO_NULL, &fd); + mpierr = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fd); VRFY((mpierr == MPI_SUCCESS), ""); mpierr = MPI_File_get_size(fd, &filesize); @@ -45,21 +44,12 @@ get_filesize(const char *filename) mpierr = MPI_File_close(&fd); VRFY((mpierr == MPI_SUCCESS), ""); - return(filesize); + return (filesize); } -typedef enum write_pattern { - none, - sec_last, - all -} write_type; - -typedef enum access_ { - write_all, - open_only, - extend_only -} access_type; +typedef enum write_pattern { none, sec_last, all } write_type; +typedef enum access_ { write_all, open_only, extend_only } access_type; /* * This creates a dataset serially with chunks, each of CHUNK_SIZE @@ -69,35 +59,35 @@ typedef enum access_ { static void create_chunked_dataset(const char *filename, int chunk_factor, write_type write_pattern) { - hid_t file_id, dataset; /* handles */ - hid_t dataspace,memspace; - hid_t cparms; - hsize_t dims[1]; - hsize_t maxdims[1] = {H5S_UNLIMITED}; - - hsize_t chunk_dims[1] ={CHUNK_SIZE}; - hsize_t count[1]; - hsize_t stride[1]; - hsize_t block[1]; - hsize_t offset[1]; /* Selection offset within dataspace */ + hid_t file_id, dataset; /* handles */ + hid_t dataspace, memspace; + hid_t cparms; + hsize_t dims[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + + hsize_t chunk_dims[1] = {CHUNK_SIZE}; + hsize_t count[1]; + hsize_t stride[1]; + hsize_t block[1]; + hsize_t offset[1]; /* Selection offset within dataspace */ /* Variables used in reading data back */ - char buffer[CHUNK_SIZE]; - long nchunks; - herr_t hrc; + char buffer[CHUNK_SIZE]; + long nchunks; + herr_t hrc; - MPI_Offset filesize, /* actual file size */ - est_filesize; /* estimated file size */ + MPI_Offset filesize, /* actual file size */ + est_filesize; /* estimated file size */ /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* Only MAINPROCESS should create the file. Others just wait. */ - if (MAINPROCESS){ - nchunks=chunk_factor*mpi_size; - dims[0]=(hsize_t)(nchunks*CHUNK_SIZE); + if (MAINPROCESS) { + nchunks = chunk_factor * mpi_size; + dims[0] = (hsize_t)(nchunks * CHUNK_SIZE); /* Create the data space with unlimited dimensions. */ - dataspace = H5Screate_simple (1, dims, maxdims); + dataspace = H5Screate_simple(1, dims, maxdims); VRFY((dataspace >= 0), ""); memspace = H5Screate_simple(1, chunk_dims, NULL); @@ -118,19 +108,20 @@ create_chunked_dataset(const char *filename, int chunk_factor, write_type write_ VRFY((hrc >= 0), ""); /* Create a new dataset within the file using cparms creation properties. */ - dataset = H5Dcreate2(file_id, DSET_NAME, H5T_NATIVE_UCHAR, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT); + dataset = + H5Dcreate2(file_id, DSET_NAME, H5T_NATIVE_UCHAR, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT); VRFY((dataset >= 0), ""); - if(write_pattern == sec_last) { + if (write_pattern == sec_last) { HDmemset(buffer, 100, CHUNK_SIZE); - count[0] = 1; + count[0] = 1; stride[0] = 1; - block[0] = chunk_dims[0]; - offset[0] = (hsize_t)(nchunks-2)*chunk_dims[0]; + block[0] = chunk_dims[0]; + offset[0] = (hsize_t)(nchunks - 2) * chunk_dims[0]; hrc = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, stride, count, block); - VRFY((hrc >= 0), ""); + VRFY((hrc >= 0), ""); /* Write sec_last chunk */ hrc = H5Dwrite(dataset, H5T_NATIVE_UCHAR, memspace, dataspace, H5P_DEFAULT, buffer); @@ -138,28 +129,27 @@ create_chunked_dataset(const char *filename, int chunk_factor, write_type write_ } /* end if */ /* Close resources */ - hrc = H5Dclose (dataset); + hrc = H5Dclose(dataset); VRFY((hrc >= 0), ""); dataset = -1; - hrc = H5Sclose (dataspace); + hrc = H5Sclose(dataspace); VRFY((hrc >= 0), ""); - hrc = H5Sclose (memspace); + hrc = H5Sclose(memspace); VRFY((hrc >= 0), ""); - hrc = H5Pclose (cparms); + hrc = H5Pclose(cparms); VRFY((hrc >= 0), ""); - hrc = H5Fclose (file_id); + hrc = H5Fclose(file_id); VRFY((hrc >= 0), ""); file_id = -1; /* verify file size */ - filesize = get_filesize(filename); + filesize = get_filesize(filename); est_filesize = (MPI_Offset)nchunks * (MPI_Offset)CHUNK_SIZE * (MPI_Offset)sizeof(unsigned char); VRFY((filesize >= est_filesize), "file size check"); - } /* Make sure all processes are done before exiting this routine. Otherwise, @@ -170,7 +160,6 @@ create_chunked_dataset(const char *filename, int chunk_factor, write_type write_ MPI_Barrier(MPI_COMM_WORLD); } - /* * This program performs three different types of parallel access. It writes on * the entire dataset, it extends the dataset to nchunks*CHUNK_SIZE, and it only @@ -178,51 +167,52 @@ create_chunked_dataset(const char *filename, int chunk_factor, write_type write_ * consistent with argument 'chunk_factor'. */ static void -parallel_access_dataset(const char *filename, int chunk_factor, access_type action, hid_t *file_id, hid_t *dataset) +parallel_access_dataset(const char *filename, int chunk_factor, access_type action, hid_t *file_id, + hid_t *dataset) { /* HDF5 gubbins */ - hid_t memspace, dataspace; /* HDF5 file identifier */ - hid_t access_plist; /* HDF5 ID for file access property list */ - herr_t hrc; /* HDF5 return code */ - hsize_t size[1]; - - hsize_t chunk_dims[1] ={CHUNK_SIZE}; - hsize_t count[1]; - hsize_t stride[1]; - hsize_t block[1]; - hsize_t offset[1]; /* Selection offset within dataspace */ - hsize_t dims[1]; - hsize_t maxdims[1]; + hid_t memspace, dataspace; /* HDF5 file identifier */ + hid_t access_plist; /* HDF5 ID for file access property list */ + herr_t hrc; /* HDF5 return code */ + hsize_t size[1]; + + hsize_t chunk_dims[1] = {CHUNK_SIZE}; + hsize_t count[1]; + hsize_t stride[1]; + hsize_t block[1]; + hsize_t offset[1]; /* Selection offset within dataspace */ + hsize_t dims[1]; + hsize_t maxdims[1]; /* Variables used in reading data back */ - char buffer[CHUNK_SIZE]; - int i; - long nchunks; + char buffer[CHUNK_SIZE]; + int i; + long nchunks; /* MPI Gubbins */ - MPI_Offset filesize, /* actual file size */ - est_filesize; /* estimated file size */ + MPI_Offset filesize, /* actual file size */ + est_filesize; /* estimated file size */ /* Initialize MPI */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - nchunks=chunk_factor*mpi_size; + nchunks = chunk_factor * mpi_size; /* Set up MPIO file access property lists */ - access_plist = H5Pcreate(H5P_FILE_ACCESS); + access_plist = H5Pcreate(H5P_FILE_ACCESS); VRFY((access_plist >= 0), ""); hrc = H5Pset_fapl_mpio(access_plist, MPI_COMM_WORLD, MPI_INFO_NULL); VRFY((hrc >= 0), ""); /* Open the file */ - if (*file_id<0){ + if (*file_id < 0) { *file_id = H5Fopen(filename, H5F_ACC_RDWR, access_plist); VRFY((*file_id >= 0), ""); } /* Open dataset*/ - if (*dataset<0){ + if (*dataset < 0) { *dataset = H5Dopen2(*file_id, DSET_NAME, H5P_DEFAULT); VRFY((*dataset >= 0), ""); } @@ -233,19 +223,19 @@ parallel_access_dataset(const char *filename, int chunk_factor, access_type acti dataspace = H5Dget_space(*dataset); VRFY((dataspace >= 0), ""); - size[0] = (hsize_t)nchunks*CHUNK_SIZE; + size[0] = (hsize_t)nchunks * CHUNK_SIZE; switch (action) { /* all chunks are written by all the processes in an interleaved way*/ case write_all: - HDmemset(buffer, mpi_rank+1, CHUNK_SIZE); - count[0] = 1; + HDmemset(buffer, mpi_rank + 1, CHUNK_SIZE); + count[0] = 1; stride[0] = 1; - block[0] = chunk_dims[0]; - for (i=0; i= 0), ""); @@ -282,10 +272,10 @@ parallel_access_dataset(const char *filename, int chunk_factor, access_type acti VRFY((hrc >= 0), ""); *dataset = -1; - hrc = H5Sclose (dataspace); + hrc = H5Sclose(dataspace); VRFY((hrc >= 0), ""); - hrc = H5Sclose (memspace); + hrc = H5Sclose(memspace); VRFY((hrc >= 0), ""); hrc = H5Fclose(*file_id); @@ -293,8 +283,8 @@ parallel_access_dataset(const char *filename, int chunk_factor, access_type acti *file_id = -1; /* verify file size */ - filesize = get_filesize(filename); - est_filesize = (MPI_Offset)nchunks*(MPI_Offset)CHUNK_SIZE*(MPI_Offset)sizeof(unsigned char); + filesize = get_filesize(filename); + est_filesize = (MPI_Offset)nchunks * (MPI_Offset)CHUNK_SIZE * (MPI_Offset)sizeof(unsigned char); VRFY((filesize >= est_filesize), "file size check"); /* Can close some plists */ @@ -317,45 +307,45 @@ parallel_access_dataset(const char *filename, int chunk_factor, access_type acti * interleaved pattern. */ static void -verify_data(const char *filename, int chunk_factor, write_type write_pattern, int vclose, - hid_t *file_id, hid_t *dataset) +verify_data(const char *filename, int chunk_factor, write_type write_pattern, int vclose, hid_t *file_id, + hid_t *dataset) { /* HDF5 gubbins */ - hid_t dataspace, memspace; /* HDF5 file identifier */ - hid_t access_plist; /* HDF5 ID for file access property list */ - herr_t hrc; /* HDF5 return code */ - - hsize_t chunk_dims[1] ={CHUNK_SIZE}; - hsize_t count[1]; - hsize_t stride[1]; - hsize_t block[1]; - hsize_t offset[1]; /* Selection offset within dataspace */ + hid_t dataspace, memspace; /* HDF5 file identifier */ + hid_t access_plist; /* HDF5 ID for file access property list */ + herr_t hrc; /* HDF5 return code */ + + hsize_t chunk_dims[1] = {CHUNK_SIZE}; + hsize_t count[1]; + hsize_t stride[1]; + hsize_t block[1]; + hsize_t offset[1]; /* Selection offset within dataspace */ /* Variables used in reading data back */ - char buffer[CHUNK_SIZE]; - int value, i; - int index_l; - long nchunks; + char buffer[CHUNK_SIZE]; + int value, i; + int index_l; + long nchunks; /* Initialize MPI */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - nchunks=chunk_factor*mpi_size; + nchunks = chunk_factor * mpi_size; /* Set up MPIO file access property lists */ - access_plist = H5Pcreate(H5P_FILE_ACCESS); + access_plist = H5Pcreate(H5P_FILE_ACCESS); VRFY((access_plist >= 0), ""); hrc = H5Pset_fapl_mpio(access_plist, MPI_COMM_WORLD, MPI_INFO_NULL); VRFY((hrc >= 0), ""); /* Open the file */ - if (*file_id<0){ + if (*file_id < 0) { *file_id = H5Fopen(filename, H5F_ACC_RDWR, access_plist); VRFY((*file_id >= 0), ""); } /* Open dataset*/ - if (*dataset<0){ + if (*dataset < 0) { *dataset = H5Dopen2(*file_id, DSET_NAME, H5P_DEFAULT); VRFY((*dataset >= 0), ""); } @@ -367,14 +357,14 @@ verify_data(const char *filename, int chunk_factor, write_type write_pattern, in VRFY((dataspace >= 0), ""); /* all processes check all chunks. */ - count[0] = 1; + count[0] = 1; stride[0] = 1; - block[0] = chunk_dims[0]; - for (i=0; i= 0), ""); @@ -386,13 +376,13 @@ verify_data(const char *filename, int chunk_factor, write_type write_pattern, in /* set expected value according the write pattern */ switch (write_pattern) { case all: - value = i%mpi_size + 1; + value = i % mpi_size + 1; break; case none: value = 0; break; case sec_last: - if (i==nchunks-2) + if (i == nchunks - 2) value = 100; else value = 0; @@ -406,10 +396,10 @@ verify_data(const char *filename, int chunk_factor, write_type write_pattern, in VRFY((buffer[index_l] == value), "data verification"); } - hrc = H5Sclose (dataspace); + hrc = H5Sclose(dataspace); VRFY((hrc >= 0), ""); - hrc = H5Sclose (memspace); + hrc = H5Sclose(memspace); VRFY((hrc >= 0), ""); /* Can close some plists */ @@ -417,7 +407,7 @@ verify_data(const char *filename, int chunk_factor, write_type write_pattern, in VRFY((hrc >= 0), ""); /* Close up */ - if (vclose){ + if (vclose) { hrc = H5Dclose(*dataset); VRFY((hrc >= 0), ""); *dataset = -1; @@ -434,8 +424,6 @@ verify_data(const char *filename, int chunk_factor, write_type write_pattern, in MPI_Barrier(MPI_COMM_WORLD); } - - /* * Test following possible scenarios, * Case 1: @@ -458,15 +446,15 @@ void test_chunk_alloc(void) { const char *filename; - hid_t file_id, dataset; + hid_t file_id, dataset; file_id = dataset = -1; /* Initialize MPI */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - filename = (const char*)GetTestParameters(); + filename = (const char *)GetTestParameters(); if (VERBOSE_MED) HDprintf("Extend Chunked allocation test on file %s\n", filename); @@ -495,5 +483,4 @@ test_chunk_alloc(void) parallel_access_dataset(filename, CHUNK_FACTOR, write_all, &file_id, &dataset); /* reopen dataset in parallel, read and verify the data */ verify_data(filename, CHUNK_FACTOR, all, CLOSE, &file_id, &dataset); - } diff --git a/testpar/t_coll_chunk.c b/testpar/t_coll_chunk.c index 740f78e..2a55ad1 100644 --- a/testpar/t_coll_chunk.c +++ b/testpar/t_coll_chunk.c @@ -16,26 +16,23 @@ #define HYPER 1 #define POINT 2 -#define ALL 3 +#define ALL 3 /* some commonly used routines for collective chunk IO tests*/ -static void ccslab_set(int mpi_rank,int mpi_size,hsize_t start[],hsize_t count[], - hsize_t stride[],hsize_t block[],int mode); +static void ccslab_set(int mpi_rank, int mpi_size, hsize_t start[], hsize_t count[], hsize_t stride[], + hsize_t block[], int mode); -static void ccdataset_fill(hsize_t start[],hsize_t count[], - hsize_t stride[],hsize_t block[],DATATYPE*dataset, - int mem_selection); +static void ccdataset_fill(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], + DATATYPE *dataset, int mem_selection); -static void ccdataset_print(hsize_t start[],hsize_t block[],DATATYPE*dataset); +static void ccdataset_print(hsize_t start[], hsize_t block[], DATATYPE *dataset); -static int ccdataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], - hsize_t block[], DATATYPE *dataset, DATATYPE *original, - int mem_selection); - -static void coll_chunktest(const char* filename, int chunk_factor, int select_factor, - int api_option, int file_selection, int mem_selection, int mode); +static int ccdataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], + DATATYPE *dataset, DATATYPE *original, int mem_selection); +static void coll_chunktest(const char *filename, int chunk_factor, int select_factor, int api_option, + int file_selection, int mem_selection, int mode); /*------------------------------------------------------------------------- * Function: coll_chunk1 @@ -88,7 +85,6 @@ coll_chunk1(void) coll_chunktest(filename, 1, BYROW_CONT, API_NONE, POINT, HYPER, IN_ORDER); } - /*------------------------------------------------------------------------- * Function: coll_chunk2 * @@ -107,7 +103,7 @@ coll_chunk1(void) *------------------------------------------------------------------------- */ - /* ------------------------------------------------------------------------ +/* ------------------------------------------------------------------------ * Descriptions for the selection: many disjoint selections inside one chunk * Two dimensions, * @@ -140,7 +136,6 @@ coll_chunk2(void) coll_chunktest(filename, 1, BYROW_DISCONT, API_NONE, POINT, HYPER, IN_ORDER); } - /*------------------------------------------------------------------------- * Function: coll_chunk3 * @@ -181,7 +176,7 @@ void coll_chunk3(void) { const char *filename = GetTestParameters(); - int mpi_size; + int mpi_size; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); coll_chunktest(filename, mpi_size, BYROW_CONT, API_NONE, HYPER, HYPER, OUT_OF_ORDER); @@ -496,17 +491,17 @@ coll_chunk8(void) void coll_chunk9(void) { - const char *filename = GetTestParameters(); + const char *filename = GetTestParameters(); - coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, HYPER, HYPER, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, HYPER, POINT, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, ALL, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, POINT, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, HYPER, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, HYPER, HYPER, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, HYPER, POINT, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, ALL, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, POINT, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, HYPER, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, ALL, IN_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, POINT, IN_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, HYPER, IN_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, ALL, IN_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, POINT, IN_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTUNBALANCE, API_MULTI_COLL, POINT, HYPER, IN_ORDER); } /*------------------------------------------------------------------------- @@ -548,28 +543,27 @@ coll_chunk9(void) void coll_chunk10(void) { - const char *filename = GetTestParameters(); + const char *filename = GetTestParameters(); - coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, HYPER, HYPER, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, HYPER, POINT, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, ALL, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, POINT, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, HYPER, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, HYPER, HYPER, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, HYPER, POINT, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, ALL, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, POINT, OUT_OF_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, HYPER, OUT_OF_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, ALL, IN_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, POINT, IN_ORDER); - coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, HYPER, IN_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, ALL, IN_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, POINT, IN_ORDER); + coll_chunktest(filename, 4, BYROW_SELECTINCHUNK, API_MULTI_IND, POINT, HYPER, IN_ORDER); } - /*------------------------------------------------------------------------- * Function: coll_chunktest * * Purpose: The real testing routine for regular selection of collective chunking storage testing both write and read, - If anything fails, it may be read or write. There is no - separation test between read and write. + If anything fails, it may be read or write. There is no + separation test between read and write. * * Return: Success: 0 * @@ -590,572 +584,563 @@ coll_chunk10(void) */ static void -coll_chunktest(const char* filename, - int chunk_factor, - int select_factor, - int api_option, - int file_selection, - int mem_selection, - int mode) +coll_chunktest(const char *filename, int chunk_factor, int select_factor, int api_option, int file_selection, + int mem_selection, int mode) { - hid_t file, dataset, file_dataspace, mem_dataspace; - hid_t acc_plist,xfer_plist,crp_plist; + hid_t file, dataset, file_dataspace, mem_dataspace; + hid_t acc_plist, xfer_plist, crp_plist; - hsize_t dims[RANK], chunk_dims[RANK]; - int* data_array1 = NULL; - int* data_origin1 = NULL; + hsize_t dims[RANK], chunk_dims[RANK]; + int * data_array1 = NULL; + int * data_origin1 = NULL; - hsize_t start[RANK],count[RANK],stride[RANK],block[RANK]; + hsize_t start[RANK], count[RANK], stride[RANK], block[RANK]; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - unsigned prop_value; + unsigned prop_value; #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - int mpi_size,mpi_rank; + int mpi_size, mpi_rank; + + herr_t status; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + size_t num_points; /* for point selection */ + hsize_t *coords = NULL; /* for point selection */ + hsize_t current_dims; /* for point selection */ + + /* set up MPI parameters */ + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); + + /* Create the data space */ + + acc_plist = create_faccess_plist(comm, info, facc_type); + VRFY((acc_plist >= 0), ""); + + file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_plist); + VRFY((file >= 0), "H5Fcreate succeeded"); + + status = H5Pclose(acc_plist); + VRFY((status >= 0), ""); + + /* setup dimensionality object */ + dims[0] = (hsize_t)(SPACE_DIM1 * mpi_size); + dims[1] = SPACE_DIM2; + + /* allocate memory for data buffer */ + data_array1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); + VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); + + /* set up dimensions of the slab this process accesses */ + ccslab_set(mpi_rank, mpi_size, start, count, stride, block, select_factor); + + /* set up the coords array selection */ + num_points = block[0] * block[1] * count[0] * count[1]; + coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); + VRFY((coords != NULL), "coords malloc succeeded"); + point_set(start, count, stride, block, num_points, coords, mode); + + file_dataspace = H5Screate_simple(2, dims, NULL); + VRFY((file_dataspace >= 0), "file dataspace created succeeded"); + + if (ALL != mem_selection) { + mem_dataspace = H5Screate_simple(2, dims, NULL); + VRFY((mem_dataspace >= 0), "mem dataspace created succeeded"); + } + else { + current_dims = num_points; + mem_dataspace = H5Screate_simple(1, ¤t_dims, NULL); + VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); + } + + crp_plist = H5Pcreate(H5P_DATASET_CREATE); + VRFY((crp_plist >= 0), ""); + + /* Set up chunk information. */ + chunk_dims[0] = dims[0] / (hsize_t)chunk_factor; + + /* to decrease the testing time, maintain bigger chunk size */ + (chunk_factor == 1) ? (chunk_dims[1] = SPACE_DIM2) : (chunk_dims[1] = SPACE_DIM2 / 2); + status = H5Pset_chunk(crp_plist, 2, chunk_dims); + VRFY((status >= 0), "chunk creation property list succeeded"); + + dataset = H5Dcreate2(file, DSET_COLLECTIVE_CHUNK_NAME, H5T_NATIVE_INT, file_dataspace, H5P_DEFAULT, + crp_plist, H5P_DEFAULT); + VRFY((dataset >= 0), "dataset created succeeded"); + + status = H5Pclose(crp_plist); + VRFY((status >= 0), ""); + + /*put some trivial data in the data array */ + ccdataset_fill(start, stride, count, block, data_array1, mem_selection); - herr_t status; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - - size_t num_points; /* for point selection */ - hsize_t *coords = NULL; /* for point selection */ - hsize_t current_dims; /* for point selection */ - - /* set up MPI parameters */ - MPI_Comm_size(comm,&mpi_size); - MPI_Comm_rank(comm,&mpi_rank); - - /* Create the data space */ - - acc_plist = create_faccess_plist(comm,info,facc_type); - VRFY((acc_plist >= 0),""); - - file = H5Fcreate(filename,H5F_ACC_TRUNC,H5P_DEFAULT,acc_plist); - VRFY((file >= 0),"H5Fcreate succeeded"); - - status = H5Pclose(acc_plist); - VRFY((status >= 0),""); - - /* setup dimensionality object */ - dims[0] = (hsize_t)(SPACE_DIM1*mpi_size); - dims[1] = SPACE_DIM2; - - /* allocate memory for data buffer */ - data_array1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); - VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); - - /* set up dimensions of the slab this process accesses */ - ccslab_set(mpi_rank, mpi_size, start, count, stride, block, select_factor); - - /* set up the coords array selection */ - num_points = block[0] * block[1] * count[0] * count[1]; - coords = (hsize_t *)HDmalloc(num_points * RANK * sizeof(hsize_t)); - VRFY((coords != NULL), "coords malloc succeeded"); - point_set(start, count, stride, block, num_points, coords, mode); - - file_dataspace = H5Screate_simple(2, dims, NULL); - VRFY((file_dataspace >= 0), "file dataspace created succeeded"); - - if(ALL != mem_selection) { - mem_dataspace = H5Screate_simple(2, dims, NULL); - VRFY((mem_dataspace >= 0), "mem dataspace created succeeded"); - } - else { - current_dims = num_points; - mem_dataspace = H5Screate_simple (1, ¤t_dims, NULL); - VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); - } - - crp_plist = H5Pcreate(H5P_DATASET_CREATE); - VRFY((crp_plist >= 0),""); - - /* Set up chunk information. */ - chunk_dims[0] = dims[0]/(hsize_t)chunk_factor; - - /* to decrease the testing time, maintain bigger chunk size */ - (chunk_factor == 1) ? (chunk_dims[1] = SPACE_DIM2) : (chunk_dims[1] = SPACE_DIM2/2); - status = H5Pset_chunk(crp_plist, 2, chunk_dims); - VRFY((status >= 0),"chunk creation property list succeeded"); - - dataset = H5Dcreate2(file, DSET_COLLECTIVE_CHUNK_NAME, H5T_NATIVE_INT, - file_dataspace, H5P_DEFAULT, crp_plist, H5P_DEFAULT); - VRFY((dataset >= 0),"dataset created succeeded"); - - status = H5Pclose(crp_plist); - VRFY((status >= 0), ""); - - /*put some trivial data in the data array */ - ccdataset_fill(start, stride, count,block, data_array1, mem_selection); - - MESG("data_array initialized"); - - switch (file_selection) { - case HYPER: - status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((status >= 0),"hyperslab selection succeeded"); - break; - - case POINT: - if (num_points) { - status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); - VRFY((status >= 0),"Element selection succeeded"); - } - else { - status = H5Sselect_none(file_dataspace); - VRFY((status >= 0),"none selection succeeded"); - } - break; - - case ALL: - status = H5Sselect_all(file_dataspace); - VRFY((status >= 0), "H5Sselect_all succeeded"); - break; - } - - switch (mem_selection) { - case HYPER: - status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((status >= 0),"hyperslab selection succeeded"); - break; - - case POINT: - if (num_points) { - status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); - VRFY((status >= 0),"Element selection succeeded"); - } - else { - status = H5Sselect_none(mem_dataspace); - VRFY((status >= 0),"none selection succeeded"); - } - break; - - case ALL: - status = H5Sselect_all(mem_dataspace); - VRFY((status >= 0), "H5Sselect_all succeeded"); - break; - } - - /* set up the collective transfer property list */ - xfer_plist = H5Pcreate(H5P_DATASET_XFER); - VRFY((xfer_plist >= 0), ""); - - status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); - VRFY((status>= 0),"MPIO collective transfer property succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - status = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); - VRFY((status>= 0),"set independent IO collectively succeeded"); - } - - switch(api_option){ - case API_LINK_HARD: - status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist,H5FD_MPIO_CHUNK_ONE_IO); - VRFY((status>= 0),"collective chunk optimization succeeded"); - break; - - case API_MULTI_HARD: - status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist,H5FD_MPIO_CHUNK_MULTI_IO); - VRFY((status>= 0),"collective chunk optimization succeeded "); - break; - - case API_LINK_TRUE: - status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist,2); - VRFY((status>= 0),"collective chunk optimization set chunk number succeeded"); - break; - - case API_LINK_FALSE: - status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist,6); - VRFY((status>= 0),"collective chunk optimization set chunk number succeeded"); - break; - - case API_MULTI_COLL: - status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist,8);/* make sure it is using multi-chunk IO */ - VRFY((status>= 0),"collective chunk optimization set chunk number succeeded"); - status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist,50); - VRFY((status>= 0),"collective chunk optimization set chunk ratio succeeded"); - break; - - case API_MULTI_IND: - status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist,8);/* make sure it is using multi-chunk IO */ - VRFY((status>= 0),"collective chunk optimization set chunk number succeeded"); - status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist,100); - VRFY((status>= 0),"collective chunk optimization set chunk ratio succeeded"); - break; - - default: - ; - } + MESG("data_array initialized"); + + switch (file_selection) { + case HYPER: + status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((status >= 0), "hyperslab selection succeeded"); + break; + + case POINT: + if (num_points) { + status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); + VRFY((status >= 0), "Element selection succeeded"); + } + else { + status = H5Sselect_none(file_dataspace); + VRFY((status >= 0), "none selection succeeded"); + } + break; + + case ALL: + status = H5Sselect_all(file_dataspace); + VRFY((status >= 0), "H5Sselect_all succeeded"); + break; + } + + switch (mem_selection) { + case HYPER: + status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((status >= 0), "hyperslab selection succeeded"); + break; + + case POINT: + if (num_points) { + status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); + VRFY((status >= 0), "Element selection succeeded"); + } + else { + status = H5Sselect_none(mem_dataspace); + VRFY((status >= 0), "none selection succeeded"); + } + break; + + case ALL: + status = H5Sselect_all(mem_dataspace); + VRFY((status >= 0), "H5Sselect_all succeeded"); + break; + } + + /* set up the collective transfer property list */ + xfer_plist = H5Pcreate(H5P_DATASET_XFER); + VRFY((xfer_plist >= 0), ""); + + status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + VRFY((status >= 0), "MPIO collective transfer property succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + status = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((status >= 0), "set independent IO collectively succeeded"); + } + + switch (api_option) { + case API_LINK_HARD: + status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist, H5FD_MPIO_CHUNK_ONE_IO); + VRFY((status >= 0), "collective chunk optimization succeeded"); + break; + + case API_MULTI_HARD: + status = H5Pset_dxpl_mpio_chunk_opt(xfer_plist, H5FD_MPIO_CHUNK_MULTI_IO); + VRFY((status >= 0), "collective chunk optimization succeeded "); + break; + + case API_LINK_TRUE: + status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 2); + VRFY((status >= 0), "collective chunk optimization set chunk number succeeded"); + break; + + case API_LINK_FALSE: + status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 6); + VRFY((status >= 0), "collective chunk optimization set chunk number succeeded"); + break; + + case API_MULTI_COLL: + status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 8); /* make sure it is using multi-chunk IO */ + VRFY((status >= 0), "collective chunk optimization set chunk number succeeded"); + status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist, 50); + VRFY((status >= 0), "collective chunk optimization set chunk ratio succeeded"); + break; + + case API_MULTI_IND: + status = H5Pset_dxpl_mpio_chunk_opt_num(xfer_plist, 8); /* make sure it is using multi-chunk IO */ + VRFY((status >= 0), "collective chunk optimization set chunk number succeeded"); + status = H5Pset_dxpl_mpio_chunk_opt_ratio(xfer_plist, 100); + VRFY((status >= 0), "collective chunk optimization set chunk ratio succeeded"); + break; + + default:; + } #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if(facc_type == FACC_MPIO) { - switch(api_option) { + if (facc_type == FACC_MPIO) { + switch (api_option) { case API_LINK_HARD: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY((status >= 0), "testing property list inserted succeeded"); + break; case API_MULTI_HARD: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY((status >= 0), "testing property list inserted succeeded"); + break; case API_LINK_TRUE: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = + H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY((status >= 0), "testing property list inserted succeeded"); + break; case API_LINK_FALSE: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = + H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY((status >= 0), "testing property list inserted succeeded"); + break; case API_MULTI_COLL: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY((status >= 0),"testing property list inserted succeeded"); - break; + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = + H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, + H5D_XFER_COLL_CHUNK_SIZE, &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY((status >= 0), "testing property list inserted succeeded"); + break; case API_MULTI_IND: - prop_value = H5D_XFER_COLL_CHUNK_DEF; - status = H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, H5D_XFER_COLL_CHUNK_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY((status >= 0),"testing property list inserted succeeded"); - break; - - default: - ; - } - } + prop_value = H5D_XFER_COLL_CHUNK_DEF; + status = + H5Pinsert2(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, H5D_XFER_COLL_CHUNK_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL); + VRFY((status >= 0), "testing property list inserted succeeded"); + break; + + default:; + } + } #endif - /* write data collectively */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); - VRFY((status >= 0),"dataset write succeeded"); + /* write data collectively */ + status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); + VRFY((status >= 0), "dataset write succeeded"); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if(facc_type == FACC_MPIO) { - switch(api_option){ + if (facc_type == FACC_MPIO) { + switch (api_option) { case API_LINK_HARD: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_LINK_HARD_NAME,&prop_value); - VRFY((status >= 0),"testing property list get succeeded"); - VRFY((prop_value == 0),"API to set LINK COLLECTIVE IO directly succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, &prop_value); + VRFY((status >= 0), "testing property list get succeeded"); + VRFY((prop_value == 0), "API to set LINK COLLECTIVE IO directly succeeded"); + break; case API_MULTI_HARD: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME,&prop_value); - VRFY((status >= 0),"testing property list get succeeded"); - VRFY((prop_value == 0),"API to set MULTI-CHUNK COLLECTIVE IO optimization succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, &prop_value); + VRFY((status >= 0), "testing property list get succeeded"); + VRFY((prop_value == 0), "API to set MULTI-CHUNK COLLECTIVE IO optimization succeeded"); + break; case API_LINK_TRUE: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME,&prop_value); - VRFY((status >= 0),"testing property list get succeeded"); - VRFY((prop_value == 0),"API to set LINK COLLECTIVE IO succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, &prop_value); + VRFY((status >= 0), "testing property list get succeeded"); + VRFY((prop_value == 0), "API to set LINK COLLECTIVE IO succeeded"); + break; case API_LINK_FALSE: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME,&prop_value); - VRFY((status >= 0),"testing property list get succeeded"); - VRFY((prop_value == 0),"API to set LINK IO transferring to multi-chunk IO succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, &prop_value); + VRFY((status >= 0), "testing property list get succeeded"); + VRFY((prop_value == 0), "API to set LINK IO transferring to multi-chunk IO succeeded"); + break; case API_MULTI_COLL: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME,&prop_value); - VRFY((status >= 0),"testing property list get succeeded"); - VRFY((prop_value == 0),"API to set MULTI-CHUNK COLLECTIVE IO with optimization succeeded"); - break; + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, &prop_value); + VRFY((status >= 0), "testing property list get succeeded"); + VRFY((prop_value == 0), "API to set MULTI-CHUNK COLLECTIVE IO with optimization succeeded"); + break; case API_MULTI_IND: - status = H5Pget(xfer_plist,H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME,&prop_value); - VRFY((status >= 0),"testing property list get succeeded"); - VRFY((prop_value == 0),"API to set MULTI-CHUNK IO transferring to independent IO succeeded"); - break; - - default: - ; - } - } + status = H5Pget(xfer_plist, H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, &prop_value); + VRFY((status >= 0), "testing property list get succeeded"); + VRFY((prop_value == 0), + "API to set MULTI-CHUNK IO transferring to independent IO succeeded"); + break; + + default:; + } + } #endif - status = H5Dclose(dataset); - VRFY((status >= 0),""); - - status = H5Pclose(xfer_plist); - VRFY((status >= 0),"property list closed"); - - status = H5Sclose(file_dataspace); - VRFY((status >= 0),""); - - status = H5Sclose(mem_dataspace); - VRFY((status >= 0),""); - - - status = H5Fclose(file); - VRFY((status >= 0),""); - - if (data_array1) HDfree(data_array1); - - /* Use collective read to verify the correctness of collective write. */ - - /* allocate memory for data buffer */ - data_array1 = (int *)HDmalloc(dims[0]*dims[1]*sizeof(int)); - VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); - - /* allocate memory for data buffer */ - data_origin1 = (int *)HDmalloc(dims[0]*dims[1]*sizeof(int)); - VRFY((data_origin1 != NULL), "data_origin1 malloc succeeded"); - - acc_plist = create_faccess_plist(comm, info, facc_type); - VRFY((acc_plist >= 0),"MPIO creation property list succeeded"); - - file = H5Fopen(filename,H5F_ACC_RDONLY,acc_plist); - VRFY((file >= 0),"H5Fcreate succeeded"); - - status = H5Pclose(acc_plist); - VRFY((status >= 0),""); - - /* open the collective dataset*/ - dataset = H5Dopen2(file, DSET_COLLECTIVE_CHUNK_NAME, H5P_DEFAULT); - VRFY((dataset >= 0), ""); - - /* set up dimensions of the slab this process accesses */ - ccslab_set(mpi_rank, mpi_size, start, count, stride, block, select_factor); - - /* obtain the file and mem dataspace*/ - file_dataspace = H5Dget_space (dataset); - VRFY((file_dataspace >= 0), ""); - - if (ALL != mem_selection) { - mem_dataspace = H5Dget_space (dataset); - VRFY((mem_dataspace >= 0), ""); - } - else { - current_dims = num_points; - mem_dataspace = H5Screate_simple (1, ¤t_dims, NULL); - VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); - } - - switch (file_selection) { - case HYPER: - status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((status >= 0),"hyperslab selection succeeded"); - break; - - case POINT: - if (num_points) { - status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); - VRFY((status >= 0),"Element selection succeeded"); - } - else { - status = H5Sselect_none(file_dataspace); - VRFY((status >= 0),"none selection succeeded"); - } - break; - - case ALL: - status = H5Sselect_all(file_dataspace); - VRFY((status >= 0), "H5Sselect_all succeeded"); - break; - } - - switch (mem_selection) { - case HYPER: - status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((status >= 0),"hyperslab selection succeeded"); - break; - - case POINT: - if (num_points) { - status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); - VRFY((status >= 0),"Element selection succeeded"); - } - else { - status = H5Sselect_none(mem_dataspace); - VRFY((status >= 0),"none selection succeeded"); - } - break; - - case ALL: - status = H5Sselect_all(mem_dataspace); - VRFY((status >= 0), "H5Sselect_all succeeded"); - break; - } - - /* fill dataset with test data */ - ccdataset_fill(start, stride,count,block, data_origin1, mem_selection); - xfer_plist = H5Pcreate (H5P_DATASET_XFER); - VRFY((xfer_plist >= 0),""); - - status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); - VRFY((status>= 0),"MPIO collective transfer property succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - status = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((status>= 0),"set independent IO collectively succeeded"); - } - - status = H5Dread(dataset, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); - VRFY((status >=0),"dataset read succeeded"); - - /* verify the read data with original expected data */ - status = ccdataset_vrfy(start, count, stride, block, data_array1, data_origin1, mem_selection); - if (status) nerrors++; - - status = H5Pclose(xfer_plist); - VRFY((status >= 0),"property list closed"); - - /* close dataset collectively */ - status=H5Dclose(dataset); - VRFY((status >= 0), "H5Dclose"); - - /* release all IDs created */ - status = H5Sclose(file_dataspace); - VRFY((status >= 0),"H5Sclose"); - - status = H5Sclose(mem_dataspace); - VRFY((status >= 0),"H5Sclose"); - - /* close the file collectively */ - status = H5Fclose(file); - VRFY((status >= 0),"H5Fclose"); - - /* release data buffers */ - if(coords) HDfree(coords); - if(data_array1) HDfree(data_array1); - if(data_origin1) HDfree(data_origin1); + status = H5Dclose(dataset); + VRFY((status >= 0), ""); -} + status = H5Pclose(xfer_plist); + VRFY((status >= 0), "property list closed"); + + status = H5Sclose(file_dataspace); + VRFY((status >= 0), ""); + + status = H5Sclose(mem_dataspace); + VRFY((status >= 0), ""); + status = H5Fclose(file); + VRFY((status >= 0), ""); + + if (data_array1) + HDfree(data_array1); + + /* Use collective read to verify the correctness of collective write. */ + + /* allocate memory for data buffer */ + data_array1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); + VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); + + /* allocate memory for data buffer */ + data_origin1 = (int *)HDmalloc(dims[0] * dims[1] * sizeof(int)); + VRFY((data_origin1 != NULL), "data_origin1 malloc succeeded"); + + acc_plist = create_faccess_plist(comm, info, facc_type); + VRFY((acc_plist >= 0), "MPIO creation property list succeeded"); + + file = H5Fopen(filename, H5F_ACC_RDONLY, acc_plist); + VRFY((file >= 0), "H5Fcreate succeeded"); + + status = H5Pclose(acc_plist); + VRFY((status >= 0), ""); + + /* open the collective dataset*/ + dataset = H5Dopen2(file, DSET_COLLECTIVE_CHUNK_NAME, H5P_DEFAULT); + VRFY((dataset >= 0), ""); + + /* set up dimensions of the slab this process accesses */ + ccslab_set(mpi_rank, mpi_size, start, count, stride, block, select_factor); + + /* obtain the file and mem dataspace*/ + file_dataspace = H5Dget_space(dataset); + VRFY((file_dataspace >= 0), ""); + + if (ALL != mem_selection) { + mem_dataspace = H5Dget_space(dataset); + VRFY((mem_dataspace >= 0), ""); + } + else { + current_dims = num_points; + mem_dataspace = H5Screate_simple(1, ¤t_dims, NULL); + VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); + } + + switch (file_selection) { + case HYPER: + status = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((status >= 0), "hyperslab selection succeeded"); + break; + + case POINT: + if (num_points) { + status = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); + VRFY((status >= 0), "Element selection succeeded"); + } + else { + status = H5Sselect_none(file_dataspace); + VRFY((status >= 0), "none selection succeeded"); + } + break; + + case ALL: + status = H5Sselect_all(file_dataspace); + VRFY((status >= 0), "H5Sselect_all succeeded"); + break; + } + + switch (mem_selection) { + case HYPER: + status = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((status >= 0), "hyperslab selection succeeded"); + break; + + case POINT: + if (num_points) { + status = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); + VRFY((status >= 0), "Element selection succeeded"); + } + else { + status = H5Sselect_none(mem_dataspace); + VRFY((status >= 0), "none selection succeeded"); + } + break; + + case ALL: + status = H5Sselect_all(mem_dataspace); + VRFY((status >= 0), "H5Sselect_all succeeded"); + break; + } + + /* fill dataset with test data */ + ccdataset_fill(start, stride, count, block, data_origin1, mem_selection); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); + VRFY((xfer_plist >= 0), ""); + + status = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + VRFY((status >= 0), "MPIO collective transfer property succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + status = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((status >= 0), "set independent IO collectively succeeded"); + } + + status = H5Dread(dataset, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); + VRFY((status >= 0), "dataset read succeeded"); + + /* verify the read data with original expected data */ + status = ccdataset_vrfy(start, count, stride, block, data_array1, data_origin1, mem_selection); + if (status) + nerrors++; + + status = H5Pclose(xfer_plist); + VRFY((status >= 0), "property list closed"); + + /* close dataset collectively */ + status = H5Dclose(dataset); + VRFY((status >= 0), "H5Dclose"); + + /* release all IDs created */ + status = H5Sclose(file_dataspace); + VRFY((status >= 0), "H5Sclose"); + + status = H5Sclose(mem_dataspace); + VRFY((status >= 0), "H5Sclose"); + + /* close the file collectively */ + status = H5Fclose(file); + VRFY((status >= 0), "H5Fclose"); + + /* release data buffers */ + if (coords) + HDfree(coords); + if (data_array1) + HDfree(data_array1); + if (data_origin1) + HDfree(data_origin1); +} /* Set up the selection */ static void -ccslab_set(int mpi_rank, - int mpi_size, - hsize_t start[], - hsize_t count[], - hsize_t stride[], - hsize_t block[], - int mode) +ccslab_set(int mpi_rank, int mpi_size, hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], + int mode) { - switch (mode){ - - case BYROW_CONT: - /* Each process takes a slabs of rows. */ - block[0] = 1; - block[1] = 1; - stride[0] = 1; - stride[1] = 1; - count[0] = SPACE_DIM1; - count[1] = SPACE_DIM2; - start[0] = (hsize_t)mpi_rank*count[0]; - start[1] = 0; - - break; - - case BYROW_DISCONT: - /* Each process takes several disjoint blocks. */ - block[0] = 1; - block[1] = 1; - stride[0] = 3; - stride[1] = 3; - count[0] = SPACE_DIM1/(stride[0]*block[0]); - count[1] = (SPACE_DIM2)/(stride[1]*block[1]); - start[0] = (hsize_t)SPACE_DIM1*(hsize_t)mpi_rank; - start[1] = 0; - - break; - - case BYROW_SELECTNONE: - /* Each process takes a slabs of rows, there are - no selections for the last process. */ - block[0] = 1; - block[1] = 1; - stride[0] = 1; - stride[1] = 1; - count[0] = ((mpi_rank >= MAX(1,(mpi_size-2)))?0:SPACE_DIM1); - count[1] = SPACE_DIM2; - start[0] = (hsize_t)mpi_rank*count[0]; - start[1] = 0; - - break; - - case BYROW_SELECTUNBALANCE: - /* The first one-third of the number of processes only - select top half of the domain, The rest will select the bottom - half of the domain. */ - - block[0] = 1; - count[0] = 2; - stride[0] = (hsize_t)SPACE_DIM1*(hsize_t)mpi_size/4+1; - block[1] = SPACE_DIM2; - count[1] = 1; - start[1] = 0; - stride[1] = 1; - if((mpi_rank *3)<(mpi_size*2)) start[0] = (hsize_t)mpi_rank; - else start[0] = (hsize_t)(1 + SPACE_DIM1*mpi_size/2 + (mpi_rank-2*mpi_size/3)); - break; - - case BYROW_SELECTINCHUNK: - /* Each process will only select one chunk */ - - block[0] = 1; - count[0] = 1; - start[0] = (hsize_t)(mpi_rank*SPACE_DIM1); - stride[0]= 1; - block[1] = SPACE_DIM2; - count[1] = 1; - stride[1]= 1; - start[1] = 0; - - break; - - default: - /* Unknown mode. Set it to cover the whole dataset. */ - block[0] = (hsize_t)SPACE_DIM1*(hsize_t)mpi_size; - block[1] = SPACE_DIM2; - stride[0] = block[0]; - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = 0; - - break; + switch (mode) { + + case BYROW_CONT: + /* Each process takes a slabs of rows. */ + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = SPACE_DIM1; + count[1] = SPACE_DIM2; + start[0] = (hsize_t)mpi_rank * count[0]; + start[1] = 0; + + break; + + case BYROW_DISCONT: + /* Each process takes several disjoint blocks. */ + block[0] = 1; + block[1] = 1; + stride[0] = 3; + stride[1] = 3; + count[0] = SPACE_DIM1 / (stride[0] * block[0]); + count[1] = (SPACE_DIM2) / (stride[1] * block[1]); + start[0] = (hsize_t)SPACE_DIM1 * (hsize_t)mpi_rank; + start[1] = 0; + + break; + + case BYROW_SELECTNONE: + /* Each process takes a slabs of rows, there are + no selections for the last process. */ + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = ((mpi_rank >= MAX(1, (mpi_size - 2))) ? 0 : SPACE_DIM1); + count[1] = SPACE_DIM2; + start[0] = (hsize_t)mpi_rank * count[0]; + start[1] = 0; + + break; + + case BYROW_SELECTUNBALANCE: + /* The first one-third of the number of processes only + select top half of the domain, The rest will select the bottom + half of the domain. */ + + block[0] = 1; + count[0] = 2; + stride[0] = (hsize_t)SPACE_DIM1 * (hsize_t)mpi_size / 4 + 1; + block[1] = SPACE_DIM2; + count[1] = 1; + start[1] = 0; + stride[1] = 1; + if ((mpi_rank * 3) < (mpi_size * 2)) + start[0] = (hsize_t)mpi_rank; + else + start[0] = (hsize_t)(1 + SPACE_DIM1 * mpi_size / 2 + (mpi_rank - 2 * mpi_size / 3)); + break; + + case BYROW_SELECTINCHUNK: + /* Each process will only select one chunk */ + + block[0] = 1; + count[0] = 1; + start[0] = (hsize_t)(mpi_rank * SPACE_DIM1); + stride[0] = 1; + block[1] = SPACE_DIM2; + count[1] = 1; + stride[1] = 1; + start[1] = 0; + + break; + + default: + /* Unknown mode. Set it to cover the whole dataset. */ + block[0] = (hsize_t)SPACE_DIM1 * (hsize_t)mpi_size; + block[1] = SPACE_DIM2; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = 0; + + break; } - if (VERBOSE_MED){ - HDprintf("start[]=(%lu,%lu), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1], - (unsigned long)(block[0]*block[1]*count[0]*count[1])); + if (VERBOSE_MED) { + HDprintf("start[]=(%lu,%lu), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); } } - /* * Fill the dataset with trivial data for testing. * Assume dimension rank is 2. */ static void -ccdataset_fill(hsize_t start[], - hsize_t stride[], - hsize_t count[], - hsize_t block[], - DATATYPE * dataset, +ccdataset_fill(hsize_t start[], hsize_t stride[], hsize_t count[], hsize_t block[], DATATYPE *dataset, int mem_selection) { DATATYPE *dataptr = dataset; DATATYPE *tmptr; - hsize_t i,j,k1,k2,k=0; + hsize_t i, j, k1, k2, k = 0; /* put some trivial data in the data_array */ tmptr = dataptr; @@ -1163,23 +1148,23 @@ ccdataset_fill(hsize_t start[], through the pointer */ for (k1 = 0; k1 < count[0]; k1++) { - for(i = 0; i < block[0]; i++) { - for(k2 = 0; k2 < count[1]; k2++) { - for(j = 0;j < block[1]; j++) { + for (i = 0; i < block[0]; i++) { + for (k2 = 0; k2 < count[1]; k2++) { + for (j = 0; j < block[1]; j++) { - if (ALL != mem_selection) { - dataptr = tmptr + ((start[0]+k1*stride[0]+i)*SPACE_DIM2+ - start[1]+k2*stride[1]+j); - } - else { - dataptr = tmptr + k; - k++; - } + if (ALL != mem_selection) { + dataptr = tmptr + ((start[0] + k1 * stride[0] + i) * SPACE_DIM2 + start[1] + + k2 * stride[1] + j); + } + else { + dataptr = tmptr + k; + k++; + } - *dataptr = (DATATYPE)(k1+k2+i+j); - } + *dataptr = (DATATYPE)(k1 + k2 + i + j); + } + } } - } } } @@ -1187,83 +1172,75 @@ ccdataset_fill(hsize_t start[], * Print the first block of the content of the dataset. */ static void -ccdataset_print(hsize_t start[], - hsize_t block[], - DATATYPE * dataset) +ccdataset_print(hsize_t start[], hsize_t block[], DATATYPE *dataset) { DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* print the column heading */ HDprintf("Print only the first block of the dataset\n"); HDprintf("%-8s", "Cols:"); - for (j=0; j < block[1]; j++){ - HDprintf("%3lu ", (unsigned long)(start[1]+j)); + for (j = 0; j < block[1]; j++) { + HDprintf("%3lu ", (unsigned long)(start[1] + j)); } HDprintf("\n"); /* print the slab data */ - for (i=0; i < block[0]; i++){ - HDprintf("Row %2lu: ", (unsigned long)(i+start[0])); - for (j=0; j < block[1]; j++){ - HDprintf("%03d ", *dataptr++); - } - HDprintf("\n"); + for (i = 0; i < block[0]; i++) { + HDprintf("Row %2lu: ", (unsigned long)(i + start[0])); + for (j = 0; j < block[1]; j++) { + HDprintf("%03d ", *dataptr++); + } + HDprintf("\n"); } } - /* * Print the content of the dataset. */ static int -ccdataset_vrfy(hsize_t start[], - hsize_t count[], - hsize_t stride[], - hsize_t block[], - DATATYPE *dataset, - DATATYPE *original, - int mem_selection) +ccdataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, + DATATYPE *original, int mem_selection) { - hsize_t i, j,k1,k2,k=0; - int vrfyerrs; - DATATYPE *dataptr,*oriptr; + hsize_t i, j, k1, k2, k = 0; + int vrfyerrs; + DATATYPE *dataptr, *oriptr; /* print it if VERBOSE_MED */ if (VERBOSE_MED) { - HDprintf("dataset_vrfy dumping:::\n"); - HDprintf("start(%lu, %lu), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1]); - HDprintf("original values:\n"); - ccdataset_print(start, block, original); - HDprintf("compared values:\n"); - ccdataset_print(start, block, dataset); + HDprintf("dataset_vrfy dumping:::\n"); + HDprintf("start(%lu, %lu), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1]); + HDprintf("original values:\n"); + ccdataset_print(start, block, original); + HDprintf("compared values:\n"); + ccdataset_print(start, block, dataset); } vrfyerrs = 0; - for (k1=0;k1 MAX_ERR_REPORT && !VERBOSE_MED) - HDprintf("[more errors ...]\n"); + HDprintf("[more errors ...]\n"); if (vrfyerrs) - HDprintf("%d errors found in ccdataset_vrfy\n", vrfyerrs); - return(vrfyerrs); + HDprintf("%d errors found in ccdataset_vrfy\n", vrfyerrs); + return (vrfyerrs); } diff --git a/testpar/t_coll_md_read.c b/testpar/t_coll_md_read.c index d4aaa2e..4439b0d 100644 --- a/testpar/t_coll_md_read.c +++ b/testpar/t_coll_md_read.c @@ -27,17 +27,17 @@ * an if (mpi_rank == 0) check. */ #define PARTIAL_NO_SELECTION_NO_SEL_PROCESS (mpi_rank == mpi_size - 1) -#define PARTIAL_NO_SELECTION_DATASET_NAME "partial_no_selection_dset" -#define PARTIAL_NO_SELECTION_DATASET_NDIMS 2 -#define PARTIAL_NO_SELECTION_Y_DIM_SCALE 5 -#define PARTIAL_NO_SELECTION_X_DIM_SCALE 5 +#define PARTIAL_NO_SELECTION_DATASET_NAME "partial_no_selection_dset" +#define PARTIAL_NO_SELECTION_DATASET_NDIMS 2 +#define PARTIAL_NO_SELECTION_Y_DIM_SCALE 5 +#define PARTIAL_NO_SELECTION_X_DIM_SCALE 5 #define MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS 2 -#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DATASET_NAME "linked_chunk_io_sort_chunk_issue" -#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_Y_DIM_SCALE 20000 -#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE 1 -#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS 1 +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DATASET_NAME "linked_chunk_io_sort_chunk_issue" +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_Y_DIM_SCALE 20000 +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE 1 +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS 1 /* * A test for issue HDFFV-10501. A parallel hang was reported which occurred @@ -53,27 +53,29 @@ * can simply be removed and the address used for the read/write can be set to an * arbitrary number (0 was chosen). */ -void test_partial_no_selection_coll_md_read(void) +void +test_partial_no_selection_coll_md_read(void) { const char *filename; - hsize_t *dataset_dims = NULL; + hsize_t * dataset_dims = NULL; hsize_t max_dataset_dims[PARTIAL_NO_SELECTION_DATASET_NDIMS]; hsize_t sel_dims[1]; - hsize_t chunk_dims[PARTIAL_NO_SELECTION_DATASET_NDIMS] = { PARTIAL_NO_SELECTION_Y_DIM_SCALE, PARTIAL_NO_SELECTION_X_DIM_SCALE }; + hsize_t chunk_dims[PARTIAL_NO_SELECTION_DATASET_NDIMS] = {PARTIAL_NO_SELECTION_Y_DIM_SCALE, + PARTIAL_NO_SELECTION_X_DIM_SCALE}; hsize_t start[PARTIAL_NO_SELECTION_DATASET_NDIMS]; hsize_t stride[PARTIAL_NO_SELECTION_DATASET_NDIMS]; hsize_t count[PARTIAL_NO_SELECTION_DATASET_NDIMS]; hsize_t block[PARTIAL_NO_SELECTION_DATASET_NDIMS]; - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t dxpl_id = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; hid_t fspace_id = H5I_INVALID_HID; hid_t mspace_id = H5I_INVALID_HID; int mpi_rank, mpi_size; - void *data = NULL; - void *read_buf = NULL; + void * data = NULL; + void * read_buf = NULL; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); @@ -96,8 +98,8 @@ void test_partial_no_selection_coll_md_read(void) dataset_dims = HDmalloc(PARTIAL_NO_SELECTION_DATASET_NDIMS * sizeof(*dataset_dims)); VRFY((dataset_dims != NULL), "malloc succeeded"); - dataset_dims[0] = (hsize_t)PARTIAL_NO_SELECTION_Y_DIM_SCALE * (hsize_t)mpi_size; - dataset_dims[1] = (hsize_t)PARTIAL_NO_SELECTION_X_DIM_SCALE * (hsize_t)mpi_size; + dataset_dims[0] = (hsize_t)PARTIAL_NO_SELECTION_Y_DIM_SCALE * (hsize_t)mpi_size; + dataset_dims[1] = (hsize_t)PARTIAL_NO_SELECTION_X_DIM_SCALE * (hsize_t)mpi_size; max_dataset_dims[0] = H5S_UNLIMITED; max_dataset_dims[1] = H5S_UNLIMITED; @@ -110,9 +112,11 @@ void test_partial_no_selection_coll_md_read(void) dcpl_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((dcpl_id >= 0), "H5Pcreate succeeded"); - VRFY((H5Pset_chunk(dcpl_id, PARTIAL_NO_SELECTION_DATASET_NDIMS, chunk_dims) >= 0), "H5Pset_chunk succeeded"); + VRFY((H5Pset_chunk(dcpl_id, PARTIAL_NO_SELECTION_DATASET_NDIMS, chunk_dims) >= 0), + "H5Pset_chunk succeeded"); - dset_id = H5Dcreate2(file_id, PARTIAL_NO_SELECTION_DATASET_NAME, H5T_NATIVE_INT, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, PARTIAL_NO_SELECTION_DATASET_NAME, H5T_NATIVE_INT, fspace_id, H5P_DEFAULT, + dcpl_id, H5P_DEFAULT); VRFY((dset_id >= 0), "H5Dcreate2 succeeded"); /* @@ -120,23 +124,25 @@ void test_partial_no_selection_coll_md_read(void) * * The ranks will write rows across the dataset. */ - start[0] = (hsize_t)PARTIAL_NO_SELECTION_Y_DIM_SCALE * (hsize_t)mpi_rank; - start[1] = 0; + start[0] = (hsize_t)PARTIAL_NO_SELECTION_Y_DIM_SCALE * (hsize_t)mpi_rank; + start[1] = 0; stride[0] = PARTIAL_NO_SELECTION_Y_DIM_SCALE; stride[1] = PARTIAL_NO_SELECTION_X_DIM_SCALE; - count[0] = 1; - count[1] = (hsize_t)mpi_size; - block[0] = PARTIAL_NO_SELECTION_Y_DIM_SCALE; - block[1] = PARTIAL_NO_SELECTION_X_DIM_SCALE; + count[0] = 1; + count[1] = (hsize_t)mpi_size; + block[0] = PARTIAL_NO_SELECTION_Y_DIM_SCALE; + block[1] = PARTIAL_NO_SELECTION_X_DIM_SCALE; - VRFY((H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) >= 0), "H5Sselect_hyperslab succeeded"); + VRFY((H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) >= 0), + "H5Sselect_hyperslab succeeded"); sel_dims[0] = count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE); mspace_id = H5Screate_simple(1, sel_dims, NULL); VRFY((mspace_id >= 0), "H5Screate_simple succeeded"); - data = HDcalloc(1, count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int)); + data = HDcalloc(1, count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * + sizeof(int)); VRFY((data != NULL), "calloc succeeded"); dxpl_id = H5Pcreate(H5P_DATASET_XFER); @@ -156,9 +162,11 @@ void test_partial_no_selection_coll_md_read(void) * the particular code path where the issue lies and we don't * want the library doing multi-chunk I/O behind our backs. */ - VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_ONE_IO) >= 0), "H5Pset_dxpl_mpio_chunk_opt succeeded"); + VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_ONE_IO) >= 0), + "H5Pset_dxpl_mpio_chunk_opt succeeded"); - read_buf = HDmalloc(count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int)); + read_buf = HDmalloc(count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * + sizeof(int)); VRFY((read_buf != NULL), "malloc succeeded"); /* @@ -172,13 +180,17 @@ void test_partial_no_selection_coll_md_read(void) /* * Finally have each rank read their section of data back from the dataset. */ - VRFY((H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, dxpl_id, read_buf) >= 0), "H5Dread succeeded"); + VRFY((H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, dxpl_id, read_buf) >= 0), + "H5Dread succeeded"); /* * Check data integrity just to be sure. */ if (!PARTIAL_NO_SELECTION_NO_SEL_PROCESS) { - VRFY((!HDmemcmp(data, read_buf, count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int))), "memcmp succeeded"); + VRFY((!HDmemcmp(data, read_buf, + count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * + sizeof(int))), + "memcmp succeeded"); } if (dataset_dims) { @@ -218,40 +230,35 @@ void test_partial_no_selection_coll_md_read(void) * major: Internal error (too specific to document in detail) * minor: Some MPI function failed * #009: H5Dmpio.c line 2546 in H5D__obtain_mpio_mode(): Message truncated, error stack: - *PMPI_Bcast(1600)..................: MPI_Bcast(buf=0x1df98e0, count=18, MPI_BYTE, root=0, comm=0x84000006) failed - *MPIR_Bcast_impl(1452).............: - *MPIR_Bcast(1476)..................: + *PMPI_Bcast(1600)..................: MPI_Bcast(buf=0x1df98e0, count=18, MPI_BYTE, root=0, comm=0x84000006) + *failed MPIR_Bcast_impl(1452).............: MPIR_Bcast(1476)..................: *MPIR_Bcast_intra(1249)............: *MPIR_SMP_Bcast(1088)..............: *MPIR_Bcast_binomial(239)..........: - *MPIDI_CH3U_Receive_data_found(131): Message from rank 0 and tag 2 truncated; 2616 bytes received but buffer size is 18 - * major: Internal error (too specific to document in detail) - * minor: MPI Error String + *MPIDI_CH3U_Receive_data_found(131): Message from rank 0 and tag 2 truncated; 2616 bytes received but buffer + *size is 18 major: Internal error (too specific to document in detail) minor: MPI Error String * */ -void test_multi_chunk_io_addrmap_issue(void) +void +test_multi_chunk_io_addrmap_issue(void) { const char *filename; - hsize_t start[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; - hsize_t stride[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; - hsize_t count[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; - hsize_t block[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; - hsize_t dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {10, 5}; - hsize_t chunk_dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {5, 5}; - hsize_t max_dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {H5S_UNLIMITED, H5S_UNLIMITED}; - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t dxpl_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - void *read_buf = NULL; - int mpi_rank; - int data[5][5] = { {0, 1, 2, 3, 4}, - {0, 1, 2, 3, 4}, - {0, 1, 2, 3, 4}, - {0, 1, 2, 3, 4}, - {0, 1, 2, 3, 4} }; + hsize_t start[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; + hsize_t stride[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; + hsize_t count[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; + hsize_t block[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; + hsize_t dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {10, 5}; + hsize_t chunk_dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {5, 5}; + hsize_t max_dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + void * read_buf = NULL; + int mpi_rank; + int data[5][5] = {{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}}; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -276,7 +283,8 @@ void test_multi_chunk_io_addrmap_issue(void) dcpl_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((dcpl_id >= 0), "H5Pcreate succeeded"); - VRFY((H5Pset_chunk(dcpl_id, MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS, chunk_dims) >= 0), "H5Pset_chunk succeeded"); + VRFY((H5Pset_chunk(dcpl_id, MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS, chunk_dims) >= 0), + "H5Pset_chunk succeeded"); dset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); VRFY((dset_id >= 0), "H5Dcreate2 succeeded"); @@ -285,9 +293,10 @@ void test_multi_chunk_io_addrmap_issue(void) VRFY((dxpl_id >= 0), "H5Pcreate succeeded"); VRFY((H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) >= 0), "H5Pset_dxpl_mpio succeeded"); - VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_MULTI_IO) >= 0), "H5Pset_dxpl_mpio_chunk_opt succeeded"); + VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_MULTI_IO) >= 0), + "H5Pset_dxpl_mpio_chunk_opt succeeded"); - start[1] = 0; + start[1] = 0; stride[0] = stride[1] = 1; count[0] = count[1] = 5; block[0] = block[1] = 1; @@ -297,7 +306,8 @@ void test_multi_chunk_io_addrmap_issue(void) else start[0] = 5; - VRFY((H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, stride, count, block) >= 0), "H5Sselect_hyperslab succeeded"); + VRFY((H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, stride, count, block) >= 0), + "H5Sselect_hyperslab succeeded"); if (mpi_rank != 0) VRFY((H5Sselect_none(space_id) >= 0), "H5Sselect_none succeeded"); @@ -358,31 +368,31 @@ void test_multi_chunk_io_addrmap_issue(void) *MPIR_Bcast(1476)........: *MPIR_Bcast_intra(1249)..: *MPIR_SMP_Bcast(1088)....: - *MPIR_Bcast_binomial(250): message sizes do not match across processes in the collective routine: Received 2096 but expected 320000 - * major: Internal error (too specific to document in detail) - * minor: MPI Error String + *MPIR_Bcast_binomial(250): message sizes do not match across processes in the collective routine: Received + *2096 but expected 320000 major: Internal error (too specific to document in detail) minor: MPI Error String */ -void test_link_chunk_io_sort_chunk_issue(void) +void +test_link_chunk_io_sort_chunk_issue(void) { const char *filename; - hsize_t *dataset_dims = NULL; - hsize_t max_dataset_dims[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; - hsize_t sel_dims[1]; - hsize_t chunk_dims[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS] = { LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS }; - hsize_t start[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; - hsize_t stride[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; - hsize_t count[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; - hsize_t block[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; - hid_t file_id = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t dxpl_id = H5I_INVALID_HID; - hid_t fspace_id = H5I_INVALID_HID; - hid_t mspace_id = H5I_INVALID_HID; - int mpi_rank, mpi_size; - void *data = NULL; - void *read_buf = NULL; + hsize_t * dataset_dims = NULL; + hsize_t max_dataset_dims[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hsize_t sel_dims[1]; + hsize_t chunk_dims[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS] = {LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS}; + hsize_t start[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hsize_t stride[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hsize_t count[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hsize_t block[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID; + int mpi_rank, mpi_size; + void * data = NULL; + void * read_buf = NULL; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); @@ -405,7 +415,8 @@ void test_link_chunk_io_sort_chunk_issue(void) dataset_dims = HDmalloc(LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS * sizeof(*dataset_dims)); VRFY((dataset_dims != NULL), "malloc succeeded"); - dataset_dims[0] = (hsize_t)LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE * (hsize_t)mpi_size * (hsize_t)LINK_CHUNK_IO_SORT_CHUNK_ISSUE_Y_DIM_SCALE; + dataset_dims[0] = (hsize_t)LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE * (hsize_t)mpi_size * + (hsize_t)LINK_CHUNK_IO_SORT_CHUNK_ISSUE_Y_DIM_SCALE; max_dataset_dims[0] = H5S_UNLIMITED; fspace_id = H5Screate_simple(LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS, dataset_dims, max_dataset_dims); @@ -417,9 +428,11 @@ void test_link_chunk_io_sort_chunk_issue(void) dcpl_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((dcpl_id >= 0), "H5Pcreate succeeded"); - VRFY((H5Pset_chunk(dcpl_id, LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS, chunk_dims) >= 0), "H5Pset_chunk succeeded"); + VRFY((H5Pset_chunk(dcpl_id, LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS, chunk_dims) >= 0), + "H5Pset_chunk succeeded"); - dset_id = H5Dcreate2(file_id, LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DATASET_NAME, H5T_NATIVE_INT, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DATASET_NAME, H5T_NATIVE_INT, fspace_id, + H5P_DEFAULT, dcpl_id, H5P_DEFAULT); VRFY((dset_id >= 0), "H5Dcreate2 succeeded"); /* @@ -428,11 +441,12 @@ void test_link_chunk_io_sort_chunk_issue(void) * The ranks will write rows across the dataset. */ stride[0] = LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE; - count[0] = (dataset_dims[0] / LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE) / (hsize_t)mpi_size; - start[0] = count[0] * (hsize_t)mpi_rank; - block[0] = LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE; + count[0] = (dataset_dims[0] / LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE) / (hsize_t)mpi_size; + start[0] = count[0] * (hsize_t)mpi_rank; + block[0] = LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE; - VRFY((H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) >= 0), "H5Sselect_hyperslab succeeded"); + VRFY((H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) >= 0), + "H5Sselect_hyperslab succeeded"); sel_dims[0] = count[0] * (LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE); @@ -459,12 +473,14 @@ void test_link_chunk_io_sort_chunk_issue(void) * the particular code path where the issue lies and we don't * want the library doing multi-chunk I/O behind our backs. */ - VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_ONE_IO) >= 0), "H5Pset_dxpl_mpio_chunk_opt succeeded"); + VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_ONE_IO) >= 0), + "H5Pset_dxpl_mpio_chunk_opt succeeded"); read_buf = HDmalloc(count[0] * (LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE) * sizeof(int)); VRFY((read_buf != NULL), "malloc succeeded"); - VRFY((H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) >= 0), "H5Sselect_hyperslab succeeded"); + VRFY((H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) >= 0), + "H5Sselect_hyperslab succeeded"); sel_dims[0] = count[0] * (LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE); @@ -479,7 +495,8 @@ void test_link_chunk_io_sort_chunk_issue(void) /* * Finally have each rank read their section of data back from the dataset. */ - VRFY((H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, dxpl_id, read_buf) >= 0), "H5Dread succeeded"); + VRFY((H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, dxpl_id, read_buf) >= 0), + "H5Dread succeeded"); if (dataset_dims) { HDfree(dataset_dims); diff --git a/testpar/t_dset.c b/testpar/t_dset.c index 13f9e89..ec1ecf7 100644 --- a/testpar/t_dset.c +++ b/testpar/t_dset.c @@ -42,131 +42,128 @@ * ZCOL same as BYCOL except process 0 gets 0 columns */ static void -slab_set(int mpi_rank, int mpi_size, hsize_t start[], hsize_t count[], - hsize_t stride[], hsize_t block[], int mode) +slab_set(int mpi_rank, int mpi_size, hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], + int mode) { switch (mode) { - case BYROW: - /* Each process takes a slabs of rows. */ - block[0] = (hsize_t)(dim0 / mpi_size); - block[1] = (hsize_t)dim1; - stride[0] = block[0]; - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)mpi_rank * block[0]; - start[1] = 0; - if (VERBOSE_MED) - HDprintf("slab_set BYROW\n"); - break; - case BYCOL: - /* Each process takes a block of columns. */ - block[0] = (hsize_t)dim0; - block[1] = (hsize_t)(dim1 / mpi_size); - stride[0] = block[0]; - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = (hsize_t)mpi_rank * block[1]; - if (VERBOSE_MED) - HDprintf("slab_set BYCOL\n"); - break; - case ZROW: - /* Similar to BYROW except process 0 gets 0 row */ - block[0] = (hsize_t)(mpi_rank ? dim0 / mpi_size : 0); - block[1] = (hsize_t)dim1; - stride[0] = (mpi_rank ? block[0] : 1); /* avoid setting stride to 0 */ - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (mpi_rank ? (hsize_t)mpi_rank * block[0] : 0); - start[1] = 0; - if (VERBOSE_MED) - HDprintf("slab_set ZROW\n"); - break; - case ZCOL: - /* Similar to BYCOL except process 0 gets 0 column */ - block[0] = (hsize_t)dim0; - block[1] = (hsize_t)(mpi_rank ? dim1 / mpi_size : 0); - stride[0] = block[0]; - stride[1] = (hsize_t)(mpi_rank ? block[1] : 1); /* avoid setting stride to 0 */ - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = (mpi_rank ? (hsize_t)mpi_rank * block[1] : 0); - if (VERBOSE_MED) - HDprintf("slab_set ZCOL\n"); - break; - default: - /* Unknown mode. Set it to cover the whole dataset. */ - HDprintf("unknown slab_set mode (%d)\n", mode); - block[0] = (hsize_t)dim0; - block[1] = (hsize_t)dim1; - stride[0] = block[0]; - stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = 0; - start[1] = 0; - if (VERBOSE_MED) - HDprintf("slab_set wholeset\n"); - break; + case BYROW: + /* Each process takes a slabs of rows. */ + block[0] = (hsize_t)(dim0 / mpi_size); + block[1] = (hsize_t)dim1; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)mpi_rank * block[0]; + start[1] = 0; + if (VERBOSE_MED) + HDprintf("slab_set BYROW\n"); + break; + case BYCOL: + /* Each process takes a block of columns. */ + block[0] = (hsize_t)dim0; + block[1] = (hsize_t)(dim1 / mpi_size); + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = (hsize_t)mpi_rank * block[1]; + if (VERBOSE_MED) + HDprintf("slab_set BYCOL\n"); + break; + case ZROW: + /* Similar to BYROW except process 0 gets 0 row */ + block[0] = (hsize_t)(mpi_rank ? dim0 / mpi_size : 0); + block[1] = (hsize_t)dim1; + stride[0] = (mpi_rank ? block[0] : 1); /* avoid setting stride to 0 */ + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = (mpi_rank ? (hsize_t)mpi_rank * block[0] : 0); + start[1] = 0; + if (VERBOSE_MED) + HDprintf("slab_set ZROW\n"); + break; + case ZCOL: + /* Similar to BYCOL except process 0 gets 0 column */ + block[0] = (hsize_t)dim0; + block[1] = (hsize_t)(mpi_rank ? dim1 / mpi_size : 0); + stride[0] = block[0]; + stride[1] = (hsize_t)(mpi_rank ? block[1] : 1); /* avoid setting stride to 0 */ + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = (mpi_rank ? (hsize_t)mpi_rank * block[1] : 0); + if (VERBOSE_MED) + HDprintf("slab_set ZCOL\n"); + break; + default: + /* Unknown mode. Set it to cover the whole dataset. */ + HDprintf("unknown slab_set mode (%d)\n", mode); + block[0] = (hsize_t)dim0; + block[1] = (hsize_t)dim1; + stride[0] = block[0]; + stride[1] = block[1]; + count[0] = 1; + count[1] = 1; + start[0] = 0; + start[1] = 0; + if (VERBOSE_MED) + HDprintf("slab_set wholeset\n"); + break; } if (VERBOSE_MED) { - HDprintf( - "start[]=(%lu,%lu), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total datapoints=%lu\n", - (unsigned long) start[0], (unsigned long) start[1], - (unsigned long) count[0], (unsigned long) count[1], - (unsigned long) stride[0], (unsigned long) stride[1], - (unsigned long) block[0], (unsigned long) block[1], - (unsigned long) (block[0] * block[1] * count[0] * count[1])); + HDprintf("start[]=(%lu,%lu), count[]=(%lu,%lu), stride[]=(%lu,%lu), block[]=(%lu,%lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); } } /* * Setup the coordinates for point selection. */ -void point_set(hsize_t start[], - hsize_t count[], - hsize_t stride[], - hsize_t block[], - size_t num_points, - hsize_t coords[], - int order) +void +point_set(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], size_t num_points, + hsize_t coords[], int order) { - hsize_t i,j, k = 0, m ,n, s1 ,s2; + hsize_t i, j, k = 0, m, n, s1, s2; HDcompile_assert(RANK == 2); - if(OUT_OF_ORDER == order) + if (OUT_OF_ORDER == order) k = (num_points * RANK) - 1; - else if(IN_ORDER == order) + else if (IN_ORDER == order) k = 0; s1 = start[0]; s2 = start[1]; - for(i = 0 ; i < count[0]; i++) - for(j = 0 ; j < count[1]; j++) - for(m = 0 ; m < block[0]; m++) - for(n = 0 ; n < block[1]; n++) - if(OUT_OF_ORDER == order) { + for (i = 0; i < count[0]; i++) + for (j = 0; j < count[1]; j++) + for (m = 0; m < block[0]; m++) + for (n = 0; n < block[1]; n++) + if (OUT_OF_ORDER == order) { coords[k--] = s2 + (stride[1] * j) + n; coords[k--] = s1 + (stride[0] * i) + m; } - else if(IN_ORDER == order) { + else if (IN_ORDER == order) { coords[k++] = s1 + stride[0] * i + m; coords[k++] = s2 + stride[1] * j + n; } - if(VERBOSE_MED) { - HDprintf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total datapoints=%lu\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1], - (unsigned long)(block[0] * block[1] * count[0] * count[1])); + if (VERBOSE_MED) { + HDprintf("start[]=(%lu, %lu), count[]=(%lu, %lu), stride[]=(%lu, %lu), block[]=(%lu, %lu), total " + "datapoints=%lu\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1], + (unsigned long)(block[0] * block[1] * count[0] * count[1])); k = 0; - for(i = 0; i < num_points ; i++) { + for (i = 0; i < num_points; i++) { HDprintf("(%d, %d)\n", (int)coords[k], (int)coords[k + 1]); k += 2; } @@ -178,92 +175,90 @@ void point_set(hsize_t start[], * Assume dimension rank is 2 and data is stored contiguous. */ static void -dataset_fill(hsize_t start[], hsize_t block[], DATATYPE * dataset) +dataset_fill(hsize_t start[], hsize_t block[], DATATYPE *dataset) { DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* put some trivial data in the data_array */ - for (i=0; i < block[0]; i++){ - for (j=0; j < block[1]; j++){ - *dataptr = (DATATYPE)((i+start[0])*100 + (j+start[1]+1)); - dataptr++; - } + for (i = 0; i < block[0]; i++) { + for (j = 0; j < block[1]; j++) { + *dataptr = (DATATYPE)((i + start[0]) * 100 + (j + start[1] + 1)); + dataptr++; + } } } - /* * Print the content of the dataset. */ static void -dataset_print(hsize_t start[], hsize_t block[], DATATYPE * dataset) +dataset_print(hsize_t start[], hsize_t block[], DATATYPE *dataset) { DATATYPE *dataptr = dataset; - hsize_t i, j; + hsize_t i, j; /* print the column heading */ HDprintf("%-8s", "Cols:"); - for (j=0; j < block[1]; j++){ - HDprintf("%3lu ", (unsigned long)(start[1]+j)); + for (j = 0; j < block[1]; j++) { + HDprintf("%3lu ", (unsigned long)(start[1] + j)); } HDprintf("\n"); /* print the slab data */ - for (i=0; i < block[0]; i++){ - HDprintf("Row %2lu: ", (unsigned long)(i+start[0])); - for (j=0; j < block[1]; j++){ - HDprintf("%03d ", *dataptr++); - } - HDprintf("\n"); + for (i = 0; i < block[0]; i++) { + HDprintf("Row %2lu: ", (unsigned long)(i + start[0])); + for (j = 0; j < block[1]; j++) { + HDprintf("%03d ", *dataptr++); + } + HDprintf("\n"); } } - /* * Print the content of the dataset. */ int -dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, DATATYPE *original) +dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, + DATATYPE *original) { hsize_t i, j; - int vrfyerrs; + int vrfyerrs; /* print it if VERBOSE_MED */ - if(VERBOSE_MED) { - HDprintf("dataset_vrfy dumping:::\n"); - HDprintf("start(%lu, %lu), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n", - (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], (unsigned long)count[1], - (unsigned long)stride[0], (unsigned long)stride[1], (unsigned long)block[0], (unsigned long)block[1]); - HDprintf("original values:\n"); - dataset_print(start, block, original); - HDprintf("compared values:\n"); - dataset_print(start, block, dataset); + if (VERBOSE_MED) { + HDprintf("dataset_vrfy dumping:::\n"); + HDprintf("start(%lu, %lu), count(%lu, %lu), stride(%lu, %lu), block(%lu, %lu)\n", + (unsigned long)start[0], (unsigned long)start[1], (unsigned long)count[0], + (unsigned long)count[1], (unsigned long)stride[0], (unsigned long)stride[1], + (unsigned long)block[0], (unsigned long)block[1]); + HDprintf("original values:\n"); + dataset_print(start, block, original); + HDprintf("compared values:\n"); + dataset_print(start, block, dataset); } vrfyerrs = 0; - for (i=0; i < block[0]; i++){ - for (j=0; j < block[1]; j++){ - if(*dataset != *original){ - if(vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED){ - HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n", - (unsigned long)i, (unsigned long)j, - (unsigned long)(i+start[0]), (unsigned long)(j+start[1]), - *(original), *(dataset)); - } - dataset++; - original++; + for (i = 0; i < block[0]; i++) { + for (j = 0; j < block[1]; j++) { + if (*dataset != *original) { + if (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED) { + HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n", + (unsigned long)i, (unsigned long)j, (unsigned long)(i + start[0]), + (unsigned long)(j + start[1]), *(original), *(dataset)); + } + dataset++; + original++; + } } } - } - if(vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) - HDprintf("[more errors ...]\n"); - if(vrfyerrs) - HDprintf("%d errors found in dataset_vrfy\n", vrfyerrs); - return(vrfyerrs); + if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) + HDprintf("[more errors ...]\n"); + if (vrfyerrs) + HDprintf("%d errors found in dataset_vrfy\n", vrfyerrs); + return (vrfyerrs); } - /* * Part 1.a--Independent read/write for fixed dimension datasets. */ @@ -279,36 +274,36 @@ dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[] void dataset_writeInd(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t sid; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - hsize_t dims[RANK]; /* dataset dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t sid; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + hsize_t dims[RANK]; /* dataset dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ const char *filename; - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Independent write test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Independent write test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); /* ---------------------------------------- @@ -326,7 +321,6 @@ dataset_writeInd(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* --------------------------------------------- * Define the dimensions of the overall datasets * and the slabs local to the MPI process. @@ -334,21 +328,17 @@ dataset_writeInd(void) /* setup dimensionality object */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); - /* create a dataset collectively */ - dataset1 = H5Dcreate2(fid, DATASETNAME1, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset1 = H5Dcreate2(fid, DATASETNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset1 >= 0), "H5Dcreate2 succeeded"); /* create another dataset collectively */ - dataset2 = H5Dcreate2(fid, DATASETNAME2, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset2 = H5Dcreate2(fid, DATASETNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset2 >= 0), "H5Dcreate2 succeeded"); - /* * To test the independent orders of writes between processes, all * even number processes write to dataset1 first, then dataset2. @@ -363,43 +353,40 @@ dataset_writeInd(void) MESG("data_array initialized"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* write data independently */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded"); /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dwrite dataset2 succeeded"); /* setup dimensions again to write with zero rows for process 0 */ - if(VERBOSE_MED) - HDprintf("writeInd by some with zero row\n"); + if (VERBOSE_MED) + HDprintf("writeInd by some with zero row\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZROW); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("writeInd by some with zero row"); -if((mpi_rank/2)*2 != mpi_rank){ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); - VRFY((ret >= 0), "H5Dwrite dataset1 by ZROW succeeded"); -} + if ((mpi_rank / 2) * 2 != mpi_rank) { + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); + VRFY((ret >= 0), "H5Dwrite dataset1 by ZROW succeeded"); + } #ifdef BARRIER_CHECKS -MPI_Barrier(MPI_COMM_WORLD); + MPI_Barrier(MPI_COMM_WORLD); #endif /* BARRIER_CHECKS */ /* release dataspace ID */ @@ -418,44 +405,45 @@ MPI_Barrier(MPI_COMM_WORLD); H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); + if (data_array1) + HDfree(data_array1); } /* Example of using the parallel HDF5 library to read a dataset */ void dataset_readInd(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - DATATYPE *data_array1 = NULL; /* data buffer */ - DATATYPE *data_origin1 = NULL; /* expected data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + DATATYPE * data_array1 = NULL; /* data buffer */ + DATATYPE * data_origin1 = NULL; /* expected data buffer */ const char *filename; - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Independent read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Independent read test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 HDmalloc succeeded"); /* setup file access template */ @@ -478,40 +466,39 @@ dataset_readInd(void) dataset2 = H5Dopen2(fid, DATASETNAME1, H5P_DEFAULT); VRFY((dataset2 >= 0), ""); - /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); /* read data independently */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), ""); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* read data independently */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), ""); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* close dataset collectively */ ret = H5Dclose(dataset1); @@ -526,11 +513,12 @@ dataset_readInd(void) H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); - if(data_origin1) HDfree(data_origin1); + if (data_array1) + HDfree(data_array1); + if (data_origin1) + HDfree(data_origin1); } - /* * Part 1.b--Collective read/write for fixed dimension datasets. */ @@ -547,48 +535,48 @@ dataset_readInd(void) void dataset_writeAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t sid; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2, dataset3, dataset4; /* Dataset ID */ - hid_t dataset5, dataset6, dataset7; /* Dataset ID */ - hid_t datatype; /* Datatype ID */ - hsize_t dims[RANK]; /* dataset dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t sid; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2, dataset3, dataset4; /* Dataset ID */ + hid_t dataset5, dataset6, dataset7; /* Dataset ID */ + hid_t datatype; /* Datatype ID */ + hsize_t dims[RANK]; /* dataset dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ const char *filename; - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ - size_t num_points; /* for point selection */ - hsize_t *coords = NULL; /* for point selection */ - hsize_t current_dims; /* for point selection */ + size_t num_points; /* for point selection */ + hsize_t *coords = NULL; /* for point selection */ + hsize_t current_dims; /* for point selection */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Collective write test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Collective write test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* set up the coords array selection */ num_points = (size_t)dim1; - coords = (hsize_t *)HDmalloc((size_t)dim1 * (size_t)RANK * sizeof(hsize_t)); + coords = (hsize_t *)HDmalloc((size_t)dim1 * (size_t)RANK * sizeof(hsize_t)); VRFY((coords != NULL), "coords malloc succeeded"); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); /* ------------------- @@ -606,7 +594,6 @@ dataset_writeAll(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* -------------------------- * Define the dimensions of the overall datasets * and create the dataset @@ -614,17 +601,16 @@ dataset_writeAll(void) /* setup 2-D dimensionality object */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); - /* create a dataset collectively */ dataset1 = H5Dcreate2(fid, DATASETNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset1 >= 0), "H5Dcreate2 succeeded"); /* create another dataset collectively */ datatype = H5Tcopy(H5T_NATIVE_INT); - ret = H5Tset_order(datatype, H5T_ORDER_LE); + ret = H5Tset_order(datatype, H5T_ORDER_LE); VRFY((ret >= 0), "H5Tset_order succeeded"); dataset2 = H5Dcreate2(fid, DATASETNAME2, datatype, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -663,54 +649,51 @@ dataset_writeAll(void) slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill the local slab with some trivial data */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* write data collectively */ MESG("writeAll by Row"); - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded"); /* setup dimensions again to writeAll with zero rows for process 0 */ - if(VERBOSE_MED) - HDprintf("writeAll by some with zero row\n"); + if (VERBOSE_MED) + HDprintf("writeAll by some with zero row\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZROW); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("writeAll by some with zero row"); - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset1 by ZROW succeeded"); /* release all temporary handles. */ @@ -726,59 +709,56 @@ dataset_writeAll(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill the local slab with some trivial data */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset2 succeeded"); /* setup dimensions again to writeAll with zero columns for process 0 */ - if(VERBOSE_MED) - HDprintf("writeAll by some with zero col\n"); + if (VERBOSE_MED) + HDprintf("writeAll by some with zero col\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZCOL); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("writeAll by some with zero col"); - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset1 by ZCOL succeeded"); /* release all temporary handles. */ @@ -788,16 +768,15 @@ dataset_writeAll(void) H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - /* Dataset3: each process takes a block of rows, except process zero uses "none" selection. */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset3); + file_dataspace = H5Dget_space(dataset3); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); - if(MAINPROCESS) { - ret = H5Sselect_none(file_dataspace); - VRFY((ret >= 0), "H5Sselect_none file_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_none(file_dataspace); + VRFY((ret >= 0), "H5Sselect_none file_dataspace succeeded"); } /* end if */ else { ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); @@ -805,42 +784,39 @@ dataset_writeAll(void) } /* end else */ /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); - if(MAINPROCESS) { - ret = H5Sselect_none(mem_dataspace); - VRFY((ret >= 0), "H5Sselect_none mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_none(mem_dataspace); + VRFY((ret >= 0), "H5Sselect_none mem_dataspace succeeded"); } /* end if */ /* fill the local slab with some trivial data */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED) { - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* end if */ /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* write data collectively */ MESG("writeAll with none"); - ret = H5Dwrite(dataset3, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset3, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset3 succeeded"); /* write data collectively (with datatype conversion) */ MESG("writeAll with none"); - ret = H5Dwrite(dataset3, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset3, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset3 succeeded"); /* release all temporary handles. */ @@ -854,11 +830,11 @@ dataset_writeAll(void) /* Additionally, these are in a scalar dataspace */ /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset4); + file_dataspace = H5Dget_space(dataset4); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); - if(MAINPROCESS) { - ret = H5Sselect_none(file_dataspace); - VRFY((ret >= 0), "H5Sselect_all file_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_none(file_dataspace); + VRFY((ret >= 0), "H5Sselect_all file_dataspace succeeded"); } /* end if */ else { ret = H5Sselect_all(file_dataspace); @@ -868,9 +844,9 @@ dataset_writeAll(void) /* create a memory dataspace independently */ mem_dataspace = H5Screate(H5S_SCALAR); VRFY((mem_dataspace >= 0), ""); - if(MAINPROCESS) { - ret = H5Sselect_none(mem_dataspace); - VRFY((ret >= 0), "H5Sselect_all mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_none(mem_dataspace); + VRFY((ret >= 0), "H5Sselect_all mem_dataspace succeeded"); } /* end if */ else { ret = H5Sselect_all(mem_dataspace); @@ -880,31 +856,29 @@ dataset_writeAll(void) /* fill the local slab with some trivial data */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED) { - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* end if */ /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* write data collectively */ MESG("writeAll with scalar dataspace"); - ret = H5Dwrite(dataset4, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset4, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset4 succeeded"); /* write data collectively (with datatype conversion) */ MESG("writeAll with scalar dataspace"); - ret = H5Dwrite(dataset4, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset4, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset4 succeeded"); /* release all temporary handles. */ @@ -912,55 +886,54 @@ dataset_writeAll(void) H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - - if(data_array1) free(data_array1); - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + if (data_array1) + free(data_array1); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); - block[0] = 1; - block[1] = (hsize_t)dim1; + block[0] = 1; + block[1] = (hsize_t)dim1; stride[0] = 1; stride[1] = (hsize_t)dim1; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)(dim0/mpi_size * mpi_rank); - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); + start[1] = 0; dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* Dataset5: point selection in File - Hyperslab selection in Memory*/ /* create a file dataspace independently */ - point_set (start, count, stride, block, num_points, coords, OUT_OF_ORDER); - file_dataspace = H5Dget_space (dataset5); + point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + file_dataspace = H5Dget_space(dataset5); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); - start[0] = 0; - start[1] = 0; - mem_dataspace = H5Dget_space (dataset5); + start[0] = 0; + start[1] = 0; + mem_dataspace = H5Dget_space(dataset5); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* write data collectively */ - ret = H5Dwrite(dataset5, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset5, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset5 succeeded"); /* release all temporary handles. */ @@ -970,35 +943,34 @@ dataset_writeAll(void) /* Dataset6: point selection in File - Point selection in Memory*/ /* create a file dataspace independently */ - start[0] = (hsize_t)(dim0/mpi_size * mpi_rank); + start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); start[1] = 0; - point_set (start, count, stride, block, num_points, coords, OUT_OF_ORDER); - file_dataspace = H5Dget_space (dataset6); + point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + file_dataspace = H5Dget_space(dataset6); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); start[0] = 0; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, IN_ORDER); - mem_dataspace = H5Dget_space (dataset6); + point_set(start, count, stride, block, num_points, coords, IN_ORDER); + mem_dataspace = H5Dget_space(dataset6); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* write data collectively */ - ret = H5Dwrite(dataset6, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset6, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset6 succeeded"); /* release all temporary handles. */ @@ -1008,34 +980,33 @@ dataset_writeAll(void) /* Dataset7: point selection in File - All selection in Memory*/ /* create a file dataspace independently */ - start[0] = (hsize_t)(dim0/mpi_size * mpi_rank); + start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); start[1] = 0; - point_set (start, count, stride, block, num_points, coords, IN_ORDER); - file_dataspace = H5Dget_space (dataset7); + point_set(start, count, stride, block, num_points, coords, IN_ORDER); + file_dataspace = H5Dget_space(dataset7); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); - current_dims = num_points; - mem_dataspace = H5Screate_simple (1, ¤t_dims, NULL); + current_dims = num_points; + mem_dataspace = H5Screate_simple(1, ¤t_dims, NULL); VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); ret = H5Sselect_all(mem_dataspace); VRFY((ret >= 0), "H5Sselect_all succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* write data collectively */ - ret = H5Dwrite(dataset7, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset7, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite dataset7 succeeded"); /* release all temporary handles. */ @@ -1065,8 +1036,10 @@ dataset_writeAll(void) H5Fclose(fid); /* release data buffers */ - if(coords) HDfree(coords); - if(data_array1) HDfree(data_array1); + if (coords) + HDfree(coords); + if (data_array1) + HDfree(data_array1); } /* @@ -1081,47 +1054,47 @@ dataset_writeAll(void) void dataset_readAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2, dataset5, dataset6, dataset7; /* Dataset ID */ - DATATYPE *data_array1 = NULL; /* data buffer */ - DATATYPE *data_origin1 = NULL; /* expected data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2, dataset5, dataset6, dataset7; /* Dataset ID */ + DATATYPE * data_array1 = NULL; /* data buffer */ + DATATYPE * data_origin1 = NULL; /* expected data buffer */ const char *filename; - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ - size_t num_points; /* for point selection */ - hsize_t *coords = NULL; /* for point selection */ - int i,j,k; + size_t num_points; /* for point selection */ + hsize_t *coords = NULL; /* for point selection */ + int i, j, k; - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Collective read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Collective read test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* set up the coords array selection */ num_points = (size_t)dim1; - coords = (hsize_t *)HDmalloc((size_t)dim0 * (size_t)dim1 * RANK * sizeof(hsize_t)); + coords = (hsize_t *)HDmalloc((size_t)dim0 * (size_t)dim1 * RANK * sizeof(hsize_t)); VRFY((coords != NULL), "coords malloc succeeded"); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 HDmalloc succeeded"); /* ------------------- @@ -1132,14 +1105,13 @@ dataset_readAll(void) VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); VRFY((fid >= 0), "H5Fopen succeeded"); /* Release file-access template */ ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* -------------------------- * Open the datasets in it * ------------------------- */ @@ -1167,62 +1139,61 @@ dataset_readAll(void) slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_origin1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_origin1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* read data collectively */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset1 succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* setup dimensions again to readAll with zero columns for process 0 */ - if(VERBOSE_MED) - HDprintf("readAll by some with zero col\n"); + if (VERBOSE_MED) + HDprintf("readAll by some with zero col\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZCOL); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("readAll by some with zero col"); - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset1 by ZCOL succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* release all temporary handles. */ /* Could have used them for dataset2 but it is cleaner */ @@ -1235,219 +1206,221 @@ dataset_readAll(void) slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_origin1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_origin1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* read data collectively */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset2 succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* setup dimensions again to readAll with zero rows for process 0 */ - if(VERBOSE_MED) - HDprintf("readAll by some with zero row\n"); + if (VERBOSE_MED) + HDprintf("readAll by some with zero row\n"); slab_set(mpi_rank, mpi_size, start, count, stride, block, ZROW); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* need to make mem_dataspace to match for process 0 */ - if(MAINPROCESS){ - ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); + if (MAINPROCESS) { + ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "H5Sset_hyperslab mem_dataspace succeeded"); } MESG("readAll by some with zero row"); - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset1 by ZROW succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - if(data_array1) free(data_array1); - if(data_origin1) free(data_origin1); - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + if (data_array1) + free(data_array1); + if (data_origin1) + free(data_origin1); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 malloc succeeded"); - block[0] = 1; - block[1] = (hsize_t)dim1; + block[0] = 1; + block[1] = (hsize_t)dim1; stride[0] = 1; stride[1] = (hsize_t)dim1; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)(dim0/mpi_size * mpi_rank); - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); + start[1] = 0; dataset_fill(start, block, data_origin1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_origin1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_origin1); } /* Dataset5: point selection in memory - Hyperslab selection in file*/ /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset5); + file_dataspace = H5Dget_space(dataset5); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); start[0] = 0; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, OUT_OF_ORDER); - mem_dataspace = H5Dget_space (dataset5); + point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + mem_dataspace = H5Dget_space(dataset5); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset5, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset5, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset5 succeeded"); - ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - - if(data_array1) free(data_array1); - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + if (data_array1) + free(data_array1); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); /* Dataset6: point selection in File - Point selection in Memory*/ /* create a file dataspace independently */ - start[0] = (hsize_t)(dim0/mpi_size * mpi_rank); + start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); start[1] = 0; - point_set (start, count, stride, block, num_points, coords, IN_ORDER); - file_dataspace = H5Dget_space (dataset6); + point_set(start, count, stride, block, num_points, coords, IN_ORDER); + file_dataspace = H5Dget_space(dataset6); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(file_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); start[0] = 0; start[1] = 0; - point_set (start, count, stride, block, num_points, coords, OUT_OF_ORDER); - mem_dataspace = H5Dget_space (dataset6); + point_set(start, count, stride, block, num_points, coords, OUT_OF_ORDER); + mem_dataspace = H5Dget_space(dataset6); VRFY((mem_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset6, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset6, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset6 succeeded"); ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); - if(ret) nerrors++; + if (ret) + nerrors++; /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - if(data_array1) free(data_array1); - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + if (data_array1) + free(data_array1); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 malloc succeeded"); /* Dataset7: point selection in memory - All selection in file*/ /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset7); + file_dataspace = H5Dget_space(dataset7); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_all(file_dataspace); VRFY((ret >= 0), "H5Sselect_all succeeded"); num_points = (size_t)(dim0 * dim1); - k=0; - for (i=0 ; i= 0), "H5Dget_space succeeded"); ret = H5Sselect_elements(mem_dataspace, H5S_SELECT_SET, num_points, coords); VRFY((ret >= 0), "H5Sselect_elements succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), ""); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } /* read data collectively */ - ret = H5Dread(dataset7, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset7, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread dataset7 succeeded"); - start[0] = (hsize_t)(dim0/mpi_size * mpi_rank); + start[0] = (hsize_t)(dim0 / mpi_size * mpi_rank); start[1] = 0; - ret = dataset_vrfy(start, count, stride, block, data_array1+(dim0/mpi_size * dim1 * mpi_rank), data_origin1); - if(ret) nerrors++; + ret = dataset_vrfy(start, count, stride, block, data_array1 + (dim0 / mpi_size * dim1 * mpi_rank), + data_origin1); + if (ret) + nerrors++; /* release all temporary handles. */ H5Sclose(file_dataspace); @@ -1472,12 +1445,14 @@ dataset_readAll(void) H5Fclose(fid); /* release data buffers */ - if(coords) HDfree(coords); - if(data_array1) HDfree(data_array1); - if(data_origin1) HDfree(data_origin1); + if (coords) + HDfree(coords); + if (data_array1) + HDfree(data_array1); + if (data_origin1) + HDfree(data_origin1); } - /* * Part 2--Independent read/write for extendible datasets. */ @@ -1493,45 +1468,44 @@ dataset_readAll(void) void extend_writeInd(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t sid; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t sid; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ const char *filename; - hsize_t dims[RANK]; /* dataset dim sizes */ - hsize_t max_dims[RANK] = - {H5S_UNLIMITED, H5S_UNLIMITED}; /* dataset maximum dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ - hsize_t chunk_dims[RANK]; /* chunk sizes */ - hid_t dataset_pl; /* dataset create prop. list */ + hsize_t dims[RANK]; /* dataset dim sizes */ + hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dataset maximum dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ + hsize_t chunk_dims[RANK]; /* chunk sizes */ + hid_t dataset_pl; /* dataset create prop. list */ - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK]; /* for hyperslab setting */ - hsize_t stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK]; /* for hyperslab setting */ + hsize_t stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent write test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent write test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* setup chunk-size. Make sure sizes are > 0 */ chunk_dims[0] = (hsize_t)chunkdim0; chunk_dims[1] = (hsize_t)chunkdim1; /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); /* ------------------- @@ -1541,22 +1515,22 @@ extend_writeInd(void) acc_tpl = create_faccess_plist(comm, info, facc_type); VRFY((acc_tpl >= 0), ""); -/* Reduce the number of metadata cache slots, so that there are cache - * collisions during the raw data I/O on the chunked dataset. This stresses - * the metadata cache and tests for cache bugs. -QAK - */ -{ - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - - ret = H5Pget_cache(acc_tpl,&mdc_nelmts,&rdcc_nelmts,&rdcc_nbytes,&rdcc_w0); - VRFY((ret >= 0), "H5Pget_cache succeeded"); - mdc_nelmts=4; - ret = H5Pset_cache(acc_tpl,mdc_nelmts,rdcc_nelmts,rdcc_nbytes,rdcc_w0); - VRFY((ret >= 0), "H5Pset_cache succeeded"); -} + /* Reduce the number of metadata cache slots, so that there are cache + * collisions during the raw data I/O on the chunked dataset. This stresses + * the metadata cache and tests for cache bugs. -QAK + */ + { + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + + ret = H5Pget_cache(acc_tpl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0); + VRFY((ret >= 0), "H5Pget_cache succeeded"); + mdc_nelmts = 4; + ret = H5Pset_cache(acc_tpl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0); + VRFY((ret >= 0), "H5Pset_cache succeeded"); + } /* create the file collectively */ fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); @@ -1566,14 +1540,13 @@ extend_writeInd(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* -------------------------------------------------------------- * Define the dimensions of the overall datasets and create them. * ------------------------------------------------------------- */ /* set up dataset storage chunk sizes and creation property list */ - if(VERBOSE_MED) - HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); + if (VERBOSE_MED) + HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); dataset_pl = H5Pcreate(H5P_DATASET_CREATE); VRFY((dataset_pl >= 0), "H5Pcreate succeeded"); ret = H5Pset_chunk(dataset_pl, RANK, chunk_dims); @@ -1582,7 +1555,7 @@ extend_writeInd(void) /* setup dimensionality object */ /* start out with no rows, extend it later. */ dims[0] = dims[1] = 0; - sid = H5Screate_simple (RANK, dims, max_dims); + sid = H5Screate_simple(RANK, dims, max_dims); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* create an extendible dataset collectively */ @@ -1597,8 +1570,6 @@ extend_writeInd(void) H5Sclose(sid); H5Pclose(dataset_pl); - - /* ------------------------- * Test writing to dataset1 * -------------------------*/ @@ -1608,37 +1579,35 @@ extend_writeInd(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED) { - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* Extend its current dim sizes before writing */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - ret = H5Dset_extent(dataset1, dims); + ret = H5Dset_extent(dataset1, dims); VRFY((ret >= 0), "H5Dset_extent succeeded"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release resource */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); - /* ------------------------- * Test writing to dataset2 * -------------------------*/ @@ -1648,13 +1617,13 @@ extend_writeInd(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* Try write to dataset2 beyond its current dim sizes. Should fail. */ @@ -1663,14 +1632,13 @@ extend_writeInd(void) H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently. Should fail. */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret < 0), "H5Dwrite failed as expected"); /* restore auto error reporting */ @@ -1680,18 +1648,17 @@ extend_writeInd(void) /* Extend dataset2 and try again. Should succeed. */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - ret = H5Dset_extent(dataset2, dims); + ret = H5Dset_extent(dataset2, dims); VRFY((ret >= 0), "H5Dset_extent succeeded"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release resource */ @@ -1700,7 +1667,6 @@ extend_writeInd(void) ret = H5Sclose(mem_dataspace); VRFY((ret >= 0), "H5Sclose succeeded"); - /* close dataset collectively */ ret = H5Dclose(dataset1); VRFY((ret >= 0), "H5Dclose1 succeeded"); @@ -1711,7 +1677,8 @@ extend_writeInd(void) H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); + if (data_array1) + HDfree(data_array1); } /* @@ -1724,30 +1691,30 @@ void extend_writeInd2(void) { const char *filename; - hid_t fid; /* HDF5 file ID */ - hid_t fapl; /* File access templates */ - hid_t fs; /* File dataspace ID */ - hid_t ms; /* Memory dataspace ID */ - hid_t dataset; /* Dataset ID */ - hsize_t orig_size=10; /* Original dataset dim size */ - hsize_t new_size=20; /* Extended dataset dim size */ - hsize_t one=1; - hsize_t max_size = H5S_UNLIMITED; /* dataset maximum dim size */ - hsize_t chunk_size = 16384; /* chunk size */ - hid_t dcpl; /* dataset create prop. list */ - int written[10], /* Data to write */ - retrieved[10]; /* Data read in */ - int mpi_size, mpi_rank; /* MPI settings */ - int i; /* Local index variable */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 file ID */ + hid_t fapl; /* File access templates */ + hid_t fs; /* File dataspace ID */ + hid_t ms; /* Memory dataspace ID */ + hid_t dataset; /* Dataset ID */ + hsize_t orig_size = 10; /* Original dataset dim size */ + hsize_t new_size = 20; /* Extended dataset dim size */ + hsize_t one = 1; + hsize_t max_size = H5S_UNLIMITED; /* dataset maximum dim size */ + hsize_t chunk_size = 16384; /* chunk size */ + hid_t dcpl; /* dataset create prop. list */ + int written[10], /* Data to write */ + retrieved[10]; /* Data read in */ + int mpi_size, mpi_rank; /* MPI settings */ + int i; /* Local index variable */ + herr_t ret; /* Generic return value */ filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent write test #2 on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent write test #2 on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* ------------------- * START AN HDF5 FILE @@ -1764,7 +1731,6 @@ extend_writeInd2(void) ret = H5Pclose(fapl); VRFY((ret >= 0), "H5Pclose succeeded"); - /* -------------------------------------------------------------- * Define the dimensions of the overall datasets and create them. * ------------------------------------------------------------- */ @@ -1776,7 +1742,7 @@ extend_writeInd2(void) VRFY((ret >= 0), "H5Pset_chunk succeeded"); /* setup dimensionality object */ - fs = H5Screate_simple (1, &orig_size, &max_size); + fs = H5Screate_simple(1, &orig_size, &max_size); VRFY((fs >= 0), "H5Screate_simple succeeded"); /* create an extendible dataset collectively */ @@ -1787,7 +1753,6 @@ extend_writeInd2(void) ret = H5Pclose(dcpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /* ------------------------- * Test writing to dataset * -------------------------*/ @@ -1796,13 +1761,13 @@ extend_writeInd2(void) VRFY((ms >= 0), "H5Screate_simple succeeded"); /* put some trivial data in the data_array */ - for(i = 0; i < (int)orig_size; i++) + for (i = 0; i < (int)orig_size; i++) written[i] = i; MESG("data array initialized"); - if(VERBOSE_MED) { - MESG("writing at offset zero: "); - for(i = 0; i < (int)orig_size; i++) - HDprintf("%s%d", i?", ":"", written[i]); + if (VERBOSE_MED) { + MESG("writing at offset zero: "); + for (i = 0; i < (int)orig_size; i++) + HDprintf("%s%d", i ? ", " : "", written[i]); HDprintf("\n"); } ret = H5Dwrite(dataset, H5T_NATIVE_INT, ms, fs, H5P_DEFAULT, written); @@ -1813,16 +1778,16 @@ extend_writeInd2(void) * -------------------------*/ ret = H5Dread(dataset, H5T_NATIVE_INT, ms, fs, H5P_DEFAULT, retrieved); VRFY((ret >= 0), "H5Dread succeeded"); - for (i=0; i<(int)orig_size; i++) - if(written[i]!=retrieved[i]) { - HDprintf("Line #%d: written!=retrieved: written[%d]=%d, retrieved[%d]=%d\n",__LINE__, - i,written[i], i,retrieved[i]); + for (i = 0; i < (int)orig_size; i++) + if (written[i] != retrieved[i]) { + HDprintf("Line #%d: written!=retrieved: written[%d]=%d, retrieved[%d]=%d\n", __LINE__, i, + written[i], i, retrieved[i]); nerrors++; } - if(VERBOSE_MED){ - MESG("read at offset zero: "); - for (i=0; i<(int)orig_size; i++) - HDprintf("%s%d", i?", ":"", retrieved[i]); + if (VERBOSE_MED) { + MESG("read at offset zero: "); + for (i = 0; i < (int)orig_size; i++) + HDprintf("%s%d", i ? ", " : "", retrieved[i]); HDprintf("\n"); } @@ -1840,13 +1805,13 @@ extend_writeInd2(void) * Write to the second half of the dataset * -------------------------*/ H5_CHECK_OVERFLOW(orig_size, hsize_t, int); - for (i=0; i<(int)orig_size; i++) + for (i = 0; i < (int)orig_size; i++) written[i] = (int)orig_size + i; MESG("data array re-initialized"); - if(VERBOSE_MED) { - MESG("writing at offset 10: "); - for (i=0; i<(int)orig_size; i++) - HDprintf("%s%d", i?", ":"", written[i]); + if (VERBOSE_MED) { + MESG("writing at offset 10: "); + for (i = 0; i < (int)orig_size; i++) + HDprintf("%s%d", i ? ", " : "", written[i]); HDprintf("\n"); } ret = H5Sselect_hyperslab(fs, H5S_SELECT_SET, &orig_size, NULL, &one, &orig_size); @@ -1859,20 +1824,19 @@ extend_writeInd2(void) * -------------------------*/ ret = H5Dread(dataset, H5T_NATIVE_INT, ms, fs, H5P_DEFAULT, retrieved); VRFY((ret >= 0), "H5Dread succeeded"); - for (i=0; i<(int)orig_size; i++) - if(written[i]!=retrieved[i]) { - HDprintf("Line #%d: written!=retrieved: written[%d]=%d, retrieved[%d]=%d\n",__LINE__, - i,written[i], i,retrieved[i]); + for (i = 0; i < (int)orig_size; i++) + if (written[i] != retrieved[i]) { + HDprintf("Line #%d: written!=retrieved: written[%d]=%d, retrieved[%d]=%d\n", __LINE__, i, + written[i], i, retrieved[i]); nerrors++; } - if(VERBOSE_MED){ - MESG("read at offset 10: "); - for (i=0; i<(int)orig_size; i++) - HDprintf("%s%d", i?", ":"", retrieved[i]); + if (VERBOSE_MED) { + MESG("read at offset 10: "); + for (i = 0; i < (int)orig_size; i++) + HDprintf("%s%d", i ? ", " : "", retrieved[i]); HDprintf("\n"); } - /* Close dataset collectively */ ret = H5Dclose(dataset); VRFY((ret >= 0), "H5Dclose succeeded"); @@ -1886,41 +1850,41 @@ extend_writeInd2(void) void extend_readInd(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ - hsize_t dims[RANK]; /* dataset dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ - DATATYPE *data_array2 = NULL; /* data buffer */ - DATATYPE *data_origin1 = NULL; /* expected data buffer */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ + hsize_t dims[RANK]; /* dataset dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ + DATATYPE * data_array2 = NULL; /* data buffer */ + DATATYPE * data_origin1 = NULL; /* expected data buffer */ const char *filename; - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent read test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); - data_array2 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array2 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array2 != NULL), "data_array2 HDmalloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 HDmalloc succeeded"); /* ------------------- @@ -1931,7 +1895,7 @@ extend_readInd(void) VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); VRFY((fid >= 0), ""); /* Release file-access template */ @@ -1951,7 +1915,7 @@ extend_readInd(void) H5Eget_auto2(H5E_DEFAULT, &old_func, &old_client_data); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sget_simple_extent_dims(file_dataspace, dims, NULL); VRFY((ret > 0), "H5Sget_simple_extent_dims succeeded"); @@ -1963,72 +1927,70 @@ extend_readInd(void) H5Eset_auto2(H5E_DEFAULT, old_func, old_client_data); H5Sclose(file_dataspace); - /* Read dataset1 using BYROW pattern */ /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* read data independently */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dread succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); VRFY((ret == 0), "dataset1 read verified correct"); - if(ret) nerrors++; + if (ret) + nerrors++; H5Sclose(mem_dataspace); H5Sclose(file_dataspace); - /* Read dataset2 using BYCOL pattern */ /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* read data independently */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array1); VRFY((ret >= 0), "H5Dread succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); VRFY((ret == 0), "dataset2 read verified correct"); - if(ret) nerrors++; + if (ret) + nerrors++; H5Sclose(mem_dataspace); H5Sclose(file_dataspace); @@ -2039,14 +2001,16 @@ extend_readInd(void) ret = H5Dclose(dataset2); VRFY((ret >= 0), ""); - /* close the file collectively */ H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); - if(data_array2) HDfree(data_array2); - if(data_origin1) HDfree(data_origin1); + if (data_array1) + HDfree(data_array1); + if (data_array2) + HDfree(data_array2); + if (data_origin1) + HDfree(data_origin1); } /* @@ -2064,46 +2028,45 @@ extend_readInd(void) void extend_writeAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t sid; /* Dataspace ID */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t sid; /* Dataspace ID */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ const char *filename; - hsize_t dims[RANK]; /* dataset dim sizes */ - hsize_t max_dims[RANK] = - {H5S_UNLIMITED, H5S_UNLIMITED}; /* dataset maximum dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ - hsize_t chunk_dims[RANK]; /* chunk sizes */ - hid_t dataset_pl; /* dataset create prop. list */ + hsize_t dims[RANK]; /* dataset dim sizes */ + hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* dataset maximum dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ + hsize_t chunk_dims[RANK]; /* chunk sizes */ + hid_t dataset_pl; /* dataset create prop. list */ - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK]; /* for hyperslab setting */ - hsize_t stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK]; /* for hyperslab setting */ + hsize_t stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent write test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent write test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* setup chunk-size. Make sure sizes are > 0 */ chunk_dims[0] = (hsize_t)chunkdim0; chunk_dims[1] = (hsize_t)chunkdim1; /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); /* ------------------- @@ -2113,22 +2076,22 @@ extend_writeAll(void) acc_tpl = create_faccess_plist(comm, info, facc_type); VRFY((acc_tpl >= 0), ""); -/* Reduce the number of metadata cache slots, so that there are cache - * collisions during the raw data I/O on the chunked dataset. This stresses - * the metadata cache and tests for cache bugs. -QAK - */ -{ - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - - ret = H5Pget_cache(acc_tpl,&mdc_nelmts,&rdcc_nelmts,&rdcc_nbytes,&rdcc_w0); - VRFY((ret >= 0), "H5Pget_cache succeeded"); - mdc_nelmts=4; - ret = H5Pset_cache(acc_tpl,mdc_nelmts,rdcc_nelmts,rdcc_nbytes,rdcc_w0); - VRFY((ret >= 0), "H5Pset_cache succeeded"); -} + /* Reduce the number of metadata cache slots, so that there are cache + * collisions during the raw data I/O on the chunked dataset. This stresses + * the metadata cache and tests for cache bugs. -QAK + */ + { + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + + ret = H5Pget_cache(acc_tpl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0); + VRFY((ret >= 0), "H5Pget_cache succeeded"); + mdc_nelmts = 4; + ret = H5Pset_cache(acc_tpl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0); + VRFY((ret >= 0), "H5Pset_cache succeeded"); + } /* create the file collectively */ fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); @@ -2138,14 +2101,13 @@ extend_writeAll(void) ret = H5Pclose(acc_tpl); VRFY((ret >= 0), ""); - /* -------------------------------------------------------------- * Define the dimensions of the overall datasets and create them. * ------------------------------------------------------------- */ /* set up dataset storage chunk sizes and creation property list */ - if(VERBOSE_MED) - HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); + if (VERBOSE_MED) + HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); dataset_pl = H5Pcreate(H5P_DATASET_CREATE); VRFY((dataset_pl >= 0), "H5Pcreate succeeded"); ret = H5Pset_chunk(dataset_pl, RANK, chunk_dims); @@ -2154,7 +2116,7 @@ extend_writeAll(void) /* setup dimensionality object */ /* start out with no rows, extend it later. */ dims[0] = dims[1] = 0; - sid = H5Screate_simple (RANK, dims, max_dims); + sid = H5Screate_simple(RANK, dims, max_dims); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* create an extendible dataset collectively */ @@ -2169,8 +2131,6 @@ extend_writeAll(void) H5Sclose(sid); H5Pclose(dataset_pl); - - /* ------------------------- * Test writing to dataset1 * -------------------------*/ @@ -2180,41 +2140,39 @@ extend_writeAll(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED) { - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* Extend its current dim sizes before writing */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - ret = H5Dset_extent(dataset1, dims); + ret = H5Dset_extent(dataset1, dims); VRFY((ret >= 0), "H5Dset_extent succeeded"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* write data collectively */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release resource */ @@ -2222,7 +2180,6 @@ extend_writeAll(void) H5Sclose(mem_dataspace); H5Pclose(xfer_plist); - /* ------------------------- * Test writing to dataset2 * -------------------------*/ @@ -2232,40 +2189,38 @@ extend_writeAll(void) /* put some trivial data in the data_array */ dataset_fill(start, block, data_array1); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* Try write to dataset2 beyond its current dim sizes. Should fail. */ /* Temporary turn off auto error reporting */ H5Eget_auto2(H5E_DEFAULT, &old_func, &old_client_data); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently. Should fail. */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret < 0), "H5Dwrite failed as expected"); /* restore auto error reporting */ @@ -2275,18 +2230,17 @@ extend_writeAll(void) /* Extend dataset2 and try again. Should succeed. */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - ret = H5Dset_extent(dataset2, dims); + ret = H5Dset_extent(dataset2, dims); VRFY((ret >= 0), "H5Dset_extent succeeded"); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* write data independently */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release resource */ @@ -2297,7 +2251,6 @@ extend_writeAll(void) ret = H5Pclose(xfer_plist); VRFY((ret >= 0), "H5Pclose succeeded"); - /* close dataset collectively */ ret = H5Dclose(dataset1); VRFY((ret >= 0), "H5Dclose1 succeeded"); @@ -2308,49 +2261,50 @@ extend_writeAll(void) H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); + if (data_array1) + HDfree(data_array1); } /* Example of using the parallel HDF5 library to read an extendible dataset */ void extend_readAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2; /* Dataset ID */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* memory dataspace ID */ + hid_t dataset1, dataset2; /* Dataset ID */ const char *filename; - hsize_t dims[RANK]; /* dataset dim sizes */ - DATATYPE *data_array1 = NULL; /* data buffer */ - DATATYPE *data_array2 = NULL; /* data buffer */ - DATATYPE *data_origin1 = NULL; /* expected data buffer */ + hsize_t dims[RANK]; /* dataset dim sizes */ + DATATYPE * data_array1 = NULL; /* data buffer */ + DATATYPE * data_array2 = NULL; /* data buffer */ + DATATYPE * data_origin1 = NULL; /* expected data buffer */ - hsize_t start[RANK]; /* for hyperslab setting */ - hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ - hsize_t block[RANK]; /* for hyperslab setting */ + hsize_t start[RANK]; /* for hyperslab setting */ + hsize_t count[RANK], stride[RANK]; /* for hyperslab setting */ + hsize_t block[RANK]; /* for hyperslab setting */ - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Extend independent read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Extend independent read test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* allocate memory for data buffer */ - data_array1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array1 != NULL), "data_array1 HDmalloc succeeded"); - data_array2 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_array2 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_array2 != NULL), "data_array2 HDmalloc succeeded"); - data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0*(size_t)dim1*sizeof(DATATYPE)); + data_origin1 = (DATATYPE *)HDmalloc((size_t)dim0 * (size_t)dim1 * sizeof(DATATYPE)); VRFY((data_origin1 != NULL), "data_origin1 HDmalloc succeeded"); /* ------------------- @@ -2361,7 +2315,7 @@ extend_readAll(void) VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); VRFY((fid >= 0), ""); /* Release file-access template */ @@ -2381,7 +2335,7 @@ extend_readAll(void) H5Eget_auto2(H5E_DEFAULT, &old_func, &old_client_data); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sget_simple_extent_dims(file_dataspace, dims, NULL); VRFY((ret > 0), "H5Sget_simple_extent_dims succeeded"); @@ -2393,95 +2347,91 @@ extend_readAll(void) H5Eset_auto2(H5E_DEFAULT, old_func, old_client_data); H5Sclose(file_dataspace); - /* Read dataset1 using BYROW pattern */ /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* read data collectively */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); VRFY((ret == 0), "dataset1 read verified correct"); - if(ret) nerrors++; + if (ret) + nerrors++; H5Sclose(mem_dataspace); H5Sclose(file_dataspace); H5Pclose(xfer_plist); - /* Read dataset2 using BYCOL pattern */ /* set up dimensions of the slab this process accesses */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), ""); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), ""); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* fill dataset with test data */ dataset_fill(start, block, data_origin1); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(start, block, data_array1); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(start, block, data_array1); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* read data collectively */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_array1); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_array1); VRFY((ret >= 0), "H5Dread succeeded"); /* verify the read data with original expected data */ ret = dataset_vrfy(start, count, stride, block, data_array1, data_origin1); VRFY((ret == 0), "dataset2 read verified correct"); - if(ret) nerrors++; + if (ret) + nerrors++; H5Sclose(mem_dataspace); H5Sclose(file_dataspace); @@ -2493,14 +2443,16 @@ extend_readAll(void) ret = H5Dclose(dataset2); VRFY((ret >= 0), ""); - /* close the file collectively */ H5Fclose(fid); /* release data buffers */ - if(data_array1) HDfree(data_array1); - if(data_array2) HDfree(data_array2); - if(data_origin1) HDfree(data_origin1); + if (data_array1) + HDfree(data_array1); + if (data_array2) + HDfree(data_array2); + if (data_origin1) + HDfree(data_origin1); } /* @@ -2511,49 +2463,49 @@ extend_readAll(void) void compress_readAll(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t dcpl; /* Dataset creation property list */ - hid_t xfer_plist; /* Dataset transfer properties list */ - hid_t dataspace; /* Dataspace ID */ - hid_t dataset; /* Dataset ID */ - int rank=1; /* Dataspace rank */ - hsize_t dim=(hsize_t)dim0; /* Dataspace dimensions */ - unsigned u; /* Local index variable */ - unsigned chunk_opts; /* Chunk options */ + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t dcpl; /* Dataset creation property list */ + hid_t xfer_plist; /* Dataset transfer properties list */ + hid_t dataspace; /* Dataspace ID */ + hid_t dataset; /* Dataset ID */ + int rank = 1; /* Dataspace rank */ + hsize_t dim = (hsize_t)dim0; /* Dataspace dimensions */ + unsigned u; /* Local index variable */ + unsigned chunk_opts; /* Chunk options */ unsigned disable_partial_chunk_filters; /* Whether filters are disabled on partial chunks */ - DATATYPE *data_read = NULL; /* data buffer */ - DATATYPE *data_orig = NULL; /* expected data buffer */ + DATATYPE * data_read = NULL; /* data buffer */ + DATATYPE * data_orig = NULL; /* expected data buffer */ const char *filename; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - int mpi_size, mpi_rank; - herr_t ret; /* Generic return value */ + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + int mpi_size, mpi_rank; + herr_t ret; /* Generic return value */ filename = GetTestParameters(); - if(VERBOSE_MED) - HDprintf("Collective chunked dataset read test on file %s\n", filename); + if (VERBOSE_MED) + HDprintf("Collective chunked dataset read test on file %s\n", filename); /* Retrieve MPI parameters */ - MPI_Comm_size(comm,&mpi_size); - MPI_Comm_rank(comm,&mpi_rank); + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); /* Allocate data buffer */ - data_orig = (DATATYPE *)HDmalloc((size_t)dim*sizeof(DATATYPE)); + data_orig = (DATATYPE *)HDmalloc((size_t)dim * sizeof(DATATYPE)); VRFY((data_orig != NULL), "data_origin1 HDmalloc succeeded"); - data_read = (DATATYPE *)HDmalloc((size_t)dim*sizeof(DATATYPE)); + data_read = (DATATYPE *)HDmalloc((size_t)dim * sizeof(DATATYPE)); VRFY((data_read != NULL), "data_array1 HDmalloc succeeded"); /* Initialize data buffers */ - for(u=0; u= 0), "H5Pset_chunk succeeded"); /* Set chunk options appropriately */ - if(disable_partial_chunk_filters) { + if (disable_partial_chunk_filters) { ret = H5Pget_chunk_opts(dcpl, &chunk_opts); - VRFY((ret>=0),"H5Pget_chunk_opts succeeded"); + VRFY((ret >= 0), "H5Pget_chunk_opts succeeded"); chunk_opts |= H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS; ret = H5Pset_chunk_opts(dcpl, chunk_opts); - VRFY((ret>=0),"H5Pset_chunk_opts succeeded"); + VRFY((ret >= 0), "H5Pset_chunk_opts succeeded"); } /* end if */ ret = H5Pset_deflate(dcpl, 9); @@ -2590,7 +2542,8 @@ compress_readAll(void) VRFY((dataspace > 0), "H5Screate_simple succeeded"); /* Create dataset */ - dataset = H5Dcreate2(fid, "compressed_data", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + dataset = + H5Dcreate2(fid, "compressed_data", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); VRFY((dataset > 0), "H5Dcreate2 succeeded"); /* Write compressed data */ @@ -2612,49 +2565,47 @@ compress_readAll(void) MPI_Barrier(comm); /* ------------------- - * OPEN AN HDF5 FILE - * -------------------*/ + * OPEN AN HDF5 FILE + * -------------------*/ /* setup file access template */ acc_tpl = create_faccess_plist(comm, info, facc_type); VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDWR,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDWR, acc_tpl); VRFY((fid > 0), "H5Fopen succeeded"); /* Release file-access template */ ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /* Open dataset with compressed chunks */ dataset = H5Dopen2(fid, "compressed_data", H5P_DEFAULT); VRFY((dataset > 0), "H5Dopen2 succeeded"); /* Try reading & writing data */ - if(dataset>0) { + if (dataset > 0) { /* Create dataset transfer property list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist > 0), "H5Pcreate succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* Try reading the data */ ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer_plist, data_read); VRFY((ret >= 0), "H5Dread succeeded"); /* Verify data read */ - for(u=0; u 0 */ chunk_dims[0] = (hsize_t)chunkdim0; @@ -2753,8 +2706,8 @@ none_selection_chunk(void) * ------------------------------------------------------------- */ /* set up dataset storage chunk sizes and creation property list */ - if(VERBOSE_MED) - HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); + if (VERBOSE_MED) + HDprintf("chunks[]=%lu,%lu\n", (unsigned long)chunk_dims[0], (unsigned long)chunk_dims[1]); dataset_pl = H5Pcreate(H5P_DATASET_CREATE); VRFY((dataset_pl >= 0), "H5Pcreate succeeded"); ret = H5Pset_chunk(dataset_pl, RANK, chunk_dims); @@ -2763,7 +2716,7 @@ none_selection_chunk(void) /* setup dimensionality object */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple(RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* create an extendible dataset collectively */ @@ -2786,65 +2739,64 @@ none_selection_chunk(void) /* allocate memory for data buffer. Only allocate enough buffer for * each processor's data. */ - if(mpi_rank) { - data_origin = (DATATYPE *)HDmalloc(block[0]*block[1]*sizeof(DATATYPE)); + if (mpi_rank) { + data_origin = (DATATYPE *)HDmalloc(block[0] * block[1] * sizeof(DATATYPE)); VRFY((data_origin != NULL), "data_origin HDmalloc succeeded"); - data_array = (DATATYPE *)HDmalloc(block[0]*block[1]*sizeof(DATATYPE)); + data_array = (DATATYPE *)HDmalloc(block[0] * block[1] * sizeof(DATATYPE)); VRFY((data_array != NULL), "data_array HDmalloc succeeded"); /* put some trivial data in the data_array */ mstart[0] = mstart[1] = 0; dataset_fill(mstart, block, data_origin); MESG("data_array initialized"); - if(VERBOSE_MED){ - MESG("data_array created"); - dataset_print(mstart, block, data_origin); + if (VERBOSE_MED) { + MESG("data_array created"); + dataset_print(mstart, block, data_origin); } } /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* Process 0 has no selection */ - if(!mpi_rank) { + if (!mpi_rank) { ret = H5Sselect_none(mem_dataspace); VRFY((ret >= 0), "H5Sselect_none succeeded"); } /* create a file dataspace independently */ - file_dataspace = H5Dget_space (dataset1); + file_dataspace = H5Dget_space(dataset1); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* Process 0 has no selection */ - if(!mpi_rank) { + if (!mpi_rank) { ret = H5Sselect_none(file_dataspace); VRFY((ret >= 0), "H5Sselect_none succeeded"); } /* set up the collective transfer properties list */ - xfer_plist = H5Pcreate (H5P_DATASET_XFER); + xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate xfer succeeded"); ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); /* write data collectively */ - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_origin); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_origin); VRFY((ret >= 0), "H5Dwrite succeeded"); /* read data independently */ - ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array); + ret = H5Dread(dataset1, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array); VRFY((ret >= 0), ""); /* verify the read data with original expected data */ - if(mpi_rank) { + if (mpi_rank) { ret = dataset_vrfy(mstart, count, stride, block, data_array, data_origin); - if(ret) nerrors++; + if (ret) + nerrors++; } /* ------------------------- @@ -2854,19 +2806,18 @@ none_selection_chunk(void) VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); /* write data collectively */ - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - xfer_plist, data_origin); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, xfer_plist, data_origin); VRFY((ret >= 0), "H5Dwrite succeeded"); /* read data independently */ - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, data_array); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, data_array); VRFY((ret >= 0), ""); /* verify the read data with original expected data */ - if(mpi_rank) { + if (mpi_rank) { ret = dataset_vrfy(mstart, count, stride, block, data_array, data_origin); - if(ret) nerrors++; + if (ret) + nerrors++; } /* release resource */ @@ -2877,7 +2828,6 @@ none_selection_chunk(void) ret = H5Pclose(xfer_plist); VRFY((ret >= 0), "H5Pclose succeeded"); - /* close dataset collectively */ ret = H5Dclose(dataset1); VRFY((ret >= 0), "H5Dclose1 succeeded"); @@ -2888,11 +2838,12 @@ none_selection_chunk(void) H5Fclose(fid); /* release data buffers */ - if(data_origin) HDfree(data_origin); - if(data_array) HDfree(data_array); + if (data_origin) + HDfree(data_origin); + if (data_array) + HDfree(data_array); } - /* Function: test_actual_io_mode * * Purpose: tests one specific case of collective I/O and checks that the @@ -2956,63 +2907,61 @@ none_selection_chunk(void) * Date: 2011-04-06 */ static void -test_actual_io_mode(int selection_mode) { - H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_write = -1; - H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_read = -1; - H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_expected = -1; - H5D_mpio_actual_io_mode_t actual_io_mode_write = -1; - H5D_mpio_actual_io_mode_t actual_io_mode_read = -1; - H5D_mpio_actual_io_mode_t actual_io_mode_expected = -1; - const char * filename; - const char * test_name; - hbool_t direct_multi_chunk_io; - hbool_t multi_chunk_io; - hbool_t is_chunked; - hbool_t is_collective; - int mpi_size = -1; - int mpi_rank = -1; - int length; - int * buffer; - int i; - MPI_Comm mpi_comm = MPI_COMM_NULL; - MPI_Info mpi_info = MPI_INFO_NULL; - hid_t fid = -1; - hid_t sid = -1; - hid_t dataset = -1; - hid_t data_type = H5T_NATIVE_INT; - hid_t fapl = -1; - hid_t mem_space = -1; - hid_t file_space = -1; - hid_t dcpl = -1; - hid_t dxpl_write = -1; - hid_t dxpl_read = -1; - hsize_t dims[RANK]; - hsize_t chunk_dims[RANK]; - hsize_t start[RANK]; - hsize_t stride[RANK]; - hsize_t count[RANK]; - hsize_t block[RANK]; - char message[256]; - herr_t ret; +test_actual_io_mode(int selection_mode) +{ + H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_write = -1; + H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_read = -1; + H5D_mpio_actual_chunk_opt_mode_t actual_chunk_opt_mode_expected = -1; + H5D_mpio_actual_io_mode_t actual_io_mode_write = -1; + H5D_mpio_actual_io_mode_t actual_io_mode_read = -1; + H5D_mpio_actual_io_mode_t actual_io_mode_expected = -1; + const char * filename; + const char * test_name; + hbool_t direct_multi_chunk_io; + hbool_t multi_chunk_io; + hbool_t is_chunked; + hbool_t is_collective; + int mpi_size = -1; + int mpi_rank = -1; + int length; + int * buffer; + int i; + MPI_Comm mpi_comm = MPI_COMM_NULL; + MPI_Info mpi_info = MPI_INFO_NULL; + hid_t fid = -1; + hid_t sid = -1; + hid_t dataset = -1; + hid_t data_type = H5T_NATIVE_INT; + hid_t fapl = -1; + hid_t mem_space = -1; + hid_t file_space = -1; + hid_t dcpl = -1; + hid_t dxpl_write = -1; + hid_t dxpl_read = -1; + hsize_t dims[RANK]; + hsize_t chunk_dims[RANK]; + hsize_t start[RANK]; + hsize_t stride[RANK]; + hsize_t count[RANK]; + hsize_t block[RANK]; + char message[256]; + herr_t ret; /* Set up some flags to make some future if statements slightly more readable */ - direct_multi_chunk_io = ( - selection_mode == TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_IND || - selection_mode == TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_COL ); + direct_multi_chunk_io = (selection_mode == TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_IND || + selection_mode == TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_COL); /* Note: RESET performs the same tests as MULTI_CHUNK_MIX_DISAGREE and then * tests independent I/O */ - multi_chunk_io = ( - selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_IND || - selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_COL || - selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_MIX || - selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_MIX_DISAGREE || - selection_mode == TEST_ACTUAL_IO_RESET ); + multi_chunk_io = + (selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_IND || + selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_COL || + selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_MIX || + selection_mode == TEST_ACTUAL_IO_MULTI_CHUNK_MIX_DISAGREE || selection_mode == TEST_ACTUAL_IO_RESET); - is_chunked = ( - selection_mode != TEST_ACTUAL_IO_CONTIGUOUS && - selection_mode != TEST_ACTUAL_IO_NO_COLLECTIVE); + is_chunked = + (selection_mode != TEST_ACTUAL_IO_CONTIGUOUS && selection_mode != TEST_ACTUAL_IO_NO_COLLECTIVE); is_collective = selection_mode != TEST_ACTUAL_IO_NO_COLLECTIVE; @@ -3041,7 +2990,7 @@ test_actual_io_mode(int selection_mode) { /* Create the basic Space */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* Create the dataset creation plist */ @@ -3049,17 +2998,16 @@ test_actual_io_mode(int selection_mode) { VRFY((dcpl >= 0), "dataset creation plist created successfully"); /* If we are not testing contiguous datasets */ - if(is_chunked) { + if (is_chunked) { /* Set up chunk information. */ - chunk_dims[0] = dims[0]/(hsize_t)mpi_size; + chunk_dims[0] = dims[0] / (hsize_t)mpi_size; chunk_dims[1] = dims[1]; - ret = H5Pset_chunk(dcpl, 2, chunk_dims); - VRFY((ret >= 0),"chunk creation property list succeeded"); + ret = H5Pset_chunk(dcpl, 2, chunk_dims); + VRFY((ret >= 0), "chunk creation property list succeeded"); } /* Create the dataset */ - dataset = H5Dcreate2(fid, "actual_io", data_type, sid, H5P_DEFAULT, - dcpl, H5P_DEFAULT); + dataset = H5Dcreate2(fid, "actual_io", data_type, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dcreate2() dataset succeeded"); /* Create the file dataspace */ @@ -3068,7 +3016,7 @@ test_actual_io_mode(int selection_mode) { /* Choose a selection method based on the type of I/O we want to occur, * and also set up some selection-dependeent test info. */ - switch(selection_mode) { + switch (selection_mode) { /* Independent I/O with optimization */ case TEST_ACTUAL_IO_MULTI_CHUNK_IND: @@ -3079,9 +3027,9 @@ test_actual_io_mode(int selection_mode) { */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); - test_name = "Multi Chunk - Independent"; + test_name = "Multi Chunk - Independent"; actual_chunk_opt_mode_expected = H5D_MPIO_MULTI_CHUNK; - actual_io_mode_expected = H5D_MPIO_CHUNK_INDEPENDENT; + actual_io_mode_expected = H5D_MPIO_CHUNK_INDEPENDENT; break; /* Collective I/O with optimization */ @@ -3093,9 +3041,9 @@ test_actual_io_mode(int selection_mode) { */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); - test_name = "Multi Chunk - Collective"; + test_name = "Multi Chunk - Collective"; actual_chunk_opt_mode_expected = H5D_MPIO_MULTI_CHUNK; - if(mpi_size > 1) + if (mpi_size > 1) actual_io_mode_expected = H5D_MPIO_CHUNK_COLLECTIVE; else actual_io_mode_expected = H5D_MPIO_CHUNK_INDEPENDENT; @@ -3112,24 +3060,25 @@ test_actual_io_mode(int selection_mode) { * and at least one chunk independently, reporting mixed I/O. */ - if(mpi_rank == 0) { - /* Select the first column */ - slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); - } else { + if (mpi_rank == 0) { + /* Select the first column */ + slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); + } + else { /* Select the first and the nth chunk in the nth column */ - block[0] = (hsize_t)(dim0 / mpi_size); - block[1] = (hsize_t)(dim1 / mpi_size); - count[0] = 2; - count[1] = 1; + block[0] = (hsize_t)(dim0 / mpi_size); + block[1] = (hsize_t)(dim1 / mpi_size); + count[0] = 2; + count[1] = 1; stride[0] = (hsize_t)mpi_rank * block[0]; stride[1] = 1; - start[0] = 0; - start[1] = (hsize_t)mpi_rank*block[1]; + start[0] = 0; + start[1] = (hsize_t)mpi_rank * block[1]; } - test_name = "Multi Chunk - Mixed"; + test_name = "Multi Chunk - Mixed"; actual_chunk_opt_mode_expected = H5D_MPIO_MULTI_CHUNK; - actual_io_mode_expected = H5D_MPIO_CHUNK_MIXED; + actual_io_mode_expected = H5D_MPIO_CHUNK_MIXED; break; /* RESET tests that the properties are properly reset to defaults each time I/O is @@ -3152,20 +3101,21 @@ test_actual_io_mode(int selection_mode) { * collectively, and their other chunk indpendently, reporting mixed I/O. */ - if(mpi_rank == 0) { - /* Select the first chunk in the first column */ - slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); - block[0] = block[0] / (hsize_t)mpi_size; - } else { + if (mpi_rank == 0) { + /* Select the first chunk in the first column */ + slab_set(mpi_rank, mpi_size, start, count, stride, block, BYCOL); + block[0] = block[0] / (hsize_t)mpi_size; + } + else { /* Select the first and the nth chunk in the nth column */ - block[0] = (hsize_t)(dim0 / mpi_size); - block[1] = (hsize_t)(dim1 / mpi_size); - count[0] = 2; - count[1] = 1; + block[0] = (hsize_t)(dim0 / mpi_size); + block[1] = (hsize_t)(dim1 / mpi_size); + count[0] = 2; + count[1] = 1; stride[0] = (hsize_t)mpi_rank * block[0]; stride[1] = 1; - start[0] = 0; - start[1] = (hsize_t)mpi_rank*block[1]; + start[0] = 0; + start[1] = (hsize_t)mpi_rank * block[1]; } /* If the testname was not already set by the RESET case */ @@ -3175,8 +3125,8 @@ test_actual_io_mode(int selection_mode) { test_name = "Multi Chunk - Mixed (Disagreement)"; actual_chunk_opt_mode_expected = H5D_MPIO_MULTI_CHUNK; - if(mpi_size > 1) { - if(mpi_rank == 0) + if (mpi_size > 1) { + if (mpi_rank == 0) actual_io_mode_expected = H5D_MPIO_CHUNK_COLLECTIVE; else actual_io_mode_expected = H5D_MPIO_CHUNK_MIXED; @@ -3191,9 +3141,9 @@ test_actual_io_mode(int selection_mode) { /* Nothing special; link chunk I/O is forced in the dxpl settings. */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); - test_name = "Link Chunk"; + test_name = "Link Chunk"; actual_chunk_opt_mode_expected = H5D_MPIO_LINK_CHUNK; - actual_io_mode_expected = H5D_MPIO_CHUNK_COLLECTIVE; + actual_io_mode_expected = H5D_MPIO_CHUNK_COLLECTIVE; break; /* Contiguous Dataset */ @@ -3202,23 +3152,23 @@ test_actual_io_mode(int selection_mode) { * collective I/O */ slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); - test_name = "Contiguous"; + test_name = "Contiguous"; actual_chunk_opt_mode_expected = H5D_MPIO_NO_CHUNK_OPTIMIZATION; - actual_io_mode_expected = H5D_MPIO_CONTIGUOUS_COLLECTIVE; + actual_io_mode_expected = H5D_MPIO_CONTIGUOUS_COLLECTIVE; break; case TEST_ACTUAL_IO_NO_COLLECTIVE: slab_set(mpi_rank, mpi_size, start, count, stride, block, BYROW); - test_name = "Independent"; + test_name = "Independent"; actual_chunk_opt_mode_expected = H5D_MPIO_NO_CHUNK_OPTIMIZATION; - actual_io_mode_expected = H5D_MPIO_NO_COLLECTIVE; + actual_io_mode_expected = H5D_MPIO_NO_COLLECTIVE; break; default: - test_name = "Undefined Selection Mode"; + test_name = "Undefined Selection Mode"; actual_chunk_opt_mode_expected = -1; - actual_io_mode_expected = -1; + actual_io_mode_expected = -1; break; } @@ -3228,7 +3178,7 @@ test_actual_io_mode(int selection_mode) { /* Create a memory dataspace mirroring the dataset and select the same hyperslab * as in the file space. */ - mem_space = H5Screate_simple (RANK, dims, NULL); + mem_space = H5Screate_simple(RANK, dims, NULL); VRFY((mem_space >= 0), "mem_space created"); ret = H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, start, stride, count, block); @@ -3240,7 +3190,7 @@ test_actual_io_mode(int selection_mode) { /* Allocate and initialize the buffer */ buffer = (int *)HDmalloc(sizeof(int) * (size_t)length); VRFY((buffer != NULL), "HDmalloc of buffer succeeded"); - for(i = 0; i < length; i++) + for (i = 0; i < length; i++) buffer[i] = i; /* Set up the dxpl for the write */ @@ -3248,7 +3198,7 @@ test_actual_io_mode(int selection_mode) { VRFY((dxpl_write >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded"); /* Set collective I/O properties in the dxpl. */ - if(is_collective) { + if (is_collective) { /* Request collective I/O */ ret = H5Pset_dxpl_mpio(dxpl_write, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); @@ -3258,19 +3208,19 @@ test_actual_io_mode(int selection_mode) { * multi chunk io instead of link chunk io. * This is via deault. */ - if(multi_chunk_io) { + if (multi_chunk_io) { /* force multi-chunk-io by threshold */ - ret = H5Pset_dxpl_mpio_chunk_opt_num(dxpl_write, (unsigned) mpi_size*2); + ret = H5Pset_dxpl_mpio_chunk_opt_num(dxpl_write, (unsigned)mpi_size * 2); VRFY((ret >= 0), "H5Pset_dxpl_mpio_chunk_opt_num succeeded"); /* set this to manipulate testing senario about allocating processes * to chunks */ - ret = H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl_write, (unsigned) 99); + ret = H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl_write, (unsigned)99); VRFY((ret >= 0), "H5Pset_dxpl_mpio_chunk_opt_ratio succeeded"); } /* Set directly go to multi-chunk-io without threshold calc. */ - if(direct_multi_chunk_io) { + if (direct_multi_chunk_io) { /* set for multi chunk io by property*/ ret = H5Pset_dxpl_mpio_chunk_opt(dxpl_write, H5FD_MPIO_CHUNK_MULTI_IO); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); @@ -3283,43 +3233,47 @@ test_actual_io_mode(int selection_mode) { /* Write */ ret = H5Dwrite(dataset, data_type, mem_space, file_space, dxpl_write, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dwrite() dataset multichunk write succeeded"); /* Retreive Actual io valuess */ ret = H5Pget_mpio_actual_io_mode(dxpl_write, &actual_io_mode_write); - VRFY((ret >= 0), "retriving actual io mode suceeded" ); + VRFY((ret >= 0), "retriving actual io mode suceeded"); ret = H5Pget_mpio_actual_chunk_opt_mode(dxpl_write, &actual_chunk_opt_mode_write); - VRFY((ret >= 0), "retriving actual chunk opt mode succeeded" ); + VRFY((ret >= 0), "retriving actual chunk opt mode succeeded"); /* Read */ ret = H5Dread(dataset, data_type, mem_space, file_space, dxpl_read, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dread() dataset multichunk read succeeded"); /* Retreive Actual io values */ ret = H5Pget_mpio_actual_io_mode(dxpl_read, &actual_io_mode_read); - VRFY((ret >= 0), "retriving actual io mode succeeded" ); + VRFY((ret >= 0), "retriving actual io mode succeeded"); ret = H5Pget_mpio_actual_chunk_opt_mode(dxpl_read, &actual_chunk_opt_mode_read); - VRFY((ret >= 0), "retriving actual chunk opt mode succeeded" ); + VRFY((ret >= 0), "retriving actual chunk opt mode succeeded"); /* Check write vs read */ VRFY((actual_io_mode_read == actual_io_mode_write), - "reading and writing are the same for actual_io_mode"); + "reading and writing are the same for actual_io_mode"); VRFY((actual_chunk_opt_mode_read == actual_chunk_opt_mode_write), - "reading and writing are the same for actual_chunk_opt_mode"); + "reading and writing are the same for actual_chunk_opt_mode"); /* Test values */ - if(actual_chunk_opt_mode_expected != (H5D_mpio_actual_chunk_opt_mode_t) -1 && actual_io_mode_expected != (H5D_mpio_actual_io_mode_t) -1) { - HDsprintf(message, "Actual Chunk Opt Mode has the correct value for %s.\n",test_name); + if (actual_chunk_opt_mode_expected != (H5D_mpio_actual_chunk_opt_mode_t)-1 && + actual_io_mode_expected != (H5D_mpio_actual_io_mode_t)-1) { + HDsprintf(message, "Actual Chunk Opt Mode has the correct value for %s.\n", test_name); VRFY((actual_chunk_opt_mode_write == actual_chunk_opt_mode_expected), message); - HDsprintf(message, "Actual IO Mode has the correct value for %s.\n",test_name); + HDsprintf(message, "Actual IO Mode has the correct value for %s.\n", test_name); VRFY((actual_io_mode_write == actual_io_mode_expected), message); - } else { - HDfprintf(stderr, "%s %d -> (%d,%d)\n", test_name, mpi_rank, - actual_chunk_opt_mode_write, actual_io_mode_write); + } + else { + HDfprintf(stderr, "%s %d -> (%d,%d)\n", test_name, mpi_rank, actual_chunk_opt_mode_write, + actual_io_mode_write); } /* To test that the property is succesfully reset to the default, we perform some @@ -3339,14 +3293,14 @@ test_actual_io_mode(int selection_mode) { /* Check Properties */ ret = H5Pget_mpio_actual_io_mode(dxpl_write, &actual_io_mode_write); - VRFY( (ret >= 0), "retriving actual io mode succeeded" ); + VRFY((ret >= 0), "retriving actual io mode succeeded"); ret = H5Pget_mpio_actual_chunk_opt_mode(dxpl_write, &actual_chunk_opt_mode_write); - VRFY( (ret >= 0), "retriving actual chunk opt mode succeeded" ); + VRFY((ret >= 0), "retriving actual chunk opt mode succeeded"); VRFY(actual_chunk_opt_mode_write == H5D_MPIO_NO_CHUNK_OPTIMIZATION, - "actual_chunk_opt_mode has correct value for reset write (independent)"); + "actual_chunk_opt_mode has correct value for reset write (independent)"); VRFY(actual_io_mode_write == H5D_MPIO_NO_COLLECTIVE, - "actual_io_mode has correct value for reset write (independent)"); + "actual_io_mode has correct value for reset write (independent)"); /* Read */ ret = H5Dread(dataset, data_type, H5S_ALL, H5S_ALL, dxpl_read, buffer); @@ -3354,15 +3308,15 @@ test_actual_io_mode(int selection_mode) { /* Check Properties */ ret = H5Pget_mpio_actual_io_mode(dxpl_read, &actual_io_mode_read); - VRFY( (ret >= 0), "retriving actual io mode succeeded" ); + VRFY((ret >= 0), "retriving actual io mode succeeded"); ret = H5Pget_mpio_actual_chunk_opt_mode(dxpl_read, &actual_chunk_opt_mode_read); - VRFY( (ret >= 0), "retriving actual chunk opt mode succeeded" ); + VRFY((ret >= 0), "retriving actual chunk opt mode succeeded"); VRFY(actual_chunk_opt_mode_read == H5D_MPIO_NO_CHUNK_OPTIMIZATION, - "actual_chunk_opt_mode has correct value for reset read (independent)"); + "actual_chunk_opt_mode has correct value for reset read (independent)"); VRFY(actual_io_mode_read == H5D_MPIO_NO_COLLECTIVE, - "actual_io_mode has correct value for reset read (independent)"); - } + "actual_io_mode has correct value for reset read (independent)"); + } } /* Release some resources */ @@ -3379,7 +3333,6 @@ test_actual_io_mode(int selection_mode) { return; } - /* Function: actual_io_mode_tests * * Purpose: Tests all possible cases of the actual_io_mode property. @@ -3388,7 +3341,8 @@ test_actual_io_mode(int selection_mode) { * Date: 2011-04-06 */ void -actual_io_mode_tests(void) { +actual_io_mode_tests(void) +{ int mpi_size = -1; int mpi_rank = -1; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); @@ -3463,7 +3417,8 @@ actual_io_mode_tests(void) { * * TEST_FILTERS: * Test for using filter (checksum) as the cause of breaking collective I/O. - * Note: TEST_FILTERS mode will not work until H5Dcreate and H5write is supported for mpio and filter feature. Use test_no_collective_cause_mode_filter() function instead. + * Note: TEST_FILTERS mode will not work until H5Dcreate and H5write is supported for mpio and filter + * feature. Use test_no_collective_cause_mode_filter() function instead. * * * Programmer: Jonathan Kim @@ -3476,34 +3431,34 @@ actual_io_mode_tests(void) { static void test_no_collective_cause_mode(int selection_mode) { - uint32_t no_collective_cause_local_write = 0; - uint32_t no_collective_cause_local_read = 0; - uint32_t no_collective_cause_local_expected = 0; - uint32_t no_collective_cause_global_write = 0; - uint32_t no_collective_cause_global_read = 0; + uint32_t no_collective_cause_local_write = 0; + uint32_t no_collective_cause_local_read = 0; + uint32_t no_collective_cause_local_expected = 0; + uint32_t no_collective_cause_global_write = 0; + uint32_t no_collective_cause_global_read = 0; uint32_t no_collective_cause_global_expected = 0; - const char * filename; - const char * test_name; - hbool_t is_chunked=1; - hbool_t is_independent=0; - int mpi_size = -1; - int mpi_rank = -1; + const char *filename; + const char *test_name; + hbool_t is_chunked = 1; + hbool_t is_independent = 0; + int mpi_size = -1; + int mpi_rank = -1; int length; - int * buffer; + int * buffer; int i; MPI_Comm mpi_comm; MPI_Info mpi_info; - hid_t fid = -1; - hid_t sid = -1; - hid_t dataset = -1; - hid_t data_type = H5T_NATIVE_INT; - hid_t fapl = -1; - hid_t dcpl = -1; + hid_t fid = -1; + hid_t sid = -1; + hid_t dataset = -1; + hid_t data_type = H5T_NATIVE_INT; + hid_t fapl = -1; + hid_t dcpl = -1; hid_t dxpl_write = -1; - hid_t dxpl_read = -1; + hid_t dxpl_read = -1; hsize_t dims[RANK]; - hid_t mem_space = -1; + hid_t mem_space = -1; hid_t file_space = -1; hsize_t chunk_dims[RANK]; herr_t ret; @@ -3511,7 +3466,7 @@ test_no_collective_cause_mode(int selection_mode) H5Z_filter_t filter_info; #endif /* LATER */ /* set to global value as default */ - int l_facc_type = facc_type; + int l_facc_type = facc_type; char message[256]; /* Set up MPI parameters */ @@ -3530,27 +3485,29 @@ test_no_collective_cause_mode(int selection_mode) VRFY((dcpl >= 0), "dataset creation plist created successfully"); if (selection_mode & TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_COMPACT) { - ret = H5Pset_layout (dcpl, H5D_COMPACT); - VRFY((ret >= 0),"set COMPACT layout succeeded"); + ret = H5Pset_layout(dcpl, H5D_COMPACT); + VRFY((ret >= 0), "set COMPACT layout succeeded"); is_chunked = 0; } if (selection_mode & TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL) { - ret = H5Pset_external (dcpl, FILE_EXTERNAL, (off_t) 0, H5F_UNLIMITED); - VRFY((ret >= 0),"set EXTERNAL file layout succeeded"); + ret = H5Pset_external(dcpl, FILE_EXTERNAL, (off_t)0, H5F_UNLIMITED); + VRFY((ret >= 0), "set EXTERNAL file layout succeeded"); is_chunked = 0; } #ifdef LATER /* fletcher32 */ if (selection_mode & TEST_FILTERS) { ret = H5Zfilter_avail(H5Z_FILTER_FLETCHER32); - VRFY ((ret >=0 ), "Fletcher32 filter is available.\n"); + VRFY((ret >= 0), "Fletcher32 filter is available.\n"); - ret = H5Zget_filter_info (H5Z_FILTER_FLETCHER32, &filter_info); - VRFY ( ( (filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) || (filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED) ) , "Fletcher32 filter encoding and decoding available.\n"); + ret = H5Zget_filter_info(H5Z_FILTER_FLETCHER32, &filter_info); + VRFY(((filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) || + (filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED)), + "Fletcher32 filter encoding and decoding available.\n"); ret = H5Pset_fletcher32(dcpl); - VRFY((ret >= 0),"set filter (flecher32) succeeded"); + VRFY((ret >= 0), "set filter (flecher32) succeeded"); } #endif /* LATER */ @@ -3570,11 +3527,10 @@ test_no_collective_cause_mode(int selection_mode) dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; } - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); } - filename = (const char *)GetTestParameters(); HDassert(filename != NULL); @@ -3588,20 +3544,18 @@ test_no_collective_cause_mode(int selection_mode) VRFY((fid >= 0), "H5Fcreate succeeded"); /* If we are not testing contiguous datasets */ - if(is_chunked) { + if (is_chunked) { /* Set up chunk information. */ - chunk_dims[0] = dims[0]/(hsize_t)mpi_size; + chunk_dims[0] = dims[0] / (hsize_t)mpi_size; chunk_dims[1] = dims[1]; - ret = H5Pset_chunk(dcpl, 2, chunk_dims); - VRFY((ret >= 0),"chunk creation property list succeeded"); + ret = H5Pset_chunk(dcpl, 2, chunk_dims); + VRFY((ret >= 0), "chunk creation property list succeeded"); } - /* Create the dataset */ dataset = H5Dcreate2(fid, "nocolcause", data_type, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dcreate2() dataset succeeded"); - /* * Set expected causes and some tweaks based on the type of test */ @@ -3641,14 +3595,14 @@ test_no_collective_cause_mode(int selection_mode) #endif /* LATER */ if (selection_mode & TEST_COLLECTIVE) { - test_name = "Broken Collective I/O - Not Broken"; - no_collective_cause_local_expected = H5D_MPIO_COLLECTIVE; + test_name = "Broken Collective I/O - Not Broken"; + no_collective_cause_local_expected = H5D_MPIO_COLLECTIVE; no_collective_cause_global_expected = H5D_MPIO_COLLECTIVE; } if (selection_mode & TEST_SET_INDEPENDENT) { - test_name = "Broken Collective I/O - Independent"; - no_collective_cause_local_expected = H5D_MPIO_SET_INDEPENDENT; + test_name = "Broken Collective I/O - Independent"; + no_collective_cause_local_expected = H5D_MPIO_SET_INDEPENDENT; no_collective_cause_global_expected = H5D_MPIO_SET_INDEPENDENT; /* switch to independent io */ is_independent = 1; @@ -3658,7 +3612,7 @@ test_no_collective_cause_mode(int selection_mode) if (selection_mode & TEST_NOT_SIMPLE_OR_SCALAR_DATASPACES || selection_mode & TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL) { file_space = H5S_ALL; - mem_space = H5S_ALL; + mem_space = H5S_ALL; } else { /* Get the file dataspace */ @@ -3666,7 +3620,7 @@ test_no_collective_cause_mode(int selection_mode) VRFY((file_space >= 0), "H5Dget_space succeeded"); /* Create the memory dataspace */ - mem_space = H5Screate_simple (RANK, dims, NULL); + mem_space = H5Screate_simple(RANK, dims, NULL); VRFY((mem_space >= 0), "mem_space created"); } @@ -3676,14 +3630,14 @@ test_no_collective_cause_mode(int selection_mode) /* Allocate and initialize the buffer */ buffer = (int *)HDmalloc(sizeof(int) * (size_t)length); VRFY((buffer != NULL), "HDmalloc of buffer succeeded"); - for(i = 0; i < length; i++) + for (i = 0; i < length; i++) buffer[i] = i; /* Set up the dxpl for the write */ dxpl_write = H5Pcreate(H5P_DATASET_XFER); VRFY((dxpl_write >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded"); - if(is_independent) { + if (is_independent) { /* Set Independent I/O */ ret = H5Pset_dxpl_mpio(dxpl_write, H5FD_MPIO_INDEPENDENT); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); @@ -3692,11 +3646,10 @@ test_no_collective_cause_mode(int selection_mode) /* Set Collective I/O */ ret = H5Pset_dxpl_mpio(dxpl_write, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - } if (selection_mode & TEST_DATA_TRANSFORMS) { - ret = H5Pset_data_transform (dxpl_write, "x+1"); + ret = H5Pset_data_transform(dxpl_write, "x+1"); VRFY((ret >= 0), "H5Pset_data_transform succeeded"); } @@ -3706,14 +3659,14 @@ test_no_collective_cause_mode(int selection_mode) /* Write */ ret = H5Dwrite(dataset, data_type, mem_space, file_space, dxpl_write, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dwrite() dataset multichunk write succeeded"); - /* Get the cause of broken collective I/O */ - ret = H5Pget_mpio_no_collective_cause (dxpl_write, &no_collective_cause_local_write, &no_collective_cause_global_write); - VRFY((ret >= 0), "retriving no collective cause succeeded" ); - + ret = H5Pget_mpio_no_collective_cause(dxpl_write, &no_collective_cause_local_write, + &no_collective_cause_global_write); + VRFY((ret >= 0), "retriving no collective cause succeeded"); /*--------------------- * Test Read access @@ -3726,25 +3679,27 @@ test_no_collective_cause_mode(int selection_mode) /* Read */ ret = H5Dread(dataset, data_type, mem_space, file_space, dxpl_read, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dread() dataset multichunk read succeeded"); /* Get the cause of broken collective I/O */ - ret = H5Pget_mpio_no_collective_cause (dxpl_read, &no_collective_cause_local_read, &no_collective_cause_global_read); - VRFY((ret >= 0), "retriving no collective cause succeeded" ); + ret = H5Pget_mpio_no_collective_cause(dxpl_read, &no_collective_cause_local_read, + &no_collective_cause_global_read); + VRFY((ret >= 0), "retriving no collective cause succeeded"); /* Check write vs read */ VRFY((no_collective_cause_local_read == no_collective_cause_local_write), - "reading and writing are the same for local cause of Broken Collective I/O"); + "reading and writing are the same for local cause of Broken Collective I/O"); VRFY((no_collective_cause_global_read == no_collective_cause_global_write), - "reading and writing are the same for global cause of Broken Collective I/O"); + "reading and writing are the same for global cause of Broken Collective I/O"); /* Test values */ - HDmemset (message, 0, sizeof (message)); - HDsprintf(message, "Local cause of Broken Collective I/O has the correct value for %s.\n",test_name); + HDmemset(message, 0, sizeof(message)); + HDsprintf(message, "Local cause of Broken Collective I/O has the correct value for %s.\n", test_name); VRFY((no_collective_cause_local_write == no_collective_cause_local_expected), message); - HDmemset (message, 0, sizeof (message)); - HDsprintf(message, "Global cause of Broken Collective I/O has the correct value for %s.\n",test_name); + HDmemset(message, 0, sizeof(message)); + HDsprintf(message, "Global cause of Broken Collective I/O has the correct value for %s.\n", test_name); VRFY((no_collective_cause_global_write == no_collective_cause_global_expected), message); /* Release some resources */ @@ -3775,7 +3730,6 @@ test_no_collective_cause_mode(int selection_mode) return; } - /* * Function: test_no_collective_cause_mode_filter * @@ -3800,31 +3754,31 @@ test_no_collective_cause_mode(int selection_mode) static void test_no_collective_cause_mode_filter(int selection_mode) { - uint32_t no_collective_cause_local_read = 0; - uint32_t no_collective_cause_local_expected = 0; - uint32_t no_collective_cause_global_read = 0; + uint32_t no_collective_cause_local_read = 0; + uint32_t no_collective_cause_local_expected = 0; + uint32_t no_collective_cause_global_read = 0; uint32_t no_collective_cause_global_expected = 0; - const char * filename; - const char * test_name = "I/O"; - hbool_t is_chunked=1; - int mpi_size = -1; - int mpi_rank = -1; + const char *filename; + const char *test_name = "I/O"; + hbool_t is_chunked = 1; + int mpi_size = -1; + int mpi_rank = -1; int length; - int * buffer; + int * buffer; int i; - MPI_Comm mpi_comm = MPI_COMM_NULL; - MPI_Info mpi_info = MPI_INFO_NULL; - hid_t fid = -1; - hid_t sid = -1; - hid_t dataset = -1; - hid_t data_type = H5T_NATIVE_INT; + MPI_Comm mpi_comm = MPI_COMM_NULL; + MPI_Info mpi_info = MPI_INFO_NULL; + hid_t fid = -1; + hid_t sid = -1; + hid_t dataset = -1; + hid_t data_type = H5T_NATIVE_INT; hid_t fapl_write = -1; - hid_t fapl_read = -1; - hid_t dcpl = -1; - hid_t dxpl = -1; + hid_t fapl_read = -1; + hid_t dcpl = -1; + hid_t dxpl = -1; hsize_t dims[RANK]; - hid_t mem_space = -1; + hid_t mem_space = -1; hid_t file_space = -1; hsize_t chunk_dims[RANK]; herr_t ret; @@ -3848,29 +3802,30 @@ test_no_collective_cause_mode_filter(int selection_mode) dcpl = H5Pcreate(H5P_DATASET_CREATE); VRFY((dcpl >= 0), "dataset creation plist created successfully"); - if (selection_mode == TEST_FILTERS_READ ) { + if (selection_mode == TEST_FILTERS_READ) { #ifdef LATER /* fletcher32 */ - ret = H5Zfilter_avail(H5Z_FILTER_FLETCHER32); - VRFY ((ret >=0 ), "Fletcher32 filter is available.\n"); + ret = H5Zfilter_avail(H5Z_FILTER_FLETCHER32); + VRFY((ret >= 0), "Fletcher32 filter is available.\n"); - ret = H5Zget_filter_info (H5Z_FILTER_FLETCHER32, (unsigned int *) &filter_info); - VRFY ( ( (filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) || (filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED) ) , "Fletcher32 filter encoding and decoding available.\n"); + ret = H5Zget_filter_info(H5Z_FILTER_FLETCHER32, (unsigned int *)&filter_info); + VRFY(((filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) || + (filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED)), + "Fletcher32 filter encoding and decoding available.\n"); - ret = H5Pset_fletcher32(dcpl); - VRFY((ret >= 0),"set filter (flecher32) succeeded"); + ret = H5Pset_fletcher32(dcpl); + VRFY((ret >= 0), "set filter (flecher32) succeeded"); #endif /* LATER */ } - else { + else { VRFY(0, "Unexpected mode, only test for TEST_FILTERS_READ."); } /* Create the basic Space */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); - filename = (const char *)GetTestParameters(); HDassert(filename != NULL); @@ -3882,23 +3837,22 @@ test_no_collective_cause_mode_filter(int selection_mode) VRFY((fid >= 0), "H5Fcreate succeeded"); /* If we are not testing contiguous datasets */ - if(is_chunked) { + if (is_chunked) { /* Set up chunk information. */ - chunk_dims[0] = dims[0]/(hsize_t)mpi_size; + chunk_dims[0] = dims[0] / (hsize_t)mpi_size; chunk_dims[1] = dims[1]; - ret = H5Pset_chunk(dcpl, 2, chunk_dims); - VRFY((ret >= 0),"chunk creation property list succeeded"); + ret = H5Pset_chunk(dcpl, 2, chunk_dims); + VRFY((ret >= 0), "chunk creation property list succeeded"); } - /* Create the dataset */ dataset = H5Dcreate2(fid, DSET_NOCOLCAUSE, data_type, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dcreate2() dataset succeeded"); #ifdef LATER /* fletcher32 */ /* Set expected cause */ - test_name = "Broken Collective I/O - Filter is required"; - no_collective_cause_local_expected = H5D_MPIO_FILTERS; + test_name = "Broken Collective I/O - Filter is required"; + no_collective_cause_local_expected = H5D_MPIO_FILTERS; no_collective_cause_global_expected = H5D_MPIO_FILTERS; #endif /* LATER */ @@ -3907,7 +3861,7 @@ test_no_collective_cause_mode_filter(int selection_mode) VRFY((file_space >= 0), "H5Dget_space succeeded"); /* Create the memory dataspace */ - mem_space = H5Screate_simple (RANK, dims, NULL); + mem_space = H5Screate_simple(RANK, dims, NULL); VRFY((mem_space >= 0), "mem_space created"); /* Get the number of elements in the selection */ @@ -3916,33 +3870,32 @@ test_no_collective_cause_mode_filter(int selection_mode) /* Allocate and initialize the buffer */ buffer = (int *)HDmalloc(sizeof(int) * length); VRFY((buffer != NULL), "HDmalloc of buffer succeeded"); - for(i = 0; i < length; i++) + for (i = 0; i < length; i++) buffer[i] = i; /* Set up the dxpl for the write */ dxpl = H5Pcreate(H5P_DATASET_XFER); VRFY((dxpl >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded"); - if (selection_mode == TEST_FILTERS_READ) { + if (selection_mode == TEST_FILTERS_READ) { /* To test read in collective I/O mode , write in independent mode * because write fails with mpio + filter */ ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_INDEPENDENT); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); } - else { + else { /* To test write in collective I/O mode. */ ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); } - /* Write */ ret = H5Dwrite(dataset, data_type, mem_space, file_space, dxpl, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dwrite() dataset multichunk write succeeded"); - /* Make a copy of the dxpl to test the read operation */ dxpl = H5Pcopy(dxpl); VRFY((dxpl >= 0), "H5Pcopy succeeded"); @@ -3954,7 +3907,6 @@ test_no_collective_cause_mode_filter(int selection_mode) if (fid) H5Fclose(fid); - /*--------------------- * Test Read access *---------------------*/ @@ -3963,8 +3915,8 @@ test_no_collective_cause_mode_filter(int selection_mode) fapl_read = create_faccess_plist(mpi_comm, mpi_info, facc_type); VRFY((fapl_read >= 0), "create_faccess_plist() succeeded"); - fid = H5Fopen (filename, H5F_ACC_RDONLY, fapl_read); - dataset = H5Dopen2 (fid, DSET_NOCOLCAUSE, H5P_DEFAULT); + fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl_read); + dataset = H5Dopen2(fid, DSET_NOCOLCAUSE, H5P_DEFAULT); /* Set collective I/O properties in the dxpl. */ ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); @@ -3973,19 +3925,21 @@ test_no_collective_cause_mode_filter(int selection_mode) /* Read */ ret = H5Dread(dataset, data_type, mem_space, file_space, dxpl, buffer); - if(ret < 0) H5Eprint2(H5E_DEFAULT, stdout); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stdout); VRFY((ret >= 0), "H5Dread() dataset multichunk read succeeded"); /* Get the cause of broken collective I/O */ - ret = H5Pget_mpio_no_collective_cause (dxpl, &no_collective_cause_local_read, &no_collective_cause_global_read); - VRFY((ret >= 0), "retriving no collective cause succeeded" ); + ret = H5Pget_mpio_no_collective_cause(dxpl, &no_collective_cause_local_read, + &no_collective_cause_global_read); + VRFY((ret >= 0), "retriving no collective cause succeeded"); /* Test values */ - HDmemset (message, 0, sizeof (message)); - HDsprintf(message, "Local cause of Broken Collective I/O has the correct value for %s.\n",test_name); + HDmemset(message, 0, sizeof(message)); + HDsprintf(message, "Local cause of Broken Collective I/O has the correct value for %s.\n", test_name); VRFY((no_collective_cause_local_read == (uint32_t)no_collective_cause_local_expected), message); - HDmemset (message, 0, sizeof (message)); - HDsprintf(message, "Global cause of Broken Collective I/O has the correct value for %s.\n",test_name); + HDmemset(message, 0, sizeof(message)); + HDsprintf(message, "Global cause of Broken Collective I/O has the correct value for %s.\n", test_name); VRFY((no_collective_cause_global_read == (uint32_t)no_collective_cause_global_expected), message); /* Release some resources */ @@ -4023,27 +3977,28 @@ no_collective_cause_tests(void) /* * Test individual cause */ - test_no_collective_cause_mode (TEST_COLLECTIVE); - test_no_collective_cause_mode (TEST_SET_INDEPENDENT); - test_no_collective_cause_mode (TEST_DATATYPE_CONVERSION); - test_no_collective_cause_mode (TEST_DATA_TRANSFORMS); - test_no_collective_cause_mode (TEST_NOT_SIMPLE_OR_SCALAR_DATASPACES); - test_no_collective_cause_mode (TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_COMPACT); - test_no_collective_cause_mode (TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL); + test_no_collective_cause_mode(TEST_COLLECTIVE); + test_no_collective_cause_mode(TEST_SET_INDEPENDENT); + test_no_collective_cause_mode(TEST_DATATYPE_CONVERSION); + test_no_collective_cause_mode(TEST_DATA_TRANSFORMS); + test_no_collective_cause_mode(TEST_NOT_SIMPLE_OR_SCALAR_DATASPACES); + test_no_collective_cause_mode(TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_COMPACT); + test_no_collective_cause_mode(TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL); #ifdef LATER /* fletcher32 */ - /* TODO: use this instead of below TEST_FILTERS_READ when H5Dcreate and - * H5Dwrite is ready for mpio + filter feature. - */ + /* TODO: use this instead of below TEST_FILTERS_READ when H5Dcreate and + * H5Dwrite is ready for mpio + filter feature. + */ /* test_no_collective_cause_mode (TEST_FILTERS); */ - test_no_collective_cause_mode_filter (TEST_FILTERS_READ); + test_no_collective_cause_mode_filter(TEST_FILTERS_READ); #endif /* LATER */ /* * Test combined causes */ - test_no_collective_cause_mode (TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL | TEST_DATATYPE_CONVERSION); - test_no_collective_cause_mode (TEST_DATATYPE_CONVERSION | TEST_DATA_TRANSFORMS); - test_no_collective_cause_mode (TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL | TEST_DATATYPE_CONVERSION | TEST_DATA_TRANSFORMS); + test_no_collective_cause_mode(TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL | TEST_DATATYPE_CONVERSION); + test_no_collective_cause_mode(TEST_DATATYPE_CONVERSION | TEST_DATA_TRANSFORMS); + test_no_collective_cause_mode(TEST_NOT_CONTIGUOUS_OR_CHUNKED_DATASET_EXTERNAL | TEST_DATATYPE_CONVERSION | + TEST_DATA_TRANSFORMS); return; } @@ -4062,41 +4017,42 @@ no_collective_cause_tests(void) void dataset_atomicity(void) { - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t sid; /* Dataspace ID */ - hid_t dataset1; /* Dataset IDs */ - hsize_t dims[RANK]; /* dataset dim sizes */ - int *write_buf = NULL; /* data buffer */ - int *read_buf = NULL; /* data buffer */ - int buf_size; - hid_t dataset2; - hid_t file_dataspace; /* File dataspace ID */ - hid_t mem_dataspace; /* Memory dataspace ID */ - hsize_t start[RANK]; - hsize_t stride[RANK]; - hsize_t count[RANK]; - hsize_t block[RANK]; + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t sid; /* Dataspace ID */ + hid_t dataset1; /* Dataset IDs */ + hsize_t dims[RANK]; /* dataset dim sizes */ + int * write_buf = NULL; /* data buffer */ + int * read_buf = NULL; /* data buffer */ + int buf_size; + hid_t dataset2; + hid_t file_dataspace; /* File dataspace ID */ + hid_t mem_dataspace; /* Memory dataspace ID */ + hsize_t start[RANK]; + hsize_t stride[RANK]; + hsize_t count[RANK]; + hsize_t block[RANK]; const char *filename; - herr_t ret; /* Generic return value */ - int mpi_size, mpi_rank; - int i, j, k; - hbool_t atomicity = FALSE; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - - dim0 = 64; dim1 = 32; + herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; + int i, j, k; + hbool_t atomicity = FALSE; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + dim0 = 64; + dim1 = 32; filename = GetTestParameters(); if (facc_type != FACC_MPIO) { HDprintf("Atomicity tests will not work without the MPIO VFD\n"); return; } - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("atomic writes to file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); buf_size = dim0 * dim1; /* allocate memory for data buffer */ @@ -4121,26 +4077,22 @@ dataset_atomicity(void) /* setup dimensionality object */ dims[0] = (hsize_t)dim0; dims[1] = (hsize_t)dim1; - sid = H5Screate_simple (RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* create datasets */ - dataset1 = H5Dcreate2(fid, DATASETNAME5, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset1 = H5Dcreate2(fid, DATASETNAME5, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset1 >= 0), "H5Dcreate2 succeeded"); - dataset2 = H5Dcreate2(fid, DATASETNAME6, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset2 = H5Dcreate2(fid, DATASETNAME6, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset2 >= 0), "H5Dcreate2 succeeded"); /* initialize datasets to 0s */ if (0 == mpi_rank) { - ret = H5Dwrite(dataset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, write_buf); + ret = H5Dwrite(dataset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded"); - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, write_buf); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, write_buf); VRFY((ret >= 0), "H5Dwrite dataset2 succeeded"); } @@ -4153,39 +4105,39 @@ dataset_atomicity(void) ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded"); - MPI_Barrier (comm); + MPI_Barrier(comm); /* make sure setting atomicity fails on a serial file ID */ /* file locking allows only one file open (serial) for writing */ - if(MAINPROCESS){ - fid=H5Fopen(filename,H5F_ACC_RDWR,H5P_DEFAULT); + if (MAINPROCESS) { + fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); VRFY((fid >= 0), "H5Fopen succeeed"); } /* should fail */ - ret = H5Fset_mpi_atomicity(fid , TRUE); + ret = H5Fset_mpi_atomicity(fid, TRUE); VRFY((ret == FAIL), "H5Fset_mpi_atomicity failed"); - if(MAINPROCESS){ + if (MAINPROCESS) { ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded"); } - MPI_Barrier (comm); + MPI_Barrier(comm); /* setup file access template */ acc_tpl = create_faccess_plist(comm, info, facc_type); VRFY((acc_tpl >= 0), ""); /* open the file collectively */ - fid=H5Fopen(filename,H5F_ACC_RDWR,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDWR, acc_tpl); VRFY((fid >= 0), "H5Fopen succeeded"); /* Release file-access template */ ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose succeeded"); - ret = H5Fset_mpi_atomicity(fid , TRUE); + ret = H5Fset_mpi_atomicity(fid, TRUE); VRFY((ret >= 0), "H5Fset_mpi_atomicity succeeded"); /* open dataset1 (contiguous case) */ @@ -4193,22 +4145,22 @@ dataset_atomicity(void) VRFY((dataset1 >= 0), "H5Dopen2 succeeded"); if (0 == mpi_rank) { - for (i=0 ; i= 0), "atomcity get failed"); VRFY((atomicity == TRUE), "atomcity set failed"); - MPI_Barrier (comm); + MPI_Barrier(comm); /* Process 0 writes contiguously to the entire dataset */ if (0 == mpi_rank) { @@ -4221,12 +4173,14 @@ dataset_atomicity(void) VRFY((ret >= 0), "H5Dwrite() dataset multichunk write succeeded"); } - if(VERBOSE_MED) { - i=0;j=0;k=0; - for (i=0 ; i= 0), "H5D close succeeded"); /* release data buffers */ - if(write_buf) HDfree(write_buf); - if(read_buf) HDfree(read_buf); + if (write_buf) + HDfree(write_buf); + if (read_buf) + HDfree(read_buf); /* open dataset2 (non-contiguous case) */ dataset2 = H5Dopen2(fid, DATASETNAME6, H5P_DEFAULT); @@ -4264,69 +4221,68 @@ dataset_atomicity(void) read_buf = (int *)HDcalloc((size_t)buf_size, sizeof(int)); VRFY((read_buf != NULL), "read_buf HDcalloc succeeded"); - for (i=0 ; i= 0), "atomcity get failed"); VRFY((atomicity == TRUE), "atomcity set failed"); - - block[0] = (hsize_t)(dim0/mpi_size - 1); - block[1] = (hsize_t)(dim1/mpi_size - 1); + block[0] = (hsize_t)(dim0 / mpi_size - 1); + block[1] = (hsize_t)(dim1 / mpi_size - 1); stride[0] = block[0] + 1; stride[1] = block[1] + 1; - count[0] = (hsize_t)mpi_size; - count[1] = (hsize_t)mpi_size; - start[0] = 0; - start[1] = 0; + count[0] = (hsize_t)mpi_size; + count[1] = (hsize_t)mpi_size; + start[0] = 0; + start[1] = 0; /* create a file dataspace */ - file_dataspace = H5Dget_space (dataset2); + file_dataspace = H5Dget_space(dataset2); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace */ - mem_dataspace = H5Screate_simple (RANK, dims, NULL); + mem_dataspace = H5Screate_simple(RANK, dims, NULL); VRFY((mem_dataspace >= 0), ""); ret = H5Sselect_hyperslab(mem_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); - MPI_Barrier (comm); + MPI_Barrier(comm); /* Process 0 writes to the dataset */ if (0 == mpi_rank) { - ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, write_buf); + ret = H5Dwrite(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, write_buf); VRFY((ret >= 0), "H5Dwrite dataset2 succeeded"); } /* All processes wait for the write to finish. This works because atomicity is set to true */ - MPI_Barrier (comm); + MPI_Barrier(comm); /* The other processes read the entire dataset */ if (0 != mpi_rank) { - ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, - H5P_DEFAULT, read_buf); + ret = H5Dread(dataset2, H5T_NATIVE_INT, mem_dataspace, file_dataspace, H5P_DEFAULT, read_buf); VRFY((ret >= 0), "H5Dread dataset2 succeeded"); } - if(VERBOSE_MED) { + if (VERBOSE_MED) { if (mpi_rank == 1) { - i=0;j=0;k=0; - for (i=0 ; i= mpi_rank*((int)block[0]+1)) { + for (i = 0; i < dim0; i++) { + if (i >= mpi_rank * ((int)block[0] + 1)) { break; } - if ((i+1)%((int)block[0]+1)==0) { + if ((i + 1) % ((int)block[0] + 1) == 0) { k += dim1; continue; } - for (j=0 ; j= mpi_rank*((int)block[1]+1)) { - k += dim1 - mpi_rank*((int)block[1]+1); + for (j = 0; j < dim1; j++) { + if (j >= mpi_rank * ((int)block[1] + 1)) { + k += dim1 - mpi_rank * ((int)block[1] + 1); break; } - if ((j+1)%((int)block[1]+1)==0) { + if ((j + 1) % ((int)block[1] + 1) == 0) { k++; continue; } else if (compare != read_buf[k]) { - HDprintf("Atomicity Test Failed Process %d: read_buf[%d] is %d, should be %d\n", mpi_rank, k, read_buf[k], compare); + HDprintf("Atomicity Test Failed Process %d: read_buf[%d] is %d, should be %d\n", mpi_rank, + k, read_buf[k], compare); nerrors++; } - k ++; + k++; } } } @@ -4374,12 +4333,13 @@ dataset_atomicity(void) VRFY((ret >= 0), "H5Sclose succeeded"); /* release data buffers */ - if(write_buf) HDfree(write_buf); - if(read_buf) HDfree(read_buf); + if (write_buf) + HDfree(write_buf); + if (read_buf) + HDfree(read_buf); ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded"); - } /* Function: dense_attr_test @@ -4392,21 +4352,21 @@ dataset_atomicity(void) void test_dense_attr(void) { - int mpi_size, mpi_rank; - hid_t fpid, fid; - hid_t gid, gpid; - hid_t atFileSpace, atid; - hsize_t atDims[1] = {10000}; - herr_t status; + int mpi_size, mpi_rank; + hid_t fpid, fid; + hid_t gid, gpid; + hid_t atFileSpace, atid; + hsize_t atDims[1] = {10000}; + herr_t status; const char *filename; /* get filename */ filename = (const char *)GetTestParameters(); - HDassert( filename != NULL ); + HDassert(filename != NULL); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); fpid = H5Pcreate(H5P_FILE_ACCESS); VRFY((fpid > 0), "H5Pcreate succeeded"); @@ -4445,4 +4405,3 @@ test_dense_attr(void) return; } - diff --git a/testpar/t_file.c b/testpar/t_file.c index 19a75c8..d284651 100644 --- a/testpar/t_file.c +++ b/testpar/t_file.c @@ -17,30 +17,30 @@ #include "testphdf5.h" -#include "H5CXprivate.h" /* API Contexts */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Iprivate.h" #include "H5PBprivate.h" /* * This file needs to access private information from the H5F package. */ -#define H5AC_FRIEND /*suppress error about including H5ACpkg */ +#define H5AC_FRIEND /*suppress error about including H5ACpkg */ #include "H5ACpkg.h" -#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ #include "H5Cpkg.h" -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING #include "H5Fpkg.h" -#define H5MF_FRIEND /*suppress error about including H5MFpkg */ +#define H5MF_FRIEND /*suppress error about including H5MFpkg */ #include "H5MFpkg.h" -#define NUM_DSETS 5 +#define NUM_DSETS 5 int mpi_size, mpi_rank; static int create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_strategy); -static int open_file(const char *filename, hid_t fapl, int metadata_write_strategy, - hsize_t page_size, size_t page_buffer_size); +static int open_file(const char *filename, hid_t fapl, int metadata_write_strategy, hsize_t page_size, + size_t page_buffer_size); /* * test file access by communicator besides COMM_WORLD. @@ -56,79 +56,79 @@ static int open_file(const char *filename, hid_t fapl, int metadata_write_strate void test_split_comm_access(void) { - MPI_Comm comm; - MPI_Info info = MPI_INFO_NULL; - int is_old, mrc; - int newrank, newprocs; - hid_t fid; /* file IDs */ - hid_t acc_tpl; /* File access properties */ - herr_t ret; /* generic return value */ + MPI_Comm comm; + MPI_Info info = MPI_INFO_NULL; + int is_old, mrc; + int newrank, newprocs; + hid_t fid; /* file IDs */ + hid_t acc_tpl; /* File access properties */ + herr_t ret; /* generic return value */ const char *filename; filename = (const char *)GetTestParameters(); if (VERBOSE_MED) - HDprintf("Split Communicator access test on file %s\n", - filename); + HDprintf("Split Communicator access test on file %s\n", filename); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); - is_old = mpi_rank%2; - mrc = MPI_Comm_split(MPI_COMM_WORLD, is_old, mpi_rank, &comm); - VRFY((mrc==MPI_SUCCESS), ""); - MPI_Comm_size(comm,&newprocs); - MPI_Comm_rank(comm,&newrank); - - if (is_old){ - /* odd-rank processes */ - mrc = MPI_Barrier(comm); - VRFY((mrc==MPI_SUCCESS), ""); - }else{ - /* even-rank processes */ - int sub_mpi_rank; /* rank in the sub-comm */ - MPI_Comm_rank(comm,&sub_mpi_rank); - - /* setup file access template */ - acc_tpl = create_faccess_plist(comm, info, facc_type); - VRFY((acc_tpl >= 0), ""); - - /* create the file collectively */ - fid=H5Fcreate(filename,H5F_ACC_TRUNC,H5P_DEFAULT,acc_tpl); - VRFY((fid >= 0), "H5Fcreate succeeded"); - - /* Release file-access template */ - ret=H5Pclose(acc_tpl); - VRFY((ret >= 0), ""); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + is_old = mpi_rank % 2; + mrc = MPI_Comm_split(MPI_COMM_WORLD, is_old, mpi_rank, &comm); + VRFY((mrc == MPI_SUCCESS), ""); + MPI_Comm_size(comm, &newprocs); + MPI_Comm_rank(comm, &newrank); + + if (is_old) { + /* odd-rank processes */ + mrc = MPI_Barrier(comm); + VRFY((mrc == MPI_SUCCESS), ""); + } + else { + /* even-rank processes */ + int sub_mpi_rank; /* rank in the sub-comm */ + MPI_Comm_rank(comm, &sub_mpi_rank); - /* close the file */ - ret=H5Fclose(fid); - VRFY((ret >= 0), ""); + /* setup file access template */ + acc_tpl = create_faccess_plist(comm, info, facc_type); + VRFY((acc_tpl >= 0), ""); - /* delete the test file */ - if (sub_mpi_rank == 0){ - mrc = MPI_File_delete((char *)filename, info); - /*VRFY((mrc==MPI_SUCCESS), ""); */ - } + /* create the file collectively */ + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); + VRFY((fid >= 0), "H5Fcreate succeeded"); + + /* Release file-access template */ + ret = H5Pclose(acc_tpl); + VRFY((ret >= 0), ""); + + /* close the file */ + ret = H5Fclose(fid); + VRFY((ret >= 0), ""); + + /* delete the test file */ + if (sub_mpi_rank == 0) { + mrc = MPI_File_delete((char *)filename, info); + /*VRFY((mrc==MPI_SUCCESS), ""); */ + } } mrc = MPI_Comm_free(&comm); - VRFY((mrc==MPI_SUCCESS), "MPI_Comm_free succeeded"); + VRFY((mrc == MPI_SUCCESS), "MPI_Comm_free succeeded"); mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "final MPI_Barrier succeeded"); + VRFY((mrc == MPI_SUCCESS), "final MPI_Barrier succeeded"); } void test_page_buffer_access(void) { - hid_t file_id = -1; /* File ID */ - hid_t fcpl, fapl; - size_t page_count = 0; - int i, num_elements = 200; - haddr_t raw_addr, meta_addr; - int *data; - H5F_t *f = NULL; - herr_t ret; /* generic return value */ + hid_t file_id = -1; /* File ID */ + hid_t fcpl, fapl; + size_t page_count = 0; + int i, num_elements = 200; + haddr_t raw_addr, meta_addr; + int * data; + H5F_t * f = NULL; + herr_t ret; /* generic return value */ const char *filename; - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); @@ -136,7 +136,7 @@ test_page_buffer_access(void) filename = (const char *)GetTestParameters(); if (VERBOSE_MED) - HDprintf("Page Buffer Usage in Parallel %s\n", filename); + HDprintf("Page Buffer Usage in Parallel %s\n", filename); fapl = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); VRFY((fapl >= 0), "create_faccess_plist succeeded"); @@ -145,15 +145,17 @@ test_page_buffer_access(void) ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)0); VRFY((ret == 0), ""); - ret = H5Pset_file_space_page_size(fcpl, sizeof(int)*128); + ret = H5Pset_file_space_page_size(fcpl, sizeof(int) * 128); VRFY((ret == 0), ""); - ret = H5Pset_page_buffer_size(fapl, sizeof(int)*100000, 0, 0); + ret = H5Pset_page_buffer_size(fapl, sizeof(int) * 100000, 0, 0); VRFY((ret == 0), ""); /* This should fail because collective metadata writes are not supported with page buffering */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; VRFY((file_id < 0), "H5Fcreate failed"); /* disable collective metadata writes for page buffering to work */ @@ -162,27 +164,29 @@ test_page_buffer_access(void) ret = create_file(filename, fcpl, fapl, H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); VRFY((ret == 0), ""); - ret = open_file(filename, fapl, H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED, sizeof(int)*100, sizeof(int)*100000); + ret = open_file(filename, fapl, H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED, sizeof(int) * 100, + sizeof(int) * 100000); VRFY((ret == 0), ""); ret = create_file(filename, fcpl, fapl, H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); VRFY((ret == 0), ""); - ret = open_file(filename, fapl, H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY, sizeof(int)*100, sizeof(int)*100000); + ret = open_file(filename, fapl, H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY, sizeof(int) * 100, + sizeof(int) * 100000); VRFY((ret == 0), ""); - ret = H5Pset_file_space_page_size(fcpl, sizeof(int)*100); + ret = H5Pset_file_space_page_size(fcpl, sizeof(int) * 100); VRFY((ret == 0), ""); - data = (int *) HDmalloc(sizeof(int)*(size_t)num_elements); + data = (int *)HDmalloc(sizeof(int) * (size_t)num_elements); /* intialize all the elements to have a value of -1 */ - for(i=0 ; ishared->page_buf != NULL), "Page Buffer created with 1 process"); /* allocate space for 200 raw elements */ - raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int)*(size_t)num_elements); + raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements); VRFY((raw_addr != HADDR_UNDEF), ""); /* allocate space for 200 metadata elements */ - meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int)*(size_t)num_elements); + meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int) * (size_t)num_elements); VRFY((meta_addr != HADDR_UNDEF), ""); page_count = 0; - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*(size_t)num_elements, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * (size_t)num_elements, data); VRFY((ret == 0), ""); - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*(size_t)num_elements, data); - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*(size_t)num_elements, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * (size_t)num_elements, data); + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * (size_t)num_elements, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); /* update the first 50 elements */ - for(i=0 ; i<50 ; i++) + for (i = 0; i < 50; i++) data[i] = i; - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, data); + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 50, data); H5Eprint2(H5E_DEFAULT, stderr); VRFY((ret == 0), ""); - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); page_count += 2; VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); /* update the second 50 elements */ - for(i=0 ; i<50 ; i++) - data[i] = i+50; - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*50), sizeof(int)*50, data); + for (i = 0; i < 50; i++) + data[i] = i + 50; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 50), sizeof(int) * 50, data); VRFY((ret == 0), ""); - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*50), sizeof(int)*50, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 50), sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); /* update 100 - 200 */ - for(i=0 ; i<100 ; i++) - data[i] = i+100; - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*100), sizeof(int)*100, data); + for (i = 0; i < 100; i++) + data[i] = i + 100; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 100), sizeof(int) * 100, data); VRFY((ret == 0), ""); - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*100), sizeof(int)*100, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 100), sizeof(int) * 100, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); @@ -252,43 +256,47 @@ test_page_buffer_access(void) VRFY((ret == 0), ""); /* read elements 0 - 200 */ - ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*200, data); + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 200, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 200; i++) + for (i = 0; i < 200; i++) VRFY((data[i] == i), "Read different values than written"); - ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*200, data); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 200, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 200; i++) + for (i = 0; i < 200; i++) VRFY((data[i] == i), "Read different values than written"); /* read elements 0 - 50 */ - ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, data); + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 50; i++) + for (i = 0; i < 50; i++) VRFY((data[i] == i), "Read different values than written"); - ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, data); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 50; i++) + for (i = 0; i < 50; i++) VRFY((data[i] == i), "Read different values than written"); /* close the file */ ret = H5Fclose(file_id); VRFY((ret >= 0), "H5Fclose succeeded"); ret = H5Pclose(fapl_self); - VRFY((ret>=0), "H5Pclose succeeded"); + VRFY((ret >= 0), "H5Pclose succeeded"); /* Pop API context */ - if(api_ctx_pushed) { ret = H5CX_pop(); VRFY((ret == 0), "H5CX_pop()"); api_ctx_pushed = FALSE; } + if (api_ctx_pushed) { + ret = H5CX_pop(); + VRFY((ret == 0), "H5CX_pop()"); + api_ctx_pushed = FALSE; + } } MPI_Barrier(MPI_COMM_WORLD); - if(mpi_size > 1) { - ret = H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 0, 0); + if (mpi_size > 1) { + ret = H5Pset_page_buffer_size(fapl, sizeof(int) * 1000, 0, 0); VRFY((ret == 0), ""); /* collective metadata writes do not work with page buffering */ ret = H5Pset_coll_metadata_write(fapl, FALSE); @@ -308,45 +316,45 @@ test_page_buffer_access(void) VRFY((f->shared->page_buf != NULL), "Page Buffer created with 1 process"); /* allocate space for 200 raw elements */ - raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int)*(size_t)num_elements); + raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements); VRFY((raw_addr != HADDR_UNDEF), ""); /* allocate space for 200 metadata elements */ - meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int)*(size_t)num_elements); + meta_addr = H5MF_alloc(f, H5FD_MEM_SUPER, sizeof(int) * (size_t)num_elements); VRFY((meta_addr != HADDR_UNDEF), ""); page_count = 0; - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*(size_t)num_elements, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * (size_t)num_elements, data); VRFY((ret == 0), ""); - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*(size_t)num_elements, data); + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * (size_t)num_elements, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); /* update the first 50 elements */ - for(i=0 ; i<50 ; i++) + for (i = 0; i < 50; i++) data[i] = i; - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, data); + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); /* update the second 50 elements */ - for(i=0 ; i<50 ; i++) - data[i] = i+50; - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*50), sizeof(int)*50, data); + for (i = 0; i < 50; i++) + data[i] = i + 50; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 50), sizeof(int) * 50, data); VRFY((ret == 0), ""); - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*50), sizeof(int)*50, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 50), sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); /* update 100 - 200 */ - for(i=0 ; i<100 ; i++) - data[i] = i+100; - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*100), sizeof(int)*100, data); + for (i = 0; i < 100; i++) + data[i] = i + 100; + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr + (sizeof(int) * 100), sizeof(int) * 100, data); VRFY((ret == 0), ""); - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*100), sizeof(int)*100, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr + (sizeof(int) * 100), sizeof(int) * 100, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); @@ -354,51 +362,51 @@ test_page_buffer_access(void) VRFY((ret == 0), ""); /* read elements 0 - 200 */ - ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*200, data); + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 200, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 200; i++) + for (i = 0; i < 200; i++) VRFY((data[i] == i), "Read different values than written"); - ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*200, data); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 200, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 200; i++) + for (i = 0; i < 200; i++) VRFY((data[i] == i), "Read different values than written"); /* read elements 0 - 50 */ - ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, data); + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 50; i++) + for (i = 0; i < 50; i++) VRFY((data[i] == i), "Read different values than written"); - ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, data); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); page_count += 1; VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 50; i++) + for (i = 0; i < 50; i++) VRFY((data[i] == i), "Read different values than written"); MPI_Barrier(MPI_COMM_WORLD); /* reset the first 50 elements to -1*/ - for(i=0 ; i<50 ; i++) + for (i = 0; i < 50; i++) data[i] = -1; - ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, data); + ret = H5F_block_write(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, data); + ret = H5F_block_write(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); /* read elements 0 - 50 */ - ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int)*50, data); + ret = H5F_block_read(f, H5FD_MEM_DRAW, raw_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 50; i++) + for (i = 0; i < 50; i++) VRFY((data[i] == -1), "Read different values than written"); - ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int)*50, data); + ret = H5F_block_read(f, H5FD_MEM_SUPER, meta_addr, sizeof(int) * 50, data); VRFY((ret == 0), ""); VRFY((H5SL_count(f->shared->page_buf->slist_ptr) == page_count), "Wrong number of pages in PB"); - for (i=0; i < 50; i++) + for (i = 0; i < 50; i++) VRFY((data[i] == -1), "Read different values than written"); /* close the file */ @@ -407,12 +415,16 @@ test_page_buffer_access(void) } ret = H5Pclose(fapl); - VRFY((ret>=0), "H5Pclose succeeded"); + VRFY((ret >= 0), "H5Pclose succeeded"); ret = H5Pclose(fcpl); - VRFY((ret>=0), "H5Pclose succeeded"); + VRFY((ret >= 0), "H5Pclose succeeded"); /* Pop API context */ - if(api_ctx_pushed) { ret = H5CX_pop(); VRFY((ret == 0), "H5CX_pop()"); api_ctx_pushed = FALSE; } + if (api_ctx_pushed) { + ret = H5CX_pop(); + VRFY((ret == 0), "H5CX_pop()"); + api_ctx_pushed = FALSE; + } HDfree(data); data = NULL; @@ -422,22 +434,22 @@ test_page_buffer_access(void) static int create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_strategy) { - hid_t file_id, dset_id, grp_id; - hid_t sid, mem_dataspace; - hsize_t start[RANK]; - hsize_t count[RANK]; - hsize_t stride[RANK]; - hsize_t block[RANK]; - DATATYPE *data_array = NULL; - hsize_t dims[RANK], i; - hsize_t num_elements; - int k; - char dset_name[20]; - H5F_t *f = NULL; - H5C_t *cache_ptr = NULL; + hid_t file_id, dset_id, grp_id; + hid_t sid, mem_dataspace; + hsize_t start[RANK]; + hsize_t count[RANK]; + hsize_t stride[RANK]; + hsize_t block[RANK]; + DATATYPE * data_array = NULL; + hsize_t dims[RANK], i; + hsize_t num_elements; + int k; + char dset_name[20]; + H5F_t * f = NULL; + H5C_t * cache_ptr = NULL; H5AC_cache_config_t config; - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret; + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret; file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); VRFY((file_id >= 0), ""); @@ -471,61 +483,57 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str grp_id = H5Gcreate2(file_id, "GROUP", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((grp_id >= 0), ""); - dims[0] = (hsize_t)(ROW_FACTOR*mpi_size); - dims[1] = (hsize_t)(COL_FACTOR*mpi_size); - sid = H5Screate_simple (RANK, dims, NULL); + dims[0] = (hsize_t)(ROW_FACTOR * mpi_size); + dims[1] = (hsize_t)(COL_FACTOR * mpi_size); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); /* Each process takes a slabs of rows. */ - block[0] = dims[0]/(hsize_t)mpi_size; - block[1] = dims[1]; + block[0] = dims[0] / (hsize_t)mpi_size; + block[1] = dims[1]; stride[0] = block[0]; stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)mpi_rank*block[0]; - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)mpi_rank * block[0]; + start[1] = 0; num_elements = block[0] * block[1]; /* allocate memory for data buffer */ - data_array = (DATATYPE *)HDmalloc(num_elements*sizeof(DATATYPE)); + data_array = (DATATYPE *)HDmalloc(num_elements * sizeof(DATATYPE)); VRFY((data_array != NULL), "data_array HDmalloc succeeded"); /* put some trivial data in the data_array */ - for(i=0 ; i= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (1, &num_elements, NULL); + mem_dataspace = H5Screate_simple(1, &num_elements, NULL); VRFY((mem_dataspace >= 0), ""); - for(k=0 ; k= 0), ""); ret = H5Dclose(dset_id); VRFY((ret == 0), ""); HDsprintf(dset_name, "D2dset%d", k); - dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), ""); ret = H5Dclose(dset_id); VRFY((ret == 0), ""); HDsprintf(dset_name, "D3dset%d", k); - dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), ""); ret = H5Dclose(dset_id); VRFY((ret == 0), ""); HDsprintf(dset_name, "dset%d", k); - dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), ""); ret = H5Dwrite(dset_id, H5T_NATIVE_INT, mem_dataspace, sid, H5P_DEFAULT, data_array); @@ -534,7 +542,7 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str ret = H5Dclose(dset_id); VRFY((ret == 0), ""); - HDmemset(data_array, 0, num_elements*sizeof(DATATYPE)); + HDmemset(data_array, 0, num_elements * sizeof(DATATYPE)); dset_id = H5Dopen2(grp_id, dset_name, H5P_DEFAULT); VRFY((dset_id >= 0), ""); @@ -544,8 +552,8 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str ret = H5Dclose(dset_id); VRFY((ret == 0), ""); - for (i=0; i < num_elements; i++) - VRFY((data_array[i] == mpi_rank+1), "Dataset Verify failed"); + for (i = 0; i < num_elements; i++) + VRFY((data_array[i] == mpi_rank + 1), "Dataset Verify failed"); HDsprintf(dset_name, "D1dset%d", k); ret = H5Ldelete(grp_id, dset_name, H5P_DEFAULT); @@ -568,7 +576,11 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str VRFY((ret == 0), ""); /* Pop API context */ - if(api_ctx_pushed) { ret = H5CX_pop(); VRFY((ret == 0), "H5CX_pop()"); api_ctx_pushed = FALSE; } + if (api_ctx_pushed) { + ret = H5CX_pop(); + VRFY((ret == 0), "H5CX_pop()"); + api_ctx_pushed = FALSE; + } MPI_Barrier(MPI_COMM_WORLD); HDfree(data_array); @@ -576,28 +588,28 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str } /* create_file */ static int -open_file(const char *filename, hid_t fapl, int metadata_write_strategy, - hsize_t page_size, size_t page_buffer_size) +open_file(const char *filename, hid_t fapl, int metadata_write_strategy, hsize_t page_size, + size_t page_buffer_size) { - hid_t file_id, dset_id, grp_id, grp_id2; - hid_t sid, mem_dataspace; - DATATYPE *data_array = NULL; - hsize_t dims[RANK]; - hsize_t start[RANK]; - hsize_t count[RANK]; - hsize_t stride[RANK]; - hsize_t block[RANK]; - int i, k, ndims; - hsize_t num_elements; - char dset_name[20]; - H5F_t *f = NULL; - H5C_t *cache_ptr = NULL; + hid_t file_id, dset_id, grp_id, grp_id2; + hid_t sid, mem_dataspace; + DATATYPE * data_array = NULL; + hsize_t dims[RANK]; + hsize_t start[RANK]; + hsize_t count[RANK]; + hsize_t stride[RANK]; + hsize_t block[RANK]; + int i, k, ndims; + hsize_t num_elements; + char dset_name[20]; + H5F_t * f = NULL; + H5C_t * cache_ptr = NULL; H5AC_cache_config_t config; - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret; + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret; config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - ret = H5Pget_mdc_config(fapl, &config); + ret = H5Pget_mdc_config(fapl, &config); VRFY((ret == 0), ""); config.metadata_write_strategy = metadata_write_strategy; @@ -632,29 +644,29 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, grp_id = H5Gopen2(file_id, "GROUP", H5P_DEFAULT); VRFY((grp_id >= 0), ""); - dims[0] = (hsize_t)(ROW_FACTOR*mpi_size); - dims[1] = (hsize_t)(COL_FACTOR*mpi_size); + dims[0] = (hsize_t)(ROW_FACTOR * mpi_size); + dims[1] = (hsize_t)(COL_FACTOR * mpi_size); /* Each process takes a slabs of rows. */ - block[0] = dims[0]/(hsize_t)mpi_size; - block[1] = dims[1]; + block[0] = dims[0] / (hsize_t)mpi_size; + block[1] = dims[1]; stride[0] = block[0]; stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)mpi_rank*block[0]; - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)mpi_rank * block[0]; + start[1] = 0; num_elements = block[0] * block[1]; /* allocate memory for data buffer */ - data_array = (DATATYPE *)HDmalloc(num_elements*sizeof(DATATYPE)); + data_array = (DATATYPE *)HDmalloc(num_elements * sizeof(DATATYPE)); VRFY((data_array != NULL), "data_array HDmalloc succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (1, &num_elements, NULL); + mem_dataspace = H5Screate_simple(1, &num_elements, NULL); VRFY((mem_dataspace >= 0), ""); - for(k=0 ; k= 0), ""); @@ -664,8 +676,8 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, ndims = H5Sget_simple_extent_dims(sid, dims, NULL); VRFY((ndims == 2), "H5Sget_simple_extent_dims succeeded"); - VRFY(dims[0] == (hsize_t)(ROW_FACTOR*mpi_size), "Wrong dataset dimensions"); - VRFY(dims[1] == (hsize_t)(COL_FACTOR*mpi_size), "Wrong dataset dimensions"); + VRFY(dims[0] == (hsize_t)(ROW_FACTOR * mpi_size), "Wrong dataset dimensions"); + VRFY(dims[1] == (hsize_t)(COL_FACTOR * mpi_size), "Wrong dataset dimensions"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); @@ -678,8 +690,8 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, ret = H5Sclose(sid); VRFY((ret == 0), ""); - for (i=0; i < (int)num_elements; i++) - VRFY((data_array[i] == mpi_rank+1), "Dataset Verify failed"); + for (i = 0; i < (int)num_elements; i++) + VRFY((data_array[i] == mpi_rank + 1), "Dataset Verify failed"); } grp_id2 = H5Gcreate2(file_id, "GROUP/GROUP2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -694,16 +706,16 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, /* flush invalidate each ring, starting from the outermost ring and * working inward. */ - for ( i = 0; i < H5C__HASH_TABLE_LEN; i++ ) { - H5C_cache_entry_t * entry_ptr = NULL; + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { + H5C_cache_entry_t *entry_ptr = NULL; entry_ptr = cache_ptr->index[i]; - while ( entry_ptr != NULL ) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->is_dirty == FALSE); - if(!entry_ptr->is_pinned && !entry_ptr->is_protected) { + if (!entry_ptr->is_pinned && !entry_ptr->is_protected) { ret = H5AC_expunge_entry(f, entry_ptr->type, entry_ptr->addr, 0); VRFY((ret == 0), ""); } @@ -728,7 +740,11 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, VRFY((ret == 0), ""); /* Pop API context */ - if(api_ctx_pushed) { ret = H5CX_pop(); VRFY((ret == 0), "H5CX_pop()"); api_ctx_pushed = FALSE; } + if (api_ctx_pushed) { + ret = H5CX_pop(); + VRFY((ret == 0), "H5CX_pop()"); + api_ctx_pushed = FALSE; + } HDfree(data_array); @@ -743,19 +759,19 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, void test_file_properties(void) { - hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ - hid_t fapl_id = H5I_INVALID_HID; /* File access plist */ - hid_t fapl_copy_id = H5I_INVALID_HID; /* File access plist */ - hbool_t is_coll; - htri_t are_equal; + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t fapl_id = H5I_INVALID_HID; /* File access plist */ + hid_t fapl_copy_id = H5I_INVALID_HID; /* File access plist */ + hbool_t is_coll; + htri_t are_equal; const char *filename; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - MPI_Comm comm_out = MPI_COMM_NULL; - MPI_Info info_out = MPI_INFO_NULL; - herr_t ret; /* Generic return value */ - int mpi_ret; /* MPI return value */ - int cmp; /* Compare value */ + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + MPI_Comm comm_out = MPI_COMM_NULL; + MPI_Info info_out = MPI_INFO_NULL; + herr_t ret; /* Generic return value */ + int mpi_ret; /* MPI return value */ + int cmp; /* Compare value */ filename = (const char *)GetTestParameters(); @@ -785,7 +801,7 @@ test_file_properties(void) /* Check the communicator */ VRFY((comm != comm_out), "Communicators should not be bitwise identical"); - cmp = MPI_UNEQUAL; + cmp = MPI_UNEQUAL; mpi_ret = MPI_Comm_compare(comm, comm_out, &cmp); VRFY((ret >= 0), "MPI_Comm_compare succeeded"); VRFY((cmp == MPI_CONGRUENT), "Communicators should be congruent via MPI_Comm_compare"); @@ -932,4 +948,3 @@ test_file_properties(void) VRFY((mpi_ret >= 0), "MPI_Info_free succeeded"); } /* end test_file_properties() */ - diff --git a/testpar/t_file_image.c b/testpar/t_file_image.c index 81bb7c2..702f73a 100644 --- a/testpar/t_file_image.c +++ b/testpar/t_file_image.c @@ -61,81 +61,75 @@ void file_image_daisy_chain_test(void) { - char file_name[1024] = "\0"; - int mpi_size, mpi_rank; - int mpi_result; - int i; - int space_ndims; + char file_name[1024] = "\0"; + int mpi_size, mpi_rank; + int mpi_result; + int i; + int space_ndims; MPI_Status rcvstat; - int * vector_ptr = NULL; - hid_t fapl_id = -1; - hid_t file_id; /* file IDs */ - hid_t dset_id = -1; - hid_t dset_type_id = -1; - hid_t space_id = -1; - herr_t err; - hsize_t dims[1]; - void * image_ptr = NULL; - ssize_t bytes_read; - ssize_t image_len; - hbool_t vector_ok = TRUE; - htri_t tri_result; - + int * vector_ptr = NULL; + hid_t fapl_id = -1; + hid_t file_id; /* file IDs */ + hid_t dset_id = -1; + hid_t dset_type_id = -1; + hid_t space_id = -1; + herr_t err; + hsize_t dims[1]; + void * image_ptr = NULL; + ssize_t bytes_read; + ssize_t image_len; + hbool_t vector_ok = TRUE; + htri_t tri_result; /* set up MPI parameters */ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* setup file name */ - HDsnprintf(file_name, 1024, "file_image_daisy_chain_test_%05d.h5", - (int)mpi_rank); + HDsnprintf(file_name, 1024, "file_image_daisy_chain_test_%05d.h5", (int)mpi_rank); - if(mpi_rank == 0) { + if (mpi_rank == 0) { - /* 1) Creates a core file with an integer vector data set + /* 1) Creates a core file with an integer vector data set * of length mpi_size, */ - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + fapl_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((fapl_id >= 0), "creating fapl"); - err = H5Pset_fapl_core(fapl_id, (size_t)(64 *1024), FALSE); + err = H5Pset_fapl_core(fapl_id, (size_t)(64 * 1024), FALSE); VRFY((err >= 0), "setting core file driver in fapl."); file_id = H5Fcreate(file_name, 0, H5P_DEFAULT, fapl_id); VRFY((file_id >= 0), "created core file"); - dims[0] = (hsize_t)mpi_size; - space_id = H5Screate_simple(1, dims, dims); + dims[0] = (hsize_t)mpi_size; + space_id = H5Screate_simple(1, dims, dims); VRFY((space_id >= 0), "created data space"); - dset_id = H5Dcreate2(file_id, "v", H5T_NATIVE_INT, space_id, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, "v", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), "created data set"); - - /* 2) Initialize the vector to zero in location 0, and + /* 2) Initialize the vector to zero in location 0, and * to -1 everywhere else. */ - vector_ptr = (int *)HDmalloc((size_t)(mpi_size) * sizeof(int)); + vector_ptr = (int *)HDmalloc((size_t)(mpi_size) * sizeof(int)); VRFY((vector_ptr != NULL), "allocated in memory representation of vector"); vector_ptr[0] = 0; - for(i = 1; i < mpi_size; i++) + for (i = 1; i < mpi_size; i++) vector_ptr[i] = -1; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)vector_ptr); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)vector_ptr); VRFY((err >= 0), "wrote initial data to vector."); HDfree(vector_ptr); vector_ptr = NULL; - /* 3) Flush the core file, and get an image of it. Close * the core file. */ - err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); + err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "flushed core file."); image_len = H5Fget_file_image(file_id, NULL, (size_t)0); @@ -148,206 +142,192 @@ file_image_daisy_chain_test(void) VRFY(bytes_read == image_len, "wrote file into image buffer"); err = H5Sclose(space_id); - VRFY((err >= 0), "closed data space."); + VRFY((err >= 0), "closed data space."); - err = H5Dclose(dset_id); - VRFY((err >= 0), "closed data set."); + err = H5Dclose(dset_id); + VRFY((err >= 0), "closed data set."); - err = H5Fclose(file_id); - VRFY((err >= 0), "closed core file(1)."); - - err = H5Pclose(fapl_id); - VRFY((err >= 0), "closed fapl(1)."); + err = H5Fclose(file_id); + VRFY((err >= 0), "closed core file(1)."); + err = H5Pclose(fapl_id); + VRFY((err >= 0), "closed fapl(1)."); /* 4) Send the image to process 1. */ - mpi_result = MPI_Ssend((void *)(&image_len), (int)sizeof(ssize_t), - MPI_BYTE, 1, 0, MPI_COMM_WORLD); - VRFY((mpi_result == MPI_SUCCESS), "sent image size to process 1"); + mpi_result = MPI_Ssend((void *)(&image_len), (int)sizeof(ssize_t), MPI_BYTE, 1, 0, MPI_COMM_WORLD); + VRFY((mpi_result == MPI_SUCCESS), "sent image size to process 1"); - mpi_result = MPI_Ssend((void *)image_ptr, (int)image_len, - MPI_BYTE, 1, 0, MPI_COMM_WORLD); - VRFY((mpi_result == MPI_SUCCESS), "sent image to process 1"); + mpi_result = MPI_Ssend((void *)image_ptr, (int)image_len, MPI_BYTE, 1, 0, MPI_COMM_WORLD); + VRFY((mpi_result == MPI_SUCCESS), "sent image to process 1"); HDfree(image_ptr); image_ptr = NULL; image_len = 0; + /* 5) Await receipt on a file image from process n-1. */ - /* 5) Await receipt on a file image from process n-1. */ - - mpi_result = MPI_Recv((void *)(&image_len), (int)sizeof(ssize_t), - MPI_BYTE, mpi_size - 1, 0, MPI_COMM_WORLD, - &rcvstat); - VRFY((mpi_result == MPI_SUCCESS), "received image len from process n-1"); + mpi_result = MPI_Recv((void *)(&image_len), (int)sizeof(ssize_t), MPI_BYTE, mpi_size - 1, 0, + MPI_COMM_WORLD, &rcvstat); + VRFY((mpi_result == MPI_SUCCESS), "received image len from process n-1"); image_ptr = (void *)HDmalloc((size_t)image_len); VRFY(image_ptr != NULL, "allocated file image receive buffer."); - mpi_result = MPI_Recv((void *)image_ptr, (int)image_len, - MPI_BYTE, mpi_size - 1, 0, MPI_COMM_WORLD, - &rcvstat); - VRFY((mpi_result == MPI_SUCCESS), \ - "received file image from process n-1"); + mpi_result = + MPI_Recv((void *)image_ptr, (int)image_len, MPI_BYTE, mpi_size - 1, 0, MPI_COMM_WORLD, &rcvstat); + VRFY((mpi_result == MPI_SUCCESS), "received file image from process n-1"); - /* 6) open the image received from process n-1, verify that + /* 6) open the image received from process n-1, verify that * it contains a vector of length equal to mpi_size, and - * that the vector contains (0, 1, 2, ... n-1). + * that the vector contains (0, 1, 2, ... n-1). */ - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + fapl_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((fapl_id >= 0), "creating fapl"); - err = H5Pset_fapl_core(fapl_id, (size_t)(64 *1024), FALSE); + err = H5Pset_fapl_core(fapl_id, (size_t)(64 * 1024), FALSE); VRFY((err >= 0), "setting core file driver in fapl."); - err = H5Pset_file_image(fapl_id, image_ptr, (size_t)image_len); + err = H5Pset_file_image(fapl_id, image_ptr, (size_t)image_len); VRFY((err >= 0), "set file image in fapl."); file_id = H5Fopen(file_name, H5F_ACC_RDWR, fapl_id); VRFY((file_id >= 0), "opened received file image file"); - dset_id = H5Dopen2(file_id, "v", H5P_DEFAULT); + dset_id = H5Dopen2(file_id, "v", H5P_DEFAULT); VRFY((dset_id >= 0), "opened data set"); - dset_type_id = H5Dget_type(dset_id); + dset_type_id = H5Dget_type(dset_id); VRFY((dset_type_id >= 0), "obtained data set type"); - tri_result = H5Tequal(dset_type_id, H5T_NATIVE_INT); + tri_result = H5Tequal(dset_type_id, H5T_NATIVE_INT); VRFY((tri_result == TRUE), "verified data set type"); - space_id = H5Dget_space(dset_id); + space_id = H5Dget_space(dset_id); VRFY((space_id >= 0), "opened data space"); - space_ndims = H5Sget_simple_extent_ndims(space_id); - VRFY((space_ndims == 1), "verified data space num dims(1)"); + space_ndims = H5Sget_simple_extent_ndims(space_id); + VRFY((space_ndims == 1), "verified data space num dims(1)"); - space_ndims = H5Sget_simple_extent_dims(space_id, dims, NULL); - VRFY((space_ndims == 1), "verified data space num dims(2)"); - VRFY((dims[0] == (hsize_t)mpi_size), "verified data space dims"); + space_ndims = H5Sget_simple_extent_dims(space_id, dims, NULL); + VRFY((space_ndims == 1), "verified data space num dims(2)"); + VRFY((dims[0] == (hsize_t)mpi_size), "verified data space dims"); - vector_ptr = (int *)HDmalloc((size_t)(mpi_size) * sizeof(int)); + vector_ptr = (int *)HDmalloc((size_t)(mpi_size) * sizeof(int)); VRFY((vector_ptr != NULL), "allocated in memory rep of vector"); - err = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)vector_ptr); + err = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)vector_ptr); VRFY((err >= 0), "read received vector."); - vector_ok = TRUE; - for(i = 0; i < mpi_size; i++) - if(vector_ptr[i] != i) + vector_ok = TRUE; + for (i = 0; i < mpi_size; i++) + if (vector_ptr[i] != i) vector_ok = FALSE; VRFY((vector_ok), "verified received vector."); HDfree(vector_ptr); vector_ptr = NULL; - /* 7) closes the core file and exit. */ + /* 7) closes the core file and exit. */ err = H5Sclose(space_id); - VRFY((err >= 0), "closed data space."); + VRFY((err >= 0), "closed data space."); - err = H5Dclose(dset_id); - VRFY((err >= 0), "closed data set."); + err = H5Dclose(dset_id); + VRFY((err >= 0), "closed data set."); - err = H5Fclose(file_id); - VRFY((err >= 0), "closed core file(1)."); + err = H5Fclose(file_id); + VRFY((err >= 0), "closed core file(1)."); - err = H5Pclose(fapl_id); - VRFY((err >= 0), "closed fapl(1)."); + err = H5Pclose(fapl_id); + VRFY((err >= 0), "closed fapl(1)."); HDfree(image_ptr); image_ptr = NULL; image_len = 0; - } else { + } + else { /* 1) Await receipt of file image from process (i - 1). */ - mpi_result = MPI_Recv((void *)(&image_len), (int)sizeof(ssize_t), - MPI_BYTE, mpi_rank - 1, 0, MPI_COMM_WORLD, - &rcvstat); - VRFY((mpi_result == MPI_SUCCESS), \ - "received image size from process mpi_rank-1"); + mpi_result = MPI_Recv((void *)(&image_len), (int)sizeof(ssize_t), MPI_BYTE, mpi_rank - 1, 0, + MPI_COMM_WORLD, &rcvstat); + VRFY((mpi_result == MPI_SUCCESS), "received image size from process mpi_rank-1"); image_ptr = (void *)HDmalloc((size_t)image_len); VRFY(image_ptr != NULL, "allocated file image receive buffer."); - mpi_result = MPI_Recv((void *)image_ptr, (int)image_len, - MPI_BYTE, mpi_rank - 1, 0, MPI_COMM_WORLD, - &rcvstat); - VRFY((mpi_result == MPI_SUCCESS), \ - "received file image from process mpi_rank-1"); - - /* 2) Open the image with the core file driver, verify that it - * contains a vector v of length, and that v[j] = j for - * 0 <= j < i, and that v[j] == -1 for i <= j < n - */ - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + mpi_result = + MPI_Recv((void *)image_ptr, (int)image_len, MPI_BYTE, mpi_rank - 1, 0, MPI_COMM_WORLD, &rcvstat); + VRFY((mpi_result == MPI_SUCCESS), "received file image from process mpi_rank-1"); + + /* 2) Open the image with the core file driver, verify that it + * contains a vector v of length, and that v[j] = j for + * 0 <= j < i, and that v[j] == -1 for i <= j < n + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((fapl_id >= 0), "creating fapl"); - err = H5Pset_fapl_core(fapl_id, (size_t)(64 * 1024), FALSE); + err = H5Pset_fapl_core(fapl_id, (size_t)(64 * 1024), FALSE); VRFY((err >= 0), "setting core file driver in fapl."); - err = H5Pset_file_image(fapl_id, image_ptr, (size_t)image_len); + err = H5Pset_file_image(fapl_id, image_ptr, (size_t)image_len); VRFY((err >= 0), "set file image in fapl."); file_id = H5Fopen(file_name, H5F_ACC_RDWR, fapl_id); - H5Eprint2(H5P_DEFAULT, stderr); + H5Eprint2(H5P_DEFAULT, stderr); VRFY((file_id >= 0), "opened received file image file"); - dset_id = H5Dopen2(file_id, "v", H5P_DEFAULT); + dset_id = H5Dopen2(file_id, "v", H5P_DEFAULT); VRFY((dset_id >= 0), "opened data set"); - dset_type_id = H5Dget_type(dset_id); + dset_type_id = H5Dget_type(dset_id); VRFY((dset_type_id >= 0), "obtained data set type"); - tri_result = H5Tequal(dset_type_id, H5T_NATIVE_INT); + tri_result = H5Tequal(dset_type_id, H5T_NATIVE_INT); VRFY((tri_result == TRUE), "verified data set type"); - space_id = H5Dget_space(dset_id); + space_id = H5Dget_space(dset_id); VRFY((space_id >= 0), "opened data space"); - space_ndims = H5Sget_simple_extent_ndims(space_id); - VRFY((space_ndims == 1), "verified data space num dims(1)"); + space_ndims = H5Sget_simple_extent_ndims(space_id); + VRFY((space_ndims == 1), "verified data space num dims(1)"); - space_ndims = H5Sget_simple_extent_dims(space_id, dims, NULL); - VRFY((space_ndims == 1), "verified data space num dims(2)"); - VRFY((dims[0] == (hsize_t)mpi_size), "verified data space dims"); + space_ndims = H5Sget_simple_extent_dims(space_id, dims, NULL); + VRFY((space_ndims == 1), "verified data space num dims(2)"); + VRFY((dims[0] == (hsize_t)mpi_size), "verified data space dims"); - vector_ptr = (int *)HDmalloc((size_t)(mpi_size) * sizeof(int)); + vector_ptr = (int *)HDmalloc((size_t)(mpi_size) * sizeof(int)); VRFY((vector_ptr != NULL), "allocated in memory rep of vector"); - err = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)vector_ptr); + err = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)vector_ptr); VRFY((err >= 0), "read received vector."); - vector_ok = TRUE; - for(i = 0; i < mpi_size; i++){ - if(i < mpi_rank) { - if(vector_ptr[i] != i) + vector_ok = TRUE; + for (i = 0; i < mpi_size; i++) { + if (i < mpi_rank) { + if (vector_ptr[i] != i) vector_ok = FALSE; - } else { - if(vector_ptr[i] != -1) + } + else { + if (vector_ptr[i] != -1) vector_ok = FALSE; - } + } } VRFY((vector_ok), "verified received vector."); + /* 3) Set v[i] = i in the core file. */ - /* 3) Set v[i] = i in the core file. */ - - vector_ptr[mpi_rank] = mpi_rank; + vector_ptr[mpi_rank] = mpi_rank; - err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, (void *)vector_ptr); + err = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)vector_ptr); VRFY((err >= 0), "wrote modified data to vector."); HDfree(vector_ptr); vector_ptr = NULL; + /* 4) Flush the core file and send it to process (mpi_rank + 1) % n. */ - /* 4) Flush the core file and send it to process (mpi_rank + 1) % n. */ - - err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); + err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "flushed core file."); image_len = H5Fget_file_image(file_id, NULL, (size_t)0); @@ -359,38 +339,33 @@ file_image_daisy_chain_test(void) bytes_read = H5Fget_file_image(file_id, image_ptr, (size_t)image_len); VRFY(bytes_read == image_len, "wrote file into image buffer"); - mpi_result = MPI_Ssend((void *)(&image_len), (int)sizeof(ssize_t), - MPI_BYTE, (mpi_rank + 1) % mpi_size, 0, - MPI_COMM_WORLD); - VRFY((mpi_result == MPI_SUCCESS), \ - "sent image size to process (mpi_rank + 1) % mpi_size"); + mpi_result = MPI_Ssend((void *)(&image_len), (int)sizeof(ssize_t), MPI_BYTE, + (mpi_rank + 1) % mpi_size, 0, MPI_COMM_WORLD); + VRFY((mpi_result == MPI_SUCCESS), "sent image size to process (mpi_rank + 1) % mpi_size"); - mpi_result = MPI_Ssend((void *)image_ptr, (int)image_len, - MPI_BYTE, (mpi_rank + 1) % mpi_size, 0, + mpi_result = MPI_Ssend((void *)image_ptr, (int)image_len, MPI_BYTE, (mpi_rank + 1) % mpi_size, 0, MPI_COMM_WORLD); - VRFY((mpi_result == MPI_SUCCESS), \ - "sent image to process (mpi_rank + 1) % mpi_size"); + VRFY((mpi_result == MPI_SUCCESS), "sent image to process (mpi_rank + 1) % mpi_size"); HDfree(image_ptr); image_ptr = NULL; image_len = 0; - /* 5) close the core file and exit. */ + /* 5) close the core file and exit. */ err = H5Sclose(space_id); - VRFY((err >= 0), "closed data space."); + VRFY((err >= 0), "closed data space."); - err = H5Dclose(dset_id); - VRFY((err >= 0), "closed data set."); + err = H5Dclose(dset_id); + VRFY((err >= 0), "closed data set."); - err = H5Fclose(file_id); - VRFY((err >= 0), "closed core file(1)."); + err = H5Fclose(file_id); + VRFY((err >= 0), "closed core file(1)."); - err = H5Pclose(fapl_id); - VRFY((err >= 0), "closed fapl(1)."); + err = H5Pclose(fapl_id); + VRFY((err >= 0), "closed fapl(1)."); } return; } /* file_image_daisy_chain_test() */ - diff --git a/testpar/t_filter_read.c b/testpar/t_filter_read.c index 7b0e677..10d6c27 100644 --- a/testpar/t_filter_read.c +++ b/testpar/t_filter_read.c @@ -19,24 +19,22 @@ * Date: 2007/05/15 */ - #include "testphdf5.h" #ifdef H5_HAVE_SZLIB_H -# include "szlib.h" +#include "szlib.h" #endif static int mpi_size, mpi_rank; /* Chunk sizes */ -#define CHUNK_DIM1 7 -#define CHUNK_DIM2 27 +#define CHUNK_DIM1 7 +#define CHUNK_DIM2 27 /* Sizes of the vertical hyperslabs. Total dataset size is {HS_DIM1, HS_DIM2 * mpi_size } */ -#define HS_DIM1 200 -#define HS_DIM2 100 - +#define HS_DIM1 200 +#define HS_DIM2 100 /*------------------------------------------------------------------------- * Function: filter_read_internal @@ -51,28 +49,27 @@ static int mpi_size, mpi_rank; *------------------------------------------------------------------------- */ static void -filter_read_internal(const char *filename, hid_t dcpl, - hsize_t *dset_size) +filter_read_internal(const char *filename, hid_t dcpl, hsize_t *dset_size) { - hid_t file, dataset; /* HDF5 IDs */ - hid_t access_plist; /* Access property list ID */ - hid_t sid, memspace; /* Dataspace IDs */ - hsize_t size[2]; /* Dataspace dimensions */ - hsize_t hs_offset[2]; /* Hyperslab offset */ - hsize_t hs_size[2]; /* Hyperslab size */ - size_t i, j; /* Local index variables */ - char name[32] = "dataset"; - herr_t hrc; /* Error status */ - int *points = NULL; /* Writing buffer for entire dataset */ - int *check = NULL; /* Reading buffer for selected hyperslab */ + hid_t file, dataset; /* HDF5 IDs */ + hid_t access_plist; /* Access property list ID */ + hid_t sid, memspace; /* Dataspace IDs */ + hsize_t size[2]; /* Dataspace dimensions */ + hsize_t hs_offset[2]; /* Hyperslab offset */ + hsize_t hs_size[2]; /* Hyperslab size */ + size_t i, j; /* Local index variables */ + char name[32] = "dataset"; + herr_t hrc; /* Error status */ + int * points = NULL; /* Writing buffer for entire dataset */ + int * check = NULL; /* Reading buffer for selected hyperslab */ /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* set sizes for dataset and hyperslabs */ hs_size[0] = size[0] = HS_DIM1; - hs_size[1] = HS_DIM2; + hs_size[1] = HS_DIM2; size[1] = hs_size[1] * (hsize_t)mpi_size; @@ -81,50 +78,50 @@ filter_read_internal(const char *filename, hid_t dcpl, /* Create the data space */ sid = H5Screate_simple(2, size, NULL); - VRFY(sid>=0, "H5Screate_simple"); + VRFY(sid >= 0, "H5Screate_simple"); /* Create buffers */ points = (int *)HDmalloc(size[0] * size[1] * sizeof(int)); - VRFY(points!=NULL, "HDmalloc"); + VRFY(points != NULL, "HDmalloc"); check = (int *)HDmalloc(hs_size[0] * hs_size[1] * sizeof(int)); - VRFY(check!=NULL, "HDmalloc"); + VRFY(check != NULL, "HDmalloc"); /* Initialize writing buffer with random data */ - for(i = 0; i < size[0]; i++) - for(j = 0; j < size[1]; j++) - points[i * size[1]+j] = (int)(i+j+7); + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + points[i * size[1] + j] = (int)(i + j + 7); VRFY(H5Pall_filters_avail(dcpl), "Incorrect filter availability"); /* Serial write phase */ - if(MAINPROCESS) { + if (MAINPROCESS) { file = H5Fcreate(h5_rmprefix(filename), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - VRFY(file>=0, "H5Fcreate"); + VRFY(file >= 0, "H5Fcreate"); /* Create the dataset */ dataset = H5Dcreate2(file, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - VRFY(dataset>=0, "H5Dcreate2"); + VRFY(dataset >= 0, "H5Dcreate2"); hrc = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points); - VRFY(hrc>=0, "H5Dwrite"); + VRFY(hrc >= 0, "H5Dwrite"); *dset_size = H5Dget_storage_size(dataset); - VRFY(*dset_size>0, "H5Dget_storage_size"); + VRFY(*dset_size > 0, "H5Dget_storage_size"); - hrc = H5Dclose (dataset); - VRFY(hrc>=0, "H5Dclose"); + hrc = H5Dclose(dataset); + VRFY(hrc >= 0, "H5Dclose"); - hrc = H5Fclose (file); - VRFY(hrc>=0, "H5Fclose"); + hrc = H5Fclose(file); + VRFY(hrc >= 0, "H5Fclose"); } MPI_Barrier(MPI_COMM_WORLD); /* Parallel read phase */ /* Set up MPIO file access property lists */ - access_plist = H5Pcreate(H5P_FILE_ACCESS); + access_plist = H5Pcreate(H5P_FILE_ACCESS); VRFY((access_plist >= 0), "H5Pcreate"); hrc = H5Pset_fapl_mpio(access_plist, MPI_COMM_WORLD, MPI_INFO_NULL); @@ -138,51 +135,48 @@ filter_read_internal(const char *filename, hid_t dcpl, VRFY((dataset >= 0), "H5Dopen2"); hrc = H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); - VRFY(hrc>=0, "H5Sselect_hyperslab"); + VRFY(hrc >= 0, "H5Sselect_hyperslab"); memspace = H5Screate_simple(2, hs_size, NULL); - VRFY(memspace>=0, "H5Screate_simple"); + VRFY(memspace >= 0, "H5Screate_simple"); - hrc = H5Dread (dataset, H5T_NATIVE_INT, memspace, sid, H5P_DEFAULT, check); - VRFY(hrc>=0, "H5Dread"); + hrc = H5Dread(dataset, H5T_NATIVE_INT, memspace, sid, H5P_DEFAULT, check); + VRFY(hrc >= 0, "H5Dread"); /* Check that the values read are the same as the values written */ - for (i=0; i=0, "H5Dclose"); + hrc = H5Dclose(dataset); + VRFY(hrc >= 0, "H5Dclose"); - hrc = H5Sclose (sid); - VRFY(hrc>=0, "H5Sclose"); + hrc = H5Sclose(sid); + VRFY(hrc >= 0, "H5Sclose"); - hrc = H5Sclose (memspace); - VRFY(hrc>=0, "H5Sclose"); + hrc = H5Sclose(memspace); + VRFY(hrc >= 0, "H5Sclose"); - hrc = H5Pclose (access_plist); - VRFY(hrc>=0, "H5Pclose"); + hrc = H5Pclose(access_plist); + VRFY(hrc >= 0, "H5Pclose"); - hrc = H5Fclose (file); - VRFY(hrc>=0, "H5Fclose"); + hrc = H5Fclose(file); + VRFY(hrc >= 0, "H5Fclose"); HDfree(points); HDfree(check); @@ -190,7 +184,6 @@ filter_read_internal(const char *filename, hid_t dcpl, MPI_Barrier(MPI_COMM_WORLD); } - /*------------------------------------------------------------------------- * Function: test_filter_read * @@ -208,36 +201,36 @@ filter_read_internal(const char *filename, hid_t dcpl, void test_filter_read(void) { - hid_t dc; /* HDF5 IDs */ - const hsize_t chunk_size[2] = {CHUNK_DIM1, CHUNK_DIM2}; /* Chunk dimensions */ - hsize_t null_size; /* Size of dataset without filters */ - unsigned chunk_opts; /* Chunk options */ - unsigned disable_partial_chunk_filters; /* Whether filters are disabled on partial chunks */ - herr_t hrc; - const char *filename; + hid_t dc; /* HDF5 IDs */ + const hsize_t chunk_size[2] = {CHUNK_DIM1, CHUNK_DIM2}; /* Chunk dimensions */ + hsize_t null_size; /* Size of dataset without filters */ + unsigned chunk_opts; /* Chunk options */ + unsigned disable_partial_chunk_filters; /* Whether filters are disabled on partial chunks */ + herr_t hrc; + const char * filename; #ifdef H5_HAVE_FILTER_FLETCHER32 - hsize_t fletcher32_size; /* Size of dataset with Fletcher32 checksum */ + hsize_t fletcher32_size; /* Size of dataset with Fletcher32 checksum */ #endif #ifdef H5_HAVE_FILTER_DEFLATE - hsize_t deflate_size; /* Size of dataset with deflate filter */ -#endif /* H5_HAVE_FILTER_DEFLATE */ + hsize_t deflate_size; /* Size of dataset with deflate filter */ +#endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SZIP - hsize_t szip_size; /* Size of dataset with szip filter */ - unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block=4; + hsize_t szip_size; /* Size of dataset with szip filter */ + unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block = 4; #endif /* H5_HAVE_FILTER_SZIP */ - hsize_t shuffle_size; /* Size of dataset with shuffle filter */ + hsize_t shuffle_size; /* Size of dataset with shuffle filter */ -#if(defined H5_HAVE_FILTER_DEFLATE || defined H5_HAVE_FILTER_SZIP) - hsize_t combo_size; /* Size of dataset with multiple filters */ -#endif /* H5_HAVE_FILTER_DEFLATE || H5_HAVE_FILTER_SZIP */ +#if (defined H5_HAVE_FILTER_DEFLATE || defined H5_HAVE_FILTER_SZIP) + hsize_t combo_size; /* Size of dataset with multiple filters */ +#endif /* H5_HAVE_FILTER_DEFLATE || H5_HAVE_FILTER_SZIP */ filename = GetTestParameters(); - if(VERBOSE_MED) + if (VERBOSE_MED) HDprintf("Parallel reading of dataset written with filters %s\n", filename); /*---------------------------------------------------------- @@ -245,116 +238,115 @@ test_filter_read(void) *---------------------------------------------------------- */ dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0,"H5Pcreate"); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0,"H5Pset_chunk"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_chunk"); - filter_read_internal(filename,dc,&null_size); + filter_read_internal(filename, dc, &null_size); /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0,"H5Pclose"); + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); /* Run steps 1-3 both with and without filters disabled on partial chunks */ - for(disable_partial_chunk_filters = 0; disable_partial_chunk_filters <= 1; - disable_partial_chunk_filters++) { + for (disable_partial_chunk_filters = 0; disable_partial_chunk_filters <= 1; + disable_partial_chunk_filters++) { /* Set chunk options appropriately */ dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0,"H5Pcreate"); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0,"H5Pset_filter"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_filter"); hrc = H5Pget_chunk_opts(dc, &chunk_opts); - VRFY(hrc>=0,"H5Pget_chunk_opts"); + VRFY(hrc >= 0, "H5Pget_chunk_opts"); - if(disable_partial_chunk_filters) + if (disable_partial_chunk_filters) chunk_opts |= H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS; - hrc = H5Pclose (dc); - VRFY(hrc>=0,"H5Pclose"); + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); /*---------------------------------------------------------- - * STEP 1: Test Fletcher32 Checksum by itself. - *---------------------------------------------------------- - */ + * STEP 1: Test Fletcher32 Checksum by itself. + *---------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_FLETCHER32 dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0,"H5Pset_filter"); + VRFY(dc >= 0, "H5Pset_filter"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0,"H5Pset_filter"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_filter"); - hrc = H5Pset_chunk_opts (dc, chunk_opts); - VRFY(hrc>=0,"H5Pset_chunk_opts"); + hrc = H5Pset_chunk_opts(dc, chunk_opts); + VRFY(hrc >= 0, "H5Pset_chunk_opts"); - hrc = H5Pset_filter (dc,H5Z_FILTER_FLETCHER32,0,0,NULL); - VRFY(hrc>=0,"H5Pset_filter"); + hrc = H5Pset_filter(dc, H5Z_FILTER_FLETCHER32, 0, 0, NULL); + VRFY(hrc >= 0, "H5Pset_filter"); - filter_read_internal(filename,dc,&fletcher32_size); - VRFY(fletcher32_size > null_size,"Size after checksumming is incorrect."); + filter_read_internal(filename, dc, &fletcher32_size); + VRFY(fletcher32_size > null_size, "Size after checksumming is incorrect."); /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0, "H5Pclose"); + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); #endif /* H5_HAVE_FILTER_FLETCHER32 */ /*---------------------------------------------------------- - * STEP 2: Test deflation by itself. - *---------------------------------------------------------- - */ + * STEP 2: Test deflation by itself. + *---------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_DEFLATE dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0, "H5Pcreate"); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0, "H5Pset_chunk"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_chunk"); - hrc = H5Pset_chunk_opts (dc, chunk_opts); - VRFY(hrc>=0,"H5Pset_chunk_opts"); + hrc = H5Pset_chunk_opts(dc, chunk_opts); + VRFY(hrc >= 0, "H5Pset_chunk_opts"); - hrc = H5Pset_deflate (dc, 6); - VRFY(hrc>=0, "H5Pset_deflate"); + hrc = H5Pset_deflate(dc, 6); + VRFY(hrc >= 0, "H5Pset_deflate"); - filter_read_internal(filename,dc,&deflate_size); + filter_read_internal(filename, dc, &deflate_size); /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0, "H5Pclose"); + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); #endif /* H5_HAVE_FILTER_DEFLATE */ /*---------------------------------------------------------- - * STEP 3: Test szip compression by itself. - *---------------------------------------------------------- - */ + * STEP 3: Test szip compression by itself. + *---------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_SZIP - if(h5_szip_can_encode() == 1) { + if (h5_szip_can_encode() == 1) { dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0, "H5Pcreate"); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0, "H5Pset_chunk"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_chunk"); - hrc = H5Pset_chunk_opts (dc, chunk_opts); - VRFY(hrc>=0,"H5Pset_chunk_opts"); + hrc = H5Pset_chunk_opts(dc, chunk_opts); + VRFY(hrc >= 0, "H5Pset_chunk_opts"); hrc = H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block); - VRFY(hrc>=0, "H5Pset_szip"); + VRFY(hrc >= 0, "H5Pset_szip"); - filter_read_internal(filename,dc,&szip_size); + filter_read_internal(filename, dc, &szip_size); /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0, "H5Pclose"); + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); } #endif /* H5_HAVE_FILTER_SZIP */ - } /* end for */ - + } /* end for */ /*---------------------------------------------------------- * STEP 4: Test shuffling by itself. @@ -362,21 +354,20 @@ test_filter_read(void) */ dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0, "H5Pcreate"); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0, "H5Pset_chunk"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_chunk"); - hrc = H5Pset_shuffle (dc); - VRFY(hrc>=0, "H5Pset_shuffle"); + hrc = H5Pset_shuffle(dc); + VRFY(hrc >= 0, "H5Pset_shuffle"); - filter_read_internal(filename,dc,&shuffle_size); - VRFY(shuffle_size==null_size,"Shuffled size not the same as uncompressed size."); + filter_read_internal(filename, dc, &shuffle_size); + VRFY(shuffle_size == null_size, "Shuffled size not the same as uncompressed size."); /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0, "H5Pclose"); - + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); /*---------------------------------------------------------- * STEP 5: Test shuffle + deflate + checksum in any order. @@ -385,47 +376,47 @@ test_filter_read(void) #ifdef H5_HAVE_FILTER_DEFLATE /* Testing shuffle+deflate+checksum filters (checksum first) */ dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0, "H5Pcreate"); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0, "H5Pset_chunk"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_chunk"); - hrc = H5Pset_fletcher32 (dc); - VRFY(hrc>=0, "H5Pset_fletcher32"); + hrc = H5Pset_fletcher32(dc); + VRFY(hrc >= 0, "H5Pset_fletcher32"); - hrc = H5Pset_shuffle (dc); - VRFY(hrc>=0, "H5Pset_shuffle"); + hrc = H5Pset_shuffle(dc); + VRFY(hrc >= 0, "H5Pset_shuffle"); - hrc = H5Pset_deflate (dc, 6); - VRFY(hrc>=0, "H5Pset_deflate"); + hrc = H5Pset_deflate(dc, 6); + VRFY(hrc >= 0, "H5Pset_deflate"); - filter_read_internal(filename,dc,&combo_size); + filter_read_internal(filename, dc, &combo_size); /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0, "H5Pclose"); + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); /* Testing shuffle+deflate+checksum filters (checksum last) */ dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0, "H5Pcreate"); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0, "H5Pset_chunk"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_chunk"); - hrc = H5Pset_shuffle (dc); - VRFY(hrc>=0, "H5Pset_shuffle"); + hrc = H5Pset_shuffle(dc); + VRFY(hrc >= 0, "H5Pset_shuffle"); - hrc = H5Pset_deflate (dc, 6); - VRFY(hrc>=0, "H5Pset_deflate"); + hrc = H5Pset_deflate(dc, 6); + VRFY(hrc >= 0, "H5Pset_deflate"); - hrc = H5Pset_fletcher32 (dc); - VRFY(hrc>=0, "H5Pset_fletcher32"); + hrc = H5Pset_fletcher32(dc); + VRFY(hrc >= 0, "H5Pset_fletcher32"); - filter_read_internal(filename,dc,&combo_size); + filter_read_internal(filename, dc, &combo_size); /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0, "H5Pclose"); + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); #endif /* H5_HAVE_FILTER_DEFLATE */ @@ -437,54 +428,53 @@ test_filter_read(void) /* Testing shuffle+szip(with encoder)+checksum filters(checksum first) */ dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0, "H5Pcreate"); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0, "H5Pset_chunk"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_chunk"); - hrc = H5Pset_fletcher32 (dc); - VRFY(hrc>=0, "H5Pset_fletcher32"); + hrc = H5Pset_fletcher32(dc); + VRFY(hrc >= 0, "H5Pset_fletcher32"); - hrc = H5Pset_shuffle (dc); - VRFY(hrc>=0, "H5Pset_shuffle"); + hrc = H5Pset_shuffle(dc); + VRFY(hrc >= 0, "H5Pset_shuffle"); /* Make sure encoding is enabled */ - if(h5_szip_can_encode() == 1) { - hrc = H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block); - VRFY(hrc>=0, "H5Pset_szip"); + if (h5_szip_can_encode() == 1) { + hrc = H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block); + VRFY(hrc >= 0, "H5Pset_szip"); - filter_read_internal(filename,dc,&combo_size); + filter_read_internal(filename, dc, &combo_size); } /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0, "H5Pclose"); + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); /* Testing shuffle+szip(with encoder)+checksum filters(checksum last) */ /* Make sure encoding is enabled */ - if(h5_szip_can_encode() == 1) { - dc = H5Pcreate(H5P_DATASET_CREATE); - VRFY(dc>=0, "H5Pcreate"); + if (h5_szip_can_encode() == 1) { + dc = H5Pcreate(H5P_DATASET_CREATE); + VRFY(dc >= 0, "H5Pcreate"); - hrc = H5Pset_chunk (dc, 2, chunk_size); - VRFY(hrc>=0, "H5Pset_chunk"); + hrc = H5Pset_chunk(dc, 2, chunk_size); + VRFY(hrc >= 0, "H5Pset_chunk"); - hrc = H5Pset_shuffle (dc); - VRFY(hrc>=0, "H5Pset_shuffle"); + hrc = H5Pset_shuffle(dc); + VRFY(hrc >= 0, "H5Pset_shuffle"); - hrc = H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block); - VRFY(hrc>=0, "H5Pset_szip"); + hrc = H5Pset_szip(dc, szip_options_mask, szip_pixels_per_block); + VRFY(hrc >= 0, "H5Pset_szip"); - hrc = H5Pset_fletcher32 (dc); - VRFY(hrc>=0, "H5Pset_fletcher32"); + hrc = H5Pset_fletcher32(dc); + VRFY(hrc >= 0, "H5Pset_fletcher32"); - filter_read_internal(filename,dc,&combo_size); + filter_read_internal(filename, dc, &combo_size); - /* Clean up objects used for this test */ - hrc = H5Pclose (dc); - VRFY(hrc>=0, "H5Pclose"); + /* Clean up objects used for this test */ + hrc = H5Pclose(dc); + VRFY(hrc >= 0, "H5Pclose"); } #endif /* H5_HAVE_FILTER_SZIP */ } - diff --git a/testpar/t_filters_parallel.c b/testpar/t_filters_parallel.c index 76f9276..37479b3 100644 --- a/testpar/t_filters_parallel.c +++ b/testpar/t_filters_parallel.c @@ -23,16 +23,13 @@ #include "t_filters_parallel.h" -const char *FILENAME[] = { - "t_filters_parallel", - NULL -}; -char filenames[1][256]; +const char *FILENAME[] = {"t_filters_parallel", NULL}; +char filenames[1][256]; int nerrors = 0; size_t cur_filter_idx = 0; -#define GZIP_INDEX 0 +#define GZIP_INDEX 0 #define FLETCHER32_INDEX 1 #define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0]) @@ -40,19 +37,19 @@ size_t cur_filter_idx = 0; /* * Used to check if a filter is available before running a test. */ -#define CHECK_CUR_FILTER_AVAIL() \ -{ \ - htri_t filter_is_avail; \ - \ - if (cur_filter_idx == GZIP_INDEX) { \ - if ((filter_is_avail = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) != TRUE) { \ - if (MAINPROCESS) { \ - HDputs(" - SKIPPED - Deflate filter not available"); \ - } \ - return; \ - } \ - } \ -} +#define CHECK_CUR_FILTER_AVAIL() \ + { \ + htri_t filter_is_avail; \ + \ + if (cur_filter_idx == GZIP_INDEX) { \ + if ((filter_is_avail = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) != TRUE) { \ + if (MAINPROCESS) { \ + HDputs(" - SKIPPED - Deflate filter not available"); \ + } \ + return; \ + } \ + } \ + } static herr_t set_dcpl_filter(hid_t dcpl); @@ -183,8 +180,8 @@ set_dcpl_filter(hid_t dcpl) static void test_write_one_chunk_filtered_dataset(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_ONE_CHUNK_FILTERED_DATASET_DIMS]; hsize_t chunk_dims[WRITE_ONE_CHUNK_FILTERED_DATASET_DIMS]; @@ -197,7 +194,8 @@ test_write_one_chunk_filtered_dataset(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to one-chunk filtered dataset"); + if (MAINPROCESS) + HDputs("Testing write to one-chunk filtered dataset"); CHECK_CUR_FILTER_AVAIL(); @@ -205,10 +203,9 @@ test_write_one_chunk_filtered_dataset(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -216,12 +213,12 @@ test_write_one_chunk_filtered_dataset(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_NROWS; - dataset_dims[1] = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS; - chunk_dims[0] = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS; - sel_dims[0] = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_NROWS / (hsize_t) mpi_size; - sel_dims[1] = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS; + dataset_dims[0] = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_NROWS; + dataset_dims[1] = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS; + sel_dims[0] = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_NROWS / (hsize_t)mpi_size; + sel_dims[1] = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS; filespace = H5Screate_simple(WRITE_ONE_CHUNK_FILTERED_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); @@ -233,14 +230,13 @@ test_write_one_chunk_filtered_dataset(void) plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, WRITE_ONE_CHUNK_FILTERED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, WRITE_ONE_CHUNK_FILTERED_DATASET_DIMS, chunk_dims) >= 0), "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, WRITE_ONE_CHUNK_FILTERED_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -249,18 +245,19 @@ test_write_one_chunk_filtered_dataset(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = 1; - count[1] = 1; - stride[0] = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS; - stride[1] = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS; - block[0] = sel_dims[0]; - block[1] = sel_dims[1]; - start[0] = ((hsize_t) mpi_rank * sel_dims[0]); - start[1] = 0; + count[0] = 1; + count[1] = 1; + stride[0] = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS; + stride[1] = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS; + block[0] = sel_dims[0]; + block[1] = sel_dims[1]; + start[0] = ((hsize_t)mpi_rank * sel_dims[0]); + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -269,55 +266,58 @@ test_write_one_chunk_filtered_dataset(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Fill data buffer */ - data_size = (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS - * (hsize_t) WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS * sizeof(*data); + data_size = (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS * + (hsize_t)WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = ((C_DATATYPE) i % (WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)) - + ((C_DATATYPE) i / (WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)); + correct_buf[i] = ((C_DATATYPE)i % (WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * + WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)) + + ((C_DATATYPE)i / (WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * + WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_ONE_CHUNK_FILTERED_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -340,8 +340,8 @@ test_write_one_chunk_filtered_dataset(void) static void test_write_filtered_dataset_no_overlap(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_UNSHARED_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[WRITE_UNSHARED_FILTERED_CHUNKS_DATASET_DIMS]; @@ -354,7 +354,8 @@ test_write_filtered_dataset_no_overlap(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks"); + if (MAINPROCESS) + HDputs("Testing write to unshared filtered chunks"); CHECK_CUR_FILTER_AVAIL(); @@ -362,11 +363,10 @@ test_write_filtered_dataset_no_overlap(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -374,12 +374,12 @@ test_write_filtered_dataset_no_overlap(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_NCOLS; - chunk_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; - sel_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS; - sel_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_NCOLS; + dataset_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; + sel_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS; + sel_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_NCOLS; filespace = H5Screate_simple(WRITE_UNSHARED_FILTERED_CHUNKS_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); @@ -392,13 +392,13 @@ test_write_filtered_dataset_no_overlap(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_UNSHARED_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, WRITE_UNSHARED_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -408,17 +408,19 @@ test_write_filtered_dataset_no_overlap(void) * it to the hyperslab in the file */ count[0] = 1; - count[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_NCOLS / (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; - stride[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS; - stride[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; - block[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS; - block[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; - start[0] = ((hsize_t) mpi_rank * (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS * count[0]); - start[1] = 0; + count[1] = + (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_NCOLS / (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; + stride[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS; + stride[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; + block[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS; + block[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; + start[0] = ((hsize_t)mpi_rank * (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_CH_NROWS * count[0]); + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -427,57 +429,55 @@ test_write_filtered_dataset_no_overlap(void) VRFY((dset_id >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = - (C_DATATYPE) ( - (i % (dataset_dims[0] / (hsize_t) mpi_size * dataset_dims[1])) - + (i / (dataset_dims[0] / (hsize_t) mpi_size * dataset_dims[1])) - ); + correct_buf[i] = (C_DATATYPE)((i % (dataset_dims[0] / (hsize_t)mpi_size * dataset_dims[1])) + + (i / (dataset_dims[0] / (hsize_t)mpi_size * dataset_dims[1]))); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_UNSHARED_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -501,8 +501,8 @@ test_write_filtered_dataset_no_overlap(void) static void test_write_filtered_dataset_overlap(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_SHARED_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[WRITE_SHARED_FILTERED_CHUNKS_DATASET_DIMS]; @@ -515,7 +515,8 @@ test_write_filtered_dataset_overlap(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to shared filtered chunks"); + if (MAINPROCESS) + HDputs("Testing write to shared filtered chunks"); CHECK_CUR_FILTER_AVAIL(); @@ -523,11 +524,10 @@ test_write_filtered_dataset_overlap(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -535,12 +535,12 @@ test_write_filtered_dataset_overlap(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_NCOLS; - chunk_dims[0] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS; - sel_dims[0] = (hsize_t) DIM0_SCALE_FACTOR; - sel_dims[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS * (hsize_t) DIM1_SCALE_FACTOR; + dataset_dims[0] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS; + sel_dims[0] = (hsize_t)DIM0_SCALE_FACTOR; + sel_dims[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS * (hsize_t)DIM1_SCALE_FACTOR; filespace = H5Screate_simple(WRITE_SHARED_FILTERED_CHUNKS_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); @@ -553,13 +553,13 @@ test_write_filtered_dataset_overlap(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_SHARED_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, WRITE_SHARED_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -568,18 +568,19 @@ test_write_filtered_dataset_overlap(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_NROWS / (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NROWS; - count[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_NCOLS / (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS; - stride[0] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NROWS; - stride[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS; - block[0] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NROWS / (hsize_t) mpi_size; - block[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS; - start[0] = (hsize_t) mpi_rank * block[0]; - start[1] = 0; + count[0] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_NROWS / (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NROWS; + count[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_NCOLS / (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS; + stride[0] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NROWS; + stride[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS; + block[0] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NROWS / (hsize_t)mpi_size; + block[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS; + start[0] = (hsize_t)mpi_rank * block[0]; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -588,57 +589,56 @@ test_write_filtered_dataset_overlap(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); + correct_buf[i] = (C_DATATYPE)( + (dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_SHARED_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -664,8 +664,8 @@ test_write_filtered_dataset_overlap(void) static void test_write_filtered_dataset_single_no_selection(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; @@ -679,7 +679,8 @@ test_write_filtered_dataset_single_no_selection(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to filtered chunks with a single process having no selection"); + if (MAINPROCESS) + HDputs("Testing write to filtered chunks with a single process having no selection"); CHECK_CUR_FILTER_AVAIL(); @@ -687,11 +688,10 @@ test_write_filtered_dataset_single_no_selection(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -699,12 +699,12 @@ test_write_filtered_dataset_single_no_selection(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; - chunk_dims[0] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; - sel_dims[0] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - sel_dims[1] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; + dataset_dims[0] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + sel_dims[0] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + sel_dims[1] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; if (mpi_rank == WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC) sel_dims[0] = sel_dims[1] = 0; @@ -720,13 +720,13 @@ test_write_filtered_dataset_single_no_selection(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -736,17 +736,19 @@ test_write_filtered_dataset_single_no_selection(void) * it to the hyperslab in the file */ count[0] = 1; - count[1] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS / (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; - stride[0] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - stride[1] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; - block[0] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - block[1] = (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; - start[0] = (hsize_t) mpi_rank * (hsize_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * count[0]; - start[1] = 0; + count[1] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS / + (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + stride[0] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + stride[1] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + block[0] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + block[1] = (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + start[0] = (hsize_t)mpi_rank * (hsize_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * count[0]; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -758,62 +760,61 @@ test_write_filtered_dataset_single_no_selection(void) VRFY((H5Sselect_none(filespace) >= 0), "Select none succeeded"); else VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = - (C_DATATYPE) ( - (i % (dataset_dims[0] / (hsize_t) mpi_size * dataset_dims[1])) - + (i / (dataset_dims[0] / (hsize_t) mpi_size * dataset_dims[1])) - ); + correct_buf[i] = (C_DATATYPE)((i % (dataset_dims[0] / (hsize_t)mpi_size * dataset_dims[1])) + + (i / (dataset_dims[0] / (hsize_t)mpi_size * dataset_dims[1]))); /* Compute the correct offset into the buffer for the process having no selection and clear it */ - segment_length = dataset_dims[0] * dataset_dims[1] / (hsize_t) mpi_size; - HDmemset(correct_buf + ((size_t) WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC * segment_length), - 0, segment_length * sizeof(*data)); + segment_length = dataset_dims[0] * dataset_dims[1] / (hsize_t)mpi_size; + HDmemset(correct_buf + + ((size_t)WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC * segment_length), + 0, segment_length * sizeof(*data)); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -840,8 +841,8 @@ test_write_filtered_dataset_single_no_selection(void) static void test_write_filtered_dataset_all_no_selection(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; @@ -850,7 +851,8 @@ test_write_filtered_dataset_all_no_selection(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to filtered chunks with all processes having no selection"); + if (MAINPROCESS) + HDputs("Testing write to filtered chunks with all processes having no selection"); CHECK_CUR_FILTER_AVAIL(); @@ -858,11 +860,10 @@ test_write_filtered_dataset_all_no_selection(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -870,10 +871,10 @@ test_write_filtered_dataset_all_no_selection(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS; - chunk_dims[0] = (hsize_t) WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + dataset_dims[0] = (hsize_t)WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; sel_dims[0] = sel_dims[1] = 0; filespace = H5Screate_simple(WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, dataset_dims, NULL); @@ -887,13 +888,13 @@ test_write_filtered_dataset_all_no_selection(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -905,47 +906,48 @@ test_write_filtered_dataset_all_no_selection(void) VRFY((H5Sselect_none(filespace) >= 0), "Select none succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -966,10 +968,10 @@ test_write_filtered_dataset_all_no_selection(void) static void test_write_filtered_dataset_point_selection(void) { - C_DATATYPE *data = NULL; + C_DATATYPE *data = NULL; C_DATATYPE *correct_buf = NULL; - C_DATATYPE *read_buf = NULL; - hsize_t *coords = NULL; + C_DATATYPE *read_buf = NULL; + hsize_t * coords = NULL; hsize_t dataset_dims[WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t sel_dims[WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; @@ -978,7 +980,8 @@ test_write_filtered_dataset_point_selection(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to filtered chunks with point selection"); + if (MAINPROCESS) + HDputs("Testing write to filtered chunks with point selection"); CHECK_CUR_FILTER_AVAIL(); @@ -986,11 +989,10 @@ test_write_filtered_dataset_point_selection(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -998,14 +1000,14 @@ test_write_filtered_dataset_point_selection(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; - chunk_dims[0] = (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NCOLS; - sel_dims[0] = (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_NROWS / (hsize_t) mpi_size; - sel_dims[1] = (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; - - filespace = H5Screate_simple(WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, dataset_dims,NULL); + dataset_dims[0] = (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + sel_dims[0] = (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_NROWS / (hsize_t)mpi_size; + sel_dims[1] = (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; + + filespace = H5Screate_simple(WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); memspace = H5Screate_simple(WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, sel_dims, NULL); @@ -1016,13 +1018,13 @@ test_write_filtered_dataset_point_selection(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -1032,69 +1034,71 @@ test_write_filtered_dataset_point_selection(void) filespace = H5Dget_space(dset_id); VRFY((filespace >= 0), "File dataspace retrieval succeeded"); - num_points = (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_NROWS * (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS / (hsize_t) mpi_size; - coords = (hsize_t *) HDcalloc(1, 2 * num_points * sizeof(*coords)); + num_points = (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_NROWS * + (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS / (hsize_t)mpi_size; + coords = (hsize_t *)HDcalloc(1, 2 * num_points * sizeof(*coords)); VRFY((NULL != coords), "Coords HDcalloc succeeded"); for (i = 0; i < num_points; i++) for (j = 0; j < WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS; j++) coords[(i * WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS) + j] = - (j > 0) ? (i % (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS) - : ((hsize_t) mpi_rank + ((hsize_t) mpi_size * (i / (hsize_t) WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS))); + (j > 0) ? (i % (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS) + : ((hsize_t)mpi_rank + + ((hsize_t)mpi_size * (i / (hsize_t)WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS))); - VRFY((H5Sselect_elements(filespace, H5S_SELECT_SET, (hsize_t ) num_points, (const hsize_t * ) coords) >= 0), - "Point selection succeeded"); + VRFY((H5Sselect_elements(filespace, H5S_SELECT_SET, (hsize_t)num_points, (const hsize_t *)coords) >= 0), + "Point selection succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); + correct_buf[i] = (C_DATATYPE)( + (dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (coords) HDfree(coords); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (coords) + HDfree(coords); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -1119,8 +1123,8 @@ test_write_filtered_dataset_point_selection(void) static void test_write_filtered_dataset_interleaved_write(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[INTERLEAVED_WRITE_FILTERED_DATASET_DIMS]; hsize_t chunk_dims[INTERLEAVED_WRITE_FILTERED_DATASET_DIMS]; @@ -1133,7 +1137,8 @@ test_write_filtered_dataset_interleaved_write(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing interleaved write to filtered chunks"); + if (MAINPROCESS) + HDputs("Testing interleaved write to filtered chunks"); CHECK_CUR_FILTER_AVAIL(); @@ -1141,11 +1146,10 @@ test_write_filtered_dataset_interleaved_write(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -1153,12 +1157,12 @@ test_write_filtered_dataset_interleaved_write(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_NROWS; - dataset_dims[1] = (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS; - chunk_dims[0] = (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS; - chunk_dims[1] = (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS; - sel_dims[0] = (hsize_t) (INTERLEAVED_WRITE_FILTERED_DATASET_NROWS / mpi_size); - sel_dims[1] = (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS; + dataset_dims[0] = (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_NROWS; + dataset_dims[1] = (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS; + chunk_dims[0] = (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS; + chunk_dims[1] = (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS; + sel_dims[0] = (hsize_t)(INTERLEAVED_WRITE_FILTERED_DATASET_NROWS / mpi_size); + sel_dims[1] = (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS; filespace = H5Screate_simple(INTERLEAVED_WRITE_FILTERED_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); @@ -1171,13 +1175,13 @@ test_write_filtered_dataset_interleaved_write(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, INTERLEAVED_WRITE_FILTERED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, INTERLEAVED_WRITE_FILTERED_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -1186,18 +1190,21 @@ test_write_filtered_dataset_interleaved_write(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = (hsize_t) (INTERLEAVED_WRITE_FILTERED_DATASET_NROWS / INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS); - count[1] = (hsize_t) (INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS / INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS); - stride[0] = (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS; - stride[1] = (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS; - block[0] = 1; - block[1] = (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS; - start[0] = (hsize_t) mpi_rank; - start[1] = 0; + count[0] = + (hsize_t)(INTERLEAVED_WRITE_FILTERED_DATASET_NROWS / INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS); + count[1] = + (hsize_t)(INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS / INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS); + stride[0] = (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS; + stride[1] = (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS; + block[0] = 1; + block[1] = (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS; + start[0] = (hsize_t)mpi_rank; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -1206,63 +1213,65 @@ test_write_filtered_dataset_interleaved_write(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) /* Add Column Index */ correct_buf[i] = - (C_DATATYPE) ( - (i % (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS) + (C_DATATYPE)((i % (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS) - /* Add the Row Index */ - + ((i % (hsize_t) (mpi_size * INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS)) / (hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS) + /* Add the Row Index */ + + ((i % (hsize_t)(mpi_size * INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS)) / + (hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS) - /* Add the amount that gets added when a rank moves down to its next section vertically in the dataset */ - + ((hsize_t) INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS * (i / (hsize_t) (mpi_size * INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS))) - ); + /* Add the amount that gets added when a rank moves down to its next section + vertically in the dataset */ + + ((hsize_t)INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS * + (i / (hsize_t)(mpi_size * INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS)))); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" INTERLEAVED_WRITE_FILTERED_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -1284,8 +1293,8 @@ test_write_filtered_dataset_interleaved_write(void) static void test_write_3d_filtered_dataset_no_overlap_separate_pages(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; hsize_t chunk_dims[WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; @@ -1298,7 +1307,8 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks on separate pages in 3D dataset"); + if (MAINPROCESS) + HDputs("Testing write to unshared filtered chunks on separate pages in 3D dataset"); CHECK_CUR_FILTER_AVAIL(); @@ -1306,11 +1316,10 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -1318,20 +1327,20 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; - dataset_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; - dataset_dims[2] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DEPTH; - chunk_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; - chunk_dims[2] = 1; - sel_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; - sel_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; - sel_dims[2] = 1; - - filespace = H5Screate_simple( WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, dataset_dims, NULL); + dataset_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; + dataset_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; + dataset_dims[2] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DEPTH; + chunk_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; + chunk_dims[2] = 1; + sel_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; + sel_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; + sel_dims[2] = 1; + + filespace = H5Screate_simple(WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); - memspace = H5Screate_simple( WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, sel_dims, NULL); + memspace = H5Screate_simple(WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, sel_dims, NULL); VRFY((memspace >= 0), "Memory dataspace creation succeeded"); /* Create chunked dataset */ @@ -1339,13 +1348,13 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME, HDF5_DATATYPE_NAME, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -1354,22 +1363,26 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS / (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; - count[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS / (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; - count[2] = 1; - stride[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; - stride[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; + count[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS / + (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; + count[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS / + (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; + count[2] = 1; + stride[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; + stride[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; stride[2] = 1; - block[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; - block[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; - block[2] = 1; - start[0] = 0; - start[1] = 0; - start[2] = (hsize_t) mpi_rank; + block[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; + block[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; + block[2] = 1; + start[0] = 0; + start[1] = 0; + start[2] = (hsize_t)mpi_rank; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", - mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], start[2], block[0], block[1], block[2]); + HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ " + "%llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", + mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], + start[2], block[0], block[1], block[2]); HDfflush(stdout); } @@ -1378,53 +1391,54 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sel_dims[2] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sel_dims[2] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ((i % (hsize_t) mpi_size) + (i / (hsize_t) mpi_size)); + correct_buf[i] = (C_DATATYPE)((i % (hsize_t)mpi_size) + (i / (hsize_t)mpi_size)); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -1447,8 +1461,8 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) static void test_write_3d_filtered_dataset_no_overlap_same_pages(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS]; hsize_t chunk_dims[WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS]; @@ -1461,7 +1475,8 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) hid_t file_id, dset_id, plist_id; hid_t filespace, memspace; - if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks on the same pages in 3D dataset"); + if (MAINPROCESS) + HDputs("Testing write to unshared filtered chunks on the same pages in 3D dataset"); CHECK_CUR_FILTER_AVAIL(); @@ -1469,11 +1484,10 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -1481,17 +1495,18 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS; - dataset_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; - dataset_dims[2] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; - chunk_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; - chunk_dims[2] = 1; - sel_dims[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; - sel_dims[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; - sel_dims[2] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; - - filespace = H5Screate_simple(WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS, dataset_dims, NULL); + dataset_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS; + dataset_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; + dataset_dims[2] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; + chunk_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; + chunk_dims[2] = 1; + sel_dims[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; + sel_dims[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; + sel_dims[2] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; + + filespace = + H5Screate_simple(WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); memspace = H5Screate_simple(WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS, sel_dims, NULL); @@ -1502,13 +1517,13 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME, + HDF5_DATATYPE_NAME, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -1518,21 +1533,24 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) * it to the hyperslab in the file */ count[0] = 1; - count[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS / (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; - count[2] = (hsize_t) mpi_size; - stride[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; - stride[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; + count[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS / + (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; + count[2] = (hsize_t)mpi_size; + stride[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; + stride[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; stride[2] = 1; - block[0] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; - block[1] = (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; - block[2] = 1; - start[0] = ((hsize_t) mpi_rank * (hsize_t) WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS * count[0]); + block[0] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; + block[1] = (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; + block[2] = 1; + start[0] = ((hsize_t)mpi_rank * (hsize_t)WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS * count[0]); start[1] = 0; start[2] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", - mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], start[2], block[0], block[1], block[2]); + HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ " + "%llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", + mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], + start[2], block[0], block[1], block[2]); HDfflush(stdout); } @@ -1541,56 +1559,55 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sel_dims[2] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sel_dims[2] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ( - (i % (dataset_dims[0] * dataset_dims[1])) - + (i / (dataset_dims[0] * dataset_dims[1])) - ); + correct_buf[i] = (C_DATATYPE)((i % (dataset_dims[0] * dataset_dims[1])) + + (i / (dataset_dims[0] * dataset_dims[1]))); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -1613,8 +1630,8 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) static void test_write_3d_filtered_dataset_overlap(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; hsize_t chunk_dims[WRITE_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; @@ -1627,7 +1644,8 @@ test_write_3d_filtered_dataset_overlap(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to shared filtered chunks in 3D dataset"); + if (MAINPROCESS) + HDputs("Testing write to shared filtered chunks in 3D dataset"); CHECK_CUR_FILTER_AVAIL(); @@ -1635,11 +1653,10 @@ test_write_3d_filtered_dataset_overlap(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -1647,15 +1664,15 @@ test_write_3d_filtered_dataset_overlap(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_NROWS; - dataset_dims[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS; - dataset_dims[2] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH; - chunk_dims[0] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; - chunk_dims[2] = 1; - sel_dims[0] = (hsize_t) (WRITE_SHARED_FILTERED_CHUNKS_3D_NROWS / mpi_size); - sel_dims[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS; - sel_dims[2] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH; + dataset_dims[0] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_NROWS; + dataset_dims[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS; + dataset_dims[2] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH; + chunk_dims[0] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; + chunk_dims[2] = 1; + sel_dims[0] = (hsize_t)(WRITE_SHARED_FILTERED_CHUNKS_3D_NROWS / mpi_size); + sel_dims[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS; + sel_dims[2] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH; filespace = H5Screate_simple(WRITE_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); @@ -1668,13 +1685,13 @@ test_write_3d_filtered_dataset_overlap(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, WRITE_SHARED_FILTERED_CHUNKS_3D_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -1683,22 +1700,24 @@ test_write_3d_filtered_dataset_overlap(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = (hsize_t) (WRITE_SHARED_FILTERED_CHUNKS_3D_NROWS / WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NROWS); - count[1] = (hsize_t) (WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS / WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS); - count[2] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH; - stride[0] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NROWS; - stride[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; + count[0] = (hsize_t)(WRITE_SHARED_FILTERED_CHUNKS_3D_NROWS / WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NROWS); + count[1] = (hsize_t)(WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS / WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS); + count[2] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH; + stride[0] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NROWS; + stride[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; stride[2] = 1; - block[0] = 1; - block[1] = (hsize_t) WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; - block[2] = 1; - start[0] = (hsize_t) mpi_rank; - start[1] = 0; - start[2] = 0; + block[0] = 1; + block[1] = (hsize_t)WRITE_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; + block[2] = 1; + start[0] = (hsize_t)mpi_rank; + start[1] = 0; + start[2] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", - mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], start[2], block[0], block[1], block[2]); + HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ " + "%llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", + mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], + start[2], block[0], block[1], block[2]); HDfflush(stdout); } @@ -1706,66 +1725,68 @@ test_write_3d_filtered_dataset_overlap(void) filespace = H5Dget_space(dset_id); VRFY((filespace >= 0), "File dataspace retrieval succeeded"); - VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, - count, block) >= 0), "Hyperslab selection succeeded"); + VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), + "Hyperslab selection succeeded"); /* Fill data buffer */ - data_size = sel_dims[0] * sel_dims[1] * sel_dims[2] * sizeof(*data); + data_size = sel_dims[0] * sel_dims[1] * sel_dims[2] * sizeof(*data); correct_buf_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*correct_buf); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) /* Add the Column Index */ - correct_buf[i] = - (C_DATATYPE) ( - (i % (hsize_t) (WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)) + correct_buf[i] = (C_DATATYPE)( + (i % (hsize_t)(WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)) - /* Add the Row Index */ - + ((i % (hsize_t) (mpi_size * WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)) - / (hsize_t) (WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)) + /* Add the Row Index */ + + ((i % (hsize_t)(mpi_size * WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * + WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)) / + (hsize_t)(WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)) - /* Add the amount that gets added when a rank moves down to its next section vertically in the dataset */ - + ((hsize_t) (WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS) - * (i / (hsize_t) (mpi_size * WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS))) - ); + /* Add the amount that gets added when a rank moves down to its next section vertically in the + dataset */ + + ((hsize_t)(WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS) * + (i / (hsize_t)(mpi_size * WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH * + WRITE_SHARED_FILTERED_CHUNKS_3D_NCOLS)))); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); dset_id = H5Dopen2(file_id, "/" WRITE_SHARED_FILTERED_CHUNKS_3D_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -1787,8 +1808,8 @@ test_write_3d_filtered_dataset_overlap(void) static void test_write_cmpd_filtered_dataset_no_conversion_unshared(void) { - COMPOUND_C_DATATYPE *data = NULL; - COMPOUND_C_DATATYPE *read_buf = NULL; + COMPOUND_C_DATATYPE *data = NULL; + COMPOUND_C_DATATYPE *read_buf = NULL; COMPOUND_C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS]; hsize_t chunk_dims[WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS]; @@ -1801,7 +1822,9 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) hid_t file_id = -1, dset_id = -1, plist_id = -1, memtype = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks in Compound Datatype dataset without Datatype conversion"); + if (MAINPROCESS) + HDputs("Testing write to unshared filtered chunks in Compound Datatype dataset without Datatype " + "conversion"); CHECK_CUR_FILTER_AVAIL(); @@ -1809,11 +1832,10 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -1822,24 +1844,27 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) /* Create the dataspace for the dataset */ dataset_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NROWS; - dataset_dims[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS; - chunk_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; - chunk_dims[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS; - sel_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; - sel_dims[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; - - filespace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, dataset_dims, NULL); + dataset_dims[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS; + chunk_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; + chunk_dims[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS; + sel_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; + sel_dims[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; + + filespace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, + dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); - memspace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, sel_dims, NULL); + memspace = + H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, sel_dims, NULL); VRFY((memspace >= 0), "Memory dataspace creation succeeded"); /* Create chunked dataset */ plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, + chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); @@ -1849,14 +1874,14 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) VRFY((memtype >= 0), "Datatype creation succeeded"); VRFY((H5Tinsert(memtype, "ShortData", HOFFSET(COMPOUND_C_DATATYPE, field1), H5T_NATIVE_SHORT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "IntData", HOFFSET(COMPOUND_C_DATATYPE, field2), H5T_NATIVE_INT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "LongData", HOFFSET(COMPOUND_C_DATATYPE, field3), H5T_NATIVE_LONG) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); - dset_id = H5Dcreate2(file_id, WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME, memtype, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME, memtype, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -1865,18 +1890,19 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = 1; - count[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; + count[0] = 1; + count[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; stride[0] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; stride[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS; - block[0] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; - block[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS; - start[0] = 0; - start[1] = ((hsize_t) mpi_rank * WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS); + block[0] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; + block[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS; + start[0] = 0; + start[1] = ((hsize_t)mpi_rank * WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS); if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -1885,69 +1911,61 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); - data = (COMPOUND_C_DATATYPE *) HDcalloc(1, (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC * sizeof(*data)); + data = (COMPOUND_C_DATATYPE *)HDcalloc( + 1, (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC * sizeof(*data)); VRFY((NULL != data), "HDcalloc succeeded"); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(COMPOUND_C_DATATYPE); - correct_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); /* Fill data buffer */ - for (i = 0; i < (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; i++) { - data[i].field1 = (short) GEN_DATA(i); - data[i].field2 = (int) GEN_DATA(i); - data[i].field3 = (long) GEN_DATA(i); + for (i = 0; i < (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; i++) { + data[i].field1 = (short)GEN_DATA(i); + data[i].field2 = (int)GEN_DATA(i); + data[i].field3 = (long)GEN_DATA(i); } for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) { - correct_buf[i].field1 = (short) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); - - correct_buf[i].field2 = (int) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); - - correct_buf[i].field3 = (long) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); + correct_buf[i].field1 = (short)((i % dataset_dims[1]) + (i / dataset_dims[1])); + + correct_buf[i].field2 = (int)((i % dataset_dims[1]) + (i / dataset_dims[1])); + + correct_buf[i].field3 = (long)((i % dataset_dims[1]) + (i / dataset_dims[1])); } /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); - VRFY((H5Dwrite(dset_id, memtype, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + VRFY((H5Dwrite(dset_id, memtype, memspace, filespace, plist_id, data) >= 0), "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); - dset_id = H5Dopen2(file_id, "/" WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME, H5P_DEFAULT); + dset_id = H5Dopen2(file_id, "/" WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME, + H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -1970,8 +1988,8 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) static void test_write_cmpd_filtered_dataset_no_conversion_shared(void) { - COMPOUND_C_DATATYPE *data = NULL; - COMPOUND_C_DATATYPE *read_buf = NULL; + COMPOUND_C_DATATYPE *data = NULL; + COMPOUND_C_DATATYPE *read_buf = NULL; COMPOUND_C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS]; hsize_t chunk_dims[WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS]; @@ -1984,7 +2002,9 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) hid_t file_id, dset_id, plist_id, memtype; hid_t filespace, memspace; - if (MAINPROCESS) HDputs("Testing write to shared filtered chunks in Compound Datatype dataset without Datatype conversion"); + if (MAINPROCESS) + HDputs("Testing write to shared filtered chunks in Compound Datatype dataset without Datatype " + "conversion"); CHECK_CUR_FILTER_AVAIL(); @@ -1992,11 +2012,10 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -2004,25 +2023,28 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS; - dataset_dims[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS; - chunk_dims[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS; - chunk_dims[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; - sel_dims[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS / (hsize_t) mpi_size; - sel_dims[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; - - filespace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, dataset_dims, NULL); + dataset_dims[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS; + dataset_dims[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS; + chunk_dims[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; + sel_dims[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS / (hsize_t)mpi_size; + sel_dims[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; + + filespace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, + dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); - memspace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, sel_dims, NULL); + memspace = + H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, sel_dims, NULL); VRFY((memspace >= 0), "Memory dataspace creation succeeded"); /* Create chunked dataset */ plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, + chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); @@ -2032,14 +2054,14 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) VRFY((memtype >= 0), "Datatype creation succeeded"); VRFY((H5Tinsert(memtype, "ShortData", HOFFSET(COMPOUND_C_DATATYPE, field1), H5T_NATIVE_SHORT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "IntData", HOFFSET(COMPOUND_C_DATATYPE, field2), H5T_NATIVE_INT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "LongData", HOFFSET(COMPOUND_C_DATATYPE, field3), H5T_NATIVE_LONG) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); - dset_id = H5Dcreate2(file_id, WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME, memtype, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME, memtype, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -2048,18 +2070,19 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = 1; - count[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; - stride[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS; + count[0] = 1; + count[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; + stride[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS; stride[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; - block[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS / (hsize_t) mpi_size; - block[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; - start[0] = (hsize_t) mpi_rank; - start[1] = 0; + block[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS / (hsize_t)mpi_size; + block[1] = WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; + start[0] = (hsize_t)mpi_rank; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -2068,72 +2091,67 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); - data = (COMPOUND_C_DATATYPE *) HDcalloc(1, (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC * sizeof(*data)); + data = (COMPOUND_C_DATATYPE *)HDcalloc( + 1, (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC * sizeof(*data)); VRFY((NULL != data), "HDcalloc succeeded"); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(COMPOUND_C_DATATYPE); - correct_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); /* Fill data buffer */ - for (i = 0; i < (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; i++) { - data[i].field1 = (short) GEN_DATA(i); - data[i].field2 = (int) GEN_DATA(i); - data[i].field3 = (long) GEN_DATA(i); + for (i = 0; i < (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; i++) { + data[i].field1 = (short)GEN_DATA(i); + data[i].field2 = (int)GEN_DATA(i); + data[i].field3 = (long)GEN_DATA(i); } for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) { - correct_buf[i].field1 = (short) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); - - correct_buf[i].field2 = (int) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); - - correct_buf[i].field3 = (long) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); + correct_buf[i].field1 = + (short)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); + + correct_buf[i].field2 = + (int)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); + + correct_buf[i].field3 = + (long)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); } /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); - VRFY((H5Dwrite(dset_id, memtype, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + VRFY((H5Dwrite(dset_id, memtype, memspace, filespace, plist_id, data) >= 0), "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); /* Verify the correct data was written */ - read_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); - dset_id = H5Dopen2(file_id, "/" WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME, H5P_DEFAULT); + dset_id = + H5Dopen2(file_id, "/" WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -2161,8 +2179,8 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) static void test_write_cmpd_filtered_dataset_type_conversion_unshared(void) { - COMPOUND_C_DATATYPE *data = NULL; - COMPOUND_C_DATATYPE *read_buf = NULL; + COMPOUND_C_DATATYPE *data = NULL; + COMPOUND_C_DATATYPE *read_buf = NULL; COMPOUND_C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS]; hsize_t chunk_dims[WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS]; @@ -2175,7 +2193,9 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) hid_t file_id = -1, dset_id = -1, plist_id = -1, filetype = -1, memtype = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks in Compound Datatype dataset with Datatype conversion"); + if (MAINPROCESS) + HDputs("Testing write to unshared filtered chunks in Compound Datatype dataset with Datatype " + "conversion"); CHECK_CUR_FILTER_AVAIL(); @@ -2183,11 +2203,10 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -2196,24 +2215,27 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) /* Create the dataspace for the dataset */ dataset_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NROWS; - dataset_dims[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS; - chunk_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; - chunk_dims[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS; - sel_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; - sel_dims[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; - - filespace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, dataset_dims, NULL); + dataset_dims[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS; + chunk_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; + chunk_dims[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS; + sel_dims[0] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; + sel_dims[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; + + filespace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, + dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); - memspace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, sel_dims, NULL); + memspace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, + sel_dims, NULL); VRFY((memspace >= 0), "Memory dataspace creation succeeded"); /* Create chunked dataset */ plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, + chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); @@ -2223,25 +2245,22 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) VRFY((memtype >= 0), "Datatype creation succeeded"); VRFY((H5Tinsert(memtype, "ShortData", HOFFSET(COMPOUND_C_DATATYPE, field1), H5T_NATIVE_SHORT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "IntData", HOFFSET(COMPOUND_C_DATATYPE, field2), H5T_NATIVE_INT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "LongData", HOFFSET(COMPOUND_C_DATATYPE, field3), H5T_NATIVE_LONG) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); /* Create the compound type for file. */ filetype = H5Tcreate(H5T_COMPOUND, 32); VRFY((filetype >= 0), "Datatype creation succeeded"); - VRFY((H5Tinsert(filetype, "ShortData", 0, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); - VRFY((H5Tinsert(filetype, "IntData", 8, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); - VRFY((H5Tinsert(filetype, "LongData", 16, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "ShortData", 0, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "IntData", 8, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "LongData", 16, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); - dset_id = H5Dcreate2(file_id, WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME, filetype, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME, + filetype, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -2250,18 +2269,19 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = 1; - count[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; + count[0] = 1; + count[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; stride[0] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; stride[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS; - block[0] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; - block[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS; - start[0] = 0; - start[1] = ((hsize_t) mpi_rank * WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS); + block[0] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; + block[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS; + start[0] = 0; + start[1] = ((hsize_t)mpi_rank * WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS); if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -2270,55 +2290,59 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); - data = (COMPOUND_C_DATATYPE *) HDcalloc(1, (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC * sizeof(*data)); + data = (COMPOUND_C_DATATYPE *)HDcalloc( + 1, (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC * sizeof(*data)); VRFY((NULL != data), "HDcalloc succeeded"); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(COMPOUND_C_DATATYPE); - correct_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); /* Fill data buffer */ - for (i = 0; i < (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; i++) { - data[i].field1 = (short) GEN_DATA(i); - data[i].field2 = (int) GEN_DATA(i); - data[i].field3 = (long) GEN_DATA(i); + for (i = 0; i < (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; i++) { + data[i].field1 = (short)GEN_DATA(i); + data[i].field2 = (int)GEN_DATA(i); + data[i].field3 = (long)GEN_DATA(i); } /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); /* Ensure that this test currently fails since type conversions break collective mode */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { VRFY((H5Dwrite(dset_id, memtype, memspace, filespace, plist_id, data) < 0), - "Dataset write succeeded"); - } H5E_END_TRY; + "Dataset write succeeded"); + } + H5E_END_TRY; - if (data) HDfree(data); + if (data) + HDfree(data); /* Verify that no data was written */ VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); - read_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); - dset_id = H5Dopen2(file_id, "/" WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME, H5P_DEFAULT); + dset_id = H5Dopen2(file_id, "/" WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME, + H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -2347,8 +2371,8 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) static void test_write_cmpd_filtered_dataset_type_conversion_shared(void) { - COMPOUND_C_DATATYPE *data = NULL; - COMPOUND_C_DATATYPE *read_buf = NULL; + COMPOUND_C_DATATYPE *data = NULL; + COMPOUND_C_DATATYPE *read_buf = NULL; COMPOUND_C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS]; hsize_t chunk_dims[WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS]; @@ -2361,7 +2385,9 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) hid_t file_id, dset_id, plist_id, filetype, memtype; hid_t filespace, memspace; - if (MAINPROCESS) HDputs("Testing write to shared filtered chunks in Compound Datatype dataset with Datatype conversion"); + if (MAINPROCESS) + HDputs( + "Testing write to shared filtered chunks in Compound Datatype dataset with Datatype conversion"); CHECK_CUR_FILTER_AVAIL(); @@ -2369,11 +2395,10 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -2381,25 +2406,28 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS; - dataset_dims[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS; - chunk_dims[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS; - chunk_dims[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; - sel_dims[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS / (hsize_t) mpi_size; - sel_dims[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; - - filespace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, dataset_dims, NULL); + dataset_dims[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS; + dataset_dims[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS; + chunk_dims[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; + sel_dims[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS / (hsize_t)mpi_size; + sel_dims[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; + + filespace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, + dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); - memspace = H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, sel_dims, NULL); + memspace = + H5Screate_simple(WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, sel_dims, NULL); VRFY((memspace >= 0), "Memory dataspace creation succeeded"); /* Create chunked dataset */ plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, + chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); @@ -2409,25 +2437,22 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) VRFY((memtype >= 0), "Datatype creation succeeded"); VRFY((H5Tinsert(memtype, "ShortData", HOFFSET(COMPOUND_C_DATATYPE, field1), H5T_NATIVE_SHORT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "IntData", HOFFSET(COMPOUND_C_DATATYPE, field2), H5T_NATIVE_INT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "LongData", HOFFSET(COMPOUND_C_DATATYPE, field3), H5T_NATIVE_LONG) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); /* Create the compound type for file. */ filetype = H5Tcreate(H5T_COMPOUND, 32); VRFY((filetype >= 0), "Datatype creation succeeded"); - VRFY((H5Tinsert(filetype, "ShortData", 0, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); - VRFY((H5Tinsert(filetype, "IntData", 8, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); - VRFY((H5Tinsert(filetype, "LongData", 16, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "ShortData", 0, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "IntData", 8, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "LongData", 16, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); - dset_id = H5Dcreate2(file_id, WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME, filetype, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME, + filetype, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -2436,18 +2461,19 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = 1; - count[1] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; - stride[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS; + count[0] = 1; + count[1] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; + stride[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS; stride[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; - block[0] = (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS / (hsize_t) mpi_size; - block[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; - start[0] = (hsize_t) mpi_rank; - start[1] = 0; + block[0] = (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS / (hsize_t)mpi_size; + block[1] = WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; + start[0] = (hsize_t)mpi_rank; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -2456,55 +2482,59 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) VRFY((filespace >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); - data = (COMPOUND_C_DATATYPE *) HDcalloc(1, (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC * sizeof(*data)); + data = (COMPOUND_C_DATATYPE *)HDcalloc( + 1, (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC * sizeof(*data)); VRFY((NULL != data), "HDcalloc succeeded"); correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(COMPOUND_C_DATATYPE); - correct_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); /* Fill data buffer */ - for (i = 0; i < (hsize_t) WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; i++) { - data[i].field1 = (short) GEN_DATA(i); - data[i].field2 = (int) GEN_DATA(i); - data[i].field3 = (long) GEN_DATA(i); + for (i = 0; i < (hsize_t)WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; i++) { + data[i].field1 = (short)GEN_DATA(i); + data[i].field2 = (int)GEN_DATA(i); + data[i].field3 = (long)GEN_DATA(i); } /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); /* Ensure that this test currently fails since type conversions break collective mode */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { VRFY((H5Dwrite(dset_id, memtype, memspace, filespace, plist_id, data) < 0), - "Dataset write succeeded"); - } H5E_END_TRY; + "Dataset write succeeded"); + } + H5E_END_TRY; - if (data) HDfree(data); + if (data) + HDfree(data); /* Verify that no data was written */ VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); - read_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); - dset_id = H5Dopen2(file_id, "/" WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME, H5P_DEFAULT); + dset_id = H5Dopen2(file_id, "/" WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME, + H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -2533,9 +2563,9 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) static void test_read_one_chunk_filtered_dataset(void) { - C_DATATYPE *read_buf = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; - C_DATATYPE *global_buf = NULL; + C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_ONE_CHUNK_FILTERED_DATASET_DIMS]; hsize_t chunk_dims[READ_ONE_CHUNK_FILTERED_DATASET_DIMS]; hsize_t sel_dims[READ_ONE_CHUNK_FILTERED_DATASET_DIMS]; @@ -2547,32 +2577,35 @@ test_read_one_chunk_filtered_dataset(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from one-chunk filtered dataset"); + if (MAINPROCESS) + HDputs("Testing read from one-chunk filtered dataset"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_NROWS; - dataset_dims[1] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_NCOLS; + dataset_dims[0] = (hsize_t)READ_ONE_CHUNK_FILTERED_DATASET_NROWS; + dataset_dims[1] = (hsize_t)READ_ONE_CHUNK_FILTERED_DATASET_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = ((C_DATATYPE) i % (READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)) - + ((C_DATATYPE) i / (READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)); + correct_buf[i] = ((C_DATATYPE)i % (READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * + READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)) + + ((C_DATATYPE)i / (READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * + READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -2584,27 +2617,27 @@ test_read_one_chunk_filtered_dataset(void) VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, READ_ONE_CHUNK_FILTERED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, READ_ONE_CHUNK_FILTERED_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -2614,11 +2647,10 @@ test_read_one_chunk_filtered_dataset(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -2628,8 +2660,8 @@ test_read_one_chunk_filtered_dataset(void) dset_id = H5Dopen2(file_id, "/" READ_ONE_CHUNK_FILTERED_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_NROWS / (hsize_t) mpi_size; - sel_dims[1] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_NCOLS; + sel_dims[0] = (hsize_t)READ_ONE_CHUNK_FILTERED_DATASET_NROWS / (hsize_t)mpi_size; + sel_dims[1] = (hsize_t)READ_ONE_CHUNK_FILTERED_DATASET_NCOLS; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -2645,66 +2677,71 @@ test_read_one_chunk_filtered_dataset(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = 1; - count[1] = 1; - stride[0] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS; - stride[1] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS; - block[0] = sel_dims[0]; - block[1] = sel_dims[1]; - start[0] = ((hsize_t) mpi_rank * sel_dims[0]); - start[1] = 0; + count[0] = 1; + count[1] = 1; + stride[0] = (hsize_t)READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS; + stride[1] = (hsize_t)READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS; + block[0] = sel_dims[0]; + block[1] = sel_dims[1]; + start[0] = ((hsize_t)mpi_rank * sel_dims[0]); + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* Collect each piece of data from all ranks into a global buffer on all ranks */ - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - recvcounts[i] = (int) flat_dims[0]; + for (i = 0; i < (size_t)mpi_size; i++) + recvcounts[i] = (int)flat_dims[0]; - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * flat_dims[0]); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * flat_dims[0]); - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int)flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, + displs, C_DATATYPE_MPI, comm)), + "MPI_Allgatherv succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -2730,9 +2767,9 @@ test_read_one_chunk_filtered_dataset(void) static void test_read_filtered_dataset_no_overlap(void) { - C_DATATYPE *read_buf = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; - C_DATATYPE *global_buf = NULL; + C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_UNSHARED_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[READ_UNSHARED_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t sel_dims[READ_UNSHARED_FILTERED_CHUNKS_DATASET_DIMS]; @@ -2744,34 +2781,34 @@ test_read_filtered_dataset_no_overlap(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks"); + if (MAINPROCESS) + HDputs("Testing read from unshared filtered chunks"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_NCOLS; + dataset_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_NCOLS; /* Setup the buffer for writing and for comparison */ - correct_buf_size = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_NROWS * (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_NCOLS * sizeof(*correct_buf); + correct_buf_size = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_NROWS * + (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_NCOLS * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ( - (i % (dataset_dims[0] / (hsize_t) mpi_size * dataset_dims[1])) - + (i / (dataset_dims[0] / (hsize_t) mpi_size * dataset_dims[1])) - ); + correct_buf[i] = (C_DATATYPE)((i % (dataset_dims[0] / (hsize_t)mpi_size * dataset_dims[1])) + + (i / (dataset_dims[0] / (hsize_t)mpi_size * dataset_dims[1]))); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -2783,27 +2820,27 @@ test_read_filtered_dataset_no_overlap(void) VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, READ_UNSHARED_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_UNSHARED_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_UNSHARED_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -2813,11 +2850,10 @@ test_read_filtered_dataset_no_overlap(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -2827,8 +2863,8 @@ test_read_filtered_dataset_no_overlap(void) dset_id = H5Dopen2(file_id, "/" READ_UNSHARED_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS; - sel_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_NCOLS; + sel_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS; + sel_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_NCOLS; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -2845,65 +2881,70 @@ test_read_filtered_dataset_no_overlap(void) * it to the selection in memory */ count[0] = 1; - count[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_NCOLS / (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; - stride[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS; - stride[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; - block[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS; - block[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; - start[0] = ((hsize_t) mpi_rank * (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS * count[0]); - start[1] = 0; + count[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_NCOLS / (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; + stride[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS; + stride[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; + block[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS; + block[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NCOLS; + start[0] = ((hsize_t)mpi_rank * (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_CH_NROWS * count[0]); + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* Collect each piece of data from all ranks into a global buffer on all ranks */ - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - recvcounts[i] = (int) flat_dims[0]; + for (i = 0; i < (size_t)mpi_size; i++) + recvcounts[i] = (int)flat_dims[0]; - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * flat_dims[0]); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * flat_dims[0]); - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int)flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, + displs, C_DATATYPE_MPI, comm)), + "MPI_Allgatherv succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -2930,9 +2971,9 @@ test_read_filtered_dataset_no_overlap(void) static void test_read_filtered_dataset_overlap(void) { - C_DATATYPE *read_buf = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; - C_DATATYPE *global_buf = NULL; + C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_SHARED_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[READ_SHARED_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t sel_dims[READ_SHARED_FILTERED_CHUNKS_DATASET_DIMS]; @@ -2944,35 +2985,34 @@ test_read_filtered_dataset_overlap(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from shared filtered chunks"); + if (MAINPROCESS) + HDputs("Testing read from shared filtered chunks"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_NCOLS; + dataset_dims[0] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); + correct_buf[i] = (C_DATATYPE)( + (dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -2984,27 +3024,27 @@ test_read_filtered_dataset_overlap(void) VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, READ_SHARED_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, READ_SHARED_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -3014,11 +3054,10 @@ test_read_filtered_dataset_overlap(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3028,8 +3067,8 @@ test_read_filtered_dataset_overlap(void) dset_id = H5Dopen2(file_id, "/" READ_SHARED_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) DIM0_SCALE_FACTOR; - sel_dims[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NCOLS * (hsize_t) DIM1_SCALE_FACTOR; + sel_dims[0] = (hsize_t)DIM0_SCALE_FACTOR; + sel_dims[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NCOLS * (hsize_t)DIM1_SCALE_FACTOR; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -3045,40 +3084,40 @@ test_read_filtered_dataset_overlap(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_NROWS / (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NROWS; - count[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_NCOLS / (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NCOLS; - stride[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NROWS; - stride[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NCOLS; - block[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NROWS / (hsize_t) mpi_size; - block[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_CH_NCOLS; - start[0] = (hsize_t) mpi_rank * block[0]; - start[1] = 0; + count[0] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_NROWS / (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NROWS; + count[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_NCOLS / (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NCOLS; + stride[0] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NROWS; + stride[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NCOLS; + block[0] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NROWS / (hsize_t)mpi_size; + block[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_CH_NCOLS; + start[0] = (hsize_t)mpi_rank * block[0]; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* @@ -3088,38 +3127,44 @@ test_read_filtered_dataset_overlap(void) * of chunks in the first dimension of the dataset. */ { - size_t loop_count = count[0]; + size_t loop_count = count[0]; size_t total_recvcounts = 0; - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) { - recvcounts[i] = (int) dataset_dims[1]; - total_recvcounts += (size_t) recvcounts[i]; + for (i = 0; i < (size_t)mpi_size; i++) { + recvcounts[i] = (int)dataset_dims[1]; + total_recvcounts += (size_t)recvcounts[i]; } - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * dataset_dims[1]); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * dataset_dims[1]); for (; loop_count; loop_count--) { - VRFY((MPI_SUCCESS == MPI_Allgatherv(&read_buf[(count[0] - loop_count) * dataset_dims[1]], recvcounts[mpi_rank], C_DATATYPE_MPI, - &global_buf[(count[0] - loop_count) * total_recvcounts], recvcounts, displs, C_DATATYPE_MPI, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(&read_buf[(count[0] - loop_count) * dataset_dims[1]], + recvcounts[mpi_rank], C_DATATYPE_MPI, + &global_buf[(count[0] - loop_count) * total_recvcounts], + recvcounts, displs, C_DATATYPE_MPI, comm)), + "MPI_Allgatherv succeeded"); } } - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -3146,9 +3191,9 @@ test_read_filtered_dataset_overlap(void) static void test_read_filtered_dataset_single_no_selection(void) { - C_DATATYPE *read_buf = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; - C_DATATYPE *global_buf = NULL; + C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t sel_dims[READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; @@ -3161,40 +3206,38 @@ test_read_filtered_dataset_single_no_selection(void) size_t segment_length; hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from filtered chunks with a single process having no selection"); + if (MAINPROCESS) + HDputs("Testing read from filtered chunks with a single process having no selection"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; + dataset_dims[0] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = - (C_DATATYPE) ( - (i % (dataset_dims[0] / (hsize_t) mpi_size * dataset_dims[1])) - + (i / (dataset_dims[0] / (hsize_t) mpi_size * dataset_dims[1])) - ); + correct_buf[i] = (C_DATATYPE)((i % (dataset_dims[0] / (hsize_t)mpi_size * dataset_dims[1])) + + (i / (dataset_dims[0] / (hsize_t)mpi_size * dataset_dims[1]))); /* Compute the correct offset into the buffer for the process having no selection and clear it */ - segment_length = dataset_dims[0] * dataset_dims[1] / (hsize_t) mpi_size; - HDmemset(correct_buf + ((size_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC * segment_length), - 0, segment_length * sizeof(*correct_buf)); + segment_length = dataset_dims[0] * dataset_dims[1] / (hsize_t)mpi_size; + HDmemset(correct_buf + ((size_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC * segment_length), + 0, segment_length * sizeof(*correct_buf)); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3202,31 +3245,32 @@ test_read_filtered_dataset_single_no_selection(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - filespace = H5Screate_simple(READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, dataset_dims, NULL); + filespace = + H5Screate_simple(READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, + HDF5_DATATYPE_NAME, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -3236,11 +3280,10 @@ test_read_filtered_dataset_single_no_selection(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3250,8 +3293,8 @@ test_read_filtered_dataset_single_no_selection(void) dset_id = H5Dopen2(file_id, "/" READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - sel_dims[1] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; + sel_dims[0] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + sel_dims[1] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; if (mpi_rank == READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC) sel_dims[0] = sel_dims[1] = 0; @@ -3271,17 +3314,19 @@ test_read_filtered_dataset_single_no_selection(void) * reads it to the selection in memory */ count[0] = 1; - count[1] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS / (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; - stride[0] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - stride[1] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; - block[0] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - block[1] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; - start[0] = (hsize_t) mpi_rank * (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * count[0]; - start[1] = 0; + count[1] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS / + (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + stride[0] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + stride[1] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + block[0] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + block[1] = (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + start[0] = (hsize_t)mpi_rank * (hsize_t)READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * count[0]; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -3289,55 +3334,62 @@ test_read_filtered_dataset_single_no_selection(void) VRFY((H5Sselect_none(filespace) >= 0), "Select none succeeded"); else VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* Collect each piece of data from all ranks into a global buffer on all ranks */ - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - recvcounts[i] = (int) (READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS); + for (i = 0; i < (size_t)mpi_size; i++) + recvcounts[i] = (int)(READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * + READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS); recvcounts[READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC] = 0; - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * (size_t) (READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS)); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * (size_t)(READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * + READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS)); if (mpi_rank == READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC) - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, 0, C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, 0, C_DATATYPE_MPI, global_buf, recvcounts, displs, + C_DATATYPE_MPI, comm)), + "MPI_Allgatherv succeeded"); else - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), - "MPI_Allgatherv succeeded"); - - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); - - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int)flat_dims[0], C_DATATYPE_MPI, global_buf, + recvcounts, displs, C_DATATYPE_MPI, comm)), + "MPI_Allgatherv succeeded"); + + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); + + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -3365,7 +3417,7 @@ test_read_filtered_dataset_single_no_selection(void) static void test_read_filtered_dataset_all_no_selection(void) { - C_DATATYPE *read_buf = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; @@ -3374,17 +3426,18 @@ test_read_filtered_dataset_all_no_selection(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing read from filtered chunks with all processes having no selection"); + if (MAINPROCESS) + HDputs("Testing read from filtered chunks with all processes having no selection"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS; + dataset_dims[0] = (hsize_t)READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); if (MAINPROCESS) { @@ -3392,7 +3445,7 @@ test_read_filtered_dataset_all_no_selection(void) VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3404,27 +3457,27 @@ test_read_filtered_dataset_all_no_selection(void) VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -3434,11 +3487,10 @@ test_read_filtered_dataset_all_no_selection(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3463,19 +3515,20 @@ test_read_filtered_dataset_all_no_selection(void) plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -3503,9 +3556,9 @@ static void test_read_filtered_dataset_point_selection(void) { C_DATATYPE *correct_buf = NULL; - C_DATATYPE *read_buf = NULL; - C_DATATYPE *global_buf = NULL; - hsize_t *coords = NULL; + C_DATATYPE *read_buf = NULL; + C_DATATYPE *global_buf = NULL; + hsize_t * coords = NULL; hsize_t dataset_dims[READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t chunk_dims[READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; hsize_t sel_dims[READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS]; @@ -3514,35 +3567,34 @@ test_read_filtered_dataset_point_selection(void) size_t num_points; hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from filtered chunks with point selection"); + if (MAINPROCESS) + HDputs("Testing read from filtered chunks with point selection"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; + dataset_dims[0] = (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); + correct_buf[i] = (C_DATATYPE)( + (dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3554,27 +3606,27 @@ test_read_filtered_dataset_point_selection(void) VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_NAME, HDF5_DATATYPE_NAME, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -3584,11 +3636,10 @@ test_read_filtered_dataset_point_selection(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3598,8 +3649,8 @@ test_read_filtered_dataset_point_selection(void) dset_id = H5Dopen2(file_id, "/" READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NROWS / (hsize_t) mpi_size; - sel_dims[1] = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; + sel_dims[0] = (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_NROWS / (hsize_t)mpi_size; + sel_dims[1] = (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -3611,35 +3662,36 @@ test_read_filtered_dataset_point_selection(void) filespace = H5Dget_space(dset_id); VRFY((filespace >= 0), "File dataspace retrieval succeeded"); - num_points = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NROWS * (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS / (hsize_t) mpi_size; - coords = (hsize_t *) HDcalloc(1, 2 * num_points * sizeof(*coords)); + num_points = (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_NROWS * + (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS / (hsize_t)mpi_size; + coords = (hsize_t *)HDcalloc(1, 2 * num_points * sizeof(*coords)); VRFY((NULL != coords), "Coords HDcalloc succeeded"); for (i = 0; i < num_points; i++) for (j = 0; j < READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS; j++) coords[(i * READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS) + j] = - (j > 0) ? (i % (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS) - : ((hsize_t) mpi_rank + ((hsize_t) mpi_size * (i / (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS))); + (j > 0) ? (i % (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS) + : ((hsize_t)mpi_rank + + ((hsize_t)mpi_size * (i / (hsize_t)READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS))); - VRFY((H5Sselect_elements(filespace, H5S_SELECT_SET, (hsize_t ) num_points, (const hsize_t * ) coords) >= 0), - "Point selection succeeded"); + VRFY((H5Sselect_elements(filespace, H5S_SELECT_SET, (hsize_t)num_points, (const hsize_t *)coords) >= 0), + "Point selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* @@ -3649,39 +3701,46 @@ test_read_filtered_dataset_point_selection(void) * of chunks in the first dimension of the dataset. */ { - size_t original_loop_count = dataset_dims[0] / (hsize_t) mpi_size; - size_t cur_loop_count = original_loop_count; - size_t total_recvcounts = 0; + size_t original_loop_count = dataset_dims[0] / (hsize_t)mpi_size; + size_t cur_loop_count = original_loop_count; + size_t total_recvcounts = 0; - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) { - recvcounts[i] = (int) dataset_dims[1]; - total_recvcounts += (size_t) recvcounts[i]; + for (i = 0; i < (size_t)mpi_size; i++) { + recvcounts[i] = (int)dataset_dims[1]; + total_recvcounts += (size_t)recvcounts[i]; } - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * dataset_dims[1]); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * dataset_dims[1]); for (; cur_loop_count; cur_loop_count--) { - VRFY((MPI_SUCCESS == MPI_Allgatherv(&read_buf[(original_loop_count - cur_loop_count) * dataset_dims[1]], recvcounts[mpi_rank], C_DATATYPE_MPI, - &global_buf[(original_loop_count - cur_loop_count) * total_recvcounts], recvcounts, displs, C_DATATYPE_MPI, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == + MPI_Allgatherv(&read_buf[(original_loop_count - cur_loop_count) * dataset_dims[1]], + recvcounts[mpi_rank], C_DATATYPE_MPI, + &global_buf[(original_loop_count - cur_loop_count) * total_recvcounts], + recvcounts, displs, C_DATATYPE_MPI, comm)), + "MPI_Allgatherv succeeded"); } } - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); HDfree(coords); @@ -3713,9 +3772,9 @@ test_read_filtered_dataset_point_selection(void) static void test_read_filtered_dataset_interleaved_read(void) { - C_DATATYPE *read_buf = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; - C_DATATYPE *global_buf = NULL; + C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[INTERLEAVED_READ_FILTERED_DATASET_DIMS]; hsize_t chunk_dims[INTERLEAVED_READ_FILTERED_DATASET_DIMS]; hsize_t sel_dims[INTERLEAVED_READ_FILTERED_DATASET_DIMS]; @@ -3727,41 +3786,43 @@ test_read_filtered_dataset_interleaved_read(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing interleaved read from filtered chunks"); + if (MAINPROCESS) + HDputs("Testing interleaved read from filtered chunks"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_NROWS; - dataset_dims[1] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_NCOLS; + dataset_dims[0] = (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_NROWS; + dataset_dims[1] = (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) /* Add Column Index */ correct_buf[i] = - (C_DATATYPE) ( - (i % (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_NCOLS) + (C_DATATYPE)((i % (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_NCOLS) - /* Add the Row Index */ - + ((i % (hsize_t) (mpi_size * INTERLEAVED_READ_FILTERED_DATASET_NCOLS)) / (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_NCOLS) + /* Add the Row Index */ + + ((i % (hsize_t)(mpi_size * INTERLEAVED_READ_FILTERED_DATASET_NCOLS)) / + (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_NCOLS) - /* Add the amount that gets added when a rank moves down to its next section vertically in the dataset */ - + ((hsize_t) INTERLEAVED_READ_FILTERED_DATASET_NCOLS * (i / (hsize_t) (mpi_size * INTERLEAVED_READ_FILTERED_DATASET_NCOLS))) - ); + /* Add the amount that gets added when a rank moves down to its next section + vertically in the dataset */ + + ((hsize_t)INTERLEAVED_READ_FILTERED_DATASET_NCOLS * + (i / (hsize_t)(mpi_size * INTERLEAVED_READ_FILTERED_DATASET_NCOLS)))); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3773,27 +3834,27 @@ test_read_filtered_dataset_interleaved_read(void) VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS; - chunk_dims[1] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS; + chunk_dims[0] = (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS; + chunk_dims[1] = (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, INTERLEAVED_READ_FILTERED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, INTERLEAVED_READ_FILTERED_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -3803,11 +3864,10 @@ test_read_filtered_dataset_interleaved_read(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3815,10 +3875,10 @@ test_read_filtered_dataset_interleaved_read(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); dset_id = H5Dopen2(file_id, "/" INTERLEAVED_READ_FILTERED_DATASET_NAME, H5P_DEFAULT); - VRFY((dset_id >= 0), "Dataset open succeeded"); + VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) (INTERLEAVED_READ_FILTERED_DATASET_NROWS / mpi_size); - sel_dims[1] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_NCOLS; + sel_dims[0] = (hsize_t)(INTERLEAVED_READ_FILTERED_DATASET_NROWS / mpi_size); + sel_dims[1] = (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_NCOLS; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -3834,40 +3894,42 @@ test_read_filtered_dataset_interleaved_read(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = (hsize_t) (INTERLEAVED_READ_FILTERED_DATASET_NROWS / INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS); - count[1] = (hsize_t) (INTERLEAVED_READ_FILTERED_DATASET_NCOLS / INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS); - stride[0] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS; - stride[1] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS; - block[0] = 1; - block[1] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS; - start[0] = (hsize_t) mpi_rank; - start[1] = 0; + count[0] = + (hsize_t)(INTERLEAVED_READ_FILTERED_DATASET_NROWS / INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS); + count[1] = + (hsize_t)(INTERLEAVED_READ_FILTERED_DATASET_NCOLS / INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS); + stride[0] = (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS; + stride[1] = (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS; + block[0] = 1; + block[1] = (hsize_t)INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS; + start[0] = (hsize_t)mpi_rank; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* @@ -3877,38 +3939,44 @@ test_read_filtered_dataset_interleaved_read(void) * of chunks in the first dimension of the dataset. */ { - size_t loop_count = count[0]; + size_t loop_count = count[0]; size_t total_recvcounts = 0; - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) { - recvcounts[i] = (int) dataset_dims[1]; - total_recvcounts += (size_t) recvcounts[i]; + for (i = 0; i < (size_t)mpi_size; i++) { + recvcounts[i] = (int)dataset_dims[1]; + total_recvcounts += (size_t)recvcounts[i]; } - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * dataset_dims[1]); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * dataset_dims[1]); for (; loop_count; loop_count--) { - VRFY((MPI_SUCCESS == MPI_Allgatherv(&read_buf[(count[0] - loop_count) * dataset_dims[1]], recvcounts[mpi_rank], C_DATATYPE_MPI, - &global_buf[(count[0] - loop_count) * total_recvcounts], recvcounts, displs, C_DATATYPE_MPI, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(&read_buf[(count[0] - loop_count) * dataset_dims[1]], + recvcounts[mpi_rank], C_DATATYPE_MPI, + &global_buf[(count[0] - loop_count) * total_recvcounts], + recvcounts, displs, C_DATATYPE_MPI, comm)), + "MPI_Allgatherv succeeded"); } } - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -3935,46 +4003,47 @@ test_read_filtered_dataset_interleaved_read(void) static void test_read_3d_filtered_dataset_no_overlap_separate_pages(void) { - MPI_Datatype vector_type; - MPI_Datatype resized_vector_type; - C_DATATYPE *read_buf = NULL; - C_DATATYPE *correct_buf = NULL; - C_DATATYPE *global_buf = NULL; - hsize_t dataset_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; - hsize_t chunk_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; - hsize_t sel_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; - hsize_t start[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; - hsize_t stride[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; - hsize_t count[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; - hsize_t block[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; - hsize_t flat_dims[1]; - size_t i, read_buf_size, correct_buf_size; - hid_t file_id = -1, dset_id = -1, plist_id = -1; - hid_t filespace = -1, memspace = -1; - - if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks on separate pages in 3D dataset"); + MPI_Datatype vector_type; + MPI_Datatype resized_vector_type; + C_DATATYPE * read_buf = NULL; + C_DATATYPE * correct_buf = NULL; + C_DATATYPE * global_buf = NULL; + hsize_t dataset_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; + hsize_t chunk_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; + hsize_t sel_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; + hsize_t start[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; + hsize_t stride[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; + hsize_t count[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; + hsize_t block[READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS]; + hsize_t flat_dims[1]; + size_t i, read_buf_size, correct_buf_size; + hid_t file_id = -1, dset_id = -1, plist_id = -1; + hid_t filespace = -1, memspace = -1; + + if (MAINPROCESS) + HDputs("Testing read from unshared filtered chunks on separate pages in 3D dataset"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; - dataset_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; - dataset_dims[2] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DEPTH; + dataset_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; + dataset_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; + dataset_dims[2] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DEPTH; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ((i % (hsize_t) mpi_size) + (i / (hsize_t) mpi_size)); + correct_buf[i] = (C_DATATYPE)((i % (hsize_t)mpi_size) + (i / (hsize_t)mpi_size)); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -3982,32 +4051,34 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - filespace = H5Screate_simple(READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, dataset_dims, NULL); + filespace = + H5Screate_simple(READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; chunk_dims[2] = 1; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY( + (H5Pset_chunk(plist_id, READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS, chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME, + HDF5_DATATYPE_NAME, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -4017,11 +4088,10 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -4031,8 +4101,8 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) dset_id = H5Dopen2(file_id, "/" READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; - sel_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; + sel_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; + sel_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; sel_dims[2] = 1; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ @@ -4049,52 +4119,54 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS / (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; - count[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS / (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; - count[2] = 1; - stride[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; - stride[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; + count[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS / + (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; + count[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS / + (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; + count[2] = 1; + stride[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; + stride[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; stride[2] = 1; - block[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; - block[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; - block[2] = 1; - start[0] = 0; - start[1] = 0; - start[2] = (hsize_t) mpi_rank; + block[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS; + block[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS; + block[2] = 1; + start[0] = 0; + start[1] = 0; + start[2] = (hsize_t)mpi_rank; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* * Due to the nature of 3-dimensional reading, create an MPI vector type that allows each * rank to write to the nth position of the global data buffer, where n is the rank number. */ - VRFY((MPI_SUCCESS == MPI_Type_vector((int) flat_dims[0], 1, mpi_size, C_DATATYPE_MPI, &vector_type)), - "MPI_Type_vector succeeded"); + VRFY((MPI_SUCCESS == MPI_Type_vector((int)flat_dims[0], 1, mpi_size, C_DATATYPE_MPI, &vector_type)), + "MPI_Type_vector succeeded"); VRFY((MPI_SUCCESS == MPI_Type_commit(&vector_type)), "MPI_Type_commit succeeded"); /* @@ -4102,21 +4174,24 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) * so make it only one MPI_LONG wide */ VRFY((MPI_SUCCESS == MPI_Type_create_resized(vector_type, 0, sizeof(long), &resized_vector_type)), - "MPI_Type_create_resized"); + "MPI_Type_create_resized"); VRFY((MPI_SUCCESS == MPI_Type_commit(&resized_vector_type)), "MPI_Type_commit succeeded"); - VRFY((MPI_SUCCESS == MPI_Allgather(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, 1, resized_vector_type, comm)), - "MPI_Allgather succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgather(read_buf, (int)flat_dims[0], C_DATATYPE_MPI, global_buf, 1, + resized_vector_type, comm)), + "MPI_Allgather succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); VRFY((MPI_SUCCESS == MPI_Type_free(&vector_type)), "MPI_Type_free succeeded"); VRFY((MPI_SUCCESS == MPI_Type_free(&resized_vector_type)), "MPI_Type_free succeeded"); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -4144,9 +4219,9 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) static void test_read_3d_filtered_dataset_no_overlap_same_pages(void) { - C_DATATYPE *read_buf = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; - C_DATATYPE *global_buf = NULL; + C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS]; hsize_t chunk_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS]; hsize_t sel_dims[READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS]; @@ -4158,35 +4233,34 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id, dset_id, plist_id; hid_t filespace, memspace; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks on the same pages in 3D dataset"); + if (MAINPROCESS) + HDputs("Testing read from unshared filtered chunks on the same pages in 3D dataset"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS; - dataset_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; - dataset_dims[2] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; + dataset_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS; + dataset_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; + dataset_dims[2] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ( - (i % (dataset_dims[0] * dataset_dims[1])) - + (i / (dataset_dims[0] * dataset_dims[1])) - ); + correct_buf[i] = (C_DATATYPE)((i % (dataset_dims[0] * dataset_dims[1])) + + (i / (dataset_dims[0] * dataset_dims[1]))); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -4194,32 +4268,34 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - filespace = H5Screate_simple(READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS, dataset_dims, NULL); + filespace = + H5Screate_simple(READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; chunk_dims[2] = 1; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS, chunk_dims) >= + 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME, + HDF5_DATATYPE_NAME, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -4229,11 +4305,10 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -4243,9 +4318,9 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) dset_id = H5Dopen2(file_id, "/" READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; - sel_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; - sel_dims[2] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; + sel_dims[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; + sel_dims[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; + sel_dims[2] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1] * sel_dims[2]; @@ -4262,69 +4337,75 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) * reads it to the selection in memory */ count[0] = 1; - count[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS / (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; - count[2] = (hsize_t) mpi_size; - stride[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; - stride[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; + count[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS / + (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; + count[2] = (hsize_t)mpi_size; + stride[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; + stride[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; stride[2] = 1; - block[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; - block[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; - block[2] = 1; - start[0] = ((hsize_t) mpi_rank * (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS * count[0]); - start[1] = 0; - start[2] = 0; + block[0] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS; + block[1] = (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS; + block[2] = 1; + start[0] = ((hsize_t)mpi_rank * (hsize_t)READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS * count[0]); + start[1] = 0; + start[2] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* Collect each piece of data from all ranks into a global buffer on all ranks */ - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - recvcounts[i] = (int) flat_dims[0]; + for (i = 0; i < (size_t)mpi_size; i++) + recvcounts[i] = (int)flat_dims[0]; - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * flat_dims[0]); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * flat_dims[0]); - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int)flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, + displs, C_DATATYPE_MPI, comm)), + "MPI_Allgatherv succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -4352,58 +4433,60 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) static void test_read_3d_filtered_dataset_overlap(void) { - MPI_Datatype vector_type; - MPI_Datatype resized_vector_type; - C_DATATYPE *read_buf = NULL; - C_DATATYPE *correct_buf = NULL; - C_DATATYPE *global_buf = NULL; - hsize_t dataset_dims[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; - hsize_t chunk_dims[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; - hsize_t sel_dims[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; - hsize_t start[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; - hsize_t stride[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; - hsize_t count[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; - hsize_t block[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; - hsize_t flat_dims[1]; - size_t i, read_buf_size, correct_buf_size; - hid_t file_id = -1, dset_id = -1, plist_id = -1; - hid_t filespace = -1, memspace = -1; - - if (MAINPROCESS) HDputs("Testing read from shared filtered chunks in 3D dataset"); + MPI_Datatype vector_type; + MPI_Datatype resized_vector_type; + C_DATATYPE * read_buf = NULL; + C_DATATYPE * correct_buf = NULL; + C_DATATYPE * global_buf = NULL; + hsize_t dataset_dims[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; + hsize_t chunk_dims[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; + hsize_t sel_dims[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; + hsize_t start[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; + hsize_t stride[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; + hsize_t count[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; + hsize_t block[READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS]; + hsize_t flat_dims[1]; + size_t i, read_buf_size, correct_buf_size; + hid_t file_id = -1, dset_id = -1, plist_id = -1; + hid_t filespace = -1, memspace = -1; + + if (MAINPROCESS) + HDputs("Testing read from shared filtered chunks in 3D dataset"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_NROWS; - dataset_dims[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_NCOLS; - dataset_dims[2] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_DEPTH; + dataset_dims[0] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_NROWS; + dataset_dims[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_NCOLS; + dataset_dims[2] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_DEPTH; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) /* Add the Column Index */ - correct_buf[i] = - (C_DATATYPE) ( - (i % (hsize_t) (READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)) + correct_buf[i] = (C_DATATYPE)( + (i % (hsize_t)(READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)) - /* Add the Row Index */ - + ((i % (hsize_t) (mpi_size * READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)) - / (hsize_t) (READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)) + /* Add the Row Index */ + + ((i % (hsize_t)(mpi_size * READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * + READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)) / + (hsize_t)(READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)) - /* Add the amount that gets added when a rank moves down to its next section vertically in the dataset */ - + ((hsize_t) (READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS) - * (i / (hsize_t) (mpi_size * READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS))) - ); + /* Add the amount that gets added when a rank moves down to its next section vertically in the + dataset */ + + ((hsize_t)(READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * READ_SHARED_FILTERED_CHUNKS_3D_NCOLS) * + (i / (hsize_t)(mpi_size * READ_SHARED_FILTERED_CHUNKS_3D_DEPTH * + READ_SHARED_FILTERED_CHUNKS_3D_NCOLS)))); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -4415,28 +4498,28 @@ test_read_3d_filtered_dataset_overlap(void) VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; chunk_dims[2] = 1; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, READ_SHARED_FILTERED_CHUNKS_3D_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_SHARED_FILTERED_CHUNKS_3D_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_SHARED_FILTERED_CHUNKS_3D_DATASET_NAME, HDF5_DATATYPE_NAME, + filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -4446,11 +4529,10 @@ test_read_3d_filtered_dataset_overlap(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -4460,9 +4542,9 @@ test_read_3d_filtered_dataset_overlap(void) dset_id = H5Dopen2(file_id, "/" READ_SHARED_FILTERED_CHUNKS_3D_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) (READ_SHARED_FILTERED_CHUNKS_3D_NROWS / mpi_size); - sel_dims[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_NCOLS; - sel_dims[2] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_DEPTH; + sel_dims[0] = (hsize_t)(READ_SHARED_FILTERED_CHUNKS_3D_NROWS / mpi_size); + sel_dims[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_NCOLS; + sel_dims[2] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_DEPTH; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1] * sel_dims[2]; @@ -4478,79 +4560,86 @@ test_read_3d_filtered_dataset_overlap(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = (hsize_t) (READ_SHARED_FILTERED_CHUNKS_3D_NROWS / READ_SHARED_FILTERED_CHUNKS_3D_CH_NROWS); - count[1] = (hsize_t) (READ_SHARED_FILTERED_CHUNKS_3D_NCOLS / READ_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS); - count[2] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_DEPTH; - stride[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_CH_NROWS; - stride[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; + count[0] = (hsize_t)(READ_SHARED_FILTERED_CHUNKS_3D_NROWS / READ_SHARED_FILTERED_CHUNKS_3D_CH_NROWS); + count[1] = (hsize_t)(READ_SHARED_FILTERED_CHUNKS_3D_NCOLS / READ_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS); + count[2] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_DEPTH; + stride[0] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_CH_NROWS; + stride[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; stride[2] = 1; - block[0] = 1; - block[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; - block[2] = 1; - start[0] = (hsize_t) mpi_rank; - start[1] = 0; - start[2] = 0; + block[0] = 1; + block[1] = (hsize_t)READ_SHARED_FILTERED_CHUNKS_3D_CH_NCOLS; + block[2] = 1; + start[0] = (hsize_t)mpi_rank; + start[1] = 0; + start[2] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - global_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); { - size_t run_length = (size_t) (READ_SHARED_FILTERED_CHUNKS_3D_NCOLS * READ_SHARED_FILTERED_CHUNKS_3D_DEPTH); - size_t num_blocks = (size_t) (READ_SHARED_FILTERED_CHUNKS_3D_NROWS / mpi_size); + size_t run_length = + (size_t)(READ_SHARED_FILTERED_CHUNKS_3D_NCOLS * READ_SHARED_FILTERED_CHUNKS_3D_DEPTH); + size_t num_blocks = (size_t)(READ_SHARED_FILTERED_CHUNKS_3D_NROWS / mpi_size); /* * Due to the nature of 3-dimensional reading, create an MPI vector type that allows each * rank to write to the nth position of the global data buffer, where n is the rank number. */ - VRFY((MPI_SUCCESS == MPI_Type_vector((int) num_blocks, (int) run_length, (int) (mpi_size * (int) run_length), C_DATATYPE_MPI, &vector_type)), - "MPI_Type_vector succeeded"); + VRFY( + (MPI_SUCCESS == MPI_Type_vector((int)num_blocks, (int)run_length, + (int)(mpi_size * (int)run_length), C_DATATYPE_MPI, &vector_type)), + "MPI_Type_vector succeeded"); VRFY((MPI_SUCCESS == MPI_Type_commit(&vector_type)), "MPI_Type_commit succeeded"); /* * Resize the type to allow interleaving, * so make it "run_length" MPI_LONGs wide */ - VRFY((MPI_SUCCESS == MPI_Type_create_resized(vector_type, 0, (MPI_Aint) (run_length * sizeof(long)), &resized_vector_type)), - "MPI_Type_create_resized"); + VRFY((MPI_SUCCESS == MPI_Type_create_resized(vector_type, 0, (MPI_Aint)(run_length * sizeof(long)), + &resized_vector_type)), + "MPI_Type_create_resized"); VRFY((MPI_SUCCESS == MPI_Type_commit(&resized_vector_type)), "MPI_Type_commit succeeded"); } - VRFY((MPI_SUCCESS == MPI_Allgather(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, 1, resized_vector_type, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgather(read_buf, (int)flat_dims[0], C_DATATYPE_MPI, global_buf, 1, + resized_vector_type, comm)), + "MPI_Allgatherv succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); VRFY((MPI_SUCCESS == MPI_Type_free(&vector_type)), "MPI_Type_free succeeded"); VRFY((MPI_SUCCESS == MPI_Type_free(&resized_vector_type)), "MPI_Type_free succeeded"); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -4577,9 +4666,9 @@ test_read_3d_filtered_dataset_overlap(void) static void test_read_cmpd_filtered_dataset_no_conversion_unshared(void) { - COMPOUND_C_DATATYPE *read_buf = NULL; + COMPOUND_C_DATATYPE *read_buf = NULL; COMPOUND_C_DATATYPE *correct_buf = NULL; - COMPOUND_C_DATATYPE *global_buf = NULL; + COMPOUND_C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS]; hsize_t chunk_dims[READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS]; hsize_t sel_dims[READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS]; @@ -4591,37 +4680,30 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id = -1, dset_id = -1, plist_id = -1, memtype = -1; hid_t filespace = -1, memspace = -1; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks in Compound Datatype dataset without Datatype conversion"); + if (MAINPROCESS) + HDputs("Testing read from unshared filtered chunks in Compound Datatype dataset without Datatype " + "conversion"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NROWS; - dataset_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS; + dataset_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NROWS; + dataset_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) { - correct_buf[i].field1 = (short) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); - - correct_buf[i].field2 = (int) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); - - correct_buf[i].field3 = (long) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); + correct_buf[i].field1 = (short)((i % dataset_dims[1]) + (i / dataset_dims[1])); + + correct_buf[i].field2 = (int)((i % dataset_dims[1]) + (i / dataset_dims[1])); + + correct_buf[i].field3 = (long)((i % dataset_dims[1]) + (i / dataset_dims[1])); } /* Create the compound type for memory. */ @@ -4629,18 +4711,18 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) VRFY((memtype >= 0), "Datatype creation succeeded"); VRFY((H5Tinsert(memtype, "ShortData", HOFFSET(COMPOUND_C_DATATYPE, field1), H5T_NATIVE_SHORT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "IntData", HOFFSET(COMPOUND_C_DATATYPE, field2), H5T_NATIVE_INT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "LongData", HOFFSET(COMPOUND_C_DATATYPE, field3), H5T_NATIVE_LONG) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -4648,7 +4730,8 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - filespace = H5Screate_simple(READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, dataset_dims, NULL); + filespace = H5Screate_simple(READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, + dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ @@ -4658,21 +4741,22 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS, + chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME, memtype, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME, + memtype, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -4682,22 +4766,22 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); - dset_id = H5Dopen2(file_id, "/" READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME, H5P_DEFAULT); + dset_id = + H5Dopen2(file_id, "/" READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; - sel_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; + sel_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; + sel_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -4713,66 +4797,70 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = 1; - count[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; + count[0] = 1; + count[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC; stride[0] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; stride[1] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS; - block[0] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; - block[1] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS; - start[0] = 0; - start[1] = ((hsize_t) mpi_rank * READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS); + block[0] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS; + block[1] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS; + start[0] = 0; + start[1] = ((hsize_t)mpi_rank * READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS); if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); - VRFY((H5Dread(dset_id, memtype, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + VRFY((H5Dread(dset_id, memtype, memspace, filespace, plist_id, read_buf) >= 0), "Dataset read succeeded"); - global_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* Collect each piece of data from all ranks into a global buffer on all ranks */ - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - recvcounts[i] = (int) (flat_dims[0] * sizeof(*read_buf)); + for (i = 0; i < (size_t)mpi_size; i++) + recvcounts[i] = (int)(flat_dims[0] * sizeof(*read_buf)); - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * flat_dims[0] * sizeof(*read_buf)); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * flat_dims[0] * sizeof(*read_buf)); - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) (flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, global_buf, recvcounts, displs, MPI_BYTE, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int)(flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, + global_buf, recvcounts, displs, MPI_BYTE, comm)), + "MPI_Allgatherv succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -4800,9 +4888,9 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) static void test_read_cmpd_filtered_dataset_no_conversion_shared(void) { - COMPOUND_C_DATATYPE *read_buf = NULL; + COMPOUND_C_DATATYPE *read_buf = NULL; COMPOUND_C_DATATYPE *correct_buf = NULL; - COMPOUND_C_DATATYPE *global_buf = NULL; + COMPOUND_C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS]; hsize_t chunk_dims[READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS]; hsize_t sel_dims[READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS]; @@ -4814,40 +4902,36 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id, dset_id, plist_id, memtype; hid_t filespace, memspace; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from shared filtered chunks in Compound Datatype dataset without Datatype conversion"); + if (MAINPROCESS) + HDputs("Testing read from shared filtered chunks in Compound Datatype dataset without Datatype " + "conversion"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS; - dataset_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS; + dataset_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS; + dataset_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) { - correct_buf[i].field1 = (short) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); - - correct_buf[i].field2 = (int) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); - - correct_buf[i].field3 = (long) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); + correct_buf[i].field1 = + (short)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); + + correct_buf[i].field2 = + (int)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); + + correct_buf[i].field3 = + (long)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); } /* Create the compound type for memory. */ @@ -4855,18 +4939,18 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) VRFY((memtype >= 0), "Datatype creation succeeded"); VRFY((H5Tinsert(memtype, "ShortData", HOFFSET(COMPOUND_C_DATATYPE, field1), H5T_NATIVE_SHORT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "IntData", HOFFSET(COMPOUND_C_DATATYPE, field2), H5T_NATIVE_INT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "LongData", HOFFSET(COMPOUND_C_DATATYPE, field3), H5T_NATIVE_LONG) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -4874,31 +4958,33 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - filespace = H5Screate_simple(READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, dataset_dims, NULL); + filespace = H5Screate_simple(READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, + dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS, + chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME, memtype, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME, + memtype, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -4908,22 +4994,22 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); - dset_id = H5Dopen2(file_id, "/" READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME, H5P_DEFAULT); + dset_id = + H5Dopen2(file_id, "/" READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS / (hsize_t) mpi_size; - sel_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; + sel_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS / (hsize_t)mpi_size; + sel_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -4939,66 +5025,70 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = 1; - count[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; - stride[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS; + count[0] = 1; + count[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC; + stride[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS; stride[1] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; - block[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS / (hsize_t) mpi_size; - block[1] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; - start[0] = (hsize_t) mpi_rank; - start[1] = 0; + block[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS / (hsize_t)mpi_size; + block[1] = READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS; + start[0] = (hsize_t)mpi_rank; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); - VRFY((H5Dread(dset_id, memtype, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + VRFY((H5Dread(dset_id, memtype, memspace, filespace, plist_id, read_buf) >= 0), "Dataset read succeeded"); - global_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* Collect each piece of data from all ranks into a global buffer on all ranks */ - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - recvcounts[i] = (int) (flat_dims[0] * sizeof(*read_buf)); + for (i = 0; i < (size_t)mpi_size; i++) + recvcounts[i] = (int)(flat_dims[0] * sizeof(*read_buf)); - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * flat_dims[0] * sizeof(*read_buf)); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * flat_dims[0] * sizeof(*read_buf)); - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) (flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, global_buf, recvcounts, displs, MPI_BYTE, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int)(flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, + global_buf, recvcounts, displs, MPI_BYTE, comm)), + "MPI_Allgatherv succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -5026,9 +5116,9 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) static void test_read_cmpd_filtered_dataset_type_conversion_unshared(void) { - COMPOUND_C_DATATYPE *read_buf = NULL; + COMPOUND_C_DATATYPE *read_buf = NULL; COMPOUND_C_DATATYPE *correct_buf = NULL; - COMPOUND_C_DATATYPE *global_buf = NULL; + COMPOUND_C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS]; hsize_t chunk_dims[READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS]; hsize_t sel_dims[READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS]; @@ -5040,37 +5130,30 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id = -1, dset_id = -1, plist_id = -1, filetype = -1, memtype = -1; hid_t filespace = -1, memspace = -1; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks in Compound Datatype dataset with Datatype conversion"); + if (MAINPROCESS) + HDputs("Testing read from unshared filtered chunks in Compound Datatype dataset with Datatype " + "conversion"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NROWS; - dataset_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS; + dataset_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NROWS; + dataset_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) { - correct_buf[i].field1 = (short) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); - - correct_buf[i].field2 = (int) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); - - correct_buf[i].field3 = (long) ( - (i % dataset_dims[1]) - + (i / dataset_dims[1]) - ); + correct_buf[i].field1 = (short)((i % dataset_dims[1]) + (i / dataset_dims[1])); + + correct_buf[i].field2 = (int)((i % dataset_dims[1]) + (i / dataset_dims[1])); + + correct_buf[i].field3 = (long)((i % dataset_dims[1]) + (i / dataset_dims[1])); } /* Create the compound type for memory. */ @@ -5078,29 +5161,26 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) VRFY((memtype >= 0), "Datatype creation succeeded"); VRFY((H5Tinsert(memtype, "ShortData", HOFFSET(COMPOUND_C_DATATYPE, field1), H5T_NATIVE_SHORT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "IntData", HOFFSET(COMPOUND_C_DATATYPE, field2), H5T_NATIVE_INT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "LongData", HOFFSET(COMPOUND_C_DATATYPE, field3), H5T_NATIVE_LONG) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); /* Create the compound type for file. */ filetype = H5Tcreate(H5T_COMPOUND, 32); VRFY((filetype >= 0), "Datatype creation succeeded"); - VRFY((H5Tinsert(filetype, "ShortData", 0, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); - VRFY((H5Tinsert(filetype, "IntData", 8, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); - VRFY((H5Tinsert(filetype, "LongData", 16, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "ShortData", 0, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "IntData", 8, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "LongData", 16, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -5108,7 +5188,8 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - filespace = H5Screate_simple(READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, dataset_dims, NULL); + filespace = H5Screate_simple(READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, + dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ @@ -5118,21 +5199,22 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS, + chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME, filetype, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME, + filetype, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -5142,22 +5224,22 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); - dset_id = H5Dopen2(file_id, "/" READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME, H5P_DEFAULT); + dset_id = H5Dopen2(file_id, "/" READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME, + H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; - sel_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; + sel_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; + sel_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -5173,66 +5255,70 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = 1; - count[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; + count[0] = 1; + count[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC; stride[0] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; stride[1] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS; - block[0] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; - block[1] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS; - start[0] = 0; - start[1] = ((hsize_t) mpi_rank * READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS); + block[0] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS; + block[1] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS; + start[0] = 0; + start[1] = ((hsize_t)mpi_rank * READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS); if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); - VRFY((H5Dread(dset_id, memtype, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + VRFY((H5Dread(dset_id, memtype, memspace, filespace, plist_id, read_buf) >= 0), "Dataset read succeeded"); - global_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* Collect each piece of data from all ranks into a global buffer on all ranks */ - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - recvcounts[i] = (int) (flat_dims[0] * sizeof(*read_buf)); + for (i = 0; i < (size_t)mpi_size; i++) + recvcounts[i] = (int)(flat_dims[0] * sizeof(*read_buf)); - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * flat_dims[0] * sizeof(*read_buf)); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * flat_dims[0] * sizeof(*read_buf)); - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) (flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, global_buf, recvcounts, displs, MPI_BYTE, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int)(flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, + global_buf, recvcounts, displs, MPI_BYTE, comm)), + "MPI_Allgatherv succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -5261,9 +5347,9 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) static void test_read_cmpd_filtered_dataset_type_conversion_shared(void) { - COMPOUND_C_DATATYPE *read_buf = NULL; + COMPOUND_C_DATATYPE *read_buf = NULL; COMPOUND_C_DATATYPE *correct_buf = NULL; - COMPOUND_C_DATATYPE *global_buf = NULL; + COMPOUND_C_DATATYPE *global_buf = NULL; hsize_t dataset_dims[READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS]; hsize_t chunk_dims[READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS]; hsize_t sel_dims[READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS]; @@ -5275,40 +5361,36 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) size_t i, read_buf_size, correct_buf_size; hid_t file_id, dset_id, plist_id, filetype, memtype; hid_t filespace, memspace; - int *recvcounts = NULL; - int *displs = NULL; + int * recvcounts = NULL; + int * displs = NULL; - if (MAINPROCESS) HDputs("Testing read from shared filtered chunks in Compound Datatype dataset with Datatype conversion"); + if (MAINPROCESS) + HDputs( + "Testing read from shared filtered chunks in Compound Datatype dataset with Datatype conversion"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS; - dataset_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS; + dataset_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS; + dataset_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS; /* Setup the buffer for writing and for comparison */ correct_buf_size = dataset_dims[0] * dataset_dims[1] * sizeof(*correct_buf); - correct_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) { - correct_buf[i].field1 = (short) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); - - correct_buf[i].field2 = (int) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); - - correct_buf[i].field3 = (long) ( - (dataset_dims[1] * (i / ((hsize_t) mpi_size * dataset_dims[1]))) - + (i % dataset_dims[1]) - + (((i % ((hsize_t) mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1]) - ); + correct_buf[i].field1 = + (short)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); + + correct_buf[i].field2 = + (int)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); + + correct_buf[i].field3 = + (long)((dataset_dims[1] * (i / ((hsize_t)mpi_size * dataset_dims[1]))) + (i % dataset_dims[1]) + + (((i % ((hsize_t)mpi_size * dataset_dims[1])) / dataset_dims[1]) % dataset_dims[1])); } /* Create the compound type for memory. */ @@ -5316,29 +5398,26 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) VRFY((memtype >= 0), "Datatype creation succeeded"); VRFY((H5Tinsert(memtype, "ShortData", HOFFSET(COMPOUND_C_DATATYPE, field1), H5T_NATIVE_SHORT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "IntData", HOFFSET(COMPOUND_C_DATATYPE, field2), H5T_NATIVE_INT) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); VRFY((H5Tinsert(memtype, "LongData", HOFFSET(COMPOUND_C_DATATYPE, field3), H5T_NATIVE_LONG) >= 0), - "Datatype insertion succeeded"); + "Datatype insertion succeeded"); /* Create the compound type for file. */ filetype = H5Tcreate(H5T_COMPOUND, 32); VRFY((filetype >= 0), "Datatype creation succeeded"); - VRFY((H5Tinsert(filetype, "ShortData", 0, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); - VRFY((H5Tinsert(filetype, "IntData", 8, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); - VRFY((H5Tinsert(filetype, "LongData", 16, H5T_STD_I64BE) >= 0), - "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "ShortData", 0, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "IntData", 8, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); + VRFY((H5Tinsert(filetype, "LongData", 16, H5T_STD_I64BE) >= 0), "Datatype insertion succeeded"); if (MAINPROCESS) { plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -5346,31 +5425,33 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - filespace = H5Screate_simple(READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, dataset_dims, NULL); + filespace = H5Screate_simple(READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, + dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); /* Create chunked dataset */ - chunk_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS; - chunk_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; + chunk_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS; + chunk_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS, + chunk_dims) >= 0), + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); - dset_id = H5Dcreate2(file_id, READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME, filetype, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME, + filetype, filespace, H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); VRFY((H5Dwrite(dset_id, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, correct_buf) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -5380,22 +5461,22 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); - dset_id = H5Dopen2(file_id, "/" READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME, H5P_DEFAULT); + dset_id = + H5Dopen2(file_id, "/" READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset open succeeded"); - sel_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS / (hsize_t) mpi_size; - sel_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; + sel_dims[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS / (hsize_t)mpi_size; + sel_dims[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; /* Setup one-dimensional memory dataspace for reading the dataset data into a contiguous buffer */ flat_dims[0] = sel_dims[0] * sel_dims[1]; @@ -5411,66 +5492,70 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) * Each process defines the dataset selection in the file and * reads it to the selection in memory */ - count[0] = 1; - count[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; - stride[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS; + count[0] = 1; + count[1] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC; + stride[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS; stride[1] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; - block[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS / (hsize_t) mpi_size; - block[1] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; - start[0] = (hsize_t) mpi_rank; - start[1] = 0; + block[0] = (hsize_t)READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS / (hsize_t)mpi_size; + block[1] = READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS; + start[0] = (hsize_t)mpi_rank; + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset read */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); read_buf_size = flat_dims[0] * sizeof(*read_buf); - read_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, read_buf_size); + read_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, read_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); - VRFY((H5Dread(dset_id, memtype, memspace, filespace, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + VRFY((H5Dread(dset_id, memtype, memspace, filespace, plist_id, read_buf) >= 0), "Dataset read succeeded"); - global_buf = (COMPOUND_C_DATATYPE *) HDcalloc(1, correct_buf_size); + global_buf = (COMPOUND_C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != global_buf), "HDcalloc succeeded"); /* Collect each piece of data from all ranks into a global buffer on all ranks */ - recvcounts = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*recvcounts)); + recvcounts = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*recvcounts)); VRFY((NULL != recvcounts), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - recvcounts[i] = (int) (flat_dims[0] * sizeof(*read_buf)); + for (i = 0; i < (size_t)mpi_size; i++) + recvcounts[i] = (int)(flat_dims[0] * sizeof(*read_buf)); - displs = (int *) HDcalloc(1, (size_t) mpi_size * sizeof(*displs)); + displs = (int *)HDcalloc(1, (size_t)mpi_size * sizeof(*displs)); VRFY((NULL != displs), "HDcalloc succeeded"); - for (i = 0; i < (size_t) mpi_size; i++) - displs[i] = (int) (i * flat_dims[0] * sizeof(*read_buf)); + for (i = 0; i < (size_t)mpi_size; i++) + displs[i] = (int)(i * flat_dims[0] * sizeof(*read_buf)); - VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) (flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, global_buf, recvcounts, displs, MPI_BYTE, comm)), - "MPI_Allgatherv succeeded"); + VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int)(flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, + global_buf, recvcounts, displs, MPI_BYTE, comm)), + "MPI_Allgatherv succeeded"); - VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (displs) HDfree(displs); - if (recvcounts) HDfree(recvcounts); - if (global_buf) HDfree(global_buf); - if (read_buf) HDfree(read_buf); - if (correct_buf) HDfree(correct_buf); + if (displs) + HDfree(displs); + if (recvcounts) + HDfree(recvcounts); + if (global_buf) + HDfree(global_buf); + if (read_buf) + HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -5495,8 +5580,8 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) static void test_write_serial_read_parallel(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_SERIAL_READ_PARALLEL_DATASET_DIMS]; hsize_t chunk_dims[WRITE_SERIAL_READ_PARALLEL_DATASET_DIMS]; @@ -5504,13 +5589,14 @@ test_write_serial_read_parallel(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1; - if (MAINPROCESS) HDputs("Testing write file serially; read file in parallel"); + if (MAINPROCESS) + HDputs("Testing write file serially; read file in parallel"); CHECK_CUR_FILTER_AVAIL(); - dataset_dims[0] = (hsize_t) WRITE_SERIAL_READ_PARALLEL_NROWS; - dataset_dims[1] = (hsize_t) WRITE_SERIAL_READ_PARALLEL_NCOLS; - dataset_dims[2] = (hsize_t) WRITE_SERIAL_READ_PARALLEL_DEPTH; + dataset_dims[0] = (hsize_t)WRITE_SERIAL_READ_PARALLEL_NROWS; + dataset_dims[1] = (hsize_t)WRITE_SERIAL_READ_PARALLEL_NCOLS; + dataset_dims[2] = (hsize_t)WRITE_SERIAL_READ_PARALLEL_DEPTH; /* Write the file on the MAINPROCESS rank */ if (MAINPROCESS) { @@ -5519,7 +5605,7 @@ test_write_serial_read_parallel(void) VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -5527,8 +5613,8 @@ test_write_serial_read_parallel(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - chunk_dims[0] = (hsize_t) WRITE_SERIAL_READ_PARALLEL_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_SERIAL_READ_PARALLEL_CH_NCOLS; + chunk_dims[0] = (hsize_t)WRITE_SERIAL_READ_PARALLEL_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_SERIAL_READ_PARALLEL_CH_NCOLS; chunk_dims[2] = 1; filespace = H5Screate_simple(WRITE_SERIAL_READ_PARALLEL_DATASET_DIMS, dataset_dims, NULL); @@ -5539,13 +5625,13 @@ test_write_serial_read_parallel(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_SERIAL_READ_PARALLEL_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, WRITE_SERIAL_READ_PARALLEL_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -5553,16 +5639,17 @@ test_write_serial_read_parallel(void) data_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*data); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -5570,24 +5657,23 @@ test_write_serial_read_parallel(void) correct_buf_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (long) i; + correct_buf[i] = (long)i; /* All ranks open the file and verify their "portion" of the dataset is correct */ plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -5600,17 +5686,17 @@ test_write_serial_read_parallel(void) plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); - if (correct_buf) HDfree(correct_buf); - if (read_buf) HDfree(read_buf); + if (correct_buf) + HDfree(correct_buf); + if (read_buf) + HDfree(read_buf); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DXPL close succeeded"); @@ -5633,8 +5719,8 @@ test_write_serial_read_parallel(void) static void test_write_parallel_read_serial(void) { - C_DATATYPE *data = NULL; - C_DATATYPE *read_buf = NULL; + C_DATATYPE *data = NULL; + C_DATATYPE *read_buf = NULL; C_DATATYPE *correct_buf = NULL; hsize_t dataset_dims[WRITE_PARALLEL_READ_SERIAL_DATASET_DIMS]; hsize_t chunk_dims[WRITE_PARALLEL_READ_SERIAL_DATASET_DIMS]; @@ -5647,7 +5733,8 @@ test_write_parallel_read_serial(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) HDputs("Testing write file in parallel; read serially"); + if (MAINPROCESS) + HDputs("Testing write file in parallel; read serially"); CHECK_CUR_FILTER_AVAIL(); @@ -5655,11 +5742,10 @@ test_write_parallel_read_serial(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -5667,15 +5753,15 @@ test_write_parallel_read_serial(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_NROWS; - dataset_dims[1] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_NCOLS; - dataset_dims[2] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_DEPTH; - chunk_dims[0] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NROWS; - chunk_dims[1] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NCOLS; - chunk_dims[2] = 1; - sel_dims[0] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NROWS; - sel_dims[1] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_NCOLS; - sel_dims[2] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_DEPTH; + dataset_dims[0] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_NROWS; + dataset_dims[1] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_NCOLS; + dataset_dims[2] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_DEPTH; + chunk_dims[0] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NROWS; + chunk_dims[1] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NCOLS; + chunk_dims[2] = 1; + sel_dims[0] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NROWS; + sel_dims[1] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_NCOLS; + sel_dims[2] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_DEPTH; filespace = H5Screate_simple(WRITE_PARALLEL_READ_SERIAL_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); @@ -5688,13 +5774,13 @@ test_write_parallel_read_serial(void) VRFY((plist_id >= 0), "DCPL creation succeeded"); VRFY((H5Pset_chunk(plist_id, WRITE_PARALLEL_READ_SERIAL_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, WRITE_PARALLEL_READ_SERIAL_DATASET_NAME, HDF5_DATATYPE_NAME, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -5703,22 +5789,24 @@ test_write_parallel_read_serial(void) /* Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = 1; - count[1] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_NCOLS / (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NCOLS; - count[2] = (hsize_t) mpi_size; - stride[0] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NROWS; - stride[1] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NCOLS; + count[0] = 1; + count[1] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_NCOLS / (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NCOLS; + count[2] = (hsize_t)mpi_size; + stride[0] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NROWS; + stride[1] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NCOLS; stride[2] = 1; - block[0] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NROWS; - block[1] = (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NCOLS; - block[2] = 1; - offset[0] = ((hsize_t) mpi_rank * (hsize_t) WRITE_PARALLEL_READ_SERIAL_CH_NROWS * count[0]); + block[0] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NROWS; + block[1] = (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NCOLS; + block[2] = 1; + offset[0] = ((hsize_t)mpi_rank * (hsize_t)WRITE_PARALLEL_READ_SERIAL_CH_NROWS * count[0]); offset[1] = 0; offset[2] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], offset[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", - mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], offset[0], offset[1], offset[2], block[0], block[1], block[2]); + HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], offset[ " + "%llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", + mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], offset[0], + offset[1], offset[2], block[0], block[1], block[2]); HDfflush(stdout); } @@ -5726,29 +5814,29 @@ test_write_parallel_read_serial(void) filespace = H5Dget_space(dset_id); VRFY((filespace >= 0), "File dataspace retrieval succeeded"); - VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, stride, - count, block) >= 0), "Hyperslab selection succeeded"); + VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, stride, count, block) >= 0), + "Hyperslab selection succeeded"); /* Fill data buffer */ data_size = sel_dims[0] * sel_dims[1] * sel_dims[2] * sizeof(*data); - data = (C_DATATYPE *) HDcalloc(1, data_size); + data = (C_DATATYPE *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); for (i = 0; i < data_size / sizeof(*data); i++) - data[i] = (C_DATATYPE) GEN_DATA(i); + data[i] = (C_DATATYPE)GEN_DATA(i); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); VRFY((H5Dwrite(dset_id, HDF5_DATATYPE_NAME, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Pclose(plist_id) >= 0), "DXPL close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -5761,7 +5849,7 @@ test_write_parallel_read_serial(void) VRFY((plist_id >= 0), "FAPL creation succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -5773,23 +5861,20 @@ test_write_parallel_read_serial(void) correct_buf_size = dataset_dims[0] * dataset_dims[1] * dataset_dims[2] * sizeof(*correct_buf); - correct_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + correct_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != correct_buf), "HDcalloc succeeded"); - read_buf = (C_DATATYPE *) HDcalloc(1, correct_buf_size); + read_buf = (C_DATATYPE *)HDcalloc(1, correct_buf_size); VRFY((NULL != read_buf), "HDcalloc succeeded"); for (i = 0; i < correct_buf_size / sizeof(*correct_buf); i++) - correct_buf[i] = (C_DATATYPE) ( - (i % (dataset_dims[0] * dataset_dims[1])) - + (i / (dataset_dims[0] * dataset_dims[1])) - ); + correct_buf[i] = (C_DATATYPE)((i % (dataset_dims[0] * dataset_dims[1])) + + (i / (dataset_dims[0] * dataset_dims[1]))); VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) >= 0), - "Dataset read succeeded"); + "Dataset read succeeded"); - VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), - "Data verification succeeded"); + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); @@ -5813,19 +5898,20 @@ test_write_parallel_read_serial(void) static void test_shrinking_growing_chunks(void) { - double *data = NULL; - hsize_t dataset_dims[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; - hsize_t chunk_dims[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; - hsize_t sel_dims[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; - hsize_t start[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; - hsize_t stride[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; - hsize_t count[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; - hsize_t block[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; - size_t i, data_size; - hid_t file_id = -1, dset_id = -1, plist_id = -1; - hid_t filespace = -1, memspace = -1; - - if (MAINPROCESS) HDputs("Testing continually shrinking/growing chunks"); + double *data = NULL; + hsize_t dataset_dims[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; + hsize_t chunk_dims[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; + hsize_t sel_dims[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; + hsize_t start[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; + hsize_t stride[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; + hsize_t count[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; + hsize_t block[SHRINKING_GROWING_CHUNKS_DATASET_DIMS]; + size_t i, data_size; + hid_t file_id = -1, dset_id = -1, plist_id = -1; + hid_t filespace = -1, memspace = -1; + + if (MAINPROCESS) + HDputs("Testing continually shrinking/growing chunks"); CHECK_CUR_FILTER_AVAIL(); @@ -5833,11 +5919,10 @@ test_shrinking_growing_chunks(void) plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); - VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), - "Set FAPL MPIO succeeded"); + VRFY((H5Pset_fapl_mpio(plist_id, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(plist_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fopen(filenames[0], H5F_ACC_RDWR, plist_id); VRFY((file_id >= 0), "Test file open succeeded"); @@ -5845,12 +5930,12 @@ test_shrinking_growing_chunks(void) VRFY((H5Pclose(plist_id) >= 0), "FAPL close succeeded"); /* Create the dataspace for the dataset */ - dataset_dims[0] = (hsize_t) SHRINKING_GROWING_CHUNKS_NROWS; - dataset_dims[1] = (hsize_t) SHRINKING_GROWING_CHUNKS_NCOLS; - chunk_dims[0] = (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NROWS; - chunk_dims[1] = (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NCOLS; - sel_dims[0] = (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NROWS; - sel_dims[1] = (hsize_t) SHRINKING_GROWING_CHUNKS_NCOLS; + dataset_dims[0] = (hsize_t)SHRINKING_GROWING_CHUNKS_NROWS; + dataset_dims[1] = (hsize_t)SHRINKING_GROWING_CHUNKS_NCOLS; + chunk_dims[0] = (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NROWS; + chunk_dims[1] = (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NCOLS; + sel_dims[0] = (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NROWS; + sel_dims[1] = (hsize_t)SHRINKING_GROWING_CHUNKS_NCOLS; filespace = H5Screate_simple(SHRINKING_GROWING_CHUNKS_DATASET_DIMS, dataset_dims, NULL); VRFY((filespace >= 0), "File dataspace creation succeeded"); @@ -5862,14 +5947,13 @@ test_shrinking_growing_chunks(void) plist_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((plist_id >= 0), "DCPL creation succeeded"); - VRFY((H5Pset_chunk(plist_id, SHRINKING_GROWING_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), - "Chunk size set"); + VRFY((H5Pset_chunk(plist_id, SHRINKING_GROWING_CHUNKS_DATASET_DIMS, chunk_dims) >= 0), "Chunk size set"); /* Add test filter to the pipeline */ VRFY((set_dcpl_filter(plist_id) >= 0), "Filter set"); dset_id = H5Dcreate2(file_id, SHRINKING_GROWING_CHUNKS_DATASET_NAME, H5T_NATIVE_DOUBLE, filespace, - H5P_DEFAULT, plist_id, H5P_DEFAULT); + H5P_DEFAULT, plist_id, H5P_DEFAULT); VRFY((dset_id >= 0), "Dataset creation succeeded"); VRFY((H5Pclose(plist_id) >= 0), "DCPL close succeeded"); @@ -5879,18 +5963,19 @@ test_shrinking_growing_chunks(void) * Each process defines the dataset selection in memory and writes * it to the hyperslab in the file */ - count[0] = 1; - count[1] = (hsize_t) SHRINKING_GROWING_CHUNKS_NCOLS / (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NCOLS; - stride[0] = (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NROWS; - stride[1] = (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NCOLS; - block[0] = (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NROWS; - block[1] = (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NCOLS; - start[0] = ((hsize_t) mpi_rank * (hsize_t) SHRINKING_GROWING_CHUNKS_CH_NROWS * count[0]); - start[1] = 0; + count[0] = 1; + count[1] = (hsize_t)SHRINKING_GROWING_CHUNKS_NCOLS / (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NCOLS; + stride[0] = (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NROWS; + stride[1] = (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NCOLS; + block[0] = (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NROWS; + block[1] = (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NCOLS; + start[0] = ((hsize_t)mpi_rank * (hsize_t)SHRINKING_GROWING_CHUNKS_CH_NROWS * count[0]); + start[1] = 0; if (VERBOSE_MED) { - HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", - mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], " + "block size[ %llu, %llu ]\n", + mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); HDfflush(stdout); } @@ -5899,18 +5984,17 @@ test_shrinking_growing_chunks(void) VRFY((dset_id >= 0), "File dataspace retrieval succeeded"); VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), - "Hyperslab selection succeeded"); + "Hyperslab selection succeeded"); /* Create property list for collective dataset write */ plist_id = H5Pcreate(H5P_DATASET_XFER); VRFY((plist_id >= 0), "DXPL creation succeeded"); - VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), - "Set DXPL MPIO succeeded"); + VRFY((H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE) >= 0), "Set DXPL MPIO succeeded"); data_size = sel_dims[0] * sel_dims[1] * sizeof(double); - data = (double *) HDcalloc(1, data_size); + data = (double *)HDcalloc(1, data_size); VRFY((NULL != data), "HDcalloc succeeded"); for (i = 0; i < SHRINKING_GROWING_CHUNKS_NLOOPS; i++) { @@ -5920,15 +6004,16 @@ test_shrinking_growing_chunks(void) else { size_t j; for (j = 0; j < data_size / sizeof(*data); j++) { - data[j] = (float) ( rand() / (double) (RAND_MAX / (double) 1.0L) ); + data[j] = (float)(rand() / (double)(RAND_MAX / (double)1.0L)); } } VRFY((H5Dwrite(dset_id, H5T_NATIVE_DOUBLE, memspace, filespace, plist_id, data) >= 0), - "Dataset write succeeded"); + "Dataset write succeeded"); } - if (data) HDfree(data); + if (data) + HDfree(data); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); VRFY((H5Sclose(filespace) >= 0), "File dataspace close succeeded"); @@ -5941,7 +6026,7 @@ test_shrinking_growing_chunks(void) #endif int -main(int argc, char** argv) +main(int argc, char **argv) { size_t i; hid_t file_id = -1, fapl = -1; @@ -5975,7 +6060,8 @@ main(int argc, char** argv) HDprintf("==========================\n\n"); } - if (VERBOSE_MED) h5_show_hostname(); + if (VERBOSE_MED) + h5_show_hostname(); ALARM_ON; @@ -5986,10 +6072,10 @@ main(int argc, char** argv) VRFY((H5Pset_fapl_mpio(fapl, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); VRFY((h5_fixname(FILENAME[0], fapl, filenames[0], sizeof(filenames[0])) != NULL), - "Test file name created"); + "Test file name created"); file_id = H5Fcreate(filenames[0], H5F_ACC_TRUNC, H5P_DEFAULT, fapl); VRFY((file_id >= 0), "Test file creation succeeded"); @@ -6001,7 +6087,8 @@ main(int argc, char** argv) (*tests[i])(); } else { - if (MAINPROCESS) MESG("MPI_Barrier failed"); + if (MAINPROCESS) + MESG("MPI_Barrier failed"); nerrors++; } } @@ -6020,7 +6107,7 @@ main(int argc, char** argv) VRFY((H5Pset_fapl_mpio(fapl, comm, info) >= 0), "Set FAPL MPIO succeeded"); VRFY((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) >= 0), - "Set libver bounds succeeded"); + "Set libver bounds succeeded"); file_id = H5Fcreate(filenames[0], H5F_ACC_TRUNC, H5P_DEFAULT, fapl); VRFY((file_id >= 0), "Test file creation succeeded"); @@ -6038,20 +6125,22 @@ main(int argc, char** argv) (*tests[i])(); } else { - if (MAINPROCESS) MESG("MPI_Barrier failed"); + if (MAINPROCESS) + MESG("MPI_Barrier failed"); nerrors++; } } - if (nerrors) goto exit; + if (nerrors) + goto exit; - if (MAINPROCESS) HDputs("All Parallel Filters tests passed\n"); + if (MAINPROCESS) + HDputs("All Parallel Filters tests passed\n"); exit: if (nerrors) if (MAINPROCESS) - HDprintf("*** %d TEST ERROR%s OCCURRED ***\n", nerrors, - nerrors > 1 ? "S" : ""); + HDprintf("*** %d TEST ERROR%s OCCURRED ***\n", nerrors, nerrors > 1 ? "S" : ""); ALARM_OFF; diff --git a/testpar/t_filters_parallel.h b/testpar/t_filters_parallel.h index 9543508..3804c09 100644 --- a/testpar/t_filters_parallel.h +++ b/testpar/t_filters_parallel.h @@ -32,10 +32,10 @@ /* Used to load other filters than GZIP */ /* #define DYNAMIC_FILTER */ /* Uncomment and define the fields below to use a dynamically loaded filter */ -#define FILTER_NUM_CDVALUES 1 -const unsigned int cd_values[FILTER_NUM_CDVALUES] = { 0 }; +#define FILTER_NUM_CDVALUES 1 +const unsigned int cd_values[FILTER_NUM_CDVALUES] = {0}; H5Z_filter_t filter_id; -unsigned int flags = 0; +unsigned int flags = 0; size_t cd_nelmts = FILTER_NUM_CDVALUES; /* Utility Macros */ @@ -49,13 +49,15 @@ size_t cd_nelmts = FILTER_NUM_CDVALUES; #define HDF5_DATATYPE_NAME H5T_NATIVE_LONG /* Macro used to generate data for datasets for later verification */ -#define GEN_DATA(i) INCREMENTAL_DATA(i) +#define GEN_DATA(i) INCREMENTAL_DATA(i) /* For experimental purposes only, will cause tests to fail data verification phase - JTH */ -/* #define GEN_DATA(i) RANK_DATA(i) */ /* Given an index value i, generates test data based upon selected mode */ +/* #define GEN_DATA(i) RANK_DATA(i) */ /* Given an index value i, generates test data based upon + selected mode */ -#define INCREMENTAL_DATA(i) ((size_t) mpi_rank + i) /* Generates incremental test data */ -#define RANK_DATA(i) (mpi_rank) /* Generates test data to visibly show which rank wrote to which parts of the dataset */ +#define INCREMENTAL_DATA(i) ((size_t)mpi_rank + i) /* Generates incremental test data */ +#define RANK_DATA(i) \ + (mpi_rank) /* Generates test data to visibly show which rank wrote to which parts of the dataset */ #define DEFAULT_DEFLATE_LEVEL 6 @@ -64,18 +66,20 @@ size_t cd_nelmts = FILTER_NUM_CDVALUES; /* Struct type for the compound datatype filtered dataset tests */ typedef struct { - short field1; - int field2; - long field3; + short field1; + int field2; + long field3; } COMPOUND_C_DATATYPE; /* Defines for the one-chunk filtered dataset write test */ -#define WRITE_ONE_CHUNK_FILTERED_DATASET_NAME "one_chunk_filtered_dataset_write" -#define WRITE_ONE_CHUNK_FILTERED_DATASET_DIMS 2 -#define WRITE_ONE_CHUNK_FILTERED_DATASET_NROWS (mpi_size * DIM0_SCALE_FACTOR) /* Must be an even multiple of the number of ranks to avoid issues */ -#define WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS (mpi_size * DIM1_SCALE_FACTOR) /* Must be an even multiple of the number of ranks to avoid issues */ -#define WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS WRITE_ONE_CHUNK_FILTERED_DATASET_NROWS -#define WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS +#define WRITE_ONE_CHUNK_FILTERED_DATASET_NAME "one_chunk_filtered_dataset_write" +#define WRITE_ONE_CHUNK_FILTERED_DATASET_DIMS 2 +#define WRITE_ONE_CHUNK_FILTERED_DATASET_NROWS \ + (mpi_size * DIM0_SCALE_FACTOR) /* Must be an even multiple of the number of ranks to avoid issues */ +#define WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS \ + (mpi_size * DIM1_SCALE_FACTOR) /* Must be an even multiple of the number of ranks to avoid issues */ +#define WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NROWS WRITE_ONE_CHUNK_FILTERED_DATASET_NROWS +#define WRITE_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS WRITE_ONE_CHUNK_FILTERED_DATASET_NCOLS /* Defines for the unshared filtered chunks write test */ #define WRITE_UNSHARED_FILTERED_CHUNKS_DATASET_NAME "unshared_filtered_chunks_write" @@ -94,55 +98,69 @@ typedef struct { #define WRITE_SHARED_FILTERED_CHUNKS_NCOLS (WRITE_SHARED_FILTERED_CHUNKS_CH_NCOLS * DIM1_SCALE_FACTOR) /* Defines for the filtered chunks write test where a process has no selection */ -#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME "single_no_selection_filtered_chunks_write" -#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 -#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) -#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) -#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS (WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) -#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS (WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) +#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME "single_no_selection_filtered_chunks_write" +#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 +#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) +#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) +#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS \ + (WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) +#define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS \ + (WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) #define WRITE_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC (mpi_size - 1) /* Defines for the filtered chunks write test where no process has a selection */ -#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME "all_no_selection_filtered_chunks_write" -#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 -#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) -#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) -#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS (WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) -#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS (WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) +#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME "all_no_selection_filtered_chunks_write" +#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 +#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) +#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) +#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS \ + (WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) +#define WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS \ + (WRITE_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) /* Defines for the filtered chunks write test with a point selection */ #define WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_NAME "point_selection_filtered_chunks_write" #define WRITE_POINT_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 #define WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) #define WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) -#define WRITE_POINT_SELECTION_FILTERED_CHUNKS_NROWS (WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) -#define WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS (WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) +#define WRITE_POINT_SELECTION_FILTERED_CHUNKS_NROWS \ + (WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) +#define WRITE_POINT_SELECTION_FILTERED_CHUNKS_NCOLS \ + (WRITE_POINT_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) /* Defines for the filtered dataset interleaved write test */ -#define INTERLEAVED_WRITE_FILTERED_DATASET_NAME "filtered_dataset_interleaved_write" -#define INTERLEAVED_WRITE_FILTERED_DATASET_DIMS 2 -#define INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS (mpi_size) -#define INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS (DIM1_SCALE_FACTOR) -#define INTERLEAVED_WRITE_FILTERED_DATASET_NROWS (INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS * DIM0_SCALE_FACTOR) -#define INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS (INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS * DIM1_SCALE_FACTOR) +#define INTERLEAVED_WRITE_FILTERED_DATASET_NAME "filtered_dataset_interleaved_write" +#define INTERLEAVED_WRITE_FILTERED_DATASET_DIMS 2 +#define INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS (mpi_size) +#define INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS (DIM1_SCALE_FACTOR) +#define INTERLEAVED_WRITE_FILTERED_DATASET_NROWS \ + (INTERLEAVED_WRITE_FILTERED_DATASET_CH_NROWS * DIM0_SCALE_FACTOR) +#define INTERLEAVED_WRITE_FILTERED_DATASET_NCOLS \ + (INTERLEAVED_WRITE_FILTERED_DATASET_CH_NCOLS * DIM1_SCALE_FACTOR) /* Defines for the 3D unshared filtered dataset separate page write test */ -#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME "3D_unshared_filtered_chunks_separate_pages_write" +#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME \ + "3D_unshared_filtered_chunks_separate_pages_write" #define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS 3 #define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS (mpi_size * DIM0_SCALE_FACTOR) #define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS (mpi_size * DIM1_SCALE_FACTOR) #define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DEPTH (mpi_size) -#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS (WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS / mpi_size) -#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS (WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS / mpi_size) +#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS \ + (WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS / mpi_size) +#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS \ + (WRITE_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS / mpi_size) /* Defines for the 3D unshared filtered dataset same page write test */ -#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME "3D_unshared_filtered_chunks_same_pages_write" +#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME \ + "3D_unshared_filtered_chunks_same_pages_write" #define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_DIMS 3 #define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS (mpi_size * DIM0_SCALE_FACTOR) #define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS (mpi_size * DIM1_SCALE_FACTOR) #define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH (mpi_size) -#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS (WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS / mpi_size) -#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS (WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS / mpi_size) +#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS \ + (WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS / mpi_size) +#define WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS \ + (WRITE_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS / mpi_size) /* Defines for the 3d shared filtered dataset write test */ #define WRITE_SHARED_FILTERED_CHUNKS_3D_DATASET_NAME "3D_shared_filtered_chunks_write" @@ -154,48 +172,58 @@ typedef struct { #define WRITE_SHARED_FILTERED_CHUNKS_3D_DEPTH (mpi_size) /* Defines for the compound datatype filtered dataset no conversion write test with unshared chunks */ -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME "compound_unshared_filtered_chunks_no_conversion_write" -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS 2 -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NROWS 1 -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS mpi_size -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS 1 -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS 1 -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC (WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS / mpi_size) +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME \ + "compound_unshared_filtered_chunks_no_conversion_write" +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS 2 +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NROWS 1 +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS mpi_size +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS 1 +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS 1 +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC \ + (WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS / mpi_size) /* Defines for the compound datatype filtered dataset no conversion write test with shared chunks */ -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME "compound_shared_filtered_chunks_no_conversion_write" -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS 2 -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS mpi_size -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS mpi_size -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS mpi_size -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS 1 -#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME \ + "compound_shared_filtered_chunks_no_conversion_write" +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS 2 +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS mpi_size +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS mpi_size +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS mpi_size +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS 1 +#define WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC \ + WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS /* Defines for the compound datatype filtered dataset type conversion write test with unshared chunks */ -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME "compound_unshared_filtered_chunks_type_conversion_write" -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS 2 -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NROWS 1 -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS mpi_size -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS 1 -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS 1 -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC (WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS / mpi_size) +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME \ + "compound_unshared_filtered_chunks_type_conversion_write" +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS 2 +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NROWS 1 +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS mpi_size +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS 1 +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS 1 +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC \ + (WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS / mpi_size) /* Defines for the compound datatype filtered dataset type conversion write test with shared chunks */ -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME "compound_shared_filtered_chunks_type_conversion_write" -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS 2 -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS mpi_size -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS mpi_size -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS mpi_size -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS 1 -#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME \ + "compound_shared_filtered_chunks_type_conversion_write" +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS 2 +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS mpi_size +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS mpi_size +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS mpi_size +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS 1 +#define WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC \ + WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS /* Defines for the one-chunk filtered dataset read test */ -#define READ_ONE_CHUNK_FILTERED_DATASET_NAME "one_chunk_filtered_dataset_read" -#define READ_ONE_CHUNK_FILTERED_DATASET_DIMS 2 -#define READ_ONE_CHUNK_FILTERED_DATASET_NROWS (mpi_size * DIM0_SCALE_FACTOR) /* Must be an even multiple of the number of ranks to avoid issues */ -#define READ_ONE_CHUNK_FILTERED_DATASET_NCOLS (mpi_size * DIM1_SCALE_FACTOR) /* Must be an even multiple of the number of ranks to avoid issues */ -#define READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS READ_ONE_CHUNK_FILTERED_DATASET_NROWS -#define READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS READ_ONE_CHUNK_FILTERED_DATASET_NCOLS +#define READ_ONE_CHUNK_FILTERED_DATASET_NAME "one_chunk_filtered_dataset_read" +#define READ_ONE_CHUNK_FILTERED_DATASET_DIMS 2 +#define READ_ONE_CHUNK_FILTERED_DATASET_NROWS \ + (mpi_size * DIM0_SCALE_FACTOR) /* Must be an even multiple of the number of ranks to avoid issues */ +#define READ_ONE_CHUNK_FILTERED_DATASET_NCOLS \ + (mpi_size * DIM1_SCALE_FACTOR) /* Must be an even multiple of the number of ranks to avoid issues */ +#define READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS READ_ONE_CHUNK_FILTERED_DATASET_NROWS +#define READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS READ_ONE_CHUNK_FILTERED_DATASET_NCOLS /* Defines for the unshared filtered chunks read test */ #define READ_UNSHARED_FILTERED_CHUNKS_DATASET_NAME "unshared_filtered_chunks_read" @@ -214,21 +242,25 @@ typedef struct { #define READ_SHARED_FILTERED_CHUNKS_NCOLS (READ_SHARED_FILTERED_CHUNKS_CH_NCOLS * DIM1_SCALE_FACTOR) /* Defines for the filtered chunks read test where a process has no selection */ -#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME "single_no_selection_filtered_chunks_read" -#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 -#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) -#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) -#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS (READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) -#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS (READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) +#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME "single_no_selection_filtered_chunks_read" +#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 +#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) +#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) +#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS \ + (READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) +#define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS \ + (READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) #define READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC (mpi_size - 1) /* Defines for the filtered chunks read test where no process has a selection */ -#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME "all_no_selection_filtered_chunks_read" -#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 -#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) -#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) -#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS (READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) -#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS (READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) +#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_NAME "all_no_selection_filtered_chunks_read" +#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_DATASET_DIMS 2 +#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS (DIM0_SCALE_FACTOR) +#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS (DIM1_SCALE_FACTOR) +#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS \ + (READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NROWS * mpi_size) +#define READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS \ + (READ_ALL_NO_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) /* Defines for the filtered chunks read test with a point selection */ #define READ_POINT_SELECTION_FILTERED_CHUNKS_DATASET_NAME "point_selection_filtered_chunks_read" @@ -239,21 +271,26 @@ typedef struct { #define READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS (READ_POINT_SELECTION_FILTERED_CHUNKS_CH_NCOLS * mpi_size) /* Defines for the filtered dataset interleaved read test */ -#define INTERLEAVED_READ_FILTERED_DATASET_NAME "filtered_dataset_interleaved_read" -#define INTERLEAVED_READ_FILTERED_DATASET_DIMS 2 -#define INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS (mpi_size) -#define INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS (DIM1_SCALE_FACTOR) -#define INTERLEAVED_READ_FILTERED_DATASET_NROWS (INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS * DIM0_SCALE_FACTOR) -#define INTERLEAVED_READ_FILTERED_DATASET_NCOLS (INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS * DIM1_SCALE_FACTOR) +#define INTERLEAVED_READ_FILTERED_DATASET_NAME "filtered_dataset_interleaved_read" +#define INTERLEAVED_READ_FILTERED_DATASET_DIMS 2 +#define INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS (mpi_size) +#define INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS (DIM1_SCALE_FACTOR) +#define INTERLEAVED_READ_FILTERED_DATASET_NROWS \ + (INTERLEAVED_READ_FILTERED_DATASET_CH_NROWS * DIM0_SCALE_FACTOR) +#define INTERLEAVED_READ_FILTERED_DATASET_NCOLS \ + (INTERLEAVED_READ_FILTERED_DATASET_CH_NCOLS * DIM1_SCALE_FACTOR) /* Defines for the 3D unshared filtered dataset separate page read test */ -#define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME "3D_unshared_filtered_chunks_separate_pages_read" +#define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_NAME \ + "3D_unshared_filtered_chunks_separate_pages_read" #define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DATASET_DIMS 3 #define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS (mpi_size * DIM0_SCALE_FACTOR) #define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS (mpi_size * DIM1_SCALE_FACTOR) #define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DEPTH (mpi_size) -#define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS (READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS / mpi_size) -#define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS (READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS / mpi_size) +#define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NROWS \ + (READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS / mpi_size) +#define READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_CH_NCOLS \ + (READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS / mpi_size) /* Defines for the 3D unshared filtered dataset same page read test */ #define READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DATASET_NAME "3D_unshared_filtered_chunks_same_pages_read" @@ -261,8 +298,10 @@ typedef struct { #define READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS (mpi_size * DIM0_SCALE_FACTOR) #define READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS (mpi_size * DIM1_SCALE_FACTOR) #define READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH (mpi_size) -#define READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS (READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS / mpi_size) -#define READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS (READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS / mpi_size) +#define READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NROWS \ + (READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS / mpi_size) +#define READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_CH_NCOLS \ + (READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS / mpi_size) /* Defines for the 3d shared filtered dataset read test */ #define READ_SHARED_FILTERED_CHUNKS_3D_DATASET_NAME "3D_shared_filtered_chunks_read" @@ -274,40 +313,48 @@ typedef struct { #define READ_SHARED_FILTERED_CHUNKS_3D_DEPTH (mpi_size) /* Defines for the compound datatype filtered dataset no conversion read test with unshared chunks */ -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME "compound_unshared_filtered_chunks_no_conversion_read" -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS 2 -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NROWS 1 -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS mpi_size -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS 1 -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS 1 -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC (READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS / mpi_size) +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_NAME \ + "compound_unshared_filtered_chunks_no_conversion_read" +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_DATASET_DIMS 2 +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NROWS 1 +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS mpi_size +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NROWS 1 +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS 1 +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_ENTRIES_PER_PROC \ + (READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS / mpi_size) /* Defines for the compound datatype filtered dataset no conversion read test with shared chunks */ -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME "compound_shared_filtered_chunks_no_conversion_read" -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS 2 -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS mpi_size -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS mpi_size -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS mpi_size -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS 1 -#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_NAME \ + "compound_shared_filtered_chunks_no_conversion_read" +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_DATASET_DIMS 2 +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS mpi_size +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS mpi_size +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NROWS mpi_size +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_CH_NCOLS 1 +#define READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_ENTRIES_PER_PROC \ + READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS /* Defines for the compound datatype filtered dataset type conversion read test with unshared chunks */ -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME "compound_unshared_filtered_chunks_type_conversion_read" -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS 2 -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NROWS 1 -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS mpi_size -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS 1 -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS 1 -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC (READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS / mpi_size) +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_NAME \ + "compound_unshared_filtered_chunks_type_conversion_read" +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_DATASET_DIMS 2 +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NROWS 1 +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS mpi_size +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NROWS 1 +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS 1 +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_ENTRIES_PER_PROC \ + (READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS / mpi_size) /* Defines for the compound datatype filtered dataset type conversion read test with shared chunks */ -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME "compound_shared_filtered_chunks_type_conversion_read" -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS 2 -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS mpi_size -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS mpi_size -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS mpi_size -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS 1 -#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_NAME \ + "compound_shared_filtered_chunks_type_conversion_read" +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_DATASET_DIMS 2 +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS mpi_size +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS mpi_size +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NROWS mpi_size +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_CH_NCOLS 1 +#define READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_ENTRIES_PER_PROC \ + READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS /* Defines for the write file serially/read in parallel test */ #define WRITE_SERIAL_READ_PARALLEL_DATASET_NAME "write_serial_read_parallel" diff --git a/testpar/t_init_term.c b/testpar/t_init_term.c index 0e40fe4..e2157ba 100644 --- a/testpar/t_init_term.c +++ b/testpar/t_init_term.c @@ -21,26 +21,23 @@ #include "testphdf5.h" -int nerrors = 0; /* errors count */ +int nerrors = 0; /* errors count */ -const char *FILENAME[] = { - "after_mpi_fin", - NULL -}; +const char *FILENAME[] = {"after_mpi_fin", NULL}; int -main (int argc, char **argv) +main(int argc, char **argv) { - int mpi_size, mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; + int mpi_size, mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; /* Initialize and finalize MPI */ MPI_Init(&argc, &argv); MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - if(MAINPROCESS) - TESTING("Usage of Serial HDF5 after MPI_Finalize() is called"); + if (MAINPROCESS) + TESTING("Usage of Serial HDF5 after MPI_Finalize() is called"); MPI_Finalize(); @@ -50,9 +47,9 @@ main (int argc, char **argv) and create a file serially */ H5open(); - if(mpi_rank == 0) { - char filename[1024]; - hid_t file_id; + if (mpi_rank == 0) { + char filename[1024]; + hid_t file_id; h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -63,12 +60,12 @@ main (int argc, char **argv) H5close(); - if(MAINPROCESS) { - if(0 == nerrors) + if (MAINPROCESS) { + if (0 == nerrors) PASSED(); else - H5_FAILED() + H5_FAILED() } - return (nerrors!=0); + return (nerrors != 0); } diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c index db0d059..a4bc26d 100644 --- a/testpar/t_mdset.c +++ b/testpar/t_mdset.c @@ -15,13 +15,12 @@ #include "H5Dprivate.h" #include "H5private.h" -#define DIM 2 -#define SIZE 32 -#define NDATASET 4 +#define DIM 2 +#define SIZE 32 +#define NDATASET 4 #define GROUP_DEPTH 128 enum obj_type { is_group, is_dset }; - static int get_size(void); static void write_dataset(hid_t, hid_t, hid_t); static int read_dataset(hid_t, hid_t, hid_t); @@ -33,7 +32,6 @@ static int read_attribute(hid_t, int, int); static int check_value(DATATYPE *, DATATYPE *, int); static void get_slab(hsize_t[], hsize_t[], hsize_t[], hsize_t[], int); - /* * The size value computed by this function is used extensively in * configuring tests for the current number of processes. @@ -54,10 +52,11 @@ get_size(void) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* needed for VRFY */ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); - if(mpi_size > size ) { - if((mpi_size % 2) == 0 ) { + if (mpi_size > size) { + if ((mpi_size % 2) == 0) { size = mpi_size; - } else { + } + else { size = mpi_size + 1; } } @@ -65,7 +64,7 @@ get_size(void) VRFY((mpi_size <= size), "mpi_size <= size"); VRFY(((size % 2) == 0), "size isn't even"); - return(size); + return (size); } /* get_size() */ @@ -73,14 +72,15 @@ get_size(void) * Example of using PHDF5 to create a zero sized dataset. * */ -void zero_dim_dset(void) +void +zero_dim_dset(void) { - int mpi_size, mpi_rank; - const char *filename; - hid_t fid, plist, dcpl, dsid, sid; - hsize_t dim, chunk_dim; - herr_t ret; - int data[1]; + int mpi_size, mpi_rank; + const char *filename; + hid_t fid, plist, dcpl, dsid, sid; + hsize_t dim, chunk_dim; + herr_t ret; + int data[1]; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); @@ -88,37 +88,37 @@ void zero_dim_dset(void) filename = GetTestParameters(); plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - VRFY((plist>=0), "create_faccess_plist succeeded"); + VRFY((plist >= 0), "create_faccess_plist succeeded"); fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); - VRFY((fid>=0), "H5Fcreate succeeded"); + VRFY((fid >= 0), "H5Fcreate succeeded"); ret = H5Pclose(plist); - VRFY((ret>=0), "H5Pclose succeeded"); + VRFY((ret >= 0), "H5Pclose succeeded"); dcpl = H5Pcreate(H5P_DATASET_CREATE); - VRFY((dcpl>=0), "failed H5Pcreate"); + VRFY((dcpl >= 0), "failed H5Pcreate"); /* Set 1 chunk size */ chunk_dim = 1; - ret = H5Pset_chunk(dcpl, 1, &chunk_dim); - VRFY((ret>=0), "failed H5Pset_chunk"); + ret = H5Pset_chunk(dcpl, 1, &chunk_dim); + VRFY((ret >= 0), "failed H5Pset_chunk"); /* Create 1D dataspace with 0 dim size */ dim = 0; sid = H5Screate_simple(1, &dim, NULL); - VRFY((sid>=0), "failed H5Screate_simple"); + VRFY((sid >= 0), "failed H5Screate_simple"); /* Create chunked dataset */ dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - VRFY((dsid>=0), "failed H5Dcreate2"); + VRFY((dsid >= 0), "failed H5Dcreate2"); /* write 0 elements from dataset */ ret = H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data); - VRFY((ret>=0), "failed H5Dwrite"); + VRFY((ret >= 0), "failed H5Dwrite"); /* Read 0 elements from dataset */ ret = H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data); - VRFY((ret>=0), "failed H5Dread"); + VRFY((ret >= 0), "failed H5Dread"); H5Pclose(dcpl); H5Dclose(dsid); @@ -136,24 +136,25 @@ void zero_dim_dset(void) * * JRM - 8/11/04 */ -void multiple_dset_write(void) +void +multiple_dset_write(void) { - int i, j, n, mpi_size, mpi_rank, size; - hid_t iof, plist, dataset, memspace, filespace; - hid_t dcpl; /* Dataset creation property list */ - hsize_t chunk_origin [DIM]; - hsize_t chunk_dims [DIM], file_dims [DIM]; - hsize_t count[DIM]={1,1}; - double *outme = NULL; - double fill=1.0; /* Fill value */ - char dname [100]; - herr_t ret; - const H5Ptest_param_t *pt; - char *filename; - int ndatasets; - - pt = GetTestParameters(); - filename = pt->name; + int i, j, n, mpi_size, mpi_rank, size; + hid_t iof, plist, dataset, memspace, filespace; + hid_t dcpl; /* Dataset creation property list */ + hsize_t chunk_origin[DIM]; + hsize_t chunk_dims[DIM], file_dims[DIM]; + hsize_t count[DIM] = {1, 1}; + double * outme = NULL; + double fill = 1.0; /* Fill value */ + char dname[100]; + herr_t ret; + const H5Ptest_param_t *pt; + char * filename; + int ndatasets; + + pt = GetTestParameters(); + filename = pt->name; ndatasets = pt->count; size = get_size(); @@ -166,45 +167,45 @@ void multiple_dset_write(void) VRFY((outme != NULL), "HDmalloc succeeded for outme"); plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - VRFY((plist>=0), "create_faccess_plist succeeded"); + VRFY((plist >= 0), "create_faccess_plist succeeded"); iof = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); - VRFY((iof>=0), "H5Fcreate succeeded"); + VRFY((iof >= 0), "H5Fcreate succeeded"); ret = H5Pclose(plist); - VRFY((ret>=0), "H5Pclose succeeded"); + VRFY((ret >= 0), "H5Pclose succeeded"); /* decide the hyperslab according to process number. */ get_slab(chunk_origin, chunk_dims, count, file_dims, size); - memspace = H5Screate_simple(DIM, chunk_dims, NULL); + memspace = H5Screate_simple(DIM, chunk_dims, NULL); filespace = H5Screate_simple(DIM, file_dims, NULL); - ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims); - VRFY((ret>=0), "mdata hyperslab selection"); + ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims); + VRFY((ret >= 0), "mdata hyperslab selection"); /* Create a dataset creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); - VRFY((dcpl>=0), "dataset creation property list succeeded"); + VRFY((dcpl >= 0), "dataset creation property list succeeded"); ret = H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill); - VRFY((ret>=0), "set fill-value succeeded"); + VRFY((ret >= 0), "set fill-value succeeded"); - for(n = 0; n < ndatasets; n++) { - HDsprintf(dname, "dataset %d", n); - dataset = H5Dcreate2(iof, dname, H5T_NATIVE_DOUBLE, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT); - VRFY((dataset > 0), dname); + for (n = 0; n < ndatasets; n++) { + HDsprintf(dname, "dataset %d", n); + dataset = H5Dcreate2(iof, dname, H5T_NATIVE_DOUBLE, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + VRFY((dataset > 0), dname); - /* calculate data to write */ - for(i = 0; i < size; i++) - for(j = 0; j < size; j++) - outme [(i * size) + j] = n*1000 + mpi_rank; + /* calculate data to write */ + for (i = 0; i < size; i++) + for (j = 0; j < size; j++) + outme[(i * size) + j] = n * 1000 + mpi_rank; - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, memspace, filespace, H5P_DEFAULT, outme); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, memspace, filespace, H5P_DEFAULT, outme); - H5Dclose(dataset); + H5Dclose(dataset); #ifdef BARRIER_CHECKS - if(!((n+1) % 10)) { - HDprintf("created %d datasets\n", n+1); - MPI_Barrier(MPI_COMM_WORLD); - } + if (!((n + 1) % 10)) { + HDprintf("created %d datasets\n", n + 1); + MPI_Barrier(MPI_COMM_WORLD); + } #endif /* BARRIER_CHECKS */ } @@ -216,7 +217,6 @@ void multiple_dset_write(void) HDfree(outme); } - /* Example of using PHDF5 to create, write, and read compact dataset. * * Changes: Updated function to use a dynamically calculated size, @@ -225,15 +225,16 @@ void multiple_dset_write(void) * * JRM - 8/11/04 */ -void compact_dataset(void) +void +compact_dataset(void) { - int i, j, mpi_size, mpi_rank, size, err_num=0; - hid_t iof, plist, dcpl, dxpl, dataset, filespace; - hsize_t file_dims [DIM]; - double *outme; - double *inme; - char dname[]="dataset"; - herr_t ret; + int i, j, mpi_size, mpi_rank, size, err_num = 0; + hid_t iof, plist, dcpl, dxpl, dataset, filespace; + hsize_t file_dims[DIM]; + double * outme; + double * inme; + char dname[] = "dataset"; + herr_t ret; const char *filename; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY hbool_t prop_value; @@ -241,7 +242,7 @@ void compact_dataset(void) size = get_size(); - for(i = 0; i < DIM; i++ ) + for (i = 0; i < DIM; i++) file_dims[i] = (hsize_t)size; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -257,14 +258,14 @@ void compact_dataset(void) VRFY((mpi_size <= size), "mpi_size <= size"); plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - iof = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); + iof = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); /* Define data space */ filespace = H5Screate_simple(DIM, file_dims, NULL); /* Create a compact dataset */ dcpl = H5Pcreate(H5P_DATASET_CREATE); - VRFY((dcpl>=0), "dataset creation property list succeeded"); + VRFY((dcpl >= 0), "dataset creation property list succeeded"); ret = H5Pset_layout(dcpl, H5D_COMPACT); VRFY((dcpl >= 0), "set property list for compact dataset"); ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); @@ -278,16 +279,15 @@ void compact_dataset(void) VRFY((dxpl >= 0), ""); ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { ret = H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* Recalculate data to write. Each process writes the same data. */ - for(i = 0; i < size; i++) - for(j = 0; j < size; j++) - outme[(i * size) + j] =(i + j) * 1000; + for (i = 0; i < size; i++) + for (j = 0; j < size; j++) + outme[(i * size) + j] = (i + j) * 1000; ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, dxpl, outme); VRFY((ret >= 0), "H5Dwrite succeeded"); @@ -300,7 +300,7 @@ void compact_dataset(void) /* Open the file and dataset, read and compare the data. */ plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - iof = H5Fopen(filename, H5F_ACC_RDONLY, plist); + iof = H5Fopen(filename, H5F_ACC_RDONLY, plist); VRFY((iof >= 0), "H5Fopen succeeded"); /* set up the collective transfer properties list */ @@ -308,9 +308,9 @@ void compact_dataset(void) VRFY((dxpl >= 0), ""); ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(dxpl,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } dataset = H5Dopen2(iof, dname, H5P_DEFAULT); @@ -318,8 +318,8 @@ void compact_dataset(void) #ifdef H5_HAVE_INSTRUMENTED_LIBRARY prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; - ret = H5Pinsert2(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, H5D_XFER_COLL_RANK0_BCAST_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); + ret = H5Pinsert2(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, H5D_XFER_COLL_RANK0_BCAST_SIZE, &prop_value, NULL, + NULL, NULL, NULL, NULL, NULL); VRFY((ret >= 0), "H5Pinsert2() succeeded"); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ @@ -328,17 +328,19 @@ void compact_dataset(void) #ifdef H5_HAVE_INSTRUMENTED_LIBRARY prop_value = FALSE; - ret = H5Pget(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value); + ret = H5Pget(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value); VRFY((ret >= 0), "H5Pget succeeded"); - VRFY((prop_value == FALSE && dxfer_coll_type == DXFER_COLLECTIVE_IO),"rank 0 Bcast optimization was performed for a compact dataset"); + VRFY((prop_value == FALSE && dxfer_coll_type == DXFER_COLLECTIVE_IO), + "rank 0 Bcast optimization was performed for a compact dataset"); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /* Verify data value */ - for(i = 0; i < size; i++) - for(j = 0; j < size; j++) - if(!H5_DBL_ABS_EQUAL(inme[(i * size) + j], outme[(i * size) + j])) - if(err_num++ < MAX_ERR_REPORT || VERBOSE_MED) - HDprintf("Dataset Verify failed at [%d][%d]: expect %f, got %f\n", i, j, outme[(i * size) + j], inme[(i * size) + j]); + for (i = 0; i < size; i++) + for (j = 0; j < size; j++) + if (!H5_DBL_ABS_EQUAL(inme[(i * size) + j], outme[(i * size) + j])) + if (err_num++ < MAX_ERR_REPORT || VERBOSE_MED) + HDprintf("Dataset Verify failed at [%d][%d]: expect %f, got %f\n", i, j, + outme[(i * size) + j], inme[(i * size) + j]); H5Pclose(plist); H5Pclose(dxpl); @@ -360,16 +362,17 @@ void compact_dataset(void) * * JRM - 8/24/04 */ -void null_dataset(void) +void +null_dataset(void) { - int mpi_size, mpi_rank; - hid_t iof, plist, dxpl, dataset, attr, sid; - unsigned uval=2; /* Buffer for writing to dataset */ - int val=1; /* Buffer for writing to attribute */ - hssize_t nelem; - char dname[]="dataset"; - char attr_name[]="attribute"; - herr_t ret; + int mpi_size, mpi_rank; + hid_t iof, plist, dxpl, dataset, attr, sid; + unsigned uval = 2; /* Buffer for writing to dataset */ + int val = 1; /* Buffer for writing to attribute */ + hssize_t nelem; + char dname[] = "dataset"; + char attr_name[] = "attribute"; + herr_t ret; const char *filename; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -378,7 +381,7 @@ void null_dataset(void) filename = GetTestParameters(); plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - iof = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); + iof = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); /* Define data space */ sid = H5Screate(H5S_NULL); @@ -396,12 +399,11 @@ void null_dataset(void) VRFY((dxpl >= 0), ""); ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { ret = H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* Write "nothing" to the dataset(with type conversion) */ ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, &uval); VRFY((ret >= 0), "H5Dwrite succeeded"); @@ -422,7 +424,7 @@ void null_dataset(void) /* Open the file and dataset, read and compare the data. */ plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - iof = H5Fopen(filename, H5F_ACC_RDONLY, plist); + iof = H5Fopen(filename, H5F_ACC_RDONLY, plist); VRFY((iof >= 0), "H5Fopen succeeded"); /* set up the collective transfer properties list */ @@ -430,27 +432,27 @@ void null_dataset(void) VRFY((dxpl >= 0), ""); ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pcreate xfer succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(dxpl,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - dataset = H5Dopen2(iof, dname, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dopen2 succeeded"); /* Try reading from the dataset(make certain our buffer is unmodified) */ ret = H5Dread(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, dxpl, &uval); - VRFY((ret>=0), "H5Dread"); - VRFY((uval==2), "H5Dread"); + VRFY((ret >= 0), "H5Dread"); + VRFY((uval == 2), "H5Dread"); /* Open the attribute for the dataset */ attr = H5Aopen(dataset, attr_name, H5P_DEFAULT); VRFY((attr >= 0), "H5Aopen"); - /* Try reading from the attribute(make certain our buffer is unmodified) */ ret = H5Aread(attr, H5T_NATIVE_INT, &val); - VRFY((ret>=0), "H5Aread"); - VRFY((val==1), "H5Aread"); + /* Try reading from the attribute(make certain our buffer is unmodified) */ ret = + H5Aread(attr, H5T_NATIVE_INT, &val); + VRFY((ret >= 0), "H5Aread"); + VRFY((val == 1), "H5Aread"); H5Pclose(plist); H5Pclose(dxpl); @@ -472,17 +474,18 @@ void null_dataset(void) * * JRM - 8/11/04 */ -void big_dataset(void) +void +big_dataset(void) { - int mpi_size, mpi_rank; /* MPI info */ - hid_t iof, /* File ID */ - fapl, /* File access property list ID */ - dataset, /* Dataset ID */ - filespace; /* Dataset's dataspace ID */ - hsize_t file_dims [4]; /* Dimensions of dataspace */ - char dname[]="dataset"; /* Name of dataset */ - MPI_Offset file_size; /* Size of file on disk */ - herr_t ret; /* Generic return value */ + int mpi_size, mpi_rank; /* MPI info */ + hid_t iof, /* File ID */ + fapl, /* File access property list ID */ + dataset, /* Dataset ID */ + filespace; /* Dataset's dataspace ID */ + hsize_t file_dims[4]; /* Dimensions of dataspace */ + char dname[] = "dataset"; /* Name of dataset */ + MPI_Offset file_size; /* Size of file on disk */ + herr_t ret; /* Generic return value */ const char *filename; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -503,11 +506,11 @@ void big_dataset(void) VRFY((iof >= 0), "H5Fcreate succeeded"); /* Define dataspace for 2GB dataspace */ - file_dims[0]= 2; - file_dims[1]= 1024; - file_dims[2]= 1024; - file_dims[3]= 1024; - filespace = H5Screate_simple(4, file_dims, NULL); + file_dims[0] = 2; + file_dims[1] = 1024; + file_dims[2] = 1024; + file_dims[3] = 1024; + filespace = H5Screate_simple(4, file_dims, NULL); VRFY((filespace >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(iof, dname, H5T_NATIVE_UCHAR, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -532,11 +535,11 @@ void big_dataset(void) VRFY((iof >= 0), "H5Fcreate succeeded"); /* Define dataspace for 4GB dataspace */ - file_dims[0]= 4; - file_dims[1]= 1024; - file_dims[2]= 1024; - file_dims[3]= 1024; - filespace = H5Screate_simple(4, file_dims, NULL); + file_dims[0] = 4; + file_dims[1] = 1024; + file_dims[2] = 1024; + file_dims[3] = 1024; + filespace = H5Screate_simple(4, file_dims, NULL); VRFY((filespace >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(iof, dname, H5T_NATIVE_UCHAR, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -561,11 +564,11 @@ void big_dataset(void) VRFY((iof >= 0), "H5Fcreate succeeded"); /* Define dataspace for 8GB dataspace */ - file_dims[0]= 8; - file_dims[1]= 1024; - file_dims[2]= 1024; - file_dims[3]= 1024; - filespace = H5Screate_simple(4, file_dims, NULL); + file_dims[0] = 8; + file_dims[1] = 1024; + file_dims[2] = 1024; + file_dims[3] = 1024; + filespace = H5Screate_simple(4, file_dims, NULL); VRFY((filespace >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(iof, dname, H5T_NATIVE_UCHAR, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -602,25 +605,26 @@ void big_dataset(void) * * JRM - 8/11/04 */ -void dataset_fillvalue(void) +void +dataset_fillvalue(void) { - int mpi_size, mpi_rank; /* MPI info */ - int err_num; /* Number of errors */ - hid_t iof, /* File ID */ - fapl, /* File access property list ID */ - dxpl, /* Data transfer property list ID */ - dataset, /* Dataset ID */ - memspace, /* Memory dataspace ID */ - filespace; /* Dataset's dataspace ID */ - char dname[]="dataset"; /* Name of dataset */ + int mpi_size, mpi_rank; /* MPI info */ + int err_num; /* Number of errors */ + hid_t iof, /* File ID */ + fapl, /* File access property list ID */ + dxpl, /* Data transfer property list ID */ + dataset, /* Dataset ID */ + memspace, /* Memory dataspace ID */ + filespace; /* Dataset's dataspace ID */ + char dname[] = "dataset"; /* Name of dataset */ hsize_t dset_dims[4] = {0, 6, 7, 8}; hsize_t req_start[4] = {0, 0, 0, 0}; hsize_t req_count[4] = {1, 6, 7, 8}; - hsize_t dset_size; /* Dataset size */ - int *rdata, *wdata; /* Buffers for data to read and write */ - int *twdata, *trdata; /* Temporary pointer into buffer */ - int acc, i, ii, j, k, l; /* Local index variables */ - herr_t ret; /* Generic return value */ + hsize_t dset_size; /* Dataset size */ + int * rdata, *wdata; /* Buffers for data to read and write */ + int * twdata, *trdata; /* Temporary pointer into buffer */ + int acc, i, ii, j, k, l; /* Local index variables */ + herr_t ret; /* Generic return value */ const char *filename; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY hbool_t prop_value; @@ -633,13 +637,13 @@ void dataset_fillvalue(void) /* Set the dataset dimension to be one row more than number of processes */ /* and calculate the actual dataset size. */ - dset_dims[0]=(hsize_t)(mpi_size+1); - dset_size=dset_dims[0]*dset_dims[1]*dset_dims[2]*dset_dims[3]; + dset_dims[0] = (hsize_t)(mpi_size + 1); + dset_size = dset_dims[0] * dset_dims[1] * dset_dims[2] * dset_dims[3]; /* Allocate space for the buffers */ - rdata=HDmalloc((size_t)(dset_size*sizeof(int))); + rdata = HDmalloc((size_t)(dset_size * sizeof(int))); VRFY((rdata != NULL), "HDcalloc succeeded for read buffer"); - wdata=HDmalloc((size_t)(dset_size*sizeof(int))); + wdata = HDmalloc((size_t)(dset_size * sizeof(int))); VRFY((wdata != NULL), "HDmalloc succeeded for write buffer"); fapl = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); @@ -669,53 +673,54 @@ void dataset_fillvalue(void) VRFY((dxpl >= 0), "H5Pcreate succeeded"); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; - ret = H5Pinsert2(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, H5D_XFER_COLL_RANK0_BCAST_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL); - VRFY((ret >= 0),"testing property list inserted succeeded"); + prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; + ret = H5Pinsert2(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, H5D_XFER_COLL_RANK0_BCAST_SIZE, &prop_value, NULL, + NULL, NULL, NULL, NULL, NULL); + VRFY((ret >= 0), "testing property list inserted succeeded"); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - for(ii = 0; ii < 2; ii++) { + for (ii = 0; ii < 2; ii++) { - if(ii == 0) - ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_INDEPENDENT); - else - ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); - VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); + if (ii == 0) + ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_INDEPENDENT); + else + ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); + VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - /* set entire read buffer with the constant 2 */ - HDmemset(rdata,2,(size_t)(dset_size*sizeof(int))); + /* set entire read buffer with the constant 2 */ + HDmemset(rdata, 2, (size_t)(dset_size * sizeof(int))); - /* Read the entire dataset back */ - ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, rdata); - VRFY((ret >= 0), "H5Dread succeeded"); + /* Read the entire dataset back */ + ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, rdata); + VRFY((ret >= 0), "H5Dread succeeded"); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - prop_value = FALSE; - ret = H5Pget(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value); - VRFY((ret >= 0), "testing property list get succeeded"); - if(ii == 0) - VRFY((prop_value == FALSE), "correctly handled rank 0 Bcast"); - else - VRFY((prop_value == TRUE), "correctly handled rank 0 Bcast"); + prop_value = FALSE; + ret = H5Pget(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value); + VRFY((ret >= 0), "testing property list get succeeded"); + if (ii == 0) + VRFY((prop_value == FALSE), "correctly handled rank 0 Bcast"); + else + VRFY((prop_value == TRUE), "correctly handled rank 0 Bcast"); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - /* Verify all data read are the fill value 0 */ - trdata = rdata; - err_num = 0; - for(i = 0; i < (int)dset_dims[0]; i++) - for(j = 0; j < (int)dset_dims[1]; j++) - for(k = 0; k < (int)dset_dims[2]; k++) - for(l = 0; l < (int)dset_dims[3]; l++, twdata++, trdata++) - if(*trdata != 0) - if(err_num++ < MAX_ERR_REPORT || VERBOSE_MED) - HDprintf("Dataset Verify failed at [%d][%d][%d][%d]: expect 0, got %d\n", i, j, k, l, *trdata); - if(err_num > MAX_ERR_REPORT && !VERBOSE_MED) - HDprintf("[more errors ...]\n"); - if(err_num) { - HDprintf("%d errors found in check_value\n", err_num); - nerrors++; - } + /* Verify all data read are the fill value 0 */ + trdata = rdata; + err_num = 0; + for (i = 0; i < (int)dset_dims[0]; i++) + for (j = 0; j < (int)dset_dims[1]; j++) + for (k = 0; k < (int)dset_dims[2]; k++) + for (l = 0; l < (int)dset_dims[3]; l++, twdata++, trdata++) + if (*trdata != 0) + if (err_num++ < MAX_ERR_REPORT || VERBOSE_MED) + HDprintf("Dataset Verify failed at [%d][%d][%d][%d]: expect 0, got %d\n", i, + j, k, l, *trdata); + if (err_num > MAX_ERR_REPORT && !VERBOSE_MED) + HDprintf("[more errors ...]\n"); + if (err_num) { + HDprintf("%d errors found in check_value\n", err_num); + nerrors++; + } } /* Barrier to ensure all processes have completed the above test. */ @@ -725,26 +730,25 @@ void dataset_fillvalue(void) * Each process writes 1 row of data. Thus last row is not written. */ /* Create hyperslabs in memory and file dataspaces */ - req_start[0]=(hsize_t)mpi_rank; - ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, req_start, NULL, req_count, NULL); + req_start[0] = (hsize_t)mpi_rank; + ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, req_start, NULL, req_count, NULL); VRFY((ret >= 0), "H5Sselect_hyperslab succeeded on memory dataspace"); ret = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, req_start, NULL, req_count, NULL); VRFY((ret >= 0), "H5Sselect_hyperslab succeeded on memory dataspace"); ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(dxpl,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); } - /* Fill write buffer with some values */ - twdata=wdata; - for(i=0, acc=0; i<(int)dset_dims[0]; i++) - for(j=0; j<(int)dset_dims[1]; j++) - for(k=0; k<(int)dset_dims[2]; k++) - for(l=0; l<(int)dset_dims[3]; l++) + twdata = wdata; + for (i = 0, acc = 0; i < (int)dset_dims[0]; i++) + for (j = 0; j < (int)dset_dims[1]; j++) + for (k = 0; k < (int)dset_dims[2]; k++) + for (l = 0; l < (int)dset_dims[3]; l++) *twdata++ = acc++; /* Collectively write a hyperslab of data to the dataset */ @@ -759,60 +763,62 @@ void dataset_fillvalue(void) */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; - ret = H5Pset(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value); - VRFY((ret >= 0), " H5Pset succeeded"); + prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; + ret = H5Pset(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value); + VRFY((ret >= 0), " H5Pset succeeded"); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - for(ii = 0; ii < 2; ii++) { + for (ii = 0; ii < 2; ii++) { - if(ii == 0) - ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_INDEPENDENT); - else - ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); - VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); + if (ii == 0) + ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_INDEPENDENT); + else + ret = H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE); + VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - /* set entire read buffer with the constant 2 */ - HDmemset(rdata,2,(size_t)(dset_size*sizeof(int))); + /* set entire read buffer with the constant 2 */ + HDmemset(rdata, 2, (size_t)(dset_size * sizeof(int))); - /* Read the entire dataset back */ - ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, rdata); - VRFY((ret >= 0), "H5Dread succeeded"); + /* Read the entire dataset back */ + ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, rdata); + VRFY((ret >= 0), "H5Dread succeeded"); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - prop_value = FALSE; - ret = H5Pget(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value); - VRFY((ret >= 0), "testing property list get succeeded"); - if(ii == 0) - VRFY((prop_value == FALSE), "correctly handled rank 0 Bcast"); - else - VRFY((prop_value == TRUE), "correctly handled rank 0 Bcast"); + prop_value = FALSE; + ret = H5Pget(dxpl, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value); + VRFY((ret >= 0), "testing property list get succeeded"); + if (ii == 0) + VRFY((prop_value == FALSE), "correctly handled rank 0 Bcast"); + else + VRFY((prop_value == TRUE), "correctly handled rank 0 Bcast"); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - /* Verify correct data read */ - twdata=wdata; - trdata=rdata; - err_num=0; - for(i=0; i<(int)dset_dims[0]; i++) - for(j=0; j<(int)dset_dims[1]; j++) - for(k=0; k<(int)dset_dims[2]; k++) - for(l=0; l<(int)dset_dims[3]; l++, twdata++, trdata++) - if(i MAX_ERR_REPORT && !VERBOSE_MED) - HDprintf("[more errors ...]\n"); - if(err_num){ - HDprintf("%d errors found in check_value\n", err_num); - nerrors++; - } + /* Verify correct data read */ + twdata = wdata; + trdata = rdata; + err_num = 0; + for (i = 0; i < (int)dset_dims[0]; i++) + for (j = 0; j < (int)dset_dims[1]; j++) + for (k = 0; k < (int)dset_dims[2]; k++) + for (l = 0; l < (int)dset_dims[3]; l++, twdata++, trdata++) + if (i < mpi_size) { + if (*twdata != *trdata) + if (err_num++ < MAX_ERR_REPORT || VERBOSE_MED) + HDprintf("Dataset Verify failed at [%d][%d][%d][%d]: expect %d, got %d\n", + i, j, k, l, *twdata, *trdata); + } /* end if */ + else { + if (*trdata != 0) + if (err_num++ < MAX_ERR_REPORT || VERBOSE_MED) + HDprintf("Dataset Verify failed at [%d][%d][%d][%d]: expect 0, got %d\n", + i, j, k, l, *trdata); + } /* end else */ + if (err_num > MAX_ERR_REPORT && !VERBOSE_MED) + HDprintf("[more errors ...]\n"); + if (err_num) { + HDprintf("%d errors found in check_value\n", err_num); + nerrors++; + } } /* Close all file objects */ @@ -841,7 +847,8 @@ void dataset_fillvalue(void) } /* combined cngrpw and ingrpr tests because ingrpr reads file created by cngrpw. */ -void collective_group_write_independent_group_read(void) +void +collective_group_write_independent_group_read(void) { collective_group_write(); independent_group_read(); @@ -856,38 +863,39 @@ void collective_group_write_independent_group_read(void) * * JRM - 8/16/04 */ -void collective_group_write(void) +void +collective_group_write(void) { - int mpi_rank, mpi_size, size; - int i, j, m; - char gname[64], dname[32]; - hid_t fid, gid, did, plist, dcpl, memspace, filespace; - DATATYPE *outme = NULL; - hsize_t chunk_origin[DIM]; - hsize_t chunk_dims[DIM], file_dims[DIM], count[DIM]; - hsize_t chunk_size[2]; /* Chunk dimensions - computed shortly */ - herr_t ret1, ret2; + int mpi_rank, mpi_size, size; + int i, j, m; + char gname[64], dname[32]; + hid_t fid, gid, did, plist, dcpl, memspace, filespace; + DATATYPE * outme = NULL; + hsize_t chunk_origin[DIM]; + hsize_t chunk_dims[DIM], file_dims[DIM], count[DIM]; + hsize_t chunk_size[2]; /* Chunk dimensions - computed shortly */ + herr_t ret1, ret2; const H5Ptest_param_t *pt; - char *filename; - int ngroups; + char * filename; + int ngroups; - pt = GetTestParameters(); + pt = GetTestParameters(); filename = pt->name; - ngroups = pt->count; + ngroups = pt->count; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); size = get_size(); - chunk_size[0] =(hsize_t)(size / 2); - chunk_size[1] =(hsize_t)(size / 2); + chunk_size[0] = (hsize_t)(size / 2); + chunk_size[1] = (hsize_t)(size / 2); outme = HDmalloc((size_t)size * (size_t)size * sizeof(DATATYPE)); VRFY((outme != NULL), "HDmalloc succeeded for outme"); plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); H5Pclose(plist); /* decide the hyperslab according to process number. */ @@ -896,24 +904,22 @@ void collective_group_write(void) /* select hyperslab in memory and file spaces. These two operations are * identical since the datasets are the same. */ memspace = H5Screate_simple(DIM, file_dims, NULL); - ret1 = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, chunk_origin, - chunk_dims, count, chunk_dims); - filespace = H5Screate_simple(DIM, file_dims, NULL); - ret2 = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin, - chunk_dims, count, chunk_dims); - VRFY((memspace>=0), "memspace"); - VRFY((filespace>=0), "filespace"); - VRFY((ret1>=0), "mgroup memspace selection"); - VRFY((ret2>=0), "mgroup filespace selection"); + ret1 = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims); + filespace = H5Screate_simple(DIM, file_dims, NULL); + ret2 = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims); + VRFY((memspace >= 0), "memspace"); + VRFY((filespace >= 0), "filespace"); + VRFY((ret1 >= 0), "mgroup memspace selection"); + VRFY((ret2 >= 0), "mgroup filespace selection"); dcpl = H5Pcreate(H5P_DATASET_CREATE); ret1 = H5Pset_chunk(dcpl, 2, chunk_size); - VRFY((dcpl>=0), "dataset creation property"); - VRFY((ret1>=0), "set chunk for dataset creation property"); + VRFY((dcpl >= 0), "dataset creation property"); + VRFY((ret1 >= 0), "set chunk for dataset creation property"); /* creates ngroups groups under the root group, writes chunked * datasets in parallel. */ - for(m = 0; m < ngroups; m++) { + for (m = 0; m < ngroups; m++) { HDsprintf(gname, "group%d", m); gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((gid > 0), gname); @@ -922,9 +928,9 @@ void collective_group_write(void) did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT); VRFY((did > 0), dname); - for(i = 0; i < size; i++) - for(j = 0; j < size; j++) - outme[(i * size) + j] =(i + j) * 1000 + mpi_rank; + for (i = 0; i < size; i++) + for (j = 0; j < size; j++) + outme[(i * size) + j] = (i + j) * 1000 + mpi_rank; H5Dwrite(did, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, outme); @@ -932,8 +938,8 @@ void collective_group_write(void) H5Gclose(gid); #ifdef BARRIER_CHECKS - if(!((m+1) % 10)) { - HDprintf("created %d groups\n", m+1); + if (!((m + 1) % 10)) { + HDprintf("created %d groups\n", m + 1); MPI_Barrier(MPI_COMM_WORLD); } #endif /* BARRIER_CHECKS */ @@ -950,17 +956,18 @@ void collective_group_write(void) /* Let two sets of processes open and read different groups and chunked * datasets independently. */ -void independent_group_read(void) +void +independent_group_read(void) { - int mpi_rank, m; - hid_t plist, fid; + int mpi_rank, m; + hid_t plist, fid; const H5Ptest_param_t *pt; - char *filename; - int ngroups; + char * filename; + int ngroups; - pt = GetTestParameters(); + pt = GetTestParameters(); filename = pt->name; - ngroups = pt->count; + ngroups = pt->count; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -973,11 +980,12 @@ void independent_group_read(void) /* open groups and read datasets. Odd number processes read even number * groups from the end; even number processes read odd number groups * from the beginning. */ - if(mpi_rank%2==0) { - for(m=ngroups-1; m==0; m-=2) + if (mpi_rank % 2 == 0) { + for (m = ngroups - 1; m == 0; m -= 2) group_dataset_read(fid, mpi_rank, m); - } else { - for(m=0; m0), dname); + VRFY((did > 0), dname); H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, indata); /* this is the original value */ - for(i=0; iname; - ngroups = pt->count; + ngroups = pt->count; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); @@ -1097,7 +1106,7 @@ void multiple_group_write(void) size = get_size(); plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist); H5Pclose(plist); /* decide the hyperslab according to process number. */ @@ -1105,38 +1114,36 @@ void multiple_group_write(void) /* select hyperslab in memory and file spaces. These two operations are * identical since the datasets are the same. */ - memspace = H5Screate_simple(DIM, file_dims, NULL); - VRFY((memspace>=0), "memspace"); - ret = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, chunk_origin, - chunk_dims, count, chunk_dims); - VRFY((ret>=0), "mgroup memspace selection"); + memspace = H5Screate_simple(DIM, file_dims, NULL); + VRFY((memspace >= 0), "memspace"); + ret = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims); + VRFY((ret >= 0), "mgroup memspace selection"); - filespace = H5Screate_simple(DIM, file_dims, NULL); - VRFY((filespace>=0), "filespace"); - ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin, - chunk_dims, count, chunk_dims); - VRFY((ret>=0), "mgroup filespace selection"); + filespace = H5Screate_simple(DIM, file_dims, NULL); + VRFY((filespace >= 0), "filespace"); + ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims); + VRFY((ret >= 0), "mgroup filespace selection"); /* creates ngroups groups under the root group, writes datasets in * parallel. */ - for(m = 0; m < ngroups; m++) { + for (m = 0; m < ngroups; m++) { HDsprintf(gname, "group%d", m); gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((gid > 0), gname); /* create attribute for these groups. */ - write_attribute(gid, is_group, m); + write_attribute(gid, is_group, m); - if(m != 0) - write_dataset(memspace, filespace, gid); + if (m != 0) + write_dataset(memspace, filespace, gid); H5Gclose(gid); #ifdef BARRIER_CHECKS - if(!((m+1) % 10)) { - HDprintf("created %d groups\n", m+1); + if (!((m + 1) % 10)) { + HDprintf("created %d groups\n", m + 1); MPI_Barrier(MPI_COMM_WORLD); - } + } #endif /* BARRIER_CHECKS */ } @@ -1144,14 +1151,14 @@ void multiple_group_write(void) gid = H5Gopen2(fid, "group0", H5P_DEFAULT); create_group_recursive(memspace, filespace, gid, 0); ret = H5Gclose(gid); - VRFY((ret>=0), "H5Gclose"); + VRFY((ret >= 0), "H5Gclose"); ret = H5Sclose(filespace); - VRFY((ret>=0), "H5Sclose"); + VRFY((ret >= 0), "H5Sclose"); ret = H5Sclose(memspace); - VRFY((ret>=0), "H5Sclose"); + VRFY((ret >= 0), "H5Sclose"); ret = H5Fclose(fid); - VRFY((ret>=0), "H5Fclose"); + VRFY((ret >= 0), "H5Fclose"); } /* @@ -1181,21 +1188,21 @@ write_dataset(hid_t memspace, hid_t filespace, hid_t gid) outme = HDmalloc((size_t)size * (size_t)size * sizeof(double)); VRFY((outme != NULL), "HDmalloc succeeded for outme"); - for(n = 0; n < NDATASET; n++) { - HDsprintf(dname, "dataset%d", n); - did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VRFY((did > 0), dname); + for (n = 0; n < NDATASET; n++) { + HDsprintf(dname, "dataset%d", n); + did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VRFY((did > 0), dname); - for(i = 0; i < size; i++) - for(j = 0; j < size; j++) + for (i = 0; i < size; i++) + for (j = 0; j < size; j++) outme[(i * size) + j] = n * 1000 + mpi_rank; - H5Dwrite(did, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, outme); + H5Dwrite(did, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, outme); - /* create attribute for these datasets.*/ - write_attribute(did, is_dset, n); + /* create attribute for these datasets.*/ + write_attribute(did, is_dset, n); - H5Dclose(did); + H5Dclose(did); } HDfree(outme); } @@ -1207,30 +1214,30 @@ write_dataset(hid_t memspace, hid_t filespace, hid_t gid) static void create_group_recursive(hid_t memspace, hid_t filespace, hid_t gid, int counter) { - hid_t child_gid; - int mpi_rank; - char gname[64]; + hid_t child_gid; + int mpi_rank; + char gname[64]; - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); #ifdef BARRIER_CHECKS - if(!((counter+1) % 10)) { - HDprintf("created %dth child groups\n", counter+1); + if (!((counter + 1) % 10)) { + HDprintf("created %dth child groups\n", counter + 1); MPI_Barrier(MPI_COMM_WORLD); - } + } #endif /* BARRIER_CHECKS */ - HDsprintf(gname, "%dth_child_group", counter+1); - child_gid = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VRFY((child_gid > 0), gname); + HDsprintf(gname, "%dth_child_group", counter + 1); + child_gid = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VRFY((child_gid > 0), gname); - /* write datasets in parallel. */ - write_dataset(memspace, filespace, gid); + /* write datasets in parallel. */ + write_dataset(memspace, filespace, gid); - if(counter < GROUP_DEPTH ) - create_group_recursive(memspace, filespace, child_gid, counter+1); + if (counter < GROUP_DEPTH) + create_group_recursive(memspace, filespace, child_gid, counter + 1); - H5Gclose(child_gid); + H5Gclose(child_gid); } /* @@ -1243,21 +1250,22 @@ create_group_recursive(hid_t memspace, hid_t filespace, hid_t gid, int counter) * * JRM - 8/11/04 */ -void multiple_group_read(void) +void +multiple_group_read(void) { - int mpi_rank, mpi_size, error_num, size; - int m; - char gname[64]; - hid_t plist, fid, gid, memspace, filespace; - hsize_t chunk_origin[DIM]; - hsize_t chunk_dims[DIM], file_dims[DIM], count[DIM]; + int mpi_rank, mpi_size, error_num, size; + int m; + char gname[64]; + hid_t plist, fid, gid, memspace, filespace; + hsize_t chunk_origin[DIM]; + hsize_t chunk_dims[DIM], file_dims[DIM], count[DIM]; const H5Ptest_param_t *pt; - char *filename; - int ngroups; + char * filename; + int ngroups; - pt = GetTestParameters(); + pt = GetTestParameters(); filename = pt->name; - ngroups = pt->count; + ngroups = pt->count; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); @@ -1265,54 +1273,51 @@ void multiple_group_read(void) size = get_size(); plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); - fid = H5Fopen(filename, H5F_ACC_RDONLY, plist); + fid = H5Fopen(filename, H5F_ACC_RDONLY, plist); H5Pclose(plist); /* decide hyperslab for each process */ get_slab(chunk_origin, chunk_dims, count, file_dims, size); /* select hyperslab for memory and file space */ - memspace = H5Screate_simple(DIM, file_dims, NULL); - H5Sselect_hyperslab(memspace, H5S_SELECT_SET, chunk_origin, chunk_dims, - count, chunk_dims); + memspace = H5Screate_simple(DIM, file_dims, NULL); + H5Sselect_hyperslab(memspace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims); filespace = H5Screate_simple(DIM, file_dims, NULL); - H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin, chunk_dims, - count, chunk_dims); + H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims); /* open every group under root group. */ - for(m=0; m 0), gname); /* check the data. */ - if(m != 0) - if((error_num = read_dataset(memspace, filespace, gid))>0) - nerrors += error_num; + if (m != 0) + if ((error_num = read_dataset(memspace, filespace, gid)) > 0) + nerrors += error_num; /* check attribute.*/ error_num = 0; - if((error_num = read_attribute(gid, is_group, m))>0 ) - nerrors += error_num; + if ((error_num = read_attribute(gid, is_group, m)) > 0) + nerrors += error_num; H5Gclose(gid); #ifdef BARRIER_CHECKS - if(!((m+1)%10)) + if (!((m + 1) % 10)) MPI_Barrier(MPI_COMM_WORLD); #endif /* BARRIER_CHECKS */ } /* open all the groups in vertical direction. */ gid = H5Gopen2(fid, "group0", H5P_DEFAULT); - VRFY((gid>0), "group0"); + VRFY((gid > 0), "group0"); recursive_read_group(memspace, filespace, gid, 0); H5Gclose(gid); H5Sclose(filespace); H5Sclose(memspace); H5Fclose(fid); - } /* @@ -1328,7 +1333,7 @@ void multiple_group_read(void) static int read_dataset(hid_t memspace, hid_t filespace, hid_t gid) { - int i, j, n, mpi_rank, mpi_size, size, attr_errors=0, vrfy_errors=0; + int i, j, n, mpi_rank, mpi_size, size, attr_errors = 0, vrfy_errors = 0; char dname[32]; DATATYPE *outdata = NULL, *indata = NULL; hid_t did; @@ -1338,32 +1343,32 @@ read_dataset(hid_t memspace, hid_t filespace, hid_t gid) size = get_size(); - indata =(DATATYPE*)HDmalloc((size_t)size * (size_t)size * sizeof(DATATYPE)); + indata = (DATATYPE *)HDmalloc((size_t)size * (size_t)size * sizeof(DATATYPE)); VRFY((indata != NULL), "HDmalloc succeeded for indata"); - outdata =(DATATYPE*)HDmalloc((size_t)size * (size_t)size * sizeof(DATATYPE)); + outdata = (DATATYPE *)HDmalloc((size_t)size * (size_t)size * sizeof(DATATYPE)); VRFY((outdata != NULL), "HDmalloc succeeded for outdata"); - for(n=0; n0), dname); + VRFY((did > 0), dname); H5Dread(did, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, indata); /* this is the original value */ - for(i=0; i0 ) + if ((attr_errors = read_attribute(did, is_dset, n)) > 0) vrfy_errors += attr_errors; H5Dclose(did); @@ -1383,23 +1388,23 @@ static void recursive_read_group(hid_t memspace, hid_t filespace, hid_t gid, int counter) { hid_t child_gid; - int mpi_rank, err_num=0; + int mpi_rank, err_num = 0; char gname[64]; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); #ifdef BARRIER_CHECKS - if((counter+1) % 10) + if ((counter + 1) % 10) MPI_Barrier(MPI_COMM_WORLD); #endif /* BARRIER_CHECKS */ - if((err_num = read_dataset(memspace, filespace, gid)) ) + if ((err_num = read_dataset(memspace, filespace, gid))) nerrors += err_num; - if(counter < GROUP_DEPTH ) { - HDsprintf(gname, "%dth_child_group", counter+1); + if (counter < GROUP_DEPTH) { + HDsprintf(gname, "%dth_child_group", counter + 1); child_gid = H5Gopen2(gid, gname, H5P_DEFAULT); - VRFY((child_gid>0), gname); - recursive_read_group(memspace, filespace, child_gid, counter+1); + VRFY((child_gid > 0), gname); + recursive_read_group(memspace, filespace, child_gid, counter + 1); H5Gclose(child_gid); } } @@ -1411,23 +1416,23 @@ static void write_attribute(hid_t obj_id, int this_type, int num) { hid_t sid, aid; - hsize_t dspace_dims[1]={8}; - int i, mpi_rank, attr_data[8], dspace_rank=1; + hsize_t dspace_dims[1] = {8}; + int i, mpi_rank, attr_data[8], dspace_rank = 1; char attr_name[32]; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - if(this_type == is_group) { + if (this_type == is_group) { HDsprintf(attr_name, "Group Attribute %d", num); sid = H5Screate(H5S_SCALAR); aid = H5Acreate2(obj_id, attr_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(aid, H5T_NATIVE_INT, &num); + H5Awrite(aid, H5T_NATIVE_INT, &num); H5Aclose(aid); H5Sclose(sid); } /* end if */ - else if(this_type == is_dset) { + else if (this_type == is_dset) { HDsprintf(attr_name, "Dataset Attribute %d", num); - for(i=0; i<8; i++) + for (i = 0; i < 8; i++) attr_data[i] = i; sid = H5Screate_simple(dspace_rank, dspace_dims, NULL); aid = H5Acreate2(obj_id, attr_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -1435,35 +1440,34 @@ write_attribute(hid_t obj_id, int this_type, int num) H5Aclose(aid); H5Sclose(sid); } /* end else-if */ - } /* Read and verify attribute for group or dataset. */ static int read_attribute(hid_t obj_id, int this_type, int num) { - hid_t aid; - hsize_t group_block[2]={1,1}, dset_block[2]={1, 8}; - int i, mpi_rank, in_num, in_data[8], out_data[8], vrfy_errors = 0; - char attr_name[32]; + hid_t aid; + hsize_t group_block[2] = {1, 1}, dset_block[2] = {1, 8}; + int i, mpi_rank, in_num, in_data[8], out_data[8], vrfy_errors = 0; + char attr_name[32]; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - if(this_type == is_group) { + if (this_type == is_group) { HDsprintf(attr_name, "Group Attribute %d", num); aid = H5Aopen(obj_id, attr_name, H5P_DEFAULT); - if(MAINPROCESS) { + if (MAINPROCESS) { H5Aread(aid, H5T_NATIVE_INT, &in_num); - vrfy_errors = dataset_vrfy(NULL, NULL, NULL, group_block, &in_num, &num); + vrfy_errors = dataset_vrfy(NULL, NULL, NULL, group_block, &in_num, &num); } H5Aclose(aid); } - else if(this_type == is_dset) { + else if (this_type == is_dset) { HDsprintf(attr_name, "Dataset Attribute %d", num); - for(i=0; i<8; i++) + for (i = 0; i < 8; i++) out_data[i] = i; aid = H5Aopen(obj_id, attr_name, H5P_DEFAULT); - if(MAINPROCESS) { + if (MAINPROCESS) { H5Aread(aid, H5T_NATIVE_INT, in_data); vrfy_errors = dataset_vrfy(NULL, NULL, NULL, dset_block, in_data, out_data); } @@ -1485,27 +1489,29 @@ read_attribute(hid_t obj_id, int this_type, int num) static int check_value(DATATYPE *indata, DATATYPE *outdata, int size) { - int mpi_rank, mpi_size, err_num=0; - hsize_t i, j; - hsize_t chunk_origin[DIM]; - hsize_t chunk_dims[DIM], count[DIM]; + int mpi_rank, mpi_size, err_num = 0; + hsize_t i, j; + hsize_t chunk_origin[DIM]; + hsize_t chunk_dims[DIM], count[DIM]; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); get_slab(chunk_origin, chunk_dims, count, NULL, size); - indata += chunk_origin[0]*(hsize_t)size; - outdata += chunk_origin[0]*(hsize_t)size; - for(i=chunk_origin[0]; i<(chunk_origin[0]+chunk_dims[0]); i++) - for(j=chunk_origin[1]; j<(chunk_origin[1]+chunk_dims[1]); j++) { - if(*indata != *outdata ) - if(err_num++ < MAX_ERR_REPORT || VERBOSE_MED) - HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col%lu): expect %d, got %d\n",(unsigned long)i,(unsigned long)j,(unsigned long)i,(unsigned long)j, *outdata, *indata); + indata += chunk_origin[0] * (hsize_t)size; + outdata += chunk_origin[0] * (hsize_t)size; + for (i = chunk_origin[0]; i < (chunk_origin[0] + chunk_dims[0]); i++) + for (j = chunk_origin[1]; j < (chunk_origin[1] + chunk_dims[1]); j++) { + if (*indata != *outdata) + if (err_num++ < MAX_ERR_REPORT || VERBOSE_MED) + HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col%lu): expect %d, got %d\n", + (unsigned long)i, (unsigned long)j, (unsigned long)i, (unsigned long)j, *outdata, + *indata); } - if(err_num > MAX_ERR_REPORT && !VERBOSE_MED) + if (err_num > MAX_ERR_REPORT && !VERBOSE_MED) HDprintf("[more errors ...]\n"); - if(err_num) + if (err_num) HDprintf("%d errors found in check_value\n", err_num); return err_num; } @@ -1520,25 +1526,24 @@ check_value(DATATYPE *indata, DATATYPE *outdata, int size) */ static void -get_slab(hsize_t chunk_origin[], hsize_t chunk_dims[], hsize_t count[], - hsize_t file_dims[], int size) +get_slab(hsize_t chunk_origin[], hsize_t chunk_dims[], hsize_t count[], hsize_t file_dims[], int size) { int mpi_rank, mpi_size; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); - if(chunk_origin != NULL) { - chunk_origin[0] = (hsize_t)mpi_rank * (hsize_t)(size/mpi_size); + if (chunk_origin != NULL) { + chunk_origin[0] = (hsize_t)mpi_rank * (hsize_t)(size / mpi_size); chunk_origin[1] = 0; } - if(chunk_dims != NULL) { - chunk_dims[0] = (hsize_t)(size/mpi_size); - chunk_dims[1] = (hsize_t)size; + if (chunk_dims != NULL) { + chunk_dims[0] = (hsize_t)(size / mpi_size); + chunk_dims[1] = (hsize_t)size; } - if(file_dims != NULL) + if (file_dims != NULL) file_dims[0] = file_dims[1] = (hsize_t)size; - if(count != NULL) + if (count != NULL) count[0] = count[1] = 1; } @@ -1565,24 +1570,24 @@ get_slab(hsize_t chunk_origin[], hsize_t chunk_dims[], hsize_t count[], #define N 4 -void io_mode_confusion(void) +void +io_mode_confusion(void) { /* * HDF5 APIs definitions */ - const int rank = 1; + const int rank = 1; const char *dataset_name = "IntArray"; - hid_t file_id, dset_id; /* file and dataset identifiers */ - hid_t filespace, memspace; /* file and memory dataspace */ - /* identifiers */ - hsize_t dimsf[1]; /* dataset dimensions */ - int data[N] = {1}; /* pointer to data buffer to write */ - hsize_t coord[N] = {0L,1L,2L,3L}; - hid_t plist_id; /* property list identifier */ - herr_t status; - + hid_t file_id, dset_id; /* file and dataset identifiers */ + hid_t filespace, memspace; /* file and memory dataspace */ + /* identifiers */ + hsize_t dimsf[1]; /* dataset dimensions */ + int data[N] = {1}; /* pointer to data buffer to write */ + hsize_t coord[N] = {0L, 1L, 2L, 3L}; + hid_t plist_id; /* property list identifier */ + herr_t status; /* * MPI variables @@ -1590,18 +1595,16 @@ void io_mode_confusion(void) int mpi_size, mpi_rank; - /* * test bed related variables */ - const char * fcn_name = "io_mode_confusion"; - const hbool_t verbose = FALSE; - const H5Ptest_param_t * pt; - char * filename; - + const char * fcn_name = "io_mode_confusion"; + const hbool_t verbose = FALSE; + const H5Ptest_param_t *pt; + char * filename; - pt = GetTestParameters(); + pt = GetTestParameters(); filename = pt->name; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -1611,183 +1614,154 @@ void io_mode_confusion(void) * Set up file access property list with parallel I/O access */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Setting up property list.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Setting up property list.\n", mpi_rank, fcn_name); plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id != -1), "H5Pcreate() failed"); status = H5Pset_fapl_mpio(plist_id, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((status >= 0 ), "H5Pset_fapl_mpio() failed"); - + VRFY((status >= 0), "H5Pset_fapl_mpio() failed"); /* * Create a new file collectively and release property list identifier. */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Creating new file.\n", mpi_rank, fcn_name); file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist_id); - VRFY((file_id >= 0 ), "H5Fcreate() failed"); + VRFY((file_id >= 0), "H5Fcreate() failed"); status = H5Pclose(plist_id); - VRFY((status >= 0 ), "H5Pclose() failed"); - + VRFY((status >= 0), "H5Pclose() failed"); /* * Create the dataspace for the dataset. */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Creating the dataspace for the dataset.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Creating the dataspace for the dataset.\n", mpi_rank, fcn_name); - dimsf[0] = N; + dimsf[0] = N; filespace = H5Screate_simple(rank, dimsf, NULL); - VRFY((filespace >= 0 ), "H5Screate_simple() failed."); - + VRFY((filespace >= 0), "H5Screate_simple() failed."); /* * Create the dataset with default properties and close filespace. */ - if(verbose ) - HDfprintf(stdout, - "%0d:%s: Creating the dataset, and closing filespace.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Creating the dataset, and closing filespace.\n", mpi_rank, fcn_name); - dset_id = H5Dcreate2(file_id, dataset_name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VRFY((dset_id >= 0 ), "H5Dcreate2() failed"); + dset_id = + H5Dcreate2(file_id, dataset_name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + VRFY((dset_id >= 0), "H5Dcreate2() failed"); status = H5Sclose(filespace); - VRFY((status >= 0 ), "H5Sclose() failed"); - + VRFY((status >= 0), "H5Sclose() failed"); - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling H5Screate_simple().\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling H5Screate_simple().\n", mpi_rank, fcn_name); memspace = H5Screate_simple(rank, dimsf, NULL); - VRFY((memspace >= 0 ), "H5Screate_simple() failed."); - + VRFY((memspace >= 0), "H5Screate_simple() failed."); - if(mpi_rank == 0 ) { - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling H5Sselect_all(memspace).\n", - mpi_rank, fcn_name); + if (mpi_rank == 0) { + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling H5Sselect_all(memspace).\n", mpi_rank, fcn_name); status = H5Sselect_all(memspace); - VRFY((status >= 0 ), "H5Sselect_all() failed"); - } else { - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling H5Sselect_none(memspace).\n", - mpi_rank, fcn_name); + VRFY((status >= 0), "H5Sselect_all() failed"); + } + else { + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling H5Sselect_none(memspace).\n", mpi_rank, fcn_name); status = H5Sselect_none(memspace); - VRFY((status >= 0 ), "H5Sselect_none() failed"); + VRFY((status >= 0), "H5Sselect_none() failed"); } - - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling MPI_Barrier().\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling MPI_Barrier().\n", mpi_rank, fcn_name); MPI_Barrier(MPI_COMM_WORLD); - - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling H5Dget_space().\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling H5Dget_space().\n", mpi_rank, fcn_name); filespace = H5Dget_space(dset_id); - VRFY((filespace >= 0 ), "H5Dget_space() failed"); - + VRFY((filespace >= 0), "H5Dget_space() failed"); /* select all */ - if(mpi_rank == 0 ) { - if(verbose ) - HDfprintf(stdout, - "%0d:%s: Calling H5Sselect_elements() -- set up hang?\n", - mpi_rank, fcn_name); + if (mpi_rank == 0) { + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling H5Sselect_elements() -- set up hang?\n", mpi_rank, fcn_name); status = H5Sselect_elements(filespace, H5S_SELECT_SET, N, (const hsize_t *)&coord); - VRFY((status >= 0 ), "H5Sselect_elements() failed"); - } else { /* select nothing */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling H5Sselect_none().\n", - mpi_rank, fcn_name); + VRFY((status >= 0), "H5Sselect_elements() failed"); + } + else { /* select nothing */ + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling H5Sselect_none().\n", mpi_rank, fcn_name); status = H5Sselect_none(filespace); - VRFY((status >= 0 ), "H5Sselect_none() failed"); + VRFY((status >= 0), "H5Sselect_none() failed"); } - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling MPI_Barrier().\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling MPI_Barrier().\n", mpi_rank, fcn_name); MPI_Barrier(MPI_COMM_WORLD); - - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Calling H5Pcreate().\n", mpi_rank, fcn_name); plist_id = H5Pcreate(H5P_DATASET_XFER); - VRFY((plist_id != -1 ), "H5Pcreate() failed"); - + VRFY((plist_id != -1), "H5Pcreate() failed"); - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling H5Pset_dxpl_mpio().\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling H5Pset_dxpl_mpio().\n", mpi_rank, fcn_name); status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE); - VRFY((status >= 0 ), "H5Pset_dxpl_mpio() failed"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { + VRFY((status >= 0), "H5Pset_dxpl_mpio() failed"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { status = H5Pset_dxpl_mpio_collective_opt(plist_id, H5FD_MPIO_INDIVIDUAL_IO); - VRFY((status>= 0),"set independent IO collectively succeeded"); + VRFY((status >= 0), "set independent IO collectively succeeded"); } + if (verbose) + HDfprintf(stdout, "%0d:%s: Calling H5Dwrite() -- hang here?.\n", mpi_rank, fcn_name); + status = H5Dwrite(dset_id, H5T_NATIVE_INT, memspace, filespace, plist_id, data); - - if(verbose ) - HDfprintf(stdout, "%0d:%s: Calling H5Dwrite() -- hang here?.\n", - mpi_rank, fcn_name); - - status = H5Dwrite(dset_id, H5T_NATIVE_INT, memspace, filespace, - plist_id, data); - - if(verbose ) - HDfprintf(stdout, "%0d:%s: Returned from H5Dwrite(), status=%d.\n", - mpi_rank, fcn_name, status); - VRFY((status >= 0 ), "H5Dwrite() failed"); + if (verbose) + HDfprintf(stdout, "%0d:%s: Returned from H5Dwrite(), status=%d.\n", mpi_rank, fcn_name, status); + VRFY((status >= 0), "H5Dwrite() failed"); /* * Close/release resources. */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Cleaning up from test.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Cleaning up from test.\n", mpi_rank, fcn_name); status = H5Dclose(dset_id); - VRFY((status >= 0 ), "H5Dclose() failed"); + VRFY((status >= 0), "H5Dclose() failed"); status = H5Sclose(filespace); - VRFY((status >= 0 ), "H5Dclose() failed"); + VRFY((status >= 0), "H5Dclose() failed"); status = H5Sclose(memspace); - VRFY((status >= 0 ), "H5Sclose() failed"); + VRFY((status >= 0), "H5Sclose() failed"); status = H5Pclose(plist_id); - VRFY((status >= 0 ), "H5Pclose() failed"); + VRFY((status >= 0), "H5Pclose() failed"); status = H5Fclose(file_id); - VRFY((status >= 0 ), "H5Fclose() failed"); - + VRFY((status >= 0), "H5Fclose() failed"); - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Done.\n", mpi_rank, fcn_name); return; @@ -1841,62 +1815,46 @@ void io_mode_confusion(void) * the correctness of the writer. AKC -- 2010/10/27 */ -#define NUM_DATA_SETS 4 -#define LOCAL_DATA_SIZE 4 -#define LARGE_ATTR_SIZE 256 +#define NUM_DATA_SETS 4 +#define LOCAL_DATA_SIZE 4 +#define LARGE_ATTR_SIZE 256 /* Since all even and odd processes are split into writer and reader comm * respectively, process 0 and 1 in COMM_WORLD become the root process of * the writer and reader comm respectively. */ -#define Writer_Root 0 -#define Reader_Root 1 -#define Reader_wait(mpi_err, xsteps) \ - mpi_err = MPI_Bcast(&xsteps, 1, MPI_INT, Writer_Root, MPI_COMM_WORLD) -#define Reader_result(mpi_err, xsteps_done) \ +#define Writer_Root 0 +#define Reader_Root 1 +#define Reader_wait(mpi_err, xsteps) mpi_err = MPI_Bcast(&xsteps, 1, MPI_INT, Writer_Root, MPI_COMM_WORLD) +#define Reader_result(mpi_err, xsteps_done) \ mpi_err = MPI_Bcast(&xsteps_done, 1, MPI_INT, Reader_Root, MPI_COMM_WORLD) -#define Reader_check(mpi_err, xsteps, xsteps_done) \ - { Reader_wait(mpi_err, xsteps); \ - Reader_result(mpi_err, xsteps_done);} +#define Reader_check(mpi_err, xsteps, xsteps_done) \ + { \ + Reader_wait(mpi_err, xsteps); \ + Reader_result(mpi_err, xsteps_done); \ + } /* object names used by both rr_obj_hdr_flush_confusion and * rr_obj_hdr_flush_confusion_reader. */ -const char * dataset_name[NUM_DATA_SETS] = - { - "dataset_0", - "dataset_1", - "dataset_2", - "dataset_3" - }; -const char * att_name[NUM_DATA_SETS] = - { - "attribute_0", - "attribute_1", - "attribute_2", - "attribute_3" - }; -const char * lg_att_name[NUM_DATA_SETS] = - { - "large_attribute_0", - "large_attribute_1", - "large_attribute_2", - "large_attribute_3" - }; - -void rr_obj_hdr_flush_confusion(void) +const char *dataset_name[NUM_DATA_SETS] = {"dataset_0", "dataset_1", "dataset_2", "dataset_3"}; +const char *att_name[NUM_DATA_SETS] = {"attribute_0", "attribute_1", "attribute_2", "attribute_3"}; +const char *lg_att_name[NUM_DATA_SETS] = {"large_attribute_0", "large_attribute_1", "large_attribute_2", + "large_attribute_3"}; + +void +rr_obj_hdr_flush_confusion(void) { /* MPI variables */ /* private communicator size and rank */ - int mpi_size; - int mpi_rank; - int mrc; /* mpi error code */ - int is_reader; /* 1 for reader process; 0 for writer process. */ + int mpi_size; + int mpi_rank; + int mrc; /* mpi error code */ + int is_reader; /* 1 for reader process; 0 for writer process. */ MPI_Comm comm; - /* test bed related variables */ - const char * fcn_name = "rr_obj_hdr_flush_confusion"; - const hbool_t verbose = FALSE; + const char * fcn_name = "rr_obj_hdr_flush_confusion"; + const hbool_t verbose = FALSE; /* Create two new private communicators from MPI_COMM_WORLD. * Even and odd ranked processes go to comm_writers and comm_readers @@ -1908,8 +1866,8 @@ void rr_obj_hdr_flush_confusion(void) HDassert(mpi_size > 2); is_reader = mpi_rank % 2; - mrc = MPI_Comm_split(MPI_COMM_WORLD, is_reader, mpi_rank, &comm); - VRFY((mrc==MPI_SUCCESS), "MPI_Comm_split"); + mrc = MPI_Comm_split(MPI_COMM_WORLD, is_reader, mpi_rank, &comm); + VRFY((mrc == MPI_SUCCESS), "MPI_Comm_split"); /* The reader proocesses branches off to do reading * while the writer processes continues to do writing @@ -1919,32 +1877,33 @@ void rr_obj_hdr_flush_confusion(void) * step. When all steps are done, they inform readers to end. */ if (is_reader) - rr_obj_hdr_flush_confusion_reader(comm); + rr_obj_hdr_flush_confusion_reader(comm); else - rr_obj_hdr_flush_confusion_writer(comm); + rr_obj_hdr_flush_confusion_writer(comm); MPI_Comm_free(&comm); - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Done.\n", mpi_rank, fcn_name); return; } /* rr_obj_hdr_flush_confusion() */ -void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) +void +rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) { - int i; - int j; - hid_t file_id = -1; - hid_t fapl_id = -1; - hid_t dxpl_id = -1; - hid_t att_id[NUM_DATA_SETS]; - hid_t att_space[NUM_DATA_SETS]; - hid_t lg_att_id[NUM_DATA_SETS]; - hid_t lg_att_space[NUM_DATA_SETS]; - hid_t disk_space[NUM_DATA_SETS]; - hid_t mem_space[NUM_DATA_SETS]; - hid_t dataset[NUM_DATA_SETS]; + int i; + int j; + hid_t file_id = -1; + hid_t fapl_id = -1; + hid_t dxpl_id = -1; + hid_t att_id[NUM_DATA_SETS]; + hid_t att_space[NUM_DATA_SETS]; + hid_t lg_att_id[NUM_DATA_SETS]; + hid_t lg_att_space[NUM_DATA_SETS]; + hid_t disk_space[NUM_DATA_SETS]; + hid_t mem_space[NUM_DATA_SETS]; + hid_t dataset[NUM_DATA_SETS]; hsize_t att_size[1]; hsize_t lg_att_size[1]; hsize_t disk_count[1]; @@ -1953,10 +1912,10 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) hsize_t mem_count[1]; hsize_t mem_size[1]; hsize_t mem_start[1]; - herr_t err; - double data[LOCAL_DATA_SIZE]; - double att[LOCAL_DATA_SIZE]; - double lg_att[LARGE_ATTR_SIZE]; + herr_t err; + double data[LOCAL_DATA_SIZE]; + double att[LOCAL_DATA_SIZE]; + double lg_att[LARGE_ATTR_SIZE]; /* MPI variables */ /* world communication size and rank */ @@ -1967,20 +1926,20 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) int mpi_rank; int mrc; /* mpi error code */ /* steps to verify and have been verified */ - int steps = 0; + int steps = 0; int steps_done = 0; /* test bed related variables */ - const char *fcn_name = "rr_obj_hdr_flush_confusion_writer"; - const hbool_t verbose = FALSE; + const char * fcn_name = "rr_obj_hdr_flush_confusion_writer"; + const hbool_t verbose = FALSE; const H5Ptest_param_t *pt; - char *filename; + char * filename; /* * setup test bed related variables: */ - pt = (const H5Ptest_param_t *)GetTestParameters(); + pt = (const H5Ptest_param_t *)GetTestParameters(); filename = pt->name; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_world_rank); @@ -1992,50 +1951,45 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * Set up file access property list with parallel I/O access */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Setting up property list.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Setting up property list.\n", mpi_rank, fcn_name); fapl_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((fapl_id != -1), "H5Pcreate(H5P_FILE_ACCESS) failed"); err = H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL); - VRFY((err >= 0 ), "H5Pset_fapl_mpio() failed"); - + VRFY((err >= 0), "H5Pset_fapl_mpio() failed"); /* * Create a new file collectively and release property list identifier. */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Creating new file \"%s\".\n", - mpi_rank, fcn_name, filename); + if (verbose) + HDfprintf(stdout, "%0d:%s: Creating new file \"%s\".\n", mpi_rank, fcn_name, filename); file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - VRFY((file_id >= 0 ), "H5Fcreate() failed"); + VRFY((file_id >= 0), "H5Fcreate() failed"); err = H5Pclose(fapl_id); - VRFY((err >= 0 ), "H5Pclose(fapl_id) failed"); - + VRFY((err >= 0), "H5Pclose(fapl_id) failed"); /* * Step 1: create the data sets and write data. */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Creating the datasets.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Creating the datasets.\n", mpi_rank, fcn_name); disk_size[0] = (hsize_t)(LOCAL_DATA_SIZE * mpi_size); - mem_size[0] = (hsize_t)(LOCAL_DATA_SIZE); + mem_size[0] = (hsize_t)(LOCAL_DATA_SIZE); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { disk_space[i] = H5Screate_simple(1, disk_size, NULL); - VRFY((disk_space[i] >= 0), "H5Screate_simple(1) failed.\n"); + VRFY((disk_space[i] >= 0), "H5Screate_simple(1) failed.\n"); - dataset[i] = H5Dcreate2(file_id, dataset_name[i], H5T_NATIVE_DOUBLE, - disk_space[i], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset[i] = H5Dcreate2(file_id, dataset_name[i], H5T_NATIVE_DOUBLE, disk_space[i], H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset[i] >= 0), "H5Dcreate(1) failed.\n"); } @@ -2044,45 +1998,41 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * setup data transfer property list */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Setting up dxpl.\n", mpi_rank, fcn_name); dxpl_id = H5Pcreate(H5P_DATASET_XFER); VRFY((dxpl_id != -1), "H5Pcreate(H5P_DATASET_XFER) failed.\n"); err = H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE); - VRFY((err >= 0), - "H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) failed.\n"); + VRFY((err >= 0), "H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) failed.\n"); /* * write data to the data sets */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Writing datasets.\n", mpi_rank, fcn_name); disk_count[0] = (hsize_t)(LOCAL_DATA_SIZE); disk_start[0] = (hsize_t)(LOCAL_DATA_SIZE * mpi_rank); - mem_count[0] = (hsize_t)(LOCAL_DATA_SIZE); - mem_start[0] = (hsize_t)(0); + mem_count[0] = (hsize_t)(LOCAL_DATA_SIZE); + mem_start[0] = (hsize_t)(0); - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + for (j = 0; j < LOCAL_DATA_SIZE; j++) { data[j] = (double)(mpi_rank + 1); } - for ( i = 0; i < NUM_DATA_SETS; i++ ) { - err = H5Sselect_hyperslab(disk_space[i], H5S_SELECT_SET, disk_start, - NULL, disk_count, NULL); + for (i = 0; i < NUM_DATA_SETS; i++) { + err = H5Sselect_hyperslab(disk_space[i], H5S_SELECT_SET, disk_start, NULL, disk_count, NULL); VRFY((err >= 0), "H5Sselect_hyperslab(1) failed.\n"); mem_space[i] = H5Screate_simple(1, mem_size, NULL); VRFY((mem_space[i] >= 0), "H5Screate_simple(2) failed.\n"); - err = H5Sselect_hyperslab(mem_space[i], H5S_SELECT_SET, - mem_start, NULL, mem_count, NULL); + err = H5Sselect_hyperslab(mem_space[i], H5S_SELECT_SET, mem_start, NULL, mem_count, NULL); VRFY((err >= 0), "H5Sselect_hyperslab(2) failed.\n"); - err = H5Dwrite(dataset[i], H5T_NATIVE_DOUBLE, mem_space[i], - disk_space[i], dxpl_id, data); + err = H5Dwrite(dataset[i], H5T_NATIVE_DOUBLE, mem_space[i], disk_space[i], dxpl_id, data); VRFY((err >= 0), "H5Dwrite(1) failed.\n"); - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) + for (j = 0; j < LOCAL_DATA_SIZE; j++) data[j] *= 10.0; } @@ -2090,10 +2040,10 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * close the data spaces */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: closing dataspaces.\n", mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { err = H5Sclose(disk_space[i]); VRFY((err >= 0), "H5Sclose(disk_space[i]) failed.\n"); err = H5Sclose(mem_space[i]); @@ -2106,9 +2056,8 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * flush the metadata cache */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", mpi_rank, fcn_name); err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "H5Fflush(1) failed.\n"); @@ -2120,23 +2069,23 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * Step 2: write attributes to each dataset */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: writing attributes.\n", mpi_rank, fcn_name); att_size[0] = (hsize_t)(LOCAL_DATA_SIZE); - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + for (j = 0; j < LOCAL_DATA_SIZE; j++) { att[j] = (double)(j + 1); } - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { att_space[i] = H5Screate_simple(1, att_size, NULL); VRFY((att_space[i] >= 0), "H5Screate_simple(3) failed.\n"); - att_id[i] = H5Acreate2(dataset[i], att_name[i], H5T_NATIVE_DOUBLE, - att_space[i], H5P_DEFAULT, H5P_DEFAULT); + att_id[i] = + H5Acreate2(dataset[i], att_name[i], H5T_NATIVE_DOUBLE, att_space[i], H5P_DEFAULT, H5P_DEFAULT); VRFY((att_id[i] >= 0), "H5Acreate(1) failed.\n"); err = H5Awrite(att_id[i], H5T_NATIVE_DOUBLE, att); VRFY((err >= 0), "H5Awrite(1) failed.\n"); - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + for (j = 0; j < LOCAL_DATA_SIZE; j++) { att[j] /= 10.0; } } @@ -2145,11 +2094,10 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * close attribute IDs and spaces */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: closing attr ids and spaces .\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: closing attr ids and spaces .\n", mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { err = H5Sclose(att_space[i]); VRFY((err >= 0), "H5Sclose(att_space[i]) failed.\n"); err = H5Aclose(att_id[i]); @@ -2162,9 +2110,8 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * flush the metadata cache again */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", mpi_rank, fcn_name); err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "H5Fflush(2) failed.\n"); @@ -2176,25 +2123,24 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * Step 3: write large attributes to each dataset */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: writing large attributes.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: writing large attributes.\n", mpi_rank, fcn_name); lg_att_size[0] = (hsize_t)(LARGE_ATTR_SIZE); - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { + for (j = 0; j < LARGE_ATTR_SIZE; j++) { lg_att[j] = (double)(j + 1); } - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { lg_att_space[i] = H5Screate_simple(1, lg_att_size, NULL); VRFY((lg_att_space[i] >= 0), "H5Screate_simple(4) failed.\n"); - lg_att_id[i] = H5Acreate2(dataset[i], lg_att_name[i], H5T_NATIVE_DOUBLE, - lg_att_space[i], H5P_DEFAULT, H5P_DEFAULT); + lg_att_id[i] = H5Acreate2(dataset[i], lg_att_name[i], H5T_NATIVE_DOUBLE, lg_att_space[i], H5P_DEFAULT, + H5P_DEFAULT); VRFY((lg_att_id[i] >= 0), "H5Acreate(2) failed.\n"); err = H5Awrite(lg_att_id[i], H5T_NATIVE_DOUBLE, lg_att); VRFY((err >= 0), "H5Awrite(2) failed.\n"); - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { + for (j = 0; j < LARGE_ATTR_SIZE; j++) { lg_att[j] /= 10.0; } } @@ -2211,9 +2157,8 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * code is going to change a lot in the near future. */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", mpi_rank, fcn_name); err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "H5Fflush(3) failed.\n"); @@ -2225,18 +2170,17 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * Step 4: write different large attributes to each dataset */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: writing different large attributes.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: writing different large attributes.\n", mpi_rank, fcn_name); - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { + for (j = 0; j < LARGE_ATTR_SIZE; j++) { lg_att[j] = (double)(j + 2); } - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { err = H5Awrite(lg_att_id[i], H5T_NATIVE_DOUBLE, lg_att); VRFY((err >= 0), "H5Awrite(2) failed.\n"); - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { + for (j = 0; j < LARGE_ATTR_SIZE; j++) { lg_att[j] /= 10.0; } } @@ -2246,9 +2190,8 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) /* * flush the metadata cache again */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", mpi_rank, fcn_name); err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "H5Fflush(3) failed.\n"); @@ -2262,11 +2205,10 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * close large attribute IDs and spaces */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: closing large attr ids and spaces .\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: closing large attr ids and spaces .\n", mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { err = H5Sclose(lg_att_space[i]); VRFY((err >= 0), "H5Sclose(lg_att_space[i]) failed.\n"); @@ -2274,15 +2216,14 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) VRFY((err >= 0), "H5Aclose(lg_att_id[i]) failed.\n"); } - /* * close the data sets */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: closing datasets .\n", mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { err = H5Dclose(dataset[i]); VRFY((err >= 0), "H5Dclose(dataset[i])1 failed.\n"); } @@ -2291,88 +2232,87 @@ void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) * close the data transfer property list. */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: closing dxpl .\n", mpi_rank, fcn_name); err = H5Pclose(dxpl_id); VRFY((err >= 0), "H5Pclose(dxpl_id) failed.\n"); - /* * Close file. */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: closing file.\n", mpi_rank, fcn_name); err = H5Fclose(file_id); - VRFY((err >= 0 ), "H5Fclose(1) failed"); + VRFY((err >= 0), "H5Fclose(1) failed"); /* End of Step 5: Close all objects and the file */ /* Tell the reader to check the file up to steps. */ steps++; Reader_check(mrc, steps, steps_done); - /* All done. Inform reader to end. */ - steps=0; + steps = 0; Reader_check(mrc, steps, steps_done); - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Done.\n", mpi_rank, fcn_name); return; } /* rr_obj_hdr_flush_confusion_writer() */ -void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) +void +rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) { - int i; - int j; - hid_t file_id = -1; - hid_t fapl_id = -1; - hid_t dxpl_id = -1; - hid_t lg_att_id[NUM_DATA_SETS]; - hid_t lg_att_type[NUM_DATA_SETS]; - hid_t disk_space[NUM_DATA_SETS]; - hid_t mem_space[NUM_DATA_SETS]; - hid_t dataset[NUM_DATA_SETS]; + int i; + int j; + hid_t file_id = -1; + hid_t fapl_id = -1; + hid_t dxpl_id = -1; + hid_t lg_att_id[NUM_DATA_SETS]; + hid_t lg_att_type[NUM_DATA_SETS]; + hid_t disk_space[NUM_DATA_SETS]; + hid_t mem_space[NUM_DATA_SETS]; + hid_t dataset[NUM_DATA_SETS]; hsize_t disk_count[1]; hsize_t disk_start[1]; hsize_t mem_count[1]; hsize_t mem_size[1]; hsize_t mem_start[1]; - herr_t err; - htri_t tri_err; - double data[LOCAL_DATA_SIZE]; - double data_read[LOCAL_DATA_SIZE]; - double att[LOCAL_DATA_SIZE]; - double att_read[LOCAL_DATA_SIZE]; - double lg_att[LARGE_ATTR_SIZE]; - double lg_att_read[LARGE_ATTR_SIZE]; + herr_t err; + htri_t tri_err; + double data[LOCAL_DATA_SIZE]; + double data_read[LOCAL_DATA_SIZE]; + double att[LOCAL_DATA_SIZE]; + double att_read[LOCAL_DATA_SIZE]; + double lg_att[LARGE_ATTR_SIZE]; + double lg_att_read[LARGE_ATTR_SIZE]; /* MPI variables */ /* world communication size and rank */ - int mpi_world_size; - int mpi_world_rank; + int mpi_world_size; + int mpi_world_rank; /* private communicator size and rank */ - int mpi_size; - int mpi_rank; - int mrc; /* mpi error code */ - int steps = -1; /* How far (steps) to verify the file */ - int steps_done = -1; /* How far (steps) have been verified */ + int mpi_size; + int mpi_rank; + int mrc; /* mpi error code */ + int steps = -1; /* How far (steps) to verify the file */ + int steps_done = -1; /* How far (steps) have been verified */ /* test bed related variables */ - const char *fcn_name = "rr_obj_hdr_flush_confusion_reader"; - const hbool_t verbose = FALSE; + const char * fcn_name = "rr_obj_hdr_flush_confusion_reader"; + const hbool_t verbose = FALSE; const H5Ptest_param_t *pt; - char *filename; + char * filename; /* * setup test bed related variables: */ - pt = (const H5Ptest_param_t *)GetTestParameters(); + pt = (const H5Ptest_param_t *)GetTestParameters(); filename = pt->name; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_world_rank); @@ -2382,53 +2322,50 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) /* Repeatedly re-open the file and verify its contents until it is */ /* told to end (when steps=0). */ - while (steps_done != 0){ + while (steps_done != 0) { Reader_wait(mrc, steps); VRFY((mrc >= 0), "Reader_wait failed"); steps_done = 0; - if (steps > 0 ){ + if (steps > 0) { /* - * Set up file access property list with parallel I/O access - */ + * Set up file access property list with parallel I/O access + */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Setting up property list.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: Setting up property list.\n", mpi_rank, fcn_name); fapl_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((fapl_id != -1), "H5Pcreate(H5P_FILE_ACCESS) failed"); err = H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL); - VRFY((err >= 0 ), "H5Pset_fapl_mpio() failed"); + VRFY((err >= 0), "H5Pset_fapl_mpio() failed"); /* - * Create a new file collectively and release property list identifier. - */ + * Create a new file collectively and release property list identifier. + */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: Re-open file \"%s\".\n", - mpi_rank, fcn_name, filename); + if (verbose) + HDfprintf(stdout, "%0d:%s: Re-open file \"%s\".\n", mpi_rank, fcn_name, filename); file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id); - VRFY((file_id >= 0 ), "H5Fopen() failed"); + VRFY((file_id >= 0), "H5Fopen() failed"); err = H5Pclose(fapl_id); - VRFY((err >= 0 ), "H5Pclose(fapl_id) failed"); + VRFY((err >= 0), "H5Pclose(fapl_id) failed"); #if 1 - if (steps >= 1){ + if (steps >= 1) { /*=====================================================* - * Step 1: open the data sets and read data. - *=====================================================*/ + * Step 1: open the data sets and read data. + *=====================================================*/ - if(verbose ) - HDfprintf(stdout, "%0d:%s: opening the datasets.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: opening the datasets.\n", mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { dataset[i] = -1; } - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { dataset[i] = H5Dopen2(file_id, dataset_name[i], H5P_DEFAULT); VRFY((dataset[i] >= 0), "H5Dopen(1) failed.\n"); disk_space[i] = H5Dget_space(dataset[i]); @@ -2436,23 +2373,22 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) } /* - * setup data transfer property list - */ + * setup data transfer property list + */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Setting up dxpl.\n", mpi_rank, fcn_name); dxpl_id = H5Pcreate(H5P_DATASET_XFER); VRFY((dxpl_id != -1), "H5Pcreate(H5P_DATASET_XFER) failed.\n"); err = H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE); - VRFY((err >= 0), - "H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) failed.\n"); + VRFY((err >= 0), "H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) failed.\n"); /* - * read data from the data sets - */ + * read data from the data sets + */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Reading datasets.\n", mpi_rank, fcn_name); disk_count[0] = (hsize_t)(LOCAL_DATA_SIZE); @@ -2464,44 +2400,43 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) mem_start[0] = (hsize_t)(0); /* set up expected data for verification */ - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + for (j = 0; j < LOCAL_DATA_SIZE; j++) { data[j] = (double)(mpi_rank + 1); } - for ( i = 0; i < NUM_DATA_SETS; i++ ) { - err = H5Sselect_hyperslab(disk_space[i], H5S_SELECT_SET, disk_start, - NULL, disk_count, NULL); + for (i = 0; i < NUM_DATA_SETS; i++) { + err = H5Sselect_hyperslab(disk_space[i], H5S_SELECT_SET, disk_start, NULL, disk_count, + NULL); VRFY((err >= 0), "H5Sselect_hyperslab(1) failed.\n"); mem_space[i] = H5Screate_simple(1, mem_size, NULL); VRFY((mem_space[i] >= 0), "H5Screate_simple(2) failed.\n"); - err = H5Sselect_hyperslab(mem_space[i], H5S_SELECT_SET, - mem_start, NULL, mem_count, NULL); + err = H5Sselect_hyperslab(mem_space[i], H5S_SELECT_SET, mem_start, NULL, mem_count, NULL); VRFY((err >= 0), "H5Sselect_hyperslab(2) failed.\n"); - err = H5Dread(dataset[i], H5T_NATIVE_DOUBLE, mem_space[i], - disk_space[i], dxpl_id, data_read); + err = H5Dread(dataset[i], H5T_NATIVE_DOUBLE, mem_space[i], disk_space[i], dxpl_id, + data_read); VRFY((err >= 0), "H5Dread(1) failed.\n"); /* compare read data with expected data */ - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) - if (!H5_DBL_ABS_EQUAL(data_read[j], data[j])){ + for (j = 0; j < LOCAL_DATA_SIZE; j++) + if (!H5_DBL_ABS_EQUAL(data_read[j], data[j])) { HDfprintf(stdout, - "%0d:%s: Reading datasets value failed in " - "Dataset %d, at position %d: expect %f, got %f.\n", - mpi_rank, fcn_name, i, j, data[j], data_read[j]); + "%0d:%s: Reading datasets value failed in " + "Dataset %d, at position %d: expect %f, got %f.\n", + mpi_rank, fcn_name, i, j, data[j], data_read[j]); nerrors++; } - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) + for (j = 0; j < LOCAL_DATA_SIZE; j++) data[j] *= 10.0; } /* - * close the data spaces - */ + * close the data spaces + */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: closing dataspaces.\n", mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { err = H5Sclose(disk_space[i]); VRFY((err >= 0), "H5Sclose(disk_space[i]) failed.\n"); err = H5Sclose(mem_space[i]); @@ -2514,18 +2449,18 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) #if 1 /*=====================================================* - * Step 2: reading attributes from each dataset - *=====================================================*/ + * Step 2: reading attributes from each dataset + *=====================================================*/ - if (steps >= 2){ - if(verbose ) + if (steps >= 2) { + if (verbose) HDfprintf(stdout, "%0d:%s: reading attributes.\n", mpi_rank, fcn_name); - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + for (j = 0; j < LOCAL_DATA_SIZE; j++) { att[j] = (double)(j + 1); } - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { hid_t att_id, att_type; att_id = H5Aopen(dataset[i], att_name[i], H5P_DEFAULT); @@ -2534,10 +2469,9 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) VRFY((att_type >= 0), "H5Aget_type failed.\n"); tri_err = H5Tequal(att_type, H5T_NATIVE_DOUBLE); VRFY((tri_err >= 0), "H5Tequal failed.\n"); - if (tri_err==0){ - HDfprintf(stdout, - "%0d:%s: Mismatched Attribute type of Dataset %d.\n", - mpi_rank, fcn_name, i); + if (tri_err == 0) { + HDfprintf(stdout, "%0d:%s: Mismatched Attribute type of Dataset %d.\n", mpi_rank, + fcn_name, i); nerrors++; } else { @@ -2545,14 +2479,15 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) err = H5Aread(att_id, H5T_NATIVE_DOUBLE, att_read); VRFY((err >= 0), "H5Aread failed.\n"); /* compare read attribute data with expected data */ - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) - if (!H5_DBL_ABS_EQUAL(att_read[j], att[j])){ + for (j = 0; j < LOCAL_DATA_SIZE; j++) + if (!H5_DBL_ABS_EQUAL(att_read[j], att[j])) { HDfprintf(stdout, - "%0d:%s: Mismatched attribute data read in Dataset %d, at position %d: expect %f, got %f.\n", - mpi_rank, fcn_name, i, j, att[j], att_read[j]); + "%0d:%s: Mismatched attribute data read in Dataset %d, at position " + "%d: expect %f, got %f.\n", + mpi_rank, fcn_name, i, j, att[j], att_read[j]); nerrors++; } - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + for (j = 0; j < LOCAL_DATA_SIZE; j++) { att[j] /= 10.0; } } @@ -2564,47 +2499,46 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) /* End of Step 2: reading attributes from each dataset */ #endif - #if 1 /*=====================================================* - * Step 3 or 4: read large attributes from each dataset. - * Step 4 has different attribute value from step 3. - *=====================================================*/ + * Step 3 or 4: read large attributes from each dataset. + * Step 4 has different attribute value from step 3. + *=====================================================*/ - if (steps >= 3){ - if(verbose ) + if (steps >= 3) { + if (verbose) HDfprintf(stdout, "%0d:%s: reading large attributes.\n", mpi_rank, fcn_name); - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { - lg_att[j] = (steps==3) ? (double)(j + 1) : (double)(j+2); + for (j = 0; j < LARGE_ATTR_SIZE; j++) { + lg_att[j] = (steps == 3) ? (double)(j + 1) : (double)(j + 2); } - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + for (i = 0; i < NUM_DATA_SETS; i++) { lg_att_id[i] = H5Aopen(dataset[i], lg_att_name[i], H5P_DEFAULT); VRFY((lg_att_id[i] >= 0), "H5Aopen(2) failed.\n"); lg_att_type[i] = H5Aget_type(lg_att_id[i]); VRFY((err >= 0), "H5Aget_type failed.\n"); tri_err = H5Tequal(lg_att_type[i], H5T_NATIVE_DOUBLE); VRFY((tri_err >= 0), "H5Tequal failed.\n"); - if (tri_err==0){ - HDfprintf(stdout, - "%0d:%s: Mismatched Large attribute type of Dataset %d.\n", - mpi_rank, fcn_name, i); + if (tri_err == 0) { + HDfprintf(stdout, "%0d:%s: Mismatched Large attribute type of Dataset %d.\n", + mpi_rank, fcn_name, i); nerrors++; } - else{ + else { /* should verify large attribute size before H5Aread */ err = H5Aread(lg_att_id[i], H5T_NATIVE_DOUBLE, lg_att_read); VRFY((err >= 0), "H5Aread failed.\n"); /* compare read attribute data with expected data */ - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) - if (!H5_DBL_ABS_EQUAL(lg_att_read[j], lg_att[j])){ + for (j = 0; j < LARGE_ATTR_SIZE; j++) + if (!H5_DBL_ABS_EQUAL(lg_att_read[j], lg_att[j])) { HDfprintf(stdout, - "%0d:%s: Mismatched large attribute data read in Dataset %d, at position %d: expect %f, got %f.\n", - mpi_rank, fcn_name, i, j, lg_att[j], lg_att_read[j]); + "%0d:%s: Mismatched large attribute data read in Dataset %d, at " + "position %d: expect %f, got %f.\n", + mpi_rank, fcn_name, i, j, lg_att[j], lg_att_read[j]); nerrors++; } - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { + for (j = 0; j < LARGE_ATTR_SIZE; j++) { lg_att[j] /= 10.0; } @@ -2615,61 +2549,58 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) VRFY((err >= 0), "H5Aclose failed.\n"); } /* Both step 3 and 4 use this same read checking code. */ - steps_done = (steps==3) ? 3 : 4; + steps_done = (steps == 3) ? 3 : 4; } /* End of Step 3 or 4: read large attributes from each dataset */ #endif - /*=====================================================* - * Step 5: read all objects from the file - *=====================================================*/ - if (steps>=5){ + * Step 5: read all objects from the file + *=====================================================*/ + if (steps >= 5) { /* nothing extra to verify. The file is closed normally. */ /* Just increment steps_done */ steps_done++; } /* - * Close the data sets - */ + * Close the data sets + */ - if(verbose ) - HDfprintf(stdout, "%0d:%s: closing datasets again.\n", - mpi_rank, fcn_name); + if (verbose) + HDfprintf(stdout, "%0d:%s: closing datasets again.\n", mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { - if ( dataset[i] >= 0 ) { + for (i = 0; i < NUM_DATA_SETS; i++) { + if (dataset[i] >= 0) { err = H5Dclose(dataset[i]); VRFY((err >= 0), "H5Dclose(dataset[i])1 failed.\n"); } } /* - * close the data transfer property list. - */ + * close the data transfer property list. + */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: closing dxpl .\n", mpi_rank, fcn_name); err = H5Pclose(dxpl_id); VRFY((err >= 0), "H5Pclose(dxpl_id) failed.\n"); /* - * Close the file - */ - if(verbose) - HDfprintf(stdout, "%0d:%s: closing file again.\n", - mpi_rank, fcn_name); + * Close the file + */ + if (verbose) + HDfprintf(stdout, "%0d:%s: closing file again.\n", mpi_rank, fcn_name); err = H5Fclose(file_id); - VRFY((err >= 0 ), "H5Fclose(1) failed"); + VRFY((err >= 0), "H5Fclose(1) failed"); } /* else if (steps_done==0) */ Reader_result(mrc, steps_done); } /* end while(1) */ - if(verbose ) + if (verbose) HDfprintf(stdout, "%0d:%s: Done.\n", mpi_rank, fcn_name); return; @@ -2684,27 +2615,27 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) #undef Writer_Root #undef Reader_Root - /* * Test creating a chunked dataset in parallel in a file with an alignment set * and an alignment threshold large enough to avoid aligning the chunks but * small enough that the raw data aggregator will be aligned if it is treated as * an object that must be aligned by the library */ -#define CHUNK_SIZE 72 -#define NCHUNKS 32 -#define AGGR_SIZE 2048 +#define CHUNK_SIZE 72 +#define NCHUNKS 32 +#define AGGR_SIZE 2048 #define EXTRA_ALIGN 100 - void chunk_align_bug_1(void) - { - int mpi_rank; - hid_t file_id, dset_id, fapl_id, dcpl_id, space_id; - hsize_t dims = CHUNK_SIZE * NCHUNKS, cdims = CHUNK_SIZE; - h5_stat_size_t file_size; - hsize_t align; - herr_t ret; - const char *filename; +void +chunk_align_bug_1(void) +{ + int mpi_rank; + hid_t file_id, dset_id, fapl_id, dcpl_id, space_id; + hsize_t dims = CHUNK_SIZE * NCHUNKS, cdims = CHUNK_SIZE; + h5_stat_size_t file_size; + hsize_t align; + herr_t ret; + const char * filename; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -2769,8 +2700,6 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) return; } /* end chunk_align_bug_1() */ - /*============================================================================= * End of t_mdset.c *===========================================================================*/ - diff --git a/testpar/t_mpi.c b/testpar/t_mpi.c index 0719ca6..fe73ba0 100644 --- a/testpar/t_mpi.c +++ b/testpar/t_mpi.c @@ -28,33 +28,34 @@ #include "testpar.h" /* FILENAME and filenames must have the same number of names */ -const char *FILENAME[2] = { "MPItest", NULL }; -char filenames[2][200]; -int nerrors = 0; -hid_t fapl; /* file access property list */ +const char *FILENAME[2] = {"MPItest", NULL}; +char filenames[2][200]; +int nerrors = 0; +hid_t fapl; /* file access property list */ /* protocols */ static int errors_sum(int nerrs); -#define MPIO_TEST_WRITE_SIZE 1024*1024 /* 1 MB */ - -static int test_mpio_overlap_writes(char *filename) { - int mpi_size, mpi_rank; - MPI_Comm comm; - MPI_Info info = MPI_INFO_NULL; - int color, mrc; - MPI_File fh; - int i; - int vrfyerrs, nerrs; +#define MPIO_TEST_WRITE_SIZE 1024 * 1024 /* 1 MB */ + +static int +test_mpio_overlap_writes(char *filename) +{ + int mpi_size, mpi_rank; + MPI_Comm comm; + MPI_Info info = MPI_INFO_NULL; + int color, mrc; + MPI_File fh; + int i; + int vrfyerrs, nerrs; unsigned char buf[4093]; /* use some prime number for size */ - int bufsize = sizeof(buf); - MPI_Offset stride; - MPI_Offset mpi_off; - MPI_Status mpi_stat; + int bufsize = sizeof(buf); + MPI_Offset stride; + MPI_Offset mpi_off; + MPI_Status mpi_stat; if (VERBOSE_MED) - HDprintf("MPIO independent overlapping writes test on file %s\n", - filename); + HDprintf("MPIO independent overlapping writes test on file %s\n", filename); nerrs = 0; /* set up MPI parameters */ @@ -71,16 +72,15 @@ static int test_mpio_overlap_writes(char *filename) { /* splits processes 0 to n-2 into one comm. and the last one into another */ color = ((mpi_rank < (mpi_size - 1)) ? 0 : 1); - mrc = MPI_Comm_split(MPI_COMM_WORLD, color, mpi_rank, &comm); + mrc = MPI_Comm_split(MPI_COMM_WORLD, color, mpi_rank, &comm); VRFY((mrc == MPI_SUCCESS), "Comm_split succeeded"); if (color == 0) { /* First n-1 processes (color==0) open a file and write it */ - mrc = MPI_File_open(comm, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, - info, &fh); + mrc = MPI_File_open(comm, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh); VRFY((mrc == MPI_SUCCESS), ""); - stride = 1; + stride = 1; mpi_off = mpi_rank * stride; while (mpi_off < MPIO_TEST_WRITE_SIZE) { /* make sure the write does not exceed the TEST_WRITE_SIZE */ @@ -89,9 +89,8 @@ static int test_mpio_overlap_writes(char *filename) { /* set data to some trivial pattern for easy verification */ for (i = 0; i < stride; i++) - buf[i] = (unsigned char) (mpi_off + i); - mrc = MPI_File_write_at(fh, mpi_off, buf, (int) stride, MPI_BYTE, - &mpi_stat); + buf[i] = (unsigned char)(mpi_off + i); + mrc = MPI_File_write_at(fh, mpi_off, buf, (int)stride, MPI_BYTE, &mpi_stat); VRFY((mrc == MPI_SUCCESS), ""); /* move the offset pointer to last byte written by all processes */ @@ -114,10 +113,11 @@ static int test_mpio_overlap_writes(char *filename) { /* sync with the other waiting processes */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc == MPI_SUCCESS), "Sync after writes"); - } else { + } + else { /* last process waits till writes are done, - * then opens file to verify data. - */ + * then opens file to verify data. + */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc == MPI_SUCCESS), "Sync after writes"); @@ -129,18 +129,15 @@ static int test_mpio_overlap_writes(char *filename) { /* make sure it does not read beyond end of data */ if (mpi_off + stride > MPIO_TEST_WRITE_SIZE) stride = MPIO_TEST_WRITE_SIZE - mpi_off; - mrc = MPI_File_read_at(fh, mpi_off, buf, (int) stride, MPI_BYTE, - &mpi_stat); + mrc = MPI_File_read_at(fh, mpi_off, buf, (int)stride, MPI_BYTE, &mpi_stat); VRFY((mrc == MPI_SUCCESS), ""); vrfyerrs = 0; for (i = 0; i < stride; i++) { unsigned char expected; - expected = (unsigned char) (mpi_off + i); - if ((expected != buf[i]) - && (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)) { - HDprintf( - "proc %d: found data error at [%ld], expect %u, got %u\n", - mpi_rank, (long) (mpi_off + i), expected, buf[i]); + expected = (unsigned char)(mpi_off + i); + if ((expected != buf[i]) && (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)) { + HDprintf("proc %d: found data error at [%ld], expect %u, got %u\n", mpi_rank, + (long)(mpi_off + i), expected, buf[i]); } } if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) @@ -157,18 +154,18 @@ static int test_mpio_overlap_writes(char *filename) { } /* - * one more sync to ensure all processes have done reading - * before ending this test. - */ + * one more sync to ensure all processes have done reading + * before ending this test. + */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc == MPI_SUCCESS), "Sync before leaving test"); return (nerrs); } -#define MB 1048576 /* 1024*1024 == 2**20 */ -#define GB 1073741824 /* 1024**3 == 2**30 */ -#define TWO_GB_LESS1 2147483647 /* 2**31 - 1 */ -#define FOUR_GB_LESS1 4294967295L /* 2**32 - 1 */ +#define MB 1048576 /* 1024*1024 == 2**20 */ +#define GB 1073741824 /* 1024**3 == 2**30 */ +#define TWO_GB_LESS1 2147483647 /* 2**31 - 1 */ +#define FOUR_GB_LESS1 4294967295L /* 2**32 - 1 */ /* * Verify that MPI_Offset exceeding 2**31 can be computed correctly. * Print any failure as information only, not as an error so that this @@ -180,23 +177,25 @@ static int test_mpio_overlap_writes(char *filename) { * Then reads the file back in by reverse order, that is process 0 * reads the data of process n-1 and vice versa. */ -static int test_mpio_gb_file(char *filename) { - int mpi_size, mpi_rank; - MPI_Info info = MPI_INFO_NULL; - int mrc; - MPI_File fh; - int i, j, n; - int vrfyerrs; - int writerrs; /* write errors */ - int nerrs; - int ntimes; /* how many times */ - char *buf = NULL; - char expected; +static int +test_mpio_gb_file(char *filename) +{ + int mpi_size, mpi_rank; + MPI_Info info = MPI_INFO_NULL; + int mrc; + MPI_File fh; + int i, j, n; + int vrfyerrs; + int writerrs; /* write errors */ + int nerrs; + int ntimes; /* how many times */ + char * buf = NULL; + char expected; MPI_Offset size; MPI_Offset mpi_off; MPI_Offset mpi_off_old; MPI_Status mpi_stat; - int is_signed, sizeof_mpi_offset; + int is_signed, sizeof_mpi_offset; nerrs = 0; /* set up MPI parameters */ @@ -207,73 +206,74 @@ static int test_mpio_gb_file(char *filename) { HDprintf("MPI_Offset range test\n"); /* figure out the signness and sizeof MPI_Offset */ - mpi_off = 0; - is_signed = ((MPI_Offset)(mpi_off - 1)) < 0; - sizeof_mpi_offset = (int) (sizeof(MPI_Offset)); + mpi_off = 0; + is_signed = ((MPI_Offset)(mpi_off - 1)) < 0; + sizeof_mpi_offset = (int)(sizeof(MPI_Offset)); /* - * Verify the sizeof MPI_Offset and correctness of handling multiple GB - * sizes. - */ + * Verify the sizeof MPI_Offset and correctness of handling multiple GB + * sizes. + */ if (MAINPROCESS) { /* only process 0 needs to check it*/ - HDprintf("MPI_Offset is %s %d bytes integeral type\n", - is_signed ? "signed" : "unsigned", (int) sizeof(MPI_Offset)); + HDprintf("MPI_Offset is %s %d bytes integeral type\n", is_signed ? "signed" : "unsigned", + (int)sizeof(MPI_Offset)); if (sizeof_mpi_offset <= 4 && is_signed) { HDprintf("Skipped 2GB range test " - "because MPI_Offset cannot support it\n"); - } else { + "because MPI_Offset cannot support it\n"); + } + else { /* verify correctness of assigning 2GB sizes */ - mpi_off = 2 * 1024 * (MPI_Offset) MB; + mpi_off = 2 * 1024 * (MPI_Offset)MB; INFO((mpi_off > 0), "2GB OFFSET assignment no overflow"); - INFO((mpi_off-1)==TWO_GB_LESS1, "2GB OFFSET assignment succeed"); + INFO((mpi_off - 1) == TWO_GB_LESS1, "2GB OFFSET assignment succeed"); /* verify correctness of increasing from below 2 GB to above 2GB */ mpi_off = TWO_GB_LESS1; for (i = 0; i < 3; i++) { mpi_off_old = mpi_off; - mpi_off = mpi_off + 1; + mpi_off = mpi_off + 1; /* no overflow */ INFO((mpi_off > 0), "2GB OFFSET increment no overflow"); /* correct inc. */ - INFO((mpi_off - 1) == mpi_off_old, - "2GB OFFSET increment succeed"); + INFO((mpi_off - 1) == mpi_off_old, "2GB OFFSET increment succeed"); } } if (sizeof_mpi_offset <= 4) { HDprintf("Skipped 4GB range test " - "because MPI_Offset cannot support it\n"); - } else { + "because MPI_Offset cannot support it\n"); + } + else { /* verify correctness of assigning 4GB sizes */ - mpi_off = 4 * 1024 * (MPI_Offset) MB; + mpi_off = 4 * 1024 * (MPI_Offset)MB; INFO((mpi_off > 0), "4GB OFFSET assignment no overflow"); - INFO((mpi_off-1)==FOUR_GB_LESS1, "4GB OFFSET assignment succeed"); + INFO((mpi_off - 1) == FOUR_GB_LESS1, "4GB OFFSET assignment succeed"); /* verify correctness of increasing from below 4 GB to above 4 GB */ mpi_off = FOUR_GB_LESS1; for (i = 0; i < 3; i++) { mpi_off_old = mpi_off; - mpi_off = mpi_off + 1; + mpi_off = mpi_off + 1; /* no overflow */ INFO((mpi_off > 0), "4GB OFFSET increment no overflow"); /* correct inc. */ - INFO((mpi_off - 1) == mpi_off_old, - "4GB OFFSET increment succeed"); + INFO((mpi_off - 1) == mpi_off_old, "4GB OFFSET increment succeed"); } } } /* - * Verify if we can write to a file of multiple GB sizes. - */ + * Verify if we can write to a file of multiple GB sizes. + */ if (VERBOSE_MED) HDprintf("MPIO GB file test %s\n", filename); if (sizeof_mpi_offset <= 4) { HDprintf("Skipped GB file range test " - "because MPI_Offset cannot support it\n"); - } else { - buf = (char *) HDmalloc(MB); + "because MPI_Offset cannot support it\n"); + } + else { + buf = (char *)HDmalloc(MB); VRFY((buf != NULL), "malloc succeed"); /* open a new file. Remove it first in case it exists. */ @@ -282,34 +282,29 @@ static int test_mpio_gb_file(char *filename) { MPI_File_delete(filename, MPI_INFO_NULL); MPI_Barrier(MPI_COMM_WORLD); /* prevent racing condition */ - mrc = MPI_File_open(MPI_COMM_WORLD, filename, - MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh); + mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh); VRFY((mrc == MPI_SUCCESS), "MPI_FILE_OPEN"); HDprintf("MPIO GB file write test %s\n", filename); /* instead of writing every bytes of the file, we will just write - * some data around the 2 and 4 GB boundaries. That should cover - * potential integer overflow and filesystem size limits. - */ + * some data around the 2 and 4 GB boundaries. That should cover + * potential integer overflow and filesystem size limits. + */ writerrs = 0; for (n = 2; n <= 4; n += 2) { ntimes = GB / MB * n / mpi_size + 1; for (i = ntimes - 2; i <= ntimes; i++) { - mpi_off = (i * mpi_size + mpi_rank) * (MPI_Offset) MB; + mpi_off = (i * mpi_size + mpi_rank) * (MPI_Offset)MB; if (VERBOSE_MED) - HDfprintf(stdout, - "proc %d: write to mpi_off=%016llx, %lld\n", - mpi_rank, mpi_off, mpi_off); + HDfprintf(stdout, "proc %d: write to mpi_off=%016llx, %lld\n", mpi_rank, mpi_off, + mpi_off); /* set data to some trivial pattern for easy verification */ for (j = 0; j < MB; j++) *(buf + j) = (int8_t)(i * mpi_size + mpi_rank); if (VERBOSE_MED) - HDfprintf(stdout, - "proc %d: writing %d bytes at offset %lld\n", - mpi_rank, MB, mpi_off); - mrc = MPI_File_write_at(fh, mpi_off, buf, MB, MPI_BYTE, - &mpi_stat); + HDfprintf(stdout, "proc %d: writing %d bytes at offset %lld\n", mpi_rank, MB, mpi_off); + mrc = MPI_File_write_at(fh, mpi_off, buf, MB, MPI_BYTE, &mpi_stat); INFO((mrc == MPI_SUCCESS), "GB size file write"); if (mrc != MPI_SUCCESS) writerrs++; @@ -324,42 +319,34 @@ static int test_mpio_gb_file(char *filename) { VRFY((mrc == MPI_SUCCESS), "Sync after writes"); /* - * Verify if we can read the multiple GB file just created. - */ + * Verify if we can read the multiple GB file just created. + */ /* open it again to verify the data written */ /* but only if there was no write errors */ HDprintf("MPIO GB file read test %s\n", filename); if (errors_sum(writerrs) > 0) { - HDprintf("proc %d: Skip read test due to previous write errors\n", - mpi_rank); + HDprintf("proc %d: Skip read test due to previous write errors\n", mpi_rank); goto finish; } - mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, - &fh); + mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh); VRFY((mrc == MPI_SUCCESS), ""); /* Only read back parts of the file that have been written. */ for (n = 2; n <= 4; n += 2) { ntimes = GB / MB * n / mpi_size + 1; for (i = ntimes - 2; i <= ntimes; i++) { - mpi_off = (i * mpi_size + (mpi_size - mpi_rank - 1)) - * (MPI_Offset) MB; + mpi_off = (i * mpi_size + (mpi_size - mpi_rank - 1)) * (MPI_Offset)MB; if (VERBOSE_MED) - HDfprintf(stdout, - "proc %d: read from mpi_off=%016llx, %lld\n", - mpi_rank, mpi_off, mpi_off); - mrc = MPI_File_read_at(fh, mpi_off, buf, MB, MPI_BYTE, - &mpi_stat); + HDfprintf(stdout, "proc %d: read from mpi_off=%016llx, %lld\n", mpi_rank, mpi_off, + mpi_off); + mrc = MPI_File_read_at(fh, mpi_off, buf, MB, MPI_BYTE, &mpi_stat); INFO((mrc == MPI_SUCCESS), "GB size file read"); expected = (int8_t)(i * mpi_size + (mpi_size - mpi_rank - 1)); vrfyerrs = 0; for (j = 0; j < MB; j++) { - if ((*(buf + j) != expected) - && (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)) { - HDprintf( - "proc %d: found data error at [%ld+%d], expect %d, got %d\n", - mpi_rank, (long) mpi_off, j, expected, - *(buf + j)); + if ((*(buf + j) != expected) && (vrfyerrs++ < MAX_ERR_REPORT || VERBOSE_MED)) { + HDprintf("proc %d: found data error at [%ld+%d], expect %d, got %d\n", mpi_rank, + (long)mpi_off, j, expected, *(buf + j)); } } if (vrfyerrs > MAX_ERR_REPORT && !VERBOSE_MED) @@ -374,23 +361,21 @@ static int test_mpio_gb_file(char *filename) { VRFY((mrc == MPI_SUCCESS), "MPI_FILE_CLOSE"); /* - * one more sync to ensure all processes have done reading - * before ending this test. - */ + * one more sync to ensure all processes have done reading + * before ending this test. + */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc == MPI_SUCCESS), "Sync before leaving test"); HDprintf("Test if MPI_File_get_size works correctly with %s\n", filename); - mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, - &fh); + mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh); VRFY((mrc == MPI_SUCCESS), ""); if (MAINPROCESS) { /* only process 0 needs to check it*/ mrc = MPI_File_get_size(fh, &size); VRFY((mrc == MPI_SUCCESS), ""); - VRFY((size == mpi_off+MB), - "MPI_File_get_size doesn't return correct file size."); + VRFY((size == mpi_off + MB), "MPI_File_get_size doesn't return correct file size."); } /* close file and free the communicator */ @@ -398,14 +383,15 @@ static int test_mpio_gb_file(char *filename) { VRFY((mrc == MPI_SUCCESS), "MPI_FILE_CLOSE"); /* - * one more sync to ensure all processes have done reading - * before ending this test. - */ + * one more sync to ensure all processes have done reading + * before ending this test. + */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc == MPI_SUCCESS), "Sync before leaving test"); } - finish: if (buf) +finish: + if (buf) HDfree(buf); return (nerrs); } @@ -427,26 +413,28 @@ static int test_mpio_gb_file(char *filename) { * Each process writes something, then reads all data back. */ -#define DIMSIZE 32 /* Dimension size. */ -#define PRINTID HDprintf("Proc %d: ", mpi_rank) -#define USENONE 0 -#define USEATOM 1 /* request atomic I/O */ -#define USEFSYNC 2 /* request file_sync */ - -static int test_mpio_1wMr(char *filename, int special_request) { - char hostname[128]; - int mpi_size, mpi_rank; - MPI_File fh; - char mpi_err_str[MPI_MAX_ERROR_STRING]; - int mpi_err_strlen; - int mpi_err; +#define DIMSIZE 32 /* Dimension size. */ +#define PRINTID HDprintf("Proc %d: ", mpi_rank) +#define USENONE 0 +#define USEATOM 1 /* request atomic I/O */ +#define USEFSYNC 2 /* request file_sync */ + +static int +test_mpio_1wMr(char *filename, int special_request) +{ + char hostname[128]; + int mpi_size, mpi_rank; + MPI_File fh; + char mpi_err_str[MPI_MAX_ERROR_STRING]; + int mpi_err_strlen; + int mpi_err; unsigned char writedata[DIMSIZE], readdata[DIMSIZE]; unsigned char expect_val; - int i, irank; - int nerrs = 0; /* number of errors */ - int atomicity; - MPI_Offset mpi_off; - MPI_Status mpi_stat; + int i, irank; + int nerrs = 0; /* number of errors */ + int atomicity; + MPI_Offset mpi_off; + MPI_Status mpi_stat; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -460,7 +448,7 @@ static int test_mpio_1wMr(char *filename, int special_request) { /* show the hostname so that we can tell where the processes are running */ if (VERBOSE_DEF) { #ifdef H5_HAVE_GETHOSTNAME - if(HDgethostname(hostname, sizeof(hostname)) < 0) { + if (HDgethostname(hostname, sizeof(hostname)) < 0) { HDprintf("gethostname failed\n"); hostname[0] = '\0'; } @@ -478,9 +466,8 @@ static int test_mpio_1wMr(char *filename, int special_request) { MPI_File_delete(filename, MPI_INFO_NULL); MPI_Barrier(MPI_COMM_WORLD); /* prevent racing condition */ - if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, - MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fh)) - != MPI_SUCCESS) { + if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, + &fh)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); PRINTID; HDprintf("MPI_File_open failed (%s)\n", mpi_err_str); @@ -489,9 +476,9 @@ static int test_mpio_1wMr(char *filename, int special_request) { if (special_request & USEATOM) { /* ================================================== - * Set atomcity to true (1). A POSIX compliant filesystem - * should not need this. - * ==================================================*/ + * Set atomcity to true (1). A POSIX compliant filesystem + * should not need this. + * ==================================================*/ if ((mpi_err = MPI_File_get_atomicity(fh, &atomicity)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); PRINTID; @@ -521,26 +508,26 @@ static int test_mpio_1wMr(char *filename, int special_request) { } /* ================================================== - * Each process calculates what to write but - * only process irank(0) writes. - * ==================================================*/ + * Each process calculates what to write but + * only process irank(0) writes. + * ==================================================*/ irank = 0; for (i = 0; i < DIMSIZE; i++) - writedata[i] = (uint8_t)(irank * DIMSIZE + i); + writedata[i] = (uint8_t)(irank * DIMSIZE + i); mpi_off = irank * DIMSIZE; /* Only one process writes */ if (mpi_rank == irank) { if (VERBOSE_HI) { PRINTID; - HDprintf("wrote %d bytes at %ld\n", DIMSIZE, (long) mpi_off); + HDprintf("wrote %d bytes at %ld\n", DIMSIZE, (long)mpi_off); } - if ((mpi_err = MPI_File_write_at(fh, mpi_off, writedata, DIMSIZE, - MPI_BYTE, &mpi_stat)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_write_at(fh, mpi_off, writedata, DIMSIZE, MPI_BYTE, &mpi_stat)) != + MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); PRINTID; - HDprintf("MPI_File_write_at offset(%ld), bytes (%d), failed (%s)\n", - (long) mpi_off, DIMSIZE, mpi_err_str); + HDprintf("MPI_File_write_at offset(%ld), bytes (%d), failed (%s)\n", (long)mpi_off, DIMSIZE, + mpi_err_str); return 1; }; }; @@ -555,9 +542,9 @@ static int test_mpio_1wMr(char *filename, int special_request) { if (special_request & USEFSYNC) { /* ================================================== - * Do a file sync. A POSIX compliant filesystem - * should not need this. - * ==================================================*/ + * Do a file sync. A POSIX compliant filesystem + * should not need this. + * ==================================================*/ if (VERBOSE_HI) HDprintf("Apply MPI_File_sync\n"); /* call file_sync to force the write out */ @@ -584,24 +571,22 @@ static int test_mpio_1wMr(char *filename, int special_request) { } /* ================================================== - * Each process reads what process 0 wrote and verify. - * ==================================================*/ - irank = 0; + * Each process reads what process 0 wrote and verify. + * ==================================================*/ + irank = 0; mpi_off = irank * DIMSIZE; - if ((mpi_err = MPI_File_read_at(fh, mpi_off, readdata, DIMSIZE, MPI_BYTE, - &mpi_stat)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_read_at(fh, mpi_off, readdata, DIMSIZE, MPI_BYTE, &mpi_stat)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); PRINTID; - HDprintf("MPI_File_read_at offset(%ld), bytes (%d), failed (%s)\n", - (long) mpi_off, DIMSIZE, mpi_err_str); + HDprintf("MPI_File_read_at offset(%ld), bytes (%d), failed (%s)\n", (long)mpi_off, DIMSIZE, + mpi_err_str); return 1; }; for (i = 0; i < DIMSIZE; i++) { expect_val = (uint8_t)(irank * DIMSIZE + i); if (readdata[i] != expect_val) { PRINTID; - HDprintf("read data[%d:%d] got %02x, expect %02x\n", irank, i, - readdata[i], expect_val); + HDprintf("read data[%d:%d] got %02x, expect %02x\n", irank, i, readdata[i], expect_val); nerrs++; } } @@ -657,41 +642,44 @@ static int test_mpio_1wMr(char *filename, int special_request) { the following values were obtained: 1,2,0 - The problem is that the displacement of the second derived datatype(datatype2) which formed the final derived datatype(advtype) - has been put after the basic datatype(MPI_BYTE) of datatype2. This is a bug. + The problem is that the displacement of the second derived datatype(datatype2) which formed the final derived + datatype(advtype) has been put after the basic datatype(MPI_BYTE) of datatype2. This is a bug. 2. This test will verify whether the complicated derived datatype is working on the current platform. - If this bug has been fixed in the previous not-working package, this test will issue a HDprintf message to tell the developer to change - the configuration specific file of HDF5 so that we can change our configurationsetting to support collective IO for irregular selections. + If this bug has been fixed in the previous not-working package, this test will issue a HDprintf message to + tell the developer to change the configuration specific file of HDF5 so that we can change our + configurationsetting to support collective IO for irregular selections. - If it turns out that the previous working MPI-IO package no longer works, this test will also issue a message to inform the corresponding failure so that - we can turn off collective IO support for irregular selections. + If it turns out that the previous working MPI-IO package no longer works, this test will also issue a message + to inform the corresponding failure so that we can turn off collective IO support for irregular selections. */ -static int test_mpio_derived_dtype(char *filename) { +static int +test_mpio_derived_dtype(char *filename) +{ - MPI_File fh; - char mpi_err_str[MPI_MAX_ERROR_STRING]; - int mpi_err_strlen; - int mpi_err; - int i; + MPI_File fh; + char mpi_err_str[MPI_MAX_ERROR_STRING]; + int mpi_err_strlen; + int mpi_err; + int i; MPI_Datatype etype, filetype; MPI_Datatype adv_filetype, bas_filetype[2]; MPI_Datatype filetypenew; - MPI_Offset disp; - MPI_Status Status; - MPI_Aint adv_disp[2]; - MPI_Aint offsets[1]; - int blocklens[1], adv_blocklens[2]; - int count, outcount; - int retcode; + MPI_Offset disp; + MPI_Status Status; + MPI_Aint adv_disp[2]; + MPI_Aint offsets[1]; + int blocklens[1], adv_blocklens[2]; + int count, outcount; + int retcode; int mpi_rank, mpi_size; - char buf[3], outbuf[3] = { 0 }; + char buf[3], outbuf[3] = {0}; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -699,23 +687,21 @@ static int test_mpio_derived_dtype(char *filename) { for (i = 0; i < 3; i++) buf[i] = (char)(i + 1); - if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, - MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fh)) - != MPI_SUCCESS) { + if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, + &fh)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_File_open failed (%s)\n", mpi_err_str); return 1; } - disp = 0; + disp = 0; etype = MPI_BYTE; - count = 1; + count = 1; blocklens[0] = 1; - offsets[0] = 0; + offsets[0] = 0; - if ((mpi_err = MPI_Type_create_hindexed(count, blocklens, offsets, MPI_BYTE, - &filetype)) != MPI_SUCCESS) { + if ((mpi_err = MPI_Type_create_hindexed(count, blocklens, offsets, MPI_BYTE, &filetype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); return 1; @@ -727,11 +713,11 @@ static int test_mpio_derived_dtype(char *filename) { return 1; } - count = 1; + count = 1; blocklens[0] = 1; - offsets[0] = 1; - if ((mpi_err = MPI_Type_create_hindexed(count, blocklens, offsets, MPI_BYTE, - &filetypenew)) != MPI_SUCCESS) { + offsets[0] = 1; + if ((mpi_err = MPI_Type_create_hindexed(count, blocklens, offsets, MPI_BYTE, &filetypenew)) != + MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); return 1; @@ -743,16 +729,16 @@ static int test_mpio_derived_dtype(char *filename) { return 1; } - outcount = 2; + outcount = 2; adv_blocklens[0] = 1; adv_blocklens[1] = 1; - adv_disp[0] = 0; - adv_disp[1] = 1; - bas_filetype[0] = filetype; - bas_filetype[1] = filetypenew; + adv_disp[0] = 0; + adv_disp[1] = 1; + bas_filetype[0] = filetype; + bas_filetype[1] = filetypenew; - if ((mpi_err = MPI_Type_create_struct(outcount, adv_blocklens, adv_disp, - bas_filetype, &adv_filetype)) != MPI_SUCCESS) { + if ((mpi_err = MPI_Type_create_struct(outcount, adv_blocklens, adv_disp, bas_filetype, &adv_filetype)) != + MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_Type_create_struct failed (%s)\n", mpi_err_str); return 1; @@ -763,15 +749,14 @@ static int test_mpio_derived_dtype(char *filename) { return 1; } - if ((mpi_err = MPI_File_set_view(fh, disp, etype, adv_filetype, "native", - MPI_INFO_NULL)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_set_view(fh, disp, etype, adv_filetype, "native", MPI_INFO_NULL)) != + MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_File_set_view failed (%s)\n", mpi_err_str); return 1; } - if ((mpi_err = MPI_File_write(fh, buf, 3, MPI_BYTE, &Status)) - != MPI_SUCCESS) { + if ((mpi_err = MPI_File_write(fh, buf, 3, MPI_BYTE, &Status)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_File_write failed (%s)\n", mpi_err_str); return 1; @@ -783,21 +768,19 @@ static int test_mpio_derived_dtype(char *filename) { return 1; } - if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, - MPI_INFO_NULL, &fh)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh)) != + MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_File_open failed (%s)\n", mpi_err_str); return 1; } - if ((mpi_err = MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native", - MPI_INFO_NULL)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_File_set_view failed (%s)\n", mpi_err_str); return 1; } - if ((mpi_err = MPI_File_read(fh, outbuf, 3, MPI_BYTE, &Status)) - != MPI_SUCCESS) { + if ((mpi_err = MPI_File_read(fh, outbuf, 3, MPI_BYTE, &Status)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_File_read failed (%s)\n", mpi_err_str); return 1; @@ -805,7 +788,8 @@ static int test_mpio_derived_dtype(char *filename) { if (outbuf[2] == 2) { retcode = 0; - } else { + } + else { /* if(mpi_rank == 0) { HDprintf("complicated derived datatype is NOT working at this platform\n"); HDprintf("go back to hdf5/config and find the corresponding\n"); @@ -824,8 +808,7 @@ static int test_mpio_derived_dtype(char *filename) { mpi_err = MPI_Barrier(MPI_COMM_WORLD); if (retcode == -1) { if (mpi_rank == 0) { - HDprintf( - "Complicated derived datatype is NOT working at this platform\n"); + HDprintf("Complicated derived datatype is NOT working at this platform\n"); HDprintf(" Please report to help@hdfgroup.org about this problem.\n"); } retcode = 1; @@ -851,29 +834,33 @@ static int test_mpio_derived_dtype(char *filename) { 2. This test will fail with the MPI-IO package that doesn't support this. For example, mpich 1.2.6. - If this bug has been fixed in the previous not-working package, this test will issue a HDprintf message to tell the developer to change - the configuration specific file of HDF5 so that we can change our configurationsetting to support special collective IO; currently only special collective IO. + If this bug has been fixed in the previous not-working package, this test will issue a HDprintf message to + tell the developer to change the configuration specific file of HDF5 so that we can change our + configurationsetting to support special collective IO; currently only special collective IO. - If it turns out that the previous working MPI-IO package no longer works, this test will also issue a message to inform the corresponding failure so that - we can turn off the support for special collective IO; currently only special collective IO. + If it turns out that the previous working MPI-IO package no longer works, this test will also issue a message + to inform the corresponding failure so that we can turn off the support for special collective IO; currently + only special collective IO. */ -static int test_mpio_special_collective(char *filename) { - int mpi_size, mpi_rank; - MPI_File fh; +static int +test_mpio_special_collective(char *filename) +{ + int mpi_size, mpi_rank; + MPI_File fh; MPI_Datatype etype, buftype, filetype; - char mpi_err_str[MPI_MAX_ERROR_STRING]; - int mpi_err_strlen; - int mpi_err; - char writedata[2 * DIMSIZE]; - char filerep[7] = "native"; - int i; - int count, bufcount; - int blocklens[2]; - MPI_Aint offsets[2]; - MPI_Offset mpi_off = 0; - MPI_Status mpi_stat; - int retcode = 0; + char mpi_err_str[MPI_MAX_ERROR_STRING]; + int mpi_err_strlen; + int mpi_err; + char writedata[2 * DIMSIZE]; + char filerep[7] = "native"; + int i; + int count, bufcount; + int blocklens[2]; + MPI_Aint offsets[2]; + MPI_Offset mpi_off = 0; + MPI_Status mpi_stat; + int retcode = 0; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -881,22 +868,21 @@ static int test_mpio_special_collective(char *filename) { /* create MPI data type */ etype = MPI_BYTE; if (mpi_rank == 0 || mpi_rank == 1) { - count = DIMSIZE; + count = DIMSIZE; bufcount = 1; } /* end if */ else { - count = 0; + count = 0; bufcount = 0; } /* end else */ blocklens[0] = count; - offsets[0] = mpi_rank * count; + offsets[0] = mpi_rank * count; blocklens[1] = count; - offsets[1] = (mpi_size + mpi_rank) * count; + offsets[1] = (mpi_size + mpi_rank) * count; if (count != 0) { - if ((mpi_err = MPI_Type_create_hindexed(2, blocklens, offsets, etype, - &filetype)) != MPI_SUCCESS) { + if ((mpi_err = MPI_Type_create_hindexed(2, blocklens, offsets, etype, &filetype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); return 1; @@ -908,8 +894,7 @@ static int test_mpio_special_collective(char *filename) { return 1; } /* end if */ - if ((mpi_err = MPI_Type_create_hindexed(2, blocklens, offsets, etype, - &buftype)) != MPI_SUCCESS) { + if ((mpi_err = MPI_Type_create_hindexed(2, blocklens, offsets, etype, &buftype)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_Type_contiguous failed (%s)\n", mpi_err_str); return 1; @@ -920,16 +905,15 @@ static int test_mpio_special_collective(char *filename) { HDprintf("MPI_Type_commit failed (%s)\n", mpi_err_str); return 1; } /* end if */ - } /* end if */ + } /* end if */ else { filetype = MPI_BYTE; - buftype = MPI_BYTE; + buftype = MPI_BYTE; } /* end else */ /* Open a file */ - if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, - MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fh)) - != MPI_SUCCESS) { + if ((mpi_err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, + &fh)) != MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_File_open failed (%s)\n", mpi_err_str); return 1; @@ -937,22 +921,22 @@ static int test_mpio_special_collective(char *filename) { /* each process writes some data */ for (i = 0; i < 2 * DIMSIZE; i++) - writedata[i] = (char) (mpi_rank * DIMSIZE + i); + writedata[i] = (char)(mpi_rank * DIMSIZE + i); /* Set the file view */ - if ((mpi_err = MPI_File_set_view(fh, mpi_off, MPI_BYTE, filetype, filerep, - MPI_INFO_NULL)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_set_view(fh, mpi_off, MPI_BYTE, filetype, filerep, MPI_INFO_NULL)) != + MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); HDprintf("MPI_File_set_view failed (%s)\n", mpi_err_str); return 1; } /* end if */ /* Collectively write into the file */ - if ((mpi_err = MPI_File_write_at_all(fh, mpi_off, writedata, bufcount, - buftype, &mpi_stat)) != MPI_SUCCESS) { + if ((mpi_err = MPI_File_write_at_all(fh, mpi_off, writedata, bufcount, buftype, &mpi_stat)) != + MPI_SUCCESS) { MPI_Error_string(mpi_err, mpi_err_str, &mpi_err_strlen); - HDprintf("MPI_File_write_at offset(%ld), bytes (%d), failed (%s)\n", - (long) mpi_off, bufcount, mpi_err_str); + HDprintf("MPI_File_write_at offset(%ld), bytes (%d), failed (%s)\n", (long)mpi_off, bufcount, + mpi_err_str); return 1; } /* end if */ @@ -980,41 +964,44 @@ static int test_mpio_special_collective(char *filename) { /* * parse the command line options */ -static int parse_options(int argc, char **argv) { +static int +parse_options(int argc, char **argv) +{ while (--argc) { if (**(++argv) != '-') { break; - } else { + } + else { switch (*(*argv + 1)) { - case 'v': - if (*((*argv + 1) + 1)) - ParseTestVerbosity((*argv + 1) + 1); - else - SetTestVerbosity(VERBO_MED); - break; - case 'f': - if (--argc < 1) { - nerrors++; + case 'v': + if (*((*argv + 1) + 1)) + ParseTestVerbosity((*argv + 1) + 1); + else + SetTestVerbosity(VERBO_MED); + break; + case 'f': + if (--argc < 1) { + nerrors++; + return (1); + } + if (**(++argv) == '-') { + nerrors++; + return (1); + } + paraprefix = *argv; + break; + case 'h': /* print help message--return with nerrors set */ return (1); - } - if (**(++argv) == '-') { + default: nerrors++; return (1); - } - paraprefix = *argv; - break; - case 'h': /* print help message--return with nerrors set */ - return (1); - default: - nerrors++; - return (1); } } } /*while*/ /* compose the test filenames */ { - int i, n; + int i, n; hid_t plist; plist = H5Pcreate(H5P_FILE_ACCESS); @@ -1022,8 +1009,7 @@ static int parse_options(int argc, char **argv) { n = sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; /* exclude the NULL */ for (i = 0; i < n; i++) - if (h5_fixname(FILENAME[i], plist, filenames[i], - sizeof(filenames[i])) == NULL) { + if (h5_fixname(FILENAME[i], plist, filenames[i], sizeof(filenames[i])) == NULL) { HDprintf("h5_fixname failed\n"); nerrors++; return (1); @@ -1042,7 +1028,9 @@ static int parse_options(int argc, char **argv) { /* * Show command usage */ -static void usage(void) { +static void +usage(void) +{ HDprintf("Usage: t_mpi [-v] [-f ]\n"); HDprintf("\t-v\tset verbose level (0-9,l,m,h)\n"); HDprintf("\t-f \tfilename prefix\n"); @@ -1052,13 +1040,17 @@ static void usage(void) { /* * return the sum of all errors. */ -static int errors_sum(int nerrs) { +static int +errors_sum(int nerrs) +{ int temp; MPI_Allreduce(&nerrs, &temp, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); return (temp); } -int main(int argc, char **argv) { +int +main(int argc, char **argv) +{ int mpi_size, mpi_rank; /* mpi variables */ int ret_code; @@ -1067,10 +1059,10 @@ int main(int argc, char **argv) { MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* Attempt to turn off atexit post processing so that in case errors - * happen during the test and the process is aborted, it will not get - * hang in the atexit post processing in which it may try to make MPI - * calls. By then, MPI calls may not work. - */ + * happen during the test and the process is aborted, it will not get + * hang in the atexit post processing in which it may try to make MPI + * calls. By then, MPI calls may not work. + */ if (H5dont_atexit() < 0) { HDprintf("Failed to turn off atexit processing. Continue.\n"); }; @@ -1097,8 +1089,8 @@ int main(int argc, char **argv) { ALARM_ON; /*======================================= - * MPIO 1 write Many read test - *=======================================*/ + * MPIO 1 write Many read test + *=======================================*/ MPI_BANNER("MPIO 1 write Many read test..."); ret_code = test_mpio_1wMr(filenames[0], USENONE); ret_code = errors_sum(ret_code); @@ -1128,8 +1120,8 @@ int main(int argc, char **argv) { } /*======================================= - * MPIO MPIO File size range test - *=======================================*/ + * MPIO MPIO File size range test + *=======================================*/ MPI_BANNER("MPIO File size range test..."); #ifndef H5_HAVE_WIN32_API ret_code = test_mpio_gb_file(filenames[0]); @@ -1139,13 +1131,13 @@ int main(int argc, char **argv) { nerrors += ret_code; } #else - if (mpi_rank==0) + if (mpi_rank == 0) HDprintf(" will be skipped on Windows (JIRA HDDFV-8064)\n"); #endif /*======================================= - * MPIO independent overlapping writes - *=======================================*/ + * MPIO independent overlapping writes + *=======================================*/ MPI_BANNER("MPIO independent overlapping writes..."); ret_code = test_mpio_overlap_writes(filenames[0]); ret_code = errors_sum(ret_code); @@ -1155,8 +1147,8 @@ int main(int argc, char **argv) { } /*======================================= - * MPIO complicated derived datatype test - *=======================================*/ + * MPIO complicated derived datatype test + *=======================================*/ MPI_BANNER("MPIO complicated derived datatype test..."); ret_code = test_mpio_derived_dtype(filenames[0]); ret_code = errors_sum(ret_code); @@ -1166,8 +1158,8 @@ int main(int argc, char **argv) { } /*======================================= - * MPIO special collective IO test - *=======================================*/ + * MPIO special collective IO test + *=======================================*/ if (mpi_size < 4) { MPI_BANNER("MPIO special collective io test SKIPPED."); if (mpi_rank == 0) @@ -1179,16 +1171,17 @@ int main(int argc, char **argv) { MPI_BANNER("MPIO special collective io test..."); ret_code = test_mpio_special_collective(filenames[0]); - sc_finish: ret_code = errors_sum(ret_code); +sc_finish: + ret_code = errors_sum(ret_code); if (mpi_rank == 0 && ret_code > 0) { HDprintf("***FAILED with %d total errors\n", ret_code); nerrors += ret_code; } - finish: +finish: /* make sure all processes are finished before final report, cleanup - * and exit. - */ + * and exit. + */ MPI_Barrier(MPI_COMM_WORLD); if (MAINPROCESS) { /* only process 0 reports */ HDprintf("===================================\n"); @@ -1213,4 +1206,3 @@ int main(int argc, char **argv) { /* cannot just return (nerrors) because exit code is limited to 1byte */ return (nerrors != 0); } - diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c index 27b561b..f21726a 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -23,17 +23,12 @@ */ #include "h5test.h" -const char *FILENAME[] = { - "flush", - "noflush", - NULL -}; +const char *FILENAME[] = {"flush", "noflush", NULL}; -static int data_g[100][100]; +static int data_g[100][100]; -#define N_GROUPS 100 +#define N_GROUPS 100 - /*------------------------------------------------------------------------- * Function: create_test_file * @@ -50,51 +45,51 @@ static int data_g[100][100]; static hid_t create_test_file(char *name, hid_t fapl_id) { - hid_t fid = H5I_INVALID_HID; - hid_t dcpl_id = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t top_level_gid = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t dxpl_id = H5I_INVALID_HID; - hsize_t dims[2] = {100, 100}; - hsize_t chunk_dims[2] = {5, 5}; - hsize_t i, j; + hid_t fid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t top_level_gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hsize_t dims[2] = {100, 100}; + hsize_t chunk_dims[2] = {5, 5}; + hsize_t i, j; - if((fid = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((fid = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) goto error; /* Create a chunked dataset */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) goto error; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) goto error; /* Write some data */ - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) data_g[i][j] = (int)(i + (i * j) + j); - if(H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) goto error; /* Create some groups */ - if((top_level_gid = H5Gcreate2(fid, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((top_level_gid = H5Gcreate2(fid, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < N_GROUPS; i++) { + for (i = 0; i < N_GROUPS; i++) { HDsprintf(name, "grp%02u", (unsigned)i); - if((gid = H5Gcreate2(top_level_gid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(top_level_gid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; } @@ -104,7 +99,6 @@ error: return H5I_INVALID_HID; } /* end create_test_file() */ - /*------------------------------------------------------------------------- * Function: main * @@ -118,33 +112,33 @@ error: *------------------------------------------------------------------------- */ int -main(int argc, char* argv[]) +main(int argc, char *argv[]) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t fapl_id = H5I_INVALID_HID; - MPI_File *mpifh_p = NULL; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + MPI_File * mpifh_p = NULL; char name[1024]; - const char *envval = NULL; + const char *envval = NULL; int mpi_size; int mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; MPI_Init(&argc, &argv); MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - if(mpi_rank == 0) + if (mpi_rank == 0) TESTING("H5Fflush (part1)"); /* Don't run using the split VFD */ envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL) + if (envval == NULL) envval = "nomatch"; - if(!HDstrcmp(envval, "split")) { - if(mpi_rank == 0) { + if (!HDstrcmp(envval, "split")) { + if (mpi_rank == 0) { SKIPPED(); HDputs(" Test not compatible with current Virtual File Driver"); } @@ -152,25 +146,25 @@ main(int argc, char* argv[]) HDexit(EXIT_FAILURE); } - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_fapl_mpio(fapl_id, comm, info) < 0) + if (H5Pset_fapl_mpio(fapl_id, comm, info) < 0) goto error; /* Create the file */ h5_fixname(FILENAME[0], fapl_id, name, sizeof(name)); - if((fid1 = create_test_file(name, fapl_id)) < 0) + if ((fid1 = create_test_file(name, fapl_id)) < 0) goto error; /* Flush and exit without closing the library */ - if(H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) goto error; /* Create the other file which will not be flushed */ h5_fixname(FILENAME[1], fapl_id, name, sizeof(name)); - if((fid2 = create_test_file(name, fapl_id)) < 0) + if ((fid2 = create_test_file(name, fapl_id)) < 0) goto error; - if(mpi_rank == 0) + if (mpi_rank == 0) PASSED(); HDfflush(stdout); @@ -184,15 +178,15 @@ main(int argc, char* argv[]) */ /* Close file 1 */ - if(H5Fget_vfd_handle(fid1, fapl_id, (void **)&mpifh_p) < 0) + if (H5Fget_vfd_handle(fid1, fapl_id, (void **)&mpifh_p) < 0) goto error; - if(MPI_File_close(mpifh_p) != MPI_SUCCESS) + if (MPI_File_close(mpifh_p) != MPI_SUCCESS) goto error; /* Close file 2 */ - if(H5Fget_vfd_handle(fid2, fapl_id, (void **)&mpifh_p) < 0) + if (H5Fget_vfd_handle(fid2, fapl_id, (void **)&mpifh_p) < 0) goto error; - if(MPI_File_close(mpifh_p) != MPI_SUCCESS) + if (MPI_File_close(mpifh_p) != MPI_SUCCESS) goto error; HDfflush(stdout); @@ -215,4 +209,3 @@ error: HDprintf("THERE WAS A REAL ERROR IN t_pflush1.\n"); HD_exit(EXIT_FAILURE); } /* end main() */ - diff --git a/testpar/t_pflush2.c b/testpar/t_pflush2.c index f4589c8..20f8a95 100644 --- a/testpar/t_pflush2.c +++ b/testpar/t_pflush2.c @@ -24,15 +24,11 @@ #include "h5test.h" -const char *FILENAME[] = { - "flush", - "noflush", - NULL -}; +const char *FILENAME[] = {"flush", "noflush", NULL}; -static int data_g[100][100]; +static int data_g[100][100]; -#define N_GROUPS 100 +#define N_GROUPS 100 /*------------------------------------------------------------------------- * Function: check_test_file @@ -47,41 +43,41 @@ static int data_g[100][100]; *------------------------------------------------------------------------- */ static herr_t -check_test_file(char* name, hid_t fapl_id) +check_test_file(char *name, hid_t fapl_id) { - hid_t fid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t top_level_gid = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t dxpl_id = H5I_INVALID_HID; - hsize_t dims[2]; - int val; - hsize_t i, j; + hid_t fid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t top_level_gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hsize_t dims[2]; + int val; + hsize_t i, j; - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) goto error; - if((fid = H5Fopen(name, H5F_ACC_RDONLY, fapl_id)) < 0) + if ((fid = H5Fopen(name, H5F_ACC_RDONLY, fapl_id)) < 0) goto error; /* Open the dataset */ - if((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) goto error; - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto error; - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto error; HDassert(100 == dims[0] && 100 == dims[1]); /* Read some data */ - if(H5Dread(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) + if (H5Dread(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) goto error; - for(i = 0; i < dims[0]; i++) { - for(j = 0; j < dims[1]; j++) { + for (i = 0; i < dims[0]; i++) { + for (j = 0; j < dims[1]; j++) { val = (int)(i + (i * j) + j); - if(data_g[i][j] != val) { + if (data_g[i][j] != val) { H5_FAILED(); HDprintf(" data_g[%lu][%lu] = %d\n", (unsigned long)i, (unsigned long)j, data_g[i][j]); HDprintf(" should be %d\n", val); @@ -90,38 +86,40 @@ check_test_file(char* name, hid_t fapl_id) } /* Open some groups */ - if((top_level_gid = H5Gopen2(fid, "some_groups", H5P_DEFAULT)) < 0) + if ((top_level_gid = H5Gopen2(fid, "some_groups", H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < N_GROUPS; i++) { + for (i = 0; i < N_GROUPS; i++) { HDsprintf(name, "grp%02u", (unsigned)i); - if((gid = H5Gopen2(top_level_gid, name, H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(top_level_gid, name, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; } - if(H5Gclose(top_level_gid) < 0) + if (H5Gclose(top_level_gid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; - if(H5Pclose(dxpl_id) < 0) + if (H5Pclose(dxpl_id) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dxpl_id); H5Gclose(top_level_gid); H5Dclose(did); H5Fclose(fid); H5Sclose(sid); H5Gclose(gid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end check_test_file() */ @@ -140,31 +138,31 @@ error: int main(int argc, char *argv[]) { - hid_t fapl_id1 = H5I_INVALID_HID; - hid_t fapl_id2 = H5I_INVALID_HID; + hid_t fapl_id1 = H5I_INVALID_HID; + hid_t fapl_id2 = H5I_INVALID_HID; H5E_auto2_t func; char name[1024]; const char *envval = NULL; - int mpi_size; - int mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; + int mpi_size; + int mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; MPI_Init(&argc, &argv); MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - if(mpi_rank == 0) + if (mpi_rank == 0) TESTING("H5Fflush (part2 with flush)"); /* Don't run using the split VFD */ envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL) + if (envval == NULL) envval = "nomatch"; - if(!HDstrcmp(envval, "split")) { - if(mpi_rank == 0) { + if (!HDstrcmp(envval, "split")) { + if (mpi_rank == 0) { SKIPPED(); HDputs(" Test not compatible with current Virtual File Driver"); } @@ -172,37 +170,37 @@ main(int argc, char *argv[]) HDexit(EXIT_FAILURE); } - if((fapl_id1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_fapl_mpio(fapl_id1, comm, info) < 0) + if (H5Pset_fapl_mpio(fapl_id1, comm, info) < 0) goto error; - if((fapl_id2 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl_id2 = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_fapl_mpio(fapl_id2, comm, info) < 0) + if (H5Pset_fapl_mpio(fapl_id2, comm, info) < 0) goto error; /* Check the case where the file was flushed */ h5_fixname(FILENAME[0], fapl_id1, name, sizeof(name)); - if(check_test_file(name, fapl_id1)) { + if (check_test_file(name, fapl_id1)) { H5_FAILED() goto error; } - else if(mpi_rank == 0) { + else if (mpi_rank == 0) { PASSED(); } /* Check the case where the file was not flushed. This should give an error * so we turn off the error stack temporarily. */ - if(mpi_rank == 0) + if (mpi_rank == 0) TESTING("H5Fflush (part2 without flush)"); - H5Eget_auto2(H5E_DEFAULT,&func, NULL); + H5Eget_auto2(H5E_DEFAULT, &func, NULL); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); h5_fixname(FILENAME[1], fapl_id2, name, sizeof(name)); - if(check_test_file(name, fapl_id2)) { - if(mpi_rank == 0) + if (check_test_file(name, fapl_id2)) { + if (mpi_rank == 0) PASSED(); } else { @@ -222,4 +220,3 @@ main(int argc, char *argv[]) error: HDexit(EXIT_FAILURE); } /* end main() */ - diff --git a/testpar/t_ph5basic.c b/testpar/t_ph5basic.c index 73d262e..6b2bfe3 100644 --- a/testpar/t_ph5basic.c +++ b/testpar/t_ph5basic.c @@ -17,7 +17,6 @@ #include "testphdf5.h" - /*------------------------------------------------------------------------- * Function: test_fapl_mpio_dup * @@ -36,23 +35,23 @@ void test_fapl_mpio_dup(void) { - int mpi_size, mpi_rank; + int mpi_size, mpi_rank; MPI_Comm comm, comm_tmp; - int mpi_size_old, mpi_rank_old; - int mpi_size_tmp, mpi_rank_tmp; - MPI_Info info = MPI_INFO_NULL; + int mpi_size_old, mpi_rank_old; + int mpi_size_tmp, mpi_rank_tmp; + MPI_Info info = MPI_INFO_NULL; MPI_Info info_tmp = MPI_INFO_NULL; - int mrc; /* MPI return value */ - hid_t acc_pl; /* File access properties */ - herr_t ret; /* HDF5 return value */ - int nkeys, nkeys_tmp; + int mrc; /* MPI return value */ + hid_t acc_pl; /* File access properties */ + herr_t ret; /* HDF5 return value */ + int nkeys, nkeys_tmp; if (VERBOSE_MED) HDprintf("Verify fapl_mpio duplicates communicator and INFO objects\n"); /* set up MPI parameters */ - MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); if (VERBOSE_MED) HDprintf("rank/size of MPI_COMM_WORLD are %d/%d\n", mpi_rank, mpi_size); @@ -148,8 +147,7 @@ test_fapl_mpio_dup(void) MPI_Comm_size(comm_tmp, &mpi_size_tmp); MPI_Comm_rank(comm_tmp, &mpi_rank_tmp); if (VERBOSE_MED) - HDprintf("After second H5Pget_fapl_mpio: rank/size of comm are %d/%d\n", - mpi_rank_tmp, mpi_size_tmp); + HDprintf("After second H5Pget_fapl_mpio: rank/size of comm are %d/%d\n", mpi_rank_tmp, mpi_size_tmp); VRFY((mpi_size_tmp == mpi_size), "MPI_Comm_size"); VRFY((mpi_rank_tmp == mpi_rank), "MPI_Comm_rank"); if (MPI_INFO_NULL != info_tmp) { @@ -168,8 +166,7 @@ test_fapl_mpio_dup(void) MPI_Comm_size(comm_tmp, &mpi_size_tmp); MPI_Comm_rank(comm_tmp, &mpi_rank_tmp); if (VERBOSE_MED) - HDprintf("After Property list closed: rank/size of comm are %d/%d\n", - mpi_rank_tmp, mpi_size_tmp); + HDprintf("After Property list closed: rank/size of comm are %d/%d\n", mpi_rank_tmp, mpi_size_tmp); if (MPI_INFO_NULL != info_tmp) { mrc = MPI_Info_get_nkeys(info_tmp, &nkeys_tmp); VRFY((mrc == MPI_SUCCESS), "MPI_Info_get_nkeys"); @@ -185,4 +182,3 @@ test_fapl_mpio_dup(void) VRFY((mrc == MPI_SUCCESS), "MPI_Info_free"); } } /* end test_fapl_mpio_dup() */ - diff --git a/testpar/t_pread.c b/testpar/t_pread.c index ba4165e..78659d4 100644 --- a/testpar/t_pread.c +++ b/testpar/t_pread.c @@ -27,24 +27,20 @@ * or to read and validate. */ #define NFILENAME 3 -const char *FILENAMES[NFILENAME + 1]={"reloc_t_pread_data_file", - "reloc_t_pread_group_0_file", - "reloc_t_pread_group_1_file", - NULL}; +const char *FILENAMES[NFILENAME + 1] = {"reloc_t_pread_data_file", "reloc_t_pread_group_0_file", + "reloc_t_pread_group_1_file", NULL}; #define FILENAME_BUF_SIZE 1024 #define COUNT 1000 #define LIMIT_NPROC 6 -hbool_t pass = true; -static const char *random_hdf5_text = -"Now is the time for all first-time-users of HDF5 to read their \ +hbool_t pass = true; +static const char *random_hdf5_text = "Now is the time for all first-time-users of HDF5 to read their \ manual or go thru the tutorials!\n\ While you\'re at it, now is also the time to read up on MPI-IO."; -static const char *hitchhiker_quote = -"A common mistake that people make when trying to design something\n\ +static const char *hitchhiker_quote = "A common mistake that people make when trying to design something\n\ completely foolproof is to underestimate the ingenuity of complete\n\ fools.\n"; @@ -53,7 +49,6 @@ static int test_parallel_read(MPI_Comm comm, int mpi_rank, int mpi_size, int gro static char *test_argv0 = NULL; - /*------------------------------------------------------------------------- * Function: generate_test_file * @@ -88,50 +83,50 @@ static char *test_argv0 = NULL; *------------------------------------------------------------------------- */ static int -generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) +generate_test_file(MPI_Comm comm, int mpi_rank, int group_id) { - int header = -1; - const char *fcn_name = "generate_test_file()"; - const char *failure_mssg = NULL; + int header = -1; + const char *fcn_name = "generate_test_file()"; + const char *failure_mssg = NULL; const char *group_filename = NULL; - char data_filename[FILENAME_BUF_SIZE]; - int file_index = 0; - int group_size; - int group_rank; - int local_failure = 0; - int global_failures = 0; - hsize_t count = COUNT; - hsize_t i; - hsize_t offset; - hsize_t dims[1] = {0}; - hid_t file_id = -1; - hid_t memspace = -1; - hid_t filespace = -1; - hid_t fctmpl = -1; - hid_t fapl_id = -1; - hid_t dxpl_id = -1; - hid_t dset_id = -1; - hid_t dset_id_ch = -1; - hid_t dcpl_id = H5P_DEFAULT; - hsize_t chunk[1]; - float nextValue; - float *data_slice = NULL; + char data_filename[FILENAME_BUF_SIZE]; + int file_index = 0; + int group_size; + int group_rank; + int local_failure = 0; + int global_failures = 0; + hsize_t count = COUNT; + hsize_t i; + hsize_t offset; + hsize_t dims[1] = {0}; + hid_t file_id = -1; + hid_t memspace = -1; + hid_t filespace = -1; + hid_t fctmpl = -1; + hid_t fapl_id = -1; + hid_t dxpl_id = -1; + hid_t dset_id = -1; + hid_t dset_id_ch = -1; + hid_t dcpl_id = H5P_DEFAULT; + hsize_t chunk[1]; + float nextValue; + float * data_slice = NULL; pass = true; HDassert(comm != MPI_COMM_NULL); - if ( (MPI_Comm_rank(comm, &group_rank)) != MPI_SUCCESS) { - pass = FALSE; + if ((MPI_Comm_rank(comm, &group_rank)) != MPI_SUCCESS) { + pass = FALSE; failure_mssg = "generate_test_file: MPI_Comm_rank failed.\n"; } - if ( (MPI_Comm_size(comm, &group_size)) != MPI_SUCCESS) { - pass = FALSE; + if ((MPI_Comm_size(comm, &group_size)) != MPI_SUCCESS) { + pass = FALSE; failure_mssg = "generate_test_file: MPI_Comm_size failed.\n"; } - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { HDfprintf(stdout, "Constructing test files..."); } @@ -143,14 +138,14 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) * file construction. The reading portion of the test * will have a similar setup process... */ - if ( pass ) { - if ( comm == MPI_COMM_WORLD ) { /* Test 1 */ + if (pass) { + if (comm == MPI_COMM_WORLD) { /* Test 1 */ file_index = 0; } - else if ( group_id == 0 ) { /* Test 2 group 0 */ + else if (group_id == 0) { /* Test 2 group 0 */ file_index = 1; } - else { /* Test 2 group 1 */ + else { /* Test 2 group 1 */ file_index = 2; } @@ -159,220 +154,212 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) * need to worry that we reassign it for each file! */ group_filename = FILENAMES[file_index]; - HDassert( group_filename ); + HDassert(group_filename); /* Assign the 'data_filename' */ - if ( h5_fixname(group_filename, H5P_DEFAULT, data_filename, - sizeof(data_filename)) == NULL ) { - pass = FALSE; + if (h5_fixname(group_filename, H5P_DEFAULT, data_filename, sizeof(data_filename)) == NULL) { + pass = FALSE; failure_mssg = "h5_fixname(0) failed.\n"; } } /* setup data to write */ - if ( pass ) { - if ( (data_slice = (float *)HDmalloc(COUNT * sizeof(float))) == NULL ) { - pass = FALSE; + if (pass) { + if ((data_slice = (float *)HDmalloc(COUNT * sizeof(float))) == NULL) { + pass = FALSE; failure_mssg = "malloc of data_slice failed.\n"; } } - if ( pass ) { + if (pass) { nextValue = (float)(mpi_rank * COUNT); - for(i=0; i 0)) { if (HDclose(header) < 0) { - pass = FALSE; + pass = FALSE; failure_mssg = "HDclose() failed.\n"; } } @@ -428,42 +415,41 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) * Only overwrite the failure message if no previous error * has been detected */ - local_failure = ( pass ? 0 : 1 ); + local_failure = (pass ? 0 : 1); /* This is a global all reduce (NOT group specific) */ - if ( MPI_Allreduce(&local_failure, &global_failures, 1, - MPI_INT, MPI_SUM, MPI_COMM_WORLD) != MPI_SUCCESS ) { - if ( pass ) { - pass = FALSE; + if (MPI_Allreduce(&local_failure, &global_failures, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD) != MPI_SUCCESS) { + if (pass) { + pass = FALSE; failure_mssg = "MPI_Allreduce() failed.\n"; } - } else if ( ( pass ) && ( global_failures > 0 ) ) { - pass = FALSE; + } + else if ((pass) && (global_failures > 0)) { + pass = FALSE; failure_mssg = "One or more processes report failure.\n"; } /* report results */ - if ( mpi_rank == 0 ) { - if ( pass ) { + if (mpi_rank == 0) { + if (pass) { HDfprintf(stdout, "Done.\n"); - } else { + } + else { HDfprintf(stdout, "FAILED.\n"); - HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", - fcn_name, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", fcn_name, failure_mssg); } } /* free data_slice if it has been allocated */ - if ( data_slice != NULL ) { + if (data_slice != NULL) { HDfree(data_slice); data_slice = NULL; } - return(! pass); + return (!pass); } /* generate_test_file() */ - /*------------------------------------------------------------------------- * Function: test_parallel_read * @@ -506,46 +492,46 @@ static int test_parallel_read(MPI_Comm comm, int mpi_rank, int mpi_size, int group_id) { const char *failure_mssg; - const char *fcn_name = "test_parallel_read()"; + const char *fcn_name = "test_parallel_read()"; const char *group_filename = NULL; - char reloc_data_filename[FILENAME_BUF_SIZE]; - int local_failure = 0; - int global_failures = 0; - int group_size; - int group_rank; - hid_t fapl_id = -1; - hid_t file_id = -1; - hid_t dset_id = -1; - hid_t dset_id_ch = -1; - hid_t dxpl_id = H5P_DEFAULT; - hid_t memspace = -1; - hid_t filespace = -1; - hid_t filetype = -1; - size_t filetype_size; - hssize_t dset_size; - hsize_t i; - hsize_t offset; - hsize_t count = COUNT; - hsize_t dims[1] = {0}; - float nextValue; - float *data_slice = NULL; + char reloc_data_filename[FILENAME_BUF_SIZE]; + int local_failure = 0; + int global_failures = 0; + int group_size; + int group_rank; + hid_t fapl_id = -1; + hid_t file_id = -1; + hid_t dset_id = -1; + hid_t dset_id_ch = -1; + hid_t dxpl_id = H5P_DEFAULT; + hid_t memspace = -1; + hid_t filespace = -1; + hid_t filetype = -1; + size_t filetype_size; + hssize_t dset_size; + hsize_t i; + hsize_t offset; + hsize_t count = COUNT; + hsize_t dims[1] = {0}; + float nextValue; + float * data_slice = NULL; pass = TRUE; HDassert(comm != MPI_COMM_NULL); - if ( (MPI_Comm_rank(comm, &group_rank)) != MPI_SUCCESS) { - pass = FALSE; + if ((MPI_Comm_rank(comm, &group_rank)) != MPI_SUCCESS) { + pass = FALSE; failure_mssg = "test_parallel_read: MPI_Comm_rank failed.\n"; } - if ( (MPI_Comm_size(comm, &group_size)) != MPI_SUCCESS) { - pass = FALSE; + if ((MPI_Comm_size(comm, &group_size)) != MPI_SUCCESS) { + pass = FALSE; failure_mssg = "test_parallel_read: MPI_Comm_size failed.\n"; } - if ( mpi_rank == 0 ) { - if ( comm == MPI_COMM_WORLD ) { + if (mpi_rank == 0) { + if (comm == MPI_COMM_WORLD) { TESTING("parallel file open test 1"); } else { @@ -554,123 +540,118 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int mpi_size, int group_id) } /* allocate space for the data_slice array */ - if ( pass ) { - if ( (data_slice = (float *)HDmalloc(COUNT * sizeof(float))) == NULL ) { - pass = FALSE; + if (pass) { + if ((data_slice = (float *)HDmalloc(COUNT * sizeof(float))) == NULL) { + pass = FALSE; failure_mssg = "malloc of data_slice failed.\n"; } } - /* Select the file file name to read * Please see the comments in the 'generate_test_file' function * for more details... */ - if ( pass ) { + if (pass) { - if ( comm == MPI_COMM_WORLD ) /* test 1 */ + if (comm == MPI_COMM_WORLD) /* test 1 */ group_filename = FILENAMES[0]; - else if ( group_id == 0 ) /* test 2 group 0 */ + else if (group_id == 0) /* test 2 group 0 */ group_filename = FILENAMES[1]; - else /* test 2 group 1 */ + else /* test 2 group 1 */ group_filename = FILENAMES[2]; HDassert(group_filename); - if ( h5_fixname(group_filename, H5P_DEFAULT, reloc_data_filename, - sizeof(reloc_data_filename)) == NULL ) { + if (h5_fixname(group_filename, H5P_DEFAULT, reloc_data_filename, sizeof(reloc_data_filename)) == + NULL) { - pass = FALSE; + pass = FALSE; failure_mssg = "h5_fixname(1) failed.\n"; } } /* setup FAPL */ - if ( pass ) { - if ( (fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0 ) { - pass = FALSE; + if (pass) { + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + pass = FALSE; failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; } } - if ( pass ) { - if ( (H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL)) < 0 ) { - pass = FALSE; + if (pass) { + if ((H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL)) < 0) { + pass = FALSE; failure_mssg = "H5Pset_fapl_mpio() failed\n"; } } /* open the file -- should have user block, exercising the optimization */ - if ( pass ) { - if ( (file_id = H5Fopen(reloc_data_filename, - H5F_ACC_RDONLY, fapl_id)) < 0 ) { - pass = FALSE; + if (pass) { + if ((file_id = H5Fopen(reloc_data_filename, H5F_ACC_RDONLY, fapl_id)) < 0) { + pass = FALSE; failure_mssg = "H5Fopen() failed\n"; } } /* open the data set */ - if ( pass ) { - if ( (dset_id = H5Dopen2(file_id, "dataset0", H5P_DEFAULT)) < 0 ) { - pass = FALSE; + if (pass) { + if ((dset_id = H5Dopen2(file_id, "dataset0", H5P_DEFAULT)) < 0) { + pass = FALSE; failure_mssg = "H5Dopen2() failed\n"; } } /* open the chunked data set */ - if ( pass ) { - if ( (dset_id_ch = H5Dopen2(file_id, "dataset0_chunked", H5P_DEFAULT)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Dopen2() failed\n"; - } + if (pass) { + if ((dset_id_ch = H5Dopen2(file_id, "dataset0_chunked", H5P_DEFAULT)) < 0) { + pass = FALSE; + failure_mssg = "H5Dopen2() failed\n"; + } } /* setup memspace */ - if ( pass ) { + if (pass) { dims[0] = count; - if ( (memspace = H5Screate_simple(1, dims, NULL)) < 0 ) { - pass = FALSE; + if ((memspace = H5Screate_simple(1, dims, NULL)) < 0) { + pass = FALSE; failure_mssg = "H5Screate_simple(1, dims, NULL) failed\n"; } } /* setup filespace */ - if ( pass ) { - if ( (filespace = H5Dget_space(dset_id)) < 0 ) { - pass = FALSE; + if (pass) { + if ((filespace = H5Dget_space(dset_id)) < 0) { + pass = FALSE; failure_mssg = "H5Dget_space(dataset) failed\n"; } } - if ( pass ) { + if (pass) { offset = (hsize_t)group_rank * count; - if ( (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, - &offset, NULL, &count, NULL)) < 0 ) { - pass = FALSE; + if ((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, &offset, NULL, &count, NULL)) < 0) { + pass = FALSE; failure_mssg = "H5Sselect_hyperslab() failed\n"; } } /* read this processes section of the data */ - if ( pass ) { - if ( (H5Dread(dset_id, H5T_NATIVE_FLOAT, memspace, - filespace, H5P_DEFAULT, data_slice)) < 0 ) { - pass = FALSE; + if (pass) { + if ((H5Dread(dset_id, H5T_NATIVE_FLOAT, memspace, filespace, H5P_DEFAULT, data_slice)) < 0) { + pass = FALSE; failure_mssg = "H5Dread() failed\n"; } } /* verify the data */ - if ( pass ) { + if (pass) { nextValue = (float)((hsize_t)mpi_rank * count); - i = 0; - while ( ( pass ) && ( i < count ) ) { + i = 0; + while ((pass) && (i < count)) { /* what we really want is data_slice[i] != nextValue -- * the following is a circumlocution to shut up the * the compiler. */ - if ( ( data_slice[i] > nextValue ) || - ( data_slice[i] < nextValue ) ) { - pass = FALSE; + if ((data_slice[i] > nextValue) || (data_slice[i] < nextValue)) { + pass = FALSE; failure_mssg = "Unexpected dset contents.\n"; } nextValue += 1; @@ -678,22 +659,22 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int mpi_size, int group_id) } } - if ( pass || (memspace != -1) ) { - if ( H5Sclose(memspace) < 0 ) { - pass = false; + if (pass || (memspace != -1)) { + if (H5Sclose(memspace) < 0) { + pass = false; failure_mssg = "H5Sclose(memspace) failed.\n"; } } - if ( pass || (filespace != -1) ) { - if ( H5Sclose(filespace) < 0 ) { - pass = false; + if (pass || (filespace != -1)) { + if (H5Sclose(filespace) < 0) { + pass = false; failure_mssg = "H5Sclose(filespace) failed.\n"; } } /* free data_slice if it has been allocated */ - if ( data_slice != NULL ) { + if (data_slice != NULL) { HDfree(data_slice); data_slice = NULL; } @@ -704,328 +685,321 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int mpi_size, int group_id) /* Don't test with more than LIMIT_NPROC processes to avoid memory issues */ - if( group_size <= LIMIT_NPROC ) { + if (group_size <= LIMIT_NPROC) { #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - hbool_t prop_value; + hbool_t prop_value; #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - if ( (filespace = H5Dget_space(dset_id )) < 0 ) { - pass = FALSE; - failure_mssg = "H5Dget_space failed.\n"; - } + if ((filespace = H5Dget_space(dset_id)) < 0) { + pass = FALSE; + failure_mssg = "H5Dget_space failed.\n"; + } - if ( (dset_size = H5Sget_simple_extent_npoints(filespace)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Sget_simple_extent_npoints failed.\n"; - } + if ((dset_size = H5Sget_simple_extent_npoints(filespace)) < 0) { + pass = FALSE; + failure_mssg = "H5Sget_simple_extent_npoints failed.\n"; + } - if ( (filetype = H5Dget_type(dset_id)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Dget_type failed.\n"; - } + if ((filetype = H5Dget_type(dset_id)) < 0) { + pass = FALSE; + failure_mssg = "H5Dget_type failed.\n"; + } - if ( (filetype_size = H5Tget_size(filetype)) == 0 ) { - pass = FALSE; - failure_mssg = "H5Tget_size failed.\n"; - } + if ((filetype_size = H5Tget_size(filetype)) == 0) { + pass = FALSE; + failure_mssg = "H5Tget_size failed.\n"; + } - if ( H5Tclose(filetype) < 0 ) { - pass = FALSE; - failure_mssg = "H5Tclose failed.\n"; - }; + if (H5Tclose(filetype) < 0) { + pass = FALSE; + failure_mssg = "H5Tclose failed.\n"; + }; - if ( (data_slice = (float *)HDmalloc((size_t)dset_size*filetype_size)) == NULL ) { - pass = FALSE; - failure_mssg = "malloc of data_slice failed.\n"; - } + if ((data_slice = (float *)HDmalloc((size_t)dset_size * filetype_size)) == NULL) { + pass = FALSE; + failure_mssg = "malloc of data_slice failed.\n"; + } - if ( pass ) { - if ( (dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Pcreate(H5P_DATASET_XFER) failed.\n"; + if (pass) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_DATASET_XFER) failed.\n"; + } } - } - if ( pass ) { - if ( (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Pset_dxpl_mpio() failed.\n"; + if (pass) { + if ((H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE)) < 0) { + pass = FALSE; + failure_mssg = "H5Pset_dxpl_mpio() failed.\n"; + } } - } #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if ( pass ) { - prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; - if(H5Pinsert2(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, H5D_XFER_COLL_RANK0_BCAST_SIZE, &prop_value, - NULL, NULL, NULL, NULL, NULL, NULL) < 0) { - pass = FALSE; - failure_mssg = "H5Pinsert2() failed\n"; - } - } + if (pass) { + prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; + if (H5Pinsert2(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, H5D_XFER_COLL_RANK0_BCAST_SIZE, + &prop_value, NULL, NULL, NULL, NULL, NULL, NULL) < 0) { + pass = FALSE; + failure_mssg = "H5Pinsert2() failed\n"; + } + } #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - /* read H5S_ALL section */ - if ( pass ) { - if ( (H5Dread(dset_id, H5T_NATIVE_FLOAT, H5S_ALL, - H5S_ALL, dxpl_id, data_slice)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Dread() failed\n"; + /* read H5S_ALL section */ + if (pass) { + if ((H5Dread(dset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id, data_slice)) < 0) { + pass = FALSE; + failure_mssg = "H5Dread() failed\n"; + } } - } #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if ( pass ) { - prop_value = FALSE; - if(H5Pget(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { - pass = FALSE; - failure_mssg = "H5Pget() failed\n"; - } if (pass) { - if(prop_value != TRUE) { - pass = FALSE; - failure_mssg = "rank 0 Bcast optimization was mistakenly not performed\n"; - } + prop_value = FALSE; + if (H5Pget(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { + pass = FALSE; + failure_mssg = "H5Pget() failed\n"; + } + if (pass) { + if (prop_value != TRUE) { + pass = FALSE; + failure_mssg = "rank 0 Bcast optimization was mistakenly not performed\n"; + } + } } - } #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - /* verify the data */ - if ( pass ) { - - if ( comm == MPI_COMM_WORLD ) /* test 1 */ - nextValue = 0; - else if ( group_id == 0 ) /* test 2 group 0 */ - nextValue = 0; - else /* test 2 group 1 */ - nextValue = (float)((hsize_t)( mpi_size / 2 )*count); - - i = 0; - while ( ( pass ) && ( i < (hsize_t)dset_size ) ) { - /* what we really want is data_slice[i] != nextValue -- - * the following is a circumlocution to shut up the - * the compiler. - */ - if ( ( data_slice[i] > nextValue ) || - ( data_slice[i] < nextValue ) ) { - pass = FALSE; - failure_mssg = "Unexpected dset contents.\n"; - } - nextValue += 1; - i++; - } - } - - /* read H5S_ALL section for the chunked dataset */ + /* verify the data */ + if (pass) { + + if (comm == MPI_COMM_WORLD) /* test 1 */ + nextValue = 0; + else if (group_id == 0) /* test 2 group 0 */ + nextValue = 0; + else /* test 2 group 1 */ + nextValue = (float)((hsize_t)(mpi_size / 2) * count); + + i = 0; + while ((pass) && (i < (hsize_t)dset_size)) { + /* what we really want is data_slice[i] != nextValue -- + * the following is a circumlocution to shut up the + * the compiler. + */ + if ((data_slice[i] > nextValue) || (data_slice[i] < nextValue)) { + pass = FALSE; + failure_mssg = "Unexpected dset contents.\n"; + } + nextValue += 1; + i++; + } + } + + /* read H5S_ALL section for the chunked dataset */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if ( pass ) { - prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; - if(H5Pset(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { - pass = FALSE; - failure_mssg = "H5Pset() failed\n"; + if (pass) { + prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; + if (H5Pset(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { + pass = FALSE; + failure_mssg = "H5Pset() failed\n"; + } } - } #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - for ( i = 0; i < (hsize_t)dset_size; i++) { - data_slice[i] = 0; - } - if ( pass ) { - if ( (H5Dread(dset_id_ch, H5T_NATIVE_FLOAT, H5S_ALL, - H5S_ALL, dxpl_id, data_slice)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Dread() failed\n"; + for (i = 0; i < (hsize_t)dset_size; i++) { + data_slice[i] = 0; + } + if (pass) { + if ((H5Dread(dset_id_ch, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id, data_slice)) < 0) { + pass = FALSE; + failure_mssg = "H5Dread() failed\n"; + } } - } #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if ( pass ) { - prop_value = FALSE; - if(H5Pget(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { - pass = FALSE; - failure_mssg = "H5Pget() failed\n"; - } if (pass) { - if(prop_value == TRUE) { - pass = FALSE; - failure_mssg = "rank 0 Bcast optimization was mistakenly performed for chunked dataset\n"; - } + prop_value = FALSE; + if (H5Pget(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { + pass = FALSE; + failure_mssg = "H5Pget() failed\n"; + } + if (pass) { + if (prop_value == TRUE) { + pass = FALSE; + failure_mssg = "rank 0 Bcast optimization was mistakenly performed for chunked dataset\n"; + } + } } - } #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - /* verify the data */ - if ( pass ) { - - if ( comm == MPI_COMM_WORLD ) /* test 1 */ - nextValue = 0; - else if ( group_id == 0 ) /* test 2 group 0 */ - nextValue = 0; - else /* test 2 group 1 */ - nextValue = (float)((hsize_t)( mpi_size / 2 )*count); - - i = 0; - while ( ( pass ) && ( i < (hsize_t)dset_size ) ) { - /* what we really want is data_slice[i] != nextValue -- - * the following is a circumlocution to shut up the - * the compiler. - */ - if ( ( data_slice[i] > nextValue ) || - ( data_slice[i] < nextValue ) ) { - pass = FALSE; - failure_mssg = "Unexpected chunked dset contents.\n"; - } - nextValue += 1; - i++; - } - } - - if ( pass || (filespace != -1) ) { - if ( H5Sclose(filespace) < 0 ) { - pass = false; - failure_mssg = "H5Sclose(filespace) failed.\n"; - } - } - - /* free data_slice if it has been allocated */ - if ( data_slice != NULL ) { - HDfree(data_slice); - data_slice = NULL; - } - - /* - * Read an H5S_ALL filespace into a hyperslab defined memory space - */ - - if ( (data_slice = (float *)HDmalloc((size_t)(dset_size*2)*filetype_size)) == NULL ) { - pass = FALSE; - failure_mssg = "malloc of data_slice failed.\n"; - } - - /* setup memspace */ - if ( pass ) { - dims[0] = (hsize_t)dset_size*2; - if ( (memspace = H5Screate_simple(1, dims, NULL)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Screate_simple(1, dims, NULL) failed\n"; - } - } - if ( pass ) { - offset = (hsize_t)dset_size; - if ( (H5Sselect_hyperslab(memspace, H5S_SELECT_SET, - &offset, NULL, &offset, NULL)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Sselect_hyperslab() failed\n"; - } - } + /* verify the data */ + if (pass) { + + if (comm == MPI_COMM_WORLD) /* test 1 */ + nextValue = 0; + else if (group_id == 0) /* test 2 group 0 */ + nextValue = 0; + else /* test 2 group 1 */ + nextValue = (float)((hsize_t)(mpi_size / 2) * count); + + i = 0; + while ((pass) && (i < (hsize_t)dset_size)) { + /* what we really want is data_slice[i] != nextValue -- + * the following is a circumlocution to shut up the + * the compiler. + */ + if ((data_slice[i] > nextValue) || (data_slice[i] < nextValue)) { + pass = FALSE; + failure_mssg = "Unexpected chunked dset contents.\n"; + } + nextValue += 1; + i++; + } + } + + if (pass || (filespace != -1)) { + if (H5Sclose(filespace) < 0) { + pass = false; + failure_mssg = "H5Sclose(filespace) failed.\n"; + } + } + + /* free data_slice if it has been allocated */ + if (data_slice != NULL) { + HDfree(data_slice); + data_slice = NULL; + } + + /* + * Read an H5S_ALL filespace into a hyperslab defined memory space + */ + + if ((data_slice = (float *)HDmalloc((size_t)(dset_size * 2) * filetype_size)) == NULL) { + pass = FALSE; + failure_mssg = "malloc of data_slice failed.\n"; + } + + /* setup memspace */ + if (pass) { + dims[0] = (hsize_t)dset_size * 2; + if ((memspace = H5Screate_simple(1, dims, NULL)) < 0) { + pass = FALSE; + failure_mssg = "H5Screate_simple(1, dims, NULL) failed\n"; + } + } + if (pass) { + offset = (hsize_t)dset_size; + if ((H5Sselect_hyperslab(memspace, H5S_SELECT_SET, &offset, NULL, &offset, NULL)) < 0) { + pass = FALSE; + failure_mssg = "H5Sselect_hyperslab() failed\n"; + } + } #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if ( pass ) { - prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; - if(H5Pset(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { - pass = FALSE; - failure_mssg = "H5Pset() failed\n"; + if (pass) { + prop_value = H5D_XFER_COLL_RANK0_BCAST_DEF; + if (H5Pset(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { + pass = FALSE; + failure_mssg = "H5Pset() failed\n"; + } } - } #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - /* read this processes section of the data */ - if ( pass ) { - if ( (H5Dread(dset_id, H5T_NATIVE_FLOAT, memspace, - H5S_ALL, dxpl_id, data_slice)) < 0 ) { - pass = FALSE; - failure_mssg = "H5Dread() failed\n"; + /* read this processes section of the data */ + if (pass) { + if ((H5Dread(dset_id, H5T_NATIVE_FLOAT, memspace, H5S_ALL, dxpl_id, data_slice)) < 0) { + pass = FALSE; + failure_mssg = "H5Dread() failed\n"; + } } - } #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - if ( pass ) { - prop_value = FALSE; - if(H5Pget(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { - pass = FALSE; - failure_mssg = "H5Pget() failed\n"; - } if (pass) { - if(prop_value != TRUE) { - pass = FALSE; - failure_mssg = "rank 0 Bcast optimization was mistakenly not performed\n"; - } + prop_value = FALSE; + if (H5Pget(dxpl_id, H5D_XFER_COLL_RANK0_BCAST_NAME, &prop_value) < 0) { + pass = FALSE; + failure_mssg = "H5Pget() failed\n"; + } + if (pass) { + if (prop_value != TRUE) { + pass = FALSE; + failure_mssg = "rank 0 Bcast optimization was mistakenly not performed\n"; + } + } } - } #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - /* verify the data */ - if ( pass ) { - - if ( comm == MPI_COMM_WORLD ) /* test 1 */ - nextValue = 0; - else if ( group_id == 0 ) /* test 2 group 0 */ - nextValue = 0; - else /* test 2 group 1 */ - nextValue = (float)((hsize_t)(mpi_size / 2)*count); - - i = (hsize_t)dset_size; - while ( ( pass ) && ( i < (hsize_t)dset_size ) ) { - /* what we really want is data_slice[i] != nextValue -- - * the following is a circumlocution to shut up the - * the compiler. - */ - if ( ( data_slice[i] > nextValue ) || - ( data_slice[i] < nextValue ) ) { - pass = FALSE; - failure_mssg = "Unexpected dset contents.\n"; - } - nextValue += 1; - i++; - } - } - - if ( pass || (memspace != -1) ) { - if ( H5Sclose(memspace) < 0 ) { - pass = false; - failure_mssg = "H5Sclose(memspace) failed.\n"; - } - } - - /* free data_slice if it has been allocated */ - if ( data_slice != NULL ) { - HDfree(data_slice); - data_slice = NULL; - } + /* verify the data */ + if (pass) { + + if (comm == MPI_COMM_WORLD) /* test 1 */ + nextValue = 0; + else if (group_id == 0) /* test 2 group 0 */ + nextValue = 0; + else /* test 2 group 1 */ + nextValue = (float)((hsize_t)(mpi_size / 2) * count); + + i = (hsize_t)dset_size; + while ((pass) && (i < (hsize_t)dset_size)) { + /* what we really want is data_slice[i] != nextValue -- + * the following is a circumlocution to shut up the + * the compiler. + */ + if ((data_slice[i] > nextValue) || (data_slice[i] < nextValue)) { + pass = FALSE; + failure_mssg = "Unexpected dset contents.\n"; + } + nextValue += 1; + i++; + } + } - if ( pass || (dxpl_id != -1) ) { - if ( H5Pclose(dxpl_id) < 0 ) { - pass = false; - failure_mssg = "H5Pclose(dxpl_id) failed.\n"; + if (pass || (memspace != -1)) { + if (H5Sclose(memspace) < 0) { + pass = false; + failure_mssg = "H5Sclose(memspace) failed.\n"; + } + } + + /* free data_slice if it has been allocated */ + if (data_slice != NULL) { + HDfree(data_slice); + data_slice = NULL; + } + + if (pass || (dxpl_id != -1)) { + if (H5Pclose(dxpl_id) < 0) { + pass = false; + failure_mssg = "H5Pclose(dxpl_id) failed.\n"; + } } - } } /* close file, etc. */ - if ( pass || (dset_id != -1) ) { - if ( H5Dclose(dset_id) < 0 ) { - pass = false; + if (pass || (dset_id != -1)) { + if (H5Dclose(dset_id) < 0) { + pass = false; failure_mssg = "H5Dclose(dset_id) failed.\n"; } } - if ( pass || (dset_id_ch != -1) ) { - if ( H5Dclose(dset_id_ch) < 0 ) { - pass = false; + if (pass || (dset_id_ch != -1)) { + if (H5Dclose(dset_id_ch) < 0) { + pass = false; failure_mssg = "H5Dclose(dset_id_ch) failed.\n"; } } - if ( pass || (file_id != -1) ) { - if ( H5Fclose(file_id) < 0 ) { - pass = false; + if (pass || (file_id != -1)) { + if (H5Fclose(file_id) < 0) { + pass = false; failure_mssg = "H5Fclose(file_id) failed.\n"; } } - if ( pass || (fapl_id != -1) ) { - if ( H5Pclose(fapl_id) < 0 ) { - pass = false; + if (pass || (fapl_id != -1)) { + if (H5Pclose(fapl_id) < 0) { + pass = false; failure_mssg = "H5Pclose(fapl_id) failed.\n"; } } @@ -1034,36 +1008,35 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int mpi_size, int group_id) * Only overwrite the failure message if no previous error * has been detected */ - local_failure = ( pass ? 0 : 1 ); + local_failure = (pass ? 0 : 1); - if ( MPI_Allreduce( &local_failure, &global_failures, 1, - MPI_INT, MPI_SUM, MPI_COMM_WORLD) != MPI_SUCCESS ) { - if ( pass ) { - pass = FALSE; + if (MPI_Allreduce(&local_failure, &global_failures, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD) != MPI_SUCCESS) { + if (pass) { + pass = FALSE; failure_mssg = "MPI_Allreduce() failed.\n"; } - } else if ( ( pass ) && ( global_failures > 0 ) ) { - pass = FALSE; + } + else if ((pass) && (global_failures > 0)) { + pass = FALSE; failure_mssg = "One or more processes report failure.\n"; } /* report results and finish cleanup */ - if ( group_rank == 0 ) { - if ( pass ) { + if (group_rank == 0) { + if (pass) { PASSED(); - } else { + } + else { H5_FAILED(); - HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", - fcn_name, failure_mssg); + HDfprintf(stdout, "%s: failure_mssg = \"%s\"\n", fcn_name, failure_mssg); } HDremove(reloc_data_filename); } - return( ! pass ); + return (!pass); } /* test_parallel_read() */ - /*------------------------------------------------------------------------- * Function: main * @@ -1088,13 +1061,13 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int mpi_size, int group_id) */ int -main( int argc, char **argv) +main(int argc, char **argv) { - int nerrs = 0; - int which_group = 0; - int mpi_rank; - int mpi_size; - int split_size; + int nerrs = 0; + int which_group = 0; + int mpi_rank; + int mpi_size; + int split_size; MPI_Comm group_comm = MPI_COMM_NULL; /* I don't believe that argv[0] can ever be NULL. @@ -1108,33 +1081,33 @@ main( int argc, char **argv) */ test_argv0 = HDstrdup(argv[0]); - if ( (MPI_Init(&argc, &argv)) != MPI_SUCCESS) { - HDfprintf(stderr, "FATAL: Unable to initialize MPI\n"); - HDexit(EXIT_FAILURE); + if ((MPI_Init(&argc, &argv)) != MPI_SUCCESS) { + HDfprintf(stderr, "FATAL: Unable to initialize MPI\n"); + HDexit(EXIT_FAILURE); } - if ( (MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank)) != MPI_SUCCESS) { + if ((MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank)) != MPI_SUCCESS) { HDfprintf(stderr, "FATAL: MPI_Comm_rank returned an error\n"); HDexit(EXIT_FAILURE); } - if ( (MPI_Comm_size(MPI_COMM_WORLD, &mpi_size)) != MPI_SUCCESS) { + if ((MPI_Comm_size(MPI_COMM_WORLD, &mpi_size)) != MPI_SUCCESS) { HDfprintf(stderr, "FATAL: MPI_Comm_size returned an error\n"); HDexit(EXIT_FAILURE); } H5open(); - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { HDfprintf(stdout, "========================================\n"); HDfprintf(stdout, "Collective file open optimization tests\n"); HDfprintf(stdout, " mpi_size = %d\n", mpi_size); HDfprintf(stdout, "========================================\n"); } - if ( mpi_size < 3 ) { + if (mpi_size < 3) { - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { HDprintf(" Need at least 3 processes. Exiting.\n"); } @@ -1148,13 +1121,10 @@ main( int argc, char **argv) * two HDF files which in turn will be opened in parallel and the * contents verified in the second read test below. */ - split_size = mpi_size / 2; + split_size = mpi_size / 2; which_group = (mpi_rank < split_size ? 0 : 1); - if ( (MPI_Comm_split(MPI_COMM_WORLD, - which_group, - 0, - &group_comm)) != MPI_SUCCESS) { + if ((MPI_Comm_split(MPI_COMM_WORLD, which_group, 0, &group_comm)) != MPI_SUCCESS) { HDfprintf(stderr, "FATAL: MPI_Comm_split returned an error\n"); HDexit(EXIT_FAILURE); @@ -1163,37 +1133,37 @@ main( int argc, char **argv) /* ------ Generate all files ------ */ /* We generate the file used for test 1 */ - nerrs += generate_test_file( MPI_COMM_WORLD, mpi_rank, which_group ); + nerrs += generate_test_file(MPI_COMM_WORLD, mpi_rank, which_group); - if ( nerrs > 0 ) { - if ( mpi_rank == 0 ) { + if (nerrs > 0) { + if (mpi_rank == 0) { HDprintf(" Test(1) file construction failed -- skipping tests.\n"); } goto finish; } /* We generate the file used for test 2 */ - nerrs += generate_test_file( group_comm, mpi_rank, which_group ); + nerrs += generate_test_file(group_comm, mpi_rank, which_group); - if ( nerrs > 0 ) { - if ( mpi_rank == 0 ) { + if (nerrs > 0) { + if (mpi_rank == 0) { HDprintf(" Test(2) file construction failed -- skipping tests.\n"); } goto finish; } /* Now read the generated test file (stil using MPI_COMM_WORLD) */ - nerrs += test_parallel_read( MPI_COMM_WORLD, mpi_rank, mpi_size, which_group); + nerrs += test_parallel_read(MPI_COMM_WORLD, mpi_rank, mpi_size, which_group); - if ( nerrs > 0 ) { - if ( mpi_rank == 0 ) { + if (nerrs > 0) { + if (mpi_rank == 0) { HDprintf(" Parallel read test(1) failed -- skipping tests.\n"); } goto finish; } /* Update the user on our progress so far. */ - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { HDprintf(" Test 1 of 2 succeeded\n"); HDprintf(" -- Starting multi-group parallel read test.\n"); } @@ -1201,21 +1171,20 @@ main( int argc, char **argv) /* run the 2nd set of tests */ nerrs += test_parallel_read(group_comm, mpi_rank, mpi_size, which_group); - if ( nerrs > 0 ) { - if ( mpi_rank == 0 ) { + if (nerrs > 0) { + if (mpi_rank == 0) { HDprintf(" Multi-group read test(2) failed\n"); } goto finish; } - if ( mpi_rank == 0 ) { + if (mpi_rank == 0) { HDprintf(" Test 2 of 2 succeeded\n"); } finish: - if ((group_comm != MPI_COMM_NULL) && - (MPI_Comm_free(&group_comm)) != MPI_SUCCESS) { + if ((group_comm != MPI_COMM_NULL) && (MPI_Comm_free(&group_comm)) != MPI_SUCCESS) { HDfprintf(stderr, "MPI_Comm_free failed!\n"); } @@ -1224,11 +1193,11 @@ finish: */ MPI_Barrier(MPI_COMM_WORLD); - if ( mpi_rank == 0 ) { /* only process 0 reports */ + if (mpi_rank == 0) { /* only process 0 reports */ const char *header = "Collective file open optimization tests"; HDfprintf(stdout, "===================================\n"); - if ( nerrs > 0 ) { + if (nerrs > 0) { HDfprintf(stdout, "***%s detected %d failures***\n", header, nerrs); } else { @@ -1246,6 +1215,6 @@ finish: MPI_Finalize(); /* cannot just return (nerrs) because exit code is limited to 1byte */ - return((nerrs > 0) ? EXIT_FAILURE : EXIT_SUCCESS ); + return ((nerrs > 0) ? EXIT_FAILURE : EXIT_SUCCESS); } /* main() */ diff --git a/testpar/t_prestart.c b/testpar/t_prestart.c index da6bbe0..21f0591 100644 --- a/testpar/t_prestart.c +++ b/testpar/t_prestart.c @@ -21,37 +21,34 @@ #include "testphdf5.h" -int nerrors = 0; /* errors count */ +int nerrors = 0; /* errors count */ -const char *FILENAME[] = { - "shutdown", - NULL -}; +const char *FILENAME[] = {"shutdown", NULL}; int -main (int argc, char **argv) +main(int argc, char **argv) { - hid_t file_id, dset_id, grp_id; - hid_t fapl, sid, mem_dataspace; - herr_t ret; - char filename[1024]; - int mpi_size, mpi_rank, ndims; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - hsize_t dims[RANK]; - hsize_t start[RANK]; - hsize_t count[RANK]; - hsize_t stride[RANK]; - hsize_t block[RANK]; - hsize_t i, j; - DATATYPE *data_array = NULL, *dataptr; /* data buffer */ + hid_t file_id, dset_id, grp_id; + hid_t fapl, sid, mem_dataspace; + herr_t ret; + char filename[1024]; + int mpi_size, mpi_rank, ndims; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + hsize_t dims[RANK]; + hsize_t start[RANK]; + hsize_t count[RANK]; + hsize_t stride[RANK]; + hsize_t block[RANK]; + hsize_t i, j; + DATATYPE *data_array = NULL, *dataptr; /* data buffer */ MPI_Init(&argc, &argv); MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - if(MAINPROCESS) - TESTING("proper shutdown of HDF5 library"); + if (MAINPROCESS) + TESTING("proper shutdown of HDF5 library"); /* Set up file access property list with parallel I/O access */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -74,64 +71,62 @@ main (int argc, char **argv) ndims = H5Sget_simple_extent_dims(sid, dims, NULL); VRFY((ndims == 2), "H5Sget_simple_extent_dims succeeded"); - VRFY(dims[0] == (hsize_t)(ROW_FACTOR*mpi_size), "Wrong dataset dimensions"); - VRFY(dims[1] == (hsize_t)(COL_FACTOR*mpi_size), "Wrong dataset dimensions"); + VRFY(dims[0] == (hsize_t)(ROW_FACTOR * mpi_size), "Wrong dataset dimensions"); + VRFY(dims[1] == (hsize_t)(COL_FACTOR * mpi_size), "Wrong dataset dimensions"); /* allocate memory for data buffer */ - data_array = (DATATYPE *)HDmalloc(dims[0]*dims[1]*sizeof(DATATYPE)); + data_array = (DATATYPE *)HDmalloc(dims[0] * dims[1] * sizeof(DATATYPE)); VRFY((data_array != NULL), "data_array HDmalloc succeeded"); /* Each process takes a slabs of rows. */ - block[0] = dims[0]/(hsize_t)mpi_size; - block[1] = dims[1]; + block[0] = dims[0] / (hsize_t)mpi_size; + block[1] = dims[1]; stride[0] = block[0]; stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)mpi_rank*block[0]; - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)mpi_rank * block[0]; + start[1] = 0; ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* write data independently */ - ret = H5Dread(dset_id, H5T_NATIVE_INT, mem_dataspace, sid, - H5P_DEFAULT, data_array); + ret = H5Dread(dset_id, H5T_NATIVE_INT, mem_dataspace, sid, H5P_DEFAULT, data_array); VRFY((ret >= 0), "H5Dwrite succeeded"); dataptr = data_array; - for (i=0; i < block[0]; i++){ - for (j=0; j < block[1]; j++){ - if(*dataptr != mpi_rank+1) { + for (i = 0; i < block[0]; i++) { + for (j = 0; j < block[1]; j++) { + if (*dataptr != mpi_rank + 1) { HDprintf("Dataset Verify failed at [%lu][%lu](row %lu, col %lu): expect %d, got %d\n", - (unsigned long)i, (unsigned long)j, - (unsigned long)((hsize_t)i+start[0]), (unsigned long)((hsize_t)j+start[1]), - mpi_rank+1, *(dataptr)); - nerrors ++; + (unsigned long)i, (unsigned long)j, (unsigned long)((hsize_t)i + start[0]), + (unsigned long)((hsize_t)j + start[1]), mpi_rank + 1, *(dataptr)); + nerrors++; } dataptr++; - } + } } MPI_Finalize(); HDremove(filename); /* release data buffers */ - if(data_array) + if (data_array) HDfree(data_array); nerrors += GetTestNumErrs(); - if(MAINPROCESS) { - if(0 == nerrors) + if (MAINPROCESS) { + if (0 == nerrors) PASSED(); else - H5_FAILED() + H5_FAILED() } - return (nerrors!=0); + return (nerrors != 0); } diff --git a/testpar/t_prop.c b/testpar/t_prop.c index dde322d..e84a942 100644 --- a/testpar/t_prop.c +++ b/testpar/t_prop.c @@ -23,13 +23,13 @@ static int test_encode_decode(hid_t orig_pl, int mpi_rank, int recv_proc) { MPI_Request req[2]; - MPI_Status status; - hid_t pl; /* Decoded property list */ - size_t buf_size = 0; - void *sbuf = NULL; - herr_t ret; /* Generic return value */ + MPI_Status status; + hid_t pl; /* Decoded property list */ + size_t buf_size = 0; + void * sbuf = NULL; + herr_t ret; /* Generic return value */ - if(mpi_rank == 0) { + if (mpi_rank == 0) { int send_size = 0; /* first call to encode returns only the size of the buffer needed */ @@ -48,13 +48,13 @@ test_encode_decode(hid_t orig_pl, int mpi_rank, int recv_proc) MPI_Isend(sbuf, send_size, MPI_BYTE, recv_proc, 124, MPI_COMM_WORLD, &req[1]); } /* end if */ - if(mpi_rank == recv_proc) { - int recv_size; + if (mpi_rank == recv_proc) { + int recv_size; void *rbuf; MPI_Recv(&recv_size, 1, MPI_INT, 0, 123, MPI_COMM_WORLD, &status); buf_size = (size_t)recv_size; - rbuf = (uint8_t *)HDmalloc(buf_size); + rbuf = (uint8_t *)HDmalloc(buf_size); MPI_Recv(rbuf, recv_size, MPI_BYTE, 0, 124, MPI_COMM_WORLD, &status); pl = H5Pdecode(rbuf); @@ -65,89 +65,88 @@ test_encode_decode(hid_t orig_pl, int mpi_rank, int recv_proc) ret = H5Pclose(pl); VRFY((ret >= 0), "H5Pclose succeeded"); - if(NULL != rbuf) + if (NULL != rbuf) HDfree(rbuf); } /* end if */ - if(0 == mpi_rank) + if (0 == mpi_rank) MPI_Waitall(2, req, MPI_STATUSES_IGNORE); - if(NULL != sbuf) + if (NULL != sbuf) HDfree(sbuf); MPI_Barrier(MPI_COMM_WORLD); - return(0); + return (0); } void test_plist_ed(void) { - hid_t dcpl; /* dataset create prop. list */ - hid_t dapl; /* dataset access prop. list */ - hid_t dxpl; /* dataset transfer prop. list */ - hid_t gcpl; /* group create prop. list */ - hid_t lcpl; /* link create prop. list */ - hid_t lapl; /* link access prop. list */ - hid_t ocpypl; /* object copy prop. list */ - hid_t ocpl; /* object create prop. list */ - hid_t fapl; /* file access prop. list */ - hid_t fcpl; /* file create prop. list */ - hid_t strcpl; /* string create prop. list */ - hid_t acpl; /* attribute create prop. list */ + hid_t dcpl; /* dataset create prop. list */ + hid_t dapl; /* dataset access prop. list */ + hid_t dxpl; /* dataset transfer prop. list */ + hid_t gcpl; /* group create prop. list */ + hid_t lcpl; /* link create prop. list */ + hid_t lapl; /* link access prop. list */ + hid_t ocpypl; /* object copy prop. list */ + hid_t ocpl; /* object create prop. list */ + hid_t fapl; /* file access prop. list */ + hid_t fcpl; /* file create prop. list */ + hid_t strcpl; /* string create prop. list */ + hid_t acpl; /* attribute create prop. list */ int mpi_size, mpi_rank, recv_proc; - hsize_t chunk_size = 16384; /* chunk size */ - double fill = 2.7f; /* Fill value */ - size_t nslots = 521*2; - size_t nbytes = 1048576 * 10; - double w0 = 0.5f; - unsigned max_compact; - unsigned min_dense; - hsize_t max_size[1]; /*data space maximum size */ - const char* c_to_f = "x+32"; - H5AC_cache_config_t my_cache_config = { - H5AC__CURR_CACHE_CONFIG_VERSION, - TRUE, - FALSE, - FALSE, - "temp", - TRUE, - FALSE, - ( 2 * 2048 * 1024), - 0.3f, - (64 * 1024 * 1024), - (4 * 1024 * 1024), - 60000, - H5C_incr__threshold, - 0.8f, - 3.0f, - TRUE, - (8 * 1024 * 1024), - H5C_flash_incr__add_space, - 2.0f, - 0.25f, - H5C_decr__age_out_with_threshold, - 0.997f, - 0.8f, - TRUE, - (3 * 1024 * 1024), - 3, - FALSE, - 0.2f, - (256 * 2048), - H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; - - herr_t ret; /* Generic return value */ - - if(VERBOSE_MED) - HDprintf("Encode/Decode DCPLs\n"); + hsize_t chunk_size = 16384; /* chunk size */ + double fill = 2.7f; /* Fill value */ + size_t nslots = 521 * 2; + size_t nbytes = 1048576 * 10; + double w0 = 0.5f; + unsigned max_compact; + unsigned min_dense; + hsize_t max_size[1]; /*data space maximum size */ + const char * c_to_f = "x+32"; + H5AC_cache_config_t my_cache_config = {H5AC__CURR_CACHE_CONFIG_VERSION, + TRUE, + FALSE, + FALSE, + "temp", + TRUE, + FALSE, + (2 * 2048 * 1024), + 0.3f, + (64 * 1024 * 1024), + (4 * 1024 * 1024), + 60000, + H5C_incr__threshold, + 0.8f, + 3.0f, + TRUE, + (8 * 1024 * 1024), + H5C_flash_incr__add_space, + 2.0f, + 0.25f, + H5C_decr__age_out_with_threshold, + 0.997f, + 0.8f, + TRUE, + (3 * 1024 * 1024), + 3, + FALSE, + 0.2f, + (256 * 2048), + H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + + herr_t ret; /* Generic return value */ + + if (VERBOSE_MED) + HDprintf("Encode/Decode DCPLs\n"); /* set up MPI parameters */ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - if(mpi_size == 1) + if (mpi_size == 1) recv_proc = 0; else recv_proc = 1; @@ -162,21 +161,17 @@ test_plist_ed(void) VRFY((ret >= 0), "H5Pset_alloc_time succeeded"); ret = H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill); - VRFY((ret>=0), "set fill-value succeeded"); + VRFY((ret >= 0), "set fill-value succeeded"); max_size[0] = 100; - ret = H5Pset_external(dcpl, "ext1.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4)); - VRFY((ret>=0), "set external succeeded"); - ret = H5Pset_external(dcpl, "ext2.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4)); - VRFY((ret>=0), "set external succeeded"); - ret = H5Pset_external(dcpl, "ext3.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4)); - VRFY((ret>=0), "set external succeeded"); - ret = H5Pset_external(dcpl, "ext4.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4)); - VRFY((ret>=0), "set external succeeded"); + ret = H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4)); + VRFY((ret >= 0), "set external succeeded"); + ret = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4)); + VRFY((ret >= 0), "set external succeeded"); + ret = H5Pset_external(dcpl, "ext3.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4)); + VRFY((ret >= 0), "set external succeeded"); + ret = H5Pset_external(dcpl, "ext4.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4)); + VRFY((ret >= 0), "set external succeeded"); ret = test_encode_decode(dcpl, mpi_rank, recv_proc); VRFY((ret >= 0), "test_encode_decode succeeded"); @@ -184,7 +179,6 @@ test_plist_ed(void) ret = H5Pclose(dcpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE DAPLS *****/ dapl = H5Pcreate(H5P_DATASET_ACCESS); VRFY((dapl >= 0), "H5Pcreate succeeded"); @@ -198,7 +192,6 @@ test_plist_ed(void) ret = H5Pclose(dapl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE OCPLS *****/ ocpl = H5Pcreate(H5P_OBJECT_CREATE); VRFY((ocpl >= 0), "H5Pcreate succeeded"); @@ -218,7 +211,6 @@ test_plist_ed(void) ret = H5Pclose(ocpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE DXPLS *****/ dxpl = H5Pcreate(H5P_DATASET_XFER); VRFY((dxpl >= 0), "H5Pcreate succeeded"); @@ -256,7 +248,6 @@ test_plist_ed(void) ret = H5Pclose(dxpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE GCPLS *****/ gcpl = H5Pcreate(H5P_GROUP_CREATE); VRFY((gcpl >= 0), "H5Pcreate succeeded"); @@ -283,12 +274,11 @@ test_plist_ed(void) ret = H5Pclose(gcpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE LCPLS *****/ lcpl = H5Pcreate(H5P_LINK_CREATE); VRFY((lcpl >= 0), "H5Pcreate succeeded"); - ret= H5Pset_create_intermediate_group(lcpl, TRUE); + ret = H5Pset_create_intermediate_group(lcpl, TRUE); VRFY((ret >= 0), "H5Pset_create_intermediate_group succeeded"); ret = test_encode_decode(lcpl, mpi_rank, recv_proc); @@ -297,7 +287,6 @@ test_plist_ed(void) ret = H5Pclose(lcpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE LAPLS *****/ lapl = H5Pcreate(H5P_LINK_ACCESS); VRFY((lapl >= 0), "H5Pcreate succeeded"); @@ -330,7 +319,6 @@ test_plist_ed(void) ret = H5Pclose(lapl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE OCPYPLS *****/ ocpypl = H5Pcreate(H5P_OBJECT_COPY); VRFY((ocpypl >= 0), "H5Pcreate succeeded"); @@ -350,7 +338,6 @@ test_plist_ed(void) ret = H5Pclose(ocpypl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE FAPLS *****/ fapl = H5Pcreate(H5P_FILE_ACCESS); VRFY((fapl >= 0), "H5Pcreate succeeded"); @@ -397,7 +384,6 @@ test_plist_ed(void) ret = H5Pclose(fapl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE FCPLS *****/ fcpl = H5Pcreate(H5P_FILE_CREATE); VRFY((fcpl >= 0), "H5Pcreate succeeded"); @@ -414,7 +400,7 @@ test_plist_ed(void) ret = H5Pset_shared_mesg_nindexes(fcpl, 8); VRFY((ret >= 0), "H5Pset_shared_mesg_nindexes succeeded"); - ret = H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32); + ret = H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32); VRFY((ret >= 0), "H5Pset_shared_mesg_index succeeded"); ret = H5Pset_shared_mesg_phase_change(fcpl, 60, 20); @@ -429,7 +415,6 @@ test_plist_ed(void) ret = H5Pclose(fcpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE STRCPLS *****/ strcpl = H5Pcreate(H5P_STRING_CREATE); VRFY((strcpl >= 0), "H5Pcreate succeeded"); @@ -443,7 +428,6 @@ test_plist_ed(void) ret = H5Pclose(strcpl); VRFY((ret >= 0), "H5Pclose succeeded"); - /******* ENCODE/DECODE ACPLS *****/ acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE); VRFY((acpl >= 0), "H5Pcreate succeeded"); @@ -457,4 +441,3 @@ test_plist_ed(void) ret = H5Pclose(acpl); VRFY((ret >= 0), "H5Pclose succeeded"); } - diff --git a/testpar/t_pshutdown.c b/testpar/t_pshutdown.c index 6a35fb2..5940ba8 100644 --- a/testpar/t_pshutdown.c +++ b/testpar/t_pshutdown.c @@ -25,36 +25,33 @@ #include "testphdf5.h" -int nerrors = 0; /* errors count */ +int nerrors = 0; /* errors count */ -const char *FILENAME[] = { - "shutdown", - NULL -}; +const char *FILENAME[] = {"shutdown", NULL}; int -main (int argc, char **argv) +main(int argc, char **argv) { - hid_t file_id, dset_id, grp_id; - hid_t fapl, sid, mem_dataspace; - hsize_t dims[RANK], i; - herr_t ret; - char filename[1024]; - int mpi_size, mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - hsize_t start[RANK]; - hsize_t count[RANK]; - hsize_t stride[RANK]; - hsize_t block[RANK]; - DATATYPE *data_array = NULL; /* data buffer */ + hid_t file_id, dset_id, grp_id; + hid_t fapl, sid, mem_dataspace; + hsize_t dims[RANK], i; + herr_t ret; + char filename[1024]; + int mpi_size, mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + hsize_t start[RANK]; + hsize_t count[RANK]; + hsize_t stride[RANK]; + hsize_t block[RANK]; + DATATYPE *data_array = NULL; /* data buffer */ MPI_Init(&argc, &argv); MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - if(MAINPROCESS) - TESTING("proper shutdown of HDF5 library"); + if (MAINPROCESS) + TESTING("proper shutdown of HDF5 library"); /* Set up file access property list with parallel I/O access */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -68,58 +65,57 @@ main (int argc, char **argv) grp_id = H5Gcreate2(file_id, "Group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((grp_id >= 0), "H5Gcreate succeeded"); - dims[0] = (hsize_t)ROW_FACTOR*(hsize_t)mpi_size; - dims[1] = (hsize_t)COL_FACTOR*(hsize_t)mpi_size; - sid = H5Screate_simple (RANK, dims, NULL); + dims[0] = (hsize_t)ROW_FACTOR * (hsize_t)mpi_size; + dims[1] = (hsize_t)COL_FACTOR * (hsize_t)mpi_size; + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); dset_id = H5Dcreate2(grp_id, "Dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), "H5Dcreate succeeded"); /* allocate memory for data buffer */ - data_array = (DATATYPE *)HDmalloc(dims[0]*dims[1]*sizeof(DATATYPE)); + data_array = (DATATYPE *)HDmalloc(dims[0] * dims[1] * sizeof(DATATYPE)); VRFY((data_array != NULL), "data_array HDmalloc succeeded"); /* Each process takes a slabs of rows. */ - block[0] = dims[0]/(hsize_t)mpi_size; - block[1] = dims[1]; + block[0] = dims[0] / (hsize_t)mpi_size; + block[1] = dims[1]; stride[0] = block[0]; stride[1] = block[1]; - count[0] = 1; - count[1] = 1; - start[0] = (hsize_t)mpi_rank*block[0]; - start[1] = 0; + count[0] = 1; + count[1] = 1; + start[0] = (hsize_t)mpi_rank * block[0]; + start[1] = 0; /* put some trivial data in the data_array */ - for(i=0 ; i= 0), "H5Sset_hyperslab succeeded"); /* create a memory dataspace independently */ - mem_dataspace = H5Screate_simple (RANK, block, NULL); + mem_dataspace = H5Screate_simple(RANK, block, NULL); VRFY((mem_dataspace >= 0), ""); /* write data independently */ - ret = H5Dwrite(dset_id, H5T_NATIVE_INT, mem_dataspace, sid, - H5P_DEFAULT, data_array); + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, mem_dataspace, sid, H5P_DEFAULT, data_array); VRFY((ret >= 0), "H5Dwrite succeeded"); /* release data buffers */ - if(data_array) + if (data_array) HDfree(data_array); MPI_Finalize(); nerrors += GetTestNumErrs(); - if(MAINPROCESS) { - if(0 == nerrors) + if (MAINPROCESS) { + if (0 == nerrors) PASSED(); else - H5_FAILED() + H5_FAILED() } - return (nerrors!=0); + return (nerrors != 0); } diff --git a/testpar/t_shapesame.c b/testpar/t_shapesame.c index 34fcc72..9ef3178 100644 --- a/testpar/t_shapesame.c +++ b/testpar/t_shapesame.c @@ -16,16 +16,14 @@ same shape by H5Sselect_shape_same(). */ -#define H5S_FRIEND /*suppress error about including H5Spkg */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ /* Define this macro to indicate that the testing APIs should be available */ #define H5S_TESTING - -#include "H5Spkg.h" /* Dataspaces */ +#include "H5Spkg.h" /* Dataspaces */ #include "testphdf5.h" - /* On Lustre (and perhaps other parallel file systems?), we have severe * slow downs if two or more processes attempt to access the same file system * block. To minimize this problem, we set alignment in the shape same tests @@ -33,71 +31,69 @@ * the chunked dataset case. */ -#define SHAPE_SAME_TEST_ALIGNMENT ((hsize_t)(4 * 1024 * 1024)) - - -#define PAR_SS_DR_MAX_RANK 5 /* must update code if this changes */ - -struct hs_dr_pio_test_vars_t -{ - int mpi_size; - int mpi_rank; - MPI_Comm mpi_comm; - MPI_Info mpi_info; - int test_num; - int edge_size; - int checker_edge_size; - int chunk_edge_size; - int small_rank; - int large_rank; - hid_t dset_type; - uint32_t * small_ds_buf_0; - uint32_t * small_ds_buf_1; - uint32_t * small_ds_buf_2; - uint32_t * small_ds_slice_buf; - uint32_t * large_ds_buf_0; - uint32_t * large_ds_buf_1; - uint32_t * large_ds_buf_2; - uint32_t * large_ds_slice_buf; - int small_ds_offset; - int large_ds_offset; - hid_t fid; /* HDF5 file ID */ - hid_t xfer_plist; - hid_t full_mem_small_ds_sid; - hid_t full_file_small_ds_sid; - hid_t mem_small_ds_sid; - hid_t file_small_ds_sid_0; - hid_t file_small_ds_sid_1; - hid_t small_ds_slice_sid; - hid_t full_mem_large_ds_sid; - hid_t full_file_large_ds_sid; - hid_t mem_large_ds_sid; - hid_t file_large_ds_sid_0; - hid_t file_large_ds_sid_1; - hid_t file_large_ds_process_slice_sid; - hid_t mem_large_ds_process_slice_sid; - hid_t large_ds_slice_sid; - hid_t small_dataset; /* Dataset ID */ - hid_t large_dataset; /* Dataset ID */ - size_t small_ds_size; - size_t small_ds_slice_size; - size_t large_ds_size; - size_t large_ds_slice_size; - hsize_t dims[PAR_SS_DR_MAX_RANK]; - hsize_t chunk_dims[PAR_SS_DR_MAX_RANK]; - hsize_t start[PAR_SS_DR_MAX_RANK]; - hsize_t stride[PAR_SS_DR_MAX_RANK]; - hsize_t count[PAR_SS_DR_MAX_RANK]; - hsize_t block[PAR_SS_DR_MAX_RANK]; - hsize_t * start_ptr; - hsize_t * stride_ptr; - hsize_t * count_ptr; - hsize_t * block_ptr; - int skips; - int max_skips; - int64_t total_tests; - int64_t tests_run; - int64_t tests_skipped; +#define SHAPE_SAME_TEST_ALIGNMENT ((hsize_t)(4 * 1024 * 1024)) + +#define PAR_SS_DR_MAX_RANK 5 /* must update code if this changes */ + +struct hs_dr_pio_test_vars_t { + int mpi_size; + int mpi_rank; + MPI_Comm mpi_comm; + MPI_Info mpi_info; + int test_num; + int edge_size; + int checker_edge_size; + int chunk_edge_size; + int small_rank; + int large_rank; + hid_t dset_type; + uint32_t *small_ds_buf_0; + uint32_t *small_ds_buf_1; + uint32_t *small_ds_buf_2; + uint32_t *small_ds_slice_buf; + uint32_t *large_ds_buf_0; + uint32_t *large_ds_buf_1; + uint32_t *large_ds_buf_2; + uint32_t *large_ds_slice_buf; + int small_ds_offset; + int large_ds_offset; + hid_t fid; /* HDF5 file ID */ + hid_t xfer_plist; + hid_t full_mem_small_ds_sid; + hid_t full_file_small_ds_sid; + hid_t mem_small_ds_sid; + hid_t file_small_ds_sid_0; + hid_t file_small_ds_sid_1; + hid_t small_ds_slice_sid; + hid_t full_mem_large_ds_sid; + hid_t full_file_large_ds_sid; + hid_t mem_large_ds_sid; + hid_t file_large_ds_sid_0; + hid_t file_large_ds_sid_1; + hid_t file_large_ds_process_slice_sid; + hid_t mem_large_ds_process_slice_sid; + hid_t large_ds_slice_sid; + hid_t small_dataset; /* Dataset ID */ + hid_t large_dataset; /* Dataset ID */ + size_t small_ds_size; + size_t small_ds_slice_size; + size_t large_ds_size; + size_t large_ds_slice_size; + hsize_t dims[PAR_SS_DR_MAX_RANK]; + hsize_t chunk_dims[PAR_SS_DR_MAX_RANK]; + hsize_t start[PAR_SS_DR_MAX_RANK]; + hsize_t stride[PAR_SS_DR_MAX_RANK]; + hsize_t count[PAR_SS_DR_MAX_RANK]; + hsize_t block[PAR_SS_DR_MAX_RANK]; + hsize_t * start_ptr; + hsize_t * stride_ptr; + hsize_t * count_ptr; + hsize_t * block_ptr; + int skips; + int max_skips; + int64_t total_tests; + int64_t tests_run; + int64_t tests_skipped; }; /*------------------------------------------------------------------------- @@ -116,60 +112,53 @@ struct hs_dr_pio_test_vars_t #define CONTIG_HS_DR_PIO_TEST__SETUP__DEBUG 0 static void -hs_dr_pio_test__setup(const int test_num, - const int edge_size, - const int checker_edge_size, - const int chunk_edge_size, - const int small_rank, - const int large_rank, - const hbool_t use_collective_io, - const hid_t dset_type, - const int express_test, - struct hs_dr_pio_test_vars_t * tv_ptr) +hs_dr_pio_test__setup(const int test_num, const int edge_size, const int checker_edge_size, + const int chunk_edge_size, const int small_rank, const int large_rank, + const hbool_t use_collective_io, const hid_t dset_type, const int express_test, + struct hs_dr_pio_test_vars_t *tv_ptr) { #if CONTIG_HS_DR_PIO_TEST__SETUP__DEBUG const char *fcnName = "hs_dr_pio_test__setup()"; #endif /* CONTIG_HS_DR_PIO_TEST__SETUP__DEBUG */ const char *filename; - hbool_t mis_match = FALSE; - int i; + hbool_t mis_match = FALSE; + int i; int mrc; - int mpi_rank; /* needed by the VRFY macro */ + int mpi_rank; /* needed by the VRFY macro */ uint32_t expected_value; - uint32_t * ptr_0; - uint32_t * ptr_1; - hid_t acc_tpl; /* File access templates */ + uint32_t * ptr_0; + uint32_t * ptr_1; + hid_t acc_tpl; /* File access templates */ hid_t small_ds_dcpl_id = H5P_DEFAULT; hid_t large_ds_dcpl_id = H5P_DEFAULT; - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ - HDassert( edge_size >= 6 ); - HDassert( edge_size >= chunk_edge_size ); - HDassert( ( chunk_edge_size == 0 ) || ( chunk_edge_size >= 3 ) ); - HDassert( 1 < small_rank ); - HDassert( small_rank < large_rank ); - HDassert( large_rank <= PAR_SS_DR_MAX_RANK ); + HDassert(edge_size >= 6); + HDassert(edge_size >= chunk_edge_size); + HDassert((chunk_edge_size == 0) || (chunk_edge_size >= 3)); + HDassert(1 < small_rank); + HDassert(small_rank < large_rank); + HDassert(large_rank <= PAR_SS_DR_MAX_RANK); - tv_ptr->test_num = test_num; - tv_ptr->edge_size = edge_size; + tv_ptr->test_num = test_num; + tv_ptr->edge_size = edge_size; tv_ptr->checker_edge_size = checker_edge_size; - tv_ptr->chunk_edge_size = chunk_edge_size; - tv_ptr->small_rank = small_rank; - tv_ptr->large_rank = large_rank; - tv_ptr->dset_type = dset_type; + tv_ptr->chunk_edge_size = chunk_edge_size; + tv_ptr->small_rank = small_rank; + tv_ptr->large_rank = large_rank; + tv_ptr->dset_type = dset_type; MPI_Comm_size(MPI_COMM_WORLD, &(tv_ptr->mpi_size)); MPI_Comm_rank(MPI_COMM_WORLD, &(tv_ptr->mpi_rank)); /* the VRFY() macro needs the local variable mpi_rank -- set it up now */ mpi_rank = tv_ptr->mpi_rank; - HDassert( tv_ptr->mpi_size >= 1 ); + HDassert(tv_ptr->mpi_size >= 1); tv_ptr->mpi_comm = MPI_COMM_WORLD; tv_ptr->mpi_info = MPI_INFO_NULL; - for ( i = 0; i < tv_ptr->small_rank - 1; i++ ) - { + for (i = 0; i < tv_ptr->small_rank - 1; i++) { tv_ptr->small_ds_size *= (size_t)(tv_ptr->edge_size); tv_ptr->small_ds_slice_size *= (size_t)(tv_ptr->edge_size); } @@ -178,10 +167,10 @@ hs_dr_pio_test__setup(const int test_num, /* used by checker board tests only */ tv_ptr->small_ds_offset = PAR_SS_DR_MAX_RANK - tv_ptr->small_rank; - HDassert( 0 < tv_ptr->small_ds_offset ); - HDassert( tv_ptr->small_ds_offset < PAR_SS_DR_MAX_RANK ); + HDassert(0 < tv_ptr->small_ds_offset); + HDassert(tv_ptr->small_ds_offset < PAR_SS_DR_MAX_RANK); - for ( i = 0; i < tv_ptr->large_rank - 1; i++ ) { + for (i = 0; i < tv_ptr->large_rank - 1; i++) { tv_ptr->large_ds_size *= (size_t)(tv_ptr->edge_size); tv_ptr->large_ds_slice_size *= (size_t)(tv_ptr->edge_size); @@ -191,9 +180,8 @@ hs_dr_pio_test__setup(const int test_num, /* used by checker board tests only */ tv_ptr->large_ds_offset = PAR_SS_DR_MAX_RANK - tv_ptr->large_rank; - HDassert( 0 <= tv_ptr->large_ds_offset ); - HDassert( tv_ptr->large_ds_offset < PAR_SS_DR_MAX_RANK ); - + HDassert(0 <= tv_ptr->large_ds_offset); + HDassert(tv_ptr->large_ds_offset < PAR_SS_DR_MAX_RANK); /* set up the start, stride, count, and block pointers */ /* used by contiguous tests only */ @@ -202,7 +190,6 @@ hs_dr_pio_test__setup(const int test_num, tv_ptr->count_ptr = &(tv_ptr->count[PAR_SS_DR_MAX_RANK - tv_ptr->large_rank]); tv_ptr->block_ptr = &(tv_ptr->block[PAR_SS_DR_MAX_RANK - tv_ptr->large_rank]); - /* Allocate buffers */ tv_ptr->small_ds_buf_0 = (uint32_t *)HDmalloc(sizeof(uint32_t) * tv_ptr->small_ds_size); VRFY((tv_ptr->small_ds_buf_0 != NULL), "malloc of small_ds_buf_0 succeeded"); @@ -213,8 +200,7 @@ hs_dr_pio_test__setup(const int test_num, tv_ptr->small_ds_buf_2 = (uint32_t *)HDmalloc(sizeof(uint32_t) * tv_ptr->small_ds_size); VRFY((tv_ptr->small_ds_buf_2 != NULL), "malloc of small_ds_buf_2 succeeded"); - tv_ptr->small_ds_slice_buf = - (uint32_t *)HDmalloc(sizeof(uint32_t) * tv_ptr->small_ds_slice_size); + tv_ptr->small_ds_slice_buf = (uint32_t *)HDmalloc(sizeof(uint32_t) * tv_ptr->small_ds_slice_size); VRFY((tv_ptr->small_ds_slice_buf != NULL), "malloc of small_ds_slice_buf succeeded"); tv_ptr->large_ds_buf_0 = (uint32_t *)HDmalloc(sizeof(uint32_t) * tv_ptr->large_ds_size); @@ -226,14 +212,13 @@ hs_dr_pio_test__setup(const int test_num, tv_ptr->large_ds_buf_2 = (uint32_t *)HDmalloc(sizeof(uint32_t) * tv_ptr->large_ds_size); VRFY((tv_ptr->large_ds_buf_2 != NULL), "malloc of large_ds_buf_2 succeeded"); - tv_ptr->large_ds_slice_buf = - (uint32_t *)HDmalloc(sizeof(uint32_t) * tv_ptr->large_ds_slice_size); + tv_ptr->large_ds_slice_buf = (uint32_t *)HDmalloc(sizeof(uint32_t) * tv_ptr->large_ds_slice_size); VRFY((tv_ptr->large_ds_slice_buf != NULL), "malloc of large_ds_slice_buf succeeded"); /* initialize the buffers */ ptr_0 = tv_ptr->small_ds_buf_0; - for(i = 0; i < (int)(tv_ptr->small_ds_size); i++) + for (i = 0; i < (int)(tv_ptr->small_ds_size); i++) *ptr_0++ = (uint32_t)i; HDmemset(tv_ptr->small_ds_buf_1, 0, sizeof(uint32_t) * tv_ptr->small_ds_size); HDmemset(tv_ptr->small_ds_buf_2, 0, sizeof(uint32_t) * tv_ptr->small_ds_size); @@ -241,7 +226,7 @@ hs_dr_pio_test__setup(const int test_num, HDmemset(tv_ptr->small_ds_slice_buf, 0, sizeof(uint32_t) * tv_ptr->small_ds_slice_size); ptr_0 = tv_ptr->large_ds_buf_0; - for(i = 0; i < (int)(tv_ptr->large_ds_size); i++) + for (i = 0; i < (int)(tv_ptr->large_ds_size); i++) *ptr_0++ = (uint32_t)i; HDmemset(tv_ptr->large_ds_buf_1, 0, sizeof(uint32_t) * tv_ptr->large_ds_size); HDmemset(tv_ptr->large_ds_buf_2, 0, sizeof(uint32_t) * tv_ptr->large_ds_size); @@ -249,23 +234,19 @@ hs_dr_pio_test__setup(const int test_num, HDmemset(tv_ptr->large_ds_slice_buf, 0, sizeof(uint32_t) * tv_ptr->large_ds_slice_size); filename = (const char *)GetTestParameters(); - HDassert( filename != NULL ); + HDassert(filename != NULL); #if CONTIG_HS_DR_PIO_TEST__SETUP__DEBUG - if ( MAINPROCESS ) { + if (MAINPROCESS) { HDfprintf(stdout, "%d: test num = %d.\n", tv_ptr->mpi_rank, tv_ptr->test_num); HDfprintf(stdout, "%d: mpi_size = %d.\n", tv_ptr->mpi_rank, tv_ptr->mpi_size); - HDfprintf(stdout, - "%d: small/large rank = %d/%d, use_collective_io = %d.\n", - tv_ptr->mpi_rank, tv_ptr->small_rank, tv_ptr->large_rank, - (int)use_collective_io); - HDfprintf(stdout, "%d: edge_size = %d, chunk_edge_size = %d.\n", - tv_ptr->mpi_rank, tv_ptr->edge_size, tv_ptr->chunk_edge_size); - HDfprintf(stdout, "%d: checker_edge_size = %d.\n", - tv_ptr->mpi_rank, tv_ptr->checker_edge_size); - HDfprintf(stdout, "%d: small_ds_size = %d, large_ds_size = %d.\n", - tv_ptr->mpi_rank, (int)(tv_ptr->small_ds_size), - (int)(tv_ptr->large_ds_size)); + HDfprintf(stdout, "%d: small/large rank = %d/%d, use_collective_io = %d.\n", tv_ptr->mpi_rank, + tv_ptr->small_rank, tv_ptr->large_rank, (int)use_collective_io); + HDfprintf(stdout, "%d: edge_size = %d, chunk_edge_size = %d.\n", tv_ptr->mpi_rank, tv_ptr->edge_size, + tv_ptr->chunk_edge_size); + HDfprintf(stdout, "%d: checker_edge_size = %d.\n", tv_ptr->mpi_rank, tv_ptr->checker_edge_size); + HDfprintf(stdout, "%d: small_ds_size = %d, large_ds_size = %d.\n", tv_ptr->mpi_rank, + (int)(tv_ptr->small_ds_size), (int)(tv_ptr->large_ds_size)); HDfprintf(stdout, "%d: filename = %s.\n", tv_ptr->mpi_rank, filename); } #endif /* CONTIG_HS_DR_PIO_TEST__SETUP__DEBUG */ @@ -280,7 +261,7 @@ hs_dr_pio_test__setup(const int test_num, * the same file system block. Do this only if express_test is greater * than zero. */ - if ( express_test > 0 ) { + if (express_test > 0) { ret = H5Pset_alignment(acc_tpl, (hsize_t)0, SHAPE_SAME_TEST_ALIGNMENT); VRFY((ret != FAIL), "H5Pset_alignment() succeeded"); @@ -296,89 +277,63 @@ hs_dr_pio_test__setup(const int test_num, ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose(acc_tpl) succeeded"); - /* setup dims: */ tv_ptr->dims[0] = (hsize_t)(tv_ptr->mpi_size + 1); - tv_ptr->dims[1] = tv_ptr->dims[2] = - tv_ptr->dims[3] = tv_ptr->dims[4] = (hsize_t)(tv_ptr->edge_size); - + tv_ptr->dims[1] = tv_ptr->dims[2] = tv_ptr->dims[3] = tv_ptr->dims[4] = (hsize_t)(tv_ptr->edge_size); /* Create small ds dataspaces */ - tv_ptr->full_mem_small_ds_sid = - H5Screate_simple(tv_ptr->small_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->full_mem_small_ds_sid != 0), - "H5Screate_simple() full_mem_small_ds_sid succeeded"); + tv_ptr->full_mem_small_ds_sid = H5Screate_simple(tv_ptr->small_rank, tv_ptr->dims, NULL); + VRFY((tv_ptr->full_mem_small_ds_sid != 0), "H5Screate_simple() full_mem_small_ds_sid succeeded"); - tv_ptr->full_file_small_ds_sid = - H5Screate_simple(tv_ptr->small_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->full_file_small_ds_sid != 0), - "H5Screate_simple() full_file_small_ds_sid succeeded"); + tv_ptr->full_file_small_ds_sid = H5Screate_simple(tv_ptr->small_rank, tv_ptr->dims, NULL); + VRFY((tv_ptr->full_file_small_ds_sid != 0), "H5Screate_simple() full_file_small_ds_sid succeeded"); tv_ptr->mem_small_ds_sid = H5Screate_simple(tv_ptr->small_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->mem_small_ds_sid != 0), - "H5Screate_simple() mem_small_ds_sid succeeded"); + VRFY((tv_ptr->mem_small_ds_sid != 0), "H5Screate_simple() mem_small_ds_sid succeeded"); tv_ptr->file_small_ds_sid_0 = H5Screate_simple(tv_ptr->small_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->file_small_ds_sid_0 != 0), - "H5Screate_simple() file_small_ds_sid_0 succeeded"); + VRFY((tv_ptr->file_small_ds_sid_0 != 0), "H5Screate_simple() file_small_ds_sid_0 succeeded"); /* used by checker board tests only */ tv_ptr->file_small_ds_sid_1 = H5Screate_simple(tv_ptr->small_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->file_small_ds_sid_1 != 0), - "H5Screate_simple() file_small_ds_sid_1 succeeded"); - - tv_ptr->small_ds_slice_sid = - H5Screate_simple(tv_ptr->small_rank - 1, &(tv_ptr->dims[1]), NULL); - VRFY((tv_ptr->small_ds_slice_sid != 0), - "H5Screate_simple() small_ds_slice_sid succeeded"); + VRFY((tv_ptr->file_small_ds_sid_1 != 0), "H5Screate_simple() file_small_ds_sid_1 succeeded"); + tv_ptr->small_ds_slice_sid = H5Screate_simple(tv_ptr->small_rank - 1, &(tv_ptr->dims[1]), NULL); + VRFY((tv_ptr->small_ds_slice_sid != 0), "H5Screate_simple() small_ds_slice_sid succeeded"); /* Create large ds dataspaces */ - tv_ptr->full_mem_large_ds_sid = - H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->full_mem_large_ds_sid != 0), - "H5Screate_simple() full_mem_large_ds_sid succeeded"); + tv_ptr->full_mem_large_ds_sid = H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); + VRFY((tv_ptr->full_mem_large_ds_sid != 0), "H5Screate_simple() full_mem_large_ds_sid succeeded"); - tv_ptr->full_file_large_ds_sid = - H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->full_file_large_ds_sid != FAIL), - "H5Screate_simple() full_file_large_ds_sid succeeded"); + tv_ptr->full_file_large_ds_sid = H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); + VRFY((tv_ptr->full_file_large_ds_sid != FAIL), "H5Screate_simple() full_file_large_ds_sid succeeded"); tv_ptr->mem_large_ds_sid = H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->mem_large_ds_sid != FAIL), - "H5Screate_simple() mem_large_ds_sid succeeded"); + VRFY((tv_ptr->mem_large_ds_sid != FAIL), "H5Screate_simple() mem_large_ds_sid succeeded"); tv_ptr->file_large_ds_sid_0 = H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->file_large_ds_sid_0 != FAIL), - "H5Screate_simple() file_large_ds_sid_0 succeeded"); + VRFY((tv_ptr->file_large_ds_sid_0 != FAIL), "H5Screate_simple() file_large_ds_sid_0 succeeded"); /* used by checker board tests only */ tv_ptr->file_large_ds_sid_1 = H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); - VRFY((tv_ptr->file_large_ds_sid_1 != FAIL), - "H5Screate_simple() file_large_ds_sid_1 succeeded"); + VRFY((tv_ptr->file_large_ds_sid_1 != FAIL), "H5Screate_simple() file_large_ds_sid_1 succeeded"); - tv_ptr->mem_large_ds_process_slice_sid = - H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); + tv_ptr->mem_large_ds_process_slice_sid = H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); VRFY((tv_ptr->mem_large_ds_process_slice_sid != FAIL), "H5Screate_simple() mem_large_ds_process_slice_sid succeeded"); - tv_ptr->file_large_ds_process_slice_sid = - H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); + tv_ptr->file_large_ds_process_slice_sid = H5Screate_simple(tv_ptr->large_rank, tv_ptr->dims, NULL); VRFY((tv_ptr->file_large_ds_process_slice_sid != FAIL), "H5Screate_simple() file_large_ds_process_slice_sid succeeded"); - - tv_ptr->large_ds_slice_sid = - H5Screate_simple(tv_ptr->large_rank - 1, &(tv_ptr->dims[1]), NULL); - VRFY((tv_ptr->large_ds_slice_sid != 0), - "H5Screate_simple() large_ds_slice_sid succeeded"); - + tv_ptr->large_ds_slice_sid = H5Screate_simple(tv_ptr->large_rank - 1, &(tv_ptr->dims[1]), NULL); + VRFY((tv_ptr->large_ds_slice_sid != 0), "H5Screate_simple() large_ds_slice_sid succeeded"); /* if chunk edge size is greater than zero, set up the small and * large data set creation property lists to specify chunked * datasets. */ - if ( tv_ptr->chunk_edge_size > 0 ) { + if (tv_ptr->chunk_edge_size > 0) { /* Under Lustre (and perhaps other parallel file systems?) we get * locking delays when two or more processes attempt to access the @@ -400,9 +355,8 @@ hs_dr_pio_test__setup(const int test_num, tv_ptr->chunk_dims[0] = 1; - tv_ptr->chunk_dims[1] = tv_ptr->chunk_dims[2] = - tv_ptr->chunk_dims[3] = - tv_ptr->chunk_dims[4] = (hsize_t)(tv_ptr->chunk_edge_size); + tv_ptr->chunk_dims[1] = tv_ptr->chunk_dims[2] = tv_ptr->chunk_dims[3] = tv_ptr->chunk_dims[4] = + (hsize_t)(tv_ptr->chunk_edge_size); small_ds_dcpl_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((ret != FAIL), "H5Pcreate() small_ds_dcpl_id succeeded"); @@ -413,7 +367,6 @@ hs_dr_pio_test__setup(const int test_num, ret = H5Pset_chunk(small_ds_dcpl_id, tv_ptr->small_rank, tv_ptr->chunk_dims); VRFY((ret != FAIL), "H5Pset_chunk() small_ds_dcpl_id succeeded"); - large_ds_dcpl_id = H5Pcreate(H5P_DATASET_CREATE); VRFY((ret != FAIL), "H5Pcreate() large_ds_dcpl_id succeeded"); @@ -425,79 +378,61 @@ hs_dr_pio_test__setup(const int test_num, } /* create the small dataset */ - tv_ptr->small_dataset = H5Dcreate2(tv_ptr->fid, "small_dataset", tv_ptr->dset_type, - tv_ptr->file_small_ds_sid_0, H5P_DEFAULT, - small_ds_dcpl_id, H5P_DEFAULT); + tv_ptr->small_dataset = + H5Dcreate2(tv_ptr->fid, "small_dataset", tv_ptr->dset_type, tv_ptr->file_small_ds_sid_0, H5P_DEFAULT, + small_ds_dcpl_id, H5P_DEFAULT); VRFY((ret != FAIL), "H5Dcreate2() small_dataset succeeded"); /* create the large dataset */ - tv_ptr->large_dataset = H5Dcreate2(tv_ptr->fid, "large_dataset", tv_ptr->dset_type, - tv_ptr->file_large_ds_sid_0, H5P_DEFAULT, - large_ds_dcpl_id, H5P_DEFAULT); + tv_ptr->large_dataset = + H5Dcreate2(tv_ptr->fid, "large_dataset", tv_ptr->dset_type, tv_ptr->file_large_ds_sid_0, H5P_DEFAULT, + large_ds_dcpl_id, H5P_DEFAULT); VRFY((ret != FAIL), "H5Dcreate2() large_dataset succeeded"); - /* setup xfer property list */ tv_ptr->xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((tv_ptr->xfer_plist >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded"); - if(use_collective_io) { + if (use_collective_io) { ret = H5Pset_dxpl_mpio(tv_ptr->xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); } /* setup selection to write initial data to the small and large data sets */ - tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); + tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); tv_ptr->stride[0] = (hsize_t)(2 * (tv_ptr->mpi_size + 1)); - tv_ptr->count[0] = 1; - tv_ptr->block[0] = 1; + tv_ptr->count[0] = 1; + tv_ptr->block[0] = 1; - for ( i = 1; i < tv_ptr->large_rank; i++ ) { + for (i = 1; i < tv_ptr->large_rank; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); + tv_ptr->count[i] = 1; + tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } /* setup selections for writing initial data to the small data set */ - ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(mem_small_ds_sid, set) suceeded"); - ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_small_ds_sid_0, set) suceeded"); - if ( MAINPROCESS ) { /* add an additional slice to the selections */ + if (MAINPROCESS) { /* add an additional slice to the selections */ tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_size); - ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, - H5S_SELECT_OR, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); - VRFY((ret>= 0), "H5Sselect_hyperslab(mem_small_ds_sid, or) suceeded"); - - ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, - H5S_SELECT_OR, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); - VRFY((ret>= 0), "H5Sselect_hyperslab(file_small_ds_sid_0, or) suceeded"); - } + ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, H5S_SELECT_OR, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); + VRFY((ret >= 0), "H5Sselect_hyperslab(mem_small_ds_sid, or) suceeded"); + ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, H5S_SELECT_OR, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); + VRFY((ret >= 0), "H5Sselect_hyperslab(file_small_ds_sid_0, or) suceeded"); + } /* write the initial value of the small data set to file */ ret = H5Dwrite(tv_ptr->small_dataset, tv_ptr->dset_type, tv_ptr->mem_small_ds_sid, @@ -505,167 +440,124 @@ hs_dr_pio_test__setup(const int test_num, VRFY((ret >= 0), "H5Dwrite() small_dataset initial write succeeded"); - /* sync with the other processes before checking data */ - if ( ! use_collective_io ) { + if (!use_collective_io) { mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync after small dataset writes"); + VRFY((mrc == MPI_SUCCESS), "Sync after small dataset writes"); } /* read the small data set back to verify that it contains the * expected data. Note that each process reads in the entire * data set and verifies it. */ - ret = H5Dread(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->full_mem_small_ds_sid, - tv_ptr->full_file_small_ds_sid, - tv_ptr->xfer_plist, - tv_ptr->small_ds_buf_1); + ret = H5Dread(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->full_mem_small_ds_sid, + tv_ptr->full_file_small_ds_sid, tv_ptr->xfer_plist, tv_ptr->small_ds_buf_1); VRFY((ret >= 0), "H5Dread() small_dataset initial read succeeded"); - /* verify that the correct data was written to the small data set */ expected_value = 0; - mis_match = FALSE; - ptr_1 = tv_ptr->small_ds_buf_1; + mis_match = FALSE; + ptr_1 = tv_ptr->small_ds_buf_1; i = 0; - for ( i = 0; i < (int)(tv_ptr->small_ds_size); i++ ) { + for (i = 0; i < (int)(tv_ptr->small_ds_size); i++) { - if ( *ptr_1 != expected_value ) { + if (*ptr_1 != expected_value) { mis_match = TRUE; } ptr_1++; expected_value++; } - VRFY( (mis_match == FALSE), "small ds init data good."); - + VRFY((mis_match == FALSE), "small ds init data good."); /* setup selections for writing initial data to the large data set */ tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); - ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(mem_large_ds_sid, set) suceeded"); - ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_large_ds_sid_0, set) suceeded"); /* In passing, setup the process slice dataspaces as well */ - ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_process_slice_sid, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); - VRFY((ret >= 0), - "H5Sselect_hyperslab(mem_large_ds_process_slice_sid, set) suceeded"); - - ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_process_slice_sid, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); - VRFY((ret >= 0), - "H5Sselect_hyperslab(file_large_ds_process_slice_sid, set) suceeded"); - - if ( MAINPROCESS ) { /* add an additional slice to the selections */ + ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_process_slice_sid, H5S_SELECT_SET, tv_ptr->start, + tv_ptr->stride, tv_ptr->count, tv_ptr->block); + VRFY((ret >= 0), "H5Sselect_hyperslab(mem_large_ds_process_slice_sid, set) suceeded"); + + ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_process_slice_sid, H5S_SELECT_SET, tv_ptr->start, + tv_ptr->stride, tv_ptr->count, tv_ptr->block); + VRFY((ret >= 0), "H5Sselect_hyperslab(file_large_ds_process_slice_sid, set) suceeded"); + + if (MAINPROCESS) { /* add an additional slice to the selections */ tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_size); - ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, - H5S_SELECT_OR, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); - VRFY((ret>= 0), "H5Sselect_hyperslab(mem_large_ds_sid, or) suceeded"); - - ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, - H5S_SELECT_OR, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); - VRFY((ret>= 0), "H5Sselect_hyperslab(file_large_ds_sid_0, or) suceeded"); - } + ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, H5S_SELECT_OR, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); + VRFY((ret >= 0), "H5Sselect_hyperslab(mem_large_ds_sid, or) suceeded"); + ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, H5S_SELECT_OR, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); + VRFY((ret >= 0), "H5Sselect_hyperslab(file_large_ds_sid_0, or) suceeded"); + } /* write the initial value of the large data set to file */ - ret = H5Dwrite(tv_ptr->large_dataset, tv_ptr->dset_type, - tv_ptr->mem_large_ds_sid, tv_ptr->file_large_ds_sid_0, - tv_ptr->xfer_plist, tv_ptr->large_ds_buf_0); - if ( ret < 0 ) H5Eprint2(H5E_DEFAULT, stderr); + ret = H5Dwrite(tv_ptr->large_dataset, tv_ptr->dset_type, tv_ptr->mem_large_ds_sid, + tv_ptr->file_large_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_0); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stderr); VRFY((ret >= 0), "H5Dwrite() large_dataset initial write succeeded"); - /* sync with the other processes before checking data */ - if ( ! use_collective_io ) { + if (!use_collective_io) { mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync after large dataset writes"); + VRFY((mrc == MPI_SUCCESS), "Sync after large dataset writes"); } - /* read the large data set back to verify that it contains the * expected data. Note that each process reads in the entire * data set. */ - ret = H5Dread(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->full_mem_large_ds_sid, - tv_ptr->full_file_large_ds_sid, - tv_ptr->xfer_plist, - tv_ptr->large_ds_buf_1); + ret = H5Dread(tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->full_mem_large_ds_sid, + tv_ptr->full_file_large_ds_sid, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_1); VRFY((ret >= 0), "H5Dread() large_dataset initial read succeeded"); - /* verify that the correct data was written to the large data set */ expected_value = 0; - mis_match = FALSE; - ptr_1 = tv_ptr->large_ds_buf_1; + mis_match = FALSE; + ptr_1 = tv_ptr->large_ds_buf_1; i = 0; - for ( i = 0; i < (int)(tv_ptr->large_ds_size); i++ ) { + for (i = 0; i < (int)(tv_ptr->large_ds_size); i++) { - if ( *ptr_1 != expected_value ) { + if (*ptr_1 != expected_value) { mis_match = TRUE; } ptr_1++; expected_value++; } - VRFY( (mis_match == FALSE), "large ds init data good."); - + VRFY((mis_match == FALSE), "large ds init data good."); /* sync with the other processes before changing data */ - if ( ! use_collective_io ) { + if (!use_collective_io) { mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync initial values check"); + VRFY((mrc == MPI_SUCCESS), "Sync initial values check"); } return; } /* hs_dr_pio_test__setup() */ - /*------------------------------------------------------------------------- * Function: hs_dr_pio_test__takedown() * @@ -682,19 +574,19 @@ hs_dr_pio_test__setup(const int test_num, #define HS_DR_PIO_TEST__TAKEDOWN__DEBUG 0 static void -hs_dr_pio_test__takedown( struct hs_dr_pio_test_vars_t * tv_ptr) +hs_dr_pio_test__takedown(struct hs_dr_pio_test_vars_t *tv_ptr) { #if HS_DR_PIO_TEST__TAKEDOWN__DEBUG const char *fcnName = "hs_dr_pio_test__takedown()"; -#endif /* HS_DR_PIO_TEST__TAKEDOWN__DEBUG */ - int mpi_rank; /* needed by the VRFY macro */ - herr_t ret; /* Generic return value */ +#endif /* HS_DR_PIO_TEST__TAKEDOWN__DEBUG */ + int mpi_rank; /* needed by the VRFY macro */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; /* Close property lists */ - if ( tv_ptr->xfer_plist != H5P_DEFAULT ) { + if (tv_ptr->xfer_plist != H5P_DEFAULT) { ret = H5Pclose(tv_ptr->xfer_plist); VRFY((ret != FAIL), "H5Pclose(xfer_plist) succeeded"); } @@ -756,21 +648,28 @@ hs_dr_pio_test__takedown( struct hs_dr_pio_test_vars_t * tv_ptr) /* Free memory buffers */ - if ( tv_ptr->small_ds_buf_0 != NULL ) HDfree(tv_ptr->small_ds_buf_0); - if ( tv_ptr->small_ds_buf_1 != NULL ) HDfree(tv_ptr->small_ds_buf_1); - if ( tv_ptr->small_ds_buf_2 != NULL ) HDfree(tv_ptr->small_ds_buf_2); - if ( tv_ptr->small_ds_slice_buf != NULL ) HDfree(tv_ptr->small_ds_slice_buf); - - if ( tv_ptr->large_ds_buf_0 != NULL ) HDfree(tv_ptr->large_ds_buf_0); - if ( tv_ptr->large_ds_buf_1 != NULL ) HDfree(tv_ptr->large_ds_buf_1); - if ( tv_ptr->large_ds_buf_2 != NULL ) HDfree(tv_ptr->large_ds_buf_2); - if ( tv_ptr->large_ds_slice_buf != NULL ) HDfree(tv_ptr->large_ds_slice_buf); + if (tv_ptr->small_ds_buf_0 != NULL) + HDfree(tv_ptr->small_ds_buf_0); + if (tv_ptr->small_ds_buf_1 != NULL) + HDfree(tv_ptr->small_ds_buf_1); + if (tv_ptr->small_ds_buf_2 != NULL) + HDfree(tv_ptr->small_ds_buf_2); + if (tv_ptr->small_ds_slice_buf != NULL) + HDfree(tv_ptr->small_ds_slice_buf); + + if (tv_ptr->large_ds_buf_0 != NULL) + HDfree(tv_ptr->large_ds_buf_0); + if (tv_ptr->large_ds_buf_1 != NULL) + HDfree(tv_ptr->large_ds_buf_1); + if (tv_ptr->large_ds_buf_2 != NULL) + HDfree(tv_ptr->large_ds_buf_2); + if (tv_ptr->large_ds_slice_buf != NULL) + HDfree(tv_ptr->large_ds_slice_buf); return; } /* hs_dr_pio_test__takedown() */ - /*------------------------------------------------------------------------- * Function: contig_hs_dr_pio_test__d2m_l2s() * @@ -796,24 +695,23 @@ hs_dr_pio_test__takedown( struct hs_dr_pio_test_vars_t * tv_ptr) #define CONTIG_HS_DR_PIO_TEST__D2M_L2S__DEBUG 0 static void -contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) +contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t *tv_ptr) { #if CONTIG_HS_DR_PIO_TEST__D2M_L2S__DEBUG const char *fcnName = "contig_hs_dr_pio_test__run_test()"; #endif /* CONTIG_HS_DR_PIO_TEST__D2M_L2S__DEBUG */ - hbool_t mis_match = FALSE; - int i, j, k, l; + hbool_t mis_match = FALSE; + int i, j, k, l; size_t n; - int mpi_rank; /* needed by the VRFY macro */ - uint32_t expected_value; - uint32_t * ptr_1; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + int mpi_rank; /* needed by the VRFY macro */ + uint32_t expected_value; + uint32_t *ptr_1; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; - /* We have already done a H5Sselect_all() on the dataspace * small_ds_slice_sid in the initialization phase, so no need to * call H5Sselect_all() again. @@ -822,16 +720,16 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* set up start, stride, count, and block -- note that we will * change start[] so as to read slices of the large cube. */ - for ( i = 0; i < PAR_SS_DR_MAX_RANK; i++ ) { + for (i = 0; i < PAR_SS_DR_MAX_RANK; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - if ( (PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1) ) { + tv_ptr->count[i] = 1; + if ((PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1)) { tv_ptr->block[i] = 1; - - } else { + } + else { tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } @@ -841,9 +739,7 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) HDmemset(tv_ptr->small_ds_slice_buf, 0, sizeof(uint32_t) * tv_ptr->small_ds_slice_size); #if CONTIG_HS_DR_PIO_TEST__D2M_L2S__DEBUG - HDfprintf(stdout, - "%s reading slices from big cube on disk into small cube slice.\n", - fcnName); + HDfprintf(stdout, "%s reading slices from big cube on disk into small cube slice.\n", fcnName); #endif /* CONTIG_HS_DR_PIO_TEST__D2M_L2S__DEBUG */ /* in serial versions of this test, we loop through all the dimensions @@ -853,11 +749,11 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * mpi_rank, and don't itterate over it. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0) { i = tv_ptr->mpi_rank; - - } else { + } + else { i = 0; } @@ -868,21 +764,21 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * test. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1) { j = tv_ptr->mpi_rank; - - } else { + } + else { j = 0; } do { - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2) { k = tv_ptr->mpi_rank; - - } else { + } + else { k = 0; } @@ -900,11 +796,11 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) l = 0; do { - if ( (tv_ptr->skips)++ < tv_ptr->max_skips ) { /* skip the test */ - - (tv_ptr->tests_skipped)++; + if ((tv_ptr->skips)++ < tv_ptr->max_skips) { /* skip the test */ - } else { /* run the test */ + (tv_ptr->tests_skipped)++; + } + else { /* run the test */ tv_ptr->skips = 0; /* reset the skips counter */ @@ -918,15 +814,9 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, - H5S_SELECT_SET, - tv_ptr->start_ptr, - tv_ptr->stride_ptr, - tv_ptr->count_ptr, - tv_ptr->block_ptr); - VRFY((ret != FAIL), - "H5Sselect_hyperslab(file_large_cube_sid) succeeded"); - + ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, H5S_SELECT_SET, tv_ptr->start_ptr, + tv_ptr->stride_ptr, tv_ptr->count_ptr, tv_ptr->block_ptr); + VRFY((ret != FAIL), "H5Sselect_hyperslab(file_large_cube_sid) succeeded"); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -934,42 +824,32 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) check = H5Sselect_shape_same(tv_ptr->small_ds_slice_sid, tv_ptr->file_large_ds_sid_0); VRFY((check == TRUE), "H5Sselect_shape_same passed"); - /* Read selection from disk */ #if CONTIG_HS_DR_PIO_TEST__D2M_L2S__DEBUG - HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", - fcnName, (int)(tv_ptr->mpi_rank), - (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), - (int)(tv_ptr->start[2]), (int)(tv_ptr->start[3]), - (int)(tv_ptr->start[4])); - HDfprintf(stdout, "%s slice/file extent dims = %d/%d.\n", - fcnName, + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, (int)(tv_ptr->mpi_rank), + (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), (int)(tv_ptr->start[2]), + (int)(tv_ptr->start[3]), (int)(tv_ptr->start[4])); + HDfprintf(stdout, "%s slice/file extent dims = %d/%d.\n", fcnName, H5Sget_simple_extent_ndims(tv_ptr->small_ds_slice_sid), H5Sget_simple_extent_ndims(tv_ptr->file_large_ds_sid_0)); #endif /* CONTIG_HS_DR_PIO_TEST__D2M_L2S__DEBUG */ - ret = H5Dread(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->small_ds_slice_sid, - tv_ptr->file_large_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->small_ds_slice_buf); + ret = + H5Dread(tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->small_ds_slice_sid, + tv_ptr->file_large_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->small_ds_slice_buf); VRFY((ret >= 0), "H5Dread() slice from large ds succeeded."); - /* verify that expected data is retrieved */ - mis_match = FALSE; - ptr_1 = tv_ptr->small_ds_slice_buf; + mis_match = FALSE; + ptr_1 = tv_ptr->small_ds_slice_buf; expected_value = (uint32_t)( - (i * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size * tv_ptr->edge_size) + + (i * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + - (k * tv_ptr->edge_size * tv_ptr->edge_size) + - (l * tv_ptr->edge_size)); + (k * tv_ptr->edge_size * tv_ptr->edge_size) + (l * tv_ptr->edge_size)); - for ( n = 0; n < tv_ptr->small_ds_slice_size; n++ ) { + for (n = 0; n < tv_ptr->small_ds_slice_size; n++) { - if ( *ptr_1 != expected_value ) { + if (*ptr_1 != expected_value) { mis_match = TRUE; } @@ -980,33 +860,25 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) expected_value++; } - VRFY((mis_match == FALSE), - "small slice read from large ds data good."); + VRFY((mis_match == FALSE), "small slice read from large ds data good."); - (tv_ptr->tests_run)++; + (tv_ptr->tests_run)++; } l++; (tv_ptr->total_tests)++; - } while ( ( tv_ptr->large_rank > 2 ) && - ( (tv_ptr->small_rank - 1) <= 1 ) && - ( l < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 2) && ((tv_ptr->small_rank - 1) <= 1) && (l < tv_ptr->edge_size)); k++; - } while ( ( tv_ptr->large_rank > 3 ) && - ( (tv_ptr->small_rank - 1) <= 2 ) && - ( k < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 3) && ((tv_ptr->small_rank - 1) <= 2) && (k < tv_ptr->edge_size)); j++; - } while ( ( tv_ptr->large_rank > 4 ) && - ( (tv_ptr->small_rank - 1) <= 3 ) && - ( j < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 4) && ((tv_ptr->small_rank - 1) <= 3) && (j < tv_ptr->edge_size)); return; } /* contig_hs_dr_pio_test__d2m_l2s() */ - /*------------------------------------------------------------------------- * Function: contig_hs_dr_pio_test__d2m_s2l() * @@ -1032,21 +904,21 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) #define CONTIG_HS_DR_PIO_TEST__D2M_S2L__DEBUG 0 static void -contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) +contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t *tv_ptr) { #if CONTIG_HS_DR_PIO_TEST__D2M_S2L__DEBUG const char *fcnName = "contig_hs_dr_pio_test__d2m_s2l()"; #endif /* CONTIG_HS_DR_PIO_TEST__D2M_S2L__DEBUG */ - hbool_t mis_match = FALSE; - int i, j, k, l; + hbool_t mis_match = FALSE; + int i, j, k, l; size_t n; - int mpi_rank; /* needed by the VRFY macro */ - size_t start_index; - size_t stop_index; - uint32_t expected_value; - uint32_t * ptr_1; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + int mpi_rank; /* needed by the VRFY macro */ + size_t start_index; + size_t stop_index; + uint32_t expected_value; + uint32_t *ptr_1; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; @@ -1056,32 +928,25 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * data (and only the correct data) is read. */ - tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); + tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); tv_ptr->stride[0] = (hsize_t)(2 * (tv_ptr->mpi_size + 1)); - tv_ptr->count[0] = 1; - tv_ptr->block[0] = 1; + tv_ptr->count[0] = 1; + tv_ptr->block[0] = 1; - for ( i = 1; i < tv_ptr->large_rank; i++ ) { + for (i = 1; i < tv_ptr->large_rank; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); + tv_ptr->count[i] = 1; + tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } - ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_small_ds_sid_0, set) suceeded"); - #if CONTIG_HS_DR_PIO_TEST__D2M_S2L__DEBUG - HDfprintf(stdout, - "%s reading slices of on disk small data set into slices of big data set.\n", - fcnName); + HDfprintf(stdout, "%s reading slices of on disk small data set into slices of big data set.\n", fcnName); #endif /* CONTIG_HS_DR_PIO_TEST__D2M_S2L__DEBUG */ /* zero out the in memory large ds */ @@ -1090,22 +955,21 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) /* set up start, stride, count, and block -- note that we will * change start[] so as to read slices of the large cube. */ - for ( i = 0; i < PAR_SS_DR_MAX_RANK; i++ ) { + for (i = 0; i < PAR_SS_DR_MAX_RANK; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - if ( (PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1) ) { + tv_ptr->count[i] = 1; + if ((PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1)) { tv_ptr->block[i] = 1; - - } else { + } + else { tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } } - /* in serial versions of this test, we loop through all the dimensions * of the large data set that don't appear in the small data set. * @@ -1115,12 +979,11 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * over it. */ - - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0) { i = tv_ptr->mpi_rank; - - } else { + } + else { i = 0; } @@ -1131,21 +994,21 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * test. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1) { j = tv_ptr->mpi_rank; - - } else { + } + else { j = 0; } do { - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2) { k = tv_ptr->mpi_rank; - - } else { + } + else { k = 0; } @@ -1163,11 +1026,11 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) l = 0; do { - if ( (tv_ptr->skips)++ < tv_ptr->max_skips ) { /* skip the test */ + if ((tv_ptr->skips)++ < tv_ptr->max_skips) { /* skip the test */ (tv_ptr->tests_skipped)++; - - } else { /* run the test */ + } + else { /* run the test */ tv_ptr->skips = 0; /* reset the skips counter */ @@ -1181,15 +1044,9 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, - H5S_SELECT_SET, - tv_ptr->start_ptr, - tv_ptr->stride_ptr, - tv_ptr->count_ptr, - tv_ptr->block_ptr); - VRFY((ret != FAIL), - "H5Sselect_hyperslab(mem_large_ds_sid) succeeded"); - + ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, H5S_SELECT_SET, tv_ptr->start_ptr, + tv_ptr->stride_ptr, tv_ptr->count_ptr, tv_ptr->block_ptr); + VRFY((ret != FAIL), "H5Sselect_hyperslab(mem_large_ds_sid) succeeded"); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -1197,57 +1054,46 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) check = H5Sselect_shape_same(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); VRFY((check == TRUE), "H5Sselect_shape_same passed"); - /* Read selection from disk */ #if CONTIG_HS_DR_PIO_TEST__D2M_S2L__DEBUG - HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", - fcnName, (int)(tv_ptr->mpi_rank), - (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), - (int)(tv_ptr->start[2]), (int)(tv_ptr->start[3]), - (int)(tv_ptr->start[4])); - HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", - fcnName, tv_ptr->mpi_rank, + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, (int)(tv_ptr->mpi_rank), + (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), (int)(tv_ptr->start[2]), + (int)(tv_ptr->start[3]), (int)(tv_ptr->start[4])); + HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", fcnName, tv_ptr->mpi_rank, H5Sget_simple_extent_ndims(tv_ptr->mem_large_ds_sid), H5Sget_simple_extent_ndims(tv_ptr->file_small_ds_sid_0)); #endif /* CONTIG_HS_DR_PIO_TEST__D2M_S2L__DEBUG */ - ret = H5Dread(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_large_ds_sid, - tv_ptr->file_small_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->large_ds_buf_1); + ret = H5Dread(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_large_ds_sid, + tv_ptr->file_small_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_1); VRFY((ret >= 0), "H5Dread() slice from small ds succeeded."); /* verify that the expected data and only the * expected data was read. */ - ptr_1 = tv_ptr->large_ds_buf_1; - expected_value = (uint32_t) - ((size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size); - start_index = (size_t)( - (i * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size * tv_ptr->edge_size) + + ptr_1 = tv_ptr->large_ds_buf_1; + expected_value = (uint32_t)((size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size); + start_index = (size_t)( + (i * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + - (k * tv_ptr->edge_size * tv_ptr->edge_size) + - (l * tv_ptr->edge_size)); + (k * tv_ptr->edge_size * tv_ptr->edge_size) + (l * tv_ptr->edge_size)); stop_index = start_index + tv_ptr->small_ds_slice_size - 1; - HDassert( start_index < stop_index ); - HDassert( stop_index <= tv_ptr->large_ds_size ); + HDassert(start_index < stop_index); + HDassert(stop_index <= tv_ptr->large_ds_size); - for ( n = 0; n < tv_ptr->large_ds_size; n++ ) { + for (n = 0; n < tv_ptr->large_ds_size; n++) { - if ( ( n >= start_index ) && ( n <= stop_index ) ) { + if ((n >= start_index) && (n <= stop_index)) { - if ( *ptr_1 != expected_value ) { + if (*ptr_1 != expected_value) { mis_match = TRUE; } expected_value++; + } + else { - } else { - - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { mis_match = TRUE; } @@ -1258,8 +1104,7 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) ptr_1++; } - VRFY((mis_match == FALSE), - "small slice read from large ds data good."); + VRFY((mis_match == FALSE), "small slice read from large ds data good."); (tv_ptr->tests_run)++; } @@ -1268,23 +1113,16 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) (tv_ptr->total_tests)++; - } while ( ( tv_ptr->large_rank > 2 ) && - ( (tv_ptr->small_rank - 1) <= 1 ) && - ( l < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 2) && ((tv_ptr->small_rank - 1) <= 1) && (l < tv_ptr->edge_size)); k++; - } while ( ( tv_ptr->large_rank > 3 ) && - ( (tv_ptr->small_rank - 1) <= 2 ) && - ( k < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 3) && ((tv_ptr->small_rank - 1) <= 2) && (k < tv_ptr->edge_size)); j++; - } while ( ( tv_ptr->large_rank > 4 ) && - ( (tv_ptr->small_rank - 1) <= 3 ) && - ( j < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 4) && ((tv_ptr->small_rank - 1) <= 3) && (j < tv_ptr->edge_size)); return; } /* contig_hs_dr_pio_test__d2m_s2l() */ - /*------------------------------------------------------------------------- * Function: contig_hs_dr_pio_test__m2d_l2s() * @@ -1312,26 +1150,25 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) #define CONTIG_HS_DR_PIO_TEST__M2D_L2S__DEBUG 0 static void -contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) +contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t *tv_ptr) { #if CONTIG_HS_DR_PIO_TEST__M2D_L2S__DEBUG const char *fcnName = "contig_hs_dr_pio_test__m2d_l2s()"; #endif /* CONTIG_HS_DR_PIO_TEST__M2D_L2S__DEBUG */ - hbool_t mis_match = FALSE; - int i, j, k, l; + hbool_t mis_match = FALSE; + int i, j, k, l; size_t n; - int mpi_rank; /* needed by the VRFY macro */ - size_t start_index; - size_t stop_index; - uint32_t expected_value; - uint32_t * ptr_1; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + int mpi_rank; /* needed by the VRFY macro */ + size_t start_index; + size_t stop_index; + uint32_t expected_value; + uint32_t *ptr_1; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; - /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that * H5Sselect_shape_same() views as being of the same shape. @@ -1343,49 +1180,40 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * the memory and file selections. */ - tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); + tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); tv_ptr->stride[0] = (hsize_t)(2 * (tv_ptr->mpi_size + 1)); - tv_ptr->count[0] = 1; - tv_ptr->block[0] = 1; + tv_ptr->count[0] = 1; + tv_ptr->block[0] = 1; - for ( i = 1; i < tv_ptr->large_rank; i++ ) { + for (i = 1; i < tv_ptr->large_rank; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); + tv_ptr->count[i] = 1; + tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } - ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_small_ds_sid_0, set) suceeded"); - ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(mem_small_ds_sid, set) suceeded"); - /* set up start, stride, count, and block -- note that we will * change start[] so as to read slices of the large cube. */ - for ( i = 0; i < PAR_SS_DR_MAX_RANK; i++ ) { + for (i = 0; i < PAR_SS_DR_MAX_RANK; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - if ( (PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1) ) { + tv_ptr->count[i] = 1; + if ((PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1)) { tv_ptr->block[i] = 1; - - } else { + } + else { tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } @@ -1394,11 +1222,8 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* zero out the in memory small ds */ HDmemset(tv_ptr->small_ds_buf_1, 0, sizeof(uint32_t) * tv_ptr->small_ds_size); - #if CONTIG_HS_DR_PIO_TEST__M2D_L2S__DEBUG - HDfprintf(stdout, - "%s writing slices from big ds to slices of small ds on disk.\n", - fcnName); + HDfprintf(stdout, "%s writing slices from big ds to slices of small ds on disk.\n", fcnName); #endif /* CONTIG_HS_DR_PIO_TEST__M2D_L2S__DEBUG */ /* in serial versions of this test, we loop through all the dimensions @@ -1410,12 +1235,11 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * over it. */ - - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0) { i = tv_ptr->mpi_rank; - - } else { + } + else { i = 0; } @@ -1426,22 +1250,22 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * test. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1) { j = tv_ptr->mpi_rank; - - } else { + } + else { j = 0; } j = 0; do { - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2) { k = tv_ptr->mpi_rank; - - } else { + } + else { k = 0; } @@ -1459,11 +1283,11 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) l = 0; do { - if ( (tv_ptr->skips)++ < tv_ptr->max_skips ) { /* skip the test */ + if ((tv_ptr->skips)++ < tv_ptr->max_skips) { /* skip the test */ (tv_ptr->tests_skipped)++; - - } else { /* run the test */ + } + else { /* run the test */ tv_ptr->skips = 0; /* reset the skips counter */ @@ -1473,12 +1297,8 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) */ /* zero out this rank's slice of the on disk small data set */ - ret = H5Dwrite(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_small_ds_sid, - tv_ptr->file_small_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->small_ds_buf_2); + ret = H5Dwrite(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_small_ds_sid, + tv_ptr->file_small_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->small_ds_buf_2); VRFY((ret >= 0), "H5Dwrite() zero slice to small ds succeeded."); /* select the portion of the in memory large cube from which we @@ -1490,15 +1310,9 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, - H5S_SELECT_SET, - tv_ptr->start_ptr, - tv_ptr->stride_ptr, - tv_ptr->count_ptr, - tv_ptr->block_ptr); - VRFY((ret >= 0), - "H5Sselect_hyperslab() mem_large_ds_sid succeeded."); - + ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, H5S_SELECT_SET, tv_ptr->start_ptr, + tv_ptr->stride_ptr, tv_ptr->count_ptr, tv_ptr->block_ptr); + VRFY((ret >= 0), "H5Sselect_hyperslab() mem_large_ds_sid succeeded."); /* verify that H5Sselect_shape_same() reports the in * memory slice through the cube selection and the @@ -1507,70 +1321,54 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) check = H5Sselect_shape_same(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); VRFY((check == TRUE), "H5Sselect_shape_same passed."); - /* write the slice from the in memory large data set to the * slice of the on disk small dataset. */ #if CONTIG_HS_DR_PIO_TEST__M2D_L2S__DEBUG - HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", - fcnName, (int)(tv_ptr->mpi_rank), - (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), - (int)(tv_ptr->start[2]), (int)(tv_ptr->start[3]), - (int)(tv_ptr->start[4])); - HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", - fcnName, tv_ptr->mpi_rank, + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, (int)(tv_ptr->mpi_rank), + (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), (int)(tv_ptr->start[2]), + (int)(tv_ptr->start[3]), (int)(tv_ptr->start[4])); + HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", fcnName, tv_ptr->mpi_rank, H5Sget_simple_extent_ndims(tv_ptr->mem_large_ds_sid), H5Sget_simple_extent_ndims(tv_ptr->file_small_ds_sid_0)); #endif /* CONTIG_HS_DR_PIO_TEST__M2D_L2S__DEBUG */ - ret = H5Dwrite(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_large_ds_sid, - tv_ptr->file_small_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->large_ds_buf_0); + ret = H5Dwrite(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_large_ds_sid, + tv_ptr->file_small_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_0); VRFY((ret >= 0), "H5Dwrite() slice to large ds succeeded."); - /* read the on disk square into memory */ - ret = H5Dread(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_small_ds_sid, - tv_ptr->file_small_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->small_ds_buf_1); + ret = H5Dread(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_small_ds_sid, + tv_ptr->file_small_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->small_ds_buf_1); VRFY((ret >= 0), "H5Dread() slice from small ds succeeded."); - /* verify that expected data is retrieved */ mis_match = FALSE; - ptr_1 = tv_ptr->small_ds_buf_1; + ptr_1 = tv_ptr->small_ds_buf_1; expected_value = (uint32_t)( - (i * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size * tv_ptr->edge_size) + + (i * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + - (k * tv_ptr->edge_size * tv_ptr->edge_size) + - (l * tv_ptr->edge_size)); + (k * tv_ptr->edge_size * tv_ptr->edge_size) + (l * tv_ptr->edge_size)); start_index = (size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size; - stop_index = start_index + tv_ptr->small_ds_slice_size - 1; + stop_index = start_index + tv_ptr->small_ds_slice_size - 1; - HDassert( start_index < stop_index ); - HDassert( stop_index <= tv_ptr->small_ds_size ); + HDassert(start_index < stop_index); + HDassert(stop_index <= tv_ptr->small_ds_size); - for ( n = 0; n < tv_ptr->small_ds_size; n++ ) { + for (n = 0; n < tv_ptr->small_ds_size; n++) { - if ( ( n >= start_index ) && ( n <= stop_index ) ) { + if ((n >= start_index) && (n <= stop_index)) { - if ( *ptr_1 != expected_value ) { + if (*ptr_1 != expected_value) { mis_match = TRUE; } expected_value++; + } + else { - } else { - - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { mis_match = TRUE; } @@ -1581,33 +1379,25 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) ptr_1++; } - VRFY((mis_match == FALSE), - "small slice write from large ds data good."); + VRFY((mis_match == FALSE), "small slice write from large ds data good."); (tv_ptr->tests_run)++; } l++; - (tv_ptr->total_tests)++; + (tv_ptr->total_tests)++; - } while ( ( tv_ptr->large_rank > 2 ) && - ( (tv_ptr->small_rank - 1) <= 1 ) && - ( l < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 2) && ((tv_ptr->small_rank - 1) <= 1) && (l < tv_ptr->edge_size)); k++; - } while ( ( tv_ptr->large_rank > 3 ) && - ( (tv_ptr->small_rank - 1) <= 2 ) && - ( k < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 3) && ((tv_ptr->small_rank - 1) <= 2) && (k < tv_ptr->edge_size)); j++; - } while ( ( tv_ptr->large_rank > 4 ) && - ( (tv_ptr->small_rank - 1) <= 3 ) && - ( j < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 4) && ((tv_ptr->small_rank - 1) <= 3) && (j < tv_ptr->edge_size)); return; } /* contig_hs_dr_pio_test__m2d_l2s() */ - /*------------------------------------------------------------------------- * Function: contig_hs_dr_pio_test__m2d_s2l() * @@ -1637,21 +1427,21 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) #define CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG 0 static void -contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) +contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t *tv_ptr) { #if CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG const char *fcnName = "contig_hs_dr_pio_test__m2d_s2l()"; #endif /* CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG */ - hbool_t mis_match = FALSE; - int i, j, k, l; + hbool_t mis_match = FALSE; + int i, j, k, l; size_t n; - int mpi_rank; /* needed by the VRFY macro */ - size_t start_index; - size_t stop_index; - uint32_t expected_value; - uint32_t * ptr_1; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + int mpi_rank; /* needed by the VRFY macro */ + size_t start_index; + size_t stop_index; + uint32_t expected_value; + uint32_t *ptr_1; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; @@ -1667,42 +1457,37 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) /* select the slice of the in memory small data set associated with * the process's mpi rank. */ - tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); + tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); tv_ptr->stride[0] = (hsize_t)(2 * (tv_ptr->mpi_size + 1)); - tv_ptr->count[0] = 1; - tv_ptr->block[0] = 1; + tv_ptr->count[0] = 1; + tv_ptr->block[0] = 1; - for ( i = 1; i < tv_ptr->large_rank; i++ ) { + for (i = 1; i < tv_ptr->large_rank; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); + tv_ptr->count[i] = 1; + tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } - ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(mem_small_ds_sid, set) suceeded"); - /* set up start, stride, count, and block -- note that we will * change start[] so as to write slices of the small data set to * slices of the large data set. */ - for ( i = 0; i < PAR_SS_DR_MAX_RANK; i++ ) { + for (i = 0; i < PAR_SS_DR_MAX_RANK; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - if ( (PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1) ) { + tv_ptr->count[i] = 1; + if ((PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1)) { tv_ptr->block[i] = 1; - - } else { + } + else { tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } @@ -1712,16 +1497,14 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) HDmemset(tv_ptr->large_ds_buf_1, 0, sizeof(uint32_t) * tv_ptr->large_ds_size); #if CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG - HDfprintf(stdout, - "%s writing process slices of small ds to slices of large ds on disk.\n", - fcnName); + HDfprintf(stdout, "%s writing process slices of small ds to slices of large ds on disk.\n", fcnName); #endif /* CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0) { i = tv_ptr->mpi_rank; - - } else { + } + else { i = 0; } @@ -1732,21 +1515,21 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * test. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1) { j = tv_ptr->mpi_rank; - - } else { + } + else { j = 0; } do { - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2) { k = tv_ptr->mpi_rank; - - } else { + } + else { k = 0; } @@ -1764,7 +1547,7 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) l = 0; do { - if ( (tv_ptr->skips)++ < tv_ptr->max_skips ) { /* skip the test */ + if ((tv_ptr->skips)++ < tv_ptr->max_skips) { /* skip the test */ (tv_ptr->tests_skipped)++; @@ -1775,18 +1558,15 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - HDfprintf(stdout, - "%s:%d: skipping test with start = %d %d %d %d %d.\n", - fcnName, (int)(tv_ptr->mpi_rank), - (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), - (int)(tv_ptr->start[2]), (int)(tv_ptr->start[3]), - (int)(tv_ptr->start[4])); - HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", - fcnName, tv_ptr->mpi_rank, + HDfprintf(stdout, "%s:%d: skipping test with start = %d %d %d %d %d.\n", fcnName, + (int)(tv_ptr->mpi_rank), (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), + (int)(tv_ptr->start[2]), (int)(tv_ptr->start[3]), (int)(tv_ptr->start[4])); + HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", fcnName, tv_ptr->mpi_rank, H5Sget_simple_extent_ndims(tv_ptr->mem_small_ds_sid), H5Sget_simple_extent_ndims(tv_ptr->file_large_ds_sid_0)); #endif /* CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG */ - } else { /* run the test */ + } + else { /* run the test */ tv_ptr->skips = 0; /* reset the skips counter */ @@ -1799,15 +1579,11 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * Note that this will leave one slice with its original data * as there is one more slice than processes. */ - ret = H5Dwrite(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->large_ds_slice_sid, - tv_ptr->file_large_ds_process_slice_sid, - tv_ptr->xfer_plist, + ret = H5Dwrite(tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->large_ds_slice_sid, + tv_ptr->file_large_ds_process_slice_sid, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_2); VRFY((ret != FAIL), "H5Dwrite() to zero large ds suceeded"); - /* select the portion of the in memory large cube to which we * are going to write data. */ @@ -1817,15 +1593,9 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, - H5S_SELECT_SET, - tv_ptr->start_ptr, - tv_ptr->stride_ptr, - tv_ptr->count_ptr, - tv_ptr->block_ptr); - VRFY((ret != FAIL), - "H5Sselect_hyperslab() target large ds slice succeeded"); - + ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, H5S_SELECT_SET, tv_ptr->start_ptr, + tv_ptr->stride_ptr, tv_ptr->count_ptr, tv_ptr->block_ptr); + VRFY((ret != FAIL), "H5Sselect_hyperslab() target large ds slice succeeded"); /* verify that H5Sselect_shape_same() reports the in * memory small data set slice selection and the @@ -1835,78 +1605,59 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) check = H5Sselect_shape_same(tv_ptr->mem_small_ds_sid, tv_ptr->file_large_ds_sid_0); VRFY((check == TRUE), "H5Sselect_shape_same passed"); - /* write the small data set slice from memory to the * target slice of the disk data set */ #if CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG - HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", - fcnName, (int)(tv_ptr->mpi_rank), - (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), - (int)(tv_ptr->start[2]), (int)(tv_ptr->start[3]), - (int)(tv_ptr->start[4])); - HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", - fcnName, tv_ptr->mpi_rank, + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, (int)(tv_ptr->mpi_rank), + (int)(tv_ptr->start[0]), (int)(tv_ptr->start[1]), (int)(tv_ptr->start[2]), + (int)(tv_ptr->start[3]), (int)(tv_ptr->start[4])); + HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", fcnName, tv_ptr->mpi_rank, H5Sget_simple_extent_ndims(tv_ptr->mem_small_ds_sid), H5Sget_simple_extent_ndims(tv_ptr->file_large_ds_sid_0)); #endif /* CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG */ - ret = H5Dwrite(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_small_ds_sid, - tv_ptr->file_large_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->small_ds_buf_0); - VRFY((ret != FAIL), - "H5Dwrite of small ds slice to large ds succeeded"); - + ret = H5Dwrite(tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_small_ds_sid, + tv_ptr->file_large_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->small_ds_buf_0); + VRFY((ret != FAIL), "H5Dwrite of small ds slice to large ds succeeded"); /* read this processes slice on the on disk large * data set into memory. */ - ret = H5Dread(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_large_ds_process_slice_sid, - tv_ptr->file_large_ds_process_slice_sid, - tv_ptr->xfer_plist, - tv_ptr->large_ds_buf_1); - VRFY((ret != FAIL), - "H5Dread() of process slice of large ds succeeded"); - + ret = H5Dread( + tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_large_ds_process_slice_sid, + tv_ptr->file_large_ds_process_slice_sid, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_1); + VRFY((ret != FAIL), "H5Dread() of process slice of large ds succeeded"); /* verify that the expected data and only the * expected data was read. */ - ptr_1 = tv_ptr->large_ds_buf_1; - expected_value = (uint32_t) - ((size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size); - - start_index = (size_t) - ((i * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size * tv_ptr->edge_size) + - (j * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size) + - (k * tv_ptr->edge_size * tv_ptr->edge_size) + - (l * tv_ptr->edge_size)); + ptr_1 = tv_ptr->large_ds_buf_1; + expected_value = (uint32_t)((size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size); + + start_index = (size_t)( + (i * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + + (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + + (k * tv_ptr->edge_size * tv_ptr->edge_size) + (l * tv_ptr->edge_size)); stop_index = start_index + tv_ptr->small_ds_slice_size - 1; - HDassert( start_index < stop_index ); - HDassert( stop_index < tv_ptr->large_ds_size ); + HDassert(start_index < stop_index); + HDassert(stop_index < tv_ptr->large_ds_size); - for ( n = 0; n < tv_ptr->large_ds_size; n++ ) { + for (n = 0; n < tv_ptr->large_ds_size; n++) { - if ( ( n >= start_index ) && ( n <= stop_index ) ) { + if ((n >= start_index) && (n <= stop_index)) { - if ( *ptr_1 != expected_value ) { + if (*ptr_1 != expected_value) { mis_match = TRUE; } expected_value++; + } + else { - } else { - - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { mis_match = TRUE; } @@ -1916,8 +1667,7 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) ptr_1++; } - VRFY((mis_match == FALSE), - "small ds slice write to large ds slice data good."); + VRFY((mis_match == FALSE), "small ds slice write to large ds slice data good."); (tv_ptr->tests_run)++; } @@ -1926,23 +1676,16 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) (tv_ptr->total_tests)++; - } while ( ( tv_ptr->large_rank > 2 ) && - ( (tv_ptr->small_rank - 1) <= 1 ) && - ( l < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 2) && ((tv_ptr->small_rank - 1) <= 1) && (l < tv_ptr->edge_size)); k++; - } while ( ( tv_ptr->large_rank > 3 ) && - ( (tv_ptr->small_rank - 1) <= 2 ) && - ( k < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 3) && ((tv_ptr->small_rank - 1) <= 2) && (k < tv_ptr->edge_size)); j++; - } while ( ( tv_ptr->large_rank > 4 ) && - ( (tv_ptr->small_rank - 1) <= 3 ) && - ( j < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 4) && ((tv_ptr->small_rank - 1) <= 3) && (j < tv_ptr->edge_size)); return; } /* contig_hs_dr_pio_test__m2d_s2l() */ - /*------------------------------------------------------------------------- * Function: contig_hs_dr_pio_test__run_test() * @@ -1959,25 +1702,15 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) #define CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG 0 static void -contig_hs_dr_pio_test__run_test(const int test_num, - const int edge_size, - const int chunk_edge_size, - const int small_rank, - const int large_rank, - const hbool_t use_collective_io, - const hid_t dset_type, - int express_test, - int * skips_ptr, - int max_skips, - int64_t * total_tests_ptr, - int64_t * tests_run_ptr, - int64_t * tests_skipped_ptr) +contig_hs_dr_pio_test__run_test(const int test_num, const int edge_size, const int chunk_edge_size, + const int small_rank, const int large_rank, const hbool_t use_collective_io, + const hid_t dset_type, int express_test, int *skips_ptr, int max_skips, + int64_t *total_tests_ptr, int64_t *tests_run_ptr, int64_t *tests_skipped_ptr) { #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG const char *fcnName = "contig_hs_dr_pio_test__run_test()"; #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ - struct hs_dr_pio_test_vars_t test_vars = - { + struct hs_dr_pio_test_vars_t test_vars = { /* int mpi_size = */ -1, /* int mpi_rank = */ -1, /* MPI_Comm mpi_comm = */ MPI_COMM_NULL, @@ -1999,7 +1732,7 @@ contig_hs_dr_pio_test__run_test(const int test_num, /* uint32_t * large_ds_slice_buf = */ NULL, /* int small_ds_offset = */ -1, /* int large_ds_offset = */ -1, - /* hid_t fid = */ -1, /* HDF5 file ID */ + /* hid_t fid = */ -1, /* HDF5 file ID */ /* hid_t xfer_plist = */ H5P_DEFAULT, /* hid_t full_mem_small_ds_sid = */ -1, /* hid_t full_file_small_ds_sid = */ -1, @@ -2015,18 +1748,18 @@ contig_hs_dr_pio_test__run_test(const int test_num, /* hid_t file_large_ds_process_slice_sid = */ -1, /* hid_t mem_large_ds_process_slice_sid = */ -1, /* hid_t large_ds_slice_sid = */ -1, - /* hid_t small_dataset = */ -1, /* Dataset ID */ - /* hid_t large_dataset = */ -1, /* Dataset ID */ + /* hid_t small_dataset = */ -1, /* Dataset ID */ + /* hid_t large_dataset = */ -1, /* Dataset ID */ /* size_t small_ds_size = */ 1, /* size_t small_ds_slice_size = */ 1, /* size_t large_ds_size = */ 1, /* size_t large_ds_slice_size = */ 1, - /* hsize_t dims[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t chunk_dims[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t start[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t stride[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t count[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t block[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, + /* hsize_t dims[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t chunk_dims[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t start[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t stride[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t count[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t block[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, /* hsize_t * start_ptr = */ NULL, /* hsize_t * stride_ptr = */ NULL, /* hsize_t * count_ptr = */ NULL, @@ -2035,22 +1768,19 @@ contig_hs_dr_pio_test__run_test(const int test_num, /* int max_skips = */ 0, /* int64_t total_tests = */ 0, /* int64_t tests_run = */ 0, - /* int64_t tests_skipped = */ 0 - }; - struct hs_dr_pio_test_vars_t * tv_ptr = &test_vars; + /* int64_t tests_skipped = */ 0}; + struct hs_dr_pio_test_vars_t *tv_ptr = &test_vars; - hs_dr_pio_test__setup(test_num, edge_size, -1, chunk_edge_size, - small_rank, large_rank, use_collective_io, + hs_dr_pio_test__setup(test_num, edge_size, -1, chunk_edge_size, small_rank, large_rank, use_collective_io, dset_type, express_test, tv_ptr); /* initialize skips & max_skips */ - tv_ptr->skips = *skips_ptr; + tv_ptr->skips = *skips_ptr; tv_ptr->max_skips = max_skips; #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { - HDfprintf(stdout, "test %d: small rank = %d, large rank = %d.\n", - test_num, small_rank, large_rank); + if (MAINPROCESS) { + HDfprintf(stdout, "test %d: small rank = %d, large rank = %d.\n", test_num, small_rank, large_rank); HDfprintf(stdout, "test %d: Initialization complete.\n", test_num); } #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ @@ -2065,26 +1795,24 @@ contig_hs_dr_pio_test__run_test(const int test_num, */ #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { + if (MAINPROCESS) { HDfprintf(stdout, "test %d: running contig_hs_dr_pio_test__d2m_l2s.\n", test_num); } #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ contig_hs_dr_pio_test__d2m_l2s(tv_ptr); - /* Second, read slices of the on disk small data set into slices * through the in memory large data set, and verify that the correct * data (and only the correct data) is read. */ #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { + if (MAINPROCESS) { HDfprintf(stdout, "test %d: running contig_hs_dr_pio_test__d2m_s2l.\n", test_num); } #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ contig_hs_dr_pio_test__d2m_s2l(tv_ptr); - /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that * H5Sselect_shape_same() views as being of the same shape. @@ -2097,13 +1825,12 @@ contig_hs_dr_pio_test__run_test(const int test_num, */ #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { + if (MAINPROCESS) { HDfprintf(stdout, "test %d: running contig_hs_dr_pio_test__m2d_l2s.\n", test_num); } #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ contig_hs_dr_pio_test__m2d_l2s(tv_ptr); - /* Now write the contents of the process's slice of the in memory * small data set to slices of the on disk large data set. After * each write, read the process's slice of the large data set back @@ -2113,25 +1840,24 @@ contig_hs_dr_pio_test__run_test(const int test_num, */ #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { + if (MAINPROCESS) { HDfprintf(stdout, "test %d: running contig_hs_dr_pio_test__m2d_s2l.\n", test_num); } #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ contig_hs_dr_pio_test__m2d_s2l(tv_ptr); #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { - HDfprintf(stdout, - "test %d: Subtests complete -- tests run/skipped/total = %lld/%lld/%lld.\n", - test_num, (long long)(tv_ptr->tests_run), (long long)(tv_ptr->tests_skipped), - (long long)(tv_ptr->total_tests)); + if (MAINPROCESS) { + HDfprintf(stdout, "test %d: Subtests complete -- tests run/skipped/total = %lld/%lld/%lld.\n", + test_num, (long long)(tv_ptr->tests_run), (long long)(tv_ptr->tests_skipped), + (long long)(tv_ptr->total_tests)); } #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ hs_dr_pio_test__takedown(tv_ptr); #if CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { + if (MAINPROCESS) { HDfprintf(stdout, "test %d: Takedown complete.\n", test_num); } #endif /* CONTIG_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ @@ -2145,7 +1871,6 @@ contig_hs_dr_pio_test__run_test(const int test_num, } /* contig_hs_dr_pio_test__run_test() */ - /*------------------------------------------------------------------------- * Function: contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) * @@ -2164,28 +1889,28 @@ contig_hs_dr_pio_test__run_test(const int test_num, static void contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) { - int express_test; - int local_express_test; - int mpi_rank = -1; - int mpi_size; - int test_num = 0; - int edge_size; - int chunk_edge_size = 0; - int small_rank; - int large_rank; - int mpi_result; - int skips = 0; - int max_skips = 0; + int express_test; + int local_express_test; + int mpi_rank = -1; + int mpi_size; + int test_num = 0; + int edge_size; + int chunk_edge_size = 0; + int small_rank; + int large_rank; + int mpi_result; + int skips = 0; + int max_skips = 0; /* The following table list the number of sub-tests skipped between * each test that is actually executed as a function of the express * test level. Note that any value in excess of 4880 will cause all * sub tests to be skipped. */ - int max_skips_tbl[4] = {0, 4, 64, 1024}; - hid_t dset_type = H5T_NATIVE_UINT; - int64_t total_tests = 0; - int64_t tests_run = 0; - int64_t tests_skipped = 0; + int max_skips_tbl[4] = {0, 4, 64, 1024}; + hid_t dset_type = H5T_NATIVE_UINT; + int64_t total_tests = 0; + int64_t tests_run = 0; + int64_t tests_skipped = 0; HDcompile_assert(sizeof(uint32_t) == sizeof(unsigned)); @@ -2196,45 +1921,33 @@ contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) local_express_test = GetTestExpress(); - mpi_result = MPI_Allreduce((void *)&local_express_test, - (void *)&express_test, - 1, - MPI_INT, - MPI_MAX, + mpi_result = MPI_Allreduce((void *)&local_express_test, (void *)&express_test, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); - VRFY((mpi_result == MPI_SUCCESS ), "MPI_Allreduce(0) succeeded"); + VRFY((mpi_result == MPI_SUCCESS), "MPI_Allreduce(0) succeeded"); - if ( local_express_test < 0 ) { + if (local_express_test < 0) { max_skips = max_skips_tbl[0]; - } else if ( local_express_test > 3 ) { + } + else if (local_express_test > 3) { max_skips = max_skips_tbl[3]; - } else { + } + else { max_skips = max_skips_tbl[local_express_test]; } - for ( large_rank = 3; large_rank <= PAR_SS_DR_MAX_RANK; large_rank++ ) { + for (large_rank = 3; large_rank <= PAR_SS_DR_MAX_RANK; large_rank++) { - for ( small_rank = 2; small_rank < large_rank; small_rank++ ) { + for (small_rank = 2; small_rank < large_rank; small_rank++) { - switch(sstest_type){ + switch (sstest_type) { case IND_CONTIG: /* contiguous data set, independent I/O */ chunk_edge_size = 0; - contig_hs_dr_pio_test__run_test(test_num, - edge_size, - chunk_edge_size, - small_rank, - large_rank, - FALSE, - dset_type, - express_test, - &skips, - max_skips, - &total_tests, - &tests_run, - &tests_skipped); + contig_hs_dr_pio_test__run_test(test_num, edge_size, chunk_edge_size, small_rank, + large_rank, FALSE, dset_type, express_test, &skips, + max_skips, &total_tests, &tests_run, &tests_skipped); test_num++; break; /* end of case IND_CONTIG */ @@ -2243,19 +1956,9 @@ contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) /* contiguous data set, collective I/O */ chunk_edge_size = 0; - contig_hs_dr_pio_test__run_test(test_num, - edge_size, - chunk_edge_size, - small_rank, - large_rank, - TRUE, - dset_type, - express_test, - &skips, - max_skips, - &total_tests, - &tests_run, - &tests_skipped); + contig_hs_dr_pio_test__run_test(test_num, edge_size, chunk_edge_size, small_rank, + large_rank, TRUE, dset_type, express_test, &skips, + max_skips, &total_tests, &tests_run, &tests_skipped); test_num++; break; /* end of case COL_CONTIG */ @@ -2264,19 +1967,9 @@ contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) /* chunked data set, independent I/O */ chunk_edge_size = 5; - contig_hs_dr_pio_test__run_test(test_num, - edge_size, - chunk_edge_size, - small_rank, - large_rank, - FALSE, - dset_type, - express_test, - &skips, - max_skips, - &total_tests, - &tests_run, - &tests_skipped); + contig_hs_dr_pio_test__run_test(test_num, edge_size, chunk_edge_size, small_rank, + large_rank, FALSE, dset_type, express_test, &skips, + max_skips, &total_tests, &tests_run, &tests_skipped); test_num++; break; /* end of case IND_CHUNKED */ @@ -2285,19 +1978,9 @@ contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) /* chunked data set, collective I/O */ chunk_edge_size = 5; - contig_hs_dr_pio_test__run_test(test_num, - edge_size, - chunk_edge_size, - small_rank, - large_rank, - TRUE, - dset_type, - express_test, - &skips, - max_skips, - &total_tests, - &tests_run, - &tests_skipped); + contig_hs_dr_pio_test__run_test(test_num, edge_size, chunk_edge_size, small_rank, + large_rank, TRUE, dset_type, express_test, &skips, + max_skips, &total_tests, &tests_run, &tests_skipped); test_num++; break; /* end of case COL_CHUNKED */ @@ -2308,24 +1991,23 @@ contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) } /* end of switch(sstest_type) */ #if CONTIG_HS_DR_PIO_TEST__DEBUG - if ( ( MAINPROCESS ) && ( tests_skipped > 0 ) ) { - HDfprintf(stdout, " run/skipped/total = %lld/%lld/%lld.\n", - tests_run, tests_skipped, total_tests); + if ((MAINPROCESS) && (tests_skipped > 0)) { + HDfprintf(stdout, " run/skipped/total = %lld/%lld/%lld.\n", tests_run, tests_skipped, + total_tests); } #endif /* CONTIG_HS_DR_PIO_TEST__DEBUG */ } } - if ( ( MAINPROCESS ) && ( tests_skipped > 0 ) ) { - HDfprintf(stdout, " %lld of %lld subtests skipped to expedite testing.\n", - tests_skipped, total_tests); + if ((MAINPROCESS) && (tests_skipped > 0)) { + HDfprintf(stdout, " %lld of %lld subtests skipped to expedite testing.\n", tests_skipped, + total_tests); } return; } /* contig_hs_dr_pio_test() */ - /**************************************************************** ** ** ckrbrd_hs_dr_pio_test__slct_ckrbrd(): @@ -2352,53 +2034,47 @@ contig_hs_dr_pio_test(ShapeSameTestMethods sstest_type) #define CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG 0 static void -ckrbrd_hs_dr_pio_test__slct_ckrbrd(const int mpi_rank, - const hid_t tgt_sid, - const int tgt_rank, - const int edge_size, - const int checker_edge_size, - const int sel_rank, +ckrbrd_hs_dr_pio_test__slct_ckrbrd(const int mpi_rank, const hid_t tgt_sid, const int tgt_rank, + const int edge_size, const int checker_edge_size, const int sel_rank, hsize_t sel_start[]) { #if CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG - const char * fcnName = "ckrbrd_hs_dr_pio_test__slct_ckrbrd():"; + const char *fcnName = "ckrbrd_hs_dr_pio_test__slct_ckrbrd():"; #endif - hbool_t first_selection = TRUE; - int i, j, k, l, m; - int n_cube_offset; - int sel_offset; - const int test_max_rank = PAR_SS_DR_MAX_RANK; /* must update code if */ - /* this changes */ - hsize_t base_count; - hsize_t offset_count; - hsize_t start[PAR_SS_DR_MAX_RANK]; - hsize_t stride[PAR_SS_DR_MAX_RANK]; - hsize_t count[PAR_SS_DR_MAX_RANK]; - hsize_t block[PAR_SS_DR_MAX_RANK]; - herr_t ret; /* Generic return value */ - - HDassert( edge_size >= 6 ); - HDassert( 0 < checker_edge_size ); - HDassert( checker_edge_size <= edge_size ); - HDassert( 0 < sel_rank ); - HDassert( sel_rank <= tgt_rank ); - HDassert( tgt_rank <= test_max_rank ); - HDassert( test_max_rank <= PAR_SS_DR_MAX_RANK ); + hbool_t first_selection = TRUE; + int i, j, k, l, m; + int n_cube_offset; + int sel_offset; + const int test_max_rank = PAR_SS_DR_MAX_RANK; /* must update code if */ + /* this changes */ + hsize_t base_count; + hsize_t offset_count; + hsize_t start[PAR_SS_DR_MAX_RANK]; + hsize_t stride[PAR_SS_DR_MAX_RANK]; + hsize_t count[PAR_SS_DR_MAX_RANK]; + hsize_t block[PAR_SS_DR_MAX_RANK]; + herr_t ret; /* Generic return value */ + + HDassert(edge_size >= 6); + HDassert(0 < checker_edge_size); + HDassert(checker_edge_size <= edge_size); + HDassert(0 < sel_rank); + HDassert(sel_rank <= tgt_rank); + HDassert(tgt_rank <= test_max_rank); + HDassert(test_max_rank <= PAR_SS_DR_MAX_RANK); sel_offset = test_max_rank - sel_rank; - HDassert( sel_offset >= 0 ); + HDassert(sel_offset >= 0); n_cube_offset = test_max_rank - tgt_rank; - HDassert( n_cube_offset >= 0 ); - HDassert( n_cube_offset <= sel_offset ); + HDassert(n_cube_offset >= 0); + HDassert(n_cube_offset <= sel_offset); #if CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG - HDfprintf(stdout, "%s:%d: edge_size/checker_edge_size = %d/%d\n", - fcnName, mpi_rank, edge_size, checker_edge_size); - HDfprintf(stdout, "%s:%d: sel_rank/sel_offset = %d/%d.\n", - fcnName, mpi_rank, sel_rank, sel_offset); - HDfprintf(stdout, "%s:%d: tgt_rank/n_cube_offset = %d/%d.\n", - fcnName, mpi_rank, tgt_rank, n_cube_offset); + HDfprintf(stdout, "%s:%d: edge_size/checker_edge_size = %d/%d\n", fcnName, mpi_rank, edge_size, + checker_edge_size); + HDfprintf(stdout, "%s:%d: sel_rank/sel_offset = %d/%d.\n", fcnName, mpi_rank, sel_rank, sel_offset); + HDfprintf(stdout, "%s:%d: tgt_rank/n_cube_offset = %d/%d.\n", fcnName, mpi_rank, tgt_rank, n_cube_offset); #endif /* CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG */ /* First, compute the base count (which assumes start == 0 @@ -2416,14 +2092,14 @@ ckrbrd_hs_dr_pio_test__slct_ckrbrd(const int mpi_rank, base_count = (hsize_t)(edge_size / (checker_edge_size * 2)); - if ( (edge_size % (checker_edge_size * 2)) > 0 ) { + if ((edge_size % (checker_edge_size * 2)) > 0) { base_count++; } offset_count = (hsize_t)((edge_size - checker_edge_size) / (checker_edge_size * 2)); - if ( ((edge_size - checker_edge_size) % (checker_edge_size * 2)) > 0 ) { + if (((edge_size - checker_edge_size) % (checker_edge_size * 2)) > 0) { offset_count++; } @@ -2433,217 +2109,187 @@ ckrbrd_hs_dr_pio_test__slct_ckrbrd(const int mpi_rank, * the checker board. */ i = 0; - while ( i < n_cube_offset ) { + while (i < n_cube_offset) { /* these values should never be used */ - start[i] = 0; + start[i] = 0; stride[i] = 0; - count[i] = 0; - block[i] = 0; + count[i] = 0; + block[i] = 0; i++; } - while ( i < sel_offset ) { + while (i < sel_offset) { - start[i] = sel_start[i]; + start[i] = sel_start[i]; stride[i] = (hsize_t)(2 * edge_size); - count[i] = 1; - block[i] = 1; + count[i] = 1; + block[i] = 1; i++; } - while ( i < test_max_rank ) { + while (i < test_max_rank) { stride[i] = (hsize_t)(2 * checker_edge_size); - block[i] = (hsize_t)checker_edge_size; + block[i] = (hsize_t)checker_edge_size; i++; } i = 0; do { - if ( 0 >= sel_offset ) { + if (0 >= sel_offset) { - if ( i == 0 ) { + if (i == 0) { start[0] = 0; count[0] = base_count; - - } else { + } + else { start[0] = (hsize_t)checker_edge_size; count[0] = offset_count; - } } j = 0; do { - if ( 1 >= sel_offset ) { + if (1 >= sel_offset) { - if ( j == 0 ) { + if (j == 0) { start[1] = 0; count[1] = base_count; - - } else { + } + else { start[1] = (hsize_t)checker_edge_size; count[1] = offset_count; - } } k = 0; do { - if ( 2 >= sel_offset ) { + if (2 >= sel_offset) { - if ( k == 0 ) { + if (k == 0) { start[2] = 0; count[2] = base_count; - - } else { + } + else { start[2] = (hsize_t)checker_edge_size; count[2] = offset_count; - } } l = 0; do { - if ( 3 >= sel_offset ) { + if (3 >= sel_offset) { - if ( l == 0 ) { + if (l == 0) { start[3] = 0; count[3] = base_count; - - } else { + } + else { start[3] = (hsize_t)checker_edge_size; count[3] = offset_count; - } } m = 0; do { - if ( 4 >= sel_offset ) { + if (4 >= sel_offset) { - if ( m == 0 ) { + if (m == 0) { start[4] = 0; count[4] = base_count; - - } else { + } + else { start[4] = (hsize_t)checker_edge_size; count[4] = offset_count; - } } - if ( ((i + j + k + l + m) % 2) == 0 ) { + if (((i + j + k + l + m) % 2) == 0) { #if CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG - HDfprintf(stdout, "%s%d: *** first_selection = %d ***\n", - fcnName, mpi_rank, (int)first_selection); - HDfprintf(stdout, "%s:%d: i/j/k/l/m = %d/%d/%d/%d/%d\n", - fcnName, mpi_rank, i, j, k, l, m); - HDfprintf(stdout, - "%s:%d: start = %d %d %d %d %d.\n", - fcnName, mpi_rank, (int)start[0], (int)start[1], - (int)start[2], (int)start[3], (int)start[4]); - HDfprintf(stdout, - "%s:%d: stride = %d %d %d %d %d.\n", - fcnName, mpi_rank, (int)stride[0], (int)stride[1], - (int)stride[2], (int)stride[3], (int)stride[4]); - HDfprintf(stdout, - "%s:%d: count = %d %d %d %d %d.\n", - fcnName, mpi_rank, (int)count[0], (int)count[1], - (int)count[2], (int)count[3], (int)count[4]); - HDfprintf(stdout, - "%s:%d: block = %d %d %d %d %d.\n", - fcnName, mpi_rank, (int)block[0], (int)block[1], - (int)block[2], (int)block[3], (int)block[4]); - HDfprintf(stdout, "%s:%d: n-cube extent dims = %d.\n", - fcnName, mpi_rank, + HDfprintf(stdout, "%s%d: *** first_selection = %d ***\n", fcnName, mpi_rank, + (int)first_selection); + HDfprintf(stdout, "%s:%d: i/j/k/l/m = %d/%d/%d/%d/%d\n", fcnName, mpi_rank, i, j, + k, l, m); + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, mpi_rank, + (int)start[0], (int)start[1], (int)start[2], (int)start[3], + (int)start[4]); + HDfprintf(stdout, "%s:%d: stride = %d %d %d %d %d.\n", fcnName, mpi_rank, + (int)stride[0], (int)stride[1], (int)stride[2], (int)stride[3], + (int)stride[4]); + HDfprintf(stdout, "%s:%d: count = %d %d %d %d %d.\n", fcnName, mpi_rank, + (int)count[0], (int)count[1], (int)count[2], (int)count[3], + (int)count[4]); + HDfprintf(stdout, "%s:%d: block = %d %d %d %d %d.\n", fcnName, mpi_rank, + (int)block[0], (int)block[1], (int)block[2], (int)block[3], + (int)block[4]); + HDfprintf(stdout, "%s:%d: n-cube extent dims = %d.\n", fcnName, mpi_rank, H5Sget_simple_extent_ndims(tgt_sid)); - HDfprintf(stdout, "%s:%d: selection rank = %d.\n", - fcnName, mpi_rank, sel_rank); + HDfprintf(stdout, "%s:%d: selection rank = %d.\n", fcnName, mpi_rank, sel_rank); #endif - if ( first_selection ) { + if (first_selection) { first_selection = FALSE; - ret = H5Sselect_hyperslab - ( - tgt_sid, - H5S_SELECT_SET, - &(start[n_cube_offset]), - &(stride[n_cube_offset]), - &(count[n_cube_offset]), - &(block[n_cube_offset]) - ); + ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_SET, &(start[n_cube_offset]), + &(stride[n_cube_offset]), &(count[n_cube_offset]), + &(block[n_cube_offset])); VRFY((ret != FAIL), "H5Sselect_hyperslab(SET) succeeded"); + } + else { - } else { - - ret = H5Sselect_hyperslab - ( - tgt_sid, - H5S_SELECT_OR, - &(start[n_cube_offset]), - &(stride[n_cube_offset]), - &(count[n_cube_offset]), - &(block[n_cube_offset]) - ); + ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_OR, &(start[n_cube_offset]), + &(stride[n_cube_offset]), &(count[n_cube_offset]), + &(block[n_cube_offset])); VRFY((ret != FAIL), "H5Sselect_hyperslab(OR) succeeded"); - } } m++; - } while ( ( m <= 1 ) && - ( 4 >= sel_offset ) ); + } while ((m <= 1) && (4 >= sel_offset)); l++; - } while ( ( l <= 1 ) && - ( 3 >= sel_offset ) ); + } while ((l <= 1) && (3 >= sel_offset)); k++; - } while ( ( k <= 1 ) && - ( 2 >= sel_offset ) ); + } while ((k <= 1) && (2 >= sel_offset)); j++; - } while ( ( j <= 1 ) && - ( 1 >= sel_offset ) ); - + } while ((j <= 1) && (1 >= sel_offset)); i++; - } while ( ( i <= 1 ) && - ( 0 >= sel_offset ) ); + } while ((i <= 1) && (0 >= sel_offset)); #if CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG - HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n", - fcnName, mpi_rank, (int)H5Sget_select_npoints(tgt_sid)); + HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n", fcnName, mpi_rank, + (int)H5Sget_select_npoints(tgt_sid)); #endif /* CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG */ /* Clip the selection back to the dataspace proper. */ - for ( i = 0; i < test_max_rank; i++ ) { + for (i = 0; i < test_max_rank; i++) { start[i] = 0; stride[i] = (hsize_t)edge_size; @@ -2651,14 +2297,13 @@ ckrbrd_hs_dr_pio_test__slct_ckrbrd(const int mpi_rank, block[i] = (hsize_t)edge_size; } - ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_AND, - start, stride, count, block); + ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_AND, start, stride, count, block); VRFY((ret != FAIL), "H5Sselect_hyperslab(AND) succeeded"); #if CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG - HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n", - fcnName, mpi_rank, (int)H5Sget_select_npoints(tgt_sid)); + HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n", fcnName, mpi_rank, + (int)H5Sget_select_npoints(tgt_sid)); HDfprintf(stdout, "%s%d: done.\n", fcnName, mpi_rank); #endif /* CKRBRD_HS_DR_PIO_TEST__SELECT_CHECKER_BOARD__DEBUG */ @@ -2666,7 +2311,6 @@ ckrbrd_hs_dr_pio_test__slct_ckrbrd(const int mpi_rank, } /* ckrbrd_hs_dr_pio_test__slct_ckrbrd() */ - /**************************************************************** ** ** ckrbrd_hs_dr_pio_test__verify_data(): @@ -2726,36 +2370,33 @@ ckrbrd_hs_dr_pio_test__slct_ckrbrd(const int mpi_rank, #define CKRBRD_HS_DR_PIO_TEST__VERIFY_DATA__DEBUG 0 static hbool_t -ckrbrd_hs_dr_pio_test__verify_data(uint32_t * buf_ptr, - const int rank, - const int edge_size, - const int checker_edge_size, - uint32_t first_expected_val, +ckrbrd_hs_dr_pio_test__verify_data(uint32_t *buf_ptr, const int rank, const int edge_size, + const int checker_edge_size, uint32_t first_expected_val, hbool_t buf_starts_in_checker) { #if CKRBRD_HS_DR_PIO_TEST__VERIFY_DATA__DEBUG - const char * fcnName = "ckrbrd_hs_dr_pio_test__verify_data():"; + const char *fcnName = "ckrbrd_hs_dr_pio_test__verify_data():"; #endif - hbool_t good_data = TRUE; - hbool_t in_checker; - hbool_t start_in_checker[5]; - uint32_t expected_value; - uint32_t * val_ptr; - int i, j, k, l, m; /* to track position in n-cube */ - int v, w, x, y, z; /* to track position in checker */ + hbool_t good_data = TRUE; + hbool_t in_checker; + hbool_t start_in_checker[5]; + uint32_t expected_value; + uint32_t *val_ptr; + int i, j, k, l, m; /* to track position in n-cube */ + int v, w, x, y, z; /* to track position in checker */ const int test_max_rank = 5; /* code changes needed if this is increased */ - HDassert( buf_ptr != NULL ); - HDassert( 0 < rank ); - HDassert( rank <= test_max_rank ); - HDassert( edge_size >= 6 ); - HDassert( 0 < checker_edge_size ); - HDassert( checker_edge_size <= edge_size ); - HDassert( test_max_rank <= PAR_SS_DR_MAX_RANK ); + HDassert(buf_ptr != NULL); + HDassert(0 < rank); + HDassert(rank <= test_max_rank); + HDassert(edge_size >= 6); + HDassert(0 < checker_edge_size); + HDassert(checker_edge_size <= edge_size); + HDassert(test_max_rank <= PAR_SS_DR_MAX_RANK); #if CKRBRD_HS_DR_PIO_TEST__VERIFY_DATA__DEBUG - int mpi_rank; + int mpi_rank; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); HDfprintf(stdout, "%s mpi_rank = %d.\n", fcnName, mpi_rank); @@ -2767,121 +2408,109 @@ ckrbrd_hs_dr_pio_test__verify_data(uint32_t * buf_ptr, } #endif - val_ptr = buf_ptr; - expected_value = first_expected_val; +val_ptr = buf_ptr; +expected_value = first_expected_val; - i = 0; - v = 0; - start_in_checker[0] = buf_starts_in_checker; - do - { - if ( v >= checker_edge_size ) { +i = 0; +v = 0; +start_in_checker[0] = buf_starts_in_checker; +do { + if (v >= checker_edge_size) { + + start_in_checker[0] = !start_in_checker[0]; + v = 0; + } - start_in_checker[0] = ! start_in_checker[0]; - v = 0; + j = 0; + w = 0; + start_in_checker[1] = start_in_checker[0]; + do { + if (w >= checker_edge_size) { + + start_in_checker[1] = !start_in_checker[1]; + w = 0; } - j = 0; - w = 0; - start_in_checker[1] = start_in_checker[0]; - do - { - if ( w >= checker_edge_size ) { - - start_in_checker[1] = ! start_in_checker[1]; - w = 0; + k = 0; + x = 0; + start_in_checker[2] = start_in_checker[1]; + do { + if (x >= checker_edge_size) { + + start_in_checker[2] = !start_in_checker[2]; + x = 0; } - k = 0; - x = 0; - start_in_checker[2] = start_in_checker[1]; - do - { - if ( x >= checker_edge_size ) { - - start_in_checker[2] = ! start_in_checker[2]; - x = 0; - } + l = 0; + y = 0; + start_in_checker[3] = start_in_checker[2]; + do { + if (y >= checker_edge_size) { - l = 0; - y = 0; - start_in_checker[3] = start_in_checker[2]; - do - { - if ( y >= checker_edge_size ) { - - start_in_checker[3] = ! start_in_checker[3]; - y = 0; - } + start_in_checker[3] = !start_in_checker[3]; + y = 0; + } - m = 0; - z = 0; + m = 0; + z = 0; #if CKRBRD_HS_DR_PIO_TEST__VERIFY_DATA__DEBUG - HDfprintf(stdout, "%d, %d, %d, %d, %d:", i, j, k, l, m); + HDfprintf(stdout, "%d, %d, %d, %d, %d:", i, j, k, l, m); #endif - in_checker = start_in_checker[3]; - do - { + in_checker = start_in_checker[3]; + do { #if CKRBRD_HS_DR_PIO_TEST__VERIFY_DATA__DEBUG - HDfprintf(stdout, " %d", (int)(*val_ptr)); + HDfprintf(stdout, " %d", (int)(*val_ptr)); #endif - if ( z >= checker_edge_size ) { - - in_checker = ! in_checker; - z = 0; - } - - if ( in_checker ) { + if (z >= checker_edge_size) { - if ( *val_ptr != expected_value ) { - - good_data = FALSE; - } + in_checker = !in_checker; + z = 0; + } - /* zero out buffer for re-use */ - *val_ptr = 0; + if (in_checker) { - } else if ( *val_ptr != 0 ) { + if (*val_ptr != expected_value) { good_data = FALSE; + } - /* zero out buffer for re-use */ - *val_ptr = 0; + /* zero out buffer for re-use */ + *val_ptr = 0; + } + else if (*val_ptr != 0) { - } + good_data = FALSE; - val_ptr++; - expected_value++; - m++; - z++; + /* zero out buffer for re-use */ + *val_ptr = 0; + } - } while ( ( rank >= (test_max_rank - 4) ) && - ( m < edge_size ) ); + val_ptr++; + expected_value++; + m++; + z++; + + } while ((rank >= (test_max_rank - 4)) && (m < edge_size)); #if CKRBRD_HS_DR_PIO_TEST__VERIFY_DATA__DEBUG - HDfprintf(stdout, "\n"); + HDfprintf(stdout, "\n"); #endif - l++; - y++; - } while ( ( rank >= (test_max_rank - 3) ) && - ( l < edge_size ) ); - k++; - x++; - } while ( ( rank >= (test_max_rank - 2) ) && - ( k < edge_size ) ); - j++; - w++; - } while ( ( rank >= (test_max_rank - 1) ) && - ( j < edge_size ) ); - i++; - v++; - } while ( ( rank >= test_max_rank ) && - ( i < edge_size ) ); + l++; + y++; + } while ((rank >= (test_max_rank - 3)) && (l < edge_size)); + k++; + x++; + } while ((rank >= (test_max_rank - 2)) && (k < edge_size)); + j++; + w++; + } while ((rank >= (test_max_rank - 1)) && (j < edge_size)); + i++; + v++; +} while ((rank >= test_max_rank) && (i < edge_size)); - return(good_data); +return (good_data); } /* ckrbrd_hs_dr_pio_test__verify_data() */ - /*------------------------------------------------------------------------- * Function: ckrbrd_hs_dr_pio_test__d2m_l2s() * @@ -2908,24 +2537,23 @@ ckrbrd_hs_dr_pio_test__verify_data(uint32_t * buf_ptr, #define CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG 0 static void -ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) +ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t *tv_ptr) { #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG const char *fcnName = "ckrbrd_hs_dr_pio_test__d2m_l2s()"; - uint32_t * ptr_0; + uint32_t * ptr_0; #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG */ - hbool_t data_ok = FALSE; - int i, j, k, l; - uint32_t expected_value; - int mpi_rank; /* needed by VRFY */ - hsize_t sel_start[PAR_SS_DR_MAX_RANK]; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hbool_t data_ok = FALSE; + int i, j, k, l; + uint32_t expected_value; + int mpi_rank; /* needed by VRFY */ + hsize_t sel_start[PAR_SS_DR_MAX_RANK]; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; - /* first, verify that we can read from disk correctly using selections * of different rank that H5Sselect_shape_same() views as being of the * same shape. @@ -2940,24 +2568,19 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) */ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0; - sel_start[tv_ptr->small_ds_offset] = (hsize_t)(tv_ptr->mpi_rank); - - ckrbrd_hs_dr_pio_test__slct_ckrbrd(tv_ptr->mpi_rank, - tv_ptr->small_ds_slice_sid, - tv_ptr->small_rank - 1, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - tv_ptr->small_rank - 1, + sel_start[tv_ptr->small_ds_offset] = (hsize_t)(tv_ptr->mpi_rank); + + ckrbrd_hs_dr_pio_test__slct_ckrbrd(tv_ptr->mpi_rank, tv_ptr->small_ds_slice_sid, tv_ptr->small_rank - 1, + tv_ptr->edge_size, tv_ptr->checker_edge_size, tv_ptr->small_rank - 1, sel_start); /* zero out the buffer we will be reading into */ HDmemset(tv_ptr->small_ds_slice_buf, 0, sizeof(uint32_t) * tv_ptr->small_ds_slice_size); #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG - HDfprintf(stdout, "%s:%d: initial small_ds_slice_buf = ", - fcnName, tv_ptr->mpi_rank); + HDfprintf(stdout, "%s:%d: initial small_ds_slice_buf = ", fcnName, tv_ptr->mpi_rank); ptr_0 = tv_ptr->small_ds_slice_buf; - for ( i = 0; i < (int)(tv_ptr->small_ds_slice_size); i++ ) { + for (i = 0; i < (int)(tv_ptr->small_ds_slice_size); i++) { HDfprintf(stdout, "%d ", (int)(*ptr_0)); ptr_0++; } @@ -2967,25 +2590,24 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* set up start, stride, count, and block -- note that we will * change start[] so as to read slices of the large cube. */ - for ( i = 0; i < PAR_SS_DR_MAX_RANK; i++ ) { + for (i = 0; i < PAR_SS_DR_MAX_RANK; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - if ( (PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1) ) { + tv_ptr->count[i] = 1; + if ((PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1)) { tv_ptr->block[i] = 1; - - } else { + } + else { tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } } #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG - HDfprintf(stdout, - "%s:%d: reading slice from big ds on disk into small ds slice.\n", - fcnName, tv_ptr->mpi_rank); + HDfprintf(stdout, "%s:%d: reading slice from big ds on disk into small ds slice.\n", fcnName, + tv_ptr->mpi_rank); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG */ /* in serial versions of this test, we loop through all the dimensions * of the large data set. However, in the parallel version, each @@ -2994,11 +2616,11 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * mpi_rank, and don't itterate over it. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0) { i = tv_ptr->mpi_rank; - - } else { + } + else { i = 0; } @@ -3009,21 +2631,21 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * test. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1) { j = tv_ptr->mpi_rank; - - } else { + } + else { j = 0; } do { - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2) { k = tv_ptr->mpi_rank; - - } else { + } + else { k = 0; } @@ -3041,11 +2663,11 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) l = 0; do { - if ( (tv_ptr->skips)++ < tv_ptr->max_skips ) { /* skip the test */ + if ((tv_ptr->skips)++ < tv_ptr->max_skips) { /* skip the test */ (tv_ptr->tests_skipped)++; - - } else { /* run the test */ + } + else { /* run the test */ tv_ptr->skips = 0; /* reset the skips counter */ @@ -3059,22 +2681,15 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - HDassert((tv_ptr->start[0] == 0)||(0 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[1] == 0)||(1 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[2] == 0)||(2 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[3] == 0)||(3 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[4] == 0)||(4 < tv_ptr->small_ds_offset + 1)); - - ckrbrd_hs_dr_pio_test__slct_ckrbrd - ( - tv_ptr->mpi_rank, - tv_ptr->file_large_ds_sid_0, - tv_ptr->large_rank, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - tv_ptr->small_rank - 1, - tv_ptr->start - ); + HDassert((tv_ptr->start[0] == 0) || (0 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[1] == 0) || (1 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[2] == 0) || (2 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[3] == 0) || (3 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[4] == 0) || (4 < tv_ptr->small_ds_offset + 1)); + + ckrbrd_hs_dr_pio_test__slct_ckrbrd( + tv_ptr->mpi_rank, tv_ptr->file_large_ds_sid_0, tv_ptr->large_rank, tv_ptr->edge_size, + tv_ptr->checker_edge_size, tv_ptr->small_rank - 1, tv_ptr->start); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -3082,52 +2697,37 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) check = H5Sselect_shape_same(tv_ptr->small_ds_slice_sid, tv_ptr->file_large_ds_sid_0); VRFY((check == TRUE), "H5Sselect_shape_same passed"); - /* Read selection from disk */ #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG - HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, - tv_ptr->mpi_rank, tv_ptr->start[0], tv_ptr->start[1], - tv_ptr->start[2], tv_ptr->start[3], tv_ptr->start[4]); - HDfprintf(stdout, "%s slice/file extent dims = %d/%d.\n", - fcnName, + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, tv_ptr->mpi_rank, + tv_ptr->start[0], tv_ptr->start[1], tv_ptr->start[2], tv_ptr->start[3], + tv_ptr->start[4]); + HDfprintf(stdout, "%s slice/file extent dims = %d/%d.\n", fcnName, H5Sget_simple_extent_ndims(tv_ptr->small_ds_slice_sid), H5Sget_simple_extent_ndims(tv_ptr->file_large_ds_sid_0)); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG */ - ret = H5Dread(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->small_ds_slice_sid, - tv_ptr->file_large_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->small_ds_slice_buf); + ret = + H5Dread(tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->small_ds_slice_sid, + tv_ptr->file_large_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->small_ds_slice_buf); VRFY((ret >= 0), "H5Dread() slice from large ds succeeded."); #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG - HDfprintf(stdout, "%s:%d: H5Dread() returns.\n", - fcnName, tv_ptr->mpi_rank); + HDfprintf(stdout, "%s:%d: H5Dread() returns.\n", fcnName, tv_ptr->mpi_rank); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__D2M_L2S__DEBUG */ /* verify that expected data is retrieved */ - expected_value = (uint32_t) - ((i * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size * tv_ptr->edge_size) + - (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + - (k * tv_ptr->edge_size * tv_ptr->edge_size) + - (l * tv_ptr->edge_size)); - - data_ok = ckrbrd_hs_dr_pio_test__verify_data - ( - tv_ptr->small_ds_slice_buf, - tv_ptr->small_rank - 1, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - expected_value, - (hbool_t)TRUE - ); - - VRFY((data_ok == TRUE), - "small slice read from large ds data good."); + expected_value = (uint32_t)( + (i * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + + (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + + (k * tv_ptr->edge_size * tv_ptr->edge_size) + (l * tv_ptr->edge_size)); + + data_ok = ckrbrd_hs_dr_pio_test__verify_data( + tv_ptr->small_ds_slice_buf, tv_ptr->small_rank - 1, tv_ptr->edge_size, + tv_ptr->checker_edge_size, expected_value, (hbool_t)TRUE); + + VRFY((data_ok == TRUE), "small slice read from large ds data good."); (tv_ptr->tests_run)++; } @@ -3136,23 +2736,16 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) (tv_ptr->total_tests)++; - } while ( ( tv_ptr->large_rank > 2 ) && - ( (tv_ptr->small_rank - 1) <= 1 ) && - ( l < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 2) && ((tv_ptr->small_rank - 1) <= 1) && (l < tv_ptr->edge_size)); k++; - } while ( ( tv_ptr->large_rank > 3 ) && - ( (tv_ptr->small_rank - 1) <= 2 ) && - ( k < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 3) && ((tv_ptr->small_rank - 1) <= 2) && (k < tv_ptr->edge_size)); j++; - } while ( ( tv_ptr->large_rank > 4 ) && - ( (tv_ptr->small_rank - 1) <= 3 ) && - ( j < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 4) && ((tv_ptr->small_rank - 1) <= 3) && (j < tv_ptr->edge_size)); return; } /* ckrbrd_hs_dr_pio_test__d2m_l2s() */ - /*------------------------------------------------------------------------- * Function: ckrbrd_hs_dr_pio_test__d2m_s2l() * @@ -3178,47 +2771,40 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) #define CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG 0 static void -ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) +ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t *tv_ptr) { #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG const char *fcnName = "ckrbrd_hs_dr_pio_test__d2m_s2l()"; #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG */ - hbool_t data_ok = FALSE; - int i, j, k, l; - size_t u; - size_t start_index; - size_t stop_index; - uint32_t expected_value; - uint32_t * ptr_1; - int mpi_rank; /* needed by VRFY */ - hsize_t sel_start[PAR_SS_DR_MAX_RANK]; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hbool_t data_ok = FALSE; + int i, j, k, l; + size_t u; + size_t start_index; + size_t stop_index; + uint32_t expected_value; + uint32_t *ptr_1; + int mpi_rank; /* needed by VRFY */ + hsize_t sel_start[PAR_SS_DR_MAX_RANK]; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; - /* similarly, read slices of the on disk small data set into slices * through the in memory large data set, and verify that the correct * data (and only the correct data) is read. */ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0; - sel_start[tv_ptr->small_ds_offset] = (hsize_t)(tv_ptr->mpi_rank); - - ckrbrd_hs_dr_pio_test__slct_ckrbrd(tv_ptr->mpi_rank, - tv_ptr->file_small_ds_sid_0, - tv_ptr->small_rank, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - tv_ptr->small_rank - 1, + sel_start[tv_ptr->small_ds_offset] = (hsize_t)(tv_ptr->mpi_rank); + + ckrbrd_hs_dr_pio_test__slct_ckrbrd(tv_ptr->mpi_rank, tv_ptr->file_small_ds_sid_0, tv_ptr->small_rank, + tv_ptr->edge_size, tv_ptr->checker_edge_size, tv_ptr->small_rank - 1, sel_start); #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG - HDfprintf(stdout, - "%s reading slices of on disk small data set into slices of big data set.\n", - fcnName); + HDfprintf(stdout, "%s reading slices of on disk small data set into slices of big data set.\n", fcnName); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG */ /* zero out the buffer we will be reading into */ @@ -3229,16 +2815,16 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * into different slices of the process slice of the large data * set. */ - for ( i = 0; i < PAR_SS_DR_MAX_RANK; i++ ) { + for (i = 0; i < PAR_SS_DR_MAX_RANK; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - if ( (PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1) ) { + tv_ptr->count[i] = 1; + if ((PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1)) { tv_ptr->block[i] = 1; - - } else { + } + else { tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } @@ -3253,12 +2839,11 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * over it. */ - - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0) { i = tv_ptr->mpi_rank; - - } else { + } + else { i = 0; } @@ -3269,21 +2854,21 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * test. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1) { j = tv_ptr->mpi_rank; - - } else { + } + else { j = 0; } do { - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2) { k = tv_ptr->mpi_rank; - - } else { + } + else { k = 0; } @@ -3301,11 +2886,11 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) l = 0; do { - if ( (tv_ptr->skips)++ < tv_ptr->max_skips ) { /* skip the test */ + if ((tv_ptr->skips)++ < tv_ptr->max_skips) { /* skip the test */ (tv_ptr->tests_skipped)++; - - } else { /* run the test */ + } + else { /* run the test */ tv_ptr->skips = 0; /* reset the skips counter */ @@ -3319,23 +2904,15 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - HDassert((tv_ptr->start[0] == 0)||(0 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[1] == 0)||(1 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[2] == 0)||(2 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[3] == 0)||(3 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[4] == 0)||(4 < tv_ptr->small_ds_offset + 1)); - - ckrbrd_hs_dr_pio_test__slct_ckrbrd - ( - tv_ptr->mpi_rank, - tv_ptr->mem_large_ds_sid, - tv_ptr->large_rank, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - tv_ptr->small_rank - 1, - tv_ptr->start - ); + HDassert((tv_ptr->start[0] == 0) || (0 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[1] == 0) || (1 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[2] == 0) || (2 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[3] == 0) || (3 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[4] == 0) || (4 < tv_ptr->small_ds_offset + 1)); + ckrbrd_hs_dr_pio_test__slct_ckrbrd( + tv_ptr->mpi_rank, tv_ptr->mem_large_ds_sid, tv_ptr->large_rank, tv_ptr->edge_size, + tv_ptr->checker_edge_size, tv_ptr->small_rank - 1, tv_ptr->start); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -3343,55 +2920,45 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) check = H5Sselect_shape_same(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); VRFY((check == TRUE), "H5Sselect_shape_same passed"); - /* Read selection from disk */ #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG - HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", - fcnName, tv_ptr->mpi_rank, - tv_ptr->start[0], tv_ptr->start[1], tv_ptr->start[2], - tv_ptr->start[3], tv_ptr->start[4]); - HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", - fcnName, tv_ptr->mpi_rank, + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, tv_ptr->mpi_rank, + tv_ptr->start[0], tv_ptr->start[1], tv_ptr->start[2], tv_ptr->start[3], + tv_ptr->start[4]); + HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", fcnName, tv_ptr->mpi_rank, H5Sget_simple_extent_ndims(tv_ptr->large_ds_slice_sid), H5Sget_simple_extent_ndims(tv_ptr->file_small_ds_sid_0)); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG */ - ret = H5Dread(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_large_ds_sid, - tv_ptr->file_small_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->large_ds_buf_1); + ret = H5Dread(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_large_ds_sid, + tv_ptr->file_small_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_1); VRFY((ret >= 0), "H5Dread() slice from small ds succeeded."); /* verify that the expected data and only the * expected data was read. */ - data_ok = TRUE; - ptr_1 = tv_ptr->large_ds_buf_1; - expected_value = - (uint32_t)((size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size); - start_index = (size_t)( - (i * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size * tv_ptr->edge_size) + + data_ok = TRUE; + ptr_1 = tv_ptr->large_ds_buf_1; + expected_value = (uint32_t)((size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size); + start_index = (size_t)( + (i * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + - (k * tv_ptr->edge_size * tv_ptr->edge_size) + - (l * tv_ptr->edge_size)); + (k * tv_ptr->edge_size * tv_ptr->edge_size) + (l * tv_ptr->edge_size)); stop_index = start_index + tv_ptr->small_ds_slice_size - 1; #if CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG { int m, n; - HDfprintf(stdout, "%s:%d: expected_value = %d.\n", - fcnName, tv_ptr->mpi_rank, expected_value); - HDfprintf(stdout, "%s:%d: start/stop index = %d/%d.\n", - fcnName, tv_ptr->mpi_rank, start_index, stop_index); + HDfprintf(stdout, "%s:%d: expected_value = %d.\n", fcnName, tv_ptr->mpi_rank, + expected_value); + HDfprintf(stdout, "%s:%d: start/stop index = %d/%d.\n", fcnName, tv_ptr->mpi_rank, + start_index, stop_index); n = 0; - for ( m = 0; (unsigned)m < tv_ptr->large_ds_size; m ++ ) { + for (m = 0; (unsigned)m < tv_ptr->large_ds_size; m++) { HDfprintf(stdout, "%d ", (int)(*ptr_1)); ptr_1++; n++; - if ( n >= tv_ptr->edge_size ) { + if (n >= tv_ptr->edge_size) { HDfprintf(stdout, "\n"); n = 0; } @@ -3401,12 +2968,12 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) } #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__D2M_S2L__DEBUG */ - HDassert( start_index < stop_index ); - HDassert( stop_index <= tv_ptr->large_ds_size ); + HDassert(start_index < stop_index); + HDassert(stop_index <= tv_ptr->large_ds_size); - for ( u = 0; u < start_index; u++ ) { + for (u = 0; u < start_index; u++) { - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { data_ok = FALSE; } @@ -3417,28 +2984,19 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) ptr_1++; } - VRFY((data_ok == TRUE), - "slice read from small to large ds data good(1)."); + VRFY((data_ok == TRUE), "slice read from small to large ds data good(1)."); - data_ok = ckrbrd_hs_dr_pio_test__verify_data - ( - ptr_1, - tv_ptr->small_rank - 1, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - expected_value, - (hbool_t)TRUE - ); - - VRFY((data_ok == TRUE), - "slice read from small to large ds data good(2)."); + data_ok = ckrbrd_hs_dr_pio_test__verify_data(ptr_1, tv_ptr->small_rank - 1, + tv_ptr->edge_size, tv_ptr->checker_edge_size, + expected_value, (hbool_t)TRUE); + VRFY((data_ok == TRUE), "slice read from small to large ds data good(2)."); ptr_1 = tv_ptr->large_ds_buf_1 + stop_index + 1; - for ( u = stop_index + 1; u < tv_ptr->large_ds_size; u++ ) { + for (u = stop_index + 1; u < tv_ptr->large_ds_size; u++) { - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { data_ok = FALSE; } @@ -3449,8 +3007,7 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) ptr_1++; } - VRFY((data_ok == TRUE), - "slice read from small to large ds data good(3)."); + VRFY((data_ok == TRUE), "slice read from small to large ds data good(3)."); (tv_ptr->tests_run)++; } @@ -3459,23 +3016,16 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) (tv_ptr->total_tests)++; - } while ( ( tv_ptr->large_rank > 2 ) && - ( (tv_ptr->small_rank - 1) <= 1 ) && - ( l < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 2) && ((tv_ptr->small_rank - 1) <= 1) && (l < tv_ptr->edge_size)); k++; - } while ( ( tv_ptr->large_rank > 3 ) && - ( (tv_ptr->small_rank - 1) <= 2 ) && - ( k < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 3) && ((tv_ptr->small_rank - 1) <= 2) && (k < tv_ptr->edge_size)); j++; - } while ( ( tv_ptr->large_rank > 4 ) && - ( (tv_ptr->small_rank - 1) <= 3 ) && - ( j < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 4) && ((tv_ptr->small_rank - 1) <= 3) && (j < tv_ptr->edge_size)); return; } /* ckrbrd_hs_dr_pio_test__d2m_s2l() */ - /*------------------------------------------------------------------------- * Function: ckrbrd_hs_dr_pio_test__m2d_l2s() * @@ -3505,27 +3055,26 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) #define CHECKER_BOARD_HS_DR_PIO_TEST__M2D_L2S__DEBUG 0 static void -ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) +ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t *tv_ptr) { #if CHECKER_BOARD_HS_DR_PIO_TEST__M2D_L2S__DEBUG const char *fcnName = "ckrbrd_hs_dr_pio_test__m2d_l2s()"; #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__M2D_L2S__DEBUG */ - hbool_t data_ok = FALSE; - int i, j, k, l; - size_t u; - size_t start_index; - size_t stop_index; - uint32_t expected_value; - uint32_t * ptr_1; - int mpi_rank; /* needed by VRFY */ - hsize_t sel_start[PAR_SS_DR_MAX_RANK]; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hbool_t data_ok = FALSE; + int i, j, k, l; + size_t u; + size_t start_index; + size_t stop_index; + uint32_t expected_value; + uint32_t *ptr_1; + int mpi_rank; /* needed by VRFY */ + hsize_t sel_start[PAR_SS_DR_MAX_RANK]; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; - /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that * H5Sselect_shape_same() views as being of the same shape. @@ -3537,61 +3086,47 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * the memory and file selections. */ - tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); + tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); tv_ptr->stride[0] = (hsize_t)(2 * (tv_ptr->mpi_size + 1)); - tv_ptr->count[0] = 1; - tv_ptr->block[0] = 1; + tv_ptr->count[0] = 1; + tv_ptr->block[0] = 1; - for ( i = 1; i < tv_ptr->large_rank; i++ ) { + for (i = 1; i < tv_ptr->large_rank; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); + tv_ptr->count[i] = 1; + tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } - ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->file_small_ds_sid_0, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_small_ds_sid_0, set) suceeded"); - ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->mem_small_ds_sid, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(mem_small_ds_sid, set) suceeded"); - sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0; - sel_start[tv_ptr->small_ds_offset] = (hsize_t)(tv_ptr->mpi_rank); - - ckrbrd_hs_dr_pio_test__slct_ckrbrd(tv_ptr->mpi_rank, - tv_ptr->file_small_ds_sid_1, - tv_ptr->small_rank, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - tv_ptr->small_rank - 1, - sel_start); + sel_start[tv_ptr->small_ds_offset] = (hsize_t)(tv_ptr->mpi_rank); + ckrbrd_hs_dr_pio_test__slct_ckrbrd(tv_ptr->mpi_rank, tv_ptr->file_small_ds_sid_1, tv_ptr->small_rank, + tv_ptr->edge_size, tv_ptr->checker_edge_size, tv_ptr->small_rank - 1, + sel_start); /* set up start, stride, count, and block -- note that we will * change start[] so as to read slices of the large cube. */ - for ( i = 0; i < PAR_SS_DR_MAX_RANK; i++ ) { + for (i = 0; i < PAR_SS_DR_MAX_RANK; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - if ( (PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1) ) { + tv_ptr->count[i] = 1; + if ((PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1)) { tv_ptr->block[i] = 1; - - } else { + } + else { tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } @@ -3600,11 +3135,10 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* zero out the in memory small ds */ HDmemset(tv_ptr->small_ds_buf_1, 0, sizeof(uint32_t) * tv_ptr->small_ds_size); - #if CHECKER_BOARD_HS_DR_PIO_TEST__M2D_L2S__DEBUG HDfprintf(stdout, - "%s writing checker boards selections of slices from big ds to slices of small ds on disk.\n", - fcnName); + "%s writing checker boards selections of slices from big ds to slices of small ds on disk.\n", + fcnName); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__M2D_L2S__DEBUG */ /* in serial versions of this test, we loop through all the dimensions @@ -3616,12 +3150,11 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * over it. */ - - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0) { i = tv_ptr->mpi_rank; - - } else { + } + else { i = 0; } @@ -3632,22 +3165,22 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * test. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1) { j = tv_ptr->mpi_rank; - - } else { + } + else { j = 0; } j = 0; do { - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2) { k = tv_ptr->mpi_rank; - - } else { + } + else { k = 0; } @@ -3665,11 +3198,11 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) l = 0; do { - if ( (tv_ptr->skips)++ < tv_ptr->max_skips ) { /* skip the test */ + if ((tv_ptr->skips)++ < tv_ptr->max_skips) { /* skip the test */ (tv_ptr->tests_skipped)++; - - } else { /* run the test */ + } + else { /* run the test */ tv_ptr->skips = 0; /* reset the skips counter */ @@ -3679,12 +3212,8 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) */ /* zero out this rank's slice of the on disk small data set */ - ret = H5Dwrite(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_small_ds_sid, - tv_ptr->file_small_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->small_ds_buf_2); + ret = H5Dwrite(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_small_ds_sid, + tv_ptr->file_small_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->small_ds_buf_2); VRFY((ret >= 0), "H5Dwrite() zero slice to small ds succeeded."); /* select the portion of the in memory large cube from which we @@ -3696,23 +3225,15 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - HDassert((tv_ptr->start[0] == 0)||(0 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[1] == 0)||(1 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[2] == 0)||(2 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[3] == 0)||(3 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[4] == 0)||(4 < tv_ptr->small_ds_offset + 1)); - - ckrbrd_hs_dr_pio_test__slct_ckrbrd - ( - tv_ptr->mpi_rank, - tv_ptr->mem_large_ds_sid, - tv_ptr->large_rank, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - tv_ptr->small_rank - 1, - tv_ptr->start - ); + HDassert((tv_ptr->start[0] == 0) || (0 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[1] == 0) || (1 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[2] == 0) || (2 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[3] == 0) || (3 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[4] == 0) || (4 < tv_ptr->small_ds_offset + 1)); + ckrbrd_hs_dr_pio_test__slct_ckrbrd( + tv_ptr->mpi_rank, tv_ptr->mem_large_ds_sid, tv_ptr->large_rank, tv_ptr->edge_size, + tv_ptr->checker_edge_size, tv_ptr->small_rank - 1, tv_ptr->start); /* verify that H5Sselect_shape_same() reports the in * memory checkerboard selection of the slice through the @@ -3722,90 +3243,67 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) check = H5Sselect_shape_same(tv_ptr->file_small_ds_sid_1, tv_ptr->mem_large_ds_sid); VRFY((check == TRUE), "H5Sselect_shape_same passed."); - /* write the checker board selection of the slice from the in * memory large data set to the slice of the on disk small * dataset. */ #if CHECKER_BOARD_HS_DR_PIO_TEST__M2D_L2S__DEBUG - HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", - fcnName, tv_ptr->mpi_rank, - tv_ptr->start[0], tv_ptr->start[1], tv_ptr->start[2], - tv_ptr->start[3], tv_ptr->start[4]); - HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", - fcnName, tv_ptr->mpi_rank, + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, tv_ptr->mpi_rank, + tv_ptr->start[0], tv_ptr->start[1], tv_ptr->start[2], tv_ptr->start[3], + tv_ptr->start[4]); + HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", fcnName, tv_ptr->mpi_rank, H5Sget_simple_extent_ndims(tv_ptr->mem_large_ds_sid), H5Sget_simple_extent_ndims(tv_ptr->file_small_ds_sid_1)); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__M2D_L2S__DEBUG */ - ret = H5Dwrite(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_large_ds_sid, - tv_ptr->file_small_ds_sid_1, - tv_ptr->xfer_plist, - tv_ptr->large_ds_buf_0); + ret = H5Dwrite(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_large_ds_sid, + tv_ptr->file_small_ds_sid_1, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_0); VRFY((ret >= 0), "H5Dwrite() slice to large ds succeeded."); - /* read the on disk process slice of the small dataset into memory */ - ret = H5Dread(tv_ptr->small_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_small_ds_sid, - tv_ptr->file_small_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->small_ds_buf_1); + ret = H5Dread(tv_ptr->small_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_small_ds_sid, + tv_ptr->file_small_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->small_ds_buf_1); VRFY((ret >= 0), "H5Dread() slice from small ds succeeded."); - /* verify that expected data is retrieved */ expected_value = (uint32_t)( - (i * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size * tv_ptr->edge_size) + + (i * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + - (k * tv_ptr->edge_size * tv_ptr->edge_size) + - (l * tv_ptr->edge_size)); + (k * tv_ptr->edge_size * tv_ptr->edge_size) + (l * tv_ptr->edge_size)); start_index = (size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size; - stop_index = start_index + tv_ptr->small_ds_slice_size - 1; + stop_index = start_index + tv_ptr->small_ds_slice_size - 1; - HDassert( start_index < stop_index ); - HDassert( stop_index <= tv_ptr->small_ds_size ); + HDassert(start_index < stop_index); + HDassert(stop_index <= tv_ptr->small_ds_size); data_ok = TRUE; ptr_1 = tv_ptr->small_ds_buf_1; - for ( u = 0; u < start_index; u++, ptr_1++ ) { + for (u = 0; u < start_index; u++, ptr_1++) { - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { data_ok = FALSE; - *ptr_1 = 0; + *ptr_1 = 0; } } - data_ok &= ckrbrd_hs_dr_pio_test__verify_data - ( - tv_ptr->small_ds_buf_1 + start_index, - tv_ptr->small_rank - 1, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - expected_value, - (hbool_t)TRUE - ); - + data_ok &= ckrbrd_hs_dr_pio_test__verify_data( + tv_ptr->small_ds_buf_1 + start_index, tv_ptr->small_rank - 1, tv_ptr->edge_size, + tv_ptr->checker_edge_size, expected_value, (hbool_t)TRUE); ptr_1 = tv_ptr->small_ds_buf_1; - for ( u = stop_index; u < tv_ptr->small_ds_size; u++, ptr_1++ ) { + for (u = stop_index; u < tv_ptr->small_ds_size; u++, ptr_1++) { - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { data_ok = FALSE; - *ptr_1 = 0; + *ptr_1 = 0; } } - VRFY((data_ok == TRUE), - "large slice write slice to small slice data good."); + VRFY((data_ok == TRUE), "large slice write slice to small slice data good."); (tv_ptr->tests_run)++; } @@ -3814,23 +3312,16 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) (tv_ptr->total_tests)++; - } while ( ( tv_ptr->large_rank > 2 ) && - ( (tv_ptr->small_rank - 1) <= 1 ) && - ( l < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 2) && ((tv_ptr->small_rank - 1) <= 1) && (l < tv_ptr->edge_size)); k++; - } while ( ( tv_ptr->large_rank > 3 ) && - ( (tv_ptr->small_rank - 1) <= 2 ) && - ( k < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 3) && ((tv_ptr->small_rank - 1) <= 2) && (k < tv_ptr->edge_size)); j++; - } while ( ( tv_ptr->large_rank > 4 ) && - ( (tv_ptr->small_rank - 1) <= 3 ) && - ( j < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 4) && ((tv_ptr->small_rank - 1) <= 3) && (j < tv_ptr->edge_size)); return; } /* ckrbrd_hs_dr_pio_test__m2d_l2s() */ - /*------------------------------------------------------------------------- * Function: ckrbrd_hs_dr_pio_test__m2d_s2l() * @@ -3860,27 +3351,26 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) #define CHECKER_BOARD_HS_DR_PIO_TEST__M2D_S2L__DEBUG 0 static void -ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) +ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t *tv_ptr) { #if CHECKER_BOARD_HS_DR_PIO_TEST__M2D_S2L__DEBUG const char *fcnName = "ckrbrd_hs_dr_pio_test__m2d_s2l()"; #endif /* CONTIG_HS_DR_PIO_TEST__M2D_S2L__DEBUG */ - hbool_t data_ok = FALSE; - int i, j, k, l; - size_t u; - size_t start_index; - size_t stop_index; - uint32_t expected_value; - uint32_t * ptr_1; - int mpi_rank; /* needed by VRFY */ - hsize_t sel_start[PAR_SS_DR_MAX_RANK]; - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + hbool_t data_ok = FALSE; + int i, j, k, l; + size_t u; + size_t start_index; + size_t stop_index; + uint32_t expected_value; + uint32_t *ptr_1; + int mpi_rank; /* needed by VRFY */ + hsize_t sel_start[PAR_SS_DR_MAX_RANK]; + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ /* initialize the local copy of mpi_rank */ mpi_rank = tv_ptr->mpi_rank; - /* Now write the contents of the process's slice of the in memory * small data set to slices of the on disk large data set. After * each write, read the process's slice of the large data set back @@ -3889,33 +3379,25 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * and file selections. */ - tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); + tv_ptr->start[0] = (hsize_t)(tv_ptr->mpi_rank); tv_ptr->stride[0] = (hsize_t)(2 * (tv_ptr->mpi_size + 1)); - tv_ptr->count[0] = 1; - tv_ptr->block[0] = 1; + tv_ptr->count[0] = 1; + tv_ptr->block[0] = 1; - for ( i = 1; i < tv_ptr->large_rank; i++ ) { + for (i = 1; i < tv_ptr->large_rank; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); + tv_ptr->count[i] = 1; + tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } - ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->file_large_ds_sid_0, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_large_ds_sid_0, set) suceeded"); - ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, - H5S_SELECT_SET, - tv_ptr->start, - tv_ptr->stride, - tv_ptr->count, - tv_ptr->block); + ret = H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, H5S_SELECT_SET, tv_ptr->start, tv_ptr->stride, + tv_ptr->count, tv_ptr->block); VRFY((ret >= 0), "H5Sselect_hyperslab(tv_ptr->mem_large_ds_sid, set) suceeded"); /* setup a checkerboard selection of the slice of the in memory small @@ -3923,30 +3405,26 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) */ sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0; - sel_start[tv_ptr->small_ds_offset] = (hsize_t)(tv_ptr->mpi_rank); - - ckrbrd_hs_dr_pio_test__slct_ckrbrd(tv_ptr->mpi_rank, - tv_ptr->mem_small_ds_sid, - tv_ptr->small_rank, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - tv_ptr->small_rank - 1, + sel_start[tv_ptr->small_ds_offset] = (hsize_t)(tv_ptr->mpi_rank); + + ckrbrd_hs_dr_pio_test__slct_ckrbrd(tv_ptr->mpi_rank, tv_ptr->mem_small_ds_sid, tv_ptr->small_rank, + tv_ptr->edge_size, tv_ptr->checker_edge_size, tv_ptr->small_rank - 1, sel_start); /* set up start, stride, count, and block -- note that we will * change start[] so as to write checkerboard selections of slices * of the small data set to slices of the large data set. */ - for ( i = 0; i < PAR_SS_DR_MAX_RANK; i++ ) { + for (i = 0; i < PAR_SS_DR_MAX_RANK; i++) { - tv_ptr->start[i] = 0; + tv_ptr->start[i] = 0; tv_ptr->stride[i] = (hsize_t)(2 * tv_ptr->edge_size); - tv_ptr->count[i] = 1; - if ( (PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1) ) { + tv_ptr->count[i] = 1; + if ((PAR_SS_DR_MAX_RANK - i) > (tv_ptr->small_rank - 1)) { tv_ptr->block[i] = 1; - - } else { + } + else { tv_ptr->block[i] = (hsize_t)(tv_ptr->edge_size); } @@ -3957,15 +3435,16 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) #if CHECKER_BOARD_HS_DR_PIO_TEST__M2D_S2L__DEBUG HDfprintf(stdout, - "%s writing process checkerboard selections of slices of small ds to process slices of large ds on disk.\n", - fcnName); + "%s writing process checkerboard selections of slices of small ds to process slices of large " + "ds on disk.\n", + fcnName); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__M2D_S2L__DEBUG */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 0) { i = tv_ptr->mpi_rank; - - } else { + } + else { i = 0; } @@ -3976,21 +3455,21 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * test. */ - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 1) { j = tv_ptr->mpi_rank; - - } else { + } + else { j = 0; } do { - if ( PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2 ) { + if (PAR_SS_DR_MAX_RANK - tv_ptr->large_rank == 2) { k = tv_ptr->mpi_rank; - - } else { + } + else { k = 0; } @@ -4008,11 +3487,11 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) l = 0; do { - if ( (tv_ptr->skips)++ < tv_ptr->max_skips ) { /* skip the test */ + if ((tv_ptr->skips)++ < tv_ptr->max_skips) { /* skip the test */ (tv_ptr->tests_skipped)++; - - } else { /* run the test */ + } + else { /* run the test */ tv_ptr->skips = 0; /* reset the skips counter */ @@ -4025,15 +3504,10 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * Note that this will leave one slice with its original data * as there is one more slice than processes. */ - ret = H5Dwrite(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_large_ds_sid, - tv_ptr->file_large_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->large_ds_buf_2); + ret = H5Dwrite(tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_large_ds_sid, + tv_ptr->file_large_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_2); VRFY((ret != FAIL), "H5Dwrite() to zero large ds suceeded"); - /* select the portion of the in memory large cube to which we * are going to write data. */ @@ -4043,23 +3517,15 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) tv_ptr->start[3] = (hsize_t)l; tv_ptr->start[4] = 0; - HDassert((tv_ptr->start[0] == 0)||(0 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[1] == 0)||(1 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[2] == 0)||(2 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[3] == 0)||(3 < tv_ptr->small_ds_offset + 1)); - HDassert((tv_ptr->start[4] == 0)||(4 < tv_ptr->small_ds_offset + 1)); - - ckrbrd_hs_dr_pio_test__slct_ckrbrd - ( - tv_ptr->mpi_rank, - tv_ptr->file_large_ds_sid_1, - tv_ptr->large_rank, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - tv_ptr->small_rank - 1, - tv_ptr->start - ); + HDassert((tv_ptr->start[0] == 0) || (0 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[1] == 0) || (1 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[2] == 0) || (2 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[3] == 0) || (3 < tv_ptr->small_ds_offset + 1)); + HDassert((tv_ptr->start[4] == 0) || (4 < tv_ptr->small_ds_offset + 1)); + ckrbrd_hs_dr_pio_test__slct_ckrbrd( + tv_ptr->mpi_rank, tv_ptr->file_large_ds_sid_1, tv_ptr->large_rank, tv_ptr->edge_size, + tv_ptr->checker_edge_size, tv_ptr->small_rank - 1, tv_ptr->start); /* verify that H5Sselect_shape_same() reports the in * memory small data set slice selection and the @@ -4069,97 +3535,70 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) check = H5Sselect_shape_same(tv_ptr->mem_small_ds_sid, tv_ptr->file_large_ds_sid_1); VRFY((check == TRUE), "H5Sselect_shape_same passed"); - /* write the small data set slice from memory to the * target slice of the disk data set */ #if CHECKER_BOARD_HS_DR_PIO_TEST__M2D_S2L__DEBUG - HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", - fcnName, tv_ptr->mpi_rank, - tv_ptr->start[0], tv_ptr->start[1], tv_ptr->start[2], - tv_ptr->start[3], tv_ptr->start[4]); - HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", - fcnName, tv_ptr->mpi_rank, + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, tv_ptr->mpi_rank, + tv_ptr->start[0], tv_ptr->start[1], tv_ptr->start[2], tv_ptr->start[3], + tv_ptr->start[4]); + HDfprintf(stdout, "%s:%d: mem/file extent dims = %d/%d.\n", fcnName, tv_ptr->mpi_rank, H5Sget_simple_extent_ndims(tv_ptr->mem_small_ds_sid), H5Sget_simple_extent_ndims(tv_ptr->file_large_ds_sid_1)); #endif /* CHECKER_BOARD_HS_DR_PIO_TEST__M2D_S2L__DEBUG */ - ret = H5Dwrite(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_small_ds_sid, - tv_ptr->file_large_ds_sid_1, - tv_ptr->xfer_plist, - tv_ptr->small_ds_buf_0); - VRFY((ret != FAIL), - "H5Dwrite of small ds slice to large ds succeeded"); - + ret = H5Dwrite(tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_small_ds_sid, + tv_ptr->file_large_ds_sid_1, tv_ptr->xfer_plist, tv_ptr->small_ds_buf_0); + VRFY((ret != FAIL), "H5Dwrite of small ds slice to large ds succeeded"); /* read this processes slice on the on disk large * data set into memory. */ - ret = H5Dread(tv_ptr->large_dataset, - H5T_NATIVE_UINT32, - tv_ptr->mem_large_ds_sid, - tv_ptr->file_large_ds_sid_0, - tv_ptr->xfer_plist, - tv_ptr->large_ds_buf_1); - VRFY((ret != FAIL), - "H5Dread() of process slice of large ds succeeded"); - + ret = H5Dread(tv_ptr->large_dataset, H5T_NATIVE_UINT32, tv_ptr->mem_large_ds_sid, + tv_ptr->file_large_ds_sid_0, tv_ptr->xfer_plist, tv_ptr->large_ds_buf_1); + VRFY((ret != FAIL), "H5Dread() of process slice of large ds succeeded"); /* verify that the expected data and only the * expected data was read. */ - expected_value = - (uint32_t)((size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size); - - start_index = (size_t) - ((i * tv_ptr->edge_size * tv_ptr->edge_size * - tv_ptr->edge_size * tv_ptr->edge_size) + - (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + - (k * tv_ptr->edge_size * tv_ptr->edge_size) + - (l * tv_ptr->edge_size)); - stop_index = start_index + tv_ptr->small_ds_slice_size - 1; + expected_value = (uint32_t)((size_t)(tv_ptr->mpi_rank) * tv_ptr->small_ds_slice_size); - HDassert( start_index < stop_index ); - HDassert( stop_index < tv_ptr->large_ds_size ); + start_index = (size_t)( + (i * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + + (j * tv_ptr->edge_size * tv_ptr->edge_size * tv_ptr->edge_size) + + (k * tv_ptr->edge_size * tv_ptr->edge_size) + (l * tv_ptr->edge_size)); + stop_index = start_index + tv_ptr->small_ds_slice_size - 1; + HDassert(start_index < stop_index); + HDassert(stop_index < tv_ptr->large_ds_size); data_ok = TRUE; ptr_1 = tv_ptr->large_ds_buf_1; - for ( u = 0; u < start_index; u++, ptr_1++ ) { + for (u = 0; u < start_index; u++, ptr_1++) { - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { data_ok = FALSE; - *ptr_1 = 0; + *ptr_1 = 0; } } - data_ok &= ckrbrd_hs_dr_pio_test__verify_data - ( - tv_ptr->large_ds_buf_1 + start_index, - tv_ptr->small_rank - 1, - tv_ptr->edge_size, - tv_ptr->checker_edge_size, - expected_value, - (hbool_t)TRUE - ); - + data_ok &= ckrbrd_hs_dr_pio_test__verify_data( + tv_ptr->large_ds_buf_1 + start_index, tv_ptr->small_rank - 1, tv_ptr->edge_size, + tv_ptr->checker_edge_size, expected_value, (hbool_t)TRUE); ptr_1 = tv_ptr->large_ds_buf_1; - for ( u = stop_index; u < tv_ptr->small_ds_size; u++, ptr_1++ ) { + for (u = stop_index; u < tv_ptr->small_ds_size; u++, ptr_1++) { - if ( *ptr_1 != 0 ) { + if (*ptr_1 != 0) { data_ok = FALSE; - *ptr_1 = 0; + *ptr_1 = 0; } } - VRFY((data_ok == TRUE), - "small ds cb slice write to large ds slice data good."); + VRFY((data_ok == TRUE), "small ds cb slice write to large ds slice data good."); (tv_ptr->tests_run)++; } @@ -4168,23 +3607,16 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) (tv_ptr->total_tests)++; - } while ( ( tv_ptr->large_rank > 2 ) && - ( (tv_ptr->small_rank - 1) <= 1 ) && - ( l < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 2) && ((tv_ptr->small_rank - 1) <= 1) && (l < tv_ptr->edge_size)); k++; - } while ( ( tv_ptr->large_rank > 3 ) && - ( (tv_ptr->small_rank - 1) <= 2 ) && - ( k < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 3) && ((tv_ptr->small_rank - 1) <= 2) && (k < tv_ptr->edge_size)); j++; - } while ( ( tv_ptr->large_rank > 4 ) && - ( (tv_ptr->small_rank - 1) <= 3 ) && - ( j < tv_ptr->edge_size ) ); + } while ((tv_ptr->large_rank > 4) && ((tv_ptr->small_rank - 1) <= 3) && (j < tv_ptr->edge_size)); return; } /* ckrbrd_hs_dr_pio_test__m2d_s2l() */ - /*------------------------------------------------------------------------- * Function: ckrbrd_hs_dr_pio_test__run_test() * @@ -4201,27 +3633,17 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) #define CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG 0 static void -ckrbrd_hs_dr_pio_test__run_test(const int test_num, - const int edge_size, - const int checker_edge_size, - const int chunk_edge_size, - const int small_rank, - const int large_rank, - const hbool_t use_collective_io, - const hid_t dset_type, - const int express_test, - int * skips_ptr, - int max_skips, - int64_t * total_tests_ptr, - int64_t * tests_run_ptr, - int64_t * tests_skipped_ptr) +ckrbrd_hs_dr_pio_test__run_test(const int test_num, const int edge_size, const int checker_edge_size, + const int chunk_edge_size, const int small_rank, const int large_rank, + const hbool_t use_collective_io, const hid_t dset_type, + const int express_test, int *skips_ptr, int max_skips, + int64_t *total_tests_ptr, int64_t *tests_run_ptr, int64_t *tests_skipped_ptr) { #if CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG const char *fcnName = "ckrbrd_hs_dr_pio_test__run_test()"; #endif /* CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ - struct hs_dr_pio_test_vars_t test_vars = - { + struct hs_dr_pio_test_vars_t test_vars = { /* int mpi_size = */ -1, /* int mpi_rank = */ -1, /* MPI_Comm mpi_comm = */ MPI_COMM_NULL, @@ -4243,7 +3665,7 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, /* uint32_t * large_ds_slice_buf = */ NULL, /* int small_ds_offset = */ -1, /* int large_ds_offset = */ -1, - /* hid_t fid = */ -1, /* HDF5 file ID */ + /* hid_t fid = */ -1, /* HDF5 file ID */ /* hid_t xfer_plist = */ H5P_DEFAULT, /* hid_t full_mem_small_ds_sid = */ -1, /* hid_t full_file_small_ds_sid = */ -1, @@ -4259,18 +3681,18 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, /* hid_t file_large_ds_process_slice_sid = */ -1, /* hid_t mem_large_ds_process_slice_sid = */ -1, /* hid_t large_ds_slice_sid = */ -1, - /* hid_t small_dataset = */ -1, /* Dataset ID */ - /* hid_t large_dataset = */ -1, /* Dataset ID */ + /* hid_t small_dataset = */ -1, /* Dataset ID */ + /* hid_t large_dataset = */ -1, /* Dataset ID */ /* size_t small_ds_size = */ 1, /* size_t small_ds_slice_size = */ 1, /* size_t large_ds_size = */ 1, /* size_t large_ds_slice_size = */ 1, - /* hsize_t dims[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t chunk_dims[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t start[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t stride[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t count[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, - /* hsize_t block[PAR_SS_DR_MAX_RANK] = */ {0,0,0,0,0}, + /* hsize_t dims[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t chunk_dims[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t start[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t stride[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t count[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, + /* hsize_t block[PAR_SS_DR_MAX_RANK] = */ {0, 0, 0, 0, 0}, /* hsize_t * start_ptr = */ NULL, /* hsize_t * stride_ptr = */ NULL, /* hsize_t * count_ptr = */ NULL, @@ -4279,30 +3701,23 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, /* int max_skips = */ 0, /* int64_t total_tests = */ 0, /* int64_t tests_run = */ 0, - /* int64_t tests_skipped = */ 0 - }; - struct hs_dr_pio_test_vars_t * tv_ptr = &test_vars; - - hs_dr_pio_test__setup(test_num, edge_size, checker_edge_size, - chunk_edge_size, small_rank, large_rank, - use_collective_io, dset_type, express_test, - tv_ptr); + /* int64_t tests_skipped = */ 0}; + struct hs_dr_pio_test_vars_t *tv_ptr = &test_vars; + hs_dr_pio_test__setup(test_num, edge_size, checker_edge_size, chunk_edge_size, small_rank, large_rank, + use_collective_io, dset_type, express_test, tv_ptr); /* initialize skips & max_skips */ - tv_ptr->skips = *skips_ptr; + tv_ptr->skips = *skips_ptr; tv_ptr->max_skips = max_skips; - #if CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { - HDfprintf(stdout, "test %d: small rank = %d, large rank = %d.\n", - test_num, small_rank, large_rank); + if (MAINPROCESS) { + HDfprintf(stdout, "test %d: small rank = %d, large rank = %d.\n", test_num, small_rank, large_rank); HDfprintf(stdout, "test %d: Initialization complete.\n", test_num); } #endif /* CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ - /* first, verify that we can read from disk correctly using selections * of different rank that H5Sselect_shape_same() views as being of the * same shape. @@ -4318,7 +3733,6 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, ckrbrd_hs_dr_pio_test__d2m_l2s(tv_ptr); - /* similarly, read slices of the on disk small data set into slices * through the in memory large data set, and verify that the correct * data (and only the correct data) is read. @@ -4326,7 +3740,6 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, ckrbrd_hs_dr_pio_test__d2m_s2l(tv_ptr); - /* now we go in the opposite direction, verifying that we can write * from memory to file using selections of different rank that * H5Sselect_shape_same() views as being of the same shape. @@ -4340,7 +3753,6 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, ckrbrd_hs_dr_pio_test__m2d_l2s(tv_ptr); - /* Now write the contents of the process's slice of the in memory * small data set to slices of the on disk large data set. After * each write, read the process's slice of the large data set back @@ -4351,20 +3763,18 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, ckrbrd_hs_dr_pio_test__m2d_s2l(tv_ptr); - #if CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { - HDfprintf(stdout, - "test %d: Subtests complete -- tests run/skipped/total = %lld/%lld/%lld.\n", - test_num, (long long)(tv_ptr->tests_run), (long long)(tv_ptr->tests_skipped), - (long long)(tv_ptr->total_tests)); + if (MAINPROCESS) { + HDfprintf(stdout, "test %d: Subtests complete -- tests run/skipped/total = %lld/%lld/%lld.\n", + test_num, (long long)(tv_ptr->tests_run), (long long)(tv_ptr->tests_skipped), + (long long)(tv_ptr->total_tests)); } #endif /* CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ hs_dr_pio_test__takedown(tv_ptr); #if CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG - if ( MAINPROCESS ) { + if (MAINPROCESS) { HDfprintf(stdout, "test %d: Takedown complete.\n", test_num); } #endif /* CKRBRD_HS_DR_PIO_TEST__RUN_TEST__DEBUG */ @@ -4378,7 +3788,6 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, } /* ckrbrd_hs_dr_pio_test__run_test() */ - /*------------------------------------------------------------------------- * Function: ckrbrd_hs_dr_pio_test() * @@ -4395,29 +3804,29 @@ ckrbrd_hs_dr_pio_test__run_test(const int test_num, static void ckrbrd_hs_dr_pio_test(ShapeSameTestMethods sstest_type) { - int express_test; - int local_express_test; - int mpi_size = -1; - int mpi_rank = -1; - int test_num = 0; - int edge_size; - int checker_edge_size = 3; - int chunk_edge_size = 0; - int small_rank = 3; - int large_rank = 4; - int mpi_result; - hid_t dset_type = H5T_NATIVE_UINT; - int skips = 0; - int max_skips = 0; + int express_test; + int local_express_test; + int mpi_size = -1; + int mpi_rank = -1; + int test_num = 0; + int edge_size; + int checker_edge_size = 3; + int chunk_edge_size = 0; + int small_rank = 3; + int large_rank = 4; + int mpi_result; + hid_t dset_type = H5T_NATIVE_UINT; + int skips = 0; + int max_skips = 0; /* The following table list the number of sub-tests skipped between * each test that is actually executed as a function of the express * test level. Note that any value in excess of 4880 will cause all * sub tests to be skipped. */ - int max_skips_tbl[4] = {0, 4, 64, 1024}; - int64_t total_tests = 0; - int64_t tests_run = 0; - int64_t tests_skipped = 0; + int max_skips_tbl[4] = {0, 4, 64, 1024}; + int64_t total_tests = 0; + int64_t tests_run = 0; + int64_t tests_skipped = 0; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -4428,20 +3837,18 @@ ckrbrd_hs_dr_pio_test(ShapeSameTestMethods sstest_type) HDcompile_assert(sizeof(uint32_t) == sizeof(unsigned)); - mpi_result = MPI_Allreduce((void *)&local_express_test, - (void *)&express_test, - 1, - MPI_INT, - MPI_MAX, + mpi_result = MPI_Allreduce((void *)&local_express_test, (void *)&express_test, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); - VRFY((mpi_result == MPI_SUCCESS ), "MPI_Allreduce(0) succeeded"); + VRFY((mpi_result == MPI_SUCCESS), "MPI_Allreduce(0) succeeded"); - if ( local_express_test < 0 ) { + if (local_express_test < 0) { max_skips = max_skips_tbl[0]; - } else if ( local_express_test > 3 ) { + } + else if (local_express_test > 3) { max_skips = max_skips_tbl[3]; - } else { + } + else { max_skips = max_skips_tbl[local_express_test]; } @@ -4453,48 +3860,27 @@ ckrbrd_hs_dr_pio_test(ShapeSameTestMethods sstest_type) } #endif - for ( large_rank = 3; large_rank <= PAR_SS_DR_MAX_RANK; large_rank++ ) { + for (large_rank = 3; large_rank <= PAR_SS_DR_MAX_RANK; large_rank++) { - for ( small_rank = 2; small_rank < large_rank; small_rank++ ) { - switch(sstest_type){ + for (small_rank = 2; small_rank < large_rank; small_rank++) { + switch (sstest_type) { case IND_CONTIG: /* contiguous data set, independent I/O */ chunk_edge_size = 0; - ckrbrd_hs_dr_pio_test__run_test(test_num, - edge_size, - checker_edge_size, - chunk_edge_size, - small_rank, - large_rank, - FALSE, - dset_type, - express_test, - &skips, - max_skips, - &total_tests, - &tests_run, + ckrbrd_hs_dr_pio_test__run_test(test_num, edge_size, checker_edge_size, chunk_edge_size, + small_rank, large_rank, FALSE, dset_type, express_test, + &skips, max_skips, &total_tests, &tests_run, &tests_skipped); test_num++; break; /* end of case IND_CONTIG */ - case COL_CONTIG: + case COL_CONTIG: /* contiguous data set, collective I/O */ chunk_edge_size = 0; - ckrbrd_hs_dr_pio_test__run_test(test_num, - edge_size, - checker_edge_size, - chunk_edge_size, - small_rank, - large_rank, - TRUE, - dset_type, - express_test, - &skips, - max_skips, - &total_tests, - &tests_run, - &tests_skipped); + ckrbrd_hs_dr_pio_test__run_test( + test_num, edge_size, checker_edge_size, chunk_edge_size, small_rank, large_rank, TRUE, + dset_type, express_test, &skips, max_skips, &total_tests, &tests_run, &tests_skipped); test_num++; break; /* end of case COL_CONTIG */ @@ -4502,19 +3888,9 @@ ckrbrd_hs_dr_pio_test(ShapeSameTestMethods sstest_type) case IND_CHUNKED: /* chunked data set, independent I/O */ chunk_edge_size = 5; - ckrbrd_hs_dr_pio_test__run_test(test_num, - edge_size, - checker_edge_size, - chunk_edge_size, - small_rank, - large_rank, - FALSE, - dset_type, - express_test, - &skips, - max_skips, - &total_tests, - &tests_run, + ckrbrd_hs_dr_pio_test__run_test(test_num, edge_size, checker_edge_size, chunk_edge_size, + small_rank, large_rank, FALSE, dset_type, express_test, + &skips, max_skips, &total_tests, &tests_run, &tests_skipped); test_num++; break; @@ -4523,20 +3899,9 @@ ckrbrd_hs_dr_pio_test(ShapeSameTestMethods sstest_type) case COL_CHUNKED: /* chunked data set, collective I/O */ chunk_edge_size = 5; - ckrbrd_hs_dr_pio_test__run_test(test_num, - edge_size, - checker_edge_size, - chunk_edge_size, - small_rank, - large_rank, - TRUE, - dset_type, - express_test, - &skips, - max_skips, - &total_tests, - &tests_run, - &tests_skipped); + ckrbrd_hs_dr_pio_test__run_test( + test_num, edge_size, checker_edge_size, chunk_edge_size, small_rank, large_rank, TRUE, + dset_type, express_test, &skips, max_skips, &total_tests, &tests_run, &tests_skipped); test_num++; break; /* end of case COL_CHUNKED */ @@ -4547,17 +3912,17 @@ ckrbrd_hs_dr_pio_test(ShapeSameTestMethods sstest_type) } /* end of switch(sstest_type) */ #if CONTIG_HS_DR_PIO_TEST__DEBUG - if ( ( MAINPROCESS ) && ( tests_skipped > 0 ) ) { - HDfprintf(stdout, " run/skipped/total = %lld/%lld/%lld.\n", - tests_run, tests_skipped, total_tests); + if ((MAINPROCESS) && (tests_skipped > 0)) { + HDfprintf(stdout, " run/skipped/total = %lld/%lld/%lld.\n", tests_run, tests_skipped, + total_tests); } #endif /* CONTIG_HS_DR_PIO_TEST__DEBUG */ } } - if ( ( MAINPROCESS ) && ( tests_skipped > 0 ) ) { - HDfprintf(stdout, " %lld of %lld subtests skipped to expedite testing.\n", - tests_skipped, total_tests); + if ((MAINPROCESS) && (tests_skipped > 0)) { + HDfprintf(stdout, " %lld of %lld subtests skipped to expedite testing.\n", tests_skipped, + total_tests); } return; @@ -4573,23 +3938,23 @@ ckrbrd_hs_dr_pio_test(ShapeSameTestMethods sstest_type) #include "testphdf5.h" #ifndef PATH_MAX -#define PATH_MAX 512 -#endif /* !PATH_MAX */ +#define PATH_MAX 512 +#endif /* !PATH_MAX */ /* global variables */ int dim0; int dim1; int chunkdim0; int chunkdim1; -int nerrors = 0; /* errors count */ -int ndatasets = 300; /* number of datasets to create*/ -int ngroups = 512; /* number of groups to create in root - * group. */ -int facc_type = FACC_MPIO; /*Test file access type */ +int nerrors = 0; /* errors count */ +int ndatasets = 300; /* number of datasets to create*/ +int ngroups = 512; /* number of groups to create in root + * group. */ +int facc_type = FACC_MPIO; /*Test file access type */ int dxfer_coll_type = DXFER_COLLECTIVE_IO; -H5E_auto2_t old_func; /* previous error handler */ -void *old_client_data; /* previous error handler arg.*/ +H5E_auto2_t old_func; /* previous error handler */ +void * old_client_data; /* previous error handler arg.*/ /* other option flags */ @@ -4598,13 +3963,11 @@ void *old_client_data; /* previous error handler arg.*/ * created in one test is accessed by a different test. * filenames[0] is reserved as the file name for PARATESTFILE. */ -#define NFILENAME 2 +#define NFILENAME 2 #define PARATESTFILE filenames[0] -const char *FILENAME[NFILENAME]={ - "ShapeSameTest", - NULL}; -char filenames[NFILENAME][PATH_MAX]; -hid_t fapl; /* file access property list */ +const char *FILENAME[NFILENAME] = {"ShapeSameTest", NULL}; +char filenames[NFILENAME][PATH_MAX]; +hid_t fapl; /* file access property list */ #ifdef USE_PAUSE /* pause the process for a moment to allow debugger to attach if desired. */ @@ -4613,15 +3976,16 @@ hid_t fapl; /* file access property list */ #include #include -void pause_proc(void) +void +pause_proc(void) { - int pid; - h5_stat_t statbuf; - char greenlight[] = "go"; - int maxloop = 10; - int loops = 0; - int time_int = 10; + int pid; + h5_stat_t statbuf; + char greenlight[] = "go"; + int maxloop = 10; + int loops = 0; + int time_int = 10; /* mpi variables */ int mpi_size, mpi_rank; @@ -4634,28 +3998,28 @@ void pause_proc(void) MPI_Get_processor_name(mpi_name, &mpi_namelen); if (MAINPROCESS) - while ((HDstat(greenlight, &statbuf) == -1) && loops < maxloop){ - if (!loops++){ - HDprintf("Proc %d (%*s, %d): to debug, attach %d\n", - mpi_rank, mpi_namelen, mpi_name, pid, pid); - } - HDprintf("waiting(%ds) for file %s ...\n", time_int, greenlight); - fflush(stdout); + while ((HDstat(greenlight, &statbuf) == -1) && loops < maxloop) { + if (!loops++) { + HDprintf("Proc %d (%*s, %d): to debug, attach %d\n", mpi_rank, mpi_namelen, mpi_name, pid, + pid); + } + HDprintf("waiting(%ds) for file %s ...\n", time_int, greenlight); + fflush(stdout); HDsleep(time_int); - } + } MPI_Barrier(MPI_COMM_WORLD); } /* Use the Profile feature of MPI to call the pause_proc() */ -int MPI_Init(int *argc, char ***argv) +int +MPI_Init(int *argc, char ***argv) { int ret_code; - ret_code=PMPI_Init(argc, argv); + ret_code = PMPI_Init(argc, argv); pause_proc(); return (ret_code); } -#endif /* USE_PAUSE */ - +#endif /* USE_PAUSE */ /* * Show command usage @@ -4664,198 +4028,198 @@ static void usage(void) { HDprintf(" [-r] [-w] [-m] [-n] " - "[-o] [-f ] [-d ]\n"); + "[-o] [-f ] [-d ]\n"); HDprintf("\t-m" - "\tset number of datasets for the multiple dataset test\n"); + "\tset number of datasets for the multiple dataset test\n"); HDprintf("\t-n" - "\tset number of groups for the multiple group test\n"); + "\tset number of groups for the multiple group test\n"); HDprintf("\t-f \tfilename prefix\n"); HDprintf("\t-2\t\tuse Split-file together with MPIO\n"); - HDprintf("\t-d \tdataset dimensions factors. Defaults (%d,%d)\n", - ROW_FACTOR, COL_FACTOR); + HDprintf("\t-d \tdataset dimensions factors. Defaults (%d,%d)\n", ROW_FACTOR, + COL_FACTOR); HDprintf("\t-c \tdataset chunk dimensions. Defaults (dim0/10,dim1/10)\n"); HDprintf("\n"); } - /* * parse the command line options */ static int parse_options(int argc, char **argv) { - int mpi_size, mpi_rank; /* mpi variables */ + int mpi_size, mpi_rank; /* mpi variables */ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* setup default chunk-size. Make sure sizes are > 0 */ - chunkdim0 = (dim0+9)/10; - chunkdim1 = (dim1+9)/10; + chunkdim0 = (dim0 + 9) / 10; + chunkdim1 = (dim1 + 9) / 10; - while (--argc){ - if (**(++argv) != '-'){ - break; - }else{ - switch(*(*argv+1)){ - case 'm': ndatasets = atoi((*argv+1)+1); - if (ndatasets < 0){ - nerrors++; - return(1); - } - break; - case 'n': ngroups = atoi((*argv+1)+1); - if (ngroups < 0){ - nerrors++; - return(1); - } - break; - case 'f': if (--argc < 1) { - nerrors++; - return(1); - } - if (**(++argv) == '-') { - nerrors++; - return(1); - } - paraprefix = *argv; - break; - case 'i': /* Collective MPI-IO access with independent IO */ - dxfer_coll_type = DXFER_INDEPENDENT_IO; - break; - case '2': /* Use the split-file driver with MPIO access */ - /* Can use $HDF5_METAPREFIX to define the */ - /* meta-file-prefix. */ - facc_type = FACC_MPIO | FACC_SPLIT; - break; - case 'd': /* dimensizes */ - if (--argc < 2){ - nerrors++; - return(1); - } - dim0 = atoi(*(++argv))*mpi_size; - argc--; - dim1 = atoi(*(++argv))*mpi_size; - /* set default chunkdim sizes too */ - chunkdim0 = (dim0+9)/10; - chunkdim1 = (dim1+9)/10; - break; - case 'c': /* chunk dimensions */ - if (--argc < 2){ - nerrors++; - return(1); - } - chunkdim0 = atoi(*(++argv)); - argc--; - chunkdim1 = atoi(*(++argv)); - break; - case 'h': /* print help message--return with nerrors set */ - return(1); - default: HDprintf("Illegal option(%s)\n", *argv); - nerrors++; - return(1); + while (--argc) { + if (**(++argv) != '-') { + break; + } + else { + switch (*(*argv + 1)) { + case 'm': + ndatasets = atoi((*argv + 1) + 1); + if (ndatasets < 0) { + nerrors++; + return (1); + } + break; + case 'n': + ngroups = atoi((*argv + 1) + 1); + if (ngroups < 0) { + nerrors++; + return (1); + } + break; + case 'f': + if (--argc < 1) { + nerrors++; + return (1); + } + if (**(++argv) == '-') { + nerrors++; + return (1); + } + paraprefix = *argv; + break; + case 'i': /* Collective MPI-IO access with independent IO */ + dxfer_coll_type = DXFER_INDEPENDENT_IO; + break; + case '2': /* Use the split-file driver with MPIO access */ + /* Can use $HDF5_METAPREFIX to define the */ + /* meta-file-prefix. */ + facc_type = FACC_MPIO | FACC_SPLIT; + break; + case 'd': /* dimensizes */ + if (--argc < 2) { + nerrors++; + return (1); + } + dim0 = atoi(*(++argv)) * mpi_size; + argc--; + dim1 = atoi(*(++argv)) * mpi_size; + /* set default chunkdim sizes too */ + chunkdim0 = (dim0 + 9) / 10; + chunkdim1 = (dim1 + 9) / 10; + break; + case 'c': /* chunk dimensions */ + if (--argc < 2) { + nerrors++; + return (1); + } + chunkdim0 = atoi(*(++argv)); + argc--; + chunkdim1 = atoi(*(++argv)); + break; + case 'h': /* print help message--return with nerrors set */ + return (1); + default: + HDprintf("Illegal option(%s)\n", *argv); + nerrors++; + return (1); + } } - } } /*while*/ /* check validity of dimension and chunk sizes */ - if (dim0 <= 0 || dim1 <= 0){ - HDprintf("Illegal dim sizes (%d, %d)\n", dim0, dim1); - nerrors++; - return(1); + if (dim0 <= 0 || dim1 <= 0) { + HDprintf("Illegal dim sizes (%d, %d)\n", dim0, dim1); + nerrors++; + return (1); } - if (chunkdim0 <= 0 || chunkdim1 <= 0){ - HDprintf("Illegal chunkdim sizes (%d, %d)\n", chunkdim0, chunkdim1); - nerrors++; - return(1); + if (chunkdim0 <= 0 || chunkdim1 <= 0) { + HDprintf("Illegal chunkdim sizes (%d, %d)\n", chunkdim0, chunkdim1); + nerrors++; + return (1); } /* Make sure datasets can be divided into equal portions by the processes */ - if ((dim0 % mpi_size) || (dim1 % mpi_size)){ - if (MAINPROCESS) - HDprintf("dim0(%d) and dim1(%d) must be multiples of processes(%d)\n", - dim0, dim1, mpi_size); - nerrors++; - return(1); + if ((dim0 % mpi_size) || (dim1 % mpi_size)) { + if (MAINPROCESS) + HDprintf("dim0(%d) and dim1(%d) must be multiples of processes(%d)\n", dim0, dim1, mpi_size); + nerrors++; + return (1); } /* compose the test filenames */ { - int i, n; + int i, n; - n = sizeof(FILENAME)/sizeof(FILENAME[0]) - 1; /* exclude the NULL */ + n = sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; /* exclude the NULL */ - for (i=0; i < n; i++) - if (h5_fixname(FILENAME[i],fapl,filenames[i],sizeof(filenames[i])) - == NULL){ - HDprintf("h5_fixname failed\n"); - nerrors++; - return(1); - } - HDprintf("Test filenames are:\n"); - for (i=0; i < n; i++) - HDprintf(" %s\n", filenames[i]); + for (i = 0; i < n; i++) + if (h5_fixname(FILENAME[i], fapl, filenames[i], sizeof(filenames[i])) == NULL) { + HDprintf("h5_fixname failed\n"); + nerrors++; + return (1); + } + HDprintf("Test filenames are:\n"); + for (i = 0; i < n; i++) + HDprintf(" %s\n", filenames[i]); } - return(0); + return (0); } - /* * Create the appropriate File access property list */ hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) { - hid_t ret_pl = -1; - herr_t ret; /* generic return value */ - int mpi_rank; /* mpi variables */ + hid_t ret_pl = -1; + herr_t ret; /* generic return value */ + int mpi_rank; /* mpi variables */ /* need the rank for error checking macros */ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - ret_pl = H5Pcreate (H5P_FILE_ACCESS); + ret_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY((ret_pl >= 0), "H5P_FILE_ACCESS"); if (l_facc_type == FACC_DEFAULT) - return (ret_pl); + return (ret_pl); - if (l_facc_type == FACC_MPIO){ - /* set Parallel access with communicator */ - ret = H5Pset_fapl_mpio(ret_pl, comm, info); - VRFY((ret >= 0), ""); + if (l_facc_type == FACC_MPIO) { + /* set Parallel access with communicator */ + ret = H5Pset_fapl_mpio(ret_pl, comm, info); + VRFY((ret >= 0), ""); ret = H5Pset_all_coll_metadata_ops(ret_pl, TRUE); - VRFY((ret >= 0), ""); + VRFY((ret >= 0), ""); ret = H5Pset_coll_metadata_write(ret_pl, TRUE); - VRFY((ret >= 0), ""); - return(ret_pl); + VRFY((ret >= 0), ""); + return (ret_pl); } - if (l_facc_type == (FACC_MPIO | FACC_SPLIT)){ - hid_t mpio_pl; - - mpio_pl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((mpio_pl >= 0), ""); - /* set Parallel access with communicator */ - ret = H5Pset_fapl_mpio(mpio_pl, comm, info); - VRFY((ret >= 0), ""); - - /* setup file access template */ - ret_pl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((ret_pl >= 0), ""); - /* set Parallel access with communicator */ - ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); - VRFY((ret >= 0), "H5Pset_fapl_split succeeded"); - H5Pclose(mpio_pl); - return(ret_pl); + if (l_facc_type == (FACC_MPIO | FACC_SPLIT)) { + hid_t mpio_pl; + + mpio_pl = H5Pcreate(H5P_FILE_ACCESS); + VRFY((mpio_pl >= 0), ""); + /* set Parallel access with communicator */ + ret = H5Pset_fapl_mpio(mpio_pl, comm, info); + VRFY((ret >= 0), ""); + + /* setup file access template */ + ret_pl = H5Pcreate(H5P_FILE_ACCESS); + VRFY((ret_pl >= 0), ""); + /* set Parallel access with communicator */ + ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); + VRFY((ret >= 0), "H5Pset_fapl_split succeeded"); + H5Pclose(mpio_pl); + return (ret_pl); } /* unknown file access types */ return (ret_pl); } - /* Shape Same test using contigous hyperslab using independent IO on contigous datasets */ static void sscontig1(void) @@ -4884,7 +4248,6 @@ sscontig4(void) contig_hs_dr_pio_test(COL_CHUNKED); } - /* Shape Same test using checker hyperslab using independent IO on contigous datasets */ static void sschecker1(void) @@ -4913,10 +4276,10 @@ sschecker4(void) ckrbrd_hs_dr_pio_test(COL_CHUNKED); } - -int main(int argc, char **argv) +int +main(int argc, char **argv) { - int mpi_size, mpi_rank; /* mpi variables */ + int mpi_size, mpi_rank; /* mpi variables */ #ifndef H5_HAVE_WIN32_API /* Un-buffer the stdout and stderr */ @@ -4928,14 +4291,14 @@ int main(int argc, char **argv) MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - dim0 = ROW_FACTOR*mpi_size; - dim1 = COL_FACTOR*mpi_size; + dim0 = ROW_FACTOR * mpi_size; + dim1 = COL_FACTOR * mpi_size; - if (MAINPROCESS){ - HDprintf("===================================\n"); - HDprintf("Shape Same Tests Start\n"); + if (MAINPROCESS) { + HDprintf("===================================\n"); + HDprintf("Shape Same Tests Start\n"); HDprintf(" express_test = %d.\n", GetTestExpress()); - HDprintf("===================================\n"); + HDprintf("===================================\n"); } /* Attempt to turn off atexit post processing so that in case errors @@ -4943,8 +4306,8 @@ int main(int argc, char **argv) * hang in the atexit post processing in which it may try to make MPI * calls. By then, MPI calls may not work. */ - if (H5dont_atexit() < 0){ - HDprintf("%d: Failed to turn off atexit processing. Continue.\n", mpi_rank); + if (H5dont_atexit() < 0) { + HDprintf("%d: Failed to turn off atexit processing. Continue.\n", mpi_rank); }; H5open(); h5_show_hostname(); @@ -4953,42 +4316,33 @@ int main(int argc, char **argv) TestInit(argv[0], usage, parse_options); /* Shape Same tests using contigous hyperslab */ - AddTest("sscontig1", sscontig1, NULL, - "Cntg hslab, ind IO, cntg dsets", PARATESTFILE); - AddTest("sscontig2", sscontig2, NULL, - "Cntg hslab, col IO, cntg dsets", PARATESTFILE); - AddTest("sscontig3", sscontig3, NULL, - "Cntg hslab, ind IO, chnk dsets", PARATESTFILE); - AddTest("sscontig4", sscontig4, NULL, - "Cntg hslab, col IO, chnk dsets", PARATESTFILE); + AddTest("sscontig1", sscontig1, NULL, "Cntg hslab, ind IO, cntg dsets", PARATESTFILE); + AddTest("sscontig2", sscontig2, NULL, "Cntg hslab, col IO, cntg dsets", PARATESTFILE); + AddTest("sscontig3", sscontig3, NULL, "Cntg hslab, ind IO, chnk dsets", PARATESTFILE); + AddTest("sscontig4", sscontig4, NULL, "Cntg hslab, col IO, chnk dsets", PARATESTFILE); /* Shape Same tests using checker board hyperslab */ - AddTest("sschecker1", sschecker1, NULL, - "Check hslab, ind IO, cntg dsets", PARATESTFILE); - AddTest("sschecker2", sschecker2, NULL, - "Check hslab, col IO, cntg dsets", PARATESTFILE); - AddTest("sschecker3", sschecker3, NULL, - "Check hslab, ind IO, chnk dsets", PARATESTFILE); - AddTest("sschecker4", sschecker4, NULL, - "Check hslab, col IO, chnk dsets", PARATESTFILE); + AddTest("sschecker1", sschecker1, NULL, "Check hslab, ind IO, cntg dsets", PARATESTFILE); + AddTest("sschecker2", sschecker2, NULL, "Check hslab, col IO, cntg dsets", PARATESTFILE); + AddTest("sschecker3", sschecker3, NULL, "Check hslab, ind IO, chnk dsets", PARATESTFILE); + AddTest("sschecker4", sschecker4, NULL, "Check hslab, col IO, chnk dsets", PARATESTFILE); /* Display testing information */ TestInfo(argv[0]); /* setup file access property list */ - fapl = H5Pcreate (H5P_FILE_ACCESS); + fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL); /* Parse command line arguments */ TestParseCmdLine(argc, argv); - if (dxfer_coll_type == DXFER_INDEPENDENT_IO && MAINPROCESS){ - HDprintf("===================================\n" - " Using Independent I/O with file set view to replace collective I/O \n" - "===================================\n"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO && MAINPROCESS) { + HDprintf("===================================\n" + " Using Independent I/O with file set view to replace collective I/O \n" + "===================================\n"); } - /* Perform requested testing */ PerformTests(); @@ -5010,16 +4364,16 @@ int main(int argc, char **argv) { int temp; MPI_Allreduce(&nerrors, &temp, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); - nerrors=temp; + nerrors = temp; } - if (MAINPROCESS){ /* only process 0 reports */ - HDprintf("===================================\n"); - if (nerrors) - HDprintf("***Shape Same tests detected %d errors***\n", nerrors); - else - HDprintf("Shape Same tests finished with no errors\n"); - HDprintf("===================================\n"); + if (MAINPROCESS) { /* only process 0 reports */ + HDprintf("===================================\n"); + if (nerrors) + HDprintf("***Shape Same tests detected %d errors***\n", nerrors); + else + HDprintf("Shape Same tests finished with no errors\n"); + HDprintf("===================================\n"); } /* close HDF5 library */ @@ -5031,6 +4385,5 @@ int main(int argc, char **argv) MPI_Finalize(); /* cannot just return (nerrors) because exit code is limited to 1byte */ - return(nerrors!=0); + return (nerrors != 0); } - diff --git a/testpar/t_span_tree.c b/testpar/t_span_tree.c index 8d2b61c..cb5c01a 100644 --- a/testpar/t_span_tree.c +++ b/testpar/t_span_tree.c @@ -35,11 +35,9 @@ #include "H5private.h" #include "testphdf5.h" - static void coll_write_test(int chunk_factor); static void coll_read_test(void); - /*------------------------------------------------------------------------- * Function: coll_irregular_cont_write * @@ -59,12 +57,9 @@ void coll_irregular_cont_write(void) { - coll_write_test(0); - + coll_write_test(0); } - - /*------------------------------------------------------------------------- * Function: coll_irregular_cont_read * @@ -84,11 +79,9 @@ void coll_irregular_cont_read(void) { - coll_read_test(); - + coll_read_test(); } - /*------------------------------------------------------------------------- * Function: coll_irregular_simple_chunk_write * @@ -108,12 +101,9 @@ void coll_irregular_simple_chunk_write(void) { - coll_write_test(1); - + coll_write_test(1); } - - /*------------------------------------------------------------------------- * Function: coll_irregular_simple_chunk_read * @@ -133,8 +123,7 @@ void coll_irregular_simple_chunk_read(void) { - coll_read_test(); - + coll_read_test(); } /*------------------------------------------------------------------------- @@ -156,12 +145,9 @@ void coll_irregular_complex_chunk_write(void) { - coll_write_test(4); - + coll_write_test(4); } - - /*------------------------------------------------------------------------- * Function: coll_irregular_complex_chunk_read * @@ -181,11 +167,9 @@ void coll_irregular_complex_chunk_read(void) { - coll_read_test(); - + coll_read_test(); } - /*------------------------------------------------------------------------- * Function: coll_write_test * @@ -202,447 +186,445 @@ coll_irregular_complex_chunk_read(void) * *------------------------------------------------------------------------- */ -void coll_write_test(int chunk_factor) +void +coll_write_test(int chunk_factor) { - const char *filename; - hid_t facc_plist,dxfer_plist,dcrt_plist; - hid_t file, datasetc,dataseti; /* File and dataset identifiers */ - hid_t mspaceid1, mspaceid, fspaceid,fspaceid1; /* Dataspace identifiers */ - - hsize_t mdim1[1]; /* Dimension size of the first dataset (in memory) */ - hsize_t fsdim[2]; /* Dimension sizes of the dataset (on disk) */ - hsize_t mdim[2]; /* Dimension sizes of the dataset in memory when we - * read selection from the dataset on the disk - */ - - hsize_t start[2]; /* Start of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Block count */ - hsize_t block[2]; /* Block sizes */ - hsize_t chunk_dims[2]; - - herr_t ret; - int i; - int fillvalue = 0; /* Fill value for the dataset */ - - int *matrix_out = NULL; - int *matrix_out1 = NULL; /* Buffer to read from the dataset */ - int *vector = NULL; - - int mpi_size,mpi_rank; - - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - - /*set up MPI parameters */ - MPI_Comm_size(comm,&mpi_size); - MPI_Comm_rank(comm,&mpi_rank); - - /* Obtain file name */ - filename = GetTestParameters(); - - /* - * Buffers' initialization. - */ - - mdim1[0] = (hsize_t)(MSPACE1_DIM*mpi_size); - mdim[0] = MSPACE_DIM1; - mdim[1] = (hsize_t)(MSPACE_DIM2*mpi_size); - fsdim[0] = FSPACE_DIM1; - fsdim[1] = (hsize_t)(FSPACE_DIM2*mpi_size); - - vector = (int*)HDmalloc(sizeof(int)*(size_t)mdim1[0]*(size_t)mpi_size); - matrix_out = (int*)HDmalloc(sizeof(int)*(size_t)mdim[0]*(size_t)mdim[1]*(size_t)mpi_size); - matrix_out1 = (int*)HDmalloc(sizeof(int)*(size_t)mdim[0]*(size_t)mdim[1]*(size_t)mpi_size); - - HDmemset(vector,0,sizeof(int)*(size_t)mdim1[0]*(size_t)mpi_size); - vector[0] = vector[MSPACE1_DIM*mpi_size - 1] = -1; - for (i = 1; i < MSPACE1_DIM*mpi_size - 1; i++) H5_CHECKED_ASSIGN(vector[i], int, i, unsigned); - - /* Grab file access property list */ - facc_plist = create_faccess_plist(comm, info, facc_type); - VRFY((facc_plist >= 0),""); - - /* - * Create a file. - */ - file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, facc_plist); - VRFY((file >= 0),"H5Fcreate succeeded"); - - /* - * Create property list for a dataset and set up fill values. - */ - dcrt_plist = H5Pcreate(H5P_DATASET_CREATE); - VRFY((dcrt_plist >= 0),""); - - ret = H5Pset_fill_value(dcrt_plist, H5T_NATIVE_INT, &fillvalue); - VRFY((ret >= 0),"Fill value creation property list succeeded"); - - if(chunk_factor != 0) { - chunk_dims[0] = fsdim[0] / (hsize_t)chunk_factor; - chunk_dims[1] = fsdim[1] / (hsize_t)chunk_factor; - ret = H5Pset_chunk(dcrt_plist, 2, chunk_dims); - VRFY((ret >= 0),"chunk creation property list succeeded"); - } - - /* - * - * Create dataspace for the first dataset in the disk. - * dim1 = 9 - * dim2 = 3600 - * - * - */ - fspaceid = H5Screate_simple(FSPACE_RANK, fsdim, NULL); - VRFY((fspaceid >= 0),"file dataspace created succeeded"); - - /* - * Create dataset in the file. Notice that creation - * property list dcrt_plist is used. - */ - datasetc = H5Dcreate2(file, "collect_write", H5T_NATIVE_INT, fspaceid, H5P_DEFAULT, dcrt_plist, H5P_DEFAULT); - VRFY((datasetc >= 0),"dataset created succeeded"); - - dataseti = H5Dcreate2(file, "independ_write", H5T_NATIVE_INT, fspaceid, H5P_DEFAULT, dcrt_plist, H5P_DEFAULT); - VRFY((dataseti >= 0),"dataset created succeeded"); - - /* The First selection for FILE - * - * block (3,2) - * stride(4,3) - * count (1,768/mpi_size) - * start (0,1+768*3*mpi_rank/mpi_size) - * - */ - - start[0] = FHSTART0; - start[1] = (hsize_t)(FHSTART1 + mpi_rank * FHSTRIDE1 * FHCOUNT1); - stride[0] = FHSTRIDE0; - stride[1] = FHSTRIDE1; - count[0] = FHCOUNT0; - count[1] = FHCOUNT1; - block[0] = FHBLOCK0; - block[1] = FHBLOCK1; - - ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* The Second selection for FILE - * - * block (3,768) - * stride (1,1) - * count (1,1) - * start (4,768*mpi_rank/mpi_size) - * - */ - - start[0] = SHSTART0; - start[1] = (hsize_t)(SHSTART1+SHCOUNT1*SHBLOCK1*mpi_rank); - stride[0] = SHSTRIDE0; - stride[1] = SHSTRIDE1; - count[0] = SHCOUNT0; - count[1] = SHCOUNT1; - block[0] = SHBLOCK0; - block[1] = SHBLOCK1; - - ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_OR, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* - * Create dataspace for the first dataset in the memory - * dim1 = 27000 - * - */ - mspaceid1 = H5Screate_simple(MSPACE1_RANK, mdim1, NULL); - VRFY((mspaceid1 >= 0),"memory dataspace created succeeded"); - - /* - * Memory space is 1-D, this is a good test to check - * whether a span-tree derived datatype needs to be built. - * block 1 - * stride 1 - * count 6912/mpi_size - * start 1 - * - */ - start[0] = MHSTART0; - stride[0] = MHSTRIDE0; - count[0] = MHCOUNT0; - block[0] = MHBLOCK0; - - ret = H5Sselect_hyperslab(mspaceid1, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* independent write */ - ret = H5Dwrite(dataseti, H5T_NATIVE_INT, mspaceid1, fspaceid, H5P_DEFAULT, vector); - VRFY((ret >= 0),"dataset independent write succeed"); - - dxfer_plist = H5Pcreate(H5P_DATASET_XFER); - VRFY((dxfer_plist >= 0),""); - - ret = H5Pset_dxpl_mpio(dxfer_plist, H5FD_MPIO_COLLECTIVE); - VRFY((ret >= 0),"MPIO data transfer property list succeed"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(dxfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); - } - - - /* collective write */ - ret = H5Dwrite(datasetc, H5T_NATIVE_INT, mspaceid1, fspaceid, dxfer_plist, vector); - VRFY((ret >= 0),"dataset collective write succeed"); - - ret = H5Sclose(mspaceid1); - VRFY((ret >= 0),""); - - ret = H5Sclose(fspaceid); - VRFY((ret >= 0),""); - - /* - * Close dataset. - */ - ret = H5Dclose(datasetc); - VRFY((ret >= 0),""); - - ret = H5Dclose(dataseti); - VRFY((ret >= 0),""); - - /* - * Close the file. - */ - ret = H5Fclose(file); - VRFY((ret >= 0),""); - /* - * Close property list - */ - - ret = H5Pclose(facc_plist); - VRFY((ret >= 0),""); - ret = H5Pclose(dxfer_plist); - VRFY((ret >= 0),""); - ret = H5Pclose(dcrt_plist); - VRFY((ret >= 0),""); - - /* - * Open the file. - */ - - /*** - - For testing collective hyperslab selection write - In this test, we are using independent read to check - the correctedness of collective write compared with - independent write, - - In order to throughly test this feature, we choose - a different selection set for reading the data out. - - - ***/ - - /* Obtain file access property list with MPI-IO driver */ - facc_plist = create_faccess_plist(comm, info, facc_type); - VRFY((facc_plist >= 0),""); - - file = H5Fopen(filename, H5F_ACC_RDONLY, facc_plist); - VRFY((file >= 0),"H5Fopen succeeded"); - - /* - * Open the dataset. - */ - datasetc = H5Dopen2(file,"collect_write", H5P_DEFAULT); - VRFY((datasetc >= 0),"H5Dopen2 succeeded"); - - dataseti = H5Dopen2(file,"independ_write", H5P_DEFAULT); - VRFY((dataseti >= 0),"H5Dopen2 succeeded"); - - /* - * Get dataspace of the open dataset. - */ - fspaceid = H5Dget_space(datasetc); - VRFY((fspaceid >= 0),"file dataspace obtained succeeded"); - - fspaceid1 = H5Dget_space(dataseti); - VRFY((fspaceid1 >= 0),"file dataspace obtained succeeded"); - - - /* The First selection for FILE to read - * - * block (1,1) - * stride(1.1) - * count (3,768/mpi_size) - * start (1,2+768*mpi_rank/mpi_size) - * - */ - start[0] = RFFHSTART0; - start[1] = (hsize_t)(RFFHSTART1+mpi_rank*RFFHCOUNT1); - block[0] = RFFHBLOCK0; - block[1] = RFFHBLOCK1; - stride[0] = RFFHSTRIDE0; - stride[1] = RFFHSTRIDE1; - count[0] = RFFHCOUNT0; - count[1] = RFFHCOUNT1; - - - /* The first selection of the dataset generated by collective write */ - ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* The first selection of the dataset generated by independent write */ - ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* The Second selection for FILE to read - * - * block (1,1) - * stride(1.1) - * count (3,1536/mpi_size) - * start (2,4+1536*mpi_rank/mpi_size) - * - */ - - start[0] = RFSHSTART0; - start[1] = (hsize_t)(RFSHSTART1+RFSHCOUNT1*mpi_rank); - block[0] = RFSHBLOCK0; - block[1] = RFSHBLOCK1; - stride[0] = RFSHSTRIDE0; - stride[1] = RFSHSTRIDE0; - count[0] = RFSHCOUNT0; - count[1] = RFSHCOUNT1; - - /* The second selection of the dataset generated by collective write */ - ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_OR, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* The second selection of the dataset generated by independent write */ - ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_OR, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* - * Create memory dataspace. - * rank = 2 - * mdim1 = 9 - * mdim2 = 3600 - * - */ - mspaceid = H5Screate_simple(MSPACE_RANK, mdim, NULL); - - /* - * Select two hyperslabs in memory. Hyperslabs has the same - * size and shape as the selected hyperslabs for the file dataspace - * Only the starting point is different. - * The first selection - * block (1,1) - * stride(1.1) - * count (3,768/mpi_size) - * start (0,768*mpi_rank/mpi_size) - * - */ - - - start[0] = RMFHSTART0; - start[1] = (hsize_t)(RMFHSTART1+mpi_rank*RMFHCOUNT1); - block[0] = RMFHBLOCK0; - block[1] = RMFHBLOCK1; - stride[0] = RMFHSTRIDE0; - stride[1] = RMFHSTRIDE1; - count[0] = RMFHCOUNT0; - count[1] = RMFHCOUNT1; - - ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* - * Select two hyperslabs in memory. Hyperslabs has the same - * size and shape as the selected hyperslabs for the file dataspace - * Only the starting point is different. - * The second selection - * block (1,1) - * stride(1,1) - * count (3,1536/mpi_size) - * start (1,2+1536*mpi_rank/mpi_size) - * - */ - start[0] = RMSHSTART0; - start[1] = (hsize_t)(RMSHSTART1+mpi_rank*RMSHCOUNT1); - block[0] = RMSHBLOCK0; - block[1] = RMSHBLOCK1; - stride[0] = RMSHSTRIDE0; - stride[1] = RMSHSTRIDE1; - count[0] = RMSHCOUNT0; - count[1] = RMSHCOUNT1; - - ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_OR, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* - * Initialize data buffer. - */ - - HDmemset(matrix_out,0,sizeof(int)*(size_t)MSPACE_DIM1*(size_t)MSPACE_DIM2*(size_t)mpi_size); - HDmemset(matrix_out1,0,sizeof(int)*(size_t)MSPACE_DIM1*(size_t)MSPACE_DIM2*(size_t)mpi_size); - /* - * Read data back to the buffer matrix_out. - */ - - ret = H5Dread(datasetc, H5T_NATIVE_INT, mspaceid, fspaceid, - H5P_DEFAULT, matrix_out); - VRFY((ret >= 0),"H5D independent read succeed"); - - - ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid, - H5P_DEFAULT, matrix_out1); - VRFY((ret >= 0),"H5D independent read succeed"); - - ret = 0; - - for (i = 0; i < MSPACE_DIM1*MSPACE_DIM2*mpi_size; i++){ - if(matrix_out[i]!=matrix_out1[i]) ret = -1; - if(ret < 0) break; + const char *filename; + hid_t facc_plist, dxfer_plist, dcrt_plist; + hid_t file, datasetc, dataseti; /* File and dataset identifiers */ + hid_t mspaceid1, mspaceid, fspaceid, fspaceid1; /* Dataspace identifiers */ + + hsize_t mdim1[1]; /* Dimension size of the first dataset (in memory) */ + hsize_t fsdim[2]; /* Dimension sizes of the dataset (on disk) */ + hsize_t mdim[2]; /* Dimension sizes of the dataset in memory when we + * read selection from the dataset on the disk + */ + + hsize_t start[2]; /* Start of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Block count */ + hsize_t block[2]; /* Block sizes */ + hsize_t chunk_dims[2]; + + herr_t ret; + int i; + int fillvalue = 0; /* Fill value for the dataset */ + + int *matrix_out = NULL; + int *matrix_out1 = NULL; /* Buffer to read from the dataset */ + int *vector = NULL; + + int mpi_size, mpi_rank; + + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + /*set up MPI parameters */ + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); + + /* Obtain file name */ + filename = GetTestParameters(); + + /* + * Buffers' initialization. + */ + + mdim1[0] = (hsize_t)(MSPACE1_DIM * mpi_size); + mdim[0] = MSPACE_DIM1; + mdim[1] = (hsize_t)(MSPACE_DIM2 * mpi_size); + fsdim[0] = FSPACE_DIM1; + fsdim[1] = (hsize_t)(FSPACE_DIM2 * mpi_size); + + vector = (int *)HDmalloc(sizeof(int) * (size_t)mdim1[0] * (size_t)mpi_size); + matrix_out = (int *)HDmalloc(sizeof(int) * (size_t)mdim[0] * (size_t)mdim[1] * (size_t)mpi_size); + matrix_out1 = (int *)HDmalloc(sizeof(int) * (size_t)mdim[0] * (size_t)mdim[1] * (size_t)mpi_size); + + HDmemset(vector, 0, sizeof(int) * (size_t)mdim1[0] * (size_t)mpi_size); + vector[0] = vector[MSPACE1_DIM * mpi_size - 1] = -1; + for (i = 1; i < MSPACE1_DIM * mpi_size - 1; i++) + H5_CHECKED_ASSIGN(vector[i], int, i, unsigned); + + /* Grab file access property list */ + facc_plist = create_faccess_plist(comm, info, facc_type); + VRFY((facc_plist >= 0), ""); + + /* + * Create a file. + */ + file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, facc_plist); + VRFY((file >= 0), "H5Fcreate succeeded"); + + /* + * Create property list for a dataset and set up fill values. + */ + dcrt_plist = H5Pcreate(H5P_DATASET_CREATE); + VRFY((dcrt_plist >= 0), ""); + + ret = H5Pset_fill_value(dcrt_plist, H5T_NATIVE_INT, &fillvalue); + VRFY((ret >= 0), "Fill value creation property list succeeded"); + + if (chunk_factor != 0) { + chunk_dims[0] = fsdim[0] / (hsize_t)chunk_factor; + chunk_dims[1] = fsdim[1] / (hsize_t)chunk_factor; + ret = H5Pset_chunk(dcrt_plist, 2, chunk_dims); + VRFY((ret >= 0), "chunk creation property list succeeded"); } - VRFY((ret >= 0),"H5D irregular collective write succeed"); + /* + * + * Create dataspace for the first dataset in the disk. + * dim1 = 9 + * dim2 = 3600 + * + * + */ + fspaceid = H5Screate_simple(FSPACE_RANK, fsdim, NULL); + VRFY((fspaceid >= 0), "file dataspace created succeeded"); - /* - * Close memory file and memory dataspaces. - */ - ret = H5Sclose(mspaceid); - VRFY((ret >= 0),""); - ret = H5Sclose(fspaceid); - VRFY((ret >= 0),""); + /* + * Create dataset in the file. Notice that creation + * property list dcrt_plist is used. + */ + datasetc = + H5Dcreate2(file, "collect_write", H5T_NATIVE_INT, fspaceid, H5P_DEFAULT, dcrt_plist, H5P_DEFAULT); + VRFY((datasetc >= 0), "dataset created succeeded"); - /* - * Close dataset. - */ - ret = H5Dclose(dataseti); - VRFY((ret >= 0),""); + dataseti = + H5Dcreate2(file, "independ_write", H5T_NATIVE_INT, fspaceid, H5P_DEFAULT, dcrt_plist, H5P_DEFAULT); + VRFY((dataseti >= 0), "dataset created succeeded"); - ret = H5Dclose(datasetc); - VRFY((ret >= 0),""); + /* The First selection for FILE + * + * block (3,2) + * stride(4,3) + * count (1,768/mpi_size) + * start (0,1+768*3*mpi_rank/mpi_size) + * + */ + + start[0] = FHSTART0; + start[1] = (hsize_t)(FHSTART1 + mpi_rank * FHSTRIDE1 * FHCOUNT1); + stride[0] = FHSTRIDE0; + stride[1] = FHSTRIDE1; + count[0] = FHCOUNT0; + count[1] = FHCOUNT1; + block[0] = FHBLOCK0; + block[1] = FHBLOCK1; - /* - * Close property list - */ + ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); - ret = H5Pclose(facc_plist); - VRFY((ret >= 0),""); + /* The Second selection for FILE + * + * block (3,768) + * stride (1,1) + * count (1,1) + * start (4,768*mpi_rank/mpi_size) + * + */ + start[0] = SHSTART0; + start[1] = (hsize_t)(SHSTART1 + SHCOUNT1 * SHBLOCK1 * mpi_rank); + stride[0] = SHSTRIDE0; + stride[1] = SHSTRIDE1; + count[0] = SHCOUNT0; + count[1] = SHCOUNT1; + block[0] = SHBLOCK0; + block[1] = SHBLOCK1; + + ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* + * Create dataspace for the first dataset in the memory + * dim1 = 27000 + * + */ + mspaceid1 = H5Screate_simple(MSPACE1_RANK, mdim1, NULL); + VRFY((mspaceid1 >= 0), "memory dataspace created succeeded"); + + /* + * Memory space is 1-D, this is a good test to check + * whether a span-tree derived datatype needs to be built. + * block 1 + * stride 1 + * count 6912/mpi_size + * start 1 + * + */ + start[0] = MHSTART0; + stride[0] = MHSTRIDE0; + count[0] = MHCOUNT0; + block[0] = MHBLOCK0; + + ret = H5Sselect_hyperslab(mspaceid1, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* independent write */ + ret = H5Dwrite(dataseti, H5T_NATIVE_INT, mspaceid1, fspaceid, H5P_DEFAULT, vector); + VRFY((ret >= 0), "dataset independent write succeed"); + + dxfer_plist = H5Pcreate(H5P_DATASET_XFER); + VRFY((dxfer_plist >= 0), ""); + + ret = H5Pset_dxpl_mpio(dxfer_plist, H5FD_MPIO_COLLECTIVE); + VRFY((ret >= 0), "MPIO data transfer property list succeed"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(dxfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); + } + + /* collective write */ + ret = H5Dwrite(datasetc, H5T_NATIVE_INT, mspaceid1, fspaceid, dxfer_plist, vector); + VRFY((ret >= 0), "dataset collective write succeed"); + + ret = H5Sclose(mspaceid1); + VRFY((ret >= 0), ""); + + ret = H5Sclose(fspaceid); + VRFY((ret >= 0), ""); + + /* + * Close dataset. + */ + ret = H5Dclose(datasetc); + VRFY((ret >= 0), ""); + + ret = H5Dclose(dataseti); + VRFY((ret >= 0), ""); + + /* + * Close the file. + */ + ret = H5Fclose(file); + VRFY((ret >= 0), ""); + /* + * Close property list + */ + + ret = H5Pclose(facc_plist); + VRFY((ret >= 0), ""); + ret = H5Pclose(dxfer_plist); + VRFY((ret >= 0), ""); + ret = H5Pclose(dcrt_plist); + VRFY((ret >= 0), ""); + + /* + * Open the file. + */ - /* - * Close the file. - */ - ret = H5Fclose(file); - VRFY((ret >= 0),""); + /*** - if (vector) - HDfree(vector); - if (matrix_out) - HDfree(matrix_out); - if (matrix_out1) - HDfree(matrix_out1); + For testing collective hyperslab selection write + In this test, we are using independent read to check + the correctedness of collective write compared with + independent write, - return ; + In order to throughly test this feature, we choose + a different selection set for reading the data out. + + + ***/ + + /* Obtain file access property list with MPI-IO driver */ + facc_plist = create_faccess_plist(comm, info, facc_type); + VRFY((facc_plist >= 0), ""); + + file = H5Fopen(filename, H5F_ACC_RDONLY, facc_plist); + VRFY((file >= 0), "H5Fopen succeeded"); + + /* + * Open the dataset. + */ + datasetc = H5Dopen2(file, "collect_write", H5P_DEFAULT); + VRFY((datasetc >= 0), "H5Dopen2 succeeded"); + + dataseti = H5Dopen2(file, "independ_write", H5P_DEFAULT); + VRFY((dataseti >= 0), "H5Dopen2 succeeded"); + + /* + * Get dataspace of the open dataset. + */ + fspaceid = H5Dget_space(datasetc); + VRFY((fspaceid >= 0), "file dataspace obtained succeeded"); + + fspaceid1 = H5Dget_space(dataseti); + VRFY((fspaceid1 >= 0), "file dataspace obtained succeeded"); + + /* The First selection for FILE to read + * + * block (1,1) + * stride(1.1) + * count (3,768/mpi_size) + * start (1,2+768*mpi_rank/mpi_size) + * + */ + start[0] = RFFHSTART0; + start[1] = (hsize_t)(RFFHSTART1 + mpi_rank * RFFHCOUNT1); + block[0] = RFFHBLOCK0; + block[1] = RFFHBLOCK1; + stride[0] = RFFHSTRIDE0; + stride[1] = RFFHSTRIDE1; + count[0] = RFFHCOUNT0; + count[1] = RFFHCOUNT1; + + /* The first selection of the dataset generated by collective write */ + ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* The first selection of the dataset generated by independent write */ + ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* The Second selection for FILE to read + * + * block (1,1) + * stride(1.1) + * count (3,1536/mpi_size) + * start (2,4+1536*mpi_rank/mpi_size) + * + */ + + start[0] = RFSHSTART0; + start[1] = (hsize_t)(RFSHSTART1 + RFSHCOUNT1 * mpi_rank); + block[0] = RFSHBLOCK0; + block[1] = RFSHBLOCK1; + stride[0] = RFSHSTRIDE0; + stride[1] = RFSHSTRIDE0; + count[0] = RFSHCOUNT0; + count[1] = RFSHCOUNT1; + + /* The second selection of the dataset generated by collective write */ + ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* The second selection of the dataset generated by independent write */ + ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* + * Create memory dataspace. + * rank = 2 + * mdim1 = 9 + * mdim2 = 3600 + * + */ + mspaceid = H5Screate_simple(MSPACE_RANK, mdim, NULL); + + /* + * Select two hyperslabs in memory. Hyperslabs has the same + * size and shape as the selected hyperslabs for the file dataspace + * Only the starting point is different. + * The first selection + * block (1,1) + * stride(1.1) + * count (3,768/mpi_size) + * start (0,768*mpi_rank/mpi_size) + * + */ + + start[0] = RMFHSTART0; + start[1] = (hsize_t)(RMFHSTART1 + mpi_rank * RMFHCOUNT1); + block[0] = RMFHBLOCK0; + block[1] = RMFHBLOCK1; + stride[0] = RMFHSTRIDE0; + stride[1] = RMFHSTRIDE1; + count[0] = RMFHCOUNT0; + count[1] = RMFHCOUNT1; + + ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* + * Select two hyperslabs in memory. Hyperslabs has the same + * size and shape as the selected hyperslabs for the file dataspace + * Only the starting point is different. + * The second selection + * block (1,1) + * stride(1,1) + * count (3,1536/mpi_size) + * start (1,2+1536*mpi_rank/mpi_size) + * + */ + start[0] = RMSHSTART0; + start[1] = (hsize_t)(RMSHSTART1 + mpi_rank * RMSHCOUNT1); + block[0] = RMSHBLOCK0; + block[1] = RMSHBLOCK1; + stride[0] = RMSHSTRIDE0; + stride[1] = RMSHSTRIDE1; + count[0] = RMSHCOUNT0; + count[1] = RMSHCOUNT1; + + ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* + * Initialize data buffer. + */ + + HDmemset(matrix_out, 0, sizeof(int) * (size_t)MSPACE_DIM1 * (size_t)MSPACE_DIM2 * (size_t)mpi_size); + HDmemset(matrix_out1, 0, sizeof(int) * (size_t)MSPACE_DIM1 * (size_t)MSPACE_DIM2 * (size_t)mpi_size); + /* + * Read data back to the buffer matrix_out. + */ + + ret = H5Dread(datasetc, H5T_NATIVE_INT, mspaceid, fspaceid, H5P_DEFAULT, matrix_out); + VRFY((ret >= 0), "H5D independent read succeed"); + + ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid, H5P_DEFAULT, matrix_out1); + VRFY((ret >= 0), "H5D independent read succeed"); + + ret = 0; + + for (i = 0; i < MSPACE_DIM1 * MSPACE_DIM2 * mpi_size; i++) { + if (matrix_out[i] != matrix_out1[i]) + ret = -1; + if (ret < 0) + break; + } + + VRFY((ret >= 0), "H5D irregular collective write succeed"); + + /* + * Close memory file and memory dataspaces. + */ + ret = H5Sclose(mspaceid); + VRFY((ret >= 0), ""); + ret = H5Sclose(fspaceid); + VRFY((ret >= 0), ""); + + /* + * Close dataset. + */ + ret = H5Dclose(dataseti); + VRFY((ret >= 0), ""); + + ret = H5Dclose(datasetc); + VRFY((ret >= 0), ""); + + /* + * Close property list + */ + + ret = H5Pclose(facc_plist); + VRFY((ret >= 0), ""); + + /* + * Close the file. + */ + ret = H5Fclose(file); + VRFY((ret >= 0), ""); + + if (vector) + HDfree(vector); + if (matrix_out) + HDfree(matrix_out); + if (matrix_out1) + HDfree(matrix_out1); + + return; } /*------------------------------------------------------------------------- @@ -665,243 +647,235 @@ static void coll_read_test(void) { - const char *filename; - hid_t facc_plist,dxfer_plist; - hid_t file, dataseti; /* File and dataset identifiers */ - hid_t mspaceid, fspaceid1; /* Dataspace identifiers */ - - - /* Dimension sizes of the dataset (on disk) */ - hsize_t mdim[2]; /* Dimension sizes of the dataset in memory when we - * read selection from the dataset on the disk - */ - - hsize_t start[2]; /* Start of hyperslab */ - hsize_t stride[2]; /* Stride of hyperslab */ - hsize_t count[2]; /* Block count */ - hsize_t block[2]; /* Block sizes */ - herr_t ret; - - int i; - - int *matrix_out; - int *matrix_out1; /* Buffer to read from the dataset */ - - int mpi_size,mpi_rank; - - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; - - /*set up MPI parameters */ - MPI_Comm_size(comm,&mpi_size); - MPI_Comm_rank(comm,&mpi_rank); - - - /* Obtain file name */ - filename = GetTestParameters(); - - - /* Initialize the buffer */ - - mdim[0] = MSPACE_DIM1; - mdim[1] = (hsize_t)(MSPACE_DIM2*mpi_size); - matrix_out =(int*)HDmalloc(sizeof(int)*(size_t)MSPACE_DIM1*(size_t)MSPACE_DIM2*(size_t)mpi_size); - matrix_out1=(int*)HDmalloc(sizeof(int)*(size_t)MSPACE_DIM1*(size_t)MSPACE_DIM2*(size_t)mpi_size); - - /*** For testing collective hyperslab selection read ***/ - - /* Obtain file access property list */ - facc_plist = create_faccess_plist(comm, info, facc_type); - VRFY((facc_plist >= 0),""); - - /* - * Open the file. - */ - file = H5Fopen(filename, H5F_ACC_RDONLY, facc_plist); - VRFY((file >= 0),"H5Fopen succeeded"); - - /* - * Open the dataset. - */ - dataseti = H5Dopen2(file,"independ_write", H5P_DEFAULT); - VRFY((dataseti >= 0),"H5Dopen2 succeeded"); - - /* - * Get dataspace of the open dataset. - */ - fspaceid1 = H5Dget_space(dataseti); - VRFY((fspaceid1 >= 0),"file dataspace obtained succeeded"); - - /* The First selection for FILE to read - * - * block (1,1) - * stride(1.1) - * count (3,768/mpi_size) - * start (1,2+768*mpi_rank/mpi_size) - * - */ - start[0] = RFFHSTART0; - start[1] = (hsize_t)(RFFHSTART1+mpi_rank*RFFHCOUNT1); - block[0] = RFFHBLOCK0; - block[1] = RFFHBLOCK1; - stride[0] = RFFHSTRIDE0; - stride[1] = RFFHSTRIDE1; - count[0] = RFFHCOUNT0; - count[1] = RFFHCOUNT1; - - ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* The Second selection for FILE to read - * - * block (1,1) - * stride(1.1) - * count (3,1536/mpi_size) - * start (2,4+1536*mpi_rank/mpi_size) - * - */ - start[0] = RFSHSTART0; - start[1] = (hsize_t)(RFSHSTART1+RFSHCOUNT1*mpi_rank); - block[0] = RFSHBLOCK0; - block[1] = RFSHBLOCK1; - stride[0] = RFSHSTRIDE0; - stride[1] = RFSHSTRIDE0; - count[0] = RFSHCOUNT0; - count[1] = RFSHCOUNT1; - - ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_OR, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - - /* - * Create memory dataspace. - */ - mspaceid = H5Screate_simple(MSPACE_RANK, mdim, NULL); - - /* - * Select two hyperslabs in memory. Hyperslabs has the same - * size and shape as the selected hyperslabs for the file dataspace. - * Only the starting point is different. - * The first selection - * block (1,1) - * stride(1.1) - * count (3,768/mpi_size) - * start (0,768*mpi_rank/mpi_size) - * - */ - - start[0] = RMFHSTART0; - start[1] = (hsize_t)(RMFHSTART1+mpi_rank*RMFHCOUNT1); - block[0] = RMFHBLOCK0; - block[1] = RMFHBLOCK1; - stride[0] = RMFHSTRIDE0; - stride[1] = RMFHSTRIDE1; - count[0] = RMFHCOUNT0; - count[1] = RMFHCOUNT1; - ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - /* - * Select two hyperslabs in memory. Hyperslabs has the same - * size and shape as the selected hyperslabs for the file dataspace - * Only the starting point is different. - * The second selection - * block (1,1) - * stride(1,1) - * count (3,1536/mpi_size) - * start (1,2+1536*mpi_rank/mpi_size) - * - */ - start[0] = RMSHSTART0; - start[1] = (hsize_t)(RMSHSTART1+mpi_rank*RMSHCOUNT1); - block[0] = RMSHBLOCK0; - block[1] = RMSHBLOCK1; - stride[0] = RMSHSTRIDE0; - stride[1] = RMSHSTRIDE1; - count[0] = RMSHCOUNT0; - count[1] = RMSHCOUNT1; - ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_OR, start, stride, count, block); - VRFY((ret >= 0),"hyperslab selection succeeded"); - - - /* - * Initialize data buffer. - */ - - HDmemset(matrix_out,0,sizeof(int)*(size_t)MSPACE_DIM1*(size_t)MSPACE_DIM2*(size_t)mpi_size); - HDmemset(matrix_out1,0,sizeof(int)*(size_t)MSPACE_DIM1*(size_t)MSPACE_DIM2*(size_t)mpi_size); - - /* - * Read data back to the buffer matrix_out. - */ - - dxfer_plist = H5Pcreate(H5P_DATASET_XFER); - VRFY((dxfer_plist >= 0),""); - - ret = H5Pset_dxpl_mpio(dxfer_plist, H5FD_MPIO_COLLECTIVE); - VRFY((ret >= 0),"MPIO data transfer property list succeed"); - if(dxfer_coll_type == DXFER_INDEPENDENT_IO) { - ret = H5Pset_dxpl_mpio_collective_opt(dxfer_plist,H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0),"set independent IO collectively succeeded"); - } - - - /* Collective read */ - ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid1, - dxfer_plist, matrix_out); - VRFY((ret >= 0),"H5D collecive read succeed"); - - ret = H5Pclose(dxfer_plist); - VRFY((ret >= 0),""); - - /* Independent read */ - ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid1, - H5P_DEFAULT, matrix_out1); - VRFY((ret >= 0),"H5D independent read succeed"); - - ret = 0; - for (i = 0; i < MSPACE_DIM1*MSPACE_DIM2*mpi_size; i++){ - if(matrix_out[i]!=matrix_out1[i])ret = -1; - if(ret < 0) break; - } - VRFY((ret >= 0),"H5D contiguous irregular collective read succeed"); - - /* - * Free read buffers. - */ - HDfree(matrix_out); - HDfree(matrix_out1); - - /* - * Close memory file and memory dataspaces. - */ - ret = H5Sclose(mspaceid); - VRFY((ret >= 0),""); - ret = H5Sclose(fspaceid1); - VRFY((ret >= 0),""); - - /* - * Close dataset. - */ - ret = H5Dclose(dataseti); - VRFY((ret >= 0),""); - - /* - * Close property list - */ - ret = H5Pclose(facc_plist); - VRFY((ret >= 0),""); - - - /* - * Close the file. - */ - ret = H5Fclose(file); - VRFY((ret >= 0),""); - - return; -} + const char *filename; + hid_t facc_plist, dxfer_plist; + hid_t file, dataseti; /* File and dataset identifiers */ + hid_t mspaceid, fspaceid1; /* Dataspace identifiers */ + + /* Dimension sizes of the dataset (on disk) */ + hsize_t mdim[2]; /* Dimension sizes of the dataset in memory when we + * read selection from the dataset on the disk + */ + + hsize_t start[2]; /* Start of hyperslab */ + hsize_t stride[2]; /* Stride of hyperslab */ + hsize_t count[2]; /* Block count */ + hsize_t block[2]; /* Block sizes */ + herr_t ret; + + int i; + + int *matrix_out; + int *matrix_out1; /* Buffer to read from the dataset */ + + int mpi_size, mpi_rank; + + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + /*set up MPI parameters */ + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); + + /* Obtain file name */ + filename = GetTestParameters(); + + /* Initialize the buffer */ + + mdim[0] = MSPACE_DIM1; + mdim[1] = (hsize_t)(MSPACE_DIM2 * mpi_size); + matrix_out = (int *)HDmalloc(sizeof(int) * (size_t)MSPACE_DIM1 * (size_t)MSPACE_DIM2 * (size_t)mpi_size); + matrix_out1 = (int *)HDmalloc(sizeof(int) * (size_t)MSPACE_DIM1 * (size_t)MSPACE_DIM2 * (size_t)mpi_size); + + /*** For testing collective hyperslab selection read ***/ + + /* Obtain file access property list */ + facc_plist = create_faccess_plist(comm, info, facc_type); + VRFY((facc_plist >= 0), ""); + + /* + * Open the file. + */ + file = H5Fopen(filename, H5F_ACC_RDONLY, facc_plist); + VRFY((file >= 0), "H5Fopen succeeded"); + + /* + * Open the dataset. + */ + dataseti = H5Dopen2(file, "independ_write", H5P_DEFAULT); + VRFY((dataseti >= 0), "H5Dopen2 succeeded"); + + /* + * Get dataspace of the open dataset. + */ + fspaceid1 = H5Dget_space(dataseti); + VRFY((fspaceid1 >= 0), "file dataspace obtained succeeded"); + + /* The First selection for FILE to read + * + * block (1,1) + * stride(1.1) + * count (3,768/mpi_size) + * start (1,2+768*mpi_rank/mpi_size) + * + */ + start[0] = RFFHSTART0; + start[1] = (hsize_t)(RFFHSTART1 + mpi_rank * RFFHCOUNT1); + block[0] = RFFHBLOCK0; + block[1] = RFFHBLOCK1; + stride[0] = RFFHSTRIDE0; + stride[1] = RFFHSTRIDE1; + count[0] = RFFHCOUNT0; + count[1] = RFFHCOUNT1; + + ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* The Second selection for FILE to read + * + * block (1,1) + * stride(1.1) + * count (3,1536/mpi_size) + * start (2,4+1536*mpi_rank/mpi_size) + * + */ + start[0] = RFSHSTART0; + start[1] = (hsize_t)(RFSHSTART1 + RFSHCOUNT1 * mpi_rank); + block[0] = RFSHBLOCK0; + block[1] = RFSHBLOCK1; + stride[0] = RFSHSTRIDE0; + stride[1] = RFSHSTRIDE0; + count[0] = RFSHCOUNT0; + count[1] = RFSHCOUNT1; + + ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* + * Create memory dataspace. + */ + mspaceid = H5Screate_simple(MSPACE_RANK, mdim, NULL); + + /* + * Select two hyperslabs in memory. Hyperslabs has the same + * size and shape as the selected hyperslabs for the file dataspace. + * Only the starting point is different. + * The first selection + * block (1,1) + * stride(1.1) + * count (3,768/mpi_size) + * start (0,768*mpi_rank/mpi_size) + * + */ + + start[0] = RMFHSTART0; + start[1] = (hsize_t)(RMFHSTART1 + mpi_rank * RMFHCOUNT1); + block[0] = RMFHBLOCK0; + block[1] = RMFHBLOCK1; + stride[0] = RMFHSTRIDE0; + stride[1] = RMFHSTRIDE1; + count[0] = RMFHCOUNT0; + count[1] = RMFHCOUNT1; + ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_SET, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* + * Select two hyperslabs in memory. Hyperslabs has the same + * size and shape as the selected hyperslabs for the file dataspace + * Only the starting point is different. + * The second selection + * block (1,1) + * stride(1,1) + * count (3,1536/mpi_size) + * start (1,2+1536*mpi_rank/mpi_size) + * + */ + start[0] = RMSHSTART0; + start[1] = (hsize_t)(RMSHSTART1 + mpi_rank * RMSHCOUNT1); + block[0] = RMSHBLOCK0; + block[1] = RMSHBLOCK1; + stride[0] = RMSHSTRIDE0; + stride[1] = RMSHSTRIDE1; + count[0] = RMSHCOUNT0; + count[1] = RMSHCOUNT1; + ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "hyperslab selection succeeded"); + + /* + * Initialize data buffer. + */ + + HDmemset(matrix_out, 0, sizeof(int) * (size_t)MSPACE_DIM1 * (size_t)MSPACE_DIM2 * (size_t)mpi_size); + HDmemset(matrix_out1, 0, sizeof(int) * (size_t)MSPACE_DIM1 * (size_t)MSPACE_DIM2 * (size_t)mpi_size); + + /* + * Read data back to the buffer matrix_out. + */ + + dxfer_plist = H5Pcreate(H5P_DATASET_XFER); + VRFY((dxfer_plist >= 0), ""); + + ret = H5Pset_dxpl_mpio(dxfer_plist, H5FD_MPIO_COLLECTIVE); + VRFY((ret >= 0), "MPIO data transfer property list succeed"); + if (dxfer_coll_type == DXFER_INDEPENDENT_IO) { + ret = H5Pset_dxpl_mpio_collective_opt(dxfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "set independent IO collectively succeeded"); + } + + /* Collective read */ + ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid1, dxfer_plist, matrix_out); + VRFY((ret >= 0), "H5D collecive read succeed"); + ret = H5Pclose(dxfer_plist); + VRFY((ret >= 0), ""); + + /* Independent read */ + ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid1, H5P_DEFAULT, matrix_out1); + VRFY((ret >= 0), "H5D independent read succeed"); + + ret = 0; + for (i = 0; i < MSPACE_DIM1 * MSPACE_DIM2 * mpi_size; i++) { + if (matrix_out[i] != matrix_out1[i]) + ret = -1; + if (ret < 0) + break; + } + VRFY((ret >= 0), "H5D contiguous irregular collective read succeed"); + + /* + * Free read buffers. + */ + HDfree(matrix_out); + HDfree(matrix_out1); + + /* + * Close memory file and memory dataspaces. + */ + ret = H5Sclose(mspaceid); + VRFY((ret >= 0), ""); + ret = H5Sclose(fspaceid1); + VRFY((ret >= 0), ""); + + /* + * Close dataset. + */ + ret = H5Dclose(dataseti); + VRFY((ret >= 0), ""); + + /* + * Close property list + */ + ret = H5Pclose(facc_plist); + VRFY((ret >= 0), ""); + + /* + * Close the file. + */ + ret = H5Fclose(file); + VRFY((ret >= 0), ""); + + return; +} /**************************************************************** ** @@ -928,7 +902,7 @@ coll_read_test(void) ** ****************************************************************/ -#define LDSCT_DS_RANK 5 +#define LDSCT_DS_RANK 5 #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG #define LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK 0 #endif @@ -936,64 +910,54 @@ coll_read_test(void) #define LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG 0 static void -lower_dim_size_comp_test__select_checker_board( - const int mpi_rank, - const hid_t tgt_sid, - const int tgt_rank, - const hsize_t dims[LDSCT_DS_RANK], - const int checker_edge_size, - const int sel_rank, - hsize_t sel_start[]) +lower_dim_size_comp_test__select_checker_board(const int mpi_rank, const hid_t tgt_sid, const int tgt_rank, + const hsize_t dims[LDSCT_DS_RANK], const int checker_edge_size, + const int sel_rank, hsize_t sel_start[]) { #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG - const char * fcnName = - "lower_dim_size_comp_test__select_checker_board():"; + const char *fcnName = "lower_dim_size_comp_test__select_checker_board():"; #endif - hbool_t first_selection = TRUE; - int i, j, k, l, m; - int ds_offset; - int sel_offset; - const int test_max_rank = LDSCT_DS_RANK; /* must update code if */ - /* this changes */ - hsize_t base_count; - hsize_t offset_count; - hsize_t start[LDSCT_DS_RANK]; - hsize_t stride[LDSCT_DS_RANK]; - hsize_t count[LDSCT_DS_RANK]; - hsize_t block[LDSCT_DS_RANK]; - herr_t ret; /* Generic return value */ + hbool_t first_selection = TRUE; + int i, j, k, l, m; + int ds_offset; + int sel_offset; + const int test_max_rank = LDSCT_DS_RANK; /* must update code if */ + /* this changes */ + hsize_t base_count; + hsize_t offset_count; + hsize_t start[LDSCT_DS_RANK]; + hsize_t stride[LDSCT_DS_RANK]; + hsize_t count[LDSCT_DS_RANK]; + hsize_t block[LDSCT_DS_RANK]; + herr_t ret; /* Generic return value */ #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, - "%s:%d: dims/checker_edge_size = %d %d %d %d %d / %d\n", - fcnName, mpi_rank, (int)dims[0], (int)dims[1], (int)dims[2], - (int)dims[3], (int)dims[4], checker_edge_size); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: dims/checker_edge_size = %d %d %d %d %d / %d\n", fcnName, mpi_rank, + (int)dims[0], (int)dims[1], (int)dims[2], (int)dims[3], (int)dims[4], checker_edge_size); } #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */ - HDassert( 0 < checker_edge_size ); - HDassert( 0 < sel_rank ); - HDassert( sel_rank <= tgt_rank ); - HDassert( tgt_rank <= test_max_rank ); - HDassert( test_max_rank <= LDSCT_DS_RANK ); + HDassert(0 < checker_edge_size); + HDassert(0 < sel_rank); + HDassert(sel_rank <= tgt_rank); + HDassert(tgt_rank <= test_max_rank); + HDassert(test_max_rank <= LDSCT_DS_RANK); sel_offset = test_max_rank - sel_rank; - HDassert( sel_offset >= 0 ); + HDassert(sel_offset >= 0); ds_offset = test_max_rank - tgt_rank; - HDassert( ds_offset >= 0 ); - HDassert( ds_offset <= sel_offset ); + HDassert(ds_offset >= 0); + HDassert(ds_offset <= sel_offset); - HDassert( (hsize_t)checker_edge_size <= dims[sel_offset] ); - HDassert( dims[sel_offset] == 10 ); + HDassert((hsize_t)checker_edge_size <= dims[sel_offset]); + HDassert(dims[sel_offset] == 10); #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: sel_rank/sel_offset = %d/%d.\n", - fcnName, mpi_rank, sel_rank, sel_offset); - HDfprintf(stdout, "%s:%d: tgt_rank/ds_offset = %d/%d.\n", - fcnName, mpi_rank, tgt_rank, ds_offset); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: sel_rank/sel_offset = %d/%d.\n", fcnName, mpi_rank, sel_rank, sel_offset); + HDfprintf(stdout, "%s:%d: tgt_rank/ds_offset = %d/%d.\n", fcnName, mpi_rank, tgt_rank, ds_offset); } #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */ @@ -1012,25 +976,23 @@ lower_dim_size_comp_test__select_checker_board( base_count = dims[sel_offset] / (hsize_t)(checker_edge_size * 2); - if ( (dims[sel_rank] % (hsize_t)(checker_edge_size * 2)) > 0 ) { + if ((dims[sel_rank] % (hsize_t)(checker_edge_size * 2)) > 0) { base_count++; } offset_count = - (hsize_t)((dims[sel_offset] - (hsize_t)checker_edge_size) / - ((hsize_t)(checker_edge_size * 2))); + (hsize_t)((dims[sel_offset] - (hsize_t)checker_edge_size) / ((hsize_t)(checker_edge_size * 2))); - if ( ((dims[sel_rank] - (hsize_t)checker_edge_size) % - ((hsize_t)(checker_edge_size * 2))) > 0 ) { + if (((dims[sel_rank] - (hsize_t)checker_edge_size) % ((hsize_t)(checker_edge_size * 2))) > 0) { offset_count++; } #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: base_count/offset_count = %d/%d.\n", - fcnName, mpi_rank, base_count, offset_count); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: base_count/offset_count = %d/%d.\n", fcnName, mpi_rank, base_count, + offset_count); } #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */ @@ -1039,235 +1001,193 @@ lower_dim_size_comp_test__select_checker_board( * the checker board. */ i = 0; - while ( i < ds_offset ) { + while (i < ds_offset) { /* these values should never be used */ - start[i] = 0; + start[i] = 0; stride[i] = 0; - count[i] = 0; - block[i] = 0; + count[i] = 0; + block[i] = 0; i++; } - while ( i < sel_offset ) { + while (i < sel_offset) { - start[i] = sel_start[i]; + start[i] = sel_start[i]; stride[i] = 2 * dims[i]; - count[i] = 1; - block[i] = 1; + count[i] = 1; + block[i] = 1; i++; } - while ( i < test_max_rank ) { + while (i < test_max_rank) { stride[i] = (hsize_t)(2 * checker_edge_size); - block[i] = (hsize_t)checker_edge_size; + block[i] = (hsize_t)checker_edge_size; i++; } i = 0; do { - if ( 0 >= sel_offset ) { + if (0 >= sel_offset) { - if ( i == 0 ) { + if (i == 0) { start[0] = 0; count[0] = base_count; - - } else { + } + else { start[0] = (hsize_t)checker_edge_size; count[0] = offset_count; - } } j = 0; do { - if ( 1 >= sel_offset ) { + if (1 >= sel_offset) { - if ( j == 0 ) { + if (j == 0) { start[1] = 0; count[1] = base_count; - - } else { + } + else { start[1] = (hsize_t)checker_edge_size; count[1] = offset_count; - } } k = 0; do { - if ( 2 >= sel_offset ) { + if (2 >= sel_offset) { - if ( k == 0 ) { + if (k == 0) { start[2] = 0; count[2] = base_count; - - } else { + } + else { start[2] = (hsize_t)checker_edge_size; count[2] = offset_count; - } } l = 0; do { - if ( 3 >= sel_offset ) { + if (3 >= sel_offset) { - if ( l == 0 ) { + if (l == 0) { start[3] = 0; count[3] = base_count; - - } else { + } + else { start[3] = (hsize_t)checker_edge_size; count[3] = offset_count; - } } m = 0; do { - if ( 4 >= sel_offset ) { + if (4 >= sel_offset) { - if ( m == 0 ) { + if (m == 0) { start[4] = 0; count[4] = base_count; - - } else { + } + else { start[4] = (hsize_t)checker_edge_size; count[4] = offset_count; - } } - if ( ((i + j + k + l + m) % 2) == 0 ) { + if (((i + j + k + l + m) % 2) == 0) { #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG - if ( mpi_rank == - LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - - HDfprintf(stdout, - "%s%d: *** first_selection = %d ***\n", - fcnName, mpi_rank, (int)first_selection); - HDfprintf(stdout, - "%s:%d: i/j/k/l/m = %d/%d/%d/%d/%d\n", - fcnName, mpi_rank, i, j, k, l, m); - HDfprintf(stdout, - "%s:%d: start = %d %d %d %d %d.\n", - fcnName, mpi_rank, - (int)start[0], (int)start[1], - (int)start[2], (int)start[3], - (int)start[4]); - HDfprintf(stdout, - "%s:%d: stride = %d %d %d %d %d.\n", - fcnName, mpi_rank, - (int)stride[0], (int)stride[1], - (int)stride[2], (int)stride[3], - (int)stride[4]); - HDfprintf(stdout, - "%s:%d: count = %d %d %d %d %d.\n", - fcnName, mpi_rank, - (int)count[0], (int)count[1], - (int)count[2], (int)count[3], - (int)count[4]); - HDfprintf(stdout, - "%s:%d: block = %d %d %d %d %d.\n", - fcnName, mpi_rank, - (int)block[0], (int)block[1], - (int)block[2], (int)block[3], - (int)block[4]); - HDfprintf(stdout, - "%s:%d: n-cube extent dims = %d.\n", - fcnName, mpi_rank, - H5Sget_simple_extent_ndims(tgt_sid)); - HDfprintf(stdout, - "%s:%d: selection rank = %d.\n", - fcnName, mpi_rank, sel_rank); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + + HDfprintf(stdout, "%s%d: *** first_selection = %d ***\n", fcnName, mpi_rank, + (int)first_selection); + HDfprintf(stdout, "%s:%d: i/j/k/l/m = %d/%d/%d/%d/%d\n", fcnName, mpi_rank, i, + j, k, l, m); + HDfprintf(stdout, "%s:%d: start = %d %d %d %d %d.\n", fcnName, mpi_rank, + (int)start[0], (int)start[1], (int)start[2], (int)start[3], + (int)start[4]); + HDfprintf(stdout, "%s:%d: stride = %d %d %d %d %d.\n", fcnName, mpi_rank, + (int)stride[0], (int)stride[1], (int)stride[2], (int)stride[3], + (int)stride[4]); + HDfprintf(stdout, "%s:%d: count = %d %d %d %d %d.\n", fcnName, mpi_rank, + (int)count[0], (int)count[1], (int)count[2], (int)count[3], + (int)count[4]); + HDfprintf(stdout, "%s:%d: block = %d %d %d %d %d.\n", fcnName, mpi_rank, + (int)block[0], (int)block[1], (int)block[2], (int)block[3], + (int)block[4]); + HDfprintf(stdout, "%s:%d: n-cube extent dims = %d.\n", fcnName, mpi_rank, + H5Sget_simple_extent_ndims(tgt_sid)); + HDfprintf(stdout, "%s:%d: selection rank = %d.\n", fcnName, mpi_rank, + sel_rank); } #endif - if ( first_selection ) { + if (first_selection) { first_selection = FALSE; - ret = H5Sselect_hyperslab - ( - tgt_sid, - H5S_SELECT_SET, - &(start[ds_offset]), - &(stride[ds_offset]), - &(count[ds_offset]), - &(block[ds_offset]) - ); + ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_SET, &(start[ds_offset]), + &(stride[ds_offset]), &(count[ds_offset]), + &(block[ds_offset])); VRFY((ret != FAIL), "H5Sselect_hyperslab(SET) succeeded"); + } + else { - } else { - - ret = H5Sselect_hyperslab - ( - tgt_sid, - H5S_SELECT_OR, - &(start[ds_offset]), - &(stride[ds_offset]), - &(count[ds_offset]), - &(block[ds_offset]) - ); + ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_OR, &(start[ds_offset]), + &(stride[ds_offset]), &(count[ds_offset]), + &(block[ds_offset])); VRFY((ret != FAIL), "H5Sselect_hyperslab(OR) succeeded"); - } } m++; - } while ( ( m <= 1 ) && - ( 4 >= sel_offset ) ); + } while ((m <= 1) && (4 >= sel_offset)); l++; - } while ( ( l <= 1 ) && - ( 3 >= sel_offset ) ); + } while ((l <= 1) && (3 >= sel_offset)); k++; - } while ( ( k <= 1 ) && - ( 2 >= sel_offset ) ); + } while ((k <= 1) && (2 >= sel_offset)); j++; - } while ( ( j <= 1 ) && - ( 1 >= sel_offset ) ); - + } while ((j <= 1) && (1 >= sel_offset)); i++; - } while ( ( i <= 1 ) && - ( 0 >= sel_offset ) ); + } while ((i <= 1) && (0 >= sel_offset)); #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n", - fcnName, mpi_rank, (int)H5Sget_select_npoints(tgt_sid)); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n", fcnName, mpi_rank, + (int)H5Sget_select_npoints(tgt_sid)); } #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */ /* Clip the selection back to the dataspace proper. */ - for ( i = 0; i < test_max_rank; i++ ) { + for (i = 0; i < test_max_rank; i++) { start[i] = 0; stride[i] = dims[i]; @@ -1275,15 +1195,14 @@ lower_dim_size_comp_test__select_checker_board( block[i] = dims[i]; } - ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_AND, - start, stride, count, block); + ret = H5Sselect_hyperslab(tgt_sid, H5S_SELECT_AND, start, stride, count, block); VRFY((ret != FAIL), "H5Sselect_hyperslab(AND) succeeded"); #if LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n", - fcnName, mpi_rank, (int)H5Sget_select_npoints(tgt_sid)); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s%d: H5Sget_select_npoints(tgt_sid) = %d.\n", fcnName, mpi_rank, + (int)H5Sget_select_npoints(tgt_sid)); HDfprintf(stdout, "%s%d: done.\n", fcnName, mpi_rank); } #endif /* LOWER_DIM_SIZE_COMP_TEST__SELECT_CHECKER_BOARD__DEBUG */ @@ -1292,7 +1211,6 @@ lower_dim_size_comp_test__select_checker_board( } /* lower_dim_size_comp_test__select_checker_board() */ - /**************************************************************** ** ** lower_dim_size_comp_test__verify_data(): @@ -1352,138 +1270,123 @@ lower_dim_size_comp_test__select_checker_board( #define LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG 0 static hbool_t -lower_dim_size_comp_test__verify_data(uint32_t * buf_ptr, +lower_dim_size_comp_test__verify_data(uint32_t *buf_ptr, #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG const int mpi_rank, #endif /* LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG */ - const int rank, - const int edge_size, - const int checker_edge_size, - uint32_t first_expected_val, - hbool_t buf_starts_in_checker) + const int rank, const int edge_size, const int checker_edge_size, + uint32_t first_expected_val, hbool_t buf_starts_in_checker) { #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG - const char * fcnName = - "lower_dim_size_comp_test__verify_data():"; + const char *fcnName = "lower_dim_size_comp_test__verify_data():"; #endif - hbool_t good_data = TRUE; - hbool_t in_checker; - hbool_t start_in_checker[5]; - uint32_t expected_value; - uint32_t * val_ptr; - int i, j, k, l, m; /* to track position in n-cube */ - int v, w, x, y, z; /* to track position in checker */ + hbool_t good_data = TRUE; + hbool_t in_checker; + hbool_t start_in_checker[5]; + uint32_t expected_value; + uint32_t *val_ptr; + int i, j, k, l, m; /* to track position in n-cube */ + int v, w, x, y, z; /* to track position in checker */ const int test_max_rank = 5; /* code changes needed if this is increased */ - HDassert( buf_ptr != NULL ); - HDassert( 0 < rank ); - HDassert( rank <= test_max_rank ); - HDassert( edge_size >= 6 ); - HDassert( 0 < checker_edge_size ); - HDassert( checker_edge_size <= edge_size ); - HDassert( test_max_rank <= LDSCT_DS_RANK ); + HDassert(buf_ptr != NULL); + HDassert(0 < rank); + HDassert(rank <= test_max_rank); + HDassert(edge_size >= 6); + HDassert(0 < checker_edge_size); + HDassert(checker_edge_size <= edge_size); + HDassert(test_max_rank <= LDSCT_DS_RANK); #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { HDfprintf(stdout, "%s mpi_rank = %d.\n", fcnName, mpi_rank); HDfprintf(stdout, "%s rank = %d.\n", fcnName, rank); HDfprintf(stdout, "%s edge_size = %d.\n", fcnName, edge_size); - HDfprintf(stdout, "%s checker_edge_size = %d.\n", - fcnName, checker_edge_size); - HDfprintf(stdout, "%s first_expected_val = %d.\n", - fcnName, (int)first_expected_val); - HDfprintf(stdout, "%s starts_in_checker = %d.\n", - fcnName, (int)buf_starts_in_checker); + HDfprintf(stdout, "%s checker_edge_size = %d.\n", fcnName, checker_edge_size); + HDfprintf(stdout, "%s first_expected_val = %d.\n", fcnName, (int)first_expected_val); + HDfprintf(stdout, "%s starts_in_checker = %d.\n", fcnName, (int)buf_starts_in_checker); } #endif - val_ptr = buf_ptr; + val_ptr = buf_ptr; expected_value = first_expected_val; - i = 0; - v = 0; + i = 0; + v = 0; start_in_checker[0] = buf_starts_in_checker; - do - { - if ( v >= checker_edge_size ) { + do { + if (v >= checker_edge_size) { - start_in_checker[0] = ! start_in_checker[0]; - v = 0; + start_in_checker[0] = !start_in_checker[0]; + v = 0; } - j = 0; - w = 0; + j = 0; + w = 0; start_in_checker[1] = start_in_checker[0]; - do - { - if ( w >= checker_edge_size ) { + do { + if (w >= checker_edge_size) { - start_in_checker[1] = ! start_in_checker[1]; - w = 0; + start_in_checker[1] = !start_in_checker[1]; + w = 0; } - k = 0; - x = 0; + k = 0; + x = 0; start_in_checker[2] = start_in_checker[1]; - do - { - if ( x >= checker_edge_size ) { + do { + if (x >= checker_edge_size) { - start_in_checker[2] = ! start_in_checker[2]; - x = 0; + start_in_checker[2] = !start_in_checker[2]; + x = 0; } - l = 0; - y = 0; + l = 0; + y = 0; start_in_checker[3] = start_in_checker[2]; - do - { - if ( y >= checker_edge_size ) { + do { + if (y >= checker_edge_size) { - start_in_checker[3] = ! start_in_checker[3]; - y = 0; + start_in_checker[3] = !start_in_checker[3]; + y = 0; } m = 0; z = 0; #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG - if ( mpi_rank == - LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { HDfprintf(stdout, "%d, %d, %d, %d, %d:", i, j, k, l, m); } #endif in_checker = start_in_checker[3]; - do - { + do { #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG - if ( mpi_rank == - LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { HDfprintf(stdout, " %d", (int)(*val_ptr)); } #endif - if ( z >= checker_edge_size ) { + if (z >= checker_edge_size) { - in_checker = ! in_checker; - z = 0; + in_checker = !in_checker; + z = 0; } - if ( in_checker ) { + if (in_checker) { - if ( *val_ptr != expected_value ) { + if (*val_ptr != expected_value) { good_data = FALSE; } /* zero out buffer for re-use */ *val_ptr = 0; - - } else if ( *val_ptr != 0 ) { + } + else if (*val_ptr != 0) { good_data = FALSE; /* zero out buffer for re-use */ *val_ptr = 0; - } val_ptr++; @@ -1491,36 +1394,29 @@ lower_dim_size_comp_test__verify_data(uint32_t * buf_ptr, m++; z++; - } while ( ( rank >= (test_max_rank - 4) ) && - ( m < edge_size ) ); + } while ((rank >= (test_max_rank - 4)) && (m < edge_size)); #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG - if ( mpi_rank == - LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { HDfprintf(stdout, "\n"); } #endif l++; y++; - } while ( ( rank >= (test_max_rank - 3) ) && - ( l < edge_size ) ); + } while ((rank >= (test_max_rank - 3)) && (l < edge_size)); k++; x++; - } while ( ( rank >= (test_max_rank - 2) ) && - ( k < edge_size ) ); + } while ((rank >= (test_max_rank - 2)) && (k < edge_size)); j++; w++; - } while ( ( rank >= (test_max_rank - 1) ) && - ( j < edge_size ) ); + } while ((rank >= (test_max_rank - 1)) && (j < edge_size)); i++; v++; - } while ( ( rank >= test_max_rank ) && - ( i < edge_size ) ); + } while ((rank >= test_max_rank) && (i < edge_size)); - return(good_data); + return (good_data); } /* lower_dim_size_comp_test__verify_data() */ - /*------------------------------------------------------------------------- * Function: lower_dim_size_comp_test__run_test() * @@ -1535,103 +1431,97 @@ lower_dim_size_comp_test__verify_data(uint32_t * buf_ptr, *------------------------------------------------------------------------- */ -#define LDSCT_DS_RANK 5 +#define LDSCT_DS_RANK 5 #define LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG 0 static void -lower_dim_size_comp_test__run_test(const int chunk_edge_size, - const hbool_t use_collective_io, +lower_dim_size_comp_test__run_test(const int chunk_edge_size, const hbool_t use_collective_io, const hid_t dset_type) { #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - const char *fcnName = "lower_dim_size_comp_test__run_test()"; - int rank; - hsize_t dims[32]; - hsize_t max_dims[32]; + const char *fcnName = "lower_dim_size_comp_test__run_test()"; + int rank; + hsize_t dims[32]; + hsize_t max_dims[32]; #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - const char *filename; - hbool_t data_ok = FALSE; - hbool_t mis_match = FALSE; - int i; - int start_index; - int stop_index; - int mrc; - int mpi_rank; - int mpi_size; - MPI_Comm mpi_comm = MPI_COMM_NULL; - MPI_Info mpi_info = MPI_INFO_NULL; - hid_t fid; /* HDF5 file ID */ - hid_t acc_tpl; /* File access templates */ - hid_t xfer_plist = H5P_DEFAULT; - size_t small_ds_size; - size_t small_ds_slice_size; - size_t large_ds_size; + const char *filename; + hbool_t data_ok = FALSE; + hbool_t mis_match = FALSE; + int i; + int start_index; + int stop_index; + int mrc; + int mpi_rank; + int mpi_size; + MPI_Comm mpi_comm = MPI_COMM_NULL; + MPI_Info mpi_info = MPI_INFO_NULL; + hid_t fid; /* HDF5 file ID */ + hid_t acc_tpl; /* File access templates */ + hid_t xfer_plist = H5P_DEFAULT; + size_t small_ds_size; + size_t small_ds_slice_size; + size_t large_ds_size; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - size_t large_ds_slice_size; + size_t large_ds_slice_size; #endif - uint32_t expected_value; - uint32_t * small_ds_buf_0 = NULL; - uint32_t * small_ds_buf_1 = NULL; - uint32_t * large_ds_buf_0 = NULL; - uint32_t * large_ds_buf_1 = NULL; - uint32_t * ptr_0; - uint32_t * ptr_1; - hsize_t small_chunk_dims[LDSCT_DS_RANK]; - hsize_t large_chunk_dims[LDSCT_DS_RANK]; - hsize_t small_dims[LDSCT_DS_RANK]; - hsize_t large_dims[LDSCT_DS_RANK]; - hsize_t start[LDSCT_DS_RANK]; - hsize_t stride[LDSCT_DS_RANK]; - hsize_t count[LDSCT_DS_RANK]; - hsize_t block[LDSCT_DS_RANK]; - hsize_t small_sel_start[LDSCT_DS_RANK]; - hsize_t large_sel_start[LDSCT_DS_RANK]; - hid_t full_mem_small_ds_sid; - hid_t full_file_small_ds_sid; - hid_t mem_small_ds_sid; - hid_t file_small_ds_sid; - hid_t full_mem_large_ds_sid; - hid_t full_file_large_ds_sid; - hid_t mem_large_ds_sid; - hid_t file_large_ds_sid; - hid_t small_ds_dcpl_id = H5P_DEFAULT; - hid_t large_ds_dcpl_id = H5P_DEFAULT; - hid_t small_dataset; /* Dataset ID */ - hid_t large_dataset; /* Dataset ID */ - htri_t check; /* Shape comparison return value */ - herr_t ret; /* Generic return value */ + uint32_t expected_value; + uint32_t *small_ds_buf_0 = NULL; + uint32_t *small_ds_buf_1 = NULL; + uint32_t *large_ds_buf_0 = NULL; + uint32_t *large_ds_buf_1 = NULL; + uint32_t *ptr_0; + uint32_t *ptr_1; + hsize_t small_chunk_dims[LDSCT_DS_RANK]; + hsize_t large_chunk_dims[LDSCT_DS_RANK]; + hsize_t small_dims[LDSCT_DS_RANK]; + hsize_t large_dims[LDSCT_DS_RANK]; + hsize_t start[LDSCT_DS_RANK]; + hsize_t stride[LDSCT_DS_RANK]; + hsize_t count[LDSCT_DS_RANK]; + hsize_t block[LDSCT_DS_RANK]; + hsize_t small_sel_start[LDSCT_DS_RANK]; + hsize_t large_sel_start[LDSCT_DS_RANK]; + hid_t full_mem_small_ds_sid; + hid_t full_file_small_ds_sid; + hid_t mem_small_ds_sid; + hid_t file_small_ds_sid; + hid_t full_mem_large_ds_sid; + hid_t full_file_large_ds_sid; + hid_t mem_large_ds_sid; + hid_t file_large_ds_sid; + hid_t small_ds_dcpl_id = H5P_DEFAULT; + hid_t large_ds_dcpl_id = H5P_DEFAULT; + hid_t small_dataset; /* Dataset ID */ + hid_t large_dataset; /* Dataset ID */ + htri_t check; /* Shape comparison return value */ + herr_t ret; /* Generic return value */ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - HDassert( mpi_size >= 1 ); + HDassert(mpi_size >= 1); mpi_comm = MPI_COMM_WORLD; mpi_info = MPI_INFO_NULL; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: chunk_edge_size = %d.\n", - fcnName, mpi_rank, (int)chunk_edge_size); - HDfprintf(stdout, "%s:%d: use_collective_io = %d.\n", - fcnName, mpi_rank, (int)use_collective_io); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: chunk_edge_size = %d.\n", fcnName, mpi_rank, (int)chunk_edge_size); + HDfprintf(stdout, "%s:%d: use_collective_io = %d.\n", fcnName, mpi_rank, (int)use_collective_io); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - - small_ds_size = (size_t)((mpi_size + 1) * 1 * 1 * 10 * 10); - small_ds_slice_size = (size_t) ( 1 * 1 * 10 * 10); + small_ds_size = (size_t)((mpi_size + 1) * 1 * 1 * 10 * 10); + small_ds_slice_size = (size_t)(1 * 1 * 10 * 10); large_ds_size = (size_t)((mpi_size + 1) * 10 * 10 * 10 * 10); #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - large_ds_slice_size = (size_t) (10 * 10 * 10 * 10); + large_ds_slice_size = (size_t)(10 * 10 * 10 * 10); - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: small ds size / slice size = %d / %d.\n", - fcnName, mpi_rank, + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: small ds size / slice size = %d / %d.\n", fcnName, mpi_rank, (int)small_ds_size, (int)small_ds_slice_size); - HDfprintf(stdout, "%s:%d: large ds size / slice size = %d / %d.\n", - fcnName, mpi_rank, + HDfprintf(stdout, "%s:%d: large ds size / slice size = %d / %d.\n", fcnName, mpi_rank, (int)large_ds_size, (int)large_ds_slice_size); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ @@ -1649,13 +1539,12 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, large_ds_buf_1 = (uint32_t *)HDmalloc(sizeof(uint32_t) * large_ds_size); VRFY((large_ds_buf_1 != NULL), "malloc of large_ds_buf_1 succeeded"); - /* initialize the buffers */ ptr_0 = small_ds_buf_0; ptr_1 = small_ds_buf_1; - for ( i = 0; i < (int)small_ds_size; i++ ) { + for (i = 0; i < (int)small_ds_size; i++) { *ptr_0 = (uint32_t)i; *ptr_1 = 0; @@ -1667,7 +1556,7 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ptr_0 = large_ds_buf_0; ptr_1 = large_ds_buf_1; - for ( i = 0; i < (int)large_ds_size; i++ ) { + for (i = 0; i < (int)large_ds_size; i++) { *ptr_0 = (uint32_t)i; *ptr_1 = 0; @@ -1676,12 +1565,10 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ptr_1++; } - /* get the file name */ filename = (const char *)GetTestParameters(); - HDassert( filename != NULL ); - + HDassert(filename != NULL); /* ---------------------------------------- * CREATE AN HDF5 FILE WITH PARALLEL ACCESS @@ -1700,11 +1587,10 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose(acc_tpl) succeeded"); - /* setup dims: */ small_dims[0] = (hsize_t)(mpi_size + 1); - small_dims[1] = 1; - small_dims[2] = 1; + small_dims[1] = 1; + small_dims[2] = 1; small_dims[3] = 10; small_dims[4] = 10; @@ -1715,51 +1601,39 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, large_dims[4] = 10; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: small_dims[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)small_dims[0], (int)small_dims[1], - (int)small_dims[2], (int)small_dims[3], (int)small_dims[4]); - HDfprintf(stdout, "%s:%d: large_dims[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)large_dims[0], (int)large_dims[1], - (int)large_dims[2], (int)large_dims[3], (int)large_dims[4]); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: small_dims[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)small_dims[0], + (int)small_dims[1], (int)small_dims[2], (int)small_dims[3], (int)small_dims[4]); + HDfprintf(stdout, "%s:%d: large_dims[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)large_dims[0], + (int)large_dims[1], (int)large_dims[2], (int)large_dims[3], (int)large_dims[4]); } #endif /* create dataspaces */ full_mem_small_ds_sid = H5Screate_simple(5, small_dims, NULL); - VRFY((full_mem_small_ds_sid != 0), - "H5Screate_simple() full_mem_small_ds_sid succeeded"); + VRFY((full_mem_small_ds_sid != 0), "H5Screate_simple() full_mem_small_ds_sid succeeded"); full_file_small_ds_sid = H5Screate_simple(5, small_dims, NULL); - VRFY((full_file_small_ds_sid != 0), - "H5Screate_simple() full_file_small_ds_sid succeeded"); + VRFY((full_file_small_ds_sid != 0), "H5Screate_simple() full_file_small_ds_sid succeeded"); mem_small_ds_sid = H5Screate_simple(5, small_dims, NULL); - VRFY((mem_small_ds_sid != 0), - "H5Screate_simple() mem_small_ds_sid succeeded"); + VRFY((mem_small_ds_sid != 0), "H5Screate_simple() mem_small_ds_sid succeeded"); file_small_ds_sid = H5Screate_simple(5, small_dims, NULL); - VRFY((file_small_ds_sid != 0), - "H5Screate_simple() file_small_ds_sid succeeded"); - + VRFY((file_small_ds_sid != 0), "H5Screate_simple() file_small_ds_sid succeeded"); full_mem_large_ds_sid = H5Screate_simple(5, large_dims, NULL); - VRFY((full_mem_large_ds_sid != 0), - "H5Screate_simple() full_mem_large_ds_sid succeeded"); + VRFY((full_mem_large_ds_sid != 0), "H5Screate_simple() full_mem_large_ds_sid succeeded"); full_file_large_ds_sid = H5Screate_simple(5, large_dims, NULL); - VRFY((full_file_large_ds_sid != 0), - "H5Screate_simple() full_file_large_ds_sid succeeded"); + VRFY((full_file_large_ds_sid != 0), "H5Screate_simple() full_file_large_ds_sid succeeded"); mem_large_ds_sid = H5Screate_simple(5, large_dims, NULL); - VRFY((mem_large_ds_sid != 0), - "H5Screate_simple() mem_large_ds_sid succeeded"); + VRFY((mem_large_ds_sid != 0), "H5Screate_simple() mem_large_ds_sid succeeded"); file_large_ds_sid = H5Screate_simple(5, large_dims, NULL); - VRFY((file_large_ds_sid != 0), - "H5Screate_simple() file_large_ds_sid succeeded"); - + VRFY((file_large_ds_sid != 0), "H5Screate_simple() file_large_ds_sid succeeded"); /* Select the entire extent of the full small ds dataspaces */ ret = H5Sselect_all(full_mem_small_ds_sid); @@ -1768,7 +1642,6 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ret = H5Sselect_all(full_file_small_ds_sid); VRFY((ret != FAIL), "H5Sselect_all(full_file_small_ds_sid) succeeded"); - /* Select the entire extent of the full large ds dataspaces */ ret = H5Sselect_all(full_mem_large_ds_sid); VRFY((ret != FAIL), "H5Sselect_all(full_mem_large_ds_sid) succeeded"); @@ -1776,22 +1649,20 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ret = H5Sselect_all(full_file_large_ds_sid); VRFY((ret != FAIL), "H5Sselect_all(full_file_large_ds_sid) succeeded"); - /* if chunk edge size is greater than zero, set up the small and * large data set creation property lists to specify chunked * datasets. */ - if ( chunk_edge_size > 0 ) { + if (chunk_edge_size > 0) { small_chunk_dims[0] = (hsize_t)(1); small_chunk_dims[1] = small_chunk_dims[2] = (hsize_t)1; small_chunk_dims[3] = small_chunk_dims[4] = (hsize_t)chunk_edge_size; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: small chunk dims[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)small_chunk_dims[0], - (int)small_chunk_dims[1], (int)small_chunk_dims[2], + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: small chunk dims[] = %d %d %d %d %d\n", fcnName, mpi_rank, + (int)small_chunk_dims[0], (int)small_chunk_dims[1], (int)small_chunk_dims[2], (int)small_chunk_dims[3], (int)small_chunk_dims[4]); } #endif @@ -1806,15 +1677,13 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, VRFY((ret != FAIL), "H5Pset_chunk() small_ds_dcpl_id succeeded"); large_chunk_dims[0] = (hsize_t)(1); - large_chunk_dims[1] = large_chunk_dims[2] = - large_chunk_dims[3] = large_chunk_dims[4] = (hsize_t)chunk_edge_size; - + large_chunk_dims[1] = large_chunk_dims[2] = large_chunk_dims[3] = large_chunk_dims[4] = + (hsize_t)chunk_edge_size; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: large chunk dims[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)large_chunk_dims[0], - (int)large_chunk_dims[1], (int)large_chunk_dims[2], + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: large chunk dims[] = %d %d %d %d %d\n", fcnName, mpi_rank, + (int)large_chunk_dims[0], (int)large_chunk_dims[1], (int)large_chunk_dims[2], (int)large_chunk_dims[3], (int)large_chunk_dims[4]); } #endif @@ -1829,30 +1698,23 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, VRFY((ret != FAIL), "H5Pset_chunk() large_ds_dcpl_id succeeded"); } - /* create the small dataset */ - small_dataset = H5Dcreate2(fid, "small_dataset", dset_type, - file_small_ds_sid, H5P_DEFAULT, + small_dataset = H5Dcreate2(fid, "small_dataset", dset_type, file_small_ds_sid, H5P_DEFAULT, small_ds_dcpl_id, H5P_DEFAULT); VRFY((ret >= 0), "H5Dcreate2() small_dataset succeeded"); - /* create the large dataset */ - large_dataset = H5Dcreate2(fid, "large_dataset", dset_type, - file_large_ds_sid, H5P_DEFAULT, + large_dataset = H5Dcreate2(fid, "large_dataset", dset_type, file_large_ds_sid, H5P_DEFAULT, large_ds_dcpl_id, H5P_DEFAULT); VRFY((ret >= 0), "H5Dcreate2() large_dataset succeeded"); #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, - "%s:%d: small/large ds id = %d / %d.\n", - fcnName, mpi_rank, (int)small_dataset, + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: small/large ds id = %d / %d.\n", fcnName, mpi_rank, (int)small_dataset, (int)large_dataset); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - /* setup xfer property list */ xfer_plist = H5Pcreate(H5P_DATASET_XFER); VRFY((xfer_plist >= 0), "H5Pcreate(H5P_DATASET_XFER) succeeded"); @@ -1860,14 +1722,12 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); - if ( ! use_collective_io ) { + if (!use_collective_io) { - ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, - H5FD_MPIO_INDIVIDUAL_IO); - VRFY((ret>= 0), "H5Pset_dxpl_mpio_collective_opt() suceeded"); + ret = H5Pset_dxpl_mpio_collective_opt(xfer_plist, H5FD_MPIO_INDIVIDUAL_IO); + VRFY((ret >= 0), "H5Pset_dxpl_mpio_collective_opt() suceeded"); } - /* setup selection to write initial data to the small data sets */ start[0] = (hsize_t)(mpi_rank + 1); start[1] = start[2] = start[3] = start[4] = 0; @@ -1882,135 +1742,89 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, block[3] = block[4] = 10; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, - "%s:%d: settings for small data set initialization.\n", - fcnName, mpi_rank); - HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)start[0], (int)start[1], - (int)start[2], (int)start[3], (int)start[4]); - HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)stride[0], (int)stride[1], - (int)stride[2], (int)stride[3], (int)stride[4]); - HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)count[0], (int)count[1], - (int)count[2], (int)count[3], (int)count[4]); - HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)block[0], (int)block[1], - (int)block[2], (int)block[3], (int)block[4]); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: settings for small data set initialization.\n", fcnName, mpi_rank); + HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)start[0], + (int)start[1], (int)start[2], (int)start[3], (int)start[4]); + HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)stride[0], + (int)stride[1], (int)stride[2], (int)stride[3], (int)stride[4]); + HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)count[0], + (int)count[1], (int)count[2], (int)count[3], (int)count[4]); + HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)block[0], + (int)block[1], (int)block[2], (int)block[3], (int)block[4]); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ /* setup selections for writing initial data to the small data set */ - ret = H5Sselect_hyperslab(mem_small_ds_sid, - H5S_SELECT_SET, - start, - stride, - count, - block); + ret = H5Sselect_hyperslab(mem_small_ds_sid, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sselect_hyperslab(mem_small_ds_sid, set) suceeded"); - ret = H5Sselect_hyperslab(file_small_ds_sid, - H5S_SELECT_SET, - start, - stride, - count, - block); + ret = H5Sselect_hyperslab(file_small_ds_sid, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_small_ds_sid, set) suceeded"); - if ( MAINPROCESS ) { /* add an additional slice to the selections */ + if (MAINPROCESS) { /* add an additional slice to the selections */ start[0] = 0; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, - "%s:%d: added settings for main process.\n", - fcnName, mpi_rank); - HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)start[0], (int)start[1], - (int)start[2], (int)start[3], (int)start[4]); - HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)stride[0], (int)stride[1], - (int)stride[2], (int)stride[3], (int)stride[4]); - HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)count[0], (int)count[1], - (int)count[2], (int)count[3], (int)count[4]); - HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)block[0], (int)block[1], - (int)block[2], (int)block[3], (int)block[4]); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: added settings for main process.\n", fcnName, mpi_rank); + HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)start[0], + (int)start[1], (int)start[2], (int)start[3], (int)start[4]); + HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)stride[0], + (int)stride[1], (int)stride[2], (int)stride[3], (int)stride[4]); + HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)count[0], + (int)count[1], (int)count[2], (int)count[3], (int)count[4]); + HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)block[0], + (int)block[1], (int)block[2], (int)block[3], (int)block[4]); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - ret = H5Sselect_hyperslab(mem_small_ds_sid, - H5S_SELECT_OR, - start, - stride, - count, - block); - VRFY((ret>= 0), "H5Sselect_hyperslab(mem_small_ds_sid, or) suceeded"); - - ret = H5Sselect_hyperslab(file_small_ds_sid, - H5S_SELECT_OR, - start, - stride, - count, - block); - VRFY((ret>= 0), "H5Sselect_hyperslab(file_small_ds_sid, or) suceeded"); - } + ret = H5Sselect_hyperslab(mem_small_ds_sid, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "H5Sselect_hyperslab(mem_small_ds_sid, or) suceeded"); - check = H5Sselect_valid(mem_small_ds_sid); - VRFY((check == TRUE),"H5Sselect_valid(mem_small_ds_sid) returns TRUE"); + ret = H5Sselect_hyperslab(file_small_ds_sid, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "H5Sselect_hyperslab(file_small_ds_sid, or) suceeded"); + } - check = H5Sselect_valid(file_small_ds_sid); - VRFY((check == TRUE),"H5Sselect_valid(file_small_ds_sid) returns TRUE"); + check = H5Sselect_valid(mem_small_ds_sid); + VRFY((check == TRUE), "H5Sselect_valid(mem_small_ds_sid) returns TRUE"); + check = H5Sselect_valid(file_small_ds_sid); + VRFY((check == TRUE), "H5Sselect_valid(file_small_ds_sid) returns TRUE"); /* write the initial value of the small data set to file */ #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: writing init value of small ds to file.\n", - fcnName, mpi_rank); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: writing init value of small ds to file.\n", fcnName, mpi_rank); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - ret = H5Dwrite(small_dataset, - dset_type, - mem_small_ds_sid, - file_small_ds_sid, - xfer_plist, - small_ds_buf_0); + ret = H5Dwrite(small_dataset, dset_type, mem_small_ds_sid, file_small_ds_sid, xfer_plist, small_ds_buf_0); VRFY((ret >= 0), "H5Dwrite() small_dataset initial write succeeded"); - /* read the small data set back to verify that it contains the * expected data. Note that each process reads in the entire * data set and verifies it. */ - ret = H5Dread(small_dataset, - H5T_NATIVE_UINT32, - full_mem_small_ds_sid, - full_file_small_ds_sid, - xfer_plist, + ret = H5Dread(small_dataset, H5T_NATIVE_UINT32, full_mem_small_ds_sid, full_file_small_ds_sid, xfer_plist, small_ds_buf_1); VRFY((ret >= 0), "H5Dread() small_dataset initial read succeeded"); - /* sync with the other processes before checking data */ mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync after small dataset writes"); - + VRFY((mrc == MPI_SUCCESS), "Sync after small dataset writes"); /* verify that the correct data was written to the small data set, * and reset the buffer to zero in passing. */ expected_value = 0; - mis_match = FALSE; - ptr_1 = small_ds_buf_1; + mis_match = FALSE; + ptr_1 = small_ds_buf_1; i = 0; - for ( i = 0; i < (int)small_ds_size; i++ ) { + for (i = 0; i < (int)small_ds_size; i++) { - if ( *ptr_1 != expected_value ) { + if (*ptr_1 != expected_value) { mis_match = TRUE; } @@ -2020,9 +1834,7 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ptr_1++; expected_value++; } - VRFY( (mis_match == FALSE), "small ds init data good."); - - + VRFY((mis_match == FALSE), "small ds init data good."); /* setup selections for writing initial data to the large data set */ start[0] = (hsize_t)(mpi_rank + 1); @@ -2037,104 +1849,64 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, block[1] = block[2] = block[3] = block[4] = (hsize_t)10; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, - "%s:%d: settings for large data set initialization.\n", - fcnName, mpi_rank); - HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)start[0], (int)start[1], - (int)start[2], (int)start[3], (int)start[4]); - HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)stride[0], (int)stride[1], - (int)stride[2], (int)stride[3], (int)stride[4]); - HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)count[0], (int)count[1], - (int)count[2], (int)count[3], (int)count[4]); - HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)block[0], (int)block[1], - (int)block[2], (int)block[3], (int)block[4]); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: settings for large data set initialization.\n", fcnName, mpi_rank); + HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)start[0], + (int)start[1], (int)start[2], (int)start[3], (int)start[4]); + HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)stride[0], + (int)stride[1], (int)stride[2], (int)stride[3], (int)stride[4]); + HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)count[0], + (int)count[1], (int)count[2], (int)count[3], (int)count[4]); + HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)block[0], + (int)block[1], (int)block[2], (int)block[3], (int)block[4]); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - ret = H5Sselect_hyperslab(mem_large_ds_sid, - H5S_SELECT_SET, - start, - stride, - count, - block); + ret = H5Sselect_hyperslab(mem_large_ds_sid, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sselect_hyperslab(mem_large_ds_sid, set) suceeded"); - ret = H5Sselect_hyperslab(file_large_ds_sid, - H5S_SELECT_SET, - start, - stride, - count, - block); + ret = H5Sselect_hyperslab(file_large_ds_sid, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_large_ds_sid, set) suceeded"); #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, - "%s%d: H5Sget_select_npoints(mem_large_ds_sid) = %d.\n", - fcnName, mpi_rank, - (int)H5Sget_select_npoints(mem_large_ds_sid)); - HDfprintf(stdout, - "%s%d: H5Sget_select_npoints(file_large_ds_sid) = %d.\n", - fcnName, mpi_rank, - (int)H5Sget_select_npoints(file_large_ds_sid)); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s%d: H5Sget_select_npoints(mem_large_ds_sid) = %d.\n", fcnName, mpi_rank, + (int)H5Sget_select_npoints(mem_large_ds_sid)); + HDfprintf(stdout, "%s%d: H5Sget_select_npoints(file_large_ds_sid) = %d.\n", fcnName, mpi_rank, + (int)H5Sget_select_npoints(file_large_ds_sid)); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - if ( MAINPROCESS ) { /* add an additional slice to the selections */ + if (MAINPROCESS) { /* add an additional slice to the selections */ start[0] = (hsize_t)0; #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, - "%s:%d: added settings for main process.\n", - fcnName, mpi_rank); - HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)start[0], (int)start[1], - (int)start[2], (int)start[3], (int)start[4]); - HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)stride[0], (int)stride[1], - (int)stride[2], (int)stride[3], (int)stride[4]); - HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)count[0], (int)count[1], - (int)count[2], (int)count[3], (int)count[4]); - HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n", - fcnName, mpi_rank, (int)block[0], (int)block[1], - (int)block[2], (int)block[3], (int)block[4]); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: added settings for main process.\n", fcnName, mpi_rank); + HDfprintf(stdout, "%s:%d: start[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)start[0], + (int)start[1], (int)start[2], (int)start[3], (int)start[4]); + HDfprintf(stdout, "%s:%d: stride[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)stride[0], + (int)stride[1], (int)stride[2], (int)stride[3], (int)stride[4]); + HDfprintf(stdout, "%s:%d: count[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)count[0], + (int)count[1], (int)count[2], (int)count[3], (int)count[4]); + HDfprintf(stdout, "%s:%d: block[] = %d %d %d %d %d\n", fcnName, mpi_rank, (int)block[0], + (int)block[1], (int)block[2], (int)block[3], (int)block[4]); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - ret = H5Sselect_hyperslab(mem_large_ds_sid, - H5S_SELECT_OR, - start, - stride, - count, - block); - VRFY((ret>= 0), "H5Sselect_hyperslab(mem_large_ds_sid, or) suceeded"); - - ret = H5Sselect_hyperslab(file_large_ds_sid, - H5S_SELECT_OR, - start, - stride, - count, - block); - VRFY((ret>= 0), "H5Sselect_hyperslab(file_large_ds_sid, or) suceeded"); + ret = H5Sselect_hyperslab(mem_large_ds_sid, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "H5Sselect_hyperslab(mem_large_ds_sid, or) suceeded"); + + ret = H5Sselect_hyperslab(file_large_ds_sid, H5S_SELECT_OR, start, stride, count, block); + VRFY((ret >= 0), "H5Sselect_hyperslab(file_large_ds_sid, or) suceeded"); #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, - "%s%d: H5Sget_select_npoints(mem_large_ds_sid) = %d.\n", - fcnName, mpi_rank, - (int)H5Sget_select_npoints(mem_large_ds_sid)); - HDfprintf(stdout, - "%s%d: H5Sget_select_npoints(file_large_ds_sid) = %d.\n", - fcnName, mpi_rank, - (int)H5Sget_select_npoints(file_large_ds_sid)); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s%d: H5Sget_select_npoints(mem_large_ds_sid) = %d.\n", fcnName, mpi_rank, + (int)H5Sget_select_npoints(mem_large_ds_sid)); + HDfprintf(stdout, "%s%d: H5Sget_select_npoints(file_large_ds_sid) = %d.\n", fcnName, mpi_rank, + (int)H5Sget_select_npoints(file_large_ds_sid)); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ } @@ -2150,93 +1922,70 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, block[0] = (hsize_t)(mpi_size + 1); block[1] = block[2] = block[3] = block[4] = (hsize_t)10; - ret = H5Sselect_hyperslab(mem_large_ds_sid, H5S_SELECT_AND, - start, stride, count, block); - VRFY((ret != FAIL),"H5Sselect_hyperslab(mem_large_ds_sid, and) succeeded"); + ret = H5Sselect_hyperslab(mem_large_ds_sid, H5S_SELECT_AND, start, stride, count, block); + VRFY((ret != FAIL), "H5Sselect_hyperslab(mem_large_ds_sid, and) succeeded"); - ret = H5Sselect_hyperslab(file_large_ds_sid, H5S_SELECT_AND, - start, stride, count, block); - VRFY((ret != FAIL),"H5Sselect_hyperslab(file_large_ds_sid, and) succeeded"); + ret = H5Sselect_hyperslab(file_large_ds_sid, H5S_SELECT_AND, start, stride, count, block); + VRFY((ret != FAIL), "H5Sselect_hyperslab(file_large_ds_sid, and) succeeded"); #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { rank = H5Sget_simple_extent_dims(mem_large_ds_sid, dims, max_dims); - HDfprintf(stdout, - "%s:%d: mem_large_ds_sid dims[%d] = %d %d %d %d %d\n", - fcnName, mpi_rank, rank, (int)dims[0], (int)dims[1], - (int)dims[2], (int)dims[3], (int)dims[4]); + HDfprintf(stdout, "%s:%d: mem_large_ds_sid dims[%d] = %d %d %d %d %d\n", fcnName, mpi_rank, rank, + (int)dims[0], (int)dims[1], (int)dims[2], (int)dims[3], (int)dims[4]); rank = H5Sget_simple_extent_dims(file_large_ds_sid, dims, max_dims); - HDfprintf(stdout, - "%s:%d: file_large_ds_sid dims[%d] = %d %d %d %d %d\n", - fcnName, mpi_rank, rank, (int)dims[0], (int)dims[1], - (int)dims[2], (int)dims[3], (int)dims[4]); + HDfprintf(stdout, "%s:%d: file_large_ds_sid dims[%d] = %d %d %d %d %d\n", fcnName, mpi_rank, rank, + (int)dims[0], (int)dims[1], (int)dims[2], (int)dims[3], (int)dims[4]); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - check = H5Sselect_valid(mem_large_ds_sid); - VRFY((check == TRUE),"H5Sselect_valid(mem_large_ds_sid) returns TRUE"); - - check = H5Sselect_valid(file_large_ds_sid); - VRFY((check == TRUE),"H5Sselect_valid(file_large_ds_sid) returns TRUE"); + check = H5Sselect_valid(mem_large_ds_sid); + VRFY((check == TRUE), "H5Sselect_valid(mem_large_ds_sid) returns TRUE"); + check = H5Sselect_valid(file_large_ds_sid); + VRFY((check == TRUE), "H5Sselect_valid(file_large_ds_sid) returns TRUE"); /* write the initial value of the large data set to file */ #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: writing init value of large ds to file.\n", - fcnName, mpi_rank); - HDfprintf(stdout, - "%s:%d: large_dataset = %d.\n", - fcnName, mpi_rank, - (int)large_dataset); - HDfprintf(stdout, - "%s:%d: mem_large_ds_sid = %d, file_large_ds_sid = %d.\n", - fcnName, mpi_rank, + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: writing init value of large ds to file.\n", fcnName, mpi_rank); + HDfprintf(stdout, "%s:%d: large_dataset = %d.\n", fcnName, mpi_rank, (int)large_dataset); + HDfprintf(stdout, "%s:%d: mem_large_ds_sid = %d, file_large_ds_sid = %d.\n", fcnName, mpi_rank, (int)mem_large_ds_sid, (int)file_large_ds_sid); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ - ret = H5Dwrite(large_dataset, - dset_type, - mem_large_ds_sid, - file_large_ds_sid, - xfer_plist, - large_ds_buf_0); + ret = H5Dwrite(large_dataset, dset_type, mem_large_ds_sid, file_large_ds_sid, xfer_plist, large_ds_buf_0); - if ( ret < 0 ) H5Eprint2(H5E_DEFAULT, stderr); + if (ret < 0) + H5Eprint2(H5E_DEFAULT, stderr); VRFY((ret >= 0), "H5Dwrite() large_dataset initial write succeeded"); - /* sync with the other processes before checking data */ mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync after large dataset writes"); + VRFY((mrc == MPI_SUCCESS), "Sync after large dataset writes"); /* read the large data set back to verify that it contains the * expected data. Note that each process reads in the entire * data set. */ - ret = H5Dread(large_dataset, - H5T_NATIVE_UINT32, - full_mem_large_ds_sid, - full_file_large_ds_sid, - xfer_plist, + ret = H5Dread(large_dataset, H5T_NATIVE_UINT32, full_mem_large_ds_sid, full_file_large_ds_sid, xfer_plist, large_ds_buf_1); VRFY((ret >= 0), "H5Dread() large_dataset initial read succeeded"); - /* verify that the correct data was written to the large data set. * in passing, reset the buffer to zeros */ expected_value = 0; - mis_match = FALSE; - ptr_1 = large_ds_buf_1; + mis_match = FALSE; + ptr_1 = large_ds_buf_1; i = 0; - for ( i = 0; i < (int)large_ds_size; i++ ) { + for (i = 0; i < (int)large_ds_size; i++) { - if ( *ptr_1 != expected_value ) { + if (*ptr_1 != expected_value) { mis_match = TRUE; } @@ -2246,52 +1995,39 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ptr_1++; expected_value++; } - VRFY( (mis_match == FALSE), "large ds init data good."); + VRFY((mis_match == FALSE), "large ds init data good."); /***********************************/ /***** INITIALIZATION COMPLETE *****/ /***********************************/ - /* read a checkerboard selection of the process slice of the * small on disk data set into the process slice of the large * in memory data set, and verify the data read. */ small_sel_start[0] = (hsize_t)(mpi_rank + 1); - small_sel_start[1] = small_sel_start[2] = - small_sel_start[3] = small_sel_start[4] = 0; - - lower_dim_size_comp_test__select_checker_board(mpi_rank, - file_small_ds_sid, - /* tgt_rank = */ 5, - small_dims, - /* checker_edge_size = */ 3, - /* sel_rank */ 2, - small_sel_start); - - expected_value = (uint32_t) - ((small_sel_start[0] * small_dims[1] * small_dims[2] * - small_dims[3] * small_dims[4]) + - (small_sel_start[1] * small_dims[2] * small_dims[3] * - small_dims[4]) + - (small_sel_start[2] * small_dims[3] * small_dims[4]) + - (small_sel_start[3] * small_dims[4]) + - (small_sel_start[4])); + small_sel_start[1] = small_sel_start[2] = small_sel_start[3] = small_sel_start[4] = 0; + lower_dim_size_comp_test__select_checker_board(mpi_rank, file_small_ds_sid, + /* tgt_rank = */ 5, small_dims, + /* checker_edge_size = */ 3, + /* sel_rank */ 2, small_sel_start); + + expected_value = + (uint32_t)((small_sel_start[0] * small_dims[1] * small_dims[2] * small_dims[3] * small_dims[4]) + + (small_sel_start[1] * small_dims[2] * small_dims[3] * small_dims[4]) + + (small_sel_start[2] * small_dims[3] * small_dims[4]) + + (small_sel_start[3] * small_dims[4]) + (small_sel_start[4])); large_sel_start[0] = (hsize_t)(mpi_rank + 1); large_sel_start[1] = 5; large_sel_start[2] = large_sel_start[3] = large_sel_start[4] = 0; - lower_dim_size_comp_test__select_checker_board(mpi_rank, - mem_large_ds_sid, - /* tgt_rank = */ 5, - large_dims, - /* checker_edge_size = */ 3, - /* sel_rank = */ 2, - large_sel_start); - + lower_dim_size_comp_test__select_checker_board(mpi_rank, mem_large_ds_sid, + /* tgt_rank = */ 5, large_dims, + /* checker_edge_size = */ 3, + /* sel_rank = */ 2, large_sel_start); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -2299,18 +2035,13 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, check = H5Sselect_shape_same(mem_large_ds_sid, file_small_ds_sid); VRFY((check == TRUE), "H5Sselect_shape_same passed (1)"); - - ret = H5Dread(small_dataset, - H5T_NATIVE_UINT32, - mem_large_ds_sid, - file_small_ds_sid, - xfer_plist, + ret = H5Dread(small_dataset, H5T_NATIVE_UINT32, mem_large_ds_sid, file_small_ds_sid, xfer_plist, large_ds_buf_1); VRFY((ret >= 0), "H5Sread() slice from small ds succeeded."); #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { HDfprintf(stdout, "%s:%d: H5Dread() returns.\n", fcnName, mpi_rank); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ @@ -2319,28 +2050,25 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, data_ok = TRUE; - start_index = (int)((large_sel_start[0] * large_dims[1] * large_dims[2] * - large_dims[3] * large_dims[4]) + - (large_sel_start[1] * large_dims[2] * large_dims[3] * - large_dims[4]) + + start_index = (int)((large_sel_start[0] * large_dims[1] * large_dims[2] * large_dims[3] * large_dims[4]) + + (large_sel_start[1] * large_dims[2] * large_dims[3] * large_dims[4]) + (large_sel_start[2] * large_dims[3] * large_dims[4]) + - (large_sel_start[3] * large_dims[4]) + - (large_sel_start[4])); + (large_sel_start[3] * large_dims[4]) + (large_sel_start[4])); - stop_index = start_index + (int)small_ds_slice_size; + stop_index = start_index + (int)small_ds_slice_size; - HDassert( 0 <= start_index ); - HDassert( start_index < stop_index ); - HDassert( stop_index <= (int)large_ds_size ); + HDassert(0 <= start_index); + HDassert(start_index < stop_index); + HDassert(stop_index <= (int)large_ds_size); ptr_1 = large_ds_buf_1; - for ( i = 0; i < start_index; i++ ) { + for (i = 0; i < start_index; i++) { - if ( *ptr_1 != (uint32_t)0 ) { + if (*ptr_1 != (uint32_t)0) { data_ok = FALSE; - *ptr_1 = (uint32_t)0; + *ptr_1 = (uint32_t)0; } ptr_1++; @@ -2348,16 +2076,14 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, VRFY((data_ok == TRUE), "slice read from small ds data good(1)."); - data_ok = lower_dim_size_comp_test__verify_data(ptr_1, #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG - mpi_rank, + mpi_rank, #endif /* LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG */ - /* rank */ 2, - /* edge_size */ 10, - /* checker_edge_size */ 3, - expected_value, - /* buf_starts_in_checker */ TRUE); + /* rank */ 2, + /* edge_size */ 10, + /* checker_edge_size */ 3, expected_value, + /* buf_starts_in_checker */ TRUE); VRFY((data_ok == TRUE), "slice read from small ds data good(2)."); @@ -2365,13 +2091,12 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ptr_1 += small_ds_slice_size; + for (i = stop_index; i < (int)large_ds_size; i++) { - for ( i = stop_index; i < (int)large_ds_size; i++ ) { - - if ( *ptr_1 != (uint32_t)0 ) { + if (*ptr_1 != (uint32_t)0) { data_ok = FALSE; - *ptr_1 = (uint32_t)0; + *ptr_1 = (uint32_t)0; } ptr_1++; @@ -2379,39 +2104,27 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, VRFY((data_ok == TRUE), "slice read from small ds data good(3)."); - - - - /* read a checkerboard selection of a slice of the process slice of * the large on disk data set into the process slice of the small * in memory data set, and verify the data read. */ small_sel_start[0] = (hsize_t)(mpi_rank + 1); - small_sel_start[1] = small_sel_start[2] = - small_sel_start[3] = small_sel_start[4] = 0; + small_sel_start[1] = small_sel_start[2] = small_sel_start[3] = small_sel_start[4] = 0; - lower_dim_size_comp_test__select_checker_board(mpi_rank, - mem_small_ds_sid, - /* tgt_rank = */ 5, - small_dims, - /* checker_edge_size = */ 3, - /* sel_rank */ 2, - small_sel_start); + lower_dim_size_comp_test__select_checker_board(mpi_rank, mem_small_ds_sid, + /* tgt_rank = */ 5, small_dims, + /* checker_edge_size = */ 3, + /* sel_rank */ 2, small_sel_start); large_sel_start[0] = (hsize_t)(mpi_rank + 1); large_sel_start[1] = 5; large_sel_start[2] = large_sel_start[3] = large_sel_start[4] = 0; - lower_dim_size_comp_test__select_checker_board(mpi_rank, - file_large_ds_sid, - /* tgt_rank = */ 5, - large_dims, - /* checker_edge_size = */ 3, - /* sel_rank = */ 2, - large_sel_start); - + lower_dim_size_comp_test__select_checker_board(mpi_rank, file_large_ds_sid, + /* tgt_rank = */ 5, large_dims, + /* checker_edge_size = */ 3, + /* sel_rank = */ 2, large_sel_start); /* verify that H5Sselect_shape_same() reports the two * selections as having the same shape. @@ -2419,18 +2132,13 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, check = H5Sselect_shape_same(mem_small_ds_sid, file_large_ds_sid); VRFY((check == TRUE), "H5Sselect_shape_same passed (2)"); - - ret = H5Dread(large_dataset, - H5T_NATIVE_UINT32, - mem_small_ds_sid, - file_large_ds_sid, - xfer_plist, + ret = H5Dread(large_dataset, H5T_NATIVE_UINT32, mem_small_ds_sid, file_large_ds_sid, xfer_plist, small_ds_buf_1); VRFY((ret >= 0), "H5Sread() slice from large ds succeeded."); #if LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { HDfprintf(stdout, "%s:%d: H5Dread() returns.\n", fcnName, mpi_rank); } #endif /* LOWER_DIM_SIZE_COMP_TEST__RUN_TEST__DEBUG */ @@ -2439,31 +2147,28 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, data_ok = TRUE; - expected_value = (uint32_t) - ((large_sel_start[0] * large_dims[1] * large_dims[2] * - large_dims[3] * large_dims[4]) + - (large_sel_start[1] * large_dims[2] * large_dims[3] * - large_dims[4]) + - (large_sel_start[2] * large_dims[3] * large_dims[4]) + - (large_sel_start[3] * large_dims[4]) + - (large_sel_start[4])); + expected_value = + (uint32_t)((large_sel_start[0] * large_dims[1] * large_dims[2] * large_dims[3] * large_dims[4]) + + (large_sel_start[1] * large_dims[2] * large_dims[3] * large_dims[4]) + + (large_sel_start[2] * large_dims[3] * large_dims[4]) + + (large_sel_start[3] * large_dims[4]) + (large_sel_start[4])); start_index = (int)(mpi_rank + 1) * (int)small_ds_slice_size; - stop_index = start_index + (int)small_ds_slice_size; + stop_index = start_index + (int)small_ds_slice_size; - HDassert( 0 <= start_index ); - HDassert( start_index < stop_index ); - HDassert( stop_index <= (int)small_ds_size ); + HDassert(0 <= start_index); + HDassert(start_index < stop_index); + HDassert(stop_index <= (int)small_ds_size); ptr_1 = small_ds_buf_1; - for ( i = 0; i < start_index; i++ ) { + for (i = 0; i < start_index; i++) { - if ( *ptr_1 != (uint32_t)0 ) { + if (*ptr_1 != (uint32_t)0) { data_ok = FALSE; - *ptr_1 = (uint32_t)0; + *ptr_1 = (uint32_t)0; } ptr_1++; @@ -2471,15 +2176,13 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, VRFY((data_ok == TRUE), "slice read from large ds data good(1)."); - data_ok = lower_dim_size_comp_test__verify_data(ptr_1, #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG mpi_rank, #endif /* LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG */ /* rank */ 2, /* edge_size */ 10, - /* checker_edge_size */ 3, - expected_value, + /* checker_edge_size */ 3, expected_value, /* buf_starts_in_checker */ TRUE); VRFY((data_ok == TRUE), "slice read from large ds data good(2)."); @@ -2488,20 +2191,19 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ptr_1 += small_ds_slice_size; + for (i = stop_index; i < (int)small_ds_size; i++) { - for ( i = stop_index; i < (int)small_ds_size; i++ ) { - - if ( *ptr_1 != (uint32_t)0 ) { + if (*ptr_1 != (uint32_t)0) { #if LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG - if ( mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK ) { - HDfprintf(stdout, "%s:%d: unexpected value at index %d: %d.\n", - fcnName, mpi_rank, (int)i, (int)(*ptr_1)); + if (mpi_rank == LOWER_DIM_SIZE_COMP_TEST_DEBUG_TARGET_RANK) { + HDfprintf(stdout, "%s:%d: unexpected value at index %d: %d.\n", fcnName, mpi_rank, (int)i, + (int)(*ptr_1)); } #endif /* LOWER_DIM_SIZE_COMP_TEST__VERIFY_DATA__DEBUG */ data_ok = FALSE; - *ptr_1 = (uint32_t)0; + *ptr_1 = (uint32_t)0; } ptr_1++; @@ -2509,7 +2211,6 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, VRFY((data_ok == TRUE), "slice read from large ds data good(3)."); - /* Close dataspaces */ ret = H5Sclose(full_mem_small_ds_sid); VRFY((ret != FAIL), "H5Sclose(full_mem_small_ds_sid) succeeded"); @@ -2523,7 +2224,6 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ret = H5Sclose(file_small_ds_sid); VRFY((ret != FAIL), "H5Sclose(file_small_ds_sid) succeeded"); - ret = H5Sclose(full_mem_large_ds_sid); VRFY((ret != FAIL), "H5Sclose(full_mem_large_ds_sid) succeeded"); @@ -2536,7 +2236,6 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ret = H5Sclose(file_large_ds_sid); VRFY((ret != FAIL), "H5Sclose(file_large_ds_sid) succeeded"); - /* Close Datasets */ ret = H5Dclose(small_dataset); VRFY((ret != FAIL), "H5Dclose(small_dataset) succeeded"); @@ -2544,24 +2243,26 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, ret = H5Dclose(large_dataset); VRFY((ret != FAIL), "H5Dclose(large_dataset) succeeded"); - /* close the file collectively */ MESG("about to close file."); ret = H5Fclose(fid); VRFY((ret != FAIL), "file close succeeded"); /* Free memory buffers */ - if ( small_ds_buf_0 != NULL ) HDfree(small_ds_buf_0); - if ( small_ds_buf_1 != NULL ) HDfree(small_ds_buf_1); + if (small_ds_buf_0 != NULL) + HDfree(small_ds_buf_0); + if (small_ds_buf_1 != NULL) + HDfree(small_ds_buf_1); - if ( large_ds_buf_0 != NULL ) HDfree(large_ds_buf_0); - if ( large_ds_buf_1 != NULL ) HDfree(large_ds_buf_1); + if (large_ds_buf_0 != NULL) + HDfree(large_ds_buf_0); + if (large_ds_buf_1 != NULL) + HDfree(large_ds_buf_1); return; } /* lower_dim_size_comp_test__run_test() */ - /*------------------------------------------------------------------------- * Function: lower_dim_size_comp_test() * @@ -2580,26 +2281,21 @@ void lower_dim_size_comp_test(void) { /* const char *fcnName = "lower_dim_size_comp_test()"; */ - int chunk_edge_size = 0; - int use_collective_io; + int chunk_edge_size = 0; + int use_collective_io; HDcompile_assert(sizeof(uint32_t) == sizeof(unsigned)); - for(use_collective_io = 0; use_collective_io <= 1; use_collective_io++) { + for (use_collective_io = 0; use_collective_io <= 1; use_collective_io++) { chunk_edge_size = 0; - lower_dim_size_comp_test__run_test(chunk_edge_size, - (hbool_t)use_collective_io, - H5T_NATIVE_UINT); + lower_dim_size_comp_test__run_test(chunk_edge_size, (hbool_t)use_collective_io, H5T_NATIVE_UINT); chunk_edge_size = 5; - lower_dim_size_comp_test__run_test(chunk_edge_size, - (hbool_t)use_collective_io, - H5T_NATIVE_UINT); + lower_dim_size_comp_test__run_test(chunk_edge_size, (hbool_t)use_collective_io, H5T_NATIVE_UINT); } /* end for */ return; } /* lower_dim_size_comp_test() */ - /*------------------------------------------------------------------------- * Function: link_chunk_collective_io_test() * @@ -2629,48 +2325,48 @@ lower_dim_size_comp_test(void) *------------------------------------------------------------------------- */ -#define LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE 16 +#define LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE 16 void link_chunk_collective_io_test(void) { /* const char *fcnName = "link_chunk_collective_io_test()"; */ const char *filename; - hbool_t mis_match = FALSE; - int i; - int mrc; - int mpi_rank; - int mpi_size; - MPI_Comm mpi_comm = MPI_COMM_WORLD; - MPI_Info mpi_info = MPI_INFO_NULL; - hsize_t count[1] = {1}; - hsize_t stride[1] = {2 * LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE}; - hsize_t block[1] = {LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE}; - hsize_t start[1]; - hsize_t dims[1]; - hsize_t chunk_dims[1] = {LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE}; - herr_t ret; /* Generic return value */ - hid_t file_id; - hid_t acc_tpl; - hid_t dset_id; - hid_t file_ds_sid; - hid_t write_mem_ds_sid; - hid_t read_mem_ds_sid; - hid_t ds_dcpl_id; - hid_t xfer_plist; - double diff; - double expected_value; - double local_data_written[LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE]; - double local_data_read[LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE]; + hbool_t mis_match = FALSE; + int i; + int mrc; + int mpi_rank; + int mpi_size; + MPI_Comm mpi_comm = MPI_COMM_WORLD; + MPI_Info mpi_info = MPI_INFO_NULL; + hsize_t count[1] = {1}; + hsize_t stride[1] = {2 * LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE}; + hsize_t block[1] = {LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE}; + hsize_t start[1]; + hsize_t dims[1]; + hsize_t chunk_dims[1] = {LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE}; + herr_t ret; /* Generic return value */ + hid_t file_id; + hid_t acc_tpl; + hid_t dset_id; + hid_t file_ds_sid; + hid_t write_mem_ds_sid; + hid_t read_mem_ds_sid; + hid_t ds_dcpl_id; + hid_t xfer_plist; + double diff; + double expected_value; + double local_data_written[LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE]; + double local_data_read[LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE]; MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - HDassert( mpi_size > 0 ); + HDassert(mpi_size > 0); /* get the file name */ filename = (const char *)GetTestParameters(); - HDassert( filename != NULL ); + HDassert(filename != NULL); /* setup file access template */ acc_tpl = create_faccess_plist(mpi_comm, mpi_info, facc_type); @@ -2691,16 +2387,13 @@ link_chunk_collective_io_test(void) /* setup mem and file dataspaces */ write_mem_ds_sid = H5Screate_simple(1, chunk_dims, NULL); - VRFY((write_mem_ds_sid != 0), - "H5Screate_simple() write_mem_ds_sid succeeded"); + VRFY((write_mem_ds_sid != 0), "H5Screate_simple() write_mem_ds_sid succeeded"); read_mem_ds_sid = H5Screate_simple(1, chunk_dims, NULL); - VRFY((read_mem_ds_sid != 0), - "H5Screate_simple() read_mem_ds_sid succeeded"); + VRFY((read_mem_ds_sid != 0), "H5Screate_simple() read_mem_ds_sid succeeded"); file_ds_sid = H5Screate_simple(1, dims, NULL); - VRFY((file_ds_sid != 0), - "H5Screate_simple() file_ds_sid succeeded"); + VRFY((file_ds_sid != 0), "H5Screate_simple() file_ds_sid succeeded"); /* setup data set creation property list */ ds_dcpl_id = H5Pcreate(H5P_DATASET_CREATE); @@ -2713,9 +2406,8 @@ link_chunk_collective_io_test(void) VRFY((ret != FAIL), "H5Pset_chunk() small_ds_dcpl_id succeeded"); /* create the data set */ - dset_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_DOUBLE, - file_ds_sid, H5P_DEFAULT, - ds_dcpl_id, H5P_DEFAULT); + dset_id = + H5Dcreate2(file_id, "dataset", H5T_NATIVE_DOUBLE, file_ds_sid, H5P_DEFAULT, ds_dcpl_id, H5P_DEFAULT); VRFY((dset_id >= 0), "H5Dcreate2() dataset succeeded"); /* close the dataset creation property list */ @@ -2723,23 +2415,17 @@ link_chunk_collective_io_test(void) VRFY((ret >= 0), "H5Pclose(ds_dcpl_id) succeeded"); /* setup local data */ - expected_value = (double)(LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE) * - (double)(mpi_rank); - for ( i = 0; i < LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE; i++ ) { + expected_value = (double)(LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE) * (double)(mpi_rank); + for (i = 0; i < LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE; i++) { local_data_written[i] = expected_value; - local_data_read[i] = 0.0; - expected_value += 1.0; + local_data_read[i] = 0.0; + expected_value += 1.0; } /* select the file and mem spaces */ start[0] = (hsize_t)(mpi_rank * LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE); - ret = H5Sselect_hyperslab(file_ds_sid, - H5S_SELECT_SET, - start, - stride, - count, - block); + ret = H5Sselect_hyperslab(file_ds_sid, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sselect_hyperslab(file_ds_sid, set) suceeded"); ret = H5Sselect_all(write_mem_ds_sid); @@ -2755,26 +2441,16 @@ link_chunk_collective_io_test(void) VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded"); /* write the data set */ - ret = H5Dwrite(dset_id, - H5T_NATIVE_DOUBLE, - write_mem_ds_sid, - file_ds_sid, - xfer_plist, - local_data_written); + ret = H5Dwrite(dset_id, H5T_NATIVE_DOUBLE, write_mem_ds_sid, file_ds_sid, xfer_plist, local_data_written); VRFY((ret >= 0), "H5Dwrite() dataset initial write succeeded"); /* sync with the other processes before checking data */ mrc = MPI_Barrier(MPI_COMM_WORLD); - VRFY((mrc==MPI_SUCCESS), "Sync after dataset write"); + VRFY((mrc == MPI_SUCCESS), "Sync after dataset write"); /* read this processes slice of the dataset back in */ - ret = H5Dread(dset_id, - H5T_NATIVE_DOUBLE, - read_mem_ds_sid, - file_ds_sid, - xfer_plist, - local_data_read); + ret = H5Dread(dset_id, H5T_NATIVE_DOUBLE, read_mem_ds_sid, file_ds_sid, xfer_plist, local_data_read); VRFY((ret >= 0), "H5Dread() dataset read succeeded"); /* close the xfer property list */ @@ -2783,17 +2459,17 @@ link_chunk_collective_io_test(void) /* verify the data */ mis_match = FALSE; - for ( i = 0; i < LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE; i++ ) { + for (i = 0; i < LINK_CHUNK_COLLECTIVE_IO_TEST_CHUNK_SIZE; i++) { diff = local_data_written[i] - local_data_read[i]; diff = fabs(diff); - if ( diff >= 0.001 ) { + if (diff >= 0.001) { mis_match = TRUE; } } - VRFY( (mis_match == FALSE), "dataset data good."); + VRFY((mis_match == FALSE), "dataset data good."); /* Close dataspaces */ ret = H5Sclose(write_mem_ds_sid); @@ -2816,4 +2492,3 @@ link_chunk_collective_io_test(void) return; } /* link_chunk_collective_io_test() */ - diff --git a/testpar/testpar.h b/testpar/testpar.h index f76de51..b2f0f30 100644 --- a/testpar/testpar.h +++ b/testpar/testpar.h @@ -22,7 +22,7 @@ #include "h5test.h" /* Constants definitions */ -#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */ +#define MAX_ERR_REPORT 10 /* Maximum number of errors reported */ /* Define some handy debugging shorthands, routines, ... */ /* debugging tools */ @@ -30,9 +30,9 @@ /* Print message mesg if verbose level is at least medium and * mesg is not an empty string. */ -#define MESG(mesg) \ - if (VERBOSE_MED && *mesg != '\0') \ - HDprintf("%s\n", mesg) +#define MESG(mesg) \ + if (VERBOSE_MED && *mesg != '\0') \ + HDprintf("%s\n", mesg) /* * VRFY: Verify if the condition val is true. @@ -44,60 +44,63 @@ * This will allow program to continue and can be used for debugging. * (The "do {...} while(0)" is to group all the statements as one unit.) */ -#define VRFY_IMPL(val, mesg, rankvar) do { \ - if (val) { \ - MESG(mesg); \ - } \ - else { \ - HDprintf("Proc %d: ", rankvar); \ - HDprintf("*** Parallel ERROR ***\n"); \ - HDprintf(" VRFY (%s) failed at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ - ++nerrors; \ - fflush(stdout); \ - if (!VERBOSE_MED) { \ - HDprintf("aborting MPI processes\n"); \ - MPI_Abort(MPI_COMM_WORLD, 1); \ - } \ - } \ -} while(0) +#define VRFY_IMPL(val, mesg, rankvar) \ + do { \ + if (val) { \ + MESG(mesg); \ + } \ + else { \ + HDprintf("Proc %d: ", rankvar); \ + HDprintf("*** Parallel ERROR ***\n"); \ + HDprintf(" VRFY (%s) failed at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \ + ++nerrors; \ + fflush(stdout); \ + if (!VERBOSE_MED) { \ + HDprintf("aborting MPI processes\n"); \ + MPI_Abort(MPI_COMM_WORLD, 1); \ + } \ + } \ + } while (0) #define VRFY_G(val, mesg) VRFY_IMPL(val, mesg, mpi_rank_g) -#define VRFY(val, mesg) VRFY_IMPL(val, mesg, mpi_rank) +#define VRFY(val, mesg) VRFY_IMPL(val, mesg, mpi_rank) /* * Checking for information purpose. * If val is false, print mesg; else nothing. * Either case, no error setting. */ -#define INFO(val, mesg) do { \ - if (val) { \ - MESG(mesg); \ - } else { \ - HDprintf("Proc %d: ", mpi_rank); \ - HDprintf("*** PHDF5 REMARK (not an error) ***\n"); \ - HDprintf(" Condition (%s) failed at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ - fflush(stdout); \ - } \ -} while(0) +#define INFO(val, mesg) \ + do { \ + if (val) { \ + MESG(mesg); \ + } \ + else { \ + HDprintf("Proc %d: ", mpi_rank); \ + HDprintf("*** PHDF5 REMARK (not an error) ***\n"); \ + HDprintf(" Condition (%s) failed at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \ + fflush(stdout); \ + } \ + } while (0) -#define MPI_BANNER(mesg) do { \ - if (VERBOSE_MED || MAINPROCESS){ \ - HDprintf("--------------------------------\n"); \ - HDprintf("Proc %d: ", mpi_rank); \ - HDprintf("*** %s\n", mesg); \ - HDprintf("--------------------------------\n"); \ - } \ -} while(0) +#define MPI_BANNER(mesg) \ + do { \ + if (VERBOSE_MED || MAINPROCESS) { \ + HDprintf("--------------------------------\n"); \ + HDprintf("Proc %d: ", mpi_rank); \ + HDprintf("*** %s\n", mesg); \ + HDprintf("--------------------------------\n"); \ + } \ + } while (0) -#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ +#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ -#define SYNC(comm) do { \ - MPI_BANNER("doing a SYNC"); \ - MPI_Barrier(comm); \ - MPI_BANNER("SYNC DONE"); \ -} while(0) +#define SYNC(comm) \ + do { \ + MPI_BANNER("doing a SYNC"); \ + MPI_Barrier(comm); \ + MPI_BANNER("SYNC DONE"); \ + } while (0) /* End of Define some handy debugging shorthands, routines, ... */ diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index b89c790..ca38623 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -18,23 +18,23 @@ #include "testphdf5.h" #ifndef PATH_MAX -#define PATH_MAX 512 -#endif /* !PATH_MAX */ +#define PATH_MAX 512 +#endif /* !PATH_MAX */ /* global variables */ int dim0; int dim1; int chunkdim0; int chunkdim1; -int nerrors = 0; /* errors count */ -int ndatasets = 300; /* number of datasets to create*/ -int ngroups = 512; /* number of groups to create in root - * group. */ -int facc_type = FACC_MPIO; /*Test file access type */ +int nerrors = 0; /* errors count */ +int ndatasets = 300; /* number of datasets to create*/ +int ngroups = 512; /* number of groups to create in root + * group. */ +int facc_type = FACC_MPIO; /*Test file access type */ int dxfer_coll_type = DXFER_COLLECTIVE_IO; -H5E_auto2_t old_func; /* previous error handler */ -void *old_client_data; /* previous error handler arg.*/ +H5E_auto2_t old_func; /* previous error handler */ +void * old_client_data; /* previous error handler arg.*/ /* other option flags */ @@ -43,13 +43,11 @@ void *old_client_data; /* previous error handler arg.*/ * created in one test is accessed by a different test. * filenames[0] is reserved as the file name for PARATESTFILE. */ -#define NFILENAME 2 +#define NFILENAME 2 #define PARATESTFILE filenames[0] -const char *FILENAME[NFILENAME]={ - "ParaTest", - NULL}; -char filenames[NFILENAME][PATH_MAX]; -hid_t fapl; /* file access property list */ +const char *FILENAME[NFILENAME] = {"ParaTest", NULL}; +char filenames[NFILENAME][PATH_MAX]; +hid_t fapl; /* file access property list */ #ifdef USE_PAUSE /* pause the process for a moment to allow debugger to attach if desired. */ @@ -58,15 +56,16 @@ hid_t fapl; /* file access property list */ #include #include -void pause_proc(void) +void +pause_proc(void) { - int pid; - h5_stat_t statbuf; - char greenlight[] = "go"; - int maxloop = 10; - int loops = 0; - int time_int = 10; + int pid; + h5_stat_t statbuf; + char greenlight[] = "go"; + int maxloop = 10; + int loops = 0; + int time_int = 10; /* mpi variables */ int mpi_size, mpi_rank; @@ -79,10 +78,10 @@ void pause_proc(void) MPI_Get_processor_name(mpi_name, &mpi_namelen); if (MAINPROCESS) - while ((HDstat(greenlight, &statbuf) == -1) && loops < maxloop){ - if (!loops++){ - HDprintf("Proc %d (%*s, %d): to debug, attach %d\n", - mpi_rank, mpi_namelen, mpi_name, pid, pid); + while ((HDstat(greenlight, &statbuf) == -1) && loops < maxloop) { + if (!loops++) { + HDprintf("Proc %d (%*s, %d): to debug, attach %d\n", mpi_rank, mpi_namelen, mpi_name, pid, + pid); } HDprintf("waiting(%ds) for file %s ...\n", time_int, greenlight); HDfflush(stdout); @@ -92,15 +91,15 @@ void pause_proc(void) } /* Use the Profile feature of MPI to call the pause_proc() */ -int MPI_Init(int *argc, char ***argv) +int +MPI_Init(int *argc, char ***argv) { int ret_code; - ret_code=PMPI_Init(argc, argv); + ret_code = PMPI_Init(argc, argv); pause_proc(); return (ret_code); } -#endif /* USE_PAUSE */ - +#endif /* USE_PAUSE */ /* * Show command usage @@ -109,164 +108,165 @@ static void usage(void) { HDprintf(" [-r] [-w] [-m] [-n] " - "[-o] [-f ] [-d ]\n"); + "[-o] [-f ] [-d ]\n"); HDprintf("\t-m" - "\tset number of datasets for the multiple dataset test\n"); + "\tset number of datasets for the multiple dataset test\n"); HDprintf("\t-n" - "\tset number of groups for the multiple group test\n"); + "\tset number of groups for the multiple group test\n"); HDprintf("\t-f \tfilename prefix\n"); HDprintf("\t-2\t\tuse Split-file together with MPIO\n"); - HDprintf("\t-d \tdataset dimensions factors. Defaults (%d,%d)\n", - ROW_FACTOR, COL_FACTOR); + HDprintf("\t-d \tdataset dimensions factors. Defaults (%d,%d)\n", ROW_FACTOR, + COL_FACTOR); HDprintf("\t-c \tdataset chunk dimensions. Defaults (dim0/10,dim1/10)\n"); HDprintf("\n"); } - /* * parse the command line options */ static int parse_options(int argc, char **argv) { - int mpi_size, mpi_rank; /* mpi variables */ + int mpi_size, mpi_rank; /* mpi variables */ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* setup default chunk-size. Make sure sizes are > 0 */ - chunkdim0 = (dim0+9)/10; - chunkdim1 = (dim1+9)/10; + chunkdim0 = (dim0 + 9) / 10; + chunkdim1 = (dim1 + 9) / 10; - while (--argc){ - if (**(++argv) != '-'){ - break; - }else{ - switch(*(*argv+1)){ - case 'm': ndatasets = atoi((*argv+1)+1); - if (ndatasets < 0){ - nerrors++; - return(1); - } - break; - case 'n': ngroups = atoi((*argv+1)+1); - if (ngroups < 0){ - nerrors++; - return(1); - } - break; - case 'f': if (--argc < 1) { - nerrors++; - return(1); - } - if (**(++argv) == '-') { - nerrors++; - return(1); - } - paraprefix = *argv; + while (--argc) { + if (**(++argv) != '-') { break; - case 'i': /* Collective MPI-IO access with independent IO */ - dxfer_coll_type = DXFER_INDEPENDENT_IO; - break; - case '2': /* Use the split-file driver with MPIO access */ - /* Can use $HDF5_METAPREFIX to define the */ - /* meta-file-prefix. */ - facc_type = FACC_MPIO | FACC_SPLIT; - break; - case 'd': /* dimensizes */ - if (--argc < 2){ - nerrors++; - return(1); - } - dim0 = atoi(*(++argv))*mpi_size; - argc--; - dim1 = atoi(*(++argv))*mpi_size; - /* set default chunkdim sizes too */ - chunkdim0 = (dim0+9)/10; - chunkdim1 = (dim1+9)/10; - break; - case 'c': /* chunk dimensions */ - if (--argc < 2){ + } + else { + switch (*(*argv + 1)) { + case 'm': + ndatasets = atoi((*argv + 1) + 1); + if (ndatasets < 0) { + nerrors++; + return (1); + } + break; + case 'n': + ngroups = atoi((*argv + 1) + 1); + if (ngroups < 0) { + nerrors++; + return (1); + } + break; + case 'f': + if (--argc < 1) { + nerrors++; + return (1); + } + if (**(++argv) == '-') { + nerrors++; + return (1); + } + paraprefix = *argv; + break; + case 'i': /* Collective MPI-IO access with independent IO */ + dxfer_coll_type = DXFER_INDEPENDENT_IO; + break; + case '2': /* Use the split-file driver with MPIO access */ + /* Can use $HDF5_METAPREFIX to define the */ + /* meta-file-prefix. */ + facc_type = FACC_MPIO | FACC_SPLIT; + break; + case 'd': /* dimensizes */ + if (--argc < 2) { + nerrors++; + return (1); + } + dim0 = atoi(*(++argv)) * mpi_size; + argc--; + dim1 = atoi(*(++argv)) * mpi_size; + /* set default chunkdim sizes too */ + chunkdim0 = (dim0 + 9) / 10; + chunkdim1 = (dim1 + 9) / 10; + break; + case 'c': /* chunk dimensions */ + if (--argc < 2) { + nerrors++; + return (1); + } + chunkdim0 = atoi(*(++argv)); + argc--; + chunkdim1 = atoi(*(++argv)); + break; + case 'h': /* print help message--return with nerrors set */ + return (1); + default: + HDprintf("Illegal option(%s)\n", *argv); nerrors++; - return(1); - } - chunkdim0 = atoi(*(++argv)); - argc--; - chunkdim1 = atoi(*(++argv)); - break; - case 'h': /* print help message--return with nerrors set */ - return(1); - default: HDprintf("Illegal option(%s)\n", *argv); - nerrors++; - return(1); + return (1); } } } /*while*/ /* check validity of dimension and chunk sizes */ - if (dim0 <= 0 || dim1 <= 0){ + if (dim0 <= 0 || dim1 <= 0) { HDprintf("Illegal dim sizes (%d, %d)\n", dim0, dim1); nerrors++; - return(1); + return (1); } - if (chunkdim0 <= 0 || chunkdim1 <= 0){ + if (chunkdim0 <= 0 || chunkdim1 <= 0) { HDprintf("Illegal chunkdim sizes (%d, %d)\n", chunkdim0, chunkdim1); nerrors++; - return(1); + return (1); } /* Make sure datasets can be divided into equal portions by the processes */ - if ((dim0 % mpi_size) || (dim1 % mpi_size)){ + if ((dim0 % mpi_size) || (dim1 % mpi_size)) { if (MAINPROCESS) - HDprintf("dim0(%d) and dim1(%d) must be multiples of processes(%d)\n", - dim0, dim1, mpi_size); + HDprintf("dim0(%d) and dim1(%d) must be multiples of processes(%d)\n", dim0, dim1, mpi_size); nerrors++; - return(1); + return (1); } /* compose the test filenames */ { int i, n; - n = sizeof(FILENAME)/sizeof(FILENAME[0]) - 1; /* exclude the NULL */ + n = sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; /* exclude the NULL */ - for (i=0; i < n; i++) - if (h5_fixname(FILENAME[i],fapl,filenames[i],sizeof(filenames[i])) - == NULL){ + for (i = 0; i < n; i++) + if (h5_fixname(FILENAME[i], fapl, filenames[i], sizeof(filenames[i])) == NULL) { HDprintf("h5_fixname failed\n"); nerrors++; - return(1); + return (1); } HDprintf("Test filenames are:\n"); - for (i=0; i < n; i++) + for (i = 0; i < n; i++) HDprintf(" %s\n", filenames[i]); } - return(0); + return (0); } - /* * Create the appropriate File access property list */ hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) { - hid_t ret_pl = -1; - herr_t ret; /* generic return value */ - int mpi_rank; /* mpi variables */ + hid_t ret_pl = -1; + herr_t ret; /* generic return value */ + int mpi_rank; /* mpi variables */ /* need the rank for error checking macros */ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - ret_pl = H5Pcreate (H5P_FILE_ACCESS); + ret_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY((ret_pl >= 0), "H5P_FILE_ACCESS"); if (l_facc_type == FACC_DEFAULT) return (ret_pl); - if (l_facc_type == FACC_MPIO){ + if (l_facc_type == FACC_MPIO) { /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(ret_pl, comm, info); VRFY((ret >= 0), ""); @@ -274,36 +274,36 @@ create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) VRFY((ret >= 0), ""); ret = H5Pset_coll_metadata_write(ret_pl, TRUE); VRFY((ret >= 0), ""); - return(ret_pl); + return (ret_pl); } - if (l_facc_type == (FACC_MPIO | FACC_SPLIT)){ + if (l_facc_type == (FACC_MPIO | FACC_SPLIT)) { hid_t mpio_pl; - mpio_pl = H5Pcreate (H5P_FILE_ACCESS); + mpio_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY((mpio_pl >= 0), ""); /* set Parallel access with communicator */ ret = H5Pset_fapl_mpio(mpio_pl, comm, info); VRFY((ret >= 0), ""); /* setup file access template */ - ret_pl = H5Pcreate (H5P_FILE_ACCESS); + ret_pl = H5Pcreate(H5P_FILE_ACCESS); VRFY((ret_pl >= 0), ""); /* set Parallel access with communicator */ ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); VRFY((ret >= 0), "H5Pset_fapl_split succeeded"); H5Pclose(mpio_pl); - return(ret_pl); + return (ret_pl); } /* unknown file access types */ return (ret_pl); } - -int main(int argc, char **argv) +int +main(int argc, char **argv) { - int mpi_size, mpi_rank; /* mpi variables */ + int mpi_size, mpi_rank; /* mpi variables */ H5Ptest_param_t ndsets_params, ngroups_params; H5Ptest_param_t collngroups_params; H5Ptest_param_t io_mode_confusion_params; @@ -319,21 +319,21 @@ int main(int argc, char **argv) MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - dim0 = ROW_FACTOR*mpi_size; - dim1 = COL_FACTOR*mpi_size; + dim0 = ROW_FACTOR * mpi_size; + dim1 = COL_FACTOR * mpi_size; - if (MAINPROCESS){ + if (MAINPROCESS) { HDprintf("===================================\n"); HDprintf("PHDF5 TESTS START\n"); HDprintf("===================================\n"); } /* Attempt to turn off atexit post processing so that in case errors - * happen during the test and the process is aborted, it will not get - * hang in the atexit post processing in which it may try to make MPI - * calls. By then, MPI calls may not work. - */ - if (H5dont_atexit() < 0){ + * happen during the test and the process is aborted, it will not get + * hang in the atexit post processing in which it may try to make MPI + * calls. By then, MPI calls may not work. + */ + if (H5dont_atexit() < 0) { HDprintf("Failed to turn off atexit processing. Continue.\n"); }; H5open(); @@ -343,209 +343,149 @@ int main(int argc, char **argv) TestInit(argv[0], usage, parse_options); /* Tests are generally arranged from least to most complexity... */ - AddTest("mpiodup", test_fapl_mpio_dup, NULL, - "fapl_mpio duplicate", NULL); + AddTest("mpiodup", test_fapl_mpio_dup, NULL, "fapl_mpio duplicate", NULL); - AddTest("split", test_split_comm_access, NULL, - "dataset using split communicators", PARATESTFILE); + AddTest("split", test_split_comm_access, NULL, "dataset using split communicators", PARATESTFILE); #ifdef PB_OUT /* temporary: disable page buffering when parallel */ - AddTest("page_buffer", test_page_buffer_access, NULL, - "page buffer usage in parallel", PARATESTFILE); + AddTest("page_buffer", test_page_buffer_access, NULL, "page buffer usage in parallel", PARATESTFILE); #endif - AddTest("props", test_file_properties, NULL, - "Coll Metadata file property settings", PARATESTFILE); - - AddTest("idsetw", dataset_writeInd, NULL, - "dataset independent write", PARATESTFILE); - AddTest("idsetr", dataset_readInd, NULL, - "dataset independent read", PARATESTFILE); - - AddTest("cdsetw", dataset_writeAll, NULL, - "dataset collective write", PARATESTFILE); - AddTest("cdsetr", dataset_readAll, NULL, - "dataset collective read", PARATESTFILE); - - AddTest("eidsetw", extend_writeInd, NULL, - "extendible dataset independent write", PARATESTFILE); - AddTest("eidsetr", extend_readInd, NULL, - "extendible dataset independent read", PARATESTFILE); - AddTest("ecdsetw", extend_writeAll, NULL, - "extendible dataset collective write", PARATESTFILE); - AddTest("ecdsetr", extend_readAll, NULL, - "extendible dataset collective read", PARATESTFILE); - AddTest("eidsetw2", extend_writeInd2, NULL, - "extendible dataset independent write #2", PARATESTFILE); - AddTest("selnone", none_selection_chunk, NULL, - "chunked dataset with none-selection", PARATESTFILE); - AddTest("calloc", test_chunk_alloc, NULL, - "parallel extend Chunked allocation on serial file", PARATESTFILE); - AddTest("fltread", test_filter_read, NULL, - "parallel read of dataset written serially with filters", PARATESTFILE); + AddTest("props", test_file_properties, NULL, "Coll Metadata file property settings", PARATESTFILE); + + AddTest("idsetw", dataset_writeInd, NULL, "dataset independent write", PARATESTFILE); + AddTest("idsetr", dataset_readInd, NULL, "dataset independent read", PARATESTFILE); + + AddTest("cdsetw", dataset_writeAll, NULL, "dataset collective write", PARATESTFILE); + AddTest("cdsetr", dataset_readAll, NULL, "dataset collective read", PARATESTFILE); + + AddTest("eidsetw", extend_writeInd, NULL, "extendible dataset independent write", PARATESTFILE); + AddTest("eidsetr", extend_readInd, NULL, "extendible dataset independent read", PARATESTFILE); + AddTest("ecdsetw", extend_writeAll, NULL, "extendible dataset collective write", PARATESTFILE); + AddTest("ecdsetr", extend_readAll, NULL, "extendible dataset collective read", PARATESTFILE); + AddTest("eidsetw2", extend_writeInd2, NULL, "extendible dataset independent write #2", PARATESTFILE); + AddTest("selnone", none_selection_chunk, NULL, "chunked dataset with none-selection", PARATESTFILE); + AddTest("calloc", test_chunk_alloc, NULL, "parallel extend Chunked allocation on serial file", + PARATESTFILE); + AddTest("fltread", test_filter_read, NULL, "parallel read of dataset written serially with filters", + PARATESTFILE); #ifdef H5_HAVE_FILTER_DEFLATE - AddTest("cmpdsetr", compress_readAll, NULL, - "compressed dataset collective read", PARATESTFILE); + AddTest("cmpdsetr", compress_readAll, NULL, "compressed dataset collective read", PARATESTFILE); #endif /* H5_HAVE_FILTER_DEFLATE */ - AddTest("zerodsetr", zero_dim_dset, NULL, - "zero dim dset", PARATESTFILE); + AddTest("zerodsetr", zero_dim_dset, NULL, "zero dim dset", PARATESTFILE); - ndsets_params.name = PARATESTFILE; + ndsets_params.name = PARATESTFILE; ndsets_params.count = ndatasets; - AddTest("ndsetw", multiple_dset_write, NULL, - "multiple datasets write", &ndsets_params); + AddTest("ndsetw", multiple_dset_write, NULL, "multiple datasets write", &ndsets_params); - ngroups_params.name = PARATESTFILE; + ngroups_params.name = PARATESTFILE; ngroups_params.count = ngroups; - AddTest("ngrpw", multiple_group_write, NULL, - "multiple groups write", &ngroups_params); - AddTest("ngrpr", multiple_group_read, NULL, - "multiple groups read", &ngroups_params); + AddTest("ngrpw", multiple_group_write, NULL, "multiple groups write", &ngroups_params); + AddTest("ngrpr", multiple_group_read, NULL, "multiple groups read", &ngroups_params); - AddTest("compact", compact_dataset, NULL, - "compact dataset test", PARATESTFILE); + AddTest("compact", compact_dataset, NULL, "compact dataset test", PARATESTFILE); - collngroups_params.name = PARATESTFILE; + collngroups_params.name = PARATESTFILE; collngroups_params.count = ngroups; /* combined cngrpw and ingrpr tests because ingrpr reads file created by cngrpw. */ AddTest("cngrpw-ingrpr", collective_group_write_independent_group_read, NULL, - "collective grp/dset write - independent grp/dset read", - &collngroups_params); + "collective grp/dset write - independent grp/dset read", &collngroups_params); #ifndef H5_HAVE_WIN32_API - AddTest("bigdset", big_dataset, NULL, - "big dataset test", PARATESTFILE); + AddTest("bigdset", big_dataset, NULL, "big dataset test", PARATESTFILE); #else HDprintf("big dataset test will be skipped on Windows (JIRA HDDFV-8064)\n"); #endif - AddTest("fill", dataset_fillvalue, NULL, - "dataset fill value", PARATESTFILE); - - AddTest("cchunk1", - coll_chunk1,NULL, "simple collective chunk io",PARATESTFILE); - AddTest("cchunk2", - coll_chunk2,NULL, "noncontiguous collective chunk io",PARATESTFILE); - AddTest("cchunk3", - coll_chunk3,NULL, "multi-chunk collective chunk io",PARATESTFILE); - AddTest("cchunk4", - coll_chunk4,NULL, "collective chunk io with partial non-selection ",PARATESTFILE); - - if((mpi_size < 3)&& MAINPROCESS ) { + AddTest("fill", dataset_fillvalue, NULL, "dataset fill value", PARATESTFILE); + + AddTest("cchunk1", coll_chunk1, NULL, "simple collective chunk io", PARATESTFILE); + AddTest("cchunk2", coll_chunk2, NULL, "noncontiguous collective chunk io", PARATESTFILE); + AddTest("cchunk3", coll_chunk3, NULL, "multi-chunk collective chunk io", PARATESTFILE); + AddTest("cchunk4", coll_chunk4, NULL, "collective chunk io with partial non-selection ", PARATESTFILE); + + if ((mpi_size < 3) && MAINPROCESS) { HDprintf("Collective chunk IO optimization APIs "); HDprintf("needs at least 3 processes to participate\n"); HDprintf("Collective chunk IO API tests will be skipped \n"); } - AddTest((mpi_size <3)? "-cchunk5":"cchunk5" , - coll_chunk5,NULL, - "linked chunk collective IO without optimization",PARATESTFILE); - AddTest((mpi_size < 3)? "-cchunk6" : "cchunk6", - coll_chunk6,NULL, - "multi-chunk collective IO with direct request",PARATESTFILE); - AddTest((mpi_size < 3)? "-cchunk7" : "cchunk7", - coll_chunk7,NULL, - "linked chunk collective IO with optimization",PARATESTFILE); - AddTest((mpi_size < 3)? "-cchunk8" : "cchunk8", - coll_chunk8,NULL, - "linked chunk collective IO transferring to multi-chunk",PARATESTFILE); - AddTest((mpi_size < 3)? "-cchunk9" : "cchunk9", - coll_chunk9,NULL, - "multiple chunk collective IO with optimization",PARATESTFILE); - AddTest((mpi_size < 3)? "-cchunk10" : "cchunk10", - coll_chunk10,NULL, - "multiple chunk collective IO transferring to independent IO",PARATESTFILE); - - + AddTest((mpi_size < 3) ? "-cchunk5" : "cchunk5", coll_chunk5, NULL, + "linked chunk collective IO without optimization", PARATESTFILE); + AddTest((mpi_size < 3) ? "-cchunk6" : "cchunk6", coll_chunk6, NULL, + "multi-chunk collective IO with direct request", PARATESTFILE); + AddTest((mpi_size < 3) ? "-cchunk7" : "cchunk7", coll_chunk7, NULL, + "linked chunk collective IO with optimization", PARATESTFILE); + AddTest((mpi_size < 3) ? "-cchunk8" : "cchunk8", coll_chunk8, NULL, + "linked chunk collective IO transferring to multi-chunk", PARATESTFILE); + AddTest((mpi_size < 3) ? "-cchunk9" : "cchunk9", coll_chunk9, NULL, + "multiple chunk collective IO with optimization", PARATESTFILE); + AddTest((mpi_size < 3) ? "-cchunk10" : "cchunk10", coll_chunk10, NULL, + "multiple chunk collective IO transferring to independent IO", PARATESTFILE); /* irregular collective IO tests*/ - AddTest("ccontw", - coll_irregular_cont_write,NULL, - "collective irregular contiguous write",PARATESTFILE); - AddTest("ccontr", - coll_irregular_cont_read,NULL, - "collective irregular contiguous read",PARATESTFILE); - AddTest("cschunkw", - coll_irregular_simple_chunk_write,NULL, - "collective irregular simple chunk write",PARATESTFILE); - AddTest("cschunkr", - coll_irregular_simple_chunk_read,NULL, - "collective irregular simple chunk read",PARATESTFILE); - AddTest("ccchunkw", - coll_irregular_complex_chunk_write,NULL, - "collective irregular complex chunk write",PARATESTFILE); - AddTest("ccchunkr", - coll_irregular_complex_chunk_read,NULL, - "collective irregular complex chunk read",PARATESTFILE); - - AddTest("null", null_dataset, NULL, - "null dataset test", PARATESTFILE); + AddTest("ccontw", coll_irregular_cont_write, NULL, "collective irregular contiguous write", PARATESTFILE); + AddTest("ccontr", coll_irregular_cont_read, NULL, "collective irregular contiguous read", PARATESTFILE); + AddTest("cschunkw", coll_irregular_simple_chunk_write, NULL, "collective irregular simple chunk write", + PARATESTFILE); + AddTest("cschunkr", coll_irregular_simple_chunk_read, NULL, "collective irregular simple chunk read", + PARATESTFILE); + AddTest("ccchunkw", coll_irregular_complex_chunk_write, NULL, "collective irregular complex chunk write", + PARATESTFILE); + AddTest("ccchunkr", coll_irregular_complex_chunk_read, NULL, "collective irregular complex chunk read", + PARATESTFILE); + + AddTest("null", null_dataset, NULL, "null dataset test", PARATESTFILE); io_mode_confusion_params.name = PARATESTFILE; io_mode_confusion_params.count = 0; /* value not used */ - AddTest("I/Omodeconf", io_mode_confusion, NULL, - "I/O mode confusion test -- hangs quickly on failure", + AddTest("I/Omodeconf", io_mode_confusion, NULL, "I/O mode confusion test -- hangs quickly on failure", &io_mode_confusion_params); - if((mpi_size < 3) && MAINPROCESS) { + if ((mpi_size < 3) && MAINPROCESS) { HDprintf("rr_obj_hdr_flush_confusion test needs at least 3 processes.\n"); HDprintf("rr_obj_hdr_flush_confusion test will be skipped \n"); } - if(mpi_size > 2) { - rr_obj_flush_confusion_params.name = PARATESTFILE; + if (mpi_size > 2) { + rr_obj_flush_confusion_params.name = PARATESTFILE; rr_obj_flush_confusion_params.count = 0; /* value not used */ AddTest("rrobjflushconf", rr_obj_hdr_flush_confusion, NULL, - "round robin object header flush confusion test", - &rr_obj_flush_confusion_params); + "round robin object header flush confusion test", &rr_obj_flush_confusion_params); } - AddTest("alnbg1", - chunk_align_bug_1, NULL, - "Chunk allocation with alignment bug.", - PARATESTFILE); + AddTest("alnbg1", chunk_align_bug_1, NULL, "Chunk allocation with alignment bug.", PARATESTFILE); - AddTest("tldsc", - lower_dim_size_comp_test, NULL, - "test lower dim size comp in span tree to mpi derived type", - PARATESTFILE); + AddTest("tldsc", lower_dim_size_comp_test, NULL, + "test lower dim size comp in span tree to mpi derived type", PARATESTFILE); - AddTest("lccio", - link_chunk_collective_io_test, NULL, - "test mpi derived type management", - PARATESTFILE); + AddTest("lccio", link_chunk_collective_io_test, NULL, "test mpi derived type management", PARATESTFILE); - AddTest("actualio", actual_io_mode_tests, NULL, - "test actual io mode proprerty", - PARATESTFILE); + AddTest("actualio", actual_io_mode_tests, NULL, "test actual io mode proprerty", PARATESTFILE); - AddTest("nocolcause", no_collective_cause_tests, NULL, - "test cause for broken collective io", + AddTest("nocolcause", no_collective_cause_tests, NULL, "test cause for broken collective io", PARATESTFILE); - AddTest("edpl", test_plist_ed, NULL, - "encode/decode Property Lists", NULL); + AddTest("edpl", test_plist_ed, NULL, "encode/decode Property Lists", NULL); - if((mpi_size < 2) && MAINPROCESS) { + if ((mpi_size < 2) && MAINPROCESS) { HDprintf("File Image Ops daisy chain test needs at least 2 processes.\n"); HDprintf("File Image Ops daisy chain test will be skipped \n"); } - AddTest((mpi_size < 2)? "-fiodc" : "fiodc", file_image_daisy_chain_test, NULL, + AddTest((mpi_size < 2) ? "-fiodc" : "fiodc", file_image_daisy_chain_test, NULL, "file image ops daisy chain", NULL); - if((mpi_size < 2)&& MAINPROCESS ) { + if ((mpi_size < 2) && MAINPROCESS) { HDprintf("Atomicity tests need at least 2 processes to participate\n"); HDprintf("8 is more recommended.. Atomicity tests will be skipped \n"); } else if (facc_type != FACC_MPIO && MAINPROCESS) { HDprintf("Atomicity tests will not work with a non MPIO VFD\n"); } - else if(mpi_size >= 2 && facc_type == FACC_MPIO){ - AddTest("atomicity", dataset_atomicity, NULL, - "dataset atomic updates", PARATESTFILE); + else if (mpi_size >= 2 && facc_type == FACC_MPIO) { + AddTest("atomicity", dataset_atomicity, NULL, "dataset atomic updates", PARATESTFILE); } - AddTest("denseattr", test_dense_attr, NULL, - "Store Dense Attributes", PARATESTFILE); + AddTest("denseattr", test_dense_attr, NULL, "Store Dense Attributes", PARATESTFILE); AddTest("noselcollmdread", test_partial_no_selection_coll_md_read, NULL, "Collective Metadata read with some ranks having no selection", PARATESTFILE); @@ -558,25 +498,24 @@ int main(int argc, char **argv) TestInfo(argv[0]); /* setup file access property list */ - fapl = H5Pcreate (H5P_FILE_ACCESS); + fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL); /* Parse command line arguments */ TestParseCmdLine(argc, argv); - if (dxfer_coll_type == DXFER_INDEPENDENT_IO && MAINPROCESS){ + if (dxfer_coll_type == DXFER_INDEPENDENT_IO && MAINPROCESS) { HDprintf("===================================\n" - " Using Independent I/O with file set view to replace collective I/O \n" - "===================================\n"); + " Using Independent I/O with file set view to replace collective I/O \n" + "===================================\n"); } - /* Perform requested testing */ PerformTests(); /* make sure all processes are finished before final report, cleanup - * and exit. - */ + * and exit. + */ MPI_Barrier(MPI_COMM_WORLD); /* Display test summary, if requested */ @@ -592,10 +531,10 @@ int main(int argc, char **argv) { int temp; MPI_Allreduce(&nerrors, &temp, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD); - nerrors=temp; + nerrors = temp; } - if (MAINPROCESS){ /* only process 0 reports */ + if (MAINPROCESS) { /* only process 0 reports */ HDprintf("===================================\n"); if (nerrors) HDprintf("***PHDF5 tests detected %d errors***\n", nerrors); @@ -614,6 +553,5 @@ int main(int argc, char **argv) MPI_Finalize(); /* cannot just return (nerrors) because exit code is limited to 1byte */ - return(nerrors!=0); + return (nerrors != 0); } - diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h index cf611b7..4393f72 100644 --- a/testpar/testphdf5.h +++ b/testpar/testphdf5.h @@ -18,164 +18,167 @@ #include "testpar.h" -enum H5TEST_COLL_CHUNK_API {API_NONE=0,API_LINK_HARD, - API_MULTI_HARD,API_LINK_TRUE,API_LINK_FALSE, - API_MULTI_COLL,API_MULTI_IND}; +enum H5TEST_COLL_CHUNK_API { + API_NONE = 0, + API_LINK_HARD, + API_MULTI_HARD, + API_LINK_TRUE, + API_LINK_FALSE, + API_MULTI_COLL, + API_MULTI_IND +}; #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif - /* Constants definitions */ -#define DIM0 600 /* Default dataset sizes. */ -#define DIM1 1200 /* Values are from a monitor pixel sizes */ -#define ROW_FACTOR 8 /* Nominal row factor for dataset size */ -#define COL_FACTOR 16 /* Nominal column factor for dataset size */ -#define RANK 2 -#define DATASETNAME1 "Data1" -#define DATASETNAME2 "Data2" -#define DATASETNAME3 "Data3" -#define DATASETNAME4 "Data4" -#define DATASETNAME5 "Data5" -#define DATASETNAME6 "Data6" -#define DATASETNAME7 "Data7" -#define DATASETNAME8 "Data8" -#define DATASETNAME9 "Data9" +#define DIM0 600 /* Default dataset sizes. */ +#define DIM1 1200 /* Values are from a monitor pixel sizes */ +#define ROW_FACTOR 8 /* Nominal row factor for dataset size */ +#define COL_FACTOR 16 /* Nominal column factor for dataset size */ +#define RANK 2 +#define DATASETNAME1 "Data1" +#define DATASETNAME2 "Data2" +#define DATASETNAME3 "Data3" +#define DATASETNAME4 "Data4" +#define DATASETNAME5 "Data5" +#define DATASETNAME6 "Data6" +#define DATASETNAME7 "Data7" +#define DATASETNAME8 "Data8" +#define DATASETNAME9 "Data9" /* point selection order */ -#define IN_ORDER 1 +#define IN_ORDER 1 #define OUT_OF_ORDER 2 /* Hyperslab layout styles */ -#define BYROW 1 /* divide into slabs of rows */ -#define BYCOL 2 /* divide into blocks of columns */ -#define ZROW 3 /* same as BYCOL except process 0 gets 0 rows */ -#define ZCOL 4 /* same as BYCOL except process 0 gets 0 columns */ +#define BYROW 1 /* divide into slabs of rows */ +#define BYCOL 2 /* divide into blocks of columns */ +#define ZROW 3 /* same as BYCOL except process 0 gets 0 rows */ +#define ZCOL 4 /* same as BYCOL except process 0 gets 0 columns */ /* File_Access_type bits */ -#define FACC_DEFAULT 0x0 /* default */ -#define FACC_MPIO 0x1 /* MPIO */ -#define FACC_SPLIT 0x2 /* Split File */ +#define FACC_DEFAULT 0x0 /* default */ +#define FACC_MPIO 0x1 /* MPIO */ +#define FACC_SPLIT 0x2 /* Split File */ -#define DXFER_COLLECTIVE_IO 0x1 /* Collective IO*/ +#define DXFER_COLLECTIVE_IO 0x1 /* Collective IO*/ #define DXFER_INDEPENDENT_IO 0x2 /* Independent IO collectively */ /*Constants for collective chunk definitions */ -#define SPACE_DIM1 24 -#define SPACE_DIM2 4 -#define BYROW_CONT 1 -#define BYROW_DISCONT 2 -#define BYROW_SELECTNONE 3 +#define SPACE_DIM1 24 +#define SPACE_DIM2 4 +#define BYROW_CONT 1 +#define BYROW_DISCONT 2 +#define BYROW_SELECTNONE 3 #define BYROW_SELECTUNBALANCE 4 -#define BYROW_SELECTINCHUNK 5 - -#define DIMO_NUM_CHUNK 4 -#define DIM1_NUM_CHUNK 2 -#define LINK_TRUE_NUM_CHUNK 2 -#define LINK_FALSE_NUM_CHUNK 6 -#define MULTI_TRUE_PERCENT 50 -#define LINK_TRUE_CHUNK_NAME "h5_link_chunk_true" +#define BYROW_SELECTINCHUNK 5 + +#define DIMO_NUM_CHUNK 4 +#define DIM1_NUM_CHUNK 2 +#define LINK_TRUE_NUM_CHUNK 2 +#define LINK_FALSE_NUM_CHUNK 6 +#define MULTI_TRUE_PERCENT 50 +#define LINK_TRUE_CHUNK_NAME "h5_link_chunk_true" #define LINK_FALSE_CHUNK_NAME "h5_link_chunk_false" -#define LINK_HARD_CHUNK_NAME "h5_link_chunk_hard" +#define LINK_HARD_CHUNK_NAME "h5_link_chunk_hard" #define MULTI_HARD_CHUNK_NAME "h5_multi_chunk_hard" #define MULTI_COLL_CHUNK_NAME "h5_multi_chunk_coll" #define MULTI_INDP_CHUNK_NAME "h5_multi_chunk_indp" #define DSET_COLLECTIVE_CHUNK_NAME "coll_chunk_name" - /*Constants for MPI derived data type generated from span tree */ -#define MSPACE1_RANK 1 /* Rank of the first dataset in memory */ -#define MSPACE1_DIM 27000 /* Dataset size in memory */ -#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */ -#define FSPACE_DIM1 9 /* Dimension sizes of the dataset as it is stored in the file */ -#define FSPACE_DIM2 3600 /* We will read dataset back from the file to the dataset in memory with these dataspace parameters. */ -#define MSPACE_RANK 2 -#define MSPACE_DIM1 9 -#define MSPACE_DIM2 3600 -#define FHCOUNT0 1 /* Count of the first dimension of the first hyperslab selection*/ -#define FHCOUNT1 768 /* Count of the second dimension of the first hyperslab selection*/ -#define FHSTRIDE0 4 /* Stride of the first dimension of the first hyperslab selection*/ -#define FHSTRIDE1 3 /* Stride of the second dimension of the first hyperslab selection*/ -#define FHBLOCK0 3 /* Block of the first dimension of the first hyperslab selection*/ -#define FHBLOCK1 2 /* Block of the second dimension of the first hyperslab selection*/ -#define FHSTART0 0 /* start of the first dimension of the first hyperslab selection*/ -#define FHSTART1 1 /* start of the second dimension of the first hyperslab selection*/ - -#define SHCOUNT0 1 /* Count of the first dimension of the first hyperslab selection*/ -#define SHCOUNT1 1 /* Count of the second dimension of the first hyperslab selection*/ -#define SHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ -#define SHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ -#define SHBLOCK0 3 /* Block of the first dimension of the first hyperslab selection*/ -#define SHBLOCK1 768 /* Block of the second dimension of the first hyperslab selection*/ -#define SHSTART0 4 /* start of the first dimension of the first hyperslab selection*/ -#define SHSTART1 0 /* start of the second dimension of the first hyperslab selection*/ - -#define MHCOUNT0 6912 /* Count of the first dimension of the first hyperslab selection*/ -#define MHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ -#define MHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ -#define MHSTART0 1 /* start of the first dimension of the first hyperslab selection*/ - - - -#define RFFHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/ -#define RFFHCOUNT1 768 /* Count of the second dimension of the first hyperslab selection*/ -#define RFFHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ -#define RFFHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ -#define RFFHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ -#define RFFHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/ -#define RFFHSTART0 1 /* start of the first dimension of the first hyperslab selection*/ -#define RFFHSTART1 2 /* start of the second dimension of the first hyperslab selection*/ - - -#define RFSHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/ -#define RFSHCOUNT1 1536 /* Count of the second dimension of the first hyperslab selection*/ -#define RFSHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ -#define RFSHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ -#define RFSHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ -#define RFSHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/ -#define RFSHSTART0 2 /* start of the first dimension of the first hyperslab selection*/ -#define RFSHSTART1 4 /* start of the second dimension of the first hyperslab selection*/ - - -#define RMFHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/ -#define RMFHCOUNT1 768 /* Count of the second dimension of the first hyperslab selection*/ -#define RMFHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ -#define RMFHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ -#define RMFHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ -#define RMFHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/ -#define RMFHSTART0 0 /* start of the first dimension of the first hyperslab selection*/ -#define RMFHSTART1 0 /* start of the second dimension of the first hyperslab selection*/ - -#define RMSHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/ -#define RMSHCOUNT1 1536 /* Count of the second dimension of the first hyperslab selection*/ -#define RMSHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ -#define RMSHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ -#define RMSHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ -#define RMSHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/ -#define RMSHSTART0 1 /* start of the first dimension of the first hyperslab selection*/ -#define RMSHSTART1 2 /* start of the second dimension of the first hyperslab selection*/ - - -#define NPOINTS 4 /* Number of points that will be selected - and overwritten */ +#define MSPACE1_RANK 1 /* Rank of the first dataset in memory */ +#define MSPACE1_DIM 27000 /* Dataset size in memory */ +#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */ +#define FSPACE_DIM1 \ + 9 /* Dimension sizes of the dataset as it is stored in the file */ +#define FSPACE_DIM2 \ + 3600 /* We will read dataset back from the file to the dataset \ + in memory with these dataspace parameters. */ +#define MSPACE_RANK 2 +#define MSPACE_DIM1 9 +#define MSPACE_DIM2 3600 +#define FHCOUNT0 1 /* Count of the first dimension of the first hyperslab selection*/ +#define FHCOUNT1 768 /* Count of the second dimension of the first hyperslab selection*/ +#define FHSTRIDE0 4 /* Stride of the first dimension of the first hyperslab selection*/ +#define FHSTRIDE1 3 /* Stride of the second dimension of the first hyperslab selection*/ +#define FHBLOCK0 3 /* Block of the first dimension of the first hyperslab selection*/ +#define FHBLOCK1 2 /* Block of the second dimension of the first hyperslab selection*/ +#define FHSTART0 0 /* start of the first dimension of the first hyperslab selection*/ +#define FHSTART1 1 /* start of the second dimension of the first hyperslab selection*/ + +#define SHCOUNT0 1 /* Count of the first dimension of the first hyperslab selection*/ +#define SHCOUNT1 1 /* Count of the second dimension of the first hyperslab selection*/ +#define SHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ +#define SHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ +#define SHBLOCK0 3 /* Block of the first dimension of the first hyperslab selection*/ +#define SHBLOCK1 768 /* Block of the second dimension of the first hyperslab selection*/ +#define SHSTART0 4 /* start of the first dimension of the first hyperslab selection*/ +#define SHSTART1 0 /* start of the second dimension of the first hyperslab selection*/ + +#define MHCOUNT0 6912 /* Count of the first dimension of the first hyperslab selection*/ +#define MHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ +#define MHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ +#define MHSTART0 1 /* start of the first dimension of the first hyperslab selection*/ + +#define RFFHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/ +#define RFFHCOUNT1 768 /* Count of the second dimension of the first hyperslab selection*/ +#define RFFHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ +#define RFFHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ +#define RFFHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ +#define RFFHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/ +#define RFFHSTART0 1 /* start of the first dimension of the first hyperslab selection*/ +#define RFFHSTART1 2 /* start of the second dimension of the first hyperslab selection*/ + +#define RFSHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/ +#define RFSHCOUNT1 1536 /* Count of the second dimension of the first hyperslab selection*/ +#define RFSHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ +#define RFSHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ +#define RFSHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ +#define RFSHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/ +#define RFSHSTART0 2 /* start of the first dimension of the first hyperslab selection*/ +#define RFSHSTART1 4 /* start of the second dimension of the first hyperslab selection*/ + +#define RMFHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/ +#define RMFHCOUNT1 768 /* Count of the second dimension of the first hyperslab selection*/ +#define RMFHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ +#define RMFHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ +#define RMFHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ +#define RMFHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/ +#define RMFHSTART0 0 /* start of the first dimension of the first hyperslab selection*/ +#define RMFHSTART1 0 /* start of the second dimension of the first hyperslab selection*/ + +#define RMSHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/ +#define RMSHCOUNT1 1536 /* Count of the second dimension of the first hyperslab selection*/ +#define RMSHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/ +#define RMSHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/ +#define RMSHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/ +#define RMSHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/ +#define RMSHSTART0 1 /* start of the first dimension of the first hyperslab selection*/ +#define RMSHSTART1 2 /* start of the second dimension of the first hyperslab selection*/ + +#define NPOINTS \ + 4 /* Number of points that will be selected \ + and overwritten */ /* Definitions of the selection mode for the test_actual_io_function. */ -#define TEST_ACTUAL_IO_NO_COLLECTIVE 0 -#define TEST_ACTUAL_IO_RESET 1 -#define TEST_ACTUAL_IO_MULTI_CHUNK_IND 2 -#define TEST_ACTUAL_IO_MULTI_CHUNK_COL 3 -#define TEST_ACTUAL_IO_MULTI_CHUNK_MIX 4 -#define TEST_ACTUAL_IO_MULTI_CHUNK_MIX_DISAGREE 5 -#define TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_IND 6 -#define TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_COL 7 -#define TEST_ACTUAL_IO_LINK_CHUNK 8 -#define TEST_ACTUAL_IO_CONTIGUOUS 9 +#define TEST_ACTUAL_IO_NO_COLLECTIVE 0 +#define TEST_ACTUAL_IO_RESET 1 +#define TEST_ACTUAL_IO_MULTI_CHUNK_IND 2 +#define TEST_ACTUAL_IO_MULTI_CHUNK_COL 3 +#define TEST_ACTUAL_IO_MULTI_CHUNK_MIX 4 +#define TEST_ACTUAL_IO_MULTI_CHUNK_MIX_DISAGREE 5 +#define TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_IND 6 +#define TEST_ACTUAL_IO_DIRECT_MULTI_CHUNK_COL 7 +#define TEST_ACTUAL_IO_LINK_CHUNK 8 +#define TEST_ACTUAL_IO_CONTIGUOUS 9 /* Definitions of the selection mode for the no_collective_cause_tests function. */ #define TEST_COLLECTIVE 0x001 @@ -188,7 +191,7 @@ enum H5TEST_COLL_CHUNK_API {API_NONE=0,API_LINK_HARD, #define TEST_FILTERS 0x080 /* TEST_FILTERS will take place of this after supporting mpio + filter for * H5Dcreate and H5Dwrite */ -#define TEST_FILTERS_READ 0x100 +#define TEST_FILTERS_READ 0x100 /* Don't erase these lines, they are put here for debugging purposes */ /* @@ -205,12 +208,11 @@ enum H5TEST_COLL_CHUNK_API {API_NONE=0,API_LINK_HARD, #define NPOINTS 4 */ /* end of debugging macro */ - /* type definitions */ -typedef struct H5Ptest_param_t /* holds extra test parameters */ +typedef struct H5Ptest_param_t /* holds extra test parameters */ { - char *name; - int count; + char *name; + int count; } H5Ptest_param_t; /* Dataset data type. Int's can be easily octo dumped. */ @@ -218,20 +220,20 @@ typedef int DATATYPE; /* Shape Same Tests Definitions */ typedef enum { - IND_CONTIG, /* Independent IO on contigous datasets */ - COL_CONTIG, /* Collective IO on contigous datasets */ - IND_CHUNKED, /* Independent IO on chunked datasets */ - COL_CHUNKED /* Collective IO on chunked datasets */ + IND_CONTIG, /* Independent IO on contigous datasets */ + COL_CONTIG, /* Collective IO on contigous datasets */ + IND_CHUNKED, /* Independent IO on chunked datasets */ + COL_CHUNKED /* Collective IO on chunked datasets */ } ShapeSameTestMethods; /* Shared global variables */ -extern int dim0, dim1; /*Dataset dimensions */ -extern int chunkdim0, chunkdim1; /*Chunk dimensions */ -extern int nerrors; /*errors count */ -extern H5E_auto2_t old_func; /* previous error handler */ -extern void *old_client_data; /*previous error handler arg.*/ -extern int facc_type; /*Test file access type */ -extern int dxfer_coll_type; +extern int dim0, dim1; /*Dataset dimensions */ +extern int chunkdim0, chunkdim1; /*Chunk dimensions */ +extern int nerrors; /*errors count */ +extern H5E_auto2_t old_func; /* previous error handler */ +extern void * old_client_data; /*previous error handler arg.*/ +extern int facc_type; /*Test file access type */ +extern int dxfer_coll_type; /* Test program prototypes */ void test_plist_ed(void); @@ -300,10 +302,10 @@ void test_multi_chunk_io_addrmap_issue(void); void test_link_chunk_io_sort_chunk_issue(void); /* commonly used prototypes */ -hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type); +hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type); MPI_Offset h5_mpi_get_file_size(const char *filename, MPI_Comm comm, MPI_Info info); -int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], - hsize_t block[], DATATYPE *dataset, DATATYPE *original); -void point_set (hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], - size_t num_points, hsize_t coords[], int order); +int dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], DATATYPE *dataset, + DATATYPE *original); +void point_set(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[], size_t num_points, + hsize_t coords[], int order); #endif /* PHDF5TEST_H */ diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 87a3b11..ec83d91 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -17,7 +17,6 @@ #include "h5diff.h" #include "ph5diff.h" - /*------------------------------------------------------------------------- * Function: print_objname * @@ -27,7 +26,7 @@ *------------------------------------------------------------------------- */ H5_ATTR_PURE int -print_objname (diff_opt_t * opts, hsize_t nfound) +print_objname(diff_opt_t *opts, hsize_t nfound) { return ((opts->mode_verbose || nfound) && !opts->mode_quiet) ? 1 : 0; } @@ -39,7 +38,7 @@ print_objname (diff_opt_t * opts, hsize_t nfound) *------------------------------------------------------------------------- */ void -do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts) +do_print_objname(const char *OBJ, const char *path1, const char *path2, diff_opt_t *opts) { /* if verbose level is higher than 0, put space line before * displaying any object or symbolic links. This improves @@ -57,7 +56,7 @@ do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_op *------------------------------------------------------------------------- */ void -do_print_attrname (const char *attr, const char *path1, const char *path2) +do_print_attrname(const char *attr, const char *path1, const char *path2) { parallel_print("%-7s: <%s> and <%s>\n", attr, path1, path2); } @@ -74,10 +73,9 @@ do_print_attrname (const char *attr, const char *path1, const char *path2) static int print_warn(diff_opt_t *opts) { - return ((opts->mode_verbose)) ? 1: 0; + return ((opts->mode_verbose)) ? 1 : 0; } - #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- * Function: phdiff_dismiss_workers @@ -95,7 +93,6 @@ phdiff_dismiss_workers(void) MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); } - /*------------------------------------------------------------------------- * Function: print_incoming_data * @@ -109,19 +106,20 @@ phdiff_dismiss_workers(void) static void print_incoming_data(void) { - char data[PRINT_DATA_MAX_SIZE + 1]; - int incomingMessage; + char data[PRINT_DATA_MAX_SIZE + 1]; + int incomingMessage; MPI_Status Status; do { MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) { - HDmemset(data, 0, PRINT_DATA_MAX_SIZE+1); - MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status); + if (incomingMessage) { + HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1); + MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, + MPI_COMM_WORLD, &Status); HDprintf("%s", data); } - } while(incomingMessage); + } while (incomingMessage); } #endif @@ -141,7 +139,7 @@ is_valid_options(diff_opt_t *opts) /*----------------------------------------------- * no -q(quiet) with -v (verbose) or -r (report) */ - if(opts->mode_quiet && (opts->mode_verbose || opts->mode_report)) { + if (opts->mode_quiet && (opts->mode_verbose || opts->mode_report)) { parallel_print("Error: -q (quiet mode) cannot be added to verbose or report modes\n"); opts->err_stat = H5DIFF_ERR; H5TOOLS_GOTO_DONE(0); @@ -149,7 +147,7 @@ is_valid_options(diff_opt_t *opts) /* ------------------------------------------------------- * only allow --no-dangling-links along with --follow-symlinks */ - if(opts->no_dangle_links && !opts->follow_links) { + if (opts->no_dangle_links && !opts->follow_links) { parallel_print("Error: --no-dangling-links must be used along with --follow-symlinks option.\n"); opts->err_stat = H5DIFF_ERR; H5TOOLS_GOTO_DONE(0); @@ -169,11 +167,11 @@ done: * 0 - not excluded path *------------------------------------------------------------------------*/ static int -is_exclude_path (char *path, h5trav_type_t type, diff_opt_t *opts) +is_exclude_path(char *path, h5trav_type_t type, diff_opt_t *opts) { struct exclude_path_list *exclude_path_ptr; - int ret_cmp; - int ret_value = 0; + int ret_cmp; + int ret_value = 0; /* check if exclude path option is given */ if (!opts->exclude_path) @@ -186,9 +184,8 @@ is_exclude_path (char *path, h5trav_type_t type, diff_opt_t *opts) while (NULL != exclude_path_ptr) { /* if exclude path is is group, exclude its members as well */ if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP) { - ret_cmp = HDstrncmp(exclude_path_ptr->obj_path, path, - HDstrlen(exclude_path_ptr->obj_path)); - if (ret_cmp == 0) { /* found matching members */ + ret_cmp = HDstrncmp(exclude_path_ptr->obj_path, path, HDstrlen(exclude_path_ptr->obj_path)); + if (ret_cmp == 0) { /* found matching members */ size_t len_grp; /* check if given path belong to an excluding group, if so @@ -200,14 +197,14 @@ is_exclude_path (char *path, h5trav_type_t type, diff_opt_t *opts) if (path[len_grp] == '/') { /* belong to excluded group! */ ret_value = 1; - break; /* while */ + break; /* while */ } } } /* exclude target is not group, just exclude the object */ else { ret_cmp = HDstrcmp(exclude_path_ptr->obj_path, path); - if (ret_cmp == 0) { /* found matching object */ + if (ret_cmp == 0) { /* found matching object */ /* excluded non-group object */ ret_value = 1; /* remember the type of this matching object. @@ -221,7 +218,7 @@ is_exclude_path (char *path, h5trav_type_t type, diff_opt_t *opts) } done: - return ret_value; + return ret_value; } /*------------------------------------------------------------------------- @@ -234,11 +231,11 @@ done: * 0 - not excluded path *------------------------------------------------------------------------*/ static int -is_exclude_attr (const char *path, h5trav_type_t type, diff_opt_t *opts) +is_exclude_attr(const char *path, h5trav_type_t type, diff_opt_t *opts) { struct exclude_path_list *exclude_ptr; - int ret_cmp; - int ret_value = 0; + int ret_cmp; + int ret_value = 0; /* check if exclude attr option is given */ if (!opts->exclude_attr_path) @@ -251,9 +248,8 @@ is_exclude_attr (const char *path, h5trav_type_t type, diff_opt_t *opts) while (NULL != exclude_ptr) { /* if exclude path is is group, exclude its members as well */ if (exclude_ptr->obj_type == H5TRAV_TYPE_GROUP) { - ret_cmp = HDstrncmp(exclude_ptr->obj_path, path, - HDstrlen(exclude_ptr->obj_path)); - if (ret_cmp == 0) { /* found matching members */ + ret_cmp = HDstrncmp(exclude_ptr->obj_path, path, HDstrlen(exclude_ptr->obj_path)); + if (ret_cmp == 0) { /* found matching members */ size_t len_grp; /* check if given path belong to an excluding group, if so @@ -265,14 +261,14 @@ is_exclude_attr (const char *path, h5trav_type_t type, diff_opt_t *opts) if (path[len_grp] == '/') { /* belong to excluded group! */ ret_value = 1; - break; /* while */ + break; /* while */ } } } /* exclude target is not group, just exclude the object */ else { ret_cmp = HDstrcmp(exclude_ptr->obj_path, path); - if (ret_cmp == 0) { /* found matching object */ + if (ret_cmp == 0) { /* found matching object */ /* excluded non-group object */ ret_value = 1; /* remember the type of this matching object. @@ -286,10 +282,9 @@ is_exclude_attr (const char *path, h5trav_type_t type, diff_opt_t *opts) } done: - return ret_value; + return ret_value; } - /*------------------------------------------------------------------------- * Function: free_exclude_path_list * @@ -308,7 +303,6 @@ free_exclude_path_list(diff_opt_t *opts) } } - /*------------------------------------------------------------------------- * Function: free_exclude_attr_list * @@ -342,21 +336,21 @@ free_exclude_attr_list(diff_opt_t *opts) * table_out [OUT] : return the list *------------------------------------------------------------------------*/ static void -build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, - trav_table_t ** table_out, diff_opt_t *opts) +build_match_list(const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, + trav_table_t **table_out, diff_opt_t *opts) { - size_t curr1 = 0; - size_t curr2 = 0; - unsigned infile[2]; - char *path1_lp = NULL; - char *path2_lp = NULL; + size_t curr1 = 0; + size_t curr2 = 0; + unsigned infile[2]; + char * path1_lp = NULL; + char * path2_lp = NULL; h5trav_type_t type1_l; h5trav_type_t type2_l; - size_t path1_offset = 0; - size_t path2_offset = 0; - int cmp; + size_t path1_offset = 0; + size_t path2_offset = 0; + int cmp; trav_table_t *table = NULL; - size_t idx; + size_t idx; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); /* init */ @@ -375,42 +369,42 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 H5TOOLS_DEBUG("objname1 = %s objname2 = %s ", objname1, objname2); /* if obj1 is not root */ - if (HDstrcmp (objname1,"/") != 0) + if (HDstrcmp(objname1, "/") != 0) path1_offset = HDstrlen(objname1); /* if obj2 is not root */ - if (HDstrcmp (objname2,"/") != 0) + if (HDstrcmp(objname2, "/") != 0) path2_offset = HDstrlen(objname2); /*-------------------------------------------------- - * build the list - */ - while(curr1 < info1->nused && curr2 < info2->nused) { + * build the list + */ + while (curr1 < info1->nused && curr2 < info2->nused) { path1_lp = (info1->paths[curr1].path) + path1_offset; path2_lp = (info2->paths[curr2].path) + path2_offset; - type1_l = info1->paths[curr1].type; - type2_l = info2->paths[curr2].type; + type1_l = info1->paths[curr1].type; + type2_l = info2->paths[curr2].type; /* criteria is string compare */ cmp = HDstrcmp(path1_lp, path2_lp); - if(cmp == 0) { - if(!is_exclude_path(path1_lp, type1_l, opts)) { + if (cmp == 0) { + if (!is_exclude_path(path1_lp, type1_l, opts)) { infile[0] = 1; infile[1] = 1; trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); /* if the two point to the same target object, * mark that in table */ - if(info1->paths[curr1].fileno == info2->paths[curr2].fileno) { + if (info1->paths[curr1].fileno == info2->paths[curr2].fileno) { int token_cmp; - if(H5Otoken_cmp(info1->fid, &info1->paths[curr1].obj_token, - &info2->paths[curr2].obj_token, &token_cmp) < 0) { + if (H5Otoken_cmp(info1->fid, &info1->paths[curr1].obj_token, + &info2->paths[curr2].obj_token, &token_cmp) < 0) { H5TOOLS_INFO("Failed to compare object tokens"); opts->err_stat = H5DIFF_ERR; H5TOOLS_GOTO_DONE_NO_RET(); } - if(!token_cmp) { - idx = table->nobjs - 1; + if (!token_cmp) { + idx = table->nobjs - 1; table->objs[idx].is_same_trgobj = 1; } } @@ -418,8 +412,8 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 curr1++; curr2++; } /* end if */ - else if(cmp < 0) { - if(!is_exclude_path(path1_lp, type1_l, opts)) { + else if (cmp < 0) { + if (!is_exclude_path(path1_lp, type1_l, opts)) { infile[0] = 1; infile[1] = 0; trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); @@ -434,16 +428,16 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 } curr2++; } /* end else */ - } /* end while */ + } /* end while */ /* list1 did not end */ infile[0] = 1; infile[1] = 0; - while(curr1 < info1->nused) { + while (curr1 < info1->nused) { path1_lp = (info1->paths[curr1].path) + path1_offset; - type1_l = info1->paths[curr1].type; + type1_l = info1->paths[curr1].type; - if(!is_exclude_path(path1_lp, type1_l, opts)) { + if (!is_exclude_path(path1_lp, type1_l, opts)) { trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); } curr1++; @@ -452,9 +446,9 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 /* list2 did not end */ infile[0] = 0; infile[1] = 1; - while(curr2 < info2->nused) { + while (curr2 < info2->nused) { path2_lp = (info2->paths[curr2].path) + path2_offset; - type2_l = info2->paths[curr2].type; + type2_l = info2->paths[curr2].type; if (!is_exclude_path(path2_lp, type2_l, opts)) { trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table); @@ -462,7 +456,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 curr2++; } /* end while */ - free_exclude_path_list (opts); + free_exclude_path_list(opts); done: *table_out = table; @@ -470,15 +464,13 @@ done: H5TOOLS_ENDDEBUG(""); } - /*------------------------------------------------------------------------- * Function: trav_grp_objs * * Purpose: Call back function from h5trav_visit(). *------------------------------------------------------------------------*/ static herr_t -trav_grp_objs(const char *path, const H5O_info2_t *oinfo, - const char *already_visited, void *udata) +trav_grp_objs(const char *path, const H5O_info2_t *oinfo, const char *already_visited, void *udata) { trav_info_visit_obj(path, oinfo, already_visited, udata); @@ -494,12 +486,12 @@ trav_grp_objs(const char *path, const H5O_info2_t *oinfo, static herr_t trav_grp_symlinks(const char *path, const H5L_info2_t *linfo, void *udata) { - trav_info_t *tinfo = (trav_info_t *)udata; - diff_opt_t *opts = (diff_opt_t *)tinfo->opts; + trav_info_t * tinfo = (trav_info_t *)udata; + diff_opt_t * opts = (diff_opt_t *)tinfo->opts; h5tool_link_info_t lnk_info; - const char *ext_fname; - const char *ext_path; - herr_t ret_value = SUCCEED; + const char * ext_fname; + const char * ext_path; + herr_t ret_value = SUCCEED; H5TOOLS_START_DEBUG(""); /* init linkinfo struct */ @@ -510,9 +502,9 @@ trav_grp_symlinks(const char *path, const H5L_info2_t *linfo, void *udata) H5TOOLS_GOTO_DONE(SUCCEED); } - switch(linfo->type) { + switch (linfo->type) { case H5L_TYPE_SOFT: - if((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) { + if ((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) { H5TOOLS_GOTO_DONE(FAIL); } else if (ret_value == 0) { @@ -525,15 +517,15 @@ trav_grp_symlinks(const char *path, const H5L_info2_t *linfo, void *udata) } /* check if already visit the target object */ - if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path)) + if (symlink_is_visited(&(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path)) H5TOOLS_GOTO_DONE(SUCCEED); /* add this link as visited link */ - if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0) + if (symlink_visit_add(&(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0) H5TOOLS_GOTO_DONE(SUCCEED); - if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, - trav_grp_objs,trav_grp_symlinks, tinfo, H5O_INFO_BASIC) < 0) { + if (h5trav_visit(tinfo->fid, path, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, tinfo, + H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); opts->err_stat = H5DIFF_ERR; H5TOOLS_GOTO_ERROR(FAIL, "Error: Could not get file contents"); @@ -545,7 +537,7 @@ trav_grp_symlinks(const char *path, const H5L_info2_t *linfo, void *udata) H5TOOLS_GOTO_DONE(FAIL); } else if (ret_value == 0) { - /* no dangling link option given and detect dangling link */ + /* no dangling link option given and detect dangling link */ tinfo->symlink_visited.dangle_link = TRUE; trav_info_visit_lnk(path, linfo, tinfo); if (opts->no_dangle_links) @@ -553,19 +545,19 @@ trav_grp_symlinks(const char *path, const H5L_info2_t *linfo, void *udata) H5TOOLS_GOTO_DONE(SUCCEED); } - if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0) + if (H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0) H5TOOLS_GOTO_DONE(SUCCEED); /* check if already visit the target object */ - if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path)) + if (symlink_is_visited(&(tinfo->symlink_visited), linfo->type, ext_fname, ext_path)) H5TOOLS_GOTO_DONE(SUCCEED); /* add this link as visited link */ - if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0) + if (symlink_visit_add(&(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0) H5TOOLS_GOTO_DONE(SUCCEED); - if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, - trav_grp_objs,trav_grp_symlinks, tinfo, H5O_INFO_BASIC) < 0) { + if (h5trav_visit(tinfo->fid, path, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, tinfo, + H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); opts->err_stat = H5DIFF_ERR; H5TOOLS_GOTO_ERROR(FAIL, "Error: Could not get file contents\n"); @@ -589,7 +581,6 @@ done: return ret_value; } - /*------------------------------------------------------------------------- * Function: h5diff * @@ -602,39 +593,39 @@ done: hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, diff_opt_t *opts) { - hid_t file1_id = H5I_INVALID_HID; - hid_t file2_id = H5I_INVALID_HID; - hid_t fapl1_id = H5P_DEFAULT; - hid_t fapl2_id = H5P_DEFAULT; - char filenames[2][MAX_FILENAME]; - hsize_t nfound = 0; - int l_ret1 = -1; - int l_ret2 = -1; - char *obj1fullname = NULL; - char *obj2fullname = NULL; - int both_objs_grp = 0; + hid_t file1_id = H5I_INVALID_HID; + hid_t file2_id = H5I_INVALID_HID; + hid_t fapl1_id = H5P_DEFAULT; + hid_t fapl2_id = H5P_DEFAULT; + char filenames[2][MAX_FILENAME]; + hsize_t nfound = 0; + int l_ret1 = -1; + int l_ret2 = -1; + char * obj1fullname = NULL; + char * obj2fullname = NULL; + int both_objs_grp = 0; /* init to group type */ h5trav_type_t obj1type = H5TRAV_TYPE_GROUP; h5trav_type_t obj2type = H5TRAV_TYPE_GROUP; /* for single object */ - H5O_info2_t oinfo1, oinfo2; /* object info */ - trav_info_t *info1_obj = NULL; - trav_info_t *info2_obj = NULL; + H5O_info2_t oinfo1, oinfo2; /* object info */ + trav_info_t *info1_obj = NULL; + trav_info_t *info2_obj = NULL; /* for group object */ - trav_info_t *info1_grp = NULL; - trav_info_t *info2_grp = NULL; + trav_info_t *info1_grp = NULL; + trav_info_t *info2_grp = NULL; /* local pointer */ - trav_info_t *info1_lp = NULL; - trav_info_t *info2_lp = NULL; + trav_info_t *info1_lp = NULL; + trav_info_t *info2_lp = NULL; /* link info from specified object */ - H5L_info2_t src_linfo1; - H5L_info2_t src_linfo2; + H5L_info2_t src_linfo1; + H5L_info2_t src_linfo2; /* link info from member object */ h5tool_link_info_t trg_linfo1; h5tool_link_info_t trg_linfo2; /* list for common objects */ trav_table_t *match_list = NULL; - diff_err_t ret_value = H5DIFF_NO_ERR; + diff_err_t ret_value = H5DIFF_NO_ERR; H5TOOLS_START_DEBUG(""); /* init filenames */ @@ -643,28 +634,28 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char HDmemset(&trg_linfo1, 0, sizeof(h5tool_link_info_t)); HDmemset(&trg_linfo2, 0, sizeof(h5tool_link_info_t)); - /*------------------------------------------------------------------------- - * check invalid combination of options - *-----------------------------------------------------------------------*/ - if(!is_valid_options(opts)) + /*------------------------------------------------------------------------- + * check invalid combination of options + *-----------------------------------------------------------------------*/ + if (!is_valid_options(opts)) H5TOOLS_GOTO_DONE(0); - opts->cmn_objs = 1; /* eliminate warning */ + opts->cmn_objs = 1; /* eliminate warning */ opts->err_stat = H5DIFF_NO_ERR; /* initialize error status */ /*------------------------------------------------------------------------- - * open the files first; if they are not valid, no point in continuing - *------------------------------------------------------------------------- - */ + * open the files first; if they are not valid, no point in continuing + *------------------------------------------------------------------------- + */ /* open file 1 */ if (opts->custom_vol[0]) { - if((fapl1_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[0]), NULL)) < 0 ) { + if ((fapl1_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[0]), NULL)) < 0) { parallel_print("h5diff: unable to create fapl for input file\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create input fapl\n"); } } - if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, fapl1_id, FALSE, NULL, (size_t)0)) < 0) { + if ((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, fapl1_id, FALSE, NULL, (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname1); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname1); } @@ -673,22 +664,22 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char /* open file 2 */ if (opts->custom_vol[1]) { - if((fapl2_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[1]), NULL)) < 0 ) { + if ((fapl2_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[1]), NULL)) < 0) { parallel_print("h5diff: unable to create fapl for output file\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create output fapl\n"); } } - if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, fapl2_id, FALSE, NULL, (size_t)0)) < 0) { + if ((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, fapl2_id, FALSE, NULL, (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname2); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname2); } H5TOOLS_DEBUG("file2_id = %s", fname2); /*------------------------------------------------------------------------- - * Initialize the info structs - *------------------------------------------------------------------------- - */ + * Initialize the info structs + *------------------------------------------------------------------------- + */ trav_info_init(fname1, file1_id, &info1_obj); trav_info_init(fname2, file2_id, &info2_obj); @@ -699,11 +690,11 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char if (HDstrncmp(objname1, "/", 1)) { #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ - if(HDasprintf(&obj1fullname, "/%s", objname1) < 0) + if (HDasprintf(&obj1fullname, "/%s", objname1) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed"); -#else /* H5_HAVE_ASPRINTF */ +#else /* H5_HAVE_ASPRINTF */ /* (malloc 2 more for "/" and end-of-line) */ - if ((obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2)) == NULL) + if ((obj1fullname = (char *)HDmalloc(HDstrlen(objname1) + 2)) == NULL) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed"); HDstrcpy(obj1fullname, "/"); @@ -718,11 +709,11 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char if (HDstrncmp(objname2, "/", 1)) { #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ - if(HDasprintf(&obj2fullname, "/%s", objname2) < 0) + if (HDasprintf(&obj2fullname, "/%s", objname2) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed"); -#else /* H5_HAVE_ASPRINTF */ +#else /* H5_HAVE_ASPRINTF */ /* (malloc 2 more for "/" and end-of-line) */ - if ((obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2)) == NULL) + if ((obj2fullname = (char *)HDmalloc(HDstrlen(objname2) + 2)) == NULL) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed"); HDstrcpy(obj2fullname, "/"); HDstrcat(obj2fullname, objname2); @@ -736,17 +727,17 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char * check if obj1 is root, group, single object or symlink */ H5TOOLS_DEBUG("h5diff check if obj1=%s is root, group, single object or symlink", obj1fullname); - if(!HDstrcmp(obj1fullname, "/")) { + if (!HDstrcmp(obj1fullname, "/")) { obj1type = H5TRAV_TYPE_GROUP; } else { /* check if link itself exist */ - if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0) { - parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); + if (H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0) { + parallel_print("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Object could not be found"); } /* get info from link */ - if(H5Lget_info2(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) { + if (H5Lget_info2(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) { parallel_print("Unable to get link info from <%s>\n", obj1fullname); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Lget_info failed"); } @@ -756,13 +747,13 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char /* * check the type of specified path for hard and symbolic links */ - if(src_linfo1.type == H5L_TYPE_HARD) { + if (src_linfo1.type == H5L_TYPE_HARD) { size_t idx; /* optional data pass */ - info1_obj->opts = (diff_opt_t*)opts; + info1_obj->opts = (diff_opt_t *)opts; - if(H5Oget_info_by_name3(file1_id, obj1fullname, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { + if (H5Oget_info_by_name3(file1_id, obj1fullname, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { parallel_print("Error: Could not get file contents\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Could not get file contents"); } @@ -786,17 +777,17 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char * check if obj2 is root, group, single object or symlink */ H5TOOLS_DEBUG("h5diff check if obj2=%s is root, group, single object or symlink", obj2fullname); - if(!HDstrcmp(obj2fullname, "/")) { + if (!HDstrcmp(obj2fullname, "/")) { obj2type = H5TRAV_TYPE_GROUP; } else { /* check if link itself exist */ - if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0) { - parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); + if (H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0) { + parallel_print("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Object could not be found"); } /* get info from link */ - if(H5Lget_info2(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) { + if (H5Lget_info2(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) { parallel_print("Unable to get link info from <%s>\n", obj2fullname); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Lget_info failed"); } @@ -806,13 +797,13 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char /* * check the type of specified path for hard and symbolic links */ - if(src_linfo2.type == H5L_TYPE_HARD) { + if (src_linfo2.type == H5L_TYPE_HARD) { size_t idx; /* optional data pass */ - info2_obj->opts = (diff_opt_t*)opts; + info2_obj->opts = (diff_opt_t *)opts; - if(H5Oget_info_by_name3(file2_id, obj2fullname, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { + if (H5Oget_info_by_name3(file2_id, obj2fullname, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { parallel_print("Error: Could not get file contents\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Could not get file contents"); } @@ -836,10 +827,10 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char else { H5TOOLS_DEBUG("h5diff no object specified"); /* set root group */ - obj1fullname = (char*)HDstrdup("/"); - obj1type = H5TRAV_TYPE_GROUP; - obj2fullname = (char*)HDstrdup("/"); - obj2type = H5TRAV_TYPE_GROUP; + obj1fullname = (char *)HDstrdup("/"); + obj1type = H5TRAV_TYPE_GROUP; + obj2fullname = (char *)HDstrdup("/"); + obj2type = H5TRAV_TYPE_GROUP; } H5TOOLS_DEBUG("get any symbolic links info - errstat:%d", opts->err_stat); @@ -852,7 +843,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char */ if (opts->follow_links) { /* pass how to handle printing warning to linkinfo option */ - if(print_warn(opts)) + if (print_warn(opts)) trg_linfo1.opt.msg_mode = trg_linfo2.opt.msg_mode = 1; /*------------------------------- @@ -864,25 +855,25 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char H5TOOLS_DEBUG("h5diff ... dangling link"); if (opts->no_dangle_links) { /* treat dangling link as error */ - if(opts->mode_verbose) + if (opts->mode_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error"); } else { - if(opts->mode_verbose) + if (opts->mode_verbose) parallel_print("obj1 <%s> is a dangling link.\n", obj1fullname); - if (l_ret1 != 0 || l_ret2 != 0) { + if (l_ret1 != 0 || l_ret2 != 0) { nfound++; print_found(nfound); H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR); } } } - else if(l_ret1 < 0) { /* fail */ - parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); + else if (l_ret1 < 0) { /* fail */ + parallel_print("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Object could not be found"); } - else if(l_ret1 != 2) { /* symbolic link */ + else if (l_ret1 != 2) { /* symbolic link */ obj1type = (h5trav_type_t)trg_linfo1.trg_type; H5TOOLS_DEBUG("h5diff ... ... trg_linfo1.trg_type == H5L_TYPE_HARD"); if (info1_lp != NULL) { @@ -890,7 +881,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char H5TOOLS_DEBUG("h5diff ... ... ... info1_obj not null"); HDmemcpy(&info1_lp->paths[idx].obj_token, &trg_linfo1.obj_token, sizeof(H5O_token_t)); - info1_lp->paths[idx].type = (h5trav_type_t)trg_linfo1.trg_type; + info1_lp->paths[idx].type = (h5trav_type_t)trg_linfo1.trg_type; info1_lp->paths[idx].fileno = trg_linfo1.fileno; } H5TOOLS_DEBUG("h5diff check symbolic link (object1) finished"); @@ -905,12 +896,12 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char H5TOOLS_DEBUG("h5diff ... dangling link"); if (opts->no_dangle_links) { /* treat dangling link as error */ - if(opts->mode_verbose) + if (opts->mode_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error"); } else { - if(opts->mode_verbose) + if (opts->mode_verbose) parallel_print("obj2 <%s> is a dangling link.\n", obj2fullname); if (l_ret1 != 0 || l_ret2 != 0) { nfound++; @@ -919,32 +910,32 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char } } } - else if(l_ret2 < 0) { /* fail */ - parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); + else if (l_ret2 < 0) { /* fail */ + parallel_print("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Object could not be found"); } - else if(l_ret2 != 2) { /* symbolic link */ + else if (l_ret2 != 2) { /* symbolic link */ obj2type = (h5trav_type_t)trg_linfo2.trg_type; if (info2_lp != NULL) { size_t idx = info2_lp->nused - 1; H5TOOLS_DEBUG("h5diff ... ... ... info2_obj not null"); HDmemcpy(&info2_lp->paths[idx].obj_token, &trg_linfo2.obj_token, sizeof(H5O_token_t)); - info2_lp->paths[idx].type = (h5trav_type_t)trg_linfo2.trg_type; + info2_lp->paths[idx].type = (h5trav_type_t)trg_linfo2.trg_type; info2_lp->paths[idx].fileno = trg_linfo2.fileno; } H5TOOLS_DEBUG("h5diff check symbolic link (object1) finished"); } } /* end of if follow symlinks */ - /* - * If verbose options is not used, don't need to traverse through the list - * of objects in the group to display objects information, - * So use h5tools_is_obj_same() to improve performance by skipping - * comparing details of same objects. - */ + /* + * If verbose options is not used, don't need to traverse through the list + * of objects in the group to display objects information, + * So use h5tools_is_obj_same() to improve performance by skipping + * comparing details of same objects. + */ - if(!(opts->mode_verbose || opts->mode_report)) { + if (!(opts->mode_verbose || opts->mode_report)) { H5TOOLS_DEBUG("h5diff NOT (opts->mode_verbose || opts->mode_report)"); /* if no danglink links */ if (l_ret1 > 0 && l_ret2 > 0) @@ -960,10 +951,10 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char */ trav_info_init(fname1, file1_id, &info1_grp); /* optional data pass */ - info1_grp->opts = (diff_opt_t*)opts; + info1_grp->opts = (diff_opt_t *)opts; - if(h5trav_visit(file1_id, obj1fullname, TRUE, TRUE, - trav_grp_objs, trav_grp_symlinks, info1_grp, H5O_INFO_BASIC) < 0) { + if (h5trav_visit(file1_id, obj1fullname, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, info1_grp, + H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not get file contents"); } @@ -974,23 +965,24 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char */ trav_info_init(fname2, file2_id, &info2_grp); /* optional data pass */ - info2_grp->opts = (diff_opt_t*)opts; + info2_grp->opts = (diff_opt_t *)opts; - if(h5trav_visit(file2_id, obj2fullname, TRUE, TRUE, - trav_grp_objs, trav_grp_symlinks, info2_grp, H5O_INFO_BASIC) < 0) { + if (h5trav_visit(file2_id, obj2fullname, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, info2_grp, + H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not get file contents"); - } /* end if */ + } /* end if */ info2_lp = info2_grp; } H5TOOLS_DEBUG("groups traversed - errstat:%d", opts->err_stat); #ifdef H5_HAVE_PARALLEL - if(g_Parallel) { + if (g_Parallel) { int i; - if((HDstrlen(fname1) > MAX_FILENAME) || (HDstrlen(fname2) > MAX_FILENAME)) { - HDfprintf(stderr, "The parallel diff only supports path names up to %d characters\n", MAX_FILENAME); + if ((HDstrlen(fname1) > MAX_FILENAME) || (HDstrlen(fname2) > MAX_FILENAME)) { + HDfprintf(stderr, "The parallel diff only supports path names up to %d characters\n", + MAX_FILENAME); MPI_Abort(MPI_COMM_WORLD, 0); } /* end if */ @@ -998,54 +990,52 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char HDstrcpy(filenames[1], fname2); /* Alert the worker tasks that there's going to be work. */ - for(i = 1; i < g_nTasks; i++) + for (i = 1; i < g_nTasks; i++) MPI_Send(filenames, (MAX_FILENAME * 2), MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD); } /* end if */ #endif H5TOOLS_DEBUG("build_match_list next - errstat:%d", opts->err_stat); /* process the objects */ - build_match_list (obj1fullname, info1_lp, obj2fullname, info2_lp, &match_list, opts); + build_match_list(obj1fullname, info1_lp, obj2fullname, info2_lp, &match_list, opts); H5TOOLS_DEBUG("build_match_list finished - errstat:%d", opts->err_stat); if (both_objs_grp) { /*------------------------------------------------------ * print the list */ - if(opts->mode_verbose) { - unsigned u; + if (opts->mode_verbose) { + unsigned u; - if(opts->mode_verbose_level > 2) { + if (opts->mode_verbose_level > 2) { parallel_print("file1: %s\n", fname1); parallel_print("file2: %s\n", fname2); - } - - parallel_print("\n"); - /* if given objects is group under root */ - if (HDstrcmp (obj1fullname,"/") || HDstrcmp (obj2fullname,"/")) - parallel_print("group1 group2\n"); - else - parallel_print("file1 file2\n"); - parallel_print("---------------------------------------\n"); - for(u = 0; u < match_list->nobjs; u++) { - int c1, c2; - c1 = (match_list->objs[u].flags[0]) ? 'x' : ' '; - c2 = (match_list->objs[u].flags[1]) ? 'x' : ' '; - parallel_print("%5c %6c %-15s\n", c1, c2, match_list->objs[u].name); - } /* end for */ - parallel_print ("\n"); - } /* end if */ + } + + parallel_print("\n"); + /* if given objects is group under root */ + if (HDstrcmp(obj1fullname, "/") || HDstrcmp(obj2fullname, "/")) + parallel_print("group1 group2\n"); + else + parallel_print("file1 file2\n"); + parallel_print("---------------------------------------\n"); + for (u = 0; u < match_list->nobjs; u++) { + int c1, c2; + c1 = (match_list->objs[u].flags[0]) ? 'x' : ' '; + c2 = (match_list->objs[u].flags[1]) ? 'x' : ' '; + parallel_print("%5c %6c %-15s\n", c1, c2, match_list->objs[u].name); + } /* end for */ + parallel_print("\n"); + } /* end if */ } H5TOOLS_DEBUG("diff_match next - errstat:%d", opts->err_stat); - nfound = diff_match(file1_id, obj1fullname, info1_lp, - file2_id, obj2fullname, info2_lp, - match_list, opts); + nfound = diff_match(file1_id, obj1fullname, info1_lp, file2_id, obj2fullname, info2_lp, match_list, opts); H5TOOLS_DEBUG("diff_match nfound: %d - errstat:%d", nfound, opts->err_stat); done: opts->err_stat = opts->err_stat | ret_value; #ifdef H5_HAVE_PARALLEL - if(g_Parallel) + if (g_Parallel) /* All done at this point, let tasks know that they won't be needed */ phdiff_dismiss_workers(); #endif @@ -1081,15 +1071,14 @@ done: H5Pclose(fapl1_id); if (fapl2_id != H5P_DEFAULT) H5Pclose(fapl2_id); - } H5E_END_TRY; + } + H5E_END_TRY; H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat); return nfound; } - - /*------------------------------------------------------------------------- * Function: diff_match * @@ -1107,29 +1096,28 @@ done: *------------------------------------------------------------------------- */ hsize_t -diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, - hid_t file2_id, const char *grp2, trav_info_t *info2, - trav_table_t *table, diff_opt_t *opts) +diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id, const char *grp2, + trav_info_t *info2, trav_table_t *table, diff_opt_t *opts) { - hsize_t nfound = 0; - unsigned i; - const char *grp1_path = ""; - const char *grp2_path = ""; - char *obj1_fullpath = NULL; - char *obj2_fullpath = NULL; - diff_args_t argdata; - size_t idx1 = 0; - size_t idx2 = 0; - diff_err_t ret_value = opts->err_stat; + hsize_t nfound = 0; + unsigned i; + const char *grp1_path = ""; + const char *grp2_path = ""; + char * obj1_fullpath = NULL; + char * obj2_fullpath = NULL; + diff_args_t argdata; + size_t idx1 = 0; + size_t idx2 = 0; + diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); /* * if not root, prepare object name to be pre-appended to group path to * make full path */ - if(HDstrcmp(grp1, "/")) + if (HDstrcmp(grp1, "/")) grp1_path = grp1; - if(HDstrcmp(grp2, "/")) + if (HDstrcmp(grp2, "/")) grp2_path = grp2; /*------------------------------------------------------------------------- @@ -1151,8 +1139,8 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, } /* objects in one file and not the other */ - for(i = 0; i < table->nobjs; i++) { - if(table->objs[i].flags[0] != table->objs[i].flags[1]) { + for (i = 0; i < table->nobjs; i++) { + if (table->objs[i].flags[0] != table->objs[i].flags[1]) { opts->contents = 0; break; } @@ -1165,29 +1153,30 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, */ #ifdef H5_HAVE_PARALLEL { - char *workerTasks = (char*)HDmalloc((size_t)(g_nTasks - 1) * sizeof(char)); - int n; - int busyTasks = 0; - struct diffs_found nFoundbyWorker; + char * workerTasks = (char *)HDmalloc((size_t)(g_nTasks - 1) * sizeof(char)); + int n; + int busyTasks = 0; + struct diffs_found nFoundbyWorker; struct diff_mpi_args args; - int havePrintToken = 1; - MPI_Status Status; + int havePrintToken = 1; + MPI_Status Status; /*set all tasks as free */ HDmemset(workerTasks, 1, (size_t)(g_nTasks - 1) * sizeof(char)); #endif - for(i = 0; i < table->nobjs; i++) { - H5TOOLS_DEBUG("diff for common objects[%d] - errstat:%d", i, opts->err_stat); - if(table->objs[i].flags[0] && table->objs[i].flags[1]) { - /* make full path for obj1 */ + for (i = 0; i < table->nobjs; i++) { + H5TOOLS_DEBUG("diff for common objects[%d] - errstat:%d", i, opts->err_stat); + if (table->objs[i].flags[0] && table->objs[i].flags[1]) { + /* make full path for obj1 */ #ifdef H5_HAVE_ASPRINTF - /* Use the asprintf() routine, since it does what we're trying to do below */ - if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) { - H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); - } -#else /* H5_HAVE_ASPRINTF */ - if((obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) { + /* Use the asprintf() routine, since it does what we're trying to do below */ + if (HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) { + H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); + } +#else /* H5_HAVE_ASPRINTF */ + if ((obj1_fullpath = (char *)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == + NULL) { H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); } else { @@ -1195,16 +1184,17 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, HDstrcat(obj1_fullpath, table->objs[i].name); } #endif /* H5_HAVE_ASPRINTF */ - H5TOOLS_DEBUG("diff_match path1 - %s", obj1_fullpath); + H5TOOLS_DEBUG("diff_match path1 - %s", obj1_fullpath); - /* make full path for obj2 */ + /* make full path for obj2 */ #ifdef H5_HAVE_ASPRINTF - /* Use the asprintf() routine, since it does what we're trying to do below */ - if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) { - H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); - } -#else /* H5_HAVE_ASPRINTF */ - if((obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) { + /* Use the asprintf() routine, since it does what we're trying to do below */ + if (HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) { + H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); + } +#else /* H5_HAVE_ASPRINTF */ + if ((obj2_fullpath = (char *)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == + NULL) { H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); } else { @@ -1212,269 +1202,293 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, HDstrcat(obj2_fullpath, table->objs[i].name); } #endif /* H5_HAVE_ASPRINTF */ - H5TOOLS_DEBUG("diff_match path2 - %s", obj2_fullpath); - - /* get index to figure out type of the object in file1 */ - while(info1->paths[idx1].path && (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0)) - idx1++; - /* get index to figure out type of the object in file2 */ - while(info2->paths[idx2].path && (HDstrcmp(obj2_fullpath, info2->paths[idx2].path) != 0)) - idx2++; - - /* Set argdata to pass other args into diff() */ - argdata.type[0] = info1->paths[idx1].type; - argdata.type[1] = info2->paths[idx2].type; - argdata.is_same_trgobj = table->objs[i].is_same_trgobj; - - opts->cmn_objs = 1; - if(!g_Parallel) { - H5TOOLS_DEBUG("diff paths - errstat:%d", opts->err_stat); - nfound += diff(file1_id, obj1_fullpath, file2_id, obj2_fullpath, opts, &argdata); - } /* end if */ -#ifdef H5_HAVE_PARALLEL - else { - int workerFound = 0; - - H5TOOLS_DEBUG("Beginning of big else block"); - /* We're in parallel mode */ - /* Since the data type of diff value is hsize_t which can - * be arbitary large such that there is no MPI type that - * matches it, the value is passed between processes as - * an array of bytes in order to be portable. But this - * may not work in non-homogeneous MPI environments. - */ - - /*Set up args to pass to worker task. */ - if(HDstrlen(obj1_fullpath) > 255 || - HDstrlen(obj2_fullpath) > 255) { - HDprintf("The parallel diff only supports object names up to 255 characters\n"); - MPI_Abort(MPI_COMM_WORLD, 0); + H5TOOLS_DEBUG("diff_match path2 - %s", obj2_fullpath); + + /* get index to figure out type of the object in file1 */ + while (info1->paths[idx1].path && (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0)) + idx1++; + /* get index to figure out type of the object in file2 */ + while (info2->paths[idx2].path && (HDstrcmp(obj2_fullpath, info2->paths[idx2].path) != 0)) + idx2++; + + /* Set argdata to pass other args into diff() */ + argdata.type[0] = info1->paths[idx1].type; + argdata.type[1] = info2->paths[idx2].type; + argdata.is_same_trgobj = table->objs[i].is_same_trgobj; + + opts->cmn_objs = 1; + if (!g_Parallel) { + H5TOOLS_DEBUG("diff paths - errstat:%d", opts->err_stat); + nfound += diff(file1_id, obj1_fullpath, file2_id, obj2_fullpath, opts, &argdata); } /* end if */ +#ifdef H5_HAVE_PARALLEL + else { + int workerFound = 0; + + H5TOOLS_DEBUG("Beginning of big else block"); + /* We're in parallel mode */ + /* Since the data type of diff value is hsize_t which can + * be arbitary large such that there is no MPI type that + * matches it, the value is passed between processes as + * an array of bytes in order to be portable. But this + * may not work in non-homogeneous MPI environments. + */ - /* set args struct to pass */ - HDstrcpy(args.name1, obj1_fullpath); - HDstrcpy(args.name2, obj2_fullpath); - args.opts = *opts; - args.argdata.type[0] = info1->paths[idx1].type; - args.argdata.type[1] = info2->paths[idx2].type; - args.argdata.is_same_trgobj = table->objs[i].is_same_trgobj; - - /* if there are any outstanding print requests, let's handle one. */ - if(busyTasks > 0) { - int incomingMessage; - - /* check if any tasks freed up, and didn't need to print. */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status); - - /* first block*/ - if(incomingMessage) { - workerTasks[Status.MPI_SOURCE - 1] = 1; - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; + /*Set up args to pass to worker task. */ + if (HDstrlen(obj1_fullpath) > 255 || HDstrlen(obj2_fullpath) > 255) { + HDprintf("The parallel diff only supports object names up to 255 characters\n"); + MPI_Abort(MPI_COMM_WORLD, 0); } /* end if */ - /* check to see if the print token was returned. */ - if(!havePrintToken) { - /* If we don't have the token, someone is probably sending us output */ - print_incoming_data(); + /* set args struct to pass */ + HDstrcpy(args.name1, obj1_fullpath); + HDstrcpy(args.name2, obj2_fullpath); + args.opts = *opts; + args.argdata.type[0] = info1->paths[idx1].type; + args.argdata.type[1] = info2->paths[idx2].type; + args.argdata.is_same_trgobj = table->objs[i].is_same_trgobj; + + /* if there are any outstanding print requests, let's handle one. */ + if (busyTasks > 0) { + int incomingMessage; - /* check incoming queue for token */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + /* check if any tasks freed up, and didn't need to print. */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status); - /* incoming token implies free task. */ - if(incomingMessage) { + /* first block*/ + if (incomingMessage) { workerTasks[Status.MPI_SOURCE - 1] = 1; - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, + MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; - havePrintToken = 1; } /* end if */ - } /* end if */ - - /* check to see if anyone needs the print token. */ - if(havePrintToken) { - /* check incoming queue for print token requests */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) { - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - havePrintToken = 0; - } /* end if */ - } /* end if */ - } /* end if */ - - /* check array of tasks to see which ones are free. - * Manager task never does work, so freeTasks[0] is really - * worker task 0. */ - for(n = 1; (n < g_nTasks) && !workerFound; n++) { - if(workerTasks[n-1]) { - /* send file id's and names to first free worker */ - MPI_Send(&args, sizeof(args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); - /* increment counter for total number of prints. */ - busyTasks++; - - /* mark worker as busy */ - workerTasks[n - 1] = 0; - workerFound = 1; - } /* end if */ - } /* end for */ - - if(!workerFound) { - /* if they were all busy, we've got to wait for one free up - * before we can move on. If we don't have the token, some - * task is currently printing so we'll wait for that task to - * return it. - */ + /* check to see if the print token was returned. */ + if (!havePrintToken) { + /* If we don't have the token, someone is probably sending us output */ + print_incoming_data(); - if(!havePrintToken) { - while(!havePrintToken) { - int incomingMessage; + /* check incoming queue for token */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, + &Status); - print_incoming_data(); - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - havePrintToken = 1; + /* incoming token implies free task. */ + if (incomingMessage) { + workerTasks[Status.MPI_SOURCE - 1] = 1; + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, + MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; - /* send this task the work unit. */ - MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + busyTasks--; + havePrintToken = 1; } /* end if */ - } /* end while */ - } /* end if */ - /* if we do have the token, check for task to free up, or wait for a task to request it */ - else { - /* But first print all the data in our incoming queue */ - print_incoming_data(); - MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; - MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + } /* end if */ + + /* check to see if anyone needs the print token. */ + if (havePrintToken) { + /* check incoming queue for print token requests */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, + &Status); + if (incomingMessage) { + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, + MPI_COMM_WORLD, &Status); + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, + MPI_COMM_WORLD); + havePrintToken = 0; + } /* end if */ + } /* end if */ + } /* end if */ + + /* check array of tasks to see which ones are free. + * Manager task never does work, so freeTasks[0] is really + * worker task 0. */ + for (n = 1; (n < g_nTasks) && !workerFound; n++) { + if (workerTasks[n - 1]) { + /* send file id's and names to first free worker */ + MPI_Send(&args, sizeof(args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); + + /* increment counter for total number of prints. */ + busyTasks++; + + /* mark worker as busy */ + workerTasks[n - 1] = 0; + workerFound = 1; } /* end if */ - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { - int incomingMessage; + } /* end for */ - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + if (!workerFound) { + /* if they were all busy, we've got to wait for one free up + * before we can move on. If we don't have the token, some + * task is currently printing so we'll wait for that task to + * return it. + */ - do { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + if (!havePrintToken) { + while (!havePrintToken) { + int incomingMessage; print_incoming_data(); - } while(!incomingMessage); - - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; - MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); - } /* end else-if */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, + &incomingMessage, &Status); + if (incomingMessage) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, + MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + havePrintToken = 1; + nfound += nFoundbyWorker.nfound; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; + /* send this task the work unit. */ + MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, + MPI_COMM_WORLD); + } /* end if */ + } /* end while */ + } /* end if */ + /* if we do have the token, check for task to free up, or wait for a task to request + * it */ else { - HDprintf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); - MPI_Abort(MPI_COMM_WORLD, 0); - MPI_Finalize(); - } /* end else */ - } /* end else */ - } /* end if */ - } /* end else */ -#endif /* H5_HAVE_PARALLEL */ - if(obj1_fullpath) - HDfree(obj1_fullpath); - if(obj2_fullpath) - HDfree(obj2_fullpath); - } /* end if */ - } /* end for */ - H5TOOLS_DEBUG("done with for loop - errstat:%d", opts->err_stat); + /* But first print all the data in our incoming queue */ + print_incoming_data(); + MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); + if (Status.MPI_TAG == MPI_TAG_DONE) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, + MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; + MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, + MPI_COMM_WORLD); + } /* end if */ + else if (Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { + int incomingMessage; -#ifdef H5_HAVE_PARALLEL - if(g_Parallel) { - /* make sure all tasks are done */ - while(busyTasks > 0) { - MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - } /* end if */ - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - if(havePrintToken) { - int incomingMessage; + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, + MPI_COMM_WORLD, &Status); + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, + MPI_COMM_WORLD); - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, + &incomingMessage, &Status); - do { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + print_incoming_data(); + } while (!incomingMessage); - print_incoming_data(); - } while(!incomingMessage); + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, + MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; + MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, + MPI_COMM_WORLD); + } /* end else-if */ + else { + HDprintf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); + MPI_Abort(MPI_COMM_WORLD, 0); + MPI_Finalize(); + } /* end else */ + } /* end else */ + } /* end if */ + } /* end else */ +#endif /* H5_HAVE_PARALLEL */ + if (obj1_fullpath) + HDfree(obj1_fullpath); + if (obj2_fullpath) + HDfree(obj2_fullpath); + } /* end if */ + } /* end for */ + H5TOOLS_DEBUG("done with for loop - errstat:%d", opts->err_stat); - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); +#ifdef H5_HAVE_PARALLEL + if (g_Parallel) { + /* make sure all tasks are done */ + while (busyTasks > 0) { + MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); + if (Status.MPI_TAG == MPI_TAG_DONE) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, + MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; } /* end if */ - /* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */ - else { - int source = Status.MPI_SOURCE; - int incomingMessage; + else if (Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, + &Status); + if (havePrintToken) { + int incomingMessage; + + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, + &Status); + + print_incoming_data(); + } while (!incomingMessage); - do { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, + MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + } /* end if */ + /* someone else must have it...wait for them to return it, then give it to the task that + * just asked for it. */ + else { + int source = Status.MPI_SOURCE; + int incomingMessage; - print_incoming_data(); - } while(!incomingMessage); + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, + &Status); + print_incoming_data(); + } while (!incomingMessage); - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, + MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + } /* end else */ + } /* end else-if */ + else if (Status.MPI_TAG == MPI_TAG_TOK_RETURN) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, + MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; - MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + havePrintToken = 1; + } /* end else-if */ + else if (Status.MPI_TAG == MPI_TAG_PRINT_DATA) { + char data[PRINT_DATA_MAX_SIZE + 1]; + HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1); + + MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, + MPI_COMM_WORLD, &Status); + + HDprintf("%s", data); + } /* end else-if */ + else { + HDprintf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG); + MPI_Abort(MPI_COMM_WORLD, 0); } /* end else */ - } /* end else-if */ - else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - havePrintToken = 1; - } /* end else-if */ - else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA) { - char data[PRINT_DATA_MAX_SIZE + 1]; - HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1); - - MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status); - - HDprintf("%s", data); - } /* end else-if */ - else { - HDprintf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG); - MPI_Abort(MPI_COMM_WORLD, 0); - } /* end else */ - } /* end while */ + } /* end while */ - for(i = 1; (int)i < g_nTasks; i++) - MPI_Send(NULL, 0, MPI_BYTE, (int)i, MPI_TAG_END, MPI_COMM_WORLD); + for (i = 1; (int)i < g_nTasks; i++) + MPI_Send(NULL, 0, MPI_BYTE, (int)i, MPI_TAG_END, MPI_COMM_WORLD); - /* Print any final data waiting in our queue */ - print_incoming_data(); - } /* end if */ - H5TOOLS_DEBUG("done with if block"); + /* Print any final data waiting in our queue */ + print_incoming_data(); + } /* end if */ + H5TOOLS_DEBUG("done with if block"); - HDfree(workerTasks); + HDfree(workerTasks); } #endif /* H5_HAVE_PARALLEL */ opts->err_stat = opts->err_stat | ret_value; - free_exclude_attr_list (opts); + free_exclude_attr_list(opts); /* free table */ if (table) @@ -1485,7 +1499,6 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, return nfound; } - /*------------------------------------------------------------------------- * Function: diff * @@ -1500,19 +1513,20 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, *------------------------------------------------------------------------- */ hsize_t -diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t *opts, diff_args_t *argdata) +diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t *opts, + diff_args_t *argdata) { - int status = -1; - hid_t dset1_id = H5I_INVALID_HID; - hid_t dset2_id = H5I_INVALID_HID; - hid_t type1_id = H5I_INVALID_HID; - hid_t type2_id = H5I_INVALID_HID; - hid_t grp1_id = H5I_INVALID_HID; - hid_t grp2_id = H5I_INVALID_HID; + int status = -1; + hid_t dset1_id = H5I_INVALID_HID; + hid_t dset2_id = H5I_INVALID_HID; + hid_t type1_id = H5I_INVALID_HID; + hid_t type2_id = H5I_INVALID_HID; + hid_t grp1_id = H5I_INVALID_HID; + hid_t grp2_id = H5I_INVALID_HID; hbool_t is_dangle_link1 = FALSE; hbool_t is_dangle_link2 = FALSE; - hbool_t is_hard_link = FALSE; - hsize_t nfound = 0; + hbool_t is_hard_link = FALSE; + hsize_t nfound = 0; h5trav_type_t object_type; diff_err_t ret_value = opts->err_stat; @@ -1527,15 +1541,13 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ HDmemset(&linkinfo2, 0, sizeof(h5tool_link_info_t)); /* pass how to handle printing warnings to linkinfo option */ - if(print_warn(opts)) + if (print_warn(opts)) linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1; /* for symbolic links, take care follow symlink and no dangling link * options */ - if (argdata->type[0] == H5TRAV_TYPE_LINK || - argdata->type[0] == H5TRAV_TYPE_UDLINK || - argdata->type[1] == H5TRAV_TYPE_LINK || - argdata->type[1] == H5TRAV_TYPE_UDLINK) { + if (argdata->type[0] == H5TRAV_TYPE_LINK || argdata->type[0] == H5TRAV_TYPE_UDLINK || + argdata->type[1] == H5TRAV_TYPE_LINK || argdata->type[1] == H5TRAV_TYPE_UDLINK) { /* * check dangling links for path1 and path2 */ @@ -1549,7 +1561,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ if (status == 0) { if (opts->no_dangle_links) { /* dangling link is error */ - if(opts->mode_verbose) + if (opts->mode_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path1); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error"); } @@ -1564,7 +1576,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ if (status == 0) { if (opts->no_dangle_links) { /* dangling link is error */ - if(opts->mode_verbose) + if (opts->mode_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path2); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error"); } @@ -1579,8 +1591,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ /* follow symbolic link option */ if (opts->follow_links) { - if (linkinfo1.linfo.type == H5L_TYPE_SOFT || - linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) + if (linkinfo1.linfo.type == H5L_TYPE_SOFT || linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) argdata->type[0] = (h5trav_type_t)linkinfo1.trg_type; if (linkinfo2.linfo.type == H5L_TYPE_SOFT || linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) @@ -1590,9 +1601,9 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ /* if objects are not the same type */ if (argdata->type[0] != argdata->type[1]) { H5TOOLS_DEBUG("diff objects are not the same"); - if (opts->mode_verbose||opts->mode_list_not_cmp) { - parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n", - path1, get_type(argdata->type[0]), path2, get_type(argdata->type[1])); + if (opts->mode_verbose || opts->mode_list_not_cmp) { + parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n", path1, + get_type(argdata->type[0]), path2, get_type(argdata->type[1])); } opts->not_cmp = 1; @@ -1612,15 +1623,14 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ * * Perform this to match the outputs as bypassing. */ - if (argdata->is_same_trgobj) { + if (argdata->is_same_trgobj) { H5TOOLS_DEBUG("argdata->is_same_trgobj"); - is_hard_link = (object_type == H5TRAV_TYPE_DATASET || - object_type == H5TRAV_TYPE_NAMED_DATATYPE || + is_hard_link = (object_type == H5TRAV_TYPE_DATASET || object_type == H5TRAV_TYPE_NAMED_DATATYPE || object_type == H5TRAV_TYPE_GROUP); if (opts->follow_links || is_hard_link) { /* print information is only verbose option is used */ - if(opts->mode_verbose || opts->mode_report) { - switch(object_type) { + if (opts->mode_verbose || opts->mode_report) { + switch (object_type) { case H5TRAV_TYPE_DATASET: do_print_objname("dataset", path1, path2, opts); break; @@ -1634,15 +1644,16 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ do_print_objname("link", path1, path2, opts); break; case H5TRAV_TYPE_UDLINK: - if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) + if (linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && + linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) do_print_objname("external link", path1, path2, opts); else - do_print_objname ("user defined link", path1, path2, opts); + do_print_objname("user defined link", path1, path2, opts); break; case H5TRAV_TYPE_UNKNOWN: default: - parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", - path1, path2, get_type(object_type) ); + parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", path1, + path2, get_type(object_type)); opts->not_cmp = 1; break; } /* switch(type)*/ @@ -1655,27 +1666,27 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ } } - switch(object_type) { - /*---------------------------------------------------------------------- - * H5TRAV_TYPE_DATASET - *---------------------------------------------------------------------- - */ + switch (object_type) { + /*---------------------------------------------------------------------- + * H5TRAV_TYPE_DATASET + *---------------------------------------------------------------------- + */ case H5TRAV_TYPE_DATASET: H5TOOLS_DEBUG("diff object type H5TRAV_TYPE_DATASET - errstat:%d", opts->err_stat); - if((dset1_id = H5Dopen2(file1_id, path1, H5P_DEFAULT)) < 0) + if ((dset1_id = H5Dopen2(file1_id, path1, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed"); - if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0) + if ((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed"); H5TOOLS_DEBUG("paths: %s - %s", path1, path2); /* verbose (-v) and report (-r) mode */ - if(opts->mode_verbose || opts->mode_report) { + if (opts->mode_verbose || opts->mode_report) { do_print_objname("dataset", path1, path2, opts); H5TOOLS_DEBUG("call diff_dataset 1:%s 2:%s ", path1, path2); nfound = diff_dataset(file1_id, file2_id, path1, path2, opts); print_found(nfound); } /* quiet mode (-q), just count differences */ - else if(opts->mode_quiet) { + else if (opts->mode_quiet) { nfound = diff_dataset(file1_id, file2_id, path1, path2, opts); } /* the rest (-c, none, ...) */ @@ -1695,39 +1706,39 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ * referenced object *--------------------------------------------------------- */ - if(path1 && !is_exclude_attr(path1, object_type, opts)) { - H5TOOLS_DEBUG( "call diff_attr 1:%s 2:%s ", path1, path2); + if (path1 && !is_exclude_attr(path1, object_type, opts)) { + H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2); nfound += diff_attr(dset1_id, dset2_id, path1, path2, opts); } - if(H5Dclose(dset1_id) < 0) + if (H5Dclose(dset1_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dclose failed"); - if(H5Dclose(dset2_id) < 0) + if (H5Dclose(dset2_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dclose failed"); break; - /*---------------------------------------------------------------------- - * H5TRAV_TYPE_NAMED_DATATYPE - *---------------------------------------------------------------------- - */ + /*---------------------------------------------------------------------- + * H5TRAV_TYPE_NAMED_DATATYPE + *---------------------------------------------------------------------- + */ case H5TRAV_TYPE_NAMED_DATATYPE: H5TOOLS_DEBUG("H5TRAV_TYPE_NAMED_DATATYPE 1:%s 2:%s ", path1, path2); - if((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0) + if ((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Topen2 failed"); - if((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0) + if ((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Topen2 failed"); - if((status = H5Tequal(type1_id, type2_id)) < 0) + if ((status = H5Tequal(type1_id, type2_id)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tequal failed"); /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ nfound = (status > 0) ? 0 : 1; - if(print_objname(opts, nfound)) + if (print_objname(opts, nfound)) do_print_objname("datatype", path1, path2, opts); /* always print the number of differences found in verbose mode */ - if(opts->mode_verbose) + if (opts->mode_verbose) print_found(nfound); /*----------------------------------------------------------------- @@ -1736,33 +1747,33 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ * referenced object *----------------------------------------------------------------- */ - if(path1 && !is_exclude_attr(path1, object_type, opts)) { + if (path1 && !is_exclude_attr(path1, object_type, opts)) { H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2); nfound += diff_attr(type1_id, type2_id, path1, path2, opts); } - if(H5Tclose(type1_id) < 0) + if (H5Tclose(type1_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose failed"); - if(H5Tclose(type2_id) < 0) + if (H5Tclose(type2_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose failed"); break; - /*---------------------------------------------------------------------- - * H5TRAV_TYPE_GROUP - *---------------------------------------------------------------------- - */ + /*---------------------------------------------------------------------- + * H5TRAV_TYPE_GROUP + *---------------------------------------------------------------------- + */ case H5TRAV_TYPE_GROUP: H5TOOLS_DEBUG("H5TRAV_TYPE_GROUP 1:%s 2:%s ", path1, path2); - if(print_objname(opts, nfound)) + if (print_objname(opts, nfound)) do_print_objname("group", path1, path2, opts); /* always print the number of differences found in verbose mode */ - if(opts->mode_verbose) + if (opts->mode_verbose) print_found(nfound); - if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) + if ((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed"); - if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) + if ((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed"); /*----------------------------------------------------------------- @@ -1771,97 +1782,92 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ * referenced object *----------------------------------------------------------------- */ - if(path1 && !is_exclude_attr(path1, object_type, opts)) { + if (path1 && !is_exclude_attr(path1, object_type, opts)) { H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2); nfound += diff_attr(grp1_id, grp2_id, path1, path2, opts); } - if(H5Gclose(grp1_id) < 0) + if (H5Gclose(grp1_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed"); - if(H5Gclose(grp2_id) < 0) + if (H5Gclose(grp2_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed"); break; + /*---------------------------------------------------------------------- + * H5TRAV_TYPE_LINK + *---------------------------------------------------------------------- + */ + case H5TRAV_TYPE_LINK: { + H5TOOLS_DEBUG("H5TRAV_TYPE_LINK 1:%s 2:%s ", path1, path2); + status = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path); - /*---------------------------------------------------------------------- - * H5TRAV_TYPE_LINK - *---------------------------------------------------------------------- - */ - case H5TRAV_TYPE_LINK: - { - H5TOOLS_DEBUG("H5TRAV_TYPE_LINK 1:%s 2:%s ", path1, path2); - status = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path); + /* if the target link name is not same then the links are "different" */ + nfound = (status != 0) ? 1 : 0; - /* if the target link name is not same then the links are "different" */ - nfound = (status != 0) ? 1 : 0; + if (print_objname(opts, nfound)) + do_print_objname("link", path1, path2, opts); - if(print_objname(opts, nfound)) - do_print_objname("link", path1, path2, opts); + /* always print the number of differences found in verbose mode */ + if (opts->mode_verbose) + print_found(nfound); + } break; - /* always print the number of differences found in verbose mode */ - if(opts->mode_verbose) - print_found(nfound); + /*---------------------------------------------------------------------- + * H5TRAV_TYPE_UDLINK + *---------------------------------------------------------------------- + */ + case H5TRAV_TYPE_UDLINK: { + H5TOOLS_DEBUG("H5TRAV_TYPE_UDLINK 1:%s 2:%s ", path1, path2); + /* Only external links will have a query function registered */ + if (linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) { + /* If the buffers are the same size, compare them */ + if (linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size) { + status = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size); } - break; - - /*---------------------------------------------------------------------- - * H5TRAV_TYPE_UDLINK - *---------------------------------------------------------------------- - */ - case H5TRAV_TYPE_UDLINK: - { - H5TOOLS_DEBUG("H5TRAV_TYPE_UDLINK 1:%s 2:%s ", path1, path2); - /* Only external links will have a query function registered */ - if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) { - /* If the buffers are the same size, compare them */ - if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size) { - status = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size); - } - else - status = 1; + else + status = 1; - /* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links - * are "different" extlinkinfo#.path is combination string of - * file_name and obj_name - */ - nfound = (status != 0) ? 1 : 0; + /* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links + * are "different" extlinkinfo#.path is combination string of + * file_name and obj_name + */ + nfound = (status != 0) ? 1 : 0; - if(print_objname(opts, nfound)) - do_print_objname("external link", path1, path2, opts); + if (print_objname(opts, nfound)) + do_print_objname("external link", path1, path2, opts); - } /* end if */ - else { - /* If one or both of these links isn't an external link, we can only - * compare information from H5Lget_info since we don't have a query - * function registered for them. - * - * If the link classes or the buffer length are not the - * same, the links are "different" - */ - if((linkinfo1.linfo.type != linkinfo2.linfo.type) || + } /* end if */ + else { + /* If one or both of these links isn't an external link, we can only + * compare information from H5Lget_info since we don't have a query + * function registered for them. + * + * If the link classes or the buffer length are not the + * same, the links are "different" + */ + if ((linkinfo1.linfo.type != linkinfo2.linfo.type) || (linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size)) - nfound = 1; - else - nfound = 0; + nfound = 1; + else + nfound = 0; - if (print_objname (opts, nfound)) - do_print_objname ("user defined link", path1, path2, opts); - } /* end else */ + if (print_objname(opts, nfound)) + do_print_objname("user defined link", path1, path2, opts); + } /* end else */ - /* always print the number of differences found in verbose mode */ - if(opts->mode_verbose) - print_found(nfound); - } - break; + /* always print the number of differences found in verbose mode */ + if (opts->mode_verbose) + print_found(nfound); + } break; case H5TRAV_TYPE_UNKNOWN: default: - if(opts->mode_verbose) - parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", - path1, path2, get_type(object_type) ); + if (opts->mode_verbose) + parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", path1, path2, + get_type(object_type)); opts->not_cmp = 1; break; - } + } done: opts->err_stat = opts->err_stat | ret_value; @@ -1870,26 +1876,26 @@ done: * handle dangling link(s) */ /* both path1 and path2 are dangling links */ - if(is_dangle_link1 && is_dangle_link2) { - if(print_objname(opts, nfound)) { + if (is_dangle_link1 && is_dangle_link2) { + if (print_objname(opts, nfound)) { do_print_objname("dangling link", path1, path2, opts); print_found(nfound); } } /* path1 is dangling link */ else if (is_dangle_link1) { - if(opts->mode_verbose) - parallel_print("obj1 <%s> is a dangling link.\n", path1); + if (opts->mode_verbose) + parallel_print("obj1 <%s> is a dangling link.\n", path1); nfound++; - if(print_objname(opts, nfound)) + if (print_objname(opts, nfound)) print_found(nfound); } /* path2 is dangling link */ else if (is_dangle_link2) { - if(opts->mode_verbose) + if (opts->mode_verbose) parallel_print("obj2 <%s> is a dangling link.\n", path2); nfound++; - if(print_objname(opts, nfound)) + if (print_objname(opts, nfound)) print_found(nfound); } @@ -1901,7 +1907,8 @@ done: /* close */ /* disable error reporting */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dset1_id); H5Dclose(dset2_id); H5Tclose(type1_id); @@ -1909,10 +1916,10 @@ done: H5Gclose(grp1_id); H5Gclose(grp2_id); /* enable error reporting */ - } H5E_END_TRY; + } + H5E_END_TRY; H5TOOLS_ENDDEBUG(": %d - errstat:%d", nfound, opts->err_stat); return nfound; } - diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index f44f653..b8a50da 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -27,8 +27,8 @@ * as it doesn't require interface change. *------------------------------------------------------------------------*/ typedef struct { - h5trav_type_t type[2]; - hbool_t is_same_trgobj; + h5trav_type_t type[2]; + hbool_t is_same_trgobj; } diff_args_t; /*------------------------------------------------------------------------- * command line options @@ -36,12 +36,11 @@ typedef struct { */ /* linked list to keep exclude path list */ struct exclude_path_list { - const char *obj_path; - h5trav_type_t obj_type; - struct exclude_path_list *next; + const char * obj_path; + h5trav_type_t obj_type; + struct exclude_path_list *next; }; - /* Enumeration value for keeping track of whether an error occurred or differences were found */ typedef enum { H5DIFF_NO_ERR, /* No error occurred */ @@ -50,50 +49,49 @@ typedef enum { } diff_err_t; typedef struct { - int mode_quiet; /* quiet mode: no output at all */ - int mode_report; /* report mode: print the data */ - int mode_verbose; /* verbose mode: print the data, list of objcets, warnings */ - int mode_verbose_level; /* control verbose details */ - int mode_list_not_cmp; /* list not comparable messages */ - int print_header; /* print header */ - int print_percentage; /* print percentage */ - int print_dims; /* print dimension index */ - int delta_bool; /* delta, absolute value to compare */ - double delta; /* delta value */ - int use_system_epsilon; /* flag to use system epsilon (1 or 0) */ - int percent_bool; /* relative error to compare*/ - double percent; /* relative error value */ - hbool_t follow_links; /* follow symbolic links */ - int no_dangle_links; /* return error when find dangling link */ - int cmn_objs; /* do we have common objects */ - int not_cmp; /* are the objects comparable */ - int contents; /* equal contents */ - int do_nans; /* consider Nans while diffing floats */ - int exclude_path; /* exclude path to an object */ - int exclude_attr_path; /* exclude path to an object */ - struct exclude_path_list *exclude; /* keep exclude path list */ - struct exclude_path_list *exclude_attr; /* keep exclude attribute list */ - int count_bool; /* count, compare up to count */ - hsize_t count; /* count value */ - diff_err_t err_stat; /* an error ocurred (2, error, 1, differences, 0, no error) */ - hsize_t nelmts; /* total number of elements */ - hsize_t hs_nelmts; /* number of elements to read at a time*/ - int rank; /* dimensionality */ - size_t m_size; /* m_size for diff */ - hid_t m_tid; /* m_tid for diff */ - hsize_t dims[H5S_MAX_RANK]; /* dimensions of object */ - hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */ - hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */ - hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ - hsize_t pos[H5S_MAX_RANK]; /* matrix position */ - hsize_t sm_pos[H5S_MAX_RANK]; /* stripmine position */ - char *obj_name[2]; /* name for object */ - struct subset_t *sset[2]; /* subsetting parameters */ - h5tools_vol_info_t vol_info[2]; /* VOL information for input file, output file */ - hbool_t custom_vol[2]; /* Using a custom input, output VOL? */ + int mode_quiet; /* quiet mode: no output at all */ + int mode_report; /* report mode: print the data */ + int mode_verbose; /* verbose mode: print the data, list of objcets, warnings */ + int mode_verbose_level; /* control verbose details */ + int mode_list_not_cmp; /* list not comparable messages */ + int print_header; /* print header */ + int print_percentage; /* print percentage */ + int print_dims; /* print dimension index */ + int delta_bool; /* delta, absolute value to compare */ + double delta; /* delta value */ + int use_system_epsilon; /* flag to use system epsilon (1 or 0) */ + int percent_bool; /* relative error to compare*/ + double percent; /* relative error value */ + hbool_t follow_links; /* follow symbolic links */ + int no_dangle_links; /* return error when find dangling link */ + int cmn_objs; /* do we have common objects */ + int not_cmp; /* are the objects comparable */ + int contents; /* equal contents */ + int do_nans; /* consider Nans while diffing floats */ + int exclude_path; /* exclude path to an object */ + int exclude_attr_path; /* exclude path to an object */ + struct exclude_path_list *exclude; /* keep exclude path list */ + struct exclude_path_list *exclude_attr; /* keep exclude attribute list */ + int count_bool; /* count, compare up to count */ + hsize_t count; /* count value */ + diff_err_t err_stat; /* an error ocurred (2, error, 1, differences, 0, no error) */ + hsize_t nelmts; /* total number of elements */ + hsize_t hs_nelmts; /* number of elements to read at a time*/ + int rank; /* dimensionality */ + size_t m_size; /* m_size for diff */ + hid_t m_tid; /* m_tid for diff */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of object */ + hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */ + hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */ + hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ + hsize_t pos[H5S_MAX_RANK]; /* matrix position */ + hsize_t sm_pos[H5S_MAX_RANK]; /* stripmine position */ + char * obj_name[2]; /* name for object */ + struct subset_t * sset[2]; /* subsetting parameters */ + h5tools_vol_info_t vol_info[2]; /* VOL information for input file, output file */ + hbool_t custom_vol[2]; /* Using a custom input, output VOL? */ } diff_opt_t; - /*------------------------------------------------------------------------- * public functions *------------------------------------------------------------------------- @@ -103,9 +101,11 @@ typedef struct { extern "C" { #endif -H5TOOLS_DLL hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, diff_opt_t *opts); +H5TOOLS_DLL hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, + diff_opt_t *opts); -H5TOOLS_DLL hsize_t diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t *opts, diff_args_t *argdata); +H5TOOLS_DLL hsize_t diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, + diff_opt_t *opts, diff_args_t *argdata); #ifdef H5_HAVE_PARALLEL H5TOOLS_DLL void phdiff_dismiss_workers(void); @@ -116,38 +116,29 @@ H5TOOLS_DLL void print_manager_output(void); } #endif - - /*------------------------------------------------------------------------- * private functions *------------------------------------------------------------------------- */ +hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, + diff_opt_t *opts); -hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, - const char *obj1_name, const char *obj2_name, diff_opt_t *opts); +hsize_t diff_datasetid(hid_t dset1_id, hid_t dset2_id, const char *obj1_name, const char *obj2_name, + diff_opt_t *opts); -hsize_t diff_datasetid(hid_t dset1_id, hid_t dset2_id, - const char *obj1_name, const char *obj2_name, diff_opt_t *opts); +hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id, const char *grp2, + trav_info_t *info2, trav_table_t *table, diff_opt_t *opts); +hsize_t diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_t container2_id); -hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, - hid_t file2_id, const char *grp2, trav_info_t *info2, - trav_table_t *table, diff_opt_t *opts); - -hsize_t diff_array(void *_mem1, void *_mem2, - diff_opt_t *opts, hid_t container1_id, hid_t container2_id); - -int diff_can_type(hid_t f_type1, hid_t f_type2, int rank1, int rank2, - hsize_t *dims1, hsize_t *dims2, hsize_t *maxdim1, hsize_t *maxdim2, - diff_opt_t *opts, int is_compound); +int diff_can_type(hid_t f_type1, hid_t f_type2, int rank1, int rank2, hsize_t *dims1, hsize_t *dims2, + hsize_t *maxdim1, hsize_t *maxdim2, diff_opt_t *opts, int is_compound); hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2, - const char *path1, const char *path2, diff_opt_t *opts); - -hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, - const char *path1, const char *path2, diff_opt_t *opts); + const char *path1, const char *path2, diff_opt_t *opts); +hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, diff_opt_t *opts); /*------------------------------------------------------------------------- * utility functions @@ -157,18 +148,16 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, /* in h5diff_util.c */ void print_found(hsize_t nfound); void print_type(hid_t type); -const char* diff_basename(const char *name); -const char* get_type(h5trav_type_t type); -const char* get_class(H5T_class_t tclass); -const char* get_sign(H5T_sign_t sign); -void print_dimensions (int rank, hsize_t *dims); -herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id, - hid_t *m_tid1, hid_t *m_tid2, - size_t *m_size1, size_t *m_size2); +const char *diff_basename(const char *name); +const char *get_type(h5trav_type_t type); +const char *get_class(H5T_class_t tclass); +const char *get_sign(H5T_sign_t sign); +void print_dimensions(int rank, hsize_t *dims); +herr_t match_up_memsize(hid_t f_tid1_id, hid_t f_tid2_id, hid_t *m_tid1, hid_t *m_tid2, size_t *m_size1, + size_t *m_size2); /* in h5diff.c */ -int print_objname(diff_opt_t *opts, hsize_t nfound); -void do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts); -void do_print_attrname (const char *attr, const char *path1, const char *path2); - -#endif /* H5DIFF_H__ */ +int print_objname(diff_opt_t *opts, hsize_t nfound); +void do_print_objname(const char *OBJ, const char *path1, const char *path2, diff_opt_t *opts); +void do_print_attrname(const char *attr, const char *path1, const char *path2); +#endif /* H5DIFF_H__ */ diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 1a4c727..dbc6691 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -24,48 +24,52 @@ *------------------------------------------------------------------------- */ -#define F_FORMAT "%-15g %-15g %-15g\n" +#define F_FORMAT "%-15g %-15g %-15g\n" -#if H5_SIZEOF_LONG_DOUBLE !=0 -#define LD_FORMAT "%-15Lf %-15Lf %-15Lf\n" +#if H5_SIZEOF_LONG_DOUBLE != 0 +#define LD_FORMAT "%-15Lf %-15Lf %-15Lf\n" #endif -#define I_FORMAT "%-15d %-15d %-15d\n" -#define S_FORMAT "%-16s %-17s\n" -#define UI_FORMAT "%-15u %-15u %-15u\n" -#define LI_FORMAT "%-15ld %-15ld %-15ld\n" -#define ULI_FORMAT "%-15lu %-15lu %-15lu\n" -#define LLI_FORMAT "%-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d\n" -#define ULLI_FORMAT "%-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u\n" +#define I_FORMAT "%-15d %-15d %-15d\n" +#define S_FORMAT "%-16s %-17s\n" +#define UI_FORMAT "%-15u %-15u %-15u\n" +#define LI_FORMAT "%-15ld %-15ld %-15ld\n" +#define ULI_FORMAT "%-15lu %-15lu %-15lu\n" +#define LLI_FORMAT "%-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d\n" +#define ULLI_FORMAT "%-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u\n" /* with -p option */ -#define F_FORMAT_P "%-15.10g %-15.10g %-15.10g %-14.10g\n" +#define F_FORMAT_P "%-15.10g %-15.10g %-15.10g %-14.10g\n" -#if H5_SIZEOF_LONG_DOUBLE !=0 -#define LD_FORMAT_P "%-15.10Lf %-15.10Lf %-15.10Lf %-14.10Lf\n" +#if H5_SIZEOF_LONG_DOUBLE != 0 +#define LD_FORMAT_P "%-15.10Lf %-15.10Lf %-15.10Lf %-14.10Lf\n" #endif -#define I_FORMAT_P "%-15d %-15d %-15d %-14f\n" -#define UI_FORMAT_P "%-15u %-15u %-15u %-14f\n" -#define LI_FORMAT_P "%-15ld %-15ld %-15ld %-14f\n" -#define ULI_FORMAT_P "%-15lu %-15lu %-15lu %-14f\n" -#define LLI_FORMAT_P "%-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-14f\n" -#define ULLI_FORMAT_P "%-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "d %-14f\n" -#define SPACES " " +#define I_FORMAT_P "%-15d %-15d %-15d %-14f\n" +#define UI_FORMAT_P "%-15u %-15u %-15u %-14f\n" +#define LI_FORMAT_P "%-15ld %-15ld %-15ld %-14f\n" +#define ULI_FORMAT_P "%-15lu %-15lu %-15lu %-14f\n" +#define LLI_FORMAT_P \ + "%-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-14f\n" +#define ULLI_FORMAT_P \ + "%-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "d %-14f\n" +#define SPACES " " /* not comparable */ -#define F_FORMAT_P_NOTCOMP "%-15.10g %-15.10g %-15.10g not comparable\n" +#define F_FORMAT_P_NOTCOMP "%-15.10g %-15.10g %-15.10g not comparable\n" -#if H5_SIZEOF_LONG_DOUBLE !=0 -#define LD_FORMAT_P_NOTCOMP "%-15.10Lf %-15.10Lf %-15.10Lf not comparable\n" +#if H5_SIZEOF_LONG_DOUBLE != 0 +#define LD_FORMAT_P_NOTCOMP "%-15.10Lf %-15.10Lf %-15.10Lf not comparable\n" #endif -#define I_FORMAT_P_NOTCOMP "%-15d %-15d %-15d not comparable\n" -#define UI_FORMAT_P_NOTCOMP "%-15u %-15u %-15u not comparable\n" -#define LI_FORMAT_P_NOTCOMP "%-15ld %-15ld %-15ld not comparable\n" -#define ULI_FORMAT_P_NOTCOMP "%-15lu %-15lu %-15lu not comparable\n" -#define LLI_FORMAT_P_NOTCOMP "%-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d not comparable\n" -#define ULLI_FORMAT_P_NOTCOMP "%-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "d not comparable\n" +#define I_FORMAT_P_NOTCOMP "%-15d %-15d %-15d not comparable\n" +#define UI_FORMAT_P_NOTCOMP "%-15u %-15u %-15u not comparable\n" +#define LI_FORMAT_P_NOTCOMP "%-15ld %-15ld %-15ld not comparable\n" +#define ULI_FORMAT_P_NOTCOMP "%-15lu %-15lu %-15lu not comparable\n" +#define LLI_FORMAT_P_NOTCOMP \ + "%-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d %-15" H5_PRINTF_LL_WIDTH "d not comparable\n" +#define ULLI_FORMAT_P_NOTCOMP \ + "%-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "d not comparable\n" /* if system EPSILON is defined, use the system EPSILON; otherwise, use constants that are close to most EPSILON values */ @@ -95,36 +99,38 @@ static hbool_t not_comparable; -#define PER(A,B) { \ - per = -1; \ - not_comparable = FALSE; \ - both_zero = FALSE; \ - if(H5_DBL_ABS_EQUAL(0, (double)A) && H5_DBL_ABS_EQUAL(0, (double)B)) \ - both_zero = TRUE; \ - if(!H5_DBL_ABS_EQUAL(0, (double)A)) \ - per = (double)ABS((double)((B) - (A)) / (double)(A)); \ - else \ - not_comparable = TRUE; \ -} - -#define PER_UNSIGN(TYPE,A,B) { \ - per = -1; \ - not_comparable = FALSE; \ - both_zero = FALSE; \ - if(H5_DBL_ABS_EQUAL(0, (double)A) && H5_DBL_ABS_EQUAL(0, (double)B)) \ - both_zero = TRUE; \ - if(!H5_DBL_ABS_EQUAL(0, (double)A)) \ - per = ABS((double)((TYPE)((B) - (A))) / (double)(A)) ; \ - else \ - not_comparable = TRUE; \ -} - -#define PDIFF(a,b) (((b) > (a)) ? ((b) - (a)) : ((a) -(b))) +#define PER(A, B) \ + { \ + per = -1; \ + not_comparable = FALSE; \ + both_zero = FALSE; \ + if (H5_DBL_ABS_EQUAL(0, (double)A) && H5_DBL_ABS_EQUAL(0, (double)B)) \ + both_zero = TRUE; \ + if (!H5_DBL_ABS_EQUAL(0, (double)A)) \ + per = (double)ABS((double)((B) - (A)) / (double)(A)); \ + else \ + not_comparable = TRUE; \ + } + +#define PER_UNSIGN(TYPE, A, B) \ + { \ + per = -1; \ + not_comparable = FALSE; \ + both_zero = FALSE; \ + if (H5_DBL_ABS_EQUAL(0, (double)A) && H5_DBL_ABS_EQUAL(0, (double)B)) \ + both_zero = TRUE; \ + if (!H5_DBL_ABS_EQUAL(0, (double)A)) \ + per = ABS((double)((TYPE)((B) - (A))) / (double)(A)); \ + else \ + not_comparable = TRUE; \ + } + +#define PDIFF(a, b) (((b) > (a)) ? ((b) - (a)) : ((a) - (b))) typedef struct mcomp_t { - unsigned n; /* number of members */ - hid_t *ids; /* member type id */ - size_t *offsets; + unsigned n; /* number of members */ + hid_t * ids; /* member type id */ + size_t * offsets; struct mcomp_t **m; /* members */ } mcomp_t; @@ -133,59 +139,65 @@ typedef struct mcomp_t { *------------------------------------------------------------------------- */ static hbool_t all_zero(const void *_mem, size_t size); -static int ull2float(unsigned long long ull_value, float *f_value); +static int ull2float(unsigned long long ull_value, float *f_value); static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t u, diff_opt_t *opts); -static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, diff_opt_t *opts); +static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, + diff_opt_t *opts); static hbool_t equal_float(float value, float expected, diff_opt_t *opts); static hbool_t equal_double(double value, double expected, diff_opt_t *opts); -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts); #endif -static int print_data(diff_opt_t *opts); +static int print_data(diff_opt_t *opts); static void print_pos(diff_opt_t *opts, hsize_t elemtno, size_t u); static void h5diff_print_char(char ch); -static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts); -static hsize_t diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, - hid_t container1_id, hid_t container2_id, mcomp_t *members); +static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, + diff_opt_t *opts); +static hsize_t diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t container1_id, + hid_t container2_id, mcomp_t *members); /* element diffs */ -static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -#if H5_SIZEOF_LONG_DOUBLE !=0 -static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +#if H5_SIZEOF_LONG_DOUBLE != 0 +static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); #endif -static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); /*------------------------------------------------------------------------- * NaN detection *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE !=0 -typedef enum dtype_t -{ - FLT_FLOAT, - FLT_DOUBLE, - FLT_LDOUBLE -}dtype_t; +#if H5_SIZEOF_LONG_DOUBLE != 0 +typedef enum dtype_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE } dtype_t; #else -typedef enum dtype_t { - FLT_FLOAT, FLT_DOUBLE -} dtype_t; +typedef enum dtype_t { FLT_FLOAT, FLT_DOUBLE } dtype_t; #endif - /*------------------------------------------------------------------------- * XCAO, 11/10/2010 * added to improve performance for compound datasets @@ -205,209 +217,207 @@ static void close_member_types(mcomp_t *members); hsize_t diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_t container2_id) { - hsize_t nfound = 0; /* number of differences found */ - size_t size; /* size of datum */ - unsigned char *mem1 = (unsigned char*) _mem1; - unsigned char *mem2 = (unsigned char*) _mem2; - hsize_t i; - mcomp_t members; - H5T_class_t type_class; + hsize_t nfound = 0; /* number of differences found */ + size_t size; /* size of datum */ + unsigned char *mem1 = (unsigned char *)_mem1; + unsigned char *mem2 = (unsigned char *)_mem2; + hsize_t i; + mcomp_t members; + H5T_class_t type_class; H5TOOLS_START_DEBUG(" - rank:%d hs_nelmts:%ld errstat:%d", opts->rank, opts->hs_nelmts, opts->err_stat); opts->print_header = 1; /* enable print header */ /* get the size. */ - size = H5Tget_size(opts->m_tid); + size = H5Tget_size(opts->m_tid); type_class = H5Tget_class(opts->m_tid); /* Fast comparison first for atomic type by memcmp(). * It is OK not to list non-atomic type here because it will not be caught * by the condition, but it gives more clarity for code planning */ - if (type_class != H5T_REFERENCE && - type_class != H5T_COMPOUND && - type_class != H5T_STRING && - type_class != H5T_VLEN && - HDmemcmp(mem1, mem2, size * opts->hs_nelmts) == 0) { + if (type_class != H5T_REFERENCE && type_class != H5T_COMPOUND && type_class != H5T_STRING && + type_class != H5T_VLEN && HDmemcmp(mem1, mem2, size * opts->hs_nelmts) == 0) { H5TOOLS_ENDDEBUG(":Fast comparison - errstat:%d", opts->err_stat); return 0; } H5TOOLS_DEBUG("type_class:%d", type_class); switch (type_class) { - case H5T_NO_CLASS: - case H5T_TIME: - case H5T_NCLASSES: - default: - H5TOOLS_DEBUG("type_class:INVALID"); - HDassert(0); - break; + case H5T_NO_CLASS: + case H5T_TIME: + case H5T_NCLASSES: + default: + H5TOOLS_DEBUG("type_class:INVALID"); + HDassert(0); + break; - /*------------------------------------------------------------------------- - * float and integer atomic types - *------------------------------------------------------------------------- - */ - case H5T_FLOAT: - H5TOOLS_DEBUG("type_class:H5T_FLOAT"); - if (H5Tequal(opts->m_tid, H5T_NATIVE_FLOAT)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_float_element(mem1, mem2, i, opts); - - mem1 += sizeof(float); - mem2 += sizeof(float); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_DOUBLE)){ - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_double_element(mem1, mem2, i, opts); - - mem1 += sizeof(double); - mem2 += sizeof(double); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } + /*------------------------------------------------------------------------- + * float and integer atomic types + *------------------------------------------------------------------------- + */ + case H5T_FLOAT: + H5TOOLS_DEBUG("type_class:H5T_FLOAT"); + if (H5Tequal(opts->m_tid, H5T_NATIVE_FLOAT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_float_element(mem1, mem2, i, opts); + + mem1 += sizeof(float); + mem2 += sizeof(float); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_DOUBLE)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_double_element(mem1, mem2, i, opts); + + mem1 += sizeof(double); + mem2 += sizeof(double); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } #if H5_SIZEOF_LONG_DOUBLE != 0 - else if (H5Tequal(opts->m_tid, H5T_NATIVE_LDOUBLE)) { - for ( i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_ldouble_element(mem1, mem2, i, opts); + else if (H5Tequal(opts->m_tid, H5T_NATIVE_LDOUBLE)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_ldouble_element(mem1, mem2, i, opts); - mem1 += sizeof(long double); - mem2 += sizeof(long double); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } + mem1 += sizeof(long double); + mem2 += sizeof(long double); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } #endif - break; - - case H5T_INTEGER: - H5TOOLS_DEBUG("type_class:H5T_INTEGER"); - if (H5Tequal(opts->m_tid, H5T_NATIVE_SCHAR)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_schar_element(mem1, mem2, i, opts); - mem1 += sizeof(char); - mem2 += sizeof(char); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_UCHAR)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_uchar_element(mem1, mem2, i, opts); - - mem1 += sizeof(unsigned char); - mem2 += sizeof(unsigned char); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_SHORT)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_short_element(mem1, mem2, i, opts); - - mem1 += sizeof(short); - mem2 += sizeof(short); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_USHORT)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_ushort_element(mem1, mem2, i, opts); - - mem1 += sizeof(unsigned short); - mem2 += sizeof(unsigned short); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_INT)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_int_element(mem1, mem2, i, opts); - - mem1 += sizeof(int); - mem2 += sizeof(int); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_UINT)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_int_element(mem1, mem2, i, opts); + break; + + case H5T_INTEGER: + H5TOOLS_DEBUG("type_class:H5T_INTEGER"); + if (H5Tequal(opts->m_tid, H5T_NATIVE_SCHAR)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_schar_element(mem1, mem2, i, opts); + mem1 += sizeof(char); + mem2 += sizeof(char); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_UCHAR)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_uchar_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned char); + mem2 += sizeof(unsigned char); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_SHORT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_short_element(mem1, mem2, i, opts); + + mem1 += sizeof(short); + mem2 += sizeof(short); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_USHORT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_ushort_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned short); + mem2 += sizeof(unsigned short); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_INT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_int_element(mem1, mem2, i, opts); + + mem1 += sizeof(int); + mem2 += sizeof(int); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_UINT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_int_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned int); + mem2 += sizeof(unsigned int); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_LONG)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_long_element(mem1, mem2, i, opts); + + mem1 += sizeof(long); + mem2 += sizeof(long); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULONG)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_ulong_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned long); + mem2 += sizeof(unsigned long); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_LLONG)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_llong_element(mem1, mem2, i, opts); + + mem1 += sizeof(long long); + mem2 += sizeof(long long); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULLONG)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_ullong_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned long long); + mem2 += sizeof(unsigned long long); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + break; - mem1 += sizeof(unsigned int); - mem2 += sizeof(unsigned int); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_LONG)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_long_element(mem1, mem2, i, opts); - - mem1 += sizeof(long); - mem2 += sizeof(long); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULONG)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_ulong_element(mem1, mem2, i, opts); - - mem1 += sizeof(unsigned long); - mem2 += sizeof(unsigned long); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_LLONG)) { - for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_llong_element(mem1, mem2, i, opts); - - mem1 += sizeof(long long); - mem2 += sizeof(long long); - if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULLONG)) { + /*------------------------------------------------------------------------- + * Other types than float and integer + *------------------------------------------------------------------------- + */ + case H5T_COMPOUND: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + case H5T_VLEN: + case H5T_REFERENCE: + H5TOOLS_DEBUG("type_class:OTHER"); + HDmemset(&members, 0, sizeof(mcomp_t)); + get_member_types(opts->m_tid, &members); for (i = 0; i < opts->hs_nelmts; i++) { - nfound += diff_ullong_element(mem1, mem2, i, opts); - - mem1 += sizeof(unsigned long long); - mem2 += sizeof(unsigned long long); + H5TOOLS_DEBUG("opts->pos[%ld]:%ld - nelmts:%ld", i, opts->pos[i], opts->hs_nelmts); + nfound += diff_datum(mem1 + i * size, mem2 + i * size, i, opts, container1_id, container2_id, + &members); if (opts->count_bool && nfound >= opts->count) - return nfound; - } /* nelmts */ - } - break; - - /*------------------------------------------------------------------------- - * Other types than float and integer - *------------------------------------------------------------------------- - */ - case H5T_COMPOUND: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - case H5T_VLEN: - case H5T_REFERENCE: - H5TOOLS_DEBUG("type_class:OTHER"); - HDmemset(&members, 0, sizeof(mcomp_t)); - get_member_types(opts->m_tid, &members); - for (i = 0; i < opts->hs_nelmts; i++) { - H5TOOLS_DEBUG("opts->pos[%ld]:%ld - nelmts:%ld", i, opts->pos[i], opts->hs_nelmts); - nfound += diff_datum(mem1 + i * size, mem2 + i * size, i, opts, container1_id, container2_id, &members); - if (opts->count_bool && nfound >= opts->count) - break; - } /* i */ - close_member_types(&members); + break; + } /* i */ + close_member_types(&members); } /* switch */ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); return nfound; @@ -447,247 +457,237 @@ diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_ *------------------------------------------------------------------------- */ static hsize_t -diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t container1_id, hid_t container2_id, mcomp_t *members) +diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t container1_id, + hid_t container2_id, mcomp_t *members) { - unsigned char *mem1 = (unsigned char*) _mem1; - unsigned char *mem2 = (unsigned char*) _mem2; - size_t u; - size_t type_size; - H5T_sign_t type_sign; - H5T_class_t type_class; - size_t offset; - unsigned nmembs; - unsigned j; - size_t size = 0; - hbool_t iszero1; - hbool_t iszero2; - hsize_t nfound = 0; /* differences found */ - double per; - hbool_t both_zero; - diff_err_t ret_value = opts->err_stat; + unsigned char *mem1 = (unsigned char *)_mem1; + unsigned char *mem2 = (unsigned char *)_mem2; + size_t u; + size_t type_size; + H5T_sign_t type_sign; + H5T_class_t type_class; + size_t offset; + unsigned nmembs; + unsigned j; + size_t size = 0; + hbool_t iszero1; + hbool_t iszero2; + hsize_t nfound = 0; /* differences found */ + double per; + hbool_t both_zero; + diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG("ph:%d elemtno:%d - errstat:%d", opts->print_header, elemtno, opts->err_stat); - type_size = H5Tget_size(opts->m_tid); + type_size = H5Tget_size(opts->m_tid); type_class = H5Tget_class(opts->m_tid); /* Fast comparison first for atomic type by memcmp(). * It is OK not to list non-atomic type here because it will not be caught * by the condition, but it gives more clarity for code planning */ - if (type_class != H5T_REFERENCE && - type_class != H5T_COMPOUND && - type_class != H5T_STRING && - type_class != H5T_VLEN && - HDmemcmp(mem1, mem2, type_size) == 0) + if (type_class != H5T_REFERENCE && type_class != H5T_COMPOUND && type_class != H5T_STRING && + type_class != H5T_VLEN && HDmemcmp(mem1, mem2, type_size) == 0) H5TOOLS_GOTO_DONE(opts->err_stat); switch (H5Tget_class(opts->m_tid)) { - case H5T_NO_CLASS: - case H5T_TIME: - case H5T_NCLASSES: - default: - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Invalid type class"); - break; + case H5T_NO_CLASS: + case H5T_TIME: + case H5T_NCLASSES: + default: + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Invalid type class"); + break; - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - case H5T_COMPOUND: - H5TOOLS_DEBUG("H5T_COMPOUND"); - { - diff_opt_t cmpd_opts; + /*------------------------------------------------------------------------- + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + case H5T_COMPOUND: + H5TOOLS_DEBUG("H5T_COMPOUND"); + { + diff_opt_t cmpd_opts; - cmpd_opts = *opts; - nmembs = members->n; + cmpd_opts = *opts; + nmembs = members->n; - for (j = 0; j < nmembs; j++) { - offset = members->offsets[j]; - cmpd_opts.m_tid = members->ids[j]; + for (j = 0; j < nmembs; j++) { + offset = members->offsets[j]; + cmpd_opts.m_tid = members->ids[j]; - nfound += diff_datum(mem1 + offset, mem2 + offset, elemtno, &cmpd_opts, container1_id, container2_id, members->m[j]); + nfound += diff_datum(mem1 + offset, mem2 + offset, elemtno, &cmpd_opts, container1_id, + container2_id, members->m[j]); + } + opts->err_stat = opts->err_stat | cmpd_opts.err_stat; + opts->print_header = cmpd_opts.print_header; + opts->not_cmp = cmpd_opts.not_cmp; } - opts->err_stat = opts->err_stat | cmpd_opts.err_stat; - opts->print_header = cmpd_opts.print_header; - opts->not_cmp = cmpd_opts.not_cmp; - } - break; + break; - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - case H5T_STRING: - H5TOOLS_DEBUG("H5T_STRING"); - { - char *s = NULL; - char *sx = NULL; - char *s1 = NULL; - char *s2 = NULL; - size_t size1; - size_t size2; - size_t sizex; - size_t size_mtype = H5Tget_size(opts->m_tid); - H5T_str_t pad = H5Tget_strpad(opts->m_tid); - - /* if variable length string */ - if (H5Tis_variable_str(opts->m_tid)) { - H5TOOLS_DEBUG("H5T_STRING variable"); - /* Get pointer to first string */ - s1 = *(char **)((void *)mem1); - if (s1) - size1 = HDstrlen(s1); - else - size1 = 0; - - /* Get pointer to second string */ - s2 = *(char **)((void *)mem2); - if (s2) - size2 = HDstrlen(s2); - else - size2 = 0; - } - else if (H5T_STR_NULLTERM == pad) { - H5TOOLS_DEBUG("H5T_STRING null term"); - /* Get pointer to first string */ - s1 = (char*) mem1; - if (s1) - size1 = HDstrlen(s1); - else - size1 = 0; - - if (size1 > size_mtype) - size1 = size_mtype; + /*------------------------------------------------------------------------- + * H5T_STRING + *------------------------------------------------------------------------- + */ + case H5T_STRING: + H5TOOLS_DEBUG("H5T_STRING"); + { + char * s = NULL; + char * sx = NULL; + char * s1 = NULL; + char * s2 = NULL; + size_t size1; + size_t size2; + size_t sizex; + size_t size_mtype = H5Tget_size(opts->m_tid); + H5T_str_t pad = H5Tget_strpad(opts->m_tid); + + /* if variable length string */ + if (H5Tis_variable_str(opts->m_tid)) { + H5TOOLS_DEBUG("H5T_STRING variable"); + /* Get pointer to first string */ + s1 = *(char **)((void *)mem1); + if (s1) + size1 = HDstrlen(s1); + else + size1 = 0; + + /* Get pointer to second string */ + s2 = *(char **)((void *)mem2); + if (s2) + size2 = HDstrlen(s2); + else + size2 = 0; + } + else if (H5T_STR_NULLTERM == pad) { + H5TOOLS_DEBUG("H5T_STRING null term"); + /* Get pointer to first string */ + s1 = (char *)mem1; + if (s1) + size1 = HDstrlen(s1); + else + size1 = 0; + + if (size1 > size_mtype) + size1 = size_mtype; - /* Get pointer to second string */ - s2 = (char*) mem2; - if (s2) - size2 = HDstrlen(s2); - else - size2 = 0; + /* Get pointer to second string */ + s2 = (char *)mem2; + if (s2) + size2 = HDstrlen(s2); + else + size2 = 0; + + if (size2 > size_mtype) + size2 = size_mtype; + } + else { + /* Get pointer to first string */ + s1 = (char *)mem1; + size1 = size_mtype; - if (size2 > size_mtype) + /* Get pointer to second string */ + s2 = (char *)mem2; size2 = size_mtype; - } - else { - /* Get pointer to first string */ - s1 = (char *) mem1; - size1 = size_mtype; + } - /* Get pointer to second string */ - s2 = (char *) mem2; - size2 = size_mtype; - } + /* + * compare for shorter string + * TODO: this code need to be improved to handle the difference + * of length of strings. + * For now mimic the previous way. + */ + H5TOOLS_DEBUG("string size:%d", size1); + H5TOOLS_DEBUG("string size:%d", size2); + if (size1 != size2) { + H5TOOLS_DEBUG("string sizes difference"); + nfound++; + } + if (size1 < size2) { + size = size1; + s = s1; + sizex = size2; + sx = s2; + } + else { + size = size2; + s = s2; + sizex = size1; + sx = s1; + } - /* - * compare for shorter string - * TODO: this code need to be improved to handle the difference - * of length of strings. - * For now mimic the previous way. - */ - H5TOOLS_DEBUG("string size:%d", size1); - H5TOOLS_DEBUG("string size:%d", size2); - if (size1 != size2) { - H5TOOLS_DEBUG("string sizes difference"); - nfound++; - } - if (size1 < size2) { - size = size1; - s = s1; - sizex = size2; - sx = s2; + /* check for NULL pointer for string */ + if (s != NULL) { + /* try fast compare first */ + if ((HDmemcmp(s, sx, size) == 0) && (size1 != size2)) { + for (u = size; u < sizex; u++) + character_compare(s + u, sx + u, elemtno, u, opts); + } + else + for (u = 0; u < size; u++) + nfound += character_compare(s + u, sx + u, elemtno, u, opts); + } /* end check for NULL pointer for string */ } - else { - size = size2; - s = s2; - sizex = size1; - sx = s1; - } - - /* check for NULL pointer for string */ - if (s != NULL) { - /* try fast compare first */ - if ((HDmemcmp(s, sx, size) == 0) && (size1 != size2)) { - for (u = size; u < sizex; u++) - character_compare(s + u, sx + u, elemtno, u, opts); - } - else - for (u = 0; u < size; u++) - nfound += character_compare(s + u, sx + u, elemtno, u, opts); - } /* end check for NULL pointer for string */ - } - break; + break; - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - case H5T_BITFIELD: - H5TOOLS_DEBUG("H5T_BITFIELD"); - /* byte-by-byte comparison */ - for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); - break; + /*------------------------------------------------------------------------- + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ + case H5T_BITFIELD: + H5TOOLS_DEBUG("H5T_BITFIELD"); + /* byte-by-byte comparison */ + for (u = 0; u < type_size; u++) + nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); + break; - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - case H5T_OPAQUE: - H5TOOLS_DEBUG("H5T_OPAQUE"); - /* byte-by-byte comparison */ - for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); - break; + /*------------------------------------------------------------------------- + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + case H5T_OPAQUE: + H5TOOLS_DEBUG("H5T_OPAQUE"); + /* byte-by-byte comparison */ + for (u = 0; u < type_size; u++) + nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); + break; - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - case H5T_ENUM: - /* For enumeration types we compare the names instead of the - * integer values. For each pair of elements being - * compared, we convert both bit patterns to their corresponding - * enumeration constant and do a string comparison + /*------------------------------------------------------------------------- + * H5T_ENUM + *------------------------------------------------------------------------- */ - H5TOOLS_DEBUG("H5T_ENUM"); - { - char enum_name1[1024]; - char enum_name2[1024]; - herr_t err1; - herr_t err2; - - /* disable error reporting */ - H5E_BEGIN_TRY { - /* If the enum value cannot be converted to a string - * it is set to an error string for later output. - */ - err1 = H5Tenum_nameof(opts->m_tid, mem1, enum_name1, sizeof enum_name1); - if (err1 < 0) - HDsnprintf(enum_name1, sizeof(enum_name1), "**INVALID VALUE**"); - - err2 = H5Tenum_nameof(opts->m_tid, mem2, enum_name2, sizeof enum_name2); - if (err2 < 0) - HDsnprintf(enum_name2, sizeof(enum_name2), "**INVALID VALUE**"); - - /* One or more bad enum values */ - if (err1 < 0 || err2 < 0) { - /* If the two values cannot be converted to a string - * (probably due to them being invalid enum values), - * don't attempt to convert them - just report errors. + case H5T_ENUM: + /* For enumeration types we compare the names instead of the + * integer values. For each pair of elements being + * compared, we convert both bit patterns to their corresponding + * enumeration constant and do a string comparison + */ + H5TOOLS_DEBUG("H5T_ENUM"); + { + char enum_name1[1024]; + char enum_name2[1024]; + herr_t err1; + herr_t err2; + + /* disable error reporting */ + H5E_BEGIN_TRY + { + /* If the enum value cannot be converted to a string + * it is set to an error string for later output. */ - nfound += 1; - opts->print_percentage = 0; - print_pos(opts, elemtno, 0); - if (print_data(opts)) { - parallel_print(S_FORMAT, enum_name1, enum_name2); - } - } - else { - /* Both enum values were valid */ - if (HDstrcmp(enum_name1, enum_name2) != 0) { - nfound = 1; + err1 = H5Tenum_nameof(opts->m_tid, mem1, enum_name1, sizeof enum_name1); + if (err1 < 0) + HDsnprintf(enum_name1, sizeof(enum_name1), "**INVALID VALUE**"); + + err2 = H5Tenum_nameof(opts->m_tid, mem2, enum_name2, sizeof enum_name2); + if (err2 < 0) + HDsnprintf(enum_name2, sizeof(enum_name2), "**INVALID VALUE**"); + + /* One or more bad enum values */ + if (err1 < 0 || err2 < 0) { + /* If the two values cannot be converted to a string + * (probably due to them being invalid enum values), + * don't attempt to convert them - just report errors. + */ + nfound += 1; opts->print_percentage = 0; print_pos(opts, elemtno, 0); if (print_data(opts)) { @@ -695,306 +695,349 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co } } else { - for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); + /* Both enum values were valid */ + if (HDstrcmp(enum_name1, enum_name2) != 0) { + nfound = 1; + opts->print_percentage = 0; + print_pos(opts, elemtno, 0); + if (print_data(opts)) { + parallel_print(S_FORMAT, enum_name1, enum_name2); + } + } + else { + for (u = 0; u < type_size; u++) + nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); + } } + /* enable error reporting */ } - /* enable error reporting */ - } H5E_END_TRY; - } - break; + H5E_END_TRY; + } + break; - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - case H5T_ARRAY: - { - hsize_t adims[H5S_MAX_RANK]; - int ndims; + /*------------------------------------------------------------------------- + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + case H5T_ARRAY: { + hsize_t adims[H5S_MAX_RANK]; + int ndims; diff_opt_t arr_opts; H5TOOLS_DEBUG("H5T_ARRAY ph=%d", opts->print_header); arr_opts = *opts; - H5TOOLS_DEBUG("Check opts: hs_nelmts:%ld to %ld rank:%d to %ld", opts->hs_nelmts, arr_opts.hs_nelmts, opts->rank, arr_opts.rank); + H5TOOLS_DEBUG("Check opts: hs_nelmts:%ld to %ld rank:%d to %ld", opts->hs_nelmts, + arr_opts.hs_nelmts, opts->rank, arr_opts.rank); /* get the array's base datatype for each element */ arr_opts.m_tid = H5Tget_super(opts->m_tid); - size = H5Tget_size(arr_opts.m_tid); - ndims = H5Tget_array_ndims(opts->m_tid); + size = H5Tget_size(arr_opts.m_tid); + ndims = H5Tget_array_ndims(opts->m_tid); H5Tget_array_dims2(opts->m_tid, adims); HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); H5TOOLS_DEBUG("attr ph=%d", arr_opts.print_header); /* calculate the number of array elements */ - for (u = 0, arr_opts.hs_nelmts = 1; u < (unsigned) ndims; u++) + for (u = 0, arr_opts.hs_nelmts = 1; u < (unsigned)ndims; u++) arr_opts.hs_nelmts *= adims[u]; for (u = 0; u < arr_opts.hs_nelmts; u++) { - nfound += diff_datum(mem1 + u * size, mem2 + u * size, elemtno, &arr_opts, container1_id, container2_id, members); + nfound += diff_datum(mem1 + u * size, mem2 + u * size, elemtno, &arr_opts, container1_id, + container2_id, members); } - opts->err_stat = opts->err_stat | arr_opts.err_stat; + opts->err_stat = opts->err_stat | arr_opts.err_stat; opts->print_header = arr_opts.print_header; - opts->not_cmp = arr_opts.not_cmp; + opts->not_cmp = arr_opts.not_cmp; H5Tclose(arr_opts.m_tid); - } - break; + } break; - /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ - case H5T_REFERENCE: - H5TOOLS_DEBUG("H5T_REFERENCE"); - iszero1 = all_zero(_mem1, H5Tget_size(opts->m_tid)); - iszero2 = all_zero(_mem2, H5Tget_size(opts->m_tid)); - if (iszero1 != iszero2) { - nfound++; - H5TOOLS_GOTO_DONE(opts->err_stat); - } - else if (!iszero1 && !iszero2) { - hid_t obj1_id = H5I_INVALID_HID; - hid_t obj2_id = H5I_INVALID_HID; - diff_opt_t ref_opts; + /*------------------------------------------------------------------------- + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ + case H5T_REFERENCE: + H5TOOLS_DEBUG("H5T_REFERENCE"); + iszero1 = all_zero(_mem1, H5Tget_size(opts->m_tid)); + iszero2 = all_zero(_mem2, H5Tget_size(opts->m_tid)); + if (iszero1 != iszero2) { + nfound++; + H5TOOLS_GOTO_DONE(opts->err_stat); + } + else if (!iszero1 && !iszero2) { + hid_t obj1_id = H5I_INVALID_HID; + hid_t obj2_id = H5I_INVALID_HID; + diff_opt_t ref_opts; - /*------------------------------------------------------------------------- - * H5T_STD_REF - * Reference - *------------------------------------------------------------------------- - */ - ref_opts = *opts; - ref_opts.obj_name[0] = NULL; - ref_opts.obj_name[1] = NULL; - if (H5Tequal(ref_opts.m_tid, H5T_STD_REF)) { - /* if (type_size == H5R_STD_REF_SIZE) */ - hid_t region1_id = H5I_INVALID_HID; - hid_t region2_id = H5I_INVALID_HID; - H5R_ref_t *ref1_buf = (H5R_ref_t *)_mem1; - H5R_ref_t *ref2_buf = (H5R_ref_t *)_mem2; - H5O_type_t obj1_type = -1; /* Object type */ - H5O_type_t obj2_type = -1; /* Object type */ - H5R_type_t ref_type; /* Reference type */ - - H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF"); - ref_type = H5Rget_type(ref1_buf); - switch (ref_type) { - case H5R_OBJECT1: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); - if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) { - if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) { - /* check object type */ - if (obj1_type == obj2_type) { - switch (obj1_type) { - case H5O_TYPE_DATASET: - if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - nfound = diff_datasetid(obj1_id, obj2_id, opts->obj_name[0], opts->obj_name[1], &ref_opts); - if(H5Dclose(obj2_id) < 0) { + /*------------------------------------------------------------------------- + * H5T_STD_REF + * Reference + *------------------------------------------------------------------------- + */ + ref_opts = *opts; + ref_opts.obj_name[0] = NULL; + ref_opts.obj_name[1] = NULL; + if (H5Tequal(ref_opts.m_tid, H5T_STD_REF)) { + /* if (type_size == H5R_STD_REF_SIZE) */ + hid_t region1_id = H5I_INVALID_HID; + hid_t region2_id = H5I_INVALID_HID; + H5R_ref_t *ref1_buf = (H5R_ref_t *)_mem1; + H5R_ref_t *ref2_buf = (H5R_ref_t *)_mem2; + H5O_type_t obj1_type = -1; /* Object type */ + H5O_type_t obj2_type = -1; /* Object type */ + H5R_type_t ref_type; /* Reference type */ + + H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF"); + ref_type = H5Rget_type(ref1_buf); + switch (ref_type) { + case H5R_OBJECT1: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); + if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) { + if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) { + /* check object type */ + if (obj1_type == obj2_type) { + switch (obj1_type) { + case H5O_TYPE_DATASET: + if ((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + if ((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + nfound = diff_datasetid(obj1_id, obj2_id, + opts->obj_name[0], + opts->obj_name[1], &ref_opts); + if (H5Dclose(obj2_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed"); + } + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Ropen_object object 2 failed"); + } + if (H5Dclose(obj1_id) < 0) { ref_opts.err_stat = H5DIFF_ERR; H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed"); } } else { ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Ropen_object object 2 failed"); + H5TOOLS_INFO("H5Ropen_object object 1 failed"); } - if(H5Dclose(obj1_id) < 0) { - ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed"); - } - } - else { - ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Ropen_object object 1 failed"); - } - break; - - case H5O_TYPE_GROUP: - case H5O_TYPE_NAMED_DATATYPE: - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - if (ref_opts.mode_verbose) - parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]); - ref_opts.not_cmp = 1; - break; - } /* end switch */ + break; + + case H5O_TYPE_GROUP: + case H5O_TYPE_NAMED_DATATYPE: + case H5O_TYPE_MAP: + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + if (ref_opts.mode_verbose) + parallel_print("Warning: Comparison not possible of " + "object types referenced: <%s> and <%s>\n", + opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + break; + } /* end switch */ + } + else { + parallel_print("Different object types referenced: <%s> and <%s>", + opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + ref_opts.err_stat = H5DIFF_ERR; + } } else { - parallel_print("Different object types referenced: <%s> and <%s>", opts->obj_name[0], opts->obj_name[1]); - ref_opts.not_cmp = 1; ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed"); } } else { ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed"); + H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed"); } - } - else { - ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed"); - } - break; - case H5R_DATASET_REGION1: - H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); - if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, &ref_opts); - if(H5Sclose(region2_id) < 0) + break; + case H5R_DATASET_REGION1: + H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); + if ((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= + 0) { + if ((region2_id = + H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, + &ref_opts); + if (H5Sclose(region2_id) < 0) + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed"); + } + if (H5Sclose(region1_id) < 0) H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed"); } - if(H5Sclose(region1_id) < 0) - H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed"); + if (H5Dclose(obj2_id) < 0) + H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed"); + } + else { + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); } - if(H5Dclose(obj2_id) < 0) + if (H5Dclose(obj1_id) < 0) H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed"); } else { H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); } - if(H5Dclose(obj1_id) < 0) - H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed"); - } - else { - H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); - } - break; - case H5R_OBJECT2: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); - if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) { - if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) { - /* check object type */ - if (obj1_type == obj2_type) { - if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - switch (obj1_type) { - case H5O_TYPE_DATASET: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : DATASET"); - nfound = diff_datasetid(obj1_id, obj2_id, opts->obj_name[0], opts->obj_name[1], &ref_opts); - break; - - case H5O_TYPE_GROUP: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : GROUP"); - if (ref_opts.mode_verbose) - parallel_print("Warning: Comparison not possible of group object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]); - ref_opts.not_cmp = 1; - break; - - case H5O_TYPE_NAMED_DATATYPE: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : NAMED"); - if (ref_opts.mode_verbose) - parallel_print("Warning: Comparison not possible of named datatypes object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]); - ref_opts.not_cmp = 1; - break; - - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - if (ref_opts.mode_verbose) - parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]); - ref_opts.not_cmp = 1; - break; - } /* end switch */ - if(H5Oclose(obj2_id) < 0) { + break; + case H5R_OBJECT2: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); + if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) { + if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) { + /* check object type */ + if (obj1_type == obj2_type) { + if ((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= + 0) { + if ((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + switch (obj1_type) { + case H5O_TYPE_DATASET: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : DATASET"); + nfound = diff_datasetid(obj1_id, obj2_id, + opts->obj_name[0], + opts->obj_name[1], &ref_opts); + break; + + case H5O_TYPE_GROUP: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : GROUP"); + if (ref_opts.mode_verbose) + parallel_print( + "Warning: Comparison not possible of group " + "object types referenced: <%s> and <%s>\n", + opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + break; + + case H5O_TYPE_NAMED_DATATYPE: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : NAMED"); + if (ref_opts.mode_verbose) + parallel_print("Warning: Comparison not possible " + "of named datatypes object types " + "referenced: <%s> and <%s>\n", + opts->obj_name[0], + opts->obj_name[1]); + ref_opts.not_cmp = 1; + break; + + case H5O_TYPE_MAP: + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + if (ref_opts.mode_verbose) + parallel_print( + "Warning: Comparison not possible of object " + "types referenced: <%s> and <%s>\n", + opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + break; + } /* end switch */ + if (H5Oclose(obj2_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); + } + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Ropen_object object 2 failed"); + } + if (H5Oclose(obj1_id) < 0) { ref_opts.err_stat = H5DIFF_ERR; H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); } } else { ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Ropen_object object 2 failed"); - } - if(H5Oclose(obj1_id) < 0) { - ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Ropen_object object 1 failed"); } } else { + parallel_print("Different object types referenced: <%s> and <%s>", + opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Ropen_object object 1 failed"); } } else { - parallel_print("Different object types referenced: <%s> and <%s>", opts->obj_name[0], opts->obj_name[1]); - ref_opts.not_cmp = 1; ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed"); } } else { ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed"); + H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed"); } - } - else { - ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed"); - } - break; - case H5R_DATASET_REGION2: - H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); - - /* if (obj_id < 0) - could mean that no reference was written do not throw failure */ - if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 1 failed"); - } - else { - if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - H5TOOLS_DEBUG("open_region - H5R_DATASET_REGION2"); - if((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (h5tools_is_zero(ref1_buf, H5Tget_size(H5T_STD_REF))) { - H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); - } - else { - if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (h5tools_is_zero(ref2_buf, H5Tget_size(H5T_STD_REF))) { - H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); - } - else { - nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, &ref_opts); - } - if(H5Sclose(region2_id) < 0) - H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); + break; + case H5R_DATASET_REGION2: + H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); + + /* if (obj_id < 0) - could mean that no reference was written do not throw failure + */ + if ((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 1 failed"); + } + else { + if ((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + H5TOOLS_DEBUG("open_region - H5R_DATASET_REGION2"); + if ((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= + 0) { + if (h5tools_is_zero(ref1_buf, H5Tget_size(H5T_STD_REF))) { + H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); } - else - H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); - } /* end else to if (h5tools_is_zero(... */ - if(H5Sclose(region1_id) < 0) - H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); + else { + if ((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + if (h5tools_is_zero(ref2_buf, H5Tget_size(H5T_STD_REF))) { + H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); + } + else { + nfound = diff_region(obj1_id, obj2_id, region1_id, + region2_id, &ref_opts); + } + if (H5Sclose(region2_id) < 0) + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); + } + else + H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); + } /* end else to if (h5tools_is_zero(... */ + if (H5Sclose(region1_id) < 0) + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); + } + else + H5TOOLS_ERROR(H5DIFF_ERR, + "H5Ropen_region H5R_DATASET_REGION2 failed"); + if (H5Dclose(obj2_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); + } + } + else { + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 2 failed"); } - else - H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed"); - if(H5Dclose(obj2_id) < 0) { + if (H5Dclose(obj1_id) < 0) { ref_opts.err_stat = H5DIFF_ERR; H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); } } - else { - H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 2 failed"); - } - if(H5Dclose(obj1_id) < 0) { - ref_opts.err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); - } - } - break; - case H5R_ATTR: - { - char name1[ATTR_NAME_MAX]; - char name2[ATTR_NAME_MAX]; + break; + case H5R_ATTR: { + char name1[ATTR_NAME_MAX]; + char name2[ATTR_NAME_MAX]; H5TOOLS_DEBUG("ref_type is H5R_ATTR"); - if((obj1_id = H5Ropen_attr(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if((obj2_id = H5Ropen_attr(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((obj1_id = H5Ropen_attr(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((obj2_id = H5Ropen_attr(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { /* get name */ - if(H5Aget_name(obj1_id, (size_t)ATTR_NAME_MAX, name1) >= 0) { + if (H5Aget_name(obj1_id, (size_t)ATTR_NAME_MAX, name1) >= 0) { /* get name */ - if(H5Aget_name(obj2_id, (size_t)ATTR_NAME_MAX, name2) >= 0) { - H5TOOLS_DEBUG("H5R_ATTR diff_attr_data - name1=%s, name2=%s", name1, name2); - nfound = diff_attr_data(obj1_id, obj2_id, name1, name2, opts->obj_name[0], opts->obj_name[1], &ref_opts); + if (H5Aget_name(obj2_id, (size_t)ATTR_NAME_MAX, name2) >= 0) { + H5TOOLS_DEBUG("H5R_ATTR diff_attr_data - name1=%s, name2=%s", + name1, name2); + nfound = diff_attr_data(obj1_id, obj2_id, name1, name2, + opts->obj_name[0], opts->obj_name[1], + &ref_opts); } else { ref_opts.err_stat = H5DIFF_ERR; @@ -1006,7 +1049,7 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co H5TOOLS_INFO("H5Aget_name first attribute failed"); } - if(H5Aclose(obj2_id) < 0) { + if (H5Aclose(obj2_id) < 0) { ref_opts.err_stat = H5DIFF_ERR; H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); } @@ -1015,7 +1058,7 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co parallel_print("Warning: Cannot open referenced attribute2\n"); H5TOOLS_INFO("H5Ropen_attr object 2 failed"); } - if(H5Aclose(obj1_id) < 0) { + if (H5Aclose(obj1_id) < 0) { H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); } } @@ -1023,51 +1066,50 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co parallel_print("Warning: Cannot open referenced attribute1\n"); H5TOOLS_INFO("H5Ropen_attr object 1 failed"); } - } - break; - case H5R_BADTYPE: - case H5R_MAXTYPE: - default: - break; - } /* end switch */ - if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed"); - if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed"); - H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF complete nfound:%d - errstat:%d", nfound, ref_opts.err_stat); - } - /*------------------------------------------------------------------------- - * H5T_STD_REF_DSETREG - * Dataset region reference - *------------------------------------------------------------------------- - */ - else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_DSETREG)) { - /* if (type_size == H5R_DSET_REG_REF_BUF_SIZE) */ - H5TOOLS_DEBUG("H5T_STD_REF_DSETREG"); - }/*dataset reference*/ - - /*------------------------------------------------------------------------- - * H5T_STD_REF_OBJ - * Object references. get the type and OID of the referenced object - *------------------------------------------------------------------------- - */ - else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_OBJ)) { - /* if (type_size == H5R_OBJ_REF_BUF_SIZE) */ - H5TOOLS_DEBUG("H5T_STD_REF_OBJ"); - }/*object reference*/ - opts->print_header = ref_opts.print_header; - opts->not_cmp = ref_opts.not_cmp; - opts->err_stat = ref_opts.err_stat | ret_value; - }/*is zero*/ - H5TOOLS_DEBUG("H5T_REFERENCE complete"); - break; + } break; + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + break; + } /* end switch */ + if (H5Rdestroy(ref2_buf) < 0) + H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed"); + if (H5Rdestroy(ref1_buf) < 0) + H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed"); + H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF complete nfound:%d - errstat:%d", nfound, + ref_opts.err_stat); + } + /*------------------------------------------------------------------------- + * H5T_STD_REF_DSETREG + * Dataset region reference + *------------------------------------------------------------------------- + */ + else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_DSETREG)) { + /* if (type_size == H5R_DSET_REG_REF_BUF_SIZE) */ + H5TOOLS_DEBUG("H5T_STD_REF_DSETREG"); + } /*dataset reference*/ + + /*------------------------------------------------------------------------- + * H5T_STD_REF_OBJ + * Object references. get the type and OID of the referenced object + *------------------------------------------------------------------------- + */ + else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_OBJ)) { + /* if (type_size == H5R_OBJ_REF_BUF_SIZE) */ + H5TOOLS_DEBUG("H5T_STD_REF_OBJ"); + } /*object reference*/ + opts->print_header = ref_opts.print_header; + opts->not_cmp = ref_opts.not_cmp; + opts->err_stat = ref_opts.err_stat | ret_value; + } /*is zero*/ + H5TOOLS_DEBUG("H5T_REFERENCE complete"); + break; - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - case H5T_VLEN: - { + /*------------------------------------------------------------------------- + * H5T_VLEN + *------------------------------------------------------------------------- + */ + case H5T_VLEN: { diff_opt_t vl_opts; H5TOOLS_DEBUG("H5T_VLEN"); @@ -1075,169 +1117,171 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co vl_opts = *opts; /* get the VL sequences's base datatype for each element */ vl_opts.m_tid = H5Tget_super(opts->m_tid); - size = H5Tget_size(vl_opts.m_tid); + size = H5Tget_size(vl_opts.m_tid); /* get the number of sequence elements */ vl_opts.hs_nelmts = ((hvl_t *)((void *)mem1))->len; for (j = 0; j < vl_opts.hs_nelmts; j++) - nfound += diff_datum(((char *) (((hvl_t *)((void *)mem1))->p)) + j * size, ((char *) (((hvl_t *)((void *)mem2))->p)) + j * size, elemtno, /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */ - &vl_opts, container1_id, container2_id, members); + nfound += diff_datum(((char *)(((hvl_t *)((void *)mem1))->p)) + j * size, + ((char *)(((hvl_t *)((void *)mem2))->p)) + j * size, + elemtno, /* Extra (void *) cast to quiet "cast to create alignment" + warning - 2019/07/05, QAK */ + &vl_opts, container1_id, container2_id, members); opts->print_header = vl_opts.print_header; - opts->not_cmp = vl_opts.not_cmp; - opts->err_stat = opts->err_stat | vl_opts.err_stat; + opts->not_cmp = vl_opts.not_cmp; + opts->err_stat = opts->err_stat | vl_opts.err_stat; H5Tclose(vl_opts.m_tid); - } - break; + } break; - /*------------------------------------------------------------------------- - * H5T_INTEGER - *------------------------------------------------------------------------- - */ - case H5T_INTEGER: - H5TOOLS_DEBUG("H5T_INTEGER"); - type_sign = H5Tget_sign(opts->m_tid); /*------------------------------------------------------------------------- - * H5T_NATIVE_SCHAR + * H5T_INTEGER *------------------------------------------------------------------------- */ - if (type_size == 1 && type_sign != H5T_SGN_NONE) { - if(type_size != sizeof(char)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not char size"); - nfound += diff_schar_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_SCHAR*/ + case H5T_INTEGER: + H5TOOLS_DEBUG("H5T_INTEGER"); + type_sign = H5Tget_sign(opts->m_tid); + /*------------------------------------------------------------------------- + * H5T_NATIVE_SCHAR + *------------------------------------------------------------------------- + */ + if (type_size == 1 && type_sign != H5T_SGN_NONE) { + if (type_size != sizeof(char)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not char size"); + nfound += diff_schar_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_SCHAR*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_UCHAR - *------------------------------------------------------------------------- - */ - else if (type_size == 1 && type_sign == H5T_SGN_NONE) { - if(type_size != sizeof(unsigned char)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned char size"); - nfound += diff_uchar_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_UCHAR*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_UCHAR + *------------------------------------------------------------------------- + */ + else if (type_size == 1 && type_sign == H5T_SGN_NONE) { + if (type_size != sizeof(unsigned char)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned char size"); + nfound += diff_uchar_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_UCHAR*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_SHORT - *------------------------------------------------------------------------- - */ - else if (type_size == 2 && type_sign != H5T_SGN_NONE) { - if(type_size != sizeof(short)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not short size"); - nfound += diff_short_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_SHORT*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_SHORT + *------------------------------------------------------------------------- + */ + else if (type_size == 2 && type_sign != H5T_SGN_NONE) { + if (type_size != sizeof(short)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not short size"); + nfound += diff_short_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_SHORT*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_USHORT - *------------------------------------------------------------------------- - */ - else if (type_size == 2 && type_sign == H5T_SGN_NONE) { - if(type_size != sizeof(unsigned short)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned short size"); - nfound += diff_ushort_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_USHORT*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_USHORT + *------------------------------------------------------------------------- + */ + else if (type_size == 2 && type_sign == H5T_SGN_NONE) { + if (type_size != sizeof(unsigned short)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned short size"); + nfound += diff_ushort_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_USHORT*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ - else if (type_size == 4 && type_sign != H5T_SGN_NONE) { - if(type_size != sizeof(int)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not int size"); - nfound += diff_int_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_INT*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ + else if (type_size == 4 && type_sign != H5T_SGN_NONE) { + if (type_size != sizeof(int)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not int size"); + nfound += diff_int_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_INT*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_UINT - *------------------------------------------------------------------------- - */ - else if (type_size == 4 && type_sign == H5T_SGN_NONE) { - if(type_size != sizeof(unsigned int)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned int size"); - nfound += diff_uint_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_UINT*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_UINT + *------------------------------------------------------------------------- + */ + else if (type_size == 4 && type_sign == H5T_SGN_NONE) { + if (type_size != sizeof(unsigned int)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned int size"); + nfound += diff_uint_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_UINT*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_LONG - *------------------------------------------------------------------------- - */ - else if (type_size == 8 && type_sign != H5T_SGN_NONE) { - if(type_size != sizeof(long)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long size"); - nfound += diff_long_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_LONG*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_LONG + *------------------------------------------------------------------------- + */ + else if (type_size == 8 && type_sign != H5T_SGN_NONE) { + if (type_size != sizeof(long)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long size"); + nfound += diff_long_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_LONG*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_ULONG - *------------------------------------------------------------------------- - */ - else if (type_size == 8 && type_sign == H5T_SGN_NONE) { - if(type_size != sizeof(unsigned long)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long size"); - nfound += diff_ulong_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_ULONG*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_ULONG + *------------------------------------------------------------------------- + */ + else if (type_size == 8 && type_sign == H5T_SGN_NONE) { + if (type_size != sizeof(unsigned long)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long size"); + nfound += diff_ulong_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_ULONG*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_LLONG - *------------------------------------------------------------------------- - */ - else if (type_size == 16 && type_sign != H5T_SGN_NONE) { - if(type_size != sizeof(long long)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long long size"); - nfound += diff_llong_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_LLONG*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_LLONG + *------------------------------------------------------------------------- + */ + else if (type_size == 16 && type_sign != H5T_SGN_NONE) { + if (type_size != sizeof(long long)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long long size"); + nfound += diff_llong_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_LLONG*/ - /*------------------------------------------------------------------------- - * H5T_NATIVE_ULLONG - *------------------------------------------------------------------------- - */ - else if (type_size == 16 && type_sign == H5T_SGN_NONE) { - if(type_size != sizeof(unsigned long long)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long long size"); - nfound += diff_ullong_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_ULLONG*/ - break; /* H5T_INTEGER class */ + /*------------------------------------------------------------------------- + * H5T_NATIVE_ULLONG + *------------------------------------------------------------------------- + */ + else if (type_size == 16 && type_sign == H5T_SGN_NONE) { + if (type_size != sizeof(unsigned long long)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long long size"); + nfound += diff_ullong_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_ULLONG*/ + break; /* H5T_INTEGER class */ - /*------------------------------------------------------------------------- - * H5T_FLOAT - *------------------------------------------------------------------------- - */ - case H5T_FLOAT: /*------------------------------------------------------------------------- - * H5T_NATIVE_FLOAT + * H5T_FLOAT *------------------------------------------------------------------------- */ - H5TOOLS_DEBUG("H5T_FLOAT"); - if (type_size == 4) { - if(type_size != sizeof(float)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not float size"); - nfound += diff_float_element(mem1, mem2, elemtno, opts); - } - /*------------------------------------------------------------------------- - * H5T_NATIVE_DOUBLE - *------------------------------------------------------------------------- - */ - else if (type_size == 8) { - if(type_size != sizeof(double)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not double size"); - nfound += diff_double_element(mem1, mem2, elemtno, opts); - } + case H5T_FLOAT: + /*------------------------------------------------------------------------- + * H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ + H5TOOLS_DEBUG("H5T_FLOAT"); + if (type_size == 4) { + if (type_size != sizeof(float)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not float size"); + nfound += diff_float_element(mem1, mem2, elemtno, opts); + } + /*------------------------------------------------------------------------- + * H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ + else if (type_size == 8) { + if (type_size != sizeof(double)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not double size"); + nfound += diff_double_element(mem1, mem2, elemtno, opts); + } #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - /*------------------------------------------------------------------------- - * H5T_NATIVE_LDOUBLE - *------------------------------------------------------------------------- - */ - else if (type_size == H5_SIZEOF_LONG_DOUBLE) { - if(type_size != sizeof(long double)) { - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long double size"); - } - nfound += diff_ldouble_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_LDOUBLE*/ -#endif /* H5_SIZEOF_LONG_DOUBLE */ + /*------------------------------------------------------------------------- + * H5T_NATIVE_LDOUBLE + *------------------------------------------------------------------------- + */ + else if (type_size == H5_SIZEOF_LONG_DOUBLE) { + if (type_size != sizeof(long double)) { + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long double size"); + } + nfound += diff_ldouble_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_LDOUBLE*/ +#endif /* H5_SIZEOF_LONG_DOUBLE */ - break; /* H5T_FLOAT class */ + break; /* H5T_FLOAT class */ } /* switch */ @@ -1257,8 +1301,10 @@ done: *------------------------------------------------------------------------- */ -static hbool_t all_zero(const void *_mem, size_t size) { - const unsigned char *mem = (const unsigned char *) _mem; +static hbool_t +all_zero(const void *_mem, size_t size) +{ + const unsigned char *mem = (const unsigned char *)_mem; while (size-- > 0) if (mem[size]) @@ -1276,17 +1322,17 @@ static hbool_t all_zero(const void *_mem, size_t size) { *------------------------------------------------------------------------- */ -static -void print_region_block(int i, hsize_t *ptdata, int ndims) { +static void +print_region_block(int i, hsize_t *ptdata, int ndims) +{ int j; parallel_print(" "); for (j = 0; j < ndims; j++) - parallel_print("%s%lu", j ? "," : " (", (unsigned long) ptdata[i * 2 * ndims + j]); + parallel_print("%s%lu", j ? "," : " (", (unsigned long)ptdata[i * 2 * ndims + j]); for (j = 0; j < ndims; j++) - parallel_print("%s%lu", j ? "," : ")-(", (unsigned long) ptdata[i * 2 * ndims + j + ndims]); + parallel_print("%s%lu", j ? "," : ")-(", (unsigned long)ptdata[i * 2 * ndims + j + ndims]); parallel_print(")"); - } /*------------------------------------------------------------------------- @@ -1298,15 +1344,15 @@ void print_region_block(int i, hsize_t *ptdata, int ndims) { *------------------------------------------------------------------------- */ -static -void print_points(int i, hsize_t *ptdata, int ndims) { +static void +print_points(int i, hsize_t *ptdata, int ndims) +{ int j; parallel_print(" "); for (j = 0; j < ndims; j++) - parallel_print("%s%lu", j ? "," : "(", (unsigned long) (ptdata[i * ndims + j])); + parallel_print("%s%lu", j ? "," : "(", (unsigned long)(ptdata[i * ndims + j])); parallel_print(")"); - } /*------------------------------------------------------------------------- @@ -1318,7 +1364,8 @@ void print_points(int i, hsize_t *ptdata, int ndims) { *------------------------------------------------------------------------- */ -static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts) +static hsize_t +diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts) { hssize_t nblocks1, npoints1; @@ -1329,8 +1376,8 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t int ndims1; int ndims2; int i, j; - hsize_t nfound_b = 0; /* block differences found */ - hsize_t nfound_p = 0; /* point differences found */ + hsize_t nfound_b = 0; /* block differences found */ + hsize_t nfound_p = 0; /* point differences found */ hsize_t ret_value = 0; H5TOOLS_START_DEBUG(""); @@ -1343,13 +1390,15 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t * respectively. They do not currently know how to translate from one to * the other. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { nblocks1 = H5Sget_select_hyper_nblocks(region1_id); nblocks2 = H5Sget_select_hyper_nblocks(region2_id); npoints1 = H5Sget_select_elem_npoints(region1_id); npoints2 = H5Sget_select_elem_npoints(region2_id); - } H5E_END_TRY; + } + H5E_END_TRY; H5TOOLS_DEBUG("blocks: 1=%ld-2=%ld", nblocks1, nblocks2); H5TOOLS_DEBUG("points: 1=%ld-2=%ld", npoints1, npoints2); @@ -1365,24 +1414,24 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t if (nblocks1 > 0) { H5TOOLS_DEBUG("region compare blocks"); HDassert(ndims1 > 0); - alloc_size = (hsize_t) nblocks1 * (unsigned) ndims1 * 2 * sizeof(ptdata1[0]); - HDassert(alloc_size == (hsize_t)((size_t )alloc_size)); /*check for overflow*/ + alloc_size = (hsize_t)nblocks1 * (unsigned)ndims1 * 2 * sizeof(ptdata1[0]); + HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { + if ((ptdata1 = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) { opts->err_stat = H5DIFF_ERR; H5TOOLS_INFO("Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); - H5Sget_select_hyper_blocklist(region1_id, (hsize_t) 0, (hsize_t) nblocks1, ptdata1); + H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1); - if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { + if ((ptdata2 = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) { opts->err_stat = H5DIFF_ERR; H5TOOLS_INFO("Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); - H5Sget_select_hyper_blocklist(region2_id, (hsize_t) 0, (hsize_t) nblocks2, ptdata2); + H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2); for (i = 0; i < nblocks1; i++) { /* start coordinates and opposite corner */ @@ -1391,8 +1440,8 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t start1 = ptdata1[i * 2 * ndims1 + j]; start2 = ptdata2[i * 2 * ndims1 + j]; - end1 = ptdata1[i * 2 * ndims1 + j + ndims1]; - end2 = ptdata2[i * 2 * ndims1 + j + ndims1]; + end1 = ptdata1[i * 2 * ndims1 + j + ndims1]; + end2 = ptdata2[i * 2 * ndims1 + j + ndims1]; if (start1 != start2 || end1 != end2) nfound_b++; } @@ -1401,7 +1450,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t /* print differences if found */ if (nfound_b && opts->mode_verbose) { H5O_info2_t oi1, oi2; - char *obj1_str = NULL, *obj2_str = NULL; + char * obj1_str = NULL, *obj2_str = NULL; H5Oget_info3(obj1_id, &oi1, H5O_INFO_BASIC); H5Oget_info3(obj2_id, &oi2, H5O_INFO_BASIC); @@ -1411,7 +1460,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t H5Otoken_to_str(obj2_id, &oi2.token, &obj2_str); parallel_print("Referenced dataset %s %s\n", obj1_str, obj2_str); - parallel_print( "------------------------------------------------------------\n"); + parallel_print("------------------------------------------------------------\n"); H5free_memory(obj1_str); H5free_memory(obj2_str); @@ -1437,24 +1486,24 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t */ if (npoints1 > 0) { H5TOOLS_DEBUG("region compare points"); - alloc_size = (hsize_t) npoints1 * (unsigned) ndims1 * sizeof(ptdata1[0]); - HDassert(alloc_size == (hsize_t)((size_t )alloc_size)); /*check for overflow*/ + alloc_size = (hsize_t)npoints1 * (unsigned)ndims1 * sizeof(ptdata1[0]); + HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { + if ((ptdata1 = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) { opts->err_stat = H5DIFF_ERR; H5TOOLS_INFO("Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); - H5Sget_select_elem_pointlist(region1_id, (hsize_t) 0, (hsize_t) npoints1, ptdata1); + H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1); - if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { + if ((ptdata2 = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) { opts->err_stat = H5DIFF_ERR; H5TOOLS_INFO("Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); - H5Sget_select_elem_pointlist(region2_id, (hsize_t) 0, (hsize_t) npoints2, ptdata2); + H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2); for (i = 0; i < npoints1; i++) { hsize_t pt1, pt2; @@ -1471,7 +1520,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t parallel_print("Region points\n"); for (i = 0; i < npoints1; i++) { hsize_t pt1, pt2; - int diff_data = 0; + int diff_data = 0; for (j = 0; j < ndims1; j++) { pt1 = ptdata1[i * ndims1 + j]; @@ -1492,9 +1541,9 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t HDfree(ptdata2); } /* else ptdata2 */ -#if defined (H5DIFF_DEBUG) +#if defined(H5DIFF_DEBUG) for (i = 0; i < npoints1; i++) { - parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i); + parallel_print("%sPt%lu: ", i ? "," : "", (unsigned long)i); for (j = 0; j < ndims1; j++) parallel_print("%s%lu", j ? "," : "(", (unsigned long)(ptdata1[i * ndims1 + j])); @@ -1508,8 +1557,8 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t } /* else ptdata1 */ } - nfound_b = nfound_b / (unsigned) ndims1; - nfound_p = nfound_p / (unsigned) ndims1; + nfound_b = nfound_b / (unsigned)ndims1; + nfound_p = nfound_p / (unsigned)ndims1; ret_value = nfound_p + nfound_b; @@ -1527,7 +1576,8 @@ done: *------------------------------------------------------------------------- */ -static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t u, diff_opt_t *opts) +static hsize_t +character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t u, diff_opt_t *opts) { hsize_t nfound = 0; /* differences found */ char temp1_uchar; @@ -1540,7 +1590,7 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t if (temp1_uchar != temp2_uchar) { if (print_data(opts)) { opts->print_percentage = 0; - opts->print_dims = 1; + opts->print_dims = 1; print_pos(opts, elemtno, u); parallel_print(" "); h5diff_print_char(temp1_uchar); @@ -1563,7 +1613,8 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t *------------------------------------------------------------------------- */ -static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, diff_opt_t *opts) +static hsize_t +character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, diff_opt_t *opts) { hsize_t nfound = 0; /* differences found */ unsigned char temp1_uchar; @@ -1578,7 +1629,7 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, h /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { + if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) { opts->print_percentage = 0; print_pos(opts, elemtno, 0); if (print_data(opts)) { @@ -1602,7 +1653,7 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, h /* -d and -p */ else if (opts->delta_bool && opts->percent_bool) { PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); - if (per > opts->percent && PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { + if (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) { opts->print_percentage = 1; print_pos(opts, elemtno, 0); if (print_data(opts)) { @@ -1630,18 +1681,19 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, h * Purpose: diff a single H5T_NATIVE_FLOAT type * * Return: number of differences found -* + * *------------------------------------------------------------------------- */ -static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ float temp1_float; float temp2_float; double per; hbool_t both_zero = FALSE; - hbool_t isnan1 = FALSE; - hbool_t isnan2 = FALSE; + hbool_t isnan1 = FALSE; + hbool_t isnan2 = FALSE; H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); @@ -1666,11 +1718,12 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if ((double) ABS(temp1_float - temp2_float) > opts->delta) { + if ((double)ABS(temp1_float - temp2_float) > opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float)); } nfound++; } @@ -1680,15 +1733,16 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float)); } nfound++; } } /*------------------------------------------------------------------------- - * !-d and -p - *------------------------------------------------------------------------- - */ + * !-d and -p + *------------------------------------------------------------------------- + */ else if (!opts->delta_bool && opts->percent_bool) { /*------------------------------------------------------------------------- * detect NaNs @@ -1706,7 +1760,8 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float)); } nfound++; } @@ -1714,8 +1769,9 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, - (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float)); + parallel_print(F_FORMAT_P, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float), + (double)ABS(1 - temp2_float / temp1_float)); } nfound++; } @@ -1725,15 +1781,16 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float)); } nfound++; } } /*------------------------------------------------------------------------- - * -d and -p - *------------------------------------------------------------------------- - */ + * -d and -p + *------------------------------------------------------------------------- + */ else if (opts->delta_bool && opts->percent_bool) { /*------------------------------------------------------------------------- * detect NaNs @@ -1752,16 +1809,18 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float)); } nfound++; } - else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) { + else if (per > opts->percent && (double)ABS(temp1_float - temp2_float) > opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, - (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float)); + parallel_print(F_FORMAT_P, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float), + (double)ABS(1 - temp2_float / temp1_float)); } nfound++; } @@ -1771,21 +1830,23 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float)); } nfound++; } } /*------------------------------------------------------------------------- - * no -d and -p - *------------------------------------------------------------------------- - */ + * no -d and -p + *------------------------------------------------------------------------- + */ else { if (equal_float(temp1_float, temp2_float, opts) == FALSE) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float, + (double)ABS(temp1_float - temp2_float)); } nfound++; } @@ -1803,15 +1864,16 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ double temp1_double; double temp2_double; double per; hbool_t both_zero = FALSE; - hbool_t isnan1 = FALSE; - hbool_t isnan2 = FALSE; + hbool_t isnan1 = FALSE; + hbool_t isnan2 = FALSE; H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); @@ -1819,14 +1881,14 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi HDmemcpy(&temp2_double, mem2, sizeof(double)); /*------------------------------------------------------------------------- - * -d and !-p - *------------------------------------------------------------------------- - */ + * -d and !-p + *------------------------------------------------------------------------- + */ if (opts->delta_bool && !opts->percent_bool) { /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ + * detect NaNs + *------------------------------------------------------------------------- + */ if (opts->do_nans) { isnan1 = HDisnan(temp1_double); isnan2 = HDisnan(temp2_double); @@ -1834,7 +1896,7 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > opts->delta) { + if (ABS(temp1_double - temp2_double) > opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -1855,14 +1917,14 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi } /*------------------------------------------------------------------------- - * !-d and -p - *------------------------------------------------------------------------- - */ + * !-d and -p + *------------------------------------------------------------------------- + */ else if (!opts->delta_bool && opts->percent_bool) { /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ + * detect NaNs + *------------------------------------------------------------------------- + */ if (opts->do_nans) { isnan1 = HDisnan(temp1_double); isnan2 = HDisnan(temp2_double); @@ -1875,7 +1937,8 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, + ABS(temp1_double - temp2_double)); } nfound++; } @@ -1883,8 +1946,8 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT_P, temp1_double, temp2_double, - ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); + parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), + ABS(1 - temp2_double / temp1_double)); } nfound++; } @@ -1900,14 +1963,14 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi } } /*------------------------------------------------------------------------- - * -d and -p - *------------------------------------------------------------------------- - */ + * -d and -p + *------------------------------------------------------------------------- + */ else if (opts->delta_bool && opts->percent_bool) { /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ + * detect NaNs + *------------------------------------------------------------------------- + */ if (opts->do_nans) { isnan1 = HDisnan(temp1_double); isnan2 = HDisnan(temp2_double); @@ -1917,20 +1980,21 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi if (!isnan1 && !isnan2) { PER(temp1_double, temp2_double); - if (not_comparable && !both_zero) { + if (not_comparable && !both_zero) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, + ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) { + else if (per > opts->percent && ABS(temp1_double - temp2_double) > opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(F_FORMAT_P, temp1_double, temp2_double, - ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); + parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), + ABS(1 - temp2_double / temp1_double)); } nfound++; } @@ -1946,9 +2010,9 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi } } /*------------------------------------------------------------------------- - * no -d and -p - *------------------------------------------------------------------------- - */ + * no -d and -p + *------------------------------------------------------------------------- + */ else { if (equal_double(temp1_double, temp2_double, opts) == FALSE) { opts->print_percentage = 0; @@ -1972,17 +2036,18 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi * Return: number of differences found *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 -static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ long double temp1_double; long double temp2_double; double per; hbool_t both_zero = FALSE; - hbool_t isnan1 = FALSE; - hbool_t isnan2 = FALSE; + hbool_t isnan1 = FALSE; + hbool_t isnan2 = FALSE; H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); @@ -2007,7 +2072,7 @@ static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hs /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > opts->delta) { + if (ABS(temp1_double - temp2_double) > opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2042,13 +2107,14 @@ static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hs /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - PER(temp1_double,temp2_double); + PER(temp1_double, temp2_double); if (not_comparable && !both_zero) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, + ABS(temp1_double - temp2_double)); } nfound++; } @@ -2056,7 +2122,8 @@ static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hs opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); + parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), + ABS(1 - temp2_double / temp1_double)); } nfound++; } @@ -2087,21 +2154,23 @@ static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hs /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - PER(temp1_double,temp2_double); + PER(temp1_double, temp2_double); if (not_comparable && !both_zero) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, + ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) { + else if (per > opts->percent && ABS(temp1_double - temp2_double) > opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); + parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), + ABS(1 - temp2_double / temp1_double)); } nfound++; } @@ -2143,7 +2212,8 @@ static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hs * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ char temp1_char; @@ -2157,7 +2227,7 @@ static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsiz /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (ABS(temp1_char-temp2_char) > opts->delta) { + if (ABS(temp1_char - temp2_char) > opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2230,7 +2300,8 @@ static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsiz * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned char temp1_uchar; @@ -2317,7 +2388,8 @@ static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsiz * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ short temp1_short; @@ -2404,7 +2476,8 @@ static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsiz * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned short temp1_ushort; @@ -2435,7 +2508,8 @@ static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); + parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, + PDIFF(temp1_ushort, temp2_ushort)); } nfound++; } @@ -2443,7 +2517,8 @@ static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); + parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), + per); } nfound++; } @@ -2456,7 +2531,8 @@ static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); + parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, + PDIFF(temp1_ushort, temp2_ushort)); } nfound++; } @@ -2464,7 +2540,8 @@ static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); + parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), + per); } nfound++; } @@ -2489,9 +2566,10 @@ static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsi * Purpose: diff a single H5T_NATIVE_INT type * * Return: number of differences found - *------------------------------------------------------------------------- + *------------------------------------------------------------------------- */ -static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ int temp1_int; @@ -2505,7 +2583,7 @@ static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_ HDmemcpy(&temp2_int, mem2, sizeof(int)); /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (ABS(temp1_int-temp2_int) > opts->delta) { + if (ABS(temp1_int - temp2_int) > opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2578,13 +2656,14 @@ static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_ * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { - hsize_t nfound = 0; /* number of differences found */ + hsize_t nfound = 0; /* number of differences found */ unsigned int temp1_uint; unsigned int temp2_uint; - double per; - hbool_t both_zero = FALSE; + double per; + hbool_t both_zero = FALSE; H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); @@ -2634,7 +2713,7 @@ static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize } nfound++; } - else if (per > opts->percent && PDIFF(temp1_uint,temp2_uint) > opts->delta) { + else if (per > opts->percent && PDIFF(temp1_uint, temp2_uint) > opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2665,12 +2744,13 @@ static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ - long temp1_long; - long temp2_long; - double per; + long temp1_long; + long temp2_long; + double per; hbool_t both_zero = FALSE; H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); @@ -2679,7 +2759,7 @@ static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize HDmemcpy(&temp2_long, mem2, sizeof(long)); /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (ABS(temp1_long-temp2_long) > opts->delta) { + if (ABS(temp1_long - temp2_long) > opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2721,7 +2801,7 @@ static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize } nfound++; } - else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) { + else if (per > opts->percent && ABS(temp1_long - temp2_long) > opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2752,7 +2832,8 @@ static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned long temp1_ulong; @@ -2783,7 +2864,8 @@ static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); + parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, + PDIFF(temp1_ulong, temp2_ulong)); } nfound++; } @@ -2804,11 +2886,12 @@ static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); + parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, + PDIFF(temp1_ulong, temp2_ulong)); } nfound++; } - else if (per > opts->percent && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) { + else if (per > opts->percent && PDIFF(temp1_ulong, temp2_ulong) > opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2839,7 +2922,8 @@ static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsiz * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ long long temp1_llong; @@ -2854,7 +2938,7 @@ static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsiz /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (ABS( temp1_llong-temp2_llong) > opts->delta) { + if (ABS(temp1_llong - temp2_llong) > opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2871,7 +2955,8 @@ static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); + parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, + ABS(temp1_llong - temp2_llong)); } nfound++; } @@ -2879,7 +2964,7 @@ static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per); + parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong), per); } nfound++; } @@ -2892,15 +2977,16 @@ static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsiz opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); + parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, + ABS(temp1_llong - temp2_llong)); } nfound++; } - else if (per > opts->percent && ABS(temp1_llong-temp2_llong) > opts->delta) { + else if (per > opts->percent && ABS(temp1_llong - temp2_llong) > opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per); + parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong), per); } nfound++; } @@ -2929,7 +3015,8 @@ static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsiz * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +static hsize_t +diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned long long temp1_ullong; @@ -2945,7 +3032,7 @@ static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsi /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) { + if (PDIFF(temp1_ullong, temp2_ullong) > (unsigned long long)opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2964,7 +3051,8 @@ static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong)); + parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, + PDIFF(temp1_ullong, temp2_ullong)); } nfound++; } @@ -2972,7 +3060,8 @@ static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong,temp2_ullong), per); + parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong), + per); } nfound++; } @@ -2987,15 +3076,17 @@ static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsi opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong)); + parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, + PDIFF(temp1_ullong, temp2_ullong)); } nfound++; } - else if (per > opts->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) { + else if (per > opts->percent && PDIFF(temp1_ullong, temp2_ullong) > (unsigned long long)opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { - parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong), per); + parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong), + per); } nfound++; } @@ -3021,11 +3112,11 @@ static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsi * Purpose: convert unsigned long long to float *------------------------------------------------------------------------- */ -static -int ull2float(unsigned long long ull_value, float *f_value) +static int +ull2float(unsigned long long ull_value, float *f_value) { hid_t dxpl_id = H5I_INVALID_HID; - unsigned char *buf = NULL; + unsigned char *buf = NULL; size_t src_size; size_t dst_size; int ret_value = 0; @@ -3036,21 +3127,23 @@ int ull2float(unsigned long long ull_value, float *f_value) src_size = H5Tget_size(H5T_NATIVE_ULLONG); dst_size = H5Tget_size(H5T_NATIVE_FLOAT); - if((buf = (unsigned char*) HDcalloc((size_t )1, MAX(src_size, dst_size))) == NULL) + if ((buf = (unsigned char *)HDcalloc((size_t)1, MAX(src_size, dst_size))) == NULL) H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for dims"); HDmemcpy(buf, &ull_value, src_size); /* do conversion */ - if (H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t) 1, buf, NULL, dxpl_id) < 0) + if (H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t)1, buf, NULL, dxpl_id) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Tconvert failed"); HDmemcpy(f_value, buf, dst_size); done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dxpl_id); - } H5E_END_TRY; + } + H5E_END_TRY; if (buf) HDfree(buf); @@ -3065,26 +3158,28 @@ done: * Purpose: use a absolute error formula to deal with floating point uncertainty *------------------------------------------------------------------------- */ -static hbool_t equal_double(double value, double expected, diff_opt_t *opts) { +static hbool_t +equal_double(double value, double expected, diff_opt_t *opts) +{ if (opts->do_nans) { /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ + * detect NaNs + *------------------------------------------------------------------------- + */ hbool_t isnan1 = HDisnan(value); hbool_t isnan2 = HDisnan(expected); /*------------------------------------------------------------------------- - * we consider NaN == NaN to be true - *------------------------------------------------------------------------- - */ + * we consider NaN == NaN to be true + *------------------------------------------------------------------------- + */ if (isnan1 && isnan2) return TRUE; /*------------------------------------------------------------------------- - * one is a NaN, do not compare but assume difference - *------------------------------------------------------------------------- - */ + * one is a NaN, do not compare but assume difference + *------------------------------------------------------------------------- + */ if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) return FALSE; } @@ -3110,9 +3205,9 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *opts) { *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE !=0 -static -hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts) +#if H5_SIZEOF_LONG_DOUBLE != 0 +static hbool_t +equal_ldouble(long double value, long double expected, diff_opt_t *opts) { if (opts->do_nans) { /*------------------------------------------------------------------------- @@ -3159,12 +3254,14 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts) * Purpose: use a absolute error formula to deal with floating point uncertainty *------------------------------------------------------------------------- */ -static hbool_t equal_float(float value, float expected, diff_opt_t *opts) { +static hbool_t +equal_float(float value, float expected, diff_opt_t *opts) +{ if (opts->do_nans) { /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ + * detect NaNs + *------------------------------------------------------------------------- + */ hbool_t isnan1 = HDisnan(value); hbool_t isnan2 = HDisnan(expected); @@ -3197,7 +3294,6 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) { return FALSE; } - /*------------------------------------------------------------------------- * * Local functions @@ -3211,8 +3307,8 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) { * Purpose: print data only in report or verbose modes, and do not print in quiet mode *------------------------------------------------------------------------- */ -static -int print_data(diff_opt_t *opts) +static int +print_data(diff_opt_t *opts) { return ((opts->mode_report || opts->mode_verbose) && !opts->mode_quiet) ? 1 : 0; } @@ -3223,8 +3319,8 @@ int print_data(diff_opt_t *opts) * Purpose: print header for difference *------------------------------------------------------------------------- */ -static -void print_header(diff_opt_t *opts) +static void +print_header(diff_opt_t *opts) { /* print header */ parallel_print("%-16s", "size:"); @@ -3234,16 +3330,14 @@ void print_header(diff_opt_t *opts) parallel_print("\n"); if (opts->print_percentage) { - parallel_print("%-15s %-15s %-15s %-15s %-15s\n", "position", - opts->obj_name[0], opts->obj_name[1], "difference", "relative"); - parallel_print( - "------------------------------------------------------------------------\n"); + parallel_print("%-15s %-15s %-15s %-15s %-15s\n", "position", opts->obj_name[0], opts->obj_name[1], + "difference", "relative"); + parallel_print("------------------------------------------------------------------------\n"); } else { - parallel_print("%-15s %-15s %-15s %-20s\n", "position", - opts->obj_name[0], opts->obj_name[1], "difference"); - parallel_print( - "------------------------------------------------------------\n"); + parallel_print("%-15s %-15s %-15s %-20s\n", "position", opts->obj_name[0], opts->obj_name[1], + "difference"); + parallel_print("------------------------------------------------------------\n"); } } @@ -3253,10 +3347,10 @@ void print_header(diff_opt_t *opts) * Purpose: print in matrix notation, converting from an array index position *------------------------------------------------------------------------- */ -static -void print_pos(diff_opt_t *opts, hsize_t idx, size_t u) +static void +print_pos(diff_opt_t *opts, hsize_t idx, size_t u) { - int i,j; + int i, j; H5TOOLS_START_DEBUG(" -- idx:%ld", idx); @@ -3269,7 +3363,7 @@ void print_pos(diff_opt_t *opts, hsize_t idx, size_t u) } /* end print header */ H5TOOLS_DEBUG("rank=%d", opts->rank); - if(opts->rank > 0) { + if (opts->rank > 0) { hsize_t curr_pos = idx; parallel_print("[ "); @@ -3278,30 +3372,35 @@ void print_pos(diff_opt_t *opts, hsize_t idx, size_t u) if (opts->sset[0] != NULL) { /* Subsetting is used - calculate total position */ hsize_t elmnt_cnt = 1; - hsize_t dim_cnt = 0; /* previous dim size */ - hsize_t str_cnt = 0; /* previous dim stride */ - hsize_t curr_idx = idx; /* calculated running position */ - hsize_t str_idx = 0; - hsize_t blk_idx = 0; - hsize_t cnt_idx = 0; - hsize_t hs_idx = 0; - j = opts->rank-1; + hsize_t dim_cnt = 0; /* previous dim size */ + hsize_t str_cnt = 0; /* previous dim stride */ + hsize_t curr_idx = idx; /* calculated running position */ + hsize_t str_idx = 0; + hsize_t blk_idx = 0; + hsize_t cnt_idx = 0; + hsize_t hs_idx = 0; + j = opts->rank - 1; do { cnt_idx = opts->sset[0]->count.data[j]; /* Count value for current dim */ - H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - count:%ld", j, curr_pos, curr_idx, cnt_idx); + H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - count:%ld", j, + curr_pos, curr_idx, cnt_idx); blk_idx = opts->sset[0]->block.data[j]; /* Block value for current dim */ - H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - block:%ld", j, curr_pos, curr_idx, blk_idx); + H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - block:%ld", j, + curr_pos, curr_idx, blk_idx); hs_idx = cnt_idx * blk_idx; /* hyperslab area value for current dim */ - H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - hs:%ld", j, curr_pos, curr_idx, hs_idx); + H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - hs:%ld", j, curr_pos, + curr_idx, hs_idx); str_idx = opts->sset[0]->stride.data[j]; /* Stride value for current dim */ - H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - stride:%ld", j, curr_pos, curr_idx, str_idx); + H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - stride:%ld", j, + curr_pos, curr_idx, str_idx); elmnt_cnt *= opts->dims[j]; /* Total number of elements in dimension */ H5TOOLS_DEBUG("... sset loop:%d with elmnt_cnt:%ld", j, elmnt_cnt); if (str_idx > blk_idx) curr_idx += dim_cnt * (str_idx - blk_idx); /* */ else if (curr_idx >= hs_idx) curr_idx += dim_cnt * str_cnt; - H5TOOLS_DEBUG("... sset loop:%d with idx:%ld (curr_idx:%ld) - stride:%ld", j, idx, curr_idx, str_idx); + H5TOOLS_DEBUG("... sset loop:%d with idx:%ld (curr_idx:%ld) - stride:%ld", j, idx, + curr_idx, str_idx); dim_cnt = elmnt_cnt; /* */ if (str_idx > blk_idx) str_cnt = str_idx - blk_idx; /* */ @@ -3320,8 +3419,9 @@ void print_pos(diff_opt_t *opts, hsize_t idx, size_t u) calc_acc_pos((unsigned)opts->rank, curr_pos, opts->acc, opts->pos); for (i = 0; i < opts->rank; i++) { - H5TOOLS_DEBUG("pos loop:%d with opts->pos=%ld opts->sm_pos=%ld", i, opts->pos[i], opts->sm_pos[i]); - opts->pos[i] += (unsigned long) opts->sm_pos[i]; + H5TOOLS_DEBUG("pos loop:%d with opts->pos=%ld opts->sm_pos=%ld", i, opts->pos[i], + opts->sm_pos[i]); + opts->pos[i] += (unsigned long)opts->sm_pos[i]; H5TOOLS_DEBUG("pos loop:%d with opts->pos=%ld", i, opts->pos[i]); parallel_print(HSIZE_T_FORMAT, (unsigned long long)opts->pos[i]); parallel_print(" "); @@ -3350,36 +3450,37 @@ void print_pos(diff_opt_t *opts, hsize_t idx, size_t u) * Purpose: Print a char *------------------------------------------------------------------------- */ -static void h5diff_print_char(char ch) +static void +h5diff_print_char(char ch) { switch (ch) { - case '"': - parallel_print("\\\""); - break; - case '\\': - parallel_print("\\\\"); - break; - case '\b': - parallel_print("\\b"); - break; - case '\f': - parallel_print("\\f"); - break; - case '\n': - parallel_print("\\n"); - break; - case '\r': - parallel_print("\\r"); - break; - case '\t': - parallel_print("\\t"); - break; - default: - if (isprint(ch)) - parallel_print("%c", ch); - else - parallel_print("\\%03o", ch); - break; + case '"': + parallel_print("\\\""); + break; + case '\\': + parallel_print("\\\\"); + break; + case '\b': + parallel_print("\\b"); + break; + case '\f': + parallel_print("\\f"); + break; + case '\n': + parallel_print("\\n"); + break; + case '\r': + parallel_print("\\r"); + break; + case '\t': + parallel_print("\\t"); + break; + default: + if (isprint(ch)) + parallel_print("%c", ch); + else + parallel_print("\\%03o", ch); + break; } } @@ -3388,7 +3489,8 @@ static void h5diff_print_char(char ch) * set up compound datatype structures. *------------------------------------------------------------------------- */ -static void get_member_types(hid_t tid, mcomp_t *members) +static void +get_member_types(hid_t tid, mcomp_t *members) { int tclass; unsigned u; @@ -3407,16 +3509,16 @@ static void get_member_types(hid_t tid, mcomp_t *members) if ((nmembs = H5Tget_nmembers(tid)) <= 0) return; - members->n = (unsigned) nmembs; + members->n = (unsigned)nmembs; - members->ids = (hid_t *) HDcalloc((size_t )members->n, sizeof(hid_t)); - members->offsets = (size_t *) HDcalloc((size_t )members->n, sizeof(size_t)); - members->m = (mcomp_t **) HDcalloc((size_t )members->n, sizeof(mcomp_t *)); + members->ids = (hid_t *)HDcalloc((size_t)members->n, sizeof(hid_t)); + members->offsets = (size_t *)HDcalloc((size_t)members->n, sizeof(size_t)); + members->m = (mcomp_t **)HDcalloc((size_t)members->n, sizeof(mcomp_t *)); for (u = 0; u < members->n; u++) { - members->ids[u] = H5Tget_member_type(tid, u); + members->ids[u] = H5Tget_member_type(tid, u); members->offsets[u] = H5Tget_member_offset(tid, u); - members->m[u] = (mcomp_t *) HDmalloc(sizeof(mcomp_t)); + members->m[u] = (mcomp_t *)HDmalloc(sizeof(mcomp_t)); HDmemset(members->m[u], 0, sizeof(mcomp_t)); get_member_types(members->ids[u], members->m[u]); } @@ -3430,7 +3532,8 @@ static void get_member_types(hid_t tid, mcomp_t *members) * clean and close compound members. *------------------------------------------------------------------------- */ -static void close_member_types(mcomp_t *members) +static void +close_member_types(mcomp_t *members) { unsigned u; @@ -3449,4 +3552,3 @@ static void close_member_types(mcomp_t *members) HDfree(members->ids); HDfree(members->offsets); } - diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index b7ec2e8..f2ff292 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -19,19 +19,18 @@ #define ATTR_NAME_MAX 255 typedef struct table_attr_t { - char *name; - unsigned exist[2]; + char * name; + unsigned exist[2]; } match_attr_t; typedef struct table_attrs_t { - size_t size; - size_t nattrs; - size_t nattrs_only1; - size_t nattrs_only2; + size_t size; + size_t nattrs; + size_t nattrs_only1; + size_t nattrs_only2; match_attr_t *attrs; } table_attrs_t; - /*------------------------------------------------------------------------- * Function: table_attrs_init * @@ -44,15 +43,16 @@ typedef struct table_attrs_t { * * Date: March 15, 2011 *------------------------------------------------------------------------*/ -static void table_attrs_init(table_attrs_t **tbl) +static void +table_attrs_init(table_attrs_t **tbl) { - table_attrs_t* table_attrs = (table_attrs_t*) HDmalloc(sizeof(table_attrs_t)); + table_attrs_t *table_attrs = (table_attrs_t *)HDmalloc(sizeof(table_attrs_t)); - table_attrs->size = 0; - table_attrs->nattrs = 0; + table_attrs->size = 0; + table_attrs->nattrs = 0; table_attrs->nattrs_only1 = 0; table_attrs->nattrs_only2 = 0; - table_attrs->attrs = NULL; + table_attrs->attrs = NULL; *tbl = table_attrs; } @@ -69,7 +69,8 @@ static void table_attrs_init(table_attrs_t **tbl) * * Date: March 15, 2011 *------------------------------------------------------------------------*/ -static void table_attrs_free( table_attrs_t *table ) +static void +table_attrs_free(table_attrs_t *table) { unsigned int i; @@ -102,24 +103,25 @@ static void table_attrs_free( table_attrs_t *table ) * * Date: March 15, 2011 *------------------------------------------------------------------------*/ -static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *table) +static void +table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *table) { - if(table->nattrs == table->size) { + if (table->nattrs == table->size) { match_attr_t *new_attrs; table->size = MAX(1, table->size * 2); - new_attrs = (match_attr_t *)HDrealloc(table->attrs, table->size * sizeof(match_attr_t)); - if(new_attrs) + new_attrs = (match_attr_t *)HDrealloc(table->attrs, table->size * sizeof(match_attr_t)); + if (new_attrs) table->attrs = new_attrs; } /* end if */ - if(table->nattrs < table->size) { + if (table->nattrs < table->size) { size_t curr_val; - curr_val = table->nattrs; + curr_val = table->nattrs; table->attrs[curr_val].exist[0] = exist[0]; table->attrs[curr_val].exist[1] = exist[1]; - if(name) + if (name) table->attrs[curr_val].name = (char *)HDstrdup(name); table->nattrs++; } @@ -137,14 +139,15 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta * Parameter: * table_out [OUT] : return the list *------------------------------------------------------------------------*/ -static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts) +static herr_t +build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t **table_out, diff_opt_t *opts) { table_attrs_t *table_lp = NULL; - H5O_info2_t oinfo1, oinfo2; /* Object info */ - hid_t attr1_id = H5I_INVALID_HID; /* attr ID */ - hid_t attr2_id = H5I_INVALID_HID; /* attr ID */ - size_t curr1 = 0; - size_t curr2 = 0; + H5O_info2_t oinfo1, oinfo2; /* Object info */ + hid_t attr1_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr2_id = H5I_INVALID_HID; /* attr ID */ + size_t curr1 = 0; + size_t curr2 = 0; unsigned infile[2]; char name1[ATTR_NAME_MAX]; char name2[ATTR_NAME_MAX]; @@ -154,11 +157,11 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); - if(H5Oget_info3(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) { + if (H5Oget_info3(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) { H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info first object failed"); } H5TOOLS_DEBUG("H5Oget_info3 loc1id=%d", oinfo1.num_attrs); - if(H5Oget_info3(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) { + if (H5Oget_info3(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) { H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info second object failed"); } H5TOOLS_DEBUG("H5Oget_info3 loc2id=%d", oinfo2.num_attrs); @@ -170,37 +173,39 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /*-------------------------------------------------- * build the list */ - while(curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs) { + while (curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs) { H5TOOLS_DEBUG("list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs); H5TOOLS_DEBUG("list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs); /*------------------ - * open attribute1 */ - if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * open attribute1 */ + if ((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, + H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx first attribute failed"); /* get name */ - if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0) + if (H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name first attribute failed"); /*------------------ - * open attribute2 */ - if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * open attribute2 */ + if ((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, + H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx second attribute failed"); /* get name */ - if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0) + if (H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name second attribute failed"); /* criteria is string compare */ cmp = HDstrcmp(name1, name2); - if(cmp == 0) { + if (cmp == 0) { infile[0] = 1; infile[1] = 1; table_attr_mark_exist(infile, name1, table_lp); curr1++; curr2++; } - else if(cmp < 0) { + else if (cmp < 0) { infile[0] = 1; infile[1] = 0; table_attr_mark_exist(infile, name1, table_lp); @@ -225,15 +230,16 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /* list1 did not end */ infile[0] = 1; infile[1] = 0; - while(curr1 < oinfo1.num_attrs) { + while (curr1 < oinfo1.num_attrs) { H5TOOLS_DEBUG("list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs); /*------------------ - * open attribute1 */ - if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * open attribute1 */ + if ((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, + H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx first attribute failed"); /* get name */ - if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0) + if (H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name first attribute failed"); H5TOOLS_DEBUG("list_attrs 1 name - %s", name1); @@ -249,14 +255,15 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /* list2 did not end */ infile[0] = 0; infile[1] = 1; - while(curr2 < oinfo2.num_attrs) { + while (curr2 < oinfo2.num_attrs) { H5TOOLS_DEBUG("list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs); /*------------------ - * open attribute2 */ - if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * open attribute2 */ + if ((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, + H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx second attribute failed"); /* get name */ - if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0) + if (H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name second attribute failed"); H5TOOLS_DEBUG("list_attrs 2 name - %s", name2); @@ -272,11 +279,11 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /*------------------------------------------------------ * print the list */ - if(opts->mode_verbose_level == 2) { + if (opts->mode_verbose_level == 2) { /* if '-v2' is detected */ parallel_print(" obj1 obj2\n"); parallel_print(" --------------------------------------\n"); - for(i = 0; i < (unsigned int) table_lp->nattrs; i++) { + for (i = 0; i < (unsigned int)table_lp->nattrs; i++) { int c1, c2; c1 = (table_lp->attrs[i].exist[0]) ? 'x' : ' '; c2 = (table_lp->attrs[i].exist[1]) ? 'x' : ' '; @@ -284,19 +291,21 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t } /* end for */ } - if(opts->mode_verbose_level >= 1) + if (opts->mode_verbose_level >= 1) parallel_print("Attributes status: %d common, %d only in obj1, %d only in obj2\n", - table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2, - table_lp->nattrs_only1, table_lp->nattrs_only2); + table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2, + table_lp->nattrs_only1, table_lp->nattrs_only2); done: *table_out = table_lp; /* disable error reporting */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(attr1_id); H5Aclose(attr2_id); - } H5E_END_TRY; + } + H5E_END_TRY; H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat); @@ -313,73 +322,74 @@ done: *------------------------------------------------------------------------- */ -hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, - const char *name1, const char *name2, const char *path1, const char *path2, diff_opt_t *opts) +hsize_t +diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2, const char *path1, + const char *path2, diff_opt_t *opts) { - hid_t space1_id = H5I_INVALID_HID; /* space ID */ - hid_t space2_id = H5I_INVALID_HID; /* space ID */ - hid_t ftype1_id = H5I_INVALID_HID; /* file data type ID */ - hid_t ftype2_id = H5I_INVALID_HID; /* file data type ID */ - hid_t mtype1_id = H5I_INVALID_HID; /* memory data type ID */ - hid_t mtype2_id = H5I_INVALID_HID; /* memory data type ID */ - size_t msize1; /* memory size of memory type */ - size_t msize2; /* memory size of memory type */ - void *buf1 = NULL; /* data buffer */ - void *buf2 = NULL; /* data buffer */ - hbool_t buf1hasdata = FALSE; /* buffer has data */ - hbool_t buf2hasdata = FALSE; /* buffer has data */ - int rank1; /* rank of dataset */ - int rank2; /* rank of dataset */ - hsize_t dims1[H5S_MAX_RANK]; /* dimensions of dataset */ - hsize_t dims2[H5S_MAX_RANK]; /* dimensions of dataset */ + hid_t space1_id = H5I_INVALID_HID; /* space ID */ + hid_t space2_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype1_id = H5I_INVALID_HID; /* file data type ID */ + hid_t ftype2_id = H5I_INVALID_HID; /* file data type ID */ + hid_t mtype1_id = H5I_INVALID_HID; /* memory data type ID */ + hid_t mtype2_id = H5I_INVALID_HID; /* memory data type ID */ + size_t msize1; /* memory size of memory type */ + size_t msize2; /* memory size of memory type */ + void * buf1 = NULL; /* data buffer */ + void * buf2 = NULL; /* data buffer */ + hbool_t buf1hasdata = FALSE; /* buffer has data */ + hbool_t buf2hasdata = FALSE; /* buffer has data */ + int rank1; /* rank of dataset */ + int rank2; /* rank of dataset */ + hsize_t dims1[H5S_MAX_RANK]; /* dimensions of dataset */ + hsize_t dims2[H5S_MAX_RANK]; /* dimensions of dataset */ hsize_t nfound = 0; int j; diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); /* get the datatypes */ - if((ftype1_id = H5Aget_type(attr1_id)) < 0) + if ((ftype1_id = H5Aget_type(attr1_id)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); - if((ftype2_id = H5Aget_type(attr2_id)) < 0) + if ((ftype2_id = H5Aget_type(attr2_id)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); if (H5Tget_class(ftype1_id) == H5T_REFERENCE) { - if((mtype1_id = H5Tcopy(H5T_STD_REF)) < 0) + if ((mtype1_id = H5Tcopy(H5T_STD_REF)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) first attribute ftype failed"); } else { - if((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0) + if ((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type first attribute ftype failed"); } if (H5Tget_class(ftype2_id) == H5T_REFERENCE) { - if((mtype2_id = H5Tcopy(H5T_STD_REF)) < 0) + if ((mtype2_id = H5Tcopy(H5T_STD_REF)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) second attribute ftype failed"); } else { - if((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0) + if ((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type second attribute ftype failed"); } - if((msize1 = H5Tget_size(mtype1_id)) == 0) + if ((msize1 = H5Tget_size(mtype1_id)) == 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_size first attribute mtype failed"); - if((msize2 = H5Tget_size(mtype2_id)) == 0) + if ((msize2 = H5Tget_size(mtype2_id)) == 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_size second attribute mtype failed"); /* get the dataspace */ - if((space1_id = H5Aget_space(attr1_id)) < 0) + if ((space1_id = H5Aget_space(attr1_id)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_space first attribute failed"); - if((space2_id = H5Aget_space(attr2_id)) < 0) + if ((space2_id = H5Aget_space(attr2_id)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_space second attribute failed"); /* get dimensions */ - if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0) + if ((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims first attribute failed"); - if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0) + if ((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims second attribute failed"); /*---------------------------------------------------------------------- - * check for comparable TYPE and SPACE - *---------------------------------------------------------------------- - */ + * check for comparable TYPE and SPACE + *---------------------------------------------------------------------- + */ H5TOOLS_DEBUG("Check for comparable TYPE and SPACE"); H5TOOLS_DEBUG("attr_names: %s - %s", name1, name2); @@ -402,22 +412,22 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, H5TOOLS_DEBUG("attr_names: %s - %s", opts->obj_name[0], opts->obj_name[1]); /* pass dims1 and dims2 for maxdims as well since attribute's maxdims - * are always same */ - if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, opts, 0) == 1) { + * are always same */ + if (diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, opts, 0) == 1) { /*----------------------------------------------------------------- - * "upgrade" the smaller memory size - *------------------------------------------------------------------ - */ - if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2)) + * "upgrade" the smaller memory size + *------------------------------------------------------------------ + */ + if (FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed"); H5TOOLS_DEBUG("initialize read"); /*--------------------------------------------------------------------- - * initialize diff_opt_t structure for dimensions - *---------------------------------------------------------------------- - */ + * initialize diff_opt_t structure for dimensions + *---------------------------------------------------------------------- + */ opts->nelmts = 1; - for(j = 0; j < rank1; j++) { + for (j = 0; j < rank1; j++) { opts->dims[j] = dims1[j]; opts->nelmts *= dims1[j]; } @@ -425,17 +435,17 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, init_acc_pos((unsigned)opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx); /*--------------------------------------------------------------------- - * read - *---------------------------------------------------------------------- - */ + * read + *---------------------------------------------------------------------- + */ buf1 = (void *)HDcalloc((size_t)(opts->nelmts), msize1); buf2 = (void *)HDcalloc((size_t)(opts->nelmts), msize2); H5TOOLS_DEBUG("attr buffer size %ld * %ld", opts->nelmts, msize1); - if(buf1 == NULL || buf2 == NULL) { + if (buf1 == NULL || buf2 == NULL) { parallel_print("cannot read into memory\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "buffer allocation failed"); } - if(H5Aread(attr1_id, mtype1_id, buf1) < 0) { + if (H5Aread(attr1_id, mtype1_id, buf1) < 0) { parallel_print("Failed reading attribute1 %s\n", name1); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); } @@ -443,7 +453,7 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, buf1hasdata = TRUE; H5TOOLS_DEBUG("attr H5Aread 1"); - if(H5Aread(attr2_id, mtype2_id, buf2) < 0) { + if (H5Aread(attr2_id, mtype2_id, buf2) < 0) { parallel_print("Failed reading attribute2 %s\n", name2); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); } @@ -453,10 +463,10 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, /* format output string */ if (opts->obj_name[0] != NULL) - HDfree(opts->obj_name[0]); + HDfree(opts->obj_name[0]); opts->obj_name[0] = NULL; if (opts->obj_name[1] != NULL) - HDfree(opts->obj_name[1]); + HDfree(opts->obj_name[1]); opts->obj_name[1] = NULL; H5TOOLS_DEBUG("attr_names: %s - %s : %s - %s", name1, name2, path1, path2); @@ -480,13 +490,13 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, } /*--------------------------------------------------------------------- - * array compare - *---------------------------------------------------------------------- - */ + * array compare + *---------------------------------------------------------------------- + */ H5TOOLS_DEBUG("array compare %s - %s", opts->obj_name[0], opts->obj_name[1]); opts->hs_nelmts = opts->nelmts; - opts->m_tid = mtype1_id; + opts->m_tid = mtype1_id; /* initialize the current stripmine position; this is necessary to print the array indices */ for (j = 0; j < opts->rank; j++) @@ -494,14 +504,14 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, /* always print name */ /* verbose (-v) and report (-r) mode */ - if(opts->mode_verbose || opts->mode_report) { + if (opts->mode_verbose || opts->mode_report) { do_print_attrname("attribute", opts->obj_name[0], opts->obj_name[1]); nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id); print_found(nfound); } /* quiet mode (-q), just count differences */ - else if(opts->mode_quiet) { + else if (opts->mode_quiet) { nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id); } /* the rest (-c, none, ...) */ @@ -513,57 +523,59 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, do_print_attrname("attribute", opts->obj_name[0], opts->obj_name[1]); print_found(nfound); } /* end if */ - } /* end else */ + } /* end else */ } - H5TOOLS_DEBUG("check for comparable TYPE and SPACE complete nfound:%d - errstat:%d", nfound, opts->err_stat); + H5TOOLS_DEBUG("check for comparable TYPE and SPACE complete nfound:%d - errstat:%d", nfound, + opts->err_stat); /*---------------------------------------------------------------------- - * close - *---------------------------------------------------------------------- - */ - if (opts->obj_name[0] != NULL) + * close + *---------------------------------------------------------------------- + */ + if (opts->obj_name[0] != NULL) HDfree(opts->obj_name[0]); - opts->obj_name[0] = NULL; - if (opts->obj_name[1] != NULL) + opts->obj_name[0] = NULL; + if (opts->obj_name[1] != NULL) HDfree(opts->obj_name[1]); - opts->obj_name[1] = NULL; + opts->obj_name[1] = NULL; /* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any - * VLEN memory first */ - if(TRUE == h5tools_detect_vlen(mtype1_id)) + * VLEN memory first */ + if (TRUE == h5tools_detect_vlen(mtype1_id)) H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); HDfree(buf1); buf1 = NULL; - if(TRUE == h5tools_detect_vlen(mtype2_id)) + if (TRUE == h5tools_detect_vlen(mtype2_id)) H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); HDfree(buf2); buf2 = NULL; - if(H5Tclose(ftype1_id) < 0) + if (H5Tclose(ftype1_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); - if(H5Tclose(ftype2_id) < 0) + if (H5Tclose(ftype2_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); - if(H5Sclose(space1_id) < 0) + if (H5Sclose(space1_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); - if(H5Sclose(space2_id) < 0) + if (H5Sclose(space2_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); - if(H5Tclose(mtype1_id) < 0) + if (H5Tclose(mtype1_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose first attribute mtype failed"); - if(H5Tclose(mtype2_id) < 0) + if (H5Tclose(mtype2_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose second attribute mtype failed"); done: opts->err_stat = opts->err_stat | ret_value; - H5E_BEGIN_TRY { - if(buf1) { - if(buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id)) + H5E_BEGIN_TRY + { + if (buf1) { + if (buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id)) H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); HDfree(buf1); } /* end if */ - if(buf2) { - if(buf2hasdata && TRUE == h5tools_detect_vlen(mtype2_id)) + if (buf2) { + if (buf2hasdata && TRUE == h5tools_detect_vlen(mtype2_id)) H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); HDfree(buf2); } /* end if */ @@ -574,7 +586,8 @@ done: H5Tclose(mtype2_id); H5Sclose(space1_id); H5Sclose(space2_id); - } H5E_END_TRY; + } + H5E_END_TRY; H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat); @@ -594,58 +607,60 @@ done: *------------------------------------------------------------------------- */ -hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, diff_opt_t *opts) +hsize_t +diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, diff_opt_t *opts) { table_attrs_t *match_list_attrs = NULL; - hid_t attr1_id = H5I_INVALID_HID; /* attr ID */ - hid_t attr2_id = H5I_INVALID_HID; /* attr ID */ - char *name1 = NULL; - char *name2 = NULL; - unsigned u; /* Local index variable */ - hsize_t nfound = 0; + hid_t attr1_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr2_id = H5I_INVALID_HID; /* attr ID */ + char * name1 = NULL; + char * name2 = NULL; + unsigned u; /* Local index variable */ + hsize_t nfound = 0; hsize_t nfound_total = 0; - diff_opt_t attr_opts; + diff_opt_t attr_opts; diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); - attr_opts = *opts; + attr_opts = *opts; attr_opts.obj_name[0] = NULL; attr_opts.obj_name[1] = NULL; - if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, &attr_opts) < 0) { + if (build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, &attr_opts) < 0) { H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "build_match_list_attrs failed"); } - H5TOOLS_DEBUG("check match_list_attrs - opts->contents:%d - errstat:%d", attr_opts.contents, attr_opts.err_stat); + H5TOOLS_DEBUG("check match_list_attrs - opts->contents:%d - errstat:%d", attr_opts.contents, + attr_opts.err_stat); /* if detect any unique extra attr */ - if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) { + if (match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) { H5TOOLS_DEBUG("attributes only in one file"); /* exit will be 1 */ attr_opts.contents = 0; } H5TOOLS_DEBUG("match_list_attrs info - opts->contents:%d", attr_opts.contents); - for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++) { + for (u = 0; u < (unsigned)match_list_attrs->nattrs; u++) { H5TOOLS_DEBUG("match_list_attrs loop[%d] - errstat:%d", u, attr_opts.err_stat); - if((match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1])) { + if ((match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1])) { name1 = name2 = match_list_attrs->attrs[u].name; H5TOOLS_DEBUG("name - %s", name1); /*-------------- - * attribute 1 */ - if((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0) + * attribute 1 */ + if ((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aopen first attribute failed"); /*-------------- - * attribute 2 */ - if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0) + * attribute 2 */ + if ((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aopen second attribute failed"); H5TOOLS_DEBUG("got attributes"); nfound = diff_attr_data(attr1_id, attr2_id, name1, name2, path1, path2, &attr_opts); - if(H5Aclose(attr1_id) < 0) + if (H5Aclose(attr1_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); - if(H5Aclose(attr2_id) < 0) + if (H5Aclose(attr2_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); nfound_total += nfound; @@ -654,18 +669,19 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *p done: opts->print_header = attr_opts.print_header; - opts->contents = attr_opts.contents; - opts->not_cmp = attr_opts.not_cmp; - opts->err_stat = attr_opts.err_stat | ret_value; + opts->contents = attr_opts.contents; + opts->not_cmp = attr_opts.not_cmp; + opts->err_stat = attr_opts.err_stat | ret_value; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { table_attrs_free(match_list_attrs); H5Aclose(attr1_id); H5Aclose(attr2_id); - } H5E_END_TRY; + } + H5E_END_TRY; H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat); return nfound_total; } - diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 944440e..f98ba3f 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -17,7 +17,6 @@ #include "h5diff.h" #include "ph5diff.h" - /*------------------------------------------------------------------------- * Function: diff_dataset * @@ -31,16 +30,16 @@ hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, diff_opt_t *opts) { int status = -1; - hid_t did1 = H5I_INVALID_HID; - hid_t did2 = H5I_INVALID_HID; - hid_t dcpl1 = H5I_INVALID_HID; - hid_t dcpl2 = H5I_INVALID_HID; + hid_t did1 = H5I_INVALID_HID; + hid_t did2 = H5I_INVALID_HID; + hid_t dcpl1 = H5I_INVALID_HID; + hid_t dcpl2 = H5I_INVALID_HID; hsize_t nfound = 0; diff_opt_t diff_opts; diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); - diff_opts = *opts; + diff_opts = *opts; diff_opts.obj_name[0] = NULL; diff_opts.obj_name[1] = NULL; @@ -50,18 +49,18 @@ diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char * *------------------------------------------------------------------------- */ /* Open the datasets */ - if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) { + if ((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) { parallel_print("Cannot open dataset <%s>\n", obj1_name); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 first dataset failed"); } - if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) { + if ((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) { parallel_print("Cannot open dataset <%s>\n", obj2_name); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 second dataset failed"); } - if((dcpl1 = H5Dget_create_plist(did1)) < 0) + if ((dcpl1 = H5Dget_create_plist(did1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist first dataset failed"); - if((dcpl2 = H5Dget_create_plist(did2)) < 0) + if ((dcpl2 = H5Dget_create_plist(did2)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist second dataset failed"); /*------------------------------------------------------------------------- @@ -73,29 +72,31 @@ diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char * */ H5TOOLS_DEBUG("h5tools_canreadf then diff_datasetid"); if ((status = h5tools_canreadf((opts->mode_verbose ? obj1_name : NULL), dcpl1) == 1) && - (status = h5tools_canreadf((opts->mode_verbose ? obj2_name : NULL), dcpl2) == 1)) + (status = h5tools_canreadf((opts->mode_verbose ? obj2_name : NULL), dcpl2) == 1)) nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, &diff_opts); else if (status < 0) { H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "h5tools_canreadf failed"); } else { - ret_value = 1; + ret_value = 1; diff_opts.not_cmp = 1; } done: opts->print_header = diff_opts.print_header; - opts->not_cmp = diff_opts.not_cmp; - opts->err_stat = diff_opts.err_stat | ret_value; + opts->not_cmp = diff_opts.not_cmp; + opts->err_stat = diff_opts.err_stat | ret_value; /* disable error reporting */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl1); H5Pclose(dcpl2); H5Dclose(did1); H5Dclose(did2); /* enable error reporting */ - } H5E_END_TRY; + } + H5E_END_TRY; H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); return nfound; @@ -155,67 +156,67 @@ done: hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_name, diff_opt_t *opts) { - hid_t sid1 = H5I_INVALID_HID; - hid_t sid2 = H5I_INVALID_HID; - hid_t f_tid1 = H5I_INVALID_HID; - hid_t f_tid2 = H5I_INVALID_HID; - hid_t m_tid1 = H5I_INVALID_HID; - hid_t m_tid2 = H5I_INVALID_HID; - hid_t dcpl1 = H5I_INVALID_HID; - hid_t dcpl2 = H5I_INVALID_HID; - H5D_layout_t stl1 = -1; - H5D_layout_t stl2 = -1; - size_t m_size1; - size_t m_size2; - H5T_sign_t sign1; - H5T_sign_t sign2; - int rank1; - int rank2; - hsize_t nelmts1; - hsize_t nelmts2; - hsize_t dims1[H5S_MAX_RANK]; - hsize_t dims2[H5S_MAX_RANK]; - hsize_t maxdim1[H5S_MAX_RANK]; - hsize_t maxdim2[H5S_MAX_RANK]; - hsize_t storage_size1; - hsize_t storage_size2; - hsize_t nfound = 0; /* number of differences found */ - int can_compare = 1; /* do diff or not */ - void *buf1 = NULL; - void *buf2 = NULL; - void *sm_buf1 = NULL; - void *sm_buf2 = NULL; - hid_t sm_space1 = H5I_INVALID_HID; /*stripmine data space */ - hid_t sm_space2 = H5I_INVALID_HID; /*stripmine data space */ - size_t need; /* bytes needed for malloc */ - int i, j; - unsigned int vl_data1 = 0; /*contains VL datatypes */ - unsigned int vl_data2 = 0; /*contains VL datatypes */ - diff_err_t ret_value = opts->err_stat; + hid_t sid1 = H5I_INVALID_HID; + hid_t sid2 = H5I_INVALID_HID; + hid_t f_tid1 = H5I_INVALID_HID; + hid_t f_tid2 = H5I_INVALID_HID; + hid_t m_tid1 = H5I_INVALID_HID; + hid_t m_tid2 = H5I_INVALID_HID; + hid_t dcpl1 = H5I_INVALID_HID; + hid_t dcpl2 = H5I_INVALID_HID; + H5D_layout_t stl1 = -1; + H5D_layout_t stl2 = -1; + size_t m_size1; + size_t m_size2; + H5T_sign_t sign1; + H5T_sign_t sign2; + int rank1; + int rank2; + hsize_t nelmts1; + hsize_t nelmts2; + hsize_t dims1[H5S_MAX_RANK]; + hsize_t dims2[H5S_MAX_RANK]; + hsize_t maxdim1[H5S_MAX_RANK]; + hsize_t maxdim2[H5S_MAX_RANK]; + hsize_t storage_size1; + hsize_t storage_size2; + hsize_t nfound = 0; /* number of differences found */ + int can_compare = 1; /* do diff or not */ + void * buf1 = NULL; + void * buf2 = NULL; + void * sm_buf1 = NULL; + void * sm_buf2 = NULL; + hid_t sm_space1 = H5I_INVALID_HID; /*stripmine data space */ + hid_t sm_space2 = H5I_INVALID_HID; /*stripmine data space */ + size_t need; /* bytes needed for malloc */ + int i, j; + unsigned int vl_data1 = 0; /*contains VL datatypes */ + unsigned int vl_data2 = 0; /*contains VL datatypes */ + diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); /* Get the dataspace handle */ - if((sid1 = H5Dget_space(did1)) < 0) + if ((sid1 = H5Dget_space(did1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_space failed"); /* Get rank */ - if((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0) + if ((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_ndims failed"); /* Get the dataspace handle */ - if((sid2 = H5Dget_space(did2)) < 0 ) + if ((sid2 = H5Dget_space(did2)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_space failed"); /* Get rank */ - if((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0) + if ((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_ndims failed"); /* Get dimensions */ - if(H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0) + if (H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims failed"); /* Get dimensions */ - if(H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0) + if (H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims failed"); H5TOOLS_DEBUG("rank: %ld - %ld", rank1, rank2); @@ -225,26 +226,26 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n */ /* Get the data type */ - if((f_tid1 = H5Dget_type(did1)) < 0) + if ((f_tid1 = H5Dget_type(did1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_type failed"); /* Get the data type */ - if((f_tid2 = H5Dget_type(did2)) < 0) + if ((f_tid2 = H5Dget_type(did2)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_type failed"); /*------------------------------------------------------------------------- * get the storage layout type *------------------------------------------------------------------------- */ - if((dcpl1 = H5Dget_create_plist(did1)) < 0) + if ((dcpl1 = H5Dget_create_plist(did1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed"); - if((stl1 = H5Pget_layout(dcpl1)) < 0) + if ((stl1 = H5Pget_layout(dcpl1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed"); H5Pclose(dcpl1); - if((dcpl2 = H5Dget_create_plist(did2)) < 0) + if ((dcpl2 = H5Dget_create_plist(did2)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed"); - if((stl2 = H5Pget_layout(dcpl2)) < 0) + if ((stl2 = H5Pget_layout(dcpl2)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed"); H5Pclose(dcpl2); @@ -258,15 +259,15 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n storage_size2 = H5Dget_storage_size(did2); H5TOOLS_DEBUG("storage size: %ld - %ld", storage_size1, storage_size2); - if(storage_size1 == 0 || storage_size2 == 0) { - if(stl1 == H5D_VIRTUAL || stl2 == H5D_VIRTUAL) { - if((opts->mode_verbose||opts->mode_list_not_cmp) && obj1_name && obj2_name) + if (storage_size1 == 0 || storage_size2 == 0) { + if (stl1 == H5D_VIRTUAL || stl2 == H5D_VIRTUAL) { + if ((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) parallel_print("Warning: <%s> or <%s> is a virtual dataset\n", obj1_name, obj2_name); } else { - if((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) + if ((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) parallel_print("Not comparable: <%s> or <%s> is an empty dataset\n", obj1_name, obj2_name); - can_compare = 0; + can_compare = 0; opts->not_cmp = 1; } } @@ -282,7 +283,6 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n } } - opts->obj_name[1] = NULL; if (obj2_name) { j = (int)HDstrlen(obj2_name); @@ -307,20 +307,20 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n */ H5TOOLS_DEBUG("check for memory type and sizes"); if (H5Tget_class(f_tid1) == H5T_REFERENCE) { - if((m_tid1 = H5Tcopy(H5T_STD_REF)) < 0) + if ((m_tid1 = H5Tcopy(H5T_STD_REF)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) first ftype failed"); } else { - if((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0) + if ((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type first ftype failed"); } if (H5Tget_class(f_tid2) == H5T_REFERENCE) { - if((m_tid2 = H5Tcopy(H5T_STD_REF)) < 0) + if ((m_tid2 = H5Tcopy(H5T_STD_REF)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) second ftype failed"); } else { - if((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0) + if ((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type second ftype failed"); } @@ -332,18 +332,18 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n * check for different signed/unsigned types *------------------------------------------------------------------------- */ - if(can_compare) { + if (can_compare) { H5TOOLS_DEBUG("can_compare for sign"); sign1 = H5Tget_sign(m_tid1); sign2 = H5Tget_sign(m_tid2); - if(sign1 != sign2) { + if (sign1 != sign2) { H5TOOLS_DEBUG("sign1 != sign2"); - if((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) { + if ((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1)); parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2)); } - can_compare = 0; + can_compare = 0; opts->not_cmp = 1; } H5TOOLS_DEBUG("can_compare for sign - can_compare=%d opts->not_cmp=%d", can_compare, opts->not_cmp); @@ -352,9 +352,9 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n /* Check if type is either VLEN-data or VLEN-string to reclaim any * VLEN memory buffer later */ - if(TRUE == h5tools_detect_vlen(m_tid1)) + if (TRUE == h5tools_detect_vlen(m_tid1)) vl_data1 = TRUE; - if(TRUE == h5tools_detect_vlen(m_tid2)) + if (TRUE == h5tools_detect_vlen(m_tid2)) vl_data2 = TRUE; H5TOOLS_DEBUG("h5tools_detect_vlen %d:%d - errstat:%d", vl_data1, vl_data2, opts->err_stat); @@ -362,61 +362,61 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n * only attempt to compare if possible *------------------------------------------------------------------------- */ - if(can_compare) { /* it is possible to compare */ - H5T_class_t tclass = H5Tget_class(f_tid1); + if (can_compare) { /* it is possible to compare */ + H5T_class_t tclass = H5Tget_class(f_tid1); H5TOOLS_DEBUG("can_compare attempt"); /*----------------------------------------------------------------- - * get number of elements - *------------------------------------------------------------------ - */ + * get number of elements + *------------------------------------------------------------------ + */ nelmts1 = 1; - for(i = 0; i < rank1; i++) + for (i = 0; i < rank1; i++) nelmts1 *= dims1[i]; nelmts2 = 1; - for(i = 0; i < rank2; i++) + for (i = 0; i < rank2; i++) nelmts2 *= dims2[i]; H5TOOLS_DEBUG("nelmts: %ld - %ld", nelmts1, nelmts2); - if(tclass != H5T_ARRAY) { + if (tclass != H5T_ARRAY) { /*----------------------------------------------------------------- * "upgrade" the smaller memory size *------------------------------------------------------------------ */ H5TOOLS_DEBUG("NOT H5T_ARRAY, upgrade the smaller memory size?"); - if (FAIL == match_up_memsize (f_tid1, f_tid2, &m_tid1, &m_tid2, &m_size1, &m_size2)) + if (FAIL == match_up_memsize(f_tid1, f_tid2, &m_tid1, &m_tid2, &m_size1, &m_size2)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed"); H5TOOLS_DEBUG("m_size: %ld - %ld", m_size1, m_size2); opts->rank = rank1; - for(i = 0; i < rank1; i++) + for (i = 0; i < rank1; i++) opts->dims[i] = dims1[i]; opts->m_size = m_size1; - opts->m_tid = m_tid1; + opts->m_tid = m_tid1; opts->nelmts = nelmts1; - need = (size_t)(nelmts1 * m_size1); /* bytes needed */ + need = (size_t)(nelmts1 * m_size1); /* bytes needed */ } else { H5TOOLS_DEBUG("Array dims: %d - %d", dims1[0], dims2[0]); /* Compare the smallest array, but create the largest buffer */ - if(m_size1 <= m_size2) { + if (m_size1 <= m_size2) { opts->rank = rank1; - for(i = 0; i < rank1; i++) + for (i = 0; i < rank1; i++) opts->dims[i] = dims1[i]; opts->m_size = m_size1; - opts->m_tid = m_tid1; + opts->m_tid = m_tid1; opts->nelmts = nelmts1; - need = (size_t)(nelmts2 * m_size2); /* bytes needed */ + need = (size_t)(nelmts2 * m_size2); /* bytes needed */ } else { opts->rank = rank2; - for(i = 0; i < rank2; i++) + for (i = 0; i < rank2; i++) opts->dims[i] = dims2[i]; opts->m_size = m_size2; - opts->m_tid = m_tid2; + opts->m_tid = m_tid2; opts->nelmts = nelmts2; - need = (size_t)(nelmts1 * m_size1); /* bytes needed */ + need = (size_t)(nelmts1 * m_size1); /* bytes needed */ } } opts->hs_nelmts = opts->nelmts; @@ -425,25 +425,24 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name); if (opts->obj_name[0] != NULL) - HDfree(opts->obj_name[0]); + HDfree(opts->obj_name[0]); opts->obj_name[0] = NULL; if (opts->obj_name[1] != NULL) - HDfree(opts->obj_name[1]); + HDfree(opts->obj_name[1]); opts->obj_name[1] = NULL; - if(obj1_name) + if (obj1_name) opts->obj_name[0] = HDstrdup(diff_basename(obj1_name)); - if(obj2_name) + if (obj2_name) opts->obj_name[1] = HDstrdup(diff_basename(obj2_name)); H5TOOLS_DEBUG("obj_names: %s - %s", opts->obj_name[0], opts->obj_name[1]); - H5TOOLS_DEBUG("read/compare"); /*---------------------------------------------------------------- * read/compare *----------------------------------------------------------------- */ - if(need < H5TOOLS_MALLOCSIZE) { + if (need < H5TOOLS_MALLOCSIZE) { buf1 = HDmalloc(need); buf2 = HDmalloc(need); } /* end if */ @@ -451,17 +450,17 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n /* Assume entire data space to be printed */ init_acc_pos((unsigned)opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx); - for(i = 0; i < opts->rank; i++) { + for (i = 0; i < opts->rank; i++) { opts->p_max_idx[i] = opts->dims[i]; } - if(buf1 != NULL && buf2 != NULL && opts->sset[0] == NULL && opts->sset[1] == NULL) { + if (buf1 != NULL && buf2 != NULL && opts->sset[0] == NULL && opts->sset[1] == NULL) { H5TOOLS_DEBUG("buf1 != NULL && buf2 != NULL"); H5TOOLS_DEBUG("H5Dread did1"); - if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) + if (H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); H5TOOLS_DEBUG("H5Dread did2"); - if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) + if (H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); /* initialize the current stripmine position; this is necessary to print the array indices */ @@ -474,60 +473,60 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n /* reclaim any VL memory, if necessary */ H5TOOLS_DEBUG("check vl_data1:%d", vl_data1); - if(vl_data1) + if (vl_data1) H5Treclaim(m_tid1, sid1, H5P_DEFAULT, buf1); H5TOOLS_DEBUG("check vl_data2:%d", vl_data2); - if(vl_data2) + if (vl_data2) H5Treclaim(m_tid2, sid2, H5P_DEFAULT, buf2); - if(buf1 != NULL) { + if (buf1 != NULL) { HDfree(buf1); buf1 = NULL; } - if(buf2 != NULL) { + if (buf2 != NULL) { HDfree(buf2); buf2 = NULL; } - } /* end if */ - else { /* possibly not enough memory, read/compare by hyperslabs */ - hsize_t elmtno; /* counter */ - int carry; /* counter carry value */ + } /* end if */ + else { /* possibly not enough memory, read/compare by hyperslabs */ + hsize_t elmtno; /* counter */ + int carry; /* counter carry value */ /* stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ - hsize_t sm_block[H5S_MAX_RANK]; /* stripmine block size */ - hsize_t sm_nbytes; /* bytes per stripmine */ - hsize_t sm_nelmts1; /* elements per stripmine */ - hsize_t sm_nelmts2; /* elements per stripmine */ - hssize_t ssm_nelmts; /* elements temp */ + hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ + hsize_t sm_block[H5S_MAX_RANK]; /* stripmine block size */ + hsize_t sm_nbytes; /* bytes per stripmine */ + hsize_t sm_nelmts1; /* elements per stripmine */ + hsize_t sm_nelmts2; /* elements per stripmine */ + hssize_t ssm_nelmts; /* elements temp */ /* hyperslab info */ - hsize_t hs_offset1[H5S_MAX_RANK]; /* starting offset */ - hsize_t hs_count1[H5S_MAX_RANK]; /* number of blocks */ - hsize_t hs_block1[H5S_MAX_RANK]; /* size of blocks */ - hsize_t hs_stride1[H5S_MAX_RANK]; /* stride */ - hsize_t hs_size1[H5S_MAX_RANK]; /* size this pass */ - hsize_t hs_offset2[H5S_MAX_RANK]; /* starting offset */ - hsize_t hs_count2[H5S_MAX_RANK]; /* number of blocks */ - hsize_t hs_block2[H5S_MAX_RANK]; /* size of blocks */ - hsize_t hs_stride2[H5S_MAX_RANK]; /* stride */ - hsize_t hs_size2[H5S_MAX_RANK]; /* size this pass */ - hsize_t hs_nelmts1 = 0; /* elements in request */ - hsize_t hs_nelmts2 = 0; /* elements in request */ - hsize_t zero[8]; /* vector of zeros */ - hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */ - hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */ + hsize_t hs_offset1[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_count1[H5S_MAX_RANK]; /* number of blocks */ + hsize_t hs_block1[H5S_MAX_RANK]; /* size of blocks */ + hsize_t hs_stride1[H5S_MAX_RANK]; /* stride */ + hsize_t hs_size1[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_offset2[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_count2[H5S_MAX_RANK]; /* number of blocks */ + hsize_t hs_block2[H5S_MAX_RANK]; /* size of blocks */ + hsize_t hs_stride2[H5S_MAX_RANK]; /* stride */ + hsize_t hs_size2[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_nelmts1 = 0; /* elements in request */ + hsize_t hs_nelmts2 = 0; /* elements in request */ + hsize_t zero[8]; /* vector of zeros */ + hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */ + hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */ H5TOOLS_DEBUG("reclaim any VL memory and free unused buffers"); - if(buf1 != NULL) { + if (buf1 != NULL) { /* reclaim any VL memory, if necessary */ - if(vl_data1) + if (vl_data1) H5Treclaim(m_tid1, sid1, H5P_DEFAULT, buf1); HDfree(buf1); buf1 = NULL; } - if(buf2 != NULL) { + if (buf2 != NULL) { /* reclaim any VL memory, if necessary */ - if(vl_data2) + if (vl_data2) H5Treclaim(m_tid2, sid2, H5P_DEFAULT, buf2); HDfree(buf2); buf2 = NULL; @@ -547,37 +546,39 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n HDmemset(zero, 0, sizeof zero); /* if subsetting was requested - initialize the subsetting variables */ - H5TOOLS_DEBUG("compare by hyperslabs: opts->nelmts=%ld - opts->m_size=%ld", opts->nelmts, opts->m_size); + H5TOOLS_DEBUG("compare by hyperslabs: opts->nelmts=%ld - opts->m_size=%ld", opts->nelmts, + opts->m_size); if (opts->sset[0] != NULL) { H5TOOLS_DEBUG("opts->sset[0] != NULL"); /* Check for valid settings - default if not specified */ - if(!opts->sset[0]->start.data || !opts->sset[0]->stride.data || !opts->sset[0]->count.data || !opts->sset[0]->block.data) { + if (!opts->sset[0]->start.data || !opts->sset[0]->stride.data || !opts->sset[0]->count.data || + !opts->sset[0]->block.data) { /* they didn't specify a ``stride'' or ``block''. default to 1 in all * dimensions */ - if(!opts->sset[0]->start.data) { + if (!opts->sset[0]->start.data) { /* default to (0, 0, ...) for the start coord */ opts->sset[0]->start.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t)); - opts->sset[0]->start.len = (unsigned)rank1; + opts->sset[0]->start.len = (unsigned)rank1; } - if(!opts->sset[0]->stride.data) { + if (!opts->sset[0]->stride.data) { opts->sset[0]->stride.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t)); - opts->sset[0]->stride.len = (unsigned)rank1; + opts->sset[0]->stride.len = (unsigned)rank1; for (i = 0; i < rank1; i++) opts->sset[0]->stride.data[i] = 1; } - if(!opts->sset[0]->count.data) { + if (!opts->sset[0]->count.data) { opts->sset[0]->count.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t)); - opts->sset[0]->count.len = (unsigned)rank1; + opts->sset[0]->count.len = (unsigned)rank1; for (i = 0; i < rank1; i++) opts->sset[0]->count.data[i] = 1; } - if(!opts->sset[0]->block.data) { + if (!opts->sset[0]->block.data) { opts->sset[0]->block.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t)); - opts->sset[0]->block.len = (unsigned)rank1; + opts->sset[0]->block.len = (unsigned)rank1; for (i = 0; i < rank1; i++) opts->sset[0]->block.data[i] = 1; } @@ -586,13 +587,13 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n * check for block overlap *------------------------------------------------------------------------- */ - for(i = 0; i < rank1; i++) { - if(opts->sset[0]->count.data[i] > 1) { - if(opts->sset[0]->stride.data[i] < opts->sset[0]->block.data[i]) { + for (i = 0; i < rank1; i++) { + if (opts->sset[0]->count.data[i] > 1) { + if (opts->sset[0]->stride.data[i] < opts->sset[0]->block.data[i]) { H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "wrong subset selection[0]; blocks overlap"); } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ } /* Reset the total number of elements to the subset from the command */ @@ -600,43 +601,45 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n for (i = 0; i < rank1; i++) { hs_offset1[i] = opts->sset[0]->start.data[i]; hs_stride1[i] = opts->sset[0]->stride.data[i]; - hs_count1[i] = opts->sset[0]->count.data[i]; - hs_block1[i] = opts->sset[0]->block.data[i]; + hs_count1[i] = opts->sset[0]->count.data[i]; + hs_block1[i] = opts->sset[0]->block.data[i]; opts->nelmts *= hs_count1[i] * hs_block1[i]; hs_size1[i] = 0; - H5TOOLS_DEBUG("[%d]hs_offset1:%ld, hs_stride1:%ld, hs_count1:%ld, hs_block1:%ld", i, hs_offset1[i], hs_stride1[i], hs_count1[i], hs_block1[i]); + H5TOOLS_DEBUG("[%d]hs_offset1:%ld, hs_stride1:%ld, hs_count1:%ld, hs_block1:%ld", i, + hs_offset1[i], hs_stride1[i], hs_count1[i], hs_block1[i]); } } if (opts->sset[1] != NULL) { H5TOOLS_DEBUG("opts->sset[1] != NULL"); /* Check for valid settings - default if not specified */ - if(!opts->sset[1]->start.data || !opts->sset[1]->stride.data || !opts->sset[1]->count.data || !opts->sset[1]->block.data) { + if (!opts->sset[1]->start.data || !opts->sset[1]->stride.data || !opts->sset[1]->count.data || + !opts->sset[1]->block.data) { /* they didn't specify a ``stride'' or ``block''. default to 1 in all * dimensions */ - if(!opts->sset[1]->start.data) { + if (!opts->sset[1]->start.data) { /* default to (0, 0, ...) for the start coord */ opts->sset[1]->start.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t)); - opts->sset[1]->start.len = (unsigned)rank2; + opts->sset[1]->start.len = (unsigned)rank2; } - if(!opts->sset[1]->stride.data) { + if (!opts->sset[1]->stride.data) { opts->sset[1]->stride.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t)); - opts->sset[1]->stride.len = (unsigned)rank2; + opts->sset[1]->stride.len = (unsigned)rank2; for (i = 0; i < rank2; i++) opts->sset[1]->stride.data[i] = 1; } - if(!opts->sset[1]->count.data) { + if (!opts->sset[1]->count.data) { opts->sset[1]->count.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t)); - opts->sset[1]->count.len = (unsigned)rank2; + opts->sset[1]->count.len = (unsigned)rank2; for (i = 0; i < rank2; i++) opts->sset[1]->count.data[i] = 1; } - if(!opts->sset[1]->block.data) { + if (!opts->sset[1]->block.data) { opts->sset[1]->block.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t)); - opts->sset[1]->block.len = (unsigned)rank2; + opts->sset[1]->block.len = (unsigned)rank2; for (i = 0; i < rank2; i++) opts->sset[1]->block.data[i] = 1; } @@ -645,22 +648,23 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n * check for block overlap *------------------------------------------------------------------------- */ - for(i = 0; i < rank2; i++) { - if(opts->sset[1]->count.data[i] > 1) { - if(opts->sset[1]->stride.data[i] < opts->sset[1]->block.data[i]) { + for (i = 0; i < rank2; i++) { + if (opts->sset[1]->count.data[i] > 1) { + if (opts->sset[1]->stride.data[i] < opts->sset[1]->block.data[i]) { H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "wrong subset selection[1]; blocks overlap"); } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ } for (i = 0; i < rank2; i++) { hs_offset2[i] = opts->sset[1]->start.data[i]; hs_stride2[i] = opts->sset[1]->stride.data[i]; - hs_count2[i] = opts->sset[1]->count.data[i]; - hs_block2[i] = opts->sset[1]->block.data[i]; - hs_size2[i] = 0; - H5TOOLS_DEBUG("[%d]hs_offset2:%ld, hs_stride2:%ld, hs_count2:%ld, hs_block2:%ld", i, hs_offset2[i], hs_stride2[i], hs_count2[i], hs_block2[i]); + hs_count2[i] = opts->sset[1]->count.data[i]; + hs_block2[i] = opts->sset[1]->block.data[i]; + hs_size2[i] = 0; + H5TOOLS_DEBUG("[%d]hs_offset2:%ld, hs_stride2:%ld, hs_count2:%ld, hs_block2:%ld", i, + hs_offset2[i], hs_stride2[i], hs_count2[i], hs_block2[i]); } } @@ -669,18 +673,18 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n * a hyperslab whose size is manageable. */ sm_nbytes = opts->m_size; - if(opts->rank > 0) { + if (opts->rank > 0) { for (i = opts->rank; i > 0; --i) { hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; if (size == 0) /* datum size > H5TOOLS_BUFSIZE */ size = 1; H5TOOLS_DEBUG("opts->dims[%d]: %ld - size: %ld", i - 1, opts->dims[i - 1], size); if (opts->sset[1] != NULL) { - sm_size[i - 1] = MIN(hs_block1[i - 1] * hs_count1[i - 1], size); + sm_size[i - 1] = MIN(hs_block1[i - 1] * hs_count1[i - 1], size); sm_block[i - 1] = MIN(hs_block1[i - 1], sm_size[i - 1]); } else { - sm_size[i - 1] = MIN(opts->dims[i - 1], size); + sm_size[i - 1] = MIN(opts->dims[i - 1], size); sm_block[i - 1] = sm_size[i - 1]; } H5TOOLS_DEBUG("sm_size[%d]: %ld - sm_block:%ld", i - 1, sm_size[i - 1], sm_block[i - 1]); @@ -690,84 +694,90 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n } H5TOOLS_DEBUG("opts->nelmts: %ld", opts->nelmts); - for(elmtno = 0; elmtno < opts->nelmts; elmtno += opts->hs_nelmts) { + for (elmtno = 0; elmtno < opts->nelmts; elmtno += opts->hs_nelmts) { H5TOOLS_DEBUG("elmtno: %ld - hs_nelmts1: %ld", elmtno, hs_nelmts1); - if(NULL == (sm_buf1 = (unsigned char *)HDmalloc((size_t) sm_nbytes))) + if (NULL == (sm_buf1 = (unsigned char *)HDmalloc((size_t)sm_nbytes))) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not allocate buffer for strip-mine"); - if(NULL == (sm_buf2 = (unsigned char *)HDmalloc((size_t) sm_nbytes))) + if (NULL == (sm_buf2 = (unsigned char *)HDmalloc((size_t)sm_nbytes))) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not allocate buffer for strip-mine"); /* calculate the hyperslab size */ /* initialize subset */ - if(opts->rank > 0) { + if (opts->rank > 0) { if (opts->sset[0] != NULL) { H5TOOLS_DEBUG("sset1 has data"); /* calculate the potential number of elements */ - for(i = 0; i < rank1; i++) { - H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i, opts->dims[i], hs_offset1[i], sm_block[i]); + for (i = 0; i < rank1; i++) { + H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i, + opts->dims[i], hs_offset1[i], sm_block[i]); hs_size1[i] = MIN(opts->dims[i] - hs_offset1[i], sm_block[i]); H5TOOLS_DEBUG("hs_size1[%d]: %ld", i, hs_size1[i]); } - if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, hs_stride1, hs_count1, hs_size1) < 0) + if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, hs_stride1, hs_count1, + hs_size1) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid1 failed"); } else { - for(i = 0, hs_nelmts1 = 1; i < rank1; i++) { - H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i, opts->dims[i], hs_offset1[i], sm_block[i]); + for (i = 0, hs_nelmts1 = 1; i < rank1; i++) { + H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i, + opts->dims[i], hs_offset1[i], sm_block[i]); hs_size1[i] = MIN(opts->dims[i] - hs_offset1[i], sm_block[i]); H5TOOLS_DEBUG("hs_size1[%d]: %ld", i, hs_size1[i]); hs_nelmts1 *= hs_size1[i]; H5TOOLS_DEBUG("hs_nelmts1:%ld *= hs_size1[%d]: %ld", hs_nelmts1, i, hs_size1[i]); } - if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, NULL, hs_size1, NULL) < 0) + if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, NULL, hs_size1, NULL) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid1 failed"); } - if((ssm_nelmts = H5Sget_select_npoints(sid1)) < 0) + if ((ssm_nelmts = H5Sget_select_npoints(sid1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_npoints failed"); sm_nelmts1 = (hsize_t)ssm_nelmts; H5TOOLS_DEBUG("sm_nelmts1: %ld", sm_nelmts1); hs_nelmts1 = sm_nelmts1; - if((sm_space1 = H5Screate_simple(1, &sm_nelmts1, NULL)) < 0) + if ((sm_space1 = H5Screate_simple(1, &sm_nelmts1, NULL)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Screate_simple failed"); - if(H5Sselect_hyperslab(sm_space1, H5S_SELECT_SET, zero, NULL, &sm_nelmts1, NULL) < 0) + if (H5Sselect_hyperslab(sm_space1, H5S_SELECT_SET, zero, NULL, &sm_nelmts1, NULL) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed"); if (opts->sset[1] != NULL) { H5TOOLS_DEBUG("sset2 has data"); - for(i = 0; i < rank2; i++) { - H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i, opts->dims[i], hs_offset2[i], sm_block[i]); + for (i = 0; i < rank2; i++) { + H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i, + opts->dims[i], hs_offset2[i], sm_block[i]); hs_size2[i] = MIN(opts->dims[i] - hs_offset2[i], sm_block[i]); H5TOOLS_DEBUG("hs_size2[%d]: %ld", i, hs_size2[i]); } - if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, hs_stride2, hs_count2, hs_size2) < 0) + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, hs_stride2, hs_count2, + hs_size2) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid2 failed"); } else { - for(i = 0, hs_nelmts2 = 1; i < rank2; i++) { - H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i, opts->dims[i], hs_offset2[i], sm_block[i]); + for (i = 0, hs_nelmts2 = 1; i < rank2; i++) { + H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i, + opts->dims[i], hs_offset2[i], sm_block[i]); hs_size2[i] = MIN(opts->dims[i] - hs_offset2[i], sm_block[i]); H5TOOLS_DEBUG("hs_size2[%d]: %ld", i, hs_size2[i]); hs_nelmts2 *= hs_size2[i]; H5TOOLS_DEBUG("hs_nelmts2:%ld *= hs_size2[%d]: %ld", hs_nelmts2, i, hs_size2[i]); } - if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid2 failed"); } - if((ssm_nelmts = H5Sget_select_npoints(sid2)) < 0) + if ((ssm_nelmts = H5Sget_select_npoints(sid2)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_npoints failed"); sm_nelmts2 = (hsize_t)ssm_nelmts; H5TOOLS_DEBUG("sm_nelmts2: %ld", sm_nelmts2); hs_nelmts2 = sm_nelmts2; - if((sm_space2 = H5Screate_simple(1, &sm_nelmts2, NULL)) < 0) + if ((sm_space2 = H5Screate_simple(1, &sm_nelmts2, NULL)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Screate_simple failed"); - if(H5Sselect_hyperslab(sm_space2, H5S_SELECT_SET, zero, NULL, &sm_nelmts2, NULL) < 0) + if (H5Sselect_hyperslab(sm_space2, H5S_SELECT_SET, zero, NULL, &sm_nelmts2, NULL) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed"); } else @@ -776,14 +786,14 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n H5TOOLS_DEBUG("hs_nelmts: %ld", opts->hs_nelmts); /* read the data */ - if(H5Dread(did1, m_tid1, sm_space1, sid1, H5P_DEFAULT, sm_buf1) < 0) + if (H5Dread(did1, m_tid1, sm_space1, sid1, H5P_DEFAULT, sm_buf1) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); - if(H5Dread(did2, m_tid2, sm_space2, sid2, H5P_DEFAULT, sm_buf2) < 0) + if (H5Dread(did2, m_tid2, sm_space2, sid2, H5P_DEFAULT, sm_buf2) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); /* print array indices. get the lower bound of the hyperslab and calculate the element position at the start of hyperslab */ - if(H5Sget_select_bounds(sid1, low, high) < 0) + if (H5Sget_select_bounds(sid1, low, high) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_bounds failed"); /* initialize the current stripmine position; this is necessary to print the array indices */ for (j = 0; j < opts->rank; j++) @@ -796,16 +806,16 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n found in each hyperslab and pass the position at the beginning for printing */ nfound += diff_array(sm_buf1, sm_buf2, opts, did1, did2); - if(sm_buf1 != NULL) { + if (sm_buf1 != NULL) { /* reclaim any VL memory, if necessary */ - if(vl_data1) + if (vl_data1) H5Treclaim(m_tid1, sm_space1, H5P_DEFAULT, sm_buf1); HDfree(sm_buf1); sm_buf1 = NULL; } - if(sm_buf2 != NULL) { + if (sm_buf2 != NULL) { /* reclaim any VL memory, if necessary */ - if(vl_data2) + if (vl_data2) H5Treclaim(m_tid2, sm_space2, H5P_DEFAULT, sm_buf2); HDfree(sm_buf2); sm_buf2 = NULL; @@ -815,10 +825,11 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n H5Sclose(sm_space2); /* calculate the next hyperslab offset */ - for(i = opts->rank, carry = 1; i > 0 && carry; --i) { + for (i = opts->rank, carry = 1; i > 0 && carry; --i) { if (opts->sset[0] != NULL) { - H5TOOLS_DEBUG("[%d]hs_size1:%ld - hs_block1:%ld - hs_stride1:%ld", i-1, hs_size1[i-1], hs_block1[i - 1], hs_stride1[i - 1]); - if(hs_size1[i - 1] >= hs_block1[i - 1]) { + H5TOOLS_DEBUG("[%d]hs_size1:%ld - hs_block1:%ld - hs_stride1:%ld", i - 1, + hs_size1[i - 1], hs_block1[i - 1], hs_stride1[i - 1]); + if (hs_size1[i - 1] >= hs_block1[i - 1]) { hs_offset1[i - 1] += hs_size1[i - 1]; } else { @@ -827,15 +838,17 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n } else hs_offset1[i - 1] += hs_size1[i - 1]; - H5TOOLS_DEBUG("[%d]hs_offset1:%ld - opts->dims:%ld", i-1, hs_offset1[i-1], opts->dims[i - 1]); - if(hs_offset1[i - 1] >= opts->dims[i - 1]) + H5TOOLS_DEBUG("[%d]hs_offset1:%ld - opts->dims:%ld", i - 1, hs_offset1[i - 1], + opts->dims[i - 1]); + if (hs_offset1[i - 1] >= opts->dims[i - 1]) hs_offset1[i - 1] = 0; else carry = 0; - H5TOOLS_DEBUG("[%d]hs_offset1:%ld", i-1, hs_offset1[i-1]); + H5TOOLS_DEBUG("[%d]hs_offset1:%ld", i - 1, hs_offset1[i - 1]); if (opts->sset[1] != NULL) { - H5TOOLS_DEBUG("[%d]hs_size2:%ld - hs_block2:%ld - hs_stride2:%ld", i-1, hs_size2[i-1], hs_block2[i - 1], hs_stride2[i - 1]); - if(hs_size2[i - 1] >= hs_block2[i - 1]) { + H5TOOLS_DEBUG("[%d]hs_size2:%ld - hs_block2:%ld - hs_stride2:%ld", i - 1, + hs_size2[i - 1], hs_block2[i - 1], hs_stride2[i - 1]); + if (hs_size2[i - 1] >= hs_block2[i - 1]) { hs_offset2[i - 1] += hs_size2[i - 1]; } else { @@ -844,17 +857,17 @@ diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_n } else hs_offset2[i - 1] += hs_size2[i - 1]; - H5TOOLS_DEBUG("[%d]hs_offset2:%ld - opts->dims:%ld", i-1, hs_offset2[i-1], opts->dims[i - 1]); - if(hs_offset2[i - 1] >= opts->dims[i - 1]) + H5TOOLS_DEBUG("[%d]hs_offset2:%ld - opts->dims:%ld", i - 1, hs_offset2[i - 1], + opts->dims[i - 1]); + if (hs_offset2[i - 1] >= opts->dims[i - 1]) hs_offset2[i - 1] = 0; - H5TOOLS_DEBUG("[%d]hs_offset2:%ld", i-1, hs_offset2[i-1]); + H5TOOLS_DEBUG("[%d]hs_offset2:%ld", i - 1, hs_offset2[i - 1]); } } /* elmtno for loop */ - } /* hyperslab read */ + } /* hyperslab read */ H5TOOLS_DEBUG("can compare complete"); } /*can_compare*/ - /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -866,38 +879,38 @@ done: H5TOOLS_DEBUG("free names - errstat:%d", opts->err_stat); /* free */ if (opts->obj_name[0] != NULL) - HDfree(opts->obj_name[0]); + HDfree(opts->obj_name[0]); opts->obj_name[0] = NULL; if (opts->obj_name[1] != NULL) - HDfree(opts->obj_name[1]); + HDfree(opts->obj_name[1]); opts->obj_name[1] = NULL; H5TOOLS_DEBUG("reclaim any VL memory"); - if(buf1 != NULL) { + if (buf1 != NULL) { /* reclaim any VL memory, if necessary */ - if(vl_data1) + if (vl_data1) H5Treclaim(m_tid1, sid1, H5P_DEFAULT, buf1); HDfree(buf1); buf1 = NULL; } - if(buf2 != NULL) { + if (buf2 != NULL) { /* reclaim any VL memory, if necessary */ - if(vl_data2) + if (vl_data2) H5Treclaim(m_tid2, sid2, H5P_DEFAULT, buf2); HDfree(buf2); buf2 = NULL; } H5TOOLS_DEBUG("reclaim any stripmine VL memory"); - if(sm_buf1 != NULL) { + if (sm_buf1 != NULL) { /* reclaim any VL memory, if necessary */ - if(vl_data1) + if (vl_data1) H5Treclaim(m_tid1, sm_space1, H5P_DEFAULT, sm_buf1); HDfree(sm_buf1); sm_buf1 = NULL; } - if(sm_buf2 != NULL) { + if (sm_buf2 != NULL) { /* reclaim any VL memory, if necessary */ - if(vl_data2) + if (vl_data2) H5Treclaim(m_tid2, sm_space2, H5P_DEFAULT, sm_buf2); HDfree(sm_buf2); sm_buf2 = NULL; @@ -905,7 +918,8 @@ done: H5TOOLS_DEBUG("close ids"); /* disable error reporting */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid1); H5Sclose(sid2); H5Sclose(sm_space1); @@ -917,7 +931,8 @@ done: H5Tclose(m_tid1); H5Tclose(m_tid2); /* enable error reporting */ - } H5E_END_TRY; + } + H5E_END_TRY; H5TOOLS_ENDDEBUG(": %d with nfound:%d", ret_value, nfound); return nfound; @@ -937,37 +952,35 @@ done: int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, hsize_t *dims2, - hsize_t *maxdim1, hsize_t *maxdim2, diff_opt_t *opts, int is_compound) + hsize_t *maxdim1, hsize_t *maxdim2, diff_opt_t *opts, int is_compound) { - H5T_class_t tclass1; - H5T_class_t tclass2; - int maxdim_diff = 0; /* maximum dimensions are different */ - int dim_diff = 0; /* current dimensions are different */ - int i; - int ret_value = 1; + H5T_class_t tclass1; + H5T_class_t tclass2; + int maxdim_diff = 0; /* maximum dimensions are different */ + int dim_diff = 0; /* current dimensions are different */ + int i; + int ret_value = 1; H5TOOLS_START_DEBUG(""); /*------------------------------------------------------------------------- * check for the same class *------------------------------------------------------------------------- */ - if((tclass1 = H5Tget_class(f_tid1)) < 0) + if ((tclass1 = H5Tget_class(f_tid1)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_class first object failed"); - if((tclass2 = H5Tget_class(f_tid2)) < 0) + if ((tclass2 = H5Tget_class(f_tid2)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_class second object failed"); H5TOOLS_DEBUG("obj_names: %s - %s", opts->obj_name[0], opts->obj_name[1]); - if(tclass1 != tclass2) { - if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { - if(is_compound) { + if (tclass1 != tclass2) { + if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { + if (is_compound) { parallel_print("Not comparable: <%s> has a class %s and <%s> has a class %s\n", - opts->obj_name[0], get_class(tclass1), - opts->obj_name[1], get_class(tclass2)); + opts->obj_name[0], get_class(tclass1), opts->obj_name[1], get_class(tclass2)); } else { parallel_print("Not comparable: <%s> is of class %s and <%s> is of class %s\n", - opts->obj_name[0], get_class(tclass1), - opts->obj_name[1], get_class(tclass2)); + opts->obj_name[0], get_class(tclass1), opts->obj_name[1], get_class(tclass2)); } } @@ -981,9 +994,9 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, */ switch (tclass1) { case H5T_TIME: - if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { - parallel_print("Not comparable: <%s> and <%s> are of class %s\n", - opts->obj_name[0], opts->obj_name[1], get_class(tclass2)); + if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { + parallel_print("Not comparable: <%s> and <%s> are of class %s\n", opts->obj_name[0], + opts->obj_name[1], get_class(tclass2)); } /* end if */ opts->not_cmp = 1; @@ -1011,11 +1024,11 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, * check for equal file datatype; warning only *------------------------------------------------------------------------- */ - if((H5Tequal(f_tid1, f_tid2) == 0) && (opts->mode_verbose) && opts->obj_name[0] && opts->obj_name[1]) { + if ((H5Tequal(f_tid1, f_tid2) == 0) && (opts->mode_verbose) && opts->obj_name[0] && opts->obj_name[1]) { H5T_class_t cl = H5Tget_class(f_tid1); parallel_print("Warning: different storage datatype\n"); - if(cl == H5T_INTEGER || cl == H5T_FLOAT) { + if (cl == H5T_INTEGER || cl == H5T_FLOAT) { parallel_print("<%s> has file datatype ", opts->obj_name[0]); print_type(f_tid1); parallel_print("\n"); @@ -1029,13 +1042,13 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, * check for the same rank *------------------------------------------------------------------------- */ - if(rank1 != rank2) { - if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { + if (rank1 != rank2) { + if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { parallel_print("Not comparable: <%s> has rank %d, dimensions ", opts->obj_name[0], rank1); print_dimensions(rank1, dims1); parallel_print(", max dimensions "); print_dimensions(rank1, maxdim1); - parallel_print("\n" ); + parallel_print("\n"); parallel_print("and <%s> has rank %d, dimensions ", opts->obj_name[1], rank2); print_dimensions(rank2, dims2); parallel_print(", max dimensions "); @@ -1051,12 +1064,12 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, * check for different dimensions *------------------------------------------------------------------------- */ - for(i = 0; imode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { + if (dim_diff == 1) { + if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { parallel_print("Not comparable: <%s> has rank %d, dimensions ", opts->obj_name[0], rank1); print_dimensions(rank1, dims1); - if(maxdim1 && maxdim2) { + if (maxdim1 && maxdim2) { parallel_print(", max dimensions "); print_dimensions(rank1, maxdim1); - parallel_print("\n" ); + parallel_print("\n"); parallel_print("and <%s> has rank %d, dimensions ", opts->obj_name[1], rank2); print_dimensions(rank2, dims2); parallel_print(", max dimensions "); @@ -1088,9 +1101,9 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, * maximum dimensions; just give a warning *------------------------------------------------------------------------- */ - if(maxdim1 && maxdim2 && maxdim_diff == 1 && opts->obj_name[0]) { - if(opts->mode_verbose) { - parallel_print( "Warning: different maximum dimensions\n"); + if (maxdim1 && maxdim2 && maxdim_diff == 1 && opts->obj_name[0]) { + if (opts->mode_verbose) { + parallel_print("Warning: different maximum dimensions\n"); parallel_print("<%s> has max dimensions ", opts->obj_name[0]); print_dimensions(rank1, maxdim1); parallel_print("\n"); @@ -1100,7 +1113,7 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, } } - if(tclass1 == H5T_STRING) { + if (tclass1 == H5T_STRING) { htri_t vstrtype1 = -1; htri_t vstrtype2 = -1; H5TOOLS_DEBUG(" - H5T_STRING"); @@ -1110,16 +1123,16 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, /* no compare if either one but not both are variable string type */ if (vstrtype1 != vstrtype2) { - if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) - parallel_print("Not comparable: <%s> or <%s> is of mixed string type\n", - opts->obj_name[0], opts->obj_name[1]); + if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) + parallel_print("Not comparable: <%s> or <%s> is of mixed string type\n", opts->obj_name[0], + opts->obj_name[1]); opts->not_cmp = 1; H5TOOLS_GOTO_DONE(0); } } - if(tclass1 == H5T_COMPOUND) { + if (tclass1 == H5T_COMPOUND) { int nmembs1; int nmembs2; int j; @@ -1130,8 +1143,8 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, nmembs1 = H5Tget_nmembers(f_tid1); nmembs2 = H5Tget_nmembers(f_tid2); - if(nmembs1 != nmembs2) { - if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { + if (nmembs1 != nmembs2) { + if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { parallel_print("Not comparable: <%s> has %d members ", opts->obj_name[0], nmembs1); parallel_print("<%s> has %d members ", opts->obj_name[1], nmembs2); parallel_print("\n"); @@ -1145,7 +1158,8 @@ diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, memb_type1 = H5Tget_member_type(f_tid1, (unsigned)j); memb_type2 = H5Tget_member_type(f_tid2, (unsigned)j); - if (diff_can_type(memb_type1, memb_type2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, opts, 1) != 1) { + if (diff_can_type(memb_type1, memb_type2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, opts, + 1) != 1) { opts->not_cmp = 1; H5Tclose(memb_type1); H5Tclose(memb_type2); @@ -1163,8 +1177,7 @@ done: return ret_value; } - -#if defined (H5DIFF_DEBUG_UNUSED) +#if defined(H5DIFF_DEBUG_UNUSED) /* this function is not currently used, but could be useful */ /*------------------------------------------------------------------------- * Function: print_sizes @@ -1172,45 +1185,46 @@ done: * Purpose: Print datatype sizes *------------------------------------------------------------------------- */ -void print_sizes( const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2); +void print_sizes(const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2); -void print_sizes( const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2) +void +print_sizes(const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2) { - size_t f_size1, f_size2; /* size of type in file */ - size_t m_size1, m_size2; /* size of type in memory */ + size_t f_size1, f_size2; /* size of type in file */ + size_t m_size1, m_size2; /* size of type in memory */ - f_size1 = H5Tget_size( f_tid1 ); - f_size2 = H5Tget_size( f_tid2 ); - m_size1 = H5Tget_size( m_tid1 ); - m_size2 = H5Tget_size( m_tid2 ); + f_size1 = H5Tget_size(f_tid1); + f_size2 = H5Tget_size(f_tid2); + m_size1 = H5Tget_size(m_tid1); + m_size2 = H5Tget_size(m_tid2); parallel_print("\n"); parallel_print("------------------\n"); - parallel_print("sizeof(char) %u\n", sizeof(char) ); - parallel_print("sizeof(short) %u\n", sizeof(short) ); - parallel_print("sizeof(int) %u\n", sizeof(int) ); - parallel_print("sizeof(long) %u\n", sizeof(long) ); + parallel_print("sizeof(char) %u\n", sizeof(char)); + parallel_print("sizeof(short) %u\n", sizeof(short)); + parallel_print("sizeof(int) %u\n", sizeof(int)); + parallel_print("sizeof(long) %u\n", sizeof(long)); parallel_print("<%s> ------------------\n", obj1); parallel_print("type on file "); print_type(f_tid1); parallel_print("\n"); - parallel_print("size on file %u\n", f_size1 ); + parallel_print("size on file %u\n", f_size1); parallel_print("type on memory "); print_type(m_tid1); parallel_print("\n"); - parallel_print("size on memory %u\n", m_size1 ); + parallel_print("size on memory %u\n", m_size1); parallel_print("<%s> ------------------\n", obj2); parallel_print("type on file "); print_type(f_tid2); parallel_print("\n"); - parallel_print("size on file %u\n", f_size2 ); + parallel_print("size on file %u\n", f_size2); parallel_print("type on memory "); print_type(m_tid2); parallel_print("\n"); - parallel_print("size on memory %u\n", m_size2 ); + parallel_print("size on memory %u\n", m_size2); parallel_print("\n"); } #endif /* H5DIFF_DEBUG */ diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index 59b11d6..ade7dcd 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -17,9 +17,8 @@ #include "h5diff.h" #include "ph5diff.h" - /* global variables */ -int g_nTasks = 1; +int g_nTasks = 1; /*------------------------------------------------------------------------- * Function: print_dimensions @@ -28,29 +27,28 @@ int g_nTasks = 1; *------------------------------------------------------------------------- */ void -print_dimensions (int rank, hsize_t *dims) +print_dimensions(int rank, hsize_t *dims) { - int i; + int i; - if(rank <= 0) - parallel_print("H5S_SCALAR" ); + if (rank <= 0) + parallel_print("H5S_SCALAR"); else { if (!dims) parallel_print("dimension is NULL"); else { parallel_print("["); - for (i = 0; i < rank-1; i++) { + for (i = 0; i < rank - 1; i++) { parallel_print(HSIZE_T_FORMAT, dims[i]); parallel_print("x"); } - parallel_print(HSIZE_T_FORMAT, dims[rank-1]); - parallel_print("]" ); + parallel_print(HSIZE_T_FORMAT, dims[rank - 1]); + parallel_print("]"); } } } - /*------------------------------------------------------------------------- * Function: print_type * @@ -61,120 +59,121 @@ print_dimensions (int rank, hsize_t *dims) * Comments: Adapted from h5dump for H5T_INTEGER and H5T_FLOAT classes only *------------------------------------------------------------------------- */ -void print_type(hid_t type) +void +print_type(hid_t type) { switch (H5Tget_class(type)) { - case H5T_INTEGER: - if(H5Tequal(type, H5T_STD_I8BE)) - parallel_print("H5T_STD_I8BE"); - else if(H5Tequal(type, H5T_STD_I8LE)) - parallel_print("H5T_STD_I8LE"); - else if(H5Tequal(type, H5T_STD_I16BE)) - parallel_print("H5T_STD_I16BE"); - else if(H5Tequal(type, H5T_STD_I16LE)) - parallel_print("H5T_STD_I16LE"); - else if(H5Tequal(type, H5T_STD_I32BE)) - parallel_print("H5T_STD_I32BE"); - else if(H5Tequal(type, H5T_STD_I32LE)) - parallel_print("H5T_STD_I32LE"); - else if(H5Tequal(type, H5T_STD_I64BE)) - parallel_print("H5T_STD_I64BE"); - else if(H5Tequal(type, H5T_STD_I64LE)) - parallel_print("H5T_STD_I64LE"); - else if(H5Tequal(type, H5T_STD_U8BE)) - parallel_print("H5T_STD_U8BE"); - else if(H5Tequal(type, H5T_STD_U8LE)) - parallel_print("H5T_STD_U8LE"); - else if(H5Tequal(type, H5T_STD_U16BE)) - parallel_print("H5T_STD_U16BE"); - else if(H5Tequal(type, H5T_STD_U16LE)) - parallel_print("H5T_STD_U16LE"); - else if(H5Tequal(type, H5T_STD_U32BE)) - parallel_print("H5T_STD_U32BE"); - else if(H5Tequal(type, H5T_STD_U32LE)) - parallel_print("H5T_STD_U32LE"); - else if(H5Tequal(type, H5T_STD_U64BE)) - parallel_print("H5T_STD_U64BE"); - else if(H5Tequal(type, H5T_STD_U64LE)) - parallel_print("H5T_STD_U64LE"); - else if(H5Tequal(type, H5T_NATIVE_SCHAR)) - parallel_print("H5T_NATIVE_SCHAR"); - else if(H5Tequal(type, H5T_NATIVE_UCHAR)) - parallel_print("H5T_NATIVE_UCHAR"); - else if(H5Tequal(type, H5T_NATIVE_SHORT)) - parallel_print("H5T_NATIVE_SHORT"); - else if(H5Tequal(type, H5T_NATIVE_USHORT)) - parallel_print("H5T_NATIVE_USHORT"); - else if(H5Tequal(type, H5T_NATIVE_INT)) - parallel_print("H5T_NATIVE_INT"); - else if(H5Tequal(type, H5T_NATIVE_UINT)) - parallel_print("H5T_NATIVE_UINT"); - else if(H5Tequal(type, H5T_NATIVE_LONG)) - parallel_print("H5T_NATIVE_LONG"); - else if(H5Tequal(type, H5T_NATIVE_ULONG)) - parallel_print("H5T_NATIVE_ULONG"); - else if(H5Tequal(type, H5T_NATIVE_LLONG)) - parallel_print("H5T_NATIVE_LLONG"); - else if(H5Tequal(type, H5T_NATIVE_ULLONG)) - parallel_print("H5T_NATIVE_ULLONG"); - else - parallel_print("undefined integer"); - break; - - case H5T_FLOAT: - if(H5Tequal(type, H5T_IEEE_F32BE)) - parallel_print("H5T_IEEE_F32BE"); - else if(H5Tequal(type, H5T_IEEE_F32LE)) - parallel_print("H5T_IEEE_F32LE"); - else if(H5Tequal(type, H5T_IEEE_F64BE)) - parallel_print("H5T_IEEE_F64BE"); - else if(H5Tequal(type, H5T_IEEE_F64LE)) - parallel_print("H5T_IEEE_F64LE"); - else if(H5Tequal(type, H5T_NATIVE_FLOAT)) - parallel_print("H5T_NATIVE_FLOAT"); - else if(H5Tequal(type, H5T_NATIVE_DOUBLE)) - parallel_print("H5T_NATIVE_DOUBLE"); -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if(H5Tequal(type, H5T_NATIVE_LDOUBLE)) - parallel_print("H5T_NATIVE_LDOUBLE"); + case H5T_INTEGER: + if (H5Tequal(type, H5T_STD_I8BE)) + parallel_print("H5T_STD_I8BE"); + else if (H5Tequal(type, H5T_STD_I8LE)) + parallel_print("H5T_STD_I8LE"); + else if (H5Tequal(type, H5T_STD_I16BE)) + parallel_print("H5T_STD_I16BE"); + else if (H5Tequal(type, H5T_STD_I16LE)) + parallel_print("H5T_STD_I16LE"); + else if (H5Tequal(type, H5T_STD_I32BE)) + parallel_print("H5T_STD_I32BE"); + else if (H5Tequal(type, H5T_STD_I32LE)) + parallel_print("H5T_STD_I32LE"); + else if (H5Tequal(type, H5T_STD_I64BE)) + parallel_print("H5T_STD_I64BE"); + else if (H5Tequal(type, H5T_STD_I64LE)) + parallel_print("H5T_STD_I64LE"); + else if (H5Tequal(type, H5T_STD_U8BE)) + parallel_print("H5T_STD_U8BE"); + else if (H5Tequal(type, H5T_STD_U8LE)) + parallel_print("H5T_STD_U8LE"); + else if (H5Tequal(type, H5T_STD_U16BE)) + parallel_print("H5T_STD_U16BE"); + else if (H5Tequal(type, H5T_STD_U16LE)) + parallel_print("H5T_STD_U16LE"); + else if (H5Tequal(type, H5T_STD_U32BE)) + parallel_print("H5T_STD_U32BE"); + else if (H5Tequal(type, H5T_STD_U32LE)) + parallel_print("H5T_STD_U32LE"); + else if (H5Tequal(type, H5T_STD_U64BE)) + parallel_print("H5T_STD_U64BE"); + else if (H5Tequal(type, H5T_STD_U64LE)) + parallel_print("H5T_STD_U64LE"); + else if (H5Tequal(type, H5T_NATIVE_SCHAR)) + parallel_print("H5T_NATIVE_SCHAR"); + else if (H5Tequal(type, H5T_NATIVE_UCHAR)) + parallel_print("H5T_NATIVE_UCHAR"); + else if (H5Tequal(type, H5T_NATIVE_SHORT)) + parallel_print("H5T_NATIVE_SHORT"); + else if (H5Tequal(type, H5T_NATIVE_USHORT)) + parallel_print("H5T_NATIVE_USHORT"); + else if (H5Tequal(type, H5T_NATIVE_INT)) + parallel_print("H5T_NATIVE_INT"); + else if (H5Tequal(type, H5T_NATIVE_UINT)) + parallel_print("H5T_NATIVE_UINT"); + else if (H5Tequal(type, H5T_NATIVE_LONG)) + parallel_print("H5T_NATIVE_LONG"); + else if (H5Tequal(type, H5T_NATIVE_ULONG)) + parallel_print("H5T_NATIVE_ULONG"); + else if (H5Tequal(type, H5T_NATIVE_LLONG)) + parallel_print("H5T_NATIVE_LLONG"); + else if (H5Tequal(type, H5T_NATIVE_ULLONG)) + parallel_print("H5T_NATIVE_ULLONG"); + else + parallel_print("undefined integer"); + break; + + case H5T_FLOAT: + if (H5Tequal(type, H5T_IEEE_F32BE)) + parallel_print("H5T_IEEE_F32BE"); + else if (H5Tequal(type, H5T_IEEE_F32LE)) + parallel_print("H5T_IEEE_F32LE"); + else if (H5Tequal(type, H5T_IEEE_F64BE)) + parallel_print("H5T_IEEE_F64BE"); + else if (H5Tequal(type, H5T_IEEE_F64LE)) + parallel_print("H5T_IEEE_F64LE"); + else if (H5Tequal(type, H5T_NATIVE_FLOAT)) + parallel_print("H5T_NATIVE_FLOAT"); + else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) + parallel_print("H5T_NATIVE_DOUBLE"); +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) + parallel_print("H5T_NATIVE_LDOUBLE"); #endif - else - parallel_print("undefined float"); - break; - - case H5T_BITFIELD: - if(H5Tequal(type, H5T_STD_B8BE)) - parallel_print("H5T_STD_B8BE"); - else if(H5Tequal(type, H5T_STD_B8LE)) - parallel_print("H5T_STD_B8LE"); - else if(H5Tequal(type, H5T_STD_B16BE)) - parallel_print("H5T_STD_B16BE"); - else if(H5Tequal(type, H5T_STD_B16LE)) - parallel_print("H5T_STD_B16LE"); - else if(H5Tequal(type, H5T_STD_B32BE)) - parallel_print("H5T_STD_B32BE"); - else if(H5Tequal(type, H5T_STD_B32LE)) - parallel_print("H5T_STD_B32LE"); - else if(H5Tequal(type, H5T_STD_B64BE)) - parallel_print("H5T_STD_B64BE"); - else if(H5Tequal(type, H5T_STD_B64LE)) - parallel_print("H5T_STD_B64LE"); - else - parallel_print("undefined bitfield"); - break; - - case H5T_TIME: - case H5T_STRING: - case H5T_OPAQUE: - case H5T_COMPOUND: - case H5T_REFERENCE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_ARRAY: - case H5T_NO_CLASS: - case H5T_NCLASSES: - default: - return; + else + parallel_print("undefined float"); + break; + + case H5T_BITFIELD: + if (H5Tequal(type, H5T_STD_B8BE)) + parallel_print("H5T_STD_B8BE"); + else if (H5Tequal(type, H5T_STD_B8LE)) + parallel_print("H5T_STD_B8LE"); + else if (H5Tequal(type, H5T_STD_B16BE)) + parallel_print("H5T_STD_B16BE"); + else if (H5Tequal(type, H5T_STD_B16LE)) + parallel_print("H5T_STD_B16LE"); + else if (H5Tequal(type, H5T_STD_B32BE)) + parallel_print("H5T_STD_B32BE"); + else if (H5Tequal(type, H5T_STD_B32LE)) + parallel_print("H5T_STD_B32LE"); + else if (H5Tequal(type, H5T_STD_B64BE)) + parallel_print("H5T_STD_B64BE"); + else if (H5Tequal(type, H5T_STD_B64LE)) + parallel_print("H5T_STD_B64LE"); + else + parallel_print("undefined bitfield"); + break; + + case H5T_TIME: + case H5T_STRING: + case H5T_OPAQUE: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + case H5T_NO_CLASS: + case H5T_NCLASSES: + default: + return; } /* end switch */ } @@ -185,24 +184,24 @@ void print_type(hid_t type) * Purpose: Returns a pointer to the last component absolute name *------------------------------------------------------------------------- */ -H5_ATTR_PURE const char* +H5_ATTR_PURE const char * diff_basename(const char *name) { size_t i; - if(name == NULL) + if (name == NULL) return NULL; /* Find the end of the base name */ i = HDstrlen(name); - while(i > 0 && '/' == name[i - 1]) + while (i > 0 && '/' == name[i - 1]) --i; /* Skip backward over base name */ - while(i > 0 && '/' != name[i - 1]) + while (i > 0 && '/' != name[i - 1]) --i; - return(name+i); + return (name + i); } /*------------------------------------------------------------------------- @@ -211,28 +210,28 @@ diff_basename(const char *name) * Purpose: Returns the type as a string *------------------------------------------------------------------------- */ -H5_ATTR_CONST const char* +H5_ATTR_CONST const char * get_type(h5trav_type_t type) { - switch(type) { + switch (type) { case H5TRAV_TYPE_DATASET: - return("H5G_DATASET"); + return ("H5G_DATASET"); case H5TRAV_TYPE_GROUP: - return("H5G_GROUP"); + return ("H5G_GROUP"); case H5TRAV_TYPE_NAMED_DATATYPE: - return("H5G_TYPE"); + return ("H5G_TYPE"); case H5TRAV_TYPE_LINK: - return("H5G_LINK"); + return ("H5G_LINK"); case H5TRAV_TYPE_UDLINK: - return("H5G_UDLINK"); + return ("H5G_UDLINK"); case H5TRAV_TYPE_UNKNOWN: default: - return("unknown type"); + return ("unknown type"); } } @@ -242,10 +241,10 @@ get_type(h5trav_type_t type) * Purpose: Returns the sign as a string *------------------------------------------------------------------------- */ -H5_ATTR_CONST const char* +H5_ATTR_CONST const char * get_sign(H5T_sign_t sign) { - switch(sign) { + switch (sign) { case H5T_SGN_NONE: return "H5T_SGN_NONE"; @@ -263,54 +262,53 @@ get_sign(H5T_sign_t sign) } /* end switch */ } - /*------------------------------------------------------------------------- * Function: get_class * * Purpose: Returns the class as a string *------------------------------------------------------------------------- */ -H5_ATTR_CONST const char* +H5_ATTR_CONST const char * get_class(H5T_class_t tclass) { - switch(tclass) { + switch (tclass) { case H5T_TIME: - return("H5T_TIME"); + return ("H5T_TIME"); case H5T_INTEGER: - return("H5T_INTEGER"); + return ("H5T_INTEGER"); case H5T_FLOAT: - return("H5T_FLOAT"); + return ("H5T_FLOAT"); case H5T_STRING: - return("H5T_STRING"); + return ("H5T_STRING"); case H5T_BITFIELD: - return("H5T_BITFIELD"); + return ("H5T_BITFIELD"); case H5T_OPAQUE: - return("H5T_OPAQUE"); + return ("H5T_OPAQUE"); case H5T_COMPOUND: - return("H5T_COMPOUND"); + return ("H5T_COMPOUND"); case H5T_REFERENCE: - return("H5T_REFERENCE"); + return ("H5T_REFERENCE"); case H5T_ENUM: - return("H5T_ENUM"); + return ("H5T_ENUM"); case H5T_VLEN: - return("H5T_VLEN"); + return ("H5T_VLEN"); case H5T_ARRAY: - return("H5T_ARRAY"); + return ("H5T_ARRAY"); case H5T_NO_CLASS: case H5T_NCLASSES: default: - return("Invalid class"); + return ("Invalid class"); } /* end switch */ } /* end get_class() */ @@ -320,33 +318,33 @@ get_class(H5T_class_t tclass) * Purpose: print number of differences found *------------------------------------------------------------------------- */ -void print_found(hsize_t nfound) +void +print_found(hsize_t nfound) { - if(g_Parallel) - parallel_print("%"H5_PRINTF_LL_WIDTH"u differences found\n", (unsigned long long)nfound); + if (g_Parallel) + parallel_print("%" H5_PRINTF_LL_WIDTH "u differences found\n", (unsigned long long)nfound); else - HDfprintf(stdout,"%Hu differences found\n",nfound); + HDfprintf(stdout, "%Hu differences found\n", nfound); } - /*----------------------------------------------------------------- * Function: match_up_memsize * * Purpose: match smaller memory size up to bigger memory size *------------------------------------------------------------------ */ -herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id, - hid_t *m_tid1, hid_t *m_tid2, - size_t *m_size1, size_t *m_size2) +herr_t +match_up_memsize(hid_t f_tid1_id, hid_t f_tid2_id, hid_t *m_tid1, hid_t *m_tid2, size_t *m_size1, + size_t *m_size2) { herr_t ret_value = SUCCEED; H5TOOLS_START_DEBUG(""); - if((*m_size1) != (*m_size2)) { - if((*m_size1) < (*m_size2)) { + if ((*m_size1) != (*m_size2)) { + if ((*m_size1) < (*m_size2)) { H5Tclose(*m_tid1); - if(((*m_tid1) = H5Tget_native_type(f_tid2_id, H5T_DIR_DEFAULT)) < 0) + if (((*m_tid1) = H5Tget_native_type(f_tid2_id, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_native_type failed"); *m_size1 = H5Tget_size(*m_tid1); @@ -354,17 +352,16 @@ herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id, else { H5Tclose(*m_tid2); - if(((*m_tid2) = H5Tget_native_type(f_tid1_id, H5T_DIR_DEFAULT)) < 0) + if (((*m_tid2) = H5Tget_native_type(f_tid1_id, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_native_type failed"); *m_size2 = H5Tget_size(*m_tid2); } /* end else */ - } /* end if */ - if((*m_size1) != (*m_size2)) + } /* end if */ + if ((*m_size1) != (*m_size2)) H5TOOLS_GOTO_ERROR(FAIL, "native type sizes do not compare"); done: H5TOOLS_ENDDEBUG(""); return ret_value; } - diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 2efca76..1990cf5 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -24,50 +24,49 @@ #ifdef H5_TOOLS_DEBUG /* global debug variables */ -int H5tools_INDENT_g = 0; +int H5tools_INDENT_g = 0; #endif - /* global variables */ H5E_auto2_t lib_func; H5E_auto2_t tools_func; -void *lib_edata; -void *tools_edata; - -hid_t H5tools_ERR_STACK_g = H5I_INVALID_HID; -hid_t H5tools_ERR_CLS_g = H5I_INVALID_HID; -hid_t H5E_tools_g = H5I_INVALID_HID; -hid_t H5E_tools_min_id_g = H5I_INVALID_HID; -hid_t H5E_tools_min_info_id_g = H5I_INVALID_HID; -hid_t H5E_tools_min_dbg_id_g = H5I_INVALID_HID; - -FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */ -FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */ -FILE *rawinstream = NULL; /* should initialize to stdin but gcc moans about it */ -FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */ -FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */ - -int bin_output; /* binary output */ -int bin_form = 0; /* binary form, default NATIVE */ -int region_output; /* region output */ -int oid_output; /* oid output */ -int data_output; /* data output */ -int attr_data_output; /* attribute data output */ -int compound_data; - -unsigned packed_bits_num; /* number of packed bits to display */ -unsigned packed_data_offset; /* offset of packed bits to display */ -unsigned packed_data_length; /* length of packed bits to display */ -unsigned long long packed_data_mask; /* mask in which packed bits to display */ - -int enable_error_stack = 0; /* re-enable error stack; disable=0 enable=1 */ +void * lib_edata; +void * tools_edata; + +hid_t H5tools_ERR_STACK_g = H5I_INVALID_HID; +hid_t H5tools_ERR_CLS_g = H5I_INVALID_HID; +hid_t H5E_tools_g = H5I_INVALID_HID; +hid_t H5E_tools_min_id_g = H5I_INVALID_HID; +hid_t H5E_tools_min_info_id_g = H5I_INVALID_HID; +hid_t H5E_tools_min_dbg_id_g = H5I_INVALID_HID; + +FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */ +FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */ +FILE *rawinstream = NULL; /* should initialize to stdin but gcc moans about it */ +FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */ +FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */ + +int bin_output; /* binary output */ +int bin_form = 0; /* binary form, default NATIVE */ +int region_output; /* region output */ +int oid_output; /* oid output */ +int data_output; /* data output */ +int attr_data_output; /* attribute data output */ +int compound_data; + +unsigned packed_bits_num; /* number of packed bits to display */ +unsigned packed_data_offset; /* offset of packed bits to display */ +unsigned packed_data_length; /* length of packed bits to display */ +unsigned long long packed_data_mask; /* mask in which packed bits to display */ + +int enable_error_stack = 0; /* re-enable error stack; disable=0 enable=1 */ /* sort parameters */ -H5_index_t sort_by = H5_INDEX_NAME; /* sort_by [creation_order | name] */ -H5_iter_order_t sort_order = H5_ITER_INC; /* sort_order [ascending | descending] */ +H5_index_t sort_by = H5_INDEX_NAME; /* sort_by [creation_order | name] */ +H5_iter_order_t sort_order = H5_ITER_INC; /* sort_order [ascending | descending] */ /* module-scoped variables */ -static int h5tools_init_g; /* if h5tools lib has been initialized */ +static int h5tools_init_g; /* if h5tools lib has been initialized */ /* Names of VOL connectors */ const char *volnames[] = { @@ -81,19 +80,11 @@ const char *volnames[] = { * somehow otherwise not enabled. * */ -const char *drivernames[]={ - [SEC2_VFD_IDX] = "sec2", - [DIRECT_VFD_IDX] = "direct", - [LOG_VFD_IDX] = "log", - [WINDOWS_VFD_IDX] = "windows", - [STDIO_VFD_IDX] = "stdio", - [CORE_VFD_IDX] = "core", - [FAMILY_VFD_IDX] = "family", - [SPLIT_VFD_IDX] = "split", - [MULTI_VFD_IDX] = "multi", - [MPIO_VFD_IDX] = "mpio", - [ROS3_VFD_IDX] = "ros3", - [HDFS_VFD_IDX] = "hdfs", +const char *drivernames[] = { + [SEC2_VFD_IDX] = "sec2", [DIRECT_VFD_IDX] = "direct", [LOG_VFD_IDX] = "log", + [WINDOWS_VFD_IDX] = "windows", [STDIO_VFD_IDX] = "stdio", [CORE_VFD_IDX] = "core", + [FAMILY_VFD_IDX] = "family", [SPLIT_VFD_IDX] = "split", [MULTI_VFD_IDX] = "multi", + [MPIO_VFD_IDX] = "mpio", [ROS3_VFD_IDX] = "ros3", [HDFS_VFD_IDX] = "hdfs", [SWMR_VFD_IDX] = "swmr", }; @@ -242,9 +233,9 @@ h5tools_close(void) int h5tools_set_data_output_file(const char *fname, int is_bin) { - int retvalue = FAIL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawdatastream is changed only when succeeded */ + int retvalue = FAIL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawdatastream is changed only when succeeded */ if (rawdatastream && rawdatastream != stdout) { if (HDfclose(rawdatastream)) @@ -259,19 +250,19 @@ h5tools_set_data_output_file(const char *fname, int is_bin) if (is_bin) { if ((f = HDfopen(fname, "wb")) != NULL) { rawdatastream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } else { if ((f = HDfopen(fname, "w")) != NULL) { rawdatastream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } } else { rawdatastream = NULL; - retvalue = SUCCEED; + retvalue = SUCCEED; } return retvalue; @@ -290,9 +281,9 @@ h5tools_set_data_output_file(const char *fname, int is_bin) int h5tools_set_attr_output_file(const char *fname, int is_bin) { - int retvalue = FAIL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawattrstream is changed only when succeeded */ + int retvalue = FAIL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawattrstream is changed only when succeeded */ if (rawattrstream && rawattrstream != stdout) { if (HDfclose(rawattrstream)) @@ -307,19 +298,19 @@ h5tools_set_attr_output_file(const char *fname, int is_bin) if (is_bin) { if ((f = HDfopen(fname, "wb")) != NULL) { rawattrstream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } else { if ((f = HDfopen(fname, "w")) != NULL) { rawattrstream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } } else { rawattrstream = NULL; - retvalue = SUCCEED; + retvalue = SUCCEED; } return retvalue; @@ -339,9 +330,9 @@ h5tools_set_attr_output_file(const char *fname, int is_bin) int h5tools_set_input_file(const char *fname, int is_bin) { - int retvalue = FAIL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawinstream is changed only when succeeded */ + int retvalue = FAIL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawinstream is changed only when succeeded */ if (rawinstream && rawinstream != stdin) { if (HDfclose(rawinstream)) @@ -355,19 +346,19 @@ h5tools_set_input_file(const char *fname, int is_bin) if (is_bin) { if ((f = HDfopen(fname, "rb")) != NULL) { rawinstream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } else { if ((f = HDfopen(fname, "r")) != NULL) { rawinstream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } } else { rawinstream = NULL; - retvalue = SUCCEED; + retvalue = SUCCEED; } return retvalue; @@ -387,9 +378,9 @@ h5tools_set_input_file(const char *fname, int is_bin) int h5tools_set_output_file(const char *fname, int is_bin) { - int retvalue = FAIL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawoutstream is changed only when succeeded */ + int retvalue = FAIL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawoutstream is changed only when succeeded */ if (rawoutstream && rawoutstream != stdout) { if (HDfclose(rawoutstream)) @@ -403,19 +394,19 @@ h5tools_set_output_file(const char *fname, int is_bin) if (is_bin) { if ((f = HDfopen(fname, "wb")) != NULL) { rawoutstream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } else { if ((f = HDfopen(fname, "w")) != NULL) { rawoutstream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } } else { rawoutstream = NULL; - retvalue = SUCCEED; + retvalue = SUCCEED; } return retvalue; @@ -434,9 +425,9 @@ h5tools_set_output_file(const char *fname, int is_bin) int h5tools_set_error_file(const char *fname, int is_bin) { - int retvalue = FAIL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawerrorstream is changed only when succeeded */ + int retvalue = FAIL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawerrorstream is changed only when succeeded */ if (rawerrorstream && rawerrorstream != stderr) { if (HDfclose(rawerrorstream)) @@ -447,23 +438,23 @@ h5tools_set_error_file(const char *fname, int is_bin) /* First check if filename is string "NULL" */ if (fname != NULL) { - /* binary output */ + /* binary output */ if (is_bin) { if ((f = HDfopen(fname, "wb")) != NULL) { rawerrorstream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } else { if ((f = HDfopen(fname, "w")) != NULL) { rawerrorstream = f; - retvalue = SUCCEED; + retvalue = SUCCEED; } } } else { rawerrorstream = NULL; - retvalue = SUCCEED; + retvalue = SUCCEED; } return retvalue; @@ -472,41 +463,40 @@ h5tools_set_error_file(const char *fname, int is_bin) static hid_t swmr_fapl_augment(hid_t fapl, const char *fname) { - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ - char *dname = NULL; + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + char * dname = NULL; /* * Set up to open the file with VFD SWMR configured. */ /* Enable page buffering */ - if(H5Pset_page_buffer_size(fapl, 4096, 100, 0) < 0) { + if (H5Pset_page_buffer_size(fapl, 4096, 100, 0) < 0) { HDfprintf(rawerrorstream, "H5Pset_page_buffer_size failed\n"); return H5I_INVALID_HID; } /* Allocate memory for the configuration structure */ config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(*config)); - if(config == NULL) { + if (config == NULL) { HDfprintf(rawerrorstream, "VFD SWMR config allocation failed\n"); return H5I_INVALID_HID; } - config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; - config->tick_len = 4; - config->max_lag = 5; - config->writer = FALSE; + config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; + config->tick_len = 4; + config->max_lag = 5; + config->writer = FALSE; config->md_pages_reserved = 128; if (H5_dirname(fname, &dname) < 0) { HDfprintf(rawerrorstream, "H5_dirname() failed\n"); return H5I_INVALID_HID; } - HDsnprintf(config->md_file_path, sizeof(config->md_file_path), - "%s/my_md_file", dname); + HDsnprintf(config->md_file_path, sizeof(config->md_file_path), "%s/my_md_file", dname); HDfree(dname); /* Enable VFD SWMR configuration */ - if(H5Pset_vfd_swmr_config(fapl, config) < 0) { + if (H5Pset_vfd_swmr_config(fapl, config) < 0) { HDfprintf(rawerrorstream, "H5Pset_vrd_swmr_config failed\n"); return H5I_INVALID_HID; } @@ -533,7 +523,8 @@ h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info) /* SWMR driver */ if (swmr_fapl_augment(fapl_id, vfd_info->fname) < 0) H5TOOLS_GOTO_ERROR(FAIL, "swmr_fapl_augment failed"); - } else if (!HDstrcmp(vfd_info->name, drivernames[SEC2_VFD_IDX])) { + } + else if (!HDstrcmp(vfd_info->name, drivernames[SEC2_VFD_IDX])) { /* SEC2 Driver */ if (H5Pset_fapl_sec2(fapl_id) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); @@ -551,7 +542,7 @@ h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info) unsigned long long log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; /* Log Driver */ - if (H5Pset_fapl_log(fapl_id, NULL, log_flags, (size_t) 0) < 0) + if (H5Pset_fapl_log(fapl_id, NULL, log_flags, (size_t)0) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_log failed"); } else if (!HDstrcmp(vfd_info->name, drivernames[WINDOWS_VFD_IDX])) { @@ -570,7 +561,7 @@ h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info) } else if (!HDstrcmp(vfd_info->name, drivernames[CORE_VFD_IDX])) { /* Core Driver */ - if (H5Pset_fapl_core(fapl_id, (size_t) H5_MB, TRUE) < 0) + if (H5Pset_fapl_core(fapl_id, (size_t)H5_MB, TRUE) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_core failed"); } else if (!HDstrcmp(vfd_info->name, drivernames[FAMILY_VFD_IDX])) { @@ -578,7 +569,7 @@ h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info) /* Set member size to be 0 to indicate the current first member size * is the member size. */ - if (H5Pset_fapl_family(fapl_id, (hsize_t) 0, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fapl_id, (hsize_t)0, H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed"); } else if (!HDstrcmp(vfd_info->name, drivernames[SPLIT_VFD_IDX])) { @@ -650,9 +641,9 @@ static herr_t h5tools_set_fapl_vol(hid_t fapl_id, h5tools_vol_info_t *vol_info) { htri_t connector_is_registered; - hid_t connector_id = H5I_INVALID_HID; - void *connector_info = NULL; - herr_t ret_value = SUCCEED; + hid_t connector_id = H5I_INVALID_HID; + void * connector_info = NULL; + herr_t ret_value = SUCCEED; switch (vol_info->type) { case VOL_BY_NAME: @@ -666,7 +657,7 @@ h5tools_set_fapl_vol(hid_t fapl_id, h5tools_vol_info_t *vol_info) else { /* Check for VOL connectors that ship with the library, then try * registering by name if that fails. - */ + */ if (!HDstrcmp(vol_info->u.name, H5VL_NATIVE_NAME)) { connector_id = H5VL_NATIVE; } @@ -749,11 +740,10 @@ done: *------------------------------------------------------------------------- */ hid_t -h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, - h5tools_vfd_info_t *vfd_info) +h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, h5tools_vfd_info_t *vfd_info) { hid_t new_fapl_id = H5I_INVALID_HID; - hid_t ret_value = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; if (prev_fapl_id < 0) H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL"); @@ -805,7 +795,7 @@ herr_t h5tools_get_vfd_name(hid_t fapl_id, char *drivername, size_t drivername_size) { hid_t fapl_vol_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; if (fapl_id < 0) H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL"); @@ -924,11 +914,11 @@ done: *------------------------------------------------------------------------- */ hid_t -h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_specific_driver, - char *drivername, size_t drivername_size) +h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_specific_driver, char *drivername, + size_t drivername_size) { - hid_t fid = H5I_INVALID_HID; - hid_t tmp_fapl_id = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t tmp_fapl_id = H5I_INVALID_HID; hid_t used_fapl_id = H5I_INVALID_HID; unsigned volnum, drivernum; hid_t ret_value = H5I_INVALID_HID; @@ -947,9 +937,11 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec fid = H5Fopen(fname, flags, fapl_id); } else { - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { fid = H5Fopen(fname, flags, fapl_id); - } H5E_END_TRY; + } + H5E_END_TRY; } /* If we succeeded in opening the file, we're done. */ @@ -974,9 +966,9 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec for (volnum = 0; volnum < NUM_VOLS; volnum++) { h5tools_vol_info_t vol_info; - vol_info.type = VOL_BY_NAME; - vol_info.info_string = NULL; - vol_info.u.name = volnames[volnum]; + vol_info.type = VOL_BY_NAME; + vol_info.info_string = NULL; + vol_info.u.name = volnames[volnum]; /* TODO: For now, we have no way of determining if an arbitrary * VOL connector is native-terminal so we only try VFDs with the @@ -1004,16 +996,17 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec if (drivernum == SWMR_VFD_IDX) continue; - vfd_info.info = NULL; - vfd_info.fname = fname; - vfd_info.name = drivernames[drivernum]; + vfd_info.info = NULL; + vfd_info.fname = fname; + vfd_info.name = drivernames[drivernum]; /* Get a fapl reflecting the selected VOL connector and VFD */ if ((tmp_fapl_id = h5tools_get_fapl(fapl_id, &vol_info, &vfd_info)) < 0) continue; /* Can we open the file with this combo? */ - if ((fid = h5tools_fopen(fname, flags, tmp_fapl_id, TRUE, drivername, drivername_size)) >= 0) { + if ((fid = h5tools_fopen(fname, flags, tmp_fapl_id, TRUE, drivername, drivername_size)) >= + 0) { used_fapl_id = tmp_fapl_id; H5TOOLS_GOTO_DONE(fid); } @@ -1098,12 +1091,12 @@ h5tools_detect_vlen(hid_t tid) /* recursive detect any vlen data values in type (compound, array ...) */ ret = H5Tdetect_class(tid, H5T_VLEN); - if((ret == TRUE) || (ret < 0)) + if ((ret == TRUE) || (ret < 0)) goto done; /* recursive detect any vlen string in type (compound, array ...) */ ret = h5tools_detect_vlen_str(tid); - if((ret == TRUE) || (ret < 0)) + if ((ret == TRUE) || (ret < 0)) goto done; done: @@ -1124,42 +1117,42 @@ htri_t h5tools_detect_vlen_str(hid_t tid) { H5T_class_t tclass = -1; - htri_t ret = FALSE; + htri_t ret = FALSE; ret = H5Tis_variable_str(tid); - if((ret == TRUE) || (ret < 0)) + if ((ret == TRUE) || (ret < 0)) goto done; tclass = H5Tget_class(tid); - if(tclass == H5T_ARRAY || tclass == H5T_VLEN) { + if (tclass == H5T_ARRAY || tclass == H5T_VLEN) { hid_t btid = H5Tget_super(tid); - if(btid < 0) { + if (btid < 0) { ret = (htri_t)btid; goto done; } ret = h5tools_detect_vlen_str(btid); - if((ret == TRUE) || (ret < 0)) { + if ((ret == TRUE) || (ret < 0)) { H5Tclose(btid); goto done; } } - else if(tclass == H5T_COMPOUND) { + else if (tclass == H5T_COMPOUND) { unsigned nmembs; - int snmembs = H5Tget_nmembers(tid); + int snmembs = H5Tget_nmembers(tid); unsigned u; - if(snmembs < 0) { + if (snmembs < 0) { ret = FAIL; goto done; } nmembs = (unsigned)snmembs; - for(u = 0; u < nmembs; u++) { + for (u = 0; u < nmembs; u++) { hid_t mtid = H5Tget_member_type(tid, u); ret = h5tools_detect_vlen_str(mtid); - if((ret == TRUE) || (ret < 0)) { + if ((ret == TRUE) || (ret < 0)) { H5Tclose(mtid); goto done; } @@ -1182,13 +1175,13 @@ done: *------------------------------------------------------------------------- */ void -h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hsize_t elmtno, int secnum) +h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno, + int secnum) { h5tools_str_t prefix; - h5tools_str_t str; /*temporary for indentation */ - size_t templength = 0; - unsigned u, indentlevel = 0; + h5tools_str_t str; /*temporary for indentation */ + size_t templength = 0; + unsigned u, indentlevel = 0; if (stream == NULL) return; @@ -1202,7 +1195,8 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context HDmemset(&str, 0, sizeof(h5tools_str_t)); /* Terminate previous line, if any */ - H5TOOLS_DEBUG("before CR elmtno=%ld, ctx->cur_column=%d, info->idx_fmt=%s, info->line_suf=%s", elmtno, ctx->cur_column, info->idx_fmt, info->line_suf); + H5TOOLS_DEBUG("before CR elmtno=%ld, ctx->cur_column=%d, info->idx_fmt=%s, info->line_suf=%s", elmtno, + ctx->cur_column, info->idx_fmt, info->line_suf); if (ctx->cur_column) { PUTSTREAM(OPT(info->line_suf, ""), stream); HDputc('\n', stream); @@ -1256,8 +1250,8 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context H5TOOLS_DEBUG("prefix=%s - templength=%d", prefix.s, templength); ctx->cur_column = ctx->prev_prefix_len = templength; - ctx->cur_elmt = 0; - ctx->need_prefix = 0; + ctx->cur_elmt = 0; + ctx->need_prefix = 0; H5TOOLS_DEBUG("prefix=%s - str=%s", prefix.s, str.s); /* Free string */ @@ -1279,12 +1273,12 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context */ void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hsize_t elmtno, hsize_t *ptdata, int secnum) + hsize_t elmtno, hsize_t *ptdata, int secnum) { h5tools_str_t prefix; - h5tools_str_t str; /*temporary for indentation */ - size_t templength = 0; - unsigned u, indentlevel = 0; + h5tools_str_t str; /*temporary for indentation */ + size_t templength = 0; + unsigned u, indentlevel = 0; if (stream == NULL) return; @@ -1344,8 +1338,8 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_ } ctx->cur_column = ctx->prev_prefix_len = templength; - ctx->cur_elmt = 0; - ctx->need_prefix = 0; + ctx->cur_elmt = 0; + ctx->need_prefix = 0; /* Free string */ h5tools_str_close(&prefix); @@ -1377,13 +1371,14 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_ */ hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter) + h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter, + hsize_t elmt_counter) { - hbool_t dimension_break = TRUE; - char *s = NULL; - char *section = NULL; /* a section of output */ - int secnum; /* section sequence number */ - int multiline; /* datum was multiline */ + hbool_t dimension_break = TRUE; + char * s = NULL; + char * section = NULL; /* a section of output */ + int secnum; /* section sequence number */ + int multiline; /* datum was multiline */ if (stream == NULL) return dimension_break; @@ -1399,9 +1394,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_contex * current location... */ if (info->line_multi_new == 1 && - (ctx->cur_column + h5tools_count_ncols(s) + - HDstrlen(OPT(info->elmt_suf2, " ")) + - HDstrlen(OPT(info->line_suf, ""))) > ncols) { + (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) { if (ctx->prev_multiline) { /* * ... and the previous element also occupied more than one @@ -1409,9 +1403,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_contex */ ctx->need_prefix = TRUE; } - else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + - HDstrlen(OPT(info->elmt_suf2, " ")) + - HDstrlen(OPT(info->line_suf, ""))) <= ncols) { + else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) <= ncols) { /* * ...but *could* fit on one line otherwise, then we * should end the current line and start this element on its @@ -1433,23 +1426,21 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_contex if (elmt_counter == ctx->size_last_dim) { ctx->need_prefix = TRUE; - dimension_break = FALSE; + dimension_break = FALSE; } H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix); } - H5TOOLS_DEBUG("elmt_counter=%ld - ctx->size_last_dim=%ld info->line_suf=%s", elmt_counter, ctx->size_last_dim, info->line_suf); + H5TOOLS_DEBUG("elmt_counter=%ld - ctx->size_last_dim=%ld info->line_suf=%s", elmt_counter, + ctx->size_last_dim, info->line_suf); /* * If the previous element occupied multiple lines and this element * is too long to fit on a line then start this element at the * beginning of the line. */ - if (info->line_multi_new == 1 && - ctx->prev_multiline && - (ctx->cur_column + - h5tools_count_ncols(s) + - HDstrlen(OPT(info->elmt_suf2, " ")) + - HDstrlen(OPT(info->line_suf, ""))) > ncols) + if (info->line_multi_new == 1 && ctx->prev_multiline && + (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix); @@ -1467,9 +1458,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_contex * one-at a time. */ multiline = 0; - for (secnum = 0, multiline = 0; - (section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); - secnum++) { + for (secnum = 0, multiline = 0; (section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) { /* * If the current section plus possible suffix and end-of-line * information would cause the output to wrap then we need to @@ -1479,9 +1468,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_contex /* * check for displaying prefix for each section */ - if ( (ctx->cur_column + HDstrlen(section) + - HDstrlen(OPT(info->elmt_suf2, " ")) + - HDstrlen(OPT(info->line_suf, ""))) > ncols) + if ((ctx->cur_column + HDstrlen(section) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = 1; /* @@ -1498,7 +1486,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_contex * this is necessary to print the array indices */ *curr_pos = ctx->sm_pos + local_elmt_counter; - H5TOOLS_DEBUG("curr_pos=%ld - ctx->sm_pos=%ld - ctx->ndims=%ld", *curr_pos, ctx->sm_pos, ctx->ndims); + H5TOOLS_DEBUG("curr_pos=%ld - ctx->sm_pos=%ld - ctx->ndims=%ld", *curr_pos, ctx->sm_pos, + ctx->ndims); h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum); } @@ -1547,13 +1536,14 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_contex */ hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter) + h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t *ptdata, + hsize_t local_elmt_counter, hsize_t elmt_counter) { - hbool_t dimension_break = TRUE; - char *s = NULL; - char *section = NULL; /* a section of output */ - int secnum; /* section sequence number */ - int multiline; /* datum was multiline */ + hbool_t dimension_break = TRUE; + char * s = NULL; + char * section = NULL; /* a section of output */ + int secnum; /* section sequence number */ + int multiline; /* datum was multiline */ H5TOOLS_START_DEBUG(""); H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter); @@ -1565,9 +1555,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools * current location... */ if (info->line_multi_new == 1 && - (ctx->cur_column + h5tools_count_ncols(s) + - HDstrlen(OPT(info->elmt_suf2, " ")) + - HDstrlen(OPT(info->line_suf, ""))) > ncols) { + (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) { if (ctx->prev_multiline) { /* * ... and the previous element also occupied more than one @@ -1575,9 +1564,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools */ ctx->need_prefix = TRUE; } - else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + - HDstrlen(OPT(info->elmt_suf2, " ")) + - HDstrlen(OPT(info->line_suf, ""))) <= ncols) { + else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) <= ncols) { /* * ...but *could* fit on one line otherwise, then we * should end the current line and start this element on its @@ -1598,7 +1586,7 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools if (elmt_counter == ctx->size_last_dim) { ctx->need_prefix = TRUE; - dimension_break = FALSE; + dimension_break = FALSE; } } @@ -1608,9 +1596,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools * beginning of the line. */ if (info->line_multi_new == 1 && ctx->prev_multiline && - (ctx->cur_column + h5tools_count_ncols(s) + - HDstrlen(OPT(info->elmt_suf2, " ")) + - HDstrlen(OPT(info->line_suf, ""))) > ncols) + (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; /* @@ -1638,9 +1625,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools * this check to happen for the first line */ if ((!info->skip_first || local_elmt_counter) && - (ctx->cur_column + HDstrlen(section) + - HDstrlen(OPT(info->elmt_suf2, " ")) + - HDstrlen(OPT(info->line_suf, ""))) > ncols) + (ctx->cur_column + HDstrlen(section) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = 1; /* @@ -1688,7 +1674,7 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools void init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx) { - int i; + int i; unsigned j; H5TOOLS_START_DEBUG(""); @@ -1696,7 +1682,7 @@ init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t for (i = 0; (unsigned)i < ndims; i++) p_min_idx[i] = 0; - if(ndims > 0) { + if (ndims > 0) { acc[ndims - 1] = 1; for (i = ((int)ndims - 2); i >= 0; i--) { acc[i] = acc[i + 1] * dims[i + 1]; @@ -1721,14 +1707,14 @@ init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t hsize_t calc_acc_pos(unsigned ndims, hsize_t elmtno, hsize_t *acc, hsize_t *pos) { - int i; - hsize_t curr_pos = elmtno; + int i; + hsize_t curr_pos = elmtno; H5TOOLS_START_DEBUG(""); - if(ndims > 0) { - for(i = 0; i < (int)ndims; i++) { - if(curr_pos > 0) { + if (ndims > 0) { + for (i = 0; i < (int)ndims; i++) { + if (curr_pos > 0) { H5TOOLS_DEBUG("curr_pos=%ld - ctx->acc[%d]=%ld", curr_pos, i, acc[i]); pos[i] = curr_pos / acc[i]; curr_pos -= acc[i] * pos[i]; @@ -1754,20 +1740,20 @@ calc_acc_pos(unsigned ndims, hsize_t elmtno, hsize_t *acc, hsize_t *pos) *------------------------------------------------------------------------- */ int -render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) +render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) { - unsigned char *mem = (unsigned char*)_mem; - size_t size; /* datum size */ + unsigned char *mem = (unsigned char *)_mem; + size_t size; /* datum size */ hsize_t block_index; H5T_class_t type_class; hbool_t past_catch = FALSE; - int ret_value = 0; + int ret_value = 0; H5TOOLS_START_DEBUG(""); - if((size = H5Tget_size(tid)) == 0) + if ((size = H5Tget_size(tid)) == 0) H5TOOLS_THROW((-1), "H5Tget_size failed"); - if((type_class = H5Tget_class(tid)) < 0) + if ((type_class = H5Tget_class(tid)) < 0) H5TOOLS_THROW((-1), "H5Tget_class failed"); switch (type_class) { @@ -1777,194 +1763,188 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t case H5T_BITFIELD: H5TOOLS_DEBUG("numbers"); block_index = block_nelmts * size; - while(block_index > 0) { - size_t bytes_in = 0; /* # of bytes to write */ - size_t bytes_wrote = 0; /* # of bytes written */ + while (block_index > 0) { + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ - if(block_index > sizeof(size_t)) + if (block_index > sizeof(size_t)) bytes_in = sizeof(size_t); else bytes_in = (size_t)block_index; bytes_wrote = HDfwrite(mem, 1, bytes_in, stream); - if(bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream))) + if (bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream))) H5TOOLS_THROW((-1), "fwrite failed"); block_index -= (hsize_t)bytes_wrote; mem = mem + bytes_wrote; } break; - case H5T_STRING: - { - unsigned int i; - H5T_str_t pad; - char *s = NULL; - unsigned char tempuchar; - - H5TOOLS_DEBUG("H5T_STRING"); - pad = H5Tget_strpad(tid); - - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - - if (H5Tis_variable_str(tid)) { - s = *(char **)((void *)mem); - if (s != NULL) - size = HDstrlen(s); - else - H5TOOLS_THROW((-1), "NULL string"); - } - else { - s = (char *) mem; - } - for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { - HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); - if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream)) - H5TOOLS_THROW((-1), "fwrite failed"); - } /* i */ - } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ - } - break; - case H5T_COMPOUND: - { - int snmembs; - unsigned nmembs; - - H5TOOLS_DEBUG("H5T_COMPOUND"); - if((snmembs = H5Tget_nmembers(tid)) < 0) - H5TOOLS_THROW((-1), "H5Tget_nmembers of compound failed"); - nmembs = (unsigned)snmembs; - - for (block_index = 0; block_index < block_nelmts; block_index++) { - unsigned j; - - mem = ((unsigned char*)_mem) + block_index * size; - for (j = 0; j < nmembs; j++) { - hid_t memb = H5I_INVALID_HID; - size_t offset; - - offset = H5Tget_member_offset(tid, j); - memb = H5Tget_member_type(tid, j); - - if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) { - H5Tclose(memb); - H5TOOLS_THROW((-1), "render_bin_output of compound member failed"); - } + case H5T_STRING: { + unsigned int i; + H5T_str_t pad; + char * s = NULL; + unsigned char tempuchar; - H5Tclose(memb); - } - } - } - break; - case H5T_ARRAY: - { - int k, ndims; - hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; - hid_t memb = H5I_INVALID_HID; - - H5TOOLS_DEBUG("H5T_ARRAY"); - /* get the array's base datatype for each element */ - memb = H5Tget_super(tid); - ndims = H5Tget_array_ndims(tid); - H5Tget_array_dims2(tid, dims); - if(ndims >= 1 && ndims <= H5S_MAX_RANK) { - /* calculate the number of array elements */ - for (k = 0, nelmts = 1; k < ndims; k++) { - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - nelmts = (size_t) temp_nelmts; - } + H5TOOLS_DEBUG("H5T_STRING"); + pad = H5Tget_strpad(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char *)_mem) + block_index * size; + + if (H5Tis_variable_str(tid)) { + s = *(char **)((void *)mem); + if (s != NULL) + size = HDstrlen(s); + else + H5TOOLS_THROW((-1), "NULL string"); } else { - H5Tclose(memb); - H5TOOLS_THROW((-1), "calculate the number of array elements failed"); + s = (char *)mem; } + for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { + HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); + if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream)) + H5TOOLS_THROW((-1), "fwrite failed"); + } /* i */ + } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ + } break; + case H5T_COMPOUND: { + int snmembs; + unsigned nmembs; + + H5TOOLS_DEBUG("H5T_COMPOUND"); + if ((snmembs = H5Tget_nmembers(tid)) < 0) + H5TOOLS_THROW((-1), "H5Tget_nmembers of compound failed"); + nmembs = (unsigned)snmembs; - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - /* dump the array element */ - if (render_bin_output(stream, container, memb, mem, nelmts) < 0) { + for (block_index = 0; block_index < block_nelmts; block_index++) { + unsigned j; + + mem = ((unsigned char *)_mem) + block_index * size; + for (j = 0; j < nmembs; j++) { + hid_t memb = H5I_INVALID_HID; + size_t offset; + + offset = H5Tget_member_offset(tid, j); + memb = H5Tget_member_type(tid, j); + + if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) { H5Tclose(memb); - H5TOOLS_THROW((-1), "render_bin_output failed"); + H5TOOLS_THROW((-1), "render_bin_output of compound member failed"); } + + H5Tclose(memb); } - H5Tclose(memb); } - break; - case H5T_VLEN: - { - hsize_t nelmts; - hid_t memb = H5I_INVALID_HID; - - H5TOOLS_DEBUG("H5T_VLEN"); - /* get the VL sequences's base datatype for each element */ - memb = H5Tget_super(tid); - - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - /* Get the number of sequence elements */ - nelmts = ((hvl_t *)((void *)mem))->len; - - /* dump the array element */ - if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *)((void *)mem))->p)), nelmts) < 0) { - H5Tclose(memb); - H5TOOLS_THROW((-1), "render_bin_output failed"); - } + } break; + case H5T_ARRAY: { + int k, ndims; + hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hid_t memb = H5I_INVALID_HID; + + H5TOOLS_DEBUG("H5T_ARRAY"); + /* get the array's base datatype for each element */ + memb = H5Tget_super(tid); + ndims = H5Tget_array_ndims(tid); + H5Tget_array_dims2(tid, dims); + if (ndims >= 1 && ndims <= H5S_MAX_RANK) { + /* calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + nelmts = (size_t)temp_nelmts; } + } + else { H5Tclose(memb); + H5TOOLS_THROW((-1), "calculate the number of array elements failed"); } - break; - case H5T_REFERENCE: - { - H5TOOLS_DEBUG("reference class type"); - if (H5Tequal(tid, H5T_STD_REF)) { - H5TOOLS_DEBUG("H5T_STD_REF"); - if (region_output) { - /* region data */ - hid_t region_id = H5I_INVALID_HID; - hid_t region_space = H5I_INVALID_HID; - H5S_sel_type region_type; - - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - if((region_id = H5Ropen_object((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed"); - else { - if((region_space = H5Ropen_region((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) { - region_type = H5Sget_select_type(region_space); - if(region_type == H5S_SEL_POINTS) - render_bin_output_region_points(region_space, region_id, stream, container); - else - render_bin_output_region_blocks(region_space, region_id, stream, container); - } - else { - H5TOOLS_INFO("H5Ropen_object H5T_STD_REF NULL"); - } - H5Sclose(region_space); - } /* end if (region_space >= 0) */ - H5Dclose(region_id); - } - } - } /* end if (region_output... */ - } - else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) { - /* if (size == H5R_DSET_REG_REF_BUF_SIZE) */ - H5TOOLS_DEBUG("H5T_STD_REF_DSETREG"); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char *)_mem) + block_index * size; + /* dump the array element */ + if (render_bin_output(stream, container, memb, mem, nelmts) < 0) { + H5Tclose(memb); + H5TOOLS_THROW((-1), "render_bin_output failed"); } - else if (H5Tequal(tid, H5T_STD_REF_OBJ)) { - /* if (size == H5R_OBJ_REF_BUF_SIZE) */ - H5TOOLS_DEBUG("H5T_STD_REF_OBJ"); + } + H5Tclose(memb); + } break; + case H5T_VLEN: { + hsize_t nelmts; + hid_t memb = H5I_INVALID_HID; + + H5TOOLS_DEBUG("H5T_VLEN"); + /* get the VL sequences's base datatype for each element */ + memb = H5Tget_super(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char *)_mem) + block_index * size; + /* Get the number of sequence elements */ + nelmts = ((hvl_t *)((void *)mem))->len; + + /* dump the array element */ + if (render_bin_output(stream, container, memb, ((char *)(((hvl_t *)((void *)mem))->p)), + nelmts) < 0) { + H5Tclose(memb); + H5TOOLS_THROW((-1), "render_bin_output failed"); } } - break; + H5Tclose(memb); + } break; + case H5T_REFERENCE: { + H5TOOLS_DEBUG("reference class type"); + if (H5Tequal(tid, H5T_STD_REF)) { + H5TOOLS_DEBUG("H5T_STD_REF"); + if (region_output) { + /* region data */ + hid_t region_id = H5I_INVALID_HID; + hid_t region_space = H5I_INVALID_HID; + H5S_sel_type region_type; + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char *)_mem) + block_index * size; + if ((region_id = H5Ropen_object((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) + H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed"); + else { + if ((region_space = H5Ropen_region((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= + 0) { + if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) { + region_type = H5Sget_select_type(region_space); + if (region_type == H5S_SEL_POINTS) + render_bin_output_region_points(region_space, region_id, stream, + container); + else + render_bin_output_region_blocks(region_space, region_id, stream, + container); + } + else { + H5TOOLS_INFO("H5Ropen_object H5T_STD_REF NULL"); + } + H5Sclose(region_space); + } /* end if (region_space >= 0) */ + H5Dclose(region_id); + } + } + } /* end if (region_output... */ + } + else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) { + /* if (size == H5R_DSET_REG_REF_BUF_SIZE) */ + H5TOOLS_DEBUG("H5T_STD_REF_DSETREG"); + } + else if (H5Tequal(tid, H5T_STD_REF_OBJ)) { + /* if (size == H5R_OBJ_REF_BUF_SIZE) */ + H5TOOLS_DEBUG("H5T_STD_REF_OBJ"); + } + } break; case H5T_TIME: case H5T_OPAQUE: H5TOOLS_DEBUG("H5T_OPAQUE"); for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; + mem = ((unsigned char *)_mem) + block_index * size; if (size != HDfwrite(mem, sizeof(char), size, stream)) H5TOOLS_THROW((-1), "fwrite failed"); } /* end for */ @@ -1978,7 +1958,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t break; } /* end switch */ -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; } @@ -1995,55 +1975,55 @@ CATCH *------------------------------------------------------------------------- */ int -render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, - hid_t container, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata) +render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, unsigned ndims, + hid_t type_id, hsize_t nblocks, hsize_t *ptdata) { - hsize_t *dims1 = NULL; - hsize_t *start = NULL; - hsize_t *count = NULL; - hsize_t numelem; - hsize_t total_size[H5S_MAX_RANK]; - unsigned jndx; - size_t type_size; - hid_t mem_space = H5I_INVALID_HID; - void *region_buf = NULL; - hbool_t past_catch = FALSE; - hsize_t blkndx; - hid_t sid1 = H5I_INVALID_HID; - int ret_value = -1; + hsize_t *dims1 = NULL; + hsize_t *start = NULL; + hsize_t *count = NULL; + hsize_t numelem; + hsize_t total_size[H5S_MAX_RANK]; + unsigned jndx; + size_t type_size; + hid_t mem_space = H5I_INVALID_HID; + void * region_buf = NULL; + hbool_t past_catch = FALSE; + hsize_t blkndx; + hid_t sid1 = H5I_INVALID_HID; + int ret_value = -1; H5TOOLS_START_DEBUG(""); /* Get the dataspace of the dataset */ - if((sid1 = H5Dget_space(region_id)) < 0) + if ((sid1 = H5Dget_space(region_id)) < 0) H5TOOLS_THROW((-1), "H5Dget_space failed"); /* Allocate space for the dimension array */ - if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) + if ((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL) H5TOOLS_THROW((-1), "Could not allocate buffer for dims"); /* find the dimensions of each data space from the block coordinates */ numelem = 1; for (jndx = 0; jndx < ndims; jndx++) { dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1; - numelem = dims1[jndx] * numelem; + numelem = dims1[jndx] * numelem; } /* Create dataspace for reading buffer */ - if((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0) + if ((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0) H5TOOLS_THROW((-1), "H5Screate_simple failed"); - if((type_size = H5Tget_size(type_id)) == 0) + if ((type_size = H5Tget_size(type_id)) == 0) H5TOOLS_THROW((-1), "H5Tget_size failed"); - if((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL) + if ((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL) H5TOOLS_THROW((-1), "Could not allocate region buffer"); /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ /* 1 2 n 1 2 n */ - if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) + if ((start = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL) H5TOOLS_THROW((-1), "Could not allocate buffer for start"); - if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) + if ((count = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL) H5TOOLS_THROW((-1), "Could not allocate buffer for count"); for (blkndx = 0; blkndx < nblocks; blkndx++) { @@ -2052,31 +2032,30 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, count[jndx] = dims1[jndx]; } - if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); - if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0) + if (H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); - if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) + if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); - if(render_bin_output(stream, container, type_id, (char*)region_buf, numelem) < 0) + if (render_bin_output(stream, container, type_id, (char *)region_buf, numelem) < 0) H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data region failed"); /* Render the region data element end */ -done: - ; +done:; } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ -CATCH + CATCH HDfree(start); HDfree(count); HDfree(region_buf); HDfree(dims1); - if(H5Sclose(mem_space) < 0) + if (H5Sclose(mem_space) < 0) H5TOOLS_ERROR((-1), "H5Sclose failed"); - if(H5Sclose(sid1) < 0) + if (H5Sclose(sid1) < 0) H5TOOLS_ERROR((-1), "H5Sclose failed"); H5TOOLS_ENDDEBUG(""); @@ -2094,40 +2073,39 @@ CATCH *------------------------------------------------------------------------- */ hbool_t -render_bin_output_region_blocks(hid_t region_space, hid_t region_id, - FILE *stream, hid_t container) +render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container) { - hssize_t snblocks; - hsize_t nblocks; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - int sndims; - unsigned ndims; - hid_t dtype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - hbool_t past_catch = FALSE; - hbool_t ret_value = TRUE; + hssize_t snblocks; + hsize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + int sndims; + unsigned ndims; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; H5TOOLS_START_DEBUG(""); - if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) + if ((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) H5TOOLS_THROW(FALSE, "H5Sget_select_hyper_nblocks failed"); nblocks = (hsize_t)snblocks; /* Print block information */ - if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) + if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) H5TOOLS_THROW(FALSE, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); - if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) + if ((ptdata = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) H5TOOLS_GOTO_ERROR(FALSE, "Could not allocate buffer for ptdata"); - if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, nblocks, ptdata) < 0) + if (H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0) H5TOOLS_GOTO_ERROR(FALSE, "H5Rget_select_hyper_blocklist failed"); - if((dtype = H5Dget_type(region_id)) < 0) + if ((dtype = H5Dget_type(region_id)) < 0) H5TOOLS_GOTO_ERROR(FALSE, "H5Dget_type failed"); - if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FALSE, "H5Tget_native_type failed"); render_bin_output_region_data_blocks(region_id, stream, container, ndims, type_id, nblocks, ptdata); @@ -2135,15 +2113,15 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, done: HDfree(ptdata); - if(type_id > 0 && H5Tclose(type_id) < 0) + if (type_id > 0 && H5Tclose(type_id) < 0) H5TOOLS_ERROR(FALSE, "H5Tclose failed"); - if(dtype > 0 && H5Tclose(dtype) < 0) + if (dtype > 0 && H5Tclose(dtype) < 0) H5TOOLS_ERROR(FALSE, "H5Tclose failed"); H5_LEAVE(TRUE) -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; } @@ -2166,44 +2144,43 @@ CATCH *------------------------------------------------------------------------- */ int -render_bin_output_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, hid_t container, - unsigned ndims, hid_t type_id, hsize_t npoints) +render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container, + unsigned ndims, hid_t type_id, hsize_t npoints) { hsize_t *dims1 = NULL; size_t type_size; - hid_t mem_space = H5I_INVALID_HID; - void *region_buf = NULL; - int ret_value = 0; + hid_t mem_space = H5I_INVALID_HID; + void * region_buf = NULL; + int ret_value = 0; H5TOOLS_START_DEBUG(""); - if((type_size = H5Tget_size(type_id)) == 0) + if ((type_size = H5Tget_size(type_id)) == 0) H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); - if((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL) + if ((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL) H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for region"); /* Allocate space for the dimension array */ - if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) + if ((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL) H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for dims"); dims1[0] = npoints; - if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) + if ((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Screate_simple failed"); - if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) + if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); - if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) + if (H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); - if(render_bin_output(stream, container, type_id, (char*)region_buf, npoints) < 0) + if (render_bin_output(stream, container, type_id, (char *)region_buf, npoints) < 0) H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data points failed"); done: HDfree(region_buf); HDfree(dims1); - if(H5Sclose(mem_space) < 0) + if (H5Sclose(mem_space) < 0) H5TOOLS_ERROR((-1), "H5Sclose failed"); H5TOOLS_ENDDEBUG(""); @@ -2221,45 +2198,44 @@ done: *------------------------------------------------------------------------- */ hbool_t -render_bin_output_region_points(hid_t region_space, hid_t region_id, - FILE *stream, hid_t container) +render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container) { hssize_t snpoints; hsize_t npoints; int sndims; unsigned ndims; - hid_t dtype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; hbool_t past_catch = FALSE; - hbool_t ret_value = TRUE; + hbool_t ret_value = TRUE; H5TOOLS_START_DEBUG(""); - if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0) + if ((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0) H5TOOLS_THROW(FALSE, "H5Sget_select_elem_npoints failed"); npoints = (hsize_t)snpoints; /* Allocate space for the dimension array */ - if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) + if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) H5TOOLS_THROW(FALSE, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; - if((dtype = H5Dget_type(region_id)) < 0) + if ((dtype = H5Dget_type(region_id)) < 0) H5TOOLS_GOTO_ERROR(FALSE, "H5Dget_type failed"); - if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FALSE, "H5Tget_native_type failed"); render_bin_output_region_data_points(region_space, region_id, stream, container, ndims, type_id, npoints); done: - if(type_id > 0 && H5Tclose(type_id) < 0) + if (type_id > 0 && H5Tclose(type_id) < 0) H5TOOLS_ERROR(FALSE, "H5Tclose failed"); - if(dtype > 0 && H5Tclose(dtype) < 0) + if (dtype > 0 && H5Tclose(dtype) < 0) H5TOOLS_ERROR(FALSE, "H5Tclose failed"); H5_LEAVE(ret_value) -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; } @@ -2276,7 +2252,7 @@ CATCH H5_ATTR_PURE hbool_t h5tools_is_zero(const void *_mem, size_t size) { - const unsigned char *mem = (const unsigned char *) _mem; + const unsigned char *mem = (const unsigned char *)_mem; while (size-- > 0) if (mem[size]) @@ -2303,31 +2279,29 @@ h5tools_is_zero(const void *_mem, size_t size) *------------------------------------------------------------------------- */ hbool_t -h5tools_is_obj_same(hid_t loc_id1, const char *name1, - hid_t loc_id2, const char *name2) +h5tools_is_obj_same(hid_t loc_id1, const char *name1, hid_t loc_id2, const char *name2) { H5O_info2_t oinfo1, oinfo2; - hbool_t ret_val = FALSE; + hbool_t ret_val = FALSE; - if ( name1 && HDstrcmp(name1, ".")) - H5Oget_info_by_name3(loc_id1, name1, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT); + if (name1 && HDstrcmp(name1, ".")) + H5Oget_info_by_name3(loc_id1, name1, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT); else - H5Oget_info3(loc_id1, &oinfo1, H5O_INFO_BASIC); + H5Oget_info3(loc_id1, &oinfo1, H5O_INFO_BASIC); - if ( name2 && HDstrcmp(name2, ".")) - H5Oget_info_by_name3(loc_id2, name2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); + if (name2 && HDstrcmp(name2, ".")) + H5Oget_info_by_name3(loc_id2, name2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); else - H5Oget_info3(loc_id2, &oinfo2, H5O_INFO_BASIC); + H5Oget_info3(loc_id2, &oinfo2, H5O_INFO_BASIC); if (oinfo1.fileno == oinfo2.fileno) { int token_cmp_val; H5Otoken_cmp(loc_id1, &oinfo1.token, &oinfo2.token, &token_cmp_val); - if(!token_cmp_val) + if (!token_cmp_val) ret_val = TRUE; } return ret_val; } - diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 14a5361..8262c80 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -23,88 +23,98 @@ #include "hdf5.h" #include "h5tools_error.h" -#define ESCAPE_HTML 1 -#define OPT(X,S) ((X) ? (X) : (S)) -#define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */ +#define ESCAPE_HTML 1 +#define OPT(X, S) ((X) ? (X) : (S)) +#define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */ #define START_OF_DATA 0x0001 -#define END_OF_DATA 0x0002 +#define END_OF_DATA 0x0002 /* format for hsize_t */ -#define HSIZE_T_FORMAT "%" H5_PRINTF_LL_WIDTH "u" +#define HSIZE_T_FORMAT "%" H5_PRINTF_LL_WIDTH "u" -#define H5TOOLS_DUMP_MAX_RANK H5S_MAX_RANK +#define H5TOOLS_DUMP_MAX_RANK H5S_MAX_RANK /* Stream macros */ -#define FLUSHSTREAM(S) if(S != NULL) HDfflush(S) -#define PRINTSTREAM(S, F, ...) if(S != NULL) HDfprintf(S, F, __VA_ARGS__) -#define PRINTVALSTREAM(S, V) if(S != NULL) HDfprintf(S, V) -#define PUTSTREAM(X,S) do { if(S != NULL) HDfputs(X, S); } while(0) +#define FLUSHSTREAM(S) \ + if (S != NULL) \ + HDfflush(S) +#define PRINTSTREAM(S, F, ...) \ + if (S != NULL) \ + HDfprintf(S, F, __VA_ARGS__) +#define PRINTVALSTREAM(S, V) \ + if (S != NULL) \ + HDfprintf(S, V) +#define PUTSTREAM(X, S) \ + do { \ + if (S != NULL) \ + HDfputs(X, S); \ + } while (0) /* * Strings for output - these were duplicated from the h5dump.h * file in order to support region reference data display */ -#define ATTRIBUTE "ATTRIBUTE" -#define BLOCK "BLOCK" -#define SUPER_BLOCK "SUPER_BLOCK" -#define COMPRESSION "COMPRESSION" -#define CONCATENATOR "//" -#define COMPLEX "COMPLEX" -#define COUNT "COUNT" -#define CSET "CSET" -#define CTYPE "CTYPE" -#define DATA "DATA" -#define DATASPACE "DATASPACE" -#define EXTERNAL "EXTERNAL" -#define FILENO "FILENO" -#define HARDLINK "HARDLINK" -#define NLINK "NLINK" -#define OBJID "OBJECTID" -#define OBJNO "OBJNO" -#define S_SCALAR "SCALAR" -#define S_SIMPLE "SIMPLE" -#define S_NULL "NULL" -#define SOFTLINK "SOFTLINK" -#define EXTLINK "EXTERNAL_LINK" -#define UDLINK "USERDEFINED_LINK" -#define START "START" -#define STRIDE "STRIDE" -#define STRSIZE "STRSIZE" -#define STRPAD "STRPAD" -#define SUBSET "SUBSET" -#define FILTERS "FILTERS" -#define DEFLATE "COMPRESSION DEFLATE" -#define DEFLATE_LEVEL "LEVEL" -#define SHUFFLE "PREPROCESSING SHUFFLE" -#define FLETCHER32 "CHECKSUM FLETCHER32" -#define SZIP "COMPRESSION SZIP" -#define NBIT "COMPRESSION NBIT" -#define SCALEOFFSET "COMPRESSION SCALEOFFSET" -#define SCALEOFFSET_MINBIT "MIN BITS" -#define STORAGE_LAYOUT "STORAGE_LAYOUT" -#define CONTIGUOUS "CONTIGUOUS" -#define COMPACT "COMPACT" -#define CHUNKED "CHUNKED" -#define EXTERNAL_FILE "EXTERNAL_FILE" -#define FILLVALUE "FILLVALUE" -#define FILE_CONTENTS "FILE_CONTENTS" -#define PACKED_BITS "PACKED_BITS" -#define PACKED_OFFSET "OFFSET" -#define PACKED_LENGTH "LENGTH" -#define REGION "REGION" -#define VDS_VIRTUAL "VIRTUAL" -#define VDS_MAPPING "MAPPING" -#define VDS_SOURCE "SOURCE" -#define VDS_REG_HYPERSLAB "SELECTION REGULAR_HYPERSLAB" -#define VDS_IRR_HYPERSLAB "SELECTION IRREGULAR_HYPERSLAB" -#define VDS_POINT "POINT" -#define VDS_SRC_FILE "FILE" -#define VDS_SRC_DATASET "DATASET" -#define VDS_NONE "SELECTION NONE" -#define VDS_ALL "SELECTION ALL" - -#define BEGIN "{" -#define END "}" +#define ATTRIBUTE "ATTRIBUTE" +#define BLOCK "BLOCK" +#define SUPER_BLOCK "SUPER_BLOCK" +#define COMPRESSION "COMPRESSION" +#define CONCATENATOR "//" +#define COMPLEX "COMPLEX" +#define COUNT "COUNT" +#define CSET "CSET" +#define CTYPE "CTYPE" +#define DATA "DATA" +#define DATASPACE "DATASPACE" +#define EXTERNAL "EXTERNAL" +#define FILENO "FILENO" +#define HARDLINK "HARDLINK" +#define NLINK "NLINK" +#define OBJID "OBJECTID" +#define OBJNO "OBJNO" +#define S_SCALAR "SCALAR" +#define S_SIMPLE "SIMPLE" +#define S_NULL "NULL" +#define SOFTLINK "SOFTLINK" +#define EXTLINK "EXTERNAL_LINK" +#define UDLINK "USERDEFINED_LINK" +#define START "START" +#define STRIDE "STRIDE" +#define STRSIZE "STRSIZE" +#define STRPAD "STRPAD" +#define SUBSET "SUBSET" +#define FILTERS "FILTERS" +#define DEFLATE "COMPRESSION DEFLATE" +#define DEFLATE_LEVEL "LEVEL" +#define SHUFFLE "PREPROCESSING SHUFFLE" +#define FLETCHER32 "CHECKSUM FLETCHER32" +#define SZIP "COMPRESSION SZIP" +#define NBIT "COMPRESSION NBIT" +#define SCALEOFFSET "COMPRESSION SCALEOFFSET" +#define SCALEOFFSET_MINBIT "MIN BITS" +#define STORAGE_LAYOUT "STORAGE_LAYOUT" +#define CONTIGUOUS "CONTIGUOUS" +#define COMPACT "COMPACT" +#define CHUNKED "CHUNKED" +#define EXTERNAL_FILE "EXTERNAL_FILE" +#define FILLVALUE "FILLVALUE" +#define FILE_CONTENTS "FILE_CONTENTS" +#define PACKED_BITS "PACKED_BITS" +#define PACKED_OFFSET "OFFSET" +#define PACKED_LENGTH "LENGTH" +#define REGION "REGION" +#define VDS_VIRTUAL "VIRTUAL" +#define VDS_MAPPING "MAPPING" +#define VDS_SOURCE "SOURCE" +#define VDS_REG_HYPERSLAB "SELECTION REGULAR_HYPERSLAB" +#define VDS_IRR_HYPERSLAB "SELECTION IRREGULAR_HYPERSLAB" +#define VDS_POINT "POINT" +#define VDS_SRC_FILE "FILE" +#define VDS_SRC_DATASET "DATASET" +#define VDS_NONE "SELECTION NONE" +#define VDS_ALL "SELECTION ALL" + +#define BEGIN "{" +#define END "}" /* * dump structure for output - this was duplicated from the h5dump.h @@ -205,7 +215,6 @@ typedef struct h5tools_dump_header_t { /* Forward declaration (see declaration in h5tools_str.c) */ struct H5LD_memb_t; - /* * Information about how to format output. */ @@ -282,19 +291,19 @@ typedef struct h5tool_format_t { * Numeric data is also subject to the formats for individual elements. */ hbool_t raw; - const char *fmt_raw; - const char *fmt_int; - const char *fmt_uint; - const char *fmt_schar; - const char *fmt_uchar; - const char *fmt_short; - const char *fmt_ushort; - const char *fmt_long; - const char *fmt_ulong; - const char *fmt_llong; - const char *fmt_ullong; - const char *fmt_double; - const char *fmt_float; + const char *fmt_raw; + const char *fmt_int; + const char *fmt_uint; + const char *fmt_schar; + const char *fmt_uchar; + const char *fmt_short; + const char *fmt_ushort; + const char *fmt_long; + const char *fmt_ulong; + const char *fmt_llong; + const char *fmt_ullong; + const char *fmt_double; + const char *fmt_float; int ascii; int str_locale; unsigned str_repeat; @@ -315,9 +324,9 @@ typedef struct h5tool_format_t { * linebreaks: a boolean value to determine if we want to break the line * after each row of an array. */ - const char *arr_pre; - const char *arr_sep; - const char *arr_suf; + const char *arr_pre; + const char *arr_sep; + const char *arr_suf; int arr_linebreak; /* @@ -344,13 +353,12 @@ typedef struct h5tool_format_t { * * listv: h5watch: vector containing info about the list of compound fields to be printed. */ - const char *cmpd_name; - const char *cmpd_sep; - const char *cmpd_pre; - const char *cmpd_suf; - const char *cmpd_end; - const struct H5LD_memb_t * const *cmpd_listv; - + const char * cmpd_name; + const char * cmpd_sep; + const char * cmpd_pre; + const char * cmpd_suf; + const char * cmpd_end; + const struct H5LD_memb_t *const *cmpd_listv; /* * Fields associated with vlen data types. @@ -369,10 +377,10 @@ typedef struct h5tool_format_t { * end: a string to print after we reach the last element of * each compound type. prints out before the suf. */ - const char *vlen_sep; - const char *vlen_pre; - const char *vlen_suf; - const char *vlen_end; + const char *vlen_sep; + const char *vlen_pre; + const char *vlen_suf; + const char *vlen_end; /* * Fields associated with the individual elements. @@ -388,9 +396,9 @@ typedef struct h5tool_format_t { * are followed on the same line by another element. The * default is a single space. */ - const char *elmt_fmt; - const char *elmt_suf1; - const char *elmt_suf2; + const char *elmt_fmt; + const char *elmt_suf1; + const char *elmt_suf2; /* * Fields associated with the index values printed at the left edge of @@ -409,9 +417,9 @@ typedef struct h5tool_format_t { * printf(3c) format which should include a format for a * character string. The default is "%s". */ - const char *idx_n_fmt; /*index number format */ - const char *idx_sep; /*separator between numbers */ - const char *idx_fmt; /*entire index format */ + const char *idx_n_fmt; /*index number format */ + const char *idx_sep; /*separator between numbers */ + const char *idx_fmt; /*entire index format */ /* * Fields associated with entire lines. @@ -467,15 +475,15 @@ typedef struct h5tool_format_t { * indentlevel: a string that shows how far to indent if extra spacing * is needed. dumper uses it. */ - unsigned line_ncols; /*columns of output */ - size_t line_per_line; /*max elements per line */ - const char *line_pre; /*prefix at front of each line */ - const char *line_1st; /*alternate pre. on first line */ - const char *line_cont; /*alternate pre. on continuation*/ - const char *line_suf; /*string to append to each line */ - const char *line_sep; /*separates lines */ - int line_multi_new; /*split multi-line outputs? */ - const char *line_indent; /*for extra identation if we need it*/ + unsigned line_ncols; /*columns of output */ + size_t line_per_line; /*max elements per line */ + const char *line_pre; /*prefix at front of each line */ + const char *line_1st; /*alternate pre. on first line */ + const char *line_cont; /*alternate pre. on continuation*/ + const char *line_suf; /*string to append to each line */ + const char *line_sep; /*separates lines */ + int line_multi_new; /*split multi-line outputs? */ + const char *line_indent; /*for extra identation if we need it*/ /*used to skip the first set of checks for line length*/ int skip_first; @@ -505,7 +513,7 @@ typedef struct h5tool_format_t { } h5tool_format_t; typedef struct subset_d { - hsize_t *data; + hsize_t * data; unsigned int len; } subset_d; @@ -518,35 +526,33 @@ struct subset_t { }; typedef struct h5tools_context_t { - size_t cur_column; /* current column for output */ - size_t cur_elmt; /* current element/output line */ - int need_prefix; /* is line prefix needed? */ + size_t cur_column; /* current column for output */ + size_t cur_elmt; /* current element/output line */ + int need_prefix; /* is line prefix needed? */ unsigned ndims; /* dimensionality */ - hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */ - hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */ - int prev_multiline; /* was prev datum multiline? */ - size_t prev_prefix_len; /* length of previous prefix */ - int continuation; /* continuation of previous data?*/ - hsize_t size_last_dim; /* the size of the last dimension, needed so we can break after each row */ - unsigned indent_level; /* the number of times we need some extra indentation */ - unsigned default_indent_level; /* this is used when the indent level gets changed */ - hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ - hsize_t pos[H5S_MAX_RANK]; /* matrix position */ - hsize_t sm_pos; /* current stripmine element position */ - const struct H5LD_memb_t * const *cmpd_listv; /* h5watch: vector containing info about the list of compound fields to be printed */ - struct subset_t *sset; /* subsetting parameters */ - int display_index; /* */ - int display_char; /* */ + hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */ + hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */ + int prev_multiline; /* was prev datum multiline? */ + size_t prev_prefix_len; /* length of previous prefix */ + int continuation; /* continuation of previous data?*/ + hsize_t size_last_dim; /* the size of the last dimension, needed so we can break after each row */ + unsigned indent_level; /* the number of times we need some extra indentation */ + unsigned default_indent_level; /* this is used when the indent level gets changed */ + hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ + hsize_t pos[H5S_MAX_RANK]; /* matrix position */ + hsize_t sm_pos; /* current stripmine element position */ + const struct H5LD_memb_t *const + *cmpd_listv; /* h5watch: vector containing info about the list of compound fields to be printed */ + struct subset_t *sset; /* subsetting parameters */ + int display_index; /* */ + int display_char; /* */ } h5tools_context_t; /* VOL and VFD info structs used to set the file access property * lists in the tools. */ -typedef enum { - VOL_BY_NAME, - VOL_BY_VALUE -} h5tools_vol_info_type_t; +typedef enum { VOL_BY_NAME, VOL_BY_VALUE } h5tools_vol_info_type_t; typedef struct h5tools_vol_info_t { h5tools_vol_info_type_t type; @@ -556,8 +562,8 @@ typedef struct h5tools_vol_info_t { /* Field specifying either the connector's name or value (ID) */ union { - const char *name; - H5VL_class_value_t value; + const char * name; + H5VL_class_value_t value; } u; } h5tools_vol_info_t; @@ -604,7 +610,6 @@ typedef enum { #include "h5tools_str.h" - #ifdef __cplusplus extern "C" { #endif @@ -612,92 +617,99 @@ extern "C" { H5TOOLS_DLLVAR const char *volnames[]; H5TOOLS_DLLVAR const char *drivernames[]; -H5TOOLS_DLLVAR h5tool_format_t h5tools_dataformat; +H5TOOLS_DLLVAR h5tool_format_t h5tools_dataformat; H5TOOLS_DLLVAR const h5tools_dump_header_t h5tools_standardformat; -H5TOOLS_DLLVAR const h5tools_dump_header_t* h5tools_dump_header_format; -H5TOOLS_DLLVAR H5E_auto2_t lib_func; -H5TOOLS_DLLVAR H5E_auto2_t tools_func; -H5TOOLS_DLLVAR void *lib_edata; -H5TOOLS_DLLVAR void *tools_edata; - -H5TOOLS_DLLVAR unsigned packed_bits_num; /* number of packed bits to display */ -H5TOOLS_DLLVAR unsigned packed_data_offset; /* offset of packed bits to display */ -H5TOOLS_DLLVAR unsigned packed_data_length; /* length of packed bits to display */ -H5TOOLS_DLLVAR unsigned long long packed_data_mask; /* mask in which packed bits to display */ -H5TOOLS_DLLVAR FILE *rawattrstream; /* output stream for raw attribute data */ -H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */ -H5TOOLS_DLLVAR FILE *rawinstream; /* input stream for raw input */ -H5TOOLS_DLLVAR FILE *rawoutstream; /* output stream for raw output */ -H5TOOLS_DLLVAR FILE *rawerrorstream; /* output stream for raw error */ -H5TOOLS_DLLVAR int bin_output; /* binary output */ -H5TOOLS_DLLVAR int bin_form; /* binary form */ -H5TOOLS_DLLVAR int region_output; /* region output */ -H5TOOLS_DLLVAR int oid_output; /* oid output */ -H5TOOLS_DLLVAR int data_output; /* data output */ -H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */ +H5TOOLS_DLLVAR const h5tools_dump_header_t *h5tools_dump_header_format; +H5TOOLS_DLLVAR H5E_auto2_t lib_func; +H5TOOLS_DLLVAR H5E_auto2_t tools_func; +H5TOOLS_DLLVAR void * lib_edata; +H5TOOLS_DLLVAR void * tools_edata; + +H5TOOLS_DLLVAR unsigned packed_bits_num; /* number of packed bits to display */ +H5TOOLS_DLLVAR unsigned packed_data_offset; /* offset of packed bits to display */ +H5TOOLS_DLLVAR unsigned packed_data_length; /* length of packed bits to display */ +H5TOOLS_DLLVAR unsigned long long packed_data_mask; /* mask in which packed bits to display */ +H5TOOLS_DLLVAR FILE *rawattrstream; /* output stream for raw attribute data */ +H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */ +H5TOOLS_DLLVAR FILE *rawinstream; /* input stream for raw input */ +H5TOOLS_DLLVAR FILE *rawoutstream; /* output stream for raw output */ +H5TOOLS_DLLVAR FILE *rawerrorstream; /* output stream for raw error */ +H5TOOLS_DLLVAR int bin_output; /* binary output */ +H5TOOLS_DLLVAR int bin_form; /* binary form */ +H5TOOLS_DLLVAR int region_output; /* region output */ +H5TOOLS_DLLVAR int oid_output; /* oid output */ +H5TOOLS_DLLVAR int data_output; /* data output */ +H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */ /* sort parameters */ -H5TOOLS_DLLVAR H5_index_t sort_by; /* sort_by [creation_order | name] */ -H5TOOLS_DLLVAR H5_iter_order_t sort_order; /* sort_order [ascending | descending] */ +H5TOOLS_DLLVAR H5_index_t sort_by; /* sort_by [creation_order | name] */ +H5TOOLS_DLLVAR H5_iter_order_t sort_order; /* sort_order [ascending | descending] */ /* things to display or which are set via command line parameters */ -H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack; disable=0 enable=1 */ +H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack; disable=0 enable=1 */ /* Strings for output */ -#define H5_TOOLS_GROUP "GROUP" -#define H5_TOOLS_DATASET "DATASET" -#define H5_TOOLS_DATATYPE "DATATYPE" -#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE" -#define H5_TOOLS_UNKNOWN "UNKNOWN" +#define H5_TOOLS_GROUP "GROUP" +#define H5_TOOLS_DATASET "DATASET" +#define H5_TOOLS_DATATYPE "DATATYPE" +#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE" +#define H5_TOOLS_UNKNOWN "UNKNOWN" /* Definitions of useful routines */ -H5TOOLS_DLL void h5tools_init(void); -H5TOOLS_DLL void h5tools_close(void); - -H5TOOLS_DLL void h5tools_error_report(void); -H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin); - -H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, h5tools_vfd_info_t *vfd_info); -H5TOOLS_DLL herr_t h5tools_get_vfd_name(hid_t fapl_id, - char *drivername, size_t drivername_size); -H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, - hbool_t use_specific_driver, char *drivername, size_t drivername_size); +H5TOOLS_DLL void h5tools_init(void); +H5TOOLS_DLL void h5tools_close(void); + +H5TOOLS_DLL void h5tools_error_report(void); +H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin); + +H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, + h5tools_vfd_info_t *vfd_info); +H5TOOLS_DLL herr_t h5tools_get_vfd_name(hid_t fapl_id, char *drivername, size_t drivername_size); +H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, hbool_t use_specific_driver, + char *drivername, size_t drivername_size); H5TOOLS_DLL hid_t h5tools_get_little_endian_type(hid_t type); H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type); H5TOOLS_DLL htri_t h5tools_detect_vlen(hid_t tid); H5TOOLS_DLL htri_t h5tools_detect_vlen_str(hid_t tid); H5TOOLS_DLL hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1, hid_t loc_id2, const char *name2); -H5TOOLS_DLL void init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx); +H5TOOLS_DLL void init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx); H5TOOLS_DLL hsize_t calc_acc_pos(unsigned ndims, hsize_t elemtno, hsize_t *acc, hsize_t *pos); H5TOOLS_DLL hbool_t h5tools_is_zero(const void *_mem, size_t size); -H5TOOLS_DLL int h5tools_canreadf(const char* name, hid_t dcpl_id); +H5TOOLS_DLL int h5tools_canreadf(const char *name, hid_t dcpl_id); H5TOOLS_DLL int h5tools_can_encode(H5Z_filter_t filtn); -H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hsize_t elmtno, int secnum); -H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hsize_t elmtno, hsize_t *ptdata, int secnum); +H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + hsize_t elmtno, int secnum); +H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, + int secnum); H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts); H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, - unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata); -H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container); -H5TOOLS_DLL int render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE* stream, hid_t container, - unsigned ndims, hid_t type_id, hsize_t npoints); -H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container); - -H5TOOLS_DLL hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, - hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter); -H5TOOLS_DLL hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, - hsize_t *curr_pos, size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter); + unsigned ndims, hid_t type_id, hsize_t nblocks, + hsize_t *ptdata); +H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, + hid_t container); +H5TOOLS_DLL int render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, + hid_t container, unsigned ndims, hid_t type_id, + hsize_t npoints); +H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, + hid_t container); + +H5TOOLS_DLL hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, + hsize_t local_elmt_counter, hsize_t elmt_counter); +H5TOOLS_DLL hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx, h5tools_str_t *buffer, + hsize_t *curr_pos, size_t ncols, hsize_t *ptdata, + hsize_t local_elmt_counter, hsize_t elmt_counter); #ifdef __cplusplus } #endif #endif /* H5TOOLS_H__ */ - diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 4ba89fa..56ffd27 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -23,192 +23,193 @@ #include "H5private.h" h5tool_format_t h5tools_dataformat = { - 0, /*raw */ - - "", /*fmt_raw */ - "%d", /*fmt_int */ - "%u", /*fmt_uint */ - "%hhd", /*fmt_schar */ - "%u", /*fmt_uchar */ - "%d", /*fmt_short */ - "%u", /*fmt_ushort */ - "%ld", /*fmt_long */ - "%lu", /*fmt_ulong */ - NULL, /*fmt_llong */ - NULL, /*fmt_ullong */ - "%g", /*fmt_double */ - "%g", /*fmt_float */ - - 0, /*ascii */ - 0, /*str_locale */ - 0, /*str_repeat */ - - "[ ", /*arr_pre */ - ",", /*arr_sep */ - " ]", /*arr_suf */ - 1, /*arr_linebreak */ - - "", /*cmpd_name */ - ",\n", /*cmpd_sep */ - "{", /*cmpd_pre */ - "}", /*cmpd_suf */ - "\n", /*cmpd_end */ - NULL, /* cmpd_listv */ - - ", ", /*vlen_sep */ - "(", /*vlen_pre */ - ")", /*vlen_suf */ - "", /*vlen_end */ - - "%s", /*elmt_fmt */ - ",", /*elmt_suf1 */ - " ", /*elmt_suf2 */ - - "", /*idx_n_fmt */ - "", /*idx_sep */ - "", /*idx_fmt */ - - 80, /*line_ncols *//*standard default columns */ - 0, /*line_per_line */ - "", /*line_pre */ - "%s", /*line_1st */ - "%s", /*line_cont */ - "", /*line_suf */ - "", /*line_sep */ - 1, /*line_multi_new */ - " ", /*line_indent */ - - 1, /*skip_first */ - - 1, /*obj_hidefileno */ + 0, /*raw */ + + "", /*fmt_raw */ + "%d", /*fmt_int */ + "%u", /*fmt_uint */ + "%hhd", /*fmt_schar */ + "%u", /*fmt_uchar */ + "%d", /*fmt_short */ + "%u", /*fmt_ushort */ + "%ld", /*fmt_long */ + "%lu", /*fmt_ulong */ + NULL, /*fmt_llong */ + NULL, /*fmt_ullong */ + "%g", /*fmt_double */ + "%g", /*fmt_float */ + + 0, /*ascii */ + 0, /*str_locale */ + 0, /*str_repeat */ + + "[ ", /*arr_pre */ + ",", /*arr_sep */ + " ]", /*arr_suf */ + 1, /*arr_linebreak */ + + "", /*cmpd_name */ + ",\n", /*cmpd_sep */ + "{", /*cmpd_pre */ + "}", /*cmpd_suf */ + "\n", /*cmpd_end */ + NULL, /* cmpd_listv */ + + ", ", /*vlen_sep */ + "(", /*vlen_pre */ + ")", /*vlen_suf */ + "", /*vlen_end */ + + "%s", /*elmt_fmt */ + ",", /*elmt_suf1 */ + " ", /*elmt_suf2 */ + + "", /*idx_n_fmt */ + "", /*idx_sep */ + "", /*idx_fmt */ + + 80, + /*line_ncols */ /*standard default columns */ + 0, /*line_per_line */ + "", /*line_pre */ + "%s", /*line_1st */ + "%s", /*line_cont */ + "", /*line_suf */ + "", /*line_sep */ + 1, /*line_multi_new */ + " ", /*line_indent */ + + 1, /*skip_first */ + + 1, /*obj_hidefileno */ " %" PRIuHADDR, /*obj_format */ - 1, /*dset_hidefileno */ + 1, /*dset_hidefileno */ "DATASET %s ", /*dset_format */ - "%s", /*dset_blockformat_pre */ - "%s", /*dset_ptformat_pre */ - "%s", /*dset_ptformat */ - 1, /*array indices */ - 1 /*escape non printable characters */ + "%s", /*dset_blockformat_pre */ + "%s", /*dset_ptformat_pre */ + "%s", /*dset_ptformat */ + 1, /*array indices */ + 1 /*escape non printable characters */ }; const h5tools_dump_header_t h5tools_standardformat = { -"standardformat", /*name */ -"HDF5", /*filebegin */ -"", /*fileend */ -SUPER_BLOCK, /*bootblockbegin */ -"", /*bootblockend */ -H5_TOOLS_GROUP, /*groupbegin */ -"", /*groupend */ -H5_TOOLS_DATASET, /*datasetbegin */ -"", /*datasetend */ -ATTRIBUTE, /*attributebegin */ -"", /*attributeend */ -H5_TOOLS_DATATYPE, /*datatypebegin */ -"", /*datatypeend */ -DATASPACE, /*dataspacebegin */ -"", /*dataspaceend */ -DATA, /*databegin */ -"", /*dataend */ -SOFTLINK, /*softlinkbegin */ -"", /*softlinkend */ -EXTLINK, /*extlinkbegin */ -"", /*extlinkend */ -UDLINK, /*udlinkbegin */ -"", /*udlinkend */ -SUBSET, /*subsettingbegin */ -"", /*subsettingend */ -START, /*startbegin */ -"", /*startend */ -STRIDE, /*stridebegin */ -"", /*strideend */ -COUNT, /*countbegin */ -"", /*countend */ -BLOCK, /*blockbegin */ -"", /*blockend */ - -"{", /*fileblockbegin */ -"}", /*fileblockend */ -"{", /*bootblockblockbegin */ -"}", /*bootblockblockend */ -"{", /*groupblockbegin */ -"}", /*groupblockend */ -"{", /*datasetblockbegin */ -"}", /*datasetblockend */ -"{", /*attributeblockbegin */ -"}", /*attributeblockend */ -"", /*datatypeblockbegin */ -"", /*datatypeblockend */ -"", /*dataspaceblockbegin */ -"", /*dataspaceblockend */ -"{", /*datablockbegin */ -"}", /*datablockend */ -"{", /*softlinkblockbegin */ -"}", /*softlinkblockend */ -"{", /*extlinkblockbegin */ -"}", /*extlinkblockend */ -"{", /*udlinkblockbegin */ -"}", /*udlinkblockend */ -"{", /*strblockbegin */ -"}", /*strblockend */ -"{", /*enumblockbegin */ -"}", /*enumblockend */ -"{", /*structblockbegin */ -"}", /*structblockend */ -"{", /*vlenblockbegin */ -"}", /*vlenblockend */ -"{", /*subsettingblockbegin */ -"}", /*subsettingblockend */ -"(", /*startblockbegin */ -");", /*startblockend */ -"(", /*strideblockbegin */ -");", /*strideblockend */ -"(", /*countblockbegin */ -");", /*countblockend */ -"(", /*blockblockbegin */ -");", /*blockblockend */ - -"", /*dataspacedescriptionbegin */ -"", /*dataspacedescriptionend */ -"(", /*dataspacedimbegin */ -")", /*dataspacedimend */ - -"", /*virtualselectionbegin */ -"", /*virtualselectionend */ -"{", /*virtualselectionblockbegin */ -"}", /*virtualselectionblockend */ -"\"", /*virtualfilenamebeginbegin */ -"\"", /*virtualfilenamebeginend */ -"\"", /*virtualdatasetnamebegin */ -"\"", /*virtualdtatasetnameend */ + "standardformat", /*name */ + "HDF5", /*filebegin */ + "", /*fileend */ + SUPER_BLOCK, /*bootblockbegin */ + "", /*bootblockend */ + H5_TOOLS_GROUP, /*groupbegin */ + "", /*groupend */ + H5_TOOLS_DATASET, /*datasetbegin */ + "", /*datasetend */ + ATTRIBUTE, /*attributebegin */ + "", /*attributeend */ + H5_TOOLS_DATATYPE, /*datatypebegin */ + "", /*datatypeend */ + DATASPACE, /*dataspacebegin */ + "", /*dataspaceend */ + DATA, /*databegin */ + "", /*dataend */ + SOFTLINK, /*softlinkbegin */ + "", /*softlinkend */ + EXTLINK, /*extlinkbegin */ + "", /*extlinkend */ + UDLINK, /*udlinkbegin */ + "", /*udlinkend */ + SUBSET, /*subsettingbegin */ + "", /*subsettingend */ + START, /*startbegin */ + "", /*startend */ + STRIDE, /*stridebegin */ + "", /*strideend */ + COUNT, /*countbegin */ + "", /*countend */ + BLOCK, /*blockbegin */ + "", /*blockend */ + + "{", /*fileblockbegin */ + "}", /*fileblockend */ + "{", /*bootblockblockbegin */ + "}", /*bootblockblockend */ + "{", /*groupblockbegin */ + "}", /*groupblockend */ + "{", /*datasetblockbegin */ + "}", /*datasetblockend */ + "{", /*attributeblockbegin */ + "}", /*attributeblockend */ + "", /*datatypeblockbegin */ + "", /*datatypeblockend */ + "", /*dataspaceblockbegin */ + "", /*dataspaceblockend */ + "{", /*datablockbegin */ + "}", /*datablockend */ + "{", /*softlinkblockbegin */ + "}", /*softlinkblockend */ + "{", /*extlinkblockbegin */ + "}", /*extlinkblockend */ + "{", /*udlinkblockbegin */ + "}", /*udlinkblockend */ + "{", /*strblockbegin */ + "}", /*strblockend */ + "{", /*enumblockbegin */ + "}", /*enumblockend */ + "{", /*structblockbegin */ + "}", /*structblockend */ + "{", /*vlenblockbegin */ + "}", /*vlenblockend */ + "{", /*subsettingblockbegin */ + "}", /*subsettingblockend */ + "(", /*startblockbegin */ + ");", /*startblockend */ + "(", /*strideblockbegin */ + ");", /*strideblockend */ + "(", /*countblockbegin */ + ");", /*countblockend */ + "(", /*blockblockbegin */ + ");", /*blockblockend */ + + "", /*dataspacedescriptionbegin */ + "", /*dataspacedescriptionend */ + "(", /*dataspacedimbegin */ + ")", /*dataspacedimend */ + + "", /*virtualselectionbegin */ + "", /*virtualselectionend */ + "{", /*virtualselectionblockbegin */ + "}", /*virtualselectionblockend */ + "\"", /*virtualfilenamebeginbegin */ + "\"", /*virtualfilenamebeginend */ + "\"", /*virtualdatasetnamebegin */ + "\"", /*virtualdtatasetnameend */ }; -const h5tools_dump_header_t* h5tools_dump_header_format; -table_t *h5dump_type_table = NULL; /* type table reference for datatype dump */ +const h5tools_dump_header_t *h5tools_dump_header_format; +table_t * h5dump_type_table = NULL; /* type table reference for datatype dump */ /* local prototypes */ -static int h5tools_print_region_data_blocks(hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, - h5tools_str_t *buffer, /* string into which to render */ - size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata); +static int h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info, + h5tools_context_t *cur_ctx, + h5tools_str_t * buffer, /* string into which to render */ + size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks, + hsize_t *ptdata); -static int h5tools_print_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, - h5tools_str_t *buffer, size_t ncols, - unsigned ndims, hid_t type_id, hsize_t npoints, hsize_t *ptdata); +static int h5tools_print_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, + const h5tool_format_t *info, h5tools_context_t *cur_ctx, + h5tools_str_t *buffer, size_t ncols, unsigned ndims, + hid_t type_id, hsize_t npoints, hsize_t *ptdata); void h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims); -void h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, int dims); +void h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + int dims); -static void h5tools_print_virtual_selection(hid_t vspace, - FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, /* in,out */ - h5tools_str_t *buffer, /* string into which to render */ - hsize_t *curr_pos, /* total data element position */ - size_t ncols); +static void h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx, /* in,out */ + h5tools_str_t * buffer, /* string into which to render */ + hsize_t * curr_pos, /* total data element position */ + size_t ncols); void h5tools_dump_init(void) @@ -253,27 +254,27 @@ h5tools_dump_init(void) *------------------------------------------------------------------------- */ int -h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */ +h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */ hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem) { - unsigned char *mem = (unsigned char*) _mem; - hsize_t i; /* element counter */ - size_t size; /* size of each datum */ + unsigned char *mem = (unsigned char *)_mem; + hsize_t i; /* element counter */ + size_t size; /* size of each datum */ hbool_t dimension_break = TRUE; - size_t ncols = 80; /* available output width */ - h5tools_str_t buffer; /* string into which to render */ - hsize_t curr_pos = 0; /* total data element position */ - hsize_t elmt_counter = 0;/* counts the # elements printed. - * I (ptl?) needed something that - * isn't going to get reset when a new - * line is formed. I'm going to use - * this var to count elements and - * break after we see a number equal - * to the ctx->size_last_dim. */ - int ret_value = 0; - - H5TOOLS_START_DEBUG(" file=%p", (void*)stream); - H5TOOLS_DEBUG("rawdata file=%p", (void*)rawdatastream); + size_t ncols = 80; /* available output width */ + h5tools_str_t buffer; /* string into which to render */ + hsize_t curr_pos = 0; /* total data element position */ + hsize_t elmt_counter = 0; /* counts the # elements printed. + * I (ptl?) needed something that + * isn't going to get reset when a new + * line is formed. I'm going to use + * this var to count elements and + * break after we see a number equal + * to the ctx->size_last_dim. */ + int ret_value = 0; + + H5TOOLS_START_DEBUG(" file=%p", (void *)stream); + H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream); /* binary dump */ if (bin_output && (rawdatastream != NULL)) { H5TOOLS_DEBUG("render_bin_output"); @@ -298,7 +299,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_cont H5TOOLS_DEBUG("data render start:%ld", nelmts); for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { - void* memref = mem + i * size; + void *memref = mem + i * size; /* Render the data element begin*/ h5tools_str_reset(&buffer); @@ -307,16 +308,16 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_cont if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ",")); - dimension_break = h5tools_render_element(stream, info, ctx, &buffer, - &curr_pos, ncols, i, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, i, elmt_counter); /* Render the data element end*/ - if(FALSE == dimension_break) + if (FALSE == dimension_break) elmt_counter = 0; } /* end for (i = 0; i < nelmts... */ H5TOOLS_DEBUG("data render finish"); h5tools_str_close(&buffer); - }/* else bin */ + } /* else bin */ H5TOOLS_ENDDEBUG("exit"); return ret_value; @@ -346,47 +347,47 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_cont *------------------------------------------------------------------------- */ hbool_t -h5tools_dump_region_attribute(hid_t region_id, - FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, /* in,out */ - h5tools_str_t *buffer, /* string into which to render */ - hsize_t *curr_pos, /* total data element position */ - size_t ncols, hsize_t region_elmt_counter, /* element counter */ - hsize_t elmt_counter) +h5tools_dump_region_attribute(hid_t region_id, FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx, /* in,out */ + h5tools_str_t * buffer, /* string into which to render */ + hsize_t * curr_pos, /* total data element position */ + size_t ncols, hsize_t region_elmt_counter, /* element counter */ + hsize_t elmt_counter) { hbool_t dimension_break = TRUE; - hid_t atype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - hid_t region_space = H5I_INVALID_HID; + hid_t atype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + hid_t region_space = H5I_INVALID_HID; h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ hbool_t past_catch = FALSE; - hbool_t ret_value = TRUE; + hbool_t ret_value = TRUE; HDassert(info); HDassert(ctx); HDassert(buffer); - outputformat = *info; + outputformat = *info; outputformat.idx_fmt = ""; outputformat.idx_n_fmt = ""; outputformat.idx_sep = ""; outputformat.line_pre = ""; - H5TOOLS_DEBUG("enter file=%p", (void*)stream); - H5TOOLS_DEBUG("rawdata file=%p", (void*)rawdatastream); + H5TOOLS_DEBUG("enter file=%p", (void *)stream); + H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream); /* Render the region { element begin */ h5tools_str_reset(buffer); h5tools_str_append(buffer, " {"); - dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, + region_elmt_counter, elmt_counter); /* Render the region { element end */ - if((region_space = H5Aget_space(region_id)) < 0) + if ((region_space = H5Aget_space(region_id)) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Aget_space failed"); - if((atype = H5Aget_type(region_id)) < 0) + if ((atype = H5Aget_type(region_id)) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Aget_type failed"); - if((type_id = H5Tget_native_type(atype, H5T_DIR_DEFAULT)) < 0) + if ((type_id = H5Tget_native_type(atype, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed"); ctx->indent_level++; @@ -394,9 +395,8 @@ h5tools_dump_region_attribute(hid_t region_id, /* Render the datatype element begin */ h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s %s ", - h5tools_dump_header_format->datatypebegin, - h5tools_dump_header_format->datatypeblockbegin); + h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin, + h5tools_dump_header_format->datatypeblockbegin); ctx->need_prefix = TRUE; ctx->indent_level++; @@ -411,7 +411,8 @@ h5tools_dump_region_attribute(hid_t region_id, if (HDstrlen(h5tools_dump_header_format->datatypeend)) h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the datatype element end */ ctx->need_prefix = TRUE; @@ -430,7 +431,8 @@ h5tools_dump_region_attribute(hid_t region_id, if (HDstrlen(h5tools_dump_header_format->dataspaceend)) h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the dataspace element end */ if (region_output) { @@ -440,10 +442,10 @@ h5tools_dump_region_attribute(hid_t region_id, } done: - if(H5Tclose(type_id) < 0) + if (H5Tclose(type_id) < 0) H5TOOLS_ERROR(dimension_break, "H5Tclose failed"); - if(H5Tclose(atype) < 0) + if (H5Tclose(atype) < 0) H5TOOLS_ERROR(dimension_break, "H5Tclose failed"); ctx->indent_level--; @@ -452,12 +454,13 @@ done: /* Render the region } element begin */ h5tools_str_reset(buffer); h5tools_str_append(buffer, "}"); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region } element end */ H5_LEAVE(dimension_break) -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; @@ -482,30 +485,32 @@ CATCH *------------------------------------------------------------------------- */ static int -h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, - h5tools_str_t *buffer, /* string into which to render */ - size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata) +h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info, + h5tools_context_t *cur_ctx, + h5tools_str_t * buffer, /* string into which to render */ + size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks, + hsize_t *ptdata) { - hbool_t dimension_break = TRUE; - hsize_t *dims1 = NULL; - hsize_t *start = NULL; - hsize_t *count = NULL; - hsize_t blkndx; - hsize_t total_size[H5S_MAX_RANK]; - hsize_t elmtno; /* elemnt index */ - hsize_t curr_pos = 0; - unsigned int region_flags; /* buffer extent flags */ - hsize_t numelem; - hsize_t numindex; - unsigned indx; - unsigned jndx; - hbool_t past_catch = FALSE; - size_t type_size; - hid_t mem_space = H5I_INVALID_HID; - hid_t sid1 = H5I_INVALID_HID; + hbool_t dimension_break = TRUE; + hsize_t * dims1 = NULL; + hsize_t * start = NULL; + hsize_t * count = NULL; + hsize_t blkndx; + hsize_t total_size[H5S_MAX_RANK]; + hsize_t elmtno; /* elemnt index */ + hsize_t curr_pos = 0; + unsigned int region_flags; /* buffer extent flags */ + hsize_t numelem; + hsize_t numindex; + unsigned indx; + unsigned jndx; + hbool_t past_catch = FALSE; + size_t type_size; + hid_t mem_space = H5I_INVALID_HID; + hid_t sid1 = H5I_INVALID_HID; h5tools_context_t ctx; - void *region_buf = NULL; - int ret_value = 0; + void * region_buf = NULL; + int ret_value = 0; HDassert(info); HDassert(cur_ctx); @@ -516,56 +521,56 @@ h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_for H5TOOLS_START_DEBUG(""); - if((type_size = H5Tget_size(type_id)) == 0) + if ((type_size = H5Tget_size(type_id)) == 0) H5TOOLS_THROW(FAIL, "H5Tget_size failed"); /* Get the dataspace of the dataset */ - if((sid1 = H5Dget_space(region_id)) < 0) + if ((sid1 = H5Dget_space(region_id)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed"); /* Allocate space for the dimension array */ - if((dims1 = (hsize_t *) HDmalloc((size_t)(sizeof(hsize_t) * ndims))) == NULL) + if ((dims1 = (hsize_t *)HDmalloc((size_t)(sizeof(hsize_t) * ndims))) == NULL) H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for dims"); /* find the dimensions of each data space from the block coordinates */ numelem = 1; for (jndx = 0; jndx < ndims; jndx++) { dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1; - numelem = dims1[jndx] * numelem; + numelem = dims1[jndx] * numelem; } /* Create dataspace for reading buffer */ - if((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0) + if ((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Screate_simple failed"); - if((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL) + if ((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL) H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate region buffer"); /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ /* 1 2 n 1 2 n */ - if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) + if ((start = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL) H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for start"); - if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) + if ((count = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL) H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for count"); - curr_pos = 0; - ctx.indent_level = cur_ctx->indent_level; - ctx.cur_column = cur_ctx->cur_column; + curr_pos = 0; + ctx.indent_level = cur_ctx->indent_level; + ctx.cur_column = cur_ctx->cur_column; ctx.prev_multiline = cur_ctx->prev_multiline; - ctx.ndims = ndims; + ctx.ndims = ndims; for (blkndx = 0; blkndx < nblocks; blkndx++) { ctx.need_prefix = TRUE; - ctx.cur_elmt = 0; + ctx.cur_elmt = 0; for (indx = 0; indx < ndims; indx++) { start[indx] = ptdata[indx + blkndx * ndims * 2]; count[indx] = dims1[indx]; } - if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) { - if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) { + if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) { + if (H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) { ctx.indent_level++; - if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { + if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { /* assume entire data space to be printed */ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx); @@ -581,9 +586,9 @@ h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_for for (indx = 0; indx < (unsigned)ctx.ndims; indx++) ctx.p_max_idx[indx] = dims1[indx]; - curr_pos = 0; - ctx.sm_pos = blkndx * 2 * ndims; - ctx.size_last_dim = dims1[ndims-1]; + curr_pos = 0; + ctx.sm_pos = blkndx * 2 * ndims; + ctx.size_last_dim = dims1[ndims - 1]; h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0); @@ -595,16 +600,16 @@ h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_for h5tools_str_append(buffer, "%s", numindex ? OPTIONAL_LINE_BREAK "" : ""); h5tools_str_sprint(buffer, info, region_id, type_id, - ((char*)region_buf + numindex * type_size), &ctx); + ((char *)region_buf + numindex * type_size), &ctx); if (numindex + 1 < numelem || (region_flags & END_OF_DATA) == 0) h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ",")); dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, - ncols, ptdata, numindex, elmtno); + ncols, ptdata, numindex, elmtno); /* Render the region data element end */ - if(FALSE == dimension_break) + if (FALSE == dimension_break) elmtno = 0; } /* end for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) */ } @@ -629,11 +634,11 @@ done: HDfree(region_buf); HDfree(dims1); - if(H5Sclose(mem_space) < 0) + if (H5Sclose(mem_space) < 0) H5TOOLS_ERROR(FAIL, "H5Sclose failed"); - if(H5Sclose(sid1) < 0) + if (H5Sclose(sid1) < 0) H5TOOLS_ERROR(FAIL, "H5Sclose failed"); -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; @@ -663,45 +668,44 @@ CATCH *------------------------------------------------------------------------- */ hbool_t -h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, /* in,out */ - h5tools_str_t *buffer, /* string into which to render */ - hsize_t *curr_pos, /* total data element position */ - size_t ncols, hsize_t region_elmt_counter, /* element counter */ - hsize_t elmt_counter) +h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, FILE *stream, + const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */ + h5tools_str_t *buffer, /* string into which to render */ + hsize_t * curr_pos, /* total data element position */ + size_t ncols, hsize_t region_elmt_counter, /* element counter */ + hsize_t elmt_counter) { - hbool_t dimension_break = TRUE; - hssize_t snblocks; - hsize_t nblocks; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - int sndims; - unsigned ndims; - hsize_t indx; - hid_t dtype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ - hbool_t past_catch = FALSE; - hbool_t ret_value = TRUE; + hbool_t dimension_break = TRUE; + hssize_t snblocks; + hsize_t nblocks; + hsize_t alloc_size; + hsize_t * ptdata = NULL; + int sndims; + unsigned ndims; + hsize_t indx; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; HDassert(info); HDassert(ctx); HDassert(buffer); H5TOOLS_START_DEBUG(""); - outputformat = *info; + outputformat = *info; outputformat.idx_fmt = ""; outputformat.idx_n_fmt = ""; outputformat.idx_sep = ""; outputformat.line_pre = ""; - if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) + if ((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) H5TOOLS_THROW(dimension_break, "H5Sget_select_hyper_nblocks failed"); nblocks = (hsize_t)snblocks; /* Print block information */ - if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) + if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) H5TOOLS_THROW(dimension_break, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; @@ -711,7 +715,8 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, h5tools_str_reset(buffer); h5tools_str_append(buffer, " {"); - dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, + region_elmt_counter, elmt_counter); /* Render the region { element end */ ctx->indent_level++; @@ -722,46 +727,46 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, h5tools_str_append(buffer, "REGION_TYPE BLOCK "); alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); - HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ - if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) + HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ + if ((ptdata = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) H5TOOLS_GOTO_ERROR(dimension_break, "Could not allocate buffer for ptdata"); - if(H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0) + if (H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Rget_select_hyper_blocklist failed"); - for(indx = 0; indx < nblocks; indx++) { + for (indx = 0; indx < nblocks; indx++) { unsigned loop_indx; - h5tools_str_append(buffer, outputformat.dset_blockformat_pre, - indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)indx); + h5tools_str_append(buffer, outputformat.dset_blockformat_pre, indx ? "," OPTIONAL_LINE_BREAK " " : "", + (unsigned long)indx); /* Start coordinates and opposite corner */ for (loop_indx = 0; loop_indx < ndims; loop_indx++) h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, loop_indx ? "," : "(", - ptdata[indx * 2 * ndims + loop_indx]); + ptdata[indx * 2 * ndims + loop_indx]); for (loop_indx = 0; loop_indx < ndims; loop_indx++) h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, loop_indx ? "," : ")-(", - ptdata[indx * 2 * ndims + loop_indx + ndims]); + ptdata[indx * 2 * ndims + loop_indx + ndims]); h5tools_str_append(buffer, ")"); } /* end for (indx = 0; indx < nblocks; indx++) */ - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region datatype info and indices element end */ ctx->need_prefix = TRUE; - if((dtype = H5Dget_type(region_id)) < 0) + if ((dtype = H5Dget_type(region_id)) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Dget_type failed"); - if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed"); /* Render the datatype element begin */ h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s %s ", - h5tools_dump_header_format->datatypebegin, - h5tools_dump_header_format->datatypeblockbegin); + h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin, + h5tools_dump_header_format->datatypeblockbegin); ctx->indent_level++; h5tools_print_datatype(stream, buffer, info, ctx, dtype, TRUE); @@ -775,7 +780,8 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, if (HDstrlen(h5tools_dump_header_format->datatypeend)) h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the datatype element end */ ctx->need_prefix = TRUE; @@ -794,7 +800,8 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, if (HDstrlen(h5tools_dump_header_format->dataspaceend)) h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the dataspace element end */ if (region_output) { @@ -802,24 +809,25 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, /* Render the databegin element begin */ h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s %s", - h5tools_dump_header_format->databegin, - h5tools_dump_header_format->datablockbegin); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->databegin, + h5tools_dump_header_format->datablockbegin); + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, + region_elmt_counter, elmt_counter); /* Render the databegin element end */ ctx->need_prefix = TRUE; - h5tools_print_region_data_blocks(region_id, rawdatastream, info, ctx, buffer, ncols, ndims, type_id, nblocks, ptdata); + h5tools_print_region_data_blocks(region_id, rawdatastream, info, ctx, buffer, ncols, ndims, type_id, + nblocks, ptdata); } done: HDfree(ptdata); - if(type_id > 0 && H5Tclose(type_id) < 0) + if (type_id > 0 && H5Tclose(type_id) < 0) H5TOOLS_ERROR(dimension_break, "H5Tclose failed"); - if(dtype > 0 && H5Tclose(dtype) < 0) + if (dtype > 0 && H5Tclose(dtype) < 0) H5TOOLS_ERROR(dimension_break, "H5Tclose failed"); if (region_output) { @@ -827,16 +835,16 @@ done: /* Render the dataend element begin */ h5tools_str_reset(buffer); - if(HDstrlen(h5tools_dump_header_format->datablockend)) { + if (HDstrlen(h5tools_dump_header_format->datablockend)) { h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datablockend); - if(HDstrlen(h5tools_dump_header_format->dataend)) + if (HDstrlen(h5tools_dump_header_format->dataend)) h5tools_str_append(buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->dataend)) + if (HDstrlen(h5tools_dump_header_format->dataend)) h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataend); - dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, - ncols, region_elmt_counter, elmt_counter); + dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, + region_elmt_counter, elmt_counter); /* Render the dataend element end */ } @@ -846,12 +854,13 @@ done: /* Render the region } element begin */ h5tools_str_reset(buffer); h5tools_str_append(buffer, "}"); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region } element end */ H5_LEAVE(dimension_break) -CATCH + CATCH H5TOOLS_ENDDEBUG(""); @@ -877,25 +886,25 @@ CATCH *------------------------------------------------------------------------- */ static int -h5tools_print_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, - h5tools_str_t *buffer, size_t ncols, - unsigned ndims, hid_t type_id, hsize_t npoints, hsize_t *ptdata) +h5tools_print_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, + const h5tool_format_t *info, h5tools_context_t *cur_ctx, + h5tools_str_t *buffer, size_t ncols, unsigned ndims, hid_t type_id, + hsize_t npoints, hsize_t *ptdata) { - hbool_t dimension_break = TRUE; - hsize_t *dims1 = NULL; - hsize_t elmtno; /* elemnt index */ - hsize_t curr_pos = 0; - hsize_t total_size[H5S_MAX_RANK]; - hsize_t jndx; - unsigned indx; - size_t type_size; - unsigned int region_flags; /* buffer extent flags */ - hid_t mem_space = H5I_INVALID_HID; - void *region_buf = NULL; + hbool_t dimension_break = TRUE; + hsize_t * dims1 = NULL; + hsize_t elmtno; /* elemnt index */ + hsize_t curr_pos = 0; + hsize_t total_size[H5S_MAX_RANK]; + hsize_t jndx; + unsigned indx; + size_t type_size; + unsigned int region_flags; /* buffer extent flags */ + hid_t mem_space = H5I_INVALID_HID; + void * region_buf = NULL; h5tools_context_t ctx; - hbool_t past_catch = FALSE; - int ret_value = 0; + hbool_t past_catch = FALSE; + int ret_value = 0; HDassert(info); HDassert(cur_ctx); @@ -907,38 +916,38 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, HDmemset(&ctx, 0, sizeof(ctx)); /* Allocate space for the dimension array */ - if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) + if ((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL) H5TOOLS_THROW((-1), "Could not allocate buffer for dims"); dims1[0] = npoints; /* Create dataspace for reading buffer */ - if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) + if ((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) H5TOOLS_THROW((-1), "H5Screate_simple failed"); - if((type_size = H5Tget_size(type_id)) == 0) + if ((type_size = H5Tget_size(type_id)) == 0) H5TOOLS_THROW((-1), "H5Tget_size failed"); - if((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL) + if ((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL) H5TOOLS_THROW((-1), "Could not allocate buffer for region"); - curr_pos = 0; - ctx.indent_level = cur_ctx->indent_level; - ctx.cur_column = cur_ctx->cur_column; + curr_pos = 0; + ctx.indent_level = cur_ctx->indent_level; + ctx.cur_column = cur_ctx->cur_column; ctx.prev_multiline = cur_ctx->prev_multiline; - ctx.ndims = ndims; + ctx.ndims = ndims; - if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) + if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); H5TOOLS_DEBUG("data render start:%ld", npoints); elmtno = 0; for (jndx = 0; jndx < npoints; jndx++, elmtno++) { ctx.need_prefix = TRUE; - ctx.cur_elmt = 0; /* points are always 0 */ + ctx.cur_elmt = 0; /* points are always 0 */ ctx.indent_level++; - if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { + if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { /* assume entire data space to be printed */ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx); @@ -956,23 +965,23 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, else ctx.size_last_dim = 0; - curr_pos = 0; /* points requires constant 0 */ + curr_pos = 0; /* points requires constant 0 */ h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0); /* Render the point element begin */ h5tools_str_reset(buffer); h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : ""); - h5tools_str_sprint(buffer, info, region_id, type_id, - ((char*)region_buf + jndx * type_size), &ctx); + h5tools_str_sprint(buffer, info, region_id, type_id, ((char *)region_buf + jndx * type_size), + &ctx); if (jndx + 1 < npoints || (region_flags & END_OF_DATA) == 0) h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ",")); - dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, - ncols, ptdata, (hsize_t)0, elmtno); + dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, ncols, + ptdata, (hsize_t)0, elmtno); /* Render the point element end */ - if(FALSE == dimension_break) + if (FALSE == dimension_break) elmtno = 0; } else { @@ -983,10 +992,10 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, done: HDfree(region_buf); -CATCH + CATCH HDfree(dims1); - if(H5Sclose(mem_space) < 0) + if (H5Sclose(mem_space) < 0) H5TOOLS_ERROR((-1), "H5Sclose failed"); H5TOOLS_ENDDEBUG(""); @@ -1018,42 +1027,42 @@ CATCH *------------------------------------------------------------------------- */ hbool_t -h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, - hsize_t elmt_counter) +h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, + const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, + hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, + hsize_t elmt_counter) { - hbool_t dimension_break = TRUE; - hssize_t snpoints; - hsize_t npoints; - hsize_t alloc_size; - hsize_t *ptdata; - int sndims; - unsigned ndims; - hsize_t indx; - hid_t dtype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ - hbool_t past_catch = FALSE; - hbool_t ret_value = TRUE; + hbool_t dimension_break = TRUE; + hssize_t snpoints; + hsize_t npoints; + hsize_t alloc_size; + hsize_t * ptdata; + int sndims; + unsigned ndims; + hsize_t indx; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; HDassert(info); HDassert(ctx); HDassert(buffer); H5TOOLS_START_DEBUG(""); - outputformat = *info; + outputformat = *info; outputformat.idx_fmt = ""; outputformat.idx_n_fmt = ""; outputformat.idx_sep = ""; outputformat.line_pre = ""; - if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0) + if ((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0) H5TOOLS_THROW(dimension_break, "H5Sget_select_elem_npoints failed"); npoints = (hsize_t)snpoints; /* Allocate space for the dimension array */ - if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) + if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) H5TOOLS_THROW(dimension_break, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; @@ -1063,7 +1072,8 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, h5tools_str_reset(buffer); h5tools_str_append(buffer, "{"); - dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, + region_elmt_counter, elmt_counter); /* Render the region { element end */ ctx->indent_level++; @@ -1074,41 +1084,41 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, h5tools_str_append(buffer, "REGION_TYPE POINT "); alloc_size = npoints * ndims * sizeof(ptdata[0]); - HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ - if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size))) + HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ + if (NULL == (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) H5TOOLS_GOTO_ERROR(dimension_break, "Could not allocate buffer for ptdata"); - if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, npoints, ptdata) < 0) + if (H5Sget_select_elem_pointlist(region_space, (hsize_t)0, npoints, ptdata) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Sget_select_elem_pointlist failed"); for (indx = 0; indx < npoints; indx++) { unsigned loop_indx; - h5tools_str_append(buffer, outputformat.dset_ptformat_pre, - indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) indx); + h5tools_str_append(buffer, outputformat.dset_ptformat_pre, indx ? "," OPTIONAL_LINE_BREAK " " : "", + (unsigned long)indx); for (loop_indx = 0; loop_indx < ndims; loop_indx++) h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, loop_indx ? "," : "(", - ptdata[indx * ndims + loop_indx]); + ptdata[indx * ndims + loop_indx]); h5tools_str_append(buffer, ")"); } /* end for (indx = 0; indx < npoints; indx++) */ - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region datatype info and indices element end */ ctx->need_prefix = TRUE; - if((dtype = H5Dget_type(region_id)) < 0) + if ((dtype = H5Dget_type(region_id)) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Dget_type failed"); - if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed"); /* Render the datatype element begin */ h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s %s ", - h5tools_dump_header_format->datatypebegin, - h5tools_dump_header_format->datatypeblockbegin); + h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin, + h5tools_dump_header_format->datatypeblockbegin); ctx->indent_level++; h5tools_print_datatype(stream, buffer, info, ctx, dtype, TRUE); @@ -1122,7 +1132,8 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, if (HDstrlen(h5tools_dump_header_format->datatypeend)) h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the datatype element end */ ctx->need_prefix = TRUE; @@ -1141,7 +1152,8 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, if (HDstrlen(h5tools_dump_header_format->dataspaceend)) h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the dataspace element end */ if (region_output) { @@ -1150,24 +1162,25 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, /* Render the databegin element begin */ h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s %s", - h5tools_dump_header_format->databegin, - h5tools_dump_header_format->datablockbegin); + h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->databegin, + h5tools_dump_header_format->datablockbegin); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, + region_elmt_counter, elmt_counter); ctx->need_prefix = TRUE; - h5tools_print_region_data_points(region_space, region_id, rawdatastream, info, ctx, buffer, ncols, ndims, type_id, npoints, ptdata); + h5tools_print_region_data_points(region_space, region_id, rawdatastream, info, ctx, buffer, ncols, + ndims, type_id, npoints, ptdata); } done: HDfree(ptdata); - if(type_id > 0 && H5Tclose(type_id) < 0) + if (type_id > 0 && H5Tclose(type_id) < 0) H5TOOLS_ERROR(dimension_break, "H5Tclose failed"); - if(dtype > 0 && H5Tclose(dtype) < 0) + if (dtype > 0 && H5Tclose(dtype) < 0) H5TOOLS_ERROR(dimension_break, "H5Tclose failed"); if (region_output) { @@ -1175,16 +1188,16 @@ done: /* Render the dataend element begin */ h5tools_str_reset(buffer); - if(HDstrlen(h5tools_dump_header_format->datablockend)) { + if (HDstrlen(h5tools_dump_header_format->datablockend)) { h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datablockend); - if(HDstrlen(h5tools_dump_header_format->dataend)) + if (HDstrlen(h5tools_dump_header_format->dataend)) h5tools_str_append(buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->dataend)) + if (HDstrlen(h5tools_dump_header_format->dataend)) h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataend); - dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, - ncols, region_elmt_counter, elmt_counter); + dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols, + region_elmt_counter, elmt_counter); /* Render the dataend element end*/ } @@ -1194,12 +1207,12 @@ done: /* Render the region } element begin */ h5tools_str_reset(buffer); h5tools_str_append(buffer, "}"); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, - ncols, region_elmt_counter, elmt_counter); + dimension_break = + h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region } element end */ H5_LEAVE(dimension_break) -CATCH + CATCH H5TOOLS_ENDDEBUG(""); @@ -1239,37 +1252,37 @@ CATCH *------------------------------------------------------------------------- */ static herr_t -h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hid_t dset, hid_t p_type, hid_t f_space, hsize_t hyperslab_count, - hsize_t *temp_start, /* start inside offset count loop */ - hsize_t *temp_count, /* count inside offset count loop */ - hsize_t *temp_block, /* block size used in loop */ - hsize_t *temp_stride, /* stride size used in loop */ - hsize_t *total_size, /* total size of dataset */ - unsigned int row_dim) /* index of row_counter dimension */ +h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, + hid_t p_type, hid_t f_space, hsize_t hyperslab_count, + hsize_t * temp_start, /* start inside offset count loop */ + hsize_t * temp_count, /* count inside offset count loop */ + hsize_t * temp_block, /* block size used in loop */ + hsize_t * temp_stride, /* stride size used in loop */ + hsize_t * total_size, /* total size of dataset */ + unsigned int row_dim) /* index of row_counter dimension */ { - size_t i; /* counters */ - size_t j; /* counters */ - hsize_t zero[1] = {0}; /* vector of zeros */ - unsigned int flags; /* buffer extent flags */ - hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */ - hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */ - size_t p_type_nbytes; /* size of memory type */ - hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ - hsize_t sm_nbytes; /* bytes per stripmine */ - hssize_t ssm_nelmts; /* elements per stripmine*/ - hsize_t sm_nelmts; /* elements per stripmine*/ - unsigned char *sm_buf = NULL; /* buffer for raw data */ - hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */ - hsize_t size_row_block; /* size for blocks along rows */ - hsize_t row_counter = 0; - hbool_t past_catch = FALSE; + size_t i; /* counters */ + size_t j; /* counters */ + hsize_t zero[1] = {0}; /* vector of zeros */ + unsigned int flags; /* buffer extent flags */ + hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */ + hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */ + size_t p_type_nbytes; /* size of memory type */ + hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ + hsize_t sm_nbytes; /* bytes per stripmine */ + hssize_t ssm_nelmts; /* elements per stripmine*/ + hsize_t sm_nelmts; /* elements per stripmine*/ + unsigned char *sm_buf = NULL; /* buffer for raw data */ + hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */ + hsize_t size_row_block; /* size for blocks along rows */ + hsize_t row_counter = 0; + hbool_t past_catch = FALSE; /* VL data special information */ - unsigned int vl_data = 0; /* contains VL datatypes */ - herr_t ret_value = SUCCEED; + unsigned int vl_data = 0; /* contains VL datatypes */ + herr_t ret_value = SUCCEED; H5TOOLS_START_DEBUG(""); - if ((size_t) ctx->ndims > NELMTS(sm_size)) + if ((size_t)ctx->ndims > NELMTS(sm_size)) H5TOOLS_THROW(FAIL, "ndims and sm_size comparision failed"); size_row_block = ctx->sset->block.data[row_dim]; @@ -1282,9 +1295,8 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c for (; hyperslab_count > 0; temp_start[row_dim] += temp_stride[row_dim], hyperslab_count--) { /* jump rows if size of block exceeded cases where block > 1 only and stride > block */ - if (size_row_block > 1 - && row_counter == size_row_block - && ctx->sset->stride.data[row_dim] > ctx->sset->block.data[row_dim]) { + if (size_row_block > 1 && row_counter == size_row_block && + ctx->sset->stride.data[row_dim] > ctx->sset->block.data[row_dim]) { hsize_t increase_rows = ctx->sset->stride.data[row_dim] - ctx->sset->block.data[row_dim]; temp_start[row_dim] += increase_rows; @@ -1294,10 +1306,10 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c row_counter++; /* calculate the potential number of elements we're going to print */ - if(H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0) + if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0) H5TOOLS_THROW(FAIL, "H5Sselect_hyperslab failed"); - if((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0) + if ((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0) H5TOOLS_THROW(FAIL, "H5Sget_select_npoints failed"); sm_nelmts = (hsize_t)ssm_nelmts; @@ -1306,7 +1318,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c * determine the strip mine size and allocate a buffer. the strip mine is * a hyperslab whose size is manageable. */ - if((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0) + if ((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0) H5TOOLS_THROW(FAIL, "H5Tget_size failed"); if (ctx->ndims > 0) @@ -1319,18 +1331,18 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c HDassert(sm_nbytes > 0); } - HDassert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/ - if(NULL == (sm_buf = (unsigned char *)HDmalloc((size_t) sm_nelmts * p_type_nbytes))) + HDassert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/ + if (NULL == (sm_buf = (unsigned char *)HDmalloc((size_t)sm_nelmts * p_type_nbytes))) H5TOOLS_THROW(FAIL, "Could not allocate buffer for strip-mine"); - if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0) + if ((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0) H5TOOLS_THROW(FAIL, "H5Screate_simple failed"); - if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &sm_nelmts, NULL) < 0) + if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &sm_nelmts, NULL) < 0) H5TOOLS_THROW(FAIL, "H5Sselect_hyperslab failed"); /* read the data */ - if(H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) + if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) H5TOOLS_THROW(FAIL, "H5Dread failed"); /* print the data */ @@ -1344,32 +1356,31 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c /* print array indices. get the lower bound of the hyperslab and calculate the element position at the start of hyperslab */ - if(H5Sget_select_bounds(f_space, low, high) < 0) + if (H5Sget_select_bounds(f_space, low, high) < 0) H5TOOLS_THROW(FAIL, "H5Sget_select_bounds failed"); /* initialize the current stripmine position; this is necessary to print the array indices */ ctx->sm_pos = 0; - for (i = 0; i < (size_t) ctx->ndims - 1; i++) { + for (i = 0; i < (size_t)ctx->ndims - 1; i++) { hsize_t offset = 1; /* accumulation of the previous dimensions */ - for (j = i + 1; j < (size_t) ctx->ndims; j++) + for (j = i + 1; j < (size_t)ctx->ndims; j++) offset *= total_size[j]; ctx->sm_pos += low[i] * offset; } ctx->sm_pos += low[ctx->ndims - 1]; - ctx->need_prefix = TRUE; - if(h5tools_dump_simple_data(stream, info, ctx, dset, flags, sm_nelmts, p_type, sm_buf) < 0) + if (h5tools_dump_simple_data(stream, info, ctx, dset, flags, sm_nelmts, p_type, sm_buf) < 0) H5TOOLS_THROW(FAIL, "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ if (vl_data) H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf); - if(H5Sclose(sm_space) < 0) + if (H5Sclose(sm_space) < 0) H5TOOLS_THROW(FAIL, "H5Sclose failed"); - if(sm_buf) + if (sm_buf) HDfree(sm_buf); sm_buf = NULL; } @@ -1380,8 +1391,8 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c } /* hyperslab_count loop */ -CATCH - if(sm_buf) + CATCH + if (sm_buf) HDfree(sm_buf); H5TOOLS_ENDDEBUG(""); @@ -1421,22 +1432,22 @@ CATCH *------------------------------------------------------------------------- */ static herr_t -h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hid_t dset, hid_t p_type, hid_t f_space, hsize_t *total_size) +h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, + hid_t p_type, hid_t f_space, hsize_t *total_size) { - size_t i; /* counters */ - hsize_t n; /* counters */ - hsize_t count; /* hyperslab count */ - hsize_t outer_count; /* offset count */ - unsigned int row_dim; /* index of row_counter dimension */ - int current_outer_dim; /* dimension for start */ - hsize_t temp_start[H5S_MAX_RANK];/* temporary start inside offset count loop */ - hsize_t max_start[H5S_MAX_RANK]; /* maximum start inside offset count loop */ - hsize_t temp_count[H5S_MAX_RANK];/* temporary count inside offset count loop */ - hsize_t temp_block[H5S_MAX_RANK];/* temporary block size used in loop */ - hsize_t temp_stride[H5S_MAX_RANK];/* temporary stride size used in loop */ - int reset_dim; - herr_t ret_value = SUCCEED; + size_t i; /* counters */ + hsize_t n; /* counters */ + hsize_t count; /* hyperslab count */ + hsize_t outer_count; /* offset count */ + unsigned int row_dim; /* index of row_counter dimension */ + int current_outer_dim; /* dimension for start */ + hsize_t temp_start[H5S_MAX_RANK]; /* temporary start inside offset count loop */ + hsize_t max_start[H5S_MAX_RANK]; /* maximum start inside offset count loop */ + hsize_t temp_count[H5S_MAX_RANK]; /* temporary count inside offset count loop */ + hsize_t temp_block[H5S_MAX_RANK]; /* temporary block size used in loop */ + hsize_t temp_stride[H5S_MAX_RANK]; /* temporary stride size used in loop */ + int reset_dim; + herr_t ret_value = SUCCEED; if (ctx->ndims == 1) row_dim = 0; @@ -1446,23 +1457,23 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools /* get the offset count */ outer_count = 1; if (ctx->ndims > 2) - for (i = 0; i < (size_t) ctx->ndims - 2; i++) { + for (i = 0; i < (size_t)ctx->ndims - 2; i++) { /* block size is handled by containing h5tools_print_simple_subset call */ outer_count = outer_count * ctx->sset->count.data[i]; } /* initialize temporary start, count and maximum start */ for (i = 0; i < ctx->ndims; i++) { - temp_start[i] = ctx->sset->start.data[i]; - temp_count[i] = ctx->sset->count.data[i]; - temp_block[i] = ctx->sset->block.data[i]; + temp_start[i] = ctx->sset->start.data[i]; + temp_count[i] = ctx->sset->count.data[i]; + temp_block[i] = ctx->sset->block.data[i]; temp_stride[i] = ctx->sset->stride.data[i]; - max_start[i] = 0; + max_start[i] = 0; } if (ctx->ndims > 2) { - for (i = 0; i < (size_t) ctx->ndims - 2; i++) { - max_start[i] = temp_start[i] + ctx->sset->count.data[i] * ctx->sset->stride.data[i]; + for (i = 0; i < (size_t)ctx->ndims - 2; i++) { + max_start[i] = temp_start[i] + ctx->sset->count.data[i] * ctx->sset->stride.data[i]; temp_count[i] = 1; } } @@ -1488,9 +1499,8 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools count = 1; } - h5tools_print_simple_subset(stream, info, ctx, dset, p_type, - f_space, count, temp_start, temp_count, - temp_block, temp_stride, total_size, row_dim); + h5tools_print_simple_subset(stream, info, ctx, dset, p_type, f_space, count, temp_start, temp_count, + temp_block, temp_stride, total_size, row_dim); if (ctx->ndims > 2) { /* dimension for start */ @@ -1561,24 +1571,25 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools *------------------------------------------------------------------------- */ static herr_t -h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type) +h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, + hid_t p_type) { int sndims; - hid_t f_space = H5I_INVALID_HID; /* file data space */ - hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ + hid_t f_space = H5I_INVALID_HID; /* file data space */ + hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ hbool_t past_catch = FALSE; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; H5TOOLS_START_DEBUG(""); - if((f_space = H5Dget_space(dset)) < 0) + if ((f_space = H5Dget_space(dset)) < 0) H5TOOLS_THROW(FAIL, "H5Dget_space failed"); - if((sndims = H5Sget_simple_extent_ndims(f_space)) < 0) + if ((sndims = H5Sget_simple_extent_ndims(f_space)) < 0) H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_ndims failed"); ctx->ndims = (unsigned)sndims; /* assume entire data space to be printed */ - if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0) + if (H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0) H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_dims failed"); init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx); @@ -1589,8 +1600,8 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_co h5tools_display_simple_subset(stream, info, ctx, dset, p_type, f_space, total_size); -CATCH - if(f_space >= 0 && H5Sclose(f_space) < 0) + CATCH + if (f_space >= 0 && H5Sclose(f_space) < 0) H5TOOLS_THROW(FAIL, "H5Sclose failed"); H5TOOLS_ENDDEBUG(""); @@ -1613,44 +1624,45 @@ CATCH *------------------------------------------------------------------------- */ static int -h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type) +h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, + hid_t p_type) { - hid_t f_space = H5I_INVALID_HID; /* file data space */ - hsize_t elmtno; /* counter */ - size_t i = 0; /* counter */ - int sndims; /* rank of dataspace */ - int carry; /* counter carry value */ - hsize_t zero[8]; /* vector of zeros */ - unsigned int flags; /* buffer extent flags */ - hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ - hbool_t past_catch = FALSE; + hid_t f_space = H5I_INVALID_HID; /* file data space */ + hsize_t elmtno; /* counter */ + size_t i = 0; /* counter */ + int sndims; /* rank of dataspace */ + int carry; /* counter carry value */ + hsize_t zero[8]; /* vector of zeros */ + unsigned int flags; /* buffer extent flags */ + hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ + hbool_t past_catch = FALSE; /* Print info */ - size_t p_type_nbytes; /* size of memory type */ - hsize_t p_nelmts; /* total selected elmts */ + size_t p_type_nbytes; /* size of memory type */ + hsize_t p_nelmts; /* total selected elmts */ /* Stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ - hsize_t sm_nbytes; /* bytes per stripmine */ - hsize_t sm_nelmts; /* elements per stripmine*/ - unsigned char *sm_buf = NULL; /* buffer for raw data */ - hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */ + hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ + hsize_t sm_nbytes; /* bytes per stripmine */ + hsize_t sm_nelmts; /* elements per stripmine*/ + unsigned char *sm_buf = NULL; /* buffer for raw data */ + hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */ /* Hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ - hsize_t hs_nelmts; /* elements in request */ + hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_nelmts; /* elements in request */ /* VL data special information */ - unsigned int vl_data = 0; /* contains VL datatypes */ - int ret_value = 0; + unsigned int vl_data = 0; /* contains VL datatypes */ + int ret_value = 0; H5TOOLS_START_DEBUG(""); if (H5I_INVALID_HID == (f_space = H5Dget_space(dset))) H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); sndims = H5Sget_simple_extent_ndims(f_space); - if(sndims < 0) + if (sndims < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_simple_extent_ndims failed"); ctx->ndims = (unsigned)sndims; H5TOOLS_DEBUG("sndims:%d", sndims); @@ -1695,7 +1707,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont sm_nbytes *= sm_size[i - 1]; } } - if(!sm_nbytes) + if (!sm_nbytes) goto done; HDassert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/ @@ -1703,7 +1715,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont H5TOOLS_DEBUG("stripmine size:%ld", sm_nbytes); sm_nelmts = sm_nbytes / p_type_nbytes; - sm_space = H5Screate_simple(1, &sm_nelmts, NULL); + sm_space = H5Screate_simple(1, &sm_nelmts, NULL); H5TOOLS_DEBUG("sm_nelmts size:%ld", sm_nelmts); H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims); @@ -1717,7 +1729,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont /* Calculate the hyperslab size */ if (ctx->ndims > 0) { for (i = 0, hs_nelmts = 1; i < ctx->ndims; i++) { - hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]); + hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]); ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i]; hs_nelmts *= hs_size[i]; } @@ -1746,7 +1758,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont indices */ ctx->sm_pos = elmtno; - if(h5tools_dump_simple_data(stream, info, ctx, dset, flags, hs_nelmts, p_type, sm_buf) < 0) + if (h5tools_dump_simple_data(stream, info, ctx, dset, flags, hs_nelmts, p_type, sm_buf) < 0) H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ @@ -1775,11 +1787,11 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont } /* if (NULL != (sm_buf...)) */ done: - if(sm_space >= 0 && H5Sclose(sm_space) < 0) + if (sm_space >= 0 && H5Sclose(sm_space) < 0) H5TOOLS_ERROR((-1), "H5Sclose failed"); - if(f_space >= 0 && H5Sclose(f_space) < 0) + if (f_space >= 0 && H5Sclose(f_space) < 0) H5TOOLS_ERROR((-1), "H5Sclose failed"); -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; } @@ -1795,33 +1807,33 @@ CATCH *------------------------------------------------------------------------- */ static int -h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hid_t attr_id, hid_t p_type) +h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id, + hid_t p_type) { - hid_t f_space = H5I_INVALID_HID; /* file data space */ + hid_t f_space = H5I_INVALID_HID; /* file data space */ hsize_t alloc_size; - int sndims; /* rank of dataspace */ - unsigned i; /* counters */ - hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ - hsize_t p_nelmts; /* total selected elmts */ + int sndims; /* rank of dataspace */ + unsigned i; /* counters */ + hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ + hsize_t p_nelmts; /* total selected elmts */ hbool_t past_catch = FALSE; - unsigned char *buf = NULL; /* buffer for raw data */ - int ret_value = 0; + unsigned char *buf = NULL; /* buffer for raw data */ + int ret_value = 0; /* VL data special information */ - unsigned int vl_data = 0; /* contains VL datatypes */ + unsigned int vl_data = 0; /* contains VL datatypes */ H5TOOLS_START_DEBUG(""); if (H5I_INVALID_HID == (f_space = H5Aget_space(attr_id))) H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); sndims = H5Sget_simple_extent_ndims(f_space); - if(sndims < 0) + if (sndims < 0) H5TOOLS_THROW((-1), "H5Dget_simple_extent_ndims failed"); ctx->ndims = (unsigned)sndims; H5TOOLS_DEBUG("sndims:%d", sndims); - if ((size_t) ctx->ndims > NELMTS(ctx->p_min_idx)) + if ((size_t)ctx->ndims > NELMTS(ctx->p_min_idx)) H5TOOLS_THROW((-1), "ctx->ndims > NELMTS(ctx->p_min_idx) failed"); /* Assume entire data space to be printed */ @@ -1854,7 +1866,8 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte H5TOOLS_DEBUG("Read the data"); /* Read the data */ if (H5Aread(attr_id, p_type, buf) >= 0) { - if(h5tools_dump_simple_data(stream, info, ctx, attr_id, START_OF_DATA | END_OF_DATA, p_nelmts, p_type, buf) < 0) + if (h5tools_dump_simple_data(stream, info, ctx, attr_id, START_OF_DATA | END_OF_DATA, p_nelmts, + p_type, buf) < 0) H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ @@ -1866,9 +1879,9 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte HDfree(buf); } /* if (NULL != (buf...)) */ done: - if(f_space >= 0 && H5Sclose(f_space) < 0) + if (f_space >= 0 && H5Sclose(f_space) < 0) H5TOOLS_ERROR((-1), "H5Sclose failed"); -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; } @@ -1894,12 +1907,12 @@ CATCH int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset) { - hid_t f_space = H5I_INVALID_HID; - hid_t p_type = H5I_INVALID_HID; - hid_t f_type = H5I_INVALID_HID; - H5S_class_t space_type; + hid_t f_space = H5I_INVALID_HID; + hid_t p_type = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; + H5S_class_t space_type; h5tool_format_t info_dflt; - int ret_value = 0; + int ret_value = 0; H5TOOLS_START_DEBUG(""); /* Use default values */ @@ -1936,7 +1949,7 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t * /* Print the data */ if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) { - if(!ctx->sset) + if (!ctx->sset) ret_value = h5tools_dump_simple_dset(rawdatastream, info, ctx, dset, p_type); else ret_value = h5tools_dump_simple_subset(rawdatastream, info, ctx, dset, p_type); @@ -1971,11 +1984,11 @@ done: int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id) { - hid_t f_space = H5I_INVALID_HID; - hid_t p_type = H5I_INVALID_HID; - hid_t f_type = H5I_INVALID_HID; - h5tool_format_t info_dflt; - int ret_value = 0; + hid_t f_space = H5I_INVALID_HID; + hid_t p_type = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; + h5tool_format_t info_dflt; + int ret_value = 0; H5TOOLS_START_DEBUG(""); /* Use default values */ @@ -2040,48 +2053,48 @@ done: */ int h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, - h5tools_context_t *ctx, hid_t type, int object_search) + h5tools_context_t *ctx, hid_t type, int object_search) { - char *mname; - hid_t mtype = H5I_INVALID_HID; - hid_t str_type = H5I_INVALID_HID; - hid_t super = H5I_INVALID_HID; - hid_t tmp_type = H5I_INVALID_HID; - int snmembers; - int sndims; - unsigned nmembers; - unsigned i; - size_t size = 0; - size_t ncols = 80; /*available output width */ - hsize_t dims[H5TOOLS_DUMP_MAX_RANK]; - hsize_t curr_pos = 0; /* total data element position */ - H5T_str_t str_pad; - H5T_cset_t cset; - H5T_order_t order; - H5T_class_t type_class; - H5T_sign_t sign; /* sign scheme value */ - htri_t is_vlstr = FALSE; - hbool_t past_catch = FALSE; - const char *sign_s = NULL; /* sign scheme string */ - const char *order_s = NULL; /* byte order string */ - int ret_value = 0; + char * mname; + hid_t mtype = H5I_INVALID_HID; + hid_t str_type = H5I_INVALID_HID; + hid_t super = H5I_INVALID_HID; + hid_t tmp_type = H5I_INVALID_HID; + int snmembers; + int sndims; + unsigned nmembers; + unsigned i; + size_t size = 0; + size_t ncols = 80; /*available output width */ + hsize_t dims[H5TOOLS_DUMP_MAX_RANK]; + hsize_t curr_pos = 0; /* total data element position */ + H5T_str_t str_pad; + H5T_cset_t cset; + H5T_order_t order; + H5T_class_t type_class; + H5T_sign_t sign; /* sign scheme value */ + htri_t is_vlstr = FALSE; + hbool_t past_catch = FALSE; + const char *sign_s = NULL; /* sign scheme string */ + const char *order_s = NULL; /* byte order string */ + int ret_value = 0; H5TOOLS_START_DEBUG(""); - if((type_class = H5Tget_class(type)) < 0) + if ((type_class = H5Tget_class(type)) < 0) H5TOOLS_THROW((-1), "H5Tget_class failed"); if (object_search && H5Tcommitted(type) > 0) { - H5O_info2_t oinfo; - obj_t *obj = NULL; /* Found object */ + H5O_info2_t oinfo; + obj_t * obj = NULL; /* Found object */ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC); obj = search_obj(h5dump_type_table, &oinfo.token); - if(obj) { - if(!obj->recorded) { + if (obj) { + if (!obj->recorded) { char *obj_tok_str = NULL; H5Otoken_to_str(type, &oinfo.token, &obj_tok_str); - h5tools_str_append(buffer,"\"/#%s\"", obj_tok_str); + h5tools_str_append(buffer, "\"/#%s\"", obj_tok_str); H5free_memory(obj_tok_str); } else @@ -2099,524 +2112,535 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ ncols = info->line_ncols; switch (type_class) { - case H5T_INTEGER: - if (H5Tequal(type, H5T_STD_I8BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_I8BE"); - else if (H5Tequal(type, H5T_STD_I8LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_I8LE"); - else if (H5Tequal(type, H5T_STD_I16BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_I16BE"); - else if (H5Tequal(type, H5T_STD_I16LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_I16LE"); - else if (H5Tequal(type, H5T_STD_I32BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_I32BE"); - else if (H5Tequal(type, H5T_STD_I32LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_I32LE"); - else if (H5Tequal(type, H5T_STD_I64BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_I64BE"); - else if (H5Tequal(type, H5T_STD_I64LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_I64LE"); - else if (H5Tequal(type, H5T_STD_U8BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_U8BE"); - else if (H5Tequal(type, H5T_STD_U8LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_U8LE"); - else if (H5Tequal(type, H5T_STD_U16BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_U16BE"); - else if (H5Tequal(type, H5T_STD_U16LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_U16LE"); - else if (H5Tequal(type, H5T_STD_U32BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_U32BE"); - else if (H5Tequal(type, H5T_STD_U32LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_U32LE"); - else if (H5Tequal(type, H5T_STD_U64BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_U64BE"); - else if (H5Tequal(type, H5T_STD_U64LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_U64LE"); - else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_SCHAR"); - else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_UCHAR"); - else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_SHORT"); - else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_USHORT"); - else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_INT"); - else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_UINT"); - else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_LONG"); - else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_ULONG"); - else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_LLONG"); - else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_ULLONG"); - else { + case H5T_INTEGER: + if (H5Tequal(type, H5T_STD_I8BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_I8BE"); + else if (H5Tequal(type, H5T_STD_I8LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_I8LE"); + else if (H5Tequal(type, H5T_STD_I16BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_I16BE"); + else if (H5Tequal(type, H5T_STD_I16LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_I16LE"); + else if (H5Tequal(type, H5T_STD_I32BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_I32BE"); + else if (H5Tequal(type, H5T_STD_I32LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_I32LE"); + else if (H5Tequal(type, H5T_STD_I64BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_I64BE"); + else if (H5Tequal(type, H5T_STD_I64LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_I64LE"); + else if (H5Tequal(type, H5T_STD_U8BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_U8BE"); + else if (H5Tequal(type, H5T_STD_U8LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_U8LE"); + else if (H5Tequal(type, H5T_STD_U16BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_U16BE"); + else if (H5Tequal(type, H5T_STD_U16LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_U16LE"); + else if (H5Tequal(type, H5T_STD_U32BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_U32BE"); + else if (H5Tequal(type, H5T_STD_U32LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_U32LE"); + else if (H5Tequal(type, H5T_STD_U64BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_U64BE"); + else if (H5Tequal(type, H5T_STD_U64LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_U64LE"); + else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_SCHAR"); + else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_UCHAR"); + else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_SHORT"); + else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_USHORT"); + else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_INT"); + else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_UINT"); + else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_LONG"); + else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_ULONG"); + else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_LLONG"); + else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_ULLONG"); + else { - /* byte order */ - if (H5Tget_size(type) > 1) { - order = H5Tget_order(type); - if (H5T_ORDER_LE == order) - order_s = " little-endian"; - else if (H5T_ORDER_BE == order) - order_s = " big-endian"; - else if (H5T_ORDER_VAX == order) - order_s = " mixed-endian"; + /* byte order */ + if (H5Tget_size(type) > 1) { + order = H5Tget_order(type); + if (H5T_ORDER_LE == order) + order_s = " little-endian"; + else if (H5T_ORDER_BE == order) + order_s = " big-endian"; + else if (H5T_ORDER_VAX == order) + order_s = " mixed-endian"; + else + order_s = " unknown-byte-order"; + } else - order_s = " unknown-byte-order"; - } - else - order_s = ""; - - /* sign */ - if ((sign = H5Tget_sign(type)) >= 0) { - if (H5T_SGN_NONE == sign) - sign_s = " unsigned"; - else if (H5T_SGN_2 == sign) - sign_s = ""; + order_s = ""; + + /* sign */ + if ((sign = H5Tget_sign(type)) >= 0) { + if (H5T_SGN_NONE == sign) + sign_s = " unsigned"; + else if (H5T_SGN_2 == sign) + sign_s = ""; + else + sign_s = " unknown-sign"; + } else sign_s = " unknown-sign"; + + /* print size, order, and sign */ + h5tools_str_append(buffer, "%lu-bit%s%s integer", (unsigned long)(8 * H5Tget_size(type)), + order_s, sign_s); } - else - sign_s = " unknown-sign"; + break; - /* print size, order, and sign */ - h5tools_str_append(buffer, "%lu-bit%s%s integer", - (unsigned long) (8 * H5Tget_size(type)), order_s, sign_s); - } - break; - - case H5T_FLOAT: - if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE) - h5tools_str_append(buffer, "H5T_IEEE_F32BE"); - else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE) - h5tools_str_append(buffer, "H5T_IEEE_F32LE"); - else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE) - h5tools_str_append(buffer, "H5T_IEEE_F64BE"); - else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE) - h5tools_str_append(buffer, "H5T_IEEE_F64LE"); - else if (H5Tequal(type, H5T_VAX_F32) == TRUE) - h5tools_str_append(buffer, "H5T_VAX_F32"); - else if (H5Tequal(type, H5T_VAX_F64) == TRUE) - h5tools_str_append(buffer, "H5T_VAX_F64"); - else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_FLOAT"); - else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_DOUBLE"); -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) - h5tools_str_append(buffer, "H5T_NATIVE_LDOUBLE"); + case H5T_FLOAT: + if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE) + h5tools_str_append(buffer, "H5T_IEEE_F32BE"); + else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE) + h5tools_str_append(buffer, "H5T_IEEE_F32LE"); + else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE) + h5tools_str_append(buffer, "H5T_IEEE_F64BE"); + else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE) + h5tools_str_append(buffer, "H5T_IEEE_F64LE"); + else if (H5Tequal(type, H5T_VAX_F32) == TRUE) + h5tools_str_append(buffer, "H5T_VAX_F32"); + else if (H5Tequal(type, H5T_VAX_F64) == TRUE) + h5tools_str_append(buffer, "H5T_VAX_F64"); + else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_FLOAT"); + else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_DOUBLE"); +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) + h5tools_str_append(buffer, "H5T_NATIVE_LDOUBLE"); #endif - else { + else { - /* byte order */ - if (H5Tget_size(type) > 1) { - order = H5Tget_order(type); - if (H5T_ORDER_LE == order) - order_s = " little-endian"; - else if (H5T_ORDER_BE == order) - order_s = " big-endian"; - else if (H5T_ORDER_VAX == order) - order_s = " mixed-endian"; + /* byte order */ + if (H5Tget_size(type) > 1) { + order = H5Tget_order(type); + if (H5T_ORDER_LE == order) + order_s = " little-endian"; + else if (H5T_ORDER_BE == order) + order_s = " big-endian"; + else if (H5T_ORDER_VAX == order) + order_s = " mixed-endian"; + else + order_s = " unknown-byte-order"; + } else - order_s = " unknown-byte-order"; - } - else - order_s = ""; - - /* print size and byte order */ - h5tools_str_append(buffer, "%lu-bit%s floating-point", - (unsigned long) (8 * H5Tget_size(type)), order_s); + order_s = ""; - } - break; - - case H5T_TIME: - h5tools_str_append(buffer, "H5T_TIME: not yet implemented"); - break; - - case H5T_STRING: - /* Make a copy of type in memory in case when TYPE is on disk, the size - * will be bigger than in memory. This makes it easier to compare - * types in memory. */ - tmp_type = H5Tcopy(type); - size = H5Tget_size(tmp_type); - str_pad = H5Tget_strpad(tmp_type); - cset = H5Tget_cset(tmp_type); - is_vlstr = H5Tis_variable_str(tmp_type); - - curr_pos = ctx->cur_column; - h5tools_str_append(buffer, "H5T_STRING %s", h5tools_dump_header_format->strblockbegin); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + /* print size and byte order */ + h5tools_str_append(buffer, "%lu-bit%s floating-point", (unsigned long)(8 * H5Tget_size(type)), + order_s); + } + break; - ctx->indent_level++; + case H5T_TIME: + h5tools_str_append(buffer, "H5T_TIME: not yet implemented"); + break; - ctx->need_prefix = TRUE; + case H5T_STRING: + /* Make a copy of type in memory in case when TYPE is on disk, the size + * will be bigger than in memory. This makes it easier to compare + * types in memory. */ + tmp_type = H5Tcopy(type); + size = H5Tget_size(tmp_type); + str_pad = H5Tget_strpad(tmp_type); + cset = H5Tget_cset(tmp_type); + is_vlstr = H5Tis_variable_str(tmp_type); + + curr_pos = ctx->cur_column; + h5tools_str_append(buffer, "H5T_STRING %s", h5tools_dump_header_format->strblockbegin); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - h5tools_str_reset(buffer); + ctx->indent_level++; - if (is_vlstr) - h5tools_str_append(buffer, "%s H5T_VARIABLE;", STRSIZE); - else - h5tools_str_append(buffer, "%s %d;", STRSIZE, (int) size); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + ctx->need_prefix = TRUE; - ctx->need_prefix = TRUE; + h5tools_str_reset(buffer); - h5tools_str_reset(buffer); + if (is_vlstr) + h5tools_str_append(buffer, "%s H5T_VARIABLE;", STRSIZE); + else + h5tools_str_append(buffer, "%s %d;", STRSIZE, (int)size); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - h5tools_str_append(buffer, "%s ", STRPAD); - switch (str_pad) { - case H5T_STR_NULLTERM: - h5tools_str_append(buffer, "H5T_STR_NULLTERM;"); - break; - case H5T_STR_NULLPAD: - h5tools_str_append(buffer, "H5T_STR_NULLPAD;"); - break; - case H5T_STR_SPACEPAD: - h5tools_str_append(buffer, "H5T_STR_SPACEPAD;"); - break; - case H5T_STR_RESERVED_3: - case H5T_STR_RESERVED_4: - case H5T_STR_RESERVED_5: - case H5T_STR_RESERVED_6: - case H5T_STR_RESERVED_7: - case H5T_STR_RESERVED_8: - case H5T_STR_RESERVED_9: - case H5T_STR_RESERVED_10: - case H5T_STR_RESERVED_11: - case H5T_STR_RESERVED_12: - case H5T_STR_RESERVED_13: - case H5T_STR_RESERVED_14: - case H5T_STR_RESERVED_15: - h5tools_str_append(buffer, "H5T_STR_UNKNOWN;"); - break; - case H5T_STR_ERROR: - h5tools_str_append(buffer, "H5T_STR_ERROR;"); - break; - default: - h5tools_str_append(buffer, "ERROR;"); - break; - } - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + ctx->need_prefix = TRUE; - ctx->need_prefix = TRUE; + h5tools_str_reset(buffer); - h5tools_str_reset(buffer); + h5tools_str_append(buffer, "%s ", STRPAD); + switch (str_pad) { + case H5T_STR_NULLTERM: + h5tools_str_append(buffer, "H5T_STR_NULLTERM;"); + break; + case H5T_STR_NULLPAD: + h5tools_str_append(buffer, "H5T_STR_NULLPAD;"); + break; + case H5T_STR_SPACEPAD: + h5tools_str_append(buffer, "H5T_STR_SPACEPAD;"); + break; + case H5T_STR_RESERVED_3: + case H5T_STR_RESERVED_4: + case H5T_STR_RESERVED_5: + case H5T_STR_RESERVED_6: + case H5T_STR_RESERVED_7: + case H5T_STR_RESERVED_8: + case H5T_STR_RESERVED_9: + case H5T_STR_RESERVED_10: + case H5T_STR_RESERVED_11: + case H5T_STR_RESERVED_12: + case H5T_STR_RESERVED_13: + case H5T_STR_RESERVED_14: + case H5T_STR_RESERVED_15: + h5tools_str_append(buffer, "H5T_STR_UNKNOWN;"); + break; + case H5T_STR_ERROR: + h5tools_str_append(buffer, "H5T_STR_ERROR;"); + break; + default: + h5tools_str_append(buffer, "ERROR;"); + break; + } + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - h5tools_str_append(buffer, "%s ", CSET); + ctx->need_prefix = TRUE; - switch (cset) { - case H5T_CSET_ASCII: - h5tools_str_append(buffer, "H5T_CSET_ASCII;"); - break; - case H5T_CSET_UTF8: - h5tools_str_append(buffer, "H5T_CSET_UTF8;"); - break; - case H5T_CSET_RESERVED_2: - case H5T_CSET_RESERVED_3: - case H5T_CSET_RESERVED_4: - case H5T_CSET_RESERVED_5: - case H5T_CSET_RESERVED_6: - case H5T_CSET_RESERVED_7: - case H5T_CSET_RESERVED_8: - case H5T_CSET_RESERVED_9: - case H5T_CSET_RESERVED_10: - case H5T_CSET_RESERVED_11: - case H5T_CSET_RESERVED_12: - case H5T_CSET_RESERVED_13: - case H5T_CSET_RESERVED_14: - case H5T_CSET_RESERVED_15: - h5tools_str_append(buffer, "H5T_CSET_UNKNOWN;"); - break; - case H5T_CSET_ERROR: - h5tools_str_append(buffer, "H5T_CSET_ERROR;"); - break; - default: - h5tools_str_append(buffer, "ERROR;"); - break; - } - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_reset(buffer); - ctx->need_prefix = TRUE; + h5tools_str_append(buffer, "%s ", CSET); + + switch (cset) { + case H5T_CSET_ASCII: + h5tools_str_append(buffer, "H5T_CSET_ASCII;"); + break; + case H5T_CSET_UTF8: + h5tools_str_append(buffer, "H5T_CSET_UTF8;"); + break; + case H5T_CSET_RESERVED_2: + case H5T_CSET_RESERVED_3: + case H5T_CSET_RESERVED_4: + case H5T_CSET_RESERVED_5: + case H5T_CSET_RESERVED_6: + case H5T_CSET_RESERVED_7: + case H5T_CSET_RESERVED_8: + case H5T_CSET_RESERVED_9: + case H5T_CSET_RESERVED_10: + case H5T_CSET_RESERVED_11: + case H5T_CSET_RESERVED_12: + case H5T_CSET_RESERVED_13: + case H5T_CSET_RESERVED_14: + case H5T_CSET_RESERVED_15: + h5tools_str_append(buffer, "H5T_CSET_UNKNOWN;"); + break; + case H5T_CSET_ERROR: + h5tools_str_append(buffer, "H5T_CSET_ERROR;"); + break; + default: + h5tools_str_append(buffer, "ERROR;"); + break; + } + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - h5tools_str_reset(buffer); + ctx->need_prefix = TRUE; - str_type = H5Tcopy(H5T_C_S1); - if (is_vlstr) - H5Tset_size(str_type, H5T_VARIABLE); - else - H5Tset_size(str_type, size); - H5Tset_cset(str_type, cset); - H5Tset_strpad(str_type, str_pad); + h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s ", CTYPE); + str_type = H5Tcopy(H5T_C_S1); + if (is_vlstr) + H5Tset_size(str_type, H5T_VARIABLE); + else + H5Tset_size(str_type, size); + H5Tset_cset(str_type, cset); + H5Tset_strpad(str_type, str_pad); - /* Check C variable-length string first. Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - h5tools_str_append(buffer, "H5T_C_S1;"); - goto found_string_type; - } + h5tools_str_append(buffer, "%s ", CTYPE); - /* Change the endianness and see if they're equal. */ - order = H5Tget_order(tmp_type); - if(order == H5T_ORDER_LE) { - if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) - H5TOOLS_ERROR((-1), "H5Tset_order failed"); - } /* end if */ - else if(order == H5T_ORDER_BE) { - if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) - H5TOOLS_ERROR((-1), "H5Tset_order failed"); - } /* end if */ - - if(H5Tequal(tmp_type, str_type)) { - h5tools_str_append(buffer, "H5T_C_S1;"); - goto found_string_type; - } + /* Check C variable-length string first. Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + h5tools_str_append(buffer, "H5T_C_S1;"); + goto found_string_type; + } - /* If not equal to C variable-length string, check Fortran type. */ - if(H5Tclose(str_type) < 0) - H5TOOLS_ERROR((-1), "H5Tclose failed"); - str_type = H5Tcopy(H5T_FORTRAN_S1); + /* Change the endianness and see if they're equal. */ + order = H5Tget_order(tmp_type); + if (order == H5T_ORDER_LE) { + if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) + H5TOOLS_ERROR((-1), "H5Tset_order failed"); + } /* end if */ + else if (order == H5T_ORDER_BE) { + if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) + H5TOOLS_ERROR((-1), "H5Tset_order failed"); + } /* end if */ + + if (H5Tequal(tmp_type, str_type)) { + h5tools_str_append(buffer, "H5T_C_S1;"); + goto found_string_type; + } - H5Tset_cset(str_type, cset); - H5Tset_size(str_type, size); - H5Tset_strpad(str_type, str_pad); + /* If not equal to C variable-length string, check Fortran type. */ + if (H5Tclose(str_type) < 0) + H5TOOLS_ERROR((-1), "H5Tclose failed"); + str_type = H5Tcopy(H5T_FORTRAN_S1); - /* Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - h5tools_str_append(buffer, "H5T_FORTRAN_S1;"); - goto found_string_type; - } + H5Tset_cset(str_type, cset); + H5Tset_size(str_type, size); + H5Tset_strpad(str_type, str_pad); - /* Change the endianness and see if they're equal. */ - order = H5Tget_order(tmp_type); - if(order == H5T_ORDER_LE) { - if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) - H5TOOLS_ERROR((-1), "H5Tset_order failed"); - } /* end if */ - else if(order == H5T_ORDER_BE) { - if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) - H5TOOLS_ERROR((-1), "H5Tset_order failed"); - } /* end if */ - - if(H5Tequal(tmp_type, str_type)) { - h5tools_str_append(buffer, "H5T_FORTRAN_S1;"); - goto found_string_type; - } + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + h5tools_str_append(buffer, "H5T_FORTRAN_S1;"); + goto found_string_type; + } - /* Type doesn't match any of above. */ - h5tools_str_append(buffer, "unknown_one_character_type;"); + /* Change the endianness and see if they're equal. */ + order = H5Tget_order(tmp_type); + if (order == H5T_ORDER_LE) { + if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) + H5TOOLS_ERROR((-1), "H5Tset_order failed"); + } /* end if */ + else if (order == H5T_ORDER_BE) { + if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) + H5TOOLS_ERROR((-1), "H5Tset_order failed"); + } /* end if */ + + if (H5Tequal(tmp_type, str_type)) { + h5tools_str_append(buffer, "H5T_FORTRAN_S1;"); + goto found_string_type; + } - found_string_type: - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - ctx->indent_level--; + /* Type doesn't match any of above. */ + h5tools_str_append(buffer, "unknown_one_character_type;"); - ctx->need_prefix = TRUE; +found_string_type: + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); + ctx->indent_level--; - h5tools_str_reset(buffer); - if(H5Tclose(str_type) < 0) - H5TOOLS_ERROR((-1), "H5Tclose failed"); - if(H5Tclose(tmp_type) < 0) - H5TOOLS_ERROR((-1), "H5Tclose failed"); - - h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend); - break; - - case H5T_BITFIELD: - if (H5Tequal(type, H5T_STD_B8BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_B8BE"); - else if (H5Tequal(type, H5T_STD_B8LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_B8LE"); - else if (H5Tequal(type, H5T_STD_B16BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_B16BE"); - else if (H5Tequal(type, H5T_STD_B16LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_B16LE"); - else if (H5Tequal(type, H5T_STD_B32BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_B32BE"); - else if (H5Tequal(type, H5T_STD_B32LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_B32LE"); - else if (H5Tequal(type, H5T_STD_B64BE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_B64BE"); - else if (H5Tequal(type, H5T_STD_B64LE) == TRUE) - h5tools_str_append(buffer, "H5T_STD_B64LE"); - else - h5tools_str_append(buffer, "undefined bitfield"); - break; + ctx->need_prefix = TRUE; - case H5T_OPAQUE: - h5tools_str_append(buffer, "H5T_OPAQUE %s", h5tools_dump_header_format->structblockbegin); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - ctx->indent_level++; - { - char *ttag; + h5tools_str_reset(buffer); + if (H5Tclose(str_type) < 0) + H5TOOLS_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(tmp_type) < 0) + H5TOOLS_ERROR((-1), "H5Tclose failed"); - if(NULL == (ttag = H5Tget_tag(type))) - H5TOOLS_THROW((-1), "H5Tget_tag failed"); + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend); + break; - ctx->need_prefix = TRUE; + case H5T_BITFIELD: + if (H5Tequal(type, H5T_STD_B8BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_B8BE"); + else if (H5Tequal(type, H5T_STD_B8LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_B8LE"); + else if (H5Tequal(type, H5T_STD_B16BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_B16BE"); + else if (H5Tequal(type, H5T_STD_B16LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_B16LE"); + else if (H5Tequal(type, H5T_STD_B32BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_B32BE"); + else if (H5Tequal(type, H5T_STD_B32LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_B32LE"); + else if (H5Tequal(type, H5T_STD_B64BE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_B64BE"); + else if (H5Tequal(type, H5T_STD_B64LE) == TRUE) + h5tools_str_append(buffer, "H5T_STD_B64LE"); + else + h5tools_str_append(buffer, "undefined bitfield"); + break; - h5tools_str_reset(buffer); - h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";", ttag); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + case H5T_OPAQUE: + h5tools_str_append(buffer, "H5T_OPAQUE %s", h5tools_dump_header_format->structblockbegin); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); + ctx->indent_level++; + { + char *ttag; - H5free_memory(ttag); + if (NULL == (ttag = H5Tget_tag(type))) + H5TOOLS_THROW((-1), "H5Tget_tag failed"); - if((size = H5Tget_size(type)) <= 0) { ctx->need_prefix = TRUE; h5tools_str_reset(buffer); - h5tools_str_append(buffer, "OPAQUE_SIZE \"%s\";", size); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";", ttag); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); + + H5free_memory(ttag); + + if ((size = H5Tget_size(type)) <= 0) { + ctx->need_prefix = TRUE; + + h5tools_str_reset(buffer); + h5tools_str_append(buffer, "OPAQUE_SIZE \"%s\";", size); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); + } } - } - ctx->indent_level--; + ctx->indent_level--; - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend); - break; + h5tools_str_reset(buffer); + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend); + break; - case H5T_COMPOUND: - if((snmembers = H5Tget_nmembers(type)) < 0) - H5TOOLS_THROW((-1), "H5Tget_nmembers failed"); - nmembers = (unsigned)snmembers; + case H5T_COMPOUND: + if ((snmembers = H5Tget_nmembers(type)) < 0) + H5TOOLS_THROW((-1), "H5Tget_nmembers failed"); + nmembers = (unsigned)snmembers; - h5tools_str_append(buffer, "H5T_COMPOUND %s", h5tools_dump_header_format->structblockbegin); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(buffer, "H5T_COMPOUND %s", h5tools_dump_header_format->structblockbegin); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->indent_level++; - for (i = 0; i < nmembers; i++) { - mname = H5Tget_member_name(type, i); - if((mtype = H5Tget_member_type(type, i)) >= 0) { - ctx->need_prefix = TRUE; + ctx->indent_level++; + for (i = 0; i < nmembers; i++) { + mname = H5Tget_member_name(type, i); + if ((mtype = H5Tget_member_type(type, i)) >= 0) { + ctx->need_prefix = TRUE; - h5tools_str_reset(buffer); - h5tools_print_datatype(stream, buffer, info, ctx, mtype, TRUE); + h5tools_str_reset(buffer); + h5tools_print_datatype(stream, buffer, info, ctx, mtype, TRUE); - h5tools_str_append(buffer, " \"%s\";", mname); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - if(H5Tclose(mtype) < 0) - H5TOOLS_ERROR((-1), "H5Tclose failed"); + h5tools_str_append(buffer, " \"%s\";", mname); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); + if (H5Tclose(mtype) < 0) + H5TOOLS_ERROR((-1), "H5Tclose failed"); + } + else + H5TOOLS_ERROR((-1), "H5Tget_member_type failed"); + H5free_memory(mname); } - else - H5TOOLS_ERROR((-1), "H5Tget_member_type failed"); - H5free_memory(mname); - } - ctx->indent_level--; + ctx->indent_level--; - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend); - break; + h5tools_str_reset(buffer); + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend); + break; - case H5T_REFERENCE: - h5tools_str_append(buffer, "H5T_REFERENCE"); - if (H5Tequal(type, H5T_STD_REF_DSETREG) == TRUE) { - h5tools_str_append(buffer, " { H5T_STD_REF_DSETREG }"); - } - else if (H5Tequal(type, H5T_STD_REF_OBJ) == TRUE) { - h5tools_str_append(buffer, " { H5T_STD_REF_OBJECT }"); - } - else if (H5Tequal(type, H5T_STD_REF) == TRUE) { - h5tools_str_append(buffer, " { H5T_STD_REF }"); - } - else { - h5tools_str_append(buffer, " { UNDEFINED }"); - } - break; + case H5T_REFERENCE: + h5tools_str_append(buffer, "H5T_REFERENCE"); + if (H5Tequal(type, H5T_STD_REF_DSETREG) == TRUE) { + h5tools_str_append(buffer, " { H5T_STD_REF_DSETREG }"); + } + else if (H5Tequal(type, H5T_STD_REF_OBJ) == TRUE) { + h5tools_str_append(buffer, " { H5T_STD_REF_OBJECT }"); + } + else if (H5Tequal(type, H5T_STD_REF) == TRUE) { + h5tools_str_append(buffer, " { H5T_STD_REF }"); + } + else { + h5tools_str_append(buffer, " { UNDEFINED }"); + } + break; - case H5T_ENUM: - if((super = H5Tget_super(type)) < 0) - H5TOOLS_THROW((-1), "H5Tget_super failed"); + case H5T_ENUM: + if ((super = H5Tget_super(type)) < 0) + H5TOOLS_THROW((-1), "H5Tget_super failed"); - h5tools_str_append(buffer, "H5T_ENUM %s", h5tools_dump_header_format->enumblockbegin); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - ctx->indent_level++; + h5tools_str_append(buffer, "H5T_ENUM %s", h5tools_dump_header_format->enumblockbegin); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); + ctx->indent_level++; - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(buffer); - h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); + h5tools_str_reset(buffer); + h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); - if(H5Tclose(super) < 0) - H5TOOLS_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(super) < 0) + H5TOOLS_ERROR((-1), "H5Tclose failed"); - h5tools_str_append(buffer, ";"); - h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(buffer, ";"); + h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - h5tools_print_enum(stream, buffer, info, ctx, type); + h5tools_print_enum(stream, buffer, info, ctx, type); - ctx->indent_level--; + ctx->indent_level--; - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockend); + h5tools_str_reset(buffer); + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockend); - break; + break; - case H5T_VLEN: - if((super = H5Tget_super(type)) < 0) - H5TOOLS_THROW((-1), "H5Tget_super failed"); + case H5T_VLEN: + if ((super = H5Tget_super(type)) < 0) + H5TOOLS_THROW((-1), "H5Tget_super failed"); - h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin); + h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin); - h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); + h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); - if(H5Tclose(super) < 0) - H5TOOLS_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(super) < 0) + H5TOOLS_ERROR((-1), "H5Tclose failed"); - h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend); + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend); - break; + break; - case H5T_ARRAY: - h5tools_str_append(buffer, "H5T_ARRAY { "); + case H5T_ARRAY: + h5tools_str_append(buffer, "H5T_ARRAY { "); - /* Get array information */ - if((sndims = H5Tget_array_ndims(type)) >= 0) { - unsigned ndims = (unsigned)sndims; + /* Get array information */ + if ((sndims = H5Tget_array_ndims(type)) >= 0) { + unsigned ndims = (unsigned)sndims; - if(H5Tget_array_dims2(type, dims) >= 0) { - /* Print array dimensions */ - for (i = 0; i < ndims; i++) - h5tools_str_append(buffer, "[" HSIZE_T_FORMAT "]", dims[i]); + if (H5Tget_array_dims2(type, dims) >= 0) { + /* Print array dimensions */ + for (i = 0; i < ndims; i++) + h5tools_str_append(buffer, "[" HSIZE_T_FORMAT "]", dims[i]); - h5tools_str_append(buffer, " "); + h5tools_str_append(buffer, " "); + } + else + H5TOOLS_ERROR((-1), "H5Tget_array_dims2 failed"); } else - H5TOOLS_ERROR((-1), "H5Tget_array_dims2 failed"); - } - else - H5TOOLS_ERROR((-1), "H5Tget_array_ndims failed"); - - /* Get array base type */ - if((super = H5Tget_super(type)) >= 0) { - /* Print base type */ - h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); - /* Close array base type */ - if(H5Tclose(super) < 0) - H5TOOLS_ERROR((-1), "H5Tclose failed"); - } - else - H5TOOLS_ERROR((-1), "H5Tget_super failed"); + H5TOOLS_ERROR((-1), "H5Tget_array_ndims failed"); + + /* Get array base type */ + if ((super = H5Tget_super(type)) >= 0) { + /* Print base type */ + h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); + /* Close array base type */ + if (H5Tclose(super) < 0) + H5TOOLS_ERROR((-1), "H5Tclose failed"); + } + else + H5TOOLS_ERROR((-1), "H5Tget_super failed"); - h5tools_str_append(buffer, " }"); + h5tools_str_append(buffer, " }"); - break; + break; - case H5T_NO_CLASS: - case H5T_NCLASSES: - default: - h5tools_str_append(buffer, "unknown datatype"); - break; + case H5T_NO_CLASS: + case H5T_NCLASSES: + default: + h5tools_str_append(buffer, "unknown datatype"); + break; } -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; } @@ -2637,69 +2661,70 @@ h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space) { hsize_t size[H5TOOLS_DUMP_MAX_RANK]; hsize_t maxsize[H5TOOLS_DUMP_MAX_RANK]; - int ndims = -1; + int ndims = -1; H5S_class_t space_type = -1; hbool_t past_catch = FALSE; int i; int ret_value = 0; H5TOOLS_START_DEBUG(""); - if((ndims = H5Sget_simple_extent_dims(space, size, maxsize)) < 0) + if ((ndims = H5Sget_simple_extent_dims(space, size, maxsize)) < 0) H5TOOLS_THROW((-1), "H5Sget_simple_extent_dims failed"); - if((space_type = H5Sget_simple_extent_type(space)) < 0) + if ((space_type = H5Sget_simple_extent_type(space)) < 0) H5TOOLS_THROW((-1), "H5Sget_simple_extent_type failed"); - switch(space_type) { - case H5S_SCALAR: - /* scalar dataspace */ - h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, S_SCALAR); - break; + switch (space_type) { + case H5S_SCALAR: + /* scalar dataspace */ + h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, + S_SCALAR); + break; - case H5S_SIMPLE: - /* simple dataspace */ - h5tools_str_append(buffer, "%s %s { %s " HSIZE_T_FORMAT, - h5tools_dump_header_format->dataspacedescriptionbegin, S_SIMPLE, - h5tools_dump_header_format->dataspacedimbegin, size[0]); + case H5S_SIMPLE: + /* simple dataspace */ + h5tools_str_append(buffer, "%s %s { %s " HSIZE_T_FORMAT, + h5tools_dump_header_format->dataspacedescriptionbegin, S_SIMPLE, + h5tools_dump_header_format->dataspacedimbegin, size[0]); - for(i = 1; i < ndims; i++) - h5tools_str_append(buffer, ", " HSIZE_T_FORMAT, size[i]); + for (i = 1; i < ndims; i++) + h5tools_str_append(buffer, ", " HSIZE_T_FORMAT, size[i]); - h5tools_str_append(buffer, " %s / ", h5tools_dump_header_format->dataspacedimend); + h5tools_str_append(buffer, " %s / ", h5tools_dump_header_format->dataspacedimend); - if(maxsize[0] == H5S_UNLIMITED) - h5tools_str_append(buffer, "%s %s", - h5tools_dump_header_format->dataspacedimbegin, "H5S_UNLIMITED"); - else - h5tools_str_append(buffer, "%s " HSIZE_T_FORMAT, - h5tools_dump_header_format->dataspacedimbegin, maxsize[0]); - - for(i = 1; i < ndims; i++) - if(maxsize[i] == H5S_UNLIMITED) - h5tools_str_append(buffer, ", %s", "H5S_UNLIMITED"); + if (maxsize[0] == H5S_UNLIMITED) + h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedimbegin, + "H5S_UNLIMITED"); else - h5tools_str_append(buffer, ", " HSIZE_T_FORMAT, maxsize[i]); + h5tools_str_append(buffer, "%s " HSIZE_T_FORMAT, + h5tools_dump_header_format->dataspacedimbegin, maxsize[0]); - h5tools_str_append(buffer, " %s }", h5tools_dump_header_format->dataspacedimend); - break; + for (i = 1; i < ndims; i++) + if (maxsize[i] == H5S_UNLIMITED) + h5tools_str_append(buffer, ", %s", "H5S_UNLIMITED"); + else + h5tools_str_append(buffer, ", " HSIZE_T_FORMAT, maxsize[i]); - case H5S_NULL: - /* null dataspace */ - h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, S_NULL); - break; + h5tools_str_append(buffer, " %s }", h5tools_dump_header_format->dataspacedimend); + break; + + case H5S_NULL: + /* null dataspace */ + h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, + S_NULL); + break; - case H5S_NO_CLASS: - default: - h5tools_str_append(buffer, "%s unknown dataspace %s\n", BEGIN, END); - break; + case H5S_NO_CLASS: + default: + h5tools_str_append(buffer, "%s unknown dataspace %s\n", BEGIN, END); + break; } /* end switch */ -CATCH + CATCH H5TOOLS_ENDDEBUG(""); return ret_value; } - /*------------------------------------------------------------------------- * Function: print_enum * @@ -2712,37 +2737,38 @@ CATCH * *-----------------------------------------------------------------------*/ int -h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type) +h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx, + hid_t type) { - char **name = NULL; /*member names */ + char ** name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ - unsigned char *copy = NULL; /*a pointer to value array */ + unsigned char *copy = NULL; /*a pointer to value array */ unsigned i; - unsigned nmembs = 0; /*number of members */ + unsigned nmembs = 0; /*number of members */ int snmembs; - hid_t super = H5I_INVALID_HID; /*enum base integer type */ - hid_t native = H5I_INVALID_HID; /*native integer datatype */ - H5T_sign_t sign_type; /*sign of value type */ - size_t type_size; /*value type size */ - size_t dst_size; /*destination value type size */ - size_t ncols = 80; /*available output width */ - hsize_t curr_pos = 0; /* total data element position */ + hid_t super = H5I_INVALID_HID; /*enum base integer type */ + hid_t native = H5I_INVALID_HID; /*native integer datatype */ + H5T_sign_t sign_type; /*sign of value type */ + size_t type_size; /*value type size */ + size_t dst_size; /*destination value type size */ + size_t ncols = 80; /*available output width */ + hsize_t curr_pos = 0; /* total data element position */ hbool_t past_catch = FALSE; - int ret_value = 0; + int ret_value = 0; H5TOOLS_START_DEBUG(""); if (info->line_ncols > 0) ncols = info->line_ncols; - if((snmembs = H5Tget_nmembers(type)) < 0) + if ((snmembs = H5Tget_nmembers(type)) < 0) H5TOOLS_THROW((-1), "H5Tget_nmembers failed"); nmembs = (unsigned)snmembs; HDassert(nmembs > 0); - if((super = H5Tget_super(type)) < 0) + if ((super = H5Tget_super(type)) < 0) H5TOOLS_THROW((-1), "H5Tget_super failed"); - if((type_size = H5Tget_size(type)) <= 0) + if ((type_size = H5Tget_size(type)) <= 0) H5TOOLS_THROW((-1), "H5Tget_size(type) failed"); /* @@ -2752,12 +2778,12 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i * 2. unsigned long long -- the largest native unsigned integer * 3. raw format */ - if(type_size <= sizeof(long long)) { + if (type_size <= sizeof(long long)) { dst_size = sizeof(long long); - if((sign_type = H5Tget_sign(type))<0) + if ((sign_type = H5Tget_sign(type)) < 0) H5TOOLS_THROW((-1), "H5Tget_sign failed"); - if(H5T_SGN_NONE == sign_type) + if (H5T_SGN_NONE == sign_type) native = H5T_NATIVE_ULLONG; else native = H5T_NATIVE_LLONG; @@ -2766,20 +2792,20 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i dst_size = type_size; /* Get the names and raw values of all members */ - if(NULL == (name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)))) + if (NULL == (name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)))) H5TOOLS_THROW((-1), "Could not allocate buffer for member name"); - if(NULL == (value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(type_size, dst_size)))) + if (NULL == (value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(type_size, dst_size)))) H5TOOLS_THROW((-1), "Could not allocate buffer for member value"); for (i = 0; i < nmembs; i++) { name[i] = H5Tget_member_name(type, i); - if(H5Tget_member_value(type, i, value + i * type_size) < 0) + if (H5Tget_member_value(type, i, value + i * type_size) < 0) H5TOOLS_THROW((-1), "H5Tget_member_value failed"); } /* Convert values to native datatype */ if (native > 0) - if(H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) H5TOOLS_THROW((-1), "H5Tconvert failed"); /* @@ -2789,7 +2815,7 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i /* Print members */ for (i = 0; i < nmembs; i++) { - int nchars; /*number of output characters */ + int nchars; /*number of output characters */ ctx->need_prefix = TRUE; h5tools_simple_prefix(stream, info, ctx, (hsize_t)0, 0); @@ -2811,35 +2837,35 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" *strangely, unless use another pointer "copy".*/ copy = value + i * dst_size; - h5tools_str_append(buffer, HSIZE_T_FORMAT, *((unsigned long long *) ((void *) copy))); + h5tools_str_append(buffer, HSIZE_T_FORMAT, *((unsigned long long *)((void *)copy))); } else { /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" *strangely, unless use another pointer "copy".*/ copy = value + i * dst_size; - h5tools_str_append(buffer, "%" H5_PRINTF_LL_WIDTH "d", *((long long *) ((void *) copy))); + h5tools_str_append(buffer, "%" H5_PRINTF_LL_WIDTH "d", *((long long *)((void *)copy))); } h5tools_str_append(buffer, ";"); h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); } -CATCH - if(name) { + CATCH + if (name) { /* Release resources */ - for(i = 0; i < nmembs; i++) - if(name[i]) + for (i = 0; i < nmembs; i++) + if (name[i]) H5free_memory(name[i]); HDfree(name); } /* end if */ - if(value) + if (value) HDfree(value); - if(super >= 0 && H5Tclose(super) < 0) + if (super >= 0 && H5Tclose(super) < 0) H5TOOLS_THROW((-1), "Could not close datatype's super class"); - if(0 == nmembs) + if (0 == nmembs) h5tools_str_append(buffer, "\n"); H5TOOLS_ENDDEBUG(""); @@ -2860,13 +2886,13 @@ CATCH void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type) { - h5tools_str_t buffer; /* string into which to render */ - size_t ncols = 80; /* available output width */ - hsize_t curr_pos = ctx->sm_pos; /* total data element position */ - /* pass to the prefix in h5tools_simple_prefix the total position - * instead of the current stripmine position i; this is necessary - * to print the array indices - */ + h5tools_str_t buffer; /* string into which to render */ + size_t ncols = 80; /* available output width */ + hsize_t curr_pos = ctx->sm_pos; /* total data element position */ + /* pass to the prefix in h5tools_simple_prefix the total position + * instead of the current stripmine position i; this is necessary + * to print the array indices + */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -2877,9 +2903,8 @@ h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s ", - h5tools_dump_header_format->datatypebegin, - h5tools_dump_header_format->datatypeblockbegin); + h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->datatypebegin, + h5tools_dump_header_format->datatypeblockbegin); h5tools_print_datatype(stream, &buffer, info, ctx, type, TRUE); if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeblockend); @@ -2907,13 +2932,13 @@ h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context void h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type) { - h5tools_str_t buffer; /* string into which to render */ - size_t ncols = 80; /* available output width */ - hsize_t curr_pos = ctx->sm_pos; /* total data element position */ - /* pass to the prefix in h5tools_simple_prefix the total position - * instead of the current stripmine position i; this is necessary - * to print the array indices - */ + h5tools_str_t buffer; /* string into which to render */ + size_t ncols = 80; /* available output width */ + hsize_t curr_pos = ctx->sm_pos; /* total data element position */ + /* pass to the prefix in h5tools_simple_prefix the total position + * instead of the current stripmine position i; this is necessary + * to print the array indices + */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -2924,8 +2949,7 @@ h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_contex ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s ", - h5tools_dump_header_format->dataspacebegin); + h5tools_str_append(&buffer, "%s ", h5tools_dump_header_format->dataspacebegin); h5tools_print_dataspace(&buffer, type); @@ -2955,13 +2979,13 @@ h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_contex void h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t oid) { - h5tools_str_t buffer; /* string into which to render */ - size_t ncols = 80; /* available output width */ - hsize_t curr_pos = ctx->sm_pos; /* total data element position */ - /* pass to the prefix in h5tools_simple_prefix the total position - * instead of the current stripmine position i; this is necessary - * to print the array indices - */ + h5tools_str_t buffer; /* string into which to render */ + size_t ncols = 80; /* available output width */ + hsize_t curr_pos = ctx->sm_pos; /* total data element position */ + /* pass to the prefix in h5tools_simple_prefix the total position + * instead of the current stripmine position i; this is necessary + * to print the array indices + */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -2988,38 +3012,43 @@ h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c */ static void h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, /* in,out*/ - h5tools_str_t *buffer, /* string into which to render */ - hsize_t *curr_pos, /* total data element position */ - size_t ncols) + h5tools_context_t *ctx, /* in,out*/ + h5tools_str_t * buffer, /* string into which to render */ + hsize_t * curr_pos, /* total data element position */ + size_t ncols) { - switch(H5Sget_select_type(vspace)) { - case H5S_SEL_NONE: /* Nothing selected */ + switch (H5Sget_select_type(vspace)) { + case H5S_SEL_NONE: /* Nothing selected */ ctx->need_prefix = TRUE; h5tools_str_reset(buffer); h5tools_str_append(buffer, "%s", VDS_NONE); break; - case H5S_SEL_POINTS: /* Sequence of points selected */ + case H5S_SEL_POINTS: /* Sequence of points selected */ h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s %s ", VDS_POINT, h5tools_dump_header_format->virtualselectionblockbegin); + h5tools_str_append(buffer, "%s %s ", VDS_POINT, + h5tools_dump_header_format->virtualselectionblockbegin); h5tools_str_dump_space_points(buffer, vspace, info); h5tools_str_append(buffer, " %s", h5tools_dump_header_format->virtualselectionblockend); break; - case H5S_SEL_HYPERSLABS: /* "New-style" hyperslab selection defined */ + case H5S_SEL_HYPERSLABS: /* "New-style" hyperslab selection defined */ ctx->need_prefix = TRUE; h5tools_str_reset(buffer); if (H5Sis_regular_hyperslab(vspace)) { - h5tools_str_append(buffer, "%s %s ", VDS_REG_HYPERSLAB, h5tools_dump_header_format->virtualselectionblockbegin); - h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_append(buffer, "%s %s ", VDS_REG_HYPERSLAB, + h5tools_dump_header_format->virtualselectionblockbegin); + h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); h5tools_str_reset(buffer); h5tools_str_dump_space_slabs(buffer, vspace, info, ctx); } else { - h5tools_str_append(buffer, "%s %s ", VDS_IRR_HYPERSLAB, h5tools_dump_header_format->virtualselectionblockbegin); - h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_append(buffer, "%s %s ", VDS_IRR_HYPERSLAB, + h5tools_dump_header_format->virtualselectionblockbegin); + h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); ctx->indent_level++; ctx->need_prefix = TRUE; h5tools_simple_prefix(stream, info, ctx, *curr_pos, 0); @@ -3028,13 +3057,14 @@ h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_ h5tools_str_dump_space_blocks(buffer, vspace, info); ctx->indent_level--; } - h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); ctx->need_prefix = TRUE; h5tools_str_reset(buffer); h5tools_str_append(buffer, "%s", h5tools_dump_header_format->virtualselectionblockend); break; - case H5S_SEL_ALL: /* Entire extent selected */ + case H5S_SEL_ALL: /* Entire extent selected */ ctx->need_prefix = TRUE; h5tools_str_reset(buffer); @@ -3045,7 +3075,7 @@ h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_ default: h5tools_str_append(buffer, "Unknown Selection"); } - h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); } /*------------------------------------------------------------------------- @@ -3057,17 +3087,17 @@ h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_ *------------------------------------------------------------------------- */ void -h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id) +h5tools_print_fill_value(h5tools_str_t *buffer /*in,out*/, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id) { - size_t size; - hid_t n_type = H5I_INVALID_HID; - void *buf = NULL; + size_t size; + hid_t n_type = H5I_INVALID_HID; + void * buf = NULL; n_type = H5Tget_native_type(type_id, H5T_DIR_DEFAULT); size = H5Tget_size(n_type); - buf = HDmalloc(size); + buf = HDmalloc(size); H5Pget_fill_value(dcpl, n_type, buf); @@ -3076,7 +3106,7 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t H5Tclose(n_type); if (buf) - HDfree (buf); + HDfree(buf); } /*------------------------------------------------------------------------- @@ -3088,32 +3118,32 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *------------------------------------------------------------------------- */ void -h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hid_t dcpl_id, hid_t type_id, hid_t dset_id) +h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dcpl_id, + hid_t type_id, hid_t dset_id) { - int nfilters; /* number of filters */ - int rank; /* rank */ + int nfilters; /* number of filters */ + int rank; /* rank */ int i; unsigned j; - unsigned filt_flags; /* filter flags */ - unsigned cd_values[20]; /* filter client data values */ + unsigned filt_flags; /* filter flags */ + unsigned cd_values[20]; /* filter client data values */ unsigned szip_options_mask; unsigned szip_pixels_per_block; - H5Z_filter_t filtn; /* filter identification number */ + H5Z_filter_t filtn; /* filter identification number */ H5D_fill_value_t fvstatus; H5D_alloc_time_t at; H5D_fill_time_t ft; H5D_layout_t stl; - size_t ncols = 80; /* available output width */ - size_t cd_nelmts; /* filter client number of values */ - off_t offset; /* offset of external file */ - char f_name[256]; /* filter name */ - char name[256]; /* external or virtual file name */ - hsize_t chsize[64]; /* chunk size in elements */ - hsize_t size; /* size of external file */ + size_t ncols = 80; /* available output width */ + size_t cd_nelmts; /* filter client number of values */ + off_t offset; /* offset of external file */ + char f_name[256]; /* filter name */ + char name[256]; /* external or virtual file name */ + hsize_t chsize[64]; /* chunk size in elements */ + hsize_t size; /* size of external file */ hsize_t storage_size; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -3121,13 +3151,13 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, ncols = info->line_ncols; storage_size = H5Dget_storage_size(dset_id); - nfilters = H5Pget_nfilters(dcpl_id); - HDstrcpy(f_name,"\0"); + nfilters = H5Pget_nfilters(dcpl_id); + HDstrcpy(f_name, "\0"); /*------------------------------------------------------------------------- - * STORAGE_LAYOUT - *------------------------------------------------------------------------- - */ + * STORAGE_LAYOUT + *------------------------------------------------------------------------- + */ ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); @@ -3143,12 +3173,14 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "%s ", CHUNKED); - rank = H5Pget_chunk(dcpl_id, (int) NELMTS(chsize), chsize); - h5tools_str_append(&buffer, "%s " HSIZE_T_FORMAT, h5tools_dump_header_format->dataspacedimbegin, chsize[0]); - for(i = 1; i < rank; i++) + rank = H5Pget_chunk(dcpl_id, (int)NELMTS(chsize), chsize); + h5tools_str_append(&buffer, "%s " HSIZE_T_FORMAT, h5tools_dump_header_format->dataspacedimbegin, + chsize[0]); + for (i = 1; i < rank; i++) h5tools_str_append(&buffer, ", " HSIZE_T_FORMAT, chsize[i]); h5tools_str_append(&buffer, " %s", h5tools_dump_header_format->dataspacedimend); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); ctx->need_prefix = TRUE; @@ -3158,49 +3190,49 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, if (nfilters) { hsize_t dims[H5S_MAX_RANK]; hsize_t nelmts = 1; - double ratio = 0; - int ok = 0; + double ratio = 0; + int ok = 0; - hid_t tid = H5Dget_type(dset_id); - hid_t sid = H5Dget_space(dset_id); + hid_t tid = H5Dget_type(dset_id); + hid_t sid = H5Dget_space(dset_id); size_t datum_size = H5Tget_size(tid); - int ndims = H5Sget_simple_extent_dims(sid, dims, NULL); + int ndims = H5Sget_simple_extent_dims(sid, dims, NULL); /* only print the compression ratio for these filters */ for (i = 0; i < nfilters && !ok; i++) { cd_nelmts = NELMTS(cd_values); - filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), - f_name, NULL); - ok = (filtn >= 0); + filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, + sizeof(f_name), f_name, NULL); + ok = (filtn >= 0); } - if(ndims && ok) { + if (ndims && ok) { hsize_t uncomp_size; - for(i = 0; i < ndims; i++) { + for (i = 0; i < ndims; i++) { nelmts *= dims[i]; } uncomp_size = nelmts * datum_size; /* compression ratio = uncompressed size / compressed size */ - if(storage_size != 0) - ratio = (double) uncomp_size / (double) storage_size; - - h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT" (%.3f:1 COMPRESSION)", storage_size, ratio); + if (storage_size != 0) + ratio = (double)uncomp_size / (double)storage_size; + h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT " (%.3f:1 COMPRESSION)", storage_size, + ratio); } else h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT, storage_size); H5Sclose(sid); H5Tclose(tid); - } else { h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT, storage_size); } - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); ctx->indent_level--; break; case H5D_COMPACT: @@ -3209,202 +3241,220 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "%s", COMPACT); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT, storage_size); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); ctx->indent_level--; break; - case H5D_CONTIGUOUS: - { - int n_external; - - n_external = H5Pget_external_count(dcpl_id); + case H5D_CONTIGUOUS: { + int n_external; - ctx->indent_level++; - if (n_external) { + n_external = H5Pget_external_count(dcpl_id); - /* EXTERNAL FILE */ - - ctx->need_prefix = TRUE; + ctx->indent_level++; + if (n_external) { - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", CONTIGUOUS); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + /* EXTERNAL FILE */ - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s", EXTERNAL, BEGIN); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s", CONTIGUOUS); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->indent_level++; - for (j = 0; j < (unsigned) n_external; j++) { - H5Pget_external(dcpl_id, j, sizeof(name), name, &offset, &size); + ctx->need_prefix = TRUE; - ctx->need_prefix = TRUE; + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s %s", EXTERNAL, BEGIN); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "FILENAME %s SIZE " HSIZE_T_FORMAT, name, size); - h5tools_str_append(&buffer, " OFFSET %ld", offset); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); - } - ctx->indent_level--; + ctx->indent_level++; + for (j = 0; j < (unsigned)n_external; j++) { + H5Pget_external(dcpl_id, j, sizeof(name), name, &offset, &size); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", END); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_append(&buffer, "FILENAME %s SIZE " HSIZE_T_FORMAT, name, size); + h5tools_str_append(&buffer, " OFFSET %ld", offset); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); } - else { - haddr_t ioffset; - hbool_t supported = FALSE; + ctx->indent_level--; - /* NORMAL FILE */ + ctx->need_prefix = TRUE; - ctx->need_prefix = TRUE; + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s", END); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); + } + else { + haddr_t ioffset; + hbool_t supported = FALSE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", CONTIGUOUS); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + /* NORMAL FILE */ - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer,"SIZE " HSIZE_T_FORMAT, storage_size); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s", CONTIGUOUS); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - /* Only dump the offset if the VOL connector implements - * the functionality. - */ - H5VLquery_optional(dset_id, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_OFFSET, &supported); + ctx->need_prefix = TRUE; - if (supported) { + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT, storage_size); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->need_prefix = TRUE; + /* Only dump the offset if the VOL connector implements + * the functionality. + */ + H5VLquery_optional(dset_id, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_OFFSET, &supported); - h5tools_str_reset(&buffer); - ioffset = H5Dget_offset(dset_id); - if (HADDR_UNDEF == ioffset) - h5tools_str_append(&buffer, "OFFSET HADDR_UNDEF"); - else - h5tools_str_append(&buffer, "OFFSET %" PRIuHADDR, ioffset); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); - } + if (supported) { + + ctx->need_prefix = TRUE; + + h5tools_str_reset(&buffer); + ioffset = H5Dget_offset(dset_id); + if (HADDR_UNDEF == ioffset) + h5tools_str_append(&buffer, "OFFSET HADDR_UNDEF"); + else + h5tools_str_append(&buffer, "OFFSET %" PRIuHADDR, ioffset); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); } - ctx->indent_level--; } - break; + ctx->indent_level--; + } break; - case H5D_VIRTUAL: - { - char dsetname[256]; /* virtual datset name */ - size_t n_vmaps; + case H5D_VIRTUAL: { + char dsetname[256]; /* virtual datset name */ + size_t n_vmaps; - H5Pget_virtual_count(dcpl_id, &n_vmaps); + H5Pget_virtual_count(dcpl_id, &n_vmaps); - if (n_vmaps) { - size_t curr_vmap; - ssize_t H5_ATTR_NDEBUG_UNUSED ssize_out; + if (n_vmaps) { + size_t curr_vmap; + ssize_t H5_ATTR_NDEBUG_UNUSED ssize_out; - ctx->indent_level++; - for (curr_vmap = 0; curr_vmap < n_vmaps; curr_vmap++) { - hid_t virtual_vspace = H5Pget_virtual_vspace(dcpl_id, curr_vmap); - hid_t virtual_srcspace = H5Pget_virtual_srcspace(dcpl_id, curr_vmap); + ctx->indent_level++; + for (curr_vmap = 0; curr_vmap < n_vmaps; curr_vmap++) { + hid_t virtual_vspace = H5Pget_virtual_vspace(dcpl_id, curr_vmap); + hid_t virtual_srcspace = H5Pget_virtual_srcspace(dcpl_id, curr_vmap); - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %ld %s ", VDS_MAPPING, curr_vmap, BEGIN); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s %ld %s ", VDS_MAPPING, curr_vmap, BEGIN); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->indent_level++; + ctx->indent_level++; - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s", VDS_VIRTUAL, BEGIN); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s %s", VDS_VIRTUAL, BEGIN); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->indent_level++; + ctx->indent_level++; - h5tools_print_virtual_selection(virtual_vspace, stream, info, ctx, &buffer, &curr_pos, (size_t) ncols); + h5tools_print_virtual_selection(virtual_vspace, stream, info, ctx, &buffer, &curr_pos, + (size_t)ncols); - ctx->indent_level--; + ctx->indent_level--; - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", END); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s", END); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s", VDS_SOURCE, BEGIN); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s %s", VDS_SOURCE, BEGIN); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->indent_level++; + ctx->indent_level++; - ssize_out = H5Pget_virtual_filename(dcpl_id, curr_vmap, NULL, 0); - HDassert(ssize_out > 0); - HDassert((size_t)ssize_out < sizeof(name)); - H5Pget_virtual_filename(dcpl_id, curr_vmap, name, sizeof(name)); - ssize_out = H5Pget_virtual_dsetname(dcpl_id, curr_vmap, NULL, 0); - HDassert(ssize_out > 0); - HDassert((size_t)ssize_out < sizeof(name)); - H5Pget_virtual_dsetname(dcpl_id, curr_vmap, dsetname, sizeof(dsetname)); + ssize_out = H5Pget_virtual_filename(dcpl_id, curr_vmap, NULL, 0); + HDassert(ssize_out > 0); + HDassert((size_t)ssize_out < sizeof(name)); + H5Pget_virtual_filename(dcpl_id, curr_vmap, name, sizeof(name)); + ssize_out = H5Pget_virtual_dsetname(dcpl_id, curr_vmap, NULL, 0); + HDassert(ssize_out > 0); + HDassert((size_t)ssize_out < sizeof(name)); + H5Pget_virtual_dsetname(dcpl_id, curr_vmap, dsetname, sizeof(dsetname)); - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s", VDS_SRC_FILE, h5tools_dump_header_format->virtualfilenamebegin); - h5tools_str_append(&buffer, "%s", name); - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualfilenameend); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s %s", VDS_SRC_FILE, + h5tools_dump_header_format->virtualfilenamebegin); + h5tools_str_append(&buffer, "%s", name); + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualfilenameend); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s", VDS_SRC_DATASET, h5tools_dump_header_format->virtualdatasetnamebegin); - h5tools_str_append(&buffer, "%s", dsetname); - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualdatasetnameend); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s %s", VDS_SRC_DATASET, + h5tools_dump_header_format->virtualdatasetnamebegin); + h5tools_str_append(&buffer, "%s", dsetname); + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualdatasetnameend); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - h5tools_print_virtual_selection(virtual_srcspace, stream, info, ctx, &buffer, &curr_pos, (size_t) ncols); + h5tools_print_virtual_selection(virtual_srcspace, stream, info, ctx, &buffer, &curr_pos, + (size_t)ncols); - ctx->indent_level--; + ctx->indent_level--; - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", END); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s", END); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); - ctx->indent_level--; + ctx->indent_level--; - ctx->need_prefix = TRUE; + ctx->need_prefix = TRUE; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", END); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); - } - ctx->indent_level--; + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s", END); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); } + ctx->indent_level--; } - break; + } break; case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: default: h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "%s", "Unknown layout"); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); - }/*switch*/ + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); + } /*switch*/ ctx->need_prefix = TRUE; @@ -3413,9 +3463,9 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); /*------------------------------------------------------------------------- - * FILTERS - *------------------------------------------------------------------------- - */ + * FILTERS + *------------------------------------------------------------------------- + */ if (H5D_VIRTUAL != stl) { ctx->need_prefix = TRUE; @@ -3425,37 +3475,43 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, ctx->indent_level++; - if(nfilters) { - for(i = 0; i < nfilters; i++) { + if (nfilters) { + for (i = 0; i < nfilters; i++) { cd_nelmts = NELMTS(cd_values); - filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, - cd_values, sizeof(f_name), f_name, NULL); + filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, + sizeof(f_name), f_name, NULL); - if(filtn < 0) + if (filtn < 0) continue; /* nothing to print for invalid filter */ ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - switch(filtn) { + switch (filtn) { case H5Z_FILTER_DEFLATE: - h5tools_str_append(&buffer, "%s %s %s %d %s", DEFLATE, BEGIN, DEFLATE_LEVEL, cd_values[0], END); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s %s %s %d %s", DEFLATE, BEGIN, DEFLATE_LEVEL, + cd_values[0], END); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); break; case H5Z_FILTER_SHUFFLE: h5tools_str_append(&buffer, "%s", SHUFFLE); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); break; case H5Z_FILTER_FLETCHER32: h5tools_str_append(&buffer, "%s", FLETCHER32); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); break; case H5Z_FILTER_SZIP: - szip_options_mask = cd_values[0];; + szip_options_mask = cd_values[0]; + ; szip_pixels_per_block = cd_values[1]; h5tools_str_append(&buffer, "%s %s", SZIP, BEGIN); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); ctx->indent_level++; @@ -3463,41 +3519,46 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "PIXELS_PER_BLOCK %d", szip_pixels_per_block); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - if(szip_options_mask & H5_SZIP_CHIP_OPTION_MASK) + if (szip_options_mask & H5_SZIP_CHIP_OPTION_MASK) h5tools_str_append(&buffer, "MODE %s", "HARDWARE"); - else if(szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK) + else if (szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK) h5tools_str_append(&buffer, "MODE %s", "K13"); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - if(szip_options_mask & H5_SZIP_EC_OPTION_MASK) + if (szip_options_mask & H5_SZIP_EC_OPTION_MASK) h5tools_str_append(&buffer, "CODING %s", "ENTROPY"); - else if(szip_options_mask & H5_SZIP_NN_OPTION_MASK) + else if (szip_options_mask & H5_SZIP_NN_OPTION_MASK) h5tools_str_append(&buffer, "CODING %s", "NEAREST NEIGHBOUR"); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - if(szip_options_mask & H5_SZIP_LSB_OPTION_MASK) + if (szip_options_mask & H5_SZIP_LSB_OPTION_MASK) h5tools_str_append(&buffer, "BYTE_ORDER %s", "LSB"); - else if(szip_options_mask & H5_SZIP_MSB_OPTION_MASK) + else if (szip_options_mask & H5_SZIP_MSB_OPTION_MASK) h5tools_str_append(&buffer, "BYTE_ORDER %s", "MSB"); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); - if(szip_options_mask & H5_SZIP_RAW_OPTION_MASK) { + if (szip_options_mask & H5_SZIP_RAW_OPTION_MASK) { ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "HEADER %s", "RAW"); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); } ctx->indent_level--; @@ -3506,19 +3567,24 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "%s", END); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); break; case H5Z_FILTER_NBIT: h5tools_str_append(&buffer, "%s", NBIT); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); break; case H5Z_FILTER_SCALEOFFSET: - h5tools_str_append(&buffer, "%s %s %s %d %s", SCALEOFFSET, BEGIN, SCALEOFFSET_MINBIT, cd_values[0], END); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s %s %s %d %s", SCALEOFFSET, BEGIN, SCALEOFFSET_MINBIT, + cd_values[0], END); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); break; default: h5tools_str_append(&buffer, "%s %s", "USER_DEFINED_FILTER", BEGIN); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); ctx->indent_level++; @@ -3526,56 +3592,61 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "FILTER_ID %d", filtn); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); - if(f_name[0] != '\0') { + if (f_name[0] != '\0') { ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "COMMENT %s", f_name); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); } if (cd_nelmts) { ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s ","PARAMS", BEGIN); - for (j=0; jindent_level--; ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s",END); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s", END); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); break; - }/*switch*/ - } /*i*/ - }/*nfilters*/ + } /*switch*/ + } /*i*/ + } /*nfilters*/ else { ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "NONE"); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); } ctx->indent_level--; ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s",END); + h5tools_str_append(&buffer, "%s", END); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); } /* end if (H5D_VIRTUAL != stl) */ /*------------------------------------------------------------------------- - * FILLVALUE - *------------------------------------------------------------------------- - */ + * FILLVALUE + *------------------------------------------------------------------------- + */ ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); @@ -3590,7 +3661,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_str_append(&buffer, "FILL_TIME "); H5Pget_fill_time(dcpl_id, &ft); - switch(ft) { + switch (ft) { case H5D_FILL_TIME_ALLOC: h5tools_str_append(&buffer, "%s", "H5D_FILL_TIME_ALLOC"); break; @@ -3639,9 +3710,9 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); /*------------------------------------------------------------------------- - * ALLOCATION_TIME - *------------------------------------------------------------------------- - */ + * ALLOCATION_TIME + *------------------------------------------------------------------------- + */ if (H5D_VIRTUAL != stl) { ctx->need_prefix = TRUE; @@ -3655,7 +3726,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_str_reset(&buffer); H5Pget_alloc_time(dcpl_id, &at); - switch(at) { + switch (at) { case H5D_ALLOC_TIME_EARLY: h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_EARLY"); break; @@ -3696,16 +3767,16 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, void h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id) { - char *comment = NULL; + char * comment = NULL; ssize_t cmt_bufsize = -1; - size_t buf_size = 0; - size_t ncols = 80; /* available output width */ - h5tools_str_t buffer; /* string into which to render */ - hsize_t curr_pos = ctx->sm_pos; /* total data element position */ - /* pass to the prefix in h5tools_simple_prefix the total position - * instead of the current stripmine position i; this is necessary - * to print the array indices - */ + size_t buf_size = 0; + size_t ncols = 80; /* available output width */ + h5tools_str_t buffer; /* string into which to render */ + hsize_t curr_pos = ctx->sm_pos; /* total data element position */ + /* pass to the prefix in h5tools_simple_prefix the total position + * instead of the current stripmine position i; this is necessary + * to print the array indices + */ hbool_t supported = FALSE; /* Check if comments are supported and return if not */ @@ -3724,17 +3795,18 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_ /* call H5Oget_comment again with the correct value */ if (cmt_bufsize > 0) { - comment = (char *)HDmalloc((size_t)(cmt_bufsize+1)); /* new_size including null terminator */ - if(comment) { + comment = (char *)HDmalloc((size_t)(cmt_bufsize + 1)); /* new_size including null terminator */ + if (comment) { cmt_bufsize = H5Oget_comment(obj_id, comment, (size_t)cmt_bufsize); - if(cmt_bufsize > 0) { + if (cmt_bufsize > 0) { comment[cmt_bufsize] = '\0'; /* necessary because null char is not returned */ ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "COMMENT \"%s\"", comment); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); h5tools_str_close(&buffer); } @@ -3754,15 +3826,16 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_ *------------------------------------------------------------------------- */ void -h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, const char *attr_name, hid_t attr_id) +h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + const char *attr_name, hid_t attr_id) { - h5tools_str_t buffer; /* string into which to render */ - size_t ncols = 80; /* available output width */ - hsize_t curr_pos = ctx->sm_pos; /* total data element position */ - /* pass to the prefix in h5tools_simple_prefix the total position - * instead of the current stripmine position i; this is necessary - * to print the array indices - */ + h5tools_str_t buffer; /* string into which to render */ + size_t ncols = 80; /* available output width */ + hsize_t curr_pos = ctx->sm_pos; /* total data element position */ + /* pass to the prefix in h5tools_simple_prefix the total position + * instead of the current stripmine position i; this is necessary + * to print the array indices + */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -3773,16 +3846,15 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_contex ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->attributebegin, attr_name, - h5tools_dump_header_format->attributeblockbegin); + h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->attributebegin, attr_name, + h5tools_dump_header_format->attributeblockbegin); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - if(attr_id < 0) { + if (attr_id < 0) { error_msg("unable to open attribute \"%s\"\n", attr_name); } else { - hid_t type = H5I_INVALID_HID; + hid_t type = H5I_INVALID_HID; hid_t space = H5I_INVALID_HID; ctx->indent_level++; @@ -3793,10 +3865,10 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_contex space = H5Aget_space(attr_id); h5tools_dump_dataspace(stream, info, ctx, space); - if(oid_output) + if (oid_output) h5tools_dump_oid(stream, info, ctx, attr_id); - if(data_output || attr_data_output) + if (data_output || attr_data_output) h5tools_dump_data(stream, info, ctx, attr_id, FALSE); ctx->indent_level--; @@ -3856,38 +3928,40 @@ void h5tools_print_packed_bits(h5tools_str_t *buffer, hid_t type) { unsigned packed_bits_size = 0; - hid_t n_type = H5Tget_native_type(type, H5T_DIR_DEFAULT); + hid_t n_type = H5Tget_native_type(type, H5T_DIR_DEFAULT); - if(H5Tget_class(n_type) == H5T_INTEGER) { - if(H5Tequal(n_type, H5T_NATIVE_SCHAR) == TRUE) + if (H5Tget_class(n_type) == H5T_INTEGER) { + if (H5Tequal(n_type, H5T_NATIVE_SCHAR) == TRUE) packed_bits_size = 8 * sizeof(char); - else if(H5Tequal(n_type, H5T_NATIVE_UCHAR) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_UCHAR) == TRUE) packed_bits_size = 8 * sizeof(unsigned char); - else if(H5Tequal(n_type, H5T_NATIVE_SHORT) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_SHORT) == TRUE) packed_bits_size = 8 * sizeof(short); - else if(H5Tequal(n_type, H5T_NATIVE_USHORT) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_USHORT) == TRUE) packed_bits_size = 8 * sizeof(unsigned short); - else if(H5Tequal(n_type, H5T_NATIVE_INT) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_INT) == TRUE) packed_bits_size = 8 * sizeof(int); - else if(H5Tequal(n_type, H5T_NATIVE_UINT) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_UINT) == TRUE) packed_bits_size = 8 * sizeof(unsigned int); - else if(H5Tequal(n_type, H5T_NATIVE_LONG) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_LONG) == TRUE) packed_bits_size = 8 * sizeof(long); - else if(H5Tequal(n_type, H5T_NATIVE_ULONG) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_ULONG) == TRUE) packed_bits_size = 8 * sizeof(unsigned long); - else if(H5Tequal(n_type, H5T_NATIVE_LLONG) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_LLONG) == TRUE) packed_bits_size = 8 * sizeof(long long); - else if(H5Tequal(n_type, H5T_NATIVE_ULLONG) == TRUE) + else if (H5Tequal(n_type, H5T_NATIVE_ULLONG) == TRUE) packed_bits_size = 8 * sizeof(unsigned long long); else error_msg("Packed Bit not valid for this datatype"); } - if((packed_bits_size > 0) && (packed_data_offset + packed_data_length) > packed_bits_size) { - error_msg("Packed Bit offset+length value(%u) too large. Max is %d\n", packed_data_offset + packed_data_length, packed_bits_size); + if ((packed_bits_size > 0) && (packed_data_offset + packed_data_length) > packed_bits_size) { + error_msg("Packed Bit offset+length value(%u) too large. Max is %d\n", + packed_data_offset + packed_data_length, packed_bits_size); packed_data_mask = 0; }; - h5tools_str_append(buffer, "%s %s=%u %s=%u", PACKED_BITS, PACKED_OFFSET, packed_data_offset, PACKED_LENGTH, packed_data_length); + h5tools_str_append(buffer, "%s %s=%u %s=%u", PACKED_BITS, PACKED_OFFSET, packed_data_offset, + PACKED_LENGTH, packed_data_length); } /*------------------------------------------------------------------------- @@ -3901,9 +3975,9 @@ h5tools_print_packed_bits(h5tools_str_t *buffer, hid_t type) void h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, int dims) { - h5tools_str_t buffer; /* string into which to render */ - hsize_t curr_pos = 0; /* total data element position */ - size_t ncols = 80; /* available output width */ + h5tools_str_t buffer; /* string into which to render */ + hsize_t curr_pos = 0; /* total data element position */ + size_t ncols = 80; /* available output width */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -3913,7 +3987,8 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tool ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->subsettingbegin, h5tools_dump_header_format->subsettingblockbegin); + h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->subsettingbegin, + h5tools_dump_header_format->subsettingblockbegin); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); ctx->indent_level++; @@ -3921,43 +3996,51 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tool ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->startbegin, h5tools_dump_header_format->startblockbegin); + h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->startbegin, + h5tools_dump_header_format->startblockbegin); h5tools_print_dims(&buffer, ctx->sset->start.data, dims); - h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->startend, h5tools_dump_header_format->startblockend); + h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->startend, + h5tools_dump_header_format->startblockend); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->stridebegin, h5tools_dump_header_format->strideblockbegin); + h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->stridebegin, + h5tools_dump_header_format->strideblockbegin); h5tools_print_dims(&buffer, ctx->sset->stride.data, dims); - h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->strideend, h5tools_dump_header_format->strideblockend); + h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->strideend, + h5tools_dump_header_format->strideblockend); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->countbegin, h5tools_dump_header_format->countblockbegin); + h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->countbegin, + h5tools_dump_header_format->countblockbegin); - if(ctx->sset->count.data) + if (ctx->sset->count.data) h5tools_print_dims(&buffer, ctx->sset->count.data, dims); else h5tools_str_append(&buffer, "DEFAULT"); - h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->countend, h5tools_dump_header_format->countblockend); + h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->countend, + h5tools_dump_header_format->countblockend); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->blockbegin, h5tools_dump_header_format->blockblockbegin); + h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->blockbegin, + h5tools_dump_header_format->blockblockbegin); - if(ctx->sset->block.data) + if (ctx->sset->block.data) h5tools_print_dims(&buffer, ctx->sset->block.data, dims); else h5tools_str_append(&buffer, "DEFAULT"); - h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->blockend, h5tools_dump_header_format->blockblockend); + h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->blockend, + h5tools_dump_header_format->blockblockend); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); ctx->indent_level--; @@ -3974,27 +4057,28 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tool *------------------------------------------------------------------------- */ void -h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container, H5R_ref_t *ref_buf, int ndims) +h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container, + H5R_ref_t *ref_buf, int ndims) { - hid_t new_obj_id = H5I_INVALID_HID; - hid_t new_obj_sid = H5I_INVALID_HID; - hsize_t elmt_counter = 0; /*counts the # elements printed. */ - size_t ncols = 80; /* available output width */ - int i; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t datactx; /* print context */ + hid_t new_obj_id = H5I_INVALID_HID; + hid_t new_obj_sid = H5I_INVALID_HID; + hsize_t elmt_counter = 0; /*counts the # elements printed. */ + size_t ncols = 80; /* available output width */ + int i; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t datactx; /* print context */ H5TOOLS_START_DEBUG(""); - datactx = *ctx; /* print context */ + datactx = *ctx; /* print context */ /* Assume entire data space to be printed */ datactx.need_prefix = TRUE; HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) { - H5O_type_t obj_type = -1; /* Object type */ - H5R_type_t ref_type; /* Reference type */ + for (i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) { + H5O_type_t obj_type = -1; /* Object type */ + H5R_type_t ref_type; /* Reference type */ H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos); @@ -4002,7 +4086,8 @@ h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_contex h5tools_str_reset(&buffer); H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i); h5tools_str_sprint(&buffer, info, container, H5T_STD_REF, &ref_buf[i], &datactx); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, + (hsize_t)ndims); ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]); switch (ref_type) { @@ -4011,12 +4096,12 @@ h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_contex if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { switch (obj_type) { case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE); - //h5tools_dump_dset(stream, info, &datactx, new_obj_id); + // h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; - if(H5Dclose(new_obj_id) < 0) + if (H5Dclose(new_obj_id) < 0) H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed"); } else @@ -4037,12 +4122,12 @@ h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_contex break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); - if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE); - //h5tools_dump_dset(stream, info, &datactx, new_obj_id); + // h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; - if(H5Dclose(new_obj_id) < 0) + if (H5Dclose(new_obj_id) < 0) H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed"); } else @@ -4056,12 +4141,12 @@ h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_contex break; case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { datactx.indent_level++; h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE); - //h5tools_dump_dset(stream, info, &datactx, new_obj_id); + // h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; - if(H5Oclose(new_obj_id) < 0) + if (H5Oclose(new_obj_id) < 0) H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); } else @@ -4088,62 +4173,68 @@ h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_contex ncols = info->line_ncols; /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */ - if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); else { - if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) { H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " {"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); datactx.need_prefix = TRUE; datactx.indent_level++; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "NULL"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); datactx.indent_level--; datactx.need_prefix = TRUE; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "}"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); } else { H5S_sel_type region_type; region_type = H5Sget_select_type(new_obj_sid); - if(region_type == H5S_SEL_POINTS) { + if (region_type == H5S_SEL_POINTS) { /* Print point information */ H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2"); - h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info, &datactx, - &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter); + h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info, + &datactx, &buffer, &curr_pos, ncols, + (hsize_t)i, elmt_counter); } - else if(region_type == H5S_SEL_HYPERSLABS) { + else if (region_type == H5S_SEL_HYPERSLABS) { /* Print block information */ H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2"); - h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info, &datactx, - &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter); + h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info, + &datactx, &buffer, &curr_pos, ncols, + (hsize_t)i, elmt_counter); } else H5TOOLS_INFO("invalid region type"); } /* end else to if (h5tools_is_zero(... */ - if(H5Sclose(new_obj_sid) < 0) + if (H5Sclose(new_obj_sid) < 0) H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); } else H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); - if(H5Dclose(new_obj_id) < 0) + if (H5Dclose(new_obj_id) < 0) H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); } break; case H5R_ATTR: H5TOOLS_DEBUG("ref_type is H5R_ATTR"); - if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - if(H5Aclose(new_obj_id) < 0) + if ((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, + (size_t)ncols, (hsize_t)0, (hsize_t)0); + if (H5Aclose(new_obj_id) < 0) H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); } else { @@ -4151,19 +4242,22 @@ h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_contex h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " {"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); datactx.need_prefix = TRUE; datactx.indent_level++; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "NULL"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); datactx.indent_level--; datactx.need_prefix = TRUE; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "}"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed"); } @@ -4174,10 +4268,10 @@ h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_contex break; } /* end switch */ - if(H5Rdestroy(&ref_buf[i]) < 0) + if (H5Rdestroy(&ref_buf[i]) < 0) H5TOOLS_INFO("H5Rdestroy failed"); - H5TOOLS_DEBUG("finished reference loop:%d",i); + H5TOOLS_DEBUG("finished reference loop:%d", i); } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */ h5tools_str_close(&buffer); @@ -4194,43 +4288,44 @@ h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_contex *------------------------------------------------------------------------- */ void -h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id, int obj_data) +h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id, + int obj_data) { - H5S_class_t space_type; - int ndims; - hid_t space = H5I_INVALID_HID; - hid_t f_type = H5I_INVALID_HID; - hsize_t total_size[H5S_MAX_RANK]; - int status = -1; - h5tools_context_t datactx; /* print context */ - h5tools_str_t buffer; /* string into which to render */ - hsize_t curr_pos = 0; /* total data element position */ - size_t ncols = 80; /* available output width */ - h5tool_format_t string_dataformat; - h5tool_format_t outputformat; - H5R_ref_t *ref_buf = NULL; - - H5TOOLS_START_DEBUG(" file=%p", (void*)stream); - H5TOOLS_DEBUG("rawdata file=%p", (void*)rawdatastream); + H5S_class_t space_type; + int ndims; + hid_t space = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; + hsize_t total_size[H5S_MAX_RANK]; + int status = -1; + h5tools_context_t datactx; /* print context */ + h5tools_str_t buffer; /* string into which to render */ + hsize_t curr_pos = 0; /* total data element position */ + size_t ncols = 80; /* available output width */ + h5tool_format_t string_dataformat; + h5tool_format_t outputformat; + H5R_ref_t * ref_buf = NULL; + + H5TOOLS_START_DEBUG(" file=%p", (void *)stream); + H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream); /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); if (info->line_ncols > 0) ncols = info->line_ncols; - outputformat = *info; + outputformat = *info; string_dataformat = *info; /* print the matrix indices */ string_dataformat.pindex = ctx->display_index; - if(obj_data) { + if (obj_data) { H5TOOLS_DEBUG("dataset"); f_type = H5Dget_type(obj_id); - space = H5Dget_space(obj_id); + space = H5Dget_space(obj_id); } else { H5TOOLS_DEBUG("attribute"); f_type = H5Aget_type(obj_id); - space = H5Aget_space(obj_id); + space = H5Aget_space(obj_id); } if (string_dataformat.pindex) { @@ -4250,14 +4345,17 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->databegin, h5tools_dump_header_format->datablockbegin); - h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->databegin, + h5tools_dump_header_format->datablockbegin); + h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); if (H5Tget_class(f_type) == H5T_REFERENCE) { ctx->indent_level++; datactx = *ctx; H5TOOLS_DEBUG("reference class type"); - if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) { + if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && + !H5Tequal(f_type, H5T_STD_REF_OBJ)) { H5TOOLS_GOTO_DONE_NO_RET(); } @@ -4270,7 +4368,8 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * datactx.need_prefix = TRUE; - if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { + if (NULL != + (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { if (obj_data) { if (H5Dread(obj_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) { HDfree(ref_buf); @@ -4292,43 +4391,43 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * } else { H5TOOLS_DEBUG("Print all the values"); - datactx = *ctx; + datactx = *ctx; string_dataformat = *info; - if((datactx.display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) { + if ((datactx.display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) { H5TOOLS_DEBUG("Print 1-byte integer data as an ASCII character string"); /* - * Print 1-byte integer data as an ASCII character string - * instead of integers if the `-r' or `--string' command-line - * option was given. - * - * We don't want to modify the global dataformat, so make a - * copy of it instead. - */ + * Print 1-byte integer data as an ASCII character string + * instead of integers if the `-r' or `--string' command-line + * option was given. + * + * We don't want to modify the global dataformat, so make a + * copy of it instead. + */ string_dataformat.idx_fmt = "\""; datactx.indent_level++; datactx.need_prefix = TRUE; h5tools_simple_prefix(stream, &string_dataformat, &datactx, (hsize_t)0, 0); string_dataformat.line_multi_new = 1; - string_dataformat.str_repeat = 8; - string_dataformat.ascii = TRUE; - string_dataformat.elmt_suf1 = ""; - string_dataformat.elmt_suf2 = ""; - string_dataformat.line_suf = "\""; + string_dataformat.str_repeat = 8; + string_dataformat.ascii = TRUE; + string_dataformat.elmt_suf1 = ""; + string_dataformat.elmt_suf2 = ""; + string_dataformat.line_suf = "\""; } else { datactx.need_prefix = TRUE; } /* Print all the values. */ - if(obj_data) { + if (obj_data) { H5TOOLS_DEBUG("h5tools_dump_dset"); status = h5tools_dump_dset(stream, &string_dataformat, &datactx, obj_id); } else { /* need to call h5tools_dump_mem for the attribute data */ space_type = H5Sget_simple_extent_type(space); - if(space_type == H5S_NULL || space_type == H5S_NO_CLASS) { + if (space_type == H5S_NULL || space_type == H5S_NO_CLASS) { status = SUCCEED; } else { @@ -4337,15 +4436,17 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * } } if (datactx.display_char && H5Tget_size(f_type) == 1 && H5Tget_class(f_type) == H5T_INTEGER) { - H5TOOLS_DEBUG("Print 1-byte integer data as an ASCII character string eol=%s",string_dataformat.line_suf); - datactx.need_prefix = FALSE; - string_dataformat.arr_linebreak = 0; - string_dataformat.idx_fmt = ""; + H5TOOLS_DEBUG("Print 1-byte integer data as an ASCII character string eol=%s", + string_dataformat.line_suf); + datactx.need_prefix = FALSE; + string_dataformat.arr_linebreak = 0; + string_dataformat.idx_fmt = ""; string_dataformat.line_multi_new = 0; - string_dataformat.line_suf = ""; + string_dataformat.line_suf = ""; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\""); - h5tools_render_element(stream, &string_dataformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, &string_dataformat, &datactx, &buffer, &curr_pos, (size_t)ncols, + (hsize_t)0, (hsize_t)0); } H5TOOLS_DEBUG("Print all the values Complete"); @@ -4362,15 +4463,16 @@ done: h5tools_simple_prefix(stream, &outputformat, ctx, (hsize_t)0, 0); h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datablockend)) { + if (HDstrlen(h5tools_dump_header_format->datablockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datablockend); - if(HDstrlen(h5tools_dump_header_format->dataend)) + if (HDstrlen(h5tools_dump_header_format->dataend)) h5tools_str_append(&buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->dataend)) + if (HDstrlen(h5tools_dump_header_format->dataend)) h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataend); - h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); if (ctx->sset && obj_data) { ctx->indent_level--; @@ -4379,17 +4481,17 @@ done: h5tools_simple_prefix(stream, &outputformat, ctx, (hsize_t)0, 0); h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->subsettingblockend)) { + if (HDstrlen(h5tools_dump_header_format->subsettingblockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->subsettingblockend); - if(HDstrlen(h5tools_dump_header_format->subsettingend)) + if (HDstrlen(h5tools_dump_header_format->subsettingend)) h5tools_str_append(&buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->subsettingend)) + if (HDstrlen(h5tools_dump_header_format->subsettingend)) h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->subsettingend); - h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, + (hsize_t)0); } h5tools_str_close(&buffer); H5TOOLS_ENDDEBUG(""); } - diff --git a/tools/lib/h5tools_dump.h b/tools/lib/h5tools_dump.h index add2e46..6383872 100644 --- a/tools/lib/h5tools_dump.h +++ b/tools/lib/h5tools_dump.h @@ -23,69 +23,75 @@ Note: these are defined in H5Zprivate, they are duplicated here. */ -#define H5_SZIP_LSB_OPTION_MASK 8 -#define H5_SZIP_MSB_OPTION_MASK 16 -#define H5_SZIP_RAW_OPTION_MASK 128 +#define H5_SZIP_LSB_OPTION_MASK 8 +#define H5_SZIP_MSB_OPTION_MASK 16 +#define H5_SZIP_RAW_OPTION_MASK 128 #ifdef __cplusplus extern "C" { #endif -H5TOOLS_DLLVAR table_t *h5dump_type_table; /*type table reference for datatype dump */ +H5TOOLS_DLLVAR table_t *h5dump_type_table; /*type table reference for datatype dump */ /* Definitions of useful routines */ -H5TOOLS_DLL void h5tools_dump_init(void); +H5TOOLS_DLL void h5tools_dump_init(void); -H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t dset); -H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t obj_id); -H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem); -H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t type); -H5TOOLS_DLL void h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t space); -H5TOOLS_DLL void h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - const char *attr_name, hid_t attr_id); -H5TOOLS_DLL void h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t oid); -H5TOOLS_DLL void h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t dcpl, hid_t type_id, hid_t obj_id); -H5TOOLS_DLL void h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t obj_id); +H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t dset); +H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx /*in,out*/, + hid_t obj_id); +H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t container, unsigned flags, + hsize_t nelmts, hid_t type, void *_mem); +H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t type); +H5TOOLS_DLL void h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t space); +H5TOOLS_DLL void h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, const char *attr_name, + hid_t attr_id); +H5TOOLS_DLL void h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t oid); +H5TOOLS_DLL void h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t dcpl, hid_t type_id, + hid_t obj_id); +H5TOOLS_DLL void h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t obj_id); H5TOOLS_DLL void h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hid_t obj_id, int obj_data); + hid_t obj_id, int obj_data); H5TOOLS_DLL void h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hid_t container, H5R_ref_t *ref_buf, int ndims); -H5TOOLS_DLL hbool_t h5tools_dump_region_attribute(hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, hsize_t elmt_counter); + hid_t container, H5R_ref_t *ref_buf, int ndims); +H5TOOLS_DLL hbool_t h5tools_dump_region_attribute(hid_t region_id, FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, h5tools_str_t *buffer, + hsize_t *curr_pos, size_t ncols, + hsize_t region_elmt_counter, hsize_t elmt_counter); -H5TOOLS_DLL hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, hsize_t elmt_counter); +H5TOOLS_DLL hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, + const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, h5tools_str_t *buffer, + hsize_t *curr_pos, size_t ncols, + hsize_t region_elmt_counter, hsize_t elmt_counter); -H5TOOLS_DLL hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, hsize_t elmt_counter); +H5TOOLS_DLL hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, FILE *stream, + const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, h5tools_str_t *buffer, + hsize_t *curr_pos, size_t ncols, + hsize_t region_elmt_counter, hsize_t elmt_counter); -H5TOOLS_DLL int h5tools_print_datatype(FILE *stream, - h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t type, int object_search); -H5TOOLS_DLL int h5tools_print_dataspace(h5tools_str_t *buffer/*in,out*/, - hid_t space); -H5TOOLS_DLL int h5tools_print_enum(FILE *stream, - h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t type); -H5TOOLS_DLL void h5tools_print_fill_value( - h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, - hid_t dcpl, hid_t type_id, hid_t obj_id); -H5TOOLS_DLL void h5tools_print_packed_bits(h5tools_str_t *buffer/*in,out*/, hid_t type); +H5TOOLS_DLL int h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer /*in,out*/, + const h5tool_format_t *info, h5tools_context_t *ctx /*in,out*/, + hid_t type, int object_search); +H5TOOLS_DLL int h5tools_print_dataspace(h5tools_str_t *buffer /*in,out*/, hid_t space); +H5TOOLS_DLL int h5tools_print_enum(FILE *stream, h5tools_str_t *buffer /*in,out*/, + const h5tool_format_t *info, h5tools_context_t *ctx /*in,out*/, + hid_t type); +H5TOOLS_DLL void h5tools_print_fill_value(h5tools_str_t *buffer /*in,out*/, const h5tool_format_t *info, + h5tools_context_t *ctx /*in,out*/, hid_t dcpl, hid_t type_id, + hid_t obj_id); +H5TOOLS_DLL void h5tools_print_packed_bits(h5tools_str_t *buffer /*in,out*/, hid_t type); #ifdef __cplusplus } #endif #endif /* H5TOOLS_DUMP_H__ */ - diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h index 764fb91..7b611c2 100644 --- a/tools/lib/h5tools_error.h +++ b/tools/lib/h5tools_error.h @@ -21,7 +21,7 @@ #include "H5Eprivate.h" /* Error handling */ /* tools-HDF5 Error variables */ -H5TOOLS_DLLVAR int H5tools_INDENT_g; +H5TOOLS_DLLVAR int H5tools_INDENT_g; H5TOOLS_DLLVAR hid_t H5tools_ERR_STACK_g; H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g; H5TOOLS_DLLVAR hid_t H5E_tools_g; @@ -41,77 +41,77 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g; /* * H5TOOLS_INIT_ERROR macro, used to initialize error reporting. */ -#define H5TOOLS_INIT_ERROR() \ -do { \ - char lib_str[256]; \ - \ - /* Initialize library version string for error class */ \ - HDsnprintf(lib_str, sizeof(lib_str), "%d.%d.%d", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); \ - \ - /* Create new HDF5 error stack for the tools to use */ \ - if ((H5tools_ERR_STACK_g = H5Ecreate_stack()) < 0) \ - HDfprintf(stderr, "Failed to create HDF5 tools error stack\n"); \ - \ - /* Register errors from the HDF5 tools as a new error class */ \ - if ((H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str)) < 0) \ - HDfprintf(stderr, "Failed to register HDF5 tools error class\n"); \ - \ - /* Create a new HDF5 major error message for errors from the tools library */ \ - if ((H5E_tools_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library")) < 0) \ - HDfprintf(stderr, "Failed to register major error message for tools library errors\n"); \ - \ - /* Create a new HDF5 minor error message for errors from the tools library */ \ - if ((H5E_tools_min_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "error in function")) < 0) \ - HDfprintf(stderr, "Failed to register minor error message for tools library errors\n"); \ - \ - /* Create a new HDF5 minor error message for info messages from the tools library */ \ - if ((H5E_tools_min_info_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function info")) < 0) \ - HDfprintf(stderr, "Failed to register minor error message for tools library info messages\n"); \ - \ - /* Create a new HDF5 minor error message for debug messages from the tools library */ \ - if ((H5E_tools_min_dbg_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function debug")) < 0) \ - HDfprintf(stderr, "Failed to register minor error message for tools library debug messages\n"); \ -} while(0) +#define H5TOOLS_INIT_ERROR() \ + do { \ + char lib_str[256]; \ + \ + /* Initialize library version string for error class */ \ + HDsnprintf(lib_str, sizeof(lib_str), "%d.%d.%d", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); \ + \ + /* Create new HDF5 error stack for the tools to use */ \ + if ((H5tools_ERR_STACK_g = H5Ecreate_stack()) < 0) \ + HDfprintf(stderr, "Failed to create HDF5 tools error stack\n"); \ + \ + /* Register errors from the HDF5 tools as a new error class */ \ + if ((H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str)) < 0) \ + HDfprintf(stderr, "Failed to register HDF5 tools error class\n"); \ + \ + /* Create a new HDF5 major error message for errors from the tools library */ \ + if ((H5E_tools_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library")) < 0) \ + HDfprintf(stderr, "Failed to register major error message for tools library errors\n"); \ + \ + /* Create a new HDF5 minor error message for errors from the tools library */ \ + if ((H5E_tools_min_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "error in function")) < 0) \ + HDfprintf(stderr, "Failed to register minor error message for tools library errors\n"); \ + \ + /* Create a new HDF5 minor error message for info messages from the tools library */ \ + if ((H5E_tools_min_info_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function info")) < 0) \ + HDfprintf(stderr, "Failed to register minor error message for tools library info messages\n"); \ + \ + /* Create a new HDF5 minor error message for debug messages from the tools library */ \ + if ((H5E_tools_min_dbg_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function debug")) < 0) \ + HDfprintf(stderr, "Failed to register minor error message for tools library debug messages\n"); \ + } while (0) /* * H5TOOLS_CLOSE_ERROR macro, used to terminate error reporting. */ -#define H5TOOLS_CLOSE_ERROR() \ -do { \ - /* Close all error messages created by H5TOOLS_INIT_ERROR() */ \ - if (H5Eclose_msg(H5E_tools_min_dbg_id_g) < 0) \ - HDfprintf(stderr, "Failed to close minor error message for tools library debug messages\n"); \ - if (H5Eclose_msg(H5E_tools_min_info_id_g) < 0) \ - HDfprintf(stderr, "Failed to close minor error message for tools library info messages\n"); \ - if (H5Eclose_msg(H5E_tools_min_id_g) < 0) \ - HDfprintf(stderr, "Failed to close minor error message for tools library errors\n"); \ - if (H5Eclose_msg(H5E_tools_g) < 0) \ - HDfprintf(stderr, "Failed to close major error message for tools library errors\n"); \ - \ - /* Unregister the HDF5 tools error class */ \ - if (H5Eunregister_class(H5tools_ERR_CLS_g) < 0) \ - HDfprintf(stderr, "Failed to unregister the HDF5 tools error class\n"); \ - \ - /* Close the tools error stack */ \ - if (H5Eclose_stack(H5tools_ERR_STACK_g) < 0) \ - HDfprintf(stderr, "Failed to close HDF5 tools error stack\n"); \ -} while(0) +#define H5TOOLS_CLOSE_ERROR() \ + do { \ + /* Close all error messages created by H5TOOLS_INIT_ERROR() */ \ + if (H5Eclose_msg(H5E_tools_min_dbg_id_g) < 0) \ + HDfprintf(stderr, "Failed to close minor error message for tools library debug messages\n"); \ + if (H5Eclose_msg(H5E_tools_min_info_id_g) < 0) \ + HDfprintf(stderr, "Failed to close minor error message for tools library info messages\n"); \ + if (H5Eclose_msg(H5E_tools_min_id_g) < 0) \ + HDfprintf(stderr, "Failed to close minor error message for tools library errors\n"); \ + if (H5Eclose_msg(H5E_tools_g) < 0) \ + HDfprintf(stderr, "Failed to close major error message for tools library errors\n"); \ + \ + /* Unregister the HDF5 tools error class */ \ + if (H5Eunregister_class(H5tools_ERR_CLS_g) < 0) \ + HDfprintf(stderr, "Failed to unregister the HDF5 tools error class\n"); \ + \ + /* Close the tools error stack */ \ + if (H5Eclose_stack(H5tools_ERR_STACK_g) < 0) \ + HDfprintf(stderr, "Failed to close HDF5 tools error stack\n"); \ + } while (0) /* * H5TOOLS_PUSH_ERROR macro, used to push an error to an error stack. Not meant to * be called directly. */ -#define H5TOOLS_PUSH_ERROR(estack_id, err_cls, maj_err_id, min_err_id, ...) \ -do { \ - if (enable_error_stack > 0) { \ - if (estack_id >= 0 && err_cls >= 0) \ - H5Epush2(estack_id, __FILE__, FUNC, __LINE__, err_cls, maj_err_id, min_err_id, __VA_ARGS__); \ - else { \ - HDfprintf(stderr, __VA_ARGS__); \ - HDfprintf(stderr, "\n"); \ - } \ - } \ -} while(0) +#define H5TOOLS_PUSH_ERROR(estack_id, err_cls, maj_err_id, min_err_id, ...) \ + do { \ + if (enable_error_stack > 0) { \ + if (estack_id >= 0 && err_cls >= 0) \ + H5Epush2(estack_id, __FILE__, FUNC, __LINE__, err_cls, maj_err_id, min_err_id, __VA_ARGS__); \ + else { \ + HDfprintf(stderr, __VA_ARGS__); \ + HDfprintf(stderr, "\n"); \ + } \ + } \ + } while (0) /* * H5TOOLS_ERROR macro, used to facilitate error reporting within a function body. @@ -121,100 +121,102 @@ do { * after the `done' label, in which case an infinite loop would ensue if control branched * backwards. */ -#define H5TOOLS_ERROR(ret_val, ...) \ -do { \ - H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, __VA_ARGS__); \ - ret_value = ret_val; \ -} while(0) +#define H5TOOLS_ERROR(ret_val, ...) \ + do { \ + H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \ + __VA_ARGS__); \ + ret_value = ret_val; \ + } while (0) /* * H5TOOLS_GOTO_ERROR macro, used to facilitate error reporting within a function body. * The arguments are the return value and an error string. The return value is assigned * to a variable `ret_value' and control branches to the `done' label. */ -#define H5TOOLS_GOTO_ERROR(ret_val, ...) \ -do { \ - H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, __VA_ARGS__); \ - H5TOOLS_GOTO_DONE(ret_val); \ -} while(0) +#define H5TOOLS_GOTO_ERROR(ret_val, ...) \ + do { \ + H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \ + __VA_ARGS__); \ + H5TOOLS_GOTO_DONE(ret_val); \ + } while (0) /* * H5TOOLS_GOTO_DONE macro, used to facilitate normal return within a function body. * The argument is the return value which is assigned to the `ret_value' * variable. Control branches to the `done' label. */ -#define H5TOOLS_GOTO_DONE(ret_val) \ -do { \ - ret_value = ret_val; \ - goto done; \ -} while(0) +#define H5TOOLS_GOTO_DONE(ret_val) \ + do { \ + ret_value = ret_val; \ + goto done; \ + } while (0) /* * H5TOOLS_GOTO_DONE_NO_RET macro, used to facilitate normal return within a function body. * Control simply branches to the `done' label without setting any return value. */ -#define H5TOOLS_GOTO_DONE_NO_RET() \ -do { \ - goto done; \ -} while(0) +#define H5TOOLS_GOTO_DONE_NO_RET() \ + do { \ + goto done; \ + } while (0) /* * H5TOOLS_INFO macro, used to facilitate error reporting. The arguments are * a description of the error. */ -#define H5TOOLS_INFO(...) \ -do { \ - H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_info_id_g, __VA_ARGS__); \ -} while(0) +#define H5TOOLS_INFO(...) \ + do { \ + H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_info_id_g, \ + __VA_ARGS__); \ + } while (0) #ifdef H5_TOOLS_DEBUG -#define H5TOOLS_START_DEBUG(...) \ -do { \ - H5tools_INDENT_g += 2; \ - HDfprintf(stderr, "%*sENTER %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ - HDfprintf(stderr, __VA_ARGS__); \ - HDfprintf(stderr, "\n"); \ - HDfflush(stderr); \ -} while(0) - -#define H5TOOLS_DEBUG(...) \ -do { \ - HDfprintf(stderr, "%*s %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ - HDfprintf(stderr, __VA_ARGS__); \ - HDfprintf(stderr, "\n"); \ - HDfflush(stderr); \ -} while(0) - -#define H5TOOLS_ENDDEBUG(...) \ -do { \ - HDfprintf(stderr, "%*sEXIT %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ - HDfprintf(stderr, __VA_ARGS__); \ - HDfprintf(stderr, "\n"); \ - H5tools_INDENT_g -= 2; \ - HDfflush(stderr); \ -} while(0) +#define H5TOOLS_START_DEBUG(...) \ + do { \ + H5tools_INDENT_g += 2; \ + HDfprintf(stderr, "%*sENTER %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ + HDfprintf(stderr, __VA_ARGS__); \ + HDfprintf(stderr, "\n"); \ + HDfflush(stderr); \ + } while (0) + +#define H5TOOLS_DEBUG(...) \ + do { \ + HDfprintf(stderr, "%*s %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ + HDfprintf(stderr, __VA_ARGS__); \ + HDfprintf(stderr, "\n"); \ + HDfflush(stderr); \ + } while (0) + +#define H5TOOLS_ENDDEBUG(...) \ + do { \ + HDfprintf(stderr, "%*sEXIT %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ + HDfprintf(stderr, __VA_ARGS__); \ + HDfprintf(stderr, "\n"); \ + H5tools_INDENT_g -= 2; \ + HDfflush(stderr); \ + } while (0) #else -#define H5TOOLS_START_DEBUG(...) \ -do { \ - ; \ -} while(0) +#define H5TOOLS_START_DEBUG(...) \ + do { \ + ; \ + } while (0) -#define H5TOOLS_DEBUG(...) \ -do { \ - ; \ -} while(0) +#define H5TOOLS_DEBUG(...) \ + do { \ + ; \ + } while (0) -#define H5TOOLS_ENDDEBUG(...) \ -do { \ - ; \ -} while(0) +#define H5TOOLS_ENDDEBUG(...) \ + do { \ + ; \ + } while (0) #endif - /* Macro for "catching" flow of control when an error occurs. Note that the * H5_LEAVE macro won't jump back here once it's past this point. */ @@ -241,11 +243,11 @@ do { \ * The return value is assigned to a variable `ret_value' and control branches * to the `catch_except' label, if we're not already past it. */ -#define H5TOOLS_THROW(ret_val, ...) \ -do { \ - H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, __VA_ARGS__); \ - H5_LEAVE(ret_val) \ -} while(0) +#define H5TOOLS_THROW(ret_val, ...) \ + do { \ + H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \ + __VA_ARGS__); \ + H5_LEAVE(ret_val) \ + } while (0) #endif /* H5TOOLS_ERROR_H_ */ - diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index 0e4c476..04c139b 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -18,11 +18,10 @@ * print a warning message *------------------------------------------------------------------------- */ -static void print_filter_warning(const char *dname, const char *fname) +static void +print_filter_warning(const char *dname, const char *fname) { - HDfprintf(stderr, - "Warning: dataset <%s> cannot be read, %s filter is not available\n", - dname, fname); + HDfprintf(stderr, "Warning: dataset <%s> cannot be read, %s filter is not available\n", dname, fname); } /*------------------------------------------------------------------------- @@ -40,14 +39,14 @@ static void print_filter_warning(const char *dname, const char *fname) *------------------------------------------------------------------------- */ int -h5tools_canreadf(const char* name, /* object name, serves also as boolean print */ - hid_t dcpl_id) /* dataset creation property list */ +h5tools_canreadf(const char *name, /* object name, serves also as boolean print */ + hid_t dcpl_id) /* dataset creation property list */ { - int nfilters; /* number of filters */ - H5Z_filter_t filtn; /* filter identification number */ - int i; /* index */ - int udfilter_avail; /* index */ - int ret_value = 1; + int nfilters; /* number of filters */ + H5Z_filter_t filtn; /* filter identification number */ + int i; /* index */ + int udfilter_avail; /* index */ + int ret_value = 1; /* get information about filters */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) @@ -59,73 +58,73 @@ h5tools_canreadf(const char* name, /* object name, serves also as boolean pr /* check availability of filters */ for (i = 0; i < nfilters; i++) { - if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, 0, 0, 0, (size_t) 0, 0, NULL)) < 0) + if ((filtn = H5Pget_filter2(dcpl_id, (unsigned)i, 0, 0, 0, (size_t)0, 0, NULL)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_filter2 failed"); switch (filtn) { - /*------------------------------------------------------------------------- - * user defined filter - *------------------------------------------------------------------------- - */ - default: - if ((udfilter_avail = H5Zfilter_avail(filtn)) < 0) { - H5TOOLS_GOTO_ERROR(FAIL, "H5Zfilter_avail failed"); - } - else if (!udfilter_avail) { - if (name) - print_filter_warning(name, "user defined"); - ret_value = 0; - } - break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE 1 , deflation like gzip + * user defined filter *------------------------------------------------------------------------- */ - case H5Z_FILTER_DEFLATE: + default: + if ((udfilter_avail = H5Zfilter_avail(filtn)) < 0) { + H5TOOLS_GOTO_ERROR(FAIL, "H5Zfilter_avail failed"); + } + else if (!udfilter_avail) { + if (name) + print_filter_warning(name, "user defined"); + ret_value = 0; + } + break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_DEFLATE 1 , deflation like gzip + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_DEFLATE: #ifndef H5_HAVE_FILTER_DEFLATE - if (name) - print_filter_warning(name,"deflate"); - ret_value = 0; + if (name) + print_filter_warning(name, "deflate"); + ret_value = 0; #endif - break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP 4 , szip compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SZIP: + break; + /*------------------------------------------------------------------------- + * H5Z_FILTER_SZIP 4 , szip compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SZIP: #ifndef H5_HAVE_FILTER_SZIP - if (name) - print_filter_warning(name,"SZIP"); - ret_value = 0; + if (name) + print_filter_warning(name, "SZIP"); + ret_value = 0; #endif - break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_SHUFFLE 2 , shuffle the data - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SHUFFLE: - break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_FLETCHER32: - break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_NBIT - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_NBIT: - break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_SCALEOFFSET - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SCALEOFFSET: - break; - }/*switch*/ - }/*for*/ + break; + /*------------------------------------------------------------------------- + * H5Z_FILTER_SHUFFLE 2 , shuffle the data + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SHUFFLE: + break; + /*------------------------------------------------------------------------- + * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_FLETCHER32: + break; + /*------------------------------------------------------------------------- + * H5Z_FILTER_NBIT + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_NBIT: + break; + /*------------------------------------------------------------------------- + * H5Z_FILTER_SCALEOFFSET + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SCALEOFFSET: + break; + } /*switch*/ + } /*for*/ done: return ret_value; @@ -147,63 +146,64 @@ h5tools_can_encode(H5Z_filter_t filtn) int ret_value = 1; switch (filtn) { - /* user defined filter */ - default: - H5TOOLS_GOTO_DONE(0); - break; - case H5Z_FILTER_DEFLATE: + /* user defined filter */ + default: + H5TOOLS_GOTO_DONE(0); + break; + case H5Z_FILTER_DEFLATE: #ifndef H5_HAVE_FILTER_DEFLATE - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(0); #endif break; - case H5Z_FILTER_SZIP: + case H5Z_FILTER_SZIP: #ifndef H5_HAVE_FILTER_SZIP - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(0); #else { unsigned int filter_config_flags; if (H5Zget_filter_info(filtn, &filter_config_flags) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Zget_filter_info failed"); - if ((filter_config_flags - & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) { + if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) { /* filter present but neither encode nor decode is supported (???) */ H5TOOLS_GOTO_ERROR(FAIL, "neither encode nor decode is supported"); } - else if ((filter_config_flags - & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_DECODE_ENABLED) { + else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + H5Z_FILTER_CONFIG_DECODE_ENABLED) { /* decoder only: read but not write */ H5TOOLS_GOTO_DONE(0); } - else if ((filter_config_flags - & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_ENCODE_ENABLED) { + else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + H5Z_FILTER_CONFIG_ENCODE_ENABLED) { /* encoder only: write but not read (???) */ H5TOOLS_GOTO_ERROR(FAIL, "encoder only: write but not read"); } - else if ((filter_config_flags - & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) - == (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) { + else if ((filter_config_flags & + (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == + (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) { H5TOOLS_GOTO_DONE(1); } } #endif break; - case H5Z_FILTER_SHUFFLE: + case H5Z_FILTER_SHUFFLE: break; - case H5Z_FILTER_FLETCHER32: + case H5Z_FILTER_FLETCHER32: break; - case H5Z_FILTER_NBIT: + case H5Z_FILTER_NBIT: break; - case H5Z_FILTER_SCALEOFFSET: + case H5Z_FILTER_SCALEOFFSET: break; - }/*switch*/ + } /*switch*/ done: return ret_value; } - diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index 0e1fa03..8d18f0e 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -19,7 +19,6 @@ #include "h5trav.h" #include "H5VLnative_private.h" - /* * Table to look up a path name for an object * reference. @@ -36,11 +35,11 @@ typedef struct { H5O_token_t obj_token; /* Object token */ - char *path; /* Object path */ + char * path; /* Object path */ } ref_path_node_t; -static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */ -static hid_t thefile = (-1); +static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */ +static hid_t thefile = (-1); static int ref_path_table_put(const char *, const H5O_token_t *token); @@ -58,14 +57,14 @@ static int ref_path_table_put(const char *, const H5O_token_t *token); *------------------------------------------------------------------------- */ static herr_t -free_ref_path_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/) +free_ref_path_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data /*in,out*/) { ref_path_node_t *node = (ref_path_node_t *)item; HDfree(node->path); HDfree(node); - return(0); + return (0); } /*------------------------------------------------------------------------- @@ -81,11 +80,11 @@ free_ref_path_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op *------------------------------------------------------------------------- */ static herr_t -init_ref_path_cb(const char *obj_name, const H5O_info2_t *oinfo, - const char *already_seen, void H5_ATTR_UNUSED *_udata) +init_ref_path_cb(const char *obj_name, const H5O_info2_t *oinfo, const char *already_seen, + void H5_ATTR_UNUSED *_udata) { /* Check if the object is already in the path table */ - if(NULL == already_seen) { + if (NULL == already_seen) { /* Insert the object into the path table */ ref_path_table_put(obj_name, &oinfo->token); } /* end if */ @@ -109,11 +108,11 @@ init_ref_path_cb(const char *obj_name, const H5O_info2_t *oinfo, static int ref_path_table_cmp(const void *key1, const void *key2) { - const H5O_token_t *token1 = (const H5O_token_t *)key1; - const H5O_token_t *token2 = (const H5O_token_t *)key2; - int cmp_value = 0; + const H5O_token_t *token1 = (const H5O_token_t *)key1; + const H5O_token_t *token2 = (const H5O_token_t *)key2; + int cmp_value = 0; - if(thefile > 0) + if (thefile > 0) H5Otoken_cmp(thefile, token1, token2, &cmp_value); else cmp_value = HDmemcmp(token1, token2, sizeof(H5O_token_t)); @@ -136,18 +135,18 @@ static int init_ref_path_table(void) { /* Sanity check */ - if(thefile > 0) { + if (thefile > 0) { /* Create skip list to store reference path information */ - if((ref_path_table = H5SL_create(H5SL_TYPE_GENERIC, ref_path_table_cmp)) == NULL) + if ((ref_path_table = H5SL_create(H5SL_TYPE_GENERIC, ref_path_table_cmp)) == NULL) return (-1); /* Iterate over objects in this file */ - if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL, H5O_INFO_BASIC) < 0) { + if (h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL, H5O_INFO_BASIC) < 0) { error_msg("unable to construct reference path table\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - return(0); + return (0); } else return (-1); @@ -170,10 +169,10 @@ int term_ref_path_table(void) { /* Destroy reference path table, freeing all memory */ - if(ref_path_table) + if (ref_path_table) H5SL_destroy(ref_path_table, free_ref_path_info, NULL); - return(0); + return (0); } /*------------------------------------------------------------------------- @@ -198,24 +197,24 @@ ref_path_table_lookup(const char *thepath, H5O_token_t *token) { H5O_info2_t oi; - if((thepath == NULL) || (HDstrlen(thepath) == 0)) + if ((thepath == NULL) || (HDstrlen(thepath) == 0)) return -1; /* Allow lookups on the root group, even though it doesn't have any link info */ - if(HDstrcmp(thepath, "/")) { - H5L_info2_t li; + if (HDstrcmp(thepath, "/")) { + H5L_info2_t li; /* Check for external link first, so we don't return the OID of an object in another file */ - if(H5Lget_info2(thefile, thepath, &li, H5P_DEFAULT) < 0) + if (H5Lget_info2(thefile, thepath, &li, H5P_DEFAULT) < 0) return -1; /* UD links can't be followed, so they always "dangle" like soft links. */ - if(li.type >= H5L_TYPE_UD_MIN) + if (li.type >= H5L_TYPE_UD_MIN) return -1; } /* end if */ /* Get the object info now */ /* (returns failure for dangling soft links) */ - if(H5Oget_info_by_name3(thefile, thepath, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + if (H5Oget_info_by_name3(thefile, thepath, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) return -1; /* Return object token through parameter */ @@ -248,14 +247,14 @@ ref_path_table_put(const char *path, const H5O_token_t *token) { ref_path_node_t *new_node; - if(ref_path_table && path) { - if((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL) - return(-1); + if (ref_path_table && path) { + if ((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL) + return (-1); HDmemcpy(&new_node->obj_token, token, sizeof(H5O_token_t)); new_node->path = HDstrdup(path); - return(H5SL_insert(ref_path_table, new_node, &(new_node->obj_token))); + return (H5SL_insert(ref_path_table, new_node, &(new_node->obj_token))); } else return (-1); @@ -266,7 +265,9 @@ ref_path_table_put(const char *path, const H5O_token_t *token) */ int xid = 1; -int get_next_xid(void) { +int +get_next_xid(void) +{ return xid++; } @@ -279,10 +280,11 @@ int get_next_xid(void) { haddr_t fake_xid = HADDR_MAX; void -get_fake_token(H5O_token_t *token) { - if(thefile > 0) { +get_fake_token(H5O_token_t *token) +{ + if (thefile > 0) { /* TODO: potential for this to be called with non-native connector objects */ - if(H5VLnative_addr_to_token(thefile, fake_xid, token) < 0) + if (H5VLnative_addr_to_token(thefile, fake_xid, token) < 0) *token = H5O_TOKEN_UNDEF; fake_xid--; } @@ -305,7 +307,7 @@ ref_path_table_gen_fake(const char *path, H5O_token_t *token) get_fake_token(token); /* Create ref path table, if it hasn't already been created */ - if(ref_path_table == NULL) + if (ref_path_table == NULL) init_ref_path_table(); /* Insert "fake" object into table */ @@ -328,25 +330,25 @@ ref_path_table_gen_fake(const char *path, H5O_token_t *token) const char * lookup_ref_path(H5R_ref_t refbuf) { - H5O_info2_t oinfo; - H5R_type_t ref_type; - hid_t ref_object; + H5O_info2_t oinfo; + H5R_type_t ref_type; + hid_t ref_object; ref_path_node_t *node; /* Be safer for h5ls */ - if(thefile < 0) - return(NULL); + if (thefile < 0) + return (NULL); /* Retrieve reference type */ - if(H5R_BADTYPE == (ref_type = H5Rget_type(&refbuf))) - return(NULL); + if (H5R_BADTYPE == (ref_type = H5Rget_type(&refbuf))) + return (NULL); /* Open the referenced object */ switch (ref_type) { case H5R_OBJECT1: case H5R_OBJECT2: - if((ref_object = H5Ropen_object(&refbuf, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return(NULL); + if ((ref_object = H5Ropen_object(&refbuf, H5P_DEFAULT, H5P_DEFAULT)) < 0) + return (NULL); break; /* Invalid referenced object type */ @@ -356,20 +358,20 @@ lookup_ref_path(H5R_ref_t refbuf) case H5R_MAXTYPE: case H5R_BADTYPE: default: - return(NULL); + return (NULL); } /* Retrieve info about the referenced object */ - if(H5Oget_info3(ref_object, &oinfo, H5O_INFO_ALL) < 0) - return(NULL); + if (H5Oget_info3(ref_object, &oinfo, H5O_INFO_ALL) < 0) + return (NULL); /* Create ref path table, if it hasn't already been created */ - if(ref_path_table == NULL) + if (ref_path_table == NULL) init_ref_path_table(); node = (ref_path_node_t *)H5SL_search(ref_path_table, &oinfo.token); - return(node ? node->path : NULL); + return (node ? node->path : NULL); } /*------------------------------------------------------------------------- @@ -394,4 +396,3 @@ fill_ref_path_table(hid_t fid) return 0; } - diff --git a/tools/lib/h5tools_ref.h b/tools/lib/h5tools_ref.h index debbea1..1be94a2 100644 --- a/tools/lib/h5tools_ref.h +++ b/tools/lib/h5tools_ref.h @@ -33,4 +33,3 @@ H5TOOLS_DLL int term_ref_path_table(void); #endif #endif - diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 1c573a7..03de3ad 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -15,17 +15,17 @@ * Purpose: These are string functions for us to use and abuse. */ #include "H5private.h" -#include "h5tools.h" /* for h5tool_format_t structure */ +#include "h5tools.h" /* for h5tool_format_t structure */ #include "h5tools_ref.h" -#include "h5tools_str.h" /* function prototypes */ +#include "h5tools_str.h" /* function prototypes */ /* Copied from hl/src/H5LDprivate.h */ /* Info about the list of comma-separated compound fields */ typedef struct H5LD_memb_t { - size_t tot_offset; - size_t last_tsize; - hid_t last_tid; - char **names; + size_t tot_offset; + size_t last_tsize; + hid_t last_tid; + char **names; } H5LD_memb_t; /* @@ -42,12 +42,12 @@ typedef struct H5LD_memb_t { #define REPEAT_VERBOSE /* Variable length string datatype */ -#define STR_INIT_LEN 4096 /*initial length */ +#define STR_INIT_LEN 4096 /*initial length */ -static char *h5tools_escape(char *s, size_t size); -static hbool_t h5tools_str_is_zero(const void *_mem, size_t size); -static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch); -void h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, h5tools_context_t *ctx); +static char * h5tools_escape(char *s, size_t size); +static hbool_t h5tools_str_is_zero(const void *_mem, size_t size); +static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch); +void h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, h5tools_context_t *ctx); /*------------------------------------------------------------------------- * Function: h5tools_str_close @@ -105,23 +105,23 @@ h5tools_str_len(h5tools_str_t *str) *------------------------------------------------------------------------- */ char * -h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) +h5tools_str_append(h5tools_str_t *str /*in,out*/, const char *fmt, ...) { - va_list ap; + va_list ap; /* Make sure we have some memory into which to print */ - if(!str->s || str->nalloc <= 0) + if (!str->s || str->nalloc <= 0) h5tools_str_reset(str); - if(HDstrlen(fmt) == 0) + if (HDstrlen(fmt) == 0) /* nothing to print */ return str->s; /* Format the arguments and append to the value already in `str' */ - while(1) { + while (1) { /* How many bytes available for new value, counting the new NUL */ int nchars = -1; - size_t avail = str->nalloc - str->len; + size_t avail = str->nalloc - str->len; HDva_start(ap, fmt); nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap); @@ -138,11 +138,11 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) * to lack of buffer size, so try one more time after realloc more * buffer size before return NULL. */ - if(nchars < 0) + if (nchars < 0) /* failure, such as bad format */ return NULL; - if((size_t) nchars >= avail || (0 == nchars && (HDstrcmp(fmt, "%s")))) { + if ((size_t)nchars >= avail || (0 == nchars && (HDstrcmp(fmt, "%s")))) { /* Truncation return value as documented by C99, or zero return value with either of the * following conditions, each of which indicates that the proper C99 return value probably * should have been positive when the format string is @@ -151,7 +151,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) */ size_t newsize = MAX(str->len + (size_t)nchars + 1, 2 * str->nalloc); HDassert(newsize > str->nalloc); /*overflow*/ - str->s = (char*)HDrealloc(str->s, newsize); + str->s = (char *)HDrealloc(str->s, newsize); HDassert(str->s); str->nalloc = newsize; } @@ -180,16 +180,16 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) *------------------------------------------------------------------------- */ char * -h5tools_str_reset(h5tools_str_t *str/*in,out*/) +h5tools_str_reset(h5tools_str_t *str /*in,out*/) { - if(!str->s || str->nalloc <= 0) { + if (!str->s || str->nalloc <= 0) { str->nalloc = STR_INIT_LEN; - str->s = (char*)HDmalloc(str->nalloc); + str->s = (char *)HDmalloc(str->nalloc); HDassert(str->s); } str->s[0] = '\0'; - str->len = 0; + str->len = 0; return str->s; } @@ -207,10 +207,10 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/) *------------------------------------------------------------------------- */ char * -h5tools_str_trunc(h5tools_str_t *str/*in,out*/, size_t size) +h5tools_str_trunc(h5tools_str_t *str /*in,out*/, size_t size) { - if(size < str->len) { - str->len = size; + if (size < str->len) { + str->len = size; str->s[size] = '\0'; } @@ -235,26 +235,26 @@ h5tools_str_trunc(h5tools_str_t *str/*in,out*/, size_t size) *------------------------------------------------------------------------- */ char * -h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) +h5tools_str_fmt(h5tools_str_t *str /*in,out*/, size_t start, const char *fmt) { - char _temp[1024], *temp = _temp; + char _temp[1024], *temp = _temp; HDassert(str); HDassert(fmt); /* If the format string is simply "%s" then don't bother doing anything */ - if(!HDstrcmp(fmt, "%s")) + if (!HDstrcmp(fmt, "%s")) return str->s; /* * Save the input value if there is a `%' anywhere in FMT. Otherwise * don't bother because we don't need a temporary copy. */ - if(HDstrchr(fmt, '%')) { + if (HDstrchr(fmt, '%')) { size_t n = sizeof(_temp); - if(str->len - start + 1 > n) { - n = str->len - start + 1; - temp = (char*)HDmalloc(n); + if (str->len - start + 1 > n) { + n = str->len - start + 1; + temp = (char *)HDmalloc(n); HDassert(temp); } @@ -266,7 +266,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) h5tools_str_append(str, fmt, temp); /* Free the temp buffer if we allocated one */ - if(temp != _temp) + if (temp != _temp) HDfree(temp); return str->s; @@ -282,10 +282,10 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) *------------------------------------------------------------------------- */ char * -h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno, - h5tools_context_t *ctx) +h5tools_str_prefix(h5tools_str_t *str /*in,out*/, const h5tool_format_t *info, hsize_t elmtno, + h5tools_context_t *ctx) { - size_t i = 0; + size_t i = 0; H5TOOLS_START_DEBUG(""); @@ -293,16 +293,16 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hs h5tools_str_reset(str); calc_acc_pos(ctx->ndims, elmtno, ctx->acc, ctx->pos); - if(ctx->ndims > 0) { + if (ctx->ndims > 0) { /* Print the index values */ - for(i = 0; i < (size_t) ctx->ndims; i++) { + for (i = 0; i < (size_t)ctx->ndims; i++) { if (i) h5tools_str_append(str, "%s", OPT(info->idx_sep, ",")); - h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]); + h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t)ctx->pos[i]); } } - else /* Scalar */ + else /* Scalar */ h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t)elmtno); H5TOOLS_DEBUG("str=%s", str->s); @@ -322,10 +322,10 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hs *------------------------------------------------------------------------- */ char * -h5tools_str_region_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno, - hsize_t *ptdata, h5tools_context_t *ctx) +h5tools_str_region_prefix(h5tools_str_t *str /*in,out*/, const h5tool_format_t *info, hsize_t elmtno, + hsize_t *ptdata, h5tools_context_t *ctx) { - size_t i = 0; + size_t i = 0; H5TOOLS_START_DEBUG(""); @@ -333,17 +333,17 @@ h5tools_str_region_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *i h5tools_str_reset(str); calc_acc_pos(ctx->ndims, elmtno, ctx->acc, ctx->pos); - if(ctx->ndims > 0) { + if (ctx->ndims > 0) { /* Print the index values */ - for(i = 0; i < (size_t) ctx->ndims; i++) { - ctx->pos[i] += (unsigned long) ptdata[ctx->sm_pos+i]; + for (i = 0; i < (size_t)ctx->ndims; i++) { + ctx->pos[i] += (unsigned long)ptdata[ctx->sm_pos + i]; if (i) h5tools_str_append(str, "%s", OPT(info->idx_sep, ",")); - h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]); + h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t)ctx->pos[i]); } } - else /* Scalar */ + else /* Scalar */ h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t)0); H5TOOLS_DEBUG("str=%s", str->s); @@ -367,15 +367,15 @@ h5tools_str_region_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *i *------------------------------------------------------------------------- */ void -h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, - const h5tool_format_t *info, h5tools_context_t *ctx) +h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, const h5tool_format_t *info, + h5tools_context_t *ctx) { - hsize_t start[H5S_MAX_RANK]; - hsize_t stride[H5S_MAX_RANK]; - hsize_t count[H5S_MAX_RANK]; - hsize_t block[H5S_MAX_RANK]; - int j; - int ndims = H5Sget_simple_extent_ndims(rspace); + hsize_t start[H5S_MAX_RANK]; + hsize_t stride[H5S_MAX_RANK]; + hsize_t count[H5S_MAX_RANK]; + hsize_t block[H5S_MAX_RANK]; + int j; + int ndims = H5Sget_simple_extent_ndims(rspace); H5Sget_regular_hyperslab(rspace, start, stride, count, block); @@ -383,7 +383,7 @@ h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, /* Start coordinates */ h5tools_str_append(str, "%s%s ", info->line_indent, START); - for(j = 0; j < ndims; j++) + for (j = 0; j < ndims; j++) h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(", start[j]); h5tools_str_append(str, ")"); h5tools_str_append(str, "%s", "\n"); @@ -391,7 +391,7 @@ h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, /* Stride coordinates */ h5tools_str_append(str, "%s ", STRIDE); - for(j = 0; j < ndims; j++) + for (j = 0; j < ndims; j++) h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(", stride[j]); h5tools_str_append(str, ")"); h5tools_str_append(str, "%s", "\n"); @@ -399,9 +399,9 @@ h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, /* Count coordinates */ h5tools_str_append(str, "%s ", COUNT); - for(j = 0; j < ndims; j++) { - if(count[j] == H5S_UNLIMITED) - h5tools_str_append(str, "%s%s", j ? "," : "(","H5S_UNLIMITED"); + for (j = 0; j < ndims; j++) { + if (count[j] == H5S_UNLIMITED) + h5tools_str_append(str, "%s%s", j ? "," : "(", "H5S_UNLIMITED"); else h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(", count[j]); } @@ -411,9 +411,9 @@ h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, /* Block coordinates */ h5tools_str_append(str, "%s ", BLOCK); - for(j = 0; j < ndims; j++) { - if(block[j] == H5S_UNLIMITED) - h5tools_str_append(str, "%s%s", j ? "," : "(","H5S_UNLIMITED"); + for (j = 0; j < ndims; j++) { + if (block[j] == H5S_UNLIMITED) + h5tools_str_append(str, "%s%s", j ? "," : "(", "H5S_UNLIMITED"); else h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(", block[j]); } @@ -432,45 +432,46 @@ h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, *------------------------------------------------------------------------- */ void -h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, - const h5tool_format_t *info) +h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, const h5tool_format_t *info) { - hssize_t snblocks; + hssize_t snblocks; /* * This function fails if the rspace does not have blocks. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { snblocks = H5Sget_select_hyper_nblocks(rspace); - } H5E_END_TRY; + } + H5E_END_TRY; /* Print block information */ - if(snblocks > 0) { - hsize_t alloc_size; - hsize_t nblocks; - hsize_t *ptdata; - hsize_t u; - unsigned ndims = (unsigned)H5Sget_simple_extent_ndims(rspace); - - nblocks = (hsize_t)snblocks; + if (snblocks > 0) { + hsize_t alloc_size; + hsize_t nblocks; + hsize_t *ptdata; + hsize_t u; + unsigned ndims = (unsigned)H5Sget_simple_extent_ndims(rspace); + + nblocks = (hsize_t)snblocks; alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); - HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ - ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); + HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ + ptdata = (hsize_t *)HDmalloc((size_t)alloc_size); H5Sget_select_hyper_blocklist(rspace, (hsize_t)0, nblocks, ptdata); - for(u = 0; u < nblocks; u++) { + for (u = 0; u < nblocks; u++) { unsigned v; - h5tools_str_append(str, info->dset_blockformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)u); + h5tools_str_append(str, info->dset_blockformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "", + (unsigned long)u); /* Start coordinates and opposite corner */ - for(v = 0; v < ndims; v++) - h5tools_str_append(str, "%s" HSIZE_T_FORMAT, v ? "," : "(", - ptdata[u * 2 * ndims + v]); + for (v = 0; v < ndims; v++) + h5tools_str_append(str, "%s" HSIZE_T_FORMAT, v ? "," : "(", ptdata[u * 2 * ndims + v]); - for(v = 0; v < ndims; v++) + for (v = 0; v < ndims; v++) h5tools_str_append(str, "%s" HSIZE_T_FORMAT, v ? "," : ")-(", - ptdata[u * 2 * ndims + v + ndims]); + ptdata[u * 2 * ndims + v + ndims]); h5tools_str_append(str, ")"); } @@ -491,41 +492,41 @@ h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, *------------------------------------------------------------------------- */ void -h5tools_str_dump_space_points(h5tools_str_t *str, hid_t rspace, - const h5tool_format_t *info) +h5tools_str_dump_space_points(h5tools_str_t *str, hid_t rspace, const h5tool_format_t *info) { - hssize_t snpoints; + hssize_t snpoints; /* * This function fails if the rspace does not have points. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { snpoints = H5Sget_select_elem_npoints(rspace); - } H5E_END_TRY; + } + H5E_END_TRY; /* Print point information */ if (snpoints > 0) { - hsize_t alloc_size; - hsize_t npoints; - hsize_t *ptdata; - hsize_t u; - unsigned ndims = (unsigned)H5Sget_simple_extent_ndims(rspace); + hsize_t alloc_size; + hsize_t npoints; + hsize_t *ptdata; + hsize_t u; + unsigned ndims = (unsigned)H5Sget_simple_extent_ndims(rspace); - npoints = (hsize_t)snpoints; + npoints = (hsize_t)snpoints; alloc_size = npoints * ndims * sizeof(ptdata[0]); - HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ - ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); + HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ + ptdata = (hsize_t *)HDmalloc((size_t)alloc_size); H5Sget_select_elem_pointlist(rspace, (hsize_t)0, npoints, ptdata); - for(u = 0; u < npoints; u++) { + for (u = 0; u < npoints; u++) { unsigned v; h5tools_str_append(str, info->dset_ptformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)u); - for(v = 0; v < ndims; v++) - h5tools_str_append(str, "%s" HSIZE_T_FORMAT, v ? "," : "(", - (ptdata[u * ndims + v])); + for (v = 0; v < ndims; v++) + h5tools_str_append(str, "%s" HSIZE_T_FORMAT, v ? "," : "(", (ptdata[u * ndims + v])); h5tools_str_append(str, ")"); } @@ -546,78 +547,77 @@ h5tools_str_dump_space_points(h5tools_str_t *str, hid_t rspace, static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch) { - if(info->str_locale == ESCAPE_HTML) { - if(ch <= ' ' || ch > '~') + if (info->str_locale == ESCAPE_HTML) { + if (ch <= ' ' || ch > '~') h5tools_str_append(str, "%%%02x", ch); else h5tools_str_append(str, "%c", ch); } else { - switch(ch) { - case '"': - if(!info->do_escape) - h5tools_str_append(str, "\""); - else - h5tools_str_append(str, "\\\""); - break; - case '\\': - if (!info->do_escape) - h5tools_str_append(str, "\\"); - else - h5tools_str_append(str, "\\\\"); - break; - case '\b': - if(!info->do_escape) - h5tools_str_append(str, "\b"); - else - h5tools_str_append(str, "\\b"); - break; - case '\f': - if(!info->do_escape) - h5tools_str_append(str, "\f"); - else - h5tools_str_append(str, "\\f"); - break; - case '\n': - if(!info->do_escape) { - h5tools_str_append(str, "\n"); - h5tools_str_append(str, " "); - } - else - h5tools_str_append(str, "\\n"); - break; - case '\r': - if(!info->do_escape) { - h5tools_str_append(str, "\r"); - h5tools_str_append(str, " "); - } - else - h5tools_str_append(str, "\\r"); - break; - case '\t': - if(!info->do_escape) - h5tools_str_append(str, "\t"); - else - h5tools_str_append(str, "\\t"); - break; - default: - if(isprint(ch)) - h5tools_str_append(str, "%c", ch); - else - h5tools_str_append(str, "\\%03o", ch); + switch (ch) { + case '"': + if (!info->do_escape) + h5tools_str_append(str, "\""); + else + h5tools_str_append(str, "\\\""); + break; + case '\\': + if (!info->do_escape) + h5tools_str_append(str, "\\"); + else + h5tools_str_append(str, "\\\\"); + break; + case '\b': + if (!info->do_escape) + h5tools_str_append(str, "\b"); + else + h5tools_str_append(str, "\\b"); + break; + case '\f': + if (!info->do_escape) + h5tools_str_append(str, "\f"); + else + h5tools_str_append(str, "\\f"); + break; + case '\n': + if (!info->do_escape) { + h5tools_str_append(str, "\n"); + h5tools_str_append(str, " "); + } + else + h5tools_str_append(str, "\\n"); + break; + case '\r': + if (!info->do_escape) { + h5tools_str_append(str, "\r"); + h5tools_str_append(str, " "); + } + else + h5tools_str_append(str, "\\r"); + break; + case '\t': + if (!info->do_escape) + h5tools_str_append(str, "\t"); + else + h5tools_str_append(str, "\\t"); + break; + default: + if (isprint(ch)) + h5tools_str_append(str, "%c", ch); + else + h5tools_str_append(str, "\\%03o", ch); - break; + break; } } } void -h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, - h5tools_context_t *ctx) +h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, h5tools_context_t *ctx) { unsigned u, indentlevel = 0; /* Write new prefix */ - if(ctx->indent_level > 0) + if (ctx->indent_level > 0) indentlevel = ctx->indent_level; else /* @@ -628,7 +628,7 @@ h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, */ indentlevel = ctx->default_indent_level; - for(u = 0; u < indentlevel; u++) + for (u = 0; u < indentlevel; u++) h5tools_str_append(str, "%s", OPT(info->line_indent, "")); } @@ -642,24 +642,24 @@ h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, *------------------------------------------------------------------------- */ char * -h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, - hid_t type, void *vp, h5tools_context_t *ctx) +h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, hid_t type, void *vp, + h5tools_context_t *ctx) { - size_t nsize, offset, size=0, nelmts, start; + size_t nsize, offset, size = 0, nelmts, start; H5T_sign_t nsign; - char *name = NULL; + char * name = NULL; unsigned char *ucp_vp = (unsigned char *)vp; - char *cp_vp = (char *)vp; - hid_t memb = H5I_INVALID_HID; - hid_t obj = H5I_INVALID_HID; + char * cp_vp = (char *)vp; + hid_t memb = H5I_INVALID_HID; + hid_t obj = H5I_INVALID_HID; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; H5T_class_t type_class; - char *ret_value = NULL; + char * ret_value = NULL; H5TOOLS_START_DEBUG(""); /* Build default formats for long long types */ - if(!fmt_llong[0]) { + if (!fmt_llong[0]) { HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH); HDsnprintf(fmt_ullong, sizeof(fmt_ullong), "%%%su", H5_PRINTF_LL_WIDTH); } @@ -669,44 +669,44 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai nsize = H5Tget_size(type); nsign = H5Tget_sign(type); - if(info->raw) { + if (info->raw) { size_t i; H5TOOLS_DEBUG("info->raw"); - if(1 == nsize) + if (1 == nsize) h5tools_str_append(str, OPT(info->fmt_raw, "0x%02x"), ucp_vp[0]); else - for(i = 0; i < nsize; i++) { - if(i) + for (i = 0; i < nsize; i++) { + if (i) h5tools_str_append(str, ":"); h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]); } } else { H5TOOLS_DEBUG("H5Tget_class(type)"); - if((type_class = H5Tget_class(type)) < 0) { + if ((type_class = H5Tget_class(type)) < 0) { H5TOOLS_ENDDEBUG(" with %s", "NULL"); return NULL; } switch (type_class) { case H5T_FLOAT: H5TOOLS_DEBUG("H5T_FLOAT"); - if(sizeof(float) == nsize) { + if (sizeof(float) == nsize) { /* if (H5Tequal(type, H5T_NATIVE_FLOAT)) */ float tempfloat; HDmemcpy(&tempfloat, vp, sizeof(float)); h5tools_str_append(str, OPT(info->fmt_float, "%g"), (double)tempfloat); } - else if(sizeof(double) == nsize) { + else if (sizeof(double) == nsize) { /* if (H5Tequal(type, H5T_NATIVE_DOUBLE)) */ double tempdouble; HDmemcpy(&tempdouble, vp, sizeof(double)); h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 } - else if(sizeof(long double) == nsize) { + else if (sizeof(long double) == nsize) { /* if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) */ long double templdouble; @@ -716,100 +716,100 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } break; - case H5T_STRING: - { - unsigned int i; - char quote = '\0'; - char *s; - - H5TOOLS_DEBUG("H5T_STRING"); - quote = '\0'; - if(H5Tis_variable_str(type)) { - /* cp_vp is the pointer into the struct where a `char*' is stored. So we have - * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ - s = *(char **)((void *)cp_vp); - if(s != NULL) - size = HDstrlen(s); - } - else { - s = cp_vp; - size = H5Tget_size(type); - } - pad = H5Tget_strpad(type); + case H5T_STRING: { + unsigned int i; + char quote = '\0'; + char * s; + + H5TOOLS_DEBUG("H5T_STRING"); + quote = '\0'; + if (H5Tis_variable_str(type)) { + /* cp_vp is the pointer into the struct where a `char*' is stored. So we have + * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ + s = *(char **)((void *)cp_vp); + if (s != NULL) + size = HDstrlen(s); + } + else { + s = cp_vp; + size = H5Tget_size(type); + } + pad = H5Tget_strpad(type); - /* Check for NULL pointer for string */ - if(s == NULL) - h5tools_str_append(str, "NULL"); - else { - for(i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { - unsigned j = 1; - - /* - * Count how many times the next character repeats. If the - * threshold is zero then that means it can repeat any number - * of times. - */ - if(info->str_repeat > 0) - while (i + j < size && s[i] == s[i + j]) - j++; - - /* - * Print the opening quote. If the repeat count is high enough to - * warrant printing the number of repeats instead of enumerating - * the characters, then make sure the character to be repeated is - * in it's own quote. - */ - if(info->str_repeat > 0 && j > info->str_repeat) { - if(quote) - h5tools_str_append(str, "%c", quote); - - quote = '\''; - h5tools_str_append(str, "%s%c", i ? " " : "", quote); - } - else if(!quote) { - quote = '"'; - h5tools_str_append(str, "%s%c", i ? " " : "", quote); - } + /* Check for NULL pointer for string */ + if (s == NULL) + h5tools_str_append(str, "NULL"); + else { + for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { + unsigned j = 1; + + /* + * Count how many times the next character repeats. If the + * threshold is zero then that means it can repeat any number + * of times. + */ + if (info->str_repeat > 0) + while (i + j < size && s[i] == s[i + j]) + j++; + + /* + * Print the opening quote. If the repeat count is high enough to + * warrant printing the number of repeats instead of enumerating + * the characters, then make sure the character to be repeated is + * in it's own quote. + */ + if (info->str_repeat > 0 && j > info->str_repeat) { + if (quote) + h5tools_str_append(str, "%c", quote); + + quote = '\''; + h5tools_str_append(str, "%s%c", i ? " " : "", quote); + } + else if (!quote) { + quote = '"'; + h5tools_str_append(str, "%s%c", i ? " " : "", quote); + } - /* Print the character */ - h5tools_print_char(str, info, s[i]); + /* Print the character */ + h5tools_print_char(str, info, s[i]); - /* Print the repeat count */ - if(info->str_repeat && j > info->str_repeat) { + /* Print the repeat count */ + if (info->str_repeat && j > info->str_repeat) { #ifdef REPEAT_VERBOSE - h5tools_str_append(str, "%c repeats %d times", quote, j - 1); + h5tools_str_append(str, "%c repeats %d times", quote, j - 1); #else - h5tools_str_append(str, "%c*%d", quote, j - 1); -#endif /* REPEAT_VERBOSE */ - quote = '\0'; - i += j - 1; - } + h5tools_str_append(str, "%c*%d", quote, j - 1); +#endif /* REPEAT_VERBOSE */ + quote = '\0'; + i += j - 1; } + } - if(quote) - h5tools_str_append(str, "%c", quote); + if (quote) + h5tools_str_append(str, "%c", quote); - if(i == 0) - /*empty string*/ - h5tools_str_append(str, "\"\""); - } /* end else */ - } - break; + if (i == 0) + /*empty string*/ + h5tools_str_append(str, "\"\""); + } /* end else */ + } break; case H5T_INTEGER: H5TOOLS_DEBUG("H5T_INTEGER"); - if(sizeof(char) == nsize) { - if(info->ascii) - h5tools_print_char(str, info, (char) (*ucp_vp)); - else if(H5T_SGN_NONE == nsign) { + if (sizeof(char) == nsize) { + if (info->ascii) + h5tools_print_char(str, info, (char)(*ucp_vp)); + else if (H5T_SGN_NONE == nsign) { unsigned char tempuchar; HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(unsigned char)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned char)) tempuchar = 0; else - tempuchar = (unsigned char)((unsigned long long)(tempuchar >> packed_data_offset) & packed_data_mask); + tempuchar = + (unsigned char)((unsigned long long)(tempuchar >> packed_data_offset) & + packed_data_mask); } h5tools_str_append(str, OPT(info->fmt_uchar, "%hhu"), tempuchar); } @@ -817,22 +817,24 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai signed char tempchar; HDmemcpy(&tempchar, cp_vp, sizeof(char)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(char)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(char)) tempchar = 0; else - tempchar = (signed char)((unsigned long long)(tempchar >> packed_data_offset) & packed_data_mask); + tempchar = + (signed char)((unsigned long long)(tempchar >> packed_data_offset) & + packed_data_mask); } h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar); } } /* end if (sizeof(char) == nsize) */ - else if(sizeof(int) == nsize) { - if(H5T_SGN_NONE == nsign) { + else if (sizeof(int) == nsize) { + if (H5T_SGN_NONE == nsign) { unsigned int tempuint; HDmemcpy(&tempuint, vp, sizeof(unsigned int)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(unsigned int)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned int)) tempuint = 0; else tempuint = (unsigned)((tempuint >> packed_data_offset) & packed_data_mask); @@ -843,25 +845,28 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai int tempint; HDmemcpy(&tempint, vp, sizeof(int)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(int)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(int)) tempint = 0; else - tempint = (int)((unsigned long long)(tempint >> packed_data_offset) & packed_data_mask); + tempint = (int)((unsigned long long)(tempint >> packed_data_offset) & + packed_data_mask); } h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); } } /* end if (sizeof(int) == nsize) */ - else if(sizeof(short) == nsize) { - if(H5T_SGN_NONE == nsign) { + else if (sizeof(short) == nsize) { + if (H5T_SGN_NONE == nsign) { unsigned short tempushort; HDmemcpy(&tempushort, vp, sizeof(unsigned short)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(unsigned short)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned short)) tempushort = 0; else - tempushort = (unsigned short)((unsigned long long)(tempushort >> packed_data_offset) & packed_data_mask); + tempushort = + (unsigned short)((unsigned long long)(tempushort >> packed_data_offset) & + packed_data_mask); } h5tools_str_append(str, OPT(info->fmt_ushort, "%hu"), tempushort); } @@ -869,22 +874,23 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai short tempshort; HDmemcpy(&tempshort, vp, sizeof(short)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(short)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(short)) tempshort = 0; else - tempshort = (short)((unsigned long long)(tempshort >> packed_data_offset) & packed_data_mask); + tempshort = (short)((unsigned long long)(tempshort >> packed_data_offset) & + packed_data_mask); } h5tools_str_append(str, OPT(info->fmt_short, "%hd"), tempshort); } } /* end if (sizeof(short) == nsize) */ - else if(sizeof(long) == nsize) { - if(H5T_SGN_NONE == nsign) { + else if (sizeof(long) == nsize) { + if (H5T_SGN_NONE == nsign) { unsigned long tempulong; HDmemcpy(&tempulong, vp, sizeof(unsigned long)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(unsigned long)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned long)) tempulong = 0; else tempulong = (tempulong >> packed_data_offset) & packed_data_mask; @@ -895,23 +901,24 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai long templong; HDmemcpy(&templong, vp, sizeof(long)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(long)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(long)) templong = 0; else - templong = (long)((unsigned long long)(templong >> packed_data_offset) & packed_data_mask); + templong = (long)((unsigned long long)(templong >> packed_data_offset) & + packed_data_mask); } h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); } } /* end if (sizeof(long) == nsize) */ #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if(sizeof(long long) == nsize) { - if(H5T_SGN_NONE == nsign) { + else if (sizeof(long long) == nsize) { + if (H5T_SGN_NONE == nsign) { unsigned long long tempullong; HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(unsigned long long)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned long long)) tempullong = 0; else tempullong = (tempullong >> packed_data_offset) & packed_data_mask; @@ -922,8 +929,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai long long templlong; HDmemcpy(&templlong, vp, sizeof(long long)); - if(packed_bits_num) { - if(packed_data_offset >= 8 * sizeof(long long)) + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(long long)) templlong = 0; else templlong = (templlong >> packed_data_offset) & packed_data_mask; @@ -931,19 +938,19 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); } } /* end if (sizeof(long long) == nsize) */ -#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ +#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ break; case H5T_COMPOUND: H5TOOLS_DEBUG("H5T_COMPOUND"); - if(ctx->cmpd_listv) { /* there is */ - unsigned save_indent_level; /* The indentation level */ - size_t curr_field; /* Current field to display */ - int i = 0; /* Local index variable */ - unsigned x = 0; /* Local index variable */ - const H5LD_memb_t * const *listv; /* Vector of information for */ - - listv = ctx->cmpd_listv; + if (ctx->cmpd_listv) { /* there is */ + unsigned save_indent_level; /* The indentation level */ + size_t curr_field; /* Current field to display */ + int i = 0; /* Local index variable */ + unsigned x = 0; /* Local index variable */ + const H5LD_memb_t *const *listv; /* Vector of information for */ + + listv = ctx->cmpd_listv; ctx->cmpd_listv = NULL; h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); @@ -954,39 +961,38 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai * put in "{", "}", ",", member name and value accordingly. */ save_indent_level = ctx->indent_level; - for(curr_field = 0; listv[curr_field] != NULL; curr_field++) { - if(curr_field) - h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); + for (curr_field = 0; listv[curr_field] != NULL; curr_field++) { + if (curr_field) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); else h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - if(info->arr_linebreak) + if (info->arr_linebreak) h5tools_str_indent(str, info, ctx); /* Process members of each field */ - for(i = 0; listv[curr_field]->names[i] != NULL; i++) { + for (i = 0; listv[curr_field]->names[i] != NULL; i++) { h5tools_str_append(str, OPT(info->cmpd_name, ""), listv[curr_field]->names[i]); - if(i) { + if (i) { ctx->indent_level++; h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); } } - h5tools_str_sprint(str, info, container, listv[curr_field]->last_tid, cp_vp + listv[curr_field]->tot_offset, ctx); - if(ctx->indent_level > 0) - for(x = ctx->indent_level; x > 0; x--) + h5tools_str_sprint(str, info, container, listv[curr_field]->last_tid, + cp_vp + listv[curr_field]->tot_offset, ctx); + if (ctx->indent_level > 0) + for (x = ctx->indent_level; x > 0; x--) h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); ctx->indent_level = save_indent_level; } - - if(info->arr_linebreak) { + if (info->arr_linebreak) { h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); h5tools_str_indent(str, info, ctx); } h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); ctx->cmpd_listv = info->cmpd_listv; - } else { int retvalue; @@ -1000,13 +1006,13 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai ctx->indent_level++; - for(j = 0; j < nmembs; j++) { - if(j) - h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); + for (j = 0; j < nmembs; j++) { + if (j) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); else h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - if(info->arr_linebreak) + if (info->arr_linebreak) h5tools_str_indent(str, info, ctx); /* The name */ @@ -1016,7 +1022,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* The value */ offset = H5Tget_member_offset(type, j); - memb = H5Tget_member_type(type, j); + memb = H5Tget_member_type(type, j); h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); @@ -1024,7 +1030,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } ctx->indent_level--; - if(info->arr_linebreak) { + if (info->arr_linebreak) { h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); h5tools_str_indent(str, info, ctx); } @@ -1033,46 +1039,43 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } break; - case H5T_ENUM: - { - char enum_name[1024]; + case H5T_ENUM: { + char enum_name[1024]; - H5TOOLS_DEBUG("H5T_ENUM"); - if(H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) - h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name))); - else { - size_t i; - if(1 == nsize) - h5tools_str_append(str, "0x%02x", ucp_vp[0]); - else - for(i = 0; i < nsize; i++) - h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); - } + H5TOOLS_DEBUG("H5T_ENUM"); + if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) + h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name))); + else { + size_t i; + if (1 == nsize) + h5tools_str_append(str, "0x%02x", ucp_vp[0]); + else + for (i = 0; i < nsize; i++) + h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); } - break; + } break; case H5T_REFERENCE: H5TOOLS_DEBUG("H5T_REFERENCE"); - if(h5tools_str_is_zero(vp, nsize)) + if (h5tools_str_is_zero(vp, nsize)) h5tools_str_append(str, "NULL"); else { if (H5Tequal(type, H5T_STD_REF)) { - H5O_type_t obj_type = -1; /* Object type */ - H5R_type_t ref_type; /* Reference type */ + H5O_type_t obj_type = -1; /* Object type */ + H5R_type_t ref_type; /* Reference type */ H5R_ref_t *ref_vp = (H5R_ref_t *)vp; H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF"); ref_type = H5Rget_type(ref_vp); H5Rget_obj_type3(ref_vp, H5P_DEFAULT, &obj_type); switch (ref_type) { - case H5R_OBJECT1: - { + case H5R_OBJECT1: { /* Object references -- show the type and OID of the referenced object. */ H5O_info2_t oi; - char *obj_tok_str = NULL; + char * obj_tok_str = NULL; H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); - if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { H5Oget_info3(obj, &oi, H5O_INFO_BASIC); H5Otoken_to_str(obj, &oi.token, &obj_tok_str); } @@ -1082,44 +1085,45 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Print object type and close object */ switch (obj_type) { case H5O_TYPE_GROUP: - h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_GROUP); + h5tools_str_append(str, "%u-%s", (unsigned)oi.type, H5_TOOLS_GROUP); break; case H5O_TYPE_DATASET: - h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_DATASET); + h5tools_str_append(str, "%u-%s", (unsigned)oi.type, H5_TOOLS_DATASET); break; case H5O_TYPE_NAMED_DATATYPE: - h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_DATATYPE); + h5tools_str_append(str, "%u-%s", (unsigned)oi.type, + H5_TOOLS_DATATYPE); break; case H5O_TYPE_MAP: case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: - h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_UNKNOWN); + h5tools_str_append(str, "%u-%s", (unsigned)oi.type, H5_TOOLS_UNKNOWN); break; } /* end switch */ h5tools_str_sprint_reference(str, ref_vp); /* Print OID */ - if(info->obj_hidefileno) + if (info->obj_hidefileno) h5tools_str_append(str, info->obj_format, obj_tok_str); else h5tools_str_append(str, info->obj_format, oi.fileno, obj_tok_str); - if(obj_tok_str) { + if (obj_tok_str) { H5free_memory(obj_tok_str); obj_tok_str = NULL; } - if(obj >= 0) - if(H5Oclose(obj) < 0) + if (obj >= 0) + if (H5Oclose(obj) < 0) H5TOOLS_ERROR(NULL, "H5Oclose H5R_OBJECT1 failed"); - } + } - break; + break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); h5tools_str_append(str, H5_TOOLS_DATASET); @@ -1177,132 +1181,127 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } break; - case H5T_ARRAY: - { - int k, ndims; - hsize_t i, dims[H5S_MAX_RANK], temp_nelmts; - static int is_next_arry_elmt = 0; - - H5TOOLS_DEBUG("H5T_ARRAY"); - /* Get the array's base datatype for each element */ - memb = H5Tget_super(type); - size = H5Tget_size(memb); - ndims = H5Tget_array_ndims(type); - H5Tget_array_dims2(type, dims); - HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); - - /* Calculate the number of array elements */ - for(k = 0, nelmts = 1; k < ndims; k++) { - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - HDassert(temp_nelmts == (hsize_t) ((size_t) temp_nelmts)); - nelmts = (size_t) temp_nelmts; - } - /* Print the opening bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); - - ctx->indent_level++; + case H5T_ARRAY: { + int k, ndims; + hsize_t i, dims[H5S_MAX_RANK], temp_nelmts; + static int is_next_arry_elmt = 0; + + H5TOOLS_DEBUG("H5T_ARRAY"); + /* Get the array's base datatype for each element */ + memb = H5Tget_super(type); + size = H5Tget_size(memb); + ndims = H5Tget_array_ndims(type); + H5Tget_array_dims2(type, dims); + HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); + + /* Calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + HDassert(temp_nelmts == (hsize_t)((size_t)temp_nelmts)); + nelmts = (size_t)temp_nelmts; + } + /* Print the opening bracket */ + h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); - for(i = 0; i < nelmts; i++) { - if(i) - h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); + ctx->indent_level++; - if(info->arr_linebreak && i && i % dims[ndims - 1] == 0) { - h5tools_str_append(str, "%s", "\n"); - h5tools_str_indent(str, info, ctx); + for (i = 0; i < nelmts; i++) { + if (i) + h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); - } /* end if */ - else if(i && info->arr_sep) { - /* if next element begin, add next line with indent */ - if(is_next_arry_elmt) { - is_next_arry_elmt = 0; + if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { + h5tools_str_append(str, "%s", "\n"); + h5tools_str_indent(str, info, ctx); - h5tools_str_append(str, "%s", "\n "); - h5tools_str_indent(str, info, ctx); + } /* end if */ + else if (i && info->arr_sep) { + /* if next element begin, add next line with indent */ + if (is_next_arry_elmt) { + is_next_arry_elmt = 0; - } - /* otherwise just add space */ - else - h5tools_str_append(str, " "); + h5tools_str_append(str, "%s", "\n "); + h5tools_str_indent(str, info, ctx); + } + /* otherwise just add space */ + else + h5tools_str_append(str, " "); - } /* end else if */ + } /* end else if */ - /* Dump values in an array element */ - is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */ - h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx); - } /* end for */ + /* Dump values in an array element */ + is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */ + h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx); + } /* end for */ - ctx->indent_level--; + ctx->indent_level--; - /* Print the closing bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); - is_next_arry_elmt = 1; /* set for begining of next array element */ - H5Tclose(memb); - } - break; + /* Print the closing bracket */ + h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); + is_next_arry_elmt = 1; /* set for begining of next array element */ + H5Tclose(memb); + } break; - case H5T_VLEN: - { - unsigned int i; + case H5T_VLEN: { + unsigned int i; - H5TOOLS_DEBUG("H5T_VLEN"); - /* Get the VL sequences's base datatype for each element */ - memb = H5Tget_super(type); - size = H5Tget_size(memb); + H5TOOLS_DEBUG("H5T_VLEN"); + /* Get the VL sequences's base datatype for each element */ + memb = H5Tget_super(type); + size = H5Tget_size(memb); - /* Print the opening bracket */ - h5tools_str_append(str, "%s", OPT(info->vlen_pre, "(")); + /* Print the opening bracket */ + h5tools_str_append(str, "%s", OPT(info->vlen_pre, "(")); - /* Get the number of sequence elements */ - nelmts = ((hvl_t *)((void *)cp_vp))->len; + /* Get the number of sequence elements */ + nelmts = ((hvl_t *)((void *)cp_vp))->len; - for(i = 0; i < nelmts; i++) { - if(i) h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); + for (i = 0; i < nelmts; i++) { + if (i) + h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); #ifdef LATER - /* Need to fix so VL data breaks at correct location on end of line -QAK */ - if(info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) { - int x; + /* Need to fix so VL data breaks at correct location on end of line -QAK */ + if (info->arr_linebreak && h5tools_str_len(str) >= info->line_ncols) { + int x; - h5tools_str_append(str, "%s", "\n"); + h5tools_str_append(str, "%s", "\n"); - /* need to indent some more here */ - if(ctx->indent_level >= 0) - h5tools_str_append(str, "%s", OPT(info->line_pre, "")); + /* need to indent some more here */ + if (ctx->indent_level >= 0) + h5tools_str_append(str, "%s", OPT(info->line_pre, "")); - for(x = 0; x < ctx->indent_level + 1; x++) - h5tools_str_append(str,"%s",OPT(info->line_indent,"")); - } /* end if */ -#endif /* LATER */ + for (x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); + } /* end if */ +#endif /* LATER */ - ctx->indent_level++; + ctx->indent_level++; - /* Dump the array element */ - h5tools_str_sprint(str, info, container, memb, ((char *) (((hvl_t *)((void *)cp_vp))->p)) + i * size, ctx); + /* Dump the array element */ + h5tools_str_sprint(str, info, container, memb, + ((char *)(((hvl_t *)((void *)cp_vp))->p)) + i * size, ctx); - ctx->indent_level--; - } /* end for */ + ctx->indent_level--; + } /* end for */ - h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")")); - H5Tclose(memb); - } - break; + h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")")); + H5Tclose(memb); + } break; case H5T_TIME: case H5T_BITFIELD: - case H5T_OPAQUE: - { - /* All other types get printed as hexadecimal */ - size_t i; - - H5TOOLS_DEBUG("OTHER"); - if(1 == nsize) - h5tools_str_append(str, "0x%02x", ucp_vp[0]); - else - for(i = 0; i < nsize; i++) - h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); - } - break; + case H5T_OPAQUE: { + /* All other types get printed as hexadecimal */ + size_t i; + + H5TOOLS_DEBUG("OTHER"); + if (1 == nsize) + h5tools_str_append(str, "0x%02x", ucp_vp[0]); + else + for (i = 0; i < nsize; i++) + h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); + } break; case H5T_NO_CLASS: case H5T_NCLASSES: @@ -1318,7 +1317,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai return ret_value; } - /*------------------------------------------------------------------------- * Function: h5tools_str_sprint_reference * @@ -1394,70 +1392,70 @@ h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *ref_vp) *------------------------------------------------------------------------- */ static char * -h5tools_escape(char *s/*in,out*/, size_t size) +h5tools_escape(char *s /*in,out*/, size_t size) { - register size_t i; - const char *escape; - char octal[8]; - size_t n = HDstrlen(s); + register size_t i; + const char * escape; + char octal[8]; + size_t n = HDstrlen(s); - for(i = 0; i < n; i++) { + for (i = 0; i < n; i++) { switch (s[i]) { - case '\'': - escape = "\\\'"; - break; - case '\"': - escape = "\\\""; - break; - case '\\': - escape = "\\\\"; - break; - case '\?': - escape = "\\\?"; - break; - case '\a': - escape = "\\a"; - break; - case '\b': - escape = "\\b"; - break; - case '\f': - escape = "\\f"; - break; - case '\n': - escape = "\\n"; - break; - case '\r': - escape = "\\r"; - break; - case '\t': - escape = "\\t"; - break; - case '\v': - escape = "\\v"; - break; - default: - if(!isprint(s[i])) { - HDsnprintf(octal, sizeof(octal), "\\%03o", (unsigned char) s[i]); - escape = octal; - } - else - escape = NULL; + case '\'': + escape = "\\\'"; + break; + case '\"': + escape = "\\\""; + break; + case '\\': + escape = "\\\\"; + break; + case '\?': + escape = "\\\?"; + break; + case '\a': + escape = "\\a"; + break; + case '\b': + escape = "\\b"; + break; + case '\f': + escape = "\\f"; + break; + case '\n': + escape = "\\n"; + break; + case '\r': + escape = "\\r"; + break; + case '\t': + escape = "\\t"; + break; + case '\v': + escape = "\\v"; + break; + default: + if (!isprint(s[i])) { + HDsnprintf(octal, sizeof(octal), "\\%03o", (unsigned char)s[i]); + escape = octal; + } + else + escape = NULL; - break; + break; } - if(escape) { + if (escape) { size_t esc_size = HDstrlen(escape); - if(n + esc_size + 1 > size) + if (n + esc_size + 1 > size) /*would overflow*/ return NULL; HDmemmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ - HDmemcpy(s + i, escape, esc_size); /*insert*/ - n += esc_size - 1; /* adjust total string size */ - i += esc_size; /* adjust string position */ + HDmemcpy(s + i, escape, esc_size); /*insert*/ + n += esc_size - 1; /* adjust total string size */ + i += esc_size; /* adjust string position */ } } @@ -1478,10 +1476,10 @@ h5tools_escape(char *s/*in,out*/, size_t size) static hbool_t h5tools_str_is_zero(const void *_mem, size_t size) { - const unsigned char *mem = (const unsigned char *) _mem; + const unsigned char *mem = (const unsigned char *)_mem; - while(size-- > 0) - if(mem[size]) + while (size-- > 0) + if (mem[size]) return FALSE; return TRUE; @@ -1504,30 +1502,31 @@ h5tools_str_is_zero(const void *_mem, size_t size) *------------------------------------------------------------------------- */ char * -h5tools_str_replace ( const char *string, const char *substr, const char *replacement ) +h5tools_str_replace(const char *string, const char *substr, const char *replacement) { char *tok = NULL; char *newstr = NULL; char *head = NULL; - if(substr == NULL || replacement == NULL) + if (substr == NULL || replacement == NULL) return HDstrdup(string); newstr = HDstrdup(string); - head = newstr; - while((tok = HDstrstr(head, substr))) { + head = newstr; + while ((tok = HDstrstr(head, substr))) { char *oldstr; oldstr = newstr; newstr = (char *)HDmalloc(HDstrlen(oldstr) - HDstrlen(substr) + HDstrlen(replacement) + 1); - if(newstr == NULL) { + if (newstr == NULL) { HDfree(oldstr); return NULL; } HDmemcpy(newstr, oldstr, (size_t)(tok - oldstr)); HDmemcpy(newstr + (tok - oldstr), replacement, HDstrlen(replacement)); - HDmemcpy(newstr + (tok - oldstr) + HDstrlen(replacement), tok + HDstrlen(substr), HDstrlen(oldstr) - HDstrlen(substr) - (size_t)(tok - oldstr)); - HDmemset(newstr + HDstrlen (oldstr) - HDstrlen(substr) + HDstrlen(replacement) , 0, 1); + HDmemcpy(newstr + (tok - oldstr) + HDstrlen(replacement), tok + HDstrlen(substr), + HDstrlen(oldstr) - HDstrlen(substr) - (size_t)(tok - oldstr)); + HDmemset(newstr + HDstrlen(oldstr) - HDstrlen(substr) + HDstrlen(replacement), 0, 1); /* move back head right after the last replacement */ head = newstr + (tok - oldstr) + HDstrlen(replacement); HDfree(oldstr); @@ -1535,4 +1534,3 @@ h5tools_str_replace ( const char *string, const char *substr, const char *replac return newstr; } - diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 074e86d..cd2a889 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -19,32 +19,31 @@ #define H5TOOLS_STR_H__ typedef struct h5tools_str_t { - char *s; /*allocate string */ - size_t len; /*length of actual value */ - size_t nalloc; /*allocated size of string */ + char * s; /*allocate string */ + size_t len; /*length of actual value */ + size_t nalloc; /*allocated size of string */ } h5tools_str_t; -H5TOOLS_DLL void h5tools_str_close(h5tools_str_t *str); -H5TOOLS_DLL size_t h5tools_str_len(h5tools_str_t *str); -H5TOOLS_DLL char *h5tools_str_append(h5tools_str_t *str, const char *fmt, ...); -H5TOOLS_DLL char *h5tools_str_reset(h5tools_str_t *str); -H5TOOLS_DLL char *h5tools_str_trunc(h5tools_str_t *str, size_t size); -H5TOOLS_DLL char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt); -H5TOOLS_DLL char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info, - hsize_t elmtno, h5tools_context_t *ctx); +H5TOOLS_DLL void h5tools_str_close(h5tools_str_t *str); +H5TOOLS_DLL size_t h5tools_str_len(h5tools_str_t *str); +H5TOOLS_DLL char * h5tools_str_append(h5tools_str_t *str, const char *fmt, ...); +H5TOOLS_DLL char * h5tools_str_reset(h5tools_str_t *str); +H5TOOLS_DLL char * h5tools_str_trunc(h5tools_str_t *str, size_t size); +H5TOOLS_DLL char * h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt); +H5TOOLS_DLL char * h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno, + h5tools_context_t *ctx); /* * new functions needed to display region reference data */ -H5TOOLS_DLL char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, - hsize_t elmtno, hsize_t *ptdata, h5tools_context_t *ctx); -H5TOOLS_DLL void h5tools_str_dump_space_slabs(h5tools_str_t *, hid_t, const h5tool_format_t *, h5tools_context_t *ctx); -H5TOOLS_DLL void h5tools_str_dump_space_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *); -H5TOOLS_DLL void h5tools_str_dump_space_points(h5tools_str_t *, hid_t, const h5tool_format_t *); -H5TOOLS_DLL void h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *vp); -H5TOOLS_DLL char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, - hid_t container, hid_t type, void *vp, - h5tools_context_t *ctx); -H5TOOLS_DLL char *h5tools_str_replace ( const char *string, const char *substr, - const char *replacement ); +H5TOOLS_DLL char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno, + hsize_t *ptdata, h5tools_context_t *ctx); +H5TOOLS_DLL void h5tools_str_dump_space_slabs(h5tools_str_t *, hid_t, const h5tool_format_t *, + h5tools_context_t *ctx); +H5TOOLS_DLL void h5tools_str_dump_space_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *); +H5TOOLS_DLL void h5tools_str_dump_space_points(h5tools_str_t *, hid_t, const h5tool_format_t *); +H5TOOLS_DLL void h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *vp); +H5TOOLS_DLL char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, + hid_t type, void *vp, h5tools_context_t *ctx); +H5TOOLS_DLL char *h5tools_str_replace(const char *string, const char *substr, const char *replacement); -#endif /* H5TOOLS_STR_H__ */ +#endif /* H5TOOLS_STR_H__ */ diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index 22e4a39..4ebe310 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -26,7 +26,7 @@ hid_t h5tools_get_little_endian_type(hid_t tid) { - hid_t p_type=H5I_INVALID_HID; + hid_t p_type = H5I_INVALID_HID; H5T_class_t type_class; size_t size; H5T_sign_t sign; @@ -35,7 +35,7 @@ h5tools_get_little_endian_type(hid_t tid) size = H5Tget_size(tid); sign = H5Tget_sign(tid); - switch(type_class) { + switch (type_class) { case H5T_INTEGER: if (size == 1 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I8LE); @@ -93,7 +93,6 @@ h5tools_get_little_endian_type(hid_t tid) return p_type; } /* end h5tools_get_little_endian_type() */ - /*------------------------------------------------------------------------- * Function: h5tools_get_big_endian_type * @@ -115,7 +114,7 @@ h5tools_get_big_endian_type(hid_t tid) size = H5Tget_size(tid); sign = H5Tget_sign(tid); - switch(type_class) { + switch (type_class) { case H5T_INTEGER: if (size == 1 && sign == H5T_SGN_2) p_type = H5Tcopy(H5T_STD_I8BE); @@ -150,7 +149,7 @@ h5tools_get_big_endian_type(hid_t tid) else if (size == 4) p_type = H5Tcopy(H5T_STD_B32BE); else if (size == 8) - p_type=H5Tcopy(H5T_STD_B64BE); + p_type = H5Tcopy(H5T_STD_B64BE); break; case H5T_TIME: @@ -171,4 +170,3 @@ h5tools_get_big_endian_type(hid_t tid) return p_type; } /* end h5tools_get_big_endian_type() */ - diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 1a1c2db..aa2418d 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -28,11 +28,11 @@ /* global variables */ unsigned h5tools_nCols = 80; /* ``get_option'' variables */ -int opt_err = 1; /*get_option prints errors if this is on */ -int opt_ind = 1; /*token pointer */ -const char *opt_arg; /*flag argument (or value) */ -static int h5tools_d_status = 0; -static const char *h5tools_progname = "h5tools"; +int opt_err = 1; /*get_option prints errors if this is on */ +int opt_ind = 1; /*token pointer */ +const char * opt_arg; /*flag argument (or value) */ +static int h5tools_d_status = 0; +static const char *h5tools_progname = "h5tools"; /* * The output functions need a temporary buffer to hold a piece of the @@ -41,22 +41,21 @@ static const char *h5tools_progname = "h5tools"; * largest value suitable for your machine (for testing use a small value). */ /* Maximum size used in a call to malloc for a dataset */ -hsize_t H5TOOLS_MALLOCSIZE = (256 * 1024 * 1024); /* 256 MB */ +hsize_t H5TOOLS_MALLOCSIZE = (256 * 1024 * 1024); /* 256 MB */ /* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */ -hsize_t H5TOOLS_BUFSIZE = ( 32 * 1024 * 1024); /* 32 MB */ - +hsize_t H5TOOLS_BUFSIZE = (32 * 1024 * 1024); /* 32 MB */ /* ``parallel_print'' variables */ -unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */ -char outBuff[OUTBUFF_SIZE]; -unsigned outBuffOffset; -FILE* overflow_file = NULL; +unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */ +char outBuff[OUTBUFF_SIZE]; +unsigned outBuffOffset; +FILE * overflow_file = NULL; /* local functions */ static void init_table(hid_t fid, table_t **tbl); #ifdef H5DUMP_DEBUG -static void dump_table(hid_t fid, char* tablename, table_t *table); -#endif /* H5DUMP_DEBUG */ +static void dump_table(hid_t fid, char *tablename, table_t *table); +#endif /* H5DUMP_DEBUG */ static void add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool_t recorded); /*------------------------------------------------------------------------- @@ -66,28 +65,29 @@ static void add_obj(table_t *table, const H5O_token_t *obj_token, const char *ob *------------------------------------------------------------------------- */ void -parallel_print(const char* format, ...) +parallel_print(const char *format, ...) { - int bytes_written; + int bytes_written; va_list ap; HDva_start(ap, format); - if(!g_Parallel) + if (!g_Parallel) HDvprintf(format, ap); else { - if(overflow_file == NULL) /*no overflow has occurred yet */ { + if (overflow_file == NULL) /*no overflow has occurred yet */ { bytes_written = HDvsnprintf(outBuff + outBuffOffset, OUTBUFF_SIZE - outBuffOffset, format, ap); HDva_end(ap); HDva_start(ap, format); - if((bytes_written < 0) || ((unsigned)bytes_written >= (OUTBUFF_SIZE - outBuffOffset))) { + if ((bytes_written < 0) || ((unsigned)bytes_written >= (OUTBUFF_SIZE - outBuffOffset))) { /* Terminate the outbuff at the end of the previous output */ outBuff[outBuffOffset] = '\0'; overflow_file = HDtmpfile(); - if(overflow_file == NULL) - HDfprintf(rawerrorstream, "warning: could not create overflow file. Output may be truncated.\n"); + if (overflow_file == NULL) + HDfprintf(rawerrorstream, + "warning: could not create overflow file. Output may be truncated.\n"); else bytes_written = HDvfprintf(overflow_file, format, ap); } @@ -96,12 +96,10 @@ parallel_print(const char* format, ...) } else bytes_written = HDvfprintf(overflow_file, format, ap); - } HDva_end(ap); } - /*------------------------------------------------------------------------- * Function: error_msg * @@ -126,7 +124,6 @@ error_msg(const char *fmt, ...) HDva_end(ap); } - /*------------------------------------------------------------------------- * Function: warn_msg * @@ -162,10 +159,9 @@ void help_ref_msg(FILE *output) { HDfprintf(output, "Try '-h' or '--help' for more information or "); - HDfprintf(output, "see the <%s> entry in the 'HDF5 Reference Manual'.\n",h5tools_getprogname()); + HDfprintf(output, "see the <%s> entry in the 'HDF5 Reference Manual'.\n", h5tools_getprogname()); } - /*------------------------------------------------------------------------- * Function: get_option * @@ -182,8 +178,8 @@ help_ref_msg(FILE *output) int get_option(int argc, const char **argv, const char *opts, const struct long_options *l_opts) { - static int sp = 1; /* character index in current token */ - int opt_opt = '?'; /* option character passed back to user */ + static int sp = 1; /* character index in current token */ + int opt_opt = '?'; /* option character passed back to user */ if (sp == 1) { /* check for more flag-like tokens */ @@ -199,7 +195,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { /* long command line option */ const char *arg = &argv[opt_ind][2]; - int i; + int i; for (i = 0; l_opts && l_opts[i].name; i++) { size_t len = HDstrlen(l_opts[i].name); @@ -219,9 +215,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti } else if (l_opts[i].has_arg == require_arg) { if (opt_err) - HDfprintf(rawerrorstream, - "%s: option required for \"--%s\" flag\n", - argv[0], arg); + HDfprintf(rawerrorstream, "%s: option required for \"--%s\" flag\n", argv[0], + arg); opt_opt = '?'; } @@ -231,9 +226,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti else { if (arg[len] == '=') { if (opt_err) - HDfprintf(rawerrorstream, - "%s: no option required for \"%s\" flag\n", - argv[0], arg); + HDfprintf(rawerrorstream, "%s: no option required for \"%s\" flag\n", argv[0], + arg); opt_opt = '?'; } @@ -255,15 +249,14 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti sp = 1; } else { - register char *cp; /* pointer into current token */ + register char *cp; /* pointer into current token */ /* short command line option */ opt_opt = argv[opt_ind][sp]; if (opt_opt == ':' || (cp = HDstrchr(opts, opt_opt)) == 0) { if (opt_err) - HDfprintf(rawerrorstream, "%s: unknown option \"%c\"\n", - argv[0], opt_opt); + HDfprintf(rawerrorstream, "%s: unknown option \"%c\"\n", argv[0], opt_opt); /* if no chars left in this token, move to next token */ if (argv[opt_ind][++sp] == '\0') { @@ -281,9 +274,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti } else if (++opt_ind >= argc) { if (opt_err) - HDfprintf(rawerrorstream, - "%s: value expected for option \"%c\"\n", - argv[0], opt_opt); + HDfprintf(rawerrorstream, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); opt_opt = '?'; } @@ -299,8 +290,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti /* check the next argument */ opt_ind++; /* we do have an extra argument, check if not last */ - if ( (opt_ind+1) < argc ) { - if ( argv[opt_ind][0] != '-' ) { + if ((opt_ind + 1) < argc) { + if (argv[opt_ind][0] != '-') { opt_arg = argv[opt_ind++]; } else { @@ -326,7 +317,6 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti return opt_opt; } - /***************************************************************************** * * Function: parse_tuple() @@ -393,22 +383,16 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti ***************************************************************************** */ herr_t -parse_tuple(const char *start, - int sep, - char **cpy_out, - unsigned *nelems, - char ***ptrs_out) +parse_tuple(const char *start, int sep, char **cpy_out, unsigned *nelems, char ***ptrs_out) { - char *elem_ptr = NULL; - char *dest_ptr = NULL; - unsigned elems_count = 0; - char **elems = NULL; /* more like *elems[], but complier... */ - char **elems_re = NULL; /* temporary pointer, for realloc */ - char *cpy = NULL; - herr_t ret_value = SUCCEED; - unsigned init_slots = 2; - - + char * elem_ptr = NULL; + char * dest_ptr = NULL; + unsigned elems_count = 0; + char ** elems = NULL; /* more like *elems[], but complier... */ + char ** elems_re = NULL; /* temporary pointer, for realloc */ + char * cpy = NULL; + herr_t ret_value = SUCCEED; + unsigned init_slots = 2; /***************** * SANITY-CHECKS * @@ -433,8 +417,6 @@ parse_tuple(const char *start, elems_count = 0; - - /*********** * PREPARE * ***********/ @@ -442,22 +424,26 @@ parse_tuple(const char *start, /* create list */ elems = (char **)HDmalloc(sizeof(char *) * (init_slots + 1)); - if (elems == NULL) { ret_value = FAIL; goto done; } /* CANTALLOC */ + if (elems == NULL) { + ret_value = FAIL; + goto done; + } /* CANTALLOC */ /* create destination string */ - start++; /* advance past opening paren '(' */ + start++; /* advance past opening paren '(' */ cpy = (char *)HDmalloc(sizeof(char) * (HDstrlen(start))); /* no +1; less '(' */ - if (cpy == NULL) { ret_value = FAIL; goto done; } /* CANTALLOC */ + if (cpy == NULL) { + ret_value = FAIL; + goto done; + } /* CANTALLOC */ /* set pointers */ - dest_ptr = cpy; /* start writing copy here */ - elem_ptr = cpy; /* first element starts here */ + dest_ptr = cpy; /* start writing copy here */ + elem_ptr = cpy; /* first element starts here */ elems[elems_count++] = elem_ptr; /* set first element pointer into list */ - - /********* * PARSE * *********/ @@ -468,30 +454,30 @@ parse_tuple(const char *start, if (*start == '\\') { /* Possibly an escape digraph. */ - if ((*(start + 1) == '\\') || - (*(start + 1) == sep) ) - { + if ((*(start + 1) == '\\') || (*(start + 1) == sep)) { /* Valid escape digraph of "\\" or "\". */ - start++; /* advance past escape char '\' */ + start++; /* advance past escape char '\' */ *(dest_ptr++) = *(start++); /* Copy subsequent char */ /* and advance pointers. */ - } else { - /* Not an accepted escape digraph. - * Copy backslash character. - */ + } + else { + /* Not an accepted escape digraph. + * Copy backslash character. + */ *(dest_ptr++) = *(start++); } - } else if (*start == sep) { + } + else if (*start == sep) { /* Non-escaped separator. * Terminate elements substring in copy, record element, advance. * Expand elements list if appropriate. */ - *(dest_ptr++) = 0; /* Null-terminate elem substring in copy */ - /* and advance pointer. */ - start++; /* Advance src pointer past separator. */ - elem_ptr = dest_ptr; /* Element pointer points to start of first */ - /* character after null sep in copy. */ + *(dest_ptr++) = 0; /* Null-terminate elem substring in copy */ + /* and advance pointer. */ + start++; /* Advance src pointer past separator. */ + elem_ptr = dest_ptr; /* Element pointer points to start of first */ + /* character after null sep in copy. */ elems[elems_count++] = elem_ptr; /* Set elem pointer in list */ /* and increment count. */ @@ -499,8 +485,7 @@ parse_tuple(const char *start, */ if (elems_count == init_slots) { init_slots *= 2; - elems_re = (char **)realloc(elems, sizeof(char *) * \ - (init_slots + 1)); + elems_re = (char **)realloc(elems, sizeof(char *) * (init_slots + 1)); if (elems_re == NULL) { /* CANTREALLOC */ ret_value = FAIL; @@ -508,24 +493,24 @@ parse_tuple(const char *start, } elems = elems_re; } - } else if (*start == ')' && *(start + 1) == '\0') { + } + else if (*start == ')' && *(start + 1) == '\0') { /* Found terminal, non-escaped close-paren. Last element. * Write null terminator to copy. * Advance source pointer to gently break from loop. * Requred to prevent ")" from always being added to last element. */ start++; - } else { + } + else { /* Copy character into destination. Advance pointers. */ *(dest_ptr++) = *(start++); } } - *dest_ptr = '\0'; /* Null-terminate destination string. */ + *dest_ptr = '\0'; /* Null-terminate destination string. */ elems[elems_count] = NULL; /* Null-terminate elements list. */ - - /******************** * PASS BACK VALUES * ********************/ @@ -537,18 +522,16 @@ parse_tuple(const char *start, done: if (ret_value == FAIL) { /* CLEANUP */ - if (cpy) free(cpy); - if (elems) free(elems); + if (cpy) + free(cpy); + if (elems) + free(elems); } return ret_value; } /* parse_tuple */ - - - - /*------------------------------------------------------------------------- * Function: indentation * @@ -570,7 +553,6 @@ indentation(unsigned x) } } - /*------------------------------------------------------------------------- * Function: print_version * @@ -583,12 +565,10 @@ indentation(unsigned x) void print_version(const char *progname) { - PRINTSTREAM(rawoutstream, "%s: Version %u.%u.%u%s%s\n", - progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, - ((const char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE); + PRINTSTREAM(rawoutstream, "%s: Version %u.%u.%u%s%s\n", progname, H5_VERS_MAJOR, H5_VERS_MINOR, + H5_VERS_RELEASE, ((const char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE); } - /*------------------------------------------------------------------------- * Function: init_table * @@ -603,15 +583,14 @@ init_table(hid_t fid, table_t **tbl) { table_t *table = (table_t *)HDmalloc(sizeof(table_t)); - table->fid = fid; - table->size = 20; + table->fid = fid; + table->size = 20; table->nobjs = 0; - table->objs = (obj_t *)HDmalloc(table->size * sizeof(obj_t)); + table->objs = (obj_t *)HDmalloc(table->size * sizeof(obj_t)); *tbl = table; } - /*------------------------------------------------------------------------- * Function: free_table * @@ -624,11 +603,11 @@ init_table(hid_t fid, table_t **tbl) void free_table(table_t *table) { - unsigned u; /* Local index value */ + unsigned u; /* Local index value */ /* Free the names for the objects in the table */ - for(u = 0; u < table->nobjs; u++) - if(table->objs[u].objname) + for (u = 0; u < table->nobjs; u++) + if (table->objs[u].objname) HDfree(table->objs[u].objname); HDfree(table->objs); @@ -645,24 +624,22 @@ free_table(table_t *table) *------------------------------------------------------------------------- */ static void -dump_table(hid_t fid, char* tablename, table_t *table) +dump_table(hid_t fid, char *tablename, table_t *table) { unsigned u; - char *obj_tok_str = NULL; + char * obj_tok_str = NULL; - PRINTSTREAM(rawoutstream,"%s: # of entries = %d\n", tablename,table->nobjs); + PRINTSTREAM(rawoutstream, "%s: # of entries = %d\n", tablename, table->nobjs); for (u = 0; u < table->nobjs; u++) { H5VLconnector_token_to_str(fid, table->objs[u].obj_token, &obj_tok_str); - PRINTSTREAM(rawoutstream,"%s %s %d %d\n", obj_tok_str, - table->objs[u].objname, - table->objs[u].displayed, table->objs[u].recorded); + PRINTSTREAM(rawoutstream, "%s %s %d %d\n", obj_tok_str, table->objs[u].objname, + table->objs[u].displayed, table->objs[u].recorded); H5VLfree_token_str(fid, obj_tok_str); } } - /*------------------------------------------------------------------------- * Function: dump_tables * @@ -678,8 +655,7 @@ dump_tables(find_objs_t *info) dump_table(info->fid, "dset_table", info->dset_table); dump_table(info->fid, "type_table", info->type_table); } -#endif /* H5DUMP_DEBUG */ - +#endif /* H5DUMP_DEBUG */ /*------------------------------------------------------------------------- * Function: search_obj @@ -692,22 +668,21 @@ dump_tables(find_objs_t *info) *------------------------------------------------------------------------- */ H5_ATTR_PURE obj_t * -search_obj(table_t *table, const H5O_token_t *obj_token) + search_obj(table_t *table, const H5O_token_t *obj_token) { unsigned u; - int token_cmp; + int token_cmp; - for(u = 0; u < table->nobjs; u++) { - if(H5Otoken_cmp(table->fid, &table->objs[u].obj_token, obj_token, &token_cmp) < 0) + for (u = 0; u < table->nobjs; u++) { + if (H5Otoken_cmp(table->fid, &table->objs[u].obj_token, obj_token, &token_cmp) < 0) return NULL; - if(!token_cmp) + if (!token_cmp) return &(table->objs[u]); } return NULL; } - /*------------------------------------------------------------------------- * Function: find_objs_cb * @@ -721,31 +696,31 @@ search_obj(table_t *table, const H5O_token_t *obj_token) static herr_t find_objs_cb(const char *name, const H5O_info2_t *oinfo, const char *already_seen, void *op_data) { - find_objs_t *info = (find_objs_t*)op_data; - herr_t ret_value = 0; + find_objs_t *info = (find_objs_t *)op_data; + herr_t ret_value = 0; - switch(oinfo->type) { + switch (oinfo->type) { case H5O_TYPE_GROUP: - if(NULL == already_seen) + if (NULL == already_seen) add_obj(info->group_table, &oinfo->token, name, TRUE); break; case H5O_TYPE_DATASET: - if(NULL == already_seen) { + if (NULL == already_seen) { hid_t dset = H5I_INVALID_HID; /* Add the dataset to the list of objects */ add_obj(info->dset_table, &oinfo->token, name, TRUE); /* Check for a dataset that uses a named datatype */ - if((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) { hid_t type = H5Dget_type(dset); - if(H5Tcommitted(type) > 0) { + if (H5Tcommitted(type) > 0) { H5O_info2_t type_oinfo; H5Oget_info3(type, &type_oinfo, H5O_INFO_BASIC); - if(search_obj(info->type_table, &type_oinfo.token) == NULL) + if (search_obj(info->type_table, &type_oinfo.token) == NULL) add_obj(info->type_table, &type_oinfo.token, name, FALSE); } /* end if */ @@ -758,10 +733,10 @@ find_objs_cb(const char *name, const H5O_info2_t *oinfo, const char *already_see break; case H5O_TYPE_NAMED_DATATYPE: - if(NULL == already_seen) { + if (NULL == already_seen) { obj_t *found_obj; - if((found_obj = search_obj(info->type_table, &oinfo->token)) == NULL) + if ((found_obj = search_obj(info->type_table, &oinfo->token)) == NULL) add_obj(info->type_table, &oinfo->token, name, TRUE); else { /* Use latest version of name */ @@ -771,7 +746,7 @@ find_objs_cb(const char *name, const H5O_info2_t *oinfo, const char *already_see /* Mark named datatype as having valid name */ found_obj->recorded = TRUE; } /* end else */ - } /* end if */ + } /* end if */ break; case H5O_TYPE_MAP: @@ -784,7 +759,6 @@ find_objs_cb(const char *name, const H5O_info2_t *oinfo, const char *already_see return ret_value; } - /*------------------------------------------------------------------------- * Function: init_objs * @@ -796,8 +770,7 @@ find_objs_cb(const char *name, const H5O_info2_t *oinfo, const char *already_see *------------------------------------------------------------------------- */ herr_t -init_objs(hid_t fid, find_objs_t *info, table_t **group_table, - table_t **dset_table, table_t **type_table) +init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table) { herr_t ret_value = SUCCEED; @@ -807,18 +780,18 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, init_table(fid, type_table); /* Init the find_objs_t */ - info->fid = fid; + info->fid = fid; info->group_table = *group_table; - info->type_table = *type_table; - info->dset_table = *dset_table; + info->type_table = *type_table; + info->dset_table = *dset_table; /* Find all shared objects */ - if((ret_value = h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info, H5O_INFO_BASIC)) < 0) + if ((ret_value = h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info, H5O_INFO_BASIC)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "finding shared objects failed"); done: /* Release resources */ - if(ret_value < 0) { + if (ret_value < 0) { free_table(*group_table); info->group_table = NULL; free_table(*type_table); @@ -829,7 +802,6 @@ done: return ret_value; } - /*------------------------------------------------------------------------- * Function: add_obj * @@ -845,7 +817,7 @@ add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool size_t u; /* See if we need to make table larger */ - if(table->nobjs == table->size) { + if (table->nobjs == table->size) { table->size *= 2; table->objs = (struct obj_t *)HDrealloc(table->objs, table->size * sizeof(table->objs[0])); } /* end if */ @@ -855,12 +827,11 @@ add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool /* Set information about object */ HDmemcpy(&table->objs[u].obj_token, obj_token, sizeof(H5O_token_t)); - table->objs[u].objname = HDstrdup(objname); - table->objs[u].recorded = record; + table->objs[u].objname = HDstrdup(objname); + table->objs[u].recorded = record; table->objs[u].displayed = 0; } - #ifndef H5_HAVE_TMPFILE /*------------------------------------------------------------------------- * Function: tmpfile @@ -901,52 +872,54 @@ tmpfile(void) * link_info->trg_path must be freed out of this function *-------------------------------------------------------------------------*/ int -H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info, hbool_t get_obj_type) +H5tools_get_symlink_info(hid_t file_id, const char *linkpath, h5tool_link_info_t *link_info, + hbool_t get_obj_type) { - htri_t l_ret; + htri_t l_ret; H5O_info2_t trg_oinfo; - hid_t fapl = H5P_DEFAULT; - hid_t lapl = H5P_DEFAULT; - int ret_value = -1; /* init to fail */ + hid_t fapl = H5P_DEFAULT; + hid_t lapl = H5P_DEFAULT; + int ret_value = -1; /* init to fail */ /* init */ link_info->trg_type = H5O_TYPE_UNKNOWN; /* if path is root, return group type */ - if(!HDstrcmp(linkpath,"/")) { + if (!HDstrcmp(linkpath, "/")) { link_info->trg_type = H5O_TYPE_GROUP; H5TOOLS_GOTO_DONE(2); } /* check if link itself exist */ - if(H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0) { - if(link_info->opt.msg_mode == 1) - parallel_print("Warning: link <%s> doesn't exist \n",linkpath); + if (H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0) { + if (link_info->opt.msg_mode == 1) + parallel_print("Warning: link <%s> doesn't exist \n", linkpath); H5TOOLS_GOTO_DONE(FAIL); } /* end if */ /* get info from link */ - if(H5Lget_info2(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) { - if(link_info->opt.msg_mode == 1) - parallel_print("Warning: unable to get link info from <%s>\n",linkpath); + if (H5Lget_info2(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) { + if (link_info->opt.msg_mode == 1) + parallel_print("Warning: unable to get link info from <%s>\n", linkpath); H5TOOLS_GOTO_DONE(FAIL); } /* end if */ /* given path is hard link (object) */ - if(link_info->linfo.type == H5L_TYPE_HARD) + if (link_info->linfo.type == H5L_TYPE_HARD) H5TOOLS_GOTO_DONE(2); /* trg_path must be freed out of this function when finished using */ - if((link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char))) == NULL) { - if(link_info->opt.msg_mode == 1) - parallel_print("Warning: unable to allocate buffer for <%s>\n",linkpath); + if ((link_info->trg_path = (char *)HDcalloc(link_info->linfo.u.val_size, sizeof(char))) == NULL) { + if (link_info->opt.msg_mode == 1) + parallel_print("Warning: unable to allocate buffer for <%s>\n", linkpath); H5TOOLS_GOTO_DONE(FAIL); } /* end if */ /* get link value */ - if(H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) { - if(link_info->opt.msg_mode == 1) - parallel_print("Warning: unable to get link value from <%s>\n",linkpath); + if (H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < + 0) { + if (link_info->opt.msg_mode == 1) + parallel_print("Warning: unable to get link value from <%s>\n", linkpath); H5TOOLS_GOTO_DONE(FAIL); } /* end if */ @@ -954,51 +927,51 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_ * if link type is external link use different lapl to * follow object in other file */ - if(link_info->linfo.type == H5L_TYPE_EXTERNAL) { - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if (link_info->linfo.type == H5L_TYPE_EXTERNAL) { + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) H5TOOLS_GOTO_DONE(FAIL); - if(H5Pset_fapl_sec2(fapl) < 0) + if (H5Pset_fapl_sec2(fapl) < 0) H5TOOLS_GOTO_DONE(FAIL); - if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) + if ((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) H5TOOLS_GOTO_DONE(FAIL); - if(H5Pset_elink_fapl(lapl, fapl) < 0) + if (H5Pset_elink_fapl(lapl, fapl) < 0) H5TOOLS_GOTO_DONE(FAIL); } /* end if */ /* Check for retrieving object info */ - if(get_obj_type) { + if (get_obj_type) { /*-------------------------------------------------------------- * if link's target object exist, get type */ - /* check if target object exist */ + /* check if target object exist */ l_ret = H5Oexists_by_name(file_id, linkpath, lapl); /* detect dangling link */ - if(l_ret == FALSE) { + if (l_ret == FALSE) { H5TOOLS_GOTO_DONE(0); } - else if(l_ret < 0) { /* function failed */ + else if (l_ret < 0) { /* function failed */ H5TOOLS_GOTO_DONE(FAIL); } /* get target object info */ - if(H5Oget_info_by_name3(file_id, linkpath, &trg_oinfo, H5O_INFO_BASIC, lapl) < 0) { - if(link_info->opt.msg_mode == 1) + if (H5Oget_info_by_name3(file_id, linkpath, &trg_oinfo, H5O_INFO_BASIC, lapl) < 0) { + if (link_info->opt.msg_mode == 1) parallel_print("Warning: unable to get object information for <%s>\n", linkpath); H5TOOLS_GOTO_DONE(FAIL); } /* end if */ /* check unknown type */ - if(trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES) { - if(link_info->opt.msg_mode == 1) + if (trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >= H5O_TYPE_NTYPES) { + if (link_info->opt.msg_mode == 1) parallel_print("Warning: target object of <%s> is unknown type\n", linkpath); H5TOOLS_GOTO_DONE(FAIL); - } /* end if */ + } /* end if */ /* set target obj type to return */ HDmemcpy(&link_info->obj_token, &trg_oinfo.token, sizeof(H5O_token_t)); link_info->trg_type = trg_oinfo.type; - link_info->fileno = trg_oinfo.fileno; + link_info->fileno = trg_oinfo.fileno; } /* end if */ else link_info->trg_type = H5O_TYPE_UNKNOWN; @@ -1007,9 +980,9 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_ ret_value = 1; done: - if(fapl != H5P_DEFAULT) + if (fapl != H5P_DEFAULT) H5Pclose(fapl); - if(lapl != H5P_DEFAULT) + if (lapl != H5P_DEFAULT) H5Pclose(lapl); return ret_value; @@ -1039,13 +1012,13 @@ h5tools_setstatus(int D_status) H5_ATTR_PURE const char * h5tools_getprogname(void) { - return h5tools_progname; + return h5tools_progname; } H5_ATTR_PURE int h5tools_getstatus(void) { - return h5tools_d_status; + return h5tools_d_status; } /*----------------------------------------------------------- @@ -1059,13 +1032,13 @@ int h5tools_getenv_update_hyperslab_bufsize(void) { const char *env_str = NULL; - long hyperslab_bufsize_mb; - int ret_value = 1; + long hyperslab_bufsize_mb; + int ret_value = 1; /* check if environment variable is set for the hyperslab buffer size */ - if (NULL != (env_str = HDgetenv ("H5TOOLS_BUFSIZE"))) { - errno = 0; - hyperslab_bufsize_mb = HDstrtol(env_str, (char**)NULL, 10); + if (NULL != (env_str = HDgetenv("H5TOOLS_BUFSIZE"))) { + errno = 0; + hyperslab_bufsize_mb = HDstrtol(env_str, (char **)NULL, 10); if (errno != 0 || hyperslab_bufsize_mb <= 0) H5TOOLS_GOTO_ERROR(FAIL, "hyperslab buffer size failed"); @@ -1094,15 +1067,14 @@ done: *---------------------------------------------------------------------------- */ herr_t -h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, - H5FD_ros3_fapl_t *fapl_config_out) +h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, H5FD_ros3_fapl_t *fapl_config_out) { - const char *ccred[3]; - unsigned nelems = 0; - char *start = NULL; - char *s3cred_src = NULL; - char **s3cred = NULL; - herr_t ret_value = SUCCEED; + const char *ccred[3]; + unsigned nelems = 0; + char * start = NULL; + char * s3cred_src = NULL; + char ** s3cred = NULL; + herr_t ret_value = SUCCEED; /* Attempt to parse S3 credentials tuple */ if (parse_tuple(tuple_str, delim, &s3cred_src, &nelems, &s3cred) < 0) @@ -1128,7 +1100,6 @@ done: return ret_value; } - /*---------------------------------------------------------------------------- * * Function: h5tools_populate_ros3_fapl() @@ -1192,8 +1163,7 @@ done: *---------------------------------------------------------------------------- */ int -h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, - const char **values) +h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values) { int show_progress = 0; /* set to 1 for debugging */ int ret_value = 1; /* 1 for success, 0 for failure */ @@ -1248,9 +1218,7 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, /* if region and ID are supplied (key optional), write to fapl... * fail if value would overflow */ - if (*values[0] != '\0' && - *values[1] != '\0') - { + if (*values[0] != '\0' && *values[1] != '\0') { if (HDstrlen(values[0]) > H5FD_ROS3_MAX_REGION_LEN) { if (show_progress) { HDprintf(" ERROR: aws_region value too long\n"); @@ -1258,13 +1226,11 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, ret_value = 0; goto done; } - HDmemcpy(fa->aws_region, values[0], - (HDstrlen(values[0]) + 1)); + HDmemcpy(fa->aws_region, values[0], (HDstrlen(values[0]) + 1)); if (show_progress) { HDprintf(" aws_region set\n"); } - if (HDstrlen(values[1]) > H5FD_ROS3_MAX_SECRET_ID_LEN) { if (show_progress) { HDprintf(" ERROR: secret_id value too long\n"); @@ -1272,9 +1238,7 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, ret_value = 0; goto done; } - HDmemcpy(fa->secret_id, - values[1], - (HDstrlen(values[1]) + 1)); + HDmemcpy(fa->secret_id, values[1], (HDstrlen(values[1]) + 1)); if (show_progress) { HDprintf(" secret_id set\n"); } @@ -1286,9 +1250,7 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, ret_value = 0; goto done; } - HDmemcpy(fa->secret_key, - values[2], - (HDstrlen(values[2]) + 1)); + HDmemcpy(fa->secret_key, values[2], (HDstrlen(values[2]) + 1)); if (show_progress) { HDprintf(" secret_key set\n"); } @@ -1297,15 +1259,10 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, if (show_progress) { HDprintf(" set to authenticate\n"); } - - } else if (*values[0] != '\0' || - *values[1] != '\0' || - *values[2] != '\0') - { + } + else if (*values[0] != '\0' || *values[1] != '\0' || *values[2] != '\0') { if (show_progress) { - HDprintf( - " ERROR: invalid assortment of empty/non-empty values\n" - ); + HDprintf(" ERROR: invalid assortment of empty/non-empty values\n"); } ret_value = 0; goto done; @@ -1330,14 +1287,13 @@ done: *---------------------------------------------------------------------------- */ herr_t -h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, - H5FD_hdfs_fapl_t *fapl_config_out) +h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, H5FD_hdfs_fapl_t *fapl_config_out) { - unsigned long k = 0; - unsigned nelems = 0; - char *props_src = NULL; - char **props = NULL; - herr_t ret_value = SUCCEED; + unsigned long k = 0; + unsigned nelems = 0; + char * props_src = NULL; + char ** props = NULL; + herr_t ret_value = SUCCEED; /* Attempt to parse HDFS configuration tuple */ if (parse_tuple(tuple_str, delim, &props_src, &nelems, &props) < 0) @@ -1382,4 +1338,3 @@ done: return ret_value; } #endif /* H5_HAVE_LIBHDFS */ - diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index 42144cc..e22c727 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -27,13 +27,13 @@ extern "C" { #endif /* ``parallel_print'' information */ -#define PRINT_DATA_MAX_SIZE 512 -#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4) +#define PRINT_DATA_MAX_SIZE 512 +#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE * 4) -H5TOOLS_DLLVAR int g_nTasks; +H5TOOLS_DLLVAR int g_nTasks; H5TOOLS_DLLVAR unsigned char g_Parallel; -H5TOOLS_DLLVAR char outBuff[]; -H5TOOLS_DLLVAR unsigned outBuffOffset; +H5TOOLS_DLLVAR char outBuff[]; +H5TOOLS_DLLVAR unsigned outBuffOffset; H5TOOLS_DLLVAR FILE *overflow_file; /* Maximum size used in a call to malloc for a dataset */ @@ -43,14 +43,14 @@ H5TOOLS_DLLVAR hsize_t H5TOOLS_BUFSIZE; /* * begin get_option section */ -H5TOOLS_DLLVAR int opt_err; /* getoption prints errors if this is on */ -H5TOOLS_DLLVAR int opt_ind; /* token pointer */ -H5TOOLS_DLLVAR const char *opt_arg; /* flag argument (or value) */ +H5TOOLS_DLLVAR int opt_err; /* getoption prints errors if this is on */ +H5TOOLS_DLLVAR int opt_ind; /* token pointer */ +H5TOOLS_DLLVAR const char *opt_arg; /* flag argument (or value) */ enum { - no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ - optional_arg /* argument is optional */ + no_arg = 0, /* doesn't take an argument */ + require_arg, /* requires an argument */ + optional_arg /* argument is optional */ }; /* @@ -82,10 +82,10 @@ enum { * end. */ typedef struct long_options { - const char *name; /* name of the long option */ - int has_arg; /* whether we should look for an arg */ - char shortval; /* the shortname equivalent of long arg - * this gets returned from get_option */ + const char *name; /* name of the long option */ + int has_arg; /* whether we should look for an arg */ + char shortval; /* the shortname equivalent of long arg + * this gets returned from get_option */ } long_options; H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt, const struct long_options *l_opt); @@ -95,15 +95,15 @@ H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt, const s /*struct taken from the dumper. needed in table struct*/ typedef struct obj_t { - H5O_token_t obj_token; - char *objname; - hbool_t displayed; /* Flag to indicate that the object has been displayed */ - hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */ + H5O_token_t obj_token; + char * objname; + hbool_t displayed; /* Flag to indicate that the object has been displayed */ + hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */ } obj_t; /*struct for the tables that the find_objs function uses*/ typedef struct table_t { - hid_t fid; + hid_t fid; size_t size; size_t nobjs; obj_t *objs; @@ -117,21 +117,23 @@ typedef struct find_objs_t { table_t *dset_table; } find_objs_t; -H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for outputting */ +H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for outputting */ /* Definitions of useful routines */ -H5TOOLS_DLL void indentation(unsigned); -H5TOOLS_DLL void print_version(const char *progname); -H5TOOLS_DLL void parallel_print(const char* format, ... ); -H5TOOLS_DLL herr_t parse_tuple(const char *start, int sep, char **cpy_out, unsigned *nelems, char ***ptrs_out); -H5TOOLS_DLL void error_msg(const char *fmt, ...); -H5TOOLS_DLL void warn_msg(const char *fmt, ...); -H5TOOLS_DLL void help_ref_msg(FILE *output); -H5TOOLS_DLL void free_table(table_t *table); +H5TOOLS_DLL void indentation(unsigned); +H5TOOLS_DLL void print_version(const char *progname); +H5TOOLS_DLL void parallel_print(const char *format, ...); +H5TOOLS_DLL herr_t parse_tuple(const char *start, int sep, char **cpy_out, unsigned *nelems, + char ***ptrs_out); +H5TOOLS_DLL void error_msg(const char *fmt, ...); +H5TOOLS_DLL void warn_msg(const char *fmt, ...); +H5TOOLS_DLL void help_ref_msg(FILE *output); +H5TOOLS_DLL void free_table(table_t *table); #ifdef H5DUMP_DEBUG H5TOOLS_DLL void dump_tables(find_objs_t *info); -#endif /* H5DUMP_DEBUG */ -H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table); +#endif /* H5DUMP_DEBUG */ +H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, + table_t **type_table); H5TOOLS_DLL obj_t *search_obj(table_t *temp, const H5O_token_t *obj_token); #ifndef H5_HAVE_TMPFILE H5TOOLS_DLL FILE *tmpfile(void); @@ -145,46 +147,48 @@ H5TOOLS_DLL FILE *tmpfile(void); /* This code is layout for common code among tools */ typedef enum toolname_t { - TOOL_H5DIFF, TOOL_H5LS, TOOL__H5DUMP /* add as necessary */ + TOOL_H5DIFF, + TOOL_H5LS, + TOOL__H5DUMP /* add as necessary */ } h5tool_toolname_t; /* this struct can be used to differntiate among tools */ typedef struct { h5tool_toolname_t toolname; - int msg_mode; + int msg_mode; } h5tool_opt_t; /* obtain link info from H5tools_get_symlink_info() */ typedef struct { - H5O_type_t trg_type; /* OUT: target type */ - char *trg_path; /* OUT: target obj path. This must be freed + H5O_type_t trg_type; /* OUT: target type */ + char * trg_path; /* OUT: target obj path. This must be freed * when used with H5tools_get_symlink_info() */ - H5O_token_t obj_token; /* OUT: target object token */ + H5O_token_t obj_token; /* OUT: target object token */ unsigned long fileno; /* OUT: File number that target object is located in */ H5L_info2_t linfo; /* OUT: link info */ h5tool_opt_t opt; /* IN: options */ } h5tool_link_info_t; - /* Definitions of routines */ -H5TOOLS_DLL int H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info, hbool_t get_obj_type); +H5TOOLS_DLL int H5tools_get_symlink_info(hid_t file_id, const char *linkpath, h5tool_link_info_t *link_info, + hbool_t get_obj_type); H5TOOLS_DLL const char *h5tools_getprogname(void); -H5TOOLS_DLL void h5tools_setprogname(const char*progname); -H5TOOLS_DLL int h5tools_getstatus(void); -H5TOOLS_DLL void h5tools_setstatus(int d_status); -H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void); +H5TOOLS_DLL void h5tools_setprogname(const char *progname); +H5TOOLS_DLL int h5tools_getstatus(void); +H5TOOLS_DLL void h5tools_setstatus(int d_status); +H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void); #ifdef H5_HAVE_ROS3_VFD H5TOOLS_DLL herr_t h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, - H5FD_ros3_fapl_t *fapl_config_out); -H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values); + H5FD_ros3_fapl_t *fapl_config_out); +H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values); #endif /* H5_HAVE_ROS3_VFD */ #ifdef H5_HAVE_LIBHDFS H5TOOLS_DLL herr_t h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, - H5FD_hdfs_fapl_t *fapl_config_out); + H5FD_hdfs_fapl_t *fapl_config_out); #endif #ifdef __cplusplus } #endif -#endif /* H5TOOLS_UTILS_H__ */ +#endif /* H5TOOLS_UTILS_H__ */ diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index dc7e27d..74357d0 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -11,7 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #include "h5trav.h" #include "h5tools.h" #include "H5private.h" @@ -22,32 +21,32 @@ */ typedef struct trav_addr_path_t { H5O_token_t token; - char *path; + char * path; } trav_addr_path_t; typedef struct trav_addr_t { - size_t nalloc; - size_t nused; + size_t nalloc; + size_t nused; trav_addr_path_t *objs; } trav_addr_t; typedef struct { - h5trav_obj_func_t visit_obj; /* Callback for visiting objects */ - h5trav_lnk_func_t visit_lnk; /* Callback for visiting links */ - void *udata; /* User data to pass to callbacks */ + h5trav_obj_func_t visit_obj; /* Callback for visiting objects */ + h5trav_lnk_func_t visit_lnk; /* Callback for visiting links */ + void * udata; /* User data to pass to callbacks */ } trav_visitor_t; typedef struct { - trav_addr_t *seen; /* List of addresses seen already */ - const trav_visitor_t *visitor; /* Information for visiting each link/object */ - hbool_t is_absolute; /* Whether the traversal has absolute paths */ - const char *base_grp_name; /* Name of the group that serves as the base - * for iteration */ - unsigned fields; /* Fields needed in H5O_info2_t struct */ + trav_addr_t * seen; /* List of addresses seen already */ + const trav_visitor_t *visitor; /* Information for visiting each link/object */ + hbool_t is_absolute; /* Whether the traversal has absolute paths */ + const char * base_grp_name; /* Name of the group that serves as the base + * for iteration */ + unsigned fields; /* Fields needed in H5O_info2_t struct */ } trav_ud_traverse_t; typedef struct { - hid_t fid; /* File ID being traversed */ + hid_t fid; /* File ID being traversed */ } trav_print_udata_t; typedef struct trav_path_op_data_t { @@ -56,26 +55,22 @@ typedef struct trav_path_op_data_t { /* format for hsize_t */ #ifdef H5TRAV_PRINT_SPACE -#define HSIZE_T_FORMAT "%" H5_PRINTF_LL_WIDTH "u" +#define HSIZE_T_FORMAT "%" H5_PRINTF_LL_WIDTH "u" #endif /* H5TRAV_PRINT_SPACE */ /*------------------------------------------------------------------------- * local functions *------------------------------------------------------------------------- */ -static void trav_table_add(trav_table_t *table, - const char *objname, - const H5O_info2_t *oinfo); +static void trav_table_add(trav_table_t *table, const char *objname, const H5O_info2_t *oinfo); -static void trav_table_addlink(trav_table_t *table, - const H5O_token_t *obj_token, - const char *path); +static void trav_table_addlink(trav_table_t *table, const H5O_token_t *obj_token, const char *path); /*------------------------------------------------------------------------- * local variables *------------------------------------------------------------------------- */ -static H5_index_t trav_index_by = H5_INDEX_NAME; +static H5_index_t trav_index_by = H5_INDEX_NAME; static H5_iter_order_t trav_index_order = H5_ITER_INC; static int trav_verbosity = 0; @@ -91,7 +86,7 @@ static int trav_verbosity = 0; void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order) { - trav_index_by = print_index_by; + trav_index_by = print_index_by; trav_index_order = print_index_order; } @@ -114,7 +109,6 @@ h5trav_set_verbose(int print_verbose) *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: trav_token_add * @@ -126,12 +120,14 @@ h5trav_set_verbose(int print_verbose) static void trav_token_add(trav_addr_t *visited, H5O_token_t *token, const char *path) { - size_t idx; /* Index of address to use */ + size_t idx; /* Index of address to use */ /* Allocate space if necessary */ - if(visited->nused == visited->nalloc) { - visited->nalloc = MAX(1, visited->nalloc * 2);; - visited->objs = (trav_addr_path_t *)HDrealloc(visited->objs, visited->nalloc * sizeof(trav_addr_path_t)); + if (visited->nused == visited->nalloc) { + visited->nalloc = MAX(1, visited->nalloc * 2); + ; + visited->objs = + (trav_addr_path_t *)HDrealloc(visited->objs, visited->nalloc * sizeof(trav_addr_path_t)); } /* end if */ /* Append it */ @@ -140,7 +136,6 @@ trav_token_add(trav_addr_t *visited, H5O_token_t *token, const char *path) visited->objs[idx].path = HDstrdup(path); } /* end trav_token_add() */ - /*------------------------------------------------------------------------- * Function: trav_token_visited * @@ -152,23 +147,22 @@ trav_token_add(trav_addr_t *visited, H5O_token_t *token, const char *path) H5_ATTR_PURE static const char * trav_token_visited(hid_t loc_id, trav_addr_t *visited, H5O_token_t *token) { - size_t u; /* Local index variable */ - int token_cmp; + size_t u; /* Local index variable */ + int token_cmp; /* Look for address */ - for(u = 0; u < visited->nused; u++) { + for (u = 0; u < visited->nused; u++) { /* Check for address already in array */ - if(H5Otoken_cmp(loc_id, &visited->objs[u].token, token, &token_cmp) < 0) + if (H5Otoken_cmp(loc_id, &visited->objs[u].token, token, &token_cmp) < 0) return NULL; - if(!token_cmp) - return(visited->objs[u].path); + if (!token_cmp) + return (visited->objs[u].path); } /* Didn't find object token */ - return(NULL); + return (NULL); } /* end trav_token_visited() */ - /*------------------------------------------------------------------------- * Function: traverse_cb * @@ -176,23 +170,23 @@ trav_token_visited(hid_t loc_id, trav_addr_t *visited, H5O_token_t *token) *------------------------------------------------------------------------- */ static herr_t -traverse_cb(hid_t loc_id, const char *path, const H5L_info2_t *linfo, - void *_udata) +traverse_cb(hid_t loc_id, const char *path, const H5L_info2_t *linfo, void *_udata) { - trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */ - char *new_name = NULL; - const char *full_name; - const char *already_visited = NULL; /* Whether the link/object was already visited */ + trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */ + char * new_name = NULL; + const char * full_name; + const char * already_visited = NULL; /* Whether the link/object was already visited */ /* Create the full path name for the link */ - if(udata->is_absolute) { - size_t base_len = HDstrlen(udata->base_grp_name); - size_t add_slash = base_len ? ((udata->base_grp_name)[base_len - 1] != '/') : 1; - size_t new_name_len = base_len + add_slash + HDstrlen(path) + 1 + 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */ - - if(NULL == (new_name = (char*)HDmalloc(new_name_len))) - return(H5_ITER_ERROR); - if(add_slash) + if (udata->is_absolute) { + size_t base_len = HDstrlen(udata->base_grp_name); + size_t add_slash = base_len ? ((udata->base_grp_name)[base_len - 1] != '/') : 1; + size_t new_name_len = base_len + add_slash + HDstrlen(path) + 1 + + 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */ + + if (NULL == (new_name = (char *)HDmalloc(new_name_len))) + return (H5_ITER_ERROR); + if (add_slash) HDsnprintf(new_name, new_name_len, "%s/%s", udata->base_grp_name, path); else HDsnprintf(new_name, new_name_len, "%s%s", udata->base_grp_name, path); @@ -202,48 +196,47 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info2_t *linfo, full_name = path; /* Perform the correct action for different types of links */ - if(linfo->type == H5L_TYPE_HARD) { + if (linfo->type == H5L_TYPE_HARD) { H5O_info2_t oinfo; /* Get information about the object */ - if(H5Oget_info_by_name3(loc_id, path, &oinfo, udata->fields, H5P_DEFAULT) < 0) { - if(new_name) + if (H5Oget_info_by_name3(loc_id, path, &oinfo, udata->fields, H5P_DEFAULT) < 0) { + if (new_name) HDfree(new_name); - return(H5_ITER_ERROR); + return (H5_ITER_ERROR); } /* end if */ /* If the object has multiple links, add it to the list of addresses * already visited, if it isn't there already */ - if(oinfo.rc > 1) - if(NULL == (already_visited = trav_token_visited(loc_id, udata->seen, &oinfo.token))) + if (oinfo.rc > 1) + if (NULL == (already_visited = trav_token_visited(loc_id, udata->seen, &oinfo.token))) trav_token_add(udata->seen, &oinfo.token, full_name); /* Make 'visit object' callback */ - if(udata->visitor->visit_obj) - if((*udata->visitor->visit_obj)(full_name, &oinfo, already_visited, udata->visitor->udata) < 0) { - if(new_name) + if (udata->visitor->visit_obj) + if ((*udata->visitor->visit_obj)(full_name, &oinfo, already_visited, udata->visitor->udata) < 0) { + if (new_name) HDfree(new_name); - return(H5_ITER_ERROR); + return (H5_ITER_ERROR); } /* end if */ - } /* end if */ + } /* end if */ else { /* Make 'visit link' callback */ - if(udata->visitor->visit_lnk) - if((*udata->visitor->visit_lnk)(full_name, linfo, udata->visitor->udata) < 0) { - if(new_name) + if (udata->visitor->visit_lnk) + if ((*udata->visitor->visit_lnk)(full_name, linfo, udata->visitor->udata) < 0) { + if (new_name) HDfree(new_name); - return(H5_ITER_ERROR); + return (H5_ITER_ERROR); } /* end if */ - } /* end else */ + } /* end else */ - if(new_name) + if (new_name) HDfree(new_name); - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /* end traverse_cb() */ - /*------------------------------------------------------------------------- * Function: traverse * @@ -255,68 +248,69 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info2_t *linfo, *------------------------------------------------------------------------- */ static int -traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, - hbool_t recurse, const trav_visitor_t *visitor, unsigned fields) +traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse, + const trav_visitor_t *visitor, unsigned fields) { - H5O_info2_t oinfo; /* Object info for starting group */ + H5O_info2_t oinfo; /* Object info for starting group */ int ret_value = 0; /* Get info for starting object */ - if(H5Oget_info_by_name3(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0) + if (H5Oget_info_by_name3(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Oget_info_by_name failed"); /* Visit the starting object */ - if(visit_start && visitor->visit_obj) + if (visit_start && visitor->visit_obj) (*visitor->visit_obj)(grp_name, &oinfo, NULL, visitor->udata); /* Go visiting, if the object is a group */ - if(oinfo.type == H5O_TYPE_GROUP) { - trav_addr_t seen; /* List of addresses seen */ - trav_ud_traverse_t udata; /* User data for iteration callback */ + if (oinfo.type == H5O_TYPE_GROUP) { + trav_addr_t seen; /* List of addresses seen */ + trav_ud_traverse_t udata; /* User data for iteration callback */ /* Init addresses seen */ seen.nused = seen.nalloc = 0; - seen.objs = NULL; + seen.objs = NULL; /* Check for multiple links to top group */ - if(oinfo.rc > 1) + if (oinfo.rc > 1) trav_token_add(&seen, &oinfo.token, grp_name); /* Set up user data structure */ - udata.seen = &seen; - udata.visitor = visitor; - udata.is_absolute = (*grp_name == '/'); + udata.seen = &seen; + udata.visitor = visitor; + udata.is_absolute = (*grp_name == '/'); udata.base_grp_name = grp_name; - udata.fields = fields; + udata.fields = fields; /* Check for iteration of links vs. visiting all links recursively */ - if(recurse) { + if (recurse) { /* Visit all links in group, recursively */ - if(H5Lvisit_by_name2(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0) + if (H5Lvisit_by_name2(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, + H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Lvisit_by_name failed"); } /* end if */ else { /* Iterate over links in group */ - if(H5Literate_by_name2(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0) + if (H5Literate_by_name2(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, + &udata, H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Literate_by_name failed"); } /* end else */ /* Free visited addresses table */ - if(seen.objs) { - size_t u; /* Local index variable */ + if (seen.objs) { + size_t u; /* Local index variable */ /* Free paths to objects */ - for(u = 0; u < seen.nused; u++) + for (u = 0; u < seen.nused; u++) HDfree(seen.objs[u].path); HDfree(seen.objs); } /* end if */ - } /* end if */ + } /* end if */ done: return ret_value; } - /*------------------------------------------------------------------------- * Function: trav_info_add * @@ -328,19 +322,20 @@ done: void trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type) { - size_t idx; /* Index of address to use */ + size_t idx; /* Index of address to use */ if (info) { /* Allocate space if necessary */ - if(info->nused == info->nalloc) { - info->nalloc = MAX(1, info->nalloc * 2);; + if (info->nused == info->nalloc) { + info->nalloc = MAX(1, info->nalloc * 2); + ; info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t)); } /* end if */ /* Append it */ - idx = info->nused++; - info->paths[idx].path = HDstrdup(path); - info->paths[idx].type = obj_type; + idx = info->nused++; + info->paths[idx].path = HDstrdup(path); + info->paths[idx].type = obj_type; info->paths[idx].fileno = 0; /* Set token to 'undefined' values */ @@ -348,7 +343,6 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type) } } /* end trav_info_add() */ - /*------------------------------------------------------------------------- * Function: trav_fileinfo_add * @@ -361,9 +355,9 @@ void trav_fileinfo_add(trav_info_t *info, hid_t loc_id) { H5O_info2_t oinfo; - size_t idx = info->nused - 1; + size_t idx = info->nused - 1; - if(info->paths[idx].path && HDstrcmp(info->paths[idx].path, ".")) + if (info->paths[idx].path && HDstrcmp(info->paths[idx].path, ".")) H5Oget_info_by_name3(loc_id, info->paths[idx].path, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); else H5Oget_info3(loc_id, &oinfo, H5O_INFO_BASIC); @@ -372,7 +366,6 @@ trav_fileinfo_add(trav_info_t *info, hid_t loc_id) info->paths[idx].fileno = oinfo.fileno; } /* end trav_fileinfo_add() */ - /*------------------------------------------------------------------------- * Function: trav_info_visit_obj * @@ -383,10 +376,10 @@ trav_fileinfo_add(trav_info_t *info, hid_t loc_id) *------------------------------------------------------------------------- */ int -trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo, - const char H5_ATTR_UNUSED *already_visited, void *udata) +trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo, const char H5_ATTR_UNUSED *already_visited, + void *udata) { - size_t idx; + size_t idx; trav_info_t *info_p; /* Add the object to the 'info' struct */ @@ -394,15 +387,14 @@ trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo, trav_info_add((trav_info_t *)udata, path, (h5trav_type_t)oinfo->type); /* set object addr and fileno. These are for checking same object */ - info_p = (trav_info_t *) udata; - idx = info_p->nused - 1; + info_p = (trav_info_t *)udata; + idx = info_p->nused - 1; HDmemcpy(&info_p->paths[idx].obj_token, &oinfo->token, sizeof(H5O_token_t)); info_p->paths[idx].fileno = oinfo->fileno; - return(0); + return (0); } /* end trav_info_visit_obj() */ - /*------------------------------------------------------------------------- * Function: trav_info_visit_lnk * @@ -416,12 +408,12 @@ int trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata) { /* Add the link to the 'info' struct */ - trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5TRAV_TYPE_LINK : H5TRAV_TYPE_UDLINK)); + trav_info_add((trav_info_t *)udata, path, + ((linfo->type == H5L_TYPE_SOFT) ? H5TRAV_TYPE_LINK : H5TRAV_TYPE_UDLINK)); - return(0); + return (0); } /* end trav_info_visit_lnk() */ - /*------------------------------------------------------------------------- * Function: h5trav_getinfo * @@ -435,16 +427,16 @@ trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata) int h5trav_getinfo(hid_t file_id, trav_info_t *info) { - trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */ + trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */ int ret_value = 0; /* Init visitor structure */ info_visitor.visit_obj = trav_info_visit_obj; info_visitor.visit_lnk = trav_info_visit_lnk; - info_visitor.udata = info; + info_visitor.udata = info; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(file_id, "/", TRUE, TRUE, &info_visitor, H5O_INFO_BASIC) < 0) + if (traverse(file_id, "/", TRUE, TRUE, &info_visitor, H5O_INFO_BASIC) < 0) H5TOOLS_GOTO_ERROR((-1), "traverse failed"); done: @@ -463,23 +455,22 @@ done: H5_ATTR_PURE ssize_t h5trav_getindex(const trav_info_t *info, const char *obj) { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ /* Loop over all paths in 'info' struct, looking for object */ - for(u = 0; u < info->nused; u++) { + for (u = 0; u < info->nused; u++) { /* Check for object name having full path (with leading '/') */ - if(HDstrcmp(obj, info->paths[u].path) == 0) - return((ssize_t)u); + if (HDstrcmp(obj, info->paths[u].path) == 0) + return ((ssize_t)u); /* Check for object name without leading '/' */ - if(HDstrcmp(obj, (info->paths[u].path + 1)) == 0) - return((ssize_t)u); + if (HDstrcmp(obj, (info->paths[u].path + 1)) == 0) + return ((ssize_t)u); } /* end for */ - return((ssize_t)-1); + return ((ssize_t)-1); } /* end h5trav_getindex() */ - /*------------------------------------------------------------------------- * Function: trav_info_init * @@ -495,19 +486,18 @@ trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info) /* Init info structure */ info->nused = info->nalloc = 0; - info->paths = NULL; - info->fname = filename; - info->fid = fileid; + info->paths = NULL; + info->fname = filename; + info->fid = fileid; /* Initialize list of visited symbolic links */ - info->symlink_visited.nused = 0; - info->symlink_visited.nalloc = 0; - info->symlink_visited.objs = NULL; + info->symlink_visited.nused = 0; + info->symlink_visited.nalloc = 0; + info->symlink_visited.objs = NULL; info->symlink_visited.dangle_link = FALSE; - *_info = info; + *_info = info; } /* end trav_info_init() */ - /*------------------------------------------------------------------------- * Function: trav_info_free * @@ -517,11 +507,11 @@ trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info) void trav_info_free(trav_info_t *info) { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ - if(info) { + if (info) { /* Free visited symbolic links path and file (if alloc) */ - for(u = 0; u < info->symlink_visited.nused; u++) { + for (u = 0; u < info->symlink_visited.nused; u++) { if (info->symlink_visited.objs[u].file) HDfree(info->symlink_visited.objs[u].file); HDfree(info->symlink_visited.objs[u].path); @@ -529,20 +519,18 @@ trav_info_free(trav_info_t *info) HDfree(info->symlink_visited.objs); /* Free path names */ - for(u = 0; u < info->nused; u++) + for (u = 0; u < info->nused; u++) HDfree(info->paths[u].path); HDfree(info->paths); HDfree(info); } /* end if */ } /* end trav_info_free() */ - /*------------------------------------------------------------------------- * "h5trav table" public functions. used in h5repack *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: trav_table_visit_obj * @@ -553,13 +541,12 @@ trav_info_free(trav_info_t *info) *------------------------------------------------------------------------- */ static int -trav_table_visit_obj(const char *path, const H5O_info2_t *oinfo, - const char *already_visited, void *udata) +trav_table_visit_obj(const char *path, const H5O_info2_t *oinfo, const char *already_visited, void *udata) { trav_table_t *table = (trav_table_t *)udata; /* Check if we've already seen this object */ - if(NULL == already_visited) + if (NULL == already_visited) /* add object to table */ trav_table_add(table, path, oinfo); else @@ -569,7 +556,6 @@ trav_table_visit_obj(const char *path, const H5O_info2_t *oinfo, return 0; } /* end trav_table_visit_obj() */ - /*------------------------------------------------------------------------- * Function: trav_table_visit_lnk * @@ -588,7 +574,6 @@ trav_table_visit_lnk(const char *path, const H5L_info2_t H5_ATTR_UNUSED *linfo, return 0; } /* end trav_table_visit_lnk() */ - /*------------------------------------------------------------------------- * Function: h5trav_gettable * @@ -601,16 +586,16 @@ trav_table_visit_lnk(const char *path, const H5L_info2_t H5_ATTR_UNUSED *linfo, int h5trav_gettable(hid_t fid, trav_table_t *table) { - trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */ + trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */ int ret_value = 0; /* Init visitor structure */ table_visitor.visit_obj = trav_table_visit_obj; table_visitor.visit_lnk = trav_table_visit_lnk; - table_visitor.udata = table; + table_visitor.udata = table; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(fid, "/", TRUE, TRUE, &table_visitor, H5O_INFO_BASIC) < 0) + if (traverse(fid, "/", TRUE, TRUE, &table_visitor, H5O_INFO_BASIC) < 0) H5TOOLS_GOTO_ERROR((-1), "traverse failed"); done: @@ -631,31 +616,31 @@ h5trav_getindext(const char *name, const trav_table_t *table) { unsigned int i; - if(table) { - for(i = 0; i < table->nobjs; i++) { + if (table) { + for (i = 0; i < table->nobjs; i++) { /* Check for object name having full path (with leading '/') */ - if(HDstrcmp(name, table->objs[i].name) == 0) - return((int)i); + if (HDstrcmp(name, table->objs[i].name) == 0) + return ((int)i); /* Check for object name without leading '/' */ - if(HDstrcmp(name, table->objs[i].name + 1) == 0) - return((int)i); + if (HDstrcmp(name, table->objs[i].name + 1) == 0) + return ((int)i); /* search also in the list of links */ - if(table->objs[i].nlinks) { + if (table->objs[i].nlinks) { unsigned int j; - for ( j=0; jobjs[i].nlinks; j++) { + for (j = 0; j < table->objs[i].nlinks; j++) { /* Check for object name having full path (with leading '/') */ - if(HDstrcmp(name, table->objs[i].links[j].new_name) == 0) - return((int)i); + if (HDstrcmp(name, table->objs[i].links[j].new_name) == 0) + return ((int)i); /* Check for object name without leading '/' */ - if(HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0) - return((int)i); + if (HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0) + return ((int)i); } /* end for */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ } return -1; } @@ -673,25 +658,25 @@ trav_table_add(trav_table_t *table, const char *path, const H5O_info2_t *oinfo) { size_t new_obj; - if(table) { - if(table->nobjs == table->size) { + if (table) { + if (table->nobjs == table->size) { table->size = MAX(1, table->size * 2); table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); } /* end if */ new_obj = table->nobjs++; - if(oinfo) + if (oinfo) HDmemcpy(&table->objs[new_obj].obj_token, &oinfo->token, sizeof(H5O_token_t)); else /* Set token to 'undefined' values */ table->objs[new_obj].obj_token = H5O_TOKEN_UNDEF; table->objs[new_obj].flags[0] = table->objs[new_obj].flags[1] = 0; - table->objs[new_obj].is_same_trgobj = 0; - table->objs[new_obj].name = (char *)HDstrdup(path); - table->objs[new_obj].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK; - table->objs[new_obj].nlinks = 0; + table->objs[new_obj].is_same_trgobj = 0; + table->objs[new_obj].name = (char *)HDstrdup(path); + table->objs[new_obj].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK; + table->objs[new_obj].nlinks = 0; table->objs[new_obj].sizelinks = 0; - table->objs[new_obj].links = NULL; + table->objs[new_obj].links = NULL; } } @@ -706,37 +691,37 @@ trav_table_add(trav_table_t *table, const char *path, const H5O_info2_t *oinfo) static void trav_table_addlink(trav_table_t *table, const H5O_token_t *obj_token, const char *path) { - size_t i; /* Local index variable */ - int token_cmp; + size_t i; /* Local index variable */ + int token_cmp; - if(table) { - for(i = 0; i < table->nobjs; i++) { - if(H5Otoken_cmp(table->fid, &table->objs[i].obj_token, obj_token, &token_cmp) < 0) + if (table) { + for (i = 0; i < table->nobjs; i++) { + if (H5Otoken_cmp(table->fid, &table->objs[i].obj_token, obj_token, &token_cmp) < 0) return; - if(!token_cmp) { + if (!token_cmp) { size_t n; /* already inserted? */ - if(HDstrcmp(table->objs[i].name, path) == 0) + if (HDstrcmp(table->objs[i].name, path) == 0) return; /* allocate space if necessary */ - if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) { + if (table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) { table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2); - table->objs[i].links = (trav_link_t *)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t)); + table->objs[i].links = (trav_link_t *)HDrealloc( + table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t)); } /* end if */ /* insert it */ - n = table->objs[i].nlinks++; + n = table->objs[i].nlinks++; table->objs[i].links[n].new_name = (char *)HDstrdup(path); return; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ } - /*------------------------------------------------------------------------- * Function: trav_table_addflags * @@ -745,15 +730,13 @@ trav_table_addlink(trav_table_t *table, const H5O_token_t *obj_token, const char * Return: void *------------------------------------------------------------------------- */ -void trav_table_addflags(unsigned *flags, - char *name, - h5trav_type_t type, - trav_table_t *table) +void +trav_table_addflags(unsigned *flags, char *name, h5trav_type_t type, trav_table_t *table) { size_t new_obj; - if(table) { - if(table->nobjs == table->size) { + if (table) { + if (table->nobjs == table->size) { table->size = MAX(1, table->size * 2); table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); } /* end if */ @@ -763,18 +746,17 @@ void trav_table_addflags(unsigned *flags, /* Set token to 'undefined' values */ table->objs[new_obj].obj_token = H5O_TOKEN_UNDEF; - table->objs[new_obj].flags[0] = flags[0]; - table->objs[new_obj].flags[1] = flags[1]; + table->objs[new_obj].flags[0] = flags[0]; + table->objs[new_obj].flags[1] = flags[1]; table->objs[new_obj].is_same_trgobj = 0; - table->objs[new_obj].name = (char *)HDstrdup(name); - table->objs[new_obj].type = type; - table->objs[new_obj].nlinks = 0; - table->objs[new_obj].sizelinks = 0; - table->objs[new_obj].links = NULL; + table->objs[new_obj].name = (char *)HDstrdup(name); + table->objs[new_obj].type = type; + table->objs[new_obj].nlinks = 0; + table->objs[new_obj].sizelinks = 0; + table->objs[new_obj].links = NULL; } } - /*------------------------------------------------------------------------- * Function: trav_table_init * @@ -783,19 +765,19 @@ void trav_table_addflags(unsigned *flags, * Return: void *------------------------------------------------------------------------- */ -void trav_table_init(hid_t fid, trav_table_t **tbl) +void +trav_table_init(hid_t fid, trav_table_t **tbl) { - trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t)); - if(table) { - table->fid = fid; - table->size = 0; + trav_table_t *table = (trav_table_t *)HDmalloc(sizeof(trav_table_t)); + if (table) { + table->fid = fid; + table->size = 0; table->nobjs = 0; - table->objs = NULL; + table->objs = NULL; } *tbl = table; } - /*------------------------------------------------------------------------- * Function: trav_table_free * @@ -804,23 +786,24 @@ void trav_table_init(hid_t fid, trav_table_t **tbl) * Return: void *------------------------------------------------------------------------- */ -void trav_table_free(trav_table_t *table) +void +trav_table_free(trav_table_t *table) { - if(table) { - if(table->objs) { + if (table) { + if (table->objs) { unsigned int i; - for(i = 0; i < table->nobjs; i++) { - HDfree(table->objs[i].name ); - if(table->objs[i].nlinks) { + for (i = 0; i < table->nobjs; i++) { + HDfree(table->objs[i].name); + if (table->objs[i].nlinks) { unsigned int j; - for(j = 0; j < table->objs[i].nlinks; j++) + for (j = 0; j < table->objs[i].nlinks; j++) HDfree(table->objs[i].links[j].new_name); HDfree(table->objs[i].links); } /* end if */ - } /* end for */ + } /* end for */ HDfree(table->objs); } /* end if */ HDfree(table); @@ -830,39 +813,40 @@ void trav_table_free(trav_table_t *table) static herr_t trav_attr(hid_t #ifndef H5TRAV_PRINT_SPACE - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5TRAV_PRINT_SPACE */ - obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data) + obj, + const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data) { trav_path_op_data_t *op_data = (trav_path_op_data_t *)_op_data; - const char *buf = op_data->path; + const char * buf = op_data->path; - if((strlen(buf)==1) && (*buf=='/')) + if ((strlen(buf) == 1) && (*buf == '/')) HDprintf(" %-10s %s%s", "attribute", buf, attr_name); else HDprintf(" %-10s %s/%s", "attribute", buf, attr_name); #ifdef H5TRAV_PRINT_SPACE - if(trav_verbosity < 2) { + if (trav_verbosity < 2) { #endif HDprintf("\n"); #ifdef H5TRAV_PRINT_SPACE } else { - hid_t attr = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hsize_t size[H5S_MAX_RANK]; - int ndims; - int i; - H5S_class_t space_type; - - if((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) { + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hsize_t size[H5S_MAX_RANK]; + int ndims; + int i; + H5S_class_t space_type; + + if ((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) { space = H5Aget_space(attr); /* Data space */ - ndims = H5Sget_simple_extent_dims(space, size, NULL); + ndims = H5Sget_simple_extent_dims(space, size, NULL); space_type = H5Sget_simple_extent_type(space); - switch(space_type) { + switch (space_type) { case H5S_SCALAR: /* scalar dataspace */ HDprintf(" scalar\n"); @@ -872,7 +856,7 @@ trav_attr(hid_t /* simple dataspace */ HDprintf(" {"); for (i = 0; i < ndims; i++) { - HDprintf("%s" HSIZE_T_FORMAT, i?", ":"", size[i]); + HDprintf("%s" HSIZE_T_FORMAT, i ? ", " : "", size[i]); } HDprintf("}\n"); break; @@ -894,10 +878,9 @@ trav_attr(hid_t } #endif - return(0); + return (0); } - /*------------------------------------------------------------------------- * Function: trav_print_visit_obj * @@ -908,15 +891,14 @@ trav_attr(hid_t *------------------------------------------------------------------------- */ static int -trav_print_visit_obj(const char *path, const H5O_info2_t *oinfo, - const char *already_visited, void *udata) +trav_print_visit_obj(const char *path, const H5O_info2_t *oinfo, const char *already_visited, void *udata) { trav_print_udata_t *print_udata = (trav_print_udata_t *)udata; /* Print the name of the object */ /* (no new-line, so that objects that we've encountered before can print * the name of the original object) */ - switch(oinfo->type) { + switch (oinfo->type) { case H5O_TYPE_GROUP: HDprintf(" %-10s %s", "group", path); break; @@ -938,24 +920,23 @@ trav_print_visit_obj(const char *path, const H5O_info2_t *oinfo, } /* end switch */ /* Check if we've already seen this object */ - if(NULL == already_visited) { + if (NULL == already_visited) { trav_path_op_data_t op_data; op_data.path = path; /* Finish printing line about object */ HDprintf("\n"); - if(trav_verbosity > 0) - H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order, - NULL, trav_attr, &op_data, H5P_DEFAULT); + if (trav_verbosity > 0) + H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order, NULL, trav_attr, + &op_data, H5P_DEFAULT); } else /* Print the link's original name */ HDprintf(" -> %s\n", already_visited); - return(0); + return (0); } /* end trav_print_visit_obj() */ - /*------------------------------------------------------------------------- * Function: trav_print_visit_lnk * @@ -971,12 +952,12 @@ trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata) trav_print_udata_t *print_udata = (trav_print_udata_t *)udata; /* Print appropriate information for the type of link */ - switch(linfo->type) { + switch (linfo->type) { case H5L_TYPE_SOFT: - if(linfo->u.val_size > 0) { - char *targbuf = (char*)HDmalloc(linfo->u.val_size + 1); - if(targbuf) { - if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0) + if (linfo->u.val_size > 0) { + char *targbuf = (char *)HDmalloc(linfo->u.val_size + 1); + if (targbuf) { + if (H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0) targbuf[0] = 0; HDprintf(" %-10s %s -> %s\n", "link", path, targbuf); HDfree(targbuf); @@ -987,16 +968,16 @@ trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata) break; case H5L_TYPE_EXTERNAL: - if(linfo->u.val_size > 0) { - char *targbuf = NULL; + if (linfo->u.val_size > 0) { + char * targbuf = NULL; const char *filename = NULL; - const char *objname = NULL; + const char *objname = NULL; - targbuf = (char*)HDmalloc(linfo->u.val_size + 1); - if(targbuf) { - if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0) + targbuf = (char *)HDmalloc(linfo->u.val_size + 1); + if (targbuf) { + if (H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0) targbuf[0] = 0; - if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0) + if (H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0) HDprintf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname); HDfree(targbuf); } @@ -1007,7 +988,7 @@ trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata) case H5L_TYPE_HARD: /* Should be handled elsewhere */ - return(-1); + return (-1); case H5L_TYPE_ERROR: case H5L_TYPE_MAX: @@ -1016,10 +997,9 @@ trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata) break; } /* end switch() */ - return(0); + return (0); } /* end trav_print_visit_lnk() */ - /*------------------------------------------------------------------------- * Function: h5trav_print * @@ -1032,9 +1012,9 @@ trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata) int h5trav_print(hid_t fid) { - trav_print_udata_t print_udata; /* User data for traversal */ - trav_visitor_t print_visitor; /* Visitor structure for printing objects */ - int ret_value = 0; + trav_print_udata_t print_udata; /* User data for traversal */ + trav_visitor_t print_visitor; /* Visitor structure for printing objects */ + int ret_value = 0; /* Init user data for printing */ print_udata.fid = fid; @@ -1042,17 +1022,16 @@ h5trav_print(hid_t fid) /* Init visitor structure */ print_visitor.visit_obj = trav_print_visit_obj; print_visitor.visit_lnk = trav_print_visit_lnk; - print_visitor.udata = &print_udata; + print_visitor.udata = &print_udata; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(fid, "/", TRUE, TRUE, &print_visitor, H5O_INFO_BASIC) < 0) + if (traverse(fid, "/", TRUE, TRUE, &print_visitor, H5O_INFO_BASIC) < 0) H5TOOLS_GOTO_ERROR(FAIL, "traverse failed"); done: return ret_value; } - /*------------------------------------------------------------------------- * Function: h5trav_visit * @@ -1063,20 +1042,19 @@ done: *------------------------------------------------------------------------- */ int -h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, - hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, - void *udata, unsigned fields) +h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, hbool_t recurse, + h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata, unsigned fields) { - trav_visitor_t visitor; /* Visitor structure for objects */ + trav_visitor_t visitor; /* Visitor structure for objects */ int ret_value = 0; /* Init visitor structure */ visitor.visit_obj = visit_obj; visitor.visit_lnk = visit_lnk; - visitor.udata = udata; + visitor.udata = udata; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(fid, grp_name, visit_start, recurse, &visitor, fields) < 0) + if (traverse(fid, grp_name, visit_start, recurse, &visitor, fields) < 0) H5TOOLS_GOTO_ERROR((-1), "traverse failed"); done: @@ -1095,15 +1073,15 @@ done: herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path) { - size_t idx; /* Index of address to use */ + size_t idx; /* Index of address to use */ herr_t ret_value = SUCCEED; /* Allocate space if necessary */ - if(visited->nused == visited->nalloc) { - void *tmp_ptr; + if (visited->nused == visited->nalloc) { + void *tmp_ptr; visited->nalloc = MAX(1, visited->nalloc * 2); - if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t)))) + if (NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t)))) H5TOOLS_GOTO_ERROR(FAIL, "visited data structure realloc failed"); visited->objs = (symlink_trav_path_t *)tmp_ptr; } /* end if */ @@ -1115,17 +1093,17 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co visited->objs[idx].file = NULL; visited->objs[idx].path = NULL; - if(type == H5L_TYPE_EXTERNAL) { - if(NULL == (visited->objs[idx].file = HDstrdup(file))) { + if (type == H5L_TYPE_EXTERNAL) { + if (NULL == (visited->objs[idx].file = HDstrdup(file))) { visited->nused--; H5TOOLS_GOTO_ERROR(FAIL, "visited data structure name allocation failed"); } /* end if */ - } /* end if */ + } /* end if */ - if(NULL == (visited->objs[idx].path = HDstrdup(path))) { + if (NULL == (visited->objs[idx].path = HDstrdup(path))) { visited->nused--; - if(visited->objs[idx].file) - HDfree (visited->objs[idx].file); + if (visited->objs[idx].file) + HDfree(visited->objs[idx].file); H5TOOLS_GOTO_ERROR(FAIL, "visited data structure path allocation failed"); } /* end if */ @@ -1133,7 +1111,6 @@ done: return ret_value; } /* end symlink_visit_add() */ - /*------------------------------------------------------------------------- * Function: symlink_is_visited * @@ -1145,23 +1122,22 @@ done: H5_ATTR_PURE hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path) { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ /* Look for symlink */ - for(u = 0; u < visited->nused; u++) { + for (u = 0; u < visited->nused; u++) { /* Check for symlink values already in array */ /* check type and path pair to distingush between symbolic links */ - if((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path)) { + if ((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path)) { /* if external link, file need to be matched as well */ - if(visited->objs[u].type == H5L_TYPE_EXTERNAL) - if(!HDstrcmp(visited->objs[u].file, file)) - return(TRUE); + if (visited->objs[u].type == H5L_TYPE_EXTERNAL) + if (!HDstrcmp(visited->objs[u].file, file)) + return (TRUE); return (TRUE); } /* end if */ - } /* end for */ + } /* end for */ /* Didn't find symlink */ - return(FALSE); + return (FALSE); } /* end symlink_is_visited() */ - diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index affdf99..ce315d1 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -17,10 +17,9 @@ #include "hdf5.h" /* Typedefs for visiting objects */ -typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info2_t *oinfo, - const char *first_seen, void *udata); -typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info2_t *linfo, - void *udata); +typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info2_t *oinfo, const char *first_seen, + void *udata); +typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info2_t *linfo, void *udata); /*------------------------------------------------------------------------- * public enum to specify type of an object @@ -34,7 +33,7 @@ typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info2_t *li *------------------------------------------------------------------------- */ typedef enum { - H5TRAV_TYPE_UNKNOWN = -1, /* Unknown object type */ + H5TRAV_TYPE_UNKNOWN = -1, /* Unknown object type */ H5TRAV_TYPE_GROUP, /* Object is a group */ H5TRAV_TYPE_DATASET, /* Object is a dataset */ H5TRAV_TYPE_NAMED_DATATYPE, /* Object is a named datatype */ @@ -50,62 +49,59 @@ typedef enum { * Functions: symlink_visit_add() and symlink_is_visited() */ typedef struct symlink_trav_path_t { - H5L_type_t type; - char *file; - char *path; + H5L_type_t type; + char * file; + char * path; } symlink_trav_path_t; typedef struct symlink_trav_t { - size_t nalloc; - size_t nused; + size_t nalloc; + size_t nused; symlink_trav_path_t *objs; - hbool_t dangle_link; + hbool_t dangle_link; } symlink_trav_t; typedef struct trav_path_t { - char *path; + char * path; h5trav_type_t type; H5O_token_t obj_token; /* object token */ - unsigned long fileno; /* File number that object is located in */ + unsigned long fileno; /* File number that object is located in */ } trav_path_t; typedef struct trav_info_t { - size_t nalloc; - size_t nused; - const char *fname; - hid_t fid; /* File ID */ - trav_path_t *paths; - symlink_trav_t symlink_visited; /* already visited symbolic links */ - void * opts; /* optional data passing */ + size_t nalloc; + size_t nused; + const char * fname; + hid_t fid; /* File ID */ + trav_path_t * paths; + symlink_trav_t symlink_visited; /* already visited symbolic links */ + void * opts; /* optional data passing */ } trav_info_t; - /*------------------------------------------------------------------------- * keep record of hard link information *------------------------------------------------------------------------- */ typedef struct trav_link_t { - char *new_name; + char *new_name; } trav_link_t; - /*------------------------------------------------------------------------- * struct to store basic info needed for the h5trav table traversal algorythm *------------------------------------------------------------------------- */ typedef struct trav_obj_t { - H5O_token_t obj_token; /* object token */ - unsigned flags[2]; /* h5diff.object is present or not in both files*/ - hbool_t is_same_trgobj; /* same target object? no need to compare */ - char *name; /* name */ - h5trav_type_t type; /* type of object */ - trav_link_t *links; /* array of possible link names */ - size_t sizelinks; /* size of links array */ - size_t nlinks; /* number of links */ + H5O_token_t obj_token; /* object token */ + unsigned flags[2]; /* h5diff.object is present or not in both files*/ + hbool_t is_same_trgobj; /* same target object? no need to compare */ + char * name; /* name */ + h5trav_type_t type; /* type of object */ + trav_link_t * links; /* array of possible link names */ + size_t sizelinks; /* size of links array */ + size_t nlinks; /* number of links */ } trav_obj_t; - /*------------------------------------------------------------------------- * private struct that stores all objects *------------------------------------------------------------------------- @@ -118,7 +114,6 @@ typedef struct trav_table_t { trav_obj_t *objs; } trav_table_t; - /*------------------------------------------------------------------------- * public functions *------------------------------------------------------------------------- @@ -132,20 +127,23 @@ extern "C" { * "h5trav general" public functions *------------------------------------------------------------------------- */ -H5TOOLS_DLL void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order); -H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, - hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, - h5trav_lnk_func_t visit_lnk, void *udata, unsigned fields); -H5TOOLS_DLL herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path); -H5TOOLS_DLL hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path); +H5TOOLS_DLL void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order); +H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse, + h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata, + unsigned fields); +H5TOOLS_DLL herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, + const char *path); +H5TOOLS_DLL hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, + const char *path); /*------------------------------------------------------------------------- * "h5trav info" public functions *------------------------------------------------------------------------- */ -H5TOOLS_DLL int h5trav_getinfo(hid_t file_id, trav_info_t *info); +H5TOOLS_DLL int h5trav_getinfo(hid_t file_id, trav_info_t *info); H5TOOLS_DLL ssize_t h5trav_getindex(const trav_info_t *info, const char *obj); -H5TOOLS_DLL int trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo, const char *already_visited, void *udata); +H5TOOLS_DLL int trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo, const char *already_visited, + void *udata); H5TOOLS_DLL int trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata); /*------------------------------------------------------------------------- @@ -153,14 +151,14 @@ H5TOOLS_DLL int trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, *------------------------------------------------------------------------- */ -H5TOOLS_DLL int h5trav_gettable(hid_t fid, trav_table_t *travt); -H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt); +H5TOOLS_DLL int h5trav_gettable(hid_t fid, trav_table_t *travt); +H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt); /*------------------------------------------------------------------------- * "h5trav print" public functions *------------------------------------------------------------------------- */ -H5TOOLS_DLL int h5trav_print(hid_t fid); +H5TOOLS_DLL int h5trav_print(hid_t fid); H5TOOLS_DLL void h5trav_set_verbose(int print_verbose); #ifdef __cplusplus @@ -189,10 +187,6 @@ H5TOOLS_DLL void trav_table_init(hid_t fid, trav_table_t **table); H5TOOLS_DLL void trav_table_free(trav_table_t *table); -H5TOOLS_DLL void trav_table_addflags(unsigned *flags, - char *objname, - h5trav_type_t type, - trav_table_t *table); - -#endif /* H5TRAV_H__ */ +H5TOOLS_DLL void trav_table_addflags(unsigned *flags, char *objname, h5trav_type_t type, trav_table_t *table); +#endif /* H5TRAV_H__ */ diff --git a/tools/lib/io_timer.c b/tools/lib/io_timer.c index 5c0c31d..0f96941 100644 --- a/tools/lib/io_timer.c +++ b/tools/lib/io_timer.c @@ -30,10 +30,10 @@ * The number to divide the tv_usec field with to get a nice decimal to add to * the number of seconds. */ -#define MICROSECOND 1000000.0F +#define MICROSECOND 1000000.0F /* global variables */ -io_time_t *timer_g; /* timer: global for stub functions */ +io_time_t *timer_g; /* timer: global for stub functions */ /* * Function: sub_time @@ -42,15 +42,13 @@ io_time_t *timer_g; /* timer: global for stub functions */ * Note that the function assumes that a > b * Programmer: Leon Arber, 1/27/06 */ -static double sub_time(struct timeval* a, struct timeval* b) +static double +sub_time(struct timeval *a, struct timeval *b) { - return (((double)a->tv_sec + - ((double)a->tv_usec) / (double)MICROSECOND) - - ((double)b->tv_sec + - ((double)b->tv_usec) / (double)MICROSECOND)); + return (((double)a->tv_sec + ((double)a->tv_usec) / (double)MICROSECOND) - + ((double)b->tv_sec + ((double)b->tv_usec) / (double)MICROSECOND)); } - /* * Function: io_time_new * Purpose: Build us a brand, spankin', new performance time object. @@ -134,67 +132,73 @@ io_time_set(io_time_t *pt, timer_type t, int start_stop) /* sanity check */ HDassert(pt); - switch(pt->type){ + switch (pt->type) { #ifdef H5_HAVE_PARALLEL - case MPI_CLOCK: - if (start_stop == TSTART) { - pt->mpi_timer[t] = MPI_Wtime(); - - /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS - * we compute the time it took to only open the file */ - if(t == HDF5_FINE_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_OPEN] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_WRITE_FIXED_DIMS]; - else if(t == HDF5_FINE_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_OPEN] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_READ_FIXED_DIMS]; - - } else { - pt->total_time[t] += MPI_Wtime() - pt->mpi_timer[t]; - pt->mpi_timer[t] = MPI_Wtime(); - - /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS - * we compute the time it took to close the file after the last read/write finished */ - if(t == HDF5_GROSS_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_CLOSE] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_WRITE_FIXED_DIMS]; - else if(t == HDF5_GROSS_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_CLOSE] += pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_READ_FIXED_DIMS]; - } - break; + case MPI_CLOCK: + if (start_stop == TSTART) { + pt->mpi_timer[t] = MPI_Wtime(); + + /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS + * we compute the time it took to only open the file */ + if (t == HDF5_FINE_WRITE_FIXED_DIMS) + pt->total_time[HDF5_FILE_WRITE_OPEN] += + pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_WRITE_FIXED_DIMS]; + else if (t == HDF5_FINE_READ_FIXED_DIMS) + pt->total_time[HDF5_FILE_READ_OPEN] += + pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_READ_FIXED_DIMS]; + } + else { + pt->total_time[t] += MPI_Wtime() - pt->mpi_timer[t]; + pt->mpi_timer[t] = MPI_Wtime(); + + /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS + * we compute the time it took to close the file after the last read/write finished */ + if (t == HDF5_GROSS_WRITE_FIXED_DIMS) + pt->total_time[HDF5_FILE_WRITE_CLOSE] += + pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_WRITE_FIXED_DIMS]; + else if (t == HDF5_GROSS_READ_FIXED_DIMS) + pt->total_time[HDF5_FILE_READ_CLOSE] += + pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_READ_FIXED_DIMS]; + } + break; #else - case MPI_CLOCK: - HDfprintf(stderr, "MPI clock set in serial library\n"); - return NULL; + case MPI_CLOCK: + HDfprintf(stderr, "MPI clock set in serial library\n"); + return NULL; #endif /* H5_HAVE_PARALLEL */ - case SYS_CLOCK: + case SYS_CLOCK: if (start_stop == TSTART) { HDgettimeofday(&pt->sys_timer[t], NULL); - /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS - * we compute the time it took to only open the file */ - if(t == HDF5_FINE_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS])); - else if(t == HDF5_FINE_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_OPEN] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS])); - - - } else { + /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS + * we compute the time it took to only open the file */ + if (t == HDF5_FINE_WRITE_FIXED_DIMS) + pt->total_time[HDF5_FILE_WRITE_OPEN] += + sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS])); + else if (t == HDF5_FINE_READ_FIXED_DIMS) + pt->total_time[HDF5_FILE_READ_OPEN] += + sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS])); + } + else { struct timeval sys_t; HDgettimeofday(&sys_t, NULL); pt->total_time[t] += sub_time(&sys_t, &(pt->sys_timer[t])); - /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS - * we compute the time it took to close the file after the last read/write finished */ - if(t == HDF5_GROSS_WRITE_FIXED_DIMS) - pt->total_time[HDF5_FILE_WRITE_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS])); - else if(t == HDF5_GROSS_READ_FIXED_DIMS) - pt->total_time[HDF5_FILE_READ_CLOSE] += sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS])); - + /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS + * we compute the time it took to close the file after the last read/write finished */ + if (t == HDF5_GROSS_WRITE_FIXED_DIMS) + pt->total_time[HDF5_FILE_WRITE_CLOSE] += + sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS])); + else if (t == HDF5_GROSS_READ_FIXED_DIMS) + pt->total_time[HDF5_FILE_READ_CLOSE] += + sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS])); } - break; + break; - default: - HDfprintf(stderr, "Unknown time clock type (%d)\n", pt->type); - return NULL; + default: + HDfprintf(stderr, "Unknown time clock type (%d)\n", pt->type); + return NULL; } /* end switch */ #if 0 diff --git a/tools/lib/io_timer.h b/tools/lib/io_timer.h index c1fa58e..fa18e65 100644 --- a/tools/lib/io_timer.h +++ b/tools/lib/io_timer.h @@ -17,16 +17,16 @@ #include "hdf5.h" #if defined(H5_TIME_WITH_SYS_TIME) -# include -# include +#include +#include #elif defined(H5_HAVE_SYS_TIME_H) -# include +#include #else -# include +#include #endif #ifdef H5_HAVE_WINSOCK2_H -# include +#include #endif /* H5_HAVE_WINSOCK2_H */ /* The different types of timers we can have */ @@ -49,43 +49,43 @@ typedef enum timer_type_ { } timer_type; typedef enum clock_type_ { - SYS_CLOCK = 0, /* Use system clock to measure time */ - MPI_CLOCK = 1 /* Use MPI clock to measure time */ + SYS_CLOCK = 0, /* Use system clock to measure time */ + MPI_CLOCK = 1 /* Use MPI clock to measure time */ } clock_type; /* Miscellaneous identifiers */ enum { - TSTART, /* Start a specified timer */ - TSTOP /* Stop a specified timer */ + TSTART, /* Start a specified timer */ + TSTOP /* Stop a specified timer */ }; /* The performance time structure */ typedef struct io_time_t { - clock_type type; - double total_time[NUM_TIMERS]; - double mpi_timer[NUM_TIMERS]; + clock_type type; + double total_time[NUM_TIMERS]; + double mpi_timer[NUM_TIMERS]; struct timeval sys_timer[NUM_TIMERS]; } io_time_t; /* External function declarations */ #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ #ifdef STANDALONE -io_time_t *io_time_new(clock_type t); -void io_time_destroy(io_time_t *pt); -io_time_t *io_time_set(io_time_t *pt, timer_type t, int start_stop); -double io_time_get(io_time_t *pt, timer_type t); +io_time_t *io_time_new(clock_type t); +void io_time_destroy(io_time_t *pt); +io_time_t *io_time_set(io_time_t *pt, timer_type t, int start_stop); +double io_time_get(io_time_t *pt, timer_type t); #else -H5TOOLS_DLL io_time_t *io_time_new(clock_type t); -H5TOOLS_DLL void io_time_destroy(io_time_t *pt); -H5TOOLS_DLL io_time_t *io_time_set(io_time_t *pt, timer_type t, int start_stop); -H5TOOLS_DLL double io_time_get(io_time_t *pt, timer_type t); +H5TOOLS_DLL io_time_t *io_time_new(clock_type t); +H5TOOLS_DLL void io_time_destroy(io_time_t *pt); +H5TOOLS_DLL io_time_t *io_time_set(io_time_t *pt, timer_type t, int start_stop); +H5TOOLS_DLL double io_time_get(io_time_t *pt, timer_type t); #endif #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* IO_TIMER__ */ +#endif /* IO_TIMER__ */ diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h index 2189e31..c2df4c6 100644 --- a/tools/lib/ph5diff.h +++ b/tools/lib/ph5diff.h @@ -15,32 +15,29 @@ #define _PH5DIFF_H__ /* Send from manager to workers */ -#define MPI_TAG_ARGS 1 -#define MPI_TAG_PRINT_TOK 2 +#define MPI_TAG_ARGS 1 +#define MPI_TAG_PRINT_TOK 2 /*Sent from workers to manager */ -#define MPI_TAG_TOK_REQUEST 3 -#define MPI_TAG_DONE 4 -#define MPI_TAG_TOK_RETURN 5 -#define MPI_TAG_PRINT_DATA 6 +#define MPI_TAG_TOK_REQUEST 3 +#define MPI_TAG_DONE 4 +#define MPI_TAG_TOK_RETURN 5 +#define MPI_TAG_PRINT_DATA 6 /* Operational tags used to init and complete diff */ -#define MPI_TAG_END 7 -#define MPI_TAG_PARALLEL 8 +#define MPI_TAG_END 7 +#define MPI_TAG_PARALLEL 8 -struct diff_mpi_args -{ - char name1[256]; - char name2[256]; +struct diff_mpi_args { + char name1[256]; + char name2[256]; diff_opt_t opts; - diff_args_t argdata; /* rest args */ + diff_args_t argdata; /* rest args */ }; -struct diffs_found -{ +struct diffs_found { hsize_t nfound; - int not_cmp; + int not_cmp; }; -#endif /* _PH5DIFF_H__ */ - +#endif /* _PH5DIFF_H__ */ diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c index 4b50c7c..733cf41 100644 --- a/tools/libtest/h5tools_test_utils.c +++ b/tools/libtest/h5tools_test_utils.c @@ -69,7 +69,6 @@ * *****************************************************************************/ - /*---------------------------------------------------------------------------- * * ifdef flag: JSVERIFY_EXP_ACT @@ -81,7 +80,6 @@ */ #define JSVERIFY_EXP_ACT 1L - /*---------------------------------------------------------------------------- * * Macro: JSFAILED_AT() @@ -98,10 +96,10 @@ * *---------------------------------------------------------------------------- */ -#define JSFAILED_AT() { \ - HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ -} - +#define JSFAILED_AT() \ + { \ + HDprintf("*FAILED* at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); \ + } /*---------------------------------------------------------------------------- * @@ -126,12 +124,11 @@ * *---------------------------------------------------------------------------- */ -#define FAIL_IF(condition) \ -if (condition) { \ - JSFAILED_AT() \ - goto error; \ -} - +#define FAIL_IF(condition) \ + if (condition) { \ + JSFAILED_AT() \ + goto error; \ + } /*---------------------------------------------------------------------------- * @@ -155,12 +152,11 @@ if (condition) { \ * *---------------------------------------------------------------------------- */ -#define FAIL_UNLESS(condition) \ -if (!(condition)) { \ - JSFAILED_AT() \ - goto error; \ -} - +#define FAIL_UNLESS(condition) \ + if (!(condition)) { \ + JSFAILED_AT() \ + goto error; \ + } /*---------------------------------------------------------------------------- * @@ -187,16 +183,16 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSERR_LONG(expected, actual, reason) { \ - JSFAILED_AT() \ - if (reason!= NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf(" ! Expected %ld\n ! Actual %ld\n", \ - (long)(expected), (long)(actual)); \ - } \ -} - +#define JSERR_LONG(expected, actual, reason) \ + { \ + JSFAILED_AT() \ + if (reason != NULL) { \ + HDprintf("%s\n", (reason)); \ + } \ + else { \ + HDprintf(" ! Expected %ld\n ! Actual %ld\n", (long)(expected), (long)(actual)); \ + } \ + } /*---------------------------------------------------------------------------- * @@ -226,19 +222,19 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSERR_STR(expected, actual, reason) { \ - JSFAILED_AT() \ - if ((reason) != NULL) { \ - HDprintf("%s\n", (reason)); \ - } else { \ - HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", \ - (expected), (actual)); \ - } \ -} +#define JSERR_STR(expected, actual, reason) \ + { \ + JSFAILED_AT() \ + if ((reason) != NULL) { \ + HDprintf("%s\n", (reason)); \ + } \ + else { \ + HDprintf("!!! Expected:\n%s\n!!!Actual:\n%s\n", (expected), (actual)); \ + } \ + } #ifdef JSVERIFY_EXP_ACT - /*---------------------------------------------------------------------------- * * Macro: JSVERIFY() @@ -255,12 +251,11 @@ if (!(condition)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY(expected, actual, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY */ - +#define JSVERIFY(expected, actual, reason) \ + if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY */ /*---------------------------------------------------------------------------- * @@ -278,12 +273,11 @@ if ((long)(actual) != (long)(expected)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY_NOT(expected, actual, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ - +#define JSVERIFY_NOT(expected, actual, reason) \ + if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY_NOT */ /*---------------------------------------------------------------------------- * @@ -301,16 +295,14 @@ if ((long)(actual) == (long)(expected)) { \ * *---------------------------------------------------------------------------- */ -#define JSVERIFY_STR(expected, actual, reason) \ -if (HDstrcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ - +#define JSVERIFY_STR(expected, actual, reason) \ + if (HDstrcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY_STR */ #else /* JSVERIFY_EXP_ACT not defined */ - /* Repeats macros above, but with actual/expected parameters reversed. */ - +/* Repeats macros above, but with actual/expected parameters reversed. */ /*---------------------------------------------------------------------------- * Macro: JSVERIFY() @@ -319,12 +311,11 @@ if (HDstrcmp((actual), (expected)) != 0) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY(actual, expected, reason) \ -if ((long)(actual) != (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY */ - +#define JSVERIFY(actual, expected, reason) \ + if ((long)(actual) != (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY */ /*---------------------------------------------------------------------------- * Macro: JSVERIFY_NOT() @@ -333,12 +324,11 @@ if ((long)(actual) != (long)(expected)) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY_NOT(actual, expected, reason) \ -if ((long)(actual) == (long)(expected)) { \ - JSERR_LONG((expected), (actual), (reason)) \ - goto error; \ -} /* JSVERIFY_NOT */ - +#define JSVERIFY_NOT(actual, expected, reason) \ + if ((long)(actual) == (long)(expected)) { \ + JSERR_LONG((expected), (actual), (reason)) \ + goto error; \ + } /* JSVERIFY_NOT */ /*---------------------------------------------------------------------------- * Macro: JSVERIFY_STR() @@ -347,11 +337,11 @@ if ((long)(actual) == (long)(expected)) { \ * 2017-10-14 *---------------------------------------------------------------------------- */ -#define JSVERIFY_STR(actual, expected, reason) \ -if (HDstrcmp((actual), (expected)) != 0) { \ - JSERR_STR((expected), (actual), (reason)); \ - goto error; \ -} /* JSVERIFY_STR */ +#define JSVERIFY_STR(actual, expected, reason) \ + if (HDstrcmp((actual), (expected)) != 0) { \ + JSERR_STR((expected), (actual), (reason)); \ + goto error; \ + } /* JSVERIFY_STR */ #endif /* ifdef/else JSVERIFY_EXP_ACT */ @@ -364,7 +354,6 @@ if (HDstrcmp((actual), (expected)) != 0) { \ /* TEST FUNCTIONS */ /******************/ - /*---------------------------------------------------------------------------- * * Function: test_parse_tuple() @@ -407,123 +396,132 @@ test_parse_tuple(void) ******************/ struct testcase cases[] = { - { "bad start", + { + "bad start", "words(before)", ';', FAIL, 0, {NULL}, }, - { "tuple not closed", + { + "tuple not closed", "(not ok", ',', FAIL, 0, {NULL}, }, - { "empty tuple", + { + "empty tuple", "()", '-', SUCCEED, 1, {""}, }, - { "no separator", + { + "no separator", "(stuff keeps on going)", ',', SUCCEED, 1, {"stuff keeps on going"}, }, - { "4-ple, escaped seperator", + { + "4-ple, escaped seperator", "(elem0,elem1,el\\,em2,elem3)", /* "el\,em" */ ',', SUCCEED, 4, {"elem0", "elem1", "el,em2", "elem3"}, }, - { "5-ple, escaped escaped separator", + { + "5-ple, escaped escaped separator", "(elem0,elem1,el\\\\,em2,elem3)", ',', SUCCEED, 5, {"elem0", "elem1", "el\\", "em2", "elem3"}, }, - { "escaped non-comma separator", + { + "escaped non-comma separator", "(5-2-7-2\\-6-2)", '-', SUCCEED, 5, - {"5","2","7","2-6","2"}, + {"5", "2", "7", "2-6", "2"}, }, - { "embedded close-paren", + { + "embedded close-paren", "(be;fo)re)", ';', SUCCEED, 2, {"be", "fo)re"}, }, - { "embedded non-escaping backslash", + { + "embedded non-escaping backslash", "(be;fo\\re)", ';', SUCCEED, 2, {"be", "fo\\re"}, }, - { "double close-paren at end", + { + "double close-paren at end", "(be;fore))", ';', SUCCEED, 2, {"be", "fore)"}, }, - { "empty elements", + { + "empty elements", "(;a1;;a4;)", ';', SUCCEED, 5, {"", "a1", "", "a4", ""}, }, - { "nested tuples with different separators", + { + "nested tuples with different separators", "((4,e,a);(6,2,a))", ';', SUCCEED, 2, - {"(4,e,a)","(6,2,a)"}, + {"(4,e,a)", "(6,2,a)"}, }, - { "nested tuples with same separators", + { + "nested tuples with same separators", "((4,e,a),(6,2,a))", ',', SUCCEED, 6, - {"(4","e","a)","(6","2","a)"}, + {"(4", "e", "a)", "(6", "2", "a)"}, }, - { "real-world use case", + { + "real-world use case", "(us-east-2,AKIAIMC3D3XLYXLN5COA,ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+)", ',', SUCCEED, 3, - {"us-east-2", - "AKIAIMC3D3XLYXLN5COA", - "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+"}, - } - }; - struct testcase tc; - unsigned n_tests = 14; - unsigned i = 0; - unsigned count = 0; - unsigned elem_i = 0; - char **parsed = NULL; - char *cpy = NULL; - herr_t success = TRUE; - hbool_t show_progress = FALSE; - - + {"us-east-2", "AKIAIMC3D3XLYXLN5COA", "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+"}, + }}; + struct testcase tc; + unsigned n_tests = 14; + unsigned i = 0; + unsigned count = 0; + unsigned elem_i = 0; + char ** parsed = NULL; + char * cpy = NULL; + herr_t success = TRUE; + hbool_t show_progress = FALSE; TESTING("arbitrary-count tuple parsing"); #if H5TOOLS_UTILS_TEST_DEBUG > 0 - show_progress = TRUE; + show_progress = TRUE; #endif /* H5TOOLS_UTILS_TEST_DEBUG */ /********* @@ -543,24 +541,25 @@ test_parse_tuple(void) /* VERIFY */ - success = parse_tuple(tc.in_str, tc.sep, &cpy, &count, &parsed); + success = parse_tuple(tc.in_str, tc.sep, &cpy, &count, &parsed); - JSVERIFY( tc.exp_ret, success, "function returned incorrect value" ) - JSVERIFY( tc.exp_nelems, count, NULL ) + JSVERIFY(tc.exp_ret, success, "function returned incorrect value") + JSVERIFY(tc.exp_nelems, count, NULL) if (success == SUCCEED) { - FAIL_IF( parsed == NULL ) + FAIL_IF(parsed == NULL) for (elem_i = 0; elem_i < count; elem_i++) { - JSVERIFY_STR( tc.exp_elems[elem_i], parsed[elem_i], NULL ) + JSVERIFY_STR(tc.exp_elems[elem_i], parsed[elem_i], NULL) } /* TEARDOWN */ HDassert(parsed != NULL); - HDassert(cpy != NULL); + HDassert(cpy != NULL); HDfree(parsed); parsed = NULL; HDfree(cpy); cpy = NULL; - } else { - FAIL_IF( parsed != NULL ) + } + else { + FAIL_IF(parsed != NULL) } /* if parse_tuple() == SUCCEED or no */ } /* for each testcase */ @@ -573,14 +572,15 @@ error: * CLEANUP * ***********/ - if (parsed != NULL) HDfree(parsed); - if (cpy != NULL) HDfree(cpy); + if (parsed != NULL) + HDfree(parsed); + if (cpy != NULL) + HDfree(cpy); return 1; } /* test_parse_tuple */ - /*---------------------------------------------------------------------------- * * Function: test_populate_ros3_fa() @@ -611,7 +611,7 @@ test_populate_ros3_fa(void) hbool_t show_progress = FALSE; int bad_version = 0xf87a; /* arbitrarily wrong version number */ -#endif /* H5_HAVE_ROS3_VFD */ +#endif /* H5_HAVE_ROS3_VFD */ TESTING("programmatic ros3 fapl population"); @@ -636,10 +636,11 @@ test_populate_ros3_fa(void) { const char *values[] = {"x", "y", "z"}; - if (show_progress) { HDprintf("NULL fapl pointer\n"); } + if (show_progress) { + HDprintf("NULL fapl pointer\n"); + } - JSVERIFY( 0, h5tools_populate_ros3_fapl(NULL, values), - "fapl pointer cannot be null" ) + JSVERIFY(0, h5tools_populate_ros3_fapl(NULL, values), "fapl pointer cannot be null") } /* NULL values pointer yields default fapl @@ -647,305 +648,309 @@ test_populate_ros3_fa(void) { H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; - if (show_progress) { HDprintf("NULL values pointer\n"); } + if (show_progress) { + HDprintf("NULL values pointer\n"); + } - JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, NULL), - "NULL values pointer yields \"default\" fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + JSVERIFY(1, h5tools_populate_ros3_fapl(&fa, NULL), "NULL values pointer yields \"default\" fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* all-empty values * yields default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; - const char *values[] = {"", "", ""}; + H5FD_ros3_fapl_t fa = {bad_version, TRUE, "u", "v", "w"}; + const char * values[] = {"", "", ""}; - if (show_progress) { HDprintf("all empty values\n"); } + if (show_progress) { + HDprintf("all empty values\n"); + } - JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), - "empty values yields \"default\" fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + JSVERIFY(1, h5tools_populate_ros3_fapl(&fa, values), "empty values yields \"default\" fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* successfully set fapl with values * excess value is ignored */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "y", "z", "a"}; - - if (show_progress) { HDprintf("successful full set\n"); } - - JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), - "four values" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( TRUE, fa.authenticate, NULL ) - JSVERIFY_STR( "x", fa.aws_region, NULL ) - JSVERIFY_STR( "y", fa.secret_id, NULL ) - JSVERIFY_STR( "z", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"x", "y", "z", "a"}; + + if (show_progress) { + HDprintf("successful full set\n"); + } + + JSVERIFY(1, h5tools_populate_ros3_fapl(&fa, values), "four values") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(TRUE, fa.authenticate, NULL) + JSVERIFY_STR("x", fa.aws_region, NULL) + JSVERIFY_STR("y", fa.secret_id, NULL) + JSVERIFY_STR("z", fa.secret_key, NULL) } /* NULL region * yeilds default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {NULL, "y", "z", NULL}; - - if (show_progress) { HDprintf("NULL region\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {NULL, "y", "z", NULL}; + + if (show_progress) { + HDprintf("NULL region\n"); + } + + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* empty region * yeilds default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"", "y", "z", NULL}; - - if (show_progress) { HDprintf("empty region; non-empty id, key\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"", "y", "z", NULL}; + + if (show_progress) { + HDprintf("empty region; non-empty id, key\n"); + } + + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* region overflow * yeilds default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = { - "somewhere over the rainbow not too high " \ - "there is another rainbow bounding some darkened sky", - "y", - "z"}; + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"somewhere over the rainbow not too high " + "there is another rainbow bounding some darkened sky", + "y", "z"}; - if (show_progress) { HDprintf("region overflow\n"); } + if (show_progress) { + HDprintf("region overflow\n"); + } HDassert(HDstrlen(values[0]) > H5FD_ROS3_MAX_REGION_LEN); - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* NULL id * yields default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", NULL, "z", NULL}; - - if (show_progress) { HDprintf("NULL id\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"x", NULL, "z", NULL}; + + if (show_progress) { + HDprintf("NULL id\n"); + } + + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* empty id (non-empty region, key) * yeilds default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "", "z", NULL}; - - if (show_progress) { HDprintf("empty id; non-empty region and key\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"x", "", "z", NULL}; + + if (show_progress) { + HDprintf("empty id; non-empty region and key\n"); + } + + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* id overflow * partial set: region */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = { - "x", - "Why is it necessary to solve the problem? " \ - "What benefits will you receive by solving the problem? " \ - "What is the unknown? " \ - "What is it you don't yet understand? " \ - "What is the information you have? " \ - "What isn't the problem? " \ - "Is the information insufficient, redundant, or contradictory? " \ - "Should you draw a diagram or figure of the problem? " \ - "What are the boundaries of the problem? " \ - "Can you separate the various parts of the problem?", - "z"}; - - if (show_progress) { HDprintf("id overflow\n"); } + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"x", + "Why is it necessary to solve the problem? " + "What benefits will you receive by solving the problem? " + "What is the unknown? " + "What is it you don't yet understand? " + "What is the information you have? " + "What isn't the problem? " + "Is the information insufficient, redundant, or contradictory? " + "Should you draw a diagram or figure of the problem? " + "What are the boundaries of the problem? " + "Can you separate the various parts of the problem?", + "z"}; + + if (show_progress) { + HDprintf("id overflow\n"); + } HDassert(HDstrlen(values[1]) > H5FD_ROS3_MAX_SECRET_ID_LEN); - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "x", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("x", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* NULL key * yields default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "y", NULL, NULL}; - - if (show_progress) { HDprintf("NULL key\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"x", "y", NULL, NULL}; + + if (show_progress) { + HDprintf("NULL key\n"); + } + + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* empty key (non-empty region, id) * yeilds authenticating fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "y", "", NULL}; - - if (show_progress) { HDprintf("empty key; non-empty region and id\n"); } - - JSVERIFY( 1, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( TRUE, fa.authenticate, NULL ) - JSVERIFY_STR( "x", fa.aws_region, NULL ) - JSVERIFY_STR( "y", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"x", "y", "", NULL}; + + if (show_progress) { + HDprintf("empty key; non-empty region and id\n"); + } + + JSVERIFY(1, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(TRUE, fa.authenticate, NULL) + JSVERIFY_STR("x", fa.aws_region, NULL) + JSVERIFY_STR("y", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* empty key, region (non-empty id) * yeilds default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"", "y", "", NULL}; - - if (show_progress) { HDprintf("empty key and region; non-empty id\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"", "y", "", NULL}; + + if (show_progress) { + HDprintf("empty key and region; non-empty id\n"); + } + + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* empty key, id (non-empty region) * yeilds default fapl */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = {"x", "", "", NULL}; - - if (show_progress) { HDprintf("empty key and id; non-empty region\n"); } - - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "", fa.aws_region, NULL ) - JSVERIFY_STR( "", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"x", "", "", NULL}; + + if (show_progress) { + HDprintf("empty key and id; non-empty region\n"); + } + + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("", fa.aws_region, NULL) + JSVERIFY_STR("", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* key overflow * partial set: region, id */ { - H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; - const char *values[] = { - "x", - "y", - "Why is it necessary to solve the problem? " \ - "What benefits will you receive by solving the problem? " \ - "What is the unknown? " \ - "What is it you don't yet understand? " \ - "What is the information you have? " \ - "What isn't the problem? " \ - "Is the information insufficient, redundant, or contradictory? " \ - "Should you draw a diagram or figure of the problem? " \ - "What are the boundaries of the problem? " \ - "Can you separate the various parts of the problem?"}; - - if (show_progress) { HDprintf("key overflow\n"); } + H5FD_ros3_fapl_t fa = {bad_version, FALSE, "a", "b", "c"}; + const char * values[] = {"x", "y", + "Why is it necessary to solve the problem? " + "What benefits will you receive by solving the problem? " + "What is the unknown? " + "What is it you don't yet understand? " + "What is the information you have? " + "What isn't the problem? " + "Is the information insufficient, redundant, or contradictory? " + "Should you draw a diagram or figure of the problem? " + "What are the boundaries of the problem? " + "Can you separate the various parts of the problem?"}; + + if (show_progress) { + HDprintf("key overflow\n"); + } HDassert(HDstrlen(values[2]) > H5FD_ROS3_MAX_SECRET_KEY_LEN); - JSVERIFY( 0, h5tools_populate_ros3_fapl(&fa, values), - "could not fill fapl" ) - JSVERIFY( H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL ) - JSVERIFY( FALSE, fa.authenticate, NULL ) - JSVERIFY_STR( "x", fa.aws_region, NULL ) - JSVERIFY_STR( "y", fa.secret_id, NULL ) - JSVERIFY_STR( "", fa.secret_key, NULL ) + JSVERIFY(0, h5tools_populate_ros3_fapl(&fa, values), "could not fill fapl") + JSVERIFY(H5FD_CURR_ROS3_FAPL_T_VERSION, fa.version, NULL) + JSVERIFY(FALSE, fa.authenticate, NULL) + JSVERIFY_STR("x", fa.aws_region, NULL) + JSVERIFY_STR("y", fa.secret_id, NULL) + JSVERIFY_STR("", fa.secret_key, NULL) } /* use case */ { - H5FD_ros3_fapl_t fa = {0, 0, "", "", ""}; - const char *values[] = { - "us-east-2", - "AKIAIMC3D3XLYXLN5COA", - "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+" - }; - JSVERIFY( 1, - h5tools_populate_ros3_fapl(&fa, values), - "unable to set use case" ) - JSVERIFY( 1, fa.version, "version check" ) - JSVERIFY( 1, fa.authenticate, "should authenticate" ) + H5FD_ros3_fapl_t fa = {0, 0, "", "", ""}; + const char * values[] = {"us-east-2", "AKIAIMC3D3XLYXLN5COA", + "ugs5aVVnLFCErO/8uW14iWE3K5AgXMpsMlWneO/+"}; + JSVERIFY(1, h5tools_populate_ros3_fapl(&fa, values), "unable to set use case") + JSVERIFY(1, fa.version, "version check") + JSVERIFY(1, fa.authenticate, "should authenticate") } PASSED(); return 0; -error : +error: /*********** * CLEANUP * ***********/ @@ -956,7 +961,6 @@ error : } /* test_populate_ros3_fa */ - /*---------------------------------------------------------------------------- * * Function: test_set_configured_fapl() @@ -976,9 +980,9 @@ error : static unsigned test_set_configured_fapl(void) { -#define UTIL_TEST_NOFAPL 1 +#define UTIL_TEST_NOFAPL 1 #define UTIL_TEST_DEFAULT 2 -#define UTIL_TEST_CREATE 3 +#define UTIL_TEST_CREATE 3 /************************* * TEST-LOCAL STRUCTURES * @@ -988,7 +992,7 @@ test_set_configured_fapl(void) int expected; int fapl_choice; const char vfdname[12]; - void *conf_fa; + void * conf_fa; } testcase; typedef struct other_fa_t { @@ -1001,8 +1005,8 @@ test_set_configured_fapl(void) * TEST-LOCAL VARIABLES * ************************/ - hid_t fapl_id = H5I_INVALID_HID; - other_fa_t wrong_fa = {0x432, 0xf82, 0x9093}; + hid_t fapl_id = H5I_INVALID_HID; + other_fa_t wrong_fa = {0x432, 0xf82, 0x9093}; H5FD_ros3_fapl_t ros3_anon_fa = {1, FALSE, "", "", ""}; H5FD_ros3_fapl_t ros3_auth_fa = { 1, /* fapl version */ @@ -1019,45 +1023,52 @@ test_set_configured_fapl(void) "", /* user name */ 2048, /* stream buffer size */ }; - unsigned n_cases = 7; /* number of common testcases */ - testcase cases[] = { - { "(common) should fail: no fapl id", + unsigned n_cases = 7; /* number of common testcases */ + testcase cases[] = { + { + "(common) should fail: no fapl id", 0, UTIL_TEST_NOFAPL, "", NULL, }, - { "(common) should fail: no fapl id (with struct)", + { + "(common) should fail: no fapl id (with struct)", 0, UTIL_TEST_NOFAPL, "", &wrong_fa, }, - { "(common) H5P_DEFAULT with no struct should succeed", + { + "(common) H5P_DEFAULT with no struct should succeed", 1, UTIL_TEST_DEFAULT, "", NULL, }, - { "(common) H5P_DEFAULT with (ignored) struct should succeed", + { + "(common) H5P_DEFAULT with (ignored) struct should succeed", 1, UTIL_TEST_DEFAULT, "", &wrong_fa, }, - { "(common) provided fapl entry should not fail", + { + "(common) provided fapl entry should not fail", 1, UTIL_TEST_CREATE, "", NULL, }, - { "(common) provided fapl entry should not fail; ignores struct", + { + "(common) provided fapl entry should not fail; ignores struct", 1, UTIL_TEST_CREATE, "", &wrong_fa, }, - { "(common) should fail: unrecoginzed vfd name", + { + "(common) should fail: unrecoginzed vfd name", 0, UTIL_TEST_DEFAULT, "unknown", @@ -1067,31 +1078,36 @@ test_set_configured_fapl(void) #ifdef H5_HAVE_ROS3_VFD /* WARNING: add number of ROS3 test cases after array definition */ - { "(ROS3) should fail: no fapl id, no struct", + { + "(ROS3) should fail: no fapl id, no struct", 0, UTIL_TEST_NOFAPL, "ros3", NULL, }, - { "(ROS3) should fail: no fapl id", + { + "(ROS3) should fail: no fapl id", 0, UTIL_TEST_NOFAPL, "ros3", &ros3_anon_fa, }, - { "(ROS3) should fail: no struct", + { + "(ROS3) should fail: no struct", 0, UTIL_TEST_CREATE, "ros3", NULL, }, - { "(ROS3) successful set", + { + "(ROS3) successful set", 1, UTIL_TEST_CREATE, "ros3", &ros3_anon_fa, }, - { "(ROS3) should fail: attempt to set DEFAULT fapl", + { + "(ROS3) should fail: attempt to set DEFAULT fapl", 0, UTIL_TEST_DEFAULT, "ros3", @@ -1102,31 +1118,36 @@ test_set_configured_fapl(void) #ifdef H5_HAVE_LIBHDFS /* WARNING: add number of HDFS test cases after array definition */ - { "(HDFS) should fail: no fapl id, no struct", + { + "(HDFS) should fail: no fapl id, no struct", 0, UTIL_TEST_NOFAPL, "hdfs", NULL, }, - { "(HDFS) should fail: no fapl id", + { + "(HDFS) should fail: no fapl id", 0, UTIL_TEST_NOFAPL, "hdfs", &hdfs_fa, }, - { "(HDFS) should fail: no struct", + { + "(HDFS) should fail: no struct", 0, UTIL_TEST_CREATE, "hdfs", NULL, }, - { "(HDFS) successful set", + { + "(HDFS) successful set", 1, UTIL_TEST_CREATE, "hdfs", &hdfs_fa, }, - { "(HDFS) should fail: attempt to set DEFAULT fapl", + { + "(HDFS) should fail: attempt to set DEFAULT fapl", 0, UTIL_TEST_DEFAULT, "hdfs", @@ -1149,67 +1170,73 @@ test_set_configured_fapl(void) for (i = 0; i < n_cases; i++) { h5tools_vfd_info_t vfd_info; - hid_t result; - testcase C = cases[i]; + hid_t result; + testcase C = cases[i]; fapl_id = H5I_INVALID_HID; #if UTIL_TEST_DEBUG - HDfprintf(stderr, "setup test %d\t%s\n", i, C.message); fflush(stderr); + HDfprintf(stderr, "setup test %d\t%s\n", i, C.message); + fflush(stderr); #endif /* UTIL_TEST_DEBUG */ /* per-test setup */ if (C.fapl_choice == UTIL_TEST_DEFAULT) { fapl_id = H5P_DEFAULT; - } else if (C.fapl_choice == UTIL_TEST_CREATE) { + } + else if (C.fapl_choice == UTIL_TEST_CREATE) { fapl_id = H5Pcreate(H5P_FILE_ACCESS); - FAIL_IF( fapl_id < 0 ) + FAIL_IF(fapl_id < 0) } #if UTIL_TEST_DEBUG - HDfprintf(stderr, "before test\n"); fflush(stderr); + HDfprintf(stderr, "before test\n"); + fflush(stderr); #endif /* UTIL_TEST_DEBUG */ /* test */ - vfd_info.info = C.conf_fa; - vfd_info.name = C.vfdname; + vfd_info.info = C.conf_fa; + vfd_info.name = C.vfdname; vfd_info.fname = "ignore"; - result = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info); + result = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info); if (C.expected == 0) - JSVERIFY( result, H5I_INVALID_HID, C.message) + JSVERIFY(result, H5I_INVALID_HID, C.message) else - JSVERIFY_NOT( result, H5I_INVALID_HID, C.message) + JSVERIFY_NOT(result, H5I_INVALID_HID, C.message) #if UTIL_TEST_DEBUG - HDfprintf(stderr, "after test\n"); fflush(stderr); + HDfprintf(stderr, "after test\n"); + fflush(stderr); #endif /* UTIL_TEST_DEBUG */ /* per-test-teardown */ if (fapl_id > 0) { - FAIL_IF( FAIL == H5Pclose(fapl_id) ) + FAIL_IF(FAIL == H5Pclose(fapl_id)) } fapl_id = H5I_INVALID_HID; #if UTIL_TEST_DEBUG - HDfprintf(stderr, "after cleanup\n"); fflush(stderr); + HDfprintf(stderr, "after cleanup\n"); + fflush(stderr); #endif /* UTIL_TEST_DEBUG */ - } #if UTIL_TEST_DEBUG - HDfprintf(stderr, "after loop\n"); fflush(stderr); + HDfprintf(stderr, "after loop\n"); + fflush(stderr); #endif /* UTIL_TEST_DEBUG */ PASSED(); return 0; -error : +error: /*********** * CLEANUP * ***********/ #if UTIL_TEST_DEBUG - HDfprintf(stderr, "ERROR\n"); fflush(stderr); + HDfprintf(stderr, "ERROR\n"); + fflush(stderr); #endif /* UTIL_TEST_DEBUG */ if (fapl_id > 0) { @@ -1223,7 +1250,6 @@ error : #undef UTIL_TEST_CREATE } /* test_set_configured_fapl */ - /*---------------------------------------------------------------------------- * * Function: main() @@ -1247,7 +1273,7 @@ main(void) #ifdef _H5TEST_ h5reset(); /* h5test? */ -#endif /* _H5TEST_ */ +#endif /* _H5TEST_ */ HDfprintf(stdout, "Testing h5tools_utils corpus.\n"); @@ -1256,16 +1282,13 @@ main(void) nerrors += test_set_configured_fapl(); if (nerrors > 0) { - HDfprintf(stdout, "***** %d h5tools_utils TEST%s FAILED! *****\n", - nerrors, - nerrors > 1 ? "S" : ""); + HDfprintf(stdout, "***** %d h5tools_utils TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); nerrors = 1; - } else { + } + else { HDfprintf(stdout, "All h5tools_utils tests passed\n"); } return (int)nerrors; } /* main */ - - diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c index 5b19ae7..daa3b62 100644 --- a/tools/src/h5copy/h5copy.c +++ b/tools/src/h5copy/h5copy.c @@ -19,25 +19,23 @@ #define PROGRAMNAME "h5copy" /* command-line options: short and long-named parameters */ -static const char *s_opts = "d:f:hi:o:ps:vVE"; -static struct long_options l_opts[] = { - { "destination", require_arg, 'd' }, - { "flag", require_arg, 'f' }, - { "help", no_arg, 'h' }, - { "input", require_arg, 'i' }, - { "output", require_arg, 'o' }, - { "parents", no_arg, 'p' }, - { "source", require_arg, 's' }, - { "verbose", no_arg, 'v' }, - { "version", no_arg, 'V' }, - { "enable-error-stack", no_arg, 'E' }, - { NULL, 0, '\0' } -}; -char *fname_src = NULL; -char *fname_dst = NULL; -char *oname_src = NULL; -char *oname_dst = NULL; -char *str_flag = NULL; +static const char * s_opts = "d:f:hi:o:ps:vVE"; +static struct long_options l_opts[] = {{"destination", require_arg, 'd'}, + {"flag", require_arg, 'f'}, + {"help", no_arg, 'h'}, + {"input", require_arg, 'i'}, + {"output", require_arg, 'o'}, + {"parents", no_arg, 'p'}, + {"source", require_arg, 's'}, + {"verbose", no_arg, 'v'}, + {"version", no_arg, 'V'}, + {"enable-error-stack", no_arg, 'E'}, + {NULL, 0, '\0'}}; +char * fname_src = NULL; +char * fname_dst = NULL; +char * oname_src = NULL; +char * oname_dst = NULL; +char * str_flag = NULL; /*------------------------------------------------------------------------- * Function: leave @@ -71,7 +69,6 @@ leave(int ret) HDexit(ret); } - /*------------------------------------------------------------------------- * Function: usage * @@ -86,7 +83,7 @@ leave(int ret) *------------------------------------------------------------------------- */ static void -usage (void) +usage(void) { FLUSHSTREAM(rawoutstream); PRINTVALSTREAM(rawoutstream, "\n"); @@ -98,29 +95,41 @@ usage (void) PRINTVALSTREAM(rawoutstream, " -d, --destination destination object name\n"); PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n"); - PRINTVALSTREAM(rawoutstream, " -p, --parents No error if existing, make parent groups as needed\n"); + PRINTVALSTREAM(rawoutstream, + " -p, --parents No error if existing, make parent groups as needed\n"); PRINTVALSTREAM(rawoutstream, " -v, --verbose Print information about OBJECTS and OPTIONS\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n"); - PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n"); + PRINTVALSTREAM(rawoutstream, + " Prints messages from the HDF5 error stack as they occur.\n"); PRINTVALSTREAM(rawoutstream, " -f, --flag Flag type\n\n"); PRINTVALSTREAM(rawoutstream, " Flag type is one of the following strings:\n\n"); PRINTVALSTREAM(rawoutstream, " shallow Copy only immediate members for groups\n\n"); PRINTVALSTREAM(rawoutstream, " soft Expand soft links into new objects\n\n"); PRINTVALSTREAM(rawoutstream, " ext Expand external links into new objects\n\n"); - PRINTVALSTREAM(rawoutstream, " ref Copy references and any referenced objects, i.e., objects\n"); + PRINTVALSTREAM(rawoutstream, + " ref Copy references and any referenced objects, i.e., objects\n"); PRINTVALSTREAM(rawoutstream, " that the references point to.\n"); - PRINTVALSTREAM(rawoutstream, " Referenced objects are copied in addition to the objects\n"); - PRINTVALSTREAM(rawoutstream, " specified on the command line and reference datasets are\n"); - PRINTVALSTREAM(rawoutstream, " populated with correct reference values. Copies of referenced\n"); - PRINTVALSTREAM(rawoutstream, " datasets outside the copy range specified on the command line\n"); - PRINTVALSTREAM(rawoutstream, " will normally have a different name from the original.\n"); - PRINTVALSTREAM(rawoutstream, " (Default:Without this option, reference value(s) in any\n"); - PRINTVALSTREAM(rawoutstream, " reference datasets are set to NULL and referenced objects are\n"); - PRINTVALSTREAM(rawoutstream, " not copied unless they are otherwise within the copy range\n"); + PRINTVALSTREAM(rawoutstream, + " Referenced objects are copied in addition to the objects\n"); + PRINTVALSTREAM(rawoutstream, + " specified on the command line and reference datasets are\n"); + PRINTVALSTREAM(rawoutstream, + " populated with correct reference values. Copies of referenced\n"); + PRINTVALSTREAM(rawoutstream, + " datasets outside the copy range specified on the command line\n"); + PRINTVALSTREAM(rawoutstream, + " will normally have a different name from the original.\n"); + PRINTVALSTREAM(rawoutstream, + " (Default:Without this option, reference value(s) in any\n"); + PRINTVALSTREAM(rawoutstream, + " reference datasets are set to NULL and referenced objects are\n"); + PRINTVALSTREAM(rawoutstream, + " not copied unless they are otherwise within the copy range\n"); PRINTVALSTREAM(rawoutstream, " specified on the command line.)\n\n"); PRINTVALSTREAM(rawoutstream, " noattr Copy object without copying attributes\n\n"); - PRINTVALSTREAM(rawoutstream, " allflags Switches all flags from the default to the non-default setting\n\n"); + PRINTVALSTREAM(rawoutstream, + " allflags Switches all flags from the default to the non-default setting\n\n"); PRINTVALSTREAM(rawoutstream, " These flag types correspond to the following API symbols\n\n"); PRINTVALSTREAM(rawoutstream, " H5O_COPY_SHALLOW_HIERARCHY_FLAG\n"); PRINTVALSTREAM(rawoutstream, " H5O_COPY_EXPAND_SOFT_LINK_FLAG\n"); @@ -130,8 +139,6 @@ usage (void) PRINTVALSTREAM(rawoutstream, " H5O_COPY_ALL\n"); } - - /*------------------------------------------------------------------------- * Function: parse_flag * @@ -156,30 +163,30 @@ usage (void) *------------------------------------------------------------------------- */ - -static int parse_flag(const char* s_flag, unsigned *flag) +static int +parse_flag(const char *s_flag, unsigned *flag) { - unsigned fla=0; + unsigned fla = 0; if (HDstrcmp(s_flag, "shallow") == 0) { fla = H5O_COPY_SHALLOW_HIERARCHY_FLAG; } - else if (HDstrcmp(s_flag, "soft") == 0) { + else if (HDstrcmp(s_flag, "soft") == 0) { fla = H5O_COPY_EXPAND_SOFT_LINK_FLAG; } - else if (HDstrcmp(s_flag, "ext") == 0) { + else if (HDstrcmp(s_flag, "ext") == 0) { fla = H5O_COPY_EXPAND_EXT_LINK_FLAG; } - else if (HDstrcmp(s_flag, "ref") == 0) { + else if (HDstrcmp(s_flag, "ref") == 0) { fla = H5O_COPY_EXPAND_REFERENCE_FLAG; } - else if (HDstrcmp(s_flag, "noattr") == 0) { + else if (HDstrcmp(s_flag, "noattr") == 0) { fla = H5O_COPY_WITHOUT_ATTR_FLAG; } - else if (HDstrcmp(s_flag, "allflags") == 0) { + else if (HDstrcmp(s_flag, "allflags") == 0) { fla = H5O_COPY_ALL; } - else if (HDstrcmp(s_flag, "nullmsg") == 0) { + else if (HDstrcmp(s_flag, "nullmsg") == 0) { fla = H5O_COPY_PRESERVE_NULL_FLAG; } else { @@ -205,19 +212,19 @@ static int parse_flag(const char* s_flag, unsigned *flag) */ int -main (int argc, const char *argv[]) +main(int argc, const char *argv[]) { - hid_t fid_src = H5I_INVALID_HID; - hid_t fid_dst = H5I_INVALID_HID; - unsigned flag = 0; - unsigned verbose = 0; - unsigned parents = 0; - hid_t ocpl_id = (-1); /* Object copy property list */ - hid_t lcpl_id = (-1); /* Link creation property list */ - int opt; - int li_ret; + hid_t fid_src = H5I_INVALID_HID; + hid_t fid_dst = H5I_INVALID_HID; + unsigned flag = 0; + unsigned verbose = 0; + unsigned parents = 0; + hid_t ocpl_id = (-1); /* Object copy property list */ + hid_t lcpl_id = (-1); /* Link creation property list */ + int opt; + int li_ret; h5tool_link_info_t linkinfo; - int ret_value = 0; + int ret_value = 0; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -229,7 +236,7 @@ main (int argc, const char *argv[]) HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t)); /* Check for no command line parameters */ - if(argc == 1) { + if (argc == 1) { usage(); leave(EXIT_FAILURE); } /* end if */ @@ -237,82 +244,82 @@ main (int argc, const char *argv[]) /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { - case 'd': - oname_dst = HDstrdup(opt_arg); - break; + case 'd': + oname_dst = HDstrdup(opt_arg); + break; + + case 'f': + /* validate flag */ + if (parse_flag(opt_arg, &flag) < 0) { + usage(); + leave(EXIT_FAILURE); + } + str_flag = HDstrdup(opt_arg); + break; + + case 'h': + usage(); + leave(EXIT_SUCCESS); + break; + + case 'i': + fname_src = HDstrdup(opt_arg); + break; + + case 'o': + fname_dst = HDstrdup(opt_arg); + break; + + case 'p': + parents = 1; + break; - case 'f': - /* validate flag */ - if (parse_flag(opt_arg, &flag) < 0) { + case 's': + oname_src = HDstrdup(opt_arg); + break; + + case 'V': + print_version(h5tools_getprogname()); + leave(EXIT_SUCCESS); + break; + + case 'v': + verbose = 1; + break; + + case 'E': + enable_error_stack = 1; + break; + + default: usage(); leave(EXIT_FAILURE); - } - str_flag = HDstrdup(opt_arg); - break; - - case 'h': - usage(); - leave(EXIT_SUCCESS); - break; - - case 'i': - fname_src = HDstrdup(opt_arg); - break; - - case 'o': - fname_dst = HDstrdup(opt_arg); - break; - - case 'p': - parents = 1; - break; - - case 's': - oname_src = HDstrdup(opt_arg); - break; - - case 'V': - print_version(h5tools_getprogname()); - leave(EXIT_SUCCESS); - break; - - case 'v': - verbose = 1; - break; - - case 'E': - enable_error_stack = 1; - break; - - default: - usage(); - leave(EXIT_FAILURE); } } /* end of while */ -/*------------------------------------------------------------------------- - * check for missing file/object names - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * check for missing file/object names + *-------------------------------------------------------------------------*/ - if (fname_src==NULL) { + if (fname_src == NULL) { error_msg("Input file name missing\n"); usage(); leave(EXIT_FAILURE); } - if (fname_dst==NULL) { + if (fname_dst == NULL) { error_msg("Output file name missing\n"); usage(); leave(EXIT_FAILURE); } - if (oname_src==NULL) { + if (oname_src == NULL) { error_msg("Source object name missing\n"); usage(); leave(EXIT_FAILURE); } - if (oname_dst==NULL) { + if (oname_dst == NULL) { error_msg("Destination object name missing\n"); usage(); leave(EXIT_FAILURE); @@ -321,63 +328,61 @@ main (int argc, const char *argv[]) /* enable error reporting if command line option */ h5tools_error_report(); - /*------------------------------------------------------------------------- - * open output file - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * open output file + *-------------------------------------------------------------------------*/ /* Attempt to open an existing HDF5 file first. Need to open the dst file before the src file just in case that the dst and src are the same file */ fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0); - /*------------------------------------------------------------------------- - * open input file - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * open input file + *-------------------------------------------------------------------------*/ fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, 0); - /*------------------------------------------------------------------------- - * test for error in opening input file - *-------------------------------------------------------------------------*/ - if (fid_src==-1) { + /*------------------------------------------------------------------------- + * test for error in opening input file + *-------------------------------------------------------------------------*/ + if (fid_src == -1) { error_msg("Could not open input file <%s>...Exiting\n", fname_src); leave(EXIT_FAILURE); } - - /*------------------------------------------------------------------------- - * create an output file when failed to open it - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * create an output file when failed to open it + *-------------------------------------------------------------------------*/ /* If we couldn't open an existing file, try creating file */ /* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */ - if(fid_dst < 0) + if (fid_dst < 0) fid_dst = H5Fcreate(fname_dst, H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT); - /*------------------------------------------------------------------------- - * test for error in opening output file - *-------------------------------------------------------------------------*/ - if (fid_dst==-1) { + /*------------------------------------------------------------------------- + * test for error in opening output file + *-------------------------------------------------------------------------*/ + if (fid_dst == -1) { error_msg("Could not open output file <%s>...Exiting\n", fname_dst); leave(EXIT_FAILURE); } - /*------------------------------------------------------------------------- - * print some info - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * print some info + *-------------------------------------------------------------------------*/ if (verbose) { - HDprintf("Copying file <%s> and object <%s> to file <%s> and object <%s>\n", - fname_src, oname_src, fname_dst, oname_dst); + HDprintf("Copying file <%s> and object <%s> to file <%s> and object <%s>\n", fname_src, oname_src, + fname_dst, oname_dst); if (flag) { HDprintf("Using %s flag\n", str_flag); } } - - /*------------------------------------------------------------------------- - * create property lists for copy - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * create property lists for copy + *-------------------------------------------------------------------------*/ /* create property to pass copy options */ if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) @@ -385,42 +390,42 @@ main (int argc, const char *argv[]) /* set options for object copy */ if (flag) { - if ( H5Pset_copy_object(ocpl_id, flag) < 0) + if (H5Pset_copy_object(ocpl_id, flag) < 0) H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pset_copy_object failed"); } /* Create link creation property list */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) { + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) { error_msg("Could not create link creation property list\n"); H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pcreate failed"); } /* end if */ /* Check for creating intermediate groups */ - if(parents) { + if (parents) { /* Set the intermediate group creation property */ - if(H5Pset_create_intermediate_group(lcpl_id, 1) < 0) { + if (H5Pset_create_intermediate_group(lcpl_id, 1) < 0) { error_msg("Could not set property for creating parent groups\n"); H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pset_create_intermediate_group failed"); } /* end if */ /* Display some output if requested */ - if(verbose) + if (verbose) HDprintf("%s: Creating parent groups\n", h5tools_getprogname()); } /* end if */ else { /* error, if parent groups doesn't already exist in destination file */ - size_t i, len; + size_t i, len; len = HDstrlen(oname_dst); /* check if all the parents groups exist. skip root group */ for (i = 1; i < len; i++) { - if ('/'==oname_dst[i]) { - char *str_ptr; + if ('/' == oname_dst[i]) { + char *str_ptr; str_ptr = (char *)HDcalloc(i + 1, sizeof(char)); HDstrncpy(str_ptr, oname_dst, i); - str_ptr[i]='\0'; + str_ptr[i] = '\0'; if (H5Lexists(fid_dst, str_ptr, H5P_DEFAULT) <= 0) { error_msg("group <%s> doesn't exist. Use -p to create parent groups.\n", str_ptr); HDfree(str_ptr); @@ -431,29 +436,27 @@ main (int argc, const char *argv[]) } } - /*------------------------------------------------------------------------- - * do the copy - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * do the copy + *-------------------------------------------------------------------------*/ - if(verbose) + if (verbose) linkinfo.opt.msg_mode = 1; li_ret = H5tools_get_symlink_info(fid_src, oname_src, &linkinfo, 1); if (li_ret == 0) { /* dangling link */ - if(H5Lcopy(fid_src, oname_src, - fid_dst, oname_dst, - H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcopy(fid_src, oname_src, fid_dst, oname_dst, H5P_DEFAULT, H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Lcopy failed"); } else { /* valid link */ - if (H5Ocopy(fid_src, /* Source file or group identifier */ - oname_src, /* Name of the source object to be copied */ - fid_dst, /* Destination file or group identifier */ - oname_dst, /* Name of the destination object */ - ocpl_id, /* Object copy property list */ - lcpl_id)<0) /* Link creation property list */ + if (H5Ocopy(fid_src, /* Source file or group identifier */ + oname_src, /* Name of the source object to be copied */ + fid_dst, /* Destination file or group identifier */ + oname_dst, /* Name of the destination object */ + ocpl_id, /* Object copy property list */ + lcpl_id) < 0) /* Link creation property list */ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Ocopy failed"); } @@ -462,15 +465,15 @@ main (int argc, const char *argv[]) HDfree(linkinfo.trg_path); /* close propertis */ - if(H5Pclose(ocpl_id)<0) + if (H5Pclose(ocpl_id) < 0) H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pclose failed"); - if(H5Pclose(lcpl_id)<0) + if (H5Pclose(lcpl_id) < 0) H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pclose failed"); /* close files */ - if (H5Fclose(fid_src)<0) + if (H5Fclose(fid_src) < 0) H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Fclose failed"); - if (H5Fclose(fid_dst)<0) + if (H5Fclose(fid_dst) < 0) H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Fclose failed"); leave(EXIT_SUCCESS); @@ -482,13 +485,14 @@ done: if (linkinfo.trg_path) HDfree(linkinfo.trg_path); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(ocpl_id); H5Pclose(lcpl_id); H5Fclose(fid_src); H5Fclose(fid_dst); - } H5E_END_TRY; + } + H5E_END_TRY; leave(ret_value); } - diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index a02ad5a..13b6127 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -17,40 +17,38 @@ #include "h5tools.h" #include "h5tools_utils.h" -static int check_n_input(const char*); -static int check_p_input(const char*); -static int check_d_input(const char*); +static int check_n_input(const char *); +static int check_p_input(const char *); +static int check_d_input(const char *); /* * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVrv:qn:d:p:NcelxE:A:S"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "version", no_arg, 'V' }, - { "report", no_arg, 'r' }, - { "verbose", optional_arg, 'v' }, - { "quiet", no_arg, 'q' }, - { "count", require_arg, 'n' }, - { "delta", require_arg, 'd' }, - { "relative", require_arg, 'p' }, - { "nan", no_arg, 'N' }, - { "compare", no_arg, 'c' }, - { "use-system-epsilon", no_arg, 'e' }, - { "follow-symlinks", no_arg, 'l' }, - { "no-dangling-links", no_arg, 'x' }, - { "exclude-path", require_arg, 'E' }, - { "exclude-attribute", require_arg, 'A' }, - { "enable-error-stack", no_arg, 'S' }, - { "vol-value-1", require_arg, '1' }, - { "vol-name-1", require_arg, '2' }, - { "vol-info-1", require_arg, '3' }, - { "vol-value-2", require_arg, '4' }, - { "vol-name-2", require_arg, '5' }, - { "vol-info-2", require_arg, '6' }, - { NULL, 0, '\0' } -}; +static const char * s_opts = "hVrv:qn:d:p:NcelxE:A:S"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"version", no_arg, 'V'}, + {"report", no_arg, 'r'}, + {"verbose", optional_arg, 'v'}, + {"quiet", no_arg, 'q'}, + {"count", require_arg, 'n'}, + {"delta", require_arg, 'd'}, + {"relative", require_arg, 'p'}, + {"nan", no_arg, 'N'}, + {"compare", no_arg, 'c'}, + {"use-system-epsilon", no_arg, 'e'}, + {"follow-symlinks", no_arg, 'l'}, + {"no-dangling-links", no_arg, 'x'}, + {"exclude-path", require_arg, 'E'}, + {"exclude-attribute", require_arg, 'A'}, + {"enable-error-stack", no_arg, 'S'}, + {"vol-value-1", require_arg, '1'}, + {"vol-name-1", require_arg, '2'}, + {"vol-info-1", require_arg, '3'}, + {"vol-value-2", require_arg, '4'}, + {"vol-name-2", require_arg, '5'}, + {"vol-info-2", require_arg, '6'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: check_options @@ -58,7 +56,8 @@ static struct long_options l_opts[] = { * Purpose: parse command line input *------------------------------------------------------------------------- */ -static void check_options(diff_opt_t* opts) +static void +check_options(diff_opt_t *opts) { /*-------------------------------------------------------------- * check for mutually exclusive options @@ -70,7 +69,9 @@ static void check_options(diff_opt_t* opts) if ((opts->delta_bool + opts->percent_bool + opts->use_system_epsilon) > 1) { HDprintf("%s error: -d, -p and --use-system-epsilon options are mutually-exclusive;\n", PROGRAMNAME); HDprintf("use no more than one.\n"); - HDprintf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 Reference Manual'.\n", PROGRAMNAME); + HDprintf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 " + "Reference Manual'.\n", + PROGRAMNAME); h5diff_exit(EXIT_FAILURE); } } @@ -93,11 +94,11 @@ static void check_options(diff_opt_t* opts) static void parse_hsize_list(const char *h_list, subset_d *d) { - hsize_t *p_list; - const char *ptr; - unsigned int size_count = 0; - unsigned int i = 0; - unsigned int last_digit = 0; + hsize_t * p_list; + const char * ptr; + unsigned int size_count = 0; + unsigned int i = 0; + unsigned int last_digit = 0; if (!h_list || !*h_list || *h_list == ';') return; @@ -123,11 +124,11 @@ parse_hsize_list(const char *h_list, subset_d *d) H5TOOLS_DEBUG("Number integers to read=%ld", size_count); /* allocate an array for the integers in the list */ - if((p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t))) == NULL) + if ((p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t))) == NULL) H5TOOLS_INFO("Unable to allocate space for subset data"); for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++) - if(HDisdigit(*ptr)) { + if (HDisdigit(*ptr)) { /* we should have an integer now */ p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0); @@ -136,7 +137,7 @@ parse_hsize_list(const char *h_list, subset_d *d) ptr++; } d->data = p_list; - d->len = size_count; + d->len = size_count; H5TOOLS_ENDDEBUG(""); } @@ -153,7 +154,7 @@ static struct subset_t * parse_subset_params(const char *dset) { struct subset_t *s = NULL; - char *brace; + char * brace; H5TOOLS_START_DEBUG(" - dset:%s", dset); if ((brace = HDstrrchr(dset, '[')) != NULL) { @@ -191,7 +192,6 @@ parse_subset_params(const char *dset) return s; } - /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -199,16 +199,18 @@ parse_subset_params(const char *dset) *------------------------------------------------------------------------- */ -void parse_command_line(int argc, const char* argv[], const char** fname1, const char** fname2, const char** objname1, const char** objname2, diff_opt_t* opts) +void +parse_command_line(int argc, const char *argv[], const char **fname1, const char **fname2, + const char **objname1, const char **objname2, diff_opt_t *opts) { - int i; - int opt; + int i; + int opt; struct exclude_path_list *exclude_head, *exclude_prev, *exclude_node; struct exclude_path_list *exclude_attr_head, *exclude_attr_prev, *exclude_attr_node; H5TOOLS_START_DEBUG(""); /* process the command-line */ - HDmemset(opts, 0, sizeof (diff_opt_t)); + HDmemset(opts, 0, sizeof(diff_opt_t)); /* assume equal contents initially */ opts->contents = 1; @@ -232,208 +234,210 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { - default: - usage(); - h5diff_exit(EXIT_FAILURE); - break; - - case 'h': - usage(); - h5diff_exit(EXIT_SUCCESS); - break; - - case 'V': - print_version(h5tools_getprogname()); - h5diff_exit(EXIT_SUCCESS); - break; - - case 'v': - opts->mode_verbose = 1; - /* This for loop is for handling style like - * -v, -v1, --verbose, --verbose=1. - */ - for (i = 1; i < argc; i++) { - /* - * short opt + default: + usage(); + h5diff_exit(EXIT_FAILURE); + break; + + case 'h': + usage(); + h5diff_exit(EXIT_SUCCESS); + break; + + case 'V': + print_version(h5tools_getprogname()); + h5diff_exit(EXIT_SUCCESS); + break; + + case 'v': + opts->mode_verbose = 1; + /* This for loop is for handling style like + * -v, -v1, --verbose, --verbose=1. */ - if (!strcmp (argv[i], "-v")) { /* no arg */ - opt_ind--; - opts->mode_verbose_level = 0; - break; + for (i = 1; i < argc; i++) { + /* + * short opt + */ + if (!strcmp(argv[i], "-v")) { /* no arg */ + opt_ind--; + opts->mode_verbose_level = 0; + break; + } + else if (!strncmp(argv[i], "-v", (size_t)2)) { + opts->mode_verbose_level = atoi(&argv[i][2]); + break; + } + + /* + * long opt + */ + if (!strcmp(argv[i], "--verbose")) { /* no arg */ + opts->mode_verbose_level = 0; + break; + } + else if (!strncmp(argv[i], "--verbose", (size_t)9) && argv[i][9] == '=') { + opts->mode_verbose_level = atoi(&argv[i][10]); + break; + } } - else if (!strncmp (argv[i], "-v", (size_t)2)) { - opts->mode_verbose_level = atoi(&argv[i][2]); - break; + break; + + case 'q': + /* use quiet mode; supress the message "0 differences found" */ + opts->mode_quiet = 1; + break; + + case 'r': + opts->mode_report = 1; + break; + + case 'l': + opts->follow_links = TRUE; + break; + + case 'x': + opts->no_dangle_links = 1; + break; + + case 'S': + enable_error_stack = 1; + break; + + case 'E': + opts->exclude_path = 1; + + /* create linked list of excluding objects */ + if ((exclude_node = (struct exclude_path_list *)HDmalloc(sizeof(struct exclude_path_list))) == + NULL) { + HDprintf("Error: lack of memory!\n"); + h5diff_exit(EXIT_FAILURE); } - /* - * long opt - */ - if (!strcmp (argv[i], "--verbose")) { /* no arg */ - opts->mode_verbose_level = 0; - break; + /* init */ + exclude_node->obj_path = opt_arg; + exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN; + exclude_prev = exclude_head; + + if (NULL == exclude_head) { + exclude_head = exclude_node; + exclude_head->next = NULL; } - else if (!strncmp (argv[i], "--verbose", (size_t)9) && argv[i][9]=='=') { - opts->mode_verbose_level = atoi(&argv[i][10]); - break; + else { + while (NULL != exclude_prev->next) + exclude_prev = exclude_prev->next; + + exclude_node->next = NULL; + exclude_prev->next = exclude_node; } - } - break; + break; - case 'q': - /* use quiet mode; supress the message "0 differences found" */ - opts->mode_quiet = 1; - break; + case 'A': + opts->exclude_attr_path = 1; - case 'r': - opts->mode_report = 1; - break; + /* create linked list of excluding objects */ + if ((exclude_attr_node = + (struct exclude_path_list *)HDmalloc(sizeof(struct exclude_path_list))) == NULL) { + HDprintf("Error: lack of memory!\n"); + h5diff_exit(EXIT_FAILURE); + } - case 'l': - opts->follow_links = TRUE; - break; + /* init */ + exclude_attr_node->obj_path = opt_arg; + exclude_attr_node->obj_type = H5TRAV_TYPE_UNKNOWN; + exclude_attr_prev = exclude_attr_head; - case 'x': - opts->no_dangle_links = 1; - break; + if (NULL == exclude_attr_head) { + exclude_attr_head = exclude_attr_node; + exclude_attr_head->next = NULL; + } + else { + while (NULL != exclude_attr_prev->next) + exclude_attr_prev = exclude_attr_prev->next; - case 'S': - enable_error_stack = 1; - break; + exclude_attr_node->next = NULL; + exclude_attr_prev->next = exclude_attr_node; + } + break; - case 'E': - opts->exclude_path = 1; + case 'd': + opts->delta_bool = 1; - /* create linked list of excluding objects */ - if( (exclude_node = (struct exclude_path_list*) HDmalloc(sizeof(struct exclude_path_list))) == NULL) { - HDprintf("Error: lack of memory!\n"); - h5diff_exit(EXIT_FAILURE); - } - - /* init */ - exclude_node->obj_path = opt_arg; - exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN; - exclude_prev = exclude_head; - - if (NULL == exclude_head) { - exclude_head = exclude_node; - exclude_head->next = NULL; - } - else { - while(NULL != exclude_prev->next) - exclude_prev = exclude_prev->next; - - exclude_node->next = NULL; - exclude_prev->next = exclude_node; - } - break; - - case 'A': - opts->exclude_attr_path = 1; - - /* create linked list of excluding objects */ - if( (exclude_attr_node = (struct exclude_path_list*) HDmalloc(sizeof(struct exclude_path_list))) == NULL) { - HDprintf("Error: lack of memory!\n"); - h5diff_exit(EXIT_FAILURE); - } - - /* init */ - exclude_attr_node->obj_path = opt_arg; - exclude_attr_node->obj_type = H5TRAV_TYPE_UNKNOWN; - exclude_attr_prev = exclude_attr_head; - - if (NULL == exclude_attr_head) { - exclude_attr_head = exclude_attr_node; - exclude_attr_head->next = NULL; - } - else { - while(NULL != exclude_attr_prev->next) - exclude_attr_prev = exclude_attr_prev->next; - - exclude_attr_node->next = NULL; - exclude_attr_prev->next = exclude_attr_node; - } - break; - - case 'd': - opts->delta_bool = 1; - - if (check_d_input(opt_arg) == -1) { - HDprintf("<-d %s> is not a valid option\n", opt_arg); - usage(); - h5diff_exit(EXIT_FAILURE); - } - opts->delta = HDatof(opt_arg); - /* do not check against default, the DBL_EPSILON is being replaced by user */ - break; - - case 'p': - opts->percent_bool = 1; - if (check_p_input(opt_arg) == -1) { - HDprintf("<-p %s> is not a valid option\n", opt_arg); - usage(); - h5diff_exit(EXIT_FAILURE); - } - opts->percent = HDatof(opt_arg); - - /* -p 0 is the same as default */ - if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F)) - opts->percent_bool = 0; - break; - - case 'n': - opts->count_bool = 1; - if (check_n_input(opt_arg) == -1) { - HDprintf("<-n %s> is not a valid option\n", opt_arg); - usage(); - h5diff_exit(EXIT_FAILURE); - } - opts->count = HDstrtoull(opt_arg, NULL, 0); - break; - - case 'N': - opts->do_nans = 0; - break; - - case 'c': - opts->mode_list_not_cmp = 1; - break; - - case 'e': - opts->use_system_epsilon = 1; - break; - - case '1': - opts->vol_info[0].type = VOL_BY_VALUE; - opts->vol_info[0].u.value = (H5VL_class_value_t)HDatoi(opt_arg); - opts->custom_vol[0] = TRUE; - break; - - case '2': - opts->vol_info[0].type = VOL_BY_NAME; - opts->vol_info[0].u.name = opt_arg; - opts->custom_vol[0] = TRUE; - break; - - case '3': - opts->vol_info[0].info_string = opt_arg; - break; - - case '4': - opts->vol_info[1].type = VOL_BY_VALUE; - opts->vol_info[1].u.value = (H5VL_class_value_t)HDatoi(opt_arg); - opts->custom_vol[1] = TRUE; - break; - - case '5': - opts->vol_info[1].type = VOL_BY_NAME; - opts->vol_info[1].u.name = opt_arg; - opts->custom_vol[1] = TRUE; - break; - - case '6': - opts->vol_info[1].info_string = opt_arg; - break; + if (check_d_input(opt_arg) == -1) { + HDprintf("<-d %s> is not a valid option\n", opt_arg); + usage(); + h5diff_exit(EXIT_FAILURE); + } + opts->delta = HDatof(opt_arg); + /* do not check against default, the DBL_EPSILON is being replaced by user */ + break; + + case 'p': + opts->percent_bool = 1; + if (check_p_input(opt_arg) == -1) { + HDprintf("<-p %s> is not a valid option\n", opt_arg); + usage(); + h5diff_exit(EXIT_FAILURE); + } + opts->percent = HDatof(opt_arg); + + /* -p 0 is the same as default */ + if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F)) + opts->percent_bool = 0; + break; + + case 'n': + opts->count_bool = 1; + if (check_n_input(opt_arg) == -1) { + HDprintf("<-n %s> is not a valid option\n", opt_arg); + usage(); + h5diff_exit(EXIT_FAILURE); + } + opts->count = HDstrtoull(opt_arg, NULL, 0); + break; + + case 'N': + opts->do_nans = 0; + break; + + case 'c': + opts->mode_list_not_cmp = 1; + break; + + case 'e': + opts->use_system_epsilon = 1; + break; + + case '1': + opts->vol_info[0].type = VOL_BY_VALUE; + opts->vol_info[0].u.value = (H5VL_class_value_t)HDatoi(opt_arg); + opts->custom_vol[0] = TRUE; + break; + + case '2': + opts->vol_info[0].type = VOL_BY_NAME; + opts->vol_info[0].u.name = opt_arg; + opts->custom_vol[0] = TRUE; + break; + + case '3': + opts->vol_info[0].info_string = opt_arg; + break; + + case '4': + opts->vol_info[1].type = VOL_BY_VALUE; + opts->vol_info[1].u.value = (H5VL_class_value_t)HDatoi(opt_arg); + opts->custom_vol[1] = TRUE; + break; + + case '5': + opts->vol_info[1].type = VOL_BY_NAME; + opts->vol_info[1].u.name = opt_arg; + opts->custom_vol[1] = TRUE; + break; + + case '6': + opts->vol_info[1].info_string = opt_arg; + break; } } @@ -455,8 +459,8 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const h5diff_exit(EXIT_FAILURE); } - *fname1 = argv[opt_ind]; - *fname2 = argv[opt_ind + 1]; + *fname1 = argv[opt_ind]; + *fname2 = argv[opt_ind + 1]; *objname1 = argv[opt_ind + 2]; H5TOOLS_DEBUG("file1 = %s", *fname1); H5TOOLS_DEBUG("file2 = %s", *fname2); @@ -486,14 +490,14 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const H5TOOLS_ENDDEBUG(""); } - /*------------------------------------------------------------------------- * Function: print_info * * Purpose: print several information messages after h5diff call *------------------------------------------------------------------------- */ -void print_info(diff_opt_t* opts) +void +print_info(diff_opt_t *opts) { if (opts->mode_quiet || opts->err_stat) return; @@ -529,7 +533,7 @@ H5_ATTR_PURE static int check_n_input(const char *str) { unsigned i; - char c; + char c; for (i = 0; i < HDstrlen(str); i++) { c = str[i]; @@ -537,9 +541,8 @@ check_n_input(const char *str) if (c < 49 || c > 57) /* ascii values between 1 and 9 */ return -1; } - else - if (c < 48 || c > 57) /* 0 also */ - return -1; + else if (c < 48 || c > 57) /* 0 also */ + return -1; } return 1; } @@ -607,188 +610,248 @@ check_d_input(const char *str) *------------------------------------------------------------------------- */ -void usage(void) +void +usage(void) { - PRINTVALSTREAM(rawoutstream, "usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]]\n"); - PRINTVALSTREAM(rawoutstream, " file1 File name of the first HDF5 file\n"); - PRINTVALSTREAM(rawoutstream, " file2 File name of the second HDF5 file\n"); - PRINTVALSTREAM(rawoutstream, " [obj1] Name of an HDF5 object, in absolute path\n"); - PRINTVALSTREAM(rawoutstream, " [obj2] Name of an HDF5 object, in absolute path\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); - PRINTVALSTREAM(rawoutstream, " -h, --help\n"); - PRINTVALSTREAM(rawoutstream, " Print a usage message and exit.\n"); - PRINTVALSTREAM(rawoutstream, " -V, --version\n"); - PRINTVALSTREAM(rawoutstream, " Print version number and exit.\n"); - PRINTVALSTREAM(rawoutstream, " -r, --report\n"); - PRINTVALSTREAM(rawoutstream, " Report mode. Print differences.\n"); - PRINTVALSTREAM(rawoutstream, " -v --verbose\n"); - PRINTVALSTREAM(rawoutstream, " Verbose mode. Print differences information and list of objects.\n"); - PRINTVALSTREAM(rawoutstream, " -vN --verbose=N\n"); - PRINTVALSTREAM(rawoutstream, " Verbose mode with level. Print differences and list of objects.\n"); - PRINTVALSTREAM(rawoutstream, " Level of detail depends on value of N:\n"); - PRINTVALSTREAM(rawoutstream, " 0 : Identical to '-v' or '--verbose'.\n"); - PRINTVALSTREAM(rawoutstream, " 1 : All level 0 information plus one-line attribute status summary.\n"); - PRINTVALSTREAM(rawoutstream, " 2 : All level 1 information plus extended attribute status report.\n"); - PRINTVALSTREAM(rawoutstream, " 3 : All level 2 information plus file names.\n"); - PRINTVALSTREAM(rawoutstream, " -q, --quiet\n"); - PRINTVALSTREAM(rawoutstream, " Quiet mode. Do not produce output.\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n"); - PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n"); - PRINTVALSTREAM(rawoutstream, " --vol-value-1 Value (ID) of the VOL connector to use for opening the\n"); - PRINTVALSTREAM(rawoutstream, " first HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-name-1 Name of the VOL connector to use for opening the first\n"); - PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-info-1 VOL-specific info to pass to the VOL connector used for\n"); - PRINTVALSTREAM(rawoutstream, " opening the first HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-value-2 Value (ID) of the VOL connector to use for opening the\n"); - PRINTVALSTREAM(rawoutstream, " second HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-name-2 Name of the VOL connector to use for opening the second\n"); - PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-info-2 VOL-specific info to pass to the VOL connector used for\n"); - PRINTVALSTREAM(rawoutstream, " opening the second HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n"); - PRINTVALSTREAM(rawoutstream, " Follow symbolic links (soft links and external links and compare the)\n"); - PRINTVALSTREAM(rawoutstream, " links' target objects.\n"); - PRINTVALSTREAM(rawoutstream, " If symbolic link(s) with the same name exist in the files being\n"); - PRINTVALSTREAM(rawoutstream, " compared, then determine whether the target of each link is an existing\n"); - PRINTVALSTREAM(rawoutstream, " object (dataset, group, or named datatype) or the link is a dangling\n"); - PRINTVALSTREAM(rawoutstream, " link (a soft or external link pointing to a target object that does\n"); - PRINTVALSTREAM(rawoutstream, " not yet exist).\n"); - PRINTVALSTREAM(rawoutstream, " - If both symbolic links are dangling links, they are treated as being\n"); - PRINTVALSTREAM(rawoutstream, " the same; by default, h5diff returns an exit code of 0.\n"); - PRINTVALSTREAM(rawoutstream, " If, however, --no-dangling-links is used with --follow-symlinks,\n"); - PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n"); - PRINTVALSTREAM(rawoutstream, " exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " - If only one of the two links is a dangling link,they are treated as\n"); - PRINTVALSTREAM(rawoutstream, " being different and h5diff returns an exit code of 1.\n"); - PRINTVALSTREAM(rawoutstream, " If, however, --no-dangling-links is used with --follow-symlinks,\n"); - PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n"); - PRINTVALSTREAM(rawoutstream, " exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " - If both symbolic links point to existing objects, h5diff compares the\n"); - PRINTVALSTREAM(rawoutstream, " two objects.\n"); - PRINTVALSTREAM(rawoutstream, " If any symbolic link specified in the call to h5diff does not exist,\n"); - PRINTVALSTREAM(rawoutstream, " h5diff treats it as an error and returns an exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " --no-dangling-links\n"); - PRINTVALSTREAM(rawoutstream, " Must be used with --follow-symlinks option; otherwise, h5diff shows\n"); - PRINTVALSTREAM(rawoutstream, " error message and returns an exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " Check for any symbolic links (soft links or external links) that do not\n"); - PRINTVALSTREAM(rawoutstream, " resolve to an existing object (dataset, group, or named datatype).\n"); - PRINTVALSTREAM(rawoutstream, " If any dangling link is found, this situation is treated as an error\n"); - PRINTVALSTREAM(rawoutstream, " and h5diff returns an exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " -c, --compare\n"); - PRINTVALSTREAM(rawoutstream, " List objects that are not comparable\n"); - PRINTVALSTREAM(rawoutstream, " -N, --nan\n"); - PRINTVALSTREAM(rawoutstream, " Avoid NaNs detection\n"); - PRINTVALSTREAM(rawoutstream, " -n C, --count=C\n"); - PRINTVALSTREAM(rawoutstream, " Print differences up to C. C must be a positive integer.\n"); - PRINTVALSTREAM(rawoutstream, " -d D, --delta=D\n"); - PRINTVALSTREAM(rawoutstream, " Print difference if (|a-b| > D). D must be a positive number. Where a\n"); - PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n"); - PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '--use-system-epsilon'.\n"); - PRINTVALSTREAM(rawoutstream, " -p R, --relative=R\n"); - PRINTVALSTREAM(rawoutstream, " Print difference if (|(a-b)/b| > R). R must be a positive number. Where a\n"); - PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n"); - PRINTVALSTREAM(rawoutstream, " Can not use with '-d' or '--use-system-epsilon'.\n"); - PRINTVALSTREAM(rawoutstream, " --use-system-epsilon\n"); - PRINTVALSTREAM(rawoutstream, " Print difference if (|a-b| > EPSILON), EPSILON is system defined value. Where a\n"); - PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n"); - PRINTVALSTREAM(rawoutstream, " If the system epsilon is not defined,one of the following predefined\n"); - PRINTVALSTREAM(rawoutstream, " values will be used:\n"); - PRINTVALSTREAM(rawoutstream, " FLT_EPSILON = 1.19209E-07 for floating-point type\n"); - PRINTVALSTREAM(rawoutstream, " DBL_EPSILON = 2.22045E-16 for double precision type\n"); - PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '-d'.\n"); - PRINTVALSTREAM(rawoutstream, " --exclude-path \"path\"\n"); - PRINTVALSTREAM(rawoutstream, " Exclude the specified path to an object when comparing files or groups.\n"); - PRINTVALSTREAM(rawoutstream, " If a group is excluded, all member objects will also be excluded.\n"); - PRINTVALSTREAM(rawoutstream, " The specified path is excluded wherever it occurs.\n"); - PRINTVALSTREAM(rawoutstream, " This flexibility enables the same option to exclude either objects that\n"); - PRINTVALSTREAM(rawoutstream, " exist only in one file or common objects that are known to differ.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " When comparing files, \"path\" is the absolute path to the excluded;\n"); - PRINTVALSTREAM(rawoutstream, " object; when comparing groups, \"path\" is similar to the relative\n"); - PRINTVALSTREAM(rawoutstream, " path from the group to the excluded object. This \"path\" can be\n"); - PRINTVALSTREAM(rawoutstream, " taken from the first section of the output of the --verbose option.\n"); - PRINTVALSTREAM(rawoutstream, " For example, if you are comparing the group /groupA in two files and\n"); - PRINTVALSTREAM(rawoutstream, " you want to exclude /groupA/groupB/groupC in both files, the exclude\n"); - PRINTVALSTREAM(rawoutstream, " option would read as follows:\n"); - PRINTVALSTREAM(rawoutstream, " --exclude-path \"/groupB/groupC\"\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " If there are multiple paths to an object, only the specified path(s)\n"); - PRINTVALSTREAM(rawoutstream, " will be excluded; the comparison will include any path not explicitly\n"); - PRINTVALSTREAM(rawoutstream, " excluded.\n"); - PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " --exclude-attribute \"path/to/object/with/attribute\"\n"); - PRINTVALSTREAM(rawoutstream, " Exclude attributes on the specified path to an object when comparing files or groups.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " If there are multiple paths to an object, only the specified path(s)\n"); - PRINTVALSTREAM(rawoutstream, " will be excluded; the comparison will include any path not explicitly\n"); - PRINTVALSTREAM(rawoutstream, " excluded.\n"); - PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Modes of output:\n"); - PRINTVALSTREAM(rawoutstream, " Default mode: print the number of differences found and where they occured\n"); - PRINTVALSTREAM(rawoutstream, " -r Report mode: print the above plus the differences\n"); - PRINTVALSTREAM(rawoutstream, " -v Verbose mode: print the above plus a list of objects and warnings\n"); - PRINTVALSTREAM(rawoutstream, " -q Quiet mode: do not print output\n"); - - PRINTVALSTREAM(rawoutstream, "\n"); - - PRINTVALSTREAM(rawoutstream, " File comparison:\n"); - PRINTVALSTREAM(rawoutstream, " If no objects [obj1[ obj2]] are specified, the h5diff comparison proceeds as\n"); - PRINTVALSTREAM(rawoutstream, " a comparison of the two files' root groups. That is, h5diff first compares\n"); - PRINTVALSTREAM(rawoutstream, " the names of root group members, generates a report of root group objects\n"); - PRINTVALSTREAM(rawoutstream, " that appear in only one file or in both files, and recursively compares\n"); - PRINTVALSTREAM(rawoutstream, " common objects.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - - PRINTVALSTREAM(rawoutstream, " Object comparison:\n"); - PRINTVALSTREAM(rawoutstream, " 1) Groups\n"); - PRINTVALSTREAM(rawoutstream, " First compares the names of member objects (relative path, from the\n"); - PRINTVALSTREAM(rawoutstream, " specified group) and generates a report of objects that appear in only\n"); - PRINTVALSTREAM(rawoutstream, " one group or in both groups. Common objects are then compared recursively.\n"); - PRINTVALSTREAM(rawoutstream, " 2) Datasets\n"); - PRINTVALSTREAM(rawoutstream, " Array rank and dimensions, datatypes, and data values are compared.\n"); - PRINTVALSTREAM(rawoutstream, " 3) Datatypes\n"); - PRINTVALSTREAM(rawoutstream, " The comparison is based on the return value of H5Tequal.\n"); - PRINTVALSTREAM(rawoutstream, " 4) Symbolic links\n"); - PRINTVALSTREAM(rawoutstream, " The paths to the target objects are compared.\n"); - PRINTVALSTREAM(rawoutstream, " (The option --follow-symlinks overrides the default behavior when\n"); - PRINTVALSTREAM(rawoutstream, " symbolic links are compared.).\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - /* - * TRILABS-227 is complete except for an issue with printing indices - * the following will be needed for subsetting - PRINTVALSTREAM(rawoutstream, " Subsetting options:\n"); - PRINTVALSTREAM(rawoutstream, " Subsetting is available by using the fcompact form of subsetting, as follows:\n"); - PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK]\n"); - PRINTVALSTREAM(rawoutstream, " It is not required to use all parameters, but until the last parameter value used,\n"); - PRINTVALSTREAM(rawoutstream, " all of the semicolons (;) are required, even when a parameter value is not specified. Example:\n"); - PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;;COUNT;BLOCK]\n"); - PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START]\n"); - PRINTVALSTREAM(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n"); - PRINTVALSTREAM(rawoutstream, " each dimension. START is optional and will default to 0 in each dimension.\n"); - PRINTVALSTREAM(rawoutstream, " Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with\n"); - PRINTVALSTREAM(rawoutstream, " one integer for each dimension of the dataset.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); -*/ - PRINTVALSTREAM(rawoutstream, " Exit code:\n"); - PRINTVALSTREAM(rawoutstream, " 0 if no differences, 1 if differences found, 2 if error\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Examples of use:\n"); - PRINTVALSTREAM(rawoutstream, " 1) h5diff file1 file2 /g1/dset1 /g1/dset2\n"); - PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 2) h5diff file1 file2 /g1/dset1\n"); - PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in both files\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 3) h5diff file1 file2\n"); - PRINTVALSTREAM(rawoutstream, " Compares all objects in both files\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Notes:\n"); - PRINTVALSTREAM(rawoutstream, " file1 and file2 can be the same file.\n"); - PRINTVALSTREAM(rawoutstream, " Use h5diff file1 file1 /g1/dset1 /g1/dset2 to compare\n"); - PRINTVALSTREAM(rawoutstream, " '/g1/dset1' and '/g1/dset2' in the same file\n"); - PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]]\n"); + PRINTVALSTREAM(rawoutstream, " file1 File name of the first HDF5 file\n"); + PRINTVALSTREAM(rawoutstream, " file2 File name of the second HDF5 file\n"); + PRINTVALSTREAM(rawoutstream, " [obj1] Name of an HDF5 object, in absolute path\n"); + PRINTVALSTREAM(rawoutstream, " [obj2] Name of an HDF5 object, in absolute path\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); + PRINTVALSTREAM(rawoutstream, " -h, --help\n"); + PRINTVALSTREAM(rawoutstream, " Print a usage message and exit.\n"); + PRINTVALSTREAM(rawoutstream, " -V, --version\n"); + PRINTVALSTREAM(rawoutstream, " Print version number and exit.\n"); + PRINTVALSTREAM(rawoutstream, " -r, --report\n"); + PRINTVALSTREAM(rawoutstream, " Report mode. Print differences.\n"); + PRINTVALSTREAM(rawoutstream, " -v --verbose\n"); + PRINTVALSTREAM(rawoutstream, + " Verbose mode. Print differences information and list of objects.\n"); + PRINTVALSTREAM(rawoutstream, " -vN --verbose=N\n"); + PRINTVALSTREAM(rawoutstream, + " Verbose mode with level. Print differences and list of objects.\n"); + PRINTVALSTREAM(rawoutstream, " Level of detail depends on value of N:\n"); + PRINTVALSTREAM(rawoutstream, " 0 : Identical to '-v' or '--verbose'.\n"); + PRINTVALSTREAM(rawoutstream, + " 1 : All level 0 information plus one-line attribute status summary.\n"); + PRINTVALSTREAM(rawoutstream, + " 2 : All level 1 information plus extended attribute status report.\n"); + PRINTVALSTREAM(rawoutstream, " 3 : All level 2 information plus file names.\n"); + PRINTVALSTREAM(rawoutstream, " -q, --quiet\n"); + PRINTVALSTREAM(rawoutstream, " Quiet mode. Do not produce output.\n"); + PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n"); + PRINTVALSTREAM(rawoutstream, + " Prints messages from the HDF5 error stack as they occur.\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-value-1 Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " first HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-name-1 Name of the VOL connector to use for opening the first\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-info-1 VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the first HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-value-2 Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " second HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-name-2 Name of the VOL connector to use for opening the second\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-info-2 VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the second HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n"); + PRINTVALSTREAM(rawoutstream, + " Follow symbolic links (soft links and external links and compare the)\n"); + PRINTVALSTREAM(rawoutstream, " links' target objects.\n"); + PRINTVALSTREAM(rawoutstream, + " If symbolic link(s) with the same name exist in the files being\n"); + PRINTVALSTREAM(rawoutstream, + " compared, then determine whether the target of each link is an existing\n"); + PRINTVALSTREAM(rawoutstream, + " object (dataset, group, or named datatype) or the link is a dangling\n"); + PRINTVALSTREAM(rawoutstream, + " link (a soft or external link pointing to a target object that does\n"); + PRINTVALSTREAM(rawoutstream, " not yet exist).\n"); + PRINTVALSTREAM(rawoutstream, + " - If both symbolic links are dangling links, they are treated as being\n"); + PRINTVALSTREAM(rawoutstream, " the same; by default, h5diff returns an exit code of 0.\n"); + PRINTVALSTREAM(rawoutstream, + " If, however, --no-dangling-links is used with --follow-symlinks,\n"); + PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n"); + PRINTVALSTREAM(rawoutstream, " exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, + " - If only one of the two links is a dangling link,they are treated as\n"); + PRINTVALSTREAM(rawoutstream, " being different and h5diff returns an exit code of 1.\n"); + PRINTVALSTREAM(rawoutstream, + " If, however, --no-dangling-links is used with --follow-symlinks,\n"); + PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n"); + PRINTVALSTREAM(rawoutstream, " exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, + " - If both symbolic links point to existing objects, h5diff compares the\n"); + PRINTVALSTREAM(rawoutstream, " two objects.\n"); + PRINTVALSTREAM(rawoutstream, + " If any symbolic link specified in the call to h5diff does not exist,\n"); + PRINTVALSTREAM(rawoutstream, " h5diff treats it as an error and returns an exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, " --no-dangling-links\n"); + PRINTVALSTREAM(rawoutstream, + " Must be used with --follow-symlinks option; otherwise, h5diff shows\n"); + PRINTVALSTREAM(rawoutstream, " error message and returns an exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, + " Check for any symbolic links (soft links or external links) that do not\n"); + PRINTVALSTREAM(rawoutstream, + " resolve to an existing object (dataset, group, or named datatype).\n"); + PRINTVALSTREAM(rawoutstream, + " If any dangling link is found, this situation is treated as an error\n"); + PRINTVALSTREAM(rawoutstream, " and h5diff returns an exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, " -c, --compare\n"); + PRINTVALSTREAM(rawoutstream, " List objects that are not comparable\n"); + PRINTVALSTREAM(rawoutstream, " -N, --nan\n"); + PRINTVALSTREAM(rawoutstream, " Avoid NaNs detection\n"); + PRINTVALSTREAM(rawoutstream, " -n C, --count=C\n"); + PRINTVALSTREAM(rawoutstream, " Print differences up to C. C must be a positive integer.\n"); + PRINTVALSTREAM(rawoutstream, " -d D, --delta=D\n"); + PRINTVALSTREAM(rawoutstream, + " Print difference if (|a-b| > D). D must be a positive number. Where a\n"); + PRINTVALSTREAM(rawoutstream, + " is the data point value in file1 and b is the data point value in file2.\n"); + PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '--use-system-epsilon'.\n"); + PRINTVALSTREAM(rawoutstream, " -p R, --relative=R\n"); + PRINTVALSTREAM(rawoutstream, + " Print difference if (|(a-b)/b| > R). R must be a positive number. Where a\n"); + PRINTVALSTREAM(rawoutstream, + " is the data point value in file1 and b is the data point value in file2.\n"); + PRINTVALSTREAM(rawoutstream, " Can not use with '-d' or '--use-system-epsilon'.\n"); + PRINTVALSTREAM(rawoutstream, " --use-system-epsilon\n"); + PRINTVALSTREAM( + rawoutstream, + " Print difference if (|a-b| > EPSILON), EPSILON is system defined value. Where a\n"); + PRINTVALSTREAM(rawoutstream, + " is the data point value in file1 and b is the data point value in file2.\n"); + PRINTVALSTREAM(rawoutstream, + " If the system epsilon is not defined,one of the following predefined\n"); + PRINTVALSTREAM(rawoutstream, " values will be used:\n"); + PRINTVALSTREAM(rawoutstream, " FLT_EPSILON = 1.19209E-07 for floating-point type\n"); + PRINTVALSTREAM(rawoutstream, " DBL_EPSILON = 2.22045E-16 for double precision type\n"); + PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '-d'.\n"); + PRINTVALSTREAM(rawoutstream, " --exclude-path \"path\"\n"); + PRINTVALSTREAM(rawoutstream, + " Exclude the specified path to an object when comparing files or groups.\n"); + PRINTVALSTREAM(rawoutstream, + " If a group is excluded, all member objects will also be excluded.\n"); + PRINTVALSTREAM(rawoutstream, " The specified path is excluded wherever it occurs.\n"); + PRINTVALSTREAM(rawoutstream, + " This flexibility enables the same option to exclude either objects that\n"); + PRINTVALSTREAM(rawoutstream, + " exist only in one file or common objects that are known to differ.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, + " When comparing files, \"path\" is the absolute path to the excluded;\n"); + PRINTVALSTREAM(rawoutstream, + " object; when comparing groups, \"path\" is similar to the relative\n"); + PRINTVALSTREAM(rawoutstream, + " path from the group to the excluded object. This \"path\" can be\n"); + PRINTVALSTREAM(rawoutstream, + " taken from the first section of the output of the --verbose option.\n"); + PRINTVALSTREAM(rawoutstream, + " For example, if you are comparing the group /groupA in two files and\n"); + PRINTVALSTREAM(rawoutstream, + " you want to exclude /groupA/groupB/groupC in both files, the exclude\n"); + PRINTVALSTREAM(rawoutstream, " option would read as follows:\n"); + PRINTVALSTREAM(rawoutstream, " --exclude-path \"/groupB/groupC\"\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, + " If there are multiple paths to an object, only the specified path(s)\n"); + PRINTVALSTREAM(rawoutstream, + " will be excluded; the comparison will include any path not explicitly\n"); + PRINTVALSTREAM(rawoutstream, " excluded.\n"); + PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " --exclude-attribute \"path/to/object/with/attribute\"\n"); + PRINTVALSTREAM( + rawoutstream, + " Exclude attributes on the specified path to an object when comparing files or groups.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, + " If there are multiple paths to an object, only the specified path(s)\n"); + PRINTVALSTREAM(rawoutstream, + " will be excluded; the comparison will include any path not explicitly\n"); + PRINTVALSTREAM(rawoutstream, " excluded.\n"); + PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Modes of output:\n"); + PRINTVALSTREAM(rawoutstream, + " Default mode: print the number of differences found and where they occured\n"); + PRINTVALSTREAM(rawoutstream, " -r Report mode: print the above plus the differences\n"); + PRINTVALSTREAM(rawoutstream, " -v Verbose mode: print the above plus a list of objects and warnings\n"); + PRINTVALSTREAM(rawoutstream, " -q Quiet mode: do not print output\n"); + + PRINTVALSTREAM(rawoutstream, "\n"); + + PRINTVALSTREAM(rawoutstream, " File comparison:\n"); + PRINTVALSTREAM(rawoutstream, + " If no objects [obj1[ obj2]] are specified, the h5diff comparison proceeds as\n"); + PRINTVALSTREAM(rawoutstream, + " a comparison of the two files' root groups. That is, h5diff first compares\n"); + PRINTVALSTREAM(rawoutstream, + " the names of root group members, generates a report of root group objects\n"); + PRINTVALSTREAM(rawoutstream, + " that appear in only one file or in both files, and recursively compares\n"); + PRINTVALSTREAM(rawoutstream, " common objects.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + + PRINTVALSTREAM(rawoutstream, " Object comparison:\n"); + PRINTVALSTREAM(rawoutstream, " 1) Groups\n"); + PRINTVALSTREAM(rawoutstream, + " First compares the names of member objects (relative path, from the\n"); + PRINTVALSTREAM(rawoutstream, + " specified group) and generates a report of objects that appear in only\n"); + PRINTVALSTREAM(rawoutstream, + " one group or in both groups. Common objects are then compared recursively.\n"); + PRINTVALSTREAM(rawoutstream, " 2) Datasets\n"); + PRINTVALSTREAM(rawoutstream, + " Array rank and dimensions, datatypes, and data values are compared.\n"); + PRINTVALSTREAM(rawoutstream, " 3) Datatypes\n"); + PRINTVALSTREAM(rawoutstream, " The comparison is based on the return value of H5Tequal.\n"); + PRINTVALSTREAM(rawoutstream, " 4) Symbolic links\n"); + PRINTVALSTREAM(rawoutstream, " The paths to the target objects are compared.\n"); + PRINTVALSTREAM(rawoutstream, " (The option --follow-symlinks overrides the default behavior when\n"); + PRINTVALSTREAM(rawoutstream, " symbolic links are compared.).\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + /* + * TRILABS-227 is complete except for an issue with printing indices + * the following will be needed for subsetting + PRINTVALSTREAM(rawoutstream, " Subsetting options:\n"); + PRINTVALSTREAM(rawoutstream, " Subsetting is available by using the fcompact form of subsetting, as + follows:\n"); PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK]\n"); + PRINTVALSTREAM(rawoutstream, " It is not required to use all parameters, but until the last parameter + value used,\n"); PRINTVALSTREAM(rawoutstream, " all of the semicolons (;) are required, even when a + parameter value is not specified. Example:\n"); PRINTVALSTREAM(rawoutstream, " obj1 + /foo/mydataset[START;;COUNT;BLOCK]\n"); PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START]\n"); + PRINTVALSTREAM(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 + in\n"); PRINTVALSTREAM(rawoutstream, " each dimension. START is optional and will default to 0 in each + dimension.\n"); PRINTVALSTREAM(rawoutstream, " Each of START, STRIDE, COUNT, and BLOCK must be a + comma-separated list of integers with\n"); PRINTVALSTREAM(rawoutstream, " one integer for each dimension + of the dataset.\n"); PRINTVALSTREAM(rawoutstream, "\n"); + */ + PRINTVALSTREAM(rawoutstream, " Exit code:\n"); + PRINTVALSTREAM(rawoutstream, " 0 if no differences, 1 if differences found, 2 if error\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Examples of use:\n"); + PRINTVALSTREAM(rawoutstream, " 1) h5diff file1 file2 /g1/dset1 /g1/dset2\n"); + PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " 2) h5diff file1 file2 /g1/dset1\n"); + PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in both files\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " 3) h5diff file1 file2\n"); + PRINTVALSTREAM(rawoutstream, " Compares all objects in both files\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Notes:\n"); + PRINTVALSTREAM(rawoutstream, " file1 and file2 can be the same file.\n"); + PRINTVALSTREAM(rawoutstream, " Use h5diff file1 file1 /g1/dset1 /g1/dset2 to compare\n"); + PRINTVALSTREAM(rawoutstream, " '/g1/dset1' and '/g1/dset2' in the same file\n"); + PRINTVALSTREAM(rawoutstream, "\n"); } diff --git a/tools/src/h5diff/h5diff_common.h b/tools/src/h5diff/h5diff_common.h index dc0676c..b855077 100644 --- a/tools/src/h5diff/h5diff_common.h +++ b/tools/src/h5diff/h5diff_common.h @@ -23,9 +23,10 @@ extern "C" { #endif void usage(void); -void parse_command_line(int argc, const char* argv[], const char** fname1, const char** fname2, const char** objname1, const char** objname2, diff_opt_t* opts); +void parse_command_line(int argc, const char *argv[], const char **fname1, const char **fname2, + const char **objname1, const char **objname2, diff_opt_t *opts); void h5diff_exit(int status); -void print_info(diff_opt_t* opts); +void print_info(diff_opt_t *opts); #ifdef __cplusplus } diff --git a/tools/src/h5diff/h5diff_main.c b/tools/src/h5diff/h5diff_main.c index 33d6570..2c7580d 100644 --- a/tools/src/h5diff/h5diff_main.c +++ b/tools/src/h5diff/h5diff_main.c @@ -17,7 +17,6 @@ #include "h5tools.h" #include "h5tools_utils.h" - /*------------------------------------------------------------------------- * Function: main * @@ -65,17 +64,17 @@ *------------------------------------------------------------------------- */ - -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - int ret; - int i; - const char *fname1 = NULL; - const char *fname2 = NULL; - const char *objname1 = NULL; - const char *objname2 = NULL; - hsize_t nfound=0; - diff_opt_t opts; + int ret; + int i; + const char *fname1 = NULL; + const char *fname2 = NULL; + const char *objname1 = NULL; + const char *objname2 = NULL; + hsize_t nfound = 0; + diff_opt_t opts; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -84,28 +83,28 @@ int main(int argc, const char *argv[]) h5tools_init(); /*------------------------------------------------------------------------- - * process the command-line - *------------------------------------------------------------------------- - */ + * process the command-line + *------------------------------------------------------------------------- + */ parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); /* enable error reporting if command line option */ h5tools_error_report(); /*------------------------------------------------------------------------- - * do the diff - *------------------------------------------------------------------------- - */ + * do the diff + *------------------------------------------------------------------------- + */ nfound = h5diff(fname1, fname2, objname1, objname2, &opts); print_info(&opts); - /*------------------------------------------------------------------------- - * exit code - * 1 if differences, 0 if no differences, 2 if error - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * exit code + * 1 if differences, 0 if no differences, 2 if error + *------------------------------------------------------------------------- + */ ret = (nfound == 0 ? 0 : 1); @@ -120,17 +119,17 @@ int main(int argc, const char *argv[]) /* free any buffers */ for (i = 0; i < 2; i++) { if (opts.sset[i]) { - if(opts.sset[i]->start.data) + if (opts.sset[i]->start.data) HDfree(opts.sset[i]->start.data); - if(opts.sset[i]->stride.data) + if (opts.sset[i]->stride.data) HDfree(opts.sset[i]->stride.data); - if(opts.sset[i]->count.data) + if (opts.sset[i]->count.data) HDfree(opts.sset[i]->count.data); - if(opts.sset[i]->block.data) + if (opts.sset[i]->block.data) HDfree(opts.sset[i]->block.data); HDfree(opts.sset[i]); - opts.sset[i]=NULL; + opts.sset[i] = NULL; } } @@ -160,4 +159,3 @@ h5diff_exit(int status) HDexit(status); } - diff --git a/tools/src/h5diff/ph5diff_main.c b/tools/src/h5diff/ph5diff_main.c index c473c8b..549d422 100644 --- a/tools/src/h5diff/ph5diff_main.c +++ b/tools/src/h5diff/ph5diff_main.c @@ -21,7 +21,7 @@ /* Name of tool */ #define PROGRAMNAME "h5diff" -static void ph5diff_worker(int ); +static void ph5diff_worker(int); /*------------------------------------------------------------------------- * Function: main @@ -43,14 +43,15 @@ static void ph5diff_worker(int ); *------------------------------------------------------------------------- */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - int nID = 0; - const char *fname1 = NULL; - const char *fname2 = NULL; - const char *objname1 = NULL; - const char *objname2 = NULL; - diff_opt_t opts; + int nID = 0; + const char *fname1 = NULL; + const char *fname2 = NULL; + const char *objname1 = NULL; + const char *objname2 = NULL; + diff_opt_t opts; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -59,15 +60,14 @@ int main(int argc, const char *argv[]) h5tools_init(); outBuffOffset = 0; - g_Parallel = 1; + g_Parallel = 1; - MPI_Init(&argc, (char***) &argv); + MPI_Init(&argc, (char ***)&argv); MPI_Comm_rank(MPI_COMM_WORLD, &nID); MPI_Comm_size(MPI_COMM_WORLD, &g_nTasks); - if(g_nTasks == 1) - { + if (g_nTasks == 1) { HDprintf("Only 1 task available...doing serial diff\n"); g_Parallel = 0; @@ -82,8 +82,7 @@ int main(int argc, const char *argv[]) else { /* Have the manager process the command-line */ - if(nID == 0) - { + if (nID == 0) { parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); h5diff(fname1, fname2, objname1, objname2, &opts); @@ -129,31 +128,27 @@ ph5diff_worker(int nID) hid_t file1_id = H5I_INVALID_HID; hid_t file2_id = H5I_INVALID_HID; - while(1) - { + while (1) { MPI_Status Status; MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); /* Check for filenames */ - if(Status.MPI_TAG == MPI_TAG_PARALLEL) - { - char filenames[2][MAX_FILENAME]; + if (Status.MPI_TAG == MPI_TAG_PARALLEL) { + char filenames[2][MAX_FILENAME]; /* Retrieve filenames */ - MPI_Recv(filenames, MAX_FILENAME*2, MPI_CHAR, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); + MPI_Recv(filenames, MAX_FILENAME * 2, MPI_CHAR, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); /* disable error reporting */ H5E_BEGIN_TRY { /* Open the files */ - if ((file1_id = H5Fopen (filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - { + if ((file1_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { HDprintf("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[0]); MPI_Abort(MPI_COMM_WORLD, 0); } - if ((file2_id = H5Fopen (filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - { + if ((file2_id = H5Fopen(filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { HDprintf("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[1]); MPI_Abort(MPI_COMM_WORLD, 0); } @@ -162,15 +157,13 @@ ph5diff_worker(int nID) H5E_END_TRY; } /* Check for work */ - else if(Status.MPI_TAG == MPI_TAG_ARGS) - { + else if (Status.MPI_TAG == MPI_TAG_ARGS) { struct diff_mpi_args args; - struct diffs_found diffs; - unsigned i; + struct diffs_found diffs; + unsigned i; /* Make certain we've received the filenames and opened the files already */ - if(file1_id < 0 || file2_id < 0) - { + if (file1_id < 0 || file2_id < 0) { HDprintf("ph5diff_worker: ERROR: work received before/without filenames\n"); break; } @@ -179,44 +172,43 @@ ph5diff_worker(int nID) MPI_Recv(&args, sizeof(args), MPI_BYTE, 0, MPI_TAG_ARGS, MPI_COMM_WORLD, &Status); /* Do the diff */ - diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.opts), &(args.argdata)); + diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.opts), &(args.argdata)); diffs.not_cmp = args.opts.not_cmp; /* If print buffer has something in it, request print token.*/ - if(outBuffOffset>0) - { + if (outBuffOffset > 0) { MPI_Send(NULL, 0, MPI_BYTE, 0, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD); /* Wait for print token. */ MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD, &Status); /* When get token, send all of our output to the manager task and then return the token */ - for(i=0; i= 0) - { + while ((tmp = getc(overflow_file)) >= 0) { *(out_data + i++) = (char)tmp; - if(i==PRINT_DATA_MAX_SIZE) - { - MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD); - i=0; + if (i == PRINT_DATA_MAX_SIZE) { + MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, + MPI_COMM_WORLD); + i = 0; HDmemset(out_data, 0, PRINT_DATA_MAX_SIZE); } } - if(i>0) - MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD); + if (i > 0) + MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, + MPI_COMM_WORLD); fclose(overflow_file); overflow_file = NULL; @@ -232,17 +224,14 @@ ph5diff_worker(int nID) MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_DONE, MPI_COMM_WORLD); } /* Check for leaving */ - else if(Status.MPI_TAG == MPI_TAG_END) - { + else if (Status.MPI_TAG == MPI_TAG_END) { MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_END, MPI_COMM_WORLD, &Status); break; } - else - { + else { HDprintf("ph5diff_worker: ERROR: invalid tag (%d) received\n", Status.MPI_TAG); break; } - } return; @@ -262,18 +251,17 @@ ph5diff_worker(int nID) * *------------------------------------------------------------------------- */ -void print_manager_output(void) +void +print_manager_output(void) { /* If there was something we buffered, let's print it now */ - if( (outBuffOffset>0) && g_Parallel) - { + if ((outBuffOffset > 0) && g_Parallel) { HDprintf("%s", outBuff); - if(overflow_file) - { - int tmp; + if (overflow_file) { + int tmp; rewind(overflow_file); - while((tmp = HDgetc(overflow_file)) >= 0) + while ((tmp = HDgetc(overflow_file)) >= 0) HDputchar(tmp); fclose(overflow_file); overflow_file = NULL; @@ -283,8 +271,7 @@ void print_manager_output(void) HDmemset(outBuff, 0, OUTBUFF_SIZE); outBuffOffset = 0; } - else if( (outBuffOffset>0) && !g_Parallel) - { + else if ((outBuffOffset > 0) && !g_Parallel) { HDfprintf(stderr, "h5diff error: outBuffOffset>0, but we're not in parallel!\n"); } } @@ -305,16 +292,18 @@ void print_manager_output(void) * *------------------------------------------------------------------------- */ -void h5diff_exit(int status) +void +h5diff_exit(int status) { /* if in parallel mode, dismiss workers, close down MPI, then exit */ - if(g_Parallel) { - if(g_nTasks > 1) { + if (g_Parallel) { + if (g_nTasks > 1) { phdiff_dismiss_workers(); MPI_Barrier(MPI_COMM_WORLD); } MPI_Finalize(); - status = EXIT_SUCCESS; /* Reset exit status, since some mpiexec commands generate output on failure status */ + status = EXIT_SUCCESS; /* Reset exit status, since some mpiexec commands generate output on failure + status */ } h5tools_close(); @@ -324,4 +313,3 @@ void h5diff_exit(int status) */ HDexit(0); } - diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index 2b21b1c..9a5e297 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -18,13 +18,13 @@ /* Name of tool */ #define PROGRAMNAME "h5dump" -static const char *driver_name_g = NULL; /* The driver to open the file with. */ -const char *outfname_g = NULL; -static hbool_t doxml_g = FALSE; -static hbool_t useschema_g = TRUE; -static const char *xml_dtd_uri_g = NULL; +static const char *driver_name_g = NULL; /* The driver to open the file with. */ +const char * outfname_g = NULL; +static hbool_t doxml_g = FALSE; +static hbool_t useschema_g = TRUE; +static const char *xml_dtd_uri_g = NULL; -static hbool_t use_custom_vol_g = FALSE; +static hbool_t use_custom_vol_g = FALSE; static h5tools_vol_info_t vol_info_g; #ifdef H5_HAVE_ROS3_VFD @@ -51,38 +51,25 @@ static H5FD_hdfs_fapl_t hdfs_fa_g = { #endif /* H5_HAVE_LIBHDFS */ /* module-scoped variables for XML option */ -#define DEFAULT_XSD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd" -#define DEFAULT_DTD "http://www.hdfgroup.org/HDF5/XML/DTD/HDF5-File.dtd" +#define DEFAULT_XSD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd" +#define DEFAULT_DTD "http://www.hdfgroup.org/HDF5/XML/DTD/HDF5-File.dtd" /* Standard DDL output */ static const dump_functions ddl_function_table = { - dump_group, - dump_named_datatype, - dump_dataset, - dump_dataspace, - dump_datatype, - dump_attr_cb, - dump_data -}; + dump_group, dump_named_datatype, dump_dataset, dump_dataspace, dump_datatype, dump_attr_cb, dump_data}; /* XML output */ static const dump_functions xml_function_table = { - xml_dump_group, - xml_dump_named_datatype, - xml_dump_dataset, - xml_dump_dataspace, - xml_dump_datatype, - xml_dump_attr, - xml_dump_data -}; + xml_dump_group, xml_dump_named_datatype, xml_dump_dataset, xml_dump_dataspace, + xml_dump_datatype, xml_dump_attr, xml_dump_data}; /* internal functions */ -static void init_prefix(char **prfx, size_t prfx_len); +static void init_prefix(char **prfx, size_t prfx_len); /* a structure for handling the order command-line parameters come in */ struct handler_t { void (*func)(hid_t, const char *, void *, int, const char *); - char *obj; + char * obj; struct subset_t *subset_info; }; @@ -93,135 +80,132 @@ struct handler_t { */ /* The following initialization makes use of C language concatenating */ /* "xxx" "yyy" into "xxxyyy". */ -static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RE*CM:O*N:vG:"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - { "contents", optional_arg, 'n' }, - { "properties", no_arg, 'p' }, - { "superblock", no_arg, 'B' }, - { "boot-block", no_arg, 'B' }, - { "boot-bloc", no_arg, 'B' }, - { "boot-blo", no_arg, 'B' }, - { "boot-bl", no_arg, 'B' }, - { "boot-b", no_arg, 'B' }, - { "boot", no_arg, 'B' }, - { "boo", no_arg, 'B' }, - { "bo", no_arg, 'B' }, - { "header", no_arg, 'H' }, - { "heade", no_arg, 'H' }, - { "head", no_arg, 'H' }, - { "hea", no_arg, 'H' }, - { "object-ids", no_arg, 'i' }, - { "object-id", no_arg, 'i' }, - { "object-i", no_arg, 'i' }, - { "object", no_arg, 'i' }, - { "objec", no_arg, 'i' }, - { "obje", no_arg, 'i' }, - { "obj", no_arg, 'i' }, - { "ob", no_arg, 'i' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, - { "ver", no_arg, 'V' }, - { "ve", no_arg, 'V' }, - { "attribute", require_arg, 'a' }, - { "attribut", require_arg, 'a' }, - { "attribu", require_arg, 'a' }, - { "attrib", require_arg, 'a' }, - { "attri", require_arg, 'a' }, - { "attr", require_arg, 'a' }, - { "att", require_arg, 'a' }, - { "at", require_arg, 'a' }, - { "block", require_arg, 'k' }, - { "bloc", require_arg, 'k' }, - { "blo", require_arg, 'k' }, - { "bl", require_arg, 'k' }, - { "count", require_arg, 'c' }, - { "coun", require_arg, 'c' }, - { "cou", require_arg, 'c' }, - { "co", require_arg, 'c' }, - { "dataset", require_arg, 'd' }, - { "datase", require_arg, 'd' }, - { "datas", require_arg, 'd' }, - { "datatype", require_arg, 't' }, - { "datatyp", require_arg, 't' }, - { "dataty", require_arg, 't' }, - { "datat", require_arg, 't' }, - { "filedriver", require_arg, 'f' }, - { "filedrive", require_arg, 'f' }, - { "filedriv", require_arg, 'f' }, - { "filedri", require_arg, 'f' }, - { "filedr", require_arg, 'f' }, - { "filed", require_arg, 'f' }, - { "file", require_arg, 'f' }, - { "fil", require_arg, 'f' }, - { "fi", require_arg, 'f' }, - { "group", require_arg, 'g' }, - { "grou", require_arg, 'g' }, - { "gro", require_arg, 'g' }, - { "gr", require_arg, 'g' }, - { "output", optional_arg, 'o' }, - { "outpu", optional_arg, 'o' }, - { "outp", optional_arg, 'o' }, - { "out", optional_arg, 'o' }, - { "ou", optional_arg, 'o' }, - { "soft-link", require_arg, 'l' }, - { "soft-lin", require_arg, 'l' }, - { "soft-li", require_arg, 'l' }, - { "soft-l", require_arg, 'l' }, - { "soft", require_arg, 'l' }, - { "sof", require_arg, 'l' }, - { "start", require_arg, 's' }, - { "star", require_arg, 's' }, - { "sta", require_arg, 's' }, - { "stride", require_arg, 'S' }, - { "strid", require_arg, 'S' }, - { "string", no_arg, 'r' }, - { "strin", no_arg, 'r' }, - { "use-dtd", no_arg, 'u' }, - { "use-dt", no_arg, 'u' }, - { "use-d", no_arg, 'u' }, - { "use-", no_arg, 'u' }, - { "use", no_arg, 'u' }, - { "us", no_arg, 'u' }, - { "u", no_arg, 'u' }, - { "width", require_arg, 'w' }, - { "widt", require_arg, 'w' }, - { "wid", require_arg, 'w' }, - { "wi", require_arg, 'w' }, - { "xml-dtd", require_arg, 'D' }, - { "xml-dt", require_arg, 'D' }, - { "xml-d", require_arg, 'D' }, - { "xml-ns", require_arg, 'X' }, - { "xml-n", require_arg, 'X' }, - { "xml", no_arg, 'x' }, - { "xm", no_arg, 'x' }, - { "onlyattr", optional_arg, 'A' }, - { "escape", no_arg, 'e' }, - { "noindex", no_arg, 'y' }, - { "binary", optional_arg, 'b' }, - { "form", require_arg, 'F' }, - { "sort_by", require_arg, 'q' }, - { "sort_order", require_arg, 'z' }, - { "format", require_arg, 'm' }, - { "region", no_arg, 'R' }, - { "enable-error-stack", optional_arg, 'E' }, - { "packed-bits", require_arg, 'M' }, - { "no-compact-subset", no_arg, 'C' }, - { "ddl", optional_arg, 'O' }, - { "any_path", require_arg, 'N' }, - { "vds-view-first-missing", no_arg, 'v' }, - { "vds-gap-size", require_arg, 'G' }, - { "s3-cred", require_arg, '$' }, - { "hdfs-attrs", require_arg, '#' }, - { "vol-value", require_arg, '1' }, - { "vol-name", require_arg, '2' }, - { "vol-info", require_arg, '3' }, - { NULL, 0, '\0' } -}; - +static const char * s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RE*CM:O*N:vG:"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"hel", no_arg, 'h'}, + {"contents", optional_arg, 'n'}, + {"properties", no_arg, 'p'}, + {"superblock", no_arg, 'B'}, + {"boot-block", no_arg, 'B'}, + {"boot-bloc", no_arg, 'B'}, + {"boot-blo", no_arg, 'B'}, + {"boot-bl", no_arg, 'B'}, + {"boot-b", no_arg, 'B'}, + {"boot", no_arg, 'B'}, + {"boo", no_arg, 'B'}, + {"bo", no_arg, 'B'}, + {"header", no_arg, 'H'}, + {"heade", no_arg, 'H'}, + {"head", no_arg, 'H'}, + {"hea", no_arg, 'H'}, + {"object-ids", no_arg, 'i'}, + {"object-id", no_arg, 'i'}, + {"object-i", no_arg, 'i'}, + {"object", no_arg, 'i'}, + {"objec", no_arg, 'i'}, + {"obje", no_arg, 'i'}, + {"obj", no_arg, 'i'}, + {"ob", no_arg, 'i'}, + {"version", no_arg, 'V'}, + {"versio", no_arg, 'V'}, + {"versi", no_arg, 'V'}, + {"vers", no_arg, 'V'}, + {"ver", no_arg, 'V'}, + {"ve", no_arg, 'V'}, + {"attribute", require_arg, 'a'}, + {"attribut", require_arg, 'a'}, + {"attribu", require_arg, 'a'}, + {"attrib", require_arg, 'a'}, + {"attri", require_arg, 'a'}, + {"attr", require_arg, 'a'}, + {"att", require_arg, 'a'}, + {"at", require_arg, 'a'}, + {"block", require_arg, 'k'}, + {"bloc", require_arg, 'k'}, + {"blo", require_arg, 'k'}, + {"bl", require_arg, 'k'}, + {"count", require_arg, 'c'}, + {"coun", require_arg, 'c'}, + {"cou", require_arg, 'c'}, + {"co", require_arg, 'c'}, + {"dataset", require_arg, 'd'}, + {"datase", require_arg, 'd'}, + {"datas", require_arg, 'd'}, + {"datatype", require_arg, 't'}, + {"datatyp", require_arg, 't'}, + {"dataty", require_arg, 't'}, + {"datat", require_arg, 't'}, + {"filedriver", require_arg, 'f'}, + {"filedrive", require_arg, 'f'}, + {"filedriv", require_arg, 'f'}, + {"filedri", require_arg, 'f'}, + {"filedr", require_arg, 'f'}, + {"filed", require_arg, 'f'}, + {"file", require_arg, 'f'}, + {"fil", require_arg, 'f'}, + {"fi", require_arg, 'f'}, + {"group", require_arg, 'g'}, + {"grou", require_arg, 'g'}, + {"gro", require_arg, 'g'}, + {"gr", require_arg, 'g'}, + {"output", optional_arg, 'o'}, + {"outpu", optional_arg, 'o'}, + {"outp", optional_arg, 'o'}, + {"out", optional_arg, 'o'}, + {"ou", optional_arg, 'o'}, + {"soft-link", require_arg, 'l'}, + {"soft-lin", require_arg, 'l'}, + {"soft-li", require_arg, 'l'}, + {"soft-l", require_arg, 'l'}, + {"soft", require_arg, 'l'}, + {"sof", require_arg, 'l'}, + {"start", require_arg, 's'}, + {"star", require_arg, 's'}, + {"sta", require_arg, 's'}, + {"stride", require_arg, 'S'}, + {"strid", require_arg, 'S'}, + {"string", no_arg, 'r'}, + {"strin", no_arg, 'r'}, + {"use-dtd", no_arg, 'u'}, + {"use-dt", no_arg, 'u'}, + {"use-d", no_arg, 'u'}, + {"use-", no_arg, 'u'}, + {"use", no_arg, 'u'}, + {"us", no_arg, 'u'}, + {"u", no_arg, 'u'}, + {"width", require_arg, 'w'}, + {"widt", require_arg, 'w'}, + {"wid", require_arg, 'w'}, + {"wi", require_arg, 'w'}, + {"xml-dtd", require_arg, 'D'}, + {"xml-dt", require_arg, 'D'}, + {"xml-d", require_arg, 'D'}, + {"xml-ns", require_arg, 'X'}, + {"xml-n", require_arg, 'X'}, + {"xml", no_arg, 'x'}, + {"xm", no_arg, 'x'}, + {"onlyattr", optional_arg, 'A'}, + {"escape", no_arg, 'e'}, + {"noindex", no_arg, 'y'}, + {"binary", optional_arg, 'b'}, + {"form", require_arg, 'F'}, + {"sort_by", require_arg, 'q'}, + {"sort_order", require_arg, 'z'}, + {"format", require_arg, 'm'}, + {"region", no_arg, 'R'}, + {"enable-error-stack", optional_arg, 'E'}, + {"packed-bits", require_arg, 'M'}, + {"no-compact-subset", no_arg, 'C'}, + {"ddl", optional_arg, 'O'}, + {"any_path", require_arg, 'N'}, + {"vds-view-first-missing", no_arg, 'v'}, + {"vds-gap-size", require_arg, 'G'}, + {"s3-cred", require_arg, '$'}, + {"hdfs-attrs", require_arg, '#'}, + {"vol-value", require_arg, '1'}, + {"vol-name", require_arg, '2'}, + {"vol-info", require_arg, '3'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: leave @@ -239,7 +223,6 @@ leave(int ret) HDexit(ret); } - /*------------------------------------------------------------------------- * Function: usage * @@ -265,46 +248,68 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " -o F, --output=F Output raw data into file F\n"); PRINTVALSTREAM(rawoutstream, " -b B, --binary=B Binary file output, of form B\n"); PRINTVALSTREAM(rawoutstream, " -O F, --ddl=F Output ddl text into file F\n"); - PRINTVALSTREAM(rawoutstream, " Use blank(empty) filename F to suppress ddl display\n"); - PRINTVALSTREAM(rawoutstream, " --s3-cred= Supply S3 authentication information to \"ros3\" vfd.\n"); - PRINTVALSTREAM(rawoutstream, " :: \"(,,)\"\n"); - PRINTVALSTREAM(rawoutstream, " If absent or -> \"(,,)\", no authentication.\n"); + PRINTVALSTREAM(rawoutstream, + " Use blank(empty) filename F to suppress ddl display\n"); + PRINTVALSTREAM(rawoutstream, + " --s3-cred= Supply S3 authentication information to \"ros3\" vfd.\n"); + PRINTVALSTREAM(rawoutstream, + " :: \"(,,)\"\n"); + PRINTVALSTREAM(rawoutstream, + " If absent or -> \"(,,)\", no authentication.\n"); PRINTVALSTREAM(rawoutstream, " Has no effect is filedriver is not `ros3'.\n"); - PRINTVALSTREAM(rawoutstream, " --hdfs-attrs= Supply configuration information for HDFS file access.\n"); + PRINTVALSTREAM(rawoutstream, + " --hdfs-attrs= Supply configuration information for HDFS file access.\n"); PRINTVALSTREAM(rawoutstream, " For use with \"--filedriver=hdfs\"\n"); PRINTVALSTREAM(rawoutstream, " :: (,,\n"); PRINTVALSTREAM(rawoutstream, " ,,\n"); PRINTVALSTREAM(rawoutstream, " )\n"); - PRINTVALSTREAM(rawoutstream, " Any absent attribute will use a default value.\n"); - PRINTVALSTREAM(rawoutstream, " --vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, + " Any absent attribute will use a default value.\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-value Value (ID) of the VOL connector to use for opening the\n"); PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-name Name of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-name Name of the VOL connector to use for opening the\n"); PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, "--------------- Object Options ---------------\n"); PRINTVALSTREAM(rawoutstream, " -a P, --attribute=P Print the specified attribute\n"); - PRINTVALSTREAM(rawoutstream, " If an attribute name contains a slash (/), escape the\n"); + PRINTVALSTREAM(rawoutstream, + " If an attribute name contains a slash (/), escape the\n"); PRINTVALSTREAM(rawoutstream, " slash with a preceding backslash (\\).\n"); PRINTVALSTREAM(rawoutstream, " (See example section below.)\n"); PRINTVALSTREAM(rawoutstream, " -d P, --dataset=P Print the specified dataset\n"); PRINTVALSTREAM(rawoutstream, " -g P, --group=P Print the specified group and all members\n"); PRINTVALSTREAM(rawoutstream, " -l P, --soft-link=P Print the value(s) of the specified soft link\n"); PRINTVALSTREAM(rawoutstream, " -t P, --datatype=P Print the specified named datatype\n"); - PRINTVALSTREAM(rawoutstream, " -N P, --any_path=P Print any attribute, dataset, group, datatype, or link that matches P\n"); - PRINTVALSTREAM(rawoutstream, " P can be the absolute path or just a relative path.\n"); + PRINTVALSTREAM( + rawoutstream, + " -N P, --any_path=P Print any attribute, dataset, group, datatype, or link that matches P\n"); + PRINTVALSTREAM(rawoutstream, + " P can be the absolute path or just a relative path.\n"); PRINTVALSTREAM(rawoutstream, " -A, --onlyattr Print the header and value of attributes\n"); - PRINTVALSTREAM(rawoutstream, " Optional value 0 suppresses printing attributes.\n"); - PRINTVALSTREAM(rawoutstream, " --vds-view-first-missing Set the VDS bounds to first missing mapped elements.\n"); - PRINTVALSTREAM(rawoutstream, " --vds-gap-size=N Set the missing file gap size, N=non-negative integers\n"); + PRINTVALSTREAM(rawoutstream, + " Optional value 0 suppresses printing attributes.\n"); + PRINTVALSTREAM(rawoutstream, + " --vds-view-first-missing Set the VDS bounds to first missing mapped elements.\n"); + PRINTVALSTREAM(rawoutstream, + " --vds-gap-size=N Set the missing file gap size, N=non-negative integers\n"); PRINTVALSTREAM(rawoutstream, "--------------- Object Property Options ---------------\n"); PRINTVALSTREAM(rawoutstream, " -i, --object-ids Print the object ids\n"); - PRINTVALSTREAM(rawoutstream, " -p, --properties Print dataset filters, storage layout and fill value\n"); - PRINTVALSTREAM(rawoutstream, " -M L, --packedbits=L Print packed bits as unsigned integers, using mask\n"); - PRINTVALSTREAM(rawoutstream, " format L for an integer dataset specified with\n"); - PRINTVALSTREAM(rawoutstream, " option -d. L is a list of offset,length values,\n"); - PRINTVALSTREAM(rawoutstream, " separated by commas. Offset is the beginning bit in\n"); - PRINTVALSTREAM(rawoutstream, " the data value and length is the number of bits of\n"); + PRINTVALSTREAM(rawoutstream, + " -p, --properties Print dataset filters, storage layout and fill value\n"); + PRINTVALSTREAM(rawoutstream, + " -M L, --packedbits=L Print packed bits as unsigned integers, using mask\n"); + PRINTVALSTREAM(rawoutstream, + " format L for an integer dataset specified with\n"); + PRINTVALSTREAM(rawoutstream, + " option -d. L is a list of offset,length values,\n"); + PRINTVALSTREAM(rawoutstream, + " separated by commas. Offset is the beginning bit in\n"); + PRINTVALSTREAM(rawoutstream, + " the data value and length is the number of bits of\n"); PRINTVALSTREAM(rawoutstream, " the mask.\n"); PRINTVALSTREAM(rawoutstream, " -R, --region Print dataset pointed by region references\n"); PRINTVALSTREAM(rawoutstream, "--------------- Formatting Options ---------------\n"); @@ -314,12 +319,17 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " -m T, --format=T Set the floating point output format\n"); PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n"); PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they occur.\n"); - PRINTVALSTREAM(rawoutstream, " Optional value 2 also prints file open errors.\n"); - PRINTVALSTREAM(rawoutstream, " --no-compact-subset Disable compact form of subsetting and allow the use\n"); + PRINTVALSTREAM(rawoutstream, + " --enable-error-stack Prints messages from the HDF5 error stack as they occur.\n"); + PRINTVALSTREAM(rawoutstream, + " Optional value 2 also prints file open errors.\n"); + PRINTVALSTREAM(rawoutstream, + " --no-compact-subset Disable compact form of subsetting and allow the use\n"); PRINTVALSTREAM(rawoutstream, " of \"[\" in dataset names.\n"); - PRINTVALSTREAM(rawoutstream, " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n"); - PRINTVALSTREAM(rawoutstream, " sets the number of columns to the maximum (65535).\n"); + PRINTVALSTREAM(rawoutstream, + " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n"); + PRINTVALSTREAM(rawoutstream, + " sets the number of columns to the maximum (65535).\n"); PRINTVALSTREAM(rawoutstream, " Default width is 80 columns.\n"); PRINTVALSTREAM(rawoutstream, "--------------- XML Options ---------------\n"); PRINTVALSTREAM(rawoutstream, " -x, --xml Output in XML using Schema\n"); @@ -327,31 +337,44 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " -D U, --xml-dtd=U Use the DTD or schema at U\n"); PRINTVALSTREAM(rawoutstream, " -X S, --xml-ns=S (XML Schema) Use qualified names n the XML\n"); PRINTVALSTREAM(rawoutstream, " \":\": no namespace, default: \"hdf5:\"\n"); - PRINTVALSTREAM(rawoutstream, " E.g., to dump a file called `-f', use h5dump -- -f\n"); + PRINTVALSTREAM(rawoutstream, + " E.g., to dump a file called `-f', use h5dump -- -f\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "--------------- Subsetting Options ---------------\n"); PRINTVALSTREAM(rawoutstream, " Subsetting is available by using the following options with a dataset\n"); PRINTVALSTREAM(rawoutstream, " option. Subsetting is done by selecting a hyperslab from the data.\n"); PRINTVALSTREAM(rawoutstream, " Thus, the options mirror those for performing a hyperslab selection.\n"); - PRINTVALSTREAM(rawoutstream, " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n"); - PRINTVALSTREAM(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n"); - PRINTVALSTREAM(rawoutstream, " each dimension. START is optional and will default to 0 in each dimension.\n"); + PRINTVALSTREAM( + rawoutstream, + " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n"); + PRINTVALSTREAM(rawoutstream, + " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n"); + PRINTVALSTREAM(rawoutstream, + " each dimension. START is optional and will default to 0 in each dimension.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " -s START, --start=START Offset of start of subsetting selection\n"); + PRINTVALSTREAM(rawoutstream, + " -s START, --start=START Offset of start of subsetting selection\n"); PRINTVALSTREAM(rawoutstream, " -S STRIDE, --stride=STRIDE Hyperslab stride\n"); - PRINTVALSTREAM(rawoutstream, " -c COUNT, --count=COUNT Number of blocks to include in selection\n"); + PRINTVALSTREAM(rawoutstream, + " -c COUNT, --count=COUNT Number of blocks to include in selection\n"); PRINTVALSTREAM(rawoutstream, " -k BLOCK, --block=BLOCK Size of block in hyperslab\n"); - PRINTVALSTREAM(rawoutstream, " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n"); + PRINTVALSTREAM( + rawoutstream, + " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n"); PRINTVALSTREAM(rawoutstream, " number of dimensions in the dataspace being queried\n"); - PRINTVALSTREAM(rawoutstream, " (Alternate compact form of subsetting is described in the Reference Manual)\n"); + PRINTVALSTREAM(rawoutstream, + " (Alternate compact form of subsetting is described in the Reference Manual)\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "--------------- Option Argument Conventions ---------------\n"); PRINTVALSTREAM(rawoutstream, " D - is the file driver to use in opening the file. Acceptable values\n"); - PRINTVALSTREAM(rawoutstream, " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n"); + PRINTVALSTREAM( + rawoutstream, + " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n"); PRINTVALSTREAM(rawoutstream, " the file driver flag, the file will be opened with each driver in\n"); PRINTVALSTREAM(rawoutstream, " turn and in the order specified above until one driver succeeds\n"); PRINTVALSTREAM(rawoutstream, " in opening the file.\n"); - PRINTVALSTREAM(rawoutstream, " See examples below for family, split, and multi driver special file name usage.\n"); + PRINTVALSTREAM(rawoutstream, + " See examples below for family, split, and multi driver special file name usage.\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " F - is a filename.\n"); PRINTVALSTREAM(rawoutstream, " P - is the full path from the root group to the object.\n"); @@ -359,12 +382,17 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " T - is a string containing the floating point format, e.g '%%.3f'\n"); PRINTVALSTREAM(rawoutstream, " U - is a URI reference (as defined in [IETF RFC 2396],\n"); PRINTVALSTREAM(rawoutstream, " updated by [IETF RFC 2732])\n"); - PRINTVALSTREAM(rawoutstream, " B - is the form of binary output: NATIVE for a memory type, FILE for the\n"); - PRINTVALSTREAM(rawoutstream, " file type, LE or BE for pre-existing little or big endian types.\n"); + PRINTVALSTREAM(rawoutstream, + " B - is the form of binary output: NATIVE for a memory type, FILE for the\n"); + PRINTVALSTREAM(rawoutstream, + " file type, LE or BE for pre-existing little or big endian types.\n"); PRINTVALSTREAM(rawoutstream, " Must be used with -o (output file) and it is recommended that\n"); - PRINTVALSTREAM(rawoutstream, " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n"); - PRINTVALSTREAM(rawoutstream, " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n"); - PRINTVALSTREAM(rawoutstream, " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n"); + PRINTVALSTREAM(rawoutstream, + " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n"); + PRINTVALSTREAM(rawoutstream, + " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n"); + PRINTVALSTREAM(rawoutstream, + " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "--------------- Examples ---------------\n"); PRINTVALSTREAM(rawoutstream, "\n"); @@ -378,14 +406,16 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " 2) Selecting a subset from dataset /foo in file quux.h5\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n"); + PRINTVALSTREAM(rawoutstream, + " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " 3) Saving dataset 'dset' in file quux.h5 to binary file 'out.bin'\n"); PRINTVALSTREAM(rawoutstream, " using a little-endian type\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " h5dump -d /dset -b LE -o out.bin quux.h5\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 4) Display two packed bits (bits 0-1 and bits 4-6) in the dataset /dset\n"); + PRINTVALSTREAM(rawoutstream, + " 4) Display two packed bits (bits 0-1 and bits 4-6) in the dataset /dset\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " h5dump -d /dset -M 0,1,4,3 quux.h5\n"); PRINTVALSTREAM(rawoutstream, "\n"); @@ -397,17 +427,19 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f split splitfile\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 7) Dataset foo in multi files mf-s.h5, mf-b.h5, mf-r.h5, mf-g.h5, mf-l.h5 and mf-o.h5\n"); + PRINTVALSTREAM( + rawoutstream, + " 7) Dataset foo in multi files mf-s.h5, mf-b.h5, mf-r.h5, mf-g.h5, mf-l.h5 and mf-o.h5\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f multi mf\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 8) Dataset foo in family files fam00000.h5 fam00001.h5 and fam00002.h5\n"); + PRINTVALSTREAM(rawoutstream, + " 8) Dataset foo in family files fam00000.h5 fam00001.h5 and fam00002.h5\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f family fam%%05d.h5\n"); PRINTVALSTREAM(rawoutstream, "\n"); } - /*------------------------------------------------------------------------- * Function: table_list_add * @@ -419,28 +451,30 @@ usage(const char *prog) ssize_t table_list_add(hid_t oid, unsigned long file_no) { - size_t idx; /* Index of table to use */ + size_t idx; /* Index of table to use */ find_objs_t info; /* Allocate space if necessary */ - if(table_list.nused == table_list.nalloc) { - h5dump_table_items_t *tmp_ptr; + if (table_list.nused == table_list.nalloc) { + h5dump_table_items_t *tmp_ptr; table_list.nalloc = MAX(1, table_list.nalloc * 2); - if(NULL == (tmp_ptr = (h5dump_table_items_t *)HDrealloc(table_list.tables, table_list.nalloc * sizeof(table_list.tables[0])))) + if (NULL == (tmp_ptr = (h5dump_table_items_t *)HDrealloc( + table_list.tables, table_list.nalloc * sizeof(table_list.tables[0])))) return -1; table_list.tables = tmp_ptr; } /* end if */ /* Append it */ - idx = table_list.nused++; + idx = table_list.nused++; table_list.tables[idx].fileno = file_no; - table_list.tables[idx].oid = oid; - if(H5Iinc_ref(oid) < 0) { + table_list.tables[idx].oid = oid; + if (H5Iinc_ref(oid) < 0) { table_list.nused--; return -1; } - if(init_objs(oid, &info, &table_list.tables[idx].group_table, &table_list.tables[idx].dset_table, &table_list.tables[idx].type_table) < 0) { + if (init_objs(oid, &info, &table_list.tables[idx].group_table, &table_list.tables[idx].dset_table, + &table_list.tables[idx].type_table) < 0) { H5Idec_ref(oid); table_list.nused--; return -1; @@ -450,10 +484,9 @@ table_list_add(hid_t oid, unsigned long file_no) dump_tables(&info); #endif /* H5DUMP_DEBUG */ - return((ssize_t) idx); + return ((ssize_t)idx); } /* end table_list_add() */ - /*------------------------------------------------------------------------- * Function: table_list_visited * @@ -465,19 +498,18 @@ table_list_add(hid_t oid, unsigned long file_no) H5_ATTR_PURE ssize_t table_list_visited(unsigned long file_no) { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ /* Look for table */ - for(u = 0; u < table_list.nused; u++) + for (u = 0; u < table_list.nused; u++) /* Check for fileno value already in array */ - if(table_list.tables[u].fileno == file_no) - return((ssize_t) u); + if (table_list.tables[u].fileno == file_no) + return ((ssize_t)u); /* Didn't find table */ - return(-1); + return (-1); } /* end table_list_visited() */ - /*------------------------------------------------------------------------- * Function: table_list_free * @@ -489,12 +521,12 @@ table_list_visited(unsigned long file_no) static void table_list_free(void) { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ /* Iterate over tables */ - for(u = 0; u < table_list.nused; u++) { + for (u = 0; u < table_list.nused; u++) { /* Release object id */ - if(H5Idec_ref(table_list.tables[u].oid) < 0) + if (H5Idec_ref(table_list.tables[u].oid) < 0) h5tools_setstatus(EXIT_FAILURE); /* Free each table */ @@ -526,15 +558,15 @@ set_binary_form(const char *form) { int bform = -1; - if (HDstrcmp(form,"NATIVE") == 0 || HDstrcmp(form,"MEMORY") == 0) { + if (HDstrcmp(form, "NATIVE") == 0 || HDstrcmp(form, "MEMORY") == 0) { /* native form */ bform = 0; } - else if (HDstrcmp(form,"FILE") == 0) /* file type form */ + else if (HDstrcmp(form, "FILE") == 0) /* file type form */ bform = 1; - else if (HDstrcmp(form,"LE") == 0) /* convert to little endian */ + else if (HDstrcmp(form, "LE") == 0) /* convert to little endian */ bform = 2; - else if (HDstrcmp(form,"BE") == 0) /* convert to big endian */ + else if (HDstrcmp(form, "BE") == 0) /* convert to big endian */ bform = 3; return bform; @@ -555,9 +587,9 @@ set_sort_by(const char *form) { H5_index_t idx_type = H5_INDEX_UNKNOWN; - if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */ + if (HDstrcmp(form, "name") == 0) /* H5_INDEX_NAME */ idx_type = H5_INDEX_NAME; - else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */ + else if (HDstrcmp(form, "creation_order") == 0) /* H5_INDEX_CRT_ORDER */ idx_type = H5_INDEX_CRT_ORDER; return idx_type; @@ -578,9 +610,9 @@ set_sort_order(const char *form) { H5_iter_order_t iter_order = H5_ITER_UNKNOWN; - if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */ + if (HDstrcmp(form, "ascending") == 0) /* H5_ITER_INC */ iter_order = H5_ITER_INC; - else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */ + else if (HDstrcmp(form, "descending") == 0) /* H5_ITER_DEC */ iter_order = H5_ITER_DEC; return iter_order; @@ -604,11 +636,11 @@ set_sort_order(const char *form) static void parse_hsize_list(const char *h_list, subset_d *d) { - hsize_t *p_list; - const char *ptr; - unsigned int size_count = 0; - unsigned int i = 0; - unsigned int last_digit = 0; + hsize_t * p_list; + const char * ptr; + unsigned int size_count = 0; + unsigned int i = 0; + unsigned int last_digit = 0; if (!h_list || !*h_list || *h_list == ';') return; @@ -633,7 +665,7 @@ parse_hsize_list(const char *h_list, subset_d *d) p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t)); for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++) - if(HDisdigit(*ptr)) { + if (HDisdigit(*ptr)) { /* we should have an integer now */ p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0); @@ -642,7 +674,7 @@ parse_hsize_list(const char *h_list, subset_d *d) ptr++; } d->data = p_list; - d->len = size_count; + d->len = size_count; } /*------------------------------------------------------------------------- @@ -658,7 +690,7 @@ static struct subset_t * parse_subset_params(const char *dset) { struct subset_t *s = NULL; - char *brace; + char * brace; if (!dump_opts.disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) { *brace++ = '\0'; @@ -713,11 +745,11 @@ parse_mask_list(const char *h_list) int slength_value; unsigned length_value; unsigned long long temp_mask; - const char *ptr = NULL; + const char * ptr = NULL; /* sanity check */ - if(h_list) { - HDmemset(packed_mask,0,sizeof(packed_mask)); + if (h_list) { + HDmemset(packed_mask, 0, sizeof(packed_mask)); packed_bits_num = 0; /* scan in pair of offset,length separated by commas. */ @@ -729,10 +761,10 @@ parse_mask_list(const char *h_list) return FAIL; } soffset_value = HDatoi(ptr); - offset_value = (unsigned)soffset_value; + offset_value = (unsigned)soffset_value; if (soffset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) { - error_msg("Packed Bit offset value(%d) must be between 0 and %u\n", - soffset_value, (unsigned)(PACKED_BITS_SIZE_MAX - 1)); + error_msg("Packed Bit offset value(%d) must be between 0 and %u\n", soffset_value, + (unsigned)(PACKED_BITS_SIZE_MAX - 1)); return FAIL; } @@ -758,7 +790,7 @@ parse_mask_list(const char *h_list) length_value = (unsigned)slength_value; if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX) { error_msg("Packed Bit offset+length value(%u) too large. Max is %u\n", - offset_value+length_value, (unsigned)PACKED_BITS_SIZE_MAX); + offset_value + length_value, (unsigned)PACKED_BITS_SIZE_MAX); return FAIL; } @@ -778,8 +810,8 @@ parse_mask_list(const char *h_list) /* After packed_mask is calculated, packed_length is not needed but */ /* keep it for debug purpose. */ temp_mask = ~0ULL; - if(length_value < (int)(8 *sizeof(unsigned long long))) { - temp_mask = temp_mask << length_value; + if (length_value < (int)(8 * sizeof(unsigned long long))) { + temp_mask = temp_mask << length_value; packed_mask[packed_bits_num] = ~temp_mask; } else @@ -795,7 +827,7 @@ parse_mask_list(const char *h_list) } } } - if(packed_bits_num > PACKED_BITS_MAX) { + if (packed_bits_num > PACKED_BITS_MAX) { error_msg("Maximum number of packed bits exceeded\n"); return FAIL; } @@ -806,13 +838,12 @@ parse_mask_list(const char *h_list) } return SUCCEED; } - else { + else { error_msg("Bad mask list argument\n"); return FAIL; } } - /*------------------------------------------------------------------------- * Function: free_handler * @@ -828,25 +859,25 @@ free_handler(struct handler_t *hand, int len) { int i; - if(hand) { + if (hand) { for (i = 0; i < len; i++) { - if(hand[i].obj) { + if (hand[i].obj) { HDfree(hand[i].obj); - hand[i].obj=NULL; + hand[i].obj = NULL; } if (hand[i].subset_info) { - if(hand[i].subset_info->start.data) + if (hand[i].subset_info->start.data) HDfree(hand[i].subset_info->start.data); - if(hand[i].subset_info->stride.data) + if (hand[i].subset_info->stride.data) HDfree(hand[i].subset_info->stride.data); - if(hand[i].subset_info->count.data) + if (hand[i].subset_info->count.data) HDfree(hand[i].subset_info->count.data); - if(hand[i].subset_info->block.data) + if (hand[i].subset_info->block.data) HDfree(hand[i].subset_info->block.data); HDfree(hand[i].subset_info); - hand[i].subset_info=NULL; + hand[i].subset_info = NULL; } } @@ -854,7 +885,6 @@ free_handler(struct handler_t *hand, int len) } } - /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -869,11 +899,11 @@ free_handler(struct handler_t *hand, int len) static struct handler_t * parse_command_line(int argc, const char *argv[]) { - struct handler_t *hand = NULL; - struct handler_t *last_dset = NULL; - int i; - int opt; - int last_was_dset = FALSE; + struct handler_t *hand = NULL; + struct handler_t *last_dset = NULL; + int i; + int opt; + int last_was_dset = FALSE; /* no arguments */ if (argc == 1) { @@ -882,7 +912,7 @@ parse_command_line(int argc, const char *argv[]) } /* this will be plenty big enough to hold the info */ - if((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t))) == NULL) { + if ((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t))) == NULL) { goto error; } @@ -890,61 +920,60 @@ parse_command_line(int argc, const char *argv[]) while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { parse_start: switch ((char)opt) { - case 'R': - dump_opts.display_region = TRUE; - region_output = TRUE; - break; - case 'B': - dump_opts.display_bb = TRUE; - last_was_dset = FALSE; - break; - case 'n': - dump_opts.display_fi = TRUE; - last_was_dset = FALSE; - if (opt_arg != NULL) - h5trav_set_verbose(HDatoi(opt_arg)); - break; - case 'p': - dump_opts.display_dcpl = TRUE; - break; - case 'y': - dump_opts.display_ai = FALSE; - break; - case 'e': - dump_opts.display_escape = TRUE; - break; - case 'H': - dump_opts.display_data = FALSE; - dump_opts.display_attr_data = FALSE; - last_was_dset = FALSE; - break; - case 'A': - if (opt_arg != NULL) { - if(0 == HDatoi(opt_arg)) - dump_opts.include_attrs = FALSE; - } - else { - dump_opts.display_data = FALSE; - dump_opts.display_attr_data = TRUE; - last_was_dset = FALSE; - } - break; - case 'i': - dump_opts.display_oid = TRUE; - last_was_dset = FALSE; - break; - case 'r': - dump_opts.display_char = TRUE; - break; - case 'V': - print_version(h5tools_getprogname()); - free_handler(hand, argc); - hand = NULL; - h5tools_setstatus(EXIT_SUCCESS); - goto done; - break; - case 'w': - { + case 'R': + dump_opts.display_region = TRUE; + region_output = TRUE; + break; + case 'B': + dump_opts.display_bb = TRUE; + last_was_dset = FALSE; + break; + case 'n': + dump_opts.display_fi = TRUE; + last_was_dset = FALSE; + if (opt_arg != NULL) + h5trav_set_verbose(HDatoi(opt_arg)); + break; + case 'p': + dump_opts.display_dcpl = TRUE; + break; + case 'y': + dump_opts.display_ai = FALSE; + break; + case 'e': + dump_opts.display_escape = TRUE; + break; + case 'H': + dump_opts.display_data = FALSE; + dump_opts.display_attr_data = FALSE; + last_was_dset = FALSE; + break; + case 'A': + if (opt_arg != NULL) { + if (0 == HDatoi(opt_arg)) + dump_opts.include_attrs = FALSE; + } + else { + dump_opts.display_data = FALSE; + dump_opts.display_attr_data = TRUE; + last_was_dset = FALSE; + } + break; + case 'i': + dump_opts.display_oid = TRUE; + last_was_dset = FALSE; + break; + case 'r': + dump_opts.display_char = TRUE; + break; + case 'V': + print_version(h5tools_getprogname()); + free_handler(hand, argc); + hand = NULL; + h5tools_setstatus(EXIT_SUCCESS); + goto done; + break; + case 'w': { int sh5tools_nCols = HDatoi(opt_arg); if (sh5tools_nCols <= 0) @@ -952,372 +981,371 @@ parse_start: else h5tools_nCols = (unsigned)sh5tools_nCols; last_was_dset = FALSE; - } - break; - case 'N': - dump_opts.display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_paths; - hand[i].obj = HDstrdup(opt_arg); - break; - } - - last_was_dset = FALSE; - break; - case 'a': - dump_opts.display_all = 0; + } break; + case 'N': + dump_opts.display_all = 0; + + for (i = 0; i < argc; i++) + if (!hand[i].func) { + hand[i].func = handle_paths; + hand[i].obj = HDstrdup(opt_arg); + break; + } - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_attributes; - hand[i].obj = HDstrdup(opt_arg); - break; - } + last_was_dset = FALSE; + break; + case 'a': + dump_opts.display_all = 0; + + for (i = 0; i < argc; i++) + if (!hand[i].func) { + hand[i].func = handle_attributes; + hand[i].obj = HDstrdup(opt_arg); + break; + } - last_was_dset = FALSE; - break; - case 'd': - dump_opts.display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_datasets; - hand[i].obj = HDstrdup(opt_arg); - hand[i].subset_info = parse_subset_params(hand[i].obj); - last_dset = &hand[i]; - break; - } + last_was_dset = FALSE; + break; + case 'd': + dump_opts.display_all = 0; + + for (i = 0; i < argc; i++) + if (!hand[i].func) { + hand[i].func = handle_datasets; + hand[i].obj = HDstrdup(opt_arg); + hand[i].subset_info = parse_subset_params(hand[i].obj); + last_dset = &hand[i]; + break; + } - last_was_dset = TRUE; - break; - case 'f': - driver_name_g = opt_arg; - break; - case 'g': - dump_opts.display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_groups; - hand[i].obj = HDstrdup(opt_arg); - break; - } + last_was_dset = TRUE; + break; + case 'f': + driver_name_g = opt_arg; + break; + case 'g': + dump_opts.display_all = 0; + + for (i = 0; i < argc; i++) + if (!hand[i].func) { + hand[i].func = handle_groups; + hand[i].obj = HDstrdup(opt_arg); + break; + } - last_was_dset = FALSE; - break; - case 'l': - dump_opts.display_all = 0; + last_was_dset = FALSE; + break; + case 'l': + dump_opts.display_all = 0; + + for (i = 0; i < argc; i++) + if (!hand[i].func) { + hand[i].func = handle_links; + hand[i].obj = HDstrdup(opt_arg); + break; + } - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_links; - hand[i].obj = HDstrdup(opt_arg); - break; - } + last_was_dset = FALSE; + break; + case 't': + dump_opts.display_all = 0; + + for (i = 0; i < argc; i++) + if (!hand[i].func) { + hand[i].func = handle_datatypes; + hand[i].obj = HDstrdup(opt_arg); + break; + } - last_was_dset = FALSE; - break; - case 't': - dump_opts.display_all = 0; + last_was_dset = FALSE; + break; - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_datatypes; - hand[i].obj = HDstrdup(opt_arg); - break; + case 'O': + if (h5tools_set_output_file(opt_arg, 0) < 0) { + usage(h5tools_getprogname()); + goto error; } + break; - last_was_dset = FALSE; - break; + case 'o': + if (bin_output) { + if (h5tools_set_data_output_file(opt_arg, 1) < 0) { + usage(h5tools_getprogname()); + goto error; + } + } + else { + if (dump_opts.display_attr_data && !dump_opts.display_data) { + if (h5tools_set_attr_output_file(opt_arg, 0) < 0) { + usage(h5tools_getprogname()); + goto error; + } + } + if (dump_opts.display_data || dump_opts.display_all) { + if (h5tools_set_data_output_file(opt_arg, 0) < 0) { + usage(h5tools_getprogname()); + goto error; + } + } + } - case 'O': - if (h5tools_set_output_file(opt_arg, 0) < 0) { - usage(h5tools_getprogname()); - goto error; - } - break; + dump_opts.usingdasho = TRUE; + last_was_dset = FALSE; + outfname_g = opt_arg; + break; - case 'o': - if (bin_output) { - if (h5tools_set_data_output_file(opt_arg, 1) < 0) { - usage(h5tools_getprogname()); - goto error; - } - } - else { - if(dump_opts.display_attr_data && !dump_opts.display_data) { - if (h5tools_set_attr_output_file(opt_arg, 0) < 0) { + case 'b': + if (opt_arg != NULL) { + if ((bin_form = set_binary_form(opt_arg)) < 0) { + /* failed to set binary form */ usage(h5tools_getprogname()); goto error; } } - if(dump_opts.display_data || dump_opts.display_all) { - if (h5tools_set_data_output_file(opt_arg, 0) < 0) { + bin_output = TRUE; + if (outfname_g != NULL) { + if (h5tools_set_data_output_file(outfname_g, 1) < 0) { + /* failed to set output file */ usage(h5tools_getprogname()); goto error; } + + last_was_dset = FALSE; } - } + break; - dump_opts.usingdasho = TRUE; - last_was_dset = FALSE; - outfname_g = opt_arg; - break; + case 'q': + if ((sort_by = set_sort_by(opt_arg)) < 0) { + /* failed to set "sort by" form */ + usage(h5tools_getprogname()); + goto error; + } + break; - case 'b': - if (opt_arg != NULL) { - if ((bin_form = set_binary_form(opt_arg)) < 0) { - /* failed to set binary form */ + case 'z': + if ((sort_order = set_sort_order(opt_arg)) < 0) { + /* failed to set "sort order" form */ usage(h5tools_getprogname()); goto error; } - } - bin_output = TRUE; - if (outfname_g != NULL) { - if (h5tools_set_data_output_file(outfname_g, 1) < 0) { - /* failed to set output file */ + break; + + case 'M': + if (!last_was_dset) { + error_msg("option `-%c' can only be used after --dataset option\n", opt); + goto error; + } + if (parse_mask_list(opt_arg) != SUCCEED) { + usage(h5tools_getprogname()); + goto error; + } + dump_opts.display_packed_bits = TRUE; + break; + case 'v': + dump_opts.display_vds_first = TRUE; + break; + case 'G': + dump_opts.vds_gap_size = HDatoi(opt_arg); + if (dump_opts.vds_gap_size < 0) { usage(h5tools_getprogname()); goto error; } + break; - last_was_dset = FALSE; - } - break; + /** begin XML parameters **/ + case 'x': + /* select XML output */ + doxml_g = TRUE; + useschema_g = TRUE; + h5tools_dump_header_format = NULL; + dump_function_table = &xml_function_table; + h5tools_nCols = 0; + break; + case 'u': + doxml_g = TRUE; + useschema_g = FALSE; + xmlnsprefix = ""; + h5tools_dump_header_format = NULL; + dump_function_table = &xml_function_table; + h5tools_nCols = 0; + break; + case 'D': + /* specify alternative XML DTD or schema */ + /* To Do: check format of this value? */ + xml_dtd_uri_g = opt_arg; + h5tools_nCols = 0; + break; - case 'q': - if ((sort_by = set_sort_by(opt_arg)) < 0) { - /* failed to set "sort by" form */ - usage(h5tools_getprogname()); - goto error; - } - break; + case 'm': + /* specify alternative floating point printing format */ + fp_format = opt_arg; + h5tools_nCols = 0; + break; - case 'z': - if ((sort_order = set_sort_order(opt_arg)) < 0) { - /* failed to set "sort order" form */ - usage(h5tools_getprogname()); - goto error; - } - break; + case 'X': + /* specify XML namespace (default="hdf5:"), or none */ + /* To Do: check format of this value? */ + if (!useschema_g) { + usage(h5tools_getprogname()); + goto error; + } + if (HDstrcmp(opt_arg, ":") == 0) + xmlnsprefix = ""; + else + xmlnsprefix = opt_arg; + h5tools_nCols = 0; + break; + /** end XML parameters **/ - case 'M': - if (!last_was_dset) { - error_msg("option `-%c' can only be used after --dataset option\n", opt); - goto error; - } - if (parse_mask_list(opt_arg) != SUCCEED){ - usage(h5tools_getprogname()); - goto error; - } - dump_opts.display_packed_bits = TRUE; - break; - case 'v': - dump_opts.display_vds_first = TRUE; - break; - case 'G': - dump_opts.vds_gap_size = HDatoi(opt_arg); - if (dump_opts.vds_gap_size < 0) { - usage(h5tools_getprogname()); - goto error; - } - break; - - /** begin XML parameters **/ - case 'x': - /* select XML output */ - doxml_g = TRUE; - useschema_g = TRUE; - h5tools_dump_header_format = NULL; - dump_function_table = &xml_function_table; - h5tools_nCols = 0; - break; - case 'u': - doxml_g = TRUE; - useschema_g = FALSE; - xmlnsprefix = ""; - h5tools_dump_header_format = NULL; - dump_function_table = &xml_function_table; - h5tools_nCols = 0; - break; - case 'D': - /* specify alternative XML DTD or schema */ - /* To Do: check format of this value? */ - xml_dtd_uri_g = opt_arg; - h5tools_nCols = 0; - break; - - case 'm': - /* specify alternative floating point printing format */ - fp_format = opt_arg; - h5tools_nCols = 0; - break; - - case 'X': - /* specify XML namespace (default="hdf5:"), or none */ - /* To Do: check format of this value? */ - if (!useschema_g) { - usage(h5tools_getprogname()); - goto error; - } - if (HDstrcmp(opt_arg,":") == 0) - xmlnsprefix = ""; - else - xmlnsprefix = opt_arg; - h5tools_nCols = 0; - break; - /** end XML parameters **/ - - /** begin subsetting parameters **/ - case 's': - case 'S': - case 'c': - case 'k': { - struct subset_t *s; - - if (!last_was_dset) { - error_msg("option `-%c' can only be used after --dataset option\n", opt); - goto error; - } + /** begin subsetting parameters **/ + case 's': + case 'S': + case 'c': + case 'k': { + struct subset_t *s; + + if (!last_was_dset) { + error_msg("option `-%c' can only be used after --dataset option\n", opt); + goto error; + } + + if (last_dset->subset_info) { + /* + * This overrides the "terse" syntax if they actually mixed + * the two. + */ + s = last_dset->subset_info; + } + else { + last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t)); + } - if (last_dset->subset_info) { /* - * This overrides the "terse" syntax if they actually mixed - * the two. + * slightly convoluted, but...we are only interested in options + * for subsetting: "--start", "--stride", "--count", and "--block" + * which can come in any order. If we run out of parameters (EOF) + * or run into one which isn't a subsetting parameter (NOT s, S, + * c, or K), then we exit the do-while look, set the subset_info + * to the structure we've been filling. If we've reached the end + * of the options, we exit the parsing (goto parse_end) otherwise, + * since we've "read" the next option, we need to parse it. So we + * jump to the beginning of the switch statement (goto parse_start). */ - s = last_dset->subset_info; - } - else { - last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t)); - } - - /* - * slightly convoluted, but...we are only interested in options - * for subsetting: "--start", "--stride", "--count", and "--block" - * which can come in any order. If we run out of parameters (EOF) - * or run into one which isn't a subsetting parameter (NOT s, S, - * c, or K), then we exit the do-while look, set the subset_info - * to the structure we've been filling. If we've reached the end - * of the options, we exit the parsing (goto parse_end) otherwise, - * since we've "read" the next option, we need to parse it. So we - * jump to the beginning of the switch statement (goto parse_start). - */ - do { - switch ((char)opt) { - case 's': - if (s->start.data) { - HDfree(s->start.data); - s->start.data = NULL; - } - parse_hsize_list(opt_arg, &s->start); - break; - case 'S': - if (s->stride.data) { - HDfree(s->stride.data); - s->stride.data = NULL; - } - parse_hsize_list(opt_arg, &s->stride); - break; - case 'c': - if (s->count.data) { - HDfree(s->count.data); - s->count.data = NULL; - } - parse_hsize_list(opt_arg, &s->count); - break; - case 'k': - if (s->block.data) { - HDfree(s->block.data); - s->block.data = NULL; + do { + switch ((char)opt) { + case 's': + if (s->start.data) { + HDfree(s->start.data); + s->start.data = NULL; + } + parse_hsize_list(opt_arg, &s->start); + break; + case 'S': + if (s->stride.data) { + HDfree(s->stride.data); + s->stride.data = NULL; + } + parse_hsize_list(opt_arg, &s->stride); + break; + case 'c': + if (s->count.data) { + HDfree(s->count.data); + s->count.data = NULL; + } + parse_hsize_list(opt_arg, &s->count); + break; + case 'k': + if (s->block.data) { + HDfree(s->block.data); + s->block.data = NULL; + } + parse_hsize_list(opt_arg, &s->block); + break; + default: + goto end_collect; } - parse_hsize_list(opt_arg, &s->block); - break; - default: - goto end_collect; - } - } while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF); + } while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF); end_collect: - last_was_dset = FALSE; - - if (opt != EOF) - goto parse_start; - else - goto parse_end; - } - /** end subsetting parameters **/ + last_was_dset = FALSE; - case 'E': - if (opt_arg != NULL) - enable_error_stack = HDatoi(opt_arg); - else - enable_error_stack = 1; - break; - case 'C': - dump_opts.disable_compact_subset = TRUE; - break; - case 'h': - usage(h5tools_getprogname()); - free_handler(hand, argc); - hand = NULL; - h5tools_setstatus(EXIT_SUCCESS); - goto done; + if (opt != EOF) + goto parse_start; + else + goto parse_end; + } + /** end subsetting parameters **/ - case '$': -#ifdef H5_HAVE_ROS3_VFD - if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa_g) < 0) { - error_msg("failed to parse S3 VFD credential info\n"); + case 'E': + if (opt_arg != NULL) + enable_error_stack = HDatoi(opt_arg); + else + enable_error_stack = 1; + break; + case 'C': + dump_opts.disable_compact_subset = TRUE; + break; + case 'h': usage(h5tools_getprogname()); free_handler(hand, argc); hand = NULL; - h5tools_setstatus(EXIT_FAILURE); + h5tools_setstatus(EXIT_SUCCESS); goto done; - } + + case '$': +#ifdef H5_HAVE_ROS3_VFD + if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa_g) < 0) { + error_msg("failed to parse S3 VFD credential info\n"); + usage(h5tools_getprogname()); + free_handler(hand, argc); + hand = NULL; + h5tools_setstatus(EXIT_FAILURE); + goto done; + } #else - error_msg("Read-Only S3 VFD not enabled.\n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; + error_msg("Read-Only S3 VFD not enabled.\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; #endif - break; + break; - case '#': + case '#': #ifdef H5_HAVE_LIBHDFS - if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa_g) < 0) { - error_msg("failed to parse HDFS VFD configuration info\n"); - usage(h5tools_getprogname()); - free_handler(hand, argc); - hand = NULL; + if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa_g) < 0) { + error_msg("failed to parse HDFS VFD configuration info\n"); + usage(h5tools_getprogname()); + free_handler(hand, argc); + hand = NULL; + h5tools_setstatus(EXIT_FAILURE); + goto done; + } +#else + error_msg("HDFS VFD not enabled.\n"); h5tools_setstatus(EXIT_FAILURE); goto done; - } -#else - error_msg("HDFS VFD not enabled.\n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; #endif - break; - - case '1': - vol_info_g.type = VOL_BY_VALUE; - vol_info_g.u.value = (H5VL_class_value_t)HDatoi(opt_arg); - use_custom_vol_g = TRUE; - break; - - case '2': - vol_info_g.type = VOL_BY_NAME; - vol_info_g.u.name = opt_arg; - use_custom_vol_g = TRUE; - break; - - case '3': - vol_info_g.info_string = opt_arg; - break; - - case '?': - default: - usage(h5tools_getprogname()); - goto error; + break; + + case '1': + vol_info_g.type = VOL_BY_VALUE; + vol_info_g.u.value = (H5VL_class_value_t)HDatoi(opt_arg); + use_custom_vol_g = TRUE; + break; + + case '2': + vol_info_g.type = VOL_BY_NAME; + vol_info_g.u.name = opt_arg; + use_custom_vol_g = TRUE; + break; + + case '3': + vol_info_g.info_string = opt_arg; + break; + + case '?': + default: + usage(h5tools_getprogname()); + goto error; } } @@ -1341,7 +1369,6 @@ error: return hand; } - /*------------------------------------------------------------------------- * Function: main * @@ -1354,25 +1381,25 @@ error: int main(int argc, const char *argv[]) { - hid_t fid = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t fapl_id = H5P_DEFAULT; - H5O_info2_t oi; - struct handler_t *hand = NULL; - int i; - unsigned u; - char *fname = NULL; + hid_t fid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; + H5O_info2_t oi; + struct handler_t *hand = NULL; + int i; + unsigned u; + char * fname = NULL; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); h5tools_dump_header_format = &h5tools_standardformat; - dump_function_table = &ddl_function_table; - dump_indent = 0; + dump_function_table = &ddl_function_table; + dump_indent = 0; /* Initialize h5tools lib */ h5tools_init(); - if((hand = parse_command_line(argc, argv))==NULL) { + if ((hand = parse_command_line(argc, argv)) == NULL) { goto done; } @@ -1432,8 +1459,8 @@ main(int argc, const char *argv[]) if (driver_name_g != NULL) { h5tools_vfd_info_t vfd_info; - vfd_info.info = NULL; - vfd_info.name = driver_name_g; + vfd_info.info = NULL; + vfd_info.name = driver_name_g; if (!HDstrcmp(driver_name_g, drivernames[ROS3_VFD_IDX])) { #ifdef H5_HAVE_ROS3_VFD @@ -1469,11 +1496,10 @@ main(int argc, const char *argv[]) } } - while(opt_ind < argc) { + while (opt_ind < argc) { fname = HDstrdup(argv[opt_ind++]); - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, - (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); + fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); @@ -1487,7 +1513,7 @@ main(int argc, const char *argv[]) /* Prepare to find objects that might be targets of a reference */ fill_ref_path_table(fid); - if(doxml_g) { + if (doxml_g) { /* initialize XML */ /* reset prefix! */ HDstrcpy(prefix, ""); @@ -1499,12 +1525,13 @@ main(int argc, const char *argv[]) } else { xml_dtd_uri_g = DEFAULT_DTD; - xmlnsprefix = ""; + xmlnsprefix = ""; } } else { - if (useschema_g && HDstrcmp(xmlnsprefix,"")) { - error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); + if (useschema_g && HDstrcmp(xmlnsprefix, "")) { + error_msg( + "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); h5tools_setstatus(EXIT_FAILURE); goto done; } @@ -1512,21 +1539,21 @@ main(int argc, const char *argv[]) } /* Get object info for root group */ - if(H5Oget_info_by_name3(fid, "/", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { + if (H5Oget_info_by_name3(fid, "/", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; } /* Initialize object tables */ - if(table_list_add(fid, oi.fileno) < 0) { + if (table_list_add(fid, oi.fileno) < 0) { error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; } group_table = table_list.tables[0].group_table; - dset_table = table_list.tables[0].dset_table; - type_table = table_list.tables[0].type_table; + dset_table = table_list.tables[0].dset_table; + type_table = table_list.tables[0].type_table; /* does there exist unamed committed datatype */ for (u = 0; u < type_table->nobjs; u++) @@ -1537,35 +1564,42 @@ main(int argc, const char *argv[]) /* start to dump - display file header information */ if (!doxml_g) { - begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin); + begin_obj(h5tools_dump_header_format->filebegin, fname, + h5tools_dump_header_format->fileblockbegin); } else { PRINTVALSTREAM(rawoutstream, "\n"); /* alternative first element, depending on schema or DTD. */ if (useschema_g) { - if (HDstrcmp(xmlnsprefix,"") == 0) { - PRINTSTREAM(rawoutstream, "\n", xml_dtd_uri_g); + if (HDstrcmp(xmlnsprefix, "") == 0) { + PRINTSTREAM(rawoutstream, + "\n", + xml_dtd_uri_g); } else { /* TO DO: make -url option work in this case (may need new option) */ char *ns; char *indx; - ns = HDstrdup(xmlnsprefix); - indx = HDstrrchr(ns,(int)':'); + ns = HDstrdup(xmlnsprefix); + indx = HDstrrchr(ns, (int)':'); if (indx) *indx = '\0'; - PRINTSTREAM(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\" " - "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " - "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File " - "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns); + PRINTSTREAM(rawoutstream, + "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File " + "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n", + xmlnsprefix, ns); HDfree(ns); } } else { - PRINTSTREAM(rawoutstream, "\n", xml_dtd_uri_g); + PRINTSTREAM(rawoutstream, "\n", + xml_dtd_uri_g); PRINTVALSTREAM(rawoutstream, "\n"); } } @@ -1574,7 +1608,7 @@ main(int argc, const char *argv[]) if (dump_opts.display_fi) { PRINTVALSTREAM(rawoutstream, "\n"); dump_fcontents(fid); - end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend); + end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend); PRINTVALSTREAM(rawoutstream, "\n"); goto done; } @@ -1583,36 +1617,35 @@ main(int argc, const char *argv[]) dump_fcpl(fid); } - if(dump_opts.display_all) { - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { + if (dump_opts.display_all) { + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { error_msg("unable to open root group\n"); h5tools_setstatus(EXIT_FAILURE); } else { if (!doxml_g) dump_indent += COL; - dump_function_table->dump_group_function(gid, "/" ); + dump_function_table->dump_group_function(gid, "/"); if (!doxml_g) dump_indent -= COL; PRINTVALSTREAM(rawoutstream, "\n"); } - if(H5Gclose(gid) < 0) { + if (H5Gclose(gid) < 0) { error_msg("unable to close root group\n"); h5tools_setstatus(EXIT_FAILURE); } - } else { /* Note: this option is not supported for XML */ - if(doxml_g) { + if (doxml_g) { error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; } /* end if */ - for(i = 0; i < argc; i++) { - if(hand[i].func) { + for (i = 0; i < argc; i++) { + if (hand[i].func) { hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL); } } @@ -1629,21 +1662,21 @@ main(int argc, const char *argv[]) /* Free tables for objects */ table_list_free(); - if(fid >=0) + if (fid >= 0) if (H5Fclose(fid) < 0) h5tools_setstatus(EXIT_FAILURE); - if(prefix) { + if (prefix) { HDfree(prefix); prefix = NULL; } - if(fname) { + if (fname) { HDfree(fname); fname = NULL; } } /* end while */ - if(hand) + if (hand) free_handler(hand, argc); /* To Do: clean up XML table */ @@ -1659,20 +1692,20 @@ done: h5tools_setstatus(EXIT_FAILURE); } - if(fid >=0) + if (fid >= 0) if (H5Fclose(fid) < 0) h5tools_setstatus(EXIT_FAILURE); - if(prefix) { + if (prefix) { HDfree(prefix); prefix = NULL; } - if(fname) { + if (fname) { HDfree(fname); fname = NULL; } - if(hand) + if (hand) free_handler(hand, argc); /* To Do: clean up XML table */ @@ -1680,7 +1713,6 @@ done: leave(h5tools_getstatus()); } /* main */ - /*------------------------------------------------------------------------- * Function: init_prefix * @@ -1695,13 +1727,12 @@ done: static void init_prefix(char **prfx, size_t prfx_len) { - if(prfx_len > 0) + if (prfx_len > 0) *prfx = (char *)HDcalloc(prfx_len, 1); else error_msg("unable to allocate prefix buffer\n"); } - /*------------------------------------------------------------------------- * Function: add_prefix * @@ -1717,12 +1748,11 @@ add_prefix(char **prfx, size_t *prfx_len, const char *name) size_t new_len = HDstrlen(*prfx) + HDstrlen(name) + 2; /* Check if we need more space */ - if(*prfx_len <= new_len) { + if (*prfx_len <= new_len) { *prfx_len = new_len + 1; - *prfx = (char *)HDrealloc(*prfx, *prfx_len); + *prfx = (char *)HDrealloc(*prfx, *prfx_len); } /* Append object name to prefix */ HDstrcat(HDstrcat(*prfx, "/"), name); } /* end add_prefix */ - diff --git a/tools/src/h5dump/h5dump.h b/tools/src/h5dump/h5dump.h index 548af09..b4198ad 100644 --- a/tools/src/h5dump/h5dump.h +++ b/tools/src/h5dump/h5dump.h @@ -26,66 +26,67 @@ **/ /* the table of dump functions */ typedef struct dump_functions_t { - void (*dump_group_function) (hid_t, const char *); - void (*dump_named_datatype_function) (hid_t, const char *); - void (*dump_dataset_function) (hid_t, const char *, struct subset_t *); - void (*dump_dataspace_function) (hid_t); - void (*dump_datatype_function) (hid_t); - herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *); - void (*dump_data_function) (hid_t, int, struct subset_t *, int); + void (*dump_group_function)(hid_t, const char *); + void (*dump_named_datatype_function)(hid_t, const char *); + void (*dump_dataset_function)(hid_t, const char *, struct subset_t *); + void (*dump_dataspace_function)(hid_t); + void (*dump_datatype_function)(hid_t); + herr_t (*dump_attribute_function)(hid_t, const char *, const H5A_info_t *, void *); + void (*dump_data_function)(hid_t, int, struct subset_t *, int); } dump_functions; /* List of table structures. There is one table structure for each file */ typedef struct h5dump_table_items_t { - unsigned long fileno; /* File number that these tables refer to */ - hid_t oid; /* ID of an object in this file, held open so fileno is consistent */ - table_t *group_table; /* Table of groups */ - table_t *dset_table; /* Table of datasets */ - table_t *type_table; /* Table of datatypes */ + unsigned long fileno; /* File number that these tables refer to */ + hid_t oid; /* ID of an object in this file, held open so fileno is consistent */ + table_t * group_table; /* Table of groups */ + table_t * dset_table; /* Table of datasets */ + table_t * type_table; /* Table of datatypes */ } h5dump_table_items_t; typedef struct h5dump_table_list_t { - size_t nalloc; - size_t nused; - h5dump_table_items_t *tables; + size_t nalloc; + size_t nused; + h5dump_table_items_t *tables; } h5dump_table_list_t; -h5dump_table_list_t table_list = {0, 0, NULL}; -table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL; +h5dump_table_list_t table_list = {0, 0, NULL}; +table_t * group_table = NULL, *dset_table = NULL, *type_table = NULL; -unsigned dump_indent = 0; /* how far in to indent the line */ -int unamedtype = 0; /* shared datatype with no name */ -hbool_t hit_elink = FALSE; /* whether we have traversed an external link */ -size_t prefix_len = 1024; -char *prefix = NULL; -const char *fp_format = NULL; +unsigned dump_indent = 0; /* how far in to indent the line */ +int unamedtype = 0; /* shared datatype with no name */ +hbool_t hit_elink = FALSE; /* whether we have traversed an external link */ +size_t prefix_len = 1024; +char * prefix = NULL; +const char *fp_format = NULL; /* things to display or which are set via command line parameters */ typedef struct { - int display_all; - int display_oid; - int display_data; - int display_attr_data; - int display_char; /* print 1-byte numbers as ASCII */ - int usingdasho; - int display_bb; /* superblock */ - int display_dcpl; /* dcpl */ - int display_fi; /* file index */ - int display_ai; /* array index */ - int display_escape; /* escape non printable characters */ - int display_region; /* print region reference data */ - int disable_compact_subset; /* disable compact form of subset notation */ - int display_packed_bits; /* print 1-8 byte numbers as packed bits */ - int include_attrs; /* Display attributes */ - int display_vds_first; /* vds display to all by default */ - int vds_gap_size; /* vds skip missing files default is none */ + int display_all; + int display_oid; + int display_data; + int display_attr_data; + int display_char; /* print 1-byte numbers as ASCII */ + int usingdasho; + int display_bb; /* superblock */ + int display_dcpl; /* dcpl */ + int display_fi; /* file index */ + int display_ai; /* array index */ + int display_escape; /* escape non printable characters */ + int display_region; /* print region reference data */ + int disable_compact_subset; /* disable compact form of subset notation */ + int display_packed_bits; /* print 1-8 byte numbers as packed bits */ + int include_attrs; /* Display attributes */ + int display_vds_first; /* vds display to all by default */ + int vds_gap_size; /* vds skip missing files default is none */ } dump_opt_t; -dump_opt_t dump_opts = {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0}; +dump_opt_t dump_opts = {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, + TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0}; -#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ -#define PACKED_BITS_SIZE_MAX (8*sizeof(long long)) /* Maximum bits size of integer types of packed-bits */ +#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ +#define PACKED_BITS_SIZE_MAX (8 * sizeof(long long)) /* Maximum bits size of integer types of packed-bits */ /* mask list for packed bits */ -unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */ +unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */ /* packed bits display parameters */ unsigned packed_offset[PACKED_BITS_MAX]; @@ -98,16 +99,17 @@ unsigned packed_length[PACKED_BITS_MAX]; const dump_functions *dump_function_table; #ifdef __cplusplus -"C" { +"C" +{ #endif -void add_prefix(char **prfx, size_t *prfx_len, const char *name); -hid_t h5_fileaccess(void); -ssize_t table_list_add(hid_t oid, unsigned long file_no); -ssize_t table_list_visited(unsigned long file_no); + void add_prefix(char **prfx, size_t *prfx_len, const char *name); + hid_t h5_fileaccess(void); + ssize_t table_list_add(hid_t oid, unsigned long file_no); + ssize_t table_list_visited(unsigned long file_no); #ifdef __cplusplus } #endif -#endif /* !H5DUMP_H__ */ +#endif /* !H5DUMP_H__ */ diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index b50ce52..94dc1fd 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -21,18 +21,18 @@ #include "h5dump_ddl.h" typedef struct { - hid_t fid; /* File ID being traversed */ - const char *op_name; /* Object name wanted */ + hid_t fid; /* File ID being traversed */ + const char *op_name; /* Object name wanted */ } trav_handle_udata_t; typedef struct { - const char *path; /* Path of object being searched */ - const char *op_name; /* Object name wanted */ + const char *path; /* Path of object being searched */ + const char *op_name; /* Object name wanted */ } trav_attr_udata_t; /* callback function used by H5Literate() */ -static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void *op_data); -static int dump_extlink(hid_t group, const char *linkname, const char *objname); +static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void *op_data); +static int dump_extlink(hid_t group, const char *linkname, const char *objname); /*------------------------------------------------------------------------- * Function: dump_datatype @@ -46,12 +46,12 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objn void dump_datatype(hid_t type) { - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; h5dump_type_table = type_table; h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type); @@ -70,17 +70,16 @@ dump_datatype(hid_t type) void dump_dataspace(hid_t space) { - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space); } - /*------------------------------------------------------------------------- * Function: dump_attr_cb * @@ -91,48 +90,49 @@ dump_dataspace(hid_t space) *------------------------------------------------------------------------- */ herr_t -dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) +dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *info, + void H5_ATTR_UNUSED *_op_data) { - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; h5tool_format_t string_dataformat; - hid_t attr_id; - herr_t ret = SUCCEED; + hid_t attr_id; + herr_t ret = SUCCEED; HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.indent_level = dump_indent / COL; + ctx.cur_column = dump_indent; ctx.display_index = dump_opts.display_ai; - ctx.display_char = dump_opts.display_char; + ctx.display_char = dump_opts.display_char; - attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); - oid_output = dump_opts.display_oid; - data_output = dump_opts.display_data; + attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); + oid_output = dump_opts.display_oid; + data_output = dump_opts.display_data; attr_data_output = dump_opts.display_attr_data; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; h5dump_type_table = type_table; h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id); h5dump_type_table = NULL; - if(attr_id < 0) { + if (attr_id < 0) { h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } @@ -140,7 +140,6 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED * return ret; } - /*------------------------------------------------------------------------- * Function: dump_all_cb * @@ -154,43 +153,43 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED * static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATTR_UNUSED *op_data) { - hid_t obj; - hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */ - herr_t ret = SUCCEED; - char *obj_path = NULL; /* Full path of object */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + hid_t obj; + hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */ + herr_t ret = SUCCEED; + char * obj_path = NULL; /* Full path of object */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; /* Build the object's path name */ obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - if(!obj_path) { + if (!obj_path) { ret = FAIL; goto done; } @@ -199,355 +198,369 @@ dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATT HDstrcat(obj_path, "/"); HDstrcat(obj_path, name); - if(linfo->type == H5L_TYPE_HARD) { - H5O_info2_t oinfo; + if (linfo->type == H5L_TYPE_HARD) { + H5O_info2_t oinfo; /* Stat the object */ - if(H5Oget_info_by_name3(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { + if (H5Oget_info_by_name3(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { error_msg("unable to get object information for \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; goto done; } /* end if */ - switch(oinfo.type) { - case H5O_TYPE_GROUP: - if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { - error_msg("unable to dump group \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - char *old_prefix; /* Pointer to previous prefix */ + switch (oinfo.type) { + case H5O_TYPE_GROUP: + if ((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { + error_msg("unable to dump group \"%s\"\n", name); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + else { + char *old_prefix; /* Pointer to previous prefix */ - /* Keep copy of prefix before iterating into group */ - old_prefix = HDstrdup(prefix); - if (old_prefix) { - /* Append group name to prefix */ - add_prefix(&prefix, &prefix_len, name); + /* Keep copy of prefix before iterating into group */ + old_prefix = HDstrdup(prefix); + if (old_prefix) { + /* Append group name to prefix */ + add_prefix(&prefix, &prefix_len, name); - /* Iterate into group */ - dump_function_table->dump_group_function(obj, name); + /* Iterate into group */ + dump_function_table->dump_group_function(obj, name); - /* Restore old prefix name */ - HDstrcpy(prefix, old_prefix); - HDfree(old_prefix); - } - else - error_msg("warning: null prefix\n"); + /* Restore old prefix name */ + HDstrcpy(prefix, old_prefix); + HDfree(old_prefix); + } + else + error_msg("warning: null prefix\n"); - /* Close group */ - H5Gclose(obj); - } - break; + /* Close group */ + H5Gclose(obj); + } + break; - case H5O_TYPE_DATASET: - if(dump_opts.display_data) { - if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { - error_msg("error in creating default access property list ID\n"); + case H5O_TYPE_DATASET: + if (dump_opts.display_data) { + if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { + error_msg("error in creating default access property list ID\n"); + } + if (dump_opts.display_vds_first) { + if (H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0) + error_msg("error in setting access property list ID, virtual_view\n"); + } + if (dump_opts.vds_gap_size > 0) { + if (H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0) + error_msg("error in setting access property list ID, virtual_printf_gap\n"); + } } - if (dump_opts.display_vds_first) { - if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0) - error_msg("error in setting access property list ID, virtual_view\n"); + if ((obj = H5Dopen2(group, name, dapl_id)) >= 0) { + if (oinfo.rc > 1 || hit_elink) { + obj_t *found_obj; /* Found object */ + + found_obj = search_obj(dset_table, &oinfo.token); + + if (found_obj == NULL) { + ctx.indent_level++; + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s \"%s\" %s", + h5tools_dump_header_format->datasetbegin, name, + h5tools_dump_header_format->datasetblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + if (HDstrlen(h5tools_dump_header_format->datasetblockend)) { + h5tools_str_append(&buffer, "%s", + h5tools_dump_header_format->datasetblockend); + if (HDstrlen(h5tools_dump_header_format->datasetend)) + h5tools_str_append(&buffer, " "); + } + if (HDstrlen(h5tools_dump_header_format->datasetend)) + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + ctx.indent_level--; + + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + if (dapl_id != H5P_DEFAULT) + H5Pclose(dapl_id); + H5Dclose(obj); + goto done; + } + else if (found_obj->displayed) { + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s \"%s\" %s", + h5tools_dump_header_format->datasetbegin, name, + h5tools_dump_header_format->datasetblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + ctx.indent_level++; + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + ctx.indent_level--; + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + if (HDstrlen(h5tools_dump_header_format->datasetblockend)) { + h5tools_str_append(&buffer, "%s", + h5tools_dump_header_format->datasetblockend); + if (HDstrlen(h5tools_dump_header_format->datasetend)) + h5tools_str_append(&buffer, " "); + } + if (HDstrlen(h5tools_dump_header_format->datasetend)) + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + if (dapl_id != H5P_DEFAULT) + H5Pclose(dapl_id); + H5Dclose(obj); + goto done; + } + else { + found_obj->displayed = TRUE; + } + } /* end if */ + + dump_function_table->dump_dataset_function(obj, name, NULL); + if (dapl_id != H5P_DEFAULT) + H5Pclose(dapl_id); + H5Dclose(obj); } - if (dump_opts.vds_gap_size > 0) { - if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0) - error_msg("error in setting access property list ID, virtual_printf_gap\n"); + else { + if (dapl_id != H5P_DEFAULT) + H5Pclose(dapl_id); + error_msg("unable to dump dataset \"%s\"\n", name); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; } - } - if((obj = H5Dopen2(group, name, dapl_id)) >= 0) { - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ - - found_obj = search_obj(dset_table, &oinfo.token); - - if(found_obj == NULL) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; + break; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datasetbegin, name, - h5tools_dump_header_format->datasetblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + case H5O_TYPE_NAMED_DATATYPE: + if ((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) { + error_msg("unable to dump datatype \"%s\"\n", name); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + else { + dump_function_table->dump_named_datatype_function(obj, name); + H5Tclose(obj); + } + break; - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); + case H5O_TYPE_MAP: + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + error_msg("unknown object \"%s\"\n", name); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + } /* end if */ + else { + char *targbuf; - ctx.need_prefix = TRUE; + switch (linfo->type) { + case H5L_TYPE_SOFT: + if ((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { + error_msg("unable to allocate buffer\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + else { + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datasetblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend); - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->softlinkbegin, + name, h5tools_dump_header_format->softlinkblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; + ctx.indent_level++; + if (H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { + error_msg("unable to get link value\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - H5Dclose(obj); - goto done; } - else if(found_obj->displayed) { - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datasetbegin, name, - h5tools_dump_header_format->datasetblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - + else { + /* print the value of a soft link */ + /* Standard DDL: no modification */ ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datasetblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend); - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - H5Dclose(obj); - goto done; - } - else { - found_obj->displayed = TRUE; + h5tools_str_append(&buffer, "LINKTARGET \"%s\"", targbuf); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } - } /* end if */ - dump_function_table->dump_dataset_function(obj, name, NULL); - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - H5Dclose(obj); - } - else { - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - error_msg("unable to dump dataset \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - break; + ctx.indent_level--; - case H5O_TYPE_NAMED_DATATYPE: - if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) { - error_msg("unable to dump datatype \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - dump_function_table->dump_named_datatype_function(obj, name); - H5Tclose(obj); - } - break; - - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - error_msg("unknown object \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - } /* end if */ - else { - char *targbuf; - - switch(linfo->type) { - case H5L_TYPE_SOFT: - if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { - error_msg("unable to allocate buffer\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->softlinkbegin, name, - h5tools_dump_header_format->softlinkblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + if (HDstrlen(h5tools_dump_header_format->softlinkblockend)) { + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkblockend); + if (HDstrlen(h5tools_dump_header_format->softlinkend)) + h5tools_str_append(&buffer, " "); + } + if (HDstrlen(h5tools_dump_header_format->softlinkend)) + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkend); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; + HDfree(targbuf); + } + break; - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get link value\n"); + case H5L_TYPE_EXTERNAL: + if ((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { + error_msg("unable to allocate buffer\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { - /* print the value of a soft link */ - /* Standard DDL: no modification */ ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "LINKTARGET \"%s\"", targbuf); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } + h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->extlinkbegin, + name, h5tools_dump_header_format->extlinkblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; + if (H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { + indentation(dump_indent); + error_msg("unable to get external link value\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } /* end if */ + else { + const char *filename; + const char *targname; + + if (H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { + indentation(dump_indent); + error_msg("unable to unpack external link value\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } /* end if */ + else { + ctx.indent_level++; + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "TARGETFILE \"%s\"", filename); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "TARGETPATH \"%s\"", targname); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + /* dump the external link */ + dump_extlink(group, name, targname); + ctx.indent_level--; + } /* end else */ + } /* end else */ + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + if (HDstrlen(h5tools_dump_header_format->extlinkblockend)) { + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkblockend); + if (HDstrlen(h5tools_dump_header_format->extlinkend)) + h5tools_str_append(&buffer, " "); + } + if (HDstrlen(h5tools_dump_header_format->extlinkend)) + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkend); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->softlinkblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkblockend); - if(HDstrlen(h5tools_dump_header_format->softlinkend)) - h5tools_str_append(&buffer, " "); + HDfree(targbuf); } - if(HDstrlen(h5tools_dump_header_format->softlinkend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(targbuf); - } - break; + break; - case H5L_TYPE_EXTERNAL: - if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { - error_msg("unable to allocate buffer\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: + case H5L_TYPE_HARD: + default: ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->extlinkbegin, name, - h5tools_dump_header_format->extlinkblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - indentation(dump_indent); - error_msg("unable to get external link value\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } /* end if */ - else { - const char *filename; - const char *targname; + h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->udlinkbegin, name, + h5tools_dump_header_format->udlinkblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { - indentation(dump_indent); - error_msg("unable to unpack external link value\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } /* end if */ - else { - ctx.indent_level++; - - ctx.need_prefix = TRUE; + ctx.indent_level++; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "TARGETFILE \"%s\"", filename); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "LINKCLASS %d", linfo->type); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.indent_level--; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "TARGETPATH \"%s\"", targname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - /* dump the external link */ - dump_extlink(group, name, targname); - ctx.indent_level--; - } /* end else */ - } /* end else */ ctx.need_prefix = TRUE; - /* Render the element */ h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->extlinkblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkblockend); - if(HDstrlen(h5tools_dump_header_format->extlinkend)) + if (HDstrlen(h5tools_dump_header_format->udlinkblockend)) { + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkblockend); + if (HDstrlen(h5tools_dump_header_format->udlinkend)) h5tools_str_append(&buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->extlinkend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(targbuf); - } - break; - - case H5L_TYPE_ERROR: - case H5L_TYPE_MAX: - case H5L_TYPE_HARD: - default: - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->udlinkbegin, name, - h5tools_dump_header_format->udlinkblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "LINKCLASS %d", linfo->type); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->udlinkblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkblockend); - if(HDstrlen(h5tools_dump_header_format->udlinkend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->udlinkend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + if (HDstrlen(h5tools_dump_header_format->udlinkend)) + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkend); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; + break; } /* end switch */ - } /* end else */ + } /* end else */ done: h5tools_str_close(&buffer); - if(obj_path) + if (obj_path) HDfree(obj_path); return ret; } @@ -565,19 +578,19 @@ attr_iteration(hid_t gid, unsigned attr_crt_order_flags) { /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group for attributes, then, sort by creation order, otherwise by name */ - if(dump_opts.include_attrs) { - if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { + if (dump_opts.include_attrs) { + if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { + if (H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - } /* end if */ + } /* end if */ else { - if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) { + if (H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - } /* end else */ + } /* end else */ } } @@ -595,7 +608,7 @@ link_iteration(hid_t gid, unsigned crt_order_flags) /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group, then, sort by creation order, otherwise by name */ - if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) + if ((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) H5Literate2(gid, sort_by, sort_order, NULL, dump_all_cb, NULL); else H5Literate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL); @@ -614,11 +627,11 @@ dump_named_datatype(hid_t tid, const char *name) { H5O_info2_t oinfo; unsigned attr_crt_order_flags; - hid_t tcpl_id = H5I_INVALID_HID; /* datatype creation property list ID */ - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + hid_t tcpl_id = H5I_INVALID_HID; /* datatype creation property list ID */ + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; h5tool_format_t string_dataformat; /* setup */ @@ -626,24 +639,24 @@ dump_named_datatype(hid_t tid, const char *name) HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; if ((tcpl_id = H5Tget_create_plist(tid)) < 0) { error_msg("error in getting creation property list ID\n"); @@ -656,7 +669,7 @@ dump_named_datatype(hid_t tid, const char *name) h5tools_setstatus(EXIT_FAILURE); } - if(H5Pclose(tcpl_id) < 0) { + if (H5Pclose(tcpl_id) < 0) { error_msg("error in closing creation property list ID\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -665,18 +678,18 @@ dump_named_datatype(hid_t tid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datatypebegin, name, - h5tools_dump_header_format->datatypeblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->datatypebegin, name, + h5tools_dump_header_format->datatypeblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC); /* Must check for uniqueness of all objects if we've traversed an elink, * otherwise only check if the reference count > 1. */ - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ + if (oinfo.rc > 1 || hit_elink) { + obj_t *found_obj; /* Found object */ found_obj = search_obj(type_table, &oinfo.token); @@ -689,7 +702,8 @@ dump_named_datatype(hid_t tid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); goto done; } else @@ -700,11 +714,12 @@ dump_named_datatype(hid_t tid, const char *name) h5tools_str_reset(&buffer); h5tools_print_datatype(rawoutstream, &buffer, outputformat, &ctx, tid, FALSE); - if(H5Tget_class(tid) != H5T_COMPOUND) { + if (H5Tget_class(tid) != H5T_COMPOUND) { h5tools_str_append(&buffer, ";"); } - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); /* print attributes */ dump_indent += COL; @@ -716,14 +731,15 @@ dump_named_datatype(hid_t tid, const char *name) done: /* Render the element */ h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datatypeblockend)) { + if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeblockend); - if(HDstrlen(h5tools_dump_header_format->datatypeend)) + if (HDstrlen(h5tools_dump_header_format->datatypeend)) h5tools_str_append(&buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->datatypeend)) + if (HDstrlen(h5tools_dump_header_format->datatypeend)) h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); } @@ -739,18 +755,18 @@ done: void dump_group(hid_t gid, const char *name) { - H5O_info2_t oinfo; - hid_t dset; - hid_t type; - hid_t gcpl_id; - unsigned crt_order_flags; - unsigned attr_crt_order_flags; - char type_name[1024]; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + H5O_info2_t oinfo; + hid_t dset; + hid_t type; + hid_t gcpl_id; + unsigned crt_order_flags; + unsigned attr_crt_order_flags; + char type_name[1024]; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { error_msg("error in getting group creation property list ID\n"); @@ -764,12 +780,12 @@ dump_group(hid_t gid, const char *name) } /* query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { + if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { error_msg("error in getting group creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } - if(H5Pclose(gcpl_id) < 0) { + if (H5Pclose(gcpl_id) < 0) { error_msg("error in closing group creation property list ID\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -779,43 +795,43 @@ dump_group(hid_t gid, const char *name) HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->groupbegin, name, - h5tools_dump_header_format->groupblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->groupbegin, name, + h5tools_dump_header_format->groupblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; - if(!HDstrcmp(name, "/") && unamedtype) { - unsigned u; /* Local index variable */ + if (!HDstrcmp(name, "/") && unamedtype) { + unsigned u; /* Local index variable */ /* dump unamed type in root group */ - for(u = 0; u < type_table->nobjs; u++) - if(!type_table->objs[u].recorded) { + for (u = 0; u < type_table->nobjs; u++) + if (!type_table->objs[u].recorded) { char *obj_tok_str = NULL; dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); @@ -831,7 +847,7 @@ dump_group(hid_t gid, const char *name) } } /* end if */ - if(dump_opts.display_oid) + if (dump_opts.display_oid) h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid); h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid); @@ -841,8 +857,8 @@ dump_group(hid_t gid, const char *name) /* Must check for uniqueness of all objects if we've traversed an elink, * otherwise only check if the reference count > 1. */ - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ + if (oinfo.rc > 1 || hit_elink) { + obj_t *found_obj; /* Found object */ found_obj = search_obj(group_table, &oinfo.token); @@ -856,7 +872,8 @@ dump_group(hid_t gid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { found_obj->displayed = TRUE; @@ -876,14 +893,15 @@ dump_group(hid_t gid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->groupblockend)) { + if (HDstrlen(h5tools_dump_header_format->groupblockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->groupblockend); - if(HDstrlen(h5tools_dump_header_format->groupend)) + if (HDstrlen(h5tools_dump_header_format->groupend)) h5tools_str_append(&buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->groupend)) + if (HDstrlen(h5tools_dump_header_format->groupend)) h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->groupend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); } @@ -899,35 +917,35 @@ dump_group(hid_t gid, const char *name) void dump_dataset(hid_t did, const char *name, struct subset_t *sset) { - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; h5tool_format_t string_dataformat; - hid_t type, space; - unsigned attr_crt_order_flags; - hid_t dcpl_id; /* dataset creation property list ID */ - h5tools_str_t buffer; /* string into which to render */ - hsize_t curr_pos = 0; /* total data element position */ + hid_t type, space; + unsigned attr_crt_order_flags; + hid_t dcpl_id; /* dataset creation property list ID */ + h5tools_str_t buffer; /* string into which to render */ + hsize_t curr_pos = 0; /* total data element position */ HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; if ((dcpl_id = H5Dget_create_plist(did)) < 0) { error_msg("error in getting creation property list ID\n"); @@ -946,19 +964,19 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ + /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datasetbegin, name, - h5tools_dump_header_format->datasetblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->datasetbegin, name, + h5tools_dump_header_format->datasetblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_dump_comment(rawoutstream, outputformat, &ctx, did); dump_indent += COL; ctx.indent_level++; - type = H5Dget_type(did); + type = H5Dget_type(did); h5dump_type_table = type_table; h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type); h5dump_type_table = NULL; @@ -967,74 +985,74 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space); H5Sclose(space); - if(dump_opts.display_oid) { + if (dump_opts.display_oid) { h5tools_dump_oid(rawoutstream, outputformat, &ctx, did); } - if(dump_opts.display_dcpl) { + if (dump_opts.display_dcpl) { h5dump_type_table = type_table; h5tools_dump_dcpl(rawoutstream, outputformat, &ctx, dcpl_id, type, did); h5dump_type_table = NULL; } H5Pclose(dcpl_id); - ctx.sset = sset; + ctx.sset = sset; ctx.display_index = dump_opts.display_ai; - ctx.display_char = dump_opts.display_char; - if(dump_opts.display_data) { - unsigned data_loop = 1; - unsigned u; + ctx.display_char = dump_opts.display_char; + if (dump_opts.display_data) { + unsigned data_loop = 1; + unsigned u; - if(dump_opts.display_packed_bits) + if (dump_opts.display_packed_bits) data_loop = packed_bits_num; - for(u = 0; u < data_loop; u++) { - if(dump_opts.display_packed_bits) { + for (u = 0; u < data_loop; u++) { + if (dump_opts.display_packed_bits) { ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); /* Render the element */ h5tools_str_reset(&buffer); - packed_data_mask = packed_mask[u]; + packed_data_mask = packed_mask[u]; packed_data_offset = packed_offset[u]; packed_data_length = packed_length[u]; h5tools_print_packed_bits(&buffer, type); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } - switch(H5Tget_class(type)) { - case H5T_TIME: - ctx.indent_level++; + switch (H5Tget_class(type)) { + case H5T_TIME: + ctx.indent_level++; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "DATA{ not yet implemented.}"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "DATA{ not yet implemented.}"); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - break; + ctx.indent_level--; + break; - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_COMPOUND: - case H5T_REFERENCE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_ARRAY: - { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: { h5tools_dump_data(rawoutstream, outputformat, &ctx, did, TRUE); - } - break; + } break; - case H5T_NO_CLASS: - case H5T_NCLASSES: - default: - error_msg("invalid H5TCLASS type\n"); - break; + case H5T_NO_CLASS: + case H5T_NCLASSES: + default: + error_msg("invalid H5TCLASS type\n"); + break; } /* end switch */ - } /* for(u=0; udatasetblockend)) { + if (HDstrlen(h5tools_dump_header_format->datasetblockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend); - if(HDstrlen(h5tools_dump_header_format->datasetend)) + if (HDstrlen(h5tools_dump_header_format->datasetend)) h5tools_str_append(&buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->datasetend)) + if (HDstrlen(h5tools_dump_header_format->datasetend)) h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); } @@ -1072,8 +1091,8 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) void dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) { - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; h5tool_format_t string_dataformat; int print_dataset = FALSE; @@ -1081,32 +1100,31 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - ctx.sset = sset; + ctx.indent_level = dump_indent / COL; + ctx.cur_column = dump_indent; + ctx.sset = sset; ctx.display_index = display_index; - ctx.display_char = dump_opts.display_char; + ctx.display_char = dump_opts.display_char; - if(obj_data == DATASET_DATA) + if (obj_data == DATASET_DATA) print_dataset = TRUE; h5tools_dump_data(rawoutstream, outputformat, &ctx, obj_id, print_dataset); } - /*------------------------------------------------------------------------- * Function: dump_fcpl * @@ -1118,19 +1136,19 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) void dump_fcpl(hid_t fid) { - hid_t fcpl; /* file creation property list ID */ - hsize_t userblock; /* userblock size retrieved from FCPL */ - size_t off_size; /* size of offsets in the file */ - size_t len_size; /* size of lengths in the file */ - H5F_fspace_strategy_t fs_strategy; /* file space strategy */ - hbool_t fs_persist; /* Persisting free-space or not */ - hsize_t fs_threshold; /* free-space section threshold */ - hsize_t fsp_size; /* file space page size */ - H5F_info2_t finfo; /* file information */ + hid_t fcpl; /* file creation property list ID */ + hsize_t userblock; /* userblock size retrieved from FCPL */ + size_t off_size; /* size of offsets in the file */ + size_t len_size; /* size of lengths in the file */ + H5F_fspace_strategy_t fs_strategy; /* file space strategy */ + hbool_t fs_persist; /* Persisting free-space or not */ + hsize_t fs_threshold; /* free-space section threshold */ + hsize_t fsp_size; /* file space page size */ + H5F_info2_t finfo; /* file information */ #ifdef SHOW_FILE_DRIVER - hid_t fapl; /* file access property list ID */ - hid_t fdriver; /* file driver */ - char dname[32]; /* buffer to store driver name */ + hid_t fapl; /* file access property list ID */ + hid_t fdriver; /* file driver */ + char dname[32]; /* buffer to store driver name */ #endif unsigned sym_lk; /* symbol table B-tree leaf 'K' value */ unsigned sym_ik; /* symbol table B-tree internal 'K' value */ @@ -1148,107 +1166,108 @@ dump_fcpl(hid_t fid) if (!supported) return; - fcpl=H5Fget_create_plist(fid); + fcpl = H5Fget_create_plist(fid); H5Fget_info2(fid, &finfo); - H5Pget_userblock(fcpl,&userblock); - H5Pget_sizes(fcpl,&off_size,&len_size); - H5Pget_sym_k(fcpl,&sym_ik,&sym_lk); - H5Pget_istore_k(fcpl,&istore_ik); + H5Pget_userblock(fcpl, &userblock); + H5Pget_sizes(fcpl, &off_size, &len_size); + H5Pget_sym_k(fcpl, &sym_ik, &sym_lk); + H5Pget_istore_k(fcpl, &istore_ik); H5Pget_file_space_strategy(fcpl, &fs_strategy, &fs_persist, &fs_threshold); H5Pget_file_space_page_size(fcpl, &fsp_size); H5Pclose(fcpl); #ifdef SHOW_FILE_DRIVER - fapl=h5_fileaccess(); - fdriver=H5Pget_driver(fapl); + fapl = h5_fileaccess(); + fdriver = H5Pget_driver(fapl); H5Pclose(fapl); #endif - /*------------------------------------------------------------------------- - * SUPER_BLOCK - *------------------------------------------------------------------------- - */ - PRINTSTREAM(rawoutstream, "\n%s %s\n",SUPER_BLOCK, BEGIN); + /*------------------------------------------------------------------------- + * SUPER_BLOCK + *------------------------------------------------------------------------- + */ + PRINTSTREAM(rawoutstream, "\n%s %s\n", SUPER_BLOCK, BEGIN); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","SUPERBLOCK_VERSION", finfo.super.version); + PRINTSTREAM(rawoutstream, "%s %u\n", "SUPERBLOCK_VERSION", finfo.super.version); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","FREELIST_VERSION", finfo.free.version); + PRINTSTREAM(rawoutstream, "%s %u\n", "FREELIST_VERSION", finfo.free.version); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","SYMBOLTABLE_VERSION", 0); /* Retain this for backward compatibility, for now (QAK) */ + PRINTSTREAM(rawoutstream, "%s %u\n", "SYMBOLTABLE_VERSION", + 0); /* Retain this for backward compatibility, for now (QAK) */ indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","OBJECTHEADER_VERSION", finfo.sohm.version); + PRINTSTREAM(rawoutstream, "%s %u\n", "OBJECTHEADER_VERSION", finfo.sohm.version); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream,"%s %zu\n","OFFSET_SIZE", off_size); + PRINTSTREAM(rawoutstream, "%s %zu\n", "OFFSET_SIZE", off_size); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream,"%s %zu\n","LENGTH_SIZE", len_size); + PRINTSTREAM(rawoutstream, "%s %zu\n", "LENGTH_SIZE", len_size); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","BTREE_RANK", sym_ik); + PRINTSTREAM(rawoutstream, "%s %u\n", "BTREE_RANK", sym_ik); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %d\n","BTREE_LEAF", sym_lk); + PRINTSTREAM(rawoutstream, "%s %d\n", "BTREE_LEAF", sym_lk); #ifdef SHOW_FILE_DRIVER - if(H5FD_CORE==fdriver) - HDstrcpy(dname,"H5FD_CORE"); + if (H5FD_CORE == fdriver) + HDstrcpy(dname, "H5FD_CORE"); #ifdef H5_HAVE_DIRECT - else if(H5FD_DIRECT==fdriver) - HDstrcpy(dname,"H5FD_DIRECT"); + else if (H5FD_DIRECT == fdriver) + HDstrcpy(dname, "H5FD_DIRECT"); #endif - else if(H5FD_FAMILY==fdriver) - HDstrcpy(dname,"H5FD_FAMILY"); - else if(H5FD_LOG==fdriver) - HDstrcpy(dname,"H5FD_LOG"); - else if(H5FD_MPIO==fdriver) - HDstrcpy(dname,"H5FD_MPIO"); - else if(H5FD_MULTI==fdriver) - HDstrcpy(dname,"H5FD_MULTI"); - else if(H5FD_SEC2==fdriver) - HDstrcpy(dname,"H5FD_SEC2"); - else if(H5FD_STDIO==fdriver) - HDstrcpy(dname,"H5FD_STDIO"); + else if (H5FD_FAMILY == fdriver) + HDstrcpy(dname, "H5FD_FAMILY"); + else if (H5FD_LOG == fdriver) + HDstrcpy(dname, "H5FD_LOG"); + else if (H5FD_MPIO == fdriver) + HDstrcpy(dname, "H5FD_MPIO"); + else if (H5FD_MULTI == fdriver) + HDstrcpy(dname, "H5FD_MULTI"); + else if (H5FD_SEC2 == fdriver) + HDstrcpy(dname, "H5FD_SEC2"); + else if (H5FD_STDIO == fdriver) + HDstrcpy(dname, "H5FD_STDIO"); else - HDstrcpy(dname,"Unknown driver"); + HDstrcpy(dname, "Unknown driver"); - /* Take out this because the driver used can be different from the - * standard output. */ - /*indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %s\n","FILE_DRIVER", dname);*/ + /* Take out this because the driver used can be different from the + * standard output. */ + /*indentation(dump_indent + COL); + PRINTSTREAM(rawoutstream, "%s %s\n","FILE_DRIVER", dname);*/ #endif indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","ISTORE_K", istore_ik); + PRINTSTREAM(rawoutstream, "%s %u\n", "ISTORE_K", istore_ik); indentation(dump_indent + COL); - if(fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) { + if (fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) { PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_FSM_AGGR"); } - else if(fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { + else if (fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_PAGE"); } - else if(fs_strategy == H5F_FSPACE_STRATEGY_AGGR) { + else if (fs_strategy == H5F_FSPACE_STRATEGY_AGGR) { PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_AGGR"); } - else if(fs_strategy == H5F_FSPACE_STRATEGY_NONE) { + else if (fs_strategy == H5F_FSPACE_STRATEGY_NONE) { PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_NONE"); } else PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "Unknown strategy"); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %s\n","FREE_SPACE_PERSIST", fs_persist ? "TRUE" : "FALSE"); + PRINTSTREAM(rawoutstream, "%s %s\n", "FREE_SPACE_PERSIST", fs_persist ? "TRUE" : "FALSE"); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %Hu\n","FREE_SPACE_SECTION_THRESHOLD", fs_threshold); + PRINTSTREAM(rawoutstream, "%s %Hu\n", "FREE_SPACE_SECTION_THRESHOLD", fs_threshold); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %Hu\n","FILE_SPACE_PAGE_SIZE", fsp_size); + PRINTSTREAM(rawoutstream, "%s %Hu\n", "FILE_SPACE_PAGE_SIZE", fsp_size); /*------------------------------------------------------------------------- - * USER_BLOCK - *------------------------------------------------------------------------- - */ + * USER_BLOCK + *------------------------------------------------------------------------- + */ indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "USER_BLOCK %s\n",BEGIN); + PRINTSTREAM(rawoutstream, "USER_BLOCK %s\n", BEGIN); indentation(dump_indent + COL + COL); - PRINTSTREAM(rawoutstream,"%s %Hu\n","USERBLOCK_SIZE", userblock); + PRINTSTREAM(rawoutstream, "%s %Hu\n", "USERBLOCK_SIZE", userblock); indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s\n",END); + PRINTSTREAM(rawoutstream, "%s\n", END); - PRINTSTREAM(rawoutstream, "%s",END); + PRINTSTREAM(rawoutstream, "%s", END); } /*------------------------------------------------------------------------- @@ -1262,7 +1281,7 @@ dump_fcpl(hid_t fid) void dump_fcontents(hid_t fid) { - PRINTSTREAM(rawoutstream, "%s %s\n",FILE_CONTENTS, BEGIN); + PRINTSTREAM(rawoutstream, "%s %s\n", FILE_CONTENTS, BEGIN); /* special case of unamed types in root group */ if (unamedtype) { @@ -1282,52 +1301,52 @@ dump_fcontents(hid_t fid) /* print objects in the files */ h5trav_print(fid); - PRINTSTREAM(rawoutstream, " %s\n",END); + PRINTSTREAM(rawoutstream, " %s\n", END); } static herr_t attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data) { - herr_t ret = SUCCEED; - int j; - char *obj_op_name; - char *obj_name; - trav_attr_udata_t *attr_data = (trav_attr_udata_t*)_op_data; - const char *buf = attr_data->path; - const char *op_name = attr_data->op_name; + herr_t ret = SUCCEED; + int j; + char * obj_op_name; + char * obj_name; + trav_attr_udata_t *attr_data = (trav_attr_udata_t *)_op_data; + const char * buf = attr_data->path; + const char * op_name = attr_data->op_name; j = (int)HDstrlen(op_name) - 1; /* find the last / */ - while(j >= 0) { - if(op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\'))) + while (j >= 0) { + if (op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\'))) break; j--; } obj_op_name = h5tools_str_replace(op_name + j + 1, "\\/", "/"); - if(obj_op_name == NULL) { + if (obj_op_name == NULL) { h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { - if(HDstrcmp(attr_name, obj_op_name)==0) { + if (HDstrcmp(attr_name, obj_op_name) == 0) { size_t u, v, w; /* object name */ - u = HDstrlen(buf); - v = HDstrlen(op_name); - w = u + 1 + v + 1 + 2; + u = HDstrlen(buf); + v = HDstrlen(op_name); + w = u + 1 + v + 1 + 2; obj_name = (char *)HDmalloc(w); - if(obj_name == NULL) { + if (obj_name == NULL) { h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { HDmemset(obj_name, '\0', w); - if(op_name[0] != '/') { + if (op_name[0] != '/') { HDstrncat(obj_name, buf, u + 1); - if(buf[u - 1] != '/') + if (buf[u - 1] != '/') HDstrncat(obj_name, "/", (size_t)2); } HDstrncat(obj_name, op_name, v + 1); @@ -1342,18 +1361,20 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a } /* end attr_search() */ static herr_t -obj_search(const char *path, const H5O_info2_t *oi, const char H5_ATTR_UNUSED *already_visited, void *_op_data) +obj_search(const char *path, const H5O_info2_t *oi, const char H5_ATTR_UNUSED *already_visited, + void *_op_data) { - trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data; - const char *op_name = handle_data->op_name; - trav_attr_udata_t attr_data; + trav_handle_udata_t *handle_data = (trav_handle_udata_t *)_op_data; + const char * op_name = handle_data->op_name; + trav_attr_udata_t attr_data; - attr_data.path = path; + attr_data.path = path; attr_data.op_name = op_name; - H5Aiterate_by_name(handle_data->fid, path, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_search, (void*)&attr_data, H5P_DEFAULT); + H5Aiterate_by_name(handle_data->fid, path, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_search, + (void *)&attr_data, H5P_DEFAULT); - if(HDstrcmp(path, op_name) == 0) { - switch(oi->type) { + if (HDstrcmp(path, op_name) == 0) { + switch (oi->type) { case H5O_TYPE_GROUP: handle_groups(handle_data->fid, path, NULL, 0, NULL); break; @@ -1381,19 +1402,19 @@ obj_search(const char *path, const H5O_info2_t *oi, const char H5_ATTR_UNUSED *a static herr_t lnk_search(const char *path, const H5L_info2_t *li, void *_op_data) { - size_t search_len; - size_t k; - char *search_name; - trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data; - const char *op_name = handle_data->op_name; + size_t search_len; + size_t k; + char * search_name; + trav_handle_udata_t *handle_data = (trav_handle_udata_t *)_op_data; + const char * op_name = handle_data->op_name; search_len = HDstrlen(op_name); - if(search_len > 0 && op_name[0] != '/') + if (search_len > 0 && op_name[0] != '/') k = 2; else k = 1; search_name = (char *)HDmalloc(search_len + k); - if(search_name == NULL) { + if (search_name == NULL) { error_msg("creating temporary link\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -1406,20 +1427,20 @@ lnk_search(const char *path, const H5L_info2_t *li, void *_op_data) HDstrncpy(search_name, op_name, search_len + 1); search_name[search_len + k - 1] = '\0'; - if(HDstrcmp(path, search_name) == 0) { - switch(li->type) { - case H5L_TYPE_SOFT: - case H5L_TYPE_EXTERNAL: - handle_links(handle_data->fid, op_name, NULL, 0, NULL); - break; + if (HDstrcmp(path, search_name) == 0) { + switch (li->type) { + case H5L_TYPE_SOFT: + case H5L_TYPE_EXTERNAL: + handle_links(handle_data->fid, op_name, NULL, 0, NULL); + break; - case H5L_TYPE_HARD: - case H5L_TYPE_MAX: - case H5L_TYPE_ERROR: - default: - error_msg("unknown link type value\n"); - h5tools_setstatus(EXIT_FAILURE); - break; + case H5L_TYPE_HARD: + case H5L_TYPE_MAX: + case H5L_TYPE_ERROR: + default: + error_msg("unknown link type value\n"); + h5tools_setstatus(EXIT_FAILURE); + break; } /* end switch() */ } HDfree(search_name); @@ -1436,19 +1457,20 @@ lnk_search(const char *path, const H5L_info2_t *li, void *_op_data) *------------------------------------------------------------------------- */ void -handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name) +handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe, + const char H5_ATTR_UNUSED *display_name) { - hid_t gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { error_msg("unable to open root group\n"); h5tools_setstatus(EXIT_FAILURE); } else { - hid_t gcpl_id; - unsigned crt_order_flags; - unsigned attr_crt_order_flags; - trav_handle_udata_t handle_udata; /* User data for traversal */ + hid_t gcpl_id; + unsigned crt_order_flags; + unsigned attr_crt_order_flags; + trav_handle_udata_t handle_udata; /* User data for traversal */ if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { error_msg("error in getting group creation property list ID\n"); @@ -1462,19 +1484,19 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H } /* query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { + if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { error_msg("error in getting group creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } - if(H5Pclose(gcpl_id) < 0) { + if (H5Pclose(gcpl_id) < 0) { error_msg("error in closing group creation property list ID\n"); h5tools_setstatus(EXIT_FAILURE); } - handle_udata.fid = fid; + handle_udata.fid = fid; handle_udata.op_name = path_name; - if(h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata, H5O_INFO_BASIC) < 0) { + if (h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata, H5O_INFO_BASIC) < 0) { error_msg("error traversing information\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -1490,33 +1512,34 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H *------------------------------------------------------------------------- */ void -handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name) +handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe, + const char H5_ATTR_UNUSED *display_name) { - hid_t oid = H5I_INVALID_HID; - hid_t attr_id = H5I_INVALID_HID; - char *obj_name = NULL; - char *attr_name = NULL; - int j; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; + hid_t oid = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; + char * obj_name = NULL; + char * attr_name = NULL; + int j; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &h5tools_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ - j = (int)HDstrlen(attr) - 1; + j = (int)HDstrlen(attr) - 1; obj_name = (char *)HDmalloc((size_t)j + 2); - if(obj_name == NULL) + if (obj_name == NULL) goto error; /* find the last / */ - while(j >= 0) { - if (attr[j] == '/' && (j==0 || (j>0 && attr[j-1]!='\\'))) + while (j >= 0) { + if (attr[j] == '/' && (j == 0 || (j > 0 && attr[j - 1] != '\\'))) break; j--; } /* object name */ - if(j == -1) + if (j == -1) HDstrcpy(obj_name, "/"); else { HDstrncpy(obj_name, attr, (size_t)j + 1); @@ -1525,32 +1548,32 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5 dump_indent += COL; HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.indent_level = dump_indent / COL; + ctx.cur_column = dump_indent; ctx.display_index = dump_opts.display_ai; - ctx.display_char = dump_opts.display_char; + ctx.display_char = dump_opts.display_char; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; attr_name = h5tools_str_replace(attr + j + 1, "\\/", "/"); /* handle error case: cannot open the object with the attribute */ - if((oid = H5Oopen(fid, obj_name, H5P_DEFAULT)) < 0) { + if ((oid = H5Oopen(fid, obj_name, H5P_DEFAULT)) < 0) { /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -1558,45 +1581,46 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5 /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->attributebegin, attr, - h5tools_dump_header_format->attributeblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->attributebegin, attr, + h5tools_dump_header_format->attributeblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); error_msg("unable to open object \"%s\"\n", obj_name); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->attributeblockend)) { + if (HDstrlen(h5tools_dump_header_format->attributeblockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeblockend); - if(HDstrlen(h5tools_dump_header_format->attributeend)) + if (HDstrlen(h5tools_dump_header_format->attributeend)) h5tools_str_append(&buffer, " "); } - if(HDstrlen(h5tools_dump_header_format->attributeend)) + if (HDstrlen(h5tools_dump_header_format->attributeend)) h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); goto error; } /* end if */ - attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); - oid_output = dump_opts.display_oid; - data_output = dump_opts.display_data; + attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); + oid_output = dump_opts.display_oid; + data_output = dump_opts.display_data; attr_data_output = dump_opts.display_attr_data; h5dump_type_table = type_table; h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id); h5dump_type_table = NULL; - if(attr_id < 0) { + if (attr_id < 0) { goto error; } /* Close object */ - if(H5Oclose(oid) < 0) { + if (H5Oclose(oid) < 0) { goto error; } /* end if */ @@ -1607,16 +1631,18 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5 error: h5tools_setstatus(EXIT_FAILURE); - if(obj_name) + if (obj_name) HDfree(obj_name); if (attr_name) HDfree(attr_name); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Oclose(oid); H5Aclose(attr_id); - } H5E_END_TRY; + } + H5E_END_TRY; dump_indent -= COL; } @@ -1633,69 +1659,69 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis { H5O_info2_t oinfo; hid_t dsetid; - hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */ - struct subset_t *sset = (struct subset_t *)data; - const char *real_name = display_name ? display_name : dset; + hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */ + struct subset_t *sset = (struct subset_t *)data; + const char * real_name = display_name ? display_name : dset; - if(dump_opts.display_data) { + if (dump_opts.display_data) { if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { error_msg("error in creating default access property list ID\n"); } if (dump_opts.display_vds_first) { - if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0) + if (H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0) error_msg("error in setting access property list ID, virtual_view\n"); } if (dump_opts.vds_gap_size > 0) { - if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0) + if (H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0) error_msg("error in setting access property list ID, virtual_printf_gap\n"); } } - if((dsetid = H5Dopen2(fid, dset, dapl_id)) < 0) { + if ((dsetid = H5Dopen2(fid, dset, dapl_id)) < 0) { if (pe) handle_links(fid, dset, data, pe, display_name); return; } /* end if */ - if(sset) { + if (sset) { unsigned int i; unsigned int ndims; - hid_t sid = H5Dget_space(dsetid); - int ndims_res = H5Sget_simple_extent_ndims(sid); + hid_t sid = H5Dget_space(dsetid); + int ndims_res = H5Sget_simple_extent_ndims(sid); H5Sclose(sid); - if(ndims_res < 0) { + if (ndims_res < 0) { error_msg("H5Sget_simple_extent_ndims failed\n"); h5tools_setstatus(EXIT_FAILURE); return; } ndims = (unsigned)ndims_res; - if(!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) { + if (!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) { /* they didn't specify a ``stride'' or ``block''. default to 1 in all * dimensions */ - if(!sset->start.data) { + if (!sset->start.data) { /* default to (0, 0, ...) for the start coord */ sset->start.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t)); - sset->start.len = ndims; + sset->start.len = ndims; } - if(!sset->stride.data) { + if (!sset->stride.data) { sset->stride.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t)); - sset->stride.len = ndims; + sset->stride.len = ndims; for (i = 0; i < ndims; i++) sset->stride.data[i] = 1; } - if(!sset->count.data) { + if (!sset->count.data) { sset->count.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t)); - sset->count.len = ndims; + sset->count.len = ndims; for (i = 0; i < ndims; i++) sset->count.data[i] = 1; } - if(!sset->block.data) { + if (!sset->block.data) { sset->block.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t)); - sset->block.len = ndims; + sset->block.len = ndims; for (i = 0; i < ndims; i++) sset->block.data[i] = 1; } @@ -1705,22 +1731,22 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis * check for dimension overflow *------------------------------------------------------------------------- */ - if(sset->start.len > ndims) { + if (sset->start.len > ndims) { error_msg("number of start dims (%u) exceed dataset dims (%u)\n", sset->start.len, ndims); h5tools_setstatus(EXIT_FAILURE); return; } - if(sset->stride.len > ndims) { + if (sset->stride.len > ndims) { error_msg("number of stride dims (%u) exceed dataset dims (%u)\n", sset->stride.len, ndims); h5tools_setstatus(EXIT_FAILURE); return; } - if(sset->count.len > ndims) { + if (sset->count.len > ndims) { error_msg("number of count dims (%u) exceed dataset dims (%u)\n", sset->count.len, ndims); h5tools_setstatus(EXIT_FAILURE); return; } - if(sset->block.len > ndims) { + if (sset->block.len > ndims) { error_msg("number of block dims (%u) exceed dataset dims (%u)\n", sset->block.len, ndims); h5tools_setstatus(EXIT_FAILURE); return; @@ -1730,29 +1756,29 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis * check for block overlap *------------------------------------------------------------------------- */ - for(i = 0; i < ndims; i++) { - if(sset->count.data[i] > 1) { - if(sset->stride.data[i] < sset->block.data[i]) { + for (i = 0; i < ndims; i++) { + if (sset->count.data[i] > 1) { + if (sset->stride.data[i] < sset->block.data[i]) { error_msg("wrong subset selection; blocks overlap\n"); h5tools_setstatus(EXIT_FAILURE); return; } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ - + } /* end if */ + } /* end for */ + } /* end if */ H5Oget_info3(dsetid, &oinfo, H5O_INFO_BASIC); - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ + if (oinfo.rc > 1 || hit_elink) { + obj_t *found_obj; /* Found object */ found_obj = search_obj(dset_table, &oinfo.token); - if(found_obj) { + if (found_obj) { if (found_obj->displayed) { PRINTVALSTREAM(rawoutstream, "\n"); indentation(dump_indent); - begin_obj(h5tools_dump_header_format->datasetbegin, real_name, h5tools_dump_header_format->datasetblockbegin); + begin_obj(h5tools_dump_header_format->datasetbegin, real_name, + h5tools_dump_header_format->datasetblockbegin); PRINTVALSTREAM(rawoutstream, "\n"); indentation(dump_indent + COL); PRINTSTREAM(rawoutstream, "%s \"%s\"\n", HARDLINK, found_obj->objname); @@ -1776,7 +1802,7 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis } if (dapl_id != H5P_DEFAULT) H5Pclose(dapl_id); - if(H5Dclose(dsetid) < 0) + if (H5Dclose(dsetid) < 0) h5tools_setstatus(EXIT_FAILURE); } @@ -1792,12 +1818,13 @@ void handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, const char *display_name) { hid_t gid; - const char *real_name = display_name ? display_name : group; + const char *real_name = display_name ? display_name : group; - if((gid = H5Gopen2(fid, group, H5P_DEFAULT)) < 0) { + if ((gid = H5Gopen2(fid, group, H5P_DEFAULT)) < 0) { if (pe) { PRINTVALSTREAM(rawoutstream, "\n"); - begin_obj(h5tools_dump_header_format->groupbegin, real_name, h5tools_dump_header_format->groupblockbegin); + begin_obj(h5tools_dump_header_format->groupbegin, real_name, + h5tools_dump_header_format->groupblockbegin); PRINTVALSTREAM(rawoutstream, "\n"); indentation(COL); error_msg("unable to open group \"%s\"\n", real_name); @@ -1808,9 +1835,9 @@ handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, c else { size_t new_len = HDstrlen(group) + 1; - if(prefix_len <= new_len) { + if (prefix_len <= new_len) { prefix_len = new_len; - prefix = (char *)HDrealloc(prefix, prefix_len); + prefix = (char *)HDrealloc(prefix, prefix_len); } /* end if */ HDstrcpy(prefix, group); @@ -1819,7 +1846,7 @@ handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, c dump_group(gid, real_name); dump_indent -= COL; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) h5tools_setstatus(EXIT_FAILURE); } /* end else */ } /* end handle_groups() */ @@ -1833,15 +1860,16 @@ handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, c *------------------------------------------------------------------------- */ void -handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name) +handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe, + const char H5_ATTR_UNUSED *display_name) { H5L_info2_t linfo; - if(H5Lget_info2(fid, links, &linfo, H5P_DEFAULT) < 0) { + if (H5Lget_info2(fid, links, &linfo, H5P_DEFAULT) < 0) { error_msg("unable to get link info from \"%s\"\n", links); h5tools_setstatus(EXIT_FAILURE); } - else if(linfo.type == H5L_TYPE_HARD) { + else if (linfo.type == H5L_TYPE_HARD) { error_msg("\"%s\" is a hard link\n", links); h5tools_setstatus(EXIT_FAILURE); } @@ -1849,56 +1877,60 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT char *buf = (char *)HDmalloc(linfo.u.val_size); PRINTVALSTREAM(rawoutstream, "\n"); - switch(linfo.type) { - case H5L_TYPE_SOFT: /* Soft link */ - begin_obj(h5tools_dump_header_format->softlinkbegin, links, h5tools_dump_header_format->softlinkblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(COL); - if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { - PRINTSTREAM(rawoutstream, "LINKTARGET \"%s\"\n", buf); - } - else { - error_msg("h5dump error: unable to get link value for \"%s\"\n", links); - h5tools_setstatus(EXIT_FAILURE); - } - end_obj(h5tools_dump_header_format->softlinkend, h5tools_dump_header_format->softlinkblockend); - break; + switch (linfo.type) { + case H5L_TYPE_SOFT: /* Soft link */ + begin_obj(h5tools_dump_header_format->softlinkbegin, links, + h5tools_dump_header_format->softlinkblockbegin); + PRINTVALSTREAM(rawoutstream, "\n"); + indentation(COL); + if (H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { + PRINTSTREAM(rawoutstream, "LINKTARGET \"%s\"\n", buf); + } + else { + error_msg("h5dump error: unable to get link value for \"%s\"\n", links); + h5tools_setstatus(EXIT_FAILURE); + } + end_obj(h5tools_dump_header_format->softlinkend, + h5tools_dump_header_format->softlinkblockend); + break; - case H5L_TYPE_EXTERNAL: - begin_obj(h5tools_dump_header_format->extlinkbegin, links, h5tools_dump_header_format->extlinkblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { - const char *elink_file; - const char *elink_path; - - if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &elink_file, &elink_path)>=0) { - indentation(COL); - PRINTSTREAM(rawoutstream, "TARGETFILE \"%s\"\n", elink_file); - indentation(COL); - PRINTSTREAM(rawoutstream, "TARGETPATH \"%s\"\n", elink_path); + case H5L_TYPE_EXTERNAL: + begin_obj(h5tools_dump_header_format->extlinkbegin, links, + h5tools_dump_header_format->extlinkblockbegin); + PRINTVALSTREAM(rawoutstream, "\n"); + if (H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { + const char *elink_file; + const char *elink_path; + + if (H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &elink_file, &elink_path) >= 0) { + indentation(COL); + PRINTSTREAM(rawoutstream, "TARGETFILE \"%s\"\n", elink_file); + indentation(COL); + PRINTSTREAM(rawoutstream, "TARGETPATH \"%s\"\n", elink_path); + } + else { + error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links); + h5tools_setstatus(EXIT_FAILURE); + } } else { - error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links); + error_msg("h5dump error: unable to get external link value for \"%s\"\n", links); h5tools_setstatus(EXIT_FAILURE); } - } - else { - error_msg("h5dump error: unable to get external link value for \"%s\"\n", links); - h5tools_setstatus(EXIT_FAILURE); - } - end_obj(h5tools_dump_header_format->extlinkend, h5tools_dump_header_format->extlinkblockend); - break; + end_obj(h5tools_dump_header_format->extlinkend, h5tools_dump_header_format->extlinkblockend); + break; - case H5L_TYPE_ERROR: - case H5L_TYPE_MAX: - case H5L_TYPE_HARD: - default: - begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(COL); - PRINTSTREAM(rawoutstream, "LINKCLASS %d\n", linfo.type); - end_obj(h5tools_dump_header_format->udlinkend, h5tools_dump_header_format->udlinkblockend); - break; + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: + case H5L_TYPE_HARD: + default: + begin_obj(h5tools_dump_header_format->udlinkbegin, links, + h5tools_dump_header_format->udlinkblockbegin); + PRINTVALSTREAM(rawoutstream, "\n"); + indentation(COL); + PRINTSTREAM(rawoutstream, "LINKCLASS %d\n", linfo.type); + end_obj(h5tools_dump_header_format->udlinkend, h5tools_dump_header_format->udlinkblockend); + break; } /* end switch */ HDfree(buf); } /* end else */ @@ -1913,19 +1945,19 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT *------------------------------------------------------------------------- */ void -handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe, const char *display_name) +handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED *data, int pe, const char *display_name) { hid_t type_id; - const char *real_name = display_name ? display_name : type; + const char *real_name = display_name ? display_name : type; - if((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) { + if ((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) { /* check if type is unamed datatype */ unsigned idx = 0; - while(idx < type_table->nobjs ) { + while (idx < type_table->nobjs) { char name[128]; - if(!type_table->objs[idx].recorded) { + if (!type_table->objs[idx].recorded) { char *obj_tok_str = NULL; /* unamed datatype */ @@ -1933,28 +1965,30 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe HDsprintf(name, "/#%s", obj_tok_str); H5free_memory(obj_tok_str); - if(!HDstrcmp(name, real_name)) + if (!HDstrcmp(name, real_name)) break; } /* end if */ idx++; } /* end while */ - if(idx == type_table->nobjs) { + if (idx == type_table->nobjs) { if (pe) { /* unknown type */ PRINTVALSTREAM(rawoutstream, "\n"); - begin_obj(h5tools_dump_header_format->datatypebegin, real_name, h5tools_dump_header_format->datatypeblockbegin); + begin_obj(h5tools_dump_header_format->datatypebegin, real_name, + h5tools_dump_header_format->datatypeblockbegin); PRINTVALSTREAM(rawoutstream, "\n"); indentation(COL); error_msg("unable to open datatype \"%s\"\n", real_name); - end_obj(h5tools_dump_header_format->datatypeend, h5tools_dump_header_format->datatypeblockend); + end_obj(h5tools_dump_header_format->datatypeend, + h5tools_dump_header_format->datatypeblockend); h5tools_setstatus(EXIT_FAILURE); } } else { hid_t dsetid = H5Dopen2(fid, type_table->objs[idx].objname, H5P_DEFAULT); - type_id = H5Dget_type(dsetid); + type_id = H5Dget_type(dsetid); dump_indent += COL; dump_named_datatype(type_id, real_name); @@ -1969,12 +2003,11 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe dump_named_datatype(type_id, real_name); dump_indent -= COL; - if(H5Tclose(type_id) < 0) + if (H5Tclose(type_id) < 0) h5tools_setstatus(EXIT_FAILURE); } } - /*------------------------------------------------------------------------- * Function: dump_extlink * @@ -1990,9 +2023,9 @@ dump_extlink(hid_t group, const char *linkname, const char *objname) { hid_t oid; H5O_info2_t oi; - table_t *old_group_table = group_table; - table_t *old_dset_table = dset_table; - table_t *old_type_table = type_table; + table_t * old_group_table = group_table; + table_t * old_dset_table = dset_table; + table_t * old_type_table = type_table; hbool_t old_hit_elink; ssize_t idx; @@ -2019,12 +2052,12 @@ dump_extlink(hid_t group, const char *linkname, const char *objname) if (idx) { /* Update table pointers */ group_table = table_list.tables[idx].group_table; - dset_table = table_list.tables[idx].dset_table; - type_table = table_list.tables[idx].type_table; + dset_table = table_list.tables[idx].dset_table; + type_table = table_list.tables[idx].type_table; /* We will now traverse the external link, set this global to indicate this */ old_hit_elink = hit_elink; - hit_elink = TRUE; + hit_elink = TRUE; /* add some indentation to distinguish that these objects are external */ dump_indent += COL; @@ -2054,8 +2087,8 @@ dump_extlink(hid_t group, const char *linkname, const char *objname) /* Reset table pointers */ group_table = old_group_table; - dset_table = old_dset_table; - type_table = old_type_table; + dset_table = old_dset_table; + type_table = old_type_table; /* Reset hit_elink */ hit_elink = old_hit_elink; @@ -2069,4 +2102,3 @@ dump_extlink(hid_t group, const char *linkname, const char *objname) fail: return FAIL; } - diff --git a/tools/src/h5dump/h5dump_ddl.h b/tools/src/h5dump/h5dump_ddl.h index ae01086..00b7c46 100644 --- a/tools/src/h5dump/h5dump_ddl.h +++ b/tools/src/h5dump/h5dump_ddl.h @@ -20,17 +20,17 @@ extern "C" { /* The dump functions of the dump_function_table */ /* standard format: no change */ -void dump_group(hid_t, const char *); -void dump_named_datatype(hid_t, const char *); -void dump_dataset(hid_t, const char *, struct subset_t *); -void dump_dataspace(hid_t space); -void dump_datatype(hid_t type); -void dump_data(hid_t, int, struct subset_t *, int); -void dump_fcpl(hid_t fid); -void dump_fcontents(hid_t fid); +void dump_group(hid_t, const char *); +void dump_named_datatype(hid_t, const char *); +void dump_dataset(hid_t, const char *, struct subset_t *); +void dump_dataspace(hid_t space); +void dump_datatype(hid_t type); +void dump_data(hid_t, int, struct subset_t *, int); +void dump_fcpl(hid_t fid); +void dump_fcontents(hid_t fid); /* callback function used by H5Aiterate2() */ -herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data); +herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data); /* other iteration functions */ void link_iteration(hid_t gid, unsigned crt_order_flags); @@ -38,13 +38,16 @@ void attr_iteration(hid_t gid, unsigned attr_crt_order_flags); void handle_paths(hid_t fid, const char *path_name, void *data, int pe, const char *display_name); void handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name); -void handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name); +void handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe, + const char H5_ATTR_UNUSED *display_name); void handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, const char *display_name); -void handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name); -void handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe, const char *display_name); +void handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe, + const char H5_ATTR_UNUSED *display_name); +void handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED *data, int pe, + const char *display_name); #ifdef __cplusplus } #endif -#endif /* !H5DUMP_DDL_H__ */ +#endif /* !H5DUMP_DDL_H__ */ diff --git a/tools/src/h5dump/h5dump_defines.h b/tools/src/h5dump/h5dump_defines.h index 7a9d4c0..669fae6 100644 --- a/tools/src/h5dump/h5dump_defines.h +++ b/tools/src/h5dump/h5dump_defines.h @@ -13,42 +13,41 @@ #ifndef H5DUMP_DEFINES_H__ #define H5DUMP_DEFINES_H__ -#define H5DUMP_MAX_RANK H5S_MAX_RANK +#define H5DUMP_MAX_RANK H5S_MAX_RANK -#define ATTRIBUTE_DATA 0 -#define DATASET_DATA 1 -#define ENUM_DATA 2 -#define COL 3 +#define ATTRIBUTE_DATA 0 +#define DATASET_DATA 1 +#define ENUM_DATA 2 +#define COL 3 /* Macros for displaying objects */ -#define begin_obj(obj,name,begin) \ - do { \ - if ((name)) { \ - PRINTSTREAM(rawoutstream, "%s \"%s\" %s", (obj), (name), (begin)); \ - } \ - else { \ - PRINTSTREAM(rawoutstream, "%s %s", (obj), (begin)); \ - } \ - } while(0); - -#define end_obj(obj,end) \ - do { \ - if(HDstrlen(end)) { \ - PRINTSTREAM(rawoutstream, "%s", end); \ - if(HDstrlen(obj)) \ - PRINTVALSTREAM(rawoutstream, " "); \ - } \ - if(HDstrlen(obj)) \ - PRINTSTREAM(rawoutstream, "%s", obj); \ - } while(0); +#define begin_obj(obj, name, begin) \ + do { \ + if ((name)) { \ + PRINTSTREAM(rawoutstream, "%s \"%s\" %s", (obj), (name), (begin)); \ + } \ + else { \ + PRINTSTREAM(rawoutstream, "%s %s", (obj), (begin)); \ + } \ + } while (0); +#define end_obj(obj, end) \ + do { \ + if (HDstrlen(end)) { \ + PRINTSTREAM(rawoutstream, "%s", end); \ + if (HDstrlen(obj)) \ + PRINTVALSTREAM(rawoutstream, " "); \ + } \ + if (HDstrlen(obj)) \ + PRINTSTREAM(rawoutstream, "%s", obj); \ + } while (0); /* 3 private values: can't be set, but can be read. Note: these are defined in H5Zprivate, they are duplicated here. */ -#define H5_SZIP_LSB_OPTION_MASK 8 -#define H5_SZIP_MSB_OPTION_MASK 16 -#define H5_SZIP_RAW_OPTION_MASK 128 +#define H5_SZIP_LSB_OPTION_MASK 8 +#define H5_SZIP_MSB_OPTION_MASK 16 +#define H5_SZIP_RAW_OPTION_MASK 128 -#endif /* !H5DUMP_DEFINES_H__ */ +#endif /* !H5DUMP_DEFINES_H__ */ diff --git a/tools/src/h5dump/h5dump_extern.h b/tools/src/h5dump/h5dump_extern.h index c615621..6ccd159 100644 --- a/tools/src/h5dump/h5dump_extern.h +++ b/tools/src/h5dump/h5dump_extern.h @@ -26,64 +26,65 @@ **/ /* the table of dump functions */ typedef struct dump_functions_t { - void (*dump_group_function) (hid_t, const char *); - void (*dump_named_datatype_function) (hid_t, const char *); - void (*dump_dataset_function) (hid_t, const char *, struct subset_t *); - void (*dump_dataspace_function) (hid_t); - void (*dump_datatype_function) (hid_t); - herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *); - void (*dump_data_function) (hid_t, int, struct subset_t *, int); + void (*dump_group_function)(hid_t, const char *); + void (*dump_named_datatype_function)(hid_t, const char *); + void (*dump_dataset_function)(hid_t, const char *, struct subset_t *); + void (*dump_dataspace_function)(hid_t); + void (*dump_datatype_function)(hid_t); + herr_t (*dump_attribute_function)(hid_t, const char *, const H5A_info_t *, void *); + void (*dump_data_function)(hid_t, int, struct subset_t *, int); } dump_functions; /* List of table structures. There is one table structure for each file */ typedef struct h5dump_table_list_t { - size_t nalloc; - size_t nused; + size_t nalloc; + size_t nused; struct { - unsigned long fileno; /* File number that these tables refer to */ - hid_t oid; /* ID of an object in this file, held open so fileno is consistent */ - table_t *group_table; /* Table of groups */ - table_t *dset_table; /* Table of datasets */ - table_t *type_table; /* Table of datatypes */ - } *tables; + unsigned long fileno; /* File number that these tables refer to */ + hid_t oid; /* ID of an object in this file, held open so fileno is consistent */ + table_t * group_table; /* Table of groups */ + table_t * dset_table; /* Table of datasets */ + table_t * type_table; /* Table of datatypes */ + } * tables; } h5dump_table_list_t; -extern h5dump_table_list_t table_list; -extern table_t *group_table, *dset_table, *type_table; +extern h5dump_table_list_t table_list; +extern table_t * group_table, *dset_table, *type_table; -extern unsigned dump_indent; /* how far in to indent the line */ -extern int unamedtype; /* shared datatype with no name */ -extern hbool_t hit_elink; /* whether we have traversed an external link */ -extern size_t prefix_len; -extern char *prefix; -extern const char *fp_format; +extern unsigned dump_indent; /* how far in to indent the line */ +extern int unamedtype; /* shared datatype with no name */ +extern hbool_t hit_elink; /* whether we have traversed an external link */ +extern size_t prefix_len; +extern char * prefix; +extern const char *fp_format; /* things to display or which are set via command line parameters */ typedef struct { - int display_all; - int display_oid; - int display_data; - int display_attr_data; - int display_char; /* print 1-byte numbers as ASCII */ - int usingdasho; - int display_bb; /* superblock */ - int display_dcpl; /* dcpl */ - int display_fi; /* file index */ - int display_ai; /* array index */ - int display_escape; /* escape non printable characters */ - int display_region; /* print region reference data */ - int disable_compact_subset; /* disable compact form of subset notation */ - int display_packed_bits; /* print 1-8 byte numbers as packed bits */ - int include_attrs; /* Display attributes */ - int display_vds_first; /* vds display to all by default */ - int vds_gap_size; /* vds skip missing files default is none */ + int display_all; + int display_oid; + int display_data; + int display_attr_data; + int display_char; /* print 1-byte numbers as ASCII */ + int usingdasho; + int display_bb; /* superblock */ + int display_dcpl; /* dcpl */ + int display_fi; /* file index */ + int display_ai; /* array index */ + int display_escape; /* escape non printable characters */ + int display_region; /* print region reference data */ + int disable_compact_subset; /* disable compact form of subset notation */ + int display_packed_bits; /* print 1-8 byte numbers as packed bits */ + int include_attrs; /* Display attributes */ + int display_vds_first; /* vds display to all by default */ + int vds_gap_size; /* vds skip missing files default is none */ } dump_opt_t; extern dump_opt_t dump_opts; -#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ -#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */ +#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ +#define PACKED_BITS_SIZE_MAX 8 * sizeof(long long) /* Maximum bits size of integer types of packed-bits */ /* mask list for packed bits */ -extern unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */ +extern unsigned long long + packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */ /* packed bits display parameters */ extern unsigned packed_offset[PACKED_BITS_MAX]; @@ -99,13 +100,13 @@ extern const dump_functions *dump_function_table; extern "C" { #endif -void add_prefix(char **prfx, size_t *prfx_len, const char *name); -hid_t h5_fileaccess(void); -ssize_t table_list_add(hid_t oid, unsigned long file_no); -ssize_t table_list_visited(unsigned long file_no); +void add_prefix(char **prfx, size_t *prfx_len, const char *name); +hid_t h5_fileaccess(void); +ssize_t table_list_add(hid_t oid, unsigned long file_no); +ssize_t table_list_visited(unsigned long file_no); #ifdef __cplusplus } #endif -#endif /* !H5DUMP_EXTERN_H__ */ +#endif /* !H5DUMP_EXTERN_H__ */ diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 696841d..0457d32 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -20,7 +20,7 @@ #include "h5dump_extern.h" #include "h5dump_xml.h" -const char *xmlnsprefix="hdf5:"; +const char *xmlnsprefix = "hdf5:"; /* * Alternative formating for data dumped to XML @@ -34,53 +34,54 @@ const char *xmlnsprefix="hdf5:"; * * This table only affects XML output. */ -static h5tool_format_t xml_dataformat = { - 0, /*raw */ - - "", /*fmt_raw */ - "%d", /*fmt_int */ - "%u", /*fmt_uint */ - "%hhd", /*fmt_schar */ - "%u", /*fmt_uchar */ - "%d", /*fmt_short */ - "%u", /*fmt_ushort */ - "%ld", /*fmt_long */ - "%lu", /*fmt_ulong */ - NULL, /*fmt_llong */ - NULL, /*fmt_ullong */ - "%g", /*fmt_double */ - "%g", /*fmt_float */ - - 0, /*ascii */ - 0, /*str_locale */ - 0, /*str_repeat */ - - "", /*arr_pre */ - "", /*arr_sep */ - "", /*arr_suf */ - 1, /*arr_linebreak */ - - "", /*cmpd_name */ - "", /*cmpd_sep */ - "", /*cmpd_pre */ - "", /*cmpd_suf */ - "", /*cmpd_end */ - NULL, /*cmpd_listv */ - - " ", /*vlen_sep */ - " ", /*vlen_pre */ - "", /*vlen_suf */ - "", /*vlen_end */ - - "%s", /*elmt_fmt */ - "", /*elmt_suf1 */ - " ", /*elmt_suf2 */ - - "", /*idx_n_fmt */ - "", /*idx_sep */ - "", /*idx_fmt */ - - 80, /*line_ncols *//*standard default columns */ +static h5tool_format_t xml_dataformat = { + 0, /*raw */ + + "", /*fmt_raw */ + "%d", /*fmt_int */ + "%u", /*fmt_uint */ + "%hhd", /*fmt_schar */ + "%u", /*fmt_uchar */ + "%d", /*fmt_short */ + "%u", /*fmt_ushort */ + "%ld", /*fmt_long */ + "%lu", /*fmt_ulong */ + NULL, /*fmt_llong */ + NULL, /*fmt_ullong */ + "%g", /*fmt_double */ + "%g", /*fmt_float */ + + 0, /*ascii */ + 0, /*str_locale */ + 0, /*str_repeat */ + + "", /*arr_pre */ + "", /*arr_sep */ + "", /*arr_suf */ + 1, /*arr_linebreak */ + + "", /*cmpd_name */ + "", /*cmpd_sep */ + "", /*cmpd_pre */ + "", /*cmpd_suf */ + "", /*cmpd_end */ + NULL, /*cmpd_listv */ + + " ", /*vlen_sep */ + " ", /*vlen_pre */ + "", /*vlen_suf */ + "", /*vlen_end */ + + "%s", /*elmt_fmt */ + "", /*elmt_suf1 */ + " ", /*elmt_suf2 */ + + "", /*idx_n_fmt */ + "", /*idx_sep */ + "", /*idx_fmt */ + + 80, + /*line_ncols */ /*standard default columns */ 0, /*line_per_line */ "", /*line_pre */ "%s", /*line_1st */ @@ -90,31 +91,30 @@ static h5tool_format_t xml_dataformat = { 1, /*line_multi_new */ " ", /*line_indent */ - 1, /*skip_first */ + 1, /*skip_first */ 1, /*obj_hidefileno */ " %" PRIuHADDR, /*obj_format */ - 1, /*dset_hidefileno */ - "DATASET %s ", /*dset_format */ - "%s", /*dset_blockformat_pre */ - "%s", /*dset_ptformat_pre */ - "%s", /*dset_ptformat */ - 0, /*array indices */ - 0 /*escape non printable characters */ + 1, /*dset_hidefileno */ + "DATASET %s ", /*dset_format */ + "%s", /*dset_blockformat_pre */ + "%s", /*dset_ptformat_pre */ + "%s", /*dset_ptformat */ + 0, /*array indices */ + 0 /*escape non printable characters */ }; - /* internal functions */ -static int xml_name_to_XID(hid_t, const char *, char *, int, int); +static int xml_name_to_XID(hid_t, const char *, char *, int, int); /* internal functions used by XML option */ -static void xml_print_datatype(hid_t, unsigned); -static void xml_print_enum(hid_t); -static int xml_print_refs(hid_t, int); -static int xml_print_strs(hid_t, int); -static char *xml_escape_the_string(const char *, int); -static char *xml_escape_the_name(const char *); +static void xml_print_datatype(hid_t, unsigned); +static void xml_print_enum(hid_t); +static int xml_print_refs(hid_t, int); +static int xml_print_strs(hid_t, int); +static char *xml_escape_the_string(const char *, int); +static char *xml_escape_the_name(const char *); /*------------------------------------------------------------------------- * Function: xml_dump_all_cb @@ -133,41 +133,41 @@ static herr_t xml_dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATTR_UNUSED *op_data) { hid_t obj; - herr_t ret = SUCCEED; - char *obj_path = NULL; /* Full path of object */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + herr_t ret = SUCCEED; + char * obj_path = NULL; /* Full path of object */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { - string_dataformat.line_ncols = 65535; + if (h5tools_nCols == 0) { + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; /* Build the object's path name */ obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - if(!obj_path) { + if (!obj_path) { ret = FAIL; goto done; } @@ -176,355 +176,362 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5 HDstrcat(obj_path, "/"); HDstrcat(obj_path, name); - if(linfo->type == H5L_TYPE_HARD) { - H5O_info2_t oinfo; + if (linfo->type == H5L_TYPE_HARD) { + H5O_info2_t oinfo; /* Stat the object */ - if(H5Oget_info_by_name3(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { + if (H5Oget_info_by_name3(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { error_msg("unable to get object information for \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; goto done; } /* end if */ - switch(oinfo.type) { - case H5O_TYPE_GROUP: - if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { - error_msg("unable to dump group \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - char *old_prefix; /* Pointer to previous prefix */ - - /* Keep copy of prefix before iterating into group */ - if((old_prefix = HDstrdup(prefix)) == NULL) { - error_msg("unable to allocate buffer\n"); + switch (oinfo.type) { + case H5O_TYPE_GROUP: + if ((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { + error_msg("unable to dump group \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { - /* Append group name to prefix */ - add_prefix(&prefix, &prefix_len, name); - - /* Iterate into group */ - dump_function_table->dump_group_function(obj, name); - - /* Restore old prefix name */ - HDstrcpy(prefix, old_prefix); - HDfree(old_prefix); - } - - /* Close group */ - H5Gclose(obj); - } - break; - - case H5O_TYPE_DATASET: - if((obj = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) { - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ - - found_obj = search_obj(dset_table, &oinfo.token); - - if(found_obj == NULL) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datasetbegin, name, - h5tools_dump_header_format->datasetblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datasetblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend); - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; + char *old_prefix; /* Pointer to previous prefix */ + /* Keep copy of prefix before iterating into group */ + if ((old_prefix = HDstrdup(prefix)) == NULL) { + error_msg("unable to allocate buffer\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - H5Dclose(obj); - goto done; } - else if(found_obj->displayed) { - /* the XML version */ - char *t_obj_path = xml_escape_the_name(obj_path); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_name = xml_escape_the_name(name); - char *t_objname = xml_escape_the_name(found_obj->objname); - char dsetxid[100]; - char parentxid[100]; - char pointerxid[100]; - - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(obj, obj_path, dsetxid, (int)sizeof(dsetxid), 1); - xml_name_to_XID(obj, prefix, parentxid, (int)sizeof(parentxid), 1); - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " - "H5Path=\"%s\" Parents=\"%s\" " - "H5ParentPaths=\"%s\">", - xmlnsprefix, - t_name, /* Dataset Name */ - dsetxid, get_next_xid(), /* OBJ-XID */ - t_obj_path, /* H5Path */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - xml_name_to_XID(obj, found_obj->objname, pointerxid, (int)sizeof(pointerxid), 1); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", - xmlnsprefix, - pointerxid,t_objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + else { + /* Append group name to prefix */ + add_prefix(&prefix, &prefix_len, name); - HDfree(t_name); - HDfree(t_obj_path); - HDfree(t_prefix); - HDfree(t_objname); + /* Iterate into group */ + dump_function_table->dump_group_function(obj, name); - H5Dclose(obj); - goto done; + /* Restore old prefix name */ + HDstrcpy(prefix, old_prefix); + HDfree(old_prefix); } - else - found_obj->displayed = TRUE; - } /* end if */ - dump_function_table->dump_dataset_function(obj, name, NULL); - H5Dclose(obj); - } - else { - error_msg("unable to dump dataset \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - break; + /* Close group */ + H5Gclose(obj); + } + break; - case H5O_TYPE_NAMED_DATATYPE: - if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) { - error_msg("unable to dump datatype \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - dump_function_table->dump_named_datatype_function(obj, name); - H5Tclose(obj); - } - break; + case H5O_TYPE_DATASET: + if ((obj = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) { + if (oinfo.rc > 1 || hit_elink) { + obj_t *found_obj; /* Found object */ + + found_obj = search_obj(dset_table, &oinfo.token); + + if (found_obj == NULL) { + ctx.indent_level++; + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s \"%s\" %s", + h5tools_dump_header_format->datasetbegin, name, + h5tools_dump_header_format->datasetblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + if (HDstrlen(h5tools_dump_header_format->datasetblockend)) { + h5tools_str_append(&buffer, "%s", + h5tools_dump_header_format->datasetblockend); + if (HDstrlen(h5tools_dump_header_format->datasetend)) + h5tools_str_append(&buffer, " "); + } + if (HDstrlen(h5tools_dump_header_format->datasetend)) + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + ctx.indent_level--; + + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + H5Dclose(obj); + goto done; + } + else if (found_obj->displayed) { + /* the XML version */ + char *t_obj_path = xml_escape_the_name(obj_path); + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix, "") ? prefix : "/"); + char *t_name = xml_escape_the_name(name); + char *t_objname = xml_escape_the_name(found_obj->objname); + char dsetxid[100]; + char parentxid[100]; + char pointerxid[100]; + + /* Create OBJ-XIDs for the parent and object */ + xml_name_to_XID(obj, obj_path, dsetxid, (int)sizeof(dsetxid), 1); + xml_name_to_XID(obj, prefix, parentxid, (int)sizeof(parentxid), 1); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, + "<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " + "H5Path=\"%s\" Parents=\"%s\" " + "H5ParentPaths=\"%s\">", + xmlnsprefix, t_name, /* Dataset Name */ + dsetxid, get_next_xid(), /* OBJ-XID */ + t_obj_path, /* H5Path */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + xml_name_to_XID(obj, found_obj->objname, pointerxid, (int)sizeof(pointerxid), 1); + + ctx.indent_level++; + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", + xmlnsprefix, pointerxid, t_objname); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + ctx.indent_level--; + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + HDfree(t_name); + HDfree(t_obj_path); + HDfree(t_prefix); + HDfree(t_objname); + + H5Dclose(obj); + goto done; + } + else + found_obj->displayed = TRUE; + } /* end if */ - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - error_msg("unknown object \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - } /* end if */ - else { - char *targbuf; + dump_function_table->dump_dataset_function(obj, name, NULL); + H5Dclose(obj); + } + else { + error_msg("unable to dump dataset \"%s\"\n", name); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + break; - switch(linfo->type) { - case H5L_TYPE_SOFT: - if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { - error_msg("unable to allocate buffer\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get link value\n"); + case H5O_TYPE_NAMED_DATATYPE: + if ((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) { + error_msg("unable to dump datatype \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { - /* print the value of a soft link */ - /* XML */ - char linkxid[100]; - char parentxid[100]; - char targetxid[100]; - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_name = xml_escape_the_name(name); - char *t_targbuf = xml_escape_the_name(targbuf); - char *t_obj_path = xml_escape_the_name(obj_path); - char *t_link_path; - int res; - - t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1); - if(targbuf[0] == '/') - HDstrcpy(t_link_path, targbuf); - else { - HDstrcpy(t_link_path, prefix); - HDstrcat(HDstrcat(t_link_path, "/"), targbuf); - } /* end else */ - - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(group, t_obj_path, linkxid, (int)sizeof(linkxid), 1); - xml_name_to_XID(group, prefix, parentxid, (int)sizeof(parentxid), 1); - - /* Try to create an OBJ-XID for the object pointed to */ - res = xml_name_to_XID(group, t_link_path, targetxid, (int)sizeof(targetxid), 0); - if (res == 0) { - /* target obj found */ - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetPath=\"%s\" TargetObj=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - t_targbuf, /* TargetPath */ - targetxid, /* TargetObj */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - /* dangling link -- omit from xml attributes */ - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - t_targbuf, /* TargetPath */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - HDfree(t_prefix); - HDfree(t_name); - HDfree(t_targbuf); - HDfree(t_obj_path); - HDfree(t_link_path); + dump_function_table->dump_named_datatype_function(obj, name); + H5Tclose(obj); } + break; - HDfree(targbuf); - } - break; - - case H5L_TYPE_EXTERNAL: - if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { - error_msg("unable to allocate buffer\n"); + case H5O_TYPE_MAP: + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + error_msg("unknown object \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } - else { - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get external link value\n"); + } + } /* end if */ + else { + char *targbuf; + + switch (linfo->type) { + case H5L_TYPE_SOFT: + if ((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { + error_msg("unable to allocate buffer\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } /* end if */ + } else { - const char *filename; - const char *targname; - - if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { - error_msg("unable to unpack external link value\n"); + if (H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { + error_msg("unable to get link value\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } /* end if */ + } else { - char linkxid[100]; - char parentxid[100]; - char *t_name = xml_escape_the_name(name); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + /* print the value of a soft link */ + /* XML */ + char linkxid[100]; + char parentxid[100]; + char targetxid[100]; + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix, "") ? prefix : "/"); + char *t_name = xml_escape_the_name(name); + char *t_targbuf = xml_escape_the_name(targbuf); char *t_obj_path = xml_escape_the_name(obj_path); - char *t_filename = xml_escape_the_name(filename); - char *t_targname = xml_escape_the_name(targname); + char *t_link_path; + int res; + + t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1); + if (targbuf[0] == '/') + HDstrcpy(t_link_path, targbuf); + else { + HDstrcpy(t_link_path, prefix); + HDstrcat(HDstrcat(t_link_path, "/"), targbuf); + } /* end else */ /* Create OBJ-XIDs for the parent and object */ xml_name_to_XID(group, t_obj_path, linkxid, (int)sizeof(linkxid), 1); xml_name_to_XID(group, prefix, parentxid, (int)sizeof(parentxid), 1); - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sExternalLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetFilename=\"%s\" " - "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - filename, /* TargetFilename */ - targname, /* TargetPath*/ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Try to create an OBJ-XID for the object pointed to */ + res = xml_name_to_XID(group, t_link_path, targetxid, (int)sizeof(targetxid), 0); + if (res == 0) { + /* target obj found */ + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, + "<%sSoftLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "TargetPath=\"%s\" TargetObj=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />", + xmlnsprefix, t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + t_targbuf, /* TargetPath */ + targetxid, /* TargetObj */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } + else { + /* dangling link -- omit from xml attributes */ + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, + "<%sSoftLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "TargetPath=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />", + xmlnsprefix, t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + t_targbuf, /* TargetPath */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } HDfree(t_prefix); HDfree(t_name); - HDfree(t_filename); - HDfree(t_targname); + HDfree(t_targbuf); HDfree(t_obj_path); - } /* end else */ - } /* end else */ - HDfree(targbuf); - } - break; + HDfree(t_link_path); + } - case H5L_TYPE_ERROR: - case H5L_TYPE_MAX: - case H5L_TYPE_HARD: - default: - { - char linkxid[100]; - char parentxid[100]; - char *t_name = xml_escape_the_name(name); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + HDfree(targbuf); + } + break; + + case H5L_TYPE_EXTERNAL: + if ((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { + error_msg("unable to allocate buffer\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + else { + if (H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { + error_msg("unable to get external link value\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } /* end if */ + else { + const char *filename; + const char *targname; + + if (H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { + error_msg("unable to unpack external link value\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } /* end if */ + else { + char linkxid[100]; + char parentxid[100]; + char *t_name = xml_escape_the_name(name); + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix, "") ? prefix : "/"); + char *t_obj_path = xml_escape_the_name(obj_path); + char *t_filename = xml_escape_the_name(filename); + char *t_targname = xml_escape_the_name(targname); + + /* Create OBJ-XIDs for the parent and object */ + xml_name_to_XID(group, t_obj_path, linkxid, (int)sizeof(linkxid), 1); + xml_name_to_XID(group, prefix, parentxid, (int)sizeof(parentxid), 1); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, + "<%sExternalLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "TargetFilename=\"%s\" " + "TargetPath=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />", + xmlnsprefix, t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + filename, /* TargetFilename */ + targname, /* TargetPath*/ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + HDfree(t_prefix); + HDfree(t_name); + HDfree(t_filename); + HDfree(t_targname); + HDfree(t_obj_path); + } /* end else */ + } /* end else */ + HDfree(targbuf); + } + break; + + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: + case H5L_TYPE_HARD: + default: { + char linkxid[100]; + char parentxid[100]; + char *t_name = xml_escape_the_name(name); + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix, "") ? prefix : "/"); char *t_obj_path = xml_escape_the_name(obj_path); /* Create OBJ-XIDs for the parent and object */ @@ -535,34 +542,34 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5 /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sUserDefined LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "LinkClass=\"%d\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - linfo->type, /* LinkClass */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, + "<%sUserDefined LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "LinkClass=\"%d\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />", + xmlnsprefix, t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + linfo->type, /* LinkClass */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_prefix); HDfree(t_name); HDfree(t_obj_path); - } - break; + } break; } /* end switch */ - } /* end else */ + } /* end else */ done: h5tools_str_close(&buffer); - if(obj_path) + if (obj_path) HDfree(obj_path); return ret; } @@ -578,10 +585,11 @@ int xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen) { H5O_token_t obj_token; - char *obj_tok_str = NULL; - int lookup_ret; + char * obj_tok_str = NULL; + int lookup_ret; - if (outlen < 22) return 1; + if (outlen < 22) + return 1; lookup_ret = ref_path_table_lookup(str, &obj_token); if (lookup_ret < 0) { @@ -625,11 +633,11 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen return 0; } -static const char *quote = """; -static const char *amp = "&"; -static const char *lt = "<"; -static const char *gt = ">"; -static const char *apos = "'"; +static const char *quote = """; +static const char *amp = "&"; +static const char *lt = "<"; +static const char *gt = ">"; +static const char *apos = "'"; /*------------------------------------------------------------------------- * Function: xml_escape_the_name @@ -642,22 +650,22 @@ static const char *apos = "'"; * Programmer: REMcG *------------------------------------------------------------------------- */ -static char * +static char * xml_escape_the_name(const char *str) { size_t extra; size_t len; size_t i; const char *cp; - char *ncp; - char *rcp; + char * ncp; + char * rcp; size_t ncp_len; if (!str) return NULL; - cp = str; - len = HDstrlen(str); + cp = str; + len = HDstrlen(str); extra = 0; for (i = 0; i < len; i++) { @@ -678,12 +686,12 @@ xml_escape_the_name(const char *str) if (extra == 0) return HDstrdup(str); - cp = str; + cp = str; ncp_len = len + extra + 1; rcp = ncp = (char *)HDmalloc(ncp_len); if (!ncp) - return NULL; /* ?? */ + return NULL; /* ?? */ for (i = 0; i < len; i++) { size_t esc_len; @@ -709,7 +717,7 @@ xml_escape_the_name(const char *str) esc_len = HDstrlen(amp); } else { - *ncp = *cp; + *ncp = *cp; esc_len = 1; } ncp += esc_len; @@ -738,9 +746,9 @@ xml_escape_the_string(const char *str, int slen) size_t extra; size_t len; size_t i; - const char *cp = NULL; - char *ncp = NULL; - char *rcp = NULL; + const char *cp = NULL; + char * ncp = NULL; + char * rcp = NULL; size_t ncp_len; if (!str) @@ -771,9 +779,9 @@ xml_escape_the_string(const char *str, int slen) cp++; } - cp = str; + cp = str; ncp_len = len + extra + 1; - rcp = ncp = (char *) HDcalloc(ncp_len, sizeof(char)); + rcp = ncp = (char *)HDcalloc(ncp_len, sizeof(char)); if (ncp == NULL) return NULL; /* ?? */ @@ -784,13 +792,13 @@ xml_escape_the_string(const char *str, int slen) if (*cp == '\\') { *ncp++ = '\\'; ncp_len--; - *ncp = *cp; + *ncp = *cp; esc_len = 1; } else if (*cp == '\"') { *ncp++ = '\\'; ncp_len--; - *ncp = *cp; + *ncp = *cp; esc_len = 1; } else if (*cp == '\'') { @@ -810,7 +818,7 @@ xml_escape_the_string(const char *str, int slen) esc_len = HDstrlen(amp); } else { - *ncp = *cp; + *ncp = *cp; esc_len = 1; } ncp += esc_len; @@ -841,69 +849,69 @@ xml_escape_the_string(const char *str, int slen) static void xml_print_datatype(hid_t type, unsigned in_group) { - char *mname; - hid_t mtype; - unsigned nmembers; - unsigned ndims; - unsigned i; - size_t size; - hsize_t dims[H5DUMP_MAX_RANK]; - H5T_str_t str_pad; - H5T_cset_t cset; - hid_t super; - H5T_order_t ord; - H5T_sign_t sgn; - size_t sz; - size_t spos; - size_t epos; - size_t esize; - size_t mpos; - size_t msize; - int nmembs; - htri_t is_vlstr = FALSE; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + char * mname; + hid_t mtype; + unsigned nmembers; + unsigned ndims; + unsigned i; + size_t size; + hsize_t dims[H5DUMP_MAX_RANK]; + H5T_str_t str_pad; + H5T_cset_t cset; + hid_t super; + H5T_order_t ord; + H5T_sign_t sgn; + size_t sz; + size_t spos; + size_t epos; + size_t esize; + size_t mpos; + size_t msize; + int nmembs; + htri_t is_vlstr = FALSE; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; + h5tool_format_t string_dataformat; + hsize_t curr_pos = 0; /* total data element position */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { - string_dataformat.line_ncols = 65535; + if (h5tools_nCols == 0) { + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; - if(!in_group && H5Tcommitted(type) > 0) { + if (!in_group && H5Tcommitted(type) > 0) { H5O_info2_t oinfo; - obj_t *found_obj; /* Found object */ + obj_t * found_obj; /* Found object */ /* detect a shared datatype, output only once */ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC); found_obj = search_obj(type_table, &oinfo.token); - if(found_obj) { + if (found_obj) { /* This should be defined somewhere else */ /* These 2 cases are handled the same right now, but probably will have something different eventually */ - char * dtxid = (char *)HDmalloc((size_t)100); + char *dtxid = (char *)HDmalloc((size_t)100); xml_name_to_XID(type, found_obj->objname, dtxid, 100, 1); if (!found_obj->recorded) { @@ -914,9 +922,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>", - xmlnsprefix, dtxid); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>", xmlnsprefix, dtxid); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { /* point to the NDT by name */ @@ -926,9 +934,10 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", - xmlnsprefix, dtxid, t_objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", xmlnsprefix, + dtxid, t_objname); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_objname); } HDfree(dtxid); @@ -939,7 +948,8 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_setstatus(EXIT_FAILURE); } } @@ -950,8 +960,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; /* */ @@ -962,7 +973,7 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sIntegerType ByteOrder=\"",xmlnsprefix); + h5tools_str_append(&buffer, "<%sIntegerType ByteOrder=\"", xmlnsprefix); switch (ord) { case H5T_ORDER_LE: h5tools_str_append(&buffer, "LE"); @@ -999,15 +1010,17 @@ xml_print_datatype(hid_t type, unsigned in_group) sz = H5Tget_size(type); h5tools_str_append(&buffer, "%lu", (unsigned long)sz); h5tools_str_append(&buffer, "\" />"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_FLOAT: @@ -1021,15 +1034,16 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sFloatType ByteOrder=\"",xmlnsprefix); + h5tools_str_append(&buffer, "<%sFloatType ByteOrder=\"", xmlnsprefix); switch (ord) { case H5T_ORDER_LE: @@ -1053,17 +1067,21 @@ xml_print_datatype(hid_t type, unsigned in_group) h5tools_str_append(&buffer, "%lu", (unsigned long)sz); H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize); h5tools_str_append(&buffer, "\" SignBitLocation=\"%lu\" ", (unsigned long)spos); - h5tools_str_append(&buffer, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos); - h5tools_str_append(&buffer, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />", (unsigned long)msize, (unsigned long)mpos); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", + (unsigned long)esize, (unsigned long)epos); + h5tools_str_append(&buffer, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />", + (unsigned long)msize, (unsigned long)mpos); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_TIME: @@ -1071,16 +1089,18 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sTimeType />",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sTimeType />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_append(&buffer, ""); ctx.indent_level--; @@ -1088,23 +1108,25 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_STRING: /* */ - size = H5Tget_size(type); - str_pad = H5Tget_strpad(type); - cset = H5Tget_cset(type); + size = H5Tget_size(type); + str_pad = H5Tget_strpad(type); + cset = H5Tget_cset(type); is_vlstr = H5Tis_variable_str(type); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; @@ -1112,17 +1134,17 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sStringType Cset=\"",xmlnsprefix); + h5tools_str_append(&buffer, "<%sStringType Cset=\"", xmlnsprefix); if (cset == H5T_CSET_ASCII) h5tools_str_append(&buffer, "H5T_CSET_ASCII\" "); else h5tools_str_append(&buffer, "unknown_cset\" "); - if(is_vlstr) + if (is_vlstr) h5tools_str_append(&buffer, "StrSize=\"H5T_VARIABLE\" StrPad=\""); else - h5tools_str_append(&buffer, "StrSize=\"%d\" StrPad=\"", (int) size); + h5tools_str_append(&buffer, "StrSize=\"%d\" StrPad=\"", (int)size); if (str_pad == H5T_STR_NULLTERM) h5tools_str_append(&buffer, "H5T_STR_NULLTERM\"/>"); @@ -1132,15 +1154,17 @@ xml_print_datatype(hid_t type, unsigned in_group) h5tools_str_append(&buffer, "H5T_STR_SPACEPAD\"/>"); else h5tools_str_append(&buffer, "H5T_STR_ERROR\"/>"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_BITFIELD: @@ -1151,15 +1175,16 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sBitfieldType ByteOrder=\"",xmlnsprefix); + h5tools_str_append(&buffer, "<%sBitfieldType ByteOrder=\"", xmlnsprefix); switch (ord) { case H5T_ORDER_LE: @@ -1178,15 +1203,17 @@ xml_print_datatype(hid_t type, unsigned in_group) size = H5Tget_size(type); h5tools_str_append(&buffer, "\" Size=\"%lu\"/>", (unsigned long)size); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_OPAQUE: @@ -1196,8 +1223,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; mname = H5Tget_tag(type); @@ -1205,19 +1233,21 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname); + h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ", xmlnsprefix, mname); H5free_memory(mname); size = H5Tget_size(type); h5tools_str_append(&buffer, "Size=\"%lu\"/>", (unsigned long)size); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_COMPOUND: @@ -1230,8 +1260,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sCompoundType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sCompoundType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); /* List each member Field of the type */ /* */ @@ -1241,16 +1272,17 @@ xml_print_datatype(hid_t type, unsigned in_group) for (i = 0; i < nmembers; i++) { char *t_fname; - mname = H5Tget_member_name(type, i); - mtype = H5Tget_member_type(type, i); + mname = H5Tget_member_name(type, i); + mtype = H5Tget_member_type(type, i); t_fname = xml_escape_the_name(mname); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">",xmlnsprefix, t_fname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">", xmlnsprefix, t_fname); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); H5free_memory(mname); HDfree(t_fname); @@ -1261,11 +1293,12 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; - xml_print_datatype(mtype,0); + xml_print_datatype(mtype, 0); dump_indent -= COL; ctx.indent_level--; @@ -1273,8 +1306,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); dump_indent -= COL; ctx.indent_level--; @@ -1282,8 +1316,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } dump_indent -= COL; ctx.indent_level--; @@ -1292,8 +1327,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_REFERENCE: @@ -1301,8 +1337,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; /* Only Object references supported at this time */ @@ -1310,32 +1347,36 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sReferenceType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sReferenceType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sObjectReferenceType />",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sObjectReferenceType />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_ENUM: @@ -1346,8 +1387,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); dump_indent += COL; ctx.indent_level++; @@ -1355,16 +1397,18 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sEnumType Nelems=\"%d\">",xmlnsprefix, nmembs); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sEnumType Nelems=\"%d\">", xmlnsprefix, nmembs); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); xml_print_enum(type); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); dump_indent -= COL; ctx.indent_level--; @@ -1372,8 +1416,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); break; case H5T_VLEN: @@ -1381,8 +1426,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sVLType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sVLType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); super = H5Tget_super(type); dump_indent += COL; ctx.indent_level++; @@ -1391,11 +1437,12 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); dump_indent += COL; ctx.indent_level++; - xml_print_datatype(super,0); + xml_print_datatype(super, 0); dump_indent -= COL; ctx.indent_level--; @@ -1403,8 +1450,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); dump_indent -= COL; ctx.indent_level--; @@ -1412,8 +1460,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); H5Tclose(super); break; @@ -1427,10 +1476,11 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sArrayType Ndims=\"",xmlnsprefix); + h5tools_str_append(&buffer, "<%sArrayType Ndims=\"", xmlnsprefix); ndims = (unsigned)H5Tget_array_ndims(type); h5tools_str_append(&buffer, "%u\">", ndims); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); /* Get array information */ H5Tget_array_dims2(type, dims); @@ -1442,8 +1492,10 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sArrayDimension DimSize=\"%u\"/>", xmlnsprefix, (int) dims[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sArrayDimension DimSize=\"%u\"/>", xmlnsprefix, + (int)dims[i]); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } ctx.indent_level--; @@ -1454,11 +1506,12 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); dump_indent += COL; ctx.indent_level++; - xml_print_datatype(super,0); + xml_print_datatype(super, 0); dump_indent -= COL; ctx.indent_level--; @@ -1466,8 +1519,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); dump_indent -= COL; ctx.indent_level--; @@ -1475,8 +1529,9 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); /* Close array base type */ H5Tclose(super); break; @@ -1489,7 +1544,8 @@ xml_print_datatype(hid_t type, unsigned in_group) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_setstatus(EXIT_FAILURE); break; } @@ -1511,48 +1567,48 @@ xml_print_datatype(hid_t type, unsigned in_group) void xml_dump_datatype(hid_t type) { - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; ctx.indent_level++; dump_indent += COL; - if(H5Tcommitted(type) > 0) { + if (H5Tcommitted(type) > 0) { H5O_info2_t oinfo; - obj_t *found_obj; /* Found object */ + obj_t * found_obj; /* Found object */ /* Datatype is a shared or named datatype */ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC); found_obj = search_obj(type_table, &oinfo.token); - if(found_obj) { + if (found_obj) { /* Shared datatype, must be entered as an object */ /* These 2 cases are the same now, but may change */ char *dtxid = (char *)HDmalloc((size_t)100); @@ -1569,9 +1625,9 @@ xml_dump_datatype(hid_t type) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\"/>", - xmlnsprefix, dtxid); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\"/>", xmlnsprefix, dtxid); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { /* pointer to a named datatype already in XML */ @@ -1582,8 +1638,9 @@ xml_dump_datatype(hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />", - xmlnsprefix, dtxid, t_objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + xmlnsprefix, dtxid, t_objname); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_objname); } HDfree(dtxid); @@ -1594,7 +1651,8 @@ xml_dump_datatype(hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } } else { @@ -1603,7 +1661,8 @@ xml_dump_datatype(hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; xml_print_datatype(type, 0); @@ -1615,7 +1674,8 @@ xml_dump_datatype(hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } ctx.indent_level--; dump_indent -= COL; @@ -1639,38 +1699,38 @@ xml_dump_dataspace(hid_t space) hsize_t size[H5DUMP_MAX_RANK]; hsize_t maxsize[H5DUMP_MAX_RANK]; int i; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ - int ndims = H5Sget_simple_extent_dims(space, size, maxsize); - H5S_class_t space_type = H5Sget_simple_extent_type(space); + int ndims = H5Sget_simple_extent_dims(space, size, maxsize); + H5S_class_t space_type = H5Sget_simple_extent_type(space); /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; ctx.indent_level++; @@ -1679,96 +1739,111 @@ xml_dump_dataspace(hid_t space) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sDataspace>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; switch (space_type) { - case H5S_SCALAR: - /* scalar dataspace (just a tag, no XML attrs. defined */ + case H5S_SCALAR: + /* scalar dataspace (just a tag, no XML attrs. defined */ - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sScalarDataspace />",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sScalarDataspace />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; - case H5S_SIMPLE: - /* simple dataspace */ - /* */ + case H5S_SIMPLE: + /* simple dataspace */ + /* */ - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSimpleDataspace Ndims=\"%d\">",xmlnsprefix, ndims); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sSimpleDataspace Ndims=\"%d\">", xmlnsprefix, ndims); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* print the elements */ - ctx.indent_level++; - for (i = 0; i < ndims; i++) { - if (maxsize[i] == H5S_UNLIMITED) { - ctx.need_prefix = TRUE; + /* print the elements */ + ctx.indent_level++; + for (i = 0; i < ndims; i++) { + if (maxsize[i] == H5S_UNLIMITED) { + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"UNLIMITED\"/>", - xmlnsprefix,size[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else if (maxsize[i] == (hsize_t) 0) { - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, + "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH + "u\" MaxDimSize=\"UNLIMITED\"/>", + xmlnsprefix, size[i]); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } + else if (maxsize[i] == (hsize_t)0) { + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>", - xmlnsprefix,size[i], size[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, + "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH + "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>", + xmlnsprefix, size[i], size[i]); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } + else { + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>", - xmlnsprefix, size[i], maxsize[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, + "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH + "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>", + xmlnsprefix, size[i], maxsize[i]); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } } - } - ctx.indent_level--; + ctx.indent_level--; - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix ); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; #ifdef TMP - /* Commented out: wait until the schema is updated first */ - case H5S_NULL: - /* null dataspace (just a tag, no XML attrs. defined */ + /* Commented out: wait until the schema is updated first */ + case H5S_NULL: + /* null dataspace (just a tag, no XML attrs. defined */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNullDataspace />",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNullDataspace />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; #endif /* TMP */ - case H5S_NULL: - case H5S_NO_CLASS: - default: - ctx.need_prefix = TRUE; + case H5S_NULL: + case H5S_NO_CLASS: + default: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } ctx.indent_level--; @@ -1778,7 +1853,8 @@ xml_dump_dataspace(hid_t space) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; h5tools_str_close(&buffer); @@ -1797,19 +1873,19 @@ xml_dump_dataspace(hid_t space) void xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, int H5_ATTR_UNUSED pindex) { - hid_t space = H5I_INVALID_HID; - hid_t type = H5I_INVALID_HID; - hid_t p_type = H5I_INVALID_HID; - int status = -1; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; + hid_t space = H5I_INVALID_HID; + hid_t type = H5I_INVALID_HID; + hid_t p_type = H5I_INVALID_HID; + int status = -1; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; + h5tool_format_t string_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; /* Print all the values. */ /* setup */ @@ -1819,29 +1895,30 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.cmpd_sep = " "; - string_dataformat.cmpd_pre = ""; - string_dataformat.cmpd_suf = ""; - string_dataformat.cmpd_end = ""; + string_dataformat.cmpd_sep = " "; + string_dataformat.cmpd_pre = ""; + string_dataformat.cmpd_suf = ""; + string_dataformat.cmpd_end = ""; string_dataformat.arr_linebreak = 0; - string_dataformat.arr_pre = ""; - outputformat = &string_dataformat; + string_dataformat.arr_pre = ""; + outputformat = &string_dataformat; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; @@ -1850,7 +1927,8 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; @@ -1866,10 +1944,10 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, else { h5tools_context_t datactx; HDmemset(&datactx, 0, sizeof(datactx)); - datactx.need_prefix = TRUE; + datactx.need_prefix = TRUE; datactx.indent_level = ctx.indent_level; - datactx.cur_column = ctx.cur_column; - status = h5tools_dump_dset(rawoutstream, outputformat, &datactx, obj_id); + datactx.cur_column = ctx.cur_column; + status = h5tools_dump_dset(rawoutstream, outputformat, &datactx, obj_id); } } else { @@ -1888,18 +1966,18 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, else if (H5Tget_class(type) == H5T_STRING) { status = xml_print_strs(obj_id, ATTRIBUTE_DATA); } - else { /* all other data */ + else { /* all other data */ space = H5Aget_space(obj_id); - if(space == H5S_NULL || space == H5S_NO_CLASS) { + if (space == H5S_NULL || space == H5S_NO_CLASS) { status = SUCCEED; } else { h5tools_context_t datactx; HDmemset(&datactx, 0, sizeof(datactx)); - datactx.need_prefix = TRUE; + datactx.need_prefix = TRUE; datactx.indent_level = ctx.indent_level; - datactx.cur_column = ctx.cur_column; - status = h5tools_dump_mem(rawoutstream, outputformat, &datactx, obj_id); + datactx.cur_column = ctx.cur_column; + status = h5tools_dump_mem(rawoutstream, outputformat, &datactx, obj_id); } H5Tclose(p_type); H5Sclose(space); @@ -1915,7 +1993,8 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "Unable to print data."); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; @@ -1930,8 +2009,9 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; @@ -1940,7 +2020,8 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); } @@ -1957,16 +2038,16 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, */ herr_t xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *info, - void H5_ATTR_UNUSED * op_data) + void H5_ATTR_UNUSED *op_data) { hid_t attr_id = H5I_INVALID_HID; - hid_t type = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; + hid_t type = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; H5S_class_t space_type; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; char *t_aname = xml_escape_the_name(attr_name); @@ -1976,36 +2057,37 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sAttribute Name=\"%s\">", xmlnsprefix, t_aname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_aname); if ((attr_id = H5Aopen(attr, attr_name, H5P_DEFAULT)) >= 0) { - type = H5Aget_type(attr_id); - space = H5Aget_space(attr_id); + type = H5Aget_type(attr_id); + space = H5Aget_space(attr_id); space_type = H5Sget_simple_extent_type(space); dump_function_table->dump_dataspace_function(space); @@ -2016,158 +2098,175 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED if (dump_opts.display_attr_data && space_type != H5S_NULL) { switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; + + case H5T_TIME: + ctx.indent_level++; + dump_indent += COL; - case H5T_TIME: - ctx.indent_level++; - dump_indent += COL; + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.indent_level--; + dump_indent -= COL; + break; - ctx.indent_level--; - dump_indent -= COL; - break; + case H5T_COMPOUND: + ctx.need_prefix = TRUE; - case H5T_COMPOUND: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; + case H5T_REFERENCE: + ctx.need_prefix = TRUE; - case H5T_REFERENCE: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + if (!H5Tequal(type, H5T_STD_REF_OBJ)) { + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } + else { + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + xml_print_refs(attr_id, ATTRIBUTE_DATA); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_VLEN: ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); + break; + case H5T_NO_CLASS: + case H5T_NCLASSES: + default: ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - xml_print_refs(attr_id, ATTRIBUTE_DATA); + h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_VLEN: - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - case H5T_NO_CLASS: - case H5T_NCLASSES: - default: - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", H5Tget_class(type)); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", H5Tget_class(type)); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; } } else { @@ -2178,7 +2277,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; @@ -2187,7 +2287,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; @@ -2196,7 +2297,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } ctx.indent_level--; dump_indent -= COL; @@ -2210,7 +2312,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); return SUCCEED; @@ -2224,7 +2327,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; @@ -2233,7 +2337,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); @@ -2255,17 +2360,17 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED void xml_dump_named_datatype(hid_t type, const char *name) { - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; - char *tmp; - char *dtxid; - char *parentxid; - char *t_tmp; - char *t_prefix; - char *t_name; + char * tmp; + char * dtxid; + char * parentxid; + char * t_tmp; + char * t_prefix; + char * t_name; tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDstrcpy(tmp, prefix); @@ -2277,34 +2382,34 @@ xml_dump_named_datatype(hid_t type, const char *name) HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; - dtxid = (char *)HDmalloc((size_t)100); + dtxid = (char *)HDmalloc((size_t)100); parentxid = (char *)HDmalloc((size_t)100); - t_tmp = xml_escape_the_name(tmp); - t_prefix = xml_escape_the_name(prefix); - t_name = xml_escape_the_name(name); + t_tmp = xml_escape_the_name(tmp); + t_prefix = xml_escape_the_name(prefix); + t_name = xml_escape_the_name(name); xml_name_to_XID(type, tmp, dtxid, 100, 1); xml_name_to_XID(type, prefix, parentxid, 100, 1); - if(HDstrncmp(name, "#", (size_t)1) == 0) { + if (HDstrncmp(name, "#", (size_t)1) == 0) { /* Special: this is an 'anonymous' NDT, deleted but still in use. We follow the dumper's undocumented practice, and @@ -2318,31 +2423,32 @@ xml_dump_named_datatype(hid_t type, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\">", - xmlnsprefix, - name, dtxid, - parentxid, HDstrcmp(prefix,"") ? t_prefix : "/"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, + "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\">", + xmlnsprefix, name, dtxid, parentxid, HDstrcmp(prefix, "") ? t_prefix : "/"); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { - H5O_info2_t oinfo; /* Object info */ + H5O_info2_t oinfo; /* Object info */ ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " - "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">", - xmlnsprefix, - t_name, dtxid, - t_tmp, parentxid, (HDstrcmp(prefix, "") ? t_prefix : "/")); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, + "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " + "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">", + xmlnsprefix, t_name, dtxid, t_tmp, parentxid, + (HDstrcmp(prefix, "") ? t_prefix : "/")); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); /* Check uniqueness of named datatype */ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC); - if(oinfo.rc > 1) { - obj_t *found_obj; /* Found object */ + if (oinfo.rc > 1) { + obj_t *found_obj; /* Found object */ /* Group with more than one link to it... */ found_obj = search_obj(type_table, &oinfo.token); @@ -2353,11 +2459,11 @@ xml_dump_named_datatype(hid_t type, const char *name) h5tools_setstatus(EXIT_FAILURE); goto done; } - else if(found_obj->displayed) { + else if (found_obj->displayed) { /* We have already printed this named datatype, print it as a * NamedDatatypePtr */ - char pointerxid[100]; + char pointerxid[100]; char *t_objname = xml_escape_the_name(found_obj->objname); ctx.indent_level++; @@ -2368,8 +2474,10 @@ xml_dump_named_datatype(hid_t type, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", xmlnsprefix, pointerxid, t_objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", xmlnsprefix, + pointerxid, t_objname); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; @@ -2378,7 +2486,8 @@ xml_dump_named_datatype(hid_t type, const char *name) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_objname); goto done; } @@ -2394,12 +2503,13 @@ xml_dump_named_datatype(hid_t type, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; - xml_print_datatype(type,1); + xml_print_datatype(type, 1); ctx.indent_level--; dump_indent -= COL; @@ -2407,8 +2517,9 @@ xml_dump_named_datatype(hid_t type, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; dump_indent -= COL; @@ -2417,8 +2528,9 @@ xml_dump_named_datatype(hid_t type, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); done: @@ -2445,23 +2557,23 @@ done: void xml_dump_group(hid_t gid, const char *name) { - H5O_info2_t oinfo; - hid_t gcpl_id; - hid_t dset, type; - unsigned crt_order_flags; - unsigned attr_crt_order_flags; - int isRoot = 0; - char type_name[1024]; - char *t_objname = NULL; - char *par_name = NULL; - char *cp = NULL; - char *tmp = NULL; - char *par = NULL; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + H5O_info2_t oinfo; + hid_t gcpl_id; + hid_t dset, type; + unsigned crt_order_flags; + unsigned attr_crt_order_flags; + int isRoot = 0; + char type_name[1024]; + char * t_objname = NULL; + char * par_name = NULL; + char * cp = NULL; + char * tmp = NULL; + char * par = NULL; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; + h5tool_format_t string_dataformat; + hsize_t curr_pos = 0; /* total data element position */ if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { error_msg("error in getting group creation property list ID\n"); @@ -2475,12 +2587,12 @@ xml_dump_group(hid_t gid, const char *name) } /* query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { + if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { error_msg("error in getting group creation properties\n"); h5tools_setstatus(EXIT_FAILURE); } - if(H5Pclose(gcpl_id) < 0) { + if (H5Pclose(gcpl_id) < 0) { error_msg("error in closing group creation property list ID\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -2490,36 +2602,36 @@ xml_dump_group(hid_t gid, const char *name) HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; - if(HDstrcmp(name, "/") == 0) { + if (HDstrcmp(name, "/") == 0) { isRoot = 1; - tmp = HDstrdup("/"); + tmp = HDstrdup("/"); } else { tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDstrcpy(tmp, prefix); par = HDstrdup(tmp); - cp = HDstrrchr(par, '/'); - if(cp) { - if((cp == par) && HDstrlen(par) > 1) + cp = HDstrrchr(par, '/'); + if (cp) { + if ((cp == par) && HDstrlen(par) > 1) *(cp + 1) = '\0'; else *cp = '\0'; @@ -2528,8 +2640,8 @@ xml_dump_group(hid_t gid, const char *name) H5Oget_info3(gid, &oinfo, H5O_INFO_BASIC); - if(oinfo.rc > 1) { - obj_t *found_obj; /* Found object */ + if (oinfo.rc > 1) { + obj_t *found_obj; /* Found object */ /* Group with more than one link to it... */ found_obj = search_obj(group_table, &oinfo.token); @@ -2540,15 +2652,15 @@ xml_dump_group(hid_t gid, const char *name) h5tools_setstatus(EXIT_FAILURE); } else { - char *t_name = xml_escape_the_name(name); - char *grpxid = (char *)HDmalloc((size_t)100); + char *t_name = xml_escape_the_name(name); + char *grpxid = (char *)HDmalloc((size_t)100); char *parentxid = (char *)HDmalloc((size_t)100); - if(found_obj->displayed) { + if (found_obj->displayed) { char *ptrstr = (char *)HDmalloc((size_t)100); /* already seen: enter a groupptr */ - if(isRoot) { + if (isRoot) { /* probably can't happen! */ xml_name_to_XID(gid, "/", grpxid, 100, 1); @@ -2556,13 +2668,14 @@ xml_dump_group(hid_t gid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", - xmlnsprefix, grpxid, "/"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix, + grpxid, "/"); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { t_objname = xml_escape_the_name(found_obj->objname); - par_name = xml_escape_the_name(par); + par_name = xml_escape_the_name(par); xml_name_to_XID(gid, tmp, grpxid, 100, 1); xml_name_to_XID(gid, par, parentxid, 100, 1); @@ -2570,18 +2683,20 @@ xml_dump_group(hid_t gid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\">", - xmlnsprefix,t_name, grpxid, get_next_xid(), - t_objname, parentxid, par_name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, + "<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\">", + xmlnsprefix, t_name, grpxid, get_next_xid(), t_objname, parentxid, + par_name); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_objname); HDfree(par_name); ctx.indent_level++; - t_objname = xml_escape_the_name(found_obj->objname);/* point to the NDT by name */ - par_name = xml_escape_the_name(par); + t_objname = xml_escape_the_name(found_obj->objname); /* point to the NDT by name */ + par_name = xml_escape_the_name(par); xml_name_to_XID(gid, found_obj->objname, ptrstr, 100, 1); xml_name_to_XID(gid, par, parentxid, 100, 1); @@ -2589,11 +2704,12 @@ xml_dump_group(hid_t gid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - ptrstr, t_objname, parentxid, par_name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, + "<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />", + xmlnsprefix, ptrstr, t_objname, parentxid, par_name); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; @@ -2605,16 +2721,17 @@ xml_dump_group(hid_t gid, const char *name) else { /* first time this group has been seen -- describe it */ - if(isRoot) { + if (isRoot) { xml_name_to_XID(gid, "/", grpxid, 100, 1); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", - xmlnsprefix, grpxid, "/"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix, + grpxid, "/"); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { char *t_tmp = xml_escape_the_name(tmp); @@ -2627,10 +2744,12 @@ xml_dump_group(hid_t gid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" >", - xmlnsprefix,t_name, grpxid, t_tmp, parentxid, par_name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, + "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" >", + xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_tmp); HDfree(par_name); @@ -2642,25 +2761,27 @@ xml_dump_group(hid_t gid, const char *name) ctx.indent_level++; dump_indent += COL; - if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { + if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { + if (H5Aiterate2(gid, sort_by, sort_order, NULL, + dump_function_table->dump_attribute_function, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - } /* end if */ + } /* end if */ else { - if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { + if (H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, + dump_function_table->dump_attribute_function, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - } /* end else */ + } /* end else */ - if(isRoot && unamedtype) { + if (isRoot && unamedtype) { unsigned u; /* Very special case: dump unamed type in root group */ - for(u = 0; u < type_table->nobjs; u++) { - if(!type_table->objs[u].recorded) { + for (u = 0; u < type_table->nobjs; u++) { + if (!type_table->objs[u].recorded) { char *obj_tok_str = NULL; dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); @@ -2679,7 +2800,7 @@ xml_dump_group(hid_t gid, const char *name) /* iterate through all the links */ - if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) + if ((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) H5Literate2(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL); else H5Literate2(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL); @@ -2694,8 +2815,8 @@ xml_dump_group(hid_t gid, const char *name) } else { /* only link -- must be first time! */ - char *t_name = xml_escape_the_name(name); - char *grpxid = (char *)HDmalloc((size_t)100); + char *t_name = xml_escape_the_name(name); + char *grpxid = (char *)HDmalloc((size_t)100); char *parentxid = (char *)HDmalloc((size_t)100); ctx.need_prefix = TRUE; @@ -2703,9 +2824,10 @@ xml_dump_group(hid_t gid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - if(isRoot) { + if (isRoot) { xml_name_to_XID(gid, "/", grpxid, 100, 1); - h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix, grpxid, "/"); + h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix, grpxid, + "/"); } else { char *t_tmp = xml_escape_the_name(tmp); @@ -2713,13 +2835,15 @@ xml_dump_group(hid_t gid, const char *name) par_name = xml_escape_the_name(par); xml_name_to_XID(gid, tmp, grpxid, 100, 1); xml_name_to_XID(gid, par, parentxid, 100, 1); - h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" >", - xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name); + h5tools_str_append(&buffer, + "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" >", + xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name); HDfree(t_tmp); HDfree(par_name); } - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_name); HDfree(grpxid); @@ -2730,25 +2854,27 @@ xml_dump_group(hid_t gid, const char *name) ctx.indent_level++; dump_indent += COL; - if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { + if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { + if (H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, + NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - } /* end if */ + } /* end if */ else { - if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { + if (H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, + dump_function_table->dump_attribute_function, NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - } /* end else */ + } /* end else */ - if(isRoot && unamedtype) { + if (isRoot && unamedtype) { unsigned u; /* Very special case: dump unamed type in root group */ - for(u = 0; u < type_table->nobjs; u++) { - if(!type_table->objs[u].recorded) { + for (u = 0; u < type_table->nobjs; u++) { + if (!type_table->objs[u].recorded) { char *obj_tok_str = NULL; dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); @@ -2767,7 +2893,7 @@ xml_dump_group(hid_t gid, const char *name) /* iterate through all the links */ - if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) + if ((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) H5Literate2(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL); else H5Literate2(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL); @@ -2780,17 +2906,18 @@ xml_dump_group(hid_t gid, const char *name) /* Render the element */ h5tools_str_reset(&buffer); - if(isRoot) + if (isRoot) h5tools_str_append(&buffer, "", xmlnsprefix); else h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); - if(par) + if (par) HDfree(par); - if(tmp) + if (tmp) HDfree(tmp); } @@ -2808,17 +2935,17 @@ static int xml_print_refs(hid_t did, int source) { herr_t e; - hid_t type = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hssize_t ssiz = -1; + hid_t type = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hssize_t ssiz = -1; hsize_t i; - H5R_ref_t *refbuf = NULL; - char *buf = NULL; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + H5R_ref_t * refbuf = NULL; + char * buf = NULL; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ if (source == DATASET_DATA) { type = H5Dget_type(did); @@ -2844,7 +2971,7 @@ xml_print_refs(hid_t did, int source) if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0) goto error; - buf = (char *) HDcalloc((size_t)ssiz, sizeof(H5R_ref_t)); + buf = (char *)HDcalloc((size_t)ssiz, sizeof(H5R_ref_t)); if (buf == NULL) goto error; e = H5Dread(did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); @@ -2857,7 +2984,7 @@ xml_print_refs(hid_t did, int source) if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0) goto error; - buf = (char *) HDcalloc((size_t)ssiz, sizeof(H5R_ref_t)); + buf = (char *)HDcalloc((size_t)ssiz, sizeof(H5R_ref_t)); if (buf == NULL) goto error; e = H5Aread(did, H5T_STD_REF, buf); @@ -2873,24 +3000,24 @@ xml_print_refs(hid_t did, int source) HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; for (i = 0; i < (hsize_t)ssiz; i++) { const char *path = lookup_ref_path(*refbuf); @@ -2902,7 +3029,8 @@ xml_print_refs(hid_t did, int source) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\"%s\"", "NULL"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { char *t_path = xml_escape_the_string(path, -1); @@ -2912,7 +3040,8 @@ xml_print_refs(hid_t did, int source) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\"%s\"", t_path); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_path); } ctx.indent_level--; @@ -2930,13 +3059,15 @@ xml_print_refs(hid_t did, int source) return SUCCEED; error: - if(buf) + if (buf) HDfree(buf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(type); H5Sclose(space); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } @@ -2954,21 +3085,21 @@ static int xml_print_strs(hid_t did, int source) { herr_t e; - hid_t type = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hssize_t ssiz = -1; + hid_t type = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hssize_t ssiz = -1; htri_t is_vlstr = FALSE; - size_t tsiz = 0; + size_t tsiz = 0; hsize_t i; - size_t str_size = 0; - char *bp = NULL; - char *onestring = NULL; - void *buf = NULL; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + size_t str_size = 0; + char * bp = NULL; + char * onestring = NULL; + void * buf = NULL; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ if (source == DATASET_DATA) type = H5Dget_type(did); @@ -2985,9 +3116,9 @@ xml_print_strs(hid_t did, int source) if (source == DATASET_DATA) { space = H5Dget_space(did); - if((ssiz = H5Sget_simple_extent_npoints(space)) < 0) + if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0) goto error; - if((tsiz = H5Tget_size(type)) == 0) + if ((tsiz = H5Tget_size(type)) == 0) goto error; buf = HDmalloc((size_t)ssiz * tsiz); @@ -3000,9 +3131,9 @@ xml_print_strs(hid_t did, int source) } else if (source == ATTRIBUTE_DATA) { space = H5Aget_space(did); - if((ssiz = H5Sget_simple_extent_npoints(space)) < 0) + if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0) goto error; - if((tsiz = H5Tget_size(type)) == 0) + if ((tsiz = H5Tget_size(type)) == 0) goto error; buf = HDmalloc((size_t)ssiz * tsiz); @@ -3014,33 +3145,33 @@ xml_print_strs(hid_t did, int source) goto error; } - bp = (char*) buf; + bp = (char *)buf; if (!is_vlstr) - onestring = (char *) HDcalloc(tsiz, sizeof(char)); + onestring = (char *)HDcalloc(tsiz, sizeof(char)); /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; for (i = 0; i < (hsize_t)ssiz; i++) { if (is_vlstr) { @@ -3059,7 +3190,8 @@ xml_print_strs(hid_t did, int source) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "NULL"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { char *t_onestring = xml_escape_the_string(onestring, (int)str_size); @@ -3070,7 +3202,8 @@ xml_print_strs(hid_t did, int source) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\"%s\"", t_onestring); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_onestring); } } @@ -3093,13 +3226,15 @@ xml_print_strs(hid_t did, int source) return SUCCEED; error: - if(buf) + if (buf) HDfree(buf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(type); H5Sclose(space); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } @@ -3124,41 +3259,42 @@ check_filters(hid_t dcpl) size_t cd_nelmts = 20; unsigned int cd_values[20]; unsigned int flags; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; nfilt = H5Pget_nfilters(dcpl); if (nfilt <= 0) return; for (i = 0; i < nfilt; i++) { - filter = H5Pget_filter2(dcpl, (unsigned) i, &flags, (size_t *) &cd_nelmts, cd_values, (size_t)120, namebuf, NULL); + filter = H5Pget_filter2(dcpl, (unsigned)i, &flags, (size_t *)&cd_nelmts, cd_values, (size_t)120, + namebuf, NULL); if (filter == H5Z_FILTER_DEFLATE) { ctx.indent_level++; ctx.need_prefix = TRUE; @@ -3174,7 +3310,8 @@ check_filters(hid_t dcpl) h5tools_str_append(&buffer, "%d", cd_values[0]); } h5tools_str_append(&buffer, "\"/>"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; } else if (filter == H5Z_FILTER_FLETCHER32) { @@ -3184,7 +3321,8 @@ check_filters(hid_t dcpl) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sFletcher32 />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; } else if (filter == H5Z_FILTER_SHUFFLE) { @@ -3194,7 +3332,8 @@ check_filters(hid_t dcpl) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sShuffle />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; } else if (filter == H5Z_FILTER_SZIP) { @@ -3241,7 +3380,8 @@ check_filters(hid_t dcpl) h5tools_str_append(&buffer, "Header=\"Raw\""); } h5tools_str_append(&buffer, "/>"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; } else { @@ -3258,37 +3398,37 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) size_t sz; size_t i; hsize_t space; - void *buf; - char *name; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; + void * buf; + char * name; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + hsize_t curr_pos = 0; /* total data element position */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; ctx.indent_level++; dump_indent += COL; @@ -3298,31 +3438,34 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; space = H5Tget_size(type); - buf = HDmalloc((size_t) space); + buf = HDmalloc((size_t)space); H5Pget_fill_value(dcpl, type, buf); if (H5Tget_class(type) == H5T_REFERENCE) { - const char * path = lookup_ref_path(*(H5R_ref_t *) buf); + const char *path = lookup_ref_path(*(H5R_ref_t *)buf); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); if (!path) { ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\"%s\"", "NULL"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { char *t_path = xml_escape_the_string(path, -1); @@ -3332,7 +3475,8 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\"%s\"", t_path); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_path); } @@ -3341,9 +3485,10 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - H5Rdestroy((H5R_ref_t *) buf); + H5Rdestroy((H5R_ref_t *)buf); } else if (H5Tget_class(type) == H5T_STRING) { /* ????? */ @@ -3352,197 +3497,221 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } else { /* all other data */ switch (H5Tget_class(type)) { - case H5T_INTEGER: - ctx.need_prefix = TRUE; + case H5T_INTEGER: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%d\"", *(int *) buf); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "\"%d\"", *(int *)buf); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_FLOAT: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_FLOAT: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%f\"", (double)*(float *)buf); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "\"%f\"", (double)*(float *)buf); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_BITFIELD: - case H5T_OPAQUE: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_BITFIELD: + case H5T_OPAQUE: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - sz = H5Tget_size(type); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + sz = H5Tget_size(type); - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\""); - for (i = 0; i < sz; i++) { - h5tools_str_append(&buffer, "%x ", *(unsigned int *) buf + (i * sizeof(unsigned int))); - } - h5tools_str_append(&buffer, "\""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "\""); + for (i = 0; i < sz; i++) { + h5tools_str_append(&buffer, "%x ", *(unsigned int *)buf + (i * sizeof(unsigned int))); + } + h5tools_str_append(&buffer, "\""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_ENUM: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_ENUM: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - name = H5Tget_member_name(type, *(unsigned *) buf); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + name = H5Tget_member_name(type, *(unsigned *)buf); - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%s\"", name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - if(name) - H5free_memory(name); - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "\"%s\"", name); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + if (name) + H5free_memory(name); + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_ARRAY: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_ARRAY: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_TIME: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_TIME: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_COMPOUND: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_COMPOUND: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_VLEN: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_VLEN: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_NO_CLASS: - case H5T_NCLASSES: - case H5T_STRING: - case H5T_REFERENCE: - default: - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + case H5T_NO_CLASS: + case H5T_NCLASSES: + case H5T_STRING: + case H5T_REFERENCE: + default: + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", H5Tget_class(type)); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", H5Tget_class(type)); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; } } HDfree(buf); @@ -3554,7 +3723,8 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; dump_indent -= COL; @@ -3572,32 +3742,32 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) void xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *sset) { - hid_t type; - hid_t space; - hid_t dcpl; - H5D_fill_value_t fvstatus; - int maxdims; - hsize_t *chsize; - int ndims; - int i; - H5D_alloc_time_t at; - H5D_fill_time_t ft; - hsize_t tempi; - char *tmp; - char *t_name; - char *t_tmp; - char *t_prefix; - unsigned attr_crt_order_flags; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - char *rstr = (char*) HDmalloc((size_t)100); - char *pstr = (char*) HDmalloc((size_t)100); - - tmp = (char*) HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); + hid_t type; + hid_t space; + hid_t dcpl; + H5D_fill_value_t fvstatus; + int maxdims; + hsize_t * chsize; + int ndims; + int i; + H5D_alloc_time_t at; + H5D_fill_time_t ft; + hsize_t tempi; + char * tmp; + char * t_name; + char * t_tmp; + char * t_prefix; + unsigned attr_crt_order_flags; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; + h5tool_format_t string_dataformat; + hsize_t curr_pos = 0; /* total data element position */ + + char *rstr = (char *)HDmalloc((size_t)100); + char *pstr = (char *)HDmalloc((size_t)100); + + tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); HDstrcpy(tmp, prefix); HDstrcat(tmp, "/"); HDstrcat(tmp, name); @@ -3607,28 +3777,28 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; - t_name = xml_escape_the_name(name); - t_tmp = xml_escape_the_name(tmp); + t_name = xml_escape_the_name(name); + t_tmp = xml_escape_the_name(tmp); t_prefix = xml_escape_the_name(prefix); string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; xml_name_to_XID(did, tmp, rstr, 100, 1); xml_name_to_XID(did, prefix, pstr, 100, 1); @@ -3637,10 +3807,11 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">", - xmlnsprefix, t_name, rstr, t_tmp, pstr, - strcmp(prefix, "") ? t_prefix : "/"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append( + &buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">", + xmlnsprefix, t_name, rstr, t_tmp, pstr, strcmp(prefix, "") ? t_prefix : "/"); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_name); HDfree(t_tmp); @@ -3649,8 +3820,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss HDfree(pstr); HDfree(tmp); - dcpl = H5Dget_create_plist(did); - type = H5Dget_type(did); + dcpl = H5Dget_create_plist(did); + type = H5Dget_type(did); space = H5Dget_space(did); /* query the creation properties for attributes */ @@ -3658,7 +3829,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Print information about storage layout */ if (H5D_CHUNKED == H5Pget_layout(dcpl)) { - if((maxdims = H5Sget_simple_extent_ndims(space)) < 0) { + if ((maxdims = H5Sget_simple_extent_ndims(space)) < 0) { error_msg("unable to get maxdims\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -3672,7 +3843,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; @@ -3683,7 +3855,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss h5tools_str_append(&buffer, "<%sChunkedLayout ", xmlnsprefix); ndims = H5Pget_chunk(dcpl, maxdims, chsize); h5tools_str_append(&buffer, "Ndims=\"%d\">", ndims); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; @@ -3694,8 +3867,10 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sChunkDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" />", xmlnsprefix, chsize[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sChunkDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" />", + xmlnsprefix, chsize[i]); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } ctx.need_prefix = TRUE; @@ -3703,7 +3878,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sRequiredFilter>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; @@ -3716,7 +3892,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; dump_indent -= COL; @@ -3726,7 +3903,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; dump_indent -= COL; @@ -3735,7 +3913,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; dump_indent -= COL; HDfree(chsize); @@ -3749,7 +3928,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; @@ -3757,7 +3937,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sContiguousLayout/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; @@ -3765,7 +3946,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; } else if (H5D_COMPACT == H5Pget_layout(dcpl)) { @@ -3776,7 +3958,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; @@ -3784,7 +3967,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sCompactLayout/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; @@ -3792,7 +3976,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; } /* and check for external.... ?? */ @@ -3845,7 +4030,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss } /* end switch */ h5tools_str_append(&buffer, "\""); h5tools_str_append(&buffer, ">"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; dump_indent += COL; @@ -3855,10 +4041,12 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sFillValue>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); H5Pfill_value_defined(dcpl, &fvstatus); - if (fvstatus == H5D_FILL_VALUE_UNDEFINED || (fvstatus == H5D_FILL_VALUE_DEFAULT && ft == H5D_FILL_TIME_IFSET)) { + if (fvstatus == H5D_FILL_VALUE_UNDEFINED || + (fvstatus == H5D_FILL_VALUE_DEFAULT && ft == H5D_FILL_TIME_IFSET)) { ctx.indent_level++; ctx.need_prefix = TRUE; @@ -3866,7 +4054,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sNoFill/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; } else { @@ -3878,7 +4067,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; dump_indent -= COL; @@ -3888,7 +4078,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; dump_indent -= COL; @@ -3900,17 +4091,19 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss dump_indent += COL; if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if (H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { + if (H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < + 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - } /* end if */ + } /* end if */ else { - if (H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { + if (H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, + NULL) < 0) { error_msg("error getting attribute information\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ - } /* end else */ + } /* end else */ ctx.indent_level--; dump_indent -= COL; @@ -3918,166 +4111,182 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss if (dump_opts.display_data && (tempi > 0)) { switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - ctx.indent_level++; - dump_indent += COL; - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - ctx.indent_level--; - dump_indent -= COL; - break; - - case H5T_TIME: - ctx.indent_level++; + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_ENUM: + case H5T_ARRAY: + ctx.indent_level++; + dump_indent += COL; + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + ctx.indent_level--; + dump_indent -= COL; + break; - ctx.need_prefix = TRUE; + case H5T_TIME: + ctx.indent_level++; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; - ctx.need_prefix = TRUE; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; - ctx.indent_level--; - break; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - case H5T_COMPOUND: - ctx.need_prefix = TRUE; + ctx.indent_level--; + break; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + case H5T_COMPOUND: + ctx.need_prefix = TRUE; - ctx.indent_level++; - dump_indent += COL; - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - ctx.indent_level--; - dump_indent -= COL; - break; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - case H5T_REFERENCE: - ctx.need_prefix = TRUE; + ctx.indent_level++; + dump_indent += COL; + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + ctx.indent_level--; + dump_indent -= COL; + break; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { + case H5T_REFERENCE: ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + if (!H5Tequal(type, H5T_STD_REF_OBJ)) { + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } + else { + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + xml_print_refs(did, DATASET_DATA); + + ctx.need_prefix = TRUE; + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; + + case H5T_VLEN: + ctx.indent_level--; + dump_indent -= COL; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - xml_print_refs(did, DATASET_DATA); + h5tools_str_append(&buffer, ""); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.indent_level++; + dump_indent += COL; + ctx.indent_level++; + dump_indent += COL; + dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); + ctx.indent_level--; + dump_indent -= COL; + break; + case H5T_NO_CLASS: + case H5T_NCLASSES: + default: ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_VLEN: - ctx.indent_level--; - dump_indent -= COL; - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, ""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; - - ctx.indent_level++; - dump_indent += COL; - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - ctx.indent_level--; - dump_indent -= COL; - break; - case H5T_NO_CLASS: - case H5T_NCLASSES: - default: - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", H5Tget_class(type)); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", H5Tget_class(type)); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.need_prefix = TRUE; + ctx.need_prefix = TRUE; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + break; } } else { @@ -4089,7 +4298,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; @@ -4097,7 +4307,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; @@ -4105,7 +4316,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; } @@ -4118,7 +4330,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); } @@ -4137,62 +4350,64 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss static void xml_print_enum(hid_t type) { - char **name = NULL; /*member names */ - unsigned char *value = NULL; /*value array */ - unsigned nmembs; /*number of members */ - hid_t super; /*enum base integer type */ - hid_t native = H5I_INVALID_HID; /*native integer datatype */ - size_t dst_size; /*destination value type size */ - unsigned i; /*miscellaneous counters */ - size_t j; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ + char ** name = NULL; /*member names */ + unsigned char * value = NULL; /*value array */ + unsigned nmembs; /*number of members */ + hid_t super; /*enum base integer type */ + hid_t native = H5I_INVALID_HID; /*native integer datatype */ + size_t dst_size; /*destination value type size */ + unsigned i; /*miscellaneous counters */ + size_t j; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * outputformat = &xml_dataformat; + h5tool_format_t string_dataformat; + hsize_t curr_pos = 0; /* total data element position */ /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; + ctx.cur_column = dump_indent; string_dataformat = *outputformat; if (fp_format) { string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; + string_dataformat.fmt_float = fp_format; } if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; + string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } else string_dataformat.line_ncols = h5tools_nCols; string_dataformat.do_escape = dump_opts.display_escape; - outputformat = &string_dataformat; + outputformat = &string_dataformat; nmembs = (unsigned)H5Tget_nmembers(type); - super = H5Tget_super(type); + super = H5Tget_super(type); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - xml_print_datatype(super,0); + xml_print_datatype(super, 0); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); /* * Determine what datatype to use for the native values. To simplify @@ -4216,7 +4431,7 @@ xml_print_enum(hid_t type) } /* Get the names and raw values of all members */ - name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)); + name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)); value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < nmembs; i++) { @@ -4241,8 +4456,9 @@ xml_print_enum(hid_t type) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sEnumElement>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sEnumElement>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); @@ -4250,7 +4466,8 @@ xml_print_enum(hid_t type) /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "%s", t_name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); HDfree(t_name); ctx.indent_level--; @@ -4258,15 +4475,17 @@ xml_print_enum(hid_t type) /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sEnumValue>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "<%sEnumValue>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level++; ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); @@ -4280,22 +4499,24 @@ xml_print_enum(hid_t type) h5tools_str_append(&buffer, "%02x", value[i * dst_size + j]); } else if (H5T_SGN_NONE == H5Tget_sign(native)) { - h5tools_str_append(&buffer,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *) - ((void *) (value + i * dst_size)))); + h5tools_str_append(&buffer, "%" H5_PRINTF_LL_WIDTH "u", + *((unsigned long long *)((void *)(value + i * dst_size)))); } else { - h5tools_str_append(&buffer,"%" H5_PRINTF_LL_WIDTH "d", - *((long long *) ((void *) (value + i * dst_size)))); + h5tools_str_append(&buffer, "%" H5_PRINTF_LL_WIDTH "d", + *((long long *)((void *)(value + i * dst_size)))); } - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); ctx.indent_level--; ctx.need_prefix = TRUE; /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, + (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } ctx.indent_level--; dump_indent -= COL; @@ -4310,4 +4531,3 @@ xml_print_enum(hid_t type) HDfree(value); H5Tclose(super); } - diff --git a/tools/src/h5dump/h5dump_xml.h b/tools/src/h5dump/h5dump_xml.h index 3c59917..4798ea8 100644 --- a/tools/src/h5dump/h5dump_xml.h +++ b/tools/src/h5dump/h5dump_xml.h @@ -13,7 +13,7 @@ #ifndef H5DUMP_XML_H__ #define H5DUMP_XML_H__ -extern const char *xmlnsprefix; +extern const char *xmlnsprefix; #ifdef __cplusplus extern "C" { @@ -22,16 +22,16 @@ extern "C" { /* The dump functions of the dump_function_table */ /* XML format: same interface, alternative output */ -void xml_dump_group(hid_t, const char *); -void xml_dump_named_datatype(hid_t, const char *); -void xml_dump_dataset(hid_t, const char *, struct subset_t *); -void xml_dump_dataspace(hid_t space); -void xml_dump_datatype(hid_t type); -herr_t xml_dump_attr(hid_t, const char *, const H5A_info_t *, void *); -void xml_dump_data(hid_t, int, struct subset_t *, int); +void xml_dump_group(hid_t, const char *); +void xml_dump_named_datatype(hid_t, const char *); +void xml_dump_dataset(hid_t, const char *, struct subset_t *); +void xml_dump_dataspace(hid_t space); +void xml_dump_datatype(hid_t type); +herr_t xml_dump_attr(hid_t, const char *, const H5A_info_t *, void *); +void xml_dump_data(hid_t, int, struct subset_t *, int); #ifdef __cplusplus } #endif -#endif /* !H5DUMP_XML_H__ */ +#endif /* !H5DUMP_XML_H__ */ diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c index e60097b..203ad2b 100644 --- a/tools/src/h5format_convert/h5format_convert.c +++ b/tools/src/h5format_convert/h5format_convert.c @@ -15,7 +15,6 @@ * Programmer: Vailin Choi; Feb 2015 */ - /* * We include the private header file so we can get to the uniform * programming environment it declares. @@ -29,42 +28,39 @@ /* Name of tool */ #define PROGRAMNAME "h5format_convert" -static char *fname_g = NULL; -static char *dname_g = NULL; -static int dset_g = FALSE; -static int noop_g = FALSE; -static int verbose_g = 0; +static char *fname_g = NULL; +static char *dname_g = NULL; +static int dset_g = FALSE; +static int noop_g = FALSE; +static int verbose_g = 0; /* * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVvd:n"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h'}, - { "he", no_arg, 'h'}, - { "version", no_arg, 'V' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, - { "verbose", no_arg, 'v' }, - { "verbos", no_arg, 'v' }, - { "verbo", no_arg, 'v' }, - { "verb", no_arg, 'v' }, - { "dname", require_arg, 'd' }, - { "dnam", require_arg, 'd' }, - { "dna", require_arg, 'd' }, - { "dn", require_arg, 'd' }, - { "noop", no_arg, 'n' }, - { "noo", no_arg, 'n' }, - { "no", no_arg, 'n' }, - { "enable-error-stack", no_arg, 'E' }, - { NULL, 0, '\0' } -}; - - +static const char * s_opts = "hVvd:n"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"hel", no_arg, 'h'}, + {"he", no_arg, 'h'}, + {"version", no_arg, 'V'}, + {"version", no_arg, 'V'}, + {"versio", no_arg, 'V'}, + {"versi", no_arg, 'V'}, + {"vers", no_arg, 'V'}, + {"verbose", no_arg, 'v'}, + {"verbos", no_arg, 'v'}, + {"verbo", no_arg, 'v'}, + {"verb", no_arg, 'v'}, + {"dname", require_arg, 'd'}, + {"dnam", require_arg, 'd'}, + {"dna", require_arg, 'd'}, + {"dn", require_arg, 'd'}, + {"noop", no_arg, 'n'}, + {"noo", no_arg, 'n'}, + {"no", no_arg, 'n'}, + {"enable-error-stack", no_arg, 'E'}, + {NULL, 0, '\0'}}; + /*------------------------------------------------------------------------- * Function: usage * @@ -74,7 +70,8 @@ static struct long_options l_opts[] = { * *------------------------------------------------------------------------- */ -static void usage(const char *prog) +static void +usage(const char *prog) { HDfprintf(stdout, "usage: %s [OPTIONS] file_name\n", prog); HDfprintf(stdout, " OPTIONS\n"); @@ -118,7 +115,7 @@ parse_command_line(int argc, const char **argv) { int opt; - /* no arguments */ + /* no arguments */ if (argc == 1) { usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); @@ -127,7 +124,7 @@ parse_command_line(int argc, const char **argv) /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char) opt) { + switch ((char)opt) { case 'h': usage(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); @@ -143,9 +140,9 @@ parse_command_line(int argc, const char **argv) break; case 'd': /* -d dname */ - if(opt_arg != NULL && *opt_arg) + if (opt_arg != NULL && *opt_arg) dname_g = HDstrdup(opt_arg); - if(dname_g == NULL) { + if (dname_g == NULL) { h5tools_setstatus(EXIT_FAILURE); error_msg("No dataset name\n", opt_arg); usage(h5tools_getprogname()); @@ -168,7 +165,7 @@ parse_command_line(int argc, const char **argv) goto error; break; } /* switch */ - } /* while */ + } /* while */ if (argc <= opt_ind) { error_msg("missing file name\n"); @@ -179,13 +176,13 @@ parse_command_line(int argc, const char **argv) fname_g = HDstrdup(argv[opt_ind]); - return(0); + return (0); error: - return(-1); ; + return (-1); + ; } /* parse_command_line() */ - /*------------------------------------------------------------------------- * Function: leave * @@ -224,134 +221,138 @@ leave(int ret) static int convert(hid_t fid, const char *dname) { - hid_t dcpl = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - H5D_layout_t layout_type; + hid_t dcpl = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + H5D_layout_t layout_type; H5D_chunk_index_t idx_type; /* Open the dataset */ - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { error_msg("unable to open dataset \"%s\"\n", dname); h5tools_setstatus(EXIT_FAILURE); goto error; } - else if(verbose_g) + else if (verbose_g) HDfprintf(stdout, "Open the dataset\n"); /* Get the dataset's creation property list */ - if((dcpl = H5Dget_create_plist(did)) < 0) { + if ((dcpl = H5Dget_create_plist(did)) < 0) { error_msg("unable to get the dataset creation property list\n"); h5tools_setstatus(EXIT_FAILURE); goto error; } /* Get the dataset's layout */ - if((layout_type = H5Pget_layout(dcpl)) < 0) { + if ((layout_type = H5Pget_layout(dcpl)) < 0) { error_msg("unable to get the dataset layout type\n"); h5tools_setstatus(EXIT_FAILURE); goto error; } - else if(verbose_g) + else if (verbose_g) HDfprintf(stdout, "Retrieve the dataset's layout\n"); - switch(layout_type) { - case H5D_CHUNKED: - if(verbose_g) - HDfprintf(stdout, "Dataset is a chunked dataset\n"); - - /* Get the dataset's chunk indexing type */ - if(H5Dget_chunk_index_type(did, &idx_type) < 0) { - error_msg("unable to get the chunk indexing type for \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; - } - else if(verbose_g) - HDfprintf(stdout, "Retrieve the dataset's chunk indexing type\n"); + switch (layout_type) { + case H5D_CHUNKED: + if (verbose_g) + HDfprintf(stdout, "Dataset is a chunked dataset\n"); - if(idx_type == H5D_CHUNK_IDX_BTREE) { - if(verbose_g) - HDfprintf(stdout, "Dataset's chunk indexing type is already version 1 B-tree: no further action\n"); - h5tools_setstatus(EXIT_SUCCESS); + /* Get the dataset's chunk indexing type */ + if (H5Dget_chunk_index_type(did, &idx_type) < 0) { + error_msg("unable to get the chunk indexing type for \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + else if (verbose_g) + HDfprintf(stdout, "Retrieve the dataset's chunk indexing type\n"); + + if (idx_type == H5D_CHUNK_IDX_BTREE) { + if (verbose_g) + HDfprintf( + stdout, + "Dataset's chunk indexing type is already version 1 B-tree: no further action\n"); + h5tools_setstatus(EXIT_SUCCESS); + goto done; + } + else if (verbose_g) + HDfprintf(stdout, "Dataset's chunk indexing type is not version 1 B-tree\n"); + + break; + + case H5D_CONTIGUOUS: + if (verbose_g) + HDfprintf(stdout, "Dataset is a contiguous dataset: downgrade layout version as needed\n"); + break; + + case H5D_COMPACT: + if (verbose_g) + HDfprintf(stdout, "Dataset is a compact dataset: downgrade layout version as needed\n"); + break; + + case H5D_VIRTUAL: + if (verbose_g) + HDfprintf(stdout, "No further action for virtual dataset\n"); goto done; - } - else if (verbose_g) - HDfprintf(stdout, "Dataset's chunk indexing type is not version 1 B-tree\n"); - - break; - case H5D_CONTIGUOUS: - if(verbose_g) - HDfprintf(stdout, "Dataset is a contiguous dataset: downgrade layout version as needed\n"); - break; - - case H5D_COMPACT: - if(verbose_g) - HDfprintf(stdout, "Dataset is a compact dataset: downgrade layout version as needed\n"); - break; - - case H5D_VIRTUAL: - if(verbose_g) - HDfprintf(stdout, "No further action for virtual dataset\n"); - goto done; - - case H5D_NLAYOUTS: - case H5D_LAYOUT_ERROR: - default: - error_msg("unknown layout type for \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; + case H5D_NLAYOUTS: + case H5D_LAYOUT_ERROR: + default: + error_msg("unknown layout type for \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; } /* end switch */ /* No further action if it is a noop */ - if(noop_g) { - if(verbose_g) + if (noop_g) { + if (verbose_g) HDfprintf(stdout, "Not converting the dataset\n"); h5tools_setstatus(EXIT_SUCCESS); goto done; } - if(verbose_g) + if (verbose_g) HDfprintf(stdout, "Converting the dataset...\n"); /* Downgrade the dataset */ - if(H5Dformat_convert(did) < 0) { + if (H5Dformat_convert(did) < 0) { error_msg("unable to downgrade dataset \"%s\"\n", dname); h5tools_setstatus(EXIT_FAILURE); goto error; } - else if(verbose_g) + else if (verbose_g) HDfprintf(stdout, "Done\n"); done: /* Close the dataset */ - if(H5Dclose(did) < 0) { + if (H5Dclose(did) < 0) { error_msg("unable to close dataset \"%s\"\n", dname); h5tools_setstatus(EXIT_FAILURE); goto error; } - else if(verbose_g) + else if (verbose_g) HDfprintf(stdout, "Close the dataset\n"); /* Close the dataset creation property list */ - if(H5Pclose(dcpl) < 0) { + if (H5Pclose(dcpl) < 0) { error_msg("unable to close dataset creation property list\n"); h5tools_setstatus(EXIT_FAILURE); goto error; } - else if(verbose_g) + else if (verbose_g) HDprintf("Close the dataset creation property list\n"); return 0; error: - if(verbose_g) + if (verbose_g) HDfprintf(stdout, "Error encountered\n"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* convert() */ @@ -372,14 +373,14 @@ convert_dsets_cb(const char *path, const H5O_info2_t *oi, const char *already_vi hid_t fid = *(hid_t *)_fid; /* If the object has already been seen then just return */ - if(NULL == already_visited) { - if(oi->type == H5O_TYPE_DATASET) { - if(verbose_g) + if (NULL == already_visited) { + if (oi->type == H5O_TYPE_DATASET) { + if (verbose_g) HDfprintf(stdout, "Going to process dataset:%s...\n", path); - if(convert(fid, path) < 0) + if (convert(fid, path) < 0) goto error; } /* end if */ - } /* end if */ + } /* end if */ return 0; @@ -387,7 +388,6 @@ error: return -1; } /* end convert_dsets_cb() */ - /*------------------------------------------------------------------------- * Function: main * @@ -411,41 +411,41 @@ main(int argc, const char *argv[]) h5tools_init(); /* Parse command line options */ - if(parse_command_line(argc, argv) < 0) + if (parse_command_line(argc, argv) < 0) goto done; - else if(verbose_g) + else if (verbose_g) HDfprintf(stdout, "Process command line options\n"); - if(noop_g && verbose_g) + if (noop_g && verbose_g) HDfprintf(stdout, "It is noop...\n"); /* enable error reporting if command line option */ h5tools_error_report(); /* Open the HDF5 file */ - if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0)) < 0) { + if ((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0)) < 0) { error_msg("unable to open file \"%s\"\n", fname_g); h5tools_setstatus(EXIT_FAILURE); goto done; } - else if(verbose_g) + else if (verbose_g) HDfprintf(stdout, "Open the file %s\n", fname_g); - if(dset_g) { /* Convert a specified dataset in the file */ - if(verbose_g) + if (dset_g) { /* Convert a specified dataset in the file */ + if (verbose_g) HDfprintf(stdout, "Going to process dataset: %s...\n", dname_g); - if(convert(fid, dname_g) < 0) + if (convert(fid, dname_g) < 0) goto done; } else { /* Convert all datasets in the file */ - if(verbose_g) + if (verbose_g) HDfprintf(stdout, "Processing all datasets in the file...\n"); - if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0) + if (h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0) goto done; } /* end else */ - if(verbose_g) { - if(noop_g) { + if (verbose_g) { + if (noop_g) { HDfprintf(stdout, "Not processing the file's superblock...\n"); h5tools_setstatus(EXIT_SUCCESS); goto done; @@ -454,7 +454,7 @@ main(int argc, const char *argv[]) } /* end if */ /* Process superblock */ - if(H5Fformat_convert(fid) < 0) { + if (H5Fformat_convert(fid) < 0) { error_msg("unable to convert file's superblock\"%s\"\n", fname_g); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -462,22 +462,21 @@ main(int argc, const char *argv[]) done: /* Close the file */ - if(fid >= 0) { - if(H5Fclose(fid) < 0) { + if (fid >= 0) { + if (H5Fclose(fid) < 0) { error_msg("unable to close file \"%s\"\n", fname_g); h5tools_setstatus(EXIT_FAILURE); } - else if(verbose_g) { + else if (verbose_g) { HDfprintf(stdout, "Close the file\n"); } - } /* end if */ + } /* end if */ - if(fname_g) + if (fname_g) HDfree(fname_g); - if(dname_g) + if (dname_g) HDfree(dname_g); leave(h5tools_getstatus()); } /* end main() */ - diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index 4a642e0..14de44b 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -27,68 +27,69 @@ #endif /* Local function declarations */ -static int gtoken(char *s); -static int process(struct Options *opt); -static int processConfigurationFile(char *infile, struct Input *in); -static int mapKeywordToIndex(char *key); -static int parsePathInfo(struct path_info *path, char *strm); -static int parseDimensions(struct Input *in, char *strm); -static int getInputSize(struct Input *in, int ival); -static int getInputClass(struct Input *in, char * strm); -static int getInputClassType(struct Input *in, char * strm); -static int getInputByteOrder(struct Input *in, FILE *strm); -static int InputClassStrToInt(char *temp); -static int getRank(struct Input *in, FILE *strm); -static int getDimensionSizes(struct Input *in, FILE *strm); -static int getOutputSize(struct Input *in, FILE *strm); -static int getOutputClass(struct Input *in, FILE *strm); -static int OutputClassStrToInt(char *temp); -static int getOutputArchitecture(struct Input *in, FILE *strm); -static int OutputArchStrToInt(const char *temp); -static int getOutputByteOrder(struct Input *in, FILE *strm); -static int OutputByteOrderStrToInt(const char *temp); -static int getChunkedDimensionSizes(struct Input *in, FILE *strm); -static int getCompressionType(struct Input *in, FILE *strm); -static int CompressionTypeStrToInt(char *temp); -static int getCompressionParameter(struct Input *in, FILE *strm); -static int getExternalFilename(struct Input *in, FILE *strm); -static int getMaximumDimensionSizes(struct Input *in, FILE *strm); -static int processDataFile(char *infile, struct Input *in, hid_t file_id); -static int readIntegerData(FILE *strm, struct Input *in); -static int readFloatData(FILE *strm, struct Input *in); -static int allocateIntegerStorage(struct Input *in); -static int allocateFloatStorage(struct Input *in); -static int readUIntegerData(FILE *strm, struct Input *in); -static int allocateUIntegerStorage(struct Input *in); -static int validateConfigurationParameters(struct Input *in); -static int processStrData(FILE *strm, struct Input *in, hid_t file_id); -static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id); -uint16_t swap_uint16(uint16_t val); -int16_t swap_int16(int16_t val); -uint32_t swap_uint32(uint32_t val); -int32_t swap_int32(int32_t val); -int64_t swap_int64(int64_t val); -uint64_t swap_uint64(uint64_t val); - -int main(int argc, char *argv[]) +static int gtoken(char *s); +static int process(struct Options *opt); +static int processConfigurationFile(char *infile, struct Input *in); +static int mapKeywordToIndex(char *key); +static int parsePathInfo(struct path_info *path, char *strm); +static int parseDimensions(struct Input *in, char *strm); +static int getInputSize(struct Input *in, int ival); +static int getInputClass(struct Input *in, char *strm); +static int getInputClassType(struct Input *in, char *strm); +static int getInputByteOrder(struct Input *in, FILE *strm); +static int InputClassStrToInt(char *temp); +static int getRank(struct Input *in, FILE *strm); +static int getDimensionSizes(struct Input *in, FILE *strm); +static int getOutputSize(struct Input *in, FILE *strm); +static int getOutputClass(struct Input *in, FILE *strm); +static int OutputClassStrToInt(char *temp); +static int getOutputArchitecture(struct Input *in, FILE *strm); +static int OutputArchStrToInt(const char *temp); +static int getOutputByteOrder(struct Input *in, FILE *strm); +static int OutputByteOrderStrToInt(const char *temp); +static int getChunkedDimensionSizes(struct Input *in, FILE *strm); +static int getCompressionType(struct Input *in, FILE *strm); +static int CompressionTypeStrToInt(char *temp); +static int getCompressionParameter(struct Input *in, FILE *strm); +static int getExternalFilename(struct Input *in, FILE *strm); +static int getMaximumDimensionSizes(struct Input *in, FILE *strm); +static int processDataFile(char *infile, struct Input *in, hid_t file_id); +static int readIntegerData(FILE *strm, struct Input *in); +static int readFloatData(FILE *strm, struct Input *in); +static int allocateIntegerStorage(struct Input *in); +static int allocateFloatStorage(struct Input *in); +static int readUIntegerData(FILE *strm, struct Input *in); +static int allocateUIntegerStorage(struct Input *in); +static int validateConfigurationParameters(struct Input *in); +static int processStrData(FILE *strm, struct Input *in, hid_t file_id); +static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id); +uint16_t swap_uint16(uint16_t val); +int16_t swap_int16(int16_t val); +uint32_t swap_uint32(uint32_t val); +int32_t swap_int32(int32_t val); +int64_t swap_int64(int64_t val); +uint64_t swap_uint64(uint64_t val); + +int +main(int argc, char *argv[]) { struct Options *opt; int outfile_named = FALSE; int token; int i; int state = 0; - struct Input *in = NULL; - - const char *err1 = "Invalid number of arguments: %d.\n"; - const char *err2 = "Error in state table.\n"; - const char *err3 = "No output file given.\n"; - const char *err4 = "Program aborted.\n"; - const char *err5 = "Invalid path %s.\n"; - const char *err6 = "Invalid dimensions - %s.\n"; - const char *err7 = "Invalid type of data - %s.\n"; - const char *err8 = "Invalid size of data - %s.\n"; - const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n"; - const char *err10 = "Length of output file name limited to 255 chars.\n"; + struct Input * in = NULL; + + const char *err1 = "Invalid number of arguments: %d.\n"; + const char *err2 = "Error in state table.\n"; + const char *err3 = "No output file given.\n"; + const char *err4 = "Program aborted.\n"; + const char *err5 = "Invalid path %s.\n"; + const char *err6 = "Invalid dimensions - %s.\n"; + const char *err7 = "Invalid type of data - %s.\n"; + const char *err8 = "Invalid size of data - %s.\n"; + const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n"; + const char *err10 = "Length of output file name limited to 255 chars.\n"; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -96,10 +97,10 @@ int main(int argc, char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - (void) HDsetvbuf(stderr, (char *) NULL, _IOLBF, 0); - (void) HDsetvbuf(stdout, (char *) NULL, _IOLBF, 0); + (void)HDsetvbuf(stderr, (char *)NULL, _IOLBF, 0); + (void)HDsetvbuf(stdout, (char *)NULL, _IOLBF, 0); - if((opt = (struct Options *)HDcalloc(1, sizeof(struct Options))) == NULL) + if ((opt = (struct Options *)HDcalloc(1, sizeof(struct Options))) == NULL) goto err; if (argv[1] && (HDstrcmp("-V", argv[1]) == 0)) { @@ -111,7 +112,7 @@ int main(int argc, char *argv[]) * validate the number of command line arguments */ if (argc < 2) { - (void) HDfprintf(stderr, err1, argc); + (void)HDfprintf(stderr, err1, argc); usage(argv[0]); goto err; } @@ -129,105 +130,105 @@ int main(int argc, char *argv[]) switch (state) { - case 1: /* counting input files */ - if (opt->fcount < 29) { - (void) HDstrcpy(opt->infiles[opt->fcount].datafile, argv[i]); - in = &(opt->infiles[opt->fcount].in); - opt->infiles[opt->fcount].config = 0; - setDefaultValues(in, opt->fcount); - opt->fcount++; - } - else { - (void) HDfprintf(stderr, err9, argv[i]); - goto err; - } + case 1: /* counting input files */ + if (opt->fcount < 29) { + (void)HDstrcpy(opt->infiles[opt->fcount].datafile, argv[i]); + in = &(opt->infiles[opt->fcount].in); + opt->infiles[opt->fcount].config = 0; + setDefaultValues(in, opt->fcount); + opt->fcount++; + } + else { + (void)HDfprintf(stderr, err9, argv[i]); + goto err; + } - break; + break; - case 2: /* -c found; look for configfile */ - break; + case 2: /* -c found; look for configfile */ + break; - case 3: /* get configfile name */ - (void) HDstrcpy(opt->infiles[opt->fcount-1].configfile, argv[i]); - opt->infiles[opt->fcount - 1].config = 1; - break; + case 3: /* get configfile name */ + (void)HDstrcpy(opt->infiles[opt->fcount - 1].configfile, argv[i]); + opt->infiles[opt->fcount - 1].config = 1; + break; - case 4: /* -o found; look for outfile */ - break; + case 4: /* -o found; look for outfile */ + break; - case 5: /* get outfile found */ - if (HDstrlen(argv[i]) > MAX_PATH_NAME_LENGTH) { - (void) HDfprintf(stderr, err10, argv[i]); - goto err; - } - (void) HDstrcpy(opt->outfile, argv[i]); - outfile_named = TRUE; - break; + case 5: /* get outfile found */ + if (HDstrlen(argv[i]) > MAX_PATH_NAME_LENGTH) { + (void)HDfprintf(stderr, err10, argv[i]); + goto err; + } + (void)HDstrcpy(opt->outfile, argv[i]); + outfile_named = TRUE; + break; - case 6: /* -h found; help, then exit */ - help(argv[0]); - HDexit(EXIT_SUCCESS); - break; + case 6: /* -h found; help, then exit */ + help(argv[0]); + HDexit(EXIT_SUCCESS); + break; - case 7: /* -d found; look for dimensions */ - break; + case 7: /* -d found; look for dimensions */ + break; - case 8: /* read dimensions */ - if (parseDimensions(in, argv[i]) == -1) { - (void) HDfprintf(stderr, err6, argv[i]); - goto err; - } - break; + case 8: /* read dimensions */ + if (parseDimensions(in, argv[i]) == -1) { + (void)HDfprintf(stderr, err6, argv[i]); + goto err; + } + break; - case 9: /* -p found; look for path name */ - break; + case 9: /* -p found; look for path name */ + break; - case 10: /* read path name */ - if (parsePathInfo(&in->path, argv[i]) == -1) { - (void) HDfprintf(stderr, err5, argv[i]); - goto err; - } - break; + case 10: /* read path name */ + if (parsePathInfo(&in->path, argv[i]) == -1) { + (void)HDfprintf(stderr, err5, argv[i]); + goto err; + } + break; - case 11: /* -t found; look for data type */ - break; + case 11: /* -t found; look for data type */ + break; - case 12: /* read data type */ - if (getInputClass(in, argv[i]) == -1) { - (void) HDfprintf(stderr, err7, argv[i]); - goto err; - } + case 12: /* read data type */ + if (getInputClass(in, argv[i]) == -1) { + (void)HDfprintf(stderr, err7, argv[i]); + goto err; + } - if (in->inputClass == 0 || in->inputClass == 4) - in->outputClass = 0; - if (in->inputClass == 1 || in->inputClass == 2 || in->inputClass == 3) - in->outputClass = 1; - if (in->inputClass == 6 || in->inputClass == 7) - in->outputClass = 2; - break; + if (in->inputClass == 0 || in->inputClass == 4) + in->outputClass = 0; + if (in->inputClass == 1 || in->inputClass == 2 || in->inputClass == 3) + in->outputClass = 1; + if (in->inputClass == 6 || in->inputClass == 7) + in->outputClass = 2; + break; - case 13: /* -s found; look for data size */ - break; + case 13: /* -s found; look for data size */ + break; - case 14: /* read data size */ - if (getInputSize(in, (int) HDstrtol(argv[i], NULL, BASE_10)) == -1) { - (void) HDfprintf(stderr, err8, argv[i]); - goto err; - } - /*set default value for output-size */ - in->outputSize = in->inputSize; - break; + case 14: /* read data size */ + if (getInputSize(in, (int)HDstrtol(argv[i], NULL, BASE_10)) == -1) { + (void)HDfprintf(stderr, err8, argv[i]); + goto err; + } + /*set default value for output-size */ + in->outputSize = in->inputSize; + break; - case ERR: /* command syntax error */ - default: - (void) HDfprintf(stderr, "%s", err2); - usage(argv[0]); - goto err; + case ERR: /* command syntax error */ + default: + (void)HDfprintf(stderr, "%s", err2); + usage(argv[0]); + goto err; } } if (FALSE == outfile_named) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); usage(argv[0]); goto err; } @@ -252,7 +253,7 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; err: - (void) HDfprintf(stderr, "%s", err4); + (void)HDfprintf(stderr, "%s", err4); for (i = 0; i < opt->fcount; i++) { in = &(opt->infiles[i].in); if (in->sizeOfDimension) @@ -271,10 +272,11 @@ err: return EXIT_FAILURE; } -static int gtoken(char *s) +static int +gtoken(char *s) { - size_t len; - int token = ERR; + size_t len; + int token = ERR; const char *err1 = "Illegal argument: %s.\n"; @@ -284,47 +286,47 @@ static int gtoken(char *s) if (s[0] == '-') { /* option name (or negative number) */ len = HDstrlen(&s[1]); switch (s[1]) { - case 'o': - if (!HDstrncmp("outfile", &s[1], len)) - token = OPT_o; - break; + case 'o': + if (!HDstrncmp("outfile", &s[1], len)) + token = OPT_o; + break; - case 'c': - if (!HDstrncmp("config", &s[1], len)) - token = OPT_c; - break; + case 'c': + if (!HDstrncmp("config", &s[1], len)) + token = OPT_c; + break; - case 'h': - if (!HDstrncmp("help", &s[1], len)) - token = OPT_h; - break; + case 'h': + if (!HDstrncmp("help", &s[1], len)) + token = OPT_h; + break; - case 'd': - if (!HDstrncmp("dims", &s[1], len)) - token = OPT_d; - break; + case 'd': + if (!HDstrncmp("dims", &s[1], len)) + token = OPT_d; + break; - case 'p': - if (!HDstrncmp("path", &s[1], len)) - token = OPT_p; - break; + case 'p': + if (!HDstrncmp("path", &s[1], len)) + token = OPT_p; + break; - case 't': - if (!HDstrncmp("type", &s[1], len)) - token = OPT_t; - break; + case 't': + if (!HDstrncmp("type", &s[1], len)) + token = OPT_t; + break; - case 's': - if (!HDstrncmp("size", &s[1], len)) - token = OPT_s; - break; - default: - token = ERR; /* not a supported option tag */ - break; + case 's': + if (!HDstrncmp("size", &s[1], len)) + token = OPT_s; + break; + default: + token = ERR; /* not a supported option tag */ + break; } if (token == ERR) - (void) HDfprintf(stderr, err1, s); + (void)HDfprintf(stderr, err1, s); } else { /* filename */ token = FILNAME; @@ -347,19 +349,20 @@ static int gtoken(char *s) *------------------------------------------------------------------------- */ -static int processDataFile(char *infile, struct Input *in, hid_t file_id) +static int +processDataFile(char *infile, struct Input *in, hid_t file_id) { - FILE *strm = NULL; - const char *err1 = "Unable to open the input file %s for reading.\n"; - const char *err2 = "Error in allocating integer data storage.\n"; - const char *err3 = "Error in allocating floating-point data storage.\n"; - const char *err4 = "Error in reading integer data.\n"; - const char *err5 = "Error in reading floating-point data.\n"; - const char *err6 = "Error in allocating unsigned integer data storage.\n"; - const char *err7 = "Error in reading unsigned integer data.\n"; - const char *err10 = "Unrecognized input class type.\n"; - const char *err11 = "Error in reading string data.\n"; - int retval = -1; + FILE * strm = NULL; + const char *err1 = "Unable to open the input file %s for reading.\n"; + const char *err2 = "Error in allocating integer data storage.\n"; + const char *err3 = "Error in allocating floating-point data storage.\n"; + const char *err4 = "Error in reading integer data.\n"; + const char *err5 = "Error in reading floating-point data.\n"; + const char *err6 = "Error in allocating unsigned integer data storage.\n"; + const char *err7 = "Error in reading unsigned integer data.\n"; + const char *err10 = "Unrecognized input class type.\n"; + const char *err11 = "Error in reading string data.\n"; + int retval = -1; /*------------------------------------------------------------------------- * special case for opening binary classes in H5_HAVE_WIN32_API @@ -368,10 +371,10 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) * "UIN" denotes an unsigned integer binary file, *------------------------------------------------------------------------- */ - if (in->inputClass == 4 /* "IN" */|| in->inputClass == 3 /* "FP" */|| in->inputClass == 7 /* "UIN" */) { + if (in->inputClass == 4 /* "IN" */ || in->inputClass == 3 /* "FP" */ || in->inputClass == 7 /* "UIN" */) { if ((strm = HDfopen(infile, READ_OPEN_FLAGS)) == NULL) { - (void) HDfprintf(stderr, err1, infile); + (void)HDfprintf(stderr, err1, infile); goto error; } } @@ -381,85 +384,85 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) */ else { if ((strm = HDfopen(infile, "r")) == NULL) { - (void) HDfprintf(stderr, err1, infile); + (void)HDfprintf(stderr, err1, infile); goto error; } } switch (in->inputClass) { - case 0: /* TEXTIN */ - case 4: /* IN */ - if (allocateIntegerStorage(in) == -1) { - (void) HDfprintf(stderr, err2, infile); - goto error; - } + case 0: /* TEXTIN */ + case 4: /* IN */ + if (allocateIntegerStorage(in) == -1) { + (void)HDfprintf(stderr, err2, infile); + goto error; + } - if (readIntegerData(strm, in) == -1) { - (void) HDfprintf(stderr, err4, infile); - goto error; - } - break; + if (readIntegerData(strm, in) == -1) { + (void)HDfprintf(stderr, err4, infile); + goto error; + } + break; - case 1: /* TEXTFP */ - case 2: /* TEXTFPE */ - case 3: /* FP */ - if (allocateFloatStorage(in) == -1) { - (void) HDfprintf(stderr, err3, infile); - goto error; + case 1: /* TEXTFP */ + case 2: /* TEXTFPE */ + case 3: /* FP */ + if (allocateFloatStorage(in) == -1) { + (void)HDfprintf(stderr, err3, infile); + goto error; + } - } + if (readFloatData(strm, in) == -1) { + (void)HDfprintf(stderr, err5, infile); + goto error; + } + break; - if (readFloatData(strm, in) == -1) { - (void) HDfprintf(stderr, err5, infile); - goto error; - } - break; + case 5: /* STR */ + if (in->h5dumpInput) { + if (processStrHDFData(strm, in, file_id) == -1) { + (void)HDfprintf(stderr, err11, infile); + goto error; + } + } + else { + if (processStrData(strm, in, file_id) == -1) { + (void)HDfprintf(stderr, err11, infile); + goto error; + } + } + + break; - case 5: /* STR */ - if (in->h5dumpInput) { - if (processStrHDFData(strm, in, file_id) == -1) { - (void) HDfprintf(stderr, err11, infile); + case 6: /* TEXTUIN */ + case 7: /* UIN */ + if (allocateUIntegerStorage(in) == -1) { + (void)HDfprintf(stderr, err6, infile); goto error; } - } - else { - if (processStrData(strm, in, file_id) == -1) { - (void) HDfprintf(stderr, err11, infile); + if (readUIntegerData(strm, in) == -1) { + (void)HDfprintf(stderr, err7, infile); goto error; } - } - - break; + break; - case 6: /* TEXTUIN */ - case 7: /* UIN */ - if (allocateUIntegerStorage(in) == -1) { - (void) HDfprintf(stderr, err6, infile); - goto error; - } - if (readUIntegerData(strm, in) == -1) { - (void) HDfprintf(stderr, err7, infile); + default: + (void)HDfprintf(stderr, "%s", err10); goto error; - } - break; - - default: - (void) HDfprintf(stderr, "%s", err10); - goto error; } /* Set success return value */ retval = 0; error: - if(strm) + if (strm) HDfclose(strm); - return(retval); + return (retval); } -static int readIntegerData(FILE *strm, struct Input *in) +static int +readIntegerData(FILE *strm, struct Input *in) { - H5DT_INT8 *in08; + H5DT_INT8 * in08; H5DT_INT16 *in16; H5DT_INT16 temp16; H5DT_INT32 *in32; @@ -469,9 +472,9 @@ static int readIntegerData(FILE *strm, struct Input *in) H5DT_INT64 temp64; char buffer[256]; #endif - hsize_t len = 1; - hsize_t i; - int j; + hsize_t len = 1; + hsize_t i; + int j; const char *err1 = "Unable to get integer value from file.\n"; const char *err2 = "Unrecognized input class type.\n"; @@ -481,160 +484,161 @@ static int readIntegerData(FILE *strm, struct Input *in) len *= in->sizeOfDimension[j]; switch (in->inputSize) { - case 8: - switch (in->inputClass) { - case 0: /* TEXTIN */ - in08 = (H5DT_INT8 *) in->data; - for (i = 0; i < len; i++, in08++) { - if (fscanf(strm, "%hd", &temp16) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - (*in08) = (H5DT_INT8) temp16; - } - break; + case 8: + switch (in->inputClass) { + case 0: /* TEXTIN */ + in08 = (H5DT_INT8 *)in->data; + for (i = 0; i < len; i++, in08++) { + if (fscanf(strm, "%hd", &temp16) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + (*in08) = (H5DT_INT8)temp16; + } + break; - case 4: /* IN */ - in08 = (H5DT_INT8 *) in->data; - for (i = 0; i < len; i++, in08++) { - if (HDfread((char *) in08, sizeof(H5DT_INT8), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } + case 4: /* IN */ + in08 = (H5DT_INT8 *)in->data; + for (i = 0; i < len; i++, in08++) { + if (HDfread((char *)in08, sizeof(H5DT_INT8), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } #ifdef H5DEBUGIMPORT - HDprintf("readIntegerData %d (0x%.8X)\n", *in08, *in08); + HDprintf("readIntegerData %d (0x%.8X)\n", *in08, *in08); #endif - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + } + break; - case 16: - in16 = (H5DT_INT16 *) in->data; - switch (in->inputClass) { - case 0: /* TEXTIN */ - for (i = 0; i < len; i++, in16++) { - if (fscanf(strm, "%hd", in16) != 1) { - (void) HDfprintf(stderr, "%s", err1); + default: + (void)HDfprintf(stderr, "%s", err2); return (-1); - } } - in16 = (H5DT_INT16 *) in->data; break; - case 4: /* IN */ - for (i = 0; i < len; i++, in16++) { - if (HDfread((char *)&temp16, sizeof(H5DT_INT16), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } -/* - if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) - *in16 = swap_int16(temp16); - else -*/ - *in16 = temp16; + case 16: + in16 = (H5DT_INT16 *)in->data; + switch (in->inputClass) { + case 0: /* TEXTIN */ + for (i = 0; i < len; i++, in16++) { + if (fscanf(strm, "%hd", in16) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } + in16 = (H5DT_INT16 *)in->data; + break; + + case 4: /* IN */ + for (i = 0; i < len; i++, in16++) { + if (HDfread((char *)&temp16, sizeof(H5DT_INT16), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + /* + if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) + *in16 = swap_int16(temp16); + else + */ + *in16 = temp16; #ifdef H5DEBUGIMPORT - HDprintf("readIntegerData %d (0x%.8X)\n", *in16, temp16); + HDprintf("readIntegerData %d (0x%.8X)\n", *in16, temp16); #endif - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + } + break; - case 32: - in32 = (H5DT_INT32 *) in->data; - switch (in->inputClass) { - case 0: /* TEXTIN */ - for (i = 0; i < len; i++, in32++) { - if (fscanf(strm, "%d", in32) != 1) { - (void) HDfprintf(stderr, "%s", err1); + default: + (void)HDfprintf(stderr, "%s", err2); return (-1); - } } break; - case 4: /* IN */ - for (i = 0; i < len; i++, in32++) { - if (HDfread((char *)&temp32, sizeof(H5DT_INT32), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } -/* - if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) - *in32 = swap_int32(temp32); - else -*/ - *in32 = temp32; + case 32: + in32 = (H5DT_INT32 *)in->data; + switch (in->inputClass) { + case 0: /* TEXTIN */ + for (i = 0; i < len; i++, in32++) { + if (fscanf(strm, "%d", in32) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } + break; + + case 4: /* IN */ + for (i = 0; i < len; i++, in32++) { + if (HDfread((char *)&temp32, sizeof(H5DT_INT32), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + /* + if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) + *in32 = swap_int32(temp32); + else + */ + *in32 = temp32; #ifdef H5DEBUGIMPORT - HDprintf("readIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32); + HDprintf("readIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32); #endif - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + } + break; -#ifdef H5_SIZEOF_LONG_LONG - case 64: - in64 = (H5DT_INT64 *) in->data; - switch (in->inputClass) { - case 0: /* TEXTIN */ - for (i = 0; i < len; i++, in64++) { - if (fscanf(strm, "%s", buffer) < 1) { - (void) HDfprintf(stderr, "%s", err1); + default: + (void)HDfprintf(stderr, "%s", err2); return (-1); - } - *in64 = (H5DT_INT64) HDstrtoll(buffer, NULL, 10); } break; - case 4: /* IN */ - for (i = 0; i < len; i++, in64++) { - if (HDfread((char *)&temp64, sizeof(H5DT_INT64), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } -/* - if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) - *in64 = swap_int64(temp64); - else -*/ - *in64 = temp64; +#ifdef H5_SIZEOF_LONG_LONG + case 64: + in64 = (H5DT_INT64 *)in->data; + switch (in->inputClass) { + case 0: /* TEXTIN */ + for (i = 0; i < len; i++, in64++) { + if (fscanf(strm, "%s", buffer) < 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + *in64 = (H5DT_INT64)HDstrtoll(buffer, NULL, 10); + } + break; + + case 4: /* IN */ + for (i = 0; i < len; i++, in64++) { + if (HDfread((char *)&temp64, sizeof(H5DT_INT64), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + /* + if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) + *in64 = swap_int64(temp64); + else + */ + *in64 = temp64; #ifdef H5DEBUGIMPORT - HDprintf("readIntegerData %d (0x%.8X)\n", *in64, temp64); + HDprintf("readIntegerData %d (0x%.8X)\n", *in64, temp64); #endif + } + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); } break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; #endif /* ifdef H5_SIZEOF_LONG_LONG */ - default: - (void) HDfprintf(stderr, "%s", err3); - break; + default: + (void)HDfprintf(stderr, "%s", err3); + break; } return (0); } -static int readUIntegerData(FILE *strm, struct Input *in) +static int +readUIntegerData(FILE *strm, struct Input *in) { - H5DT_UINT8 *in08; + H5DT_UINT8 * in08; H5DT_UINT16 *in16; H5DT_UINT16 temp16; H5DT_UINT32 *in32; @@ -642,7 +646,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) #ifdef H5_SIZEOF_LONG_LONG H5DT_UINT64 *in64; H5DT_UINT64 temp64; - char buffer[256]; + char buffer[256]; #endif hsize_t len = 1; hsize_t i; @@ -655,161 +659,162 @@ static int readUIntegerData(FILE *strm, struct Input *in) len *= in->sizeOfDimension[j]; switch (in->inputSize) { - case 8: - switch (in->inputClass) { - case 6: /* TEXTUIN */ - in08 = (H5DT_UINT8 *) in->data; - for (i = 0; i < len; i++, in08++) { - if (fscanf(strm, "%hu", &temp16) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - (*in08) = (H5DT_UINT8) temp16; - } - break; - - case 7: /* UIN */ - in08 = (H5DT_UINT8 *) in->data; - for (i = 0; i < len; i++, in08++) { - if (HDfread((char *) in08, sizeof(H5DT_UINT8), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - } - break; + case 8: + switch (in->inputClass) { + case 6: /* TEXTUIN */ + in08 = (H5DT_UINT8 *)in->data; + for (i = 0; i < len; i++, in08++) { + if (fscanf(strm, "%hu", &temp16) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + (*in08) = (H5DT_UINT8)temp16; + } + break; - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + case 7: /* UIN */ + in08 = (H5DT_UINT8 *)in->data; + for (i = 0; i < len; i++, in08++) { + if (HDfread((char *)in08, sizeof(H5DT_UINT8), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } + break; - case 16: - in16 = (H5DT_UINT16 *) in->data; - switch (in->inputClass) { - case 6: /* TEXTUIN */ - for (i = 0; i < len; i++, in16++) { - if (fscanf(strm, "%hu", in16) != 1) { - (void) HDfprintf(stderr, "%s", err1); + default: + (void)HDfprintf(stderr, "%s", err2); return (-1); - } } break; - case 7: /* UIN */ - for (i = 0; i < len; i++, in16++) { - if (HDfread((char *)&temp16, sizeof(H5DT_UINT16), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } -/* - if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) - *in16 = swap_uint16(temp16); - else -*/ - *in16 = temp16; + case 16: + in16 = (H5DT_UINT16 *)in->data; + switch (in->inputClass) { + case 6: /* TEXTUIN */ + for (i = 0; i < len; i++, in16++) { + if (fscanf(strm, "%hu", in16) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } + break; + + case 7: /* UIN */ + for (i = 0; i < len; i++, in16++) { + if (HDfread((char *)&temp16, sizeof(H5DT_UINT16), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + /* + if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) + *in16 = swap_uint16(temp16); + else + */ + *in16 = temp16; #ifdef H5DEBUGIMPORT - HDprintf("readUIntegerData %d (0x%.4X = 0x%.4X)\n", *in16, *in16, temp16); + HDprintf("readUIntegerData %d (0x%.4X = 0x%.4X)\n", *in16, *in16, temp16); #endif - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + } + break; - case 32: - in32 = (H5DT_UINT32 *) in->data; - switch (in->inputClass) { - case 6: /* TEXTUIN */ - for (i = 0; i < len; i++, in32++) { - if (fscanf(strm, "%u", in32) != 1) { - (void) HDfprintf(stderr, "%s", err1); + default: + (void)HDfprintf(stderr, "%s", err2); return (-1); - } } break; - case 7: /* UIN */ - for (i = 0; i < len; i++, in32++) { - if (HDfread((char *)&temp32, sizeof(H5DT_UINT32), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } -/* - if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) - *in32 = swap_uint32(temp32); - else -*/ - *in32 = temp32; + case 32: + in32 = (H5DT_UINT32 *)in->data; + switch (in->inputClass) { + case 6: /* TEXTUIN */ + for (i = 0; i < len; i++, in32++) { + if (fscanf(strm, "%u", in32) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } + break; + + case 7: /* UIN */ + for (i = 0; i < len; i++, in32++) { + if (HDfread((char *)&temp32, sizeof(H5DT_UINT32), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + /* + if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) + *in32 = swap_uint32(temp32); + else + */ + *in32 = temp32; #ifdef H5DEBUGIMPORT - HDprintf("readUIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32); + HDprintf("readUIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32); #endif - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + } + break; -#ifdef H5_SIZEOF_LONG_LONG - case 64: - in64 = (H5DT_UINT64 *) in->data; - switch (in->inputClass) { - case 6: /* TEXTUIN */ - for (i = 0; i < len; i++, in64++) { - if (fscanf(strm, "%s", buffer) < 1) { - (void) HDfprintf(stderr, "%s", err1); + default: + (void)HDfprintf(stderr, "%s", err2); return (-1); - } - *in64 = (H5DT_UINT64) HDstrtoll(buffer, NULL, 10); } break; - case 7: /* UIN */ - for (i = 0; i < len; i++, in64++) { - if (HDfread((char *)&temp64, sizeof(H5DT_UINT64), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } -/* - if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) - *in64 = swap_uint64(temp64); - else -*/ - *in64 = temp64; +#ifdef H5_SIZEOF_LONG_LONG + case 64: + in64 = (H5DT_UINT64 *)in->data; + switch (in->inputClass) { + case 6: /* TEXTUIN */ + for (i = 0; i < len; i++, in64++) { + if (fscanf(strm, "%s", buffer) < 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + *in64 = (H5DT_UINT64)HDstrtoll(buffer, NULL, 10); + } + break; + + case 7: /* UIN */ + for (i = 0; i < len; i++, in64++) { + if (HDfread((char *)&temp64, sizeof(H5DT_UINT64), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + /* + if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) + *in64 = swap_uint64(temp64); + else + */ + *in64 = temp64; #ifdef H5DEBUGIMPORT - HDprintf("readUIntegerData %ld (0x%.8X = 0x%.8X)\n", *in64, *in64, temp64); + HDprintf("readUIntegerData %ld (0x%.8X = 0x%.8X)\n", *in64, *in64, temp64); #endif + } + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); } break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; #endif /* ifdef H5_SIZEOF_LONG_LONG */ - default: - (void) HDfprintf(stderr, "%s", err3); - break; + default: + (void)HDfprintf(stderr, "%s", err3); + break; } return (0); } -static int readFloatData(FILE *strm, struct Input *in) +static int +readFloatData(FILE *strm, struct Input *in) { H5DT_FLOAT32 *fp32; - uint32_t *bfp32; - uint32_t temp32; + uint32_t * bfp32; + uint32_t temp32; H5DT_FLOAT64 *fp64; - uint64_t *bfp64; - uint64_t temp64; + uint64_t * bfp64; + uint64_t temp64; hsize_t len = 1; hsize_t i; @@ -822,113 +827,113 @@ static int readFloatData(FILE *strm, struct Input *in) len *= in->sizeOfDimension[j]; switch (in->inputSize) { - case 32: - fp32 = (H5DT_FLOAT32 *) in->data; - switch (in->inputClass) { - case 1: /* TEXTFP */ - for (i = 0; i < len; i++, fp32++) { - if (fscanf(strm, "%f", fp32) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - } + case 32: + fp32 = (H5DT_FLOAT32 *)in->data; + switch (in->inputClass) { + case 1: /* TEXTFP */ + for (i = 0; i < len; i++, fp32++) { + if (fscanf(strm, "%f", fp32) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } - fp32 = (H5DT_FLOAT32 *) in->data; - break; + fp32 = (H5DT_FLOAT32 *)in->data; + break; - /* same as TEXTFP */ - case 2: /*TEXTFPE */ + /* same as TEXTFP */ + case 2: /*TEXTFPE */ - for (i = 0; i < len; i++, fp32++) { - if (fscanf(strm, "%f", fp32) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - } + for (i = 0; i < len; i++, fp32++) { + if (fscanf(strm, "%f", fp32) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } - fp32 = (H5DT_FLOAT32 *) in->data; - break; + fp32 = (H5DT_FLOAT32 *)in->data; + break; - case 3: /* FP */ - bfp32 = (uint32_t *) in->data; - for (i = 0; i < len; i++, bfp32++) { - if (HDfread((char *)&temp32, sizeof(uint32_t), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } -/* - if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) - *bfp32 = swap_uint32(temp32); - else -*/ - *bfp32 = temp32; + case 3: /* FP */ + bfp32 = (uint32_t *)in->data; + for (i = 0; i < len; i++, bfp32++) { + if (HDfread((char *)&temp32, sizeof(uint32_t), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + /* + if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) + *bfp32 = swap_uint32(temp32); + else + */ + *bfp32 = temp32; #ifdef H5DEBUGIMPORT - HDprintf("readFloatData %ld (0x%.8X = 0x%.8X)\n", *bfp32, *bfp32, temp32); + HDprintf("readFloatData %ld (0x%.8X = 0x%.8X)\n", *bfp32, *bfp32, temp32); #endif - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + } + break; - case 64: - fp64 = (H5DT_FLOAT64 *) in->data; - switch (in->inputClass) { - case 1: /* TEXTFP */ - for (i = 0; i < len; i++, fp64++) { - if (fscanf(strm, "%lf", fp64) != 1) { - (void) HDfprintf(stderr, "%s", err1); + default: + (void)HDfprintf(stderr, "%s", err2); return (-1); - } } - - fp64 = (H5DT_FLOAT64 *) in->data; break; - /* same as TEXTFP */ - case 2: /*TEXTFPE */ + case 64: + fp64 = (H5DT_FLOAT64 *)in->data; + switch (in->inputClass) { + case 1: /* TEXTFP */ + for (i = 0; i < len; i++, fp64++) { + if (fscanf(strm, "%lf", fp64) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } - for (i = 0; i < len; i++, fp64++) { - if (fscanf(strm, "%lf", fp64) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - } + fp64 = (H5DT_FLOAT64 *)in->data; + break; - fp64 = (H5DT_FLOAT64 *) in->data; - break; + /* same as TEXTFP */ + case 2: /*TEXTFPE */ - case 3: /* FP */ - bfp64 = (uint64_t *) in->data; - for (i = 0; i < len; i++, bfp64++) { - if (HDfread((char *)&temp64, sizeof(uint64_t), 1, strm) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } -/* - if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) - *bfp64 = swap_uint64(temp64); - else -*/ - *bfp64 = temp64; + for (i = 0; i < len; i++, fp64++) { + if (fscanf(strm, "%lf", fp64) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + } + + fp64 = (H5DT_FLOAT64 *)in->data; + break; + + case 3: /* FP */ + bfp64 = (uint64_t *)in->data; + for (i = 0; i < len; i++, bfp64++) { + if (HDfread((char *)&temp64, sizeof(uint64_t), 1, strm) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + /* + if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder)) + *bfp64 = swap_uint64(temp64); + else + */ + *bfp64 = temp64; #ifdef H5DEBUGIMPORT - HDprintf("readFloatData %ld (0x%.16lX)\n", *bfp64, temp64); + HDprintf("readFloatData %ld (0x%.16lX)\n", *bfp64, temp64); #endif + } + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); } break; default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - break; + (void)HDfprintf(stderr, "%s", err3); + break; } return (0); } @@ -947,7 +952,8 @@ static int readFloatData(FILE *strm, struct Input *in) * *------------------------------------------------------------------------- */ -static int processStrData(FILE *strm, struct Input *in, hid_t file_id) +static int +processStrData(FILE *strm, struct Input *in, hid_t file_id) { hid_t group_id; hid_t dset_id; @@ -968,8 +974,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) *------------------------------------------------------------------------- */ - while(EOF != (c = HDfgetc(strm))) - if (c == 10) /* eol */ + while (EOF != (c = HDfgetc(strm))) + if (c == 10) /* eol */ nlines++; if (!nlines) @@ -997,13 +1003,14 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) { /* create parent groups */ if (in->path.count > 1) { - j = 0; + j = 0; handle = file_id; while (j < in->path.count - 1) { if ((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) { group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); for (; j < in->path.count - 1; j++) - group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group_id = + H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); handle = group_id; break; } @@ -1013,7 +1020,7 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) } else { handle = file_id; - j = 0; + j = 0; } /*enable error reporting */ @@ -1026,21 +1033,22 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) if ((mspace_id = H5Screate(H5S_SCALAR)) < 0) goto out; - if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto out; line = 0; - while(EOF != (c = HDfgetc(strm))) { + while (EOF != (c = HDfgetc(strm))) { str[i] = (char)c; i++; if (c == 10) { /* eol */ - char *str2 = str; - hid_t fspace_id; + char * str2 = str; + hid_t fspace_id; hsize_t start[1]; - hsize_t count[1] = { 1 }; + hsize_t count[1] = {1}; str[i - 1] = '\0'; /* terminate string */ @@ -1058,9 +1066,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) if (H5Sclose(fspace_id) < 0) goto out; - i = 0; + i = 0; str[0] = '\0'; - } } @@ -1087,20 +1094,21 @@ out: * *------------------------------------------------------------------------- */ -static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) +static int +processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) { - hid_t group_id = H5I_INVALID_HID; - hid_t dset_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t mspace_id = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - hid_t handle = H5I_INVALID_HID; - char *str1 = NULL; - char *str2 = NULL; - char *str3 = NULL; - char str[1024] = ""; + hid_t group_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + hid_t handle = H5I_INVALID_HID; + char * str1 = NULL; + char * str2 = NULL; + char * str3 = NULL; + char str[1024] = ""; int j; - hsize_t line; + hsize_t line; /*------------------------------------------------------------------------- * read file and generate an HDF5 dataset @@ -1121,13 +1129,14 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) { /* create parent groups */ if (in->path.count > 1) { - j = 0; + j = 0; handle = file_id; while (j < in->path.count - 1) { if ((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) { group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); for (; j < in->path.count - 1; j++) - group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group_id = + H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); handle = group_id; break; } @@ -1137,7 +1146,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) } else { handle = file_id; - j = 0; + j = 0; } /*enable error reporting */ @@ -1153,67 +1162,69 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) if ((mspace_id = H5Screate(H5S_SCALAR)) < 0) goto out; - if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto out; #ifdef H5DEBUGIMPORT HDprintf("processStrHDFData DATATYPE STRING ready to process strings\n"); #endif line = 0; - j = 0; + j = 0; - while (HDfgets(str,sizeof(str),strm)) { + while (HDfgets(str, sizeof(str), strm)) { str1 = str; str2 = NULL; str3 = NULL; #ifdef H5DEBUGIMPORT - HDprintf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1); + HDprintf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1); #endif - /* process string to remove the first and last quote char */ - str2 = strchr(str1, '"'); - if (str2 != NULL) { + /* process string to remove the first and last quote char */ + str2 = strchr(str1, '"'); + if (str2 != NULL) { #ifdef H5DEBUGIMPORT - HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); + HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); #endif - str2++; + str2++; #ifdef H5DEBUGIMPORT - HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); + HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); #endif - str3 = strrchr(str2, '"'); - if (str3 != NULL) { + str3 = strrchr(str2, '"'); + if (str3 != NULL) { #ifdef H5DEBUGIMPORT - HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str3), str3); + HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str3), str3); #endif - *str3 = '\0'; + *str3 = '\0'; #ifdef H5DEBUGIMPORT - HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); + HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); #endif - if(HDstrlen(str2) > 0) { - hid_t fspace_id; - hsize_t start[1]; - hsize_t count[1] = { 1 }; + if (HDstrlen(str2) > 0) { + hid_t fspace_id; + hsize_t start[1]; + hsize_t count[1] = {1}; #ifdef H5DEBUGIMPORT - HDprintf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line, str2); + HDprintf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line, + str2); #endif - if ((fspace_id = H5Dget_space(dset_id)) < 0) - goto out; + if ((fspace_id = H5Dget_space(dset_id)) < 0) + goto out; - start[0] = line++; + start[0] = line++; - if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) - goto out; + if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + goto out; - if (H5Dwrite(dset_id, type_id, mspace_id, fspace_id, H5P_DEFAULT, &str2) < 0) - goto out; + if (H5Dwrite(dset_id, type_id, mspace_id, fspace_id, H5P_DEFAULT, &str2) < 0) + goto out; - if (H5Sclose(fspace_id) < 0) - goto out; - } + if (H5Sclose(fspace_id) < 0) + goto out; } } + } str[0] = '\0'; j++; } @@ -1233,21 +1244,22 @@ out: #ifdef H5DEBUGIMPORT HDprintf("processStrHDFData DATATYPE STRING error exit\n"); #endif -/* disable error reporting */ -H5E_BEGIN_TRY -{ - /* close */ - H5Dclose(dset_id); - H5Sclose(space_id); - H5Sclose(mspace_id); - H5Tclose(type_id); -} -H5E_END_TRY; + /* disable error reporting */ + H5E_BEGIN_TRY + { + /* close */ + H5Dclose(dset_id); + H5Sclose(space_id); + H5Sclose(mspace_id); + H5Tclose(type_id); + } + H5E_END_TRY; return (-1); } -static int allocateIntegerStorage(struct Input *in) +static int +allocateIntegerStorage(struct Input *in) { hsize_t len = 1; int j; @@ -1258,44 +1270,45 @@ static int allocateIntegerStorage(struct Input *in) len *= in->sizeOfDimension[j]; switch (in->inputSize) { - case 8: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_INT8))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 8: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_INT8))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - case 16: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_INT16))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 16: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_INT16))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - case 32: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_INT32))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 32: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_INT32))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - case 64: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_INT64))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 64: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_INT64))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - default: - (void) HDfprintf(stderr, "%s", err2); - break; + default: + (void)HDfprintf(stderr, "%s", err2); + break; } return (0); } -static int allocateUIntegerStorage(struct Input *in) +static int +allocateUIntegerStorage(struct Input *in) { - hsize_t len = 1; + hsize_t len = 1; const char *err1 = "Unable to allocate dynamic memory.\n"; const char *err2 = "Invalid storage size for unsigned integer input data.\n"; int j; @@ -1304,42 +1317,43 @@ static int allocateUIntegerStorage(struct Input *in) len *= in->sizeOfDimension[j]; switch (in->inputSize) { - case 8: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_UINT8))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 8: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_UINT8))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - case 16: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_UINT16))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 16: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_UINT16))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - case 32: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_UINT32))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 32: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_UINT32))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - case 64: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_UINT64))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 64: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_UINT64))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - default: - (void) HDfprintf(stderr, "%s", err2); - break; + default: + (void)HDfprintf(stderr, "%s", err2); + break; } return (0); } -static int allocateFloatStorage(struct Input *in) +static int +allocateFloatStorage(struct Input *in) { hsize_t len = 1; int j; @@ -1350,54 +1364,55 @@ static int allocateFloatStorage(struct Input *in) len *= in->sizeOfDimension[j]; switch (in->inputSize) { - case 32: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_FLOAT32))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 32: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_FLOAT32))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - case 64: - if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_FLOAT64))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - break; + case 64: + if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_FLOAT64))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + break; - default: - (void) HDfprintf(stderr, "%s", err2); - break; + default: + (void)HDfprintf(stderr, "%s", err2); + break; } return (0); } -static int processConfigurationFile(char *infile, struct Input *in) +static int +processConfigurationFile(char *infile, struct Input *in) { - FILE *strm = NULL; - char key[MAX_PATH_NAME_LENGTH]; - int kindex; - char temp[MAX_PATH_NAME_LENGTH]; - int ival; - int scanret; - int retval = -1; - - const char *err1 = "Unable to open the configuration file: %s for reading.\n"; - const char *err2 = "Unknown keyword: %s in configuration file: %s\n"; - const char *err3a = "PATH keyword appears twice in %s.\n"; - const char *err3b = "Error in parsing the path information from %s.\n"; - const char *err4a = "INPUT-CLASS keyword appears twice in %s.\n"; - const char *err4b = "Error in retrieving the input class from %s.\n"; - const char *err5a = "INPUT-SIZE keyword appears twice in %s.\n"; - const char *err5b = "Error in retrieving the input size from %s.\n"; - const char *err6a = "RANK keyword appears twice in %s.\n"; - const char *err6b = "Error in retrieving the rank from %s.\n"; - const char *err7a = "DIMENSION-SIZES keyword appears twice in %s.\n"; - const char *err7b = "DIMENSION-SIZES cannot appear before RANK is provided.\n"; - const char *err7c = "Error in retrieving the dimension sizes from %s.\n"; - const char *err8a = "OUTPUT-CLASS keyword appears twice in %s.\n"; - const char *err8b = "Error in retrieving the output class from %s.\n"; - const char *err9a = "OUTPUT-SIZE keyword appears twice in %s.\n"; - const char *err9b = "Error in retrieving the output size from %s.\n"; + FILE *strm = NULL; + char key[MAX_PATH_NAME_LENGTH]; + int kindex; + char temp[MAX_PATH_NAME_LENGTH]; + int ival; + int scanret; + int retval = -1; + + const char *err1 = "Unable to open the configuration file: %s for reading.\n"; + const char *err2 = "Unknown keyword: %s in configuration file: %s\n"; + const char *err3a = "PATH keyword appears twice in %s.\n"; + const char *err3b = "Error in parsing the path information from %s.\n"; + const char *err4a = "INPUT-CLASS keyword appears twice in %s.\n"; + const char *err4b = "Error in retrieving the input class from %s.\n"; + const char *err5a = "INPUT-SIZE keyword appears twice in %s.\n"; + const char *err5b = "Error in retrieving the input size from %s.\n"; + const char *err6a = "RANK keyword appears twice in %s.\n"; + const char *err6b = "Error in retrieving the rank from %s.\n"; + const char *err7a = "DIMENSION-SIZES keyword appears twice in %s.\n"; + const char *err7b = "DIMENSION-SIZES cannot appear before RANK is provided.\n"; + const char *err7c = "Error in retrieving the dimension sizes from %s.\n"; + const char *err8a = "OUTPUT-CLASS keyword appears twice in %s.\n"; + const char *err8b = "Error in retrieving the output class from %s.\n"; + const char *err9a = "OUTPUT-SIZE keyword appears twice in %s.\n"; + const char *err9b = "Error in retrieving the output size from %s.\n"; const char *err10a = "OUTPUT-ARCHITECTURE keyword appears twice in %s.\n"; const char *err10b = "Error in retrieving the output architecture from %s.\n"; const char *err11a = "OUTPUT-BYTE-ORDER keyword appears twice in %s.\n"; @@ -1417,10 +1432,10 @@ static int processConfigurationFile(char *infile, struct Input *in) const char *err16a = "MAXIMUM-DIMENSIONS keyword appears twice in %s.\n"; const char *err16b = "MAXIMUM-DIMENSIONS cannot appear before DIMENSION-SIZES are provided.\n"; const char *err16c = "Error in retrieving the maximum dimension sizes from %s.\n"; - const char *err17 = "Configuration parameters are invalid in %s.\n"; - const char *err18 = "Unable to get string value.\n"; - const char *err19 = "Unable to get integer value.\n"; - const char *err20 = "Unable to get subset values.\n"; + const char *err17 = "Configuration parameters are invalid in %s.\n"; + const char *err18 = "Unable to get string value.\n"; + const char *err19 = "Unable to get integer value.\n"; + const char *err20 = "Unable to get subset values.\n"; /* create vector to map which keywords have been found check vector after each keyword to check for violation @@ -1429,17 +1444,17 @@ static int processConfigurationFile(char *infile, struct Input *in) */ /* Initialize machine endian */ - volatile uint32_t ibyte=0x01234567; + volatile uint32_t ibyte = 0x01234567; /* 0 for big endian, 1 for little endian. */ - if ((*((volatile uint8_t*)(&ibyte))) == 0x67) { + if ((*((volatile uint8_t *)(&ibyte))) == 0x67) { if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err11e); + (void)HDfprintf(stderr, "%s", err11e); return (-1); } } else { if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err11e); + (void)HDfprintf(stderr, "%s", err11e); return (-1); } } @@ -1450,64 +1465,64 @@ static int processConfigurationFile(char *infile, struct Input *in) in->inputArchitecture = 0; /* default to NATIVE */ if ((strm = HDfopen(infile, "r")) == NULL) { - (void) HDfprintf(stderr, err1, infile); + (void)HDfprintf(stderr, err1, infile); goto error; } scanret = fscanf(strm, "%254s", key); - if((scanret == 1) && !HDstrcmp("HDF5", key)) { + if ((scanret == 1) && !HDstrcmp("HDF5", key)) { #ifdef H5DEBUGIMPORT int pndx; HDprintf("\nh5dump file\n"); #endif in->h5dumpInput = 1; - scanret = fscanf(strm, "%254s", temp); /* filename */ - scanret = fscanf(strm, "%254s", temp); /* start bracket */ - scanret = fscanf(strm, "%254s", key); /* DATASET */ + scanret = fscanf(strm, "%254s", temp); /* filename */ + scanret = fscanf(strm, "%254s", temp); /* start bracket */ + scanret = fscanf(strm, "%254s", key); /* DATASET */ while (scanret == 1) { - if(!HDstrcmp("DATASET", key)) { /* PATH */ + if (!HDstrcmp("DATASET", key)) { /* PATH */ #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASET key\n"); #endif if (in->configOptionVector[PATH] == 1) { - (void) HDfprintf(stderr, err3a, infile); + (void)HDfprintf(stderr, err3a, infile); goto error; } if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASET %s found\n", temp); #endif if (parsePathInfo(&in->path, temp) == -1) { - (void) HDfprintf(stderr, err3b, infile); + (void)HDfprintf(stderr, err3b, infile); goto error; } in->configOptionVector[PATH] = 1; - scanret = fscanf(strm, "%254s", temp); /* start bracket */ + scanret = fscanf(strm, "%254s", temp); /* start bracket */ #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASET %s found\n", temp); #endif - } /* if(!HDstrcmp("DATASET", key)) PATH */ - else if(!HDstrcmp("DATATYPE", key)) { /* INPUT-CLASS */ + } /* if(!HDstrcmp("DATASET", key)) PATH */ + else if (!HDstrcmp("DATATYPE", key)) { /* INPUT-CLASS */ #ifdef H5DEBUGIMPORT HDprintf("h5dump DATATYPE key\n"); #endif if (in->configOptionVector[INPUT_CLASS] == 1) { - (void) HDfprintf(stderr, err4a, infile); + (void)HDfprintf(stderr, err4a, infile); goto error; } if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATATYPE %s found\n", temp); #endif if ((kindex = getInputClassType(in, temp)) == -1) { - (void) HDfprintf(stderr, err4b, infile); + (void)HDfprintf(stderr, err4b, infile); goto error; } #ifdef H5DEBUGIMPORT @@ -1520,8 +1535,7 @@ static int processConfigurationFile(char *infile, struct Input *in) if (in->configOptionVector[OUTPUT_CLASS] == 0) { if (in->inputClass == 0 || in->inputClass == 4) in->outputClass = 0; - if (in->inputClass == 1 || in->inputClass == 2 - || in->inputClass == 3) + if (in->inputClass == 1 || in->inputClass == 2 || in->inputClass == 3) in->outputClass = 1; if (in->inputClass == 6 || in->inputClass == 7) in->outputClass = 2; @@ -1530,27 +1544,27 @@ static int processConfigurationFile(char *infile, struct Input *in) HDprintf("h5dump DATATYPE type %d outputClass\n", in->outputClass); #endif - if(in->inputClass == 5) { /* STRING */ + if (in->inputClass == 5) { /* STRING */ int get_next_prop = 1; - in->outputClass = -1; + in->outputClass = -1; #ifdef H5DEBUGIMPORT HDprintf("h5dump DATATYPE STRING found\n"); #endif if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATATYPE STRING %s found\n", temp); #endif if (fscanf(strm, "%254s", temp) != 1) { /* string properties */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } while (get_next_prop) { - if(!HDstrcmp("STRSIZE", temp)) { /* STRSIZE */ + if (!HDstrcmp("STRSIZE", temp)) { /* STRSIZE */ if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err19); + (void)HDfprintf(stderr, "%s", err19); goto error; } #ifdef H5DEBUGIMPORT @@ -1558,9 +1572,9 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif if (HDstrcmp("H5T_VARIABLE;", temp)) { char *more = temp; - ival = (int)HDstrtol(more, &more, 10); + ival = (int)HDstrtol(more, &more, 10); if (getInputSize(in, ival) == -1) { - (void) HDfprintf(stderr, err5b, infile); + (void)HDfprintf(stderr, err5b, infile); goto error; } #ifdef H5DEBUGIMPORT @@ -1568,28 +1582,27 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif } } - else if(!HDstrcmp("STRPAD", temp)) { /* STRPAD */ + else if (!HDstrcmp("STRPAD", temp)) { /* STRPAD */ if (fscanf(strm, "%254s", temp) != 1) { /* STRPAD type */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATATYPE STRING STRPAD %s found\n", temp); #endif } - else if(!HDstrcmp("CSET", key)) { /* CSET */ + else if (!HDstrcmp("CSET", key)) { /* CSET */ if (fscanf(strm, "%254s", temp) != 1) { /* CSET type */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATATYPE STRING CSET %s found\n", temp); #endif - } - else if(!HDstrcmp("CTYPE", temp)) { /* CTYPE */ + else if (!HDstrcmp("CTYPE", temp)) { /* CTYPE */ if (fscanf(strm, "%254s", temp) != 1) { /* CTYPE type */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT @@ -1597,90 +1610,91 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif } /* if(!HDstrcmp("CSET", key)) */ if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATATYPE STRING %s found\n", temp); #endif - if(!HDstrcmp("}", temp)) { /* end bracket */ + if (!HDstrcmp("}", temp)) { /* end bracket */ get_next_prop = 0; } - } /* while (get_next_prop) */ - } /* if(kindex == 5) STRING */ - } /* else if(!HDstrcmp("DATATYPE", key)) INPUT-CLASS */ - else if(!HDstrcmp("DATASPACE", key)) { /* RANK and DIMENSIONS */ - hsize_t temp_dims[MAX_NUM_DIMENSION]; + } /* while (get_next_prop) */ + } /* if(kindex == 5) STRING */ + } /* else if(!HDstrcmp("DATATYPE", key)) INPUT-CLASS */ + else if (!HDstrcmp("DATASPACE", key)) { /* RANK and DIMENSIONS */ + hsize_t temp_dims[MAX_NUM_DIMENSION]; #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE key\n"); #endif if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } - if(!HDstrcmp("SCALAR", temp)) { /* SCALAR */ + if (!HDstrcmp("SCALAR", temp)) { /* SCALAR */ in->rank = 0; - } /* if(!HDstrcmp("SCALAR", key)) */ - else if(!HDstrcmp("NULL", temp)) { /* NULL */ - (void) HDfprintf(stderr, err6b, infile); + } /* if(!HDstrcmp("SCALAR", key)) */ + else if (!HDstrcmp("NULL", temp)) { /* NULL */ + (void)HDfprintf(stderr, err6b, infile); goto error; - } /* else if(!HDstrcmp("NULL", key)) */ - else if(!HDstrcmp("SIMPLE", temp)) { /* SIMPLE */ + } /* else if(!HDstrcmp("NULL", key)) */ + else if (!HDstrcmp("SIMPLE", temp)) { /* SIMPLE */ int icount = 0; #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE found\n"); #endif if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif - if(!HDstrcmp("(", temp)) { /* start paren */ + if (!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; - int i = 0; + int i = 0; if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */ - (void) HDfprintf(stderr, err16c, infile); + (void)HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif while (get_next_dim) { - char *more = temp; + char *more = temp; temp_dims[icount] = HDstrtoull(more, &more, 10); if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif - if(!HDstrcmp(")", temp)) { /* end paren */ - in->rank = ++icount; + if (!HDstrcmp(")", temp)) { /* end paren */ + in->rank = ++icount; in->configOptionVector[RANK] = 1; - get_next_dim = 0; + get_next_dim = 0; } else { /* Dimension */ icount++; if (icount > MAX_NUM_DIMENSION) { - (void) HDfprintf(stderr, "Invalid value for rank.\n"); + (void)HDfprintf(stderr, "Invalid value for rank.\n"); goto error; } } } /* while (get_next_dim) */ - if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { + if ((in->sizeOfDimension = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == + NULL) { goto error; } #ifdef H5DEBUGIMPORT @@ -1699,36 +1713,37 @@ static int processConfigurationFile(char *infile, struct Input *in) in->configOptionVector[DIM] = 1; } /* if(!HDstrcmp("(", key)) start paren */ else { - (void) HDfprintf(stderr, err5b, infile); + (void)HDfprintf(stderr, err5b, infile); goto error; } if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif - if(!HDstrcmp("/", temp)) { /* / max dims */ - if ((in->maxsizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { + if (!HDstrcmp("/", temp)) { /* / max dims */ + if ((in->maxsizeOfDimension = + (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) { goto error; } if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif - if(!HDstrcmp("(", temp)) { /* start paren */ + if (!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; - int i = 0; + int i = 0; #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE process max dim values\n"); #endif if (fscanf(strm, "%254s", temp) != 1) { /* max dim with optional comma */ - (void) HDfprintf(stderr, err16c, infile); + (void)HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT @@ -1738,28 +1753,29 @@ static int processConfigurationFile(char *infile, struct Input *in) #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE get max dim value\n"); #endif - if(!HDstrcmp("H5S_UNLIMITED", temp) || !HDstrcmp("H5S_UNLIMITED,", temp)) { /* unlimited */ - in->maxsizeOfDimension[i] = H5S_UNLIMITED; + if (!HDstrcmp("H5S_UNLIMITED", temp) || + !HDstrcmp("H5S_UNLIMITED,", temp)) { /* unlimited */ + in->maxsizeOfDimension[i] = H5S_UNLIMITED; in->configOptionVector[EXTEND] = 1; } else { - char *more = temp; + char *more = temp; in->maxsizeOfDimension[i] = HDstrtoull(more, &more, 10); } if (fscanf(strm, "%254s", temp) != 1) { /* max dim or end paren */ - (void) HDfprintf(stderr, err16c, infile); + (void)HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif - if(!HDstrcmp(")", temp)) { /* end paren */ + if (!HDstrcmp(")", temp)) { /* end paren */ get_next_dim = 0; } else { /* comma */ i++; if (i >= MAX_NUM_DIMENSION) { - (void) HDfprintf(stderr, "Invalid value for rank.\n"); + (void)HDfprintf(stderr, "Invalid value for rank.\n"); goto error; } } @@ -1774,7 +1790,7 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif } /* if(!HDstrcmp("(", key)) start paren */ else { - (void) HDfprintf(stderr, err16c, infile); + (void)HDfprintf(stderr, err16c, infile); goto error; } scanret = fscanf(strm, "%254s", temp); /* end bracket */ @@ -1782,71 +1798,71 @@ static int processConfigurationFile(char *infile, struct Input *in) HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif } /* if(!HDstrcmp("/", key)) max dims separator */ - } /* else if(!HDstrcmp("SIMPLE", key)) */ + } /* else if(!HDstrcmp("SIMPLE", key)) */ else { - (void) HDfprintf(stderr, err5b, infile); + (void)HDfprintf(stderr, err5b, infile); goto error; } } /* else if(!HDstrcmp("DATASPACE", key)) RANK and DIMENSIONS */ - else if(!HDstrcmp("STORAGE_LAYOUT", key)) { /* CHUNKED-DIMENSION-SIZES */ + else if (!HDstrcmp("STORAGE_LAYOUT", key)) { /* CHUNKED-DIMENSION-SIZES */ #ifdef H5DEBUGIMPORT HDprintf("h5dump STORAGE_LAYOUT key\n"); #endif if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump STORAGE_LAYOUT %s found\n", temp); #endif if (fscanf(strm, "%254s", temp) != 1) { /* CHUNKED */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump STORAGE_LAYOUT %s found\n", temp); #endif - if(!HDstrcmp("CHUNKED", temp)) { /* CHUNKED */ - if ((in->sizeOfChunk = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { - (void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n"); + if (!HDstrcmp("CHUNKED", temp)) { /* CHUNKED */ + if ((in->sizeOfChunk = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) { + (void)HDfprintf(stderr, "Unable to allocate dynamic memory.\n"); goto error; } if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif - if(!HDstrcmp("(", temp)) { /* start paren */ + if (!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; - int icount = 0; + int icount = 0; if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */ - (void) HDfprintf(stderr, err16c, infile); + (void)HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif while (get_next_dim) { - char *more = temp; + char *more = temp; in->sizeOfChunk[icount] = HDstrtoull(more, &more, 10); if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif - if(!HDstrcmp(")", temp)) { /* end paren */ + if (!HDstrcmp(")", temp)) { /* end paren */ in->configOptionVector[RANK] = 1; - get_next_dim = 0; + get_next_dim = 0; } else { /* Dimension */ icount++; if (icount > MAX_NUM_DIMENSION) { - (void) HDfprintf(stderr, "Invalid value for rank.\n"); + (void)HDfprintf(stderr, "Invalid value for rank.\n"); goto error; } } @@ -1861,19 +1877,19 @@ static int processConfigurationFile(char *infile, struct Input *in) in->configOptionVector[DIM] = 1; } /* if(!HDstrcmp("(", key)) start paren */ else { - (void) HDfprintf(stderr, err5b, infile); + (void)HDfprintf(stderr, err5b, infile); goto error; } if (fscanf(strm, "%254s", temp) != 1) { /* SIZE */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif - if(!HDstrcmp("SIZE", temp)) { /* SIZE */ + if (!HDstrcmp("SIZE", temp)) { /* SIZE */ if (fscanf(strm, "%d", (&ival)) != 1) { - (void) HDfprintf(stderr, "%s", err19); + (void)HDfprintf(stderr, "%s", err19); goto error; } #ifdef H5DEBUGIMPORT @@ -1882,7 +1898,7 @@ static int processConfigurationFile(char *infile, struct Input *in) } while (HDstrcmp("}", temp)) { if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT @@ -1891,52 +1907,52 @@ static int processConfigurationFile(char *infile, struct Input *in) } in->configOptionVector[CHUNK] = 1; } /* if(!HDstrcmp("CHUNKED", key)) CHUNKED */ - } /* else if(!HDstrcmp("STORAGE_LAYOUT", key)) CHUNKED-DIMENSION-SIZES */ - else if(!HDstrcmp("FILTERS", key)) { /* FILTERS */ + } /* else if(!HDstrcmp("STORAGE_LAYOUT", key)) CHUNKED-DIMENSION-SIZES */ + else if (!HDstrcmp("FILTERS", key)) { /* FILTERS */ #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS key\n"); #endif if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS %s found\n", temp); #endif if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS %s found\n", temp); #endif - if(!HDstrcmp("COMPRESSION", temp)) { /* COMPRESSION */ + if (!HDstrcmp("COMPRESSION", temp)) { /* COMPRESSION */ #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS COMPRESSION found\n"); #endif if (fscanf(strm, "%254s", temp) != 1) { /* DEFLATE */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp); #endif if (fscanf(strm, "%254s", temp) != 1) { /* bgin bracket */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp); #endif if (fscanf(strm, "%254s", temp) != 1) { /* LEVEL */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp); #endif if (fscanf(strm, "%d", (&ival)) != 1) { - (void) HDfprintf(stderr, "%s", err19); + (void)HDfprintf(stderr, "%s", err19); goto error; } #ifdef H5DEBUGIMPORT @@ -1944,95 +1960,95 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif in->compressionParam = ival; if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp); #endif - in->compressionType = 0; /* ONLY GZIP supported */ + in->compressionType = 0; /* ONLY GZIP supported */ in->configOptionVector[COMPRESS] = 1; } - else if(!HDstrcmp("CONTIGUOUS", temp)) { /* CONTIGUOUS */ + else if (!HDstrcmp("CONTIGUOUS", temp)) { /* CONTIGUOUS */ #ifdef H5DEBUGIMPORT - HDprintf("h5dump FILTERS CONTIGUOUS found\n"); + HDprintf("h5dump FILTERS CONTIGUOUS found\n"); #endif in->configOptionVector[COMPRESS] = 0; } - else if(!HDstrcmp("NONE", temp)) { /* NONE */ + else if (!HDstrcmp("NONE", temp)) { /* NONE */ #ifdef H5DEBUGIMPORT - HDprintf("h5dump FILTERS NONE found\n"); + HDprintf("h5dump FILTERS NONE found\n"); #endif in->configOptionVector[COMPRESS] = 0; } if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump FILTERS %s found\n", temp); #endif } - else if(!HDstrcmp("SUBSET", key)) { /* reduce dimensions */ - hsize_t temp_dims[MAX_NUM_DIMENSION]; - int get_next_prop = 1; + else if (!HDstrcmp("SUBSET", key)) { /* reduce dimensions */ + hsize_t temp_dims[MAX_NUM_DIMENSION]; + int get_next_prop = 1; #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET key\n"); #endif if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ - (void) HDfprintf(stderr, err20, infile); + (void)HDfprintf(stderr, err20, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET %s found\n", temp); #endif if (fscanf(strm, "%254s", temp) != 1) { /* SUBSET keyword */ - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET %s found\n", temp); #endif while (get_next_prop) { - if(!HDstrcmp("COUNT", temp)) { /* COUNT */ + if (!HDstrcmp("COUNT", temp)) { /* COUNT */ int icount = 0; if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET %s found\n", temp); #endif - if(!HDstrcmp("(", temp)) { /* start paren */ + if (!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; - int i = 0; + int i = 0; if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */ - (void) HDfprintf(stderr, err16c, infile); + (void)HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET COUNT [%s] found\n", temp); #endif while (get_next_dim) { - char *more = temp; + char *more = temp; temp_dims[icount] = HDstrtoull(more, &more, 10); if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET COUNT %s found\n", temp); #endif - if(!HDstrcmp(");", temp)) { /* end paren */ - in->rank = ++icount; + if (!HDstrcmp(");", temp)) { /* end paren */ + in->rank = ++icount; in->configOptionVector[RANK] = 1; - get_next_dim = 0; + get_next_dim = 0; } else { /* Dimension */ icount++; if (icount >= MAX_NUM_DIMENSION) { - (void) HDfprintf(stderr, "Invalid value for rank.\n"); + (void)HDfprintf(stderr, "Invalid value for rank.\n"); goto error; } } @@ -2048,47 +2064,47 @@ static int processConfigurationFile(char *infile, struct Input *in) HDprintf("\n"); #endif in->configOptionVector[DIM] = 1; - } /* if(!HDstrcmp("(", key)) start paren */ - } /* if(!HDstrcmp("COUNT", temp)) COUNT */ - if(!HDstrcmp("BLOCK", temp)) { /* BLOCK */ + } /* if(!HDstrcmp("(", key)) start paren */ + } /* if(!HDstrcmp("COUNT", temp)) COUNT */ + if (!HDstrcmp("BLOCK", temp)) { /* BLOCK */ int icount = 0; if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET %s found\n", temp); #endif - if(!HDstrcmp("(", temp)) { /* start paren */ + if (!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; - int i = 0; + int i = 0; if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */ - (void) HDfprintf(stderr, err16c, infile); + (void)HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT - HDprintf("h5dump SUBSET BLOCK [%s] found\n", temp); + HDprintf("h5dump SUBSET BLOCK [%s] found\n", temp); #endif while (get_next_dim) { - char *more = temp; + char *more = temp; temp_dims[icount] = HDstrtoull(more, &more, 10); if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */ - (void) HDfprintf(stderr, err6b, infile); + (void)HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET BLOCK %s found\n", temp); #endif - if(!HDstrcmp(");", temp)) { /* end paren */ - in->rank = ++icount; + if (!HDstrcmp(");", temp)) { /* end paren */ + in->rank = ++icount; in->configOptionVector[RANK] = 1; - get_next_dim = 0; + get_next_dim = 0; } else { /* Dimension */ icount++; if (icount > MAX_NUM_DIMENSION) { - (void) HDfprintf(stderr, "Invalid value for rank.\n"); + (void)HDfprintf(stderr, "Invalid value for rank.\n"); goto error; } } @@ -2105,20 +2121,20 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif in->configOptionVector[DIM] = 1; } /* if(!HDstrcmp("(", key)) start paren */ - } /* if(!HDstrcmp("BLOCK", temp)) BLOCK */ + } /* if(!HDstrcmp("BLOCK", temp)) BLOCK */ if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); + (void)HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT HDprintf("h5dump SUBSET %s found\n", temp); #endif - if(!HDstrcmp("}", temp)) { /* end bracket */ + if (!HDstrcmp("}", temp)) { /* end bracket */ get_next_prop = 0; } - } /* while (get_next_prop) */ - } /* else if(!HDstrcmp("SUBSET", key)) */ - else if(!HDstrcmp("DATA", key)) { /* FINSHED */ + } /* while (get_next_prop) */ + } /* else if(!HDstrcmp("SUBSET", key)) */ + else if (!HDstrcmp("DATA", key)) { /* FINSHED */ #ifdef H5DEBUGIMPORT HDprintf("h5dump DATA key\n"); #endif @@ -2157,256 +2173,255 @@ static int processConfigurationFile(char *infile, struct Input *in) #endif while (scanret == 1) { if ((kindex = mapKeywordToIndex(key)) == -1) { - (void) HDfprintf(stderr, err2, key, infile); + (void)HDfprintf(stderr, err2, key, infile); goto error; } switch (kindex) { - case 0: /* PATH */ - if (in->configOptionVector[PATH] == 1) { - (void) HDfprintf(stderr, err3a, infile); - goto error; - } - if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); - goto error; - } - if (parsePathInfo(&in->path, temp) == -1) { - (void) HDfprintf(stderr, err3b, infile); - goto error; - } - in->configOptionVector[PATH] = 1; - break; + case 0: /* PATH */ + if (in->configOptionVector[PATH] == 1) { + (void)HDfprintf(stderr, err3a, infile); + goto error; + } + if (fscanf(strm, "%254s", temp) != 1) { + (void)HDfprintf(stderr, "%s", err18); + goto error; + } + if (parsePathInfo(&in->path, temp) == -1) { + (void)HDfprintf(stderr, err3b, infile); + goto error; + } + in->configOptionVector[PATH] = 1; + break; - case 1: /* INPUT-CLASS */ - if (in->configOptionVector[INPUT_CLASS] == 1) { - (void) HDfprintf(stderr, err4a, infile); - goto error; - } + case 1: /* INPUT-CLASS */ + if (in->configOptionVector[INPUT_CLASS] == 1) { + (void)HDfprintf(stderr, err4a, infile); + goto error; + } - if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err18); - goto error; - } - if (getInputClass(in, temp) == -1) { - (void) HDfprintf(stderr, err4b, infile); - goto error; - } + if (fscanf(strm, "%254s", temp) != 1) { + (void)HDfprintf(stderr, "%s", err18); + goto error; + } + if (getInputClass(in, temp) == -1) { + (void)HDfprintf(stderr, err4b, infile); + goto error; + } - in->configOptionVector[INPUT_CLASS] = 1; + in->configOptionVector[INPUT_CLASS] = 1; - /*set default value for output-class */ - if (in->configOptionVector[OUTPUT_CLASS] == 0) { - if (in->inputClass == 0 || in->inputClass == 4) - in->outputClass = 0; - if (in->inputClass == 1 || in->inputClass == 2 - || in->inputClass == 3) - in->outputClass = 1; - if (in->inputClass == 6 || in->inputClass == 7) - in->outputClass = 2; - } - break; + /*set default value for output-class */ + if (in->configOptionVector[OUTPUT_CLASS] == 0) { + if (in->inputClass == 0 || in->inputClass == 4) + in->outputClass = 0; + if (in->inputClass == 1 || in->inputClass == 2 || in->inputClass == 3) + in->outputClass = 1; + if (in->inputClass == 6 || in->inputClass == 7) + in->outputClass = 2; + } + break; - case 2: /* INPUT-SIZE */ - if (in->configOptionVector[INPUT_SIZE] == 1) { - (void) HDfprintf(stderr, err5a, infile); - goto error; - } - if (fscanf(strm, "%254d", (&ival)) != 1) { - (void) HDfprintf(stderr, "%s", err19); - goto error; - } - if (getInputSize(in, ival) == -1) { - (void) HDfprintf(stderr, err5b, infile); - goto error; - } - in->configOptionVector[INPUT_SIZE] = 1; + case 2: /* INPUT-SIZE */ + if (in->configOptionVector[INPUT_SIZE] == 1) { + (void)HDfprintf(stderr, err5a, infile); + goto error; + } + if (fscanf(strm, "%254d", (&ival)) != 1) { + (void)HDfprintf(stderr, "%s", err19); + goto error; + } + if (getInputSize(in, ival) == -1) { + (void)HDfprintf(stderr, err5b, infile); + goto error; + } + in->configOptionVector[INPUT_SIZE] = 1; - /*set default value for output-size */ - if (in->configOptionVector[OUTPUT_SIZE] == 0) - in->outputSize = in->inputSize; - break; + /*set default value for output-size */ + if (in->configOptionVector[OUTPUT_SIZE] == 0) + in->outputSize = in->inputSize; + break; - case 3: /* RANK */ - if (in->configOptionVector[RANK] == 1) { - (void) HDfprintf(stderr, err6a, infile); - goto error; - } + case 3: /* RANK */ + if (in->configOptionVector[RANK] == 1) { + (void)HDfprintf(stderr, err6a, infile); + goto error; + } - if (getRank(in, strm) == -1) { - (void) HDfprintf(stderr, err6b, infile); - goto error; - } - in->configOptionVector[RANK] = 1; - break; + if (getRank(in, strm) == -1) { + (void)HDfprintf(stderr, err6b, infile); + goto error; + } + in->configOptionVector[RANK] = 1; + break; - case 4: /* DIMENSION-SIZES */ - if (in->configOptionVector[DIM] == 1) { - (void) HDfprintf(stderr, err7a, infile); - goto error; - } + case 4: /* DIMENSION-SIZES */ + if (in->configOptionVector[DIM] == 1) { + (void)HDfprintf(stderr, err7a, infile); + goto error; + } - if (in->configOptionVector[RANK] == 0) { - (void) HDfprintf(stderr, err7b, infile); - goto error; - } - if (getDimensionSizes(in, strm) == -1) { - (void) HDfprintf(stderr, err7c, infile); - goto error; - } - in->configOptionVector[DIM] = 1; - break; + if (in->configOptionVector[RANK] == 0) { + (void)HDfprintf(stderr, err7b, infile); + goto error; + } + if (getDimensionSizes(in, strm) == -1) { + (void)HDfprintf(stderr, err7c, infile); + goto error; + } + in->configOptionVector[DIM] = 1; + break; - case 5: /* OUTPUT-CLASS */ - if (in->configOptionVector[OUTPUT_CLASS] == 1) { - (void) HDfprintf(stderr, err8a, infile); - goto error; - } + case 5: /* OUTPUT-CLASS */ + if (in->configOptionVector[OUTPUT_CLASS] == 1) { + (void)HDfprintf(stderr, err8a, infile); + goto error; + } - if (getOutputClass(in, strm) == -1) { - (void) HDfprintf(stderr, err8b, infile); - goto error; - } - in->configOptionVector[OUTPUT_CLASS] = 1; - break; + if (getOutputClass(in, strm) == -1) { + (void)HDfprintf(stderr, err8b, infile); + goto error; + } + in->configOptionVector[OUTPUT_CLASS] = 1; + break; - case 6: /* OUTPUT-SIZE */ - if (in->configOptionVector[OUTPUT_SIZE] == 1) { - (void) HDfprintf(stderr, err9a, infile); - goto error; - } + case 6: /* OUTPUT-SIZE */ + if (in->configOptionVector[OUTPUT_SIZE] == 1) { + (void)HDfprintf(stderr, err9a, infile); + goto error; + } - if (getOutputSize(in, strm) == -1) { - (void) HDfprintf(stderr, err9b, infile); - goto error; - } - in->configOptionVector[OUTPUT_SIZE] = 1; - break; + if (getOutputSize(in, strm) == -1) { + (void)HDfprintf(stderr, err9b, infile); + goto error; + } + in->configOptionVector[OUTPUT_SIZE] = 1; + break; - case 7: /* OUTPUT-ARCHITECTURE */ - if (in->configOptionVector[OUTPUT_ARCH] == 1) { - (void) HDfprintf(stderr, err10a, infile); - goto error; - } + case 7: /* OUTPUT-ARCHITECTURE */ + if (in->configOptionVector[OUTPUT_ARCH] == 1) { + (void)HDfprintf(stderr, err10a, infile); + goto error; + } - if (getOutputArchitecture(in, strm) == -1) { - (void) HDfprintf(stderr, err10b, infile); - goto error; - } - in->configOptionVector[OUTPUT_ARCH] = 1; - break; + if (getOutputArchitecture(in, strm) == -1) { + (void)HDfprintf(stderr, err10b, infile); + goto error; + } + in->configOptionVector[OUTPUT_ARCH] = 1; + break; - case 8: /* OUTPUT-BYTE-ORDER */ - if (in->configOptionVector[OUTPUT_B_ORDER] == 1) { - (void) HDfprintf(stderr, err11a, infile); - goto error; - } + case 8: /* OUTPUT-BYTE-ORDER */ + if (in->configOptionVector[OUTPUT_B_ORDER] == 1) { + (void)HDfprintf(stderr, err11a, infile); + goto error; + } - if (getOutputByteOrder(in, strm) == -1) { - (void) HDfprintf(stderr, err11b, infile); - goto error; - } - in->configOptionVector[OUTPUT_B_ORDER] = 1; - break; + if (getOutputByteOrder(in, strm) == -1) { + (void)HDfprintf(stderr, err11b, infile); + goto error; + } + in->configOptionVector[OUTPUT_B_ORDER] = 1; + break; - case 9: /* CHUNKED-DIMENSION-SIZES */ - if (in->configOptionVector[CHUNK] == 1) { - (void) HDfprintf(stderr, err12a, infile); - goto error; - } - /* cant appear before dimension sizes have been provided */ - if (in->configOptionVector[DIM] == 0) { - (void) HDfprintf(stderr, err12b, infile); - goto error; - } + case 9: /* CHUNKED-DIMENSION-SIZES */ + if (in->configOptionVector[CHUNK] == 1) { + (void)HDfprintf(stderr, err12a, infile); + goto error; + } + /* cant appear before dimension sizes have been provided */ + if (in->configOptionVector[DIM] == 0) { + (void)HDfprintf(stderr, err12b, infile); + goto error; + } - if (getChunkedDimensionSizes(in, strm) == -1) { - (void) HDfprintf(stderr, err12c, infile); - goto error; - } - in->configOptionVector[CHUNK] = 1; - break; + if (getChunkedDimensionSizes(in, strm) == -1) { + (void)HDfprintf(stderr, err12c, infile); + goto error; + } + in->configOptionVector[CHUNK] = 1; + break; - case 10: /* COMPRESSION-TYPE */ - if (in->configOptionVector[COMPRESS] == 1) { - (void) HDfprintf(stderr, err13a, infile); - goto error; - } + case 10: /* COMPRESSION-TYPE */ + if (in->configOptionVector[COMPRESS] == 1) { + (void)HDfprintf(stderr, err13a, infile); + goto error; + } - if (getCompressionType(in, strm) == -1) { - (void) HDfprintf(stderr, err13b, infile); - goto error; - } - in->configOptionVector[COMPRESS] = 1; + if (getCompressionType(in, strm) == -1) { + (void)HDfprintf(stderr, err13b, infile); + goto error; + } + in->configOptionVector[COMPRESS] = 1; - if (in->configOptionVector[COMPRESS_PARAM] == 0) { - if (in->compressionType == 0) - in->compressionParam = 6; /* default value if compressionType is GZIP */ - } - break; + if (in->configOptionVector[COMPRESS_PARAM] == 0) { + if (in->compressionType == 0) + in->compressionParam = 6; /* default value if compressionType is GZIP */ + } + break; - case 11: /* COMPRESSION-PARAM */ - if (in->configOptionVector[COMPRESS_PARAM] == 1) { - (void) HDfprintf(stderr, err14a, infile); - goto error; - } + case 11: /* COMPRESSION-PARAM */ + if (in->configOptionVector[COMPRESS_PARAM] == 1) { + (void)HDfprintf(stderr, err14a, infile); + goto error; + } - if (getCompressionParameter(in, strm) == -1) { - (void) HDfprintf(stderr, err14b, infile); - goto error; - } + if (getCompressionParameter(in, strm) == -1) { + (void)HDfprintf(stderr, err14b, infile); + goto error; + } - in->configOptionVector[COMPRESS_PARAM] = 1; + in->configOptionVector[COMPRESS_PARAM] = 1; - if (in->configOptionVector[COMPRESS] == 0) - in->compressionType = 0; + if (in->configOptionVector[COMPRESS] == 0) + in->compressionType = 0; - break; + break; - case 12: /* EXTERNAL-STORAGE */ - if (in->configOptionVector[EXTERNALSTORE] == 1) { - (void) HDfprintf(stderr, err15a, infile); - goto error; - } + case 12: /* EXTERNAL-STORAGE */ + if (in->configOptionVector[EXTERNALSTORE] == 1) { + (void)HDfprintf(stderr, err15a, infile); + goto error; + } - if (getExternalFilename(in, strm) == -1) { - (void) HDfprintf(stderr, err15b, infile); - goto error; - } - in->configOptionVector[EXTERNALSTORE] = 1; - break; + if (getExternalFilename(in, strm) == -1) { + (void)HDfprintf(stderr, err15b, infile); + goto error; + } + in->configOptionVector[EXTERNALSTORE] = 1; + break; - case 13: /* MAXIMUM-DIMENSIONS */ - if (in->configOptionVector[EXTEND] == 1) { - (void) HDfprintf(stderr, err16a, infile); - goto error; - } - /* cant appear before dimension sizes have been provided */ - if (in->configOptionVector[DIM] == 0) { - (void) HDfprintf(stderr, err16b, infile); - goto error; - } - if (getMaximumDimensionSizes(in, strm) == -1) { - (void) HDfprintf(stderr, err16c, infile); - goto error; - } - in->configOptionVector[EXTEND] = 1; - break; + case 13: /* MAXIMUM-DIMENSIONS */ + if (in->configOptionVector[EXTEND] == 1) { + (void)HDfprintf(stderr, err16a, infile); + goto error; + } + /* cant appear before dimension sizes have been provided */ + if (in->configOptionVector[DIM] == 0) { + (void)HDfprintf(stderr, err16b, infile); + goto error; + } + if (getMaximumDimensionSizes(in, strm) == -1) { + (void)HDfprintf(stderr, err16c, infile); + goto error; + } + in->configOptionVector[EXTEND] = 1; + break; - case 14: /* INPUT-BYTE-ORDER */ - if (in->configOptionVector[INPUT_B_ORDER] == 1) { - (void) HDfprintf(stderr, err11c, infile); - goto error; - } + case 14: /* INPUT-BYTE-ORDER */ + if (in->configOptionVector[INPUT_B_ORDER] == 1) { + (void)HDfprintf(stderr, err11c, infile); + goto error; + } - if (getInputByteOrder(in, strm) == -1) { - (void) HDfprintf(stderr, err11d, infile); - goto error; - } - in->configOptionVector[INPUT_B_ORDER] = 1; - break; + if (getInputByteOrder(in, strm) == -1) { + (void)HDfprintf(stderr, err11d, infile); + goto error; + } + in->configOptionVector[INPUT_B_ORDER] = 1; + break; - default: - break; + default: + break; } scanret = fscanf(strm, "%254s", key); } @@ -2417,7 +2432,7 @@ static int processConfigurationFile(char *infile, struct Input *in) */ if (validateConfigurationParameters(in) == -1) { - (void) HDfprintf(stderr, err17, infile); + (void)HDfprintf(stderr, err17, infile); goto error; } } @@ -2426,19 +2441,22 @@ static int processConfigurationFile(char *infile, struct Input *in) retval = 0; error: - if(strm) + if (strm) HDfclose(strm); - return(retval); + return (retval); } -static int validateConfigurationParameters(struct Input *in) +static int +validateConfigurationParameters(struct Input *in) { const char *err1 = "One or more of the required fields (RANK, DIMENSION-SIZES) missing.\n"; - const char *err2 = "Cannot specify chunking or compression or extendible data sets with the external file option.\n"; - const char *err3 = "Cannot specify the compression or the extendible data sets without the chunking option.\n"; + const char *err2 = + "Cannot specify chunking or compression or extendible data sets with the external file option.\n"; + const char *err3 = + "Cannot specify the compression or the extendible data sets without the chunking option.\n"; const char *err4a = "OUTPUT-ARCHITECTURE cannot be STD if OUTPUT-CLASS is floating point (FP).\n"; const char *err4b = "OUTPUT-ARCHITECTURE cannot be IEEE if OUTPUT-CLASS is integer (IN).\n"; - const char *err5 = "For OUTPUT-CLASS FP, valid values for OUTPUT-SIZE are (32, 64) .\n"; + const char *err5 = "For OUTPUT-CLASS FP, valid values for OUTPUT-SIZE are (32, 64) .\n"; #ifndef H5_SIZEOF_LONG_LONG const char *err6 = "No support for reading 64-bit integer (INPUT-CLASS: IN, TEXTIN, UIN, TEXTUIN files\n"; #endif @@ -2448,20 +2466,21 @@ static int validateConfigurationParameters(struct Input *in) return (0); if ((in->configOptionVector[DIM] != 1) || (in->configOptionVector[RANK] != 1)) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } if (in->configOptionVector[EXTERNALSTORE] == 1) { - if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[CHUNK] == 1) || (in->configOptionVector[EXTEND] == 1)) { - (void) HDfprintf(stderr, "%s", err2); + if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[CHUNK] == 1) || + (in->configOptionVector[EXTEND] == 1)) { + (void)HDfprintf(stderr, "%s", err2); return (-1); } } if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[EXTEND] == 1)) { if (in->configOptionVector[CHUNK] != 1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } } @@ -2469,33 +2488,35 @@ static int validateConfigurationParameters(struct Input *in) /* Arch cant be STD if O/p class is FP */ if (in->outputArchitecture == 1) if (in->outputClass == 1) { - (void) HDfprintf(stderr, "%s", err4a); + (void)HDfprintf(stderr, "%s", err4a); return (-1); } /* Arch cant be IEEE if O/p class is IN */ if (in->outputArchitecture == 2) if (in->outputClass == 0) { - (void) HDfprintf(stderr, "%s", err4b); + (void)HDfprintf(stderr, "%s", err4b); return (-1); } if (in->outputClass == 1) if (in->outputSize != 32 && in->outputSize != 64) { - (void) HDfprintf(stderr, "%s", err5); + (void)HDfprintf(stderr, "%s", err5); return (-1); } #ifndef H5_SIZEOF_LONG_LONG - if (in->inputSize == 64 && (in->inputClass == 0 || in->inputClass == 4 || in->inputClass == 6 || in->inputClass == 7) ) { - (void) HDfprintf(stderr, "%s", err6); + if (in->inputSize == 64 && + (in->inputClass == 0 || in->inputClass == 4 || in->inputClass == 6 || in->inputClass == 7)) { + (void)HDfprintf(stderr, "%s", err6); return -1; } #endif return (0); } -static int mapKeywordToIndex(char *key) +static int +mapKeywordToIndex(char *key) { int i; @@ -2505,66 +2526,67 @@ static int mapKeywordToIndex(char *key) return -1; } -static int parsePathInfo(struct path_info *path, char *temp) +static int +parsePathInfo(struct path_info *path, char *temp) { const char delimiter[] = "/\""; - char *token; - int i = 0; + char * token; + int i = 0; const char *err1 = "Path string larger than MAX_PATH_NAME_LENGTH.\n"; - token = HDstrtok (temp, delimiter); + token = HDstrtok(temp, delimiter); if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) { - (void) HDfprintf(stderr, err1); + (void)HDfprintf(stderr, err1); return (-1); } - HDstrcpy(path->group[i++],token); + HDstrcpy(path->group[i++], token); while (1) { - token = HDstrtok (NULL, delimiter); + token = HDstrtok(NULL, delimiter); if (token == NULL) break; if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) { - (void) HDfprintf(stderr, err1); + (void)HDfprintf(stderr, err1); return (-1); } - HDstrcpy(path->group[i++],token); + HDstrcpy(path->group[i++], token); } path->count = i; return (0); } -static int parseDimensions(struct Input *in, char *strm) +static int +parseDimensions(struct Input *in, char *strm) { const char delimiter[] = ","; char temp[255]; - char *token; - int i = 0; + char * token; + int i = 0; const char *err1 = "Unable to allocate dynamic memory.\n"; HDstrncpy(temp, strm, sizeof(temp)); temp[sizeof(temp) - 1] = '\0'; - HDstrtok (temp, delimiter); + HDstrtok(temp, delimiter); while (1) { - token = HDstrtok (NULL, delimiter); + token = HDstrtok(NULL, delimiter); if (token == NULL) break; i++; } in->rank = i + 1; - if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); + if ((in->sizeOfDimension = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); return (-1); } i = 0; HDstrncpy(temp, strm, sizeof(temp)); - temp[sizeof(temp) - 1] = '\0'; - in->sizeOfDimension[i++] - = HDstrtoull(HDstrtok (temp, delimiter), NULL, BASE_10); + temp[sizeof(temp) - 1] = '\0'; + in->sizeOfDimension[i++] = HDstrtoull(HDstrtok(temp, delimiter), NULL, BASE_10); while (1) { - token = HDstrtok (NULL, delimiter); + token = HDstrtok(NULL, delimiter); if (token == NULL) break; in->sizeOfDimension[i++] = HDstrtoull(token, NULL, BASE_10); @@ -2572,7 +2594,8 @@ static int parseDimensions(struct Input *in, char *strm) return (0); } -static int getOutputClass(struct Input *in, FILE *strm) +static int +getOutputClass(struct Input *in, FILE *strm) { char temp[255]; int kindex; @@ -2580,12 +2603,12 @@ static int getOutputClass(struct Input *in, FILE *strm) const char *err2 = "Invalid value for output class.\n"; if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } if ((kindex = OutputClassStrToInt(temp)) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } @@ -2593,10 +2616,11 @@ static int getOutputClass(struct Input *in, FILE *strm) return (0); } -static int OutputClassStrToInt(char *temp) +static int +OutputClassStrToInt(char *temp) { - int i; - char classKeywordTable[3][15] = { "IN", "FP", "UIN" }; + int i; + char classKeywordTable[3][15] = {"IN", "FP", "UIN"}; for (i = 0; i < 3; i++) if (!HDstrcmp(classKeywordTable[i], temp)) return i; @@ -2604,16 +2628,17 @@ static int OutputClassStrToInt(char *temp) return -1; } /* same as getInputSize. But defined separately for extensibility */ -static int getOutputSize(struct Input *in, FILE *strm) +static int +getOutputSize(struct Input *in, FILE *strm) { int ival; int i; - int outputSizeValidValues[4] = { 8, 16, 32, 64 }; - const char *err1 = "Unable to get integer value.\n"; - const char *err2 = "Invalid value for output size.\n"; + int outputSizeValidValues[4] = {8, 16, 32, 64}; + const char *err1 = "Unable to get integer value.\n"; + const char *err2 = "Invalid value for output size.\n"; if (fscanf(strm, "%d", (&ival)) != 1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } @@ -2622,17 +2647,18 @@ static int getOutputSize(struct Input *in, FILE *strm) in->outputSize = ival; return (0); } - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } -static int getInputClass(struct Input *in, char * temp) +static int +getInputClass(struct Input *in, char *temp) { int kindex; const char *err1 = "Invalid value for input class.\n"; if ((kindex = InputClassStrToInt(temp)) == -1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } @@ -2640,355 +2666,356 @@ static int getInputClass(struct Input *in, char * temp) return (0); } -static int getInputClassType(struct Input *in, char * buffer) +static int +getInputClassType(struct Input *in, char *buffer) { int kindex = -1; - const char *err1 = "Invalid value for input class.\n"; - const char *err2 = "Invalid value for output architecture.\n"; - const char *err3 = "Invalid value for input byte-order.\n"; + const char *err1 = "Invalid value for input class.\n"; + const char *err2 = "Invalid value for output architecture.\n"; + const char *err3 = "Invalid value for input byte-order.\n"; if (!HDstrcmp(buffer, "H5T_STD_I8BE")) { - in->inputSize = 8; + in->inputSize = 8; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 4; } else if (!HDstrcmp(buffer, "H5T_STD_I8LE")) { - in->inputSize = 8; + in->inputSize = 8; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 4; } else if (!HDstrcmp(buffer, "H5T_STD_I16BE")) { - in->inputSize = 16; + in->inputSize = 16; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 4; } else if (!HDstrcmp(buffer, "H5T_STD_I16LE")) { - in->inputSize = 16; + in->inputSize = 16; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 4; } else if (!HDstrcmp(buffer, "H5T_STD_I32BE")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 4; } else if (!HDstrcmp(buffer, "H5T_STD_I32LE")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 4; } else if (!HDstrcmp(buffer, "H5T_STD_I64BE")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 4; } else if (!HDstrcmp(buffer, "H5T_STD_I64LE")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 4; } else if (!HDstrcmp(buffer, "H5T_STD_U8BE")) { - in->inputSize = 8; + in->inputSize = 8; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 7; } else if (!HDstrcmp(buffer, "H5T_STD_U8LE")) { - in->inputSize = 8; + in->inputSize = 8; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 7; } else if (!HDstrcmp(buffer, "H5T_STD_U16BE")) { - in->inputSize = 16; + in->inputSize = 16; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 7; } else if (!HDstrcmp(buffer, "H5T_STD_U16LE")) { - in->inputSize = 16; + in->inputSize = 16; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 7; } else if (!HDstrcmp(buffer, "H5T_STD_U32BE")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 7; } else if (!HDstrcmp(buffer, "H5T_STD_U32LE")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 7; } else if (!HDstrcmp(buffer, "H5T_STD_U64BE")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 7; } else if (!HDstrcmp(buffer, "H5T_STD_U64LE")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 7; } else if (!HDstrcmp(buffer, "H5T_NATIVE_SCHAR")) { - in->inputSize = 8; + in->inputSize = 8; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -2996,11 +3023,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 4; } else if (!HDstrcmp(buffer, "H5T_NATIVE_UCHAR")) { - in->inputSize = 8; + in->inputSize = 8; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3008,11 +3035,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 7; } else if (!HDstrcmp(buffer, "H5T_NATIVE_SHORT")) { - in->inputSize = 16; + in->inputSize = 16; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3020,11 +3047,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 4; } else if (!HDstrcmp(buffer, "H5T_NATIVE_USHORT")) { - in->inputSize = 16; + in->inputSize = 16; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3032,11 +3059,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 7; } else if (!HDstrcmp(buffer, "H5T_NATIVE_INT")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3044,11 +3071,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 4; } else if (!HDstrcmp(buffer, "H5T_NATIVE_UINT")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3056,11 +3083,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 7; } else if (!HDstrcmp(buffer, "H5T_NATIVE_LONG")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3068,11 +3095,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 4; } else if (!HDstrcmp(buffer, "H5T_NATIVE_ULONG")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3080,11 +3107,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 7; } else if (!HDstrcmp(buffer, "H5T_NATIVE_LLONG")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3092,11 +3119,11 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 4; } else if (!HDstrcmp(buffer, "H5T_NATIVE_ULLONG")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3104,107 +3131,107 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 7; } else if (!HDstrcmp(buffer, "H5T_IEEE_F32BE")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("IEEE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 3; } else if (!HDstrcmp(buffer, "H5T_IEEE_F32LE")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("IEEE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 3; } else if (!HDstrcmp(buffer, "H5T_IEEE_F64BE")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("IEEE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 3; } else if (!HDstrcmp(buffer, "H5T_IEEE_F64LE")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("IEEE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = 3; } else if (!HDstrcmp(buffer, "H5T_VAX_F32")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; kindex = 3; } else if (!HDstrcmp(buffer, "H5T_VAX_F64")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; kindex = 3; } else if (!HDstrcmp(buffer, "H5T_NATIVE_FLOAT")) { - in->inputSize = 32; + in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3212,24 +3239,24 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 3; } else if (!HDstrcmp(buffer, "H5T_NATIVE_DOUBLE")) { - in->inputSize = 64; + in->inputSize = 64; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; kindex = 3; } -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 else if (!HDstrcmp(buffer, "H5T_NATIVE_LDOUBLE")) { - in->inputSize = H5_SIZEOF_LONG_DOUBLE; + in->inputSize = H5_SIZEOF_LONG_DOUBLE; in->configOptionVector[INPUT_SIZE] = 1; if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; @@ -3237,192 +3264,192 @@ static int getInputClassType(struct Input *in, char * buffer) kindex = 3; } #endif - else if(!HDstrcmp(buffer, "H5T_TIME: not yet implemented")) { + else if (!HDstrcmp(buffer, "H5T_TIME: not yet implemented")) { kindex = -1; } - else if(!HDstrcmp(buffer, "H5T_STRING")) { + else if (!HDstrcmp(buffer, "H5T_STRING")) { kindex = 5; } /* case H5T_BITFIELD: */ else if (!HDstrcmp(buffer, "H5T_STD_B8BE")) { if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = -1; } else if (!HDstrcmp(buffer, "H5T_STD_B8LE")) { if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = -1; } else if (!HDstrcmp(buffer, "H5T_STD_B16BE")) { if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = -1; } else if (!HDstrcmp(buffer, "H5T_STD_B16LE")) { if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = -1; } else if (!HDstrcmp(buffer, "H5T_STD_B32BE")) { if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = -1; } else if (!HDstrcmp(buffer, "H5T_STD_B32LE")) { if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = -1; } else if (!HDstrcmp(buffer, "H5T_STD_B64BE")) { if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = -1; } else if (!HDstrcmp(buffer, "H5T_STD_B64LE")) { if ((kindex = OutputArchStrToInt("STD")) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->outputArchitecture = kindex; if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } in->outputByteOrder = kindex; - #ifdef H5DEBUGIMPORT +#ifdef H5DEBUGIMPORT HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); - #endif +#endif kindex = -1; } /* case H5T_OPAQUE: */ - else if(!HDstrcmp(buffer, "H5T_OPAQUE")) { + else if (!HDstrcmp(buffer, "H5T_OPAQUE")) { kindex = -1; } /* case H5T_COMPOUND: */ - else if(!HDstrcmp(buffer, "H5T_COMPOUND")) { + else if (!HDstrcmp(buffer, "H5T_COMPOUND")) { kindex = -1; } /* case H5T_REFERENCE: */ - else if(!HDstrcmp(buffer, "H5T_REFERENCE")) { + else if (!HDstrcmp(buffer, "H5T_REFERENCE")) { kindex = -1; } /* case H5T_ENUM: */ - else if(!HDstrcmp(buffer, "H5T_ENUM")) { + else if (!HDstrcmp(buffer, "H5T_ENUM")) { kindex = -1; } /* case H5T_VLEN: */ - else if(!HDstrcmp(buffer, "H5T_VLEN")) { + else if (!HDstrcmp(buffer, "H5T_VLEN")) { kindex = -1; } /* case H5T_ARRAY: */ - else if(!HDstrcmp(buffer, "H5T_ARRAY")) { + else if (!HDstrcmp(buffer, "H5T_ARRAY")) { kindex = -1; } if (kindex == -1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } @@ -3439,10 +3466,11 @@ static int getInputClassType(struct Input *in, char * buffer) return (0); } -static int InputClassStrToInt(char *temp) +static int +InputClassStrToInt(char *temp) { - int i; - char classKeywordTable[8][15] = { "TEXTIN", "TEXTFP", "TEXTFPE", "FP", "IN", "STR", "TEXTUIN", "UIN" }; + int i; + char classKeywordTable[8][15] = {"TEXTIN", "TEXTFP", "TEXTFPE", "FP", "IN", "STR", "TEXTUIN", "UIN"}; for (i = 0; i < 8; i++) if (!HDstrcmp(classKeywordTable[i], temp)) return i; @@ -3450,22 +3478,24 @@ static int InputClassStrToInt(char *temp) } /* same as getOutputSize. But defined separately for extensibility */ -static int getInputSize(struct Input *in, int ival) +static int +getInputSize(struct Input *in, int ival) { int i; - int inputSizeValidValues[4] = { 8, 16, 32, 64 }; - const char *err1 = "Invalid value for input size.\n"; + int inputSizeValidValues[4] = {8, 16, 32, 64}; + const char *err1 = "Invalid value for input size.\n"; for (i = 0; i < 4; i++) if (inputSizeValidValues[i] == ival) { in->inputSize = ival; return (0); } - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } -static int getInputByteOrder(struct Input *in, FILE *strm) +static int +getInputByteOrder(struct Input *in, FILE *strm) { char temp[255]; int kindex; @@ -3473,12 +3503,12 @@ static int getInputByteOrder(struct Input *in, FILE *strm) const char *err2 = "Invalid value for input byte-order.\n"; if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } if ((kindex = OutputByteOrderStrToInt(temp)) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } @@ -3486,15 +3516,16 @@ static int getInputByteOrder(struct Input *in, FILE *strm) return (0); } -static int getRank(struct Input *in, FILE *strm) +static int +getRank(struct Input *in, FILE *strm) { - int ival; + int ival; const char *err1 = "Unable to get integer value.\n"; const char *err2 = "Invalid value for rank.\n"; if (fscanf(strm, "%d", (&ival)) != 1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } if (ival >= MIN_NUM_DIMENSION && ival <= MAX_NUM_DIMENSION) { @@ -3502,21 +3533,23 @@ static int getRank(struct Input *in, FILE *strm) return (0); } - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } /* same as getChunkedDimensionSizes. But defined separately for extensibility */ -static int getDimensionSizes(struct Input *in, FILE *strm) +static int +getDimensionSizes(struct Input *in, FILE *strm) { unsigned long long ullval; - int i = 0; + int i = 0; const char *err1 = "Unable to allocate dynamic memory.\n"; - const char *err2 = "No. of dimensions for which dimension sizes provided is not equal to provided rank.\n"; + const char *err2 = + "No. of dimensions for which dimension sizes provided is not equal to provided rank.\n"; - if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); + if ((in->sizeOfDimension = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); return (-1); } @@ -3524,23 +3557,25 @@ static int getDimensionSizes(struct Input *in, FILE *strm) in->sizeOfDimension[i++] = ullval; if (in->rank != i) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } return (0); } /* same as getDimensionSizes. But defined separately for extensibility */ -static int getChunkedDimensionSizes(struct Input *in, FILE *strm) +static int +getChunkedDimensionSizes(struct Input *in, FILE *strm) { unsigned long long ullval; - int i = 0; + int i = 0; const char *err1 = "Unable to allocate dynamic memory.\n"; - const char *err2 = "No. of dimensions for which chunked dimension sizes provided is not equal to provided rank.\n"; + const char *err2 = + "No. of dimensions for which chunked dimension sizes provided is not equal to provided rank.\n"; const char *err3 = "The CHUNKED-DIMENSION-SIZES cannot exceed the sizes of DIMENSION-SIZES\n"; - if ((in->sizeOfChunk = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); + if ((in->sizeOfChunk = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); return (-1); } @@ -3548,29 +3583,32 @@ static int getChunkedDimensionSizes(struct Input *in, FILE *strm) in->sizeOfChunk[i++] = ullval; if (in->rank != i) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } for (i = 0; i < in->rank; i++) if (in->sizeOfChunk[i] > in->sizeOfDimension[i]) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } return (0); } -static int getMaximumDimensionSizes(struct Input *in, FILE *strm) +static int +getMaximumDimensionSizes(struct Input *in, FILE *strm) { long long llval; - int i = 0; + int i = 0; const char *err1 = "Unable to allocate dynamic memory.\n"; - const char *err2 = "No. of dimensions for which maximum dimension sizes provided is not equal to provided rank.\n"; - const char *err3 = "The MAXIMUM-DIMENSIONS cannot be less than the sizes of DIMENSION-SIZES. Exception: can be -1 to indicate unlimited size\n"; + const char *err2 = + "No. of dimensions for which maximum dimension sizes provided is not equal to provided rank.\n"; + const char *err3 = "The MAXIMUM-DIMENSIONS cannot be less than the sizes of DIMENSION-SIZES. Exception: " + "can be -1 to indicate unlimited size\n"; - if ((in->maxsizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { - (void) HDfprintf(stderr, "%s", err1); + if ((in->maxsizeOfDimension = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) { + (void)HDfprintf(stderr, "%s", err1); return (-1); } @@ -3582,21 +3620,22 @@ static int getMaximumDimensionSizes(struct Input *in, FILE *strm) } if (in->rank != i) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } for (i = 0; i < in->rank; i++) { if (in->maxsizeOfDimension[i] != H5S_UNLIMITED) if (in->maxsizeOfDimension[i] < in->sizeOfDimension[i]) { - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err3); return (-1); } } return (0); } -static int getOutputArchitecture(struct Input *in, FILE *strm) +static int +getOutputArchitecture(struct Input *in, FILE *strm) { char temp[255]; int kindex; @@ -3604,12 +3643,12 @@ static int getOutputArchitecture(struct Input *in, FILE *strm) const char *err2 = "Invalid value for output architecture.\n"; if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } if ((kindex = OutputArchStrToInt(temp)) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } @@ -3617,18 +3656,19 @@ static int getOutputArchitecture(struct Input *in, FILE *strm) return (0); } -static int OutputArchStrToInt(const char *temp) +static int +OutputArchStrToInt(const char *temp) { - int i; - char outputArchKeywordTable[8][15] = { "NATIVE", "STD", "IEEE", "INTEL", - "CRAY", "MIPS", "ALPHA", "UNIX" }; + int i; + char outputArchKeywordTable[8][15] = {"NATIVE", "STD", "IEEE", "INTEL", "CRAY", "MIPS", "ALPHA", "UNIX"}; for (i = 0; i < 8; i++) if (!HDstrcmp(outputArchKeywordTable[i], temp)) return i; return -1; } -static int getOutputByteOrder(struct Input *in, FILE *strm) +static int +getOutputByteOrder(struct Input *in, FILE *strm) { char temp[255]; int kindex; @@ -3636,12 +3676,12 @@ static int getOutputByteOrder(struct Input *in, FILE *strm) const char *err2 = "Invalid value for output byte-order.\n"; if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } if ((kindex = OutputByteOrderStrToInt(temp)) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } @@ -3649,17 +3689,19 @@ static int getOutputByteOrder(struct Input *in, FILE *strm) return (0); } -static int OutputByteOrderStrToInt(const char *temp) +static int +OutputByteOrderStrToInt(const char *temp) { - int i; - char outputByteOrderKeywordTable[2][15] = { "BE", "LE" }; + int i; + char outputByteOrderKeywordTable[2][15] = {"BE", "LE"}; for (i = 0; i < 2; i++) if (!HDstrcmp(outputByteOrderKeywordTable[i], temp)) return i; return -1; } -static int getCompressionType(struct Input *in, FILE *strm) +static int +getCompressionType(struct Input *in, FILE *strm) { char temp[255]; int kindex; @@ -3667,34 +3709,35 @@ static int getCompressionType(struct Input *in, FILE *strm) const char *err2 = "Invalid value for compression.\n"; if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } if ((kindex = CompressionTypeStrToInt(temp)) == -1) { - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err2); return (-1); } in->compressionType = kindex; return (0); - } -static int CompressionTypeStrToInt(char *temp) +static int +CompressionTypeStrToInt(char *temp) { /* currently supports only GZIP */ /* can be extended by adding fields to the table */ - int i; - char CompressionTypeKeywordTable[1][15] = { "GZIP" }; + int i; + char CompressionTypeKeywordTable[1][15] = {"GZIP"}; for (i = 0; i < 1; i++) if (!HDstrcmp(CompressionTypeKeywordTable[i], temp)) return i; return -1; } -static int getCompressionParameter(struct Input *in, FILE *strm) +static int +getCompressionParameter(struct Input *in, FILE *strm) { /* currently supports only GZIP */ /* can be extended by adding more values to COMPRESSION-TYPE and */ @@ -3706,883 +3749,889 @@ static int getCompressionParameter(struct Input *in, FILE *strm) const char *err3 = "Unsupported Compression Type.\n"; switch (in->compressionType) { - case 0: /* GZIP */ - if (fscanf(strm, "%d", (&ival)) != 1) { - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } + case 0: /* GZIP */ + if (fscanf(strm, "%d", (&ival)) != 1) { + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } - if (ival < 0 || ival > 9) { - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - in->compressionParam = ival; - return (0); + if (ival < 0 || ival > 9) { + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } + in->compressionParam = ival; + return (0); - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); } } -static int getExternalFilename(struct Input *in, FILE *strm) +static int +getExternalFilename(struct Input *in, FILE *strm) { char temp[255]; const char *err1 = "Unable to get 'string' value.\n"; if (fscanf(strm, "%254s", temp) != 1) { - (void) HDfprintf(stderr, "%s", err1); + (void)HDfprintf(stderr, "%s", err1); return (-1); } - in->externFilename = (char *) HDmalloc ((size_t) (HDstrlen(temp) + 1) * sizeof(char)); - (void) HDstrncpy(in->externFilename, temp, HDstrlen(temp) + 1); + in->externFilename = (char *)HDmalloc((size_t)(HDstrlen(temp) + 1) * sizeof(char)); + (void)HDstrncpy(in->externFilename, temp, HDstrlen(temp) + 1); return (0); } -void setDefaultValues(struct Input *in, int count) +void +setDefaultValues(struct Input *in, int count) { - int i; - char temp[255]; - char num[255]; - - in->h5dumpInput = 0; - in->inputClass = 3; /* FP */ - in->inputSize = 32; - in->outputClass = 1; /* FP */ - in->outputSize = 32; + int i; + char temp[255]; + char num[255]; + + in->h5dumpInput = 0; + in->inputClass = 3; /* FP */ + in->inputSize = 32; + in->outputClass = 1; /* FP */ + in->outputSize = 32; in->inputByteOrder = -1; /* use default */ - in->rank = 0; - in->path.count = 1; + in->rank = 0; + in->path.count = 1; HDstrcpy(temp, "dataset"); HDsprintf(num, "%d", count); HDstrcat(temp, num); HDstrcpy(in->path.group[0], temp); - in->outputArchitecture = 0; /* NATIVE */ - in->outputByteOrder = -1; /* use default */ - in->compressionType = 0; /* GZIP */ + in->outputArchitecture = 0; /* NATIVE */ + in->outputByteOrder = -1; /* use default */ + in->compressionType = 0; /* GZIP */ for (i = 0; i < NUM_KEYS; i++) in->configOptionVector[i] = 0; } -hid_t createOutputDataType(struct Input *in) +hid_t +createOutputDataType(struct Input *in) { hid_t new_type = (-1); - const char *err1 = "Invalid value for output class.\n"; - const char *err2 = "Invalid value for output size.\n"; - const char *err3 = "Invalid value for output byte order.\n"; - const char *err4 = "Invalid value for output architecture.\n"; - const char *err5 = "STD not supported for float.\n"; - const char *err6 = "IEEE not supported for INT.\n"; + const char *err1 = "Invalid value for output class.\n"; + const char *err2 = "Invalid value for output size.\n"; + const char *err3 = "Invalid value for output byte order.\n"; + const char *err4 = "Invalid value for output architecture.\n"; + const char *err5 = "STD not supported for float.\n"; + const char *err6 = "IEEE not supported for INT.\n"; switch (in->outputClass) { - case 0: - switch (in->outputArchitecture) { - case 0: /* NATIVE */ - switch (in->outputSize) { - case 8: - new_type = H5Tcopy(H5T_NATIVE_CHAR); - break; - - case 16: - new_type = H5Tcopy(H5T_NATIVE_SHORT); - break; - - case 32: - new_type = H5Tcopy(H5T_NATIVE_INT); - break; - - case 64: - new_type = H5Tcopy(H5T_NATIVE_LLONG); - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - switch (in->outputByteOrder) { - case -1: /* default */ - break; - case 0: - H5Tset_order(new_type, H5T_ORDER_BE); - break; - - case 1: - H5Tset_order(new_type, H5T_ORDER_LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - case 1: /* STD */ - switch (in->outputSize) { - case 8: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_I8BE); - break; - - case 1: - new_type = H5Tcopy(H5T_STD_I8LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - case 16: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_I16BE); - break; - - case 1: - new_type = H5Tcopy(H5T_STD_I16LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - case 32: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_I32BE); - break; - - case 1: - new_type = H5Tcopy(H5T_STD_I32LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - case 64: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_I64BE); - break; - - case 1: - new_type = H5Tcopy(H5T_STD_I64LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err4); - return (-1); - } - break; - - case 1: - switch (in->outputArchitecture) { - case 0: - switch (in->outputSize) { - case 32: - new_type = H5Tcopy(H5T_NATIVE_FLOAT); - break; - - case 64: - new_type = H5Tcopy(H5T_NATIVE_DOUBLE); - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - switch (in->outputByteOrder) { - case -1: /* DEFAULT */ - break; - case 0: - H5Tset_order(new_type, H5T_ORDER_BE); - break; - - case 1: - H5Tset_order(new_type, H5T_ORDER_LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - case 1: - (void) HDfprintf(stderr, "%s", err5); - return (-1); - - case 2: - switch (in->outputSize) { - case 32: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_IEEE_F32BE); - break; - - case 1: - new_type = H5Tcopy(H5T_IEEE_F32LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - case 64: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_IEEE_F64BE); - break; - - case 1: - new_type = H5Tcopy(H5T_IEEE_F64LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err4); - return (-1); - } - break; - - case 2: - switch (in->outputArchitecture) { case 0: - switch (in->outputSize) { - case 8: - new_type = H5Tcopy(H5T_NATIVE_UCHAR); - break; - - case 16: - new_type = H5Tcopy(H5T_NATIVE_USHORT); - break; - - case 32: - new_type = H5Tcopy(H5T_NATIVE_UINT); - break; - - case 64: - new_type = H5Tcopy(H5T_NATIVE_ULLONG); - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - switch (in->outputByteOrder) { - case -1: /* Default */ - break; - case 0: - H5Tset_order(new_type, H5T_ORDER_BE); - break; - - case 1: - H5Tset_order(new_type, H5T_ORDER_LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - case 1: - switch (in->outputSize) { - case 8: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_U8BE); - break; - - case 1: - new_type = H5Tcopy(H5T_STD_U8LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - case 16: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_U16BE); - break; - - case 1: - new_type = H5Tcopy(H5T_STD_U16LE); - break; + switch (in->outputArchitecture) { + case 0: /* NATIVE */ + switch (in->outputSize) { + case 8: + new_type = H5Tcopy(H5T_NATIVE_CHAR); + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; + case 16: + new_type = H5Tcopy(H5T_NATIVE_SHORT); + break; - case 32: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_U32BE); - break; + case 32: + new_type = H5Tcopy(H5T_NATIVE_INT); + break; - case 1: - new_type = H5Tcopy(H5T_STD_U32LE); - break; + case 64: + new_type = H5Tcopy(H5T_NATIVE_LLONG); + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } + switch (in->outputByteOrder) { + case -1: /* default */ + break; + case 0: + H5Tset_order(new_type, H5T_ORDER_BE); + break; - case 64: - switch (in->outputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_U64BE); - break; + case 1: + H5Tset_order(new_type, H5T_ORDER_LE); + break; - case 1: - new_type = H5Tcopy(H5T_STD_U64LE); + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; - - case 2: - (void) HDfprintf(stderr, "%s", err6); - return (-1); + case 1: /* STD */ + switch (in->outputSize) { + case 8: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_I8BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_I8LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - default: - (void) HDfprintf(stderr, "%s", err4); - return (-1); - } - break; + case 16: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_I16BE); + break; - default: - (void) HDfprintf(stderr, "%s", err1); - return (-1); - } - return new_type; -} + case 1: + new_type = H5Tcopy(H5T_STD_I16LE); + break; -hid_t createInputDataType(struct Input *in) -{ - hid_t new_type = (-1); - const char *err1 = "Invalid value for input class.\n"; - const char *err2 = "Invalid value for input size.\n"; - const char *err3 = "Invalid value for input byte order.\n"; - const char *err4 = "Invalid value for output architecture.\n"; - const char *err5 = "STD not supported for float.\n"; - const char *err6 = "IEEE not supported for INT.\n"; + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - if (in->h5dumpInput) { - switch (in->inputClass) { - case 4: - switch (in->inputArchitecture) { - case 0: /*NATIVE*/ - switch (in->inputSize) { - case 8: - new_type = H5Tcopy(H5T_NATIVE_CHAR); - break; + case 32: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_I32BE); + break; - case 16: - new_type = H5Tcopy(H5T_NATIVE_SHORT); - break; + case 1: + new_type = H5Tcopy(H5T_STD_I32LE); + break; - case 32: - new_type = H5Tcopy(H5T_NATIVE_INT); - break; + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - case 64: - new_type = H5Tcopy(H5T_NATIVE_LLONG); - break; + case 64: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_I64BE); + break; - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - switch (in->inputByteOrder) { - case -1: /* default */ - break; - case 0: - H5Tset_order(new_type, H5T_ORDER_BE); - break; + case 1: + new_type = H5Tcopy(H5T_STD_I64LE); + break; - case 1: - H5Tset_order(new_type, H5T_ORDER_LE); + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } break; default: - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err4); return (-1); - } - break; + } + break; - case 1: /*STD*/ - switch (in->inputSize) { - case 8: - switch (in->inputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_I8BE); - break; + case 1: + switch (in->outputArchitecture) { + case 0: + switch (in->outputSize) { + case 32: + new_type = H5Tcopy(H5T_NATIVE_FLOAT); + break; - case 1: - new_type = H5Tcopy(H5T_STD_I8LE); - break; + case 64: + new_type = H5Tcopy(H5T_NATIVE_DOUBLE); + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); } - break; - - case 16: - switch (in->inputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_I16BE); - break; + switch (in->outputByteOrder) { + case -1: /* DEFAULT */ + break; + case 0: + H5Tset_order(new_type, H5T_ORDER_BE); + break; - case 1: - new_type = H5Tcopy(H5T_STD_I16LE); - break; + case 1: + H5Tset_order(new_type, H5T_ORDER_LE); + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); } break; - case 32: - switch (in->inputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_I32BE); - break; + case 1: + (void)HDfprintf(stderr, "%s", err5); + return (-1); - case 1: - new_type = H5Tcopy(H5T_STD_I32LE); - break; + case 2: + switch (in->outputSize) { + case 32: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_IEEE_F32BE); + break; + + case 1: + new_type = H5Tcopy(H5T_IEEE_F32LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; + case 64: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_IEEE_F64BE); + break; - case 64: - switch (in->inputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_I64BE); - break; + case 1: + new_type = H5Tcopy(H5T_IEEE_F64LE); + break; - case 1: - new_type = H5Tcopy(H5T_STD_I64LE); - break; + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); } break; default: - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err4); return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err4); - return (-1); } break; - case 3: - switch (in->inputArchitecture) { - case 0: - switch (in->inputSize) { - case 32: - new_type = H5Tcopy(H5T_NATIVE_FLOAT); - break; - - case 64: - new_type = H5Tcopy(H5T_NATIVE_DOUBLE); - break; - - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - switch (in->inputByteOrder) { - case -1: /* DEFAULT */ - break; + case 2: + switch (in->outputArchitecture) { case 0: - H5Tset_order(new_type, H5T_ORDER_BE); - break; + switch (in->outputSize) { + case 8: + new_type = H5Tcopy(H5T_NATIVE_UCHAR); + break; - case 1: - H5Tset_order(new_type, H5T_ORDER_LE); - break; + case 16: + new_type = H5Tcopy(H5T_NATIVE_USHORT); + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; + case 32: + new_type = H5Tcopy(H5T_NATIVE_UINT); + break; - case 1: - (void) HDfprintf(stderr, "%s", err5); - return (-1); + case 64: + new_type = H5Tcopy(H5T_NATIVE_ULLONG); + break; - case 2: - switch (in->inputSize) { - case 32: - switch (in->inputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_IEEE_F32BE); - break; + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } + switch (in->outputByteOrder) { + case -1: /* Default */ + break; + case 0: + H5Tset_order(new_type, H5T_ORDER_BE); + break; - case 1: - new_type = H5Tcopy(H5T_IEEE_F32LE); - break; + case 1: + H5Tset_order(new_type, H5T_ORDER_LE); + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); } break; - case 64: - switch (in->inputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_IEEE_F64BE); - break; + case 1: + switch (in->outputSize) { + case 8: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_U8BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_U8LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - case 1: - new_type = H5Tcopy(H5T_IEEE_F64LE); - break; + case 16: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_U16BE); + break; - default: - (void) HDfprintf(stderr, "%s", err3); - return (-1); - } - break; + case 1: + new_type = H5Tcopy(H5T_STD_U16LE); + break; - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - default: - (void) HDfprintf(stderr, "%s", err4); - return (-1); - } - break; + case 32: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_U32BE); + break; - case 7: - switch (in->inputArchitecture) { - case 0: - switch (in->inputSize) { - case 8: - new_type = H5Tcopy(H5T_NATIVE_UCHAR); - break; + case 1: + new_type = H5Tcopy(H5T_STD_U32LE); + break; - case 16: - new_type = H5Tcopy(H5T_NATIVE_USHORT); - break; + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - case 32: - new_type = H5Tcopy(H5T_NATIVE_UINT); - break; + case 64: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_U64BE); + break; - case 64: - new_type = H5Tcopy(H5T_NATIVE_ULLONG); - break; + case 1: + new_type = H5Tcopy(H5T_STD_U64LE); + break; - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - switch (in->inputByteOrder) { - case -1: /* Default */ - break; - case 0: - H5Tset_order(new_type, H5T_ORDER_BE); - break; + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - case 1: - H5Tset_order(new_type, H5T_ORDER_LE); + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } break; + case 2: + (void)HDfprintf(stderr, "%s", err6); + return (-1); + default: - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err4); return (-1); - } - break; + } + break; - case 1: - switch (in->inputSize) { - case 8: - switch (in->inputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_U8BE); + default: + (void)HDfprintf(stderr, "%s", err1); + return (-1); + } + return new_type; +} + +hid_t +createInputDataType(struct Input *in) +{ + hid_t new_type = (-1); + const char *err1 = "Invalid value for input class.\n"; + const char *err2 = "Invalid value for input size.\n"; + const char *err3 = "Invalid value for input byte order.\n"; + const char *err4 = "Invalid value for output architecture.\n"; + const char *err5 = "STD not supported for float.\n"; + const char *err6 = "IEEE not supported for INT.\n"; + + if (in->h5dumpInput) { + switch (in->inputClass) { + case 4: + switch (in->inputArchitecture) { + case 0: /*NATIVE*/ + switch (in->inputSize) { + case 8: + new_type = H5Tcopy(H5T_NATIVE_CHAR); + break; + + case 16: + new_type = H5Tcopy(H5T_NATIVE_SHORT); + break; + + case 32: + new_type = H5Tcopy(H5T_NATIVE_INT); + break; + + case 64: + new_type = H5Tcopy(H5T_NATIVE_LLONG); + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } + switch (in->inputByteOrder) { + case -1: /* default */ + break; + case 0: + H5Tset_order(new_type, H5T_ORDER_BE); + break; + + case 1: + H5Tset_order(new_type, H5T_ORDER_LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } break; - case 1: - new_type = H5Tcopy(H5T_STD_U8LE); + case 1: /*STD*/ + switch (in->inputSize) { + case 8: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_I8BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_I8LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + case 16: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_I16BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_I16LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + case 32: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_I32BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_I32LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + case 64: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_I64BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_I64LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } break; default: - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err4); return (-1); - } - break; + } + break; - case 16: - switch (in->inputByteOrder) { - case -1: + case 3: + switch (in->inputArchitecture) { case 0: - new_type = H5Tcopy(H5T_STD_U16BE); + switch (in->inputSize) { + case 32: + new_type = H5Tcopy(H5T_NATIVE_FLOAT); + break; + + case 64: + new_type = H5Tcopy(H5T_NATIVE_DOUBLE); + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } + switch (in->inputByteOrder) { + case -1: /* DEFAULT */ + break; + case 0: + H5Tset_order(new_type, H5T_ORDER_BE); + break; + + case 1: + H5Tset_order(new_type, H5T_ORDER_LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } break; case 1: - new_type = H5Tcopy(H5T_STD_U16LE); - break; - - default: - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err5); return (-1); - } - break; - case 32: - switch (in->inputByteOrder) { - case -1: - case 0: - new_type = H5Tcopy(H5T_STD_U32BE); - break; + case 2: + switch (in->inputSize) { + case 32: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_IEEE_F32BE); + break; + + case 1: + new_type = H5Tcopy(H5T_IEEE_F32LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + case 64: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_IEEE_F64BE); + break; + + case 1: + new_type = H5Tcopy(H5T_IEEE_F64LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; - case 1: - new_type = H5Tcopy(H5T_STD_U32LE); + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } break; default: - (void) HDfprintf(stderr, "%s", err3); + (void)HDfprintf(stderr, "%s", err4); return (-1); - } - break; + } + break; - case 64: - switch (in->inputByteOrder) { - case -1: + case 7: + switch (in->inputArchitecture) { case 0: - new_type = H5Tcopy(H5T_STD_U64BE); + switch (in->inputSize) { + case 8: + new_type = H5Tcopy(H5T_NATIVE_UCHAR); + break; + + case 16: + new_type = H5Tcopy(H5T_NATIVE_USHORT); + break; + + case 32: + new_type = H5Tcopy(H5T_NATIVE_UINT); + break; + + case 64: + new_type = H5Tcopy(H5T_NATIVE_ULLONG); + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } + switch (in->inputByteOrder) { + case -1: /* Default */ + break; + case 0: + H5Tset_order(new_type, H5T_ORDER_BE); + break; + + case 1: + H5Tset_order(new_type, H5T_ORDER_LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } break; case 1: - new_type = H5Tcopy(H5T_STD_U64LE); + switch (in->inputSize) { + case 8: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_U8BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_U8LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + case 16: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_U16BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_U16LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + case 32: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_U32BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_U32LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + case 64: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_STD_U64BE); + break; + + case 1: + new_type = H5Tcopy(H5T_STD_U64LE); + break; + + default: + (void)HDfprintf(stderr, "%s", err3); + return (-1); + } + break; + + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } break; - default: - (void) HDfprintf(stderr, "%s", err3); + case 2: + (void)HDfprintf(stderr, "%s", err6); return (-1); - } - break; - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); + default: + (void)HDfprintf(stderr, "%s", err4); + return (-1); } break; - case 2: - (void) HDfprintf(stderr, "%s", err6); - return (-1); - default: - (void) HDfprintf(stderr, "%s", err4); + (void)HDfprintf(stderr, "%s", err1); return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err1); - return (-1); } } else { switch (in->inputClass) { - case 0: - case 4: - switch (in->inputSize) { - case 8: - new_type = H5Tcopy(H5T_NATIVE_CHAR); - break; + case 0: + case 4: + switch (in->inputSize) { + case 8: + new_type = H5Tcopy(H5T_NATIVE_CHAR); + break; - case 16: - new_type = H5Tcopy(H5T_NATIVE_SHORT); - break; + case 16: + new_type = H5Tcopy(H5T_NATIVE_SHORT); + break; - case 32: - new_type = H5Tcopy(H5T_NATIVE_INT); - break; + case 32: + new_type = H5Tcopy(H5T_NATIVE_INT); + break; + + case 64: + new_type = H5Tcopy(H5T_NATIVE_LLONG); + break; - case 64: - new_type = H5Tcopy(H5T_NATIVE_LLONG); + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } break; - default: - (void) HDfprintf(stderr, "%s", err2); - return (-1); - } - break; + case 1: + case 2: + case 3: + switch (in->inputSize) { + case 32: + new_type = H5Tcopy(H5T_NATIVE_FLOAT); + break; - case 1: - case 2: - case 3: - switch (in->inputSize) { - case 32: - new_type = H5Tcopy(H5T_NATIVE_FLOAT); - break; + case 64: + new_type = H5Tcopy(H5T_NATIVE_DOUBLE); + break; - case 64: - new_type = H5Tcopy(H5T_NATIVE_DOUBLE); + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } break; - default: - (void) HDfprintf(stderr, "%s", err2); + case 5: + (void)HDfprintf(stderr, "%s", err1); return (-1); - } - break; + break; - case 5: - (void) HDfprintf(stderr, "%s", err1); - return (-1); - break; + case 6: + case 7: + switch (in->inputSize) { + case 8: + new_type = H5Tcopy(H5T_NATIVE_UCHAR); + break; - case 6: - case 7: - switch (in->inputSize) { - case 8: - new_type = H5Tcopy(H5T_NATIVE_UCHAR); - break; + case 16: + new_type = H5Tcopy(H5T_NATIVE_USHORT); + break; - case 16: - new_type = H5Tcopy(H5T_NATIVE_USHORT); - break; + case 32: + new_type = H5Tcopy(H5T_NATIVE_UINT); + break; - case 32: - new_type = H5Tcopy(H5T_NATIVE_UINT); - break; + case 64: + new_type = H5Tcopy(H5T_NATIVE_ULLONG); + break; - case 64: - new_type = H5Tcopy(H5T_NATIVE_ULLONG); + default: + (void)HDfprintf(stderr, "%s", err2); + return (-1); + } break; default: - (void) HDfprintf(stderr, "%s", err2); + (void)HDfprintf(stderr, "%s", err1); return (-1); - } - break; - - default: - (void) HDfprintf(stderr, "%s", err1); - return (-1); } } return new_type; } -static int process(struct Options *opt) +static int +process(struct Options *opt) { - struct Input *in; - FILE *extfile; - hid_t file_id; - hid_t group_id; - hid_t handle; - hid_t dataset; - hid_t dataspace = (-1); - hid_t intype; - hid_t outtype; - hid_t proplist; - hsize_t numOfElements = 1; - int j; - int k; + struct Input *in; + FILE * extfile; + hid_t file_id; + hid_t group_id; + hid_t handle; + hid_t dataset; + hid_t dataspace = (-1); + hid_t intype; + hid_t outtype; + hid_t proplist; + hsize_t numOfElements = 1; + int j; + int k; const char *err1 = "Error creating HDF output file: %s.\n"; const char *err2 = "Error in processing the configuration file: %s.\n"; const char *err3 = "Error in reading the input file: %s.\n"; const char *err4 = "Error in creating or opening external file.\n"; - const char *err5 = "Error in creating the output data set. Dataset with the same name may exist at the specified path\n"; + const char *err5 = + "Error in creating the output data set. Dataset with the same name may exist at the specified path\n"; const char *err6 = "Error in writing the output data set.\n"; H5E_BEGIN_TRY { if ((file_id = H5Fopen(opt->outfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { if ((file_id = H5Fcreate(opt->outfile, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) == FAIL) { - (void) HDfprintf(stderr, err1, opt->outfile); + (void)HDfprintf(stderr, err1, opt->outfile); return (-1); } } @@ -4593,13 +4642,13 @@ static int process(struct Options *opt) in = &(opt->infiles[k].in); if (opt->infiles[k].config == 1) { if (processConfigurationFile(opt->infiles[k].configfile, in) == -1) { - (void) HDfprintf(stderr, err2, opt->infiles[k].configfile); + (void)HDfprintf(stderr, err2, opt->infiles[k].configfile); return (-1); } } if (processDataFile(opt->infiles[k].datafile, in, file_id) == -1) { - (void) HDfprintf(stderr, err3, opt->infiles[k].datafile); + (void)HDfprintf(stderr, err3, opt->infiles[k].datafile); return (-1); } @@ -4612,13 +4661,15 @@ static int process(struct Options *opt) { /* create parent groups */ if (in->path.count > 1) { - j = 0; + j = 0; handle = file_id; while (j < in->path.count - 1) { if ((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) { - group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); for (; j < in->path.count - 1; j++) - group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); handle = group_id; break; } @@ -4628,7 +4679,7 @@ static int process(struct Options *opt) } else { handle = file_id; - j = 0; + j = 0; } /*enable error reporting */ @@ -4636,7 +4687,7 @@ static int process(struct Options *opt) H5E_END_TRY; /*create data type */ - intype = createInputDataType(in); + intype = createInputDataType(in); outtype = createOutputDataType(in); #ifdef H5DEBUGIMPORT HDprintf("process intype %ld outtype %ld\n", intype, outtype); @@ -4651,20 +4702,21 @@ static int process(struct Options *opt) } if (in->configOptionVector[COMPRESS] == 1) { - H5Pset_deflate(proplist, (unsigned) in->compressionParam); + H5Pset_deflate(proplist, (unsigned)in->compressionParam); } if (in->configOptionVector[EXTERNALSTORE] == 1) { /* creating the external file if it doesnt exist */ if ((extfile = HDfopen(in->externFilename, "ab")) == NULL) { - (void) HDfprintf(stderr, "%s", err4); + (void)HDfprintf(stderr, "%s", err4); H5Pclose(proplist); H5Sclose(dataspace); H5Fclose(file_id); return (-1); } HDfclose(extfile); - H5Pset_external(proplist, in->externFilename, (off_t)0, numOfElements * (hsize_t)in->inputSize / 8); + H5Pset_external(proplist, in->externFilename, (off_t)0, + numOfElements * (hsize_t)in->inputSize / 8); } /* create dataspace */ @@ -4677,8 +4729,9 @@ static int process(struct Options *opt) H5E_BEGIN_TRY { /* create data set */ - if ((dataset = H5Dcreate2(handle, in->path.group[j], outtype, dataspace, H5P_DEFAULT, proplist, H5P_DEFAULT)) < 0) { - (void) HDfprintf(stderr, "%s", err5); + if ((dataset = H5Dcreate2(handle, in->path.group[j], outtype, dataspace, H5P_DEFAULT, + proplist, H5P_DEFAULT)) < 0) { + (void)HDfprintf(stderr, "%s", err5); H5Pclose(proplist); H5Sclose(dataspace); H5Fclose(file_id); @@ -4690,8 +4743,8 @@ static int process(struct Options *opt) H5E_END_TRY; /* write dataset */ - if (H5Dwrite(dataset, intype, H5S_ALL, H5S_ALL, H5P_DEFAULT, (VOIDP) in->data) < 0) { - (void) HDfprintf(stderr, "%s", err6); + if (H5Dwrite(dataset, intype, H5S_ALL, H5S_ALL, H5P_DEFAULT, (VOIDP)in->data) < 0) { + (void)HDfprintf(stderr, "%s", err6); H5Dclose(dataset); H5Pclose(proplist); H5Sclose(dataspace); @@ -4710,36 +4763,44 @@ 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)); } -int16_t swap_int16(int16_t val) +int16_t +swap_int16(int16_t val) { return (int16_t)((val << 8) | ((val >> 8) & 0xFF)); } -uint32_t swap_uint32(uint32_t val) +uint32_t +swap_uint32(uint32_t val) { val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF); return (val << 16) | (val >> 16); } -int32_t swap_int32(int32_t val) +int32_t +swap_int32(int32_t val) { val = (int32_t)(((uint32_t)(val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF)); return (val << 16) | ((val >> 16) & 0xFFFF); } -int64_t swap_int64(int64_t val) +int64_t +swap_int64(int64_t val) { - val = (int64_t)(((uint64_t)(val << 8) & 0xFF00FF00FF00FF00ULL) | ((uint64_t)(val >> 8) & 0x00FF00FF00FF00FFULL)); - val = (int64_t)(((uint64_t)(val << 16) & 0xFFFF0000FFFF0000ULL) | ((uint64_t)(val >> 16) & 0x0000FFFF0000FFFFULL)); + val = (int64_t)(((uint64_t)(val << 8) & 0xFF00FF00FF00FF00ULL) | + ((uint64_t)(val >> 8) & 0x00FF00FF00FF00FFULL)); + val = (int64_t)(((uint64_t)(val << 16) & 0xFFFF0000FFFF0000ULL) | + ((uint64_t)(val >> 16) & 0x0000FFFF0000FFFFULL)); return (int64_t)((uint64_t)(val << 32) | ((uint64_t)(val >> 32) & 0xFFFFFFFFULL)); } -uint64_t swap_uint64(uint64_t val) +uint64_t +swap_uint64(uint64_t val) { val = ((val << 8) & 0xFF00FF00FF00FF00ULL) | ((val >> 8) & 0x00FF00FF00FF00FFULL); val = ((val << 16) & 0xFFFF0000FFFF0000ULL) | ((val >> 16) & 0x0000FFFF0000FFFFULL); @@ -4754,414 +4815,297 @@ uint64_t swap_uint64(uint64_t val) * Print a helpful summary of command usage and features. */ -void help(char *name) +void +help(char *name) { - (void) HDfprintf(stdout, "Name:\n\n"); - (void) HDfprintf(stdout, "\t%s\n\n", name); - (void) HDfprintf(stdout, "\t TOOL NAME:\n"); - (void) HDfprintf(stdout, "\t %s\n", name); - (void) HDfprintf(stdout, "\t SYNTAX:\n"); - (void) HDfprintf(stdout, "\t %s -h[elp], OR\n", name); - (void) HDfprintf(stdout, - "\t %s -c[onfig] [ -c[config] ...]", name); - (void) HDfprintf(stdout, "\t\t\t\t -o[utfile] \n\n"); - (void) HDfprintf(stdout, "\t PURPOSE:\n"); - (void) HDfprintf(stdout, - "\t To convert data stored in one or more ASCII or binary files\n"); - (void) HDfprintf(stdout, - "\t into one or more datasets (in accordance with the \n"); - (void) HDfprintf(stdout, - "\t user-specified type and storage properties) in an existing \n"); - (void) HDfprintf(stdout, "\t or new HDF5 file.\n\n"); - (void) HDfprintf(stdout, "\t DESCRIPTION:\n"); - (void) HDfprintf(stdout, - "\t The primary objective of the utility is to convert floating\n"); - (void) HDfprintf(stdout, - "\t point or integer data stored in ASCII text or binary form \n"); - (void) HDfprintf(stdout, - "\t into a data-set according to the type and storage properties\n"); - (void) HDfprintf(stdout, - "\t specified by the user. The utility can also accept ASCII\n"); - (void) HDfprintf(stdout, - "\t text files and store the contents in a compact form as an\n"); - (void) HDfprintf(stdout, "\t array of one-dimensional strings.\n\n"); - (void) HDfprintf(stdout, - "\t The input data to be written as a data-set can be provided\n"); - (void) HDfprintf(stdout, "\t to the utility in one of the following forms:\n"); - (void) HDfprintf(stdout, - "\t 1. ASCII text file with numeric data (floating point or \n"); - (void) HDfprintf(stdout, "\t integer data). \n"); - (void) HDfprintf(stdout, - "\t 2. Binary file with native floating point data (32-bit or \n"); - (void) HDfprintf(stdout, "\t 64-bit) \n"); - (void) HDfprintf(stdout, - "\t 3. Binary file with native integer (signed or unsigned)\n"); - (void) HDfprintf(stdout, "\t data (8-bit or 16-bit or 32-bit or 64-bit). \n"); - (void) HDfprintf(stdout, - "\t 4. ASCII text file containing strings (text data).\n"); - (void) HDfprintf(stdout, "\t \n"); - (void) HDfprintf(stdout, - "\t Every input file is associated with a configuration file \n"); - (void) HDfprintf(stdout, - "\t also provided as an input to the utility. (See Section \n"); - (void) HDfprintf(stdout, - "\t \"CONFIGURATION FILE\" to know how it is to be organized).\n"); - (void) HDfprintf(stdout, - "\t The class, size and dimensions of the input data is \n"); - (void) HDfprintf(stdout, - "\t specified in this configuration file. A point to note is\n"); - (void) HDfprintf(stdout, - "\t that the floating point data in the ASCII text file may be\n"); - (void) HDfprintf(stdout, - "\t organized in the fixed floating form (for example 323.56)\n"); - (void) HDfprintf(stdout, - "\t or in a scientific notation (for example 3.23E+02). A \n"); - (void) HDfprintf(stdout, - "\t different input-class specification is to be used for both\n"); - (void) HDfprintf(stdout, "\t forms.\n\n"); - (void) HDfprintf(stdout, - "\t The utility extracts the input data from the input file \n"); - (void) HDfprintf(stdout, - "\t according to the specified parameters and saves it into \n"); - (void) HDfprintf(stdout, "\t an H5 dataset. \n\n"); - (void) HDfprintf(stdout, - "\t The user can specify output type and storage properties in \n"); - (void) HDfprintf(stdout, - "\t the configuration file. The user is required to specify the \n"); - (void) HDfprintf(stdout, - "\t path of the dataset. If the groups in the path leading to \n"); - (void) HDfprintf(stdout, - "\t the data-set do not exist, the groups will be created by the\n"); - (void) HDfprintf(stdout, - "\t utility. If no group is specified, the dataset will be\n"); - (void) HDfprintf(stdout, "\t created under the root group.\n\n"); - (void) HDfprintf(stdout, - "\t In addition to the name, the user is also required to \n"); - (void) HDfprintf(stdout, - "\t provide the class and size of output data to be written to \n"); - (void) HDfprintf(stdout, - "\t the dataset and may optionally specify the output-architecture,\n"); - (void) HDfprintf(stdout, - "\t and the output-byte-order. If output-architecture is not \n"); - (void) HDfprintf(stdout, - "\t specified the default is NATIVE. Output-byte-orders are fixed\n"); - (void) HDfprintf(stdout, - "\t for some architectures and may be specified only if output-\n"); - (void) HDfprintf(stdout, "\t architecture is IEEE, UNIX or STD.\n\n"); - (void) HDfprintf(stdout, - "\t Also, layout and other storage properties such as \n"); - (void) HDfprintf(stdout, - "\t compression, external storage and extendible data-sets may be\n"); - (void) HDfprintf(stdout, - "\t optionally specified. The layout and storage properties \n"); - (void) HDfprintf(stdout, - "\t denote how raw data is to be organized on the disk. If these \n"); - (void) HDfprintf(stdout, - "\t options are not specified the default is Contiguous layout \n"); - (void) HDfprintf(stdout, "\t and storage.\n\n"); - (void) HDfprintf(stdout, - "\t The dataset can be organized in any of the following ways:\n"); - (void) HDfprintf(stdout, "\t 1. Contiguous.\n"); - (void) HDfprintf(stdout, "\t 2. Chunked.\n"); - (void) HDfprintf(stdout, - "\t 3. External Storage File (has to be contiguous)\n"); - (void) HDfprintf(stdout, - "\t 4. Extendible data sets (has to be chunked)\n"); - (void) HDfprintf(stdout, "\t 5. Compressed. (has to be chunked)\n"); - (void) HDfprintf(stdout, - "\t 6. Compressed & Extendible (has to be chunked)\n\n"); - (void) HDfprintf(stdout, - "\t If the user wants to store raw data in a non-HDF file then \n"); - (void) HDfprintf(stdout, - "\t the external storage file option is to be used and the name \n"); - (void) HDfprintf(stdout, "\t of the file is to be specified. \n\n"); - (void) HDfprintf(stdout, - "\t If the user wants the dimensions of the data-set to be\n"); - (void) HDfprintf(stdout, - "\t unlimited, the extendible data set option can be chosen. \n\n"); - (void) HDfprintf(stdout, - "\t The user may also specify the type of compression and the \n"); - (void) HDfprintf(stdout, - "\t level to which the data set must be compresses by setting \n"); - (void) HDfprintf(stdout, "\t the compressed option.\n\n"); - (void) HDfprintf(stdout, "\t SYNOPSIS:\n"); - (void) HDfprintf(stdout, "\t h5import -h[elp], OR\n"); - (void) HDfprintf( stdout, - "\t h5import -c[onfig] \ + (void)HDfprintf(stdout, "Name:\n\n"); + (void)HDfprintf(stdout, "\t%s\n\n", name); + (void)HDfprintf(stdout, "\t TOOL NAME:\n"); + (void)HDfprintf(stdout, "\t %s\n", name); + (void)HDfprintf(stdout, "\t SYNTAX:\n"); + (void)HDfprintf(stdout, "\t %s -h[elp], OR\n", name); + (void)HDfprintf(stdout, "\t %s -c[onfig] [ -c[config] ...]", + name); + (void)HDfprintf(stdout, "\t\t\t\t -o[utfile] \n\n"); + (void)HDfprintf(stdout, "\t PURPOSE:\n"); + (void)HDfprintf(stdout, "\t To convert data stored in one or more ASCII or binary files\n"); + (void)HDfprintf(stdout, "\t into one or more datasets (in accordance with the \n"); + (void)HDfprintf(stdout, "\t user-specified type and storage properties) in an existing \n"); + (void)HDfprintf(stdout, "\t or new HDF5 file.\n\n"); + (void)HDfprintf(stdout, "\t DESCRIPTION:\n"); + (void)HDfprintf(stdout, "\t The primary objective of the utility is to convert floating\n"); + (void)HDfprintf(stdout, "\t point or integer data stored in ASCII text or binary form \n"); + (void)HDfprintf(stdout, "\t into a data-set according to the type and storage properties\n"); + (void)HDfprintf(stdout, "\t specified by the user. The utility can also accept ASCII\n"); + (void)HDfprintf(stdout, "\t text files and store the contents in a compact form as an\n"); + (void)HDfprintf(stdout, "\t array of one-dimensional strings.\n\n"); + (void)HDfprintf(stdout, "\t The input data to be written as a data-set can be provided\n"); + (void)HDfprintf(stdout, "\t to the utility in one of the following forms:\n"); + (void)HDfprintf(stdout, "\t 1. ASCII text file with numeric data (floating point or \n"); + (void)HDfprintf(stdout, "\t integer data). \n"); + (void)HDfprintf(stdout, "\t 2. Binary file with native floating point data (32-bit or \n"); + (void)HDfprintf(stdout, "\t 64-bit) \n"); + (void)HDfprintf(stdout, "\t 3. Binary file with native integer (signed or unsigned)\n"); + (void)HDfprintf(stdout, "\t data (8-bit or 16-bit or 32-bit or 64-bit). \n"); + (void)HDfprintf(stdout, "\t 4. ASCII text file containing strings (text data).\n"); + (void)HDfprintf(stdout, "\t \n"); + (void)HDfprintf(stdout, "\t Every input file is associated with a configuration file \n"); + (void)HDfprintf(stdout, "\t also provided as an input to the utility. (See Section \n"); + (void)HDfprintf(stdout, "\t \"CONFIGURATION FILE\" to know how it is to be organized).\n"); + (void)HDfprintf(stdout, "\t The class, size and dimensions of the input data is \n"); + (void)HDfprintf(stdout, "\t specified in this configuration file. A point to note is\n"); + (void)HDfprintf(stdout, "\t that the floating point data in the ASCII text file may be\n"); + (void)HDfprintf(stdout, "\t organized in the fixed floating form (for example 323.56)\n"); + (void)HDfprintf(stdout, "\t or in a scientific notation (for example 3.23E+02). A \n"); + (void)HDfprintf(stdout, "\t different input-class specification is to be used for both\n"); + (void)HDfprintf(stdout, "\t forms.\n\n"); + (void)HDfprintf(stdout, "\t The utility extracts the input data from the input file \n"); + (void)HDfprintf(stdout, "\t according to the specified parameters and saves it into \n"); + (void)HDfprintf(stdout, "\t an H5 dataset. \n\n"); + (void)HDfprintf(stdout, "\t The user can specify output type and storage properties in \n"); + (void)HDfprintf(stdout, "\t the configuration file. The user is required to specify the \n"); + (void)HDfprintf(stdout, "\t path of the dataset. If the groups in the path leading to \n"); + (void)HDfprintf(stdout, "\t the data-set do not exist, the groups will be created by the\n"); + (void)HDfprintf(stdout, "\t utility. If no group is specified, the dataset will be\n"); + (void)HDfprintf(stdout, "\t created under the root group.\n\n"); + (void)HDfprintf(stdout, "\t In addition to the name, the user is also required to \n"); + (void)HDfprintf(stdout, "\t provide the class and size of output data to be written to \n"); + (void)HDfprintf(stdout, "\t the dataset and may optionally specify the output-architecture,\n"); + (void)HDfprintf(stdout, "\t and the output-byte-order. If output-architecture is not \n"); + (void)HDfprintf(stdout, "\t specified the default is NATIVE. Output-byte-orders are fixed\n"); + (void)HDfprintf(stdout, "\t for some architectures and may be specified only if output-\n"); + (void)HDfprintf(stdout, "\t architecture is IEEE, UNIX or STD.\n\n"); + (void)HDfprintf(stdout, "\t Also, layout and other storage properties such as \n"); + (void)HDfprintf(stdout, "\t compression, external storage and extendible data-sets may be\n"); + (void)HDfprintf(stdout, "\t optionally specified. The layout and storage properties \n"); + (void)HDfprintf(stdout, "\t denote how raw data is to be organized on the disk. If these \n"); + (void)HDfprintf(stdout, "\t options are not specified the default is Contiguous layout \n"); + (void)HDfprintf(stdout, "\t and storage.\n\n"); + (void)HDfprintf(stdout, "\t The dataset can be organized in any of the following ways:\n"); + (void)HDfprintf(stdout, "\t 1. Contiguous.\n"); + (void)HDfprintf(stdout, "\t 2. Chunked.\n"); + (void)HDfprintf(stdout, "\t 3. External Storage File (has to be contiguous)\n"); + (void)HDfprintf(stdout, "\t 4. Extendible data sets (has to be chunked)\n"); + (void)HDfprintf(stdout, "\t 5. Compressed. (has to be chunked)\n"); + (void)HDfprintf(stdout, "\t 6. Compressed & Extendible (has to be chunked)\n\n"); + (void)HDfprintf(stdout, "\t If the user wants to store raw data in a non-HDF file then \n"); + (void)HDfprintf(stdout, "\t the external storage file option is to be used and the name \n"); + (void)HDfprintf(stdout, "\t of the file is to be specified. \n\n"); + (void)HDfprintf(stdout, "\t If the user wants the dimensions of the data-set to be\n"); + (void)HDfprintf(stdout, "\t unlimited, the extendible data set option can be chosen. \n\n"); + (void)HDfprintf(stdout, "\t The user may also specify the type of compression and the \n"); + (void)HDfprintf(stdout, "\t level to which the data set must be compresses by setting \n"); + (void)HDfprintf(stdout, "\t the compressed option.\n\n"); + (void)HDfprintf(stdout, "\t SYNOPSIS:\n"); + (void)HDfprintf(stdout, "\t h5import -h[elp], OR\n"); + (void)HDfprintf(stdout, "\t h5import -c[onfig] \ [ -c[config] ...] -o[utfile] \n\n"); - (void) HDfprintf(stdout, "\t -h[elp]:\n"); - (void) HDfprintf(stdout, - "\t Prints this summary of usage, and exits.\n\n"); - (void) HDfprintf(stdout, "\t :\n"); - (void) HDfprintf(stdout, - "\t Name of the Input file(s), containing a \n"); - (void) HDfprintf(stdout, - "\t single n-dimensional floating point or integer array \n"); - (void) HDfprintf(stdout, - "\t in either ASCII text, native floating point(32-bit \n"); - (void) HDfprintf(stdout, - "\t or 64-bit) or native integer(8-bit or 16-bit or \n"); - (void) HDfprintf(stdout, - "\t 32-bit or 64-bit). Data to be specified in the order\n"); - (void) HDfprintf(stdout, "\t of fastest changing dimensions first.\n\n"); - (void) HDfprintf(stdout, "\t -c[config] :\n"); - (void) HDfprintf(stdout, - "\t Every input file should be associated with a \n"); - (void) HDfprintf(stdout, - "\t configuration file and this is done by the -c option.\n"); - (void) HDfprintf(stdout, - "\t is the name of the configuration file.\n"); - (void) HDfprintf(stdout, "\t (See Section \"CONFIGURATION FILE\")\n\n"); - (void) HDfprintf(stdout, "\t -o[utfile] :\n"); - (void) HDfprintf(stdout, - "\t Name of the HDF5 output file. Data from one or more \n"); - (void) HDfprintf(stdout, - "\t input files are stored as one or more data sets in \n"); - (void) HDfprintf(stdout, - "\t . The output file may be an existing file or \n"); - (void) HDfprintf(stdout, - "\t it maybe new in which case it will be created.\n\n\n"); - (void) HDfprintf(stdout, "\t CONFIGURATION FILE:\n"); - (void) HDfprintf(stdout, - "\t The configuration file is an ASCII text file and must be \n"); - (void) HDfprintf(stdout, - "\t the ddl formatted file (without data values) produced by h5dump \n"); - (void) HDfprintf(stdout, - "\t when used with the options '-o outfilename -b' of a single dataset (-d) \n"); - (void) HDfprintf(stdout, - "\t OR organized as \"CONFIG-KEYWORD VALUE\" pairs, one pair on each \n"); - (void) HDfprintf(stdout, "\t line.\n\n"); - (void) HDfprintf(stdout, - "\t The configuration file may have the following keywords each \n"); - (void) HDfprintf(stdout, "\t followed by an acceptable value.\n\n"); - (void) HDfprintf(stdout, "\t Required KEYWORDS:\n"); - (void) HDfprintf(stdout, "\t PATH\n"); - (void) HDfprintf(stdout, "\t INPUT-CLASS\n"); - (void) HDfprintf(stdout, "\t INPUT-SIZE\n"); - (void) HDfprintf(stdout, "\t INPUT-BYTE-ORDER\n"); - (void) HDfprintf(stdout, "\t RANK\n"); - (void) HDfprintf(stdout, "\t DIMENSION-SIZES\n"); - (void) HDfprintf(stdout, "\t OUTPUT-CLASS\n"); - (void) HDfprintf(stdout, "\t OUTPUT-SIZE\n\n"); - (void) HDfprintf(stdout, "\t Optional KEYWORDS:\n"); - (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE\n"); - (void) HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER\n"); - (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES\n"); - (void) HDfprintf(stdout, "\t COMPRESSION-TYPE\n"); - (void) HDfprintf(stdout, "\t COMPRESSION-PARAM\n"); - (void) HDfprintf(stdout, "\t EXTERNAL-STORAGE\n"); - (void) HDfprintf(stdout, "\t MAXIMUM-DIMENSIONS\n\n\n"); - (void) HDfprintf(stdout, "\t Values for keywords:\n"); - (void) HDfprintf(stdout, "\t PATH:\n"); - (void) HDfprintf(stdout, "\t Strings separated by spaces to represent\n"); - (void) HDfprintf(stdout, "\t the path of the data-set. If the groups in\n"); - (void) HDfprintf(stdout, - "\t the path do not exist, they will be created. \n"); - (void) HDfprintf(stdout, "\t For example,\n"); - (void) HDfprintf(stdout, "\t PATH grp1/grp2/dataset1\n"); - (void) HDfprintf(stdout, "\t PATH: keyword\n"); - (void) HDfprintf(stdout, "\t grp1: group under the root. If\n"); - (void) HDfprintf(stdout, "\t non-existent will be created.\n"); - (void) HDfprintf(stdout, "\t grp2: group under grp1. If \n"); - (void) HDfprintf(stdout, "\t non-existent will be created \n"); - (void) HDfprintf(stdout, "\t under grp1.\n"); - (void) HDfprintf(stdout, "\t dataset1: the name of the data-set \n"); - (void) HDfprintf(stdout, "\t to be created.\n\n"); - (void) HDfprintf(stdout, "\t INPUT-CLASS:\n"); - (void) HDfprintf(stdout, "\t String denoting the type of input data.\n"); - (void) HDfprintf(stdout, "\t (\"TEXTIN\", \"TEXTFP\", \"FP\", \"IN\", \n"); - (void) HDfprintf(stdout, "\t \"STR\", \"TEXTUIN\", \"UIN\"). \n"); - (void) HDfprintf(stdout, - "\t INPUT-CLASS \"TEXTIN\" denotes an ASCII text \n"); - (void) HDfprintf(stdout, - "\t file with signed integer data in ASCII form,\n"); - (void) HDfprintf(stdout, - "\t INPUT-CLASS \"TEXTUIN\" denotes an ASCII text \n"); - (void) HDfprintf(stdout, - "\t file with unsigned integer data in ASCII form,\n"); - (void) HDfprintf(stdout, - "\t \"TEXTFP\" denotes an ASCII text file containing\n"); - (void) HDfprintf(stdout, "\t floating point data in the fixed notation\n"); - (void) HDfprintf(stdout, "\t (325.34),\n"); - (void) HDfprintf(stdout, - "\t \"FP\" denotes a floating point binary file,\n"); - (void) HDfprintf(stdout, - "\t \"IN\" denotes a signed integer binary file,\n"); - (void) HDfprintf(stdout, - "\t \"UIN\" denotes an unsigned integer binary file,\n"); - (void) HDfprintf(stdout, "\t & \"STR\" denotes an ASCII text file the \n"); - (void) HDfprintf(stdout, - "\t contents of which should be stored as an 1-D \n"); - (void) HDfprintf(stdout, "\t array of strings.\n"); - (void) HDfprintf(stdout, "\t If INPUT-CLASS is \"STR\", then RANK, \n"); - (void) HDfprintf(stdout, - "\t DIMENSION-SIZES, OUTPUT-CLASS, OUTPUT-SIZE, \n"); - (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE and OUTPUT-BYTE-ORDER \n"); - (void) HDfprintf(stdout, "\t will be ignored.\n\n\n"); - (void) HDfprintf(stdout, "\t INPUT-SIZE:\n"); - (void) HDfprintf(stdout, - "\t Integer denoting the size of the input data \n"); - (void) HDfprintf(stdout, "\t (8, 16, 32, 64). \n\n"); - (void) HDfprintf(stdout, "\t For floating point,\n"); - (void) HDfprintf(stdout, "\t INPUT-SIZE can be 32 or 64.\n"); - (void) HDfprintf(stdout, "\t For integers (signed and unsigned)\n"); - (void) HDfprintf(stdout, "\t INPUT-SIZE can be 8, 16, 32 or 64.\n\n"); - (void) HDfprintf(stdout, "\t RANK:\n"); - (void) HDfprintf(stdout, - "\t Integer denoting the number of dimensions.\n\n"); - (void) HDfprintf(stdout, "\t DIMENSION-SIZES:\n"); - (void) HDfprintf(stdout, - "\t Integers separated by spaces to denote the \n"); - (void) HDfprintf(stdout, "\t dimension sizes for the no. of dimensions \n"); - (void) HDfprintf(stdout, "\t determined by rank.\n\n"); - (void) HDfprintf(stdout, "\t OUTPUT-CLASS:\n"); - (void) HDfprintf(stdout, - "\t String dentoting data type of the dataset to \n"); - (void) HDfprintf(stdout, "\t be written (\"IN\",\"FP\", \"UIN\")\n\n"); - (void) HDfprintf(stdout, "\t OUTPUT-SIZE:\n"); - (void) HDfprintf(stdout, - "\t Integer denoting the size of the data in the \n"); - (void) HDfprintf(stdout, "\t output dataset to be written.\n"); - (void) HDfprintf(stdout, - "\t If OUTPUT-CLASS is \"FP\", OUTPUT-SIZE can be \n"); - (void) HDfprintf(stdout, "\t 32 or 64.\n"); - (void) HDfprintf(stdout, - "\t If OUTPUT-CLASS is \"IN\" or \"UIN\", OUTPUT-SIZE\n"); - (void) HDfprintf(stdout, "\t can be 8, 16, 32 or 64.\n\n"); - (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE:\n"); - (void) HDfprintf(stdout, "\t STRING denoting the type of output \n"); - (void) HDfprintf(stdout, - "\t architecture. Can accept the following values\n"); - (void) HDfprintf(stdout, "\t STD\n"); - (void) HDfprintf(stdout, "\t IEEE\n"); - (void) HDfprintf(stdout, "\t INTEL\n"); - (void) HDfprintf(stdout, "\t CRAY\n"); - (void) HDfprintf(stdout, "\t MIPS\n"); - (void) HDfprintf(stdout, "\t ALPHA\n"); - (void) HDfprintf(stdout, "\t NATIVE (default)\n"); - (void) HDfprintf(stdout, "\t UNIX\n\n"); - (void) HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER:\n"); - (void) HDfprintf(stdout, - "\t String denoting the output-byte-order. Ignored\n"); - (void) HDfprintf(stdout, - "\t if the OUTPUT-ARCHITECTURE is not specified or\n"); - (void) HDfprintf(stdout, "\t if it is IEEE, UNIX or STD. Can accept the \n"); - (void) HDfprintf(stdout, "\t following values.\n"); - (void) HDfprintf(stdout, "\t BE (default)\n"); - (void) HDfprintf(stdout, "\t LE\n\n"); - (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES:\n"); - (void) HDfprintf(stdout, "\t Integers separated by spaces to denote the \n"); - (void) HDfprintf(stdout, - "\t dimension sizes of the chunk for the no. of \n"); - (void) HDfprintf(stdout, - "\t dimensions determined by rank. Required field\n"); - (void) HDfprintf(stdout, - "\t to denote that the dataset will be stored with\n"); - (void) HDfprintf(stdout, - "\t chunked storage. If this field is absent the\n"); - (void) HDfprintf(stdout, - "\t dataset will be stored with contiguous storage.\n\n"); - (void) HDfprintf(stdout, "\t COMPRESSION-TYPE:\n"); - (void) HDfprintf(stdout, - "\t String denoting the type of compression to be\n"); - (void) HDfprintf(stdout, "\t used with the chunked storage. Requires the\n"); - (void) HDfprintf(stdout, - "\t CHUNKED-DIMENSION-SIZES to be specified. The only \n"); - (void) HDfprintf(stdout, - "\t currently supported compression method is GZIP. \n"); - (void) HDfprintf(stdout, "\t Will accept the following value\n"); - (void) HDfprintf(stdout, "\t GZIP\n\n"); - (void) HDfprintf(stdout, "\t COMPRESSION-PARAM:\n"); - (void) HDfprintf(stdout, - "\t Integer used to denote compression level and \n"); - (void) HDfprintf(stdout, "\t this option is to be always specified when \n"); - (void) HDfprintf(stdout, - "\t the COMPRESSION-TYPE option is specified. The\n"); - (void) HDfprintf(stdout, "\t values are applicable only to GZIP \n"); - (void) HDfprintf(stdout, "\t compression.\n"); - (void) HDfprintf(stdout, "\t Value 1-9: The level of Compression. \n"); - (void) HDfprintf(stdout, "\t 1 will result in the fastest \n"); - (void) HDfprintf(stdout, "\t compression while 9 will result in \n"); - (void) HDfprintf(stdout, "\t the best compression ratio. The default\n"); - (void) HDfprintf(stdout, "\t level of compression is 6.\n\n"); - (void) HDfprintf(stdout, "\t EXTERNAL-STORAGE:\n"); - (void) HDfprintf(stdout, - "\t String to denote the name of the non-HDF5 file \n"); - (void) HDfprintf(stdout, - "\t to store data to. Cannot be used if CHUNKED-\n"); - (void) HDfprintf(stdout, - "\t DIMENSIONS or COMPRESSION-TYPE or EXTENDIBLE-\n"); - (void) HDfprintf(stdout, "\t DATASET is specified.\n"); - (void) HDfprintf(stdout, "\t Value : the name of the \n"); - (void) HDfprintf(stdout, "\t external file as a string to be used.\n\n"); - (void) HDfprintf(stdout, "\t MAXIMUM-DIMENSIONS:\n"); - (void) HDfprintf(stdout, "\t Integers separated by spaces to denote the \n"); - (void) HDfprintf(stdout, "\t maximum dimension sizes of all the \n"); - (void) HDfprintf(stdout, "\t dimensions determined by rank. Requires the\n"); - (void) HDfprintf(stdout, - "\t CHUNKED-DIMENSION-SIZES to be specified. A value of \n"); - (void) HDfprintf(stdout, "\t -1 for any dimension implies UNLIMITED \n"); - (void) HDfprintf(stdout, - "\t DIMENSION size for that particular dimension.\n\n"); - (void) HDfprintf(stdout, "\t EXAMPLES:\n"); - (void) HDfprintf(stdout, "\t 1. Configuration File may look like:\n\n"); - (void) HDfprintf(stdout, "\t PATH work h5 pkamat First-set\n"); - (void) HDfprintf(stdout, "\t INPUT-CLASS TEXTFP\n"); - (void) HDfprintf(stdout, "\t RANK 3\n"); - (void) HDfprintf(stdout, "\t DIMENSION-SIZES 5 2 4\n"); - (void) HDfprintf(stdout, "\t OUTPUT-CLASS FP\n"); - (void) HDfprintf(stdout, "\t OUTPUT-SIZE 64\n"); - (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE IEEE\n"); - (void) HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES 2 2 2 \n\n"); - (void) HDfprintf(stdout, - "\t The above configuration will accept a floating point array \n"); - (void) HDfprintf(stdout, - "\t (5 x 2 x 4) in an ASCII file with the rank and dimension sizes \n"); - (void) HDfprintf(stdout, - "\t specified and will save it in a chunked data-set (of pattern \n"); - (void) HDfprintf(stdout, - "\t 2 X 2 X 2) of 64-bit floating point in the little-endian order \n"); - (void) HDfprintf(stdout, - "\t and IEEE architecture. The dataset will be stored at\n"); - (void) HDfprintf(stdout, "\t \"/work/h5/pkamat/First-set\"\n\n"); - (void) HDfprintf(stdout, "\t 2. Another configuration could be:\n\n"); - (void) HDfprintf(stdout, "\t PATH Second-set\n"); - (void) HDfprintf(stdout, "\t INPUT-CLASS IN \n"); - (void) HDfprintf(stdout, "\t RANK 5\n"); - (void) HDfprintf(stdout, "\t DIMENSION-SIZES 6 3 5 2 4\n"); - (void) HDfprintf(stdout, "\t OUTPUT-CLASS IN\n"); - (void) HDfprintf(stdout, "\t OUTPUT-SIZE 32\n"); - (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES 2 2 2 2 2\n"); - (void) HDfprintf(stdout, "\t EXTENDIBLE-DATASET 1 3 \n"); - (void) HDfprintf(stdout, "\t COMPRESSION-TYPE GZIP\n"); - (void) HDfprintf(stdout, "\t COMPRESSION-PARAM 7\n\n\n"); - (void) HDfprintf(stdout, - "\t The above configuration will accept an integer array \n"); - (void) HDfprintf(stdout, - "\t (6 X 3 X 5 x 2 x 4) in a binary file with the rank and \n"); - (void) HDfprintf(stdout, - "\t dimension sizes specified and will save it in a chunked data-set\n"); - (void) HDfprintf(stdout, - "\t (of pattern 2 X 2 X 2 X 2 X 2) of 32-bit floating point in \n"); - (void) HDfprintf(stdout, - "\t native format (as output-architecture is not specified). The \n"); - (void) HDfprintf(stdout, - "\t first and the third dimension will be defined as unlimited. The \n"); - (void) HDfprintf(stdout, - "\t data-set will be compressed using GZIP and a compression level \n"); - (void) HDfprintf(stdout, "\t of 7.\n"); - (void) HDfprintf(stdout, - "\t The dataset will be stored at \"/Second-set\"\n\n"); + (void)HDfprintf(stdout, "\t -h[elp]:\n"); + (void)HDfprintf(stdout, "\t Prints this summary of usage, and exits.\n\n"); + (void)HDfprintf(stdout, "\t :\n"); + (void)HDfprintf(stdout, "\t Name of the Input file(s), containing a \n"); + (void)HDfprintf(stdout, "\t single n-dimensional floating point or integer array \n"); + (void)HDfprintf(stdout, "\t in either ASCII text, native floating point(32-bit \n"); + (void)HDfprintf(stdout, "\t or 64-bit) or native integer(8-bit or 16-bit or \n"); + (void)HDfprintf(stdout, "\t 32-bit or 64-bit). Data to be specified in the order\n"); + (void)HDfprintf(stdout, "\t of fastest changing dimensions first.\n\n"); + (void)HDfprintf(stdout, "\t -c[config] :\n"); + (void)HDfprintf(stdout, "\t Every input file should be associated with a \n"); + (void)HDfprintf(stdout, "\t configuration file and this is done by the -c option.\n"); + (void)HDfprintf(stdout, "\t is the name of the configuration file.\n"); + (void)HDfprintf(stdout, "\t (See Section \"CONFIGURATION FILE\")\n\n"); + (void)HDfprintf(stdout, "\t -o[utfile] :\n"); + (void)HDfprintf(stdout, "\t Name of the HDF5 output file. Data from one or more \n"); + (void)HDfprintf(stdout, "\t input files are stored as one or more data sets in \n"); + (void)HDfprintf(stdout, "\t . The output file may be an existing file or \n"); + (void)HDfprintf(stdout, "\t it maybe new in which case it will be created.\n\n\n"); + (void)HDfprintf(stdout, "\t CONFIGURATION FILE:\n"); + (void)HDfprintf(stdout, "\t The configuration file is an ASCII text file and must be \n"); + (void)HDfprintf(stdout, "\t the ddl formatted file (without data values) produced by h5dump \n"); + (void)HDfprintf(stdout, "\t when used with the options '-o outfilename -b' of a single dataset (-d) \n"); + (void)HDfprintf(stdout, "\t OR organized as \"CONFIG-KEYWORD VALUE\" pairs, one pair on each \n"); + (void)HDfprintf(stdout, "\t line.\n\n"); + (void)HDfprintf(stdout, "\t The configuration file may have the following keywords each \n"); + (void)HDfprintf(stdout, "\t followed by an acceptable value.\n\n"); + (void)HDfprintf(stdout, "\t Required KEYWORDS:\n"); + (void)HDfprintf(stdout, "\t PATH\n"); + (void)HDfprintf(stdout, "\t INPUT-CLASS\n"); + (void)HDfprintf(stdout, "\t INPUT-SIZE\n"); + (void)HDfprintf(stdout, "\t INPUT-BYTE-ORDER\n"); + (void)HDfprintf(stdout, "\t RANK\n"); + (void)HDfprintf(stdout, "\t DIMENSION-SIZES\n"); + (void)HDfprintf(stdout, "\t OUTPUT-CLASS\n"); + (void)HDfprintf(stdout, "\t OUTPUT-SIZE\n\n"); + (void)HDfprintf(stdout, "\t Optional KEYWORDS:\n"); + (void)HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE\n"); + (void)HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER\n"); + (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES\n"); + (void)HDfprintf(stdout, "\t COMPRESSION-TYPE\n"); + (void)HDfprintf(stdout, "\t COMPRESSION-PARAM\n"); + (void)HDfprintf(stdout, "\t EXTERNAL-STORAGE\n"); + (void)HDfprintf(stdout, "\t MAXIMUM-DIMENSIONS\n\n\n"); + (void)HDfprintf(stdout, "\t Values for keywords:\n"); + (void)HDfprintf(stdout, "\t PATH:\n"); + (void)HDfprintf(stdout, "\t Strings separated by spaces to represent\n"); + (void)HDfprintf(stdout, "\t the path of the data-set. If the groups in\n"); + (void)HDfprintf(stdout, "\t the path do not exist, they will be created. \n"); + (void)HDfprintf(stdout, "\t For example,\n"); + (void)HDfprintf(stdout, "\t PATH grp1/grp2/dataset1\n"); + (void)HDfprintf(stdout, "\t PATH: keyword\n"); + (void)HDfprintf(stdout, "\t grp1: group under the root. If\n"); + (void)HDfprintf(stdout, "\t non-existent will be created.\n"); + (void)HDfprintf(stdout, "\t grp2: group under grp1. If \n"); + (void)HDfprintf(stdout, "\t non-existent will be created \n"); + (void)HDfprintf(stdout, "\t under grp1.\n"); + (void)HDfprintf(stdout, "\t dataset1: the name of the data-set \n"); + (void)HDfprintf(stdout, "\t to be created.\n\n"); + (void)HDfprintf(stdout, "\t INPUT-CLASS:\n"); + (void)HDfprintf(stdout, "\t String denoting the type of input data.\n"); + (void)HDfprintf(stdout, "\t (\"TEXTIN\", \"TEXTFP\", \"FP\", \"IN\", \n"); + (void)HDfprintf(stdout, "\t \"STR\", \"TEXTUIN\", \"UIN\"). \n"); + (void)HDfprintf(stdout, "\t INPUT-CLASS \"TEXTIN\" denotes an ASCII text \n"); + (void)HDfprintf(stdout, "\t file with signed integer data in ASCII form,\n"); + (void)HDfprintf(stdout, "\t INPUT-CLASS \"TEXTUIN\" denotes an ASCII text \n"); + (void)HDfprintf(stdout, "\t file with unsigned integer data in ASCII form,\n"); + (void)HDfprintf(stdout, "\t \"TEXTFP\" denotes an ASCII text file containing\n"); + (void)HDfprintf(stdout, "\t floating point data in the fixed notation\n"); + (void)HDfprintf(stdout, "\t (325.34),\n"); + (void)HDfprintf(stdout, "\t \"FP\" denotes a floating point binary file,\n"); + (void)HDfprintf(stdout, "\t \"IN\" denotes a signed integer binary file,\n"); + (void)HDfprintf(stdout, "\t \"UIN\" denotes an unsigned integer binary file,\n"); + (void)HDfprintf(stdout, "\t & \"STR\" denotes an ASCII text file the \n"); + (void)HDfprintf(stdout, "\t contents of which should be stored as an 1-D \n"); + (void)HDfprintf(stdout, "\t array of strings.\n"); + (void)HDfprintf(stdout, "\t If INPUT-CLASS is \"STR\", then RANK, \n"); + (void)HDfprintf(stdout, "\t DIMENSION-SIZES, OUTPUT-CLASS, OUTPUT-SIZE, \n"); + (void)HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE and OUTPUT-BYTE-ORDER \n"); + (void)HDfprintf(stdout, "\t will be ignored.\n\n\n"); + (void)HDfprintf(stdout, "\t INPUT-SIZE:\n"); + (void)HDfprintf(stdout, "\t Integer denoting the size of the input data \n"); + (void)HDfprintf(stdout, "\t (8, 16, 32, 64). \n\n"); + (void)HDfprintf(stdout, "\t For floating point,\n"); + (void)HDfprintf(stdout, "\t INPUT-SIZE can be 32 or 64.\n"); + (void)HDfprintf(stdout, "\t For integers (signed and unsigned)\n"); + (void)HDfprintf(stdout, "\t INPUT-SIZE can be 8, 16, 32 or 64.\n\n"); + (void)HDfprintf(stdout, "\t RANK:\n"); + (void)HDfprintf(stdout, "\t Integer denoting the number of dimensions.\n\n"); + (void)HDfprintf(stdout, "\t DIMENSION-SIZES:\n"); + (void)HDfprintf(stdout, "\t Integers separated by spaces to denote the \n"); + (void)HDfprintf(stdout, "\t dimension sizes for the no. of dimensions \n"); + (void)HDfprintf(stdout, "\t determined by rank.\n\n"); + (void)HDfprintf(stdout, "\t OUTPUT-CLASS:\n"); + (void)HDfprintf(stdout, "\t String dentoting data type of the dataset to \n"); + (void)HDfprintf(stdout, "\t be written (\"IN\",\"FP\", \"UIN\")\n\n"); + (void)HDfprintf(stdout, "\t OUTPUT-SIZE:\n"); + (void)HDfprintf(stdout, "\t Integer denoting the size of the data in the \n"); + (void)HDfprintf(stdout, "\t output dataset to be written.\n"); + (void)HDfprintf(stdout, "\t If OUTPUT-CLASS is \"FP\", OUTPUT-SIZE can be \n"); + (void)HDfprintf(stdout, "\t 32 or 64.\n"); + (void)HDfprintf(stdout, "\t If OUTPUT-CLASS is \"IN\" or \"UIN\", OUTPUT-SIZE\n"); + (void)HDfprintf(stdout, "\t can be 8, 16, 32 or 64.\n\n"); + (void)HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE:\n"); + (void)HDfprintf(stdout, "\t STRING denoting the type of output \n"); + (void)HDfprintf(stdout, "\t architecture. Can accept the following values\n"); + (void)HDfprintf(stdout, "\t STD\n"); + (void)HDfprintf(stdout, "\t IEEE\n"); + (void)HDfprintf(stdout, "\t INTEL\n"); + (void)HDfprintf(stdout, "\t CRAY\n"); + (void)HDfprintf(stdout, "\t MIPS\n"); + (void)HDfprintf(stdout, "\t ALPHA\n"); + (void)HDfprintf(stdout, "\t NATIVE (default)\n"); + (void)HDfprintf(stdout, "\t UNIX\n\n"); + (void)HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER:\n"); + (void)HDfprintf(stdout, "\t String denoting the output-byte-order. Ignored\n"); + (void)HDfprintf(stdout, "\t if the OUTPUT-ARCHITECTURE is not specified or\n"); + (void)HDfprintf(stdout, "\t if it is IEEE, UNIX or STD. Can accept the \n"); + (void)HDfprintf(stdout, "\t following values.\n"); + (void)HDfprintf(stdout, "\t BE (default)\n"); + (void)HDfprintf(stdout, "\t LE\n\n"); + (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES:\n"); + (void)HDfprintf(stdout, "\t Integers separated by spaces to denote the \n"); + (void)HDfprintf(stdout, "\t dimension sizes of the chunk for the no. of \n"); + (void)HDfprintf(stdout, "\t dimensions determined by rank. Required field\n"); + (void)HDfprintf(stdout, "\t to denote that the dataset will be stored with\n"); + (void)HDfprintf(stdout, "\t chunked storage. If this field is absent the\n"); + (void)HDfprintf(stdout, "\t dataset will be stored with contiguous storage.\n\n"); + (void)HDfprintf(stdout, "\t COMPRESSION-TYPE:\n"); + (void)HDfprintf(stdout, "\t String denoting the type of compression to be\n"); + (void)HDfprintf(stdout, "\t used with the chunked storage. Requires the\n"); + (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES to be specified. The only \n"); + (void)HDfprintf(stdout, "\t currently supported compression method is GZIP. \n"); + (void)HDfprintf(stdout, "\t Will accept the following value\n"); + (void)HDfprintf(stdout, "\t GZIP\n\n"); + (void)HDfprintf(stdout, "\t COMPRESSION-PARAM:\n"); + (void)HDfprintf(stdout, "\t Integer used to denote compression level and \n"); + (void)HDfprintf(stdout, "\t this option is to be always specified when \n"); + (void)HDfprintf(stdout, "\t the COMPRESSION-TYPE option is specified. The\n"); + (void)HDfprintf(stdout, "\t values are applicable only to GZIP \n"); + (void)HDfprintf(stdout, "\t compression.\n"); + (void)HDfprintf(stdout, "\t Value 1-9: The level of Compression. \n"); + (void)HDfprintf(stdout, "\t 1 will result in the fastest \n"); + (void)HDfprintf(stdout, "\t compression while 9 will result in \n"); + (void)HDfprintf(stdout, "\t the best compression ratio. The default\n"); + (void)HDfprintf(stdout, "\t level of compression is 6.\n\n"); + (void)HDfprintf(stdout, "\t EXTERNAL-STORAGE:\n"); + (void)HDfprintf(stdout, "\t String to denote the name of the non-HDF5 file \n"); + (void)HDfprintf(stdout, "\t to store data to. Cannot be used if CHUNKED-\n"); + (void)HDfprintf(stdout, "\t DIMENSIONS or COMPRESSION-TYPE or EXTENDIBLE-\n"); + (void)HDfprintf(stdout, "\t DATASET is specified.\n"); + (void)HDfprintf(stdout, "\t Value : the name of the \n"); + (void)HDfprintf(stdout, "\t external file as a string to be used.\n\n"); + (void)HDfprintf(stdout, "\t MAXIMUM-DIMENSIONS:\n"); + (void)HDfprintf(stdout, "\t Integers separated by spaces to denote the \n"); + (void)HDfprintf(stdout, "\t maximum dimension sizes of all the \n"); + (void)HDfprintf(stdout, "\t dimensions determined by rank. Requires the\n"); + (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES to be specified. A value of \n"); + (void)HDfprintf(stdout, "\t -1 for any dimension implies UNLIMITED \n"); + (void)HDfprintf(stdout, "\t DIMENSION size for that particular dimension.\n\n"); + (void)HDfprintf(stdout, "\t EXAMPLES:\n"); + (void)HDfprintf(stdout, "\t 1. Configuration File may look like:\n\n"); + (void)HDfprintf(stdout, "\t PATH work h5 pkamat First-set\n"); + (void)HDfprintf(stdout, "\t INPUT-CLASS TEXTFP\n"); + (void)HDfprintf(stdout, "\t RANK 3\n"); + (void)HDfprintf(stdout, "\t DIMENSION-SIZES 5 2 4\n"); + (void)HDfprintf(stdout, "\t OUTPUT-CLASS FP\n"); + (void)HDfprintf(stdout, "\t OUTPUT-SIZE 64\n"); + (void)HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE IEEE\n"); + (void)HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES 2 2 2 \n\n"); + (void)HDfprintf(stdout, "\t The above configuration will accept a floating point array \n"); + (void)HDfprintf(stdout, "\t (5 x 2 x 4) in an ASCII file with the rank and dimension sizes \n"); + (void)HDfprintf(stdout, "\t specified and will save it in a chunked data-set (of pattern \n"); + (void)HDfprintf(stdout, "\t 2 X 2 X 2) of 64-bit floating point in the little-endian order \n"); + (void)HDfprintf(stdout, "\t and IEEE architecture. The dataset will be stored at\n"); + (void)HDfprintf(stdout, "\t \"/work/h5/pkamat/First-set\"\n\n"); + (void)HDfprintf(stdout, "\t 2. Another configuration could be:\n\n"); + (void)HDfprintf(stdout, "\t PATH Second-set\n"); + (void)HDfprintf(stdout, "\t INPUT-CLASS IN \n"); + (void)HDfprintf(stdout, "\t RANK 5\n"); + (void)HDfprintf(stdout, "\t DIMENSION-SIZES 6 3 5 2 4\n"); + (void)HDfprintf(stdout, "\t OUTPUT-CLASS IN\n"); + (void)HDfprintf(stdout, "\t OUTPUT-SIZE 32\n"); + (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES 2 2 2 2 2\n"); + (void)HDfprintf(stdout, "\t EXTENDIBLE-DATASET 1 3 \n"); + (void)HDfprintf(stdout, "\t COMPRESSION-TYPE GZIP\n"); + (void)HDfprintf(stdout, "\t COMPRESSION-PARAM 7\n\n\n"); + (void)HDfprintf(stdout, "\t The above configuration will accept an integer array \n"); + (void)HDfprintf(stdout, "\t (6 X 3 X 5 x 2 x 4) in a binary file with the rank and \n"); + (void)HDfprintf(stdout, "\t dimension sizes specified and will save it in a chunked data-set\n"); + (void)HDfprintf(stdout, "\t (of pattern 2 X 2 X 2 X 2 X 2) of 32-bit floating point in \n"); + (void)HDfprintf(stdout, "\t native format (as output-architecture is not specified). The \n"); + (void)HDfprintf(stdout, "\t first and the third dimension will be defined as unlimited. The \n"); + (void)HDfprintf(stdout, "\t data-set will be compressed using GZIP and a compression level \n"); + (void)HDfprintf(stdout, "\t of 7.\n"); + (void)HDfprintf(stdout, "\t The dataset will be stored at \"/Second-set\"\n\n"); return; } -void usage(char *name) +void +usage(char *name) { - (void) HDfprintf(stdout, "\nUsage:\t%s -h[elp], OR\n", name); - (void) HDfprintf(stdout, - "\t%s -c[onfig] \ - [ -c[config] ...] -o[utfile] \n\n", name); + (void)HDfprintf(stdout, "\nUsage:\t%s -h[elp], OR\n", name); + (void)HDfprintf(stdout, "\t%s -c[onfig] \ + [ -c[config] ...] -o[utfile] \n\n", + name); return; } - diff --git a/tools/src/h5import/h5import.h b/tools/src/h5import/h5import.h index 00c41f6..405d953 100644 --- a/tools/src/h5import/h5import.h +++ b/tools/src/h5import/h5import.h @@ -25,116 +25,109 @@ */ #define FILNAME 0 /* filename */ -#define OPT_o 1 +#define OPT_o 1 /* output filename */ -#define OPT_c 2 /* configuration filename */ -#define OPT_h 3 /* request for explanation */ -#define OPT_d 4 /* dimensions */ -#define OPT_p 5 /* pathname */ -#define OPT_t 6 /* data type */ -#define OPT_s 7 /* data size */ -#define ERR 20 /* invalid token */ - -#define MAX_GROUPS_IN_PATH 20 +#define OPT_c 2 /* configuration filename */ +#define OPT_h 3 /* request for explanation */ +#define OPT_d 4 /* dimensions */ +#define OPT_p 5 /* pathname */ +#define OPT_t 6 /* data type */ +#define OPT_s 7 /* data size */ +#define ERR 20 /* invalid token */ + +#define MAX_GROUPS_IN_PATH 20 #define MAX_PATH_NAME_LENGTH 255 -#define NUM_KEYS 15 -#define MIN_NUM_DIMENSION 1 -#define MAX_NUM_DIMENSION 32 -#define BASE_10 10 - -#define PATH 0 -#define INPUT_CLASS 1 -#define INPUT_SIZE 2 -#define RANK 3 -#define DIM 4 -#define OUTPUT_CLASS 5 -#define OUTPUT_SIZE 6 -#define OUTPUT_ARCH 7 -#define OUTPUT_B_ORDER 8 -#define CHUNK 9 -#define COMPRESS 10 -#define COMPRESS_PARAM 11 -#define EXTERNALSTORE 12 -#define EXTEND 13 -#define INPUT_B_ORDER 14 +#define NUM_KEYS 15 +#define MIN_NUM_DIMENSION 1 +#define MAX_NUM_DIMENSION 32 +#define BASE_10 10 + +#define PATH 0 +#define INPUT_CLASS 1 +#define INPUT_SIZE 2 +#define RANK 3 +#define DIM 4 +#define OUTPUT_CLASS 5 +#define OUTPUT_SIZE 6 +#define OUTPUT_ARCH 7 +#define OUTPUT_B_ORDER 8 +#define CHUNK 9 +#define COMPRESS 10 +#define COMPRESS_PARAM 11 +#define EXTERNALSTORE 12 +#define EXTEND 13 +#define INPUT_B_ORDER 14 /* data types */ -#define H5DT_INT8 signed char -#define H5DT_INT16 short -#define H5DT_INT32 int -#define H5DT_FLOAT32 float -#define H5DT_FLOAT64 double -#define VOIDP void* -#define H5DT_UINT8 unsigned char -#define H5DT_UINT16 unsigned short -#define H5DT_UINT32 unsigned int -#define H5DT_INT64 long long -#define H5DT_UINT64 unsigned H5DT_INT64 - -struct path_info -{ +#define H5DT_INT8 signed char +#define H5DT_INT16 short +#define H5DT_INT32 int +#define H5DT_FLOAT32 float +#define H5DT_FLOAT64 double +#define VOIDP void * +#define H5DT_UINT8 unsigned char +#define H5DT_UINT16 unsigned short +#define H5DT_UINT32 unsigned int +#define H5DT_INT64 long long +#define H5DT_UINT64 unsigned H5DT_INT64 + +struct path_info { char group[MAX_GROUPS_IN_PATH][MAX_PATH_NAME_LENGTH]; - int count; + int count; }; -struct Input -{ - int h5dumpInput; +struct Input { + int h5dumpInput; struct path_info path; - int inputClass; - int inputSize; - int inputArchitecture; - int inputByteOrder; - int rank; - hsize_t* sizeOfDimension; - int outputClass; - int outputSize; - int outputArchitecture; - int outputByteOrder; - hsize_t* sizeOfChunk; - hsize_t* maxsizeOfDimension; - int compressionType; - int compressionParam; - char *externFilename; - VOIDP data; - int configOptionVector[NUM_KEYS]; + int inputClass; + int inputSize; + int inputArchitecture; + int inputByteOrder; + int rank; + hsize_t * sizeOfDimension; + int outputClass; + int outputSize; + int outputArchitecture; + int outputByteOrder; + hsize_t * sizeOfChunk; + hsize_t * maxsizeOfDimension; + int compressionType; + int compressionParam; + char * externFilename; + VOIDP data; + int configOptionVector[NUM_KEYS]; }; -struct infilesformat -{ - char datafile[MAX_PATH_NAME_LENGTH]; - char configfile[MAX_PATH_NAME_LENGTH]; +struct infilesformat { + char datafile[MAX_PATH_NAME_LENGTH]; + char configfile[MAX_PATH_NAME_LENGTH]; struct Input in; - int config; /* Configfile present? No - 0. Yes - 1 */ + int config; /* Configfile present? No - 0. Yes - 1 */ }; -struct Options -{ - struct infilesformat infiles[30]; /* structure to hold the list of input file names. Limited to 30*/ - char outfile[256]; /* output file name */ - int fcount; /* number of input files */ +struct Options { + struct infilesformat infiles[30]; /* structure to hold the list of input file names. Limited to 30*/ + char outfile[256]; /* output file name */ + int fcount; /* number of input files */ }; -char keytable[NUM_KEYS][30] = { - "PATH", - "INPUT-CLASS", - "INPUT-SIZE", - "RANK", - "DIMENSION-SIZES", - "OUTPUT-CLASS", - "OUTPUT-SIZE", - "OUTPUT-ARCHITECTURE", - "OUTPUT-BYTE-ORDER", - "CHUNKED-DIMENSION-SIZES", - "COMPRESSION-TYPE", - "COMPRESSION-PARAM", - "EXTERNAL-STORAGE", - "MAXIMUM-DIMENSIONS", - "INPUT-BYTE-ORDER" -}; - -static int state_table[15][8] = -{ +char keytable[NUM_KEYS][30] = {"PATH", + "INPUT-CLASS", + "INPUT-SIZE", + "RANK", + "DIMENSION-SIZES", + "OUTPUT-CLASS", + "OUTPUT-SIZE", + "OUTPUT-ARCHITECTURE", + "OUTPUT-BYTE-ORDER", + "CHUNKED-DIMENSION-SIZES", + "COMPRESSION-TYPE", + "COMPRESSION-PARAM", + "EXTERNAL-STORAGE", + "MAXIMUM-DIMENSIONS", + "INPUT-BYTE-ORDER"}; + +static int state_table[15][8] = { /* token ordering: FILNAME OPT_o OPT_c OPT_h OPT_d OPT_p OPT_t OPT_s */ /* state 0: start */ @@ -189,12 +182,11 @@ static int state_table[15][8] = * Function declarations for h5import * */ -void usage(char *); -void setDefaultValues(struct Input *in, int count); -void help(char *); - -hid_t createOutputDataType(struct Input *in); -hid_t createInputDataType(struct Input *in); +void usage(char *); +void setDefaultValues(struct Input *in, int count); +void help(char *); -#endif /* H5IMPORT_H__ */ +hid_t createOutputDataType(struct Input *in); +hid_t createInputDataType(struct Input *in); +#endif /* H5IMPORT_H__ */ diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c index 8b61112..d77767a 100644 --- a/tools/src/h5jam/h5jam.c +++ b/tools/src/h5jam/h5jam.c @@ -19,36 +19,29 @@ /* Name of tool */ #define PROGRAMNAME "h5jam" -herr_t write_pad(int ofile, hsize_t old_where, hsize_t *new_where); -hsize_t compute_user_block_size (hsize_t); -hsize_t copy_some_to_file (int, int, hsize_t, hsize_t, ssize_t); -void parse_command_line (int, const char *[]); +herr_t write_pad(int ofile, hsize_t old_where, hsize_t *new_where); +hsize_t compute_user_block_size(hsize_t); +hsize_t copy_some_to_file(int, int, hsize_t, hsize_t, ssize_t); +void parse_command_line(int, const char *[]); -int do_clobber = FALSE; +int do_clobber = FALSE; char *output_file = NULL; -char *input_file = NULL; -char *ub_file = NULL; +char *input_file = NULL; +char *ub_file = NULL; /* * Command-line options: The user can specify short or long-named * parameters. The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -static const char *s_opts = "hi:u:o:c:V"; /* add more later ? */ +static const char * s_opts = "hi:u:o:c:V"; /* add more later ? */ static struct long_options l_opts[] = { - {"help", no_arg, 'h'}, - {"hel", no_arg, 'h'}, - {"i", require_arg, 'i'}, /* input file */ - {"u", require_arg, 'u'}, /* user block file */ - {"o", require_arg, 'o'}, /* output file */ - {"clobber", no_arg, 'c'}, /* clobber existing UB */ - {"clobbe", no_arg, 'c'}, - {"clobb", no_arg, 'c'}, - {"clob", no_arg, 'c'}, - {"clo", no_arg, 'c'}, - {"cl", no_arg, 'c'}, - {NULL, 0, '\0'} -}; + {"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, {"i", require_arg, 'i'}, /* input file */ + {"u", require_arg, 'u'}, /* user block file */ + {"o", require_arg, 'o'}, /* output file */ + {"clobber", no_arg, 'c'}, /* clobber existing UB */ + {"clobbe", no_arg, 'c'}, {"clobb", no_arg, 'c'}, {"clob", no_arg, 'c'}, + {"clo", no_arg, 'c'}, {"cl", no_arg, 'c'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -59,56 +52,35 @@ static struct long_options l_opts[] = { *------------------------------------------------------------------------- */ static void -usage (const char *prog) +usage(const char *prog) { - HDfflush (stdout); - HDfprintf (stdout, - "usage: %s -i -u [-o ] [--clobber]\n", prog); - HDfprintf (stdout, "\n"); - HDfprintf (stdout, - "Adds user block to front of an HDF5 file and creates a new concatenated file.\n"); - HDfprintf (stdout, "\n"); - HDfprintf (stdout, - "OPTIONS\n"); - HDfprintf (stdout, - " -i in_file.h5 Specifies the input HDF5 file.\n"); - HDfprintf (stdout, - " -u in_user_file Specifies the file to be inserted into the user block.\n"); - HDfprintf (stdout, - " Can be any file format except an HDF5 format.\n"); - HDfprintf (stdout, - " -o out_file.h5 Specifies the output HDF5 file.\n"); - HDfprintf (stdout, - " If not specified, the user block will be concatenated in\n"); - HDfprintf (stdout, - " place to the input HDF5 file.\n"); - HDfprintf (stdout, - " --clobber Wipes out any existing user block before concatenating\n"); - HDfprintf (stdout, - " the given user block.\n"); - HDfprintf (stdout, - " The size of the new user block will be the larger of;\n"); - HDfprintf (stdout, - " - the size of existing user block in the input HDF5 file\n"); - HDfprintf (stdout, - " - the size of user block required by new input user file\n"); - HDfprintf (stdout, - " (size = 512 x 2N, N is positive integer.)\n"); - HDfprintf (stdout, "\n"); - HDfprintf (stdout, - " -h Prints a usage message and exits.\n"); - HDfprintf (stdout, - " -V Prints the HDF5 library version and exits.\n"); - HDfprintf (stdout, "\n"); - HDfprintf (stdout, - "Exit Status:\n"); - HDfprintf (stdout, - " 0 Succeeded.\n"); - HDfprintf (stdout, - " >0 An error occurred.\n"); + HDfflush(stdout); + HDfprintf(stdout, "usage: %s -i -u [-o ] [--clobber]\n", prog); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, "Adds user block to front of an HDF5 file and creates a new concatenated file.\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, "OPTIONS\n"); + HDfprintf(stdout, " -i in_file.h5 Specifies the input HDF5 file.\n"); + HDfprintf(stdout, " -u in_user_file Specifies the file to be inserted into the user block.\n"); + HDfprintf(stdout, " Can be any file format except an HDF5 format.\n"); + HDfprintf(stdout, " -o out_file.h5 Specifies the output HDF5 file.\n"); + HDfprintf(stdout, " If not specified, the user block will be concatenated in\n"); + HDfprintf(stdout, " place to the input HDF5 file.\n"); + HDfprintf(stdout, " --clobber Wipes out any existing user block before concatenating\n"); + HDfprintf(stdout, " the given user block.\n"); + HDfprintf(stdout, " The size of the new user block will be the larger of;\n"); + HDfprintf(stdout, " - the size of existing user block in the input HDF5 file\n"); + HDfprintf(stdout, " - the size of user block required by new input user file\n"); + HDfprintf(stdout, " (size = 512 x 2N, N is positive integer.)\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " -h Prints a usage message and exits.\n"); + HDfprintf(stdout, " -V Prints the HDF5 library version and exits.\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, "Exit Status:\n"); + HDfprintf(stdout, " 0 Succeeded.\n"); + HDfprintf(stdout, " >0 An error occurred.\n"); } - /*------------------------------------------------------------------------- * Function: leave * @@ -136,40 +108,38 @@ leave(int ret) */ void -parse_command_line (int argc, const char *argv[]) +parse_command_line(int argc, const char *argv[]) { - int opt = FALSE; - - /* parse command line options */ - while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) - { - switch ((char) opt) - { - case 'o': - output_file = HDstrdup (opt_arg); - break; - case 'i': - input_file = HDstrdup (opt_arg); - break; - case 'u': - ub_file = HDstrdup (opt_arg); - break; - case 'c': - do_clobber = TRUE; - break; - case 'h': - usage (h5tools_getprogname()); - leave (EXIT_SUCCESS); - break; - case 'V': - print_version (h5tools_getprogname()); - leave (EXIT_SUCCESS); - break; - case '?': - default: - usage (h5tools_getprogname()); - leave (EXIT_FAILURE); - } + int opt = FALSE; + + /* parse command line options */ + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { + case 'o': + output_file = HDstrdup(opt_arg); + break; + case 'i': + input_file = HDstrdup(opt_arg); + break; + case 'u': + ub_file = HDstrdup(opt_arg); + break; + case 'c': + do_clobber = TRUE; + break; + case 'h': + usage(h5tools_getprogname()); + leave(EXIT_SUCCESS); + break; + case 'V': + print_version(h5tools_getprogname()); + leave(EXIT_SUCCESS); + break; + case '?': + default: + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } } } @@ -183,24 +153,24 @@ parse_command_line (int argc, const char *argv[]) *------------------------------------------------------------------------- */ int -main (int argc, const char *argv[]) +main(int argc, const char *argv[]) { - int ufid = -1; - int h5fid = -1; - int ofid = -1; - hid_t ifile = H5I_INVALID_HID; - hid_t plist = H5I_INVALID_HID; - herr_t status; - htri_t testval; - hsize_t usize; - hsize_t h5fsize; - hsize_t startub; - hsize_t where; - hsize_t newubsize; - off_t fsize; - h5_stat_t sbuf; - h5_stat_t sbuf2; - int res; + int ufid = -1; + int h5fid = -1; + int ofid = -1; + hid_t ifile = H5I_INVALID_HID; + hid_t plist = H5I_INVALID_HID; + herr_t status; + htri_t testval; + hsize_t usize; + hsize_t h5fsize; + hsize_t startub; + hsize_t where; + hsize_t newubsize; + off_t fsize; + h5_stat_t sbuf; + h5_stat_t sbuf2; + int res; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -274,14 +244,14 @@ main (int argc, const char *argv[]) ifile = H5I_INVALID_HID; ufid = HDopen(ub_file, O_RDONLY); - if(ufid < 0) { + if (ufid < 0) { error_msg("unable to open user block file \"%s\"\n", ub_file); h5tools_setstatus(EXIT_FAILURE); goto done; } res = HDfstat(ufid, &sbuf); - if(res < 0) { + if (res < 0) { error_msg("Can't stat file \"%s\"\n", ub_file); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -290,14 +260,14 @@ main (int argc, const char *argv[]) fsize = (off_t)sbuf.st_size; h5fid = HDopen(input_file, O_RDONLY); - if(h5fid < 0) { + if (h5fid < 0) { error_msg("unable to open HDF5 file for read \"%s\"\n", input_file); h5tools_setstatus(EXIT_FAILURE); goto done; } res = HDfstat(h5fid, &sbuf2); - if(res < 0) { + if (res < 0) { error_msg("Can't stat file \"%s\"\n", input_file); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -324,7 +294,7 @@ main (int argc, const char *argv[]) } } - newubsize = compute_user_block_size((hsize_t) fsize); + newubsize = compute_user_block_size((hsize_t)fsize); startub = usize; @@ -334,53 +304,53 @@ main (int argc, const char *argv[]) if (usize > newubsize) { newubsize = usize; } - startub = 0; /*blast the old */ + startub = 0; /*blast the old */ } else { /* add new ub to current ublock, pad to new offset */ newubsize += usize; - newubsize = compute_user_block_size((hsize_t) newubsize); + newubsize = compute_user_block_size((hsize_t)newubsize); } } /* copy the HDF5 from starting at usize to starting at newubsize: * makes room at 'from' for new ub */ /* if no current ub, usize is 0 */ - copy_some_to_file(h5fid, ofid, usize, newubsize, (ssize_t) (h5fsize - usize)); + copy_some_to_file(h5fid, ofid, usize, newubsize, (ssize_t)(h5fsize - usize)); /* copy the old ub to the beginning of the new file */ if (!do_clobber) { - where = copy_some_to_file(h5fid, ofid, (hsize_t) 0, (hsize_t) 0, (ssize_t) usize); + where = copy_some_to_file(h5fid, ofid, (hsize_t)0, (hsize_t)0, (ssize_t)usize); } /* copy the new ub to the end of the ub */ - where = copy_some_to_file(ufid, ofid, (hsize_t) 0, startub, (ssize_t) - 1); + where = copy_some_to_file(ufid, ofid, (hsize_t)0, startub, (ssize_t)-1); /* pad the ub */ - if(write_pad(ofid, where, &where) < 0) { + if (write_pad(ofid, where, &where) < 0) { error_msg("Can't pad file \"%s\"\n", output_file); h5tools_setstatus(EXIT_FAILURE); goto done; } /* end if */ done: - if(ub_file) + if (ub_file) HDfree(ub_file); - if(input_file) + if (input_file) HDfree(input_file); - if(output_file) + if (output_file) HDfree(output_file); - if(plist >= 0) + if (plist >= 0) H5Pclose(plist); - if(ifile >= 0) + if (ifile >= 0) H5Fclose(ifile); - if(ufid >= 0) + if (ufid >= 0) HDclose(ufid); - if(h5fid >= 0) + if (h5fid >= 0) HDclose(h5fid); - if(ofid >= 0) + if (ofid >= 0) HDclose(ofid); leave(h5tools_getstatus()); @@ -407,29 +377,28 @@ done: *------------------------------------------------------------------------- */ hsize_t -copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, - ssize_t limit) +copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, ssize_t limit) { - char buf[1024]; + char buf[1024]; h5_stat_t sbuf; - int res; - ssize_t tot = 0; - ssize_t howmuch = 0; - ssize_t nchars = -1; - ssize_t to; - ssize_t from; - ssize_t toend; - ssize_t fromend; - - if(startin > startout) { + int res; + ssize_t tot = 0; + ssize_t howmuch = 0; + ssize_t nchars = -1; + ssize_t to; + ssize_t from; + ssize_t toend; + ssize_t fromend; + + if (startin > startout) { /* this case is prohibited */ error_msg("copy_some_to_file: panic: startin > startout?\n"); - exit (EXIT_FAILURE); + exit(EXIT_FAILURE); } /* end if */ - if(limit < 0) { + if (limit < 0) { res = HDfstat(infid, &sbuf); - if(res < 0) { + if (res < 0) { error_msg("Can't stat file \n"); HDexit(EXIT_FAILURE); } /* end if */ @@ -440,27 +409,27 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, howmuch = limit; } /* end if */ - if(0 == howmuch) + if (0 == howmuch) return 0; - toend = (ssize_t) startout + howmuch; - fromend = (ssize_t) startin + howmuch; + toend = (ssize_t)startout + howmuch; + fromend = (ssize_t)startin + howmuch; if (howmuch > 512) { - to = toend - 512; + to = toend - 512; from = fromend - 512; } else { - to = toend - howmuch; + to = toend - howmuch; from = fromend - howmuch; } /* end if */ while (howmuch > 0) { - HDlseek(outfid, (off_t) to, SEEK_SET); - HDlseek(infid, (off_t) from, SEEK_SET); + HDlseek(outfid, (off_t)to, SEEK_SET); + HDlseek(infid, (off_t)from, SEEK_SET); if (howmuch > 512) { - nchars = HDread(infid, buf, (unsigned) 512); + nchars = HDread(infid, buf, (unsigned)512); } else { nchars = HDread(infid, buf, (unsigned)howmuch); @@ -471,14 +440,14 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, HDexit(EXIT_FAILURE); } /* end if */ - if(HDwrite (outfid, buf, (unsigned) nchars) < 0) { + if (HDwrite(outfid, buf, (unsigned)nchars) < 0) { error_msg("Write error \n"); HDexit(EXIT_FAILURE); } tot += nchars; howmuch -= nchars; - if(howmuch > 512) { + if (howmuch > 512) { to -= nchars; from -= nchars; } @@ -486,12 +455,11 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, to -= howmuch; from -= howmuch; } /* end if */ - } /* end while */ + } /* end while */ return (hsize_t)tot + (hsize_t)startout; } /* end copy_some_to_file() */ - /*------------------------------------------------------------------------- * Function: compute_user_block_size * @@ -508,10 +476,10 @@ compute_user_block_size(hsize_t ublock_size) { hsize_t where = 512; - if(0 == ublock_size) + if (0 == ublock_size) return 0; - while(where < ublock_size) + while (where < ublock_size) where *= 2; return where; @@ -528,10 +496,10 @@ herr_t write_pad(int ofile, hsize_t old_where, hsize_t *new_where) { unsigned int i; - char buf[1]; - hsize_t psize; + char buf[1]; + hsize_t psize; - if(new_where == NULL) + if (new_where == NULL) return FAIL; buf[0] = '\0'; @@ -541,8 +509,8 @@ write_pad(int ofile, hsize_t old_where, hsize_t *new_where) psize = compute_user_block_size(old_where); psize -= old_where; - for(i = 0; i < psize; i++) - if(HDwrite(ofile, buf, 1) < 0) + for (i = 0; i < psize; i++) + if (HDwrite(ofile, buf, 1) < 0) return FAIL; /* Set the new size of the file. */ @@ -550,4 +518,3 @@ write_pad(int ofile, hsize_t old_where, hsize_t *new_where) return SUCCEED; } /* end write_pad() */ - diff --git a/tools/src/h5jam/h5unjam.c b/tools/src/h5jam/h5unjam.c index b48e2c1..d02cada 100644 --- a/tools/src/h5jam/h5unjam.c +++ b/tools/src/h5jam/h5unjam.c @@ -21,34 +21,28 @@ #define COPY_BUF_SIZE 1024 -hsize_t write_pad( int , hsize_t ); -hsize_t compute_pad( hsize_t ); -herr_t copy_to_file( FILE *, FILE * , ssize_t, ssize_t ); +hsize_t write_pad(int, hsize_t); +hsize_t compute_pad(hsize_t); +herr_t copy_to_file(FILE *, FILE *, ssize_t, ssize_t); -int do_delete = FALSE; +int do_delete = FALSE; char *output_file = NULL; -char *input_file = NULL; -char *ub_file = NULL; +char *input_file = NULL; +char *ub_file = NULL; /* * Command-line options: The user can specify short or long-named * parameters. The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -static const char *s_opts = "hu:i:o:d:V"; +static const char * s_opts = "hu:i:o:d:V"; static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - {"i", require_arg, 'i'}, /* input file */ - {"u", require_arg, 'u'}, /* user block file */ - {"o", require_arg, 'o'}, /* output file */ - {"delete", no_arg, 'd'}, /* delete ub */ - {"delet", no_arg, 'd'}, - {"dele", no_arg, 'd'}, - {"del", no_arg, 'd'}, - {"de", no_arg, 'd'}, - { NULL, 0, '\0' } -}; + {"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, {"i", require_arg, 'i'}, /* input file */ + {"u", require_arg, 'u'}, /* user block file */ + {"o", require_arg, 'o'}, /* output file */ + {"delete", no_arg, 'd'}, /* delete ub */ + {"delet", no_arg, 'd'}, {"dele", no_arg, 'd'}, {"del", no_arg, 'd'}, + {"de", no_arg, 'd'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -62,55 +56,34 @@ static void usage(const char *prog) { HDfflush(stdout); - HDfprintf(stdout, - "usage: %s -i [-o ] [-u | --delete]\n", prog); + HDfprintf(stdout, "usage: %s -i [-o ] [-u | --delete]\n", + prog); HDfprintf(stdout, "\n"); - HDfprintf(stdout, - "Splits user file and HDF5 file into two files: user block data and HDF5 data.\n"); + HDfprintf(stdout, "Splits user file and HDF5 file into two files: user block data and HDF5 data.\n"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, - "OPTIONS\n"); - HDfprintf(stdout, - " -i in_file.h5 Specifies the HDF5 as input. If the input HDF5 file\n"); - HDfprintf(stdout, - " contains no user block, exit with an error message.\n"); - HDfprintf(stdout, - " -o out_file.h5 Specifies output HDF5 file without a user block.\n"); - HDfprintf(stdout, - " If not specified, the user block will be removed from the\n"); - HDfprintf(stdout, - " input HDF5 file.\n"); - HDfprintf(stdout, - " -u out_user_file\n"); - HDfprintf(stdout, - " Specifies the output file containing the data from the\n"); - HDfprintf(stdout, - " user block.\n"); - HDfprintf(stdout, - " Cannot be used with --delete option.\n"); - HDfprintf(stdout, - " --delete Remove the user block from the input HDF5 file. The content\n"); - HDfprintf(stdout, - " of the user block is discarded.\n"); - HDfprintf(stdout, - " Cannot be used with the -u option.\n"); + HDfprintf(stdout, "OPTIONS\n"); + HDfprintf(stdout, " -i in_file.h5 Specifies the HDF5 as input. If the input HDF5 file\n"); + HDfprintf(stdout, " contains no user block, exit with an error message.\n"); + HDfprintf(stdout, " -o out_file.h5 Specifies output HDF5 file without a user block.\n"); + HDfprintf(stdout, " If not specified, the user block will be removed from the\n"); + HDfprintf(stdout, " input HDF5 file.\n"); + HDfprintf(stdout, " -u out_user_file\n"); + HDfprintf(stdout, " Specifies the output file containing the data from the\n"); + HDfprintf(stdout, " user block.\n"); + HDfprintf(stdout, " Cannot be used with --delete option.\n"); + HDfprintf(stdout, " --delete Remove the user block from the input HDF5 file. The content\n"); + HDfprintf(stdout, " of the user block is discarded.\n"); + HDfprintf(stdout, " Cannot be used with the -u option.\n"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, - " -h Prints a usage message and exits.\n"); - HDfprintf(stdout, - " -V Prints the HDF5 library version and exits.\n"); + HDfprintf(stdout, " -h Prints a usage message and exits.\n"); + HDfprintf(stdout, " -V Prints the HDF5 library version and exits.\n"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, - " If neither --delete nor -u is specified, the user block from the input file\n"); - HDfprintf(stdout, - " will be displayed to stdout.\n"); + HDfprintf(stdout, " If neither --delete nor -u is specified, the user block from the input file\n"); + HDfprintf(stdout, " will be displayed to stdout.\n"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, - "Exit Status:\n"); - HDfprintf(stdout, - " 0 Succeeded.\n"); - HDfprintf(stdout, - " >0 An error occurred.\n"); + HDfprintf(stdout, "Exit Status:\n"); + HDfprintf(stdout, " 0 Succeeded.\n"); + HDfprintf(stdout, " >0 An error occurred.\n"); } /*------------------------------------------------------------------------- @@ -127,9 +100,9 @@ parse_command_line(int argc, const char *argv[]) { int opt = FALSE; - /* parse command line options */ + /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char)opt) { + switch ((char)opt) { case 'o': output_file = HDstrdup(opt_arg); if (output_file) @@ -140,7 +113,8 @@ parse_command_line(int argc, const char *argv[]) input_file = HDstrdup(opt_arg); if (input_file) h5tools_set_input_file(input_file, 1); - break;; + break; + ; case 'u': ub_file = HDstrdup(opt_arg); @@ -160,7 +134,7 @@ parse_command_line(int argc, const char *argv[]) goto done; case 'V': - print_version (h5tools_getprogname()); + print_version(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); goto done; @@ -175,11 +149,11 @@ parse_command_line(int argc, const char *argv[]) return EXIT_SUCCESS; done: - if(input_file) + if (input_file) HDfree(input_file); - if(output_file) + if (output_file) HDfree(output_file); - if(ub_file) + if (ub_file) HDfree(ub_file); return EXIT_FAILURE; @@ -188,8 +162,8 @@ done: static void leave(int ret) { - h5tools_close(); - HDexit(ret); + h5tools_close(); + HDexit(ret); } /*------------------------------------------------------------------------- @@ -204,14 +178,14 @@ leave(int ret) int main(int argc, const char *argv[]) { - hid_t ifile = H5I_INVALID_HID; - hid_t plist = H5I_INVALID_HID; - off_t fsize; - hsize_t usize; - htri_t testval; - herr_t status; - int res; - h5_stat_t sbuf; + hid_t ifile = H5I_INVALID_HID; + hid_t plist = H5I_INVALID_HID; + off_t fsize; + hsize_t usize; + htri_t testval; + herr_t status; + int res; + h5_stat_t sbuf; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -219,7 +193,7 @@ main(int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - if(EXIT_FAILURE == parse_command_line(argc, argv)) + if (EXIT_FAILURE == parse_command_line(argc, argv)) goto done; /* enable error reporting if command line option */ @@ -237,12 +211,12 @@ main(int argc, const char *argv[]) if (testval <= 0) { error_msg("Input HDF5 file \"%s\" is not HDF\n", input_file); - help_ref_msg (stderr); + help_ref_msg(stderr); h5tools_setstatus(EXIT_FAILURE); goto done; } - ifile = H5Fopen(input_file, H5F_ACC_RDONLY , H5P_DEFAULT); + ifile = H5Fopen(input_file, H5F_ACC_RDONLY, H5P_DEFAULT); if (ifile < 0) { error_msg("Can't open input HDF5 file \"%s\"\n", input_file); @@ -257,7 +231,7 @@ main(int argc, const char *argv[]) goto done; } - status = H5Pget_userblock(plist, & usize); + status = H5Pget_userblock(plist, &usize); if (status < 0) { error_msg("Can't get user block for file \"%s\"\n", input_file); h5tools_setstatus(EXIT_FAILURE); @@ -268,14 +242,14 @@ main(int argc, const char *argv[]) H5Fclose(ifile); if (usize == 0) { - /* no user block to remove: message? */ + /* no user block to remove: message? */ error_msg("\"%s\" has no user block: no change to file\n", input_file); h5tools_setstatus(EXIT_SUCCESS); goto done; } res = HDfstat(HDfileno(rawinstream), &sbuf); - if(res < 0) { + if (res < 0) { error_msg("Can't stat file \"%s\"\n", input_file); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -290,14 +264,14 @@ main(int argc, const char *argv[]) } if (output_file == NULL) { - error_msg("unable to open output HDF5 file \"%s\"\n", input_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; + error_msg("unable to open output HDF5 file \"%s\"\n", input_file); + h5tools_setstatus(EXIT_FAILURE); + goto done; } /* copy from 0 to 'usize - 1' into ufid */ if (!do_delete) { - if(copy_to_file(rawinstream, rawoutstream, 0, (ssize_t) usize) < 0) { + if (copy_to_file(rawinstream, rawoutstream, 0, (ssize_t)usize) < 0) { error_msg("unable to copy user block to output file \"%s\"\n", ub_file); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -306,20 +280,20 @@ main(int argc, const char *argv[]) /* copy from usize to end of file into h5fid, * starting at end of user block if present */ - if(copy_to_file(rawinstream, rawdatastream, (ssize_t) usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) { + if (copy_to_file(rawinstream, rawdatastream, (ssize_t)usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) { error_msg("unable to copy hdf5 data to output file \"%s\"\n", output_file); h5tools_setstatus(EXIT_FAILURE); goto done; } done: - if(input_file) + if (input_file) HDfree(input_file); - if(output_file) + if (output_file) HDfree(output_file); - if(ub_file) { + if (ub_file) { HDfree(ub_file); } @@ -334,17 +308,17 @@ done: *------------------------------------------------------------------------- */ herr_t -copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much ) +copy_to_file(FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much) { static char buf[COPY_BUF_SIZE]; - size_t how_much; - off_t where = (off_t)_where; - off_t to; - off_t from; - herr_t ret_value = 0; + size_t how_much; + off_t where = (off_t)_where; + off_t to; + off_t from; + herr_t ret_value = 0; /* nothing to copy */ - if(show_much <= 0) + if (show_much <= 0) goto done; how_much = (size_t)show_much; @@ -352,27 +326,27 @@ copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much ) HDfseek(infid, 0L, 0); from = where; - to = 0; - while(how_much > 0) { - size_t bytes_in = 0; /* # of bytes to read */ - size_t bytes_read = 0; /* # of bytes actually read */ - size_t bytes_wrote = 0; /* # of bytes written */ + to = 0; + while (how_much > 0) { + size_t bytes_in = 0; /* # of bytes to read */ + size_t bytes_read = 0; /* # of bytes actually read */ + size_t bytes_wrote = 0; /* # of bytes written */ if (how_much > COPY_BUF_SIZE) bytes_in = COPY_BUF_SIZE; else bytes_in = how_much; - /* Seek to correct position in input file */ + /* Seek to correct position in input file */ HDfseek(infid, from, SEEK_SET); /* Read data to buffer */ bytes_read = HDfread(buf, (size_t)1, bytes_in, infid); - if(0 == bytes_read && HDferror(infid)) { + if (0 == bytes_read && HDferror(infid)) { ret_value = -1; goto done; } /* end if */ - if(0 == bytes_read && HDfeof(infid)) { + if (0 == bytes_read && HDfeof(infid)) { goto done; } /* end if */ @@ -384,15 +358,14 @@ copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much ) from += (off_t)bytes_read; to += (off_t)bytes_read; - /* Write nchars bytes to output file */ + /* Write nchars bytes to output file */ bytes_wrote = HDfwrite(buf, (size_t)1, bytes_read, ofid); - if(bytes_wrote != bytes_read || (0 == bytes_wrote && HDferror(ofid))) { /* error */ + if (bytes_wrote != bytes_read || (0 == bytes_wrote && HDferror(ofid))) { /* error */ ret_value = -1; goto done; } /* end if */ - } /* end while */ + } /* end while */ done: return ret_value; -} /* end copy_to_file */ - +} /* end copy_to_file */ diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index 2b16db9..75f5096 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -16,7 +16,6 @@ * Monday, March 23, 1998 */ - /* * We include the private header file so we can get to the uniform * programming environment it declares. Other than that, h5ls only calls @@ -31,112 +30,113 @@ /* Name of tool */ #define PROGRAMNAME "h5ls" -#define NAME_BUF_SIZE 2048 +#define NAME_BUF_SIZE 2048 /* * Alternative formating for data dumped by H5LS * * This table only affects H5LS output. */ -static h5tool_format_t ls_dataformat = { - 0, /*raw */ - - "", /*fmt_raw */ - "%d", /*fmt_int */ - "%u", /*fmt_uint */ - "%hhd", /*fmt_schar */ - "%u", /*fmt_uchar */ - "%d", /*fmt_short */ - "%u", /*fmt_ushort */ - "%ld", /*fmt_long */ - "%lu", /*fmt_ulong */ - NULL, /*fmt_llong */ - NULL, /*fmt_ullong */ - "%g", /*fmt_double */ - "%g", /*fmt_float */ - - 0, /*ascii */ - 0, /*str_locale */ - 0, /*str_repeat */ - - "[", /*arr_pre */ - ",", /*arr_sep */ - "]", /*arr_suf */ - 1, /*arr_linebreak */ - - "", /*cmpd_name */ - ",", /*cmpd_sep */ - "{", /*cmpd_pre */ - "}", /*cmpd_suf */ - "", /*cmpd_end */ - NULL, /* cmpd_listv */ - - ",", /*vlen_sep */ - "(", /*vlen_pre */ - ")", /*vlen_suf */ - "", /*vlen_end */ - - "%s", /*elmt_fmt */ - ",", /*elmt_suf1 */ - " ", /*elmt_suf2 */ - - HSIZE_T_FORMAT, /*idx_n_fmt */ - ",", /*idx_sep */ - "(%s)", /*idx_fmt */ - - 65535, /*line_ncols *//*standard default columns */ - 0, /*line_per_line */ - "", /*line_pre */ - "%s", /*line_1st */ - "%s", /*line_cont */ - "", /*line_suf */ - "", /*line_sep */ - 1, /*line_multi_new */ - " ", /*line_indent */ - - 0, /*skip_first */ - - 0, /*obj_hidefileno */ - "-%lu:%" PRIuHADDR, /*obj_format */ - - 0, /*dset_hidefileno */ - "DSET-%s ", /*dset_format */ - "%sBlk%lu: ", /*dset_blockformat_pre */ - "%sPt%lu: ", /*dset_ptformat_pre */ - "%s", /*dset_ptformat */ - 1, /*array indices */ - 1 /*escape non printable characters */ +static h5tool_format_t ls_dataformat = { + 0, /*raw */ + + "", /*fmt_raw */ + "%d", /*fmt_int */ + "%u", /*fmt_uint */ + "%hhd", /*fmt_schar */ + "%u", /*fmt_uchar */ + "%d", /*fmt_short */ + "%u", /*fmt_ushort */ + "%ld", /*fmt_long */ + "%lu", /*fmt_ulong */ + NULL, /*fmt_llong */ + NULL, /*fmt_ullong */ + "%g", /*fmt_double */ + "%g", /*fmt_float */ + + 0, /*ascii */ + 0, /*str_locale */ + 0, /*str_repeat */ + + "[", /*arr_pre */ + ",", /*arr_sep */ + "]", /*arr_suf */ + 1, /*arr_linebreak */ + + "", /*cmpd_name */ + ",", /*cmpd_sep */ + "{", /*cmpd_pre */ + "}", /*cmpd_suf */ + "", /*cmpd_end */ + NULL, /* cmpd_listv */ + + ",", /*vlen_sep */ + "(", /*vlen_pre */ + ")", /*vlen_suf */ + "", /*vlen_end */ + + "%s", /*elmt_fmt */ + ",", /*elmt_suf1 */ + " ", /*elmt_suf2 */ + + HSIZE_T_FORMAT, /*idx_n_fmt */ + ",", /*idx_sep */ + "(%s)", /*idx_fmt */ + + 65535, + /*line_ncols */ /*standard default columns */ + 0, /*line_per_line */ + "", /*line_pre */ + "%s", /*line_1st */ + "%s", /*line_cont */ + "", /*line_suf */ + "", /*line_sep */ + 1, /*line_multi_new */ + " ", /*line_indent */ + + 0, /*skip_first */ + + 0, /*obj_hidefileno */ + "-%lu:%" PRIuHADDR, /*obj_format */ + + 0, /*dset_hidefileno */ + "DSET-%s ", /*dset_format */ + "%sBlk%lu: ", /*dset_blockformat_pre */ + "%sPt%lu: ", /*dset_ptformat_pre */ + "%s", /*dset_ptformat */ + 1, /*array indices */ + 1 /*escape non printable characters */ }; /* Struct to pass through to visitors */ typedef struct { - const char *fname; /* Filename */ - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ - hbool_t symlink_target; /* Whether this is the target of an symbolic link */ - symlink_trav_t *symlink_list; /* List of visited symbolic links */ - size_t base_len; /* Length of base path name, if not root */ - size_t name_start; /* # of leading characters to strip off path names on output */ -}iter_t; + const char * fname; /* Filename */ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hbool_t symlink_target; /* Whether this is the target of an symbolic link */ + symlink_trav_t *symlink_list; /* List of visited symbolic links */ + size_t base_len; /* Length of base path name, if not root */ + size_t name_start; /* # of leading characters to strip off path names on output */ +} iter_t; /* Command-line switches */ -static int verbose_g = 0; /* lots of extra output */ -static int width_g = 80; /* output width in characters */ -static hbool_t vfd_swmr_poll_g = FALSE; /* poll for changes using VFD SWMR */ -static hbool_t address_g = FALSE; /* print raw data addresses */ -static hbool_t data_g = FALSE; /* display dataset values? */ -static hbool_t label_g = FALSE; /* label compound values? */ -static hbool_t string_g = FALSE; /* print 1-byte numbers as ASCII? */ -static hbool_t fullname_g = FALSE; /* print full path names */ -static hbool_t recursive_g = FALSE; /* recursive descent listing */ -static hbool_t follow_symlink_g = FALSE; /* follow symbolic links */ -static hbool_t no_dangling_link_g = FALSE; /* treat dangling link is error */ -static hbool_t follow_elink_g = FALSE; /* follow external links */ -static hbool_t grp_literal_g = FALSE; /* list group, not contents */ -static hbool_t hexdump_g = FALSE; /* show data as raw hexadecimal */ -static hbool_t simple_output_g = FALSE; /* make output more machine-readable */ -static hbool_t show_file_name_g = FALSE; /* show file name for full names */ -static hbool_t no_line_wrap_g = FALSE; /* show data content without line wrap */ -static hbool_t display_root_g = FALSE; /* show root group in output? */ +static int verbose_g = 0; /* lots of extra output */ +static int width_g = 80; /* output width in characters */ +static hbool_t vfd_swmr_poll_g = FALSE; /* poll for changes using VFD SWMR */ +static hbool_t address_g = FALSE; /* print raw data addresses */ +static hbool_t data_g = FALSE; /* display dataset values? */ +static hbool_t label_g = FALSE; /* label compound values? */ +static hbool_t string_g = FALSE; /* print 1-byte numbers as ASCII? */ +static hbool_t fullname_g = FALSE; /* print full path names */ +static hbool_t recursive_g = FALSE; /* recursive descent listing */ +static hbool_t follow_symlink_g = FALSE; /* follow symbolic links */ +static hbool_t no_dangling_link_g = FALSE; /* treat dangling link is error */ +static hbool_t follow_elink_g = FALSE; /* follow external links */ +static hbool_t grp_literal_g = FALSE; /* list group, not contents */ +static hbool_t hexdump_g = FALSE; /* show data as raw hexadecimal */ +static hbool_t simple_output_g = FALSE; /* make output more machine-readable */ +static hbool_t show_file_name_g = FALSE; /* show file name for full names */ +static hbool_t no_line_wrap_g = FALSE; /* show data content without line wrap */ +static hbool_t display_root_g = FALSE; /* show root group in output? */ /* Information about how to display each type of object */ static struct dispatch_t { @@ -147,17 +147,17 @@ static struct dispatch_t { herr_t (*list2)(hid_t obj, const char *name); } dispatch_g[H5O_TYPE_NTYPES]; -#define DISPATCH(TYPE, NAME, LIST1, LIST2) { \ - dispatch_g[TYPE].name = (NAME); \ - dispatch_g[TYPE].list1 = (LIST1); \ - dispatch_g[TYPE].list2 = (LIST2); \ -} +#define DISPATCH(TYPE, NAME, LIST1, LIST2) \ + { \ + dispatch_g[TYPE].name = (NAME); \ + dispatch_g[TYPE].list1 = (LIST1); \ + dispatch_g[TYPE].list2 = (LIST2); \ + } -static void print_type(h5tools_str_t *buffer, hid_t type, int ind); +static void print_type(h5tools_str_t *buffer, hid_t type, int ind); static hbool_t print_int_type(h5tools_str_t *buffer, hid_t type, int ind); static hbool_t print_float_type(h5tools_str_t *buffer, hid_t type, int ind); -static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter); - +static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter); /*------------------------------------------------------------------------- * Function: usage @@ -168,42 +168,53 @@ static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter); *------------------------------------------------------------------------- */ static void -usage (void) +usage(void) { FLUSHSTREAM(rawoutstream); PRINTVALSTREAM(rawoutstream, "usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...]\n"); PRINTVALSTREAM(rawoutstream, " h5ls [OPTIONS] --poll file\n"); PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); PRINTVALSTREAM(rawoutstream, " -h, -?, --help Print a usage message and exit\n"); - PRINTVALSTREAM(rawoutstream, " -a, --address Print raw data address. If dataset is contiguous, address\n"); - PRINTVALSTREAM(rawoutstream, " is offset in file of beginning of raw data. If chunked,\n"); - PRINTVALSTREAM(rawoutstream, " returned list of addresses indicates offset of each chunk.\n"); + PRINTVALSTREAM(rawoutstream, + " -a, --address Print raw data address. If dataset is contiguous, address\n"); + PRINTVALSTREAM(rawoutstream, + " is offset in file of beginning of raw data. If chunked,\n"); + PRINTVALSTREAM(rawoutstream, + " returned list of addresses indicates offset of each chunk.\n"); PRINTVALSTREAM(rawoutstream, " Must be used with -v, --verbose option.\n"); PRINTVALSTREAM(rawoutstream, " Provides no information for non-dataset objects.\n"); PRINTVALSTREAM(rawoutstream, " -d, --data Print the values of datasets\n"); PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n"); - PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n"); + PRINTVALSTREAM(rawoutstream, + " Prints messages from the HDF5 error stack as they occur.\n"); PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n"); - PRINTVALSTREAM(rawoutstream, " Follow symbolic links (soft links and external links)\n"); + PRINTVALSTREAM(rawoutstream, + " Follow symbolic links (soft links and external links)\n"); PRINTVALSTREAM(rawoutstream, " to display target object information.\n"); PRINTVALSTREAM(rawoutstream, " Without this option, h5ls identifies a symbolic link\n"); PRINTVALSTREAM(rawoutstream, " as a soft link or external link and prints the value\n"); - PRINTVALSTREAM(rawoutstream, " assigned to the symbolic link; it does not provide any\n"); + PRINTVALSTREAM(rawoutstream, + " assigned to the symbolic link; it does not provide any\n"); PRINTVALSTREAM(rawoutstream, " information regarding the target object or determine\n"); PRINTVALSTREAM(rawoutstream, " whether the link is a dangling link.\n"); PRINTVALSTREAM(rawoutstream, " --no-dangling-links\n"); PRINTVALSTREAM(rawoutstream, " Must be used with --follow-symlinks option;\n"); - PRINTVALSTREAM(rawoutstream, " otherwise, h5ls shows error message and returns an exit\n"); + PRINTVALSTREAM(rawoutstream, + " otherwise, h5ls shows error message and returns an exit\n"); PRINTVALSTREAM(rawoutstream, " code of 1.\n"); - PRINTVALSTREAM(rawoutstream, " Check for any symbolic links (soft links or external links)\n"); - PRINTVALSTREAM(rawoutstream, " that do not resolve to an existing object (dataset, group,\n"); + PRINTVALSTREAM(rawoutstream, + " Check for any symbolic links (soft links or external links)\n"); + PRINTVALSTREAM(rawoutstream, + " that do not resolve to an existing object (dataset, group,\n"); PRINTVALSTREAM(rawoutstream, " or named datatype).\n"); - PRINTVALSTREAM(rawoutstream, " If any dangling link is found, this situation is treated\n"); + PRINTVALSTREAM(rawoutstream, + " If any dangling link is found, this situation is treated\n"); PRINTVALSTREAM(rawoutstream, " as an error and h5ls returns an exit code of 1.\n"); PRINTVALSTREAM(rawoutstream, " -f, --full Print full path names instead of base names\n"); PRINTVALSTREAM(rawoutstream, " -g, --group Show information about a group, not its contents\n"); PRINTVALSTREAM(rawoutstream, " -l, --label Label members of compound datasets\n"); - PRINTVALSTREAM(rawoutstream, " -p, --poll Continuously re-read and re-display the input file using VFD SWMR\n"); + PRINTVALSTREAM(rawoutstream, + " -p, --poll Continuously re-read and re-display the input file using VFD SWMR\n"); PRINTVALSTREAM(rawoutstream, " -r, --recursive List all groups recursively, avoiding cycles\n"); PRINTVALSTREAM(rawoutstream, " -s, --string Print 1-byte integer datasets as ASCII\n"); PRINTVALSTREAM(rawoutstream, " -S, --simple Use a machine-readable output format\n"); @@ -212,20 +223,26 @@ usage (void) PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " --vfd=DRIVER Use the specified virtual file driver\n"); PRINTVALSTREAM(rawoutstream, " -x, --hexdump Show raw data in hexadecimal format\n"); - PRINTVALSTREAM(rawoutstream, " --s3-cred=C Supply S3 authentication information to \"ros3\" vfd.\n"); - PRINTVALSTREAM(rawoutstream, " Accepts tuple of \"(,,)\".\n"); - PRINTVALSTREAM(rawoutstream, " If absent or C->\"(,,)\", defaults to no-authentication.\n"); + PRINTVALSTREAM(rawoutstream, + " --s3-cred=C Supply S3 authentication information to \"ros3\" vfd.\n"); + PRINTVALSTREAM(rawoutstream, + " Accepts tuple of \"(,,)\".\n"); + PRINTVALSTREAM(rawoutstream, + " If absent or C->\"(,,)\", defaults to no-authentication.\n"); PRINTVALSTREAM(rawoutstream, " Has no effect if vfd flag not set to \"ros3\".\n"); PRINTVALSTREAM(rawoutstream, " --hdfs-attrs=A Supply configuration information to Hadoop VFD.\n"); PRINTVALSTREAM(rawoutstream, " Accepts tuple of (,,\n"); PRINTVALSTREAM(rawoutstream, " ...,,)\n"); - PRINTVALSTREAM(rawoutstream, " If absent or A == '(,,,,)', all default values are used.\n"); + PRINTVALSTREAM(rawoutstream, + " If absent or A == '(,,,,)', all default values are used.\n"); PRINTVALSTREAM(rawoutstream, " Has no effect if vfd flag is not 'hdfs'.\n"); - PRINTVALSTREAM(rawoutstream, " --vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-value Value (ID) of the VOL connector to use for opening the\n"); PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, " --vol-name Name of the VOL connector to use for opening the\n"); PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " file/OBJECT\n"); @@ -236,7 +253,8 @@ usage (void) PRINTVALSTREAM(rawoutstream, " \"%%05d\" to open a file family.\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " Deprecated Options\n"); - PRINTVALSTREAM(rawoutstream, " The following options have been removed in HDF5 1.12. Use the indicated\n"); + PRINTVALSTREAM(rawoutstream, + " The following options have been removed in HDF5 1.12. Use the indicated\n"); PRINTVALSTREAM(rawoutstream, " replacement option in all work.\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " -E or --external Follow external links.\n"); @@ -245,7 +263,6 @@ usage (void) PRINTVALSTREAM(rawoutstream, " Replaced by --enable-error-stack.\n"); } - /*------------------------------------------------------------------------- * Function: print_string * @@ -258,7 +275,7 @@ usage (void) static int print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces) { - int nprint=0; + int nprint = 0; for (/*void*/; s && *s; s++) { switch (*s) { @@ -317,7 +334,7 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces) } else { if (buffer) - h5tools_str_append(buffer, "\\%03o", *((const unsigned char*)s)); + h5tools_str_append(buffer, "\\%03o", *((const unsigned char *)s)); nprint += 4; } break; @@ -326,7 +343,6 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces) return nprint; } - /*------------------------------------------------------------------------- * Function: print_obj_name * @@ -339,9 +355,9 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces) static int print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname, const char *s) { - static char fullname[NAME_BUF_SIZE]; /* Buffer for file and/or object name */ - const char *name = fullname; /* Pointer to buffer for printing */ - int n; + static char fullname[NAME_BUF_SIZE]; /* Buffer for file and/or object name */ + const char *name = fullname; /* Pointer to buffer for printing */ + int n; if (show_file_name_g) HDsnprintf(fullname, sizeof(fullname), "%s/%s", iter->fname, oname + iter->name_start); @@ -352,7 +368,7 @@ print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname, con if (fullname_g) n = print_string(buffer, name, TRUE); else { - const char *last_sep; /* The location of the last group separator */ + const char *last_sep; /* The location of the last group separator */ /* Find the last component of the path name */ if (NULL == (last_sep = HDstrrchr(name, '/'))) @@ -367,7 +383,6 @@ print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname, con return TRUE; } - /*------------------------------------------------------------------------- * Function: print_native_type * @@ -417,7 +432,7 @@ print_native_type(h5tools_str_t *buffer, hid_t type, int ind) else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) { h5tools_str_append(buffer, "native double"); } -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) { h5tools_str_append(buffer, "native long double"); } @@ -528,7 +543,6 @@ print_native_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - /*------------------------------------------------------------------------- * Function: print_ieee_type * @@ -559,7 +573,6 @@ print_ieee_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - /*------------------------------------------------------------------------- * Function: print_precision * @@ -573,22 +586,22 @@ print_ieee_type(h5tools_str_t *buffer, hid_t type, int ind) static void print_precision(h5tools_str_t *buffer, hid_t type, int ind) { - size_t prec; /* precision */ - H5T_pad_t plsb, pmsb; /* lsb and msb padding */ - const char *plsb_s=NULL; /* lsb padding string */ - const char *pmsb_s=NULL; /* msb padding string */ - size_t nbits; /* number of bits */ + size_t prec; /* precision */ + H5T_pad_t plsb, pmsb; /* lsb and msb padding */ + const char *plsb_s = NULL; /* lsb padding string */ + const char *pmsb_s = NULL; /* msb padding string */ + size_t nbits; /* number of bits */ /* If the precision is less than the total size then show the precision * and offset on the following line. Also display the padding * information. */ if (8 * H5Tget_size(type) != (prec = H5Tget_precision(type))) { - h5tools_str_append(buffer, "\n%*s(%lu bit%s of precision beginning at bit %lu)", - ind, "", (unsigned long)prec, 1 == prec ? "" : "s", (unsigned long)H5Tget_offset(type)); + h5tools_str_append(buffer, "\n%*s(%lu bit%s of precision beginning at bit %lu)", ind, "", + (unsigned long)prec, 1 == prec ? "" : "s", (unsigned long)H5Tget_offset(type)); H5Tget_pad(type, &plsb, &pmsb); if (H5Tget_offset(type) > 0) { - switch(plsb) { + switch (plsb) { case H5T_PAD_ZERO: plsb_s = "zero"; break; @@ -607,7 +620,7 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind) } } if ((unsigned)H5Tget_offset(type) + prec < 8 * H5Tget_size(type)) { - switch(pmsb) { + switch (pmsb) { case H5T_PAD_ZERO: pmsb_s = "zero"; break; @@ -629,20 +642,21 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind) h5tools_str_append(buffer, "\n%*s(", ind, ""); if (plsb_s) { nbits = (unsigned)H5Tget_offset(type); - h5tools_str_append(buffer, "%lu %s bit%s at bit 0", (unsigned long)nbits, plsb_s, 1 == nbits ? "" : "s"); + h5tools_str_append(buffer, "%lu %s bit%s at bit 0", (unsigned long)nbits, plsb_s, + 1 == nbits ? "" : "s"); } if (plsb_s && pmsb_s) h5tools_str_append(buffer, ", "); if (pmsb_s) { nbits = (8 * H5Tget_size(type)) - ((unsigned)H5Tget_offset(type) + prec); - h5tools_str_append(buffer, "%lu %s bit%s at bit %lu", (unsigned long)nbits, pmsb_s, 1 == nbits ? "" : "s", (unsigned long)(8 * H5Tget_size(type) - nbits)); + h5tools_str_append(buffer, "%lu %s bit%s at bit %lu", (unsigned long)nbits, pmsb_s, + 1 == nbits ? "" : "s", (unsigned long)(8 * H5Tget_size(type) - nbits)); } h5tools_str_append(buffer, ")"); } } } - /*------------------------------------------------------------------------- * Function: print_int_type * @@ -658,10 +672,10 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind) static hbool_t print_int_type(h5tools_str_t *buffer, hid_t type, int ind) { - H5T_order_t order; /* byte order value */ - const char *order_s = NULL; /* byte order string */ - H5T_sign_t sign; /* sign scheme value */ - const char *sign_s = NULL; /* sign scheme string */ + H5T_order_t order; /* byte order value */ + const char *order_s = NULL; /* byte order string */ + H5T_sign_t sign; /* sign scheme value */ + const char *sign_s = NULL; /* sign scheme string */ if (H5T_INTEGER != H5Tget_class(type)) return FALSE; @@ -704,12 +718,12 @@ print_int_type(h5tools_str_t *buffer, hid_t type, int ind) /* Print size, order, and sign on first line, precision and padding * information on the subsequent lines */ - h5tools_str_append(buffer, "%lu-bit%s%s integer", (unsigned long)(8*H5Tget_size(type)), order_s, sign_s); + h5tools_str_append(buffer, "%lu-bit%s%s integer", (unsigned long)(8 * H5Tget_size(type)), order_s, + sign_s); print_precision(buffer, type, ind); return TRUE; } - /*------------------------------------------------------------------------- * Function: print_float_type * @@ -723,15 +737,15 @@ static hbool_t print_float_type(h5tools_str_t *buffer, hid_t type, int ind) { H5T_order_t order; /* byte order value */ - const char *order_s=NULL; /* byte order string */ + const char *order_s = NULL; /* byte order string */ size_t spos; /* sign bit position */ size_t esize, epos; /* exponent size and position */ size_t msize, mpos; /* significand size and position */ size_t ebias; /* exponent bias */ H5T_norm_t norm; /* significand normalization */ - const char *norm_s=NULL; /* normalization string */ + const char *norm_s = NULL; /* normalization string */ H5T_pad_t pad; /* internal padding value */ - const char *pad_s=NULL; /* internal padding string */ + const char *pad_s = NULL; /* internal padding string */ if (H5T_FLOAT != H5Tget_class(type)) return FALSE; @@ -758,13 +772,13 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind) /* Print size and byte order on first line, precision and padding on * subsequent lines. */ - h5tools_str_append(buffer, "%lu-bit%s floating-point", (unsigned long)(8*H5Tget_size(type)), order_s); + h5tools_str_append(buffer, "%lu-bit%s floating-point", (unsigned long)(8 * H5Tget_size(type)), order_s); print_precision(buffer, type, ind); /* Print sizes, locations, and other information about each field */ - H5Tget_fields (type, &spos, &epos, &esize, &mpos, &msize); + H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize); ebias = H5Tget_ebias(type); - norm = H5Tget_norm(type); + norm = H5Tget_norm(type); switch (norm) { case H5T_NORM_IMPLIED: norm_s = ", msb implied"; @@ -778,14 +792,14 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind) case H5T_NORM_ERROR: norm_s = ", unknown normalization"; break; - default: - ; - break; + default:; + break; } - h5tools_str_append(buffer, "\n%*s(significant for %lu bit%s at bit %lu%s)", ind, "", - (unsigned long)msize, 1==msize?"":"s", (unsigned long)mpos, norm_s); - h5tools_str_append(buffer, "\n%*s(exponent for %lu bit%s at bit %lu, bias is 0x%lx)", - ind, "", (unsigned long)esize, 1==esize?"":"s", (unsigned long)epos, (unsigned long)ebias); + h5tools_str_append(buffer, "\n%*s(significant for %lu bit%s at bit %lu%s)", ind, "", (unsigned long)msize, + 1 == msize ? "" : "s", (unsigned long)mpos, norm_s); + h5tools_str_append(buffer, "\n%*s(exponent for %lu bit%s at bit %lu, bias is 0x%lx)", ind, "", + (unsigned long)esize, 1 == esize ? "" : "s", (unsigned long)epos, + (unsigned long)ebias); h5tools_str_append(buffer, "\n%*s(sign bit at %lu)", ind, "", (unsigned long)spos); /* Display internal padding */ @@ -805,16 +819,14 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind) case H5T_NPAD: pad_s = "unknown"; break; - default: - ; - break; + default:; + break; } h5tools_str_append(buffer, "\n%*s(internal padding bits are %s)", ind, "", pad_s); } return TRUE; } - /*------------------------------------------------------------------------- * Function: print_cmpd_type * @@ -827,39 +839,39 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind) static hbool_t print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind) { - char *name = NULL; /* member name */ - size_t size; /* total size of type in bytes */ - hid_t subtype; /* member data type */ - int nmembs; /* number of members */ - int n; /* miscellaneous counters */ - unsigned i; /* miscellaneous counters */ - - if(H5T_COMPOUND != H5Tget_class(type)) + char * name = NULL; /* member name */ + size_t size; /* total size of type in bytes */ + hid_t subtype; /* member data type */ + int nmembs; /* number of members */ + int n; /* miscellaneous counters */ + unsigned i; /* miscellaneous counters */ + + if (H5T_COMPOUND != H5Tget_class(type)) return FALSE; - if((nmembs = H5Tget_nmembers(type)) < 0) + if ((nmembs = H5Tget_nmembers(type)) < 0) return FALSE; h5tools_str_append(buffer, "struct {"); for (i = 0; i < (unsigned)nmembs; i++) { /* Name and offset */ name = H5Tget_member_name(type, i); - h5tools_str_append(buffer, "\n%*s\"", ind+4, ""); + h5tools_str_append(buffer, "\n%*s\"", ind + 4, ""); n = print_string(buffer, name, FALSE); - h5tools_str_append(buffer, "\"%*s +%-4lu ", MAX(0, 16-n), "", (unsigned long)H5Tget_member_offset(type, i)); + h5tools_str_append(buffer, "\"%*s +%-4lu ", MAX(0, 16 - n), "", + (unsigned long)H5Tget_member_offset(type, i)); H5free_memory(name); /* Member's type */ subtype = H5Tget_member_type(type, i); - print_type(buffer, subtype, ind+4); + print_type(buffer, subtype, ind + 4); H5Tclose(subtype); } size = H5Tget_size(type); - h5tools_str_append(buffer, "\n%*s} %lu byte%s", ind, "", (unsigned long)size, 1==size?"":"s"); + h5tools_str_append(buffer, "\n%*s} %lu byte%s", ind, "", (unsigned long)size, 1 == size ? "" : "s"); return TRUE; } - /*------------------------------------------------------------------------- * Function: print_enum_type * @@ -872,8 +884,8 @@ print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind) static hbool_t print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) { - int nmembs; /* number of members */ - hid_t super; /* enum base integer type */ + int nmembs; /* number of members */ + hid_t super; /* enum base integer type */ if (H5T_ENUM != H5Tget_class(type)) return FALSE; @@ -886,11 +898,11 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) h5tools_str_append(buffer, " {"); if (nmembs > 0) { - char **name; /* member names */ - unsigned char *value; /* value array */ - hid_t native = H5I_INVALID_HID; /* native integer data type */ - size_t dst_size; /* destination value type size */ - unsigned i; /* miscellaneous counters */ + char ** name; /* member names */ + unsigned char *value; /* value array */ + hid_t native = H5I_INVALID_HID; /* native integer data type */ + size_t dst_size; /* destination value type size */ + unsigned i; /* miscellaneous counters */ /* Determine what data type to use for the native values. To simplify * things we entertain three possibilities: @@ -908,7 +920,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) dst_size = H5Tget_size(type); /* Get the names and raw values of all members */ - name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)); + name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)); value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < (unsigned)nmembs; i++) { name[i] = H5Tget_member_name(type, i); @@ -933,10 +945,10 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) /* Print members */ for (i = 0; i < (unsigned)nmembs; i++) { - unsigned char *copy; /* a pointer to value array */ - int nchars; /* number of output characters */ + unsigned char *copy; /* a pointer to value array */ + int nchars; /* number of output characters */ - h5tools_str_append(buffer, "\n%*s", ind+4, ""); + h5tools_str_append(buffer, "\n%*s", ind + 4, ""); nchars = print_string(buffer, name[i], TRUE); h5tools_str_append(buffer, "%*s = ", MAX(0, 16 - nchars), ""); @@ -945,30 +957,30 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) h5tools_str_append(buffer, "0x"); for (j = 0; j < dst_size; j++) - h5tools_str_append(buffer, "%02x", value[i*dst_size+j]); + h5tools_str_append(buffer, "%02x", value[i * dst_size + j]); } else if (H5T_SGN_NONE == H5Tget_sign(native)) { /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" *strangely, unless use another pointer "copy".*/ copy = value + i * dst_size; - h5tools_str_append(buffer, HSIZE_T_FORMAT, *((unsigned long long*)((void*)copy))); + h5tools_str_append(buffer, HSIZE_T_FORMAT, *((unsigned long long *)((void *)copy))); } else { /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" *strangely, unless use another pointer "copy".*/ copy = value + i * dst_size; - h5tools_str_append(buffer, "%"H5_PRINTF_LL_WIDTH"d", *((long long*)((void*)copy))); + h5tools_str_append(buffer, "%" H5_PRINTF_LL_WIDTH "d", *((long long *)((void *)copy))); } } /* Release resources */ - for(i = 0; i < (unsigned)nmembs; i++) + for (i = 0; i < (unsigned)nmembs; i++) H5free_memory(name[i]); HDfree(name); HDfree(value); } else - h5tools_str_append(buffer, "\n%*s ", ind+4, ""); + h5tools_str_append(buffer, "\n%*s ", ind + 4, ""); h5tools_str_append(buffer, "\n%*s}", ind, ""); @@ -977,7 +989,6 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - /*------------------------------------------------------------------------- * Function: print_string_type * @@ -990,10 +1001,10 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) static hbool_t print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind) { - H5T_str_t pad; - const char *pad_s=NULL; + H5T_str_t pad; + const char *pad_s = NULL; H5T_cset_t cset; - const char *cset_s=NULL; + const char *cset_s = NULL; if (H5T_STRING != H5Tget_class(type)) return FALSE; @@ -1026,9 +1037,8 @@ print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind) case H5T_STR_ERROR: pad_s = "unknown-format"; break; - default: - ; - break; + default:; + break; } /* Character set */ @@ -1057,9 +1067,8 @@ print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind) case H5T_CSET_ERROR: cset_s = "unknown-character-set"; break; - default: - ; - break; + default:; + break; } if (H5Tis_variable_str(type)) { @@ -1072,7 +1081,6 @@ print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind) return TRUE; } - /*------------------------------------------------------------------------- * Function: print_reference_type * @@ -1104,7 +1112,6 @@ print_reference_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind) return TRUE; } - /*------------------------------------------------------------------------- * Function: print_opaque_type * @@ -1117,7 +1124,7 @@ print_reference_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind) static hbool_t print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind) { - char *tag; + char * tag; size_t size; if (H5T_OPAQUE != H5Tget_class(type)) @@ -1134,7 +1141,6 @@ print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - /*------------------------------------------------------------------------- * Function: print_vlen_type * @@ -1147,7 +1153,7 @@ print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind) static hbool_t print_vlen_type(h5tools_str_t *buffer, hid_t type, int ind) { - hid_t super; + hid_t super; if (H5T_VLEN != H5Tget_class(type)) return FALSE; @@ -1159,7 +1165,6 @@ print_vlen_type(h5tools_str_t *buffer, hid_t type, int ind) return TRUE; } - /*--------------------------------------------------------------------------- * Purpose: Print information about an array type * @@ -1170,9 +1175,9 @@ print_vlen_type(h5tools_str_t *buffer, hid_t type, int ind) static hbool_t print_array_type(h5tools_str_t *buffer, hid_t type, int ind) { - hid_t super; - int ndims, i; - hsize_t *dims=NULL; + hid_t super; + int ndims, i; + hsize_t *dims = NULL; if (H5T_ARRAY != H5Tget_class(type)) return FALSE; @@ -1183,7 +1188,7 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind) /* Print dimensions */ for (i = 0; i < ndims; i++) - h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT , i?",":"[", dims[i]); + h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, i ? "," : "[", dims[i]); h5tools_str_append(buffer, "]"); HDfree(dims); @@ -1191,16 +1196,14 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind) else h5tools_str_append(buffer, " [SCALAR]\n", rawoutstream); - /* Print parent type */ h5tools_str_append(buffer, " "); super = H5Tget_super(type); - print_type(buffer, super, ind+4); + print_type(buffer, super, ind + 4); H5Tclose(super); return TRUE; } - /*------------------------------------------------------------------------- * Function: print_bitfield_type * @@ -1213,12 +1216,12 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind) static hbool_t print_bitfield_type(h5tools_str_t *buffer, hid_t type, int ind) { - H5T_order_t order; /* byte order value */ - const char *order_s = NULL; /* byte order string */ + H5T_order_t order; /* byte order value */ + const char *order_s = NULL; /* byte order string */ if (H5T_BITFIELD != H5Tget_class(type)) return FALSE; - if (H5Tget_size(type)>1) { + if (H5Tget_size(type) > 1) { order = H5Tget_order(type); if (H5T_ORDER_LE == order) { order_s = " little-endian"; @@ -1237,12 +1240,11 @@ print_bitfield_type(h5tools_str_t *buffer, hid_t type, int ind) order_s = ""; } - h5tools_str_append(buffer, "%lu-bit%s bitfield", (unsigned long)(8*H5Tget_size(type)), order_s); + h5tools_str_append(buffer, "%lu-bit%s bitfield", (unsigned long)(8 * H5Tget_size(type)), order_s); print_precision(buffer, type, ind); return TRUE; } - /*------------------------------------------------------------------------- * Function: print_type * @@ -1259,11 +1261,11 @@ print_bitfield_type(h5tools_str_t *buffer, hid_t type, int ind) static void print_type(h5tools_str_t *buffer, hid_t type, int ind) { - H5T_class_t data_class = H5Tget_class(type); + H5T_class_t data_class = H5Tget_class(type); /* Bad data type */ if (type < 0) { - h5tools_str_append(buffer,""); + h5tools_str_append(buffer, ""); return; } @@ -1276,29 +1278,25 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind) H5Otoken_to_str(type, &oi.token, &type_string); - h5tools_str_append(buffer,"shared-%lu:%s", oi.fileno, type_string); + h5tools_str_append(buffer, "shared-%lu:%s", oi.fileno, type_string); H5free_memory(type_string); } /* end if */ else - h5tools_str_append(buffer,"shared "); + h5tools_str_append(buffer, "shared "); } /* end if */ /* Print the type */ - if (print_native_type(buffer, type, ind) || - print_ieee_type(buffer, type, ind) || - print_cmpd_type(buffer, type, ind) || - print_enum_type(buffer, type, ind) || - print_string_type(buffer, type, ind) || - print_reference_type(buffer, type, ind) || - print_vlen_type(buffer, type, ind) || - print_array_type(buffer, type, ind) || - print_opaque_type(buffer, type, ind) || - print_bitfield_type(buffer, type, ind)) + if (print_native_type(buffer, type, ind) || print_ieee_type(buffer, type, ind) || + print_cmpd_type(buffer, type, ind) || print_enum_type(buffer, type, ind) || + print_string_type(buffer, type, ind) || print_reference_type(buffer, type, ind) || + print_vlen_type(buffer, type, ind) || print_array_type(buffer, type, ind) || + print_opaque_type(buffer, type, ind) || print_bitfield_type(buffer, type, ind)) return; /* Unknown type */ - h5tools_str_append(buffer,"%lu-byte class-%u unknown", (unsigned long)H5Tget_size(type), (unsigned)data_class); + h5tools_str_append(buffer, "%lu-byte class-%u unknown", (unsigned long)H5Tget_size(type), + (unsigned)data_class); } /*------------------------------------------------------------------------- @@ -1312,37 +1310,37 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind) static void dump_dataset_values(hid_t dset) { - hid_t f_type = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hsize_t total_size[H5S_MAX_RANK]; - int ndims; - char string_prefix[64]; - static char fmt_double[16]; - static char fmt_float[16]; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t outputformat; - h5tool_format_t *info = &ls_dataformat; - H5R_ref_t *ref_buf = NULL; + hid_t f_type = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hsize_t total_size[H5S_MAX_RANK]; + int ndims; + char string_prefix[64]; + static char fmt_double[16]; + static char fmt_float[16]; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t outputformat; + h5tool_format_t * info = &ls_dataformat; + H5R_ref_t * ref_buf = NULL; H5TOOLS_START_DEBUG(""); f_type = H5Dget_type(dset); - space = H5Dget_space(dset); + space = H5Dget_space(dset); HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - outputformat = *info; - outputformat.line_1st = NULL; - outputformat.idx_fmt = ""; + outputformat = *info; + outputformat.line_1st = NULL; + outputformat.idx_fmt = ""; if (simple_output_g) { - outputformat.idx_fmt = ""; - outputformat.line_per_line = 1; + outputformat.idx_fmt = ""; + outputformat.line_per_line = 1; outputformat.line_multi_new = 0; - outputformat.line_pre = " "; - outputformat.line_cont = " "; + outputformat.line_pre = " "; + outputformat.line_cont = " "; outputformat.arr_pre = ""; outputformat.arr_suf = ""; @@ -1357,9 +1355,8 @@ dump_dataset_values(hid_t dset) if (label_g) outputformat.cmpd_name = "%s="; - outputformat.elmt_suf1 = " "; + outputformat.elmt_suf1 = " "; outputformat.str_locale = ESCAPE_HTML; - } else { if (no_line_wrap_g) { @@ -1370,8 +1367,8 @@ dump_dataset_values(hid_t dset) } if (label_g) outputformat.cmpd_name = "%s="; - outputformat.line_pre = " %s "; - outputformat.line_cont = " %s "; + outputformat.line_pre = " %s "; + outputformat.line_cont = " %s "; outputformat.str_repeat = 8; outputformat.arr_pre = NULL; @@ -1402,7 +1399,7 @@ dump_dataset_values(hid_t dset) else if (string_g && H5Tget_size(f_type) == 1 && (H5Tget_class(f_type) == H5T_INTEGER)) { /* Print 1-byte integer data as an ASCI character string instead of * integers if the `-s' or `--string' command-line option was given. */ - outputformat.ascii = TRUE; + outputformat.ascii = TRUE; outputformat.elmt_suf1 = ""; outputformat.elmt_suf2 = ""; HDsnprintf(string_prefix, sizeof(string_prefix), "%s\"", outputformat.line_pre); @@ -1412,20 +1409,22 @@ dump_dataset_values(hid_t dset) info = &outputformat; ctx.indent_level = 1; - ctx.cur_column = (size_t)curr_pos; + ctx.cur_column = (size_t)curr_pos; /* Print all the values. */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " Data:\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, + (hsize_t)0); ctx.need_prefix = TRUE; - ctx.cur_column = (size_t)curr_pos; + ctx.cur_column = (size_t)curr_pos; if (vfd_swmr_poll_g) H5Drefresh(dset); if (H5Tget_class(f_type) == H5T_REFERENCE) { H5TOOLS_DEBUG("reference class type"); - if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) { + if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && + !H5Tequal(f_type, H5T_STD_REF_OBJ)) { H5TOOLS_GOTO_DONE_NO_RET(); } @@ -1438,9 +1437,10 @@ dump_dataset_values(hid_t dset) ctx.need_prefix = TRUE; - if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { + if (NULL != + (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { H5TOOLS_DEBUG("H5Dread reference read"); - if(H5Dread(dset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) { + if (H5Dread(dset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) { HDfree(ref_buf); H5TOOLS_INFO("H5Dread reference failed"); H5TOOLS_GOTO_DONE_NO_RET(); @@ -1455,7 +1455,8 @@ dump_dataset_values(hid_t dset) if (h5tools_dump_dset(rawoutstream, info, &ctx, dset) < 0) { h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " Unable to print data."); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); } } done: @@ -1469,7 +1470,6 @@ done: H5TOOLS_ENDDEBUG(""); } - /*------------------------------------------------------------------------- * Function: dump_attribute_values * @@ -1481,37 +1481,37 @@ done: static void dump_attribute_values(hid_t attr) { - hid_t f_type = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hsize_t total_size[H5S_MAX_RANK]; - int ndims; - char string_prefix[64]; - static char fmt_double[16]; - static char fmt_float[16]; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t outputformat; - h5tool_format_t *info = &ls_dataformat; - H5R_ref_t *ref_buf = NULL; + hid_t f_type = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hsize_t total_size[H5S_MAX_RANK]; + int ndims; + char string_prefix[64]; + static char fmt_double[16]; + static char fmt_float[16]; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t outputformat; + h5tool_format_t * info = &ls_dataformat; + H5R_ref_t * ref_buf = NULL; H5TOOLS_START_DEBUG(""); f_type = H5Aget_type(attr); - space = H5Aget_space(attr); + space = H5Aget_space(attr); HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - outputformat = *info; - outputformat.line_1st = NULL; - outputformat.idx_fmt = ""; + outputformat = *info; + outputformat.line_1st = NULL; + outputformat.idx_fmt = ""; if (simple_output_g) { - outputformat.idx_fmt = ""; - outputformat.line_per_line = 1; + outputformat.idx_fmt = ""; + outputformat.line_per_line = 1; outputformat.line_multi_new = 0; - outputformat.line_pre = " "; - outputformat.line_cont = " "; + outputformat.line_pre = " "; + outputformat.line_cont = " "; outputformat.arr_pre = ""; outputformat.arr_suf = ""; @@ -1526,9 +1526,8 @@ dump_attribute_values(hid_t attr) if (label_g) outputformat.cmpd_name = "%s="; - outputformat.elmt_suf1 = " "; + outputformat.elmt_suf1 = " "; outputformat.str_locale = ESCAPE_HTML; - } else { if (no_line_wrap_g) { @@ -1539,8 +1538,8 @@ dump_attribute_values(hid_t attr) } if (label_g) outputformat.cmpd_name = "%s="; - outputformat.line_pre = " %s "; - outputformat.line_cont = " %s "; + outputformat.line_pre = " %s "; + outputformat.line_cont = " %s "; outputformat.str_repeat = 8; outputformat.arr_pre = NULL; @@ -1571,7 +1570,7 @@ dump_attribute_values(hid_t attr) else if (string_g && H5Tget_size(f_type) == 1 && (H5Tget_class(f_type) == H5T_INTEGER)) { /* Print 1-byte integer data as an ASCI character string instead of * integers if the `-s' or `--string' command-line option was given. */ - outputformat.ascii = TRUE; + outputformat.ascii = TRUE; outputformat.elmt_suf1 = ""; outputformat.elmt_suf2 = ""; HDsnprintf(string_prefix, sizeof(string_prefix), "%s\"", outputformat.line_pre); @@ -1581,19 +1580,21 @@ dump_attribute_values(hid_t attr) info = &outputformat; ctx.indent_level = 2; - ctx.cur_column = (size_t)curr_pos; + ctx.cur_column = (size_t)curr_pos; /* Print all the values. */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " Data:\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, + (hsize_t)0); ctx.need_prefix = TRUE; - ctx.cur_column = (size_t)curr_pos; + ctx.cur_column = (size_t)curr_pos; if (H5Tget_class(f_type) == H5T_REFERENCE) { H5TOOLS_DEBUG("reference class type"); - if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) { + if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && + !H5Tequal(f_type, H5T_STD_REF_OBJ)) { H5TOOLS_GOTO_DONE_NO_RET(); } @@ -1606,9 +1607,10 @@ dump_attribute_values(hid_t attr) ctx.need_prefix = TRUE; - if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { + if (NULL != + (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { H5TOOLS_DEBUG("H5Aread reference read"); - if(H5Aread(attr, H5T_STD_REF, ref_buf) < 0) { + if (H5Aread(attr, H5T_STD_REF, ref_buf) < 0) { HDfree(ref_buf); H5TOOLS_INFO("H5Aread reference failed"); H5TOOLS_GOTO_DONE_NO_RET(); @@ -1627,7 +1629,8 @@ dump_attribute_values(hid_t attr) if (h5tools_dump_mem(rawoutstream, info, &ctx, attr) < 0) { h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " Unable to print data."); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); } ctx.indent_level--; H5TOOLS_DEBUG("Attribute data read complete"); @@ -1654,20 +1657,20 @@ done: */ static herr_t list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, - void H5_ATTR_UNUSED *op_data) + void H5_ATTR_UNUSED *op_data) { - hid_t attr = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t type = H5I_INVALID_HID; - hsize_t size[H5S_MAX_RANK]; - hsize_t nelmts = 1; - int ndims; - int i; - H5S_class_t space_type; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *info = &ls_dataformat; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t type = H5I_INVALID_HID; + hsize_t size[H5S_MAX_RANK]; + hsize_t nelmts = 1; + int ndims; + int i; + H5S_class_t space_type; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * info = &ls_dataformat; H5TOOLS_START_DEBUG(""); @@ -1675,7 +1678,7 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain HDmemset(&buffer, 0, sizeof(h5tools_str_t)); ctx.indent_level = 2; - ctx.cur_column = (size_t)curr_pos; + ctx.cur_column = (size_t)curr_pos; h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " Attribute: "); @@ -1685,41 +1688,45 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain H5TOOLS_DEBUG("Attribute name:%s", attr_name); if ((attr = H5Aopen(obj, attr_name, H5P_DEFAULT)) >= 0) { space = H5Aget_space(attr); - type = H5Aget_type(attr); + type = H5Aget_type(attr); /* Data space */ - ndims = H5Sget_simple_extent_dims(space, size, NULL); + ndims = H5Sget_simple_extent_dims(space, size, NULL); space_type = H5Sget_simple_extent_type(space); H5TOOLS_DEBUG("Attribute ndims:%d", ndims); - switch(space_type) { + switch (space_type) { case H5S_SCALAR: /* scalar dataspace */ h5tools_str_append(&buffer, " scalar\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); break; case H5S_SIMPLE: /* simple dataspace */ h5tools_str_append(&buffer, " {"); for (i = 0; i < ndims; i++) { - h5tools_str_append(&buffer, "%s" HSIZE_T_FORMAT, i?", ":"", size[i]); + h5tools_str_append(&buffer, "%s" HSIZE_T_FORMAT, i ? ", " : "", size[i]); nelmts *= size[i]; } h5tools_str_append(&buffer, "}\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); break; case H5S_NULL: /* null dataspace */ h5tools_str_append(&buffer, " null\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); break; case H5S_NO_CLASS: default: /* Unknown dataspace type */ h5tools_str_append(&buffer, " unknown\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); break; } /* end switch */ @@ -1728,7 +1735,8 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain h5tools_str_append(&buffer, " %-10s ", "Type:"); print_type(&buffer, type, 15); h5tools_str_append(&buffer, "\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); H5Sclose(space); H5Tclose(type); @@ -1748,7 +1756,6 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain return 0; } - /*------------------------------------------------------------------------- * Function: dataset_list1 * @@ -1764,16 +1771,16 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain static herr_t dataset_list1(hid_t dset) { - hsize_t cur_size[H5S_MAX_RANK]; /* current dataset dimensions */ - hsize_t max_size[H5S_MAX_RANK]; /* maximum dataset dimensions */ - hid_t space; /* data space */ - int ndims; /* dimensionality */ - H5S_class_t space_type; /* type of dataspace */ - int i; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *info = &ls_dataformat; + hsize_t cur_size[H5S_MAX_RANK]; /* current dataset dimensions */ + hsize_t max_size[H5S_MAX_RANK]; /* maximum dataset dimensions */ + hid_t space; /* data space */ + int ndims; /* dimensionality */ + H5S_class_t space_type; /* type of dataspace */ + int i; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * info = &ls_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -1782,17 +1789,17 @@ dataset_list1(hid_t dset) /* Information that goes on the same row as the name. The name has * already been printed. */ - space = H5Dget_space(dset); + space = H5Dget_space(dset); space_type = H5Sget_simple_extent_type(space); - ndims = H5Sget_simple_extent_dims(space, cur_size, max_size); + ndims = H5Sget_simple_extent_dims(space, cur_size, max_size); h5tools_str_append(&buffer, " {"); for (i = 0; i < ndims; i++) { - h5tools_str_append(&buffer, "%s"HSIZE_T_FORMAT, i?", ":"", cur_size[i]); - if (max_size[i]==H5S_UNLIMITED) { + h5tools_str_append(&buffer, "%s" HSIZE_T_FORMAT, i ? ", " : "", cur_size[i]); + if (max_size[i] == H5S_UNLIMITED) { h5tools_str_append(&buffer, "/%s", "Inf"); } else if (max_size[i] != cur_size[i] || verbose_g > 0) { - h5tools_str_append(&buffer, "/"HSIZE_T_FORMAT, max_size[i]); + h5tools_str_append(&buffer, "/" HSIZE_T_FORMAT, max_size[i]); } } if (space_type == H5S_SCALAR) @@ -1800,15 +1807,15 @@ dataset_list1(hid_t dset) else if (space_type == H5S_NULL) h5tools_str_append(&buffer, "NULL"); h5tools_str_append(&buffer, "}"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); - H5Sclose (space); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, + (hsize_t)0); + H5Sclose(space); h5tools_str_close(&buffer); return 0; } - /*------------------------------------------------------------------------- * Function: dataset_list2 * @@ -1822,30 +1829,30 @@ dataset_list1(hid_t dset) static herr_t dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) { - hid_t dcpl; /* dataset creation property list */ - hid_t type; /* data type of dataset */ - hid_t space; /* data space of dataset */ - int nf; /* number of filters */ - unsigned filt_flags; /* filter flags */ - H5Z_filter_t filt_id; /* filter identification number */ - unsigned cd_values[20]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ - size_t cd_num; /* filter client data counter */ - char f_name[256]; /* filter/file name */ - char s[64]; /* temporary string buffer */ - off_t f_offset; /* offset in external file */ - hsize_t f_size; /* bytes used in external file */ - hsize_t total, used; /* total size or offset */ - int ndims; /* dimensionality */ - int n, max_len; /* max extern file name length */ - double utilization; /* percent utilization of storage */ - H5T_class_t tclass; /* datatype class identifier */ - int i; - H5D_layout_t stl; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *info = &ls_dataformat; + hid_t dcpl; /* dataset creation property list */ + hid_t type; /* data type of dataset */ + hid_t space; /* data space of dataset */ + int nf; /* number of filters */ + unsigned filt_flags; /* filter flags */ + H5Z_filter_t filt_id; /* filter identification number */ + unsigned cd_values[20]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ + size_t cd_num; /* filter client data counter */ + char f_name[256]; /* filter/file name */ + char s[64]; /* temporary string buffer */ + off_t f_offset; /* offset in external file */ + hsize_t f_size; /* bytes used in external file */ + hsize_t total, used; /* total size or offset */ + int ndims; /* dimensionality */ + int n, max_len; /* max extern file name length */ + double utilization; /* percent utilization of storage */ + H5T_class_t tclass; /* datatype class identifier */ + int i; + H5D_layout_t stl; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * info = &ls_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -1853,26 +1860,24 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) h5tools_str_reset(&buffer); if (verbose_g > 0) { - dcpl = H5Dget_create_plist(dset); + dcpl = H5Dget_create_plist(dset); space = H5Dget_space(dset); - type = H5Dget_type(dset); + type = H5Dget_type(dset); stl = H5Pget_layout(dcpl); switch (stl) { - case H5D_CHUNKED: - { - hsize_t chsize[64]; /* chunk size in elements */ - - ndims = H5Pget_chunk(dcpl, (int)NELMTS(chsize), chsize/*out*/); - h5tools_str_append(&buffer, " %-10s {", "Chunks:"); - total = H5Tget_size(type); - for (i = 0; i < ndims; i++) { - h5tools_str_append(&buffer, "%s"HSIZE_T_FORMAT, i?", ":"", chsize[i]); - total *= chsize[i]; - } - h5tools_str_append(&buffer, "} "HSIZE_T_FORMAT" bytes\n", total); + case H5D_CHUNKED: { + hsize_t chsize[64]; /* chunk size in elements */ + + ndims = H5Pget_chunk(dcpl, (int)NELMTS(chsize), chsize /*out*/); + h5tools_str_append(&buffer, " %-10s {", "Chunks:"); + total = H5Tget_size(type); + for (i = 0; i < ndims; i++) { + h5tools_str_append(&buffer, "%s" HSIZE_T_FORMAT, i ? ", " : "", chsize[i]); + total *= chsize[i]; } - break; + h5tools_str_append(&buffer, "} " HSIZE_T_FORMAT " bytes\n", total); + } break; case H5D_COMPACT: break; case H5D_CONTIGUOUS: @@ -1881,64 +1886,73 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) for (i = 0, max_len = 0; i < nf; i++) { if (H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, NULL, NULL) < 0) continue; - n = print_string(NULL, f_name, TRUE); + n = print_string(NULL, f_name, TRUE); max_len = MAX(max_len, n); } /* end for */ - h5tools_str_append(&buffer, " %-10s %d external file%s\n", "Extern:", nf, 1==nf?"":"s"); - h5tools_str_append(&buffer, " %4s %10s %10s %10s %s\n", "ID", "DSet-Addr", "File-Addr", "Bytes", "File"); - h5tools_str_append(&buffer, " %4s %10s %10s %10s ", "----", "----------", "----------", "----------"); + h5tools_str_append(&buffer, " %-10s %d external file%s\n", "Extern:", nf, + 1 == nf ? "" : "s"); + h5tools_str_append(&buffer, " %4s %10s %10s %10s %s\n", "ID", "DSet-Addr", + "File-Addr", "Bytes", "File"); + h5tools_str_append(&buffer, " %4s %10s %10s %10s ", "----", "----------", + "----------", "----------"); for (i = 0; i < max_len; i++) h5tools_str_append(&buffer, "-"); h5tools_str_append(&buffer, "\n"); - for (i = 0, total=0; i < nf; i++) { - if (H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, &f_offset, &f_size)<0) { - h5tools_str_append(&buffer, " #%03d %10"H5_PRINTF_LL_WIDTH"u %10s %10s ***ERROR*** %s\n", - i, total, "", "", i+1 0) { - utilization = ((double)total * (double)100.0f) / (double)used; - h5tools_str_append(&buffer, ", %1.2f%% utilization", utilization); - } + case H5T_REFERENCE: + if (H5Tequal(dset, H5T_STD_REF)) { + h5tools_str_append(&buffer, "reference information not available"); + } + else if (H5Tequal(dset, H5T_STD_REF_DSETREG)) { + h5tools_str_append(&buffer, "information not available"); + } + break; + + case H5T_NO_CLASS: + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_TIME: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_COMPOUND: + case H5T_ENUM: + case H5T_ARRAY: + case H5T_NCLASSES: + default: + h5tools_str_append(&buffer, + HSIZE_T_FORMAT " logical byte%s, " HSIZE_T_FORMAT " allocated byte%s", + total, 1 == total ? "" : "s", used, 1 == used ? "" : "s"); + if (used > 0) { + utilization = ((double)total * (double)100.0f) / (double)used; + h5tools_str_append(&buffer, ", %1.2f%% utilization", utilization); + } } h5tools_str_append(&buffer, "\n"); @@ -1990,23 +2006,27 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) if ((nf = H5Pget_nfilters(dcpl)) > 0) { for (i = 0; i < nf; i++) { cd_nelmts = NELMTS(cd_values); - filt_id = H5Pget_filter2(dcpl, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), f_name, NULL); + filt_id = H5Pget_filter2(dcpl, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, + sizeof(f_name), f_name, NULL); f_name[sizeof(f_name) - 1] = '\0'; HDsnprintf(s, sizeof(s), "Filter-%d:", i); - h5tools_str_append(&buffer, " %-10s %s-%u %s {", s, (f_name[0] ? f_name : "method"), (unsigned)filt_id, ((filt_flags & H5Z_FLAG_OPTIONAL) ? "OPT" : "")); + h5tools_str_append(&buffer, " %-10s %s-%u %s {", s, (f_name[0] ? f_name : "method"), + (unsigned)filt_id, ((filt_flags & H5Z_FLAG_OPTIONAL) ? "OPT" : "")); for (cd_num = 0; cd_num < cd_nelmts; cd_num++) h5tools_str_append(&buffer, "%s%u", (cd_num ? ", " : ""), cd_values[cd_num]); h5tools_str_append(&buffer, "}\n"); } /* end for */ - } /* end if */ - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + } /* end if */ + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); /* Print data type */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " %-10s ", "Type:"); print_type(&buffer, type, 15); h5tools_str_append(&buffer, "\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); /* Print address information */ if (address_g) @@ -2026,7 +2046,6 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) return 0; } /* end dataset_list2() */ - /*------------------------------------------------------------------------- * Function: datatype_list2 * @@ -2041,10 +2060,10 @@ static herr_t datatype_list2(hid_t type, const char H5_ATTR_UNUSED *name) { if (verbose_g > 0) { - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *info = &ls_dataformat; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * info = &ls_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -2054,14 +2073,14 @@ datatype_list2(hid_t type, const char H5_ATTR_UNUSED *name) h5tools_str_append(&buffer, " %-10s ", "Type:"); print_type(&buffer, type, 15); h5tools_str_append(&buffer, "\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); } return 0; } - /*------------------------------------------------------------------------- * Function: list_obj * @@ -2074,12 +2093,12 @@ datatype_list2(hid_t type, const char H5_ATTR_UNUSED *name) static herr_t list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, void *_iter) { - H5O_type_t obj_type = oinfo->type; /* Type of the object */ - iter_t *iter = (iter_t*)_iter; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *info = &ls_dataformat; + H5O_type_t obj_type = oinfo->type; /* Type of the object */ + iter_t * iter = (iter_t *)_iter; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * info = &ls_dataformat; H5TOOLS_START_DEBUG(""); @@ -2102,7 +2121,8 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi h5tools_str_append(&buffer, "{"); if (obj_type >= 0 && dispatch_g[obj_type].name) h5tools_str_append(&buffer, "%s", dispatch_g[obj_type].name); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, + (hsize_t)0); /* Check if we've seen this object before */ if (first_seen) { @@ -2112,10 +2132,11 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi if (!iter->symlink_target) { h5tools_str_append(&buffer, "\n"); } - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); } /* end if */ else { - hid_t obj_id = H5I_INVALID_HID; /* ID of object opened */ + hid_t obj_id = H5I_INVALID_HID; /* ID of object opened */ /* Open the object. Not all objects can be opened. If this is the case * then return right away. @@ -2124,7 +2145,8 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi if (obj_type >= 0 && (obj_id = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) { h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " *ERROR*\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); goto done; } /* end if */ @@ -2135,17 +2157,18 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi if (!iter->symlink_target || (verbose_g > 0)) { h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); } /* Show detailed information about the object, beginning with information * which is common to all objects. */ if (verbose_g > 0) { - size_t buf_size = 0; - char* comment = NULL; - char* obj_tok_str = NULL; + size_t buf_size = 0; + char * comment = NULL; + char * obj_tok_str = NULL; ssize_t cmt_bufsize = -1; - hbool_t supported = FALSE; + hbool_t supported = FALSE; /* Display attributes */ H5TOOLS_DEBUG("Display attributes"); @@ -2158,16 +2181,17 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " %-10s %lu:%s\n", "Location:", oinfo->fileno, obj_tok_str); h5tools_str_append(&buffer, " %-10s %u\n", "Links:", (unsigned)oinfo->rc); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); H5free_memory(obj_tok_str); /* Modification time */ if (oinfo->mtime > 0) { - char buf[256]; + char buf[256]; struct tm *tm; - if(simple_output_g) + if (simple_output_g) tm = HDgmtime(&(oinfo->mtime)); else tm = HDlocaltime(&(oinfo->mtime)); @@ -2175,9 +2199,10 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " %-10s %s\n", "Modified:", buf); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, + (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); } /* end if */ - } /* end if */ + } /* end if */ /* Only emit comments if the VOL connector supports that */ H5VLquery_optional(obj_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported); @@ -2191,7 +2216,8 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi * H5Oget_comment again with the correct value. */ if (cmt_bufsize > 0) { - comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */ + comment = + (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */ if (comment) { cmt_bufsize = H5Oget_comment(obj_id, comment, (size_t)cmt_bufsize); if (cmt_bufsize > 0) { @@ -2200,7 +2226,8 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi h5tools_str_append(&buffer, " %-10s \"", "Comment:"); print_string(&buffer, comment, FALSE); h5tools_str_append(&buffer, "\"\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, + (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); } /* end if */ HDfree(comment); } @@ -2221,7 +2248,8 @@ done: if (iter->symlink_target) { h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "}\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); iter->symlink_target = FALSE; } h5tools_str_close(&buffer); @@ -2231,7 +2259,6 @@ done: return 0; } /* end list_obj() */ - /*------------------------------------------------------------------------- * Function: list_lnk * @@ -2244,14 +2271,14 @@ done: static herr_t list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter) { - char *buf = NULL; - iter_t *iter = (iter_t*)_iter; - int ret; - hsize_t curr_pos = 0; /* total data element position */ - h5tool_link_info_t lnk_info; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *info = &ls_dataformat; + char * buf = NULL; + iter_t * iter = (iter_t *)_iter; + int ret; + hsize_t curr_pos = 0; /* total data element position */ + h5tool_link_info_t lnk_info; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * info = &ls_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -2263,17 +2290,17 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter) /* if verbose, make H5tools_get_symlink_info() display more */ if (verbose_g) - lnk_info.opt.msg_mode=1; + lnk_info.opt.msg_mode = 1; /* Print the link's name, either full name or base name */ print_obj_name(&buffer, iter, name, ""); - switch(linfo->type) { + switch (linfo->type) { case H5L_TYPE_SOFT: ret = H5tools_get_symlink_info(iter->fid, name, &lnk_info, follow_symlink_g); /* lnk_info.trg_path is malloced in H5tools_get_symlink_info() * so it will be freed via buf later */ - buf = (char*)lnk_info.trg_path; + buf = (char *)lnk_info.trg_path; /* error */ if (ret < 0) goto done; @@ -2284,7 +2311,8 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter) h5tools_str_append(&buffer, "Soft Link {"); h5tools_str_append(&buffer, buf); h5tools_str_append(&buffer, "}"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); if (follow_symlink_g) { hbool_t orig_grp_literal = grp_literal_g; h5tools_str_reset(&buffer); @@ -2293,10 +2321,12 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter) /* Check if we have already seen this softlink */ if (symlink_is_visited(iter->symlink_list, linfo->type, NULL, buf)) { h5tools_str_append(&buffer, "{Already Visited}\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, + (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); goto done; } - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); /* Add this link to the list of seen softlinks */ if (symlink_visit_add(iter->symlink_list, linfo->type, NULL, buf) < 0) @@ -2321,21 +2351,21 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter) else { h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); } break; - case H5L_TYPE_EXTERNAL: - { + case H5L_TYPE_EXTERNAL: { const char *filename; const char *path; - hbool_t follow_link = follow_symlink_g || follow_elink_g; + hbool_t follow_link = follow_symlink_g || follow_elink_g; ret = H5tools_get_symlink_info(iter->fid, name, &lnk_info, follow_link); /* lnk_info.trg_path is malloced in H5tools_get_symlink_info() * so it will be freed via buf later */ - buf = (char*)lnk_info.trg_path; + buf = (char *)lnk_info.trg_path; /* error */ if (ret < 0) goto done; @@ -2349,11 +2379,12 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter) h5tools_str_append(&buffer, "External Link {"); h5tools_str_append(&buffer, filename); h5tools_str_append(&buffer, "/"); - if(*path != '/') + if (*path != '/') h5tools_str_append(&buffer, "/"); h5tools_str_append(&buffer, path); h5tools_str_append(&buffer, "}"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); /* Recurse through the external link */ /* keep the follow_elink_g for backward compatibility with -E */ @@ -2365,10 +2396,12 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter) /* Check if we have already seen this elink */ if (symlink_is_visited(iter->symlink_list, linfo->type, filename, path)) { h5tools_str_append(&buffer, "{Already Visited}\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, + (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); goto done; } - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); /* Add this link to the list of seen elinks */ if (symlink_visit_add(iter->symlink_list, linfo->type, filename, path) < 0) { @@ -2394,15 +2427,15 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter) } else PRINTVALSTREAM(rawoutstream, "\n"); - } - break; + } break; case H5L_TYPE_ERROR: case H5L_TYPE_HARD: case H5L_TYPE_MAX: default: h5tools_str_append(&buffer, "UD Link {cannot follow UD links}\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); break; } /* end switch */ @@ -2414,7 +2447,6 @@ done: return 0; } /* end list_lnk() */ - /*------------------------------------------------------------------------- * Function: visit_obj * @@ -2427,12 +2459,12 @@ done: static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter) { - int retval = 0; - H5O_info2_t oi; /* Information for object */ - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *info = &ls_dataformat; + int retval = 0; + H5O_info2_t oi; /* Information for object */ + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * info = &ls_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -2440,14 +2472,15 @@ visit_obj(hid_t file, const char *oname, iter_t *iter) h5tools_str_reset(&buffer); /* Retrieve info for object to list */ - if (H5Oget_info_by_name3(file, oname, &oi, H5O_INFO_BASIC|H5O_INFO_TIME, H5P_DEFAULT) < 0) { + if (H5Oget_info_by_name3(file, oname, &oi, H5O_INFO_BASIC | H5O_INFO_TIME, H5P_DEFAULT) < 0) { if (iter->symlink_target) { h5tools_str_append(&buffer, "{**NOT FOUND**}\n"); iter->symlink_target = FALSE; } else print_obj_name(&buffer, iter, oname, "**NOT FOUND**"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); retval = -1; goto done; } /* end if */ @@ -2457,18 +2490,20 @@ visit_obj(hid_t file, const char *oname, iter_t *iter) /* Get ID for group */ if (!iter->symlink_target && (iter->gid = H5Gopen2(file, oname, H5P_DEFAULT)) < 0) { h5tools_str_append(&buffer, "%s: unable to open '%s' as group\n", iter->fname, oname); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); - goto done; /* Previously "continue", when this code was in main(). - * We don't "continue" here in order to close the file - * and free the file name properly. */ - } /* end if */ + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); + goto done; /* Previously "continue", when this code was in main(). + * We don't "continue" here in order to close the file + * and free the file name properly. */ + } /* end if */ /* Delay specifying the name start point so the original object name is * displayed if it is a link or non-group object */ iter->name_start = iter->base_len; /* Specified name is a group. List the complete contents of the group. */ - h5trav_visit(file, oname, (hbool_t) (display_root_g || iter->symlink_target), recursive_g, list_obj, list_lnk, iter, H5O_INFO_BASIC|H5O_INFO_TIME); + h5trav_visit(file, oname, (hbool_t)(display_root_g || iter->symlink_target), recursive_g, list_obj, + list_lnk, iter, H5O_INFO_BASIC | H5O_INFO_TIME); /* Close group */ if (!iter->symlink_target) @@ -2488,7 +2523,6 @@ done: return retval; } - /*------------------------------------------------------------------------- * Function: get_width * @@ -2504,7 +2538,7 @@ done: static int get_width(void) { - int width = 80; /*the default */ + int width = 80; /*the default */ char *s; /* Try to get it from the COLUMNS environment variable first since it's @@ -2544,14 +2578,14 @@ get_width(void) { /* Unix with ioctl(TIOCGWINSZ) */ struct winsize w; - if (ioctl(2, (int)TIOCGWINSZ, &w)>=0 && w.ws_col>0) + if (ioctl(2, (int)TIOCGWINSZ, &w) >= 0 && w.ws_col > 0) width = w.ws_col; } #elif defined(H5_HAVE_TIOCGETD) && defined(H5_HAVE_IOCTL) { /* Unix with ioctl(TIOCGETD) */ struct uwdata w; - if (ioctl(2, WIOCGETD, &w)>=0 && w.uw_width>0) + if (ioctl(2, WIOCGETD, &w) >= 0 && w.uw_width > 0) width = w.uw_width / w.uw_hs; } #endif @@ -2582,7 +2616,8 @@ is_valid_args(void) } if (no_dangling_link_g && !follow_symlink_g) { - HDfprintf(rawerrorstream, "Error: --no-dangling-links must be used along with --follow-symlinks option!\n\n"); + HDfprintf(rawerrorstream, + "Error: --no-dangling-links must be used along with --follow-symlinks option!\n\n"); ret = FALSE; goto out; } @@ -2591,7 +2626,6 @@ out: return ret; } - /*------------------------------------------------------------------------- * Function: leave * @@ -2608,7 +2642,6 @@ leave(int ret) HDexit(ret); } - /*------------------------------------------------------------------------- * Function: main * @@ -2621,18 +2654,18 @@ leave(int ret) int main(int argc, const char *argv[]) { - hid_t file_id = H5I_INVALID_HID; - char *fname = NULL, *oname = NULL, *x; - const char *s = NULL; - char *rest; - int argno, times; - static char root_name[] = "/"; - char drivername[50]; - const char *preferred_driver = NULL; - int err_exit = 0; - uint64_t poll_nanosecs = 1000; - hid_t fapl_id = H5P_DEFAULT; - hbool_t custom_vol_fapl = FALSE; + hid_t file_id = H5I_INVALID_HID; + char * fname = NULL, *oname = NULL, *x; + const char * s = NULL; + char * rest; + int argno, times; + static char root_name[] = "/"; + char drivername[50]; + const char * preferred_driver = NULL; + int err_exit = 0; + uint64_t poll_nanosecs = 1000; + hid_t fapl_id = H5P_DEFAULT; + hbool_t custom_vol_fapl = FALSE; h5tools_vol_info_t vol_info; #ifdef H5_HAVE_ROS3_VFD @@ -2689,12 +2722,12 @@ main(int argc, const char *argv[]) else if (!HDstrcmp(argv[argno], "--address")) { address_g = TRUE; } - else if(!HDstrcmp(argv[argno], "--data")) { + else if (!HDstrcmp(argv[argno], "--data")) { data_g = TRUE; } else if (!HDstrcmp(argv[argno], "--enable-error-stack")) { enable_error_stack = 1; - /* deprecated --errors */ + /* deprecated --errors */ } else if (!HDstrcmp(argv[argno], "--errors")) { enable_error_stack = 1; @@ -2710,20 +2743,22 @@ main(int argc, const char *argv[]) } else if (!HDstrcmp(argv[argno], "--full")) { fullname_g = TRUE; - } else if(!HDstrncmp(argv[argno], "--poll=", strlen("--poll="))) { - int nscanned = 0, rc; + } + else if (!HDstrncmp(argv[argno], "--poll=", strlen("--poll="))) { + int nscanned = 0, rc; uint64_t poll_millisecs; - rc = sscanf(argv[argno], "--poll=%" SCNu64 "%n", &poll_millisecs, - &nscanned); + rc = sscanf(argv[argno], "--poll=%" SCNu64 "%n", &poll_millisecs, &nscanned); if (rc != 1 || argv[argno][nscanned] != '\0') { usage(); leave(EXIT_FAILURE); } - poll_nanosecs = poll_millisecs * 1000000; + poll_nanosecs = poll_millisecs * 1000000; vfd_swmr_poll_g = TRUE; - } else if(!HDstrcmp(argv[argno], "--poll")) { + } + else if (!HDstrcmp(argv[argno], "--poll")) { vfd_swmr_poll_g = TRUE; - } else if (!HDstrcmp(argv[argno], "--group")) { + } + else if (!HDstrcmp(argv[argno], "--group")) { grp_literal_g = TRUE; } else if (!HDstrcmp(argv[argno], "--label")) { @@ -2731,7 +2766,7 @@ main(int argc, const char *argv[]) } else if (!HDstrcmp(argv[argno], "--recursive")) { recursive_g = TRUE; - fullname_g = TRUE; + fullname_g = TRUE; } else if (!HDstrcmp(argv[argno], "--simple")) { simple_output_g = TRUE; @@ -2740,23 +2775,23 @@ main(int argc, const char *argv[]) string_g = TRUE; } else if (!HDstrncmp(argv[argno], "--vfd=", (size_t)6)) { - preferred_driver = argv[argno]+6; + preferred_driver = argv[argno] + 6; } else if (!HDstrncmp(argv[argno], "--vol-value=", (size_t)12)) { - vol_info.type = VOL_BY_VALUE; - vol_info.u.value = (H5VL_class_value_t)HDatoi(argv[argno]+12); - custom_vol_fapl = TRUE; + vol_info.type = VOL_BY_VALUE; + vol_info.u.value = (H5VL_class_value_t)HDatoi(argv[argno] + 12); + custom_vol_fapl = TRUE; } else if (!HDstrncmp(argv[argno], "--vol-name=", (size_t)11)) { - vol_info.type = VOL_BY_NAME; - vol_info.u.name = argv[argno]+11; + vol_info.type = VOL_BY_NAME; + vol_info.u.name = argv[argno] + 11; custom_vol_fapl = TRUE; } else if (!HDstrncmp(argv[argno], "--vol-info=", (size_t)11)) { - vol_info.info_string = argv[argno]+11; + vol_info.info_string = argv[argno] + 11; } else if (!HDstrncmp(argv[argno], "--width=", (size_t)8)) { - width_g = (int)HDstrtol(argv[argno]+8, &rest, 0); + width_g = (int)HDstrtol(argv[argno] + 8, &rest, 0); if (0 == width_g) no_line_wrap_g = TRUE; @@ -2802,14 +2837,13 @@ main(int argc, const char *argv[]) } width_g = (int)HDstrtol(s, &rest, 0); - if(0 == width_g) { + if (0 == width_g) { no_line_wrap_g = TRUE; } - else if(width_g < 0 || *rest) { + else if (width_g < 0 || *rest) { usage(); leave(EXIT_FAILURE); } - } else if (!HDstrncmp(argv[argno], "--s3-cred=", (size_t)10)) { #ifdef H5_HAVE_ROS3_VFD @@ -2817,7 +2851,8 @@ main(int argc, const char *argv[]) start = strchr(argv[argno], '='); if (start == NULL) { - HDfprintf(rawerrorstream, "Error: Unable to parse null credentials tuple\n" + HDfprintf(rawerrorstream, + "Error: Unable to parse null credentials tuple\n" " For anonymous access, omit \"--s3-cred\" and use only \"--vfd=ros3\"\n\n"); usage(); leave(EXIT_FAILURE); @@ -2839,8 +2874,8 @@ main(int argc, const char *argv[]) #ifdef H5_HAVE_LIBHDFS char const *start = NULL; - start = argv[argno]+13; /* should never segfault: worst case of */ - if (*start != '(') { /* null-termintor after '='. */ + start = argv[argno] + 13; /* should never segfault: worst case of */ + if (*start != '(') { /* null-termintor after '='. */ usage(); leave(EXIT_FAILURE); } @@ -2856,10 +2891,10 @@ main(int argc, const char *argv[]) leave(EXIT_FAILURE); #endif } - else if('-'!=argv[argno][1]) { + else if ('-' != argv[argno][1]) { /* Single-letter switches */ - for(s = argv[argno] + 1; *s; s++) { - switch(*s) { + for (s = argv[argno] + 1; *s; s++) { + switch (*s) { case '?': case 'h': /* --help */ usage(); @@ -2901,7 +2936,7 @@ main(int argc, const char *argv[]) case 'r': /* --recursive */ recursive_g = TRUE; - fullname_g = TRUE; + fullname_g = TRUE; break; case 'S': /* --simple */ @@ -2929,7 +2964,7 @@ main(int argc, const char *argv[]) usage(); leave(EXIT_FAILURE); } /* end switch */ - } /* end for */ + } /* end for */ } else { HDfprintf(stderr, "Unknown argument: %s\n", argv[argno]); @@ -2949,8 +2984,8 @@ main(int argc, const char *argv[]) } /* end if */ if (vfd_swmr_poll_g && argc > 1 + argno) { - HDfprintf(rawerrorstream, "Error: -p / --poll is limited to only one file[/OBJECT]\n\n"); - leave(EXIT_FAILURE); + HDfprintf(rawerrorstream, "Error: -p / --poll is limited to only one file[/OBJECT]\n\n"); + leave(EXIT_FAILURE); } /* Check for conflicting arguments */ if (!is_valid_args()) { @@ -2982,24 +3017,24 @@ main(int argc, const char *argv[]) * chops off the last component. If we reach the beginning of the name * then there must have been something wrong with the file (perhaps it * doesn't exist). */ - show_file_name_g = (argc-argno > 1); /*show file names if more than one*/ - while(argno < argc) { - H5L_info2_t li; - iter_t iter; + show_file_name_g = (argc - argno > 1); /*show file names if more than one*/ + while (argno < argc) { + H5L_info2_t li; + iter_t iter; symlink_trav_t symlink_list; - size_t u; + size_t u; - fname = HDstrdup(argv[argno++]); - oname = NULL; + fname = HDstrdup(argv[argno++]); + oname = NULL; file_id = H5I_INVALID_HID; while (fname && *fname) { if (preferred_driver) { h5tools_vfd_info_t vfd_info; - vfd_info.info = NULL; - vfd_info.name = preferred_driver; - vfd_info.fname = fname; + vfd_info.info = NULL; + vfd_info.name = preferred_driver; + vfd_info.fname = fname; if (!HDstrcmp(preferred_driver, drivernames[ROS3_VFD_IDX])) { #ifdef H5_HAVE_ROS3_VFD @@ -3024,17 +3059,18 @@ main(int argc, const char *argv[]) } } - file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, - (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, drivername, sizeof drivername); + file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, + drivername, sizeof drivername); if (file_id >= 0) { if (verbose_g) PRINTSTREAM(rawoutstream, "Opened \"%s\" with %s driver.\n", fname, drivername); break; /*success*/ - } else if (vfd_swmr_poll_g) + } + else if (vfd_swmr_poll_g) break; /* Shorten the file name; lengthen the object name */ - x = oname; + x = oname; oname = HDstrrchr(fname, '/'); if (x) *x = '/'; @@ -3044,7 +3080,7 @@ main(int argc, const char *argv[]) } /* end while */ if (file_id < 0) { - HDfprintf(rawerrorstream, "%s: unable to open file\n", argv[argno-1]); + HDfprintf(rawerrorstream, "%s: unable to open file\n", argv[argno - 1]); HDfree(fname); err_exit = 1; continue; @@ -3052,9 +3088,9 @@ main(int argc, const char *argv[]) if (oname) { /* Always use absolute paths to avoid confusion, keep track of where * to begin path name output */ - *oname = '/'; + *oname = '/'; iter.base_len = HDstrlen(oname); - iter.base_len -= oname[iter.base_len-1] == '/'; + iter.base_len -= oname[iter.base_len - 1] == '/'; x = oname; if (NULL == (oname = HDstrdup(oname))) { HDfprintf(rawerrorstream, "memory allocation failed\n"); @@ -3069,49 +3105,50 @@ main(int argc, const char *argv[]) oname = root_name; if (recursive_g) display_root_g = TRUE; - iter.base_len = 0; + iter.base_len = 0; iter.name_start = 0; /* Use x to remember if we have allocated space in oname */ x = NULL; } /* end if */ /* Remember the file information for later */ - iter.fname = fname; - iter.fid = file_id; - iter.gid = H5I_INVALID_HID; - iter.symlink_target = FALSE; - iter.symlink_list = &symlink_list; + iter.fname = fname; + iter.fid = file_id; + iter.gid = H5I_INVALID_HID; + iter.symlink_target = FALSE; + iter.symlink_list = &symlink_list; iter.symlink_list->dangle_link = FALSE; /* Initialize list of visited symbolic links */ symlink_list.nused = symlink_list.nalloc = 0; - symlink_list.objs = NULL; + symlink_list.objs = NULL; /* Check for root group as object name */ if (HDstrcmp(oname, root_name)) { /* Check the type of link given */ if (H5Lget_info2(file_id, oname, &li, H5P_DEFAULT) < 0) { - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *info = &ls_dataformat; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t * info = &ls_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); HDmemset(&buffer, 0, sizeof(h5tools_str_t)); h5tools_str_reset(&buffer); print_obj_name(&buffer, &iter, oname, "**NOT FOUND**"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, + (hsize_t)0, (hsize_t)0); leave(EXIT_FAILURE); } /* end if */ - } /* end if */ + } /* end if */ else li.type = H5L_TYPE_HARD; for (times = 0; vfd_swmr_poll_g || times < 1; times++) { if (vfd_swmr_poll_g) { int i; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) printf("\n"); } /* Open the object and display it's information */ @@ -3167,4 +3204,3 @@ main(int argc, const char *argv[]) else leave(EXIT_SUCCESS); } /* end main() */ - diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index b2cb02b..395b66b 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -22,10 +22,10 @@ *------------------------------------------------------------------------- */ -static int check_options(pack_opt_t *options); -static int check_objects(const char* fname, pack_opt_t *options); -static const char* get_sfilter(H5Z_filter_t filtn); -static int have_request(pack_opt_t *options); +static int check_options(pack_opt_t *options); +static int check_objects(const char *fname, pack_opt_t *options); +static const char *get_sfilter(H5Z_filter_t filtn); +static int have_request(pack_opt_t *options); /*------------------------------------------------------------------------- * Function: h5repack @@ -42,7 +42,7 @@ static int have_request(pack_opt_t *options); *------------------------------------------------------------------------- */ int -h5repack(const char* infile, const char* outfile, pack_opt_t *options) +h5repack(const char *infile, const char *outfile, pack_opt_t *options) { /* check input */ if (check_options(options) < 0) @@ -73,17 +73,17 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest) int k, n; HDmemset(options, 0, sizeof(pack_opt_t)); - options->min_comp = 0; - options->verbose = verbose; - options->latest = latest; - options->layout_g = H5D_LAYOUT_ERROR; - options->low_bound = H5F_LIBVER_EARLIEST; + options->min_comp = 0; + options->verbose = verbose; + options->latest = latest; + options->layout_g = H5D_LAYOUT_ERROR; + options->low_bound = H5F_LIBVER_EARLIEST; options->high_bound = H5F_LIBVER_LATEST; - options->fin_fapl = H5P_DEFAULT; - options->fout_fapl = H5P_DEFAULT; + options->fin_fapl = H5P_DEFAULT; + options->fout_fapl = H5P_DEFAULT; for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) { - options->filter_g[n].filtn = -1; + options->filter_g[n].filtn = -1; options->filter_g[n].cd_nelmts = 0; for (k = 0; k < CD_VALUES; k++) options->filter_g[n].cd_values[k] = 0; @@ -117,7 +117,7 @@ h5repack_end(pack_opt_t *options) int h5repack_addfilter(const char *str, pack_opt_t *options) { - obj_list_t *obj_list = NULL; /* one object list for the -f and -l option entry */ + obj_list_t * obj_list = NULL; /* one object list for the -f and -l option entry */ filter_info_t filter; /* filter info for the current -f option entry */ unsigned n_objs; /* number of objects in the current -f or -l option entry */ int is_glb; /* is the filter global */ @@ -166,7 +166,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options) init_packobject(&pack); if (options->all_layout == 1) { - error_msg( "invalid layout input: 'all' option is present with other objects <%s>\n", str); + error_msg("invalid layout input: 'all' option is present with other objects <%s>\n", str); return ret_value; } @@ -222,13 +222,14 @@ h5repack_addlayout(const char *str, pack_opt_t *options) *------------------------------------------------------------------------- */ hid_t -copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) +copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, + pack_opt_t *options) { - named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ - named_dt_t *dt_ret = NULL; /* Datatype to return */ - H5O_info2_t oinfo; /* Object info of input dtype */ - int token_cmp; - hid_t ret_value = H5I_INVALID_HID; + named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ + named_dt_t *dt_ret = NULL; /* Datatype to return */ + H5O_info2_t oinfo; /* Object info of input dtype */ + int token_cmp; + hid_t ret_value = H5I_INVALID_HID; if (H5Oget_info3(type_in, &oinfo, H5O_INFO_BASIC) < 0) H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Oget_info failed"); @@ -256,7 +257,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t /* Push onto the stack */ if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed"); - dt->next = *named_dt_head_p; + dt->next = *named_dt_head_p; *named_dt_head_p = dt; /* Update the token/address and id */ @@ -269,8 +270,8 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t if (!token_cmp) dt_ret = dt; } /* end if named datatype */ - } /* end for each object in traversal table */ - } /* end else (create the stack) */ + } /* end for each object in traversal table */ + } /* end else (create the stack) */ /* Handle the case that the requested datatype was not found. This is * possible if the datatype was committed anonymously in the input file. @@ -279,7 +280,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t /* Push the new datatype onto the stack */ if (NULL == (dt_ret = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed"); - dt_ret->next = *named_dt_head_p; + dt_ret->next = *named_dt_head_p; *named_dt_head_p = dt_ret; /* Update the token/address and id */ @@ -323,8 +324,8 @@ done: int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) { - named_dt_t *dt = *named_dt_head_p; - int ret_value = -1; + named_dt_t *dt = *named_dt_head_p; + int ret_value = -1; while (dt) { /* Pop the datatype off the stack and free it */ @@ -355,24 +356,24 @@ done: int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) { - hid_t attr_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr_id = H5I_INVALID_HID; /* attr ID */ hid_t attr_out = H5I_INVALID_HID; /* attr ID */ hid_t space_id = H5I_INVALID_HID; /* space ID */ hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ - size_t msize; /* size of type */ - void *buf = NULL; /* data buffer */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - htri_t is_named; /* Whether the datatype is named */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + size_t msize; /* size of type */ + void * buf = NULL; /* data buffer */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + htri_t is_named; /* Whether the datatype is named */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ char name[255]; - H5O_info2_t oinfo; /* object info */ + H5O_info2_t oinfo; /* object info */ int j; unsigned u; - hbool_t is_ref = 0; + hbool_t is_ref = 0; H5T_class_t type_class = -1; - int ret_value = 0; + int ret_value = 0; if (H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed"); @@ -381,12 +382,13 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ * copy all attributes *------------------------------------------------------------------------- */ - for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { + for (u = 0; u < (unsigned)oinfo.num_attrs; u++) { /* open attribute */ - if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, + H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed"); - if (H5Aget_name(attr_id, (size_t) 255, name) < 0) + if (H5Aget_name(attr_id, (size_t)255, name) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); /* get the file datatype */ @@ -442,12 +444,12 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ *--------------------------------------------------------------------- */ type_class = H5Tget_class(wtype_id); - is_ref = (type_class == H5T_REFERENCE); + is_ref = (type_class == H5T_REFERENCE); if (type_class == H5T_VLEN || type_class == H5T_ARRAY) { hid_t base_type = H5I_INVALID_HID; base_type = H5Tget_super(ftype_id); - is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); + is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); if (H5Tclose(base_type) < 0) H5TOOLS_ERROR((-1), "H5Tclose base_type failed"); } /* end if type_class is variable length or array */ @@ -456,7 +458,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ int nmembers = H5Tget_nmembers(wtype_id); for (j = 0; j < nmembers; j++) { - hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j); + hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j); H5T_class_t mtclass = H5Tget_class(mtid); if (H5Tclose(mtid) < 0) H5TOOLS_ERROR((-1), "H5Tclose mtid failed"); @@ -466,7 +468,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ break; } } /* end for each member */ - } /* end if type_class is H5T_COMPOUND */ + } /* end if type_class is H5T_COMPOUND */ if (!is_ref) { /*----------------------------------------------------------------- @@ -525,7 +527,8 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ } /* for u (each attribute) */ done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (buf) { /* Check if we have VL data and string in the attribute's * datatype that must be reclaimed @@ -542,7 +545,8 @@ done: H5Tclose(wtype_id); H5Tclose(ftype_id); H5Aclose(attr_id); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } /* end copy_attr() */ @@ -571,31 +575,31 @@ check_options(pack_opt_t *options) if (options->all_layout == 1) { HDprintf("All objects to modify layout are...\n"); switch (options->layout_g) { - case H5D_COMPACT: - strcpy(slayout, "compact"); - break; - case H5D_CONTIGUOUS: - strcpy(slayout, "contiguous"); - break; - case H5D_CHUNKED: - strcpy(slayout, "chunked"); - break; - case H5D_VIRTUAL: - strcpy(slayout, "virtual"); - break; - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - H5TOOLS_GOTO_ERROR((-1), "invalid layout"); - break; - default: - strcpy(slayout, "invalid layout\n"); - H5TOOLS_GOTO_DONE((-1)); + case H5D_COMPACT: + strcpy(slayout, "compact"); + break; + case H5D_CONTIGUOUS: + strcpy(slayout, "contiguous"); + break; + case H5D_CHUNKED: + strcpy(slayout, "chunked"); + break; + case H5D_VIRTUAL: + strcpy(slayout, "virtual"); + break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + H5TOOLS_GOTO_ERROR((-1), "invalid layout"); + break; + default: + strcpy(slayout, "invalid layout\n"); + H5TOOLS_GOTO_DONE((-1)); } HDprintf(" Apply %s layout to all", slayout); if (H5D_CHUNKED == options->layout_g) { HDprintf("with dimension [ "); for (j = 0; j < options->chunk_g.rank; j++) - HDprintf("%d ", (int) options->chunk_g.chunk_lengths[j]); + HDprintf("%d ", (int)options->chunk_g.chunk_lengths[j]); HDprintf("]"); } HDprintf("\n"); @@ -605,13 +609,13 @@ check_options(pack_opt_t *options) } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { - char* name = options->op_tbl->objs[i].path; + char *name = options->op_tbl->objs[i].path; if (options->op_tbl->objs[i].chunk.rank > 0) { if (options->verbose) { HDprintf(" <%s> with chunk size ", name); for (k = 0; k < options->op_tbl->objs[i].chunk.rank; k++) - HDprintf("%d ", (int) options->op_tbl->objs[i].chunk.chunk_lengths[k]); + HDprintf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]); HDprintf("\n"); } has_ck = 1; @@ -641,36 +645,38 @@ check_options(pack_opt_t *options) continue; } switch (filtn) { - case H5Z_FILTER_NONE: - HDprintf(" Uncompress all\n"); - break; - case H5Z_FILTER_SHUFFLE: - case H5Z_FILTER_FLETCHER32: - HDprintf(" All with %s\n", get_sfilter(filtn)); - break; - case H5Z_FILTER_SZIP: - case H5Z_FILTER_DEFLATE: - HDprintf(" All with %s, parameter %d\n", get_sfilter(filtn), options->filter_g[k].cd_values[0]); - break; - default: - HDprintf(" User Defined %d\n", filtn); - break; + case H5Z_FILTER_NONE: + HDprintf(" Uncompress all\n"); + break; + case H5Z_FILTER_SHUFFLE: + case H5Z_FILTER_FLETCHER32: + HDprintf(" All with %s\n", get_sfilter(filtn)); + break; + case H5Z_FILTER_SZIP: + case H5Z_FILTER_DEFLATE: + HDprintf(" All with %s, parameter %d\n", get_sfilter(filtn), + options->filter_g[k].cd_values[0]); + break; + default: + HDprintf(" User Defined %d\n", filtn); + break; } /* end switch */ - } /* end for each filter */ - } /* end if options->all_filter == 1 (TODO: meaning) */ + } /* end for each filter */ + } /* end if options->all_filter == 1 (TODO: meaning) */ else HDprintf("No all objects to apply filter\n"); } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { pack_info_t pack = options->op_tbl->objs[i]; - char* name = pack.path; + char * name = pack.path; for (j = 0; j < pack.nfilters; j++) { if (options->verbose) { if (pack.filter[j].filtn >= 0) { if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) { - HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), pack.filter[j].filtn); + HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), + pack.filter[j].filtn); } else { HDprintf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn)); @@ -679,7 +685,7 @@ check_options(pack_opt_t *options) } has_cp = 1; } /* end for each filter */ - } /* end for each object in options table */ + } /* end for each object in options table */ if (options->all_filter == 1 && has_cp) H5TOOLS_GOTO_ERROR((-1), "invalid compression input: 'all' option is present with other objects"); @@ -705,7 +711,8 @@ check_options(pack_opt_t *options) */ if (options->ublock_filename != NULL && options->ublock_size == 0) { if (options->verbose) { - HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename); + HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", + options->ublock_filename); options->ublock_size = 1024; } } @@ -735,14 +742,14 @@ done: *------------------------------------------------------------------------- */ static int -check_objects(const char* fname, pack_opt_t *options) +check_objects(const char *fname, pack_opt_t *options) { hid_t fid = H5I_INVALID_HID; hid_t did = H5I_INVALID_HID; hid_t sid = H5I_INVALID_HID; unsigned int i; int ifil; - trav_table_t *travt = NULL; + trav_table_t *travt = NULL; int ret_value = 0; /* nothing to do */ @@ -754,7 +761,7 @@ check_objects(const char* fname, pack_opt_t *options) *------------------------------------------------------------------------- */ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, options->fin_fapl, - (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0) + (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); /*------------------------------------------------------------------------- @@ -780,8 +787,8 @@ check_objects(const char* fname, pack_opt_t *options) HDprintf("Opening file. Searching %zu objects to modify ...\n", travt->nobjs); for (i = 0; i < options->op_tbl->nelems; i++) { - pack_info_t obj = options->op_tbl->objs[i]; - char* name = obj.path; + pack_info_t obj = options->op_tbl->objs[i]; + char * name = obj.path; if (options->verbose) HDprintf(" <%s>", name); @@ -789,7 +796,7 @@ check_objects(const char* fname, pack_opt_t *options) /* the input object names are present in the file and are valid */ if (h5trav_getindext(name, travt) < 0) H5TOOLS_GOTO_ERROR((-1), "%s Could not find <%s> in file <%s>. Exiting...\n", - (options->verbose ? "\n" : ""), name, fname); + (options->verbose ? "\n" : ""), name, fname); if (options->verbose) HDprintf("...Found\n"); @@ -798,14 +805,13 @@ check_objects(const char* fname, pack_opt_t *options) H5TOOLS_GOTO_ERROR((-1), "invalid filter"); /* check for extra filter conditions */ switch (obj.filter[ifil].filtn) { - /* chunk size must be smaller than pixels per block */ - case H5Z_FILTER_SZIP: - { - int j; - hsize_t csize = 1; - unsigned ppb = obj.filter[ifil].cd_values[0]; - hsize_t dims[H5S_MAX_RANK]; - int rank; + /* chunk size must be smaller than pixels per block */ + case H5Z_FILTER_SZIP: { + int j; + hsize_t csize = 1; + unsigned ppb = obj.filter[ifil].cd_values[0]; + hsize_t dims[H5S_MAX_RANK]; + int rank; if (obj.chunk.rank > 0) { rank = obj.chunk.rank; @@ -836,18 +842,20 @@ check_objects(const char* fname, pack_opt_t *options) } } /* end case SZIP */ break; - default: - break; + default: + break; } /* end switch */ - } /* for ifil (each user-defined filter) */ - } /* for i (each object in options traversal table) */ + } /* for ifil (each user-defined filter) */ + } /* for i (each object in options traversal table) */ done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; if (travt) trav_table_free(travt); return ret_value; @@ -901,4 +909,3 @@ get_sfilter(H5Z_filter_t filtn) else return "UD"; } /* end get_sfilter() */ - diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h index caa1166..e62e4a0 100644 --- a/tools/src/h5repack/h5repack.h +++ b/tools/src/h5repack/h5repack.h @@ -11,7 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #ifndef H5REPACK_H__ #define H5REPACK_H__ @@ -19,21 +18,20 @@ #include "hdf5.h" #include "h5trav.h" -#define H5FOPENERROR "unable to open file" -#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/ -#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/ -#define MAX_NC_NAME 256 /* max length of a name */ -#define MAX_VAR_DIMS 32 /* max per variable dimensions */ -#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */ -#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ -#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */ +#define H5FOPENERROR "unable to open file" +#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/ +#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/ +#define MAX_NC_NAME 256 /* max length of a name */ +#define MAX_VAR_DIMS 32 /* max per variable dimensions */ +#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */ +#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ +#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */ /* File space default information */ -#define FS_PAGESIZE_DEF 4096 -#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR -#define FS_PERSIST_DEF FALSE -#define FS_THRESHOLD_DEF 1 - +#define FS_PAGESIZE_DEF 4096 +#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR +#define FS_PERSIST_DEF FALSE +#define FS_THRESHOLD_DEF 1 /*------------------------------------------------------------------------- * data structures for command line options @@ -42,7 +40,7 @@ /* a list of names */ typedef struct { - char obj[MAX_NC_NAME]; + char obj[MAX_NC_NAME]; } obj_list_t; /* @@ -60,16 +58,16 @@ typedef struct { #define CD_VALUES 20 typedef struct { - H5Z_filter_t filtn; /* filter identification number */ - unsigned filt_flag; /* filter definition flag */ - unsigned cd_values[CD_VALUES]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ + H5Z_filter_t filtn; /* filter identification number */ + unsigned filt_flag; /* filter definition flag */ + unsigned cd_values[CD_VALUES]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ } filter_info_t; /* chunk lengths along each dimension and rank */ typedef struct { - hsize_t chunk_lengths[MAX_VAR_DIMS]; - int rank; + hsize_t chunk_lengths[MAX_VAR_DIMS]; + int rank; } chunk_info_t; /* we currently define a maximum value for the filters array, @@ -78,22 +76,21 @@ typedef struct { /* information for one object, contains PATH, CHUNK info and FILTER info */ typedef struct { - char path[MAX_NC_NAME]; /* name of object */ - filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */ - int nfilters; /* current number of filters */ - H5D_layout_t layout; /* layout information */ - chunk_info_t chunk; /* chunk information */ - hid_t refobj_id; /* object ID, references */ + char path[MAX_NC_NAME]; /* name of object */ + filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */ + int nfilters; /* current number of filters */ + H5D_layout_t layout; /* layout information */ + chunk_info_t chunk; /* chunk information */ + hid_t refobj_id; /* object ID, references */ } pack_info_t; /* store a table of all objects */ typedef struct { - unsigned int size; - unsigned int nelems; - pack_info_t *objs; + unsigned int size; + unsigned int nelems; + pack_info_t *objs; } pack_opttbl_t; - /*------------------------------------------------------------------------- * command line options *------------------------------------------------------------------------- @@ -101,41 +98,40 @@ typedef struct { /* all the above, ready to go to the hrepack call */ typedef struct { - pack_opttbl_t *op_tbl; /*table with all -c and -f options */ - int all_layout; /*apply the layout to all objects */ - int all_filter; /*apply the filter to all objects */ - filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */ - int n_filter_g; /*number of global filters */ - chunk_info_t chunk_g; /*global chunk INFO for the ALL case */ - H5D_layout_t layout_g; /*global layout information for the ALL case */ - int verbose; /*verbose mode */ - hsize_t min_comp; /*minimum size to compress, in bytes */ - int use_native; /*use a native type in write */ - hbool_t latest; /*pack file with the latest file format */ - H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */ - H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */ - hid_t fin_fapl; /* FAPL to use for opening the input file */ - hid_t fout_fapl; /* FAPL to use for opening/creating the output file */ - int grp_compact; /* Set the maximum number of links to store as header messages in the group */ - int grp_indexed; /* Set the minimum number of links to store in the indexed format */ - int msg_size[8]; /* Minimum size of shared messages: dataspace, - datatype, fill value, filter pipleline, attribute */ - const char *ublock_filename; /* user block file name */ - hsize_t ublock_size; /* user block size */ - hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */ - hsize_t threshold; /* alignment threshold for H5Pset_alignment */ - hsize_t alignment; /* alignment for H5Pset_alignment */ - H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ - int fs_persist; /* Free space section threshold */ - long fs_threshold; /* Free space section threshold */ - long long fs_pagesize; /* File space page size */ + pack_opttbl_t *op_tbl; /*table with all -c and -f options */ + int all_layout; /*apply the layout to all objects */ + int all_filter; /*apply the filter to all objects */ + filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */ + int n_filter_g; /*number of global filters */ + chunk_info_t chunk_g; /*global chunk INFO for the ALL case */ + H5D_layout_t layout_g; /*global layout information for the ALL case */ + int verbose; /*verbose mode */ + hsize_t min_comp; /*minimum size to compress, in bytes */ + int use_native; /*use a native type in write */ + hbool_t latest; /*pack file with the latest file format */ + H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */ + H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */ + hid_t fin_fapl; /* FAPL to use for opening the input file */ + hid_t fout_fapl; /* FAPL to use for opening/creating the output file */ + int grp_compact; /* Set the maximum number of links to store as header messages in the group */ + int grp_indexed; /* Set the minimum number of links to store in the indexed format */ + int msg_size[8]; /* Minimum size of shared messages: dataspace, + datatype, fill value, filter pipleline, attribute */ + const char * ublock_filename; /* user block file name */ + hsize_t ublock_size; /* user block size */ + hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */ + hsize_t threshold; /* alignment threshold for H5Pset_alignment */ + hsize_t alignment; /* alignment for H5Pset_alignment */ + H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ + int fs_persist; /* Free space section threshold */ + long fs_threshold; /* Free space section threshold */ + long long fs_pagesize; /* File space page size */ } pack_opt_t; - typedef struct named_dt_t { - H5O_token_t obj_token; /* Object token for the named dtype in the in file */ - hid_t id_out; /* Open identifier for the dtype in the out file */ - struct named_dt_t *next; /* Next dtype */ + H5O_token_t obj_token; /* Object token for the named dtype in the in file */ + hid_t id_out; /* Open identifier for the dtype in the out file */ + struct named_dt_t *next; /* Next dtype */ } named_dt_t; /*------------------------------------------------------------------------- @@ -147,9 +143,9 @@ typedef struct named_dt_t { extern "C" { #endif -int h5repack(const char* infile, const char* outfile, pack_opt_t *options); -int h5repack_addfilter(const char* str, pack_opt_t *options); -int h5repack_addlayout(const char* str, pack_opt_t *options); +int h5repack(const char *infile, const char *outfile, pack_opt_t *options); +int h5repack_addfilter(const char *str, pack_opt_t *options); +int h5repack_addlayout(const char *str, pack_opt_t *options); int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest); int h5repack_end(pack_opt_t *options); int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options); @@ -162,36 +158,29 @@ int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, h * However copy_attr() may be obsoleted when H5Acopy is available and put back * others to static in h5repack_copy.c. */ -hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options); -int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err); -int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, - trav_table_t *travt, pack_opt_t *options); +hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, + pack_opt_t *options); +int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err); +int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, + pack_opt_t *options); #ifdef __cplusplus } #endif - - /*------------------------------------------------------------------------- * private functions *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * copy module *------------------------------------------------------------------------- */ -int copy_objects (const char* fnamein, - const char* fnameout, - pack_opt_t *options); +int copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options); -int do_copy_refobjs(hid_t fidin, - hid_t fidout, - trav_table_t *travt, - pack_opt_t *options); +int do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options); /*------------------------------------------------------------------------- * filters and verify module @@ -199,56 +188,38 @@ int do_copy_refobjs(hid_t fidin, */ void init_packobject(pack_info_t *obj); - /*------------------------------------------------------------------------- * filters and copy module *------------------------------------------------------------------------- */ -int apply_filters(const char* name, /* object name from traverse list */ - int rank, /* rank of dataset */ - hsize_t *dims, /* dimensions of dataset */ - size_t msize, /* size of type */ - hid_t dcpl_id, /* dataset creation property list */ +int apply_filters(const char *name, /* object name from traverse list */ + int rank, /* rank of dataset */ + hsize_t * dims, /* dimensions of dataset */ + size_t msize, /* size of type */ + hid_t dcpl_id, /* dataset creation property list */ pack_opt_t *options, /* repack options */ - int *has_filter); /* (OUT) object NAME has a filter */ - + int * has_filter); /* (OUT) object NAME has a filter */ /*------------------------------------------------------------------------- * options table *------------------------------------------------------------------------- */ -int options_table_init(pack_opttbl_t **tbl); -int options_table_free(pack_opttbl_t *table); -int options_add_layout(obj_list_t *obj_list, - unsigned n_objs, - pack_info_t *pack, - pack_opttbl_t *table); -int options_add_filter(obj_list_t *obj_list, - unsigned n_objs, - filter_info_t filt, - pack_opttbl_t *table); -pack_info_t* options_get_object(const char *path, - pack_opttbl_t *table); +int options_table_init(pack_opttbl_t **tbl); +int options_table_free(pack_opttbl_t *table); +int options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table); +int options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pack_opttbl_t *table); +pack_info_t *options_get_object(const char *path, pack_opttbl_t *table); /*------------------------------------------------------------------------- * parse functions *------------------------------------------------------------------------- */ -obj_list_t* parse_filter(const char *str, - unsigned *n_objs, - filter_info_t *filt, - pack_opt_t *options, +obj_list_t *parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb); -obj_list_t* parse_layout(const char *str, - unsigned *n_objs, - pack_info_t *pack, /* info about object */ +obj_list_t *parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about object */ pack_opt_t *options); - - - -#endif /* H5REPACK_H__ */ - +#endif /* H5REPACK_H__ */ diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index b1d6ab4..3e438a1 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -31,24 +31,21 @@ */ /* size of buffer/# of bytes to xfer at a time when copying userblock */ -#define USERBLOCK_XFER_SIZE 512 +#define USERBLOCK_XFER_SIZE 512 /*------------------------------------------------------------------------- * local functions *------------------------------------------------------------------------- */ -static int get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], - size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p); +static int get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], size_t size_datum, + hsize_t dims_hslab[], hsize_t *hslab_nbytes_p); static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr); -static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, - pack_opt_t *options); -static int copy_user_block(const char *infile, const char *outfile, - hsize_t size); -#if defined (H5REPACK_DEBUG_USER_BLOCK) +static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options); +static int copy_user_block(const char *infile, const char *outfile, hsize_t size); +#if defined(H5REPACK_DEBUG_USER_BLOCK) static void print_user_block(const char *filename, hid_t fid); #endif - /*------------------------------------------------------------------------- * Function: copy_objects * @@ -59,33 +56,33 @@ static void print_user_block(const char *filename, hid_t fid); *------------------------------------------------------------------------- */ int -copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) +copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options) { - hid_t fidin = H5I_INVALID_HID; - hid_t fidout = H5I_INVALID_HID; - hid_t fcpl_in = H5I_INVALID_HID; /* file creation property list ID for input file */ - hid_t grp_in = H5I_INVALID_HID; /* group ID */ - hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */ - hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ - trav_table_t *travt = NULL; - hsize_t ub_size = 0; /* size of user block */ - H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */ - hbool_t set_persist; /* Persist free-space status to be set in output file */ - hsize_t set_threshold; /* Free-space section threshold to be set in output file */ - hsize_t set_pagesize; /* File space page size to be set in output file */ - H5F_fspace_strategy_t in_strategy; /* Strategy from input file */ - hbool_t in_persist; /* Persist free-space status from input file */ - hsize_t in_threshold; /* Free-space section threshold from input file */ - hsize_t in_pagesize; /* File space page size from input file */ - unsigned crt_order_flags; /* group creation order flag */ - int ret_value = 0; + hid_t fidin = H5I_INVALID_HID; + hid_t fidout = H5I_INVALID_HID; + hid_t fcpl_in = H5I_INVALID_HID; /* file creation property list ID for input file */ + hid_t grp_in = H5I_INVALID_HID; /* group ID */ + hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */ + hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ + trav_table_t * travt = NULL; + hsize_t ub_size = 0; /* size of user block */ + H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */ + hbool_t set_persist; /* Persist free-space status to be set in output file */ + hsize_t set_threshold; /* Free-space section threshold to be set in output file */ + hsize_t set_pagesize; /* File space page size to be set in output file */ + H5F_fspace_strategy_t in_strategy; /* Strategy from input file */ + hbool_t in_persist; /* Persist free-space status from input file */ + hsize_t in_threshold; /* Free-space section threshold from input file */ + hsize_t in_pagesize; /* File space page size from input file */ + unsigned crt_order_flags; /* group creation order flag */ + int ret_value = 0; /*------------------------------------------------------------------------- * open input file *------------------------------------------------------------------------- */ if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, options->fin_fapl, - (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t) 0)) < 0) + (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t)0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR); /* get user block size and file space strategy/persist/threshold */ @@ -97,11 +94,11 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) H5TOOLS_GOTO_ERROR((-1), "H5Pget_userblock failed to retrieve userblock size"); /* If the -S option is not set, get "strategy" from the input file */ - if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) + if (H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy"); /* If the -G option is not set, get "pagesize" from the input file */ - if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) + if (H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space threshold"); /* open root group */ @@ -120,7 +117,7 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed to close property list"); } - if(options->latest) + if (options->latest) options->low_bound = options->high_bound = H5F_LIBVER_LATEST; /* Create file access property list */ @@ -129,7 +126,7 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); /* It can be default, latest or other settings by users */ - if(H5Pset_libver_bounds(options->fout_fapl, options->low_bound, options->high_bound) < 0) + if (H5Pset_libver_bounds(options->fout_fapl, options->low_bound, options->high_bound) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_libver_bounds failed to set format version bounds"); /* Check if we need to create a non-default file creation property list */ @@ -147,8 +144,11 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) /* Adjust group creation parameters for root group */ /* (So that it is created in "dense storage" form) */ - if (H5Pset_link_phase_change(fcpl, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed to adjust group creation parameters for root group"); + if (H5Pset_link_phase_change(fcpl, (unsigned)options->grp_compact, + (unsigned)options->grp_indexed) < 0) + H5TOOLS_GOTO_ERROR( + (-1), + "H5Pset_link_phase_change failed to adjust group creation parameters for root group"); for (i = 0; i < 5; i++) { if (options->msg_size[i] > 0) { @@ -176,26 +176,28 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) default: break; } /* end switch */ - min_mesg_sizes[nindex] = (unsigned) options->msg_size[i]; + min_mesg_sizes[nindex] = (unsigned)options->msg_size[i]; nindex++; } /* end if */ - } /* end for */ + } /* end for */ if (nindex > 0) { if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_nindexes failed to set the number of shared object header message indexes"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_nindexes failed to set the number of shared " + "object header message indexes"); /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */ for (i = 0; i < (nindex - 1); i++) if (H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_index failed to configure the specified shared object header message index"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_index failed to configure the specified " + "shared object header message index"); } /* if (nindex>0) */ } /* end if */ - } /* end if */ -#if defined (H5REPACK_DEBUG_USER_BLOCK) -print_user_block(fnamein, fidin); + } /* end if */ +#if defined(H5REPACK_DEBUG_USER_BLOCK) + print_user_block(fnamein, fidin); #endif /*------------------------------------------------------------------------- @@ -255,41 +257,41 @@ print_user_block(fnamein, fidin); if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list"); - if(H5Pset_link_creation_order(fcpl, crt_order_flags ) < 0) + if (H5Pset_link_creation_order(fcpl, crt_order_flags) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed"); /* Set file space info to those from input file */ - set_strategy = in_strategy; - set_persist = in_persist; + set_strategy = in_strategy; + set_persist = in_persist; set_threshold = in_threshold; - set_pagesize = in_pagesize; + set_pagesize = in_pagesize; - if(options->fs_strategy == (H5F_fspace_strategy_t)-1) /* A default strategy is specified by user */ + if (options->fs_strategy == (H5F_fspace_strategy_t)-1) /* A default strategy is specified by user */ set_strategy = FS_STRATEGY_DEF; - else if(options->fs_strategy != (H5F_fspace_strategy_t)0) /* Set strategy as specified by user */ + else if (options->fs_strategy != (H5F_fspace_strategy_t)0) /* Set strategy as specified by user */ set_strategy = options->fs_strategy; - if(options->fs_persist == -1) /* A default "persist" is specified by user */ + if (options->fs_persist == -1) /* A default "persist" is specified by user */ set_persist = FS_PERSIST_DEF; - else if(options->fs_persist != 0) /* Set "persist" as specified by user */ + else if (options->fs_persist != 0) /* Set "persist" as specified by user */ set_persist = (hbool_t)options->fs_persist; - if(options->fs_threshold == -1) /* A "0" threshold is specified by user */ + if (options->fs_threshold == -1) /* A "0" threshold is specified by user */ set_threshold = (hsize_t)0; - else if(options->fs_threshold != 0) /* Set threshold as specified by user */ + else if (options->fs_threshold != 0) /* Set threshold as specified by user */ set_threshold = (hsize_t)options->fs_threshold; /* Set file space information as specified */ - if(H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0) + if (H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_file_space_strategy failed to set file space strategy"); - if(options->fs_pagesize == -1) /* A "0" file space page size is specified by user */ + if (options->fs_pagesize == -1) /* A "0" file space page size is specified by user */ set_pagesize = (hsize_t)0; - else if(options->fs_pagesize != 0) /* Set file space page size as specified by user */ + else if (options->fs_pagesize != 0) /* Set file space page size as specified by user */ set_pagesize = (hsize_t)options->fs_pagesize; - if(set_pagesize != FS_PAGESIZE_DEF) /* Set non-default file space page size as specified */ - if(H5Pset_file_space_page_size(fcpl, set_pagesize) < 0) + if (set_pagesize != FS_PAGESIZE_DEF) /* Set non-default file space page size as specified */ + if (H5Pset_file_space_page_size(fcpl, set_pagesize) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_file_space_page_size failed to set file space page size"); /*------------------------------------------------------------------------- @@ -326,19 +328,21 @@ print_user_block(fnamein, fidin); H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); /*------------------------------------------------------------------------- - * do the copy - *------------------------------------------------------------------------- - */ + * do the copy + *------------------------------------------------------------------------- + */ if (do_copy_objects(fidin, fidout, travt, options) < 0) - H5TOOLS_GOTO_ERROR((-1), "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout); + H5TOOLS_GOTO_ERROR((-1), "do_copy_objects from <%s> could not copy data to <%s>", fnamein, + fnameout); /*------------------------------------------------------------------------- - * do the copy of referenced objects - * and create hard links - *------------------------------------------------------------------------- - */ + * do the copy of referenced objects + * and create hard links + *------------------------------------------------------------------------- + */ if (do_copy_refobjs(fidin, fidout, travt, options) < 0) - H5TOOLS_GOTO_ERROR((-1), "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout); + H5TOOLS_GOTO_ERROR((-1), "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, + fnameout); } /*------------------------------------------------------------------------- @@ -351,7 +355,8 @@ print_user_block(fnamein, fidin); H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting..."); done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl_in); H5Pclose(gcpl_in); H5Pclose(fcpl); @@ -360,7 +365,8 @@ done: H5Fclose(fidout); H5Fclose(fidin); H5Fclose(fidout); - } H5E_END_TRY; + } + H5E_END_TRY; if (travt) trav_table_free(travt); @@ -400,20 +406,20 @@ done: *-----------------------------------------*/ int -get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], - size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p) +get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], size_t size_datum, hsize_t dims_hslab[], + hsize_t *hslab_nbytes_p) { - int k; + int k; H5D_layout_t dset_layout; - int rank_chunk; - hsize_t dims_chunk[H5S_MAX_RANK]; - hsize_t size_chunk = 1; - hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ - hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ - hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */ - hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */ - hsize_t hslab_nbytes; /* size of hyperslab in byte */ - int ret_value = 0; + int rank_chunk; + hsize_t dims_chunk[H5S_MAX_RANK]; + hsize_t size_chunk = 1; + hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ + hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ + hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */ + hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */ + hsize_t hslab_nbytes; /* size of hyperslab in byte */ + int ret_value = 0; /* init to set as size of a data element */ hslab_nbytes = size_datum; @@ -452,7 +458,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], chunk_dims_map[k - 1]++; /* get mapped hyperslab dims */ - hs_dims_map[k - 1] = MIN (nchunk_fit, chunk_dims_map[k-1]); + hs_dims_map[k - 1] = MIN(nchunk_fit, chunk_dims_map[k - 1]); /* prepare next round */ nchunk_fit = nchunk_fit / chunk_dims_map[k - 1]; @@ -461,7 +467,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], nchunk_fit = 1; /* get hyperslab dimentions as unmapping to actual size */ - dims_hslab[k - 1] = MIN( (hs_dims_map[k-1] * dims_chunk[k-1]), dims_dset[k-1]); + dims_hslab[k - 1] = MIN((hs_dims_map[k - 1] * dims_chunk[k - 1]), dims_dset[k - 1]); /* calculate total size for the hyperslab */ hslab_nbytes *= dims_hslab[k - 1]; @@ -482,7 +488,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], if (ndatum_fit == 0) ndatum_fit = 1; /* get hyperslab dimentions within a chunk boundary */ - dims_hslab[k - 1] = MIN (dims_chunk[k-1], ndatum_fit); + dims_hslab[k - 1] = MIN(dims_chunk[k - 1], ndatum_fit); /* calculate total size for the hyperslab */ hslab_nbytes *= dims_hslab[k - 1]; @@ -578,46 +584,45 @@ done: */ int -do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, - pack_opt_t *options) /* repack options */ +do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - hid_t grp_in = H5I_INVALID_HID; /* group ID */ - hid_t grp_out = H5I_INVALID_HID; /* group ID */ - hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */ - hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */ - hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */ - hid_t gcpl_out = H5I_INVALID_HID; /* group creation property list */ - hid_t type_in = H5I_INVALID_HID; /* named type ID */ - hid_t type_out = H5I_INVALID_HID; /* named type ID */ - hid_t dcpl_in = H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t dcpl_out = H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t f_space_id = H5I_INVALID_HID; /* file space ID */ - hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ - hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ - named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ - size_t msize; /* size of type */ - hsize_t nelmts; /* number of elements in dataset */ - H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */ - int rank; /* rank of dataset */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ - hsize_t dsize_in; /* input dataset size before filter */ - hsize_t dsize_out; /* output dataset size after filter */ - int apply_s; /* flag for apply filter to small dataset sizes */ - int apply_f; /* flag for apply filter to return error on H5Dcreate */ - void *buf = NULL; /* buffer for raw data */ - void *hslab_buf = NULL; /* hyperslab buffer for raw data */ - int has_filter; /* current object has a filter */ - int req_filter; /* there was a request for a filter */ - int req_obj_layout = 0; /* request layout to current object */ - unsigned crt_order_flags; /* group creation order flag */ - unsigned i; - unsigned u; - int ifil; - int is_ref = 0; - htri_t is_named; - hbool_t limit_maxdims; - hsize_t size_dset; - int ret_value = 0; + hid_t grp_in = H5I_INVALID_HID; /* group ID */ + hid_t grp_out = H5I_INVALID_HID; /* group ID */ + hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */ + hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */ + hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */ + hid_t gcpl_out = H5I_INVALID_HID; /* group creation property list */ + hid_t type_in = H5I_INVALID_HID; /* named type ID */ + hid_t type_out = H5I_INVALID_HID; /* named type ID */ + hid_t dcpl_in = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t dcpl_out = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t f_space_id = H5I_INVALID_HID; /* file space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ + hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ + named_dt_t * named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ + size_t msize; /* size of type */ + hsize_t nelmts; /* number of elements in dataset */ + H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */ + int rank; /* rank of dataset */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ + hsize_t dsize_in; /* input dataset size before filter */ + hsize_t dsize_out; /* output dataset size after filter */ + int apply_s; /* flag for apply filter to small dataset sizes */ + int apply_f; /* flag for apply filter to return error on H5Dcreate */ + void * buf = NULL; /* buffer for raw data */ + void * hslab_buf = NULL; /* hyperslab buffer for raw data */ + int has_filter; /* current object has a filter */ + int req_filter; /* there was a request for a filter */ + int req_obj_layout = 0; /* request layout to current object */ + unsigned crt_order_flags; /* group creation order flag */ + unsigned i; + unsigned u; + int ifil; + int is_ref = 0; + htri_t is_named; + hbool_t limit_maxdims; + hsize_t size_dset; + int ret_value = 0; /*------------------------------------------------------------------------- * copy the supplied object list @@ -633,613 +638,638 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (travt->objs) { for (i = 0; i < travt->nobjs; i++) { /* init variables per obj */ - buf = NULL; + buf = NULL; limit_maxdims = FALSE; switch (travt->objs[i].type) { - case H5TRAV_TYPE_UNKNOWN: - break; + case H5TRAV_TYPE_UNKNOWN: + break; - /*------------------------------------------------------------------------- - * H5TRAV_TYPE_GROUP - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_GROUP: - if (options->verbose) - HDprintf(FORMAT_OBJ, "group", travt->objs[i].name); - - /* open input group */ - if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); - - /* get input group creation property list */ - if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); - - /* query and set the group creation properties */ - if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); - - /* set up group creation property list */ - if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); - - if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed"); + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_GROUP + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_GROUP: + if (options->verbose) + HDprintf(FORMAT_OBJ, "group", travt->objs[i].name); - /*------------------------------------------------------------------------- - * the root is a special case, we get an ID for the root group - * and copy its attributes using that ID - *------------------------------------------------------------------------- - */ - if (HDstrcmp(travt->objs[i].name, "/") == 0) { - if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0) + /* open input group */ + if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); - } - else { - if (options->grp_compact > 0 || options->grp_indexed > 0) - if (H5Pset_link_phase_change(gcpl_out, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed"); - - if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Gcreate2 failed"); - } - /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ - if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - - if (H5Pclose(gcpl_out) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - if (H5Pclose(gcpl_in) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - if (H5Gclose(grp_out) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); - if (H5Gclose(grp_in) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); + /* get input group creation property list */ + if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); - break; + /* query and set the group creation properties */ + if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); - /*------------------------------------------------------------------------- - * H5TRAV_TYPE_DATASET - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_DATASET: - { - hbool_t use_h5ocopy; - - has_filter = 0; - req_filter = 0; - - /* check if global filters were requested */ - if (options->n_filter_g) - req_filter = 1; - - /* check if filters were requested for individual objects */ - if (options->op_tbl->objs) { - for (u = 0; u < options->op_tbl->nelems; u++) { - if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0) - for (ifil = 0; ifil < options->op_tbl->objs[ifil].nfilters; ifil++) { - if (options->op_tbl->objs[u].filter[ifil].filtn > 0) - req_filter = 1; - } - } - } + /* set up group creation property list */ + if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); - /* check if layout change requested individual object */ - if (options->layout_g != H5D_LAYOUT_ERROR) { - pack_info_t *pckinfo; + if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed"); - /* any dataset is specified */ - if (options->op_tbl->nelems > 0) { - /* check if object exist */ - pckinfo = options_get_object(travt->objs[i].name, options->op_tbl); - if (pckinfo) - req_obj_layout = 1; + /*------------------------------------------------------------------------- + * the root is a special case, we get an ID for the root group + * and copy its attributes using that ID + *------------------------------------------------------------------------- + */ + if (HDstrcmp(travt->objs[i].name, "/") == 0) { + if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); + } + else { + if (options->grp_compact > 0 || options->grp_indexed > 0) + if (H5Pset_link_phase_change(gcpl_out, (unsigned)options->grp_compact, + (unsigned)options->grp_indexed) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed"); + + if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, + H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gcreate2 failed"); } - } - /* early detection of references */ - if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); - if ((ftype_id = H5Dget_type(dset_in)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); - if (H5T_REFERENCE == H5Tget_class(ftype_id)) - is_ref = 1; - - /* Check if the datatype is committed */ - if ((is_named = H5Tcommitted(ftype_id)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed"); - if (is_named) - if ((wtype_id = copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0) - H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - if (H5Tclose(ftype_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); - if (H5Dclose(dset_in) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + if (H5Pclose(gcpl_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Pclose(gcpl_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Gclose(grp_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); + if (H5Gclose(grp_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); + + break; /*------------------------------------------------------------------------- - * check if we should use H5Ocopy or not - * if there is a request for filters/layout, we read/write the object - * otherwise we do a copy using H5Ocopy + * H5TRAV_TYPE_DATASET *------------------------------------------------------------------------- */ - use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1 - || options->all_layout == 1 || is_ref || is_named); - - /* - * Check if we are using different source and destination VOL connectors. - * In this case, we currently have to avoid usage of H5Ocopy since it - * doesn't support this. - */ - if (use_h5ocopy && (options->fin_fapl != H5P_DEFAULT || options->fout_fapl != H5P_DEFAULT)) { - hid_t in_vol_id; - hid_t out_vol_id; - hid_t default_vol_id; - - if (H5Pget_vol_id(H5P_FILE_ACCESS_DEFAULT, &default_vol_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); - - if (options->fin_fapl == H5P_DEFAULT) - in_vol_id = default_vol_id; - else - if (H5Pget_vol_id(options->fin_fapl, &in_vol_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); - if (options->fout_fapl == H5P_DEFAULT) - out_vol_id = default_vol_id; - else - if (H5Pget_vol_id(options->fout_fapl, &out_vol_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); - - if (in_vol_id != out_vol_id) - use_h5ocopy = FALSE; - - if (in_vol_id != default_vol_id) - if (H5VLclose(in_vol_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); - if (out_vol_id != default_vol_id) - if (H5VLclose(out_vol_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); - if (H5VLclose(default_vol_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); - } + case H5TRAV_TYPE_DATASET: { + hbool_t use_h5ocopy; + + has_filter = 0; + req_filter = 0; + + /* check if global filters were requested */ + if (options->n_filter_g) + req_filter = 1; + + /* check if filters were requested for individual objects */ + if (options->op_tbl->objs) { + for (u = 0; u < options->op_tbl->nelems; u++) { + if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0) + for (ifil = 0; ifil < options->op_tbl->objs[ifil].nfilters; ifil++) { + if (options->op_tbl->objs[u].filter[ifil].filtn > 0) + req_filter = 1; + } + } + } - if (!use_h5ocopy) { - int j; + /* check if layout change requested individual object */ + if (options->layout_g != H5D_LAYOUT_ERROR) { + pack_info_t *pckinfo; + + /* any dataset is specified */ + if (options->op_tbl->nelems > 0) { + /* check if object exist */ + pckinfo = options_get_object(travt->objs[i].name, options->op_tbl); + if (pckinfo) + req_obj_layout = 1; + } + } + /* early detection of references */ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); - if ((f_space_id = H5Dget_space(dset_in)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); if ((ftype_id = H5Dget_type(dset_in)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); - if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); - if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); - HDmemset(dims, 0, sizeof dims); - if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); - if (H5Dget_space_status(dset_in, &space_status) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dget_space_status failed"); - - /* If the input dataset has external storage, it must be contiguous. - * Accordingly, there would be no filter or chunk properties to preserve, - * so create a new DCPL. - * Otherwise, copy dcpl_in. - */ - if (H5Pget_external_count(dcpl_in)) { - if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); - } - else if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) { - H5TOOLS_GOTO_ERROR((-1), "H5Pcopy failed"); - } + if (H5T_REFERENCE == H5Tget_class(ftype_id)) + is_ref = 1; - nelmts = 1; - for (j = 0; j < rank; j++) - nelmts *= dims[j]; + /* Check if the datatype is committed */ + if ((is_named = H5Tcommitted(ftype_id)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed"); + if (is_named) + if ((wtype_id = + copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); - /* wtype_id will have already been set if using a named dtype */ - if (!is_named) { - if (options->use_native == 1) - wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); - else - wtype_id = H5Tcopy(ftype_id); - } - - if ((msize = H5Tget_size(wtype_id)) == 0) - H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); - - /* size of current dset */ - size_dset = nelmts * msize; + if (H5Tclose(ftype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Dclose(dset_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); /*------------------------------------------------------------------------- - * check if the dataset creation property list has filters that - * are not registered in the current configuration - * 1) the external filters GZIP and SZIP might not be available - * 2) the internal filters might be turned off + * check if we should use H5Ocopy or not + * if there is a request for filters/layout, we read/write the object + * otherwise we do a copy using H5Ocopy *------------------------------------------------------------------------- */ - if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) { - apply_s = 1; - apply_f = 1; + use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1 || + options->all_layout == 1 || is_ref || is_named); - /*------------------------------------------------------------------------- - * references are a special case - * we cannot just copy the buffers, but instead we recreate the reference - * in a second traversal of the output file - *------------------------------------------------------------------------- - */ - if (H5T_REFERENCE != H5Tget_class(wtype_id)) { - /* get the storage size of the input dataset */ - dsize_in = H5Dget_storage_size(dset_in); + /* + * Check if we are using different source and destination VOL connectors. + * In this case, we currently have to avoid usage of H5Ocopy since it + * doesn't support this. + */ + if (use_h5ocopy && + (options->fin_fapl != H5P_DEFAULT || options->fout_fapl != H5P_DEFAULT)) { + hid_t in_vol_id; + hid_t out_vol_id; + hid_t default_vol_id; - /* check for small size datasets (less than 1k) except - * changing to COMPACT. For the reference, COMPACT is limited - * by size 64K by library. - */ - if (options->layout_g != H5D_COMPACT) - if (size_dset < options->min_comp) - apply_s = 0; - - /* apply the filter */ - if (apply_s) - if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, options, &has_filter) < 0) - H5TOOLS_GOTO_ERROR((-1), "apply_filters failed"); - - /* only if layout change requested for entire file or - * individual obj */ - if (options->all_layout > 0 || req_obj_layout == 1) { - /*------------------------------------------------- - * Unset the unlimited max dims if convert to other - * than chunk layouts, because unlimited max dims - * only can be applied to chunk layout. - * Also perform only for targeted dataset - * Also check for size limit to convert to compact - *-------------------------------------------------*/ - if (options->layout_g != H5D_CHUNKED) { - /* any dataset is specified */ - if (options->op_tbl->nelems > 0) { - /* if current obj match specified obj */ - if (options_get_object(travt->objs[i].name, options->op_tbl)) - limit_maxdims = TRUE; - } - else /* no dataset is specified */ - limit_maxdims = TRUE; + if (H5Pget_vol_id(H5P_FILE_ACCESS_DEFAULT, &default_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); + + if (options->fin_fapl == H5P_DEFAULT) + in_vol_id = default_vol_id; + else if (H5Pget_vol_id(options->fin_fapl, &in_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); + if (options->fout_fapl == H5P_DEFAULT) + out_vol_id = default_vol_id; + else if (H5Pget_vol_id(options->fout_fapl, &out_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); - /* if convert to COMPACT */ - if (options->layout_g == H5D_COMPACT) - if (size_dset > MAX_COMPACT_DSIZE) - limit_maxdims = FALSE; + if (in_vol_id != out_vol_id) + use_h5ocopy = FALSE; - /* unset unlimited max dims */ - if (limit_maxdims) - H5Sset_extent_simple(f_space_id, rank, dims, NULL); - } /* end if not chunked */ - } /* end if layout change requested for entire file or individual object */ + if (in_vol_id != default_vol_id) + if (H5VLclose(in_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); + if (out_vol_id != default_vol_id) + if (H5VLclose(out_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); + if (H5VLclose(default_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); + } - /*------------------------------------------------------------------------- - * create the output dataset; - * disable error checking in case the dataset cannot be created with the - * modified dcpl; in that case use the original instead - *------------------------------------------------------------------------- - */ - dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); - if (dset_out == H5I_INVALID_HID) { - H5TOOLS_INFO("H5Dcreate2 failed"); - if (options->verbose) - HDprintf(" warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name); + if (!use_h5ocopy) { + int j; + + if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); + if ((f_space_id = H5Dget_space(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); + if ((ftype_id = H5Dget_type(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); + if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); + if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); + HDmemset(dims, 0, sizeof dims); + if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); + if (H5Dget_space_status(dset_in, &space_status) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space_status failed"); + + /* If the input dataset has external storage, it must be contiguous. + * Accordingly, there would be no filter or chunk properties to preserve, + * so create a new DCPL. + * Otherwise, copy dcpl_in. + */ + if (H5Pget_external_count(dcpl_in)) { + if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); + } + else if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) { + H5TOOLS_GOTO_ERROR((-1), "H5Pcopy failed"); + } + + nelmts = 1; + for (j = 0; j < rank; j++) + nelmts *= dims[j]; + + /* wtype_id will have already been set if using a named dtype */ + if (!is_named) { + if (options->use_native == 1) + wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); + else + wtype_id = H5Tcopy(ftype_id); + } + + if ((msize = H5Tget_size(wtype_id)) == 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); + + /* size of current dset */ + size_dset = nelmts * msize; - if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); - apply_f = 0; - } /* end if retry dataset create */ + /*------------------------------------------------------------------------- + * check if the dataset creation property list has filters that + * are not registered in the current configuration + * 1) the external filters GZIP and SZIP might not be available + * 2) the internal filters might be turned off + *------------------------------------------------------------------------- + */ + if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) { + apply_s = 1; + apply_f = 1; /*------------------------------------------------------------------------- - * read/write + * references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + * in a second traversal of the output file *------------------------------------------------------------------------- */ - if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) { - size_t need = (size_t)(nelmts * msize); /* bytes needed */ - - /* have to read the whole dataset if there is only one element in the dataset */ - if (need < H5TOOLS_MALLOCSIZE) - buf = HDmalloc(need); - - if (buf != NULL) { - if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); - if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); - - /* Check if we have VL data in the dataset's - * datatype that must be reclaimed */ - if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) - if (H5Treclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Treclaim failed"); - - if (buf != NULL) { /* TODO: is buf potentially released by H5Dvlen_reclaim()? */ - HDfree(buf); - buf = NULL; - } - } - else { /* possibly not enough memory, read/write by hyperslabs */ - size_t p_type_nbytes = msize; /*size of memory type */ - hsize_t p_nelmts = nelmts; /*total elements */ - hsize_t elmtno; /*counter */ - int carry; /*counter carry value */ - unsigned int vl_data = 0; /*contains VL datatypes */ - - /* hyperslab info */ - hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */ - hsize_t hslab_nbytes; /*bytes per hyperslab */ - hsize_t hslab_nelmts; /*elements per hyperslab*/ - hid_t hslab_space; /*hyperslab data space */ - - /* hyperslab selection info */ - hsize_t hs_sel_offset[H5S_MAX_RANK];/* selection offset */ - hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */ - hsize_t hs_select_nelmts; /* selected elements */ - hsize_t zero[8]; /*vector of zeros */ - int k; - H5D_layout_t dset_layout; - hid_t dcpl_tmp = H5I_INVALID_HID; /* dataset creation property list ID */ - - /* check if we have VL data in the dataset's datatype */ - if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE) - vl_data = TRUE; - - /* check first if writing dataset is chunked, - * if so use its chunk layout for better performance. */ - dset_layout = H5Pget_layout(dcpl_out); - if (dset_layout == H5D_CHUNKED) - dcpl_tmp = dcpl_out; /* writing dataset */ - else { - dset_layout = H5Pget_layout(dcpl_in); - if (dset_layout == H5D_CHUNKED) - dcpl_tmp = dcpl_in; /* reading dataset */ - } + if (H5T_REFERENCE != H5Tget_class(wtype_id)) { + /* get the storage size of the input dataset */ + dsize_in = H5Dget_storage_size(dset_in); - /* get hyperslab dims and size in byte */ - if (get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, &hslab_nbytes) < 0) - H5TOOLS_GOTO_ERROR((-1), "get_hyperslab failed"); - - hslab_buf = HDmalloc((size_t)hslab_nbytes); - if (hslab_buf == NULL) - H5TOOLS_GOTO_ERROR((-1), "can't allocate space for hyperslab"); - - hslab_nelmts = hslab_nbytes / p_type_nbytes; - hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL); - - /* the hyperslab selection loop */ - HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset); - HDmemset(zero, 0, sizeof zero); - - for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) { - if (rank > 0) { - /* calculate the hyperslab selections. - * The selection would be same as the hyperslab - * except for remaining edge portion of the dataset - * which is smaller then the hyperslab. - */ - for (k = 0, hs_select_nelmts = 1; k < rank; k++) { - /* MIN() is used to get the remaining edge portion if exist. - * "dims[k] - hs_sel_offset[k]" is remaining edge portion that is smaller then the hyperslab.*/ - hs_sel_count[k] = MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]); - hs_select_nelmts *= hs_sel_count[k]; - } + /* check for small size datasets (less than 1k) except + * changing to COMPACT. For the reference, COMPACT is limited + * by size 64K by library. + */ + if (options->layout_g != H5D_COMPACT) + if (size_dset < options->min_comp) + apply_s = 0; + + /* apply the filter */ + if (apply_s) + if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, + options, &has_filter) < 0) + H5TOOLS_GOTO_ERROR((-1), "apply_filters failed"); + + /* only if layout change requested for entire file or + * individual obj */ + if (options->all_layout > 0 || req_obj_layout == 1) { + /*------------------------------------------------- + * Unset the unlimited max dims if convert to other + * than chunk layouts, because unlimited max dims + * only can be applied to chunk layout. + * Also perform only for targeted dataset + * Also check for size limit to convert to compact + *-------------------------------------------------*/ + if (options->layout_g != H5D_CHUNKED) { + /* any dataset is specified */ + if (options->op_tbl->nelems > 0) { + /* if current obj match specified obj */ + if (options_get_object(travt->objs[i].name, options->op_tbl)) + limit_maxdims = TRUE; + } + else /* no dataset is specified */ + limit_maxdims = TRUE; - if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_sel_offset, NULL, hs_sel_count, NULL) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); - if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, NULL, &hs_select_nelmts, NULL) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); - } /* end if rank > 0 */ - else { - H5Sselect_all(f_space_id); - H5Sselect_all(hslab_space); - hs_select_nelmts = 1; - } /* end (else) rank == 0 */ + /* if convert to COMPACT */ + if (options->layout_g == H5D_COMPACT) + if (size_dset > MAX_COMPACT_DSIZE) + limit_maxdims = FALSE; + + /* unset unlimited max dims */ + if (limit_maxdims) + H5Sset_extent_simple(f_space_id, rank, dims, NULL); + } /* end if not chunked */ + } /* end if layout change requested for entire file or individual object */ + + /*------------------------------------------------------------------------- + * create the output dataset; + * disable error checking in case the dataset cannot be created with the + * modified dcpl; in that case use the original instead + *------------------------------------------------------------------------- + */ + dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, + H5P_DEFAULT, dcpl_out, H5P_DEFAULT); + if (dset_out == H5I_INVALID_HID) { + H5TOOLS_INFO("H5Dcreate2 failed"); + if (options->verbose) + HDprintf(" warning: could not create dataset <%s>. Applying original " + "settings\n", + travt->objs[i].name); + + if ((dset_out = + H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, + H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); + apply_f = 0; + } /* end if retry dataset create */ + + /*------------------------------------------------------------------------- + * read/write + *------------------------------------------------------------------------- + */ + if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) { + size_t need = (size_t)(nelmts * msize); /* bytes needed */ + + /* have to read the whole dataset if there is only one element in the + * dataset */ + if (need < H5TOOLS_MALLOCSIZE) + buf = HDmalloc(need); - if(H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) + if (buf != NULL) { + if (H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < + 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); - if(H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) + if (H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < + 0) H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); - /* reclaim any VL memory, if necessary */ - if (vl_data) - H5Treclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf); - - /* calculate the next hyperslab offset */ - for (k = rank, carry = 1; k > 0 && carry; --k) { - hs_sel_offset[k - 1] += hs_sel_count[k - 1]; - /* if reached the end of a dim */ - if (hs_sel_offset[k - 1] == dims[k - 1]) - hs_sel_offset[k - 1] = 0; - else - carry = 0; - } - } /* end for (hyperslab selection loop) */ + /* Check if we have VL data in the dataset's + * datatype that must be reclaimed */ + if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) + if (H5Treclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Treclaim failed"); - H5Sclose(hslab_space); - if (hslab_buf != NULL) { - HDfree(hslab_buf); - hslab_buf = NULL; + if (buf != NULL) { /* TODO: is buf potentially released by + H5Dvlen_reclaim()? */ + HDfree(buf); + buf = NULL; + } } - } /* end if reading/writing by hyperslab */ - } /* end if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */ - - /*------------------------------------------------------------------------- - * print amount of compression used - *------------------------------------------------------------------------- - */ - if (options->verbose) { - double ratio = 0; - - /* only print the compression ration if there was a filter request */ - if (apply_s && apply_f && req_filter) { - /* get the storage size of the output dataset */ - dsize_out = H5Dget_storage_size(dset_out); - - /* compression ratio = uncompressed size / compressed size */ - if (dsize_out != 0) - ratio = (double) dsize_in / (double) dsize_out; - print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1); - } - else - print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0); + else { /* possibly not enough memory, read/write by hyperslabs */ + size_t p_type_nbytes = msize; /*size of memory type */ + hsize_t p_nelmts = nelmts; /*total elements */ + hsize_t elmtno; /*counter */ + int carry; /*counter carry value */ + unsigned int vl_data = 0; /*contains VL datatypes */ + + /* hyperslab info */ + hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */ + hsize_t hslab_nbytes; /*bytes per hyperslab */ + hsize_t hslab_nelmts; /*elements per hyperslab*/ + hid_t hslab_space; /*hyperslab data space */ + + /* hyperslab selection info */ + hsize_t hs_sel_offset[H5S_MAX_RANK]; /* selection offset */ + hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */ + hsize_t hs_select_nelmts; /* selected elements */ + hsize_t zero[8]; /*vector of zeros */ + int k; + H5D_layout_t dset_layout; + hid_t dcpl_tmp = + H5I_INVALID_HID; /* dataset creation property list ID */ + + /* check if we have VL data in the dataset's datatype */ + if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE) + vl_data = TRUE; + + /* check first if writing dataset is chunked, + * if so use its chunk layout for better performance. */ + dset_layout = H5Pget_layout(dcpl_out); + if (dset_layout == H5D_CHUNKED) + dcpl_tmp = dcpl_out; /* writing dataset */ + else { + dset_layout = H5Pget_layout(dcpl_in); + if (dset_layout == H5D_CHUNKED) + dcpl_tmp = dcpl_in; /* reading dataset */ + } - /* print a message that the filter was not applied - * (in case there was a filter) - */ - if (has_filter && apply_s == 0) - HDprintf(" \n", travt->objs[i].name, (int) options->min_comp); + /* get hyperslab dims and size in byte */ + if (get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, + &hslab_nbytes) < 0) + H5TOOLS_GOTO_ERROR((-1), "get_hyperslab failed"); + + hslab_buf = HDmalloc((size_t)hslab_nbytes); + if (hslab_buf == NULL) + H5TOOLS_GOTO_ERROR((-1), "can't allocate space for hyperslab"); + + hslab_nelmts = hslab_nbytes / p_type_nbytes; + hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL); + + /* the hyperslab selection loop */ + HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset); + HDmemset(zero, 0, sizeof zero); + + for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) { + if (rank > 0) { + /* calculate the hyperslab selections. + * The selection would be same as the hyperslab + * except for remaining edge portion of the dataset + * which is smaller then the hyperslab. + */ + for (k = 0, hs_select_nelmts = 1; k < rank; k++) { + /* MIN() is used to get the remaining edge portion if + * exist. "dims[k] - hs_sel_offset[k]" is remaining edge + * portion that is smaller then the hyperslab.*/ + hs_sel_count[k] = + MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]); + hs_select_nelmts *= hs_sel_count[k]; + } + + if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, + hs_sel_offset, NULL, hs_sel_count, + NULL) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); + if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, + NULL, &hs_select_nelmts, NULL) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); + } /* end if rank > 0 */ + else { + H5Sselect_all(f_space_id); + H5Sselect_all(hslab_space); + hs_select_nelmts = 1; + } /* end (else) rank == 0 */ + + if (H5Dread(dset_in, wtype_id, hslab_space, f_space_id, + H5P_DEFAULT, hslab_buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); + if (H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, + H5P_DEFAULT, hslab_buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + + /* reclaim any VL memory, if necessary */ + if (vl_data) + H5Treclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf); + + /* calculate the next hyperslab offset */ + for (k = rank, carry = 1; k > 0 && carry; --k) { + hs_sel_offset[k - 1] += hs_sel_count[k - 1]; + /* if reached the end of a dim */ + if (hs_sel_offset[k - 1] == dims[k - 1]) + hs_sel_offset[k - 1] = 0; + else + carry = 0; + } + } /* end for (hyperslab selection loop) */ - if (has_filter && apply_f == 0) - HDprintf(" \n", travt->objs[i].name); - } /* end if verbose (print compression) */ + H5Sclose(hslab_space); + if (hslab_buf != NULL) { + HDfree(hslab_buf); + hslab_buf = NULL; + } + } /* end if reading/writing by hyperslab */ + } /* end if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */ - /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ - if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); + /*------------------------------------------------------------------------- + * print amount of compression used + *------------------------------------------------------------------------- + */ + if (options->verbose) { + double ratio = 0; + + /* only print the compression ration if there was a filter request */ + if (apply_s && apply_f && req_filter) { + /* get the storage size of the output dataset */ + dsize_out = H5Dget_storage_size(dset_out); + + /* compression ratio = uncompressed size / compressed size */ + if (dsize_out != 0) + ratio = (double)dsize_in / (double)dsize_out; + print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1); + } + else + print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0); + + /* print a message that the filter was not applied + * (in case there was a filter) + */ + if (has_filter && apply_s == 0) + HDprintf(" \n", + travt->objs[i].name, (int)options->min_comp); + + if (has_filter && apply_f == 0) + HDprintf(" \n", + travt->objs[i].name); + } /* end if verbose (print compression) */ + + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - if (H5Dclose(dset_out) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); - } /* end if not a reference */ - } /* end if h5tools_canreadf (filter availability check) */ + if (H5Dclose(dset_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + } /* end if not a reference */ + } /* end if h5tools_canreadf (filter availability check) */ + /*------------------------------------------------------------------------- + * Close + *------------------------------------------------------------------------- + */ + if (H5Tclose(ftype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(wtype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Pclose(dcpl_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Pclose(dcpl_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Sclose(f_space_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); + if (H5Dclose(dset_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + } /*------------------------------------------------------------------------- - * Close + * We do not have request for filter/chunking; use H5Ocopy instead *------------------------------------------------------------------------- */ - if (H5Tclose(ftype_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); - if (H5Tclose(wtype_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); - if (H5Pclose(dcpl_in) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - if (H5Pclose(dcpl_out) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - if (H5Sclose(f_space_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); - if (H5Dclose(dset_in) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); - } - /*------------------------------------------------------------------------- - * We do not have request for filter/chunking; use H5Ocopy instead - *------------------------------------------------------------------------- - */ - else { - hid_t pid = H5I_INVALID_HID; + else { + hid_t pid = H5I_INVALID_HID; - /* create property to pass copy options */ - if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); + /* create property to pass copy options */ + if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); - /* set options for object copy */ - if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed"); + /* set options for object copy */ + if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed"); - if (H5Ocopy(fidin, /* Source file or group identifier */ - travt->objs[i].name, /* Name of the source object to be copied */ - fidout, /* Destination file or group identifier */ - travt->objs[i].name, /* Name of the destination object */ - pid, /* Properties which apply to the copy */ - H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ - H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed"); + if (H5Ocopy(fidin, /* Source file or group identifier */ + travt->objs[i].name, /* Name of the source object to be copied */ + fidout, /* Destination file or group identifier */ + travt->objs[i].name, /* Name of the destination object */ + pid, /* Properties which apply to the copy */ + H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ + H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed"); - if (H5Pclose(pid) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Pclose(pid) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - /*------------------------------------------------------------------------- - * Copy attrs manually - *------------------------------------------------------------------------- - */ - if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); - if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); - if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - if (H5Dclose(dset_in) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); - if (H5Dclose(dset_out) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + /*------------------------------------------------------------------------- + * Copy attrs manually + *------------------------------------------------------------------------- + */ + if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); + if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); + if (H5Dclose(dset_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + if (H5Dclose(dset_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + + if (options->verbose) + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); + + } /* end whether we have request for filter/chunking */ + break; + } /* H5TRAV_TYPE_DATASET */ + + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_NAMED_DATATYPE + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_NAMED_DATATYPE: if (options->verbose) - HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); + HDprintf(FORMAT_OBJ, "type", travt->objs[i].name); - } /* end whether we have request for filter/chunking */ + if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed"); - break; - } /* H5TRAV_TYPE_DATASET */ + /* Copy the datatype anonymously */ + if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); - /*------------------------------------------------------------------------- - * H5TRAV_TYPE_NAMED_DATATYPE - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_NAMED_DATATYPE: - if (options->verbose) - HDprintf(FORMAT_OBJ, "type", travt->objs[i].name); + /* Link in to group structure */ + if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < + 0) + H5TOOLS_GOTO_ERROR((-1), "H5Lcreate_hard failed"); - if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed"); + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - /* Copy the datatype anonymously */ - if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0) - H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); + if (H5Tclose(type_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(type_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + type_out = H5I_INVALID_HID; /* named datatypes stack, named_dt_head, manages allocation */ - /* Link in to group structure */ - if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Lcreate_hard failed"); + break; /*------------------------------------------------------------------------- - * copy attrs + * H5TRAV_TYPE_LINK + * H5TRAV_TYPE_UDLINK + * + * Only handles external links; H5Lcopy will fail for other UD link types + * since we don't have creation or copy callbacks for them. *------------------------------------------------------------------------- */ - if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - - if (H5Tclose(type_in) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); - if (H5Tclose(type_out) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); - type_out = H5I_INVALID_HID; /* named datatypes stack, named_dt_head, manages allocation */ - - break; - - /*------------------------------------------------------------------------- - * H5TRAV_TYPE_LINK - * H5TRAV_TYPE_UDLINK - * - * Only handles external links; H5Lcopy will fail for other UD link types - * since we don't have creation or copy callbacks for them. - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_LINK: - case H5TRAV_TYPE_UDLINK: - if (options->verbose) - HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); + case H5TRAV_TYPE_LINK: + case H5TRAV_TYPE_UDLINK: + if (options->verbose) + HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); - if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed"); + if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, + H5P_DEFAULT) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed"); - if (options->verbose) - HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); - break; + if (options->verbose) + HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); + break; - default: - H5TOOLS_GOTO_ERROR((-1), "Object type not found"); + default: + H5TOOLS_GOTO_ERROR((-1), "Object type not found"); } /* switch */ - } /* end for each object to traverse */ - } /* end if there are objects */ + } /* end for each object to traverse */ + } /* end if there are objects */ done: @@ -1250,9 +1280,11 @@ done: H5TOOLS_ERROR((-1), "named_datatype_free failed"); } else - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { named_datatype_free(&named_dt_head, 1); - } H5E_END_TRY; + } + H5E_END_TRY; H5E_BEGIN_TRY { @@ -1268,7 +1300,8 @@ done: H5Tclose(wtype_id); H5Tclose(type_in); H5Tclose(type_out); - } H5E_END_TRY; + } + H5E_END_TRY; /* free */ if (buf != NULL) @@ -1288,17 +1321,17 @@ done: static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) { - char strfilter[255]; -#if defined (PRINT_DEBUG ) - char temp[255]; + char strfilter[255]; +#if defined(PRINT_DEBUG) + char temp[255]; #endif - int nfilters; /* number of filters */ - unsigned filt_flags; /* filter flags */ - H5Z_filter_t filtn; /* filter identification number */ - unsigned cd_values[20]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ - char f_objname[256]; /* filter objname */ - int i; + int nfilters; /* number of filters */ + unsigned filt_flags; /* filter flags */ + H5Z_filter_t filtn; /* filter identification number */ + unsigned cd_values[20]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ + char f_objname[256]; /* filter objname */ + int i; HDstrcpy(strfilter, "\0"); @@ -1309,8 +1342,8 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) for (i = 0; i < nfilters; i++) { cd_nelmts = NELMTS(cd_values); - if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts, - cd_values, sizeof(f_objname), f_objname, NULL)) < 0) { + if ((filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, + sizeof(f_objname), f_objname, NULL)) < 0) { HDstrcat(strfilter, "ERROR "); continue; } @@ -1323,11 +1356,11 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) case H5Z_FILTER_DEFLATE: HDstrcat(strfilter, "GZIP "); -#if defined (PRINT_DEBUG) +#if defined(PRINT_DEBUG) { unsigned level = cd_values[0]; - HDsprintf(temp,"(%d)", level); + HDsprintf(temp, "(%d)", level); HDstrcat(strfilter, temp); } #endif @@ -1336,12 +1369,12 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) case H5Z_FILTER_SZIP: HDstrcat(strfilter, "SZIP "); -#if defined (PRINT_DEBUG) +#if defined(PRINT_DEBUG) { unsigned options_mask = cd_values[0]; /* from dcpl, not filt*/ - unsigned ppb = cd_values[1]; + unsigned ppb = cd_values[1]; - HDsprintf(temp,"(%d,", ppb); + HDsprintf(temp, "(%d,", ppb); HDstrcat(strfilter, temp); if (options_mask & H5_SZIP_EC_OPTION_MASK) HDstrcpy(temp, "EC) "); @@ -1372,7 +1405,7 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) HDstrcat(strfilter, "UD "); break; } /* end switch */ - } /* end for each filter */ + } /* end for each filter */ if (!pr) HDprintf(FORMAT_OBJ, "dset", objname); @@ -1411,9 +1444,9 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) /* Copy the userblock from the input file to the output file */ while (size > 0) { - ssize_t nread, nbytes; /* # of bytes transfered, etc. */ - char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */ - const char *wbuf; /* Pointer into buffer, for writing */ + ssize_t nread, nbytes; /* # of bytes transfered, etc. */ + char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */ + const char *wbuf; /* Pointer into buffer, for writing */ /* Read buffer from source file */ if (size > USERBLOCK_XFER_SIZE) @@ -1426,14 +1459,14 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) /* Write buffer to destination file */ /* (compensating for interrupted writes & checking for errors, etc.) */ nbytes = nread; - wbuf = rbuf; + wbuf = rbuf; while (nbytes > 0) { ssize_t nwritten; /* # of bytes written */ do { nwritten = HDwrite(outfid, wbuf, (size_t)nbytes); } while (-1 == nwritten && EINTR == errno); - if (-1 == nwritten) /* error */ + if (-1 == nwritten) /* error */ H5TOOLS_GOTO_ERROR((-1), "HDwrite failed"); HDassert(nwritten > 0); HDassert(nwritten <= nbytes); @@ -1445,7 +1478,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) } /* end while */ /* Update size of userblock left to transfer */ - size = size - (hsize_t) nread; + size = size - (hsize_t)nread; } /* end while */ done: @@ -1465,14 +1498,13 @@ done: * Return: 0, ok, -1 no *------------------------------------------------------------------------- */ -#if defined (H5REPACK_DEBUG_USER_BLOCK) -static -void +#if defined(H5REPACK_DEBUG_USER_BLOCK) +static void print_user_block(const char *filename, hid_t fid) { - int fh = -1; /* file handle */ - hsize_t ub_size; /* user block size */ - hsize_t size; /* size read */ + int fh = -1; /* file handle */ + hsize_t ub_size; /* user block size */ + hsize_t size; /* size read */ hid_t fcpl = H5I_INVALID_HID; /* file creation property list ID for HDF5 file */ int i; int ret_value = 0; @@ -1499,8 +1531,8 @@ print_user_block(const char *filename, hid_t fid) /* read file */ while (size > 0) { - ssize_t nread; /* # of bytes read */ - char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */ + ssize_t nread; /* # of bytes read */ + char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */ /* read buffer */ if (size > USERBLOCK_XFER_SIZE) @@ -1511,7 +1543,6 @@ print_user_block(const char *filename, hid_t fid) for (i = 0; i < nread; i++) { HDprintf("%c ", rbuf[i]); - } HDprintf("\n"); @@ -1530,4 +1561,3 @@ done: return; } /* end print_user_block() */ #endif - diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c index d1179fb..0570c0f 100644 --- a/tools/src/h5repack/h5repack_filters.c +++ b/tools/src/h5repack/h5repack_filters.c @@ -17,12 +17,12 @@ /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) #endif /* minimum of two values */ #undef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) /*------------------------------------------------------------------------- * Function: aux_copy_obj @@ -32,15 +32,16 @@ * Return: 0 success, -1 failure *------------------------------------------------------------------------- */ -static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ - const char* name, /* object name from traverse list */ - pack_info_t *objout /*OUT*/) /* info about object to filter */ +static int +aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ + const char * name, /* object name from traverse list */ + pack_info_t *objout /*OUT*/) /* info about object to filter */ { int nfilters; /* number of filters in DCPL */ char f_objname[256]; /* filter objname */ H5D_layout_t layout; - int rank; /* rank of dataset */ - hsize_t chsize[64]; /* chunk size in elements */ + int rank; /* rank of dataset */ + hsize_t chsize[64]; /* chunk size in elements */ int i; unsigned u; int ret_value = 0; @@ -50,8 +51,9 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed"); /* copy filter_info_t structure */ for (i = 0; i < nfilters; i++) { - if ((objout->filter[i].filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts, - objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0) + if ((objout->filter[i].filtn = H5Pget_filter2( + dcpl_id, (unsigned)i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts, + objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_filter2 failed"); } @@ -63,7 +65,7 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ objout->layout = layout; if (layout == H5D_CHUNKED) { - if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) + if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); objout->chunk.rank = rank; for (u = 0; u < (unsigned)rank; u++) @@ -81,30 +83,33 @@ done: * in the repack options list *------------------------------------------------------------------------- */ -static int aux_find_obj(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static int +aux_find_obj(const char * name, /* object name from traverse list */ + pack_opt_t * options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { - char *pdest = NULL; - const char *pname = NULL; + char * pdest = NULL; + const char * pname = NULL; unsigned int i; for (i = 0; i < options->op_tbl->nelems; i++) { if (HDstrcmp(options->op_tbl->objs[i].path, name) == 0) { *obj = options->op_tbl->objs[i]; - return (int) i; + return (int)i; } pdest = options->op_tbl->objs[i].path; - if (pdest[0] == '/') pdest++; + if (pdest[0] == '/') + pdest++; pname = name; - if (pname[0] == '/') pname++; + if (pname[0] == '/') + pname++; if (HDstrcmp(pdest, pname) == 0) { *obj = options->op_tbl->objs[i]; - return (int) i; + return (int)i; } - }/*i*/ + } /*i*/ return -1; } @@ -118,9 +123,10 @@ static int aux_find_obj(const char* name, /* object name from traverse list */ * Return: 0 not found, 1 found *------------------------------------------------------------------------- */ -static int aux_assign_obj(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static int +aux_assign_obj(const char * name, /* object name from traverse list */ + pack_opt_t * options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { int idx, i; pack_info_t tmp; @@ -136,44 +142,44 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ /* assign the global layout info to the OBJ info */ tmp.layout = options->layout_g; switch (options->layout_g) { - case H5D_CHUNKED: - tmp.chunk.rank = options->chunk_g.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_VIRTUAL: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->chunk_g.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_VIRTUAL: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } else { tmp.layout = options->op_tbl->objs[idx].layout; switch (tmp.layout) { - case H5D_CHUNKED: - tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_VIRTUAL: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_VIRTUAL: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } /* applying to all objects */ if (options->all_filter) { /* assign the global filter */ - tmp.nfilters = 1; + tmp.nfilters = 1; tmp.filter[0] = options->filter_g[0]; } /* if all */ else { @@ -197,21 +203,20 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ /* assign the global layout info to the OBJ info */ tmp.layout = options->layout_g; switch (options->layout_g) { - case H5D_CHUNKED: - tmp.chunk.rank = options->chunk_g.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = - options->chunk_g.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_VIRTUAL: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->chunk_g.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_VIRTUAL: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } } @@ -230,16 +235,17 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ -int apply_filters(const char* name, /* object name from traverse list */ - int rank, /* rank of dataset */ - hsize_t *dims, /* dimensions of dataset */ - size_t msize, /* size of type */ - hid_t dcpl_id, /* dataset creation property list */ - pack_opt_t *options, /* repack options */ - int *has_filter) /* (OUT) object NAME has a filter */ +int +apply_filters(const char *name, /* object name from traverse list */ + int rank, /* rank of dataset */ + hsize_t * dims, /* dimensions of dataset */ + size_t msize, /* size of type */ + hid_t dcpl_id, /* dataset creation property list */ + pack_opt_t *options, /* repack options */ + int * has_filter) /* (OUT) object NAME has a filter */ { - int nfilters; /* number of filters in DCPL */ - hsize_t chsize[64]; /* chunk size in elements */ + int nfilters; /* number of filters in DCPL */ + hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; int i; pack_info_t obj; @@ -269,7 +275,6 @@ int apply_filters(const char* name, /* object name from traverse list */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed"); - /*------------------------------------------------------------------------- * check if we have filters in the pipeline * we want to replace them with the input filters @@ -281,7 +286,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed"); } - else if(nfilters) { + else if (nfilters) { *has_filter = 1; if (aux_copy_obj(dcpl_id, name, &filtobj) < 0) H5TOOLS_GOTO_ERROR((-1), "aux_copy_obj failed"); @@ -297,9 +302,9 @@ int apply_filters(const char* name, /* object name from traverse list */ H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed"); if (layout == H5D_CHUNKED) { - if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) + if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); - obj.layout = H5D_CHUNKED; + obj.layout = H5D_CHUNKED; obj.chunk.rank = rank; for (i = 0; i < rank; i++) obj.chunk.chunk_lengths[i] = chsize[i]; @@ -327,7 +332,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (obj.layout == -1) { /* stripmine info */ hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nbytes; /*bytes per stripmine */ obj.chunk.rank = rank; @@ -339,7 +344,7 @@ int apply_filters(const char* name, /* object name from traverse list */ sm_nbytes = msize; for (i = rank; i > 0; --i) { hsize_t size = 0; - if(sm_nbytes == 0) + if (sm_nbytes == 0) H5TOOLS_GOTO_ERROR((-1), "number of bytes per stripmine must be > 0"); size = H5TOOLS_BUFSIZE / sm_nbytes; if (size == 0) /* datum size > H5TOOLS_BUFSIZE */ @@ -358,19 +363,18 @@ int apply_filters(const char* name, /* object name from traverse list */ H5TOOLS_GOTO_ERROR((-1), "invalid filter"); switch (obj.filter[i].filtn) { - /*------------------------------------------------------------------------- - * H5Z_FILTER_NONE 0 , uncompress if compressed - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_NONE: - break; - - /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE 1 , deflation like gzip - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_DEFLATE: - { + /*------------------------------------------------------------------------- + * H5Z_FILTER_NONE 0 , uncompress if compressed + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_NONE: + break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_DEFLATE 1 , deflation like gzip + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_DEFLATE: { unsigned aggression; /* the deflate level */ aggression = obj.filter[i].cd_values[0]; @@ -379,19 +383,17 @@ int apply_filters(const char* name, /* object name from traverse list */ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_deflate(dcpl_id, aggression) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_deflate failed"); - } - break; + } break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP 4 , szip compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SZIP: - { + /*------------------------------------------------------------------------- + * H5Z_FILTER_SZIP 4 , szip compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SZIP: { unsigned options_mask; unsigned pixels_per_block; - options_mask = obj.filter[i].cd_values[0]; + options_mask = obj.filter[i].cd_values[0]; pixels_per_block = obj.filter[i].cd_values[1]; /* set up for szip data */ @@ -399,70 +401,64 @@ int apply_filters(const char* name, /* object name from traverse list */ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_szip(dcpl_id, options_mask, pixels_per_block) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_szip failed"); - } - break; + } break; - /*------------------------------------------------------------------------- - * H5Z_FILTER_SHUFFLE 2 , shuffle the data - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SHUFFLE: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); - if (H5Pset_shuffle(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed"); - break; - - /*------------------------------------------------------------------------- - * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_FLETCHER32: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); - if (H5Pset_fletcher32(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed"); - break; - /*----------- ------------------------------------------------------------- - * H5Z_FILTER_NBIT , NBIT compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_NBIT: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); - if (H5Pset_nbit(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed"); - break; - /*----------- ------------------------------------------------------------- - * H5Z_FILTER_SCALEOFFSET , scale+offset compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SCALEOFFSET: - { + /*------------------------------------------------------------------------- + * H5Z_FILTER_SHUFFLE 2 , shuffle the data + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SHUFFLE: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_shuffle(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed"); + break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_FLETCHER32: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_fletcher32(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed"); + break; + /*----------- ------------------------------------------------------------- + * H5Z_FILTER_NBIT , NBIT compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_NBIT: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_nbit(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed"); + break; + /*----------- ------------------------------------------------------------- + * H5Z_FILTER_SCALEOFFSET , scale+offset compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SCALEOFFSET: { H5Z_SO_scale_type_t scale_type; - int scale_factor; + int scale_factor; - scale_type = (H5Z_SO_scale_type_t) obj.filter[i].cd_values[0]; - scale_factor = (int) obj.filter[i].cd_values[1]; + scale_type = (H5Z_SO_scale_type_t)obj.filter[i].cd_values[0]; + scale_factor = (int)obj.filter[i].cd_values[1]; if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_scaleoffset(dcpl_id, scale_type, scale_factor) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_scaleoffset failed"); - } - break; - default: - { + } break; + default: { if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); - if (H5Pset_filter(dcpl_id, obj.filter[i].filtn, - obj.filter[i].filt_flag, obj.filter[i].cd_nelmts, - obj.filter[i].cd_values) < 0) + if (H5Pset_filter(dcpl_id, obj.filter[i].filtn, obj.filter[i].filt_flag, + obj.filter[i].cd_nelmts, obj.filter[i].cd_values) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_filter failed"); - } - break; + } break; } /* switch */ - }/*i*/ + } /*i*/ } /*obj.nfilters*/ @@ -474,7 +470,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (H5Zfilter_avail(filtobj.filter[i].filtn) <= 0) H5TOOLS_GOTO_ERROR((-1), "%d filter unavailable", filtobj.filter[i].filtn); } /* for */ - } /* nfilters */ + } /* nfilters */ /*------------------------------------------------------------------------- * layout @@ -504,4 +500,3 @@ int apply_filters(const char* name, /* object name from traverse list */ done: return ret_value; } - diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 0ad61c0..c2ce208 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -18,58 +18,55 @@ /* Name of tool */ #define PROGRAMNAME "h5repack" -static int parse_command_line(int argc, const char **argv, pack_opt_t* options); +static int parse_command_line(int argc, const char **argv, pack_opt_t *options); static void leave(int ret) H5_ATTR_NORETURN; - /* module-scoped variables */ -static int has_i = 0; -static int has_o = 0; -const char *infile = NULL; +static int has_i = 0; +static int has_o = 0; +const char *infile = NULL; const char *outfile = NULL; /* * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVvf:l:m:e:nLj:k:c:d:s:u:b:M:t:a:i:o:S:P:T:G:q:z:E"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "version", no_arg, 'V' }, - { "verbose", no_arg, 'v' }, - { "filter", require_arg, 'f' }, - { "layout", require_arg, 'l' }, - { "minimum", require_arg, 'm' }, - { "file", require_arg, 'e' }, - { "native", no_arg, 'n' }, - { "latest", no_arg, 'L' }, - { "low", require_arg, 'j' }, - { "high", require_arg, 'k' }, - { "compact", require_arg, 'c' }, - { "indexed", require_arg, 'd' }, - { "ssize", require_arg, 's' }, - { "ublock", require_arg, 'u' }, - { "block", require_arg, 'b' }, - { "metadata_block_size", require_arg, 'M' }, - { "threshold", require_arg, 't' }, - { "alignment", require_arg, 'a' }, - { "infile", require_arg, 'i' }, /* for backward compability */ - { "outfile", require_arg, 'o' }, /* for backward compability */ - { "fs_strategy", require_arg, 'S' }, - { "fs_persist", require_arg, 'P' }, - { "fs_threshold", require_arg, 'T' }, - { "fs_pagesize", require_arg, 'G' }, - { "sort_by", require_arg, 'q' }, - { "sort_order", require_arg, 'z' }, - { "enable-error-stack", no_arg, 'E' }, - { "src-vol-value", require_arg, '1' }, - { "src-vol-name", require_arg, '2' }, - { "src-vol-info", require_arg, '3' }, - { "dst-vol-value", require_arg, '4' }, - { "dst-vol-name", require_arg, '5' }, - { "dst-vol-info", require_arg, '6' }, - { NULL, 0, '\0' } -}; +static const char * s_opts = "hVvf:l:m:e:nLj:k:c:d:s:u:b:M:t:a:i:o:S:P:T:G:q:z:E"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"version", no_arg, 'V'}, + {"verbose", no_arg, 'v'}, + {"filter", require_arg, 'f'}, + {"layout", require_arg, 'l'}, + {"minimum", require_arg, 'm'}, + {"file", require_arg, 'e'}, + {"native", no_arg, 'n'}, + {"latest", no_arg, 'L'}, + {"low", require_arg, 'j'}, + {"high", require_arg, 'k'}, + {"compact", require_arg, 'c'}, + {"indexed", require_arg, 'd'}, + {"ssize", require_arg, 's'}, + {"ublock", require_arg, 'u'}, + {"block", require_arg, 'b'}, + {"metadata_block_size", require_arg, 'M'}, + {"threshold", require_arg, 't'}, + {"alignment", require_arg, 'a'}, + {"infile", require_arg, 'i'}, /* for backward compability */ + {"outfile", require_arg, 'o'}, /* for backward compability */ + {"fs_strategy", require_arg, 'S'}, + {"fs_persist", require_arg, 'P'}, + {"fs_threshold", require_arg, 'T'}, + {"fs_pagesize", require_arg, 'G'}, + {"sort_by", require_arg, 'q'}, + {"sort_order", require_arg, 'z'}, + {"enable-error-stack", no_arg, 'E'}, + {"src-vol-value", require_arg, '1'}, + {"src-vol-name", require_arg, '2'}, + {"src-vol-info", require_arg, '3'}, + {"dst-vol-value", require_arg, '4'}, + {"dst-vol-name", require_arg, '5'}, + {"dst-vol-info", require_arg, '6'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -80,7 +77,9 @@ static struct long_options l_opts[] = { * *------------------------------------------------------------------------- */ -static void usage(const char *prog) { +static void +usage(const char *prog) +{ FLUSHSTREAM(rawoutstream); PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] file1 file2\n", prog); PRINTVALSTREAM(rawoutstream, " file1 Input HDF5 File\n"); @@ -90,102 +89,134 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); + PRINTVALSTREAM(rawoutstream, + " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); PRINTVALSTREAM(rawoutstream, " occur\n"); - PRINTVALSTREAM(rawoutstream, " --src-vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, + " --src-vol-value Value (ID) of the VOL connector to use for opening the\n"); PRINTVALSTREAM(rawoutstream, " input HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --src-vol-name Name of the VOL connector to use for opening the input\n"); + PRINTVALSTREAM(rawoutstream, + " --src-vol-name Name of the VOL connector to use for opening the input\n"); PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --src-vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, + " --src-vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the input HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --dst-vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, + " --dst-vol-value Value (ID) of the VOL connector to use for opening the\n"); PRINTVALSTREAM(rawoutstream, " output HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --dst-vol-name Name of the VOL connector to use for opening the output\n"); + PRINTVALSTREAM(rawoutstream, + " --dst-vol-name Name of the VOL connector to use for opening the output\n"); PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, + " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); - PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n"); + PRINTVALSTREAM(rawoutstream, + " This option will take precedence over the options\n"); PRINTVALSTREAM(rawoutstream, " --low and --high\n"); - PRINTVALSTREAM(rawoutstream, " --low=BOUND The low bound for library release versions to use\n"); + PRINTVALSTREAM(rawoutstream, + " --low=BOUND The low bound for library release versions to use\n"); PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n"); PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_EARLIEST)\n"); - PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use\n"); + PRINTVALSTREAM(rawoutstream, + " --high=BOUND The high bound for library release versions to use\n"); PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n"); PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_LATEST)\n"); PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); - PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); + PRINTVALSTREAM(rawoutstream, + " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); - PRINTVALSTREAM(rawoutstream, " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n"); + PRINTVALSTREAM(rawoutstream, + " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n"); PRINTVALSTREAM(rawoutstream, " -e E, --file=E Name of file E with the -f and -l options\n"); - PRINTVALSTREAM(rawoutstream, " -u U, --ublock=U Name of file U with user block data to be added\n"); + PRINTVALSTREAM(rawoutstream, + " -u U, --ublock=U Name of file U with user block data to be added\n"); PRINTVALSTREAM(rawoutstream, " -b B, --block=B Size of user block to be added\n"); - PRINTVALSTREAM(rawoutstream, " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n"); + PRINTVALSTREAM(rawoutstream, + " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n"); PRINTVALSTREAM(rawoutstream, " -t T, --threshold=T Threshold value for H5Pset_alignment\n"); PRINTVALSTREAM(rawoutstream, " -a A, --alignment=A Alignment value for H5Pset_alignment\n"); PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n"); PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n"); PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n"); PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n"); - PRINTVALSTREAM(rawoutstream, " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for\n"); + PRINTVALSTREAM(rawoutstream, + " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for\n"); PRINTVALSTREAM(rawoutstream, " H5Pset_file_space_strategy\n"); - PRINTVALSTREAM(rawoutstream, " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-\n"); + PRINTVALSTREAM(rawoutstream, + " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-\n"); PRINTVALSTREAM(rawoutstream, " space for H5Pset_file_space_strategy\n"); - PRINTVALSTREAM(rawoutstream, " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold\n"); + PRINTVALSTREAM(rawoutstream, + " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold\n"); PRINTVALSTREAM(rawoutstream, " for H5Pset_file_space_strategy\n"); PRINTVALSTREAM(rawoutstream, " -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for\n"); PRINTVALSTREAM(rawoutstream, " H5Pset_file_space_page_size\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n"); + PRINTVALSTREAM(rawoutstream, + " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n"); PRINTVALSTREAM(rawoutstream, " E - is a filename.\n"); PRINTVALSTREAM(rawoutstream, " S - is an integer\n"); PRINTVALSTREAM(rawoutstream, " U - is a filename.\n"); PRINTVALSTREAM(rawoutstream, " T - is an integer\n"); PRINTVALSTREAM(rawoutstream, " A - is an integer greater than zero\n"); - PRINTVALSTREAM(rawoutstream, " Q - is the sort index type for the input file. It can be \"name\" or\n"); + PRINTVALSTREAM(rawoutstream, + " Q - is the sort index type for the input file. It can be \"name\" or\n"); PRINTVALSTREAM(rawoutstream, " \"creation_order\" (default)\n"); - PRINTVALSTREAM(rawoutstream, " Z - is the sort order type for the input file. It can be \"descending\" or\n"); + PRINTVALSTREAM(rawoutstream, + " Z - is the sort order type for the input file. It can be \"descending\" or\n"); PRINTVALSTREAM(rawoutstream, " \"ascending\" (default)\n"); PRINTVALSTREAM(rawoutstream, " B - is the user block size, any value that is 512 or greater and is\n"); PRINTVALSTREAM(rawoutstream, " a power of 2 (1024 default)\n"); - PRINTVALSTREAM(rawoutstream, " F - is the shared object header message type, any of . If F is not specified, S applies to all messages\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " BOUND is an integer indicating the library release versions to use when\n"); + PRINTVALSTREAM(rawoutstream, + " BOUND is an integer indicating the library release versions to use when\n"); PRINTVALSTREAM(rawoutstream, " creating objects in the file (see H5Pset_libver_bounds()):\n"); PRINTVALSTREAM(rawoutstream, " 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 3: This is H5F_LIBVER_V112 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 4: This is H5F_LIBVER_V114 in H5F_libver_t struct\n"); - PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V114 for this release\n"); + PRINTVALSTREAM(rawoutstream, + " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V114 for this release\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n"); PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n"); - PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space\n"); + PRINTVALSTREAM(rawoutstream, + " The mechanisms used in managing file space are free-space\n"); PRINTVALSTREAM(rawoutstream, " managers, aggregators and virtual file driver.\n"); PRINTVALSTREAM(rawoutstream, " PAGE:\n"); - PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space\n"); - PRINTVALSTREAM(rawoutstream, " managers with embedded paged aggregation and virtual file driver.\n"); + PRINTVALSTREAM(rawoutstream, + " The mechanisms used in managing file space are free-space\n"); + PRINTVALSTREAM(rawoutstream, + " managers with embedded paged aggregation and virtual file driver.\n"); PRINTVALSTREAM(rawoutstream, " AGGR:\n"); - PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are aggregators and\n"); + PRINTVALSTREAM(rawoutstream, + " The mechanisms used in managing file space are aggregators and\n"); PRINTVALSTREAM(rawoutstream, " virtual file driver.\n"); PRINTVALSTREAM(rawoutstream, " NONE:\n"); - PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are virtual file\n"); + PRINTVALSTREAM(rawoutstream, + " The mechanisms used in managing file space are virtual file\n"); PRINTVALSTREAM(rawoutstream, " driver.\n"); - PRINTVALSTREAM(rawoutstream, " The default strategy when not set is FSM_AGGR without persisting free-\n"); + PRINTVALSTREAM(rawoutstream, + " The default strategy when not set is FSM_AGGR without persisting free-\n"); PRINTVALSTREAM(rawoutstream, " space.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n"); + PRINTVALSTREAM(rawoutstream, + " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n"); PRINTVALSTREAM(rawoutstream, " The default when not set is not persisting free-space.\n"); PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be\n"); + PRINTVALSTREAM(rawoutstream, + " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be\n"); PRINTVALSTREAM(rawoutstream, " tracked by the library.\n"); PRINTVALSTREAM(rawoutstream, " The default when not set is 1.\n"); PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when\n"); + PRINTVALSTREAM(rawoutstream, + " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when\n"); PRINTVALSTREAM(rawoutstream, " the file space strategy PAGE is used.\n"); PRINTVALSTREAM(rawoutstream, " The default when not set is 4096.\n"); PRINTVALSTREAM(rawoutstream, "\n"); @@ -193,8 +224,10 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " :=\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " is a comma separated list of object names, meaning apply\n"); - PRINTVALSTREAM(rawoutstream, " compression only to those objects. If no names are specified, the filter\n"); + PRINTVALSTREAM(rawoutstream, + " is a comma separated list of object names, meaning apply\n"); + PRINTVALSTREAM(rawoutstream, + " compression only to those objects. If no names are specified, the filter\n"); PRINTVALSTREAM(rawoutstream, " is applied to all objects\n"); PRINTVALSTREAM(rawoutstream, " can be:\n"); PRINTVALSTREAM(rawoutstream, " GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n"); @@ -207,15 +240,19 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " NONE, to remove all filters\n"); PRINTVALSTREAM(rawoutstream, " is optional filter parameter information\n"); PRINTVALSTREAM(rawoutstream, " GZIP= from 1-9\n"); - PRINTVALSTREAM(rawoutstream, " SZIP= pixels per block is a even number in\n"); + PRINTVALSTREAM(rawoutstream, + " SZIP= pixels per block is a even number in\n"); PRINTVALSTREAM(rawoutstream, " 2-32 and coding method is either EC or NN\n"); PRINTVALSTREAM(rawoutstream, " SHUF (no parameter)\n"); PRINTVALSTREAM(rawoutstream, " FLET (no parameter)\n"); PRINTVALSTREAM(rawoutstream, " NBIT (no parameter)\n"); - PRINTVALSTREAM(rawoutstream, " SOFF= scale_factor is an integer and scale_type\n"); + PRINTVALSTREAM(rawoutstream, + " SOFF= scale_factor is an integer and scale_type\n"); PRINTVALSTREAM(rawoutstream, " is either IN or DS\n"); - PRINTVALSTREAM(rawoutstream, " UD=\n"); - PRINTVALSTREAM(rawoutstream, " Required values: filter_number, filter_flag, cd_value_count, value1\n"); + PRINTVALSTREAM(rawoutstream, + " UD=\n"); + PRINTVALSTREAM(rawoutstream, + " Required values: filter_number, filter_flag, cd_value_count, value1\n"); PRINTVALSTREAM(rawoutstream, " Optional values: value2 to valueN\n"); PRINTVALSTREAM(rawoutstream, " NONE (no parameter)\n"); PRINTVALSTREAM(rawoutstream, "\n"); @@ -223,8 +260,10 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " :=\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " is a comma separated list of object names, meaning that\n"); - PRINTVALSTREAM(rawoutstream, " layout information is supplied for those objects. If no names are\n"); + PRINTVALSTREAM(rawoutstream, + " is a comma separated list of object names, meaning that\n"); + PRINTVALSTREAM(rawoutstream, + " layout information is supplied for those objects. If no names are\n"); PRINTVALSTREAM(rawoutstream, " specified, the layout type is applied to all objects\n"); PRINTVALSTREAM(rawoutstream, " can be:\n"); PRINTVALSTREAM(rawoutstream, " CHUNK, to apply chunking layout\n"); @@ -243,11 +282,14 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "2) h5repack -v -f dset1:SZIP=8,NN file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " SZIP compression with 8 pixels per block and NN coding method to object dset1\n"); + PRINTVALSTREAM(rawoutstream, + " SZIP compression with 8 pixels per block and NN coding method to object dset1\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n"); + PRINTVALSTREAM(rawoutstream, + "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n"); + PRINTVALSTREAM(rawoutstream, + " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n"); PRINTVALSTREAM(rawoutstream, " and remove filters to objects dset3, dset4, dset5\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "4) h5repack -L -c 10 -s 20:dtype file1 file2\n"); @@ -278,7 +320,8 @@ static void usage(const char *prog) { * Return: Does not return *------------------------------------------------------------------------- */ -static void leave(int ret) +static void +leave(int ret) { h5tools_close(); HDexit(ret); @@ -292,15 +335,15 @@ static void leave(int ret) * Return: void, exit on error *------------------------------------------------------------------------- */ -static -int read_info(const char *filename, pack_opt_t *options) +static int +read_info(const char *filename, pack_opt_t *options) { - char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - char comp_info[1024]; + char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + char comp_info[1024]; FILE *fp = NULL; - char c; - int i; - int ret_value = EXIT_SUCCESS; + char c; + int i; + int ret_value = EXIT_SUCCESS; if (NULL == (fp = HDfopen(filename, "r"))) { error_msg("cannot open options file %s\n", filename); @@ -315,7 +358,7 @@ int read_info(const char *filename, pack_opt_t *options) break; /* Info indicator must be for layout or filter */ - if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) { + if (HDstrcmp(stype, "-l") && HDstrcmp(stype, "-f")) { error_msg("bad file format for %s", filename); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; @@ -429,16 +472,16 @@ set_sort_order(const char *form) * Purpose: parse command line input *------------------------------------------------------------------------- */ -static -int parse_command_line(int argc, const char **argv, pack_opt_t* options) +static int +parse_command_line(int argc, const char **argv, pack_opt_t *options) { h5tools_vol_info_t in_vol_info; h5tools_vol_info_t out_vol_info; - hbool_t custom_in_fapl = FALSE; - hbool_t custom_out_fapl = FALSE; - hid_t tmp_fapl = H5I_INVALID_HID; - int bound, opt; - int ret_value = 0; + hbool_t custom_in_fapl = FALSE; + hbool_t custom_out_fapl = FALSE; + hid_t tmp_fapl = H5I_INVALID_HID; + int bound, opt; + int ret_value = 0; /* Initialize fapl info structs */ HDmemset(&in_vol_info, 0, sizeof(h5tools_vol_info_t)); @@ -446,7 +489,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) /* parse command line options */ while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { - switch ((char) opt) { + switch ((char)opt) { /* -i for backward compatibility */ case 'i': @@ -497,8 +540,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'm': - options->min_comp = HDstrtoull(opt_arg , NULL, 0); - if ((int) options->min_comp <= 0) { + options->min_comp = HDstrtoull(opt_arg, NULL, 0); + if ((int)options->min_comp <= 0) { error_msg("invalid minimum compress size <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -546,66 +589,64 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'c': - options->grp_compact = HDatoi( opt_arg ); + options->grp_compact = HDatoi(opt_arg); if (options->grp_compact > 0) options->latest = TRUE; /* must use latest format */ break; case 'd': - options->grp_indexed = HDatoi( opt_arg ); + options->grp_indexed = HDatoi(opt_arg); if (options->grp_indexed > 0) options->latest = TRUE; /* must use latest format */ break; - case 's': - { - int idx = 0; - int ssize = 0; - char *msgPtr = HDstrchr(opt_arg, ':'); - options->latest = TRUE; /* must use latest format */ - if (msgPtr == NULL) { - ssize = HDatoi(opt_arg); - for (idx = 0; idx < 5; idx++) - options->msg_size[idx] = ssize; - } - else { - char msgType[10]; - - HDstrcpy(msgType, msgPtr + 1); - msgPtr[0] = '\0'; - ssize = HDatoi( opt_arg ); - if (!HDstrncmp(msgType, "dspace", 6)) - options->msg_size[0] = ssize; - else if (!HDstrncmp(msgType, "dtype", 5)) - options->msg_size[1] = ssize; - else if (!HDstrncmp(msgType, "fill", 4)) - options->msg_size[2] = ssize; - else if (!HDstrncmp(msgType, "pline", 5)) - options->msg_size[3] = ssize; - else if (!HDstrncmp(msgType, "attr", 4)) - options->msg_size[4] = ssize; - } + case 's': { + int idx = 0; + int ssize = 0; + char *msgPtr = HDstrchr(opt_arg, ':'); + options->latest = TRUE; /* must use latest format */ + if (msgPtr == NULL) { + ssize = HDatoi(opt_arg); + for (idx = 0; idx < 5; idx++) + options->msg_size[idx] = ssize; } - break; + else { + char msgType[10]; + + HDstrcpy(msgType, msgPtr + 1); + msgPtr[0] = '\0'; + ssize = HDatoi(opt_arg); + if (!HDstrncmp(msgType, "dspace", 6)) + options->msg_size[0] = ssize; + else if (!HDstrncmp(msgType, "dtype", 5)) + options->msg_size[1] = ssize; + else if (!HDstrncmp(msgType, "fill", 4)) + options->msg_size[2] = ssize; + else if (!HDstrncmp(msgType, "pline", 5)) + options->msg_size[3] = ssize; + else if (!HDstrncmp(msgType, "attr", 4)) + options->msg_size[4] = ssize; + } + } break; case 'u': options->ublock_filename = opt_arg; break; case 'b': - options->ublock_size = (hsize_t) HDatol( opt_arg ); + options->ublock_size = (hsize_t)HDatol(opt_arg); break; case 'M': - options->meta_block_size = (hsize_t) HDatol( opt_arg ); + options->meta_block_size = (hsize_t)HDatol(opt_arg); break; case 't': - options->threshold = (hsize_t) HDatol( opt_arg ); + options->threshold = (hsize_t)HDatol(opt_arg); break; case 'a': - options->alignment = HDstrtoull(opt_arg , NULL, 0); + options->alignment = HDstrtoull(opt_arg, NULL, 0); if (options->alignment < 1) { error_msg("invalid alignment size\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); @@ -614,30 +655,28 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) } break; - case 'S': - { - char strategy[MAX_NC_NAME]; - - HDstrcpy(strategy, opt_arg); - if (!HDstrcmp(strategy, "FSM_AGGR")) - options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; - else if (!HDstrcmp(strategy, "PAGE")) - options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE; - else if (!HDstrcmp(strategy, "AGGR")) - options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR; - else if (!HDstrcmp(strategy, "NONE")) - options->fs_strategy = H5F_FSPACE_STRATEGY_NONE; - else { - error_msg("invalid file space management strategy\n", opt_arg); - h5tools_setstatus(EXIT_FAILURE); - ret_value = -1; - goto done; - } - if (options->fs_strategy == (H5F_fspace_strategy_t)0) - /* To distinguish the "specified" zero value */ - options->fs_strategy = (H5F_fspace_strategy_t)-1; + case 'S': { + char strategy[MAX_NC_NAME]; + + HDstrcpy(strategy, opt_arg); + if (!HDstrcmp(strategy, "FSM_AGGR")) + options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + else if (!HDstrcmp(strategy, "PAGE")) + options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE; + else if (!HDstrcmp(strategy, "AGGR")) + options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR; + else if (!HDstrcmp(strategy, "NONE")) + options->fs_strategy = H5F_FSPACE_STRATEGY_NONE; + else { + error_msg("invalid file space management strategy\n", opt_arg); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + goto done; } - break; + if (options->fs_strategy == (H5F_fspace_strategy_t)0) + /* To distinguish the "specified" zero value */ + options->fs_strategy = (H5F_fspace_strategy_t)-1; + } break; case 'P': options->fs_persist = HDatoi(opt_arg); @@ -657,7 +696,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) options->fs_pagesize = HDstrtoll(opt_arg, NULL, 0); if (options->fs_pagesize == 0) /* To distinguish the "specified" zero value */ - options->fs_pagesize = -1; + options->fs_pagesize = -1; break; case 'q': @@ -683,15 +722,15 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case '1': - in_vol_info.type = VOL_BY_VALUE; + in_vol_info.type = VOL_BY_VALUE; in_vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg); - custom_in_fapl = TRUE; + custom_in_fapl = TRUE; break; case '2': - in_vol_info.type = VOL_BY_NAME; + in_vol_info.type = VOL_BY_NAME; in_vol_info.u.name = opt_arg; - custom_in_fapl = TRUE; + custom_in_fapl = TRUE; break; case '3': @@ -699,15 +738,15 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case '4': - out_vol_info.type = VOL_BY_VALUE; + out_vol_info.type = VOL_BY_VALUE; out_vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg); - custom_out_fapl = TRUE; + custom_out_fapl = TRUE; break; case '5': - out_vol_info.type = VOL_BY_NAME; + out_vol_info.type = VOL_BY_NAME; out_vol_info.u.name = opt_arg; - custom_out_fapl = TRUE; + custom_out_fapl = TRUE; break; case '6': @@ -717,12 +756,12 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) default: break; } /* end switch */ - } /* end while there are more options to parse */ + } /* end while there are more options to parse */ /* If neither -i nor -o given, get in and out files positionally */ if (0 == (has_i + has_o)) { if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { - infile = argv[opt_ind]; + infile = argv[opt_ind]; outfile = argv[opt_ind + 1]; if (!HDstrcmp(infile, outfile)) { @@ -801,10 +840,11 @@ done: * Failure: EXIT_FAILURE(1) *------------------------------------------------------------------------- */ -int main(int argc, const char **argv) +int +main(int argc, const char **argv) { - pack_opt_t options; /*the global options */ - int parse_ret; + pack_opt_t options; /*the global options */ + int parse_ret; HDmemset(&options, 0, sizeof(pack_opt_t)); @@ -866,4 +906,3 @@ done: leave(h5tools_getstatus()); } - diff --git a/tools/src/h5repack/h5repack_opttable.c b/tools/src/h5repack/h5repack_opttable.c index 56fc12d..bb90b58 100644 --- a/tools/src/h5repack/h5repack_opttable.c +++ b/tools/src/h5repack/h5repack_opttable.c @@ -21,24 +21,25 @@ * Purpose: initialize a pack_info_t structure * * Return: void - *------------------------------------------------------------------------- + *------------------------------------------------------------------------- */ -void init_packobject(pack_info_t *obj) +void +init_packobject(pack_info_t *obj) { int j, k; HDstrcpy(obj->path, "\0"); for (j = 0; j < H5_REPACK_MAX_NFILTERS; j++) { - obj->filter[j].filtn = -1; + obj->filter[j].filtn = -1; obj->filter[j].cd_nelmts = CD_VALUES; for (k = 0; k < CD_VALUES; k++) obj->filter[j].cd_values[k] = 0; } obj->chunk.rank = -1; - obj->refobj_id = -1; - obj->layout = H5D_LAYOUT_ERROR; - obj->nfilters = 0; + obj->refobj_id = -1; + obj->layout = H5D_LAYOUT_ERROR; + obj->nfilters = 0; } /*------------------------------------------------------------------------- @@ -50,7 +51,8 @@ void init_packobject(pack_info_t *obj) *------------------------------------------------------------------------- */ -static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt) +static void +aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt) { if (table->objs[I].nfilters < H5_REPACK_MAX_NFILTERS) table->objs[I].filter[table->objs[I].nfilters++] = filt; @@ -66,7 +68,8 @@ static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_in * Return: void *------------------------------------------------------------------------- */ -static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info_t *pack) +static void +aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info_t *pack) { int k; @@ -75,15 +78,14 @@ static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info /* -2 means the NONE option, remove chunking and set the layout to contiguous */ if (pack->chunk.rank == -2) { - table->objs[I].layout = H5D_CONTIGUOUS; + table->objs[I].layout = H5D_CONTIGUOUS; table->objs[I].chunk.rank = -2; } /* otherwise set the chunking type */ else { table->objs[I].chunk.rank = pack->chunk.rank; for (k = 0; k < pack->chunk.rank; k++) - table->objs[I].chunk.chunk_lengths[k] = - pack->chunk.chunk_lengths[k]; + table->objs[I].chunk.chunk_lengths[k] = pack->chunk.chunk_lengths[k]; } } } @@ -100,10 +102,10 @@ static int aux_inctable(pack_opttbl_t *table, unsigned n_objs) { unsigned u; - int ret_value = 0; + int ret_value = 0; table->size += n_objs; - table->objs = (pack_info_t*) HDrealloc(table->objs, table->size * sizeof(pack_info_t)); + table->objs = (pack_info_t *)HDrealloc(table->objs, table->size * sizeof(pack_info_t)); if (table->objs == NULL) { H5TOOLS_INFO("not enough memory for options table"); ret_value = -1; @@ -116,27 +118,28 @@ aux_inctable(pack_opttbl_t *table, unsigned n_objs) return ret_value; } - /*------------------------------------------------------------------------- * Function: options_table_init * * Purpose: init options table * * Return: 0, ok, -1, fail - *------------------------------------------------------------------------- + *------------------------------------------------------------------------- */ -int options_table_init(pack_opttbl_t **tbl) { - unsigned int i; +int +options_table_init(pack_opttbl_t **tbl) +{ + unsigned int i; pack_opttbl_t *table; - int ret_value = 0; + int ret_value = 0; - if (NULL == (table = (pack_opttbl_t *) HDmalloc(sizeof(pack_opttbl_t)))) { + if (NULL == (table = (pack_opttbl_t *)HDmalloc(sizeof(pack_opttbl_t)))) { H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table"); } - table->size = 30; + table->size = 30; table->nelems = 0; - if (NULL == (table->objs = (pack_info_t*) HDmalloc(table->size * sizeof(pack_info_t)))) { + if (NULL == (table->objs = (pack_info_t *)HDmalloc(table->size * sizeof(pack_info_t)))) { HDfree(table); H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table"); } @@ -149,7 +152,6 @@ done: return ret_value; } - /*------------------------------------------------------------------------- * Function: options_table_free * @@ -159,7 +161,9 @@ done: *------------------------------------------------------------------------- */ -int options_table_free(pack_opttbl_t *table) { +int +options_table_free(pack_opttbl_t *table) +{ HDfree(table->objs); HDfree(table); return 0; @@ -171,15 +175,15 @@ int options_table_free(pack_opttbl_t *table) { * Purpose: add a layout option to the option list * * Return: 0, ok, -1, fail - *------------------------------------------------------------------------- + *------------------------------------------------------------------------- */ int -options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table) +options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table) { unsigned i, j, I; - unsigned added = 0; - hbool_t found = FALSE; - int ret_value = 0; + unsigned added = 0; + hbool_t found = FALSE; + int ret_value = 0; /* increase the size of the collection by N_OBJS if necessary */ if (table->nelems + n_objs >= table->size) @@ -193,7 +197,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa /* linear table search */ for (i = 0; i < table->nelems; i++) { /*already on the table */ - if (HDstrcmp(obj_list[j].obj,table->objs[i].path) == 0) { + if (HDstrcmp(obj_list[j].obj, table->objs[i].path) == 0) { /* already chunk info inserted for this one; exit */ if (table->objs[i].chunk.rank > 0) { H5TOOLS_INFO("chunk information already inserted for <%s>\n", obj_list[j].obj); @@ -206,7 +210,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa break; } } /* if */ - } /* i */ + } /* i */ if (!found) { /* keep the grow in a temp var */ @@ -220,14 +224,13 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa -f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20 dset1 is already inserted, but dset2 must also be */ - else - if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) { - /* keep the grow in a temp var */ - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_layout(table, I, pack); - } + else if (found && HDstrcmp(obj_list[j].obj, table->objs[i].path) != 0) { + /* keep the grow in a temp var */ + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_layout(table, I, pack); + } } /* j */ } /* first time insertion */ @@ -258,8 +261,8 @@ int options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pack_opttbl_t *table) { unsigned int i, j, I; - unsigned added = 0; - hbool_t found = FALSE; + unsigned added = 0; + hbool_t found = FALSE; /* increase the size of the collection by N_OBJS if necessary */ if (table->nelems + n_objs >= table->size) @@ -279,7 +282,7 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa found = TRUE; break; } /* if */ - } /* i */ + } /* i */ if (!found) { /* keep the grow in a temp var */ @@ -293,14 +296,13 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa -l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1 dset1 is already inserted, but dset2 must also be */ - else - if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) { - /* keep the grow in a temp var */ - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_filter(table, I, filt); - } + else if (found && HDstrcmp(obj_list[j].obj, table->objs[i].path) != 0) { + /* keep the grow in a temp var */ + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_filter(table, I, filt); + } } /* j */ } @@ -329,9 +331,11 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa *------------------------------------------------------------------------- */ -pack_info_t* options_get_object(const char *path, pack_opttbl_t *table) { +pack_info_t * +options_get_object(const char *path, pack_opttbl_t *table) +{ unsigned int i; - char tbl_path[MAX_NC_NAME + 1]; /* +1 for start with "/" case */ + char tbl_path[MAX_NC_NAME + 1]; /* +1 for start with "/" case */ for (i = 0; i < table->nelems; i++) { /* make full path (start with "/") to compare correctly */ diff --git a/tools/src/h5repack/h5repack_parse.c b/tools/src/h5repack/h5repack_parse.c index 95cacc1..2147a47 100644 --- a/tools/src/h5repack/h5repack_parse.c +++ b/tools/src/h5repack/h5repack_parse.c @@ -37,8 +37,9 @@ * "A,B:NONE" *------------------------------------------------------------------------- */ -obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, - pack_opt_t *options, int *is_glb) { +obj_list_t * +parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb) +{ size_t i, m, u; char c; size_t len = HDstrlen(str); @@ -48,7 +49,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, char scomp[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; char stype[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; char smask[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - obj_list_t* obj_list = NULL; + obj_list_t *obj_list = NULL; unsigned pixels_per_block; /* initialize compression info */ @@ -59,7 +60,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, for (i = 0, n = 0; i < len; i++) { c = str[i]; if (c == ':') { - end_obj = (int) i; + end_obj = (int)i; break; } if (c == ',') @@ -71,13 +72,13 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, if (end_obj == -1) { /* apply to all objects */ options->all_filter = 1; - *is_glb = 1; - *n_objs = 1; + *is_glb = 1; + *n_objs = 1; } else *n_objs = n; - obj_list = (obj_list_t *) HDmalloc(n * sizeof(obj_list_t)); + obj_list = (obj_list_t *)HDmalloc(n * sizeof(obj_list_t)); if (obj_list == NULL) { error_msg("could not allocate object list\n"); return NULL; @@ -85,10 +86,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, /* get object list */ if (end_obj > 0) - for (j = 0, k = 0, n = 0; j < (unsigned) end_obj; j++, k++) { - c = str[j]; + for (j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) { + c = str[j]; sobj[k] = c; - if (c == ',' || j == (unsigned) (end_obj - 1)) { + if (c == ',' || j == (unsigned)(end_obj - 1)) { if (c == ',') sobj[k] = '\0'; else @@ -101,7 +102,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /* nothing after : */ - if (end_obj + 1 == (int) len) { + if (end_obj + 1 == (int)len) { if (obj_list) HDfree(obj_list); error_msg("input Error: Invalid compression type in <%s>\n", str); @@ -111,25 +112,25 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, /* get filter additional parameters */ m = 0; for (i = (size_t)(end_obj + 1), k = 0, j = 0; i < len; i++, k++) { - c = str[i]; + c = str[i]; scomp[k] = c; if (c == '=' || i == len - 1) { - if (c == '=') { /*one more parameter */ + if (c == '=') { /*one more parameter */ scomp[k] = '\0'; /*cut space */ /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP - * szip has the format SZIP= - * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN' - * example SZIP=8,NN - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SZIP + * szip has the format SZIP= + * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN' + * example SZIP=8,NN + *------------------------------------------------------------------------- + */ if (HDstrcmp(scomp, "SZIP") == 0) { l = -1; /* mask index check */ for (m = 0, u = i + 1; u < len; u++, m++) { if (str[u] == ',') { stype[m] = '\0'; /* end digit of szip */ - l = 0; /* start EC or NN search */ - u++; /* skip ',' */ + l = 0; /* start EC or NN search */ + u++; /* skip ',' */ } c = str[u]; if (!HDisdigit(c) && l == -1) { @@ -145,10 +146,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, l++; if (l == 2) { smask[l] = '\0'; - i = len - 1; /* end */ - if (HDstrcmp(smask,"NN") == 0) + i = len - 1; /* end */ + if (HDstrcmp(smask, "NN") == 0) filt->cd_values[j++] = H5_SZIP_NN_OPTION_MASK; - else if (HDstrcmp(smask,"EC") == 0) + else if (HDstrcmp(smask, "EC") == 0) filt->cd_values[j++] = H5_SZIP_EC_OPTION_MASK; else { error_msg("szip mask must be 'NN' or 'EC' \n"); @@ -157,29 +158,29 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } } /* u */ - } /*if */ + } /*if */ /*------------------------------------------------------------------------- - * H5Z_FILTER_SCALEOFFSET - * scaleoffset has the format SOFF= - * scale_type can be - * integer datatype, H5Z_SO_INT (IN) - * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS) - * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented - * for integer datatypes, scale_factor denotes Minimum Bits - * for float datatypes, scale_factor denotes decimal scale factor - * examples - * SOFF=31,IN - * SOFF=3,DF - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SCALEOFFSET + * scaleoffset has the format SOFF= + * scale_type can be + * integer datatype, H5Z_SO_INT (IN) + * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS) + * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented + * for integer datatypes, scale_factor denotes Minimum Bits + * for float datatypes, scale_factor denotes decimal scale factor + * examples + * SOFF=31,IN + * SOFF=3,DF + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "SOFF") == 0) { l = -1; /* mask index check */ for (m = 0, u = i + 1; u < len; u++, m++) { if (str[u] == ',') { stype[m] = '\0'; /* end digit */ - l = 0; /* start 'IN' , 'DS', or 'ES' search */ - u++; /* skip ',' */ + l = 0; /* start 'IN' , 'DS', or 'ES' search */ + u++; /* skip ',' */ } c = str[u]; if (!HDisdigit(c) && l == -1) { @@ -195,8 +196,8 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, l++; if (l == 2) { smask[l] = '\0'; - i = len - 1; /* end */ - if (HDstrcmp(smask,"IN") == 0) + i = len - 1; /* end */ + if (HDstrcmp(smask, "IN") == 0) filt->cd_values[j++] = H5Z_SO_INT; else if (HDstrcmp(smask, "DS") == H5Z_SO_FLOAT_DSCALE) filt->cd_values[j++] = H5Z_SO_FLOAT_DSCALE; @@ -207,15 +208,15 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } } /* u */ - } /*if */ + } /*if */ /*------------------------------------------------------------------------- - * User Defined - * has the format UD= - * BZIP2 example - * UD=307,0,1,9 - *------------------------------------------------------------------------- - */ + * User Defined + * has the format + *UD= BZIP2 example + * UD=307,0,1,9 + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "UD") == 0) { l = -1; /* filter number index check */ f = -1; /* filter flag index check */ @@ -225,15 +226,15 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, stype[q] = '\0'; /* end digit */ if (l == -1) { filt->filtn = HDatoi(stype); - l = 0; + l = 0; } else if (f == -1) { filt->filt_flag = (unsigned)HDstrtoul(stype, NULL, 0); - f = 0; + f = 0; } else if (p == -1) { filt->cd_nelmts = HDstrtoull(stype, NULL, 0); - p = 0; + p = 0; } else { filt->cd_values[j++] = (unsigned)HDstrtoul(stype, NULL, 0); @@ -260,9 +261,9 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } /*if */ /*------------------------------------------------------------------------- - * all other filters - *------------------------------------------------------------------------- - */ + * all other filters + *------------------------------------------------------------------------- + */ else { /* here we could have 1 or 2 digits */ for (m = 0, u = i + 1; u < len; u++, m++) { @@ -279,36 +280,36 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, stype[m] = '\0'; } /*if */ - filt->cd_values[j++] = (unsigned) HDstrtoul(stype, NULL, 0); - if(filt->cd_nelmts == 0) + filt->cd_values[j++] = (unsigned)HDstrtoul(stype, NULL, 0); + if (filt->cd_nelmts == 0) j = 0; i += m; /* jump */ } else if (i == len - 1) { /*no more parameters */ scomp[k + 1] = '\0'; - no_param = 1; + no_param = 1; } /*------------------------------------------------------------------------- - * translate from string to filter symbol - *------------------------------------------------------------------------- - */ + * translate from string to filter symbol + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5Z_FILTER_NONE - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_NONE + *------------------------------------------------------------------------- + */ if (HDstrcmp(scomp, "NONE") == 0) { - filt->filtn = H5Z_FILTER_NONE; + filt->filtn = H5Z_FILTER_NONE; filt->cd_nelmts = 0; } /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_DEFLATE + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "GZIP") == 0) { - filt->filtn = H5Z_FILTER_DEFLATE; + filt->filtn = H5Z_FILTER_DEFLATE; filt->cd_nelmts = 1; if (no_param) { /*no more parameters, GZIP must have parameter */ if (obj_list) @@ -319,11 +320,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SZIP + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "SZIP") == 0) { - filt->filtn = H5Z_FILTER_SZIP; + filt->filtn = H5Z_FILTER_SZIP; filt->cd_nelmts = 2; if (no_param) { /*no more parameters, SZIP must have parameter */ if (obj_list) @@ -334,11 +335,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } /*------------------------------------------------------------------------- - * H5Z_FILTER_SHUFFLE - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SHUFFLE + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "SHUF") == 0) { - filt->filtn = H5Z_FILTER_SHUFFLE; + filt->filtn = H5Z_FILTER_SHUFFLE; filt->cd_nelmts = 0; if (m > 0) { /*shuffle does not have parameter */ if (obj_list) @@ -348,11 +349,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /*------------------------------------------------------------------------- - * H5Z_FILTER_FLETCHER32 - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_FLETCHER32 + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "FLET") == 0) { - filt->filtn = H5Z_FILTER_FLETCHER32; + filt->filtn = H5Z_FILTER_FLETCHER32; filt->cd_nelmts = 0; if (m > 0) { /*shuffle does not have parameter */ if (obj_list) @@ -362,11 +363,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /*------------------------------------------------------------------------- - * H5Z_FILTER_NBIT - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_NBIT + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "NBIT") == 0) { - filt->filtn = H5Z_FILTER_NBIT; + filt->filtn = H5Z_FILTER_NBIT; filt->cd_nelmts = 0; if (m > 0) { /*nbit does not have parameter */ if (obj_list) @@ -376,11 +377,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /*------------------------------------------------------------------------- - * H5Z_FILTER_SCALEOFFSET - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SCALEOFFSET + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "SOFF") == 0) { - filt->filtn = H5Z_FILTER_SCALEOFFSET; + filt->filtn = H5Z_FILTER_SCALEOFFSET; filt->cd_nelmts = 2; if (no_param) { /*no more parameters, SOFF must have parameter */ if (obj_list) @@ -390,9 +391,9 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /*------------------------------------------------------------------------- - * User Defined Filter - *------------------------------------------------------------------------- - */ + * User Defined Filter + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "UD") == 0) { /* parameters does not match count */ if (filt->cd_nelmts != j) { @@ -413,56 +414,55 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } /*i*/ /*------------------------------------------------------------------------- - * check valid parameters - *------------------------------------------------------------------------- - */ + * check valid parameters + *------------------------------------------------------------------------- + */ switch (filt->filtn) { - /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_DEFLATE: - if (filt->cd_values[0] > 9) { - if (obj_list) - HDfree(obj_list); - error_msg("invalid compression parameter in <%s>\n", str); - HDexit(EXIT_FAILURE); - } - break; /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SZIP: - pixels_per_block = filt->cd_values[0]; - if ((pixels_per_block % 2) == 1) { - if (obj_list) - HDfree(obj_list); - error_msg("pixels_per_block is not even in <%s>\n", str); - HDexit(EXIT_FAILURE); - } - if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) { - if (obj_list) - HDfree(obj_list); - error_msg("pixels_per_block is too large in <%s>\n", str); - HDexit(EXIT_FAILURE); - } - if ((HDstrcmp(smask,"NN") != 0) && (HDstrcmp(smask,"EC") != 0)) { - if (obj_list) - HDfree(obj_list); - error_msg("szip mask must be 'NN' or 'EC' \n"); - HDexit(EXIT_FAILURE); - } - break; - default: - break; + * H5Z_FILTER_DEFLATE + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_DEFLATE: + if (filt->cd_values[0] > 9) { + if (obj_list) + HDfree(obj_list); + error_msg("invalid compression parameter in <%s>\n", str); + HDexit(EXIT_FAILURE); + } + break; + /*------------------------------------------------------------------------- + * H5Z_FILTER_SZIP + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SZIP: + pixels_per_block = filt->cd_values[0]; + if ((pixels_per_block % 2) == 1) { + if (obj_list) + HDfree(obj_list); + error_msg("pixels_per_block is not even in <%s>\n", str); + HDexit(EXIT_FAILURE); + } + if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) { + if (obj_list) + HDfree(obj_list); + error_msg("pixels_per_block is too large in <%s>\n", str); + HDexit(EXIT_FAILURE); + } + if ((HDstrcmp(smask, "NN") != 0) && (HDstrcmp(smask, "EC") != 0)) { + if (obj_list) + HDfree(obj_list); + error_msg("szip mask must be 'NN' or 'EC' \n"); + HDexit(EXIT_FAILURE); + } + break; + default: + break; }; return obj_list; } - /*------------------------------------------------------------------------- * Function: parse_layout * @@ -484,9 +484,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, * *------------------------------------------------------------------------- */ -obj_list_t* parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about layout needed */ -pack_opt_t *options) { - obj_list_t* obj_list = NULL; +obj_list_t * +parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about layout needed */ + pack_opt_t *options) +{ + obj_list_t *obj_list = NULL; unsigned i, j, n; char c; size_t len = HDstrlen(str); @@ -503,7 +505,7 @@ pack_opt_t *options) { for (i = 0, n = 0; i < len; i++) { c = str[i]; if (c == ':') - end_obj = (int) i; + end_obj = (int)i; if (c == ',') n++; } @@ -513,7 +515,7 @@ pack_opt_t *options) { } n++; - obj_list = (obj_list_t*) HDmalloc(n * sizeof(obj_list_t)); + obj_list = (obj_list_t *)HDmalloc(n * sizeof(obj_list_t)); if (obj_list == NULL) { error_msg("could not allocate object list\n"); return NULL; @@ -522,10 +524,10 @@ pack_opt_t *options) { /* get object list */ if (end_obj > 0) - for (j = 0, k = 0, n = 0; j < (unsigned) end_obj; j++, k++) { - c = str[j]; + for (j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) { + c = str[j]; sobj[k] = c; - if (c == ',' || j == (unsigned) (end_obj - 1)) { + if (c == ',' || j == (unsigned)(end_obj - 1)) { if (c == ',') sobj[k] = '\0'; else @@ -538,7 +540,7 @@ pack_opt_t *options) { } /* nothing after : */ - if (end_obj + 1 == (int) len) { + if (end_obj + 1 == (int)len) { if (obj_list) HDfree(obj_list); error_msg("in parse layout, no characters after : in <%s>\n", str); @@ -546,7 +548,7 @@ pack_opt_t *options) { } /* get layout info */ - for (j = (unsigned) (end_obj + 1), n = 0; n <= 5; j++, n++) { + for (j = (unsigned)(end_obj + 1), n = 0; n <= 5; j++, n++) { if (n == 5) { slayout[n] = '\0'; /*cut string */ if (HDstrcmp(slayout, "COMPA") == 0) @@ -561,16 +563,16 @@ pack_opt_t *options) { } } else { - c = str[j]; + c = str[j]; slayout[n] = c; } } /* j */ if (pack->layout == H5D_CHUNKED) { /*------------------------------------------------------------------------- - * get chunk info - *------------------------------------------------------------------------- - */ + * get chunk info + *------------------------------------------------------------------------- + */ k = 0; if (j > len) { if (obj_list) @@ -580,7 +582,7 @@ pack_opt_t *options) { } for (i = j, c_index = 0; i < len; i++) { - c = str[i]; + c = str[i]; sdim[k] = c; k++; /*increment sdim index */ @@ -593,8 +595,8 @@ pack_opt_t *options) { if (c == 'x' || i == len - 1) { if (c == 'x') { - sdim[k - 1] = '\0'; - k = 0; + sdim[k - 1] = '\0'; + k = 0; pack->chunk.chunk_lengths[c_index] = HDstrtoull(sdim, NULL, 0); if (pack->chunk.chunk_lengths[c_index] == 0) { if (obj_list) @@ -606,8 +608,8 @@ pack_opt_t *options) { } else if (i == len - 1) { /*no more parameters */ sdim[k] = '\0'; - k = 0; - if (HDstrcmp(sdim,"NONE") == 0) { + k = 0; + if (HDstrcmp(sdim, "NONE") == 0) { pack->chunk.rank = -2; } else { @@ -621,9 +623,9 @@ pack_opt_t *options) { pack->chunk.rank = c_index + 1; } } /*if */ - } /*if c=='x' || i==len-1 */ - } /*i*/ - } /*H5D_CHUNKED*/ + } /*if c=='x' || i==len-1 */ + } /*i*/ + } /*H5D_CHUNKED*/ return obj_list; } diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c index 2685823..78957c6 100644 --- a/tools/src/h5repack/h5repack_refs.c +++ b/tools/src/h5repack/h5repack_refs.c @@ -15,17 +15,15 @@ #include "h5diff.h" #include "h5tools.h" - /*------------------------------------------------------------------------- * local functions *------------------------------------------------------------------------- */ -static const char* MapIdToName(hid_t refobj_id,trav_table_t *travt); -static int copy_refs_attr(hid_t loc_in, hid_t loc_out, - trav_table_t *travt, hid_t fidout); -static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, - hid_t fid_out, void *ref_out, trav_table_t *travt); +static const char *MapIdToName(hid_t refobj_id, trav_table_t *travt); +static int copy_refs_attr(hid_t loc_in, hid_t loc_out, trav_table_t *travt, hid_t fidout); +static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, hid_t fid_out, void *ref_out, + trav_table_t *travt); /*------------------------------------------------------------------------- * Function: do_copy_refobjs @@ -37,35 +35,33 @@ static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, *------------------------------------------------------------------------- */ -int do_copy_refobjs(hid_t fidin, - hid_t fidout, - trav_table_t *travt, - pack_opt_t *options) /* repack options */ +int +do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - hid_t grp_in = H5I_INVALID_HID; /* read group ID */ - hid_t grp_out = H5I_INVALID_HID; /* write group ID */ - hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */ - hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */ - hid_t type_in = H5I_INVALID_HID; /* named type ID */ - hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t space_id = H5I_INVALID_HID; /* space ID */ - hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */ - hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */ - size_t msize; /* memory size of memory type */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ + hid_t grp_in = H5I_INVALID_HID; /* read group ID */ + hid_t grp_out = H5I_INVALID_HID; /* write group ID */ + hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */ + hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */ + hid_t type_in = H5I_INVALID_HID; /* named type ID */ + hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t space_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */ + hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */ + size_t msize; /* memory size of memory type */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ unsigned int i, j; - int k; - named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ - int ret_value = 0; + int k; + named_dt_t * named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ + int ret_value = 0; /*------------------------------------------------------------------------- - * browse - *------------------------------------------------------------------------- - */ - for(i = 0; i < travt->nobjs; i++) { - switch(travt->objs[i].type) { + * browse + *------------------------------------------------------------------------- + */ + for (i = 0; i < travt->nobjs; i++) { + switch (travt->objs[i].type) { /*------------------------------------------------------------------------- * H5TRAV_TYPE_GROUP *------------------------------------------------------------------------- @@ -75,27 +71,28 @@ int do_copy_refobjs(hid_t fidin, * copy referenced objects in attributes *------------------------------------------------------------------------- */ - if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + if ((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); - if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); - if(copy_refs_attr(grp_in, grp_out, travt, fidout) < 0) + if (copy_refs_attr(grp_in, grp_out, travt, fidout) < 0) H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed"); - if(H5Gclose(grp_out) < 0) + if (H5Gclose(grp_out) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); - if(H5Gclose(grp_in) < 0) + if (H5Gclose(grp_in) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); /*------------------------------------------------------------------------- * check for hard links *------------------------------------------------------------------------- */ - if(travt->objs[i].nlinks) - for(j = 0; j < travt->objs[i].nlinks; j++) - H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); + if (travt->objs[i].nlinks) + for (j = 0; j < travt->objs[i].nlinks; j++) + H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, + travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); break; /*------------------------------------------------------------------------- @@ -103,26 +100,26 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ case H5TRAV_TYPE_DATASET: - if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); - if((space_id = H5Dget_space(dset_in)) < 0) + if ((space_id = H5Dget_space(dset_in)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); - if((ftype_id = H5Dget_type(dset_in)) < 0) + if ((ftype_id = H5Dget_type(dset_in)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); - if((dcpl_id = H5Dget_create_plist(dset_in)) < 0) + if ((dcpl_id = H5Dget_create_plist(dset_in)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); - if((rank = H5Sget_simple_extent_ndims(space_id)) < 0) + if ((rank = H5Sget_simple_extent_ndims(space_id)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); - if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); nelmts = 1; - for(k = 0; k < rank; k++) + for (k = 0; k < rank; k++) nelmts *= dims[k]; - if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) + if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed"); - if((msize = H5Tget_size(mtype_id)) == 0) + if ((msize = H5Tget_size(mtype_id)) == 0) H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); /*------------------------------------------------------------------------- @@ -132,7 +129,7 @@ int do_copy_refobjs(hid_t fidin, * 2) the internal filters might be turned off *------------------------------------------------------------------------- */ - if(h5tools_canreadf(NULL, dcpl_id) == 1) { + if (h5tools_canreadf(NULL, dcpl_id) == 1) { /*------------------------------------------------------------------------- * test for a valid output dataset *------------------------------------------------------------------------- @@ -144,75 +141,78 @@ int do_copy_refobjs(hid_t fidin, * we cannot just copy the buffers, but instead we recreate the reference *------------------------------------------------------------------------- */ - if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { - hid_t refobj_id = H5I_INVALID_HID; - hobj_ref_t *refbuf = NULL; /* buffer for object references */ - hobj_ref_t *buf = NULL; - const char* refname; - unsigned u; + if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { + hid_t refobj_id = H5I_INVALID_HID; + hobj_ref_t *refbuf = NULL; /* buffer for object references */ + hobj_ref_t *buf = NULL; + const char *refname; + unsigned u; /*------------------------------------------------------------------------- * read to memory *------------------------------------------------------------------------- */ - if(nelmts) { + if (nelmts) { buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); - if(buf==NULL) { - HDprintf("cannot read into memory\n" ); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); - refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize); - if(refbuf == NULL){ - HDprintf("cannot allocate memory\n" ); + refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize); + if (refbuf == NULL) { + HDprintf("cannot allocate memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ - for(u = 0; u < nelmts; u++) { - H5E_BEGIN_TRY { - if((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_OBJECT, &buf[u])) < 0) + for (u = 0; u < nelmts; u++) { + H5E_BEGIN_TRY + { + if ((refobj_id = + H5Rdereference2(dset_in, H5P_DEFAULT, H5R_OBJECT, &buf[u])) < 0) continue; - } H5E_END_TRY; + } + H5E_END_TRY; /* get the name. a valid name could only occur * in the second traversal of the file */ - if((refname = MapIdToName(refobj_id, travt)) != NULL) { + if ((refname = MapIdToName(refobj_id, travt)) != NULL) { /* create the reference, -1 parameter for objects */ - if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); - if(options->verbose) { - HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name ); + if (options->verbose) { + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); HDprintf("object <%s> object reference created to <%s>\n", - travt->objs[i].name, - refname); + travt->objs[i].name, refname); } } /*refname*/ if (H5Oclose(refobj_id) < 0) H5TOOLS_ERROR((-1), "H5Oclose refob failed"); } /* u */ - } /*nelmts*/ + } /*nelmts*/ /*------------------------------------------------------------------------- * create/write dataset/close *------------------------------------------------------------------------- */ - if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, + H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); - if(nelmts) - if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) + if (nelmts) + if (H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); - if(buf) + if (buf) HDfree(buf); - if(refbuf) + if (refbuf) HDfree(refbuf); - /*------------------------------------------------------ - * copy attrs - *----------------------------------------------------*/ - if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + /*------------------------------------------------------ + * copy attrs + *----------------------------------------------------*/ + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); } /*H5T_STD_REF_OBJ*/ @@ -220,87 +220,93 @@ int do_copy_refobjs(hid_t fidin, * dataset region references *------------------------------------------------------------------------- */ - else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { + else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { hid_t refobj_id = H5I_INVALID_HID; - hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ - hdset_reg_ref_t *buf = NULL; /* output buffer */ - const char* refname; + hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ + hdset_reg_ref_t *buf = NULL; /* output buffer */ + const char * refname; unsigned u; /*------------------------------------------------------------------------- * read input to memory *------------------------------------------------------------------------- */ - if(nelmts) { + if (nelmts) { buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize)); - if(buf == NULL) { + if (buf == NULL) { HDprintf("cannot read into memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); /*------------------------------------------------------------------------- * create output *------------------------------------------------------------------------- */ - refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ - if(refbuf == NULL) { + refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), + (size_t)nelmts); /*init to zero */ + if (refbuf == NULL) { HDprintf("cannot allocate memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ - for(u = 0; u < nelmts; u++) { - H5E_BEGIN_TRY { - if((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_DATASET_REGION, &buf[u])) < 0) + for (u = 0; u < nelmts; u++) { + H5E_BEGIN_TRY + { + if ((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_DATASET_REGION, + &buf[u])) < 0) continue; - } H5E_END_TRY; + } + H5E_END_TRY; /* get the name. a valid name could only occur * in the second traversal of the file */ - if((refname = MapIdToName(refobj_id, travt)) != NULL) { - hid_t region_id = H5I_INVALID_HID; /* region id of the referenced dataset */ + if ((refname = MapIdToName(refobj_id, travt)) != NULL) { + hid_t region_id = + H5I_INVALID_HID; /* region id of the referenced dataset */ - if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) + if ((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Rget_region failed"); /* create the reference, we need the space_id */ - if(H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, region_id) < 0) + if (H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, + region_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); - if(H5Sclose(region_id) < 0) + if (H5Sclose(region_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); - if(options->verbose) { - HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name ); + if (options->verbose) { + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); HDprintf("object <%s> region reference created to <%s>\n", - travt->objs[i].name, - refname); + travt->objs[i].name, refname); } } /*refname*/ if (H5Oclose(refobj_id) < 0) H5TOOLS_ERROR((-1), "H5Oclose refobj_id failed"); } /* u */ - } /*nelmts*/ + } /*nelmts*/ /*------------------------------------------------------------------------- * create/write dataset/close *------------------------------------------------------------------------- */ - if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, + H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); - if(nelmts) - if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) + if (nelmts) + if (H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); - if(buf) + if (buf) HDfree(buf); - if(refbuf) + if (refbuf) HDfree(refbuf); - /*----------------------------------------------------- - * copy attrs - *----------------------------------------------------*/ - if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + /*----------------------------------------------------- + * copy attrs + *----------------------------------------------------*/ + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); } /* H5T_STD_REF_DSETREG */ /*------------------------------------------------------------------------- @@ -308,7 +314,7 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ else { - if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); } /* end else */ @@ -316,18 +322,19 @@ int do_copy_refobjs(hid_t fidin, * copy referenced objects in attributes *------------------------------------------------------------------------- */ - if(copy_refs_attr(dset_in, dset_out, travt, fidout) < 0) + if (copy_refs_attr(dset_in, dset_out, travt, fidout) < 0) H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed"); /*------------------------------------------------------------------------- * check for hard links *------------------------------------------------------------------------- */ - if(travt->objs[i].nlinks) - for(j = 0; j < travt->objs[i].nlinks; j++) - H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); + if (travt->objs[i].nlinks) + for (j = 0; j < travt->objs[i].nlinks; j++) + H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, + travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); - if(H5Dclose(dset_out) < 0) + if (H5Dclose(dset_out) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } /*can_read*/ @@ -335,15 +342,15 @@ int do_copy_refobjs(hid_t fidin, * close *------------------------------------------------------------------------- */ - if(H5Tclose(ftype_id) < 0) + if (H5Tclose(ftype_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); - if(H5Tclose(mtype_id) < 0) + if (H5Tclose(mtype_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - if(H5Sclose(space_id) < 0) + if (H5Sclose(space_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); - if(H5Dclose(dset_in) < 0) + if (H5Dclose(dset_in) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); break; @@ -352,9 +359,9 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ case H5TRAV_TYPE_NAMED_DATATYPE: - if((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed"); - if(H5Tclose(type_in) < 0) + if (H5Tclose(type_in) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); break; @@ -374,7 +381,7 @@ int do_copy_refobjs(hid_t fidin, default: break; } /* end switch */ - } /* end for */ + } /* end for */ /* Finalize (link) the stack of named datatypes (if any) * This function is paired with copy_named_datatype() which is called @@ -386,7 +393,8 @@ int do_copy_refobjs(hid_t fidin, return ret_value; done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(grp_in); H5Gclose(grp_out); H5Pclose(dcpl_id); @@ -397,12 +405,12 @@ done: H5Tclose(mtype_id); H5Tclose(type_in); named_datatype_free(&named_dt_head, 1); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } - /*------------------------------------------------------------------------- * Function: copy_refs_attr * @@ -425,91 +433,87 @@ done: *------------------------------------------------------------------------- */ -static int copy_refs_attr(hid_t loc_in, - hid_t loc_out, - trav_table_t *travt, - hid_t fidout) /* for saving references */ +static int +copy_refs_attr(hid_t loc_in, hid_t loc_out, trav_table_t *travt, hid_t fidout) /* for saving references */ { - hid_t attr_id = H5I_INVALID_HID; /* attr ID */ - hid_t attr_out = H5I_INVALID_HID; /* attr ID */ - hid_t space_id = H5I_INVALID_HID; /* space ID */ - hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */ - hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */ - size_t msize; /* memory size of type */ - hsize_t nelmts; /* number of elements in dataset */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + hid_t attr_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr_out = H5I_INVALID_HID; /* attr ID */ + hid_t space_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */ + hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */ + size_t msize; /* memory size of type */ + hsize_t nelmts; /* number of elements in dataset */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ char name[255]; - H5O_info2_t oinfo; /* Object info */ + H5O_info2_t oinfo; /* Object info */ unsigned u, i, j; int rank; H5T_class_t type_class = -1; - hbool_t is_ref = 0, - is_ref_vlen = 0, - is_ref_array = 0, - is_ref_comp = 0; - void *refbuf = NULL; - void *buf = NULL; - unsigned *ref_comp_index = NULL; - size_t *ref_comp_size = NULL; + hbool_t is_ref = 0, is_ref_vlen = 0, is_ref_array = 0, is_ref_comp = 0; + void * refbuf = NULL; + void * buf = NULL; + unsigned * ref_comp_index = NULL; + size_t * ref_comp_size = NULL; int ref_comp_field_n = 0; - int ret_value = 0; + int ret_value = 0; - if(H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) + if (H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed"); - for(u = 0; u < (unsigned)oinfo.num_attrs; u++) { + for (u = 0; u < (unsigned)oinfo.num_attrs; u++) { is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0; /* open attribute */ - if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, + H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed"); /* get the file datatype */ - if((ftype_id = H5Aget_type(attr_id)) < 0) + if ((ftype_id = H5Aget_type(attr_id)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aget_type failed"); type_class = H5Tget_class(ftype_id); - if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) + if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed"); - if((msize = H5Tget_size(mtype_id)) == 0) + if ((msize = H5Tget_size(mtype_id)) == 0) H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); is_ref = (type_class == H5T_REFERENCE); - if(type_class == H5T_VLEN ) { + if (type_class == H5T_VLEN) { hid_t base_type = H5Tget_super(ftype_id); is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE); - msize = H5Tget_size(base_type); + msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) H5TOOLS_ERROR((-1), "H5Tclose base_type failed"); } - else if(type_class == H5T_ARRAY ) { + else if (type_class == H5T_ARRAY) { hid_t base_type = H5Tget_super(ftype_id); is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE); - msize = H5Tget_size(base_type); + msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Tclose base_type failed"); } - else if(type_class == H5T_COMPOUND) { - int nmembers = H5Tget_nmembers(ftype_id) ; + else if (type_class == H5T_COMPOUND) { + int nmembers = H5Tget_nmembers(ftype_id); if (nmembers < 1) H5TOOLS_GOTO_ERROR((-1), "H5Tget_nmembers failed"); - ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers*sizeof(unsigned)); - ref_comp_size = (size_t *)HDmalloc((size_t)nmembers*sizeof(ref_comp_size)); + ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers * sizeof(unsigned)); + ref_comp_size = (size_t *)HDmalloc((size_t)nmembers * sizeof(ref_comp_size)); ref_comp_field_n = 0; - for (i=0; i<(unsigned)nmembers; i++) { + for (i = 0; i < (unsigned)nmembers; i++) { hid_t mtid = H5Tget_member_type(ftype_id, i); if ((H5Tget_class(mtid) == H5T_REFERENCE)) { ref_comp_index[ref_comp_field_n] = i; - ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid); + ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid); ref_comp_field_n++; } if (H5Tclose(mtid) < 0) @@ -537,10 +541,8 @@ static int copy_refs_attr(hid_t loc_in, KY 2020-02-07 */ is_ref_comp = (ref_comp_field_n > 0); - } - if (!(is_ref || is_ref_vlen || is_ref_array || is_ref_comp)) { if (H5Tclose(mtype_id) < 0) H5TOOLS_ERROR((-1), "H5Tclose mtype_id failed"); @@ -552,31 +554,30 @@ static int copy_refs_attr(hid_t loc_in, } /* get name */ - if(H5Aget_name(attr_id, 255, name) < 0) + if (H5Aget_name(attr_id, 255, name) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aget_name failed"); /* get the dataspace handle */ - if((space_id = H5Aget_space(attr_id)) < 0) + if ((space_id = H5Aget_space(attr_id)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aget_space failed"); /* get dimensions */ - if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) + if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); - /*------------------------------------------------------------------------- - * elements - *------------------------------------------------------------------------- - */ + * elements + *------------------------------------------------------------------------- + */ nelmts = 1; - for(j = 0; j < (unsigned)rank; j++) + for (j = 0; j < (unsigned)rank; j++) nelmts *= dims[j]; if (is_ref_array) { - unsigned array_rank = 0; - hsize_t array_size = 1; - hsize_t array_dims[H5S_MAX_RANK]; - hid_t base_type = H5Tget_super(ftype_id); + unsigned array_rank = 0; + hsize_t array_size = 1; + hsize_t array_dims[H5S_MAX_RANK]; + hid_t base_type = H5Tget_super(ftype_id); msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) @@ -584,153 +585,163 @@ static int copy_refs_attr(hid_t loc_in, array_rank = (unsigned)H5Tget_array_ndims(mtype_id); H5Tget_array_dims2(mtype_id, array_dims); - for(j = 0; j 0) { + if (nelmts > 0) { /* handle object references */ - if((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE==msize)) { + if ((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE == msize)) { buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); - if(buf == NULL) { + if (buf == NULL) { HDprintf("cannot read into memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Aread(attr_id, mtype_id, buf) < 0) + if (H5Aread(attr_id, mtype_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize); - if(refbuf == NULL) { + if (refbuf == NULL) { HDprintf("cannot allocate memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ - for(i = 0; i < (unsigned)nelmts; i++) - if(update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout, &((hobj_ref_t *)refbuf)[i], travt) < 0) + for (i = 0; i < (unsigned)nelmts; i++) + if (update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout, + &((hobj_ref_t *)refbuf)[i], travt) < 0) continue; } /* H5T_STD_REF_OBJ */ /* handle region references */ - else if((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) { + else if ((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) { buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize)); - if(buf == NULL) { - HDprintf( "cannot read into memory\n" ); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Aread(attr_id, mtype_id, buf) < 0) + if (H5Aread(attr_id, mtype_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); /*------------------------------------------------------------------------- * create output *------------------------------------------------------------------------- */ - refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ - if(refbuf == NULL) { - HDprintf( "cannot allocate memory\n" ); + refbuf = + (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ + if (refbuf == NULL) { + HDprintf("cannot allocate memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ - for(i = 0; i < (unsigned)nelmts; i++) - if(update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout, &((hdset_reg_ref_t *)refbuf)[i], travt) < 0) + for (i = 0; i < (unsigned)nelmts; i++) + if (update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout, + &((hdset_reg_ref_t *)refbuf)[i], travt) < 0) continue; } /* H5T_STD_REF_DSETREG */ else if (is_ref_vlen) { /* handle VLEN of references */ - buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t))); + buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t))); refbuf = buf; /* reuse the read buffer for write */ - if(buf == NULL) { - HDprintf( "cannot read into memory\n" ); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Aread(attr_id, mtype_id, buf) < 0) + if (H5Aread(attr_id, mtype_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); - if (H5R_OBJ_REF_BUF_SIZE==msize) { + if (H5R_OBJ_REF_BUF_SIZE == msize) { hobj_ref_t ref_out; - for (i=0; i<(unsigned)nelmts; i++) { + for (i = 0; i < (unsigned)nelmts; i++) { hobj_ref_t *ptr = (hobj_ref_t *)((hvl_t *)buf)[i].p; - for (j=0; j<((hvl_t *)buf)[i].len; j++ ) { - if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt)<0) + for (j = 0; j < ((hvl_t *)buf)[i].len; j++) { + if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt) < 0) continue; HDmemcpy(&(ptr[j]), &ref_out, msize); } - } /* for (i=0; inobjs; u++) { - if(travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET || - travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP || - travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) { - H5O_info2_t ref_oinfo; /* Stat for the refobj id */ + for (u = 0; u < travt->nobjs; u++) { + if (travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET || + travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP || + travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) { + H5O_info2_t ref_oinfo; /* Stat for the refobj id */ int token_cmp; /* obtain information to identify the referenced object uniquely */ - if(H5Oget_info3(refobj_id, &ref_oinfo, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(refobj_id, &ref_oinfo, H5O_INFO_BASIC) < 0) goto out; - if(H5Otoken_cmp(refobj_id, &ref_oinfo.token, &travt->objs[u].obj_token, &token_cmp) < 0) + if (H5Otoken_cmp(refobj_id, &ref_oinfo.token, &travt->objs[u].obj_token, &token_cmp) < 0) goto out; - if(!token_cmp) { + if (!token_cmp) { ret = travt->objs[u].name; goto out; } - } /* end if */ - } /* u */ + } /* end if */ + } /* u */ out: return ret; @@ -829,13 +842,14 @@ out: * Purpose: Update a reference value *------------------------------------------------------------------------- */ -static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, - hid_t fid_out, void *ref_out, trav_table_t *travt) +static herr_t +update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, hid_t fid_out, void *ref_out, + trav_table_t *travt) { const char *ref_obj_name; - hid_t space_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; hid_t ref_obj_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; ref_obj_id = H5Rdereference2(obj_id, H5P_DEFAULT, ref_type, ref_in); if (ref_obj_id < 0) @@ -851,15 +865,16 @@ static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, H5TOOLS_GOTO_ERROR(FAIL, "H5Rget_region failed"); } - if(H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0) + if (H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Rcreate failed"); done: - H5E_BEGIN_TRY { - H5Sclose(space_id); - H5Oclose(ref_obj_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Sclose(space_id); + H5Oclose(ref_obj_id); + } + H5E_END_TRY; return ret_value; } - diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c index 7bb5dfd..4149729 100644 --- a/tools/src/h5repack/h5repack_verify.c +++ b/tools/src/h5repack/h5repack_verify.c @@ -17,13 +17,12 @@ /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) #endif static int verify_layout(hid_t pid, pack_info_t *obj); static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter); - /*------------------------------------------------------------------------- * Function: h5repack_verify * @@ -39,62 +38,62 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options) { - hid_t fidin = H5I_INVALID_HID; /* file ID for input file*/ - hid_t fidout = H5I_INVALID_HID; /* file ID for output file*/ - hid_t did = H5I_INVALID_HID; /* dataset ID */ - hid_t pid = H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t sid = H5I_INVALID_HID; /* space ID */ - hid_t tid = H5I_INVALID_HID; /* type ID */ - int ok = 1; /* step results */ - unsigned int i; - trav_table_t *travt = NULL; - hid_t fcpl_in = H5I_INVALID_HID; /* file creation property for input file */ - hid_t fcpl_out = H5I_INVALID_HID; /* file creation property for output file */ - H5F_fspace_strategy_t in_strategy, out_strategy; /* file space handling strategy for in/output file */ - hbool_t in_persist, out_persist; /* free-space persist status for in/output file */ - hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */ - hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */ - int ret_value = 0; + hid_t fidin = H5I_INVALID_HID; /* file ID for input file*/ + hid_t fidout = H5I_INVALID_HID; /* file ID for output file*/ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t pid = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t sid = H5I_INVALID_HID; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* type ID */ + int ok = 1; /* step results */ + unsigned int i; + trav_table_t * travt = NULL; + hid_t fcpl_in = H5I_INVALID_HID; /* file creation property for input file */ + hid_t fcpl_out = H5I_INVALID_HID; /* file creation property for output file */ + H5F_fspace_strategy_t in_strategy, out_strategy; /* file space handling strategy for in/output file */ + hbool_t in_persist, out_persist; /* free-space persist status for in/output file */ + hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */ + hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */ + int ret_value = 0; /* open the output file */ - if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) + if ((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on <%s>", out_fname); - for(i = 0; i < options->op_tbl->nelems; i++) { - char *name = options->op_tbl->objs[i].path; - pack_info_t *obj = &options->op_tbl->objs[i]; + for (i = 0; i < options->op_tbl->nelems; i++) { + char * name = options->op_tbl->objs[i].path; + pack_info_t *obj = &options->op_tbl->objs[i]; - /*------------------------------------------------------------------------- - * open - *------------------------------------------------------------------------- - */ - if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) + /*------------------------------------------------------------------------- + * open + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name); - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); - if((pid = H5Dget_create_plist(did)) < 0) + if ((pid = H5Dget_create_plist(did)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); - /*------------------------------------------------------------------------- - * filter check - *------------------------------------------------------------------------- - */ - if(verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0) + /*------------------------------------------------------------------------- + * filter check + *------------------------------------------------------------------------- + */ + if (verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0) ok = 0; - /*------------------------------------------------------------------------- - * layout check - *------------------------------------------------------------------------- - */ - if((obj->layout != -1) && (verify_layout(pid, obj) == 0)) + /*------------------------------------------------------------------------- + * layout check + *------------------------------------------------------------------------- + */ + if ((obj->layout != -1) && (verify_layout(pid, obj) == 0)) ok = 0; - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ if (H5Pclose(pid) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Sclose(sid) < 0) @@ -105,65 +104,65 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); } - /*------------------------------------------------------------------------- - * check for the "all" objects option - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * check for the "all" objects option + *------------------------------------------------------------------------- + */ - if(options->all_filter == 1 || options->all_layout == 1) { + if (options->all_filter == 1 || options->all_layout == 1) { /* Initialize indexing options */ h5trav_set_index(sort_by, sort_order); /* init table */ trav_table_init(fidout, &travt); /* get the list of objects in the file */ - if(h5trav_gettable(fidout, travt) < 0) + if (h5trav_gettable(fidout, travt) < 0) H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); - for(i = 0; i < travt->nobjs; i++) { + for (i = 0; i < travt->nobjs; i++) { char *name = travt->objs[i].name; - if(travt->objs[i].type == H5TRAV_TYPE_DATASET) { - /*------------------------------------------------------------------------- - * open - *------------------------------------------------------------------------- - */ - if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) + if (travt->objs[i].type == H5TRAV_TYPE_DATASET) { + /*------------------------------------------------------------------------- + * open + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name); - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); - if((pid = H5Dget_create_plist(did)) < 0) + if ((pid = H5Dget_create_plist(did)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); - /*------------------------------------------------------------------------- - * filter check - *------------------------------------------------------------------------- - */ - if(options->all_filter == 1) { - if(verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0) + /*------------------------------------------------------------------------- + * filter check + *------------------------------------------------------------------------- + */ + if (options->all_filter == 1) { + if (verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0) ok = 0; } - /*------------------------------------------------------------------------- - * layout check - *------------------------------------------------------------------------- - */ - if(options->all_layout == 1) { + /*------------------------------------------------------------------------- + * layout check + *------------------------------------------------------------------------- + */ + if (options->all_layout == 1) { pack_info_t pack; init_packobject(&pack); pack.layout = options->layout_g; - pack.chunk = options->chunk_g; - if(verify_layout(pid, &pack) == 0) + pack.chunk = options->chunk_g; + if (verify_layout(pid, &pack) == 0) ok = 0; } - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ if (H5Pclose(pid) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Sclose(sid) < 0) @@ -173,45 +172,47 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options if (H5Tclose(tid) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); } /* if */ - } /* i */ + } /* i */ /* free table */ trav_table_free(travt); travt = NULL; } - /*------------------------------------------------------------------------- - * Verify that file space info are set as expected - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Verify that file space info are set as expected + *------------------------------------------------------------------------- + */ /* open the input file */ - if((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on file <%s>", in_fname); /* Get file creation property list for input file */ - if((fcpl_in = H5Fget_create_plist(fidin)) < 0) + if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list"); /* Get file space info for input file */ - if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold"); + if (H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) + H5TOOLS_GOTO_ERROR((-1), + "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold"); /* Get file space page size for input file */ - if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) + if (H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space page size"); /* Output file is already opened */ /* Get file creation property list for output file */ - if((fcpl_out = H5Fget_create_plist(fidout)) < 0) + if ((fcpl_out = H5Fget_create_plist(fidout)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list"); /* Get file space info for output file */ - if(H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold"); + if (H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0) + H5TOOLS_GOTO_ERROR((-1), + "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold"); /* Get file space page size for output file */ - if(H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0) + if (H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space page size"); /* @@ -219,12 +220,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options * If -S option is not set, the file space handling strategy should be * the same as the input file's strategy. */ - if(options->fs_strategy) { - if(out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy)) + if (options->fs_strategy) { + if (out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy)) H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected"); } else { - if(out_strategy != in_strategy) + if (out_strategy != in_strategy) H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected"); } @@ -233,12 +234,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options * If the -P option is not set, the free-space persist status should be * the same as the input file's free-space persist status */ - if(options->fs_persist) { - if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist)) + if (options->fs_persist) { + if (out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist)) H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected"); } else { - if(out_persist != in_persist) + if (out_persist != in_persist) H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected"); } @@ -247,12 +248,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options * If the -T option is not set, the threshold should be the same as the * input file's threshold size. */ - if(options->fs_threshold) { - if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold)) + if (options->fs_threshold) { + if (out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold)) H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected"); } else { - if(out_threshold != in_threshold) + if (out_threshold != in_threshold) H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected"); } @@ -261,20 +262,20 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options * If the -G option is not set, the file space page size should be * the same as the input file's file space page size. */ - if(options->fs_pagesize) { - if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize)) + if (options->fs_pagesize) { + if (out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize)) H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected"); } else { /* "-G" is not set */ - if(out_pagesize != in_pagesize) + if (out_pagesize != in_pagesize) H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected"); - } ret_value = ok; done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl_in); H5Pclose(fcpl_out); H5Pclose(pid); @@ -285,7 +286,8 @@ done: H5Fclose(fidout); if (travt) trav_table_free(travt); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } /* h5repack_verify() */ @@ -305,13 +307,14 @@ done: *------------------------------------------------------------------------- */ -int verify_layout(hid_t pid, pack_info_t *obj) +int +verify_layout(hid_t pid, pack_info_t *obj) { - hsize_t chsize[64]; /* chunk size in elements */ - H5D_layout_t layout; /* layout */ - int nfilters; /* number of filters */ - int rank; /* rank */ - int i; /* index */ + hsize_t chsize[64]; /* chunk size in elements */ + H5D_layout_t layout; /* layout */ + int nfilters; /* number of filters */ + int rank; /* rank */ + int i; /* index */ /* check if we have filters in the input object */ if ((nfilters = H5Pget_nfilters(pid)) < 0) @@ -328,8 +331,8 @@ int verify_layout(hid_t pid, pack_info_t *obj) if (obj->layout != layout) return 0; - if (layout==H5D_CHUNKED) { - if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize/*out*/)) < 0) + if (layout == H5D_CHUNKED) { + if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize /*out*/)) < 0) return -1; if (obj->chunk.rank != rank) return 0; @@ -353,49 +356,50 @@ int verify_layout(hid_t pid, pack_info_t *obj) *------------------------------------------------------------------------- */ -int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl) +int +h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl) { - hid_t fid1 = H5I_INVALID_HID; /* file ID */ - hid_t fid2 = H5I_INVALID_HID; /* file ID */ - hid_t dset1 = H5I_INVALID_HID; /* dataset ID */ - hid_t dset2 = H5I_INVALID_HID; /* dataset ID */ - hid_t gid = H5I_INVALID_HID; /* group ID */ - hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t gcplid = H5I_INVALID_HID; /* group creation property list */ - unsigned crt_order_flag1; /* group creation order flag */ - unsigned crt_order_flag2; /* group creation order flag */ + hid_t fid1 = H5I_INVALID_HID; /* file ID */ + hid_t fid2 = H5I_INVALID_HID; /* file ID */ + hid_t dset1 = H5I_INVALID_HID; /* dataset ID */ + hid_t dset2 = H5I_INVALID_HID; /* dataset ID */ + hid_t gid = H5I_INVALID_HID; /* group ID */ + hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t gcplid = H5I_INVALID_HID; /* group creation property list */ + unsigned crt_order_flag1; /* group creation order flag */ + unsigned crt_order_flag2; /* group creation order flag */ trav_table_t *trav = NULL; unsigned int i; int ret_value = 1; - /*------------------------------------------------------------------------- - * open the files - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * open the files + *------------------------------------------------------------------------- + */ /* Open the files */ if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, TRUE, NULL, 0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR); if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, TRUE, NULL, 0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR); - /*------------------------------------------------------------------------- - * get file table list of objects - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * get file table list of objects + *------------------------------------------------------------------------- + */ /* Initialize indexing options */ h5trav_set_index(sort_by, sort_order); /* init table */ trav_table_init(fid1, &trav); - if(h5trav_gettable(fid1, trav) < 0) + if (h5trav_gettable(fid1, trav) < 0) H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); - /*------------------------------------------------------------------------- - * traverse the suppplied object list - *------------------------------------------------------------------------- - */ - for(i = 0; i < trav->nobjs; i++) { - if(trav->objs[i].type == H5TRAV_TYPE_GROUP) { + /*------------------------------------------------------------------------- + * traverse the suppplied object list + *------------------------------------------------------------------------- + */ + for (i = 0; i < trav->nobjs; i++) { + if (trav->objs[i].type == H5TRAV_TYPE_GROUP) { if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed on first <%s>", trav->objs[i].name); if ((gcplid = H5Gget_create_plist(gid)) < 0) @@ -421,40 +425,40 @@ int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, h if (crt_order_flag1 != crt_order_flag2) H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name); } - else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) { - if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) + else if (trav->objs[i].type == H5TRAV_TYPE_DATASET) { + if ((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on first <%s>", trav->objs[i].name); - if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) + if ((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on second <%s>", trav->objs[i].name); - if((dcpl1 = H5Dget_create_plist(dset1)) < 0) + if ((dcpl1 = H5Dget_create_plist(dset1)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); - if((dcpl2 = H5Dget_create_plist(dset2)) < 0) + if ((dcpl2 = H5Dget_create_plist(dset2)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); - /*------------------------------------------------------------------------- - * compare the property lists - *------------------------------------------------------------------------- - */ - if((ret_value = H5Pequal(dcpl1, dcpl2)) < 0) + /*------------------------------------------------------------------------- + * compare the property lists + *------------------------------------------------------------------------- + */ + if ((ret_value = H5Pequal(dcpl1, dcpl2)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pequal failed"); - if(ret_value == 0) + if (ret_value == 0) H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name); - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if(H5Pclose(dcpl1) < 0) + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + if (H5Pclose(dcpl1) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - if(H5Pclose(dcpl2) < 0) + if (H5Pclose(dcpl2) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - if(H5Dclose(dset1) < 0) + if (H5Dclose(dset1) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); - if(H5Dclose(dset2) < 0) + if (H5Dclose(dset2) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } /*if*/ - } /*for*/ + } /*for*/ done: H5E_BEGIN_TRY @@ -467,14 +471,14 @@ done: H5Fclose(fid2); H5Pclose(gcplid); H5Gclose(gid); - if(trav) + if (trav) trav_table_free(trav); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } - /*------------------------------------------------------------------------- * Function: verify_filters * @@ -489,27 +493,25 @@ done: *------------------------------------------------------------------------- */ -static -int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) +static int +verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) { - int nfilters_dcpl; /* number of filters in DCPL*/ - unsigned filt_flags; /* filter flags */ - H5Z_filter_t filtn; /* filter identification number */ - unsigned cd_values[20]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ - char f_name[256]; /* filter name */ - size_t size; /* type size */ - int i; /* index */ - unsigned j; /* index */ + int nfilters_dcpl; /* number of filters in DCPL*/ + unsigned filt_flags; /* filter flags */ + H5Z_filter_t filtn; /* filter identification number */ + unsigned cd_values[20]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ + char f_name[256]; /* filter name */ + size_t size; /* type size */ + int i; /* index */ + unsigned j; /* index */ /* get information about filters */ - if((nfilters_dcpl = H5Pget_nfilters(pid)) < 0) + if ((nfilters_dcpl = H5Pget_nfilters(pid)) < 0) return -1; /* if we do not have filters and the requested filter is NONE, return 1 */ - if(!nfilters_dcpl && - nfilters == 1 && - filter[0].filtn == H5Z_FILTER_NONE) + if (!nfilters_dcpl && nfilters == 1 && filter[0].filtn == H5Z_FILTER_NONE) return 1; /* else the numbers of filters must match */ @@ -523,8 +525,8 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) for (i = 0; i < nfilters_dcpl; i++) { cd_nelmts = NELMTS(cd_values); - filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts, - cd_values, sizeof(f_name), f_name, NULL); + filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), f_name, + NULL); /* filter ID */ if (filtn < 0) @@ -535,7 +537,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) /* compare client data values. some filters do return local values */ switch (filtn) { case H5Z_FILTER_NONE: - break; + break; case H5Z_FILTER_SHUFFLE: /* 1 private client value is returned by DCPL */ @@ -543,7 +545,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) return 0; /* get dataset's type size */ - if((size = H5Tget_size(tid)) <= 0) + if ((size = H5Tget_size(tid)) <= 0) return -1; /* the private client value holds the dataset's type size */ diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index 1d587e1..c13a160 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #include "h5tools.h" #include "h5tools_utils.h" #include "h5tools_ref.h" @@ -24,100 +24,98 @@ /* Parameters to control statistics gathered */ /* Default threshold for small groups/datasets/attributes */ -#define DEF_SIZE_SMALL_GROUPS 10 -#define DEF_SIZE_SMALL_DSETS 10 -#define DEF_SIZE_SMALL_ATTRS 10 +#define DEF_SIZE_SMALL_GROUPS 10 +#define DEF_SIZE_SMALL_DSETS 10 +#define DEF_SIZE_SMALL_ATTRS 10 -#define SIZE_SMALL_SECTS 10 +#define SIZE_SMALL_SECTS 10 -#define H5_NFILTERS_IMPL 8 /* Number of currently implemented filters + one to - accommodate for user-define filters + one - to accomodate datasets whithout any filters */ +#define H5_NFILTERS_IMPL \ + 8 /* Number of currently implemented filters + one to \ + accommodate for user-define filters + one \ + to accomodate datasets whithout any filters */ /* File space management strategies: see H5Fpublic.h for declarations */ -const char *FS_STRATEGY_NAME[] = { - "H5F_FSPACE_STRATEGY_FSM_AGGR", - "H5F_FSPACE_STRATEGY_PAGE", - "H5F_FSPACE_STRATEGY_AGGR", - "H5F_FSPACE_STRATEGY_NONE", - "unknown", - NULL -}; +const char *FS_STRATEGY_NAME[] = {"H5F_FSPACE_STRATEGY_FSM_AGGR", + "H5F_FSPACE_STRATEGY_PAGE", + "H5F_FSPACE_STRATEGY_AGGR", + "H5F_FSPACE_STRATEGY_NONE", + "unknown", + NULL}; /* Datatype statistics for datasets */ typedef struct dtype_info_t { - hid_t tid; /* ID of datatype */ - unsigned long count; /* Number of types found */ - unsigned long named; /* Number of types that are named */ + hid_t tid; /* ID of datatype */ + unsigned long count; /* Number of types found */ + unsigned long named; /* Number of types that are named */ } dtype_info_t; typedef struct ohdr_info_t { - hsize_t total_size; /* Total size of object headers */ - hsize_t free_size; /* Total free space in object headers */ + hsize_t total_size; /* Total size of object headers */ + hsize_t free_size; /* Total free space in object headers */ } ohdr_info_t; /* Info to pass to the iteration functions */ typedef struct iter_t { - hid_t fid; /* File ID */ - hsize_t filesize; /* Size of the file */ - unsigned long uniq_groups; /* Number of unique groups */ - unsigned long uniq_dsets; /* Number of unique datasets */ - unsigned long uniq_dtypes; /* Number of unique named datatypes */ - unsigned long uniq_links; /* Number of unique links */ - unsigned long uniq_others; /* Number of other unique objects */ - - unsigned long max_links; /* Maximum # of links to an object */ - hsize_t max_fanout; /* Maximum fanout from a group */ - unsigned long *num_small_groups; /* Size of small groups tracked */ - unsigned group_nbins; /* Number of bins for group counts */ - unsigned long *group_bins; /* Pointer to array of bins for group counts */ - ohdr_info_t group_ohdr_info; /* Object header information for groups */ - - hsize_t max_attrs; /* Maximum attributes from a group */ - unsigned long *num_small_attrs; /* Size of small attributes tracked */ - unsigned attr_nbins; /* Number of bins for attribute counts */ - unsigned long *attr_bins; /* Pointer to array of bins for attribute counts */ - - unsigned max_dset_rank; /* Maximum rank of dataset */ - unsigned long dset_rank_count[H5S_MAX_RANK]; /* Number of datasets of each rank */ - hsize_t max_dset_dims; /* Maximum dimension size of dataset */ - unsigned long *small_dset_dims; /* Size of dimensions of small datasets tracked */ - unsigned long dset_layouts[H5D_NLAYOUTS]; /* Type of storage for each dataset */ - unsigned long dset_comptype[H5_NFILTERS_IMPL]; /* Number of currently implemented filters */ - unsigned long dset_ntypes; /* Number of diff. dataset datatypes found */ - dtype_info_t *dset_type_info; /* Pointer to dataset datatype information found */ - unsigned dset_dim_nbins; /* Number of bins for dataset dimensions */ - unsigned long *dset_dim_bins; /* Pointer to array of bins for dataset dimensions */ - ohdr_info_t dset_ohdr_info; /* Object header information for datasets */ - hsize_t dset_storage_size; /* Size of raw data for datasets */ - hsize_t dset_external_storage_size; /* Size of raw data for datasets with external storage */ - ohdr_info_t dtype_ohdr_info; /* Object header information for datatypes */ - hsize_t groups_btree_storage_size; /* btree size for group */ - hsize_t groups_heap_storage_size; /* heap size for group */ - hsize_t attrs_btree_storage_size; /* btree size for attributes (1.8) */ - hsize_t attrs_heap_storage_size; /* fractal heap size for attributes (1.8) */ - hsize_t SM_hdr_storage_size; /* header size for SOHM table (1.8) */ - hsize_t SM_index_storage_size; /* index (btree & list) size for SOHM table (1.8) */ - hsize_t SM_heap_storage_size; /* fractal heap size for SOHM table (1.8) */ - hsize_t super_size; /* superblock size */ - hsize_t super_ext_size; /* superblock extension size */ - hsize_t ublk_size; /* user block size (if exists) */ - H5F_fspace_strategy_t fs_strategy; /* File space management strategy */ - hbool_t fs_persist; /* Free-space persist or not */ - hsize_t fs_threshold; /* Free-space section threshold */ - hsize_t fsp_size; /* File space page size */ - hsize_t free_space; /* Amount of freespace in the file */ - hsize_t free_hdr; /* Size of free space manager metadata in the file */ - unsigned long num_small_sects[SIZE_SMALL_SECTS]; /* Size of small free-space sections */ - unsigned sect_nbins; /* Number of bins for free-space section sizes */ - unsigned long *sect_bins; /* Pointer to array of bins for free-space section sizes */ - hsize_t datasets_index_storage_size;/* meta size for chunked dataset's indexing type */ - hsize_t datasets_heap_storage_size; /* heap size for dataset with external storage */ - unsigned long nexternal; /* Number of external files for a dataset */ - int local; /* Flag to indicate iteration over the object*/ + hid_t fid; /* File ID */ + hsize_t filesize; /* Size of the file */ + unsigned long uniq_groups; /* Number of unique groups */ + unsigned long uniq_dsets; /* Number of unique datasets */ + unsigned long uniq_dtypes; /* Number of unique named datatypes */ + unsigned long uniq_links; /* Number of unique links */ + unsigned long uniq_others; /* Number of other unique objects */ + + unsigned long max_links; /* Maximum # of links to an object */ + hsize_t max_fanout; /* Maximum fanout from a group */ + unsigned long *num_small_groups; /* Size of small groups tracked */ + unsigned group_nbins; /* Number of bins for group counts */ + unsigned long *group_bins; /* Pointer to array of bins for group counts */ + ohdr_info_t group_ohdr_info; /* Object header information for groups */ + + hsize_t max_attrs; /* Maximum attributes from a group */ + unsigned long *num_small_attrs; /* Size of small attributes tracked */ + unsigned attr_nbins; /* Number of bins for attribute counts */ + unsigned long *attr_bins; /* Pointer to array of bins for attribute counts */ + + unsigned max_dset_rank; /* Maximum rank of dataset */ + unsigned long dset_rank_count[H5S_MAX_RANK]; /* Number of datasets of each rank */ + hsize_t max_dset_dims; /* Maximum dimension size of dataset */ + unsigned long *small_dset_dims; /* Size of dimensions of small datasets tracked */ + unsigned long dset_layouts[H5D_NLAYOUTS]; /* Type of storage for each dataset */ + unsigned long dset_comptype[H5_NFILTERS_IMPL]; /* Number of currently implemented filters */ + unsigned long dset_ntypes; /* Number of diff. dataset datatypes found */ + dtype_info_t * dset_type_info; /* Pointer to dataset datatype information found */ + unsigned dset_dim_nbins; /* Number of bins for dataset dimensions */ + unsigned long *dset_dim_bins; /* Pointer to array of bins for dataset dimensions */ + ohdr_info_t dset_ohdr_info; /* Object header information for datasets */ + hsize_t dset_storage_size; /* Size of raw data for datasets */ + hsize_t dset_external_storage_size; /* Size of raw data for datasets with external storage */ + ohdr_info_t dtype_ohdr_info; /* Object header information for datatypes */ + hsize_t groups_btree_storage_size; /* btree size for group */ + hsize_t groups_heap_storage_size; /* heap size for group */ + hsize_t attrs_btree_storage_size; /* btree size for attributes (1.8) */ + hsize_t attrs_heap_storage_size; /* fractal heap size for attributes (1.8) */ + hsize_t SM_hdr_storage_size; /* header size for SOHM table (1.8) */ + hsize_t SM_index_storage_size; /* index (btree & list) size for SOHM table (1.8) */ + hsize_t SM_heap_storage_size; /* fractal heap size for SOHM table (1.8) */ + hsize_t super_size; /* superblock size */ + hsize_t super_ext_size; /* superblock extension size */ + hsize_t ublk_size; /* user block size (if exists) */ + H5F_fspace_strategy_t fs_strategy; /* File space management strategy */ + hbool_t fs_persist; /* Free-space persist or not */ + hsize_t fs_threshold; /* Free-space section threshold */ + hsize_t fsp_size; /* File space page size */ + hsize_t free_space; /* Amount of freespace in the file */ + hsize_t free_hdr; /* Size of free space manager metadata in the file */ + unsigned long num_small_sects[SIZE_SMALL_SECTS]; /* Size of small free-space sections */ + unsigned sect_nbins; /* Number of bins for free-space section sizes */ + unsigned long * sect_bins; /* Pointer to array of bins for free-space section sizes */ + hsize_t datasets_index_storage_size; /* meta size for chunked dataset's indexing type */ + hsize_t datasets_heap_storage_size; /* heap size for dataset with external storage */ + unsigned long nexternal; /* Number of external files for a dataset */ + int local; /* Flag to indicate iteration over the object*/ } iter_t; - static const char *drivername = NULL; #ifdef H5_HAVE_ROS3_VFD @@ -143,27 +141,27 @@ static H5FD_hdfs_fapl_t hdfs_fa = { }; #endif /* H5_HAVE_LIBHDFS */ -static int display_all = TRUE; +static int display_all = TRUE; /* Enable the printing of selected statistics */ -static int display_file = FALSE; /* display file information */ -static int display_group = FALSE; /* display groups information */ -static int display_dset = FALSE; /* display datasets information */ -static int display_dset_dtype_meta = FALSE; /* display datasets' datatype information */ -static int display_attr = FALSE; /* display attributes information */ -static int display_free_sections = FALSE; /* display free space information */ -static int display_summary = FALSE; /* display summary of file space information */ +static int display_file = FALSE; /* display file information */ +static int display_group = FALSE; /* display groups information */ +static int display_dset = FALSE; /* display datasets information */ +static int display_dset_dtype_meta = FALSE; /* display datasets' datatype information */ +static int display_attr = FALSE; /* display attributes information */ +static int display_free_sections = FALSE; /* display free space information */ +static int display_summary = FALSE; /* display summary of file space information */ -static int display_file_metadata = FALSE; /* display file space info for file's metadata */ -static int display_group_metadata = FALSE; /* display file space info for groups' metadata */ -static int display_dset_metadata = FALSE; /* display file space info for datasets' metadata */ +static int display_file_metadata = FALSE; /* display file space info for file's metadata */ +static int display_group_metadata = FALSE; /* display file space info for groups' metadata */ +static int display_dset_metadata = FALSE; /* display file space info for datasets' metadata */ -static int display_object = FALSE; /* not implemented yet */ +static int display_object = FALSE; /* not implemented yet */ /* Initialize threshold for small groups/datasets/attributes */ -static int sgroups_threshold = DEF_SIZE_SMALL_GROUPS; -static int sdsets_threshold = DEF_SIZE_SMALL_DSETS; -static int sattrs_threshold = DEF_SIZE_SMALL_ATTRS; +static int sgroups_threshold = DEF_SIZE_SMALL_GROUPS; +static int sdsets_threshold = DEF_SIZE_SMALL_DSETS; +static int sattrs_threshold = DEF_SIZE_SMALL_ATTRS; /* a structure for handling the order command-line parameters come in */ struct handler_t { @@ -171,120 +169,116 @@ struct handler_t { char **obj; }; -static const char *s_opts ="Aa:Ddm:EFfhGgl:sSTO:Vw:H:"; +static const char *s_opts = "Aa:Ddm:EFfhGgl:sSTO:Vw:H:"; /* e.g. "filemetadata" has to precede "file"; "groupmetadata" has to precede "group" etc. */ -static struct long_options l_opts[] = { - {"help", no_arg, 'h'}, - {"hel", no_arg, 'h'}, - {"he", no_arg, 'h'}, - {"filemetadata", no_arg, 'F'}, - {"filemetadat", no_arg, 'F'}, - {"filemetada", no_arg, 'F'}, - {"filemetad", no_arg, 'F'}, - {"filemeta", no_arg, 'F'}, - {"filemet", no_arg, 'F'}, - {"fileme", no_arg, 'F'}, - {"filem", no_arg, 'F'}, - {"file", no_arg, 'f'}, - {"fil", no_arg, 'f'}, - {"fi", no_arg, 'f'}, - {"groupmetadata", no_arg, 'G'}, - {"groupmetadat", no_arg, 'G'}, - {"groupmetada", no_arg, 'G'}, - {"groupmetad", no_arg, 'G'}, - {"groupmeta", no_arg, 'G'}, - {"groupmet", no_arg, 'G'}, - {"groupme", no_arg, 'G'}, - {"groupm", no_arg, 'G'}, - {"group", no_arg, 'g'}, - {"grou", no_arg, 'g'}, - {"gro", no_arg, 'g'}, - {"gr", no_arg, 'g'}, - { "links", require_arg, 'l' }, - { "link", require_arg, 'l' }, - { "lin", require_arg, 'l' }, - { "li", require_arg, 'l' }, - {"dsetmetadata", no_arg, 'D'}, - {"dsetmetadat", no_arg, 'D'}, - {"dsetmetada", no_arg, 'D'}, - {"dsetmetad", no_arg, 'D'}, - {"dsetmeta", no_arg, 'D'}, - {"dsetmet", no_arg, 'D'}, - {"dsetme", no_arg, 'D'}, - {"dsetm", no_arg, 'D'}, - {"dset", no_arg, 'd'}, - {"dse", no_arg, 'd'}, - {"ds", no_arg, 'd'}, - {"dims", require_arg, 'm'}, - {"dim", require_arg, 'm'}, - {"di", require_arg, 'm'}, - {"dtypemetadata", no_arg, 'T'}, - {"dtypemetadat", no_arg, 'T'}, - {"dtypemetada", no_arg, 'T'}, - {"dtypemetad", no_arg, 'T'}, - {"dtypemeta", no_arg, 'T'}, - {"dtypemet", no_arg, 'T'}, - {"dtypeme", no_arg, 'T'}, - {"dtypem", no_arg, 'T'}, - {"dtype", no_arg, 'T'}, - {"dtyp", no_arg, 'T'}, - {"dty", no_arg, 'T'}, - {"dt", no_arg, 'T'}, - { "object", require_arg, 'O' }, - { "objec", require_arg, 'O' }, - { "obje", require_arg, 'O' }, - { "obj", require_arg, 'O' }, - { "ob", require_arg, 'O' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, - { "ver", no_arg, 'V' }, - { "ve", no_arg, 'V' }, - { "attribute", no_arg, 'A' }, - { "attribut", no_arg, 'A' }, - { "attribu", no_arg, 'A' }, - { "attrib", no_arg, 'A' }, - { "attri", no_arg, 'A' }, - { "attr", no_arg, 'A' }, - { "att", no_arg, 'A' }, - { "at", no_arg, 'A' }, - { "enable-error-stack", no_arg, 'E' }, - { "numattrs", require_arg, 'a' }, - { "numattr", require_arg, 'a' }, - { "numatt", require_arg, 'a' }, - { "numat", require_arg, 'a' }, - { "numa", require_arg, 'a' }, - { "num", require_arg, 'a' }, - { "nu", require_arg, 'a' }, - { "freespace", no_arg, 's' }, - { "freespac", no_arg, 's' }, - { "freespa", no_arg, 's' }, - { "freesp", no_arg, 's' }, - { "frees", no_arg, 's' }, - { "free", no_arg, 's' }, - { "fre", no_arg, 's' }, - { "fr", no_arg, 's' }, - { "summary", no_arg, 'S' }, - { "summar", no_arg, 'S' }, - { "summa", no_arg, 'S' }, - { "summ", no_arg, 'S' }, - { "sum", no_arg, 'S' }, - { "su", no_arg, 'S' }, - { "s3-cred", require_arg, 'w' }, - { "hdfs-attrs", require_arg, 'H' }, - { NULL, 0, '\0' } -}; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"hel", no_arg, 'h'}, + {"he", no_arg, 'h'}, + {"filemetadata", no_arg, 'F'}, + {"filemetadat", no_arg, 'F'}, + {"filemetada", no_arg, 'F'}, + {"filemetad", no_arg, 'F'}, + {"filemeta", no_arg, 'F'}, + {"filemet", no_arg, 'F'}, + {"fileme", no_arg, 'F'}, + {"filem", no_arg, 'F'}, + {"file", no_arg, 'f'}, + {"fil", no_arg, 'f'}, + {"fi", no_arg, 'f'}, + {"groupmetadata", no_arg, 'G'}, + {"groupmetadat", no_arg, 'G'}, + {"groupmetada", no_arg, 'G'}, + {"groupmetad", no_arg, 'G'}, + {"groupmeta", no_arg, 'G'}, + {"groupmet", no_arg, 'G'}, + {"groupme", no_arg, 'G'}, + {"groupm", no_arg, 'G'}, + {"group", no_arg, 'g'}, + {"grou", no_arg, 'g'}, + {"gro", no_arg, 'g'}, + {"gr", no_arg, 'g'}, + {"links", require_arg, 'l'}, + {"link", require_arg, 'l'}, + {"lin", require_arg, 'l'}, + {"li", require_arg, 'l'}, + {"dsetmetadata", no_arg, 'D'}, + {"dsetmetadat", no_arg, 'D'}, + {"dsetmetada", no_arg, 'D'}, + {"dsetmetad", no_arg, 'D'}, + {"dsetmeta", no_arg, 'D'}, + {"dsetmet", no_arg, 'D'}, + {"dsetme", no_arg, 'D'}, + {"dsetm", no_arg, 'D'}, + {"dset", no_arg, 'd'}, + {"dse", no_arg, 'd'}, + {"ds", no_arg, 'd'}, + {"dims", require_arg, 'm'}, + {"dim", require_arg, 'm'}, + {"di", require_arg, 'm'}, + {"dtypemetadata", no_arg, 'T'}, + {"dtypemetadat", no_arg, 'T'}, + {"dtypemetada", no_arg, 'T'}, + {"dtypemetad", no_arg, 'T'}, + {"dtypemeta", no_arg, 'T'}, + {"dtypemet", no_arg, 'T'}, + {"dtypeme", no_arg, 'T'}, + {"dtypem", no_arg, 'T'}, + {"dtype", no_arg, 'T'}, + {"dtyp", no_arg, 'T'}, + {"dty", no_arg, 'T'}, + {"dt", no_arg, 'T'}, + {"object", require_arg, 'O'}, + {"objec", require_arg, 'O'}, + {"obje", require_arg, 'O'}, + {"obj", require_arg, 'O'}, + {"ob", require_arg, 'O'}, + {"version", no_arg, 'V'}, + {"versio", no_arg, 'V'}, + {"versi", no_arg, 'V'}, + {"vers", no_arg, 'V'}, + {"ver", no_arg, 'V'}, + {"ve", no_arg, 'V'}, + {"attribute", no_arg, 'A'}, + {"attribut", no_arg, 'A'}, + {"attribu", no_arg, 'A'}, + {"attrib", no_arg, 'A'}, + {"attri", no_arg, 'A'}, + {"attr", no_arg, 'A'}, + {"att", no_arg, 'A'}, + {"at", no_arg, 'A'}, + {"enable-error-stack", no_arg, 'E'}, + {"numattrs", require_arg, 'a'}, + {"numattr", require_arg, 'a'}, + {"numatt", require_arg, 'a'}, + {"numat", require_arg, 'a'}, + {"numa", require_arg, 'a'}, + {"num", require_arg, 'a'}, + {"nu", require_arg, 'a'}, + {"freespace", no_arg, 's'}, + {"freespac", no_arg, 's'}, + {"freespa", no_arg, 's'}, + {"freesp", no_arg, 's'}, + {"frees", no_arg, 's'}, + {"free", no_arg, 's'}, + {"fre", no_arg, 's'}, + {"fr", no_arg, 's'}, + {"summary", no_arg, 'S'}, + {"summar", no_arg, 'S'}, + {"summa", no_arg, 'S'}, + {"summ", no_arg, 'S'}, + {"sum", no_arg, 'S'}, + {"su", no_arg, 'S'}, + {"s3-cred", require_arg, 'w'}, + {"hdfs-attrs", require_arg, 'H'}, + {NULL, 0, '\0'}}; static void leave(int ret) { - h5tools_close(); - HDexit(ret); + h5tools_close(); + HDexit(ret); } - - /*------------------------------------------------------------------------- * Function: usage * @@ -294,47 +288,49 @@ leave(int ret) * *------------------------------------------------------------------------- */ -static void usage(const char *prog) +static void +usage(const char *prog) { - HDfflush(stdout); - HDfprintf(stdout, "Usage: %s [OPTIONS] file\n", prog); - HDfprintf(stdout, "\n"); - HDfprintf(stdout, " OPTIONS\n"); - HDfprintf(stdout, " -h, --help Print a usage message and exit\n"); - HDfprintf(stdout, " -V, --version Print version number and exit\n"); - HDfprintf(stdout, " -f, --file Print file information\n"); - HDfprintf(stdout, " -F, --filemetadata Print file space information for file's metadata\n"); - HDfprintf(stdout, " -g, --group Print group information\n"); - HDfprintf(stdout, " -l N, --links=N Set the threshold for the # of links when printing\n"); - HDfprintf(stdout, " information for small groups. N is an integer greater\n"); - HDfprintf(stdout, " than 0. The default threshold is 10.\n"); - HDfprintf(stdout, " -G, --groupmetadata Print file space information for groups' metadata\n"); - HDfprintf(stdout, " -d, --dset Print dataset information\n"); - HDfprintf(stdout, " -m N, --dims=N Set the threshold for the dimension sizes when printing\n"); - HDfprintf(stdout, " information for small datasets. N is an integer greater\n"); - HDfprintf(stdout, " than 0. The default threshold is 10.\n"); - HDfprintf(stdout, " -D, --dsetmetadata Print file space information for datasets' metadata\n"); - HDfprintf(stdout, " -T, --dtypemetadata Print datasets' datatype information\n"); - HDfprintf(stdout, " -A, --attribute Print attribute information\n"); - HDfprintf(stdout, " -a N, --numattrs=N Set the threshold for the # of attributes when printing\n"); - HDfprintf(stdout, " information for small # of attributes. N is an integer greater\n"); - HDfprintf(stdout, " than 0. The default threshold is 10.\n"); - HDfprintf(stdout, " -s, --freespace Print free space information\n"); - HDfprintf(stdout, " -S, --summary Print summary of file space information\n"); - HDfprintf(stdout, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n"); - HDfprintf(stdout, " --s3-cred= Access file on S3, using provided credential\n"); - HDfprintf(stdout, " :: (region,id,key)\n"); - HDfprintf(stdout, " If == \"(,,)\", no authentication is used.\n"); - HDfprintf(stdout, " --hdfs-attrs= Access a file on HDFS with given configuration\n"); - HDfprintf(stdout, " attributes.\n"); - HDfprintf(stdout, " :: (,,\n"); - HDfprintf(stdout, " ,,\n"); - HDfprintf(stdout, " )\n"); - HDfprintf(stdout, " If an attribute is empty, a default value will be\n"); - HDfprintf(stdout, " used.\n"); + HDfflush(stdout); + HDfprintf(stdout, "Usage: %s [OPTIONS] file\n", prog); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " OPTIONS\n"); + HDfprintf(stdout, " -h, --help Print a usage message and exit\n"); + HDfprintf(stdout, " -V, --version Print version number and exit\n"); + HDfprintf(stdout, " -f, --file Print file information\n"); + HDfprintf(stdout, " -F, --filemetadata Print file space information for file's metadata\n"); + HDfprintf(stdout, " -g, --group Print group information\n"); + HDfprintf(stdout, " -l N, --links=N Set the threshold for the # of links when printing\n"); + HDfprintf(stdout, " information for small groups. N is an integer greater\n"); + HDfprintf(stdout, " than 0. The default threshold is 10.\n"); + HDfprintf(stdout, " -G, --groupmetadata Print file space information for groups' metadata\n"); + HDfprintf(stdout, " -d, --dset Print dataset information\n"); + HDfprintf(stdout, " -m N, --dims=N Set the threshold for the dimension sizes when printing\n"); + HDfprintf(stdout, + " information for small datasets. N is an integer greater\n"); + HDfprintf(stdout, " than 0. The default threshold is 10.\n"); + HDfprintf(stdout, " -D, --dsetmetadata Print file space information for datasets' metadata\n"); + HDfprintf(stdout, " -T, --dtypemetadata Print datasets' datatype information\n"); + HDfprintf(stdout, " -A, --attribute Print attribute information\n"); + HDfprintf(stdout, " -a N, --numattrs=N Set the threshold for the # of attributes when printing\n"); + HDfprintf(stdout, + " information for small # of attributes. N is an integer greater\n"); + HDfprintf(stdout, " than 0. The default threshold is 10.\n"); + HDfprintf(stdout, " -s, --freespace Print free space information\n"); + HDfprintf(stdout, " -S, --summary Print summary of file space information\n"); + HDfprintf(stdout, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n"); + HDfprintf(stdout, " --s3-cred= Access file on S3, using provided credential\n"); + HDfprintf(stdout, " :: (region,id,key)\n"); + HDfprintf(stdout, " If == \"(,,)\", no authentication is used.\n"); + HDfprintf(stdout, " --hdfs-attrs= Access a file on HDFS with given configuration\n"); + HDfprintf(stdout, " attributes.\n"); + HDfprintf(stdout, " :: (,,\n"); + HDfprintf(stdout, " ,,\n"); + HDfprintf(stdout, " )\n"); + HDfprintf(stdout, " If an attribute is empty, a default value will be\n"); + HDfprintf(stdout, " used.\n"); } - /*------------------------------------------------------------------------- * Function: ceil_log10 * @@ -351,9 +347,9 @@ H5_ATTR_CONST static unsigned ceil_log10(unsigned long x) { unsigned long pow10 = 1; - unsigned ret = 0; + unsigned ret = 0; - while(x >= pow10) { + while (x >= pow10) { pow10 *= 10; ret++; } /* end while */ @@ -361,7 +357,6 @@ ceil_log10(unsigned long x) return ret; } /* ceil_log10() */ - /*------------------------------------------------------------------------- * Function: attribute_stats * @@ -379,39 +374,38 @@ ceil_log10(unsigned long x) static herr_t attribute_stats(iter_t *iter, const H5O_info2_t *oi, const H5O_native_info_t *native_oi) { - unsigned bin; /* "bin" the number of objects falls in */ + unsigned bin; /* "bin" the number of objects falls in */ /* Update dataset & attribute metadata info */ iter->attrs_btree_storage_size += native_oi->meta_size.attr.index_size; iter->attrs_heap_storage_size += native_oi->meta_size.attr.heap_size; /* Update small # of attribute count & limits */ - if(oi->num_attrs <= (hsize_t)sattrs_threshold) + if (oi->num_attrs <= (hsize_t)sattrs_threshold) (iter->num_small_attrs[(size_t)oi->num_attrs])++; - if(oi->num_attrs > iter->max_attrs) + if (oi->num_attrs > iter->max_attrs) iter->max_attrs = oi->num_attrs; /* Add attribute count to proper bin */ bin = ceil_log10((unsigned long)oi->num_attrs); - if((bin + 1) > iter->attr_nbins) { + if ((bin + 1) > iter->attr_nbins) { iter->attr_bins = (unsigned long *)HDrealloc(iter->attr_bins, (bin + 1) * sizeof(unsigned long)); HDassert(iter->attr_bins); /* Initialize counts for intermediate bins */ - while(iter->attr_nbins < bin) + while (iter->attr_nbins < bin) iter->attr_bins[iter->attr_nbins++] = 0; iter->attr_nbins++; /* Initialize count for new bin */ iter->attr_bins[bin] = 1; - } /* end if */ - else - (iter->attr_bins[bin])++; + } /* end if */ + else + (iter->attr_bins[bin])++; - return 0; + return 0; } /* end attribute_stats() */ - /*------------------------------------------------------------------------- * Function: group_stats * @@ -440,9 +434,9 @@ attribute_stats(iter_t *iter, const H5O_info2_t *oi, const H5O_native_info_t *na static herr_t group_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_native_info_t *native_oi) { - H5G_info_t ginfo; /* Group information */ - unsigned bin; /* "bin" the number of objects falls in */ - herr_t ret_value = SUCCEED; + H5G_info_t ginfo; /* Group information */ + unsigned bin; /* "bin" the number of objects falls in */ + herr_t ret_value = SUCCEED; /* Gather statistics about this type of object */ iter->uniq_groups++; @@ -452,26 +446,27 @@ group_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_nat iter->group_ohdr_info.free_size += native_oi->hdr.space.free; /* Get group information */ - if((ret_value = H5Gget_info_by_name(iter->fid, name, &ginfo, H5P_DEFAULT)) < 0) + if ((ret_value = H5Gget_info_by_name(iter->fid, name, &ginfo, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Gget_info_by_name() failed"); /* Update link stats */ /* Collect statistics for small groups */ - if(ginfo.nlinks < (hsize_t)sgroups_threshold) + if (ginfo.nlinks < (hsize_t)sgroups_threshold) (iter->num_small_groups[(size_t)ginfo.nlinks])++; /* Determine maximum link count */ - if(ginfo.nlinks > iter->max_fanout) + if (ginfo.nlinks > iter->max_fanout) iter->max_fanout = ginfo.nlinks; /* Add group count to proper bin */ bin = ceil_log10((unsigned long)ginfo.nlinks); - if((bin + 1) > iter->group_nbins) { + if ((bin + 1) > iter->group_nbins) { /* Allocate more storage for info about dataset's datatype */ - if((iter->group_bins = (unsigned long *)HDrealloc(iter->group_bins, (bin + 1) * sizeof(unsigned long))) == NULL) + if ((iter->group_bins = + (unsigned long *)HDrealloc(iter->group_bins, (bin + 1) * sizeof(unsigned long))) == NULL) H5TOOLS_GOTO_ERROR(FAIL, "H5Drealloc() failed"); /* Initialize counts for intermediate bins */ - while(iter->group_nbins < bin) + while (iter->group_nbins < bin) iter->group_bins[iter->group_nbins++] = 0; iter->group_nbins++; @@ -486,14 +481,13 @@ group_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_nat iter->groups_heap_storage_size += native_oi->meta_size.obj.heap_size; /* Update attribute metadata info */ - if((ret_value = attribute_stats(iter, oi, native_oi)) < 0) + if ((ret_value = attribute_stats(iter, oi, native_oi)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "attribute_stats failed"); done: return ret_value; } /* end group_stats() */ - /*------------------------------------------------------------------------- * Function: dataset_stats * @@ -510,22 +504,22 @@ done: static herr_t dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_native_info_t *native_oi) { - unsigned bin; /* "bin" the number of objects falls in */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hid_t dcpl; /* Dataset creation property list ID */ - hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataset */ - H5D_layout_t lout; /* Layout of dataset */ - unsigned type_found; /* Whether the dataset's datatype was */ - /* already found */ - int ndims; /* Number of dimensions of dataset */ - hsize_t storage; /* Size of dataset storage */ - unsigned u; /* Local index variable */ - int num_ext; /* Number of external files for a dataset */ - int nfltr; /* Number of filters for a dataset */ - H5Z_filter_t fltr; /* Filter identifier */ - herr_t ret_value = SUCCEED; + unsigned bin; /* "bin" the number of objects falls in */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hid_t dcpl; /* Dataset creation property list ID */ + hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataset */ + H5D_layout_t lout; /* Layout of dataset */ + unsigned type_found; /* Whether the dataset's datatype was */ + /* already found */ + int ndims; /* Number of dimensions of dataset */ + hsize_t storage; /* Size of dataset storage */ + unsigned u; /* Local index variable */ + int num_ext; /* Number of external files for a dataset */ + int nfltr; /* Number of filters for a dataset */ + H5Z_filter_t fltr; /* Filter identifier */ + herr_t ret_value = SUCCEED; /* Gather statistics about this type of object */ iter->uniq_dsets++; @@ -534,7 +528,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_n iter->dset_ohdr_info.total_size += native_oi->hdr.space.total; iter->dset_ohdr_info.free_size += native_oi->hdr.space.free; - if((did = H5Dopen2(iter->fid, name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(iter->fid, name, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen() failed"); /* Update dataset metadata info */ @@ -542,7 +536,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_n iter->datasets_heap_storage_size += native_oi->meta_size.obj.heap_size; /* Update attribute metadata info */ - if((ret_value = attribute_stats(iter, oi, native_oi)) < 0) + if ((ret_value = attribute_stats(iter, oi, native_oi)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "attribute_stats() failed"); /* Get storage info */ @@ -550,26 +544,26 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_n storage = H5Dget_storage_size(did); /* Gather layout statistics */ - if((dcpl = H5Dget_create_plist(did)) < 0) + if ((dcpl = H5Dget_create_plist(did)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_create_plist() failed"); - if((lout = H5Pget_layout(dcpl)) < 0) + if ((lout = H5Pget_layout(dcpl)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_layout() failed"); /* Object header's total size for H5D_COMPACT layout includes raw data size */ /* "storage" also includes H5D_COMPACT raw data size */ - if(lout == H5D_COMPACT) + if (lout == H5D_COMPACT) iter->dset_ohdr_info.total_size -= storage; /* Track the layout type for dataset */ (iter->dset_layouts[lout])++; /* Get the number of external files for the dataset */ - if((num_ext = H5Pget_external_count(dcpl)) < 0) + if ((num_ext = H5Pget_external_count(dcpl)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_external_count() failed"); /* Accumulate raw data size accordingly */ - if(num_ext) { + if (num_ext) { iter->nexternal += (unsigned long)num_ext; iter->dset_external_storage_size += (unsigned long)storage; } @@ -577,37 +571,38 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_n iter->dset_storage_size += storage; /* Gather dataspace statistics */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_space() failed"); - if((ndims = H5Sget_simple_extent_dims(sid, dims, NULL)) < 0) + if ((ndims = H5Sget_simple_extent_dims(sid, dims, NULL)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims() failed"); /* Check for larger rank of dataset */ - if((unsigned)ndims > iter->max_dset_rank) + if ((unsigned)ndims > iter->max_dset_rank) iter->max_dset_rank = (unsigned)ndims; /* Track the number of datasets with each rank */ (iter->dset_rank_count[ndims])++; /* Only gather dim size statistics on 1-D datasets */ - if(ndims == 1) { + if (ndims == 1) { /* Determine maximum dimension size */ - if(dims[0] > iter->max_dset_dims) + if (dims[0] > iter->max_dset_dims) iter->max_dset_dims = dims[0]; /* Collect statistics for small datasets */ - if(dims[0] < (hsize_t)sdsets_threshold) + if (dims[0] < (hsize_t)sdsets_threshold) (iter->small_dset_dims[(size_t)dims[0]])++; /* Add dim count to proper bin */ bin = ceil_log10((unsigned long)dims[0]); - if((bin + 1) > iter->dset_dim_nbins) { + if ((bin + 1) > iter->dset_dim_nbins) { /* Allocate more storage for info about dataset's datatype */ - if((iter->dset_dim_bins = (unsigned long *)HDrealloc(iter->dset_dim_bins, (bin + 1) * sizeof(unsigned long))) == NULL) + if ((iter->dset_dim_bins = (unsigned long *)HDrealloc(iter->dset_dim_bins, + (bin + 1) * sizeof(unsigned long))) == NULL) H5TOOLS_GOTO_ERROR(FAIL, "H5Drealloc() failed"); /* Initialize counts for intermediate bins */ - while(iter->dset_dim_nbins < bin) + while (iter->dset_dim_nbins < bin) iter->dset_dim_bins[iter->dset_dim_nbins++] = 0; iter->dset_dim_nbins++; @@ -618,22 +613,22 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_n (iter->dset_dim_bins[bin])++; } /* end if */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose() failed"); /* Gather datatype statistics */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_type() failed"); type_found = FALSE; - for(u = 0; u < iter->dset_ntypes; u++) - if(H5Tequal(iter->dset_type_info[u].tid, tid) > 0) { + for (u = 0; u < iter->dset_ntypes; u++) + if (H5Tequal(iter->dset_type_info[u].tid, tid) > 0) { type_found = TRUE; break; } /* end for */ - if(type_found) - (iter->dset_type_info[u].count)++; + if (type_found) + (iter->dset_type_info[u].count)++; else { unsigned curr_ntype = (unsigned)iter->dset_ntypes; @@ -641,11 +636,12 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_n iter->dset_ntypes++; /* Allocate more storage for info about dataset's datatype */ - if((iter->dset_type_info = (dtype_info_t *)HDrealloc(iter->dset_type_info, iter->dset_ntypes * sizeof(dtype_info_t))) == NULL) + if ((iter->dset_type_info = (dtype_info_t *)HDrealloc( + iter->dset_type_info, iter->dset_ntypes * sizeof(dtype_info_t))) == NULL) H5TOOLS_GOTO_ERROR(FAIL, "H5Drealloc() failed"); /* Initialize information about datatype */ - if((iter->dset_type_info[curr_ntype].tid = H5Tcopy(tid)) < 0) + if ((iter->dset_type_info[curr_ntype].tid = H5Tcopy(tid)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Tcopy() failed"); iter->dset_type_info[curr_ntype].count = 1; iter->dset_type_info[curr_ntype].named = 0; @@ -655,37 +651,36 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_n } /* end else */ /* Check if the datatype is a named datatype */ - if(H5Tcommitted(tid) > 0) + if (H5Tcommitted(tid) > 0) (iter->dset_type_info[u].named)++; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose() failed"); /* Track different filters */ - if((nfltr = H5Pget_nfilters(dcpl)) >= 0) { - if(nfltr == 0) - iter->dset_comptype[0]++; - for(u = 0; u < (unsigned)nfltr; u++) { + if ((nfltr = H5Pget_nfilters(dcpl)) >= 0) { + if (nfltr == 0) + iter->dset_comptype[0]++; + for (u = 0; u < (unsigned)nfltr; u++) { fltr = H5Pget_filter2(dcpl, u, 0, 0, 0, 0, 0, NULL); - if(fltr >= 0) { - if(fltr < (H5_NFILTERS_IMPL - 1)) + if (fltr >= 0) { + if (fltr < (H5_NFILTERS_IMPL - 1)) iter->dset_comptype[fltr]++; else iter->dset_comptype[H5_NFILTERS_IMPL - 1]++; /*other filters*/ - } /* end if */ - } /* end for */ - } /* endif nfltr */ + } /* end if */ + } /* end for */ + } /* endif nfltr */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose() failed"); - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose() failed"); done: - return ret_value; -} /* end dataset_stats() */ - + return ret_value; +} /* end dataset_stats() */ /*------------------------------------------------------------------------- * Function: datatype_stats @@ -712,12 +707,11 @@ datatype_stats(iter_t *iter, const H5O_info2_t *oi, const H5O_native_info_t *nat iter->dtype_ohdr_info.free_size += native_oi->hdr.space.free; /* Update attribute metadata info */ - if((ret_value = attribute_stats(iter, oi, native_oi)) < 0) + if ((ret_value = attribute_stats(iter, oi, native_oi)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "attribute_stats() failed"); done: - return ret_value; -} /* end datatype_stats() */ - + return ret_value; +} /* end datatype_stats() */ /*------------------------------------------------------------------------- * Function: obj_stats @@ -733,36 +727,35 @@ done: *------------------------------------------------------------------------- */ static herr_t -obj_stats(const char *path, const H5O_info2_t *oi, const char *already_visited, - void *_iter) +obj_stats(const char *path, const H5O_info2_t *oi, const char *already_visited, void *_iter) { H5O_native_info_t native_info; - iter_t *iter = (iter_t *)_iter; - herr_t ret_value = SUCCEED; + iter_t * iter = (iter_t *)_iter; + herr_t ret_value = SUCCEED; /* If the object has already been seen then just return */ - if(NULL == already_visited) { + if (NULL == already_visited) { /* Retrieve the native info for the object */ - if(H5Oget_native_info_by_name(iter->fid, path, &native_info, H5O_NATIVE_INFO_ALL, H5P_DEFAULT) < 0) + if (H5Oget_native_info_by_name(iter->fid, path, &native_info, H5O_NATIVE_INFO_ALL, H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_native_info_by_name failed"); /* Gather some general statistics about the object */ - if(oi->rc > iter->max_links) + if (oi->rc > iter->max_links) iter->max_links = oi->rc; - switch(oi->type) { + switch (oi->type) { case H5O_TYPE_GROUP: - if(group_stats(iter, path, oi, &native_info) < 0) + if (group_stats(iter, path, oi, &native_info) < 0) H5TOOLS_GOTO_ERROR(FAIL, "group_stats failed"); break; case H5O_TYPE_DATASET: - if(dataset_stats(iter, path, oi, &native_info) < 0) + if (dataset_stats(iter, path, oi, &native_info) < 0) H5TOOLS_GOTO_ERROR(FAIL, "dataset_stats failed"); break; case H5O_TYPE_NAMED_DATATYPE: - if(datatype_stats(iter, oi, &native_info) < 0) + if (datatype_stats(iter, oi, &native_info) < 0) H5TOOLS_GOTO_ERROR(FAIL, "datatype_stats failed"); break; @@ -774,13 +767,12 @@ obj_stats(const char *path, const H5O_info2_t *oi, const char *already_visited, iter->uniq_others++; break; } /* end switch */ - } /* end if */ + } /* end if */ done: return ret_value; } /* end obj_stats() */ - /*------------------------------------------------------------------------- * Function: lnk_stats * @@ -799,7 +791,7 @@ lnk_stats(const char H5_ATTR_UNUSED *path, const H5L_info2_t *li, void *_iter) { iter_t *iter = (iter_t *)_iter; - switch(li->type) { + switch (li->type) { case H5L_TYPE_SOFT: case H5L_TYPE_EXTERNAL: /* Gather statistics about links and UD links */ @@ -833,35 +825,35 @@ lnk_stats(const char H5_ATTR_UNUSED *path, const H5L_info2_t *li, void *_iter) static herr_t freespace_stats(hid_t fid, iter_t *iter) { - H5F_sect_info_t *sect_info = NULL; /* Free space sections */ - ssize_t nsects; /* Number of free space sections */ - size_t u; /* Local index variable */ + H5F_sect_info_t *sect_info = NULL; /* Free space sections */ + ssize_t nsects; /* Number of free space sections */ + size_t u; /* Local index variable */ /* Query section information */ - if((nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, 0, NULL)) < 0) - return(FAIL); - else if(nsects) { - if(NULL == (sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t)))) - return(FAIL); + if ((nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, 0, NULL)) < 0) + return (FAIL); + else if (nsects) { + if (NULL == (sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t)))) + return (FAIL); nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, (size_t)nsects, sect_info); HDassert(nsects); } /* end else-if */ - for(u = 0; u < (size_t)nsects; u++) { - unsigned bin; /* "bin" the number of objects falls in */ + for (u = 0; u < (size_t)nsects; u++) { + unsigned bin; /* "bin" the number of objects falls in */ - if(sect_info[u].size < SIZE_SMALL_SECTS) + if (sect_info[u].size < SIZE_SMALL_SECTS) (iter->num_small_sects[(size_t)sect_info[u].size])++; /* Add section size to proper bin */ bin = ceil_log10((unsigned long)sect_info[u].size); - if(bin >= iter->sect_nbins) { + if (bin >= iter->sect_nbins) { /* Allocate more storage for section info */ iter->sect_bins = (unsigned long *)HDrealloc(iter->sect_bins, (bin + 1) * sizeof(unsigned long)); HDassert(iter->sect_bins); /* Initialize counts for intermediate bins */ - while(iter->sect_nbins < bin) + while (iter->sect_nbins < bin) iter->sect_bins[iter->sect_nbins++] = 0; iter->sect_nbins++; @@ -872,13 +864,12 @@ freespace_stats(hid_t fid, iter_t *iter) (iter->sect_bins[bin])++; } /* end for */ - if(sect_info) + if (sect_info) HDfree(sect_info); return 0; } /* end freespace_stats() */ - /*------------------------------------------------------------------------- * Function: hand_free * @@ -893,11 +884,11 @@ freespace_stats(hid_t fid, iter_t *iter) static void hand_free(struct handler_t *hand) { - if(hand) { + if (hand) { unsigned u; - for(u = 0; u < hand->obj_count; u++) - if(hand->obj[u]) { + for (u = 0; u < hand->obj_count; u++) + if (hand->obj[u]) { HDfree(hand->obj[u]); hand->obj[u] = NULL; } /* end if */ @@ -907,7 +898,6 @@ hand_free(struct handler_t *hand) } /* end if */ } /* end hand_free() */ - /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -925,13 +915,13 @@ hand_free(struct handler_t *hand) static int parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) { - int opt; - unsigned u; - struct handler_t *hand = NULL; + int opt; + unsigned u; + struct handler_t *hand = NULL; /* parse command line options */ - while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char)opt) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { case 'h': usage(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); @@ -949,29 +939,29 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) break; case 'F': - display_all = FALSE; + display_all = FALSE; display_file_metadata = TRUE; break; case 'f': - display_all = FALSE; + display_all = FALSE; display_file = TRUE; break; case 'G': - display_all = FALSE; + display_all = FALSE; display_group_metadata = TRUE; break; case 'g': - display_all = FALSE; + display_all = FALSE; display_group = TRUE; break; case 'l': - if(opt_arg) { + if (opt_arg) { sgroups_threshold = HDatoi(opt_arg); - if(sgroups_threshold < 1) { + if (sgroups_threshold < 1) { error_msg("Invalid threshold for small groups\n"); goto error; } @@ -982,19 +972,19 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) break; case 'D': - display_all = FALSE; + display_all = FALSE; display_dset_metadata = TRUE; break; case 'd': - display_all = FALSE; + display_all = FALSE; display_dset = TRUE; break; case 'm': - if(opt_arg) { + if (opt_arg) { sdsets_threshold = HDatoi(opt_arg); - if(sdsets_threshold < 1) { + if (sdsets_threshold < 1) { error_msg("Invalid threshold for small datasets\n"); goto error; } @@ -1005,19 +995,19 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) break; case 'T': - display_all = FALSE; + display_all = FALSE; display_dset_dtype_meta = TRUE; break; case 'A': - display_all = FALSE; + display_all = FALSE; display_attr = TRUE; break; case 'a': - if(opt_arg) { + if (opt_arg) { sattrs_threshold = HDatoi(opt_arg); - if(sattrs_threshold < 1) { + if (sattrs_threshold < 1) { error_msg("Invalid threshold for small # of attributes\n"); goto error; } @@ -1028,35 +1018,35 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) break; case 's': - display_all = FALSE; + display_all = FALSE; display_free_sections = TRUE; break; case 'S': - display_all = FALSE; + display_all = FALSE; display_summary = TRUE; break; case 'O': - display_all = FALSE; + display_all = FALSE; display_object = TRUE; /* Allocate space to hold the command line info */ - if(NULL == (hand = (struct handler_t *)HDcalloc((size_t)1, sizeof(struct handler_t)))) { + if (NULL == (hand = (struct handler_t *)HDcalloc((size_t)1, sizeof(struct handler_t)))) { error_msg("unable to allocate memory for object struct\n"); goto error; } /* end if */ /* Allocate space to hold the object strings */ hand->obj_count = (size_t)argc; - if(NULL == (hand->obj = (char **)HDcalloc((size_t)argc, sizeof(char *)))) { + if (NULL == (hand->obj = (char **)HDcalloc((size_t)argc, sizeof(char *)))) { error_msg("unable to allocate memory for object array\n"); goto error; } /* end if */ /* Store object names */ - for(u = 0; u < hand->obj_count; u++) - if(NULL == (hand->obj[u] = HDstrdup(opt_arg))) { + for (u = 0; u < hand->obj_count; u++) + if (NULL == (hand->obj[u] = HDstrdup(opt_arg))) { error_msg("unable to allocate memory for object name\n"); goto error; } /* end if */ @@ -1094,10 +1084,10 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) usage(h5tools_getprogname()); goto error; } /* end switch */ - } /* end while */ + } /* end while */ /* check for file name to be processed */ - if(argc <= opt_ind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); goto error; @@ -1116,7 +1106,6 @@ error: return -1; } - /*------------------------------------------------------------------------- * Function: iter_free * @@ -1133,55 +1122,54 @@ iter_free(iter_t *iter) { /* Clear array of bins for group counts */ - if(iter->group_bins) { + if (iter->group_bins) { HDfree(iter->group_bins); iter->group_bins = NULL; } /* end if */ /* Clear array for tracking small groups */ - if(iter->num_small_groups) { + if (iter->num_small_groups) { HDfree(iter->num_small_groups); iter->num_small_groups = NULL; } /* end if */ /* Clear array of bins for attribute counts */ - if(iter->attr_bins) { + if (iter->attr_bins) { HDfree(iter->attr_bins); iter->attr_bins = NULL; } /* end if */ /* Clear array for tracking small attributes */ - if(iter->num_small_attrs) { + if (iter->num_small_attrs) { HDfree(iter->num_small_attrs); - iter->num_small_attrs= NULL; + iter->num_small_attrs = NULL; } /* end if */ /* Clear dataset datatype information found */ - if(iter->dset_type_info) { + if (iter->dset_type_info) { HDfree(iter->dset_type_info); iter->dset_type_info = NULL; } /* end if */ /* Clear array of bins for dataset dimensions */ - if(iter->dset_dim_bins) { + if (iter->dset_dim_bins) { HDfree(iter->dset_dim_bins); iter->dset_dim_bins = NULL; } /* end if */ /* Clear array of tracking 1-D small datasets */ - if(iter->small_dset_dims) { + if (iter->small_dset_dims) { HDfree(iter->small_dset_dims); iter->small_dset_dims = NULL; } /* end if */ /* Clear array of bins for free-space section sizes */ - if(iter->sect_bins) { + if (iter->sect_bins) { HDfree(iter->sect_bins); iter->sect_bins = NULL; } /* end if */ } /* end iter_free() */ - /*------------------------------------------------------------------------- * Function: print_file_info * @@ -1213,7 +1201,6 @@ print_file_info(const iter_t *iter) return 0; } /* print_file_info() */ - /*------------------------------------------------------------------------- * Function: print_file_metadata * @@ -1238,11 +1225,11 @@ print_file_metadata(const iter_t *iter) HDfprintf(stdout, "\tObject headers: (total/unused)\n"); HDfprintf(stdout, "\t\tGroups: %Hu/%Hu\n", iter->group_ohdr_info.total_size, - iter->group_ohdr_info.free_size); - HDfprintf(stdout, "\t\tDatasets(exclude compact data): %Hu/%Hu\n", - iter->dset_ohdr_info.total_size, iter->dset_ohdr_info.free_size); + iter->group_ohdr_info.free_size); + HDfprintf(stdout, "\t\tDatasets(exclude compact data): %Hu/%Hu\n", iter->dset_ohdr_info.total_size, + iter->dset_ohdr_info.free_size); HDfprintf(stdout, "\t\tDatatypes: %Hu/%Hu\n", iter->dtype_ohdr_info.total_size, - iter->dtype_ohdr_info.free_size); + iter->dtype_ohdr_info.free_size); HDfprintf(stdout, "\tGroups:\n"); HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->groups_btree_storage_size); @@ -1270,7 +1257,6 @@ print_file_metadata(const iter_t *iter) return 0; } /* print_file_metadata() */ - /*------------------------------------------------------------------------- * Function: print_group_info * @@ -1293,32 +1279,32 @@ print_file_metadata(const iter_t *iter) static herr_t print_group_info(const iter_t *iter) { - unsigned long power; /* Temporary "power" for bins */ - unsigned long total; /* Total count for various statistics */ - unsigned u; /* Local index variable */ + unsigned long power; /* Temporary "power" for bins */ + unsigned long total; /* Total count for various statistics */ + unsigned u; /* Local index variable */ - HDprintf("Small groups (with 0 to %u links):\n", sgroups_threshold-1); + HDprintf("Small groups (with 0 to %u links):\n", sgroups_threshold - 1); total = 0; - for(u = 0; u < (unsigned)sgroups_threshold; u++) { - if(iter->num_small_groups[u] > 0) { + for (u = 0; u < (unsigned)sgroups_threshold; u++) { + if (iter->num_small_groups[u] > 0) { HDprintf("\t# of groups with %u link(s): %lu\n", u, iter->num_small_groups[u]); total += iter->num_small_groups[u]; } /* end if */ - } /* end for */ + } /* end for */ HDprintf("\tTotal # of small groups: %lu\n", total); HDprintf("Group bins:\n"); total = 0; - if((iter->group_nbins > 0) && (iter->group_bins[0] > 0)) { - HDprintf("\t# of groups with 0 link: %lu\n", iter->group_bins[0]); - total = iter->group_bins[0]; + if ((iter->group_nbins > 0) && (iter->group_bins[0] > 0)) { + HDprintf("\t# of groups with 0 link: %lu\n", iter->group_bins[0]); + total = iter->group_bins[0]; } /* end if */ power = 1; - for(u = 1; u < iter->group_nbins; u++) { - if(iter->group_bins[u] > 0) { - HDprintf("\t# of groups with %lu - %lu links: %lu\n", power, (power * 10) - 1, - iter->group_bins[u]); - total += iter->group_bins[u]; + for (u = 1; u < iter->group_nbins; u++) { + if (iter->group_bins[u] > 0) { + HDprintf("\t# of groups with %lu - %lu links: %lu\n", power, (power * 10) - 1, + iter->group_bins[u]); + total += iter->group_bins[u]; } /* end if */ power *= 10; } /* end for */ @@ -1327,7 +1313,6 @@ print_group_info(const iter_t *iter) return 0; } /* print_group_info() */ - /*------------------------------------------------------------------------- * Function: print_group_metadata * @@ -1345,8 +1330,8 @@ print_group_metadata(const iter_t *iter) { HDprintf("File space information for groups' metadata (in bytes):\n"); - HDfprintf(stdout, "\tObject headers (total/unused): %Hu/%Hu\n", - iter->group_ohdr_info.total_size, iter->group_ohdr_info.free_size); + HDfprintf(stdout, "\tObject headers (total/unused): %Hu/%Hu\n", iter->group_ohdr_info.total_size, + iter->group_ohdr_info.free_size); HDfprintf(stdout, "\tB-tree/List: %Hu\n", iter->groups_btree_storage_size); HDfprintf(stdout, "\tHeap: %Hu\n", iter->groups_heap_storage_size); @@ -1354,7 +1339,6 @@ print_group_metadata(const iter_t *iter) return 0; } /* print_group_metadata() */ - /*------------------------------------------------------------------------- * Function: print_dataset_info * @@ -1371,44 +1355,43 @@ print_group_metadata(const iter_t *iter) static herr_t print_dataset_info(const iter_t *iter) { - unsigned long power; /* Temporary "power" for bins */ - unsigned long total; /* Total count for various statistics */ - unsigned u; /* Local index variable */ + unsigned long power; /* Temporary "power" for bins */ + unsigned long total; /* Total count for various statistics */ + unsigned u; /* Local index variable */ - if(iter->uniq_dsets > 0) { + if (iter->uniq_dsets > 0) { HDprintf("Dataset dimension information:\n"); HDprintf("\tMax. rank of datasets: %u\n", iter->max_dset_rank); HDprintf("\tDataset ranks:\n"); - for(u = 0; u < H5S_MAX_RANK; u++) - if(iter->dset_rank_count[u] > 0) + for (u = 0; u < H5S_MAX_RANK; u++) + if (iter->dset_rank_count[u] > 0) HDprintf("\t\t# of dataset with rank %u: %lu\n", u, iter->dset_rank_count[u]); HDprintf("1-D Dataset information:\n"); HDfprintf(stdout, "\tMax. dimension size of 1-D datasets: %Hu\n", iter->max_dset_dims); HDprintf("\tSmall 1-D datasets (with dimension sizes 0 to %u):\n", sdsets_threshold - 1); total = 0; - for(u = 0; u < (unsigned)sdsets_threshold; u++) { - if(iter->small_dset_dims[u] > 0) { - HDprintf("\t\t# of datasets with dimension sizes %u: %lu\n", u, - iter->small_dset_dims[u]); + for (u = 0; u < (unsigned)sdsets_threshold; u++) { + if (iter->small_dset_dims[u] > 0) { + HDprintf("\t\t# of datasets with dimension sizes %u: %lu\n", u, iter->small_dset_dims[u]); total += iter->small_dset_dims[u]; } /* end if */ - } /* end for */ + } /* end for */ HDprintf("\t\tTotal # of small datasets: %lu\n", total); /* Protect against no datasets in file */ - if(iter->dset_dim_nbins > 0) { + if (iter->dset_dim_nbins > 0) { HDprintf("\t1-D Dataset dimension bins:\n"); total = 0; - if(iter->dset_dim_bins[0] > 0) { + if (iter->dset_dim_bins[0] > 0) { HDprintf("\t\t# of datasets with dimension size 0: %lu\n", iter->dset_dim_bins[0]); total = iter->dset_dim_bins[0]; } /* end if */ power = 1; - for(u = 1; u < iter->dset_dim_nbins; u++) { - if(iter->dset_dim_bins[u] > 0) { - HDprintf("\t\t# of datasets with dimension size %lu - %lu: %lu\n", power, (power * 10) - 1, - iter->dset_dim_bins[u]); + for (u = 1; u < iter->dset_dim_nbins; u++) { + if (iter->dset_dim_bins[u] > 0) { + HDprintf("\t\t# of datasets with dimension size %lu - %lu: %lu\n", power, + (power * 10) - 1, iter->dset_dim_bins[u]); total += iter->dset_dim_bins[u]; } /* end if */ power *= 10; @@ -1421,27 +1404,29 @@ print_dataset_info(const iter_t *iter) HDfprintf(stdout, "\tTotal external raw data size: %Hu\n", iter->dset_external_storage_size); HDprintf("Dataset layout information:\n"); - for(u = 0; u < H5D_NLAYOUTS; u++) - HDprintf("\tDataset layout counts[%s]: %lu\n", (u == H5D_COMPACT ? "COMPACT" : - (u == H5D_CONTIGUOUS ? "CONTIG" : (u == H5D_CHUNKED ? "CHUNKED" : "VIRTUAL"))), iter->dset_layouts[u]); + for (u = 0; u < H5D_NLAYOUTS; u++) + HDprintf("\tDataset layout counts[%s]: %lu\n", + (u == H5D_COMPACT + ? "COMPACT" + : (u == H5D_CONTIGUOUS ? "CONTIG" : (u == H5D_CHUNKED ? "CHUNKED" : "VIRTUAL"))), + iter->dset_layouts[u]); HDprintf("\tNumber of external files : %lu\n", iter->nexternal); HDprintf("Dataset filters information:\n"); HDprintf("\tNumber of datasets with:\n"); - HDprintf("\t\tNO filter: %lu\n", iter->dset_comptype[H5Z_FILTER_ERROR+1]); + HDprintf("\t\tNO filter: %lu\n", iter->dset_comptype[H5Z_FILTER_ERROR + 1]); HDprintf("\t\tGZIP filter: %lu\n", iter->dset_comptype[H5Z_FILTER_DEFLATE]); HDprintf("\t\tSHUFFLE filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SHUFFLE]); HDprintf("\t\tFLETCHER32 filter: %lu\n", iter->dset_comptype[H5Z_FILTER_FLETCHER32]); HDprintf("\t\tSZIP filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SZIP]); HDprintf("\t\tNBIT filter: %lu\n", iter->dset_comptype[H5Z_FILTER_NBIT]); HDprintf("\t\tSCALEOFFSET filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SCALEOFFSET]); - HDprintf("\t\tUSER-DEFINED filter: %lu\n", iter->dset_comptype[H5_NFILTERS_IMPL-1]); + HDprintf("\t\tUSER-DEFINED filter: %lu\n", iter->dset_comptype[H5_NFILTERS_IMPL - 1]); } /* end if */ return 0; } /* print_dataset_info() */ - /*------------------------------------------------------------------------- * Function: print_dataset_metadata * @@ -1460,17 +1445,15 @@ print_dset_metadata(const iter_t *iter) { HDprintf("File space information for datasets' metadata (in bytes):\n"); - HDfprintf(stdout, "\tObject headers (total/unused): %Hu/%Hu\n", - iter->dset_ohdr_info.total_size, iter->dset_ohdr_info.free_size); + HDfprintf(stdout, "\tObject headers (total/unused): %Hu/%Hu\n", iter->dset_ohdr_info.total_size, + iter->dset_ohdr_info.free_size); - HDfprintf(stdout, "\tIndex for Chunked datasets: %Hu\n", - iter->datasets_index_storage_size); + HDfprintf(stdout, "\tIndex for Chunked datasets: %Hu\n", iter->datasets_index_storage_size); HDfprintf(stdout, "\tHeap: %Hu\n", iter->datasets_heap_storage_size); return 0; } /* print_dset_metadata() */ - /*------------------------------------------------------------------------- * Function: print_dset_dtype_meta * @@ -1487,21 +1470,21 @@ print_dset_metadata(const iter_t *iter) static herr_t print_dset_dtype_meta(const iter_t *iter) { - unsigned long total; /* Total count for various statistics */ - size_t dtype_size; /* Size of encoded datatype */ - unsigned u; /* Local index variable */ + unsigned long total; /* Total count for various statistics */ + size_t dtype_size; /* Size of encoded datatype */ + unsigned u; /* Local index variable */ - if(iter->dset_ntypes) { + if (iter->dset_ntypes) { HDprintf("Dataset datatype information:\n"); HDprintf("\t# of unique datatypes used by datasets: %lu\n", iter->dset_ntypes); total = 0; - for(u = 0; u < iter->dset_ntypes; u++) { + for (u = 0; u < iter->dset_ntypes; u++) { H5Tencode(iter->dset_type_info[u].tid, NULL, &dtype_size); HDprintf("\tDataset datatype #%u:\n", u); - HDprintf("\t\tCount (total/named) = (%lu/%lu)\n", - iter->dset_type_info[u].count, iter->dset_type_info[u].named); + HDprintf("\t\tCount (total/named) = (%lu/%lu)\n", iter->dset_type_info[u].count, + iter->dset_type_info[u].named); HDprintf("\t\tSize (desc./elmt) = (%lu/%lu)\n", (unsigned long)dtype_size, - (unsigned long)H5Tget_size(iter->dset_type_info[u].tid)); + (unsigned long)H5Tget_size(iter->dset_type_info[u].tid)); H5Tclose(iter->dset_type_info[u].tid); total += iter->dset_type_info[u].count; } /* end for */ @@ -1511,7 +1494,6 @@ print_dset_dtype_meta(const iter_t *iter) return 0; } /* print_dset_dtype_meta() */ - /*------------------------------------------------------------------------- * Function: print_attr_info * @@ -1529,28 +1511,28 @@ print_dset_dtype_meta(const iter_t *iter) static herr_t print_attr_info(const iter_t *iter) { - unsigned long power; /* Temporary "power" for bins */ - unsigned long total; /* Total count for various statistics */ - unsigned u; /* Local index variable */ + unsigned long power; /* Temporary "power" for bins */ + unsigned long total; /* Total count for various statistics */ + unsigned u; /* Local index variable */ HDprintf("Small # of attributes (objects with 1 to %u attributes):\n", sattrs_threshold); total = 0; - for(u = 1; u <= (unsigned)sattrs_threshold; u++) { - if(iter->num_small_attrs[u] > 0) { + for (u = 1; u <= (unsigned)sattrs_threshold; u++) { + if (iter->num_small_attrs[u] > 0) { HDprintf("\t# of objects with %u attributes: %lu\n", u, iter->num_small_attrs[u]); total += iter->num_small_attrs[u]; } /* end if */ - } /* end for */ + } /* end for */ HDprintf("\tTotal # of objects with small # of attributes: %lu\n", total); HDprintf("Attribute bins:\n"); total = 0; power = 1; - for(u = 1; u < iter->attr_nbins; u++) { - if(iter->attr_bins[u] > 0) { - HDprintf("\t# of objects with %lu - %lu attributes: %lu\n", power, (power * 10) - 1, - iter->attr_bins[u]); - total += iter->attr_bins[u]; + for (u = 1; u < iter->attr_nbins; u++) { + if (iter->attr_bins[u] > 0) { + HDprintf("\t# of objects with %lu - %lu attributes: %lu\n", power, (power * 10) - 1, + iter->attr_bins[u]); + total += iter->attr_bins[u]; } /* end if */ power *= 10; } /* end for */ @@ -1560,7 +1542,6 @@ print_attr_info(const iter_t *iter) return 0; } /* print_attr_info() */ - /*------------------------------------------------------------------------- * Function: print_freespace_info * @@ -1577,31 +1558,30 @@ print_attr_info(const iter_t *iter) static herr_t print_freespace_info(const iter_t *iter) { - unsigned long power; /* Temporary "power" for bins */ - unsigned long total; /* Total count for various statistics */ - unsigned u; /* Local index variable */ + unsigned long power; /* Temporary "power" for bins */ + unsigned long total; /* Total count for various statistics */ + unsigned u; /* Local index variable */ HDfprintf(stdout, "Free-space persist: %s\n", iter->fs_persist ? "TRUE" : "FALSE"); HDfprintf(stdout, "Free-space section threshold: %Hu bytes\n", iter->fs_threshold); HDprintf("Small size free-space sections (< %u bytes):\n", (unsigned)SIZE_SMALL_SECTS); total = 0; - for(u = 0; u < SIZE_SMALL_SECTS; u++) { - if(iter->num_small_sects[u] > 0) { + for (u = 0; u < SIZE_SMALL_SECTS; u++) { + if (iter->num_small_sects[u] > 0) { HDprintf("\t# of sections of size %u: %lu\n", u, iter->num_small_sects[u]); total += iter->num_small_sects[u]; } /* end if */ - } /* end for */ + } /* end for */ HDprintf("\tTotal # of small size sections: %lu\n", total); HDprintf("Free-space section bins:\n"); total = 0; power = 1; - for(u = 1; u < iter->sect_nbins; u++) { - if(iter->sect_bins[u] > 0) { - HDprintf("\t# of sections of size %lu - %lu: %lu\n", power, (power * 10) - 1, - iter->sect_bins[u]); - total += iter->sect_bins[u]; + for (u = 1; u < iter->sect_nbins; u++) { + if (iter->sect_bins[u] > 0) { + HDprintf("\t# of sections of size %lu - %lu: %lu\n", power, (power * 10) - 1, iter->sect_bins[u]); + total += iter->sect_bins[u]; } /* end if */ power *= 10; } /* end for */ @@ -1610,7 +1590,6 @@ print_freespace_info(const iter_t *iter) return 0; } /* print_freespace_info() */ - /*------------------------------------------------------------------------- * Function: print_storage_summary * @@ -1628,36 +1607,27 @@ static herr_t print_storage_summary(const iter_t *iter) { hsize_t total_meta = 0; - hsize_t unaccount = 0; - double percent = 0.0f; + hsize_t unaccount = 0; + double percent = 0.0f; HDfprintf(stdout, "File space management strategy: %s\n", FS_STRATEGY_NAME[iter->fs_strategy]); HDfprintf(stdout, "File space page size: %Hu bytes\n", iter->fsp_size); HDprintf("Summary of file space information:\n"); total_meta = - iter->super_size + iter->super_ext_size + iter->ublk_size + - iter->group_ohdr_info.total_size + - iter->dset_ohdr_info.total_size + - iter->dtype_ohdr_info.total_size + - iter->groups_btree_storage_size + - iter->groups_heap_storage_size + - iter->attrs_btree_storage_size + - iter->attrs_heap_storage_size + - iter->datasets_index_storage_size + - iter->datasets_heap_storage_size + - iter->SM_hdr_storage_size + - iter->SM_index_storage_size + - iter->SM_heap_storage_size + - iter->free_hdr; + iter->super_size + iter->super_ext_size + iter->ublk_size + iter->group_ohdr_info.total_size + + iter->dset_ohdr_info.total_size + iter->dtype_ohdr_info.total_size + iter->groups_btree_storage_size + + iter->groups_heap_storage_size + iter->attrs_btree_storage_size + iter->attrs_heap_storage_size + + iter->datasets_index_storage_size + iter->datasets_heap_storage_size + iter->SM_hdr_storage_size + + iter->SM_index_storage_size + iter->SM_heap_storage_size + iter->free_hdr; HDfprintf(stdout, " File metadata: %Hu bytes\n", total_meta); HDfprintf(stdout, " Raw data: %Hu bytes\n", iter->dset_storage_size); percent = ((double)iter->free_space / (double)iter->filesize) * (double)100.0f; - HDfprintf(stdout, " Amount/Percent of tracked free space: %Hu bytes/%3.1f%\n", - iter->free_space, percent); + HDfprintf(stdout, " Amount/Percent of tracked free space: %Hu bytes/%3.1f%\n", iter->free_space, + percent); - if(iter->filesize < (total_meta + iter->dset_storage_size + iter->free_space)) { + if (iter->filesize < (total_meta + iter->dset_storage_size + iter->free_space)) { unaccount = (total_meta + iter->dset_storage_size + iter->free_space) - iter->filesize; HDfprintf(stdout, " ??? File has %Hu more bytes accounted for than its size! ???\n", unaccount); } @@ -1666,15 +1636,15 @@ print_storage_summary(const iter_t *iter) HDfprintf(stdout, " Unaccounted space: %Hu bytes\n", unaccount); } - HDfprintf(stdout, "Total space: %Hu bytes\n", total_meta + iter->dset_storage_size + iter->free_space + unaccount); + HDfprintf(stdout, "Total space: %Hu bytes\n", + total_meta + iter->dset_storage_size + iter->free_space + unaccount); - if(iter->nexternal) + if (iter->nexternal) HDfprintf(stdout, "External raw data: %Hu bytes\n", iter->dset_external_storage_size); return 0; } /* print_storage_summary() */ - /*------------------------------------------------------------------------- * Function: print_file_statistics * @@ -1692,36 +1662,45 @@ print_storage_summary(const iter_t *iter) static void print_file_statistics(const iter_t *iter) { - if(display_all) { - display_file = TRUE; - display_group = TRUE; - display_dset = TRUE; + if (display_all) { + display_file = TRUE; + display_group = TRUE; + display_dset = TRUE; display_dset_dtype_meta = TRUE; - display_attr = TRUE; - display_free_sections = TRUE; - display_summary = TRUE; + display_attr = TRUE; + display_free_sections = TRUE; + display_summary = TRUE; - display_file_metadata = TRUE; + display_file_metadata = TRUE; display_group_metadata = TRUE; - display_dset_metadata = TRUE; + display_dset_metadata = TRUE; } - if(display_file) print_file_info(iter); - if(display_file_metadata) print_file_metadata(iter); - - if(display_group) print_group_info(iter); - if(!display_all && display_group_metadata) print_group_metadata(iter); - - if(display_dset) print_dataset_info(iter); - if(display_dset_dtype_meta) print_dset_dtype_meta(iter); - if(!display_all && display_dset_metadata) print_dset_metadata(iter); - - if(display_attr) print_attr_info(iter); - if(display_free_sections) print_freespace_info(iter); - if(display_summary) print_storage_summary(iter); + if (display_file) + print_file_info(iter); + if (display_file_metadata) + print_file_metadata(iter); + + if (display_group) + print_group_info(iter); + if (!display_all && display_group_metadata) + print_group_metadata(iter); + + if (display_dset) + print_dataset_info(iter); + if (display_dset_dtype_meta) + print_dset_dtype_meta(iter); + if (!display_all && display_dset_metadata) + print_dset_metadata(iter); + + if (display_attr) + print_attr_info(iter); + if (display_free_sections) + print_freespace_info(iter); + if (display_summary) + print_storage_summary(iter); } /* print_file_statistics() */ - /*------------------------------------------------------------------------- * Function: print_object_statistics * @@ -1744,7 +1723,6 @@ print_object_statistics(const char *name) HDprintf("Object name %s\n", name); } /* print_object_statistics() */ - /*------------------------------------------------------------------------- * Function: print_statistics * @@ -1764,13 +1742,12 @@ print_object_statistics(const char *name) static void print_statistics(const char *name, const iter_t *iter) { - if(display_object) + if (display_object) print_object_statistics(name); else print_file_statistics(iter); } /* print_statistics() */ - /*------------------------------------------------------------------------- * Function: main * @@ -1783,11 +1760,11 @@ print_statistics(const char *name, const iter_t *iter) int main(int argc, const char *argv[]) { - iter_t iter; - const char *fname = NULL; - hid_t fid = H5I_INVALID_HID; - struct handler_t *hand = NULL; - hid_t fapl_id = H5P_DEFAULT; + iter_t iter; + const char * fname = NULL; + hid_t fid = H5I_INVALID_HID; + struct handler_t *hand = NULL; + hid_t fapl_id = H5P_DEFAULT; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -1797,7 +1774,7 @@ main(int argc, const char *argv[]) HDmemset(&iter, 0, sizeof(iter)); - if(parse_command_line(argc, argv, &hand) < 0) + if (parse_command_line(argc, argv, &hand) < 0) goto done; fname = argv[opt_ind]; @@ -1808,9 +1785,9 @@ main(int argc, const char *argv[]) if (drivername) { h5tools_vfd_info_t vfd_info; - vfd_info.info = NULL; - vfd_info.name = drivername; - vfd_info.fname = fname; + vfd_info.info = NULL; + vfd_info.name = drivername; + vfd_info.fname = fname; if (!HDstrcmp(drivername, drivernames[ROS3_VFD_IDX])) { #ifdef H5_HAVE_ROS3_VFD @@ -1836,16 +1813,15 @@ main(int argc, const char *argv[]) } /* Check for filename given */ - if(fname) { - hid_t fcpl; - H5F_info2_t finfo; + if (fname) { + hid_t fcpl; + H5F_info2_t finfo; HDprintf("Filename: %s\n", fname); - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, - (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); + fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); - if(fid < 0) { + if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -1854,72 +1830,74 @@ main(int argc, const char *argv[]) /* Initialize iter structure */ iter.fid = fid; - if(H5Fget_filesize(fid, &iter.filesize) < 0) + if (H5Fget_filesize(fid, &iter.filesize) < 0) warn_msg("Unable to retrieve file size\n"); HDassert(iter.filesize != 0); /* Get storge info for file-level structures */ - if(H5Fget_info2(fid, &finfo) < 0) + if (H5Fget_info2(fid, &finfo) < 0) warn_msg("Unable to retrieve file info\n"); else { - iter.super_size = finfo.super.super_size; - iter.super_ext_size = finfo.super.super_ext_size; - iter.SM_hdr_storage_size = finfo.sohm.hdr_size; + iter.super_size = finfo.super.super_size; + iter.super_ext_size = finfo.super.super_ext_size; + iter.SM_hdr_storage_size = finfo.sohm.hdr_size; iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size; - iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; - iter.free_space = finfo.free.tot_space; - iter.free_hdr = finfo.free.meta_size; + iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; + iter.free_space = finfo.free.tot_space; + iter.free_hdr = finfo.free.meta_size; } /* end else */ iter.num_small_groups = (unsigned long *)HDcalloc((size_t)sgroups_threshold, sizeof(unsigned long)); - iter.num_small_attrs = (unsigned long *)HDcalloc((size_t)(sattrs_threshold+1), sizeof(unsigned long)); + iter.num_small_attrs = + (unsigned long *)HDcalloc((size_t)(sattrs_threshold + 1), sizeof(unsigned long)); iter.small_dset_dims = (unsigned long *)HDcalloc((size_t)sdsets_threshold, sizeof(unsigned long)); - if(iter.num_small_groups == NULL || iter.num_small_attrs == NULL || iter.small_dset_dims == NULL) { + if (iter.num_small_groups == NULL || iter.num_small_attrs == NULL || iter.small_dset_dims == NULL) { error_msg("Unable to allocate memory for tracking small groups/datasets/attributes\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } - if((fcpl = H5Fget_create_plist(fid)) < 0) + if ((fcpl = H5Fget_create_plist(fid)) < 0) warn_msg("Unable to retrieve file creation property\n"); - if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0) + if (H5Pget_userblock(fcpl, &iter.ublk_size) < 0) warn_msg("Unable to retrieve userblock size\n"); - if(H5Pget_file_space_strategy(fcpl, &iter.fs_strategy, &iter.fs_persist, &iter.fs_threshold) < 0) + if (H5Pget_file_space_strategy(fcpl, &iter.fs_strategy, &iter.fs_persist, &iter.fs_threshold) < 0) warn_msg("Unable to retrieve file space information\n"); HDassert(iter.fs_strategy >= 0 && iter.fs_strategy < H5F_FSPACE_STRATEGY_NTYPES); - if(H5Pget_file_space_page_size(fcpl, &iter.fsp_size) < 0) + if (H5Pget_file_space_page_size(fcpl, &iter.fsp_size) < 0) warn_msg("Unable to retrieve file space page size\n"); /* get information for free-space sections */ - if(freespace_stats(fid, &iter) < 0) + if (freespace_stats(fid, &iter) < 0) warn_msg("Unable to retrieve freespace info\n"); /* Walk the objects or all file */ - if(display_object) { + if (display_object) { unsigned u; - for(u = 0; u < hand->obj_count; u++) { - if(h5trav_visit(fid, hand->obj[u], TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < 0) { + for (u = 0; u < hand->obj_count; u++) { + if (h5trav_visit(fid, hand->obj[u], TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < + 0) { error_msg("unable to traverse object \"%s\"\n", hand->obj[u]); h5tools_setstatus(EXIT_FAILURE); } else print_statistics(hand->obj[u], &iter); } /* end for */ - } /* end if */ + } /* end if */ else { - if(h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < 0) { + if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < 0) { error_msg("unable to traverse objects/links in file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); } else print_statistics("/", &iter); } /* end else */ - } /* end if */ + } /* end if */ done: hand_free(hand); @@ -1934,11 +1912,10 @@ done: } } - if(fid >= 0 && H5Fclose(fid) < 0) { + if (fid >= 0 && H5Fclose(fid) < 0) { error_msg("unable to close file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); } /* end if */ leave(h5tools_getstatus()); } /* end main() */ - diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c index 96cbf9c..0ef9483 100644 --- a/tools/src/misc/h5clear.c +++ b/tools/src/misc/h5clear.c @@ -24,64 +24,60 @@ #include "h5tools_utils.h" /* Name of tool */ -#define PROGRAMNAME "h5clear" +#define PROGRAMNAME "h5clear" /* Make these private properties (defined in H5Fprivate.h) available to h5clear. */ -#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" -#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" -#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" +#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" +#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" +#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" /* Default increment is 1 megabytes for the --increment option */ -#define DEFAULT_INCREMENT 1024*1024 +#define DEFAULT_INCREMENT 1024 * 1024 -static char *fname_g = NULL; +static char * fname_g = NULL; static hbool_t clear_status_flags = FALSE; static hbool_t remove_cache_image = FALSE; -static hbool_t print_filesize = FALSE; -static hbool_t increment_eoa_eof = FALSE; -static hsize_t increment = DEFAULT_INCREMENT; +static hbool_t print_filesize = FALSE; +static hbool_t increment_eoa_eof = FALSE; +static hsize_t increment = DEFAULT_INCREMENT; /* * Command-line options: only publicize long options */ -static const char *s_opts = "hVsmzi*"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h'}, - { "he", no_arg, 'h'}, - { "version", no_arg, 'V' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, - { "status", no_arg, 's' }, - { "statu", no_arg, 's' }, - { "stat", no_arg, 's' }, - { "sta", no_arg, 's' }, - { "st", no_arg, 's' }, - { "image", no_arg, 'm' }, - { "imag", no_arg, 'm' }, - { "ima", no_arg, 'm' }, - { "im", no_arg, 'm' }, - { "filesize", no_arg, 'z' }, - { "filesiz", no_arg, 'z' }, - { "filesi", no_arg, 'z' }, - { "files", no_arg, 'z' }, - { "file", no_arg, 'z' }, - { "fil", no_arg, 'z' }, - { "fi", no_arg, 'z' }, - { "increment", optional_arg, 'i' }, - { "incremen", optional_arg, 'i' }, - { "increme", optional_arg, 'i' }, - { "increm", optional_arg, 'i' }, - { "incre", optional_arg, 'i' }, - { "incr", optional_arg, 'i' }, - { "inc", optional_arg, 'i' }, - { "in", optional_arg, 'i' }, - { NULL, 0, '\0' } -}; - - +static const char * s_opts = "hVsmzi*"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"hel", no_arg, 'h'}, + {"he", no_arg, 'h'}, + {"version", no_arg, 'V'}, + {"version", no_arg, 'V'}, + {"versio", no_arg, 'V'}, + {"versi", no_arg, 'V'}, + {"vers", no_arg, 'V'}, + {"status", no_arg, 's'}, + {"statu", no_arg, 's'}, + {"stat", no_arg, 's'}, + {"sta", no_arg, 's'}, + {"st", no_arg, 's'}, + {"image", no_arg, 'm'}, + {"imag", no_arg, 'm'}, + {"ima", no_arg, 'm'}, + {"im", no_arg, 'm'}, + {"filesize", no_arg, 'z'}, + {"filesiz", no_arg, 'z'}, + {"filesi", no_arg, 'z'}, + {"files", no_arg, 'z'}, + {"file", no_arg, 'z'}, + {"fil", no_arg, 'z'}, + {"fi", no_arg, 'z'}, + {"increment", optional_arg, 'i'}, + {"incremen", optional_arg, 'i'}, + {"increme", optional_arg, 'i'}, + {"increm", optional_arg, 'i'}, + {"incre", optional_arg, 'i'}, + {"incr", optional_arg, 'i'}, + {"inc", optional_arg, 'i'}, + {"in", optional_arg, 'i'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -92,7 +88,8 @@ static struct long_options l_opts[] = { * *------------------------------------------------------------------------- */ -static void usage(const char *prog) +static void +usage(const char *prog) { HDfprintf(stdout, "usage: %s [OPTIONS] file_name\n", prog); HDfprintf(stdout, " OPTIONS\n"); @@ -101,12 +98,17 @@ static void usage(const char *prog) HDfprintf(stdout, " -s, --status Clear the status_flags field in the file's superblock\n"); HDfprintf(stdout, " -m, --image Remove the metadata cache image from the file\n"); HDfprintf(stdout, " --filesize Print the file's EOA and EOF\n"); - HDfprintf(stdout, " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for\n"); + HDfprintf(stdout, + " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for\n"); HDfprintf(stdout, " the file .\n"); - HDfprintf(stdout, " C is >= 0; C is optional and will default to 1M when not set.\n"); - HDfprintf(stdout, " This option helps to repair a crashed file where the stored EOA\n"); + HDfprintf(stdout, + " C is >= 0; C is optional and will default to 1M when not set.\n"); + HDfprintf( + stdout, + " This option helps to repair a crashed file where the stored EOA\n"); HDfprintf(stdout, " in the superblock is different from the actual EOF.\n"); - HDfprintf(stdout, " The file’s EOA and EOF will be the same after applying\n"); + HDfprintf(stdout, + " The file’s EOA and EOF will be the same after applying\n"); HDfprintf(stdout, " this option to the file.\n"); HDfprintf(stdout, "\n"); HDfprintf(stdout, "Examples of use:\n"); @@ -124,7 +126,6 @@ static void usage(const char *prog) HDfprintf(stdout, " Set the EOA to the maximum of (EOA, EOF) + 512 for the file .\n"); } /* usage() */ - /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -141,7 +142,7 @@ parse_command_line(int argc, const char **argv) { int opt; - /* no arguments */ + /* no arguments */ if (argc == 1) { usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); @@ -149,8 +150,8 @@ parse_command_line(int argc, const char **argv) } /* parse command line options */ - while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char)opt) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { case 'h': usage(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); @@ -175,7 +176,7 @@ parse_command_line(int argc, const char **argv) case 'i': increment_eoa_eof = TRUE; - if(opt_arg != NULL) { + if (opt_arg != NULL) { if (HDatoi(opt_arg) < 0) { usage(h5tools_getprogname()); goto done; @@ -189,10 +190,10 @@ parse_command_line(int argc, const char **argv) h5tools_setstatus(EXIT_FAILURE); goto error; } /* end switch */ - } /* end while */ + } /* end while */ /* check for file name to be processed */ - if(argc <= opt_ind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); @@ -202,7 +203,7 @@ parse_command_line(int argc, const char **argv) fname_g = HDstrdup(argv[opt_ind]); done: - return(0); + return (0); error: return -1; @@ -224,8 +225,6 @@ leave(int ret) HDexit(ret); } /* leave() */ - - /*------------------------------------------------------------------------- * Function: main * @@ -254,14 +253,14 @@ leave(int ret) *------------------------------------------------------------------------- */ int -main (int argc, const char *argv[]) +main(int argc, const char *argv[]) { - char *fname = NULL; /* File name */ - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - hid_t fid = H5I_INVALID_HID; /* File ID */ - haddr_t image_addr; - hsize_t image_len; - unsigned flags = H5F_ACC_RDWR; /* file access flags */ + char * fname = NULL; /* File name */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + haddr_t image_addr; + hsize_t image_len; + unsigned flags = H5F_ACC_RDWR; /* file access flags */ h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -270,26 +269,24 @@ main (int argc, const char *argv[]) h5tools_init(); /* Parse command line options */ - if(parse_command_line(argc, argv) < 0) + if (parse_command_line(argc, argv) < 0) goto done; - if(fname_g == NULL) + if (fname_g == NULL) goto done; /* enable error reporting if command line option */ h5tools_error_report(); /* Print usage/exit if not using at least one of the options */ - if(!clear_status_flags && !remove_cache_image && - !increment_eoa_eof && !print_filesize) { + if (!clear_status_flags && !remove_cache_image && !increment_eoa_eof && !print_filesize) { usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); goto done; } /* Cannot combine the --filesize option with other options */ - if(print_filesize && - (clear_status_flags || remove_cache_image || increment_eoa_eof)) { + if (print_filesize && (clear_status_flags || remove_cache_image || increment_eoa_eof)) { error_msg("Cannot combine --filesize with other options\n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -299,17 +296,17 @@ main (int argc, const char *argv[]) fname = HDstrdup(fname_g); /* Get a copy of the file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { error_msg("H5Pcreate\n"); h5tools_setstatus(EXIT_FAILURE); goto done; - } + } /* -s option */ - if(clear_status_flags) { + if (clear_status_flags) { /* Set to clear the status_flags in the file's superblock */ /* Activate this private property */ - if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) { + if (H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) { error_msg("H5Pset\n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -317,15 +314,15 @@ main (int argc, const char *argv[]) } /* --increment option */ - if(increment_eoa_eof) { + if (increment_eoa_eof) { /* Activate this private property */ - if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &increment_eoa_eof) < 0) { + if (H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &increment_eoa_eof) < 0) { error_msg("H5Pset\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } /* Activate this private property */ - if(H5Pset(fapl, H5F_ACS_NULL_FSM_ADDR_NAME, &increment_eoa_eof) < 0) { + if (H5Pset(fapl, H5F_ACS_NULL_FSM_ADDR_NAME, &increment_eoa_eof) < 0) { error_msg("H5Pset\n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -333,9 +330,9 @@ main (int argc, const char *argv[]) } /* --filesize option; open the file read-only */ - if(print_filesize) { + if (print_filesize) { /* Activate this private property */ - if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &print_filesize) < 0) { + if (H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &print_filesize) < 0) { error_msg("H5Pset\n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -344,19 +341,19 @@ main (int argc, const char *argv[]) } /* Open the file */ - if((fid = h5tools_fopen(fname, flags, fapl, FALSE, NULL, (size_t)0)) < 0) { + if ((fid = h5tools_fopen(fname, flags, fapl, FALSE, NULL, (size_t)0)) < 0) { error_msg("h5tools_fopen\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } /* --filesize option */ - if(print_filesize) { - h5_stat_t st; /* Stat info call */ - haddr_t eoa; /* The EOA value */ + if (print_filesize) { + h5_stat_t st; /* Stat info call */ + haddr_t eoa; /* The EOA value */ /* Get the file's EOA and EOF */ - if(H5Fget_eoa(fid, &eoa) < 0 || HDstat(fname, &st) < 0) { + if (H5Fget_eoa(fid, &eoa) < 0 || HDstat(fname, &st) < 0) { error_msg("H5Fget_eoa or HDstat\n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -365,9 +362,9 @@ main (int argc, const char *argv[]) } /* --increment option */ - if(increment_eoa_eof) { + if (increment_eoa_eof) { /* Set the file's EOA to the maximum of (EOA, EOF) + increment */ - if(H5Fincrement_filesize(fid, increment) < 0) { + if (H5Fincrement_filesize(fid, increment) < 0) { error_msg("H5Fset_eoa\n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -375,29 +372,30 @@ main (int argc, const char *argv[]) } /* -m option */ - if(remove_cache_image) { - if(H5Fget_mdc_image_info(fid, &image_addr, &image_len) < 0) { + if (remove_cache_image) { + if (H5Fget_mdc_image_info(fid, &image_addr, &image_len) < 0) { error_msg("H5Fget_mdc_image_info\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } - if(image_addr == HADDR_UNDEF && image_len == 0) + if (image_addr == HADDR_UNDEF && image_len == 0) warn_msg("No cache image in the file\n"); } h5tools_setstatus(EXIT_SUCCESS); done: - if(fname) + if (fname) HDfree(fname); - if(fname_g) + if (fname_g) HDfree(fname_g); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Fclose(fid); - } H5E_END_TRY + } + H5E_END_TRY leave(h5tools_getstatus()); } /* main() */ - diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c index e9a783b..1b01704 100644 --- a/tools/src/misc/h5debug.c +++ b/tools/src/misc/h5debug.c @@ -21,42 +21,41 @@ * *------------------------------------------------------------------------- */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#define H5B2_FRIEND /*suppress error about including H5B2pkg */ -#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ -#define H5EA_FRIEND /*suppress error about including H5EApkg */ -#define H5EA_TESTING /*suppress warning about H5EA testing funcs*/ -#define H5FA_FRIEND /*suppress error about including H5FApkg */ -#define H5FA_TESTING /*suppress warning about H5FA testing funcs*/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#define H5HF_FRIEND /*suppress error about including H5HFpkg */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#define H5SM_FRIEND /*suppress error about including H5SMpkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5B2pkg.h" /* v2 B-trees */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#define H5B2_FRIEND /*suppress error about including H5B2pkg */ +#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#define H5EA_FRIEND /*suppress error about including H5EApkg */ +#define H5EA_TESTING /*suppress warning about H5EA testing funcs*/ +#define H5FA_FRIEND /*suppress error about including H5FApkg */ +#define H5FA_TESTING /*suppress warning about H5FA testing funcs*/ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5HF_FRIEND /*suppress error about including H5HFpkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5SM_FRIEND /*suppress error about including H5SMpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5B2pkg.h" /* v2 B-trees */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5Fpkg.h" /* File access */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5Fpkg.h" /* File access */ #include "H5FSprivate.h" /* Free space manager */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HFpkg.h" /* Fractal heaps */ #include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMpkg.h" /* Implicitly shared messages */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMpkg.h" /* Implicitly shared messages */ /* File drivers */ #include "H5FDfamily.h" -#define VCOL 50 - +#define VCOL 50 /*------------------------------------------------------------------------- * Function: get_H5B2_class @@ -76,10 +75,10 @@ static const H5B2_class_t * get_H5B2_class(const uint8_t *sig) { - H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1]; - const H5B2_class_t *cls = NULL; + H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1]; + const H5B2_class_t *cls = NULL; - switch(subtype) { + switch (subtype) { case H5B2_TEST_ID: cls = H5B2_TEST; break; @@ -137,10 +136,9 @@ get_H5B2_class(const uint8_t *sig) HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype)); } /* end switch */ - return(cls); + return (cls); } /* end get_H5B2_class() */ - /*------------------------------------------------------------------------- * Function: get_H5EA_class * @@ -159,10 +157,10 @@ get_H5B2_class(const uint8_t *sig) static const H5EA_class_t * get_H5EA_class(const uint8_t *sig) { - H5EA_cls_id_t clsid = (H5EA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1]; - const H5EA_class_t *cls = NULL; + H5EA_cls_id_t clsid = (H5EA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1]; + const H5EA_class_t *cls = NULL; - switch(clsid) { + switch (clsid) { case H5EA_CLS_TEST_ID: cls = H5EA_CLS_TEST; break; @@ -180,10 +178,9 @@ get_H5EA_class(const uint8_t *sig) HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid)); } /* end switch */ - return(cls); + return (cls); } /* end get_H5EA_class() */ - /*------------------------------------------------------------------------- * Function: get_H5FA_class * @@ -202,10 +199,10 @@ get_H5EA_class(const uint8_t *sig) static const H5FA_class_t * get_H5FA_class(const uint8_t *sig) { - H5FA_cls_id_t clsid = (H5FA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1]; - const H5FA_class_t *cls = NULL; + H5FA_cls_id_t clsid = (H5FA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1]; + const H5FA_class_t *cls = NULL; - switch(clsid) { + switch (clsid) { case H5FA_CLS_TEST_ID: cls = H5FA_CLS_TEST; break; @@ -223,10 +220,9 @@ get_H5FA_class(const uint8_t *sig) HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid)); } /* end switch */ - return(cls); + return (cls); } /* end get_H5FA_class() */ - /*------------------------------------------------------------------------- * Function: main * @@ -245,29 +241,29 @@ get_H5FA_class(const uint8_t *sig) int main(int argc, char *argv[]) { - hid_t fid = H5I_INVALID_HID; - hid_t fapl = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t fapl = H5I_INVALID_HID; H5VL_object_t *vol_obj; - H5F_t *f; - haddr_t addr = 0; - int extra_count = 0; /* Number of extra arguments */ - haddr_t extra[10]; - uint8_t sig[H5F_SIGNATURE_LEN]; - size_t u; - H5E_auto2_t func; - void *edata; - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t status = SUCCEED; - int exit_value = 0; - - if(argc == 1) { + H5F_t * f; + haddr_t addr = 0; + int extra_count = 0; /* Number of extra arguments */ + haddr_t extra[10]; + uint8_t sig[H5F_SIGNATURE_LEN]; + size_t u; + H5E_auto2_t func; + void * edata; + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t status = SUCCEED; + int exit_value = 0; + + if (argc == 1) { HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]*]\n", argv[0]); exit_value = 1; goto done; } /* end if */ /* Initialize the library */ - if(H5open() < 0) { + if (H5open() < 0) { HDfprintf(stderr, "cannot initialize the library\n"); exit_value = 1; goto done; @@ -280,45 +276,45 @@ main(int argc, char *argv[]) /* * Open the file and get the file descriptor. */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { HDfprintf(stderr, "cannot create file access property list\n"); exit_value = 1; goto done; } /* end if */ - if(HDstrchr(argv[1], '%')) - if(H5Pset_fapl_family (fapl, (hsize_t)0, H5P_DEFAULT) < 0) { + if (HDstrchr(argv[1], '%')) + if (H5Pset_fapl_family(fapl, (hsize_t)0, H5P_DEFAULT) < 0) { HDfprintf(stderr, "cannot set file access property list\n"); exit_value = 1; goto done; } - if((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) { + if ((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) { HDfprintf(stderr, "cannot open file\n"); exit_value = 1; goto done; } /* end if */ /* Push API context */ - if(H5CX_push() < 0) { + if (H5CX_push() < 0) { HDfprintf(stderr, "cannot set API context\n"); exit_value = 1; goto done; } api_ctx_pushed = TRUE; - if(NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(fid))) { + if (NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(fid))) { HDfprintf(stderr, "cannot obtain vol_obj pointer\n"); exit_value = 2; goto done; } /* end if */ - if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj))) { + if (NULL == (f = (H5F_t *)H5VL_object_data(vol_obj))) { HDfprintf(stderr, "cannot obtain H5F_t pointer\n"); exit_value = 2; goto done; } /* end if */ /* Ignore metadata tags while using h5debug */ - if(H5AC_ignore_tags(f) < 0) { + if (H5AC_ignore_tags(f) < 0) { HDfprintf(stderr, "cannot ignore metadata tags\n"); exit_value = 1; goto done; @@ -329,22 +325,23 @@ main(int argc, char *argv[]) */ /* Primary data structure to dump */ - if(argc > 2) + if (argc > 2) addr = (haddr_t)HDstrtoll(argv[2], NULL, 0); /* Extra arguments for primary data structure */ HDmemset(extra, 0, sizeof(extra)); - if(argc > 3) { + if (argc > 3) { /* Number of extra arguments */ extra_count = argc - 3; /* Range check against 'extra' array size */ - if(extra_count > (int)(sizeof(extra) / sizeof(haddr_t))) { - HDfprintf(stderr, "\nWARNING: Only using first %d extra parameters\n\n", (int)(sizeof(extra) / sizeof(haddr_t))); + if (extra_count > (int)(sizeof(extra) / sizeof(haddr_t))) { + HDfprintf(stderr, "\nWARNING: Only using first %d extra parameters\n\n", + (int)(sizeof(extra) / sizeof(haddr_t))); extra_count = (int)(sizeof(extra) / sizeof(haddr_t)); } /* end if */ - for(u = 0; u < (size_t)extra_count; u++) + for (u = 0; u < (size_t)extra_count; u++) extra[u] = (haddr_t)HDstrtoll(argv[u + 3], NULL, 0); } /* end if */ @@ -352,47 +349,45 @@ main(int argc, char *argv[]) * Read the signature at the specified file position. */ HDfprintf(stdout, "Reading signature at address %a (rel)\n", addr); - if(H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), sig) < 0) { + if (H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), sig) < 0) { HDfprintf(stderr, "cannot read signature\n"); exit_value = 3; goto done; } - if(!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) { + if (!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) { /* * Debug the file's super block. */ status = H5F_debug(f, stdout, 0, VCOL); - - } else if(!HDmemcmp(sig, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + } + else if (!HDmemcmp(sig, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a local heap. */ status = H5HL_debug(f, addr, stdout, 0, VCOL); - } - else if(!HDmemcmp (sig, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a global heap collection. */ status = H5HG_debug(f, addr, stdout, 0, VCOL); - } - else if(!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a symbol table node. */ /* Check for extra parameters */ - if(extra_count == 0 || extra[0] == 0) { - HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n"); + if (extra_count == 0 || extra[0] == 0) { + HDfprintf(stderr, + "\nWarning: Providing the group's local heap address will give more information\n"); HDfprintf(stderr, "Symbol table node usage:\n"); HDfprintf(stderr, "\th5debug
\n\n"); } /* end if */ status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]); - } - else if(!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a B-tree. B-trees are debugged through the B-tree * subclass. The subclass identifier is the byte immediately @@ -402,79 +397,87 @@ main(int argc, char *argv[]) unsigned ndims; uint32_t dim[H5O_LAYOUT_NDIMS]; - switch(subtype) { - case H5B_SNODE_ID: - /* Check for extra parameters */ - if(extra_count == 0 || extra[0] == 0) { - HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n"); - HDfprintf(stderr, "B-tree symbol table node usage:\n"); - HDfprintf(stderr, "\th5debug
\n\n"); - exit_value = 4; - goto done; - } /* end if */ - - status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]); - break; - - case H5B_CHUNK_ID: - /* Check for extra parameters */ - if(extra_count == 0 || extra[0] == 0) { - HDfprintf(stderr, "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n"); - HDfprintf(stderr, "B-tree chunked storage node usage:\n"); - HDfprintf(stderr, "\th5debug <# of dimensions> ...\n"); - exit_value = 4; - goto done; - } /* end if */ - - /* Set # of dimensions */ - ndims = (unsigned)extra[0]; - - /* Check for dimension error */ - if(ndims > 9) { - HDfprintf(stderr, "ERROR: Only 9 dimensions support currently (fix h5debug)\n"); - HDfprintf(stderr, "B-tree chunked storage node usage:\n"); - HDfprintf(stderr, "\th5debug <# of dimensions> ...\n"); - exit_value = 4; - goto done; - } /* end for */ + switch (subtype) { + case H5B_SNODE_ID: + /* Check for extra parameters */ + if (extra_count == 0 || extra[0] == 0) { + HDfprintf( + stderr, + "\nWarning: Providing the group's local heap address will give more information\n"); + HDfprintf(stderr, "B-tree symbol table node usage:\n"); + HDfprintf(stderr, + "\th5debug
\n\n"); + exit_value = 4; + goto done; + } /* end if */ - /* Build array of chunk dimensions */ - for(u = 0; u < ndims; u++) - dim[u] = (uint32_t)extra[u + 1]; + status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]); + break; - /* Check for dimension error */ - for(u = 0; u < ndims; u++) - if(0 == dim[u]) { - HDfprintf(stderr, "ERROR: Chunk dimensions should be >0\n"); + case H5B_CHUNK_ID: + /* Check for extra parameters */ + if (extra_count == 0 || extra[0] == 0) { + HDfprintf( + stderr, + "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n"); HDfprintf(stderr, "B-tree chunked storage node usage:\n"); - HDfprintf(stderr, "\th5debug <# of dimensions> ...\n"); + HDfprintf(stderr, "\th5debug <# of dimensions> ...\n"); exit_value = 4; goto done; } /* end if */ - /* Set the last dimension (the element size) to zero */ - dim[ndims] = 0; - - status = H5D_btree_debug(f, addr, stdout, 0, VCOL, ndims, dim); - break; + /* Set # of dimensions */ + ndims = (unsigned)extra[0]; - case H5B_NUM_BTREE_ID: - default: - HDfprintf(stderr, "Unknown v1 B-tree subtype %u\n", (unsigned)(subtype)); - exit_value = 4; - goto done; + /* Check for dimension error */ + if (ndims > 9) { + HDfprintf(stderr, "ERROR: Only 9 dimensions support currently (fix h5debug)\n"); + HDfprintf(stderr, "B-tree chunked storage node usage:\n"); + HDfprintf(stderr, "\th5debug <# of dimensions> ...\n"); + exit_value = 4; + goto done; + } /* end for */ + + /* Build array of chunk dimensions */ + for (u = 0; u < ndims; u++) + dim[u] = (uint32_t)extra[u + 1]; + + /* Check for dimension error */ + for (u = 0; u < ndims; u++) + if (0 == dim[u]) { + HDfprintf(stderr, "ERROR: Chunk dimensions should be >0\n"); + HDfprintf(stderr, "B-tree chunked storage node usage:\n"); + HDfprintf(stderr, "\th5debug <# of dimensions> " + "...\n"); + exit_value = 4; + goto done; + } /* end if */ + + /* Set the last dimension (the element size) to zero */ + dim[ndims] = 0; + + status = H5D_btree_debug(f, addr, stdout, 0, VCOL, ndims, dim); + break; + + case H5B_NUM_BTREE_ID: + default: + HDfprintf(stderr, "Unknown v1 B-tree subtype %u\n", (unsigned)(subtype)); + exit_value = 4; + goto done; } - } - else if(!HDmemcmp(sig, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a v2 B-tree header. - */ + */ const H5B2_class_t *cls = get_H5B2_class(sig); HDassert(cls); - if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0)) { - HDfprintf(stderr, "ERROR: Need v2 B-tree header address and object header address containing the layout message in order to dump header\n"); + if ((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0)) { + HDfprintf(stderr, "ERROR: Need v2 B-tree header address and object header address containing the " + "layout message in order to dump header\n"); HDfprintf(stderr, "v2 B-tree hdr usage:\n"); HDfprintf(stderr, "\th5debug \n"); exit_value = 4; @@ -482,9 +485,8 @@ main(int argc, char *argv[]) } /* end if */ status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra[0]); - } - else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a v2 B-tree internal node. */ @@ -492,28 +494,35 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 || extra[3] == 0)) { - HDfprintf(stderr, "ERROR: Need v2 B-tree header address, the node's number of records, depth, and object header address containing the layout message in order to dump internal node\n"); - HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n"); + if ((cls == H5D_BT2 || cls == H5D_BT2_FILT) && + (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 || extra[3] == 0)) { + HDfprintf(stderr, + "ERROR: Need v2 B-tree header address, the node's number of records, depth, and object " + "header address containing the layout message in order to dump internal node\n"); + HDfprintf(stderr, + "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n"); HDfprintf(stderr, "v2 B-tree internal node usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf(stderr, "\th5debug " + " \n"); exit_value = 4; goto done; - } - else if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) { - HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and depth in order to dump internal node\n"); - HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n"); + else if (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) { + HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and " + "depth in order to dump internal node\n"); + HDfprintf(stderr, + "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n"); HDfprintf(stderr, "v2 B-tree internal node usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf(stderr, "\th5debug " + " \n"); exit_value = 4; goto done; } /* end if */ - status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (unsigned)extra[2], (haddr_t)extra[3]); - + status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], + (unsigned)extra[2], (haddr_t)extra[3]); } - else if(!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a v2 B-tree leaf node. */ @@ -521,118 +530,126 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 )) { + if ((cls == H5D_BT2 || cls == H5D_BT2_FILT) && + (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0)) { - HDfprintf(stderr, "ERROR: Need v2 B-tree header address, number of records, and object header address containing the layout message in order to dump leaf node\n"); + HDfprintf(stderr, "ERROR: Need v2 B-tree header address, number of records, and object header " + "address containing the layout message in order to dump leaf node\n"); HDfprintf(stderr, "v2 B-tree leaf node usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf(stderr, "\th5debug \n"); exit_value = 4; goto done; - } - else if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { - HDfprintf(stderr, "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n"); + else if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) { + HDfprintf( + stderr, + "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n"); HDfprintf(stderr, "v2 B-tree leaf node usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf( + stderr, + "\th5debug \n"); exit_value = 4; goto done; } /* end if */ - status = H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (haddr_t)extra[2]); - + status = + H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (haddr_t)extra[2]); } - else if(!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a fractal heap header. */ status = H5HF_hdr_debug(f, addr, stdout, 0, VCOL); - } - else if(!HDmemcmp(sig, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a fractal heap direct block. */ /* Check for enough valid parameters */ - if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { - HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to dump direct block\n"); + if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) { + HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to " + "dump direct block\n"); HDfprintf(stderr, "Fractal heap direct block usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf( + stderr, + "\th5debug \n"); exit_value = 4; goto done; } /* end if */ status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra[0], (size_t)extra[1]); - } - else if(!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a fractal heap indirect block. */ /* Check for enough valid parameters */ - if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { - HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump indirect block\n"); + if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) { + HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump " + "indirect block\n"); HDfprintf(stderr, "Fractal heap indirect block usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf( + stderr, + "\th5debug \n"); exit_value = 4; goto done; } /* end if */ status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra[0], (unsigned)extra[1]); - } - else if(!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a free space header. */ status = H5FS_debug(f, addr, stdout, 0, VCOL); - } - else if(!HDmemcmp(sig, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug free space serialized sections. */ /* Check for enough valid parameters */ - if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { - HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump serialized sections\n"); + if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) { + HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump " + "serialized sections\n"); HDfprintf(stderr, "Free space serialized sections usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf(stderr, "\th5debug \n"); exit_value = 4; goto done; } /* end if */ status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra[0], extra[1]); - } - else if(!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug shared message master table. */ - status = H5SM_table_debug(f, addr, stdout, 0, VCOL, (unsigned) UFAIL, (unsigned) UFAIL); - + status = H5SM_table_debug(f, addr, stdout, 0, VCOL, (unsigned)UFAIL, (unsigned)UFAIL); } - else if(!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug shared message list index. */ /* Check for enough valid parameters */ - if(extra_count == 0 || extra[0] == 0) { + if (extra_count == 0 || extra[0] == 0) { HDfprintf(stderr, "ERROR: Need shared message header address in order to shared message list\n"); HDfprintf(stderr, "Shared message list usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf(stderr, + "\th5debug \n"); exit_value = 4; goto done; } /* end if */ status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra[0]); - } - else if(!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug an extensible aray header. */ @@ -640,18 +657,20 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if(extra_count == 0 || extra[0] == 0) { - HDfprintf(stderr, "ERROR: Need object header address containing the layout message in order to dump header\n"); + if (extra_count == 0 || extra[0] == 0) { + HDfprintf( + stderr, + "ERROR: Need object header address containing the layout message in order to dump header\n"); HDfprintf(stderr, "Extensible array header block usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf(stderr, + "\th5debug \n"); exit_value = 4; goto done; } /* end if */ status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]); - } - else if(!HDmemcmp(sig, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug an extensible aray index block. */ @@ -659,18 +678,20 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { - HDfprintf(stderr, "ERROR: Need extensible array header address and object header address containing the layout message in order to dump index block\n"); + if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) { + HDfprintf(stderr, "ERROR: Need extensible array header address and object header address " + "containing the layout message in order to dump index block\n"); HDfprintf(stderr, "Extensible array index block usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf(stderr, "\th5debug \n"); exit_value = 4; goto done; } /* end if */ status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], extra[2]); - } - else if(!HDmemcmp(sig, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug an extensible aray data block. */ @@ -697,18 +719,20 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) { - HDfprintf(stderr, "ERROR: Need extensible array header address, # of elements in data block and object header address containing the layout message in order to dump data block\n"); + if (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) { + HDfprintf(stderr, + "ERROR: Need extensible array header address, # of elements in data block and object " + "header address containing the layout message in order to dump data block\n"); HDfprintf(stderr, "Extensible array data block usage:\n"); - HDfprintf(stderr, "\th5debug <# of elements in data block> <# of " + "elements in data block> \n"); exit_value = 4; @@ -725,9 +751,8 @@ main(int argc, char *argv[]) } /* end if */ status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]); - } - else if(!HDmemcmp(sig, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug a fixed array data block. */ @@ -735,32 +760,32 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { - HDfprintf(stderr, "ERROR: Need fixed array header address and object header address containing the layout message in order to dump data block\n"); + if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) { + HDfprintf(stderr, "ERROR: Need fixed array header address and object header address containing " + "the layout message in order to dump data block\n"); HDfprintf(stderr, "fixed array data block usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf( + stderr, + "\th5debug \n"); exit_value = 4; goto done; } /* end if */ status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], extra[1]); - } - else if(!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + else if (!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* * Debug v2 object header (which have signatures). */ status = H5O_debug(f, addr, stdout, 0, VCOL); - } - else if(sig[0] == H5O_VERSION_1) { + else if (sig[0] == H5O_VERSION_1) { /* * This could be a v1 object header. Since they don't have a signature * it's a somewhat "ify" detection. */ status = H5O_debug(f, addr, stdout, 0, VCOL); - } else { /* @@ -785,7 +810,7 @@ main(int argc, char *argv[]) } /* end else */ /* Check for an error when dumping information */ - if(status < 0) { + if (status < 0) { HDfprintf(stderr, "An error occurred!\n"); H5Eprint2(H5E_DEFAULT, stderr); exit_value = 5; @@ -793,14 +818,16 @@ main(int argc, char *argv[]) } /* end if */ done: - if(fapl > 0) H5Pclose(fapl); - if(fid > 0) H5Fclose(fid); + if (fapl > 0) + H5Pclose(fapl); + if (fid > 0) + H5Fclose(fid); /* Pop API context */ - if(api_ctx_pushed) H5CX_pop(); + if (api_ctx_pushed) + H5CX_pop(); H5Eset_auto2(H5E_DEFAULT, func, edata); return exit_value; } /* main() */ - diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c index ad3b7b8..21a647f 100644 --- a/tools/src/misc/h5mkgrp.c +++ b/tools/src/misc/h5mkgrp.c @@ -11,7 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #include "H5private.h" #include "h5tools.h" #include "h5tools_utils.h" @@ -23,33 +22,25 @@ int d_status = EXIT_SUCCESS; /* command-line options: short and long-named parameters */ -static const char *s_opts = "hlpvV"; +static const char * s_opts = "hlpvV"; static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "latest", no_arg, 'l' }, - { "parents", no_arg, 'p' }, - { "verbose", no_arg, 'v' }, - { "version", no_arg, 'V' }, - { "vol-value", require_arg, '1' }, - { "vol-name", require_arg, '2' }, - { "vol-info", require_arg, '3' }, - { NULL, 0, '\0' } -}; + {"help", no_arg, 'h'}, {"latest", no_arg, 'l'}, {"parents", no_arg, 'p'}, + {"verbose", no_arg, 'v'}, {"version", no_arg, 'V'}, {"vol-value", require_arg, '1'}, + {"vol-name", require_arg, '2'}, {"vol-info", require_arg, '3'}, {NULL, 0, '\0'}}; /* Command line parameter settings */ typedef struct mkgrp_opt_t { - char *fname; /* File name to operate on */ - hbool_t latest; /* Whether file should use latest format versions */ - hbool_t verbose; /* Whether output should be verbose */ - hbool_t parents; /* Whether to create intermediate groups */ - size_t ngroups; /* Number of groups to create */ - char **groups; /* Pointer to array of group names */ - hid_t fapl_id; /* fapl to use when opening the file */ + char * fname; /* File name to operate on */ + hbool_t latest; /* Whether file should use latest format versions */ + hbool_t verbose; /* Whether output should be verbose */ + hbool_t parents; /* Whether to create intermediate groups */ + size_t ngroups; /* Number of groups to create */ + char ** groups; /* Pointer to array of group names */ + hid_t fapl_id; /* fapl to use when opening the file */ } mkgrp_opt_t; -mkgrp_opt_t params_g; /* Command line parameter settings */ +mkgrp_opt_t params_g; /* Command line parameter settings */ - /*------------------------------------------------------------------------- * Function: leave * @@ -81,7 +72,6 @@ leave(int ret) HDexit(ret); } /* end leave() */ - /*------------------------------------------------------------------------- * Function: usage * @@ -100,20 +90,24 @@ usage(const char *prog) PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] FILE GROUP...\n", prog); PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n"); - PRINTVALSTREAM(rawoutstream, " -l, --latest Use latest version of file format to create groups\n"); - PRINTVALSTREAM(rawoutstream, " -p, --parents No error if existing, make parent groups as needed\n"); + PRINTVALSTREAM(rawoutstream, + " -l, --latest Use latest version of file format to create groups\n"); + PRINTVALSTREAM(rawoutstream, + " -p, --parents No error if existing, make parent groups as needed\n"); PRINTVALSTREAM(rawoutstream, " -v, --verbose Print information about OBJECTS and OPTIONS\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); - PRINTVALSTREAM(rawoutstream, " --vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-value Value (ID) of the VOL connector to use for opening the\n"); PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-name Name of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-name Name of the VOL connector to use for opening the\n"); PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); - PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, + " --vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, "\n"); } /* end usage() */ - /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -130,14 +124,14 @@ usage(const char *prog) static int parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) { - int opt; /* Option from command line */ - size_t curr_group; /* Current group name to copy */ - hbool_t custom_fapl = FALSE; + int opt; /* Option from command line */ + size_t curr_group; /* Current group name to copy */ + hbool_t custom_fapl = FALSE; h5tools_vol_info_t vol_info; - hid_t tmp_fapl_id = H5I_INVALID_HID; + hid_t tmp_fapl_id = H5I_INVALID_HID; /* Check for empty command line */ - if(argc == 1) { + if (argc == 1) { usage(h5tools_getprogname()); leave(EXIT_SUCCESS); } @@ -146,8 +140,8 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t)); /* Parse command line options */ - while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char)opt) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { /* Display 'help' */ case 'h': usage(h5tools_getprogname()); @@ -176,15 +170,15 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) break; case '1': - vol_info.type = VOL_BY_VALUE; + vol_info.type = VOL_BY_VALUE; vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg); - custom_fapl = TRUE; + custom_fapl = TRUE; break; case '2': - vol_info.type = VOL_BY_NAME; + vol_info.type = VOL_BY_NAME; vol_info.u.name = opt_arg; - custom_fapl = TRUE; + custom_fapl = TRUE; break; case '3': @@ -196,10 +190,10 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) usage(h5tools_getprogname()); leave(EXIT_FAILURE); } /* end switch */ - } /* end while */ + } /* end while */ /* Check for file name to be processed */ - if(argc <= opt_ind) { + if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -210,7 +204,7 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) opt_ind++; /* Check for group(s) to be created */ - if(argc <= opt_ind) { + if (argc <= opt_ind) { error_msg("missing group name(s)\n"); usage(h5tools_getprogname()); leave(EXIT_FAILURE); @@ -218,11 +212,11 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) /* Allocate space for the group name pointers */ options->ngroups = (size_t)(argc - opt_ind); - options->groups = (char **)HDmalloc(options->ngroups * sizeof(char *)); + options->groups = (char **)HDmalloc(options->ngroups * sizeof(char *)); /* Retrieve the group names */ curr_group = 0; - while(opt_ind < argc) { + while (opt_ind < argc) { options->groups[curr_group] = HDstrdup(argv[opt_ind]); curr_group++; opt_ind++; @@ -248,7 +242,6 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) return 0; } /* parse_command_line() */ - /*------------------------------------------------------------------------- * Function: main * @@ -261,9 +254,9 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) int main(int argc, const char *argv[]) { - hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ - hid_t lcpl_id = H5I_INVALID_HID; /* Link creation property list ID */ - size_t curr_group; /* Current group to create */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t lcpl_id = H5I_INVALID_HID; /* Link creation property list ID */ + size_t curr_group; /* Current group to create */ h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -275,13 +268,13 @@ main(int argc, const char *argv[]) HDmemset(¶ms_g, 0, sizeof(params_g)); /* Create file access property list */ - if((params_g.fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + if ((params_g.fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { error_msg("Could not create file access property list\n"); leave(EXIT_FAILURE); } /* Parse command line */ - if(parse_command_line(argc, argv, ¶ms_g) < 0) { + if (parse_command_line(argc, argv, ¶ms_g) < 0) { error_msg("unable to parse command line arguments\n"); leave(EXIT_FAILURE); } @@ -290,15 +283,15 @@ main(int argc, const char *argv[]) h5tools_error_report(); /* Check for creating groups with new format version */ - if(params_g.latest) { + if (params_g.latest) { /* Set the "use the latest version of the format" bounds */ - if(H5Pset_libver_bounds(params_g.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + if (H5Pset_libver_bounds(params_g.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { error_msg("Could not set property for using latest version of the format\n"); leave(EXIT_FAILURE); } /* Display some output if requested */ - if(params_g.verbose) + if (params_g.verbose) HDprintf("%s: Creating groups with latest version of the format\n", h5tools_getprogname()); } @@ -307,67 +300,66 @@ main(int argc, const char *argv[]) /* If we couldn't open an existing file, try creating file */ /* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */ - if(fid < 0) + if (fid < 0) fid = H5Fcreate(params_g.fname, H5F_ACC_EXCL, H5P_DEFAULT, params_g.fapl_id); /* Test for error in opening file */ - if(fid < 0) { + if (fid < 0) { error_msg("Could not open output file '%s'\n", params_g.fname); leave(EXIT_FAILURE); } /* Create link creation property list */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) { + if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) { error_msg("Could not create link creation property list\n"); leave(EXIT_FAILURE); } /* Check for creating intermediate groups */ - if(params_g.parents) { + if (params_g.parents) { /* Set the intermediate group creation property */ - if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) { + if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) { error_msg("Could not set property for creating parent groups\n"); leave(EXIT_FAILURE); } /* Display some output if requested */ - if(params_g.verbose) + if (params_g.verbose) HDprintf("%s: Creating parent groups\n", h5tools_getprogname()); } /* Loop over creating requested groups */ - for(curr_group = 0; curr_group < params_g.ngroups; curr_group++) { - hid_t gid; /* Group ID */ + for (curr_group = 0; curr_group < params_g.ngroups; curr_group++) { + hid_t gid; /* Group ID */ /* Attempt to create a group */ - if((gid = H5Gcreate2(fid, params_g.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + if ((gid = H5Gcreate2(fid, params_g.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { error_msg("Could not create group '%s'\n", params_g.groups[curr_group]); leave(EXIT_FAILURE); } /* Close the group */ - if(H5Gclose(gid) < 0) { + if (H5Gclose(gid) < 0) { error_msg("Could not close group '%s'??\n", params_g.groups[curr_group]); leave(EXIT_FAILURE); } /* Display some output if requested */ - if(params_g.verbose) + if (params_g.verbose) HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params_g.groups[curr_group]); } /* end for */ /* Close link creation property list */ - if(H5Pclose(lcpl_id) < 0) { + if (H5Pclose(lcpl_id) < 0) { error_msg("Could not close link creation property list\n"); leave(EXIT_FAILURE); } /* Close file */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { error_msg("Could not close output file '%s'??\n", params_g.fname); leave(EXIT_FAILURE); } leave(EXIT_SUCCESS); } /* end main() */ - diff --git a/tools/src/misc/h5repart.c b/tools/src/misc/h5repart.c index d516fa0..10e9f23 100644 --- a/tools/src/misc/h5repart.c +++ b/tools/src/misc/h5repart.c @@ -26,16 +26,15 @@ #include "hdf5.h" #include "H5private.h" -#define NAMELEN 4096 -#define GB *1024*1024*1024 +#define NAMELEN 4096 +#define GB *1024 * 1024 * 1024 /* Make these 2 private properties(defined in H5Fprivate.h) available to h5repart. * The first one updates the member file size in the superblock. The second one * change file driver from family to a single file driver. */ -#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" -#define H5F_ACS_FAMILY_TO_SINGLE_NAME "family_to_single" - +#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" +#define H5F_ACS_FAMILY_TO_SINGLE_NAME "family_to_single" /*------------------------------------------------------------------------- * Function: usage @@ -52,26 +51,26 @@ *------------------------------------------------------------------------- */ static void -usage (const char *progname) +usage(const char *progname) { HDfprintf(stderr, "usage: %s [-v] [-V] [-[b|m] N[g|m|k]] [-family_to_sec2|-family_to_single] SRC DST\n", - progname); + progname); HDfprintf(stderr, " -v Produce verbose output\n"); HDfprintf(stderr, " -V Print a version number and exit\n"); HDfprintf(stderr, " -b N The I/O block size, defaults to 1kB\n"); HDfprintf(stderr, " -m N The destination member size or 1GB\n"); HDfprintf(stderr, " -family_to_sec2 Deprecated version of -family_to_single (below)\n"); - HDfprintf(stderr, " -family_to_single Change file driver from family to the default single-file VFD (windows or sec2)\n"); + HDfprintf(stderr, " -family_to_single Change file driver from family to the default single-file VFD " + "(windows or sec2)\n"); HDfprintf(stderr, " SRC The name of the source file\n"); HDfprintf(stderr, " DST The name of the destination files\n"); HDfprintf(stderr, "Sizes may be suffixed with `g' for GB, `m' for MB or " - "`k' for kB.\n"); + "`k' for kB.\n"); HDfprintf(stderr, "File family names include an integer printf " - "format such as `%%d'\n"); - HDexit (EXIT_FAILURE); + "format such as `%%d'\n"); + HDexit(EXIT_FAILURE); } - /*------------------------------------------------------------------------- * Function: get_size * @@ -95,48 +94,47 @@ usage (const char *progname) *------------------------------------------------------------------------- */ static off_t -get_size (const char *progname, int *argno, int argc, char *argv[]) +get_size(const char *progname, int *argno, int argc, char *argv[]) { - off_t retval=-1; - char *suffix; + off_t retval = -1; + char *suffix; - if (isdigit ((int)(argv[*argno][2]))) { - retval = HDstrtol(argv[*argno]+2, &suffix, 10); + if (isdigit((int)(argv[*argno][2]))) { + retval = HDstrtol(argv[*argno] + 2, &suffix, 10); (*argno)++; } - else if (argv[*argno][2] || *argno+1>=argc) { - usage (progname); + else if (argv[*argno][2] || *argno + 1 >= argc) { + usage(progname); } else { - retval = HDstrtol(argv[*argno+1], &suffix, 0); - if (suffix == argv[*argno+1]) - usage (progname); + retval = HDstrtol(argv[*argno + 1], &suffix, 0); + if (suffix == argv[*argno + 1]) + usage(progname); *argno += 2; } if (suffix && suffix[0] && !suffix[1]) { switch (*suffix) { - case 'G': - case 'g': - retval *= 1024 * 1024 * 1024; - break; - case 'M': - case 'm': - retval *= 1024 * 1024; - break; - case 'k': - retval *= 1024; - break; - default: - usage(progname); + case 'G': + case 'g': + retval *= 1024 * 1024 * 1024; + break; + case 'M': + case 'm': + retval *= 1024 * 1024; + break; + case 'k': + retval *= 1024; + break; + default: + usage(progname); } } else if (suffix && suffix[0]) { - usage (progname); + usage(progname); } return retval; } - /*------------------------------------------------------------------------- * Function: main * @@ -154,47 +152,47 @@ get_size (const char *progname, int *argno, int argc, char *argv[]) *------------------------------------------------------------------------- */ int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { - const char *prog_name; /*program name */ - size_t blk_size=1024; /*size of each I/O block */ - char *buf=NULL; /*I/O block buffer */ - size_t n, i; /*counters */ - ssize_t nio; /*I/O return value */ - int argno=1; /*program argument number */ - int src, dst=-1; /*source & destination files */ - int need_seek=FALSE; /*destination needs to seek? */ - int need_write; /*data needs to be written? */ - h5_stat_t sb; /*temporary file stat buffer */ - - int verbose=FALSE; /*display file names? */ - - const char *src_gen_name; /*general source name */ - char *src_name=NULL; /*source member name */ - - int src_is_family; /*is source name a family name? */ - int src_membno=0; /*source member number */ - - const char *dst_gen_name; /*general destination name */ - char *dst_name=NULL; /*destination member name */ - int dst_is_family; /*is dst name a family name? */ - int dst_membno=0; /*destination member number */ - - off_t left_overs=0; /*amount of zeros left over */ - off_t src_offset=0; /*offset in source member */ - off_t dst_offset=0; /*offset in destination member */ - off_t src_size; /*source logical member size */ - off_t src_act_size; /*source actual member size */ - off_t dst_size=1 GB; /*destination logical memb size */ - hid_t fapl; /*file access property list */ - hid_t file; - hsize_t hdsize; /*destination logical memb size */ - hbool_t family_to_single = FALSE; /*change family to single file driver? */ + const char *prog_name; /*program name */ + size_t blk_size = 1024; /*size of each I/O block */ + char * buf = NULL; /*I/O block buffer */ + size_t n, i; /*counters */ + ssize_t nio; /*I/O return value */ + int argno = 1; /*program argument number */ + int src, dst = -1; /*source & destination files */ + int need_seek = FALSE; /*destination needs to seek? */ + int need_write; /*data needs to be written? */ + h5_stat_t sb; /*temporary file stat buffer */ + + int verbose = FALSE; /*display file names? */ + + const char *src_gen_name; /*general source name */ + char * src_name = NULL; /*source member name */ + + int src_is_family; /*is source name a family name? */ + int src_membno = 0; /*source member number */ + + const char *dst_gen_name; /*general destination name */ + char * dst_name = NULL; /*destination member name */ + int dst_is_family; /*is dst name a family name? */ + int dst_membno = 0; /*destination member number */ + + off_t left_overs = 0; /*amount of zeros left over */ + off_t src_offset = 0; /*offset in source member */ + off_t dst_offset = 0; /*offset in destination member */ + off_t src_size; /*source logical member size */ + off_t src_act_size; /*source actual member size */ + off_t dst_size = 1 GB; /*destination logical memb size */ + hid_t fapl; /*file access property list */ + hid_t file; + hsize_t hdsize; /*destination logical memb size */ + hbool_t family_to_single = FALSE; /*change family to single file driver? */ /* * Get the program name from argv[0]. Use only the last component. */ - if ((prog_name = HDstrrchr (argv[0], '/'))) + if ((prog_name = HDstrrchr(argv[0], '/'))) prog_name++; else prog_name = argv[0]; @@ -206,28 +204,35 @@ main (int argc, char *argv[]) if (!HDstrcmp(argv[argno], "-v")) { verbose = TRUE; argno++; - } else if (!HDstrcmp(argv[argno], "-V")) { - HDprintf("This is %s version %u.%u release %u\n", prog_name, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); + } + else if (!HDstrcmp(argv[argno], "-V")) { + HDprintf("This is %s version %u.%u release %u\n", prog_name, H5_VERS_MAJOR, H5_VERS_MINOR, + H5_VERS_RELEASE); HDexit(EXIT_SUCCESS); - } else if (!HDstrcmp(argv[argno], "-family_to_sec2")) { + } + else if (!HDstrcmp(argv[argno], "-family_to_sec2")) { family_to_single = TRUE; argno++; - } else if (!HDstrcmp(argv[argno], "-family_to_single")) { + } + else if (!HDstrcmp(argv[argno], "-family_to_single")) { family_to_single = TRUE; argno++; - } else if ('b' == argv[argno][1]) { - blk_size = (size_t) get_size(prog_name, &argno, argc, argv); - } else if ('m' == argv[argno][1]) { + } + else if ('b' == argv[argno][1]) { + blk_size = (size_t)get_size(prog_name, &argno, argc, argv); + } + else if ('m' == argv[argno][1]) { dst_size = get_size(prog_name, &argno, argc, argv); - } else { + } + else { usage(prog_name); } /* end if */ - } /* end while */ + } /* end while */ /* allocate names */ - if(NULL == (src_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char)))) + if (NULL == (src_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char)))) HDexit(EXIT_FAILURE); - if(NULL == (dst_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char)))) + if (NULL == (dst_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char)))) HDexit(EXIT_FAILURE); /* @@ -238,7 +243,7 @@ main (int argc, char *argv[]) usage(prog_name); src_gen_name = argv[argno++]; HDsprintf(src_name, src_gen_name, src_membno); - src_is_family = strcmp (src_name, src_gen_name); + src_is_family = strcmp(src_name, src_gen_name); if ((src = HDopen(src_name, O_RDONLY)) < 0) { HDperror(src_name); @@ -256,13 +261,13 @@ main (int argc, char *argv[]) /* * Get the name for the destination file and open the first member. */ - if (argno>=argc) - usage (prog_name); + if (argno >= argc) + usage(prog_name); dst_gen_name = argv[argno++]; HDsprintf(dst_name, dst_gen_name, dst_membno); dst_is_family = HDstrcmp(dst_name, dst_gen_name); - if ((dst = HDopen(dst_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) { + if ((dst = HDopen(dst_name, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) { HDperror(dst_name); HDexit(EXIT_FAILURE); } @@ -271,32 +276,32 @@ main (int argc, char *argv[]) /* No more arguments */ if (argno < argc) - usage (prog_name); + usage(prog_name); /* Now the real work, split the file */ buf = (char *)HDmalloc(blk_size); - while (src_offset src_size) { - HDfprintf(stderr, "%s: member truncated to %lu bytes\n", src_name, (unsigned long) src_size); + HDfprintf(stderr, "%s: member truncated to %lu bytes\n", src_name, (unsigned long)src_size); } src_offset = 0; if (verbose) HDfprintf(stderr, "< %s\n", src_name); } - /* - * Update the destination offset, opening a new member if one will be - * needed. The first member is extended to the logical member size - * but other members might be smaller if they end with a hole. - */ - dst_offset = dst_offset + (off_t) n; + /* + * Update the destination offset, opening a new member if one will be + * needed. The first member is extended to the logical member size + * but other members might be smaller if they end with a hole. + */ + dst_offset = dst_offset + (off_t)n; if (dst_is_family && dst_offset == dst_size) { if (0 == dst_membno) { - if (HDlseek (dst, dst_size-1, SEEK_SET) < 0) { + if (HDlseek(dst, dst_size - 1, SEEK_SET) < 0) { HDperror("HDHDlseek"); HDexit(EXIT_FAILURE); } - if (HDread (dst, buf, 1) < 0) { + if (HDread(dst, buf, 1) < 0) { HDperror("read"); HDexit(EXIT_FAILURE); } - if (HDlseek (dst, dst_size-1, SEEK_SET) < 0) { + if (HDlseek(dst, dst_size - 1, SEEK_SET) < 0) { HDperror("HDlseek"); HDexit(EXIT_FAILURE); } - if (HDwrite (dst, buf, 1) < 0) { + if (HDwrite(dst, buf, 1) < 0) { HDperror("write"); HDexit(EXIT_FAILURE); } @@ -405,7 +410,7 @@ main (int argc, char *argv[]) HDexit(EXIT_FAILURE); } dst_offset = 0; - need_seek = FALSE; + need_seek = FALSE; if (verbose) HDfprintf(stderr, "> %s\n", dst_name); } @@ -417,56 +422,56 @@ main (int argc, char *argv[]) * family has been truncated. */ if (need_seek) { - if (HDlseek (dst, dst_offset-1, SEEK_SET)<0) { - HDperror ("HDlseek"); - HDexit (EXIT_FAILURE); + if (HDlseek(dst, dst_offset - 1, SEEK_SET) < 0) { + HDperror("HDlseek"); + HDexit(EXIT_FAILURE); } - if (HDread (dst, buf, 1)<0) { - HDperror ("read"); - HDexit (EXIT_FAILURE); + if (HDread(dst, buf, 1) < 0) { + HDperror("read"); + HDexit(EXIT_FAILURE); } - if (HDlseek (dst, dst_offset-1, SEEK_SET)<0) { - HDperror ("HDlseek"); - HDexit (EXIT_FAILURE); + if (HDlseek(dst, dst_offset - 1, SEEK_SET) < 0) { + HDperror("HDlseek"); + HDexit(EXIT_FAILURE); } - if (HDwrite (dst, buf, 1)<0) { - HDperror ("write"); - HDexit (EXIT_FAILURE); + if (HDwrite(dst, buf, 1) < 0) { + HDperror("write"); + HDexit(EXIT_FAILURE); } } - HDclose (dst); + HDclose(dst); /* Modify family driver information saved in superblock through private property. * These private properties are for this tool only. */ - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) { - HDperror ("H5Pcreate"); - HDexit (EXIT_FAILURE); + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + HDperror("H5Pcreate"); + HDexit(EXIT_FAILURE); } - if(family_to_single) { + if (family_to_single) { /* The user wants to change file driver from family to a single-file VFD. * Open the file with the sec2, windows, etc. driver. This property signals * the library to ignore the family driver information saved in the superblock. */ - if(H5Pset(fapl, H5F_ACS_FAMILY_TO_SINGLE_NAME, &family_to_single) < 0) { - HDperror ("H5Pset"); - HDexit (EXIT_FAILURE); + if (H5Pset(fapl, H5F_ACS_FAMILY_TO_SINGLE_NAME, &family_to_single) < 0) { + HDperror("H5Pset"); + HDexit(EXIT_FAILURE); } } else { /* Modify family size saved in superblock through private property. It signals * library to save the new member size(specified in command line) in superblock. * This private property is for this tool only. */ - if(H5Pset_fapl_family(fapl, H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) { - HDperror ("H5Pset_fapl_family"); - HDexit (EXIT_FAILURE); + if (H5Pset_fapl_family(fapl, H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) { + HDperror("H5Pset_fapl_family"); + HDexit(EXIT_FAILURE); } /* Set the property of the new member size as hsize_t */ hdsize = (hsize_t)dst_size; - if(H5Pset(fapl, H5F_ACS_FAMILY_NEWSIZE_NAME, &hdsize) < 0) { - HDperror ("H5Pset"); - HDexit (EXIT_FAILURE); + if (H5Pset(fapl, H5F_ACS_FAMILY_NEWSIZE_NAME, &hdsize) < 0) { + HDperror("H5Pset"); + HDexit(EXIT_FAILURE); } } @@ -478,18 +483,20 @@ main (int argc, char *argv[]) * file and the new file can only be a single file, reopen the new file should fail. * There's nothing to do in this case. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file = H5Fopen(dst_gen_name, H5F_ACC_RDWR, fapl); - } H5E_END_TRY; + } + H5E_END_TRY; - if(file >= 0) { - if(H5Fclose(file) < 0) { + if (file >= 0) { + if (H5Fclose(file) < 0) { HDperror("H5Fclose"); HDexit(EXIT_FAILURE); } /* end if */ - } /* end if */ + } /* end if */ - if(H5Pclose(fapl) < 0) { + if (H5Pclose(fapl) < 0) { HDperror("H5Pclose"); HDexit(EXIT_FAILURE); } /* end if */ diff --git a/tools/test/h5copy/dynlib_copy.c b/tools/test/h5copy/dynlib_copy.c index 571452e..97bd1f5 100644 --- a/tools/test/h5copy/dynlib_copy.c +++ b/tools/test/h5copy/dynlib_copy.c @@ -17,25 +17,33 @@ #include #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIBUD, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ + "dynlibud", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*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) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ cd_values = cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp - MULTIPLIER; + *int_ptr = temp - MULTIPLIER; int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp + MULTIPLIER; + *int_ptr = temp + MULTIPLIER; int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/test/h5copy/h5copygentest.c b/tools/test/h5copy/h5copygentest.c index 2a8a575..1327e0f 100644 --- a/tools/test/h5copy/h5copygentest.c +++ b/tools/test/h5copy/h5copygentest.c @@ -18,35 +18,34 @@ #include "H5private.h" /* HDF file names */ -#define HDF_FILE1 "h5copytst.h5" -#define HDF_FILE1_NEW "h5copytst_new.h5" -#define HDF_FILE2 "h5copy_ref.h5" -#define HDF_EXT_SRC_FILE "h5copy_extlinks_src.h5" -#define HDF_EXT_TRG_FILE "h5copy_extlinks_trg.h5" +#define HDF_FILE1 "h5copytst.h5" +#define HDF_FILE1_NEW "h5copytst_new.h5" +#define HDF_FILE2 "h5copy_ref.h5" +#define HDF_EXT_SRC_FILE "h5copy_extlinks_src.h5" +#define HDF_EXT_TRG_FILE "h5copy_extlinks_trg.h5" /* objects in HDF_FILE1 */ -#define DATASET_SIMPLE "simple" -#define DATASET_CHUNK "chunk" -#define DATASET_COMPACT "compact" -#define DATASET_COMPOUND "compound" -#define DATASET_COMPRESSED "compressed" -#define DATASET_NAMED_VL "named_vl" -#define DATASET_NESTED_VL "nested_vl" -#define DATASET_ATTR "dset_attr" -#define ATTR "attr" -#define GROUP_EMPTY "grp_empty" -#define GROUP_DATASETS "grp_dsets" -#define GROUP_NESTED "grp_nested" -#define GROUP_ATTR "grp_attr" +#define DATASET_SIMPLE "simple" +#define DATASET_CHUNK "chunk" +#define DATASET_COMPACT "compact" +#define DATASET_COMPOUND "compound" +#define DATASET_COMPRESSED "compressed" +#define DATASET_NAMED_VL "named_vl" +#define DATASET_NESTED_VL "nested_vl" +#define DATASET_ATTR "dset_attr" +#define ATTR "attr" +#define GROUP_EMPTY "grp_empty" +#define GROUP_DATASETS "grp_dsets" +#define GROUP_NESTED "grp_nested" +#define GROUP_ATTR "grp_attr" /* Obj reference */ -#define OBJ_REF_DS "Dset1" +#define OBJ_REF_DS "Dset1" #define OBJ_REF_GRP "Group" /* Region reference */ #define REG_REF_DS1 "Dset_REGREF" #define REG_REF_DS2 "Dset2" - /*------------------------------------------------------------------------- * Function: gent_simple * @@ -54,11 +53,12 @@ * *------------------------------------------------------------------------- */ -static void gent_simple(hid_t loc_id) +static void +gent_simple(hid_t loc_id) { hid_t sid, did; hsize_t dims[1] = {6}; - int buf[6] = {1,2,3,4,5,6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -81,12 +81,13 @@ static void gent_simple(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_chunked(hid_t loc_id) +static void +gent_chunked(hid_t loc_id) { hid_t sid, did, pid; - hsize_t dims[1] = {6}; + hsize_t dims[1] = {6}; hsize_t chunk_dims[1] = {2}; - int buf[6] = {1,2,3,4,5,6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -107,7 +108,6 @@ static void gent_chunked(hid_t loc_id) H5Pclose(pid); } - /*------------------------------------------------------------------------- * Function: gent_compact * @@ -115,18 +115,19 @@ static void gent_chunked(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_compact(hid_t loc_id) +static void +gent_compact(hid_t loc_id) { hid_t sid, did, pid; hsize_t dims[1] = {6}; - int buf[6] = {1,2,3,4,5,6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); /* create property plist */ pid = H5Pcreate(H5P_DATASET_CREATE); - H5Pset_layout (pid,H5D_COMPACT); + H5Pset_layout(pid, H5D_COMPACT); /* create dataset */ did = H5Dcreate2(loc_id, DATASET_COMPACT, H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT); @@ -140,7 +141,6 @@ static void gent_compact(hid_t loc_id) H5Pclose(pid); } - /*------------------------------------------------------------------------- * Function: gent_compound * @@ -148,10 +148,10 @@ static void gent_compact(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_compound(hid_t loc_id) +static void +gent_compound(hid_t loc_id) { - typedef struct s_t - { + typedef struct s_t { char str1[20]; char str2[20]; } s_t; @@ -167,8 +167,8 @@ static void gent_compound(hid_t loc_id) tid_s = H5Tcopy(H5T_C_S1); H5Tset_size(tid_s, 20); - H5Tinsert(tid_c, "str1", HOFFSET(s_t,str1), tid_s); - H5Tinsert(tid_c, "str2", HOFFSET(s_t,str2), tid_s); + H5Tinsert(tid_c, "str1", HOFFSET(s_t, str1), tid_s); + H5Tinsert(tid_c, "str2", HOFFSET(s_t, str2), tid_s); /* create dataset */ did = H5Dcreate2(loc_id, DATASET_COMPOUND, tid_c, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -190,12 +190,13 @@ static void gent_compound(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_compressed(hid_t loc_id) +static void +gent_compressed(hid_t loc_id) { hid_t sid, did, pid; - hsize_t dims[1] = {6}; + hsize_t dims[1] = {6}; hsize_t chunk_dims[1] = {2}; - int buf[6] = {1,2,3,4,5,6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -205,7 +206,7 @@ static void gent_compressed(hid_t loc_id) H5Pset_chunk(pid, 1, chunk_dims); /* set the deflate filter */ -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) H5Pset_deflate(pid, 1); #endif @@ -221,7 +222,6 @@ static void gent_compressed(hid_t loc_id) H5Pclose(pid); } - /*------------------------------------------------------------------------- * Function: gent_named_vl * @@ -230,20 +230,21 @@ static void gent_compressed(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_named_vl(hid_t loc_id) +static void +gent_named_vl(hid_t loc_id) { hid_t sid, did, tid; hsize_t dims[1] = {2}; hvl_t buf[2]; /* allocate and initialize VL dataset to write */ - buf[0].len = 1; - buf[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf[0].p)[0]=1; - buf[1].len = 2; - buf[1].p = HDmalloc( 2 * sizeof(int)); - ((int *)buf[1].p)[0]=2; - ((int *)buf[1].p)[1]=3; + buf[0].len = 1; + buf[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf[0].p)[0] = 1; + buf[1].len = 2; + buf[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf[1].p)[0] = 2; + ((int *)buf[1].p)[1] = 3; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -261,13 +262,12 @@ static void gent_named_vl(hid_t loc_id) H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); /* close */ - H5Treclaim(tid,sid,H5P_DEFAULT,buf); + H5Treclaim(tid, sid, H5P_DEFAULT, buf); H5Sclose(sid); H5Dclose(did); H5Tclose(tid); } - /*------------------------------------------------------------------------- * Function: gent_nested_vl * @@ -275,28 +275,29 @@ static void gent_named_vl(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_nested_vl(hid_t loc_id) +static void +gent_nested_vl(hid_t loc_id) { hid_t sid, did, tid1, tid2; hsize_t dims[1] = {2}; hvl_t buf[2]; - hvl_t *tvl; + hvl_t * tvl; /* allocate and initialize VL dataset to write */ - buf[0].len = 1; - buf[0].p = HDmalloc( 1 * sizeof(hvl_t)); - tvl = (hvl_t *)buf[0].p; - tvl->p = HDmalloc( 1 * sizeof(int) ); - tvl->len = 1; - ((int *)tvl->p)[0]=1; - - buf[1].len = 1; - buf[1].p = HDmalloc( 1 * sizeof(hvl_t)); - tvl = (hvl_t *)buf[1].p; - tvl->p = HDmalloc( 2 * sizeof(int) ); - tvl->len = 2; - ((int *)tvl->p)[0]=2; - ((int *)tvl->p)[1]=3; + buf[0].len = 1; + buf[0].p = HDmalloc(1 * sizeof(hvl_t)); + tvl = (hvl_t *)buf[0].p; + tvl->p = HDmalloc(1 * sizeof(int)); + tvl->len = 1; + ((int *)tvl->p)[0] = 1; + + buf[1].len = 1; + buf[1].p = HDmalloc(1 * sizeof(hvl_t)); + tvl = (hvl_t *)buf[1].p; + tvl->p = HDmalloc(2 * sizeof(int)); + tvl->len = 2; + ((int *)tvl->p)[0] = 2; + ((int *)tvl->p)[1] = 3; /* create dataspace */ sid = H5Screate_simple(1, dims, NULL); @@ -314,14 +315,13 @@ static void gent_nested_vl(hid_t loc_id) H5Dwrite(did, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); /* close */ - H5Treclaim(tid2,sid,H5P_DEFAULT,buf); + H5Treclaim(tid2, sid, H5P_DEFAULT, buf); H5Sclose(sid); H5Dclose(did); H5Tclose(tid1); H5Tclose(tid2); } - /*------------------------------------------------------------------------- * Function: gent_att_compound_vlstr * @@ -331,22 +331,23 @@ static void gent_nested_vl(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_att_compound_vlstr(hid_t loc_id) +static void +gent_att_compound_vlstr(hid_t loc_id) { typedef struct { /* Compound structure for the attribute */ - int i; + int i; const char *v; } s1; - hsize_t dim[1] = {1}; /* Dimension size */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hid_t tid = H5I_INVALID_HID; /* Datatype ID */ - hid_t aid = H5I_INVALID_HID; /* Attribute ID */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - hid_t vl_str_tid = H5I_INVALID_HID; /* Variable length datatype ID */ - hid_t cmpd_tid = H5I_INVALID_HID; /* Compound datatype ID */ - hid_t null_sid = H5I_INVALID_HID; /* Null dataspace ID */ - s1 buf; /* Buffer */ + hsize_t dim[1] = {1}; /* Dimension size */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t tid = H5I_INVALID_HID; /* Datatype ID */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t vl_str_tid = H5I_INVALID_HID; /* Variable length datatype ID */ + hid_t cmpd_tid = H5I_INVALID_HID; /* Compound datatype ID */ + hid_t null_sid = H5I_INVALID_HID; /* Null dataspace ID */ + s1 buf; /* Buffer */ buf.i = 9; buf.v = "ThisIsAString"; @@ -409,7 +410,8 @@ static void gent_att_compound_vlstr(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_datasets(hid_t loc_id) +static void +gent_datasets(hid_t loc_id) { gent_simple(loc_id); gent_chunked(loc_id); @@ -427,9 +429,10 @@ static void gent_datasets(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_empty_group(hid_t loc_id) +static void +gent_empty_group(hid_t loc_id) { - hid_t gid; + hid_t gid; /* Create group in location */ gid = H5Gcreate2(loc_id, GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -446,9 +449,10 @@ static void gent_empty_group(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_nested_datasets(hid_t loc_id) +static void +gent_nested_datasets(hid_t loc_id) { - hid_t gid; + hid_t gid; /* Create group in location */ gid = H5Gcreate2(loc_id, GROUP_DATASETS, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -468,9 +472,10 @@ static void gent_nested_datasets(hid_t loc_id) * *------------------------------------------------------------------------- */ -static void gent_nested_group(hid_t loc_id) +static void +gent_nested_group(hid_t loc_id) { - hid_t gid; + hid_t gid; /* Create group in location */ gid = H5Gcreate2(loc_id, GROUP_NESTED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -482,7 +487,6 @@ static void gent_nested_group(hid_t loc_id) H5Gclose(gid); } - /*------------------------------------------------------------------------- * Function: gen_obj_ref * @@ -490,41 +494,39 @@ static void gent_nested_group(hid_t loc_id) * * Programmer: Jonathan Kim (Feb 23, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_obj_ref(hid_t loc_id) +static herr_t +gen_obj_ref(hid_t loc_id) { - hid_t sid=0, oid=0; - hsize_t dims1[1]={3}; - hsize_t dims2[1]={2}; - int data[3] = {10,20,30}; - int status; + hid_t sid = 0, oid = 0; + hsize_t dims1[1] = {3}; + hsize_t dims2[1] = {2}; + int data[3] = {10, 20, 30}; + int status; /*--------------------- * create obj references to the previously created objects. * Passing -1 as reference is an object.*/ - hobj_ref_t or_data[2]; /* write buffer */ - herr_t ret = SUCCEED; + hobj_ref_t or_data[2]; /* write buffer */ + herr_t ret = SUCCEED; /*-------------- * add dataset */ sid = H5Screate_simple(1, dims1, NULL); - if (sid < 0) - { + if (sid < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - oid = H5Dcreate2 (loc_id, OBJ_REF_DS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (oid < 0) - { + oid = H5Dcreate2(loc_id, OBJ_REF_DS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid < 0) { HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } status = H5Dwrite(oid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -535,64 +537,57 @@ static herr_t gen_obj_ref(hid_t loc_id) /*-------------- * add group */ - oid = H5Gcreate2 (loc_id, OBJ_REF_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (oid < 0) - { + oid = H5Gcreate2(loc_id, OBJ_REF_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid < 0) { HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } H5Gclose(oid); - status = H5Rcreate (&or_data[0], loc_id, OBJ_REF_DS, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { + status = H5Rcreate(&or_data[0], loc_id, OBJ_REF_DS, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - status = H5Rcreate (&or_data[1], loc_id, OBJ_REF_GRP, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { + status = H5Rcreate(&or_data[1], loc_id, OBJ_REF_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - sid = H5Screate_simple (1, dims2, NULL); - if (sid < 0) - { + sid = H5Screate_simple(1, dims2, NULL); + if (sid < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - oid = H5Dcreate2 (loc_id, "Dset_OBJREF", H5T_STD_REF_OBJ, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid < 0) - { + oid = H5Dcreate2(loc_id, "Dset_OBJREF", H5T_STD_REF_OBJ, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid < 0) { HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } status = H5Dwrite(oid, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, or_data); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: - if(oid > 0) + if (oid > 0) H5Dclose(oid); - if(sid > 0) + if (sid > 0) H5Sclose(sid); return ret; } - /*------------------------------------------------------------------------- * Function: gen_region_ref * @@ -600,107 +595,98 @@ out: * * Programmer: Jonathan Kim (Feb 23, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_region_ref(hid_t loc_id) +static herr_t +gen_region_ref(hid_t loc_id) { - hid_t sid=0, oid1=0, oid2=0; - int status; - herr_t ret = SUCCEED; - char data[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; - hsize_t dims2[2] = {3,16}; - hsize_t coords[4][2] = { {0,1}, {2,11}, {1,0}, {2,4} }; - hdset_reg_ref_t rr_data[2]; - hsize_t start[2] = {0,0}; - hsize_t stride[2] = {2,11}; - hsize_t count[2] = {2,2}; - hsize_t block[2] = {1,3}; - hsize_t dims1[1] = {2}; - - sid = H5Screate_simple (2, dims2, NULL); - if (sid < 0) - { + hid_t sid = 0, oid1 = 0, oid2 = 0; + int status; + herr_t ret = SUCCEED; + char data[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; + hsize_t dims2[2] = {3, 16}; + hsize_t coords[4][2] = {{0, 1}, {2, 11}, {1, 0}, {2, 4}}; + hdset_reg_ref_t rr_data[2]; + hsize_t start[2] = {0, 0}; + hsize_t stride[2] = {2, 11}; + hsize_t count[2] = {2, 2}; + hsize_t block[2] = {1, 3}; + hsize_t dims1[1] = {2}; + + sid = H5Screate_simple(2, dims2, NULL); + if (sid < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create normal dataset which is refered */ - oid2 = H5Dcreate2 (loc_id, REG_REF_DS2, H5T_STD_I8LE, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid2 < 0) - { + oid2 = H5Dcreate2(loc_id, REG_REF_DS2, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid2 < 0) { HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* write values to dataset */ - status = H5Dwrite (oid2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if (status < 0) - { + status = H5Dwrite(oid2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select elements space for reference */ - status = H5Sselect_elements (sid, H5S_SELECT_SET, 4, coords[0]); - if (status < 0) - { + status = H5Sselect_elements(sid, H5S_SELECT_SET, 4, coords[0]); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference from elements space */ - status = H5Rcreate (&rr_data[0], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid); - if (status < 0) - { + status = H5Rcreate(&rr_data[0], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select hyperslab space for reference */ - status = H5Sselect_hyperslab (sid, H5S_SELECT_SET, start, stride, count, block); - if (status < 0) - { + status = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Sselect_hyperslab failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference from hyperslab space */ - status = H5Rcreate (&rr_data[1], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid); - if (status < 0) - { + status = H5Rcreate(&rr_data[1], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - H5Sclose (sid); + H5Sclose(sid); /* Create dataspace. */ - sid = H5Screate_simple (1, dims1, NULL); - if (sid < 0) - { + sid = H5Screate_simple(1, dims1, NULL); + if (sid < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference dataset */ - oid1 = H5Dcreate2 (loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid1 < 0) - { + oid1 = H5Dcreate2(loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid1 < 0) { HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* write data as region references */ - status = H5Dwrite (oid1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data); - if (status < 0) - { + status = H5Dwrite(oid1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -708,11 +694,11 @@ static herr_t gen_region_ref(hid_t loc_id) out: if (oid1 > 0) - H5Dclose (oid1); + H5Dclose(oid1); if (oid2 > 0) - H5Dclose (oid2); + H5Dclose(oid2); if (sid > 0) - H5Sclose (sid); + H5Sclose(sid); return ret; } @@ -723,31 +709,32 @@ out: * Purpose: Testing with various objects * *------------------------------------------------------------------------*/ -static void Test_Obj_Copy(void) +static void +Test_Obj_Copy(void) { - hid_t fid = H5I_INVALID_HID; /* File id */ - hid_t fapl_new = (-1); /* File access property id */ - unsigned new_format; /* New format or old format */ + hid_t fid = H5I_INVALID_HID; /* File id */ + hid_t fapl_new = (-1); /* File access property id */ + unsigned new_format; /* New format or old format */ - if((fapl_new = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + if ((fapl_new = H5Pcreate(H5P_FILE_ACCESS)) < 0) { HDfprintf(stderr, "Error: H5Pcreate failed.\n"); goto out; } - if(H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + if (H5Pset_libver_bounds(fapl_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { HDfprintf(stderr, "Error: H5Pset_libver_bounds failed.\n"); goto out; } /* Test with old & new format groups */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { /* Set the FAPL for the type of format */ /* Create source file */ - if(new_format) + if (new_format) fid = H5Fcreate(HDF_FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_new); else fid = H5Fcreate(HDF_FILE1_NEW, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(fid < 0) { + if (fid < 0) { HDfprintf(stderr, "Error: H5Fcreate failed.\n"); goto out; } @@ -764,11 +751,11 @@ static void Test_Obj_Copy(void) out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ - if(fid > 0) + * Close + *------------------------------------------------------------------------*/ + if (fid > 0) H5Fclose(fid); - if(fapl_new > 0) + if (fapl_new > 0) H5Pclose(fapl_new); } @@ -778,14 +765,14 @@ out: * Purpose: Testing with various references * *------------------------------------------------------------------------*/ -static void Test_Ref_Copy(void) +static void +Test_Ref_Copy(void) { - hid_t fid=0; + hid_t fid = 0; herr_t status; - fid = H5Fcreate (HDF_FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fid < 0) - { + fid = H5Fcreate(HDF_FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (fid < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_FILE2); goto out; } @@ -802,9 +789,9 @@ static void Test_Ref_Copy(void) out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ - if(fid > 0) + * Close + *------------------------------------------------------------------------*/ + if (fid > 0) H5Fclose(fid); } @@ -815,20 +802,20 @@ out: * * Programmer: Jonathan Kim (March 03, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_extlink_trg(hid_t loc_id) +static herr_t +gen_extlink_trg(hid_t loc_id) { - hid_t gid=0, tid=0; - int status; + hid_t gid = 0, tid = 0; + int status; herr_t ret = SUCCEED; /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /*-------------- * target file */ gid = H5Gcreate2(loc_id, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid < 0) - { + if (gid < 0) { HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -836,24 +823,23 @@ static herr_t gen_extlink_trg(hid_t loc_id) /*-------------- * add dataset */ - gent_simple(loc_id); + gent_simple(loc_id); /*-------------------- * add named datatype */ - tid = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(loc_id, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + tid = H5Tcopy(H5T_NATIVE_INT); + status = H5Tcommit2(loc_id, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: - if(gid > 0) + if (gid > 0) H5Gclose(gid); - if(tid > 0) + if (tid > 0) H5Tclose(tid); return ret; @@ -866,30 +852,29 @@ out: * * Programmer: Jonathan Kim (March 03, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_extlink_src(hid_t loc_id) +static herr_t +gen_extlink_src(hid_t loc_id) { - hid_t gid=0; - int status; + hid_t gid = 0; + int status; herr_t ret = SUCCEED; /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid = H5Gcreate2(loc_id, "/group_ext", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid < 0) - { + if (gid < 0) { HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /*----------------------------------------------------------------------- - * External links - *------------------------------------------------------------------------*/ + * External links + *------------------------------------------------------------------------*/ /* link to dataset */ status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/simple", gid, "extlink_dset", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -897,17 +882,16 @@ static herr_t gen_extlink_src(hid_t loc_id) /* link to group */ status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/group", gid, "extlink_grp", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* link to datatype */ - status = H5Lcreate_external(HDF_EXT_TRG_FILE, "/datatype", gid, "extlink_datatype", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + status = + H5Lcreate_external(HDF_EXT_TRG_FILE, "/datatype", gid, "extlink_datatype", H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -915,8 +899,7 @@ static herr_t gen_extlink_src(hid_t loc_id) /* dangling link - no obj*/ status = H5Lcreate_external(HDF_EXT_TRG_FILE, "notyet", gid, "extlink_notyet1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -924,15 +907,14 @@ static herr_t gen_extlink_src(hid_t loc_id) /* dangling link - no file */ status = H5Lcreate_external("notyet_file.h5", "notyet", gid, "extlink_notyet2", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Lcreate_external failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: - if(gid > 0) + if (gid > 0) H5Gclose(gid); return ret; @@ -944,22 +926,21 @@ out: * Purpose: gerenate external link files * *------------------------------------------------------------------------*/ -static void Test_Extlink_Copy(void) +static void +Test_Extlink_Copy(void) { - hid_t fid1=0; - hid_t fid2=0; + hid_t fid1 = 0; + hid_t fid2 = 0; herr_t status; - fid1 = H5Fcreate (HDF_EXT_SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fid1 < 0) - { + fid1 = H5Fcreate(HDF_EXT_SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_EXT_SRC_FILE); goto out; } - fid2 = H5Fcreate (HDF_EXT_TRG_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fid2 < 0) - { + fid2 = H5Fcreate(HDF_EXT_TRG_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (fid2 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_EXT_TRG_FILE); goto out; } @@ -976,11 +957,11 @@ static void Test_Extlink_Copy(void) out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ - if(fid1 > 0) + * Close + *------------------------------------------------------------------------*/ + if (fid1 > 0) H5Fclose(fid1); - if(fid2 > 0) + if (fid2 > 0) H5Fclose(fid2); } @@ -990,7 +971,8 @@ out: *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { Test_Obj_Copy(); Test_Ref_Copy(); @@ -998,4 +980,3 @@ int main(void) return 0; } - diff --git a/tools/test/h5diff/dynlib_diff.c b/tools/test/h5diff/dynlib_diff.c index 661a6dc..32d2daf 100644 --- a/tools/test/h5diff/dynlib_diff.c +++ b/tools/test/h5diff/dynlib_diff.c @@ -17,25 +17,33 @@ #include #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIBUD, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ + "dynlibud", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*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) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ cd_values = cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = (int8_t)(temp - MULTIPLIER); + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = (int8_t)(temp + MULTIPLIER); + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/test/h5diff/h5diffgentest.c b/tools/test/h5diff/h5diffgentest.c index bdc2ddc..2466bc1 100644 --- a/tools/test/h5diff/h5diffgentest.c +++ b/tools/test/h5diff/h5diffgentest.c @@ -38,58 +38,58 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); *------------------------------------------------------------------------- */ -#define FILE1 "h5diff_basic1.h5" -#define FILE2 "h5diff_basic2.h5" -#define FILE3 "h5diff_types.h5" -#define FILE4 "h5diff_dtypes.h5" -#define FILE5 "h5diff_attr1.h5" -#define FILE6 "h5diff_attr2.h5" -#define FILE6a "h5diff_attr3.h5" -#define FILE7 "h5diff_dset1.h5" -#define FILE8 "h5diff_dset2.h5" -#define FILE8A "h5diff_dset3.h5" -#define FILE9 "h5diff_hyper1.h5" -#define FILE10 "h5diff_hyper2.h5" -#define FILE11 "h5diff_empty.h5" -#define FILE12 "h5diff_links.h5" -#define FILE13 "h5diff_softlinks.h5" -#define FILE14 "h5diff_linked_softlink.h5" -#define FILE15 "h5diff_extlink_src.h5" -#define FILE16 "h5diff_extlink_trg.h5" -#define FILE17 "h5diff_ext2softlink_src.h5" -#define FILE18 "h5diff_ext2softlink_trg.h5" -#define FILE19 "h5diff_dset_zero_dim_size1.h5" -#define FILE20 "h5diff_dset_zero_dim_size2.h5" -#define FILE21 "h5diff_dset_idx1.h5" -#define FILE22 "h5diff_dset_idx2.h5" -#define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" -#define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" -#define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" -#define GRP_RECURSE_FILE2 "h5diff_grp_recurse2.h5" +#define FILE1 "h5diff_basic1.h5" +#define FILE2 "h5diff_basic2.h5" +#define FILE3 "h5diff_types.h5" +#define FILE4 "h5diff_dtypes.h5" +#define FILE5 "h5diff_attr1.h5" +#define FILE6 "h5diff_attr2.h5" +#define FILE6a "h5diff_attr3.h5" +#define FILE7 "h5diff_dset1.h5" +#define FILE8 "h5diff_dset2.h5" +#define FILE8A "h5diff_dset3.h5" +#define FILE9 "h5diff_hyper1.h5" +#define FILE10 "h5diff_hyper2.h5" +#define FILE11 "h5diff_empty.h5" +#define FILE12 "h5diff_links.h5" +#define FILE13 "h5diff_softlinks.h5" +#define FILE14 "h5diff_linked_softlink.h5" +#define FILE15 "h5diff_extlink_src.h5" +#define FILE16 "h5diff_extlink_trg.h5" +#define FILE17 "h5diff_ext2softlink_src.h5" +#define FILE18 "h5diff_ext2softlink_trg.h5" +#define FILE19 "h5diff_dset_zero_dim_size1.h5" +#define FILE20 "h5diff_dset_zero_dim_size2.h5" +#define FILE21 "h5diff_dset_idx1.h5" +#define FILE22 "h5diff_dset_idx2.h5" +#define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" +#define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" +#define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" +#define GRP_RECURSE_FILE2 "h5diff_grp_recurse2.h5" /* same structure via external links through files */ -#define GRP_RECURSE1_EXT "h5diff_grp_recurse_ext1.h5" -#define GRP_RECURSE2_EXT1 "h5diff_grp_recurse_ext2-1.h5" -#define GRP_RECURSE2_EXT2 "h5diff_grp_recurse_ext2-2.h5" -#define GRP_RECURSE2_EXT3 "h5diff_grp_recurse_ext2-3.h5" +#define GRP_RECURSE1_EXT "h5diff_grp_recurse_ext1.h5" +#define GRP_RECURSE2_EXT1 "h5diff_grp_recurse_ext2-1.h5" +#define GRP_RECURSE2_EXT2 "h5diff_grp_recurse_ext2-2.h5" +#define GRP_RECURSE2_EXT3 "h5diff_grp_recurse_ext2-3.h5" /* same structure, same obj name with different value */ -#define EXCLUDE_FILE1_1 "h5diff_exclude1-1.h5" -#define EXCLUDE_FILE1_2 "h5diff_exclude1-2.h5" +#define EXCLUDE_FILE1_1 "h5diff_exclude1-1.h5" +#define EXCLUDE_FILE1_2 "h5diff_exclude1-2.h5" /* different structure and obj names */ -#define EXCLUDE_FILE2_1 "h5diff_exclude2-1.h5" -#define EXCLUDE_FILE2_2 "h5diff_exclude2-2.h5" +#define EXCLUDE_FILE2_1 "h5diff_exclude2-1.h5" +#define EXCLUDE_FILE2_2 "h5diff_exclude2-2.h5" /* only one file has unique objs */ -#define EXCLUDE_FILE3_1 "h5diff_exclude3-1.h5" -#define EXCLUDE_FILE3_2 "h5diff_exclude3-2.h5" +#define EXCLUDE_FILE3_1 "h5diff_exclude3-1.h5" +#define EXCLUDE_FILE3_2 "h5diff_exclude3-2.h5" /* compound type with multiple vlen string types */ -#define COMP_VL_STRS_FILE "h5diff_comp_vl_strs.h5" +#define COMP_VL_STRS_FILE "h5diff_comp_vl_strs.h5" /* attribute compre with verbose level */ #define ATTR_VERBOSE_LEVEL_FILE1 "h5diff_attr_v_level1.h5" #define ATTR_VERBOSE_LEVEL_FILE2 "h5diff_attr_v_level2.h5" /* file containing valid/invalid enum value mix */ #define ENUM_INVALID_VALUES "h5diff_enum_invalid_values.h5" /* file with container types (array,vlen) with multiple compounds */ -#define COMPS_COMPLEX1 "compounds_array_vlen1.h5" -#define COMPS_COMPLEX2 "compounds_array_vlen2.h5" +#define COMPS_COMPLEX1 "compounds_array_vlen1.h5" +#define COMPS_COMPLEX2 "compounds_array_vlen2.h5" /* non-comparable dataset and attribute */ #define NON_COMPARBLES1 "non_comparables1.h5" #define NON_COMPARBLES2 "non_comparables2.h5" @@ -102,7 +102,7 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); #define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */ #define STR_SIZE 3 -#define GBLL ((unsigned long long) 1024 * 1024 *1024 ) +#define GBLL ((unsigned long long)1024 * 1024 * 1024) #define MY_LINKCLASS 187 @@ -112,80 +112,82 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); #define SPACE1_DIM2 0 /* Error macros */ -#define AT() HDprintf("ERROR at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); -#define PROGRAM_ERROR do {AT(); goto error;} while(0) +#define AT() HDprintf("ERROR at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); +#define PROGRAM_ERROR \ + do { \ + AT(); \ + goto error; \ + } while (0) /* A UD link traversal function. Shouldn't actually be called. */ static hid_t -UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED hid_t cur_group, - H5_ATTR_UNUSED const void * udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id, - H5_ATTR_UNUSED hid_t dxpl_id) +UD_traverse(H5_ATTR_UNUSED const char *link_name, H5_ATTR_UNUSED hid_t cur_group, + H5_ATTR_UNUSED const void *udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id, + H5_ATTR_UNUSED hid_t dxpl_id) { return -1; } const H5L_class_t UD_link_class[1] = {{ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)MY_LINKCLASS, /* Link type id number */ - "UD link class", /* name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + (H5L_type_t)MY_LINKCLASS, /* Link type id number */ + "UD link class", /* name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; - /*------------------------------------------------------------------------- * prototypes *------------------------------------------------------------------------- */ /* tests called in main() */ -static int test_basic(const char *fname1, const char *fname2, const char *fname3); -static int test_types(const char *fname); -static int test_datatypes(const char *fname); -static int test_attributes(const char *fname, int make_diffs); -static int test_datasets(const char *fname, int make_diffs); -static int test_special_datasets(const char *fname, int make_diffs); -static int test_hyperslab(const char *fname, int make_diffs); -static int test_link_name(const char *fname1); -static int test_soft_links(const char *fname1); -static int test_linked_softlinks(const char *fname1); -static int test_external_links(const char *fname1, const char *fname2); -static int test_ext2soft_links(const char *fname1, const char *fname2); -static int test_dangle_links(const char *fname1, const char *fname2); -static int test_group_recurse(const char *fname1, const char *fname2); -static int test_group_recurse2(void); -static int test_exclude_obj1(const char *fname1, const char *fname2); -static int test_exclude_obj2(const char *fname1, const char *fname2); -static int test_exclude_obj3(const char *fname1, const char *fname2); -static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new); -static int test_attributes_verbose_level(const char *fname1, const char *fname2); -static int test_enums(const char *fname); -static void test_comps_array(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_vlen(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_array_vlen(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_vlen_arry(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); +static int test_basic(const char *fname1, const char *fname2, const char *fname3); +static int test_types(const char *fname); +static int test_datatypes(const char *fname); +static int test_attributes(const char *fname, int make_diffs); +static int test_datasets(const char *fname, int make_diffs); +static int test_special_datasets(const char *fname, int make_diffs); +static int test_hyperslab(const char *fname, int make_diffs); +static int test_link_name(const char *fname1); +static int test_soft_links(const char *fname1); +static int test_linked_softlinks(const char *fname1); +static int test_external_links(const char *fname1, const char *fname2); +static int test_ext2soft_links(const char *fname1, const char *fname2); +static int test_dangle_links(const char *fname1, const char *fname2); +static int test_group_recurse(const char *fname1, const char *fname2); +static int test_group_recurse2(void); +static int test_exclude_obj1(const char *fname1, const char *fname2); +static int test_exclude_obj2(const char *fname1, const char *fname2); +static int test_exclude_obj3(const char *fname1, const char *fname2); +static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new); +static int test_attributes_verbose_level(const char *fname1, const char *fname2); +static int test_enums(const char *fname); +static void test_comps_array(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); +static void test_comps_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new); +static void test_comps_array_vlen(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); +static void test_comps_vlen_arry(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); static void test_data_nocomparables(const char *fname, int diff); static void test_objs_nocomparables(const char *fname1, const char *fname2); static void test_objs_strings(const char *fname, const char *fname2); static void test_double_epsilon(const char *fname1, const char *fname2); /* called by test_attributes() and test_datasets() */ -static void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); -static void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); -static void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); +static void write_attr_strings(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); +static void write_attr_in(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); +static void write_dset_in(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); static void gen_datareg(hid_t fid, int make_diffs); /* utilities */ -static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); +static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); static herr_t write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); -static int gen_dataset_idx(const char *file, int format); +static int gen_dataset_idx(const char *file, int format); /*------------------------------------------------------------------------- * Function: main @@ -195,7 +197,8 @@ static int gen_dataset_idx(const char *file, int format); *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { test_basic(FILE1, FILE2, FILE11); @@ -235,11 +238,11 @@ int main(void) test_special_datasets(FILE20, 1); /* - * Generate 2 files: FILE21 with old format; FILE22 with new format - * Create 2 datasets in each file: - * One dataset: chunked layout, w/o filters, fixed dimension - * One dataset: chunked layout, w/ filters, fixed dimension - */ + * Generate 2 files: FILE21 with old format; FILE22 with new format + * Create 2 datasets in each file: + * One dataset: chunked layout, w/o filters, fixed dimension + * One dataset: chunked layout, w/ filters, fixed dimension + */ gen_dataset_idx(FILE21, 0); gen_dataset_idx(FILE22, 1); @@ -257,16 +260,16 @@ int main(void) test_comp_vlen_strings(COMP_VL_STRS_FILE, "group_copy", 0); /* diff when invalid enum values are present. - * This will probably grow to involve more extensive testing of - * enums so it has been given its own test file and test (apart - * from the basic type testing). - */ + * This will probably grow to involve more extensive testing of + * enums so it has been given its own test file and test (apart + * from the basic type testing). + */ test_enums(ENUM_INVALID_VALUES); /* ------------------------------------------------- - * Create test files with dataset and attribute with container types - * (array, vlen) with multiple nested compound types. - */ + * Create test files with dataset and attribute with container types + * (array, vlen) with multiple nested compound types. + */ /* file1 */ test_comps_array(COMPS_COMPLEX1, "dset1", "attr1", 0, 1); test_comps_vlen(COMPS_COMPLEX1, "dset2", "attr2", 0, 0); @@ -279,10 +282,10 @@ int main(void) test_comps_vlen_arry(COMPS_COMPLEX2, "dset4", "attr4", 5, 0); /*------------------------------------------------- - * Create test files with non-comparable dataset and attributes with - * comparable datasets and attributes. All the comparables should display - * differences. - */ + * Create test files with non-comparable dataset and attributes with + * comparable datasets and attributes. All the comparables should display + * differences. + */ test_data_nocomparables(NON_COMPARBLES1, 0); test_data_nocomparables(NON_COMPARBLES2, 5); @@ -307,13 +310,13 @@ int main(void) *------------------------------------------------------------------------- */ -static -int test_basic(const char *fname1, const char *fname2, const char *fname3) +static int +test_basic(const char *fname1, const char *fname2, const char *fname3) { - hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID, gid2 = H5I_INVALID_HID, gid3 = H5I_INVALID_HID; - hsize_t dims1[1] = { 6 }; - hsize_t dims2[2] = { 3, 2 }; + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID, gid2 = H5I_INVALID_HID, gid3 = H5I_INVALID_HID; + hsize_t dims1[1] = {6}; + hsize_t dims2[2] = {3, 2}; /* create the empty file */ if ((fid1 = H5Fcreate(fname3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { @@ -326,9 +329,9 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) } /*------------------------------------------------------------------------- - * create two files - *------------------------------------------------------------------------- - */ + * create two files + *------------------------------------------------------------------------- + */ if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; @@ -336,156 +339,141 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) goto out; /*------------------------------------------------------------------------- - * create groups - *------------------------------------------------------------------------- - */ + * create groups + *------------------------------------------------------------------------- + */ gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid2 = H5Gcreate2(fid2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid3 = H5Gcreate2(fid2, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * tests: - * # 1.1 normal mode - * # 1.2 normal mode with objects - * # 1.3 report mode - * # 1.4 report mode with objects - * # 1.5 with -d - *------------------------------------------------------------------------- - */ + * tests: + * # 1.1 normal mode + * # 1.2 normal mode with objects + * # 1.3 report mode + * # 1.4 report mode with objects + * # 1.5 with -d + *------------------------------------------------------------------------- + */ { - double data1[3][2] = - { { 1.0F, 1.0F }, { 1.00F, 1.000F }, { 0.0F, 0.0F } }; - double data2[3][2] = - { { 0.0F, 1.1F }, { 1.01F, 1.001F }, { 0.0F, 1.0F } }; - double data3[3][2] = { { 100.0F, 100.0F }, { 100.00F, 100.000F }, { - 100.0F, 100.0F } }; - double data4[3][2] = { { 105.0F, 120.0F }, { 160.00F, 95.000F }, { - 80.0F, 40.0F } }; + double data1[3][2] = {{1.0F, 1.0F}, {1.00F, 1.000F}, {0.0F, 0.0F}}; + double data2[3][2] = {{0.0F, 1.1F}, {1.01F, 1.001F}, {0.0F, 1.0F}}; + double data3[3][2] = {{100.0F, 100.0F}, {100.00F, 100.000F}, {100.0F, 100.0F}}; + double data4[3][2] = {{105.0F, 120.0F}, {160.00F, 95.000F}, {80.0F, 40.0F}}; write_dset(gid1, 2, dims2, "dset1", H5T_NATIVE_DOUBLE, data1); write_dset(gid2, 2, dims2, "dset2", H5T_NATIVE_DOUBLE, data2); write_dset(gid1, 2, dims2, "dset3", H5T_NATIVE_DOUBLE, data3); write_dset(gid2, 2, dims2, "dset4", H5T_NATIVE_DOUBLE, data4); write_dset(gid2, 2, dims2, "dset1", H5T_NATIVE_DOUBLE, data2); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.1 with -p (int) - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.1 with -p (int) + *------------------------------------------------------------------------- + */ { - int data5[3][2] = { { 100, 100 }, { 100, 0 }, { 0, 100 } }; - int data6[3][2] = { { 120, 80 }, { 0, 100 }, { 0, 50 } }; + int data5[3][2] = {{100, 100}, {100, 0}, {0, 100}}; + int data6[3][2] = {{120, 80}, {0, 100}, {0, 50}}; write_dset(gid1, 2, dims2, "dset5", H5T_NATIVE_INT, data5); write_dset(gid1, 2, dims2, "dset6", H5T_NATIVE_INT, data6); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.2 with -p (unsigned long long) - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.2 with -p (unsigned long long) + *------------------------------------------------------------------------- + */ { - unsigned long long data7[3][2] = - { { 100, 100 }, { 100, 0 }, { 0, 100 } }; - unsigned long long data8[3][2] = { { 120, 80 }, { 0, 100 }, { 0, 50 } }; + unsigned long long data7[3][2] = {{100, 100}, {100, 0}, {0, 100}}; + unsigned long long data8[3][2] = {{120, 80}, {0, 100}, {0, 50}}; write_dset(gid1, 2, dims2, "dset7", H5T_NATIVE_ULLONG, data7); write_dset(gid1, 2, dims2, "dset8", H5T_NATIVE_ULLONG, data8); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.3 with -p (double) - * - * A B 1-B/A % - * 100 120 0.2 20 - * 100 80 0.2 20 - * 100 0 1 100 - * 0 100 #DIV/0! #DIV/0! - * 0 0 #DIV/0! #DIV/0! - * 100 50 0.5 50 - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.3 with -p (double) + * + * A B 1-B/A % + * 100 120 0.2 20 + * 100 80 0.2 20 + * 100 0 1 100 + * 0 100 #DIV/0! #DIV/0! + * 0 0 #DIV/0! #DIV/0! + * 100 50 0.5 50 + *------------------------------------------------------------------------- + */ { - double data9[3][2] = { { 100.0F, 100.0F }, { 100.0F, 0.0F }, { 0.0F, - 100.0F } }; - double data10[3][2] = { { 120.0F, 80.0F }, { 0.0F, 100.0F }, { 0.0F, - 50.0F } }; + double data9[3][2] = {{100.0F, 100.0F}, {100.0F, 0.0F}, {0.0F, 100.0F}}; + double data10[3][2] = {{120.0F, 80.0F}, {0.0F, 100.0F}, {0.0F, 50.0F}}; write_dset(gid1, 2, dims2, "dset9", H5T_NATIVE_DOUBLE, data9); write_dset(gid1, 2, dims2, "dset10", H5T_NATIVE_DOUBLE, data10); - } /*------------------------------------------------------------------------- - * test floating point comparison - *------------------------------------------------------------------------- - */ + * test floating point comparison + *------------------------------------------------------------------------- + */ { /* epsilon = 0.0000001 = 1e-7 - * system epsilon for float : FLT_EPSILON = 1.19209E-07 - */ - float data11[3][2] = { { 0.000000f, 0.0000001f }, { 0.0000001f, - 0.00000022f }, { 0.0000001f, 0.0000001f } }; - float data12[3][2] = { { 0.000000f, 0.0000002f }, { 0.0000003f, - 0.0000001f }, { 0.000000f, 0.0000001f } }; + * system epsilon for float : FLT_EPSILON = 1.19209E-07 + */ + float data11[3][2] = {{0.000000f, 0.0000001f}, {0.0000001f, 0.00000022f}, {0.0000001f, 0.0000001f}}; + float data12[3][2] = {{0.000000f, 0.0000002f}, {0.0000003f, 0.0000001f}, {0.000000f, 0.0000001f}}; /* epsilon = 0.0000000000000001 = 1e-16 - * system epsilon for double : DBL_EPSILON = 2.22045E-16 - */ - double data13[3][2] = { { 0.0000000000000000, 0.0000000000000001 }, - { 0.0000000000000001, 0.0000000000000000 }, - { 0.00000000000000033, 0.0000000000000001 } }; - double data14[3][2] = { { 0.0000000000000000, 0.0000000000000004 }, - { 0.0000000000000002, 0.0000000000000001 }, - { 0.0000000000000001, 0.00000000000000000 } }; + * system epsilon for double : DBL_EPSILON = 2.22045E-16 + */ + double data13[3][2] = {{0.0000000000000000, 0.0000000000000001}, + {0.0000000000000001, 0.0000000000000000}, + {0.00000000000000033, 0.0000000000000001}}; + double data14[3][2] = {{0.0000000000000000, 0.0000000000000004}, + {0.0000000000000002, 0.0000000000000001}, + {0.0000000000000001, 0.00000000000000000}}; write_dset(gid1, 2, dims2, "fp1", H5T_NATIVE_FLOAT, data11); write_dset(gid1, 2, dims2, "fp2", H5T_NATIVE_FLOAT, data12); write_dset(gid1, 2, dims2, "d1", H5T_NATIVE_DOUBLE, data13); write_dset(gid1, 2, dims2, "d2", H5T_NATIVE_DOUBLE, data14); - } -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 { /*------------------------------------------------------------------------- - * H5T_NATIVE_LDOUBLE - *------------------------------------------------------------------------- - */ - - long double data15[3][2] = { {1.0L,1.0L}, {1.0L,1.0L}, {1.0L,1.0L}}; + * H5T_NATIVE_LDOUBLE + *------------------------------------------------------------------------- + */ - write_dset(gid1,2,dims2,"ld",H5T_NATIVE_LDOUBLE,data15); + long double data15[3][2] = {{1.0L, 1.0L}, {1.0L, 1.0L}, {1.0L, 1.0L}}; + write_dset(gid1, 2, dims2, "ld", H5T_NATIVE_LDOUBLE, data15); } #endif /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_FLOAT - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ { float data15[6]; float data16[6]; - data15[0] = (float) HDsqrt(-1.0F); + data15[0] = (float)HDsqrt(-1.0F); data15[1] = 1.0F; - data15[2] = (float) HDsqrt(-1.0F); + data15[2] = (float)HDsqrt(-1.0F); data15[3] = 1.0F; data15[4] = 1.0F; data15[5] = 1.0F; - data16[0] = (float) HDsqrt(-1.0F); - data16[1] = (float) HDsqrt(-1.0F); + data16[0] = (float)HDsqrt(-1.0F); + data16[1] = (float)HDsqrt(-1.0F); data16[2] = 1.0F; data16[3] = 1.0F; data16[4] = 1.0F; @@ -493,13 +481,12 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) write_dset(gid1, 1, dims1, "fp15", H5T_NATIVE_FLOAT, data15); write_dset(gid1, 1, dims1, "fp16", H5T_NATIVE_FLOAT, data16); - } /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_DOUBLE - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ { double data17[6]; @@ -525,15 +512,15 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) } /*------------------------------------------------------------------------ - * INFINITY values - *------------------------------------------------------------------------ - */ + * INFINITY values + *------------------------------------------------------------------------ + */ { - float data19[6]; + float data19[6]; double data20[6]; - data19[0] = data19[1] = data19[2] = (float) HDlog(0.0F); - data19[3] = data19[4] = data19[5] = (float) -HDlog(0.0F); + data19[0] = data19[1] = data19[2] = (float)HDlog(0.0F); + data19[3] = data19[4] = data19[5] = (float)-HDlog(0.0F); data20[0] = data20[1] = data20[2] = HDlog(0.0F); data20[3] = data20[4] = data20[5] = -HDlog(0.0F); @@ -545,39 +532,38 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) } /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_DOUBLE and H5T_NATIVE_FLOAT inside H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_DOUBLE and H5T_NATIVE_FLOAT inside H5T_COMPOUND + *------------------------------------------------------------------------- + */ { typedef struct cmp1_t { double d; - float f; + float f; } cmp1_t; - cmp1_t buf1[2]; - cmp1_t buf2[2]; - hsize_t dims[1] = { 2 }; - size_t type_size; - hid_t tid; + cmp1_t buf1[2]; + cmp1_t buf2[2]; + hsize_t dims[1] = {2}; + size_t type_size; + hid_t tid; buf1[0].d = HDsqrt(-1.0F); - buf1[0].f = (float) HDsqrt(-1.0F); + buf1[0].f = (float)HDsqrt(-1.0F); buf2[0].d = HDsqrt(-1.0F); - buf2[0].f = (float) HDsqrt(-1.0F); + buf2[0].f = (float)HDsqrt(-1.0F); buf1[1].d = HDsqrt(-1.0F); - buf1[1].f = (float) HDsqrt(-1.0F); + buf1[1].f = (float)HDsqrt(-1.0F); buf2[1].d = 0.0F; buf2[1].f = 0.0F; type_size = sizeof(cmp1_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "d", HOFFSET(cmp1_t, d), H5T_NATIVE_DOUBLE); H5Tinsert(tid, "f", HOFFSET(cmp1_t, f), H5T_NATIVE_FLOAT); write_dset(gid1, 1, dims, "dset11", tid, buf1); write_dset(gid1, 1, dims, "dset12", tid, buf2); H5Tclose(tid); - } /* not comparable objects */ @@ -585,11 +571,11 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) typedef struct cmp1_t { double d; - int i; + int i; } cmp1_t; typedef struct cmp2_t { - int i; + int i; double d; } cmp2_t; @@ -597,17 +583,17 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) int i; } cmp3_t; - double data2[6] = { 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F }; - int data3[6] = { 0, 0, 0, 0, 0, 0 }; - int data4[3][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data5[2][2] = { { 0, 0 }, { 0, 0 } }; - unsigned int data6[3][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; - cmp1_t data7[1] = { { 1.0f, 2 } }; - cmp2_t data8[1] = { { 1, 2.0f } }; - hsize_t dims3[2] = { 2, 2 }; - hsize_t dims4[1] = { 1 }; - size_t type_size; - hid_t tid; + double data2[6] = {0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F}; + int data3[6] = {0, 0, 0, 0, 0, 0}; + int data4[3][2] = {{0, 0}, {0, 0}, {0, 0}}; + int data5[2][2] = {{0, 0}, {0, 0}}; + unsigned int data6[3][2] = {{0, 0}, {0, 0}, {0, 0}}; + cmp1_t data7[1] = {{1.0f, 2}}; + cmp2_t data8[1] = {{1, 2.0f}}; + hsize_t dims3[2] = {2, 2}; + hsize_t dims4[1] = {1}; + size_t type_size; + hid_t tid; write_dset(gid3, 1, dims1, "dset1", H5T_NATIVE_DOUBLE, NULL); write_dset(gid3, 1, dims1, "dset2", H5T_NATIVE_DOUBLE, data2); @@ -618,14 +604,14 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) /* case of compound with different type members */ type_size = sizeof(cmp1_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "d", HOFFSET(cmp1_t, d), H5T_NATIVE_DOUBLE); H5Tinsert(tid, "i", HOFFSET(cmp1_t, i), H5T_NATIVE_INT); write_dset(gid3, 1, dims4, "dset7", tid, data7); H5Tclose(tid); type_size = sizeof(cmp2_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "i", HOFFSET(cmp2_t, i), H5T_NATIVE_INT); H5Tinsert(tid, "d", HOFFSET(cmp2_t, d), H5T_NATIVE_DOUBLE); write_dset(gid3, 1, dims4, "dset8", tid, data8); @@ -633,17 +619,16 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) /* case of compound with different number of members */ type_size = sizeof(cmp3_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "i", HOFFSET(cmp2_t, i), H5T_NATIVE_INT); write_dset(gid3, 1, dims4, "dset9", tid, NULL); H5Tclose(tid); - } /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + * close + *------------------------------------------------------------------------- + */ H5Gclose(gid1); H5Gclose(gid2); H5Gclose(gid3); @@ -664,18 +649,18 @@ out: * *------------------------------------------------------------------------- */ -static -int test_types(const char *fname) +static int +test_types(const char *fname) { - hid_t fid1 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; - hid_t tid1 = H5I_INVALID_HID; - hid_t tid2 = H5I_INVALID_HID; - herr_t status; - hsize_t dims[1] = { 1 }; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t tid1 = H5I_INVALID_HID; + hid_t tid2 = H5I_INVALID_HID; + herr_t status; + hsize_t dims[1] = {1}; typedef struct s1_t { - int a; + int a; float b; } s1_t; typedef struct s2_t { @@ -683,30 +668,30 @@ int test_types(const char *fname) } s2_t; /*------------------------------------------------------------------------- - * Create one file - *------------------------------------------------------------------------- - */ + * Create one file + *------------------------------------------------------------------------- + */ fid1 = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ + * H5G_DATASET + *------------------------------------------------------------------------- + */ write_dset(fid1, 1, dims, "dset", H5T_NATIVE_INT, 0); /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * H5G_GROUP + *------------------------------------------------------------------------- + */ + gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Gclose(gid1); - gid2 = H5Gcreate2(fid1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid2 = H5Gcreate2(fid1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Gclose(gid2); /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ + * H5G_TYPE + *------------------------------------------------------------------------- + */ /* create and commit datatype 1 */ tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); @@ -721,25 +706,25 @@ int test_types(const char *fname) H5Tclose(tid2); /*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ + * H5G_LINK + *------------------------------------------------------------------------- + */ status = H5Lcreate_soft("g1", fid1, "l1", H5P_DEFAULT, H5P_DEFAULT); status = H5Lcreate_soft("g2", fid1, "l2", H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * H5G_UDLINK - *------------------------------------------------------------------------- - */ + * H5G_UDLINK + *------------------------------------------------------------------------- + */ H5Lcreate_external("filename", "objname", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT); H5Lregister(UD_link_class); - H5Lcreate_ud(fid1, "ud_link", (H5L_type_t) MY_LINKCLASS, NULL, (size_t) 0, H5P_DEFAULT, H5P_DEFAULT); + H5Lcreate_ud(fid1, "ud_link", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------- - */ + * Close + *------------------------------------------------------------------------- + */ status = H5Fclose(fid1); return status; } @@ -789,138 +774,138 @@ int test_types(const char *fname) * *------------------------------------------------------------------------- */ -static -int test_datatypes(const char *fname) +static int +test_datatypes(const char *fname) { - hid_t fid1 = H5I_INVALID_HID; - hid_t dset = H5I_INVALID_HID; - hsize_t dims[2] = { 3, 2 }; - herr_t status; - char buf1a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - char buf1b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - short buf2a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - short buf2b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - int buf3a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - int buf3b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - long buf4a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - long buf4b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - float buf5a[3][2] = { { 1.0F, 1.0F }, { 1.0F, 1.0F }, { 1.0F, 1.0F } }; - float buf5b[3][2] = { { 1.0F, 1.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; - double buf6a[3][2] = { { 1.0F, 1.0F }, { 1.0F, 1.0F }, { 1.0F, 1.0F } }; - double buf6b[3][2] = { { 1.0F, 1.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; + hid_t fid1 = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; + hsize_t dims[2] = {3, 2}; + herr_t status; + char buf1a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + char buf1b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + short buf2a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + short buf2b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + int buf3a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + int buf3b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + long buf4a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + long buf4b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + float buf5a[3][2] = {{1.0F, 1.0F}, {1.0F, 1.0F}, {1.0F, 1.0F}}; + float buf5b[3][2] = {{1.0F, 1.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; + double buf6a[3][2] = {{1.0F, 1.0F}, {1.0F, 1.0F}, {1.0F, 1.0F}}; + double buf6b[3][2] = {{1.0F, 1.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; /*unsigned/signed test signed char -128 to 127 unsigned char 0 to 255 */ - char buf7a[3][2] = { { -1, -128 }, { -1, -1 }, { -1, -1 } }; - unsigned char buf7b[3][2] = { { 1, 128 }, { 1, 1 }, { 1, 1 } }; + char buf7a[3][2] = {{-1, -128}, {-1, -1}, {-1, -1}}; + unsigned char buf7b[3][2] = {{1, 128}, {1, 1}, {1, 1}}; /* long long test */ - long long buf8a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - long long buf8b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - unsigned long long buf9a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - unsigned long long buf9b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; + long long buf8a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + long long buf8b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + unsigned long long buf9a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + unsigned long long buf9b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; - unsigned int buf10a[3][2] = { { UIMAX, 1 }, { 1, 1 }, { 1, 1 } }; - unsigned int buf10b[3][2] = { { UIMAX - 1, 1 }, { 3, 4 }, { 5, 6 } }; + unsigned int buf10a[3][2] = {{UIMAX, 1}, {1, 1}, {1, 1}}; + unsigned int buf10b[3][2] = {{UIMAX - 1, 1}, {3, 4}, {5, 6}}; - unsigned short buf11a[3][2] = { { 204, 205 }, { 2, 3 }, { 1, 1 } }; - unsigned int buf11b[3][2] = { { 204, 205 }, { 2, 3 }, { 1, 1 } }; + unsigned short buf11a[3][2] = {{204, 205}, {2, 3}, {1, 1}}; + unsigned int buf11b[3][2] = {{204, 205}, {2, 3}, {1, 1}}; /*------------------------------------------------------------------------- - * Create a file - *------------------------------------------------------------------------- - */ + * Create a file + *------------------------------------------------------------------------- + */ fid1 = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * Check for different storage order. Give a warning if they are different - *------------------------------------------------------------------------- - */ + * Check for different storage order. Give a warning if they are different + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset0a", H5T_STD_I16LE, buf2a); write_dset(fid1, 2, dims, "dset0b", H5T_STD_I32LE, buf3b); /*------------------------------------------------------------------------- - * H5T_NATIVE_CHAR - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_CHAR + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset1a", H5T_NATIVE_CHAR, buf1a); write_dset(fid1, 2, dims, "dset1b", H5T_NATIVE_CHAR, buf1b); /*------------------------------------------------------------------------- - * H5T_NATIVE_SHORT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_SHORT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset2a", H5T_NATIVE_SHORT, buf2a); write_dset(fid1, 2, dims, "dset2b", H5T_NATIVE_SHORT, buf2b); /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset3a", H5T_NATIVE_INT, buf3a); write_dset(fid1, 2, dims, "dset3b", H5T_NATIVE_INT, buf3b); /*------------------------------------------------------------------------- - * H5T_NATIVE_LONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_LONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset4a", H5T_NATIVE_LONG, buf4a); write_dset(fid1, 2, dims, "dset4b", H5T_NATIVE_LONG, buf4b); /*------------------------------------------------------------------------- - * H5T_NATIVE_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset5a", H5T_NATIVE_FLOAT, buf5a); write_dset(fid1, 2, dims, "dset5b", H5T_NATIVE_FLOAT, buf5b); /*------------------------------------------------------------------------- - * H5T_NATIVE_DOUBLE - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset6a", H5T_NATIVE_DOUBLE, buf6a); write_dset(fid1, 2, dims, "dset6b", H5T_NATIVE_DOUBLE, buf6b); /*------------------------------------------------------------------------- - * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset7a", H5T_NATIVE_CHAR, buf7a); write_dset(fid1, 2, dims, "dset7b", H5T_NATIVE_UCHAR, buf7b); /*------------------------------------------------------------------------- - * H5T_NATIVE_LLONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_LLONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset8a", H5T_NATIVE_LLONG, buf8a); write_dset(fid1, 2, dims, "dset8b", H5T_NATIVE_LLONG, buf8b); /*------------------------------------------------------------------------- - * H5T_NATIVE_ULLONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_ULLONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset9a", H5T_NATIVE_ULLONG, buf9a); write_dset(fid1, 2, dims, "dset9b", H5T_NATIVE_ULLONG, buf9b); /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset10a", H5T_NATIVE_UINT, buf10a); write_dset(fid1, 2, dims, "dset10b", H5T_NATIVE_UINT, buf10b); /*------------------------------------------------------------------------- - * Same type class, different size - *------------------------------------------------------------------------- - */ + * Same type class, different size + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset11a", H5T_STD_U16LE, buf11a); dset = H5Dopen2(fid1, "dset11a", H5P_DEFAULT); write_attr(dset, 2, dims, "attr", H5T_STD_U16LE, buf11a); @@ -932,9 +917,9 @@ int test_datatypes(const char *fname) H5Dclose(dset); /*------------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------- - */ + * Close + *------------------------------------------------------------------------- + */ status = H5Fclose(fid1); return status; } @@ -979,44 +964,44 @@ int test_datatypes(const char *fname) * *------------------------------------------------------------------------- */ -static -int test_attributes(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_attributes(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t root_id = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hsize_t dims[1] = { 2 }; - herr_t status; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t root_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims[1] = {2}; + herr_t status; /* Create a file */ if ((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; /* Create a 1D dataset */ - sid = H5Screate_simple(1, dims, NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Sclose(sid); assert(status >= 0); /* Create groups */ - gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); root_id = H5Gopen2(fid, "/", H5P_DEFAULT); /*------------------------------------------------------------------------- - * write a series of attributes on the dataset, group, and root group - *------------------------------------------------------------------------- - */ + * write a series of attributes on the dataset, group, and root group + *------------------------------------------------------------------------- + */ if (make_diffs > 1) { write_attr_strings(did, "dset", fid, make_diffs); - write_attr_strings(gid, NULL, (hid_t) 0, make_diffs); - write_attr_strings(root_id, NULL, (hid_t) 0, make_diffs); + write_attr_strings(gid, NULL, (hid_t)0, make_diffs); + write_attr_strings(root_id, NULL, (hid_t)0, make_diffs); } else { write_attr_in(did, "dset", fid, make_diffs); - write_attr_in(gid, NULL, (hid_t) 0, make_diffs); - write_attr_in(root_id, NULL, (hid_t) 0, make_diffs); + write_attr_in(gid, NULL, (hid_t)0, make_diffs); + write_attr_in(root_id, NULL, (hid_t)0, make_diffs); } /* Close */ @@ -1041,34 +1026,35 @@ int test_attributes(const char *file, int make_diffs /* flag to modify data buff * *------------------------------------------------------------------------- */ -static int test_attributes_verbose_level(const char *fname1, const char *fname2) +static int +test_attributes_verbose_level(const char *fname1, const char *fname2) { herr_t status = SUCCEED; - hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; - hid_t f1_gid = H5I_INVALID_HID, f2_gid = H5I_INVALID_HID; - hid_t f1_gid2 = H5I_INVALID_HID, f2_gid2 = H5I_INVALID_HID; - hid_t f1_gid3 = H5I_INVALID_HID, f2_gid3 = H5I_INVALID_HID; - hid_t f1_gid4 = H5I_INVALID_HID, f2_gid4 = H5I_INVALID_HID; - hid_t f1_did = H5I_INVALID_HID, f2_did = H5I_INVALID_HID; - hid_t f1_sid = H5I_INVALID_HID, f2_sid = H5I_INVALID_HID; - hid_t f1_tid = H5I_INVALID_HID, f2_tid = H5I_INVALID_HID; + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; + hid_t f1_gid = H5I_INVALID_HID, f2_gid = H5I_INVALID_HID; + hid_t f1_gid2 = H5I_INVALID_HID, f2_gid2 = H5I_INVALID_HID; + hid_t f1_gid3 = H5I_INVALID_HID, f2_gid3 = H5I_INVALID_HID; + hid_t f1_gid4 = H5I_INVALID_HID, f2_gid4 = H5I_INVALID_HID; + hid_t f1_did = H5I_INVALID_HID, f2_did = H5I_INVALID_HID; + hid_t f1_sid = H5I_INVALID_HID, f2_sid = H5I_INVALID_HID; + hid_t f1_tid = H5I_INVALID_HID, f2_tid = H5I_INVALID_HID; /* dset */ - hsize_t dset_dims[1] = { 3 }; - int dset_data[3] = { 0, 1, 2 }; + hsize_t dset_dims[1] = {3}; + int dset_data[3] = {0, 1, 2}; /* common attrs dim */ - hsize_t attr_dims[1] = { 2 }; + hsize_t attr_dims[1] = {2}; /* file1 attr */ - int f1_attr_idata[2] = { 1, 2 }; /* integer */ - float f1_attr_fdata[2] = { 1.1F, 2.2F }; /* float */ + int f1_attr_idata[2] = {1, 2}; /* integer */ + float f1_attr_fdata[2] = {1.1F, 2.2F}; /* float */ /* file2 attr */ - int f2_attr_idata[2] = { 2, 3 }; /* integer */ - float f2_attr_fdata[2] = { 2.1F, 3.2F }; /* float */ + int f2_attr_idata[2] = {2, 3}; /* integer */ + float f2_attr_fdata[2] = {2.1F, 3.2F}; /* float */ /*---------------------------------------------------------------------- - * Create file1 - *-----------------------------------------------------------------------*/ + * Create file1 + *-----------------------------------------------------------------------*/ if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; @@ -1076,8 +1062,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Groups - */ + * Groups + */ f1_gid = H5Gcreate2(fid1, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_gid < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -1107,8 +1093,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Datasets - */ + * Datasets + */ f1_sid = H5Screate_simple(1, dset_dims, NULL); f1_did = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, f1_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_did == FAIL) { @@ -1124,8 +1110,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Named Datatype - */ + * Named Datatype + */ f1_tid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(fid1, "ntype", f1_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -1135,8 +1121,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------------------------------------------- - * Create file2 - *-----------------------------------------------------------------------*/ + * Create file2 + *-----------------------------------------------------------------------*/ if ((fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; @@ -1144,8 +1130,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Groups - */ + * Groups + */ f2_gid = H5Gcreate2(fid2, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_gid < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); @@ -1175,8 +1161,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Datasets - */ + * Datasets + */ f2_sid = H5Screate_simple(1, dset_dims, NULL); f2_did = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, f2_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_did == FAIL) { @@ -1192,8 +1178,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * Named Datatype - */ + * Named Datatype + */ f2_tid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(fid2, "ntype", f2_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -1203,9 +1189,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) } /*---------------------------------- - * CASE1 - Same attr number, all Same attr name - * add attr to group - */ + * CASE1 - Same attr number, all Same attr name + * add attr to group + */ write_attr(f1_gid, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid, 1, attr_dims, "float1", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1213,9 +1199,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_gid, 1, attr_dims, "float1", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE2 - Same attr number, some Same attr name - * add attr to dset - */ + * CASE2 - Same attr number, some Same attr name + * add attr to dset + */ write_attr(f1_did, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_did, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1223,9 +1209,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_did, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE3 - Same attr number, all different attr name - * add attr to ntype - */ + * CASE3 - Same attr number, all different attr name + * add attr to ntype + */ write_attr(f1_tid, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_tid, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_tid, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1235,9 +1221,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_tid, 1, attr_dims, "float6", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE4 - Different attr number, some same attr name (vs file2-g2) - * add attr to g2 - */ + * CASE4 - Different attr number, some same attr name (vs file2-g2) + * add attr to g2 + */ write_attr(f1_gid2, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid2, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_gid2, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1246,9 +1232,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_gid2, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE5 - Different attr number, all different attr name - * add attr to g3 - */ + * CASE5 - Different attr number, all different attr name + * add attr to g3 + */ write_attr(f1_gid3, 1, attr_dims, "integer10", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid3, 1, attr_dims, "float11", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_gid3, 1, attr_dims, "float12", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1258,8 +1244,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1 > 0) H5Fclose(fid1); if (fid2 > 0) @@ -1306,16 +1292,16 @@ out: * *------------------------------------------------------------------------- */ -static -int test_datasets(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_datasets(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hsize_t dims[1] = { 2 }; - herr_t status; - int buf[2] = { 1, 2 }; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims[1] = {2}; + herr_t status; + int buf[2] = {1, 2}; if (make_diffs > 0) memset(buf, 0, sizeof buf); @@ -1325,8 +1311,8 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer return -1; /* Create a 1D dataset */ - sid = H5Screate_simple(1, dims, NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); status = H5Sclose(sid); assert(status >= 0); @@ -1335,9 +1321,9 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * write a series of datasets on the group - *------------------------------------------------------------------------- - */ + * write a series of datasets on the group + *------------------------------------------------------------------------- + */ write_dset_in(gid, "/dset", fid, make_diffs); @@ -1359,16 +1345,16 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer * Purpose: Check datasets with datasapce of zero dimension size. *------------------------------------------------------------------------- */ -static -int test_special_datasets(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_special_datasets(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t sid0 = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hsize_t dims0[SPACE1_RANK] = { SPACE1_DIM1, SPACE1_DIM2 }; - hsize_t dims[SPACE1_RANK] = { SPACE1_DIM1, SPACE1_DIM2 }; - herr_t status; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid0 = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims0[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; + hsize_t dims[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; + herr_t status; /* Create a file */ if ((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -1376,7 +1362,7 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat /* Create a dataset with zero dimension size */ sid0 = H5Screate_simple(SPACE1_RANK, dims0, NULL); - did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* close dataset */ status = H5Dclose(did); @@ -1387,7 +1373,7 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat assert(status >= 0); /* Create a dataset with zero dimension size in one file but the other one - * has a dataset with a non-zero dimension size */ + * has a dataset with a non-zero dimension size */ if (make_diffs) dims[1] = SPACE1_DIM2 + 4; @@ -1416,16 +1402,17 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_link_name(const char *fname1) +static int +test_link_name(const char *fname1) { - hid_t fid1 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -1434,16 +1421,15 @@ static int test_link_name(const char *fname1) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } - gid2 = H5Gcreate2(fid1, "group_longname", H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + gid2 = H5Gcreate2(fid1, "group_longname", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -1452,8 +1438,8 @@ static int test_link_name(const char *fname1) } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ status = H5Lcreate_soft("group", fid1, "link_g1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); @@ -1470,8 +1456,8 @@ static int test_link_name(const char *fname1) out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ + * Close + *------------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1489,18 +1475,19 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_soft_links(const char *fname1) +static int +test_soft_links(const char *fname1) { - hid_t fid1 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -1509,8 +1496,8 @@ static int test_soft_links(const char *fname1) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -1519,8 +1506,8 @@ static int test_soft_links(const char *fname1) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -1544,8 +1531,8 @@ static int test_soft_links(const char *fname1) } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("/target_dset1", fid1, "softlink_dset1_1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -1591,8 +1578,8 @@ static int test_soft_links(const char *fname1) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1608,20 +1595,21 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_linked_softlinks(const char *fname1) +static int +test_linked_softlinks(const char *fname1) { - hid_t fid1 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; - hid_t gid3 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t gid3 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -1630,8 +1618,8 @@ static int test_linked_softlinks(const char *fname1) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -1654,8 +1642,8 @@ static int test_linked_softlinks(const char *fname1) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -1678,10 +1666,10 @@ static int test_linked_softlinks(const char *fname1) } /*----------------------------------------------------------------------- - * Soft Links (Linked) - *------------------------------------------------------------------------*/ + * Soft Links (Linked) + *------------------------------------------------------------------------*/ /*--------- - * file 1 */ + * file 1 */ status = H5Lcreate_soft("/target_dset1", fid1, "softlink1_to_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); @@ -1768,8 +1756,8 @@ static int test_linked_softlinks(const char *fname1) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1789,20 +1777,21 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_external_links(const char *fname1, const char *fname2) +static int +test_external_links(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* source file */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -1820,10 +1809,10 @@ static int test_external_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ gid1 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); @@ -1838,10 +1827,10 @@ static int test_external_links(const char *fname1, const char *fname2) goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ status = write_dset(fid2, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); @@ -1864,18 +1853,20 @@ static int test_external_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /*--------------*/ /* source file */ - status = H5Lcreate_external(fname2, "/target_group/x_dset", fid1, "ext_link_dset1", H5P_DEFAULT, H5P_DEFAULT); + status = + H5Lcreate_external(fname2, "/target_group/x_dset", fid1, "ext_link_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } - status = H5Lcreate_external(fname2, "/target_group2/x_dset", fid1, "ext_link_dset2", H5P_DEFAULT, H5P_DEFAULT); + status = + H5Lcreate_external(fname2, "/target_group2/x_dset", fid1, "ext_link_dset2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; @@ -1912,8 +1903,8 @@ static int test_external_links(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -1934,19 +1925,20 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_ext2soft_links(const char *fname1, const char *fname2) +static int +test_ext2soft_links(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* source file */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -1964,8 +1956,8 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /* target file */ gid2 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { @@ -1975,10 +1967,10 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ status = write_dset(fid2, 2, dims2, "dset1", H5T_NATIVE_INT, data2); if (status == FAIL) { HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); @@ -1994,10 +1986,10 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Soft Links (Linked) - *------------------------------------------------------------------------*/ + * Soft Links (Linked) + *------------------------------------------------------------------------*/ /*--------------- - * target file */ + * target file */ status = H5Lcreate_soft("/dset1", fid2, "softlink_to_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); @@ -2013,10 +2005,10 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /*--------------- - * source file */ + * source file */ status = H5Lcreate_external(fname2, "/target_group", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); @@ -2024,14 +2016,16 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) goto out; } - status = H5Lcreate_external(fname2, "/softlink_to_dset1", fid1, "ext_link_to_slink1", H5P_DEFAULT, H5P_DEFAULT); + status = H5Lcreate_external(fname2, "/softlink_to_dset1", fid1, "ext_link_to_slink1", H5P_DEFAULT, + H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } - status = H5Lcreate_external(fname2, "/softlink_to_dset2", fid1, "ext_link_to_slink2", H5P_DEFAULT, H5P_DEFAULT); + status = H5Lcreate_external(fname2, "/softlink_to_dset2", fid1, "ext_link_to_slink2", H5P_DEFAULT, + H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; @@ -2040,8 +2034,8 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2062,20 +2056,20 @@ out: * *------------------------------------------------------------------------- */ -static -int gen_dataset_idx(const char *file, int format) +static int +gen_dataset_idx(const char *file, int format) { - hid_t fid = H5I_INVALID_HID; /* file id */ - hid_t did = H5I_INVALID_HID; - hid_t did2 = H5I_INVALID_HID; /* dataset id */ - hid_t sid = H5I_INVALID_HID; /* space id */ - hid_t fapl = H5I_INVALID_HID; /* file access property id */ - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ - hsize_t dims[1] = { 10 }; /* dataset dimension */ - hsize_t c_dims[1] = { 2 }; /* chunk dimension */ - herr_t status; /* return status */ - int buf[10]; /* data buffer */ - int i; /* local index variable */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t did = H5I_INVALID_HID; + hid_t did2 = H5I_INVALID_HID; /* dataset id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t fapl = H5I_INVALID_HID; /* file access property id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hsize_t dims[1] = {10}; /* dataset dimension */ + hsize_t c_dims[1] = {2}; /* chunk dimension */ + herr_t status; /* return status */ + int buf[10]; /* data buffer */ + int i; /* local index variable */ /* Get a copy of the file aaccess property */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -2095,7 +2089,7 @@ int gen_dataset_idx(const char *file, int format) buf[i] = i; /* Set chunk */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); status = H5Pset_chunk(dcpl, 1, c_dims); assert(status >= 0); @@ -2107,13 +2101,13 @@ int gen_dataset_idx(const char *file, int format) status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); assert(status >= 0); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ status = H5Pset_deflate(dcpl, 9); assert(status >= 0); /* Create and write the dataset */ - did2 = H5Dcreate2(fid, "dset_filter", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + did2 = H5Dcreate2(fid, "dset_filter", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); status = H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); assert(status >= 0); @@ -2149,18 +2143,19 @@ int gen_dataset_idx(const char *file, int format) * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_dangle_links(const char *fname1, const char *fname2) +static int +test_dangle_links(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -2176,8 +2171,8 @@ static int test_dangle_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -2209,8 +2204,8 @@ static int test_dangle_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("no_obj", fid1, "soft_link1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2270,8 +2265,8 @@ static int test_dangle_links(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /* file1 */ status = H5Lcreate_external(fname2, "no_obj", fid1, "ext_link1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2332,8 +2327,8 @@ static int test_dangle_links(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2349,21 +2344,24 @@ out: * Programmer: Jonathan Kim (Aug 19, 2010) * *-------------------------------------------------------------------------*/ -static int test_group_recurse(const char *fname1, const char *fname2) +static int +test_group_recurse(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t gid1_f1 = H5I_INVALID_HID, gid2_f1 = H5I_INVALID_HID, gid3_f1 = H5I_INVALID_HID, gid10_f1 = H5I_INVALID_HID; - hid_t gid1_f2 = H5I_INVALID_HID, gid2_f2 = H5I_INVALID_HID, gid3_f2 = H5I_INVALID_HID, gid11_f2 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 0, 1 }, { 1, 0 }, { 1, 0 } }; - int data2[4][2] = { { 0, 2 }, { 0, 2 }, { 2, 0 }, { 2, 0 } }; - int data3[4][2] = { { 0, 3 }, { 0, 3 }, { 3, 0 }, { 3, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1_f1 = H5I_INVALID_HID, gid2_f1 = H5I_INVALID_HID, gid3_f1 = H5I_INVALID_HID, + gid10_f1 = H5I_INVALID_HID; + hid_t gid1_f2 = H5I_INVALID_HID, gid2_f2 = H5I_INVALID_HID, gid3_f2 = H5I_INVALID_HID, + gid11_f2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {0, 1}, {1, 0}, {1, 0}}; + int data2[4][2] = {{0, 2}, {0, 2}, {2, 0}, {2, 0}}; + int data3[4][2] = {{0, 3}, {0, 3}, {3, 0}, {3, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -2379,8 +2377,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /* file1 */ gid1_f1 = H5Gcreate2(fid1, "/grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1_f1 < 0) { @@ -2440,8 +2438,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets under root - *------------------------------------------------------------------------*/ + * Datasets under root + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -2487,8 +2485,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets under group - *------------------------------------------------------------------------*/ + * Datasets under group + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(gid1_f1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -2600,8 +2598,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("/grp1", fid1, "slink_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2661,8 +2659,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /* file1 */ status = H5Lcreate_external(fname2, "/grp1", fid1, "elink_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2708,9 +2706,9 @@ static int test_group_recurse(const char *fname1, const char *fname2) } /*------------------------------ - * external circle route test - * file1/grp11 <-> file2/grp10 via elink_grp_circle link - */ + * external circle route test + * file1/grp11 <-> file2/grp10 via elink_grp_circle link + */ /* file1 */ status = H5Lcreate_external(fname2, "/grp11", gid10_f1, "elink_grp_circle", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2728,8 +2726,8 @@ static int test_group_recurse(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2761,38 +2759,39 @@ out: *-------------------------------------------------------------------------*/ #define GRP_R_DSETNAME1 "dset1" #define GRP_R_DSETNAME2 "dset2" -static int test_group_recurse2(void) +static int +test_group_recurse2(void) { - hid_t fileid1 = H5I_INVALID_HID; - hid_t grp1 = H5I_INVALID_HID; - hid_t grp2 = H5I_INVALID_HID; - hid_t grp3 = H5I_INVALID_HID; - hid_t grp4 = H5I_INVALID_HID; - hid_t dset1 = H5I_INVALID_HID; - hid_t dset2 = H5I_INVALID_HID; - hid_t datatype = H5I_INVALID_HID; - hid_t dataspace = H5I_INVALID_HID; - hid_t fileid2 = H5I_INVALID_HID; - hid_t fileid3 = H5I_INVALID_HID; - hid_t fileid4 = H5I_INVALID_HID; + hid_t fileid1 = H5I_INVALID_HID; + hid_t grp1 = H5I_INVALID_HID; + hid_t grp2 = H5I_INVALID_HID; + hid_t grp3 = H5I_INVALID_HID; + hid_t grp4 = H5I_INVALID_HID; + hid_t dset1 = H5I_INVALID_HID; + hid_t dset2 = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t dataspace = H5I_INVALID_HID; + hid_t fileid2 = H5I_INVALID_HID; + hid_t fileid3 = H5I_INVALID_HID; + hid_t fileid4 = H5I_INVALID_HID; hsize_t dimsf[2]; /* dataset dimensions */ - herr_t status = 0; - int data1[4][2] = { { 0, 0 }, { 1, 1 }, { 2, 2 }, { 3, 3 } }; - int data2[4][2] = { { 0, 0 }, { 0, 1 }, { 0, 2 }, { 3, 3 } }; + herr_t status = 0; + int data1[4][2] = {{0, 0}, {1, 1}, {2, 2}, {3, 3}}; + int data2[4][2] = {{0, 0}, {0, 1}, {0, 2}, {3, 3}}; /*----------------------------------------------------------------------- - * FILE 1 - *------------------------------------------------------------------------*/ + * FILE 1 + *------------------------------------------------------------------------*/ /* - * Create a new file using H5F_ACC_TRUNC access, - * default file creation properties, and default file - * access properties. - */ + * Create a new file using H5F_ACC_TRUNC access, + * default file creation properties, and default file + * access properties. + */ fileid1 = H5Fcreate(GRP_RECURSE1_EXT, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ grp1 = H5Gcreate2(fileid1, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); @@ -2822,72 +2821,72 @@ static int test_group_recurse2(void) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* - * Describe the size of the array and create the data space for fixed - * size dataset. - */ - dimsf[0] = 4; - dimsf[1] = 2; + * Describe the size of the array and create the data space for fixed + * size dataset. + */ + dimsf[0] = 4; + dimsf[1] = 2; dataspace = H5Screate_simple(2, dimsf, NULL); /* - * Define datatype for the data in the file. - * We will store little endian INT numbers. - */ + * Define datatype for the data in the file. + * We will store little endian INT numbers. + */ datatype = H5Tcopy(H5T_NATIVE_INT); - status = H5Tset_order(datatype, H5T_ORDER_LE); + status = H5Tset_order(datatype, H5T_ORDER_LE); /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the file using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(fileid1, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); H5Dclose(dset1); /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the file using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(grp3, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*--------------- - * dset2 - */ + * dset2 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset2 = H5Dcreate2(grp4, GRP_R_DSETNAME2, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); /*----------------------------------------------------------------------- - * Soft links - *------------------------------------------------------------------------*/ + * Soft links + *------------------------------------------------------------------------*/ /* - * under '/' root - */ + * under '/' root + */ /* link to dset1 */ status = H5Lcreate_soft(GRP_R_DSETNAME1, fileid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -2904,15 +2903,15 @@ static int test_group_recurse2(void) H5Gclose(grp4); /*----------------------------------------------------------------------- - * FILE 2-3 - *------------------------------------------------------------------------*/ + * FILE 2-3 + *------------------------------------------------------------------------*/ /* crate target file */ fileid4 = H5Fcreate(GRP_RECURSE2_EXT3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp4 = H5Gcreate2(fileid4, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp4 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT3); @@ -2921,32 +2920,32 @@ static int test_group_recurse2(void) } /*--------------- - * dset2 - */ + * dset2 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset2 = H5Dcreate2(grp4, GRP_R_DSETNAME2, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); H5Gclose(grp4); H5Dclose(dset2); /*----------------------------------------------------------------------- - * FILE 2-2 - *------------------------------------------------------------------------*/ + * FILE 2-2 + *------------------------------------------------------------------------*/ /* crate target file */ fileid3 = H5Fcreate(GRP_RECURSE2_EXT2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp2 = H5Gcreate2(fileid3, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp2 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT2); @@ -2962,22 +2961,22 @@ static int test_group_recurse2(void) } /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(grp3, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*----------------------------------------------- - * extlink to $GRP_RECURSE2_EXT3/g4 - */ + * extlink to $GRP_RECURSE2_EXT3/g4 + */ status = H5Lcreate_external(GRP_RECURSE2_EXT3, "/g4", fileid3, "/g2/g3/g4", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", GRP_RECURSE2_EXT2); @@ -2990,15 +2989,15 @@ static int test_group_recurse2(void) H5Gclose(grp3); /*----------------------------------------------------------------------- - * FILE 2-1 - *------------------------------------------------------------------------*/ + * FILE 2-1 + *------------------------------------------------------------------------*/ /* crate target file */ fileid2 = H5Fcreate(GRP_RECURSE2_EXT1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp1 = H5Gcreate2(fileid2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); @@ -3007,21 +3006,21 @@ static int test_group_recurse2(void) } /*--------------- - * dset1 - */ + * dset1 + */ dset1 = H5Dcreate2(fileid2, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*----------------------------------------------------------------------- - * Soft links - *------------------------------------------------------------------------*/ + * Soft links + *------------------------------------------------------------------------*/ /* - * under '/' root - */ + * under '/' root + */ /* link to dset1 */ status = H5Lcreate_soft(GRP_R_DSETNAME1, fileid2, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { @@ -3031,8 +3030,8 @@ static int test_group_recurse2(void) } /*----------------------------------------------- - * extlink to $GRP_RECURSE2_EXT2/g2 - */ + * extlink to $GRP_RECURSE2_EXT2/g2 + */ status = H5Lcreate_external(GRP_RECURSE2_EXT2, "/g2", fileid2, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", GRP_RECURSE2_EXT1); @@ -3045,8 +3044,8 @@ static int test_group_recurse2(void) out: /* - * Close/release resources. - */ + * Close/release resources. + */ if (dataspace > 0) H5Sclose(dataspace); if (datatype > 0) @@ -3072,20 +3071,21 @@ out: * Programmer: Jonathan Kim (July, 21, 2010) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj1(const char *fname1, const char *fname2) +static int +test_exclude_obj1(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data2[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + int data2[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -3101,8 +3101,8 @@ static int test_exclude_obj1(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { @@ -3121,8 +3121,8 @@ static int test_exclude_obj1(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -3169,8 +3169,8 @@ static int test_exclude_obj1(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3192,21 +3192,22 @@ out: * Programmer: Jonathan Kim (July, 21, 2010) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj2(const char *fname1, const char *fname2) +static int +test_exclude_obj2(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; - hid_t gid3 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data2[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t gid3 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + int data2[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -3222,8 +3223,8 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { @@ -3250,8 +3251,8 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset10", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -3298,8 +3299,8 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3323,18 +3324,19 @@ out: * Programmer: Jonathan Kim (Mar, 19, 2012) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj3(const char *fname1, const char *fname2) +static int +test_exclude_obj3(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); @@ -3350,8 +3352,8 @@ static int test_exclude_obj3(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { @@ -3361,8 +3363,8 @@ static int test_exclude_obj3(const char *fname1, const char *fname2) } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { @@ -3388,8 +3390,8 @@ static int test_exclude_obj3(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3409,182 +3411,181 @@ out: * Programmer: Jonathan Kim (Oct, 26, 2010) * *-------------------------------------------------------------------------*/ -#define STR_RANK 1 -#define VLEN_STR_DIM 1 -#define FIXLEN_STR_SIZE 21 -#define FIXLEN_STR_DIM 1 -#define VLEN_STR_ARRY_DIM 3 -#define FIXLEN_STR_ARRY_DIM 3 +#define STR_RANK 1 +#define VLEN_STR_DIM 1 +#define FIXLEN_STR_SIZE 21 +#define FIXLEN_STR_DIM 1 +#define VLEN_STR_ARRY_DIM 3 +#define FIXLEN_STR_ARRY_DIM 3 #define FIXLEN_STR_ARRY_SIZE 30 -#define COMP_RANK 1 -#define COMP_DIM 1 -static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new) +#define COMP_RANK 1 +#define COMP_DIM 1 +static int +test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new) { - int i; + int i; hid_t fid1 = H5I_INVALID_HID; /* file id */ - hid_t gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; /* compound1 datatype */ typedef struct comp1_t { - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char * str_vlen; /* vlen string */ + char * str_vlen_repeat; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ } comp1_t; /* compound2 datatype */ typedef struct comp2_t { - char *str_vlen; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char * str_vlen; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ } comp2_t; /* compound3 datatype */ typedef struct comp3_t { - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char *str_vlen; /* vlen string */ + char *str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ } comp3_t; /* compound4 datatype */ typedef struct comp4_t { - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ } comp4_t; /* compound5 datatype */ typedef struct comp5_t { - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char *str_vlen; /* vlen string */ + char *str_vlen_repeat; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ } comp5_t; /* compound6 datatype */ typedef struct comp6_t { - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char *str_vlen; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char *str_vlen; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char *str_vlen_repeat; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ } comp6_t; /* compound7 datatype */ typedef struct comp7_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char * str_vlen_repeat; /* vlen string */ } comp7_t; /* compound8 datatype */ typedef struct comp8_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ } comp8_t; /* compound9 datatype */ typedef struct comp9_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - int int_data1; - hobj_ref_t objref1; /* reference */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - hobj_ref_t objref2; /* reference */ - char *str_vlen; /* vlen string */ - int int_data2; - char *str_vlen_repeat; /* vlen string */ - hobj_ref_t objref3; /* reference */ - int int_data3; + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + int int_data1; + hobj_ref_t objref1; /* reference */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + hobj_ref_t objref2; /* reference */ + char * str_vlen; /* vlen string */ + int int_data2; + char * str_vlen_repeat; /* vlen string */ + hobj_ref_t objref3; /* reference */ + int int_data3; } comp9_t; /* vlen string */ - hid_t sid_vlen_str = H5I_INVALID_HID; /* dataspace ID */ - hid_t tid_vlen_str = H5I_INVALID_HID; /* datatype ID */ - char vlen_str_buf[] = { "Variable length string" }; - hsize_t dims_vlen_str[] = { VLEN_STR_DIM }; + hid_t sid_vlen_str = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_vlen_str = H5I_INVALID_HID; /* datatype ID */ + char vlen_str_buf[] = {"Variable length string"}; + hsize_t dims_vlen_str[] = {VLEN_STR_DIM}; /* fixlen string */ - hid_t sid_fixlen_str = H5I_INVALID_HID; /* dataspace ID */ - hid_t tid_fixlen_str = H5I_INVALID_HID; /* datatype ID */ - const char fixlen_str_buf[FIXLEN_STR_SIZE] = { "Fixed length string" }; - hsize_t dims_fixlen_str[] = { FIXLEN_STR_DIM }; + hid_t sid_fixlen_str = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_fixlen_str = H5I_INVALID_HID; /* datatype ID */ + const char fixlen_str_buf[FIXLEN_STR_SIZE] = {"Fixed length string"}; + hsize_t dims_fixlen_str[] = {FIXLEN_STR_DIM}; /* vlen string array */ - hid_t sid_vlen_str_array = H5I_INVALID_HID; /* dataspace ID */ - hid_t tid_vlen_str_array_pre = H5I_INVALID_HID; /* datatype ID */ - hid_t tid_vlen_str_array = H5I_INVALID_HID; /* datatype ID */ - const char *vlen_str_array_buf[VLEN_STR_ARRY_DIM] = - { "1 - Variable length string Array", - "2 - Testing variable length string array in compound type", - "3 - Four score and seven\n years ago our forefathers brought forth on this continent a new nation," }; - hsize_t dims_vlen_str_array[] = { VLEN_STR_ARRY_DIM }; + hid_t sid_vlen_str_array = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_vlen_str_array_pre = H5I_INVALID_HID; /* datatype ID */ + hid_t tid_vlen_str_array = H5I_INVALID_HID; /* datatype ID */ + const char *vlen_str_array_buf[VLEN_STR_ARRY_DIM] = { + "1 - Variable length string Array", "2 - Testing variable length string array in compound type", + "3 - Four score and seven\n years ago our forefathers brought forth on this continent a new nation,"}; + hsize_t dims_vlen_str_array[] = {VLEN_STR_ARRY_DIM}; /* fixlen string array */ - hid_t sid_fixlen_str_array = H5I_INVALID_HID; /* dataspace ID */ - hid_t tid_fixlen_str_array_pre = H5I_INVALID_HID; /* datatype ID */ - hid_t tid_fixlen_str_array = H5I_INVALID_HID; /* datatype ID */ + hid_t sid_fixlen_str_array = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_fixlen_str_array_pre = H5I_INVALID_HID; /* datatype ID */ + hid_t tid_fixlen_str_array = H5I_INVALID_HID; /* datatype ID */ const char *fixlen_str_array_buf[FIXLEN_STR_ARRY_DIM] = { - "1 - Fixed length string Array", "2 - Fixed length string Array", - "3 - Fixed length string Array" }; - hsize_t dims_fixlen_str_array[] = { FIXLEN_STR_ARRY_DIM }; + "1 - Fixed length string Array", "2 - Fixed length string Array", "3 - Fixed length string Array"}; + hsize_t dims_fixlen_str_array[] = {FIXLEN_STR_ARRY_DIM}; /*------------------------------------------ - * compound dataset - *------------------------------------------*/ - hid_t sid_comp = H5I_INVALID_HID; /* dataspace ID */ - hid_t tid1_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t tid2_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t tid3_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t tid4_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t tid5_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t tid6_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t tid7_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t tid8_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t tid9_comp = H5I_INVALID_HID; /* datatype ID */ - hid_t did_comp = H5I_INVALID_HID; /* dataset ID */ - hsize_t dims_comp[] = { COMP_DIM }; - herr_t status = SUCCEED; + * compound dataset + *------------------------------------------*/ + hid_t sid_comp = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid1_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid2_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid3_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid4_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid5_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid6_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid7_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid8_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid9_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t did_comp = H5I_INVALID_HID; /* dataset ID */ + hsize_t dims_comp[] = {COMP_DIM}; + herr_t status = SUCCEED; /* make compound strings data */ comp1_t comp1_buf; @@ -3641,25 +3642,15 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* copy vlen string array data to compound buffers */ for (i = 0; i < VLEN_STR_ARRY_DIM; i++) { - comp1_buf.str_array_vlen[i] = comp1_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp2_buf.str_array_vlen[i] = comp2_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp3_buf.str_array_vlen[i] = comp3_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp4_buf.str_array_vlen[i] = comp4_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp5_buf.str_array_vlen[i] = comp5_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp6_buf.str_array_vlen[i] = comp6_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp7_buf.str_array_vlen[i] = comp7_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp8_buf.str_array_vlen[i] = comp8_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp9_buf.str_array_vlen[i] = comp9_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - + comp1_buf.str_array_vlen[i] = comp1_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp2_buf.str_array_vlen[i] = comp2_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp3_buf.str_array_vlen[i] = comp3_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp4_buf.str_array_vlen[i] = comp4_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp5_buf.str_array_vlen[i] = comp5_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp6_buf.str_array_vlen[i] = comp6_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp7_buf.str_array_vlen[i] = comp7_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp8_buf.str_array_vlen[i] = comp8_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp9_buf.str_array_vlen[i] = comp9_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; } /* copy fixlen string attay data to compound buffers */ @@ -3698,8 +3689,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int comp9_buf.int_data3 = 30; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) { fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -3718,8 +3709,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Create group - *------------------------------------------------------------------------*/ + * Create group + *------------------------------------------------------------------------*/ gid = H5Gcreate2(fid1, grp_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); @@ -3728,8 +3719,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Variable length String1 - Create space and type - *------------------------------------------------------------------------*/ + * Variable length String1 - Create space and type + *------------------------------------------------------------------------*/ sid_vlen_str = H5Screate_simple(STR_RANK, dims_vlen_str, NULL); if (sid_vlen_str < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3738,7 +3729,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } tid_vlen_str = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_vlen_str, H5T_VARIABLE); + status = H5Tset_size(tid_vlen_str, H5T_VARIABLE); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; @@ -3746,8 +3737,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Fixed length String2 - Create space and type - *------------------------------------------------------------------------*/ + * Fixed length String2 - Create space and type + *------------------------------------------------------------------------*/ sid_fixlen_str = H5Screate_simple(STR_RANK, dims_fixlen_str, NULL); if (sid_fixlen_str < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3756,7 +3747,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } tid_fixlen_str = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_fixlen_str, FIXLEN_STR_SIZE); + status = H5Tset_size(tid_fixlen_str, FIXLEN_STR_SIZE); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; @@ -3764,8 +3755,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Fixed length String3 array - Create space and type - *------------------------------------------------------------------------*/ + * Fixed length String3 array - Create space and type + *------------------------------------------------------------------------*/ sid_vlen_str_array = H5Screate_simple(STR_RANK, dims_vlen_str_array, NULL); if (sid_vlen_str_array < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3774,7 +3765,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } tid_vlen_str_array_pre = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_vlen_str_array_pre, H5T_VARIABLE); + status = H5Tset_size(tid_vlen_str_array_pre, H5T_VARIABLE); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; @@ -3790,8 +3781,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*----------------------------------------------------------------------- - * Variable length String4 array - Create space and type - *------------------------------------------------------------------------*/ + * Variable length String4 array - Create space and type + *------------------------------------------------------------------------*/ sid_fixlen_str_array = H5Screate_simple(STR_RANK, dims_fixlen_str_array, NULL); if (sid_fixlen_str_array < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3800,7 +3791,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } tid_fixlen_str_array_pre = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_fixlen_str_array_pre, FIXLEN_STR_ARRY_SIZE); + status = H5Tset_size(tid_fixlen_str_array_pre, FIXLEN_STR_ARRY_SIZE); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; @@ -3815,8 +3806,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int } /*------------------------------------------------------------------------- - * Compound dataset - *------------------------------------------------------------------------*/ + * Compound dataset + *------------------------------------------------------------------------*/ sid_comp = H5Screate_simple(COMP_RANK, dims_comp, NULL); if (sid_comp < 0) { HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); @@ -3879,7 +3870,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int H5Tinsert(tid5_comp, "FIXLEN_STR1", HOFFSET(comp5_t, str_fixlen), tid_fixlen_str); H5Tinsert(tid5_comp, "FIXLEN_STR2", HOFFSET(comp5_t, str_fixlen_repeat), tid_fixlen_str); H5Tinsert(tid5_comp, "VLEN_STR_ARRAY1", HOFFSET(comp5_t, str_array_vlen), tid_vlen_str_array); - H5Tinsert(tid5_comp, "VLEN_STR_ARRAY2", HOFFSET(comp5_t, str_vlen_array_again), tid_vlen_str_array); + H5Tinsert(tid5_comp, "VLEN_STR_ARRAY2", HOFFSET(comp5_t, str_vlen_array_again), tid_vlen_str_array); H5Tinsert(tid5_comp, "FIXLEN_STR_ARRAY1", HOFFSET(comp5_t, str_array_fixlen), tid_fixlen_str_array); H5Tinsert(tid5_comp, "FIXLEN_STR_ARRAY2", HOFFSET(comp5_t, str_fixlen_array_again), tid_fixlen_str_array); @@ -3931,7 +3922,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 1 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset1", tid1_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid1_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp1_buf); + status = H5Dwrite(did_comp, tid1_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp1_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3941,7 +3932,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 2 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset2", tid2_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid2_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp2_buf); + status = H5Dwrite(did_comp, tid2_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp2_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3951,7 +3942,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 3 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset3", tid3_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid3_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp3_buf); + status = H5Dwrite(did_comp, tid3_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp3_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3961,7 +3952,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 4 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset4", tid4_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid4_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp4_buf); + status = H5Dwrite(did_comp, tid4_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp4_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3971,7 +3962,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 5 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset5", tid5_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid5_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp5_buf); + status = H5Dwrite(did_comp, tid5_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp5_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3981,7 +3972,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 6 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset6", tid6_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid6_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp6_buf); + status = H5Dwrite(did_comp, tid6_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp6_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -3991,7 +3982,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 7 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset7", tid7_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid7_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp7_buf); + status = H5Dwrite(did_comp, tid7_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp7_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -4001,7 +3992,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 8 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset8", tid8_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid8_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp8_buf); + status = H5Dwrite(did_comp, tid8_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp8_buf); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; @@ -4013,9 +4004,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int did_comp = H5Dcreate2(gid, "Compound_dset9", tid9_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* obj references */ - status = H5Rcreate(&(comp9_buf.objref1), gid, "Compound_dset2", H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&(comp9_buf.objref2), gid, "Compound_dset3", H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&(comp9_buf.objref3), gid, "Compound_dset4", H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&(comp9_buf.objref1), gid, "Compound_dset2", H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&(comp9_buf.objref2), gid, "Compound_dset3", H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&(comp9_buf.objref3), gid, "Compound_dset4", H5R_OBJECT, (hid_t)-1); status = H5Dwrite(did_comp, tid9_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp9_buf); if (status < 0) { @@ -4029,8 +4020,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1 > 0) H5Fclose(fid1); if (gid > 0) @@ -4094,59 +4085,60 @@ out: * *-------------------------------------------------------------------------*/ -static int test_enums(const char *fname) +static int +test_enums(const char *fname) { hid_t fid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; - int enum_val = -1; + hid_t tid = H5I_INVALID_HID; + int enum_val = -1; /* The data in the two arrays cover the following cases: - * - * V = valid enum value, I = invalid enum value - * - * 0: I-I (same value) - * 1: V-I - * 2: I-V - * 3: V-V (same value) - * 4: I-I (different values) SKIPPED FOR NOW - * 5: V-V (different values) - */ + * + * V = valid enum value, I = invalid enum value + * + * 0: I-I (same value) + * 1: V-I + * 2: I-V + * 3: V-V (same value) + * 4: I-I (different values) SKIPPED FOR NOW + * 5: V-V (different values) + */ /* *** NOTE *** - * - * There is a bug in H5Dread() where invalid enum values are always - * returned as -1 so two different invalid enum values cannot be - * properly compared. Test 4 has been adjusted to pass here - * while we fix the issue. - */ - int data1[6] = { 9, 0, 9, 0, 9, 0 }; + * + * There is a bug in H5Dread() where invalid enum values are always + * returned as -1 so two different invalid enum values cannot be + * properly compared. Test 4 has been adjusted to pass here + * while we fix the issue. + */ + int data1[6] = {9, 0, 9, 0, 9, 0}; /*int data1[6] = {9, 0, 9, 0, 8, 0}; */ - int data2[6] = { 9, 9, 0, 0, 9, 1 }; + int data2[6] = {9, 9, 0, 0, 9, 1}; hsize_t dims = 6; herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create the file - *---------------------------------------------------------------------*/ + * Create the file + *---------------------------------------------------------------------*/ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------------------------------- - * Create enum types - *---------------------------------------------------------------------*/ + * Create enum types + *---------------------------------------------------------------------*/ - tid = H5Tenum_create(H5T_NATIVE_INT); + tid = H5Tenum_create(H5T_NATIVE_INT); enum_val = 0; - status = H5Tenum_insert(tid, "YIN", &enum_val); + status = H5Tenum_insert(tid, "YIN", &enum_val); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tenum_insert failed.\n", fname); status = FAIL; goto out; } enum_val = 1; - status = H5Tenum_insert(tid, "YANG", &enum_val); + status = H5Tenum_insert(tid, "YANG", &enum_val); if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tenum_insert failed.\n", fname); status = FAIL; @@ -4154,8 +4146,8 @@ static int test_enums(const char *fname) } /*----------------------------------------------------------------------- - * Create datasets containing enum data. - *---------------------------------------------------------------------*/ + * Create datasets containing enum data. + *---------------------------------------------------------------------*/ status = write_dset(fid, 1, &dims, "dset1", tid, data1); if (status < 0) { @@ -4172,8 +4164,8 @@ static int test_enums(const char *fname) out: /*----------------------------------------------------------------------- - * Close - *---------------------------------------------------------------------*/ + * Close + *---------------------------------------------------------------------*/ if (fid) H5Fclose(fid); if (tid) @@ -4203,35 +4195,36 @@ out: * Programmer: Jonathan Kim (Sep, 1, 2011) * *-------------------------------------------------------------------------*/ -#define SDIM_DSET 2 +#define SDIM_DSET 2 #define SDIM_CMPD_ARRAY 2 -static void test_comps_array(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_array(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 2 */ typedef struct { - int i2; + int i2; float f2; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; cmpd2_t cmpd2[SDIM_CMPD_ARRAY]; } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* dataset with compound1 */ - hid_t fid = H5I_INVALID_HID; /* HDF5 File IDs */ - hid_t did_dset = H5I_INVALID_HID; /* Dataset ID */ - hid_t sid_dset = H5I_INVALID_HID; /* Dataset space ID */ - hid_t tid_cmpd1 = H5I_INVALID_HID; /* Compound1 type ID */ - hid_t tid_arry1 = H5I_INVALID_HID; /* Array type ID in compound1 */ - hid_t tid_cmpd2 = H5I_INVALID_HID; /* Compound2 type ID */ - hid_t tid_attr = H5I_INVALID_HID; - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_cmpd_arry[] = { SDIM_CMPD_ARRAY }; - int i, j; + hid_t fid = H5I_INVALID_HID; /* HDF5 File IDs */ + hid_t did_dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* Dataset space ID */ + hid_t tid_cmpd1 = H5I_INVALID_HID; /* Compound1 type ID */ + hid_t tid_arry1 = H5I_INVALID_HID; /* Array type ID in compound1 */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* Compound2 type ID */ + hid_t tid_attr = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_cmpd_arry[] = {SDIM_CMPD_ARRAY}; + int i, j; herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ @@ -4239,20 +4232,20 @@ static void test_comps_array(const char *fname, const char *dset, const char *at wdata[i].i1 = i; for (j = 0; j < SDIM_CMPD_ARRAY; j++) { wdata[i].cmpd2[j].i2 = i * 10 + diff; - wdata[i].cmpd2[j].f2 = (float) i * 10.5F + (float) diff; + wdata[i].cmpd2[j].f2 = (float)i * 10.5F + (float)diff; } /* end for */ } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ------------------------------- - * Create a sub compound2 datatype */ + * Create a sub compound2 datatype */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert integer field */ @@ -4264,8 +4257,8 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create a top compound1. - */ + * Create a top compound1. + */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); @@ -4278,8 +4271,8 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /* ------------------- - * Create a dataset - */ + * Create a dataset + */ /* Create dataspace for datasets */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4290,15 +4283,15 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); assert(ret >= 0); /* ---------------- - * Close Dataset */ + * Close Dataset */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Tclose(tid_arry1); @@ -4315,57 +4308,56 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); } -static void test_comps_vlen(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 2 */ typedef struct { - int i2; + int i2; float f2; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; hvl_t vl; /* VL information for compound2 */ } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* Dataset for compound1 */ - hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ - hid_t did_dset = H5I_INVALID_HID; /* dataset ID */ - hid_t sid_dset = H5I_INVALID_HID; /* dataset space ID */ - hid_t tid_attr = H5I_INVALID_HID; - hid_t tid_cmpd2 = H5I_INVALID_HID; /* compound2 type ID */ - hid_t tid_cmpd1 = H5I_INVALID_HID; /* compound1 type ID */ - hid_t tid_cmpd1_vlen = H5I_INVALID_HID; - hsize_t sdims_dset[] = { SDIM_DSET }; + hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ + hid_t did_dset = H5I_INVALID_HID; /* dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* dataset space ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd2 = H5I_INVALID_HID; /* compound2 type ID */ + hid_t tid_cmpd1 = H5I_INVALID_HID; /* compound1 type ID */ + hid_t tid_cmpd1_vlen = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; - unsigned i, j; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + unsigned i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ for (i = 0; i < SDIM_DSET; i++) { - wdata[i].i1 = (int) i; - wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); + wdata[i].i1 = (int)i; + wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); wdata[i].vl.len = i + 1; for (j = 0; j < (i + 1); j++) { - ((cmpd2_t *) wdata[i].vl.p)[j].i2 = - (int) (i * 10 + (unsigned) diff); - ((cmpd2_t *) wdata[i].vl.p)[j].f2 = (float) i * 10.5F - + (float) diff; + ((cmpd2_t *)wdata[i].vl.p)[j].i2 = (int)(i * 10 + (unsigned)diff); + ((cmpd2_t *)wdata[i].vl.p)[j].f2 = (float)i * 10.5F + (float)diff; } /* end for */ - } /* end for */ + } /* end for */ /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ----------------------------- - * Create sub compound2 type */ + * Create sub compound2 type */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert fields */ @@ -4375,7 +4367,7 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /* --------------------------- - * Create top compound1 type */ + * Create top compound1 type */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Insert fields */ ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); @@ -4387,8 +4379,8 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /* ------------------------------- - * Create dataset with compound1 - */ + * Create dataset with compound1 + */ /* Create dataspace for dataset */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4400,8 +4392,8 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); @@ -4412,7 +4404,7 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /* ---------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Dclose(did_dset); @@ -4429,60 +4421,59 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); } -static void test_comps_array_vlen(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_array_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { typedef struct { - int i3; + int i3; float f3; } cmpd3_t; typedef struct { /* Typedef for compound datatype */ - int i2; + int i2; hvl_t vl; /* VL information to write */ } cmpd2_t; typedef struct { - int i1; + int i1; cmpd2_t cmpd2[SDIM_CMPD_ARRAY]; } cmpd1_t; - cmpd1_t wdata[SDIM_DSET]; /* Information to write */ - hid_t fid = H5I_INVALID_HID; /* HDF5 File IDs */ - hid_t did_dset = H5I_INVALID_HID; /* Dataset ID */ - hid_t sid_dset = H5I_INVALID_HID; /* Dataspace ID */ - hid_t tid_attr = H5I_INVALID_HID; - hid_t tid_cmpd1 = H5I_INVALID_HID; /* Compound1 Datatype ID */ - hid_t tid_arry1 = H5I_INVALID_HID; /* Array Datatype ID */ - hid_t tid_cmpd2 = H5I_INVALID_HID; /* Compound2 Datatype ID */ - hid_t tid_cmpd2_vlen = H5I_INVALID_HID; - hid_t tid_cmpd3 = H5I_INVALID_HID; /* Compound3 Datatype ID */ - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_arry[] = { SDIM_CMPD_ARRAY }; - unsigned i, j, k; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + cmpd1_t wdata[SDIM_DSET]; /* Information to write */ + hid_t fid = H5I_INVALID_HID; /* HDF5 File IDs */ + hid_t did_dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* Dataspace ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd1 = H5I_INVALID_HID; /* Compound1 Datatype ID */ + hid_t tid_arry1 = H5I_INVALID_HID; /* Array Datatype ID */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* Compound2 Datatype ID */ + hid_t tid_cmpd2_vlen = H5I_INVALID_HID; + hid_t tid_cmpd3 = H5I_INVALID_HID; /* Compound3 Datatype ID */ + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_arry[] = {SDIM_CMPD_ARRAY}; + unsigned i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write in compound1 */ for (i = 0; i < SDIM_DSET; i++) { - wdata[i].i1 = (int) i; + wdata[i].i1 = (int)i; /* Allocate and initialize VL data to write in compound2 */ for (j = 0; j < SDIM_CMPD_ARRAY; j++) { - wdata[i].cmpd2[j].i2 = (int) (j * 10); - wdata[i].cmpd2[j].vl.p = HDmalloc((j + 1) * sizeof(cmpd3_t)); + wdata[i].cmpd2[j].i2 = (int)(j * 10); + wdata[i].cmpd2[j].vl.p = HDmalloc((j + 1) * sizeof(cmpd3_t)); wdata[i].cmpd2[j].vl.len = j + 1; for (k = 0; k < (j + 1); k++) { /* Initialize data of compound3 */ - ((cmpd3_t *) wdata[i].cmpd2[j].vl.p)[k].i3 = (int) j * 10 - + diff; - ((cmpd3_t *) wdata[i].cmpd2[j].vl.p)[k].f3 = (float) j * 10.5F - + (float) diff; + ((cmpd3_t *)wdata[i].cmpd2[j].vl.p)[k].i3 = (int)j * 10 + diff; + ((cmpd3_t *)wdata[i].cmpd2[j].vl.p)[k].f3 = (float)j * 10.5F + (float)diff; } /* end for */ - } /* end for */ + } /* end for */ } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else @@ -4492,7 +4483,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch sid_dset = H5Screate_simple(1, sdims_dset, NULL); /*------------------------------------- - * Create a sub compound3 datatype */ + * Create a sub compound3 datatype */ tid_cmpd3 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd3_t)); /* Insert integer field */ @@ -4504,7 +4495,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /*------------------------------------- - * Create a sub compound2 datatype */ + * Create a sub compound2 datatype */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert integer field */ @@ -4512,12 +4503,12 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /* Create a VL datatype */ tid_cmpd2_vlen = H5Tvlen_create(tid_cmpd3); - ret = H5Tinsert(tid_cmpd2, "vlen", HOFFSET(cmpd2_t, vl), tid_cmpd2_vlen); + ret = H5Tinsert(tid_cmpd2, "vlen", HOFFSET(cmpd2_t, vl), tid_cmpd2_vlen); assert(ret >= 0); /*----------------------------------- - * Create a top compound1 datatype for dataset. - */ + * Create a top compound1 datatype for dataset. + */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Create an array datatype */ @@ -4526,7 +4517,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch H5Tinsert(tid_cmpd1, "array_comp", HOFFSET(cmpd1_t, cmpd2), tid_arry1); /* ---------------------- - * Create a dataset */ + * Create a dataset */ did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Write dataset to disk */ @@ -4534,8 +4525,8 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); @@ -4546,7 +4537,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /*------------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Tclose(tid_arry1); @@ -4567,70 +4558,71 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); } -static void test_comps_vlen_arry(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_vlen_arry(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 3 */ typedef struct { - int i3; + int i3; float f3; } cmpd3_t; /* sub compound 2 */ typedef struct { - int i2; + int i2; cmpd3_t cmpd3[SDIM_CMPD_ARRAY]; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; hvl_t vl; /* VL information for compound2 */ } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* Dataset for compound1 */ - hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ - hid_t did_dset = H5I_INVALID_HID; /* dataset ID */ - hid_t sid_dset = H5I_INVALID_HID; /* dataset space ID */ - hid_t tid_attr = H5I_INVALID_HID; - hid_t tid_cmpd3 = H5I_INVALID_HID; /* compound3 type ID */ - hid_t tid_cmpd2 = H5I_INVALID_HID; /* compound2 type ID */ - hid_t tid_cmpd2_arry = H5I_INVALID_HID; - hid_t tid_cmpd1 = H5I_INVALID_HID; /* compound1 type ID */ - hid_t tid_cmpd1_vlen = H5I_INVALID_HID; - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_cmpd_arry[] = { SDIM_CMPD_ARRAY }; - - unsigned i, j, k; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ + hid_t did_dset = H5I_INVALID_HID; /* dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* dataset space ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd3 = H5I_INVALID_HID; /* compound3 type ID */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* compound2 type ID */ + hid_t tid_cmpd2_arry = H5I_INVALID_HID; + hid_t tid_cmpd1 = H5I_INVALID_HID; /* compound1 type ID */ + hid_t tid_cmpd1_vlen = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_cmpd_arry[] = {SDIM_CMPD_ARRAY}; + + unsigned i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ for (i = 0; i < SDIM_DSET; i++) { /* compound 1 data */ - wdata[i].i1 = (int) i; - wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); + wdata[i].i1 = (int)i; + wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); wdata[i].vl.len = i + 1; for (j = 0; j < (i + 1); j++) { /* compound2 data */ - ((cmpd2_t *) wdata[i].vl.p)[j].i2 = (int) i * 10 + diff; + ((cmpd2_t *)wdata[i].vl.p)[j].i2 = (int)i * 10 + diff; for (k = 0; k < SDIM_CMPD_ARRAY; k++) { /* compound 3 data */ - ((cmpd2_t *) (wdata[i].vl.p))[j].cmpd3[k].i3 = (int) ((float) k * 10.5F) + diff; - ((cmpd2_t *) (wdata[i].vl.p))[j].cmpd3[k].f3 = (float) k * 10.5F + (float) diff; + ((cmpd2_t *)(wdata[i].vl.p))[j].cmpd3[k].i3 = (int)((float)k * 10.5F) + diff; + ((cmpd2_t *)(wdata[i].vl.p))[j].cmpd3[k].f3 = (float)k * 10.5F + (float)diff; } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ----------------------------- - * Create sub compound3 type */ + * Create sub compound3 type */ tid_cmpd3 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd3_t)); /* Insert fields */ @@ -4640,45 +4632,44 @@ static void test_comps_vlen_arry(const char * fname, const char *dset, const cha assert(ret >= 0); /* ----------------------------- - * Create sub compound2 type */ + * Create sub compound2 type */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); ret = H5Tinsert(tid_cmpd2, "int2", HOFFSET(cmpd2_t, i2), H5T_NATIVE_INT); assert(ret >= 0); tid_cmpd2_arry = H5Tarray_create2(tid_cmpd3, 1, sdims_cmpd_arry); - ret = H5Tinsert(tid_cmpd2, "array_cmpd2", HOFFSET(cmpd2_t, cmpd3), tid_cmpd2_arry); + ret = H5Tinsert(tid_cmpd2, "array_cmpd2", HOFFSET(cmpd2_t, cmpd3), tid_cmpd2_arry); assert(ret >= 0); /* --------------------------- - * Create top compound1 type - */ + * Create top compound1 type + */ /* Create a VL datatype */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Insert fields */ ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); assert(ret >= 0); tid_cmpd1_vlen = H5Tvlen_create(tid_cmpd2); - ret = H5Tinsert(tid_cmpd1, "vlen_cmpd1", HOFFSET(cmpd1_t, vl), tid_cmpd1_vlen); + ret = H5Tinsert(tid_cmpd1, "vlen_cmpd1", HOFFSET(cmpd1_t, vl), tid_cmpd1_vlen); assert(ret >= 0); /* ------------------------------- - * Create dataset with compound1 - */ + * Create dataset with compound1 + */ /* Create dataspace for dataset */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); /* Create a dataset */ - did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Write dataset to disk */ ret = H5Dwrite(did_dset, tid_cmpd1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); @@ -4689,7 +4680,7 @@ static void test_comps_vlen_arry(const char * fname, const char *dset, const cha assert(ret >= 0); /* ---------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Dclose(did_dset); @@ -4720,83 +4711,83 @@ static void test_comps_vlen_arry(const char * fname, const char *dset, const cha * *-------------------------------------------------------------------------*/ #define DIM_ARRY 3 -static void test_data_nocomparables(const char * fname, int make_diffs) +static void +test_data_nocomparables(const char *fname, int make_diffs) { - hid_t fid = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; - hid_t did1 = H5I_INVALID_HID; - hid_t did2 = H5I_INVALID_HID; - hid_t sid1 = H5I_INVALID_HID; - hid_t tid_dset1 = H5I_INVALID_HID; - hid_t tid_attr1 = H5I_INVALID_HID; - hsize_t dims1_1[1] = { DIM_ARRY }; - hsize_t dims1_2[1] = { DIM_ARRY + 1 }; - hsize_t dims2[2] = { DIM_ARRY, 1 }; - int data1[DIM_ARRY] = { 0, 0, 0 }; - int data2[DIM_ARRY] = { 1, 1, 1 }; - int data3[DIM_ARRY + 1] = { 1, 1, 1, 1 }; - int data1_dim2[DIM_ARRY][1] = { { 0 }, { 0 }, { 0 } }; - int rank_attr; - char data1_str[DIM_ARRY][STR_SIZE] = { "ab", "cd", "ef" }; - herr_t status = SUCCEED; - void *dset_data_ptr1 = NULL; - void *dset_data_ptr2 = NULL; - void *dset_data_ptr3 = NULL; - void *attr_data_ptr1 = NULL; - void *attr_data_ptr2 = NULL; - void *attr_data_ptr3 = NULL; - void *attr_data_ptr4 = NULL; - void *attr2_dim_ptr = NULL; - void *attr3_dim_ptr = NULL; + hid_t fid = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t did1 = H5I_INVALID_HID; + hid_t did2 = H5I_INVALID_HID; + hid_t sid1 = H5I_INVALID_HID; + hid_t tid_dset1 = H5I_INVALID_HID; + hid_t tid_attr1 = H5I_INVALID_HID; + hsize_t dims1_1[1] = {DIM_ARRY}; + hsize_t dims1_2[1] = {DIM_ARRY + 1}; + hsize_t dims2[2] = {DIM_ARRY, 1}; + int data1[DIM_ARRY] = {0, 0, 0}; + int data2[DIM_ARRY] = {1, 1, 1}; + int data3[DIM_ARRY + 1] = {1, 1, 1, 1}; + int data1_dim2[DIM_ARRY][1] = {{0}, {0}, {0}}; + int rank_attr; + char data1_str[DIM_ARRY][STR_SIZE] = {"ab", "cd", "ef"}; + herr_t status = SUCCEED; + void * dset_data_ptr1 = NULL; + void * dset_data_ptr2 = NULL; + void * dset_data_ptr3 = NULL; + void * attr_data_ptr1 = NULL; + void * attr_data_ptr2 = NULL; + void * attr_data_ptr3 = NULL; + void * attr_data_ptr4 = NULL; + void * attr2_dim_ptr = NULL; + void * attr3_dim_ptr = NULL; /* init */ - tid_dset1 = H5Tcopy(H5T_NATIVE_INT); - dset_data_ptr1 = (int*) &data1; - dset_data_ptr2 = (int*) &data1; - dset_data_ptr3 = (int*) &data1; - tid_attr1 = H5Tcopy(H5T_NATIVE_INT); - attr_data_ptr1 = (int*) &data1; - attr_data_ptr3 = (int*) &data1; - attr_data_ptr4 = (int*) &data1; - attr2_dim_ptr = (hsize_t*) &dims1_1; - attr3_dim_ptr = (hsize_t*) &dims1_1; - rank_attr = 1; + tid_dset1 = H5Tcopy(H5T_NATIVE_INT); + dset_data_ptr1 = (int *)&data1; + dset_data_ptr2 = (int *)&data1; + dset_data_ptr3 = (int *)&data1; + tid_attr1 = H5Tcopy(H5T_NATIVE_INT); + attr_data_ptr1 = (int *)&data1; + attr_data_ptr3 = (int *)&data1; + attr_data_ptr4 = (int *)&data1; + attr2_dim_ptr = (hsize_t *)&dims1_1; + attr3_dim_ptr = (hsize_t *)&dims1_1; + rank_attr = 1; if (make_diffs) { /* ------------ - * group1 */ + * group1 */ tid_dset1 = H5Tcopy(H5T_C_S1); - H5Tset_size(tid_dset1, (size_t) STR_SIZE); - dset_data_ptr1 = (char*) &data1_str; - dset_data_ptr2 = (int*) &data2; - attr_data_ptr1 = (int*) &data2; + H5Tset_size(tid_dset1, (size_t)STR_SIZE); + dset_data_ptr1 = (char *)&data1_str; + dset_data_ptr2 = (int *)&data2; + attr_data_ptr1 = (int *)&data2; /* ----------- - * group2 - */ - dset_data_ptr3 = (int*) &data2; + * group2 + */ + dset_data_ptr3 = (int *)&data2; /* dset1/attr1 */ tid_attr1 = H5Tcopy(H5T_C_S1); - H5Tset_size(tid_attr1, (size_t) STR_SIZE); - attr_data_ptr2 = (char*) &data1_str; + H5Tset_size(tid_attr1, (size_t)STR_SIZE); + attr_data_ptr2 = (char *)&data1_str; /* dset1/attr2 */ - attr2_dim_ptr = (hsize_t*) &dims1_2; + attr2_dim_ptr = (hsize_t *)&dims1_2; /* dset1/attr3 */ - attr_data_ptr3 = (int*) &data1_dim2; - attr3_dim_ptr = (hsize_t*) &dims2; - rank_attr = 2; + attr_data_ptr3 = (int *)&data1_dim2; + attr3_dim_ptr = (hsize_t *)&dims2; + rank_attr = 2; /* dset1/attr4 */ - attr_data_ptr4 = (int*) &data2; - + attr_data_ptr4 = (int *)&data2; } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname); @@ -4805,8 +4796,8 @@ static void test_data_nocomparables(const char * fname, int make_diffs) } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname); @@ -4822,8 +4813,8 @@ static void test_data_nocomparables(const char * fname, int make_diffs) } /*----------------------------------------------------------------------- - * Datasets in /g1 - *------------------------------------------------------------------------*/ + * Datasets in /g1 + *------------------------------------------------------------------------*/ if ((sid1 = H5Screate_simple(1, dims1_1, NULL)) < 0) goto out; @@ -4849,10 +4840,10 @@ static void test_data_nocomparables(const char * fname, int make_diffs) } /*----------------------------------------------------------------------- - * Datasets in /g2 - *------------------------------------------------------------------------*/ + * Datasets in /g2 + *------------------------------------------------------------------------*/ /* --------- - * dset1 */ + * dset1 */ if ((did2 = H5Dcreate2(gid2, "dset1", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1"); status = FAIL; @@ -4868,16 +4859,16 @@ static void test_data_nocomparables(const char * fname, int make_diffs) write_attr(did2, 1, dims1_1, "attr1", tid_attr1, attr_data_ptr2); /* attr2 - non-compatible : same rank, different dimention */ - write_attr(did2, 1, (hsize_t *) attr2_dim_ptr, "attr2", H5T_NATIVE_INT, data3); + write_attr(did2, 1, (hsize_t *)attr2_dim_ptr, "attr2", H5T_NATIVE_INT, data3); /* attr3 - non-compatible : different rank */ - write_attr(did2, rank_attr, (hsize_t *) attr3_dim_ptr, "attr3", H5T_NATIVE_INT, attr_data_ptr3); + write_attr(did2, rank_attr, (hsize_t *)attr3_dim_ptr, "attr3", H5T_NATIVE_INT, attr_data_ptr3); /* attr4 - compatible : different data values */ write_attr(did2, 1, dims1_1, "attr4", H5T_NATIVE_INT, attr_data_ptr4); /*---------- - * dset2 */ + * dset2 */ status = write_dset(gid2, 1, dims1_1, "dset2", H5T_NATIVE_INT, dset_data_ptr3); if (status == FAIL) { HDfprintf(stderr, "Error: %s> write_dset failed\n", fname); @@ -4887,8 +4878,8 @@ static void test_data_nocomparables(const char * fname, int make_diffs) out: /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ + * Close IDs + *-----------------------------------------------------------------------*/ if (fid) H5Fclose(fid); if (gid1) @@ -4918,95 +4909,96 @@ out: static void test_objs_nocomparables(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t topgid1 = H5I_INVALID_HID; - hid_t topgid2 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID; - hid_t tid1 = H5I_INVALID_HID; - hid_t gid2 = H5I_INVALID_HID; - hid_t tid2 = H5I_INVALID_HID; - hsize_t dims[1] = { DIM_ARRY }; - int data1[DIM_ARRY] = { 1, 1, 1 }; - int data2[DIM_ARRY] = { 2, 2, 2 }; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t topgid1 = H5I_INVALID_HID; + hid_t topgid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t tid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t tid2 = H5I_INVALID_HID; + hsize_t dims[1] = {DIM_ARRY}; + int data1[DIM_ARRY] = {1, 1, 1}; + int data2[DIM_ARRY] = {2, 2, 2}; /*----------------------------------------------------------------------- - * Open file(s) to add objects - *------------------------------------------------------------------------*/ + * Open file(s) to add objects + *------------------------------------------------------------------------*/ /* file1 */ - if((fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) PROGRAM_ERROR; /* file2 */ - if((fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) PROGRAM_ERROR; /*----------------------------------------------------------------------- - * in file1 : add member objects - *------------------------------------------------------------------------*/ + * in file1 : add member objects + *------------------------------------------------------------------------*/ /* parent group */ - if((topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) PROGRAM_ERROR; /* dataset */ - if(write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1) < 0) + if (write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1) < 0) PROGRAM_ERROR; /* group */ - if((gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) PROGRAM_ERROR; /* committed type */ - if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) PROGRAM_ERROR; - if(H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) PROGRAM_ERROR; /*----------------------------------------------------------------------- - * in file2 : add member objects - *------------------------------------------------------------------------*/ + * in file2 : add member objects + *------------------------------------------------------------------------*/ /* parent group */ - if((topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) PROGRAM_ERROR; /* group */ - if((gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) PROGRAM_ERROR; /* committed type */ - if((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) PROGRAM_ERROR; - if(H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) PROGRAM_ERROR; /* dataset */ - if(write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2) < 0) + if (write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2) < 0) PROGRAM_ERROR; /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ - if(H5Fclose(fid1) < 0) + * Close IDs + *-----------------------------------------------------------------------*/ + if (H5Fclose(fid1) < 0) PROGRAM_ERROR; - if(H5Fclose(fid2) < 0) + if (H5Fclose(fid2) < 0) PROGRAM_ERROR; - if(H5Gclose(topgid1) < 0) + if (H5Gclose(topgid1) < 0) PROGRAM_ERROR; - if(H5Gclose(topgid2) < 0) + if (H5Gclose(topgid2) < 0) PROGRAM_ERROR; - if(H5Gclose(gid1) < 0) + if (H5Gclose(gid1) < 0) PROGRAM_ERROR; - if(H5Gclose(gid2) < 0) + if (H5Gclose(gid2) < 0) PROGRAM_ERROR; - if(H5Tclose(tid1) < 0) + if (H5Tclose(tid1) < 0) PROGRAM_ERROR; - if(H5Tclose(tid2) < 0) + if (H5Tclose(tid2) < 0) PROGRAM_ERROR; return; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid1); H5Fclose(fid2); H5Gclose(topgid1); @@ -5015,18 +5007,20 @@ error: H5Gclose(gid2); H5Tclose(tid1); H5Tclose(tid2); - } H5E_END_TRY; + } + H5E_END_TRY; return; } -static hid_t mkstr(int size, H5T_str_t pad) +static hid_t +mkstr(int size, H5T_str_t pad) { hid_t type; if ((type = H5Tcopy(H5T_C_S1)) < 0) return -1; - if (H5Tset_size(type, (size_t) size) < 0) + if (H5Tset_size(type, (size_t)size) < 0) return -1; if (H5Tset_strpad(type, pad) < 0) return -1; @@ -5042,51 +5036,44 @@ static hid_t mkstr(int size, H5T_str_t pad) * types. * h5diff should show differences output from these common objects. *-------------------------------------------------------------------------*/ -static void test_objs_strings(const char *fname1, const char *fname2) +static void +test_objs_strings(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID; - hid_t fid2 = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t f_type = H5I_INVALID_HID; - hid_t m_type = H5I_INVALID_HID; - hsize_t dims1[] = { 3, 4 }; - char string1A[12][3] = { "s1", "s2", "s3", "s4", "s5", "s6", "s", "s", "s9", - "s0", "s1", "s2" }; - char string1B[12][3] = { "s1", "s2", "s3", "s4", "s", "s", "s7", "s8", "s9", - "s0", "s1", "s2" }; - - hsize_t dims2[] = { 20 }; - char string2A[20][10] = { "ab cd ef1", "ab cd ef2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd 9", "ab cd 0", "ab cd 1", "ab cd 2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0" }; - char string2B[20][10] = { "ab cd ef1", "ab cd ef2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2", "ab cd 3", - "ab cd 4", "ab cd 5", "ab cd 6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0" }; - - hsize_t dims3[] = { 27 }; - char string3A[27][6] = { "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", - "abcd5", "abcd6", "abcd7", "abcd8", "abcd9", "abcd0", "abcd1", - "abd2", "abc3", "bcd4", "acd5", "abcd6", "abcd7", "abcd8", "abcd9", - "abcd0", "abcd1", "abcd2", "abcd3", "abc4", "abc5", "abc6" }; - char string3B[27][6] = { "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", - "abcd5", "abcd6", "abcd7", "abcd8", "abcd9", "abcd0", "abcd1", - "abcd2", "abcd3", "abcd4", "abcd5", "abd6", "abc7", "bcd8", "acd9", - "abcd0", "abcd1", "abcd2", "abcd3", "abd4", "abd5", "abd6" }; - - hsize_t dims4[] = { 3 }; - char string4A[3][21] = { "s1234567890123456789", "s1234567890123456789", - "s12345678901234567" }; - char string4B[3][21] = { "s1234567890123456789", "s12345678901234567", - "s1234567890123456789" }; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; + hid_t m_type = H5I_INVALID_HID; + hsize_t dims1[] = {3, 4}; + char string1A[12][3] = {"s1", "s2", "s3", "s4", "s5", "s6", "s", "s", "s9", "s0", "s1", "s2"}; + char string1B[12][3] = {"s1", "s2", "s3", "s4", "s", "s", "s7", "s8", "s9", "s0", "s1", "s2"}; + + hsize_t dims2[] = {20}; + char string2A[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd 9", "ab cd 0", + "ab cd 1", "ab cd 2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + char string2B[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0", + "ab cd ef1", "ab cd ef2", "ab cd 3", "ab cd 4", "ab cd 5", + "ab cd 6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + + hsize_t dims3[] = {27}; + char string3A[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", "abcd8", + "abcd9", "abcd0", "abcd1", "abd2", "abc3", "bcd4", "acd5", "abcd6", "abcd7", + "abcd8", "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abc4", "abc5", "abc6"}; + char string3B[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", "abcd8", + "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abd6", "abc7", + "bcd8", "acd9", "abcd0", "abcd1", "abcd2", "abcd3", "abd4", "abd5", "abd6"}; + + hsize_t dims4[] = {3}; + char string4A[3][21] = {"s1234567890123456789", "s1234567890123456789", "s12345678901234567"}; + char string4B[3][21] = {"s1234567890123456789", "s12345678901234567", "s1234567890123456789"}; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* file1 */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -5102,9 +5089,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) } /* string 1 : nullterm string */ - space = H5Screate_simple(2, dims1, NULL); - f_type = mkstr(5, H5T_STR_NULLTERM); - m_type = mkstr(3, H5T_STR_NULLTERM); + space = H5Screate_simple(2, dims1, NULL); + f_type = mkstr(5, H5T_STR_NULLTERM); + m_type = mkstr(3, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string1A); H5Dclose(dataset); @@ -5116,9 +5103,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 2 : space pad string */ - space = H5Screate_simple(1, dims2, NULL); - f_type = mkstr(11, H5T_STR_SPACEPAD); - m_type = mkstr(10, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims2, NULL); + f_type = mkstr(11, H5T_STR_SPACEPAD); + m_type = mkstr(10, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string2", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string2A); H5Dclose(dataset); @@ -5130,9 +5117,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 3 : null pad string */ - space = H5Screate_simple(1, dims3, NULL); - f_type = mkstr(8, H5T_STR_NULLPAD); - m_type = mkstr(6, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims3, NULL); + f_type = mkstr(8, H5T_STR_NULLPAD); + m_type = mkstr(6, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string3", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string3A); H5Dclose(dataset); @@ -5144,9 +5131,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 4 : space pad long string */ - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_SPACEPAD); - m_type = mkstr(21, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims4, NULL); + f_type = mkstr(168, H5T_STR_SPACEPAD); + m_type = mkstr(21, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string4", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4A); H5Dclose(dataset); @@ -5172,10 +5159,10 @@ static void test_objs_strings(const char *fname1, const char *fname2) string4B[2][11] = 'a'; string4B[2][12] = 'B'; string4B[2][13] = 'c'; - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_NULLTERM); - m_type = mkstr(21, H5T_STR_NULLTERM); - dataset = H5Dcreate2(fid1, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims4, NULL); + f_type = mkstr(168, H5T_STR_NULLTERM); + m_type = mkstr(21, H5T_STR_NULLTERM); + dataset = H5Dcreate2(fid1, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4A); H5Dclose(dataset); dataset = H5Dcreate2(fid2, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -5187,8 +5174,8 @@ static void test_objs_strings(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ + * Close IDs + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -5203,78 +5190,77 @@ out: * *------------------------------------------------------------------------- */ -static -void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_attr_strings(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t aid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; herr_t H5_ATTR_NDEBUG_UNUSED status; - int val, i, j, k, l, n; - float f; + int val, i, j, k, l, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, RED }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0F}, {3, 4.0F}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2] = {RED, RED}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1.0F, 2.0F}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - e_t buf452[3][2]; /* enum */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0F}, {3, 4.0F}, {5, 6.0F}, {7, 8.0F}, {9, 10.0F}, {11, 12.0F}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + e_t buf452[3][2]; /* enum */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1.0F, 2.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - e_t buf453[4][3][2]; /* enum */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - /*------------------------------------------------------------------------- - * 1D attributes - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -5296,20 +5282,20 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 1, dims, "string", tid, buf1a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 1, dims, "VLstring", tid, buf1); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -5331,9 +5317,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf2[2]= {1,2}; @@ -5347,15 +5333,15 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 ] 2 0 2 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -5383,13 +5369,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } @@ -5423,18 +5409,18 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } /* $h5diff file7.h5 file6.h5 g1 g1 -v @@ -5446,9 +5432,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 ] 3 0 3 */ - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf5); assert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); @@ -5550,13 +5536,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 2, dims2, "string2D", tid, buf12a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 2, dims2, "VLstring2D", tid, buf12); status = H5Tclose(tid); @@ -5603,7 +5589,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); @@ -5643,8 +5629,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, - (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } @@ -5686,13 +5671,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make n = 0; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } @@ -5712,9 +5697,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 2 1 ] 11 0 11 */ - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf52); assert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); @@ -5873,13 +5858,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 3, dims3, "string3D", tid, buf13a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 3, dims3, "VLstring3D", tid, buf13); status = H5Tclose(tid); @@ -5895,7 +5880,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; /* position bitfield3D of bitfield3D of difference @@ -5934,7 +5919,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); @@ -5951,8 +5936,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make if (make_diffs) { buf33[i][j][k].a = 0; buf33[i][j][k].b = 0.0F; - } else { - buf33[i][j][k].a = (char) n++; + } + else { + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } /*position compound3D of compound3D of difference @@ -6022,8 +6008,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, - H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } @@ -6085,13 +6070,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } /* position vlen3D of vlen3D of difference @@ -6108,9 +6093,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 1 0 ] 10 0 10 etc */ - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf53); assert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); @@ -6125,7 +6110,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make */ n = 1; for (i = 0; i < 24; i++) { - for (j = 0; j < (int) dimarray[0]; j++) { + for (j = 0; j < (int)dimarray[0]; j++) { if (make_diffs) buf63[i][j] = 0; else @@ -6194,78 +6179,77 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make * *------------------------------------------------------------------------- */ -static -void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_attr_in(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t aid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; herr_t H5_ATTR_NDEBUG_UNUSED status; - int val, i, j, k, l, n; - float f; + int val, i, j, k, l, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, RED }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0F}, {3, 4.0F}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2] = {RED, RED}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1.0F, 2.0F}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - e_t buf452[3][2]; /* enum */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0F}, {3, 4.0F}, {5, 6.0F}, {7, 8.0F}, {9, 10.0F}, {11, 12.0F}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + e_t buf452[3][2]; /* enum */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1.0F, 2.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - e_t buf453[4][3][2]; /* enum */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - /*------------------------------------------------------------------------- - * 1D attributes - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -6283,22 +6267,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] d z [ 1 ] e z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 1, dims, "VLstring", tid, buf1a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -6320,9 +6304,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf2[2]= {1,2}; @@ -6336,15 +6320,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] 2 0 2 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -6371,20 +6355,20 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) buf45[i] = GREEN; @@ -6405,24 +6389,24 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } /* $h5diff file7.h5 file6.h5 g1 g1 -v @@ -6434,9 +6418,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] 3 0 3 */ - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf5); assert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); @@ -6446,9 +6430,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 2; i++) @@ -6474,9 +6458,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 2; i++) { @@ -6502,14 +6486,14 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_attr(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); /*------------------------------------------------------------------------- - * 2D attributes - *------------------------------------------------------------------------- - */ + * 2D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) @@ -6537,8 +6521,8 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 1 ] l z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); @@ -6546,15 +6530,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 2, dims2, "VLstring2D", tid, buf12a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf22, 0, sizeof buf22); @@ -6577,9 +6561,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf22[3][2]= {{1,2},{3,4},{5,6}}; @@ -6594,15 +6578,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf32, 0, sizeof buf32); /* @@ -6626,21 +6610,21 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) { if (make_diffs) @@ -6668,21 +6652,21 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } @@ -6702,9 +6686,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 1 ] 11 0 11 */ - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf52); assert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); @@ -6714,9 +6698,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf62, 0, sizeof buf62); @@ -6751,9 +6735,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) { memset(buf72, 0, sizeof buf72); @@ -6785,14 +6769,14 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_attr(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); /*------------------------------------------------------------------------- - * 3D attributes - *------------------------------------------------------------------------- - */ + * 3D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 4; i++) @@ -6859,8 +6843,8 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 3 2 1 ] Z z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); @@ -6868,15 +6852,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 3, dims3, "VLstring3D", tid, buf13a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -6885,7 +6869,7 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; } /* position bitfield3D of bitfield3D of difference @@ -6921,18 +6905,18 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -6943,7 +6927,7 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf33[i][j][k].b = 0.0F; } else { - buf33[i][j][k].a = (char) n++; + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } } @@ -7006,23 +6990,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, - H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) @@ -7068,22 +7051,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } /* position vlen3D of vlen3D of difference @@ -7100,9 +7083,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 1 0 ] 10 0 10 etc */ - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf53); assert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); @@ -7112,12 +7095,12 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 24; i++) - for (j = 0; j < (int) dimarray[0]; j++) { + for (j = 0; j < (int)dimarray[0]; j++) { if (make_diffs) buf63[i][j] = 0; else @@ -7141,9 +7124,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ n = 1; f = 1; for (i = 0; i < 4; i++) @@ -7185,77 +7168,76 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff * *------------------------------------------------------------------------- */ -static -void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_dset_in(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t did = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; herr_t H5_ATTR_NDEBUG_UNUSED status; - int val, i, j, k, l, n; - float f; - int fillvalue = 2; - int scalar_data = 2; + int val, i, j, k, l, n; + float f; + int fillvalue = 2; + int scalar_data = 2; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, GREEN }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0F}, {3, 4.0F}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2] = {RED, GREEN}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1.0F, 2.0F}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0F}, {3, 4.0F}, {5, 6.0F}, {7, 8.0F}, {9, 10.0F}, {11, 12.0F}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1.0F, 2.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ if (make_diffs == 2) dimarray[0] = 4; /*------------------------------------------------------------------------- - * H5S_SCALAR - *------------------------------------------------------------------------- - */ + * H5S_SCALAR + *------------------------------------------------------------------------- + */ if (make_diffs) scalar_data = 1; @@ -7274,37 +7256,37 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff H5Sclose(sid); /*------------------------------------------------------------------------- - * 1D - *------------------------------------------------------------------------- - */ + * 1D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) buf1[i][j] = 'z'; - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 1, dims, "VLstring", tid, buf1a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7315,9 +7297,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -7325,15 +7307,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf3[i].b = 0; } - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7346,27 +7328,27 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_DATASET_REGION dataset region reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_DATASET_REGION dataset region reference) + *------------------------------------------------------------------------- + */ gen_datareg(fid, make_diffs); /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); @@ -7374,30 +7356,29 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); HDassert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); @@ -7407,9 +7388,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7421,21 +7402,21 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); { - double *dbuf; /* information to write */ - hid_t ldid = H5I_INVALID_HID; /* dataset ID */ - hid_t lsid = H5I_INVALID_HID; /* dataspace ID */ - hid_t ltid = H5I_INVALID_HID; /* datatype ID */ - size_t size; - hsize_t sdims[] = { 1 }; - hsize_t tdims[] = { H5TOOLS_MALLOCSIZE / sizeof(double) + 1 }; - size_t jj; + double *dbuf; /* information to write */ + hid_t ldid = H5I_INVALID_HID; /* dataset ID */ + hid_t lsid = H5I_INVALID_HID; /* dataspace ID */ + hid_t ltid = H5I_INVALID_HID; /* datatype ID */ + size_t size; + hsize_t sdims[] = {1}; + hsize_t tdims[] = {H5TOOLS_MALLOCSIZE / sizeof(double) + 1}; + size_t jj; /* allocate and initialize array data to write */ size = (H5TOOLS_MALLOCSIZE / sizeof(double) + 1) * sizeof(double); - dbuf = (double *) HDmalloc(size); + dbuf = (double *)HDmalloc(size); for (jj = 0; jj < (H5TOOLS_MALLOCSIZE / sizeof(double) + 1); jj++) - dbuf[jj] = (double) jj; + dbuf[jj] = (double)jj; if (make_diffs) { dbuf[5] = 0; @@ -7459,9 +7440,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff } /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -7473,14 +7454,14 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_dset(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); /*------------------------------------------------------------------------- - * 2D - *------------------------------------------------------------------------- - */ + * 2D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 3; i++) @@ -7489,8 +7470,8 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf12[i][j][k] = 'z'; } - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); @@ -7498,15 +7479,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 2, dims2, "VLstring2D", tid, buf12a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf22, 0, sizeof buf22); @@ -7516,18 +7497,18 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf32, 0, sizeof buf32); @@ -7539,21 +7520,21 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); @@ -7562,27 +7543,27 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) { if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52); assert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); @@ -7592,9 +7573,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf62, 0, sizeof buf62); @@ -7604,40 +7585,40 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ if (make_diffs) { memset(buf72, 0, sizeof buf72); memset(buf82, 0, sizeof buf82); } - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); status = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue); - sid = H5Screate_simple(2, dims2, NULL); - did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); status = H5Pclose(dcpl); status = H5Dclose(did); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_FLOAT + *------------------------------------------------------------------------- + */ write_dset(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); /*------------------------------------------------------------------------- - * 3D - *------------------------------------------------------------------------- - */ + * 3D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 4; i++) @@ -7647,8 +7628,8 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf13[i][j][k][l] = 'z'; } - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); @@ -7657,15 +7638,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 3, dims3, "VLstring3D", tid, buf13a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -7674,7 +7655,7 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; } tid = H5Tcopy(H5T_STD_B8LE); @@ -7682,18 +7663,18 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -7704,7 +7685,7 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf33[i][j][k].b = 0.0F; } else { - buf33[i][j][k].a = (char) n++; + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } } @@ -7716,22 +7697,22 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); @@ -7740,28 +7721,28 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) { if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } } - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53); assert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); @@ -7771,9 +7752,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 24; i++) @@ -7789,9 +7770,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ n = 1; f = 1; for (i = 0; i < 4; i++) @@ -7821,44 +7802,43 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff *------------------------------------------------------------------------- */ -static -void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) { /* data dataset */ - hid_t did1 = H5I_INVALID_HID; /* dataset ID */ - hid_t sid1 = H5I_INVALID_HID; /* dataspace ID */ - hsize_t dims1[2] = { 10, 10 };/* dimensions */ - int *buf; /* dataset buffer */ + hid_t did1 = H5I_INVALID_HID; /* dataset ID */ + hid_t sid1 = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims1[2] = {10, 10}; /* dimensions */ + int * buf; /* dataset buffer */ /* reference dataset */ - hid_t did2 = H5I_INVALID_HID; /* dataset ID */ - hid_t sid2 = H5I_INVALID_HID; /* dataspace ID */ - hsize_t dims2[] = { 2 }; /* 2 references */ - hdset_reg_ref_t *rbuf; /* buffer for write the references */ - hsize_t start[10]; /* starting location of hyperslab */ - hsize_t count[10]; /* element count of hyperslab */ - hsize_t coord[5][2]; /* coordinates for point selection */ + hid_t did2 = H5I_INVALID_HID; /* dataset ID */ + hid_t sid2 = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims2[] = {2}; /* 2 references */ + hdset_reg_ref_t * rbuf; /* buffer for write the references */ + hsize_t start[10]; /* starting location of hyperslab */ + hsize_t count[10]; /* element count of hyperslab */ + hsize_t coord[5][2]; /* coordinates for point selection */ herr_t H5_ATTR_NDEBUG_UNUSED status; - int i; + int i; /* allocate the buffer for write the references */ - rbuf = (hdset_reg_ref_t *) HDcalloc((size_t )2, sizeof(hdset_reg_ref_t)); + rbuf = (hdset_reg_ref_t *)HDcalloc((size_t)2, sizeof(hdset_reg_ref_t)); /* allocate the buffer for write the data dataset */ - buf = (int *) HDmalloc(10 * 10 * sizeof(int)); + buf = (int *)HDmalloc(10 * 10 * sizeof(int)); for (i = 0; i < 10 * 10; i++) buf[i] = i; /* create the data dataset */ - sid1 = H5Screate_simple(2, dims1, NULL); - did1 = H5Dcreate2(fid, "dsetref", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid1 = H5Screate_simple(2, dims1, NULL); + did1 = H5Dcreate2(fid, "dsetref", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); HDassert(status >= 0); /* create the reference dataset */ sid2 = H5Screate_simple(1, dims2, NULL); - did2 = H5Dcreate2(fid, "refreg", H5T_STD_REF_DSETREG, sid2, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + did2 = H5Dcreate2(fid, "refreg", H5T_STD_REF_DSETREG, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* create the references */ /* select hyperslab for first reference */ @@ -7901,7 +7881,7 @@ void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) coord[4][0] = 1; coord[4][1] = 7; } - H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t) 5, (const hsize_t *) coord); + H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)5, (const hsize_t *)coord); H5Sget_select_npoints(sid1); /* store second dataset region */ @@ -7933,25 +7913,25 @@ void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) * *------------------------------------------------------------------------- */ -static -int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buffers */) +static int +test_hyperslab(const char *fname, int make_diffs /* flag to modify data buffers */) { - hid_t did = H5I_INVALID_HID; - hid_t fid = H5I_INVALID_HID; - hid_t f_sid = H5I_INVALID_HID; - hid_t m_sid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[1] = { GBLL }; /* dataset dimensions */ - hsize_t hs_size[1] = { GBLL / (1024 * 1024) }; /* hyperslab dimensions */ - hsize_t chunk_dims[1] = { GBLL / 1024 }; /* chunk dimensions */ + hid_t did = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t f_sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[1] = {GBLL}; /* dataset dimensions */ + hsize_t hs_size[1] = {GBLL / (1024 * 1024)}; /* hyperslab dimensions */ + hsize_t chunk_dims[1] = {GBLL / 1024}; /* chunk dimensions */ hsize_t hs_start[1]; - size_t size; - size_t nelmts = (size_t)GBLL / (1024 * 1024); /* elements in each hyperslab */ - char fillvalue = -1; - char *buf = NULL; - int i, j, s; - char c; + size_t size; + size_t nelmts = (size_t)GBLL / (1024 * 1024); /* elements in each hyperslab */ + char fillvalue = -1; + char * buf = NULL; + int i, j, s; + char c; /* create */ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -7973,8 +7953,8 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff goto out; /* create a evenly divided buffer from 0 to 127 */ - buf = (char *) HDmalloc((size_t)(nelmts * size)); - s = 1024 * 1024 / 127; + buf = (char *)HDmalloc((size_t)(nelmts * size)); + s = 1024 * 1024 / 127; for (i = 0, j = 0, c = 0; i < 1024 * 1024; j++, i++) { if (j == s) { c++; @@ -7988,7 +7968,7 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff if (make_diffs && i == 512 * 512) HDmemset(buf, 0, nelmts); - hs_start[0] = (unsigned long long) i * GBLL / (1024 * 1024); + hs_start[0] = (unsigned long long)i * GBLL / (1024 * 1024); if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, hs_start, NULL, hs_size, NULL) < 0) goto out; @@ -8015,13 +7995,15 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(f_sid); H5Sclose(m_sid); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } @@ -8030,51 +8012,53 @@ out: * * Purpose: Create test files to compare data with epsilion */ -static -void test_double_epsilon(const char *fname1, const char *fname2) +static void +test_double_epsilon(const char *fname1, const char *fname2) { - hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; - hsize_t dims1[2] = { 4, 7 }; - hsize_t dims2[2] = { 4, 7 }; - double wdata[4][7]; - int i, j; + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; + hsize_t dims1[2] = {4, 7}; + hsize_t dims2[2] = {4, 7}; + double wdata[4][7]; + int i, j; /*------------------------------------------------------------------------- - * create two files - *------------------------------------------------------------------------- - */ + * create two files + *------------------------------------------------------------------------- + */ if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) PROGRAM_ERROR; if ((fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) PROGRAM_ERROR; /* - * Initialize data. - */ - for (i=0; i<4; i++) - for (j=0; j<7; j++) + * Initialize data. + */ + for (i = 0; i < 4; i++) + for (j = 0; j < 7; j++) wdata[i][j] = 0.0; /* dataset */ - if(write_dset(fid1, 2, dims1, "dataset", H5T_IEEE_F64LE, wdata) < 0) + if (write_dset(fid1, 2, dims1, "dataset", H5T_IEEE_F64LE, wdata) < 0) PROGRAM_ERROR; /* - * Initialize data. - */ - for (i=0; i<4; i++) - for (j=0; j<7; j++) + * Initialize data. + */ + for (i = 0; i < 4; i++) + for (j = 0; j < 7; j++) wdata[i][j] = (double)1.e-19; /* dataset */ - if(write_dset(fid2, 2, dims1, "dataset", H5T_IEEE_F64LE, wdata) < 0) + if (write_dset(fid2, 2, dims1, "dataset", H5T_IEEE_F64LE, wdata) < 0) PROGRAM_ERROR; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Fclose(fid1); H5Fclose(fid2); - } H5E_END_TRY; + } + H5E_END_TRY; return; } @@ -8086,8 +8070,8 @@ error: * *------------------------------------------------------------------------- */ -static -int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) +static int +write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) { hid_t aid = H5I_INVALID_HID; hid_t sid = H5I_INVALID_HID; @@ -8133,33 +8117,34 @@ write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, v hid_t sid = H5I_INVALID_HID; /* create a space */ - if((sid = H5Screate_simple(rank, dims, NULL)) < 0) + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) PROGRAM_ERROR; /* create the dataset */ - if((did = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) PROGRAM_ERROR; /* write */ - if(buf) - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (buf) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) PROGRAM_ERROR; /* close */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) PROGRAM_ERROR; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) PROGRAM_ERROR; return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } /* end write_dset() */ - diff --git a/tools/test/h5dump/binread.c b/tools/test/h5dump/binread.c index 6165cd8..171a5fd 100644 --- a/tools/test/h5dump/binread.c +++ b/tools/test/h5dump/binread.c @@ -27,9 +27,9 @@ */ -#define NELMTS 6 -#define TYPE int -#define FORMAT "%d " +#define NELMTS 6 +#define TYPE int +#define FORMAT "%d " /*------------------------------------------------------------------------- * Function: usage @@ -45,7 +45,7 @@ *------------------------------------------------------------------------- */ static void -usage (void) +usage(void) { fprintf(stderr, "usage: binread FILE_NAME\n"); } @@ -59,13 +59,13 @@ usage (void) */ int -main (int argc, const char *argv[]) +main(int argc, const char *argv[]) { - FILE *stream; + FILE * stream; size_t numread; TYPE buf[NELMTS]; size_t i, nelmts = NELMTS; - char *fname=NULL; + char * fname = NULL; if (argc != 2) { usage(); @@ -74,12 +74,12 @@ main (int argc, const char *argv[]) fname = strdup(argv[1]); - if((stream = fopen(fname, "rb")) != NULL) { - numread = fread(buf, sizeof( TYPE ), nelmts, stream); + if ((stream = fopen(fname, "rb")) != NULL) { + numread = fread(buf, sizeof(TYPE), nelmts, stream); printf("Number of items read = %llu\n", (unsigned long long)numread); for (i = 0; i < nelmts; i++) { - printf(FORMAT,buf[i]); + printf(FORMAT, buf[i]); } printf("\n"); @@ -92,4 +92,3 @@ main (int argc, const char *argv[]) return 0; } - diff --git a/tools/test/h5dump/dynlib_dump.c b/tools/test/h5dump/dynlib_dump.c index 661a6dc..32d2daf 100644 --- a/tools/test/h5dump/dynlib_dump.c +++ b/tools/test/h5dump/dynlib_dump.c @@ -17,25 +17,33 @@ #include #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIBUD, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ + "dynlibud", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*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) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ cd_values = cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = (int8_t)(temp - MULTIPLIER); + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = (int8_t)(temp + MULTIPLIER); + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index 731e233..a75ae61 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -25,96 +25,96 @@ #include "h5test.h" #include "h5tools.h" -#define FILE1 "tgroup.h5" -#define FILE2 "tdset.h5" -#define FILE3 "tattr.h5" -#define FILE4 "tslink.h5" -#define FILE4_1 "tsoftlinks.h5" -#define FILE5 "thlink.h5" -#define FILE6 "tcompound.h5" -#define FILE7 "tall.h5" -#define FILE8 "tdset2.h5" -#define FILE9 "tcompound2.h5" -#define FILE10 "tloop.h5" -#define FILE11 "tloop2.h5" -#define FILE12 "tmany.h5" -#define FILE13 "tstr.h5" -#define FILE14 "tstr2.h5" -#define FILE15 "tenum.h5" -#define FILE16 "tobjref.h5" -#define FILE17 "tdatareg.h5" -#define FILE18 "tnestedcomp.h5" -#define FILE19 "topaque.h5" -#define FILE20 "tbitfields.h5" -#define FILE21 "tvldtypes1.h5" -#define FILE22 "tvldtypes2.h5" -#define FILE23 "tvldtypes3.h5" -#define FILE24 "tvldtypes4.h5" -#define FILE25 "tarray1.h5" +#define FILE1 "tgroup.h5" +#define FILE2 "tdset.h5" +#define FILE3 "tattr.h5" +#define FILE4 "tslink.h5" +#define FILE4_1 "tsoftlinks.h5" +#define FILE5 "thlink.h5" +#define FILE6 "tcompound.h5" +#define FILE7 "tall.h5" +#define FILE8 "tdset2.h5" +#define FILE9 "tcompound2.h5" +#define FILE10 "tloop.h5" +#define FILE11 "tloop2.h5" +#define FILE12 "tmany.h5" +#define FILE13 "tstr.h5" +#define FILE14 "tstr2.h5" +#define FILE15 "tenum.h5" +#define FILE16 "tobjref.h5" +#define FILE17 "tdatareg.h5" +#define FILE18 "tnestedcomp.h5" +#define FILE19 "topaque.h5" +#define FILE20 "tbitfields.h5" +#define FILE21 "tvldtypes1.h5" +#define FILE22 "tvldtypes2.h5" +#define FILE23 "tvldtypes3.h5" +#define FILE24 "tvldtypes4.h5" +#define FILE25 "tarray1.h5" #define FILE25_BIG "tarray1_big.h5" -#define FILE26 "tarray2.h5" -#define FILE27 "tarray3.h5" -#define FILE28 "tarray4.h5" -#define FILE29 "tarray5.h5" -#define FILE30 "tarray6.h5" -#define FILE31 "tarray7.h5" -#define FILE32 "tempty.h5" -#define FILE33 "tgrp_comments.h5" -#define FILE34 "tsplit_file" -#define FILE35 "tfamily%05d.h5" -#define FILE36 "tmulti" -#define FILE37 "tlarge_objname.h5" -#define FILE38 "tvlstr.h5" -#define FILE39 "tchar.h5" -#define FILE40 "tattr2.h5" -#define FILE41 "tcompound_complex.h5" -#define FILE42 "tnamed_dtype_attr.h5" -#define FILE43 "tvldtypes5.h5" -#define FILE44 "tfilters.h5" -#define FILE45 "tnullspace.h5" -#define FILE46 "tfcontents1.h5" -#define FILE47 "tfcontents2.h5" -#define FILE48 "tfvalues.h5" -#define FILE49 "tstr3.h5" -#define FILE50 "taindices.h5" -#define FILE51 "tlonglinks.h5" -#define FILE52 "tldouble.h5" -#define FILE53 "textlink.h5" -#define FILE54 "tudlink.h5" -#define FILE55 "tbinary.h5" -#define FILE56 "tbigdims.h5" -#define FILE57 "thyperslab.h5" -#define FILE58 "tordergr.h5" -#define FILE59 "torderattr.h5" -#define FILE60 "tfpformat.h5" -#define FILE61 "textlinksrc.h5" -#define FILE62 "textlinktar.h5" -#define FILE63 "textlinkfar.h5" -#define FILE64 "tattrreg.h5" -#define FILE65 "file_space.h5" -#define FILE66 "packedbits.h5" -#define FILE67 "zerodim.h5" -#define FILE68 "charsets.h5" -#define FILE68a "tdset_idx.h5" -#define FILE69 "tattrintsize.h5" -#define FILE70 "tcmpdintsize.h5" -#define FILE71 "tcmpdattrintsize.h5" -#define FILE72 "tnestedcmpddt.h5" -#define FILE73 "tscalarintsize.h5" -#define FILE74 "tscalarattrintsize.h5" -#define FILE75 "tscalarstring.h5" -#define FILE76 "tcmpdintarray.h5" -#define FILE77 "tcmpdints.h5" -#define FILE78 "tscalarintattrsize.h5" -#define FILE79 "tintsattrs.h5" -#define FILE80 "tbitnopaque.h5" -#define FILE81 "tints4dims.h5" -#define FILE82 "tcompound_complex2.h5" -#define FILE83 "tvlenstr_array.h5" -#define FILE84 "tudfilter.h5" -#define FILE85 "tgrpnullspace.h5" -#define FILE86 "err_attr_dspace.h5" -#define FILE87 "tintsnodata.h5" +#define FILE26 "tarray2.h5" +#define FILE27 "tarray3.h5" +#define FILE28 "tarray4.h5" +#define FILE29 "tarray5.h5" +#define FILE30 "tarray6.h5" +#define FILE31 "tarray7.h5" +#define FILE32 "tempty.h5" +#define FILE33 "tgrp_comments.h5" +#define FILE34 "tsplit_file" +#define FILE35 "tfamily%05d.h5" +#define FILE36 "tmulti" +#define FILE37 "tlarge_objname.h5" +#define FILE38 "tvlstr.h5" +#define FILE39 "tchar.h5" +#define FILE40 "tattr2.h5" +#define FILE41 "tcompound_complex.h5" +#define FILE42 "tnamed_dtype_attr.h5" +#define FILE43 "tvldtypes5.h5" +#define FILE44 "tfilters.h5" +#define FILE45 "tnullspace.h5" +#define FILE46 "tfcontents1.h5" +#define FILE47 "tfcontents2.h5" +#define FILE48 "tfvalues.h5" +#define FILE49 "tstr3.h5" +#define FILE50 "taindices.h5" +#define FILE51 "tlonglinks.h5" +#define FILE52 "tldouble.h5" +#define FILE53 "textlink.h5" +#define FILE54 "tudlink.h5" +#define FILE55 "tbinary.h5" +#define FILE56 "tbigdims.h5" +#define FILE57 "thyperslab.h5" +#define FILE58 "tordergr.h5" +#define FILE59 "torderattr.h5" +#define FILE60 "tfpformat.h5" +#define FILE61 "textlinksrc.h5" +#define FILE62 "textlinktar.h5" +#define FILE63 "textlinkfar.h5" +#define FILE64 "tattrreg.h5" +#define FILE65 "file_space.h5" +#define FILE66 "packedbits.h5" +#define FILE67 "zerodim.h5" +#define FILE68 "charsets.h5" +#define FILE68a "tdset_idx.h5" +#define FILE69 "tattrintsize.h5" +#define FILE70 "tcmpdintsize.h5" +#define FILE71 "tcmpdattrintsize.h5" +#define FILE72 "tnestedcmpddt.h5" +#define FILE73 "tscalarintsize.h5" +#define FILE74 "tscalarattrintsize.h5" +#define FILE75 "tscalarstring.h5" +#define FILE76 "tcmpdintarray.h5" +#define FILE77 "tcmpdints.h5" +#define FILE78 "tscalarintattrsize.h5" +#define FILE79 "tintsattrs.h5" +#define FILE80 "tbitnopaque.h5" +#define FILE81 "tints4dims.h5" +#define FILE82 "tcompound_complex2.h5" +#define FILE83 "tvlenstr_array.h5" +#define FILE84 "tudfilter.h5" +#define FILE85 "tgrpnullspace.h5" +#define FILE86 "err_attr_dspace.h5" +#define FILE87 "tintsnodata.h5" /*------------------------------------------------------------------------- * prototypes @@ -122,60 +122,51 @@ */ /* utility functions */ -static int -make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t tid, hid_t dcpl, void *buf); -static int -write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, - hid_t tid, void *buf); -static int -write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, - hid_t tid, void *buf ); +static int make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t tid, hid_t dcpl, void *buf); +static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, hid_t tid, void *buf); +static int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf); /* a filter operation callback function */ -static size_t -myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf); +static size_t myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, + size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf); /* a "set local" callback */ -static herr_t -set_local_myfilter(hid_t dcpl_id, hid_t tid, hid_t H5_ATTR_UNUSED sid); +static herr_t set_local_myfilter(hid_t dcpl_id, hid_t tid, hid_t H5_ATTR_UNUSED sid); #define MYFILTER_ID 405 /* This message derives from H5Z */ const H5Z_class2_t H5Z_MYFILTER[1] = {{ - H5Z_CLASS_T_VERS, - MYFILTER_ID, /* Filter id number */ - 1, 1, - "myfilter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - set_local_myfilter, /* The "set local" callback */ - myfilter, /* The actual filter function */ + H5Z_CLASS_T_VERS, MYFILTER_ID, /* Filter id number */ + 1, 1, "myfilter", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + set_local_myfilter, /* The "set local" callback */ + myfilter, /* The actual filter function */ }}; -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIBUD, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ + "dynlibud", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ }}; - /* A UD link traversal function. Shouldn't actually be called. */ -static hid_t UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED hid_t cur_group, - H5_ATTR_UNUSED const void * udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id, - H5_ATTR_UNUSED hid_t dxpl_id) +static hid_t +UD_traverse(H5_ATTR_UNUSED const char *link_name, H5_ATTR_UNUSED hid_t cur_group, + H5_ATTR_UNUSED const void *udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id, + H5_ATTR_UNUSED hid_t dxpl_id) { return -1; } @@ -183,20 +174,19 @@ static hid_t UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED h #define MY_LINKCLASS 187 const H5L_class_t UD_link_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)MY_LINKCLASS, /* Link type id number */ - "UD link class", /* name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)MY_LINKCLASS, /* Link type id number */ + "UD link class", /* name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; - #define LENSTR 50 -#define LENSTR2 11 +#define LENSTR2 11 #define SPACE2_RANK 2 #define SPACE2_DIM1 10 @@ -207,8 +197,8 @@ const H5L_class_t UD_link_class[1] = {{ #define DIM1 20 #define DIM2 10 -#define CDIM1 DIM1/2 -#define CDIM2 DIM2/2 +#define CDIM1 DIM1 / 2 +#define CDIM2 DIM2 / 2 #define RANK 2 /* Dataspace of 0 dimension size */ @@ -219,22 +209,15 @@ const H5L_class_t UD_link_class[1] = {{ /* Element selection information */ #define POINT1_NPOINTS 10 -typedef enum{ - RED, - GREEN, - BLUE, - WHITE, - BLACK -} enumtype; +typedef enum { RED, GREEN, BLUE, WHITE, BLACK } enumtype; /* Compound datatype */ typedef struct s1_t { - unsigned int a; - unsigned int b; - float c; + unsigned int a; + unsigned int b; + float c; } s1_t; - /* 1-D array datatype */ #define ARRAY1_RANK 1 #define ARRAY1_DIM1 4 @@ -256,17 +239,17 @@ typedef struct s1_t { /* "File 41" macros */ /* Name of dataset to create in datafile */ -#define F41_DATASETNAME "CompoundComplex" +#define F41_DATASETNAME "CompoundComplex" /* Dataset dimensions */ -#define F41_LENGTH 6 -#define F41_RANK 1 -#define F41_ARRAY_RANK 1 -#define F41_ARRAY_RANKd 2 -#define F41_DIMb 4 -#define F41_ARRAY_DIMc 6 -#define F41_ARRAY_DIMd1 5 -#define F41_ARRAY_DIMd2 6 -#define F41_ARRAY_DIMf 10 +#define F41_LENGTH 6 +#define F41_RANK 1 +#define F41_ARRAY_RANK 1 +#define F41_ARRAY_RANKd 2 +#define F41_DIMb 4 +#define F41_ARRAY_DIMc 6 +#define F41_ARRAY_DIMd1 5 +#define F41_ARRAY_DIMd2 6 +#define F41_ARRAY_DIMf 10 /* "File 42" macros */ /* Name of dataset to create in datafile */ @@ -280,113 +263,113 @@ typedef struct s1_t { #define F43_DSETNAME "Dataset" /* "File 51" macros */ -#define F51_MAX_NAME_LEN ((64*1024)+1024) +#define F51_MAX_NAME_LEN ((64 * 1024) + 1024) /* "File 64" macros */ -#define F64_FILE "tarray8.h5" -#define F64_DATASET "DS1" -#define F64_DIM0 1 -#define F64_ARRAY_BUF_LEN (4*1024) -#define F64_DIM1 (F64_ARRAY_BUF_LEN / sizeof(int) + 1) +#define F64_FILE "tarray8.h5" +#define F64_DATASET "DS1" +#define F64_DIM0 1 +#define F64_ARRAY_BUF_LEN (4 * 1024) +#define F64_DIM1 (F64_ARRAY_BUF_LEN / sizeof(int) + 1) /* File 65 macros */ -#define STRATEGY H5F_FSPACE_STRATEGY_NONE /* File space handling strategy */ -#define THRESHOLD10 10 /* Free-space section threshold */ -#define FSPACE_PAGE_SIZE 8192 /* File space page size */ +#define STRATEGY H5F_FSPACE_STRATEGY_NONE /* File space handling strategy */ +#define THRESHOLD10 10 /* Free-space section threshold */ +#define FSPACE_PAGE_SIZE 8192 /* File space page size */ /* "FILE66" macros and for FILE69, FILE87 */ -#define F66_XDIM 8 -#define F66_DATASETU08 "DU08BITS" -#define F66_DATASETS08 "DS08BITS" -#define F66_YDIM8 8 -#define F66_DATASETU16 "DU16BITS" -#define F66_DATASETS16 "DS16BITS" -#define F66_YDIM16 16 -#define F66_DATASETU32 "DU32BITS" -#define F66_DATASETS32 "DS32BITS" -#define F66_YDIM32 32 -#define F66_DATASETU64 "DU64BITS" -#define F66_DATASETS64 "DS64BITS" -#define F66_YDIM64 64 -#define F66_DUMMYDBL "DummyDBL" +#define F66_XDIM 8 +#define F66_DATASETU08 "DU08BITS" +#define F66_DATASETS08 "DS08BITS" +#define F66_YDIM8 8 +#define F66_DATASETU16 "DU16BITS" +#define F66_DATASETS16 "DS16BITS" +#define F66_YDIM16 16 +#define F66_DATASETU32 "DU32BITS" +#define F66_DATASETS32 "DS32BITS" +#define F66_YDIM32 32 +#define F66_DATASETU64 "DU64BITS" +#define F66_DATASETS64 "DS64BITS" +#define F66_YDIM64 64 +#define F66_DUMMYDBL "DummyDBL" /* Declarations for gent_dataset_idx() for "FILE68a" */ #define F68a_DSET_FIXED "dset_fixed" -#define F68a_DSET_FIXED_FILTER "dset_filter" +#define F68a_DSET_FIXED_FILTER "dset_filter" #define F68a_DSET_BTREE "dset_btree" -#define F68a_DIM200 200 -#define F68a_DIM100 100 -#define F68a_DIM20 20 -#define F68a_DIM10 10 -#define F68a_CHUNK 5 +#define F68a_DIM200 200 +#define F68a_DIM100 100 +#define F68a_DIM20 20 +#define F68a_DIM10 10 +#define F68a_CHUNK 5 /* "FILE70" macros and for FILE71 */ /* Name of dataset to create in datafile */ -#define F70_DATASETNAME "CompoundIntSize" +#define F70_DATASETNAME "CompoundIntSize" #define F70_LENGTH 4 #define F70_RANK 1 #define F70_ARRAY_RANK 2 #define F70_XDIM 8 -#define F70_DATASETU08 "DU08BITS" -#define F70_DATASETS08 "DS08BITS" +#define F70_DATASETU08 "DU08BITS" +#define F70_DATASETS08 "DS08BITS" #define F70_YDIM8 8 -#define F70_DATASETU16 "DU16BITS" -#define F70_DATASETS16 "DS16BITS" +#define F70_DATASETU16 "DU16BITS" +#define F70_DATASETS16 "DS16BITS" #define F70_YDIM16 16 -#define F70_DATASETU32 "DU32BITS" -#define F70_DATASETS32 "DS32BITS" +#define F70_DATASETU32 "DU32BITS" +#define F70_DATASETS32 "DS32BITS" #define F70_YDIM32 32 -#define F70_DATASETU64 "DU64BITS" -#define F70_DATASETS64 "DS64BITS" +#define F70_DATASETU64 "DU64BITS" +#define F70_DATASETS64 "DS64BITS" #define F70_YDIM64 64 -#define F70_DUMMYDBL "DummyDBL" +#define F70_DUMMYDBL "DummyDBL" /* Name of dataset to create in datafile */ -#define F71_DATASETNAME "CompoundAttrIntSize" +#define F71_DATASETNAME "CompoundAttrIntSize" /* "FILE73" macros and for FILE69 and FILE78 */ -#define F73_ARRAY_RANK 2 -#define F73_XDIM 8 -#define F73_DATASETU08 "DU08BITS" -#define F73_DATASETS08 "DS08BITS" -#define F73_YDIM8 8 -#define F73_DATASETU16 "DU16BITS" -#define F73_DATASETS16 "DS16BITS" -#define F73_YDIM16 16 -#define F73_DATASETU32 "DU32BITS" -#define F73_DATASETS32 "DS32BITS" -#define F73_YDIM32 32 -#define F73_DATASETU64 "DU64BITS" -#define F73_DATASETS64 "DS64BITS" -#define F73_YDIM64 64 -#define F73_DUMMYDBL "DummyDBL" +#define F73_ARRAY_RANK 2 +#define F73_XDIM 8 +#define F73_DATASETU08 "DU08BITS" +#define F73_DATASETS08 "DS08BITS" +#define F73_YDIM8 8 +#define F73_DATASETU16 "DU16BITS" +#define F73_DATASETS16 "DS16BITS" +#define F73_YDIM16 16 +#define F73_DATASETU32 "DU32BITS" +#define F73_DATASETS32 "DS32BITS" +#define F73_YDIM32 32 +#define F73_DATASETU64 "DU64BITS" +#define F73_DATASETS64 "DS64BITS" +#define F73_YDIM64 64 +#define F73_DUMMYDBL "DummyDBL" /* "FILE76 and FILE77 */ /* Name of dataset to create in datafile */ -#define F76_DATASETNAME "CompoundIntArray" +#define F76_DATASETNAME "CompoundIntArray" #define F76_LENGTH 4 #define F76_RANK 1 #define F76_ARRAY_RANK 1 -#define F76_DATASETU08 "DU08BITS" -#define F76_DATASETS08 "DS08BITS" -#define F76_DIM8 8 -#define F76_DATASETU16 "DU16BITS" -#define F76_DATASETS16 "DS16BITS" -#define F76_DIM16 16 -#define F76_DATASETU32 "DU32BITS" -#define F76_DATASETS32 "DS32BITS" -#define F76_DIM32 32 -#define F76_DATASETU64 "DU64BITS" -#define F76_DATASETS64 "DS64BITS" -#define F76_DIM64 64 -#define F76_DUMMYDBL "DummyDBL" +#define F76_DATASETU08 "DU08BITS" +#define F76_DATASETS08 "DS08BITS" +#define F76_DIM8 8 +#define F76_DATASETU16 "DU16BITS" +#define F76_DATASETS16 "DS16BITS" +#define F76_DIM16 16 +#define F76_DATASETU32 "DU32BITS" +#define F76_DATASETS32 "DS32BITS" +#define F76_DIM32 32 +#define F76_DATASETU64 "DU64BITS" +#define F76_DATASETS64 "DS64BITS" +#define F76_DIM64 64 +#define F76_DUMMYDBL "DummyDBL" /* Name of dataset to create in datafile */ -#define F77_DATASETNAME1 "CompoundInts" -#define F77_DATASETNAME2 "CompoundRInts" -#define F77_LENGTH 64 +#define F77_DATASETNAME1 "CompoundInts" +#define F77_DATASETNAME2 "CompoundRInts" +#define F77_LENGTH 64 -#define F80_DIM32 32 +#define F80_DIM32 32 -#define F81_DATASETNAME "FourDimInts" +#define F81_DATASETNAME "FourDimInts" #define F81_RANK 4 #define F81_WDIM 10 #define F81_XDIM 8 @@ -395,22 +378,22 @@ typedef struct s1_t { /* "File 82" macros */ /* Name of dataset to create in datafile */ -#define F82_DATASETNAME "CompoundComplex1D" +#define F82_DATASETNAME "CompoundComplex1D" /* Dataset dimensions */ -#define F82_DIM32 32 -#define F82_RANK 1 +#define F82_DIM32 32 +#define F82_RANK 1 /* #define F82_RANK2 2 */ /* #define F82_RANK3 3 */ /* #define F82_RANK4 4 */ /* "File 83" macros */ /* Name of dataset to create in datafile */ -#define F83_DATASETNAME "ScalarArrayOfVlenStr" -#define F83_DATASETNAME2 "CompoundArrayOfVlenStr" +#define F83_DATASETNAME "ScalarArrayOfVlenStr" +#define F83_DATASETNAME2 "CompoundArrayOfVlenStr" /* Dataset dimensions */ -#define F83_DIM 5 -#define F83_RANK 1 -#define F83_ARRAYDIM 3 +#define F83_DIM 5 +#define F83_RANK 1 +#define F83_ARRAYDIM 3 static void gent_group(void) @@ -461,34 +444,35 @@ gent_group(void) static void gent_dataset(void) { - hid_t fid, dataset, space; - hsize_t dims[2]; - int **dset1 = NULL; - int *dset1_data = NULL; - double **dset2 = NULL; - double *dset2_data = NULL; - int i, j; + hid_t fid, dataset, space; + hsize_t dims[2]; + int ** dset1 = NULL; + int * dset1_data = NULL; + double **dset2 = NULL; + double * dset2_data = NULL; + int i, j; /* Set up data arrays */ dset1_data = (int *)HDcalloc(10 * 20, sizeof(int)); - dset1 = (int **)HDcalloc(10, sizeof(dset1_data)); + dset1 = (int **)HDcalloc(10, sizeof(dset1_data)); for (i = 0; i < 10; i++) dset1[i] = dset1_data + (i * 20); dset2_data = (double *)HDcalloc(30 * 20, sizeof(double)); - dset2 = (double **)HDcalloc(30, sizeof(dset2_data)); + dset2 = (double **)HDcalloc(30, sizeof(dset2_data)); for (i = 0; i < 30; i++) dset2[i] = dset2_data + (i * 20); fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* dset1 */ - dims[0] = 10; dims[1] = 20; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 10; + dims[1] = 20; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 20; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 20; j++) dset1[i][j] = j + i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1_data); @@ -496,12 +480,13 @@ gent_dataset(void) H5Dclose(dataset); /* dset2 */ - dims[0] = 30; dims[1] = 20; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 30; + dims[1] = 20; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset2", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 30; i++) - for(j = 0; j < 20; j++) + for (i = 0; i < 30; i++) + for (j = 0; j < 20; j++) dset2[i][j] = 0.0001F * (float)j + (float)i; H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_data); @@ -519,26 +504,29 @@ gent_dataset(void) static void gent_dataset2(void) { - hid_t fid, dataset, space, create_plist; + hid_t fid, dataset, space, create_plist; hsize_t dims[2]; hsize_t maxdims[2]; - int dset1[10][20]; - double dset2[30][10]; - int i, j; + int dset1[10][20]; + double dset2[30][10]; + int i, j; - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); create_plist = H5Pcreate(H5P_DATASET_CREATE); - dims[0] = 5; dims[1] = 5; + dims[0] = 5; + dims[1] = 5; H5Pset_chunk(create_plist, 2, dims); /* dset1 */ - dims[0] = 10; dims[1] = 20; - maxdims[0] = H5S_UNLIMITED; maxdims[1] = 20; - space = H5Screate_simple(2, dims, maxdims); - dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); + dims[0] = 10; + dims[1] = 20; + maxdims[0] = H5S_UNLIMITED; + maxdims[1] = 20; + space = H5Screate_simple(2, dims, maxdims); + dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 20; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 20; j++) dset1[i][j] = j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); @@ -546,13 +534,15 @@ gent_dataset2(void) H5Dclose(dataset); /* dset2 */ - dims[0] = 30; dims[1] = 10; - maxdims[0] = 30; maxdims[1] = H5S_UNLIMITED; - space = H5Screate_simple(2, dims, maxdims); - dataset = H5Dcreate2(fid, "/dset2", H5T_IEEE_F64BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); + dims[0] = 30; + dims[1] = 10; + maxdims[0] = 30; + maxdims[1] = H5S_UNLIMITED; + space = H5Screate_simple(2, dims, maxdims); + dataset = H5Dcreate2(fid, "/dset2", H5T_IEEE_F64BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - for(i = 0; i < 30; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 30; i++) + for (j = 0; j < 10; j++) dset2[i][j] = j; H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); @@ -566,21 +556,21 @@ gent_dataset2(void) static void gent_attribute(void) { - hid_t fid, root, space, attr, type; + hid_t fid, root, space, attr, type; hsize_t dims[2]; - char buf[60]; - int i, data[10]; - double d[10]; - char string[]= "string attribute"; - int point = 100; + char buf[60]; + int i, data[10]; + double d[10]; + char string[] = "string attribute"; + int point = 100; - fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* attribute 1 */ dims[0] = 24; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "/attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(root, "/attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "attribute of root group"); H5Awrite(attr, H5T_NATIVE_SCHAR, buf); H5Sclose(space); @@ -588,10 +578,11 @@ gent_attribute(void) /* attribute 2 */ dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(root, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) data[i] = i+1; + for (i = 0; i < 10; i++) + data[i] = i + 1; H5Awrite(attr, H5T_NATIVE_INT, data); H5Sclose(space); @@ -599,10 +590,11 @@ gent_attribute(void) /* attribute 3 */ dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "attr3", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(root, "attr3", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) d[i] = 0.1F * (float)i; + for (i = 0; i < 10; i++) + d[i] = 0.1F * (float)i; H5Awrite(attr, H5T_NATIVE_DOUBLE, d); H5Sclose(space); @@ -610,14 +602,14 @@ gent_attribute(void) /* attribute 4 */ space = H5Screate(H5S_SCALAR); - attr = H5Acreate2(root, "attr4", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); + attr = H5Acreate2(root, "attr4", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT, &point); H5Sclose(space); H5Aclose(attr); /* attribute 5 */ space = H5Screate(H5S_SCALAR); - type = H5Tcopy(H5T_C_S1); + type = H5Tcopy(H5T_C_S1); H5Tset_size(type, 17); attr = H5Acreate2(root, "attr5", type, space, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, type, string); @@ -629,11 +621,12 @@ gent_attribute(void) H5Fclose(fid); } -static void gent_softlink(void) +static void +gent_softlink(void) { hid_t fid, root; - fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); H5Lcreate_soft("somevalue", root, "slink1", H5P_DEFAULT, H5P_DEFAULT); H5Lcreate_soft("linkvalue", root, "slink2", H5P_DEFAULT, H5P_DEFAULT); @@ -654,25 +647,25 @@ static void gent_softlink(void) *-------------------------------------------------------------------------*/ #define NX 4 #define NY 2 -static int gent_softlink2(void) +static int +gent_softlink2(void) { - hid_t fileid1 = H5I_INVALID_HID; - hid_t gid1 = H5I_INVALID_HID, gid2 = H5I_INVALID_HID; - hid_t datatype = H5I_INVALID_HID; - hid_t dset1 = H5I_INVALID_HID, dset2 = H5I_INVALID_HID; - hid_t dataspace = H5I_INVALID_HID; - hsize_t dimsf[2]; /* dataset dimensions */ - int data1[NX][NY] = {{0,0},{1,1},{2,2},{3,3}}; - int data2[NX][NY] = {{0,0},{0,1},{0,2},{3,3}}; - herr_t status = SUCCEED; + hid_t fileid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID, gid2 = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t dset1 = H5I_INVALID_HID, dset2 = H5I_INVALID_HID; + hid_t dataspace = H5I_INVALID_HID; + hsize_t dimsf[2]; /* dataset dimensions */ + int data1[NX][NY] = {{0, 0}, {1, 1}, {2, 2}, {3, 3}}; + int data2[NX][NY] = {{0, 0}, {0, 1}, {0, 2}, {3, 3}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- * FILE *------------------------------------------------------------------------*/ /* Create a new file */ fileid1 = H5Fcreate(FILE4_1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fileid1 < 0) - { + if (fileid1 < 0) { HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", FILE4_1); status = FAIL; goto out; @@ -682,16 +675,14 @@ static int gent_softlink2(void) * Groups *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fileid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid1 < 0) - { + if (gid1 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", FILE4_1); status = FAIL; goto out; } gid2 = H5Gcreate2(fileid1, "group_empty", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid2 < 0) - { + if (gid2 < 0) { HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", FILE4_1); status = FAIL; goto out; @@ -701,9 +692,8 @@ static int gent_softlink2(void) * Named datatype *------------------------------------------------------------------------*/ datatype = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(fileid1, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + status = H5Tcommit2(fileid1, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", FILE4_1); status = FAIL; goto out; @@ -716,8 +706,8 @@ static int gent_softlink2(void) * Describe the size of the array and create the data space for fixed * size dataset. */ - dimsf[0] = NX; - dimsf[1] = NY; + dimsf[0] = NX; + dimsf[1] = NY; dataspace = H5Screate_simple(2, dimsf, NULL); /* @@ -728,18 +718,15 @@ static int gent_softlink2(void) * dset1 */ /* Create a new dataset as sample object */ - dset1 = H5Dcreate2(fileid1, "/dset1", H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dset1 < 0) - { + dset1 = H5Dcreate2(fileid1, "/dset1", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset1 < 0) { HDfprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1); status = FAIL; goto out; } status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", FILE4_1); status = FAIL; goto out; @@ -749,18 +736,15 @@ static int gent_softlink2(void) * dset2 */ /* Create a new dataset as sample object */ - dset2 = H5Dcreate2(fileid1, "/dset2", H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dset2 < 0) - { + dset2 = H5Dcreate2(fileid1, "/dset2", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset2 < 0) { HDfprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1); status = FAIL; goto out; } status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", FILE4_1); status = FAIL; goto out; @@ -774,8 +758,7 @@ static int gent_softlink2(void) */ /* link to dset1 */ status = H5Lcreate_soft("/dset1", fileid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -783,8 +766,7 @@ static int gent_softlink2(void) /* link to data type */ status = H5Lcreate_soft("/dtype", fileid1, "soft_dtype", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -792,8 +774,7 @@ static int gent_softlink2(void) /* link to group1 */ status = H5Lcreate_soft("/group1", fileid1, "soft_group1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -801,8 +782,7 @@ static int gent_softlink2(void) /* link to empty group */ status = H5Lcreate_soft("/group_empty", fileid1, "soft_empty_grp", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -810,8 +790,7 @@ static int gent_softlink2(void) /* dangling link */ status = H5Lcreate_soft("not_yet", fileid1, "soft_dangle", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -822,8 +801,7 @@ static int gent_softlink2(void) */ /* link to dset1 */ status = H5Lcreate_soft("/dset1", gid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -831,8 +809,7 @@ static int gent_softlink2(void) /* link to dset2 */ status = H5Lcreate_soft("/dset2", gid1, "soft_dset2", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -840,8 +817,7 @@ static int gent_softlink2(void) /* link to data type */ status = H5Lcreate_soft("/dtype", gid1, "soft_dtype", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -849,8 +825,7 @@ static int gent_softlink2(void) /* link to empty group */ status = H5Lcreate_soft("/group_empty", gid1, "soft_empty_grp", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; @@ -858,42 +833,41 @@ static int gent_softlink2(void) /* dangling link */ status = H5Lcreate_soft("not_yet", gid1, "soft_dangle", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); status = FAIL; goto out; } - out: +out: /* * Close/release resources. */ - if(dataspace >= 0 && H5Sclose(dataspace) < 0) { + if (dataspace >= 0 && H5Sclose(dataspace) < 0) { HDfprintf(stderr, "Error: %s> H5Sclose failed.\n", FILE4_1); status = FAIL; } - if(gid1 >= 0 && H5Gclose(gid1) < 0) { + if (gid1 >= 0 && H5Gclose(gid1) < 0) { HDfprintf(stderr, "Error: %s> H5Gclose failed.\n", FILE4_1); status = FAIL; } - if(gid2 >= 0 && H5Gclose(gid2) < 0) { + if (gid2 >= 0 && H5Gclose(gid2) < 0) { HDfprintf(stderr, "Error: %s> H5Gclose failed.\n", FILE4_1); status = FAIL; } - if(datatype >= 0 && H5Tclose(datatype) < 0) { + if (datatype >= 0 && H5Tclose(datatype) < 0) { HDfprintf(stderr, "Error: %s> H5Tclose failed.\n", FILE4_1); status = FAIL; } - if(dset1 >= 0 && H5Dclose(dset1) < 0) { + if (dset1 >= 0 && H5Dclose(dset1) < 0) { HDfprintf(stderr, "Error: %s> H5Dclose failed.\n", FILE4_1); status = FAIL; } - if(dset2 >= 0 && H5Dclose(dset2) < 0) { + if (dset2 >= 0 && H5Dclose(dset2) < 0) { HDfprintf(stderr, "Error: %s> H5Dclose failed.\n", FILE4_1); status = FAIL; } - if(fileid1 >= 0 && H5Fclose(fileid1) < 0) { + if (fileid1 >= 0 && H5Fclose(fileid1) < 0) { HDfprintf(stderr, "Error: %s> H5Fclose failed.\n", FILE4_1); status = FAIL; } @@ -914,18 +888,20 @@ static int gent_softlink2(void) dset3 */ -static void gent_hardlink(void) +static void +gent_hardlink(void) { - hid_t fid, group, dataset, space; + hid_t fid, group, dataset, space; hsize_t dim = 5; - int i, dset[5]; + int i, dset[5]; fid = H5Fcreate(FILE5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - space = H5Screate_simple(1, &dim, NULL); + space = H5Screate_simple(1, &dim, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 5; i++) dset[i] = i; + for (i = 0; i < 5; i++) + dset[i] = i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); H5Sclose(space); @@ -948,7 +924,8 @@ static void gent_hardlink(void) H5Fclose(fid); } -static void gent_extlink(void) +static void +gent_extlink(void) { hid_t fid; @@ -960,10 +937,11 @@ static void gent_extlink(void) H5Fclose(fid); } -static void gent_udlink(void) +static void +gent_udlink(void) { hid_t fid; - char buf[4]; + char buf[4]; H5Lregister(UD_link_class); @@ -976,7 +954,6 @@ static void gent_udlink(void) H5Fclose(fid); } - /* / / | \ \ @@ -985,69 +962,69 @@ static void gent_udlink(void) dset2 */ -static void gent_compound_dt(void) { /* test compound data type */ +static void +gent_compound_dt(void) +{ /* test compound data type */ hid_t fid, group, dataset, space, space3, type, type2; hid_t array_dt; typedef struct { - int a; - float b; - double c; + int a; + float b; + double c; } dset1_t; dset1_t dset1[5]; typedef struct { - int a; - float b; + int a; + float b; } dset2_t; dset2_t dset2[5]; typedef struct { - int a[4]; - float b[5][6]; + int a[4]; + float b[5][6]; } dset3_t; dset3_t dset3[3][6]; typedef struct { - int a; - float b; + int a; + float b; } dset4_t; dset4_t dset4[5]; typedef struct { - int a; - float b; + int a; + float b; } dset5_t; dset5_t dset5[5]; - int i, j, k, l; + int i, j, k, l; unsigned ndims; - hsize_t dim[2]; + hsize_t dim[2]; hsize_t sdim = 5; hsize_t dset3_dim[2]; - - for(i = 0; i < (int)sdim; i++) { + for (i = 0; i < (int)sdim; i++) { dset1[i].a = i; - dset1[i].b = (float)(i*i); - dset1[i].c = (float)(1.0F/(float)(i+1)); + dset1[i].b = (float)(i * i); + dset1[i].c = (float)(1.0F / (float)(i + 1)); dset2[i].a = i; - dset2[i].b = (float)((float)i+ (float)i*0.1F); + dset2[i].b = (float)((float)i + (float)i * 0.1F); dset4[i].a = i; - dset4[i].b = (float)(i+3); + dset4[i].b = (float)(i + 3); dset5[i].a = i; - dset5[i].b = (float)((float)i*0.1F); + dset5[i].b = (float)((float)i * 0.1F); } - fid = H5Fcreate(FILE6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); space = H5Screate_simple(1, &sdim, NULL); - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32BE); H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32BE); @@ -1062,11 +1039,11 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Dclose(dataset); /* shared data type 1 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset2_t)); H5Tinsert(type, "int_name", HOFFSET(dset2_t, a), H5T_STD_I32BE); H5Tinsert(type, "float_name", HOFFSET(dset2_t, b), H5T_IEEE_F32BE); H5Tcommit2(fid, "type1", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset2_t)); H5Tinsert(type2, "int_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "float_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); group = H5Gcreate2(fid, "/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -1077,12 +1054,12 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Tclose(type); H5Dclose(dataset); - /* shared data type 2 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset3_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset3_t)); - ndims = 1; dim[0] = 4; + ndims = 1; + dim[0] = 4; array_dt = H5Tarray_create2(H5T_STD_I32BE, ndims, dim); H5Tinsert(type, "int_array", HOFFSET(dset3_t, a), array_dt); @@ -1092,7 +1069,9 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Tinsert(type2, "int_array", HOFFSET(dset3_t, a), array_dt); H5Tclose(array_dt); - ndims = 2; dim[0] = 5; dim[1] = 6; + ndims = 2; + dim[0] = 5; + dim[1] = 6; array_dt = H5Tarray_create2(H5T_IEEE_F32BE, ndims, dim); H5Tinsert(type, "float_array", HOFFSET(dset3_t, b), array_dt); @@ -1104,16 +1083,16 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Tcommit2(fid, "type2", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - dset3_dim[0] = 3; dset3_dim[1] = 6; - space3 = H5Screate_simple(2, dset3_dim, NULL); - dataset = H5Dcreate2(group, "dset3", type, space3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < (int)dset3_dim[0]; i++) - for(j = 0; j < (int)dset3_dim[1]; j++) { - for(k = 0; k < 4; k++) + dset3_dim[0] = 3; + dset3_dim[1] = 6; + space3 = H5Screate_simple(2, dset3_dim, NULL); + dataset = H5Dcreate2(group, "dset3", type, space3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + for (i = 0; i < (int)dset3_dim[0]; i++) + for (j = 0; j < (int)dset3_dim[1]; j++) { + for (k = 0; k < 4; k++) dset3[i][j].a[k] = k + j + i; - for(k = 0; k < 5; k++) - for(l = 0; l < 6; l++) + for (k = 0; k < 5; k++) + for (l = 0; l < 6; l++) dset3[i][j].b[k][l] = (float)((k + 1) + l + j + i); } H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset3); @@ -1123,8 +1102,8 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Dclose(dataset); /* shared data type 3 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset4_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset4_t)); H5Tinsert(type, "int", HOFFSET(dset4_t, a), H5T_STD_I32BE); H5Tinsert(type, "float", HOFFSET(dset4_t, b), H5T_IEEE_F32BE); H5Tcommit2(group, "type3", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -1138,7 +1117,6 @@ static void gent_compound_dt(void) { /* test compound data type */ H5Dclose(dataset); H5Gclose(group); - /* unamed data type */ group = H5Gcreate2(fid, "/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -1171,51 +1149,53 @@ static void gent_compound_dt(void) { /* test compound data type */ dset2 */ -static void gent_compound_dt2(void) { /* test compound data type */ +static void +gent_compound_dt2(void) +{ /* test compound data type */ hid_t fid, group, dataset, space, type, create_plist, type2; hid_t array_dt; typedef struct { - int a; - float b; - double c; + int a; + float b; + double c; } dset1_t; dset1_t dset1[10]; typedef struct { - int a; - float b; + int a; + float b; } dset2_t; dset2_t dset2[10]; typedef struct { - int a[4]; - float b[5][6]; + int a[4]; + float b[5][6]; } dset3_t; typedef struct { - int a; - float b; + int a; + float b; } dset4_t; dset4_t dset4[10]; typedef struct { - int a; - float b; + int a; + float b; } dset5_t; dset5_t dset5[10]; - int i; + int i; unsigned ndims; - hsize_t dim[2]; + hsize_t dim[2]; hsize_t sdim, maxdim; sdim = 10; - for(i = 0; i < (int)sdim; i++) { + for (i = 0; i < (int)sdim; i++) { dset1[i].a = i; - dset1[i].b = (float)(i*i); - dset1[i].c = (float)(1.0F / (float)(i+ 1)); + dset1[i].b = (float)(i * i); + dset1[i].c = (float)(1.0F / (float)(i + 1)); dset2[i].a = i; dset2[i].b = (float)((float)i + (float)i * 0.1F); @@ -1234,12 +1214,12 @@ static void gent_compound_dt2(void) { /* test compound data type */ sdim = 2; H5Pset_chunk(create_plist, 1, &sdim); - sdim = 6; + sdim = 6; maxdim = H5S_UNLIMITED; space = H5Screate_simple(1, &sdim, &maxdim); - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32BE); H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32BE); @@ -1247,7 +1227,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ dataset = H5Dcreate2(fid, "/dset1", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); H5Tinsert(type2, "a_name", HOFFSET(dset1_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "b_name", HOFFSET(dset1_t, b), H5T_NATIVE_FLOAT); @@ -1260,7 +1240,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Sclose(space); H5Dclose(dataset); - sdim = 6; + sdim = 6; maxdim = 10; space = H5Screate_simple(1, &sdim, &maxdim); @@ -1275,7 +1255,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ dataset = H5Dcreate2(group, "dset2", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset2_t)); H5Tinsert(type2, "int_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "float_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); @@ -1284,16 +1264,18 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Tclose(type2); H5Dclose(dataset); - /* shared data type 2 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset3_t)); - ndims = 1; dim[0] = 4; + ndims = 1; + dim[0] = 4; array_dt = H5Tarray_create2(H5T_STD_I32BE, ndims, dim); H5Tinsert(type, "int_array", HOFFSET(dset3_t, a), array_dt); H5Tclose(array_dt); - ndims = 2; dim[0] = 5; dim[1] = 6; + ndims = 2; + dim[0] = 5; + dim[1] = 6; array_dt = H5Tarray_create2(H5T_IEEE_F32BE, ndims, dim); H5Tinsert(type, "float_array", HOFFSET(dset3_t, b), array_dt); H5Tclose(array_dt); @@ -1309,7 +1291,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ dataset = H5Dcreate2(group, "dset4", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset4_t)); H5Tinsert(type2, "int", HOFFSET(dset4_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "float", HOFFSET(dset4_t, b), H5T_NATIVE_FLOAT); H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset4); @@ -1319,7 +1301,6 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Dclose(dataset); H5Gclose(group); - /* unamed data type */ group = H5Gcreate2(fid, "/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -1328,7 +1309,7 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Tinsert(type, "float", HOFFSET(dset5_t, b), H5T_IEEE_F32BE); H5Tcommit2(group, "type4", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset5", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); H5Tinsert(type2, "int", HOFFSET(dset5_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "float", HOFFSET(dset5_t, b), H5T_NATIVE_FLOAT); H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset5); @@ -1343,10 +1324,8 @@ static void gent_compound_dt2(void) { /* test compound data type */ H5Pclose(create_plist); H5Fclose(fid); - } - /* / : g1 g2 attr1 attr2 @@ -1358,14 +1337,15 @@ g2 : dset2.1 dset2.2 udlink */ -static void gent_all(void) +static void +gent_all(void) { - hid_t fid, group, attr, dataset, space; + hid_t fid, group, attr, dataset, space; hsize_t dims[2]; - int data[2][2], dset1[10][10], dset2[20]; - char buf[60]; - int i, j; - float dset2_1[10], dset2_2[3][5]; + int data[2][2], dset1[10][10], dset2[20]; + char buf[60]; + int i, j; + float dset2_1[10], dset2_2[3][5]; fid = H5Fcreate(FILE7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1389,17 +1369,21 @@ static void gent_all(void) group = H5Gopen2(fid, "/", H5P_DEFAULT); dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "abcdefghi"); H5Awrite(attr, H5T_NATIVE_SCHAR, buf); H5Sclose(space); H5Aclose(attr); - dims[0] = 2; dims[1] = 2; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; + dims[0] = 2; + dims[1] = 2; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); + data[0][0] = 0; + data[0][1] = 1; + data[1][0] = 2; + data[1][1] = 3; H5Awrite(attr, H5T_NATIVE_INT, data); H5Sclose(space); H5Aclose(attr); @@ -1409,27 +1393,28 @@ static void gent_all(void) group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT); /* dset1.1.1 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 10; + dims[1] = 10; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) dset1[i][j] = j * i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); H5Sclose(space); /* attributes of dset1.1.1 */ dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "1st attribute of dset1.1.1"); H5Awrite(attr, H5T_NATIVE_SCHAR, buf); H5Sclose(space); H5Aclose(attr); dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "2nd attribute of dset1.1.1"); H5Awrite(attr, H5T_NATIVE_SCHAR, buf); H5Sclose(space); @@ -1439,9 +1424,9 @@ static void gent_all(void) /* dset1.1.2 */ dims[0] = 20; - space = H5Screate_simple(1, dims, NULL); + space = H5Screate_simple(1, dims, NULL); dataset = H5Dcreate2(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 20; i++) + for (i = 0; i < 20; i++) dset2[i] = i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); H5Sclose(space); @@ -1461,20 +1446,21 @@ static void gent_all(void) /* dset2.1 */ dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); + space = H5Screate_simple(1, dims, NULL); dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) dset2_1[i] = (float)((float)i * 0.1F + 1); H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1); H5Sclose(space); H5Dclose(dataset); /* dset2.2 */ - dims[0] = 3; dims[1] = 5; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 3; + dims[1] = 5; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 3; i++) - for(j = 0; j < 5; j++) + for (i = 0; i < 3; i++) + for (j = 0; j < 5; j++) dset2_2[i][j] = (float)((float)(i + 1) * (float)j * 0.1F); H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2); H5Sclose(space); @@ -1500,7 +1486,9 @@ o - group objects */ -static void gent_loop(void) { +static void +gent_loop(void) +{ hid_t fid, group; fid = H5Fcreate(FILE10, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1516,7 +1504,8 @@ static void gent_loop(void) { H5Fclose(fid); } -static void gent_loop2(void) +static void +gent_loop2(void) { hid_t fid, group; @@ -1553,25 +1542,25 @@ static void gent_loop2(void) static void gent_many(void) { - hid_t fid, group, attr, dataset, space, space2, type, create_plist, type2; - hid_t array_dt; + hid_t fid, group, attr, dataset, space, space2, type, create_plist, type2; + hid_t array_dt; hsize_t dims[2]; - int data[2][2], dset2[10][10], dset3[10][10]; - double d[10]; + int data[2][2], dset2[10][10], dset3[10][10]; + double d[10]; - char buf[60]; - int i, j; - int i0, i1, i2, i3; + char buf[60]; + int i, j; + int i0, i1, i2, i3; hsize_t sdim, maxdim; - typedef struct { /* compound type has members with rank > 1 */ - int a[2][2][2][2]; /* arrays are 2x2x2x2 */ - double b[2][2][2][2]; - double c[2][2][2][2]; + typedef struct { /* compound type has members with rank > 1 */ + int a[2][2][2][2]; /* arrays are 2x2x2x2 */ + double b[2][2][2][2]; + double c[2][2][2][2]; } dset1_t; dset1_t dset1[6]; - hsize_t dim[4]; + hsize_t dim[4]; herr_t H5_ATTR_NDEBUG_UNUSED ret; fid = H5Fcreate(FILE12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1586,10 +1575,10 @@ gent_many(void) group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); dim[0] = dim[1] = dim[2] = dim[3] = 2; - array_dt = H5Tarray_create2(H5T_STD_I32BE, 4, dim); + array_dt = H5Tarray_create2(H5T_STD_I32BE, 4, dim); H5Tinsert(type, "a_array", HOFFSET(dset1_t, a), array_dt); H5Tclose(array_dt); @@ -1601,7 +1590,7 @@ gent_many(void) H5Tinsert(type, "c_array", HOFFSET(dset1_t, c), array_dt); H5Tclose(array_dt); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); array_dt = H5Tarray_create2(H5T_NATIVE_INT, 4, dim); H5Tinsert(type2, "a_array", HOFFSET(dset1_t, a), array_dt); @@ -1615,44 +1604,47 @@ gent_many(void) H5Tinsert(type2, "c_array", HOFFSET(dset1_t, c), array_dt); H5Tclose(array_dt); - /* dset1 */ - sdim = 6; - maxdim = H5S_UNLIMITED; - space = H5Screate_simple(1, &sdim, &maxdim); + sdim = 6; + maxdim = H5S_UNLIMITED; + space = H5Screate_simple(1, &sdim, &maxdim); dataset = H5Dcreate2(group, "dset1", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); /* add attributes to dset1 */ dims[0] = 10; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space2, H5P_DEFAULT, H5P_DEFAULT); + space2 = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space2, H5P_DEFAULT, H5P_DEFAULT); HDsprintf(buf, "abcdefghi"); H5Awrite(attr, H5T_NATIVE_CHAR, buf); H5Sclose(space2); H5Aclose(attr); - dims[0] = 2; dims[1] = 2; - space2 = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I32BE, space2, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; + dims[0] = 2; + dims[1] = 2; + space2 = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(dataset, "attr2", H5T_STD_I32BE, space2, H5P_DEFAULT, H5P_DEFAULT); + data[0][0] = 0; + data[0][1] = 1; + data[1][0] = 2; + data[1][1] = 3; H5Awrite(attr, H5T_NATIVE_INT, data); H5Sclose(space2); H5Aclose(attr); dims[0] = 10; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr3", H5T_IEEE_F64BE, space2, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) + space2 = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr3", H5T_IEEE_F64BE, space2, H5P_DEFAULT, H5P_DEFAULT); + for (i = 0; i < 10; i++) d[i] = 0.1F * (float)i; H5Awrite(attr, H5T_NATIVE_DOUBLE, d); H5Sclose(space2); H5Aclose(attr); - for(j=0; j<(int)sdim; j++) { - for(i3 = 0; i3 < 2; i3++) { - for(i2 = 0; i2 < 2; i2++) { - for(i1 = 0; i1 < 2; i1++) { - for(i0 = 0; i0 < 2; i0++) { + for (j = 0; j < (int)sdim; j++) { + for (i3 = 0; i3 < 2; i3++) { + for (i2 = 0; i2 < 2; i2++) { + for (i1 = 0; i1 < 2; i1++) { + for (i0 = 0; i0 < 2; i0++) { dset1[j].a[i3][i2][i1][i0] = i0 + j; dset1[j].b[i3][i2][i1][i0] = (double)(i0 + j); dset1[j].c[i3][i2][i1][i0] = (double)((hsize_t)i0 + (hsize_t)j + sdim); @@ -1685,12 +1677,13 @@ gent_many(void) group = H5Gcreate2(fid, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* dset2 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 10; + dims[1] = 10; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(group, "dset2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) dset2[i][j] = j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); @@ -1708,12 +1701,13 @@ gent_many(void) group = H5Gcreate2(fid, "/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* dset3 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); + dims[0] = 10; + dims[1] = 10; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(group, "dset3", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) dset3[i][j] = i; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset3); @@ -1746,68 +1740,68 @@ gent_many(void) H5Fclose(fid); } -static hid_t mkstr(int size, H5T_str_t pad) { +static hid_t +mkstr(int size, H5T_str_t pad) +{ hid_t type; - if((type=H5Tcopy(H5T_C_S1)) < 0) return -1; - if(H5Tset_size(type, (size_t)size) < 0) return -1; - if(H5Tset_strpad(type, pad) < 0) return -1; + if ((type = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if (H5Tset_size(type, (size_t)size) < 0) + return -1; + if (H5Tset_strpad(type, pad) < 0) + return -1; return type; } -static void gent_str(void) { +static void +gent_str(void) +{ hid_t fid, dataset, space, f_type, m_type, str_type, f_type2; hid_t array_dt; - hsize_t dims1[] = { 3, 4}; - char string1[12][3] = {"s1","s2","s3","s4","s5","s6","s7","s8","s9", - "s0","s1","s2"}; - - hsize_t dims2[]={20}; - char string2[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", - "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2", - "ab cd ef3", "ab cd ef4", "ab cd ef5", "ab cd ef6", - "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; - - hsize_t dims3[] = { 27}; - char string3[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", - "abcd4", "abcd5", "abcd6", "abcd7", - "abcd8", "abcd9", "abcd0", "abcd1", - "abcd2", "abcd3", "abcd4", "abcd5", - "abcd6", "abcd7", "abcd8", "abcd9", - "abcd0", "abcd1", "abcd2", "abcd3", - "abcd4", "abcd5", "abcd6"}; + hsize_t dims1[] = {3, 4}; + char string1[12][3] = {"s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s0", "s1", "s2"}; + + hsize_t dims2[] = {20}; + char string2[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0", + "ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + + hsize_t dims3[] = {27}; + char string3[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", "abcd8", + "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", + "abcd8", "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6"}; int i, j, k, l; - hsize_t dims4[] = { 3 }; - char string4[3][21] = { "s1234567890123456789", "s1234567890123456789", - "s1234567890123456789"}; + hsize_t dims4[] = {3}; + char string4[3][21] = {"s1234567890123456789", "s1234567890123456789", "s1234567890123456789"}; - hsize_t dims5[] = { 3, 6}; + hsize_t dims5[] = {3, 6}; typedef struct { - int a[8][10]; - char s[12][33]; + int a[8][10]; + char s[12][33]; } compound_t; - compound_t **comp1 = NULL; - compound_t *comp1_data = NULL; - hsize_t mdims[2]; + compound_t **comp1 = NULL; + compound_t * comp1_data = NULL; + hsize_t mdims[2]; /* Set up data array */ comp1_data = (compound_t *)HDcalloc(3 * 6, sizeof(compound_t)); - comp1 = (compound_t **)HDcalloc(3, sizeof(comp1_data)); + comp1 = (compound_t **)HDcalloc(3, sizeof(comp1_data)); for (i = 0; i < 3; i++) comp1[i] = comp1_data + (i * 6); fid = H5Fcreate(FILE13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* string 1 : nullterm string */ - space = H5Screate_simple(2, dims1, NULL); - f_type = mkstr(5, H5T_STR_NULLTERM); - m_type = mkstr(3, H5T_STR_NULLTERM); + space = H5Screate_simple(2, dims1, NULL); + f_type = mkstr(5, H5T_STR_NULLTERM); + m_type = mkstr(3, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid, "/string1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string1); H5Tclose(m_type); @@ -1816,9 +1810,9 @@ static void gent_str(void) { H5Dclose(dataset); /* string 2 : space pad string */ - space = H5Screate_simple(1, dims2, NULL); - f_type = mkstr(11, H5T_STR_SPACEPAD); - m_type = mkstr(10, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims2, NULL); + f_type = mkstr(11, H5T_STR_SPACEPAD); + m_type = mkstr(10, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid, "/string2", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string2); H5Tclose(m_type); @@ -1827,9 +1821,9 @@ static void gent_str(void) { H5Dclose(dataset); /* string 3 : null pad string */ - space = H5Screate_simple(1, dims3, NULL); - f_type = mkstr(8, H5T_STR_NULLPAD); - m_type = mkstr(6, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims3, NULL); + f_type = mkstr(8, H5T_STR_NULLPAD); + m_type = mkstr(6, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid, "/string3", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string3); H5Tclose(m_type); @@ -1838,9 +1832,9 @@ static void gent_str(void) { H5Dclose(dataset); /* string 4 : space pad long string */ - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_SPACEPAD); - m_type = mkstr(21, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims4, NULL); + f_type = mkstr(168, H5T_STR_SPACEPAD); + m_type = mkstr(21, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid, "/string4", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4); H5Tclose(m_type); @@ -1849,11 +1843,12 @@ static void gent_str(void) { H5Dclose(dataset); /* compound data */ - space = H5Screate_simple(2, dims5, NULL); - f_type = H5Tcreate (H5T_COMPOUND, sizeof(compound_t)); - f_type2 = H5Tcreate (H5T_COMPOUND, sizeof(compound_t)); + space = H5Screate_simple(2, dims5, NULL); + f_type = H5Tcreate(H5T_COMPOUND, sizeof(compound_t)); + f_type2 = H5Tcreate(H5T_COMPOUND, sizeof(compound_t)); - mdims[0] = 8; mdims[1] = 10; + mdims[0] = 8; + mdims[1] = 10; array_dt = H5Tarray_create2(H5T_STD_I32BE, 2, mdims); H5Tinsert(f_type, "int_array", HOFFSET(compound_t, a), array_dt); @@ -1863,7 +1858,8 @@ static void gent_str(void) { H5Tinsert(f_type2, "int_array", HOFFSET(compound_t, a), array_dt); H5Tclose(array_dt); - mdims[0] = 3; mdims[1] = 4; + mdims[0] = 3; + mdims[1] = 4; str_type = mkstr(32, H5T_STR_SPACEPAD); array_dt = H5Tarray_create2(str_type, 2, mdims); @@ -1877,12 +1873,12 @@ static void gent_str(void) { H5Tclose(array_dt); H5Tclose(str_type); - for(i = 0; i < 3; i++) - for(j = 0; j < 6; j++) { - for(k = 0 ; k < 8; k++) - for(l = 0; l < 10; l++) + for (i = 0; i < 3; i++) + for (j = 0; j < 6; j++) { + for (k = 0; k < 8; k++) + for (l = 0; l < 10; l++) comp1[i][j].a[k][l] = (l + j + k) * (l + j + k); - for(k = 0 ; k < 12; k++) + for (k = 0; k < 12; k++) HDstrcpy(comp1[i][j].s[k], "abcdefgh12345678abcdefgh12345678"); } @@ -1909,17 +1905,17 @@ static void gent_str(void) { string2 string4 string6 */ -static void gent_str2(void) +static void +gent_str2(void) { - hid_t fid, group, attr, dataset, space, space2, mem_space, hyper_space; - hid_t fxdlenstr, fxdlenstr2, memtype; + hid_t fid, group, attr, dataset, space, space2, mem_space, hyper_space; + hid_t fxdlenstr, fxdlenstr2, memtype; hsize_t dims[1], size[1], stride[1], count[1], block[1]; hsize_t start[1]; - - int i; - char buf[LENSTR+20]; - char buf2[3*LENSTR2]; + int i; + char buf[LENSTR + 20]; + char buf2[3 * LENSTR2]; hsize_t sdim; fid = H5Fcreate(FILE14, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1934,16 +1930,16 @@ static void gent_str2(void) H5Tset_cset(memtype, H5T_CSET_ASCII); H5Tset_strpad(memtype, H5T_STR_NULLTERM); - sdim = 10; - size[0] = sdim; - space = H5Screate_simple(1, size, NULL); - size[0] = 1; - mem_space = H5Screate_simple(1,size,NULL); + sdim = 10; + size[0] = sdim; + space = H5Screate_simple(1, size, NULL); + size[0] = 1; + mem_space = H5Screate_simple(1, size, NULL); hyper_space = H5Scopy(space); /* dset1 */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset1", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* add attributes to dset1 */ @@ -1954,71 +1950,69 @@ static void gent_str2(void) H5Tset_strpad(fxdlenstr2, H5T_STR_NULLTERM); dims[0] = 3; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", fxdlenstr2, space2, H5P_DEFAULT, H5P_DEFAULT); - HDsprintf(&(buf2[0*LENSTR2]), "0123456789"); - HDsprintf(&(buf2[1*LENSTR2]), "abcdefghij"); - HDsprintf(&(buf2[2*LENSTR2]), "ABCDEFGHIJ"); + space2 = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr1", fxdlenstr2, space2, H5P_DEFAULT, H5P_DEFAULT); + HDsprintf(&(buf2[0 * LENSTR2]), "0123456789"); + HDsprintf(&(buf2[1 * LENSTR2]), "abcdefghij"); + HDsprintf(&(buf2[2 * LENSTR2]), "ABCDEFGHIJ"); H5Awrite(attr, fxdlenstr2, buf2); H5Sclose(space2); H5Tclose(fxdlenstr2); H5Aclose(attr); - stride[0]=1; - count[0]=1; - block[0]=1; + stride[0] = 1; + count[0] = 1; + block[0] = 1; - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_NULLTERM of", i); - H5Tset_size(memtype, HDstrlen(buf)+1); + H5Tset_size(memtype, HDstrlen(buf) + 1); H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); } H5Dclose(dataset); H5Gclose(group); - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset2", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_NULLTERM of string array", i); - H5Tset_size(memtype, HDstrlen(buf)+1); + H5Tset_size(memtype, HDstrlen(buf) + 1); H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); } H5Dclose(dataset); H5Gclose(group); - H5Tclose(fxdlenstr); fxdlenstr = H5Tcopy(H5T_C_S1); H5Tset_size(fxdlenstr, LENSTR); H5Tset_cset(fxdlenstr, H5T_CSET_ASCII); H5Tset_strpad(fxdlenstr, H5T_STR_NULLPAD); - group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset3", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0;(hsize_t) i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_NULLPAD of", i); - H5Tset_size(memtype, HDstrlen(buf)+1); + H5Tset_size(memtype, HDstrlen(buf) + 1); H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); } H5Dclose(dataset); H5Gclose(group); - - group = H5Gcreate2(fid, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset4", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_NULLPAD of string array", i); - H5Tset_size(memtype, HDstrlen(buf)+1); + H5Tset_size(memtype, HDstrlen(buf) + 1); H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); } @@ -2031,10 +2025,10 @@ static void gent_str2(void) H5Tset_cset(fxdlenstr, H5T_CSET_ASCII); H5Tset_strpad(fxdlenstr, H5T_STR_SPACEPAD); - group = H5Gcreate2(fid, "/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset5", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_SPACEPAD of", i); H5Tset_size(memtype, HDstrlen(buf) + 1); @@ -2044,11 +2038,10 @@ static void gent_str2(void) H5Dclose(dataset); H5Gclose(group); - - group = H5Gcreate2(fid, "/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + group = H5Gcreate2(fid, "/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataset = H5Dcreate2(group, "dset6", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; (hsize_t)i < sdim; i++) { + for (i = 0; (hsize_t)i < sdim; i++) { start[0] = (hsize_t)i; HDsprintf(buf, "This is row %1d of type H5T_STR_SPACEPAD of string array", i); H5Tset_size(memtype, HDstrlen(buf) + 1); @@ -2066,30 +2059,29 @@ static void gent_str2(void) H5Fclose(fid); } -static void gent_enum(void) +static void +gent_enum(void) { /*some code is taken from enum.c in the test dir */ - hid_t file, type, space, dset; - int val; - enumtype data[] = {RED, GREEN, BLUE, GREEN, WHITE, - WHITE, BLACK, GREEN, BLUE, RED, - RED, BLUE, GREEN, BLACK, WHITE, - RED, WHITE, GREEN, GREEN, BLUE}; - hsize_t size[1] = {NELMTS(data)}; + hid_t file, type, space, dset; + int val; + enumtype data[] = {RED, GREEN, BLUE, GREEN, WHITE, WHITE, BLACK, GREEN, BLUE, RED, + RED, BLUE, GREEN, BLACK, WHITE, RED, WHITE, GREEN, GREEN, BLUE}; + hsize_t size[1] = {NELMTS(data)}; - file = H5Fcreate(FILE15,H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE15, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Try to test names with special characters */ type = H5Tcreate(H5T_ENUM, sizeof(enumtype)); - H5Tenum_insert(type, "RED", (val = 0, &val)); + H5Tenum_insert(type, "RED", (val = 0, &val)); H5Tenum_insert(type, "GREEN\ngreen", (val = 1, &val)); - H5Tenum_insert(type, "BLUE blue", (val = 2, &val)); + H5Tenum_insert(type, "BLUE blue", (val = 2, &val)); H5Tenum_insert(type, "WHITE \"white\"", (val = 3, &val)); H5Tenum_insert(type, "BLACK \'black\'", (val = 4, &val)); H5Tcommit2(file, "enum normal", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - space = H5Screate_simple(1,size,NULL); - dset = H5Dcreate2(file,"table",type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, size, NULL); + dset = H5Dcreate2(file, "table", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dset, type, space, space, H5P_DEFAULT, data); H5Dclose(dset); @@ -2097,28 +2089,29 @@ static void gent_enum(void) H5Fclose(file); } -static void gent_objref(void) +static void +gent_objref(void) { /*some code is taken from enum.c in the test dir */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hobj_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ - uint32_t *tu32; /* Temporary pointer to uint32 data */ - int i; /* counting variables */ - const char *write_comment = "Foo!"; /* Comments for group */ - hbool_t supports_comments = FALSE; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hobj_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ + uint32_t * tu32; /* Temporary pointer to uint32 data */ + int i; /* counting variables */ + const char *write_comment = "Foo!"; /* Comments for group */ + hbool_t supports_comments = FALSE; /* Allocate write & read buffers */ - wbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - rbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - tbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + wbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + rbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + tbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); /* Create file */ fid1 = H5Fcreate(FILE16, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2139,7 +2132,7 @@ static void gent_objref(void) /* Create a dataset (inside Group1) */ dataset = H5Dcreate2(group, "Dataset1", H5T_STD_U32BE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(tu32 = (uint32_t *)((void*)wbuf), i = 0; i < SPACE1_DIM1; i++) + for (tu32 = (uint32_t *)((void *)wbuf), i = 0; i < SPACE1_DIM1; i++) *tu32++ = (uint32_t)(i * 3); /* Write selection to disk */ @@ -2158,11 +2151,11 @@ static void gent_objref(void) tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); /* Insert fields */ - H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_STD_I32BE); + H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_STD_I32BE); - H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_IEEE_F32BE); + H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_IEEE_F32BE); - H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_IEEE_F32BE); + H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_IEEE_F32BE); /* Save datatype for later */ H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -2206,34 +2199,34 @@ static void gent_objref(void) HDfree(tbuf); } -static void gent_datareg(void) +static void +gent_datareg(void) { /*some code is taken from enum.c in the test dir */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dset1, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid2; /* Dataspace ID #2 */ - hsize_t dims1[] = {SPACE1_DIM1}, - dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hdset_reg_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - int i; /* counting variables */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dset1, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t sid1, /* Dataspace ID #1 */ + sid2; /* Dataspace ID #2 */ + hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hdset_reg_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t *tu8; /* Temporary pointer to uint8 data */ + int i; /* counting variables */ /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf = (hdset_reg_ref_t*) HDmalloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); - dwbuf = (uint8_t*) HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - drbuf = (uint8_t*) HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); + drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2); /* Create file */ fid1 = H5Fcreate(FILE17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2244,7 +2237,7 @@ static void gent_datareg(void) /* Create a dataset */ dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) + for (tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ @@ -2262,10 +2255,14 @@ static void gent_datareg(void) /* Create references */ /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 6; - block[0] = 1; block[1] = 1; + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 6; + block[0] = 1; + block[1] = 1; H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); H5Sget_select_npoints(sid2); @@ -2274,25 +2271,35 @@ static void gent_datareg(void) H5Rcreate(&wbuf[0], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); /* Select sequence of ten points for second reference */ - coord1[0][0]=6; coord1[0][1]=9; - coord1[1][0]=2; coord1[1][1]=2; - coord1[2][0]=8; coord1[2][1]=4; - coord1[3][0]=1; coord1[3][1]=6; - coord1[4][0]=2; coord1[4][1]=8; - coord1[5][0]=3; coord1[5][1]=2; - coord1[6][0]=0; coord1[6][1]=4; - coord1[7][0]=9; coord1[7][1]=0; - coord1[8][0]=7; coord1[8][1]=1; - coord1[9][0]=3; coord1[9][1]=3; - H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(hsize_t *)coord1); + coord1[0][0] = 6; + coord1[0][1] = 9; + coord1[1][0] = 2; + coord1[1][1] = 2; + coord1[2][0] = 8; + coord1[2][1] = 4; + coord1[3][0] = 1; + coord1[3][1] = 6; + coord1[4][0] = 2; + coord1[4][1] = 8; + coord1[5][0] = 3; + coord1[5][1] = 2; + coord1[6][0] = 0; + coord1[6][1] = 4; + coord1[7][0] = 9; + coord1[7][1] = 0; + coord1[8][0] = 7; + coord1[8][1] = 1; + coord1[9][0] = 3; + coord1[9][1] = 3; + H5Sselect_elements(sid2, H5S_SELECT_SET, POINT1_NPOINTS, (hsize_t *)coord1); H5Sget_select_npoints(sid2); /* Store second dataset region */ - H5Rcreate(&wbuf[1],fid1,"/Dataset2",H5R_DATASET_REGION,sid2); + H5Rcreate(&wbuf[1], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); /* Write selection to disk */ - H5Dwrite(dset1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf); + H5Dwrite(dset1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); /* Close disk dataspace */ H5Sclose(sid1); @@ -2313,36 +2320,37 @@ static void gent_datareg(void) HDfree(drbuf); } -static void gent_attrreg(void) +static void +gent_attrreg(void) { /*some code is taken from enum.c in the test dir */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dset1; /* Dataset ID */ - hid_t dset2; /* Dereferenced dataset ID */ - hid_t sid1; /* Dataspace ID #1 */ - hid_t sid2; /* Dataspace ID #2 */ - hid_t sid3; /* Dataspace ID #3 */ - hid_t attr1; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hdset_reg_ref_t *wbuf; /* buffer to write to disk */ - hdset_reg_ref_t *rbuf; /* buffer read from disk */ - uint8_t *dwbuf; /* Buffer for writing numeric data to disk */ - uint8_t *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - int i; /* counting variables */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dset1; /* Dataset ID */ + hid_t dset2; /* Dereferenced dataset ID */ + hid_t sid1; /* Dataspace ID #1 */ + hid_t sid2; /* Dataspace ID #2 */ + hid_t sid3; /* Dataspace ID #3 */ + hid_t attr1; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hdset_reg_ref_t *wbuf; /* buffer to write to disk */ + hdset_reg_ref_t *rbuf; /* buffer read from disk */ + uint8_t * dwbuf; /* Buffer for writing numeric data to disk */ + uint8_t * drbuf; /* Buffer for reading numeric data from disk */ + uint8_t * tu8; /* Temporary pointer to uint8 data */ + int i; /* counting variables */ /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf = (hdset_reg_ref_t*) HDmalloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); - dwbuf = (uint8_t*) HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - drbuf = (uint8_t*) HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); + drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2); /* Create file */ fid1 = H5Fcreate(FILE64, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2353,7 +2361,7 @@ static void gent_attrreg(void) /* Create a dataset */ dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) + for (tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ @@ -2366,18 +2374,21 @@ static void gent_attrreg(void) * Create dataset with a null dataspace to serve as the parent for * the attribute. */ - sid1 = H5Screate (H5S_NULL); - dset1 = H5Dcreate2 (fid1, "Dataset1", H5T_STD_I32LE, sid1, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - H5Sclose (sid1); + sid1 = H5Screate(H5S_NULL); + dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_I32LE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Sclose(sid1); /* Create references */ /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 6; - block[0] = 1; block[1] = 1; + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 6; + block[0] = 1; + block[1] = 1; H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); H5Sget_select_npoints(sid2); @@ -2386,36 +2397,45 @@ static void gent_attrreg(void) H5Rcreate(&wbuf[0], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); /* Select sequence of ten points for second reference */ - coord1[0][0]=6; coord1[0][1]=9; - coord1[1][0]=2; coord1[1][1]=2; - coord1[2][0]=8; coord1[2][1]=4; - coord1[3][0]=1; coord1[3][1]=6; - coord1[4][0]=2; coord1[4][1]=8; - coord1[5][0]=3; coord1[5][1]=2; - coord1[6][0]=0; coord1[6][1]=4; - coord1[7][0]=9; coord1[7][1]=0; - coord1[8][0]=7; coord1[8][1]=1; - coord1[9][0]=3; coord1[9][1]=3; - H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(hsize_t *)coord1); + coord1[0][0] = 6; + coord1[0][1] = 9; + coord1[1][0] = 2; + coord1[1][1] = 2; + coord1[2][0] = 8; + coord1[2][1] = 4; + coord1[3][0] = 1; + coord1[3][1] = 6; + coord1[4][0] = 2; + coord1[4][1] = 8; + coord1[5][0] = 3; + coord1[5][1] = 2; + coord1[6][0] = 0; + coord1[6][1] = 4; + coord1[7][0] = 9; + coord1[7][1] = 0; + coord1[8][0] = 7; + coord1[8][1] = 1; + coord1[9][0] = 3; + coord1[9][1] = 3; + H5Sselect_elements(sid2, H5S_SELECT_SET, POINT1_NPOINTS, (hsize_t *)coord1); H5Sget_select_npoints(sid2); /* Store second dataset region */ - H5Rcreate(&wbuf[1],fid1,"/Dataset2",H5R_DATASET_REGION,sid2); + H5Rcreate(&wbuf[1], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); /* Create dataspace for the attribute */ sid3 = H5Screate_simple(SPACE1_RANK, dims1, NULL); /* Create the attribute and write the region references to it. */ - attr1 = H5Acreate2 (dset1, "Attribute1", H5T_STD_REF_DSETREG, sid3, H5P_DEFAULT, - H5P_DEFAULT); - H5Awrite (attr1, H5T_STD_REF_DSETREG, wbuf); + attr1 = H5Acreate2(dset1, "Attribute1", H5T_STD_REF_DSETREG, sid3, H5P_DEFAULT, H5P_DEFAULT); + H5Awrite(attr1, H5T_STD_REF_DSETREG, wbuf); /* Close attribute dataspace */ H5Sclose(sid3); /* Close attribute */ - H5Aclose (attr1); + H5Aclose(attr1); /* Close Dataset */ H5Dclose(dset1); @@ -2434,48 +2454,48 @@ static void gent_attrreg(void) } /*taken from Elena's compound test file*/ -static void gent_nestcomp(void) +static void +gent_nestcomp(void) { /* Compound memeber of the compound datatype*/ typedef struct cmp_t { - char a; - float b[2]; + char a; + float b[2]; } cmp_t; /* First structure and dataset*/ typedef struct s1_t { - int a; - float b; - double c; - cmp_t d; + int a; + float b; + double c; + cmp_t d; } s2_t; - hid_t cmp_tid; /* Handle for the compound datatype */ - hid_t char_id; /* Handle for the string datatype */ - hid_t array_dt; - hsize_t array_dims[] = {2}; /* Dataspace dimensions */ - unsigned ndims = 1; /* Number of dimensions in the array field */ + hid_t cmp_tid; /* Handle for the compound datatype */ + hid_t char_id; /* Handle for the string datatype */ + hid_t array_dt; + hsize_t array_dims[] = {2}; /* Dataspace dimensions */ + unsigned ndims = 1; /* Number of dimensions in the array field */ - s2_t s1[10]; - hid_t s2_tid; /* File datatype identifier */ + s2_t s1[10]; + hid_t s2_tid; /* File datatype identifier */ - int i; - hid_t file, dataset, space; /* Handles */ - herr_t status; - hsize_t dim[] = {10}; /* Dataspace dimensions */ + int i; + hid_t file, dataset, space; /* Handles */ + herr_t status; + hsize_t dim[] = {10}; /* Dataspace dimensions */ char datasetname[] = "ArrayOfStructures"; - /* * Initialize the data */ - for(i = 0; i< 10; i++) { - s1[i].a = i; - s1[i].b = (float)(i*i); - s1[i].c = 1.0F/(float)(i + 1); - s1[i].d.a = (char)(65 + i); + for (i = 0; i < 10; i++) { + s1[i].a = i; + s1[i].b = (float)(i * i); + s1[i].c = 1.0F / (float)(i + 1); + s1[i].d.a = (char)(65 + i); s1[i].d.b[0] = -100.0F; - s1[i].d.b[1] = 100.0F; + s1[i].d.b[1] = 100.0F; } /* @@ -2494,7 +2514,7 @@ static void gent_nestcomp(void) /* * Create a datatype for compound field first. */ - cmp_tid = H5Tcreate (H5T_COMPOUND, sizeof(cmp_t)); + cmp_tid = H5Tcreate(H5T_COMPOUND, sizeof(cmp_t)); /* We are using C string of length one to represent "real" character */ char_id = H5Tcopy(H5T_C_S1); @@ -2505,7 +2525,7 @@ static void gent_nestcomp(void) H5Tinsert(cmp_tid, "array_name", HOFFSET(cmp_t, b), array_dt); H5Tclose(array_dt); - s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)); + s2_tid = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); H5Tinsert(s2_tid, "a_name", HOFFSET(s2_t, a), H5T_NATIVE_INT); H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE); H5Tinsert(s2_tid, "b_name", HOFFSET(s2_t, b), H5T_NATIVE_FLOAT); @@ -2522,7 +2542,7 @@ static void gent_nestcomp(void) * Wtite data to the dataset; */ status = H5Dwrite(dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); - if(status < 0) + if (status < 0) HDfprintf(stderr, "gent_nestcomp H5Dwrite failed\n"); /* @@ -2536,14 +2556,15 @@ static void gent_nestcomp(void) H5Fclose(file); } -static void gent_opaque(void) +static void +gent_opaque(void) { - hid_t file, type, dataset, space; - char test[100][2]; - int x; + hid_t file, type, dataset, space; + char test[100][2]; + int x; hsize_t dim = 2; - for(x = 0; x < 100; x++){ + for (x = 0; x < 100; x++) { test[x][0] = (char)x; test[x][1] = (char)(99 - x); } @@ -2580,83 +2601,94 @@ static void gent_opaque(void) H5Fclose(file); } -static void gent_bitfields(void) +static void +gent_bitfields(void) { - hid_t file, grp=H5I_INVALID_HID, type=H5I_INVALID_HID, space=H5I_INVALID_HID, dset=H5I_INVALID_HID; - size_t i; - hsize_t nelmts; + hid_t file, grp = H5I_INVALID_HID, type = H5I_INVALID_HID, space = H5I_INVALID_HID, + dset = H5I_INVALID_HID; + size_t i; + hsize_t nelmts; unsigned char buf[32]; file = H5Fcreate(FILE20, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if((grp = H5Gcreate2(file, "typetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if ((grp = H5Gcreate2(file, "typetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; /* bitfield_1 */ nelmts = sizeof(buf); - if((type = H5Tcopy(H5T_STD_B8LE)) < 0 || - (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || - (dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((type = H5Tcopy(H5T_STD_B8LE)) < 0 || (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || + (dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < sizeof buf; i++) + for (i = 0; i < sizeof buf; i++) buf[i] = (uint8_t)(0xff ^ i); - if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Tclose(type) < 0) + goto error; + if (H5Dclose(dset) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Tclose(type) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; /* bitfield_2 */ - nelmts = sizeof(buf)/2; - if((type = H5Tcopy(H5T_STD_B16LE)) < 0 || - (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || - (dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + nelmts = sizeof(buf) / 2; + if ((type = H5Tcopy(H5T_STD_B16LE)) < 0 || (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || + (dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < sizeof buf; i++) + for (i = 0; i < sizeof buf; i++) buf[i] = (uint8_t)(0xff ^ i); - if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + if (H5Sclose(space) < 0) + goto error; + if (H5Tclose(type) < 0) + goto error; + if (H5Dclose(dset) < 0) + goto error; + if (H5Gclose(grp) < 0) goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Tclose(type) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; H5Fclose(file); - error: - H5E_BEGIN_TRY { +error: + H5E_BEGIN_TRY + { H5Gclose(grp); H5Tclose(type); H5Sclose(space); H5Dclose(dset); - } H5E_END_TRY; + } + H5E_END_TRY; } -static void gent_vldatatypes(void) +static void +gent_vldatatypes(void) { - hvl_t adata, wdata[SPACE1_DIM1]; - hid_t file, dset, space, type; - hsize_t dims[] = { SPACE1_DIM1 }; - int i; - herr_t H5_ATTR_NDEBUG_UNUSED ret=0; + hvl_t adata, wdata[SPACE1_DIM1]; + hid_t file, dset, space, type; + hsize_t dims[] = {SPACE1_DIM1}; + int i; + herr_t H5_ATTR_NDEBUG_UNUSED ret = 0; file = H5Fcreate(FILE21, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Allocate and initialize VL dataset to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { int j; - wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(int)); wdata[i].len = (size_t)(i + 1); - for(j = 0; j < i + 1; j++) + for (j = 0; j < i + 1; j++) ((int *)wdata[i].p)[j] = i * 10 + j; } /* write out the integers in little-endian format */ space = H5Screate_simple(SPACE1_RANK, dims, NULL); - type = H5Tvlen_create(H5T_NATIVE_INT); - dset = H5Dcreate2(file, "Dataset1.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + type = H5Tvlen_create(H5T_NATIVE_INT); + dset = H5Dcreate2(file, "Dataset1.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDassert(ret >= 0); ret = H5Treclaim(type, space, H5P_DEFAULT, wdata); HDassert(ret >= 0); @@ -2669,21 +2701,21 @@ static void gent_vldatatypes(void) HDassert(ret >= 0); /* Allocate and initialize VL dataset to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { int j; - wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(float)); + wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(float)); wdata[i].len = (size_t)(i + 1); - for(j = 0; j < i + 1; j++) + for (j = 0; j < i + 1; j++) ((float *)wdata[i].p)[j] = (float)((float)(i * 10) + ((float)j) / 10.0F); } /* end for */ /* write out the floats in little-endian format */ space = H5Screate_simple(SPACE1_RANK, dims, NULL); - type = H5Tvlen_create(H5T_NATIVE_FLOAT); - dset = H5Dcreate2(file, "Dataset2.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + type = H5Tvlen_create(H5T_NATIVE_FLOAT); + dset = H5Dcreate2(file, "Dataset2.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDassert(ret >= 0); ret = H5Treclaim(type, space, H5P_DEFAULT, wdata); HDassert(ret >= 0); @@ -2696,17 +2728,17 @@ static void gent_vldatatypes(void) HDassert(ret >= 0); /* Allocate and initialize a scalar VL dataset to write */ - adata.p = HDmalloc(37 * sizeof(int)); + adata.p = HDmalloc(37 * sizeof(int)); adata.len = 37; - for(i = 0; i < 37; i++) + for (i = 0; i < 37; i++) ((int *)adata.p)[i] = i * 2; /* write out scalar VL dataset in little-endian format */ space = H5Screate_simple(0, NULL, NULL); - type = H5Tvlen_create(H5T_NATIVE_INT); - dset = H5Dcreate2(file, "Dataset3.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &adata); + type = H5Tvlen_create(H5T_NATIVE_INT); + dset = H5Dcreate2(file, "Dataset3.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &adata); HDassert(ret >= 0); ret = H5Treclaim(type, space, H5P_DEFAULT, &adata); HDassert(ret >= 0); @@ -2724,35 +2756,35 @@ static void gent_vldatatypes(void) static void gent_vldatatypes2(void) { - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t *t1; /* Temporary pointer to VL information */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j,k; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hvl_t * t1; /* Temporary pointer to VL information */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hsize_t dims1[] = {SPACE1_DIM1}; + unsigned i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { + for (i = 0; i < SPACE1_DIM1; i++) { wdata[i].p = (hvl_t *)HDmalloc((i + 1) * sizeof(hvl_t)); - if(wdata[i].p == NULL) { + if (wdata[i].p == NULL) { HDprintf("Cannot allocate memory for VL data! i=%u\n", i); return; } /* end if */ wdata[i].len = i + 1; - for(t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) { + for (t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) { t1->p = (unsigned *)HDmalloc((j + 1) * sizeof(unsigned)); - if(t1->p == NULL) { - HDprintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); + if (t1->p == NULL) { + HDprintf("Cannot allocate memory for VL data! i=%u, j=%u\n", i, j); return; } /* end if */ - t1->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)t1->p)[k]=i*100+j*10+k; + t1->len = j + 1; + for (k = 0; k < (j + 1); k++) + ((unsigned int *)t1->p)[k] = i * 100 + j * 10 + k; } /* end for */ - } /* end for */ + } /* end for */ /* Create file */ fid1 = H5Fcreate(FILE22, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2788,32 +2820,32 @@ gent_vldatatypes2(void) HDassert(ret >= 0); ret = H5Fclose(fid1); HDassert(ret >= 0); - } -static void gent_vldatatypes3(void) +static void +gent_vldatatypes3(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; hvl_t v; } s1; - s1 wdata[SPACE1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + s1 wdata[SPACE1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hsize_t dims1[] = {SPACE1_DIM1}; + unsigned i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ - for(i=0; i= 0); } -static void gent_vldatatypes4(void) +static void +gent_vldatatypes4(void) { - typedef struct { /* Struct that the VL sequences are composed of */ - int i; + typedef struct { /* Struct that the VL sequences are composed of */ + int i; float f; } s1; - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1, tid2; /* Datatype IDs */ + hsize_t dims1[] = {SPACE1_DIM1}; + unsigned i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize VL data to write */ - for(i=0; i0); + HDassert(fid1 > 0); /* Create dataspace for datasets */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - HDassert(sid1>0); + HDassert(sid1 > 0); /* Create a datatype to refer to */ tid1 = H5Tvlen_create(H5T_NATIVE_UINT); - HDassert(tid1>0); + HDassert(tid1 > 0); /* Create a dataset */ dataset = H5Dcreate2(fid1, F43_DSETNAME, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(dataset>0); + HDassert(dataset > 0); ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); HDassert(ret >= 0); @@ -2982,10 +3016,10 @@ static void gent_vldatatypes5(void) ret = H5Tclose(tid1); HDassert(ret >= 0); - ret = H5Sclose (sid1); + ret = H5Sclose(sid1); HDassert(ret >= 0); - ret = H5Fclose (fid1); + ret = H5Fclose(fid1); HDassert(ret >= 0); } @@ -2996,42 +3030,43 @@ static void gent_vldatatypes5(void) display array indices every 262 x N (N > 0) based on 2000x1000 dims. */ #define SPACE_ARRAY1BIG_DIM 2000 -#define ARRAY1BIG_DIM 1000 +#define ARRAY1BIG_DIM 1000 -static void gent_array1_big(void) +static void +gent_array1_big(void) { - int *wdata; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t sdims1[] = {SPACE_ARRAY1BIG_DIM}; - hsize_t tdims1[] = {ARRAY1BIG_DIM}; - int i,j; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + int * wdata; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t sdims1[] = {SPACE_ARRAY1BIG_DIM}; + hsize_t tdims1[] = {ARRAY1BIG_DIM}; + int i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* for region reference dataset */ - hid_t dset2; - hid_t sid2; - hsize_t dims2[] = {SPACE1_DIM1}; - hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ - hdset_reg_ref_t *wbuf; /* buffer to write to disk */ - - start[0] = 0; + hid_t dset2; + hid_t sid2; + hsize_t dims2[] = {SPACE1_DIM1}; + hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ + hdset_reg_ref_t *wbuf; /* buffer to write to disk */ + + start[0] = 0; stride[0] = 1; - count[0] = 999; - block[0] = 1; + count[0] = 999; + block[0] = 1; /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); wdata = (int *)HDmalloc(sizeof(int) * (size_t)(SPACE_ARRAY1BIG_DIM * ARRAY1BIG_DIM)); /* Allocate and initialize array data to write */ - for(i = 0; i < SPACE_ARRAY1BIG_DIM; i++) - for(j = 0; j < ARRAY1BIG_DIM; j++) + for (i = 0; i < SPACE_ARRAY1BIG_DIM; i++) + for (j = 0; j < ARRAY1BIG_DIM; j++) *(wdata + (i * ARRAY1BIG_DIM) + j) = i * 1; /* Create file */ @@ -3071,7 +3106,7 @@ static void gent_array1_big(void) H5Rcreate(&wbuf[0], fid1, "/Dataset1", H5R_DATASET_REGION, sid1); /* Write selection to disk */ - H5Dwrite(dset2,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf); + H5Dwrite(dset2, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); /* Close Dataset */ ret = H5Dclose(dataset); @@ -3088,22 +3123,23 @@ static void gent_array1_big(void) HDfree(wdata); } -static void gent_array1(void) +static void +gent_array1(void) { - int wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j; /* counting variables */ - herr_t ret H5_ATTR_NDEBUG_UNUSED; /* Generic return value */ + int wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j; /* counting variables */ + herr_t ret H5_ATTR_NDEBUG_UNUSED; /* Generic return value */ /* Allocate and initialize array data to write */ - for(i=0; i= 0); } -static void gent_array2(void) +static void +gent_array2(void) { - int wdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information to write */ - hid_t fid; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ + int wdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information to write */ + hid_t fid; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims2[] = {ARRAY2_DIM1,ARRAY2_DIM2,ARRAY2_DIM3}; - int i,j,k,l; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + hsize_t tdims2[] = {ARRAY2_DIM1, ARRAY2_DIM2, ARRAY2_DIM3}; + int i, j, k, l; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize array data to write */ - for(i=0; i= 0); } -static void gent_array3(void) +static void +gent_array3(void) { - int wdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information to write */ - hid_t fid; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid1; /* 1-D array Datatype ID */ - hid_t tid2; /* 2-D array Datatype ID */ + int wdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information to write */ + hid_t fid; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid1; /* 1-D array Datatype ID */ + hid_t tid2; /* 2-D array Datatype ID */ hsize_t sdims1[] = {SPACE1_DIM1}; hsize_t tdims1[] = {ARRAY1_DIM1}; - hsize_t tdims2[] = {ARRAY3_DIM1,ARRAY3_DIM2}; - int i,j,k,l; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + hsize_t tdims2[] = {ARRAY3_DIM1, ARRAY3_DIM2}; + int i, j, k, l; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Allocate and initialize array data to write */ - for(i=0; i= 0); } -static void gent_array4(void) +static void +gent_array4(void) { - typedef struct { /* Typedef for compound datatype */ - int i; - float f; + typedef struct { /* Typedef for compound datatype */ + int i; + float f; } s2_t; - s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Compound Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* Compound Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ - for(i=0; i= 0); } -static void gent_array5(void) +static void +gent_array5(void) { - typedef struct { /* Typedef for compound datatype */ - int i; - float f[ARRAY1_DIM1]; + typedef struct { /* Typedef for compound datatype */ + int i; + float f[ARRAY1_DIM1]; } s2_t; - s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Compound Datatype ID */ - hid_t tid3; /* Nested Array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* Compound Datatype ID */ + hid_t tid3; /* Nested Array Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ - for(i=0; i= 0); /* Create an array of floats datatype */ tid3 = H5Tarray_create2(H5T_NATIVE_FLOAT, ARRAY1_RANK, tdims1); /* Insert float array field */ - ret = H5Tinsert (tid2, "f", HOFFSET(s2_t,f), tid3); + ret = H5Tinsert(tid2, "f", HOFFSET(s2_t, f), tid3); HDassert(ret >= 0); /* Close array of floats field datatype */ @@ -3372,25 +3412,26 @@ static void gent_array5(void) HDassert(ret >= 0); } -static void gent_array6(void) +static void +gent_array6(void) { - hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* VL Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k; /* counting variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* VL Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j, k; /* counting variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ - for(i=0; i= 0); } -static void gent_array7(void) +static void +gent_array7(void) { - hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* VL Datatype ID */ - hid_t tid3; /* Nested Array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k,l; /* Index variables */ - herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ + hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Array Datatype ID */ + hid_t tid2; /* VL Datatype ID */ + hid_t tid3; /* Nested Array Datatype ID */ + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int i, j, k, l; /* Index variables */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Initialize array data to write */ - for(i=0; i=0 && filetype>=0 && space>=0) { - dset = H5Dcreate2 (file, F64_DATASET, filetype, space, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); - if(dset>=0) - status = H5Dwrite (dset, filetype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(status >= 0); + if (file >= 0 && filetype >= 0 && space >= 0) { + dset = H5Dcreate2(file, F64_DATASET, filetype, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset >= 0) + status = H5Dwrite(dset, filetype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + HDassert(status >= 0); } /* * Close and release resources. */ - status = H5Dclose (dset); + status = H5Dclose(dset); HDassert(status >= 0); - status = H5Sclose (space); + status = H5Sclose(space); HDassert(status >= 0); - status = H5Tclose (filetype); + status = H5Tclose(filetype); HDassert(status >= 0); - status = H5Fclose (file); + status = H5Fclose(file); HDassert(status >= 0); HDfree(wdata); } -static void gent_empty(void) +static void +gent_empty(void) { typedef struct { - int a; - float b; - char c; + int a; + float b; + char c; } empty_struct; - hid_t file, dset, space, type; - hsize_t dims[] = { SPACE1_DIM1 }; - herr_t H5_ATTR_NDEBUG_UNUSED ret=0; + hid_t file, dset, space, type; + hsize_t dims[] = {SPACE1_DIM1}; + herr_t H5_ATTR_NDEBUG_UNUSED ret = 0; file = H5Fcreate(FILE32, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3612,10 +3656,10 @@ static void gent_empty(void) HDassert(ret >= 0); /* write out an empty compound dataset */ - type = H5Tcreate(H5T_COMPOUND,sizeof(empty_struct)); - H5Tinsert(type, "a", HOFFSET(empty_struct, a),H5T_NATIVE_INT); - H5Tinsert(type, "b", HOFFSET(empty_struct, b),H5T_NATIVE_FLOAT); - H5Tinsert(type, "c", HOFFSET(empty_struct, c),H5T_NATIVE_CHAR); + type = H5Tcreate(H5T_COMPOUND, sizeof(empty_struct)); + H5Tinsert(type, "a", HOFFSET(empty_struct, a), H5T_NATIVE_INT); + H5Tinsert(type, "b", HOFFSET(empty_struct, b), H5T_NATIVE_FLOAT); + H5Tinsert(type, "c", HOFFSET(empty_struct, c), H5T_NATIVE_CHAR); dset = H5Dcreate2(file, "Dataset5.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Don't write any data */ ret = H5Dclose(dset); @@ -3633,8 +3677,8 @@ static void gent_empty(void) static void gent_group_comments(void) { - hid_t fid = H5I_INVALID_HID; - hid_t group = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t group = H5I_INVALID_HID; hbool_t supports_comments = FALSE; fid = H5Fcreate(FILE33, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3707,23 +3751,26 @@ gent_group_comments(void) /* /glongcomment */ group = H5Gcreate2(fid, "/glongcomment", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (supports_comments) - H5Oset_comment_by_name(group, "/glongcomment", "Comment for group /glongcomment with a really, really, really long, long, long comment", H5P_DEFAULT); + H5Oset_comment_by_name( + group, "/glongcomment", + "Comment for group /glongcomment with a really, really, really long, long, long comment", + H5P_DEFAULT); H5Gclose(group); H5Fclose(fid); } -static -void gent_split_file(void) +static void +gent_split_file(void) { - hid_t fapl, fid, root, attr, space, dataset, atype; - char meta[] = "this is some metadata on this file"; + hid_t fapl, fid, root, attr, space, dataset, atype; + char meta[] = "this is some metadata on this file"; hsize_t dims[2]; - int i, j, dset[10][15]; + int i, j, dset[10][15]; fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); - fid = H5Fcreate(FILE34, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + fid = H5Fcreate(FILE34, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); root = H5Gopen2(fid, "/", H5P_DEFAULT); atype = H5Tcopy(H5T_C_S1); @@ -3731,8 +3778,8 @@ void gent_split_file(void) H5Tset_strpad(atype, H5T_STR_NULLTERM); dims[0] = 1; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "Metadata", atype, space, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(root, "Metadata", atype, space, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, atype, meta); H5Tclose(atype); H5Sclose(space); @@ -3741,11 +3788,11 @@ void gent_split_file(void) /* create dataset */ dims[0] = 10; dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 15; j++) dset[i][j] = i + j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); @@ -3756,14 +3803,14 @@ void gent_split_file(void) H5Pclose(fapl); } -static -void gent_family(void) +static void +gent_family(void) { - hid_t fapl, fid, space, dataset; + hid_t fapl, fid, space, dataset; hsize_t dims[2]; - int i, j, dset[10][15]; + int i, j, dset[10][15]; -#define FAMILY_SIZE 256 +#define FAMILY_SIZE 256 fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT); @@ -3773,11 +3820,11 @@ void gent_family(void) /* create dataset */ dims[0] = 10; dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 15; j++) dset[i][j] = i + j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); @@ -3789,23 +3836,23 @@ void gent_family(void) static const char *multi_letters = "msbrglo"; -static -void gent_multi(void) +static void +gent_multi(void) { - hid_t fapl, fid, space, dataset; + hid_t fapl, fid, space, dataset; hsize_t dims[2]; - int i, j, dset[10][15]; + int i, j, dset[10][15]; /* Multi-file driver, general case of the split driver */ - H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; + H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char **sv = NULL; - char *sv_data = NULL; - haddr_t memb_addr[H5FD_MEM_NTYPES]; + char ** sv = NULL; + char * sv_data = NULL; + haddr_t memb_addr[H5FD_MEM_NTYPES]; sv_data = (char *)HDcalloc(H5FD_MEM_NTYPES * 1024, sizeof(char)); - sv = (char **)HDcalloc(H5FD_MEM_NTYPES, sizeof(sv_data)); + sv = (char **)HDcalloc(H5FD_MEM_NTYPES, sizeof(sv_data)); for (i = 0; i < H5FD_MEM_NTYPES; i++) sv[i] = sv_data + (i * 1024); @@ -3818,9 +3865,9 @@ void gent_multi(void) HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { memb_fapl[mt] = H5P_DEFAULT; - memb_map[mt] = mt; + memb_map[mt] = mt; HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; /*HDprintf("memb_name[%d]=%s, memb_map[%d]=%d; ", mt, memb_name[mt], mt, memb_map[mt]);*/ @@ -3828,19 +3875,18 @@ void gent_multi(void) } memb_map[H5FD_MEM_DEFAULT] = H5FD_MEM_SUPER; - H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE); + H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE); fid = H5Fcreate(FILE36, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); /* create dataset */ dims[0] = 10; dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) + for (i = 0; i < 10; i++) + for (j = 0; j < 15; j++) dset[i][j] = i + j; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); @@ -3854,17 +3900,18 @@ void gent_multi(void) HDfree(sv_data); } -static void gent_large_objname(void) +static void +gent_large_objname(void) { - hid_t fid, group, group2; - char grp_name[128]; + hid_t fid, group, group2; + char grp_name[128]; register int i; fid = H5Fcreate(FILE37, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); group = H5Gcreate2(fid, "this_is_a_large_group_name", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 50; ++i) { + for (i = 0; i < 50; ++i) { HDsprintf(grp_name, "this_is_a_large_group_name%d", i); group2 = H5Gcreate2(group, grp_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Gclose(group2); @@ -3874,20 +3921,19 @@ static void gent_large_objname(void) H5Fclose(fid); } -static void gent_vlstr(void) +static void +gent_vlstr(void) { - const char *wdata[SPACE1_DIM1]= { - "Four score and seven years ago our forefathers brought forth on this continent a new nation,", - "conceived in liberty and dedicated to the proposition that all men are created equal.", - "", - NULL - }; /* Information to write */ - const char *string_att= "This is the string for the attribute"; - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, root; /* Dataset ID */ - hid_t sid1, dataspace;/* Dataspace ID */ - hid_t tid1, att; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; + const char *wdata[SPACE1_DIM1] = { + "Four score and seven years ago our forefathers brought forth on this continent a new nation,", + "conceived in liberty and dedicated to the proposition that all men are created equal.", "", + NULL}; /* Information to write */ + const char *string_att = "This is the string for the attribute"; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, root; /* Dataset ID */ + hid_t sid1, dataspace; /* Dataspace ID */ + hid_t tid1, att; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; /* Create file */ fid1 = H5Fcreate(FILE38, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -3895,8 +3941,8 @@ static void gent_vlstr(void) sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); /* Create a VL string datatype to refer to */ - tid1 = H5Tcopy (H5T_C_S1); - H5Tset_size (tid1, H5T_VARIABLE); + tid1 = H5Tcopy(H5T_C_S1); + H5Tset_size(tid1, H5T_VARIABLE); /* Create a dataset and write VL string to it. */ dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -3908,7 +3954,7 @@ static void gent_vlstr(void) H5Tcommit2(fid1, "vl_string_type", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Create an group attribute of VL string type */ - root = H5Gopen2(fid1, "/", H5P_DEFAULT); + root = H5Gopen2(fid1, "/", H5P_DEFAULT); dataspace = H5Screate(H5S_SCALAR); att = H5Acreate2(root, "test_scalar", tid1, dataspace, H5P_DEFAULT, H5P_DEFAULT); @@ -3923,19 +3969,19 @@ static void gent_vlstr(void) H5Fclose(fid1); } -static void gent_char(void) +static void +gent_char(void) { - const char *wdata = - "Four score and seven years ago our forefathers brought " - "forth on this continent a new nation, conceived in " - "liberty and dedicated to the proposition that all " - "men are created equal. Now we are engaged in a great " - "civil war, testing whether that nation or any nation " - "so conceived and so dedicated can long endure."; - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hsize_t dims1[1]; + const char *wdata = "Four score and seven years ago our forefathers brought " + "forth on this continent a new nation, conceived in " + "liberty and dedicated to the proposition that all " + "men are created equal. Now we are engaged in a great " + "civil war, testing whether that nation or any nation " + "so conceived and so dedicated can long endure."; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hsize_t dims1[1]; dims1[0] = HDstrlen(wdata); @@ -3955,8 +4001,6 @@ static void gent_char(void) H5Fclose(fid1); } - - /*------------------------------------------------------------------------- * Function: write_attr_in * @@ -3971,66 +4015,59 @@ static void gent_char(void) *------------------------------------------------------------------------- */ -static void write_attr_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid) +static void +write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to dataset*/ + hid_t fid) { /* Compound datatype */ - typedef struct s_t - { - char a; - double b; + typedef struct s_t { + char a; + double b; } s_t; - typedef enum - { - E_RED, - E_GREEN - } e_t; + typedef enum { E_RED, E_GREEN } e_t; - hid_t aid; - hid_t sid; - hid_t tid; - herr_t H5_ATTR_NDEBUG_UNUSED status; - int val, i, j, k, n; - float f; + hid_t aid; + hid_t sid; + hid_t tid; + herr_t H5_ATTR_NDEBUG_UNUSED status; + int val, i, j, k, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int buf7[2]= {1,2}; /* integer */ - float buf8[2]= {1,2}; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][3] = {"ab", "de"}; /* string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1, 2}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - + hsize_t dims3[3] = {4, 3, 2}; + char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", + "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ /*------------------------------------------------------------------------- * 1D attributes @@ -4041,9 +4078,9 @@ static void write_attr_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,1,dims,"string",tid,buf1); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_attr(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4051,26 +4088,26 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,1,dims,"bitfield",tid,buf2); + write_attr(loc_id, 1, dims, "bitfield", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,1,dims,"opaque",tid,buf2); + write_attr(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,1,dims,"compound",tid,buf3); + write_attr(loc_id, 1, dims, "compound", tid, buf3); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4078,11 +4115,10 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,(hid_t)-1); - status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,(hid_t)-1); - write_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); + if (dset_name) { + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); + write_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- @@ -4090,9 +4126,9 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,1,dims,"enum",tid,0); + write_attr(loc_id, 1, dims, "enum", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4102,17 +4138,17 @@ static void write_attr_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); ((int *)buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); ((int *)buf5[1].p)[0] = 2; ((int *)buf5[1].p)[1] = 3; - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf5); HDassert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); @@ -4136,7 +4172,6 @@ static void write_attr_in(hid_t loc_id, write_attr(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7); write_attr(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); - /*------------------------------------------------------------------------- * 2D attributes *------------------------------------------------------------------------- @@ -4146,9 +4181,9 @@ static void write_attr_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,2,dims2,"string2D",tid,buf12); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_attr(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4156,26 +4191,26 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,2,dims2,"bitfield2D",tid,buf22); + write_attr(loc_id, 2, dims2, "bitfield2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,2,dims2,"opaque2D",tid,buf22); + write_attr(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,2,dims2,"compound2D",tid,buf32); + write_attr(loc_id, 2, dims2, "compound2D", tid, buf32); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4183,14 +4218,13 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { - status=H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,(hid_t)-1); + if (dset_name) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); } } - write_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); + write_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- @@ -4198,9 +4232,9 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,2,dims2,"enum2D",tid,0); + write_attr(loc_id, 2, dims2, "enum2D", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4209,21 +4243,21 @@ static void write_attr_in(hid_t loc_id, */ /* Allocate and initialize VL dataset to write */ - n=0; - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { + n = 0; + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { int l; - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) + for (l = 0; l < i + 1; l++) ((int *)buf52[i][j].p)[l] = n++; } } - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf52); HDassert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); @@ -4247,7 +4281,6 @@ static void write_attr_in(hid_t loc_id, write_attr(loc_id, 2, dims2, "integer2D", H5T_NATIVE_INT, buf72); write_attr(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); - /*------------------------------------------------------------------------- * 3D attributes *------------------------------------------------------------------------- @@ -4257,9 +4290,9 @@ static void write_attr_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,3,dims3,"string3D",tid,buf13); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_attr(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4267,25 +4300,25 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { buf23[i][j][k] = (char)n++; } } } tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,3,dims3,"bitfield3D",tid,buf23); + write_attr(loc_id, 3, dims3, "bitfield3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,3,dims3,"opaque3D",tid,buf23); + write_attr(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4293,19 +4326,19 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { buf33[i][j][k].a = (char)n++; - buf33[i][j][k].b=n++; + buf33[i][j][k].b = n++; } } } - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,3,dims3,"compound3D",tid,buf33); + write_attr(loc_id, 3, dims3, "compound3D", tid, buf33); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4313,15 +4346,14 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) - status=H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,(hid_t)-1); + if (dset_name) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); } } - write_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); + write_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- @@ -4329,9 +4361,9 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,3,dims3,"enum3D",tid,0); + write_attr(loc_id, 3, dims3, "enum3D", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4341,22 +4373,22 @@ static void write_attr_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ n = 0; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { int l; - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) + for (l = 0; l < i + 1; l++) ((int *)buf53[i][j][k].p)[l] = n++; } } } - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf53); HDassert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); @@ -4370,8 +4402,8 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ n = 1; - for(i = 0; i < 24; i++) - for(j = 0; j < (int)dimarray[0]; j++) + for (i = 0; i < 24; i++) + for (j = 0; j < (int)dimarray[0]; j++) buf63[i][j] = n++; tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); @@ -4382,21 +4414,20 @@ static void write_attr_in(hid_t loc_id, * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - n=1; f=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; + n = 1; + f = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + buf73[i][j][k] = n++; + buf83[i][j][k] = f++; } } } - write_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); - write_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); + write_attr(loc_id, 3, dims3, "integer3D", H5T_NATIVE_INT, buf73); + write_attr(loc_id, 3, dims3, "float3D", H5T_NATIVE_FLOAT, buf83); } - - /*------------------------------------------------------------------------- * Function: write_dset_in * @@ -4411,68 +4442,61 @@ static void write_attr_in(hid_t loc_id, *------------------------------------------------------------------------- */ -static void write_dset_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid) +static void +write_dset_in(hid_t loc_id, const char *dset_name, /* for saving reference to dataset*/ + hid_t fid) { /* Compound datatype */ - typedef struct s_t - { - char a; - double b; + typedef struct s_t { + char a; + double b; } s_t; - typedef enum - { - E_RED, - E_GREEN - } e_t; - - hid_t did; - hid_t sid; - hid_t tid; - hid_t plist_id; - herr_t H5_ATTR_NDEBUG_UNUSED status; - int val, i, j, k, n; - float f; - int fillvalue=2; + typedef enum { E_RED, E_GREEN } e_t; + + hid_t did; + hid_t sid; + hid_t tid; + hid_t plist_id; + herr_t H5_ATTR_NDEBUG_UNUSED status; + int val, i, j, k, n; + float f; + int fillvalue = 2; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int buf7[2]= {1,2}; /* integer */ - float buf8[2]= {1,2}; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][3] = {"ab", "de"}; /* string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1, 2}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - + hsize_t dims3[3] = {4, 3, 2}; + char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", + "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ /*------------------------------------------------------------------------- * 1D @@ -4483,9 +4507,9 @@ static void write_dset_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,1,dims,"string",tid,buf1); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_dset(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4493,26 +4517,26 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,1,dims,"bitfield",tid,buf2); + write_dset(loc_id, 1, dims, "bitfield", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,1,dims,"opaque",tid,buf2); + write_dset(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,1,dims,"compound",tid,buf3); + write_dset(loc_id, 1, dims, "compound", tid, buf3); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4520,11 +4544,10 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,(hid_t)-1); - status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,(hid_t)-1); - write_dset(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); + if (dset_name) { + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); + write_dset(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- @@ -4532,9 +4555,9 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,1,dims,"enum",tid,0); + write_dset(loc_id, 1, dims, "enum", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4544,17 +4567,17 @@ static void write_dset_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf5[0].p)[0]=1; - buf5[1].len = 2; - buf5[1].p = HDmalloc( 2 * sizeof(int)); - ((int *)buf5[1].p)[0]=2; - ((int *)buf5[1].p)[1]=3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); HDassert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf5); @@ -4575,9 +4598,8 @@ static void write_dset_in(hid_t loc_id, * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7); - write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8); - + write_dset(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7); + write_dset(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); /*------------------------------------------------------------------------- * 2D @@ -4588,9 +4610,9 @@ static void write_dset_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,2,dims2,"string2D",tid,buf12); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_dset(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4598,26 +4620,26 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22); + write_dset(loc_id, 2, dims2, "bitfield2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,2,dims2,"opaque2D",tid,buf22); + write_dset(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,2,dims2,"compound2D",tid,buf32); + write_dset(loc_id, 2, dims2, "compound2D", tid, buf32); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4625,14 +4647,13 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { - status=H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,(hid_t)-1); + if (dset_name) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); } } - write_dset(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); + write_dset(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- @@ -4640,9 +4661,9 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,2,dims2,"enum2D",tid,0); + write_dset(loc_id, 2, dims2, "enum2D", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4651,20 +4672,20 @@ static void write_dset_in(hid_t loc_id, */ /* Allocate and initialize VL dataset to write */ - n=0; - for(i = 0; i < 3; i++) - for(j = 0; j < 2; j++) { + n = 0; + for (i = 0; i < 3; i++) + for (j = 0; j < 2; j++) { int l; - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) + for (l = 0; l < i + 1; l++) ((int *)buf52[i][j].p)[l] = n++; } - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52); HDassert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf52); @@ -4686,13 +4707,13 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ plist_id = H5Pcreate(H5P_DATASET_CREATE); - status = H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue); - sid = H5Screate_simple(2, dims2, NULL); - did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT); - status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); - status = H5Pclose(plist_id); - status = H5Dclose(did); - status = H5Sclose(sid); + status = H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue); + sid = H5Screate_simple(2, dims2, NULL); + did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT); + status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); + status = H5Pclose(plist_id); + status = H5Dclose(did); + status = H5Sclose(sid); /*------------------------------------------------------------------------- * H5T_FLOAT @@ -4701,7 +4722,6 @@ static void write_dset_in(hid_t loc_id, write_dset(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); - /*------------------------------------------------------------------------- * 3D *------------------------------------------------------------------------- @@ -4711,9 +4731,9 @@ static void write_dset_in(hid_t loc_id, * H5T_STRING *------------------------------------------------------------------------- */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,3,dims3,"string3D",tid,buf13); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, 2); + write_dset(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4721,22 +4741,22 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) + n = 1; + for (i = 0; i < 4; i++) + for (j = 0; j < 3; j++) + for (k = 0; k < 2; k++) buf23[i][j][k] = (char)n++; tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23); + write_dset(loc_id, 3, dims3, "bitfield3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, 1); + tid = H5Tcreate(H5T_OPAQUE, 1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,3,dims3,"opaque3D",tid,buf23); + write_dset(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4744,17 +4764,17 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) { + n = 1; + for (i = 0; i < 4; i++) + for (j = 0; j < 3; j++) + for (k = 0; k < 2; k++) { buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,3,dims3,"compound3D",tid,buf33); + write_dset(loc_id, 3, dims3, "compound3D", tid, buf33); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4762,15 +4782,14 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) - status=H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,(hid_t)-1); + if (dset_name) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); } } - write_dset(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); + write_dset(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- @@ -4778,9 +4797,9 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); + H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,3,dims3,"enum3D",tid,0); + write_dset(loc_id, 3, dims3, "enum3D", tid, 0); status = H5Tclose(tid); /*------------------------------------------------------------------------- @@ -4790,20 +4809,20 @@ static void write_dset_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ n = 0; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) { + for (i = 0; i < 4; i++) + for (j = 0; j < 3; j++) + for (k = 0; k < 2; k++) { int l; - buf53[i][j][k].p = HDmalloc(((size_t)i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc(((size_t)i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) + for (l = 0; l < i + 1; l++) ((int *)buf53[i][j][k].p)[l] = n++; } - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53); HDassert(status >= 0); status = H5Treclaim(tid, sid, H5P_DEFAULT, buf53); @@ -4816,10 +4835,10 @@ static void write_dset_in(hid_t loc_id, * H5T_ARRAY *------------------------------------------------------------------------- */ - n=1; - for(i = 0; i < 24; i++) { - for(j = 0; j < (int)dimarray[0]; j++) { - buf63[i][j]=n++; + n = 1; + for (i = 0; i < 24; i++) { + for (j = 0; j < (int)dimarray[0]; j++) { + buf63[i][j] = n++; } } @@ -4831,22 +4850,20 @@ static void write_dset_in(hid_t loc_id, * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - n=1; f=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; + n = 1; + f = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + buf73[i][j][k] = n++; + buf83[i][j][k] = f++; } } } - write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); - write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); + write_dset(loc_id, 3, dims3, "integer3D", H5T_NATIVE_INT, buf73); + write_dset(loc_id, 3, dims3, "float3D", H5T_NATIVE_FLOAT, buf83); } - - - /*------------------------------------------------------------------------- * Function: gent_attr_all * @@ -4861,23 +4878,24 @@ static void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ -static void gent_attr_all(void) +static void +gent_attr_all(void) { - hid_t fid; - hid_t did; - hid_t group_id; - hid_t group2_id; - hid_t root_id; - hid_t sid; - hsize_t dims[1] = {2}; - herr_t H5_ATTR_NDEBUG_UNUSED status; + hid_t fid; + hid_t did; + hid_t group_id; + hid_t group2_id; + hid_t root_id; + hid_t sid; + hsize_t dims[1] = {2}; + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Create a file and a dataset */ fid = H5Fcreate(FILE40, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create a 1D dataset */ - sid = H5Screate_simple(1,dims,NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Sclose(sid); HDassert(status >= 0); @@ -4891,16 +4909,16 @@ static void gent_attr_all(void) *------------------------------------------------------------------------- */ - write_attr_in(did,"dset",fid); - write_attr_in(group_id,NULL,(hid_t)0); - write_attr_in(root_id,NULL,(hid_t)0); + write_attr_in(did, "dset", fid); + write_attr_in(group_id, NULL, (hid_t)0); + write_attr_in(root_id, NULL, (hid_t)0); /*------------------------------------------------------------------------- * write a series of datasets on group 2 *------------------------------------------------------------------------- */ - write_dset_in(group2_id,"/dset",fid); + write_dset_in(group2_id, "/dset", fid); /* Close */ status = H5Dclose(did); @@ -4917,7 +4935,6 @@ static void gent_attr_all(void) HDassert(status >= 0); } - /*------------------------------------------------------------------------- * Function: write_attr * @@ -4930,13 +4947,12 @@ static void gent_attr_all(void) *------------------------------------------------------------------------- */ -static -int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, - hid_t tid, void *buf) +static int +write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, hid_t tid, void *buf) { - hid_t aid; - hid_t sid; - herr_t status; + hid_t aid; + hid_t sid; + herr_t status; /* Create a buf space */ sid = H5Screate_simple(rank, dims, NULL); @@ -4945,7 +4961,7 @@ int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, aid = H5Acreate2(loc_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT); /* Write the buf */ - if(buf) + if (buf) status = H5Awrite(aid, tid, buf); /* Close */ @@ -4969,13 +4985,12 @@ int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, *------------------------------------------------------------------------- */ -static -int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, - hid_t tid, void *buf ) +static int +write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf) { - hid_t did; - hid_t sid; - herr_t status; + hid_t did; + hid_t sid; + herr_t status; /* Create a buf space */ sid = H5Screate_simple(rank, dims, NULL); @@ -4984,7 +4999,7 @@ int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Write the buf */ - if(buf) + if (buf) status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); /* Close */ @@ -4994,67 +5009,64 @@ int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, return status; } - -static void gent_compound_complex(void) +static void +gent_compound_complex(void) { /* Structure and array for compound types */ typedef struct Array1Struct { - int a; - const char *b[F41_DIMb]; - char c[F41_ARRAY_DIMc]; - short d[F41_ARRAY_DIMd1][F41_ARRAY_DIMd2]; - float e; - double f[F41_ARRAY_DIMf]; - char g; + int a; + const char *b[F41_DIMb]; + char c[F41_ARRAY_DIMc]; + short d[F41_ARRAY_DIMd1][F41_ARRAY_DIMd2]; + float e; + double f[F41_ARRAY_DIMf]; + char g; } Array1Struct; - Array1Struct Array1[F41_LENGTH]; + Array1Struct Array1[F41_LENGTH]; /* Define the value of the string array */ - const char *quote [F41_DIMb] = { - "A fight is a contract that takes two people to honor.", - "A combative stance means that you've accepted the contract.", - "In which case, you deserve what you get.", - " -- Professor Cheng Man-ch'ing" - }; + const char *quote[F41_DIMb] = {"A fight is a contract that takes two people to honor.", + "A combative stance means that you've accepted the contract.", + "In which case, you deserve what you get.", + " -- Professor Cheng Man-ch'ing"}; /* Define the value of the character array */ - char chararray [F41_ARRAY_DIMc] = {'H', 'e', 'l', 'l', 'o', '!'}; - + char chararray[F41_ARRAY_DIMc] = {'H', 'e', 'l', 'l', 'o', '!'}; + + hid_t Array1Structid; /* File datatype identifier */ + hid_t array_tid; /* Array datatype handle */ + hid_t array1_tid; /* Array datatype handle */ + hid_t array2_tid; /* Array datatype handle */ + hid_t array4_tid; /* Array datatype handle */ + hid_t datafile, dataset; /* Datafile/dataset handles */ + hid_t dataspace; /* Dataspace handle */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F41_LENGTH}; /* Dataspace dimensions */ + hsize_t array_dimb[] = {F41_DIMb}; /* Array dimensions */ + hsize_t array_dimd[] = {F41_ARRAY_DIMd1, F41_ARRAY_DIMd2}; /* Array dimensions */ + hsize_t array_dimf[] = {F41_ARRAY_DIMf}; /* Array dimensions */ + hid_t str_array_id; - hid_t Array1Structid; /* File datatype identifier */ - hid_t array_tid; /* Array datatype handle */ - hid_t array1_tid; /* Array datatype handle */ - hid_t array2_tid; /* Array datatype handle */ - hid_t array4_tid; /* Array datatype handle */ - hid_t datafile, dataset; /* Datafile/dataset handles */ - hid_t dataspace; /* Dataspace handle */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ - hsize_t dim[] = {F41_LENGTH}; /* Dataspace dimensions */ - hsize_t array_dimb[] = {F41_DIMb}; /* Array dimensions */ - hsize_t array_dimd[]={F41_ARRAY_DIMd1,F41_ARRAY_DIMd2}; /* Array dimensions */ - hsize_t array_dimf[]={F41_ARRAY_DIMf}; /* Array dimensions */ - hid_t str_array_id; - - int m, n, o; /* Array init loop vars */ + int m, n, o; /* Array init loop vars */ /* Initialize the data in the arrays/datastructure */ - for(m = 0; m< F41_LENGTH; m++) { + for (m = 0; m < F41_LENGTH; m++) { Array1[m].a = m; - for(n = 0; n < F41_DIMb; n++) + for (n = 0; n < F41_DIMb; n++) Array1[m].b[n] = quote[n]; - for(n = 0; n < F41_ARRAY_DIMc; n++) + for (n = 0; n < F41_ARRAY_DIMc; n++) Array1[m].c[n] = chararray[n]; - for(n = 0; n < F41_ARRAY_DIMd1; n++) - for(o = 0; o < F41_ARRAY_DIMd2; o++) + for (n = 0; n < F41_ARRAY_DIMd1; n++) + for (o = 0; o < F41_ARRAY_DIMd2; o++) Array1[m].d[n][o] = (short)(m + n + o); - Array1[m].e = (float)((float)m * 0.96F ); + Array1[m].e = (float)((float)m * 0.96F); - for(n = 0; n < F41_ARRAY_DIMf; n++) - Array1[m].f[n] = ((float)m * 1024.9637F ); + for (n = 0; n < F41_ARRAY_DIMf; n++) + Array1[m].f[n] = ((float)m * 1024.9637F); Array1[m].g = 'm'; } @@ -5064,16 +5076,15 @@ static void gent_compound_complex(void) HDassert(dataspace >= 0); /* Create the file */ - datafile = H5Fcreate(FILE41, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT); + datafile = H5Fcreate(FILE41, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); HDassert(datafile >= 0); /* Copy the array data type for the string array */ - array_tid = H5Tcopy (H5T_C_S1); + array_tid = H5Tcopy(H5T_C_S1); HDassert(array_tid >= 0); /* Set the string array size to Variable */ - status = H5Tset_size (array_tid,H5T_VARIABLE); + status = H5Tset_size(array_tid, H5T_VARIABLE); HDassert(status >= 0); /* Create the array data type for the string array */ @@ -5081,11 +5092,11 @@ static void gent_compound_complex(void) HDassert(str_array_id >= 0); /* Copy the array data type for the character array */ - array1_tid = H5Tcopy (H5T_C_S1); + array1_tid = H5Tcopy(H5T_C_S1); HDassert(array1_tid >= 0); /* Set the character array size */ - status = H5Tset_size (array1_tid, F41_ARRAY_DIMc); + status = H5Tset_size(array1_tid, F41_ARRAY_DIMc); HDassert(status >= 0); /* Create the array data type for the character array */ @@ -5097,45 +5108,37 @@ static void gent_compound_complex(void) HDassert(array4_tid >= 0); /* Create the memory data type */ - Array1Structid = H5Tcreate (H5T_COMPOUND, sizeof(Array1Struct)); + Array1Structid = H5Tcreate(H5T_COMPOUND, sizeof(Array1Struct)); HDassert(Array1Structid >= 0); /* Insert the arrays and variables into the structure */ - status = H5Tinsert(Array1Structid, "a_name", - HOFFSET(Array1Struct, a), H5T_NATIVE_INT); + status = H5Tinsert(Array1Structid, "a_name", HOFFSET(Array1Struct, a), H5T_NATIVE_INT); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "b_name", - HOFFSET(Array1Struct, b), str_array_id); + status = H5Tinsert(Array1Structid, "b_name", HOFFSET(Array1Struct, b), str_array_id); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "c_name", - HOFFSET(Array1Struct, c), array1_tid); + status = H5Tinsert(Array1Structid, "c_name", HOFFSET(Array1Struct, c), array1_tid); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "d_name", - HOFFSET(Array1Struct, d), array2_tid); + status = H5Tinsert(Array1Structid, "d_name", HOFFSET(Array1Struct, d), array2_tid); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "e_name", - HOFFSET(Array1Struct, e), H5T_NATIVE_FLOAT); + status = H5Tinsert(Array1Structid, "e_name", HOFFSET(Array1Struct, e), H5T_NATIVE_FLOAT); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "f_name", - HOFFSET(Array1Struct, f), array4_tid); + status = H5Tinsert(Array1Structid, "f_name", HOFFSET(Array1Struct, f), array4_tid); HDassert(status >= 0); - status = H5Tinsert(Array1Structid, "g_name", - HOFFSET(Array1Struct, g), H5T_NATIVE_CHAR); + status = H5Tinsert(Array1Structid, "g_name", HOFFSET(Array1Struct, g), H5T_NATIVE_CHAR); HDassert(status >= 0); /* Create the dataset */ - dataset = H5Dcreate2(datafile, F41_DATASETNAME, Array1Structid, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(datafile, F41_DATASETNAME, Array1Structid, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); /* Write data to the dataset */ - status = H5Dwrite(dataset, Array1Structid, H5S_ALL, H5S_ALL, - H5P_DEFAULT, Array1); + status = H5Dwrite(dataset, Array1Structid, H5S_ALL, H5S_ALL, H5P_DEFAULT, Array1); HDassert(status >= 0); /* Release resources */ @@ -5167,21 +5170,21 @@ static void gent_compound_complex(void) HDassert(status >= 0); } - -static void gent_named_dtype_attr(void) +static void +gent_named_dtype_attr(void) { - hid_t fid; - hid_t did; - hid_t sid; - hid_t tid; - hid_t aid; - hid_t gid; - int data=8; + hid_t fid; + hid_t did; + hid_t sid; + hid_t tid; + hid_t aid; + hid_t gid; + int data = 8; herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Create a file */ - fid=H5Fcreate(FILE42, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>0); + fid = H5Fcreate(FILE42, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid > 0); /*------------------------------------------------------------------------- * datatype @@ -5189,8 +5192,8 @@ static void gent_named_dtype_attr(void) */ /* Create a datatype to commit and use */ - tid=H5Tcopy(H5T_NATIVE_INT); - HDassert(tid>0); + tid = H5Tcopy(H5T_NATIVE_INT); + HDassert(tid > 0); /* Commit datatype to file */ ret = H5Tcommit2(fid, F42_TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -5272,20 +5275,20 @@ static void gent_named_dtype_attr(void) HDassert(ret >= 0); } - /*------------------------------------------------------------------------- * Function: gent_null_space * * Purpose: generates dataset and attribute of null dataspace *------------------------------------------------------------------------- */ -static void gent_null_space(void) +static void +gent_null_space(void) { hid_t fid, root, dataset, space, attr; - int dset_buf = 10; - int point = 4; + int dset_buf = 10; + int point = 4; - fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* null space */ @@ -5313,22 +5316,23 @@ static void gent_null_space(void) * Purpose: generates dataset and attribute with dataspace of 0 dimension size *------------------------------------------------------------------------- */ -static void gent_zero_dim_size(void) +static void +gent_zero_dim_size(void) { - hid_t fid, root, dataset, space, attr; - hsize_t dims1[] = {SPACE3_DIM1, SPACE3_DIM2}; - int dset_buf = 10; - int point = 4; + hid_t fid, root, dataset, space, attr; + hsize_t dims1[] = {SPACE3_DIM1, SPACE3_DIM2}; + int dset_buf = 10; + int point = 4; - fid = H5Fcreate(FILE67, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE67, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* dataspace of 0 dimension size */ space = H5Screate_simple(SPACE3_RANK, dims1, NULL); /* dataset */ - dataset = H5Dcreate2(fid, "dset of 0 dimension size", H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, "dset of 0 dimension size", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); /* nothing should be written */ H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf); @@ -5350,39 +5354,34 @@ static void gent_zero_dim_size(void) * *------------------------------------------------------------------------- */ -static -int make_dset(hid_t loc_id, - const char *name, - hid_t sid, - hid_t tid, - hid_t dcpl, - void *buf) +static int +make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t tid, hid_t dcpl, void *buf) { - hid_t dsid; + hid_t dsid; /* create the dataset */ - if((dsid = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; /* write */ - if(H5Dwrite(dsid, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dsid, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) return -1; return 0; - out: - H5E_BEGIN_TRY { +out: + H5E_BEGIN_TRY + { H5Dclose(dsid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - /*------------------------------------------------------------------------- * Function: make_external * @@ -5393,19 +5392,19 @@ int make_dset(hid_t loc_id, static void make_external(hid_t fid) { - hid_t dcpl; /*dataset creation property list */ - hid_t sid; /*dataspace ID */ - hid_t dsid; /*dataset ID */ - hsize_t cur_size[1]; /*data space current size */ - hsize_t max_size[1]; /*data space maximum size */ - hsize_t size; /*bytes reserved for data in the external file*/ - int H5_ATTR_NDEBUG_UNUSED ret; + hid_t dcpl; /*dataset creation property list */ + hid_t sid; /*dataspace ID */ + hid_t dsid; /*dataset ID */ + hsize_t cur_size[1]; /*data space current size */ + hsize_t max_size[1]; /*data space maximum size */ + hsize_t size; /*bytes reserved for data in the external file*/ + int H5_ATTR_NDEBUG_UNUSED ret; cur_size[0] = max_size[0] = 100; - size = (max_size[0]*sizeof(int)/2); + size = (max_size[0] * sizeof(int) / 2); dcpl = H5Pcreate(H5P_DATASET_CREATE); - ret = H5Pset_external(dcpl, "ext1.bin", (off_t)0, size); + ret = H5Pset_external(dcpl, "ext1.bin", (off_t)0, size); HDassert(ret >= 0); ret = H5Pset_external(dcpl, "ext2.bin", (off_t)0, size); @@ -5434,32 +5433,33 @@ make_external(hid_t fid) * *------------------------------------------------------------------------- */ -static void gent_filters(void) +static void +gent_filters(void) { - hid_t fid; /* file id */ - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ + hid_t fid; /* file id */ + hid_t dcpl; /* dataset creation property list */ + hid_t sid; /* dataspace ID */ + hid_t tid; /* datatype ID */ #ifdef H5_HAVE_FILTER_SZIP - unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block=4; + unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block = 4; #endif /* H5_HAVE_FILTER_SZIP */ - hsize_t dims1[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int buf1[DIM1][DIM2]; - int i, j, n; + hsize_t dims1[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf1[DIM1][DIM2]; + int i, j, n; int H5_ATTR_NDEBUG_UNUSED ret; - hbool_t supports_comments = FALSE; + hbool_t supports_comments = FALSE; - for(i=n=0; i=0); + fid = H5Fcreate(FILE44, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /* Check if we support comments in the current VOL connector */ H5VLquery_optional(fid, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_SET_COMMENT, &supports_comments); @@ -5478,7 +5478,7 @@ static void gent_filters(void) ret = H5Pset_layout(dcpl, H5D_COMPACT); HDassert(ret >= 0); - ret=make_dset(fid,"compact",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "compact", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); if (supports_comments) { @@ -5489,11 +5489,12 @@ static void gent_filters(void) ret = H5Pset_layout(dcpl, H5D_CONTIGUOUS); HDassert(ret >= 0); - ret=make_dset(fid,"contiguous",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "contiguous", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); if (supports_comments) { - ret = H5Oset_comment_by_name(fid, "contiguous", "This is a dataset with contiguous storage", H5P_DEFAULT); + ret = H5Oset_comment_by_name(fid, "contiguous", "This is a dataset with contiguous storage", + H5P_DEFAULT); HDassert(ret >= 0); } @@ -5503,7 +5504,7 @@ static void gent_filters(void) ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims); HDassert(ret >= 0); - ret=make_dset(fid,"chunked",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "chunked", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); if (supports_comments) { @@ -5525,16 +5526,16 @@ static void gent_filters(void) *------------------------------------------------------------------------- */ #ifdef H5_HAVE_FILTER_SZIP - if(h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { + if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set szip data */ - ret = H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); + ret = H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block); HDassert(ret >= 0); - ret=make_dset(fid,"szip",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "szip", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); } #endif /* H5_HAVE_FILTER_SZIP */ @@ -5543,51 +5544,49 @@ static void gent_filters(void) * GZIP *------------------------------------------------------------------------- */ -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set deflate data */ ret = H5Pset_deflate(dcpl, 9); HDassert(ret >= 0); - ret=make_dset(fid,"deflate",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "deflate", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); #endif - /*------------------------------------------------------------------------- * shuffle *------------------------------------------------------------------------- */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the shuffle filter */ ret = H5Pset_shuffle(dcpl); HDassert(ret >= 0); - ret=make_dset(fid,"shuffle",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "shuffle", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); - /*------------------------------------------------------------------------- * checksum *------------------------------------------------------------------------- */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the checksum filter */ ret = H5Pset_fletcher32(dcpl); HDassert(ret >= 0); - ret=make_dset(fid,"fletcher32",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "fletcher32", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5596,16 +5595,16 @@ static void gent_filters(void) */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the checksum filter */ ret = H5Pset_nbit(dcpl); HDassert(ret >= 0); - tid=H5Tcopy(H5T_NATIVE_INT); - H5Tset_precision(tid,H5Tget_size(tid)-1); - ret=make_dset(fid,"nbit",sid,tid,dcpl,buf1); + tid = H5Tcopy(H5T_NATIVE_INT); + H5Tset_precision(tid, H5Tget_size(tid) - 1); + ret = make_dset(fid, "nbit", sid, tid, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5614,14 +5613,14 @@ static void gent_filters(void) */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the scaleoffset filter */ - ret = H5Pset_scaleoffset(dcpl,H5Z_SO_INT,(int)H5Tget_size(H5T_NATIVE_INT)); + ret = H5Pset_scaleoffset(dcpl, H5Z_SO_INT, (int)H5Tget_size(H5T_NATIVE_INT)); HDassert(ret >= 0); - ret=make_dset(fid,"scaleoffset",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "scaleoffset", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5629,7 +5628,7 @@ static void gent_filters(void) *------------------------------------------------------------------------- */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /* set the shuffle filter */ @@ -5637,15 +5636,15 @@ static void gent_filters(void) HDassert(ret >= 0); #ifdef H5_HAVE_FILTER_SZIP - if(h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { - szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; + if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { + szip_options_mask = H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; /* set szip data */ - ret = H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); + ret = H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block); HDassert(ret >= 0); } #endif /* H5_HAVE_FILTER_SZIP */ -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ ret = H5Pset_deflate(dcpl, 5); HDassert(ret >= 0); @@ -5659,29 +5658,28 @@ static void gent_filters(void) ret = H5Pset_nbit(dcpl); HDassert(ret >= 0); - ret=make_dset(fid,"all",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "all", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); - /*------------------------------------------------------------------------- * user defined filter *------------------------------------------------------------------------- */ /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); - ret = H5Zregister (H5Z_MYFILTER); + ret = H5Zregister(H5Z_MYFILTER); HDassert(ret >= 0); - ret = H5Pset_filter (dcpl, MYFILTER_ID, 0, 0, NULL); + ret = H5Pset_filter(dcpl, MYFILTER_ID, 0, 0, NULL); HDassert(ret >= 0); - ret=make_dset(fid,"myfilter",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "myfilter", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); + ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5696,7 +5694,7 @@ static void gent_filters(void) */ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_early",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "alloc_time_early", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5705,7 +5703,7 @@ static void gent_filters(void) */ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR); HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_incr",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "alloc_time_incr", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5714,7 +5712,7 @@ static void gent_filters(void) */ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_late",sid,H5T_NATIVE_INT,dcpl,buf1); + ret = make_dset(fid, "alloc_time_late", sid, H5T_NATIVE_INT, dcpl, buf1); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5747,7 +5745,6 @@ static void gent_filters(void) HDassert(ret >= 0); } - /*------------------------------------------------------------------------- * Function: myfilter * @@ -5757,13 +5754,12 @@ static void gent_filters(void) */ static size_t myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) + const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { return nbytes; } - /*------------------------------------------------------------------------- * Function: set_local_myfilter * @@ -5775,21 +5771,21 @@ myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, static herr_t set_local_myfilter(hid_t dcpl_id, hid_t H5_ATTR_UNUSED tid, hid_t H5_ATTR_UNUSED sid) { - unsigned flags; /* Filter flags */ - size_t cd_nelmts = 0; /* Number of filter parameters */ - unsigned cd_values[2] = {5, 6}; /* Filter parameters */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = 0; /* Number of filter parameters */ + unsigned cd_values[2] = {5, 6}; /* Filter parameters */ /* Get the filter's current parameters */ - if(H5Pget_filter_by_id2(dcpl_id, MYFILTER_ID, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) - return(FAIL); + if (H5Pget_filter_by_id2(dcpl_id, MYFILTER_ID, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) + return (FAIL); cd_nelmts = 2; /* Modify the filter's parameters for this dataset */ - if(H5Pmodify_filter(dcpl_id, MYFILTER_ID, flags, cd_nelmts, cd_values) < 0) - return(FAIL); + if (H5Pmodify_filter(dcpl_id, MYFILTER_ID, flags, cd_nelmts, cd_values) < 0) + return (FAIL); - return(SUCCEED); + return (SUCCEED); } /*------------------------------------------------------------------------- @@ -5799,62 +5795,54 @@ set_local_myfilter(hid_t dcpl_id, hid_t H5_ATTR_UNUSED tid, hid_t H5_ATTR_UNUSED * *------------------------------------------------------------------------- */ -static void gent_fcontents(void) +static void +gent_fcontents(void) { - hid_t fid; /* file id */ - hid_t gid1; /* group ID */ - hid_t tid; /* datatype ID */ - hsize_t dims[1]={4}; - int buf[4]={1,2,3,4}; - int H5_ATTR_NDEBUG_UNUSED ret; - - /* create a file */ - fid = H5Fcreate(FILE46, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - + hid_t fid; /* file id */ + hid_t gid1; /* group ID */ + hid_t tid; /* datatype ID */ + hsize_t dims[1] = {4}; + int buf[4] = {1, 2, 3, 4}; + int H5_ATTR_NDEBUG_UNUSED ret; - write_dset(fid,1,dims,"dset",H5T_NATIVE_INT,buf); + /* create a file */ + fid = H5Fcreate(FILE46, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); + write_dset(fid, 1, dims, "dset", H5T_NATIVE_INT, buf); /*------------------------------------------------------------------------- * links *------------------------------------------------------------------------- */ - /* hard link to "dset" */ gid1 = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Lcreate_hard(gid1, "/dset", H5L_SAME_LOC, "dset1", H5P_DEFAULT, H5P_DEFAULT); H5Gclose(gid1); - /* hard link to "dset" */ gid1 = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Lcreate_hard(gid1, "/dset", H5L_SAME_LOC, "dset2", H5P_DEFAULT, H5P_DEFAULT); H5Gclose(gid1); - /* hard link to "g2" */ gid1 = H5Gopen2(fid, "/g1", H5P_DEFAULT); H5Lcreate_hard(gid1, "/g2", H5L_SAME_LOC, "g1.1", H5P_DEFAULT, H5P_DEFAULT); H5Gclose(gid1); - /* hard link to "dset" */ ret = H5Lcreate_hard(fid, "/dset", H5L_SAME_LOC, "dset3", H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); - /* hard link to "dset" */ ret = H5Lcreate_hard(fid, "/dset", H5L_SAME_LOC, "dset4", H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); - /* soft link to itself */ ret = H5Lcreate_soft("mylink", fid, "mylink", H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); - /* soft link to "dset" */ ret = H5Lcreate_soft("/dset", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); @@ -5877,7 +5865,6 @@ static void gent_fcontents(void) ret = H5Tclose(tid); HDassert(ret >= 0); - /* no name datatype */ tid = H5Tcopy(H5T_NATIVE_INT); ret = H5Tcommit2(fid, "mytype2", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -5888,21 +5875,17 @@ static void gent_fcontents(void) ret = H5Tclose(tid); HDassert(ret >= 0); - /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ - ret = H5Fclose(fid); HDassert(ret >= 0); - /* create a file for the bootblock test */ - fid = H5Fcreate(FILE47, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - + fid = H5Fcreate(FILE47, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); ret = H5Fclose(fid); HDassert(ret >= 0); @@ -5915,35 +5898,34 @@ static void gent_fcontents(void) * *------------------------------------------------------------------------- */ -static void gent_fvalues(void) +static void +gent_fvalues(void) { /* compound datatype */ - typedef struct c_t - { - char a; - double b; + typedef struct c_t { + char a; + double b; } c_t; - - hid_t fid; /* file id */ - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ - hid_t did; /* datasetID */ - hsize_t dims[1]={2}; - int buf[2]={1,2}; /* integer */ - int fillval1=-99; /* integer fill value */ - c_t buf2[2]={{1,2},{3,4}}; /* compound */ - c_t fillval2[1]={{1,2}}; /* compound fill value */ - hvl_t buf3[2]; /* vlen */ - hvl_t fillval3; /* vlen fill value */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf4[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int H5_ATTR_NDEBUG_UNUSED ret; + hid_t fid; /* file id */ + hid_t dcpl; /* dataset creation property list */ + hid_t sid; /* dataspace ID */ + hid_t tid; /* datatype ID */ + hid_t did; /* datasetID */ + hsize_t dims[1] = {2}; + int buf[2] = {1, 2}; /* integer */ + int fillval1 = -99; /* integer fill value */ + c_t buf2[2] = {{1, 2}, {3, 4}}; /* compound */ + c_t fillval2[1] = {{1, 2}}; /* compound fill value */ + hvl_t buf3[2]; /* vlen */ + hvl_t fillval3; /* vlen fill value */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf4[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int H5_ATTR_NDEBUG_UNUSED ret; /* create a file */ - fid = H5Fcreate(FILE48, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE48, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /* create a space */ sid = H5Screate_simple(1, dims, NULL); @@ -5962,7 +5944,7 @@ static void gent_fvalues(void) ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); HDassert(ret >= 0); - ret=make_dset(fid,"fill_time_ifset",sid,H5T_NATIVE_INT,dcpl,buf); + ret = make_dset(fid, "fill_time_ifset", sid, H5T_NATIVE_INT, dcpl, buf); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5975,7 +5957,7 @@ static void gent_fvalues(void) ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); HDassert(ret >= 0); - ret=make_dset(fid,"fill_time_never",sid,H5T_NATIVE_INT,dcpl,buf); + ret = make_dset(fid, "fill_time_never", sid, H5T_NATIVE_INT, dcpl, buf); HDassert(ret >= 0); /*------------------------------------------------------------------------- @@ -5988,7 +5970,7 @@ static void gent_fvalues(void) ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); HDassert(ret >= 0); - ret=make_dset(fid,"fill_time_alloc",sid,H5T_NATIVE_INT,dcpl,buf); + ret = make_dset(fid, "fill_time_alloc", sid, H5T_NATIVE_INT, dcpl, buf); HDassert(ret >= 0); ret = H5Pclose(dcpl); @@ -5998,19 +5980,19 @@ static void gent_fvalues(void) * dataset with no fill value *------------------------------------------------------------------------- */ - write_dset(fid,1,dims,"no_fill",H5T_NATIVE_INT,buf); + write_dset(fid, 1, dims, "no_fill", H5T_NATIVE_INT, buf); /*------------------------------------------------------------------------- * dataset with a H5T_COMPOUND fill value *------------------------------------------------------------------------- */ dcpl = H5Pcreate(H5P_DATASET_CREATE); - tid = H5Tcreate (H5T_COMPOUND, sizeof(c_t)); + tid = H5Tcreate(H5T_COMPOUND, sizeof(c_t)); H5Tinsert(tid, "a", HOFFSET(c_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(c_t, b), H5T_NATIVE_DOUBLE); ret = H5Pset_fill_value(dcpl, tid, &fillval2); HDassert(ret >= 0); - ret=make_dset(fid,"fill_compound",sid,tid,dcpl,buf2); + ret = make_dset(fid, "fill_compound", sid, tid, dcpl, buf2); HDassert(ret >= 0); ret = H5Tclose(tid); HDassert(ret >= 0); @@ -6021,19 +6003,20 @@ static void gent_fvalues(void) * dataset with a H5T_VLEN fill value *------------------------------------------------------------------------- */ - buf3[0].len = 1; - buf3[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf3[0].p)[0]=1; - buf3[1].len = 2; - buf3[1].p = HDmalloc(2 * sizeof(int)); + buf3[0].len = 1; + buf3[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf3[0].p)[0] = 1; + buf3[1].len = 2; + buf3[1].p = HDmalloc(2 * sizeof(int)); ((int *)buf3[1].p)[0] = 2; ((int *)buf3[1].p)[1] = 3; - tid = H5Tvlen_create(H5T_NATIVE_INT); + tid = H5Tvlen_create(H5T_NATIVE_INT); dcpl = H5Pcreate(H5P_DATASET_CREATE); - fillval3.p=NULL; fillval3.len=0; - ret = H5Pset_fill_value(dcpl, tid, &fillval3); + fillval3.p = NULL; + fillval3.len = 0; + ret = H5Pset_fill_value(dcpl, tid, &fillval3); HDassert(ret >= 0); did = H5Dcreate2(fid, "fill_vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -6054,7 +6037,6 @@ static void gent_fvalues(void) write_dset(fid, 1, dims, "fill_array", tid, buf4); ret = H5Tclose(tid); - /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -6065,7 +6047,6 @@ static void gent_fvalues(void) HDassert(ret >= 0); } - /*------------------------------------------------------------------------- * Function: gent_string * @@ -6073,49 +6054,50 @@ static void gent_fvalues(void) * *------------------------------------------------------------------------- */ -static void gent_string(void) +static void +gent_string(void) { /* compound datatype */ - typedef struct c_t - { - int a; - char str[255]; + typedef struct c_t { + int a; + char str[255]; } c_t; - hid_t fid; /* file id */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ - hid_t str_tid; /* datatype ID */ - hid_t did; /* dataset ID */ - char buf1[]={"quote \" backspace\b form feed\f new line\n tab\t new line\n carriage return\r"}; - const char *buf2[SPACE1_DIM1]= { - "Four score and seven\n years ago our forefathers brought forth on this continent a new nation,", - "conceived in liberty\n and dedicated to the proposition that all men are created equal.", - "Now we are engaged\n in a great civil war,", - "testing whether that\n nation or any nation so conceived and so dedicated can long endure." - }; - c_t buf3 = {24, "Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; - char buf4[] = {"Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; - hsize_t dims1[] = {1}; - hsize_t dims2[] = {SPACE1_DIM1}; - hsize_t dims4[1]; - int H5_ATTR_NDEBUG_UNUSED ret; + hid_t fid; /* file id */ + hid_t sid; /* dataspace ID */ + hid_t tid; /* datatype ID */ + hid_t str_tid; /* datatype ID */ + hid_t did; /* dataset ID */ + char buf1[] = {"quote \" backspace\b form feed\f new line\n tab\t new line\n carriage return\r"}; + const char *buf2[SPACE1_DIM1] = { + "Four score and seven\n years ago our forefathers brought forth on this continent a new nation,", + "conceived in liberty\n and dedicated to the proposition that all men are created equal.", + "Now we are engaged\n in a great civil war,", + "testing whether that\n nation or any nation so conceived and so dedicated can long endure."}; + c_t buf3 = { + 24, "Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; + char buf4[] = { + "Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; + hsize_t dims1[] = {1}; + hsize_t dims2[] = {SPACE1_DIM1}; + hsize_t dims4[1]; + int H5_ATTR_NDEBUG_UNUSED ret; dims4[0] = sizeof(buf4); /* create a file */ - fid = H5Fcreate(FILE49, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE49, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /*------------------------------------------------------------------------- * str1 *------------------------------------------------------------------------- */ - tid=H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); ret = H5Tset_size(tid, sizeof(buf1)); HDassert(ret >= 0); - write_dset(fid,1,dims1,"str1",tid,buf1); + write_dset(fid, 1, dims1, "str1", tid, buf1); HDassert(ret >= 0); ret = H5Tclose(tid); HDassert(ret >= 0); @@ -6142,13 +6124,13 @@ static void gent_string(void) * str3 *------------------------------------------------------------------------- */ - sid = H5Screate_simple(SPACE1_RANK, dims1, NULL); - tid = H5Tcreate (H5T_COMPOUND, sizeof(c_t)); - str_tid = H5Tcopy( H5T_C_S1 ); - H5Tset_size( str_tid, 255 ); + sid = H5Screate_simple(SPACE1_RANK, dims1, NULL); + tid = H5Tcreate(H5T_COMPOUND, sizeof(c_t)); + str_tid = H5Tcopy(H5T_C_S1); + H5Tset_size(str_tid, 255); H5Tinsert(tid, "a", HOFFSET(c_t, a), H5T_NATIVE_INT); - H5Tinsert(tid, "str", HOFFSET(c_t, str), str_tid ); - ret=make_dset(fid,"str3",sid,tid,H5P_DEFAULT,&buf3); + H5Tinsert(tid, "str", HOFFSET(c_t, str), str_tid); + ret = make_dset(fid, "str3", sid, tid, H5P_DEFAULT, &buf3); HDassert(ret >= 0); ret = H5Tclose(tid); HDassert(ret >= 0); @@ -6162,7 +6144,7 @@ static void gent_string(void) *------------------------------------------------------------------------- */ sid = H5Screate_simple(SPACE1_RANK, dims4, NULL); - ret=make_dset(fid,"str4",sid,H5T_NATIVE_CHAR,H5P_DEFAULT,buf4); + ret = make_dset(fid, "str4", sid, H5T_NATIVE_CHAR, H5P_DEFAULT, buf4); ret = H5Sclose(sid); HDassert(ret >= 0); @@ -6174,7 +6156,6 @@ static void gent_string(void) HDassert(ret >= 0); } - /*------------------------------------------------------------------------- * Function: gent_aindices * @@ -6182,49 +6163,50 @@ static void gent_string(void) * *------------------------------------------------------------------------- */ -static void gent_aindices(void) +static void +gent_aindices(void) { - hid_t fid; /* file id */ - hid_t gid[6]; /* group ids */ - hsize_t dims1[1] = {100}; - hsize_t dims2[2] = {10,10}; - hsize_t dims3[3] = {2,10,10}; - hsize_t dims4[4] = {2,2,10,10}; - int buf1[100]; - int buf2[10][10]; - int buf3[2][10][10]; - int buf4[2][2][10][10]; - int i, j, k, l, n; - int H5_ATTR_NDEBUG_UNUSED ret; - - for(i = n = 0; i < 100; i++) + hid_t fid; /* file id */ + hid_t gid[6]; /* group ids */ + hsize_t dims1[1] = {100}; + hsize_t dims2[2] = {10, 10}; + hsize_t dims3[3] = {2, 10, 10}; + hsize_t dims4[4] = {2, 2, 10, 10}; + int buf1[100]; + int buf2[10][10]; + int buf3[2][10][10]; + int buf4[2][2][10][10]; + int i, j, k, l, n; + int H5_ATTR_NDEBUG_UNUSED ret; + + for (i = n = 0; i < 100; i++) buf1[i] = n++; - for(i = n = 0; i < 10; i++) - for(j = 0; j < 10; j++) + for (i = n = 0; i < 10; i++) + for (j = 0; j < 10; j++) buf2[i][j] = n++; - for(i = n = 0; i < 2; i++) - for(j = 0; j < 10; j++) - for(k = 0; k < 10; k++) + for (i = n = 0; i < 2; i++) + for (j = 0; j < 10; j++) + for (k = 0; k < 10; k++) buf3[i][j][k] = n++; - for(i = n = 0; i < 2; i++) - for(j = 0; j < 2; j++) - for(k = 0; k < 10; k++) - for(l = 0; l < 10; l++) + for (i = n = 0; i < 2; i++) + for (j = 0; j < 2; j++) + for (k = 0; k < 10; k++) + for (l = 0; l < 10; l++) buf4[i][j][k][l] = n++; /* create a file */ - fid = H5Fcreate(FILE50, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); + fid = H5Fcreate(FILE50, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /*------------------------------------------------------------------------- * root datasets *------------------------------------------------------------------------- */ - write_dset(fid,1,dims1,"1d",H5T_NATIVE_INT,buf1); - write_dset(fid,2,dims2,"2d",H5T_NATIVE_INT,buf2); - write_dset(fid,3,dims3,"3d",H5T_NATIVE_INT,buf3); - write_dset(fid,4,dims4,"4d",H5T_NATIVE_INT,buf4); + write_dset(fid, 1, dims1, "1d", H5T_NATIVE_INT, buf1); + write_dset(fid, 2, dims2, "2d", H5T_NATIVE_INT, buf2); + write_dset(fid, 3, dims3, "3d", H5T_NATIVE_INT, buf3); + write_dset(fid, 4, dims4, "4d", H5T_NATIVE_INT, buf4); /*------------------------------------------------------------------------- * test with group indentation @@ -6236,11 +6218,11 @@ static void gent_aindices(void) gid[3] = H5Gcreate2(fid, "g1/g2/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid[4] = H5Gcreate2(fid, "g1/g2/g3/g4/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid[5] = H5Gcreate2(fid, "g1/g2/g3/g4/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - write_dset(gid[5],1,dims1,"1d",H5T_NATIVE_INT,buf1); - write_dset(gid[5],2,dims2,"2d",H5T_NATIVE_INT,buf2); - write_dset(gid[5],3,dims3,"3d",H5T_NATIVE_INT,buf3); - write_dset(gid[5],4,dims4,"4d",H5T_NATIVE_INT,buf4); - for(i = 0; i < 6; i++) + write_dset(gid[5], 1, dims1, "1d", H5T_NATIVE_INT, buf1); + write_dset(gid[5], 2, dims2, "2d", H5T_NATIVE_INT, buf2); + write_dset(gid[5], 3, dims3, "3d", H5T_NATIVE_INT, buf3); + write_dset(gid[5], 4, dims4, "4d", H5T_NATIVE_INT, buf4); + for (i = 0; i < 6; i++) H5Gclose(gid[i]); /*------------------------------------------------------------------------- @@ -6249,10 +6231,8 @@ static void gent_aindices(void) */ ret = H5Fclose(fid); HDassert(ret >= 0); - } - /*------------------------------------------------------------------------- * Function: gent_longlinks * @@ -6260,13 +6240,14 @@ static void gent_aindices(void) * *------------------------------------------------------------------------- */ -static void gent_longlinks(void) +static void +gent_longlinks(void) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t H5_ATTR_NDEBUG_UNUSED gid2 = (-1); /* Datatype ID */ - char *objname = NULL; /* Name of object [Long] */ - size_t u; /* Local index variable */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ + hid_t H5_ATTR_NDEBUG_UNUSED gid2 = (-1); /* Datatype ID */ + char * objname = NULL; /* Name of object [Long] */ + size_t u; /* Local index variable */ /* Create files */ fid = H5Fcreate(FILE51, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -6277,9 +6258,9 @@ static void gent_longlinks(void) HDassert(gid >= 0); /* Construct very long file name */ - objname = (char*) HDmalloc((size_t)(F51_MAX_NAME_LEN + 1)); + objname = (char *)HDmalloc((size_t)(F51_MAX_NAME_LEN + 1)); HDassert(objname); - for(u = 0; u < F51_MAX_NAME_LEN; u++) + for (u = 0; u < F51_MAX_NAME_LEN; u++) objname[u] = 'a'; objname[F51_MAX_NAME_LEN] = '\0'; @@ -6310,40 +6291,41 @@ static void gent_longlinks(void) * *------------------------------------------------------------------------- */ -static int gent_ldouble(void) +static int +gent_ldouble(void) { hid_t fid; hid_t did; hid_t tid; hid_t sid; hsize_t dims[1] = {3}; - long double buf[3] = {1,2,3}; + long double buf[3] = {1, 2, 3}; - if((fid = H5Fcreate(FILE52, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE52, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto error; - if((tid = H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) goto error; - if(H5Tget_size(tid) == 0) + if (H5Tget_size(tid) == 0) goto error; - if((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; return 0; @@ -6351,10 +6333,8 @@ static int gent_ldouble(void) error: HDprintf("error !\n"); return -1; - } - /*------------------------------------------------------------------------- * Function: gent_binary * @@ -6369,16 +6349,15 @@ error: static void gent_binary(void) { - hid_t fid, sid, did, aid; - hsize_t dims[1] = {6}; - int ibuf[6] = {1,2,3,4,5,6}; - float fbuf[6] = {1,2,3,4,5,6}; - double dbuf[6] = {1,2,3,4,5,6}; + hid_t fid, sid, did, aid; + hsize_t dims[1] = {6}; + int ibuf[6] = {1, 2, 3, 4, 5, 6}; + float fbuf[6] = {1, 2, 3, 4, 5, 6}; + double dbuf[6] = {1, 2, 3, 4, 5, 6}; fid = H5Fcreate(FILE55, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); sid = H5Screate_simple(1, dims, NULL); - /*------------------------------------------------------------------------- * integer *------------------------------------------------------------------------- @@ -6407,7 +6386,6 @@ gent_binary(void) H5Aclose(aid); H5Dclose(did); - /* close */ H5Sclose(sid); H5Fclose(fid); @@ -6421,88 +6399,86 @@ gent_binary(void) * *------------------------------------------------------------------------- */ -#define GB4LL ((unsigned long long) 4*1024*1024*1024) -#define DIM_4GB (GB4LL + 10) +#define GB4LL ((unsigned long long)4 * 1024 * 1024 * 1024) +#define DIM_4GB (GB4LL + 10) static void gent_bigdims(void) { - hid_t fid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; - hid_t f_sid = H5I_INVALID_HID; - hid_t m_sid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[1]={DIM_4GB}; /* dataset dimensions */ - hsize_t chunk_dims[1]={1024}; /* chunk dimensions */ - hsize_t hs_start[1]; - hsize_t hs_size[1]; /* hyperslab dimensions */ - size_t size; - char fillvalue=0; - char *buf=NULL; - hsize_t i; - char c; - size_t nelmts; - int H5_ATTR_NDEBUG_UNUSED ret; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t f_sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[1] = {DIM_4GB}; /* dataset dimensions */ + hsize_t chunk_dims[1] = {1024}; /* chunk dimensions */ + hsize_t hs_start[1]; + hsize_t hs_size[1]; /* hyperslab dimensions */ + size_t size; + char fillvalue = 0; + char * buf = NULL; + hsize_t i; + char c; + size_t nelmts; + int H5_ATTR_NDEBUG_UNUSED ret; /* create a file */ - fid = H5Fcreate(FILE56, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE56, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); HDassert(fid >= 0); /* create dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_SCHAR, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_SCHAR, &fillvalue) < 0) goto out; - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dims) < 0) goto out; - if((f_sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((f_sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; - if((did = H5Dcreate2(fid, "dset4gb", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset4gb", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((size = H5Tget_size(tid)) <= 0) + if ((size = H5Tget_size(tid)) <= 0) goto out; /* select an hyperslab */ - nelmts = 20; + nelmts = 20; hs_start[0] = GB4LL - 10; hs_size[0] = nelmts; - if((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) + if ((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) goto out; - buf=(char *) HDmalloc((unsigned)(nelmts*size)); + buf = (char *)HDmalloc((unsigned)(nelmts * size)); - for(i=0, c=0; i=0); + fid = H5Fcreate(FILE57, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); - write_dset(fid,2,dims,"stripmine",H5T_NATIVE_DOUBLE,buf); + write_dset(fid, 2, dims, "stripmine", H5T_NATIVE_DOUBLE, buf); ret = H5Fclose(fid); HDassert(ret >= 0); @@ -6569,23 +6545,22 @@ gent_hyperslab(void) static void gent_group_creation_order(void) { - hid_t fid = H5I_INVALID_HID; /* file ID */ - hid_t gid = H5I_INVALID_HID; /* group ID */ - hid_t gcpl_id = H5I_INVALID_HID; /* group creation property list ID */ - hid_t fcpl_id = H5I_INVALID_HID; /* file creation property list ID (to set root group order) */ + hid_t fid = H5I_INVALID_HID; /* file ID */ + hid_t gid = H5I_INVALID_HID; /* group ID */ + hid_t gcpl_id = H5I_INVALID_HID; /* group creation property list ID */ + hid_t fcpl_id = H5I_INVALID_HID; /* file creation property list ID (to set root group order) */ - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) goto out; - if(H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED ) < 0) + if (H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; - if((fid = H5Fcreate(FILE58, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE58, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT)) < 0) goto out; - /* create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto out; /*------------------------------------------------------------------------- @@ -6593,128 +6568,124 @@ gent_group_creation_order(void) *------------------------------------------------------------------------- */ - - if((gid = H5Gcreate2(fid, "2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "2/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "2/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - /*------------------------------------------------------------------------- * create a group "1" with H5P_CRT_ORDER_TRACKED set *------------------------------------------------------------------------- */ - if(H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + if (H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; - - if((gid = H5Gcreate2(fid, "1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - if((gid = H5Gcreate2(fid, "1/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "1/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; - - if(H5Pclose(gcpl_id) < 0) + if (H5Pclose(gcpl_id) < 0) goto out; gcpl_id = H5I_INVALID_HID; - if(H5Pclose(fcpl_id) < 0) + if (H5Pclose(fcpl_id) < 0) goto out; fcpl_id = H5I_INVALID_HID; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto out; fid = H5I_INVALID_HID; return; - out: +out: HDprintf("Error.....\n"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Pclose(gcpl_id); H5Pclose(fcpl_id); H5Fclose(fid); - - } H5E_END_TRY; + } + H5E_END_TRY; return; - } /*------------------------------------------------------------------------- @@ -6728,47 +6699,47 @@ gent_group_creation_order(void) static void gent_attr_creation_order(void) { - hid_t fid = H5I_INVALID_HID; /* file id */ - hid_t gid = H5I_INVALID_HID; /* group id */ - hid_t did = H5I_INVALID_HID; /* dataset id */ - hid_t sid = H5I_INVALID_HID; /* space id */ - hid_t aid = H5I_INVALID_HID; /* attribute id */ - hid_t tid = H5I_INVALID_HID; /* datatype id */ - hid_t gcpl_id = H5I_INVALID_HID; /* group creation property list ID */ - hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t tcpl_id = H5I_INVALID_HID; /* datatype creation property list ID */ - int i; - const char *attr_name[3] = {"c", "b", "a" }; - - if((fid = H5Fcreate(FILE59, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t gid = H5I_INVALID_HID; /* group id */ + hid_t did = H5I_INVALID_HID; /* dataset id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t aid = H5I_INVALID_HID; /* attribute id */ + hid_t tid = H5I_INVALID_HID; /* datatype id */ + hid_t gcpl_id = H5I_INVALID_HID; /* group creation property list ID */ + hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t tcpl_id = H5I_INVALID_HID; /* datatype creation property list ID */ + int i; + const char *attr_name[3] = {"c", "b", "a"}; + + if ((fid = H5Fcreate(FILE59, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto out; /* create dataset creation property list */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; /* create dataset creation property list */ - if((tcpl_id = H5Pcreate(H5P_DATATYPE_CREATE)) < 0) + if ((tcpl_id = H5Pcreate(H5P_DATATYPE_CREATE)) < 0) goto out; /* enable attribute creation order tracking on dataset property list */ - if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + if (H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; /* enable attribute creation order tracking on group property list */ - if(H5Pset_attr_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + if (H5Pset_attr_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; /* enable attribute creation order tracking on datatype property list */ - if(H5Pset_attr_creation_order(tcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + if (H5Pset_attr_creation_order(tcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; /* create a dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; /*------------------------------------------------------------------------- @@ -6777,74 +6748,68 @@ gent_attr_creation_order(void) */ /* create a dataset */ - if((did = H5Dcreate2(fid, "dt", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dt", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; aid = H5I_INVALID_HID; } /* end for */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; did = H5I_INVALID_HID; - /*------------------------------------------------------------------------- * create a dataset without creation order tracked for attributes and atributes in it *------------------------------------------------------------------------- */ /* create a dataset */ - if((did = H5Dcreate2(fid, "d", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "d", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; aid = H5I_INVALID_HID; } /* end for */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; did = H5I_INVALID_HID; - - /*------------------------------------------------------------------------- * create a group with creation order tracked for attributes and atributes in it *------------------------------------------------------------------------- */ - if((gid = H5Gcreate2(fid, "gt", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "gt", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; aid = H5I_INVALID_HID; } /* end for */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; @@ -6853,22 +6818,21 @@ gent_attr_creation_order(void) *------------------------------------------------------------------------- */ - if((gid = H5Gcreate2(fid, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; aid = H5I_INVALID_HID; } /* end for */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; @@ -6877,25 +6841,24 @@ gent_attr_creation_order(void) *------------------------------------------------------------------------- */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto out; - if((H5Tcommit2(fid, "tt", tid, H5P_DEFAULT, tcpl_id, H5P_DEFAULT)) < 0) + if ((H5Tcommit2(fid, "tt", tid, H5P_DEFAULT, tcpl_id, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; aid = H5I_INVALID_HID; } /* end for */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; @@ -6904,25 +6867,24 @@ gent_attr_creation_order(void) *------------------------------------------------------------------------- */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto out; - if((H5Tcommit2(fid, "t", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((H5Tcommit2(fid, "t", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; aid = H5I_INVALID_HID; } /* end for */ - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; @@ -6930,22 +6892,21 @@ gent_attr_creation_order(void) * add some attributes to the root group *------------------------------------------------------------------------- */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) goto out; /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 0; i < 3; i++) { + if ((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* close attribute */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; aid = H5I_INVALID_HID; } /* end for */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; gid = H5I_INVALID_HID; @@ -6953,29 +6914,28 @@ gent_attr_creation_order(void) * close *------------------------------------------------------------------------- */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; sid = H5I_INVALID_HID; - if(H5Pclose(dcpl_id) < 0) + if (H5Pclose(dcpl_id) < 0) goto out; dcpl_id = H5I_INVALID_HID; - if(H5Pclose(gcpl_id) < 0) + if (H5Pclose(gcpl_id) < 0) goto out; gcpl_id = H5I_INVALID_HID; - if(H5Pclose(tcpl_id) < 0) + if (H5Pclose(tcpl_id) < 0) goto out; tcpl_id = H5I_INVALID_HID; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto out; fid = H5I_INVALID_HID; - - return; - out: +out: HDprintf("Error.....\n"); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Dclose(did); H5Sclose(sid); @@ -6983,10 +6943,9 @@ gent_attr_creation_order(void) H5Pclose(dcpl_id); H5Pclose(tcpl_id); H5Fclose(fid); - - } H5E_END_TRY; + } + H5E_END_TRY; return; - } /*------------------------------------------------------------------------- @@ -7002,10 +6961,10 @@ gent_attr_creation_order(void) static void gent_fpformat(void) { - hid_t fid, sid, did; - hsize_t dims[1] = {6}; - double dbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; - float fbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; + hid_t fid, sid, did; + hsize_t dims[1] = {6}; + double dbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; + float fbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; fid = H5Fcreate(FILE60, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); sid = H5Screate_simple(1, dims, NULL); @@ -7018,7 +6977,6 @@ gent_fpformat(void) H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); H5Dclose(did); - /*------------------------------------------------------------------------- * float *------------------------------------------------------------------------- @@ -7027,7 +6985,6 @@ gent_fpformat(void) H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf); H5Dclose(did); - /* close */ H5Sclose(sid); H5Fclose(fid); @@ -7045,15 +7002,14 @@ gent_fpformat(void) static void gent_extlinks(void) { - hid_t source_fid, target_fid, far_fid, sid, did, gid, gid2, tid; - hsize_t dims[1] = {6}; - int buf[6] = {1, 2, 3, 4, 5, 6}; + hid_t source_fid, target_fid, far_fid, sid, did, gid, gid2, tid; + hsize_t dims[1] = {6}; + int buf[6] = {1, 2, 3, 4, 5, 6}; /* create two files, a source and a target */ source_fid = H5Fcreate(FILE61, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); target_fid = H5Fcreate(FILE62, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - far_fid = H5Fcreate(FILE63, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - + far_fid = H5Fcreate(FILE63, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- * create Groups, a Dataset, a committed Datatype, external links, and a @@ -7077,7 +7033,6 @@ gent_extlinks(void) H5Gclose(gid2); H5Gclose(gid); - sid = H5Screate_simple(1, dims, NULL); did = H5Dcreate2(target_fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); @@ -7127,8 +7082,8 @@ gent_extlinks(void) static void gent_fs_strategy_threshold(void) { - hid_t fid; /* File id */ - hid_t fcpl; /* File creation property */ + hid_t fid; /* File id */ + hid_t fcpl; /* File creation property */ /* Create file-creation template */ fcpl = H5Pcreate(H5P_FILE_CREATE); @@ -7162,11 +7117,11 @@ gent_fs_strategy_threshold(void) static void gent_dataset_idx(void) { - hid_t fid, space, dcpl, fapl; - hsize_t dims[2]; - hsize_t maxdims[2]; - int buf[20][10]; - int i, j; + hid_t fid, space, dcpl, fapl; + hsize_t dims[2]; + hsize_t maxdims[2]; + int buf[20][10]; + int i, j; int H5_ATTR_NDEBUG_UNUSED ret; /* Get a copy of the file aaccess property */ @@ -7176,7 +7131,7 @@ gent_dataset_idx(void) ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); assert(ret >= 0); - fid = H5Fcreate(FILE68a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + fid = H5Fcreate(FILE68a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); dcpl = H5Pcreate(H5P_DATASET_CREATE); dims[0] = F68a_CHUNK; @@ -7189,11 +7144,11 @@ gent_dataset_idx(void) /* dataset with fixed dimensions */ dims[0] = F68a_DIM20; dims[1] = F68a_DIM10; - space = H5Screate_simple(RANK, dims, NULL); + space = H5Screate_simple(RANK, dims, NULL); - for(i = 0; i < F68a_DIM20; i++) - for(j = 0; j < F68a_DIM10; j++) - buf[i][j] = j; + for (i = 0; i < F68a_DIM20; i++) + for (j = 0; j < F68a_DIM10; j++) + buf[i][j] = j; ret = make_dset(fid, F68a_DSET_FIXED, space, H5T_NATIVE_INT, dcpl, buf); assert(ret >= 0); @@ -7202,13 +7157,13 @@ gent_dataset_idx(void) /* dataset with non-fixed dimensions */ maxdims[0] = F68a_DIM200; maxdims[1] = F68a_DIM100; - space = H5Screate_simple(RANK, dims, maxdims); + space = H5Screate_simple(RANK, dims, maxdims); ret = make_dset(fid, F68a_DSET_BTREE, space, H5T_NATIVE_INT, dcpl, buf); assert(ret >= 0); H5Sclose(space); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* dataset with fixed dimensions and filters */ /* remove the filters from the dcpl */ @@ -7220,7 +7175,7 @@ gent_dataset_idx(void) assert(ret >= 0); space = H5Screate_simple(RANK, dims, NULL); - ret = make_dset(fid, F68a_DSET_FIXED_FILTER, space, H5T_NATIVE_INT, dcpl, buf); + ret = make_dset(fid, F68a_DSET_FIXED_FILTER, space, H5T_NATIVE_INT, dcpl, buf); assert(ret >= 0); H5Sclose(space); @@ -7245,54 +7200,55 @@ gent_dataset_idx(void) static void gent_packedbits(void) { - hid_t fid = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t **dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t **dset8 = NULL; - int16_t **dset16 = NULL; - int32_t **dset32 = NULL; - int64_t **dset64 = NULL; - double **dsetdbl = NULL; - - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + uint8_t ** dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t ** dset8 = NULL; + int16_t ** dset16 = NULL; + int32_t ** dset32 = NULL; + int64_t ** dset64 = NULL; + double ** dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); fid = H5Fcreate(FILE66, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) + for (j = 1; j < dims[1]; j++) dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); valu8bits = (uint8_t)(valu8bits << 1); } @@ -7302,15 +7258,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) + dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); valu16bits = (uint16_t)(valu16bits << 1); } @@ -7319,15 +7276,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) - dsetu32[i][j] = dsetu32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) + dsetu32[i][j] = dsetu32[i][j - 1] << 1; valu32bits <<= 1; } @@ -7336,15 +7294,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) - dsetu64[i][j] = dsetu64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) + dsetu64[i][j] = dsetu64[i][j - 1] << 1; valu64bits <<= 1; } @@ -7353,15 +7312,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) + dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); val8bits = (int8_t)(val8bits << 1); } @@ -7370,15 +7330,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) + dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); val16bits = (int16_t)(val16bits << 1); } @@ -7387,15 +7348,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) - dset32[i][j] = dset32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) + dset32[i][j] = dset32[i][j - 1] << 1; val32bits <<= 1; } @@ -7404,15 +7366,16 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) - dset64[i][j] = dset64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) + dset64[i][j] = dset64[i][j - 1] << 1; val64bits <<= 1; } @@ -7421,12 +7384,13 @@ gent_packedbits(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); @@ -7460,57 +7424,58 @@ gent_packedbits(void) static void gent_attr_intsize(void) { - hid_t fid = H5I_INVALID_HID; - hid_t attr = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t root = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t root = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t **dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t **dset8 = NULL; - int16_t **dset16 = NULL; - int32_t **dset32 = NULL; - int64_t **dset64 = NULL; - double **dsetdbl = NULL; - - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + uint8_t ** dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t ** dset8 = NULL; + int16_t ** dset16 = NULL; + int32_t ** dset32 = NULL; + int64_t ** dset64 = NULL; + double ** dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); - fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* Attribute of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -7520,15 +7485,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -7538,15 +7504,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dsetu32[i][j] = dsetu32[i][j - 1] << 1; } valu32bits <<= 1; } @@ -7556,15 +7523,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dsetu64[i][j] = dsetu64[i][j - 1] << 1; } valu64bits <<= 1; } @@ -7574,15 +7542,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -7592,15 +7561,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -7610,15 +7580,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dset32[i][j] = dset32[i][j - 1] << 1; } val32bits <<= 1; } @@ -7628,15 +7599,16 @@ gent_attr_intsize(void) H5Aclose(attr); /* Attribute of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dset64[i][j] = dset64[i][j - 1] << 1; } val64bits <<= 1; } @@ -7646,12 +7618,13 @@ gent_attr_intsize(void) H5Aclose(attr); /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(root, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl[0]); @@ -7676,77 +7649,85 @@ gent_attr_intsize(void) static void gent_nodata(void) { - hid_t fid, dataset, space; + hid_t fid, dataset, space; hsize_t dims[2]; fid = H5Fcreate(FILE87, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); } - /*------------------------------------------------------------------------- * Function: gent_charsets * @@ -7760,83 +7741,88 @@ gent_nodata(void) static void gent_charsets(void) { - hid_t fid, did, sid; + hid_t fid, did, sid; herr_t H5_ATTR_NDEBUG_UNUSED status; - hsize_t dim[] = {1}; /* Dataspace dimensions */ + hsize_t dim[] = {1}; /* Dataspace dimensions */ typedef struct CharSetInfo { - const char *ascii_p_; - const char *utf8_p_; + const char *ascii_p_; + const char *utf8_p_; } CharSetInfo; - hid_t charset_dtid = H5Tcreate( H5T_COMPOUND, sizeof( CharSetInfo ) ); - hid_t ascii_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); - hid_t utf8_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); - const char * writeData[] = { "ascii", "utf8", }; + hid_t charset_dtid = H5Tcreate(H5T_COMPOUND, sizeof(CharSetInfo)); + hid_t ascii_dtid = H5Tcreate(H5T_STRING, H5T_VARIABLE); + hid_t utf8_dtid = H5Tcreate(H5T_STRING, H5T_VARIABLE); + const char *writeData[] = { + "ascii", + "utf8", + }; - sid = H5Screate_simple( 1, dim, NULL ); - fid = H5Fcreate( FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - status = H5Tset_cset( ascii_dtid, H5T_CSET_ASCII ); + sid = H5Screate_simple(1, dim, NULL); + fid = H5Fcreate(FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + status = H5Tset_cset(ascii_dtid, H5T_CSET_ASCII); HDassert(status >= 0); - H5Tinsert( charset_dtid, "ascii", HOFFSET(CharSetInfo, ascii_p_ ), ascii_dtid ); + H5Tinsert(charset_dtid, "ascii", HOFFSET(CharSetInfo, ascii_p_), ascii_dtid); - status = H5Tset_cset( utf8_dtid, H5T_CSET_UTF8 ); + status = H5Tset_cset(utf8_dtid, H5T_CSET_UTF8); HDassert(status >= 0); - H5Tinsert( charset_dtid, "utf8", HOFFSET( CharSetInfo, utf8_p_ ), utf8_dtid ); + H5Tinsert(charset_dtid, "utf8", HOFFSET(CharSetInfo, utf8_p_), utf8_dtid); - did = H5Dcreate2( fid, "CharSets", charset_dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); + did = H5Dcreate2(fid, "CharSets", charset_dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite( did, charset_dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, writeData ); + status = H5Dwrite(did, charset_dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, writeData); HDassert(status >= 0); - H5Tclose( charset_dtid ); - H5Tclose( ascii_dtid ); - H5Tclose( utf8_dtid ); - H5Sclose( sid ); - H5Dclose( did ); - H5Fclose( fid ); + H5Tclose(charset_dtid); + H5Tclose(ascii_dtid); + H5Tclose(utf8_dtid); + H5Sclose(sid); + H5Dclose(did); + H5Fclose(fid); } -static void gent_compound_intsizes(void) { - hid_t fid, dataset, space; - hsize_t dims[2]; - hsize_t array_dim8[]={F70_XDIM,F70_YDIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F70_XDIM,F70_YDIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F70_XDIM,F70_YDIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F70_XDIM,F70_YDIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ +static void +gent_compound_intsizes(void) +{ + hid_t fid, dataset, space; + hsize_t dims[2]; + hsize_t array_dim8[] = {F70_XDIM, F70_YDIM8}; /* Array dimensions */ + hsize_t array_dim16[] = {F70_XDIM, F70_YDIM16}; /* Array dimensions */ + hsize_t array_dim32[] = {F70_XDIM, F70_YDIM32}; /* Array dimensions */ + hsize_t array_dim64[] = {F70_XDIM, F70_YDIM64}; /* Array dimensions */ + hid_t arrayu8_tid; /* Array datatype handle */ + hid_t arrayu16_tid; /* Array datatype handle */ + hid_t arrayu32_tid; /* Array datatype handle */ + hid_t arrayu64_tid; /* Array datatype handle */ + hid_t array8_tid; /* Array datatype handle */ + hid_t array16_tid; /* Array datatype handle */ + hid_t array32_tid; /* Array datatype handle */ + hid_t array64_tid; /* Array datatype handle */ + hid_t arraydbl_tid; /* Array datatype handle */ uint8_t valu8bits; uint16_t valu16bits; uint32_t valu32bits; uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; /* Structure and array for compound types */ typedef struct Array1Struct { - uint8_t dsetu8[F70_XDIM][F70_YDIM8]; - uint16_t dsetu16[F70_XDIM][F70_YDIM16]; - uint32_t dsetu32[F70_XDIM][F70_YDIM32]; - uint64_t dsetu64[F70_XDIM][F70_YDIM64]; - int8_t dset8[F70_XDIM][F70_YDIM8]; - int16_t dset16[F70_XDIM][F70_YDIM16]; - int32_t dset32[F70_XDIM][F70_YDIM32]; - int64_t dset64[F70_XDIM][F70_YDIM64]; - double dsetdbl[F70_XDIM][F70_YDIM8]; + uint8_t dsetu8[F70_XDIM][F70_YDIM8]; + uint16_t dsetu16[F70_XDIM][F70_YDIM16]; + uint32_t dsetu32[F70_XDIM][F70_YDIM32]; + uint64_t dsetu64[F70_XDIM][F70_YDIM64]; + int8_t dset8[F70_XDIM][F70_YDIM8]; + int16_t dset16[F70_XDIM][F70_YDIM16]; + int32_t dset32[F70_XDIM][F70_YDIM32]; + int64_t dset64[F70_XDIM][F70_YDIM64]; + double dsetdbl[F70_XDIM][F70_YDIM8]; } Array1Struct; Array1Struct *Array1; - hid_t Array1Structid; /* File datatype identifier */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ - hsize_t dim[] = { F70_LENGTH }; /* Dataspace dimensions */ + hid_t Array1Structid; /* File datatype identifier */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F70_LENGTH}; /* Dataspace dimensions */ int m, n, o; /* Array init loop vars */ @@ -7848,98 +7834,107 @@ static void gent_compound_intsizes(void) { for (m = 0; m < F70_LENGTH; m++) { /* Array of 8 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu8[n][0] = valu8bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o - 1] << 1); valu8bits = (uint8_t)(valu8bits << 1); } /* Array of 16 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM16; - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu16[n][0] = valu16bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o - 1] << 1); valu16bits = (uint16_t)(valu16bits << 1); } /* Array of 32 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM32; - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu32[n][0] = valu32bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o - 1] << 1; valu32bits <<= 1; } /* Array of 64 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM64; - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu64[n][0] = valu64bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o - 1] << 1; valu64bits <<= 1; } /* Array of 8 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val8bits = (int8_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset8[n][0] = val8bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o - 1] << 1); val8bits = (int8_t)(val8bits << 1); } /* Array of 16 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM16; - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val16bits = (int16_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset16[n][0] = val16bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o - 1] << 1); val16bits = (int16_t)(val16bits << 1); } /* Array of 32 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM32; - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val32bits = (int32_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset32[n][0] = val32bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dset32[n][o] = Array1[m].dset32[n][o - 1] << 1; val32bits <<= 1; } /* Array of 64 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM64; - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset64[n][0] = val64bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) + Array1[m].dset64[n][o] = Array1[m].dset64[n][o - 1] << 1; val64bits <<= 1; } /* Double Dummy set for failure tests */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - for(n = 0; n < (int)dims[0]; n++) - for(o = 0; o < (int)dims[1]; o++) + for (n = 0; n < (int)dims[0]; n++) + for (o = 0; o < (int)dims[1]; o++) Array1[m].dsetdbl[n][o] = 0.0001F * (float)o + (float)n; } @@ -8069,47 +8064,49 @@ static void gent_compound_intsizes(void) { HDfree(Array1); } -static void gent_compound_attr_intsizes(void) { - hid_t fid, attr, space, root; - hsize_t dims[2]; - hsize_t array_dim8[]={F70_XDIM,F70_YDIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F70_XDIM,F70_YDIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F70_XDIM,F70_YDIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F70_XDIM,F70_YDIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ +static void +gent_compound_attr_intsizes(void) +{ + hid_t fid, attr, space, root; + hsize_t dims[2]; + hsize_t array_dim8[] = {F70_XDIM, F70_YDIM8}; /* Array dimensions */ + hsize_t array_dim16[] = {F70_XDIM, F70_YDIM16}; /* Array dimensions */ + hsize_t array_dim32[] = {F70_XDIM, F70_YDIM32}; /* Array dimensions */ + hsize_t array_dim64[] = {F70_XDIM, F70_YDIM64}; /* Array dimensions */ + hid_t arrayu8_tid; /* Array datatype handle */ + hid_t arrayu16_tid; /* Array datatype handle */ + hid_t arrayu32_tid; /* Array datatype handle */ + hid_t arrayu64_tid; /* Array datatype handle */ + hid_t array8_tid; /* Array datatype handle */ + hid_t array16_tid; /* Array datatype handle */ + hid_t array32_tid; /* Array datatype handle */ + hid_t array64_tid; /* Array datatype handle */ + hid_t arraydbl_tid; /* Array datatype handle */ uint8_t valu8bits; uint16_t valu16bits; uint32_t valu32bits; uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; /* Structure and array for compound types */ typedef struct Array1Struct { - uint8_t dsetu8[F70_XDIM][F70_YDIM8]; - uint16_t dsetu16[F70_XDIM][F70_YDIM16]; - uint32_t dsetu32[F70_XDIM][F70_YDIM32]; - uint64_t dsetu64[F70_XDIM][F70_YDIM64]; - int8_t dset8[F70_XDIM][F70_YDIM8]; - int16_t dset16[F70_XDIM][F70_YDIM16]; - int32_t dset32[F70_XDIM][F70_YDIM32]; - int64_t dset64[F70_XDIM][F70_YDIM64]; - double dsetdbl[F70_XDIM][F70_YDIM8]; + uint8_t dsetu8[F70_XDIM][F70_YDIM8]; + uint16_t dsetu16[F70_XDIM][F70_YDIM16]; + uint32_t dsetu32[F70_XDIM][F70_YDIM32]; + uint64_t dsetu64[F70_XDIM][F70_YDIM64]; + int8_t dset8[F70_XDIM][F70_YDIM8]; + int16_t dset16[F70_XDIM][F70_YDIM16]; + int32_t dset32[F70_XDIM][F70_YDIM32]; + int64_t dset64[F70_XDIM][F70_YDIM64]; + double dsetdbl[F70_XDIM][F70_YDIM8]; } Array1Struct; Array1Struct *Array1 = NULL; - hid_t Array1Structid; /* File datatype identifier */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ - hsize_t dim[] = { F70_LENGTH }; /* Dataspace dimensions */ + hid_t Array1Structid; /* File datatype identifier */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F70_LENGTH}; /* Dataspace dimensions */ int m, n, o; /* Array init loop vars */ @@ -8119,106 +8116,115 @@ static void gent_compound_attr_intsizes(void) { for (m = 0; m < F70_LENGTH; m++) { /* Array of 8 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu8[n][0] = valu8bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } /* Array of 16 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM16; - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu16[n][0] = valu16bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } /* Array of 32 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM32; - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu32[n][0] = valu32bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o - 1] << 1; } valu32bits <<= 1; } /* Array of 64 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM64; - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dsetu64[n][0] = valu64bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o - 1] << 1; } valu64bits <<= 1; } /* Array of 8 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val8bits = (int8_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset8[n][0] = val8bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } /* Array of 16 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM16; - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val16bits = (int16_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset16[n][0] = val16bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1); + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } /* Array of 32 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM32; - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val32bits = (int32_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset32[n][0] = val32bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dset32[n][o] = Array1[m].dset32[n][o - 1] << 1; } val32bits <<= 1; } /* Array of 64 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM64; - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Array1[m].dset64[n][0] = val64bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; + for (o = 1; o < (int)dims[1]; o++) { + Array1[m].dset64[n][o] = Array1[m].dset64[n][o - 1] << 1; } val64bits <<= 1; } /* Double Dummy set for failure tests */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; + dims[0] = F70_XDIM; + dims[1] = F70_YDIM8; - for(n = 0; n < (int)dims[0]; n++) - for(o = 0; o < (int)dims[1]; o++) + for (n = 0; n < (int)dims[0]; n++) + for (o = 0; o < (int)dims[1]; o++) Array1[m].dsetdbl[n][o] = 0.0001F * (float)o + (float)n; } @@ -8350,51 +8356,53 @@ static void gent_compound_attr_intsizes(void) { HDfree(Array1); } -static void gent_nested_compound_dt(void) { /* test nested data type */ - hid_t fid, group, dataset, space, type, create_plist, type1, type2; - hid_t array_dt, enum_dt; +static void +gent_nested_compound_dt(void) +{ /* test nested data type */ + hid_t fid, group, dataset, space, type, create_plist, type1, type2; + hid_t array_dt, enum_dt; enumtype val; typedef struct { - int a; - float b; + int a; + float b; } dset1_t; dset1_t dset1[10]; typedef struct { - int a; - float b; - enumtype c; + int a; + float b; + enumtype c; } dset2_t; dset2_t dset2[10]; typedef struct { - int a[5]; - float b[5][6]; - dset1_t c; + int a[5]; + float b[5][6]; + dset1_t c; } dset3_t; dset3_t dset3[10]; enumtype dset4[] = {RED, GREEN, BLUE, GREEN, WHITE, BLUE}; - int i, j, k; + int i, j, k; unsigned ndims; - hsize_t dim[2]; + hsize_t dim[2]; hsize_t sdim, maxdim; sdim = 10; - for(i = 0; i < (int)sdim; i++) { + for (i = 0; i < (int)sdim; i++) { dset1[i].a = i; - dset1[i].b = (float)(i*i); + dset1[i].b = (float)(i * i); dset2[i].a = i; dset2[i].b = (float)((float)i + (float)i * 0.1F); dset2[i].c = GREEN; - for(j = 0; j < 5; j++) { + for (j = 0; j < 5; j++) { dset3[i].a[j] = i * j; - for(k = 0; k < 6; k++) { + for (k = 0; k < 6; k++) { dset3[i].b[j][k] = (float)((float)i * (float)j * (float)k * 1.0F); } } @@ -8409,13 +8417,12 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ sdim = 2; H5Pset_chunk(create_plist, 1, &sdim); - - sdim = 6; + sdim = 6; maxdim = H5S_UNLIMITED; space = H5Screate_simple(1, &sdim, &maxdim); - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); + type = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32LE); H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32LE); @@ -8427,20 +8434,20 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ H5Dclose(dataset); /* Create the shared enumerated datatype. */ - enum_dt = H5Tenum_create (H5T_NATIVE_INT); - val = (enumtype) RED; - H5Tenum_insert (enum_dt, "Red", &val); - val = (enumtype) GREEN; - H5Tenum_insert (enum_dt, "Green", &val); - val = (enumtype) BLUE; - H5Tenum_insert (enum_dt, "Blue", &val); - val = (enumtype) WHITE; - H5Tenum_insert (enum_dt, "White", &val); - val = (enumtype) BLACK; - H5Tenum_insert (enum_dt, "Black", &val); - H5Tcommit2(fid, "enumtype", enum_dt, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2[0])); + enum_dt = H5Tenum_create(H5T_NATIVE_INT); + val = (enumtype)RED; + H5Tenum_insert(enum_dt, "Red", &val); + val = (enumtype)GREEN; + H5Tenum_insert(enum_dt, "Green", &val); + val = (enumtype)BLUE; + H5Tenum_insert(enum_dt, "Blue", &val); + val = (enumtype)WHITE; + H5Tenum_insert(enum_dt, "White", &val); + val = (enumtype)BLACK; + H5Tenum_insert(enum_dt, "Black", &val); + H5Tcommit2(fid, "enumtype", enum_dt, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset2[0])); H5Tinsert(type2, "a_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); H5Tinsert(type2, "b_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); @@ -8466,19 +8473,22 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ group = H5Gcreate2(fid, "/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); + type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset3_t)); - ndims = 1; dim[0] = 5; + ndims = 1; + dim[0] = 5; array_dt = H5Tarray_create2(H5T_STD_I32LE, ndims, dim); H5Tinsert(type2, "int_name", HOFFSET(dset3_t, a), array_dt); H5Tclose(array_dt); - ndims = 2; dim[0] = 5; dim[1] = 6; + ndims = 2; + dim[0] = 5; + dim[1] = 6; array_dt = H5Tarray_create2(H5T_IEEE_F32LE, ndims, dim); H5Tinsert(type2, "float_name", HOFFSET(dset3_t, b), array_dt); H5Tclose(array_dt); - H5Tinsert (type2, "cmpd_name", HOFFSET (dset3_t, c), type1); + H5Tinsert(type2, "cmpd_name", HOFFSET(dset3_t, c), type1); dataset = H5Dcreate2(group, "dset3", type2, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); @@ -8496,7 +8506,6 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ H5Pclose(create_plist); H5Fclose(fid); - } /*------------------------------------------------------------------------- @@ -8512,57 +8521,58 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ static void gent_intscalars(void) { - hid_t fid = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t **dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t **dset8 = NULL; - int16_t **dset16 = NULL; - int32_t **dset32 = NULL; - int64_t **dset64 = NULL; - double **dsetdbl = NULL; - - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + uint8_t ** dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t ** dset8 = NULL; + int16_t ** dset16 = NULL; + int32_t ** dset32 = NULL; + int64_t ** dset64 = NULL; + double ** dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); fid = H5Fcreate(FILE73, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -8572,16 +8582,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -8591,16 +8602,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dsetu32[i][j] = dsetu32[i][j - 1] << 1; } valu32bits <<= 1; } @@ -8610,16 +8622,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dsetu64[i][j] = dsetu64[i][j - 1] << 1; } valu64bits <<= 1; } @@ -8629,16 +8642,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -8648,16 +8662,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -8667,16 +8682,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dset32[i][j] = dset32[i][j - 1] << 1; } val32bits <<= 1; } @@ -8686,16 +8702,17 @@ gent_intscalars(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dset64[i][j] = dset64[i][j - 1] << 1; } val64bits <<= 1; } @@ -8705,13 +8722,14 @@ gent_intscalars(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); @@ -8745,60 +8763,60 @@ gent_intscalars(void) static void gent_attr_intscalars(void) { - hid_t fid = H5I_INVALID_HID; - hid_t attr = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t root = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t root = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; + uint8_t ** dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t ** dset8 = NULL; + int16_t ** dset16 = NULL; + int32_t ** dset32 = NULL; + int64_t ** dset64 = NULL; + double ** dsetdbl = NULL; - uint8_t **dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t **dset8 = NULL; - int16_t **dset16 = NULL; - int32_t **dset32 = NULL; - int64_t **dset64 = NULL; - double **dsetdbl = NULL; - - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); - fid = H5Fcreate(FILE74, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE74, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* Attribute of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -8808,16 +8826,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -8827,16 +8846,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dsetu32[i][j] = dsetu32[i][j - 1] << 1; } valu32bits <<= 1; } @@ -8846,16 +8866,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dsetu64[i][j] = dsetu64[i][j - 1] << 1; } valu64bits <<= 1; } @@ -8865,16 +8886,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -8884,16 +8906,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -8903,16 +8926,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dset32[i][j] = dset32[i][j - 1] << 1; } val32bits <<= 1; } @@ -8922,16 +8946,17 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Attribute of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dset64[i][j] = dset64[i][j - 1] << 1; } val64bits <<= 1; } @@ -8941,13 +8966,14 @@ gent_attr_intscalars(void) H5Aclose(attr); /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); + attr = H5Acreate2(root, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); + + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; H5Awrite(attr, tid, dsetdbl[0]); @@ -8981,28 +9007,29 @@ gent_attr_intscalars(void) static void gent_string_scalars(void) { - hid_t fid, attr, dataset, space, tid, root; - hsize_t dims[2]; - char string[F73_XDIM][F73_YDIM8]; + hid_t fid, attr, dataset, space, tid, root; + hsize_t dims[2]; + char string[F73_XDIM][F73_YDIM8]; unsigned int i, j; - fid = H5Fcreate(FILE75, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE75, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); /* string scalar */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tcopy(H5T_C_S1); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tcopy(H5T_C_S1); H5Tset_size(tid, F73_XDIM * F73_YDIM8); memset(string, ' ', F73_XDIM * F73_YDIM8); - for(i = 0; i < dims[0]; i++) { + for (i = 0; i < dims[0]; i++) { string[i][0] = (char)('A' + i); - for(j = 1; j < dims[1]; j++) { - string[i][j] = (char)(string[i][j-1] + 1); + for (j = 1; j < dims[1]; j++) { + string[i][j] = (char)(string[i][j - 1] + 1); } } - string[dims[0]-1][dims[1]-1] = 0; + string[dims[0] - 1][dims[1] - 1] = 0; /* Dataset of string scalar */ dataset = H5Dcreate2(fid, "the_str", tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -9021,47 +9048,49 @@ gent_string_scalars(void) H5Fclose(fid); } -static void gent_compound_int_array(void) { - hid_t fid, dataset, space; - hsize_t dims[1]; +static void +gent_compound_int_array(void) +{ + hid_t fid, dataset, space; + hsize_t dims[1]; uint8_t valu8bits; uint16_t valu16bits; uint32_t valu32bits; uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; - hsize_t array_dim8[]={F76_DIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F76_DIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F76_DIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F76_DIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + hsize_t array_dim8[] = {F76_DIM8}; /* Array dimensions */ + hsize_t array_dim16[] = {F76_DIM16}; /* Array dimensions */ + hsize_t array_dim32[] = {F76_DIM32}; /* Array dimensions */ + hsize_t array_dim64[] = {F76_DIM64}; /* Array dimensions */ + hid_t arrayu8_tid; /* Array datatype handle */ + hid_t arrayu16_tid; /* Array datatype handle */ + hid_t arrayu32_tid; /* Array datatype handle */ + hid_t arrayu64_tid; /* Array datatype handle */ + hid_t array8_tid; /* Array datatype handle */ + hid_t array16_tid; /* Array datatype handle */ + hid_t array32_tid; /* Array datatype handle */ + hid_t array64_tid; /* Array datatype handle */ + hid_t arraydbl_tid; /* Array datatype handle */ /* Structure and array for compound types */ typedef struct Cmpd1Struct { - uint8_t dsetu8[F76_DIM8]; - uint16_t dsetu16[F76_DIM16]; - uint32_t dsetu32[F76_DIM32]; - uint64_t dsetu64[F76_DIM64]; - int8_t dset8[F76_DIM8]; - int16_t dset16[F76_DIM16]; - int32_t dset32[F76_DIM32]; - int64_t dset64[F76_DIM64]; - double dsetdbl[F76_DIM8]; + uint8_t dsetu8[F76_DIM8]; + uint16_t dsetu16[F76_DIM16]; + uint32_t dsetu32[F76_DIM32]; + uint64_t dsetu64[F76_DIM64]; + int8_t dset8[F76_DIM8]; + int16_t dset16[F76_DIM16]; + int32_t dset32[F76_DIM32]; + int64_t dset64[F76_DIM64]; + double dsetdbl[F76_DIM8]; } Cmpd1Struct; Cmpd1Struct *Cmpd1; - hid_t Cmpd1Structid; /* File datatype identifier */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ - hsize_t dim[] = { F76_LENGTH }; /* Dataspace dimensions */ + hid_t Cmpd1Structid; /* File datatype identifier */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F76_LENGTH}; /* Dataspace dimensions */ int m, n; /* Array init loop vars */ @@ -9075,26 +9104,26 @@ static void gent_compound_int_array(void) { /* Array of 8 bits unsigned int */ dims[0] = F76_DIM8; - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dsetu8[n] = valu8bits; - valu8bits = (uint8_t)(valu8bits << 1); + valu8bits = (uint8_t)(valu8bits << 1); } /* Array of 16 bits unsigned int */ dims[0] = F76_DIM16; - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dsetu16[n] = valu16bits; - valu16bits = (uint16_t)(valu16bits << 1); + valu16bits = (uint16_t)(valu16bits << 1); } /* Array of 32 bits unsigned int */ dims[0] = F76_DIM32; - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dsetu32[n] = valu32bits; valu32bits <<= 1; } @@ -9102,8 +9131,8 @@ static void gent_compound_int_array(void) { /* Array of 64 bits unsigned int */ dims[0] = F76_DIM64; - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dsetu64[n] = valu64bits; valu64bits <<= 1; } @@ -9111,26 +9140,26 @@ static void gent_compound_int_array(void) { /* Array of 8 bits signed int */ dims[0] = F76_DIM8; - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val8bits = (int8_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dset8[n] = val8bits; - val8bits = (int8_t)(val8bits << 1); + val8bits = (int8_t)(val8bits << 1); } /* Array of 16 bits signed int */ dims[0] = F76_DIM16; - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val16bits = (int16_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dset16[n] = val16bits; - val16bits = (int16_t)(val16bits << 1); + val16bits = (int16_t)(val16bits << 1); } /* Array of 32 bits signed int */ dims[0] = F76_DIM32; - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val32bits = (int32_t)~0; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dset32[n] = val32bits; val32bits <<= 1; } @@ -9138,8 +9167,8 @@ static void gent_compound_int_array(void) { /* Array of 64 bits signed int */ dims[0] = F76_DIM64; - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (n = 0; n < (int)dims[0]; n++) { Cmpd1[m].dset64[n] = val64bits; val64bits <<= 1; } @@ -9147,7 +9176,7 @@ static void gent_compound_int_array(void) { /* Double Dummy set for failure tests */ dims[0] = F76_DIM8; - for(n = 0; n < (int)dims[0]; n++) + for (n = 0; n < (int)dims[0]; n++) Cmpd1[m].dsetdbl[n] = 0.0001F + (float)n; } @@ -9277,47 +9306,49 @@ static void gent_compound_int_array(void) { HDfree(Cmpd1); } -static void gent_compound_ints(void) { - hid_t fid, dataset, space; - uint8_t valu8bits = (uint8_t) ~0u; /* all 1s */ - uint16_t valu16bits = (uint16_t) ~0u; /* all 1s */ - uint32_t valu32bits = (uint32_t) ~0u; /* all 1s */ - uint64_t valu64bits = (uint64_t) ~0Lu; /* all 1s */ - int8_t val8bits = (int8_t) ~0; /* all 1s */ - int16_t val16bits = (int16_t) ~0; /* all 1s */ - int32_t val32bits = (int32_t) ~0; /* all 1s */ - int64_t val64bits = (int64_t) ~0L; /* all 1s */ +static void +gent_compound_ints(void) +{ + hid_t fid, dataset, space; + uint8_t valu8bits = (uint8_t)~0u; /* all 1s */ + uint16_t valu16bits = (uint16_t)~0u; /* all 1s */ + uint32_t valu32bits = (uint32_t)~0u; /* all 1s */ + uint64_t valu64bits = (uint64_t)~0Lu; /* all 1s */ + int8_t val8bits = (int8_t)~0; /* all 1s */ + int16_t val16bits = (int16_t)~0; /* all 1s */ + int32_t val32bits = (int32_t)~0; /* all 1s */ + int64_t val64bits = (int64_t)~0L; /* all 1s */ /* Structure and array for compound types */ typedef struct Cmpd1Struct { - uint8_t dsetu8; - uint16_t dsetu16; - uint32_t dsetu32; - uint64_t dsetu64; - int8_t dset8; - int16_t dset16; - int32_t dset32; - int64_t dset64; - double dsetdbl; + uint8_t dsetu8; + uint16_t dsetu16; + uint32_t dsetu32; + uint64_t dsetu64; + int8_t dset8; + int16_t dset16; + int32_t dset32; + int64_t dset64; + double dsetdbl; } Cmpd1Struct; Cmpd1Struct *Cmpd1; typedef struct Cmpd2Struct { - uint64_t dsetu64; - uint32_t dsetu32; - uint16_t dsetu16; - uint8_t dsetu8; - int64_t dset64; - int32_t dset32; - int16_t dset16; - int8_t dset8; - double dsetdbl; + uint64_t dsetu64; + uint32_t dsetu32; + uint16_t dsetu16; + uint8_t dsetu8; + int64_t dset64; + int32_t dset32; + int16_t dset16; + int8_t dset8; + double dsetdbl; } Cmpd2Struct; Cmpd2Struct *Cmpd2; - hid_t Cmpd1Structid; /* File datatype identifier */ - hid_t Cmpd2Structid; /* File datatype identifier */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ - hsize_t dim[] = { F77_LENGTH }; /* Dataspace dimensions */ + hid_t Cmpd1Structid; /* File datatype identifier */ + hid_t Cmpd2Structid; /* File datatype identifier */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ + hsize_t dim[] = {F77_LENGTH}; /* Dataspace dimensions */ int m; /* Array init loop vars */ @@ -9331,57 +9362,57 @@ static void gent_compound_ints(void) { for (m = 0; m < F77_LENGTH; m++) { /* Array of 8 bits unsigned int */ - if((m % F76_DIM8) == 0) - valu8bits = (uint8_t) ~0u; /* all 1s */ + if ((m % F76_DIM8) == 0) + valu8bits = (uint8_t)~0u; /* all 1s */ Cmpd1[m].dsetu8 = valu8bits; Cmpd2[m].dsetu8 = valu8bits; - valu8bits = (uint8_t)(valu8bits << 1); + valu8bits = (uint8_t)(valu8bits << 1); /* Array of 16 bits unsigned int */ - if((m % F76_DIM16) == 0) - valu16bits = (uint16_t) ~0u; /* all 1s */ + if ((m % F76_DIM16) == 0) + valu16bits = (uint16_t)~0u; /* all 1s */ Cmpd1[m].dsetu16 = valu16bits; Cmpd2[m].dsetu16 = valu16bits; - valu16bits = (uint16_t)(valu16bits << 1); + valu16bits = (uint16_t)(valu16bits << 1); /* Array of 32 bits unsigned int */ - if((m % F76_DIM32) == 0) - valu32bits = (uint32_t) ~0u; /* all 1s */ + if ((m % F76_DIM32) == 0) + valu32bits = (uint32_t)~0u; /* all 1s */ Cmpd1[m].dsetu32 = valu32bits; Cmpd2[m].dsetu32 = valu32bits; valu32bits <<= 1; /* Array of 64 bits unsigned int */ - if((m % F76_DIM64) == 0) - valu64bits = (uint64_t) ~0Lu; /* all 1s */ + if ((m % F76_DIM64) == 0) + valu64bits = (uint64_t)~0Lu; /* all 1s */ Cmpd1[m].dsetu64 = valu64bits; Cmpd2[m].dsetu64 = valu64bits; valu64bits <<= 1; /* Array of 8 bits signed int */ - if((m % F76_DIM8) == 0) - val8bits = (int8_t) ~0; /* all 1s */ + if ((m % F76_DIM8) == 0) + val8bits = (int8_t)~0; /* all 1s */ Cmpd1[m].dset8 = val8bits; Cmpd2[m].dset8 = val8bits; - val8bits = (int8_t)(val8bits << 1); + val8bits = (int8_t)(val8bits << 1); /* Array of 16 bits signed int */ - if((m % F76_DIM16) == 0) - val16bits = (int16_t) ~0; /* all 1s */ + if ((m % F76_DIM16) == 0) + val16bits = (int16_t)~0; /* all 1s */ Cmpd1[m].dset16 = val16bits; Cmpd2[m].dset16 = val16bits; - val16bits = (int16_t)(val16bits << 1); + val16bits = (int16_t)(val16bits << 1); /* Array of 32 bits signed int */ - if((m % F76_DIM32) == 0) - val32bits = (int32_t) ~0; /* all 1s */ + if ((m % F76_DIM32) == 0) + val32bits = (int32_t)~0; /* all 1s */ Cmpd1[m].dset32 = val32bits; Cmpd2[m].dset32 = val32bits; val32bits <<= 1; /* Array of 64 bits signed int */ - if((m % F76_DIM64) == 0) - val64bits = (int64_t) ~0L; /* all 1s */ + if ((m % F76_DIM64) == 0) + val64bits = (int64_t)~0L; /* all 1s */ Cmpd1[m].dset64 = val64bits; Cmpd2[m].dset64 = val64bits; val64bits <<= 1; @@ -9521,58 +9552,59 @@ static void gent_compound_ints(void) { static void gent_intattrscalars(void) { - hid_t fid = H5I_INVALID_HID; - hid_t attr = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t **dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t **dset8 = NULL; - int16_t **dset16 = NULL; - int32_t **dset32 = NULL; - int64_t **dset64 = NULL; - double **dsetdbl = NULL; - - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + uint8_t ** dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t ** dset8 = NULL; + int16_t ** dset16 = NULL; + int32_t ** dset32 = NULL; + int64_t ** dset64 = NULL; + double ** dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); fid = H5Fcreate(FILE78, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); } valu8bits = (uint8_t)(valu8bits << 1); } @@ -9586,16 +9618,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); } valu16bits = (uint16_t)(valu16bits << 1); } @@ -9609,16 +9642,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dsetu32[i][j] = dsetu32[i][j - 1] << 1; } valu32bits <<= 1; } @@ -9632,16 +9666,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dsetu64[i][j] = dsetu64[i][j - 1] << 1; } valu64bits <<= 1; } @@ -9655,16 +9690,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); } val8bits = (int8_t)(val8bits << 1); } @@ -9678,16 +9714,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM16; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); + for (j = 1; j < dims[1]; j++) { + dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); } val16bits = (int16_t)(val16bits << 1); } @@ -9701,16 +9738,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM32; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dset32[i][j] = dset32[i][j - 1] << 1; } val32bits <<= 1; } @@ -9724,16 +9762,17 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM64; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; + for (j = 1; j < dims[1]; j++) { + dset64[i][j] = dset64[i][j - 1] << 1; } val64bits <<= 1; } @@ -9747,13 +9786,14 @@ gent_intattrscalars(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); + dims[0] = F73_XDIM; + dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); dataset = H5Dcreate2(fid, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); @@ -9790,80 +9830,80 @@ gent_intattrscalars(void) static void gent_intsattrs(void) { - hid_t fid = H5I_INVALID_HID; - hid_t attr = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - hid_t space = H5I_INVALID_HID; - hid_t aspace = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t aspace = H5I_INVALID_HID; hsize_t dims[2], adims[1]; + uint8_t ** dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t ** dset8 = NULL; + int16_t ** dset16 = NULL; + int32_t ** dset32 = NULL; + int64_t ** dset64 = NULL; + double ** dsetdbl = NULL; + + uint8_t * asetu8 = NULL; + uint16_t *asetu16 = NULL; + uint32_t *asetu32 = NULL; + uint64_t *asetu64 = NULL; + int8_t * aset8 = NULL; + int16_t * aset16 = NULL; + int32_t * aset32 = NULL; + int64_t * aset64 = NULL; + double * asetdbl = NULL; - uint8_t **dsetu8 = NULL; - uint16_t **dsetu16 = NULL; - uint32_t **dsetu32 = NULL; - uint64_t **dsetu64 = NULL; - int8_t **dset8 = NULL; - int16_t **dset16 = NULL; - int32_t **dset32 = NULL; - int64_t **dset64 = NULL; - double **dsetdbl = NULL; - - uint8_t *asetu8 = NULL; - uint16_t *asetu16 = NULL; - uint32_t *asetu32 = NULL; - uint64_t *asetu64 = NULL; - int8_t *aset8 = NULL; - int16_t *aset16 = NULL; - int32_t *aset32 = NULL; - int64_t *aset64 = NULL; - double *asetdbl = NULL; - - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; unsigned int i, j; /* Create arrays */ - H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); - H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); - H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); - H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); - H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); - asetu8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(uint8_t)); + asetu8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(uint8_t)); asetu16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(uint16_t)); asetu32 = HDcalloc(F66_XDIM * F66_YDIM32, sizeof(uint32_t)); asetu64 = HDcalloc(F66_XDIM * F66_YDIM64, sizeof(uint64_t)); - aset8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(int8_t)); + aset8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(int8_t)); aset16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(int16_t)); aset32 = HDcalloc(F66_XDIM * F66_YDIM32, sizeof(int32_t)); aset64 = HDcalloc(F66_XDIM * F66_YDIM64, sizeof(int64_t)); - asetdbl = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(double)); + asetdbl = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(double)); fid = H5Fcreate(FILE79, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - asetu8[i*dims[1]] = dsetu8[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); - asetu8[i*dims[1]+j] = dsetu8[i][j]; + valu8bits = (uint8_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu8[i][0] = valu8bits; + asetu8[i * dims[1]] = dsetu8[i][0]; + for (j = 1; j < dims[1]; j++) { + dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); + asetu8[i * dims[1] + j] = dsetu8[i][j]; } valu8bits = (uint8_t)(valu8bits << 1); } @@ -9871,8 +9911,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); /* Attribute of 8 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU08, H5T_STD_U8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETU08, H5T_STD_U8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_UINT8, asetu8); H5Aclose(attr); H5Sclose(aspace); @@ -9880,17 +9920,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - asetu16[i*dims[1]] = dsetu16[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); - asetu16[i*dims[1]+j] = dsetu16[i][j]; + valu16bits = (uint16_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu16[i][0] = valu16bits; + asetu16[i * dims[1]] = dsetu16[i][0]; + for (j = 1; j < dims[1]; j++) { + dsetu16[i][j] = (uint16_t)(dsetu16[i][j - 1] << 1); + asetu16[i * dims[1] + j] = dsetu16[i][j]; } valu16bits = (uint16_t)(valu16bits << 1); } @@ -9898,8 +9939,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); /* Attribute of 16 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM16; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU16, H5T_STD_U16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETU16, H5T_STD_U16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_UINT16, asetu16); H5Aclose(attr); H5Sclose(aspace); @@ -9907,17 +9948,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - asetu32[i*dims[1]] = dsetu32[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; - asetu32[i*dims[1]+j] = dsetu32[i][j]; + valu32bits = (uint32_t)~0u; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu32[i][0] = valu32bits; + asetu32[i * dims[1]] = dsetu32[i][0]; + for (j = 1; j < dims[1]; j++) { + dsetu32[i][j] = dsetu32[i][j - 1] << 1; + asetu32[i * dims[1] + j] = dsetu32[i][j]; } valu32bits <<= 1; } @@ -9925,8 +9967,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); /* Attribute of 32 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM32; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU32, H5T_STD_U32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETU32, H5T_STD_U32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_UINT32, asetu32); H5Aclose(attr); H5Sclose(aspace); @@ -9934,17 +9976,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - asetu64[i*dims[1]] = dsetu64[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; - asetu64[i*dims[1]+j] = dsetu64[i][j]; + valu64bits = (uint64_t)~0Lu; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dsetu64[i][0] = valu64bits; + asetu64[i * dims[1]] = dsetu64[i][0]; + for (j = 1; j < dims[1]; j++) { + dsetu64[i][j] = dsetu64[i][j - 1] << 1; + asetu64[i * dims[1] + j] = dsetu64[i][j]; } valu64bits <<= 1; } @@ -9952,8 +9995,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); /* Attribute of 64 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM64; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU64, H5T_STD_U64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETU64, H5T_STD_U64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_UINT64, asetu64); H5Aclose(attr); H5Sclose(aspace); @@ -9961,17 +10004,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - aset8[i*dims[1]] = dset8[i][0]; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); - aset8[i*dims[1]+j] = dset8[i][j]; + val8bits = (int8_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset8[i][0] = val8bits; + aset8[i * dims[1]] = dset8[i][0]; + for (j = 1; j < dims[1]; j++) { + dset8[i][j] = (int8_t)(dset8[i][j - 1] << 1); + aset8[i * dims[1] + j] = dset8[i][j]; } val8bits = (int8_t)(val8bits << 1); } @@ -9979,8 +10023,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); /* Attribute of 8 bits signed int */ adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS08, H5T_STD_I8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETS08, H5T_STD_I8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT8, aset8); H5Aclose(attr); H5Sclose(aspace); @@ -9988,17 +10032,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM16; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - aset16[i*dims[1]] = dset16[i][0]; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); - aset16[i*dims[1]+j] = dset16[i][j]; + val16bits = (int16_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset16[i][0] = val16bits; + aset16[i * dims[1]] = dset16[i][0]; + for (j = 1; j < dims[1]; j++) { + dset16[i][j] = (int16_t)(dset16[i][j - 1] << 1); + aset16[i * dims[1] + j] = dset16[i][j]; } val16bits = (int16_t)(val16bits << 1); } @@ -10006,8 +10051,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); /* Attribute of 16 bits signed int */ adims[0] = F66_XDIM * F66_YDIM16; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS16, H5T_STD_I16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETS16, H5T_STD_I16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT16, aset16); H5Aclose(attr); H5Sclose(aspace); @@ -10015,17 +10060,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM32; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - aset32[i*dims[1]] = dset32[i][0]; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; - aset32[i*dims[1]+j] = dset32[i][j]; + val32bits = (int32_t)~0; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset32[i][0] = val32bits; + aset32[i * dims[1]] = dset32[i][0]; + for (j = 1; j < dims[1]; j++) { + dset32[i][j] = dset32[i][j - 1] << 1; + aset32[i * dims[1] + j] = dset32[i][j]; } val32bits <<= 1; } @@ -10033,8 +10079,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); /* Attribute of 32 bits signed int */ adims[0] = F66_XDIM * F66_YDIM32; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS32, H5T_STD_I32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETS32, H5T_STD_I32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT32, aset32); H5Aclose(attr); H5Sclose(aspace); @@ -10042,17 +10088,18 @@ gent_intsattrs(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM64; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - aset64[i*dims[1]] = dset64[i][0]; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; - aset64[i*dims[1]+j] = dset64[i][j]; + val64bits = (int64_t)~0L; /* all 1s */ + for (i = 0; i < dims[0]; i++) { + dset64[i][0] = val64bits; + aset64[i * dims[1]] = dset64[i][0]; + for (j = 1; j < dims[1]; j++) { + dset64[i][j] = dset64[i][j - 1] << 1; + aset64[i * dims[1] + j] = dset64[i][j]; } val64bits <<= 1; } @@ -10060,8 +10107,8 @@ gent_intsattrs(void) H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); /* Attribute of 64 bits signed int */ adims[0] = F66_XDIM * F66_YDIM64; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS64, H5T_STD_I64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DATASETS64, H5T_STD_I64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_INT64, aset64); H5Aclose(attr); H5Sclose(aspace); @@ -10069,21 +10116,22 @@ gent_intsattrs(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); + dims[0] = F66_XDIM; + dims[1] = F66_YDIM8; + space = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) { - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - asetdbl[i*dims[1]+j] = dsetdbl[i][j]; + for (i = 0; i < dims[0]; i++) + for (j = 0; j < dims[1]; j++) { + dsetdbl[i][j] = 0.0001F * (float)j + (float)i; + asetdbl[i * dims[1] + j] = dsetdbl[i][j]; } H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); /* Attribute of double */ adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DUMMYDBL, H5T_IEEE_F64BE, aspace, H5P_DEFAULT, H5P_DEFAULT); + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F66_DUMMYDBL, H5T_IEEE_F64BE, aspace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_DOUBLE, asetdbl); H5Aclose(attr); H5Sclose(aspace); @@ -10112,25 +10160,26 @@ gent_intsattrs(void) HDfree(asetdbl); } -static void gent_bitnopaquefields(void) +static void +gent_bitnopaquefields(void) { /* Compound datatype */ - typedef struct s_t - { - uint8_t a; - uint16_t b; - uint32_t c; - uint64_t d; + typedef struct s_t { + uint8_t a; + uint16_t b; + uint32_t c; + uint64_t d; } s_t; - hid_t file_id=H5I_INVALID_HID, grp=H5I_INVALID_HID, type=H5I_INVALID_HID, space=H5I_INVALID_HID, dset=H5I_INVALID_HID; - size_t i; + hid_t file_id = H5I_INVALID_HID, grp = H5I_INVALID_HID, type = H5I_INVALID_HID, space = H5I_INVALID_HID, + dset = H5I_INVALID_HID; + size_t i; hsize_t nelmts = F80_DIM32; - uint8_t buf[F80_DIM32]; /* bitfield, opaque */ - uint16_t buf2[F80_DIM32]; /* bitfield, opaque */ - uint32_t buf3[F80_DIM32]; /* bitfield, opaque */ - uint64_t buf4[F80_DIM32]; /* bitfield, opaque */ - s_t buf5[F80_DIM32]; /* compound */ + uint8_t buf[F80_DIM32]; /* bitfield, opaque */ + uint16_t buf2[F80_DIM32]; /* bitfield, opaque */ + uint32_t buf3[F80_DIM32]; /* bitfield, opaque */ + uint64_t buf4[F80_DIM32]; /* bitfield, opaque */ + s_t buf5[F80_DIM32]; /* compound */ file_id = H5Fcreate(FILE80, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -10138,7 +10187,8 @@ static void gent_bitnopaquefields(void) /* bitfield_1 */ if ((type = H5Tcopy(H5T_STD_B8LE)) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 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); } @@ -10153,7 +10203,8 @@ static void gent_bitnopaquefields(void) /* bitfield_2 */ if ((type = H5Tcopy(H5T_STD_B16LE)) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 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)); } @@ -10168,7 +10219,8 @@ static void gent_bitnopaquefields(void) /* bitfield_3 */ if ((type = H5Tcopy(H5T_STD_B32LE)) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_3", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_3", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for (i = 0; i < nelmts; i++) { buf3[i] = (uint32_t)0xffffffff ^ (uint32_t)(i * 32); } @@ -10183,7 +10235,8 @@ static void gent_bitnopaquefields(void) /* bitfield_4 */ if ((type = H5Tcopy(H5T_STD_B64LE)) >= 0) { if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_4", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(grp, "bitfield_4", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for (i = 0; i < nelmts; i++) { buf4[i] = (uint64_t)0xffffffffffffffff ^ (uint64_t)(i * 64); } @@ -10203,8 +10256,9 @@ static void gent_bitnopaquefields(void) if ((type = H5Tcreate(H5T_OPAQUE, 1)) >= 0) { if ((H5Tset_tag(type, "1-byte opaque type")) >= 0) { 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++) + if ((dset = H5Dcreate2(grp, "opaque_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) H5_CHECKED_ASSIGN(buf[i], uint8_t, 0xff ^ i, size_t); H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); H5Dclose(dset); @@ -10219,8 +10273,9 @@ static void gent_bitnopaquefields(void) if ((type = H5Tcreate(H5T_OPAQUE, 2)) >= 0) { if ((H5Tset_tag(type, "2-byte opaque type")) >= 0) { 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++) + if ((dset = H5Dcreate2(grp, "opaque_2", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) H5_CHECKED_ASSIGN(buf2[i], uint16_t, 0xffff ^ (i * 16), size_t); H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); @@ -10242,8 +10297,9 @@ static void gent_bitnopaquefields(void) H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); 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++) { + if ((dset = H5Dcreate2(grp, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) { H5_CHECKED_ASSIGN(buf5[i].a, uint8_t, 0xff ^ i, size_t); H5_CHECKED_ASSIGN(buf5[i].b, uint16_t, 0xffff ^ (i * 16), size_t); buf5[i].c = (uint32_t)0xffffffff ^ (uint32_t)(i * 32); @@ -10273,23 +10329,27 @@ static void gent_bitnopaquefields(void) static void gent_intsfourdims(void) { - hid_t fid, dataset, space; - hsize_t dims[F81_RANK]; - uint32_t dset1[F81_ZDIM][F81_YDIM][F81_XDIM][F81_WDIM]; + hid_t fid, dataset, space; + hsize_t dims[F81_RANK]; + uint32_t dset1[F81_ZDIM][F81_YDIM][F81_XDIM][F81_WDIM]; unsigned int i, j, k, l; fid = H5Fcreate(FILE81, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 32 bits unsigned int */ - dims[0] = F81_ZDIM; dims[1] = F81_YDIM; dims[2] = F81_XDIM; dims[3] = F81_WDIM; - space = H5Screate_simple(F81_RANK, dims, NULL); + dims[0] = F81_ZDIM; + dims[1] = F81_YDIM; + dims[2] = F81_XDIM; + dims[3] = F81_WDIM; + space = H5Screate_simple(F81_RANK, dims, NULL); dataset = H5Dcreate2(fid, F81_DATASETNAME, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < F81_ZDIM; i++) - for(j = 0; j < F81_YDIM; j++) - for(k = 0; k < F81_XDIM; k++) - for(l = 0; l < F81_WDIM; l++) - dset1[i][j][k][l] = i*F81_YDIM*F81_XDIM*F81_WDIM + j*F81_XDIM*F81_WDIM + k*F81_WDIM + l; + for (i = 0; i < F81_ZDIM; i++) + for (j = 0; j < F81_YDIM; j++) + for (k = 0; k < F81_XDIM; k++) + for (l = 0; l < F81_WDIM; l++) + dset1[i][j][k][l] = + i * F81_YDIM * F81_XDIM * F81_WDIM + j * F81_XDIM * F81_WDIM + k * F81_WDIM + l; H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); H5Sclose(space); @@ -10305,7 +10365,8 @@ gent_intsfourdims(void) * various sizes, dimensions, member types and nesting. *------------------------------------------------------------------------- */ -static void gent_compound_complex2(void) +static void +gent_compound_complex2(void) { /* Third-level nested compound */ typedef struct { @@ -10325,45 +10386,42 @@ static void gent_compound_complex2(void) } further_nested; typedef struct { - char further_nested_string[11]; - char further_nested_string_array[4][13]; + char further_nested_string[11]; + char further_nested_string_array[4][13]; third_level_compound deep_nest; } further_nested2; /* First First-level nested compound */ - typedef struct - { + typedef struct { double nested_a; char nested_string[23]; char nested_string_array[4][12]; } nested_compound; /* Second First-level nested compound */ - typedef struct - { + typedef struct { float a; further_nested b; further_nested2 c; } multiple_nested_compound; /* Compound datatype with different member types */ - typedef struct - { + typedef struct { /* Arrays nested inside compound */ unsigned int a[4]; int b[6]; float c[2][4]; - nested_compound d; /* Compound inside compound */ - multiple_nested_compound e; /* Compound inside compound with further nested compound */ + nested_compound d; /* Compound inside compound */ + multiple_nested_compound e; /* Compound inside compound with further nested compound */ } compound; - compound *buf; /* compound */ + compound *buf; /* compound */ - hid_t file, type=H5I_INVALID_HID, space=H5I_INVALID_HID, dset=H5I_INVALID_HID; - hid_t dset_array_a, dset_array_b, dset_array_c; - hid_t cmpd_tid1 = H5I_INVALID_HID, cmpd_tid2 = H5I_INVALID_HID, cmpd_tid3 = H5I_INVALID_HID; - size_t i; - size_t j, k; + hid_t file, type = H5I_INVALID_HID, space = H5I_INVALID_HID, dset = H5I_INVALID_HID; + hid_t dset_array_a, dset_array_b, dset_array_c; + hid_t cmpd_tid1 = H5I_INVALID_HID, cmpd_tid2 = H5I_INVALID_HID, cmpd_tid3 = H5I_INVALID_HID; + size_t i; + size_t j, k; unsigned dset_array_ndims; hsize_t dset_array_a_dims[1], dset_array_b_dims[1], dset_array_c_dims[2]; hsize_t nelmts = F82_DIM32; @@ -10377,23 +10435,27 @@ static void gent_compound_complex2(void) if ((space = H5Screate_simple(F82_RANK, &nelmts, NULL)) >= 0) { /* CompoundComplex1D */ if ((type = H5Tcreate(H5T_COMPOUND, sizeof(compound))) >= 0) { - hid_t str_type, array; + hid_t str_type, array; hsize_t dims[1]; - hid_t nest1, nest2; + hid_t nest1, nest2; /* Insert top-level array members */ - dset_array_ndims = 1; dset_array_a_dims[0] = 4; - dset_array_a = H5Tarray_create2(H5T_STD_U32LE, dset_array_ndims, dset_array_a_dims); + dset_array_ndims = 1; + dset_array_a_dims[0] = 4; + dset_array_a = H5Tarray_create2(H5T_STD_U32LE, dset_array_ndims, dset_array_a_dims); H5Tinsert(type, "a", HOFFSET(compound, a), dset_array_a); H5Tclose(dset_array_a); - dset_array_ndims = 1; dset_array_b_dims[0] = 6; - dset_array_b = H5Tarray_create2(H5T_STD_I32LE, dset_array_ndims, dset_array_b_dims); + dset_array_ndims = 1; + dset_array_b_dims[0] = 6; + dset_array_b = H5Tarray_create2(H5T_STD_I32LE, dset_array_ndims, dset_array_b_dims); H5Tinsert(type, "b", HOFFSET(compound, b), dset_array_b); H5Tclose(dset_array_b); - dset_array_ndims = 2; dset_array_c_dims[0] = 2; dset_array_c_dims[1] = 4; - dset_array_c = H5Tarray_create2(H5T_IEEE_F32LE, dset_array_ndims, dset_array_c_dims); + dset_array_ndims = 2; + dset_array_c_dims[0] = 2; + dset_array_c_dims[1] = 4; + dset_array_c = H5Tarray_create2(H5T_IEEE_F32LE, dset_array_ndims, dset_array_c_dims); H5Tinsert(type, "c", HOFFSET(compound, c), dset_array_c); H5Tclose(dset_array_c); @@ -10402,16 +10464,16 @@ static void gent_compound_complex2(void) H5Tinsert(cmpd_tid1, "nested_double", HOFFSET(nested_compound, nested_a), H5T_IEEE_F64LE); - dims[0] = 1; + dims[0] = 1; str_type = mkstr(23, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); + array = H5Tarray_create2(str_type, 1, dims); H5Tinsert(cmpd_tid1, "nested_string", HOFFSET(nested_compound, nested_string), array); H5Tclose(array); H5Tclose(str_type); - dims[0] = 4; + dims[0] = 4; str_type = mkstr(12, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); + array = H5Tarray_create2(str_type, 1, dims); H5Tinsert(cmpd_tid1, "nested_string_array", HOFFSET(nested_compound, nested_string_array), array); H5Tclose(array); H5Tclose(str_type); @@ -10427,7 +10489,7 @@ static void gent_compound_complex2(void) nest1 = H5Tcreate(H5T_COMPOUND, sizeof(further_nested)); dims[0] = 5; - array = H5Tarray_create2(H5T_STD_U32LE, 1, dims); + array = H5Tarray_create2(H5T_STD_U32LE, 1, dims); H5Tinsert(nest1, "nested_unsigned_int", HOFFSET(further_nested, multiple_nested_a), array); H5Tclose(array); @@ -10449,17 +10511,18 @@ static void gent_compound_complex2(void) /* Add second further nested compound */ nest2 = H5Tcreate(H5T_COMPOUND, sizeof(further_nested2)); - dims[0] = 1; + dims[0] = 1; str_type = mkstr(11, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); + array = H5Tarray_create2(str_type, 1, dims); H5Tinsert(nest2, "nested_string", HOFFSET(further_nested2, further_nested_string), array); H5Tclose(array); H5Tclose(str_type); - dims[0] = 4; + dims[0] = 4; str_type = mkstr(13, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); - H5Tinsert(nest2, "nested_string_array", HOFFSET(further_nested2, further_nested_string_array), array); + array = H5Tarray_create2(str_type, 1, dims); + H5Tinsert(nest2, "nested_string_array", HOFFSET(further_nested2, further_nested_string_array), + array); H5Tclose(array); H5Tclose(str_type); @@ -10467,8 +10530,9 @@ static void gent_compound_complex2(void) cmpd_tid3 = H5Tcreate(H5T_COMPOUND, sizeof(third_level_compound)); dims[0] = 10; - array = H5Tarray_create2(H5T_STD_I16LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_short", HOFFSET(third_level_compound, deep_nested_short), array); + array = H5Tarray_create2(H5T_STD_I16LE, 1, dims); + H5Tinsert(cmpd_tid3, "deep_nested_short", HOFFSET(third_level_compound, deep_nested_short), + array); H5Tclose(array); array = H5Tarray_create2(H5T_STD_I32LE, 1, dims); @@ -10480,11 +10544,13 @@ static void gent_compound_complex2(void) H5Tclose(array); array = H5Tarray_create2(H5T_IEEE_F64LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_double", HOFFSET(third_level_compound, deep_nested_double), array); + H5Tinsert(cmpd_tid3, "deep_nested_double", HOFFSET(third_level_compound, deep_nested_double), + array); H5Tclose(array); array = H5Tarray_create2(H5T_IEEE_F32LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_float", HOFFSET(third_level_compound, deep_nested_float), array); + H5Tinsert(cmpd_tid3, "deep_nested_float", HOFFSET(third_level_compound, deep_nested_float), + array); H5Tclose(array); H5Tinsert(nest2, "deep_nested_compound", HOFFSET(further_nested2, deep_nest), cmpd_tid3); @@ -10494,19 +10560,19 @@ static void gent_compound_complex2(void) H5Tinsert(type, "multiple_nested_compound", HOFFSET(compound, e), cmpd_tid2); - - if ((dset = H5Dcreate2(file, F82_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { + if ((dset = H5Dcreate2(file, F82_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { + for (i = 0; i < nelmts; i++) { for (j = 0; j < dset_array_a_dims[0]; j++) - buf[i].a[j] = (unsigned int)(j + i*10); + buf[i].a[j] = (unsigned int)(j + i * 10); for (j = 0; j < dset_array_b_dims[0]; j++) - buf[i].b[j] = (int)(j - i*10); + buf[i].b[j] = (int)(j - i * 10); for (j = 0; j < dset_array_c_dims[0]; j++) for (k = 0; k < dset_array_c_dims[1]; k++) - buf[i].c[j][k] = (float)(j + k + i*10) + (float)(j) * 0.1F; + buf[i].c[j][k] = (float)(j + k + i * 10) + (float)(j)*0.1F; /* Set up first nested compound */ - buf[i].d.nested_a = (double) i; + buf[i].d.nested_a = (double)i; HDstrcpy(buf[i].d.nested_string, "This is a test string."); @@ -10514,13 +10580,13 @@ static void gent_compound_complex2(void) HDstrcpy(buf[i].d.nested_string_array[j], "String test"); /* Set up multiple nested compound */ - buf[i].e.a = (float) i; + buf[i].e.a = (float)i; for (j = 0; j < 5; j++) { - buf[i].e.b.multiple_nested_a[j] = (unsigned int)(j + i*10); - buf[i].e.b.multiple_nested_b[j] = (int)(j - i*10); - buf[i].e.b.multiple_nested_c[j] = (unsigned long)(j + i*10); - buf[i].e.b.multiple_nested_d[j] = (long)(j - i*10); + buf[i].e.b.multiple_nested_a[j] = (unsigned int)(j + i * 10); + buf[i].e.b.multiple_nested_b[j] = (int)(j - i * 10); + buf[i].e.b.multiple_nested_c[j] = (unsigned long)(j + i * 10); + buf[i].e.b.multiple_nested_d[j] = (long)(j - i * 10); } HDstrcpy(buf[i].e.c.further_nested_string, "1234567890"); @@ -10528,11 +10594,11 @@ static void gent_compound_complex2(void) HDstrcpy(buf[i].e.c.further_nested_string_array[j], "STRING ARRAY"); for (j = 0; j < 10; j++) { - buf[i].e.c.deep_nest.deep_nested_short[j] = (short)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_int[j] = (int)(j - i*10); - buf[i].e.c.deep_nest.deep_nested_long[j] = (long)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_double[j] = (double)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_float[j] = (float)(j + i*10); + buf[i].e.c.deep_nest.deep_nested_short[j] = (short)(j + i * 10); + buf[i].e.c.deep_nest.deep_nested_int[j] = (int)(j - i * 10); + buf[i].e.c.deep_nest.deep_nested_long[j] = (long)(j + i * 10); + buf[i].e.c.deep_nest.deep_nested_double[j] = (double)(j + i * 10); + buf[i].e.c.deep_nest.deep_nested_float[j] = (float)(j + i * 10); } } @@ -10550,74 +10616,71 @@ static void gent_compound_complex2(void) } /* CompoundComplex2D */ -/* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { - H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); - H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); - H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); - H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); - if ((space = H5Screate_simple(F82_RANK2, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; - buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); - buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); - buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); - } + /* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { + H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); + H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); + H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); + H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); + if ((space = H5Screate_simple(F82_RANK2, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) { buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; + buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); + buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); + buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); + } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); - H5Dclose(dset); + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); + H5Dclose(dset); + } + H5Sclose(space); } - H5Sclose(space); + H5Tclose(type); } - H5Tclose(type); - } -*/ + */ /* CompoundComplex3D */ -/* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { - H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); - H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); - H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); - H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); - if ((space = H5Screate_simple(F82_RANK3, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; - buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); - buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); - buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); - } + /* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { + H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); + H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); + H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); + H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); + if ((space = H5Screate_simple(F82_RANK3, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) { buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; + buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); + buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); + buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); + } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); - H5Dclose(dset); + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); + H5Dclose(dset); + } + H5Sclose(space); } - H5Sclose(space); + H5Tclose(type); } - H5Tclose(type); - } -*/ + */ /* CompoundComplex4D */ -/* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { - H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); - H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); - H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); - H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); - if ((space = H5Screate_simple(F82_RANK4, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; - buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); - buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); - buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); - } + /* if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { + H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); + H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); + H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); + H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); + if ((space = H5Screate_simple(F82_RANK4, &nelmts, NULL)) >= 0) { + if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { for(i = 0; i < nelmts; i++) { buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; + buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); + buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); + buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); + } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); - H5Dclose(dset); + H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); + H5Dclose(dset); + } + H5Sclose(space); } - H5Sclose(space); + H5Tclose(type); } - H5Tclose(type); - } -*/ + */ H5Fclose(file); HDfree(buf); @@ -10630,32 +10693,30 @@ static void gent_compound_complex2(void) * length strings. *------------------------------------------------------------------------- */ -static void gent_vlenstr_array(void) +static void +gent_vlenstr_array(void) { /* Compound datatype with different member types */ - typedef struct compound - { + typedef struct compound { /* Array of variable-length strings*/ const char *vlen_array[F83_ARRAYDIM]; } compound; - compound buf[F83_DIM]; + compound buf[F83_DIM]; const char *test[F83_ARRAYDIM] = { - "This is a variable-length test string.", - "This test string is also variable-length.", - "A final test of variable-length strings. This string is longer than the others." - }; - const char *buffer[F83_DIM*F83_ARRAYDIM]; + "This is a variable-length test string.", "This test string is also variable-length.", + "A final test of variable-length strings. This string is longer than the others."}; + const char *buffer[F83_DIM * F83_ARRAYDIM]; - hid_t file, type=H5I_INVALID_HID, space=H5I_INVALID_HID, dset=H5I_INVALID_HID; + hid_t file, type = H5I_INVALID_HID, space = H5I_INVALID_HID, dset = H5I_INVALID_HID; hid_t cmpd_tid1, array_tid; - int i, j; + int i, j; hsize_t dims[] = {F83_DIM}, arraydim[] = {F83_ARRAYDIM}; /* Initialize scalar data */ for (i = 0; i < F83_DIM; i++) for (j = 0; j < 3; j++) - buffer[j + 3*i] = test[j]; + buffer[j + 3 * i] = test[j]; /* Initialize compound data */ for (i = 0; i < F83_DIM; i++) @@ -10670,7 +10731,8 @@ static void gent_vlenstr_array(void) /* ScalarArrayOfVlenStr */ if ((type = H5Tarray_create2(array_tid, F83_RANK, arraydim)) >= 0) { - if ((dset = H5Dcreate2(file, F83_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(file, F83_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer) < 0) HDfprintf(stderr, "gent_vlenstr_array H5Dwrite failed\n"); @@ -10691,7 +10753,8 @@ static void gent_vlenstr_array(void) array_tid = H5Tarray_create2(cmpd_tid1, F83_RANK, arraydim); H5Tinsert(type, "vlen_str_array", HOFFSET(compound, vlen_array), array_tid); - if ((dset = H5Dcreate2(file, F83_DATASETNAME2, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if ((dset = H5Dcreate2(file, F83_DATASETNAME2, type, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) >= 0) { if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) HDfprintf(stderr, "gent_vlenstr_array H5Dwrite failed\n"); @@ -10712,34 +10775,35 @@ static void gent_vlenstr_array(void) * Purpose: Generate a file to be used in testing user defined filter plugin3. *------------------------------------------------------------------------- */ -static void gent_udfilter(void) +static void +gent_udfilter(void) { - hid_t fid; /* file id */ - hid_t dcpl; /* dataset creation property list */ - hid_t dsid; /* dataset ID */ - hid_t sid; /* dataspace ID */ - - hsize_t dims1[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int buf1[DIM1][DIM2]; - int i, j, n; - int H5_ATTR_NDEBUG_UNUSED ret; - - for(i=n=0; i=0); + fid = H5Fcreate(FILE84, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(fid >= 0); /* create a space */ sid = H5Screate_simple(SPACE2_RANK, dims1, NULL); dcpl = H5Pcreate(H5P_DATASET_CREATE); - HDassert(dcpl>=0); + HDassert(dcpl >= 0); ret = H5Pset_layout(dcpl, H5D_CHUNKED); HDassert(ret >= 0); @@ -10747,10 +10811,10 @@ static void gent_udfilter(void) ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims); HDassert(ret >= 0); - ret = H5Zregister (H5Z_DYNLIBUD); + ret = H5Zregister(H5Z_DYNLIBUD); HDassert(ret >= 0); - ret = H5Pset_filter (dcpl, H5Z_FILTER_DYNLIBUD, H5Z_FLAG_MANDATORY, 0, NULL); + ret = H5Pset_filter(dcpl, H5Z_FILTER_DYNLIBUD, H5Z_FLAG_MANDATORY, 0, NULL); HDassert(ret >= 0); /* create the dataset */ @@ -10797,38 +10861,37 @@ static void gent_udfilter(void) *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*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) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ cd_values = cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = (int8_t)(temp - MULTIPLIER); + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = (int8_t)(temp + MULTIPLIER); + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ @@ -10845,13 +10908,14 @@ H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, * Purpose: generates dataset and attribute of null dataspace in a group *------------------------------------------------------------------------- */ -static void gent_null_space_group(void) +static void +gent_null_space_group(void) { hid_t fid, root, group, dataset, space, attr; - int dset_buf = 10; - int point = 4; + int dset_buf = 10; + int point = 4; - fid = H5Fcreate(FILE85, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE85, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -10891,75 +10955,78 @@ static void gent_null_space_group(void) static void gent_err_attr_dspace(void) { - hid_t fid = H5I_INVALID_HID; /* File identifier */ - hid_t fcpl = H5I_INVALID_HID; /* File access property list */ - hid_t sid = H5I_INVALID_HID; /* Dataspace identifier */ - hid_t aid = H5I_INVALID_HID; /* Attribute identifier */ - hsize_t dims = 2; /* Dimensino size */ - int wdata[2] = {7, 42}; /* The buffer to write */ - int fd = -1; /* The file descriptor */ - char val = 6; /* An invalid version */ + hid_t fid = H5I_INVALID_HID; /* File identifier */ + hid_t fcpl = H5I_INVALID_HID; /* File access property list */ + hid_t sid = H5I_INVALID_HID; /* Dataspace identifier */ + hid_t aid = H5I_INVALID_HID; /* Attribute identifier */ + hsize_t dims = 2; /* Dimensino size */ + int wdata[2] = {7, 42}; /* The buffer to write */ + int fd = -1; /* The file descriptor */ + char val = 6; /* An invalid version */ /* Create an fcpl */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Set up the dataspace message to be shared */ - if(H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) + if (H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) goto error; - if(H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_SDSPACE_FLAG, 1) < 0) + if (H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_SDSPACE_FLAG, 1) < 0) goto error; /* Create the file with the shared message setting */ - if((fid = H5Fcreate(FILE86, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE86, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create the dataspace */ - if((sid = H5Screate_simple(1, &dims, &dims)) < 0) + if ((sid = H5Screate_simple(1, &dims, &dims)) < 0) goto error; /* Create an attribute with shared dataspace */ - if((aid = H5Acreate2(fid, "attribute", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(fid, "attribute", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Awrite(aid, H5T_NATIVE_INT, wdata) < 0) + if (H5Awrite(aid, H5T_NATIVE_INT, wdata) < 0) goto error; /* Closing */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* This section of code will write an illegal version to the "version" field of the shared dataspace message */ - if((fd = HDopen(FILE86, O_RDWR, 0633)) < 0) + if ((fd = HDopen(FILE86, O_RDWR, 0633)) < 0) goto error; /* Offset of the "version" field to modify is as follows: */ /* 1916: offset of the object header containing the attribute message */ /* 32: offset of the attribute message in the object header */ /* 30: offset in the attribute message containing the version of the shared dataspace message */ - if(HDlseek(fd, 1916+32+30, SEEK_SET) < 0) + if (HDlseek(fd, 1916 + 32 + 30, SEEK_SET) < 0) goto error; - if(HDwrite(fd, &val, 1) < 0) + if (HDwrite(fd, &val, 1) < 0) goto error; - if(HDclose(fd) < 0) + if (HDclose(fd) < 0) goto error; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl); H5Aclose(aid); H5Sclose(sid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_err_attr_dspace() */ -int main(void) +int +main(void) { gent_group(); gent_attribute(); @@ -11057,4 +11124,3 @@ int main(void) return 0; } - diff --git a/tools/test/h5format_convert/h5fc_chk_idx.c b/tools/test/h5format_convert/h5fc_chk_idx.c index 2fbbec4..2f54199 100644 --- a/tools/test/h5format_convert/h5fc_chk_idx.c +++ b/tools/test/h5format_convert/h5fc_chk_idx.c @@ -43,16 +43,16 @@ usage(void) int main(int argc, char *argv[]) { - char *fname = NULL; - char *dname = NULL; - hid_t fid = H5I_INVALID_HID; - hid_t did = H5I_INVALID_HID; + char * fname = NULL; + char * dname = NULL; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; H5D_chunk_index_t idx_type; /* h5fc_chk_idx fname dname */ - if(argc != 3) { - usage(); - HDexit(EXIT_FAILURE); + if (argc != 3) { + usage(); + HDexit(EXIT_FAILURE); } /* end if */ /* Duplicate the file name & dataset name */ @@ -60,42 +60,41 @@ main(int argc, char *argv[]) dname = HDstrdup(argv[2]); /* Try opening the file */ - if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) { - HDfprintf(stderr, "h5fc_chk_idx: unable to open the file\n"); - HDexit(EXIT_FAILURE); + if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) { + HDfprintf(stderr, "h5fc_chk_idx: unable to open the file\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Open the dataset */ - if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { - HDfprintf(stderr, "h5fc_chk_idx: unable to open the dataset\n"); - HDexit(EXIT_FAILURE); + if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { + HDfprintf(stderr, "h5fc_chk_idx: unable to open the dataset\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Get the dataset's chunk indexing type */ - if(H5Dget_chunk_index_type(did, &idx_type) < 0) { - HDfprintf(stderr, "h5fc_chk_idx: unable to get chunk index type for the dataset\n"); - HDexit(EXIT_FAILURE); + if (H5Dget_chunk_index_type(did, &idx_type) < 0) { + HDfprintf(stderr, "h5fc_chk_idx: unable to get chunk index type for the dataset\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Close the dataset */ - if(H5Dclose(did) < 0) { - HDfprintf(stderr, "h5fc_chk_idx: unable to close the dataset\n"); - HDexit(EXIT_FAILURE); + if (H5Dclose(did) < 0) { + HDfprintf(stderr, "h5fc_chk_idx: unable to close the dataset\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Close the file */ - if(H5Fclose(fid) < 0) { - HDfprintf(stderr, "h5fc_chk_idx_type: cannot close the file\n"); - HDexit(EXIT_FAILURE); + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "h5fc_chk_idx_type: cannot close the file\n"); + HDexit(EXIT_FAILURE); } /* end if */ /* Return success when the chunk indexing type is version 1 B-tree */ - if(idx_type == H5D_CHUNK_IDX_BTREE) - HDexit(EXIT_SUCCESS); + if (idx_type == H5D_CHUNK_IDX_BTREE) + HDexit(EXIT_SUCCESS); else { - HDfprintf(stderr, "Error: chunk indexing type is %d\n", idx_type); - HDexit(EXIT_FAILURE); + HDfprintf(stderr, "Error: chunk indexing type is %d\n", idx_type); + HDexit(EXIT_FAILURE); } /* end if */ } /* main() */ - diff --git a/tools/test/h5format_convert/h5fc_gentest.c b/tools/test/h5format_convert/h5fc_gentest.c index 1e9e2cf..8e05854 100644 --- a/tools/test/h5format_convert/h5fc_gentest.c +++ b/tools/test/h5format_convert/h5fc_gentest.c @@ -24,45 +24,42 @@ #include "hdf5.h" #include "H5private.h" -#define NON_V3_FILE "h5fc_non_v3.h5" -#define EDGE_V3_FILE "h5fc_edge_v3.h5" -#define ERR_LEVEL_FILE "h5fc_err_level.h5" - -const char *FILENAME[] = { - "h5fc_ext1_i.h5", /* 0 */ - "h5fc_ext1_s.h5", /* 1 */ - "h5fc_ext1_f.h5", /* 2 */ - "h5fc_ext2_is.h5", /* 3 */ - "h5fc_ext2_if.h5", /* 4 */ - "h5fc_ext2_sf.h5", /* 5 */ - "h5fc_ext3_isf.h5", /* 6 */ - "h5fc_ext_none.h5", /* 7 */ - NULL -}; - -#define GROUP "GROUP" - -#define DSET_COMPACT "DSET_COMPACT" -#define DSET_CONTIGUOUS "DSET_CONTIGUOUS" - -#define DSET_EA "DSET_EA" -#define DSET_NDATA_EA "DSET_NDATA_EA" +#define NON_V3_FILE "h5fc_non_v3.h5" +#define EDGE_V3_FILE "h5fc_edge_v3.h5" +#define ERR_LEVEL_FILE "h5fc_err_level.h5" + +const char *FILENAME[] = {"h5fc_ext1_i.h5", /* 0 */ + "h5fc_ext1_s.h5", /* 1 */ + "h5fc_ext1_f.h5", /* 2 */ + "h5fc_ext2_is.h5", /* 3 */ + "h5fc_ext2_if.h5", /* 4 */ + "h5fc_ext2_sf.h5", /* 5 */ + "h5fc_ext3_isf.h5", /* 6 */ + "h5fc_ext_none.h5", /* 7 */ + NULL}; + +#define GROUP "GROUP" + +#define DSET_COMPACT "DSET_COMPACT" +#define DSET_CONTIGUOUS "DSET_CONTIGUOUS" + +#define DSET_EA "DSET_EA" +#define DSET_NDATA_EA "DSET_NDATA_EA" #define DSET_BT2 "DSET_BT2" -#define DSET_NDATA_BT2 "DSET_NDATA_BT2" -#define DSET_FA "DSET_FA" -#define DSET_NDATA_FA "DSET_NDATA_FA" -#define DSET_NONE "DSET_NONE" -#define DSET_NDATA_NONE "DSET_NDATA_NONE" +#define DSET_NDATA_BT2 "DSET_NDATA_BT2" +#define DSET_FA "DSET_FA" +#define DSET_NDATA_FA "DSET_NDATA_FA" +#define DSET_NONE "DSET_NONE" +#define DSET_NDATA_NONE "DSET_NDATA_NONE" -#define DSET_EDGE "DSET_EDGE" -#define DSET_ERR "DSET_ERR" +#define DSET_EDGE "DSET_EDGE" +#define DSET_ERR "DSET_ERR" #define ISTORE_IK 64 #define ISTORE_ERR 1 #define NUM 500 - /* * Function: gen_non() * @@ -77,42 +74,42 @@ const char *FILENAME[] = { static void gen_non(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* file id */ - hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ - hid_t gid = H5I_INVALID_HID; /* group id */ - hid_t sid = H5I_INVALID_HID; /* space id */ - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ - hid_t did1 = -1, did2 = H5I_INVALID_HID; /* dataset id */ - hsize_t dims1[1] = {10}; /* dataset dimension */ - hsize_t dims2[2] = {4, 6}; /* dataset dimension */ - hsize_t max_dims[2]; /* maximum dataset dimension */ - hsize_t c_dims[2] = {2, 3}; /* chunk dimension */ - int i; /* local index variable */ - int buf[24]; /* data buffer */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ + hid_t gid = H5I_INVALID_HID; /* group id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did1 = -1, did2 = H5I_INVALID_HID; /* dataset id */ + hsize_t dims1[1] = {10}; /* dataset dimension */ + hsize_t dims2[2] = {4, 6}; /* dataset dimension */ + hsize_t max_dims[2]; /* maximum dataset dimension */ + hsize_t c_dims[2] = {2, 3}; /* chunk dimension */ + int i; /* local index variable */ + int buf[24]; /* data buffer */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; - if(H5Pset_shared_mesg_nindexes(fcpl, 4) < 0) + if (H5Pset_shared_mesg_nindexes(fcpl, 4) < 0) goto error; - if(H5Pset_istore_k(fcpl, 64) < 0) + if (H5Pset_istore_k(fcpl, 64) < 0) goto error; /* Create an empty file with latest-format */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create a group */ - if((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create data */ - for(i = 0; i < 24; i++) + for (i = 0; i < 24; i++) buf[i] = i; /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, c_dims) < 0) + if (H5Pset_chunk(dcpl, 2, c_dims) < 0) goto error; /* @@ -122,17 +119,17 @@ gen_non(const char *fname) /* Create dataspace */ max_dims[0] = 10; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(fid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; /* @@ -143,35 +140,35 @@ gen_non(const char *fname) max_dims[0] = 10; max_dims[0] = H5S_UNLIMITED; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* Re-open the file with old format */ - if((fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto error; /* Open the group */ - if((gid = H5Gopen2(fid, GROUP, H5P_DEFAULT)) < 0) + if ((gid = H5Gopen2(fid, GROUP, H5P_DEFAULT)) < 0) goto error; /* @@ -179,23 +176,23 @@ gen_non(const char *fname) */ /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, c_dims) < 0) + if (H5Pset_chunk(dcpl, 2, c_dims) < 0) goto error; /* Create dataspace */ max_dims[0] = H5S_UNLIMITED; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Close the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; /* @@ -205,25 +202,25 @@ gen_non(const char *fname) /* Create dataspace */ max_dims[0] = 10; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the dataset */ - if((did2 = H5Dcreate2(gid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; /* @@ -231,61 +228,64 @@ gen_non(const char *fname) */ /* Create dataspace */ - if((sid = H5Screate_simple(1, dims1, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims1, NULL)) < 0) goto error; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_layout(dcpl, H5D_COMPACT) < 0) + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(gid, DSET_COMPACT, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(gid, DSET_COMPACT, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; /* Closing */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; /* * Create a contiguous dataset with (2d with data) in the file */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) + if (H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) goto error; - if((sid = H5Screate_simple(2, dims2, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) goto error; /* Create the dataset */ - if((did2 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Gclose(gid) < 0) - goto error; - if(H5Pclose(fcpl) < 0) - goto error; - if(H5Fclose(fid) < 0) + if (H5Gclose(gid) < 0) + goto error; + if (H5Pclose(fcpl) < 0) + goto error; + if (H5Fclose(fid) < 0) goto error; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did1); @@ -293,7 +293,8 @@ error: H5Gclose(gid); H5Fclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_non() */ @@ -307,75 +308,76 @@ error: static void gen_edge(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* file id */ - hid_t fapl = H5I_INVALID_HID; /* file access property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace id */ - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ - hid_t did = H5I_INVALID_HID; /* dataset id */ - hsize_t dims2[2] = {12, 6}; /* Dataset dimensions */ - hsize_t c_dims[2] = {5, 5}; /* Chunk dimensions */ - float buf[12][6]; /* Buffer for writing data */ - int i, j; /* local index variable */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t fapl = H5I_INVALID_HID; /* file access property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did = H5I_INVALID_HID; /* dataset id */ + hsize_t dims2[2] = {12, 6}; /* Dataset dimensions */ + hsize_t c_dims[2] = {5, 5}; /* Chunk dimensions */ + float buf[12][6]; /* Buffer for writing data */ + int i, j; /* local index variable */ /* Create a new format file */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Set chunk, filter, no-filter-edge-chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, c_dims) < 0) + if (H5Pset_chunk(dcpl, 2, c_dims) < 0) goto error; - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) goto error; - if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + if (H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) goto error; /* Create dataspace */ - if((sid = H5Screate_simple(2, dims2, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) goto error; /* Create the dataset */ - if((did = H5Dcreate2(fid, DSET_EDGE, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_EDGE, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Create data */ - for (i = 0; i< 12; i++) - for (j = 0; j< 6; j++) + for (i = 0; i < 12; i++) + for (j = 0; j < 6; j++) buf[i][j] = 100.0F; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); H5Fclose(fid); H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_edge() */ - /* * Function: gen_err_level() * @@ -395,30 +397,30 @@ error: static void gen_err_level(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* file ID */ - hid_t fapl = H5I_INVALID_HID; /* file access property list */ - hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace id */ - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t did = H5I_INVALID_HID; /* dataset ID */ - hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ - hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ - unsigned char *buf = NULL; /* buffer for data */ - hsize_t dims[2] = {0, 1}; /* dataset dimension sizes */ - hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* dataset maximum dimension sizes */ - hsize_t chunk_dims[2] = {1, 1}; /* chunk dimension sizes */ - int n = 0; /* local index variable */ + hid_t fid = H5I_INVALID_HID; /* file ID */ + hid_t fapl = H5I_INVALID_HID; /* file access property list */ + hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + unsigned char *buf = NULL; /* buffer for data */ + hsize_t dims[2] = {0, 1}; /* dataset dimension sizes */ + hsize_t max_dims[2] = {1, H5S_UNLIMITED}; /* dataset maximum dimension sizes */ + hsize_t chunk_dims[2] = {1, 1}; /* chunk dimension sizes */ + int n = 0; /* local index variable */ /* Create a new format file */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Set 'K' value to 1 in file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; - if(H5Pset_istore_k(fcpl, ISTORE_ERR) < 0) + if (H5Pset_istore_k(fcpl, ISTORE_ERR) < 0) goto error; /* Initialize data buffer */ @@ -426,87 +428,88 @@ gen_err_level(const char *fname) HDmemset(buf, 42, NUM * sizeof(unsigned char)); /* Create the test file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Create a chunked dataset with extensible array chunk index */ - if((sid = H5Screate_simple(2, dims, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims, max_dims)) < 0) goto error; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0) goto error; - if((did = H5Dcreate2(fid, DSET_ERR, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET_ERR, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* Re-open the file */ - if((fid = H5Fopen(fname, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(fname, H5F_ACC_RDWR, fapl)) < 0) goto error; /* Open the dataset */ - if((did = H5Dopen2(fid, DSET_ERR, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(fid, DSET_ERR, H5P_DEFAULT)) < 0) goto error; /* Loop through appending 1 element at a time */ - for(n = 0; n < NUM; n++) { - hsize_t start[2] = {0, 0}; - hsize_t count[2] = {1, 1}; - hsize_t extent[2] = {0, 0}; + for (n = 0; n < NUM; n++) { + hsize_t start[2] = {0, 0}; + hsize_t count[2] = {1, 1}; + hsize_t extent[2] = {0, 0}; + + start[0] = 0; + start[1] = (hsize_t)n; + extent[0] = 1; + extent[1] = (hsize_t)(n + 1); + + /* Set current dimension sizes for the dataset */ + if (H5Dset_extent(did, extent) < 0) + goto error; - start[0] = 0; - start[1] = (hsize_t)n; - extent[0] = 1; - extent[1] = (hsize_t)(n + 1); + /* Set up memory dataspace */ + if ((msid = H5Screate_simple(2, count, NULL)) < 0) + goto error; - /* Set current dimension sizes for the dataset */ - if(H5Dset_extent(did, extent) < 0) - goto error; + /* Get file dataspace */ + if ((fsid = H5Dget_space(did)) < 0) + goto error; - /* Set up memory dataspace */ - if((msid = H5Screate_simple(2, count, NULL)) < 0) - goto error; + if ((H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, count, NULL)) < 0) + goto error; - /* Get file dataspace */ - if((fsid = H5Dget_space(did)) < 0) - goto error; + /* Write to the dataset */ + if (H5Dwrite(did, H5T_NATIVE_UCHAR, msid, fsid, H5P_DEFAULT, buf) < 0) + goto error; - if((H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, count, NULL)) < 0) - goto error; + if (H5Sclose(fsid) < 0) + goto error; + if (H5Sclose(msid) < 0) + goto error; + } - /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_UCHAR, msid, fsid, H5P_DEFAULT, buf) < 0) + /* Closing */ + if (H5Dclose(did) < 0) goto error; - - if(H5Sclose(fsid) < 0) + if (H5Fclose(fid) < 0) goto error; - if(H5Sclose(msid) < 0) + if (H5Pclose(fapl) < 0) goto error; - } - - /* Closing */ - if(H5Dclose(did) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; - if(H5Pclose(fapl) < 0) - goto error; error: - if(buf) + if (buf) free(buf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); @@ -515,7 +518,8 @@ error: H5Fclose(fid); H5Pclose(fapl); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_err_level() */ @@ -534,26 +538,26 @@ error: static void gen_ext(const char *fname, unsigned new_format, unsigned what) { - hid_t fid = H5I_INVALID_HID; /* file id */ - hid_t fapl = H5I_INVALID_HID; /* file access property list */ - hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ - hid_t gid = H5I_INVALID_HID; /* group id */ - hid_t sid = H5I_INVALID_HID; /* space id */ - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ - hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* dataset id */ - hsize_t dims1[1] = {10}; /* dataset dimension */ - hsize_t dims2[2] = {4, 6}; /* dataset dimension */ - hsize_t max_dims[2]; /* maximum dataset dimension */ - hsize_t c_dims[2] = {2, 3}; /* chunk dimension */ - int i; /* local index variable */ - int buf[24]; /* data buffer */ - - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - - if(new_format) { + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t fapl = H5I_INVALID_HID; /* file access property list */ + hid_t fcpl = H5I_INVALID_HID; /* file creation property list */ + hid_t gid = H5I_INVALID_HID; /* group id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* dataset id */ + hsize_t dims1[1] = {10}; /* dataset dimension */ + hsize_t dims2[2] = {4, 6}; /* dataset dimension */ + hsize_t max_dims[2]; /* maximum dataset dimension */ + hsize_t c_dims[2] = {2, 3}; /* chunk dimension */ + int i; /* local index variable */ + int buf[24]; /* data buffer */ + + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + if (new_format) { /* Create a new format file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; } /* end if */ @@ -561,68 +565,68 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) fcpl = H5Pcreate(H5P_FILE_CREATE); /* Generate messages that might be placed in superblock extension */ - switch(what) { - case 0: - H5Pset_istore_k(fcpl, ISTORE_IK); - break; - case 1: - H5Pset_shared_mesg_nindexes(fcpl, 4); - break; - case 2: - H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); - break; - case 3: - H5Pset_istore_k(fcpl, ISTORE_IK); - H5Pset_shared_mesg_nindexes(fcpl, 4); - break; - case 4: - H5Pset_istore_k(fcpl, ISTORE_IK); - H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1); - break; - case 5: - H5Pset_shared_mesg_nindexes(fcpl, 4); - H5Pset_file_space_page_size(fcpl, (hsize_t)512); - break; - case 6: - H5Pset_istore_k(fcpl, ISTORE_IK); - H5Pset_shared_mesg_nindexes(fcpl, 4); - H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); - break; - default: - break; + switch (what) { + case 0: + H5Pset_istore_k(fcpl, ISTORE_IK); + break; + case 1: + H5Pset_shared_mesg_nindexes(fcpl, 4); + break; + case 2: + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)1); + break; + case 3: + H5Pset_istore_k(fcpl, ISTORE_IK); + H5Pset_shared_mesg_nindexes(fcpl, 4); + break; + case 4: + H5Pset_istore_k(fcpl, ISTORE_IK); + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1); + break; + case 5: + H5Pset_shared_mesg_nindexes(fcpl, 4); + H5Pset_file_space_page_size(fcpl, (hsize_t)512); + break; + case 6: + H5Pset_istore_k(fcpl, ISTORE_IK); + H5Pset_shared_mesg_nindexes(fcpl, 4); + H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1); + break; + default: + break; } /* Create the file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Create a group */ - if((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, c_dims) < 0) + if (H5Pset_chunk(dcpl, 2, c_dims) < 0) goto error; - /* * Create a contiguous dataset */ /* Create dataspace */ - if((sid = H5Screate_simple(1, dims1, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims1, NULL)) < 0) goto error; /* Create the dataset */ - if((did1 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_CONTIGUOUS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; /* @@ -633,33 +637,32 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) /* Create dataspace */ max_dims[0] = 10; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the 2 datasets */ - if((did1 = H5Dcreate2(gid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(gid, DSET_NDATA_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((did2 = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Create data */ - for(i = 0; i < 24; i++) + for (i = 0; i < 24; i++) buf[i] = i; /* Write to one dataset */ - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; - /* * Create 2 chunked datasets with version 2 B-tree chunk indexing type * (one with data; one without data) @@ -669,26 +672,26 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) max_dims[0] = 10; max_dims[0] = H5S_UNLIMITED; max_dims[1] = H5S_UNLIMITED; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the 2 datasets */ - if((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_NDATA_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((did2 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, DSET_BT2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to one dataset */ - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; /* @@ -699,70 +702,70 @@ gen_ext(const char *fname, unsigned new_format, unsigned what) /* Create dataspace */ max_dims[0] = 20; max_dims[1] = 10; - if((sid = H5Screate_simple(2, dims2, max_dims)) < 0) + if ((sid = H5Screate_simple(2, dims2, max_dims)) < 0) goto error; /* Create the datasets */ - if((did1 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((did2 = H5Dcreate2(gid, DSET_NDATA_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, DSET_NDATA_FA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; - /* * Create 2 chunked datasets with implicit chunk indexing type * (one with data; one without data) */ /* Create dataspace */ - if((sid = H5Screate_simple(2, dims2, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) goto error; /* Set early allocation */ - if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto error; /* Create the 2 datasets */ - if((did1 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if((did2 = H5Dcreate2(gid, DSET_NDATA_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(gid, DSET_NDATA_NONE, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to one dataset */ - if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Closing */ - if(H5Dclose(did1) < 0) + if (H5Dclose(did1) < 0) goto error; - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did1); @@ -771,7 +774,8 @@ error: H5Fclose(fid); H5Pclose(fapl); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; } /* end gen_ext() */ @@ -790,19 +794,18 @@ main(void) gen_err_level(ERR_LEVEL_FILE); /* Generate old/new format file with/without messages in the superblock extension */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - for(i = 0; i < 8; i++) { + for (new_format = FALSE; new_format <= TRUE; new_format++) { + for (i = 0; i < 8; i++) { char filename[50]; HDmemset(filename, 0, sizeof(filename)); - if(!new_format) + if (!new_format) HDstrcat(filename, "old_"); HDstrcat(filename, FILENAME[i]); gen_ext(filename, new_format, i); } /* end for */ - } /* end for */ + } /* end for */ return 0; } /* end main */ - diff --git a/tools/test/h5import/h5importtest.c b/tools/test/h5import/h5importtest.c index 580530a..6e41b7f 100644 --- a/tools/test/h5import/h5importtest.c +++ b/tools/test/h5import/h5importtest.c @@ -32,40 +32,40 @@ int main(void) { - int nrow = 3, ncol = 4, npln = 5; - int i, j, k; - FILE *sp; - char machine_order[3] = {0, 0, 0}; + int nrow = 3, ncol = 4, npln = 5; + int i, j, k; + FILE *sp; + char machine_order[3] = {0, 0, 0}; - float row4[3], col4[4], pln4[5]; - float rowo4 = 11.0F, colo4 = 21.0F, plno4 = 51.0F; - float rowi4 = 1.0F, coli4 = 2.0F, plni4 = 5.0F; + float row4[3], col4[4], pln4[5]; + float rowo4 = 11.0F, colo4 = 21.0F, plno4 = 51.0F; + float rowi4 = 1.0F, coli4 = 2.0F, plni4 = 5.0F; - int b32i3[5][3][4]; - int row4i[3], col4i[4], pln4i[5]; - int rowo4i = 11 , colo4i = 21 , plno4i = 51 ; - int rowi4i = 1 , coli4i = 2 , plni4i = 5 ; + int b32i3[5][3][4]; + int row4i[3], col4i[4], pln4i[5]; + int rowo4i = 11, colo4i = 21, plno4i = 51; + int rowi4i = 1, coli4i = 2, plni4i = 5; #ifdef H5_SIZEOF_LONG_LONG long long row4i64[3], col4i64[4], pln4i64[5]; - long long rowo4i64 = (long long)11 , colo4i64 = (long long)21 , plno4i64 = (long long)51 ; - long long rowi4i64 = (long long)1 , coli4i64 = (long long)2 , plni4i64 = (long long)5 ; + long long rowo4i64 = (long long)11, colo4i64 = (long long)21, plno4i64 = (long long)51; + long long rowi4i64 = (long long)1, coli4i64 = (long long)2, plni4i64 = (long long)5; #endif - short b16i3[5][3][4]; - short row4i16[3], col4i16[4], pln4i16[5]; - short rowo4i16 = (short)11 , colo4i16 = (short)21 , plno4i16 = (short)51 ; - short rowi4i16 = (short)1 , coli4i16 = (short)2 , plni4i16 = (short)5 ; + short b16i3[5][3][4]; + short row4i16[3], col4i16[4], pln4i16[5]; + short rowo4i16 = (short)11, colo4i16 = (short)21, plno4i16 = (short)51; + short rowi4i16 = (short)1, coli4i16 = (short)2, plni4i16 = (short)5; - char b8i3[5][3][4]; - char row4i8[3], col4i8[4], pln4i8[5]; - char rowo4i8 = (char)11 , colo4i8 = (char)21 , plno4i8 = (char)51 ; - char rowi4i8 = (char)1 , coli4i8 = (char)2 , plni4i8 = (char)5 ; + char b8i3[5][3][4]; + char row4i8[3], col4i8[4], pln4i8[5]; + char rowo4i8 = (char)11, colo4i8 = (char)21, plno4i8 = (char)51; + char rowi4i8 = (char)1, coli4i8 = (char)2, plni4i8 = (char)5; - double b64r3[5][3][4]; - double row8[3], col8[4], pln8[5]; - double rowo8 = 11.0F, colo8 = 21.0F, plno8 = 51.0F; - double rowi8 = 1.0F, coli8 = 2.0F, plni8 = 5.0F; + double b64r3[5][3][4]; + double row8[3], col8[4], pln8[5]; + double rowo8 = 11.0F, colo8 = 21.0F, plno8 = 51.0F; + double rowi8 = 1.0F, coli8 = 2.0F, plni8 = 5.0F; /* Initialize machine endian */ volatile uint32_t ibyte = 0x01234567; @@ -76,19 +76,18 @@ main(void) HDstrcpy(machine_order, "BE"); /* - * initialize the row, column, and plane vectors - * - * row values start at 11 and increment by 1 => 11, 12, 13 - * column values start at 21 and increment by 2 => 21, 23, 25, 27 - * plane values start at 51 and increment by 5 => 51, 56, 61, 66, 71 - */ - + * initialize the row, column, and plane vectors + * + * row values start at 11 and increment by 1 => 11, 12, 13 + * column values start at 21 and increment by 2 => 21, 23, 25, 27 + * plane values start at 51 and increment by 5 => 51, 56, 61, 66, 71 + */ /* - * build array elements - rank 2 - * - * element value = sum of row value and col values - */ + * build array elements - rank 2 + * + * element value = sum of row value and col values + */ row4[0] = rowo4; col4[0] = colo4; @@ -116,46 +115,43 @@ main(void) col4i8[0] = colo4i8; pln4i8[0] = plno4i8; - for (i = 1; i < nrow; i++) - { - row4[i] = row4[i - 1] + rowi4; - row8[i] = row8[i - 1] + rowi8; + for (i = 1; i < nrow; i++) { + row4[i] = row4[i - 1] + rowi4; + row8[i] = row8[i - 1] + rowi8; row4i[i] = row4i[i - 1] + rowi4i; #ifdef H5_SIZEOF_LONG_LONG row4i64[i] = row4i64[i - 1] + rowi4i64; #endif row4i16[i] = (short)(row4i16[i - 1] + rowi4i16); - row4i8[i] = (char)(row4i8[i - 1] + rowi4i8); + row4i8[i] = (char)(row4i8[i - 1] + rowi4i8); } - for (j = 1; j < ncol; j++) - { - col4[j] = col4[j - 1] + coli4; - col8[j] = col8[j - 1] + coli8; + for (j = 1; j < ncol; j++) { + col4[j] = col4[j - 1] + coli4; + col8[j] = col8[j - 1] + coli8; col4i[j] = col4i[j - 1] + coli4i; #ifdef H5_SIZEOF_LONG_LONG col4i64[j] = col4i64[j - 1] + coli4i64; #endif col4i16[j] = (short)(col4i16[j - 1] + coli4i16); - col4i8[j] = (char)(col4i8[j - 1] + coli4i8); + col4i8[j] = (char)(col4i8[j - 1] + coli4i8); } - for (k = 1; k < npln; k++) - { - pln4[k] = pln4[k - 1] + plni4; - pln8[k] = pln8[k - 1] + plni8; + for (k = 1; k < npln; k++) { + pln4[k] = pln4[k - 1] + plni4; + pln8[k] = pln8[k - 1] + plni8; pln4i[k] = pln4i[k - 1] + plni4i; #ifdef H5_SIZEOF_LONG_LONG pln4i64[k] = pln4i64[k - 1] + plni4i64; #endif pln4i16[k] = (short)(pln4i16[k - 1] + plni4i16); - pln4i8[k] = (char)(pln4i8[k - 1] + plni4i8); + pln4i8[k] = (char)(pln4i8[k - 1] + plni4i8); } /* - * build array elements - rank 3 - * - * element value = sum of row value, col, and plane values - */ + * build array elements - rank 3 + * + * element value = sum of row value, col, and plane values + */ for (i = 0; i < nrow; i++) for (j = 0; j < ncol; j++) @@ -163,296 +159,267 @@ main(void) b64r3[k][i][j] = row8[i] + col8[j] + pln8[k]; b32i3[k][i][j] = row4i[i] + col4i[j] + pln4i[k]; b16i3[k][i][j] = (short)(row4i16[i] + col4i16[j] + pln4i16[k]); - b8i3[k][i][j] = (char)(row4i8[i] + col4i8[j] + pln4i8[k]); + b8i3[k][i][j] = (char)(row4i8[i] + col4i8[j] + pln4i8[k]); } - - #ifndef UNICOS #ifdef REBUILDTEXTFILES - /*------------------------------------------------------------------------- - * TOOLTEST txtin8.txt -c $srcdir/testfiles/txtin8.conf -o txtin8.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST txtin8.txt -c $srcdir/testfiles/txtin8.conf -o txtin8.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("txtin8.txt", "w"); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - (void) HDfprintf(sp, "%10u", b8i3[k][i][j]); - (void) HDfprintf(sp, "\n"); - } + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) + (void)HDfprintf(sp, "%10u", b8i3[k][i][j]); + (void)HDfprintf(sp, "\n"); + } } - (void) HDfclose(sp); + (void)HDfclose(sp); - /*------------------------------------------------------------------------- - * TOOLTEST txtin16.txt -c $srcdir/testfiles/txtin16.conf -o txtin16.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST txtin16.txt -c $srcdir/testfiles/txtin16.conf -o txtin16.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("txtin16.txt", "w"); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - (void) HDfprintf(sp, "%10u", b16i3[k][i][j]); - (void) HDfprintf(sp, "\n"); - } + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) + (void)HDfprintf(sp, "%10u", b16i3[k][i][j]); + (void)HDfprintf(sp, "\n"); + } } - (void) HDfclose(sp); + (void)HDfclose(sp); - /*------------------------------------------------------------------------- - * TOOLTEST txtin32.txt -c $srcdir/testfiles/textin32.conf -o textin32.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST txtin32.txt -c $srcdir/testfiles/textin32.conf -o textin32.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("txtin32.txt", "w"); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { for (j = 0; j < ncol; j++) - (void) HDfprintf(sp, "%10d", b32i3[k][i][j]); - (void) HDfprintf(sp, "\n"); + (void)HDfprintf(sp, "%10d", b32i3[k][i][j]); + (void)HDfprintf(sp, "\n"); } } - (void) HDfclose(sp); + (void)HDfclose(sp); #endif - /*------------------------------------------------------------------------- - * TOOLTEST binin32.bin -c binin32.conf -o binin32.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST binin32.bin -c binin32.conf -o binin32.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binin32.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b32i3[k][i][j], sizeof(int), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b32i3[k][i][j], sizeof(int), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binin32.conf", "w"); - (void) HDfprintf(sp, "PATH /int/bin/32-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS IN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 32\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER BE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 1 2 1\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binuin32.bin -c binuin32.conf -o binuin32.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /int/bin/32-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS IN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 32\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER BE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 1 2 1\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binuin32.bin -c binuin32.conf -o binuin32.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binuin32.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b32i3[k][i][j], sizeof(unsigned int), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b32i3[k][i][j], sizeof(unsigned int), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binuin32.conf", "w"); - (void) HDfprintf(sp, "PATH /int/buin/32-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS UIN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 32\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binin16.bin -c binin16.conf -o binin16.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /int/buin/32-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS UIN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 32\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binin16.bin -c binin16.conf -o binin16.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binin16.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b16i3[k][i][j], sizeof(short), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b16i3[k][i][j], sizeof(short), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binin16.conf", "w"); - (void) HDfprintf(sp, "PATH /int/bin/16-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS IN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 16\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 2 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); - (void) HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 8\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binuin16.bin -c binuin16.conf -o binuin16.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /int/bin/16-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS IN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 16\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 2 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); + (void)HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 8\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binuin16.bin -c binuin16.conf -o binuin16.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binuin16.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b16i3[k][i][j], sizeof(unsigned short), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b16i3[k][i][j], sizeof(unsigned short), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binuin16.conf", "w"); - (void) HDfprintf(sp, "PATH /int/buin/16-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS UIN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 16\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER BE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 2 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); - (void) HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 8\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binin8.bin -c binin8.conf -o binin8.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /int/buin/16-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS UIN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 16\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER BE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 2 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); + (void)HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 8\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binin8.bin -c binin8.conf -o binin8.h5 + *------------------------------------------------------------------------- + */ sp = HDfopen("binin8.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b8i3[k][i][j], sizeof(char), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b8i3[k][i][j], sizeof(char), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binin8.conf", "w"); - (void) HDfprintf(sp, "PATH /int/bin/8-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS IN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 8\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-CLASS IN\n"); - (void) HDfprintf(sp, "OUTPUT-SIZE 16\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); - (void) HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 -1\n"); - (void) HDfprintf(sp, "COMPRESSION-PARAM 3\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); + (void)HDfprintf(sp, "PATH /int/bin/8-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS IN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 8\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-CLASS IN\n"); + (void)HDfprintf(sp, "OUTPUT-SIZE 16\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); + (void)HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 -1 -1\n"); + (void)HDfprintf(sp, "COMPRESSION-PARAM 3\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); #endif /* UNICOS */ - /*------------------------------------------------------------------------- - * TOOLTEST binfp64.bin -c binfp64.conf -o binfp64.h5 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * TOOLTEST binfp64.bin -c binfp64.conf -o binfp64.h5 + *------------------------------------------------------------------------- + */ - /* - * binary 64-bit file - rank 2 & 3 - */ + /* + * binary 64-bit file - rank 2 & 3 + */ sp = HDfopen("binfp64.bin", OPEN_FLAGS); - for (k = 0; k < npln; k++) - { - for (i = 0; i < nrow; i++) - { - for (j = 0; j < ncol; j++) - { - (void) HDfwrite((char *) &b64r3[k][i][j], sizeof(double), 1, sp); + for (k = 0; k < npln; k++) { + for (i = 0; i < nrow; i++) { + for (j = 0; j < ncol; j++) { + (void)HDfwrite((char *)&b64r3[k][i][j], sizeof(double), 1, sp); } } } - (void) HDfclose(sp); + (void)HDfclose(sp); sp = HDfopen("binfp64.conf", "w"); - (void) HDfprintf(sp, "PATH /fp/bin/64-bit\n"); - (void) HDfprintf(sp, "INPUT-CLASS FP\n"); - (void) HDfprintf(sp, "INPUT-SIZE 64\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 3\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE IEEE\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); - (void) HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); - (void) HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 6 7\n"); - (void) HDfprintf(sp, "COMPRESSION-PARAM 8\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - - /*------------------------------------------------------------------------- - * TOOLTEST binin8w.bin -c binin8w.conf -o binin8w.h5 - *------------------------------------------------------------------------- - */ + (void)HDfprintf(sp, "PATH /fp/bin/64-bit\n"); + (void)HDfprintf(sp, "INPUT-CLASS FP\n"); + (void)HDfprintf(sp, "INPUT-SIZE 64\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 3\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE IEEE\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 5 3 4\n"); + (void)HDfprintf(sp, "CHUNKED-DIMENSION-SIZES 2 2 2\n"); + (void)HDfprintf(sp, "MAXIMUM-DIMENSIONS -1 6 7\n"); + (void)HDfprintf(sp, "COMPRESSION-PARAM 8\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); + + /*------------------------------------------------------------------------- + * TOOLTEST binin8w.bin -c binin8w.conf -o binin8w.h5 + *------------------------------------------------------------------------- + */ { /* test CR+LF (13,10) and EOF (26) in windows */ - char bin8w[4] = {13,10,26,0}; + char bin8w[4] = {13, 10, 26, 0}; sp = HDfopen("binin8w.bin", OPEN_FLAGS); - for (i = 0; i < 4; i++) - { + for (i = 0; i < 4; i++) { char c = bin8w[i]; - if ( HDfwrite( &c, sizeof(char), 1, sp) != 1 ) + if (HDfwrite(&c, sizeof(char), 1, sp) != 1) HDprintf("error writing file\n"); } HDfclose(sp); sp = HDfopen("binin8w.conf", "w"); - (void) HDfprintf(sp, "INPUT-CLASS IN\n"); - (void) HDfprintf(sp, "INPUT-SIZE 8\n"); - (void) HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); - (void) HDfprintf(sp, "RANK 1\n"); - (void) HDfprintf(sp, "OUTPUT-CLASS IN\n"); - (void) HDfprintf(sp, "OUTPUT-SIZE 8\n"); - (void) HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); - (void) HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); - (void) HDfprintf(sp, "DIMENSION-SIZES 4\n"); - (void) HDfprintf(sp, "\n"); - (void) HDfclose(sp); - + (void)HDfprintf(sp, "INPUT-CLASS IN\n"); + (void)HDfprintf(sp, "INPUT-SIZE 8\n"); + (void)HDfprintf(sp, "INPUT-BYTE-ORDER %s\n", machine_order); + (void)HDfprintf(sp, "RANK 1\n"); + (void)HDfprintf(sp, "OUTPUT-CLASS IN\n"); + (void)HDfprintf(sp, "OUTPUT-SIZE 8\n"); + (void)HDfprintf(sp, "OUTPUT-ARCHITECTURE STD\n"); + (void)HDfprintf(sp, "OUTPUT-BYTE-ORDER LE\n"); + (void)HDfprintf(sp, "DIMENSION-SIZES 4\n"); + (void)HDfprintf(sp, "\n"); + (void)HDfclose(sp); } return (EXIT_SUCCESS); } - diff --git a/tools/test/h5jam/getub.c b/tools/test/h5jam/getub.c index f496a7a..9e9cd4d 100644 --- a/tools/test/h5jam/getub.c +++ b/tools/test/h5jam/getub.c @@ -21,11 +21,9 @@ void parse_command_line(int argc, const char *argv[]); #define PROGRAM_NAME "getub" char *nbytes = NULL; -static const char *s_opts = "c:"; /* add more later ? */ -static struct long_options l_opts[] = { - {"c", require_arg, 'c'}, /* input file */ - {NULL, 0, '\0'} -}; +static const char * s_opts = "c:"; /* add more later ? */ +static struct long_options l_opts[] = {{"c", require_arg, 'c'}, /* input file */ + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -36,7 +34,7 @@ static struct long_options l_opts[] = { *------------------------------------------------------------------------- */ static void -usage (const char *prog) +usage(const char *prog) { HDfflush(stdout); HDfprintf(stdout, "usage: %s -c nb file] \n", prog); @@ -59,33 +57,33 @@ parse_command_line(int argc, const char *argv[]) int opt; /* parse command line options */ - while((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) { - switch((char) opt) { - case 'c': - nbytes = HDstrdup(opt_arg); - break; - case '?': - default: - usage(h5tools_getprogname()); - HDexit(EXIT_FAILURE); + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { + case 'c': + nbytes = HDstrdup(opt_arg); + break; + case '?': + default: + usage(h5tools_getprogname()); + HDexit(EXIT_FAILURE); } /* end switch */ - } /* end while */ + } /* end while */ - if(argc <= opt_ind) { - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - HDexit(EXIT_FAILURE); + if (argc <= opt_ind) { + error_msg("missing file name\n"); + usage(h5tools_getprogname()); + HDexit(EXIT_FAILURE); } /* end if */ } /* end parse_command_line() */ int main(int argc, const char *argv[]) { - int fd = H5I_INVALID_HID; + int fd = H5I_INVALID_HID; unsigned size; - char *filename = NULL; - long res; - char *buf = NULL; + char * filename = NULL; + long res; + char * buf = NULL; h5tools_setprogname(PROGRAM_NAME); h5tools_setstatus(EXIT_SUCCESS); @@ -95,14 +93,14 @@ main(int argc, const char *argv[]) parse_command_line(argc, argv); - if(NULL == nbytes) { + if (NULL == nbytes) { /* missing arg */ error_msg("missing size\n"); usage(h5tools_getprogname()); goto error; } /* end if */ - if(argc <= (opt_ind)) { + if (argc <= (opt_ind)) { error_msg("missing file name\n"); usage(h5tools_getprogname()); goto error; @@ -111,30 +109,30 @@ main(int argc, const char *argv[]) filename = HDstrdup(argv[opt_ind]); size = 0; - if(EOF == (res = sscanf(nbytes, "%u", &size))) { - /* fail */ - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - goto error; + if (EOF == (res = sscanf(nbytes, "%u", &size))) { + /* fail */ + error_msg("missing file name\n"); + usage(h5tools_getprogname()); + goto error; } /* end if */ - if((fd = HDopen(filename, O_RDONLY, 0)) < 0) { + if ((fd = HDopen(filename, O_RDONLY, 0)) < 0) { error_msg("can't open file %s\n", filename); goto error; } /* end if */ - if(NULL == (buf = (char *)HDmalloc((unsigned)(size + 1)))) { + if (NULL == (buf = (char *)HDmalloc((unsigned)(size + 1)))) { error_msg("can't allocate buffer \n"); goto error; } /* end if */ res = HDread(fd, buf, (unsigned)size); - if(res < (long)size) { + if (res < (long)size) { error_msg("Bad read \n"); goto error; } /* end if */ - if(HDwrite(1, buf, (unsigned)size) < 0) { + if (HDwrite(1, buf, (unsigned)size) < 0) { error_msg("Bad write \n"); goto error; } /* end if */ @@ -146,10 +144,9 @@ main(int argc, const char *argv[]) return EXIT_SUCCESS; error: - if(buf) + if (buf) HDfree(buf); - if(fd >= 0) + if (fd >= 0) HDclose(fd); return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/h5jam/h5jamgentest.c b/tools/test/h5jam/h5jamgentest.c index 56b4ead..aac226e 100644 --- a/tools/test/h5jam/h5jamgentest.c +++ b/tools/test/h5jam/h5jamgentest.c @@ -1,4 +1,4 @@ - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * @@ -64,31 +64,24 @@ char pattern[11] = "abcdefghij"; *------------------------------------------------------------------------- */ - #define BUF_SIZE 1024 /* Element selection information */ -typedef enum{ - RED, - GREEN, - BLUE, - WHITE, - BLACK -} enumtype; +typedef enum { RED, GREEN, BLUE, WHITE, BLACK } enumtype; /* Compound datatype */ typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; - /* A UD link traversal function. Shouldn't actually be called. */ -static hid_t UD_traverse(const char H5_ATTR_UNUSED * link_name, hid_t H5_ATTR_UNUSED cur_group, - const void H5_ATTR_UNUSED * udata, size_t H5_ATTR_UNUSED udata_size, hid_t H5_ATTR_UNUSED lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id) +static hid_t +UD_traverse(const char H5_ATTR_UNUSED *link_name, hid_t H5_ATTR_UNUSED cur_group, + const void H5_ATTR_UNUSED *udata, size_t H5_ATTR_UNUSED udata_size, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id) { return -1; } @@ -106,8 +99,6 @@ const H5L_class_t UD_link_class[1] = {{ NULL /* Query callback */ }}; - - /* gent_ub with no ub, identical to gent_all from h5dumpgentest.c @@ -126,184 +117,188 @@ g2 : dset2.1 dset2.2 udlink */ static void -gent_ub(const char * filename, size_t ub_size, size_t ub_fill) +gent_ub(const char *filename, size_t ub_size, size_t ub_fill) { - hid_t fid, group, attr, dataset, space; - hid_t create_plist; + hid_t fid, group, attr, dataset, space; + hid_t create_plist; hsize_t dims[2]; - int data[2][2], dset1[10][10], dset2[20]; - char buf[BUF_SIZE]; - int i, j; - size_t u; - float dset2_1[10], dset2_2[3][5]; - int fd; - char *bp; - - if(ub_size > 0) - { - create_plist = H5Pcreate(H5P_FILE_CREATE); - H5Pset_userblock(create_plist, (hsize_t)ub_size); - fid = H5Fcreate(filename, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT); - } - else - { - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - } - - /* create groups */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* root attributes */ - group = H5Gopen2(fid, "/", H5P_DEFAULT); - - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - HDsprintf(buf, "abcdefghi"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - dims[0] = 2; dims[1] = 2; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; - H5Awrite(attr, H5T_NATIVE_INT, data); - H5Sclose(space); - H5Aclose(attr); - - H5Gclose(group); - - group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT); - - /* dset1.1.1 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - dset1[i][j] = j*i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - H5Sclose(space); - - /* attributes of dset1.1.1 */ - dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - HDsprintf(buf, "1st attribute of dset1.1.1"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - HDsprintf(buf, "2nd attribute of dset1.1.1"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - H5Dclose(dataset); - - /* dset1.1.2 */ - dims[0] = 20; - space = H5Screate_simple(1, dims, NULL); - dataset = H5Dcreate2(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 20; i++) - dset2[i] = i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - H5Sclose(space); - H5Dclose(dataset); - - H5Gclose(group); - - /* external link */ - H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT); - - /* soft link */ - group = H5Gopen2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT); - H5Lcreate_soft("somevalue", group, "slink", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gopen2(fid, "/g2", H5P_DEFAULT); - - /* dset2.1 */ - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 10; i++) - dset2_1[i] = (float)((float)i * 0.1F + 1.0F); - H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1); - H5Sclose(space); - H5Dclose(dataset); - - /* dset2.2 */ - dims[0] = 3; dims[1] = 5; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 3; i++) - for (j = 0; j < 5; j++) + int data[2][2], dset1[10][10], dset2[20]; + char buf[BUF_SIZE]; + int i, j; + size_t u; + float dset2_1[10], dset2_2[3][5]; + int fd; + char * bp; + + if (ub_size > 0) { + create_plist = H5Pcreate(H5P_FILE_CREATE); + H5Pset_userblock(create_plist, (hsize_t)ub_size); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT); + } + else { + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + } + + /* create groups */ + group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(group); + + group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(group); + + group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(group); + + group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(group); + + group = H5Gcreate2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(group); + + /* root attributes */ + group = H5Gopen2(fid, "/", H5P_DEFAULT); + + dims[0] = 10; + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + HDsprintf(buf, "abcdefghi"); + H5Awrite(attr, H5T_NATIVE_SCHAR, buf); + H5Sclose(space); + H5Aclose(attr); + + dims[0] = 2; + dims[1] = 2; + space = H5Screate_simple(2, dims, NULL); + attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); + data[0][0] = 0; + data[0][1] = 1; + data[1][0] = 2; + data[1][1] = 3; + H5Awrite(attr, H5T_NATIVE_INT, data); + H5Sclose(space); + H5Aclose(attr); + + H5Gclose(group); + + group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT); + + /* dset1.1.1 */ + dims[0] = 10; + dims[1] = 10; + space = H5Screate_simple(2, dims, NULL); + dataset = H5Dcreate2(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + dset1[i][j] = j * i; + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); + H5Sclose(space); + + /* attributes of dset1.1.1 */ + dims[0] = 27; + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + HDsprintf(buf, "1st attribute of dset1.1.1"); + H5Awrite(attr, H5T_NATIVE_SCHAR, buf); + H5Sclose(space); + H5Aclose(attr); + + dims[0] = 27; + space = H5Screate_simple(1, dims, NULL); + attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); + HDsprintf(buf, "2nd attribute of dset1.1.1"); + H5Awrite(attr, H5T_NATIVE_SCHAR, buf); + H5Sclose(space); + H5Aclose(attr); + + H5Dclose(dataset); + + /* dset1.1.2 */ + dims[0] = 20; + space = H5Screate_simple(1, dims, NULL); + dataset = H5Dcreate2(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + for (i = 0; i < 20; i++) + dset2[i] = i; + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); + H5Sclose(space); + H5Dclose(dataset); + + H5Gclose(group); + + /* external link */ + H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT); + + /* soft link */ + group = H5Gopen2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT); + H5Lcreate_soft("somevalue", group, "slink", H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(group); + + group = H5Gopen2(fid, "/g2", H5P_DEFAULT); + + /* dset2.1 */ + dims[0] = 10; + space = H5Screate_simple(1, dims, NULL); + dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + for (i = 0; i < 10; i++) + dset2_1[i] = (float)((float)i * 0.1F + 1.0F); + H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1); + H5Sclose(space); + H5Dclose(dataset); + + /* dset2.2 */ + dims[0] = 3; + dims[1] = 5; + space = H5Screate_simple(2, dims, NULL); + dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + for (i = 0; i < 3; i++) + for (j = 0; j < 5; j++) dset2_2[i][j] = (float)(((float)i + 1.0F) * (float)j * 0.1F); - H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2); - H5Sclose(space); - H5Dclose(dataset); + H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2); + H5Sclose(space); + H5Dclose(dataset); - H5Gclose(group); + H5Gclose(group); - /* user-defined link */ - H5Lregister(UD_link_class); - H5Lcreate_ud(fid, "/g2/udlink", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); + /* user-defined link */ + H5Lregister(UD_link_class); + H5Lcreate_ud(fid, "/g2/udlink", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); - H5Fclose(fid); + H5Fclose(fid); - /* If a user block is being used, write to it here */ - if(ub_size > 0) { - HDassert(ub_size <= BUF_SIZE); + /* If a user block is being used, write to it here */ + if (ub_size > 0) { + HDassert(ub_size <= BUF_SIZE); - fd = HDopen(filename, O_RDWR); - HDassert(fd >= 0); + fd = HDopen(filename, O_RDWR); + HDassert(fd >= 0); - /* fill buf with pattern */ - HDmemset(buf, '\0', ub_size); - bp = buf; - for (u = 0; u < ub_fill; u++) - *bp++ = pattern[u % 10]; + /* fill buf with pattern */ + HDmemset(buf, '\0', ub_size); + bp = buf; + for (u = 0; u < ub_fill; u++) + *bp++ = pattern[u % 10]; - HDwrite(fd, buf, ub_size); + HDwrite(fd, buf, ub_size); - HDclose(fd); - } + HDclose(fd); + } } static void create_textfile(const char *name, size_t size) { - char *buf; - int fd; + char * buf; + int fd; size_t i; - char *bp; + char * bp; - fd = HDcreat(name,0777); + fd = HDcreat(name, 0777); HDassert(fd >= 0); buf = (char *)HDcalloc(size, (size_t)1); HDassert(buf); /* fill buf with pattern */ bp = buf; - for(i = 0; i < size; i++) + for (i = 0; i < size; i++) *bp++ = pattern[i % 10]; HDwrite(fd, buf, size); @@ -319,22 +314,22 @@ void create_binfile(char *name, off_t size) { char *buf; - int fd; - int i; + int fd; + int i; char *bp; - fd = creat(name,0777); + fd = creat(name, 0777); HDassert(fd >= 0); - buf = HDcalloc(size,1); + buf = HDcalloc(size, 1); HDassert(buf); /* fill buf with pattern */ bp = buf; for (i = 0; i < size; i++) - *bp++ = (char) i & 0xff; + *bp++ = (char)i & 0xff; - HDwrite(fd,buf,size); + HDwrite(fd, buf, size); HDclose(fd); } @@ -346,32 +341,32 @@ create_binfile(char *name, off_t size) *------------------------------------------------------------------------- */ - -int main(void) +int +main(void) { -/* -create_textfile(UBTXT1, (size_t)0); -*/ -create_textfile(UBTXT2, (size_t)10); -create_textfile(UBTXT3, (size_t)511); -create_textfile(UBTXT4, (size_t)512); -create_textfile(UBTXT5, (size_t)513); -/* -create_textfile(UBTXT6, (size_t)1023); -create_textfile(UBTXT7, (size_t)1024); -create_textfile(UBTXT8, (size_t)1025); -create_textfile(UBTXT9, (size_t)2047); -create_textfile(UBTXT10, (size_t)2048); -create_textfile(UBTXT11, (size_t)2049); - -create_binfile(UBBIN1, (off_t)0); -create_binfile(UBBIN2, (off_t)10); -create_binfile(UBBIN3, (off_t)511); -create_binfile(UBBIN4, (off_t)512); -create_binfile(UBBIN5, (off_t)513); - -*/ + /* + create_textfile(UBTXT1, (size_t)0); + */ + create_textfile(UBTXT2, (size_t)10); + create_textfile(UBTXT3, (size_t)511); + create_textfile(UBTXT4, (size_t)512); + create_textfile(UBTXT5, (size_t)513); + /* + create_textfile(UBTXT6, (size_t)1023); + create_textfile(UBTXT7, (size_t)1024); + create_textfile(UBTXT8, (size_t)1025); + create_textfile(UBTXT9, (size_t)2047); + create_textfile(UBTXT10, (size_t)2048); + create_textfile(UBTXT11, (size_t)2049); + + create_binfile(UBBIN1, (off_t)0); + create_binfile(UBBIN2, (off_t)10); + create_binfile(UBBIN3, (off_t)511); + create_binfile(UBBIN4, (off_t)512); + create_binfile(UBBIN5, (off_t)513); + + */ gent_ub(FILE7, (size_t)0, (size_t)0); gent_ub(FILE8, (size_t)512, HDstrlen(pattern)); gent_ub(FILE9, (size_t)1024, (size_t)513); diff --git a/tools/test/h5jam/tellub.c b/tools/test/h5jam/tellub.c index 453444d..afb7e95 100644 --- a/tools/test/h5jam/tellub.c +++ b/tools/test/h5jam/tellub.c @@ -24,12 +24,8 @@ * parameters. The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -static const char *s_opts = "h"; -static struct long_options l_opts[] = { - {"help", no_arg, 'h'}, - {"hel", no_arg, 'h'}, - {NULL, 0, '\0'} -}; +static const char * s_opts = "h"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -40,12 +36,11 @@ static struct long_options l_opts[] = { *------------------------------------------------------------------------- */ static void -usage (const char *prog) +usage(const char *prog) { HDfflush(stdout); HDfprintf(stdout, "usage: %s h5_file\n", prog); - HDfprintf(stdout, - " Check that h5_fil is HDF5 file and print size of user block \n"); + HDfprintf(stdout, " Check that h5_fil is HDF5 file and print size of user block \n"); HDfprintf(stdout, " %s -h\n", prog); HDfprintf(stdout, " Print a usage message and exit\n"); } /* end usage() */ @@ -61,20 +56,20 @@ usage (const char *prog) */ static void -parse_command_line (int argc, const char *argv[]) +parse_command_line(int argc, const char *argv[]) { int opt; /* parse command line options */ - while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) { - switch ((char) opt) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { case 'h': - usage (h5tools_getprogname()); + usage(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); break; case '?': default: - usage (h5tools_getprogname()); + usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); } } @@ -82,7 +77,7 @@ parse_command_line (int argc, const char *argv[]) /* check for file name to be processed */ if (argc <= opt_ind) { error_msg("missing file name\n"); - usage (h5tools_getprogname()); + usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); } } /* end parse_command_line() */ @@ -90,8 +85,8 @@ parse_command_line (int argc, const char *argv[]) static void leave(int ret) { - h5tools_close(); - HDexit(ret); + h5tools_close(); + HDexit(ret); } /*------------------------------------------------------------------------- @@ -103,14 +98,14 @@ leave(int ret) *------------------------------------------------------------------------- */ int -main (int argc, const char *argv[]) +main(int argc, const char *argv[]) { - char *ifname; - hid_t ifile = H5I_INVALID_HID; + char * ifname; + hid_t ifile = H5I_INVALID_HID; hsize_t usize; - htri_t testval; - herr_t status; - hid_t plist = H5I_INVALID_HID; + htri_t testval; + herr_t status; + hid_t plist = H5I_INVALID_HID; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -123,9 +118,9 @@ main (int argc, const char *argv[]) /* enable error reporting if command line option */ h5tools_error_report(); - if(argc <= (opt_ind)) { + if (argc <= (opt_ind)) { error_msg("missing file name\n"); - usage (h5tools_getprogname()); + usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); goto done; } @@ -134,7 +129,7 @@ main (int argc, const char *argv[]) testval = H5Fis_accessible(ifname, H5P_DEFAULT); - if(testval <= 0) { + if (testval <= 0) { error_msg("Input HDF5 file is not HDF \"%s\"\n", ifname); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -142,33 +137,32 @@ main (int argc, const char *argv[]) ifile = H5Fopen(ifname, H5F_ACC_RDONLY, H5P_DEFAULT); - if(ifile < 0) { + if (ifile < 0) { error_msg("Can't open input HDF5 file \"%s\"\n", ifname); h5tools_setstatus(EXIT_FAILURE); goto done; } plist = H5Fget_create_plist(ifile); - if(plist < 0) { + if (plist < 0) { error_msg("Can't get file creation plist for file \"%s\"\n", ifname); h5tools_setstatus(EXIT_FAILURE); goto done; } status = H5Pget_userblock(plist, &usize); - if(status < 0) { + if (status < 0) { error_msg("Can't get user block for file \"%s\"\n", ifname); h5tools_setstatus(EXIT_FAILURE); goto done; } - HDprintf("%ld\n", (long) usize); + HDprintf("%ld\n", (long)usize); done: - H5Pclose (plist); - if(ifile >= 0) - H5Fclose (ifile); + H5Pclose(plist); + if (ifile >= 0) + H5Fclose(ifile); leave(h5tools_getstatus()); } /* end main() */ - diff --git a/tools/test/h5ls/dynlib_ls.c b/tools/test/h5ls/dynlib_ls.c index 661a6dc..32d2daf 100644 --- a/tools/test/h5ls/dynlib_ls.c +++ b/tools/test/h5ls/dynlib_ls.c @@ -17,25 +17,33 @@ #include #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIBUD, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ + "dynlibud", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*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) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ cd_values = cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = (int8_t)(temp - MULTIPLIER); + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = (int8_t)(temp + MULTIPLIER); + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/test/h5repack/dynlib_rpk.c b/tools/test/h5repack/dynlib_rpk.c index 29c3eae..1899586 100644 --- a/tools/test/h5repack/dynlib_rpk.c +++ b/tools/test/h5repack/dynlib_rpk.c @@ -20,24 +20,32 @@ #include #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIB1 257 +#define H5Z_FILTER_DYNLIB1 257 -static size_t H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIB1[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIB1, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib1", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ + 1, 1, /* Encoding and decoding enabled */ + "dynlib1", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_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 @@ -57,39 +65,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +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] > 9) + if (cd_values[0] > 9) return 0; add_on = (int)cd_values[0]; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + 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 */ + } /* 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 */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlib1() */ - diff --git a/tools/test/h5repack/dynlib_vrpk.c b/tools/test/h5repack/dynlib_vrpk.c index 06d90ff..4891743 100644 --- a/tools/test/h5repack/dynlib_vrpk.c +++ b/tools/test/h5repack/dynlib_vrpk.c @@ -17,26 +17,35 @@ #include #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIB4 260 +#define H5Z_FILTER_DYNLIB4 260 -#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) +#define PUSH_ERR(func, minor, str) \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) -static size_t H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIB4[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIB4, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib4", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib4, /* The actual filter function */ + 1, 1, /* Encoding and decoding enabled */ + "dynlib4", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)H5Z_filter_dynlib4, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB4;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIB4; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlib4 @@ -53,50 +62,48 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB4;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlib4(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; unsigned ver_info[3]; /* Check for the library version */ - if(H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) { + if (H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) { PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion"); - return(0); + return (0); } /* Check for the correct number of parameters */ - if(cd_nelmts == 0) - return(0); + if (cd_nelmts == 0) + return (0); /* Check that permanent parameters are set correctly */ - if(cd_values[0] > 9) - return(0); + if (cd_values[0] > 9) + return (0); - if(ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) { + if (ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) { PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion does not match"); - return(0); + return (0); } add_on = (int)cd_values[0]; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + 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 */ + } /* 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 */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlib4() */ - diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index 7604964..4a6d854 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -35,28 +35,34 @@ #include "hdf5.h" #include "H5private.h" -#define MAX_NAME_SIZE 256 +#define MAX_NAME_SIZE 256 #define FILE_INT32LE_1 "h5repack_int32le_1d" #define FILE_INT32LE_2 "h5repack_int32le_2d" #define FILE_INT32LE_3 "h5repack_int32le_3d" -#define FILE_UINT8BE "h5repack_uint8be" -#define FILE_F32LE "h5repack_f32le" - -#define H5REPACKGENTEST_OOPS { \ - ret_value = -1; \ - goto done; \ -} - -#define H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space) { \ - if ((dcpl) != H5P_DEFAULT && (dcpl) != H5I_INVALID_HID) { \ - (void)H5Pclose((dcpl)); \ - } \ - if ((file) != H5I_INVALID_HID) { (void)H5Fclose((file)); } \ - if ((space) != H5I_INVALID_HID) { (void)H5Sclose((space)); } \ -} +#define FILE_UINT8BE "h5repack_uint8be" +#define FILE_F32LE "h5repack_f32le" + +#define H5REPACKGENTEST_OOPS \ + { \ + ret_value = -1; \ + goto done; \ + } + +#define H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space) \ + { \ + if ((dcpl) != H5P_DEFAULT && (dcpl) != H5I_INVALID_HID) { \ + (void)H5Pclose((dcpl)); \ + } \ + if ((file) != H5I_INVALID_HID) { \ + (void)H5Fclose((file)); \ + } \ + if ((space) != H5I_INVALID_HID) { \ + (void)H5Sclose((space)); \ + } \ + } struct external_def { - hsize_t type_size; + hsize_t type_size; unsigned n_elts_per_file; unsigned n_elts_total; }; @@ -66,14 +72,13 @@ struct external_def { * Returns 0 on success, -1 on failure. */ static int -__make_dataset(hid_t file_id, const char *dset_name, - hid_t mem_type_id, hid_t space_id, hid_t dcpl_id, void *wdata) { - hid_t dset_id = H5I_INVALID_HID; +__make_dataset(hid_t file_id, const char *dset_name, hid_t mem_type_id, hid_t space_id, hid_t dcpl_id, + void *wdata) +{ + hid_t dset_id = H5I_INVALID_HID; int ret_value = 0; - dset_id = H5Dcreate2(file_id, dset_name, mem_type_id, space_id, - H5P_DEFAULT, dcpl_id, - H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, dset_name, mem_type_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); if (dset_id == H5I_INVALID_HID) H5REPACKGENTEST_OOPS; @@ -82,7 +87,7 @@ __make_dataset(hid_t file_id, const char *dset_name, done: if (dset_id != H5I_INVALID_HID) - (void) H5Dclose(dset_id); + (void)H5Dclose(dset_id); return ret_value; } /* end __make_dataset() */ @@ -96,11 +101,12 @@ done: * Returns 0 on success, -1 on failure. */ static int -__set_dcpl_external_list(hid_t dcpl, const char *filename, - unsigned n_elts_per_file, unsigned n_elts_total, hsize_t elt_size) { +__set_dcpl_external_list(hid_t dcpl, const char *filename, unsigned n_elts_per_file, unsigned n_elts_total, + hsize_t elt_size) +{ char name[MAX_NAME_SIZE]; unsigned n_external_files = 0; - unsigned i = 0; + unsigned i = 0; if (NULL == filename || '\0' == *filename) return -1; @@ -109,7 +115,6 @@ __set_dcpl_external_list(hid_t dcpl, const char *filename, if (n_elts_total != (n_external_files * n_elts_per_file)) return -1; - for (i = 0; i < n_external_files; i++) { if (HDsnprintf(name, MAX_NAME_SIZE, "%s_ex-%u.dat", filename, i) >= MAX_NAME_SIZE) return -1; @@ -127,12 +132,13 @@ __set_dcpl_external_list(hid_t dcpl, const char *filename, * Returns 0 on success, -1 on failure. */ static int -__make_file(const char *basename, struct external_def *ext, - hid_t type_id, hsize_t rank, hsize_t *dims, void *wdata) { +__make_file(const char *basename, struct external_def *ext, hid_t type_id, hsize_t rank, hsize_t *dims, + void *wdata) +{ char filename[MAX_NAME_SIZE]; - hid_t file_id = H5I_INVALID_HID; - hid_t dcpl_id = H5P_DEFAULT; - hid_t space_id = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; + hid_t dcpl_id = H5P_DEFAULT; + hid_t space_id = H5I_INVALID_HID; int ret_value = 0; if (HDsnprintf(filename, MAX_NAME_SIZE, "%s%s.h5", basename, (NULL != ext) ? "_ex" : "") >= MAX_NAME_SIZE) @@ -143,7 +149,8 @@ __make_file(const char *basename, struct external_def *ext, if (dcpl_id == H5I_INVALID_HID) H5REPACKGENTEST_OOPS; - if (__set_dcpl_external_list(dcpl_id, basename, ext->n_elts_per_file, ext->n_elts_total, ext->type_size) < 0) + if (__set_dcpl_external_list(dcpl_id, basename, ext->n_elts_per_file, ext->n_elts_total, + ext->type_size) < 0) H5REPACKGENTEST_OOPS; } @@ -155,29 +162,29 @@ __make_file(const char *basename, struct external_def *ext, if (file_id == H5I_INVALID_HID) H5REPACKGENTEST_OOPS; - if (__make_dataset(file_id, "dset", type_id, space_id, dcpl_id, wdata) < 0) H5REPACKGENTEST_OOPS; done: H5REPACKGENTEST_COMMON_CLEANUP(dcpl_id, file_id, space_id); -return ret_value; + return ret_value; } /* end __make_file() */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Returns 0 on success, -1 on failure. */ static int -generate_int32le_1d(hbool_t external) { - int32_t wdata[12]; - hsize_t dims[] = { 12 }; - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(int32_t), 6, 12 }; - int32_t n = 0; - int ret_value = 0; +generate_int32le_1d(hbool_t external) +{ + int32_t wdata[12]; + hsize_t dims[] = {12}; + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 6, 12}; + int32_t n = 0; + int ret_value = 0; /* Generate values - */ + */ for (n = 0; n < 12; n++) { wdata[n] = n - 6; } @@ -193,16 +200,17 @@ generate_int32le_1d(hbool_t external) { * Returns 0 on success, -1 on failure. */ static int -generate_int32le_2d(hbool_t external) { - int32_t wdata[64]; - hsize_t dims[] = { 8, 8 }; - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(int32_t), 64, 64 }; - int32_t n = 0; - int ret_value = 0; +generate_int32le_2d(hbool_t external) +{ + int32_t wdata[64]; + hsize_t dims[] = {8, 8}; + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 64, 64}; + int32_t n = 0; + int ret_value = 0; /* Generate values - */ + */ for (n = 0; n < 64; n++) { wdata[n] = n - 32; } @@ -218,19 +226,20 @@ generate_int32le_2d(hbool_t external) { * Returns 0 on success, -1 on failure. */ static int -generate_int32le_3d(hbool_t external) { - hsize_t dims[] = { 8, 8, 8 }; - int32_t wdata[512]; /* 8^3, from dims */ - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(int32_t), 512, 512 }; - int32_t n = 0; - int i = 0; - int j = 0; - int k = 0; - int ret_value = 0; +generate_int32le_3d(hbool_t external) +{ + hsize_t dims[] = {8, 8, 8}; + int32_t wdata[512]; /* 8^3, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 512, 512}; + int32_t n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; /* generate values, alternating positive and negative - */ + */ for (i = 0, n = 0; (hsize_t)i < dims[0]; i++) { for (j = 0; (hsize_t)j < dims[1]; j++) { for (k = 0; (hsize_t)k < dims[2]; k++, n++) { @@ -250,19 +259,20 @@ generate_int32le_3d(hbool_t external) { * Returns 0 on success, -1 on failure. */ static int -generate_uint8be(hbool_t external) { - hsize_t dims[] = { 4, 8, 8 }; - uint8_t wdata[256]; /* 4*8*8, from dims */ - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(uint8_t), 64, 256 }; - uint8_t n = 0; - int i = 0; - int j = 0; - int k = 0; - int ret_value = 0; +generate_uint8be(hbool_t external) +{ + hsize_t dims[] = {4, 8, 8}; + uint8_t wdata[256]; /* 4*8*8, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(uint8_t), 64, 256}; + uint8_t n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; /* Generate values, ping-pong from ends of range - */ + */ for (i = 0, n = 0; (hsize_t)i < dims[0]; i++) { for (j = 0; (hsize_t)j < dims[1]; j++) { for (k = 0; (hsize_t)k < dims[2]; k++, n++) { @@ -282,16 +292,17 @@ generate_uint8be(hbool_t external) { * Returns 0 on success, -1 on failure. */ static int -generate_f32le(hbool_t external) { - hsize_t dims[] = { 12, 6 }; - float wdata[72]; /* 12*6, from dims */ - struct external_def *def_ptr = NULL; - struct external_def def = { (hsize_t) sizeof(float), 72, 72 }; - float n = 0; - int i = 0; - int j = 0; - int k = 0; - int ret_value = 0; +generate_f32le(hbool_t external) +{ + hsize_t dims[] = {12, 6}; + float wdata[72]; /* 12*6, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(float), 72, 72}; + float n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; /* Generate values */ for (i = 0, k = 0, n = 0; (hsize_t)i < dims[0]; i++) { @@ -312,7 +323,8 @@ generate_f32le(hbool_t external) { * Return 0 on success, nonzero on failure. */ int -main(void) { +main(void) +{ int i = 0; for (i = 0; i < 2; i++) { @@ -336,4 +348,3 @@ main(void) { return EXIT_SUCCESS; } /* end main() */ - diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index ab0dbb7..1e49901 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/h5repack/h5repacktst.c @@ -17,39 +17,42 @@ #include "h5tools.h" #include "h5tools_utils.h" -#define GOERROR {H5_FAILED(); goto error;} - +#define GOERROR \ + { \ + H5_FAILED(); \ + goto error; \ + } /* fill value test */ -#define FNAME0 "h5repack_fill.h5" -#define FNAME0OUT "h5repack_fill_out.h5" +#define FNAME0 "h5repack_fill.h5" +#define FNAME0OUT "h5repack_fill_out.h5" /* HDF5 objects and all dataset datatypes */ -#define FNAME1 "h5repack_objs.h5" -#define FNAME1OUT "h5repack_objs_out.h5" +#define FNAME1 "h5repack_objs.h5" +#define FNAME1OUT "h5repack_objs_out.h5" /* attributes, all datatypes */ -#define FNAME2 "h5repack_attr.h5" -#define FNAME2OUT "h5repack_attr_out.h5" +#define FNAME2 "h5repack_attr.h5" +#define FNAME2OUT "h5repack_attr_out.h5" /* hard links */ -#define FNAME3 "h5repack_hlink.h5" -#define FNAME3OUT "h5repack_hlink_out.h5" +#define FNAME3 "h5repack_hlink.h5" +#define FNAME3OUT "h5repack_hlink_out.h5" /* layout */ -#define FNAME4 "h5repack_layout.h5" -#define FNAME4OUT "h5repack_layout_out.h5" +#define FNAME4 "h5repack_layout.h5" +#define FNAME4OUT "h5repack_layout_out.h5" /* H5D_ALLOC_TIME_EARLY */ -#define FNAME5 "h5repack_early.h5" -#define FNAME5OUT "h5repack_early_out.h5" -#define FNAME6 "h5repack_early2.h5" +#define FNAME5 "h5repack_early.h5" +#define FNAME5OUT "h5repack_early_out.h5" +#define FNAME6 "h5repack_early2.h5" #ifdef H5_HAVE_FILTER_SZIP /* SZIP filter */ -#define FNAME7 "h5repack_szip.h5" -#define FNAME7OUT "h5repack_szip_out.h5" +#define FNAME7 "h5repack_szip.h5" +#define FNAME7OUT "h5repack_szip_out.h5" #endif /* GZIP filter */ -#define FNAME8 "h5repack_deflate.h5" -#define FNAME8OUT "h5repack_deflate_out.h5" +#define FNAME8 "h5repack_deflate.h5" +#define FNAME8OUT "h5repack_deflate_out.h5" /* GZIP filter */ -#define FNAME9 "h5repack_shuffle.h5" -#define FNAME9OUT "h5repack_shuffle_out.h5" +#define FNAME9 "h5repack_shuffle.h5" +#define FNAME9OUT "h5repack_shuffle_out.h5" /* Fletcher filter */ #define FNAME10 "h5repack_fletcher.h5" #define FNAME10OUT "h5repack_fletcher_out.h5" @@ -72,58 +75,55 @@ #define FNAME16 "h5repack_ub.h5" #define FNAME16OUT "h5repack_ub_out.h5" /* Named datatypes */ -#define FNAME17 "h5repack_named_dtypes.h5" -#define FNAME17OUT "h5repack_named_dtypes_out.h5" +#define FNAME17 "h5repack_named_dtypes.h5" +#define FNAME17OUT "h5repack_named_dtypes_out.h5" -#define FNAME18 "h5repack_layout2.h5" +#define FNAME18 "h5repack_layout2.h5" /* Files for testing file space paging */ -#define FSPACE_OUT "h5repack_fspace_OUT.h5" /* The output file */ -#define NELMTS(X) (sizeof(X)/sizeof(X[0])) /* # of elements */ +#define FSPACE_OUT "h5repack_fspace_OUT.h5" /* The output file */ +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) /* # of elements */ const char *H5REPACK_FSPACE_FNAMES[] = { - "h5repack_latest.h5", /* 0 */ - "h5repack_default.h5", /* 1 */ - "h5repack_page_persist.h5", /* 2 */ - "h5repack_fsm_aggr_persist.h5", /* 3 */ - "h5repack_page_threshold.h5", /* 4 */ - "h5repack_fsm_aggr_threshold.h5", /* 5 */ - "h5repack_aggr.h5", /* 6 */ - "h5repack_none.h5" /* 7 */ + "h5repack_latest.h5", /* 0 */ + "h5repack_default.h5", /* 1 */ + "h5repack_page_persist.h5", /* 2 */ + "h5repack_fsm_aggr_persist.h5", /* 3 */ + "h5repack_page_threshold.h5", /* 4 */ + "h5repack_fsm_aggr_threshold.h5", /* 5 */ + "h5repack_aggr.h5", /* 6 */ + "h5repack_none.h5" /* 7 */ }; -#define FNAME_UB "ublock.bin" +#define FNAME_UB "ublock.bin" /* obj and region references */ -#define FNAME_REF "h5repack_refs.h5" +#define FNAME_REF "h5repack_refs.h5" /* obj and region references in attr of compound and vlen type */ -#define FNAME_ATTR_REF "h5repack_attr_refs.h5" +#define FNAME_ATTR_REF "h5repack_attr_refs.h5" -const char *H5REPACK_FILENAMES[] = { - "h5repack_big_out", - NULL -}; +const char *H5REPACK_FILENAMES[] = {"h5repack_big_out", NULL}; #define H5REPACK_EXTFILE "h5repack_ext.bin" /* Name of tool */ #define PROGRAMNAME "h5repacktst" -#define DIM1 40 -#define DIM2 20 -#define CDIM1 DIM1/2 -#define CDIM2 DIM2/2 -#define RANK 2 +#define DIM1 40 +#define DIM2 20 +#define CDIM1 DIM1 / 2 +#define CDIM2 DIM2 / 2 +#define RANK 2 /* Size of userblock (for userblock test) */ -#define USERBLOCK_SIZE 2048 +#define USERBLOCK_SIZE 2048 /* obj and region references */ -#define NAME_OBJ_DS1 "Dset1" -#define NAME_OBJ_GRP "Group" +#define NAME_OBJ_DS1 "Dset1" +#define NAME_OBJ_GRP "Group" #define NAME_OBJ_NDTYPE "NamedDatatype" -#define NAME_OBJ_DS2 "Dset2" -#define REG_REF_DS1 "Dset_REGREF" +#define NAME_OBJ_DS2 "Dset2" +#define REG_REF_DS1 "Dset_REGREF" /*------------------------------------------------------------------------- * prototypes @@ -148,21 +148,20 @@ static int make_all_filters(hid_t loc_id); static int make_fill(hid_t loc_id); static int make_big(hid_t loc_id); static int make_testfiles(void); -static int write_dset_in(hid_t loc_id,const char* dset_name,hid_t file_id,int make_diffs ); -static int write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs ); -static int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *dset_name,hid_t tid,void *buf ); -static int make_dset(hid_t loc_id,const char *name,hid_t sid,hid_t dcpl,void *buf); -static int make_attr(hid_t loc_id,int rank,hsize_t *dims,const char *attr_name,hid_t tid,void *buf); +static int write_dset_in(hid_t loc_id, const char *dset_name, hid_t file_id, int make_diffs); +static int write_attr_in(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); +static int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf); +static int make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t dcpl, void *buf); +static int make_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, hid_t tid, void *buf); static int make_dset_reg_ref(hid_t loc_id); static int make_external(hid_t loc_id); static int make_userblock(void); -static int verify_userblock( const char* filename); +static int verify_userblock(const char *filename); static int make_userblock_file(void); static int make_named_dtype(hid_t loc_id); static int make_references(hid_t loc_id); static int make_complex_attr_references(hid_t loc_id); - /*------------------------------------------------------------------------- * Function: main * @@ -173,18 +172,19 @@ static int make_complex_attr_references(hid_t loc_id); *------------------------------------------------------------------------- */ -int main (void) +int +main(void) { - pack_opt_t pack_options; - diff_opt_t diff_options; + pack_opt_t pack_options; + diff_opt_t diff_options; - unsigned j; /* Local index variable for testing file space */ - const char *fname; /* File name for testing file space */ + unsigned j; /* Local index variable for testing file space */ + const char *fname; /* File name for testing file space */ - h5_stat_t file_stat; - h5_stat_size_t fsize1, fsize2; /* file sizes */ -#if defined (H5_HAVE_FILTER_SZIP) - int szip_can_encode = 0; + h5_stat_t file_stat; + h5_stat_size_t fsize1, fsize2; /* file sizes */ +#if defined(H5_HAVE_FILTER_SZIP) + int szip_can_encode = 0; #endif h5tools_setprogname(PROGRAMNAME); @@ -194,8 +194,8 @@ int main (void) h5tools_init(); /* initialize */ - HDmemset(&diff_options, 0, sizeof (diff_opt_t)); - HDmemset(&pack_options, 0, sizeof (pack_opt_t)); + HDmemset(&diff_options, 0, sizeof(diff_opt_t)); + HDmemset(&pack_options, 0, sizeof(pack_opt_t)); /* run tests */ puts("Testing h5repack:"); @@ -218,153 +218,150 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" files with file space info setting--no options (-S, -P, -T, -G) are set"); - j = 0; /* #0 */ + j = 0; /* #0 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - TESTING(" files with file space info setting--all options -S, -P, -T, -G are set"); - ++j; /* #1 */ + ++j; /* #1 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; - pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ pack_options.fs_threshold = 1; - pack_options.fs_pagesize = 8192; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + pack_options.fs_pagesize = 8192; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - TESTING(" files with file space info setting--options -S and -T are set"); - ++j; /* #2 */ + ++j; /* #2 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - pack_options.fs_strategy = (H5F_fspace_strategy_t)-1; /* "FSM_AGGR" specified via -S FSM_AGGR */ - pack_options.fs_threshold = -1; /* "0" specified via -T 0 */ - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + pack_options.fs_strategy = (H5F_fspace_strategy_t)-1; /* "FSM_AGGR" specified via -S FSM_AGGR */ + pack_options.fs_threshold = -1; /* "0" specified via -T 0 */ + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - TESTING(" files with file space info setting-- options -S and -P are set & -L"); - ++j; /* #3 */ + ++j; /* #3 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, TRUE) < 0) + if (h5repack_init(&pack_options, 0, TRUE) < 0) GOERROR; pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; /* "PAGE" specified via -S */ - pack_options.fs_persist = TRUE; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + pack_options.fs_persist = TRUE; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); TESTING(" files with file space info setting-- options -P and -T are set & -L"); - ++j; /* #4 */ + ++j; /* #4 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, TRUE) < 0) + if (h5repack_init(&pack_options, 0, TRUE) < 0) GOERROR; - pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ pack_options.fs_threshold = 2; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); TESTING(" files with file space info setting-- options -S and -G are set & -L"); - ++j; /* #5 */ + ++j; /* #5 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, TRUE) < 0) + if (h5repack_init(&pack_options, 0, TRUE) < 0) GOERROR; pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; pack_options.fs_pagesize = 8192; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); TESTING(" files with file space info setting-- options -S, -P, -T, -G are set"); - ++j; /* #6 */ + ++j; /* #6 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; - pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ pack_options.fs_threshold = 1; - pack_options.fs_pagesize = 8192; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + pack_options.fs_pagesize = 8192; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); TESTING(" files with file space info setting-- options -S, -T, -G are set & -L"); - ++j; /* #7 */ + ++j; /* #7 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); fname = H5REPACK_FSPACE_FNAMES[j]; - if(h5repack_init(&pack_options, 0, TRUE) < 0) + if (h5repack_init(&pack_options, 0, TRUE) < 0) GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_AGGR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_AGGR; pack_options.fs_threshold = 1; - pack_options.fs_pagesize = 4096; - if(h5repack(fname, FSPACE_OUT, &pack_options) < 0) + pack_options.fs_pagesize = 4096; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) GOERROR; - if(h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); @@ -388,7 +385,6 @@ int main (void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * file with all kinds of dataset datatypes *------------------------------------------------------------------------- @@ -408,7 +404,6 @@ int main (void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * file with attributes *------------------------------------------------------------------------- @@ -565,7 +560,7 @@ int main (void) TESTING(" adding szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (h5tools_can_encode(H5Z_FILTER_SZIP) > 0) szip_can_encode = 1; @@ -575,7 +570,7 @@ int main (void) */ if (szip_can_encode) { - if (h5repack_init (&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset2:SZIP=8,EC", &pack_options) < 0) GOERROR; @@ -587,7 +582,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; - if (h5repack_end (&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); @@ -599,14 +594,13 @@ int main (void) SKIPPED(); #endif - /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- */ TESTING(" adding szip filter to all"); -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -630,7 +624,6 @@ int main (void) SKIPPED(); #endif - TESTING(" addding shuffle filter"); /*------------------------------------------------------------------------- @@ -679,7 +672,6 @@ int main (void) PASSED(); - TESTING(" adding checksum filter"); /*------------------------------------------------------------------------- @@ -726,7 +718,6 @@ int main (void) PASSED(); - TESTING(" filter queue fletcher, shuffle, deflate, szip"); /*------------------------------------------------------------------------- @@ -743,7 +734,7 @@ int main (void) if (h5repack_addfilter("dset1:SHUF", &pack_options) < 0) GOERROR; -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_addfilter("dset1:SZIP=8,NN", &pack_options) < 0) GOERROR; @@ -766,7 +757,6 @@ int main (void) PASSED(); - TESTING(" adding layout chunked (old format)"); /*------------------------------------------------------------------------- @@ -782,7 +772,7 @@ int main (void) GOERROR; if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options ) <= 0) + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -804,7 +794,7 @@ int main (void) GOERROR; if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options ) <= 0) + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -933,7 +923,6 @@ int main (void) PASSED(); - TESTING(" layout compact to contiguous conversion"); /*------------------------------------------------------------------------- @@ -986,9 +975,9 @@ int main (void) GOERROR; if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) GOERROR; - if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) >0) + if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options)<= 0) + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -1110,7 +1099,6 @@ int main (void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * the following tests assume the input files have filters * FNAME7 @@ -1122,7 +1110,7 @@ int main (void) */ TESTING(" copy of szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -1148,7 +1136,7 @@ int main (void) TESTING(" removing szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -1172,7 +1160,6 @@ int main (void) SKIPPED(); #endif - TESTING(" copy of deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE @@ -1192,7 +1179,6 @@ int main (void) SKIPPED(); #endif - TESTING(" removing deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE @@ -1214,8 +1200,6 @@ int main (void) SKIPPED(); #endif - - TESTING(" copy of shuffle filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1231,7 +1215,6 @@ int main (void) PASSED(); - TESTING(" removing shuffle filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1249,7 +1232,6 @@ int main (void) PASSED(); - TESTING(" copy of fletcher filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1265,7 +1247,6 @@ int main (void) PASSED(); - TESTING(" removing fletcher filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1283,7 +1264,6 @@ int main (void) PASSED(); - TESTING(" copy of nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1299,7 +1279,6 @@ int main (void) PASSED(); - TESTING(" removing nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1317,7 +1296,6 @@ int main (void) PASSED(); - TESTING(" adding nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1328,14 +1306,13 @@ int main (void) GOERROR; if (h5diff(FNAME12, FNAME12OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME12, FNAME12OUT, &pack_options)<= 0) + if (h5repack_verify(FNAME12, FNAME12OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - TESTING(" copy of scaleoffset filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1351,7 +1328,6 @@ int main (void) PASSED(); - TESTING(" removing scaleoffset filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1369,7 +1345,6 @@ int main (void) PASSED(); - TESTING(" adding scaleoffset filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1387,7 +1362,6 @@ int main (void) PASSED(); - /*------------------------------------------------------------------------- * file with all filters * dset_all @@ -1399,7 +1373,7 @@ int main (void) */ TESTING(" filter conversion from deflate to szip"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_SZIP) && defined(H5_HAVE_FILTER_DEFLATE) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1426,7 +1400,7 @@ int main (void) TESTING(" filter conversion from szip to deflate"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_SZIP) && defined(H5_HAVE_FILTER_DEFLATE) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1451,7 +1425,6 @@ int main (void) SKIPPED(); #endif - /*------------------------------------------------------------------------- * test the NONE global option *------------------------------------------------------------------------- @@ -1459,7 +1432,7 @@ int main (void) TESTING(" removing all filters"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_SZIP) && defined(H5_HAVE_FILTER_DEFLATE) if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -1519,17 +1492,17 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" file with userblock"); - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - if(h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) + if (h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME16, FNAME16OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME16, FNAME16OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME16, FNAME16OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME16, FNAME16OUT, &pack_options) <= 0) GOERROR; - if(verify_userblock(FNAME16OUT) < 0) + if (verify_userblock(FNAME16OUT) < 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); @@ -1540,7 +1513,7 @@ int main (void) TESTING(" latest file format options"); if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - pack_options.latest = 1; + pack_options.latest = 1; pack_options.grp_compact = 10; pack_options.grp_indexed = 5; pack_options.msg_size[0] = 10; @@ -1552,13 +1525,12 @@ int main (void) GOERROR; if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options)<=0) + if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * test several global filters *------------------------------------------------------------------------- @@ -1566,7 +1538,7 @@ int main (void) TESTING(" several global filters"); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -1588,7 +1560,6 @@ int main (void) SKIPPED(); #endif - /*------------------------------------------------------------------------- * test file with userblock *------------------------------------------------------------------------- @@ -1597,31 +1568,29 @@ int main (void) #ifdef H5_HAVE_FILTER_DEFLATE - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; /* add the options for a user block size and user block filename */ - pack_options.ublock_size = USERBLOCK_SIZE; + pack_options.ublock_size = USERBLOCK_SIZE; pack_options.ublock_filename = FNAME_UB; - if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) + if (h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) GOERROR; - if(verify_userblock(FNAME8OUT) < 0) + if (verify_userblock(FNAME8OUT) < 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; - PASSED(); #else SKIPPED(); #endif - /*------------------------------------------------------------------------- * test file with aligment *------------------------------------------------------------------------- @@ -1630,18 +1599,18 @@ int main (void) #ifdef H5_HAVE_FILTER_DEFLATE - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; /* add the options for aligment */ pack_options.alignment = 1; pack_options.threshold = 1; - if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) + if (h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) GOERROR; /* verify aligment */ @@ -1655,7 +1624,7 @@ int main (void) GOERROR; if ((fapl = H5Fget_access_plist(fid)) < 0) GOERROR; - if (H5Pget_alignment(fapl, &threshold, &alignment) < 0) + if (H5Pget_alignment(fapl, &threshold, &alignment) < 0) GOERROR; if (threshold != 1) GOERROR; @@ -1665,14 +1634,11 @@ int main (void) GOERROR; if (H5Fclose(fid) < 0) GOERROR; - } - - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; - PASSED(); #else SKIPPED(); @@ -1684,19 +1650,18 @@ int main (void) */ TESTING(" file with committed datatypes"); - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - if(h5repack(FNAME17, FNAME17OUT, &pack_options) < 0) + if (h5repack(FNAME17, FNAME17OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME17, FNAME17OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME17, FNAME17OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME17, FNAME17OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME17, FNAME17OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; - PASSED(); /*------------------------------------------------------------------------- @@ -1711,48 +1676,46 @@ int main (void) /* First run without metadata option. No need to verify the correctness */ /* since this has been verified by earlier tests. Just record the file */ /* size of the output file. */ - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) GOERROR; - if(HDstat(FNAME4OUT, &file_stat) < 0) + if (HDstat(FNAME4OUT, &file_stat) < 0) GOERROR; fsize1 = file_stat.st_size; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; /* run it again with metadata option */ - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; pack_options.meta_block_size = 8192; - if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; /* record the file size of the output file */ - if(HDstat(FNAME4OUT, &file_stat) < 0) + if (HDstat(FNAME4OUT, &file_stat) < 0) GOERROR; fsize2 = file_stat.st_size; /* verify second file size is larger than the first one */ - if(fsize2 <= fsize1) + if (fsize2 <= fsize1) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * clean temporary test files *------------------------------------------------------------------------- */ { - hid_t fapl; + hid_t fapl; fapl = h5_fileaccess(); h5_clean_files(H5REPACK_FILENAMES, fapl); - } puts("All h5repack tests passed."); @@ -1764,105 +1727,103 @@ int main (void) error: puts("***** H5REPACK TESTS FAILED *****"); return 1; - } - /*------------------------------------------------------------------------- -* Function: make_testfiles -* -* Purpose: make a test file with all types of HDF5 objects, -* datatypes and filters -* -*------------------------------------------------------------------------- -*/ -static -int make_testfiles(void) + * Function: make_testfiles + * + * Purpose: make a test file with all types of HDF5 objects, + * datatypes and filters + * + *------------------------------------------------------------------------- + */ +static int +make_testfiles(void) { - hid_t fid = H5I_INVALID_HID; - hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - unsigned j; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + unsigned j; /* Local index variable */ /*------------------------------------------------------------------------- * create a file for general copy test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME0, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME0, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_fill(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create another file for general copy test (all datatypes) *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_all_objects(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file for attributes copy test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_attributes(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file for hard links test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_hlinks(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file for layouts test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_layout(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file for layout conversion test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME18, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME18, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(make_layout2(fid) < 0) + if (make_layout2(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * for test layout conversions form chunk with unlimited max dims *------------------------------------------------------------------------- */ - if((fid = H5Fcreate("h5repack_layout3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate("h5repack_layout3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(make_layout3(fid) < 0) + if (make_layout3(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- @@ -1872,131 +1833,130 @@ int make_testfiles(void) if (make_early() < 0) goto out; - /*------------------------------------------------------------------------- - * create a file with the SZIP filter - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * create a file with the SZIP filter + *------------------------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_SZIP - if((fid = H5Fcreate(FNAME7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_szip(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; #endif /* H5_HAVE_FILTER_SZIP */ - /*------------------------------------------------------------------------- * create a file with the deflate filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_deflate(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with the shuffle filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME9, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME9, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_shuffle(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with the fletcher32 filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME10, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME10, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_fletcher32(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with all the filters *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME11, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME11, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_all_filters(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with the nbit filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_nbit(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with the scaleoffset filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_scaleoffset(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a big dataset *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME14, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME14, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_big(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with external dataset *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME15, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME15, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_external(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with userblock *------------------------------------------------------------------------- */ - if(make_userblock() < 0) + if (make_userblock() < 0) goto out; /*------------------------------------------------------------------------- * create a userblock file *------------------------------------------------------------------------- */ - if(make_userblock_file() < 0) + if (make_userblock_file() < 0) goto out; /*------------------------------------------------------------------------- * create a file with named datatypes *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_named_dtype(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- @@ -2005,23 +1965,23 @@ int make_testfiles(void) * add attribute with obj and region reference type (bug1726) *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; /* create reference type datasets */ if (make_references(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with obj and region references in attribute of compound and * vlen datatype *-------------------------------------------------------------------------*/ - if((fid = H5Fcreate(FNAME_ATTR_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME_ATTR_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_complex_attr_references(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- @@ -2029,11 +1989,11 @@ int make_testfiles(void) *------------------------------------------------------------------------- */ /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) return -1; /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; /* @@ -2042,9 +2002,9 @@ int make_testfiles(void) * default: inpage=4096 */ j = 0; - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[j], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[j], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /* @@ -2053,9 +2013,9 @@ int make_testfiles(void) * default: inpage=4096 */ HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /* @@ -2066,21 +2026,20 @@ int make_testfiles(void) * latest format */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; - if(H5Pset_file_space_page_size(fcpl, (hsize_t)512) < 0) + if (H5Pset_file_space_page_size(fcpl, (hsize_t)512) < 0) return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) return -1; HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; - /* * #3 -- h5repack_fsm_aggr_persist.h5 * Setting: @@ -2088,19 +2047,18 @@ int make_testfiles(void) * default: inpage=4096 */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) return -1; HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; - /* * #4 -- h5repack_page_threshold.h5 * Setting: @@ -2110,18 +2068,18 @@ int make_testfiles(void) */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)3) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)3) < 0) return -1; - if(H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) + if (H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) return -1; HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; /* @@ -2132,18 +2090,18 @@ int make_testfiles(void) */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)3) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)3) < 0) return -1; - if(H5Pset_file_space_page_size(fcpl, (hsize_t)FS_PAGESIZE_DEF) < 0) + if (H5Pset_file_space_page_size(fcpl, (hsize_t)FS_PAGESIZE_DEF) < 0) return -1; HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; /* @@ -2154,16 +2112,16 @@ int make_testfiles(void) */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) return -1; HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; /* @@ -2174,21 +2132,21 @@ int make_testfiles(void) */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_NONE, FALSE, (hsize_t)1) < 0) return -1; - if(H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) + if (H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) return -1; HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) return -1; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) return -1; return 0; @@ -2198,47 +2156,44 @@ out: return -1; } - - /*------------------------------------------------------------------------- -* Function: make_all_objects -* -* Purpose: make a test file with all types of HDF5 objects -* -*------------------------------------------------------------------------- -*/ -static -int make_all_objects(hid_t loc_id) + * Function: make_all_objects + * + * Purpose: make a test file with all types of HDF5 objects + * + *------------------------------------------------------------------------- + */ +static int +make_all_objects(hid_t loc_id) { - hid_t did = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; - hid_t rid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t gcplid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t rid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t gcplid = H5I_INVALID_HID; hsize_t dims[1] = {2}; /* compound datatype */ - typedef struct s_t - { - int a; - float b; + typedef struct s_t { + int a; + float b; } s_t; /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ + * H5G_DATASET + *------------------------------------------------------------------------- + */ if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; - if ((did = H5Dcreate2(loc_id, "dset_referenced", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "dset_referenced", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto out; - /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * H5G_GROUP + *------------------------------------------------------------------------- + */ + if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; if (H5Gclose(gid) < 0) goto out; @@ -2254,9 +2209,9 @@ int make_all_objects(hid_t loc_id) goto out; /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ + * H5G_TYPE + *------------------------------------------------------------------------- + */ /* create a compound datatype */ if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) @@ -2269,27 +2224,27 @@ int make_all_objects(hid_t loc_id) goto out; /*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ + * H5G_LINK + *------------------------------------------------------------------------- + */ if (H5Lcreate_soft("dset", loc_id, "link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * H5G_UDLINK - *------------------------------------------------------------------------- - */ + * H5G_UDLINK + *------------------------------------------------------------------------- + */ /* Create an external link. Other UD links are not supported by h5repack */ if (H5Lcreate_external("file", "path", loc_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * write a series of datasetes at root - *------------------------------------------------------------------------- - */ + * write a series of datasetes at root + *------------------------------------------------------------------------- + */ - if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) + if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) goto out; if (write_dset_in(rid, "dset_referenced", loc_id, 0) < 0) goto out; @@ -2317,58 +2272,58 @@ out: H5Sclose(sid); H5Tclose(tid); H5Pclose(gcplid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_attributes -* -* Purpose: make a test file with all types of attributes -* -*------------------------------------------------------------------------- -*/ -static -int make_attributes(hid_t loc_id) + * Function: make_attributes + * + * Purpose: make a test file with all types of attributes + * + *------------------------------------------------------------------------- + */ +static int +make_attributes(hid_t loc_id) { - hid_t did = H5I_INVALID_HID; - hid_t gid = H5I_INVALID_HID; - hid_t rid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t rid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; hsize_t dims[1] = {2}; /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ + * H5G_DATASET + *------------------------------------------------------------------------- + */ if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; - if ((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * H5G_GROUP + *------------------------------------------------------------------------- + */ + if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) + if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * write a series of attributes on the dataset, group, and root group - *------------------------------------------------------------------------- - */ + * write a series of attributes on the dataset, group, and root group + *------------------------------------------------------------------------- + */ - if ( write_attr_in(did, "dset", loc_id, 0) < 0) + if (write_attr_in(did, "dset", loc_id, 0) < 0) goto out; if (write_attr_in(gid, "dset", loc_id, 0) < 0) goto out; if (write_attr_in(rid, "dset", loc_id, 0) < 0) goto out; - /* close */ + /* close */ if (H5Dclose(did) < 0) goto out; if (H5Gclose(gid) < 0) @@ -2387,59 +2342,58 @@ out: H5Gclose(gid); H5Gclose(rid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- -* Function: make_hlinks -* -* Purpose: make a test file with hard links -* -*------------------------------------------------------------------------- -*/ -static -int make_hlinks(hid_t loc_id) + * Function: make_hlinks + * + * Purpose: make a test file with hard links + * + *------------------------------------------------------------------------- + */ +static int +make_hlinks(hid_t loc_id) { - hid_t g1id =- 1; - hid_t g2id = H5I_INVALID_HID; - hid_t g3id = H5I_INVALID_HID; - hsize_t dims[2] = {3,2}; - int buf[3][2] = {{1,1}, {1,2}, {2,2}}; + hid_t g1id = -1; + hid_t g2id = H5I_INVALID_HID; + hid_t g3id = H5I_INVALID_HID; + hsize_t dims[2] = {3, 2}; + int buf[3][2] = {{1, 1}, {1, 2}, {2, 2}}; /*------------------------------------------------------------------------- - * create a dataset and some hard links to it - *------------------------------------------------------------------------- - */ + * create a dataset and some hard links to it + *------------------------------------------------------------------------- + */ - if(write_dset(loc_id, 2, dims, "dset", H5T_NATIVE_INT, buf) < 0) + if (write_dset(loc_id, 2, dims, "dset", H5T_NATIVE_INT, buf) < 0) return -1; - if(H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link1 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link1 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) return -1; - if(H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link2 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link2 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) return -1; - if(H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link3 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link3 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) return -1; /*------------------------------------------------------------------------- - * create a group and some hard links to it - *------------------------------------------------------------------------- - */ + * create a group and some hard links to it + *------------------------------------------------------------------------- + */ - if((g1id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((g1id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if((g2id = H5Gcreate2(g1id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((g2id = H5Gcreate2(g1id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if((g3id = H5Gcreate2(g2id, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((g3id = H5Gcreate2(g2id, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Lcreate_hard(loc_id, "g1", g2id, "link1 to g1", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(loc_id, "g1", g2id, "link1 to g1", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - if(H5Lcreate_hard(g1id, "g2", g3id, "link1 to g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(g1id, "g2", g3id, "link1 to g2", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - /* close */ if (H5Gclose(g1id) < 0) goto out; @@ -2456,31 +2410,30 @@ out: H5Gclose(g1id); H5Gclose(g2id); H5Gclose(g3id); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } - /*------------------------------------------------------------------------- -* Function: make_szip -* -* Purpose: make a dataset with the SZIP filter -* -*------------------------------------------------------------------------- -*/ + * Function: make_szip + * + * Purpose: make a dataset with the SZIP filter + * + *------------------------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_SZIP -static -int make_szip(hid_t loc_id) +static int +make_szip(hid_t loc_id) { - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace ID */ - unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; unsigned szip_pixels_per_block = 8; - hsize_t dims[RANK] = {DIM1, DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int **buf = NULL; - int szip_can_encode = 0; + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int ** buf = NULL; + int szip_can_encode = 0; /* Create and fill array */ H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); @@ -2489,26 +2442,26 @@ int make_szip(hid_t loc_id) H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; /*------------------------------------------------------------------------- - * SZIP - *------------------------------------------------------------------------- - */ + * SZIP + *------------------------------------------------------------------------- + */ /* Make sure encoding is enabled */ if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) szip_can_encode = 1; if (szip_can_encode) { /* set szip data */ - if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block) < 0) + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) goto error; if (make_dset(loc_id, "dset_szip", sid, dcpl, buf[0]) < 0) goto error; @@ -2516,9 +2469,9 @@ int make_szip(hid_t loc_id) else /* WARNING? SZIP is decoder only, can't generate test files */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; HDfree(buf); @@ -2526,10 +2479,12 @@ int make_szip(hid_t loc_id) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); @@ -2537,23 +2492,21 @@ error: } #endif /* H5_HAVE_FILTER_SZIP */ - - /*------------------------------------------------------------------------- -* Function: make_deflate -* -* Purpose: make a dataset with the deflate filter -* -*------------------------------------------------------------------------- -*/ -static -int make_deflate(hid_t loc_id) + * Function: make_deflate + * + * Purpose: make a dataset with the deflate filter + * + *------------------------------------------------------------------------- + */ +static int +make_deflate(hid_t loc_id) { - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace ID */ - hsize_t dims[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int **buf = NULL; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int ** buf = NULL; hobj_ref_t bufref[1]; /* reference */ hsize_t dims1r[1] = {1}; @@ -2564,22 +2517,22 @@ int make_deflate(hid_t loc_id) H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; - /*------------------------------------------------------------------------- - * GZIP - *------------------------------------------------------------------------- - */ -#if defined (H5_HAVE_FILTER_DEFLATE) + /*------------------------------------------------------------------------- + * GZIP + *------------------------------------------------------------------------- + */ +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) goto error; if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf[0]) < 0) goto error; @@ -2592,14 +2545,13 @@ int make_deflate(hid_t loc_id) goto error; #endif - /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; HDfree(buf); @@ -2607,32 +2559,33 @@ int make_deflate(hid_t loc_id) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); return -1; } - /*------------------------------------------------------------------------- -* Function: make_shuffle -* -* Purpose: make a dataset with the shuffle filter -* -*------------------------------------------------------------------------- -*/ -static -int make_shuffle(hid_t loc_id) + * Function: make_shuffle + * + * Purpose: make a dataset with the shuffle filter + * + *------------------------------------------------------------------------- + */ +static int +make_shuffle(hid_t loc_id) { - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace ID */ - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int **buf = NULL; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int ** buf = NULL; /* Create and fill array */ H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); @@ -2641,19 +2594,19 @@ int make_shuffle(hid_t loc_id) H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; /*------------------------------------------------------------------------- - * shuffle - *------------------------------------------------------------------------- - */ + * shuffle + *------------------------------------------------------------------------- + */ /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) @@ -2661,14 +2614,13 @@ int make_shuffle(hid_t loc_id) if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf[0]) < 0) goto error; - /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; HDfree(buf); @@ -2676,10 +2628,12 @@ int make_shuffle(hid_t loc_id) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); @@ -2687,20 +2641,20 @@ error: } /*------------------------------------------------------------------------- -* Function: make_fletcher32 -* -* Purpose: make a dataset with the fletcher32 filter -* -*------------------------------------------------------------------------- -*/ -static -int make_fletcher32(hid_t loc_id) + * Function: make_fletcher32 + * + * Purpose: make a dataset with the fletcher32 filter + * + *------------------------------------------------------------------------- + */ +static int +make_fletcher32(hid_t loc_id) { - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace ID */ - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int **buf = NULL; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int ** buf = NULL; /* Create and fill array */ H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); @@ -2709,23 +2663,22 @@ int make_fletcher32(hid_t loc_id) H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; - /*------------------------------------------------------------------------- - * fletcher32 - *------------------------------------------------------------------------- - */ - + * fletcher32 + *------------------------------------------------------------------------- + */ + /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) @@ -2734,12 +2687,12 @@ int make_fletcher32(hid_t loc_id) goto error; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; HDfree(buf); @@ -2747,34 +2700,35 @@ int make_fletcher32(hid_t loc_id) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); return -1; } - /*------------------------------------------------------------------------- -* Function: make_nbit -* -* Purpose: make a dataset with the nbit filter -* -*------------------------------------------------------------------------- -*/ -static -int make_nbit(hid_t loc_id) + * Function: make_nbit + * + * Purpose: make a dataset with the nbit filter + * + *------------------------------------------------------------------------- + */ +static int +make_nbit(hid_t loc_id) { - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace ID */ - hid_t dtid = H5I_INVALID_HID; - hid_t dsid = H5I_INVALID_HID; - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int **buf = NULL; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hid_t dtid = H5I_INVALID_HID; + hid_t dsid = H5I_INVALID_HID; + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int ** buf = NULL; /* Create and fill array */ H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); @@ -2783,45 +2737,45 @@ int make_nbit(hid_t loc_id) H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; dtid = H5Tcopy(H5T_NATIVE_INT); - if (H5Tset_precision(dtid,(H5Tget_precision(dtid) - 1)) < 0) + if (H5Tset_precision(dtid, (H5Tget_precision(dtid) - 1)) < 0) goto error; /* remove the filters from the dcpl */ - if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; - if(H5Pset_nbit(dcpl) < 0) + if (H5Pset_nbit(dcpl) < 0) goto error; - if((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) goto error; H5Dclose(dsid); - if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; - if((dsid = H5Dcreate2(loc_id, "dset_int31", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_int31", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) goto error; H5Dclose(dsid); /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; if (H5Tclose(dtid) < 0) goto error; @@ -2831,36 +2785,37 @@ int make_nbit(hid_t loc_id) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(dtid); H5Pclose(dcpl); H5Sclose(sid); H5Dclose(dsid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); return -1; } - /*------------------------------------------------------------------------- -* Function: make_scaleoffset -* -* Purpose: make a dataset with the scaleoffset filter -* -*------------------------------------------------------------------------- -*/ -static -int make_scaleoffset(hid_t loc_id) + * Function: make_scaleoffset + * + * Purpose: make a dataset with the scaleoffset filter + * + *------------------------------------------------------------------------- + */ +static int +make_scaleoffset(hid_t loc_id) { - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace ID */ - hid_t dtid = H5I_INVALID_HID; - hid_t dsid = H5I_INVALID_HID; - hsize_t dims[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int **buf = NULL; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hid_t dtid = H5I_INVALID_HID; + hid_t dsid = H5I_INVALID_HID; + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int ** buf = NULL; /* Create and fill array */ H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); @@ -2869,41 +2824,41 @@ int make_scaleoffset(hid_t loc_id) H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; dtid = H5Tcopy(H5T_NATIVE_INT); /* remove the filters from the dcpl */ - if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; - if(H5Pset_scaleoffset(dcpl, H5Z_SO_INT, 31) < 0) + if (H5Pset_scaleoffset(dcpl, H5Z_SO_INT, 31) < 0) goto error; - if((dsid = H5Dcreate2(loc_id, "dset_scaleoffset", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_scaleoffset", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) goto error; H5Dclose(dsid); - if((dsid = H5Dcreate2(loc_id, "dset_none", dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_none", dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) goto error; H5Tclose(dtid); H5Dclose(dsid); /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; HDfree(buf); @@ -2911,41 +2866,42 @@ int make_scaleoffset(hid_t loc_id) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dsid); H5Tclose(dtid); H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); return -1; } - /*------------------------------------------------------------------------- -* Function: make_all_filters -* -* Purpose: make a file with all filters -* -*------------------------------------------------------------------------- -*/ -static -int make_all_filters(hid_t loc_id) + * Function: make_all_filters + * + * Purpose: make a file with all filters + * + *------------------------------------------------------------------------- + */ +static int +make_all_filters(hid_t loc_id) { - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid = H5I_INVALID_HID; /* dataspace ID */ - hid_t dtid = H5I_INVALID_HID; - hid_t dsid = H5I_INVALID_HID; -#if defined (H5_HAVE_FILTER_SZIP) - unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hid_t dtid = H5I_INVALID_HID; + hid_t dsid = H5I_INVALID_HID; +#if defined(H5_HAVE_FILTER_SZIP) + unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; unsigned szip_pixels_per_block = 8; #endif /* H5_HAVE_FILTER_SZIP */ - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int **buf = NULL; -#if defined (H5_HAVE_FILTER_SZIP) + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int ** buf = NULL; +#if defined(H5_HAVE_FILTER_SZIP) int szip_can_encode = 0; #endif @@ -2956,7 +2912,7 @@ int make_all_filters(hid_t loc_id) H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -2973,24 +2929,23 @@ int make_all_filters(hid_t loc_id) if (H5Pset_fletcher32(dcpl) < 0) goto error; -#if defined (H5_HAVE_FILTER_SZIP) - if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) - { +#if defined(H5_HAVE_FILTER_SZIP) + if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { szip_can_encode = 1; } - if (szip_can_encode) - { + if (szip_can_encode) { /* set szip data */ - if(H5Pset_szip (dcpl,szip_options_mask, szip_pixels_per_block) < 0) + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) goto error; - } else { + } + else { /* WARNING? SZIP is decoder only, can't generate test data using szip */ } #endif -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) goto error; #endif @@ -2998,7 +2953,7 @@ int make_all_filters(hid_t loc_id) goto error; /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) @@ -3006,28 +2961,25 @@ int make_all_filters(hid_t loc_id) if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf[0]) < 0) goto error; - - /* Make sure encoding is enabled */ -#if defined (H5_HAVE_FILTER_SZIP) - if (szip_can_encode) - { + /* Make sure encoding is enabled */ +#if defined(H5_HAVE_FILTER_SZIP) + if (szip_can_encode) { /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; /* set szip data */ - if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block) < 0) + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) goto error; if (make_dset(loc_id, "dset_szip", sid, dcpl, buf[0]) < 0) goto error; - } else - { + } + else { /* WARNING? SZIP is decoder only, can't generate test dataset */ } #endif - /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) @@ -3035,20 +2987,17 @@ int make_all_filters(hid_t loc_id) if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf[0]) < 0) goto error; - -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; /* set deflate data */ - if(H5Pset_deflate(dcpl, 1) < 0) + if (H5Pset_deflate(dcpl, 1) < 0) goto error; if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf[0]) < 0) goto error; #endif - - /* remove the filters from the dcpl */ if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto error; @@ -3059,20 +3008,20 @@ int make_all_filters(hid_t loc_id) goto error; if (H5Tset_precision(dtid, (H5Tget_precision(dtid) - 1)) < 0) goto error; - if((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) goto error; /* close */ - if(H5Tclose(dtid) < 0) + if (H5Tclose(dtid) < 0) goto error; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; HDfree(buf); @@ -3086,35 +3035,34 @@ error: H5Dclose(dsid); H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); return -1; } - - /*------------------------------------------------------------------------- -* Function: make_early -* -* Purpose: create a file for the H5D_ALLOC_TIME_EARLY test -* -*------------------------------------------------------------------------- -*/ -static -int make_early(void) + * Function: make_early + * + * Purpose: create a file for the H5D_ALLOC_TIME_EARLY test + * + *------------------------------------------------------------------------- + */ +static int +make_early(void) { - hsize_t dims[1] ={3000}; - hsize_t cdims[1]={30}; - hid_t fid=H5I_INVALID_HID; - hid_t did=H5I_INVALID_HID; - hid_t sid=H5I_INVALID_HID; - hid_t tid=H5I_INVALID_HID; - hid_t dcpl=H5I_INVALID_HID; + hsize_t dims[1] = {3000}; + hsize_t cdims[1] = {30}; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; int i; char name[16]; - int iter=100; + int iter = 100; if ((fid = H5Fcreate(FNAME5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; @@ -3130,8 +3078,7 @@ int make_early(void) if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto out; - for(i = 0; i < iter; i++) - { + for (i = 0; i < iter; i++) { if ((fid = H5Fopen(FNAME5, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto out; if ((did = H5Dcreate2(fid, "early", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) @@ -3152,15 +3099,14 @@ int make_early(void) } /*------------------------------------------------------------------------- - * do the same without close/opening the file and creating the dataset - *------------------------------------------------------------------------- - */ + * do the same without close/opening the file and creating the dataset + *------------------------------------------------------------------------- + */ if ((fid = H5Fcreate(FNAME6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - for(i = 0; i < iter; i++) - { + for (i = 0; i < iter; i++) { if ((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) goto out; HDsprintf(name, "%d", i); @@ -3187,28 +3133,28 @@ out: H5Sclose(sid); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_layout -* -* Purpose: make several datasets with several layouts in location LOC_ID -* -*------------------------------------------------------------------------- -*/ -static -int make_layout(hid_t loc_id) + * Function: make_layout + * + * Purpose: make several datasets with several layouts in location LOC_ID + * + *------------------------------------------------------------------------- + */ +static int +make_layout(hid_t loc_id) { - hid_t dcpl=H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid=H5I_INVALID_HID; /* dataspace ID */ - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int **buf = NULL; - int i; - char name[16]; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int ** buf = NULL; + int i; + char name[16]; /* Create and fill array */ H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); @@ -3216,63 +3162,61 @@ int make_layout(hid_t loc_id) goto error; H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); - /*------------------------------------------------------------------------- - * make several dataset with no filters - *------------------------------------------------------------------------- - */ - for (i=0; i<4; i++) { - HDsprintf(name,"dset%d",i+1); + * make several dataset with no filters + *------------------------------------------------------------------------- + */ + for (i = 0; i < 4; i++) { + HDsprintf(name, "dset%d", i + 1); if (write_dset(loc_id, RANK, dims, name, H5T_NATIVE_INT, buf[0]) < 0) goto error; } - /*------------------------------------------------------------------------- - * make several dataset with several layout options - *------------------------------------------------------------------------- - */ + * make several dataset with several layout options + *------------------------------------------------------------------------- + */ /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; /*------------------------------------------------------------------------- - * H5D_COMPACT - *------------------------------------------------------------------------- - */ - if(H5Pset_layout (dcpl,H5D_COMPACT) < 0) + * H5D_COMPACT + *------------------------------------------------------------------------- + */ + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto error; if (make_dset(loc_id, "dset_compact", sid, dcpl, buf[0]) < 0) goto error; /*------------------------------------------------------------------------- - * H5D_CONTIGUOUS - *------------------------------------------------------------------------- - */ - if(H5Pset_layout (dcpl,H5D_CONTIGUOUS) < 0) + * H5D_CONTIGUOUS + *------------------------------------------------------------------------- + */ + if (H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) goto error; if (make_dset(loc_id, "dset_contiguous", sid, dcpl, buf[0]) < 0) goto error; /*------------------------------------------------------------------------- - * H5D_CHUNKED - *------------------------------------------------------------------------- - */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + * H5D_CHUNKED + *------------------------------------------------------------------------- + */ + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; if (make_dset(loc_id, "dset_chunk", sid, dcpl, buf[0]) < 0) goto error; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; HDfree(buf); @@ -3284,7 +3228,8 @@ error: { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); @@ -3301,25 +3246,25 @@ error: * *------------------------------------------------------------------------- */ -#define S_DIM1 4 -#define S_DIM2 10 -#define CONTIG_S "contig_small" -#define CHUNKED_S_FIX "chunked_small_fixed" +#define S_DIM1 4 +#define S_DIM2 10 +#define CONTIG_S "contig_small" +#define CHUNKED_S_FIX "chunked_small_fixed" -static -int make_layout2(hid_t loc_id) +static int +make_layout2(hid_t loc_id) { - hid_t contig_dcpl = H5I_INVALID_HID; /* dataset creation property list */ - hid_t chunked_dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t contig_dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t chunked_dcpl = H5I_INVALID_HID; /* dataset creation property list */ - int ret_value = -1; /* Return value */ - hid_t s_sid = H5I_INVALID_HID; /* dataspace ID */ + int ret_value = -1; /* Return value */ + hid_t s_sid = H5I_INVALID_HID; /* dataspace ID */ - hsize_t s_dims[RANK] = {S_DIM1,S_DIM2}; /* Dataspace (< 1 k) */ - hsize_t chunk_dims[RANK] = {S_DIM1/2, S_DIM2/2}; /* Dimension sizes for chunks */ + hsize_t s_dims[RANK] = {S_DIM1, S_DIM2}; /* Dataspace (< 1 k) */ + hsize_t chunk_dims[RANK] = {S_DIM1 / 2, S_DIM2 / 2}; /* Dimension sizes for chunks */ - int **s_buf = NULL; /* Temporary buffer */ + int **s_buf = NULL; /* Temporary buffer */ /* Create and fill array */ H5TEST_ALLOCATE_2D_ARRAY(s_buf, int, S_DIM1, S_DIM2); @@ -3328,23 +3273,23 @@ int make_layout2(hid_t loc_id) H5TEST_FILL_2D_ARRAY(s_buf, int, S_DIM1, S_DIM2); /* Create dataspaces */ - if((s_sid = H5Screate_simple(RANK, s_dims, NULL)) < 0) + if ((s_sid = H5Screate_simple(RANK, s_dims, NULL)) < 0) goto error; /* Create contiguous datasets */ - if((contig_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((contig_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_layout(contig_dcpl, H5D_CONTIGUOUS) < 0) + if (H5Pset_layout(contig_dcpl, H5D_CONTIGUOUS) < 0) goto error; - if(make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf[0]) < 0) + if (make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf[0]) < 0) goto error; /* Create chunked datasets */ - if((chunked_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((chunked_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(chunked_dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(chunked_dcpl, RANK, chunk_dims) < 0) goto error; - if(make_dset(loc_id, CHUNKED_S_FIX, s_sid, chunked_dcpl, s_buf[0]) < 0) + if (make_dset(loc_id, CHUNKED_S_FIX, s_sid, chunked_dcpl, s_buf[0]) < 0) goto error; HDfree(s_buf); @@ -3352,55 +3297,56 @@ int make_layout2(hid_t loc_id) ret_value = 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(contig_dcpl); H5Pclose(chunked_dcpl); H5Sclose(s_sid); - - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(s_buf); - return(ret_value); + return (ret_value); } /* make_layout2() */ /*------------------------------------------------------------------------- -* Function: make_layout3 -* -* Purpose: make chunked datasets with unlimited max dim and chunk dim is -* bigger than current dim. (HDFFV-7933) -* Test for converting chunk to chunk , chunk to conti and chunk -* to compact. -* - The chunk to chunk changes layout bigger than any current dim -* again. -* - The chunk to compact test dataset bigger than 64K, should -* remain original layout.* -* -*------------------------------------------------------------------------- -*/ + * Function: make_layout3 + * + * Purpose: make chunked datasets with unlimited max dim and chunk dim is + * bigger than current dim. (HDFFV-7933) + * Test for converting chunk to chunk , chunk to conti and chunk + * to compact. + * - The chunk to chunk changes layout bigger than any current dim + * again. + * - The chunk to compact test dataset bigger than 64K, should + * remain original layout.* + * + *------------------------------------------------------------------------- + */ #define DIM1_L3 300 #define DIM2_L3 200 /* small size */ #define SDIM1_L3 4 #define SDIM2_L3 50 -static -int make_layout3(hid_t loc_id) +static int +make_layout3(hid_t loc_id) { - hid_t dcpl1=H5I_INVALID_HID; /* dataset creation property list */ - hid_t dcpl2=H5I_INVALID_HID; /* dataset creation property list */ - hid_t dcpl3=H5I_INVALID_HID; /* dataset creation property list */ - hid_t sid1=H5I_INVALID_HID; /* dataspace ID */ - hid_t sid2=H5I_INVALID_HID; /* dataspace ID */ - hsize_t dims1[RANK]={DIM1_L3,DIM2_L3}; - hsize_t dims2[RANK]={SDIM1_L3,SDIM2_L3}; - hsize_t maxdims[RANK]={H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims1[RANK]={DIM1_L3*2,5}; - hsize_t chunk_dims2[RANK]={SDIM1_L3 + 2, SDIM2_L3/2}; - hsize_t chunk_dims3[RANK]={SDIM1_L3 - 2, SDIM2_L3/2}; - int **buf1 = NULL; - int **buf2 = NULL; + hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list */ + hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list */ + hid_t dcpl3 = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid1 = H5I_INVALID_HID; /* dataspace ID */ + hid_t sid2 = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims1[RANK] = {DIM1_L3, DIM2_L3}; + hsize_t dims2[RANK] = {SDIM1_L3, SDIM2_L3}; + hsize_t maxdims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims1[RANK] = {DIM1_L3 * 2, 5}; + hsize_t chunk_dims2[RANK] = {SDIM1_L3 + 2, SDIM2_L3 / 2}; + hsize_t chunk_dims3[RANK] = {SDIM1_L3 - 2, SDIM2_L3 / 2}; + int ** buf1 = NULL; + int ** buf2 = NULL; /* Create and fill arrays */ H5TEST_ALLOCATE_2D_ARRAY(buf1, int, DIM1_L3, DIM2_L3); @@ -3413,77 +3359,76 @@ int make_layout3(hid_t loc_id) goto error; H5TEST_FILL_2D_ARRAY(buf2, int, SDIM1_L3, SDIM2_L3); - /*------------------------------------------------------------------------- - * make chunked dataset with - * - dset maxdims are UNLIMIT - * - a chunk dim is bigger than dset dim - * - dset size bigger than compact max (64K) - *------------------------------------------------------------------------- - */ + * make chunked dataset with + * - dset maxdims are UNLIMIT + * - a chunk dim is bigger than dset dim + * - dset size bigger than compact max (64K) + *------------------------------------------------------------------------- + */ /* create a space */ - if((sid1 = H5Screate_simple(RANK, dims1, maxdims)) < 0) + if ((sid1 = H5Screate_simple(RANK, dims1, maxdims)) < 0) goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl1, RANK, chunk_dims1) < 0) + if (H5Pset_chunk(dcpl1, RANK, chunk_dims1) < 0) goto error; if (make_dset(loc_id, "chunk_unlimit1", sid1, dcpl1, buf1[0]) < 0) goto error; /*------------------------------------------------------------------------- - * make chunked dataset with - * - dset maxdims are UNLIMIT - * - a chunk dim is bigger than dset dim - * - dset size smaller than compact (64K) - *------------------------------------------------------------------------- - */ + * make chunked dataset with + * - dset maxdims are UNLIMIT + * - a chunk dim is bigger than dset dim + * - dset size smaller than compact (64K) + *------------------------------------------------------------------------- + */ /* create a space */ - if((sid2 = H5Screate_simple(RANK, dims2, maxdims)) < 0) + if ((sid2 = H5Screate_simple(RANK, dims2, maxdims)) < 0) goto error; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl2, RANK, chunk_dims2) < 0) + if (H5Pset_chunk(dcpl2, RANK, chunk_dims2) < 0) goto error; if (make_dset(loc_id, "chunk_unlimit2", sid2, dcpl2, buf2[0]) < 0) goto error; /*------------------------------------------------------------------------- - * make chunked dataset with - * - dset maxdims are UNLIMIT - * - a chunk dims are smaller than dset dims - * - dset size smaller than compact (64K) - *------------------------------------------------------------------------- - */ + * make chunked dataset with + * - dset maxdims are UNLIMIT + * - a chunk dims are smaller than dset dims + * - dset size smaller than compact (64K) + *------------------------------------------------------------------------- + */ /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl3 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl3, RANK, chunk_dims3) < 0) + if (H5Pset_chunk(dcpl3, RANK, chunk_dims3) < 0) goto error; if (make_dset(loc_id, "chunk_unlimit3", sid2, dcpl3, buf2[0]) < 0) goto error; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid1) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid1) < 0) goto error; - if(H5Sclose(sid2) < 0) + if (H5Sclose(sid2) < 0) goto error; - if(H5Pclose(dcpl1) < 0) + if (H5Pclose(dcpl1) < 0) goto error; - if(H5Pclose(dcpl2) < 0) + if (H5Pclose(dcpl2) < 0) goto error; - if(H5Pclose(dcpl3) < 0) + if (H5Pclose(dcpl3) < 0) goto error; HDfree(buf1); @@ -3499,7 +3444,8 @@ error: H5Pclose(dcpl1); H5Pclose(dcpl2); H5Pclose(dcpl3); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf1); HDfree(buf2); @@ -3508,178 +3454,179 @@ error: } /*------------------------------------------------------------------------- -* Function: make a file with an integer dataset with a fill value -* -* Purpose: test copy of fill values -* -*------------------------------------------------------------------------- -*/ -static -int make_fill(hid_t loc_id) + * Function: make a file with an integer dataset with a fill value + * + * Purpose: test copy of fill values + * + *------------------------------------------------------------------------- + */ +static int +make_fill(hid_t loc_id) { - hid_t did=H5I_INVALID_HID; - hid_t sid=H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; hid_t dcpl; - hsize_t dims[2]={3,2}; - int buf[3][2]= {{1,1},{1,2},{2,2}}; + hsize_t dims[2] = {3, 2}; + int buf[3][2] = {{1, 1}, {1, 2}, {2, 2}}; int fillvalue = 2; /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0) goto out; - if((sid = H5Screate_simple(2,dims,NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) goto out; - if((did = H5Dcreate2(loc_id, "dset_fill", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "dset_fill", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- -* Function: make_big -* -* Purpose: used in test read by hyperslabs. Creates a 128MB dataset. -* Only 1 1024Kb hyperslab is written. -* -*------------------------------------------------------------------------- -*/ -static -int make_big(hid_t loc_id) + * Function: make_big + * + * Purpose: used in test read by hyperslabs. Creates a 128MB dataset. + * Only 1 1024Kb hyperslab is written. + * + *------------------------------------------------------------------------- + */ +static int +make_big(hid_t loc_id) { - hid_t did=H5I_INVALID_HID; - hid_t f_sid=H5I_INVALID_HID; - hid_t m_sid=H5I_INVALID_HID; - hid_t tid; - hid_t dcpl; - hsize_t dims[1]={ H5TOOLS_MALLOCSIZE + 1}; /* dataset dimensions */ - hsize_t hs_size[1]; /* hyperslab dimensions */ - hsize_t hs_start[1]; /* hyperslab start */ - hsize_t chunk_dims[1]={1024}; /* chunk dimensions */ - size_t size; - size_t nelmts=(size_t)1024; - signed char fillvalue=-1; - signed char *buf=NULL; + hid_t did = H5I_INVALID_HID; + hid_t f_sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t tid; + hid_t dcpl; + hsize_t dims[1] = {H5TOOLS_MALLOCSIZE + 1}; /* dataset dimensions */ + hsize_t hs_size[1]; /* hyperslab dimensions */ + hsize_t hs_start[1]; /* hyperslab start */ + hsize_t chunk_dims[1] = {1024}; /* chunk dimensions */ + size_t size; + size_t nelmts = (size_t)1024; + signed char fillvalue = -1; + signed char *buf = NULL; /* write one 1024 byte hyperslab */ hs_start[0] = 0; hs_size[0] = 1024; /* create */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_SCHAR, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_SCHAR, &fillvalue) < 0) goto out; - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dims) < 0) goto out; - if((f_sid = H5Screate_simple(1,dims,NULL)) < 0) + if ((f_sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; - if((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) + if ((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) goto out; - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((size = H5Tget_size(tid))<=0) + if ((size = H5Tget_size(tid)) <= 0) goto out; /* initialize buffer to 0 */ - buf=(signed char *) HDcalloc( nelmts, size); + buf = (signed char *)HDcalloc(nelmts, size); - if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size, NULL) < 0) + if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, hs_start, NULL, hs_size, NULL) < 0) goto out; - if (H5Dwrite (did,H5T_NATIVE_SCHAR,m_sid,f_sid,H5P_DEFAULT,buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_SCHAR, m_sid, f_sid, H5P_DEFAULT, buf) < 0) goto out; HDfree(buf); - buf=NULL; + buf = NULL; /* close */ - if(H5Sclose(f_sid) < 0) + if (H5Sclose(f_sid) < 0) goto out; - if(H5Sclose(m_sid) < 0) + if (H5Sclose(m_sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(f_sid); H5Sclose(m_sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } - /*------------------------------------------------------------------------- -* Function: make_external -* -* Purpose: create a external dataset -* -*------------------------------------------------------------------------- -*/ -static -int make_external(hid_t loc_id) + * Function: make_external + * + * Purpose: create a external dataset + * + *------------------------------------------------------------------------- + */ +static int +make_external(hid_t loc_id) { - hid_t did=H5I_INVALID_HID; - hid_t sid=H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; hid_t dcpl; - int buf[2]={1,2}; - hsize_t cur_size[1]; /* data space current size */ - hsize_t max_size[1]; /* data space maximum size */ + int buf[2] = {1, 2}; + hsize_t cur_size[1]; /* data space current size */ + hsize_t max_size[1]; /* data space maximum size */ hsize_t size; cur_size[0] = max_size[0] = 2; - size = max_size[0] * sizeof(int); + size = max_size[0] * sizeof(int); /* create */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_external(dcpl, H5REPACK_EXTFILE, (off_t)0, size) < 0) + if (H5Pset_external(dcpl, H5REPACK_EXTFILE, (off_t)0, size) < 0) goto out; - if((sid = H5Screate_simple(1,cur_size, max_size)) < 0) + if ((sid = H5Screate_simple(1, cur_size, max_size)) < 0) goto out; - if((did = H5Dcreate2(loc_id, "external", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "external", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; return 0; @@ -3690,51 +3637,50 @@ out: H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- -* Function: make_userblock -* -* Purpose: create a file for the userblock copying test -* -*------------------------------------------------------------------------- -*/ + * Function: make_userblock + * + * Purpose: create a file for the userblock copying test + * + *------------------------------------------------------------------------- + */ static int make_userblock(void) { - hid_t fid = H5I_INVALID_HID; - hid_t fcpl = H5I_INVALID_HID; - int fd = -1; /* File descriptor for writing userblock */ - char ub[USERBLOCK_SIZE]; /* User block data */ - ssize_t H5_ATTR_NDEBUG_UNUSED nwritten; /* # of bytes written */ - size_t u; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; + int fd = -1; /* File descriptor for writing userblock */ + char ub[USERBLOCK_SIZE]; /* User block data */ + ssize_t H5_ATTR_NDEBUG_UNUSED nwritten; /* # of bytes written */ + size_t u; /* Local index variable */ /* Create file creation property list with userblock set */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto out; - if(H5Pset_userblock(fcpl, (hsize_t)USERBLOCK_SIZE) < 0) + if (H5Pset_userblock(fcpl, (hsize_t)USERBLOCK_SIZE) < 0) goto out; /* Create file with userblock */ - if((fid = H5Fcreate(FNAME16, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME16, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto out; /* Close file creation property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto out; - /* Initialize userblock data */ - for(u = 0; u < USERBLOCK_SIZE; u++) + for (u = 0; u < USERBLOCK_SIZE; u++) ub[u] = (char)('a' + (char)(u % 26)); /* Re-open HDF5 file, as "plain" file */ - if((fd = HDopen(FNAME16, O_WRONLY)) < 0) + if ((fd = HDopen(FNAME16, O_WRONLY)) < 0) goto out; /* Write userblock data */ @@ -3747,58 +3693,59 @@ make_userblock(void) return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; - if(fd >= 0) + } + H5E_END_TRY; + if (fd >= 0) HDclose(fd); return -1; } /* end make_userblock() */ /*------------------------------------------------------------------------- -* Function: verify_userblock -* -* Purpose: Verify that the userblock was copied correctly -* -*------------------------------------------------------------------------- -*/ + * Function: verify_userblock + * + * Purpose: Verify that the userblock was copied correctly + * + *------------------------------------------------------------------------- + */ static int -verify_userblock( const char* filename) +verify_userblock(const char *filename) { - hid_t fid = H5I_INVALID_HID; - hid_t fcpl = H5I_INVALID_HID; - int fd = -1; /* File descriptor for writing userblock */ - char ub[USERBLOCK_SIZE]; /* User block data */ - hsize_t ub_size = 0; /* User block size */ - ssize_t H5_ATTR_NDEBUG_UNUSED nread; /* # of bytes read */ - size_t u; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; + int fd = -1; /* File descriptor for writing userblock */ + char ub[USERBLOCK_SIZE]; /* User block data */ + hsize_t ub_size = 0; /* User block size */ + ssize_t H5_ATTR_NDEBUG_UNUSED nread; /* # of bytes read */ + size_t u; /* Local index variable */ /* Open file with userblock */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto out; /* Retrieve file creation property list & userblock size */ - if((fcpl = H5Fget_create_plist(fid)) < 0) + if ((fcpl = H5Fget_create_plist(fid)) < 0) goto out; - if(H5Pget_userblock(fcpl, &ub_size) < 0) + if (H5Pget_userblock(fcpl, &ub_size) < 0) goto out; /* Verify userblock size is correct */ - if(ub_size != USERBLOCK_SIZE) + if (ub_size != USERBLOCK_SIZE) goto out; /* Close file creation property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto out; - /* Re-open HDF5 file, as "plain" file */ - if((fd = HDopen(filename, O_RDONLY)) < 0) + if ((fd = HDopen(filename, O_RDONLY)) < 0) goto out; /* Read userblock data */ @@ -3806,8 +3753,8 @@ verify_userblock( const char* filename) HDassert(nread == USERBLOCK_SIZE); /* Verify userblock data */ - for(u = 0; u < USERBLOCK_SIZE; u++) - if(ub[u] != (char)('a' + (u % 26))) + for (u = 0; u < USERBLOCK_SIZE; u++) + if (ub[u] != (char)('a' + (u % 26))) goto out; /* Close file */ @@ -3816,38 +3763,39 @@ verify_userblock( const char* filename) return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; - if(fd >= 0) + } + H5E_END_TRY; + if (fd >= 0) HDclose(fd); return -1; } /* end verify_userblock() */ - /*------------------------------------------------------------------------- -* Function: make_userblock_file -* -* Purpose: create a file for the userblock add test -* -*------------------------------------------------------------------------- -*/ + * Function: make_userblock_file + * + * Purpose: create a file for the userblock add test + * + *------------------------------------------------------------------------- + */ static int make_userblock_file(void) { - int fd = -1; /* File descriptor for writing userblock */ - char ub[USERBLOCK_SIZE]; /* User block data */ - ssize_t H5_ATTR_NDEBUG_UNUSED nwritten; /* # of bytes written */ - size_t u; /* Local index variable */ + int fd = -1; /* File descriptor for writing userblock */ + char ub[USERBLOCK_SIZE]; /* User block data */ + ssize_t H5_ATTR_NDEBUG_UNUSED nwritten; /* # of bytes written */ + size_t u; /* Local index variable */ /* initialize userblock data */ - for(u = 0; u < USERBLOCK_SIZE; u++) + for (u = 0; u < USERBLOCK_SIZE; u++) ub[u] = (char)('a' + (char)(u % 26)); /* open file */ - if((fd = HDopen(FNAME_UB, O_WRONLY|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + if ((fd = HDopen(FNAME_UB, O_WRONLY | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto out; /* write userblock data */ @@ -3861,147 +3809,135 @@ make_userblock_file(void) out: - if(fd >= 0) + if (fd >= 0) HDclose(fd); return -1; } /*------------------------------------------------------------------------- -* Function: write_dset_in -* -* Purpose: write datasets in LOC_ID -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ -static -int write_dset_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t file_id, - int make_diffs /* flag to modify data buffers */) + * Function: write_dset_in + * + * Purpose: write datasets in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ +static int +write_dset_in(hid_t loc_id, const char *dset_name, /* for saving reference to dataset*/ + hid_t file_id, int make_diffs /* flag to modify data buffers */) { /* compound datatype */ - typedef struct s_t - { + typedef struct s_t { char a; double b; } s_t; - typedef enum - { - RED, - GREEN - } e_t; - - hid_t did=H5I_INVALID_HID; - hid_t sid=H5I_INVALID_HID; - hid_t tid=H5I_INVALID_HID; - hid_t pid=H5I_INVALID_HID; + typedef enum { RED, GREEN } e_t; + + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t pid = H5I_INVALID_HID; unsigned i, j; - int val, k, n; - float f; + int val, k, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - hsize_t dims1r[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2]= {RED,GREEN}; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int buf7[2]= {1,2}; /* integer */ - float buf8[2]= {1,2}; /* float */ + hsize_t dims[1] = {2}; + hsize_t dims1r[1] = {2}; + char buf1[2][3] = {"ab", "de"}; /* string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2] = {RED, GREEN}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1, 2}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - hsize_t dims2r[2]={1,1}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[1][1]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ + hsize_t dims2[2] = {3, 2}; + hsize_t dims2r[2] = {1, 1}; + char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */ + hobj_ref_t buf42[1][1]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - hsize_t dims3r[3]={1,1,1}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[1][1][1]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - - /*------------------------------------------------------------------------- - * 1D - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + hsize_t dims3r[3] = {1, 1, 1}; + char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", + "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[1][1][1]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - + * H5T_STRING + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) - for(j = 0; j < 2; j++) + if (make_diffs) { + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) buf1[i][j] = 'z'; } - if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (write_dset(loc_id,1,dims,"string",tid,buf1) < 0) + if (write_dset(loc_id, 1, dims, "string", tid, buf1) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - /* create hard link */ if (H5Lcreate_hard(loc_id, "string", H5L_SAME_LOC, "string_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) + if (make_diffs) { + for (i = 0; i < 2; i++) buf2[i] = buf2[1] = 0; } if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (write_dset(loc_id,1,dims,"bitfield",tid,buf2) < 0) + if (write_dset(loc_id, 1, dims, "bitfield", tid, buf2) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) { + if (make_diffs) { + for (i = 0; i < 2; i++) { buf3[i].a = 0; buf3[i].b = 0; } @@ -4011,45 +3947,43 @@ int write_dset_in(hid_t loc_id, goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (write_dset(loc_id,1,dims,"opaque",tid,buf2) < 0) + if (write_dset(loc_id, 1, dims, "opaque", tid, buf2) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) + if (make_diffs) { + for (i = 0; i < 2; i++) buf45[i] = GREEN; } - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (write_dset(loc_id,1,dims,"compound",tid,buf3) < 0) + if (write_dset(loc_id, 1, dims, "compound", tid, buf3) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* object references ( H5R_OBJECT ) */ - buf4[0]=0; - buf4[1]=0; - if (dset_name) - { - if (H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + buf4[0] = 0; + buf4[1] = 0; + if (dset_name) { + if (H5Rcreate(&buf4[0], file_id, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; - if (write_dset(loc_id,1,dims1r,"refobj",H5T_STD_REF_OBJ,buf4) < 0) + if (write_dset(loc_id, 1, dims1r, "refobj", H5T_STD_REF_OBJ, buf4) < 0) goto out; } @@ -4057,38 +3991,37 @@ int write_dset_in(hid_t loc_id, if (make_dset_reg_ref(loc_id) < 0) goto out; - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (write_dset(loc_id,1,dims,"enum",tid,buf45) < 0) + if (write_dset(loc_id, 1, dims, "enum", tid, buf45) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf5[0].p)[0]=1; - buf5[1].len = 2; - buf5[1].p = HDmalloc( 2 * sizeof(int)); + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); ((int *)buf5[1].p)[0] = 2; ((int *)buf5[1].p)[1] = 3; - if(make_diffs) { + if (make_diffs) { ((int *)buf5[0].p)[0] = 0; ((int *)buf5[1].p)[0] = 0; ((int *)buf5[1].p)[1] = 0; @@ -4112,13 +4045,13 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) - for(j = 0; j < 3; j++) + if (make_diffs) { + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) buf6[i][j] = 0; } @@ -4131,27 +4064,26 @@ int write_dset_in(hid_t loc_id, { - hsize_t TEST_BUFSIZE = (128 * 1024 * 1024); /* 128MB */ - double *dbuf; /* information to write */ + hsize_t TEST_BUFSIZE = (128 * 1024 * 1024); /* 128MB */ + double * dbuf; /* information to write */ size_t size; hsize_t sdims[] = {1}; hsize_t tdims[] = {TEST_BUFSIZE / sizeof(double) + 1}; unsigned u; /* allocate and initialize array data to write */ - size = ( TEST_BUFSIZE / sizeof(double) + 1 ) * sizeof(double); - dbuf = (double*)HDmalloc( size ); - if (NULL == dbuf) - { - HDprintf ("\nError: Cannot allocate memory for \"arrayd\" data buffer size %dMB.\n", (int) size / 1000000 ); + size = (TEST_BUFSIZE / sizeof(double) + 1) * sizeof(double); + dbuf = (double *)HDmalloc(size); + if (NULL == dbuf) { + HDprintf("\nError: Cannot allocate memory for \"arrayd\" data buffer size %dMB.\n", + (int)size / 1000000); goto out; } - for( u = 0; u < TEST_BUFSIZE / sizeof(double) + 1; u++) + for (u = 0; u < TEST_BUFSIZE / sizeof(double) + 1; u++) dbuf[u] = u; - if (make_diffs) - { + if (make_diffs) { dbuf[5] = 0; dbuf[6] = 0; } @@ -4182,107 +4114,100 @@ int write_dset_in(hid_t loc_id, } /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) { + if (make_diffs) { + for (i = 0; i < 2; i++) { buf7[i] = 0; buf8[i] = 0; } } - if (write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7) < 0) + if (write_dset(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7) < 0) goto out; - if (write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8) < 0) + if (write_dset(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8) < 0) goto out; - /*------------------------------------------------------------------------- - * 2D - *------------------------------------------------------------------------- - */ + * 2D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ - if (make_diffs) - { + if (make_diffs) { HDmemset(buf12, 'z', sizeof buf12); } - if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (write_dset(loc_id,2,dims2,"string2D",tid,buf12) < 0) + if (write_dset(loc_id, 2, dims2, "string2D", tid, buf12) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf22,0,sizeof buf22); + if (make_diffs) { + HDmemset(buf22, 0, sizeof buf22); } if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22) < 0) + if (write_dset(loc_id, 2, dims2, "bitfield2D", tid, buf22) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (write_dset(loc_id,2,dims2,"opaque2D",tid,buf22) < 0) + if (write_dset(loc_id, 2, dims2, "opaque2D", tid, buf22) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf32,0,sizeof buf32); + if (make_diffs) { + HDmemset(buf32, 0, sizeof buf32); } - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (write_dset(loc_id,2,dims2,"compound2D",tid,buf32) < 0) + if (write_dset(loc_id, 2, dims2, "compound2D", tid, buf32) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* Create references to dataset */ - if (dset_name) - { + if (dset_name) { if (H5Rcreate(&buf42[0][0], file_id, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; if (write_dset(loc_id, 2, dims2r, "refobj2D", H5T_STD_REF_OBJ, buf42) < 0) @@ -4290,36 +4215,36 @@ int write_dset_in(hid_t loc_id, } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (write_dset(loc_id,2,dims2,"enum2D",tid,0) < 0) + if (write_dset(loc_id, 2, dims2, "enum2D", tid, 0) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { unsigned l; - buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) { - if(make_diffs) + for (l = 0; l < i + 1; l++) { + if (make_diffs) ((int *)buf52[i][j].p)[l] = 0; else ((int *)buf52[i][j].p)[l] = n++; @@ -4345,16 +4270,14 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf62,0,sizeof buf62); + if (make_diffs) { + HDmemset(buf62, 0, sizeof buf62); } - if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) goto out; if (write_dset(loc_id, 2, dims2, "array2D", tid, buf62) < 0) @@ -4363,17 +4286,15 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ - + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ - if(make_diffs) { + if (make_diffs) { HDmemset(buf72, 0, sizeof buf72); HDmemset(buf82, 0, sizeof buf82); } - if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) @@ -4390,49 +4311,46 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_FLOAT + *------------------------------------------------------------------------- + */ - if (write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82) < 0) + if (write_dset(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82) < 0) goto out; - /*------------------------------------------------------------------------- - * 3D - *------------------------------------------------------------------------- - */ + * 3D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf13,'z',sizeof buf13); + if (make_diffs) { + HDmemset(buf13, 'z', sizeof buf13); } if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (write_dset(loc_id,3,dims3,"string3D",tid,buf13) < 0) + if (write_dset(loc_id, 3, dims3, "string3D", tid, buf13) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - if(make_diffs) + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) buf23[i][j][k] = 0; else buf23[i][j][k] = (char)(n++); @@ -4440,37 +4358,36 @@ int write_dset_in(hid_t loc_id, } } - if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23) < 0) + if (write_dset(loc_id, 3, dims3, "bitfield3D", tid, buf23) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (write_dset(loc_id,3,dims3,"opaque3D",tid,buf23) < 0) + if (write_dset(loc_id, 3, dims3, "opaque3D", tid, buf23) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - if(make_diffs) { + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { buf33[i][j][k].a = 0; buf33[i][j][k].b = 0; } @@ -4482,25 +4399,23 @@ int write_dset_in(hid_t loc_id, } } - - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (write_dset(loc_id,3,dims3,"compound3D",tid,buf33) < 0) + if (write_dset(loc_id, 3, dims3, "compound3D", tid, buf33) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* Create references to dataset */ - if (dset_name) - { + if (dset_name) { if (H5Rcreate(&buf43[0][0][0], file_id, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; if (write_dset(loc_id, 3, dims3r, "refobj3D", H5T_STD_REF_OBJ, buf43) < 0) @@ -4508,37 +4423,37 @@ int write_dset_in(hid_t loc_id, } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (write_dset(loc_id,3,dims3,"enum3D",tid,0) < 0) + if (write_dset(loc_id, 3, dims3, "enum3D", tid, 0) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { unsigned l; - buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) { - if(make_diffs) + for (l = 0; l < i + 1; l++) { + if (make_diffs) ((int *)buf53[i][j][k].p)[l] = 0; else ((int *)buf53[i][j][k].p)[l] = n++; @@ -4567,15 +4482,14 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - + * H5T_ARRAY + *------------------------------------------------------------------------- + */ n = 1; - for(i = 0; i < 24; i++) { - for(j = 0; j < dimarray[0]; j++) { - if(make_diffs) + for (i = 0; i < 24; i++) { + for (j = 0; j < dimarray[0]; j++) { + if (make_diffs) buf63[i][j] = 0; else buf63[i][j] = n++; @@ -4590,76 +4504,77 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - n=1; f=1; + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ + n = 1; + f = 1; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { for (k = 0; k < 2; k++) { if (make_diffs) { - buf73[i][j][k]=0; - buf83[i][j][k]=0; + buf73[i][j][k] = 0; + buf83[i][j][k] = 0; } else { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; + buf73[i][j][k] = n++; + buf83[i][j][k] = f++; } } } } - if (write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73) < 0) + if (write_dset(loc_id, 3, dims3, "integer3D", H5T_NATIVE_INT, buf73) < 0) goto out; - if (write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0) + if (write_dset(loc_id, 3, dims3, "float3D", H5T_NATIVE_FLOAT, buf83) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Sclose(sid); H5Dclose(did); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - /*------------------------------------------------------------------------- -* Function: make_dset_reg_ref -* -* Purpose: write dataset region references -* -*------------------------------------------------------------------------- -*/ + * Function: make_dset_reg_ref + * + * Purpose: write dataset region references + * + *------------------------------------------------------------------------- + */ #define SPACE1_RANK 1 #define SPACE1_DIM1 1 #define SPACE2_RANK 2 #define SPACE2_DIM1 10 #define SPACE2_DIM2 10 -static -int make_dset_reg_ref(hid_t loc_id) +static int +make_dset_reg_ref(hid_t loc_id) { - hid_t did1=H5I_INVALID_HID; /* Dataset ID */ - hid_t did2=H5I_INVALID_HID; /* Dereferenced dataset ID */ - hid_t sid1=H5I_INVALID_HID; /* Dataspace ID #1 */ - hid_t sid2=H5I_INVALID_HID; /* Dataspace ID #2 */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hdset_reg_ref_t *wbuf=NULL; /* buffer to write to disk */ - int *dwbuf=NULL; /* Buffer for writing numeric data to disk */ - int i; /* counting variables */ - int retval = -1; /* return value */ + hid_t did1 = H5I_INVALID_HID; /* Dataset ID */ + hid_t did2 = H5I_INVALID_HID; /* Dereferenced dataset ID */ + hid_t sid1 = H5I_INVALID_HID; /* Dataspace ID #1 */ + hid_t sid2 = H5I_INVALID_HID; /* Dataspace ID #2 */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hdset_reg_ref_t *wbuf = NULL; /* buffer to write to disk */ + int * dwbuf = NULL; /* Buffer for writing numeric data to disk */ + int i; /* counting variables */ + int retval = -1; /* return value */ /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); dwbuf = (int *)HDmalloc(sizeof(int) * SPACE2_DIM1 * SPACE2_DIM2); /* Create dataspace for datasets */ @@ -4667,7 +4582,8 @@ int make_dset_reg_ref(hid_t loc_id) goto out; /* Create a dataset */ - if ((did2 = H5Dcreate2(loc_id, "dsetreg", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(loc_id, "dsetreg", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto out; for (i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) @@ -4682,24 +4598,28 @@ int make_dset_reg_ref(hid_t loc_id) goto out; /* Create a dataset */ - if ((did1 = H5Dcreate2(loc_id, "refreg", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(loc_id, "refreg", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto out; /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 6; - block[0] = 1; block[1] = 1; + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 6; + block[0] = 1; + block[1] = 1; if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0) goto out; - /* Store dataset region */ if (H5Rcreate(&wbuf[0], loc_id, "dsetreg", H5R_DATASET_REGION, sid2) < 0) goto out; /* Write selection to disk */ - if (H5Dwrite(did1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf) < 0) + if (H5Dwrite(did1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) goto out; /* Close all objects */ @@ -4715,9 +4635,9 @@ int make_dset_reg_ref(hid_t loc_id) retval = 0; out: - if(wbuf) + if (wbuf) HDfree(wbuf); - if(dwbuf) + if (dwbuf) HDfree(dwbuf); H5E_BEGIN_TRY @@ -4726,105 +4646,96 @@ out: H5Sclose(sid2); H5Dclose(did1); H5Dclose(did2); - } H5E_END_TRY; + } + H5E_END_TRY; return retval; } /*------------------------------------------------------------------------- -* Function: write_attr_in -* -* Purpose: write attributes in LOC_ID (dataset, group, named datatype) -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ - -static -int write_attr_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid, /* for reference create */ - int make_diffs /* flag to modify data buffers */) + * Function: write_attr_in + * + * Purpose: write attributes in LOC_ID (dataset, group, named datatype) + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ + +static int +write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to dataset*/ + hid_t fid, /* for reference create */ + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ - typedef struct s_t - { + typedef struct s_t { char a; double b; } s_t; - typedef enum - { - RED, - GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t aid = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; - hid_t tid = H5I_INVALID_HID; - int val, j, k, n; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + int val, j, k, n; unsigned i; - float f; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2]= {RED,RED}; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int buf7[2]= {1,2}; /* integer */ - float buf8[2]= {1,2}; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][3] = {"ab", "de"}; /* string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2] = {RED, RED}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1, 2}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - e_t buf452[3][2]; /* enum */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + e_t buf452[3][2]; /* enum */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - e_t buf453[4][3][2]; /* enum */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - - /*------------------------------------------------------------------------- - * 1D attributes - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", + "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - for (i=0; i<2; i++) - for (j=0; j<2; j++) - { - buf1[i][j]='z'; + if (make_diffs) { + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) { + buf1[i][j] = 'z'; } } /* @@ -4843,21 +4754,20 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (make_attr(loc_id,1,dims,"string",tid,buf1) < 0) + if (make_attr(loc_id, 1, dims, "string", tid, buf1) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - for (i=0; i<2; i++) - buf2[i]=buf2[1]=0; + if (make_diffs) { + for (i = 0; i < 2; i++) + buf2[i] = buf2[1] = 0; } /* buf2[2]= {1,2}; @@ -4873,16 +4783,16 @@ int write_attr_in(hid_t loc_id, if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (make_attr(loc_id,1,dims,"bitfield",tid,buf2) < 0) + if (make_attr(loc_id, 1, dims, "bitfield", tid, buf2) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf2[2]= {1,2}; @@ -4900,22 +4810,21 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (make_attr(loc_id,1,dims,"opaque",tid,buf2) < 0) + if (make_attr(loc_id, 1, dims, "opaque", tid, buf2) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - for (i=0; i<2; i++) - { - buf3[i].a=0; buf3[i].b=0; + if (make_diffs) { + for (i = 0; i < 2; i++) { + buf3[i].a = 0; + buf3[i].b = 0; } } @@ -4932,43 +4841,39 @@ int write_attr_in(hid_t loc_id, [ 1 ] 4 5 1 */ - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (make_attr(loc_id,1,dims,"compound",tid,buf3) < 0) + if (make_attr(loc_id, 1, dims, "compound", tid, buf3) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* object references ( H5R_OBJECT */ - if (dset_name) - { - if (H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + if (dset_name) { + if (H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; - if (H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + if (H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; - if (make_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4) < 0) + if (make_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4) < 0) goto out; } - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - if (make_diffs) - { - for (i=0; i<2; i++) - { - buf45[i]=GREEN; + * H5T_ENUM + *------------------------------------------------------------------------- + */ + if (make_diffs) { + for (i = 0; i < 2; i++) { + buf45[i] = GREEN; } } /* @@ -4983,33 +4888,32 @@ int write_attr_in(hid_t loc_id, */ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (make_attr(loc_id,1,dims,"enum",tid,buf45) < 0) + if (make_attr(loc_id, 1, dims, "enum", tid, buf45) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf5[0].p)[0]=1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); ((int *)buf5[1].p)[0] = 2; ((int *)buf5[1].p)[1] = 3; - if(make_diffs) - { + if (make_diffs) { ((int *)buf5[0].p)[0] = 0; ((int *)buf5[1].p)[0] = 0; ((int *)buf5[1].p)[1] = 0; @@ -5045,16 +4949,14 @@ int write_attr_in(hid_t loc_id, sid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - for (i=0; i<2; i++) - for (j=0; j<3; j++) - { - buf6[i][j]=0; + if (make_diffs) { + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) { + buf6[i][j] = 0; } } /* @@ -5080,16 +4982,14 @@ int write_attr_in(hid_t loc_id, tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ - if(make_diffs) - { - for(i = 0; i < 2; i++) - { - buf7[i]=0; - buf8[i]=0; + if (make_diffs) { + for (i = 0; i < 2; i++) { + buf7[i] = 0; + buf8[i] = 0; } } @@ -5107,23 +5007,21 @@ int write_attr_in(hid_t loc_id, [ 0 ] 1 0 1 [ 1 ] 2 0 2 */ - if (make_attr(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7) < 0) + if (make_attr(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7) < 0) goto out; - if (make_attr(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8) < 0) + if (make_attr(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8) < 0) goto out; - /*------------------------------------------------------------------------- - * 2D attributes - *------------------------------------------------------------------------- - */ + * 2D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - if (make_diffs) - { + * H5T_STRING + *------------------------------------------------------------------------- + */ + if (make_diffs) { HDmemset(buf12, 'z', sizeof buf12); } @@ -5151,20 +5049,19 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (make_attr(loc_id,2,dims2,"string2D",tid,buf12) < 0) + if (make_attr(loc_id, 2, dims2, "string2D", tid, buf12) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf22,0,sizeof buf22); + if (make_diffs) { + HDmemset(buf22, 0, sizeof buf22); } /* @@ -5181,19 +5078,18 @@ int write_attr_in(hid_t loc_id, [ 2 1 ] 6 0 6 */ - if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (make_attr(loc_id,2,dims2,"bitfield2D",tid,buf22) < 0) + if (make_attr(loc_id, 2, dims2, "bitfield2D", tid, buf22) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf22[3][2]= {{1,2},{3,4},{5,6}}; @@ -5212,19 +5108,18 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (make_attr(loc_id,2,dims2,"opaque2D",tid,buf22) < 0) + if (make_attr(loc_id, 2, dims2, "opaque2D", tid, buf22) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - if (make_diffs) - { - HDmemset(buf32,0,sizeof buf32); + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + if (make_diffs) { + HDmemset(buf32, 0, sizeof buf32); } /* @@ -5241,47 +5136,44 @@ int write_attr_in(hid_t loc_id, [ 2 1 ] 6 0 6 */ - - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (make_attr(loc_id,2,dims2,"compound2D",tid,buf32) < 0) + if (make_attr(loc_id, 2, dims2, "compound2D", tid, buf32) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* Create references to dataset */ - if (dset_name) - { - for (i = 0; i < 3; i++) - { - for (j = 0; j < 2; j++) - { - if (H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + if (dset_name) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + if (H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; } } - if (make_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42) < 0) + if (make_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42) < 0) goto out; } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - for (i=0; i<3; i++) - { - for (j=0; j<2; j++) - { - if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=RED; + * H5T_ENUM + *------------------------------------------------------------------------- + */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + if (make_diffs) + buf452[i][j] = GREEN; + else + buf452[i][j] = RED; } } @@ -5299,31 +5191,31 @@ int write_attr_in(hid_t loc_id, if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (make_attr(loc_id,2,dims2,"enum2D",tid,buf452) < 0) + if (make_attr(loc_id, 2, dims2, "enum2D", tid, buf452) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - n=0; - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { + n = 0; + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { unsigned l; - buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) - if(make_diffs) + for (l = 0; l < i + 1; l++) + if (make_diffs) ((int *)buf52[i][j].p)[l] = 0; else ((int *)buf52[i][j].p)[l] = n++; @@ -5367,13 +5259,12 @@ int write_attr_in(hid_t loc_id, sid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf62,0,sizeof buf62); + if (make_diffs) { + HDmemset(buf62, 0, sizeof buf62); } /* buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; @@ -5410,12 +5301,11 @@ int write_attr_in(hid_t loc_id, tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ - if(make_diffs) - { + if (make_diffs) { HDmemset(buf72, 0, sizeof buf72); HDmemset(buf82, 0, sizeof buf82); } @@ -5441,25 +5331,23 @@ int write_attr_in(hid_t loc_id, [ 2 1 ] 6 0 6 */ - if (make_attr(loc_id,2,dims2,"integer2D",H5T_NATIVE_INT,buf72) < 0) + if (make_attr(loc_id, 2, dims2, "integer2D", H5T_NATIVE_INT, buf72) < 0) goto out; - if (make_attr(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82) < 0) + if (make_attr(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82) < 0) goto out; - /*------------------------------------------------------------------------- - * 3D attributes - *------------------------------------------------------------------------- - */ + * 3D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf13,'z',sizeof buf13); + if (make_diffs) { + HDmemset(buf13, 'z', sizeof buf13); } /* @@ -5523,22 +5411,22 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (make_attr(loc_id,3,dims3,"string3D",tid,buf13) < 0) + if (make_attr(loc_id, 3, dims3, "string3D", tid, buf13) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - if(make_diffs) + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) buf23[i][j][k] = 0; else buf23[i][j][k] = (char)(n++); @@ -5577,36 +5465,36 @@ int write_attr_in(hid_t loc_id, if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (make_attr(loc_id,3,dims3,"bitfield3D",tid,buf23) < 0) + if (make_attr(loc_id, 3, dims3, "bitfield3D", tid, buf23) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (make_attr(loc_id,3,dims3,"opaque3D",tid,buf23) < 0) + if (make_attr(loc_id, 3, dims3, "opaque3D", tid, buf23) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - if(make_diffs) { + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { buf33[i][j][k].a = 0; buf33[i][j][k].b = 0; } @@ -5669,58 +5557,48 @@ int write_attr_in(hid_t loc_id, [ 3 2 1 ] 48 0 48 */ - - - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (make_attr(loc_id,3,dims3,"compound3D",tid,buf33) < 0) + if (make_attr(loc_id, 3, dims3, "compound3D", tid, buf33) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* Create references to dataset */ - if (dset_name) - { - for (i = 0; i < 4; i++) - { - for (j = 0; j < 3; j++) - { + if (dset_name) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { for (k = 0; k < 2; k++) - if (H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + if (H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; } } - if (make_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43) < 0) + if (make_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43) < 0) goto out; } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ - for (i = 0; i < 4; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 2; k++) - { - if (make_diffs) - { - buf453[i][j][k]=RED; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { + buf453[i][j][k] = RED; } - else - { - buf453[i][j][k]=GREEN; + else { + buf453[i][j][k] = GREEN; } } } @@ -5755,35 +5633,31 @@ int write_attr_in(hid_t loc_id, [ 3 2 1 ] GREEN RED */ - if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (make_attr(loc_id,3,dims3,"enum3D",tid,buf453) < 0) + if (make_attr(loc_id, 3, dims3, "enum3D", tid, buf453) < 0) goto out; if (H5Tclose(tid) < 0) goto out; tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - n=0; - for (i = 0; i < 4; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 2; k++) - { + n = 0; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { unsigned l; - buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)i + 1; for (l = 0; l < i + 1; l++) if (make_diffs) @@ -5829,16 +5703,16 @@ int write_attr_in(hid_t loc_id, sid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - n=1; - for (i = 0; i < 24; i++) - { - for (j = 0; j < (int)dimarray[0]; j++) - { - if (make_diffs) buf63[i][j]=0; - else buf63[i][j]=n++; + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + n = 1; + for (i = 0; i < 24; i++) { + for (j = 0; j < (int)dimarray[0]; j++) { + if (make_diffs) + buf63[i][j] = 0; + else + buf63[i][j] = n++; } } /* @@ -5863,23 +5737,19 @@ int write_attr_in(hid_t loc_id, tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - n = 1; f = 1; - for(i = 0; i < 4; i++) - { - for(j = 0; j < 3; j++) - { - for(k = 0; k < 2; k++) - { - if(make_diffs) - { + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ + n = 1; + f = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { buf73[i][j][k] = 0; buf83[i][j][k] = 0; } - else - { + else { buf73[i][j][k] = n++; buf83[i][j][k] = f++; } @@ -5902,45 +5772,39 @@ int write_attr_in(hid_t loc_id, [ 1 1 1 ] 10 0 10 etc */ - if (make_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73) < 0) + if (make_attr(loc_id, 3, dims3, "integer3D", H5T_NATIVE_INT, buf73) < 0) goto out; - if (make_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0) + if (make_attr(loc_id, 3, dims3, "float3D", H5T_NATIVE_FLOAT, buf83) < 0) goto out; - return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Sclose(sid); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - - /*------------------------------------------------------------------------- -* Function: make_dset -* -* Purpose: utility function to create and write a dataset in LOC_ID -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ -static -int make_dset(hid_t loc_id, - const char *name, - hid_t sid, - hid_t dcpl, - void *buf) + * Function: make_dset + * + * Purpose: utility function to create and write a dataset in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ +static int +make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t dcpl, void *buf) { - hid_t did=H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; if ((did = H5Dcreate2(loc_id, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; @@ -5951,42 +5815,37 @@ int make_dset(hid_t loc_id, return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: write_dset -* -* Purpose: utility function to create and write a dataset in LOC_ID -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ -static -int write_dset( hid_t loc_id, - int rank, - hsize_t *dims, - const char *dset_name, - hid_t tid, - void *buf ) + * Function: write_dset + * + * Purpose: utility function to create and write a dataset in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ +static int +write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf) { - hid_t did=H5I_INVALID_HID; - hid_t sid=H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if (buf) - { - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (buf) { + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; } if (H5Dclose(did) < 0) @@ -5997,44 +5856,38 @@ int write_dset( hid_t loc_id, return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - /*------------------------------------------------------------------------- -* Function: make_attr -* -* Purpose: utility function to write an attribute in LOC_ID -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ -static -int make_attr(hid_t loc_id, - int rank, - hsize_t *dims, - const char *attr_name, - hid_t tid, - void *buf) + * Function: make_attr + * + * Purpose: utility function to write an attribute in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ +static int +make_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, hid_t tid, void *buf) { - hid_t aid; - hid_t sid; + hid_t aid; + hid_t sid; if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; if ((aid = H5Acreate2(loc_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(buf) - { - if(H5Awrite(aid, tid, buf) < 0) + if (buf) { + if (H5Awrite(aid, tid, buf) < 0) goto out; } if (H5Aclose(aid) < 0) @@ -6044,119 +5897,120 @@ int make_attr(hid_t loc_id, return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_named_dtype -* -* Purpose: create a file with named datatypes in various configurations -* -*------------------------------------------------------------------------- -*/ -static -int make_named_dtype(hid_t loc_id) + * Function: make_named_dtype + * + * Purpose: create a file with named datatypes in various configurations + * + *------------------------------------------------------------------------- + */ +static int +make_named_dtype(hid_t loc_id) { - hsize_t dims[1] ={3}; - hid_t did=H5I_INVALID_HID; - hid_t aid=H5I_INVALID_HID; - hid_t sid=H5I_INVALID_HID; - hid_t tid=H5I_INVALID_HID; - hid_t gid=H5I_INVALID_HID; + hsize_t dims[1] = {3}; + hid_t did = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* Create a dataset with an anonymous committed datatype as the first thing * h5repack sees */ - if((tid = H5Tcopy(H5T_STD_I16LE)) < 0) + if ((tid = H5Tcopy(H5T_STD_I16LE)) < 0) goto out; - if(H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; if ((did = H5Dcreate2(loc_id, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; /* Create an attribute on that dataset that uses a committed datatype in * a remote group */ - if((gid = H5Gcreate2(loc_id, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(loc_id, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - if((gid = H5Gcreate2(loc_id, "M/M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(loc_id, "M/M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - if((tid = H5Tcopy(H5T_STD_I16BE)) < 0) + if ((tid = H5Tcopy(H5T_STD_I16BE)) < 0) goto out; - if(H5Tcommit2(loc_id, "/M/M/A", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(loc_id, "/M/M/A", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - if((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /* Create a dataset in the remote group that uses a committed datatype in * the root group */ - if((tid = H5Tcopy(H5T_STD_I32LE)) < 0) + if ((tid = H5Tcopy(H5T_STD_I32LE)) < 0) goto out; - if(H5Tcommit2(loc_id, "N", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(loc_id, "N", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - if((did = H5Dcreate2(loc_id, "M/M/B", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "M/M/B", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; /* Create an attribute on the remote dataset that uses an anonymous * committed datatype */ - if((tid = H5Tcopy(H5T_STD_I32BE)) < 0) + if ((tid = H5Tcopy(H5T_STD_I32BE)) < 0) goto out; - if(H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - if((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; /* Create another attribute that uses the same anonymous datatype */ - if((aid = H5Acreate2(did, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /* Create a dataset in the root group that uses the committed datatype in * the root group */ - if((tid = H5Topen2(loc_id, "N", H5P_DEFAULT)) < 0) + if ((tid = H5Topen2(loc_id, "N", H5P_DEFAULT)) < 0) goto out; - if((did = H5Dcreate2(loc_id, "O", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "O", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /* Create 2 attributes on the committed datatype that use that datatype */ - if((aid = H5Acreate2(tid, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(tid, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if((aid = H5Acreate2(tid, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(tid, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; /* Close */ @@ -6173,7 +6027,8 @@ out: H5Sclose(sid); H5Dclose(did); H5Gclose(gid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end make_named_dtype() */ @@ -6190,48 +6045,45 @@ out: * * Programmer: Jonathan Kim (March 23, 2010) *------------------------------------------------------------------------*/ -static herr_t add_attr_with_objref(hid_t file_id, hid_t obj_id) +static herr_t +add_attr_with_objref(hid_t file_id, hid_t obj_id) { int ret = SUCCEED; int status; /* attr obj ref */ - hsize_t dim_attr_objref[1]={3}; + hsize_t dim_attr_objref[1] = {3}; hobj_ref_t data_attr_objref[3]; /* -------------------------------- * add attribute with obj ref type */ /* ref to dset */ - status = H5Rcreate(&data_attr_objref[0],file_id,NAME_OBJ_DS1,H5R_OBJECT,(hid_t)-1); - if (status < 0) - { + status = H5Rcreate(&data_attr_objref[0], file_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* ref to group */ - status = H5Rcreate(&data_attr_objref[1],file_id,NAME_OBJ_GRP,H5R_OBJECT,(hid_t)-1); - if (status < 0) - { + status = H5Rcreate(&data_attr_objref[1], file_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* ref to datatype */ - status = H5Rcreate(&data_attr_objref[2],file_id,NAME_OBJ_NDTYPE,H5R_OBJECT,(hid_t)-1); - if (status < 0) - { + status = H5Rcreate(&data_attr_objref[2], file_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create attr with obj ref type */ - status = make_attr(obj_id,1,dim_attr_objref,"Attr_OBJREF",H5T_STD_REF_OBJ,data_attr_objref); - if (status < 0) - { + status = make_attr(obj_id, 1, dim_attr_objref, "Attr_OBJREF", H5T_STD_REF_OBJ, data_attr_objref); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> make_attr failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6240,7 +6092,6 @@ static herr_t add_attr_with_objref(hid_t file_id, hid_t obj_id) out: return ret; - } /*------------------------------------------------------------------------- @@ -6255,52 +6106,48 @@ out: * * Programmer: Jonathan Kim (March 23, 2010) *------------------------------------------------------------------------*/ -static herr_t add_attr_with_regref(hid_t file_id, hid_t obj_id) +static herr_t +add_attr_with_regref(hid_t file_id, hid_t obj_id) { int ret = SUCCEED; int status; /* attr region ref */ - hid_t sid_regrefed_dset=0; - hsize_t dim_regrefed_dset[2]={3,6}; - hsize_t coords_regrefed_dset[3][2] = {{0,1},{1,2},{2,3}}; - hsize_t dim_attr_regref[1]= {1}; /* dim of */ + hid_t sid_regrefed_dset = 0; + hsize_t dim_regrefed_dset[2] = {3, 6}; + hsize_t coords_regrefed_dset[3][2] = {{0, 1}, {1, 2}, {2, 3}}; + hsize_t dim_attr_regref[1] = {1}; /* dim of */ hdset_reg_ref_t data_attr_regref[1]; - /* ----------------------------------- * add attribute with region ref type */ - sid_regrefed_dset = H5Screate_simple (2, dim_regrefed_dset, NULL); - if (sid_regrefed_dset < 0) - { + sid_regrefed_dset = H5Screate_simple(2, dim_regrefed_dset, NULL); + if (sid_regrefed_dset < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select elements space for reference */ - status = H5Sselect_elements (sid_regrefed_dset, H5S_SELECT_SET, (size_t)3, coords_regrefed_dset[0]); - if (status < 0) - { + status = H5Sselect_elements(sid_regrefed_dset, H5S_SELECT_SET, (size_t)3, coords_regrefed_dset[0]); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference from elements space */ - status = H5Rcreate (&data_attr_regref[0], file_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_regrefed_dset); - if (status < 0) - { + status = H5Rcreate(&data_attr_regref[0], file_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_regrefed_dset); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create attr with region ref type */ - status = make_attr(obj_id,1,dim_attr_regref,"Attr_REGREF",H5T_STD_REF_DSETREG,data_attr_regref); - if (status < 0) - { + status = make_attr(obj_id, 1, dim_attr_regref, "Attr_REGREF", H5T_STD_REF_DSETREG, data_attr_regref); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> make_attr failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6308,10 +6155,9 @@ static herr_t add_attr_with_regref(hid_t file_id, hid_t obj_id) out: if (sid_regrefed_dset > 0) - H5Sclose (sid_regrefed_dset); + H5Sclose(sid_regrefed_dset); return ret; - } /*------------------------------------------------------------------------- @@ -6325,44 +6171,42 @@ out: * * Programmer: Jonathan Kim (March 23, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_refered_objs(hid_t loc_id) +static herr_t +gen_refered_objs(hid_t loc_id) { - int status; + int status; herr_t ret = SUCCEED; /* objects (dset, group, datatype) */ - hid_t sid=0, did1=0, gid=0, tid=0; - hsize_t dims1[1]={3}; - int data[3] = {10,20,30}; + hid_t sid = 0, did1 = 0, gid = 0, tid = 0; + hsize_t dims1[1] = {3}; + int data[3] = {10, 20, 30}; /* Dset2 */ - hid_t sid2=0, did2=0; - hsize_t dims2[2] = {3,16}; - char data2[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; + hid_t sid2 = 0, did2 = 0; + hsize_t dims2[2] = {3, 16}; + char data2[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; /*----------------------- * add short dataset * (define NAME_OBJ_DS1) */ sid = H5Screate_simple(1, dims1, NULL); - if (sid < 0) - { + if (sid < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - did1 = H5Dcreate2 (loc_id, NAME_OBJ_DS1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (did1 < 0) - { + did1 = H5Dcreate2(loc_id, NAME_OBJ_DS1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did1 < 0) { HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } status = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6372,9 +6216,8 @@ static herr_t gen_refered_objs(hid_t loc_id) * add group * (define NAME_OBJ_GRP) */ - gid = H5Gcreate2 (loc_id, NAME_OBJ_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid < 0) - { + gid = H5Gcreate2(loc_id, NAME_OBJ_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (gid < 0) { HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6384,62 +6227,56 @@ static herr_t gen_refered_objs(hid_t loc_id) * add named datatype * (define NAME_OBJ_NDTYPE) */ - tid = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(loc_id, NAME_OBJ_NDTYPE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + tid = H5Tcopy(H5T_NATIVE_INT); + status = H5Tcommit2(loc_id, NAME_OBJ_NDTYPE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; - } - + } - /*-------------------------- - * create long dataset - * (define NAME_OBJ_DS2) - */ - sid2 = H5Screate_simple (2, dims2, NULL); - if (sid2 < 0) - { + /*-------------------------- + * create long dataset + * (define NAME_OBJ_DS2) + */ + sid2 = H5Screate_simple(2, dims2, NULL); + if (sid2 < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create normal dataset which is refered */ - did2 = H5Dcreate2 (loc_id, NAME_OBJ_DS2, H5T_STD_I8LE, sid2, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (did2 < 0) - { + did2 = H5Dcreate2(loc_id, NAME_OBJ_DS2, H5T_STD_I8LE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did2 < 0) { HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* write values to dataset */ - status = H5Dwrite (did2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); - if (status < 0) - { + status = H5Dwrite(did2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: - if(did1 > 0) + if (did1 > 0) H5Dclose(did1); - if(gid > 0) + if (gid > 0) H5Gclose(gid); - if(tid > 0) + if (tid > 0) H5Tclose(tid); - if(sid > 0) + if (sid > 0) H5Sclose(sid); - if(did2 > 0) + if (did2 > 0) H5Dclose(did2); - if(sid2 > 0) + if (sid2 > 0) H5Sclose(sid2); return ret; - } /*------------------------------------------------------------------------- @@ -6453,17 +6290,18 @@ out: * * Programmer: Jonathan Kim (March 18, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_obj_ref(hid_t loc_id) +static herr_t +gen_obj_ref(hid_t loc_id) { - int status; + int status; herr_t ret = SUCCEED; - hid_t sid=0, oid=0; - hsize_t dims_dset_objref[1]={3}; + hid_t sid = 0, oid = 0; + hsize_t dims_dset_objref[1] = {3}; /* attr with int type */ - hsize_t dim_attr_int[1]={2}; - int data_attr_int[2] = {10,20}; + hsize_t dim_attr_int[1] = {2}; + int data_attr_int[2] = {10, 20}; /* write buffer for obj reference */ hobj_ref_t objref_buf[3]; @@ -6473,27 +6311,24 @@ static herr_t gen_obj_ref(hid_t loc_id) * Passing -1 as reference is an object.*/ /* obj ref to dataset */ - status = H5Rcreate (&objref_buf[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { + status = H5Rcreate(&objref_buf[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* obj ref to group */ - status = H5Rcreate (&objref_buf[1], loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { + status = H5Rcreate(&objref_buf[1], loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* obj ref to named-datatype */ - status = H5Rcreate (&objref_buf[2], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { + status = H5Rcreate(&objref_buf[2], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6502,38 +6337,34 @@ static herr_t gen_obj_ref(hid_t loc_id) /*--------------------------------------------------------- * create dataset contain references */ - sid = H5Screate_simple (1, dims_dset_objref, NULL); - if (sid < 0) - { + sid = H5Screate_simple(1, dims_dset_objref, NULL); + if (sid < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - oid = H5Dcreate2 (loc_id, "Dset_OBJREF", H5T_STD_REF_OBJ, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid < 0) - { + oid = H5Dcreate2(loc_id, "Dset_OBJREF", H5T_STD_REF_OBJ, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid < 0) { HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } status = H5Dwrite(oid, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, objref_buf); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* add attribute with int type */ - if (make_attr(oid,1,dim_attr_int,"integer",H5T_NATIVE_INT,data_attr_int) < 0) + if (make_attr(oid, 1, dim_attr_int, "integer", H5T_NATIVE_INT, data_attr_int) < 0) goto out; /* add attribute with obj ref */ status = add_attr_with_objref(loc_id, oid); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> add_attr_with_objref failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6541,23 +6372,21 @@ static herr_t gen_obj_ref(hid_t loc_id) /* add attribute with region ref */ status = add_attr_with_regref(loc_id, oid); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> add_attr_with_regref failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: - if(oid > 0) + if (oid > 0) H5Dclose(oid); - if(sid > 0) + if (sid > 0) H5Sclose(sid); return ret; } - /*------------------------------------------------------------------------- * Function: gen_region_ref * @@ -6568,110 +6397,103 @@ out: * * Programmer: Jonathan Kim (March 18, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_region_ref(hid_t loc_id) +static herr_t +gen_region_ref(hid_t loc_id) { - int status; + int status; herr_t ret = SUCCEED; /* target dataset */ - hid_t sid_trg=0; - hsize_t dims_trg[2] = {3,16}; + hid_t sid_trg = 0; + hsize_t dims_trg[2] = {3, 16}; /* dset with region ref type */ - hid_t sid_ref=0, oid_ref=0; + hid_t sid_ref = 0, oid_ref = 0; /* region ref to target dataset */ - hsize_t coords[4][2] = { {0,1}, {2,11}, {1,0}, {2,4} }; - hdset_reg_ref_t rr_data[2]; - hsize_t start[2] = {0,0}; - hsize_t stride[2] = {2,11}; - hsize_t count[2] = {2,2}; - hsize_t block[2] = {1,3}; - hsize_t dims1[1] = {2}; + hsize_t coords[4][2] = {{0, 1}, {2, 11}, {1, 0}, {2, 4}}; + hdset_reg_ref_t rr_data[2]; + hsize_t start[2] = {0, 0}; + hsize_t stride[2] = {2, 11}; + hsize_t count[2] = {2, 2}; + hsize_t block[2] = {1, 3}; + hsize_t dims1[1] = {2}; /* attr with int type */ - hsize_t dim_attr_int[1]={2}; - int data_attr_int[2] = {10,20}; + hsize_t dim_attr_int[1] = {2}; + int data_attr_int[2] = {10, 20}; - sid_trg = H5Screate_simple (2, dims_trg, NULL); - if (sid_trg < 0) - { + sid_trg = H5Screate_simple(2, dims_trg, NULL); + if (sid_trg < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select elements space for reference */ - status = H5Sselect_elements (sid_trg, H5S_SELECT_SET, (size_t)4, coords[0]); - if (status < 0) - { + status = H5Sselect_elements(sid_trg, H5S_SELECT_SET, (size_t)4, coords[0]); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference from elements space */ - status = H5Rcreate (&rr_data[0], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); - if (status < 0) - { + status = H5Rcreate(&rr_data[0], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select hyperslab space for reference */ - status = H5Sselect_hyperslab (sid_trg, H5S_SELECT_SET, start, stride, count, block); - if (status < 0) - { + status = H5Sselect_hyperslab(sid_trg, H5S_SELECT_SET, start, stride, count, block); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Sselect_hyperslab failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference from hyperslab space */ - status = H5Rcreate (&rr_data[1], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); - if (status < 0) - { + status = H5Rcreate(&rr_data[1], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* Create dataspace. */ - sid_ref = H5Screate_simple (1, dims1, NULL); - if (sid_ref < 0) - { + sid_ref = H5Screate_simple(1, dims1, NULL); + if (sid_ref < 0) { HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference dataset */ - oid_ref = H5Dcreate2 (loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid_ref, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid_ref < 0) - { + oid_ref = + H5Dcreate2(loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid_ref, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid_ref < 0) { HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* write data as region references */ - status = H5Dwrite (oid_ref, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data); - if (status < 0) - { + status = H5Dwrite(oid_ref, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* add attribute with int type */ - if (make_attr(oid_ref,1,dim_attr_int,"integer",H5T_NATIVE_INT,data_attr_int) < 0) + if (make_attr(oid_ref, 1, dim_attr_int, "integer", H5T_NATIVE_INT, data_attr_int) < 0) goto out; /* add attribute with obj ref */ status = add_attr_with_objref(loc_id, oid_ref); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> add_attr_with_objref failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6679,8 +6501,7 @@ static herr_t gen_region_ref(hid_t loc_id) /* add attribute with region ref */ status = add_attr_with_regref(loc_id, oid_ref); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> add_attr_with_regref failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6688,48 +6509,46 @@ static herr_t gen_region_ref(hid_t loc_id) out: if (oid_ref > 0) - H5Dclose (oid_ref); + H5Dclose(oid_ref); if (sid_ref > 0) - H5Sclose (sid_ref); + H5Sclose(sid_ref); if (sid_trg > 0) - H5Sclose (sid_trg); + H5Sclose(sid_trg); return ret; } /*------------------------------------------------------------------------- -* Function: make_references -* -* Purpose: create a file with obj and region references -* -* Programmer: Jonathan Kim (March 18, 2010) -*------------------------------------------------------------------------- -*/ -static herr_t make_references(hid_t loc_id) + * Function: make_references + * + * Purpose: create a file with obj and region references + * + * Programmer: Jonathan Kim (March 18, 2010) + *------------------------------------------------------------------------- + */ +static herr_t +make_references(hid_t loc_id) { herr_t ret = SUCCEED; herr_t status; /* add target objects */ status = gen_refered_objs(loc_id); - if (status == FAIL) - { + if (status == FAIL) { HDfprintf(stderr, "Failed to generate referenced object.\n"); ret = FAIL; } /* add object reference */ status = gen_obj_ref(loc_id); - if (status == FAIL) - { + if (status == FAIL) { HDfprintf(stderr, "Failed to generate object reference.\n"); ret = FAIL; } /* add region reference */ status = gen_region_ref(loc_id); - if (status == FAIL) - { + if (status == FAIL) { HDfprintf(stderr, "Failed to generate region reference.\n"); ret = FAIL; } @@ -6738,110 +6557,107 @@ static herr_t make_references(hid_t loc_id) } /*------------------------------------------------------------------------- -* Function: make_complex_attr_references -* -* Purpose: -* create a file with : -* 1. obj ref in attribute of compound type -* 2. region ref in attribute of compound type -* 3. obj ref in attribute of vlen type -* 4. region ref in attribute of vlen type -* -* Programmer: Jonathan (March 25, 2010) -*------------------------------------------------------------------------- -*/ + * Function: make_complex_attr_references + * + * Purpose: + * create a file with : + * 1. obj ref in attribute of compound type + * 2. region ref in attribute of compound type + * 3. obj ref in attribute of vlen type + * 4. region ref in attribute of vlen type + * + * Programmer: Jonathan (March 25, 2010) + *------------------------------------------------------------------------- + */ /* obj dset */ #define RANK_OBJ 2 #define DIM0_OBJ 6 #define DIM1_OBJ 10 /* container dset */ #define RANK_DSET 1 -#define DIM_DSET 4 +#define DIM_DSET 4 /* 1. obj references in compound attr */ #define RANK_COMP_OBJREF 1 -#define DIM_COMP_OBJREF 3 /* for dataset, group, datatype */ +#define DIM_COMP_OBJREF 3 /* for dataset, group, datatype */ /* 2. region references in compound attr */ #define RANK_COMP_REGREF 1 -#define DIM_COMP_REGREF 1 /* for element region */ +#define DIM_COMP_REGREF 1 /* for element region */ /* 3. obj references in vlen attr */ #define RANK_VLEN_OBJREF 1 -#define DIM_VLEN_OBJREF 3 /* for dataset, group, datatype */ -#define LEN0_VLEN_OBJREF 1 /* dataset */ -#define LEN1_VLEN_OBJREF 1 /* group */ -#define LEN2_VLEN_OBJREF 1 /* datatype */ +#define DIM_VLEN_OBJREF 3 /* for dataset, group, datatype */ +#define LEN0_VLEN_OBJREF 1 /* dataset */ +#define LEN1_VLEN_OBJREF 1 /* group */ +#define LEN2_VLEN_OBJREF 1 /* datatype */ /* 4. region references in vlen attr */ #define RANK_VLEN_REGREF 1 -#define DIM_VLEN_REGREF 1 /* for element region */ -#define LEN0_VLEN_REGREF 1 /* element region */ +#define DIM_VLEN_REGREF 1 /* for element region */ +#define LEN0_VLEN_REGREF 1 /* element region */ -static herr_t make_complex_attr_references(hid_t loc_id) +static herr_t +make_complex_attr_references(hid_t loc_id) { herr_t ret = SUCCEED; herr_t status; /* * for objects */ - hid_t objgid=0, objdid=0, objtid=0, objsid=0; - hsize_t obj_dims[RANK_OBJ] = {DIM0_OBJ, DIM1_OBJ}; - int obj_data[DIM0_OBJ][DIM1_OBJ]= - {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, - {10,11,12,13,14,15,16,17,18,19}, - {20,21,22,23,24,25,26,27,28,29}, - {30,31,32,33,34,35,36,37,38,39}, - {40,41,42,43,44,45,46,47,48,49}, - {50,51,52,53,54,55,56,57,58,59}}; + hid_t objgid = 0, objdid = 0, objtid = 0, objsid = 0; + hsize_t obj_dims[RANK_OBJ] = {DIM0_OBJ, DIM1_OBJ}; + int obj_data[DIM0_OBJ][DIM1_OBJ] = { + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}, + {20, 21, 22, 23, 24, 25, 26, 27, 28, 29}, {30, 31, 32, 33, 34, 35, 36, 37, 38, 39}, + {40, 41, 42, 43, 44, 45, 46, 47, 48, 49}, {50, 51, 52, 53, 54, 55, 56, 57, 58, 59}}; /* * group main */ - hid_t main_gid=0; + hid_t main_gid = 0; /* * dataset which the attribute will be attached to */ hsize_t main_dset_dims[RANK_DSET] = {DIM_DSET}; - hid_t main_sid=0, main_did=0; + hid_t main_sid = 0, main_did = 0; /* * 1. obj references in compound attr */ - hid_t comp_objref_tid=0, comp_objref_aid=0; + hid_t comp_objref_tid = 0, comp_objref_aid = 0; typedef struct comp_objref_t { hobj_ref_t val_objref; - int val_int; + int val_int; } comp_objref_t; comp_objref_t comp_objref_data[DIM_COMP_OBJREF]; - hid_t comp_objref_attr_sid=0; - hsize_t comp_objref_dim[RANK_COMP_OBJREF] = {DIM_COMP_OBJREF}; + hid_t comp_objref_attr_sid = 0; + hsize_t comp_objref_dim[RANK_COMP_OBJREF] = {DIM_COMP_OBJREF}; /* * 2. region references in compound attr */ - hid_t comp_regref_tid=0, comp_regref_aid=0; + hid_t comp_regref_tid = 0, comp_regref_aid = 0; typedef struct comp_regref_t { hdset_reg_ref_t val_regref; - int val_int; + int val_int; } comp_regref_t; comp_regref_t comp_regref_data[DIM_COMP_REGREF]; - hid_t comp_regref_attr_sid=0; - hsize_t comp_regref_dim[RANK_COMP_REGREF] = {DIM_COMP_REGREF}; - hsize_t coords[4][2] = { {0,1}, {2,3}, {3,4}, {4,5} }; + hid_t comp_regref_attr_sid = 0; + hsize_t comp_regref_dim[RANK_COMP_REGREF] = {DIM_COMP_REGREF}; + hsize_t coords[4][2] = {{0, 1}, {2, 3}, {3, 4}, {4, 5}}; /* * 3. obj references in vlen attr */ - hid_t vlen_objref_attr_tid=0, vlen_objref_attr_sid=0; - hid_t vlen_objref_attr_id=0; - hvl_t vlen_objref_data[DIM_VLEN_OBJREF]; + hid_t vlen_objref_attr_tid = 0, vlen_objref_attr_sid = 0; + hid_t vlen_objref_attr_id = 0; + hvl_t vlen_objref_data[DIM_VLEN_OBJREF]; hsize_t vlen_objref_dims[RANK_VLEN_OBJREF] = {DIM_VLEN_OBJREF}; /* * 4. region references in vlen attr */ - hid_t vlen_regref_attr_tid=0, vlen_regref_attr_sid=0; - hid_t vlen_regref_attr_id=0; - hvl_t vlen_regref_data[DIM_VLEN_REGREF]; + hid_t vlen_regref_attr_tid = 0, vlen_regref_attr_sid = 0; + hid_t vlen_regref_attr_id = 0; + hvl_t vlen_regref_data[DIM_VLEN_REGREF]; hsize_t vlen_regref_dim[RANK_VLEN_REGREF] = {DIM_VLEN_REGREF}; - /* --------------------------------------- * create objects which to be referenced */ @@ -6852,8 +6668,7 @@ static herr_t make_complex_attr_references(hid_t loc_id) objsid = H5Screate_simple(RANK_OBJ, obj_dims, NULL); objdid = H5Dcreate2(loc_id, NAME_OBJ_DS1, H5T_NATIVE_INT, objsid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(objdid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_data[0]); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6862,21 +6677,18 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* object3 named datatype */ objtid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(loc_id, NAME_OBJ_NDTYPE, objtid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /* --------------------------------------------- * Put testing objs in this group * create group contain dataset with attribute and the attribute has * compound type which contain obj and region reference */ main_gid = H5Gcreate2(loc_id, "group_main", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (main_gid < 0) - { + if (main_gid < 0) { HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6887,11 +6699,11 @@ static herr_t make_complex_attr_references(hid_t loc_id) */ main_sid = H5Screate_simple(RANK_DSET, main_dset_dims, NULL); - main_did = H5Dcreate2(main_gid, "dset_main", H5T_NATIVE_INT, main_sid, H5P_DEFAULT,H5P_DEFAULT, H5P_DEFAULT); + main_did = + H5Dcreate2(main_gid, "dset_main", H5T_NATIVE_INT, main_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(main_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_data[0]); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6904,7 +6716,7 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create compound type for attribute */ - comp_objref_tid = H5Tcreate (H5T_COMPOUND, sizeof(comp_objref_t)); + comp_objref_tid = H5Tcreate(H5T_COMPOUND, sizeof(comp_objref_t)); H5Tinsert(comp_objref_tid, "value_objref", HOFFSET(comp_objref_t, val_objref), H5T_STD_REF_OBJ); H5Tinsert(comp_objref_tid, "value_int", HOFFSET(comp_objref_t, val_int), H5T_NATIVE_INT); @@ -6912,30 +6724,27 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * Create the object references into compound type */ - /* references to dataset */ - status = H5Rcreate (&(comp_objref_data[0].val_objref), loc_id, NAME_OBJ_DS1, H5R_OBJECT,(hid_t)-1); - if (status < 0) - { + /* references to dataset */ + status = H5Rcreate(&(comp_objref_data[0].val_objref), loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } comp_objref_data[0].val_int = 0; - /* references to group */ - status = H5Rcreate (&(comp_objref_data[1].val_objref), loc_id, NAME_OBJ_GRP, H5R_OBJECT,(hid_t)-1); - if (status < 0) - { + /* references to group */ + status = H5Rcreate(&(comp_objref_data[1].val_objref), loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } comp_objref_data[1].val_int = 10; - /* references to datatype */ - status = H5Rcreate (&(comp_objref_data[2].val_objref), loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT,(hid_t)-1); - if (status < 0) - { + /* references to datatype */ + status = H5Rcreate(&(comp_objref_data[2].val_objref), loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6945,11 +6754,11 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create attribute and write the object ref */ - comp_objref_attr_sid = H5Screate_simple (RANK_COMP_OBJREF, comp_objref_dim, NULL); - comp_objref_aid = H5Acreate2 (main_did, "Comp_OBJREF", comp_objref_tid, comp_objref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite (comp_objref_aid, comp_objref_tid, comp_objref_data); - if (status < 0) - { + comp_objref_attr_sid = H5Screate_simple(RANK_COMP_OBJREF, comp_objref_dim, NULL); + comp_objref_aid = + H5Acreate2(main_did, "Comp_OBJREF", comp_objref_tid, comp_objref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(comp_objref_aid, comp_objref_tid, comp_objref_data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6961,7 +6770,7 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create compound type for attribute */ - comp_regref_tid = H5Tcreate (H5T_COMPOUND, sizeof(comp_regref_t)); + comp_regref_tid = H5Tcreate(H5T_COMPOUND, sizeof(comp_regref_t)); H5Tinsert(comp_regref_tid, "value_regref", HOFFSET(comp_regref_t, val_regref), H5T_STD_REF_DSETREG); H5Tinsert(comp_regref_tid, "value_int", HOFFSET(comp_regref_t, val_int), H5T_NATIVE_INT); @@ -6969,16 +6778,14 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create the region reference */ - status = H5Sselect_elements (objsid, H5S_SELECT_SET, (size_t)4, coords[0]); - if (status < 0) - { + status = H5Sselect_elements(objsid, H5S_SELECT_SET, (size_t)4, coords[0]); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - status = H5Rcreate (&(comp_regref_data[0].val_regref), loc_id, NAME_OBJ_DS1, H5R_DATASET_REGION, objsid); - if (status < 0) - { + status = H5Rcreate(&(comp_regref_data[0].val_regref), loc_id, NAME_OBJ_DS1, H5R_DATASET_REGION, objsid); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -6988,80 +6795,78 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create attribute and write the region ref */ - comp_regref_attr_sid = H5Screate_simple (RANK_COMP_REGREF, comp_regref_dim, NULL); - comp_regref_aid = H5Acreate2 (main_did, "Comp_REGREF", comp_regref_tid, comp_regref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite (comp_regref_aid, comp_regref_tid, comp_regref_data); - if (status < 0) - { + comp_regref_attr_sid = H5Screate_simple(RANK_COMP_REGREF, comp_regref_dim, NULL); + comp_regref_aid = + H5Acreate2(main_did, "Comp_REGREF", comp_regref_tid, comp_regref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(comp_regref_aid, comp_regref_tid, comp_regref_data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /*------------------------------------------------------------------- * 3. create obj references in attribute of vlen type */ /* * prepare vlen data */ - vlen_objref_data[0].len = LEN0_VLEN_OBJREF; - vlen_objref_data[0].p = HDmalloc (vlen_objref_data[0].len * sizeof(hobj_ref_t)); - vlen_objref_data[1].len = LEN1_VLEN_OBJREF; - vlen_objref_data[1].p = HDmalloc (vlen_objref_data[1].len * sizeof(hobj_ref_t)); - vlen_objref_data[2].len = LEN2_VLEN_OBJREF; - vlen_objref_data[2].p = HDmalloc (vlen_objref_data[2].len * sizeof(hobj_ref_t)); - - /* - * create obj references - */ - /* reference to dataset */ - status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[0].p)[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { + vlen_objref_data[0].len = LEN0_VLEN_OBJREF; + vlen_objref_data[0].p = HDmalloc(vlen_objref_data[0].len * sizeof(hobj_ref_t)); + vlen_objref_data[1].len = LEN1_VLEN_OBJREF; + vlen_objref_data[1].p = HDmalloc(vlen_objref_data[1].len * sizeof(hobj_ref_t)); + vlen_objref_data[2].len = LEN2_VLEN_OBJREF; + vlen_objref_data[2].p = HDmalloc(vlen_objref_data[2].len * sizeof(hobj_ref_t)); + + /* + * create obj references + */ + /* reference to dataset */ + status = + H5Rcreate(&((hobj_ref_t *)vlen_objref_data[0].p)[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /* reference to group */ - status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[1].p)[0], loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { + /* reference to group */ + status = + H5Rcreate(&((hobj_ref_t *)vlen_objref_data[1].p)[0], loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /* reference to datatype */ - status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[2].p)[0], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { + /* reference to datatype */ + status = + H5Rcreate(&((hobj_ref_t *)vlen_objref_data[2].p)[0], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /* - * create vlen type with obj reference - */ - vlen_objref_attr_tid = H5Tvlen_create (H5T_STD_REF_OBJ); - vlen_objref_attr_sid = H5Screate_simple (RANK_VLEN_OBJREF, vlen_objref_dims, NULL); + /* + * create vlen type with obj reference + */ + vlen_objref_attr_tid = H5Tvlen_create(H5T_STD_REF_OBJ); + vlen_objref_attr_sid = H5Screate_simple(RANK_VLEN_OBJREF, vlen_objref_dims, NULL); - /* + /* * create attribute and write the object reference */ - vlen_objref_attr_id = H5Acreate2(main_did, "Vlen_OBJREF", vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite (vlen_objref_attr_id, vlen_objref_attr_tid, vlen_objref_data); - if (status < 0) - { + vlen_objref_attr_id = H5Acreate2(main_did, "Vlen_OBJREF", vlen_objref_attr_tid, vlen_objref_attr_sid, + H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(vlen_objref_attr_id, vlen_objref_attr_tid, vlen_objref_data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* close resource for vlen data */ - status = H5Treclaim (vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, vlen_objref_data); - if (status < 0) - { + status = H5Treclaim(vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, vlen_objref_data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Treclaim failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -7075,21 +6880,20 @@ static herr_t make_complex_attr_references(hid_t loc_id) * prepare vlen data */ vlen_regref_data[0].len = LEN0_VLEN_REGREF; - vlen_regref_data[0].p = HDmalloc (vlen_regref_data[0].len * sizeof(hdset_reg_ref_t)); + vlen_regref_data[0].p = HDmalloc(vlen_regref_data[0].len * sizeof(hdset_reg_ref_t)); /* * create region reference */ status = H5Sselect_elements(objsid, H5S_SELECT_SET, (size_t)4, coords[0]); - if (status < 0) - { + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - status = H5Rcreate (&((hdset_reg_ref_t*)vlen_regref_data[0].p)[0], loc_id, NAME_OBJ_DS1, H5R_DATASET_REGION, objsid); - if (status < 0) - { + status = H5Rcreate(&((hdset_reg_ref_t *)vlen_regref_data[0].p)[0], loc_id, NAME_OBJ_DS1, + H5R_DATASET_REGION, objsid); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; @@ -7104,19 +6908,18 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create attribute and write the region reference */ - vlen_regref_attr_id = H5Acreate2(main_did, "Vlen_REGREF", vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite(vlen_regref_attr_id, vlen_regref_attr_tid, vlen_regref_data); - if (status < 0) - { + vlen_regref_attr_id = H5Acreate2(main_did, "Vlen_REGREF", vlen_regref_attr_tid, vlen_regref_attr_sid, + H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(vlen_regref_attr_id, vlen_regref_attr_tid, vlen_regref_data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* close resource for vlen data */ - status = H5Treclaim (vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, vlen_regref_data); - if (status < 0) - { + status = H5Treclaim(vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, vlen_regref_data); + if (status < 0) { HDfprintf(stderr, "Error: %s %d> H5Treclaim failed.\n", FUNC, __LINE__); ret = FAIL; goto out; diff --git a/tools/test/h5repack/testh5repack_detect_szip.c b/tools/test/h5repack/testh5repack_detect_szip.c index 6b86dd5..7da550b 100644 --- a/tools/test/h5repack/testh5repack_detect_szip.c +++ b/tools/test/h5repack/testh5repack_detect_szip.c @@ -16,7 +16,6 @@ #include "h5tools_utils.h" #include "h5test.h" - /* Name of tool */ #define PROGRAMNAME "h5repack_detect_szip" @@ -39,8 +38,8 @@ *------------------------------------------------------------------------- */ - -int main(void) +int +main(void) { h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -51,9 +50,9 @@ int main(void) #ifdef H5_HAVE_FILTER_SZIP if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { HDprintf("yes\n"); - return(1); + return (1); } #endif /* H5_HAVE_FILTER_SZIP */ HDprintf("no\n"); - return(0); + return (0); } diff --git a/tools/test/h5stat/h5stat_gentest.c b/tools/test/h5stat/h5stat_gentest.c index 0bf1001..c5e8570 100644 --- a/tools/test/h5stat/h5stat_gentest.c +++ b/tools/test/h5stat/h5stat_gentest.c @@ -24,28 +24,28 @@ #include "H5private.h" /* For gen_newgrat_file() */ -#define NEWGRAT_FILE "h5stat_newgrat.h5" -#define DATASET_NAME "DATASET_NAME" -#define GROUP_NAME "GROUP" +#define NEWGRAT_FILE "h5stat_newgrat.h5" +#define DATASET_NAME "DATASET_NAME" +#define GROUP_NAME "GROUP" #define ATTR_NAME "ATTR" #define NUM_GRPS 35000 #define NUM_ATTRS 100 /* Declarations for gen_idx_file() */ -#define IDX_FILE "h5stat_idx.h5" +#define IDX_FILE "h5stat_idx.h5" #define DSET "dset" -#define DSET_FILTER "dset_filter" +#define DSET_FILTER "dset_filter" /* For gen_threshold_file() */ -#define THRESHOLD_FILE "h5stat_threshold.h5" -#define THRES_ATTR_NAME "attr" -#define THRES_ATTR_GRP_NAME "grp_attr" +#define THRESHOLD_FILE "h5stat_threshold.h5" +#define THRES_ATTR_NAME "attr" +#define THRES_ATTR_GRP_NAME "grp_attr" #define THRES_DSET_NAME "dset" -#define THRES_NUM 10 +#define THRES_NUM 10 #define THRES_NUM_25 25 /* For gen_err_refcount() */ -#define ERR_REFCOUNT_FILE "h5stat_err_refcount.h5" +#define ERR_REFCOUNT_FILE "h5stat_err_refcount.h5" /* * Generate HDF5 file with latest format with @@ -54,71 +54,72 @@ static void gen_newgrat_file(const char *fname) { - hid_t fcpl = H5I_INVALID_HID; /* File creation property */ - hid_t fapl = H5I_INVALID_HID; /* File access property */ - hid_t fid = H5I_INVALID_HID; /* File id */ - hid_t gid = H5I_INVALID_HID; /* Group id */ - hid_t tid = H5I_INVALID_HID; /* Datatype id */ - hid_t sid = H5I_INVALID_HID; /* Dataspace id */ - hid_t attr_id = H5I_INVALID_HID; /* Attribute id */ - hid_t did = H5I_INVALID_HID; /* Dataset id */ - char name[30]; /* Group name */ - char attrname[30]; /* Attribute name */ - int i; /* Local index variable */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property */ + hid_t fapl = H5I_INVALID_HID; /* File access property */ + hid_t fid = H5I_INVALID_HID; /* File id */ + hid_t gid = H5I_INVALID_HID; /* Group id */ + hid_t tid = H5I_INVALID_HID; /* Datatype id */ + hid_t sid = H5I_INVALID_HID; /* Dataspace id */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute id */ + hid_t did = H5I_INVALID_HID; /* Dataset id */ + char name[30]; /* Group name */ + char attrname[30]; /* Attribute name */ + int i; /* Local index variable */ /* Get a copy file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Get a copy of file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Set file space handling strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1) < 0) goto error; - /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + /* Create file */ + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Create NUM_GRPS groups in the root group */ - for(i = 1; i <= NUM_GRPS; i++) { - HDsprintf(name, "%s%d", GROUP_NAME,i); - if((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= NUM_GRPS; i++) { + HDsprintf(name, "%s%d", GROUP_NAME, i); + if ((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; } /* end for */ /* Create a datatype to commit and use */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; /* Create dataspace for dataset */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto error; /* Create dataset */ - if((did = H5Dcreate2(fid, DATASET_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create NUM_ATTRS for the dataset */ - for(i = 1; i <= NUM_ATTRS; i++) { - HDsprintf(attrname, "%s%d", ATTR_NAME,i); - if((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= NUM_ATTRS; i++) { + HDsprintf(attrname, "%s%d", ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } /* end for */ /* Close dataset, dataspace, datatype, file */ error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); H5Aclose(attr_id); @@ -127,178 +128,183 @@ error: H5Sclose(sid); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_newgrat_file() */ /* * Generate an HDF5 file with groups, datasets, attributes for testing the options: * -l N (--links=N): Set the threshold for # of links when printing information for small groups. - * -m N (--dims=N): Set the threshold for the # of dimension sizes when printing information for small datasets. - * -a N (--numattrs=N): Set the threshold for the # of attributes when printing information for small # of attributes. + * -m N (--dims=N): Set the threshold for the # of dimension sizes when printing information for small + * datasets. -a N (--numattrs=N): Set the threshold for the # of attributes when printing information for + * small # of attributes. */ static void gen_threshold_file(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t sid0 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid1 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid2 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid3 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid4 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hid_t attr_id = H5I_INVALID_HID; /* Attribute ID */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - hsize_t two_dims[] = {2, 5}; /* Dimension array */ - hsize_t one_dims[] = {6}; /* Dimension array */ - hsize_t zero_dims[] = {0}; /* Dimension array */ - char name[30]; /* Name */ - unsigned i; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t sid0 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid1 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid2 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid3 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid4 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hsize_t two_dims[] = {2, 5}; /* Dimension array */ + hsize_t one_dims[] = {6}; /* Dimension array */ + hsize_t zero_dims[] = {0}; /* Dimension array */ + char name[30]; /* Name */ + unsigned i; /* Local index variable */ /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 1-D dataspace with zero dimension size */ - if((sid0 = H5Screate_simple(1, zero_dims, NULL)) < 0) + if ((sid0 = H5Screate_simple(1, zero_dims, NULL)) < 0) goto error; /* Create 1-D dataspace with non-zero dimension size*/ - if((sid1 = H5Screate_simple(1, one_dims, NULL)) < 0) + if ((sid1 = H5Screate_simple(1, one_dims, NULL)) < 0) goto error; /* Create 2-D dataspace */ - if((sid2 = H5Screate_simple(2, two_dims, NULL)) < 0) + if ((sid2 = H5Screate_simple(2, two_dims, NULL)) < 0) goto error; /* Create scalar dataspace */ - if((sid3 = H5Screate(H5S_SCALAR)) < 0) + if ((sid3 = H5Screate(H5S_SCALAR)) < 0) goto error; /* Create null dataspace */ - if((sid4 = H5Screate(H5S_NULL)) < 0) + if ((sid4 = H5Screate(H5S_NULL)) < 0) goto error; /* Create an attribute for the root group */ - if((attr_id = H5Acreate2(fid, "attr", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(fid, "attr", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; /* Create 1-D dataset with zero dimension size for the root group */ - if((did = H5Dcreate2(fid, "zero_dset", H5T_NATIVE_UCHAR, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "zero_dset", H5T_NATIVE_UCHAR, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; /* Create 11 attributes for the dataset */ - for(i = 1; i <= (THRES_NUM+1); i++) { - HDsprintf(name, "%s%d", THRES_ATTR_NAME,i); - if((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= (THRES_NUM + 1); i++) { + HDsprintf(name, "%s%d", THRES_ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create dataset with scalar dataspace for the root group */ - if((did = H5Dcreate2(fid, "scalar_dset", H5T_NATIVE_UCHAR, sid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "scalar_dset", H5T_NATIVE_UCHAR, sid3, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create dataset with null dataspace for the root group */ - if((did = H5Dcreate2(fid, "null_dset", H5T_NATIVE_UCHAR, sid4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "null_dset", H5T_NATIVE_UCHAR, sid4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create 2-D dataset for the root group */ - if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 10 attributes for the 2-D dataset */ - for(i = 1; i <= THRES_NUM; i++) { - HDsprintf(name, "%s%d", THRES_ATTR_NAME,i); - if((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= THRES_NUM; i++) { + HDsprintf(name, "%s%d", THRES_ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create first group */ - if((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create an attribute for the group */ - if((attr_id = H5Acreate2(gid, "ATTR", H5T_NATIVE_INT, sid3, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(gid, "ATTR", H5T_NATIVE_INT, sid3, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close attribute */ - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; /* Create 10 1-D datasets with non-zero dimension size for the group */ - for(i = 1; i <= THRES_NUM; i++) { + for (i = 1; i <= THRES_NUM; i++) { /* set up dataset name */ - HDsprintf(name, "%s%d", THRES_DSET_NAME,i); + HDsprintf(name, "%s%d", THRES_DSET_NAME, i); /* Create the dataset */ - if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; } /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - /* Create second group */ - if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 25 attributes for the group */ - for(i = 1; i <= THRES_NUM_25; i++) { - /* Set up attribute name */ - HDsprintf(name, "%s%d", THRES_ATTR_GRP_NAME,i); + for (i = 1; i <= THRES_NUM_25; i++) { + /* Set up attribute name */ + HDsprintf(name, "%s%d", THRES_ATTR_GRP_NAME, i); /* Create the attribute */ - if((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the attribute */ - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; /* Create third group */ - if((gid = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 9 1-D datasets with non-zero dimension size for the group */ - for(i = 1; i < THRES_NUM; i++) { + for (i = 1; i < THRES_NUM; i++) { /* set up dataset name */ - HDsprintf(name, "%s%d", THRES_DSET_NAME,i); + HDsprintf(name, "%s%d", THRES_DSET_NAME, i); /* Create the dataset */ - if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; } error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Aclose(attr_id); H5Dclose(did); @@ -308,7 +314,8 @@ error: H5Sclose(sid3); H5Sclose(sid4); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_threshold_file() */ @@ -323,77 +330,79 @@ error: static void gen_idx_file(const char *fname) { - hid_t fapl = H5I_INVALID_HID; /* file access property id */ - hid_t fid = H5I_INVALID_HID; /* file id */ - hid_t sid = H5I_INVALID_HID; /* space id */ - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ - hid_t did = -1, did2 = H5I_INVALID_HID; /* dataset id */ - hsize_t dims[1] = {10}; /* dataset dimension */ - hsize_t c_dims[1] = {2}; /* chunk dimension */ - int i; /* local index variable */ - int buf[10]; /* data buffer */ + hid_t fapl = H5I_INVALID_HID; /* file access property id */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did = -1, did2 = H5I_INVALID_HID; /* dataset id */ + hsize_t dims[1] = {10}; /* dataset dimension */ + hsize_t c_dims[1] = {2}; /* chunk dimension */ + int i; /* local index variable */ + int buf[10]; /* data buffer */ /* Get a copy of the file access property */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set the "use the latest format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Create data */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) buf[i] = i; /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 1, c_dims) < 0) + if (H5Pset_chunk(dcpl, 1, c_dims) < 0) goto error; /* Create a 1D dataset */ - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) goto error; /* Create and write the dataset */ - if((did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; #endif /* closing: dataspace, dataset, file */ error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); H5Fclose(fid); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) H5Dclose(did2); #endif - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_idx_file() */ @@ -413,70 +422,70 @@ error: static void gen_err_refcount(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* File identifier */ - hid_t sid = H5I_INVALID_HID; /* Dataspace message */ - hid_t did = H5I_INVALID_HID; /* Dataset identifier */ - hid_t gid = H5I_INVALID_HID; /* Group identifier */ - hid_t aid1 = -1, aid2 = H5I_INVALID_HID; /* Attribute identifier */ - hid_t tid = H5I_INVALID_HID; /* Datatype identifier */ - int i, n; /* Local index variables */ - int buf[10]; /* Data buffer */ - hsize_t dims[1]; /* Dimension size */ - int fd = -1; /* File descriptor */ - unsigned short val = 22; /* The refcount message ID */ + hid_t fid = H5I_INVALID_HID; /* File identifier */ + hid_t sid = H5I_INVALID_HID; /* Dataspace message */ + hid_t did = H5I_INVALID_HID; /* Dataset identifier */ + hid_t gid = H5I_INVALID_HID; /* Group identifier */ + hid_t aid1 = -1, aid2 = H5I_INVALID_HID; /* Attribute identifier */ + hid_t tid = H5I_INVALID_HID; /* Datatype identifier */ + int i, n; /* Local index variables */ + int buf[10]; /* Data buffer */ + hsize_t dims[1]; /* Dimension size */ + int fd = -1; /* File descriptor */ + unsigned short val = 22; /* The refcount message ID */ /* Initialize data buffer */ n = 0; - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) buf[i] = n++; /* Create the file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create a group */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create a committed datatype in the group */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - if(H5Tcommit2(gid, "dtype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(gid, "dtype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; /* Create the dataspace */ dims[0] = 10; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto error; /* Create a dataset with the committed datatype in the file */ - if((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Attach an attribute with the committed datatype to the group */ - if((aid1 = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid1 = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Attach an attribute with the committed datatype to the dataset */ - if((aid2 = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid2 = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Aclose(aid1) < 0) + if (H5Aclose(aid1) < 0) goto error; - if(H5Aclose(aid2) < 0) + if (H5Aclose(aid2) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* This section of code will write a refcount message ID to a message in the @@ -486,14 +495,15 @@ gen_err_refcount(const char *fname) with the committed datatype */ /* 24: the offset in the object header containing the version of the attribute message */ - if((fd = HDopen(fname, O_RDWR, 0633)) >= 0) { - HDlseek(fd, 4520+24, SEEK_SET); + if ((fd = HDopen(fname, O_RDWR, 0633)) >= 0) { + HDlseek(fd, 4520 + 24, SEEK_SET); HDwrite(fd, &val, 2); HDclose(fd); } error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Dclose(did); H5Tclose(tid); @@ -501,7 +511,8 @@ error: H5Aclose(aid1); H5Aclose(aid2); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; } /* gen_err_refcount() */ /* @@ -528,7 +539,8 @@ error: * jira issue. */ -int main(void) +int +main(void) { gen_newgrat_file(NEWGRAT_FILE); gen_threshold_file(THRESHOLD_FILE); @@ -541,4 +553,3 @@ int main(void) return 0; } - diff --git a/tools/test/misc/clear_open_chk.c b/tools/test/misc/clear_open_chk.c index 7d22ca6..c66282c 100644 --- a/tools/test/misc/clear_open_chk.c +++ b/tools/test/misc/clear_open_chk.c @@ -40,11 +40,11 @@ usage(void) int main(int argc, char *argv[]) { - char *fname; /* The HDF5 file name */ - hid_t fid; /* File ID */ + char *fname; /* The HDF5 file name */ + hid_t fid; /* File ID */ /* Check the # of arguments */ - if(argc != 2) { + if (argc != 2) { usage(); HDexit(EXIT_FAILURE); } @@ -53,7 +53,7 @@ main(int argc, char *argv[]) fname = HDstrdup(argv[1]); /* Try opening the file */ - if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) { + if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) { HDfprintf(stderr, "clear_open_chk: unable to open the file\n"); HDfree(fname); HDexit(EXIT_FAILURE); @@ -61,7 +61,7 @@ main(int argc, char *argv[]) HDfree(fname); /* Close the file */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "clear_open_chk: cannot close the file\n"); HDexit(EXIT_FAILURE); } diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c index 8d6883c..a088e51 100644 --- a/tools/test/misc/h5clear_gentest.c +++ b/tools/test/misc/h5clear_gentest.c @@ -15,31 +15,31 @@ /* The HDF5 test files */ const char *FILENAME[] = { - "h5clear_sec2_v3.h5", /* 0 -- sec2 file with superblock version 3 */ - "h5clear_log_v3.h5", /* 1 -- log file with superblock veresion 3 */ - "h5clear_sec2_v0.h5", /* 2 -- sec2 file with superblock version 0 */ - "h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */ + "h5clear_sec2_v3.h5", /* 0 -- sec2 file with superblock version 3 */ + "h5clear_log_v3.h5", /* 1 -- log file with superblock veresion 3 */ + "h5clear_sec2_v0.h5", /* 2 -- sec2 file with superblock version 0 */ + "h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */ }; const char *FILENAME_ENHANCE[] = { - "h5clear_fsm_persist_equal.h5", /* 0: persisting free-space, stored EOA = actual EOF */ - "h5clear_fsm_persist_greater.h5", /* 1: persisting free-space, stored EOA > actual EOF */ - "h5clear_fsm_persist_less.h5", /* 2: persisting free-space, stored EOA < actual EOF */ - "h5clear_fsm_persist_user_equal.h5", /* 3: user block, persisting free-space, stored EOA = actual EOF */ - "h5clear_fsm_persist_user_greater.h5", /* 4: user block, persisting free-space, stored EOA > actual EOF */ - "h5clear_fsm_persist_user_less.h5", /* 5: user block, persisting free-space, stored EOA < actual EOF */ - "h5clear_status_noclose.h5", /* 6 -- v3 superblock, nonzero status_flags, no flush, exit, - stored EOA < actual EOF */ - "h5clear_fsm_persist_noclose.h5" /* 7 -- persisting free-space, no flush, exit, stored EOA < actual EOF */ + "h5clear_fsm_persist_equal.h5", /* 0: persisting free-space, stored EOA = actual EOF */ + "h5clear_fsm_persist_greater.h5", /* 1: persisting free-space, stored EOA > actual EOF */ + "h5clear_fsm_persist_less.h5", /* 2: persisting free-space, stored EOA < actual EOF */ + "h5clear_fsm_persist_user_equal.h5", /* 3: user block, persisting free-space, stored EOA = actual EOF */ + "h5clear_fsm_persist_user_greater.h5", /* 4: user block, persisting free-space, stored EOA > actual EOF */ + "h5clear_fsm_persist_user_less.h5", /* 5: user block, persisting free-space, stored EOA < actual EOF */ + "h5clear_status_noclose.h5", /* 6 -- v3 superblock, nonzero status_flags, no flush, exit, + stored EOA < actual EOF */ + "h5clear_fsm_persist_noclose.h5" /* 7 -- persisting free-space, no flush, exit, stored EOA < actual EOF */ }; -#define KB 1024U +#define KB 1024U -#define CACHE_IMAGE_FILE "h5clear_mdc_image.h5" -#define DSET "DSET" -#define DATASET "dset" -#define NUM_ELMTS 100 -#define USERBLOCK 512 +#define CACHE_IMAGE_FILE "h5clear_mdc_image.h5" +#define DSET "DSET" +#define DATASET "dset" +#define NUM_ELMTS 100 +#define USERBLOCK 512 /*------------------------------------------------------------------------- * Function: gen_cache_image_file @@ -56,73 +56,71 @@ const char *FILENAME_ENHANCE[] = { static int gen_cache_image_file(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t did = -1, sid = H5I_INVALID_HID; /* Dataset ID, dataspace ID */ - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ - hsize_t dims[2]; /* Dimension sizes */ - hsize_t chunks[2]; /* Chunked dimension sizes */ - int i, j; /* Local index variables */ - int **buf = NULL; /* Buffer for data to write */ - H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ - { H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, FALSE, - H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t did = -1, sid = H5I_INVALID_HID; /* Dataset ID, dataspace ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hsize_t dims[2]; /* Dimension sizes */ + hsize_t chunks[2]; /* Chunked dimension sizes */ + int i, j; /* Local index variables */ + int ** buf = NULL; /* Buffer for data to write */ + H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ + {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; /* Create and fill array */ H5TEST_ALLOCATE_2D_ARRAY(buf, int, 50, 100); if (NULL == buf) goto error; - for(i = 0; i < 50; i++) - for(j = 0; j < 100; j++) + for (i = 0; i < 50; i++) + for (j = 0; j < 100; j++) buf[i][j] = i * j; /* Create a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Enable latest format in fapl */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Enable metadata cache image in fapl */ - if(H5Pset_mdc_image_config(fapl, &cache_image_config) < 0) + if (H5Pset_mdc_image_config(fapl, &cache_image_config) < 0) goto error; /* Create the file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Create dataspace */ dims[0] = 50; dims[1] = 100; - if((sid = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) goto error; /* Set up to create a chunked dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; chunks[0] = 5; chunks[1] = 10; - if(H5Pset_chunk(dcpl, 2, chunks) < 0) + if (H5Pset_chunk(dcpl, 2, chunks) < 0) goto error; - if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) goto error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto error; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; HDfree(buf); @@ -130,14 +128,16 @@ gen_cache_image_file(const char *fname) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); H5Fclose(fid); H5Pclose(fapl); H5Pclose(dcpl); - } H5E_END_TRY; + } + H5E_END_TRY; HDfree(buf); @@ -173,61 +173,61 @@ error: static int gen_enhance_files(hbool_t user) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hsize_t dim[1]; /* Dimension sizes */ - int data[NUM_ELMTS]; /* Buffer for data */ - int fd = H5I_INVALID_HID; /* The file descriptor ID */ - int64_t eoa; /* The EOA value */ - uint32_t chksum; /* The chksum value */ - int i = 0 , j = 0, u = 0; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hsize_t dim[1]; /* Dimension sizes */ + int data[NUM_ELMTS]; /* Buffer for data */ + int fd = H5I_INVALID_HID; /* The file descriptor ID */ + int64_t eoa; /* The EOA value */ + uint32_t chksum; /* The chksum value */ + int i = 0, j = 0, u = 0; /* Local index variable */ /* Get a copy of the default file creation property */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Check to see if user block will be added */ - if(user) { - if(H5Pset_userblock(fcpl, (hsize_t)USERBLOCK) < 0) + if (user) { + if (H5Pset_userblock(fcpl, (hsize_t)USERBLOCK) < 0) goto error; u = 3; } /* Set file space strategy and persisting free-space */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) goto error; /* * Create the file, then write invalid EOA to the file. */ - for(i = 0+u; i < 3+u; i++) { + for (i = 0 + u; i < 3 + u; i++) { /* Create the file with the file space strategy and persisting free-space */ - if((fid = H5Fcreate(FILENAME_ENHANCE[i], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAME_ENHANCE[i], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create the dataset */ dim[0] = NUM_ELMTS; - if((sid = H5Screate_simple(1, dim, NULL)) < 0) - goto error; - if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) + goto error; + if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(j = 0; j < NUM_ELMTS; j++) + for (j = 0; j < NUM_ELMTS; j++) data[j] = j; /* Write the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto error; /* @@ -235,7 +235,7 @@ gen_enhance_files(hbool_t user) * --FILENAME_ENHANCE[0]: "h5clear_fsm_persist_equal.h5" * --FILENAME_ENHANCE[3]: "h5clear_fsm_persist_user_equal.h5", */ - if(!(i % 3)) + if (!(i % 3)) continue; /* * For the following files: @@ -248,27 +248,27 @@ gen_enhance_files(hbool_t user) * update the chksum value. */ /* Open the file */ - if((fd = open(FILENAME_ENHANCE[i], O_RDWR, 0663)) < 0) + if ((fd = open(FILENAME_ENHANCE[i], O_RDWR, 0663)) < 0) goto error; - switch(i) { + switch (i) { case 1: /* stored EOA is > EOF */ - eoa = 3048; + eoa = 3048; chksum = 268376587; break; case 2: /* stored EOA is < EOF */ - eoa = 512; + eoa = 512; chksum = 372920305; break; case 4: /* with userblock, stored EOA > EOF */ - eoa = 4000; + eoa = 4000; chksum = 4168810027; break; case 5: /* with userblock, stored EOA < EOF */ - eoa = 3000; + eoa = 3000; chksum = 3716054346; break; @@ -277,40 +277,42 @@ gen_enhance_files(hbool_t user) } /* location of "end of file address" */ - if(lseek(fd, (off_t)(28+(user?USERBLOCK:0)), SEEK_SET) < 0) + if (lseek(fd, (off_t)(28 + (user ? USERBLOCK : 0)), SEEK_SET) < 0) goto error; /* Write the bad eoa value to the file */ - if(write(fd, &eoa, sizeof(eoa)) < 0) + if (write(fd, &eoa, sizeof(eoa)) < 0) goto error; /* location of "superblock checksum" */ - if(lseek(fd, (off_t)(44+(user?USERBLOCK:0)), SEEK_SET) < 0) + if (lseek(fd, (off_t)(44 + (user ? USERBLOCK : 0)), SEEK_SET) < 0) goto error; /* Write the chksum value to the file */ - if(write(fd, &chksum, sizeof(chksum)) < 0) + if (write(fd, &chksum, sizeof(chksum)) < 0) goto error; /* Close the file */ - if(close(fd) < 0) + if (close(fd) < 0) goto error; } /* end for */ /* Close the property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Dclose(did); H5Fclose(fid); H5Pclose(fcpl); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } /* gen_enhance_files() */ @@ -370,39 +372,39 @@ error: int main(void) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ - hid_t fapl = -1, new_fapl = H5I_INVALID_HID; /* File access property lists */ - char fname[512]; /* File name */ - unsigned new_format; /* To use latest library format or not */ - hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hsize_t dim[1]; /* Dimension sizes */ - int data[NUM_ELMTS]; /* Buffer for data */ - int i; /* Local index variables */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl = -1, new_fapl = H5I_INVALID_HID; /* File access property lists */ + char fname[512]; /* File name */ + unsigned new_format; /* To use latest library format or not */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hsize_t dim[1]; /* Dimension sizes */ + int data[NUM_ELMTS]; /* Buffer for data */ + int i; /* Local index variables */ /* Generate a file with cache image feature enabled */ - if(gen_cache_image_file(CACHE_IMAGE_FILE) < 0) + if (gen_cache_image_file(CACHE_IMAGE_FILE) < 0) goto error; /* Generate the first 6 files in FILENAME_ENHANCE[] */ - if(gen_enhance_files(FALSE) < 0) + if (gen_enhance_files(FALSE) < 0) goto error; - if(gen_enhance_files(TRUE) < 0) + if (gen_enhance_files(TRUE) < 0) goto error; /* * Generate files in FILENAME[] */ /* Create a copy of the file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Copy the file access property list */ - if((new_fapl = H5Pcopy(fapl)) < 0) + if ((new_fapl = H5Pcopy(fapl)) < 0) goto error; /* Set to latest library format */ - if(H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* @@ -410,54 +412,56 @@ main(void) * --FILENAME[0]: "h5clear_sec2_v3.h5", "latest_h5clear_sec2_v3.h5" * --FILENAME[1]: "h5clear_log_v3.h5", "latest_h5clear_log_v3.h5" */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - hid_t fapl2, my_fapl; /* File access property lists */ + for (new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t fapl2, my_fapl; /* File access property lists */ /* Set to use the appropriate file access property list */ - if(new_format) + if (new_format) fapl2 = new_fapl; else fapl2 = fapl; /* * Create a sec2 file */ - if((my_fapl = H5Pcopy(fapl2)) < 0) + if ((my_fapl = H5Pcopy(fapl2)) < 0) goto error; /* Create the file */ - HDsprintf(fname, "%s%s", new_format? "latest_":"", FILENAME[0]); - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, my_fapl)) < 0) + HDsprintf(fname, "%s%s", new_format ? "latest_" : "", FILENAME[0]); + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, + my_fapl)) < 0) goto error; /* Flush the file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) goto error; /* Close the property list */ - if(H5Pclose(my_fapl) < 0) + if (H5Pclose(my_fapl) < 0) goto error; /* * Create a log file */ /* Create a copy of file access property list */ - if((my_fapl = H5Pcopy(fapl2)) < 0) - goto error; + if ((my_fapl = H5Pcopy(fapl2)) < 0) + goto error; /* Setup the fapl for the log driver */ - if(H5Pset_fapl_log(my_fapl, "append.log", (unsigned long long)H5FD_LOG_ALL, (size_t)(4 * KB)) < 0) + if (H5Pset_fapl_log(my_fapl, "append.log", (unsigned long long)H5FD_LOG_ALL, (size_t)(4 * KB)) < 0) goto error; /* Create the file */ - HDsprintf(fname, "%s%s", new_format? "latest_":"", FILENAME[1]); - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, my_fapl)) < 0) + HDsprintf(fname, "%s%s", new_format ? "latest_" : "", FILENAME[1]); + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, + my_fapl)) < 0) goto error; /* Flush the file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) goto error; /* Close the property list */ - if(H5Pclose(my_fapl) < 0) + if (H5Pclose(my_fapl) < 0) goto error; } /* end for */ @@ -466,39 +470,37 @@ main(void) * Create a sec2 file with v0 superblock but nonzero status_flags: * FILENAME[2]: "h5clear_sec2_v0.h5" */ - if((fid = H5Fcreate(FILENAME[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Flush the file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) goto error; - /* * Create a sec2 file with v2 superblock but nonzero status_flags: * FILENAME[3]: "h5clear_sec2_v2.h5" */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; - if(H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) + if (H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) goto error; - if(H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 50) < 0) + if (H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 50) < 0) goto error; - if((fid = H5Fcreate(FILENAME[3], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME[3], H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Flush the file */ - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) goto error; - /* Close the property lists */ - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; - if(H5Pclose(new_fapl) < 0) + if (H5Pclose(new_fapl) < 0) goto error; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; /* @@ -515,42 +517,41 @@ main(void) * --does not flush the file, just exit without closing file: * --this file is similar to the user-suppplied test file attached with HDFFV-10347 */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; /* Set to latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - goto error; + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; /* Create file with SWMR-write access */ - if((fid = H5Fcreate(FILENAME_ENHANCE[6], H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(FILENAME_ENHANCE[6], H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0) goto error; /* Create the dataset */ dim[0] = NUM_ELMTS; - if((sid = H5Screate_simple(1, dim, NULL)) < 0) + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < NUM_ELMTS; i++) + for (i = 0; i < NUM_ELMTS; i++) data[i] = i; /* Write the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto error; /* Does not flush and does not close the file */ - /* * FILENAME_ENHANCE[7]: h5clear_fsm_persist_noclose.h5 * --stored EOA < actual EOF @@ -559,42 +560,41 @@ main(void) * --undefined fsinfo.fs_addr * --does not flush the file, just exit without closing */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Set file space strategy and persisting free-space */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) - goto error; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + goto error; /* Create the file with the set file space info */ - if((fid = H5Fcreate(FILENAME_ENHANCE[7], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILENAME_ENHANCE[7], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create the dataset */ dim[0] = NUM_ELMTS; - if((sid = H5Screate_simple(1, dim, NULL)) < 0) + if ((sid = H5Screate_simple(1, dim, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < NUM_ELMTS; i++) + for (i = 0; i < NUM_ELMTS; i++) data[i] = i; /* Write the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Closing */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto error; /* Does not flush and does not close the file */ - fflush(stdout); fflush(stderr); diff --git a/tools/test/misc/h5perf_gentest.c b/tools/test/misc/h5perf_gentest.c index f50e5fb..8fa1c74 100644 --- a/tools/test/misc/h5perf_gentest.c +++ b/tools/test/misc/h5perf_gentest.c @@ -21,70 +21,70 @@ #include #include -#define FNAME "test_perf.h5" -#define NGROUPS 20 -#define NDSETS 20 -#define NATTRS 20 -#define DIM0 40 -#define NROWS 100 -#define NTYPES 9 -#define MAXVLEN 10 -#define FIXED_LEN 8 - -typedef enum { SOLID=0, LIQUID, GAS, PLASMA } phase_t; +#define FNAME "test_perf.h5" +#define NGROUPS 20 +#define NDSETS 20 +#define NATTRS 20 +#define DIM0 40 +#define NROWS 100 +#define NTYPES 9 +#define MAXVLEN 10 +#define FIXED_LEN 8 + +typedef enum { SOLID = 0, LIQUID, GAS, PLASMA } phase_t; typedef struct { - int i; - unsigned long long l; - float f; - double d; - char s[FIXED_LEN]; - phase_t e; - float f_array[FIXED_LEN]; - hvl_t i_vlen; - char *s_vlen; + int i; + unsigned long long l; + float f; + double d; + char s[FIXED_LEN]; + phase_t e; + float f_array[FIXED_LEN]; + hvl_t i_vlen; + char * s_vlen; } test_comp_t; typedef struct { - int zipcode; - char *city; + int zipcode; + char *city; } zipcode_t; -int add_attrs(hid_t oid, int idx); -int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) ; -herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, - int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen, - int compressed, int latest); +int add_attrs(hid_t oid, int idx); +int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf); +herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattrs, hsize_t nrows, + hsize_t dim0, hsize_t chunk, int vlen, int compressed, int latest); -int main (int argc, char *argv[]) +int +main(int argc, char *argv[]) { char fname[32]; - int i, ngrps=NGROUPS, ndsets=NDSETS, nattrs=NATTRS, dim0=DIM0, - chunk=DIM0/10+1, nrows=NROWS, vlen=MAXVLEN, l=0, z=0; + int i, ngrps = NGROUPS, ndsets = NDSETS, nattrs = NATTRS, dim0 = DIM0, chunk = DIM0 / 10 + 1, + nrows = NROWS, vlen = MAXVLEN, l = 0, z = 0; memset(fname, 0, 32); - for (i=1; i, Jan. 2013 ****************************************************************************/ -herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, - int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen, - int compressed, int latest) +herr_t +create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattrs, hsize_t nrows, hsize_t dim0, + hsize_t chunk, int vlen, int compressed, int latest) { - int i, j, k; - hid_t fid, sid_null, sid_scalar, sid_1d, sid_2d, did, aid, sid_2, sid_large, - fapl=H5P_DEFAULT, dcpl=H5P_DEFAULT, gid1, gid2, cmp_tid, tid_str, - tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s; - char name[32], tmp_name1[32], tmp_name2[32], tmp_name3[32]; - hsize_t dims[1]={dim0}, dims2d[2]={dim0, (dim0/4+1)}, dims_array[1]={FIXED_LEN}, - dim1[1]={2}; - char *enum_names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"}; - test_comp_t *buf_comp=NULL, *buf_comp_large=NULL; - int *buf_int=NULL; - float (*buf_float_a)[FIXED_LEN]=NULL; - double **buf_double2d=NULL; - hvl_t *buf_vlen_i=NULL; - char (*buf_str)[FIXED_LEN]; - char **buf_vlen_s=NULL; - hobj_ref_t buf_ref[2]; + int i, j, k; + hid_t fid, sid_null, sid_scalar, sid_1d, sid_2d, did, aid, sid_2, sid_large, + fapl = H5P_DEFAULT, dcpl = H5P_DEFAULT, gid1, gid2, cmp_tid, tid_str, tid_enum, tid_array_f, + tid_vlen_i, tid_vlen_s; + char name[32], tmp_name1[32], tmp_name2[32], tmp_name3[32]; + hsize_t dims[1] = {dim0}, dims2d[2] = {dim0, (dim0 / 4 + 1)}, dims_array[1] = {FIXED_LEN}, dim1[1] = {2}; + char * enum_names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"}; + test_comp_t *buf_comp = NULL, *buf_comp_large = NULL; + int * buf_int = NULL; + float(*buf_float_a)[FIXED_LEN] = NULL; + double **buf_double2d = NULL; + hvl_t * buf_vlen_i = NULL; + char(*buf_str)[FIXED_LEN]; + char ** buf_vlen_s = NULL; + hobj_ref_t buf_ref[2]; hdset_reg_ref_t buf_reg_ref[2]; - size_t offset, len; - herr_t status; - char *names[NTYPES] = { "int", "ulong", "float", "double", "fixed string", - "enum", "fixed float array", "vlen int array", "vlen strings"}; - hid_t types[NTYPES] = { H5T_NATIVE_INT, H5T_NATIVE_UINT64, H5T_NATIVE_FLOAT, - H5T_NATIVE_DOUBLE, tid_str, tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s}; - hsize_t coords[4][2] = { {0, 1}, {3, 5}, {1, 0}, {2, 4}}, start=0, stride=1, count=1; - - if (nrows < NROWS) nrows = NROWS; - if (ngrpsdim0) chunk=dim0/4; - if (chunk<1) chunk = 1; - if (vlen<1) vlen = MAXVLEN; + size_t offset, len; + herr_t status; + char * names[NTYPES] = {"int", + "ulong", + "float", + "double", + "fixed string", + "enum", + "fixed float array", + "vlen int array", + "vlen strings"}; + hid_t types[NTYPES] = {H5T_NATIVE_INT, H5T_NATIVE_UINT64, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE, tid_str, + tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s}; + hsize_t coords[4][2] = {{0, 1}, {3, 5}, {1, 0}, {2, 4}}, start = 0, stride = 1, count = 1; + + if (nrows < NROWS) + nrows = NROWS; + if (ngrps < NGROUPS) + ngrps = NGROUPS; + if (ndsets < NDSETS) + ndsets = NDSETS; + if (nattrs < NATTRS) + nattrs = NATTRS; + if (dim0 < DIM0) + dim0 = DIM0; + if (chunk > dim0) + chunk = dim0 / 4; + if (chunk < 1) + chunk = 1; + if (vlen < 1) + vlen = MAXVLEN; /* create fixed string datatype */ - types[4] = tid_str = H5Tcopy (H5T_C_S1); - H5Tset_size (tid_str, FIXED_LEN); + types[4] = tid_str = H5Tcopy(H5T_C_S1); + H5Tset_size(tid_str, FIXED_LEN); /* create enum datatype */ types[5] = tid_enum = H5Tenum_create(H5T_NATIVE_INT); - for (i = (int) SOLID; i <= (int) PLASMA; i++) { - phase_t val = (phase_t) i; - status = H5Tenum_insert (tid_enum, enum_names[i], &val); + for (i = (int)SOLID; i <= (int)PLASMA; i++) { + phase_t val = (phase_t)i; + status = H5Tenum_insert(tid_enum, enum_names[i], &val); } /* create float array datatype */ - types[6] = tid_array_f = H5Tarray_create (H5T_NATIVE_FLOAT, 1, dims_array); + types[6] = tid_array_f = H5Tarray_create(H5T_NATIVE_FLOAT, 1, dims_array); /* create variable length integer datatypes */ - types[7] = tid_vlen_i = H5Tvlen_create (H5T_NATIVE_INT); + types[7] = tid_vlen_i = H5Tvlen_create(H5T_NATIVE_INT); /* create variable length string datatype */ - types[8] = tid_vlen_s = H5Tcopy (H5T_C_S1); - H5Tset_size (tid_vlen_s, H5T_VARIABLE); + types[8] = tid_vlen_s = H5Tcopy(H5T_C_S1); + H5Tset_size(tid_vlen_s, H5T_VARIABLE); /* create compound datatypes */ - cmp_tid = H5Tcreate (H5T_COMPOUND, sizeof (test_comp_t)); - offset = 0; - for (i=0; i0) { - H5Pset_chunk (dcpl, 1, &chunk); + if (chunk > 0) { + H5Pset_chunk(dcpl, 1, &chunk); } /* set dataset compression */ if (compressed) { - if (chunk<=0) { - chunk = dim0/10+1;; - H5Pset_chunk (dcpl, 1, &chunk); + if (chunk <= 0) { + chunk = dim0 / 10 + 1; + ; + H5Pset_chunk(dcpl, 1, &chunk); } - H5Pset_shuffle (dcpl); - H5Pset_deflate (dcpl, 6); + H5Pset_shuffle(dcpl); + H5Pset_deflate(dcpl, 6); } /* allocate buffers */ - buf_comp = (test_comp_t *)calloc(dim0, sizeof(test_comp_t)); - buf_comp_large = (test_comp_t *)calloc(nrows, sizeof(test_comp_t)); - buf_int = (int *)calloc(dim0, sizeof(int)); - buf_float_a = malloc(dim0*sizeof(*buf_float_a)); - buf_vlen_i = (hvl_t *)calloc(dim0, sizeof (hvl_t)); - buf_vlen_s = (char **)calloc(dim0, sizeof(char *)); - buf_str = malloc(dim0*sizeof (*buf_str)); + buf_comp = (test_comp_t *)calloc(dim0, sizeof(test_comp_t)); + buf_comp_large = (test_comp_t *)calloc(nrows, sizeof(test_comp_t)); + buf_int = (int *)calloc(dim0, sizeof(int)); + buf_float_a = malloc(dim0 * sizeof(*buf_float_a)); + buf_vlen_i = (hvl_t *)calloc(dim0, sizeof(hvl_t)); + buf_vlen_s = (char **)calloc(dim0, sizeof(char *)); + buf_str = malloc(dim0 * sizeof(*buf_str)); /* allocate array of doulbe pointers */ - buf_double2d = (double **)calloc(dims2d[0],sizeof(double *)); + buf_double2d = (double **)calloc(dims2d[0], sizeof(double *)); /* allocate a contigous chunk of memory for the data */ - buf_double2d[0] = (double *)calloc( dims2d[0]*dims2d[1],sizeof(double) ); + buf_double2d[0] = (double *)calloc(dims2d[0] * dims2d[1], sizeof(double)); /* assign memory city to pointer array */ - for (i=1; i = 0) + H5E_BEGIN_TRY + { + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) free(buffer); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main */ - diff --git a/tools/test/misc/vds/UC_2.h b/tools/test/misc/vds/UC_2.h index 07f9b9a..e0334df 100644 --- a/tools/test/misc/vds/UC_2.h +++ b/tools/test/misc/vds/UC_2.h @@ -48,61 +48,51 @@ */ -#define UC_2_N_SOURCES 5 +#define UC_2_N_SOURCES 5 /* Dataset dimensions */ -#define UC_2_A_HEIGHT 2 -#define UC_2_B_HEIGHT 4 -#define UC_2_AB_HEIGHT 6 /* For hyperslab start position */ -#define UC_2_C_HEIGHT 2 -#define UC_2_D_HEIGHT 5 -#define UC_2_E_HEIGHT 3 -#define UC_2_FULL_HEIGHT 8 /* A+B+C and D+E */ -#define UC_2_WIDTH 7 -#define UC_2_FULL_WIDTH 14 /* 2*width */ - -#define UC_2_N_PLANES_IN_SERIES 3 /* number of planes in a series of sub-images */ -#define UC_2_N_MAX_PLANES H5S_UNLIMITED /* max number of planes */ -#define UC_2_N_TEST_PLANES 6 /* number of planes we write */ +#define UC_2_A_HEIGHT 2 +#define UC_2_B_HEIGHT 4 +#define UC_2_AB_HEIGHT 6 /* For hyperslab start position */ +#define UC_2_C_HEIGHT 2 +#define UC_2_D_HEIGHT 5 +#define UC_2_E_HEIGHT 3 +#define UC_2_FULL_HEIGHT 8 /* A+B+C and D+E */ +#define UC_2_WIDTH 7 +#define UC_2_FULL_WIDTH 14 /* 2*width */ + +#define UC_2_N_PLANES_IN_SERIES 3 /* number of planes in a series of sub-images */ +#define UC_2_N_MAX_PLANES H5S_UNLIMITED /* max number of planes */ +#define UC_2_N_TEST_PLANES 6 /* number of planes we write */ /* Dataset datatypes */ -#define UC_2_SOURCE_DATATYPE H5T_STD_I32LE -#define UC_2_VDS_DATATYPE H5T_STD_I32LE +#define UC_2_SOURCE_DATATYPE H5T_STD_I32LE +#define UC_2_VDS_DATATYPE H5T_STD_I32LE /* Starting size of datasets, both source and VDS */ -static hsize_t UC_2_DIMS[UC_2_N_SOURCES][RANK] = { - {0, UC_2_A_HEIGHT, UC_2_WIDTH}, - {0, UC_2_B_HEIGHT, UC_2_WIDTH}, - {0, UC_2_C_HEIGHT, UC_2_WIDTH}, - {0, UC_2_D_HEIGHT, UC_2_WIDTH}, - {0, UC_2_E_HEIGHT, UC_2_WIDTH} -}; +static hsize_t UC_2_DIMS[UC_2_N_SOURCES][RANK] = {{0, UC_2_A_HEIGHT, UC_2_WIDTH}, + {0, UC_2_B_HEIGHT, UC_2_WIDTH}, + {0, UC_2_C_HEIGHT, UC_2_WIDTH}, + {0, UC_2_D_HEIGHT, UC_2_WIDTH}, + {0, UC_2_E_HEIGHT, UC_2_WIDTH}}; /* Maximum size of datasets, both source and VDS */ -static hsize_t UC_2_MAX_DIMS[UC_2_N_SOURCES][RANK] = { - {UC_2_N_MAX_PLANES, UC_2_A_HEIGHT, UC_2_WIDTH}, - {UC_2_N_MAX_PLANES, UC_2_B_HEIGHT, UC_2_WIDTH}, - {UC_2_N_MAX_PLANES, UC_2_C_HEIGHT, UC_2_WIDTH}, - {UC_2_N_MAX_PLANES, UC_2_D_HEIGHT, UC_2_WIDTH}, - {UC_2_N_MAX_PLANES, UC_2_E_HEIGHT, UC_2_WIDTH} -}; +static hsize_t UC_2_MAX_DIMS[UC_2_N_SOURCES][RANK] = {{UC_2_N_MAX_PLANES, UC_2_A_HEIGHT, UC_2_WIDTH}, + {UC_2_N_MAX_PLANES, UC_2_B_HEIGHT, UC_2_WIDTH}, + {UC_2_N_MAX_PLANES, UC_2_C_HEIGHT, UC_2_WIDTH}, + {UC_2_N_MAX_PLANES, UC_2_D_HEIGHT, UC_2_WIDTH}, + {UC_2_N_MAX_PLANES, UC_2_E_HEIGHT, UC_2_WIDTH}}; /* File names for source datasets */ static char UC_2_FILE_NAMES[UC_2_N_SOURCES][NAME_LEN] = { - {"2_a.h5"}, - {"2_b.h5"}, - {"2_c.h5"}, - {"2_d.h5"}, - {"2_e.h5"} -}; + {"2_a.h5"}, {"2_b.h5"}, {"2_c.h5"}, {"2_d.h5"}, {"2_e.h5"}}; /* VDS file name */ -#define UC_2_VDS_FILE_NAME "2_vds.h5" +#define UC_2_VDS_FILE_NAME "2_vds.h5" /* Dataset names */ -#define UC_2_SOURCE_DSET_NAME "source_dset" -#define UC_2_SOURCE_DSET_PATH "/source_dset" -#define UC_2_VDS_DSET_NAME "vds_dset" +#define UC_2_SOURCE_DSET_NAME "source_dset" +#define UC_2_SOURCE_DSET_PATH "/source_dset" +#define UC_2_VDS_DSET_NAME "vds_dset" #endif /* UC_2_H */ - diff --git a/tools/test/misc/vds/UC_2_two_dims_gen.c b/tools/test/misc/vds/UC_2_two_dims_gen.c index b9799d6..2d21d03 100644 --- a/tools/test/misc/vds/UC_2_two_dims_gen.c +++ b/tools/test/misc/vds/UC_2_two_dims_gen.c @@ -17,7 +17,6 @@ * See the header file for a description. */ - #include #include "hdf5.h" @@ -25,72 +24,60 @@ #include "UC_common.h" #include "UC_2.h" -static hsize_t UC_2_VDS_DIMS[RANK] = {0, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH}; -static hsize_t UC_2_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH}; +static hsize_t UC_2_VDS_DIMS[RANK] = {0, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH}; +static hsize_t UC_2_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH}; /* Positions of source datasets in the VDS */ static hsize_t UC_2_POSITIONS[UC_2_N_SOURCES][RANK] = { - /* A */ {0, 0, 0}, - /* B */ {0, UC_2_A_HEIGHT, 0}, + /* A */ {0, 0, 0}, + /* B */ {0, UC_2_A_HEIGHT, 0}, /* C */ {0, UC_2_AB_HEIGHT, 0}, - /* D */ {0, 0, UC_2_WIDTH}, - /* E */ {0, UC_2_D_HEIGHT, UC_2_WIDTH} -}; + /* D */ {0, 0, UC_2_WIDTH}, + /* E */ {0, UC_2_D_HEIGHT, UC_2_WIDTH}}; /* Planes */ -static hsize_t UC_2_PLANES[UC_2_N_SOURCES][RANK] = { - {1, UC_2_A_HEIGHT, UC_2_WIDTH}, - {1, UC_2_B_HEIGHT, UC_2_WIDTH}, - {1, UC_2_C_HEIGHT, UC_2_WIDTH}, - {1, UC_2_D_HEIGHT, UC_2_WIDTH}, - {1, UC_2_E_HEIGHT, UC_2_WIDTH} -}; +static hsize_t UC_2_PLANES[UC_2_N_SOURCES][RANK] = {{1, UC_2_A_HEIGHT, UC_2_WIDTH}, + {1, UC_2_B_HEIGHT, UC_2_WIDTH}, + {1, UC_2_C_HEIGHT, UC_2_WIDTH}, + {1, UC_2_D_HEIGHT, UC_2_WIDTH}, + {1, UC_2_E_HEIGHT, UC_2_WIDTH}}; /* Chunk dimensions */ -static hsize_t UC_2_CHUNK_DIMS[UC_2_N_SOURCES][RANK] = { - {UC_2_N_PLANES_IN_SERIES, UC_2_A_HEIGHT, UC_2_WIDTH}, - {UC_2_N_PLANES_IN_SERIES, UC_2_B_HEIGHT, UC_2_WIDTH}, - {UC_2_N_PLANES_IN_SERIES, UC_2_C_HEIGHT, UC_2_WIDTH}, - {UC_2_N_PLANES_IN_SERIES, UC_2_D_HEIGHT, UC_2_WIDTH}, - {UC_2_N_PLANES_IN_SERIES, UC_2_E_HEIGHT, UC_2_WIDTH} -}; +static hsize_t UC_2_CHUNK_DIMS[UC_2_N_SOURCES][RANK] = {{UC_2_N_PLANES_IN_SERIES, UC_2_A_HEIGHT, UC_2_WIDTH}, + {UC_2_N_PLANES_IN_SERIES, UC_2_B_HEIGHT, UC_2_WIDTH}, + {UC_2_N_PLANES_IN_SERIES, UC_2_C_HEIGHT, UC_2_WIDTH}, + {UC_2_N_PLANES_IN_SERIES, UC_2_D_HEIGHT, UC_2_WIDTH}, + {UC_2_N_PLANES_IN_SERIES, UC_2_E_HEIGHT, UC_2_WIDTH}}; /* Fill values */ -static int UC_2_FILL_VALUES[UC_2_N_SOURCES] = { - -1, - -2, - -3, - -4, - -5 -}; -static int UC_2_VDS_FILL_VALUE = -9; +static int UC_2_FILL_VALUES[UC_2_N_SOURCES] = {-1, -2, -3, -4, -5}; +static int UC_2_VDS_FILL_VALUE = -9; int main(void) { - hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ - hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ - - hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ - hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ - hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ - hid_t did = H5I_INVALID_HID; /* dataset ID */ - hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ - hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hsize_t start[RANK]; /* starting point for hyperslab */ - hsize_t extent[RANK]; /* dataset extents */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ - int *buffer = NULL; /* data buffer */ - int value = -1; /* value written to datasets */ - hsize_t count = 0; /* number of elements in a plane */ - int n_planes = -1; /* number of planes to write */ + hsize_t start[RANK]; /* starting point for hyperslab */ + hsize_t extent[RANK]; /* dataset extents */ - int i; /* iterator */ - int j; /* iterator */ - hsize_t k; /* iterator */ + int * buffer = NULL; /* data buffer */ + int value = -1; /* value written to datasets */ + hsize_t count = 0; /* number of elements in a plane */ + int n_planes = -1; /* number of planes to write */ + int i; /* iterator */ + int j; /* iterator */ + hsize_t k; /* iterator */ /* Start by creating the virtual dataset (VDS) dataspace and creation * property list. The individual source datasets are then created @@ -98,15 +85,13 @@ main(void) */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_2_VDS_DATATYPE, - &UC_2_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_2_VDS_DATATYPE, &UC_2_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_2_VDS_DIMS, - UC_2_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_2_VDS_DIMS, UC_2_VDS_MAX_DIMS)) < 0) UC_ERROR /************************************ @@ -117,65 +102,61 @@ main(void) start[1] = 0; start[2] = 0; - for(i = 0; i < UC_2_N_SOURCES; i++) { + for (i = 0; i < UC_2_N_SOURCES; i++) { /* source dataset dcpl */ - if((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_chunk(src_dcplid, RANK, UC_2_CHUNK_DIMS[i]) < 0) + if (H5Pset_chunk(src_dcplid, RANK, UC_2_CHUNK_DIMS[i]) < 0) UC_ERROR - if(H5Pset_fill_value(src_dcplid, UC_2_SOURCE_DATATYPE, - &UC_2_FILL_VALUES[i]) < 0) + if (H5Pset_fill_value(src_dcplid, UC_2_SOURCE_DATATYPE, &UC_2_FILL_VALUES[i]) < 0) UC_ERROR - if(H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) + if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) UC_ERROR /* Create source file, dataspace, and dataset */ - if((fid = H5Fcreate(UC_2_FILE_NAMES[i], H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_2_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR - if((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], - UC_2_MAX_DIMS[i])) < 0) + if ((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], UC_2_MAX_DIMS[i])) < 0) UC_ERROR - if((did = H5Dcreate2(fid, UC_2_SOURCE_DSET_NAME, - UC_2_SOURCE_DATATYPE, src_sid, - H5P_DEFAULT, src_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_2_SOURCE_DSET_NAME, UC_2_SOURCE_DATATYPE, src_sid, H5P_DEFAULT, + src_dcplid, H5P_DEFAULT)) < 0) UC_ERROR /* Set the dataset's extent (will eventually vary with i) */ extent[0] = UC_2_N_TEST_PLANES; extent[1] = UC_2_PLANES[i][1]; extent[2] = UC_2_PLANES[i][2]; - if(H5Dset_extent(did, extent) < 0) + if (H5Dset_extent(did, extent) < 0) UC_ERROR /* Create a data buffer that represents a plane */ count = UC_2_PLANES[i][1] * UC_2_PLANES[i][2]; - if(NULL == (buffer = (int *)malloc(count * sizeof(int)))) + if (NULL == (buffer = (int *)malloc(count * sizeof(int)))) UC_ERROR /* Create the memory dataspace */ - if((msid = H5Screate_simple(RANK, UC_2_PLANES[i], NULL)) < 0) + if ((msid = H5Screate_simple(RANK, UC_2_PLANES[i], NULL)) < 0) UC_ERROR /* Get the file dataspace */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) UC_ERROR /* Write planes to the dataset, number will eventually vary with i */ n_planes = UC_2_N_TEST_PLANES; - for(j = 0; j < n_planes; j++) { + for (j = 0; j < n_planes; j++) { value = ((i + 1) * 10) + j; - for(k = 0; k < count; k++) - buffer[k] = value; + for (k = 0; k < count; k++) + buffer[k] = value; start[0] = (hsize_t)j; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_2_PLANES[i], NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_2_PLANES[i], NULL) < 0) UC_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) UC_ERROR } /* end for */ @@ -184,30 +165,27 @@ main(void) start[0] = 0; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_2_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_2_MAX_DIMS[i], NULL) < 0) UC_ERROR - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_2_POSITIONS[i], NULL, - UC_2_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_2_POSITIONS[i], NULL, UC_2_MAX_DIMS[i], NULL) < 0) UC_ERROR /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], - UC_2_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], UC_2_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR /* close */ - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) UC_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) UC_ERROR - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR - if(H5Pclose(src_dcplid) < 0) + if (H5Pclose(src_dcplid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR free(buffer); @@ -218,51 +196,51 @@ main(void) *******************************/ /* file */ - if((fid = H5Fcreate(UC_2_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_2_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_2_VDS_DSET_NAME, UC_2_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_2_VDS_DSET_NAME, UC_2_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { - if(src_sid >= 0) + H5E_BEGIN_TRY + { + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) free(buffer); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/misc/vds/UC_3.h b/tools/test/misc/vds/UC_3.h index 0c26dfb..d9f3f5a 100644 --- a/tools/test/misc/vds/UC_3.h +++ b/tools/test/misc/vds/UC_3.h @@ -31,42 +31,40 @@ * Height and width are large enough to encompass the * mapped source datasets with gaps. */ -#define UC_31_VDS_HEIGHT 25 /* full height + 7 (gaps of 1) */ -#define UC_31_VDS_WIDTH 8 /* full width + 0 (no gaps) */ -#define UC_32_VDS_HEIGHT 13 /* full height + 5 */ -#define UC_32_VDS_WIDTH 19 /* full width + 5 */ -#define UC_31_GAP 1 +#define UC_31_VDS_HEIGHT 25 /* full height + 7 (gaps of 1) */ +#define UC_31_VDS_WIDTH 8 /* full width + 0 (no gaps) */ +#define UC_32_VDS_HEIGHT 13 /* full height + 5 */ +#define UC_32_VDS_WIDTH 19 /* full width + 5 */ +#define UC_31_GAP 1 /* VDS datatypes */ -#define UC_31_VDS_DATATYPE H5T_STD_I32LE -#define UC_32_VDS_DATATYPE H5T_STD_I32LE +#define UC_31_VDS_DATATYPE H5T_STD_I32LE +#define UC_32_VDS_DATATYPE H5T_STD_I32LE /* Starting size of virtual datasets */ -static hsize_t UC_31_VDS_DIMS[RANK] = {0, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH}; -static hsize_t UC_32_VDS_DIMS[RANK] = {0, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH}; +static hsize_t UC_31_VDS_DIMS[RANK] = {0, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH}; +static hsize_t UC_32_VDS_DIMS[RANK] = {0, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH}; /* Maximum size of virtual datasets */ -static hsize_t UC_31_VDS_MAX_DIMS[RANK] = {UC_1_N_MAX_PLANES, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH}; -static hsize_t UC_32_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH}; +static hsize_t UC_31_VDS_MAX_DIMS[RANK] = {UC_1_N_MAX_PLANES, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH}; +static hsize_t UC_32_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH}; /* Positions of mapped source datasets */ static hsize_t UC_32_POSITIONS[UC_2_N_SOURCES][RANK] = { - /* A */ {0, 1, 1}, - /* B */ {0, 4, 0}, - /* C */ {0, 11, 4}, - /* D */ {0, 1, 9}, - /* E */ {0, 8, 12} -}; + /* A */ {0, 1, 1}, + /* B */ {0, 4, 0}, + /* C */ {0, 11, 4}, + /* D */ {0, 1, 9}, + /* E */ {0, 8, 12}}; /* VDS file names */ -#define UC_31_VDS_FILE_NAME "3_1_vds.h5" -#define UC_32_VDS_FILE_NAME "3_2_vds.h5" +#define UC_31_VDS_FILE_NAME "3_1_vds.h5" +#define UC_32_VDS_FILE_NAME "3_2_vds.h5" /* Dataset name */ -#define UC_3_VDS_DSET_NAME "vds_dset" +#define UC_3_VDS_DSET_NAME "vds_dset" /* Fill value */ -static int UC_3_VDS_FILL_VALUE = -9; +static int UC_3_VDS_FILL_VALUE = -9; #endif /* UC_3_H */ - diff --git a/tools/test/misc/vds/UC_3_gaps_gen.c b/tools/test/misc/vds/UC_3_gaps_gen.c index 74a23dc..54fa766 100644 --- a/tools/test/misc/vds/UC_3_gaps_gen.c +++ b/tools/test/misc/vds/UC_3_gaps_gen.c @@ -29,28 +29,26 @@ static herr_t create_3_1_vds(void) { - hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ - hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ - hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ - hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ - hsize_t start[RANK]; /* source starting point for hyperslab */ - hsize_t position[RANK]; /* vds mapping positions */ + hsize_t start[RANK]; /* source starting point for hyperslab */ + hsize_t position[RANK]; /* vds mapping positions */ - int i; /* iterator */ + int i; /* iterator */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_31_VDS_DATATYPE, - &UC_3_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_31_VDS_DATATYPE, &UC_3_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_31_VDS_DIMS, - UC_31_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_31_VDS_DIMS, UC_31_VDS_MAX_DIMS)) < 0) UC_ERROR /* Set starting positions */ @@ -65,26 +63,22 @@ create_3_1_vds(void) /****************************** * Create source-VDS mappings * ******************************/ - for(i = 0; i < UC_1_N_SOURCES; i++) { + for (i = 0; i < UC_1_N_SOURCES; i++) { - if((src_sid = H5Screate_simple(RANK, UC_1_DIMS[i], - UC_1_MAX_DIMS[i])) < 0) - UC_ERROR + if ((src_sid = H5Screate_simple(RANK, UC_1_DIMS[i], UC_1_MAX_DIMS[i])) < 0) + UC_ERROR /* set up hyperslabs for source and destination datasets */ - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_1_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_1_MAX_DIMS[i], NULL) < 0) UC_ERROR - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, position, - NULL, UC_1_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, position, NULL, UC_1_MAX_DIMS[i], NULL) < 0) UC_ERROR position[1] += UC_1_DIMS[i][1] + UC_31_GAP; /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_1_FILE_NAMES[i], - UC_1_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_1_FILE_NAMES[i], UC_1_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR } /* end for */ @@ -94,39 +88,40 @@ create_3_1_vds(void) *******************************/ /* file */ - if((fid = H5Fcreate(UC_31_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_31_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_31_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_31_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return 0; error: - H5E_BEGIN_TRY { - if(vds_sid >= 0) + H5E_BEGIN_TRY + { + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - } H5E_END_TRY + } + H5E_END_TRY return -1; @@ -136,27 +131,25 @@ error: static herr_t create_3_2_vds(void) { - hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ - hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ - hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ - hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ - hsize_t start[RANK]; /* source starting point for hyperslab */ + hsize_t start[RANK]; /* source starting point for hyperslab */ - int i; /* iterator */ + int i; /* iterator */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_32_VDS_DATATYPE, - &UC_3_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_32_VDS_DATATYPE, &UC_3_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_32_VDS_DIMS, - UC_32_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_32_VDS_DIMS, UC_32_VDS_MAX_DIMS)) < 0) UC_ERROR /* Set starting positions */ @@ -167,25 +160,22 @@ create_3_2_vds(void) /****************************** * Create source-VDS mappings * ******************************/ - for(i = 0; i < UC_2_N_SOURCES; i++) { + for (i = 0; i < UC_2_N_SOURCES; i++) { - if((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], - UC_2_MAX_DIMS[i])) < 0) - UC_ERROR + if ((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], UC_2_MAX_DIMS[i])) < 0) + UC_ERROR /* set up hyperslabs for source and destination datasets */ - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_2_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_2_MAX_DIMS[i], NULL) < 0) UC_ERROR - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_32_POSITIONS[i], - NULL, UC_2_MAX_DIMS[i], NULL) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_32_POSITIONS[i], NULL, UC_2_MAX_DIMS[i], NULL) < + 0) UC_ERROR /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], - UC_2_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], UC_2_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR } /* end for */ @@ -195,39 +185,40 @@ create_3_2_vds(void) *******************************/ /* file */ - if((fid = H5Fcreate(UC_32_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_32_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_32_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_32_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return 0; error: - H5E_BEGIN_TRY { - if(vds_sid >= 0) + H5E_BEGIN_TRY + { + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - } H5E_END_TRY + } + H5E_END_TRY return -1; @@ -237,10 +228,10 @@ int main(void) { - if(create_3_1_vds() < 0) + if (create_3_1_vds() < 0) UC_ERROR - if(create_3_2_vds() < 0) + if (create_3_2_vds() < 0) UC_ERROR return EXIT_SUCCESS; @@ -250,4 +241,3 @@ error: return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/misc/vds/UC_4.h b/tools/test/misc/vds/UC_4.h index 5dba4fb..5322b9d 100644 --- a/tools/test/misc/vds/UC_4.h +++ b/tools/test/misc/vds/UC_4.h @@ -29,39 +29,35 @@ /* virtual dataset <---> source dataset mapping and sizes */ -#define UC_4_N_SOURCES 3 +#define UC_4_N_SOURCES 3 /* Dataset dimensions */ -#define UC_4_SRC_PLANES 3 -#define UC_4_HEIGHT 4 -#define UC_4_WIDTH 4 +#define UC_4_SRC_PLANES 3 +#define UC_4_HEIGHT 4 +#define UC_4_WIDTH 4 /* max number of planes for VDS (sources are finite) */ -#define UC_4_VDS_MAX_PLANES H5S_UNLIMITED -#define UC_4_N_TEST_PLANES 9 /* number of planes in the VDS */ +#define UC_4_VDS_MAX_PLANES H5S_UNLIMITED +#define UC_4_N_TEST_PLANES 9 /* number of planes in the VDS */ /* Dataset datatypes */ -#define UC_4_SOURCE_DATATYPE H5T_STD_I32LE -#define UC_4_VDS_DATATYPE H5T_STD_I32LE +#define UC_4_SOURCE_DATATYPE H5T_STD_I32LE +#define UC_4_VDS_DATATYPE H5T_STD_I32LE /* Starting size of datasets, both source and VDS */ static hsize_t UC_4_SOURCE_DIMS[RANK] = {0, UC_4_HEIGHT, UC_4_WIDTH}; -static hsize_t UC_4_VDS_DIMS[RANK] = {0, UC_4_HEIGHT, UC_4_WIDTH}; +static hsize_t UC_4_VDS_DIMS[RANK] = {0, UC_4_HEIGHT, UC_4_WIDTH}; /* Max size of datasets, both source and VDS */ static hsize_t UC_4_SOURCE_MAX_DIMS[RANK] = {UC_4_SRC_PLANES, UC_4_HEIGHT, UC_4_WIDTH}; -static hsize_t UC_4_VDS_MAX_DIMS[RANK] = {UC_4_VDS_MAX_PLANES, UC_4_HEIGHT, UC_4_WIDTH}; +static hsize_t UC_4_VDS_MAX_DIMS[RANK] = {UC_4_VDS_MAX_PLANES, UC_4_HEIGHT, UC_4_WIDTH}; /* Planes (both source and VDS) */ static hsize_t UC_4_PLANE[RANK] = {1, UC_4_HEIGHT, UC_4_WIDTH}; /* File names for source datasets */ -static char UC_4_FILE_NAMES[UC_4_N_SOURCES][NAME_LEN] = { - {"4_0.h5"}, - {"4_1.h5"}, - {"4_2.h5"} -}; -static char UC_4_MAPPING_FILE_NAME[NAME_LEN] = "4_%b.h5"; +static char UC_4_FILE_NAMES[UC_4_N_SOURCES][NAME_LEN] = {{"4_0.h5"}, {"4_1.h5"}, {"4_2.h5"}}; +static char UC_4_MAPPING_FILE_NAME[NAME_LEN] = "4_%b.h5"; /* VDS file name */ static char UC_4_VDS_FILE_NAME[NAME_LEN] = "4_vds.h5"; @@ -72,13 +68,7 @@ static char UC_4_SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; static char UC_4_VDS_DSET_NAME[NAME_LEN] = "vds_dset"; /* Fill values */ -static int UC_4_FILL_VALUES[UC_4_N_SOURCES] = { - -1, - -2, - -3 -}; -static int UC_4_VDS_FILL_VALUE = -9; +static int UC_4_FILL_VALUES[UC_4_N_SOURCES] = {-1, -2, -3}; +static int UC_4_VDS_FILL_VALUE = -9; #endif /* UC_4_H */ - - diff --git a/tools/test/misc/vds/UC_4_printf_gen.c b/tools/test/misc/vds/UC_4_printf_gen.c index 24451e9..d4cadfb 100644 --- a/tools/test/misc/vds/UC_4_printf_gen.c +++ b/tools/test/misc/vds/UC_4_printf_gen.c @@ -27,109 +27,104 @@ int main(void) { - hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ - hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ - hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ - hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ - hid_t did = H5I_INVALID_HID; /* dataset ID */ - hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ - hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ /* Hyperslab arrays */ hsize_t start[RANK] = {0, 0, 0}; hsize_t count[RANK] = {H5S_UNLIMITED, 1, 1}; - int *buffer = NULL; /* data buffer */ - int value = -1; /* value written to datasets */ + int *buffer = NULL; /* data buffer */ + int value = -1; /* value written to datasets */ - hsize_t n = 0; /* number of elements in a plane */ + hsize_t n = 0; /* number of elements in a plane */ - int i; /* iterator */ - int j; /* iterator */ - hsize_t k; /* iterator */ + int i; /* iterator */ + int j; /* iterator */ + hsize_t k; /* iterator */ /************************************ * Create source files and datasets * ************************************/ /* Create source dataspace ID */ - if((src_sid = H5Screate_simple(RANK, UC_4_SOURCE_DIMS, - UC_4_SOURCE_MAX_DIMS)) < 0) + if ((src_sid = H5Screate_simple(RANK, UC_4_SOURCE_DIMS, UC_4_SOURCE_MAX_DIMS)) < 0) UC_ERROR - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_4_SOURCE_MAX_DIMS, NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_4_SOURCE_MAX_DIMS, NULL) < 0) UC_ERROR /* Create source files and datasets */ - for(i = 0; i < UC_4_N_SOURCES; i++) { + for (i = 0; i < UC_4_N_SOURCES; i++) { /* source dataset dcpl */ - if((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_chunk(src_dcplid, RANK, UC_4_PLANE) < 0) + if (H5Pset_chunk(src_dcplid, RANK, UC_4_PLANE) < 0) UC_ERROR - if(H5Pset_fill_value(src_dcplid, UC_4_SOURCE_DATATYPE, - &UC_4_FILL_VALUES[i]) < 0) + if (H5Pset_fill_value(src_dcplid, UC_4_SOURCE_DATATYPE, &UC_4_FILL_VALUES[i]) < 0) UC_ERROR - if(H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) + if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) UC_ERROR /* Create source file and dataset */ - if((fid = H5Fcreate(UC_4_FILE_NAMES[i], H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_4_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR - if((did = H5Dcreate2(fid, UC_4_SOURCE_DSET_NAME, - UC_4_SOURCE_DATATYPE, src_sid, - H5P_DEFAULT, src_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_4_SOURCE_DSET_NAME, UC_4_SOURCE_DATATYPE, src_sid, H5P_DEFAULT, + src_dcplid, H5P_DEFAULT)) < 0) UC_ERROR /* Set the dataset's extent */ - if(H5Dset_extent(did, UC_4_SOURCE_MAX_DIMS) < 0) + if (H5Dset_extent(did, UC_4_SOURCE_MAX_DIMS) < 0) UC_ERROR /* Create a data buffer that represents a plane */ n = UC_4_PLANE[1] * UC_4_PLANE[2]; - if(NULL == (buffer = (int *)malloc(n * sizeof(int)))) + if (NULL == (buffer = (int *)malloc(n * sizeof(int)))) UC_ERROR /* Create the memory dataspace */ - if((msid = H5Screate_simple(RANK, UC_4_PLANE, NULL)) < 0) + if ((msid = H5Screate_simple(RANK, UC_4_PLANE, NULL)) < 0) UC_ERROR /* Get the file dataspace */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) UC_ERROR /* Write planes to the dataset */ - for(j = 0; j < UC_4_SRC_PLANES; j++) { + for (j = 0; j < UC_4_SRC_PLANES; j++) { value = ((i + 1) * 10) + j; - for(k = 0; k < n; k++) - buffer[k] = value; + for (k = 0; k < n; k++) + buffer[k] = value; start[0] = (hsize_t)j; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_4_PLANE, NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_4_PLANE, NULL) < 0) UC_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) UC_ERROR } /* end for */ /* close */ - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) UC_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) UC_ERROR - if(H5Pclose(src_dcplid) < 0) + if (H5Pclose(src_dcplid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR free(buffer); @@ -140,78 +135,75 @@ main(void) *******************/ /* Create file */ - if((fid = H5Fcreate(UC_4_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_4_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_4_VDS_DATATYPE, - &UC_4_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_4_VDS_DATATYPE, &UC_4_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_4_VDS_DIMS, - UC_4_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_4_VDS_DIMS, UC_4_VDS_MAX_DIMS)) < 0) UC_ERROR start[0] = 0; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, - UC_4_SOURCE_MAX_DIMS, count, UC_4_SOURCE_MAX_DIMS) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, UC_4_SOURCE_MAX_DIMS, count, + UC_4_SOURCE_MAX_DIMS) < 0) UC_ERROR /* Add VDS mapping - The mapped file name uses a printf-like * naming scheme that automatically maps new files. */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_4_MAPPING_FILE_NAME, - UC_4_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_4_MAPPING_FILE_NAME, UC_4_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR /* Create dataset */ - if((did = H5Dcreate2(fid, UC_4_VDS_DSET_NAME, UC_4_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_4_VDS_DSET_NAME, UC_4_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { - if(src_sid >= 0) + H5E_BEGIN_TRY + { + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) free(buffer); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/misc/vds/UC_5.h b/tools/test/misc/vds/UC_5.h index 3f8fe41..5ed230c 100644 --- a/tools/test/misc/vds/UC_5.h +++ b/tools/test/misc/vds/UC_5.h @@ -28,20 +28,20 @@ /* virtual dataset <---> source dataset mapping and sizes */ -#define UC_5_N_SOURCES 3 +#define UC_5_N_SOURCES 3 /* Dataset dimensions */ -#define UC_5_SRC_PLANES 3 -#define UC_5_HEIGHT 4 -#define UC_5_WIDTH 4 +#define UC_5_SRC_PLANES 3 +#define UC_5_HEIGHT 4 +#define UC_5_WIDTH 4 /* max number of planes for datasets */ -#define UC_5_MAX_PLANES H5S_UNLIMITED -#define UC_5_N_TEST_PLANES 9 /* number of planes in VDS */ +#define UC_5_MAX_PLANES H5S_UNLIMITED +#define UC_5_N_TEST_PLANES 9 /* number of planes in VDS */ /* Dataset datatypes */ -#define UC_5_SOURCE_DATATYPE H5T_STD_I32LE -#define UC_5_VDS_DATATYPE H5T_STD_I32LE +#define UC_5_SOURCE_DATATYPE H5T_STD_I32LE +#define UC_5_VDS_DATATYPE H5T_STD_I32LE /* Starting size of datasets, both source and VDS */ static hsize_t UC_5_SOURCE_DIMS[RANK] = {0, UC_5_HEIGHT, UC_5_WIDTH}; @@ -55,11 +55,7 @@ static hsize_t UC_5_VDS_MAX_DIMS[RANK] = {UC_5_MAX_PLANES, UC_5_HEIGHT, UC_5_ static hsize_t UC_5_PLANE[RANK] = {1, UC_5_HEIGHT, UC_5_WIDTH}; /* File names for source datasets */ -static char UC_5_FILE_NAMES[UC_5_N_SOURCES][NAME_LEN] = { - {"5_a.h5"}, - {"5_b.h5"}, - {"5_c.h5"} -}; +static char UC_5_FILE_NAMES[UC_5_N_SOURCES][NAME_LEN] = {{"5_a.h5"}, {"5_b.h5"}, {"5_c.h5"}}; /* VDS file name */ static char UC_5_VDS_FILE_NAME[NAME_LEN] = "5_vds.h5"; @@ -70,12 +66,7 @@ static char UC_5_SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; static char UC_5_VDS_DSET_NAME[NAME_LEN] = "vds_dset"; /* Fill values */ -static int UC_5_FILL_VALUES[UC_5_N_SOURCES] = { - -1, - -2, - -3 -}; -static int UC_5_VDS_FILL_VALUE = -9; +static int UC_5_FILL_VALUES[UC_5_N_SOURCES] = {-1, -2, -3}; +static int UC_5_VDS_FILL_VALUE = -9; #endif /* UC_5_H */ - diff --git a/tools/test/misc/vds/UC_5_stride_gen.c b/tools/test/misc/vds/UC_5_stride_gen.c index 726ce6e..d0c6d28 100644 --- a/tools/test/misc/vds/UC_5_stride_gen.c +++ b/tools/test/misc/vds/UC_5_stride_gen.c @@ -27,31 +27,31 @@ int main(void) { - hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ - hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ + hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */ + hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */ - hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ - hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ + hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */ + hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */ - hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ - hid_t did = H5I_INVALID_HID; /* dataset ID */ - hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ - hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */ + hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */ - hsize_t extent[RANK]; /* source dataset extents */ - hsize_t start[RANK]; /* starting point for hyperslab */ - hsize_t stride[RANK]; /* hypserslab stride */ - hsize_t count[RANK]; /* hypserslab count */ - hsize_t map_start = 0; /* starting point in the VDS map */ + hsize_t extent[RANK]; /* source dataset extents */ + hsize_t start[RANK]; /* starting point for hyperslab */ + hsize_t stride[RANK]; /* hypserslab stride */ + hsize_t count[RANK]; /* hypserslab count */ + hsize_t map_start = 0; /* starting point in the VDS map */ - int *buffer = NULL; /* data buffer */ - int value = -1; /* value written to datasets */ + int *buffer = NULL; /* data buffer */ + int value = -1; /* value written to datasets */ - hsize_t n = 0; /* number of elements in a plane */ + hsize_t n = 0; /* number of elements in a plane */ - int i; /* iterator */ - int j; /* iterator */ - hsize_t k; /* iterator */ + int i; /* iterator */ + int j; /* iterator */ + hsize_t k; /* iterator */ /* Start by creating the virtual dataset (VDS) dataspace and creation * property list. The individual source datasets are then created @@ -59,15 +59,13 @@ main(void) */ /* Create VDS dcpl */ - if((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_fill_value(vds_dcplid, UC_5_VDS_DATATYPE, - &UC_5_VDS_FILL_VALUE) < 0) + if (H5Pset_fill_value(vds_dcplid, UC_5_VDS_DATATYPE, &UC_5_VDS_FILL_VALUE) < 0) UC_ERROR /* Create VDS dataspace */ - if((vds_sid = H5Screate_simple(RANK, UC_5_VDS_DIMS, - UC_5_VDS_MAX_DIMS)) < 0) + if ((vds_sid = H5Screate_simple(RANK, UC_5_VDS_DIMS, UC_5_VDS_MAX_DIMS)) < 0) UC_ERROR /********************************* @@ -75,9 +73,9 @@ main(void) *********************************/ /* Hyperslab array setup */ - start[0] = 0; - start[1] = 0; - start[2] = 0; + start[0] = 0; + start[1] = 0; + start[2] = 0; map_start = 0; stride[0] = UC_5_N_SOURCES; @@ -92,61 +90,57 @@ main(void) extent[1] = UC_5_HEIGHT; extent[2] = UC_5_WIDTH; - for(i = 0; i < UC_5_N_SOURCES; i++) { + for (i = 0; i < UC_5_N_SOURCES; i++) { /* source dataset dcpl */ - if((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) UC_ERROR - if(H5Pset_chunk(src_dcplid, RANK, UC_5_PLANE) < 0) + if (H5Pset_chunk(src_dcplid, RANK, UC_5_PLANE) < 0) UC_ERROR - if(H5Pset_fill_value(src_dcplid, UC_5_SOURCE_DATATYPE, - &UC_5_FILL_VALUES[i]) < 0) + if (H5Pset_fill_value(src_dcplid, UC_5_SOURCE_DATATYPE, &UC_5_FILL_VALUES[i]) < 0) UC_ERROR - if(H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) + if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0) UC_ERROR /* Create source file, dataspace, and dataset */ - if((fid = H5Fcreate(UC_5_FILE_NAMES[i], H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_5_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR - if((src_sid = H5Screate_simple(RANK, UC_5_SOURCE_DIMS, - UC_5_SOURCE_MAX_DIMS)) < 0) + if ((src_sid = H5Screate_simple(RANK, UC_5_SOURCE_DIMS, UC_5_SOURCE_MAX_DIMS)) < 0) UC_ERROR - if((did = H5Dcreate2(fid, UC_5_SOURCE_DSET_NAME, - UC_5_SOURCE_DATATYPE, src_sid, - H5P_DEFAULT, src_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_5_SOURCE_DSET_NAME, UC_5_SOURCE_DATATYPE, src_sid, H5P_DEFAULT, + src_dcplid, H5P_DEFAULT)) < 0) UC_ERROR /* Set the dataset's extent */ - if(H5Dset_extent(did, extent) < 0) + if (H5Dset_extent(did, extent) < 0) UC_ERROR /* Create a data buffer that represents a plane */ n = UC_5_PLANE[1] * UC_5_PLANE[2]; - if(NULL == (buffer = (int *)malloc(n * sizeof(int)))) + if (NULL == (buffer = (int *)malloc(n * sizeof(int)))) UC_ERROR /* Create the memory dataspace */ - if((msid = H5Screate_simple(RANK, UC_5_PLANE, NULL)) < 0) + if ((msid = H5Screate_simple(RANK, UC_5_PLANE, NULL)) < 0) UC_ERROR /* Get the file dataspace */ - if((fsid = H5Dget_space(did)) < 0) + if ((fsid = H5Dget_space(did)) < 0) UC_ERROR /* Write planes to the dataset */ - for(j = 0; j < UC_5_SRC_PLANES; j++) { + for (j = 0; j < UC_5_SRC_PLANES; j++) { value = ((i + 1) * 10) + j; - for(k = 0; k < n; k++) - buffer[k] = value; + for (k = 0; k < n; k++) + buffer[k] = value; start[0] = (hsize_t)j; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_5_PLANE, NULL) < 0) + if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_5_PLANE, NULL) < 0) UC_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) UC_ERROR } /* end for */ @@ -155,32 +149,29 @@ main(void) start[0] = 0; start[1] = 0; start[2] = 0; - if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, - UC_5_SOURCE_MAX_DIMS, NULL) < 0) + if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_5_SOURCE_MAX_DIMS, NULL) < 0) UC_ERROR start[0] = map_start; - if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, stride, - count, UC_5_PLANE) < 0) + if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, stride, count, UC_5_PLANE) < 0) UC_ERROR map_start += 1; /* Add VDS mapping */ - if(H5Pset_virtual(vds_dcplid, vds_sid, UC_5_FILE_NAMES[i], - UC_5_SOURCE_DSET_PATH, src_sid) < 0) + if (H5Pset_virtual(vds_dcplid, vds_sid, UC_5_FILE_NAMES[i], UC_5_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR /* close */ - if(H5Sclose(msid) < 0) + if (H5Sclose(msid) < 0) UC_ERROR - if(H5Sclose(fsid) < 0) + if (H5Sclose(fsid) < 0) UC_ERROR - if(H5Sclose(src_sid) < 0) + if (H5Sclose(src_sid) < 0) UC_ERROR - if(H5Pclose(src_dcplid) < 0) + if (H5Pclose(src_dcplid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR free(buffer); @@ -191,51 +182,51 @@ main(void) *******************/ /* file */ - if((fid = H5Fcreate(UC_5_VDS_FILE_NAME, H5F_ACC_TRUNC, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(UC_5_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ - if((did = H5Dcreate2(fid, UC_5_VDS_DSET_NAME, UC_5_VDS_DATATYPE, vds_sid, - H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, UC_5_VDS_DSET_NAME, UC_5_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, + H5P_DEFAULT)) < 0) UC_ERROR /* close */ - if(H5Pclose(vds_dcplid) < 0) + if (H5Pclose(vds_dcplid) < 0) UC_ERROR - if(H5Sclose(vds_sid) < 0) + if (H5Sclose(vds_sid) < 0) UC_ERROR - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) UC_ERROR - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) UC_ERROR return EXIT_SUCCESS; error: - H5E_BEGIN_TRY { - if(src_sid >= 0) + H5E_BEGIN_TRY + { + if (src_sid >= 0) (void)H5Sclose(src_sid); - if(src_dcplid >= 0) + if (src_dcplid >= 0) (void)H5Pclose(src_dcplid); - if(vds_sid >= 0) + if (vds_sid >= 0) (void)H5Sclose(vds_sid); - if(vds_dcplid >= 0) + if (vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); - if(fid >= 0) + if (fid >= 0) (void)H5Fclose(fid); - if(did >= 0) + if (did >= 0) (void)H5Dclose(did); - if(msid >= 0) + if (msid >= 0) (void)H5Sclose(msid); - if(fsid >= 0) + if (fsid >= 0) (void)H5Sclose(fsid); - if(buffer != NULL) + if (buffer != NULL) free(buffer); - } H5E_END_TRY + } + H5E_END_TRY return EXIT_FAILURE; } /* end main() */ - diff --git a/tools/test/misc/vds/UC_common.h b/tools/test/misc/vds/UC_common.h index 78d8a11..af3ef03 100644 --- a/tools/test/misc/vds/UC_common.h +++ b/tools/test/misc/vds/UC_common.h @@ -28,21 +28,26 @@ ******************************************/ /* All datasets are 3D */ -#define RANK 3 +#define RANK 3 /* Lengths of string identifiers (file, dataset names, etc.) */ -#define NAME_LEN 32 +#define NAME_LEN 32 /* Compression level */ -#define COMPRESSION_LEVEL 7 +#define COMPRESSION_LEVEL 7 /* Booleans */ -#define TRUE 1 +#define TRUE 1 #define FALSE 0 /* Testing macros */ -#define AT() printf (" at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); -#define UC_ERROR {puts("*ERROR*"); fflush(stdout); AT(); goto error;} +#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); +#define UC_ERROR \ + { \ + puts("*ERROR*"); \ + fflush(stdout); \ + AT(); \ + goto error; \ + } #endif /* USE_CASE_COMMON_H */ - diff --git a/tools/test/perform/chunk.c b/tools/test/perform/chunk.c index 3603c9b..90ae815 100644 --- a/tools/test/perform/chunk.c +++ b/tools/test/perform/chunk.c @@ -25,73 +25,70 @@ #include "hdf5.h" #ifdef H5_STDC_HEADERS -# include -# include -# include -# include +#include +#include +#include +#include #endif /* Solaris Studio defines attribute, but for the attributes we need */ #if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus || defined(__SUNPRO_C) -# undef __attribute__ -# define __attribute__(X) /*void*/ -# define H5_ATTR_UNUSED /*void*/ +#undef __attribute__ +#define __attribute__(X) /*void*/ +#define H5_ATTR_UNUSED /*void*/ #else -# define H5_ATTR_UNUSED __attribute__((unused)) +#define H5_ATTR_UNUSED __attribute__((unused)) #endif -#define FILE_NAME "chunk.h5" -#define LINESPOINTS "lines" -#define CH_SIZE 100 /*squared in terms of bytes */ -#define DS_SIZE 20 /*squared in terms of chunks */ -#define FILTER_COUNTER 305 -#define READ 0 -#define WRITE 1 -#define MIN(X,Y) ((X)<(Y)?(X):(Y)) -#define MAX(X,Y) ((X)>(Y)?(X):(Y)) -#define SQUARE(X) ((X)*(X)) +#define FILE_NAME "chunk.h5" +#define LINESPOINTS "lines" +#define CH_SIZE 100 /*squared in terms of bytes */ +#define DS_SIZE 20 /*squared in terms of chunks */ +#define FILTER_COUNTER 305 +#define READ 0 +#define WRITE 1 +#define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) +#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) +#define SQUARE(X) ((X) * (X)) /* The row-major test */ -#define RM_CACHE_STRT 25 -#define RM_CACHE_END 25 -#define RM_CACHE_DELT 5 -#define RM_START (double)0.50F -#define RM_END (double)5.00F -#define RM_DELTA (double)0.50F -#define RM_W0 0.0F -#define RM_NRDCC 521 +#define RM_CACHE_STRT 25 +#define RM_CACHE_END 25 +#define RM_CACHE_DELT 5 +#define RM_START (double)0.50F +#define RM_END (double)5.00F +#define RM_DELTA (double)0.50F +#define RM_W0 0.0F +#define RM_NRDCC 521 /* Diagonal test */ -#define DIAG_CACHE_STRT 25 -#define DIAG_CACHE_END 25 -#define DIAG_CACHE_DELT 5 -#define DIAG_START (double)0.50F -#define DIAG_END (double)5.00F -#define DIAG_DELTA (double)0.50F +#define DIAG_CACHE_STRT 25 +#define DIAG_CACHE_END 25 +#define DIAG_CACHE_DELT 5 +#define DIAG_START (double)0.50F +#define DIAG_END (double)5.00F +#define DIAG_DELTA (double)0.50F /* #define DIAG_W0 0.65F */ /* #define DIAG_NRDCC 521 */ -static size_t nio_g; -static hid_t fapl_g = H5I_INVALID_HID; +static size_t nio_g; +static hid_t fapl_g = H5I_INVALID_HID; /* Local function prototypes */ -static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t cd_nelmts, - const unsigned *cd_values, size_t nbytes, - size_t *buf_size, void **buf); +static size_t counter(unsigned H5_ATTR_UNUSED flags, size_t cd_nelmts, const unsigned *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_COUNTER[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER_COUNTER, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "counter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - counter, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER_COUNTER, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "counter", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + counter, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: counter * @@ -109,15 +106,14 @@ const H5Z_class2_t H5Z_COUNTER[1] = {{ *------------------------------------------------------------------------- */ static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) +counter(unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { nio_g += nbytes; return nbytes; } - /*------------------------------------------------------------------------- * Function: create_dataset * @@ -136,21 +132,21 @@ counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, *------------------------------------------------------------------------- */ static void -create_dataset (void) +create_dataset(void) { - hid_t file, space, dcpl, dset; - hsize_t size[2]; - signed char *buf; + hid_t file, space, dcpl, dset; + hsize_t size[2]; + signed char *buf; /* The file */ - file = H5Fcreate (FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_g); + file = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_g); /* The data space */ size[0] = size[1] = DS_SIZE * CH_SIZE; - space = H5Screate_simple(2, size, size); + space = H5Screate_simple(2, size, size); /* The storage layout and compression */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); size[0] = size[1] = CH_SIZE; H5Pset_chunk(dcpl, 2, size); H5Zregister(H5Z_COUNTER); @@ -158,10 +154,10 @@ create_dataset (void) /* The dataset */ dset = H5Dcreate2(file, "dset", H5T_NATIVE_SCHAR, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - assert(dset>=0); + assert(dset >= 0); /* The data */ - buf = (signed char *)calloc(1, SQUARE (DS_SIZE*CH_SIZE)); + buf = (signed char *)calloc(1, SQUARE(DS_SIZE * CH_SIZE)); H5Dwrite(dset, H5T_NATIVE_SCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); free(buf); @@ -172,7 +168,6 @@ create_dataset (void) H5Fclose(file); } - /*------------------------------------------------------------------------- * Function: test_rowmaj * @@ -189,64 +184,60 @@ create_dataset (void) *------------------------------------------------------------------------- */ static double -test_rowmaj (int op, size_t cache_size, size_t io_size) +test_rowmaj(int op, size_t cache_size, size_t io_size) { - hid_t file, dset, mem_space, file_space; - signed char *buf = (signed char *)calloc (1, (size_t)(SQUARE(io_size))); - hsize_t i, j, hs_size[2]; - hsize_t hs_offset[2]; - int mdc_nelmts; - size_t rdcc_nelmts; - double w0; - - H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0); + hid_t file, dset, mem_space, file_space; + signed char *buf = (signed char *)calloc(1, (size_t)(SQUARE(io_size))); + hsize_t i, j, hs_size[2]; + hsize_t hs_offset[2]; + int mdc_nelmts; + size_t rdcc_nelmts; + double w0; + + H5Pget_cache(fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0); #ifdef RM_W0 w0 = RM_W0; #endif #ifdef RM_NRDCC rdcc_nelmts = RM_NRDCC; #endif - H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts, - cache_size*SQUARE (CH_SIZE), w0); - file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g); - dset = H5Dopen2(file, "dset", H5P_DEFAULT); + H5Pset_cache(fapl_g, mdc_nelmts, rdcc_nelmts, cache_size * SQUARE(CH_SIZE), w0); + file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g); + dset = H5Dopen2(file, "dset", H5P_DEFAULT); file_space = H5Dget_space(dset); - nio_g = 0; + nio_g = 0; - for (i=0; i0) nio -= SQUARE (io_size-offset); + nio_g = 0; + + for (i = 0, hs_size[0] = io_size; hs_size[0] == io_size; i += offset) { + hs_offset[0] = hs_offset[1] = i; + hs_size[0] = hs_size[1] = MIN(io_size, CH_SIZE * DS_SIZE - i); + mem_space = H5Screate_simple(2, hs_size, hs_size); + H5Sselect_hyperslab(file_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); + if (READ == op) { + H5Dread(dset, H5T_NATIVE_SCHAR, mem_space, file_space, H5P_DEFAULT, buf); + } + else { + H5Dwrite(dset, H5T_NATIVE_SCHAR, mem_space, file_space, H5P_DEFAULT, buf); + } + H5Sclose(mem_space); + nio += hs_size[0] * hs_size[1]; + if (i > 0) + nio -= SQUARE(io_size - offset); } - free (buf); - H5Sclose (file_space); - H5Dclose (dset); - H5Fclose (file); + free(buf); + H5Sclose(file_space); + H5Dclose(dset); + H5Fclose(file); /* * The extra cast in the following statement is a bug workaround for the * Win32 version 5.0 compiler. * 1998-11-06 ptl */ - return (double)nio/(double)nio_g; + return (double)nio / (double)nio_g; } - /*------------------------------------------------------------------------- * Function: main * @@ -339,25 +327,25 @@ test_diag (int op, size_t cache_size, size_t io_size, size_t offset) *------------------------------------------------------------------------- */ int -main (void) +main(void) { - size_t io_size; - double effic, io_percent; - FILE *f, *d; - size_t cache_size; - double w0; + size_t io_size; + double effic, io_percent; + FILE * f, *d; + size_t cache_size; + double w0; /* * Create a global file access property list. */ - fapl_g = H5Pcreate (H5P_FILE_ACCESS); - H5Pget_cache (fapl_g, NULL, NULL, NULL, &w0); + fapl_g = H5Pcreate(H5P_FILE_ACCESS); + H5Pget_cache(fapl_g, NULL, NULL, NULL, &w0); /* Create the file */ - create_dataset (); - f = fopen ("x-gnuplot", "w"); + create_dataset(); + f = fopen("x-gnuplot", "w"); - printf("Test %8s %8s %8s\n", "CacheSz", "ChunkSz", "Effic"); + printf("Test %8s %8s %8s\n", "CacheSz", "ChunkSz", "Effic"); printf("--------- -------- -------- --------\n"); #if 1 @@ -365,45 +353,44 @@ main (void) * Test row-major reading of the dataset with various sizes of request * windows. */ - if (RM_CACHE_STRT==RM_CACHE_END) { - fprintf (f, "set yrange [0:1.2]\n"); - fprintf (f, "set ytics 0, 0.1, 1\n"); - fprintf (f, "set xlabel \"%s\"\n", - "Request size as a fraction of chunk size"); - fprintf (f, "set ylabel \"Efficiency\"\n"); - fprintf (f, "set title \"Cache %d chunks, w0=%g, " - "Size=(total=%d, chunk=%d)\"\n", - RM_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE); - } else { - fprintf (f, "set autoscale\n"); - fprintf (f, "set hidden3d\n"); + if (RM_CACHE_STRT == RM_CACHE_END) { + fprintf(f, "set yrange [0:1.2]\n"); + fprintf(f, "set ytics 0, 0.1, 1\n"); + fprintf(f, "set xlabel \"%s\"\n", "Request size as a fraction of chunk size"); + fprintf(f, "set ylabel \"Efficiency\"\n"); + fprintf(f, + "set title \"Cache %d chunks, w0=%g, " + "Size=(total=%d, chunk=%d)\"\n", + RM_CACHE_STRT, w0, DS_SIZE * CH_SIZE, CH_SIZE); + } + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fprintf (f, "set terminal postscript\nset output \"x-rowmaj-rd.ps\"\n"); - fprintf (f, "%s \"x-rowmaj-rd.dat\" title \"RowMaj-Read\" with %s\n", - RM_CACHE_STRT==RM_CACHE_END?"plot":"splot", - LINESPOINTS); - fprintf (f, "set terminal x11\nreplot\n"); - d = fopen ("x-rowmaj-rd.dat", "w"); - for (cache_size=RM_CACHE_STRT; - cache_size<=RM_CACHE_END; - cache_size+=RM_CACHE_DELT) { - for (io_percent=RM_START; io_percent<=RM_END; io_percent+=RM_DELTA) { - io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); - printf ("Rowmaj-rd %8d %8.2f", (int)cache_size, io_percent); - fflush (stdout); - effic = test_rowmaj (READ, cache_size, io_size); - printf (" %8.2f\n", effic); - if (RM_CACHE_STRT==RM_CACHE_END) { - fprintf (d, "%g %g\n", io_percent, effic); - } else { - fprintf (d, "%g\n", effic); - } - } - fprintf (d, "\n"); + fprintf(f, "set terminal postscript\nset output \"x-rowmaj-rd.ps\"\n"); + fprintf(f, "%s \"x-rowmaj-rd.dat\" title \"RowMaj-Read\" with %s\n", + RM_CACHE_STRT == RM_CACHE_END ? "plot" : "splot", LINESPOINTS); + fprintf(f, "set terminal x11\nreplot\n"); + d = fopen("x-rowmaj-rd.dat", "w"); + for (cache_size = RM_CACHE_STRT; cache_size <= RM_CACHE_END; cache_size += RM_CACHE_DELT) { + for (io_percent = RM_START; io_percent <= RM_END; io_percent += RM_DELTA) { + io_size = MAX(1, (size_t)(CH_SIZE * io_percent)); + printf("Rowmaj-rd %8d %8.2f", (int)cache_size, io_percent); + fflush(stdout); + effic = test_rowmaj(READ, cache_size, io_size); + printf(" %8.2f\n", effic); + if (RM_CACHE_STRT == RM_CACHE_END) { + fprintf(d, "%g %g\n", io_percent, effic); + } + else { + fprintf(d, "%g\n", effic); + } + } + fprintf(d, "\n"); } - fclose (d); - fprintf (f, "pause -1\n"); + fclose(d); + fprintf(f, "pause -1\n"); #endif #if 1 @@ -411,138 +398,133 @@ main (void) * Test row-major writing of the dataset with various sizes of request * windows. */ - if (RM_CACHE_STRT==RM_CACHE_END) { - fprintf (f, "set yrange [0:1.2]\n"); - fprintf (f, "set ytics 0, 0.1, 1\n"); - fprintf (f, "set xlabel \"%s\"\n", - "Request size as a fraction of chunk size"); - fprintf (f, "set ylabel \"Efficiency\"\n"); - fprintf (f, "set title \"Cache %d chunks,w0=%g, " - "Size=(total=%d, chunk=%d)\"\n", - RM_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE); - } else { - fprintf (f, "set autoscale\n"); - fprintf (f, "set hidden3d\n"); + if (RM_CACHE_STRT == RM_CACHE_END) { + fprintf(f, "set yrange [0:1.2]\n"); + fprintf(f, "set ytics 0, 0.1, 1\n"); + fprintf(f, "set xlabel \"%s\"\n", "Request size as a fraction of chunk size"); + fprintf(f, "set ylabel \"Efficiency\"\n"); + fprintf(f, + "set title \"Cache %d chunks,w0=%g, " + "Size=(total=%d, chunk=%d)\"\n", + RM_CACHE_STRT, w0, DS_SIZE * CH_SIZE, CH_SIZE); + } + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fprintf (f, "set terminal postscript\nset output \"x-rowmaj-wr.ps\"\n"); - fprintf (f, "%s \"x-rowmaj-wr.dat\" title \"RowMaj-Write\" with %s\n", - RM_CACHE_STRT==RM_CACHE_END?"plot":"splot", - LINESPOINTS); - fprintf (f, "set terminal x11\nreplot\n"); - d = fopen ("x-rowmaj-wr.dat", "w"); - for (cache_size=RM_CACHE_STRT; - cache_size<=RM_CACHE_END; - cache_size+=RM_CACHE_DELT) { - for (io_percent=RM_START; io_percent<=RM_END; io_percent+=RM_DELTA) { - io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); - printf ("Rowmaj-wr %8d %8.2f", (int)cache_size, io_percent); - fflush (stdout); - effic = test_rowmaj (WRITE, cache_size, io_size); - printf (" %8.2f\n", effic); - if (RM_CACHE_STRT==RM_CACHE_END) { - fprintf (d, "%g %g\n", io_percent, effic); - } else { - fprintf (d, "%g\n", effic); - } - } - fprintf (d, "\n"); + fprintf(f, "set terminal postscript\nset output \"x-rowmaj-wr.ps\"\n"); + fprintf(f, "%s \"x-rowmaj-wr.dat\" title \"RowMaj-Write\" with %s\n", + RM_CACHE_STRT == RM_CACHE_END ? "plot" : "splot", LINESPOINTS); + fprintf(f, "set terminal x11\nreplot\n"); + d = fopen("x-rowmaj-wr.dat", "w"); + for (cache_size = RM_CACHE_STRT; cache_size <= RM_CACHE_END; cache_size += RM_CACHE_DELT) { + for (io_percent = RM_START; io_percent <= RM_END; io_percent += RM_DELTA) { + io_size = MAX(1, (size_t)(CH_SIZE * io_percent)); + printf("Rowmaj-wr %8d %8.2f", (int)cache_size, io_percent); + fflush(stdout); + effic = test_rowmaj(WRITE, cache_size, io_size); + printf(" %8.2f\n", effic); + if (RM_CACHE_STRT == RM_CACHE_END) { + fprintf(d, "%g %g\n", io_percent, effic); + } + else { + fprintf(d, "%g\n", effic); + } + } + fprintf(d, "\n"); } - fclose (d); - fprintf (f, "pause -1\n"); + fclose(d); + fprintf(f, "pause -1\n"); #endif #if 1 /* * Test diagonal read */ - if (DIAG_CACHE_STRT==DIAG_CACHE_END) { - fprintf (f, "set yrange [0:1.2]\n"); - fprintf (f, "set ytics 0, 0.1, 1\n"); - fprintf (f, "set xlabel \"%s\"\n", - "Request size as a fraction of chunk size"); - fprintf (f, "set ylabel \"Efficiency\"\n"); - fprintf (f, "set title \"Cache %d chunks,w0=%g, " - "Size=(total=%d, chunk=%d)\"\n", - DIAG_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE); - } else { - fprintf (f, "set autoscale\n"); - fprintf (f, "set hidden3d\n"); + if (DIAG_CACHE_STRT == DIAG_CACHE_END) { + fprintf(f, "set yrange [0:1.2]\n"); + fprintf(f, "set ytics 0, 0.1, 1\n"); + fprintf(f, "set xlabel \"%s\"\n", "Request size as a fraction of chunk size"); + fprintf(f, "set ylabel \"Efficiency\"\n"); + fprintf(f, + "set title \"Cache %d chunks,w0=%g, " + "Size=(total=%d, chunk=%d)\"\n", + DIAG_CACHE_STRT, w0, DS_SIZE * CH_SIZE, CH_SIZE); + } + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fprintf (f, "set terminal postscript\nset output \"x-diag-rd.ps\"\n"); - fprintf (f, "%s \"x-diag-rd.dat\" title \"Diag-Read\" with %s\n", - DIAG_CACHE_STRT==DIAG_CACHE_END?"plot":"splot", LINESPOINTS); - fprintf (f, "set terminal x11\nreplot\n"); - d = fopen ("x-diag-rd.dat", "w"); - for (cache_size=DIAG_CACHE_STRT; - cache_size<=DIAG_CACHE_END; - cache_size+=DIAG_CACHE_DELT) { - for (io_percent=DIAG_START; io_percent<=DIAG_END; io_percent+=DIAG_DELTA) { - io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); - printf ("Diag-rd %8d %8.2f", (int)cache_size, io_percent); - fflush (stdout); - effic = test_diag (READ, cache_size, io_size, MAX (1, io_size/2)); - printf (" %8.2f\n", effic); - if (DIAG_CACHE_STRT==DIAG_CACHE_END) { - fprintf (d, "%g %g\n", io_percent, effic); - } else { - fprintf (d, "%g\n", effic); - } - } - fprintf (d, "\n"); + fprintf(f, "set terminal postscript\nset output \"x-diag-rd.ps\"\n"); + fprintf(f, "%s \"x-diag-rd.dat\" title \"Diag-Read\" with %s\n", + DIAG_CACHE_STRT == DIAG_CACHE_END ? "plot" : "splot", LINESPOINTS); + fprintf(f, "set terminal x11\nreplot\n"); + d = fopen("x-diag-rd.dat", "w"); + for (cache_size = DIAG_CACHE_STRT; cache_size <= DIAG_CACHE_END; cache_size += DIAG_CACHE_DELT) { + for (io_percent = DIAG_START; io_percent <= DIAG_END; io_percent += DIAG_DELTA) { + io_size = MAX(1, (size_t)(CH_SIZE * io_percent)); + printf("Diag-rd %8d %8.2f", (int)cache_size, io_percent); + fflush(stdout); + effic = test_diag(READ, cache_size, io_size, MAX(1, io_size / 2)); + printf(" %8.2f\n", effic); + if (DIAG_CACHE_STRT == DIAG_CACHE_END) { + fprintf(d, "%g %g\n", io_percent, effic); + } + else { + fprintf(d, "%g\n", effic); + } + } + fprintf(d, "\n"); } - fclose (d); - fprintf (f, "pause -1\n"); + fclose(d); + fprintf(f, "pause -1\n"); #endif #if 1 /* * Test diagonal write */ - if (DIAG_CACHE_STRT==DIAG_CACHE_END) { - fprintf (f, "set yrange [0:1.2]\n"); - fprintf (f, "set ytics 0, 0.1, 1\n"); - fprintf (f, "set xlabel \"%s\"\n", - "Request size as a fraction of chunk size"); - fprintf (f, "set ylabel \"Efficiency\"\n"); - fprintf (f, "set title \"Cache %d chunks, w0=%g, " - "Size=(total=%d, chunk=%d)\"\n", - DIAG_CACHE_STRT, w0, DS_SIZE*CH_SIZE, CH_SIZE); - } else { - fprintf (f, "set autoscale\n"); - fprintf (f, "set hidden3d\n"); + if (DIAG_CACHE_STRT == DIAG_CACHE_END) { + fprintf(f, "set yrange [0:1.2]\n"); + fprintf(f, "set ytics 0, 0.1, 1\n"); + fprintf(f, "set xlabel \"%s\"\n", "Request size as a fraction of chunk size"); + fprintf(f, "set ylabel \"Efficiency\"\n"); + fprintf(f, + "set title \"Cache %d chunks, w0=%g, " + "Size=(total=%d, chunk=%d)\"\n", + DIAG_CACHE_STRT, w0, DS_SIZE * CH_SIZE, CH_SIZE); } - fprintf (f, "set terminal postscript\nset output \"x-diag-wr.ps\"\n"); - fprintf (f, "%s \"x-diag-wr.dat\" title \"Diag-Write\" with %s\n", - DIAG_CACHE_STRT==DIAG_CACHE_END?"plot":"splot", LINESPOINTS); - fprintf (f, "set terminal x11\nreplot\n"); - d = fopen ("x-diag-wr.dat", "w"); - for (cache_size=DIAG_CACHE_STRT; - cache_size<=DIAG_CACHE_END; - cache_size+=DIAG_CACHE_DELT) { - for (io_percent=DIAG_START; - io_percent<=DIAG_END; - io_percent+=DIAG_DELTA) { - io_size = MAX (1, (size_t)(CH_SIZE*io_percent)); - printf ("Diag-wr %8d %8.2f", (int)cache_size, io_percent); - fflush (stdout); - effic = test_diag (WRITE, cache_size, io_size, MAX (1, io_size/2)); - printf (" %8.2f\n", effic); - if (DIAG_CACHE_STRT==DIAG_CACHE_END) { - fprintf (d, "%g %g\n", io_percent, effic); - } else { - fprintf (d, "%g\n", effic); - } - } - fprintf (d, "\n"); + else { + fprintf(f, "set autoscale\n"); + fprintf(f, "set hidden3d\n"); } - fclose (d); - fprintf (f, "pause -1\n"); + fprintf(f, "set terminal postscript\nset output \"x-diag-wr.ps\"\n"); + fprintf(f, "%s \"x-diag-wr.dat\" title \"Diag-Write\" with %s\n", + DIAG_CACHE_STRT == DIAG_CACHE_END ? "plot" : "splot", LINESPOINTS); + fprintf(f, "set terminal x11\nreplot\n"); + d = fopen("x-diag-wr.dat", "w"); + for (cache_size = DIAG_CACHE_STRT; cache_size <= DIAG_CACHE_END; cache_size += DIAG_CACHE_DELT) { + for (io_percent = DIAG_START; io_percent <= DIAG_END; io_percent += DIAG_DELTA) { + io_size = MAX(1, (size_t)(CH_SIZE * io_percent)); + printf("Diag-wr %8d %8.2f", (int)cache_size, io_percent); + fflush(stdout); + effic = test_diag(WRITE, cache_size, io_size, MAX(1, io_size / 2)); + printf(" %8.2f\n", effic); + if (DIAG_CACHE_STRT == DIAG_CACHE_END) { + fprintf(d, "%g %g\n", io_percent, effic); + } + else { + fprintf(d, "%g\n", effic); + } + } + fprintf(d, "\n"); + } + fclose(d); + fprintf(f, "pause -1\n"); #endif - - H5Pclose (fapl_g); - fclose (f); + H5Pclose(fapl_g); + fclose(f); return 0; } - diff --git a/tools/test/perform/chunk_cache.c b/tools/test/perform/chunk_cache.c index d7c56af..9a6d5fa 100644 --- a/tools/test/perform/chunk_cache.c +++ b/tools/test/perform/chunk_cache.c @@ -21,28 +21,28 @@ #include "H5private.h" #include "h5test.h" -#define FILENAME "chunk_cache_perf.h5" +#define FILENAME "chunk_cache_perf.h5" -#define RANK 2 +#define RANK 2 #define DSET1_NAME "partial_chunks" -#define DSET1_DIM1 9 * 1000 -#define DSET1_DIM2 9 -#define CHUNK1_DIM1 2 * 1000 -#define CHUNK1_DIM2 2 +#define DSET1_DIM1 9 * 1000 +#define DSET1_DIM2 9 +#define CHUNK1_DIM1 2 * 1000 +#define CHUNK1_DIM2 2 #define DSET2_NAME "hash_value" -#define DSET2_DIM1 300 -#define DSET2_DIM2 600 -#define CHUNK2_DIM1 100 -#define CHUNK2_DIM2 100 +#define DSET2_DIM1 300 +#define DSET2_DIM2 600 +#define CHUNK2_DIM1 100 +#define CHUNK2_DIM2 100 -#define RDCC_NSLOTS 5 -#define RDCC_NBYTES 1024 * 1024 * 10 -#define RDCC_W0 0.75F +#define RDCC_NSLOTS 5 +#define RDCC_NBYTES 1024 * 1024 * 10 +#define RDCC_W0 0.75F -#define FILTER_COUNTER 306 -static size_t nbytes_global; +#define FILTER_COUNTER 306 +static size_t nbytes_global; typedef struct test_time_t { long tv_sec; @@ -50,20 +50,18 @@ typedef struct test_time_t { } test_time_t; /* Local function prototypes for the dummy filter */ -static size_t -counter (unsigned flags, size_t cd_nelmts, - const unsigned *cd_values, size_t nbytes, - size_t *buf_size, void **buf); +static size_t counter(unsigned flags, size_t cd_nelmts, const unsigned *cd_values, size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_COUNTER[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - FILTER_COUNTER, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "counter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - counter, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER_COUNTER, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "counter", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + counter, /* The actual filter function */ }}; /*------------------------------------------------------------------------- @@ -71,9 +69,9 @@ const H5Z_class2_t H5Z_COUNTER[1] = {{ * track of the data of chunks being read from file into memory. */ static size_t -counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) +counter(unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned H5_ATTR_UNUSED *cd_values, size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, + void H5_ATTR_UNUSED **buf) { nbytes_global += nbytes; return nbytes; @@ -81,10 +79,10 @@ counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, /*---------------------------------------------------------------------------*/ static void -cleanup (void) +cleanup(void) { - if (!getenv ("HDF5_NOCLEANUP")) { - remove (FILENAME); + if (!getenv("HDF5_NOCLEANUP")) { + remove(FILENAME); } } @@ -93,58 +91,59 @@ cleanup (void) * dataset dimension: 9000 x 9 * chunk dimension: 2000 x 2 */ -static int create_dset1(hid_t file) +static int +create_dset1(hid_t file) { - hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[RANK] = {DSET1_DIM1, DSET1_DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK1_DIM1, CHUNK1_DIM2}; - int **data; /* data for writing */ + hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[RANK] = {DSET1_DIM1, DSET1_DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK1_DIM1, CHUNK1_DIM2}; + int ** data; /* data for writing */ /* Create the data space. */ - if((dataspace = H5Screate_simple (RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* Modify dataset creation properties, i.e. enable chunking */ - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; /* Set the dummy filter simply for counting the number of bytes being read into the memory */ - if(H5Zregister(H5Z_COUNTER) < 0) + if (H5Zregister(H5Z_COUNTER) < 0) goto error; - if(H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) + if (H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) goto error; /* Create a new dataset within the file using chunk creation properties. */ - if((dataset = H5Dcreate2 (file, DSET1_NAME, H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET1_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) goto error; /* Create & fill array */ - H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2); + H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2); H5TEST_FILL_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2); - /* Write data to dataset */ - if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Close resources */ - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); return 0; error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); + } + H5E_END_TRY; return 1; } @@ -154,41 +153,42 @@ error: * dataset dimensions: 300 x 600 * chunk dimensions: 100 x 100 */ -static int create_dset2(hid_t file) +static int +create_dset2(hid_t file) { - hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; - hid_t dcpl = H5I_INVALID_HID; - hsize_t dims[RANK] = {DSET2_DIM1, DSET2_DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK2_DIM1, CHUNK2_DIM2}; - int **data; /* data for writing */ + hid_t dataspace = H5I_INVALID_HID, dataset = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[RANK] = {DSET2_DIM1, DSET2_DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK2_DIM1, CHUNK2_DIM2}; + int ** data; /* data for writing */ /* Create the data space. */ - if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* Modify dataset creation properties, i.e. enable chunking */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; /* Set the dummy filter simply for counting the number of bytes being read into the memory */ - if(H5Zregister(H5Z_COUNTER) < 0) + if (H5Zregister(H5Z_COUNTER) < 0) goto error; - if(H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) + if (H5Pset_filter(dcpl, FILTER_COUNTER, 0, 0, NULL) < 0) goto error; /* Create a new dataset within the file using chunk creation properties. */ - if((dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < + 0) goto error; /* Create & fill array */ - H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2); + H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2); H5TEST_FILL_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2); /* Write data to dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Close resources */ @@ -199,11 +199,13 @@ static int create_dset2(hid_t file) return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Pclose(dcpl); H5Sclose(dataspace); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -212,31 +214,32 @@ error: * Check the performance of the chunk cache when partial chunks exist * along the dataset dimensions. */ -static int check_partial_chunks_perf(hid_t file) +static int +check_partial_chunks_perf(hid_t file) { - hid_t dataset = H5I_INVALID_HID; - hid_t filespace = H5I_INVALID_HID; - hid_t memspace = H5I_INVALID_HID; - hid_t dapl = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t filespace = H5I_INVALID_HID; + hid_t memspace = H5I_INVALID_HID; + hid_t dapl = H5I_INVALID_HID; - int rdata[DSET1_DIM2]; /* data for reading */ - int i; + int rdata[DSET1_DIM2]; /* data for reading */ + int i; - hsize_t row_rank = 1; - hsize_t row_dim[1] = {DSET1_DIM2}; - hsize_t start[RANK] = {0, 0}; - hsize_t count[RANK] = {1, DSET1_DIM2}; - double start_t, end_t; + hsize_t row_rank = 1; + hsize_t row_dim[1] = {DSET1_DIM2}; + hsize_t start[RANK] = {0, 0}; + hsize_t count[RANK] = {1, DSET1_DIM2}; + double start_t, end_t; - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) goto error; - if(H5Pset_chunk_cache (dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) + if (H5Pset_chunk_cache(dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) goto error; - dataset = H5Dopen2 (file, DSET1_NAME, dapl); + dataset = H5Dopen2(file, DSET1_NAME, dapl); H5_CHECK_OVERFLOW(row_rank, hsize_t, int); - memspace = H5Screate_simple((int)row_rank, row_dim, NULL); + memspace = H5Screate_simple((int)row_rank, row_dim, NULL); filespace = H5Dget_space(dataset); nbytes_global = 0; @@ -244,37 +247,40 @@ static int check_partial_chunks_perf(hid_t file) start_t = H5_get_time(); /* Read the data row by row */ - for(i = 0; i < DSET1_DIM1; i++) { + for (i = 0; i < DSET1_DIM1; i++) { start[0] = (hsize_t)i; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, - start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; - if(H5Dread (dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, rdata) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rdata) < 0) goto error; } end_t = H5_get_time(); - if((end_t - start_t) > (double)0.0f) - printf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %lu\n", (end_t -start_t), nbytes_global); + if ((end_t - start_t) > (double)0.0f) + printf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %lu\n", + (end_t - start_t), nbytes_global); else - printf("1. Partial chunks: no total read time because timer is not available; number of bytes being read from file is %lu\n", nbytes_global); + printf("1. Partial chunks: no total read time because timer is not available; number of bytes being " + "read from file is %lu\n", + nbytes_global); - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); return 0; error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); + } + H5E_END_TRY; return 1; } @@ -283,34 +289,35 @@ error: * is smaller than the number of chunks along the fastest-growing * dimension of the dataset. */ -static int check_hash_value_perf(hid_t file) +static int +check_hash_value_perf(hid_t file) { - hid_t dataset = H5I_INVALID_HID; - hid_t filespace = H5I_INVALID_HID; - hid_t memspace = H5I_INVALID_HID; - hid_t dapl = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t filespace = H5I_INVALID_HID; + hid_t memspace = H5I_INVALID_HID; + hid_t dapl = H5I_INVALID_HID; - int rdata[DSET2_DIM1]; /* data for reading */ - int i; + int rdata[DSET2_DIM1]; /* data for reading */ + int i; - hsize_t column_rank = 1; - hsize_t column_dim[1] = {DSET2_DIM1}; - hsize_t start[RANK] = {0, 0}; - hsize_t count[RANK] = {DSET2_DIM1, 1}; - double start_t, end_t; + hsize_t column_rank = 1; + hsize_t column_dim[1] = {DSET2_DIM1}; + hsize_t start[RANK] = {0, 0}; + hsize_t count[RANK] = {DSET2_DIM1, 1}; + double start_t, end_t; - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) goto error; - if(H5Pset_chunk_cache (dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) + if (H5Pset_chunk_cache(dapl, RDCC_NSLOTS, RDCC_NBYTES, RDCC_W0) < 0) goto error; - if((dataset = H5Dopen2 (file, DSET2_NAME, dapl)) < 0) + if ((dataset = H5Dopen2(file, DSET2_NAME, dapl)) < 0) goto error; H5_CHECK_OVERFLOW(column_rank, hsize_t, int); - if((memspace = H5Screate_simple((int)column_rank, column_dim, NULL)) < 0) + if ((memspace = H5Screate_simple((int)column_rank, column_dim, NULL)) < 0) goto error; - if((filespace = H5Dget_space(dataset)) < 0) + if ((filespace = H5Dget_space(dataset)) < 0) goto error; nbytes_global = 0; @@ -318,37 +325,40 @@ static int check_hash_value_perf(hid_t file) start_t = H5_get_time(); /* Read the data column by column */ - for(i = 0; i < DSET2_DIM2; i++) { + for (i = 0; i < DSET2_DIM2; i++) { start[1] = (hsize_t)i; - if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, - start, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, NULL, count, NULL) < 0) goto error; - if(H5Dread (dataset, H5T_NATIVE_INT, memspace, filespace, - H5P_DEFAULT, rdata) < 0) + if (H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT, rdata) < 0) goto error; } end_t = H5_get_time(); - if((end_t - start_t) > (double)0.0f) - printf("2. Hash value: total read time is %lf; number of bytes being read from file is %lu\n", (end_t -start_t), nbytes_global); + if ((end_t - start_t) > (double)0.0f) + printf("2. Hash value: total read time is %lf; number of bytes being read from file is %lu\n", + (end_t - start_t), nbytes_global); else - printf("2. Hash value: no total read time because timer is not available; number of bytes being read from file is %lu\n", nbytes_global); + printf("2. Hash value: no total read time because timer is not available; number of bytes being read " + "from file is %lu\n", + nbytes_global); - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); return 0; error: - H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Sclose (filespace); - H5Sclose (memspace); - H5Pclose (dapl); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Sclose(filespace); + H5Sclose(memspace); + H5Pclose(dapl); + } + H5E_END_TRY; return 1; } @@ -359,32 +369,33 @@ error: * in the fastest-growing dimension. *-------------------------------------------------------------------------------------*/ int -main (void) +main(void) { - hid_t file; /* handles */ - int nerrors = 0; + hid_t file; /* handles */ + int nerrors = 0; /* Create a new file. If file exists its contents will be overwritten. */ - if((file = H5Fcreate (FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; nerrors += create_dset1(file); nerrors += create_dset2(file); - if(H5Fclose (file) < 0) + if (H5Fclose(file) < 0) goto error; /* Re-open the file for testing performance. */ - if((file = H5Fopen (FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((file = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto error; nerrors += check_partial_chunks_perf(file); nerrors += check_hash_value_perf(file); - if(H5Fclose (file) < 0) + if (H5Fclose(file) < 0) goto error; - if (nerrors>0) goto error; + if (nerrors > 0) + goto error; cleanup(); return 0; diff --git a/tools/test/perform/direct_write_perf.c b/tools/test/perform/direct_write_perf.c index 20b7237..f4ec7f8 100644 --- a/tools/test/perform/direct_write_perf.c +++ b/tools/test/perform/direct_write_perf.c @@ -26,213 +26,226 @@ #include #ifdef H5_STDC_HEADERS -# include -# include -# include -# include +#include +#include +#include +#include #endif #ifdef H5_HAVE_UNISTD_H -# include -# include +#include +#include #endif #ifdef H5_HAVE_SYS_STAT_H -# include +#include #endif #if defined(H5_TIME_WITH_SYS_TIME) -# include -# include +#include +#include #elif defined(H5_HAVE_SYS_TIME_H) -# include +#include #else -# include +#include #endif -const char *FILENAME[] = { - "direct_write", - "unix.raw", - NULL -}; +const char *FILENAME[] = {"direct_write", "unix.raw", NULL}; /* * Print the current location on the standard output stream. */ #define FUNC __func__ -#define AT() printf (" at %s:%d in %s()...\n", \ - __FILE__, __LINE__, FUNC); -#define H5_FAILED() {puts("*FAILED*");fflush(stdout);} -#define TEST_ERROR {H5_FAILED(); AT(); goto error;} -#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);} -#define PASSED() {puts(" PASSED");fflush(stdout);} - -#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset" -#define DIRECT_COMPRESSED_DSET "direct_compressed_dset" -#define REG_COMPRESSED_DSET "reg_compressed_dset" -#define REG_NO_COMPRESS_DSET "reg_no_compress_dset" -#define RANK 3 -#define NX 100 -#define NY 1000 -#define NZ 250 -#define CHUNK_NX 1 -#define CHUNK_NY 1000 -#define CHUNK_NZ 250 - -#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s))*1.001)+12) -char filename[1024]; +#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); +#define H5_FAILED() \ + { \ + puts("*FAILED*"); \ + fflush(stdout); \ + } +#define TEST_ERROR \ + { \ + H5_FAILED(); \ + AT(); \ + goto error; \ + } +#define TESTING(WHAT) \ + { \ + printf("Testing %-62s", WHAT); \ + fflush(stdout); \ + } +#define PASSED() \ + { \ + puts(" PASSED"); \ + fflush(stdout); \ + } + +#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset" +#define DIRECT_COMPRESSED_DSET "direct_compressed_dset" +#define REG_COMPRESSED_DSET "reg_compressed_dset" +#define REG_NO_COMPRESS_DSET "reg_no_compress_dset" +#define RANK 3 +#define NX 100 +#define NY 1000 +#define NZ 250 +#define CHUNK_NX 1 +#define CHUNK_NY 1000 +#define CHUNK_NZ 250 + +#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s)) * 1.001) + 12) +char filename[1024]; unsigned int *outbuf[NX]; -size_t data_size[NX]; -double total_size = 0.0; +size_t data_size[NX]; +double total_size = 0.0; unsigned int *direct_buf[NX]; -double MB = 1048576.0; +double MB = 1048576.0; /*-------------------------------------------------- * Function to report IO rate *-------------------------------------------------- */ -void reportTime(struct timeval start, double mbytes) +void +reportTime(struct timeval start, double mbytes) { - struct timeval timeval_stop,timeval_diff; + struct timeval timeval_stop, timeval_diff; /*end timing*/ - gettimeofday(&timeval_stop,NULL); + gettimeofday(&timeval_stop, NULL); /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec=timeval_stop.tv_usec-start.tv_usec; - timeval_diff.tv_sec=timeval_stop.tv_sec-start.tv_sec; + timeval_diff.tv_usec = timeval_stop.tv_usec - start.tv_usec; + timeval_diff.tv_sec = timeval_stop.tv_sec - start.tv_sec; - if(timeval_diff.tv_usec<0) { - timeval_diff.tv_usec+=1000000; + if (timeval_diff.tv_usec < 0) { + timeval_diff.tv_usec += 1000000; timeval_diff.tv_sec--; } /* end if */ -/*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec, (double)timeval_diff.tv_usec);*/ - printf("MBytes/second: %lf\n", (double)mbytes/((double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0))); + /*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec, + * (double)timeval_diff.tv_usec);*/ + printf("MBytes/second: %lf\n", (double)mbytes / ((double)timeval_diff.tv_sec + + ((double)timeval_diff.tv_usec / (double)1000000.0))); } /*-------------------------------------------------- * Create file, datasets, and initialize data *-------------------------------------------------- */ -int create_file(hid_t fapl_id) +int +create_file(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t fapl; - hid_t cparms; - hid_t dataspace, dataset; - hsize_t dims[RANK] = {NX, NY, NZ}; - hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; - unsigned int aggression = 9; /* Compression aggression setting */ - int ret; - int i, j, n; + hid_t file; /* handles */ + hid_t fapl; + hid_t cparms; + hid_t dataspace, dataset; + hsize_t dims[RANK] = {NX, NY, NZ}; + hsize_t chunk_dims[RANK] = {CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + unsigned int aggression = 9; /* Compression aggression setting */ + int ret; + int i, j, n; int flag; int unix_file; unsigned int *p; - size_t buf_size = CHUNK_NY*CHUNK_NZ*sizeof(unsigned int); + size_t buf_size = CHUNK_NY * CHUNK_NZ * sizeof(unsigned int); const Bytef *z_src; - Bytef *z_dst; /*destination buffer */ - uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); - uLong z_src_nbytes = (uLong)buf_size; + Bytef * z_dst; /*destination buffer */ + uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); + uLong z_src_nbytes = (uLong)buf_size; TESTING("Create a file and dataset"); /* * Create the data space with unlimited dimensions. */ - if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; /* * Create a new file. If file exists its contents will be overwritten. */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; /* * Modify dataset creation properties, i.e. enable chunking and compression */ - if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if(H5Pset_chunk( cparms, RANK, chunk_dims) < 0) + if (H5Pset_chunk(cparms, RANK, chunk_dims) < 0) TEST_ERROR; /* * Create a new dataset within the file using cparms * creation properties. */ - if((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - if((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; /* Set compression */ - if(H5Pset_deflate( cparms, aggression) < 0) + if (H5Pset_deflate(cparms, aggression) < 0) TEST_ERROR; - if((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - - if((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, - cparms, H5P_DEFAULT)) < 0) + if ((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, + H5P_DEFAULT)) < 0) TEST_ERROR; - if(H5Dclose(dataset) < 0) + if (H5Dclose(dataset) < 0) TEST_ERROR; - if(H5Fclose(file) < 0) + if (H5Fclose(file) < 0) TEST_ERROR; - if(H5Sclose(dataspace) < 0) + if (H5Sclose(dataspace) < 0) TEST_ERROR; - if(H5Pclose(cparms) < 0) + if (H5Pclose(cparms) < 0) TEST_ERROR; /* create a unix file*/ - flag = O_CREAT|O_TRUNC|O_WRONLY; + flag = O_CREAT | O_TRUNC | O_WRONLY; - if ((unix_file=open(FILENAME[1],flag,S_IRWXU))== -1) + if ((unix_file = open(FILENAME[1], flag, S_IRWXU)) == -1) TEST_ERROR; - if (close(unix_file) < 0) - { + if (close(unix_file) < 0) { printf(" unable to close the file\n"); TEST_ERROR; } - /* Initialize data for chunks */ - for(i = 0; i < NX; i++) { - p = direct_buf[i] = (unsigned int*)malloc(CHUNK_NY*CHUNK_NZ*sizeof(unsigned int)); + for (i = 0; i < NX; i++) { + p = direct_buf[i] = (unsigned int *)malloc(CHUNK_NY * CHUNK_NZ * sizeof(unsigned int)); - for(j=0; j < CHUNK_NY*CHUNK_NZ; j++, p++) + for (j = 0; j < CHUNK_NY * CHUNK_NZ; j++, p++) *p = rand() % 65000; - z_src = (const Bytef*)direct_buf[i]; + z_src = (const Bytef *)direct_buf[i]; z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); /* Allocate output (compressed) buffer */ - outbuf[i] = (unsigned int*)malloc((size_t)z_dst_nbytes); - z_dst = (Bytef *)outbuf[i]; + outbuf[i] = (unsigned int *)malloc((size_t)z_dst_nbytes); + z_dst = (Bytef *)outbuf[i]; /* Perform compression from the source to the destination buffer */ ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); @@ -241,28 +254,31 @@ int create_file(hid_t fapl_id) total_size += data_size[i]; /* Check for various zlib errors */ - if(Z_BUF_ERROR == ret) { + if (Z_BUF_ERROR == ret) { fprintf(stderr, "overflow"); TEST_ERROR; - } else if(Z_MEM_ERROR == ret) { - fprintf(stderr, "deflate memory error"); + } + else if (Z_MEM_ERROR == ret) { + fprintf(stderr, "deflate memory error"); TEST_ERROR; - } else if(Z_OK != ret) { - fprintf(stderr, "other deflate error"); + } + else if (Z_OK != ret) { + fprintf(stderr, "other deflate error"); TEST_ERROR; } } - PASSED(); error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dataset); H5Sclose(dataspace); H5Pclose(cparms); H5Fclose(file); - } H5E_END_TRY; + } + H5E_END_TRY; return 1; } @@ -274,37 +290,37 @@ error: int test_direct_write_uncompressed_data(hid_t fapl_id) { - hid_t file; /* handles */ - hid_t dataspace, dataset; - hid_t dxpl; - herr_t status; - int i; + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t dxpl; + herr_t status; + int i; - unsigned filter_mask = 0; - hsize_t offset[RANK] = {0, 0, 0}; + unsigned filter_mask = 0; + hsize_t offset[RANK] = {0, 0, 0}; struct timeval timeval_start; TESTING("H5Dwrite_chunk for uncompressed data"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; /* Start the timer */ - gettimeofday(&timeval_start,NULL); + gettimeofday(&timeval_start, NULL); /* Reopen the file and dataset */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - if((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0) + if ((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0) TEST_ERROR; - /* Write the compressed chunk data repeatedly to cover all the chunks in the * dataset, using the direct writing function. */ - for(i=0; iru_utime.tv_sec)+ - (double)(r_stop->ru_utime.tv_usec)/(double)1000000.0F) - - ((double)(r_start->ru_utime.tv_sec)+ - (double)(r_start->ru_utime.tv_usec)/(double)1000000.0F); + u_time = ((double)(r_stop->ru_utime.tv_sec) + (double)(r_stop->ru_utime.tv_usec) / (double)1000000.0F) - + ((double)(r_start->ru_utime.tv_sec) + (double)(r_start->ru_utime.tv_usec) / (double)1000000.0F); - s_time = ((double)(r_stop->ru_stime.tv_sec)+ - (double)(r_stop->ru_stime.tv_usec)/(double)1000000.0F) - - ((double)(r_start->ru_stime.tv_sec)+ - (double)(r_start->ru_stime.tv_usec)/(double)1000000.0F); + s_time = ((double)(r_stop->ru_stime.tv_sec) + (double)(r_stop->ru_stime.tv_usec) / (double)1000000.0F) - + ((double)(r_start->ru_stime.tv_sec) + (double)(r_start->ru_stime.tv_usec) / (double)1000000.0F); #endif e_time = t_stop - t_start; H5_bandwidth(bw, (double)nbytes, e_time); #ifdef H5_HAVE_GETRUSAGE - HDprintf(HEADING "%1.2fuser %1.2fsystem %1.2felapsed %s\n", - prefix, u_time, s_time, e_time, bw); + HDprintf(HEADING "%1.2fuser %1.2fsystem %1.2felapsed %s\n", prefix, u_time, s_time, e_time, bw); #else - HDprintf(HEADING "%1.2felapsed %s\n", - prefix, e_time, bw); + HDprintf(HEADING "%1.2felapsed %s\n", prefix, e_time, bw); #endif } - /*------------------------------------------------------------------------- * Function: synchronize * @@ -106,7 +96,7 @@ static void synchronize(void) { #ifdef H5_HAVE_SYSTEM -#if defined(H5_HAVE_WIN32_API) && ! defined(__CYGWIN__) +#if defined(H5_HAVE_WIN32_API) && !defined(__CYGWIN__) _flushall(); #else int H5_ATTR_NDEBUG_UNUSED status; @@ -120,7 +110,6 @@ synchronize(void) #endif } - /*------------------------------------------------------------------------- * Function: main * @@ -139,22 +128,21 @@ int main(void) { hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; - unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; + unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; - unsigned char *the_data = NULL; - hid_t file, dset, file_space = H5I_INVALID_HID; + unsigned char *the_data = NULL; + hid_t file, dset, file_space = H5I_INVALID_HID; #ifdef H5_HAVE_GETRUSAGE - struct rusage r_start, r_stop; + struct rusage r_start, r_stop; #endif - double t_start, t_stop; - int fd; - unsigned u; - herr_t H5_ATTR_NDEBUG_UNUSED status; - hssize_t H5_ATTR_NDEBUG_UNUSED n; - off_t H5_ATTR_NDEBUG_UNUSED offset; - hsize_t start[2]; - hsize_t count[2]; - + double t_start, t_stop; + int fd; + unsigned u; + herr_t H5_ATTR_NDEBUG_UNUSED status; + hssize_t H5_ATTR_NDEBUG_UNUSED n; + off_t H5_ATTR_NDEBUG_UNUSED offset; + hsize_t start[2]; + hsize_t count[2]; /* * The extra cast in the following statement is a bug workaround for the @@ -162,12 +150,12 @@ main(void) * 1998-11-06 ptl */ HDprintf("I/O request size is %1.1fMB\n", - (double)(hssize_t)(size[0] * size[1]) / (double)1024.0F * (double)1024); + (double)(hssize_t)(size[0] * size[1]) / (double)1024.0F * (double)1024); /* Open the files */ file = H5Fcreate(HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); HDassert(file >= 0); - fd = HDopen(RAW_FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666); + fd = HDopen(RAW_FILE_NAME, O_RDWR | O_CREAT | O_TRUNC, 0666); HDassert(fd >= 0); /* Create the dataset */ @@ -180,7 +168,6 @@ main(void) /* initial fill for lazy malloc */ HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); - /* Fill raw */ synchronize(); #ifdef H5_HAVE_GETRUSAGE @@ -188,10 +175,10 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "fill raw"); - for(u = 0; u < nwrite; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); + for (u = 0; u < nwrite; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -200,10 +187,9 @@ main(void) HDputc('\n', stderr); print_stats("fill raw", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); - + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Fill hdf5 */ synchronize(); @@ -212,12 +198,11 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "fill hdf5"); - for(u = 0; u < nread; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert(status >= 0); + for (u = 0; u < nread; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -226,9 +211,9 @@ main(void) HDputc('\n', stderr); print_stats("fill hdf5", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Write the raw dataset */ synchronize(); @@ -237,13 +222,13 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "out raw"); - for(u = 0; u < nwrite; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek(fd, (off_t)0, SEEK_SET); - HDassert(0 == offset); - n = HDwrite(fd, the_data, (size_t)(size[0] * size[1])); - HDassert(n >= 0 && (size_t)n == (size[0] * size[1])); + for (u = 0; u < nwrite; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek(fd, (off_t)0, SEEK_SET); + HDassert(0 == offset); + n = HDwrite(fd, the_data, (size_t)(size[0] * size[1])); + HDassert(n >= 0 && (size_t)n == (size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -252,9 +237,9 @@ main(void) HDputc('\n', stderr); print_stats("out raw", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Write the hdf5 dataset */ synchronize(); @@ -263,12 +248,11 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "out hdf5"); - for(u = 0; u < nwrite; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - status = H5Dwrite(dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, - H5P_DEFAULT, the_data); - HDassert(status >= 0); + for (u = 0; u < nwrite; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dwrite(dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -277,9 +261,9 @@ main(void) HDputc('\n', stderr); print_stats("out hdf5", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read the raw dataset */ synchronize(); @@ -288,13 +272,13 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "in raw"); - for(u = 0; u < nread; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek(fd, (off_t)0, SEEK_SET); - HDassert(0 == offset); - n = HDread(fd, the_data, (size_t)(size[0] * size[1])); - HDassert(n >= 0 && (size_t)n == (size[0] * size[1])); + for (u = 0; u < nread; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek(fd, (off_t)0, SEEK_SET); + HDassert(0 == offset); + n = HDread(fd, the_data, (size_t)(size[0] * size[1])); + HDassert(n >= 0 && (size_t)n == (size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -303,10 +287,9 @@ main(void) HDputc('\n', stderr); print_stats("in raw", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); - + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read the hdf5 dataset */ synchronize(); @@ -315,12 +298,11 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "in hdf5"); - for(u = 0; u < nread; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert(status >= 0); + for (u = 0; u < nread; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -329,15 +311,15 @@ main(void) HDputc('\n', stderr); print_stats("in hdf5", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read hyperslab */ HDassert(size[0] > 20 && size[1] > 20); start[0] = start[1] = 10; count[0] = count[1] = size[0] - 20; - status = H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL); + status = H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL); HDassert(status >= 0); synchronize(); #ifdef H5_HAVE_GETRUSAGE @@ -345,12 +327,11 @@ main(void) #endif t_start = H5_get_time(); HDfprintf(stderr, HEADING, "in hdf5 partial"); - for(u = 0; u < nread; u++) { - HDputc(PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert(status >= 0); + for (u = 0; u < nread; u++) { + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -359,9 +340,9 @@ main(void) HDputc('\n', stderr); print_stats("in hdf5 partial", #ifdef H5_HAVE_GETRUSAGE - &r_start, &r_stop, + &r_start, &r_stop, #endif /* H5_HAVE_GETRUSAGE */ - t_start, t_stop, (size_t)(nread * size[0] * size[1])); + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Close everything */ HDclose(fd); @@ -374,4 +355,3 @@ main(void) return 0; } - diff --git a/tools/test/perform/overhead.c b/tools/test/perform/overhead.c index 58558a5..ea866bd 100644 --- a/tools/test/perform/overhead.c +++ b/tools/test/perform/overhead.c @@ -24,49 +24,41 @@ #include "H5private.h" #ifdef H5_STDC_HEADERS -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include #endif #ifdef H5_HAVE_IO_H -# include +#include #endif #ifdef H5_HAVE_UNISTD_H -# include -# include +#include +#include #endif /* Solaris Studio defines attribute, but for the attributes we need */ #if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus || defined(__SUNPRO_C) -# undef __attribute__ -# define __attribute__(X) /*void*/ -# define H5_ATTR_UNUSED /*void*/ +#undef __attribute__ +#define __attribute__(X) /*void*/ +#define H5_ATTR_UNUSED /*void*/ #else -# define H5_ATTR_UNUSED __attribute__((unused)) +#define H5_ATTR_UNUSED __attribute__((unused)) #endif -#define FILE_NAME_1 "overhead.h5" +#define FILE_NAME_1 "overhead.h5" #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif /* FALSE */ #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif /* TRUE */ -typedef enum fill_t { - FILL_ALL, - FILL_FORWARD, - FILL_REVERSE, - FILL_INWARD, - FILL_OUTWARD, - FILL_RANDOM -} fill_t; +typedef enum fill_t { FILL_ALL, FILL_FORWARD, FILL_REVERSE, FILL_INWARD, FILL_OUTWARD, FILL_RANDOM } fill_t; - /*------------------------------------------------------------------------- * Function: usage * @@ -84,8 +76,7 @@ typedef enum fill_t { static void usage(const char *prog) { - HDfprintf(stderr, "usage: %s [STYLE|cache] [LEFT [MIDDLE [RIGHT]]]\n", - prog); + HDfprintf(stderr, "usage: %s [STYLE|cache] [LEFT [MIDDLE [RIGHT]]]\n", prog); HDfprintf(stderr, "\ STYLE is the order that the dataset is filled and should be one of:\n\ forward -- Fill the dataset from lowest address to highest\n\ @@ -117,7 +108,6 @@ usage(const char *prog) exit(1); } - /*------------------------------------------------------------------------- * Function: cleanup * @@ -133,14 +123,13 @@ usage(const char *prog) *------------------------------------------------------------------------- */ static void -cleanup (void) +cleanup(void) { - if (!getenv ("HDF5_NOCLEANUP")) { - remove (FILE_NAME_1); + if (!getenv("HDF5_NOCLEANUP")) { + remove(FILE_NAME_1); } } - /*------------------------------------------------------------------------- * Function: display_error_cb * @@ -158,15 +147,14 @@ cleanup (void) *------------------------------------------------------------------------- */ static herr_t -display_error_cb (hid_t estack, void H5_ATTR_UNUSED *client_data) +display_error_cb(hid_t estack, void H5_ATTR_UNUSED *client_data) { - puts ("*FAILED*"); + puts("*FAILED*"); H5Eprint2(estack, stdout); return 0; } - /*------------------------------------------------------------------------- * Function: test * @@ -184,92 +172,103 @@ display_error_cb (hid_t estack, void H5_ATTR_UNUSED *client_data) *------------------------------------------------------------------------- */ static int -test(fill_t fill_style, const double splits[], - hbool_t verbose, hbool_t use_rdcc) +test(fill_t fill_style, const double splits[], hbool_t verbose, hbool_t use_rdcc) { - hid_t file = (-1), fapl = (-1), dcpl = (-1), xfer = (-1), mspace = (-1), fspace = (-1), dset = (-1); - hsize_t ch_size[1] = {1}; /*chunk size */ - hsize_t cur_size[1] = {1000}; /*current dataset size */ - hsize_t max_size[1] = {H5S_UNLIMITED}; /*maximum dataset size */ - hsize_t hs_start[1]; /*hyperslab start offset*/ - hsize_t hs_count[1] = {1}; /*hyperslab nelmts */ - int fd = (-1); /*h5 file direct */ - int *had = NULL; /*for random filling */ - const char *sname=NULL; /*fill style nam */ - int mdc_nelmts; /*num meta objs to cache*/ - hsize_t i, k; - int j; - h5_stat_t sb; + hid_t file = (-1), fapl = (-1), dcpl = (-1), xfer = (-1), mspace = (-1), fspace = (-1), dset = (-1); + hsize_t ch_size[1] = {1}; /*chunk size */ + hsize_t cur_size[1] = {1000}; /*current dataset size */ + hsize_t max_size[1] = {H5S_UNLIMITED}; /*maximum dataset size */ + hsize_t hs_start[1]; /*hyperslab start offset*/ + hsize_t hs_count[1] = {1}; /*hyperslab nelmts */ + int fd = (-1); /*h5 file direct */ + int * had = NULL; /*for random filling */ + const char *sname = NULL; /*fill style nam */ + int mdc_nelmts; /*num meta objs to cache*/ + hsize_t i, k; + int j; + h5_stat_t sb; - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - if(!use_rdcc) { - if(H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL) < 0) goto error; - if(H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0F) < 0) goto error; + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if (!use_rdcc) { + if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL) < 0) + goto error; + if (H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0F) < 0) + goto error; } - if((file = H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 1, ch_size) < 0) goto error; - if((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pset_btree_ratios(xfer, splits[0], splits[1], splits[2]) < 0) goto error; - if((fspace = H5Screate_simple(1, cur_size, max_size)) < 0) goto error; - if((mspace = H5Screate_simple(1, ch_size, ch_size)) < 0) goto error; - if((dset = H5Dcreate2(file, "chunked", H5T_NATIVE_INT, - fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if ((fd=HDopen(FILE_NAME_1, O_RDONLY, 0666)) < 0) goto error; + if ((file = H5Fcreate(FILE_NAME_1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if (H5Pset_chunk(dcpl, 1, ch_size) < 0) + goto error; + if ((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_btree_ratios(xfer, splits[0], splits[1], splits[2]) < 0) + goto error; + if ((fspace = H5Screate_simple(1, cur_size, max_size)) < 0) + goto error; + if ((mspace = H5Screate_simple(1, ch_size, ch_size)) < 0) + goto error; + if ((dset = H5Dcreate2(file, "chunked", H5T_NATIVE_INT, fspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if ((fd = HDopen(FILE_NAME_1, O_RDONLY, 0666)) < 0) + goto error; - if(FILL_RANDOM==fill_style) + if (FILL_RANDOM == fill_style) had = (int *)calloc((size_t)cur_size[0], sizeof(int)); - for (i=1; i<=cur_size[0]; i++) { + for (i = 1; i <= cur_size[0]; i++) { /* Decide which chunk to write to */ switch (fill_style) { - case FILL_FORWARD: - hs_start[0] = i-1; - break; - case FILL_REVERSE: - hs_start[0] = cur_size[0]-i; - break; - case FILL_INWARD: - hs_start[0] = i%2 ? i/2 : cur_size[0]-i/2; - break; - case FILL_OUTWARD: - k = (cur_size[0] - i) + 1; - hs_start[0] = k % 2 ? (k / 2) : (hsize_t)((hssize_t)cur_size[0] - (hssize_t)(k / 2)); - break; - case FILL_RANDOM: - for (j=HDrand()%(int)cur_size[0]; had[j]; j=(j+1)%(int)cur_size[0]) - /*void*/; - hs_start[0] = (hsize_t)j; - had[j] = 1; - break; - case FILL_ALL: - abort(); - default: - /* unknown request */ - HDfprintf(stderr, "Unknown fill style\n"); - goto error; - break; + case FILL_FORWARD: + hs_start[0] = i - 1; + break; + case FILL_REVERSE: + hs_start[0] = cur_size[0] - i; + break; + case FILL_INWARD: + hs_start[0] = i % 2 ? i / 2 : cur_size[0] - i / 2; + break; + case FILL_OUTWARD: + k = (cur_size[0] - i) + 1; + hs_start[0] = k % 2 ? (k / 2) : (hsize_t)((hssize_t)cur_size[0] - (hssize_t)(k / 2)); + break; + case FILL_RANDOM: + for (j = HDrand() % (int)cur_size[0]; had[j]; j = (j + 1) % (int)cur_size[0]) + /*void*/; + hs_start[0] = (hsize_t)j; + had[j] = 1; + break; + case FILL_ALL: + abort(); + default: + /* unknown request */ + HDfprintf(stderr, "Unknown fill style\n"); + goto error; + break; } /* Write the chunk */ - if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_start, NULL, - hs_count, NULL) < 0) goto error; + if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_start, NULL, hs_count, NULL) < 0) + goto error; if (H5Dwrite(dset, H5T_NATIVE_INT, mspace, fspace, xfer, &i) < 0) { goto error; } /* Determine overhead */ if (verbose) { - if (H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; - if (HDfstat(fd, &sb) < 0) goto error; - printf("%4lu %8.3f ***\n", - (unsigned long)i, - (double)(sb.st_size - (HDoff_t)(i * sizeof(int))) / (double)i); + if (H5Fflush(file, H5F_SCOPE_LOCAL) < 0) + goto error; + if (HDfstat(fd, &sb) < 0) + goto error; + printf("%4lu %8.3f ***\n", (unsigned long)i, + (double)(sb.st_size - (HDoff_t)(i * sizeof(int))) / (double)i); } } - if(had) { + if (had) { free(had); had = NULL; } /* end if */ @@ -283,53 +282,52 @@ test(fill_t fill_style, const double splits[], if (!verbose) { switch (fill_style) { - case FILL_FORWARD: - sname = "forward"; - break; - case FILL_REVERSE: - sname = "reverse"; - break; - case FILL_INWARD: - sname = "inward"; - break; - case FILL_OUTWARD: - sname = "outward"; - break; - case FILL_RANDOM: - sname = "random"; - break; - case FILL_ALL: - abort(); - default: - /* unknown request */ - HDfprintf(stderr, "Unknown fill style\n"); - goto error; - break; + case FILL_FORWARD: + sname = "forward"; + break; + case FILL_REVERSE: + sname = "reverse"; + break; + case FILL_INWARD: + sname = "inward"; + break; + case FILL_OUTWARD: + sname = "outward"; + break; + case FILL_RANDOM: + sname = "random"; + break; + case FILL_ALL: + abort(); + default: + /* unknown request */ + HDfprintf(stderr, "Unknown fill style\n"); + goto error; + break; } - if (HDfstat(fd, &sb) < 0) goto error; + if (HDfstat(fd, &sb) < 0) + goto error; printf("%-7s %8.3f\n", sname, - (double)(sb.st_size - (HDoff_t)(cur_size[0] * sizeof(int))) / - (double)cur_size[0]); + (double)(sb.st_size - (HDoff_t)(cur_size[0] * sizeof(int))) / (double)cur_size[0]); } HDclose(fd); return 0; - error: +error: H5Dclose(dset); H5Sclose(mspace); H5Sclose(fspace); H5Pclose(dcpl); H5Pclose(xfer); H5Fclose(file); - if(had) + if (had) free(had); HDclose(fd); return 1; } - /*------------------------------------------------------------------------- * Function: main * @@ -349,58 +347,70 @@ test(fill_t fill_style, const double splits[], int main(int argc, char *argv[]) { - hid_t xfer; + hid_t xfer; fill_t fill_style = FILL_ALL; - hbool_t use_cache = FALSE; + hbool_t use_cache = FALSE; double splits[3]; - int i, j, nerrors=0; + int i, j, nerrors = 0; /* Default split ratios */ H5Eset_auto2(H5E_DEFAULT, display_error_cb, NULL); - if((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; - if(H5Pget_btree_ratios(xfer, splits+0, splits+1, splits+2) < 0) goto error; - if(H5Pclose(xfer) < 0) goto error; + if ((xfer = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pget_btree_ratios(xfer, splits + 0, splits + 1, splits + 2) < 0) + goto error; + if (H5Pclose(xfer) < 0) + goto error; /* Parse command-line options */ - for(i = 1, j = 0; i < argc; i++) { + for (i = 1, j = 0; i < argc; i++) { if (!strcmp(argv[i], "forward")) { fill_style = FILL_FORWARD; - } else if (!strcmp(argv[i], "reverse")) { + } + else if (!strcmp(argv[i], "reverse")) { fill_style = FILL_REVERSE; - } else if (!strcmp(argv[i], "inward")) { + } + else if (!strcmp(argv[i], "inward")) { fill_style = FILL_INWARD; - } else if (!strcmp(argv[i], "outward")) { + } + else if (!strcmp(argv[i], "outward")) { fill_style = FILL_OUTWARD; - } else if (!strcmp(argv[i], "random")) { + } + else if (!strcmp(argv[i], "random")) { fill_style = FILL_RANDOM; - } else if (!strcmp(argv[i], "cache")) { + } + else if (!strcmp(argv[i], "cache")) { use_cache = TRUE; - } else if (j<3 && (isdigit(argv[i][0]) || '.'==argv[i][0])) { + } + else if (j < 3 && (isdigit(argv[i][0]) || '.' == argv[i][0])) { splits[j++] = strtod(argv[i], NULL); - } else { + } + else { usage(argv[0]); } } - if (FILL_ALL==fill_style) { + if (FILL_ALL == fill_style) { printf("%-7s %8s\n", "Style", "Bytes/Chunk"); printf("%-7s %8s\n", "-----", "-----------"); nerrors += test(FILL_FORWARD, splits, FALSE, use_cache); nerrors += test(FILL_REVERSE, splits, FALSE, use_cache); - nerrors += test(FILL_INWARD, splits, FALSE, use_cache); + nerrors += test(FILL_INWARD, splits, FALSE, use_cache); nerrors += test(FILL_OUTWARD, splits, FALSE, use_cache); - nerrors += test(FILL_RANDOM, splits, FALSE, use_cache); + nerrors += test(FILL_RANDOM, splits, FALSE, use_cache); } else { - if (use_cache) usage(argv[0]); - nerrors += test(fill_style, splits, TRUE, FALSE); + if (use_cache) + usage(argv[0]); + nerrors += test(fill_style, splits, TRUE, FALSE); } - if (nerrors>0) goto error; + if (nerrors > 0) + goto error; cleanup(); return 0; - error: +error: HDfprintf(stderr, "*** ERRORS DETECTED ***\n"); return 1; } diff --git a/tools/test/perform/perf.c b/tools/test/perform/perf.c index 364836f..6d467e1 100644 --- a/tools/test/perform/perf.c +++ b/tools/test/perform/perf.c @@ -44,17 +44,17 @@ #endif #if defined(H5_TIME_WITH_SYS_TIME) -# include -# include +#include +#include #elif defined(H5_HAVE_SYS_TIME_H) -# include +#include #else -# include +#include #endif #include -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ -# include +#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ +#include #endif /* Macro definitions */ @@ -62,50 +62,46 @@ * if val is false (0), print mesg and if fatal is true (non-zero), die. */ #define H5FATAL 1 -#define VRFY(val, mesg, fatal) do { \ - if (!val) { \ - printf("Proc %d: ", mynod); \ - printf("*** Assertion failed (%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ - if (fatal){ \ - fflush(stdout); \ - goto die_jar_jar_die; \ - } \ - } \ -} while(0) -#define RANK 1 +#define VRFY(val, mesg, fatal) \ + do { \ + if (!val) { \ + printf("Proc %d: ", mynod); \ + printf("*** Assertion failed (%s) at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \ + if (fatal) { \ + fflush(stdout); \ + goto die_jar_jar_die; \ + } \ + } \ + } while (0) +#define RANK 1 #define MAX_PATH 1024 -hsize_t dims[RANK]; /* dataset dim sizes */ +hsize_t dims[RANK]; /* dataset dim sizes */ hsize_t block[RANK], stride[RANK], count[RANK]; hsize_t start[RANK]; -hid_t fid; /* HDF5 file ID */ -hid_t acc_tpl; /* File access templates */ -hid_t sid; /* Dataspace ID */ -hid_t file_dataspace; /* File dataspace ID */ -hid_t mem_dataspace; /* memory dataspace ID */ -hid_t dataset; /* Dataset ID */ -hsize_t opt_alignment = 1; -hsize_t opt_threshold = 1; -int opt_split_vfd = 0; -char *meta_ext, *raw_ext; /* holds the meta and raw file extension if */ - /* opt_split_vfd is set */ - +hid_t fid; /* HDF5 file ID */ +hid_t acc_tpl; /* File access templates */ +hid_t sid; /* Dataspace ID */ +hid_t file_dataspace; /* File dataspace ID */ +hid_t mem_dataspace; /* memory dataspace ID */ +hid_t dataset; /* Dataset ID */ +hsize_t opt_alignment = 1; +hsize_t opt_threshold = 1; +int opt_split_vfd = 0; +char * meta_ext, *raw_ext; /* holds the meta and raw file extension if */ + /* opt_split_vfd is set */ /* DEFAULT VALUES FOR OPTIONS */ -int64_t opt_block = 1048576*16; -int opt_iter = 1; -int opt_stripe = -1; -int opt_correct = 0; -int amode = O_RDWR | O_CREAT; -char opt_file[256] = "perftest.out"; +int64_t opt_block = 1048576 * 16; +int opt_iter = 1; +int opt_stripe = -1; +int opt_correct = 0; +int amode = O_RDWR | O_CREAT; +char opt_file[256] = "perftest.out"; char opt_pvfstab[256] = "notset"; -int opt_pvfstab_set = 0; +int opt_pvfstab_set = 0; -const char *FILENAME[] = { - opt_file, - NULL -}; +const char *FILENAME[] = {opt_file, NULL}; /* function prototypes */ static int parse_args(int argc, char **argv); @@ -115,42 +111,44 @@ static int parse_args(int argc, char **argv); extern char *optarg; #endif -int main(int argc, char **argv) +int +main(int argc, char **argv) { - char *buf, *tmp, *buf2 = NULL, *tmp2 = NULL, *check; - int i, j, mynod=0, nprocs=1, my_correct = 1, correct, myerrno; - double stim, etim; - double write_tim = 0; - double read_tim = 0; - double read_bw, write_bw; - double max_read_tim, max_write_tim; - double min_read_tim, min_write_tim; - double ave_read_tim, ave_write_tim; + char * buf, *tmp, *buf2 = NULL, *tmp2 = NULL, *check; + int i, j, mynod = 0, nprocs = 1, my_correct = 1, correct, myerrno; + double stim, etim; + double write_tim = 0; + double read_tim = 0; + double read_bw, write_bw; + double max_read_tim, max_write_tim; + double min_read_tim, min_write_tim; + double ave_read_tim, ave_write_tim; int64_t iter_jump = 0; - char filename[MAX_PATH]; - herr_t ret; /* Generic return value */ + char filename[MAX_PATH]; + herr_t ret; /* Generic return value */ /* startup MPI and determine the rank of this process */ - MPI_Init(&argc,&argv); + MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &mynod); /* parse the command line arguments */ parse_args(argc, argv); - if (mynod == 0) printf("# Using hdf5-io calls.\n"); + if (mynod == 0) + printf("# Using hdf5-io calls.\n"); - /* kindof a weird hack- if the location of the pvfstab file was - * specified on the command line, then spit out this location into - * the appropriate environment variable: */ + /* kindof a weird hack- if the location of the pvfstab file was + * specified on the command line, then spit out this location into + * the appropriate environment variable: */ #if H5_HAVE_SETENV -/* no setenv or unsetenv */ + /* no setenv or unsetenv */ if (opt_pvfstab_set) { - if((setenv("PVFSTAB_FILE", opt_pvfstab, 1)) < 0){ - perror("setenv"); - goto die_jar_jar_die; - } + if ((setenv("PVFSTAB_FILE", opt_pvfstab, 1)) < 0) { + perror("setenv"); + goto die_jar_jar_die; + } } #endif @@ -160,55 +158,56 @@ int main(int argc, char **argv) iter_jump = nprocs * opt_block; /* setup a buffer of data to write */ - if (!(tmp = (char *) malloc((size_t)opt_block + 256))) { - perror("malloc"); - goto die_jar_jar_die; + if (!(tmp = (char *)malloc((size_t)opt_block + 256))) { + perror("malloc"); + goto die_jar_jar_die; } - buf = tmp + 128 - (((long)tmp) % 128); /* align buffer */ + buf = tmp + 128 - (((long)tmp) % 128); /* align buffer */ if (opt_correct) { - /* do the same buffer setup for verifiable data */ - if (!(tmp2 = (char *) malloc((size_t)opt_block + 256))) { - perror("malloc2"); - goto die_jar_jar_die; - } - buf2 = tmp + 128 - (((long)tmp) % 128); + /* do the same buffer setup for verifiable data */ + if (!(tmp2 = (char *)malloc((size_t)opt_block + 256))) { + perror("malloc2"); + goto die_jar_jar_die; + } + buf2 = tmp + 128 - (((long)tmp) % 128); } /* setup file access template with parallel IO access. */ - if (opt_split_vfd){ - hid_t mpio_pl; - - mpio_pl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment*opt_threshold != 1){ - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); - } + if (opt_split_vfd) { + hid_t mpio_pl; + + mpio_pl = H5Pcreate(H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL); + VRFY((ret >= 0), "", H5FATAL); + + /* set optional allocation alignment */ + if (opt_alignment * opt_threshold != 1) { + ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment); + VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); + } - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl); - VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL); - ret = H5Pclose(mpio_pl); - VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL); - }else{ - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment*opt_threshold != 1){ - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); + /* setup file access template */ + acc_tpl = H5Pcreate(H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl); + VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL); + ret = H5Pclose(mpio_pl); + VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL); } + else { + /* setup file access template */ + acc_tpl = H5Pcreate(H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); + VRFY((ret >= 0), "", H5FATAL); + + /* set optional allocation alignment */ + if (opt_alignment * opt_threshold != 1) { + ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment); + VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); + } } h5_fixname_no_suffix(FILENAME[0], acc_tpl, filename, sizeof filename); @@ -219,14 +218,13 @@ int main(int argc, char **argv) /* define a contiquous dataset of opt_iter*nprocs*opt_block chars */ dims[0] = (hsize_t)opt_iter * (hsize_t)nprocs * (hsize_t)opt_block; - sid = H5Screate_simple(RANK, dims, NULL); + sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded", H5FATAL); - dataset = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_CHAR, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dcreate2 succeeded", H5FATAL); /* create the memory dataspace and the file dataspace */ - dims[0] = (hsize_t)opt_block; + dims[0] = (hsize_t)opt_block; mem_dataspace = H5Screate_simple(RANK, dims, NULL); VRFY((mem_dataspace >= 0), "", H5FATAL); file_dataspace = H5Dget_space(dataset); @@ -235,48 +233,46 @@ int main(int argc, char **argv) /* now each process writes a block of opt_block chars in round robbin * fashion until the whole dataset is covered. */ - for(j=0; j < opt_iter; j++) { + for (j = 0; j < opt_iter; j++) { /* setup a file dataspace selection */ - start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); + start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); stride[0] = block[0] = (hsize_t)opt_block; - count[0]= 1; - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); + count[0] = 1; + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL); - if (opt_correct) /* fill in buffer for iteration */ { - for (i=mynod+j, check=buf; i= 0), "H5Dwrite dataset1 succeeded", !H5FATAL); - /* discover the ending time of the operation */ - etim = MPI_Wtime(); + /* discover the ending time of the operation */ + etim = MPI_Wtime(); - write_tim += (etim - stim); + write_tim += (etim - stim); - /* we are done with this "write" iteration */ + /* we are done with this "write" iteration */ } /* close dataset and file */ - ret=H5Dclose(dataset); + ret = H5Dclose(dataset); VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL); - ret=H5Fclose(fid); + ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL); - - /* wait for everyone to synchronize at this point */ MPI_Barrier(MPI_COMM_WORLD); /* reopen the file for reading */ - fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); VRFY((fid >= 0), "", H5FATAL); /* open the dataset */ @@ -288,119 +284,111 @@ int main(int argc, char **argv) */ /* we are going to repeat the read the same pattern the write used */ - for (j=0; j < opt_iter; j++) { + for (j = 0; j < opt_iter; j++) { /* setup a file dataspace selection */ - start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); + start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); stride[0] = block[0] = (hsize_t)opt_block; - count[0]= 1; - ret=H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); + count[0] = 1; + ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL); - /* seek to the appropriate spot give the current iteration and - * rank within the MPI processes */ + /* seek to the appropriate spot give the current iteration and + * rank within the MPI processes */ - /* discover the start time */ - MPI_Barrier(MPI_COMM_WORLD); - stim = MPI_Wtime(); + /* discover the start time */ + MPI_Barrier(MPI_COMM_WORLD); + stim = MPI_Wtime(); /* read in the file data */ - if (!opt_correct){ + if (!opt_correct) { ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf); } - else{ + else { ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf2); } myerrno = errno; /* discover the end time */ - etim = MPI_Wtime(); - read_tim += (etim - stim); + etim = MPI_Wtime(); + read_tim += (etim - stim); VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL); - - if (ret < 0) HDfprintf(stderr, "node %d, read error, loc = %Ld: %s\n", - mynod, mynod*opt_block, strerror(myerrno)); + if (ret < 0) + HDfprintf(stderr, "node %d, read error, loc = %Ld: %s\n", mynod, mynod * opt_block, + strerror(myerrno)); /* if the user wanted to check correctness, compare the write * buffer to the read buffer */ if (opt_correct && memcmp(buf, buf2, (size_t)opt_block)) { - HDfprintf(stderr, "node %d, correctness test failed\n", mynod); - my_correct = 0; - MPI_Allreduce(&my_correct, &correct, 1, MPI_INT, MPI_MIN, - MPI_COMM_WORLD); + HDfprintf(stderr, "node %d, correctness test failed\n", mynod); + my_correct = 0; + MPI_Allreduce(&my_correct, &correct, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); } /* we are done with this read iteration */ } /* close dataset and file */ - ret=H5Dclose(dataset); + ret = H5Dclose(dataset); VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL); - ret=H5Fclose(fid); + ret = H5Fclose(fid); VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL); - ret=H5Pclose(acc_tpl); + ret = H5Pclose(acc_tpl); VRFY((ret >= 0), "H5Pclose succeeded", H5FATAL); /* compute the read and write times */ - MPI_Allreduce(&read_tim, &max_read_tim, 1, MPI_DOUBLE, MPI_MAX, - MPI_COMM_WORLD); - MPI_Allreduce(&read_tim, &min_read_tim, 1, MPI_DOUBLE, MPI_MIN, - MPI_COMM_WORLD); - MPI_Allreduce(&read_tim, &ave_read_tim, 1, MPI_DOUBLE, MPI_SUM, - MPI_COMM_WORLD); + MPI_Allreduce(&read_tim, &max_read_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + MPI_Allreduce(&read_tim, &min_read_tim, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + MPI_Allreduce(&read_tim, &ave_read_tim, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); /* calculate the average from the sum */ ave_read_tim = ave_read_tim / nprocs; - MPI_Allreduce(&write_tim, &max_write_tim, 1, MPI_DOUBLE, MPI_MAX, - MPI_COMM_WORLD); - MPI_Allreduce(&write_tim, &min_write_tim, 1, MPI_DOUBLE, MPI_MIN, - MPI_COMM_WORLD); - MPI_Allreduce(&write_tim, &ave_write_tim, 1, MPI_DOUBLE, MPI_SUM, - MPI_COMM_WORLD); + MPI_Allreduce(&write_tim, &max_write_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + MPI_Allreduce(&write_tim, &min_write_tim, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + MPI_Allreduce(&write_tim, &ave_write_tim, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); /* calculate the average from the sum */ ave_write_tim = ave_write_tim / nprocs; /* print out the results on one node */ if (mynod == 0) { - read_bw = (double)((int64_t)(opt_block*nprocs*opt_iter))/(max_read_tim*1000000.0); - write_bw = (double)((int64_t)(opt_block*nprocs*opt_iter))/(max_write_tim*1000000.0); + read_bw = (double)((int64_t)(opt_block * nprocs * opt_iter)) / (max_read_tim * 1000000.0); + write_bw = (double)((int64_t)(opt_block * nprocs * opt_iter)) / (max_write_tim * 1000000.0); - printf("nr_procs = %d, nr_iter = %d, blk_sz = %ld\n", nprocs, - opt_iter, (long)opt_block); + printf("nr_procs = %d, nr_iter = %d, blk_sz = %ld\n", nprocs, opt_iter, (long)opt_block); - printf("# total_size = %ld\n", (long)(opt_block*nprocs*opt_iter)); + printf("# total_size = %ld\n", (long)(opt_block * nprocs * opt_iter)); - printf("# Write: min_time = %f, max_time = %f, mean_time = %f\n", - min_write_tim, max_write_tim, ave_write_tim); - printf("# Read: min_time = %f, max_time = %f, mean_time = %f\n", - min_read_tim, max_read_tim, ave_read_tim); + printf("# Write: min_time = %f, max_time = %f, mean_time = %f\n", min_write_tim, max_write_tim, + ave_write_tim); + printf("# Read: min_time = %f, max_time = %f, mean_time = %f\n", min_read_tim, max_read_tim, + ave_read_tim); - printf("Write bandwidth = %f Mbytes/sec\n", write_bw); - printf("Read bandwidth = %f Mbytes/sec\n", read_bw); + printf("Write bandwidth = %f Mbytes/sec\n", write_bw); + printf("Read bandwidth = %f Mbytes/sec\n", read_bw); - if (opt_correct) { - printf("Correctness test %s.\n", correct ? "passed" : "failed"); - } + if (opt_correct) { + printf("Correctness test %s.\n", correct ? "passed" : "failed"); + } } - die_jar_jar_die: #if H5_HAVE_SETENV -/* no setenv or unsetenv */ + /* no setenv or unsetenv */ /* clear the environment variable if it was set earlier */ - if (opt_pvfstab_set){ - unsetenv("PVFSTAB_FILE"); + if (opt_pvfstab_set) { + unsetenv("PVFSTAB_FILE"); } #endif free(tmp); - if (opt_correct) free(tmp2); + if (opt_correct) + free(tmp2); MPI_Finalize(); - return(0); + return (0); } static int @@ -432,32 +420,29 @@ parse_args(int argc, char **argv) * e.g., -a4096/512 allocate at 4096 bytes * boundary if request size >= 512. */ - { - char *p; + { + char *p; - opt_alignment = (hsize_t)HDatoi(optarg); - if(NULL != (p = (char*)HDstrchr(optarg, '/'))) - opt_threshold = (hsize_t)HDatoi(p + 1); - } - HDfprintf(stdout, - "alignment/threshold=%Hu/%Hu\n", - opt_alignment, opt_threshold); + opt_alignment = (hsize_t)HDatoi(optarg); + if (NULL != (p = (char *)HDstrchr(optarg, '/'))) + opt_threshold = (hsize_t)HDatoi(p + 1); + } + HDfprintf(stdout, "alignment/threshold=%Hu/%Hu\n", opt_alignment, opt_threshold); break; case '2': /* use 2-files, i.e., split file driver */ - opt_split_vfd=1; + opt_split_vfd = 1; /* get meta and raw file extension. */ /* syntax is , */ meta_ext = raw_ext = optarg; - while (*raw_ext != '\0'){ - if (*raw_ext == ','){ + while (*raw_ext != '\0') { + if (*raw_ext == ',') { *raw_ext = '\0'; raw_ext++; break; } raw_ext++; } - printf("split-file-vfd used: %s,%s\n", - meta_ext, raw_ext); + printf("split-file-vfd used: %s,%s\n", meta_ext, raw_ext); break; case 'c': /* correctness */ opt_correct = 1; @@ -468,7 +453,7 @@ parse_args(int argc, char **argv) } } - return(0); + return (0); } /* @@ -479,13 +464,12 @@ parse_args(int argc, char **argv) * End: */ -#else /* H5_HAVE_PARALLEL */ +#else /* H5_HAVE_PARALLEL */ /* dummy program since H5_HAVE_PARALLEL is not configured in */ int main(int H5_ATTR_UNUSED argc, char H5_ATTR_UNUSED **argv) { printf("No parallel performance because parallel is not configured in\n"); - return(0); + return (0); } #endif /* H5_HAVE_PARALLEL */ - diff --git a/tools/test/perform/perf_meta.c b/tools/test/perform/perf_meta.c index b56f074..5052077 100644 --- a/tools/test/perform/perf_meta.c +++ b/tools/test/perform/perf_meta.c @@ -21,39 +21,33 @@ #include "h5test.h" #ifdef H5_HAVE_PARALLEL -#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ -#endif /*H5_HAVE_PARALLEL*/ +#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */ +#endif /*H5_HAVE_PARALLEL*/ /* File_Access_type bits */ -#define FACC_DEFAULT 0x0 /* serial as default */ -#define FACC_MPIO 0x1 /* MPIO */ +#define FACC_DEFAULT 0x0 /* serial as default */ +#define FACC_MPIO 0x1 /* MPIO */ /* Which test to run */ -int RUN_TEST = 0x0; /* all tests as default */ -int TEST_1 = 0x1; /* Test 1 */ -int TEST_2 = 0x2; /* Test 2 */ -int TEST_3 = 0x4; /* Test 3 */ - +int RUN_TEST = 0x0; /* all tests as default */ +int TEST_1 = 0x1; /* Test 1 */ +int TEST_2 = 0x2; /* Test 2 */ +int TEST_3 = 0x4; /* Test 3 */ -const char *FILENAME[] = { - "meta_perf_1", - "meta_perf_2", - "meta_perf_3", - NULL -}; +const char *FILENAME[] = {"meta_perf_1", "meta_perf_2", "meta_perf_3", NULL}; /* Default values for performance. Can be changed through command line options */ -int NUM_DSETS = 16; -int NUM_ATTRS = 8; -int BATCH_ATTRS = 2; -hbool_t flush_dset = FALSE; -hbool_t flush_attr = FALSE; -int nerrors = 0; /* errors count */ -hid_t fapl; +int NUM_DSETS = 16; +int NUM_ATTRS = 8; +int BATCH_ATTRS = 2; +hbool_t flush_dset = FALSE; +hbool_t flush_attr = FALSE; +int nerrors = 0; /* errors count */ +hid_t fapl; /* Data space IDs */ -hid_t space; -hid_t small_space; +hid_t space; +hid_t small_space; /* Performance data */ typedef struct p_time { @@ -68,11 +62,10 @@ typedef struct p_time { /*Test file access type for parallel. MPIO as default */ int facc_type = FACC_DEFAULT; -double retrieve_time(void); -void perf(p_time *perf_t, double start_t, double end_t); -void print_perf(p_time, p_time, p_time); +double retrieve_time(void); +void perf(p_time *perf_t, double start_t, double end_t); +void print_perf(p_time, p_time, p_time); - /*------------------------------------------------------------------------- * Function: parse_options * @@ -91,108 +84,108 @@ parse_options(int argc, char **argv) int t; /* Use default values */ - if(argc==1) - return(0); - - while (--argc){ - if (**(++argv) != '-'){ - break; - }else{ - switch(*(*argv+1)){ - case 'h': /* Help page */ - return(1); - - case 'd': /* Number of datasets */ - NUM_DSETS = atoi((*argv+1)+1); - if (NUM_DSETS < 0){ - nerrors++; - return(1); - } - break; - - case 'a': /* Number of attributes per dataset */ - NUM_ATTRS = atoi((*argv+1)+1); - if (NUM_ATTRS < 0){ - nerrors++; - return(1); - } - break; - - case 'n': /* Number of attributes to be created in batch */ - BATCH_ATTRS = atoi((*argv+1)+1); - if (BATCH_ATTRS < 0){ - nerrors++; - return(1); - } - break; - - case 'm': /* Use the MPI-IO driver */ - facc_type = FACC_MPIO; - break; - - case 'f': /* Call H5Fflush for each dataset or attribute */ - if(!strcmp("a", (*argv+2))) - flush_attr = TRUE; - else if(!strcmp("d", (*argv+2))) - flush_dset = TRUE; - else { - nerrors++; - return(1); - } - break; - - case 't': /* Which test to run */ - t = atoi((*argv+1)+1); - if (t < 1 || t > 3){ - nerrors++; - return(1); - } - if(t == 1) - RUN_TEST |= TEST_1; - else if(t == 2) - RUN_TEST |= TEST_2; - else - RUN_TEST |= TEST_3; - - break; - - default: nerrors++; - return(1); - } - } + if (argc == 1) + return (0); + + while (--argc) { + if (**(++argv) != '-') { + break; + } + else { + switch (*(*argv + 1)) { + case 'h': /* Help page */ + return (1); + + case 'd': /* Number of datasets */ + NUM_DSETS = atoi((*argv + 1) + 1); + if (NUM_DSETS < 0) { + nerrors++; + return (1); + } + break; + + case 'a': /* Number of attributes per dataset */ + NUM_ATTRS = atoi((*argv + 1) + 1); + if (NUM_ATTRS < 0) { + nerrors++; + return (1); + } + break; + + case 'n': /* Number of attributes to be created in batch */ + BATCH_ATTRS = atoi((*argv + 1) + 1); + if (BATCH_ATTRS < 0) { + nerrors++; + return (1); + } + break; + + case 'm': /* Use the MPI-IO driver */ + facc_type = FACC_MPIO; + break; + + case 'f': /* Call H5Fflush for each dataset or attribute */ + if (!strcmp("a", (*argv + 2))) + flush_attr = TRUE; + else if (!strcmp("d", (*argv + 2))) + flush_dset = TRUE; + else { + nerrors++; + return (1); + } + break; + + case 't': /* Which test to run */ + t = atoi((*argv + 1) + 1); + if (t < 1 || t > 3) { + nerrors++; + return (1); + } + if (t == 1) + RUN_TEST |= TEST_1; + else if (t == 2) + RUN_TEST |= TEST_2; + else + RUN_TEST |= TEST_3; + + break; + + default: + nerrors++; + return (1); + } + } } /*while*/ /* Check valid values */ #ifndef H5_HAVE_PARALLEL - if(facc_type == FACC_MPIO) - { + if (facc_type == FACC_MPIO) { nerrors++; - return(1); + return (1); } #endif /*H5_HAVE_PARALLEL*/ - if(NUM_ATTRS && !BATCH_ATTRS) + if (NUM_ATTRS && !BATCH_ATTRS) NUM_ATTRS = 0; - if(!NUM_ATTRS && BATCH_ATTRS) + if (!NUM_ATTRS && BATCH_ATTRS) BATCH_ATTRS = 0; - if(!NUM_DSETS) { + if (!NUM_DSETS) { nerrors++; - return(1); + return (1); } - if(NUM_ATTRS && BATCH_ATTRS) { - if(BATCH_ATTRS > NUM_ATTRS || NUM_ATTRS % BATCH_ATTRS) { - nerrors++; - return(1); + if (NUM_ATTRS && BATCH_ATTRS) { + if (BATCH_ATTRS > NUM_ATTRS || NUM_ATTRS % BATCH_ATTRS) { + nerrors++; + return (1); } } - return(0); + return (0); } - /*------------------------------------------------------------------------- * Function: usage * @@ -212,39 +205,38 @@ usage(void) "[-a]\n" "\t[-n] [-f